From 616b49e1f87f966ad77cc1990b24f679fcc82d8a Mon Sep 17 00:00:00 2001 From: Lamparter Date: Sun, 17 Nov 2024 15:20:49 +0000 Subject: [PATCH 01/84] Code cleanup --- .../IronPythonAnalyzerAnalyzer.cs | 6 +- Src/IronPython.Modules/IterTools.cs | 42 +- Src/IronPython.Modules/ModuleOps.cs | 13 +- Src/IronPython.Modules/NtSignalState.cs | 2 +- .../Properties/AssemblyInfo.cs | 1 - .../ResourceMetaPathImporter.cs | 44 +- Src/IronPython.Modules/SimpleSignalState.cs | 8 +- Src/IronPython.Modules/_bisect.cs | 12 +- Src/IronPython.Modules/_codecs.cs | 3 +- Src/IronPython.Modules/_codecs_cn.cs | 7 - Src/IronPython.Modules/_collections.cs | 33 +- Src/IronPython.Modules/_csv.cs | 2 +- Src/IronPython.Modules/_ctypes/Array.cs | 1 - Src/IronPython.Modules/_ctypes/ArrayType.cs | 1 - Src/IronPython.Modules/_ctypes/CData.cs | 5 +- .../_ctypes/CFuncPtrType.cs | 13 +- Src/IronPython.Modules/_ctypes/Field.cs | 4 +- .../_ctypes/MarshalCleanup.cs | 2 - .../_ctypes/MemoryHolder.cs | 20 +- .../_ctypes/NativeArgument.cs | 6 +- Src/IronPython.Modules/_ctypes/Pointer.cs | 2 +- Src/IronPython.Modules/_ctypes/PointerType.cs | 11 +- Src/IronPython.Modules/_ctypes/SimpleCData.cs | 9 +- Src/IronPython.Modules/_ctypes/SimpleType.cs | 6 +- .../_ctypes/SimpleTypeKind.cs | 2 - Src/IronPython.Modules/_ctypes/StructType.cs | 6 +- Src/IronPython.Modules/_ctypes/Structure.cs | 6 +- Src/IronPython.Modules/_ctypes/Union.cs | 2 +- Src/IronPython.Modules/_ctypes/UnionType.cs | 3 - Src/IronPython.Modules/_datetime.cs | 3 +- Src/IronPython.Modules/_functools.cs | 2 +- Src/IronPython.Modules/_heapq.cs | 7 +- Src/IronPython.Modules/_multibytecodec.cs | 8 - Src/IronPython.Modules/_multiprocessing.cs | 2 - Src/IronPython.Modules/_opcode.cs | 13 +- Src/IronPython.Modules/_random.cs | 2 +- Src/IronPython.Modules/_socket.cs | 40 +- Src/IronPython.Modules/_ssl.cs | 6 +- Src/IronPython.Modules/_struct.cs | 10 +- Src/IronPython.Modules/_warnings.cs | 18 +- Src/IronPython.Modules/_weakref.cs | 27 +- Src/IronPython.Modules/_winapi.cs | 7 +- Src/IronPython.Modules/array.cs | 21 +- Src/IronPython.Modules/atexit.cs | 17 +- Src/IronPython.Modules/bz2/BZ2Compressor.cs | 7 +- Src/IronPython.Modules/bz2/BZ2Decompressor.cs | 3 + Src/IronPython.Modules/bz2/BZ2Module.cs | 3 - .../bz2/dotnetzip/BZip2/BZip2Compressor.cs | 784 +- .../bz2/dotnetzip/BZip2/BZip2InputStream.cs | 576 +- .../bz2/dotnetzip/BZip2/BZip2OutputStream.cs | 128 +- .../bz2/dotnetzip/BZip2/BitWriter.cs | 58 +- .../bz2/dotnetzip/BZip2/CRC32.cs | 230 +- .../BZip2/ParallelBZip2OutputStream.cs | 249 +- .../bz2/dotnetzip/BZip2/Rand.cs | 9 +- Src/IronPython.Modules/gc.cs | 16 +- Src/IronPython.Modules/grp.cs | 31 +- .../hashlib/SHA224Managed.cs | 2 - .../hashlib/SHA384Managed.cs | 1 - Src/IronPython.Modules/hashlib/_hashlib.cs | 1 - Src/IronPython.Modules/marshal.cs | 2 +- Src/IronPython.Modules/math.cs | 6 +- Src/IronPython.Modules/msvcrt.cs | 21 +- Src/IronPython.Modules/nt.cs | 7 +- Src/IronPython.Modules/pwd.cs | 26 +- Src/IronPython.Modules/pyexpat.cs | 2 +- Src/IronPython.Modules/re.cs | 14 +- Src/IronPython.Modules/resource.cs | 34 +- Src/IronPython.Modules/select.cs | 4 +- Src/IronPython.Modules/signal.cs | 6 +- Src/IronPython.Modules/spwd.cs | 22 +- Src/IronPython.Modules/winreg.cs | 5 +- Src/IronPython.Modules/winsound.cs | 3 +- Src/IronPython.Modules/xxsubtype.cs | 11 +- Src/IronPython.Modules/zipimport.cs | 3 +- Src/IronPython.Modules/zlib/Compress.cs | 50 +- Src/IronPython.Modules/zlib/Decompress.cs | 54 +- Src/IronPython.Modules/zlib/ZlibModule.cs | 98 +- .../zlib/zlib.net/Adler32.cs | 110 +- .../zlib/zlib.net/Deflate.cs | 666 +- .../zlib/zlib.net/InfBlocks.cs | 301 +- .../zlib/zlib.net/InfCodes.cs | 1181 +- .../zlib/zlib.net/InfTree.cs | 526 +- .../zlib/zlib.net/Inflate.cs | 657 +- .../zlib/zlib.net/StaticTree.cs | 78 +- Src/IronPython.Modules/zlib/zlib.net/Tree.cs | 423 +- .../zlib/zlib.net/ZStream.cs | 273 +- .../zlib/zlib.net/ZStreamException.cs | 28 +- Src/IronPython.Modules/zlib/zlib.net/Zlib.cs | 344 +- Src/IronPython.SQLite/Connection.cs | 305 +- Src/IronPython.SQLite/Contants.cs | 6 +- Src/IronPython.SQLite/Cursor.cs | 286 +- Src/IronPython.SQLite/Exceptions.cs | 53 +- Src/IronPython.SQLite/Extensions.cs | 12 +- .../Properties/AssemblyInfo.cs | 1 - Src/IronPython.SQLite/Row.cs | 54 +- Src/IronPython.SQLite/Statement.cs | 155 +- Src/IronPython.SQLite/Util.cs | 11 +- Src/IronPython.SQLite/_sqlite.cs | 35 +- Src/IronPython.SQLite/c#sqlite/BtreeInt_h.cs | 1510 +- Src/IronPython.SQLite/c#sqlite/Btree_h.cs | 540 +- Src/IronPython.SQLite/c#sqlite/Delegates.cs | 480 +- Src/IronPython.SQLite/c#sqlite/Hash_h.cs | 249 +- Src/IronPython.SQLite/c#sqlite/VdbeInt_h.cs | 1116 +- Src/IronPython.SQLite/c#sqlite/Vdbe_h.cs | 493 +- Src/IronPython.SQLite/c#sqlite/_Custom.cs | 966 +- Src/IronPython.SQLite/c#sqlite/alter_c.cs | 1625 +- Src/IronPython.SQLite/c#sqlite/analyze_c.cs | 1196 +- Src/IronPython.SQLite/c#sqlite/attach_c.cs | 1114 +- Src/IronPython.SQLite/c#sqlite/auth_c.cs | 70 +- Src/IronPython.SQLite/c#sqlite/backup_c.cs | 1417 +- Src/IronPython.SQLite/c#sqlite/bitvec_c.cs | 967 +- Src/IronPython.SQLite/c#sqlite/btmutex_c.cs | 60 +- Src/IronPython.SQLite/c#sqlite/btree_c.cs | 15612 ++++++++-------- Src/IronPython.SQLite/c#sqlite/build_c.cs | 7459 ++++---- Src/IronPython.SQLite/c#sqlite/callback_c.cs | 946 +- Src/IronPython.SQLite/c#sqlite/complete_c.cs | 526 +- Src/IronPython.SQLite/c#sqlite/crypto.cs | 110 +- Src/IronPython.SQLite/c#sqlite/ctime_c.cs | 145 +- Src/IronPython.SQLite/c#sqlite/date_c.cs | 2368 ++- Src/IronPython.SQLite/c#sqlite/delete_c.cs | 1126 +- Src/IronPython.SQLite/c#sqlite/expr_c.cs | 7834 ++++---- Src/IronPython.SQLite/c#sqlite/fault_c.cs | 190 +- Src/IronPython.SQLite/c#sqlite/fkey_c.cs | 2441 ++- Src/IronPython.SQLite/c#sqlite/func_c.cs | 3462 ++-- Src/IronPython.SQLite/c#sqlite/global_c.cs | 372 +- Src/IronPython.SQLite/c#sqlite/hash_c.cs | 599 +- Src/IronPython.SQLite/c#sqlite/hwtime_c.cs | 107 +- Src/IronPython.SQLite/c#sqlite/insert_c.cs | 3758 ++-- Src/IronPython.SQLite/c#sqlite/journal_c.cs | 74 +- .../c#sqlite/keywordhash_h.cs | 415 +- Src/IronPython.SQLite/c#sqlite/legacy_c.cs | 417 +- Src/IronPython.SQLite/c#sqlite/loadext_c.cs | 1211 +- Src/IronPython.SQLite/c#sqlite/main_c.cs | 5232 +++--- Src/IronPython.SQLite/c#sqlite/malloc_c.cs | 1793 +- Src/IronPython.SQLite/c#sqlite/mem_Pool.cs | 288 +- .../c#sqlite/memjournal_c.cs | 543 +- Src/IronPython.SQLite/c#sqlite/mutex_c.cs | 292 +- Src/IronPython.SQLite/c#sqlite/mutex_h.cs | 128 +- .../c#sqlite/mutex_noop_c.cs | 357 +- Src/IronPython.SQLite/c#sqlite/mutex_w32.cs | 596 +- Src/IronPython.SQLite/c#sqlite/notify_c.cs | 60 +- Src/IronPython.SQLite/c#sqlite/opcodes_c.cs | 21 +- Src/IronPython.SQLite/c#sqlite/opcodes_h.cs | 640 +- Src/IronPython.SQLite/c#sqlite/os_c.cs | 677 +- Src/IronPython.SQLite/c#sqlite/os_common_h.cs | 132 +- Src/IronPython.SQLite/c#sqlite/os_h.cs | 504 +- Src/IronPython.SQLite/c#sqlite/os_win_c.cs | 3943 ++-- Src/IronPython.SQLite/c#sqlite/pager_c.cs | 12345 ++++++------ Src/IronPython.SQLite/c#sqlite/pager_h.cs | 397 +- Src/IronPython.SQLite/c#sqlite/parse_c.cs | 5676 +++--- Src/IronPython.SQLite/c#sqlite/parse_h.cs | 636 +- Src/IronPython.SQLite/c#sqlite/pcache1_c.cs | 1974 +- Src/IronPython.SQLite/c#sqlite/pcache_c.cs | 1208 +- Src/IronPython.SQLite/c#sqlite/pcache_h.cs | 309 +- Src/IronPython.SQLite/c#sqlite/pragma_c.cs | 2699 ++- Src/IronPython.SQLite/c#sqlite/prepare_c.cs | 1729 +- Src/IronPython.SQLite/c#sqlite/printf_c.cs | 2506 ++- Src/IronPython.SQLite/c#sqlite/random_c.cs | 335 +- Src/IronPython.SQLite/c#sqlite/resolve_c.cs | 2431 ++- Src/IronPython.SQLite/c#sqlite/rowset_c.cs | 909 +- Src/IronPython.SQLite/c#sqlite/select_c.cs | 9162 +++++---- Src/IronPython.SQLite/c#sqlite/sqlite3_h.cs | 14735 ++++++++------- Src/IronPython.SQLite/c#sqlite/sqliteInt_h.cs | 7658 ++++---- .../c#sqlite/sqliteLimit_h.cs | 336 +- Src/IronPython.SQLite/c#sqlite/status_c.cs | 473 +- Src/IronPython.SQLite/c#sqlite/table_c.cs | 69 +- Src/IronPython.SQLite/c#sqlite/tokenize_c.cs | 1215 +- Src/IronPython.SQLite/c#sqlite/trigger_c.cs | 2292 ++- Src/IronPython.SQLite/c#sqlite/update_c.cs | 1314 +- Src/IronPython.SQLite/c#sqlite/utf_c.cs | 482 +- Src/IronPython.SQLite/c#sqlite/util_c.cs | 2810 ++- Src/IronPython.SQLite/c#sqlite/vacuum_c.cs | 716 +- Src/IronPython.SQLite/c#sqlite/vdbe_c.cs | 12129 ++++++------ Src/IronPython.SQLite/c#sqlite/vdbeapi_c.cs | 2508 ++- Src/IronPython.SQLite/c#sqlite/vdbeaux_c.cs | 7270 ++++--- Src/IronPython.SQLite/c#sqlite/vdbeblob_c.cs | 58 +- Src/IronPython.SQLite/c#sqlite/vdbemem_c.cs | 2700 ++- Src/IronPython.SQLite/c#sqlite/vdbetrace_c.cs | 322 +- Src/IronPython.SQLite/c#sqlite/vtab_c.cs | 2195 +-- Src/IronPython.SQLite/c#sqlite/wal_c.cs | 511 +- Src/IronPython.SQLite/c#sqlite/wal_h.cs | 250 +- Src/IronPython.SQLite/c#sqlite/walker_c.cs | 333 +- Src/IronPython.SQLite/c#sqlite/where_c.cs | 9442 +++++----- Src/IronPython.Wpf/DynamicXamlReader.cs | 12 +- Src/IronPython.Wpf/Properties/AssemblyInfo.cs | 1 - Src/IronPython.Wpf/_wpf.cs | 4 +- Src/IronPython/Compiler/Ast/AndExpression.cs | 1 + .../Compiler/Ast/AssertStatement.cs | 5 +- .../Compiler/Ast/AssignmentStatement.cs | 11 +- Src/IronPython/Compiler/Ast/AstMethods.cs | 6 +- .../Compiler/Ast/AugmentedAssignStatement.cs | 5 +- .../Compiler/Ast/BinaryExpression.cs | 14 +- Src/IronPython/Compiler/Ast/BreakStatement.cs | 2 - .../Compiler/Ast/ClassDefinition.cs | 1 - Src/IronPython/Compiler/Ast/Comprehension.cs | 7 +- .../Compiler/Ast/ComprehensionFor.cs | 4 +- .../Compiler/Ast/ComprehensionIf.cs | 5 +- .../Compiler/Ast/ConditionalExpression.cs | 6 +- .../Compiler/Ast/ConstantExpression.cs | 7 +- .../Compiler/Ast/ContinueStatement.cs | 2 - Src/IronPython/Compiler/Ast/DelStatement.cs | 4 +- Src/IronPython/Compiler/Ast/DottedName.cs | 2 - .../Compiler/Ast/DynamicConvertExpression.cs | 6 +- .../Ast/DynamicGetMemberExpression.cs | 16 +- Src/IronPython/Compiler/Ast/EmptyStatement.cs | 3 +- .../Compiler/Ast/ErrorExpression.cs | 4 - Src/IronPython/Compiler/Ast/Expression.cs | 3 +- .../Compiler/Ast/ExpressionStatement.cs | 2 - Src/IronPython/Compiler/Ast/FlowChecker.cs | 3 +- Src/IronPython/Compiler/Ast/ForStatement.cs | 12 +- .../Compiler/Ast/FromImportStatement.cs | 6 +- .../Compiler/Ast/FunctionDefinition.cs | 28 +- .../Compiler/Ast/GeneratorExpression.cs | 8 - .../Ast/GetGlobalContextExpression.cs | 5 +- .../GetParentContextFromFunctionExpression.cs | 4 +- Src/IronPython/Compiler/Ast/IfStatement.cs | 7 +- .../Compiler/Ast/ImportStatement.cs | 5 +- .../Compiler/Ast/IndexExpression.cs | 4 +- .../Compiler/Ast/LambdaExpression.cs | 2 - .../Compiler/Ast/MemberExpression.cs | 7 +- Src/IronPython/Compiler/Ast/ModuleName.cs | 2 - Src/IronPython/Compiler/Ast/NameExpression.cs | 7 +- Src/IronPython/Compiler/Ast/Node.cs | 25 +- Src/IronPython/Compiler/Ast/OrExpression.cs | 1 + Src/IronPython/Compiler/Ast/Parameter.cs | 3 - .../Compiler/Ast/ParenthesisExpression.cs | 4 +- Src/IronPython/Compiler/Ast/PythonAst.cs | 36 +- .../Compiler/Ast/PythonNameBinder.cs | 10 +- Src/IronPython/Compiler/Ast/PythonVariable.cs | 9 - .../Compiler/Ast/RelativeModuleName.cs | 2 - Src/IronPython/Compiler/Ast/ScopeStatement.cs | 6 +- .../Compiler/Ast/SerializedScopeStatement.cs | 6 - .../Compiler/Ast/SliceExpression.cs | 2 - Src/IronPython/Compiler/Ast/SuiteStatement.cs | 14 +- Src/IronPython/Compiler/Ast/TryStatement.cs | 9 +- .../Compiler/Ast/UnaryExpression.cs | 8 +- Src/IronPython/Compiler/Ast/WhileStatement.cs | 3 +- Src/IronPython/Compiler/Ast/WithStatement.cs | 26 +- .../Compiler/Ast/YieldExpression.cs | 6 +- .../Compiler/Ast/YieldFromExpression.cs | 6 +- Src/IronPython/Compiler/ClosureExpression.cs | 9 +- Src/IronPython/Compiler/ClosureInfo.cs | 8 +- .../Compiler/CollectableCompilationMode.cs | 9 +- Src/IronPython/Compiler/CompilationMode.cs | 20 +- Src/IronPython/Compiler/GeneratorRewriter.cs | 33 +- .../Compiler/LookupCompilationMode.cs | 11 +- Src/IronPython/Compiler/OnDiskScriptCode.cs | 8 +- Src/IronPython/Compiler/Parser.cs | 8 +- Src/IronPython/Compiler/PythonCallTargets.cs | 41 +- .../Compiler/PythonCompilerOptions.cs | 4 +- .../Compiler/PythonDynamicExpression.cs | 13 +- Src/IronPython/Compiler/PythonGlobal.cs | 8 +- .../PythonGlobalVariableExpression.cs | 14 +- .../Compiler/PythonSavableScriptCode.cs | 9 +- Src/IronPython/Compiler/PythonScriptCode.cs | 26 +- .../Compiler/ReducableDynamicExpression.cs | 10 +- Src/IronPython/Compiler/RunnableScriptCode.cs | 9 +- Src/IronPython/Compiler/RuntimeScriptCode.cs | 15 +- .../Compiler/ToDiskCompilationMode.cs | 10 +- Src/IronPython/Compiler/Token.cs | 2 +- .../Compiler/UncollectableCompilationMode.cs | 21 +- Src/IronPython/Hosting/Python.cs | 16 +- .../Hosting/PythonCodeDomCodeGen.cs | 4 +- .../Hosting/PythonConsoleOptions.cs | 3 +- Src/IronPython/Hosting/PythonService.cs | 6 +- .../Windows/Ucrtbase/Interop.strerror.cs | 2 - Src/IronPython/Modules/_ast.cs | 1 - Src/IronPython/Modules/_fileio.cs | 5 +- Src/IronPython/Modules/_imp.cs | 6 +- Src/IronPython/Modules/_io.cs | 164 +- Src/IronPython/Runtime/ArrayData.cs | 10 +- .../Runtime/Binding/BinaryRetTypeBinder.cs | 8 +- Src/IronPython/Runtime/Binding/Binders.cs | 7 +- .../Runtime/Binding/BindingHelpers.cs | 27 +- .../Runtime/Binding/BindingWarnings.cs | 1 - .../Binding/CompatibilityInvokeBinder.cs | 10 - .../Runtime/Binding/ConditionalBuilder.cs | 6 +- .../Runtime/Binding/ContextArgBuilder.cs | 11 +- .../Runtime/Binding/ConversionBinder.cs | 13 +- .../Runtime/Binding/CreateFallbackBinder.cs | 10 - .../Runtime/Binding/FastBindResult.cs | 10 - Src/IronPython/Runtime/Binding/FastGetBase.cs | 2 - Src/IronPython/Runtime/Binding/FastSetBase.cs | 1 - .../Runtime/Binding/IComConvertible.cs | 3 - .../Runtime/Binding/IFastGettable.cs | 7 - .../Runtime/Binding/IFastInvokable.cs | 5 - .../Runtime/Binding/IFastSettable.cs | 8 - .../Runtime/Binding/IPythonConvertible.cs | 4 - .../Runtime/Binding/IPythonGetable.cs | 3 - .../Runtime/Binding/IPythonInvokable.cs | 4 +- .../Runtime/Binding/IPythonOperable.cs | 3 - Src/IronPython/Runtime/Binding/IPythonSite.cs | 6 +- .../Runtime/Binding/MetaBuiltinFunction.cs | 99 +- .../Binding/MetaBuiltinMethodDescriptor.cs | 10 +- .../Runtime/Binding/MetaPythonFunction.cs | 26 +- .../Runtime/Binding/MetaPythonObject.cs | 14 +- .../Runtime/Binding/MetaPythonType.Calls.cs | 52 +- .../Runtime/Binding/MetaPythonType.Members.cs | 14 +- .../Runtime/Binding/MetaPythonType.cs | 10 +- .../Runtime/Binding/MetaUserObject.Members.cs | 62 +- .../Runtime/Binding/MetaUserObject.cs | 26 +- .../Binding/PythonBinaryOperationBinder.cs | 31 +- .../Runtime/Binding/PythonBinder.Create.cs | 8 +- .../Runtime/Binding/PythonBinder.cs | 47 +- .../Binding/PythonDeleteIndexBinder.cs | 9 +- .../Binding/PythonDeleteMemberBinder.cs | 10 +- .../Binding/PythonDeleteSliceBinder.cs | 6 +- .../Runtime/Binding/PythonExtensionBinder.cs | 7 +- .../Runtime/Binding/PythonGetIndexBinder.cs | 12 +- .../Runtime/Binding/PythonGetMemberBinder.cs | 11 +- .../Runtime/Binding/PythonGetSliceBinder.cs | 6 +- .../Runtime/Binding/PythonIndexType.cs | 4 - .../Runtime/Binding/PythonInvokeBinder.cs | 12 +- .../Runtime/Binding/PythonOperationBinder.cs | 23 +- .../Runtime/Binding/PythonOperationKind.cs | 12 +- .../Runtime/Binding/PythonOverloadResolver.cs | 12 +- .../Binding/PythonProtocol.Operations.cs | 32 +- .../Runtime/Binding/PythonSetIndexBinder.cs | 12 +- .../Runtime/Binding/PythonSetMemberBinder.cs | 14 +- .../Runtime/Binding/PythonSetSliceBinder.cs | 8 +- .../Binding/PythonUnaryOperationBinder.cs | 8 +- .../Binding/SiteLocalStorageBuilder.cs | 12 +- .../Runtime/Binding/SlotOrFunction.cs | 15 +- Src/IronPython/Runtime/Binding/WarningInfo.cs | 1 + Src/IronPython/Runtime/BufferProtocol.cs | 28 +- Src/IronPython/Runtime/BuiltinPythonModule.cs | 3 +- .../Runtime/BuiltinsDictionaryStorage.cs | 7 +- Src/IronPython/Runtime/ByteArray.cs | 25 +- Src/IronPython/Runtime/Bytes.cs | 23 +- .../Runtime/ClassMethodDescriptor.cs | 6 +- Src/IronPython/Runtime/ClrModule.cs | 14 +- Src/IronPython/Runtime/CodeContext.cs | 5 +- Src/IronPython/Runtime/CollectionDebugView.cs | 4 +- .../Runtime/CommonDictionaryStorage.cs | 6 +- Src/IronPython/Runtime/CompiledLoader.cs | 5 +- .../Runtime/ConstantDictionaryStorage.cs | 14 +- Src/IronPython/Runtime/Converter.cs | 24 +- .../Runtime/CustomDictionaryStorage.cs | 1 - .../Runtime/DebuggerDictionaryStorage.cs | 2 - Src/IronPython/Runtime/DefaultContext.cs | 6 +- Src/IronPython/Runtime/Descriptors.cs | 19 +- Src/IronPython/Runtime/DictionaryOps.cs | 8 +- Src/IronPython/Runtime/DictionaryStorage.cs | 5 +- .../Runtime/DictionaryTypeInfoAttribute.cs | 2 +- .../Runtime/EmptyDictionaryStorage.cs | 3 +- Src/IronPython/Runtime/Enumerate.cs | 4 +- Src/IronPython/Runtime/ErrorCodes.cs | 4 +- .../Exceptions/AttributeErrorException.cs | 1 + .../Exceptions/IndentationException.cs | 1 + .../Runtime/Exceptions/PythonException.cs | 1 + .../PythonExceptions.BaseException.cs | 6 +- .../Runtime/Exceptions/PythonExceptions.cs | 22 +- .../Runtime/Exceptions/SystemExitException.cs | 1 + .../Runtime/Exceptions/TabException.cs | 2 +- .../Runtime/Exceptions/TraceBack.cs | 18 +- .../Runtime/Exceptions/TypeErrorException.cs | 5 +- .../Runtime/Exceptions/ValueErrorException.cs | 1 + Src/IronPython/Runtime/FunctionAttributes.cs | 4 +- Src/IronPython/Runtime/FunctionCode.cs | 21 +- Src/IronPython/Runtime/Generator.cs | 11 +- .../Runtime/GlobalDictionaryStorage.cs | 7 +- Src/IronPython/Runtime/Implementation.cs | 3 - Src/IronPython/Runtime/Importer.cs | 14 +- Src/IronPython/Runtime/Index.cs | 5 +- .../InstancedModuleDictionaryStorage.cs | 2 +- Src/IronPython/Runtime/Interfaces.cs | 2 +- .../Runtime/MemoryStreamContentProvider.cs | 1 + Src/IronPython/Runtime/MemoryView.cs | 39 +- Src/IronPython/Runtime/Method.cs | 12 +- Src/IronPython/Runtime/ModuleContext.cs | 2 +- .../Runtime/ModuleDictionaryStorage.cs | 4 +- Src/IronPython/Runtime/ModuleGlobalCache.cs | 5 +- Src/IronPython/Runtime/ModuleLoader.cs | 2 - Src/IronPython/Runtime/ModuleOptions.cs | 2 - Src/IronPython/Runtime/NewStringFormatter.cs | 6 +- .../Runtime/ObjectAttributesAdapter.cs | 5 +- Src/IronPython/Runtime/ObjectDebugView.cs | 4 +- Src/IronPython/Runtime/Operations/ArrayOps.cs | 4 +- .../Runtime/Operations/BigIntegerOps.cs | 28 +- Src/IronPython/Runtime/Operations/BoolOps.cs | 3 +- Src/IronPython/Runtime/Operations/ByteOps.cs | 3 - Src/IronPython/Runtime/Operations/CharOps.cs | 3 +- .../Runtime/Operations/DBNullOps.cs | 2 +- .../Runtime/Operations/DelegateOps.cs | 6 +- Src/IronPython/Runtime/Operations/EnumOps.cs | 2 +- Src/IronPython/Runtime/Operations/FloatOps.cs | 7 +- .../Runtime/Operations/IListOfByteOps.cs | 7 +- .../Runtime/Operations/InstanceOps.cs | 22 +- Src/IronPython/Runtime/Operations/IntOps.cs | 4 +- .../Runtime/Operations/MarshalOps.cs | 380 +- .../Runtime/Operations/NamespaceTrackerOps.cs | 7 +- .../Runtime/Operations/ObjectOps.cs | 10 +- .../Runtime/Operations/PythonCalls.cs | 2 - .../Runtime/Operations/PythonOps.cs | 33 +- .../Runtime/Operations/PythonTypeOps.cs | 54 +- .../Runtime/Operations/StringOps.cs | 46 +- .../Runtime/Operations/TypeGroupOps.cs | 10 +- .../Runtime/Operations/TypeTrackerOps.cs | 4 +- .../Runtime/Operations/UserTypeOps.cs | 26 +- Src/IronPython/Runtime/OutputWriter.cs | 3 +- Src/IronPython/Runtime/Profiler.cs | 9 +- Src/IronPython/Runtime/PythonContext.cs | 14 +- Src/IronPython/Runtime/PythonDictionary.cs | 16 +- .../Runtime/PythonDocumentationProvider.cs | 10 +- .../Runtime/PythonDynamicStackFrame.cs | 3 +- Src/IronPython/Runtime/PythonEncoding.cs | 16 +- Src/IronPython/Runtime/PythonFileManager.cs | 12 +- Src/IronPython/Runtime/PythonFunction.cs | 13 +- .../Runtime/PythonHiddenBaseClassAttribute.cs | 3 - Src/IronPython/Runtime/PythonList.cs | 7 +- Src/IronPython/Runtime/PythonModule.cs | 16 +- Src/IronPython/Runtime/PythonOptions.cs | 6 +- .../Runtime/PythonScopeExtension.cs | 1 - Src/IronPython/Runtime/PythonStrIterator.cs | 6 +- .../Runtime/PythonTracebackListener.cs | 14 +- Src/IronPython/Runtime/PythonTuple.cs | 3 +- Src/IronPython/Runtime/PythonTypeAttribute.cs | 2 - .../RuntimeVariablesDictionaryStorage.cs | 1 - .../Runtime/ScopeDictionaryStorage.cs | 6 +- .../Runtime/SequenceTypeInfoAttribute.cs | 6 +- Src/IronPython/Runtime/SetStorage.cs | 24 +- Src/IronPython/Runtime/Slice.cs | 4 +- .../Runtime/StringDictionaryStorage.cs | 3 +- Src/IronPython/Runtime/StringFormatSpec.cs | 10 +- Src/IronPython/Runtime/Super.cs | 11 +- Src/IronPython/Runtime/ThrowingErrorSink.cs | 4 +- Src/IronPython/Runtime/TypecodeOps.cs | 3 +- .../Runtime/Types/BuiltinFunction.cs | 11 +- .../Types/BuiltinFunctionOverloadMapper.cs | 6 +- .../Runtime/Types/BuiltinMethodDescriptor.cs | 14 +- .../Runtime/Types/CachedNewTypeInfo.cs | 2 +- .../Runtime/Types/ConstructorFunction.cs | 5 +- .../Runtime/Types/CustomAttributeTracker.cs | 20 +- .../Types/CustomInstanceDictionaryStorage.cs | 8 +- Src/IronPython/Runtime/Types/DocBuilder.cs | 23 +- .../Runtime/Types/DynamicBaseTypeAttribute.cs | 2 +- Src/IronPython/Runtime/Types/EmptyType.cs | 6 +- .../Runtime/Types/ExtensionPropertyInfo.cs | 4 +- Src/IronPython/Runtime/Types/IPythonObject.cs | 3 - .../Runtime/Types/InstanceCreator.cs | 3 +- Src/IronPython/Runtime/Types/NameConverter.cs | 12 +- Src/IronPython/Runtime/Types/NewTypeInfo.cs | 4 +- Src/IronPython/Runtime/Types/NewTypeMaker.cs | 50 +- .../Runtime/Types/OperatorMapping.cs | 4 +- .../Runtime/Types/ParameterInfoWrapper.cs | 2 +- .../Runtime/Types/PythonAssemblyOps.cs | 4 +- .../Runtime/Types/PythonSiteCache.cs | 6 +- Src/IronPython/Runtime/Types/PythonType.cs | 95 +- .../Runtime/Types/PythonTypeDataSlot.cs | 4 - .../Runtime/Types/PythonTypeDictSlot.cs | 3 +- .../Runtime/Types/PythonTypeInfo.cs | 25 +- .../Runtime/Types/PythonTypeSlot.cs | 11 +- .../Runtime/Types/PythonTypeTypeSlot.cs | 2 +- .../Types/PythonTypeUserDescriptorSlot.cs | 3 +- .../Runtime/Types/PythonTypeWeakRefSlot.cs | 2 +- .../Runtime/Types/ReflectedEvent.cs | 4 +- .../Types/ReflectedExtensionProperty.cs | 4 +- .../Runtime/Types/ReflectedField.cs | 16 +- .../Runtime/Types/ReflectedGetterSetter.cs | 9 +- .../Runtime/Types/ReflectedIndexer.cs | 6 +- .../Runtime/Types/ReflectedProperty.cs | 13 +- .../Runtime/Types/ReflectedSlotProperty.cs | 10 +- Src/IronPython/Runtime/WeakRef.cs | 6 +- Src/IronPython/Runtime/WrapperDictionary.cs | 4 +- Src/IronPython/Runtime/Zip.cs | 4 +- Src/IronPythonCompiler/AssemblyResolver.cs | 3 - Src/IronPythonCompiler/Config.cs | 9 +- Src/IronPythonCompiler/ConsoleOps.cs | 3 - .../Properties/AssemblyInfo.cs | 1 - Src/IronPythonTest/AttrInjectorTest.cs | 4 +- Src/IronPythonTest/BindTest.cs | 37 +- Src/IronPythonTest/BinderTest.cs | 36 +- Src/IronPythonTest/Cases/CPythonCases.cs | 3 +- Src/IronPythonTest/Cases/CaseExecuter.cs | 5 +- Src/IronPythonTest/Cases/CaseGenerator.cs | 1 + Src/IronPythonTest/Cases/IronPythonCases.cs | 3 +- Src/IronPythonTest/ClrType.cs | 6 +- Src/IronPythonTest/Conversions.cs | 3 +- Src/IronPythonTest/DynamicRegressions.cs | 30 +- Src/IronPythonTest/EncodingTest.cs | 6 +- Src/IronPythonTest/EngineTest.cs | 3 - Src/IronPythonTest/Events.cs | 2 +- Src/IronPythonTest/ExtensionMethodTest.cs | 8 +- Src/IronPythonTest/Indexable.cs | 2 +- Src/IronPythonTest/InheritTest.cs | 23 +- Src/IronPythonTest/IronMath.cs | 1 + Src/IronPythonTest/MemberMappingTests.cs | 5 +- Src/IronPythonTest/MemberOverloadTest.cs | 7 +- Src/IronPythonTest/MethodParametersStubs.cs | 8 +- Src/IronPythonTest/NullableTest.cs | 13 +- Src/IronPythonTest/OperatorTest.cs | 1 + Src/IronPythonTest/ProtocolTest.cs | 1 + Src/IronPythonTest/StaticTest.cs | 12 +- Src/IronPythonTest/Stress/Engine.cs | 13 +- Src/IronPythonTest/StringDictionaryStorage.cs | 9 +- Src/IronPythonTest/TestBuiltinModule.cs | 6 +- Src/IronPythonTest/TypeDescriptor.cs | 2 +- Src/IronPythonTest/Util/IniParser.cs | 10 +- Src/IronPythonTest/Util/TestManifest.cs | 4 - Src/IronPythonWindow/IronPythonWindow.cs | 2 + 500 files changed, 94651 insertions(+), 105786 deletions(-) diff --git a/IronPythonAnalyzer/IronPythonAnalyzer/IronPythonAnalyzerAnalyzer.cs b/IronPythonAnalyzer/IronPythonAnalyzer/IronPythonAnalyzerAnalyzer.cs index d392b4230..0cd941e1c 100644 --- a/IronPythonAnalyzer/IronPythonAnalyzer/IronPythonAnalyzerAnalyzer.cs +++ b/IronPythonAnalyzer/IronPythonAnalyzer/IronPythonAnalyzerAnalyzer.cs @@ -2,14 +2,10 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; -using System.Threading; + using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Operations; diff --git a/Src/IronPython.Modules/IterTools.cs b/Src/IronPython.Modules/IterTools.cs index 5de12db3d..8012998e2 100644 --- a/Src/IronPython.Modules/IterTools.cs +++ b/Src/IronPython.Modules/IterTools.cs @@ -8,16 +8,16 @@ using System.Numerics; using System.Runtime.InteropServices; -using Microsoft.Scripting; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - using IronPython.Runtime; using IronPython.Runtime.Binding; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + [assembly: PythonModule("itertools", typeof(IronPython.Modules.PythonIterTools))] namespace IronPython.Modules { public static class PythonIterTools { @@ -219,7 +219,7 @@ private static void EnsureIterator(CodeContext/*!*/ context, object iter) { if (iter == null || !PythonOps.HasAttr(context, iter, "__iter__") && !PythonOps.HasAttr(context, iter, "__getitem__")) { - throw PythonOps.TypeError("'{0}' object is not iterable", PythonOps.GetPythonTypeName(iter)); + throw PythonOps.TypeError("'{0}' object is not iterable", PythonOps.GetPythonTypeName(iter)); } } @@ -262,13 +262,13 @@ public count(BigInteger start) { InnerEnumerator = BigIntYielder(this, start, 1); } - public count(int start=0, int step=1) { + public count(int start = 0, int step = 1) { _curInt = start; _step = step; InnerEnumerator = IntYielder(this, start, step); } - public count([DefaultParameterValue(0)]int start, BigInteger step) { + public count([DefaultParameterValue(0)] int start, BigInteger step) { _curInt = start; _step = step; InnerEnumerator = IntYielder(this, start, step); @@ -286,7 +286,7 @@ public count(BigInteger start, BigInteger step) { InnerEnumerator = BigIntYielder(this, start, step); } - public count(CodeContext/*!*/ context, [DefaultParameterValue(0)]object start, [DefaultParameterValue(1)]object step) { + public count(CodeContext/*!*/ context, [DefaultParameterValue(0)] object start, [DefaultParameterValue(1)] object step) { EnsureNumeric(context, start); EnsureNumeric(context, step); _cur = start; @@ -301,7 +301,7 @@ private static void EnsureNumeric(CodeContext/*!*/ context, object num) { if (num == null || !PythonOps.HasAttr(context, num, "__int__") && !PythonOps.HasAttr(context, num, "__float__")) { - throw PythonOps.TypeError("a number is required"); + throw PythonOps.TypeError("a number is required"); } } @@ -517,9 +517,9 @@ private IEnumerator Yielder(IEnumerator iter) { if (MoveNextHelper(iter)) { while (!_fFinished) { while (PythonContext.Equal(GetKey(iter.Current), curKey)) { - if (!MoveNextHelper(iter)) { - _fFinished = true; - yield break; + if (!MoveNextHelper(iter)) { + _fFinished = true; + yield break; } } curKey = GetKey(iter.Current); @@ -531,9 +531,9 @@ private IEnumerator Yielder(IEnumerator iter) { private IEnumerator Grouper(IEnumerator iter, object curKey) { while (PythonContext.Equal(GetKey(iter.Current), curKey)) { yield return iter.Current; - if (!MoveNextHelper(iter)) { - _fFinished = true; - yield break; + if (!MoveNextHelper(iter)) { + _fFinished = true; + yield break; } } } @@ -658,7 +658,7 @@ public zip_longest(params object[] iterables) { } } - public zip_longest([ParamDictionary]IDictionary paramDict, params object[] iterables) { + public zip_longest([ParamDictionary] IDictionary paramDict, params object[] iterables) { object fill; if (paramDict.TryGetValue("fillvalue", out fill)) { @@ -747,7 +747,7 @@ public product(CodeContext context, params object[] iterables) { InnerEnumerator = Yielder(ArrayUtils.ConvertAll(iterables, x => new PythonList(context, PythonOps.GetEnumerator(x)))); } - public product(CodeContext context, [ParamDictionary]IDictionary paramDict, params object[] iterables) { + public product(CodeContext context, [ParamDictionary] IDictionary paramDict, params object[] iterables) { object repeat; int iRepeat = 1; if (paramDict.TryGetValue("repeat", out repeat)) { @@ -970,7 +970,7 @@ public permutations(CodeContext context, object iterable) { public permutations(CodeContext context, object iterable, object r) { _data = new PythonList(context, iterable); - + InnerEnumerator = Yielder(GetR(r, _data)); } @@ -1133,9 +1133,9 @@ IEnumerator IEnumerable.GetEnumerator() { #endregion } - + [PythonType] - public class starmap : IterBase { + public class starmap : IterBase { public starmap(CodeContext context, object function, object iterable) { InnerEnumerator = Yielder(context, function, PythonOps.GetEnumerator(iterable)); } @@ -1194,7 +1194,7 @@ public void __setstate__(object state) { private IEnumerator Yielder(object predicate, IEnumerator iter) { while (MoveNextHelper(iter)) { - if(!Converter.ConvertToBoolean( + if (!Converter.ConvertToBoolean( _context.LanguageContext.CallSplat(predicate, iter.Current) )) { break; diff --git a/Src/IronPython.Modules/ModuleOps.cs b/Src/IronPython.Modules/ModuleOps.cs index c7441cb3b..aab4c099f 100644 --- a/Src/IronPython.Modules/ModuleOps.cs +++ b/Src/IronPython.Modules/ModuleOps.cs @@ -10,14 +10,13 @@ using System.Numerics; using System.Runtime.InteropServices; -using Microsoft.Scripting; -using Microsoft.Scripting.Utils; - using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting.Utils; + namespace IronPython.Modules { /// /// Provides helper functions which need to be called from generated code to implement various @@ -92,7 +91,7 @@ public static CTypes.CData CheckSimpleCDataType(object o, object type) { bool valid = true; // if we have an array, we can also send a pointer as long as the element types // for the pointer and array are the same - if(res != null && res.NativeType is CTypes.ArrayType at) { + if (res != null && res.NativeType is CTypes.ArrayType at) { valid = ((type is CTypes.ArrayType t) && (t.ElementType == at.ElementType)) || ((type is CTypes.PointerType p) && (p._type == at.ElementType)); } @@ -109,7 +108,7 @@ public static CTypes.CData CheckSimpleCDataType(object o, object type) { if (res == null && PythonOps.TryGetBoundAttr(o, "_as_parameter_", out object asParam)) { res = asParam as CTypes._CFuncPtr; } - + if (res == null || res.NativeType != type) { throw ArgumentError(type, ((PythonType)type).Name, o); } @@ -297,14 +296,14 @@ public static IntPtr GetPointer(object value) { } if (value is int iVal) { - if(iVal > int.MaxValue) { + if (iVal > int.MaxValue) { iVal = -1; } return new IntPtr(iVal); } if (value is BigInteger bigVal) { - if(bigVal > long.MaxValue) { + if (bigVal > long.MaxValue) { bigVal = -1; } return new IntPtr((long)bigVal); diff --git a/Src/IronPython.Modules/NtSignalState.cs b/Src/IronPython.Modules/NtSignalState.cs index 2bc1ec812..9b87ecd5b 100644 --- a/Src/IronPython.Modules/NtSignalState.cs +++ b/Src/IronPython.Modules/NtSignalState.cs @@ -102,7 +102,7 @@ internal static class NativeSignal { [DllImport("Kernel32")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool SetConsoleCtrlHandler(WinSignalsHandler Handler, [MarshalAs(UnmanagedType.Bool)]bool Add); + internal static extern bool SetConsoleCtrlHandler(WinSignalsHandler Handler, [MarshalAs(UnmanagedType.Bool)] bool Add); [DllImport("Kernel32")] [return: MarshalAs(UnmanagedType.Bool)] diff --git a/Src/IronPython.Modules/Properties/AssemblyInfo.cs b/Src/IronPython.Modules/Properties/AssemblyInfo.cs index 2f5435278..994510a64 100644 --- a/Src/IronPython.Modules/Properties/AssemblyInfo.cs +++ b/Src/IronPython.Modules/Properties/AssemblyInfo.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; diff --git a/Src/IronPython.Modules/ResourceMetaPathImporter.cs b/Src/IronPython.Modules/ResourceMetaPathImporter.cs index a3c444e2d..55ed53f31 100644 --- a/Src/IronPython.Modules/ResourceMetaPathImporter.cs +++ b/Src/IronPython.Modules/ResourceMetaPathImporter.cs @@ -3,9 +3,11 @@ using System.IO; using System.Linq; using System.Reflection; + using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Zlib; + using Microsoft.Scripting; using Microsoft.Scripting.Runtime; @@ -131,8 +133,7 @@ public object load_module(CodeContext /*!*/ context, string fullname) { modules.Add(fullname, mod); try { script.Run(mod.Scope); - } - catch (Exception) { + } catch (Exception) { modules.Remove(fullname); throw; } @@ -175,8 +176,7 @@ private byte[] GetCodeFromData(CodeContext /*!*/ context, bool isbytecode, Packe if (data != null) { if (isbytecode) { // would put in code to unmarshal the bytecode here... - } - else { + } else { code = data; } } @@ -221,8 +221,8 @@ public static PackedResourceInfo Create(string fullName, int compress, #if DEBUG public override string ToString() { var sizeDesc = String.Format("{0} bytes", _fileSize); - if (Convert.ToDouble(_fileSize)/1024.0 > 1.0) - sizeDesc = String.Format("{0} KB", Math.Round(Convert.ToDouble(_fileSize)/1024.0, 1)); + if (Convert.ToDouble(_fileSize) / 1024.0 > 1.0) + sizeDesc = String.Format("{0} KB", Math.Round(Convert.ToDouble(_fileSize) / 1024.0, 1)); return String.Format("{0} ({1})", FullName, sizeDesc); } #endif @@ -259,26 +259,25 @@ where isPyFile let path = lineage.Take(lineage.Length - 1).ToArray() orderby fileName select new { - name = fileName, - path, - dottedPath = String.Join(".", path), - entry - }; + name = fileName, + path, + dottedPath = String.Join(".", path), + entry + }; var moduleContents = from source in parsedSources orderby source.dottedPath group source by source.dottedPath into moduleGroup select new { - moduleGroup.Key, - Items = moduleGroup.Select(item => item.entry).ToArray() - }; + moduleGroup.Key, + Items = moduleGroup.Select(item => item.entry).ToArray() + }; modules = moduleContents.ToDictionary( moduleGroup => moduleGroup.Key, moduleGroup => moduleGroup.Items); return true; - } - catch (Exception exception) { + } catch (Exception exception) { files = null; modules = null; unpackingError = String.Format("{0}: {1}", exception.GetType().Name, exception.Message); @@ -310,7 +309,7 @@ private bool ReadZipDirectory(out IDictionary result var endofCentralDir = new byte[22]; reader.BaseStream.Seek(-22, SeekOrigin.End); - var headerPosition = (int) reader.BaseStream.Position; + var headerPosition = (int)reader.BaseStream.Position; if (reader.Read(endofCentralDir, 0, 22) != 22) { unpackingError = "Can't read ZIP resource: Invalid ZIP Directory."; return false; @@ -332,8 +331,7 @@ private bool ReadZipDirectory(out IDictionary result .ToDictionary(entry => entry.FullName); return true; } - } - catch (Exception exception) { + } catch (Exception exception) { unpackingError = String.Format("{0}: {1}", exception.GetType().Name, exception.Message); return false; } @@ -410,21 +408,19 @@ public bool GetData(PackedResourceInfo tocEntry, out byte[] result, out string u byte[] rawData; try { rawData = reader.ReadBytes(compress == 0 ? dataSize : dataSize + 1); - } - catch { + } catch { unpackingError = "Can't read data"; return false; } if (compress != 0) { - rawData[dataSize] = (byte) 'Z'; + rawData[dataSize] = (byte)'Z'; } result = compress == 0 ? rawData : ZlibModule.Decompress(rawData, -15); return true; } - } - catch (Exception exception) { + } catch (Exception exception) { unpackingError = String.Format("{0}: {1}", exception.GetType().Name, exception.Message); return false; } diff --git a/Src/IronPython.Modules/SimpleSignalState.cs b/Src/IronPython.Modules/SimpleSignalState.cs index c746290b3..784c5fbf2 100644 --- a/Src/IronPython.Modules/SimpleSignalState.cs +++ b/Src/IronPython.Modules/SimpleSignalState.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; + using IronPython.Runtime; #if FEATURE_PROCESS @@ -16,7 +14,7 @@ public SimpleSignalState(PythonContext pc) private void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e) { int pySignal; - switch(e.SpecialKey) { + switch (e.SpecialKey) { case ConsoleSpecialKey.ControlC: pySignal = SIGINT; break; @@ -28,7 +26,7 @@ private void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e) { default: throw new InvalidOperationException("unreachable"); } - + lock (PySignalToPyHandler) { if (PySignalToPyHandler[pySignal].GetType() == typeof(int)) { int tempId = (int)PySignalToPyHandler[pySignal]; diff --git a/Src/IronPython.Modules/_bisect.cs b/Src/IronPython.Modules/_bisect.cs index 1468699d9..b90a79ea1 100644 --- a/Src/IronPython.Modules/_bisect.cs +++ b/Src/IronPython.Modules/_bisect.cs @@ -6,14 +6,14 @@ using System.Collections; using System.Reflection; -using Microsoft.Scripting.Generation; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting.Generation; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + [assembly: PythonModule("_bisect", typeof(IronPython.Modules.PythonBisectModule))] namespace IronPython.Modules { @@ -201,7 +201,7 @@ public static object bisect_left(CodeContext/*!*/ context, object a, object x, i Optional args lo (default 0) and hi (default len(a)) bound the slice of a to be searched. ")] - public static void InsortRight(CodeContext/*!*/ context, object a, object x, int lo=0, int hi=-1) { + public static void InsortRight(CodeContext/*!*/ context, object a, object x, int lo = 0, int hi = -1) { if (a is PythonList l && l.GetType() == typeof(PythonList)) { l.Insert(InternalBisectRight(context, l, x, lo, hi), x); return; @@ -227,7 +227,7 @@ public static void InsortRight(CodeContext/*!*/ context, object a, object x, int Optional args lo (default 0) and hi (default len(a)) bound the slice of a to be searched. ")] - public static void insort_left(CodeContext/*!*/ context, object a, object x, int lo=0, int hi=-1) { + public static void insort_left(CodeContext/*!*/ context, object a, object x, int lo = 0, int hi = -1) { if (a is PythonList l && l.GetType() == typeof(PythonList)) { l.Insert(InternalBisectLeft(context, l, x, lo, hi), x); return; diff --git a/Src/IronPython.Modules/_codecs.cs b/Src/IronPython.Modules/_codecs.cs index 277b74160..991362b82 100644 --- a/Src/IronPython.Modules/_codecs.cs +++ b/Src/IronPython.Modules/_codecs.cs @@ -161,8 +161,7 @@ public static PythonTuple escape_decode([NotNone] IBufferProtocol data, string? Func?>? eh = null; return delegate (in ReadOnlySpan data, int start, int end, string message) { - eh ??= errors switch - { + eh ??= errors switch { "strict" => idx => throw PythonOps.ValueError(@"invalid \x escape at position {0}", idx), "replace" => idx => _replacementMarker ??= new[] { (byte)'?' }, "ignore" => idx => null, diff --git a/Src/IronPython.Modules/_codecs_cn.cs b/Src/IronPython.Modules/_codecs_cn.cs index 9836d2887..76d712608 100644 --- a/Src/IronPython.Modules/_codecs_cn.cs +++ b/Src/IronPython.Modules/_codecs_cn.cs @@ -2,13 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Collections.Generic; -using System.Text; -using System.Runtime.InteropServices; -using IronPython.Runtime; -using IronPython.Runtime.Operations; - #if FALSE [assembly: PythonModule("_codecs_cn", typeof(IronPython.Modules._codecs_cn))] namespace IronPython.Modules { diff --git a/Src/IronPython.Modules/_collections.cs b/Src/IronPython.Modules/_collections.cs index f0f838ba4..ada192949 100644 --- a/Src/IronPython.Modules/_collections.cs +++ b/Src/IronPython.Modules/_collections.cs @@ -10,17 +10,16 @@ using System.Runtime.CompilerServices; using System.Text; -using Microsoft.Scripting; -using Microsoft.Scripting.Actions; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - using IronPython.Runtime; using IronPython.Runtime.Binding; -using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting; +using Microsoft.Scripting.Actions; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + [assembly: PythonModule("_collections", typeof(IronPython.Modules.PythonCollections))] namespace IronPython.Modules { public class PythonCollections { @@ -42,7 +41,7 @@ private deque(int maxlen) { _data = _maxLen < 0 ? new object[8] : new object[Math.Min(_maxLen, 8)]; } - public static object __new__(CodeContext/*!*/ context, PythonType cls, [ParamDictionary]IDictionary dict, params object[] args) { + public static object __new__(CodeContext/*!*/ context, PythonType cls, [ParamDictionary] IDictionary dict, params object[] args) { if (cls == DynamicHelpers.GetPythonTypeFromType(typeof(deque))) return new deque(); return cls.CreateInstance(context); } @@ -52,7 +51,7 @@ public void __init__() { clear(); } - public void __init__([ParamDictionary]IDictionary dict) { + public void __init__([ParamDictionary] IDictionary dict) { _maxLen = VerifyMaxLen(dict); clear(); } @@ -65,12 +64,12 @@ public void __init__(object iterable) { public void __init__(object iterable, object maxlen) { _maxLen = VerifyMaxLenValue(maxlen); - + clear(); extend(iterable); } - public void __init__(object iterable, [ParamDictionary]IDictionary dict) { + public void __init__(object iterable, [ParamDictionary] IDictionary dict) { if (VerifyMaxLen(dict) < 0) { __init__(iterable); } else { @@ -82,7 +81,7 @@ private static int VerifyMaxLen(IDictionary dict) { if (dict.Count != 1) { throw PythonOps.TypeError("deque() takes at most 1 keyword argument ({0} given)", dict.Count); } - + object value; if (!dict.TryGetValue("maxlen", out value)) { IEnumerator e = dict.Keys.GetEnumerator(); @@ -105,7 +104,7 @@ private static int VerifyMaxLenValue(object value) { Extensible ebi => (int)ebi.Value, _ => throw PythonOps.TypeError("an integer is required") }; - + if (res < 0) throw PythonOps.ValueError("maxlen must be non-negative"); return res; @@ -425,7 +424,7 @@ public void rotate(CodeContext/*!*/ context, object n) { // too bad, we got gaps, looks like we'll be doing some real work. object[] newData = new object[_itemCnt]; // we re-size to itemCnt so that future rotates don't require work int curWriteIndex = rot; - WalkDeque(delegate(int curIndex) { + WalkDeque(delegate (int curIndex) { newData[curWriteIndex] = _data[curIndex]; curWriteIndex = (curWriteIndex + 1) % _itemCnt; return true; @@ -534,7 +533,7 @@ public void __delitem__(CodeContext/*!*/ context, object index) { // we'll just recreate our data by walking the data once. object[] newData = new object[_data.Length]; int writeIndex = 0; - WalkDeque(delegate(int curIndex) { + WalkDeque(delegate (int curIndex) { if (curIndex != realIndex) { newData[writeIndex++] = _data[curIndex]; } @@ -555,7 +554,7 @@ public PythonTuple __reduce__() { lock (_lockObj) { object[] items = new object[_itemCnt]; int curItem = 0; - WalkDeque(delegate(int curIndex) { + WalkDeque(delegate (int curIndex) { items[curItem++] = _data[curIndex]; return true; }); @@ -932,7 +931,7 @@ private bool WalkDeque(DequeWalker walker) { string comma = ""; lock (_lockObj) { - WalkDeque(delegate(int index) { + WalkDeque(delegate (int index) { sb.Append(comma); sb.Append(PythonOps.Repr(context, _data[index])); comma = ", "; @@ -1167,7 +1166,7 @@ public void __init__(CodeContext/*!*/ context, object default_factory, [NotNone] public void __init__(CodeContext/*!*/ context, object default_factory, [ParamDictionary, NotNone] IDictionary dict, [NotNone] params object[] args) { __init__(context, default_factory, args); - foreach (KeyValuePair kvp in dict) { + foreach (KeyValuePair kvp in dict) { this[kvp.Key] = kvp.Value; } } diff --git a/Src/IronPython.Modules/_csv.cs b/Src/IronPython.Modules/_csv.cs index 9623552b7..eda531097 100644 --- a/Src/IronPython.Modules/_csv.cs +++ b/Src/IronPython.Modules/_csv.cs @@ -319,7 +319,7 @@ public static Dialect Create(CodeContext/*!*/ context, public void DeleteMember(CodeContext/*!*/ context, string name) { if (string.Equals(name, "delimiter") || string.Equals(name, "skipinitialspace") || - string.Equals(name, "doublequote")|| + string.Equals(name, "doublequote") || string.Equals(name, "strict") || string.Equals(name, "escapechar") || string.Equals(name, "lineterminator") || diff --git a/Src/IronPython.Modules/_ctypes/Array.cs b/Src/IronPython.Modules/_ctypes/Array.cs index cec1619b3..8d8cd2348 100644 --- a/Src/IronPython.Modules/_ctypes/Array.cs +++ b/Src/IronPython.Modules/_ctypes/Array.cs @@ -7,7 +7,6 @@ using System.Collections; using System.Collections.Generic; using System.Diagnostics; -using System.Numerics; using System.Text; using IronPython.Runtime; diff --git a/Src/IronPython.Modules/_ctypes/ArrayType.cs b/Src/IronPython.Modules/_ctypes/ArrayType.cs index 72dc3838a..c36cd44fd 100644 --- a/Src/IronPython.Modules/_ctypes/ArrayType.cs +++ b/Src/IronPython.Modules/_ctypes/ArrayType.cs @@ -9,7 +9,6 @@ using System.Diagnostics; using System.Numerics; using System.Reflection.Emit; -using System.Runtime.InteropServices; using IronPython.Runtime; using IronPython.Runtime.Operations; diff --git a/Src/IronPython.Modules/_ctypes/CData.cs b/Src/IronPython.Modules/_ctypes/CData.cs index 147061c25..6eff67f5e 100644 --- a/Src/IronPython.Modules/_ctypes/CData.cs +++ b/Src/IronPython.Modules/_ctypes/CData.cs @@ -13,7 +13,6 @@ using System.Threading; using IronPython.Runtime; -using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; @@ -73,7 +72,7 @@ internal void SetAddress(IntPtr address) { internal void InitializeFromBuffer(object? data, int offset, int size) { var bp = data as IBufferProtocol ?? throw PythonOps.TypeErrorForBadInstance("{0} object does not have the buffer interface", data); - // Python 3.5: PythonOps.TypeErrorForBytesLikeTypeMismatch(data); + // Python 3.5: PythonOps.TypeErrorForBytesLikeTypeMismatch(data); IPythonBuffer buffer = bp.GetBuffer(BufferFlags.FullRO); if (buffer.IsReadOnly) { @@ -98,7 +97,7 @@ internal void InitializeFromBuffer(object? data, int offset, int size) { internal void InitializeFromBufferCopy(object? data, int offset, int size) { var bp = data as IBufferProtocol ?? throw PythonOps.TypeErrorForBadInstance("{0} object does not have the buffer interface", data); - // Python 3.5: PythonOps.TypeErrorForBytesLikeTypeMismatch(data); + // Python 3.5: PythonOps.TypeErrorForBytesLikeTypeMismatch(data); using IPythonBuffer buffer = bp.GetBuffer(); var span = buffer.AsReadOnlySpan(); diff --git a/Src/IronPython.Modules/_ctypes/CFuncPtrType.cs b/Src/IronPython.Modules/_ctypes/CFuncPtrType.cs index 4e0d81143..fa1f4dfb3 100644 --- a/Src/IronPython.Modules/_ctypes/CFuncPtrType.cs +++ b/Src/IronPython.Modules/_ctypes/CFuncPtrType.cs @@ -12,15 +12,14 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using Microsoft.Scripting; -using Microsoft.Scripting.Actions; -using Microsoft.Scripting.Generation; -using Microsoft.Scripting.Utils; - using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting.Actions; +using Microsoft.Scripting.Generation; +using Microsoft.Scripting.Utils; + namespace IronPython.Modules { /// /// Provides support for interop with native code from Python code. @@ -187,7 +186,7 @@ internal Delegate MakeReverseDelegate(CodeContext/*!*/ context, object target) { return _reverseDelegate.CreateDelegate(_reverseDelegateType, constantPool); } - + private void MakeReverseDelegateWorker(CodeContext context) { Type[] sigTypes; Type[] callSiteType; @@ -223,7 +222,7 @@ private void MakeReverseDelegateWorker(CodeContext context) { // load code context int contextIndex = constantPool.Count; Debug.Assert(pc.SharedContext != null); - constantPool.Add(pc.SharedContext); + constantPool.Add(pc.SharedContext); ilGen.Emit(OpCodes.Ldarg_0); ilGen.Emit(OpCodes.Ldc_I4, contextIndex); ilGen.Emit(OpCodes.Ldelem_Ref); diff --git a/Src/IronPython.Modules/_ctypes/Field.cs b/Src/IronPython.Modules/_ctypes/Field.cs index 9b38b43e5..d4f2a0e5e 100644 --- a/Src/IronPython.Modules/_ctypes/Field.cs +++ b/Src/IronPython.Modules/_ctypes/Field.cs @@ -8,12 +8,12 @@ using System.Diagnostics; using System.Numerics; -using Microsoft.Scripting.Runtime; - using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting.Runtime; + namespace IronPython.Modules { /// /// Provides support for interop with native code from Python code. diff --git a/Src/IronPython.Modules/_ctypes/MarshalCleanup.cs b/Src/IronPython.Modules/_ctypes/MarshalCleanup.cs index 6db8a3eb7..f2256dec2 100644 --- a/Src/IronPython.Modules/_ctypes/MarshalCleanup.cs +++ b/Src/IronPython.Modules/_ctypes/MarshalCleanup.cs @@ -4,8 +4,6 @@ #if FEATURE_LCG -using System; -using System.Reflection; using System.Reflection.Emit; using System.Runtime.InteropServices; diff --git a/Src/IronPython.Modules/_ctypes/MemoryHolder.cs b/Src/IronPython.Modules/_ctypes/MemoryHolder.cs index ff0872b26..aeee5fe79 100644 --- a/Src/IronPython.Modules/_ctypes/MemoryHolder.cs +++ b/Src/IronPython.Modules/_ctypes/MemoryHolder.cs @@ -165,24 +165,24 @@ public byte ReadByte(int offset) { return res; } - public short ReadInt16(int offset, bool swap=false) { + public short ReadInt16(int offset, bool swap = false) { short res = Marshal.ReadInt16(_data, offset); GC.KeepAlive(this); - if(swap) res = Swap(res); + if (swap) res = Swap(res); return res; } - public int ReadInt32(int offset, bool swap=false) { + public int ReadInt32(int offset, bool swap = false) { int res = Marshal.ReadInt32(_data, offset); GC.KeepAlive(this); - if(swap) res = Swap(res); + if (swap) res = Swap(res); return res; } - public long ReadInt64(int offset, bool swap=false) { + public long ReadInt64(int offset, bool swap = false) { long res = Marshal.ReadInt64(_data, offset); GC.KeepAlive(this); - if(swap) res = Swap(res); + if (swap) res = Swap(res); return res; } @@ -240,7 +240,7 @@ internal static Bytes ReadBytes(IntPtr addr, int offset, int length) { // ptrToStringAnsi gives special treatment to values >= 128. MemoryStream res = new MemoryStream(); byte b; - while((b = Marshal.ReadByte(addr, offset++)) != 0) { + while ((b = Marshal.ReadByte(addr, offset++)) != 0) { res.WriteByte(b); } return Bytes.Make(res.ToArray()); @@ -259,17 +259,17 @@ public void WriteByte(int offset, byte value) { GC.KeepAlive(this); } - public void WriteInt16(int offset, short value, bool swap=false) { + public void WriteInt16(int offset, short value, bool swap = false) { Marshal.WriteInt16(_data, offset, swap ? Swap(value) : value); GC.KeepAlive(this); } - public void WriteInt32(int offset, int value, bool swap=false) { + public void WriteInt32(int offset, int value, bool swap = false) { Marshal.WriteInt32(_data, offset, swap ? Swap(value) : value); GC.KeepAlive(this); } - public void WriteInt64(int offset, long value, bool swap=false) { + public void WriteInt64(int offset, long value, bool swap = false) { Marshal.WriteInt64(_data, offset, swap ? Swap(value) : value); GC.KeepAlive(this); } diff --git a/Src/IronPython.Modules/_ctypes/NativeArgument.cs b/Src/IronPython.Modules/_ctypes/NativeArgument.cs index 880d097d2..ca58cdff0 100644 --- a/Src/IronPython.Modules/_ctypes/NativeArgument.cs +++ b/Src/IronPython.Modules/_ctypes/NativeArgument.cs @@ -6,16 +6,16 @@ using System; -using Microsoft.Scripting.Runtime; - using IronPython.Runtime; using IronPython.Runtime.Types; +using Microsoft.Scripting.Runtime; + namespace IronPython.Modules { /// /// Provides support for interop with native code from Python code. /// - public static partial class CTypes { + public static partial class CTypes { // returned from from_param, byref, seemingly called "cparam", but type() says CArgObject in CPython [PythonType, PythonHidden] public sealed class NativeArgument : ICodeFormattable { diff --git a/Src/IronPython.Modules/_ctypes/Pointer.cs b/Src/IronPython.Modules/_ctypes/Pointer.cs index cb36feecf..aa9c27afc 100644 --- a/Src/IronPython.Modules/_ctypes/Pointer.cs +++ b/Src/IronPython.Modules/_ctypes/Pointer.cs @@ -44,7 +44,7 @@ public object contents { CData res = (CData)elementType.CreateInstance(elementType.Context.SharedContext); res.MemHolder = MemHolder.ReadMemoryHolder(0); - if(res.MemHolder.UnsafeAddress == IntPtr.Zero) { + if (res.MemHolder.UnsafeAddress == IntPtr.Zero) { throw PythonOps.ValueError("NULL value access"); } return res; diff --git a/Src/IronPython.Modules/_ctypes/PointerType.cs b/Src/IronPython.Modules/_ctypes/PointerType.cs index 197863398..26fa69abc 100644 --- a/Src/IronPython.Modules/_ctypes/PointerType.cs +++ b/Src/IronPython.Modules/_ctypes/PointerType.cs @@ -9,13 +9,12 @@ using System.Numerics; using System.Reflection.Emit; -using Microsoft.Scripting; -using Microsoft.Scripting.Runtime; - using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting.Runtime; + namespace IronPython.Modules { /// /// Provides support for interop with native code from Python code. @@ -124,7 +123,7 @@ object INativeType.SetValue(MemoryHolder address, int offset, object value) { _Array array; if (value == null) { address.WriteIntPtr(offset, IntPtr.Zero); - } else if (value is int) { + } else if (value is int) { address.WriteIntPtr(offset, new IntPtr((int)value)); } else if (value is BigInteger) { address.WriteIntPtr(offset, new IntPtr((long)(BigInteger)value)); @@ -161,7 +160,7 @@ MarshalCleanup INativeType.EmitMarshalling(ILGenerator/*!*/ method, LocalOrArg a method.MarkLabel(nextTry); nextTry = method.DefineLabel(); - + argIndex.Emit(method); if (argumentType.IsValueType) { method.Emit(OpCodes.Box, argumentType); @@ -172,7 +171,7 @@ MarshalCleanup INativeType.EmitMarshalling(ILGenerator/*!*/ method, LocalOrArg a MarshalCleanup res = null; if (st != null && !argIndex.Type.IsValueType) { if (st._type == SimpleTypeKind.Char || st._type == SimpleTypeKind.WChar) { - + if (st._type == SimpleTypeKind.Char) { SimpleType.TryToCharPtrConversion(method, argIndex, argumentType, done); } else { diff --git a/Src/IronPython.Modules/_ctypes/SimpleCData.cs b/Src/IronPython.Modules/_ctypes/SimpleCData.cs index 9bb1cb126..6839c8fc6 100644 --- a/Src/IronPython.Modules/_ctypes/SimpleCData.cs +++ b/Src/IronPython.Modules/_ctypes/SimpleCData.cs @@ -9,12 +9,12 @@ using System.Numerics; using System.Runtime.CompilerServices; -using Microsoft.Scripting.Runtime; - using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting.Runtime; + namespace IronPython.Modules { /// /// Provides support for interop with native code from Python code. @@ -36,9 +36,8 @@ public void __init__() { } public void __init__(CodeContext/*!*/ context, object value) { - switch(((SimpleType)NativeType)._type) { - case SimpleTypeKind.Char: - { + switch (((SimpleType)NativeType)._type) { + case SimpleTypeKind.Char: { if (value is IList t && t.Count == 1) { value = Bytes.FromByte(t[0]); } else if (value is int i) { diff --git a/Src/IronPython.Modules/_ctypes/SimpleType.cs b/Src/IronPython.Modules/_ctypes/SimpleType.cs index a071c2118..22cba6f1c 100644 --- a/Src/IronPython.Modules/_ctypes/SimpleType.cs +++ b/Src/IronPython.Modules/_ctypes/SimpleType.cs @@ -13,7 +13,6 @@ using System.Runtime.InteropServices; using IronPython.Runtime; -using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; @@ -254,7 +253,7 @@ object INativeType.SetValue(MemoryHolder/*!*/ owner, int offset, object value) { case SimpleTypeKind.SignedByte: owner.WriteByte(offset, ModuleOps.GetSignedByte(value, this)); break; case SimpleTypeKind.UnsignedByte: owner.WriteByte(offset, ModuleOps.GetUnsignedByte(value, this)); break; case SimpleTypeKind.WChar: owner.WriteInt16(offset, (short)ModuleOps.GetWChar(value, this)); break; - case SimpleTypeKind.SignedShort: owner.WriteInt16(offset, ModuleOps.GetSignedShort(value, this), _swap); break; + case SimpleTypeKind.SignedShort: owner.WriteInt16(offset, ModuleOps.GetSignedShort(value, this), _swap); break; case SimpleTypeKind.UnsignedShort: owner.WriteInt16(offset, ModuleOps.GetUnsignedShort(value, this), _swap); break; case SimpleTypeKind.VariantBool: owner.WriteInt16(offset, (short)ModuleOps.GetVariantBool(value, this), _swap); break; case SimpleTypeKind.SignedInt: owner.WriteInt32(offset, ModuleOps.GetSignedInt(value, this), _swap); break; @@ -524,8 +523,7 @@ internal static void MarshalWCharPointer(ILGenerator method, LocalOrArg argIndex method.Emit(OpCodes.Ldc_I4, RuntimeHelpers.OffsetToStringData); #pragma warning restore CS0618 // Type or member is obsolete method.Emit(OpCodes.Add); - } - else { + } else { method.Emit(OpCodes.Call, StringGetPinnableReference); } method.Emit(OpCodes.Br, done); diff --git a/Src/IronPython.Modules/_ctypes/SimpleTypeKind.cs b/Src/IronPython.Modules/_ctypes/SimpleTypeKind.cs index 995a248b3..291a04658 100644 --- a/Src/IronPython.Modules/_ctypes/SimpleTypeKind.cs +++ b/Src/IronPython.Modules/_ctypes/SimpleTypeKind.cs @@ -4,8 +4,6 @@ #if FEATURE_CTYPES -using System; - namespace IronPython.Modules { /// /// Provides support for interop with native code from Python code. diff --git a/Src/IronPython.Modules/_ctypes/StructType.cs b/Src/IronPython.Modules/_ctypes/StructType.cs index e4ffdafee..77f3f2e4b 100644 --- a/Src/IronPython.Modules/_ctypes/StructType.cs +++ b/Src/IronPython.Modules/_ctypes/StructType.cs @@ -5,20 +5,18 @@ #if FEATURE_CTYPES using System; -using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Numerics; using System.Reflection.Emit; -using System.Runtime.InteropServices; using System.Text; -using Microsoft.Scripting; - using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting; + namespace IronPython.Modules { /// /// Provides support for interop with native code from Python code. diff --git a/Src/IronPython.Modules/_ctypes/Structure.cs b/Src/IronPython.Modules/_ctypes/Structure.cs index e3711c2d6..4f7c23312 100644 --- a/Src/IronPython.Modules/_ctypes/Structure.cs +++ b/Src/IronPython.Modules/_ctypes/Structure.cs @@ -6,12 +6,12 @@ using System.Collections.Generic; -using Microsoft.Scripting; - using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting; + namespace IronPython.Modules { /// /// Provides support for interop with native code from Python code. @@ -53,7 +53,7 @@ public void __init__([NotNone] params object[] args) { st.SetValueInternal(MemHolder, 0, args); } - public void __init__(CodeContext/*!*/ context, [ParamDictionary]IDictionary kwargs) { + public void __init__(CodeContext/*!*/ context, [ParamDictionary] IDictionary kwargs) { CheckAbstract(); foreach (var x in kwargs) { diff --git a/Src/IronPython.Modules/_ctypes/Union.cs b/Src/IronPython.Modules/_ctypes/Union.cs index 987dfdc8e..c5ef9c1f2 100644 --- a/Src/IronPython.Modules/_ctypes/Union.cs +++ b/Src/IronPython.Modules/_ctypes/Union.cs @@ -11,7 +11,7 @@ namespace IronPython.Modules { /// /// Provides support for interop with native code from Python code. /// - public static partial class CTypes { + public static partial class CTypes { [PythonType("Union")] public abstract class _Union : CData { public void __init__(CodeContext/*!*/ context) { diff --git a/Src/IronPython.Modules/_ctypes/UnionType.cs b/Src/IronPython.Modules/_ctypes/UnionType.cs index ce2e0c0b6..ac0b1202c 100644 --- a/Src/IronPython.Modules/_ctypes/UnionType.cs +++ b/Src/IronPython.Modules/_ctypes/UnionType.cs @@ -5,12 +5,9 @@ #if FEATURE_CTYPES using System; -using System.Collections; using System.Collections.Generic; using System.Reflection.Emit; -using Microsoft.Scripting; - using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; diff --git a/Src/IronPython.Modules/_datetime.cs b/Src/IronPython.Modules/_datetime.cs index b3acc4d42..6066e8a4e 100644 --- a/Src/IronPython.Modules/_datetime.cs +++ b/Src/IronPython.Modules/_datetime.cs @@ -1037,8 +1037,7 @@ public override string strftime(CodeContext/*!*/ context, [NotNone] string dateF public double timestamp() { if (tzinfo is null) { return PythonTime.TicksToTimestamp(_dateTime.ToUniversalTime().Ticks); - } - else { + } else { return (this - new datetime(new DateTime(1970, 1, 1), timezone.utc)).total_seconds(); } } diff --git a/Src/IronPython.Modules/_functools.cs b/Src/IronPython.Modules/_functools.cs index 6bd2d9dd9..ac573fd43 100644 --- a/Src/IronPython.Modules/_functools.cs +++ b/Src/IronPython.Modules/_functools.cs @@ -148,7 +148,7 @@ public PythonDictionary __dict__ { get { return EnsureDict(); } - [param: NotNone] + [param: NotNone] set { _dict = value; } diff --git a/Src/IronPython.Modules/_heapq.cs b/Src/IronPython.Modules/_heapq.cs index a9c1f3b68..7bae82b5a 100644 --- a/Src/IronPython.Modules/_heapq.cs +++ b/Src/IronPython.Modules/_heapq.cs @@ -4,14 +4,13 @@ using System; using System.Collections; -using System.Collections.Generic; -using System.Text; -using Microsoft.Scripting.Runtime; + using IronPython.Runtime; -using IronPython.Runtime.Binding; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting.Runtime; + [assembly: PythonModule("_heapq", typeof(IronPython.Modules.PythonHeapq))] namespace IronPython.Modules { public static class PythonHeapq { diff --git a/Src/IronPython.Modules/_multibytecodec.cs b/Src/IronPython.Modules/_multibytecodec.cs index 0c75d3880..242b36096 100644 --- a/Src/IronPython.Modules/_multibytecodec.cs +++ b/Src/IronPython.Modules/_multibytecodec.cs @@ -2,14 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Collections.Generic; -using System.Text; -using System.Runtime.InteropServices; -using IronPython.Runtime; -using IronPython.Runtime.Operations; -using Microsoft.Scripting; - #if FALSE [assembly: PythonModule("_multibytecodec", typeof(IronPython.Modules._multibytecodec))] namespace IronPython.Modules { diff --git a/Src/IronPython.Modules/_multiprocessing.cs b/Src/IronPython.Modules/_multiprocessing.cs index 63fcba0d5..fa624450b 100644 --- a/Src/IronPython.Modules/_multiprocessing.cs +++ b/Src/IronPython.Modules/_multiprocessing.cs @@ -7,8 +7,6 @@ using System.Runtime.InteropServices; using System.Runtime.Versioning; -using Microsoft.Win32.SafeHandles; - using IronPython.Runtime; [assembly: PythonModule("_multiprocessing", typeof(IronPython.Modules.MultiProcessing))] diff --git a/Src/IronPython.Modules/_opcode.cs b/Src/IronPython.Modules/_opcode.cs index 03c654010..cbddd04f2 100644 --- a/Src/IronPython.Modules/_opcode.cs +++ b/Src/IronPython.Modules/_opcode.cs @@ -2,19 +2,8 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Numerics; -using System.Text; - -using Microsoft.Scripting.Utils; - using IronPython.Runtime; -using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; [assembly: PythonModule("_opcode", typeof(IronPython.Modules.PythonOpcode))] namespace IronPython.Modules { @@ -156,7 +145,7 @@ public static class PythonOpcode { private const int FVS_MASK = 0x4; private const int FVS_HAVE_SPEC = 0x4; - public static int stack_effect(CodeContext context, int opcode, object oparg=null) { + public static int stack_effect(CodeContext context, int opcode, object oparg = null) { int ioparg = 0; if (opcode >= HAVE_ARGUMENT) { diff --git a/Src/IronPython.Modules/_random.cs b/Src/IronPython.Modules/_random.cs index a77b7fdac..d2a0045c1 100644 --- a/Src/IronPython.Modules/_random.cs +++ b/Src/IronPython.Modules/_random.cs @@ -4,10 +4,10 @@ using System; using System.Linq; -using System.Numerics; using IronPython.Runtime; using IronPython.Runtime.Operations; + using Microsoft.Scripting.Utils; [assembly: PythonModule("_random", typeof(IronPython.Modules.PythonRandom))] diff --git a/Src/IronPython.Modules/_socket.cs b/Src/IronPython.Modules/_socket.cs index 9587d6864..ff3f486df 100644 --- a/Src/IronPython.Modules/_socket.cs +++ b/Src/IronPython.Modules/_socket.cs @@ -1588,40 +1588,40 @@ public static void setdefaulttimeout(CodeContext/*!*/ context, object? timeout) // Darwin: man 3 gai_strerror // The specified network host does not have any network addresses in the requested address family. [PythonHidden(PlatformsAttribute.PlatformFamily.Windows)] - public static int EAI_ADDRFAMILY => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 1 : -9; + public static int EAI_ADDRFAMILY => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 1 : -9; // The name server returned a temporary failure indication. Try again later. - public static int EAI_AGAIN => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 2 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -3 : (int)SocketError.TryAgain; + public static int EAI_AGAIN => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 2 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -3 : (int)SocketError.TryAgain; // hints.ai_flags contains invalid flags. - public static int EAI_BADFLAGS => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 3 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -1 : (int)SocketError.InvalidArgument; + public static int EAI_BADFLAGS => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 3 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -1 : (int)SocketError.InvalidArgument; // The name server returned a permanent failure indication. - public static int EAI_FAIL => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 4 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -4 : (int)SocketError.NoRecovery; + public static int EAI_FAIL => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 4 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -4 : (int)SocketError.NoRecovery; // The requested address family is not supported. - public static int EAI_FAMILY => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 5 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -6 : (int)SocketError.AddressFamilyNotSupported; + public static int EAI_FAMILY => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 5 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -6 : (int)SocketError.AddressFamilyNotSupported; // Out of memory. - public static int EAI_MEMORY => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 6 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -10 : (int)SocketError.NoBufferSpaceAvailable; + public static int EAI_MEMORY => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 6 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -10 : (int)SocketError.NoBufferSpaceAvailable; // The specified network host exists, but does not have any network addresses defined. - public static int EAI_NODATA => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 7 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -5 : (int)SocketError.HostNotFound; // not SocketError.NoData, like you would think + public static int EAI_NODATA => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 7 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -5 : (int)SocketError.HostNotFound; // not SocketError.NoData, like you would think // The node or service is not known. - public static int EAI_NONAME => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 8 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -2 : (int)SocketError.HostNotFound; + public static int EAI_NONAME => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 8 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -2 : (int)SocketError.HostNotFound; // The requested service is not available for the requested socket type. - public static int EAI_SERVICE => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 9 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -8 : (int)SocketError.TypeNotFound; + public static int EAI_SERVICE => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 9 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -8 : (int)SocketError.TypeNotFound; // The requested socket type is not supported. - public static int EAI_SOCKTYPE => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 10 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -7 : (int)SocketError.SocketNotSupported; + public static int EAI_SOCKTYPE => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 10 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -7 : (int)SocketError.SocketNotSupported; // Other system error, check errno for details. [PythonHidden(PlatformsAttribute.PlatformFamily.Windows)] - public static int EAI_SYSTEM => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 11 : -11; + public static int EAI_SYSTEM => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 11 : -11; // Invalid value for hints. [PythonHidden(PlatformsAttribute.PlatformFamily.Windows, PlatformID.Unix)] - public static int EAI_BADHINTS => 12; + public static int EAI_BADHINTS => 12; // Resolved protocol is unknown. [PythonHidden(PlatformsAttribute.PlatformFamily.Windows, PlatformID.Unix)] - public static int EAI_PROTOCOL => 13; + public static int EAI_PROTOCOL => 13; // Argument buffer overflow. [PythonHidden(PlatformsAttribute.PlatformFamily.Windows)] - public static int EAI_OVERFLOW => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 14 : -12; + public static int EAI_OVERFLOW => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 14 : -12; // Maximum value of EAI_* erors plus one. [PythonHidden(PlatformsAttribute.PlatformFamily.Windows, PlatformID.Unix)] - public static int EAI_MAX => 15; + public static int EAI_MAX => 15; public const int INADDR_ALLHOSTS_GROUP = unchecked((int)0xe0000001); public const int INADDR_ANY = (int)0x00000000; @@ -1739,9 +1739,9 @@ public static void setdefaulttimeout(CodeContext/*!*/ context, object? timeout) #region Private implementation private static int HERROR_HOST_NOT_FOUND = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? (int)SocketError.HostNotFound : 1; - private static int HERROR_TRY_AGAIN = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? (int)SocketError.TryAgain : 2; - private static int HERROR_NO_RECOVERY = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? (int)SocketError.NoRecovery : 3; - private static int HERROR_NO_DATA = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? (int)SocketError.NoData : 4; + private static int HERROR_TRY_AGAIN = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? (int)SocketError.TryAgain : 2; + private static int HERROR_NO_RECOVERY = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? (int)SocketError.NoRecovery : 3; + private static int HERROR_NO_DATA = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? (int)SocketError.NoData : 4; /// /// Return a socket exception (socket.error, socket.timeout, socket.herror) based on the information in the existing exception. @@ -1842,7 +1842,7 @@ private static Exception MakeGaiException(CodeContext context, int eaiCode) { return PythonExceptions.CreateThrowable(gaierror(context), EAI_BADHINTS, "Bad hints"); } return MakeGaiException(context, EAI_SERVICE); - // TODO: Handle other defined codes (currently unused). Remap codes that are not available on a specific system. + // TODO: Handle other defined codes (currently unused). Remap codes that are not available on a specific system. } else { // fallback to generic error if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { @@ -2033,7 +2033,7 @@ private static IPAddress[] HostToAddresses(CodeContext/*!*/ context, string host if (addrs.Count > 0) return addrs.ToArray(); } throw MakeGaiException(context, EAI_NODATA); - } catch (SocketException ex) { + } catch (SocketException ex) { throw MakeGaiException(context, ex); } } diff --git a/Src/IronPython.Modules/_ssl.cs b/Src/IronPython.Modules/_ssl.cs index 499dc3789..431506fb3 100644 --- a/Src/IronPython.Modules/_ssl.cs +++ b/Src/IronPython.Modules/_ssl.cs @@ -640,12 +640,10 @@ public int read(CodeContext/*!*/ context, int size, [NotNone] IBufferProtocol bu var numRead = _sslStream.Read(buf, 0, size); buf.AsSpan(0, numRead).CopyTo(pythonBuffer.AsSpan()); return numRead; - } - finally { + } finally { ArrayPool.Return(buf); } - } - else { + } else { return _sslStream.Read(buf, 0, size); } #endif diff --git a/Src/IronPython.Modules/_struct.cs b/Src/IronPython.Modules/_struct.cs index de4c8989b..98bd84267 100644 --- a/Src/IronPython.Modules/_struct.cs +++ b/Src/IronPython.Modules/_struct.cs @@ -9,15 +9,15 @@ using System.Runtime.CompilerServices; using System.Threading; -using Microsoft.Scripting; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + [assembly: PythonModule("_struct", typeof(IronPython.Modules.PythonStruct))] namespace IronPython.Modules { public static class PythonStruct { @@ -60,7 +60,7 @@ public Struct(params object[] args) { } [Documentation("creates a new uninitialized struct object - all arguments are ignored")] - public Struct([ParamDictionary]IDictionary kwArgs, params object[] args) { + public Struct([ParamDictionary] IDictionary kwArgs, params object[] args) { } [Documentation("initializes or re-initializes the compiled struct object with a new format")] diff --git a/Src/IronPython.Modules/_warnings.cs b/Src/IronPython.Modules/_warnings.cs index ae37101c8..b1d712257 100644 --- a/Src/IronPython.Modules/_warnings.cs +++ b/Src/IronPython.Modules/_warnings.cs @@ -3,20 +3,18 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.IO; using System.Numerics; using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; using System.Text; -using System.Text.RegularExpressions; + using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; + using Microsoft.Scripting; using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; [assembly: PythonModule("_warnings", typeof(IronPython.Modules.PythonWarnings))] namespace IronPython.Modules { @@ -54,7 +52,7 @@ public static void PerformModuleReload(PythonContext/*!*/ context, PythonDiction public static void _filters_mutated() { } // TODO: do something with this - public static void warn(CodeContext context, object message, PythonType category=null, int stacklevel=1) { + public static void warn(CodeContext context, object message, PythonType category = null, int stacklevel = 1) { PythonContext pContext = context.LanguageContext; PythonList argv = pContext.GetSystemStateValue("argv") as PythonList; @@ -111,7 +109,7 @@ public static void warn(CodeContext context, object message, PythonType category warn_explicit(context, message, category, filename, lineno, module, registry, globals); } - public static void warn_explicit(CodeContext context, object message, PythonType category, string filename, int lineno, string module=null, PythonDictionary registry=null, object module_globals=null) { + public static void warn_explicit(CodeContext context, object message, PythonType category, string filename, int lineno, string module = null, PythonDictionary registry = null, object module_globals = null) { PythonContext pContext = context.LanguageContext; PythonDictionary fields = (PythonDictionary)pContext.GetModuleState(_keyFields); object warnings = pContext.GetWarningsModule(); @@ -148,7 +146,7 @@ public static void warn_explicit(CodeContext context, object message, PythonType PythonList filters = (PythonList)fields[_keyFilters]; if (warnings != null) { filters = PythonOps.GetBoundAttr(context, warnings, "filters") as PythonList; - if(filters == null) { + if (filters == null) { throw PythonOps.ValueError("_warnings.filters must be a list"); } } @@ -212,7 +210,7 @@ public static void warn_explicit(CodeContext context, object message, PythonType if (warnings != null) { object show_fxn = PythonOps.GetBoundAttr(context, warnings, "showwarning"); - if(show_fxn != null) { + if (show_fxn != null) { PythonCalls.Call( context, show_fxn, @@ -225,7 +223,7 @@ public static void warn_explicit(CodeContext context, object message, PythonType } } - internal static string formatwarning(object message, PythonType category, string filename, int lineno, string line=null) { + internal static string formatwarning(object message, PythonType category, string filename, int lineno, string line = null) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("{0}:{1}: {2}: {3}\n", filename, lineno, category.Name, message); if (line == null && lineno > 0 && File.Exists(filename)) { @@ -241,7 +239,7 @@ internal static string formatwarning(object message, PythonType category, string return sb.ToString(); } - internal static void showwarning(CodeContext context, object message, PythonType category, string filename, int lineno, object file=null, string line=null) { + internal static void showwarning(CodeContext context, object message, PythonType category, string filename, int lineno, object file = null, string line = null) { string text = formatwarning(message, category, filename, lineno, line); try { diff --git a/Src/IronPython.Modules/_weakref.cs b/Src/IronPython.Modules/_weakref.cs index 838fe71ae..787b8884b 100644 --- a/Src/IronPython.Modules/_weakref.cs +++ b/Src/IronPython.Modules/_weakref.cs @@ -8,12 +8,10 @@ using System.Runtime.CompilerServices; using IronPython.Runtime; -using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; using Microsoft.Scripting; -using Microsoft.Scripting.Actions; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; @@ -76,8 +74,7 @@ public static void _remove_dead_weakref(CodeContext context, PythonDictionary di public static readonly PythonType ReferenceType = DynamicHelpers.GetPythonTypeFromType(typeof(@ref)); [PythonType("weakref")] - public class @ref : IStructuralEquatable - { + public class @ref : IStructuralEquatable { private readonly CodeContext _context; internal readonly WeakHandle _target; private int _hashVal; @@ -283,8 +280,7 @@ private static bool RefEquals(object x, object y, IEqualityComparer comparer) { } [PythonType, DynamicBaseType, PythonHidden] - public sealed partial class weakproxy : IPythonObject, ICodeFormattable, IProxyObject, IPythonMembersList, IStructuralEquatable - { + public sealed partial class weakproxy : IPythonObject, ICodeFormattable, IProxyObject, IPythonMembersList, IStructuralEquatable { internal readonly WeakHandle _target; private readonly CodeContext/*!*/ _context; @@ -382,7 +378,7 @@ PythonType IPythonObject.PythonType { object[] IPythonObject.GetSlots() { return null; } object[] IPythonObject.GetSlotsCreate() { return null; } - + #endregion #region object overloads @@ -484,7 +480,7 @@ bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer) { return comparer.Equals(obj, other); } - + #endregion public object __bool__() { @@ -499,7 +495,7 @@ public static explicit operator bool(weakproxy self) { [PythonType, DynamicBaseTypeAttribute, PythonHidden] public sealed partial class weakcallableproxy : IPythonObject, - ICodeFormattable, + ICodeFormattable, IProxyObject, IStructuralEquatable, IPythonMembersList { @@ -545,8 +541,7 @@ private weakcallableproxy(CodeContext context, object target, object callback) { ~weakcallableproxy() { // remove our self from the chain... IWeakReferenceable iwr; - if (_context.LanguageContext.TryConvertToWeakReferenceable(_target.Target, out iwr)) - { + if (_context.LanguageContext.TryConvertToWeakReferenceable(_target.Target, out iwr)) { WeakRefTracker wrt = iwr.GetWeakRef(); wrt.RemoveHandler(this); } @@ -610,7 +605,7 @@ PythonType IPythonObject.PythonType { object[] IPythonObject.GetSlots() { return null; } object[] IPythonObject.GetSlotsCreate() { return null; } - + #endregion #region object overloads @@ -638,9 +633,9 @@ public override string ToString() { public object Call(CodeContext/*!*/ context, params object[] args) { return context.LanguageContext.CallSplat(GetObject(), args); } - + [SpecialName] - public object Call(CodeContext/*!*/ context, [ParamDictionary]IDictionary dict, params object[] args) { + public object Call(CodeContext/*!*/ context, [ParamDictionary] IDictionary dict, params object[] args) { return PythonCalls.CallWithKeywordArgs(context, GetObject(), args, dict); } @@ -736,7 +731,7 @@ public static WeakRefTracker InitializeWeakRef(PythonContext context, object sel WeakRefTracker wrt = iwr.GetWeakRef(); if (wrt == null) { - if (!iwr.SetWeakRef(wrt = new WeakRefTracker(iwr))) + if (!iwr.SetWeakRef(wrt = new WeakRefTracker(iwr))) throw PythonOps.TypeError("cannot create weak reference to '{0}' object", PythonOps.GetPythonTypeName(target)); } @@ -810,7 +805,7 @@ public object Call(CodeContext context, params object[] args) { [SpecialName] - public object Call(CodeContext context, [ParamDictionary]IDictionary dict, params object[] args) { + public object Call(CodeContext context, [ParamDictionary] IDictionary dict, params object[] args) { object targetMethod; if (!DynamicHelpers.GetPythonType(target.Target).TryGetBoundMember(context, target.Target, name, out targetMethod)) throw PythonOps.AttributeError("type {0} has no attribute {1}", diff --git a/Src/IronPython.Modules/_winapi.cs b/Src/IronPython.Modules/_winapi.cs index dcfacd5d4..3d11b0594 100644 --- a/Src/IronPython.Modules/_winapi.cs +++ b/Src/IronPython.Modules/_winapi.cs @@ -24,8 +24,7 @@ public static class PythonWinApi { if (overlapped) { throw new NotImplementedException(); - } - else { + } else { var result = ConnectNamedPipe(checked((IntPtr)(long)handle), IntPtr.Zero); if (!result) throw PythonNT.GetLastWin32Error(); @@ -169,7 +168,7 @@ public static BigInteger DuplicateHandle( int desired_access, bool inherit_handle, object? DUPLICATE_SAME_ACCESS) { - + IntPtr currentProcessIntPtr = new IntPtr((long)source_process_handle); IntPtr handleIntPtr = new IntPtr((long)source_handle); IntPtr currentProcess2IntPtr = new IntPtr((long)target_process_handle); @@ -303,7 +302,7 @@ private static extern IntPtr CreateFile( [DllImport("kernel32.dll", EntryPoint = "CreateProcess", SetLastError = true)] private static extern bool CreateProcessPI(string? lpApplicationName, string? lpCommandLine, ref SECURITY_ATTRIBUTES lpProcessAttributes, - ref SECURITY_ATTRIBUTES lpThreadAttributes, [MarshalAs(UnmanagedType.Bool)]bool bInheritHandles, + ref SECURITY_ATTRIBUTES lpThreadAttributes, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandles, uint dwCreationFlags, string? lpEnvironment, string? lpCurrentDirectory, [In] ref STARTUPINFO lpStartupInfo, out PROCESS_INFORMATION lpProcessInformation); diff --git a/Src/IronPython.Modules/array.cs b/Src/IronPython.Modules/array.cs index 578ec8d2f..2c1242251 100644 --- a/Src/IronPython.Modules/array.cs +++ b/Src/IronPython.Modules/array.cs @@ -13,19 +13,18 @@ using System.Linq; using System.Numerics; using System.Reflection; -using System.Runtime.InteropServices; using System.Text; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using SpecialName = System.Runtime.CompilerServices.SpecialNameAttribute; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + using NotNull = System.Diagnostics.CodeAnalysis.NotNullAttribute; +using SpecialName = System.Runtime.CompilerServices.SpecialNameAttribute; [assembly: PythonModule("array", typeof(IronPython.Modules.ArrayModule))] namespace IronPython.Modules { @@ -69,16 +68,14 @@ private static array ArrayReconstructor(CodeContext context, [NotNone] PythonTyp static string MachineFormatToTypeCode(int machineFormat, out bool isBigEndian, out string? encoding) { isBigEndian = machineFormat % 2 == 1; - encoding = machineFormat switch - { + encoding = machineFormat switch { 18 => "UTF-16-LE", 19 => "UTF-16-BE", 20 => "UTF-32-LE", 21 => "UTF-32-BE", _ => null, }; - return machineFormat switch - { + return machineFormat switch { 0 => "B", 1 => "b", 2 => "H", @@ -157,8 +154,7 @@ private array(char typeCode, ArrayData data) { } private static ArrayData CreateData(char typecode) { - return (typecode) switch - { + return (typecode) switch { 'b' => new ArrayData(), 'B' => new ArrayData(), 'u' => new ArrayData(), @@ -581,8 +577,7 @@ public PythonTuple __reduce_ex__(CodeContext context, int version) { dict); static int TypeCodeToMachineFormat(char typeCode) { - return typeCode switch - { + return typeCode switch { 'b' => 1, 'B' => 0, 'u' => 18, diff --git a/Src/IronPython.Modules/atexit.cs b/Src/IronPython.Modules/atexit.cs index c2a35aeb0..8943951e9 100644 --- a/Src/IronPython.Modules/atexit.cs +++ b/Src/IronPython.Modules/atexit.cs @@ -2,13 +2,12 @@ using System.Collections.Generic; using System.Runtime.CompilerServices; -using Microsoft.Scripting; - using IronPython.Runtime; -using Microsoft.Scripting.Runtime; - -using IronPython.Runtime.Operations; using IronPython.Runtime.Exceptions; +using IronPython.Runtime.Operations; + +using Microsoft.Scripting; +using Microsoft.Scripting.Runtime; [assembly: PythonModule("atexit", typeof(IronPython.Modules.PythonAtExit))] namespace IronPython.Modules { @@ -28,15 +27,15 @@ public FunctionDescriptor(object func, IDictionary kwargs, objec } public object Func { - get; + get; } public IDictionary KeywordArgs { - get; + get; } public object[] Args { - get; + get; } } @@ -57,7 +56,7 @@ Register a function to be executed upon normal program termination\n\ kwargs - optional keyword arguments to pass to func func is returned to facilitate usage as a decorator.")] - public static object register(CodeContext context, object func, [ParamDictionary]IDictionary kwargs, params object[] args) { + public static object register(CodeContext context, object func, [ParamDictionary] IDictionary kwargs, params object[] args) { if (!PythonOps.IsCallable(context, func)) { throw PythonOps.TypeError("the first argument must be callable"); } diff --git a/Src/IronPython.Modules/bz2/BZ2Compressor.cs b/Src/IronPython.Modules/bz2/BZ2Compressor.cs index 9453e1ff5..7ef908efc 100644 --- a/Src/IronPython.Modules/bz2/BZ2Compressor.cs +++ b/Src/IronPython.Modules/bz2/BZ2Compressor.cs @@ -6,12 +6,13 @@ // using System; -using System.Collections.Generic; using System.IO; using System.Linq; -using System.Runtime.InteropServices; + using Ionic.BZip2; + using IronPython.Runtime; + using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; @@ -19,7 +20,7 @@ namespace IronPython.Modules.Bz2 { public static partial class Bz2Module { [PythonType] public class BZ2Compressor { - public const string __doc__ = + public const string __doc__ = @"BZ2Compressor([compresslevel=9]) -> compressor object Create a new compressor object. This object may be used to compress diff --git a/Src/IronPython.Modules/bz2/BZ2Decompressor.cs b/Src/IronPython.Modules/bz2/BZ2Decompressor.cs index fcc9a54e0..13d98582a 100644 --- a/Src/IronPython.Modules/bz2/BZ2Decompressor.cs +++ b/Src/IronPython.Modules/bz2/BZ2Decompressor.cs @@ -9,9 +9,12 @@ using System.Collections.Generic; using System.IO; using System.Linq; + using Ionic.BZip2; + using IronPython.Runtime; using IronPython.Runtime.Operations; + using Microsoft.Scripting.Runtime; namespace IronPython.Modules.Bz2 { diff --git a/Src/IronPython.Modules/bz2/BZ2Module.cs b/Src/IronPython.Modules/bz2/BZ2Module.cs index 6ad5cbcb5..b83f37626 100644 --- a/Src/IronPython.Modules/bz2/BZ2Module.cs +++ b/Src/IronPython.Modules/bz2/BZ2Module.cs @@ -5,9 +5,6 @@ // Copyright 2012 Jeff Hardy // -using System.Collections.Generic; -using System.Linq; - using IronPython.Runtime; [assembly: PythonModule("_bz2", typeof(IronPython.Modules.Bz2.Bz2Module))] diff --git a/Src/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs b/Src/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs index e628857bb..a0ee547e0 100644 --- a/Src/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs +++ b/Src/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs @@ -85,14 +85,11 @@ // using System; -using System.IO; // flymake: csc.exe /t:module BZip2InputStream.cs BZip2OutputStream.cs Rand.cs BCRC32.cs @@FILE@@ -namespace Ionic.BZip2 -{ - internal class BZip2Compressor - { +namespace Ionic.BZip2 { + internal class BZip2Compressor { private int blockSize100k; // 0...9 private int currentByte = -1; private int runLength = 0; @@ -141,12 +138,10 @@ internal class BZip2Compressor /// is necessary because BZip2 does byte shredding. /// public BZip2Compressor(BitWriter writer) - : this(writer, BZip2.MaxBlockSize) - { + : this(writer, BZip2.MaxBlockSize) { } - public BZip2Compressor(BitWriter writer, int blockSize) - { + public BZip2Compressor(BitWriter writer, int blockSize) { this.blockSize100k = blockSize; this.bw = writer; @@ -160,8 +155,7 @@ public BZip2Compressor(BitWriter writer, int blockSize) Reset(); } - private void Reset() - { + private void Reset() { // initBlock(); this.crc.Reset(); this.currentByte = -1; @@ -173,18 +167,15 @@ private void Reset() } - public int BlockSize - { + public int BlockSize { get { return this.blockSize100k; } } - public uint Crc32 - { + public uint Crc32 { get; private set; } - public int AvailableBytesOut - { + public int AvailableBytesOut { get; private set; } @@ -202,8 +193,7 @@ public int AvailableBytesOut /// then writes no more. In that case the stream may want to check. /// /// - public int UncompressedBytes - { + public int UncompressedBytes { get { return this.last + 1; } } @@ -217,8 +207,7 @@ public int UncompressedBytes /// stores the encoded data into the rle block. /// /// - public int Fill(byte[] buffer, int offset, int count) - { + public int Fill(byte[] buffer, int offset, int count) { if (this.last >= this.outBlockFillThreshold) return 0; // We're full, I tell you! @@ -227,8 +216,7 @@ public int Fill(byte[] buffer, int offset, int count) int rc; // do run-length-encoding until block is full - do - { + do { rc = write0(buffer[offset++]); if (rc > 0) bytesWritten++; } while (offset < limit && rc == 1); @@ -259,22 +247,18 @@ public int Fill(byte[] buffer, int offset, int count) /// /// /// 0 if the byte was not written, non-zero if written. - private int write0(byte b) - { + private int write0(byte b) { bool rc; // there is no current run in progress - if (this.currentByte == -1) - { + if (this.currentByte == -1) { this.currentByte = b; this.runLength++; return 1; } // this byte is the same as the current run in progress - if (this.currentByte == b) - { - if (++this.runLength > 254) - { + if (this.currentByte == b) { + if (++this.runLength > 254) { rc = AddRunToOutputBlock(false); this.currentByte = -1; this.runLength = 0; @@ -288,8 +272,7 @@ private int write0(byte b) // and try to start a new run. rc = AddRunToOutputBlock(false); - if (rc) - { + if (rc) { this.currentByte = -1; this.runLength = 0; // returning 0 implies the block is full, and the byte was not written. @@ -316,8 +299,7 @@ private int write0(byte b) /// /// /// true if the block is now full; otherwise false. - private bool AddRunToOutputBlock(bool final) - { + private bool AddRunToOutputBlock(bool final) { runs++; /* add_pair_to_block ( EState* s ) */ int previousLast = this.last; @@ -325,8 +307,7 @@ private bool AddRunToOutputBlock(bool final) // sanity check only - because of the check done at the // bottom of this method, and the logic in write0(), this // should never ever happen. - if (previousLast >= this.outBlockFillThreshold && !final) - { + if (previousLast >= this.outBlockFillThreshold && !final) { var msg = String.Format("block overrun(final={2}): {0} >= threshold ({1})", previousLast, this.outBlockFillThreshold, final); throw new Exception(msg); @@ -341,14 +322,13 @@ private bool AddRunToOutputBlock(bool final) // rle block. For those two reasons, the base offset from last is // always +2. - byte b = (byte) this.currentByte; + byte b = (byte)this.currentByte; byte[] block = this.cstate.block; this.cstate.inUse[b] = true; int rl = this.runLength; this.crc.UpdateCRC(b, rl); - switch (rl) - { + switch (rl) { case 1: block[previousLast + 2] = b; this.last = previousLast + 1; @@ -374,7 +354,7 @@ private bool AddRunToOutputBlock(bool final) block[previousLast + 3] = b; block[previousLast + 4] = b; block[previousLast + 5] = b; - block[previousLast + 6] = (byte) rl; + block[previousLast + 6] = (byte)rl; this.last = previousLast + 5; break; } @@ -429,11 +409,11 @@ public void CompressAndWrite() // endBlock this.bw.WriteByte(0x53); this.bw.WriteByte(0x59); - this.Crc32 = (uint) this.crc.Crc32Result; + this.Crc32 = (uint)this.crc.Crc32Result; this.bw.WriteInt(this.Crc32); /* Now a single bit indicating randomisation. */ - this.bw.WriteBits(1, (this.blockRandomised)?1U:0U); + this.bw.WriteBits(1, (this.blockRandomised) ? 1U : 0U); /* Finally, block's contents proper. */ moveToFrontCodeAndSend(); @@ -442,8 +422,7 @@ public void CompressAndWrite() // endBlock } - private void randomiseBlock() - { + private void randomiseBlock() { bool[] inUse = this.cstate.inUse; byte[] block = this.cstate.block; int lastShadow = this.last; @@ -453,19 +432,16 @@ private void randomiseBlock() int rNToGo = 0; int rTPos = 0; - for (int i = 0, j = 1; i <= lastShadow; i = j, j++) - { - if (rNToGo == 0) - { - rNToGo = (char) Rand.Rnums(rTPos); - if (++rTPos == 512) - { + for (int i = 0, j = 1; i <= lastShadow; i = j, j++) { + if (rNToGo == 0) { + rNToGo = (char)Rand.Rnums(rTPos); + if (++rTPos == 512) { rTPos = 0; } } rNToGo--; - block[j] ^= (byte) ((rNToGo == 1) ? 1 : 0); + block[j] ^= (byte)((rNToGo == 1) ? 1 : 0); // handle 16 bit signed numbers inUse[block[j] & 0xff] = true; @@ -474,8 +450,7 @@ private void randomiseBlock() this.blockRandomised = true; } - private void mainSort() - { + private void mainSort() { CompressionState dataShadow = this.cstate; int[] runningOrder = dataShadow.mainSort_runningOrder; int[] copy = dataShadow.mainSort_copy; @@ -489,8 +464,7 @@ private void mainSort() bool firstAttemptShadow = this.firstAttempt; // Set up the 2-byte frequency table - for (int i = 65537; --i >= 0;) - { + for (int i = 65537; --i >= 0;) { ftab[i] = 0; } @@ -499,12 +473,10 @@ private void mainSort() * last+NUM_OVERSHOOT_BYTES inclusive. First, set up the overshoot area * for block. */ - for (int i = 0; i < BZip2.NUM_OVERSHOOT_BYTES; i++) - { + for (int i = 0; i < BZip2.NUM_OVERSHOOT_BYTES; i++) { block[lastShadow + i + 2] = block[(i % (lastShadow + 1)) + 1]; } - for (int i = lastShadow + BZip2.NUM_OVERSHOOT_BYTES +1; --i >= 0;) - { + for (int i = lastShadow + BZip2.NUM_OVERSHOOT_BYTES + 1; --i >= 0;) { quadrant[i] = '\0'; } block[0] = block[lastShadow + 1]; @@ -512,8 +484,7 @@ private void mainSort() // Complete the initial radix sort: int c1 = block[0] & 0xff; - for (int i = 0; i <= lastShadow; i++) - { + for (int i = 0; i <= lastShadow; i++) { int c2 = block[i + 1] & 0xff; ftab[(c1 << 8) + c2]++; c1 = c2; @@ -523,8 +494,7 @@ private void mainSort() ftab[i] += ftab[i - 1]; c1 = block[1] & 0xff; - for (int i = 0; i < lastShadow; i++) - { + for (int i = 0; i < lastShadow; i++) { int c2 = block[i + 2] & 0xff; fmap[--ftab[(c1 << 8) + c2]] = i; c1 = c2; @@ -536,28 +506,23 @@ private void mainSort() * Now ftab contains the first loc of every small bucket. Calculate the * running order, from smallest to largest big bucket. */ - for (int i = 256; --i >= 0;) - { + for (int i = 256; --i >= 0;) { bigDone[i] = false; runningOrder[i] = i; } - for (int h = 364; h != 1;) - { + for (int h = 364; h != 1;) { h /= 3; - for (int i = h; i <= 255; i++) - { + for (int i = h; i <= 255; i++) { int vv = runningOrder[i]; int a = ftab[(vv + 1) << 8] - ftab[vv << 8]; int b = h - 1; int j = i; for (int ro = runningOrder[j - h]; (ftab[(ro + 1) << 8] - ftab[ro << 8]) > a; ro = runningOrder[j - - h]) - { + - h]) { runningOrder[j] = ro; j -= h; - if (j <= b) - { + if (j <= b) { break; } } @@ -568,8 +533,7 @@ private void mainSort() /* * The main sorting loop. */ - for (int i = 0; i <= 255; i++) - { + for (int i = 0; i <= 255; i++) { /* * Process big buckets, starting with the least full. */ @@ -582,20 +546,16 @@ private void mainSort() * already completed many of the small buckets [ss, j], so we don't * have to sort them at all. */ - for (int j = 0; j <= 255; j++) - { + for (int j = 0; j <= 255; j++) { int sb = (ss << 8) + j; int ftab_sb = ftab[sb]; - if ((ftab_sb & SETMASK) != SETMASK) - { + if ((ftab_sb & SETMASK) != SETMASK) { int lo = ftab_sb & CLEARMASK; int hi = (ftab[sb + 1] & CLEARMASK) - 1; - if (hi > lo) - { + if (hi > lo) { mainQSort3(dataShadow, lo, hi, 2); if (firstAttemptShadow - && (this.workDone > workLimitShadow)) - { + && (this.workDone > workLimitShadow)) { return; } } @@ -607,17 +567,14 @@ private void mainSort() // Now scan this big bucket so as to synthesise the // sorted order for small buckets [t, ss] for all t != ss. - for (int j = 0; j <= 255; j++) - { + for (int j = 0; j <= 255; j++) { copy[j] = ftab[(j << 8) + ss] & CLEARMASK; } - for (int j = ftab[ss << 8] & CLEARMASK, hj = (ftab[(ss + 1) << 8] & CLEARMASK); j < hj; j++) - { + for (int j = ftab[ss << 8] & CLEARMASK, hj = (ftab[(ss + 1) << 8] & CLEARMASK); j < hj; j++) { int fmap_j = fmap[j]; c1 = block[fmap_j] & 0xff; - if (!bigDone[c1]) - { + if (!bigDone[c1]) { fmap[copy[c1]] = (fmap_j == 0) ? lastShadow : (fmap_j - 1); copy[c1]++; } @@ -636,24 +593,20 @@ private void mainSort() */ bigDone[ss] = true; - if (i < 255) - { + if (i < 255) { int bbStart = ftab[ss << 8] & CLEARMASK; int bbSize = (ftab[(ss + 1) << 8] & CLEARMASK) - bbStart; int shifts = 0; - while ((bbSize >> shifts) > 65534) - { + while ((bbSize >> shifts) > 65534) { shifts++; } - for (int j = 0; j < bbSize; j++) - { + for (int j = 0; j < bbSize; j++) { int a2update = fmap[bbStart + j]; - char qVal = (char) (j >> shifts); + char qVal = (char)(j >> shifts); quadrant[a2update] = qVal; - if (a2update < BZip2.NUM_OVERSHOOT_BYTES) - { + if (a2update < BZip2.NUM_OVERSHOOT_BYTES) { quadrant[a2update + lastShadow + 1] = qVal; } } @@ -663,16 +616,14 @@ private void mainSort() } - private void blockSort() - { + private void blockSort() { this.workLimit = WORK_FACTOR * this.last; this.workDone = 0; this.blockRandomised = false; this.firstAttempt = true; mainSort(); - if (this.firstAttempt && (this.workDone > this.workLimit)) - { + if (this.firstAttempt && (this.workDone > this.workLimit)) { randomiseBlock(); this.workLimit = this.workDone = 0; this.firstAttempt = false; @@ -681,10 +632,8 @@ private void blockSort() int[] fmap = this.cstate.fmap; this.origPtr = -1; - for (int i = 0, lastShadow = this.last; i <= lastShadow; i++) - { - if (fmap[i] == 0) - { + for (int i = 0, lastShadow = this.last; i <= lastShadow; i++) { + if (fmap[i] == 0) { this.origPtr = i; break; } @@ -702,11 +651,9 @@ private void blockSort() *

*/ private bool mainSimpleSort(CompressionState dataShadow, int lo, - int hi, int d) - { + int hi, int d) { int bigN = hi - lo + 1; - if (bigN < 2) - { + if (bigN < 2) { return this.firstAttempt && (this.workDone > this.workLimit); } @@ -727,16 +674,13 @@ private bool mainSimpleSort(CompressionState dataShadow, int lo, // coding it in additional loops. // HP: - while (--hp >= 0) - { + while (--hp >= 0) { int h = increments[hp]; int mj = lo + h - 1; - for (int i = lo + h; i <= hi;) - { + for (int i = lo + h; i <= hi;) { // copy - for (int k = 3; (i <= hi) && (--k >= 0); i++) - { + for (int k = 3; (i <= hi) && (--k >= 0); i++) { int v = fmap[i]; int vd = v + d; int j = i; @@ -754,17 +698,13 @@ private bool mainSimpleSort(CompressionState dataShadow, int lo, bool onceRunned = false; int a = 0; - HAMMER: while (true) - { - if (onceRunned) - { + HAMMER: while (true) { + if (onceRunned) { fmap[j] = a; - if ((j -= h) <= mj) - { + if ((j -= h) <= mj) { goto END_HAMMER; } - } - else { + } else { onceRunned = true; } @@ -774,111 +714,70 @@ private bool mainSimpleSort(CompressionState dataShadow, int lo, // following could be done in a loop, but // unrolled it for performance: - if (block[i1 + 1] == block[i2 + 1]) - { - if (block[i1 + 2] == block[i2 + 2]) - { - if (block[i1 + 3] == block[i2 + 3]) - { - if (block[i1 + 4] == block[i2 + 4]) - { - if (block[i1 + 5] == block[i2 + 5]) - { - if (block[(i1 += 6)] == block[(i2 += 6)]) - { + if (block[i1 + 1] == block[i2 + 1]) { + if (block[i1 + 2] == block[i2 + 2]) { + if (block[i1 + 3] == block[i2 + 3]) { + if (block[i1 + 4] == block[i2 + 4]) { + if (block[i1 + 5] == block[i2 + 5]) { + if (block[(i1 += 6)] == block[(i2 += 6)]) { int x = lastShadow; - X: while (x > 0) - { + X: while (x > 0) { x -= 4; - if (block[i1 + 1] == block[i2 + 1]) - { - if (quadrant[i1] == quadrant[i2]) - { - if (block[i1 + 2] == block[i2 + 2]) - { - if (quadrant[i1 + 1] == quadrant[i2 + 1]) - { - if (block[i1 + 3] == block[i2 + 3]) - { - if (quadrant[i1 + 2] == quadrant[i2 + 2]) - { - if (block[i1 + 4] == block[i2 + 4]) - { - if (quadrant[i1 + 3] == quadrant[i2 + 3]) - { - if ((i1 += 4) >= lastPlus1) - { + if (block[i1 + 1] == block[i2 + 1]) { + if (quadrant[i1] == quadrant[i2]) { + if (block[i1 + 2] == block[i2 + 2]) { + if (quadrant[i1 + 1] == quadrant[i2 + 1]) { + if (block[i1 + 3] == block[i2 + 3]) { + if (quadrant[i1 + 2] == quadrant[i2 + 2]) { + if (block[i1 + 4] == block[i2 + 4]) { + if (quadrant[i1 + 3] == quadrant[i2 + 3]) { + if ((i1 += 4) >= lastPlus1) { i1 -= lastPlus1; } - if ((i2 += 4) >= lastPlus1) - { + if ((i2 += 4) >= lastPlus1) { i2 -= lastPlus1; } workDoneShadow++; goto X; - } - else if ((quadrant[i1 + 3] > quadrant[i2 + 3])) - { + } else if ((quadrant[i1 + 3] > quadrant[i2 + 3])) { goto HAMMER; - } - else { + } else { goto END_HAMMER; } - } - else if ((block[i1 + 4] & 0xff) > (block[i2 + 4] & 0xff)) - { + } else if ((block[i1 + 4] & 0xff) > (block[i2 + 4] & 0xff)) { goto HAMMER; - } - else { + } else { goto END_HAMMER; } - } - else if ((quadrant[i1 + 2] > quadrant[i2 + 2])) - { + } else if ((quadrant[i1 + 2] > quadrant[i2 + 2])) { goto HAMMER; - } - else { + } else { goto END_HAMMER; } - } - else if ((block[i1 + 3] & 0xff) > (block[i2 + 3] & 0xff)) - { + } else if ((block[i1 + 3] & 0xff) > (block[i2 + 3] & 0xff)) { goto HAMMER; - } - else { + } else { goto END_HAMMER; } - } - else if ((quadrant[i1 + 1] > quadrant[i2 + 1])) - { + } else if ((quadrant[i1 + 1] > quadrant[i2 + 1])) { goto HAMMER; - } - else { + } else { goto END_HAMMER; } - } - else if ((block[i1 + 2] & 0xff) > (block[i2 + 2] & 0xff)) - { + } else if ((block[i1 + 2] & 0xff) > (block[i2 + 2] & 0xff)) { goto HAMMER; - } - else { + } else { goto END_HAMMER; } - } - else if ((quadrant[i1] > quadrant[i2])) - { + } else if ((quadrant[i1] > quadrant[i2])) { goto HAMMER; - } - else { + } else { goto END_HAMMER; } - } - else if ((block[i1 + 1] & 0xff) > (block[i2 + 1] & 0xff)) - { + } else if ((block[i1 + 1] & 0xff) > (block[i2 + 1] & 0xff)) { goto HAMMER; - } - else { + } else { goto END_HAMMER; } @@ -886,71 +785,53 @@ private bool mainSimpleSort(CompressionState dataShadow, int lo, goto END_HAMMER; } // while x > 0 else { - if ((block[i1] & 0xff) > (block[i2] & 0xff)) - { + if ((block[i1] & 0xff) > (block[i2] & 0xff)) { goto HAMMER; - } - else { + } else { goto END_HAMMER; } } - } - else if ((block[i1 + 5] & 0xff) > (block[i2 + 5] & 0xff)) - { + } else if ((block[i1 + 5] & 0xff) > (block[i2 + 5] & 0xff)) { goto HAMMER; - } - else { + } else { goto END_HAMMER; } - } - else if ((block[i1 + 4] & 0xff) > (block[i2 + 4] & 0xff)) - { + } else if ((block[i1 + 4] & 0xff) > (block[i2 + 4] & 0xff)) { goto HAMMER; - } - else { + } else { goto END_HAMMER; } - } - else if ((block[i1 + 3] & 0xff) > (block[i2 + 3] & 0xff)) - { + } else if ((block[i1 + 3] & 0xff) > (block[i2 + 3] & 0xff)) { goto HAMMER; - } - else { + } else { goto END_HAMMER; } - } - else if ((block[i1 + 2] & 0xff) > (block[i2 + 2] & 0xff)) - { + } else if ((block[i1 + 2] & 0xff) > (block[i2 + 2] & 0xff)) { goto HAMMER; - } - else { + } else { goto END_HAMMER; } - } - else if ((block[i1 + 1] & 0xff) > (block[i2 + 1] & 0xff)) - { + } else if ((block[i1 + 1] & 0xff) > (block[i2 + 1] & 0xff)) { goto HAMMER; - } - else { + } else { goto END_HAMMER; } } // HAMMER - END_HAMMER: + END_HAMMER: // end inline mainGTU fmap[j] = v; } if (firstAttemptShadow && (i <= hi) - && (workDoneShadow > workLimitShadow)) - { + && (workDoneShadow > workLimitShadow)) { goto END_HP; } } } - END_HP: + END_HP: this.workDone = workDoneShadow; return firstAttemptShadow && (workDoneShadow > workLimitShadow); @@ -958,19 +839,16 @@ private bool mainSimpleSort(CompressionState dataShadow, int lo, - private static void vswap(int[] fmap, int p1, int p2, int n) - { + private static void vswap(int[] fmap, int p1, int p2, int n) { n += p1; - while (p1 < n) - { + while (p1 < n) { int t = fmap[p1]; fmap[p1++] = fmap[p2]; fmap[p2++] = t; } } - private static byte med3(byte a, byte b, byte c) - { + private static byte med3(byte a, byte b, byte c) { return (a < b) ? (b < c ? b : a < c ? c : a) : (b > c ? b : a > c ? c : a); } @@ -980,8 +858,7 @@ private static byte med3(byte a, byte b, byte c) * Method "mainQSort3", file "blocksort.c", BZip2 1.0.2 */ private void mainQSort3(CompressionState dataShadow, int loSt, - int hiSt, int dSt) - { + int hiSt, int dSt) { int[] stack_ll = dataShadow.stack_ll; int[] stack_hh = dataShadow.stack_hh; int[] stack_dd = dataShadow.stack_dd; @@ -992,20 +869,16 @@ private void mainQSort3(CompressionState dataShadow, int loSt, stack_hh[0] = hiSt; stack_dd[0] = dSt; - for (int sp = 1; --sp >= 0;) - { + for (int sp = 1; --sp >= 0;) { int lo = stack_ll[sp]; int hi = stack_hh[sp]; int d = stack_dd[sp]; - if ((hi - lo < SMALL_THRESH) || (d > DEPTH_THRESH)) - { - if (mainSimpleSort(dataShadow, lo, hi, d)) - { + if ((hi - lo < SMALL_THRESH) || (d > DEPTH_THRESH)) { + if (mainSimpleSort(dataShadow, lo, hi, d)) { return; } - } - else { + } else { int d1 = d + 1; int med = med3(block[fmap[lo] + d1], block[fmap[hi] + d1], block[fmap[(lo + hi) >> 1] + d1]) & 0xff; @@ -1015,65 +888,50 @@ private void mainQSort3(CompressionState dataShadow, int loSt, int ltLo = lo; int gtHi = hi; - while (true) - { - while (unLo <= unHi) - { + while (true) { + while (unLo <= unHi) { int n = (block[fmap[unLo] + d1] & 0xff) - med; - if (n == 0) - { + if (n == 0) { int temp = fmap[unLo]; fmap[unLo++] = fmap[ltLo]; fmap[ltLo++] = temp; - } - else if (n < 0) - { + } else if (n < 0) { unLo++; - } - else { + } else { break; } } - while (unLo <= unHi) - { + while (unLo <= unHi) { int n = (block[fmap[unHi] + d1] & 0xff) - med; - if (n == 0) - { + if (n == 0) { int temp = fmap[unHi]; fmap[unHi--] = fmap[gtHi]; fmap[gtHi--] = temp; - } - else if (n > 0) - { + } else if (n > 0) { unHi--; - } - else { + } else { break; } } - if (unLo <= unHi) - { + if (unLo <= unHi) { int temp = fmap[unLo]; fmap[unLo++] = fmap[unHi]; fmap[unHi--] = temp; - } - else { + } else { break; } } - if (gtHi < ltLo) - { + if (gtHi < ltLo) { stack_ll[sp] = lo; stack_hh[sp] = hi; stack_dd[sp] = d1; sp++; - } - else { + } else { int n = ((ltLo - lo) < (unLo - ltLo)) ? (ltLo - lo) : (unLo - ltLo); vswap(fmap, lo, unLo - n, n); @@ -1105,8 +963,7 @@ private void mainQSort3(CompressionState dataShadow, int loSt, - private void generateMTFValues() - { + private void generateMTFValues() { int lastShadow = this.last; CompressionState dataShadow = this.cstate; bool[] inUse = dataShadow.inUse; @@ -1119,11 +976,9 @@ private void generateMTFValues() // make maps int nInUseShadow = 0; - for (int i = 0; i < 256; i++) - { - if (inUse[i]) - { - unseqToSeq[i] = (byte) nInUseShadow; + for (int i = 0; i < 256; i++) { + if (inUse[i]) { + unseqToSeq[i] = (byte)nInUseShadow; nInUseShadow++; } } @@ -1131,27 +986,23 @@ private void generateMTFValues() int eob = nInUseShadow + 1; - for (int i = eob; i >= 0; i--) - { + for (int i = eob; i >= 0; i--) { mtfFreq[i] = 0; } - for (int i = nInUseShadow; --i >= 0;) - { - yy[i] = (byte) i; + for (int i = nInUseShadow; --i >= 0;) { + yy[i] = (byte)i; } int wr = 0; int zPend = 0; - for (int i = 0; i <= lastShadow; i++) - { + for (int i = 0; i <= lastShadow; i++) { byte ll_i = unseqToSeq[block[fmap[i]] & 0xff]; byte tmp = yy[0]; int j = 0; - while (ll_i != tmp) - { + while (ll_i != tmp) { j++; byte tmp2 = tmp; tmp = yy[j]; @@ -1159,93 +1010,70 @@ private void generateMTFValues() } yy[0] = tmp; - if (j == 0) - { + if (j == 0) { zPend++; - } - else - { - if (zPend > 0) - { + } else { + if (zPend > 0) { zPend--; - while (true) - { - if ((zPend & 1) == 0) - { + while (true) { + if ((zPend & 1) == 0) { sfmap[wr] = BZip2.RUNA; wr++; mtfFreq[BZip2.RUNA]++; - } - else - { + } else { sfmap[wr] = BZip2.RUNB; wr++; mtfFreq[BZip2.RUNB]++; } - if (zPend >= 2) - { + if (zPend >= 2) { zPend = (zPend - 2) >> 1; - } - else - { + } else { break; } } zPend = 0; } - sfmap[wr] = (char) (j + 1); + sfmap[wr] = (char)(j + 1); wr++; mtfFreq[j + 1]++; } } - if (zPend > 0) - { + if (zPend > 0) { zPend--; - while (true) - { - if ((zPend & 1) == 0) - { + while (true) { + if ((zPend & 1) == 0) { sfmap[wr] = BZip2.RUNA; wr++; mtfFreq[BZip2.RUNA]++; - } - else - { + } else { sfmap[wr] = BZip2.RUNB; wr++; mtfFreq[BZip2.RUNB]++; } - if (zPend >= 2) - { + if (zPend >= 2) { zPend = (zPend - 2) >> 1; - } - else - { + } else { break; } } } - sfmap[wr] = (char) eob; + sfmap[wr] = (char)eob; mtfFreq[eob]++; this.nMTF = wr + 1; } - private static void hbAssignCodes(int[] code, byte[] length, + private static void hbAssignCodes(int[] code, byte[] length, int minLen, int maxLen, - int alphaSize) - { + int alphaSize) { int vec = 0; - for (int n = minLen; n <= maxLen; n++) - { - for (int i = 0; i < alphaSize; i++) - { - if ((length[i] & 0xff) == n) - { + for (int n = minLen; n <= maxLen; n++) { + for (int i = 0; i < alphaSize; i++) { + if ((length[i] & 0xff) == n) { code[i] = vec; vec++; } @@ -1257,16 +1085,13 @@ private static void hbAssignCodes(int[] code, byte[] length, - private void sendMTFValues() - { + private void sendMTFValues() { byte[][] len = this.cstate.sendMTFValues_len; int alphaSize = this.nInUse + 2; - for (int t = BZip2.NGroups; --t >= 0;) - { + for (int t = BZip2.NGroups; --t >= 0;) { byte[] len_t = len[t]; - for (int v = alphaSize; --v >= 0;) - { + for (int v = alphaSize; --v >= 0;) { len_t[v] = GREATER_ICOST; } } @@ -1303,39 +1128,32 @@ private void sendMTFValues() sendMTFValues7(nSelectors); } - private void sendMTFValues0(int nGroups, int alphaSize) - { + private void sendMTFValues0(int nGroups, int alphaSize) { byte[][] len = this.cstate.sendMTFValues_len; int[] mtfFreq = this.cstate.mtfFreq; int remF = this.nMTF; int gs = 0; - for (int nPart = nGroups; nPart > 0; nPart--) - { + for (int nPart = nGroups; nPart > 0; nPart--) { int tFreq = remF / nPart; int ge = gs - 1; int aFreq = 0; - for (int a = alphaSize - 1; (aFreq < tFreq) && (ge < a);) - { + for (int a = alphaSize - 1; (aFreq < tFreq) && (ge < a);) { aFreq += mtfFreq[++ge]; } if ((ge > gs) && (nPart != nGroups) && (nPart != 1) - && (((nGroups - nPart) & 1) != 0)) - { + && (((nGroups - nPart) & 1) != 0)) { aFreq -= mtfFreq[ge--]; } byte[] len_np = len[nPart - 1]; - for (int v = alphaSize; --v >= 0;) - { - if ((v >= gs) && (v <= ge)) - { + for (int v = alphaSize; --v >= 0;) { + if ((v >= gs) && (v <= ge)) { len_np[v] = LESSER_ICOST; - } - else { + } else { len_np[v] = GREATER_ICOST; } } @@ -1346,10 +1164,9 @@ private void sendMTFValues0(int nGroups, int alphaSize) } - private static void hbMakeCodeLengths(byte[] len, int[] freq, + private static void hbMakeCodeLengths(byte[] len, int[] freq, CompressionState state1, int alphaSize, - int maxLen) - { + int maxLen) { /* * Nodes and heap entries run from 1. Entry 0 for both the heap and * nodes is a sentinel. @@ -1358,13 +1175,11 @@ private static void hbMakeCodeLengths(byte[] len, int[] freq, int[] weight = state1.weight; int[] parent = state1.parent; - for (int i = alphaSize; --i >= 0;) - { + for (int i = alphaSize; --i >= 0;) { weight[i + 1] = (freq[i] == 0 ? 1 : freq[i]) << 8; } - for (bool tooLong = true; tooLong;) - { + for (bool tooLong = true; tooLong;) { tooLong = false; int nNodes = alphaSize; @@ -1373,24 +1188,21 @@ private static void hbMakeCodeLengths(byte[] len, int[] freq, weight[0] = 0; parent[0] = -2; - for (int i = 1; i <= alphaSize; i++) - { + for (int i = 1; i <= alphaSize; i++) { parent[i] = -1; nHeap++; heap[nHeap] = i; int zz = nHeap; int tmp = heap[zz]; - while (weight[tmp] < weight[heap[zz >> 1]]) - { + while (weight[tmp] < weight[heap[zz >> 1]]) { heap[zz] = heap[zz >> 1]; zz >>= 1; } heap[zz] = tmp; } - while (nHeap > 1) - { + while (nHeap > 1) { int n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; @@ -1399,23 +1211,19 @@ private static void hbMakeCodeLengths(byte[] len, int[] freq, int zz = 1; int tmp = heap[1]; - while (true) - { + while (true) { yy = zz << 1; - if (yy > nHeap) - { + if (yy > nHeap) { break; } if ((yy < nHeap) - && (weight[heap[yy + 1]] < weight[heap[yy]])) - { + && (weight[heap[yy + 1]] < weight[heap[yy]])) { yy++; } - if (weight[tmp] < weight[heap[yy]]) - { + if (weight[tmp] < weight[heap[yy]]) { break; } @@ -1433,23 +1241,19 @@ private static void hbMakeCodeLengths(byte[] len, int[] freq, zz = 1; tmp = heap[1]; - while (true) - { + while (true) { yy = zz << 1; - if (yy > nHeap) - { + if (yy > nHeap) { break; } if ((yy < nHeap) - && (weight[heap[yy + 1]] < weight[heap[yy]])) - { + && (weight[heap[yy + 1]] < weight[heap[yy]])) { yy++; } - if (weight[tmp] < weight[heap[yy]]) - { + if (weight[tmp] < weight[heap[yy]]) { break; } @@ -1463,7 +1267,7 @@ private static void hbMakeCodeLengths(byte[] len, int[] freq, int weight_n1 = weight[n1]; int weight_n2 = weight[n2]; - weight[nNodes] = (int) (((uint)weight_n1 & 0xffffff00U) + weight[nNodes] = (int)(((uint)weight_n1 & 0xffffff00U) + ((uint)weight_n2 & 0xffffff00U)) | (1 + (((weight_n1 & 0x000000ff) > (weight_n2 & 0x000000ff)) @@ -1478,8 +1282,7 @@ private static void hbMakeCodeLengths(byte[] len, int[] freq, zz = nHeap; tmp = heap[zz]; int weight_tmp = weight[tmp]; - while (weight_tmp < weight[heap[zz >> 1]]) - { + while (weight_tmp < weight[heap[zz >> 1]]) { heap[zz] = heap[zz >> 1]; zz >>= 1; } @@ -1487,28 +1290,23 @@ private static void hbMakeCodeLengths(byte[] len, int[] freq, } - for (int i = 1; i <= alphaSize; i++) - { + for (int i = 1; i <= alphaSize; i++) { int j = 0; int k = i; - for (int parent_k; (parent_k = parent[k]) >= 0;) - { + for (int parent_k; (parent_k = parent[k]) >= 0;) { k = parent_k; j++; } - len[i - 1] = (byte) j; - if (j > maxLen) - { + len[i - 1] = (byte)j; + if (j > maxLen) { tooLong = true; } } - if (tooLong) - { - for (int i = 1; i < alphaSize; i++) - { + if (tooLong) { + for (int i = 1; i < alphaSize; i++) { int j = weight[i] >> 8; j = 1 + (j >> 1); weight[i] = j << 8; @@ -1518,8 +1316,7 @@ private static void hbMakeCodeLengths(byte[] len, int[] freq, } - private int sendMTFValues1(int nGroups, int alphaSize) - { + private int sendMTFValues1(int nGroups, int alphaSize) { CompressionState dataShadow = this.cstate; int[][] rfreq = dataShadow.sendMTFValues_rfreq; int[] fave = dataShadow.sendMTFValues_fave; @@ -1537,22 +1334,18 @@ private int sendMTFValues1(int nGroups, int alphaSize) int nSelectors = 0; - for (int iter = 0; iter < BZip2.N_ITERS; iter++) - { - for (int t = nGroups; --t >= 0;) - { + for (int iter = 0; iter < BZip2.N_ITERS; iter++) { + for (int t = nGroups; --t >= 0;) { fave[t] = 0; int[] rfreqt = rfreq[t]; - for (int i = alphaSize; --i >= 0;) - { + for (int i = alphaSize; --i >= 0;) { rfreqt[i] = 0; } } nSelectors = 0; - for (int gs = 0; gs < this.nMTF;) - { + for (int gs = 0; gs < this.nMTF;) { /* Set group start & end marks. */ /* @@ -1562,14 +1355,12 @@ private int sendMTFValues1(int nGroups, int alphaSize) int ge = Math.Min(gs + BZip2.G_SIZE - 1, nMTFShadow - 1); - if (nGroups == BZip2.NGroups) - { + if (nGroups == BZip2.NGroups) { // unrolled version of the else-block int[] c = new int[6]; - for (int i = gs; i <= ge; i++) - { + for (int i = gs; i <= ge; i++) { int icv = sfmap[i]; c[0] += len_0[icv] & 0xff; c[1] += len_1[icv] & 0xff; @@ -1579,26 +1370,21 @@ private int sendMTFValues1(int nGroups, int alphaSize) c[5] += len_5[icv] & 0xff; } - cost[0] = (short) c[0]; - cost[1] = (short) c[1]; - cost[2] = (short) c[2]; - cost[3] = (short) c[3]; - cost[4] = (short) c[4]; - cost[5] = (short) c[5]; - } - else - { - for (int t = nGroups; --t >= 0;) - { + cost[0] = (short)c[0]; + cost[1] = (short)c[1]; + cost[2] = (short)c[2]; + cost[3] = (short)c[3]; + cost[4] = (short)c[4]; + cost[5] = (short)c[5]; + } else { + for (int t = nGroups; --t >= 0;) { cost[t] = 0; } - for (int i = gs; i <= ge; i++) - { + for (int i = gs; i <= ge; i++) { int icv = sfmap[i]; - for (int t = nGroups; --t >= 0;) - { - cost[t] += (short) (len[t][icv] & 0xff); + for (int t = nGroups; --t >= 0;) { + cost[t] += (short)(len[t][icv] & 0xff); } } } @@ -1608,26 +1394,23 @@ private int sendMTFValues1(int nGroups, int alphaSize) * record its identity in the selector table. */ int bt = -1; - for (int t = nGroups, bc = 999999999; --t >= 0;) - { + for (int t = nGroups, bc = 999999999; --t >= 0;) { int cost_t = cost[t]; - if (cost_t < bc) - { + if (cost_t < bc) { bc = cost_t; bt = t; } } fave[bt]++; - selector[nSelectors] = (byte) bt; + selector[nSelectors] = (byte)bt; nSelectors++; /* * Increment the symbol frequencies for the selected table. */ int[] rfreq_bt = rfreq[bt]; - for (int i = gs; i <= ge; i++) - { + for (int i = gs; i <= ge; i++) { rfreq_bt[sfmap[i]]++; } @@ -1637,8 +1420,7 @@ private int sendMTFValues1(int nGroups, int alphaSize) /* * Recompute the tables based on the accumulated frequencies. */ - for (int t = 0; t < nGroups; t++) - { + for (int t = 0; t < nGroups; t++) { hbMakeCodeLengths(len[t], rfreq[t], this.cstate, alphaSize, 20); } } @@ -1646,26 +1428,22 @@ private int sendMTFValues1(int nGroups, int alphaSize) return nSelectors; } - private void sendMTFValues2(int nGroups, int nSelectors) - { + private void sendMTFValues2(int nGroups, int nSelectors) { // assert (nGroups < 8) : nGroups; CompressionState dataShadow = this.cstate; byte[] pos = dataShadow.sendMTFValues2_pos; - for (int i = nGroups; --i >= 0;) - { - pos[i] = (byte) i; + for (int i = nGroups; --i >= 0;) { + pos[i] = (byte)i; } - for (int i = 0; i < nSelectors; i++) - { + for (int i = 0; i < nSelectors; i++) { byte ll_i = dataShadow.selector[i]; byte tmp = pos[0]; int j = 0; - while (ll_i != tmp) - { + while (ll_i != tmp) { j++; byte tmp2 = tmp; tmp = pos[j]; @@ -1673,29 +1451,24 @@ private void sendMTFValues2(int nGroups, int nSelectors) } pos[0] = tmp; - dataShadow.selectorMtf[i] = (byte) j; + dataShadow.selectorMtf[i] = (byte)j; } } - private void sendMTFValues3(int nGroups, int alphaSize) - { + private void sendMTFValues3(int nGroups, int alphaSize) { int[][] code = this.cstate.sendMTFValues_code; byte[][] len = this.cstate.sendMTFValues_len; - for (int t = 0; t < nGroups; t++) - { + for (int t = 0; t < nGroups; t++) { int minLen = 32; int maxLen = 0; byte[] len_t = len[t]; - for (int i = alphaSize; --i >= 0;) - { + for (int i = alphaSize; --i >= 0;) { int l = len_t[i] & 0xff; - if (l > maxLen) - { + if (l > maxLen) { maxLen = l; } - if (l < minLen) - { + if (l < minLen) { minLen = l; } } @@ -1707,43 +1480,34 @@ private void sendMTFValues3(int nGroups, int alphaSize) } } - private void sendMTFValues4() - { + private void sendMTFValues4() { bool[] inUse = this.cstate.inUse; bool[] inUse16 = this.cstate.sentMTFValues4_inUse16; - for (int i = 16; --i >= 0;) - { + for (int i = 16; --i >= 0;) { inUse16[i] = false; int i16 = i * 16; - for (int j = 16; --j >= 0;) - { - if (inUse[i16 + j]) - { + for (int j = 16; --j >= 0;) { + if (inUse[i16 + j]) { inUse16[i] = true; } } } uint u = 0; - for (int i = 0; i < 16; i++) - { + for (int i = 0; i < 16; i++) { if (inUse16[i]) u |= 1U << (16 - i - 1); } this.bw.WriteBits(16, u); - for (int i = 0; i < 16; i++) - { - if (inUse16[i]) - { + for (int i = 0; i < 16; i++) { + if (inUse16[i]) { int i16 = i * 16; u = 0; - for (int j = 0; j < 16; j++) - { - if (inUse[i16 + j]) - { + for (int j = 0; j < 16; j++) { + if (inUse[i16 + j]) { u |= 1U << (16 - j - 1); } } @@ -1753,17 +1517,14 @@ private void sendMTFValues4() } - private void sendMTFValues5(int nGroups, int nSelectors) - { - this.bw.WriteBits(3, (uint) nGroups); - this.bw.WriteBits(15, (uint) nSelectors); + private void sendMTFValues5(int nGroups, int nSelectors) { + this.bw.WriteBits(3, (uint)nGroups); + this.bw.WriteBits(15, (uint)nSelectors); byte[] selectorMtf = this.cstate.selectorMtf; - for (int i = 0; i < nSelectors; i++) - { - for (int j = 0, hj = selectorMtf[i] & 0xff; j < hj; j++) - { + for (int i = 0; i < nSelectors; i++) { + for (int j = 0, hj = selectorMtf[i] & 0xff; j < hj; j++) { this.bw.WriteBits(1, 1); } @@ -1771,27 +1532,22 @@ private void sendMTFValues5(int nGroups, int nSelectors) } } - private void sendMTFValues6(int nGroups, int alphaSize) - { + private void sendMTFValues6(int nGroups, int alphaSize) { byte[][] len = this.cstate.sendMTFValues_len; - for (int t = 0; t < nGroups; t++) - { + for (int t = 0; t < nGroups; t++) { byte[] len_t = len[t]; - uint curr = (uint) (len_t[0] & 0xff); + uint curr = (uint)(len_t[0] & 0xff); this.bw.WriteBits(5, curr); - for (int i = 0; i < alphaSize; i++) - { + for (int i = 0; i < alphaSize; i++) { int lti = len_t[i] & 0xff; - while (curr < lti) - { + while (curr < lti) { this.bw.WriteBits(2, 2U); curr++; /* 10 */ } - while (curr > lti) - { + while (curr > lti) { this.bw.WriteBits(2, 3U); curr--; /* 11 */ } @@ -1802,28 +1558,25 @@ private void sendMTFValues6(int nGroups, int alphaSize) } - private void sendMTFValues7(int nSelectors) - { - byte[][] len = this.cstate.sendMTFValues_len; - int[][] code = this.cstate.sendMTFValues_code; + private void sendMTFValues7(int nSelectors) { + byte[][] len = this.cstate.sendMTFValues_len; + int[][] code = this.cstate.sendMTFValues_code; byte[] selector = this.cstate.selector; - char[] sfmap = this.cstate.sfmap; - int nMTFShadow = this.nMTF; + char[] sfmap = this.cstate.sfmap; + int nMTFShadow = this.nMTF; int selCtr = 0; - for (int gs = 0; gs < nMTFShadow;) - { + for (int gs = 0; gs < nMTFShadow;) { int ge = Math.Min(gs + BZip2.G_SIZE - 1, nMTFShadow - 1); int ix = selector[selCtr] & 0xff; int[] code_selCtr = code[ix]; byte[] len_selCtr = len[ix]; - while (gs <= ge) - { + while (gs <= ge) { int sfmap_i = sfmap[gs]; int n = len_selCtr[sfmap_i] & 0xFF; - this.bw.WriteBits(n, (uint) code_selCtr[sfmap_i]); + this.bw.WriteBits(n, (uint)code_selCtr[sfmap_i]); gs++; } @@ -1832,9 +1585,8 @@ private void sendMTFValues7(int nSelectors) } } - private void moveToFrontCodeAndSend() - { - this.bw.WriteBits(24, (uint) this.origPtr); + private void moveToFrontCodeAndSend() { + this.bw.WriteBits(24, (uint)this.origPtr); generateMTFValues(); sendMTFValues(); } @@ -1844,8 +1596,7 @@ private void moveToFrontCodeAndSend() - private class CompressionState - { + private class CompressionState { // with blockSize 900k public readonly bool[] inUse = new bool[256]; // 256 byte public readonly byte[] unseqToSeq = new byte[256]; // 256 byte @@ -1899,16 +1650,15 @@ private class CompressionState */ public char[] quadrant; - public CompressionState(int blockSize100k) - { + public CompressionState(int blockSize100k) { int n = blockSize100k * BZip2.BlockSizeMultiple; this.block = new byte[(n + 1 + BZip2.NUM_OVERSHOOT_BYTES)]; this.fmap = new int[n]; this.sfmap = new char[2 * n]; this.quadrant = this.sfmap; - this.sendMTFValues_len = BZip2.InitRectangularArray(BZip2.NGroups,BZip2.MaxAlphaSize); - this.sendMTFValues_rfreq = BZip2.InitRectangularArray(BZip2.NGroups,BZip2.MaxAlphaSize); - this.sendMTFValues_code = BZip2.InitRectangularArray(BZip2.NGroups,BZip2.MaxAlphaSize); + this.sendMTFValues_len = BZip2.InitRectangularArray(BZip2.NGroups, BZip2.MaxAlphaSize); + this.sendMTFValues_rfreq = BZip2.InitRectangularArray(BZip2.NGroups, BZip2.MaxAlphaSize); + this.sendMTFValues_code = BZip2.InitRectangularArray(BZip2.NGroups, BZip2.MaxAlphaSize); } } diff --git a/Src/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs b/Src/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs index 113d139aa..19f075e91 100644 --- a/Src/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs +++ b/Src/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs @@ -57,14 +57,12 @@ using System; using System.IO; -namespace Ionic.BZip2 -{ +namespace Ionic.BZip2 { /// /// A read-only decorator stream that performs BZip2 decompression on Read. /// - public class BZip2InputStream : System.IO.Stream - { + public class BZip2InputStream : System.IO.Stream { private bool _disposed; private bool _leaveOpen; private Int64 totalBytesRead; @@ -89,8 +87,7 @@ public class BZip2InputStream : System.IO.Stream /// /// Compressor State /// - private enum CState - { + private enum CState { EOF = 0, START_BLOCK = 1, RAND_PART_A = 2, @@ -129,8 +126,7 @@ private enum CState /// /// The stream from which to read compressed data public BZip2InputStream(Stream input) - : this(input, false) - {} + : this(input, false) { } /// @@ -169,8 +165,7 @@ public BZip2InputStream(Stream input) /// /// public BZip2InputStream(Stream input, bool leaveOpen) - : base() - { + : base() { this.input = input; this._leaveOpen = leaveOpen; @@ -198,8 +193,7 @@ public BZip2InputStream(Stream input, bool leaveOpen) /// the offset within that data array to put the first byte read. /// the number of bytes to read. /// the number of bytes actually read - public override int Read(byte[] buffer, int offset, int count) - { + public override int Read(byte[] buffer, int offset, int count) { if (offset < 0) throw new IndexOutOfRangeException(String.Format("offset ({0}) must be > 0", offset)); @@ -216,25 +210,22 @@ public override int Read(byte[] buffer, int offset, int count) int hi = offset + count; int destOffset = offset; - for (int b; (destOffset < hi) && ((b = ReadByte()) >= 0);) - { - buffer[destOffset++] = (byte) b; + for (int b; (destOffset < hi) && ((b = ReadByte()) >= 0);) { + buffer[destOffset++] = (byte)b; } return destOffset - offset; } - private void MakeMaps() - { + private void MakeMaps() { bool[] inUse = this.data.inUse; byte[] seqToUnseq = this.data.seqToUnseq; int n = 0; - for (int i = 0; i < 256; i++) - { + for (int i = 0; i < 256; i++) { if (inUse[i]) - seqToUnseq[n++] = (byte) i; + seqToUnseq[n++] = (byte)i; } this.nInUse = n; @@ -244,12 +235,10 @@ private void MakeMaps() /// Read a single byte from the stream. /// /// the byte read from the stream, or -1 if EOF - public override int ReadByte() - { + public override int ReadByte() { int retChar = this.currentChar; totalBytesRead++; - switch (this.currentState) - { + switch (this.currentState) { case CState.EOF: return -1; @@ -294,10 +283,8 @@ public override int ReadByte() /// /// The return value depends on whether the captive stream supports reading. /// - public override bool CanRead - { - get - { + public override bool CanRead { + get { if (_disposed) throw new ObjectDisposedException("BZip2Stream"); return this.input.CanRead; } @@ -310,8 +297,7 @@ public override bool CanRead /// /// Always returns false. /// - public override bool CanSeek - { + public override bool CanSeek { get { return false; } } @@ -322,10 +308,8 @@ public override bool CanSeek /// /// The return value depends on whether the captive stream supports writing. /// - public override bool CanWrite - { - get - { + public override bool CanWrite { + get { if (_disposed) throw new ObjectDisposedException("BZip2Stream"); return input.CanWrite; } @@ -334,8 +318,7 @@ public override bool CanWrite /// /// Flush the stream. /// - public override void Flush() - { + public override void Flush() { if (_disposed) throw new ObjectDisposedException("BZip2Stream"); input.Flush(); } @@ -343,8 +326,7 @@ public override void Flush() /// /// Reading this property always throws a . /// - public override long Length - { + public override long Length { get { throw new NotImplementedException(); } } @@ -357,10 +339,8 @@ public override long Length /// cref="NotImplementedException"/>. Reading will return the /// total number of uncompressed bytes read in. /// - public override long Position - { - get - { + public override long Position { + get { return this.totalBytesRead; } set { throw new NotImplementedException(); } @@ -372,8 +352,7 @@ public override long Position /// this is irrelevant, since it will always throw! /// this is irrelevant, since it will always throw! /// irrelevant! - public override long Seek(long offset, System.IO.SeekOrigin origin) - { + public override long Seek(long offset, System.IO.SeekOrigin origin) { throw new NotImplementedException(); } @@ -381,8 +360,7 @@ public override long Seek(long offset, System.IO.SeekOrigin origin) /// Calling this method always throws a . ///
/// this is irrelevant, since it will always throw! - public override void SetLength(long value) - { + public override void SetLength(long value) { throw new NotImplementedException(); } @@ -392,8 +370,7 @@ public override void SetLength(long value) /// this parameter is never used /// this parameter is never used /// this parameter is never used - public override void Write(byte[] buffer, int offset, int count) - { + public override void Write(byte[] buffer, int offset, int count) { throw new NotImplementedException(); } @@ -404,25 +381,19 @@ public override void Write(byte[] buffer, int offset, int count) /// /// indicates whether the Dispose method was invoked by user code. /// - protected override void Dispose(bool disposing) - { - try - { - if (!_disposed) - { + protected override void Dispose(bool disposing) { + try { + if (!_disposed) { if (disposing) input?.Close(); _disposed = true; } - } - finally - { + } finally { base.Dispose(disposing); } } - private void init() - { + private void init() { if (null == this.input) throw new IOException("No input Stream"); @@ -437,7 +408,7 @@ private void init() if ((blockSize < '1') || (blockSize > '9')) throw new IOException("Stream is not BZip2 formatted: illegal " - + "blocksize " + (char) blockSize); + + "blocksize " + (char)blockSize); this.blockSize100k = blockSize - '0'; @@ -445,19 +416,16 @@ private void init() SetupBlock(); } - private void CheckMagicChar(char expected, int position) - { + private void CheckMagicChar(char expected, int position) { int magic = this.input.ReadByte(); - if (magic != (int)expected) - { + if (magic != (int)expected) { var msg = String.Format("Not a valid BZip2 stream. byte {0}, expected '{1}', got '{2}'", position, (int)expected, magic); throw new IOException(msg); } } - private void InitBlock() - { + private void InitBlock() { char magic0 = bsGetUByte(); char magic1 = bsGetUByte(); char magic2 = bsGetUByte(); @@ -466,24 +434,19 @@ private void InitBlock() char magic5 = bsGetUByte(); if (magic0 == 0x17 && magic1 == 0x72 && magic2 == 0x45 - && magic3 == 0x38 && magic4 == 0x50 && magic5 == 0x90) - { + && magic3 == 0x38 && magic4 == 0x50 && magic5 == 0x90) { complete(); // end of file - } - else if (magic0 != 0x31 || - magic1 != 0x41 || - magic2 != 0x59 || - magic3 != 0x26 || - magic4 != 0x53 || - magic5 != 0x59) - { + } else if (magic0 != 0x31 || + magic1 != 0x41 || + magic2 != 0x59 || + magic3 != 0x26 || + magic4 != 0x53 || + magic5 != 0x59) { this.currentState = CState.EOF; var msg = String.Format("bad block header at offset 0x{0:X}", this.input.Position); throw new IOException(msg); - } - else - { + } else { this.storedBlockCRC = bsGetInt(); // Console.WriteLine(" stored block CRC : {0:X8}", this.storedBlockCRC); @@ -502,13 +465,11 @@ private void InitBlock() } - private void EndBlock() - { + private void EndBlock() { this.computedBlockCRC = (uint)this.crc.Crc32Result; // A bad CRC is considered a fatal error. - if (this.storedBlockCRC != this.computedBlockCRC) - { + if (this.storedBlockCRC != this.computedBlockCRC) { // make next blocks readable without error // (repair feature, not yet documented, not tested) // this.computedCombinedCRC = (this.storedCombinedCRC << 1) @@ -530,14 +491,12 @@ private void EndBlock() } - private void complete() - { + private void complete() { this.storedCombinedCRC = bsGetInt(); this.currentState = CState.EOF; this.data = null; - if (this.storedCombinedCRC != this.computedCombinedCRC) - { + if (this.storedCombinedCRC != this.computedCombinedCRC) { var msg = String.Format("BZip2 CRC error (expected {0:X8}, computed {1:X8})", this.storedCombinedCRC, this.computedCombinedCRC); @@ -548,18 +507,13 @@ private void complete() /// /// Close the stream. /// - public override void Close() - { + public override void Close() { Stream inShadow = this.input; - if (inShadow != null) - { - try - { + if (inShadow != null) { + try { if (!this._leaveOpen) inShadow.Close(); - } - finally - { + } finally { this.data = null; this.input = null; } @@ -579,15 +533,12 @@ public override void Close() /// /// The number of bits to read, always between 1 and 32. /// - private int GetBits(int n) - { + private int GetBits(int n) { int bsLiveShadow = this.bsLive; int bsBuffShadow = this.bsBuff; - if (bsLiveShadow < n) - { - do - { + if (bsLiveShadow < n) { + do { int thech = this.input.ReadByte(); if (thech < 0) @@ -630,19 +581,16 @@ private int GetBits(int n) // return ((bsBuffShadow >> (bsLiveShadow - 1)) & 1) != 0; // } - private bool bsGetBit() - { + private bool bsGetBit() { int bit = GetBits(1); return bit != 0; } - private char bsGetUByte() - { - return (char) GetBits(8); + private char bsGetUByte() { + return (char)GetBits(8); } - private uint bsGetInt() - { + private uint bsGetInt() { return (uint)((((((GetBits(8) << 8) | GetBits(8)) << 8) | GetBits(8)) << 8) | GetBits(8)); } @@ -651,39 +599,31 @@ private uint bsGetInt() * Called by createHuffmanDecodingTables() exclusively. */ private static void hbCreateDecodeTables(int[] limit, - int[] bbase, int[] perm, char[] length, - int minLen, int maxLen, int alphaSize) - { - for (int i = minLen, pp = 0; i <= maxLen; i++) - { - for (int j = 0; j < alphaSize; j++) - { - if (length[j] == i) - { + int[] bbase, int[] perm, char[] length, + int minLen, int maxLen, int alphaSize) { + for (int i = minLen, pp = 0; i <= maxLen; i++) { + for (int j = 0; j < alphaSize; j++) { + if (length[j] == i) { perm[pp++] = j; } } } - for (int i = BZip2.MaxCodeLength; --i > 0;) - { + for (int i = BZip2.MaxCodeLength; --i > 0;) { bbase[i] = 0; limit[i] = 0; } - for (int i = 0; i < alphaSize; i++) - { + for (int i = 0; i < alphaSize; i++) { bbase[length[i] + 1]++; } - for (int i = 1, b = bbase[0]; i < BZip2.MaxCodeLength; i++) - { + for (int i = 1, b = bbase[0]; i < BZip2.MaxCodeLength; i++) { b += bbase[i]; bbase[i] = b; } - for (int i = minLen, vec = 0, b = bbase[i]; i <= maxLen; i++) - { + for (int i = minLen, vec = 0, b = bbase[i]; i <= maxLen; i++) { int nb = bbase[i + 1]; vec += nb - b; b = nb; @@ -691,16 +631,14 @@ private static void hbCreateDecodeTables(int[] limit, vec <<= 1; } - for (int i = minLen + 1; i <= maxLen; i++) - { + for (int i = minLen + 1; i <= maxLen; i++) { bbase[i] = ((limit[i - 1] + 1) << 1) - bbase[i]; } } - private void recvDecodingTables() - { + private void recvDecodingTables() { var s = this.data; bool[] inUse = s.inUse; byte[] pos = s.recvDecodingTables_pos; @@ -709,28 +647,21 @@ private void recvDecodingTables() int inUse16 = 0; /* Receive the mapping table */ - for (int i = 0; i < 16; i++) - { - if (bsGetBit()) - { + for (int i = 0; i < 16; i++) { + if (bsGetBit()) { inUse16 |= 1 << i; } } - for (int i = 256; --i >= 0;) - { + for (int i = 256; --i >= 0;) { inUse[i] = false; } - for (int i = 0; i < 16; i++) - { - if ((inUse16 & (1 << i)) != 0) - { + for (int i = 0; i < 16; i++) { + if ((inUse16 & (1 << i)) != 0) { int i16 = i << 4; - for (int j = 0; j < 16; j++) - { - if (bsGetBit()) - { + for (int j = 0; j < 16; j++) { + if (bsGetBit()) { inUse[i16 + j] = true; } } @@ -744,28 +675,23 @@ private void recvDecodingTables() int nGroups = GetBits(3); int nSelectors = GetBits(15); - for (int i = 0; i < nSelectors; i++) - { + for (int i = 0; i < nSelectors; i++) { int j = 0; - while (bsGetBit()) - { + while (bsGetBit()) { j++; } - s.selectorMtf[i] = (byte) j; + s.selectorMtf[i] = (byte)j; } /* Undo the MTF values for the selectors. */ - for (int v = nGroups; --v >= 0;) - { - pos[v] = (byte) v; + for (int v = nGroups; --v >= 0;) { + pos[v] = (byte)v; } - for (int i = 0; i < nSelectors; i++) - { + for (int i = 0; i < nSelectors; i++) { int v = s.selectorMtf[i]; byte tmp = pos[v]; - while (v > 0) - { + while (v > 0) { // nearly all times v is zero, 4 in most other cases pos[v] = pos[v - 1]; v--; @@ -777,17 +703,14 @@ private void recvDecodingTables() char[][] len = s.temp_charArray2d; /* Now the coding tables */ - for (int t = 0; t < nGroups; t++) - { + for (int t = 0; t < nGroups; t++) { int curr = GetBits(5); char[] len_t = len[t]; - for (int i = 0; i < alphaSize; i++) - { - while (bsGetBit()) - { + for (int i = 0; i < alphaSize; i++) { + while (bsGetBit()) { curr += bsGetBit() ? -1 : 1; } - len_t[i] = (char) curr; + len_t[i] = (char)curr; } } @@ -800,18 +723,15 @@ private void recvDecodingTables() * Called by recvDecodingTables() exclusively. */ private void createHuffmanDecodingTables(int alphaSize, - int nGroups) - { + int nGroups) { var s = this.data; char[][] len = s.temp_charArray2d; - for (int t = 0; t < nGroups; t++) - { + for (int t = 0; t < nGroups; t++) { int minLen = 32; int maxLen = 0; char[] len_t = len[t]; - for (int i = alphaSize; --i >= 0;) - { + for (int i = alphaSize; --i >= 0;) { char lent = len_t[i]; if (lent > maxLen) maxLen = lent; @@ -827,8 +747,7 @@ private void createHuffmanDecodingTables(int alphaSize, - private void getAndMoveToFrontDecode() - { + private void getAndMoveToFrontDecode() { var s = this.data; this.origPtr = GetBits(24); @@ -847,9 +766,8 @@ private void getAndMoveToFrontDecode() * does save having to do it later in a separate pass, and so saves a * block's worth of cache misses. */ - for (int i = 256; --i >= 0;) - { - yy[i] = (byte) i; + for (int i = 256; --i >= 0;) { + yy[i] = (byte)i; s.unzftab[i] = 0; } @@ -866,38 +784,27 @@ private void getAndMoveToFrontDecode() int[] perm_zt = s.gPerm[zt]; int minLens_zt = s.gMinlen[zt]; - while (nextSym != eob) - { - if ((nextSym == BZip2.RUNA) || (nextSym == BZip2.RUNB)) - { + while (nextSym != eob) { + if ((nextSym == BZip2.RUNA) || (nextSym == BZip2.RUNB)) { int es = -1; - for (int n = 1; true; n <<= 1) - { - if (nextSym == BZip2.RUNA) - { + for (int n = 1; true; n <<= 1) { + if (nextSym == BZip2.RUNA) { es += n; - } - else if (nextSym == BZip2.RUNB) - { + } else if (nextSym == BZip2.RUNB) { es += n << 1; - } - else - { + } else { break; } - if (groupPos == 0) - { + if (groupPos == 0) { groupPos = BZip2.G_SIZE - 1; zt = s.selector[++groupNo] & 0xff; base_zt = s.gBase[zt]; limit_zt = s.gLimit[zt]; perm_zt = s.gPerm[zt]; minLens_zt = s.gMinlen[zt]; - } - else - { + } else { groupPos--; } @@ -905,17 +812,13 @@ private void getAndMoveToFrontDecode() // Inlined: // int zvec = GetBits(zn); - while (bsLiveShadow < zn) - { + while (bsLiveShadow < zn) { int thech = this.input.ReadByte(); - if (thech >= 0) - { + if (thech >= 0) { bsBuffShadow = (bsBuffShadow << 8) | thech; bsLiveShadow += 8; continue; - } - else - { + } else { throw new IOException("unexpected end of stream"); } } @@ -923,20 +826,15 @@ private void getAndMoveToFrontDecode() & ((1 << zn) - 1); bsLiveShadow -= zn; - while (zvec > limit_zt[zn]) - { + while (zvec > limit_zt[zn]) { zn++; - while (bsLiveShadow < 1) - { + while (bsLiveShadow < 1) { int thech = this.input.ReadByte(); - if (thech >= 0) - { + if (thech >= 0) { bsBuffShadow = (bsBuffShadow << 8) | thech; bsLiveShadow += 8; continue; - } - else - { + } else { throw new IOException("unexpected end of stream"); } } @@ -950,16 +848,13 @@ private void getAndMoveToFrontDecode() byte ch = s.seqToUnseq[yy[0]]; s.unzftab[ch & 0xff] += es + 1; - while (es-- >= 0) - { + while (es-- >= 0) { s.ll8[++lastShadow] = ch; } if (lastShadow >= limitLast) throw new IOException("block overrun"); - } - else - { + } else { if (++lastShadow >= limitLast) throw new IOException("block overrun"); @@ -972,31 +867,24 @@ private void getAndMoveToFrontDecode() * native method call overhead of System.Buffer.BlockCopy for very * small ranges to copy. */ - if (nextSym <= 16) - { - for (int j = nextSym - 1; j > 0;) - { + if (nextSym <= 16) { + for (int j = nextSym - 1; j > 0;) { yy[j] = yy[--j]; } - } - else - { + } else { System.Buffer.BlockCopy(yy, 0, yy, 1, nextSym - 1); } yy[0] = tmp; - if (groupPos == 0) - { + if (groupPos == 0) { groupPos = BZip2.G_SIZE - 1; zt = s.selector[++groupNo] & 0xff; base_zt = s.gBase[zt]; limit_zt = s.gLimit[zt]; perm_zt = s.gPerm[zt]; minLens_zt = s.gMinlen[zt]; - } - else - { + } else { groupPos--; } @@ -1004,17 +892,13 @@ private void getAndMoveToFrontDecode() // Inlined: // int zvec = GetBits(zn); - while (bsLiveShadow < zn) - { + while (bsLiveShadow < zn) { int thech = this.input.ReadByte(); - if (thech >= 0) - { + if (thech >= 0) { bsBuffShadow = (bsBuffShadow << 8) | thech; bsLiveShadow += 8; continue; - } - else - { + } else { throw new IOException("unexpected end of stream"); } } @@ -1022,20 +906,15 @@ private void getAndMoveToFrontDecode() & ((1 << zn) - 1); bsLiveShadow -= zn; - while (zvec > limit_zt[zn]) - { + while (zvec > limit_zt[zn]) { zn++; - while (bsLiveShadow < 1) - { + while (bsLiveShadow < 1) { int thech = this.input.ReadByte(); - if (thech >= 0) - { + if (thech >= 0) { bsBuffShadow = (bsBuffShadow << 8) | thech; bsLiveShadow += 8; continue; - } - else - { + } else { throw new IOException("unexpected end of stream"); } } @@ -1052,8 +931,7 @@ private void getAndMoveToFrontDecode() } - private int getAndMoveToFrontDecode0(int groupNo) - { + private int getAndMoveToFrontDecode0(int groupNo) { var s = this.data; int zt = s.selector[groupNo] & 0xff; int[] limit_zt = s.gLimit[zt]; @@ -1062,21 +940,16 @@ private int getAndMoveToFrontDecode0(int groupNo) int bsLiveShadow = this.bsLive; int bsBuffShadow = this.bsBuff; - while (zvec > limit_zt[zn]) - { + while (zvec > limit_zt[zn]) { zn++; - while (bsLiveShadow < 1) - { + while (bsLiveShadow < 1) { int thech = this.input.ReadByte(); - if (thech >= 0) - { + if (thech >= 0) { bsBuffShadow = (bsBuffShadow << 8) | thech; bsLiveShadow += 8; continue; - } - else - { + } else { throw new IOException("unexpected end of stream"); } } @@ -1091,8 +964,7 @@ private int getAndMoveToFrontDecode0(int groupNo) } - private void SetupBlock() - { + private void SetupBlock() { if (this.data == null) return; @@ -1103,36 +975,31 @@ private void SetupBlock() // xxxx /* Check: unzftab entries in range. */ - for (i = 0; i <= 255; i++) - { + for (i = 0; i <= 255; i++) { if (s.unzftab[i] < 0 || s.unzftab[i] > this.last) throw new Exception("BZ_DATA_ERROR"); } /* Actually generate cftab. */ s.cftab[0] = 0; - for (i = 1; i <= 256; i++) s.cftab[i] = s.unzftab[i-1]; - for (i = 1; i <= 256; i++) s.cftab[i] += s.cftab[i-1]; + for (i = 1; i <= 256; i++) s.cftab[i] = s.unzftab[i - 1]; + for (i = 1; i <= 256; i++) s.cftab[i] += s.cftab[i - 1]; /* Check: cftab entries in range. */ - for (i = 0; i <= 256; i++) - { - if (s.cftab[i] < 0 || s.cftab[i] > this.last+1) - { + for (i = 0; i <= 256; i++) { + if (s.cftab[i] < 0 || s.cftab[i] > this.last + 1) { var msg = String.Format("BZ_DATA_ERROR: cftab[{0}]={1} last={2}", i, s.cftab[i], this.last); throw new Exception(msg); } } /* Check: cftab entries non-descending. */ - for (i = 1; i <= 256; i++) - { - if (s.cftab[i-1] > s.cftab[i]) + for (i = 1; i <= 256; i++) { + if (s.cftab[i - 1] > s.cftab[i]) throw new Exception("BZ_DATA_ERROR"); } int lastShadow; - for (i = 0, lastShadow = this.last; i <= lastShadow; i++) - { + for (i = 0, lastShadow = this.last; i <= lastShadow; i++) { tt[s.cftab[s.ll8[i] & 0xff]++] = i; } @@ -1144,37 +1011,28 @@ private void SetupBlock() this.su_i2 = 0; this.su_ch2 = 256; /* not a valid 8-bit byte value?, and not EOF */ - if (this.blockRandomised) - { + if (this.blockRandomised) { this.su_rNToGo = 0; this.su_rTPos = 0; SetupRandPartA(); - } - else - { + } else { SetupNoRandPartA(); } } - private void SetupRandPartA() - { - if (this.su_i2 <= this.last) - { + private void SetupRandPartA() { + if (this.su_i2 <= this.last) { this.su_chPrev = this.su_ch2; int su_ch2Shadow = this.data.ll8[this.su_tPos] & 0xff; this.su_tPos = this.data.tt[this.su_tPos]; - if (this.su_rNToGo == 0) - { + if (this.su_rNToGo == 0) { this.su_rNToGo = Rand.Rnums(this.su_rTPos) - 1; - if (++this.su_rTPos == 512) - { + if (++this.su_rTPos == 512) { this.su_rTPos = 0; } - } - else - { + } else { this.su_rNToGo--; } this.su_ch2 = su_ch2Shadow ^= (this.su_rNToGo == 1) ? 1 : 0; @@ -1182,19 +1040,15 @@ private void SetupRandPartA() this.currentChar = su_ch2Shadow; this.currentState = CState.RAND_PART_B; this.crc.UpdateCRC((byte)su_ch2Shadow); - } - else - { + } else { EndBlock(); InitBlock(); SetupBlock(); } } - private void SetupNoRandPartA() - { - if (this.su_i2 <= this.last) - { + private void SetupNoRandPartA() { + if (this.su_i2 <= this.last) { this.su_chPrev = this.su_ch2; int su_ch2Shadow = this.data.ll8[this.su_tPos] & 0xff; this.su_ch2 = su_ch2Shadow; @@ -1203,9 +1057,7 @@ private void SetupNoRandPartA() this.currentChar = su_ch2Shadow; this.currentState = CState.NO_RAND_PART_B; this.crc.UpdateCRC((byte)su_ch2Shadow); - } - else - { + } else { this.currentState = CState.NO_RAND_PART_A; EndBlock(); InitBlock(); @@ -1213,55 +1065,40 @@ private void SetupNoRandPartA() } } - private void SetupRandPartB() - { - if (this.su_ch2 != this.su_chPrev) - { + private void SetupRandPartB() { + if (this.su_ch2 != this.su_chPrev) { this.currentState = CState.RAND_PART_A; this.su_count = 1; SetupRandPartA(); - } - else if (++this.su_count >= 4) - { - this.su_z = (char) (this.data.ll8[this.su_tPos] & 0xff); + } else if (++this.su_count >= 4) { + this.su_z = (char)(this.data.ll8[this.su_tPos] & 0xff); this.su_tPos = this.data.tt[this.su_tPos]; - if (this.su_rNToGo == 0) - { + if (this.su_rNToGo == 0) { this.su_rNToGo = Rand.Rnums(this.su_rTPos) - 1; - if (++this.su_rTPos == 512) - { + if (++this.su_rTPos == 512) { this.su_rTPos = 0; } - } - else - { + } else { this.su_rNToGo--; } this.su_j2 = 0; this.currentState = CState.RAND_PART_C; - if (this.su_rNToGo == 1) - { + if (this.su_rNToGo == 1) { this.su_z ^= (char)1; } SetupRandPartC(); - } - else - { + } else { this.currentState = CState.RAND_PART_A; SetupRandPartA(); } } - private void SetupRandPartC() - { - if (this.su_j2 < this.su_z) - { + private void SetupRandPartC() { + if (this.su_j2 < this.su_z) { this.currentChar = this.su_ch2; this.crc.UpdateCRC((byte)this.su_ch2); this.su_j2++; - } - else - { + } else { this.currentState = CState.RAND_PART_A; this.su_i2++; this.su_count = 0; @@ -1269,46 +1106,35 @@ private void SetupRandPartC() } } - private void SetupNoRandPartB() - { - if (this.su_ch2 != this.su_chPrev) - { + private void SetupNoRandPartB() { + if (this.su_ch2 != this.su_chPrev) { this.su_count = 1; SetupNoRandPartA(); - } - else if (++this.su_count >= 4) - { - this.su_z = (char) (this.data.ll8[this.su_tPos] & 0xff); + } else if (++this.su_count >= 4) { + this.su_z = (char)(this.data.ll8[this.su_tPos] & 0xff); this.su_tPos = this.data.tt[this.su_tPos]; this.su_j2 = 0; SetupNoRandPartC(); - } - else - { + } else { SetupNoRandPartA(); } } - private void SetupNoRandPartC() - { - if (this.su_j2 < this.su_z) - { + private void SetupNoRandPartC() { + if (this.su_j2 < this.su_z) { int su_ch2Shadow = this.su_ch2; this.currentChar = su_ch2Shadow; this.crc.UpdateCRC((byte)su_ch2Shadow); this.su_j2++; this.currentState = CState.NO_RAND_PART_C; - } - else - { + } else { this.su_i2++; this.su_count = 0; SetupNoRandPartA(); } } - private sealed class DecompressionState - { + private sealed class DecompressionState { // (with blockSize 900k) public readonly bool[] inUse = new bool[256]; public readonly byte[] seqToUnseq = new byte[256]; // 256 byte @@ -1339,18 +1165,17 @@ private sealed class DecompressionState // 4560782 byte // =============== - public DecompressionState(int blockSize100k) - { + public DecompressionState(int blockSize100k) { this.unzftab = new int[256]; // 1024 byte - this.gLimit = BZip2.InitRectangularArray(BZip2.NGroups,BZip2.MaxAlphaSize); - this.gBase = BZip2.InitRectangularArray(BZip2.NGroups,BZip2.MaxAlphaSize); - this.gPerm = BZip2.InitRectangularArray(BZip2.NGroups,BZip2.MaxAlphaSize); + this.gLimit = BZip2.InitRectangularArray(BZip2.NGroups, BZip2.MaxAlphaSize); + this.gBase = BZip2.InitRectangularArray(BZip2.NGroups, BZip2.MaxAlphaSize); + this.gPerm = BZip2.InitRectangularArray(BZip2.NGroups, BZip2.MaxAlphaSize); this.gMinlen = new int[BZip2.NGroups]; // 24 byte this.cftab = new int[257]; // 1028 byte this.getAndMoveToFrontDecode_yy = new byte[256]; // 512 byte - this.temp_charArray2d = BZip2.InitRectangularArray(BZip2.NGroups,BZip2.MaxAlphaSize); + this.temp_charArray2d = BZip2.InitRectangularArray(BZip2.NGroups, BZip2.MaxAlphaSize); this.recvDecodingTables_pos = new byte[BZip2.NGroups]; // 6 byte this.ll8 = new byte[blockSize100k * BZip2.BlockSizeMultiple]; @@ -1363,16 +1188,14 @@ public DecompressionState(int blockSize100k) * I don't initialize it at construction time to avoid unneccessary * memory allocation when compressing small files. */ - public int[] initTT(int length) - { + public int[] initTT(int length) { int[] ttShadow = this.tt; // tt.length should always be >= length, but theoretically // it can happen, if the compressor mixed small and large // blocks. Normally only the last block will be smaller // than others. - if ((ttShadow == null) || (ttShadow.Length < length)) - { + if ((ttShadow == null) || (ttShadow.Length < length)) { this.tt = ttShadow = new int[length]; } @@ -1515,36 +1338,33 @@ private struct StateDump { // } - internal static class BZip2 - { - internal static T[][] InitRectangularArray(int d1, int d2) - { - var x = new T[d1][]; - for (int i=0; i < d1; i++) - { - x[i] = new T[d2]; - } - return x; + internal static class BZip2 { + internal static T[][] InitRectangularArray(int d1, int d2) { + var x = new T[d1][]; + for (int i = 0; i < d1; i++) { + x[i] = new T[d2]; } + return x; + } - public static readonly int BlockSizeMultiple = 100000; - public static readonly int MinBlockSize = 1; - public static readonly int MaxBlockSize = 9; - public static readonly int MaxAlphaSize = 258; - public static readonly int MaxCodeLength = 23; - public static readonly char RUNA = (char) 0; - public static readonly char RUNB = (char) 1; - public static readonly int NGroups = 6; - public static readonly int G_SIZE = 50; - public static readonly int N_ITERS = 4; - public static readonly int MaxSelectors = (2 + (900000 / G_SIZE)); + public static readonly int BlockSizeMultiple = 100000; + public static readonly int MinBlockSize = 1; + public static readonly int MaxBlockSize = 9; + public static readonly int MaxAlphaSize = 258; + public static readonly int MaxCodeLength = 23; + public static readonly char RUNA = (char)0; + public static readonly char RUNB = (char)1; + public static readonly int NGroups = 6; + public static readonly int G_SIZE = 50; + public static readonly int N_ITERS = 4; + public static readonly int MaxSelectors = (2 + (900000 / G_SIZE)); public static readonly int NUM_OVERSHOOT_BYTES = 20; - /* - *

If you are ever unlucky/improbable enough to get a stack - * overflow whilst sorting, increase the following constant and - * try again. In practice I have never seen the stack go above 27 - * elems, so the following limit seems very generous.

- */ + /* + *

If you are ever unlucky/improbable enough to get a stack + * overflow whilst sorting, increase the following constant and + * try again. In practice I have never seen the stack go above 27 + * elems, so the following limit seems very generous.

+ */ internal static readonly int QSORT_STACK_SIZE = 1000; diff --git a/Src/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs b/Src/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs index 41863ffb0..95b5d3a80 100644 --- a/Src/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs +++ b/Src/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs @@ -83,14 +83,12 @@ using System.IO; -namespace Ionic.BZip2 -{ +namespace Ionic.BZip2 { /// /// A write-only decorator stream that compresses data as it is /// written using the BZip2 algorithm. /// - public class BZip2OutputStream : System.IO.Stream - { + public class BZip2OutputStream : System.IO.Stream { private int totalBytesWrittenIn; private bool leaveOpen; private BZip2Compressor compressor; @@ -136,8 +134,7 @@ public class BZip2OutputStream : System.IO.Stream /// /// public BZip2OutputStream(Stream output) - : this(output, BZip2.MaxBlockSize, false) - { + : this(output, BZip2.MaxBlockSize, false) { } @@ -150,8 +147,7 @@ public BZip2OutputStream(Stream output) /// The valid range is 1..9. /// public BZip2OutputStream(Stream output, int blockSize) - : this(output, blockSize, false) - { + : this(output, blockSize, false) { } @@ -163,8 +159,7 @@ public BZip2OutputStream(Stream output, int blockSize) /// whether to leave the captive stream open upon closing this stream. /// public BZip2OutputStream(Stream output, bool leaveOpen) - : this(output, BZip2.MaxBlockSize, leaveOpen) - { + : this(output, BZip2.MaxBlockSize, leaveOpen) { } @@ -181,11 +176,9 @@ public BZip2OutputStream(Stream output, bool leaveOpen) /// /// whether to leave the captive stream open upon closing this stream. /// - public BZip2OutputStream(Stream output, int blockSize, bool leaveOpen) - { + public BZip2OutputStream(Stream output, int blockSize, bool leaveOpen) { if (blockSize < BZip2.MinBlockSize || - blockSize > BZip2.MaxBlockSize) - { + blockSize > BZip2.MaxBlockSize) { var msg = String.Format("blockSize={0} is out of range; must be between {1} and {2}", blockSize, BZip2.MinBlockSize, BZip2.MaxBlockSize); @@ -216,10 +209,8 @@ public BZip2OutputStream(Stream output, int blockSize, bool leaveOpen) /// constructors that accept a bool value. /// /// - public override void Close() - { - if (output != null) - { + public override void Close() { + if (output != null) { Stream o = this.output; Finish(); if (!leaveOpen) @@ -231,17 +222,14 @@ public override void Close() /// /// Flush the stream. /// - public override void Flush() - { - if (this.output != null) - { + public override void Flush() { + if (this.output != null) { this.bw.Flush(); this.output.Flush(); } } - private void EmitHeader() - { + private void EmitHeader() { var magic = new byte[] { (byte) 'B', (byte) 'Z', @@ -253,8 +241,7 @@ private void EmitHeader() this.output.Write(magic, 0, magic.Length); } - private void EmitTrailer() - { + private void EmitTrailer() { // A magic 48-bit number, 0x177245385090, to indicate the end // of the last block. (sqrt(pi), if you want to know) @@ -277,30 +264,26 @@ private void EmitTrailer() this.bw.TotalBytesWrittenOut); } - private void Finish() - { + private void Finish() { // Console.WriteLine("BZip2:Finish"); - try - { + try { var totalBefore = this.bw.TotalBytesWrittenOut; this.compressor.CompressAndWrite(); - TraceOutput(TraceBits.Write,"out block length (bytes): {0} (0x{0:X})", + TraceOutput(TraceBits.Write, "out block length (bytes): {0} (0x{0:X})", this.bw.TotalBytesWrittenOut - totalBefore); TraceOutput(TraceBits.Crc, " combined CRC (before): {0:X8}", this.combinedCRC); this.combinedCRC = (this.combinedCRC << 1) | (this.combinedCRC >> 31); - this.combinedCRC ^= (uint) compressor.Crc32; + this.combinedCRC ^= (uint)compressor.Crc32; TraceOutput(TraceBits.Crc, " block CRC : {0:X8}", this.compressor.Crc32); TraceOutput(TraceBits.Crc, " combined CRC (final) : {0:X8}", this.combinedCRC); EmitTrailer(); - } - finally - { + } finally { this.output = null; this.compressor = null; this.bw = null; @@ -311,8 +294,7 @@ private void Finish() /// /// The blocksize parameter specified at construction time. /// - public int BlockSize - { + public int BlockSize { get { return this.blockSize100k; } } @@ -339,8 +321,7 @@ public int BlockSize /// The buffer holding data to write to the stream. /// the offset within that data array to find the first byte to write. /// the number of bytes to write. - public override void Write(byte[] buffer, int offset, int count) - { + public override void Write(byte[] buffer, int offset, int count) { if (offset < 0) throw new IndexOutOfRangeException(String.Format("offset ({0}) must be > 0", offset)); if (count < 0) @@ -356,30 +337,28 @@ public override void Write(byte[] buffer, int offset, int count) int bytesWritten = 0; int bytesRemaining = count; - do - { + do { int n = compressor.Fill(buffer, offset, bytesRemaining); - if (n != bytesRemaining) - { + if (n != bytesRemaining) { // The compressor data block is full. Compress and // write out the compressed data, then reset the // compressor and continue. var totalBefore = this.bw.TotalBytesWrittenOut; this.compressor.CompressAndWrite(); - TraceOutput(TraceBits.Write,"out block length (bytes): {0} (0x{0:X})", + TraceOutput(TraceBits.Write, "out block length (bytes): {0} (0x{0:X})", this.bw.TotalBytesWrittenOut - totalBefore); - // and now any remaining bits - TraceOutput(TraceBits.Write, - " remaining: {0} 0x{1:X}", - this.bw.NumRemainingBits, - this.bw.RemainingBits); + // and now any remaining bits + TraceOutput(TraceBits.Write, + " remaining: {0} 0x{1:X}", + this.bw.NumRemainingBits, + this.bw.RemainingBits); TraceOutput(TraceBits.Crc, " combined CRC (before): {0:X8}", this.combinedCRC); this.combinedCRC = (this.combinedCRC << 1) | (this.combinedCRC >> 31); - this.combinedCRC ^= (uint) compressor.Crc32; + this.combinedCRC ^= (uint)compressor.Crc32; TraceOutput(TraceBits.Crc, " block CRC : {0:X8}", compressor.Crc32); TraceOutput(TraceBits.Crc, " combined CRC (after) : {0:X8}", @@ -402,8 +381,7 @@ public override void Write(byte[] buffer, int offset, int count) /// /// The return value is always false. /// - public override bool CanRead - { + public override bool CanRead { get { return false; } } @@ -413,8 +391,7 @@ public override bool CanRead /// /// Always returns false. /// - public override bool CanSeek - { + public override bool CanSeek { get { return false; } } @@ -425,10 +402,8 @@ public override bool CanSeek /// The return value should always be true, unless and until the /// object is disposed and closed. /// - public override bool CanWrite - { - get - { + public override bool CanWrite { + get { if (this.output == null) throw new ObjectDisposedException("BZip2Stream"); return this.output.CanWrite; } @@ -437,8 +412,7 @@ public override bool CanWrite /// /// Reading this property always throws a . /// - public override long Length - { + public override long Length { get { throw new NotImplementedException(); } } @@ -451,10 +425,8 @@ public override long Length /// cref="NotImplementedException"/>. Reading will return the /// total number of uncompressed bytes written through. /// - public override long Position - { - get - { + public override long Position { + get { return this.totalBytesWrittenIn; } set { throw new NotImplementedException(); } @@ -466,8 +438,7 @@ public override long Position /// this is irrelevant, since it will always throw! /// this is irrelevant, since it will always throw! /// irrelevant! - public override long Seek(long offset, System.IO.SeekOrigin origin) - { + public override long Seek(long offset, System.IO.SeekOrigin origin) { throw new NotImplementedException(); } @@ -475,8 +446,7 @@ public override long Seek(long offset, System.IO.SeekOrigin origin) /// Calling this method always throws a . ///
/// this is irrelevant, since it will always throw! - public override void SetLength(long value) - { + public override void SetLength(long value) { throw new NotImplementedException(); } @@ -487,32 +457,28 @@ public override void SetLength(long value) /// this parameter is never used /// this parameter is never used /// never returns anything; always throws - public override int Read(byte[] buffer, int offset, int count) - { + public override int Read(byte[] buffer, int offset, int count) { throw new NotImplementedException(); } // used only when Trace is defined [Flags] - private enum TraceBits : uint - { - None = 0, - Crc = 1, - Write = 2, - All = 0xffffffff, + private enum TraceBits : uint { + None = 0, + Crc = 1, + Write = 2, + All = 0xffffffff, } [System.Diagnostics.ConditionalAttribute("Trace")] - private void TraceOutput(TraceBits bits, string format, params object[] varParams) - { - if ((bits & this.desiredTrace) != 0) - { + private void TraceOutput(TraceBits bits, string format, params object[] varParams) { + if ((bits & this.desiredTrace) != 0) { //lock(outputLock) { int tid = System.Threading.Thread.CurrentThread.GetHashCode(); - Console.ForegroundColor = (ConsoleColor) (tid % 8 + 10); + Console.ForegroundColor = (ConsoleColor)(tid % 8 + 10); Console.Write("{0:000} PBOS ", tid); Console.WriteLine(format, varParams); Console.ResetColor(); diff --git a/Src/IronPython.Modules/bz2/dotnetzip/BZip2/BitWriter.cs b/Src/IronPython.Modules/bz2/dotnetzip/BZip2/BitWriter.cs index 02ab1bb9a..ab991203f 100644 --- a/Src/IronPython.Modules/bz2/dotnetzip/BZip2/BitWriter.cs +++ b/Src/IronPython.Modules/bz2/dotnetzip/BZip2/BitWriter.cs @@ -80,21 +80,17 @@ // -using System; using System.IO; -namespace Ionic.BZip2 -{ +namespace Ionic.BZip2 { - internal class BitWriter - { + internal class BitWriter { private uint accumulator; private int nAccumulatedBits; private Stream output; private int totalBytesWrittenOut; - public BitWriter(Stream s) - { + public BitWriter(Stream s) { this.output = s; } @@ -107,26 +103,20 @@ public BitWriter(Stream s) /// in other words it is valid only after a call to Flush(). /// /// - public byte RemainingBits - { - get - { - return (byte) (this.accumulator >> (32 - this.nAccumulatedBits) & 0xff); + public byte RemainingBits { + get { + return (byte)(this.accumulator >> (32 - this.nAccumulatedBits) & 0xff); } } - public int NumRemainingBits - { - get - { + public int NumRemainingBits { + get { return this.nAccumulatedBits; } } - public int TotalBytesWrittenOut - { - get - { + public int TotalBytesWrittenOut { + get { return this.totalBytesWrittenOut; } } @@ -141,8 +131,7 @@ public int TotalBytesWrittenOut /// distinct data blocks. /// /// - public void Reset() - { + public void Reset() { this.accumulator = 0; this.nAccumulatedBits = 0; this.totalBytesWrittenOut = 0; @@ -159,14 +148,12 @@ public void Reset() /// reasons, this method does not check! /// /// - public void WriteBits(int nbits, uint value) - { + public void WriteBits(int nbits, uint value) { int nAccumulated = this.nAccumulatedBits; uint u = this.accumulator; - while (nAccumulated >= 8) - { - this.output.WriteByte ((byte)(u >> 24 & 0xff)); + while (nAccumulated >= 8) { + this.output.WriteByte((byte)(u >> 24 & 0xff)); this.totalBytesWrittenOut++; u <<= 8; nAccumulated -= 8; @@ -187,16 +174,14 @@ public void WriteBits(int nbits, uint value) /// /// Write a full 8-bit byte into the output. /// - public void WriteByte(byte b) - { + public void WriteByte(byte b) { WriteBits(8, b); } /// /// Write four 8-bit bytes into the output. /// - public void WriteInt(uint u) - { + public void WriteInt(uint u) { WriteBits(8, (u >> 24) & 0xff); WriteBits(8, (u >> 16) & 0xff); WriteBits(8, (u >> 8) & 0xff); @@ -220,9 +205,8 @@ public void WriteInt(uint u) /// parent BZip2OutputStream. /// /// - public void Flush() - { - WriteBits(0,0); + public void Flush() { + WriteBits(0, 0); } @@ -231,12 +215,10 @@ public void Flush() /// necessary. This must be the last method invoked on an instance of /// BitWriter. ///
- public void FinishAndPad() - { + public void FinishAndPad() { Flush(); - if (this.NumRemainingBits > 0) - { + if (this.NumRemainingBits > 0) { byte b = (byte)((this.accumulator >> 24) & 0xff); this.output.WriteByte(b); this.totalBytesWrittenOut++; diff --git a/Src/IronPython.Modules/bz2/dotnetzip/BZip2/CRC32.cs b/Src/IronPython.Modules/bz2/dotnetzip/BZip2/CRC32.cs index 46f3ad2e4..ffc0397cb 100644 --- a/Src/IronPython.Modules/bz2/dotnetzip/BZip2/CRC32.cs +++ b/Src/IronPython.Modules/bz2/dotnetzip/BZip2/CRC32.cs @@ -27,10 +27,8 @@ using System; -using Interop = System.Runtime.InteropServices; -namespace Ionic.Crc -{ +namespace Ionic.Crc { /// /// Computes a CRC-32. The CRC-32 algorithm is parameterized - you /// can set the polynomial and enable or disable bit @@ -42,15 +40,12 @@ namespace Ionic.Crc /// archive files. /// - public class CRC32 - { + public class CRC32 { /// /// Indicates the total number of bytes applied to the CRC. /// - public Int64 TotalBytesRead - { - get - { + public Int64 TotalBytesRead { + get { return _TotalBytesRead; } } @@ -58,10 +53,8 @@ public Int64 TotalBytesRead /// /// Indicates the current CRC for all blocks slurped in. /// - public Int32 Crc32Result - { - get - { + public Int32 Crc32Result { + get { return unchecked((Int32)(~_register)); } } @@ -71,8 +64,7 @@ public Int32 Crc32Result /// /// The stream over which to calculate the CRC32 /// the CRC32 calculation - public Int32 GetCrc32(System.IO.Stream input) - { + public Int32 GetCrc32(System.IO.Stream input) { return GetCrc32AndCopy(input, null); } @@ -83,13 +75,11 @@ public Int32 GetCrc32(System.IO.Stream input) /// The stream over which to calculate the CRC32 /// The stream into which to deflate the input /// the CRC32 calculation - public Int32 GetCrc32AndCopy(System.IO.Stream input, System.IO.Stream output) - { + public Int32 GetCrc32AndCopy(System.IO.Stream input, System.IO.Stream output) { if (input == null) throw new Exception("The input stream must not be null."); - unchecked - { + unchecked { byte[] buffer = new byte[BUFFER_SIZE]; int readSize = BUFFER_SIZE; @@ -97,8 +87,7 @@ public Int32 GetCrc32AndCopy(System.IO.Stream input, System.IO.Stream output) int count = input.Read(buffer, 0, readSize); output?.Write(buffer, 0, count); _TotalBytesRead += count; - while (count > 0) - { + while (count > 0) { SlurpBlock(buffer, 0, count); count = input.Read(buffer, 0, readSize); if (output != null) output.Write(buffer, 0, count); @@ -117,13 +106,11 @@ public Int32 GetCrc32AndCopy(System.IO.Stream input, System.IO.Stream output) /// The word to start with. /// The byte to combine it with. /// The CRC-ized result. - public Int32 ComputeCrc32(Int32 W, byte B) - { + public Int32 ComputeCrc32(Int32 W, byte B) { return _InternalComputeCrc32((UInt32)W, B); } - internal Int32 _InternalComputeCrc32(UInt32 W, byte B) - { + internal Int32 _InternalComputeCrc32(UInt32 W, byte B) { return (Int32)(crc32Table[(W ^ B) & 0xFF] ^ (W >> 8)); } @@ -135,23 +122,18 @@ internal Int32 _InternalComputeCrc32(UInt32 W, byte B) /// block of bytes to slurp /// starting point in the block /// how many bytes within the block to slurp - public void SlurpBlock(byte[] block, int offset, int count) - { + public void SlurpBlock(byte[] block, int offset, int count) { if (block == null) throw new Exception("The data buffer must not be null."); // bzip algorithm - for (int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { int x = offset + i; byte b = block[x]; - if (this.reverseBits) - { + if (this.reverseBits) { UInt32 temp = (_register >> 24) ^ b; _register = (_register << 8) ^ crc32Table[temp]; - } - else - { + } else { UInt32 temp = (_register & 0x000000FF) ^ b; _register = (_register >> 8) ^ crc32Table[temp]; } @@ -164,15 +146,11 @@ public void SlurpBlock(byte[] block, int offset, int count) /// Process one byte in the CRC. ///
/// the byte to include into the CRC . - public void UpdateCRC(byte b) - { - if (this.reverseBits) - { + public void UpdateCRC(byte b) { + if (this.reverseBits) { UInt32 temp = (_register >> 24) ^ b; _register = (_register << 8) ^ crc32Table[temp]; - } - else - { + } else { UInt32 temp = (_register & 0x000000FF) ^ b; _register = (_register >> 8) ^ crc32Table[temp]; } @@ -192,19 +170,14 @@ public void UpdateCRC(byte b) /// /// the byte to include into the CRC. /// the number of times that byte should be repeated. - public void UpdateCRC(byte b, int n) - { - while (n-- > 0) - { - if (this.reverseBits) - { + public void UpdateCRC(byte b, int n) { + while (n-- > 0) { + if (this.reverseBits) { uint temp = (_register >> 24) ^ b; _register = (_register << 8) ^ crc32Table[(temp >= 0) ? temp : (temp + 256)]; - } - else - { + } else { UInt32 temp = (_register & 0x000000FF) ^ b; _register = (_register >> 8) ^ crc32Table[(temp >= 0) ? temp @@ -216,10 +189,8 @@ public void UpdateCRC(byte b, int n) - private static uint ReverseBits(uint data) - { - unchecked - { + private static uint ReverseBits(uint data) { + unchecked { uint ret = data; ret = (ret & 0x55555555) << 1 | (ret >> 1) & 0x55555555; ret = (ret & 0x33333333) << 2 | (ret >> 2) & 0x33333333; @@ -229,10 +200,8 @@ private static uint ReverseBits(uint data) } } - private static byte ReverseBits(byte data) - { - unchecked - { + private static byte ReverseBits(byte data) { + unchecked { uint u = (uint)data * 0x00020202; uint m = 0x01044010; uint s = u & m; @@ -243,37 +212,27 @@ private static byte ReverseBits(byte data) - private void GenerateLookupTable() - { + private void GenerateLookupTable() { crc32Table = new UInt32[256]; - unchecked - { + unchecked { UInt32 dwCrc; byte i = 0; - do - { + do { dwCrc = i; - for (byte j = 8; j > 0; j--) - { - if ((dwCrc & 1) == 1) - { + for (byte j = 8; j > 0; j--) { + if ((dwCrc & 1) == 1) { dwCrc = (dwCrc >> 1) ^ dwPolynomial; - } - else - { + } else { dwCrc >>= 1; } } - if (reverseBits) - { + if (reverseBits) { crc32Table[ReverseBits(i)] = ReverseBits(dwCrc); - } - else - { + } else { crc32Table[i] = dwCrc; } i++; - } while (i!=0); + } while (i != 0); } #if VERBOSE @@ -294,13 +253,11 @@ private void GenerateLookupTable() } - private uint gf2_matrix_times(uint[] matrix, uint vec) - { + private uint gf2_matrix_times(uint[] matrix, uint vec) { uint sum = 0; - int i=0; - while (vec != 0) - { - if ((vec & 0x01)== 0x01) + int i = 0; + while (vec != 0) { + if ((vec & 0x01) == 0x01) sum ^= matrix[i]; vec >>= 1; i++; @@ -308,8 +265,7 @@ private uint gf2_matrix_times(uint[] matrix, uint vec) return sum; } - private void gf2_matrix_square(uint[] square, uint[] mat) - { + private void gf2_matrix_square(uint[] square, uint[] mat) { for (int i = 0; i < 32; i++) square[i] = gf2_matrix_times(mat, mat[i]); } @@ -327,22 +283,20 @@ private void gf2_matrix_square(uint[] square, uint[] mat) /// /// the crc value to be combined with this one /// the length of data the CRC value was calculated on - public void Combine(int crc, int length) - { + public void Combine(int crc, int length) { uint[] even = new uint[32]; // even-power-of-two zeros operator uint[] odd = new uint[32]; // odd-power-of-two zeros operator if (length == 0) return; - uint crc1= ~_register; - uint crc2= (uint) crc; + uint crc1 = ~_register; + uint crc2 = (uint)crc; // put operator for one zero bit in odd odd[0] = this.dwPolynomial; // the CRC-32 polynomial uint row = 1; - for (int i = 1; i < 32; i++) - { + for (int i = 1; i < 32; i++) { odd[i] = row; row <<= 1; } @@ -353,7 +307,7 @@ public void Combine(int crc, int length) // put operator for four zero bits in odd gf2_matrix_square(odd, even); - uint len2 = (uint) length; + uint len2 = (uint)length; // apply len2 zeros to crc1 (first square will put the operator for one // zero byte, eight zero bits, in even) @@ -361,7 +315,7 @@ public void Combine(int crc, int length) // apply zeros operator for this bit of len2 gf2_matrix_square(even, odd); - if ((len2 & 1)== 1) + if ((len2 & 1) == 1) crc1 = gf2_matrix_times(even, crc1); len2 >>= 1; @@ -370,7 +324,7 @@ public void Combine(int crc, int length) // another iteration of the loop with odd and even swapped gf2_matrix_square(odd, even); - if ((len2 & 1)==1) + if ((len2 & 1) == 1) crc1 = gf2_matrix_times(odd, crc1); len2 >>= 1; @@ -379,7 +333,7 @@ public void Combine(int crc, int length) crc1 ^= crc2; - _register= ~crc1; + _register = ~crc1; //return (int) crc1; return; @@ -390,8 +344,7 @@ public void Combine(int crc, int length) /// Create an instance of the CRC32 class using the default settings: no /// bit reversal, and a polynomial of 0xEDB88320. ///
- public CRC32() : this(false) - { + public CRC32() : this(false) { } /// @@ -411,8 +364,7 @@ public CRC32() : this(false) /// /// public CRC32(bool reverseBits) : - this( unchecked((int)0xEDB88320), reverseBits) - { + this(unchecked((int)0xEDB88320), reverseBits) { } @@ -441,10 +393,9 @@ public CRC32(bool reverseBits) : /// reverseBits parameter. /// /// - public CRC32(int polynomial, bool reverseBits) - { + public CRC32(int polynomial, bool reverseBits) { this.reverseBits = reverseBits; - this.dwPolynomial = (uint) polynomial; + this.dwPolynomial = (uint)polynomial; this.GenerateLookupTable(); } @@ -457,8 +408,7 @@ public CRC32(int polynomial, bool reverseBits) /// multiple, distinct CRCs on multiple, distinct data blocks. /// /// - public void Reset() - { + public void Reset() { _register = 0xFFFFFFFFU; } @@ -491,8 +441,7 @@ public void Reset() /// DotNetZip library. /// /// - public class CrcCalculatorStream : System.IO.Stream, System.IDisposable - { + public class CrcCalculatorStream : System.IO.Stream, System.IDisposable { private static readonly Int64 UnsetLengthLimit = -99; internal System.IO.Stream _innerStream; @@ -512,8 +461,7 @@ public class CrcCalculatorStream : System.IO.Stream, System.IDisposable /// /// The underlying stream public CrcCalculatorStream(System.IO.Stream stream) - : this(true, CrcCalculatorStream.UnsetLengthLimit, stream, null) - { + : this(true, CrcCalculatorStream.UnsetLengthLimit, stream, null) { } /// @@ -530,8 +478,7 @@ public CrcCalculatorStream(System.IO.Stream stream) /// true to leave the underlying stream /// open upon close of the CrcCalculatorStream; false otherwise. public CrcCalculatorStream(System.IO.Stream stream, bool leaveOpen) - : this(leaveOpen, CrcCalculatorStream.UnsetLengthLimit, stream, null) - { + : this(leaveOpen, CrcCalculatorStream.UnsetLengthLimit, stream, null) { } /// @@ -551,8 +498,7 @@ public CrcCalculatorStream(System.IO.Stream stream, bool leaveOpen) /// The underlying stream /// The length of the stream to slurp public CrcCalculatorStream(System.IO.Stream stream, Int64 length) - : this(true, length, stream, null) - { + : this(true, length, stream, null) { if (length < 0) throw new ArgumentException("length"); } @@ -573,8 +519,7 @@ public CrcCalculatorStream(System.IO.Stream stream, Int64 length) /// true to leave the underlying stream /// open upon close of the CrcCalculatorStream; false otherwise. public CrcCalculatorStream(System.IO.Stream stream, Int64 length, bool leaveOpen) - : this(leaveOpen, length, stream, null) - { + : this(leaveOpen, length, stream, null) { if (length < 0) throw new ArgumentException("length"); } @@ -597,8 +542,7 @@ public CrcCalculatorStream(System.IO.Stream stream, Int64 length, bool leaveOpen /// the CRC32 instance to use to calculate the CRC32 public CrcCalculatorStream(System.IO.Stream stream, Int64 length, bool leaveOpen, CRC32 crc32) - : this(leaveOpen, length, stream, crc32) - { + : this(leaveOpen, length, stream, crc32) { if (length < 0) throw new ArgumentException("length"); } @@ -611,8 +555,7 @@ public CrcCalculatorStream(System.IO.Stream stream, Int64 length, bool leaveOpen // value. private CrcCalculatorStream (bool leaveOpen, Int64 length, System.IO.Stream stream, CRC32 crc32) - : base() - { + : base() { _innerStream = stream; _Crc32 = crc32 ?? new CRC32(); _lengthLimit = length; @@ -628,8 +571,7 @@ private CrcCalculatorStream /// This is either the total number of bytes read, or the total number of /// bytes written, depending on the direction of this stream. /// - public Int64 TotalBytesSlurped - { + public Int64 TotalBytesSlurped { get { return _Crc32.TotalBytesRead; } } @@ -643,8 +585,7 @@ public Int64 TotalBytesSlurped /// get an accurate CRC for the entire stream. /// /// - public Int32 Crc - { + public Int32 Crc { get { return _Crc32.Crc32Result; } } @@ -657,8 +598,7 @@ public Int32 Crc /// Set this at any point before calling . /// /// - public bool LeaveOpen - { + public bool LeaveOpen { get { return _leaveOpen; } set { _leaveOpen = value; } } @@ -670,8 +610,7 @@ public bool LeaveOpen /// the offset at which to start /// the number of bytes to read /// the number of bytes actually read - public override int Read(byte[] buffer, int offset, int count) - { + public override int Read(byte[] buffer, int offset, int count) { int bytesToRead = count; // Need to limit the # of bytes returned, if the stream is intended to have @@ -682,8 +621,7 @@ public override int Read(byte[] buffer, int offset, int count) // calling ReadToEnd() on it, We can "over-read" the zip data and get a // corrupt string. The length limits that, prevents that problem. - if (_lengthLimit != CrcCalculatorStream.UnsetLengthLimit) - { + if (_lengthLimit != CrcCalculatorStream.UnsetLengthLimit) { if (_Crc32.TotalBytesRead >= _lengthLimit) return 0; // EOF Int64 bytesRemaining = _lengthLimit - _Crc32.TotalBytesRead; if (bytesRemaining < count) bytesToRead = (int)bytesRemaining; @@ -699,8 +637,7 @@ public override int Read(byte[] buffer, int offset, int count) /// the buffer from which to write /// the offset at which to start writing /// the number of bytes to write - public override void Write(byte[] buffer, int offset, int count) - { + public override void Write(byte[] buffer, int offset, int count) { if (count > 0) _Crc32.SlurpBlock(buffer, offset, count); _innerStream.Write(buffer, offset, count); } @@ -708,8 +645,7 @@ public override void Write(byte[] buffer, int offset, int count) /// /// Indicates whether the stream supports reading. /// - public override bool CanRead - { + public override bool CanRead { get { return _innerStream.CanRead; } } @@ -721,34 +657,29 @@ public override bool CanRead /// Always returns false. /// /// - public override bool CanSeek - { + public override bool CanSeek { get { return false; } } /// /// Indicates whether the stream supports writing. /// - public override bool CanWrite - { + public override bool CanWrite { get { return _innerStream.CanWrite; } } /// /// Flush the stream. /// - public override void Flush() - { + public override void Flush() { _innerStream.Flush(); } /// /// Returns the length of the underlying stream. /// - public override long Length - { - get - { + public override long Length { + get { if (_lengthLimit == CrcCalculatorStream.UnsetLengthLimit) return _innerStream.Length; else return _lengthLimit; @@ -760,8 +691,7 @@ public override long Length /// If you use the setter, it will throw /// . /// - public override long Position - { + public override long Position { get { return _Crc32.TotalBytesRead; } set { throw new NotSupportedException(); } } @@ -773,8 +703,7 @@ public override long Position /// N/A /// N/A /// N/A - public override long Seek(long offset, System.IO.SeekOrigin origin) - { + public override long Seek(long offset, System.IO.SeekOrigin origin) { throw new NotSupportedException(); } @@ -783,22 +712,19 @@ public override long Seek(long offset, System.IO.SeekOrigin origin) /// /// /// N/A - public override void SetLength(long value) - { + public override void SetLength(long value) { throw new NotSupportedException(); } - void IDisposable.Dispose() - { + void IDisposable.Dispose() { Close(); } /// /// Closes the stream. /// - public override void Close() - { + public override void Close() { base.Close(); if (!_leaveOpen) _innerStream.Close(); diff --git a/Src/IronPython.Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs b/Src/IronPython.Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs index 91193f5aa..3231651f3 100644 --- a/Src/IronPython.Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs +++ b/Src/IronPython.Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs @@ -129,22 +129,19 @@ // using System; -using System.IO; using System.Collections.Generic; +using System.IO; using System.Threading; -namespace Ionic.BZip2 -{ - internal class WorkItem - { +namespace Ionic.BZip2 { + internal class WorkItem { public int index; public BZip2Compressor Compressor { get; private set; } public MemoryStream ms; public int ordinal; public BitWriter bw; - public WorkItem(int ix, int blockSize) - { + public WorkItem(int ix, int blockSize) { // compressed data gets written to a MemoryStream this.ms = new MemoryStream(); this.bw = new BitWriter(ms); @@ -184,8 +181,7 @@ public WorkItem(int ix, int blockSize) /// /// /// - public class ParallelBZip2OutputStream : System.IO.Stream - { + public class ParallelBZip2OutputStream : System.IO.Stream { private static readonly int BufferPairsPerCore = 4; private int _maxWorkers; private bool firstWriteDone; @@ -196,8 +192,8 @@ public class ParallelBZip2OutputStream : System.IO.Stream private volatile Exception pendingException; private bool handlingException; private bool emitting; - private System.Collections.Generic.Queue toWrite; - private System.Collections.Generic.Queue toFill; + private System.Collections.Generic.Queue toWrite; + private System.Collections.Generic.Queue toFill; private System.Collections.Generic.List pool; private object latestLock = new object(); private object eLock = new object(); // for exceptions @@ -248,8 +244,7 @@ public class ParallelBZip2OutputStream : System.IO.Stream /// /// public ParallelBZip2OutputStream(Stream output) - : this(output, BZip2.MaxBlockSize, false) - { + : this(output, BZip2.MaxBlockSize, false) { } /// @@ -261,8 +256,7 @@ public ParallelBZip2OutputStream(Stream output) /// The valid range is 1..9. /// public ParallelBZip2OutputStream(Stream output, int blockSize) - : this(output, blockSize, false) - { + : this(output, blockSize, false) { } /// @@ -273,8 +267,7 @@ public ParallelBZip2OutputStream(Stream output, int blockSize) /// whether to leave the captive stream open upon closing this stream. /// public ParallelBZip2OutputStream(Stream output, bool leaveOpen) - : this(output, BZip2.MaxBlockSize, leaveOpen) - { + : this(output, BZip2.MaxBlockSize, leaveOpen) { } /// @@ -290,10 +283,8 @@ public ParallelBZip2OutputStream(Stream output, bool leaveOpen) /// /// whether to leave the captive stream open upon closing this stream. /// - public ParallelBZip2OutputStream(Stream output, int blockSize, bool leaveOpen) - { - if (blockSize < BZip2.MinBlockSize || blockSize > BZip2.MaxBlockSize) - { + public ParallelBZip2OutputStream(Stream output, int blockSize, bool leaveOpen) { + if (blockSize < BZip2.MinBlockSize || blockSize > BZip2.MaxBlockSize) { var msg = String.Format("blockSize={0} is out of range; must be between {1} and {2}", blockSize, BZip2.MinBlockSize, BZip2.MaxBlockSize); @@ -313,15 +304,13 @@ public ParallelBZip2OutputStream(Stream output, int blockSize, bool leaveOpen) } - private void InitializePoolOfWorkItems() - { + private void InitializePoolOfWorkItems() { this.toWrite = new Queue(); this.toFill = new Queue(); this.pool = new System.Collections.Generic.List(); int nWorkers = BufferPairsPerCore * Environment.ProcessorCount; nWorkers = Math.Min(nWorkers, this.MaxWorkers); - for(int i=0; i < nWorkers; i++) - { + for (int i = 0; i < nWorkers; i++) { this.pool.Add(new WorkItem(i, this.blockSize100k)); this.toFill.Enqueue(i); } @@ -395,14 +384,11 @@ private void InitializePoolOfWorkItems() /// allocated. /// /// - public int MaxWorkers - { - get - { + public int MaxWorkers { + get { return _maxWorkers; } - set - { + set { if (value < 4) throw new ArgumentException("MaxWorkers", "Value must be 4 or greater."); @@ -419,10 +405,8 @@ public int MaxWorkers /// constructors that accept a bool value. /// /// - public override void Close() - { - if (this.pendingException != null) - { + public override void Close() { + if (this.pendingException != null) { this.handlingException = true; var pe = this.pendingException; this.pendingException = null; @@ -437,12 +421,9 @@ public override void Close() Stream o = this.output; - try - { + try { FlushOutput(true); - } - finally - { + } finally { this.output = null; this.bw = null; } @@ -452,25 +433,20 @@ public override void Close() } - private void FlushOutput(bool lastInput) - { + private void FlushOutput(bool lastInput) { if (this.emitting) return; // compress and write whatever is ready - if (this.currentlyFilling >= 0) - { + if (this.currentlyFilling >= 0) { WorkItem workitem = this.pool[this.currentlyFilling]; CompressOne(workitem); this.currentlyFilling = -1; // get a new buffer next Write() } - if (lastInput) - { + if (lastInput) { EmitPendingBuffers(true, false); EmitTrailer(); - } - else - { + } else { EmitPendingBuffers(false, false); } } @@ -480,18 +456,15 @@ private void FlushOutput(bool lastInput) /// /// Flush the stream. /// - public override void Flush() - { - if (this.output != null) - { + public override void Flush() { + if (this.output != null) { FlushOutput(false); this.bw.Flush(); this.output.Flush(); } } - private void EmitHeader() - { + private void EmitHeader() { var magic = new byte[] { (byte) 'B', (byte) 'Z', @@ -503,8 +476,7 @@ private void EmitHeader() this.output.Write(magic, 0, magic.Length); } - private void EmitTrailer() - { + private void EmitTrailer() { // A magic 48-bit number, 0x177245385090, to indicate the end // of the last block. (sqrt(pi), if you want to know) @@ -531,8 +503,7 @@ private void EmitTrailer() /// /// The blocksize parameter specified at construction time. /// - public int BlockSize - { + public int BlockSize { get { return this.blockSize100k; } } @@ -561,8 +532,7 @@ public int BlockSize /// The buffer holding data to write to the stream. /// the offset within that data array to find the first byte to write. /// the number of bytes to write. - public override void Write(byte[] buffer, int offset, int count) - { + public override void Write(byte[] buffer, int offset, int count) { bool mustWait = false; // This method does this: @@ -575,8 +545,7 @@ public override void Write(byte[] buffer, int offset, int count) throw new IOException("the stream is not open"); // dispense any exceptions that occurred on the BG threads - if (this.pendingException != null) - { + if (this.pendingException != null) { this.handlingException = true; var pe = this.pendingException; this.pendingException = null; @@ -595,8 +564,7 @@ public override void Write(byte[] buffer, int offset, int count) if (count == 0) return; // nothing to do - if (!this.firstWriteDone) - { + if (!this.firstWriteDone) { // Want to do this on first Write, first session, and not in the // constructor. Must allow the MaxWorkers to change after // construction, but before first Write(). @@ -607,8 +575,7 @@ public override void Write(byte[] buffer, int offset, int count) int bytesWritten = 0; int bytesRemaining = count; - do - { + do { // may need to make buffers available EmitPendingBuffers(false, mustWait); @@ -616,14 +583,10 @@ public override void Write(byte[] buffer, int offset, int count) // get a compressor to fill int ix = -1; - if (this.currentlyFilling >= 0) - { + if (this.currentlyFilling >= 0) { ix = this.currentlyFilling; - } - else - { - if (this.toFill.Count == 0) - { + } else { + if (this.toFill.Count == 0) { // No compressors available to fill, so... need to emit // compressed buffers. mustWait = true; @@ -638,15 +601,13 @@ public override void Write(byte[] buffer, int offset, int count) workitem.ordinal = this.lastFilled; int n = workitem.Compressor.Fill(buffer, offset, bytesRemaining); - if (n != bytesRemaining) - { - if (!ThreadPool.QueueUserWorkItem( CompressOne, workitem )) + if (n != bytesRemaining) { + if (!ThreadPool.QueueUserWorkItem(CompressOne, workitem)) throw new Exception("Cannot enqueue workitem"); this.currentlyFilling = -1; // will get a new buffer next time offset += n; - } - else + } else this.currentlyFilling = ix; bytesRemaining -= n; @@ -660,8 +621,7 @@ public override void Write(byte[] buffer, int offset, int count) - private void EmitPendingBuffers(bool doAll, bool mustWait) - { + private void EmitPendingBuffers(bool doAll, bool mustWait) { // When combining parallel compression with a ZipSegmentedStream, it's // possible for the ZSS to throw from within this method. In that // case, Close/Dispose will be called on this stream, if this stream @@ -676,47 +636,36 @@ private void EmitPendingBuffers(bool doAll, bool mustWait) if (doAll || mustWait) this.newlyCompressedBlob.WaitOne(); - do - { + do { int firstSkip = -1; int millisecondsToWait = doAll ? 200 : (mustWait ? -1 : 0); int nextToWrite = -1; - do - { - if (Monitor.TryEnter(this.toWrite, millisecondsToWait)) - { + do { + if (Monitor.TryEnter(this.toWrite, millisecondsToWait)) { nextToWrite = -1; - try - { + try { if (this.toWrite.Count > 0) nextToWrite = this.toWrite.Dequeue(); - } - finally - { + } finally { Monitor.Exit(this.toWrite); } - if (nextToWrite >= 0) - { + if (nextToWrite >= 0) { WorkItem workitem = this.pool[nextToWrite]; - if (workitem.ordinal != this.lastWritten + 1) - { + if (workitem.ordinal != this.lastWritten + 1) { // out of order. requeue and try again. - lock(this.toWrite) - { + lock (this.toWrite) { this.toWrite.Enqueue(nextToWrite); } - if (firstSkip == nextToWrite) - { + if (firstSkip == nextToWrite) { // We went around the list once. // None of the items in the list is the one we want. // Now wait for a compressor to signal again. this.newlyCompressedBlob.WaitOne(); firstSkip = -1; - } - else if (firstSkip == -1) + } else if (firstSkip == -1) firstSkip = nextToWrite; continue; @@ -731,7 +680,7 @@ private void EmitPendingBuffers(bool doAll, bool mustWait) var bw2 = workitem.bw; bw2.Flush(); // not bw2.FinishAndPad()! var ms = workitem.ms; - ms.Seek(0,SeekOrigin.Begin); + ms.Seek(0, SeekOrigin.Begin); // cannot dump bytes!! // ms.WriteTo(this.output); @@ -741,8 +690,7 @@ private void EmitPendingBuffers(bool doAll, bool mustWait) int y = -1; long totOut = 0; var buffer = new byte[1024]; - while ((n = ms.Read(buffer,0,buffer.Length)) > 0) - { + while ((n = ms.Read(buffer, 0, buffer.Length)) > 0) { #if Trace if (y == -1) // diagnostics only { @@ -754,8 +702,7 @@ private void EmitPendingBuffers(bool doAll, bool mustWait) } #endif y = n; - for (int k=0; k < n; k++) - { + for (int k = 0; k < n; k++) { this.bw.WriteByte(buffer[k]); } totOut += n; @@ -774,15 +721,14 @@ private void EmitPendingBuffers(bool doAll, bool mustWait) " remaining bits: {0} 0x{1:X}", bw2.NumRemainingBits, bw2.RemainingBits); - if (bw2.NumRemainingBits > 0) - { + if (bw2.NumRemainingBits > 0) { this.bw.WriteBits(bw2.NumRemainingBits, bw2.RemainingBits); } - TraceOutput(TraceBits.Crc," combined CRC (before): {0:X8}", + TraceOutput(TraceBits.Crc, " combined CRC (before): {0:X8}", this.combinedCRC); this.combinedCRC = (this.combinedCRC << 1) | (this.combinedCRC >> 31); - this.combinedCRC ^= (uint) workitem.Compressor.Crc32; + this.combinedCRC ^= (uint)workitem.Compressor.Crc32; TraceOutput(TraceBits.Crc, " block CRC : {0:X8}", @@ -805,16 +751,14 @@ private void EmitPendingBuffers(bool doAll, bool mustWait) // don't wait next time through if (millisecondsToWait == -1) millisecondsToWait = 0; } - } - else + } else nextToWrite = -1; } while (nextToWrite >= 0); } while (doAll && (this.lastWritten != this.latestCompressed)); - if (doAll) - { + if (doAll) { TraceOutput(TraceBits.Crc, " combined CRC (final) : {0:X8}", this.combinedCRC); } @@ -823,32 +767,25 @@ private void EmitPendingBuffers(bool doAll, bool mustWait) } - private void CompressOne(Object wi) - { + private void CompressOne(Object wi) { // compress and one buffer - WorkItem workitem = (WorkItem) wi; - try - { + WorkItem workitem = (WorkItem)wi; + try { // compress and write to the compressor's MemoryStream workitem.Compressor.CompressAndWrite(); - lock(this.latestLock) - { + lock (this.latestLock) { if (workitem.ordinal > this.latestCompressed) this.latestCompressed = workitem.ordinal; } - lock (this.toWrite) - { + lock (this.toWrite) { this.toWrite.Enqueue(workitem.index); } this.newlyCompressedBlob.Set(); - } - catch (System.Exception exc1) - { - lock(this.eLock) - { + } catch (System.Exception exc1) { + lock (this.eLock) { // expose the exception to the main thread - if (this.pendingException!=null) + if (this.pendingException != null) this.pendingException = exc1; } } @@ -863,8 +800,7 @@ private void CompressOne(Object wi) /// /// The return value is always false. /// - public override bool CanRead - { + public override bool CanRead { get { return false; } } @@ -874,8 +810,7 @@ public override bool CanRead /// /// Always returns false. /// - public override bool CanSeek - { + public override bool CanSeek { get { return false; } } @@ -885,10 +820,8 @@ public override bool CanSeek /// /// The return value depends on whether the captive stream supports writing. /// - public override bool CanWrite - { - get - { + public override bool CanWrite { + get { if (this.output == null) throw new ObjectDisposedException("BZip2Stream"); return this.output.CanWrite; } @@ -897,8 +830,7 @@ public override bool CanWrite /// /// Reading this property always throws a . /// - public override long Length - { + public override long Length { get { throw new NotImplementedException(); } } @@ -911,10 +843,8 @@ public override long Length /// cref="NotImplementedException"/>. Reading will return the /// total number of uncompressed bytes written through. /// - public override long Position - { - get - { + public override long Position { + get { return this.totalBytesWrittenIn; } set { throw new NotImplementedException(); } @@ -934,8 +864,7 @@ public override long Position /// this is irrelevant, since it will always throw! /// this is irrelevant, since it will always throw! /// irrelevant! - public override long Seek(long offset, System.IO.SeekOrigin origin) - { + public override long Seek(long offset, System.IO.SeekOrigin origin) { throw new NotImplementedException(); } @@ -943,8 +872,7 @@ public override long Seek(long offset, System.IO.SeekOrigin origin) /// Calling this method always throws a . /// /// this is irrelevant, since it will always throw! - public override void SetLength(long value) - { + public override void SetLength(long value) { throw new NotImplementedException(); } @@ -955,32 +883,27 @@ public override void SetLength(long value) /// this parameter is never used /// this parameter is never used /// never returns anything; always throws - public override int Read(byte[] buffer, int offset, int count) - { + public override int Read(byte[] buffer, int offset, int count) { throw new NotImplementedException(); } // used only when Trace is defined [Flags] - private enum TraceBits : uint - { - None = 0, - Crc = 1, - Write = 2, - All = 0xffffffff, + private enum TraceBits : uint { + None = 0, + Crc = 1, + Write = 2, + All = 0xffffffff, } [System.Diagnostics.ConditionalAttribute("Trace")] - private void TraceOutput(TraceBits bits, string format, params object[] varParams) - { - if ((bits & this.desiredTrace) != 0) - { - lock(outputLock) - { + private void TraceOutput(TraceBits bits, string format, params object[] varParams) { + if ((bits & this.desiredTrace) != 0) { + lock (outputLock) { int tid = Thread.CurrentThread.GetHashCode(); - Console.ForegroundColor = (ConsoleColor) (tid % 8 + 10); + Console.ForegroundColor = (ConsoleColor)(tid % 8 + 10); Console.Write("{0:000} PBOS ", tid); Console.WriteLine(format, varParams); Console.ResetColor(); diff --git a/Src/IronPython.Modules/bz2/dotnetzip/BZip2/Rand.cs b/Src/IronPython.Modules/bz2/dotnetzip/BZip2/Rand.cs index ac00decd2..654ae49da 100644 --- a/Src/IronPython.Modules/bz2/dotnetzip/BZip2/Rand.cs +++ b/Src/IronPython.Modules/bz2/dotnetzip/BZip2/Rand.cs @@ -24,10 +24,8 @@ // ------------------------------------------------------------------ -namespace Ionic.BZip2 -{ - internal static class Rand - { +namespace Ionic.BZip2 { + internal static class Rand { private static int[] RNUMS = { 619, 720, 127, 481, 931, 816, 813, 233, 566, 247, @@ -90,8 +88,7 @@ internal static class Rand /// /// the index /// the random number - internal static int Rnums(int i) - { + internal static int Rnums(int i) { return RNUMS[i]; } } diff --git a/Src/IronPython.Modules/gc.cs b/Src/IronPython.Modules/gc.cs index 87bcacbaf..a27605892 100644 --- a/Src/IronPython.Modules/gc.cs +++ b/Src/IronPython.Modules/gc.cs @@ -5,13 +5,11 @@ using System; using System.Linq; -using Microsoft.Scripting; -using Microsoft.Scripting.Runtime; - using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; + +using Microsoft.Scripting.Runtime; using SpecialName = System.Runtime.CompilerServices.SpecialNameAttribute; @@ -29,7 +27,7 @@ public static class PythonGC { private static readonly object _threadholdKey = new object(); [SpecialName] - public static void PerformModuleReload(PythonContext/*!*/ context, PythonDictionary/*!*/ dict) { + public static void PerformModuleReload(PythonContext/*!*/ context, PythonDictionary/*!*/ dict) { context.SetModuleState(_threadholdKey, PythonTuple.MakeTuple(64 * 1024, 256 * 1024, 1024 * 1024)); } @@ -65,19 +63,19 @@ public static object[] get_objects() { } public static void set_threshold(CodeContext/*!*/ context, params object[] args) { - if(args.Length == 0) { + if (args.Length == 0) { throw PythonOps.TypeError("set_threshold() takes at least 1 argument (0 given)"); } - if(args.Length > 3) { + if (args.Length > 3) { throw PythonOps.TypeError("set_threshold() takes at most 3 arguments ({0} given)", args.Length); } - if(args.Any(x => x is double)) { + if (args.Any(x => x is double)) { throw PythonOps.TypeError("integer argument expected, got float"); } - if(!args.All(x => x is int)) { + if (!args.All(x => x is int)) { throw PythonOps.TypeError("an integer is required"); } diff --git a/Src/IronPython.Modules/grp.cs b/Src/IronPython.Modules/grp.cs index d46de20f5..16dfe8b26 100644 --- a/Src/IronPython.Modules/grp.cs +++ b/Src/IronPython.Modules/grp.cs @@ -8,16 +8,14 @@ using System.Collections.Generic; using System.Runtime.InteropServices; -using Microsoft.Scripting.Runtime; - using IronPython.Runtime; using IronPython.Runtime.Operations; -using System.Numerics; +using Microsoft.Scripting.Runtime; [assembly: PythonModule("grp", typeof(IronPython.Modules.PythonGrp), PlatformsAttribute.PlatformFamily.Unix)] namespace IronPython.Modules { - + public static class PythonGrp { public const string __doc__ = @"Access to the Unix group database. @@ -79,13 +77,10 @@ private static struct_group Make(IntPtr pwd) { return new struct_group(g.gr_name, g.gr_passwd, g.gr_gid, PythonList.FromEnumerable(MarshalStringArray(g.gr_mem))); } - private static IEnumerable MarshalStringArray(IntPtr arrayPtr) - { - if (arrayPtr != IntPtr.Zero) - { + private static IEnumerable MarshalStringArray(IntPtr arrayPtr) { + if (arrayPtr != IntPtr.Zero) { IntPtr ptr = Marshal.ReadIntPtr(arrayPtr); - while (ptr != IntPtr.Zero) - { + while (ptr != IntPtr.Zero) { string key = Marshal.PtrToStringAnsi(ptr); yield return key; arrayPtr = new IntPtr(arrayPtr.ToInt64() + IntPtr.Size); @@ -96,7 +91,7 @@ private static IEnumerable MarshalStringArray(IntPtr arrayPtr) public static struct_group getgrgid(int gid) { var grp = _getgrgid(gid); - if(grp == IntPtr.Zero) { + if (grp == IntPtr.Zero) { throw PythonOps.KeyError($"getgrgid(): gid not found: {gid}"); } @@ -105,7 +100,7 @@ public static struct_group getgrgid(int gid) { public static struct_group getgrnam(string name) { var grp = _getgrnam(name); - if(grp == IntPtr.Zero) { + if (grp == IntPtr.Zero) { throw PythonOps.KeyError($"getgrnam()): name not found: {name}"); } @@ -116,27 +111,27 @@ public static PythonList getgrall() { var res = new PythonList(); setgrent(); IntPtr val = getgrent(); - while(val != IntPtr.Zero) { + while (val != IntPtr.Zero) { res.Add(Make(val)); val = getgrent(); } - + return res; } #region P/Invoke Declarations - [DllImport("libc", EntryPoint="getgrgid", CallingConvention=CallingConvention.Cdecl)] + [DllImport("libc", EntryPoint = "getgrgid", CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr _getgrgid(int uid); - [DllImport("libc", EntryPoint="getgrnam", CallingConvention=CallingConvention.Cdecl)] + [DllImport("libc", EntryPoint = "getgrnam", CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr _getgrnam([MarshalAs(UnmanagedType.LPStr)] string name); - [DllImport("libc", CallingConvention=CallingConvention.Cdecl)] + [DllImport("libc", CallingConvention = CallingConvention.Cdecl)] private static extern void setgrent(); - [DllImport("libc", CallingConvention=CallingConvention.Cdecl)] + [DllImport("libc", CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr getgrent(); #endregion diff --git a/Src/IronPython.Modules/hashlib/SHA224Managed.cs b/Src/IronPython.Modules/hashlib/SHA224Managed.cs index 6037a5df2..4840afd76 100644 --- a/Src/IronPython.Modules/hashlib/SHA224Managed.cs +++ b/Src/IronPython.Modules/hashlib/SHA224Managed.cs @@ -29,8 +29,6 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -using System.Security.Cryptography; - using IronPython.Runtime; namespace Mono.Security.Cryptography { diff --git a/Src/IronPython.Modules/hashlib/SHA384Managed.cs b/Src/IronPython.Modules/hashlib/SHA384Managed.cs index 6ea90617b..e47a86c94 100644 --- a/Src/IronPython.Modules/hashlib/SHA384Managed.cs +++ b/Src/IronPython.Modules/hashlib/SHA384Managed.cs @@ -30,7 +30,6 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -using System; using System.Runtime.InteropServices; using System.Security.Cryptography; diff --git a/Src/IronPython.Modules/hashlib/_hashlib.cs b/Src/IronPython.Modules/hashlib/_hashlib.cs index f463224ca..2af22c374 100644 --- a/Src/IronPython.Modules/hashlib/_hashlib.cs +++ b/Src/IronPython.Modules/hashlib/_hashlib.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Security.Cryptography; diff --git a/Src/IronPython.Modules/marshal.cs b/Src/IronPython.Modules/marshal.cs index 1841e9a93..f431892e7 100644 --- a/Src/IronPython.Modules/marshal.cs +++ b/Src/IronPython.Modules/marshal.cs @@ -30,7 +30,7 @@ public static Bytes dumps(object value, int version = PythonMarshal.version) { return Bytes.Make(MarshalOps.GetBytes(value, version)); } - public static object loads([BytesLike]IList bytes) { + public static object loads([BytesLike] IList bytes) { return MarshalOps.GetObject(bytes.GetEnumerator()); } diff --git a/Src/IronPython.Modules/math.cs b/Src/IronPython.Modules/math.cs index a7f3910a5..6e6dfff2d 100644 --- a/Src/IronPython.Modules/math.cs +++ b/Src/IronPython.Modules/math.cs @@ -9,12 +9,10 @@ using System.Linq; using System.Numerics; -using Microsoft.Scripting; -using Microsoft.Scripting.Utils; - using IronPython.Runtime; using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; + +using Microsoft.Scripting.Utils; [assembly: PythonModule("math", typeof(IronPython.Modules.PythonMath))] namespace IronPython.Modules { diff --git a/Src/IronPython.Modules/msvcrt.cs b/Src/IronPython.Modules/msvcrt.cs index e81c3d119..3ccc6e61a 100644 --- a/Src/IronPython.Modules/msvcrt.cs +++ b/Src/IronPython.Modules/msvcrt.cs @@ -5,6 +5,7 @@ #if FEATURE_NATIVE using Microsoft.Win32.SafeHandles; + using System; using System.ComponentModel; using System.IO; @@ -195,34 +196,34 @@ public static void ungetwch(char @char) { private static int EOF = -1; private static ushort WEOF = 0xFFFF; - [DllImport("msvcr100", SetLastError=true, CallingConvention=CallingConvention.Cdecl)] + [DllImport("msvcr100", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] private static extern int _heapmin(); - [DllImport("msvcr100", CallingConvention=CallingConvention.Cdecl)] + [DllImport("msvcr100", CallingConvention = CallingConvention.Cdecl)] private static extern int _kbhit(); - [DllImport("msvcr100", CallingConvention=CallingConvention.Cdecl)] + [DllImport("msvcr100", CallingConvention = CallingConvention.Cdecl)] private static extern int _getch(); - [DllImport("msvcr100", CallingConvention=CallingConvention.Cdecl)] + [DllImport("msvcr100", CallingConvention = CallingConvention.Cdecl)] private static extern int _getche(); - [DllImport("msvcr100", CallingConvention=CallingConvention.Cdecl)] + [DllImport("msvcr100", CallingConvention = CallingConvention.Cdecl)] private static extern int _putch(int c); - [DllImport("msvcr100", SetLastError=true, CallingConvention=CallingConvention.Cdecl)] + [DllImport("msvcr100", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] private static extern int _ungetch(int c); - [DllImport("msvcr100", CallingConvention=CallingConvention.Cdecl)] + [DllImport("msvcr100", CallingConvention = CallingConvention.Cdecl)] private static extern ushort _getwch(); - [DllImport("msvcr100", CallingConvention=CallingConvention.Cdecl)] + [DllImport("msvcr100", CallingConvention = CallingConvention.Cdecl)] private static extern ushort _getwche(); - [DllImport("msvcr100", CallingConvention=CallingConvention.Cdecl)] + [DllImport("msvcr100", CallingConvention = CallingConvention.Cdecl)] private static extern ushort _putwch(char c); - [DllImport("msvcr100", SetLastError=true, CallingConvention=CallingConvention.Cdecl)] + [DllImport("msvcr100", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] private static extern ushort _ungetwch(ushort c); #endregion diff --git a/Src/IronPython.Modules/nt.cs b/Src/IronPython.Modules/nt.cs index f6f920a3c..e5fe37817 100644 --- a/Src/IronPython.Modules/nt.cs +++ b/Src/IronPython.Modules/nt.cs @@ -5,6 +5,7 @@ #nullable enable using Microsoft.Win32.SafeHandles; + using System; using System.Collections; using System.Collections.Generic; @@ -2306,10 +2307,10 @@ private static Bytes ToFsBytes(this IBufferProtocol bp, CodeContext context) { private static string ConvertToFsString(CodeContext context, [NotNull] object? o, string argname, [CallerMemberName] string? methodname = null) => o switch { - string s => s, + string s => s, ExtensibleString es => es.Value, - Bytes b => b.ToFsString(context), - IBufferProtocol bp => bp.ToFsBytes(context).ToFsString(context), + Bytes b => b.ToFsString(context), + IBufferProtocol bp => bp.ToFsBytes(context).ToFsString(context), // TODO: Python 3.6: os.PathLike _ => throw PythonOps.TypeError("{0}: {1} should be string or bytes, not '{2}'", methodname, argname, PythonOps.GetPythonTypeName(o)) }; diff --git a/Src/IronPython.Modules/pwd.cs b/Src/IronPython.Modules/pwd.cs index 1eb3b015b..a848008f1 100644 --- a/Src/IronPython.Modules/pwd.cs +++ b/Src/IronPython.Modules/pwd.cs @@ -5,19 +5,17 @@ #if FEATURE_NATIVE using System; +using System.Numerics; using System.Runtime.InteropServices; -using Microsoft.Scripting.Runtime; - -using IronPython; using IronPython.Runtime; using IronPython.Runtime.Operations; -using System.Numerics; +using Microsoft.Scripting.Runtime; [assembly: PythonModule("pwd", typeof(IronPython.Modules.PythonPwd), PlatformsAttribute.PlatformFamily.Unix)] namespace IronPython.Modules { - + public static class PythonPwd { public const string __doc__ = @"This module provides access to the Unix password database. It is available on all Unix versions. @@ -130,11 +128,11 @@ public static struct_passwd getpwuid(object uid) { if (uid is int id) { var pwd = _getpwuid(id); - if(pwd == IntPtr.Zero) { + if (pwd == IntPtr.Zero) { throw PythonOps.KeyError($"getpwuid(): uid not found: {id}"); } - return Make(pwd); + return Make(pwd); } throw PythonOps.TypeError($"integer argument expected, got {PythonOps.GetPythonTypeName(uid)}"); @@ -143,7 +141,7 @@ public static struct_passwd getpwuid(object uid) { [Documentation("Return the password database entry for the given user name.")] public static struct_passwd getpwnam(string name) { var pwd = _getpwnam(name); - if(pwd == IntPtr.Zero) { + if (pwd == IntPtr.Zero) { throw PythonOps.KeyError($"getpwname(): name not found: {name}"); } @@ -155,27 +153,27 @@ public static PythonList getpwall() { var res = new PythonList(); setpwent(); IntPtr val = getpwent(); - while(val != IntPtr.Zero) { + while (val != IntPtr.Zero) { res.Add(Make(val)); val = getpwent(); } - + return res; } #region P/Invoke Declarations - [DllImport("libc", EntryPoint="getpwuid", CallingConvention=CallingConvention.Cdecl)] + [DllImport("libc", EntryPoint = "getpwuid", CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr _getpwuid(int uid); - [DllImport("libc", EntryPoint="getpwnam", CallingConvention=CallingConvention.Cdecl)] + [DllImport("libc", EntryPoint = "getpwnam", CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr _getpwnam([MarshalAs(UnmanagedType.LPStr)] string name); - [DllImport("libc", CallingConvention=CallingConvention.Cdecl)] + [DllImport("libc", CallingConvention = CallingConvention.Cdecl)] private static extern void setpwent(); - [DllImport("libc", CallingConvention=CallingConvention.Cdecl)] + [DllImport("libc", CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr getpwent(); #endregion diff --git a/Src/IronPython.Modules/pyexpat.cs b/Src/IronPython.Modules/pyexpat.cs index 0e68c8a06..a8ead845d 100644 --- a/Src/IronPython.Modules/pyexpat.cs +++ b/Src/IronPython.Modules/pyexpat.cs @@ -229,7 +229,7 @@ public static string ErrorString(int errno) { return null; } - public static object ParserCreate(CodeContext context, [ParamDictionary]IDictionary kwArgs\u00F8, params object[] args\u00F8) { + public static object ParserCreate(CodeContext context, [ParamDictionary] IDictionary kwArgs\u00F8, params object[] args\u00F8) { var numArgs = argsø.Length + kwArgsø.Count; if (numArgs > 3) throw PythonOps.TypeError($"ParserCreate() takes at most 3 arguments ({numArgs} given)"); diff --git a/Src/IronPython.Modules/re.cs b/Src/IronPython.Modules/re.cs index c2a371819..0d065889e 100644 --- a/Src/IronPython.Modules/re.cs +++ b/Src/IronPython.Modules/re.cs @@ -74,14 +74,14 @@ internal enum ReFlags : int { public const int A = (int)ReFlags.ASCII; // long forms - public const int TEMPLATE = (int)ReFlags.TEMPLATE; + public const int TEMPLATE = (int)ReFlags.TEMPLATE; public const int IGNORECASE = (int)ReFlags.IGNORECASE; - public const int LOCALE = (int)ReFlags.LOCALE; - public const int MULTILINE = (int)ReFlags.MULTILINE; - public const int DOTALL = (int)ReFlags.DOTALL; - public const int UNICODE = (int)ReFlags.UNICODE; - public const int VERBOSE = (int)ReFlags.VERBOSE; - public const int ASCII = (int)ReFlags.ASCII; + public const int LOCALE = (int)ReFlags.LOCALE; + public const int MULTILINE = (int)ReFlags.MULTILINE; + public const int DOTALL = (int)ReFlags.DOTALL; + public const int UNICODE = (int)ReFlags.UNICODE; + public const int VERBOSE = (int)ReFlags.VERBOSE; + public const int ASCII = (int)ReFlags.ASCII; #endregion diff --git a/Src/IronPython.Modules/resource.cs b/Src/IronPython.Modules/resource.cs index f83898a1c..ba6f0babb 100644 --- a/Src/IronPython.Modules/resource.cs +++ b/Src/IronPython.Modules/resource.cs @@ -5,18 +5,18 @@ #nullable enable using System; -using System.Numerics; using System.Linq; +using System.Numerics; using System.Runtime.InteropServices; using System.Runtime.Versioning; -using Microsoft.Scripting.Runtime; - using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting.Runtime; + [assembly: PythonModule("resource", typeof(IronPython.Modules.PythonResourceModule), PlatformsAttribute.PlatformFamily.Unix)] namespace IronPython.Modules; @@ -367,20 +367,20 @@ internal struct rusage { public timeval ru_utime; // user CPU time used public timeval ru_stime; // system CPU time used - public long ru_maxrss; // maximum resident set size - public long ru_ixrss; // integral shared memory size - public long ru_idrss; // integral unshared data size - public long ru_isrss; // integral unshared stack size - public long ru_minflt; // page reclaims (soft page faults) - public long ru_majflt; // page faults (hard page faults) - public long ru_nswap; // swaps - public long ru_inblock; // block input operations - public long ru_oublock; // block output operations - public long ru_msgsnd; // IPC messages sent - public long ru_msgrcv; // IPC messages received - public long ru_nsignals; // signals received - public long ru_nvcsw; // voluntary context switches - public long ru_nivcsw; // involuntary context switches + public long ru_maxrss; // maximum resident set size + public long ru_ixrss; // integral shared memory size + public long ru_idrss; // integral unshared data size + public long ru_isrss; // integral unshared stack size + public long ru_minflt; // page reclaims (soft page faults) + public long ru_majflt; // page faults (hard page faults) + public long ru_nswap; // swaps + public long ru_inblock; // block input operations + public long ru_oublock; // block output operations + public long ru_msgsnd; // IPC messages sent + public long ru_msgrcv; // IPC messages received + public long ru_nsignals; // signals received + public long ru_nvcsw; // voluntary context switches + public long ru_nivcsw; // involuntary context switches } #pragma warning restore CS0649 diff --git a/Src/IronPython.Modules/select.cs b/Src/IronPython.Modules/select.cs index f5f8c2ed3..9d7e9a5a3 100644 --- a/Src/IronPython.Modules/select.cs +++ b/Src/IronPython.Modules/select.cs @@ -40,7 +40,7 @@ public static class PythonSelect { + "Note that select() on IronPython works only with sockets; it will not work with\n" + "files or other objects." )] - public static PythonTuple select(CodeContext/*!*/ context, object iwtd, object owtd, object ewtd, object timeout=null) { + public static PythonTuple select(CodeContext/*!*/ context, object iwtd, object owtd, object ewtd, object timeout = null) { PythonList readerList, writerList, errorList; Dictionary readerOriginals, writerOriginals, errorOriginals; ProcessSocketSequence(context, iwtd, out readerList, out readerOriginals); @@ -57,7 +57,7 @@ public static PythonTuple select(CodeContext/*!*/ context, object iwtd, object o if (!Converter.TryConvertToDouble(timeout, out timeoutSeconds)) { throw PythonOps.TypeErrorForTypeMismatch("float or None", timeout); } - timeoutMicroseconds = (int) (1000000 * timeoutSeconds); + timeoutMicroseconds = (int)(1000000 * timeoutSeconds); } try { diff --git a/Src/IronPython.Modules/signal.cs b/Src/IronPython.Modules/signal.cs index 1ae2de2f8..b42c63fdf 100644 --- a/Src/IronPython.Modules/signal.cs +++ b/Src/IronPython.Modules/signal.cs @@ -160,7 +160,7 @@ public static object signal(CodeContext/*!*/ context, int sig, object action) { PythonFunction result = action as PythonFunction; if (result == null) { //It could still be something like a type that implements __call__ - if (! PythonOps.IsCallable(context, action)) { + if (!PythonOps.IsCallable(context, action)) { throw PythonOps.TypeError("signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object"); } } @@ -191,11 +191,11 @@ public static void set_wakeup_fd(CodeContext/*!*/ context, uint fd) { } private static readonly object _PythonSignalStateKey = new object(); - + private static PythonSignalState GetPythonSignalState(CodeContext/*!*/ context) { return (PythonSignalState)context.LanguageContext.GetModuleState(_PythonSignalStateKey); } - + private static void SetPythonSignalState(CodeContext/*!*/ context, PythonSignalState pss) { context.LanguageContext.SetModuleState(_PythonSignalStateKey, pss); } diff --git a/Src/IronPython.Modules/spwd.cs b/Src/IronPython.Modules/spwd.cs index 9445f7341..a477f56d7 100644 --- a/Src/IronPython.Modules/spwd.cs +++ b/Src/IronPython.Modules/spwd.cs @@ -7,16 +7,14 @@ using System; using System.Runtime.InteropServices; -using Microsoft.Scripting.Runtime; - using IronPython.Runtime; using IronPython.Runtime.Operations; -using System.Numerics; +using Microsoft.Scripting.Runtime; [assembly: PythonModule("spwd", typeof(IronPython.Modules.PythonSpwd), PlatformsAttribute.PlatformFamily.Unix)] namespace IronPython.Modules { - + public static class PythonSpwd { public const string __doc__ = @"This module provides access to the Unix shadow password database. It is available on various Unix versions. @@ -41,7 +39,7 @@ private struct spwd { public int sp_inact; public int sp_expire; public int sp_flag; - }; + }; [PythonType("struct_spwd")] [Documentation(@"spwd.struct_spwd: Results from getsp*() routines. @@ -54,7 +52,7 @@ public class struct_spwd : PythonTuple { private const int LENGTH = 9; internal struct_spwd(string sp_nam, string sp_pwd, int sp_lstchg, int sp_min, int sp_max, int sp_warn, int sp_inact, int sp_expire, int sp_flag) : - base(new object[] { sp_nam ,sp_pwd, sp_lstchg, sp_min, sp_max, sp_warn, sp_inact, sp_expire, sp_flag }) { + base(new object[] { sp_nam, sp_pwd, sp_lstchg, sp_min, sp_max, sp_warn, sp_inact, sp_expire, sp_flag }) { } [Documentation("login name")] @@ -97,7 +95,7 @@ private static struct_spwd Make(IntPtr pwd) { [Documentation("Return the shadow password database entry for the given user name.")] public static struct_spwd getspnam(string name) { var pwd = _getspnam(name); - if(pwd == IntPtr.Zero) { + if (pwd == IntPtr.Zero) { throw PythonOps.KeyError($"getspnam(): name not found"); } @@ -109,24 +107,24 @@ public static PythonList getspall() { var res = new PythonList(); setspent(); IntPtr val = getspent(); - while(val != IntPtr.Zero) { + while (val != IntPtr.Zero) { res.Add(Make(val)); val = getspent(); } - + return res; } #region P/Invoke Declarations - [DllImport("libc", EntryPoint="getspnam", CallingConvention=CallingConvention.Cdecl)] + [DllImport("libc", EntryPoint = "getspnam", CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr _getspnam([MarshalAs(UnmanagedType.LPStr)] string name); - [DllImport("libc", CallingConvention=CallingConvention.Cdecl)] + [DllImport("libc", CallingConvention = CallingConvention.Cdecl)] private static extern void setspent(); - [DllImport("libc", CallingConvention=CallingConvention.Cdecl)] + [DllImport("libc", CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr getspent(); #endregion diff --git a/Src/IronPython.Modules/winreg.cs b/Src/IronPython.Modules/winreg.cs index 5b80836d2..22270900b 100644 --- a/Src/IronPython.Modules/winreg.cs +++ b/Src/IronPython.Modules/winreg.cs @@ -4,8 +4,6 @@ #if FEATURE_REGISTRY -using Microsoft.Win32; -using Microsoft.Win32.SafeHandles; using System; using System.Collections.Concurrent; using System.ComponentModel; @@ -22,6 +20,9 @@ using IronPython.Runtime.Exceptions; using IronPython.Runtime.Types; +using Microsoft.Win32; +using Microsoft.Win32.SafeHandles; + [assembly: PythonModule("winreg", typeof(IronPython.Modules.PythonWinReg), PlatformsAttribute.PlatformFamily.Windows)] namespace IronPython.Modules { [SupportedOSPlatform("windows")] diff --git a/Src/IronPython.Modules/winsound.cs b/Src/IronPython.Modules/winsound.cs index 56cb0cfc8..327bf04d1 100644 --- a/Src/IronPython.Modules/winsound.cs +++ b/Src/IronPython.Modules/winsound.cs @@ -7,7 +7,6 @@ #nullable enable using System; -using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Runtime.Versioning; @@ -132,7 +131,7 @@ public static void Beep(CodeContext/*!*/ context, int freq, int dur) { } [Documentation("MessageBeep(x) - call Windows MessageBeep(x). x defaults to MB_OK.")] - public static void MessageBeep(CodeContext/*!*/ context, int x=MB_OK) { + public static void MessageBeep(CodeContext/*!*/ context, int x = MB_OK) { MessageBeep(x); } diff --git a/Src/IronPython.Modules/xxsubtype.cs b/Src/IronPython.Modules/xxsubtype.cs index 8980fc8c1..db2c251ec 100644 --- a/Src/IronPython.Modules/xxsubtype.cs +++ b/Src/IronPython.Modules/xxsubtype.cs @@ -2,17 +2,16 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using Microsoft.Scripting; - using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting; + [assembly: PythonModule("xxsubtype", typeof(IronPython.Modules.xxsubtype))] -namespace IronPython.Modules { +namespace IronPython.Modules { /// /// Samples on how to subtype built-in types from C# /// @@ -50,12 +49,12 @@ public void setstate(int value) { state = value; } - public static object staticmeth([ParamDictionary]IDictionary dict, params object[] args) { + public static object staticmeth([ParamDictionary] IDictionary dict, params object[] args) { return PythonTuple.MakeTuple(null, PythonTuple.MakeTuple(args), dict); } [ClassMethod] - public static object classmeth(PythonType cls, [ParamDictionary]IDictionary dict, params object[] args) { + public static object classmeth(PythonType cls, [ParamDictionary] IDictionary dict, params object[] args) { return PythonTuple.MakeTuple(cls, PythonTuple.MakeTuple(args), dict); } } diff --git a/Src/IronPython.Modules/zipimport.cs b/Src/IronPython.Modules/zipimport.cs index f1d97b0d2..62bb9c8f7 100644 --- a/Src/IronPython.Modules/zipimport.cs +++ b/Src/IronPython.Modules/zipimport.cs @@ -1,6 +1,6 @@ using System; -using System.IO; using System.Collections.Generic; +using System.IO; using System.Runtime.CompilerServices; using IronPython.Runtime; @@ -10,7 +10,6 @@ using IronPython.Zlib; using Microsoft.Scripting; -using Microsoft.Scripting.Utils; using Microsoft.Scripting.Runtime; [assembly: PythonModule("zipimport", typeof(IronPython.Runtime.ZipImportModule))] diff --git a/Src/IronPython.Modules/zlib/Compress.cs b/Src/IronPython.Modules/zlib/Compress.cs index 4f07b7fdf..e9903d2a9 100644 --- a/Src/IronPython.Modules/zlib/Compress.cs +++ b/Src/IronPython.Modules/zlib/Compress.cs @@ -6,33 +6,30 @@ // using System; -using System.Collections.Generic; using System.Linq; -using System.Runtime.InteropServices; + using ComponentAce.Compression.Libs.ZLib; + using IronPython.Runtime; using IronPython.Runtime.Operations; + using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -namespace IronPython.Zlib -{ +namespace IronPython.Zlib { [PythonType] - public class Compress - { + public class Compress { private const int Z_OK = ZlibModule.Z_OK; private const int Z_BUF_ERROR = ZlibModule.Z_BUF_ERROR; private const int Z_STREAM_END = ZlibModule.Z_STREAM_END; - + private const int Z_NO_FLUSH = ZlibModule.Z_NO_FLUSH; private const int Z_FINISH = ZlibModule.Z_FINISH; - internal Compress(int level, int method, int wbits, int memlevel, int strategy) - { + internal Compress(int level, int method, int wbits, int memlevel, int strategy) { zst = new ZStream(); int err = zst.DeflateInit(level, wbits); - switch(err) - { + switch (err) { case ZlibModule.Z_OK: break; @@ -49,8 +46,7 @@ internal Compress(int level, int method, int wbits, int memlevel, int strategy) After calling this function, some of the input data may still be stored in internal buffers for later processing. Call the flush() method to clear these buffers.")] - public Bytes compress([NotNone] IBufferProtocol data) - { + public Bytes compress([NotNone] IBufferProtocol data) { using var buffer = data.GetBuffer(); byte[] input = buffer.AsUnsafeArray() ?? buffer.ToArray(); byte[] output = new byte[ZlibModule.DEFAULTALLOC]; @@ -65,8 +61,7 @@ public Bytes compress([NotNone] IBufferProtocol data) int err = zst.deflate(Z_NO_FLUSH); - while(err == Z_OK && zst.avail_out == 0) - { + while (err == Z_OK && zst.avail_out == 0) { int length = output.Length; Array.Resize(ref output, output.Length * 2); @@ -76,8 +71,7 @@ public Bytes compress([NotNone] IBufferProtocol data) err = zst.deflate(Z_NO_FLUSH); } - if(err != Z_OK && err != Z_BUF_ERROR) - { + if (err != Z_OK && err != Z_BUF_ERROR) { throw ZlibModule.zlib_error(this.zst, err, "while compressing"); } @@ -90,12 +84,10 @@ public Bytes compress([NotNone] IBufferProtocol data) default value used when mode is not specified is Z_FINISH. If mode == Z_FINISH, the compressor object can no longer be used after calling the flush() method. Otherwise, more data can still be compressed.")] - public Bytes flush(int mode=Z_FINISH) - { + public Bytes flush(int mode = Z_FINISH) { byte[] output = new byte[ZlibModule.DEFAULTALLOC]; - if(mode == Z_NO_FLUSH) - { + if (mode == Z_NO_FLUSH) { return Bytes.Empty; } @@ -106,8 +98,7 @@ public Bytes flush(int mode=Z_FINISH) zst.avail_out = output.Length; int err = zst.deflate((FlushStrategy)mode); - while(err == Z_OK && zst.avail_out == 0) - { + while (err == Z_OK && zst.avail_out == 0) { int old_length = output.Length; Array.Resize(ref output, output.Length * 2); @@ -117,16 +108,12 @@ public Bytes flush(int mode=Z_FINISH) err = zst.deflate((FlushStrategy)mode); } - if(err == Z_STREAM_END && mode == Z_FINISH) - { + if (err == Z_STREAM_END && mode == Z_FINISH) { err = zst.deflateEnd(); - if(err != Z_OK) - { + if (err != Z_OK) { throw ZlibModule.zlib_error(this.zst, err, "from deflateEnd()"); } - } - else if(err != Z_OK && err != Z_BUF_ERROR) - { + } else if (err != Z_OK && err != Z_BUF_ERROR) { throw ZlibModule.zlib_error(this.zst, err, "while flushing"); } @@ -141,8 +128,7 @@ public Bytes flush(int mode=Z_FINISH) private ZStream zst; - private static Bytes GetBytes(byte[] bytes, int index, int count) - { + private static Bytes GetBytes(byte[] bytes, int index, int count) { var res = new byte[count]; Array.Copy(bytes, index, res, 0, count); return Bytes.Make(res); diff --git a/Src/IronPython.Modules/zlib/Decompress.cs b/Src/IronPython.Modules/zlib/Decompress.cs index c0965e6ad..528e36cf2 100644 --- a/Src/IronPython.Modules/zlib/Decompress.cs +++ b/Src/IronPython.Modules/zlib/Decompress.cs @@ -6,20 +6,19 @@ // using System; -using System.Collections.Generic; using System.Linq; -using System.Runtime.InteropServices; + using ComponentAce.Compression.Libs.ZLib; + using IronPython.Runtime; using IronPython.Runtime.Operations; + using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -namespace IronPython.Zlib -{ +namespace IronPython.Zlib { [PythonType] - public class Decompress - { + public class Decompress { private const int Z_OK = ZlibModule.Z_OK; private const int Z_STREAM_END = ZlibModule.Z_STREAM_END; private const int Z_BUF_ERROR = ZlibModule.Z_BUF_ERROR; @@ -27,12 +26,10 @@ public class Decompress private const int Z_SYNC_FLUSH = ZlibModule.Z_SYNC_FLUSH; private const int Z_FINISH = ZlibModule.Z_FINISH; - internal Decompress(int wbits) - { + internal Decompress(int wbits) { zst = new ZStream(); int err = zst.inflateInit(wbits); - switch(err) - { + switch (err) { case ZlibModule.Z_OK: break; @@ -59,9 +56,8 @@ Call the flush() method to clear these buffers. If the max_length parameter is specified then the return value will be no longer than max_length. Unconsumed input data will be stored in the unconsumed_tail attribute.")] - public Bytes decompress([NotNone] IBufferProtocol data, int max_length=0) - { - if(max_length < 0) throw new ArgumentException("max_length must be greater than zero"); + public Bytes decompress([NotNone] IBufferProtocol data, int max_length = 0) { + if (max_length < 0) throw new ArgumentException("max_length must be greater than zero"); using var buffer = data.GetBuffer(); byte[] input = buffer.AsUnsafeArray() ?? buffer.ToArray(); @@ -77,9 +73,8 @@ public Bytes decompress([NotNone] IBufferProtocol data, int max_length=0) int err = zst.inflate(FlushStrategy.Z_SYNC_FLUSH); - while(err == Z_OK && zst.avail_out == 0) - { - if(max_length > 0 && output.Length >= max_length) + while (err == Z_OK && zst.avail_out == 0) { + if (max_length > 0 && output.Length >= max_length) break; int old_length = output.Length; @@ -90,18 +85,14 @@ public Bytes decompress([NotNone] IBufferProtocol data, int max_length=0) err = zst.inflate(FlushStrategy.Z_SYNC_FLUSH); } - if(max_length > 0) - { + if (max_length > 0) { unconsumed_tail = GetBytes(zst.next_in, zst.next_in_index, zst.avail_in); } - if(err == Z_STREAM_END) - { + if (err == Z_STREAM_END) { unused_data += GetBytes(zst.next_in, zst.next_in_index, zst.avail_in); eof = true; - } - else if(err != Z_OK && err != Z_BUF_ERROR) - { + } else if (err != Z_OK && err != Z_BUF_ERROR) { throw ZlibModule.zlib_error(this.zst, err, "while decompressing"); } @@ -115,9 +106,8 @@ public Bytes decompress([NotNone] IBufferProtocol data, int max_length=0) output buffer. The decompressor object can no longer be used after this call.")] - public Bytes flush(int length=ZlibModule.DEFAULTALLOC) - { - if(length < 1) + public Bytes flush(int length = ZlibModule.DEFAULTALLOC) { + if (length < 1) throw PythonOps.ValueError("length must be greater than 0."); byte[] output = new byte[length]; @@ -129,8 +119,7 @@ public Bytes flush(int length=ZlibModule.DEFAULTALLOC) int err = zst.inflate(FlushStrategy.Z_FINISH); - while((err == Z_OK || err == Z_BUF_ERROR) &&zst.avail_out == 0) - { + while ((err == Z_OK || err == Z_BUF_ERROR) && zst.avail_out == 0) { int old_length = output.Length; Array.Resize(ref output, output.Length * 2); zst.next_out = output; @@ -139,11 +128,9 @@ public Bytes flush(int length=ZlibModule.DEFAULTALLOC) err = zst.inflate(FlushStrategy.Z_FINISH); } - if(err == Z_STREAM_END) - { + if (err == Z_STREAM_END) { err = zst.inflateEnd(); - if(err != Z_OK) - { + if (err != Z_OK) { throw ZlibModule.zlib_error(this.zst, err, "from inflateEnd()"); } } @@ -159,8 +146,7 @@ public Bytes flush(int length=ZlibModule.DEFAULTALLOC) private ZStream zst; - private static Bytes GetBytes(byte[] bytes, int index, int count) - { + private static Bytes GetBytes(byte[] bytes, int index, int count) { var res = new byte[count]; Array.Copy(bytes, index, res, 0, count); return Bytes.Make(res); diff --git a/Src/IronPython.Modules/zlib/ZlibModule.cs b/Src/IronPython.Modules/zlib/ZlibModule.cs index 208c61417..940739236 100644 --- a/Src/IronPython.Modules/zlib/ZlibModule.cs +++ b/Src/IronPython.Modules/zlib/ZlibModule.cs @@ -6,24 +6,23 @@ // using System; -using System.Collections.Generic; using System.Linq; -using System.Numerics; using System.Runtime.CompilerServices; + using ComponentAce.Compression.Libs.ZLib; + using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; + using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; [assembly: PythonModule("zlib", typeof(IronPython.Zlib.ZlibModule))] -namespace IronPython.Zlib -{ - public static class ZlibModule - { +namespace IronPython.Zlib { + public static class ZlibModule { public const string __doc__ = @"The functions in this module allow compression and decompression using the zlib library, which is based on GNU zip. @@ -73,8 +72,7 @@ public static class ZlibModule An optional starting value can be specified. The returned checksum is a signed integer.")] - public static int adler32([NotNone] IBufferProtocol data, long value=1L) - { + public static int adler32([NotNone] IBufferProtocol data, long value = 1L) { using var buffer = data.GetBuffer(); return (int)Adler32.GetAdler32Checksum(value, buffer.AsUnsafeArray() ?? buffer.ToArray(), 0, buffer.NumBytes()); } @@ -91,8 +89,7 @@ public static object crc32([NotNone] IBufferProtocol data, uint value = 0) Optional arg level is the compression level, in 1-9.")] public static Bytes compress([NotNone] IBufferProtocol data, - int level=Z_DEFAULT_COMPRESSION) - { + int level = Z_DEFAULT_COMPRESSION) { using var buffer = data.GetBuffer(); byte[] input = buffer.AsUnsafeArray() ?? buffer.ToArray(); byte[] output = new byte[input.Length + input.Length / 1000 + 12 + 1]; @@ -104,15 +101,14 @@ public static Bytes compress([NotNone] IBufferProtocol data, zst.avail_out = output.Length; int err = zst.DeflateInit(level); - switch(err) - { + switch (err) { case (Z_OK): break; - + case (Z_STREAM_ERROR): throw PythonOps.CreateThrowable(error, "Bad compression level"); - + default: zst.deflateEnd(); zlib_error(zst, err, "while compressing data"); @@ -121,16 +117,14 @@ public static Bytes compress([NotNone] IBufferProtocol data, err = zst.deflate(FlushStrategy.Z_FINISH); - if(err != Z_STREAM_END) - { + if (err != Z_STREAM_END) { zst.deflateEnd(); throw zlib_error(zst, err, "while compressing data"); } err = zst.deflateEnd(); - if(err == Z_OK) - { + if (err == Z_OK) { var res = new byte[(int)zst.total_out]; Array.Copy(output, res, res.Length); return Bytes.Make(res); @@ -143,12 +137,11 @@ public static Bytes compress([NotNone] IBufferProtocol data, Optional arg level is the compression level, in 1-9.")] public static Compress compressobj( - int level=Z_DEFAULT_COMPRESSION, - int method=DEFLATED, - int wbits=MAX_WBITS, - int memlevel=DEF_MEM_LEVEL, - int strategy=Z_DEFAULT_STRATEGY) - { + int level = Z_DEFAULT_COMPRESSION, + int method = DEFLATED, + int wbits = MAX_WBITS, + int memlevel = DEF_MEM_LEVEL, + int strategy = Z_DEFAULT_STRATEGY) { return new Compress(level, method, wbits, memlevel, strategy); } @@ -157,9 +150,8 @@ public static Compress compressobj( Optional arg wbits is the window buffer size. Optional arg bufsize is the initial output buffer size.")] public static Bytes decompress([NotNone] IBufferProtocol data, - int wbits=MAX_WBITS, - int bufsize=DEFAULTALLOC) - { + int wbits = MAX_WBITS, + int bufsize = DEFAULTALLOC) { using var buffer = data.GetBuffer(); var bytes = Decompress(buffer.AsUnsafeArray() ?? buffer.ToArray(), wbits, bufsize); return Bytes.Make(bytes); @@ -168,30 +160,24 @@ public static Bytes decompress([NotNone] IBufferProtocol data, [Documentation(@"decompressobj([wbits]) -- Return a decompressor object. Optional arg wbits is the window buffer size.")] - public static Decompress decompressobj(int wbits=MAX_WBITS) - { + public static Decompress decompressobj(int wbits = MAX_WBITS) { return new Decompress(wbits); } [SpecialName] - public static void PerformModuleReload(PythonContext context, PythonDictionary dict) - { + public static void PerformModuleReload(PythonContext context, PythonDictionary dict) { error = context.EnsureModuleException("zlib.error", PythonExceptions.Exception, dict, "error", "zlib"); } public static PythonType error; - internal static Exception MakeError(params object[] args) - { + internal static Exception MakeError(params object[] args) { return PythonOps.CreateThrowable(error, args); } - internal static Exception zlib_error(ZStream zst, int err, string msg) - { + internal static Exception zlib_error(ZStream zst, int err, string msg) { string zmsg = zst.msg; - if(zmsg == null) - { - switch(err) - { + if (zmsg == null) { + switch (err) { case Z_BUF_ERROR: zmsg = "incomplete or truncated stream"; break; @@ -204,15 +190,14 @@ internal static Exception zlib_error(ZStream zst, int err, string msg) } } - if(zmsg == null) + if (zmsg == null) return MakeError(string.Format("Error {0} {1}", err, msg)); else return MakeError(string.Format("Error {0} {1}: {2}", err, msg, zmsg)); } [PythonHidden] - internal static byte[] Decompress(byte[] input, int wbits=MAX_WBITS, int bufsize=DEFAULTALLOC) - { + internal static byte[] Decompress(byte[] input, int wbits = MAX_WBITS, int bufsize = DEFAULTALLOC) { byte[] outputBuffer = new byte[bufsize]; byte[] output = new byte[bufsize]; int outputOffset = 0; @@ -224,26 +209,20 @@ internal static byte[] Decompress(byte[] input, int wbits=MAX_WBITS, int bufsize zst.avail_out = outputBuffer.Length; int err = zst.inflateInit(wbits); - if(err != Z_OK) - { + if (err != Z_OK) { zst.inflateEnd(); throw zlib_error(zst, err, "while preparing to decompress data"); } - do - { + do { err = zst.inflate(FlushStrategy.Z_FINISH); - if(err != Z_STREAM_END) - { - if(err == Z_BUF_ERROR && zst.avail_out > 0) - { + if (err != Z_STREAM_END) { + if (err == Z_BUF_ERROR && zst.avail_out > 0) { zst.inflateEnd(); throw zlib_error(zst, err, "while decompressing data"); - } - else if(err == Z_OK || (err == Z_BUF_ERROR && zst.avail_out == 0)) - { + } else if (err == Z_OK || (err == Z_BUF_ERROR && zst.avail_out == 0)) { // copy to the output and reset the buffer - if(outputOffset + outputBuffer.Length > output.Length) + if (outputOffset + outputBuffer.Length > output.Length) Array.Resize(ref output, output.Length * 2); Array.Copy(outputBuffer, 0, output, outputOffset, outputBuffer.Length); @@ -252,23 +231,20 @@ internal static byte[] Decompress(byte[] input, int wbits=MAX_WBITS, int bufsize zst.next_out = outputBuffer; zst.avail_out = outputBuffer.Length; zst.next_out_index = 0; - } - else - { + } else { zst.inflateEnd(); throw zlib_error(zst, err, "while decompressing data"); } } - } while(err != Z_STREAM_END); + } while (err != Z_STREAM_END); err = zst.inflateEnd(); - if(err != Z_OK) - { + if (err != Z_OK) { throw zlib_error(zst, err, "while finishing data decompression"); } - if(outputOffset + outputBuffer.Length - zst.avail_out > output.Length) + if (outputOffset + outputBuffer.Length - zst.avail_out > output.Length) Array.Resize(ref output, output.Length * 2); Array.Copy(outputBuffer, 0, output, outputOffset, outputBuffer.Length - zst.avail_out); diff --git a/Src/IronPython.Modules/zlib/zlib.net/Adler32.cs b/Src/IronPython.Modules/zlib/zlib.net/Adler32.cs index aa3f973b9..827b0f019 100644 --- a/Src/IronPython.Modules/zlib/zlib.net/Adler32.cs +++ b/Src/IronPython.Modules/zlib/zlib.net/Adler32.cs @@ -44,70 +44,60 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * and contributors of zlib. */ -using System; - -namespace ComponentAce.Compression.Libs.ZLib -{ +namespace ComponentAce.Compression.Libs.ZLib { /// /// This class represents adler32 checksum algorithm. /// - public static class Adler32 - { - // largest prime smaller than 65536 - private const int BASE = 65521; - // NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 - private const int NMAX = 5552; - + public static class Adler32 { + // largest prime smaller than 65536 + private const int BASE = 65521; + // NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 + private const int NMAX = 5552; + /// /// This static method returns adler32 checksum of the buffer data /// - public static long GetAdler32Checksum(long adler, byte[] buf, int index, int len) - { - if (buf == null) - { - return 1L; - } - - long s1 = adler & 0xffff; - long s2 = (adler >> 16) & 0xffff; - int k; - - while (len > 0) - { - k = len < NMAX?len:NMAX; - len -= k; - while (k >= 16) - { - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - k -= 16; - } - if (k != 0) - { - do - { - s1 += (buf[index++] & 0xff); s2 += s1; - } - while (--k != 0); - } - s1 %= BASE; - s2 %= BASE; - } - return (s2 << 16) | s1; - } - } + public static long GetAdler32Checksum(long adler, byte[] buf, int index, int len) { + if (buf == null) { + return 1L; + } + + long s1 = adler & 0xffff; + long s2 = (adler >> 16) & 0xffff; + int k; + + while (len > 0) { + k = len < NMAX ? len : NMAX; + len -= k; + while (k >= 16) { + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + k -= 16; + } + if (k != 0) { + do { + s1 += (buf[index++] & 0xff); s2 += s1; + } + while (--k != 0); + } + s1 %= BASE; + s2 %= BASE; + } + return (s2 << 16) | s1; + } + } } \ No newline at end of file diff --git a/Src/IronPython.Modules/zlib/zlib.net/Deflate.cs b/Src/IronPython.Modules/zlib/zlib.net/Deflate.cs index 59ab2d132..02f124f20 100644 --- a/Src/IronPython.Modules/zlib/zlib.net/Deflate.cs +++ b/Src/IronPython.Modules/zlib/zlib.net/Deflate.cs @@ -44,22 +44,19 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using System; -namespace ComponentAce.Compression.Libs.ZLib -{ +namespace ComponentAce.Compression.Libs.ZLib { /// /// Implementation of the Deflate compression algorithm. /// - public sealed class Deflate - { + public sealed class Deflate { #region Nested class /// /// Deflate algorithm configuration parameters class /// - internal class Config - { + internal class Config { /// /// reduce lazy search above this match length /// @@ -78,12 +75,11 @@ internal class Config internal int max_chain; internal int func; - + /// /// Constructor which initializes class inner fields /// - internal Config(int good_length, int max_lazy, int nice_length, int max_chain, int func) - { + internal Config(int good_length, int max_lazy, int nice_length, int max_chain, int func) { this.good_length = good_length; this.max_lazy = max_lazy; this.nice_length = nice_length; @@ -105,7 +101,7 @@ internal Config(int good_length, int max_lazy, int nice_length, int max_chain, i /// Defalult compression method /// public const int Z_DEFAULT_COMPRESSION = -1; - + /// /// Default memory level /// @@ -115,7 +111,7 @@ internal Config(int good_length, int max_lazy, int nice_length, int max_chain, i private const int STORED = 0; private const int FAST = 1; private const int SLOW = 2; - + /// /// Deflate class congiration table /// @@ -257,7 +253,7 @@ internal Config(int good_length, int max_lazy, int nice_length, int max_chain, i /// /// LZ77 Window size (32K by default) /// - private int w_size; + private int w_size; /// /// log2(w_size) (8..16) @@ -387,7 +383,7 @@ internal Config(int good_length, int max_lazy, int nice_length, int max_chain, i /// favor or force Huffman coding /// private CompressionStrategy strategy; - + /// /// Use a faster search when the previous match is longer than this /// @@ -407,7 +403,7 @@ internal Config(int good_length, int max_lazy, int nice_length, int max_chain, i /// distance tree /// private short[] dyn_dtree; - + /// /// Huffman tree for bit lengths /// @@ -421,7 +417,7 @@ internal Config(int good_length, int max_lazy, int nice_length, int max_chain, i /// /// desc for distance tree /// - private Tree d_desc = new Tree(); + private Tree d_desc = new Tree(); /// /// desc for bit length tree @@ -535,8 +531,7 @@ internal Config(int good_length, int max_lazy, int nice_length, int max_chain, i /// /// Default constructor /// - internal Deflate() - { + internal Deflate() { dyn_ltree = new short[HEAP_SIZE * 2]; dyn_dtree = new short[(2 * D_CODES + 1) * 2]; // distance tree bl_tree = new short[(2 * BL_CODES + 1) * 2]; // Huffman tree for bit lengths @@ -545,8 +540,7 @@ internal Deflate() /// /// Initialization /// - private void lm_init() - { + private void lm_init() { window_size = 2 * w_size; Array.Clear(head, 0, hash_size); @@ -568,8 +562,7 @@ private void lm_init() /// /// Initialize the tree data structures for a new zlib stream. /// - private void tr_init() - { + private void tr_init() { l_desc.DynTree = dyn_ltree; l_desc.StatDesc = StaticTree.static_l_desc; @@ -591,8 +584,7 @@ private void tr_init() /// /// Initializes block /// - private void init_block() - { + private void init_block() { // Initialize the trees. for (int i = 0; i < L_CODES; i++) dyn_ltree[i * 2] = 0; @@ -612,15 +604,12 @@ private void init_block() /// when the heap property is re-established (each father smaller than its /// two sons). /// - internal void pqdownheap(short[] tree, int k) - { + internal void pqdownheap(short[] tree, int k) { int v = heap[k]; int j = k << 1; // left son of k - while (j <= heap_len) - { + while (j <= heap_len) { // Set j to the smallest of the two sons: - if (j < heap_len && smaller(tree, heap[j + 1], heap[j], depth)) - { + if (j < heap_len && smaller(tree, heap[j + 1], heap[j], depth)) { j++; } // Exit if v is smaller than both sons @@ -635,8 +624,7 @@ internal void pqdownheap(short[] tree, int k) heap[k] = v; } - internal static bool smaller(short[] tree, int n, int m, byte[] depth) - { + internal static bool smaller(short[] tree, int n, int m, byte[] depth) { return (tree[n * 2] < tree[m * 2] || (tree[n * 2] == tree[m * 2] && depth[n] <= depth[m])); } @@ -644,8 +632,7 @@ internal static bool smaller(short[] tree, int n, int m, byte[] depth) /// Scan a literal or distance tree to determine the frequencies of the codes /// in the bit length tree. ///
- private void scan_tree(short[] tree, int max_code) - { + private void scan_tree(short[] tree, int max_code) { int n; // iterates over all tree elements int prevlen = -1; // last emitted length int curlen; // length of current code @@ -654,49 +641,34 @@ private void scan_tree(short[] tree, int max_code) int max_count = 7; // max repeat count int min_count = 4; // min repeat count - if (nextlen == 0) - { + if (nextlen == 0) { max_count = 138; min_count = 3; } tree[(max_code + 1) * 2 + 1] = (short)ZLibUtil.Identity(0xffff); // guard - for (n = 0; n <= max_code; n++) - { + for (n = 0; n <= max_code; n++) { curlen = nextlen; nextlen = tree[(n + 1) * 2 + 1]; - if (++count < max_count && curlen == nextlen) - { + if (++count < max_count && curlen == nextlen) { continue; } - if (count < min_count) - { + if (count < min_count) { bl_tree[curlen * 2] = (short)(bl_tree[curlen * 2] + count); - } - else if (curlen != 0) - { + } else if (curlen != 0) { if (curlen != prevlen) bl_tree[curlen * 2]++; bl_tree[REP_3_6 * 2]++; - } - else if (count <= 10) - { + } else if (count <= 10) { bl_tree[REPZ_3_10 * 2]++; - } - else - { + } else { bl_tree[REPZ_11_138 * 2]++; } count = 0; prevlen = curlen; - if (nextlen == 0) - { + if (nextlen == 0) { max_count = 138; min_count = 3; - } - else if (curlen == nextlen) - { + } else if (curlen == nextlen) { max_count = 6; min_count = 3; - } - else - { + } else { max_count = 7; min_count = 4; } } @@ -706,8 +678,7 @@ private void scan_tree(short[] tree, int max_code) /// Construct the Huffman tree for the bit lengths and return the index in /// bl_order of the last bit length code to send. ///
- private int build_bl_tree() - { + private int build_bl_tree() { int max_blindex; // index of last bit length code of non zero freq // Determine the bit length frequencies for literal and distance trees @@ -722,8 +693,7 @@ private int build_bl_tree() // Determine the number of bit length codes to send. The pkzip format // requires that at least 4 bit length codes be sent. (appnote.txt says // 3 but the actual value used is 4.) - for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) - { + for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) { if (bl_tree[ZLibUtil.bl_order[max_blindex] * 2 + 1] != 0) break; } @@ -738,15 +708,13 @@ private int build_bl_tree() /// lengths of the bit length codes, the literal tree and the distance tree. /// IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. /// - private void send_all_trees(int lcodes, int dcodes, int blcodes) - { + private void send_all_trees(int lcodes, int dcodes, int blcodes) { int rank; // index in bl_order send_bits(lcodes - 257, 5); // not +255 as stated in appnote.txt send_bits(dcodes - 1, 5); send_bits(blcodes - 4, 4); // not -3 as stated in appnote.txt - for (rank = 0; rank < blcodes; rank++) - { + for (rank = 0; rank < blcodes; rank++) { send_bits(bl_tree[ZLibUtil.bl_order[rank] * 2 + 1], 3); } send_tree(dyn_ltree, lcodes - 1); // literal tree @@ -757,8 +725,7 @@ private void send_all_trees(int lcodes, int dcodes, int blcodes) /// Send a literal or distance tree in compressed form, using the codes in /// bl_tree. /// - private void send_tree(short[] tree, int max_code) - { + private void send_tree(short[] tree, int max_code) { int n; // iterates over all tree elements int prevlen = -1; // last emitted length int curlen; // length of current code @@ -767,56 +734,38 @@ private void send_tree(short[] tree, int max_code) int max_count = 7; // max repeat count int min_count = 4; // min repeat count - if (nextlen == 0) - { + if (nextlen == 0) { max_count = 138; min_count = 3; } - for (n = 0; n <= max_code; n++) - { + for (n = 0; n <= max_code; n++) { curlen = nextlen; nextlen = tree[(n + 1) * 2 + 1]; - if (++count < max_count && curlen == nextlen) - { + if (++count < max_count && curlen == nextlen) { continue; - } - else if (count < min_count) - { - do - { + } else if (count < min_count) { + do { send_code(curlen, bl_tree); } while (--count != 0); - } - else if (curlen != 0) - { - if (curlen != prevlen) - { + } else if (curlen != 0) { + if (curlen != prevlen) { send_code(curlen, bl_tree); count--; } send_code(REP_3_6, bl_tree); send_bits(count - 3, 2); - } - else if (count <= 10) - { + } else if (count <= 10) { send_code(REPZ_3_10, bl_tree); send_bits(count - 3, 3); - } - else - { + } else { send_code(REPZ_11_138, bl_tree); send_bits(count - 11, 7); } count = 0; prevlen = curlen; - if (nextlen == 0) - { + if (nextlen == 0) { max_count = 138; min_count = 3; - } - else if (curlen == nextlen) - { + } else if (curlen == nextlen) { max_count = 6; min_count = 3; - } - else - { + } else { max_count = 7; min_count = 4; } } @@ -826,8 +775,7 @@ private void send_tree(short[] tree, int max_code) /// Output a byte on the stream. /// IN assertion: there is enough room in Pending_buf. /// - private void put_byte(byte[] p, int start, int len) - { + private void put_byte(byte[] p, int start, int len) { Array.Copy(p, start, Pending_buf, Pending, len); Pending += len; } @@ -835,42 +783,34 @@ private void put_byte(byte[] p, int start, int len) /// /// Adds a byte to the buffer /// - private void put_byte(byte c) - { + private void put_byte(byte c) { Pending_buf[Pending++] = c; } - private void put_short(int w) - { + private void put_short(int w) { put_byte((byte)(w)); put_byte((byte)(ZLibUtil.URShift(w, 8))); } - private void putShortMSB(int b) - { + private void putShortMSB(int b) { put_byte((byte)(b >> 8)); put_byte((byte)(b)); } - private void send_code(int c, short[] tree) - { + private void send_code(int c, short[] tree) { send_bits((tree[c * 2] & 0xffff), (tree[c * 2 + 1] & 0xffff)); } - private void send_bits(int value_Renamed, int length) - { + private void send_bits(int value_Renamed, int length) { int len = length; - if (bi_valid > (int)Buf_size - len) - { + if (bi_valid > (int)Buf_size - len) { int val = value_Renamed; // bi_buf |= (val << bi_valid); bi_buf = (short)((ushort)bi_buf | (ushort)(((val << bi_valid) & 0xffff))); put_short(bi_buf); bi_buf = (short)(ZLibUtil.URShift(val, (Buf_size - bi_valid))); bi_valid += len - Buf_size; - } - else - { + } else { // bi_buf |= (value) << bi_valid; bi_buf = (short)((ushort)bi_buf | (ushort)((((value_Renamed) << bi_valid) & 0xffff))); bi_valid += len; @@ -888,8 +828,7 @@ private void send_bits(int value_Renamed, int length) /// To simplify the code, we assume the worst case of last real code encoded /// on one bit only. /// - private void _tr_align() - { + private void _tr_align() { send_bits(STATIC_TREES << 1, 3); send_code(END_BLOCK, StaticTree.static_ltree); @@ -899,8 +838,7 @@ private void _tr_align() // (10 - bi_valid) bits. The lookahead for the last real code (before // the EOB of the previous block) was thus at least one plus the length // of the EOB plus what we have just sent of the empty static block. - if (1 + last_eob_len + 10 - bi_valid < 9) - { + if (1 + last_eob_len + 10 - bi_valid < 9) { send_bits(STATIC_TREES << 1, 3); send_code(END_BLOCK, StaticTree.static_ltree); bi_flush(); @@ -912,21 +850,17 @@ private void _tr_align() /// Save the match info and tally the frequency counts. Return true if /// the current block must be flushed. /// - private bool _tr_tally(int dist, int lc) - { + private bool _tr_tally(int dist, int lc) { Pending_buf[d_buf + last_lit * 2] = (byte)(ZLibUtil.URShift(dist, 8)); Pending_buf[d_buf + last_lit * 2 + 1] = (byte)dist; Pending_buf[l_buf + last_lit] = (byte)lc; last_lit++; - if (dist == 0) - { + if (dist == 0) { // lc is the unmatched char dyn_ltree[lc * 2]++; - } - else - { + } else { matches++; // Here, lc is the match length - MIN_MATCH dist--; // dist = match distance - 1 @@ -934,14 +868,12 @@ private bool _tr_tally(int dist, int lc) dyn_dtree[Tree.d_code(dist) * 2]++; } - if ((last_lit & 0x1fff) == 0 && level > 2) - { + if ((last_lit & 0x1fff) == 0 && level > 2) { // Compute an upper bound for the compressed length int out_length = last_lit * 8; int in_length = strstart - block_start; int dcode; - for (dcode = 0; dcode < D_CODES; dcode++) - { + for (dcode = 0; dcode < D_CODES; dcode++) { out_length = (int)(out_length + (int)dyn_dtree[dcode * 2] * (5L + ZLibUtil.extra_dbits[dcode])); } out_length = ZLibUtil.URShift(out_length, 3); @@ -958,34 +890,27 @@ private bool _tr_tally(int dist, int lc) /// /// Send the block data compressed using the given Huffman trees /// - private void compress_block(short[] ltree, short[] dtree) - { + private void compress_block(short[] ltree, short[] dtree) { int dist; // distance of matched string int lc; // match length or unmatched char (if dist == 0) int lx = 0; // running index in l_buf int code; // the code to send int extra; // number of extra bits to send - if (last_lit != 0) - { - do - { + if (last_lit != 0) { + do { dist = ((Pending_buf[d_buf + lx * 2] << 8) & 0xff00) | (Pending_buf[d_buf + lx * 2 + 1] & 0xff); lc = (Pending_buf[l_buf + lx]) & 0xff; lx++; - if (dist == 0) - { + if (dist == 0) { send_code(lc, ltree); // send a literal byte - } - else - { + } else { // Here, lc is the match length - MIN_MATCH code = ZLibUtil._length_code[lc]; send_code(code + LITERALS + 1, ltree); // send the length code extra = ZLibUtil.extra_lbits[code]; - if (extra != 0) - { + if (extra != 0) { lc -= ZLibUtil.base_length[code]; send_bits(lc, extra); // send the extra length bits } @@ -994,8 +919,7 @@ private void compress_block(short[] ltree, short[] dtree) send_code(code, dtree); // send the distance code extra = ZLibUtil.extra_dbits[code]; - if (extra != 0) - { + if (extra != 0) { dist -= ZLibUtil.base_dist[code]; send_bits(dist, extra); // send the extra distance bits } @@ -1016,21 +940,17 @@ private void compress_block(short[] ltree, short[] dtree) /// IN assertion: the fields freq of dyn_ltree are set and the total of all /// frequencies does not exceed 64K (to fit in an int on 16 bit machines). /// - private void set_data_type() - { + private void set_data_type() { int n = 0; int ascii_freq = 0; int bin_freq = 0; - while (n < 7) - { + while (n < 7) { bin_freq += dyn_ltree[n * 2]; n++; } - while (n < 128) - { + while (n < 128) { ascii_freq += dyn_ltree[n * 2]; n++; } - while (n < LITERALS) - { + while (n < LITERALS) { bin_freq += dyn_ltree[n * 2]; n++; } data_type = (bin_freq > (ZLibUtil.URShift(ascii_freq, 2)) ? BlockType.Z_BINARY : BlockType.Z_ASCII); @@ -1039,16 +959,12 @@ private void set_data_type() /// /// Flush the bit buffer, keeping at most 7 bits in it. /// - private void bi_flush() - { - if (bi_valid == 16) - { + private void bi_flush() { + if (bi_valid == 16) { put_short(bi_buf); bi_buf = 0; bi_valid = 0; - } - else if (bi_valid >= 8) - { + } else if (bi_valid >= 8) { put_byte((byte)bi_buf); bi_buf = (short)(ZLibUtil.URShift(bi_buf, 8)); bi_valid -= 8; @@ -1058,14 +974,10 @@ private void bi_flush() /// /// Flush the bit buffer and align the output on a byte boundary /// - private void bi_windup() - { - if (bi_valid > 8) - { + private void bi_windup() { + if (bi_valid > 8) { put_short(bi_buf); - } - else if (bi_valid > 0) - { + } else if (bi_valid > 0) { put_byte((byte)bi_buf); } bi_buf = 0; @@ -1076,14 +988,12 @@ private void bi_windup() /// Copy a stored block, storing first the length and its /// one's complement if requested. /// - private void copy_block(int buf, int len, bool header) - { + private void copy_block(int buf, int len, bool header) { bi_windup(); // align on byte boundary last_eob_len = 8; // enough lookahead for inflate - if (header) - { + if (header) { put_short((short)len); put_short((short)~len); } @@ -1094,8 +1004,7 @@ private void copy_block(int buf, int len, bool header) /// /// Flushes block /// - private void flush_block_only(bool eof) - { + private void flush_block_only(bool eof) { _tr_flush_block(block_start >= 0 ? block_start : -1, strstart - block_start, eof); block_start = strstart; strm.FlushPending(); @@ -1110,25 +1019,21 @@ private void flush_block_only(bool eof) /// NOTE: this function should be optimized to avoid extra copying from /// Window to Pending_buf. /// - private int deflate_stored(int flush) - { + private int deflate_stored(int flush) { // Stored blocks are limited to 0xffff bytes, Pending_buf is limited // to pending_buf_size, and each stored block has a 5 byte header: int max_block_size = 0xffff; int max_start; - if (max_block_size > pending_buf_size - 5) - { + if (max_block_size > pending_buf_size - 5) { max_block_size = pending_buf_size - 5; } // Copy as much as possible from input to output: - while (true) - { + while (true) { // Fill the Window as much as possible: - if (lookahead <= 1) - { + if (lookahead <= 1) { fill_window(); if (lookahead == 0 && flush == (int)FlushStrategy.Z_NO_FLUSH) return NeedMore; @@ -1141,8 +1046,7 @@ private int deflate_stored(int flush) // Emit a stored block if Pending_buf will be full: max_start = block_start + max_block_size; - if (strstart == 0 || strstart >= max_start) - { + if (strstart == 0 || strstart >= max_start) { // strstart == 0 is possible when wraparound on 16-bit machine lookahead = (int)(strstart - max_start); strstart = (int)max_start; @@ -1154,8 +1058,7 @@ private int deflate_stored(int flush) // Flush if we may have to slide, otherwise block_start may become // negative and the data will be gone: - if (strstart - block_start >= w_size - MIN_LOOKAHEAD) - { + if (strstart - block_start >= w_size - MIN_LOOKAHEAD) { flush_block_only(false); if (strm.avail_out == 0) return NeedMore; @@ -1172,8 +1075,7 @@ private int deflate_stored(int flush) /// /// Send a stored block /// - private void _tr_stored_block(int buf, int stored_len, bool eof) - { + private void _tr_stored_block(int buf, int stored_len, bool eof) { send_bits((STORED_BLOCK << 1) + (eof ? 1 : 0), 3); // send block type copy_block(buf, stored_len, true); // with header } @@ -1182,14 +1084,12 @@ private void _tr_stored_block(int buf, int stored_len, bool eof) /// Determine the best encoding for the current block: dynamic trees, static /// trees or store, and output the encoded block to the zip file. /// - private void _tr_flush_block(int buf, int stored_len, bool eof) - { + private void _tr_flush_block(int buf, int stored_len, bool eof) { int opt_lenb, static_lenb; // opt_len and static_len in bytes int max_blindex = 0; // index of last bit length code of non zero freq // Build the Huffman trees unless a stored block is forced - if (level > 0) - { + if (level > 0) { // Check if the file is ascii or binary if (data_type == BlockType.Z_UNKNOWN) set_data_type(); @@ -1212,14 +1112,11 @@ private void _tr_flush_block(int buf, int stored_len, bool eof) if (static_lenb <= opt_lenb) opt_lenb = static_lenb; - } - else - { + } else { opt_lenb = static_lenb = stored_len + 5; // force a stored block } - if (stored_len + 4 <= opt_lenb && buf != -1) - { + if (stored_len + 4 <= opt_lenb && buf != -1) { // 4: two words for the lengths // The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. // Otherwise we can't have processed more than WSIZE input bytes since @@ -1227,14 +1124,10 @@ private void _tr_flush_block(int buf, int stored_len, bool eof) // successful. If LIT_BUFSIZE <= WSIZE, it is never too late to // transform a block into a stored block. _tr_stored_block(buf, stored_len, eof); - } - else if (static_lenb == opt_lenb) - { + } else if (static_lenb == opt_lenb) { send_bits((STATIC_TREES << 1) + (eof ? 1 : 0), 3); compress_block(StaticTree.static_ltree, StaticTree.static_dtree); - } - else - { + } else { send_bits((DYN_TREES << 1) + (eof ? 1 : 0), 3); send_all_trees(l_desc.MaxCode + 1, d_desc.MaxCode + 1, max_blindex + 1); compress_block(dyn_ltree, dyn_dtree); @@ -1245,8 +1138,7 @@ private void _tr_flush_block(int buf, int stored_len, bool eof) init_block(); - if (eof) - { + if (eof) { bi_windup(); } } @@ -1261,32 +1153,25 @@ private void _tr_flush_block(int buf, int stored_len, bool eof) /// performed for at least two bytes (required for the zip translate_eol /// option -- not supported here). /// - private void fill_window() - { + private void fill_window() { int n, m; int p; int more; // Amount of free space at the End of the Window. - do - { + do { more = (window_size - lookahead - strstart); // Deal with !@#$% 64K limit: - if (more == 0 && strstart == 0 && lookahead == 0) - { + if (more == 0 && strstart == 0 && lookahead == 0) { more = w_size; - } - else if (more == -1) - { + } else if (more == -1) { // Very unlikely, but possible on 16 bit machine if strstart == 0 // and lookahead == 1 (input done one byte at time) more--; // If the Window is almost full and there is insufficient lookahead, // move the upper half to the lower one to make room in the upper half. - } - else if (strstart >= w_size + w_size - MIN_LOOKAHEAD) - { + } else if (strstart >= w_size + w_size - MIN_LOOKAHEAD) { Array.Copy(window, w_size, window, 0, w_size); match_start -= w_size; strstart -= w_size; // we now have strstart >= MAX_DIST @@ -1300,8 +1185,7 @@ private void fill_window() n = hash_size; p = n; - do - { + do { m = (head[--p] & 0xffff); head[p] = (short)(m >= w_size ? (m - w_size) : 0); //head[p] = (m >= w_size?(short) (m - w_size):0); @@ -1310,8 +1194,7 @@ private void fill_window() n = w_size; p = n; - do - { + do { m = (prev[--p] & 0xffff); prev[p] = (short)(m >= w_size ? (m - w_size) : 0); //prev[p] = (m >= w_size?(short) (m - w_size):0); @@ -1340,8 +1223,7 @@ private void fill_window() lookahead += n; // Initialize the hash value now that we have some input: - if (lookahead >= MIN_MATCH) - { + if (lookahead >= MIN_MATCH) { ins_h = window[strstart] & 0xff; ins_h = (((ins_h) << hash_shift) ^ (window[strstart + 1] & 0xff)) & hash_mask; } @@ -1358,23 +1240,19 @@ private void fill_window() /// new strings in the dictionary only for unmatched strings or for short /// matches. It is used only for the fast compression options. /// - private int deflate_fast(int flush) - { + private int deflate_fast(int flush) { // short hash_head = 0; // head of the hash chain int hash_head = 0; // head of the hash chain bool bflush; // set if current block must be flushed - while (true) - { + while (true) { // Make sure that we always have enough lookahead, except // at the End of the input file. We need MAX_MATCH bytes // for the next match, plus MIN_MATCH bytes to insert the // string following the next match. - if (lookahead < MIN_LOOKAHEAD) - { + if (lookahead < MIN_LOOKAHEAD) { fill_window(); - if (lookahead < MIN_LOOKAHEAD && flush == (int)FlushStrategy.Z_NO_FLUSH) - { + if (lookahead < MIN_LOOKAHEAD && flush == (int)FlushStrategy.Z_NO_FLUSH) { return NeedMore; } if (lookahead == 0) @@ -1383,8 +1261,7 @@ private int deflate_fast(int flush) // Insert the string Window[strstart .. strstart+2] in the // dictionary, and set hash_head to the head of the hash chain: - if (lookahead >= MIN_MATCH) - { + if (lookahead >= MIN_MATCH) { ins_h = (((ins_h) << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; // prev[strstart&w_mask]=hash_head=head[ins_h]; @@ -1396,19 +1273,16 @@ private int deflate_fast(int flush) // Find the longest match, discarding those <= prev_length. // At this point we have always match_length < MIN_MATCH - if (hash_head != 0L && ((strstart - hash_head) & 0xffff) <= w_size - MIN_LOOKAHEAD) - { + if (hash_head != 0L && ((strstart - hash_head) & 0xffff) <= w_size - MIN_LOOKAHEAD) { // To simplify the code, we prevent matches with the string // of Window index 0 (in particular we have to avoid a match // of the string with itself at the start of the input file). - if (strategy != CompressionStrategy.Z_HUFFMAN_ONLY) - { + if (strategy != CompressionStrategy.Z_HUFFMAN_ONLY) { match_length = longest_match(hash_head); } // longest_match() sets match_start } - if (match_length >= MIN_MATCH) - { + if (match_length >= MIN_MATCH) { // check_match(strstart, match_start, match_length); bflush = _tr_tally(strstart - match_start, match_length - MIN_MATCH); @@ -1417,11 +1291,9 @@ private int deflate_fast(int flush) // Insert new strings in the hash table only if the match length // is not too large. This saves time but degrades compression. - if (match_length <= max_lazy_match && lookahead >= MIN_MATCH) - { + if (match_length <= max_lazy_match && lookahead >= MIN_MATCH) { match_length--; // string at strstart already in hash table - do - { + do { strstart++; ins_h = ((ins_h << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; @@ -1435,9 +1307,7 @@ private int deflate_fast(int flush) } while (--match_length != 0); strstart++; - } - else - { + } else { strstart += match_length; match_length = 0; ins_h = window[strstart] & 0xff; @@ -1446,17 +1316,14 @@ private int deflate_fast(int flush) // If lookahead < MIN_MATCH, ins_h is garbage, but it does not // matter since it will be recomputed at next deflate call. } - } - else - { + } else { // No match, output a literal byte bflush = _tr_tally(0, window[strstart] & 0xff); lookahead--; strstart++; } - if (bflush) - { + if (bflush) { flush_block_only(false); if (strm.avail_out == 0) @@ -1465,8 +1332,7 @@ private int deflate_fast(int flush) } flush_block_only(flush == (int)FlushStrategy.Z_FINISH); - if (strm.avail_out == 0) - { + if (strm.avail_out == 0) { if (flush == (int)FlushStrategy.Z_FINISH) return FinishStarted; else @@ -1480,25 +1346,21 @@ private int deflate_fast(int flush) /// evaluation for matches: a match is finally adopted only if there is /// no better match at the next Window position. /// - private int deflate_slow(int flush) - { + private int deflate_slow(int flush) { // short hash_head = 0; // head of hash chain int hash_head = 0; // head of hash chain bool bflush; // set if current block must be flushed // Process the input block. - while (true) - { + while (true) { // Make sure that we always have enough lookahead, except // at the End of the input file. We need MAX_MATCH bytes // for the next match, plus MIN_MATCH bytes to insert the // string following the next match. - if (lookahead < MIN_LOOKAHEAD) - { + if (lookahead < MIN_LOOKAHEAD) { fill_window(); - if (lookahead < MIN_LOOKAHEAD && flush == (int)FlushStrategy.Z_NO_FLUSH) - { + if (lookahead < MIN_LOOKAHEAD && flush == (int)FlushStrategy.Z_NO_FLUSH) { return NeedMore; } if (lookahead == 0) @@ -1508,8 +1370,7 @@ private int deflate_slow(int flush) // Insert the string Window[strstart .. strstart+2] in the // dictionary, and set hash_head to the head of the hash chain: - if (lookahead >= MIN_MATCH) - { + if (lookahead >= MIN_MATCH) { ins_h = (((ins_h) << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; // prev[strstart&w_mask]=hash_head=head[ins_h]; hash_head = (head[ins_h] & 0xffff); @@ -1521,20 +1382,17 @@ private int deflate_slow(int flush) prev_length = match_length; prev_match = match_start; match_length = MIN_MATCH - 1; - if (hash_head != 0 && prev_length < max_lazy_match && ((strstart - hash_head) & 0xffff) <= w_size - MIN_LOOKAHEAD) - { + if (hash_head != 0 && prev_length < max_lazy_match && ((strstart - hash_head) & 0xffff) <= w_size - MIN_LOOKAHEAD) { // To simplify the code, we prevent matches with the string // of Window index 0 (in particular we have to avoid a match // of the string with itself at the start of the input file). - if (strategy != CompressionStrategy.Z_HUFFMAN_ONLY) - { + if (strategy != CompressionStrategy.Z_HUFFMAN_ONLY) { match_length = longest_match(hash_head); } // longest_match() sets match_start - if (match_length <= 5 && (strategy == CompressionStrategy.Z_FILTERED || (match_length == MIN_MATCH && strstart - match_start > 4096))) - { + if (match_length <= 5 && (strategy == CompressionStrategy.Z_FILTERED || (match_length == MIN_MATCH && strstart - match_start > 4096))) { // If prev_match is also MIN_MATCH, match_start is garbage // but we will ignore the current match anyway. @@ -1544,8 +1402,7 @@ private int deflate_slow(int flush) // If there was a match at the previous step and the current // match is not better, output the previous match: - if (prev_length >= MIN_MATCH && match_length <= prev_length) - { + if (prev_length >= MIN_MATCH && match_length <= prev_length) { int max_insert = strstart + lookahead - MIN_MATCH; // Do not insert strings in hash table beyond this. @@ -1559,10 +1416,8 @@ private int deflate_slow(int flush) // the hash table. lookahead -= (prev_length - 1); prev_length -= 2; - do - { - if (++strstart <= max_insert) - { + do { + if (++strstart <= max_insert) { ins_h = (((ins_h) << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; //prev[strstart&w_mask]=hash_head=head[ins_h]; hash_head = (head[ins_h] & 0xffff); @@ -1575,15 +1430,12 @@ private int deflate_slow(int flush) match_length = MIN_MATCH - 1; strstart++; - if (bflush) - { + if (bflush) { flush_block_only(false); if (strm.avail_out == 0) return NeedMore; } - } - else if (match_available != 0) - { + } else if (match_available != 0) { // If there was no match at the previous position, output a // single literal. If there was a match but the current match @@ -1591,17 +1443,14 @@ private int deflate_slow(int flush) bflush = _tr_tally(0, window[strstart - 1] & 0xff); - if (bflush) - { + if (bflush) { flush_block_only(false); } strstart++; lookahead--; if (strm.avail_out == 0) return NeedMore; - } - else - { + } else { // There is no previous match to compare with, wait for // the next step to decide. @@ -1611,15 +1460,13 @@ private int deflate_slow(int flush) } } - if (match_available != 0) - { + if (match_available != 0) { bflush = _tr_tally(0, window[strstart - 1] & 0xff); match_available = 0; } flush_block_only(flush == (int)FlushStrategy.Z_FINISH); - if (strm.avail_out == 0) - { + if (strm.avail_out == 0) { if (flush == (int)FlushStrategy.Z_FINISH) return FinishStarted; @@ -1632,8 +1479,7 @@ private int deflate_slow(int flush) /// /// Finds the longest matching data part /// - private int longest_match(int cur_match) - { + private int longest_match(int cur_match) { int chain_length = max_chain_length; // max hash chain length int scan = strstart; // current string int match; // matched string @@ -1655,8 +1501,7 @@ private int longest_match(int cur_match) // It is easy to get rid of this optimization if necessary. // Do not waste too much time if we already have a good match: - if (prev_length >= good_match) - { + if (prev_length >= good_match) { chain_length >>= 2; } @@ -1665,8 +1510,7 @@ private int longest_match(int cur_match) if (nice_match > lookahead) nice_match = lookahead; - do - { + do { match = cur_match; // Skip to next match if the match length cannot increase @@ -1683,16 +1527,14 @@ private int longest_match(int cur_match) // We check for insufficient lookahead only every 8th comparison; // the 256th check will be made at strstart+258. - do - { + do { } while (window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && scan < strend); len = MAX_MATCH - (int)(strend - scan); scan = strend - MAX_MATCH; - if (len > best_len) - { + if (len > best_len) { match_start = cur_match; best_len = len; if (len >= nice_match) @@ -1715,8 +1557,7 @@ private int longest_match(int cur_match) /// Compression level /// Window bits /// A result code - internal int DeflateInit(ZStream strm, int level, int bits) - { + internal int DeflateInit(ZStream strm, int level, int bits) { return DeflateInit2(strm, level, bits, DEF_MEM_LEVEL, CompressionStrategy.Z_DEFAULT_STRATEGY); } @@ -1726,8 +1567,7 @@ internal int DeflateInit(ZStream strm, int level, int bits) /// ZStream object /// Compression level /// Operation result result code - internal int DeflateInit(ZStream strm, int level) - { + internal int DeflateInit(ZStream strm, int level) { return DeflateInit(strm, level, ZLibUtil.MAX_WBITS); } @@ -1740,8 +1580,7 @@ internal int DeflateInit(ZStream strm, int level) /// Memory level /// Compression strategy /// Operation result code - internal int DeflateInit2(ZStream strm, int level, int windowBits, int memLevel, CompressionStrategy strategy) - { + internal int DeflateInit2(ZStream strm, int level, int windowBits, int memLevel, CompressionStrategy strategy) { int noheader = 0; strm.msg = null; @@ -1749,15 +1588,13 @@ internal int DeflateInit2(ZStream strm, int level, int windowBits, int memLevel, if (level == Z_DEFAULT_COMPRESSION) level = 6; - if (windowBits < 0) - { + if (windowBits < 0) { // undocumented feature: suppress zlib header noheader = 1; windowBits = -windowBits; } - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || windowBits < 9 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > CompressionStrategy.Z_HUFFMAN_ONLY) - { + if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || windowBits < 9 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > CompressionStrategy.Z_HUFFMAN_ONLY) { return (int)ZLibResultCode.Z_STREAM_ERROR; } @@ -1798,8 +1635,7 @@ internal int DeflateInit2(ZStream strm, int level, int windowBits, int memLevel, /// /// Resets the current state of deflate object /// - internal int deflateReset(ZStream strm) - { + internal int deflateReset(ZStream strm) { strm.total_in = strm.total_out = 0; strm.msg = null; // strm.Data_type = BlockType.Z_UNKNOWN; @@ -1807,8 +1643,7 @@ internal int deflateReset(ZStream strm) Pending = 0; Pending_out = 0; - if (NoHeader < 0) - { + if (NoHeader < 0) { NoHeader = 0; // was set to -1 by deflate(..., Z_FINISH); } status = (NoHeader != 0) ? DeflateState.BUSY_STATE : DeflateState.INIT_STATE; @@ -1825,10 +1660,8 @@ internal int deflateReset(ZStream strm) /// /// Finish compression with deflate algorithm /// - internal int deflateEnd() - { - if (status != DeflateState.INIT_STATE && status != DeflateState.BUSY_STATE && status != DeflateState.FINISH_STATE) - { + internal int deflateEnd() { + if (status != DeflateState.INIT_STATE && status != DeflateState.BUSY_STATE && status != DeflateState.FINISH_STATE) { return (int)ZLibResultCode.Z_STREAM_ERROR; } // Deallocate in reverse order of allocations: @@ -1843,27 +1676,22 @@ internal int deflateEnd() /// /// Sets deflate algorithm parameters /// - internal int deflateParams(ZStream strm, int level, CompressionStrategy strategy) - { + internal int deflateParams(ZStream strm, int level, CompressionStrategy strategy) { int err = (int)ZLibResultCode.Z_OK; - if (level == Z_DEFAULT_COMPRESSION) - { + if (level == Z_DEFAULT_COMPRESSION) { level = 6; } - if (level < 0 || level > 9 || strategy < 0 || strategy > CompressionStrategy.Z_HUFFMAN_ONLY) - { + if (level < 0 || level > 9 || strategy < 0 || strategy > CompressionStrategy.Z_HUFFMAN_ONLY) { return (int)ZLibResultCode.Z_STREAM_ERROR; } - if (config_table[this.level].func != config_table[level].func && strm.total_in != 0) - { + if (config_table[this.level].func != config_table[level].func && strm.total_in != 0) { // Flush the last buffer: err = strm.deflate(FlushStrategy.Z_PARTIAL_FLUSH); } - if (this.level != level) - { + if (this.level != level) { this.level = level; max_lazy_match = config_table[this.level].max_lazy; good_match = config_table[this.level].good_length; @@ -1877,8 +1705,7 @@ internal int deflateParams(ZStream strm, int level, CompressionStrategy strategy /// /// Sets deflate dictionary /// - internal int deflateSetDictionary(ZStream strm, byte[] dictionary, int dictLength) - { + internal int deflateSetDictionary(ZStream strm, byte[] dictionary, int dictLength) { int length = dictLength; int index = 0; @@ -1889,8 +1716,7 @@ internal int deflateSetDictionary(ZStream strm, byte[] dictionary, int dictLengt if (length < MIN_MATCH) return (int)ZLibResultCode.Z_OK; - if (length > w_size - MIN_LOOKAHEAD) - { + if (length > w_size - MIN_LOOKAHEAD) { length = w_size - MIN_LOOKAHEAD; index = dictLength - length; // use the tail of the dictionary } @@ -1905,8 +1731,7 @@ internal int deflateSetDictionary(ZStream strm, byte[] dictionary, int dictLengt ins_h = window[0] & 0xff; ins_h = (((ins_h) << hash_shift) ^ (window[1] & 0xff)) & hash_mask; - for (int n = 0; n <= length - MIN_MATCH; n++) - { + for (int n = 0; n <= length - MIN_MATCH; n++) { ins_h = (((ins_h) << hash_shift) ^ (window[(n) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; prev[n & w_mask] = head[ins_h]; head[ins_h] = (short)n; @@ -1917,22 +1742,18 @@ internal int deflateSetDictionary(ZStream strm, byte[] dictionary, int dictLengt /// /// Performs data compression with the deflate algorithm /// - internal int deflate(ZStream strm, FlushStrategy f) - { + internal int deflate(ZStream strm, FlushStrategy f) { int internalFlush = (int)f; - if (internalFlush > (int)FlushStrategy.Z_FINISH || internalFlush < 0) - { + if (internalFlush > (int)FlushStrategy.Z_FINISH || internalFlush < 0) { return (int)ZLibResultCode.Z_STREAM_ERROR; } - if (strm.next_out == null || (strm.next_in == null && strm.avail_in != 0) || (status == DeflateState.FINISH_STATE && internalFlush != (int)FlushStrategy.Z_FINISH)) - { + if (strm.next_out == null || (strm.next_in == null && strm.avail_in != 0) || (status == DeflateState.FINISH_STATE && internalFlush != (int)FlushStrategy.Z_FINISH)) { strm.msg = ZLibUtil.z_errmsg[(int)ZLibResultCode.Z_NEED_DICT - ((int)ZLibResultCode.Z_STREAM_ERROR)]; return (int)ZLibResultCode.Z_STREAM_ERROR; } - if (strm.avail_out == 0) - { + if (strm.avail_out == 0) { strm.msg = ZLibUtil.z_errmsg[(int)ZLibResultCode.Z_NEED_DICT - ((int)ZLibResultCode.Z_BUF_ERROR)]; return (int)ZLibResultCode.Z_BUF_ERROR; } @@ -1942,8 +1763,7 @@ internal int deflate(ZStream strm, FlushStrategy f) last_flush = internalFlush; // Write the zlib header - if (status == DeflateState.INIT_STATE) - { + if (status == DeflateState.INIT_STATE) { int header = (Z_DEFLATED + ((w_bits - 8) << 4)) << 8; int level_flags = (level > 0) ? ((level - 1) & 0xff) >> 1 : 0; @@ -1959,8 +1779,7 @@ internal int deflate(ZStream strm, FlushStrategy f) // Save the adler32 of the preset dictionary: - if (strstart != 0) - { + if (strstart != 0) { putShortMSB((int)(ZLibUtil.URShift(strm.adler, 16))); putShortMSB((int)(strm.adler & 0xffff)); } @@ -1968,11 +1787,9 @@ internal int deflate(ZStream strm, FlushStrategy f) } // Flush as much pending output as possible - if (Pending != 0) - { + if (Pending != 0) { strm.FlushPending(); - if (strm.avail_out == 0) - { + if (strm.avail_out == 0) { //System.out.println(" _avail_out==0"); // Since _avail_out is 0, deflate will be called again with // more output space, but possibly with both pending and @@ -1986,90 +1803,76 @@ internal int deflate(ZStream strm, FlushStrategy f) // Make sure there is something to do and avoid duplicate consecutive // flushes. For repeated and useless calls with Z_FINISH, we keep // returning (int)ZLibResultCode.Z_STREAM_END instead of Z_BUFF_ERROR. - } - else if (strm.avail_in == 0 && internalFlush <= old_flush && internalFlush != (int)FlushStrategy.Z_FINISH) - { + } else if (strm.avail_in == 0 && internalFlush <= old_flush && internalFlush != (int)FlushStrategy.Z_FINISH) { strm.msg = ZLibUtil.z_errmsg[(int)ZLibResultCode.Z_NEED_DICT - ((int)ZLibResultCode.Z_BUF_ERROR)]; return (int)ZLibResultCode.Z_BUF_ERROR; } // User must not provide more input after the first FINISH: - if (status == DeflateState.FINISH_STATE && strm.avail_in != 0) - { + if (status == DeflateState.FINISH_STATE && strm.avail_in != 0) { strm.msg = ZLibUtil.z_errmsg[(int)ZLibResultCode.Z_NEED_DICT - ((int)ZLibResultCode.Z_BUF_ERROR)]; - return (int)ZLibResultCode.Z_BUF_ERROR; - } - - // Start a new block or continue the current one. - if (strm.avail_in != 0 || lookahead != 0 || (internalFlush != (int)FlushStrategy.Z_NO_FLUSH && status != DeflateState.FINISH_STATE)) - { - int bstate = - 1; - switch (config_table[level].func) - { - - case STORED: - bstate = deflate_stored(internalFlush); - break; - - case FAST: - bstate = deflate_fast(internalFlush); - break; - - case SLOW: - bstate = deflate_slow(internalFlush); - break; - - default: - break; - - } - - if (bstate == FinishStarted || bstate == FinishDone) - { - status = DeflateState.FINISH_STATE; - } - if (bstate == NeedMore || bstate == FinishStarted) - { - if (strm.avail_out == 0) - { - last_flush = -1; // avoid BUF_ERROR next call, see above - } - return (int)ZLibResultCode.Z_OK; - // If internalFlush != Z_NO_FLUSH && _avail_out == 0, the next call - // of deflate should use the same internalFlush parameter to make sure - // that the internalFlush is complete. So we don't have to output an - // empty block here, this will be done at next call. This also - // ensures that for a very small output buffer, we emit at most - // one empty block. - } - - if (bstate == BlockDone) - { - if (internalFlush == (int)FlushStrategy.Z_PARTIAL_FLUSH) - { - _tr_align(); - } - else - { - // FULL_FLUSH or SYNC_FLUSH - _tr_stored_block(0, 0, false); - // For a full internalFlush, this empty block will be recognized - // as a special marker by inflate_sync(). - if (internalFlush == (int)FlushStrategy.Z_FULL_FLUSH) - { - for (int i = 0; i < hash_size; i++) - // forget history - head[i] = 0; - } - } - strm.FlushPending(); - if (strm.avail_out == 0) - { - last_flush = -1; // avoid BUF_ERROR at next call, see above - return (int)ZLibResultCode.Z_OK; - } - } - } + return (int)ZLibResultCode.Z_BUF_ERROR; + } + + // Start a new block or continue the current one. + if (strm.avail_in != 0 || lookahead != 0 || (internalFlush != (int)FlushStrategy.Z_NO_FLUSH && status != DeflateState.FINISH_STATE)) { + int bstate = -1; + switch (config_table[level].func) { + + case STORED: + bstate = deflate_stored(internalFlush); + break; + + case FAST: + bstate = deflate_fast(internalFlush); + break; + + case SLOW: + bstate = deflate_slow(internalFlush); + break; + + default: + break; + + } + + if (bstate == FinishStarted || bstate == FinishDone) { + status = DeflateState.FINISH_STATE; + } + if (bstate == NeedMore || bstate == FinishStarted) { + if (strm.avail_out == 0) { + last_flush = -1; // avoid BUF_ERROR next call, see above + } + return (int)ZLibResultCode.Z_OK; + // If internalFlush != Z_NO_FLUSH && _avail_out == 0, the next call + // of deflate should use the same internalFlush parameter to make sure + // that the internalFlush is complete. So we don't have to output an + // empty block here, this will be done at next call. This also + // ensures that for a very small output buffer, we emit at most + // one empty block. + } + + if (bstate == BlockDone) { + if (internalFlush == (int)FlushStrategy.Z_PARTIAL_FLUSH) { + _tr_align(); + } else { + // FULL_FLUSH or SYNC_FLUSH + _tr_stored_block(0, 0, false); + // For a full internalFlush, this empty block will be recognized + // as a special marker by inflate_sync(). + if (internalFlush == (int)FlushStrategy.Z_FULL_FLUSH) { + for (int i = 0; i < hash_size; i++) + // forget history + head[i] = 0; + } + } + strm.FlushPending(); + if (strm.avail_out == 0) { + last_flush = -1; // avoid BUF_ERROR at next call, see above + return (int)ZLibResultCode.Z_OK; + } + } + } if (internalFlush != (int)FlushStrategy.Z_FINISH) return (int)ZLibResultCode.Z_OK; @@ -2077,13 +1880,13 @@ internal int deflate(ZStream strm, FlushStrategy f) return (int)ZLibResultCode.Z_STREAM_END; // Write the zlib trailer (adler32) - putShortMSB((int) (ZLibUtil.URShift(strm.adler, 16))); - putShortMSB((int) (strm.adler & 0xffff)); + putShortMSB((int)(ZLibUtil.URShift(strm.adler, 16))); + putShortMSB((int)(strm.adler & 0xffff)); strm.FlushPending(); // If _avail_out is zero, the application will call deflate again // to internalFlush the rest. - NoHeader = - 1; // WritePos the trailer only once! + NoHeader = -1; // WritePos the trailer only once! return Pending != 0 ? (int)ZLibResultCode.Z_OK : (int)ZLibResultCode.Z_STREAM_END; } @@ -2092,8 +1895,7 @@ internal int deflate(ZStream strm, FlushStrategy f) /// /// Static constructor initializes config_table /// - static Deflate() - { + static Deflate() { { config_table = new Config[10]; // good lazy nice chain @@ -2110,5 +1912,5 @@ static Deflate() config_table[9] = new Config(32, 258, 258, 4096, SLOW); } } - } + } } diff --git a/Src/IronPython.Modules/zlib/zlib.net/InfBlocks.cs b/Src/IronPython.Modules/zlib/zlib.net/InfBlocks.cs index 3283c3e38..64f9fc02b 100644 --- a/Src/IronPython.Modules/zlib/zlib.net/InfBlocks.cs +++ b/Src/IronPython.Modules/zlib/zlib.net/InfBlocks.cs @@ -43,11 +43,9 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ using System; -namespace ComponentAce.Compression.Libs.ZLib -{ +namespace ComponentAce.Compression.Libs.ZLib { - internal enum InflateBlockMode - { + internal enum InflateBlockMode { TYPE = 0, // get type bits (3, including End bit) LENS = 1, // get lengths for stored STORED = 2, // processing stored block @@ -60,8 +58,7 @@ internal enum InflateBlockMode BAD = 9 // a data error--stuck here } - internal sealed class InfBlocks - { + internal sealed class InfBlocks { #region Fields private const int MANY = 1440; @@ -166,8 +163,7 @@ internal sealed class InfBlocks #region Methods - internal InfBlocks(ZStream z, bool needCheck, int w) - { + internal InfBlocks(ZStream z, bool needCheck, int w) { hufts = new int[MANY * 3]; Window = new byte[w]; End = w; @@ -179,16 +175,13 @@ internal InfBlocks(ZStream z, bool needCheck, int w) /// /// Resets this InfBlocks class instance /// - internal void reset(ZStream z, long[] c) - { + internal void reset(ZStream z, long[] c) { if (c != null) c[0] = check; - if (mode == InflateBlockMode.BTREE || mode == InflateBlockMode.DTREE) - { + if (mode == InflateBlockMode.BTREE || mode == InflateBlockMode.DTREE) { blens = null; } - if (mode == InflateBlockMode.CODES) - { + if (mode == InflateBlockMode.CODES) { codes.free(z); } mode = InflateBlockMode.TYPE; @@ -203,8 +196,7 @@ internal void reset(ZStream z, long[] c) /// /// Block processing functions /// - internal int proc(ZStream z, int r) - { + internal int proc(ZStream z, int r) { int t; // temporary storage int b; // bit buffer int k; // bits in bit buffer @@ -222,21 +214,15 @@ internal int proc(ZStream z, int r) } // process input based on current state - while (true) - { - switch (mode) - { + while (true) { + switch (mode) { case InflateBlockMode.TYPE: - while (k < (3)) - { - if (n != 0) - { + while (k < (3)) { + if (n != 0) { r = (int)ZLibResultCode.Z_OK; - } - else - { + } else { BitB = b; BitK = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; @@ -251,8 +237,7 @@ internal int proc(ZStream z, int r) t = (int)(b & 7); last = t & 1; - switch (ZLibUtil.URShift(t, 1)) - { + switch (ZLibUtil.URShift(t, 1)) { case 0: // stored { @@ -274,8 +259,7 @@ internal int proc(ZStream z, int r) InfTree.inflate_trees_fixed(bl, bd, tl, td, z); codes = new InfCodes(bl[0], bd[0], tl[0], td[0], z); - } - { + } { b = ZLibUtil.URShift(b, (3)); k -= (3); } @@ -307,14 +291,10 @@ internal int proc(ZStream z, int r) case InflateBlockMode.LENS: - while (k < (32)) - { - if (n != 0) - { + while (k < (32)) { + if (n != 0) { r = (int)ZLibResultCode.Z_OK; - } - else - { + } else { BitB = b; BitK = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; @@ -327,8 +307,7 @@ internal int proc(ZStream z, int r) k += 8; } - if (((ZLibUtil.URShift((~b), 16)) & 0xffff) != (b & 0xffff)) - { + if (((ZLibUtil.URShift((~b), 16)) & 0xffff) != (b & 0xffff)) { mode = InflateBlockMode.BAD; z.msg = "invalid stored block lengths"; r = (int)ZLibResultCode.Z_DATA_ERROR; @@ -344,31 +323,25 @@ internal int proc(ZStream z, int r) break; case InflateBlockMode.STORED: - if (n == 0) - { + if (n == 0) { BitB = b; BitK = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; WritePos = q; return inflate_flush(z, r); } - if (m == 0) - { - if (q == End && ReadPos != 0) - { + if (m == 0) { + if (q == End && ReadPos != 0) { q = 0; m = (int)(q < ReadPos ? ReadPos - q - 1 : End - q); } - if (m == 0) - { + if (m == 0) { WritePos = q; r = inflate_flush(z, r); q = WritePos; m = (int)(q < ReadPos ? ReadPos - q - 1 : End - q); - if (q == End && ReadPos != 0) - { + if (q == End && ReadPos != 0) { q = 0; m = (int)(q < ReadPos ? ReadPos - q - 1 : End - q); } - if (m == 0) - { + if (m == 0) { BitB = b; BitK = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; WritePos = q; @@ -393,14 +366,10 @@ internal int proc(ZStream z, int r) case InflateBlockMode.TABLE: - while (k < (14)) - { - if (n != 0) - { + while (k < (14)) { + if (n != 0) { r = (int)ZLibResultCode.Z_OK; - } - else - { + } else { BitB = b; BitK = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; @@ -414,8 +383,7 @@ internal int proc(ZStream z, int r) } table = t = (b & 0x3fff); - if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) - { + if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) { mode = InflateBlockMode.BAD; z.msg = "too many length or distance symbols"; r = (int)ZLibResultCode.Z_DATA_ERROR; @@ -426,8 +394,7 @@ internal int proc(ZStream z, int r) return inflate_flush(z, r); } t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); - blens = new int[t]; - { + blens = new int[t]; { b = ZLibUtil.URShift(b, (14)); k -= (14); } @@ -436,16 +403,11 @@ internal int proc(ZStream z, int r) goto case InflateBlockMode.BTREE; case InflateBlockMode.BTREE: - while (index < 4 + (ZLibUtil.URShift(table, 10))) - { - while (k < (3)) - { - if (n != 0) - { + while (index < 4 + (ZLibUtil.URShift(table, 10))) { + while (k < (3)) { + if (n != 0) { r = (int)ZLibResultCode.Z_OK; - } - else - { + } else { BitB = b; BitK = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; @@ -465,18 +427,15 @@ internal int proc(ZStream z, int r) } } - while (index < 19) - { + while (index < 19) { blens[ZLibUtil.border[index++]] = 0; } bb[0] = 7; t = InfTree.inflate_trees_bits(blens, bb, tb, hufts, z); - if (t != (int)ZLibResultCode.Z_OK) - { + if (t != (int)ZLibResultCode.Z_OK) { r = t; - if (r == (int)ZLibResultCode.Z_DATA_ERROR) - { + if (r == (int)ZLibResultCode.Z_DATA_ERROR) { blens = null; mode = InflateBlockMode.BAD; } @@ -492,11 +451,9 @@ internal int proc(ZStream z, int r) goto case InflateBlockMode.DTREE; case InflateBlockMode.DTREE: - while (true) - { + while (true) { t = table; - if (!(index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))) - { + if (!(index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))) { break; } @@ -505,14 +462,10 @@ internal int proc(ZStream z, int r) t = bb[0]; - while (k < (t)) - { - if (n != 0) - { + while (k < (t)) { + if (n != 0) { r = (int)ZLibResultCode.Z_OK; - } - else - { + } else { BitB = b; BitK = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; @@ -528,25 +481,18 @@ internal int proc(ZStream z, int r) t = hufts[(tb[0] + (b & ZLibUtil.inflate_mask[t])) * 3 + 1]; c = hufts[(tb[0] + (b & ZLibUtil.inflate_mask[t])) * 3 + 2]; - if (c < 16) - { + if (c < 16) { b = ZLibUtil.URShift(b, (t)); k -= (t); blens[index++] = c; - } - else - { + } else { // c == 16..18 i = c == 18 ? 7 : c - 14; j = c == 18 ? 11 : 3; - while (k < (t + i)) - { - if (n != 0) - { + while (k < (t + i)) { + if (n != 0) { r = (int)ZLibResultCode.Z_OK; - } - else - { + } else { BitB = b; BitK = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; @@ -567,8 +513,7 @@ internal int proc(ZStream z, int r) i = index; t = table; - if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || (c == 16 && i < 1)) - { + if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || (c == 16 && i < 1)) { blens = null; mode = InflateBlockMode.BAD; z.msg = "invalid bit length repeat"; @@ -581,8 +526,7 @@ internal int proc(ZStream z, int r) } c = c == 16 ? blens[i - 1] : 0; - do - { + do { blens[i++] = c; } while (--j != 0); @@ -590,8 +534,7 @@ internal int proc(ZStream z, int r) } } - tb[0] = -1; - { + tb[0] = -1; { int[] bl = new int[1]; int[] bd = new int[1]; int[] tl = new int[1]; @@ -602,10 +545,8 @@ internal int proc(ZStream z, int r) bd[0] = 6; // must be <= 9 for lookahead assumptions t = table; t = InfTree.inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), blens, bl, bd, tl, td, hufts, z); - if (t != (int)ZLibResultCode.Z_OK) - { - if (t == (int)ZLibResultCode.Z_DATA_ERROR) - { + if (t != (int)ZLibResultCode.Z_OK) { + if (t == (int)ZLibResultCode.Z_DATA_ERROR) { blens = null; mode = InflateBlockMode.BAD; } @@ -628,8 +569,7 @@ internal int proc(ZStream z, int r) z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; WritePos = q; - if ((r = codes.proc(this, z, r)) != (int)ZLibResultCode.Z_STREAM_END) - { + if ((r = codes.proc(this, z, r)) != (int)ZLibResultCode.Z_STREAM_END) { return inflate_flush(z, r); } r = (int)ZLibResultCode.Z_OK; @@ -638,8 +578,7 @@ internal int proc(ZStream z, int r) p = z.next_in_index; n = z.avail_in; b = BitB; k = BitK; q = WritePos; m = (int)(q < ReadPos ? ReadPos - q - 1 : End - q); - if (last == 0) - { + if (last == 0) { mode = InflateBlockMode.TYPE; break; } @@ -650,8 +589,7 @@ internal int proc(ZStream z, int r) WritePos = q; r = inflate_flush(z, r); q = WritePos; m = (int)(q < ReadPos ? ReadPos - q - 1 : End - q); - if (ReadPos != WritePos) - { + if (ReadPos != WritePos) { BitB = b; BitK = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; WritePos = q; @@ -692,8 +630,7 @@ internal int proc(ZStream z, int r) /// /// Frees inner buffers /// - internal void free(ZStream z) - { + internal void free(ZStream z) { reset(z, null); Window = null; hufts = null; @@ -704,8 +641,7 @@ internal void free(ZStream z) /// Sets dictionary /// - internal void set_dictionary(byte[] d, int start, int n) - { + internal void set_dictionary(byte[] d, int start, int n) { Array.Copy(d, start, Window, 0, n); ReadPos = WritePos = n; } @@ -714,75 +650,72 @@ internal void set_dictionary(byte[] d, int start, int n) /// Returns true if inflate is currently at the End of a block generated /// by Z_SYNC_FLUSH or Z_FULL_FLUSH. /// - internal int sync_point() - { + internal int sync_point() { return mode == InflateBlockMode.LENS ? 1 : 0; } /// /// copy as much as possible from the sliding Window to the output area /// - internal int inflate_flush(ZStream z, int r) - { - // local copies of source and destination pointers - int p = z.next_out_index; - int q = ReadPos; - - // compute number of bytes to copy as far as End of Window - int n = (int) ((q <= WritePos?WritePos:End) - q); - if (n > z.avail_out) - n = z.avail_out; - if (n != 0 && r == (int)ZLibResultCode.Z_BUF_ERROR) - r = (int)ZLibResultCode.Z_OK; - - // update counters - z.avail_out -= n; - z.total_out += n; - - // update check information - if (needCheck) - z.adler = check = Adler32.GetAdler32Checksum(check, Window, q, n); - - // copy as far as End of Window - Array.Copy(Window, q, z.next_out, p, n); - p += n; - q += n; - - // see if more to copy at beginning of Window - if (q == End) - { - // wrap pointers - q = 0; - if (WritePos == End) - WritePos = 0; - - // compute bytes to copy - n = WritePos - q; - if (n > z.avail_out) - n = z.avail_out; - if (n != 0 && r == (int)ZLibResultCode.Z_BUF_ERROR) - r = (int)ZLibResultCode.Z_OK; - - // update counters - z.avail_out -= n; - z.total_out += n; - - // update check information - if (needCheck) - z.adler = check = Adler32.GetAdler32Checksum(check, Window, q, n); - - // copy - Array.Copy(Window, q, z.next_out, p, n); - p += n; - q += n; - } - - // update pointers - z.next_out_index = p; - ReadPos = q; - - // done - return r; + internal int inflate_flush(ZStream z, int r) { + // local copies of source and destination pointers + int p = z.next_out_index; + int q = ReadPos; + + // compute number of bytes to copy as far as End of Window + int n = (int)((q <= WritePos ? WritePos : End) - q); + if (n > z.avail_out) + n = z.avail_out; + if (n != 0 && r == (int)ZLibResultCode.Z_BUF_ERROR) + r = (int)ZLibResultCode.Z_OK; + + // update counters + z.avail_out -= n; + z.total_out += n; + + // update check information + if (needCheck) + z.adler = check = Adler32.GetAdler32Checksum(check, Window, q, n); + + // copy as far as End of Window + Array.Copy(Window, q, z.next_out, p, n); + p += n; + q += n; + + // see if more to copy at beginning of Window + if (q == End) { + // wrap pointers + q = 0; + if (WritePos == End) + WritePos = 0; + + // compute bytes to copy + n = WritePos - q; + if (n > z.avail_out) + n = z.avail_out; + if (n != 0 && r == (int)ZLibResultCode.Z_BUF_ERROR) + r = (int)ZLibResultCode.Z_OK; + + // update counters + z.avail_out -= n; + z.total_out += n; + + // update check information + if (needCheck) + z.adler = check = Adler32.GetAdler32Checksum(check, Window, q, n); + + // copy + Array.Copy(Window, q, z.next_out, p, n); + p += n; + q += n; + } + + // update pointers + z.next_out_index = p; + ReadPos = q; + + // done + return r; } #endregion diff --git a/Src/IronPython.Modules/zlib/zlib.net/InfCodes.cs b/Src/IronPython.Modules/zlib/zlib.net/InfCodes.cs index 78700fcf8..79b7a371c 100644 --- a/Src/IronPython.Modules/zlib/zlib.net/InfCodes.cs +++ b/Src/IronPython.Modules/zlib/zlib.net/InfCodes.cs @@ -43,32 +43,29 @@ EVEN IF ADVISED OF THE POSSIBI InflateCodesMode.LITY OF SUCH DAMAGE. */ using System; -namespace ComponentAce.Compression.Libs.ZLib -{ +namespace ComponentAce.Compression.Libs.ZLib { /// /// Inflate codes mode /// - internal enum InflateCodesMode - { - START = 0, // x: set up for InflateCodesMode.LEN - LEN = 1, // i: get length/literal/eob next - LENEXT = 2, // i: getting length extra (have base) - DIST = 3, // i: get distance next - DISTEXT = 4, // i: getting distance extra - COPY = 5, // o: copying bytes in Window, waiting for space - LIT = 6, // o: got literal, waiting for output space - WASH = 7, // o: got eob, possibly still output waiting - END = 8, // x: got eob and all data flushed - BADCODE = 9 // x: got error + internal enum InflateCodesMode { + START = 0, // x: set up for InflateCodesMode.LEN + LEN = 1, // i: get length/literal/eob next + LENEXT = 2, // i: getting length extra (have base) + DIST = 3, // i: get distance next + DISTEXT = 4, // i: getting distance extra + COPY = 5, // o: copying bytes in Window, waiting for space + LIT = 6, // o: got literal, waiting for output space + WASH = 7, // o: got eob, possibly still output waiting + END = 8, // x: got eob and all data flushed + BADCODE = 9 // x: got error } /// /// This class is used by the InfBlocks class /// - internal sealed class InfCodes - { - + internal sealed class InfCodes { + #region Fields /// @@ -142,635 +139,563 @@ internal sealed class InfCodes /// /// Constructor which takes literal, distance trees, corresponding bites decoded for branches, corresponding indexes and a ZStream object /// - internal InfCodes(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, ZStream z) - { - mode = InflateCodesMode.START; - lbits = (byte) bl; - dbits = (byte) bd; - ltree = tl; - ltree_index = tl_index; - dtree = td; - dtree_index = td_index; - } + internal InfCodes(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, ZStream z) { + mode = InflateCodesMode.START; + lbits = (byte)bl; + dbits = (byte)bd; + ltree = tl; + ltree_index = tl_index; + dtree = td; + dtree_index = td_index; + } /// /// Constructor which takes literal, distance trees, corresponding bites decoded for branches and a ZStream object /// - internal InfCodes(int bl, int bd, int[] tl, int[] td, ZStream z) - { - mode = InflateCodesMode.START; - lbits = (byte) bl; - dbits = (byte) bd; - ltree = tl; - ltree_index = 0; - dtree = td; - dtree_index = 0; - } - + internal InfCodes(int bl, int bd, int[] tl, int[] td, ZStream z) { + mode = InflateCodesMode.START; + lbits = (byte)bl; + dbits = (byte)bd; + ltree = tl; + ltree_index = 0; + dtree = td; + dtree_index = 0; + } + /// /// Block processing method /// /// An instance of the InfBlocks class /// A ZStream object /// A result code - internal int proc(InfBlocks s, ZStream z, int r) - { - int j; // temporary storage - //int[] t; // temporary pointer - int tindex; // temporary pointer - int e; // extra bits or operation - int b = 0; // bit buffer - int k = 0; // bits in bit buffer - int p = 0; // input data pointer - int n; // bytes available there - int q; // output Window WritePos pointer - int m; // bytes to End of Window or ReadPos pointer - int f; // pointer to copy strings from - - // copy input/output information to locals (UPDATE macro restores) - p = z.next_in_index; n = z.avail_in; b = s.BitB; k = s.BitK; - q = s.WritePos; m = q < s.ReadPos?s.ReadPos - q - 1:s.End - q; - - // process input and output based on current state - while (true) - { - switch (mode) - { - - // waiting for "i:"=input, "o:"=output, "x:"=nothing - case InflateCodesMode.START: // x: set up for InflateCodesMode.LEN - if (m >= 258 && n >= 10) - { - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - r = inflate_fast(lbits, dbits, ltree, ltree_index, dtree, dtree_index, s, z); - - p = z.next_in_index; n = z.avail_in; b = s.BitB; k = s.BitK; - q = s.WritePos; m = q < s.ReadPos?s.ReadPos - q - 1:s.End - q; - - if (r != (int)ZLibResultCode.Z_OK) - { - mode = r == (int)ZLibResultCode.Z_STREAM_END? InflateCodesMode.WASH: InflateCodesMode.BADCODE; - break; - } - } - need = lbits; - tree = ltree; - tree_index = ltree_index; - - mode = InflateCodesMode.LEN; - goto case InflateCodesMode.LEN; - - case InflateCodesMode.LEN: // i: get length/literal/eob next - j = need; - - while (k < (j)) - { - if (n != 0) - r = (int)ZLibResultCode.Z_OK; - else - { - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - } - n--; - b |= (z.next_in[p++] & 0xff) << k; - k += 8; - } - - tindex = (tree_index + (b & ZLibUtil.inflate_mask[j])) * 3; - - b = ZLibUtil.URShift(b, (tree[tindex + 1])); - k -= (tree[tindex + 1]); - - e = tree[tindex]; - - if (e == 0) - { - // literal - lit = tree[tindex + 2]; - mode = InflateCodesMode.LIT; - break; - } - if ((e & 16) != 0) - { - // length - get_Renamed = e & 15; - count = tree[tindex + 2]; - mode = InflateCodesMode.LENEXT; - break; - } - if ((e & 64) == 0) - { - // next table - need = e; - tree_index = tindex / 3 + tree[tindex + 2]; - break; - } - if ((e & 32) != 0) - { - // End of block - mode = InflateCodesMode.WASH; - break; - } - mode = InflateCodesMode.BADCODE; // invalid code - z.msg = "invalid literal/length code"; - r = (int)ZLibResultCode.Z_DATA_ERROR; - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - - - case InflateCodesMode.LENEXT: // i: getting length extra (have base) - j = get_Renamed; - - while (k < (j)) - { - if (n != 0) - r = (int)ZLibResultCode.Z_OK; - else - { - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - } - n--; b |= (z.next_in[p++] & 0xff) << k; - k += 8; - } - - count += (b & ZLibUtil.inflate_mask[j]); - - b >>= j; - k -= j; - - need = dbits; - tree = dtree; - tree_index = dtree_index; - mode = InflateCodesMode.DIST; - goto case InflateCodesMode.DIST; - - case InflateCodesMode.DIST: // i: get distance next - j = need; - - while (k < (j)) - { - if (n != 0) - r = (int)ZLibResultCode.Z_OK; - else - { - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - } - n--; b |= (z.next_in[p++] & 0xff) << k; - k += 8; - } - - tindex = (tree_index + (b & ZLibUtil.inflate_mask[j])) * 3; - - b >>= tree[tindex + 1]; - k -= tree[tindex + 1]; - - e = (tree[tindex]); - if ((e & 16) != 0) - { - // distance - get_Renamed = e & 15; - dist = tree[tindex + 2]; - mode = InflateCodesMode.DISTEXT; - break; - } - if ((e & 64) == 0) - { - // next table - need = e; - tree_index = tindex / 3 + tree[tindex + 2]; - break; - } - mode = InflateCodesMode.BADCODE; // invalid code - z.msg = "invalid distance code"; - r = (int)ZLibResultCode.Z_DATA_ERROR; - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - - - case InflateCodesMode.DISTEXT: // i: getting distance extra - j = get_Renamed; - - while (k < (j)) - { - if (n != 0) - r = (int)ZLibResultCode.Z_OK; - else - { - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - } - n--; b |= (z.next_in[p++] & 0xff) << k; - k += 8; - } - - dist += (b & ZLibUtil.inflate_mask[j]); - - b >>= j; - k -= j; - - mode = InflateCodesMode.COPY; - goto case InflateCodesMode.COPY; - - case InflateCodesMode.COPY: // o: copying bytes in Window, waiting for space - f = q - dist; - while (f < 0) - { - // modulo Window size-"while" instead - f += s.End; // of "if" handles invalid distances - } - while (count != 0) - { - - if (m == 0) - { - if (q == s.End && s.ReadPos != 0) - { - q = 0; m = q < s.ReadPos?s.ReadPos - q - 1:s.End - q; - } - if (m == 0) - { - s.WritePos = q; r = s.inflate_flush(z, r); - q = s.WritePos; m = q < s.ReadPos?s.ReadPos - q - 1:s.End - q; - - if (q == s.End && s.ReadPos != 0) - { - q = 0; m = q < s.ReadPos?s.ReadPos - q - 1:s.End - q; - } - - if (m == 0) - { - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - } - } - } - - s.Window[q++] = s.Window[f++]; m--; - - if (f == s.End) - f = 0; - count--; - } - mode = InflateCodesMode.START; - break; - - case InflateCodesMode.LIT: // o: got literal, waiting for output space - if (m == 0) - { - if (q == s.End && s.ReadPos != 0) - { - q = 0; m = q < s.ReadPos?s.ReadPos - q - 1:s.End - q; - } - if (m == 0) - { - s.WritePos = q; r = s.inflate_flush(z, r); - q = s.WritePos; m = q < s.ReadPos?s.ReadPos - q - 1:s.End - q; - - if (q == s.End && s.ReadPos != 0) - { - q = 0; m = q < s.ReadPos?s.ReadPos - q - 1:s.End - q; - } - if (m == 0) - { - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - } - } - } - r = (int)ZLibResultCode.Z_OK; - - s.Window[q++] = (byte) lit; m--; - - mode = InflateCodesMode.START; - break; - - case InflateCodesMode.WASH: // o: got eob, possibly more output - if (k > 7) - { - // return unused byte, if any - k -= 8; - n++; - p--; // can always return one - } - - s.WritePos = q; r = s.inflate_flush(z, r); - q = s.WritePos; m = q < s.ReadPos?s.ReadPos - q - 1:s.End - q; - - if (s.ReadPos != s.WritePos) - { - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - } - mode = InflateCodesMode.END; - goto case InflateCodesMode.END; - - case InflateCodesMode.END: - r = (int)ZLibResultCode.Z_STREAM_END; - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - - - case InflateCodesMode.BADCODE: // x: got error - - r = (int)ZLibResultCode.Z_DATA_ERROR; - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - - - default: - r = (int)ZLibResultCode.Z_STREAM_ERROR; - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - - } - } - } - + internal int proc(InfBlocks s, ZStream z, int r) { + int j; // temporary storage + //int[] t; // temporary pointer + int tindex; // temporary pointer + int e; // extra bits or operation + int b = 0; // bit buffer + int k = 0; // bits in bit buffer + int p = 0; // input data pointer + int n; // bytes available there + int q; // output Window WritePos pointer + int m; // bytes to End of Window or ReadPos pointer + int f; // pointer to copy strings from + + // copy input/output information to locals (UPDATE macro restores) + p = z.next_in_index; n = z.avail_in; b = s.BitB; k = s.BitK; + q = s.WritePos; m = q < s.ReadPos ? s.ReadPos - q - 1 : s.End - q; + + // process input and output based on current state + while (true) { + switch (mode) { + + // waiting for "i:"=input, "o:"=output, "x:"=nothing + case InflateCodesMode.START: // x: set up for InflateCodesMode.LEN + if (m >= 258 && n >= 10) { + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + r = inflate_fast(lbits, dbits, ltree, ltree_index, dtree, dtree_index, s, z); + + p = z.next_in_index; n = z.avail_in; b = s.BitB; k = s.BitK; + q = s.WritePos; m = q < s.ReadPos ? s.ReadPos - q - 1 : s.End - q; + + if (r != (int)ZLibResultCode.Z_OK) { + mode = r == (int)ZLibResultCode.Z_STREAM_END ? InflateCodesMode.WASH : InflateCodesMode.BADCODE; + break; + } + } + need = lbits; + tree = ltree; + tree_index = ltree_index; + + mode = InflateCodesMode.LEN; + goto case InflateCodesMode.LEN; + + case InflateCodesMode.LEN: // i: get length/literal/eob next + j = need; + + while (k < (j)) { + if (n != 0) + r = (int)ZLibResultCode.Z_OK; + else { + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + } + n--; + b |= (z.next_in[p++] & 0xff) << k; + k += 8; + } + + tindex = (tree_index + (b & ZLibUtil.inflate_mask[j])) * 3; + + b = ZLibUtil.URShift(b, (tree[tindex + 1])); + k -= (tree[tindex + 1]); + + e = tree[tindex]; + + if (e == 0) { + // literal + lit = tree[tindex + 2]; + mode = InflateCodesMode.LIT; + break; + } + if ((e & 16) != 0) { + // length + get_Renamed = e & 15; + count = tree[tindex + 2]; + mode = InflateCodesMode.LENEXT; + break; + } + if ((e & 64) == 0) { + // next table + need = e; + tree_index = tindex / 3 + tree[tindex + 2]; + break; + } + if ((e & 32) != 0) { + // End of block + mode = InflateCodesMode.WASH; + break; + } + mode = InflateCodesMode.BADCODE; // invalid code + z.msg = "invalid literal/length code"; + r = (int)ZLibResultCode.Z_DATA_ERROR; + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + + + case InflateCodesMode.LENEXT: // i: getting length extra (have base) + j = get_Renamed; + + while (k < (j)) { + if (n != 0) + r = (int)ZLibResultCode.Z_OK; + else { + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + } + n--; b |= (z.next_in[p++] & 0xff) << k; + k += 8; + } + + count += (b & ZLibUtil.inflate_mask[j]); + + b >>= j; + k -= j; + + need = dbits; + tree = dtree; + tree_index = dtree_index; + mode = InflateCodesMode.DIST; + goto case InflateCodesMode.DIST; + + case InflateCodesMode.DIST: // i: get distance next + j = need; + + while (k < (j)) { + if (n != 0) + r = (int)ZLibResultCode.Z_OK; + else { + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + } + n--; b |= (z.next_in[p++] & 0xff) << k; + k += 8; + } + + tindex = (tree_index + (b & ZLibUtil.inflate_mask[j])) * 3; + + b >>= tree[tindex + 1]; + k -= tree[tindex + 1]; + + e = (tree[tindex]); + if ((e & 16) != 0) { + // distance + get_Renamed = e & 15; + dist = tree[tindex + 2]; + mode = InflateCodesMode.DISTEXT; + break; + } + if ((e & 64) == 0) { + // next table + need = e; + tree_index = tindex / 3 + tree[tindex + 2]; + break; + } + mode = InflateCodesMode.BADCODE; // invalid code + z.msg = "invalid distance code"; + r = (int)ZLibResultCode.Z_DATA_ERROR; + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + + + case InflateCodesMode.DISTEXT: // i: getting distance extra + j = get_Renamed; + + while (k < (j)) { + if (n != 0) + r = (int)ZLibResultCode.Z_OK; + else { + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + } + n--; b |= (z.next_in[p++] & 0xff) << k; + k += 8; + } + + dist += (b & ZLibUtil.inflate_mask[j]); + + b >>= j; + k -= j; + + mode = InflateCodesMode.COPY; + goto case InflateCodesMode.COPY; + + case InflateCodesMode.COPY: // o: copying bytes in Window, waiting for space + f = q - dist; + while (f < 0) { + // modulo Window size-"while" instead + f += s.End; // of "if" handles invalid distances + } + while (count != 0) { + + if (m == 0) { + if (q == s.End && s.ReadPos != 0) { + q = 0; m = q < s.ReadPos ? s.ReadPos - q - 1 : s.End - q; + } + if (m == 0) { + s.WritePos = q; r = s.inflate_flush(z, r); + q = s.WritePos; m = q < s.ReadPos ? s.ReadPos - q - 1 : s.End - q; + + if (q == s.End && s.ReadPos != 0) { + q = 0; m = q < s.ReadPos ? s.ReadPos - q - 1 : s.End - q; + } + + if (m == 0) { + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + } + } + } + + s.Window[q++] = s.Window[f++]; m--; + + if (f == s.End) + f = 0; + count--; + } + mode = InflateCodesMode.START; + break; + + case InflateCodesMode.LIT: // o: got literal, waiting for output space + if (m == 0) { + if (q == s.End && s.ReadPos != 0) { + q = 0; m = q < s.ReadPos ? s.ReadPos - q - 1 : s.End - q; + } + if (m == 0) { + s.WritePos = q; r = s.inflate_flush(z, r); + q = s.WritePos; m = q < s.ReadPos ? s.ReadPos - q - 1 : s.End - q; + + if (q == s.End && s.ReadPos != 0) { + q = 0; m = q < s.ReadPos ? s.ReadPos - q - 1 : s.End - q; + } + if (m == 0) { + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + } + } + } + r = (int)ZLibResultCode.Z_OK; + + s.Window[q++] = (byte)lit; m--; + + mode = InflateCodesMode.START; + break; + + case InflateCodesMode.WASH: // o: got eob, possibly more output + if (k > 7) { + // return unused byte, if any + k -= 8; + n++; + p--; // can always return one + } + + s.WritePos = q; r = s.inflate_flush(z, r); + q = s.WritePos; m = q < s.ReadPos ? s.ReadPos - q - 1 : s.End - q; + + if (s.ReadPos != s.WritePos) { + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + } + mode = InflateCodesMode.END; + goto case InflateCodesMode.END; + + case InflateCodesMode.END: + r = (int)ZLibResultCode.Z_STREAM_END; + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + + + case InflateCodesMode.BADCODE: // x: got error + + r = (int)ZLibResultCode.Z_DATA_ERROR; + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + + + default: + r = (int)ZLibResultCode.Z_STREAM_ERROR; + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + + } + } + } + /// /// Frees allocated resources /// - internal void free(ZStream z) - { - } - + internal void free(ZStream z) { + } - /// + + /// /// Fast inflate procedure. Called with number of bytes left to WritePos in Window at least 258 /// (the maximum string length) and number of input bytes available /// at least ten. The ten bytes are six bytes for the longest length/ /// distance pair plus four bytes for overloading the bit buffer. - /// - internal int inflate_fast(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, InfBlocks s, ZStream z) - { - int t; // temporary pointer - int[] tp; // temporary pointer - int tp_index; // temporary pointer - int e; // extra bits or operation - int b; // bit buffer - int k; // bits in bit buffer - int p; // input data pointer - int n; // bytes available there - int q; // output Window WritePos pointer - int m; // bytes to End of Window or ReadPos pointer - int ml; // mask for literal/length tree - int md; // mask for distance tree - int c; // bytes to copy - int d; // distance back to copy from - int r; // copy source pointer - - // load input, output, bit values - p = z.next_in_index; n = z.avail_in; b = s.BitB; k = s.BitK; - q = s.WritePos; m = q < s.ReadPos?s.ReadPos - q - 1:s.End - q; - - // initialize masks - ml = ZLibUtil.inflate_mask[bl]; - md = ZLibUtil.inflate_mask[bd]; - - // do until not enough input or output space for fast loop - do - { - // assume called with m >= 258 && n >= 10 - // get literal/length code - while (k < (20)) - { - // max bits for literal/length code - n--; - b |= (z.next_in[p++] & 0xff) << k; k += 8; - } - - t = b & ml; - tp = tl; - tp_index = tl_index; - if ((e = tp[(tp_index + t) * 3]) == 0) - { - b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]); - - s.Window[q++] = (byte) tp[(tp_index + t) * 3 + 2]; - m--; - continue; - } - do - { - - b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]); - - if ((e & 16) != 0) - { - e &= 15; - c = tp[(tp_index + t) * 3 + 2] + ((int) b & ZLibUtil.inflate_mask[e]); - - b >>= e; k -= e; - - // decode distance base of block to copy - while (k < (15)) - { - // max bits for distance code - n--; - b |= (z.next_in[p++] & 0xff) << k; k += 8; - } - - t = b & md; - tp = td; - tp_index = td_index; - e = tp[(tp_index + t) * 3]; - - do - { - - b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]); - - if ((e & 16) != 0) - { - // get extra bits to add to distance base - e &= 15; - while (k < (e)) - { - // get extra bits (up to 13) - n--; - b |= (z.next_in[p++] & 0xff) << k; k += 8; - } - - d = tp[(tp_index + t) * 3 + 2] + (b & ZLibUtil.inflate_mask[e]); - - b >>= (e); k -= (e); - - // do the copy - m -= c; - if (q >= d) - { - // offset before dest - // just copy - r = q - d; - if (q - r > 0 && 2 > (q - r)) - { - s.Window[q++] = s.Window[r++]; c--; // minimum count is three, - s.Window[q++] = s.Window[r++]; c--; // so unroll loop a little - } - else - { - Array.Copy(s.Window, r, s.Window, q, 2); - q += 2; r += 2; c -= 2; - } - } - else - { - // else offset after destination - r = q - d; - do - { - r += s.End; // force pointer in Window - } - while (r < 0); // covers invalid distances - e = s.End - r; - if (c > e) - { - // if source crosses, - c -= e; // wrapped copy - if (q - r > 0 && e > (q - r)) - { - do - { - s.Window[q++] = s.Window[r++]; - } - while (--e != 0); - } - else - { - Array.Copy(s.Window, r, s.Window, q, e); - q += e; r += e; e = 0; - } - r = 0; // copy rest from start of Window - } - } - - // copy all or what's left - if (q - r > 0 && c > (q - r)) - { - do - { - s.Window[q++] = s.Window[r++]; - } - while (--c != 0); - } - else - { - Array.Copy(s.Window, r, s.Window, q, c); - q += c; r += c; c = 0; - } - break; - } - else if ((e & 64) == 0) - { - t += tp[(tp_index + t) * 3 + 2]; - t += (b & ZLibUtil.inflate_mask[e]); - e = tp[(tp_index + t) * 3]; - } - else - { - z.msg = "invalid distance code"; - - c = z.avail_in - n; c = (k >> 3) < c?k >> 3:c; n += c; p -= c; k -= (c << 3); - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - - return (int)ZLibResultCode.Z_DATA_ERROR; - } - } - while (true); - break; - } - - if ((e & 64) == 0) - { - t += tp[(tp_index + t) * 3 + 2]; - t += (b & ZLibUtil.inflate_mask[e]); - if ((e = tp[(tp_index + t) * 3]) == 0) - { - - b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]); - - s.Window[q++] = (byte) tp[(tp_index + t) * 3 + 2]; - m--; - break; - } - } - else if ((e & 32) != 0) - { - - c = z.avail_in - n; c = (k >> 3) < c?k >> 3:c; n += c; p -= c; k -= (c << 3); - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - - return (int)ZLibResultCode.Z_STREAM_END; - } - else - { - z.msg = "invalid literal/length code"; - - c = z.avail_in - n; c = (k >> 3) < c?k >> 3:c; n += c; p -= c; k -= (c << 3); - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - - return (int)ZLibResultCode.Z_DATA_ERROR; - } - } - while (true); - } - while (m >= 258 && n >= 10); - - // not enough input or output--restore pointers and return - c = z.avail_in - n; c = (k >> 3) < c?k >> 3:c; n += c; p -= c; k -= (c << 3); - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - - return (int)ZLibResultCode.Z_OK; - } + /// + internal int inflate_fast(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, InfBlocks s, ZStream z) { + int t; // temporary pointer + int[] tp; // temporary pointer + int tp_index; // temporary pointer + int e; // extra bits or operation + int b; // bit buffer + int k; // bits in bit buffer + int p; // input data pointer + int n; // bytes available there + int q; // output Window WritePos pointer + int m; // bytes to End of Window or ReadPos pointer + int ml; // mask for literal/length tree + int md; // mask for distance tree + int c; // bytes to copy + int d; // distance back to copy from + int r; // copy source pointer + + // load input, output, bit values + p = z.next_in_index; n = z.avail_in; b = s.BitB; k = s.BitK; + q = s.WritePos; m = q < s.ReadPos ? s.ReadPos - q - 1 : s.End - q; + + // initialize masks + ml = ZLibUtil.inflate_mask[bl]; + md = ZLibUtil.inflate_mask[bd]; + + // do until not enough input or output space for fast loop + do { + // assume called with m >= 258 && n >= 10 + // get literal/length code + while (k < (20)) { + // max bits for literal/length code + n--; + b |= (z.next_in[p++] & 0xff) << k; k += 8; + } + + t = b & ml; + tp = tl; + tp_index = tl_index; + if ((e = tp[(tp_index + t) * 3]) == 0) { + b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]); + + s.Window[q++] = (byte)tp[(tp_index + t) * 3 + 2]; + m--; + continue; + } + do { + + b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]); + + if ((e & 16) != 0) { + e &= 15; + c = tp[(tp_index + t) * 3 + 2] + ((int)b & ZLibUtil.inflate_mask[e]); + + b >>= e; k -= e; + + // decode distance base of block to copy + while (k < (15)) { + // max bits for distance code + n--; + b |= (z.next_in[p++] & 0xff) << k; k += 8; + } + + t = b & md; + tp = td; + tp_index = td_index; + e = tp[(tp_index + t) * 3]; + + do { + + b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]); + + if ((e & 16) != 0) { + // get extra bits to add to distance base + e &= 15; + while (k < (e)) { + // get extra bits (up to 13) + n--; + b |= (z.next_in[p++] & 0xff) << k; k += 8; + } + + d = tp[(tp_index + t) * 3 + 2] + (b & ZLibUtil.inflate_mask[e]); + + b >>= (e); k -= (e); + + // do the copy + m -= c; + if (q >= d) { + // offset before dest + // just copy + r = q - d; + if (q - r > 0 && 2 > (q - r)) { + s.Window[q++] = s.Window[r++]; c--; // minimum count is three, + s.Window[q++] = s.Window[r++]; c--; // so unroll loop a little + } else { + Array.Copy(s.Window, r, s.Window, q, 2); + q += 2; r += 2; c -= 2; + } + } else { + // else offset after destination + r = q - d; + do { + r += s.End; // force pointer in Window + } + while (r < 0); // covers invalid distances + e = s.End - r; + if (c > e) { + // if source crosses, + c -= e; // wrapped copy + if (q - r > 0 && e > (q - r)) { + do { + s.Window[q++] = s.Window[r++]; + } + while (--e != 0); + } else { + Array.Copy(s.Window, r, s.Window, q, e); + q += e; r += e; e = 0; + } + r = 0; // copy rest from start of Window + } + } + + // copy all or what's left + if (q - r > 0 && c > (q - r)) { + do { + s.Window[q++] = s.Window[r++]; + } + while (--c != 0); + } else { + Array.Copy(s.Window, r, s.Window, q, c); + q += c; r += c; c = 0; + } + break; + } else if ((e & 64) == 0) { + t += tp[(tp_index + t) * 3 + 2]; + t += (b & ZLibUtil.inflate_mask[e]); + e = tp[(tp_index + t) * 3]; + } else { + z.msg = "invalid distance code"; + + c = z.avail_in - n; c = (k >> 3) < c ? k >> 3 : c; n += c; p -= c; k -= (c << 3); + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + + return (int)ZLibResultCode.Z_DATA_ERROR; + } + } + while (true); + break; + } + + if ((e & 64) == 0) { + t += tp[(tp_index + t) * 3 + 2]; + t += (b & ZLibUtil.inflate_mask[e]); + if ((e = tp[(tp_index + t) * 3]) == 0) { + + b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]); + + s.Window[q++] = (byte)tp[(tp_index + t) * 3 + 2]; + m--; + break; + } + } else if ((e & 32) != 0) { + + c = z.avail_in - n; c = (k >> 3) < c ? k >> 3 : c; n += c; p -= c; k -= (c << 3); + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + + return (int)ZLibResultCode.Z_STREAM_END; + } else { + z.msg = "invalid literal/length code"; + + c = z.avail_in - n; c = (k >> 3) < c ? k >> 3 : c; n += c; p -= c; k -= (c << 3); + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + + return (int)ZLibResultCode.Z_DATA_ERROR; + } + } + while (true); + } + while (m >= 258 && n >= 10); + + // not enough input or output--restore pointers and return + c = z.avail_in - n; c = (k >> 3) < c ? k >> 3 : c; n += c; p -= c; k -= (c << 3); + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + + return (int)ZLibResultCode.Z_OK; + } #endregion } diff --git a/Src/IronPython.Modules/zlib/zlib.net/InfTree.cs b/Src/IronPython.Modules/zlib/zlib.net/InfTree.cs index 3a0be26d6..e3f5d4c45 100644 --- a/Src/IronPython.Modules/zlib/zlib.net/InfTree.cs +++ b/Src/IronPython.Modules/zlib/zlib.net/InfTree.cs @@ -43,22 +43,20 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ using System; -namespace ComponentAce.Compression.Libs.ZLib -{ - /// - /// Contains utility information for the InfTree class - /// - internal class InfTreeUtil - { +namespace ComponentAce.Compression.Libs.ZLib { + /// + /// Contains utility information for the InfTree class + /// + internal class InfTreeUtil { internal const int MANY = 1440; internal const int fixed_bl = 9; internal const int fixed_bd = 5; - internal static readonly int[] fixed_tl = new int[]{96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 192, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 160, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 224, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 144, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 208, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 176, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 240, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 200, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 168, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 232, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 152, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 216, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 184, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 248, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 196, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 164, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 228, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 148, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 212, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 180, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 244, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 204, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 172, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 236, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 156, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 220, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 188, 0, 8, 14, 0, 8, 142, 0, 8, 78, 0, 9, 252, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 194, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 162, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 226, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 146, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 210, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 178, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 242, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 202, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 170, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 234, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 154, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 218, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 186, - 0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 250, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 198, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 166, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 230, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 150, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 214, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 182, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 246, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 206, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 174, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 238, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 158, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 222, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 190, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 254, 96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 193, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 161, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 225, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 145, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 209, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 177, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 241, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 201, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 169, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 233, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 153, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 217, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 185, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 249, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 197, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 165, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 229, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 149, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 213, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 181, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 245, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 205, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 173, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 237, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 157, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 221, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 189, 0, 8, - 14, 0, 8, 142, 0, 8, 78, 0, 9, 253, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 195, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 163, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 227, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 147, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 211, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 179, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 243, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 203, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 171, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 235, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 155, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 219, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 187, 0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 251, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 199, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 167, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 231, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 151, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 215, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 183, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 247, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 207, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 175, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 239, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 159, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 223, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 191, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 255}; + internal static readonly int[] fixed_tl = new int[]{96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 192, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 160, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 224, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 144, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 208, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 176, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 240, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 200, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 168, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 232, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 152, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 216, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 184, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 248, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 196, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 164, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 228, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 148, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 212, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 180, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 244, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 204, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 172, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 236, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 156, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 220, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 188, 0, 8, 14, 0, 8, 142, 0, 8, 78, 0, 9, 252, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 194, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 162, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 226, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 146, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 210, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 178, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 242, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 202, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 170, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 234, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 154, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 218, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 186, + 0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 250, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 198, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 166, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 230, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 150, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 214, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 182, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 246, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 206, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 174, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 238, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 158, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 222, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 190, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 254, 96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 193, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 161, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 225, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 145, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 209, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 177, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 241, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 201, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 169, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 233, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 153, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 217, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 185, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 249, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 197, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 165, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 229, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 149, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 213, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 181, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 245, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 205, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 173, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 237, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 157, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 221, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 189, 0, 8, + 14, 0, 8, 142, 0, 8, 78, 0, 9, 253, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 195, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 163, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 227, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 147, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 211, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 179, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 243, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 203, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 171, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 235, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 155, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 219, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 187, 0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 251, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 199, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 167, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 231, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 151, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 215, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 183, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 247, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 207, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 175, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 239, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 159, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 223, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 191, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 255}; internal static readonly int[] fixed_td = new int[] { 80, 5, 1, 87, 5, 257, 83, 5, 17, 91, 5, 4097, 81, 5, 5, 89, 5, 1025, 85, 5, 65, 93, 5, 16385, 80, 5, 3, 88, 5, 513, 84, 5, 33, 92, 5, 8193, 82, 5, 9, 90, 5, 2049, 86, 5, 129, 192, 5, 24577, 80, 5, 2, 87, 5, 385, 83, 5, 25, 91, 5, 6145, 81, 5, 7, 89, 5, 1537, 85, 5, 97, 93, 5, 24577, 80, 5, 4, 88, 5, 769, 84, 5, 49, 92, 5, 12289, 82, 5, 13, 90, 5, 3073, 86, 5, 193, 192, 5, 24577 }; @@ -75,9 +73,8 @@ internal class InfTreeUtil internal const int BMAX = 15; // maximum bit length of any code } - internal sealed class InfTree - { - + internal sealed class InfTree { + #region Methods /// @@ -86,300 +83,255 @@ internal sealed class InfTree /// /// Return (int)ZLibResultCode.Z_OK on success, (int)ZLibResultCode.Z_DATA_ERROR if the given code set is incomplete (the tables are still built in this case), (int)ZLibResultCode.Z_DATA_ERROR if the input is invalid (an over-subscribed set of lengths), or (int)ZLibResultCode.Z_DATA_ERROR if not enough memory. /// - private static int huft_build(int[] b, int bindex, int n, int s, int[] d, int[] e, int[] t, int[] m, int[] hp, int[] hn, int[] v) - { - - int a; // counter for codes of length k - int[] c = new int[InfTreeUtil.BMAX + 1]; // bit length count table - int f; // i repeats in table every internalFlush entries - int g; // maximum code length - int h; // table level - int i; // counter, current code - int j; // counter - int k; // number of bits in current code - int l; // bits per table (returned in m) - int mask; // (1 << windowBits) - 1, to avoid cc -O bug on HP - int p; // pointer into c[], buffer[], or v[] - int q; // points to current table - int[] r = new int[3]; // table entry for structure assignment + private static int huft_build(int[] b, int bindex, int n, int s, int[] d, int[] e, int[] t, int[] m, int[] hp, int[] hn, int[] v) { + + int a; // counter for codes of length k + int[] c = new int[InfTreeUtil.BMAX + 1]; // bit length count table + int f; // i repeats in table every internalFlush entries + int g; // maximum code length + int h; // table level + int i; // counter, current code + int j; // counter + int k; // number of bits in current code + int l; // bits per table (returned in m) + int mask; // (1 << windowBits) - 1, to avoid cc -O bug on HP + int p; // pointer into c[], buffer[], or v[] + int q; // points to current table + int[] r = new int[3]; // table entry for structure assignment int[] u = new int[InfTreeUtil.BMAX]; // table stack - int w; // bits before this table == (l * h) + int w; // bits before this table == (l * h) int[] x = new int[InfTreeUtil.BMAX + 1]; // bit offsets, then code stack - int xp; // pointer into x - int y; // number of dummy codes added - int z; // number of entries in current table - - // Generate counts for each bit length - - p = 0; i = n; - do - { - c[b[bindex + p]]++; p++; i--; // assume all entries <= BMAX - } - while (i != 0); - - if (c[0] == n) - { - // null input--all zero length codes - t[0] = - 1; - m[0] = 0; - return (int)ZLibResultCode.Z_OK; - } - - // Find minimum and maximum length, bound *m by those - l = m[0]; + int xp; // pointer into x + int y; // number of dummy codes added + int z; // number of entries in current table + + // Generate counts for each bit length + + p = 0; i = n; + do { + c[b[bindex + p]]++; p++; i--; // assume all entries <= BMAX + } + while (i != 0); + + if (c[0] == n) { + // null input--all zero length codes + t[0] = -1; + m[0] = 0; + return (int)ZLibResultCode.Z_OK; + } + + // Find minimum and maximum length, bound *m by those + l = m[0]; for (j = 1; j <= InfTreeUtil.BMAX; j++) - if (c[j] != 0) - break; - k = j; // minimum code length - if (l < j) - { - l = j; - } - for (i = InfTreeUtil.BMAX; i != 0; i--) - { - if (c[i] != 0) - break; - } - g = i; // maximum code length - if (l > i) - { - l = i; - } - m[0] = l; - - // Adjust last length count to fill out codes, if needed - for (y = 1 << j; j < i; j++, y <<= 1) - { - if ((y -= c[j]) < 0) - { - return (int)ZLibResultCode.Z_DATA_ERROR; - } - } - if ((y -= c[i]) < 0) - { - return (int)ZLibResultCode.Z_DATA_ERROR; - } - c[i] += y; - - // Generate starting offsets into the value table for each length - x[1] = j = 0; - p = 1; xp = 2; - while (--i != 0) - { - // note that i == g from above - x[xp] = (j += c[p]); - xp++; - p++; - } - - // Make a table of values in order of bit lengths - i = 0; p = 0; - do - { - if ((j = b[bindex + p]) != 0) - { - v[x[j]++] = i; - } - p++; - } - while (++i < n); - n = x[g]; // set n to length of v - - // Generate the Huffman codes and for each, make the table entries - x[0] = i = 0; // first Huffman code is zero - p = 0; // grab values in bit order - h = - 1; // no tables yet--level -1 - w = - l; // bits decoded == (l * h) - u[0] = 0; // just to keep compilers happy - q = 0; // ditto - z = 0; // ditto - - // go through the bit lengths (k already is bits in shortest code) - for (; k <= g; k++) - { - a = c[k]; - while (a-- != 0) - { - // here i is the Huffman code of length k bits for value *p - // make tables up to required level - while (k > w + l) - { - h++; - w += l; // previous table always l bits - // compute minimum size table less than or equal to l bits - z = g - w; - z = (z > l)?l:z; // table size upper limit - if ((f = 1 << (j = k - w)) > a + 1) - { - // try a k-windowBits bit table - // too few codes for k-windowBits bit table - f -= (a + 1); // deduct codes from patterns left - xp = k; - if (j < z) - { - while (++j < z) - { - // try smaller tables up to z bits - if ((f <<= 1) <= c[++xp]) - break; // enough codes to use up j bits - f -= c[xp]; // else deduct codes from patterns - } - } - } - z = 1 << j; // table entries for j-bit table - - // allocate new table + if (c[j] != 0) + break; + k = j; // minimum code length + if (l < j) { + l = j; + } + for (i = InfTreeUtil.BMAX; i != 0; i--) { + if (c[i] != 0) + break; + } + g = i; // maximum code length + if (l > i) { + l = i; + } + m[0] = l; + + // Adjust last length count to fill out codes, if needed + for (y = 1 << j; j < i; j++, y <<= 1) { + if ((y -= c[j]) < 0) { + return (int)ZLibResultCode.Z_DATA_ERROR; + } + } + if ((y -= c[i]) < 0) { + return (int)ZLibResultCode.Z_DATA_ERROR; + } + c[i] += y; + + // Generate starting offsets into the value table for each length + x[1] = j = 0; + p = 1; xp = 2; + while (--i != 0) { + // note that i == g from above + x[xp] = (j += c[p]); + xp++; + p++; + } + + // Make a table of values in order of bit lengths + i = 0; p = 0; + do { + if ((j = b[bindex + p]) != 0) { + v[x[j]++] = i; + } + p++; + } + while (++i < n); + n = x[g]; // set n to length of v + + // Generate the Huffman codes and for each, make the table entries + x[0] = i = 0; // first Huffman code is zero + p = 0; // grab values in bit order + h = -1; // no tables yet--level -1 + w = -l; // bits decoded == (l * h) + u[0] = 0; // just to keep compilers happy + q = 0; // ditto + z = 0; // ditto + + // go through the bit lengths (k already is bits in shortest code) + for (; k <= g; k++) { + a = c[k]; + while (a-- != 0) { + // here i is the Huffman code of length k bits for value *p + // make tables up to required level + while (k > w + l) { + h++; + w += l; // previous table always l bits + // compute minimum size table less than or equal to l bits + z = g - w; + z = (z > l) ? l : z; // table size upper limit + if ((f = 1 << (j = k - w)) > a + 1) { + // try a k-windowBits bit table + // too few codes for k-windowBits bit table + f -= (a + 1); // deduct codes from patterns left + xp = k; + if (j < z) { + while (++j < z) { + // try smaller tables up to z bits + if ((f <<= 1) <= c[++xp]) + break; // enough codes to use up j bits + f -= c[xp]; // else deduct codes from patterns + } + } + } + z = 1 << j; // table entries for j-bit table + + // allocate new table if (hn[0] + z > InfTreeUtil.MANY) - // (note: doesn't matter for fixed) - return (int)ZLibResultCode.Z_DATA_ERROR; // overflow of MANY - u[h] = q = hn[0]; // DEBUG - hn[0] += z; - - // connect to last table, if there is one - if (h != 0) - { - x[h] = i; // save pattern for backing up - r[0] = (byte) j; // bits in this table - r[1] = (byte) l; // bits to dump before this table - j = ZLibUtil.URShift(i, (w - l)); - r[2] = (int) (q - u[h - 1] - j); // offset to this table - Array.Copy(r, 0, hp, (u[h - 1] + j) * 3, 3); // connect to last table - } - else - { - t[0] = q; // first table is returned result - } - } - - // set up table entry in r - r[1] = (byte) (k - w); - if (p >= n) - { - r[0] = 128 + 64; // out of values--invalid code - } - else if (v[p] < s) - { - r[0] = (byte) (v[p] < 256?0:32 + 64); // 256 is End-of-block - r[2] = v[p++]; // simple code is just the value - } - else - { - r[0] = (byte) (e[v[p] - s] + 16 + 64); // non-simple--look up in lists - r[2] = d[v[p++] - s]; - } - - // fill code-like entries with r - f = 1 << (k - w); - for (j = ZLibUtil.URShift(i, w); j < z; j += f) - { - Array.Copy(r, 0, hp, (q + j) * 3, 3); - } - - // backwards increment the k-bit code i - for (j = 1 << (k - 1); (i & j) != 0; j = ZLibUtil.URShift(j, 1)) - { - i ^= j; - } - i ^= j; - - // backup over finished tables - mask = (1 << w) - 1; // needed on HP, cc -O bug - while ((i & mask) != x[h]) - { - h--; // don't need to update q - w -= l; - mask = (1 << w) - 1; - } - } - } - // Return (int)ZLibResultCode.Z_DATA_ERROR if we were given an incomplete table + // (note: doesn't matter for fixed) + return (int)ZLibResultCode.Z_DATA_ERROR; // overflow of MANY + u[h] = q = hn[0]; // DEBUG + hn[0] += z; + + // connect to last table, if there is one + if (h != 0) { + x[h] = i; // save pattern for backing up + r[0] = (byte)j; // bits in this table + r[1] = (byte)l; // bits to dump before this table + j = ZLibUtil.URShift(i, (w - l)); + r[2] = (int)(q - u[h - 1] - j); // offset to this table + Array.Copy(r, 0, hp, (u[h - 1] + j) * 3, 3); // connect to last table + } else { + t[0] = q; // first table is returned result + } + } + + // set up table entry in r + r[1] = (byte)(k - w); + if (p >= n) { + r[0] = 128 + 64; // out of values--invalid code + } else if (v[p] < s) { + r[0] = (byte)(v[p] < 256 ? 0 : 32 + 64); // 256 is End-of-block + r[2] = v[p++]; // simple code is just the value + } else { + r[0] = (byte)(e[v[p] - s] + 16 + 64); // non-simple--look up in lists + r[2] = d[v[p++] - s]; + } + + // fill code-like entries with r + f = 1 << (k - w); + for (j = ZLibUtil.URShift(i, w); j < z; j += f) { + Array.Copy(r, 0, hp, (q + j) * 3, 3); + } + + // backwards increment the k-bit code i + for (j = 1 << (k - 1); (i & j) != 0; j = ZLibUtil.URShift(j, 1)) { + i ^= j; + } + i ^= j; + + // backup over finished tables + mask = (1 << w) - 1; // needed on HP, cc -O bug + while ((i & mask) != x[h]) { + h--; // don't need to update q + w -= l; + mask = (1 << w) - 1; + } + } + } + // Return (int)ZLibResultCode.Z_DATA_ERROR if we were given an incomplete table return y != 0 && g != 1 ? (int)ZLibResultCode.Z_BUF_ERROR : (int)ZLibResultCode.Z_OK; - } - + } + /// /// Build trees /// - internal static int inflate_trees_bits(int[] c, int[] bb, int[] tb, int[] hp, ZStream z) - { - int r; - int[] hn = new int[1]; // hufts used in space - int[] v = new int[19]; // work area for huft_build - - r = huft_build(c, 0, 19, 19, null, null, tb, bb, hp, hn, v); - - if (r == (int)ZLibResultCode.Z_DATA_ERROR) - { - z.msg = "oversubscribed dynamic bit lengths tree"; - } - else if (r == (int)ZLibResultCode.Z_DATA_ERROR || bb[0] == 0) - { - z.msg = "incomplete dynamic bit lengths tree"; - r = (int)ZLibResultCode.Z_DATA_ERROR; - } - return r; - } - + internal static int inflate_trees_bits(int[] c, int[] bb, int[] tb, int[] hp, ZStream z) { + int r; + int[] hn = new int[1]; // hufts used in space + int[] v = new int[19]; // work area for huft_build + + r = huft_build(c, 0, 19, 19, null, null, tb, bb, hp, hn, v); + + if (r == (int)ZLibResultCode.Z_DATA_ERROR) { + z.msg = "oversubscribed dynamic bit lengths tree"; + } else if (r == (int)ZLibResultCode.Z_DATA_ERROR || bb[0] == 0) { + z.msg = "incomplete dynamic bit lengths tree"; + r = (int)ZLibResultCode.Z_DATA_ERROR; + } + return r; + } + /// /// Builds dynamic trees /// - internal static int inflate_trees_dynamic(int nl, int nd, int[] c, int[] bl, int[] bd, int[] tl, int[] td, int[] hp, ZStream z) - { - int r; - int[] hn = new int[1]; // hufts used in space - int[] v = new int[288]; // work area for huft_build - - // build literal/length tree + internal static int inflate_trees_dynamic(int nl, int nd, int[] c, int[] bl, int[] bd, int[] tl, int[] td, int[] hp, ZStream z) { + int r; + int[] hn = new int[1]; // hufts used in space + int[] v = new int[288]; // work area for huft_build + + // build literal/length tree r = huft_build(c, 0, nl, 257, InfTreeUtil.cplens, InfTreeUtil.cplext, tl, bl, hp, hn, v); - if (r != (int)ZLibResultCode.Z_OK || bl[0] == 0) - { - if (r == (int)ZLibResultCode.Z_DATA_ERROR) - { - z.msg = "oversubscribed literal/length tree"; - } - else if (r != (int)ZLibResultCode.Z_DATA_ERROR) - { - z.msg = "incomplete literal/length tree"; - r = (int)ZLibResultCode.Z_DATA_ERROR; - } - return r; - } - - // build distance tree + if (r != (int)ZLibResultCode.Z_OK || bl[0] == 0) { + if (r == (int)ZLibResultCode.Z_DATA_ERROR) { + z.msg = "oversubscribed literal/length tree"; + } else if (r != (int)ZLibResultCode.Z_DATA_ERROR) { + z.msg = "incomplete literal/length tree"; + r = (int)ZLibResultCode.Z_DATA_ERROR; + } + return r; + } + + // build distance tree r = huft_build(c, nl, nd, 0, InfTreeUtil.cpdist, InfTreeUtil.cpdext, td, bd, hp, hn, v); - - if (r != (int)ZLibResultCode.Z_OK || (bd[0] == 0 && nl > 257)) - { - if (r == (int)ZLibResultCode.Z_DATA_ERROR) - { - z.msg = "oversubscribed distance tree"; - } - else if (r == (int)ZLibResultCode.Z_DATA_ERROR) - { - z.msg = "incomplete distance tree"; - r = (int)ZLibResultCode.Z_DATA_ERROR; - } - else if (r != (int)ZLibResultCode.Z_DATA_ERROR) - { - z.msg = "empty distance tree with lengths"; - r = (int)ZLibResultCode.Z_DATA_ERROR; - } - return r; - } - - return (int)ZLibResultCode.Z_OK; - } - + + if (r != (int)ZLibResultCode.Z_OK || (bd[0] == 0 && nl > 257)) { + if (r == (int)ZLibResultCode.Z_DATA_ERROR) { + z.msg = "oversubscribed distance tree"; + } else if (r == (int)ZLibResultCode.Z_DATA_ERROR) { + z.msg = "incomplete distance tree"; + r = (int)ZLibResultCode.Z_DATA_ERROR; + } else if (r != (int)ZLibResultCode.Z_DATA_ERROR) { + z.msg = "empty distance tree with lengths"; + r = (int)ZLibResultCode.Z_DATA_ERROR; + } + return r; + } + + return (int)ZLibResultCode.Z_OK; + } + /// /// Build fixed trees /// - internal static int inflate_trees_fixed(int[] bl, int[] bd, int[][] tl, int[][] td, ZStream z) - { + internal static int inflate_trees_fixed(int[] bl, int[] bd, int[][] tl, int[][] td, ZStream z) { bl[0] = InfTreeUtil.fixed_bl; bd[0] = InfTreeUtil.fixed_bd; tl[0] = InfTreeUtil.fixed_tl; td[0] = InfTreeUtil.fixed_td; - return (int)ZLibResultCode.Z_OK; + return (int)ZLibResultCode.Z_OK; } #endregion diff --git a/Src/IronPython.Modules/zlib/zlib.net/Inflate.cs b/Src/IronPython.Modules/zlib/zlib.net/Inflate.cs index 6cf3e0d5b..f50f6375b 100644 --- a/Src/IronPython.Modules/zlib/zlib.net/Inflate.cs +++ b/Src/IronPython.Modules/zlib/zlib.net/Inflate.cs @@ -44,17 +44,15 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using System; using System.Collections.Generic; -namespace ComponentAce.Compression.Libs.ZLib -{ +namespace ComponentAce.Compression.Libs.ZLib { /// /// This enumeration contains modes of inflate processing /// - internal enum InflateMode - { + internal enum InflateMode { /// /// waiting for method byte /// - METHOD = 0, + METHOD = 0, /// /// waiting for flag byte /// @@ -110,15 +108,14 @@ internal enum InflateMode } - internal sealed class Inflate - { + internal sealed class Inflate { #region Fields - /// + /// /// current inflate mode - /// - public InflateMode mode; + /// + public InflateMode mode; #region mode dependent information @@ -126,8 +123,8 @@ internal sealed class Inflate /// if FLAGS, method byte /// private int method; - - // if CHECK, check values to compare + + // if CHECK, check values to compare /// /// computed check value @@ -138,10 +135,10 @@ internal sealed class Inflate /// stream check value /// private long need; - - /// + + /// /// if BAD, inflateSync's marker bytes count - /// + /// private int marker; #endregion @@ -150,15 +147,15 @@ internal sealed class Inflate /// /// flag for no wrapper /// - private int nowrap; + private int nowrap; /// /// log2(Window size) (8..15, defaults to 15) /// private int wbits; - private IEnumerator gzipHeaderRemover; + private IEnumerator gzipHeaderRemover; - private bool detectHeader; + private bool detectHeader; #endregion @@ -166,7 +163,7 @@ internal sealed class Inflate /// current inflate_blocks state /// private InfBlocks blocks; - + #endregion #region Methods @@ -176,30 +173,28 @@ internal sealed class Inflate /// /// A ZStream object /// A result code - internal int inflateReset(ZStream z) - { + internal int inflateReset(ZStream z) { if (z?.istate == null) return (int)ZLibResultCode.Z_STREAM_ERROR; - + z.total_in = z.total_out = 0; z.msg = null; - z.istate.mode = z.istate.nowrap != 0? InflateMode.BLOCKS: InflateMode.METHOD; + z.istate.mode = z.istate.nowrap != 0 ? InflateMode.BLOCKS : InflateMode.METHOD; z.istate.blocks.reset(z, null); return (int)ZLibResultCode.Z_OK; } - + /// /// Finishes the inflate algorithm processing /// /// A ZStream object /// Operation result code - internal int inflateEnd(ZStream z) - { - blocks?.free(z); - blocks = null; - // ZFREE(z, z->state); - return (int)ZLibResultCode.Z_OK; - } + internal int inflateEnd(ZStream z) { + blocks?.free(z); + blocks = null; + // ZFREE(z, z->state); + return (int)ZLibResultCode.Z_OK; + } /// /// Initializes the inflate algorithm @@ -207,46 +202,39 @@ internal int inflateEnd(ZStream z) /// A ZStream object /// Window size /// Operation result code - internal int inflateInit(ZStream z, int windowBits) - { - z.msg = null; - blocks = null; - - // handle undocumented nowrap option (no zlib header or check) - nowrap = 0; + internal int inflateInit(ZStream z, int windowBits) { + z.msg = null; + blocks = null; + + // handle undocumented nowrap option (no zlib header or check) + nowrap = 0; detectHeader = false; - if (windowBits < 0) - { + if (windowBits < 0) { // deflate, no header - windowBits = - windowBits; - nowrap = 1; - } - else if ((windowBits & 16) != 0) - { + windowBits = -windowBits; + nowrap = 1; + } else if ((windowBits & 16) != 0) { gzipHeaderRemover = GzipHeader.CreateRemover(z); windowBits &= ~16; - } - else if ((windowBits & 32) != 0) - { + } else if ((windowBits & 32) != 0) { detectHeader = true; windowBits &= ~32; } - // set Window size - if (windowBits < 8 || windowBits > 15) - { - inflateEnd(z); - return (int)ZLibResultCode.Z_STREAM_ERROR; - } - wbits = windowBits; - - z.istate.blocks = new InfBlocks(z, z.istate.nowrap == 0, 1 << windowBits); - - // reset state - inflateReset(z); - return (int)ZLibResultCode.Z_OK; - } + // set Window size + if (windowBits < 8 || windowBits > 15) { + inflateEnd(z); + return (int)ZLibResultCode.Z_STREAM_ERROR; + } + wbits = windowBits; + + z.istate.blocks = new InfBlocks(z, z.istate.nowrap == 0, 1 << windowBits); + + // reset state + inflateReset(z); + return (int)ZLibResultCode.Z_OK; + } /// @@ -255,19 +243,17 @@ internal int inflateInit(ZStream z, int windowBits) /// A ZStream object /// Flush strategy /// Operation result code - internal int inflate(ZStream z, FlushStrategy flush) - { - int internalFlush = (int)flush; + internal int inflate(ZStream z, FlushStrategy flush) { + int internalFlush = (int)flush; - if (z?.istate == null || z.next_in == null) + if (z?.istate == null || z.next_in == null) return (int)ZLibResultCode.Z_STREAM_ERROR; - int res_temp = internalFlush == (int)FlushStrategy.Z_FINISH - ? (int)ZLibResultCode.Z_BUF_ERROR - : (int)ZLibResultCode.Z_OK; - int r = (int)ZLibResultCode.Z_BUF_ERROR; + int res_temp = internalFlush == (int)FlushStrategy.Z_FINISH + ? (int)ZLibResultCode.Z_BUF_ERROR + : (int)ZLibResultCode.Z_OK; + int r = (int)ZLibResultCode.Z_BUF_ERROR; - if (detectHeader) - { + if (detectHeader) { if (z.avail_in == 0) return r; if (z.next_in[z.next_in_index] == 0x1F) @@ -275,8 +261,7 @@ internal int inflate(ZStream z, FlushStrategy flush) detectHeader = false; } - if (gzipHeaderRemover != null) - { + if (gzipHeaderRemover != null) { if (z.avail_in == 0) return r; if (gzipHeaderRemover.MoveNext()) @@ -287,300 +272,276 @@ internal int inflate(ZStream z, FlushStrategy flush) nowrap = 1; } - while (true) - { + while (true) { - switch (z.istate.mode) - { - - case InflateMode.METHOD: - - if (z.avail_in == 0) + switch (z.istate.mode) { + + case InflateMode.METHOD: + + if (z.avail_in == 0) return r; r = res_temp; - - z.avail_in--; z.total_in++; - if (((z.istate.method = z.next_in[z.next_in_index++]) & 0xf) != ZLibUtil.Z_DEFLATED) - { - z.istate.mode = InflateMode.BAD; - z.msg = "unknown compression method"; - z.istate.marker = 5; // can't try inflateSync - break; - } - if ((z.istate.method >> 4) + 8 > z.istate.wbits) - { - z.istate.mode = InflateMode.BAD; - z.msg = "invalid Window size"; - z.istate.marker = 5; // can't try inflateSync - break; - } - z.istate.mode = InflateMode.FLAG; - goto case InflateMode.FLAG; - - case InflateMode.FLAG: - - if (z.avail_in == 0) + + z.avail_in--; z.total_in++; + if (((z.istate.method = z.next_in[z.next_in_index++]) & 0xf) != ZLibUtil.Z_DEFLATED) { + z.istate.mode = InflateMode.BAD; + z.msg = "unknown compression method"; + z.istate.marker = 5; // can't try inflateSync + break; + } + if ((z.istate.method >> 4) + 8 > z.istate.wbits) { + z.istate.mode = InflateMode.BAD; + z.msg = "invalid Window size"; + z.istate.marker = 5; // can't try inflateSync + break; + } + z.istate.mode = InflateMode.FLAG; + goto case InflateMode.FLAG; + + case InflateMode.FLAG: + + if (z.avail_in == 0) return r; r = res_temp; - - z.avail_in--; z.total_in++; - int b = (z.next_in[z.next_in_index++]) & 0xff; - - if ((((z.istate.method << 8) + b) % 31) != 0) - { - z.istate.mode = InflateMode.BAD; - z.msg = "incorrect header check"; - z.istate.marker = 5; // can't try inflateSync - break; - } - - if ((b & ZLibUtil.PRESET_DICT) == 0) - { - z.istate.mode = InflateMode.BLOCKS; - break; - } - z.istate.mode = InflateMode.DICT4; - goto case InflateMode.DICT4; - - case InflateMode.DICT4: - - if (z.avail_in == 0) + + z.avail_in--; z.total_in++; + int b = (z.next_in[z.next_in_index++]) & 0xff; + + if ((((z.istate.method << 8) + b) % 31) != 0) { + z.istate.mode = InflateMode.BAD; + z.msg = "incorrect header check"; + z.istate.marker = 5; // can't try inflateSync + break; + } + + if ((b & ZLibUtil.PRESET_DICT) == 0) { + z.istate.mode = InflateMode.BLOCKS; + break; + } + z.istate.mode = InflateMode.DICT4; + goto case InflateMode.DICT4; + + case InflateMode.DICT4: + + if (z.avail_in == 0) return r; r = res_temp; - - z.avail_in--; z.total_in++; - z.istate.need = ((long)(z.next_in[z.next_in_index++] & 0xff) << 24) & unchecked((int) 0xff000000L); - z.istate.mode = InflateMode.DICT3; - goto case InflateMode.DICT3; - - case InflateMode.DICT3: - - if (z.avail_in == 0) + + z.avail_in--; z.total_in++; + z.istate.need = ((long)(z.next_in[z.next_in_index++] & 0xff) << 24) & unchecked((int)0xff000000L); + z.istate.mode = InflateMode.DICT3; + goto case InflateMode.DICT3; + + case InflateMode.DICT3: + + if (z.avail_in == 0) return r; r = res_temp; - - z.avail_in--; z.total_in++; - z.istate.need += (((long)(z.next_in[z.next_in_index++] & 0xff) << 16) & 0xff0000L); - z.istate.mode = InflateMode.DICT2; - goto case InflateMode.DICT2; - - case InflateMode.DICT2: - - if (z.avail_in == 0) + + z.avail_in--; z.total_in++; + z.istate.need += (((long)(z.next_in[z.next_in_index++] & 0xff) << 16) & 0xff0000L); + z.istate.mode = InflateMode.DICT2; + goto case InflateMode.DICT2; + + case InflateMode.DICT2: + + if (z.avail_in == 0) return r; r = res_temp; - - z.avail_in--; z.total_in++; - z.istate.need += (((long)(z.next_in[z.next_in_index++] & 0xff) << 8) & 0xff00L); - z.istate.mode = InflateMode.DICT1; - goto case InflateMode.DICT1; - - case InflateMode.DICT1: - - if (z.avail_in == 0) + + z.avail_in--; z.total_in++; + z.istate.need += (((long)(z.next_in[z.next_in_index++] & 0xff) << 8) & 0xff00L); + z.istate.mode = InflateMode.DICT1; + goto case InflateMode.DICT1; + + case InflateMode.DICT1: + + if (z.avail_in == 0) return r; r = res_temp; - - z.avail_in--; z.total_in++; - z.istate.need += (z.next_in[z.next_in_index++] & 0xffL); - z.adler = z.istate.need; - z.istate.mode = InflateMode.DICT0; - return (int)ZLibResultCode.Z_NEED_DICT; - - case InflateMode.DICT0: - z.istate.mode = InflateMode.BAD; - z.msg = "need dictionary"; - z.istate.marker = 0; // can try inflateSync - return (int)ZLibResultCode.Z_STREAM_ERROR; - - case InflateMode.BLOCKS: - r = z.istate.blocks.proc(z, r); - if (r == (int)ZLibResultCode.Z_DATA_ERROR) - { - z.istate.mode = InflateMode.BAD; - z.istate.marker = 0; // can try inflateSync - break; - } - if (r == (int)ZLibResultCode.Z_OK) - { + + z.avail_in--; z.total_in++; + z.istate.need += (z.next_in[z.next_in_index++] & 0xffL); + z.adler = z.istate.need; + z.istate.mode = InflateMode.DICT0; + return (int)ZLibResultCode.Z_NEED_DICT; + + case InflateMode.DICT0: + z.istate.mode = InflateMode.BAD; + z.msg = "need dictionary"; + z.istate.marker = 0; // can try inflateSync + return (int)ZLibResultCode.Z_STREAM_ERROR; + + case InflateMode.BLOCKS: + r = z.istate.blocks.proc(z, r); + if (r == (int)ZLibResultCode.Z_DATA_ERROR) { + z.istate.mode = InflateMode.BAD; + z.istate.marker = 0; // can try inflateSync + break; + } + if (r == (int)ZLibResultCode.Z_OK) { r = res_temp; - } - if (r != (int)ZLibResultCode.Z_STREAM_END) - { - return r; - } + } + if (r != (int)ZLibResultCode.Z_STREAM_END) { + return r; + } r = res_temp; - z.istate.blocks.reset(z, z.istate.was); - if (z.istate.nowrap != 0) - { - z.istate.mode = InflateMode.DONE; - break; - } - z.istate.mode = InflateMode.CHECK4; - goto case InflateMode.CHECK4; - - case InflateMode.CHECK4: - - if (z.avail_in == 0) + z.istate.blocks.reset(z, z.istate.was); + if (z.istate.nowrap != 0) { + z.istate.mode = InflateMode.DONE; + break; + } + z.istate.mode = InflateMode.CHECK4; + goto case InflateMode.CHECK4; + + case InflateMode.CHECK4: + + if (z.avail_in == 0) return r; r = res_temp; - - z.avail_in--; z.total_in++; - z.istate.need = ((z.next_in[z.next_in_index++] & 0xff) << 24) & unchecked((int) 0xff000000L); - z.istate.mode = InflateMode.CHECK3; - goto case InflateMode.CHECK3; - - case InflateMode.CHECK3: - - if (z.avail_in == 0) + + z.avail_in--; z.total_in++; + z.istate.need = ((z.next_in[z.next_in_index++] & 0xff) << 24) & unchecked((int)0xff000000L); + z.istate.mode = InflateMode.CHECK3; + goto case InflateMode.CHECK3; + + case InflateMode.CHECK3: + + if (z.avail_in == 0) return r; r = res_temp; - - z.avail_in--; z.total_in++; - z.istate.need += (((z.next_in[z.next_in_index++] & 0xff) << 16) & 0xff0000L); - z.istate.mode = InflateMode.CHECK2; - goto case InflateMode.CHECK2; - - case InflateMode.CHECK2: - - if (z.avail_in == 0) + + z.avail_in--; z.total_in++; + z.istate.need += (((z.next_in[z.next_in_index++] & 0xff) << 16) & 0xff0000L); + z.istate.mode = InflateMode.CHECK2; + goto case InflateMode.CHECK2; + + case InflateMode.CHECK2: + + if (z.avail_in == 0) return r; r = res_temp; - - z.avail_in--; z.total_in++; - z.istate.need += (((z.next_in[z.next_in_index++] & 0xff) << 8) & 0xff00L); - z.istate.mode = InflateMode.CHECK1; - goto case InflateMode.CHECK1; - - case InflateMode.CHECK1: - - if (z.avail_in == 0) + + z.avail_in--; z.total_in++; + z.istate.need += (((z.next_in[z.next_in_index++] & 0xff) << 8) & 0xff00L); + z.istate.mode = InflateMode.CHECK1; + goto case InflateMode.CHECK1; + + case InflateMode.CHECK1: + + if (z.avail_in == 0) return r; r = res_temp; - - z.avail_in--; z.total_in++; - z.istate.need += (z.next_in[z.next_in_index++] & 0xffL); - - if (unchecked(((int) (z.istate.was[0])) != ((int) (z.istate.need)))) - { - z.istate.mode = InflateMode.BAD; - z.msg = "incorrect data check"; - z.istate.marker = 5; // can't try inflateSync - break; - } - - z.istate.mode = InflateMode.DONE; - goto case InflateMode.DONE; - - case InflateMode.DONE: - return (int)ZLibResultCode.Z_STREAM_END; - - case InflateMode.BAD: - return (int)ZLibResultCode.Z_DATA_ERROR; - - default: - return (int)ZLibResultCode.Z_STREAM_ERROR; - - } - } - } - - /// - /// Sets dictionary for the inflate operation - /// - /// A ZStream object - /// An array of byte - dictionary - /// Dictionary length - /// Operation result code - internal int inflateSetDictionary(ZStream z, byte[] dictionary, int dictLength) - { - int index = 0; - int length = dictLength; - if (z?.istate?.mode != InflateMode.DICT0) - return (int)ZLibResultCode.Z_STREAM_ERROR; - - if (Adler32.GetAdler32Checksum(1L, dictionary, 0, dictLength) != z.adler) - { - return (int)ZLibResultCode.Z_DATA_ERROR; - } - - z.adler = Adler32.GetAdler32Checksum(0, null, 0, 0); - - if (length >= (1 << z.istate.wbits)) - { - length = (1 << z.istate.wbits) - 1; - index = dictLength - length; - } - z.istate.blocks.set_dictionary(dictionary, index, length); - z.istate.mode = InflateMode.BLOCKS; - return (int)ZLibResultCode.Z_OK; - } - - + + z.avail_in--; z.total_in++; + z.istate.need += (z.next_in[z.next_in_index++] & 0xffL); + + if (unchecked(((int)(z.istate.was[0])) != ((int)(z.istate.need)))) { + z.istate.mode = InflateMode.BAD; + z.msg = "incorrect data check"; + z.istate.marker = 5; // can't try inflateSync + break; + } + + z.istate.mode = InflateMode.DONE; + goto case InflateMode.DONE; + + case InflateMode.DONE: + return (int)ZLibResultCode.Z_STREAM_END; + + case InflateMode.BAD: + return (int)ZLibResultCode.Z_DATA_ERROR; + + default: + return (int)ZLibResultCode.Z_STREAM_ERROR; + + } + } + } + + /// + /// Sets dictionary for the inflate operation + /// + /// A ZStream object + /// An array of byte - dictionary + /// Dictionary length + /// Operation result code + internal int inflateSetDictionary(ZStream z, byte[] dictionary, int dictLength) { + int index = 0; + int length = dictLength; + if (z?.istate?.mode != InflateMode.DICT0) + return (int)ZLibResultCode.Z_STREAM_ERROR; + + if (Adler32.GetAdler32Checksum(1L, dictionary, 0, dictLength) != z.adler) { + return (int)ZLibResultCode.Z_DATA_ERROR; + } + + z.adler = Adler32.GetAdler32Checksum(0, null, 0, 0); + + if (length >= (1 << z.istate.wbits)) { + length = (1 << z.istate.wbits) - 1; + index = dictLength - length; + } + z.istate.blocks.set_dictionary(dictionary, index, length); + z.istate.mode = InflateMode.BLOCKS; + return (int)ZLibResultCode.Z_OK; + } + + /// /// Inflate synchronization /// /// A ZStream object /// Operation result code - internal int inflateSync(ZStream z) - { - int n; // number of bytes to look at - int p; // pointer to bytes - int m; // number of marker bytes found in a row - long r, w; // temporaries to save _total_in and _total_out - - // set up - if (z?.istate == null) - return (int)ZLibResultCode.Z_STREAM_ERROR; - if (z.istate.mode != InflateMode.BAD) - { - z.istate.mode = InflateMode.BAD; - z.istate.marker = 0; - } - if ((n = z.avail_in) == 0) - return (int)ZLibResultCode.Z_BUF_ERROR; - p = z.next_in_index; - m = z.istate.marker; - - // search - while (n != 0 && m < 4) - { - if (z.next_in[p] == ZLibUtil.mark[m]) - { - m++; - } - else if (z.next_in[p] != 0) - { - m = 0; - } - else - { - m = 4 - m; - } - p++; n--; - } - - // restore - z.total_in += p - z.next_in_index; - z.next_in_index = p; - z.avail_in = n; - z.istate.marker = m; - - // return no joy or set up to restart on a new block - if (m != 4) - { - return (int)ZLibResultCode.Z_DATA_ERROR; - } - r = z.total_in; w = z.total_out; - inflateReset(z); - z.total_in = r; z.total_out = w; - z.istate.mode = InflateMode.BLOCKS; - return (int)ZLibResultCode.Z_OK; - } - + internal int inflateSync(ZStream z) { + int n; // number of bytes to look at + int p; // pointer to bytes + int m; // number of marker bytes found in a row + long r, w; // temporaries to save _total_in and _total_out + + // set up + if (z?.istate == null) + return (int)ZLibResultCode.Z_STREAM_ERROR; + if (z.istate.mode != InflateMode.BAD) { + z.istate.mode = InflateMode.BAD; + z.istate.marker = 0; + } + if ((n = z.avail_in) == 0) + return (int)ZLibResultCode.Z_BUF_ERROR; + p = z.next_in_index; + m = z.istate.marker; + + // search + while (n != 0 && m < 4) { + if (z.next_in[p] == ZLibUtil.mark[m]) { + m++; + } else if (z.next_in[p] != 0) { + m = 0; + } else { + m = 4 - m; + } + p++; n--; + } + + // restore + z.total_in += p - z.next_in_index; + z.next_in_index = p; + z.avail_in = n; + z.istate.marker = m; + + // return no joy or set up to restart on a new block + if (m != 4) { + return (int)ZLibResultCode.Z_DATA_ERROR; + } + r = z.total_in; w = z.total_out; + inflateReset(z); + z.total_in = r; z.total_out = w; + z.istate.mode = InflateMode.BLOCKS; + return (int)ZLibResultCode.Z_OK; + } + /// - /// Returns true if inflate is currently at the End of a block generated - /// by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP - /// implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH - /// but removes the length bytes of the resulting empty stored block. When - /// decompressing, PPP checks that at the End of input packet, inflate is - /// waiting for these length bytes. + /// Returns true if inflate is currently at the End of a block generated + /// by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP + /// implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH + /// but removes the length bytes of the resulting empty stored block. When + /// decompressing, PPP checks that at the End of input packet, inflate is + /// waiting for these length bytes. /// - internal int inflateSyncPoint(ZStream z) - { - if (z?.istate?.blocks == null) - return (int)ZLibResultCode.Z_STREAM_ERROR; - return z.istate.blocks.sync_point(); + internal int inflateSyncPoint(ZStream z) { + if (z?.istate?.blocks == null) + return (int)ZLibResultCode.Z_STREAM_ERROR; + return z.istate.blocks.sync_point(); } #endregion diff --git a/Src/IronPython.Modules/zlib/zlib.net/StaticTree.cs b/Src/IronPython.Modules/zlib/zlib.net/StaticTree.cs index cf7f7ec0b..4349421b7 100644 --- a/Src/IronPython.Modules/zlib/zlib.net/StaticTree.cs +++ b/Src/IronPython.Modules/zlib/zlib.net/StaticTree.cs @@ -42,58 +42,54 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * and contributors of zlib. */ -namespace ComponentAce.Compression.Libs.ZLib -{ - - internal sealed class StaticTree - { +namespace ComponentAce.Compression.Libs.ZLib { + + internal sealed class StaticTree { #region Fields - - private const int BL_CODES = 19; - private const int D_CODES = 30; - private const int LITERALS = 256; - private const int LENGTH_CODES = 29; - private const int L_CODES = (LITERALS + 1 + LENGTH_CODES); - - /// + + private const int BL_CODES = 19; + private const int D_CODES = 30; + private const int LITERALS = 256; + private const int LENGTH_CODES = 29; + private const int L_CODES = (LITERALS + 1 + LENGTH_CODES); + + /// /// Bit length codes must not exceed MAX_BL_BITS bits - /// - internal const int MAX_BL_BITS = 7; - - internal static readonly short[] static_ltree = new short[]{12, 8, 140, 8, 76, 8, 204, 8, 44, 8, 172, 8, 108, 8, 236, 8, 28, 8, 156, 8, 92, 8, 220, 8, 60, 8, 188, 8, 124, 8, 252, 8, 2, 8, 130, 8, 66, 8, 194, 8, 34, 8, 162, 8, 98, 8, 226, 8, 18, 8, 146, 8, 82, 8, 210, 8, 50, 8, 178, 8, 114, 8, 242, 8, 10, 8, 138, 8, 74, 8, 202, 8, 42, 8, 170, 8, 106, 8, 234, 8, 26, 8, 154, 8, 90, 8, 218, 8, 58, 8, 186, 8, 122, 8, 250, 8, 6, 8, 134, 8, 70, 8, 198, 8, 38, 8, 166, 8, 102, 8, 230, 8, 22, 8, 150, 8, 86, 8, 214, 8, 54, 8, 182, 8, 118, 8, 246, 8, 14, 8, 142, 8, 78, 8, 206, 8, 46, 8, 174, 8, 110, 8, 238, 8, 30, 8, 158, 8, 94, 8, 222, 8, 62, 8, 190, 8, 126, 8, 254, 8, 1, 8, 129, 8, 65, 8, 193, 8, 33, 8, 161, 8, 97, 8, 225, 8, 17, 8, 145, 8, 81, 8, 209, 8, 49, 8, 177, 8, 113, 8, 241, 8, 9, 8, 137, 8, 73, 8, 201, 8, 41, 8, 169, 8, 105, 8, 233, 8, 25, 8, 153, 8, 89, 8, 217, 8, 57, 8, 185, 8, 121, 8, 249, 8, 5, 8, 133, 8, 69, 8, 197, 8, 37, 8, 165, 8, 101, 8, 229, 8, 21, 8, 149, 8, 85, 8, 213, 8, 53, 8, 181, 8, 117, 8, 245, 8, 13, 8, 141, 8, 77, 8, 205, 8, 45, 8, 173, 8, 109, 8, 237, 8, 29, 8, 157, 8, 93, 8, 221, 8, 61, 8, 189, 8, 125, 8, 253, 8, 19, 9, 275, 9, 147, 9, 403, 9, 83, 9, 339, 9, 211, 9, 467, 9, 51, 9, 307, 9, 179, 9, 435, 9, 115, 9, 371, 9, 243, 9, 499, 9, 11, 9, 267, 9, 139, 9, 395, 9, 75, 9, 331, 9, 203, 9, 459, 9, 43, 9, 299, 9, 171, 9, 427, 9, 107, 9, 363, 9, 235, 9, 491, 9, 27, 9, 283, 9, 155, 9, 411, 9, 91, 9, 347, 9, 219, 9, 475, 9, 59, 9, 315, 9, 187, 9, 443, 9, 123, 9, 379, 9, 251, 9, 507, 9, 7, 9, 263, 9, 135, 9, 391, 9, 71, 9, 327, 9, 199, 9, 455, 9, 39, 9, 295, 9, 167, 9, 423, 9, 103, 9, 359, 9, 231, 9, 487, 9, 23, 9, 279, 9, 151, 9, 407, 9, 87, 9, 343, 9, 215, 9, 471, 9, 55, 9, 311, 9, 183, 9, 439, 9, 119, 9, 375, 9, 247, 9, 503, 9, 15, 9, 271, 9, 143, 9, 399, 9, 79, 9, 335, 9, 207, 9, 463, 9, 47, 9, 303, 9, 175, 9, 431, 9, 111, 9, 367, 9, 239, 9, 495, 9, 31, 9, 287, 9, 159, 9, 415, 9, 95, 9, 351, 9, 223, 9, 479, 9, 63, 9, 319, 9, 191, 9, 447, 9, 127, 9, 383, 9, 255, 9, 511, 9, 0, 7, 64, 7 - , 32, 7, 96, 7, 16, 7, 80, 7, 48, 7, 112, 7, 8, 7, 72, 7, 40, 7, 104, 7, 24, 7, 88, 7, 56, 7, 120, 7, 4, 7, 68, 7, 36, 7, 100, 7, 20, 7, 84, 7, 52, 7, 116, 7, 3, 8, 131, 8, 67, 8, 195, 8, 35, 8, 163, 8, 99, 8, 227, 8}; + /// + internal const int MAX_BL_BITS = 7; + + internal static readonly short[] static_ltree = new short[]{12, 8, 140, 8, 76, 8, 204, 8, 44, 8, 172, 8, 108, 8, 236, 8, 28, 8, 156, 8, 92, 8, 220, 8, 60, 8, 188, 8, 124, 8, 252, 8, 2, 8, 130, 8, 66, 8, 194, 8, 34, 8, 162, 8, 98, 8, 226, 8, 18, 8, 146, 8, 82, 8, 210, 8, 50, 8, 178, 8, 114, 8, 242, 8, 10, 8, 138, 8, 74, 8, 202, 8, 42, 8, 170, 8, 106, 8, 234, 8, 26, 8, 154, 8, 90, 8, 218, 8, 58, 8, 186, 8, 122, 8, 250, 8, 6, 8, 134, 8, 70, 8, 198, 8, 38, 8, 166, 8, 102, 8, 230, 8, 22, 8, 150, 8, 86, 8, 214, 8, 54, 8, 182, 8, 118, 8, 246, 8, 14, 8, 142, 8, 78, 8, 206, 8, 46, 8, 174, 8, 110, 8, 238, 8, 30, 8, 158, 8, 94, 8, 222, 8, 62, 8, 190, 8, 126, 8, 254, 8, 1, 8, 129, 8, 65, 8, 193, 8, 33, 8, 161, 8, 97, 8, 225, 8, 17, 8, 145, 8, 81, 8, 209, 8, 49, 8, 177, 8, 113, 8, 241, 8, 9, 8, 137, 8, 73, 8, 201, 8, 41, 8, 169, 8, 105, 8, 233, 8, 25, 8, 153, 8, 89, 8, 217, 8, 57, 8, 185, 8, 121, 8, 249, 8, 5, 8, 133, 8, 69, 8, 197, 8, 37, 8, 165, 8, 101, 8, 229, 8, 21, 8, 149, 8, 85, 8, 213, 8, 53, 8, 181, 8, 117, 8, 245, 8, 13, 8, 141, 8, 77, 8, 205, 8, 45, 8, 173, 8, 109, 8, 237, 8, 29, 8, 157, 8, 93, 8, 221, 8, 61, 8, 189, 8, 125, 8, 253, 8, 19, 9, 275, 9, 147, 9, 403, 9, 83, 9, 339, 9, 211, 9, 467, 9, 51, 9, 307, 9, 179, 9, 435, 9, 115, 9, 371, 9, 243, 9, 499, 9, 11, 9, 267, 9, 139, 9, 395, 9, 75, 9, 331, 9, 203, 9, 459, 9, 43, 9, 299, 9, 171, 9, 427, 9, 107, 9, 363, 9, 235, 9, 491, 9, 27, 9, 283, 9, 155, 9, 411, 9, 91, 9, 347, 9, 219, 9, 475, 9, 59, 9, 315, 9, 187, 9, 443, 9, 123, 9, 379, 9, 251, 9, 507, 9, 7, 9, 263, 9, 135, 9, 391, 9, 71, 9, 327, 9, 199, 9, 455, 9, 39, 9, 295, 9, 167, 9, 423, 9, 103, 9, 359, 9, 231, 9, 487, 9, 23, 9, 279, 9, 151, 9, 407, 9, 87, 9, 343, 9, 215, 9, 471, 9, 55, 9, 311, 9, 183, 9, 439, 9, 119, 9, 375, 9, 247, 9, 503, 9, 15, 9, 271, 9, 143, 9, 399, 9, 79, 9, 335, 9, 207, 9, 463, 9, 47, 9, 303, 9, 175, 9, 431, 9, 111, 9, 367, 9, 239, 9, 495, 9, 31, 9, 287, 9, 159, 9, 415, 9, 95, 9, 351, 9, 223, 9, 479, 9, 63, 9, 319, 9, 191, 9, 447, 9, 127, 9, 383, 9, 255, 9, 511, 9, 0, 7, 64, 7 + , 32, 7, 96, 7, 16, 7, 80, 7, 48, 7, 112, 7, 8, 7, 72, 7, 40, 7, 104, 7, 24, 7, 88, 7, 56, 7, 120, 7, 4, 7, 68, 7, 36, 7, 100, 7, 20, 7, 84, 7, 52, 7, 116, 7, 3, 8, 131, 8, 67, 8, 195, 8, 35, 8, 163, 8, 99, 8, 227, 8}; internal static readonly short[] static_dtree = new short[] { 0, 5, 16, 5, 8, 5, 24, 5, 4, 5, 20, 5, 12, 5, 28, 5, 2, 5, 18, 5, 10, 5, 26, 5, 6, 5, 22, 5, 14, 5, 30, 5, 1, 5, 17, 5, 9, 5, 25, 5, 5, 5, 21, 5, 13, 5, 29, 5, 3, 5, 19, 5, 11, 5, 27, 5, 7, 5, 23, 5 }; - - internal static StaticTree static_l_desc; - - internal static StaticTree static_d_desc; - - internal static StaticTree static_bl_desc; - - internal short[] static_tree; // static tree or null - internal int[] extra_bits; // extra bits for each code or null - internal int extra_base; // base index for extra_bits - internal int elems; // max number of elements in the tree - internal int max_length; // max bit length for the codes + + internal static StaticTree static_l_desc; + + internal static StaticTree static_d_desc; + + internal static StaticTree static_bl_desc; + + internal short[] static_tree; // static tree or null + internal int[] extra_bits; // extra bits for each code or null + internal int extra_base; // base index for extra_bits + internal int elems; // max number of elements in the tree + internal int max_length; // max bit length for the codes #endregion #region Constructors - internal StaticTree(short[] static_tree, int[] extra_bits, int extra_base, int elems, int max_length) - { - this.static_tree = static_tree; - this.extra_bits = extra_bits; - this.extra_base = extra_base; - this.elems = elems; - this.max_length = max_length; - } - static StaticTree() - { - static_l_desc = new StaticTree(static_ltree, ZLibUtil.extra_lbits, LITERALS + 1, L_CODES, ZLibUtil.MAX_WBITS); + internal StaticTree(short[] static_tree, int[] extra_bits, int extra_base, int elems, int max_length) { + this.static_tree = static_tree; + this.extra_bits = extra_bits; + this.extra_base = extra_base; + this.elems = elems; + this.max_length = max_length; + } + static StaticTree() { + static_l_desc = new StaticTree(static_ltree, ZLibUtil.extra_lbits, LITERALS + 1, L_CODES, ZLibUtil.MAX_WBITS); static_d_desc = new StaticTree(static_dtree, ZLibUtil.extra_dbits, 0, D_CODES, ZLibUtil.MAX_WBITS); static_bl_desc = new StaticTree(null, ZLibUtil.extra_blbits, 0, BL_CODES, MAX_BL_BITS); } diff --git a/Src/IronPython.Modules/zlib/zlib.net/Tree.cs b/Src/IronPython.Modules/zlib/zlib.net/Tree.cs index 576be2f1b..8f5e26b30 100644 --- a/Src/IronPython.Modules/zlib/zlib.net/Tree.cs +++ b/Src/IronPython.Modules/zlib/zlib.net/Tree.cs @@ -41,16 +41,12 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) * and contributors of zlib. */ -using System; +namespace ComponentAce.Compression.Libs.ZLib { -namespace ComponentAce.Compression.Libs.ZLib -{ - /// /// This class represents a tree and is used in the Deflate class /// - internal sealed class Tree - { + internal sealed class Tree { #region Fields @@ -76,8 +72,7 @@ internal sealed class Tree /// /// The dynamic tree /// - public short[] DynTree - { + public short[] DynTree { get { return dyn_tree; } set { dyn_tree = value; } } @@ -85,16 +80,14 @@ public short[] DynTree /// /// Largest code with non zero frequency /// - public int MaxCode - { + public int MaxCode { get { return max_code; } set { max_code = value; } } /// /// the corresponding static tree /// - internal StaticTree StatDesc - { + internal StaticTree StatDesc { get { return stat_desc; } set { stat_desc = value; } } @@ -108,101 +101,93 @@ internal StaticTree StatDesc /// must not have side effects. _dist_code[256] and _dist_code[257] are never /// used. /// - internal static int d_code(int dist) - { + internal static int d_code(int dist) { return ((dist) < 256 ? ZLibUtil._dist_code[dist] : ZLibUtil._dist_code[256 + (ZLibUtil.URShift((dist), 7))]); - } - - /// - /// Compute the optimal bit lengths for a tree and update the total bit length - /// for the current block. - /// IN assertion: the fields freq and dad are set, heap[heap_max] and - /// above are the tree nodes sorted by increasing frequency. - /// OUT assertions: the field count is set to the optimal bit length, the - /// array bl_count contains the frequencies for each bit length. - /// The length opt_len is updated; static_len is also updated if stree is - /// not null. + } + + /// + /// Compute the optimal bit lengths for a tree and update the total bit length + /// for the current block. + /// IN assertion: the fields freq and dad are set, heap[heap_max] and + /// above are the tree nodes sorted by increasing frequency. + /// OUT assertions: the field count is set to the optimal bit length, the + /// array bl_count contains the frequencies for each bit length. + /// The length opt_len is updated; static_len is also updated if stree is + /// not null. /// - private void gen_bitlen(Deflate s) - { - short[] tree = dyn_tree; - short[] stree = stat_desc.static_tree; - int[] extra = stat_desc.extra_bits; - int base_Renamed = stat_desc.extra_base; - int max_length = stat_desc.max_length; - int h; // heap index - int n, m; // iterate over the tree elements - int bits; // bit length - int xbits; // extra bits - short f; // frequency - int overflow = 0; // number of elements with bit length too large + private void gen_bitlen(Deflate s) { + short[] tree = dyn_tree; + short[] stree = stat_desc.static_tree; + int[] extra = stat_desc.extra_bits; + int base_Renamed = stat_desc.extra_base; + int max_length = stat_desc.max_length; + int h; // heap index + int n, m; // iterate over the tree elements + int bits; // bit length + int xbits; // extra bits + short f; // frequency + int overflow = 0; // number of elements with bit length too large for (bits = 0; bits <= ZLibUtil.MAX_WBITS; bits++) - s.bl_count[bits] = 0; - - // In a first pass, compute the optimal bit lengths (which may - // overflow in the case of the bit length tree). - tree[s.heap[s.heap_max] * 2 + 1] = 0; // root of the heap - - for (h = s.heap_max + 1; h < ZLibUtil.HEAP_SIZE; h++) - { - n = s.heap[h]; - bits = tree[tree[n * 2 + 1] * 2 + 1] + 1; - if (bits > max_length) - { - bits = max_length; overflow++; - } - tree[n * 2 + 1] = (short) bits; - // We overwrite tree[n*2+1] which is no longer needed - - if (n > max_code) - continue; // not a leaf node - - s.bl_count[bits]++; - xbits = 0; - if (n >= base_Renamed) - xbits = extra[n - base_Renamed]; - f = tree[n * 2]; - s.opt_len += f * (bits + xbits); - if (stree != null) - s.static_len += f * (stree[n * 2 + 1] + xbits); - } - if (overflow == 0) - return ; - - // This happens for example on obj2 and pic of the Calgary corpus - // Find the first bit length which could increase: - do - { - bits = max_length - 1; - while (s.bl_count[bits] == 0) - bits--; - s.bl_count[bits]--; // move one leaf down the tree - s.bl_count[bits + 1] = (short) (s.bl_count[bits + 1] + 2); // move one overflow item as its brother - s.bl_count[max_length]--; - // The brother of the overflow item also moves one step up, - // but this does not affect bl_count[max_length] - overflow -= 2; - } - while (overflow > 0); - - for (bits = max_length; bits != 0; bits--) - { - n = s.bl_count[bits]; - while (n != 0) - { - m = s.heap[--h]; - if (m > max_code) - continue; - if (tree[m * 2 + 1] != bits) - { - s.opt_len = (int) (s.opt_len + ((long) bits - (long) tree[m * 2 + 1]) * (long) tree[m * 2]); - tree[m * 2 + 1] = (short) bits; - } - n--; - } - } - } + s.bl_count[bits] = 0; + + // In a first pass, compute the optimal bit lengths (which may + // overflow in the case of the bit length tree). + tree[s.heap[s.heap_max] * 2 + 1] = 0; // root of the heap + + for (h = s.heap_max + 1; h < ZLibUtil.HEAP_SIZE; h++) { + n = s.heap[h]; + bits = tree[tree[n * 2 + 1] * 2 + 1] + 1; + if (bits > max_length) { + bits = max_length; overflow++; + } + tree[n * 2 + 1] = (short)bits; + // We overwrite tree[n*2+1] which is no longer needed + + if (n > max_code) + continue; // not a leaf node + + s.bl_count[bits]++; + xbits = 0; + if (n >= base_Renamed) + xbits = extra[n - base_Renamed]; + f = tree[n * 2]; + s.opt_len += f * (bits + xbits); + if (stree != null) + s.static_len += f * (stree[n * 2 + 1] + xbits); + } + if (overflow == 0) + return; + + // This happens for example on obj2 and pic of the Calgary corpus + // Find the first bit length which could increase: + do { + bits = max_length - 1; + while (s.bl_count[bits] == 0) + bits--; + s.bl_count[bits]--; // move one leaf down the tree + s.bl_count[bits + 1] = (short)(s.bl_count[bits + 1] + 2); // move one overflow item as its brother + s.bl_count[max_length]--; + // The brother of the overflow item also moves one step up, + // but this does not affect bl_count[max_length] + overflow -= 2; + } + while (overflow > 0); + + for (bits = max_length; bits != 0; bits--) { + n = s.bl_count[bits]; + while (n != 0) { + m = s.heap[--h]; + if (m > max_code) + continue; + if (tree[m * 2 + 1] != bits) { + s.opt_len = (int)(s.opt_len + ((long)bits - (long)tree[m * 2 + 1]) * (long)tree[m * 2]); + tree[m * 2 + 1] = (short)bits; + } + n--; + } + } + } /// /// Construct one Huffman tree and assigns the code bit strings and lengths. @@ -212,92 +197,85 @@ private void gen_bitlen(Deflate s) /// and corresponding code. The length opt_len is updated; static_len is /// also updated if stree is not null. The field max_code is set. /// - internal void build_tree(Deflate s) - { - short[] tree = dyn_tree; - short[] stree = stat_desc.static_tree; - int elems = stat_desc.elems; - int n, m; // iterate over heap elements - int max_code = - 1; // largest code with non zero frequency - int node; // new node being created - - // Construct the initial heap, with least frequent element in - // heap[1]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. - // heap[0] is not used. - s.heap_len = 0; - s.heap_max = ZLibUtil.HEAP_SIZE; - - for (n = 0; n < elems; n++) - { - if (tree[n * 2] != 0) - { - s.heap[++s.heap_len] = max_code = n; - s.depth[n] = 0; - } - else - { - tree[n * 2 + 1] = 0; - } - } - - // The pkzip format requires that at least one distance code exists, - // and that at least one bit should be sent even if there is only one - // possible code. So to avoid special checks later on we force at least - // two codes of non zero frequency. - while (s.heap_len < 2) - { - node = s.heap[++s.heap_len] = (max_code < 2?++max_code:0); - tree[node * 2] = 1; - s.depth[node] = 0; - s.opt_len--; - if (stree != null) - s.static_len -= stree[node * 2 + 1]; - // node is 0 or 1 so it does not have extra bits - } - this.max_code = max_code; - - // The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, - // establish sub-heaps of increasing lengths: - - for (n = s.heap_len / 2; n >= 1; n--) - s.pqdownheap(tree, n); - - // Construct the Huffman tree by repeatedly combining the least two - // frequent nodes. - - node = elems; // next internal node of the tree - do - { - // n = node of least frequency - n = s.heap[1]; - s.heap[1] = s.heap[s.heap_len--]; - s.pqdownheap(tree, 1); - m = s.heap[1]; // m = node of next least frequency - - s.heap[--s.heap_max] = n; // keep the nodes sorted by frequency - s.heap[--s.heap_max] = m; - - // Create a new node father of n and m - tree[node * 2] = (short) (tree[n * 2] + tree[m * 2]); - s.depth[node] = (byte) (System.Math.Max((byte) s.depth[n], (byte) s.depth[m]) + 1); - tree[n * 2 + 1] = tree[m * 2 + 1] = (short) node; - - // and insert the new node in the heap - s.heap[1] = node++; - s.pqdownheap(tree, 1); - } - while (s.heap_len >= 2); - - s.heap[--s.heap_max] = s.heap[1]; - - // At this point, the fields freq and dad are set. We can now - // generate the bit lengths. - - gen_bitlen(s); - - // The field count is now set, we can generate the bit codes - gen_codes(tree, max_code, s.bl_count); - } + internal void build_tree(Deflate s) { + short[] tree = dyn_tree; + short[] stree = stat_desc.static_tree; + int elems = stat_desc.elems; + int n, m; // iterate over heap elements + int max_code = -1; // largest code with non zero frequency + int node; // new node being created + + // Construct the initial heap, with least frequent element in + // heap[1]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. + // heap[0] is not used. + s.heap_len = 0; + s.heap_max = ZLibUtil.HEAP_SIZE; + + for (n = 0; n < elems; n++) { + if (tree[n * 2] != 0) { + s.heap[++s.heap_len] = max_code = n; + s.depth[n] = 0; + } else { + tree[n * 2 + 1] = 0; + } + } + + // The pkzip format requires that at least one distance code exists, + // and that at least one bit should be sent even if there is only one + // possible code. So to avoid special checks later on we force at least + // two codes of non zero frequency. + while (s.heap_len < 2) { + node = s.heap[++s.heap_len] = (max_code < 2 ? ++max_code : 0); + tree[node * 2] = 1; + s.depth[node] = 0; + s.opt_len--; + if (stree != null) + s.static_len -= stree[node * 2 + 1]; + // node is 0 or 1 so it does not have extra bits + } + this.max_code = max_code; + + // The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, + // establish sub-heaps of increasing lengths: + + for (n = s.heap_len / 2; n >= 1; n--) + s.pqdownheap(tree, n); + + // Construct the Huffman tree by repeatedly combining the least two + // frequent nodes. + + node = elems; // next internal node of the tree + do { + // n = node of least frequency + n = s.heap[1]; + s.heap[1] = s.heap[s.heap_len--]; + s.pqdownheap(tree, 1); + m = s.heap[1]; // m = node of next least frequency + + s.heap[--s.heap_max] = n; // keep the nodes sorted by frequency + s.heap[--s.heap_max] = m; + + // Create a new node father of n and m + tree[node * 2] = (short)(tree[n * 2] + tree[m * 2]); + s.depth[node] = (byte)(System.Math.Max((byte)s.depth[n], (byte)s.depth[m]) + 1); + tree[n * 2 + 1] = tree[m * 2 + 1] = (short)node; + + // and insert the new node in the heap + s.heap[1] = node++; + s.pqdownheap(tree, 1); + } + while (s.heap_len >= 2); + + s.heap[--s.heap_max] = s.heap[1]; + + // At this point, the fields freq and dad are set. We can now + // generate the bit lengths. + + gen_bitlen(s); + + // The field count is now set, we can generate the bit codes + gen_codes(tree, max_code, s.bl_count); + } /// /// Generate the codes for a given tree and bit counts (which need not be @@ -307,48 +285,43 @@ internal void build_tree(Deflate s) /// OUT assertion: the field code is set for all tree elements of non /// zero code length. /// - private static void gen_codes(short[] tree, int max_code, short[] bl_count) - { + private static void gen_codes(short[] tree, int max_code, short[] bl_count) { short[] next_code = new short[ZLibUtil.MAX_WBITS + 1]; // next code value for each bit length - short code = 0; // running code value - int bits; // bit index - int n; // code index - - // The distribution counts are first used to generate the code values - // without bit reversal. - for (bits = 1; bits <= ZLibUtil.MAX_WBITS; bits++) - { - next_code[bits] = code = (short) ((code + bl_count[bits - 1]) << 1); - } - - // Check that the bit counts in bl_count are consistent. The last code - // must be all ones. - - for (n = 0; n <= max_code; n++) - { - int len = tree[n * 2 + 1]; - if (len == 0) - continue; - // Now reverse the bits - tree[n * 2] = (short) (bi_reverse(next_code[len]++, len)); - } - } + short code = 0; // running code value + int bits; // bit index + int n; // code index + + // The distribution counts are first used to generate the code values + // without bit reversal. + for (bits = 1; bits <= ZLibUtil.MAX_WBITS; bits++) { + next_code[bits] = code = (short)((code + bl_count[bits - 1]) << 1); + } + + // Check that the bit counts in bl_count are consistent. The last code + // must be all ones. + + for (n = 0; n <= max_code; n++) { + int len = tree[n * 2 + 1]; + if (len == 0) + continue; + // Now reverse the bits + tree[n * 2] = (short)(bi_reverse(next_code[len]++, len)); + } + } /// /// Reverse the first count bits of a code, using straightforward code (a faster /// method would use a table) /// - private static int bi_reverse(int code, int len) - { - int res = 0; - do - { - res |= code & 1; - code = ZLibUtil.URShift(code, 1); - res <<= 1; - } - while (--len > 0); - return ZLibUtil.URShift(res, 1); + private static int bi_reverse(int code, int len) { + int res = 0; + do { + res |= code & 1; + code = ZLibUtil.URShift(code, 1); + res <<= 1; + } + while (--len > 0); + return ZLibUtil.URShift(res, 1); } #endregion diff --git a/Src/IronPython.Modules/zlib/zlib.net/ZStream.cs b/Src/IronPython.Modules/zlib/zlib.net/ZStream.cs index cb3fde016..b264ac549 100644 --- a/Src/IronPython.Modules/zlib/zlib.net/ZStream.cs +++ b/Src/IronPython.Modules/zlib/zlib.net/ZStream.cs @@ -45,22 +45,20 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma warning disable 419 // msc: Ambiguous reference in cref attribute -namespace ComponentAce.Compression.Libs.ZLib -{ +namespace ComponentAce.Compression.Libs.ZLib { /// /// ZStream is used to store user data to compress/decompress. /// - public sealed class ZStream - { + public sealed class ZStream { #region Constants - + private const int DEF_WBITS = ZLibUtil.MAX_WBITS; #endregion #region Fields - + /// /// Next input byte array /// @@ -75,7 +73,7 @@ public sealed class ZStream /// Number of bytes available at _next_in /// private int _avail_in; - + /// /// total nb of input bytes ReadPos so far /// @@ -133,8 +131,7 @@ public sealed class ZStream /// /// Gets/Sets the next input byte array. /// - public byte[] next_in - { + public byte[] next_in { get { return _next_in; } set { _next_in = value; } } @@ -142,8 +139,7 @@ public byte[] next_in /// /// Index of the first byte in the input array. /// - public int next_in_index - { + public int next_in_index { get { return _next_in_index; } set { _next_in_index = value; } } @@ -151,8 +147,7 @@ public int next_in_index /// /// Gets/Sets the number of bytes available in the input buffer. /// - public int avail_in - { + public int avail_in { get { return _avail_in; } set { _avail_in = value; } } @@ -160,8 +155,7 @@ public int avail_in /// /// Gets/Sets the total number of bytes in the input buffer. /// - public long total_in - { + public long total_in { get { return _total_in; } set { _total_in = value; } } @@ -169,8 +163,7 @@ public long total_in /// /// Gets/Sets the buffer for the next output data. /// - public byte[] next_out - { + public byte[] next_out { get { return _next_out; } set { _next_out = value; } } @@ -178,8 +171,7 @@ public byte[] next_out /// /// Gets/Sets the index of the first byte in the byte array to write to. /// - public int next_out_index - { + public int next_out_index { get { return _next_out_index; } set { _next_out_index = value; } } @@ -187,8 +179,7 @@ public int next_out_index /// /// Gets/Sets the remaining free space in the buffer. /// - public int avail_out - { + public int avail_out { get { return _avail_out; } set { _avail_out = value; } } @@ -196,8 +187,7 @@ public int avail_out /// /// Gets/Sets the total number of bytes in the output array. /// - public long total_out - { + public long total_out { get { return _total_out; } set { _total_out = value; } } @@ -205,8 +195,7 @@ public long total_out /// /// Gets sets the last error message occurred during class operations. /// - public string msg - { + public string msg { get { return _msg; } set { _msg = value; } } @@ -214,8 +203,7 @@ public string msg /// /// A deflate object to perform data compression /// - internal Deflate dstate - { + internal Deflate dstate { get { return _dstate; } set { _dstate = value; } } @@ -223,8 +211,7 @@ internal Deflate dstate /// /// Inflate object to perform data decompression /// - internal Inflate istate - { + internal Inflate istate { get { return _istate; } set { _istate = value; } } @@ -251,10 +238,9 @@ public bool IsInitialized { /// apart from reading the ZLib header if present: this will be done by . (So and /// may be modified, but and are unchanged.) /// - public int inflateInit() - { - return inflateInit(DEF_WBITS); - } + public int inflateInit() { + return inflateInit(DEF_WBITS); + } /// /// This is another version of with an extra parameter. The fields , must be @@ -274,12 +260,11 @@ public int inflateInit() /// if present: this will be done by . (So and may be modified, /// but and are unchanged.) /// - public int inflateInit(int windowBits) - { - _istate = new Inflate(); - return _istate.inflateInit(this, windowBits); - } - + public int inflateInit(int windowBits) { + _istate = new Inflate(); + return _istate.inflateInit(this, windowBits); + } + /// /// This method decompresses as much data as possible, and stops when the input buffer () becomes empty or /// the output buffer () becomes full. It may some introduce some output latency (reading input without producing any output) @@ -332,12 +317,11 @@ public int inflateInit(int windowBits) /// when is used. In the case, the application /// may then call to look for a good compression block. /// - public int inflate(FlushStrategy flush) - { - if (_istate == null) - return (int)ZLibResultCode.Z_STREAM_ERROR; - return _istate.inflate(this, flush); - } + public int inflate(FlushStrategy flush) { + if (_istate == null) + return (int)ZLibResultCode.Z_STREAM_ERROR; + return _istate.inflate(this, flush); + } /// /// All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any @@ -347,17 +331,16 @@ public int inflate(FlushStrategy flush) /// inflateEnd returns if success, /// if the stream state was inconsistent. In the error case, msg may be set but then points to a static string (which must not be deallocated). /// - public int inflateEnd() - { - next_in_index = 0; - next_out_index = 0; - - if (_istate == null) - return (int)ZLibResultCode.Z_STREAM_ERROR; - int ret = _istate.inflateEnd(this); - _istate = null; - return ret; - } + public int inflateEnd() { + next_in_index = 0; + next_out_index = 0; + + if (_istate == null) + return (int)ZLibResultCode.Z_STREAM_ERROR; + int ret = _istate.inflateEnd(this); + _istate = null; + return ret; + } /// /// Skips invalid compressed data until a full flush point (see the description of deflate with Z_FULL_FLUSH) can be found, @@ -370,12 +353,11 @@ public int inflateEnd() /// current value of which indicates where valid compressed data was found. In the error case, the application may repeatedly /// call , providing more input each time, until success or end of the input data. /// - public int inflateSync() - { - if (_istate == null) - return (int)ZLibResultCode.Z_STREAM_ERROR; - return _istate.inflateSync(this); - } + public int inflateSync() { + if (_istate == null) + return (int)ZLibResultCode.Z_STREAM_ERROR; + return _istate.inflateSync(this); + } /// /// Initializes the decompression dictionary from the given uncompressed byte sequence. This function must be called immediately after a call of if this call returned . The dictionary chosen by the compressor can be determined from the Adler32 value returned by this call of . The compressor and decompresser must use exactly the same dictionary. @@ -385,12 +367,11 @@ public int inflateSync() /// /// inflateSetDictionary returns if success, if a parameter is invalid (such as null dictionary) or the stream state is inconsistent, if the given dictionary doesn't match the expected one (incorrect Adler32 value). inflateSetDictionary does not perform any decompression: this will be done by subsequent calls of . /// - public int inflateSetDictionary(byte[] dictionary, int dictLength) - { - if (_istate == null) - return (int)ZLibResultCode.Z_STREAM_ERROR; - return _istate.inflateSetDictionary(this, dictionary, dictLength); - } + public int inflateSetDictionary(byte[] dictionary, int dictLength) { + if (_istate == null) + return (int)ZLibResultCode.Z_STREAM_ERROR; + return _istate.inflateSetDictionary(this, dictionary, dictLength); + } /// /// Initializes the internal stream state for compression. @@ -401,10 +382,9 @@ public int inflateSetDictionary(byte[] dictionary, int dictLength) /// if level is not a valid compression level. is set to null if there is /// no error message. does not perform any compression: this will be done by . /// - public int DeflateInit(int level) - { - return DeflateInit(level, ZLibUtil.MAX_WBITS); - } + public int DeflateInit(int level) { + return DeflateInit(level, ZLibUtil.MAX_WBITS); + } /// /// Initializes the internal stream state for compression. @@ -418,11 +398,10 @@ public int DeflateInit(int level) /// if level is not a valid compression level. is set to null if there /// is no error message. does not perform any compression: this will be done by . /// - public int DeflateInit(int level, int bits) - { - _dstate = new Deflate(); - return _dstate.DeflateInit(this, level, bits); - } + public int DeflateInit(int level, int bits) { + _dstate = new Deflate(); + return _dstate.DeflateInit(this, level, bits); + } public int DeflateInit(int level, int windowBits, int memLevel, CompressionStrategy strategy) { _dstate = new Deflate(); @@ -431,7 +410,7 @@ public int DeflateInit(int level, int windowBits, int memLevel, CompressionStrat public int reset() { if (_dstate != null) { - return _dstate.deflateReset(this); + return _dstate.deflateReset(this); } if (_istate != null) { @@ -510,14 +489,12 @@ public int reset() { /// (for example or was zero). /// /// - public int deflate(FlushStrategy flush) - { - if (_dstate == null) - { - return (int)ZLibResultCode.Z_STREAM_ERROR; - } - return _dstate.deflate(this, flush); - } + public int deflate(FlushStrategy flush) { + if (_dstate == null) { + return (int)ZLibResultCode.Z_STREAM_ERROR; + } + return _dstate.deflate(this, flush); + } /// /// All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending @@ -528,17 +505,16 @@ public int deflate(FlushStrategy flush) /// if the stream was freed prematurely (some input or output was discarded). In the error case, /// may be set but then points to a static string (which must not be deallocated). /// - public int deflateEnd() - { - next_in_index = 0; - next_out_index = 0; - - if (_dstate == null) - return (int)ZLibResultCode.Z_STREAM_ERROR; - int ret = _dstate.deflateEnd(); - _dstate = null; - return ret; - } + public int deflateEnd() { + next_in_index = 0; + next_out_index = 0; + + if (_dstate == null) + return (int)ZLibResultCode.Z_STREAM_ERROR; + int ret = _dstate.deflateEnd(); + _dstate = null; + return ret; + } /// /// Dynamically update the compression level and compression strategy. The interpretation of level is as in . @@ -556,12 +532,11 @@ public int deflateEnd() /// deflateParams returns if success, if the source stream /// state was inconsistent or if a parameter was invalid, if was zero. /// - public int deflateParams(int level, CompressionStrategy strategy) - { - if (_dstate == null) - return (int)ZLibResultCode.Z_STREAM_ERROR; - return _dstate.deflateParams(this, level, strategy); - } + public int deflateParams(int level, CompressionStrategy strategy) { + if (_dstate == null) + return (int)ZLibResultCode.Z_STREAM_ERROR; + return _dstate.deflateParams(this, level, strategy); + } /// /// Initializes the compression dictionary from the given byte sequence without producing any compressed output. This function must be called @@ -589,71 +564,65 @@ public int deflateParams(int level, CompressionStrategy strategy) /// called for this stream or if the compression method is bsort). does not perform any compression: /// this will be done by . /// - public int deflateSetDictionary(byte[] dictionary, int dictLength) - { - if (_dstate == null) - return (int)ZLibResultCode.Z_STREAM_ERROR; - return _dstate.deflateSetDictionary(this, dictionary, dictLength); - } + public int deflateSetDictionary(byte[] dictionary, int dictLength) { + if (_dstate == null) + return (int)ZLibResultCode.Z_STREAM_ERROR; + return _dstate.deflateSetDictionary(this, dictionary, dictLength); + } /// /// Flush as much pending output as possible. All output goes through this function so some applications may wish to /// modify it to avoid allocating a large buffer and copying into it. /// /// - public void FlushPending() - { - int len = _dstate.Pending; - - if (len > _avail_out) - len = _avail_out; - if (len == 0) - return ; - - Array.Copy(_dstate.Pending_buf, _dstate.Pending_out, _next_out, _next_out_index, len); - - _next_out_index += len; - _dstate.Pending_out += len; - _total_out += len; - _avail_out -= len; - _dstate.Pending -= len; - if (_dstate.Pending == 0) - { - _dstate.Pending_out = 0; - } - } + public void FlushPending() { + int len = _dstate.Pending; + + if (len > _avail_out) + len = _avail_out; + if (len == 0) + return; + + Array.Copy(_dstate.Pending_buf, _dstate.Pending_out, _next_out, _next_out_index, len); + + _next_out_index += len; + _dstate.Pending_out += len; + _total_out += len; + _avail_out -= len; + _dstate.Pending -= len; + if (_dstate.Pending == 0) { + _dstate.Pending_out = 0; + } + } /// /// Read a new buffer from the current input stream, update the adler32 and total number of bytes read. All input goes /// through this function so some applications may wish to modify it to avoid allocating a large buffer and copying from it. /// /// - public int ReadBuf(byte[] buf, int start, int size) - { - int len = _avail_in; - - if (len > size) - len = size; - if (len == 0) - return 0; - - _avail_in -= len; - - if (_dstate.NoHeader == 0) - { - adler = Adler32.GetAdler32Checksum(adler, _next_in, _next_in_index, len); - } - Array.Copy(_next_in, _next_in_index, buf, start, len); - _next_in_index += len; - _total_in += len; - return len; - } + public int ReadBuf(byte[] buf, int start, int size) { + int len = _avail_in; + + if (len > size) + len = size; + if (len == 0) + return 0; + + _avail_in -= len; + + if (_dstate.NoHeader == 0) { + adler = Adler32.GetAdler32Checksum(adler, _next_in, _next_in_index, len); + } + Array.Copy(_next_in, _next_in_index, buf, start, len); + _next_in_index += len; + _total_in += len; + return len; + } /// /// Frees all inner buffers. /// - public void free() - { + public void free() { _next_in = null; _next_out = null; _msg = null; diff --git a/Src/IronPython.Modules/zlib/zlib.net/ZStreamException.cs b/Src/IronPython.Modules/zlib/zlib.net/ZStreamException.cs index e0204d4b0..9a128c5e9 100644 --- a/Src/IronPython.Modules/zlib/zlib.net/ZStreamException.cs +++ b/Src/IronPython.Modules/zlib/zlib.net/ZStreamException.cs @@ -42,27 +42,23 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * and contributors of zlib. */ -namespace ComponentAce.Compression.Libs.ZLib -{ - /// - /// Exceptions that occur in ZStream - /// - public class ZStreamException : System.IO.IOException - { +namespace ComponentAce.Compression.Libs.ZLib { + /// + /// Exceptions that occur in ZStream + /// + public class ZStreamException : System.IO.IOException { /// /// Default constructor. /// public ZStreamException() - :base() - { - } - + : base() { + } + /// /// Constructor which takes one parameter - an error message /// - public ZStreamException(System.String s) - :base(s) - { - } - } + public ZStreamException(System.String s) + : base(s) { + } + } } \ No newline at end of file diff --git a/Src/IronPython.Modules/zlib/zlib.net/Zlib.cs b/Src/IronPython.Modules/zlib/zlib.net/Zlib.cs index 129d5647c..ec1760997 100644 --- a/Src/IronPython.Modules/zlib/zlib.net/Zlib.cs +++ b/Src/IronPython.Modules/zlib/zlib.net/Zlib.cs @@ -44,13 +44,11 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using System; using System.Text; -namespace ComponentAce.Compression.Libs.ZLib -{ +namespace ComponentAce.Compression.Libs.ZLib { /// /// Some constants for specifying compression levels. Methods which takes a compression level as a parameter expects an integer value from 0 to 9. You can either specify an integer value or use constants for some most widely used compression levels. /// - public static class ZLibCompressionLevel - { + public static class ZLibCompressionLevel { /// /// No compression should be used at all. /// @@ -72,8 +70,7 @@ public static class ZLibCompressionLevel /// /// Compression strategies. The strategy parameter is used to tune the compression algorithm. The strategy parameter only affects the compression ratio but not the correctness of the compressed output even if it is not set appropriately. /// - public enum CompressionStrategy - { + public enum CompressionStrategy { /// /// This strategy is designed for filtered data. Data which consists of mostly small values, with random distribution should use Z_FILTERED. With this strategy, less string matching is performed. /// @@ -91,8 +88,7 @@ public enum CompressionStrategy /// /// Flush strategies /// - public enum FlushStrategy - { + public enum FlushStrategy { /// /// Do not internalFlush data, but just write data as normal to the output buffer. This is the normal way in which data is written to the output buffer. /// @@ -118,8 +114,7 @@ public enum FlushStrategy /// /// Results of operations in ZLib library /// - public enum ZLibResultCode - { + public enum ZLibResultCode { /// /// No failure was encountered, the operation completed without problem. /// @@ -135,34 +130,33 @@ public enum ZLibResultCode /// /// An internal error occurred /// - Z_ERRNO = - 1, + Z_ERRNO = -1, /// /// The stream structure was inconsistent /// - Z_STREAM_ERROR = - 2, + Z_STREAM_ERROR = -2, /// /// Input data has been corrupted (for decompression). /// - Z_DATA_ERROR = - 3, + Z_DATA_ERROR = -3, /// /// Memory allocation failed. /// - Z_MEM_ERROR = - 4, + Z_MEM_ERROR = -4, /// /// There was not enough space in the output buffer. /// - Z_BUF_ERROR = - 5, + Z_BUF_ERROR = -5, /// /// The version supplied does not match that supported by the ZLib module. /// - Z_VERSION_ERROR = - 6 + Z_VERSION_ERROR = -6 } /// /// States of deflate operation /// - internal enum DeflateState - { + internal enum DeflateState { INIT_STATE = 42, BUSY_STATE = 113, FINISH_STATE = 666 @@ -171,8 +165,7 @@ internal enum DeflateState /// /// Data block types, i.e. binary or ascii text /// - public enum BlockType - { + public enum BlockType { Z_BINARY = 0, Z_ASCII = 1, Z_UNKNOWN = 2 @@ -181,12 +174,10 @@ public enum BlockType /// /// Helper class /// - public static class ZLibUtil - { + public static class ZLibUtil { #region Copy large array to a small one in several steps - internal class CopyLargeArrayToSmall - { + internal class CopyLargeArrayToSmall { private static byte[] srcBuf; private static int srcOff; @@ -196,8 +187,7 @@ internal class CopyLargeArrayToSmall private static int destLen; private static int nWritten; - public static void Initialize(byte[] srcBuf, int srcOff, int srcDataLen, byte[] destBuff, int destOff, int destLen) - { + public static void Initialize(byte[] srcBuf, int srcOff, int srcDataLen, byte[] destBuff, int destOff, int destLen) { ZLibUtil.CopyLargeArrayToSmall.srcBuf = srcBuf; ZLibUtil.CopyLargeArrayToSmall.srcOff = srcOff; ZLibUtil.CopyLargeArrayToSmall.srcDataLen = srcDataLen; @@ -206,25 +196,21 @@ public static void Initialize(byte[] srcBuf, int srcOff, int srcDataLen, byte[] ZLibUtil.CopyLargeArrayToSmall.destLen = destLen; ZLibUtil.CopyLargeArrayToSmall.nWritten = 0; } - + public static int GetRemainingDataSize() { return srcDataLen; } /// /// Copies large array which was passed as srcBuf to the Initialize method into the destination array which were passes as destBuff /// /// The number of bytes copied - public static int CopyData() - { - if (srcDataLen > destLen) - { + public static int CopyData() { + if (srcDataLen > destLen) { Array.Copy(srcBuf, srcOff, destBuff, destOff, destLen); srcDataLen -= destLen; srcOff += destLen; nWritten = destLen; return nWritten; - } - else - { + } else { Array.Copy(srcBuf, srcOff, destBuff, destOff, srcDataLen); nWritten = srcDataLen; srcDataLen = 0; @@ -268,158 +254,146 @@ public static int CopyData() /// /// The literal to return /// The received value - internal static long Identity(long literal) - { - return literal; - } + internal static long Identity(long literal) { + return literal; + } - /// - /// This method returns the literal value received - /// - /// The literal to return - /// The received value - internal static ulong Identity(ulong literal) - { - return literal; - } + /// + /// This method returns the literal value received + /// + /// The literal to return + /// The received value + internal static ulong Identity(ulong literal) { + return literal; + } - /// - /// This method returns the literal value received - /// - /// The literal to return - /// The received value - internal static float Identity(float literal) - { - return literal; - } + /// + /// This method returns the literal value received + /// + /// The literal to return + /// The received value + internal static float Identity(float literal) { + return literal; + } - /// - /// This method returns the literal value received - /// - /// The literal to return - /// The received value - internal static double Identity(double literal) - { - return literal; - } - - /*******************************/ - /// - /// Performs an unsigned bitwise right shift with the specified number - /// - /// Number to operate on - /// Ammount of bits to shift - /// The resulting number from the shift operation - internal static int URShift(int number, int bits) - { - if ( number >= 0) - return number >> bits; - else - return (number >> bits) + (2 << ~bits); - } - - /// - /// Performs an unsigned bitwise right shift with the specified number - /// - /// Number to operate on - /// Ammount of bits to shift - /// The resulting number from the shift operation - internal static int URShift(int number, long bits) - { - return URShift(number, (int)bits); - } - - /// - /// Performs an unsigned bitwise right shift with the specified number - /// - /// Number to operate on - /// Ammount of bits to shift - /// The resulting number from the shift operation - internal static long URShift(long number, int bits) - { - if ( number >= 0) - return number >> bits; - else - return (number >> bits) + (2L << ~bits); - } - - /// - /// Performs an unsigned bitwise right shift with the specified number - /// - /// Number to operate on - /// Ammount of bits to shift - /// The resulting number from the shift operation - internal static long URShift(long number, long bits) - { - return URShift(number, (int)bits); - } - - /*******************************/ - /// Reads a number of characters from the current source Stream and writes the data to the target array at the specified index. - /// The source Stream to ReadPos from. - /// Contains the array of characters ReadPos from the source Stream. - /// The starting index of the target array. - /// The maximum number of characters to ReadPos from the source Stream. - /// The number of characters ReadPos. The number will be less than or equal to count depending on the data available in the source Stream. Returns -1 if the End of the stream is reached. - internal static System.Int32 ReadInput(System.IO.Stream sourceStream, byte[] target, int start, int count) - { - // Returns 0 bytes if not enough space in target - if (target.Length == 0) - return 0; - - byte[] receiver = new byte[target.Length]; - int bytesRead = sourceStream.Read(receiver, start, count); - - // Returns -1 if EOF - if (bytesRead == 0) - return -1; - - for(int i = start; i < start + bytesRead; i++) - target[i] = (byte)receiver[i]; - - return bytesRead; - } - - /// Reads a number of characters from the current source TextReader and writes the data to the target array at the specified index. - /// The source TextReader to ReadPos from - /// Contains the array of characteres ReadPos from the source TextReader. - /// The starting index of the target array. - /// The maximum number of characters to ReadPos from the source TextReader. - /// The number of characters ReadPos. The number will be less than or equal to count depending on the data available in the source TextReader. Returns -1 if the End of the stream is reached. - internal static System.Int32 ReadInput(System.IO.TextReader sourceTextReader, byte[] target, int start, int count) - { - // Returns 0 bytes if not enough space in target - if (target.Length == 0) return 0; - - char[] charArray = new char[target.Length]; - int bytesRead = sourceTextReader.Read(charArray, start, count); - - // Returns -1 if EOF - if (bytesRead == 0) return -1; - - for(int index=start; index - /// Converts a string to an array of bytes - /// - /// The string to be converted - /// The new array of bytes - internal static byte[] ToByteArray(string sourceString) - { - return Encoding.UTF8.GetBytes(sourceString); - } - - /// - /// Converts an array of bytes to an array of chars - /// - /// The array of bytes to convert - /// The new array of chars - internal static char[] ToCharArray(byte[] byteArray) - { + /// + /// This method returns the literal value received + /// + /// The literal to return + /// The received value + internal static double Identity(double literal) { + return literal; + } + + /*******************************/ + /// + /// Performs an unsigned bitwise right shift with the specified number + /// + /// Number to operate on + /// Ammount of bits to shift + /// The resulting number from the shift operation + internal static int URShift(int number, int bits) { + if (number >= 0) + return number >> bits; + else + return (number >> bits) + (2 << ~bits); + } + + /// + /// Performs an unsigned bitwise right shift with the specified number + /// + /// Number to operate on + /// Ammount of bits to shift + /// The resulting number from the shift operation + internal static int URShift(int number, long bits) { + return URShift(number, (int)bits); + } + + /// + /// Performs an unsigned bitwise right shift with the specified number + /// + /// Number to operate on + /// Ammount of bits to shift + /// The resulting number from the shift operation + internal static long URShift(long number, int bits) { + if (number >= 0) + return number >> bits; + else + return (number >> bits) + (2L << ~bits); + } + + /// + /// Performs an unsigned bitwise right shift with the specified number + /// + /// Number to operate on + /// Ammount of bits to shift + /// The resulting number from the shift operation + internal static long URShift(long number, long bits) { + return URShift(number, (int)bits); + } + + /*******************************/ + /// Reads a number of characters from the current source Stream and writes the data to the target array at the specified index. + /// The source Stream to ReadPos from. + /// Contains the array of characters ReadPos from the source Stream. + /// The starting index of the target array. + /// The maximum number of characters to ReadPos from the source Stream. + /// The number of characters ReadPos. The number will be less than or equal to count depending on the data available in the source Stream. Returns -1 if the End of the stream is reached. + internal static System.Int32 ReadInput(System.IO.Stream sourceStream, byte[] target, int start, int count) { + // Returns 0 bytes if not enough space in target + if (target.Length == 0) + return 0; + + byte[] receiver = new byte[target.Length]; + int bytesRead = sourceStream.Read(receiver, start, count); + + // Returns -1 if EOF + if (bytesRead == 0) + return -1; + + for (int i = start; i < start + bytesRead; i++) + target[i] = (byte)receiver[i]; + + return bytesRead; + } + + /// Reads a number of characters from the current source TextReader and writes the data to the target array at the specified index. + /// The source TextReader to ReadPos from + /// Contains the array of characteres ReadPos from the source TextReader. + /// The starting index of the target array. + /// The maximum number of characters to ReadPos from the source TextReader. + /// The number of characters ReadPos. The number will be less than or equal to count depending on the data available in the source TextReader. Returns -1 if the End of the stream is reached. + internal static System.Int32 ReadInput(System.IO.TextReader sourceTextReader, byte[] target, int start, int count) { + // Returns 0 bytes if not enough space in target + if (target.Length == 0) return 0; + + char[] charArray = new char[target.Length]; + int bytesRead = sourceTextReader.Read(charArray, start, count); + + // Returns -1 if EOF + if (bytesRead == 0) return -1; + + for (int index = start; index < start + bytesRead; index++) + target[index] = (byte)charArray[index]; + + return bytesRead; + } + + /// + /// Converts a string to an array of bytes + /// + /// The string to be converted + /// The new array of bytes + internal static byte[] ToByteArray(string sourceString) { + return Encoding.UTF8.GetBytes(sourceString); + } + + /// + /// Converts an array of bytes to an array of chars + /// + /// The array of bytes to convert + /// The new array of chars + internal static char[] ToCharArray(byte[] byteArray) { return Encoding.UTF8.GetChars(byteArray); } @@ -476,8 +450,8 @@ internal static char[] ToCharArray(byte[] byteArray) /// internal const int DIST_CODE_LEN = 512; - internal static readonly byte[] _dist_code = new byte[]{0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29}; + internal static readonly byte[] _dist_code = new byte[]{0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29}; internal static readonly byte[] _length_code = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 }; diff --git a/Src/IronPython.SQLite/Connection.cs b/Src/IronPython.SQLite/Connection.cs index 65e5e9361..3ab5bb0ff 100644 --- a/Src/IronPython.SQLite/Connection.cs +++ b/Src/IronPython.SQLite/Connection.cs @@ -8,42 +8,37 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading; + using Community.CsharpSqlite; + using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; + using Microsoft.Scripting; using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; using sqlite3_stmt = Community.CsharpSqlite.Sqlite3.Vdbe; using sqlite3_value = Community.CsharpSqlite.Sqlite3.Mem; -namespace IronPython.SQLite -{ - public static partial class PythonSQLite - { +namespace IronPython.SQLite { + public static partial class PythonSQLite { [PythonType] - public class Connection - { + public class Connection { public bool autocommit = false; public int total_changes { get { return Sqlite3.sqlite3_total_changes(this.db); } } - + public int detect_types { get; set; } public bool check_same_thread { get; set; } private double _timeout; - public double timeout - { + public double timeout { get { return _timeout; } set { _timeout = value; Sqlite3.sqlite3_busy_timeout(this.db, (int)(_timeout * 1000)); } } private string _isolation_level; - public string isolation_level - { + public string isolation_level { get { return _isolation_level; } set { setIsolationLevel(value); } } @@ -65,7 +60,7 @@ public string isolation_level internal bool inTransaction = false; internal int thread_ident = Environment.CurrentManagedThreadId; - private static readonly Dictionary emptyKwargs= new Dictionary(); + private static readonly Dictionary emptyKwargs = new Dictionary(); public PythonType Warning = PythonSQLite.Warning; public PythonType Error = PythonSQLite.Error; @@ -78,23 +73,21 @@ public string isolation_level public PythonType ProgrammingError = PythonSQLite.ProgrammingError; public PythonType NotSupportedError = PythonSQLite.NotSupportedError; - private enum AllStatmentsAction - { + private enum AllStatmentsAction { Reset, Finalize } public Connection(string database, - double timeout=0.0, - int detect_types=0, - string isolation_level=null, - bool check_same_thread=true, - object factory=null, - int cached_statements=0) - { + double timeout = 0.0, + int detect_types = 0, + string isolation_level = null, + bool check_same_thread = true, + object factory = null, + int cached_statements = 0) { this.text_factory = typeof(string); int rc = Sqlite3.sqlite3_open(database, out this.db); - if(rc != Sqlite3.SQLITE_OK) + if (rc != Sqlite3.SQLITE_OK) throw GetSqliteError(this.db, null); setIsolationLevel(isolation_level ?? ""); @@ -104,150 +97,135 @@ public Connection(string database, this.check_same_thread = check_same_thread; } - ~Connection() - { - if(this.db != null) + ~Connection() { + if (this.db != null) Sqlite3.sqlite3_close(this.db); } [Documentation("Closes the connection.")] - public void close() - { + public void close() { checkThread(); doAllStatements(AllStatmentsAction.Finalize); - if(this.db != null) - { + if (this.db != null) { int rc = Sqlite3.SQLITE_OK, i = 0; - - do - { + + do { rc = Sqlite3.sqlite3_close(this.db); - if(rc == Sqlite3.SQLITE_BUSY) - { + if (rc == Sqlite3.SQLITE_BUSY) { GC.Collect(); GC.WaitForPendingFinalizers(); } - } while(rc == Sqlite3.SQLITE_BUSY && i++ < 3); + } while (rc == Sqlite3.SQLITE_BUSY && i++ < 3); - if(rc != Sqlite3.SQLITE_OK) + if (rc != Sqlite3.SQLITE_OK) throw GetSqliteError(this.db, null); this.db = null; } } - internal void begin() - { + internal void begin() { sqlite3_stmt statement = null; string tail = null; int rc = Sqlite3.sqlite3_prepare(this.db, this.begin_statement, -1, ref statement, ref tail); - if(rc != Sqlite3.SQLITE_OK) + if (rc != Sqlite3.SQLITE_OK) throw GetSqliteError(this.db, statement); rc = Util.Step(statement); - if(rc == Sqlite3.SQLITE_DONE) + if (rc == Sqlite3.SQLITE_DONE) this.inTransaction = true; else throw GetSqliteError(this.db, statement); rc = Sqlite3.sqlite3_finalize(statement); - if(rc != Sqlite3.SQLITE_OK) + if (rc != Sqlite3.SQLITE_OK) GetSqliteError(this.db, null); } [Documentation("Commit the current transaction.")] - public void commit() - { + public void commit() { checkThread(); checkConnection(); - if(inTransaction) - { + if (inTransaction) { sqlite3_stmt statement = null; string tail = null; int rc = Sqlite3.sqlite3_prepare(this.db, "COMMIT", -1, ref statement, ref tail); - if(rc != Sqlite3.SQLITE_OK) + if (rc != Sqlite3.SQLITE_OK) throw GetSqliteError(this.db, null); rc = Util.Step(statement); - if(rc == Sqlite3.SQLITE_DONE) + if (rc == Sqlite3.SQLITE_DONE) this.inTransaction = false; else throw GetSqliteError(this.db, statement); rc = Sqlite3.sqlite3_finalize(statement); - if(rc != Sqlite3.SQLITE_OK) + if (rc != Sqlite3.SQLITE_OK) GetSqliteError(this.db, null); } } [Documentation("Roll back the current transaction.")] - public void rollback() - { + public void rollback() { checkThread(); checkConnection(); - if(inTransaction) - { + if (inTransaction) { doAllStatements(AllStatmentsAction.Reset); sqlite3_stmt statement = null; string tail = null; int rc = Sqlite3.sqlite3_prepare(this.db, "ROLLBACK", -1, ref statement, ref tail); - if(rc != Sqlite3.SQLITE_OK) + if (rc != Sqlite3.SQLITE_OK) throw GetSqliteError(this.db, null); rc = Util.Step(statement); - if(rc == Sqlite3.SQLITE_DONE) + if (rc == Sqlite3.SQLITE_DONE) this.inTransaction = false; else throw GetSqliteError(this.db, statement); rc = Sqlite3.sqlite3_finalize(statement); - if(rc != Sqlite3.SQLITE_OK) + if (rc != Sqlite3.SQLITE_OK) GetSqliteError(this.db, null); } } [Documentation("Return a cursor for the connection.")] - public object cursor(CodeContext context, object factory=null) - { + public object cursor(CodeContext context, object factory = null) { checkThread(); checkConnection(); object cursor = factory == null ? new Cursor(context, this) : PythonCalls.Call(context, factory, this); - if(this.row_factory != null) + if (this.row_factory != null) context.LanguageContext.Operations.SetMember(cursor, "row_factory", this.row_factory); return cursor; } [Documentation("Executes a SQL statement. Non-standard.")] - public object execute(CodeContext context, [ParamDictionary]IDictionary kwargs, params object[] args) - { + public object execute(CodeContext context, [ParamDictionary] IDictionary kwargs, params object[] args) { object c = cursor(context, null); object execute = context.LanguageContext.Operations.GetMember(c, "execute"); return PythonCalls.CallWithKeywordArgs(context, execute, args, kwargs); } [Documentation("Repeatedly executes a SQL statement. Non-standard.")] - public object executemany(CodeContext context, [ParamDictionary]IDictionary kwargs, params object[] args) - { + public object executemany(CodeContext context, [ParamDictionary] IDictionary kwargs, params object[] args) { object c = cursor(context, null); object executemany = context.LanguageContext.Operations.GetMember(c, "executemany"); return PythonCalls.CallWithKeywordArgs(context, executemany, args, kwargs); } [Documentation("Executes a multiple SQL statements at once. Non-standard.")] - public object executescript(CodeContext context, [ParamDictionary]IDictionary kwargs, params object[] args) - { + public object executescript(CodeContext context, [ParamDictionary] IDictionary kwargs, params object[] args) { object c = cursor(context, null); object executescript = context.LanguageContext.Operations.GetMember(c, "executescript"); return PythonCalls.CallWithKeywordArgs(context, executescript, args, kwargs); } - public object __call__(string sql) - { + public object __call__(string sql) { dropUnusedStatementReferences(); Statement statement = new Statement(this, sql); @@ -255,17 +233,16 @@ public object __call__(string sql) return statement; } - private void dropUnusedStatementReferences() - { - if(this.created_statements++ < 200) + private void dropUnusedStatementReferences() { + if (this.created_statements++ < 200) return; this.created_statements = 0; List new_list = new List(); - foreach(WeakReference weakref in this.statements) - if(weakref.IsAlive) + foreach (WeakReference weakref in this.statements) + if (weakref.IsAlive) new_list.Add(weakref); this.statements = new_list; @@ -274,51 +251,43 @@ private void dropUnusedStatementReferences() #region User functions [Documentation("Creates a new function. Non-standard.")] - public void create_function(CodeContext context, string name, int narg, object func) - { - int rc = Sqlite3.sqlite3_create_function(this.db, - name, narg, - Sqlite3.SQLITE_ANY, - new object[] { context, func }, - callUserFunction, + public void create_function(CodeContext context, string name, int narg, object func) { + int rc = Sqlite3.sqlite3_create_function(this.db, + name, narg, + Sqlite3.SQLITE_ANY, + new object[] { context, func }, + callUserFunction, null, null); - - if(rc != Sqlite3.SQLITE_OK) + + if (rc != Sqlite3.SQLITE_OK) throw MakeOperationalError("Error creating function"); else this.function_pinboard[func] = null; } - private static void callUserFunction(Sqlite3.sqlite3_context ctx, int argc, sqlite3_value[] argv) - { + private static void callUserFunction(Sqlite3.sqlite3_context ctx, int argc, sqlite3_value[] argv) { object[] data = (object[])Sqlite3.sqlite3_user_data(ctx); CodeContext context = (CodeContext)data[0]; object func = data[1]; object[] args = buildPyParams(context, ctx, argc, argv); - try - { + try { object result = PythonCalls.CallWithKeywordArgs(context, func, args, emptyKwargs); setResult(ctx, result); - } - catch(Exception) - { + } catch (Exception) { Sqlite3.sqlite3_result_error(ctx, "user-defined function raised exception", -1); } } - private static object[] buildPyParams(CodeContext context, Sqlite3.sqlite3_context ctx, int argc, sqlite3_value[] argv) - { + private static object[] buildPyParams(CodeContext context, Sqlite3.sqlite3_context ctx, int argc, sqlite3_value[] argv) { object[] args = new object[argc]; - for(int i = 0; i < argc; ++i) - { + for (int i = 0; i < argc; ++i) { sqlite3_value cur_value = argv[i]; object cur_py_value = null; - switch(Sqlite3.sqlite3_value_type(cur_value)) - { + switch (Sqlite3.sqlite3_value_type(cur_value)) { case Sqlite3.SQLITE_INTEGER: cur_py_value = (int)Sqlite3.sqlite3_value_int64(cur_value); break; @@ -347,32 +316,28 @@ private static object[] buildPyParams(CodeContext context, Sqlite3.sqlite3_conte return args; } - private static void setResult(Sqlite3.sqlite3_context ctx, object result) - { - if(result == null) + private static void setResult(Sqlite3.sqlite3_context ctx, object result) { + if (result == null) Sqlite3.sqlite3_result_null(ctx); - else if(result is bool) + else if (result is bool) Sqlite3.sqlite3_result_int64(ctx, ((bool)result) ? 1 : 0); - else if(result is int) + else if (result is int) Sqlite3.sqlite3_result_int64(ctx, (int)result); - else if(result is long) + else if (result is long) Sqlite3.sqlite3_result_int64(ctx, (long)result); else if (result is System.Numerics.BigInteger) Sqlite3.sqlite3_result_int64(ctx, (long)(System.Numerics.BigInteger)result); - else if(result is float) + else if (result is float) Sqlite3.sqlite3_result_double(ctx, (float)result); - else if(result is double) + else if (result is double) Sqlite3.sqlite3_result_double(ctx, (double)result); - else if(result is string) + else if (result is string) Sqlite3.sqlite3_result_text(ctx, (string)result, -1, Sqlite3.SQLITE_TRANSIENT); - else if(result is byte[]) - { + else if (result is byte[]) { byte[] b = (byte[])result; string s = Latin1.GetString(b, 0, b.Length); Sqlite3.sqlite3_result_blob(ctx, s, s.Length, Sqlite3.SQLITE_TRANSIENT); - } - else - { + } else { // TODO raise error } } @@ -381,58 +346,44 @@ private static void setResult(Sqlite3.sqlite3_context ctx, object result) #region User aggregates - private class UserAggregateThunk - { - public UserAggregateThunk(CodeContext context, string name, object aggregate_class) - { + private class UserAggregateThunk { + public UserAggregateThunk(CodeContext context, string name, object aggregate_class) { this.context = context; this.aggregate_class = aggregate_class; this.name = name; } - public void stepCallback(Sqlite3.sqlite3_context ctx, int argc, sqlite3_value[] param) - { - if(instance == null) - { - try - { + public void stepCallback(Sqlite3.sqlite3_context ctx, int argc, sqlite3_value[] param) { + if (instance == null) { + try { instance = PythonCalls.Call(context, aggregate_class); - } - catch(Exception) - { + } catch (Exception) { Sqlite3.sqlite3_result_error(ctx, "user-defined aggregate's '__init__' method raised error", -1); return; } } - try - { + try { object step = context.LanguageContext.Operations.GetMember(instance, "step"); object[] args = buildPyParams(context, ctx, argc, param); PythonCalls.CallWithKeywordArgs(context, step, args, new Dictionary()); - } - catch(Exception e) - { - if(e is MissingMemberException) + } catch (Exception e) { + if (e is MissingMemberException) throw; Sqlite3.sqlite3_result_error(ctx, "user-defined aggregate's 'step' method raised error", -1); } } - public void finalCallback(Sqlite3.sqlite3_context ctx) - { - if(instance == null) + public void finalCallback(Sqlite3.sqlite3_context ctx) { + if (instance == null) return; - try - { + try { object function_result = context.LanguageContext.Operations.InvokeMember(instance, "finalize"); setResult(ctx, function_result); - } - catch(Exception) - { + } catch (Exception) { Sqlite3.sqlite3_result_error(ctx, "user-defined aggregate's 'finalize' method raised error", -1); } } @@ -444,8 +395,7 @@ public void finalCallback(Sqlite3.sqlite3_context ctx) } [Documentation("Creates a new aggregate. Non-standard.")] - public void create_aggregate(CodeContext context, string name, int n_arg, object aggregate_class) - { + public void create_aggregate(CodeContext context, string name, int n_arg, object aggregate_class) { UserAggregateThunk thunk = new UserAggregateThunk(context, name, aggregate_class); int rc = Sqlite3.sqlite3_create_function(this.db, @@ -456,7 +406,7 @@ public void create_aggregate(CodeContext context, string name, int n_arg, object thunk.stepCallback, thunk.finalCallback); - if(rc != Sqlite3.SQLITE_OK) + if (rc != Sqlite3.SQLITE_OK) throw MakeOperationalError("Error creating aggregate"); else this.function_pinboard[aggregate_class] = null; @@ -465,45 +415,37 @@ public void create_aggregate(CodeContext context, string name, int n_arg, object #endregion [Documentation("Creates a collation function. Non-standard.")] - public void create_collation(params object[] args) - { + public void create_collation(params object[] args) { throw new NotImplementedException(); } [Documentation("Sets progress handler callback. Non-standard.")] - public void set_progress_handler(params object[] args) - { + public void set_progress_handler(params object[] args) { throw new NotImplementedException(); } [Documentation("Sets authorizer callback. Non-standard.")] - public void set_authorizer(params object[] args) - { + public void set_authorizer(params object[] args) { throw new NotImplementedException(); } [Documentation("For context manager. Non-standard.")] - public object __enter__() - { + public object __enter__() { return this; } [Documentation("For context manager. Non-standard.")] - public object __exit__(CodeContext context, object exc_type, object exc_value, object exc_tb) - { + public object __exit__(CodeContext context, object exc_type, object exc_value, object exc_tb) { DynamicOperations ops = context.LanguageContext.Operations; - if(exc_type == null && exc_value == null && exc_tb == null) - { + if (exc_type == null && exc_value == null && exc_tb == null) { object commitfn; - if(ops.TryGetMember(this, "commit", out commitfn)) + if (ops.TryGetMember(this, "commit", out commitfn)) ops.Invoke(commitfn); else commit(); - } - else - { + } else { object rollbackfn; - if(ops.TryGetMember(this, "rollback", out rollbackfn)) + if (ops.TryGetMember(this, "rollback", out rollbackfn)) ops.Invoke(rollbackfn); else rollback(); @@ -512,77 +454,64 @@ public object __exit__(CodeContext context, object exc_type, object exc_value, o return false; } - public object iterdump(CodeContext context) - { + public object iterdump(CodeContext context) { throw new NotImplementedException("Not supported with C#-sqlite for unknown reasons."); //var ops = context.LanguageContext.Operations; //PythonModule sqlite3 = Importer.ImportModule(context, context.GlobalScope, "sqlite3", false, -1) as PythonModule; //PythonModule dump = Importer.ImportFrom(context, sqlite3, "dump") as PythonModule; - + //object _iterdump = ops.GetMember(dump, "_iterdump"); //object result = ops.Invoke(_iterdump, this); //return result; } - internal void checkConnection() - { - if(this.db == null) + internal void checkConnection() { + if (this.db == null) throw MakeProgrammingError("Cannot operate on a closed database."); } - internal void checkThread() - { - if(this.check_same_thread) - if(this.thread_ident != Environment.CurrentManagedThreadId) + internal void checkThread() { + if (this.check_same_thread) + if (this.thread_ident != Environment.CurrentManagedThreadId) throw MakeProgrammingError("SQLite objects created in a thread can only be used in that same thread." + "The object was created in thread id {0} and this is thread id {1}".Format( this.thread_ident, Environment.CurrentManagedThreadId)); } - internal static void verify(Connection connection) - { + internal static void verify(Connection connection) { verify(connection, false); } - internal static void verify(Connection connection, bool closed) - { - if(!closed && (connection == null || connection.db == null)) + internal static void verify(Connection connection, bool closed) { + if (!closed && (connection == null || connection.db == null)) throw MakeProgrammingError("Cannot operate on a closed database."); connection.checkThread(); } - private void setIsolationLevel(string isolation_level) - { + private void setIsolationLevel(string isolation_level) { this.begin_statement = null; - if(isolation_level == null) - { + if (isolation_level == null) { this._isolation_level = null; this.commit(); this.inTransaction = false; - } - else - { + } else { this._isolation_level = isolation_level; this.begin_statement = "BEGIN " + isolation_level; } } - private void doAllStatements(AllStatmentsAction action) - { - foreach(WeakReference weakref in this.statements) - { - if(weakref.IsAlive) - { + private void doAllStatements(AllStatmentsAction action) { + foreach (WeakReference weakref in this.statements) { + if (weakref.IsAlive) { Statement statement = weakref.Target as Statement; - if(statement != null) - { - if(action == AllStatmentsAction.Reset) + if (statement != null) { + if (action == AllStatmentsAction.Reset) statement.Reset(); else statement.SqliteFinalize(); diff --git a/Src/IronPython.SQLite/Contants.cs b/Src/IronPython.SQLite/Contants.cs index f3fe63263..ad65e4f3e 100644 --- a/Src/IronPython.SQLite/Contants.cs +++ b/Src/IronPython.SQLite/Contants.cs @@ -7,10 +7,8 @@ using Community.CsharpSqlite; -namespace IronPython.SQLite -{ - public static partial class PythonSQLite - { +namespace IronPython.SQLite { + public static partial class PythonSQLite { public const int SQLITE_OK = Sqlite3.SQLITE_OK; public const int SQLITE_DENY = 1; diff --git a/Src/IronPython.SQLite/Cursor.cs b/Src/IronPython.SQLite/Cursor.cs index 8570ad7ef..4d90c8770 100644 --- a/Src/IronPython.SQLite/Cursor.cs +++ b/Src/IronPython.SQLite/Cursor.cs @@ -9,24 +9,22 @@ using System.Collections; using System.Collections.Generic; using System.Numerics; -using System.Runtime.InteropServices; using System.Text.RegularExpressions; + using Community.CsharpSqlite; + using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; + using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; using sqlite3_stmt = Community.CsharpSqlite.Sqlite3.Vdbe; -namespace IronPython.SQLite -{ - public static partial class PythonSQLite - { +namespace IronPython.SQLite { + public static partial class PythonSQLite { [PythonType] - public class Cursor : IEnumerable - { + public class Cursor : IEnumerable { public const string __doc__ = "SQLite database cursor class."; private Statement statement; @@ -40,9 +38,8 @@ public class Cursor : IEnumerable public int rowcount { get; private set; } - public int? rownumber - { - get { return null; } + public int? rownumber { + get { return null; } } public BigInteger? lastrowid { get; private set; } @@ -53,62 +50,54 @@ public int? rownumber public Connection connection { get; private set; } - public object callproc(string procname) - { + public object callproc(string procname) { throw PythonSQLite.MakeNotSupportedError(); } private CodeContext context; - public Cursor(CodeContext context, Connection connection) - { + public Cursor(CodeContext context, Connection connection) { this.context = context; this.connection = connection; this.arraysize = 1; this.rowcount = -1; - if(this.connection != null) + if (this.connection != null) this.connection.checkThread(); } - ~Cursor() - { - if(this.statement != null) + ~Cursor() { + if (this.statement != null) this.statement.Reset(); } [Documentation("Closes the cursor.")] - public void close() - { + public void close() { connection.checkThread(); connection.checkConnection(); - if(this.statement != null) - { + if (this.statement != null) { this.statement.Reset(); } } [Documentation("Executes a SQL statement.")] - public object execute(CodeContext context, object operation, object args=null) - { + public object execute(CodeContext context, object operation, object args = null) { return queryExecute(context, false, operation, args); } [Documentation("Repeatedly executes a SQL statement.")] - public object executemany(CodeContext context, object operation, object args) - { + public object executemany(CodeContext context, object operation, object args) { return queryExecute(context, true, operation, args); } - private object queryExecute(CodeContext context, bool multiple, object operation_obj, object args) - { - if(!(operation_obj is string)) + private object queryExecute(CodeContext context, bool multiple, object operation_obj, object args) { + if (!(operation_obj is string)) throw CreateThrowable(PythonExceptions.ValueError, "operation parameter must be str or unicode"); string operation = (string)operation_obj; - if(string.IsNullOrEmpty(operation)) + if (string.IsNullOrEmpty(operation)) return null; int rc; @@ -118,21 +107,18 @@ private object queryExecute(CodeContext context, bool multiple, object operation this.next_row = null; IEnumerator parameters_iter = null; - if(multiple) - { - if(args != null) + if (multiple) { + if (args != null) parameters_iter = PythonOps.CreatePythonEnumerator(context, args); - } - else - { + } else { object[] parameters_list = { args }; - if(parameters_list[0] == null) + if (parameters_list[0] == null) parameters_list[0] = new PythonTuple(); parameters_iter = parameters_list.GetEnumerator(); } - if(this.statement != null) + if (this.statement != null) rc = this.statement.Reset(); this.description = null; @@ -141,35 +127,33 @@ private object queryExecute(CodeContext context, bool multiple, object operation // TODO: use stmt cache instead ? this.statement = (Statement)this.connection.__call__(operation); - if(this.statement.in_use) + if (this.statement.in_use) this.statement = new Statement(connection, operation); this.statement.Reset(); this.statement.MarkDirty(); - if(!string.IsNullOrEmpty(connection.begin_statement)) - { - switch(statement.StatementType) - { + if (!string.IsNullOrEmpty(connection.begin_statement)) { + switch (statement.StatementType) { case StatementType.Update: case StatementType.Insert: case StatementType.Delete: case StatementType.Replace: - if(!connection.inTransaction) + if (!connection.inTransaction) connection.begin(); - + break; case StatementType.Other: // it's a DDL statement or something similar // we better COMMIT first so it works for all cases - if(connection.inTransaction) + if (connection.inTransaction) connection.commit(); break; case StatementType.Select: - if(multiple) + if (multiple) throw MakeProgrammingError("You cannot execute SELECT statements in executemany()."); break; @@ -178,9 +162,8 @@ private object queryExecute(CodeContext context, bool multiple, object operation } } - while(true) - { - if(!parameters_iter.MoveNext()) + while (true) { + if (!parameters_iter.MoveNext()) break; object parameters = parameters_iter.Current; @@ -188,45 +171,35 @@ private object queryExecute(CodeContext context, bool multiple, object operation this.statement.MarkDirty(); this.statement.BindParameters(context, parameters); - while(true) - { + while (true) { rc = this.statement.RawStep(); - if(rc == Sqlite3.SQLITE_DONE || rc == Sqlite3.SQLITE_ROW) + if (rc == Sqlite3.SQLITE_DONE || rc == Sqlite3.SQLITE_ROW) break; rc = this.statement.Reset(); - if(rc == Sqlite3.SQLITE_SCHEMA) - { + if (rc == Sqlite3.SQLITE_SCHEMA) { rc = this.statement.Recompile(context, parameters); - if(rc == Sqlite3.SQLITE_OK) - { + if (rc == Sqlite3.SQLITE_OK) { continue; - } - else - { + } else { this.statement.Reset(); throw GetSqliteError(this.connection.db, null); } - } - else - { + } else { this.statement.Reset(); throw GetSqliteError(this.connection.db, null); } } - if(!buildRowCastMap()) + if (!buildRowCastMap()) throw MakeOperationalError("Error while building row_cast_map"); - if(rc == Sqlite3.SQLITE_ROW || (rc == Sqlite3.SQLITE_DONE && this.statement.StatementType == StatementType.Select)) - { - if(this.description == null) - { + if (rc == Sqlite3.SQLITE_ROW || (rc == Sqlite3.SQLITE_DONE && this.statement.StatementType == StatementType.Select)) { + if (this.description == null) { int numcols = Sqlite3.sqlite3_column_count(this.statement.st); object[] new_description = new object[numcols]; - for(int i = 0; i < numcols; ++i) - { + for (int i = 0; i < numcols; ++i) { string name = buildColumnName(Sqlite3.sqlite3_column_name(this.statement.st, i)); object descriptor = new object[] { @@ -246,98 +219,78 @@ private object queryExecute(CodeContext context, bool multiple, object operation } } - if(rc == Sqlite3.SQLITE_ROW) - { - if(multiple) + if (rc == Sqlite3.SQLITE_ROW) { + if (multiple) throw MakeProgrammingError("executemany() can only execute DML statements."); this.next_row = fetchOneRow(context); - } - else if(rc == Sqlite3.SQLITE_DONE && !multiple) - { + } else if (rc == Sqlite3.SQLITE_DONE && !multiple) { this.statement.Reset(); } - switch(this.statement.StatementType) - { + switch (this.statement.StatementType) { case StatementType.Update: case StatementType.Delete: case StatementType.Insert: case StatementType.Replace: - if(this.rowcount == -1) + if (this.rowcount == -1) this.rowcount = 0; this.rowcount += Sqlite3.sqlite3_changes(this.connection.db); break; } - if(!multiple && this.statement.StatementType == StatementType.Insert) - { + if (!multiple && this.statement.StatementType == StatementType.Insert) { this.lastrowid = Sqlite3.sqlite3_last_insert_rowid(this.connection.db); - } - else - { + } else { this.lastrowid = null; } - if(multiple) + if (multiple) rc = this.statement.Reset(); } return this; } - private string buildColumnName(string colname) - { + private string buildColumnName(string colname) { int n = colname.IndexOf('['); return n < 0 ? colname : colname.Substring(0, n).Trim(); } - private object fetchOneRow(CodeContext context) - { + private object fetchOneRow(CodeContext context) { int numcols = Sqlite3.sqlite3_data_count(this.statement.st); object[] row = new object[numcols]; object converter = null; - for(int i = 0; i < numcols; ++i) - { + for (int i = 0; i < numcols; ++i) { object converted = null; - if(this.connection.detect_types != 0) - { + if (this.connection.detect_types != 0) { converter = row_cast_map[i]; - } - else - { + } else { converter = null; } - if(converter != null) - { + if (converter != null) { byte[] val = Sqlite3.sqlite3_column_blob(this.statement.st, i); - if(val == null) - { + if (val == null) { converted = null; - } - else - { + } else { string item = Latin1.GetString(val, 0, val.Length); converted = PythonCalls.Call(context, converter, item); } - } - else - { + } else { int coltype = Sqlite3.sqlite3_column_type(this.statement.st, i); - switch(coltype) - { + switch (coltype) { case Sqlite3.SQLITE_NULL: converted = null; break; case Sqlite3.SQLITE_INTEGER: long l = Sqlite3.sqlite3_column_int64(this.statement.st, i); - if(l < int.MinValue || l > int.MaxValue) + if (l < int.MinValue || l > int.MaxValue) converted = (BigInteger)l; else converted = (int)l; @@ -365,8 +318,7 @@ private object fetchOneRow(CodeContext context) return new PythonTuple(row); } - public Cursor executescript(string operation) - { + public Cursor executescript(string operation) { connection.checkThread(); connection.checkConnection(); this.connection.commit(); @@ -374,9 +326,8 @@ public Cursor executescript(string operation) sqlite3_stmt statement = null; string script = operation; bool statement_completed = false; - while(true) - { - if(Sqlite3.sqlite3_complete(operation) == 0) + while (true) { + if (Sqlite3.sqlite3_complete(operation) == 0) break; statement_completed = true; @@ -386,46 +337,41 @@ public Cursor executescript(string operation) ref statement, ref script); - if(rc != Sqlite3.SQLITE_OK) + if (rc != Sqlite3.SQLITE_OK) throw GetSqliteError(this.connection.db, null); /* execute statement, and ignore results of SELECT statements */ rc = Sqlite3.SQLITE_ROW; - while(rc == Sqlite3.SQLITE_ROW) + while (rc == Sqlite3.SQLITE_ROW) rc = Sqlite3.sqlite3_step(statement); - if(rc != Sqlite3.SQLITE_DONE) - { + if (rc != Sqlite3.SQLITE_DONE) { Sqlite3.sqlite3_finalize(statement); throw GetSqliteError(this.connection.db, null); } rc = Sqlite3.sqlite3_finalize(statement); - if(rc != Sqlite3.SQLITE_OK) + if (rc != Sqlite3.SQLITE_OK) throw GetSqliteError(this.connection.db, null); } - if(!statement_completed) + if (!statement_completed) throw MakeProgrammingError("you did not provide a complete SQL statement"); return this; } - public object __iter__() - { + public object __iter__() { return this; } - public object __next__(CodeContext context) - { + public object __next__(CodeContext context) { object next_row_tuple, next_row; connection.checkThread(); connection.checkConnection(); - if(this.next_row == null) - { - if(this.statement != null) - { + if (this.next_row == null) { + if (this.statement != null) { this.statement.Reset(); this.statement = null; } @@ -436,25 +382,20 @@ public object __next__(CodeContext context) next_row_tuple = this.next_row; this.next_row = null; - if(this.row_factory != null) - { + if (this.row_factory != null) { next_row = PythonCalls.Call(context, this.row_factory, this, next_row_tuple); - } - else - { + } else { next_row = next_row_tuple; } - if(this.statement != null) - { + if (this.statement != null) { int rc = this.statement.RawStep(); - if(rc != Sqlite3.SQLITE_DONE && rc != Sqlite3.SQLITE_ROW) - { + if (rc != Sqlite3.SQLITE_DONE && rc != Sqlite3.SQLITE_ROW) { this.statement.Reset(); throw GetSqliteError(this.connection.db, this.statement.st); } - if(rc == Sqlite3.SQLITE_ROW) + if (rc == Sqlite3.SQLITE_ROW) this.next_row = fetchOneRow(context); } @@ -462,41 +403,33 @@ public object __next__(CodeContext context) } [Documentation("Fetches one row from the resultset.")] - public object fetchone(CodeContext context) - { - try - { + public object fetchone(CodeContext context) { + try { return this.__next__(context); - } - catch(StopIterationException) - { + } catch (StopIterationException) { return null; } } - public object fetchmany(CodeContext context) - { + public object fetchmany(CodeContext context) { return fetchmany(context, this.arraysize); } [Documentation("Fetches several rows from the resultset.")] - public object fetchmany(CodeContext context, int size) - { + public object fetchmany(CodeContext context, int size) { PythonList result = new PythonList(); object item = fetchone(context); - for(int i = 0; i < size && item != null; ++i, item = fetchone(context)) + for (int i = 0; i < size && item != null; ++i, item = fetchone(context)) result.Add(item); return result; } [Documentation("Fetches all rows from the resultset.")] - public object fetchall(CodeContext context) - { + public object fetchall(CodeContext context) { PythonList result = new PythonList(); object item = fetchone(context); - while(item != null) - { + while (item != null) { result.Add(item); item = fetchone(context); } @@ -504,8 +437,7 @@ public object fetchall(CodeContext context) return result; } - public object nextset() - { + public object nextset() { return null; } @@ -515,42 +447,34 @@ public void setinputsizes(object sizes) { } [Documentation("Required by DB-API. Does nothing in IronPython.Sqlite3.")] public void setoutputsize(params object[] args) { } - private bool buildRowCastMap() - { - if(this.connection.detect_types == 0) + private bool buildRowCastMap() { + if (this.connection.detect_types == 0) return true; row_cast_map = new List(); object converter = null; - for(int i = 0; i < Sqlite3.sqlite3_column_count(this.statement.st); ++i) - { + for (int i = 0; i < Sqlite3.sqlite3_column_count(this.statement.st); ++i) { converter = null; - if((this.connection.detect_types & PARSE_COLNAMES) != 0) - { + if ((this.connection.detect_types & PARSE_COLNAMES) != 0) { string colname = Sqlite3.sqlite3_column_name(this.statement.st, i); - if(colname != null) - { + if (colname != null) { Regex matchColname = new Regex(@"\[(\w+)\]"); Match match = matchColname.Match(colname); - if(match.Success) - { + if (match.Success) { string key = match.Groups[1].ToString(); converter = getConverter(key); } } } - if((converter == null) && ((this.connection.detect_types & PARSE_DECLTYPES) != 0)) - { + if ((converter == null) && ((this.connection.detect_types & PARSE_DECLTYPES) != 0)) { string decltype = Sqlite3.sqlite3_column_decltype(this.statement.st, i); - if(decltype != null) - { + if (decltype != null) { Regex matchDecltype = new Regex(@"\b(\w+)\b"); Match match = matchDecltype.Match(decltype); - if(match.Success) - { + if (match.Success) { string py_decltype = match.Groups[1].ToString(); converter = getConverter(py_decltype); } @@ -563,23 +487,19 @@ private bool buildRowCastMap() return true; } - private object getConverter(string key) - { + private object getConverter(string key) { object converter; return converters.TryGetValue(key.ToUpperInvariant(), out converter) ? converter : null; } #region IEnumerable Members - public IEnumerator GetEnumerator() - { + public IEnumerator GetEnumerator() { PythonList results = new PythonList(); - try - { - while(true) + try { + while (true) results.append(this.__next__(this.context)); - } - catch(StopIterationException) { } + } catch (StopIterationException) { } return results.GetEnumerator(); } diff --git a/Src/IronPython.SQLite/Exceptions.cs b/Src/IronPython.SQLite/Exceptions.cs index 99117ae47..978cf76e6 100644 --- a/Src/IronPython.SQLite/Exceptions.cs +++ b/Src/IronPython.SQLite/Exceptions.cs @@ -6,18 +6,17 @@ // using System; + using Community.CsharpSqlite; + using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -namespace IronPython.SQLite -{ - public static partial class PythonSQLite - { - private static void InitModuleExceptions(PythonContext context, PythonDictionary dict) - { +namespace IronPython.SQLite { + public static partial class PythonSQLite { + private static void InitModuleExceptions(PythonContext context, PythonDictionary dict) { Warning = context.EnsureModuleException("sqlite.Warning", PythonExceptions.Warning, dict, "Warning", "_sqlite3"); Error = context.EnsureModuleException("sqlite.Error", PythonExceptions.Exception, dict, "Error", "_sqlite3"); InterfaceError = context.EnsureModuleException("sqlite.InterfaceError", Error, dict, "InterfaceError", "_sqlite3"); @@ -31,78 +30,65 @@ private static void InitModuleExceptions(PythonContext context, PythonDictionary } public static PythonType Warning; - internal static Exception MakeWarning(params object[] args) - { + internal static Exception MakeWarning(params object[] args) { return CreateThrowable(Warning, args); } public static PythonType Error; - internal static Exception MakeError(params object[] args) - { + internal static Exception MakeError(params object[] args) { return CreateThrowable(Error, args); } public static PythonType InterfaceError; - internal static Exception MakeInterfaceError(params object[] args) - { + internal static Exception MakeInterfaceError(params object[] args) { return CreateThrowable(InterfaceError, args); } public static PythonType DatabaseError; - internal static Exception MakeDatabaseError(params object[] args) - { + internal static Exception MakeDatabaseError(params object[] args) { return CreateThrowable(DatabaseError, args); } public static PythonType DataError; - internal static Exception MakeDataError(params object[] args) - { + internal static Exception MakeDataError(params object[] args) { return CreateThrowable(DataError, args); } public static PythonType OperationalError; - internal static Exception MakeOperationalError(params object[] args) - { + internal static Exception MakeOperationalError(params object[] args) { return CreateThrowable(OperationalError, args); } public static PythonType IntegrityError; - internal static Exception MakeIntegrityError(params object[] args) - { + internal static Exception MakeIntegrityError(params object[] args) { return CreateThrowable(IntegrityError, args); } public static PythonType InternalError; - internal static Exception MakeInternalError(params object[] args) - { + internal static Exception MakeInternalError(params object[] args) { return CreateThrowable(InternalError, args); } public static PythonType ProgrammingError; - internal static Exception MakeProgrammingError(params object[] args) - { + internal static Exception MakeProgrammingError(params object[] args) { return CreateThrowable(ProgrammingError, args); } public static PythonType NotSupportedError; - internal static Exception MakeNotSupportedError(params object[] args) - { + internal static Exception MakeNotSupportedError(params object[] args) { return CreateThrowable(NotSupportedError, args); } - internal static Exception GetSqliteError(Sqlite3.sqlite3 db, Sqlite3.Vdbe st) - { + internal static Exception GetSqliteError(Sqlite3.sqlite3 db, Sqlite3.Vdbe st) { /* SQLite often doesn't report anything useful, unless you reset the statement first */ - if(st != null) - { + if (st != null) { Sqlite3.sqlite3_reset(st); } int errorcode = Sqlite3.sqlite3_errcode(db); string errmsg = Sqlite3.sqlite3_errmsg(db); - switch(errorcode) - { + switch (errorcode) { case SQLITE_OK: return null; @@ -146,8 +132,7 @@ internal static Exception GetSqliteError(Sqlite3.sqlite3 db, Sqlite3.Vdbe st) } } - private static Exception CreateThrowable(PythonType type, params object[] args) - { + private static Exception CreateThrowable(PythonType type, params object[] args) { return PythonOps.CreateThrowable(type, args); } } diff --git a/Src/IronPython.SQLite/Extensions.cs b/Src/IronPython.SQLite/Extensions.cs index 40c1cf389..2f556d5e1 100644 --- a/Src/IronPython.SQLite/Extensions.cs +++ b/Src/IronPython.SQLite/Extensions.cs @@ -5,17 +5,13 @@ // Copyright (c) Jeff Hardy 2010-2012. // -namespace IronPython.SQLite -{ - internal static class StringExtensions - { - public static string Format(this string format, params object[] args) - { +namespace IronPython.SQLite { + internal static class StringExtensions { + public static string Format(this string format, params object[] args) { return string.Format(format, args); } - public static bool IsNullOrEmpty(this string value) - { + public static bool IsNullOrEmpty(this string value) { return string.IsNullOrEmpty(value); } } diff --git a/Src/IronPython.SQLite/Properties/AssemblyInfo.cs b/Src/IronPython.SQLite/Properties/AssemblyInfo.cs index e1fc294d1..78ec08d19 100644 --- a/Src/IronPython.SQLite/Properties/AssemblyInfo.cs +++ b/Src/IronPython.SQLite/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; diff --git a/Src/IronPython.SQLite/Row.cs b/Src/IronPython.SQLite/Row.cs index 75215ced7..baef4eb67 100644 --- a/Src/IronPython.SQLite/Row.cs +++ b/Src/IronPython.SQLite/Row.cs @@ -6,65 +6,52 @@ // using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using IronPython.Runtime; using System.Collections; + +using IronPython.Runtime; using IronPython.Runtime.Exceptions; -namespace IronPython.SQLite -{ - public static partial class PythonSQLite - { +namespace IronPython.SQLite { + public static partial class PythonSQLite { [PythonType] - public class Row : IEnumerable - { + public class Row : IEnumerable { private PythonTuple data; private PythonTuple description; - public Row(Cursor cursor, PythonTuple data) - { + public Row(Cursor cursor, PythonTuple data) { this.data = data; this.description = cursor.description; } - public override bool Equals(object obj) - { + public override bool Equals(object obj) { Row other = obj as Row; - if(other == null) + if (other == null) return false; - if(object.ReferenceEquals(this, other)) + if (object.ReferenceEquals(this, other)) return true; return this.description.Equals(other.description) && this.data.Equals(other.data); } - public override int GetHashCode() - { + public override int GetHashCode() { return description.GetHashCode() ^ data.GetHashCode(); } - public object __iter__() - { + public object __iter__() { return data; } - public object this[long i] - { + public object this[long i] { get { return this.data[i]; } } - public object this[string s] - { - get - { - for(int i = 0; i < data.Count; ++i) - { + public object this[string s] { + get { + for (int i = 0; i < data.Count; ++i) { PythonTuple col_desc = (PythonTuple)description[i]; - if(s.Equals((string)col_desc[0], StringComparison.OrdinalIgnoreCase)) + if (s.Equals((string)col_desc[0], StringComparison.OrdinalIgnoreCase)) return data[i]; } @@ -72,12 +59,10 @@ public object this[string s] } } - public PythonList keys() - { + public PythonList keys() { PythonList list = new PythonList(); - for(int i = 0; i < data.Count; ++i) - { + for (int i = 0; i < data.Count; ++i) { list.append(((PythonTuple)description[i])[0]); } @@ -86,8 +71,7 @@ public PythonList keys() #region IEnumerable Members - public IEnumerator GetEnumerator() - { + public IEnumerator GetEnumerator() { return data.GetEnumerator(); } diff --git a/Src/IronPython.SQLite/Statement.cs b/Src/IronPython.SQLite/Statement.cs index 373787b47..8eb121ec6 100644 --- a/Src/IronPython.SQLite/Statement.cs +++ b/Src/IronPython.SQLite/Statement.cs @@ -8,17 +8,17 @@ using System; using System.Collections; using System.Diagnostics; + using Community.CsharpSqlite; + using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; using sqlite3_stmt = Community.CsharpSqlite.Sqlite3.Vdbe; -namespace IronPython.SQLite -{ - internal enum StatementType - { +namespace IronPython.SQLite { + internal enum StatementType { Unknown, Select, Insert, @@ -29,8 +29,7 @@ internal enum StatementType } [DebuggerDisplay("{sql}")] - internal class Statement - { + internal class Statement { private readonly Guid uniqueid; private Sqlite3.sqlite3 db; internal sqlite3_stmt st; @@ -43,8 +42,7 @@ internal class Statement public string Tail { get; private set; } - public Statement(PythonSQLite.Connection connection, string operation) - { + public Statement(PythonSQLite.Connection connection, string operation) { this.uniqueid = Guid.NewGuid(); this.db = connection.db; @@ -52,8 +50,7 @@ public Statement(PythonSQLite.Connection connection, string operation) this.st = null; string tail = null; - if(Sqlite3.sqlite3_prepare(this.db, this.sql, -1, ref this.st, ref tail) != Sqlite3.SQLITE_OK /*TODO: || too much sql */) - { + if (Sqlite3.sqlite3_prepare(this.db, this.sql, -1, ref this.st, ref tail) != Sqlite3.SQLITE_OK /*TODO: || too much sql */) { Sqlite3.sqlite3_finalize(st); this.st = null; throw PythonSQLite.GetSqliteError(this.db, null); @@ -62,8 +59,7 @@ public Statement(PythonSQLite.Connection connection, string operation) this.Tail = tail; } - private Statement(Sqlite3.sqlite3 db, sqlite3_stmt stmt, string operation, string tail) - { + private Statement(Sqlite3.sqlite3 db, sqlite3_stmt stmt, string operation, string tail) { this.uniqueid = Guid.NewGuid(); this.db = db; @@ -73,10 +69,8 @@ private Statement(Sqlite3.sqlite3 db, sqlite3_stmt stmt, string operation, strin this.Tail = tail; } - ~Statement() - { - if(this.st != null) - { + ~Statement() { + if (this.st != null) { Sqlite3.sqlite3_finalize(this.st); } @@ -84,24 +78,22 @@ private Statement(Sqlite3.sqlite3 db, sqlite3_stmt stmt, string operation, strin } private StatementType _type = StatementType.Unknown; - public StatementType StatementType - { - get - { - if(this._type != StatementType.Unknown) + public StatementType StatementType { + get { + if (this._type != StatementType.Unknown) return _type; string s = this.sql.TrimStart(); - if(s.StartsWith("select", StringComparison.InvariantCultureIgnoreCase)) + if (s.StartsWith("select", StringComparison.InvariantCultureIgnoreCase)) this._type = StatementType.Select; - else if(s.StartsWith("insert", StringComparison.InvariantCultureIgnoreCase)) + else if (s.StartsWith("insert", StringComparison.InvariantCultureIgnoreCase)) this._type = StatementType.Insert; - else if(s.StartsWith("update", StringComparison.InvariantCultureIgnoreCase)) + else if (s.StartsWith("update", StringComparison.InvariantCultureIgnoreCase)) this._type = StatementType.Update; - else if(s.StartsWith("delete", StringComparison.InvariantCultureIgnoreCase)) + else if (s.StartsWith("delete", StringComparison.InvariantCultureIgnoreCase)) this._type = StatementType.Delete; - else if(s.StartsWith("replace", StringComparison.InvariantCultureIgnoreCase)) + else if (s.StartsWith("replace", StringComparison.InvariantCultureIgnoreCase)) this._type = StatementType.Replace; else this._type = StatementType.Other; @@ -110,24 +102,22 @@ public StatementType StatementType } } - public void BindParameters(CodeContext context, object parameters) - { - if(bound) + public void BindParameters(CodeContext context, object parameters) { + if (bound) this.ClearParameters(); int num_params_needed = Sqlite3.sqlite3_bind_parameter_count(this.st); - if(parameters == null) - { - if(num_params_needed > 0) + if (parameters == null) { + if (num_params_needed > 0) throw PythonSQLite.MakeProgrammingError("parameters are required but not specified."); else return; } - if(parameters is IDictionary) + if (parameters is IDictionary) BindParameters(context, (IDictionary)parameters, num_params_needed); - else if(parameters is IList) + else if (parameters is IList) BindParameters(context, (IList)parameters, num_params_needed); else throw PythonSQLite.MakeProgrammingError("unknown parameter type"); @@ -135,72 +125,65 @@ public void BindParameters(CodeContext context, object parameters) bound = true; } - private void BindParameters(CodeContext context, IDictionary args, int num_params_needed) - { - for(int i = 1; i <= num_params_needed; ++i) - { + private void BindParameters(CodeContext context, IDictionary args, int num_params_needed) { + for (int i = 1; i <= num_params_needed; ++i) { string binding_name = Sqlite3.sqlite3_bind_parameter_name(this.st, i); - if(string.IsNullOrEmpty(binding_name)) + if (string.IsNullOrEmpty(binding_name)) throw PythonSQLite.MakeProgrammingError("Binding {0} has no name, but you supplied a dictionary (which has only names).".Format(i)); // remove the leading colon binding_name = binding_name.Substring(1); - if(args.Contains(binding_name)) + if (args.Contains(binding_name)) BindParameter(context, i, maybeAdapt(context, args[binding_name])); else throw PythonSQLite.MakeProgrammingError("You did not supply a value for binding {0}.".Format(i)); } } - private void BindParameters(CodeContext context, IList args, int num_params_needed) - { - if(num_params_needed != args.Count) + private void BindParameters(CodeContext context, IList args, int num_params_needed) { + if (num_params_needed != args.Count) throw PythonSQLite.MakeProgrammingError("Incorrect number of bindings supplied."); - for(int i = 0; i < args.Count; ++i) - { + for (int i = 0; i < args.Count; ++i) { BindParameter(context, i + 1, maybeAdapt(context, args[i])); } } - private void BindParameter(CodeContext context, int index, object arg) - { + private void BindParameter(CodeContext context, int index, object arg) { int rc; - if(arg == null) + if (arg == null) rc = Sqlite3.sqlite3_bind_null(st, index); - else if(arg is int) + else if (arg is int) rc = Sqlite3.sqlite3_bind_int(st, index, (int)arg); - else if(arg is bool) + else if (arg is bool) rc = Sqlite3.sqlite3_bind_int(st, index, (bool)arg ? 1 : 0); - else if(arg is long) + else if (arg is long) rc = Sqlite3.sqlite3_bind_int64(st, index, (long)arg); else if (arg is System.Numerics.BigInteger) rc = Sqlite3.sqlite3_bind_int64(st, index, (long)((System.Numerics.BigInteger)arg)); - else if(arg is float) + else if (arg is float) rc = Sqlite3.sqlite3_bind_double(st, index, (float)arg); - else if(arg is double) + else if (arg is double) rc = Sqlite3.sqlite3_bind_double(st, index, (double)arg); - else if(arg is string) + else if (arg is string) rc = Sqlite3.sqlite3_bind_text(st, index, (string)arg, -1, Sqlite3.SQLITE_TRANSIENT); - else if(arg is byte[]) + else if (arg is byte[]) rc = Sqlite3.sqlite3_bind_blob(this.st, index, (byte[])arg, -1, Sqlite3.SQLITE_TRANSIENT); else throw PythonSQLite.MakeInterfaceError("Unable to bind parameter {0} - unsupported type {1}".Format(index, arg.GetType())); - if(rc != Sqlite3.SQLITE_OK) + if (rc != Sqlite3.SQLITE_OK) throw PythonSQLite.MakeInterfaceError("Unable to bind parameter {0}: {1}".Format(index, Sqlite3.sqlite3_errmsg(db))); } - private object maybeAdapt(CodeContext context, object value) - { + private object maybeAdapt(CodeContext context, object value) { return needsAdaptation(context, value) ? adaptValue(context, value) : value; } - private bool needsAdaptation(CodeContext context, object value) - { + private bool needsAdaptation(CodeContext context, object value) { // TODO The check for primitive types could probably be cached like pysqlite does - if(value == null || + if (value == null || value is int || value is bool || value is long || @@ -208,31 +191,26 @@ value is System.Numerics.BigInteger || value is float || value is double || value is string || - value is byte[]) - { + value is byte[]) { object proto = DynamicHelpers.GetPythonTypeFromType(typeof(PythonSQLite.PrepareProtocol)); object type = DynamicHelpers.GetPythonType(value); object key = new PythonTuple(new[] { type, proto }); return PythonSQLite.adapters.ContainsKey(key); - } - else - { + } else { return true; } } - private object adaptValue(CodeContext context, object value) - { + private object adaptValue(CodeContext context, object value) { object proto = DynamicHelpers.GetPythonTypeFromType(typeof(PythonSQLite.PrepareProtocol)); object type = DynamicHelpers.GetPythonType(value); object key = new PythonTuple(new[] { type, proto }); object adapter; - if(PythonSQLite.adapters.TryGetValue(key, out adapter)) - { + if (PythonSQLite.adapters.TryGetValue(key, out adapter)) { object adapted = PythonCalls.Call(context, adapter, value); return adapted; } @@ -240,11 +218,9 @@ private object adaptValue(CodeContext context, object value) // TODO: Use proto? Any value whatsoever? object conform; - if(context.LanguageContext.Operations.TryGetMember(value, "__conform__", out conform)) - { + if (context.LanguageContext.Operations.TryGetMember(value, "__conform__", out conform)) { object adapted = PythonCalls.Call(context, conform, proto); - if(adapted != null) - { + if (adapted != null) { return adapted; } } @@ -252,17 +228,14 @@ private object adaptValue(CodeContext context, object value) return value; } - public int RawStep() - { + public int RawStep() { return Util.Step(st); } - public int SqliteFinalize() - { + public int SqliteFinalize() { int rc = Sqlite3.SQLITE_OK; - if(this.st != null) - { + if (this.st != null) { rc = Sqlite3.sqlite3_finalize(this.st); this.st = null; } @@ -272,40 +245,34 @@ public int SqliteFinalize() return rc; } - public int Reset() - { + public int Reset() { int rc = Sqlite3.SQLITE_OK; - if(this.in_use && this.st != null) - { + if (this.in_use && this.st != null) { rc = Sqlite3.sqlite3_reset(this.st); - if(rc == Sqlite3.SQLITE_OK) + if (rc == Sqlite3.SQLITE_OK) this.in_use = false; } return rc; } - private void ClearParameters() - { - if(Sqlite3.sqlite3_clear_bindings(this.st) != Sqlite3.SQLITE_OK) + private void ClearParameters() { + if (Sqlite3.sqlite3_clear_bindings(this.st) != Sqlite3.SQLITE_OK) throw PythonSQLite.GetSqliteError(this.db, null); } - internal void MarkDirty() - { + internal void MarkDirty() { this.in_use = true; } - internal int Recompile(CodeContext context, object parameters) - { + internal int Recompile(CodeContext context, object parameters) { sqlite3_stmt new_st = null; string tail = null; int rc = Sqlite3.sqlite3_prepare(this.db, this.sql, -1, ref new_st, ref tail); - if(rc == Sqlite3.SQLITE_OK) - { + if (rc == Sqlite3.SQLITE_OK) { Statement new_stmt = new Statement(this.st.db, new_st, this.sql, tail); new_stmt.BindParameters(context, parameters); diff --git a/Src/IronPython.SQLite/Util.cs b/Src/IronPython.SQLite/Util.cs index ab23d0b28..d0a370c5d 100644 --- a/Src/IronPython.SQLite/Util.cs +++ b/Src/IronPython.SQLite/Util.cs @@ -7,13 +7,10 @@ using Community.CsharpSqlite; -namespace IronPython.SQLite -{ - internal static class Util - { - public static int Step(Sqlite3.Vdbe statement) - { - if(statement == null) +namespace IronPython.SQLite { + internal static class Util { + public static int Step(Sqlite3.Vdbe statement) { + if (statement == null) return Sqlite3.SQLITE_OK; else return Sqlite3.sqlite3_step(statement); diff --git a/Src/IronPython.SQLite/_sqlite.cs b/Src/IronPython.SQLite/_sqlite.cs index 732a93db3..9d62d6b28 100644 --- a/Src/IronPython.SQLite/_sqlite.cs +++ b/Src/IronPython.SQLite/_sqlite.cs @@ -7,21 +7,20 @@ using System; using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; using System.Text; + using Community.CsharpSqlite; + using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; + using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; [assembly: PythonModule("_sqlite3", typeof(IronPython.SQLite.PythonSQLite))] -namespace IronPython.SQLite -{ - public static partial class PythonSQLite - { +namespace IronPython.SQLite { + public static partial class PythonSQLite { public static readonly string version = typeof(PythonSQLite).Assembly.GetName().Version.ToString(3); public static readonly string sqlite_version = Sqlite3.sqlite3_version.Replace("(C#)", ""); @@ -33,21 +32,19 @@ public static partial class PythonSQLite internal static Encoding Latin1 = Encoding.GetEncoding("iso-8859-1"); [SpecialName] - public static void PerformModuleReload(PythonContext context, PythonDictionary dict) - { + public static void PerformModuleReload(PythonContext context, PythonDictionary dict) { InitModuleExceptions(context, dict); } public static object connect(CodeContext context, string database, - double timeout=0.0, - int detect_types=0, - string isolation_level=null, - bool check_same_thread=true, - object factory=null, - int cached_statements=0) - { - if(factory == null) + double timeout = 0.0, + int detect_types = 0, + string isolation_level = null, + bool check_same_thread = true, + object factory = null, + int cached_statements = 0) { + if (factory == null) return new Connection(database, timeout, detect_types, isolation_level, check_same_thread, factory, cached_statements); else return PythonCalls.Call(context, factory, database, timeout, detect_types, isolation_level, check_same_thread, factory, cached_statements); @@ -56,8 +53,7 @@ public static object connect(CodeContext context, [Documentation(@"register_adapter(type, callable) Registers an adapter with pysqlite's adapter registry. Non-standard.")] - public static void register_adapter(CodeContext context, PythonType type, object adapter) - { + public static void register_adapter(CodeContext context, PythonType type, object adapter) { object proto = DynamicHelpers.GetPythonTypeFromType(typeof(PrepareProtocol)); object key = new PythonTuple(new object[] { type, proto }); adapters[key] = adapter; @@ -66,8 +62,7 @@ public static void register_adapter(CodeContext context, PythonType type, object [Documentation(@"register_converter(typename, callable) Registers a converter with pysqlite. Non-standard.")] - public static void register_converter(CodeContext context, string type, object converter) - { + public static void register_converter(CodeContext context, string type, object converter) { converters[type.ToUpperInvariant()] = converter; } diff --git a/Src/IronPython.SQLite/c#sqlite/BtreeInt_h.cs b/Src/IronPython.SQLite/c#sqlite/BtreeInt_h.cs index e68d86db3..064daab41 100644 --- a/Src/IronPython.SQLite/c#sqlite/BtreeInt_h.cs +++ b/Src/IronPython.SQLite/c#sqlite/BtreeInt_h.cs @@ -3,515 +3,499 @@ using i16 = System.Int16; using i64 = System.Int64; -using u8 = System.Byte; +using Pgno = System.UInt32; +using sqlite3_int64 = System.Int64; using u16 = System.UInt16; using u32 = System.UInt32; -using u64 = System.UInt64; - -using sqlite3_int64 = System.Int64; -using Pgno = System.UInt32; - -namespace Community.CsharpSqlite -{ - using DbPage = Sqlite3.PgHdr; - - public partial class Sqlite3 - { - /* - ** 2004 April 6 - ** - ** 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 implements a external (disk-based) database using BTrees. - ** For a detailed discussion of BTrees, refer to - ** - ** Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3: - ** "Sorting And Searching", pages 473-480. Addison-Wesley - ** Publishing Company, Reading, Massachusetts. - ** - ** The basic idea is that each page of the file contains N database - ** entries and N+1 pointers to subpages. - ** - ** ---------------------------------------------------------------- - ** | Ptr(0) | Key(0) | Ptr(1) | Key(1) | ... | Key(N-1) | Ptr(N) | - ** ---------------------------------------------------------------- - ** - ** All of the keys on the page that Ptr(0) points to have values less - ** than Key(0). All of the keys on page Ptr(1) and its subpages have - ** values greater than Key(0) and less than Key(1). All of the keys - ** on Ptr(N) and its subpages have values greater than Key(N-1). And - ** so forth. - ** - ** Finding a particular key requires reading O(log(M)) pages from the - ** disk where M is the number of entries in the tree. - ** - ** In this implementation, a single file can hold one or more separate - ** BTrees. Each BTree is identified by the index of its root page. The - ** key and data for any entry are combined to form the "payload". A - ** fixed amount of payload can be carried directly on the database - ** page. If the payload is larger than the preset amount then surplus - ** bytes are stored on overflow pages. The payload for an entry - ** and the preceding pointer are combined to form a "Cell". Each - ** page has a small header which contains the Ptr(N) pointer and other - ** information such as the size of key and data. - ** - ** FORMAT DETAILS - ** - ** The file is divided into pages. The first page is called page 1, - ** the second is page 2, and so forth. A page number of zero indicates - ** "no such page". The page size can be any power of 2 between 512 and 65536. - ** Each page can be either a btree page, a freelist page, an overflow - ** page, or a pointer-map page. - ** - ** The first page is always a btree page. The first 100 bytes of the first - ** 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. - ** 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 - ** 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 - ** - ** 40 4 Schema cookie - ** 44 4 File format of schema layer - ** 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 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 - ** and thus when they need to flush their cache. - ** - ** The max embedded payload fraction is the amount of the total usable - ** space in a page that can be consumed by a single cell for standard - ** B-tree (non-LEAFDATA) tables. A value of 255 means 100%. The default - ** is to limit the maximum cell size so that at least 4 cells will fit - ** on one page. Thus the default max embedded payload fraction is 64. - ** - ** If the payload for a cell is larger than the max payload, then extra - ** payload is spilled to overflow pages. Once an overflow page is allocated, - ** as many bytes as possible are moved into the overflow pages without letting - ** the cell size drop below the min embedded payload fraction. - ** - ** The min leaf payload fraction is like the min embedded payload fraction - ** except that it applies to leaf nodes in a LEAFDATA tree. The maximum - ** payload fraction for a LEAFDATA tree is always 100% (or 255) and it - ** not specified in the header. - ** - ** Each btree pages is divided into three sections: The header, the - ** cell pointer array, and the cell content area. Page 1 also has a 100-byte - ** file header that occurs before the page header. - ** - ** |----------------| - ** | file header | 100 bytes. Page 1 only. - ** |----------------| - ** | page header | 8 bytes for leaves. 12 bytes for interior nodes - ** |----------------| - ** | cell pointer | | 2 bytes per cell. Sorted order. - ** | array | | Grows downward - ** | | v - ** |----------------| - ** | unallocated | - ** | space | - ** |----------------| ^ Grows upwards - ** | cell content | | Arbitrary order interspersed with freeblocks. - ** | area | | and free space fragments. - ** |----------------| - ** - ** The page headers looks like this: - ** - ** OFFSET SIZE DESCRIPTION - ** 0 1 Flags. 1: intkey, 2: zerodata, 4: leafdata, 8: leaf - ** 1 2 byte offset to the first freeblock - ** 3 2 number of cells on this page - ** 5 2 first byte of the cell content area - ** 7 1 number of fragmented free bytes - ** 8 4 Right child (the Ptr(N) value). Omitted on leaves. - ** - ** The flags define the format of this btree page. The leaf flag means that - ** this page has no children. The zerodata flag means that this page carries - ** only keys and no data. The intkey flag means that the key is a integer - ** which is stored in the key size entry of the cell header rather than in - ** the payload area. - ** - ** The cell pointer array begins on the first byte after the page header. - ** The cell pointer array contains zero or more 2-byte numbers which are - ** offsets from the beginning of the page to the cell content in the cell - ** content area. The cell pointers occur in sorted order. The system strives - ** to keep free space after the last cell pointer so that new cells can - ** be easily added without having to defragment the page. - ** - ** Cell content is stored at the very end of the page and grows toward the - ** beginning of the page. - ** - ** Unused space within the cell content area is collected into a linked list of - ** freeblocks. Each freeblock is at least 4 bytes in size. The byte offset - ** to the first freeblock is given in the header. Freeblocks occur in - ** increasing order. Because a freeblock must be at least 4 bytes in size, - ** any group of 3 or fewer unused bytes in the cell content area cannot - ** exist on the freeblock chain. A group of 3 or fewer free bytes is called - ** a fragment. The total number of bytes in all fragments is recorded. - ** in the page header at offset 7. - ** - ** SIZE DESCRIPTION - ** 2 Byte offset of the next freeblock - ** 2 Bytes in this freeblock - ** - ** Cells are of variable length. Cells are stored in the cell content area at - ** the end of the page. Pointers to the cells are in the cell pointer array - ** that immediately follows the page header. Cells is not necessarily - ** contiguous or in order, but cell pointers are contiguous and in order. - ** - ** Cell content makes use of variable length integers. A variable - ** length integer is 1 to 9 bytes where the lower 7 bits of each - ** byte are used. The integer consists of all bytes that have bit 8 set and - ** the first byte with bit 8 clear. The most significant byte of the integer - ** appears first. A variable-length integer may not be more than 9 bytes long. - ** As a special case, all 8 bytes of the 9th byte are used as data. This - ** allows a 64-bit integer to be encoded in 9 bytes. - ** - ** 0x00 becomes 0x00000000 - ** 0x7f becomes 0x0000007f - ** 0x81 0x00 becomes 0x00000080 - ** 0x82 0x00 becomes 0x00000100 - ** 0x80 0x7f becomes 0x0000007f - ** 0x8a 0x91 0xd1 0xac 0x78 becomes 0x12345678 - ** 0x81 0x81 0x81 0x81 0x01 becomes 0x10204081 - ** - ** Variable length integers are used for rowids and to hold the number of - ** bytes of key and data in a btree cell. - ** - ** The content of a cell looks like this: - ** - ** SIZE DESCRIPTION - ** 4 Page number of the left child. Omitted if leaf flag is set. - ** var Number of bytes of data. Omitted if the zerodata flag is set. - ** var Number of bytes of key. Or the key itself if intkey flag is set. - ** * Payload - ** 4 First page of the overflow chain. Omitted if no overflow - ** - ** Overflow pages form a linked list. Each page except the last is completely - ** filled with data (pagesize - 4 bytes). The last page can have as little - ** as 1 byte of data. - ** - ** SIZE DESCRIPTION - ** 4 Page number of next overflow page - ** * Data - ** - ** Freelist pages come in two subtypes: trunk pages and leaf pages. The - ** file header points to the first in a linked list of trunk page. Each trunk - ** page points to multiple leaf pages. The content of a leaf page is - ** unspecified. A trunk page looks like this: - ** - ** SIZE DESCRIPTION - ** 4 Page number of next trunk page - ** 4 Number of leaf pointers on this page - ** * zero or more pages numbers of leaves - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +using u8 = System.Byte; - /* The following value is the maximum cell size assuming a maximum page - ** size give above. - */ - //#define MX_CELL_SIZE(pBt) ((int)(pBt->pageSize-8)) - static int MX_CELL_SIZE( BtShared pBt ) - { - return (int)( pBt.pageSize - 8 ); - } +namespace Community.CsharpSqlite { + using DbPage = Sqlite3.PgHdr; + + public partial class Sqlite3 { + /* + ** 2004 April 6 + ** + ** 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 implements a external (disk-based) database using BTrees. + ** For a detailed discussion of BTrees, refer to + ** + ** Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3: + ** "Sorting And Searching", pages 473-480. Addison-Wesley + ** Publishing Company, Reading, Massachusetts. + ** + ** The basic idea is that each page of the file contains N database + ** entries and N+1 pointers to subpages. + ** + ** ---------------------------------------------------------------- + ** | Ptr(0) | Key(0) | Ptr(1) | Key(1) | ... | Key(N-1) | Ptr(N) | + ** ---------------------------------------------------------------- + ** + ** All of the keys on the page that Ptr(0) points to have values less + ** than Key(0). All of the keys on page Ptr(1) and its subpages have + ** values greater than Key(0) and less than Key(1). All of the keys + ** on Ptr(N) and its subpages have values greater than Key(N-1). And + ** so forth. + ** + ** Finding a particular key requires reading O(log(M)) pages from the + ** disk where M is the number of entries in the tree. + ** + ** In this implementation, a single file can hold one or more separate + ** BTrees. Each BTree is identified by the index of its root page. The + ** key and data for any entry are combined to form the "payload". A + ** fixed amount of payload can be carried directly on the database + ** page. If the payload is larger than the preset amount then surplus + ** bytes are stored on overflow pages. The payload for an entry + ** and the preceding pointer are combined to form a "Cell". Each + ** page has a small header which contains the Ptr(N) pointer and other + ** information such as the size of key and data. + ** + ** FORMAT DETAILS + ** + ** The file is divided into pages. The first page is called page 1, + ** the second is page 2, and so forth. A page number of zero indicates + ** "no such page". The page size can be any power of 2 between 512 and 65536. + ** Each page can be either a btree page, a freelist page, an overflow + ** page, or a pointer-map page. + ** + ** The first page is always a btree page. The first 100 bytes of the first + ** 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. + ** 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 + ** 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 + ** + ** 40 4 Schema cookie + ** 44 4 File format of schema layer + ** 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 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 + ** and thus when they need to flush their cache. + ** + ** The max embedded payload fraction is the amount of the total usable + ** space in a page that can be consumed by a single cell for standard + ** B-tree (non-LEAFDATA) tables. A value of 255 means 100%. The default + ** is to limit the maximum cell size so that at least 4 cells will fit + ** on one page. Thus the default max embedded payload fraction is 64. + ** + ** If the payload for a cell is larger than the max payload, then extra + ** payload is spilled to overflow pages. Once an overflow page is allocated, + ** as many bytes as possible are moved into the overflow pages without letting + ** the cell size drop below the min embedded payload fraction. + ** + ** The min leaf payload fraction is like the min embedded payload fraction + ** except that it applies to leaf nodes in a LEAFDATA tree. The maximum + ** payload fraction for a LEAFDATA tree is always 100% (or 255) and it + ** not specified in the header. + ** + ** Each btree pages is divided into three sections: The header, the + ** cell pointer array, and the cell content area. Page 1 also has a 100-byte + ** file header that occurs before the page header. + ** + ** |----------------| + ** | file header | 100 bytes. Page 1 only. + ** |----------------| + ** | page header | 8 bytes for leaves. 12 bytes for interior nodes + ** |----------------| + ** | cell pointer | | 2 bytes per cell. Sorted order. + ** | array | | Grows downward + ** | | v + ** |----------------| + ** | unallocated | + ** | space | + ** |----------------| ^ Grows upwards + ** | cell content | | Arbitrary order interspersed with freeblocks. + ** | area | | and free space fragments. + ** |----------------| + ** + ** The page headers looks like this: + ** + ** OFFSET SIZE DESCRIPTION + ** 0 1 Flags. 1: intkey, 2: zerodata, 4: leafdata, 8: leaf + ** 1 2 byte offset to the first freeblock + ** 3 2 number of cells on this page + ** 5 2 first byte of the cell content area + ** 7 1 number of fragmented free bytes + ** 8 4 Right child (the Ptr(N) value). Omitted on leaves. + ** + ** The flags define the format of this btree page. The leaf flag means that + ** this page has no children. The zerodata flag means that this page carries + ** only keys and no data. The intkey flag means that the key is a integer + ** which is stored in the key size entry of the cell header rather than in + ** the payload area. + ** + ** The cell pointer array begins on the first byte after the page header. + ** The cell pointer array contains zero or more 2-byte numbers which are + ** offsets from the beginning of the page to the cell content in the cell + ** content area. The cell pointers occur in sorted order. The system strives + ** to keep free space after the last cell pointer so that new cells can + ** be easily added without having to defragment the page. + ** + ** Cell content is stored at the very end of the page and grows toward the + ** beginning of the page. + ** + ** Unused space within the cell content area is collected into a linked list of + ** freeblocks. Each freeblock is at least 4 bytes in size. The byte offset + ** to the first freeblock is given in the header. Freeblocks occur in + ** increasing order. Because a freeblock must be at least 4 bytes in size, + ** any group of 3 or fewer unused bytes in the cell content area cannot + ** exist on the freeblock chain. A group of 3 or fewer free bytes is called + ** a fragment. The total number of bytes in all fragments is recorded. + ** in the page header at offset 7. + ** + ** SIZE DESCRIPTION + ** 2 Byte offset of the next freeblock + ** 2 Bytes in this freeblock + ** + ** Cells are of variable length. Cells are stored in the cell content area at + ** the end of the page. Pointers to the cells are in the cell pointer array + ** that immediately follows the page header. Cells is not necessarily + ** contiguous or in order, but cell pointers are contiguous and in order. + ** + ** Cell content makes use of variable length integers. A variable + ** length integer is 1 to 9 bytes where the lower 7 bits of each + ** byte are used. The integer consists of all bytes that have bit 8 set and + ** the first byte with bit 8 clear. The most significant byte of the integer + ** appears first. A variable-length integer may not be more than 9 bytes long. + ** As a special case, all 8 bytes of the 9th byte are used as data. This + ** allows a 64-bit integer to be encoded in 9 bytes. + ** + ** 0x00 becomes 0x00000000 + ** 0x7f becomes 0x0000007f + ** 0x81 0x00 becomes 0x00000080 + ** 0x82 0x00 becomes 0x00000100 + ** 0x80 0x7f becomes 0x0000007f + ** 0x8a 0x91 0xd1 0xac 0x78 becomes 0x12345678 + ** 0x81 0x81 0x81 0x81 0x01 becomes 0x10204081 + ** + ** Variable length integers are used for rowids and to hold the number of + ** bytes of key and data in a btree cell. + ** + ** The content of a cell looks like this: + ** + ** SIZE DESCRIPTION + ** 4 Page number of the left child. Omitted if leaf flag is set. + ** var Number of bytes of data. Omitted if the zerodata flag is set. + ** var Number of bytes of key. Or the key itself if intkey flag is set. + ** * Payload + ** 4 First page of the overflow chain. Omitted if no overflow + ** + ** Overflow pages form a linked list. Each page except the last is completely + ** filled with data (pagesize - 4 bytes). The last page can have as little + ** as 1 byte of data. + ** + ** SIZE DESCRIPTION + ** 4 Page number of next overflow page + ** * Data + ** + ** Freelist pages come in two subtypes: trunk pages and leaf pages. The + ** file header points to the first in a linked list of trunk page. Each trunk + ** page points to multiple leaf pages. The content of a leaf page is + ** unspecified. A trunk page looks like this: + ** + ** SIZE DESCRIPTION + ** 4 Page number of next trunk page + ** 4 Number of leaf pointers on this page + ** * zero or more pages numbers of leaves + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + + /* The following value is the maximum cell size assuming a maximum page + ** size give above. + */ + //#define MX_CELL_SIZE(pBt) ((int)(pBt->pageSize-8)) + static int MX_CELL_SIZE(BtShared pBt) { + return (int)(pBt.pageSize - 8); + } - /* The maximum number of cells on a single page of the database. This - ** assumes a minimum cell size of 6 bytes (4 bytes for the cell itself - ** plus 2 bytes for the index to the cell in the page header). Such - ** small cells will be rare, but they are possible. - */ - //#define MX_CELL(pBt) ((pBt.pageSize-8)/6) - static int MX_CELL( BtShared pBt ) - { - return ( (int)( pBt.pageSize - 8 ) / 6 ); - } + /* The maximum number of cells on a single page of the database. This + ** assumes a minimum cell size of 6 bytes (4 bytes for the cell itself + ** plus 2 bytes for the index to the cell in the page header). Such + ** small cells will be rare, but they are possible. + */ + //#define MX_CELL(pBt) ((pBt.pageSize-8)/6) + static int MX_CELL(BtShared pBt) { + return ((int)(pBt.pageSize - 8) / 6); + } - /* Forward declarations */ - //typedef struct MemPage MemPage; - //typedef struct BtLock BtLock; - - /* - ** This is a magic string that appears at the beginning of every - ** SQLite database in order to identify the file as a real database. - ** - ** You can change this value at compile-time by specifying a - ** -DSQLITE_FILE_HEADER="..." on the compiler command-line. The - ** header must be exactly 16 bytes including the zero-terminator so - ** the string itself should be 15 characters long. If you change - ** the header, then your custom library will not be able to read - ** databases generated by the standard tools and the standard tools - ** will not be able to read databases created by your custom library. - */ + /* Forward declarations */ + //typedef struct MemPage MemPage; + //typedef struct BtLock BtLock; + + /* + ** This is a magic string that appears at the beginning of every + ** SQLite database in order to identify the file as a real database. + ** + ** You can change this value at compile-time by specifying a + ** -DSQLITE_FILE_HEADER="..." on the compiler command-line. The + ** header must be exactly 16 bytes including the zero-terminator so + ** the string itself should be 15 characters long. If you change + ** the header, then your custom library will not be able to read + ** databases generated by the standard tools and the standard tools + ** will not be able to read databases created by your custom library. + */ #if !SQLITE_FILE_HEADER //* 123456789 123456 */ - const string SQLITE_FILE_HEADER = "SQLite format 3\0"; + const string SQLITE_FILE_HEADER = "SQLite format 3\0"; #endif - /* -** Page type flags. An ORed combination of these flags appear as the -** first byte of on-disk image of every BTree page. -*/ - const byte PTF_INTKEY = 0x01; - const byte PTF_ZERODATA = 0x02; - const byte PTF_LEAFDATA = 0x04; - const byte PTF_LEAF = 0x08; - - /* - ** As each page of the file is loaded into memory, an instance of the following - ** structure is appended and initialized to zero. This structure stores - ** information about the page that is decoded from the raw file page. - ** - ** The pParent field points back to the parent page. This allows us to - ** walk up the BTree from any leaf to the root. Care must be taken to - ** unref() the parent page pointer when this page is no longer referenced. - ** The pageDestructor() routine handles that chore. - ** - ** Access to all fields of this structure is controlled by the mutex - ** stored in MemPage.pBt.mutex. - */ - public struct _OvflCell - { /* Cells that will not fit on aData[] */ - public u8[] pCell; /* Pointers to the body of the overflow cell */ - public u16 idx; /* Insert this cell before idx-th non-overflow cell */ - public _OvflCell Copy() - { - _OvflCell cp = new _OvflCell(); - if ( pCell != null ) - { - cp.pCell = sqlite3Malloc( pCell.Length ); - Buffer.BlockCopy( pCell, 0, cp.pCell, 0, pCell.Length ); - } - cp.idx = idx; - return cp; - } - }; - public class MemPage - { - public u8 isInit; /* True if previously initialized. MUST BE FIRST! */ - public u8 nOverflow; /* Number of overflow cell bodies in aCell[] */ - public u8 intKey; /* True if u8key flag is set */ - public u8 leaf; /* 1 if leaf flag is set */ - public u8 hasData; /* True if this page stores data */ - public u8 hdrOffset; /* 100 for page 1. 0 otherwise */ - public u8 childPtrSize; /* 0 if leaf==1. 4 if leaf==0 */ - public u16 maxLocal; /* Copy of BtShared.maxLocal or BtShared.maxLeaf */ - public u16 minLocal; /* Copy of BtShared.minLocal or BtShared.minLeaf */ - public u16 cellOffset; /* Index in aData of first cell pou16er */ - public u16 nFree; /* Number of free bytes on the page */ - public u16 nCell; /* Number of cells on this page, local and ovfl */ - public u16 maskPage; /* Mask for page offset */ - public _OvflCell[] aOvfl = new _OvflCell[5]; - public BtShared pBt; /* Pointer to BtShared that this page is part of */ - public byte[] aData; /* Pointer to disk image of the page data */ - public DbPage pDbPage; /* Pager page handle */ - public Pgno pgno; /* Page number for this page */ - - //public byte[] aData - //{ - // get - // { - // Debug.Assert( pgno != 1 || pDbPage.pData == _aData ); - // return _aData; - // } - // set - // { - // _aData = value; - // Debug.Assert( pgno != 1 || pDbPage.pData == _aData ); - // } - //} - - public MemPage Copy() - { - MemPage cp = (MemPage)MemberwiseClone(); - if ( aOvfl != null ) - { - cp.aOvfl = new _OvflCell[aOvfl.Length]; - for ( int i = 0; i < aOvfl.Length; i++ ) - cp.aOvfl[i] = aOvfl[i].Copy(); - } - if ( aData != null ) - { - cp.aData = sqlite3Malloc( aData.Length ); - Buffer.BlockCopy( aData, 0, cp.aData, 0, aData.Length ); - } - return cp; - } - }; - - /* - ** The in-memory image of a disk page has the auxiliary information appended - ** to the end. EXTRA_SIZE is the number of bytes of space needed to hold - ** that extra information. + /* + ** Page type flags. An ORed combination of these flags appear as the + ** first byte of on-disk image of every BTree page. */ - const int EXTRA_SIZE = 0;// No used in C#, since we use create a class; was MemPage.Length; - - /* - ** A linked list of the following structures is stored at BtShared.pLock. - ** Locks are added (or upgraded from READ_LOCK to WRITE_LOCK) when a cursor - ** is opened on the table with root page BtShared.iTable. Locks are removed - ** from this list when a transaction is committed or rolled back, or when - ** a btree handle is closed. - */ - public class BtLock - { - Btree pBtree; /* Btree handle holding this lock */ - Pgno iTable; /* Root page of table */ - u8 eLock; /* READ_LOCK or WRITE_LOCK */ - BtLock pNext; /* Next in BtShared.pLock list */ - }; - - /* Candidate values for BtLock.eLock */ - //#define READ_LOCK 1 - //#define WRITE_LOCK 2 - const int READ_LOCK = 1; - const int WRITE_LOCK = 2; - - /* A Btree handle - ** - ** A database connection contains a pointer to an instance of - ** this object for every database file that it has open. This structure - ** is opaque to the database connection. The database connection cannot - ** see the internals of this structure and only deals with pointers to - ** this structure. - ** - ** For some database files, the same underlying database cache might be - ** shared between multiple connections. In that case, each connection - ** has it own instance of this object. But each instance of this object - ** points to the same BtShared object. The database cache and the - ** schema associated with the database file are all contained within - ** the BtShared object. - ** - ** All fields in this structure are accessed under sqlite3.mutex. - ** The pBt pointer itself may not be changed while there exists cursors - ** in the referenced BtShared that point back to this Btree since those - ** cursors have to go through this Btree to find their BtShared and - ** they often do so without holding sqlite3.mutex. - */ - public class Btree - { - public sqlite3 db; /* The database connection holding this Btree */ - public BtShared pBt; /* Sharable content of this Btree */ - public u8 inTrans; /* TRANS_NONE, TRANS_READ or TRANS_WRITE */ - public bool sharable; /* True if we can share pBt with another db */ - public bool locked; /* True if db currently has pBt locked */ - public int wantToLock; /* Number of nested calls to sqlite3BtreeEnter() */ - public int nBackup; /* Number of backup operations reading this btree */ - public Btree pNext; /* List of other sharable Btrees from the same db */ - public Btree pPrev; /* Back pointer of the same list */ + const byte PTF_INTKEY = 0x01; + const byte PTF_ZERODATA = 0x02; + const byte PTF_LEAFDATA = 0x04; + const byte PTF_LEAF = 0x08; + + /* + ** As each page of the file is loaded into memory, an instance of the following + ** structure is appended and initialized to zero. This structure stores + ** information about the page that is decoded from the raw file page. + ** + ** The pParent field points back to the parent page. This allows us to + ** walk up the BTree from any leaf to the root. Care must be taken to + ** unref() the parent page pointer when this page is no longer referenced. + ** The pageDestructor() routine handles that chore. + ** + ** Access to all fields of this structure is controlled by the mutex + ** stored in MemPage.pBt.mutex. + */ + public struct _OvflCell { /* Cells that will not fit on aData[] */ + public u8[] pCell; /* Pointers to the body of the overflow cell */ + public u16 idx; /* Insert this cell before idx-th non-overflow cell */ + public _OvflCell Copy() { + _OvflCell cp = new _OvflCell(); + if (pCell != null) { + cp.pCell = sqlite3Malloc(pCell.Length); + Buffer.BlockCopy(pCell, 0, cp.pCell, 0, pCell.Length); + } + cp.idx = idx; + return cp; + } + }; + public class MemPage { + public u8 isInit; /* True if previously initialized. MUST BE FIRST! */ + public u8 nOverflow; /* Number of overflow cell bodies in aCell[] */ + public u8 intKey; /* True if u8key flag is set */ + public u8 leaf; /* 1 if leaf flag is set */ + public u8 hasData; /* True if this page stores data */ + public u8 hdrOffset; /* 100 for page 1. 0 otherwise */ + public u8 childPtrSize; /* 0 if leaf==1. 4 if leaf==0 */ + public u16 maxLocal; /* Copy of BtShared.maxLocal or BtShared.maxLeaf */ + public u16 minLocal; /* Copy of BtShared.minLocal or BtShared.minLeaf */ + public u16 cellOffset; /* Index in aData of first cell pou16er */ + public u16 nFree; /* Number of free bytes on the page */ + public u16 nCell; /* Number of cells on this page, local and ovfl */ + public u16 maskPage; /* Mask for page offset */ + public _OvflCell[] aOvfl = new _OvflCell[5]; + public BtShared pBt; /* Pointer to BtShared that this page is part of */ + public byte[] aData; /* Pointer to disk image of the page data */ + public DbPage pDbPage; /* Pager page handle */ + public Pgno pgno; /* Page number for this page */ + + //public byte[] aData + //{ + // get + // { + // Debug.Assert( pgno != 1 || pDbPage.pData == _aData ); + // return _aData; + // } + // set + // { + // _aData = value; + // Debug.Assert( pgno != 1 || pDbPage.pData == _aData ); + // } + //} + + public MemPage Copy() { + MemPage cp = (MemPage)MemberwiseClone(); + if (aOvfl != null) { + cp.aOvfl = new _OvflCell[aOvfl.Length]; + for (int i = 0; i < aOvfl.Length; i++) + cp.aOvfl[i] = aOvfl[i].Copy(); + } + if (aData != null) { + cp.aData = sqlite3Malloc(aData.Length); + Buffer.BlockCopy(aData, 0, cp.aData, 0, aData.Length); + } + return cp; + } + }; + + /* + ** The in-memory image of a disk page has the auxiliary information appended + ** to the end. EXTRA_SIZE is the number of bytes of space needed to hold + ** that extra information. + */ + const int EXTRA_SIZE = 0;// No used in C#, since we use create a class; was MemPage.Length; + + /* + ** A linked list of the following structures is stored at BtShared.pLock. + ** Locks are added (or upgraded from READ_LOCK to WRITE_LOCK) when a cursor + ** is opened on the table with root page BtShared.iTable. Locks are removed + ** from this list when a transaction is committed or rolled back, or when + ** a btree handle is closed. + */ + public class BtLock { + Btree pBtree; /* Btree handle holding this lock */ + Pgno iTable; /* Root page of table */ + u8 eLock; /* READ_LOCK or WRITE_LOCK */ + BtLock pNext; /* Next in BtShared.pLock list */ + }; + + /* Candidate values for BtLock.eLock */ + //#define READ_LOCK 1 + //#define WRITE_LOCK 2 + const int READ_LOCK = 1; + const int WRITE_LOCK = 2; + + /* A Btree handle + ** + ** A database connection contains a pointer to an instance of + ** this object for every database file that it has open. This structure + ** is opaque to the database connection. The database connection cannot + ** see the internals of this structure and only deals with pointers to + ** this structure. + ** + ** For some database files, the same underlying database cache might be + ** shared between multiple connections. In that case, each connection + ** has it own instance of this object. But each instance of this object + ** points to the same BtShared object. The database cache and the + ** schema associated with the database file are all contained within + ** the BtShared object. + ** + ** All fields in this structure are accessed under sqlite3.mutex. + ** The pBt pointer itself may not be changed while there exists cursors + ** in the referenced BtShared that point back to this Btree since those + ** cursors have to go through this Btree to find their BtShared and + ** they often do so without holding sqlite3.mutex. + */ + public class Btree { + public sqlite3 db; /* The database connection holding this Btree */ + public BtShared pBt; /* Sharable content of this Btree */ + public u8 inTrans; /* TRANS_NONE, TRANS_READ or TRANS_WRITE */ + public bool sharable; /* True if we can share pBt with another db */ + public bool locked; /* True if db currently has pBt locked */ + public int wantToLock; /* Number of nested calls to sqlite3BtreeEnter() */ + public int nBackup; /* Number of backup operations reading this btree */ + public Btree pNext; /* List of other sharable Btrees from the same db */ + public Btree pPrev; /* Back pointer of the same list */ #if !SQLITE_OMIT_SHARED_CACHE BtLock lock; /* Object used to lock page 1 */ #endif - }; - - /* - ** Btree.inTrans may take one of the following values. - ** - ** If the shared-data extension is enabled, there may be multiple users - ** of the Btree structure. At most one of these may open a write transaction, - ** but any number may have active read transactions. - */ - const byte TRANS_NONE = 0; - const byte TRANS_READ = 1; - const byte TRANS_WRITE = 2; - - /* - ** An instance of this object represents a single database file. - ** - ** A single database file can be in use as the same time by two - ** or more database connections. When two or more connections are - ** sharing the same database file, each connection has it own - ** private Btree object for the file and each of those Btrees points - ** to this one BtShared object. BtShared.nRef is the number of - ** connections currently sharing this database file. - ** - ** Fields in this structure are accessed under the BtShared.mutex - ** mutex, except for nRef and pNext which are accessed under the - ** global SQLITE_MUTEX_STATIC_MASTER mutex. The pPager field - ** may not be modified once it is initially set as long as nRef>0. - ** The pSchema field may be set once under BtShared.mutex and - ** thereafter is unchanged as long as nRef>0. - ** - ** isPending: - ** - ** If a BtShared client fails to obtain a write-lock on a database - ** table (because there exists one or more read-locks on the table), - ** the shared-cache enters 'pending-lock' state and isPending is - ** set to true. - ** - ** The shared-cache leaves the 'pending lock' state when either of - ** the following occur: - ** - ** 1) The current writer (BtShared.pWriter) concludes its transaction, OR - ** 2) The number of locks held by other connections drops to zero. - ** - ** while in the 'pending-lock' state, no connection may start a new - ** transaction. - ** - ** This feature is included to help prevent writer-starvation. - */ - public class BtShared - { - public Pager pPager; /* The page cache */ - public sqlite3 db; /* Database connection currently using this Btree */ - public BtCursor pCursor; /* A list of all open cursors */ - public MemPage pPage1; /* First page of the database */ - public bool readOnly; /* True if the underlying file is readonly */ - public bool pageSizeFixed; /* True if the page size can no longer be changed */ - public bool secureDelete; /* True if secure_delete is enabled */ - public bool initiallyEmpty; /* Database is empty at start of transaction */ - public u8 openFlags; /* Flags to sqlite3BtreeOpen() */ + }; + + /* + ** Btree.inTrans may take one of the following values. + ** + ** If the shared-data extension is enabled, there may be multiple users + ** of the Btree structure. At most one of these may open a write transaction, + ** but any number may have active read transactions. + */ + const byte TRANS_NONE = 0; + const byte TRANS_READ = 1; + const byte TRANS_WRITE = 2; + + /* + ** An instance of this object represents a single database file. + ** + ** A single database file can be in use as the same time by two + ** or more database connections. When two or more connections are + ** sharing the same database file, each connection has it own + ** private Btree object for the file and each of those Btrees points + ** to this one BtShared object. BtShared.nRef is the number of + ** connections currently sharing this database file. + ** + ** Fields in this structure are accessed under the BtShared.mutex + ** mutex, except for nRef and pNext which are accessed under the + ** global SQLITE_MUTEX_STATIC_MASTER mutex. The pPager field + ** may not be modified once it is initially set as long as nRef>0. + ** The pSchema field may be set once under BtShared.mutex and + ** thereafter is unchanged as long as nRef>0. + ** + ** isPending: + ** + ** If a BtShared client fails to obtain a write-lock on a database + ** table (because there exists one or more read-locks on the table), + ** the shared-cache enters 'pending-lock' state and isPending is + ** set to true. + ** + ** The shared-cache leaves the 'pending lock' state when either of + ** the following occur: + ** + ** 1) The current writer (BtShared.pWriter) concludes its transaction, OR + ** 2) The number of locks held by other connections drops to zero. + ** + ** while in the 'pending-lock' state, no connection may start a new + ** transaction. + ** + ** This feature is included to help prevent writer-starvation. + */ + public class BtShared { + public Pager pPager; /* The page cache */ + public sqlite3 db; /* Database connection currently using this Btree */ + public BtCursor pCursor; /* A list of all open cursors */ + public MemPage pPage1; /* First page of the database */ + public bool readOnly; /* True if the underlying file is readonly */ + public bool pageSizeFixed; /* True if the page size can no longer be changed */ + public bool secureDelete; /* True if secure_delete is enabled */ + public bool initiallyEmpty; /* Database is empty at start of transaction */ + public u8 openFlags; /* Flags to sqlite3BtreeOpen() */ #if !SQLITE_OMIT_AUTOVACUUM - public bool autoVacuum; /* True if auto-vacuum is enabled */ - public bool incrVacuum; /* True if incr-vacuum is enabled */ + public bool autoVacuum; /* True if auto-vacuum is enabled */ + public bool incrVacuum; /* True if incr-vacuum is enabled */ #endif - public u8 inTransaction; /* Transaction state */ - public bool doNotUseWAL; /* If true, do not open write-ahead-log file */ - public u16 maxLocal; /* Maximum local payload in non-LEAFDATA tables */ - public u16 minLocal; /* Minimum local payload in non-LEAFDATA tables */ - public u16 maxLeaf; /* Maximum local payload in a LEAFDATA table */ - public u16 minLeaf; /* Minimum local payload in a LEAFDATA table */ - public u32 pageSize; /* Total number of bytes on a page */ - public u32 usableSize; /* Number of usable bytes on each page */ - public int nTransaction; /* Number of open transactions (read + write) */ - public Pgno nPage; /* Number of pages in the database */ - public Schema pSchema; /* Pointer to space allocated by sqlite3BtreeSchema() */ - public dxFreeSchema xFreeSchema;/* Destructor for BtShared.pSchema */ - public sqlite3_mutex mutex; /* Non-recursive mutex required to access this object */ - public Bitvec pHasContent; /* Set of pages moved to free-list this transaction */ + public u8 inTransaction; /* Transaction state */ + public bool doNotUseWAL; /* If true, do not open write-ahead-log file */ + public u16 maxLocal; /* Maximum local payload in non-LEAFDATA tables */ + public u16 minLocal; /* Minimum local payload in non-LEAFDATA tables */ + public u16 maxLeaf; /* Maximum local payload in a LEAFDATA table */ + public u16 minLeaf; /* Minimum local payload in a LEAFDATA table */ + public u32 pageSize; /* Total number of bytes on a page */ + public u32 usableSize; /* Number of usable bytes on each page */ + public int nTransaction; /* Number of open transactions (read + write) */ + public Pgno nPage; /* Number of pages in the database */ + public Schema pSchema; /* Pointer to space allocated by sqlite3BtreeSchema() */ + public dxFreeSchema xFreeSchema;/* Destructor for BtShared.pSchema */ + public sqlite3_mutex mutex; /* Non-recursive mutex required to access this object */ + public Bitvec pHasContent; /* Set of pages moved to free-list this transaction */ #if !SQLITE_OMIT_SHARED_CACHE public int nRef; /* Number of references to this structure */ public BtShared pNext; /* Next on a list of sharable BtShared structs */ @@ -520,304 +504,290 @@ public class BtShared public u8 isExclusive; /* True if pWriter has an EXCLUSIVE lock on the db */ public u8 isPending; /* If waiting for read-locks to clear */ #endif - public byte[] pTmpSpace; /* BtShared.pageSize bytes of space for tmp use */ - }; - - /* - ** An instance of the following structure is used to hold information - ** about a cell. The parseCellPtr() function fills in this structure - ** based on information extract from the raw disk page. - */ - //typedef struct CellInfo CellInfo; - public struct CellInfo - { - public int iCell; /* Offset to start of cell content -- Needed for C# */ - public byte[] pCell; /* Pointer to the start of cell content */ - public i64 nKey; /* The key for INTKEY tables, or number of bytes in key */ - public u32 nData; /* Number of bytes of data */ - public u32 nPayload; /* Total amount of payload */ - public u16 nHeader; /* Size of the cell content header in bytes */ - public u16 nLocal; /* Amount of payload held locally */ - public u16 iOverflow; /* Offset to overflow page number. Zero if no overflow */ - public u16 nSize; /* Size of the cell content on the main b-tree page */ - public bool Equals( CellInfo ci ) - { - if ( ci.iCell >= ci.pCell.Length || iCell >= this.pCell.Length ) - return false; - if ( ci.pCell[ci.iCell] != this.pCell[iCell] ) - return false; - if ( ci.nKey != this.nKey || ci.nData != this.nData || ci.nPayload != this.nPayload ) - return false; - if ( ci.nHeader != this.nHeader || ci.nLocal != this.nLocal ) - return false; - if ( ci.iOverflow != this.iOverflow || ci.nSize != this.nSize ) - return false; - return true; - } - }; - - /* - ** Maximum depth of an SQLite B-Tree structure. Any B-Tree deeper than - ** this will be declared corrupt. This value is calculated based on a - ** maximum database size of 2^31 pages a minimum fanout of 2 for a - ** root-node and 3 for all other internal nodes. - ** - ** If a tree that appears to be taller than this is encountered, it is - ** assumed that the database is corrupt. - */ - //#define BTCURSOR_MAX_DEPTH 20 - const int BTCURSOR_MAX_DEPTH = 20; - - /* - ** A cursor is a pointer to a particular entry within a particular - ** b-tree within a database file. - ** - ** The entry is identified by its MemPage and the index in - ** MemPage.aCell[] of the entry. - ** - ** A single database file can shared by two more database connections, - ** but cursors cannot be shared. Each cursor is associated with a - ** particular database connection identified BtCursor.pBtree.db. - ** - ** Fields in this structure are accessed under the BtShared.mutex - ** found at self.pBt.mutex. - */ - public class BtCursor - { - public Btree pBtree; /* The Btree to which this cursor belongs */ - public BtShared pBt; /* The BtShared this cursor points to */ - public BtCursor pNext; - public BtCursor pPrev; /* Forms a linked list of all cursors */ - public KeyInfo pKeyInfo; /* Argument passed to comparison function */ - public Pgno pgnoRoot; /* The root page of this tree */ - public sqlite3_int64 cachedRowid; /* Next rowid cache. 0 means not valid */ - public CellInfo info = new CellInfo(); /* A parse of the cell we are pointing at */ - public byte[] pKey; /* Saved key that was cursor's last known position */ - public i64 nKey; /* Size of pKey, or last integer key */ - public int skipNext; /* Prev() is noop if negative. Next() is noop if positive */ - public u8 wrFlag; /* True if writable */ - public u8 atLast; /* VdbeCursor pointing to the last entry */ - public bool validNKey; /* True if info.nKey is valid */ - public int eState; /* One of the CURSOR_XXX constants (see below) */ + public byte[] pTmpSpace; /* BtShared.pageSize bytes of space for tmp use */ + }; + + /* + ** An instance of the following structure is used to hold information + ** about a cell. The parseCellPtr() function fills in this structure + ** based on information extract from the raw disk page. + */ + //typedef struct CellInfo CellInfo; + public struct CellInfo { + public int iCell; /* Offset to start of cell content -- Needed for C# */ + public byte[] pCell; /* Pointer to the start of cell content */ + public i64 nKey; /* The key for INTKEY tables, or number of bytes in key */ + public u32 nData; /* Number of bytes of data */ + public u32 nPayload; /* Total amount of payload */ + public u16 nHeader; /* Size of the cell content header in bytes */ + public u16 nLocal; /* Amount of payload held locally */ + public u16 iOverflow; /* Offset to overflow page number. Zero if no overflow */ + public u16 nSize; /* Size of the cell content on the main b-tree page */ + public bool Equals(CellInfo ci) { + if (ci.iCell >= ci.pCell.Length || iCell >= this.pCell.Length) + return false; + if (ci.pCell[ci.iCell] != this.pCell[iCell]) + return false; + if (ci.nKey != this.nKey || ci.nData != this.nData || ci.nPayload != this.nPayload) + return false; + if (ci.nHeader != this.nHeader || ci.nLocal != this.nLocal) + return false; + if (ci.iOverflow != this.iOverflow || ci.nSize != this.nSize) + return false; + return true; + } + }; + + /* + ** Maximum depth of an SQLite B-Tree structure. Any B-Tree deeper than + ** this will be declared corrupt. This value is calculated based on a + ** maximum database size of 2^31 pages a minimum fanout of 2 for a + ** root-node and 3 for all other internal nodes. + ** + ** If a tree that appears to be taller than this is encountered, it is + ** assumed that the database is corrupt. + */ + //#define BTCURSOR_MAX_DEPTH 20 + const int BTCURSOR_MAX_DEPTH = 20; + + /* + ** A cursor is a pointer to a particular entry within a particular + ** b-tree within a database file. + ** + ** The entry is identified by its MemPage and the index in + ** MemPage.aCell[] of the entry. + ** + ** A single database file can shared by two more database connections, + ** but cursors cannot be shared. Each cursor is associated with a + ** particular database connection identified BtCursor.pBtree.db. + ** + ** Fields in this structure are accessed under the BtShared.mutex + ** found at self.pBt.mutex. + */ + public class BtCursor { + public Btree pBtree; /* The Btree to which this cursor belongs */ + public BtShared pBt; /* The BtShared this cursor points to */ + public BtCursor pNext; + public BtCursor pPrev; /* Forms a linked list of all cursors */ + public KeyInfo pKeyInfo; /* Argument passed to comparison function */ + public Pgno pgnoRoot; /* The root page of this tree */ + public sqlite3_int64 cachedRowid; /* Next rowid cache. 0 means not valid */ + public CellInfo info = new CellInfo(); /* A parse of the cell we are pointing at */ + public byte[] pKey; /* Saved key that was cursor's last known position */ + public i64 nKey; /* Size of pKey, or last integer key */ + public int skipNext; /* Prev() is noop if negative. Next() is noop if positive */ + public u8 wrFlag; /* True if writable */ + public u8 atLast; /* VdbeCursor pointing to the last entry */ + public bool validNKey; /* True if info.nKey is valid */ + public int eState; /* One of the CURSOR_XXX constants (see below) */ #if !SQLITE_OMIT_INCRBLOB public Pgno[] aOverflow; /* Cache of overflow page locations */ public bool isIncrblobHandle; /* True if this cursor is an incr. io handle */ #endif - public i16 iPage; /* Index of current page in apPage */ - public u16[] aiIdx = new u16[BTCURSOR_MAX_DEPTH]; /* Current index in apPage[i] */ - public MemPage[] apPage = new MemPage[BTCURSOR_MAX_DEPTH]; /* Pages from root to current page */ - - public void Clear() - { - pNext = null; - pPrev = null; - pKeyInfo = null; - pgnoRoot = 0; - cachedRowid = 0; - info = new CellInfo(); - wrFlag = 0; - atLast = 0; - validNKey = false; - eState = 0; - pKey = null; - nKey = 0; - skipNext = 0; + public i16 iPage; /* Index of current page in apPage */ + public u16[] aiIdx = new u16[BTCURSOR_MAX_DEPTH]; /* Current index in apPage[i] */ + public MemPage[] apPage = new MemPage[BTCURSOR_MAX_DEPTH]; /* Pages from root to current page */ + + public void Clear() { + pNext = null; + pPrev = null; + pKeyInfo = null; + pgnoRoot = 0; + cachedRowid = 0; + info = new CellInfo(); + wrFlag = 0; + atLast = 0; + validNKey = false; + eState = 0; + pKey = null; + nKey = 0; + skipNext = 0; #if !SQLITE_OMIT_INCRBLOB isIncrblobHandle=false; aOverflow= null; #endif - iPage = 0; - } - public BtCursor Copy() - { - BtCursor cp = (BtCursor)MemberwiseClone(); - return cp; - } - }; - - /* - ** Potential values for BtCursor.eState. - ** - ** CURSOR_VALID: - ** VdbeCursor points to a valid entry. getPayload() etc. may be called. - ** - ** CURSOR_INVALID: - ** VdbeCursor does not point to a valid entry. This can happen (for example) - ** because the table is empty or because BtreeCursorFirst() has not been - ** called. - ** - ** CURSOR_REQUIRESEEK: - ** The table that this cursor was opened on still exists, but has been - ** modified since the cursor was last used. The cursor position is saved - ** in variables BtCursor.pKey and BtCursor.nKey. When a cursor is in - ** this state, restoreCursorPosition() can be called to attempt to - ** seek the cursor to the saved position. - ** - ** CURSOR_FAULT: - ** A unrecoverable error (an I/O error or a malloc failure) has occurred - ** on a different connection that shares the BtShared cache with this - ** cursor. The error has left the cache in an inconsistent state. - ** Do nothing else with this cursor. Any attempt to use the cursor - ** should return the error code stored in BtCursor.skip - */ - const int CURSOR_INVALID = 0; - const int CURSOR_VALID = 1; - const int CURSOR_REQUIRESEEK = 2; - const int CURSOR_FAULT = 3; - - /* - ** The database page the PENDING_BYTE occupies. This page is never used. - */ - //# define PENDING_BYTE_PAGE(pBt) PAGER_MJ_PGNO(pBt) - // TODO -- Convert PENDING_BYTE_PAGE to inline - static u32 PENDING_BYTE_PAGE( BtShared pBt ) - { - return (u32)PAGER_MJ_PGNO( pBt.pPager ); - } + iPage = 0; + } + public BtCursor Copy() { + BtCursor cp = (BtCursor)MemberwiseClone(); + return cp; + } + }; + + /* + ** Potential values for BtCursor.eState. + ** + ** CURSOR_VALID: + ** VdbeCursor points to a valid entry. getPayload() etc. may be called. + ** + ** CURSOR_INVALID: + ** VdbeCursor does not point to a valid entry. This can happen (for example) + ** because the table is empty or because BtreeCursorFirst() has not been + ** called. + ** + ** CURSOR_REQUIRESEEK: + ** The table that this cursor was opened on still exists, but has been + ** modified since the cursor was last used. The cursor position is saved + ** in variables BtCursor.pKey and BtCursor.nKey. When a cursor is in + ** this state, restoreCursorPosition() can be called to attempt to + ** seek the cursor to the saved position. + ** + ** CURSOR_FAULT: + ** A unrecoverable error (an I/O error or a malloc failure) has occurred + ** on a different connection that shares the BtShared cache with this + ** cursor. The error has left the cache in an inconsistent state. + ** Do nothing else with this cursor. Any attempt to use the cursor + ** should return the error code stored in BtCursor.skip + */ + const int CURSOR_INVALID = 0; + const int CURSOR_VALID = 1; + const int CURSOR_REQUIRESEEK = 2; + const int CURSOR_FAULT = 3; + + /* + ** The database page the PENDING_BYTE occupies. This page is never used. + */ + //# define PENDING_BYTE_PAGE(pBt) PAGER_MJ_PGNO(pBt) + // TODO -- Convert PENDING_BYTE_PAGE to inline + static u32 PENDING_BYTE_PAGE(BtShared pBt) { + return (u32)PAGER_MJ_PGNO(pBt.pPager); + } - /* - ** These macros define the location of the pointer-map entry for a - ** database page. The first argument to each is the number of usable - ** bytes on each page of the database (often 1024). The second is the - ** page number to look up in the pointer map. - ** - ** PTRMAP_PAGENO returns the database page number of the pointer-map - ** page that stores the required pointer. PTRMAP_PTROFFSET returns - ** the offset of the requested map entry. - ** - ** If the pgno argument passed to PTRMAP_PAGENO is a pointer-map page, - ** then pgno is returned. So (pgno==PTRMAP_PAGENO(pgsz, pgno)) can be - ** used to test if pgno is a pointer-map page. PTRMAP_ISPAGE implements - ** this test. - */ - //#define PTRMAP_PAGENO(pBt, pgno) ptrmapPageno(pBt, pgno) - static Pgno PTRMAP_PAGENO( BtShared pBt, Pgno pgno ) - { - return ptrmapPageno( pBt, pgno ); - } - //#define PTRMAP_PTROFFSET(pgptrmap, pgno) (5*(pgno-pgptrmap-1)) - static u32 PTRMAP_PTROFFSET( u32 pgptrmap, u32 pgno ) - { - return ( 5 * ( pgno - pgptrmap - 1 ) ); - } - //#define PTRMAP_ISPAGE(pBt, pgno) (PTRMAP_PAGENO((pBt),(pgno))==(pgno)) - static bool PTRMAP_ISPAGE( BtShared pBt, u32 pgno ) - { - return ( PTRMAP_PAGENO( ( pBt ), ( pgno ) ) == ( pgno ) ); - } - /* - ** The pointer map is a lookup table that identifies the parent page for - ** each child page in the database file. The parent page is the page that - ** contains a pointer to the child. Every page in the database contains - ** 0 or 1 parent pages. (In this context 'database page' refers - ** to any page that is not part of the pointer map itself.) Each pointer map - ** entry consists of a single byte 'type' and a 4 byte parent page number. - ** The PTRMAP_XXX identifiers below are the valid types. - ** - ** The purpose of the pointer map is to facility moving pages from one - ** position in the file to another as part of autovacuum. When a page - ** is moved, the pointer in its parent must be updated to point to the - ** new location. The pointer map is used to locate the parent page quickly. - ** - ** PTRMAP_ROOTPAGE: The database page is a root-page. The page-number is not - ** used in this case. - ** - ** PTRMAP_FREEPAGE: The database page is an unused (free) page. The page-number - ** is not used in this case. - ** - ** PTRMAP_OVERFLOW1: The database page is the first page in a list of - ** overflow pages. The page number identifies the page that - ** contains the cell with a pointer to this overflow page. - ** - ** PTRMAP_OVERFLOW2: The database page is the second or later page in a list of - ** overflow pages. The page-number identifies the previous - ** page in the overflow page list. - ** - ** PTRMAP_BTREE: The database page is a non-root btree page. The page number - ** identifies the parent page in the btree. - */ - //#define PTRMAP_ROOTPAGE 1 - //#define PTRMAP_FREEPAGE 2 - //#define PTRMAP_OVERFLOW1 3 - //#define PTRMAP_OVERFLOW2 4 - //#define PTRMAP_BTREE 5 - const int PTRMAP_ROOTPAGE = 1; - const int PTRMAP_FREEPAGE = 2; - const int PTRMAP_OVERFLOW1 = 3; - const int PTRMAP_OVERFLOW2 = 4; - const int PTRMAP_BTREE = 5; - - /* A bunch of Debug.Assert() statements to check the transaction state variables - ** of handle p (type Btree*) are internally consistent. - */ + /* + ** These macros define the location of the pointer-map entry for a + ** database page. The first argument to each is the number of usable + ** bytes on each page of the database (often 1024). The second is the + ** page number to look up in the pointer map. + ** + ** PTRMAP_PAGENO returns the database page number of the pointer-map + ** page that stores the required pointer. PTRMAP_PTROFFSET returns + ** the offset of the requested map entry. + ** + ** If the pgno argument passed to PTRMAP_PAGENO is a pointer-map page, + ** then pgno is returned. So (pgno==PTRMAP_PAGENO(pgsz, pgno)) can be + ** used to test if pgno is a pointer-map page. PTRMAP_ISPAGE implements + ** this test. + */ + //#define PTRMAP_PAGENO(pBt, pgno) ptrmapPageno(pBt, pgno) + static Pgno PTRMAP_PAGENO(BtShared pBt, Pgno pgno) { + return ptrmapPageno(pBt, pgno); + } + //#define PTRMAP_PTROFFSET(pgptrmap, pgno) (5*(pgno-pgptrmap-1)) + static u32 PTRMAP_PTROFFSET(u32 pgptrmap, u32 pgno) { + return (5 * (pgno - pgptrmap - 1)); + } + //#define PTRMAP_ISPAGE(pBt, pgno) (PTRMAP_PAGENO((pBt),(pgno))==(pgno)) + static bool PTRMAP_ISPAGE(BtShared pBt, u32 pgno) { + return (PTRMAP_PAGENO((pBt), (pgno)) == (pgno)); + } + /* + ** The pointer map is a lookup table that identifies the parent page for + ** each child page in the database file. The parent page is the page that + ** contains a pointer to the child. Every page in the database contains + ** 0 or 1 parent pages. (In this context 'database page' refers + ** to any page that is not part of the pointer map itself.) Each pointer map + ** entry consists of a single byte 'type' and a 4 byte parent page number. + ** The PTRMAP_XXX identifiers below are the valid types. + ** + ** The purpose of the pointer map is to facility moving pages from one + ** position in the file to another as part of autovacuum. When a page + ** is moved, the pointer in its parent must be updated to point to the + ** new location. The pointer map is used to locate the parent page quickly. + ** + ** PTRMAP_ROOTPAGE: The database page is a root-page. The page-number is not + ** used in this case. + ** + ** PTRMAP_FREEPAGE: The database page is an unused (free) page. The page-number + ** is not used in this case. + ** + ** PTRMAP_OVERFLOW1: The database page is the first page in a list of + ** overflow pages. The page number identifies the page that + ** contains the cell with a pointer to this overflow page. + ** + ** PTRMAP_OVERFLOW2: The database page is the second or later page in a list of + ** overflow pages. The page-number identifies the previous + ** page in the overflow page list. + ** + ** PTRMAP_BTREE: The database page is a non-root btree page. The page number + ** identifies the parent page in the btree. + */ + //#define PTRMAP_ROOTPAGE 1 + //#define PTRMAP_FREEPAGE 2 + //#define PTRMAP_OVERFLOW1 3 + //#define PTRMAP_OVERFLOW2 4 + //#define PTRMAP_BTREE 5 + const int PTRMAP_ROOTPAGE = 1; + const int PTRMAP_FREEPAGE = 2; + const int PTRMAP_OVERFLOW1 = 3; + const int PTRMAP_OVERFLOW2 = 4; + const int PTRMAP_BTREE = 5; + + /* A bunch of Debug.Assert() statements to check the transaction state variables + ** of handle p (type Btree*) are internally consistent. + */ #if DEBUG - //#define btreeIntegrity(p) \ - // Debug.Assert( p.pBt.inTransaction!=TRANS_NONE || p.pBt.nTransaction==0 ); \ - // Debug.Assert( p.pBt.inTransaction>=p.inTrans ); - static void btreeIntegrity( Btree p ) - { - Debug.Assert( p.pBt.inTransaction != TRANS_NONE || p.pBt.nTransaction == 0 ); - Debug.Assert( p.pBt.inTransaction >= p.inTrans ); - } + //#define btreeIntegrity(p) \ + // Debug.Assert( p.pBt.inTransaction!=TRANS_NONE || p.pBt.nTransaction==0 ); \ + // Debug.Assert( p.pBt.inTransaction>=p.inTrans ); + static void btreeIntegrity(Btree p) { + Debug.Assert(p.pBt.inTransaction != TRANS_NONE || p.pBt.nTransaction == 0); + Debug.Assert(p.pBt.inTransaction >= p.inTrans); + } #else static void btreeIntegrity(Btree p) { } #endif - /* -** The ISAUTOVACUUM macro is used within balance_nonroot() to determine -** if the database supports auto-vacuum or not. Because it is used -** within an expression that is an argument to another macro -** (sqliteMallocRaw), it is not possible to use conditional compilation. -** So, this macro is defined instead. -*/ + /* + ** The ISAUTOVACUUM macro is used within balance_nonroot() to determine + ** if the database supports auto-vacuum or not. Because it is used + ** within an expression that is an argument to another macro + ** (sqliteMallocRaw), it is not possible to use conditional compilation. + ** So, this macro is defined instead. + */ #if !SQLITE_OMIT_AUTOVACUUM - //#define ISAUTOVACUUM (pBt.autoVacuum) + //#define ISAUTOVACUUM (pBt.autoVacuum) #else //#define ISAUTOVACUUM 0 public static bool ISAUTOVACUUM =false; #endif - /* -** This structure is passed around through all the sanity checking routines -** in order to keep track of some global state information. -*/ - //typedef struct IntegrityCk IntegrityCk; - public class IntegrityCk - { - public BtShared pBt; /* The tree being checked out */ - public Pager pPager; /* The associated pager. Also accessible by pBt.pPager */ - public Pgno nPage; /* Number of pages in the database */ - public int[] anRef; /* Number of times each page is referenced */ - public int mxErr; /* Stop accumulating errors when this reaches zero */ - public int nErr; /* Number of messages written to zErrMsg so far */ - //public int mallocFailed; /* A memory allocation error has occurred */ - public StrAccum errMsg = new StrAccum( 100 ); /* Accumulate the error message text here */ - }; - - /* - ** Read or write a two- and four-byte big-endian integer values. + /* + ** This structure is passed around through all the sanity checking routines + ** in order to keep track of some global state information. */ - //#define get2byte(x) ((x)[0]<<8 | (x)[1]) - static int get2byte( byte[] p, int offset ) - { - return p[offset + 0] << 8 | p[offset + 1]; - } + //typedef struct IntegrityCk IntegrityCk; + public class IntegrityCk { + public BtShared pBt; /* The tree being checked out */ + public Pager pPager; /* The associated pager. Also accessible by pBt.pPager */ + public Pgno nPage; /* Number of pages in the database */ + public int[] anRef; /* Number of times each page is referenced */ + public int mxErr; /* Stop accumulating errors when this reaches zero */ + public int nErr; /* Number of messages written to zErrMsg so far */ + //public int mallocFailed; /* A memory allocation error has occurred */ + public StrAccum errMsg = new StrAccum(100); /* Accumulate the error message text here */ + }; + + /* + ** Read or write a two- and four-byte big-endian integer values. + */ + //#define get2byte(x) ((x)[0]<<8 | (x)[1]) + static int get2byte(byte[] p, int offset) { + return p[offset + 0] << 8 | p[offset + 1]; + } - //#define put2byte(p,v) ((p)[0] = (u8)((v)>>8), (p)[1] = (u8)(v)) - static void put2byte( byte[] pData, int Offset, u32 v ) - { - pData[Offset + 0] = (byte)( v >> 8 ); - pData[Offset + 1] = (byte)v; - } - static void put2byte( byte[] pData, int Offset, int v ) - { - pData[Offset + 0] = (byte)( v >> 8 ); - pData[Offset + 1] = (byte)v; - } + //#define put2byte(p,v) ((p)[0] = (u8)((v)>>8), (p)[1] = (u8)(v)) + static void put2byte(byte[] pData, int Offset, u32 v) { + pData[Offset + 0] = (byte)(v >> 8); + pData[Offset + 1] = (byte)v; + } + static void put2byte(byte[] pData, int Offset, int v) { + pData[Offset + 0] = (byte)(v >> 8); + pData[Offset + 1] = (byte)v; + } - //#define get4byte sqlite3Get4byte - //#define put4byte sqlite3Put4byte + //#define get4byte sqlite3Get4byte + //#define put4byte sqlite3Put4byte - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/Btree_h.cs b/Src/IronPython.SQLite/c#sqlite/Btree_h.cs index 996516f23..688165138 100644 --- a/Src/IronPython.SQLite/c#sqlite/Btree_h.cs +++ b/Src/IronPython.SQLite/c#sqlite/Btree_h.cs @@ -1,247 +1,243 @@ -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 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. - ** - ************************************************************************* - ** This header file defines the interface that the sqlite B-Tree file - ** subsystem. See comments in the source code for a detailed description - ** of what each interface routine does. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#if !_BTREE_H_ - //#define _BTREE_H_ - - /* TODO: This definition is just included so other modules compile. It - ** needs to be revisited. - */ - const int SQLITE_N_BTREE_META = 10; - - /* - ** If defined as non-zero, auto-vacuum is enabled by default. Otherwise - ** it must be turned on for each database using "PRAGMA auto_vacuum = 1". - */ +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** This header file defines the interface that the sqlite B-Tree file + ** subsystem. See comments in the source code for a detailed description + ** of what each interface routine does. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#if !_BTREE_H_ + //#define _BTREE_H_ + + /* TODO: This definition is just included so other modules compile. It + ** needs to be revisited. + */ + const int SQLITE_N_BTREE_META = 10; + + /* + ** If defined as non-zero, auto-vacuum is enabled by default. Otherwise + ** it must be turned on for each database using "PRAGMA auto_vacuum = 1". + */ #if !SQLITE_DEFAULT_AUTOVACUUM - const int SQLITE_DEFAULT_AUTOVACUUM = 0; + const int SQLITE_DEFAULT_AUTOVACUUM = 0; #endif - const int BTREE_AUTOVACUUM_NONE = 0; /* Do not do auto-vacuum */ - const int BTREE_AUTOVACUUM_FULL = 1; /* Do full auto-vacuum */ - const int BTREE_AUTOVACUUM_INCR = 2; /* Incremental vacuum */ - - /* - ** Forward declarations of structure - */ - //typedef struct Btree Btree; - //typedef struct BtCursor BtCursor; - //typedef struct BtShared BtShared; - - //int sqlite3BtreeOpen( - // sqlite3_vfs *pVfs, /* VFS to use with this b-tree */ - // string zFilename, /* Name of database file to open */ - // sqlite3 db, /* Associated database connection */ - // Btree **ppBtree, /* Return open Btree* here */ - // int flags, /* Flags */ - // int vfsFlags /* Flags passed through to VFS open */ - //); - - /* The flags parameter to sqlite3BtreeOpen can be the bitwise or of the - ** following values. - ** - ** NOTE: These values must match the corresponding PAGER_ values in - ** pager.h. - */ - //#define BTREE_OMIT_JOURNAL 1 /* Do not create or use a rollback journal */ - //#define BTREE_NO_READLOCK 2 /* Omit readlocks on readonly files */ - //#define BTREE_MEMORY 4 /* This is an in-memory DB */ - //#define BTREE_SINGLE 8 /* The file contains at most 1 b-tree */ - //#define BTREE_UNORDERED 16 /* Use of a hash implementation is OK */ - const int BTREE_OMIT_JOURNAL = 1; /* Do not create or use a rollback journal */ - const int BTREE_NO_READLOCK = 2; /* Omit readlocks on readonly files */ - const int BTREE_MEMORY = 4; /* This is an in-memory DB */ - const int BTREE_SINGLE = 8; /* The file contains at most 1 b-tree */ - const int BTREE_UNORDERED = 16; /* Use of a hash implementation is OK */ - - //int sqlite3BtreeClose(Btree); - //int sqlite3BtreeSetCacheSize(Btree*,int); - //int sqlite3BtreeSetSafetyLevel(Btree*,int,int,int); - //int sqlite3BtreeSyncDisabled(Btree); - //int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix); - //int sqlite3BtreeGetPageSize(Btree); - //int sqlite3BtreeMaxPageCount(Btree*,int); - //u32 sqlite3BtreeLastPage(Btree); - //int sqlite3BtreeSecureDelete(Btree*,int); - //int sqlite3BtreeGetReserve(Btree); - //int sqlite3BtreeSetAutoVacuum(Btree , int); - //int sqlite3BtreeGetAutoVacuum(Btree ); - //int sqlite3BtreeBeginTrans(Btree*,int); - //int sqlite3BtreeCommitPhaseOne(Btree*, string zMaster); - //int sqlite3BtreeCommitPhaseTwo(Btree*, int); - //int sqlite3BtreeCommit(Btree); - //int sqlite3BtreeRollback(Btree); - //int sqlite3BtreeBeginStmt(Btree); - //int sqlite3BtreeCreateTable(Btree*, int*, int flags); - //int sqlite3BtreeIsInTrans(Btree); - //int sqlite3BtreeIsInReadTrans(Btree); - //int sqlite3BtreeIsInBackup(Btree); - //void *sqlite3BtreeSchema(Btree , int, void()(void )); - //int sqlite3BtreeSchemaLocked( Btree* pBtree ); - //int sqlite3BtreeLockTable( Btree* pBtree, int iTab, u8 isWriteLock ); - //int sqlite3BtreeSavepoint(Btree *, int, int); - - //string sqlite3BtreeGetFilename(Btree ); - //string sqlite3BtreeGetJournalname(Btree ); - //int sqlite3BtreeCopyFile(Btree *, Btree ); - - //int sqlite3BtreeIncrVacuum(Btree ); - - /* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR - ** of the flags shown below. - ** - ** Every SQLite table must have either BTREE_INTKEY or BTREE_BLOBKEY set. - ** With BTREE_INTKEY, the table key is a 64-bit integer and arbitrary data - ** is stored in the leaves. (BTREE_INTKEY is used for SQL tables.) With - ** BTREE_BLOBKEY, the key is an arbitrary BLOB and no content is stored - ** anywhere - the key is the content. (BTREE_BLOBKEY is used for SQL - ** indices.) - */ - //#define BTREE_INTKEY 1 /* Table has only 64-bit signed integer keys */ - //#define BTREE_BLOBKEY 2 /* Table has keys only - no data */ - const int BTREE_INTKEY = 1; - const int BTREE_BLOBKEY = 2; - - //int sqlite3BtreeDropTable(Btree*, int, int); - //int sqlite3BtreeClearTable(Btree*, int, int); - //void sqlite3BtreeTripAllCursors(Btree*, int); - - //void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue); - //int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value); - - - /* - ** The second parameter to sqlite3BtreeGetMeta or sqlite3BtreeUpdateMeta - ** should be one of the following values. The integer values are assigned - ** to constants so that the offset of the corresponding field in an - ** SQLite database header may be found using the following formula: - ** - ** offset = 36 + (idx * 4) - ** - ** For example, the free-page-count field is located at byte offset 36 of - ** the database file header. The incr-vacuum-flag field is located at - ** byte offset 64 (== 36+4*7). - */ - //#define BTREE_FREE_PAGE_COUNT 0 - //#define BTREE_SCHEMA_VERSION 1 - //#define BTREE_FILE_FORMAT 2 - //#define BTREE_DEFAULT_CACHE_SIZE 3 - //#define BTREE_LARGEST_ROOT_PAGE 4 - //#define BTREE_TEXT_ENCODING 5 - //#define BTREE_USER_VERSION 6 - //#define BTREE_INCR_VACUUM 7 - const int BTREE_FREE_PAGE_COUNT = 0; - const int BTREE_SCHEMA_VERSION = 1; - const int BTREE_FILE_FORMAT = 2; - const int BTREE_DEFAULT_CACHE_SIZE = 3; - const int BTREE_LARGEST_ROOT_PAGE = 4; - const int BTREE_TEXT_ENCODING = 5; - const int BTREE_USER_VERSION = 6; - const int BTREE_INCR_VACUUM = 7; - - //int sqlite3BtreeCursor( - // Btree*, /* BTree containing table to open */ - // int iTable, /* Index of root page */ - // int wrFlag, /* 1 for writing. 0 for read-only */ - // struct KeyInfo*, /* First argument to compare function */ - // BtCursor pCursor /* Space to write cursor structure */ - //); - //int sqlite3BtreeCursorSize(void); - //void sqlite3BtreeCursorZero(BtCursor); - - //int sqlite3BtreeCloseCursor(BtCursor); - //int sqlite3BtreeMovetoUnpacked( - // BtCursor*, - // UnpackedRecord pUnKey, - // i64 intKey, - // int bias, - // int pRes - //); - //int sqlite3BtreeCursorHasMoved(BtCursor*, int); - //int sqlite3BtreeDelete(BtCursor); - //int sqlite3BtreeInsert(BtCursor*, const void pKey, i64 nKey, - // const void pData, int nData, - // int nZero, int bias, int seekResult); - //int sqlite3BtreeFirst(BtCursor*, int pRes); - //int sqlite3BtreeLast(BtCursor*, int pRes); - //int sqlite3BtreeNext(BtCursor*, int pRes); - //int sqlite3BtreeEof(BtCursor); - //int sqlite3BtreePrevious(BtCursor*, int pRes); - //int sqlite3BtreeKeySize(BtCursor*, i64 pSize); - //int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void); - //const void *sqlite3BtreeKeyFetch(BtCursor*, int pAmt); - //const void *sqlite3BtreeDataFetch(BtCursor*, int pAmt); - //int sqlite3BtreeDataSize(BtCursor*, u32 pSize); - //int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void); - //void sqlite3BtreeSetCachedRowid(BtCursor*, sqlite3_int64); - //sqlite3_int64 sqlite3BtreeGetCachedRowid(BtCursor); - - //char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int); - //struct Pager *sqlite3BtreePager(Btree); - - //int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void); - //void sqlite3BtreeCacheOverflow(BtCursor ); - //void sqlite3BtreeClearCursor(BtCursor ); - - //int sqlite3BtreeSetVersion(Btree *pBt, int iVersion); - - //#if !NDEBUG - //int sqlite3BtreeCursorIsValid(BtCursor); - //#endif - - //#if !SQLITE_OMIT_BTREECOUNT - //int sqlite3BtreeCount(BtCursor *, i64 ); - //#endif - - //#if SQLITE_TEST - //int sqlite3BtreeCursorInfo(BtCursor*, int*, int); - //void sqlite3BtreeCursorList(Btree); - //#endif + const int BTREE_AUTOVACUUM_NONE = 0; /* Do not do auto-vacuum */ + const int BTREE_AUTOVACUUM_FULL = 1; /* Do full auto-vacuum */ + const int BTREE_AUTOVACUUM_INCR = 2; /* Incremental vacuum */ + + /* + ** Forward declarations of structure + */ + //typedef struct Btree Btree; + //typedef struct BtCursor BtCursor; + //typedef struct BtShared BtShared; + + //int sqlite3BtreeOpen( + // sqlite3_vfs *pVfs, /* VFS to use with this b-tree */ + // string zFilename, /* Name of database file to open */ + // sqlite3 db, /* Associated database connection */ + // Btree **ppBtree, /* Return open Btree* here */ + // int flags, /* Flags */ + // int vfsFlags /* Flags passed through to VFS open */ + //); + + /* The flags parameter to sqlite3BtreeOpen can be the bitwise or of the + ** following values. + ** + ** NOTE: These values must match the corresponding PAGER_ values in + ** pager.h. + */ + //#define BTREE_OMIT_JOURNAL 1 /* Do not create or use a rollback journal */ + //#define BTREE_NO_READLOCK 2 /* Omit readlocks on readonly files */ + //#define BTREE_MEMORY 4 /* This is an in-memory DB */ + //#define BTREE_SINGLE 8 /* The file contains at most 1 b-tree */ + //#define BTREE_UNORDERED 16 /* Use of a hash implementation is OK */ + const int BTREE_OMIT_JOURNAL = 1; /* Do not create or use a rollback journal */ + const int BTREE_NO_READLOCK = 2; /* Omit readlocks on readonly files */ + const int BTREE_MEMORY = 4; /* This is an in-memory DB */ + const int BTREE_SINGLE = 8; /* The file contains at most 1 b-tree */ + const int BTREE_UNORDERED = 16; /* Use of a hash implementation is OK */ + + //int sqlite3BtreeClose(Btree); + //int sqlite3BtreeSetCacheSize(Btree*,int); + //int sqlite3BtreeSetSafetyLevel(Btree*,int,int,int); + //int sqlite3BtreeSyncDisabled(Btree); + //int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix); + //int sqlite3BtreeGetPageSize(Btree); + //int sqlite3BtreeMaxPageCount(Btree*,int); + //u32 sqlite3BtreeLastPage(Btree); + //int sqlite3BtreeSecureDelete(Btree*,int); + //int sqlite3BtreeGetReserve(Btree); + //int sqlite3BtreeSetAutoVacuum(Btree , int); + //int sqlite3BtreeGetAutoVacuum(Btree ); + //int sqlite3BtreeBeginTrans(Btree*,int); + //int sqlite3BtreeCommitPhaseOne(Btree*, string zMaster); + //int sqlite3BtreeCommitPhaseTwo(Btree*, int); + //int sqlite3BtreeCommit(Btree); + //int sqlite3BtreeRollback(Btree); + //int sqlite3BtreeBeginStmt(Btree); + //int sqlite3BtreeCreateTable(Btree*, int*, int flags); + //int sqlite3BtreeIsInTrans(Btree); + //int sqlite3BtreeIsInReadTrans(Btree); + //int sqlite3BtreeIsInBackup(Btree); + //void *sqlite3BtreeSchema(Btree , int, void()(void )); + //int sqlite3BtreeSchemaLocked( Btree* pBtree ); + //int sqlite3BtreeLockTable( Btree* pBtree, int iTab, u8 isWriteLock ); + //int sqlite3BtreeSavepoint(Btree *, int, int); + + //string sqlite3BtreeGetFilename(Btree ); + //string sqlite3BtreeGetJournalname(Btree ); + //int sqlite3BtreeCopyFile(Btree *, Btree ); + + //int sqlite3BtreeIncrVacuum(Btree ); + + /* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR + ** of the flags shown below. + ** + ** Every SQLite table must have either BTREE_INTKEY or BTREE_BLOBKEY set. + ** With BTREE_INTKEY, the table key is a 64-bit integer and arbitrary data + ** is stored in the leaves. (BTREE_INTKEY is used for SQL tables.) With + ** BTREE_BLOBKEY, the key is an arbitrary BLOB and no content is stored + ** anywhere - the key is the content. (BTREE_BLOBKEY is used for SQL + ** indices.) + */ + //#define BTREE_INTKEY 1 /* Table has only 64-bit signed integer keys */ + //#define BTREE_BLOBKEY 2 /* Table has keys only - no data */ + const int BTREE_INTKEY = 1; + const int BTREE_BLOBKEY = 2; + + //int sqlite3BtreeDropTable(Btree*, int, int); + //int sqlite3BtreeClearTable(Btree*, int, int); + //void sqlite3BtreeTripAllCursors(Btree*, int); + + //void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue); + //int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value); + + + /* + ** The second parameter to sqlite3BtreeGetMeta or sqlite3BtreeUpdateMeta + ** should be one of the following values. The integer values are assigned + ** to constants so that the offset of the corresponding field in an + ** SQLite database header may be found using the following formula: + ** + ** offset = 36 + (idx * 4) + ** + ** For example, the free-page-count field is located at byte offset 36 of + ** the database file header. The incr-vacuum-flag field is located at + ** byte offset 64 (== 36+4*7). + */ + //#define BTREE_FREE_PAGE_COUNT 0 + //#define BTREE_SCHEMA_VERSION 1 + //#define BTREE_FILE_FORMAT 2 + //#define BTREE_DEFAULT_CACHE_SIZE 3 + //#define BTREE_LARGEST_ROOT_PAGE 4 + //#define BTREE_TEXT_ENCODING 5 + //#define BTREE_USER_VERSION 6 + //#define BTREE_INCR_VACUUM 7 + const int BTREE_FREE_PAGE_COUNT = 0; + const int BTREE_SCHEMA_VERSION = 1; + const int BTREE_FILE_FORMAT = 2; + const int BTREE_DEFAULT_CACHE_SIZE = 3; + const int BTREE_LARGEST_ROOT_PAGE = 4; + const int BTREE_TEXT_ENCODING = 5; + const int BTREE_USER_VERSION = 6; + const int BTREE_INCR_VACUUM = 7; + + //int sqlite3BtreeCursor( + // Btree*, /* BTree containing table to open */ + // int iTable, /* Index of root page */ + // int wrFlag, /* 1 for writing. 0 for read-only */ + // struct KeyInfo*, /* First argument to compare function */ + // BtCursor pCursor /* Space to write cursor structure */ + //); + //int sqlite3BtreeCursorSize(void); + //void sqlite3BtreeCursorZero(BtCursor); + + //int sqlite3BtreeCloseCursor(BtCursor); + //int sqlite3BtreeMovetoUnpacked( + // BtCursor*, + // UnpackedRecord pUnKey, + // i64 intKey, + // int bias, + // int pRes + //); + //int sqlite3BtreeCursorHasMoved(BtCursor*, int); + //int sqlite3BtreeDelete(BtCursor); + //int sqlite3BtreeInsert(BtCursor*, const void pKey, i64 nKey, + // const void pData, int nData, + // int nZero, int bias, int seekResult); + //int sqlite3BtreeFirst(BtCursor*, int pRes); + //int sqlite3BtreeLast(BtCursor*, int pRes); + //int sqlite3BtreeNext(BtCursor*, int pRes); + //int sqlite3BtreeEof(BtCursor); + //int sqlite3BtreePrevious(BtCursor*, int pRes); + //int sqlite3BtreeKeySize(BtCursor*, i64 pSize); + //int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void); + //const void *sqlite3BtreeKeyFetch(BtCursor*, int pAmt); + //const void *sqlite3BtreeDataFetch(BtCursor*, int pAmt); + //int sqlite3BtreeDataSize(BtCursor*, u32 pSize); + //int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void); + //void sqlite3BtreeSetCachedRowid(BtCursor*, sqlite3_int64); + //sqlite3_int64 sqlite3BtreeGetCachedRowid(BtCursor); + + //char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int); + //struct Pager *sqlite3BtreePager(Btree); + + //int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void); + //void sqlite3BtreeCacheOverflow(BtCursor ); + //void sqlite3BtreeClearCursor(BtCursor ); + + //int sqlite3BtreeSetVersion(Btree *pBt, int iVersion); + + //#if !NDEBUG + //int sqlite3BtreeCursorIsValid(BtCursor); + //#endif + + //#if !SQLITE_OMIT_BTREECOUNT + //int sqlite3BtreeCount(BtCursor *, i64 ); + //#endif + + //#if SQLITE_TEST + //int sqlite3BtreeCursorInfo(BtCursor*, int*, int); + //void sqlite3BtreeCursorList(Btree); + //#endif #if !SQLITE_OMIT_WAL //int sqlite3BtreeCheckpoint(Btree*, int, int *, int ); #endif - /* -** If we are not using shared cache, then there is no need to -** use mutexes to access the BtShared structures. So make the -** Enter and Leave procedures no-ops. -*/ + /* + ** If we are not using shared cache, then there is no need to + ** use mutexes to access the BtShared structures. So make the + ** Enter and Leave procedures no-ops. + */ #if !SQLITE_OMIT_SHARED_CACHE //void sqlite3BtreeEnter(Btree); //void sqlite3BtreeEnterAll(sqlite3); #else - //# define sqlite3BtreeEnter(X) - static void sqlite3BtreeEnter( Btree bt ) - { - } - //# define sqlite3BtreeEnterAll(X) - static void sqlite3BtreeEnterAll( sqlite3 p ) - { - } + //# define sqlite3BtreeEnter(X) + static void sqlite3BtreeEnter(Btree bt) { + } + //# define sqlite3BtreeEnterAll(X) + static void sqlite3BtreeEnterAll(sqlite3 p) { + } #endif #if !(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE @@ -257,50 +253,42 @@ static void sqlite3BtreeEnterAll( sqlite3 p ) int sqlite3SchemaMutexHeld(sqlite3*,int,Schema); #endif #else - //# define sqlite3BtreeSharable(X) 0 - static bool sqlite3BtreeSharable( Btree X ) - { - return false; - } - - //# define sqlite3BtreeLeave(X) - static void sqlite3BtreeLeave( Btree X ) - { - } - - //# define sqlite3BtreeEnterCursor(X) - static void sqlite3BtreeEnterCursor( BtCursor X ) - { - } - - //# define sqlite3BtreeLeaveCursor(X) - static void sqlite3BtreeLeaveCursor( BtCursor X ) - { - } - - //# define sqlite3BtreeLeaveAll(X) - static void sqlite3BtreeLeaveAll( sqlite3 X ) - { - } - - //# define sqlite3BtreeHoldsMutex(X) 1 - static bool sqlite3BtreeHoldsMutex( Btree X ) - { - return true; - } - - //# define sqlite3BtreeHoldsAllMutexes(X) 1 - static bool sqlite3BtreeHoldsAllMutexes( sqlite3 X ) - { - return true; - } - //# define sqlite3SchemaMutexHeld(X,Y,Z) 1 - static bool sqlite3SchemaMutexHeld( sqlite3 X, int y, Schema z ) - { - return true; - } + //# define sqlite3BtreeSharable(X) 0 + static bool sqlite3BtreeSharable(Btree X) { + return false; + } + + //# define sqlite3BtreeLeave(X) + static void sqlite3BtreeLeave(Btree X) { + } + + //# define sqlite3BtreeEnterCursor(X) + static void sqlite3BtreeEnterCursor(BtCursor X) { + } + + //# define sqlite3BtreeLeaveCursor(X) + static void sqlite3BtreeLeaveCursor(BtCursor X) { + } + + //# define sqlite3BtreeLeaveAll(X) + static void sqlite3BtreeLeaveAll(sqlite3 X) { + } + + //# define sqlite3BtreeHoldsMutex(X) 1 + static bool sqlite3BtreeHoldsMutex(Btree X) { + return true; + } + + //# define sqlite3BtreeHoldsAllMutexes(X) 1 + static bool sqlite3BtreeHoldsAllMutexes(sqlite3 X) { + return true; + } + //# define sqlite3SchemaMutexHeld(X,Y,Z) 1 + static bool sqlite3SchemaMutexHeld(sqlite3 X, int y, Schema z) { + return true; + } #endif - //#endif // * _BTREE_H_ */ - } + //#endif // * _BTREE_H_ */ + } } diff --git a/Src/IronPython.SQLite/c#sqlite/Delegates.cs b/Src/IronPython.SQLite/c#sqlite/Delegates.cs index 97a7aeb4f..e59053ae5 100644 --- a/Src/IronPython.SQLite/c#sqlite/Delegates.cs +++ b/Src/IronPython.SQLite/c#sqlite/Delegates.cs @@ -7,103 +7,101 @@ using System; using System.Text; + using HANDLE = System.IntPtr; -using i16 = System.Int16; using sqlite3_int64 = System.Int64; using u32 = System.UInt32; -namespace Community.CsharpSqlite -{ - using DbPage = Sqlite3.PgHdr; - using sqlite3_pcache = Sqlite3.PCache1; - using sqlite3_stmt = Sqlite3.Vdbe; - using sqlite3_value = Sqlite3.Mem; +namespace Community.CsharpSqlite { + using DbPage = Sqlite3.PgHdr; + using sqlite3_pcache = Sqlite3.PCache1; + using sqlite3_stmt = Sqlite3.Vdbe; + using sqlite3_value = Sqlite3.Mem; - public partial class Sqlite3 - { - public delegate void dxAuth( object pAuthArg, int b, string c, string d, string e, string f ); - public delegate int dxBusy( object pBtShared, int iValue ); - public delegate void dxFreeAux( object pAuxArg ); - public delegate int dxCallback( object pCallbackArg, sqlite3_int64 argc, object p2, object p3 ); - public delegate void dxalarmCallback( object pNotUsed, sqlite3_int64 iNotUsed, int size ); - public delegate void dxCollNeeded( object pCollNeededArg, sqlite3 db, int eTextRep, string collationName ); - public delegate int dxCommitCallback( object pCommitArg ); - public delegate int dxCompare( object pCompareArg, int size1, string Key1, int size2, string Key2 ); - public delegate bool dxCompare4( string Key1, int size1, string Key2, int size2 ); - public delegate void dxDel( ref string pDelArg ); // needs ref - public delegate void dxDelCollSeq( ref object pDelArg ); // needs ref - public delegate void dxLog( object pLogArg, int i, string msg ); - public delegate void dxLogcallback( object pCallbackArg, int argc, string p2 ); - public delegate void dxProfile( object pProfileArg, string msg, sqlite3_int64 time ); - public delegate int dxProgress( object pProgressArg ); - public delegate void dxRollbackCallback( object pRollbackArg ); - public delegate void dxTrace( object pTraceArg, string msg ); - public delegate void dxUpdateCallback( object pUpdateArg, int b, string c, string d, sqlite3_int64 e ); - public delegate int dxWalCallback( object pWalArg, sqlite3 db, string zDb, int nEntry ); + public partial class Sqlite3 { + public delegate void dxAuth(object pAuthArg, int b, string c, string d, string e, string f); + public delegate int dxBusy(object pBtShared, int iValue); + public delegate void dxFreeAux(object pAuxArg); + public delegate int dxCallback(object pCallbackArg, sqlite3_int64 argc, object p2, object p3); + public delegate void dxalarmCallback(object pNotUsed, sqlite3_int64 iNotUsed, int size); + public delegate void dxCollNeeded(object pCollNeededArg, sqlite3 db, int eTextRep, string collationName); + public delegate int dxCommitCallback(object pCommitArg); + public delegate int dxCompare(object pCompareArg, int size1, string Key1, int size2, string Key2); + public delegate bool dxCompare4(string Key1, int size1, string Key2, int size2); + public delegate void dxDel(ref string pDelArg); // needs ref + public delegate void dxDelCollSeq(ref object pDelArg); // needs ref + public delegate void dxLog(object pLogArg, int i, string msg); + public delegate void dxLogcallback(object pCallbackArg, int argc, string p2); + public delegate void dxProfile(object pProfileArg, string msg, sqlite3_int64 time); + public delegate int dxProgress(object pProgressArg); + public delegate void dxRollbackCallback(object pRollbackArg); + public delegate void dxTrace(object pTraceArg, string msg); + public delegate void dxUpdateCallback(object pUpdateArg, int b, string c, string d, sqlite3_int64 e); + public delegate int dxWalCallback(object pWalArg, sqlite3 db, string zDb, int nEntry); - /* - * FUNCTIONS - * - */ - public delegate void dxFunc( sqlite3_context ctx, int intValue, sqlite3_value[] value ); - public delegate void dxStep( sqlite3_context ctx, int intValue, sqlite3_value[] value ); - public delegate void dxFinal( sqlite3_context ctx ); - public delegate void dxFDestroy( object pArg ); - // - public delegate string dxColname( sqlite3_value pVal ); - public delegate int dxFuncBtree( Btree p ); - public delegate int dxExprTreeFunction( ref int pArg, Expr pExpr ); - public delegate int dxExprTreeFunction_NC( NameContext pArg, ref Expr pExpr ); - public delegate int dxExprTreeFunction_OBJ( object pArg, Expr pExpr ); - /* - VFS Delegates - */ - public delegate int dxClose( sqlite3_file File_ID ); - public delegate int dxCheckReservedLock( sqlite3_file File_ID, ref int pRes ); - public delegate int dxDeviceCharacteristics( sqlite3_file File_ID ); - public delegate int dxFileControl( sqlite3_file File_ID, int op, ref sqlite3_int64 pArgs ); - public delegate int dxFileSize( sqlite3_file File_ID, ref long size ); - public delegate int dxLock( sqlite3_file File_ID, int locktype ); - public delegate int dxRead( sqlite3_file File_ID, byte[] buffer, int amount, sqlite3_int64 offset ); - public delegate int dxSectorSize( sqlite3_file File_ID ); - public delegate int dxSync( sqlite3_file File_ID, int flags ); - public delegate int dxTruncate( sqlite3_file File_ID, sqlite3_int64 size ); - public delegate int dxUnlock( sqlite3_file File_ID, int locktype ); - public delegate int dxWrite( sqlite3_file File_ID, byte[] buffer, int amount, sqlite3_int64 offset ); - public delegate int dxShmMap( sqlite3_file File_ID, int iPg, int pgsz, int pInt, out object pvolatile ); - public delegate int dxShmLock( sqlite3_file File_ID, int offset, int n, int flags ); - public delegate void dxShmBarrier( sqlite3_file File_ID ); - public delegate int dxShmUnmap( sqlite3_file File_ID, int deleteFlag ); - /* - sqlite_vfs Delegates - */ - public delegate int dxOpen( sqlite3_vfs vfs, string zName, sqlite3_file db, int flags, out int pOutFlags ); - public delegate int dxDelete( sqlite3_vfs vfs, string zName, int syncDir ); - public delegate int dxAccess( sqlite3_vfs vfs, string zName, int flags, out int pResOut ); - public delegate int dxFullPathname( sqlite3_vfs vfs, string zName, int nOut, StringBuilder zOut ); - public delegate HANDLE dxDlOpen( sqlite3_vfs vfs, string zFilename ); - public delegate int dxDlError( sqlite3_vfs vfs, int nByte, string zErrMsg ); - public delegate HANDLE dxDlSym( sqlite3_vfs vfs, HANDLE data, string zSymbol ); - public delegate int dxDlClose( sqlite3_vfs vfs, HANDLE data ); - public delegate int dxRandomness( sqlite3_vfs vfs, int nByte, byte[] buffer ); - public delegate int dxSleep( sqlite3_vfs vfs, int microseconds ); - public delegate int dxCurrentTime( sqlite3_vfs vfs, ref double currenttime ); - public delegate int dxGetLastError( sqlite3_vfs pVfs, int nBuf, ref string zBuf ); - public delegate int dxCurrentTimeInt64( sqlite3_vfs pVfs, ref sqlite3_int64 pTime ); - public delegate int dxSetSystemCall( sqlite3_vfs pVfs, string zName, sqlite3_int64 sqlite3_syscall_ptr ); - public delegate int dxGetSystemCall( sqlite3_vfs pVfs, string zName, sqlite3_int64 sqlite3_syscall_ptr ); - public delegate int dxNextSystemCall( sqlite3_vfs pVfs, string zName, sqlite3_int64 sqlite3_syscall_ptr ); + /* + * FUNCTIONS + * + */ + public delegate void dxFunc(sqlite3_context ctx, int intValue, sqlite3_value[] value); + public delegate void dxStep(sqlite3_context ctx, int intValue, sqlite3_value[] value); + public delegate void dxFinal(sqlite3_context ctx); + public delegate void dxFDestroy(object pArg); + // + public delegate string dxColname(sqlite3_value pVal); + public delegate int dxFuncBtree(Btree p); + public delegate int dxExprTreeFunction(ref int pArg, Expr pExpr); + public delegate int dxExprTreeFunction_NC(NameContext pArg, ref Expr pExpr); + public delegate int dxExprTreeFunction_OBJ(object pArg, Expr pExpr); + /* + VFS Delegates + */ + public delegate int dxClose(sqlite3_file File_ID); + public delegate int dxCheckReservedLock(sqlite3_file File_ID, ref int pRes); + public delegate int dxDeviceCharacteristics(sqlite3_file File_ID); + public delegate int dxFileControl(sqlite3_file File_ID, int op, ref sqlite3_int64 pArgs); + public delegate int dxFileSize(sqlite3_file File_ID, ref long size); + public delegate int dxLock(sqlite3_file File_ID, int locktype); + public delegate int dxRead(sqlite3_file File_ID, byte[] buffer, int amount, sqlite3_int64 offset); + public delegate int dxSectorSize(sqlite3_file File_ID); + public delegate int dxSync(sqlite3_file File_ID, int flags); + public delegate int dxTruncate(sqlite3_file File_ID, sqlite3_int64 size); + public delegate int dxUnlock(sqlite3_file File_ID, int locktype); + public delegate int dxWrite(sqlite3_file File_ID, byte[] buffer, int amount, sqlite3_int64 offset); + public delegate int dxShmMap(sqlite3_file File_ID, int iPg, int pgsz, int pInt, out object pvolatile); + public delegate int dxShmLock(sqlite3_file File_ID, int offset, int n, int flags); + public delegate void dxShmBarrier(sqlite3_file File_ID); + public delegate int dxShmUnmap(sqlite3_file File_ID, int deleteFlag); + /* + sqlite_vfs Delegates + */ + public delegate int dxOpen(sqlite3_vfs vfs, string zName, sqlite3_file db, int flags, out int pOutFlags); + public delegate int dxDelete(sqlite3_vfs vfs, string zName, int syncDir); + public delegate int dxAccess(sqlite3_vfs vfs, string zName, int flags, out int pResOut); + public delegate int dxFullPathname(sqlite3_vfs vfs, string zName, int nOut, StringBuilder zOut); + public delegate HANDLE dxDlOpen(sqlite3_vfs vfs, string zFilename); + public delegate int dxDlError(sqlite3_vfs vfs, int nByte, string zErrMsg); + public delegate HANDLE dxDlSym(sqlite3_vfs vfs, HANDLE data, string zSymbol); + public delegate int dxDlClose(sqlite3_vfs vfs, HANDLE data); + public delegate int dxRandomness(sqlite3_vfs vfs, int nByte, byte[] buffer); + public delegate int dxSleep(sqlite3_vfs vfs, int microseconds); + public delegate int dxCurrentTime(sqlite3_vfs vfs, ref double currenttime); + public delegate int dxGetLastError(sqlite3_vfs pVfs, int nBuf, ref string zBuf); + public delegate int dxCurrentTimeInt64(sqlite3_vfs pVfs, ref sqlite3_int64 pTime); + public delegate int dxSetSystemCall(sqlite3_vfs pVfs, string zName, sqlite3_int64 sqlite3_syscall_ptr); + public delegate int dxGetSystemCall(sqlite3_vfs pVfs, string zName, sqlite3_int64 sqlite3_syscall_ptr); + public delegate int dxNextSystemCall(sqlite3_vfs pVfs, string zName, sqlite3_int64 sqlite3_syscall_ptr); - /* - * Pager Delegates - */ + /* + * Pager Delegates + */ - public delegate void dxDestructor( DbPage dbPage ); /* Call this routine when freeing pages */ - public delegate int dxBusyHandler( object pBusyHandlerArg ); - public delegate void dxReiniter( DbPage dbPage ); /* Call this routine when reloading pages */ + public delegate void dxDestructor(DbPage dbPage); /* Call this routine when freeing pages */ + public delegate int dxBusyHandler(object pBusyHandlerArg); + public delegate void dxReiniter(DbPage dbPage); /* Call this routine when reloading pages */ - public delegate void dxFreeSchema( Schema schema ); + public delegate void dxFreeSchema(Schema schema); #if SQLITE_HAS_CODEC public delegate byte[] dxCodec( codec_ctx pCodec, byte[] D, uint pageNumber, int X ); //void *(*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */ @@ -111,184 +109,184 @@ sqlite_vfs Delegates public delegate void dxCodecFree( ref codec_ctx pCodec ); //void (*xCodecFree)(void); /* Destructor for the codec */ #endif - //Module - public delegate void dxDestroy( ref PgHdr pDestroyArg ); - public delegate int dxStress( object obj, PgHdr pPhHdr ); + //Module + public delegate void dxDestroy(ref PgHdr pDestroyArg); + public delegate int dxStress(object obj, PgHdr pPhHdr); - //sqlite3_module - public delegate int smdxCreateConnect( sqlite3 db, object pAux, int argc, string[] constargv, out sqlite3_vtab ppVTab, out string pError ); - public delegate int smdxBestIndex( sqlite3_vtab pVTab, ref sqlite3_index_info pIndex ); - public delegate int smdxDisconnect( ref object pVTab ); - public delegate int smdxDestroy(ref object pVTab ); - public delegate int smdxOpen( sqlite3_vtab pVTab, out sqlite3_vtab_cursor ppCursor ); - public delegate int smdxClose( ref sqlite3_vtab_cursor pCursor ); - public delegate int smdxFilter( sqlite3_vtab_cursor pCursor, int idxNum, string idxStr, int argc, sqlite3_value[] argv ); - public delegate int smdxNext( sqlite3_vtab_cursor pCursor ); - public delegate int smdxEof( sqlite3_vtab_cursor pCursor ); - public delegate int smdxColumn( sqlite3_vtab_cursor pCursor, sqlite3_context p2, int p3 ); - public delegate int smdxRowid( sqlite3_vtab_cursor pCursor, out sqlite3_int64 pRowid ); - public delegate int smdxUpdate( sqlite3_vtab pVTab, int p1, sqlite3_value[] p2, out sqlite3_int64 p3 ); - public delegate int smdxFunction ( sqlite3_vtab pVTab ); - public delegate int smdxFindFunction( sqlite3_vtab pVtab, int nArg, string zName, ref dxFunc pxFunc, ref object ppArg ); - public delegate int smdxRename( sqlite3_vtab pVtab, string zNew ); - public delegate int smdxFunctionArg (sqlite3_vtab pVTab, int nArg ); + //sqlite3_module + public delegate int smdxCreateConnect(sqlite3 db, object pAux, int argc, string[] constargv, out sqlite3_vtab ppVTab, out string pError); + public delegate int smdxBestIndex(sqlite3_vtab pVTab, ref sqlite3_index_info pIndex); + public delegate int smdxDisconnect(ref object pVTab); + public delegate int smdxDestroy(ref object pVTab); + public delegate int smdxOpen(sqlite3_vtab pVTab, out sqlite3_vtab_cursor ppCursor); + public delegate int smdxClose(ref sqlite3_vtab_cursor pCursor); + public delegate int smdxFilter(sqlite3_vtab_cursor pCursor, int idxNum, string idxStr, int argc, sqlite3_value[] argv); + public delegate int smdxNext(sqlite3_vtab_cursor pCursor); + public delegate int smdxEof(sqlite3_vtab_cursor pCursor); + public delegate int smdxColumn(sqlite3_vtab_cursor pCursor, sqlite3_context p2, int p3); + public delegate int smdxRowid(sqlite3_vtab_cursor pCursor, out sqlite3_int64 pRowid); + public delegate int smdxUpdate(sqlite3_vtab pVTab, int p1, sqlite3_value[] p2, out sqlite3_int64 p3); + public delegate int smdxFunction(sqlite3_vtab pVTab); + public delegate int smdxFindFunction(sqlite3_vtab pVtab, int nArg, string zName, ref dxFunc pxFunc, ref object ppArg); + public delegate int smdxRename(sqlite3_vtab pVtab, string zNew); + public delegate int smdxFunctionArg(sqlite3_vtab pVTab, int nArg); - //AutoExtention - public delegate int dxInit( sqlite3 db, ref string zMessage, sqlite3_api_routines sar ); + //AutoExtention + public delegate int dxInit(sqlite3 db, ref string zMessage, sqlite3_api_routines sar); #if !SQLITE_OMIT_VIRTUALTABLE - public delegate int dmxCreate(sqlite3 db, object pAux, int argc, string p4, object argv, sqlite3_vtab ppVTab, char p7); - public delegate int dmxConnect(sqlite3 db, object pAux, int argc, string p4, object argv, sqlite3_vtab ppVTab, char p7); - public delegate int dmxBestIndex(sqlite3_vtab pVTab, ref sqlite3_index_info pIndexInfo); - public delegate int dmxDisconnect(sqlite3_vtab pVTab); - public delegate int dmxDestroy(sqlite3_vtab pVTab); - public delegate int dmxOpen(sqlite3_vtab pVTab, sqlite3_vtab_cursor ppCursor); - public delegate int dmxClose(sqlite3_vtab_cursor pCursor); - public delegate int dmxFilter(sqlite3_vtab_cursor pCursor, int idmxNum, string idmxStr, int argc, sqlite3_value argv); - public delegate int dmxNext(sqlite3_vtab_cursor pCursor); - public delegate int dmxEof(sqlite3_vtab_cursor pCursor); - public delegate int dmxColumn(sqlite3_vtab_cursor pCursor, sqlite3_context ctx, int i3); - public delegate int dmxRowid(sqlite3_vtab_cursor pCursor, sqlite3_int64 pRowid); - public delegate int dmxUpdate(sqlite3_vtab pVTab, int i2, sqlite3_value sv3, sqlite3_int64 v4); - public delegate int dmxBegin(sqlite3_vtab pVTab); - public delegate int dmxSync(sqlite3_vtab pVTab); - public delegate int dmxCommit(sqlite3_vtab pVTab); - public delegate int dmxRollback(sqlite3_vtab pVTab); - public delegate int dmxFindFunction(sqlite3_vtab pVtab, int nArg, string zName); - public delegate int dmxRename(sqlite3_vtab pVtab, string zNew); + public delegate int dmxCreate(sqlite3 db, object pAux, int argc, string p4, object argv, sqlite3_vtab ppVTab, char p7); + public delegate int dmxConnect(sqlite3 db, object pAux, int argc, string p4, object argv, sqlite3_vtab ppVTab, char p7); + public delegate int dmxBestIndex(sqlite3_vtab pVTab, ref sqlite3_index_info pIndexInfo); + public delegate int dmxDisconnect(sqlite3_vtab pVTab); + public delegate int dmxDestroy(sqlite3_vtab pVTab); + public delegate int dmxOpen(sqlite3_vtab pVTab, sqlite3_vtab_cursor ppCursor); + public delegate int dmxClose(sqlite3_vtab_cursor pCursor); + public delegate int dmxFilter(sqlite3_vtab_cursor pCursor, int idmxNum, string idmxStr, int argc, sqlite3_value argv); + public delegate int dmxNext(sqlite3_vtab_cursor pCursor); + public delegate int dmxEof(sqlite3_vtab_cursor pCursor); + public delegate int dmxColumn(sqlite3_vtab_cursor pCursor, sqlite3_context ctx, int i3); + public delegate int dmxRowid(sqlite3_vtab_cursor pCursor, sqlite3_int64 pRowid); + public delegate int dmxUpdate(sqlite3_vtab pVTab, int i2, sqlite3_value sv3, sqlite3_int64 v4); + public delegate int dmxBegin(sqlite3_vtab pVTab); + public delegate int dmxSync(sqlite3_vtab pVTab); + public delegate int dmxCommit(sqlite3_vtab pVTab); + public delegate int dmxRollback(sqlite3_vtab pVTab); + public delegate int dmxFindFunction(sqlite3_vtab pVtab, int nArg, string zName); + public delegate int dmxRename(sqlite3_vtab pVtab, string zNew); #endif - //Faults - public delegate void void_function(); + //Faults + public delegate void void_function(); - //Mem Methods - public delegate int dxMemInit( object o ); - public delegate void dxMemShutdown( object o ); - public delegate byte[] dxMalloc( int nSize ); - public delegate int[] dxMallocInt( int nSize ); - public delegate Mem dxMallocMem( Mem pMem ); - public delegate void dxFree( ref byte[] pOld ); - public delegate void dxFreeInt( ref int[] pOld ); - public delegate void dxFreeMem( ref Mem pOld ); - public delegate byte[] dxRealloc( byte[] pOld, int nSize ); - public delegate int dxSize( byte[] pArray ); - public delegate int dxRoundup( int nSize ); + //Mem Methods + public delegate int dxMemInit(object o); + public delegate void dxMemShutdown(object o); + public delegate byte[] dxMalloc(int nSize); + public delegate int[] dxMallocInt(int nSize); + public delegate Mem dxMallocMem(Mem pMem); + public delegate void dxFree(ref byte[] pOld); + public delegate void dxFreeInt(ref int[] pOld); + public delegate void dxFreeMem(ref Mem pOld); + public delegate byte[] dxRealloc(byte[] pOld, int nSize); + public delegate int dxSize(byte[] pArray); + public delegate int dxRoundup(int nSize); - //Mutex Methods - public delegate int dxMutexInit(); - public delegate int dxMutexEnd(); - public delegate sqlite3_mutex dxMutexAlloc( int iNumber ); - public delegate void dxMutexFree( sqlite3_mutex sm ); - public delegate void dxMutexEnter( sqlite3_mutex sm ); - public delegate int dxMutexTry( sqlite3_mutex sm ); - public delegate void dxMutexLeave( sqlite3_mutex sm ); - public delegate bool dxMutexHeld( sqlite3_mutex sm ); - public delegate bool dxMutexNotheld( sqlite3_mutex sm ); + //Mutex Methods + public delegate int dxMutexInit(); + public delegate int dxMutexEnd(); + public delegate sqlite3_mutex dxMutexAlloc(int iNumber); + public delegate void dxMutexFree(sqlite3_mutex sm); + public delegate void dxMutexEnter(sqlite3_mutex sm); + public delegate int dxMutexTry(sqlite3_mutex sm); + public delegate void dxMutexLeave(sqlite3_mutex sm); + public delegate bool dxMutexHeld(sqlite3_mutex sm); + public delegate bool dxMutexNotheld(sqlite3_mutex sm); - public delegate object dxColumn( sqlite3_stmt pStmt, int i ); - public delegate int dxColumn_I( sqlite3_stmt pStmt, int i ); + public delegate object dxColumn(sqlite3_stmt pStmt, int i); + public delegate int dxColumn_I(sqlite3_stmt pStmt, int i); - // Walker Methods - public delegate int dxExprCallback( Walker W, ref Expr E ); /* Callback for expressions */ - public delegate int dxSelectCallback( Walker W, Select S ); /* Callback for SELECTs */ + // Walker Methods + public delegate int dxExprCallback(Walker W, ref Expr E); /* Callback for expressions */ + public delegate int dxSelectCallback(Walker W, Select S); /* Callback for SELECTs */ - // pcache Methods - public delegate int dxPC_Init( object NotUsed ); - public delegate void dxPC_Shutdown( object NotUsed ); - public delegate sqlite3_pcache dxPC_Create( int szPage, bool bPurgeable ); - public delegate void dxPC_Cachesize( sqlite3_pcache pCache, int nCachesize ); - public delegate int dxPC_Pagecount( sqlite3_pcache pCache ); - public delegate PgHdr dxPC_Fetch( sqlite3_pcache pCache, u32 key, int createFlag ); - public delegate void dxPC_Unpin( sqlite3_pcache pCache, PgHdr p2, bool discard ); - public delegate void dxPC_Rekey( sqlite3_pcache pCache, PgHdr p2, u32 oldKey, u32 newKey ); - public delegate void dxPC_Truncate( sqlite3_pcache pCache, u32 iLimit ); - public delegate void dxPC_Destroy( ref sqlite3_pcache pCache ); + // pcache Methods + public delegate int dxPC_Init(object NotUsed); + public delegate void dxPC_Shutdown(object NotUsed); + public delegate sqlite3_pcache dxPC_Create(int szPage, bool bPurgeable); + public delegate void dxPC_Cachesize(sqlite3_pcache pCache, int nCachesize); + public delegate int dxPC_Pagecount(sqlite3_pcache pCache); + public delegate PgHdr dxPC_Fetch(sqlite3_pcache pCache, u32 key, int createFlag); + public delegate void dxPC_Unpin(sqlite3_pcache pCache, PgHdr p2, bool discard); + public delegate void dxPC_Rekey(sqlite3_pcache pCache, PgHdr p2, u32 oldKey, u32 newKey); + public delegate void dxPC_Truncate(sqlite3_pcache pCache, u32 iLimit); + public delegate void dxPC_Destroy(ref sqlite3_pcache pCache); - public delegate void dxIter( PgHdr p ); + public delegate void dxIter(PgHdr p); #if NET_35 || NET_40 - //API Simplifications -- Actions - public static Action ResultBlob = sqlite3_result_blob; - public static Action ResultDouble = sqlite3_result_double; - public static Action ResultError = sqlite3_result_error; - public static Action ResultErrorCode = sqlite3_result_error_code; - public static Action ResultErrorNoMem = sqlite3_result_error_nomem; - public static Action ResultErrorTooBig = sqlite3_result_error_toobig; - public static Action ResultInt = sqlite3_result_int; - public static Action ResultInt64 = sqlite3_result_int64; - public static Action ResultNull = sqlite3_result_null; - public static Action ResultText = sqlite3_result_text; - public static Action ResultText_Offset = sqlite3_result_text; - public static Action ResultValue = sqlite3_result_value; - public static Action ResultZeroblob = sqlite3_result_zeroblob; - public static Action SetAuxdata = sqlite3_set_auxdata; + //API Simplifications -- Actions + public static Action ResultBlob = sqlite3_result_blob; + public static Action ResultDouble = sqlite3_result_double; + public static Action ResultError = sqlite3_result_error; + public static Action ResultErrorCode = sqlite3_result_error_code; + public static Action ResultErrorNoMem = sqlite3_result_error_nomem; + public static Action ResultErrorTooBig = sqlite3_result_error_toobig; + public static Action ResultInt = sqlite3_result_int; + public static Action ResultInt64 = sqlite3_result_int64; + public static Action ResultNull = sqlite3_result_null; + public static Action ResultText = sqlite3_result_text; + public static Action ResultText_Offset = sqlite3_result_text; + public static Action ResultValue = sqlite3_result_value; + public static Action ResultZeroblob = sqlite3_result_zeroblob; + public static Action SetAuxdata = sqlite3_set_auxdata; - //API Simplifications -- Functions - public delegate Int32 FinalizeDelegate( sqlite3_stmt pStmt ); - public static FinalizeDelegate Finalize = sqlite3_finalize; + //API Simplifications -- Functions + public delegate Int32 FinalizeDelegate(sqlite3_stmt pStmt); + public static FinalizeDelegate Finalize = sqlite3_finalize; - public static Func ClearBindings = sqlite3_clear_bindings; - public static Func ColumnBlob = sqlite3_column_blob; - public static Func ColumnBytes = sqlite3_column_bytes; - public static Func ColumnBytes16 = sqlite3_column_bytes16; - public static Func ColumnCount = sqlite3_column_count; - public static Func ColumnDecltype = sqlite3_column_decltype; - public static Func ColumnDouble = sqlite3_column_double; - public static Func ColumnInt = sqlite3_column_int; - public static Func ColumnInt64 = sqlite3_column_int64; - public static Func ColumnName = sqlite3_column_name; - public static Func ColumnText = sqlite3_column_text; - public static Func ColumnType = sqlite3_column_type; - public static Func ColumnValue = sqlite3_column_value; - public static Func DataCount = sqlite3_data_count; - public static Func Reset = sqlite3_reset; - public static Func Step = sqlite3_step; + public static Func ClearBindings = sqlite3_clear_bindings; + public static Func ColumnBlob = sqlite3_column_blob; + public static Func ColumnBytes = sqlite3_column_bytes; + public static Func ColumnBytes16 = sqlite3_column_bytes16; + public static Func ColumnCount = sqlite3_column_count; + public static Func ColumnDecltype = sqlite3_column_decltype; + public static Func ColumnDouble = sqlite3_column_double; + public static Func ColumnInt = sqlite3_column_int; + public static Func ColumnInt64 = sqlite3_column_int64; + public static Func ColumnName = sqlite3_column_name; + public static Func ColumnText = sqlite3_column_text; + public static Func ColumnType = sqlite3_column_type; + public static Func ColumnValue = sqlite3_column_value; + public static Func DataCount = sqlite3_data_count; + public static Func Reset = sqlite3_reset; + public static Func Step = sqlite3_step; - public static Func BindBlob = sqlite3_bind_blob; - public static Func BindDouble = sqlite3_bind_double; - public static Func BindInt = sqlite3_bind_int; - public static Func BindInt64 = sqlite3_bind_int64; - public static Func BindNull = sqlite3_bind_null; - public static Func BindParameterCount = sqlite3_bind_parameter_count; - public static Func BindParameterIndex = sqlite3_bind_parameter_index; - public static Func BindParameterName = sqlite3_bind_parameter_name; - public static Func BindText = sqlite3_bind_text; - public static Func BindValue = sqlite3_bind_value; - public static Func BindZeroblob = sqlite3_bind_zeroblob; + public static Func BindBlob = sqlite3_bind_blob; + public static Func BindDouble = sqlite3_bind_double; + public static Func BindInt = sqlite3_bind_int; + public static Func BindInt64 = sqlite3_bind_int64; + public static Func BindNull = sqlite3_bind_null; + public static Func BindParameterCount = sqlite3_bind_parameter_count; + public static Func BindParameterIndex = sqlite3_bind_parameter_index; + public static Func BindParameterName = sqlite3_bind_parameter_name; + public static Func BindText = sqlite3_bind_text; + public static Func BindValue = sqlite3_bind_value; + public static Func BindZeroblob = sqlite3_bind_zeroblob; - public delegate Int32 OpenDelegate( string zFilename, out sqlite3 ppDb ); - public static Func Close = sqlite3_close; - public static Func DbHandle = sqlite3_db_handle; - public static Func Errmsg = sqlite3_errmsg; - public static OpenDelegate Open = sqlite3_open; - public static Func NextStmt = sqlite3_next_stmt; - public static Func Shutdown = sqlite3_shutdown; - public static Func StmtStatus = sqlite3_stmt_status; + public delegate Int32 OpenDelegate(string zFilename, out sqlite3 ppDb); + public static Func Close = sqlite3_close; + public static Func DbHandle = sqlite3_db_handle; + public static Func Errmsg = sqlite3_errmsg; + public static OpenDelegate Open = sqlite3_open; + public static Func NextStmt = sqlite3_next_stmt; + public static Func Shutdown = sqlite3_shutdown; + public static Func StmtStatus = sqlite3_stmt_status; - public delegate Int32 PrepareDelegate( sqlite3 db, String zSql, Int32 nBytes, ref sqlite3_stmt ppStmt, ref string pzTail ); - public delegate Int32 PrepareDelegateNoTail( sqlite3 db, String zSql, Int32 nBytes, ref sqlite3_stmt ppStmt, Int32 iDummy ); - public static PrepareDelegate Prepare = sqlite3_prepare; - public static PrepareDelegate PrepareV2 = sqlite3_prepare_v2; - public static PrepareDelegateNoTail PrepareV2NoTail = sqlite3_prepare_v2; + public delegate Int32 PrepareDelegate(sqlite3 db, String zSql, Int32 nBytes, ref sqlite3_stmt ppStmt, ref string pzTail); + public delegate Int32 PrepareDelegateNoTail(sqlite3 db, String zSql, Int32 nBytes, ref sqlite3_stmt ppStmt, Int32 iDummy); + public static PrepareDelegate Prepare = sqlite3_prepare; + public static PrepareDelegate PrepareV2 = sqlite3_prepare_v2; + public static PrepareDelegateNoTail PrepareV2NoTail = sqlite3_prepare_v2; - public static Func AggregateContext = sqlite3_aggregate_context; - public static Func GetAuxdata = sqlite3_get_auxdata; - public static Func ContextDbHandle = sqlite3_context_db_handle; - public static Func UserData = sqlite3_user_data; + public static Func AggregateContext = sqlite3_aggregate_context; + public static Func GetAuxdata = sqlite3_get_auxdata; + public static Func ContextDbHandle = sqlite3_context_db_handle; + public static Func UserData = sqlite3_user_data; - public static Func ValueBlob = sqlite3_value_blob; - public static Func ValueBytes = sqlite3_value_bytes; - public static Func ValueBytes16 = sqlite3_value_bytes16; - public static Func ValueDouble = sqlite3_value_double; - public static Func ValueInt = sqlite3_value_int; - public static Func ValueInt64 = sqlite3_value_int64; - public static Func ValueText = sqlite3_value_text; - public static Func ValueType = sqlite3_value_type; + public static Func ValueBlob = sqlite3_value_blob; + public static Func ValueBytes = sqlite3_value_bytes; + public static Func ValueBytes16 = sqlite3_value_bytes16; + public static Func ValueDouble = sqlite3_value_double; + public static Func ValueInt = sqlite3_value_int; + public static Func ValueInt64 = sqlite3_value_int64; + public static Func ValueText = sqlite3_value_text; + public static Func ValueType = sqlite3_value_type; #endif - } + } } -#if( NET_35 && !NET_40) || WINDOWS_PHONE +#if (NET_35 && !NET_40) || WINDOWS_PHONE namespace System { // Summary: diff --git a/Src/IronPython.SQLite/c#sqlite/Hash_h.cs b/Src/IronPython.SQLite/c#sqlite/Hash_h.cs index cbb09ce7a..7274cd967 100644 --- a/Src/IronPython.SQLite/c#sqlite/Hash_h.cs +++ b/Src/IronPython.SQLite/c#sqlite/Hash_h.cs @@ -1,141 +1,130 @@ -using u8 = System.Byte; using u32 = System.UInt32; -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 2001 September 22 - ** - ** 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 is the header file for the generic hash-table implemenation - ** used in SQLite. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#if !_SQLITE_HASH_H_ - //#define _SQLITE_HASH_H_ +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2001 September 22 + ** + ** 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 is the header file for the generic hash-table implemenation + ** used in SQLite. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + //#if !_SQLITE_HASH_H_ + //#define _SQLITE_HASH_H_ - /* Forward declarations of structures. */ - //typedef struct Hash Hash; - //typedef struct HashElem HashElem; + /* Forward declarations of structures. */ + //typedef struct Hash Hash; + //typedef struct HashElem HashElem; - /* A complete hash table is an instance of the following structure. - ** The internals of this structure are intended to be opaque -- client - ** code should not attempt to access or modify the fields of this structure - ** directly. Change this structure only by using the routines below. - ** However, some of the "procedures" and "functions" for modifying and - ** accessing this structure are really macros, so we can't really make - ** this structure opaque. - ** - ** All elements of the hash table are on a single doubly-linked list. - ** Hash.first points to the head of this list. - ** - ** There are Hash.htsize buckets. Each bucket points to a spot in - ** the global doubly-linked list. The contents of the bucket are the - ** element pointed to plus the next _ht.count-1 elements in the list. - ** - ** Hash.htsize and Hash.ht may be zero. In that case lookup is done - ** by a linear search of the global list. For small tables, the - ** Hash.ht table is never allocated because if there are few elements - ** in the table, it is faster to do a linear search than to manage - ** the hash table. - */ - public class _ht - { /* the hash table */ - public int count; /* Number of entries with this hash */ - public HashElem chain; /* Pointer to first entry with this hash */ - }; + /* A complete hash table is an instance of the following structure. + ** The internals of this structure are intended to be opaque -- client + ** code should not attempt to access or modify the fields of this structure + ** directly. Change this structure only by using the routines below. + ** However, some of the "procedures" and "functions" for modifying and + ** accessing this structure are really macros, so we can't really make + ** this structure opaque. + ** + ** All elements of the hash table are on a single doubly-linked list. + ** Hash.first points to the head of this list. + ** + ** There are Hash.htsize buckets. Each bucket points to a spot in + ** the global doubly-linked list. The contents of the bucket are the + ** element pointed to plus the next _ht.count-1 elements in the list. + ** + ** Hash.htsize and Hash.ht may be zero. In that case lookup is done + ** by a linear search of the global list. For small tables, the + ** Hash.ht table is never allocated because if there are few elements + ** in the table, it is faster to do a linear search than to manage + ** the hash table. + */ + public class _ht { /* the hash table */ + public int count; /* Number of entries with this hash */ + public HashElem chain; /* Pointer to first entry with this hash */ + }; - public class Hash - { - public u32 htsize = 31; /* Number of buckets in the hash table */ - public u32 count; /* Number of entries in this table */ - public HashElem first; /* The first element of the array */ - public _ht[] ht; - public Hash Copy() - { - if ( this == null ) - return null; - else - { - Hash cp = (Hash)MemberwiseClone(); - return cp; - } - } - }; + public class Hash { + public u32 htsize = 31; /* Number of buckets in the hash table */ + public u32 count; /* Number of entries in this table */ + public HashElem first; /* The first element of the array */ + public _ht[] ht; + public Hash Copy() { + if (this == null) + return null; + else { + Hash cp = (Hash)MemberwiseClone(); + return cp; + } + } + }; - /* Each element in the hash table is an instance of the following - ** structure. All elements are stored on a single doubly-linked list. - ** - ** Again, this structure is intended to be opaque, but it can't really - ** be opaque because it is used by macros. - */ - public class HashElem - { - public HashElem next; - public HashElem prev; /* Next and previous elements in the table */ - public object data; /* Data associated with this element */ - public string pKey; - public int nKey; /* Key associated with this element */ - }; + /* Each element in the hash table is an instance of the following + ** structure. All elements are stored on a single doubly-linked list. + ** + ** Again, this structure is intended to be opaque, but it can't really + ** be opaque because it is used by macros. + */ + public class HashElem { + public HashElem next; + public HashElem prev; /* Next and previous elements in the table */ + public object data; /* Data associated with this element */ + public string pKey; + public int nKey; /* Key associated with this element */ + }; - /* - ** Access routines. To delete, insert a NULL pointer. - */ - //void sqlite3HashInit(Hash); - //void *sqlite3HashInsert(Hash*, string pKey, int nKey, object *pData); - //void *sqlite3HashFind(const Hash*, string pKey, int nKey); - //void sqlite3HashClear(Hash); + /* + ** Access routines. To delete, insert a NULL pointer. + */ + //void sqlite3HashInit(Hash); + //void *sqlite3HashInsert(Hash*, string pKey, int nKey, object *pData); + //void *sqlite3HashFind(const Hash*, string pKey, int nKey); + //void sqlite3HashClear(Hash); - /* - ** Macros for looping over all elements of a hash table. The idiom is - ** like this: - ** - ** Hash h; - ** HashElem p; - ** ... - ** for(p=sqliteHashFirst(&h); p; p=sqliteHashNext(p)){ - ** SomeStructure pData = sqliteHashData(p); - ** // do something with pData - ** } - */ - //#define sqliteHashFirst(H) ((H).first) - static HashElem sqliteHashFirst( Hash H ) - { - return H.first; - } - //#define sqliteHashNext(E) ((E).next) - static HashElem sqliteHashNext( HashElem E ) - { - return E.next; - } - //#define sqliteHashData(E) ((E).data) - static object sqliteHashData( HashElem E ) - { - return E.data; - } - /* #define sqliteHashKey(E) ((E)->pKey) // NOT USED */ - /* #define sqliteHashKeysize(E) ((E)->nKey) // NOT USED */ + /* + ** Macros for looping over all elements of a hash table. The idiom is + ** like this: + ** + ** Hash h; + ** HashElem p; + ** ... + ** for(p=sqliteHashFirst(&h); p; p=sqliteHashNext(p)){ + ** SomeStructure pData = sqliteHashData(p); + ** // do something with pData + ** } + */ + //#define sqliteHashFirst(H) ((H).first) + static HashElem sqliteHashFirst(Hash H) { + return H.first; + } + //#define sqliteHashNext(E) ((E).next) + static HashElem sqliteHashNext(HashElem E) { + return E.next; + } + //#define sqliteHashData(E) ((E).data) + static object sqliteHashData(HashElem E) { + return E.data; + } + /* #define sqliteHashKey(E) ((E)->pKey) // NOT USED */ + /* #define sqliteHashKeysize(E) ((E)->nKey) // NOT USED */ - /* - ** Number of entries in a hash table - */ - /* #define sqliteHashCount(H) ((H)->count) // NOT USED */ + /* + ** Number of entries in a hash table + */ + /* #define sqliteHashCount(H) ((H)->count) // NOT USED */ - //#endif // * _SQLITE_HASH_H_ */ - } + //#endif // * _SQLITE_HASH_H_ */ + } } diff --git a/Src/IronPython.SQLite/c#sqlite/VdbeInt_h.cs b/Src/IronPython.SQLite/c#sqlite/VdbeInt_h.cs index 8dba30007..2666c677b 100644 --- a/Src/IronPython.SQLite/c#sqlite/VdbeInt_h.cs +++ b/Src/IronPython.SQLite/c#sqlite/VdbeInt_h.cs @@ -1,6 +1,4 @@ using System; -using System.Diagnostics; -using System.Runtime.InteropServices; using FILE = System.IO.TextWriter; @@ -8,8 +6,6 @@ using u8 = System.Byte; using u16 = System.UInt16; using u32 = System.UInt32; -using u64 = System.UInt64; -using unsigned = System.UIntPtr; using Pgno = System.UInt32; @@ -30,176 +26,169 @@ #endif -namespace Community.CsharpSqlite -{ - using Op = Sqlite3.VdbeOp; - - public partial class Sqlite3 - { - /* - ** 2003 September 6 - ** - ** 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 is the header file for information that is private to the - ** VDBE. This information used to all be at the top of the single - ** source code file "vdbe.c". When that file became too big (over - ** 6000 lines long) it was split up into several smaller files and - ** this header information was factored out. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#if !_VDBEINT_H_ - //#define _VDBEINT_H_ - - /* - ** SQL is translated into a sequence of instructions to be - ** executed by a virtual machine. Each instruction is an instance - ** of the following structure. - */ - //typedef struct VdbeOp Op; - - /* - ** Boolean values - */ - //typedef unsigned char Bool; - - /* - ** A cursor is a pointer into a single BTree within a database file. - ** The cursor can seek to a BTree entry with a particular key, or - ** loop over all entries of the Btree. You can also insert new BTree - ** entries or retrieve the key or data from the entry that the cursor - ** is currently pointing to. - ** - ** Every cursor that the virtual machine has open is represented by an - ** instance of the following structure. - */ - public class VdbeCursor - { - public BtCursor pCursor; /* The cursor structure of the backend */ - public Btree pBt; /* Separate file holding temporary table */ - public KeyInfo pKeyInfo; /* Info about index keys needed by index cursors */ - public int iDb; /* Index of cursor database in db->aDb[] (or -1) */ - public int pseudoTableReg; /* Register holding pseudotable content. */ - public int nField; /* Number of fields in the header */ - public bool zeroed; /* True if zeroed out and ready for reuse */ - public bool rowidIsValid; /* True if lastRowid is valid */ - public bool atFirst; /* True if pointing to first entry */ - public bool useRandomRowid; /* Generate new record numbers semi-randomly */ - public bool nullRow; /* True if pointing to a row with no data */ - public bool deferredMoveto; /* A call to sqlite3BtreeMoveto() is needed */ - public bool isTable; /* True if a table requiring integer keys */ - public bool isIndex; /* True if an index containing keys only - no data */ - public bool isOrdered; /* True if the underlying table is BTREE_UNORDERED */ +namespace Community.CsharpSqlite { + using Op = Sqlite3.VdbeOp; + + public partial class Sqlite3 { + /* + ** 2003 September 6 + ** + ** 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 is the header file for information that is private to the + ** VDBE. This information used to all be at the top of the single + ** source code file "vdbe.c". When that file became too big (over + ** 6000 lines long) it was split up into several smaller files and + ** this header information was factored out. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#if !_VDBEINT_H_ + //#define _VDBEINT_H_ + + /* + ** SQL is translated into a sequence of instructions to be + ** executed by a virtual machine. Each instruction is an instance + ** of the following structure. + */ + //typedef struct VdbeOp Op; + + /* + ** Boolean values + */ + //typedef unsigned char Bool; + + /* + ** A cursor is a pointer into a single BTree within a database file. + ** The cursor can seek to a BTree entry with a particular key, or + ** loop over all entries of the Btree. You can also insert new BTree + ** entries or retrieve the key or data from the entry that the cursor + ** is currently pointing to. + ** + ** Every cursor that the virtual machine has open is represented by an + ** instance of the following structure. + */ + public class VdbeCursor { + public BtCursor pCursor; /* The cursor structure of the backend */ + public Btree pBt; /* Separate file holding temporary table */ + public KeyInfo pKeyInfo; /* Info about index keys needed by index cursors */ + public int iDb; /* Index of cursor database in db->aDb[] (or -1) */ + public int pseudoTableReg; /* Register holding pseudotable content. */ + public int nField; /* Number of fields in the header */ + public bool zeroed; /* True if zeroed out and ready for reuse */ + public bool rowidIsValid; /* True if lastRowid is valid */ + public bool atFirst; /* True if pointing to first entry */ + public bool useRandomRowid; /* Generate new record numbers semi-randomly */ + public bool nullRow; /* True if pointing to a row with no data */ + public bool deferredMoveto; /* A call to sqlite3BtreeMoveto() is needed */ + public bool isTable; /* True if a table requiring integer keys */ + public bool isIndex; /* True if an index containing keys only - no data */ + public bool isOrdered; /* True if the underlying table is BTREE_UNORDERED */ #if !SQLITE_OMIT_VIRTUALTABLE - public sqlite3_vtab_cursor pVtabCursor; /* The cursor for a virtual table */ - public sqlite3_module pModule; /* Module for cursor pVtabCursor */ + public sqlite3_vtab_cursor pVtabCursor; /* The cursor for a virtual table */ + public sqlite3_module pModule; /* Module for cursor pVtabCursor */ #endif - public i64 seqCount; /* Sequence counter */ - public i64 movetoTarget; /* Argument to the deferred sqlite3BtreeMoveto() */ - public i64 lastRowid; /* Last rowid from a Next or NextIdx operation */ - - /* Result of last sqlite3BtreeMoveto() done by an OP_NotExists or - ** OP_IsUnique opcode on this cursor. */ - public int seekResult; - - /* Cached information about the header for the data record that the - ** cursor is currently pointing to. Only valid if cacheStatus matches - ** Vdbe.cacheCtr. Vdbe.cacheCtr will never take on the value of - ** CACHE_STALE and so setting cacheStatus=CACHE_STALE guarantees that - ** the cache is out of date. - ** - ** aRow might point to (ephemeral) data for the current row, or it might - ** be NULL. - */ - public u32 cacheStatus; /* Cache is valid if this matches Vdbe.cacheCtr */ - public Pgno payloadSize; /* Total number of bytes in the record */ - public u32[] aType; /* Type values for all entries in the record */ - public u32[] aOffset; /* Cached offsets to the start of each columns data */ - public int aRow; /* Pointer to Data for the current row, if all on one page */ - - public VdbeCursor Copy() - { - return (VdbeCursor)MemberwiseClone(); - } - }; - //typedef struct VdbeCursor VdbeCursor; - - - /* - ** When a sub-program is executed (OP_Program), a structure of this type - ** is allocated to store the current value of the program counter, as - ** well as the current memory cell array and various other frame specific - ** values stored in the Vdbe struct. When the sub-program is finished, - ** these values are copied back to the Vdbe from the VdbeFrame structure, - ** restoring the state of the VM to as it was before the sub-program - ** began executing. - ** - ** The memory for a VdbeFrame object is allocated and managed by a memory - ** cell in the parent (calling) frame. When the memory cell is deleted or - ** overwritten, the VdbeFrame object is not freed immediately. Instead, it - ** is linked into the Vdbe.pDelFrame list. The contents of the Vdbe.pDelFrame - ** list is deleted when the VM is reset in VdbeHalt(). The reason for doing - ** this instead of deleting the VdbeFrame immediately is to avoid recursive - ** calls to sqlite3VdbeMemRelease() when the memory cells belonging to the - ** child frame are released. - ** - ** The currently executing frame is stored in Vdbe.pFrame. Vdbe.pFrame is - ** set to NULL if the currently executing frame is the main program. - */ - //typedef struct VdbeFrame VdbeFrame; - public class VdbeFrame - { - public Vdbe v; /* VM this frame belongs to */ - public int pc; /* Program Counter in parent (calling) frame */ - public Op[] aOp; /* Program instructions for parent frame */ - public int nOp; /* Size of aOp array */ - public Mem[] aMem; /* Array of memory cells for parent frame */ - public int nMem; /* Number of entries in aMem */ - public VdbeCursor[] apCsr; /* Array of Vdbe cursors for parent frame */ - public u16 nCursor; /* Number of entries in apCsr */ - public int token; /* Copy of SubProgram.token */ - public int nChildMem; /* Number of memory cells for child frame */ - public int nChildCsr; /* Number of cursors for child frame */ - public i64 lastRowid; /* Last insert rowid (sqlite3.lastRowid) */ - public int nChange; /* Statement changes (Vdbe.nChanges) */ - public VdbeFrame pParent; /* Parent of this frame, or NULL if parent is main */ - // - // Needed for C# Implementation - // - public Mem[] aChildMem; /* Array of memory cells for child frame */ - public VdbeCursor[] aChildCsr; /* Array of cursors for child frame */ - }; - - //#define VdbeFrameMem(p) ((Mem )&((u8 )p)[ROUND8(sizeof(VdbeFrame))]) - /* - ** A value for VdbeCursor.cacheValid that means the cache is always invalid. - */ - const int CACHE_STALE = 0; - - /* - ** Internally, the vdbe manipulates nearly all SQL values as Mem - ** structures. Each Mem struct may cache multiple representations (string, - ** integer etc.) of the same value. - */ - public class Mem - { - public sqlite3 db; /* The associated database connection */ - public string z; /* String value */ - public double r; /* Real value */ - public struct union_ip - { + public i64 seqCount; /* Sequence counter */ + public i64 movetoTarget; /* Argument to the deferred sqlite3BtreeMoveto() */ + public i64 lastRowid; /* Last rowid from a Next or NextIdx operation */ + + /* Result of last sqlite3BtreeMoveto() done by an OP_NotExists or + ** OP_IsUnique opcode on this cursor. */ + public int seekResult; + + /* Cached information about the header for the data record that the + ** cursor is currently pointing to. Only valid if cacheStatus matches + ** Vdbe.cacheCtr. Vdbe.cacheCtr will never take on the value of + ** CACHE_STALE and so setting cacheStatus=CACHE_STALE guarantees that + ** the cache is out of date. + ** + ** aRow might point to (ephemeral) data for the current row, or it might + ** be NULL. + */ + public u32 cacheStatus; /* Cache is valid if this matches Vdbe.cacheCtr */ + public Pgno payloadSize; /* Total number of bytes in the record */ + public u32[] aType; /* Type values for all entries in the record */ + public u32[] aOffset; /* Cached offsets to the start of each columns data */ + public int aRow; /* Pointer to Data for the current row, if all on one page */ + + public VdbeCursor Copy() { + return (VdbeCursor)MemberwiseClone(); + } + }; + //typedef struct VdbeCursor VdbeCursor; + + + /* + ** When a sub-program is executed (OP_Program), a structure of this type + ** is allocated to store the current value of the program counter, as + ** well as the current memory cell array and various other frame specific + ** values stored in the Vdbe struct. When the sub-program is finished, + ** these values are copied back to the Vdbe from the VdbeFrame structure, + ** restoring the state of the VM to as it was before the sub-program + ** began executing. + ** + ** The memory for a VdbeFrame object is allocated and managed by a memory + ** cell in the parent (calling) frame. When the memory cell is deleted or + ** overwritten, the VdbeFrame object is not freed immediately. Instead, it + ** is linked into the Vdbe.pDelFrame list. The contents of the Vdbe.pDelFrame + ** list is deleted when the VM is reset in VdbeHalt(). The reason for doing + ** this instead of deleting the VdbeFrame immediately is to avoid recursive + ** calls to sqlite3VdbeMemRelease() when the memory cells belonging to the + ** child frame are released. + ** + ** The currently executing frame is stored in Vdbe.pFrame. Vdbe.pFrame is + ** set to NULL if the currently executing frame is the main program. + */ + //typedef struct VdbeFrame VdbeFrame; + public class VdbeFrame { + public Vdbe v; /* VM this frame belongs to */ + public int pc; /* Program Counter in parent (calling) frame */ + public Op[] aOp; /* Program instructions for parent frame */ + public int nOp; /* Size of aOp array */ + public Mem[] aMem; /* Array of memory cells for parent frame */ + public int nMem; /* Number of entries in aMem */ + public VdbeCursor[] apCsr; /* Array of Vdbe cursors for parent frame */ + public u16 nCursor; /* Number of entries in apCsr */ + public int token; /* Copy of SubProgram.token */ + public int nChildMem; /* Number of memory cells for child frame */ + public int nChildCsr; /* Number of cursors for child frame */ + public i64 lastRowid; /* Last insert rowid (sqlite3.lastRowid) */ + public int nChange; /* Statement changes (Vdbe.nChanges) */ + public VdbeFrame pParent; /* Parent of this frame, or NULL if parent is main */ + // + // Needed for C# Implementation + // + public Mem[] aChildMem; /* Array of memory cells for child frame */ + public VdbeCursor[] aChildCsr; /* Array of cursors for child frame */ + }; + + //#define VdbeFrameMem(p) ((Mem )&((u8 )p)[ROUND8(sizeof(VdbeFrame))]) + /* + ** A value for VdbeCursor.cacheValid that means the cache is always invalid. + */ + const int CACHE_STALE = 0; + + /* + ** Internally, the vdbe manipulates nearly all SQL values as Mem + ** structures. Each Mem struct may cache multiple representations (string, + ** integer etc.) of the same value. + */ + public class Mem { + public sqlite3 db; /* The associated database connection */ + public string z; /* String value */ + public double r; /* Real value */ + public struct union_ip { #if DEBUG_CLASS_MEM || DEBUG_CLASS_ALL public i64 _i; /* First operand */ public i64 i @@ -208,16 +197,16 @@ public i64 i set { _i = value; } } #else - public i64 i; /* Integer value used when MEM_Int is set in flags */ + public i64 i; /* Integer value used when MEM_Int is set in flags */ #endif - public int nZero; /* Used when bit MEM_Zero is set in flags */ - public FuncDef pDef; /* Used only when flags==MEM_Agg */ - public RowSet pRowSet; /* Used only when flags==MEM_RowSet */ - public VdbeFrame pFrame; /* Used when flags==MEM_Frame */ - }; - public union_ip u; - public byte[] zBLOB; /* BLOB value */ - public int n; /* Number of characters in string value, excluding '\0' */ + public int nZero; /* Used when bit MEM_Zero is set in flags */ + public FuncDef pDef; /* Used only when flags==MEM_Agg */ + public RowSet pRowSet; /* Used only when flags==MEM_RowSet */ + public VdbeFrame pFrame; /* Used when flags==MEM_Frame */ + }; + public union_ip u; + public byte[] zBLOB; /* BLOB value */ + public int n; /* Number of characters in string value, excluding '\0' */ #if DEBUG_CLASS_MEM || DEBUG_CLASS_ALL public u16 _flags; /* First operand */ public u16 flags @@ -226,334 +215,322 @@ public u16 flags set { _flags = value; } } #else - public u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */ + public u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */ #endif - public u8 type; /* One of SQLITE_NULL, SQLITE_TEXT, SQLITE_INTEGER, etc */ - public u8 enc; /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */ + public u8 type; /* One of SQLITE_NULL, SQLITE_TEXT, SQLITE_INTEGER, etc */ + public u8 enc; /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */ #if SQLITE_DEBUG - public Mem pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */ - public object pFiller; /* So that sizeof(Mem) is a multiple of 8 */ + public Mem pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */ + public object pFiller; /* So that sizeof(Mem) is a multiple of 8 */ #endif - public dxDel xDel; /* If not null, call this function to delete Mem.z */ - // Not used under c# - //public string zMalloc; /* Dynamic buffer allocated by sqlite3Malloc() */ - public Mem _Mem; /* Used when C# overload Z as MEM space */ - public SumCtx _SumCtx; /* Used when C# overload Z as Sum context */ - public SubProgram[] _SubProgram;/* Used when C# overload Z as SubProgram*/ - public StrAccum _StrAccum; /* Used when C# overload Z as STR context */ - public object _MD5Context; /* Used when C# overload Z as MD5 context */ - - public Mem() - { - } - - public Mem( sqlite3 db, string z, double r, int i, int n, u16 flags, u8 type, u8 enc + public dxDel xDel; /* If not null, call this function to delete Mem.z */ + // Not used under c# + //public string zMalloc; /* Dynamic buffer allocated by sqlite3Malloc() */ + public Mem _Mem; /* Used when C# overload Z as MEM space */ + public SumCtx _SumCtx; /* Used when C# overload Z as Sum context */ + public SubProgram[] _SubProgram;/* Used when C# overload Z as SubProgram*/ + public StrAccum _StrAccum; /* Used when C# overload Z as STR context */ + public object _MD5Context; /* Used when C# overload Z as MD5 context */ + + public Mem() { + } + + public Mem(sqlite3 db, string z, double r, int i, int n, u16 flags, u8 type, u8 enc #if SQLITE_DEBUG - , Mem pScopyFrom, object pFiller /* pScopyFrom, pFiller */ + , Mem pScopyFrom, object pFiller /* pScopyFrom, pFiller */ #endif - ) - { - this.db = db; - this.z = z; - this.r = r; - this.u.i = i; - this.n = n; - this.flags = flags; + ) { + this.db = db; + this.z = z; + this.r = r; + this.u.i = i; + this.n = n; + this.flags = flags; #if SQLITE_DEBUG - this.pScopyFrom = pScopyFrom; - this.pFiller = pFiller; + this.pScopyFrom = pScopyFrom; + this.pFiller = pFiller; #endif - this.type = type; - this.enc = enc; - } - - public void CopyTo( ref Mem ct ) - { - if ( ct == null ) - ct = new Mem(); - ct.u = u; - ct.r = r; - ct.db = db; - ct.z = z; - if ( zBLOB == null ) - ct.zBLOB = null; - else - { - ct.zBLOB = sqlite3Malloc( zBLOB.Length ); - Buffer.BlockCopy( zBLOB, 0, ct.zBLOB, 0, zBLOB.Length ); - } - ct.n = n; - ct.flags = flags; - ct.type = type; - ct.enc = enc; - ct.xDel = xDel; - } - - }; - - /* One or more of the following flags are set to indicate the validOK - ** representations of the value stored in the Mem struct. - ** - ** If the MEM_Null flag is set, then the value is an SQL NULL value. - ** No other flags may be set in this case. - ** - ** If the MEM_Str flag is set then Mem.z points at a string representation. - ** Usually this is encoded in the same unicode encoding as the main - ** database (see below for exceptions). If the MEM_Term flag is also - ** set, then the string is nul terminated. The MEM_Int and MEM_Real - ** flags may coexist with the MEM_Str flag. - */ - //#define MEM_Null 0x0001 /* Value is NULL */ - //#define MEM_Str 0x0002 /* Value is a string */ - //#define MEM_Int 0x0004 /* Value is an integer */ - //#define MEM_Real 0x0008 /* Value is a real number */ - //#define MEM_Blob 0x0010 /* Value is a BLOB */ - //#define MEM_RowSet 0x0020 /* Value is a RowSet object */ - //#define MEM_Frame 0x0040 /* Value is a VdbeFrame object */ - //#define MEM_Invalid 0x0080 /* Value is undefined */ - //#define MEM_TypeMask 0x00ff /* Mask of type bits */ - const int MEM_Null = 0x0001; - const int MEM_Str = 0x0002; - const int MEM_Int = 0x0004; - const int MEM_Real = 0x0008; - const int MEM_Blob = 0x0010; - const int MEM_RowSet = 0x0020; - const int MEM_Frame = 0x0040; - const int MEM_Invalid = 0x0080; - const int MEM_TypeMask = 0x00ff; - - /* Whenever Mem contains a valid string or blob representation, one of - ** the following flags must be set to determine the memory management - ** policy for Mem.z. The MEM_Term flag tells us whether or not the - ** string is \000 or \u0000 terminated - // */ - //#define MEM_Term 0x0200 /* String rep is nul terminated */ - //#define MEM_Dyn 0x0400 /* Need to call sqliteFree() on Mem.z */ - //#define MEM_Static 0x0800 /* Mem.z points to a static string */ - //#define MEM_Ephem 0x1000 /* Mem.z points to an ephemeral string */ - //#define MEM_Agg 0x2000 /* Mem.z points to an agg function context */ - //#define MEM_Zero 0x4000 /* Mem.i contains count of 0s appended to blob */ - //#if SQLITE_OMIT_INCRBLOB - // #undef MEM_Zero - // #define MEM_Zero 0x0000 - //#endif - const int MEM_Term = 0x0200; - const int MEM_Dyn = 0x0400; - const int MEM_Static = 0x0800; - const int MEM_Ephem = 0x1000; - const int MEM_Agg = 0x2000; + this.type = type; + this.enc = enc; + } + + public void CopyTo(ref Mem ct) { + if (ct == null) + ct = new Mem(); + ct.u = u; + ct.r = r; + ct.db = db; + ct.z = z; + if (zBLOB == null) + ct.zBLOB = null; + else { + ct.zBLOB = sqlite3Malloc(zBLOB.Length); + Buffer.BlockCopy(zBLOB, 0, ct.zBLOB, 0, zBLOB.Length); + } + ct.n = n; + ct.flags = flags; + ct.type = type; + ct.enc = enc; + ct.xDel = xDel; + } + + }; + + /* One or more of the following flags are set to indicate the validOK + ** representations of the value stored in the Mem struct. + ** + ** If the MEM_Null flag is set, then the value is an SQL NULL value. + ** No other flags may be set in this case. + ** + ** If the MEM_Str flag is set then Mem.z points at a string representation. + ** Usually this is encoded in the same unicode encoding as the main + ** database (see below for exceptions). If the MEM_Term flag is also + ** set, then the string is nul terminated. The MEM_Int and MEM_Real + ** flags may coexist with the MEM_Str flag. + */ + //#define MEM_Null 0x0001 /* Value is NULL */ + //#define MEM_Str 0x0002 /* Value is a string */ + //#define MEM_Int 0x0004 /* Value is an integer */ + //#define MEM_Real 0x0008 /* Value is a real number */ + //#define MEM_Blob 0x0010 /* Value is a BLOB */ + //#define MEM_RowSet 0x0020 /* Value is a RowSet object */ + //#define MEM_Frame 0x0040 /* Value is a VdbeFrame object */ + //#define MEM_Invalid 0x0080 /* Value is undefined */ + //#define MEM_TypeMask 0x00ff /* Mask of type bits */ + const int MEM_Null = 0x0001; + const int MEM_Str = 0x0002; + const int MEM_Int = 0x0004; + const int MEM_Real = 0x0008; + const int MEM_Blob = 0x0010; + const int MEM_RowSet = 0x0020; + const int MEM_Frame = 0x0040; + const int MEM_Invalid = 0x0080; + const int MEM_TypeMask = 0x00ff; + + /* Whenever Mem contains a valid string or blob representation, one of + ** the following flags must be set to determine the memory management + ** policy for Mem.z. The MEM_Term flag tells us whether or not the + ** string is \000 or \u0000 terminated + // */ + //#define MEM_Term 0x0200 /* String rep is nul terminated */ + //#define MEM_Dyn 0x0400 /* Need to call sqliteFree() on Mem.z */ + //#define MEM_Static 0x0800 /* Mem.z points to a static string */ + //#define MEM_Ephem 0x1000 /* Mem.z points to an ephemeral string */ + //#define MEM_Agg 0x2000 /* Mem.z points to an agg function context */ + //#define MEM_Zero 0x4000 /* Mem.i contains count of 0s appended to blob */ + //#if SQLITE_OMIT_INCRBLOB + // #undef MEM_Zero + // #define MEM_Zero 0x0000 + //#endif + const int MEM_Term = 0x0200; + const int MEM_Dyn = 0x0400; + const int MEM_Static = 0x0800; + const int MEM_Ephem = 0x1000; + const int MEM_Agg = 0x2000; #if !SQLITE_OMIT_INCRBLOB const int MEM_Zero = 0x4000; #else - const int MEM_Zero = 0x0000; + const int MEM_Zero = 0x0000; #endif - /* -** Clear any existing type flags from a Mem and replace them with f -*/ - //#define MemSetTypeFlag(p, f) \ - // ((p)->flags = ((p)->flags&~(MEM_TypeMask|MEM_Zero))|f) - static void MemSetTypeFlag( Mem p, int f ) - { - p.flags = (u16)( p.flags & ~( MEM_TypeMask | MEM_Zero ) | f ); - }// TODO -- Convert back to inline for speed - - /* - ** Return true if a memory cell is not marked as invalid. This macro - ** is for use inside Debug.Assert() statements only. + /* + ** Clear any existing type flags from a Mem and replace them with f */ + //#define MemSetTypeFlag(p, f) \ + // ((p)->flags = ((p)->flags&~(MEM_TypeMask|MEM_Zero))|f) + static void MemSetTypeFlag(Mem p, int f) { + p.flags = (u16)(p.flags & ~(MEM_TypeMask | MEM_Zero) | f); + }// TODO -- Convert back to inline for speed + + /* + ** Return true if a memory cell is not marked as invalid. This macro + ** is for use inside Debug.Assert() statements only. + */ #if SQLITE_DEBUG - //#define memIsValid(M) ((M)->flags & MEM_Invalid)==0 - static bool memIsValid( Mem M ) - { - return ( ( M ).flags & MEM_Invalid ) == 0; - } + //#define memIsValid(M) ((M)->flags & MEM_Invalid)==0 + static bool memIsValid(Mem M) { + return ((M).flags & MEM_Invalid) == 0; + } #else static bool memIsValid( Mem M ) { return true; } #endif - /* A VdbeFunc is just a FuncDef (defined in sqliteInt.h) that contains -** additional information about auxiliary information bound to arguments -** of the function. This is used to implement the sqlite3_get_auxdata() -** and sqlite3_set_auxdata() APIs. The "auxdata" is some auxiliary data -** that can be associated with a constant argument to a function. This -** allows functions such as "regexp" to compile their constant regular -** expression argument once and reused the compiled code for multiple -** invocations. -*/ - public class AuxData - { - public object pAux; /* Aux data for the i-th argument */ - //(void ); /* Destructor for the aux data */ - }; - - public class VdbeFunc : FuncDef - { - public FuncDef pFunc; /* The definition of the function */ - public int nAux; /* Number of entries allocated for apAux[] */ - public AuxData[] apAux = new AuxData[2]; /* One slot for each function argument */ - }; - - /* - ** The "context" argument for a installable function. A pointer to an - ** instance of this structure is the first argument to the routines used - ** implement the SQL functions. - ** - ** There is a typedef for this structure in sqlite.h. So all routines, - ** even the public interface to SQLite, can use a pointer to this structure. - ** But this file is the only place where the internal details of this - ** structure are known. - ** - ** This structure is defined inside of vdbeInt.h because it uses substructures - ** (Mem) which are only defined there. - */ - public class sqlite3_context - { - public FuncDef pFunc; /* Pointer to function information. MUST BE FIRST */ - public VdbeFunc pVdbeFunc; /* Auxilary data, if created. */ - public Mem s = new Mem(); /* The return value is stored here */ - public Mem pMem; /* Memory cell used to store aggregate context */ - public int isError; /* Error code returned by the function. */ - public CollSeq pColl; /* Collating sequence */ - - }; - - /* - ** An instance of the virtual machine. This structure contains the complete - ** state of the virtual machine. - ** - ** The "sqlite3_stmt" structure pointer that is returned by sqlite3_prepare() - ** is really a pointer to an instance of this structure. - ** - ** The Vdbe.inVtabMethod variable is set to non-zero for the duration of - ** any virtual table method invocations made by the vdbe program. It is - ** set to 2 for xDestroy method calls and 1 for all other methods. This - ** variable is used for two purposes: to allow xDestroy methods to execute - ** "DROP TABLE" statements and to prevent some nasty side effects of - ** malloc failure when SQLite is invoked recursively by a virtual table - ** method function. + /* A VdbeFunc is just a FuncDef (defined in sqliteInt.h) that contains + ** additional information about auxiliary information bound to arguments + ** of the function. This is used to implement the sqlite3_get_auxdata() + ** and sqlite3_set_auxdata() APIs. The "auxdata" is some auxiliary data + ** that can be associated with a constant argument to a function. This + ** allows functions such as "regexp" to compile their constant regular + ** expression argument once and reused the compiled code for multiple + ** invocations. */ - public class Vdbe - { - public sqlite3 db; /* The database connection that owns this statement */ - public Op[] aOp; /* Space to hold the virtual machine's program */ - public Mem[] aMem; /* The memory locations */ - public Mem[] apArg; /* Arguments to currently executing user function */ - public Mem[] aColName; /* Column names to return */ - public Mem[] pResultSet; /* Pointer to an array of results */ - public int nMem; /* Number of memory locations currently allocated */ - public int nOp; /* Number of instructions in the program */ - public int nOpAlloc; /* Number of slots allocated for aOp[] */ - public int nLabel; /* Number of labels used */ - public int nLabelAlloc; /* Number of slots allocated in aLabel[] */ - public int[] aLabel; /* Space to hold the labels */ - public u16 nResColumn; /* Number of columns in one row of the result set */ - public u16 nCursor; /* Number of slots in apCsr[] */ - public u32 magic; /* Magic number for sanity checking */ - public string zErrMsg; /* Error message written here */ - public Vdbe pPrev; /* Linked list of VDBEs with the same Vdbe.db */ - public Vdbe pNext; /* Linked list of VDBEs with the same Vdbe.db */ - public VdbeCursor[] apCsr; /* One element of this array for each open cursor */ - public Mem[] aVar; /* Values for the OP_Variable opcode. */ - public string[] azVar; /* Name of variables */ - public ynVar nVar; /* Number of entries in aVar[] */ - public ynVar nzVar; /* Number of entries in azVar[] */ - public u32 cacheCtr; /* VdbeCursor row cache generation counter */ - public int pc; /* The program counter */ - public int rc; /* Value to return */ - public u8 errorAction; /* Recovery action to do in case of an error */ - public int explain; /* True if EXPLAIN present on SQL command */ - public bool changeCntOn; /* True to update the change-counter */ - public bool expired; /* True if the VM needs to be recompiled */ - public u8 runOnlyOnce; /* Automatically expire on reset */ - public int minWriteFileFormat; /* Minimum file format for writable database files */ - public int inVtabMethod; /* See comments above */ - public bool usesStmtJournal; /* True if uses a statement journal */ - public bool readOnly; /* True for read-only statements */ - public int nChange; /* Number of db changes made since last reset */ - public bool isPrepareV2; /* True if prepared with prepare_v2() */ - public yDbMask btreeMask; /* Bitmask of db.aDb[] entries referenced */ - public yDbMask lockMask; /* Subset of btreeMask that requires a lock */ - - public int iStatement; /* Statement number (or 0 if has not opened stmt) */ - public int[] aCounter = new int[3]; /* Counters used by sqlite3_stmt_status() */ + public class AuxData { + public object pAux; /* Aux data for the i-th argument */ + //(void ); /* Destructor for the aux data */ + }; + + public class VdbeFunc : FuncDef { + public FuncDef pFunc; /* The definition of the function */ + public int nAux; /* Number of entries allocated for apAux[] */ + public AuxData[] apAux = new AuxData[2]; /* One slot for each function argument */ + }; + + /* + ** The "context" argument for a installable function. A pointer to an + ** instance of this structure is the first argument to the routines used + ** implement the SQL functions. + ** + ** There is a typedef for this structure in sqlite.h. So all routines, + ** even the public interface to SQLite, can use a pointer to this structure. + ** But this file is the only place where the internal details of this + ** structure are known. + ** + ** This structure is defined inside of vdbeInt.h because it uses substructures + ** (Mem) which are only defined there. + */ + public class sqlite3_context { + public FuncDef pFunc; /* Pointer to function information. MUST BE FIRST */ + public VdbeFunc pVdbeFunc; /* Auxilary data, if created. */ + public Mem s = new Mem(); /* The return value is stored here */ + public Mem pMem; /* Memory cell used to store aggregate context */ + public int isError; /* Error code returned by the function. */ + public CollSeq pColl; /* Collating sequence */ + + }; + + /* + ** An instance of the virtual machine. This structure contains the complete + ** state of the virtual machine. + ** + ** The "sqlite3_stmt" structure pointer that is returned by sqlite3_prepare() + ** is really a pointer to an instance of this structure. + ** + ** The Vdbe.inVtabMethod variable is set to non-zero for the duration of + ** any virtual table method invocations made by the vdbe program. It is + ** set to 2 for xDestroy method calls and 1 for all other methods. This + ** variable is used for two purposes: to allow xDestroy methods to execute + ** "DROP TABLE" statements and to prevent some nasty side effects of + ** malloc failure when SQLite is invoked recursively by a virtual table + ** method function. + */ + public class Vdbe { + public sqlite3 db; /* The database connection that owns this statement */ + public Op[] aOp; /* Space to hold the virtual machine's program */ + public Mem[] aMem; /* The memory locations */ + public Mem[] apArg; /* Arguments to currently executing user function */ + public Mem[] aColName; /* Column names to return */ + public Mem[] pResultSet; /* Pointer to an array of results */ + public int nMem; /* Number of memory locations currently allocated */ + public int nOp; /* Number of instructions in the program */ + public int nOpAlloc; /* Number of slots allocated for aOp[] */ + public int nLabel; /* Number of labels used */ + public int nLabelAlloc; /* Number of slots allocated in aLabel[] */ + public int[] aLabel; /* Space to hold the labels */ + public u16 nResColumn; /* Number of columns in one row of the result set */ + public u16 nCursor; /* Number of slots in apCsr[] */ + public u32 magic; /* Magic number for sanity checking */ + public string zErrMsg; /* Error message written here */ + public Vdbe pPrev; /* Linked list of VDBEs with the same Vdbe.db */ + public Vdbe pNext; /* Linked list of VDBEs with the same Vdbe.db */ + public VdbeCursor[] apCsr; /* One element of this array for each open cursor */ + public Mem[] aVar; /* Values for the OP_Variable opcode. */ + public string[] azVar; /* Name of variables */ + public ynVar nVar; /* Number of entries in aVar[] */ + public ynVar nzVar; /* Number of entries in azVar[] */ + public u32 cacheCtr; /* VdbeCursor row cache generation counter */ + public int pc; /* The program counter */ + public int rc; /* Value to return */ + public u8 errorAction; /* Recovery action to do in case of an error */ + public int explain; /* True if EXPLAIN present on SQL command */ + public bool changeCntOn; /* True to update the change-counter */ + public bool expired; /* True if the VM needs to be recompiled */ + public u8 runOnlyOnce; /* Automatically expire on reset */ + public int minWriteFileFormat; /* Minimum file format for writable database files */ + public int inVtabMethod; /* See comments above */ + public bool usesStmtJournal; /* True if uses a statement journal */ + public bool readOnly; /* True for read-only statements */ + public int nChange; /* Number of db changes made since last reset */ + public bool isPrepareV2; /* True if prepared with prepare_v2() */ + public yDbMask btreeMask; /* Bitmask of db.aDb[] entries referenced */ + public yDbMask lockMask; /* Subset of btreeMask that requires a lock */ + + public int iStatement; /* Statement number (or 0 if has not opened stmt) */ + public int[] aCounter = new int[3]; /* Counters used by sqlite3_stmt_status() */ #if !SQLITE_OMIT_TRACE - public i64 startTime; /* Time when query started - used for profiling */ + public i64 startTime; /* Time when query started - used for profiling */ #endif - public i64 nFkConstraint; /* Number of imm. FK constraints this VM */ - public i64 nStmtDefCons; /* Number of def. constraints when stmt started */ - public string zSql = ""; /* Text of the SQL statement that generated this */ - public object pFree; /* Free this when deleting the vdbe */ + public i64 nFkConstraint; /* Number of imm. FK constraints this VM */ + public i64 nStmtDefCons; /* Number of def. constraints when stmt started */ + public string zSql = ""; /* Text of the SQL statement that generated this */ + public object pFree; /* Free this when deleting the vdbe */ #if SQLITE_DEBUG - public FILE trace; /* Write an execution trace here, if not NULL */ + public FILE trace; /* Write an execution trace here, if not NULL */ #endif - public VdbeFrame pFrame; /* Parent frame */ - public VdbeFrame pDelFrame; /* List of frame objects to free on VM reset */ - public int nFrame; /* Number of frames in pFrame list */ - public u32 expmask; /* Binding to these vars invalidates VM */ - public SubProgram pProgram; /* Linked list of all sub-programs used by VM */ - - public Vdbe Copy() - { - Vdbe cp = (Vdbe)MemberwiseClone(); - return cp; - } - public void CopyTo( Vdbe ct ) - { - ct.db = db; - ct.pPrev = pPrev; - ct.pNext = pNext; - ct.nOp = nOp; - ct.nOpAlloc = nOpAlloc; - ct.aOp = aOp; - ct.nLabel = nLabel; - ct.nLabelAlloc = nLabelAlloc; - ct.aLabel = aLabel; - ct.apArg = apArg; - ct.aColName = aColName; - ct.nCursor = nCursor; - ct.apCsr = apCsr; - ct.aVar = aVar; - ct.azVar = azVar; - ct.nVar = nVar; - ct.nzVar = nzVar; - ct.magic = magic; - ct.nMem = nMem; - ct.aMem = aMem; - ct.cacheCtr = cacheCtr; - ct.pc = pc; - ct.rc = rc; - ct.errorAction = errorAction; - ct.nResColumn = nResColumn; - ct.zErrMsg = zErrMsg; - ct.pResultSet = pResultSet; - ct.explain = explain; - ct.changeCntOn = changeCntOn; - ct.expired = expired; - ct.minWriteFileFormat = minWriteFileFormat; - ct.inVtabMethod = inVtabMethod; - ct.usesStmtJournal = usesStmtJournal; - ct.readOnly = readOnly; - ct.nChange = nChange; - ct.isPrepareV2 = isPrepareV2; + public VdbeFrame pFrame; /* Parent frame */ + public VdbeFrame pDelFrame; /* List of frame objects to free on VM reset */ + public int nFrame; /* Number of frames in pFrame list */ + public u32 expmask; /* Binding to these vars invalidates VM */ + public SubProgram pProgram; /* Linked list of all sub-programs used by VM */ + + public Vdbe Copy() { + Vdbe cp = (Vdbe)MemberwiseClone(); + return cp; + } + public void CopyTo(Vdbe ct) { + ct.db = db; + ct.pPrev = pPrev; + ct.pNext = pNext; + ct.nOp = nOp; + ct.nOpAlloc = nOpAlloc; + ct.aOp = aOp; + ct.nLabel = nLabel; + ct.nLabelAlloc = nLabelAlloc; + ct.aLabel = aLabel; + ct.apArg = apArg; + ct.aColName = aColName; + ct.nCursor = nCursor; + ct.apCsr = apCsr; + ct.aVar = aVar; + ct.azVar = azVar; + ct.nVar = nVar; + ct.nzVar = nzVar; + ct.magic = magic; + ct.nMem = nMem; + ct.aMem = aMem; + ct.cacheCtr = cacheCtr; + ct.pc = pc; + ct.rc = rc; + ct.errorAction = errorAction; + ct.nResColumn = nResColumn; + ct.zErrMsg = zErrMsg; + ct.pResultSet = pResultSet; + ct.explain = explain; + ct.changeCntOn = changeCntOn; + ct.expired = expired; + ct.minWriteFileFormat = minWriteFileFormat; + ct.inVtabMethod = inVtabMethod; + ct.usesStmtJournal = usesStmtJournal; + ct.readOnly = readOnly; + ct.nChange = nChange; + ct.isPrepareV2 = isPrepareV2; #if !SQLITE_OMIT_TRACE - ct.startTime = startTime; + ct.startTime = startTime; #endif - ct.btreeMask = btreeMask; - ct.lockMask = lockMask; - aCounter.CopyTo( ct.aCounter, 0 ); - ct.zSql = zSql; - ct.pFree = pFree; + ct.btreeMask = btreeMask; + ct.lockMask = lockMask; + aCounter.CopyTo(ct.aCounter, 0); + ct.zSql = zSql; + ct.pFree = pFree; #if SQLITE_DEBUG - ct.trace = trace; + ct.trace = trace; #endif - ct.nFkConstraint = nFkConstraint; - ct.nStmtDefCons = nStmtDefCons; - ct.iStatement = iStatement; - ct.pFrame = pFrame; - ct.nFrame = nFrame; - ct.expmask = expmask; - ct.pProgram = pProgram; + ct.nFkConstraint = nFkConstraint; + ct.nStmtDefCons = nStmtDefCons; + ct.iStatement = iStatement; + ct.pFrame = pFrame; + ct.nFrame = nFrame; + ct.expmask = expmask; + ct.pProgram = pProgram; #if SQLITE_SSE ct.fetchId=fetchId; ct.lru=lru; @@ -562,119 +539,116 @@ public void CopyTo( Vdbe ct ) ct.pLruPrev=pLruPrev; ct.pLruNext=pLruNext; #endif - } - }; - - /* - ** The following are allowed values for Vdbe.magic - */ - //#define VDBE_MAGIC_INIT 0x26bceaa5 /* Building a VDBE program */ - //#define VDBE_MAGIC_RUN 0xbdf20da3 /* VDBE is ready to execute */ - //#define VDBE_MAGIC_HALT 0x519c2973 /* VDBE has completed execution */ - //#define VDBE_MAGIC_DEAD 0xb606c3c8 /* The VDBE has been deallocated */ - const u32 VDBE_MAGIC_INIT = 0x26bceaa5; /* Building a VDBE program */ - const u32 VDBE_MAGIC_RUN = 0xbdf20da3; /* VDBE is ready to execute */ - const u32 VDBE_MAGIC_HALT = 0x519c2973; /* VDBE has completed execution */ - const u32 VDBE_MAGIC_DEAD = 0xb606c3c8; /* The VDBE has been deallocated */ - /* - ** Function prototypes - */ - //void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor); - //void sqliteVdbePopStack(Vdbe*,int); - //int sqlite3VdbeCursorMoveto(VdbeCursor); - //#if (SQLITE_DEBUG) || defined(VDBE_PROFILE) - //void sqlite3VdbePrintOp(FILE*, int, Op); - //#endif - //u32 sqlite3VdbeSerialTypeLen(u32); - //u32 sqlite3VdbeSerialType(Mem*, int); - //u32sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int); - //u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem); - //void sqlite3VdbeDeleteAuxData(VdbeFunc*, int); - - //int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int ); - //int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int); - //int sqlite3VdbeIdxRowid(sqlite3 *, i64 ); - //int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq); - //int sqlite3VdbeExec(Vdbe); - //int sqlite3VdbeList(Vdbe); - //int sqlite3VdbeHalt(Vdbe); - //int sqlite3VdbeChangeEncoding(Mem *, int); - //int sqlite3VdbeMemTooBig(Mem); - //int sqlite3VdbeMemCopy(Mem*, const Mem); - //void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int); - //void sqlite3VdbeMemMove(Mem*, Mem); - //int sqlite3VdbeMemNulTerminate(Mem); - //int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, void()(void)); - //void sqlite3VdbeMemSetInt64(Mem*, i64); + } + }; + + /* + ** The following are allowed values for Vdbe.magic + */ + //#define VDBE_MAGIC_INIT 0x26bceaa5 /* Building a VDBE program */ + //#define VDBE_MAGIC_RUN 0xbdf20da3 /* VDBE is ready to execute */ + //#define VDBE_MAGIC_HALT 0x519c2973 /* VDBE has completed execution */ + //#define VDBE_MAGIC_DEAD 0xb606c3c8 /* The VDBE has been deallocated */ + const u32 VDBE_MAGIC_INIT = 0x26bceaa5; /* Building a VDBE program */ + const u32 VDBE_MAGIC_RUN = 0xbdf20da3; /* VDBE is ready to execute */ + const u32 VDBE_MAGIC_HALT = 0x519c2973; /* VDBE has completed execution */ + const u32 VDBE_MAGIC_DEAD = 0xb606c3c8; /* The VDBE has been deallocated */ + /* + ** Function prototypes + */ + //void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor); + //void sqliteVdbePopStack(Vdbe*,int); + //int sqlite3VdbeCursorMoveto(VdbeCursor); + //#if (SQLITE_DEBUG) || defined(VDBE_PROFILE) + //void sqlite3VdbePrintOp(FILE*, int, Op); + //#endif + //u32 sqlite3VdbeSerialTypeLen(u32); + //u32 sqlite3VdbeSerialType(Mem*, int); + //u32sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int); + //u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem); + //void sqlite3VdbeDeleteAuxData(VdbeFunc*, int); + + //int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int ); + //int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int); + //int sqlite3VdbeIdxRowid(sqlite3 *, i64 ); + //int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq); + //int sqlite3VdbeExec(Vdbe); + //int sqlite3VdbeList(Vdbe); + //int sqlite3VdbeHalt(Vdbe); + //int sqlite3VdbeChangeEncoding(Mem *, int); + //int sqlite3VdbeMemTooBig(Mem); + //int sqlite3VdbeMemCopy(Mem*, const Mem); + //void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int); + //void sqlite3VdbeMemMove(Mem*, Mem); + //int sqlite3VdbeMemNulTerminate(Mem); + //int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, void()(void)); + //void sqlite3VdbeMemSetInt64(Mem*, i64); #if SQLITE_OMIT_FLOATING_POINT //# define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64 #else - //void sqlite3VdbeMemSetDouble(Mem*, double); + //void sqlite3VdbeMemSetDouble(Mem*, double); #endif - //void sqlite3VdbeMemSetNull(Mem); - //void sqlite3VdbeMemSetZeroBlob(Mem*,int); - //void sqlite3VdbeMemSetRowSet(Mem); - //int sqlite3VdbeMemMakeWriteable(Mem); - //int sqlite3VdbeMemStringify(Mem*, int); - //i64 sqlite3VdbeIntValue(Mem); - //int sqlite3VdbeMemIntegerify(Mem); - //double sqlite3VdbeRealValue(Mem); - //void sqlite3VdbeIntegerAffinity(Mem); - //int sqlite3VdbeMemRealify(Mem); - //int sqlite3VdbeMemNumerify(Mem); - //int sqlite3VdbeMemFromBtree(BtCursor*,int,int,int,Mem); - //void sqlite3VdbeMemRelease(Mem p); - //void sqlite3VdbeMemReleaseExternal(Mem p); - //int sqlite3VdbeMemFinalize(Mem*, FuncDef); - //string sqlite3OpcodeName(int); - //int sqlite3VdbeMemGrow(Mem pMem, int n, int preserve); - //int sqlite3VdbeCloseStatement(Vdbe *, int); - //void sqlite3VdbeFrameDelete(VdbeFrame); - //int sqlite3VdbeFrameRestore(VdbeFrame ); - //void sqlite3VdbeMemStoreType(Mem *pMem); + //void sqlite3VdbeMemSetNull(Mem); + //void sqlite3VdbeMemSetZeroBlob(Mem*,int); + //void sqlite3VdbeMemSetRowSet(Mem); + //int sqlite3VdbeMemMakeWriteable(Mem); + //int sqlite3VdbeMemStringify(Mem*, int); + //i64 sqlite3VdbeIntValue(Mem); + //int sqlite3VdbeMemIntegerify(Mem); + //double sqlite3VdbeRealValue(Mem); + //void sqlite3VdbeIntegerAffinity(Mem); + //int sqlite3VdbeMemRealify(Mem); + //int sqlite3VdbeMemNumerify(Mem); + //int sqlite3VdbeMemFromBtree(BtCursor*,int,int,int,Mem); + //void sqlite3VdbeMemRelease(Mem p); + //void sqlite3VdbeMemReleaseExternal(Mem p); + //int sqlite3VdbeMemFinalize(Mem*, FuncDef); + //string sqlite3OpcodeName(int); + //int sqlite3VdbeMemGrow(Mem pMem, int n, int preserve); + //int sqlite3VdbeCloseStatement(Vdbe *, int); + //void sqlite3VdbeFrameDelete(VdbeFrame); + //int sqlite3VdbeFrameRestore(VdbeFrame ); + //void sqlite3VdbeMemStoreType(Mem *pMem); #if !(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE//>0 //void sqlite3VdbeEnter(Vdbe); //void sqlite3VdbeLeave(Vdbe); #else -//# define sqlite3VdbeEnter(X) - static void sqlite3VdbeEnter( Vdbe p ) - { - } -//# define sqlite3VdbeLeave(X) - static void sqlite3VdbeLeave( Vdbe p ) - { - } + //# define sqlite3VdbeEnter(X) + static void sqlite3VdbeEnter(Vdbe p) { + } + //# define sqlite3VdbeLeave(X) + static void sqlite3VdbeLeave(Vdbe p) { + } #endif #if SQLITE_DEBUG - //void sqlite3VdbeMemPrepareToChange(Vdbe*,Mem); + //void sqlite3VdbeMemPrepareToChange(Vdbe*,Mem); #endif #if !SQLITE_OMIT_FOREIGN_KEY - //int sqlite3VdbeCheckFk(Vdbe *, int); + //int sqlite3VdbeCheckFk(Vdbe *, int); #else //# define sqlite3VdbeCheckFk(p,i) 0 static int sqlite3VdbeCheckFk( Vdbe p, int i ) { return 0; } #endif - //int sqlite3VdbeMemTranslate(Mem*, u8); - //#if SQLITE_DEBUG - // void sqlite3VdbePrintSql(Vdbe); - // void sqlite3VdbeMemPrettyPrint(Mem pMem, string zBuf); - //#endif - //int sqlite3VdbeMemHandleBom(Mem pMem); + //int sqlite3VdbeMemTranslate(Mem*, u8); + //#if SQLITE_DEBUG + // void sqlite3VdbePrintSql(Vdbe); + // void sqlite3VdbeMemPrettyPrint(Mem pMem, string zBuf); + //#endif + //int sqlite3VdbeMemHandleBom(Mem pMem); #if !SQLITE_OMIT_INCRBLOB // int sqlite3VdbeMemExpandBlob(Mem ); #else - // #define sqlite3VdbeMemExpandBlob(x) SQLITE_OK - static int sqlite3VdbeMemExpandBlob( Mem x ) - { - return SQLITE_OK; - } + // #define sqlite3VdbeMemExpandBlob(x) SQLITE_OK + static int sqlite3VdbeMemExpandBlob(Mem x) { + return SQLITE_OK; + } #endif - //#endif //* !_VDBEINT_H_) */ - } + //#endif //* !_VDBEINT_H_) */ + } } diff --git a/Src/IronPython.SQLite/c#sqlite/Vdbe_h.cs b/Src/IronPython.SQLite/c#sqlite/Vdbe_h.cs index 28d39cb07..250ba71cc 100644 --- a/Src/IronPython.SQLite/c#sqlite/Vdbe_h.cs +++ b/Src/IronPython.SQLite/c#sqlite/Vdbe_h.cs @@ -1,83 +1,78 @@ using i64 = System.Int64; using u8 = System.Byte; -using u64 = System.UInt64; -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 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. - ** - ************************************************************************* - ** Header file for the Virtual DataBase Engine (VDBE) - ** - ** This header defines the interface to the virtual database engine - ** or VDBE. The VDBE implements an abstract machine that runs a - ** simple program to access and modify the underlying database. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#if !_SQLITE_VDBE_H_ - //#define _SQLITE_VDBE_H_ - //#include +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** Header file for the Virtual DataBase Engine (VDBE) + ** + ** This header defines the interface to the virtual database engine + ** or VDBE. The VDBE implements an abstract machine that runs a + ** simple program to access and modify the underlying database. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#if !_SQLITE_VDBE_H_ + //#define _SQLITE_VDBE_H_ + //#include - /* - ** A single VDBE is an opaque structure named "Vdbe". Only routines - ** in the source file sqliteVdbe.c are allowed to see the insides - ** of this structure. - */ - //typedef struct Vdbe Vdbe; + /* + ** A single VDBE is an opaque structure named "Vdbe". Only routines + ** in the source file sqliteVdbe.c are allowed to see the insides + ** of this structure. + */ + //typedef struct Vdbe Vdbe; - /* - ** The names of the following types declared in vdbeInt.h are required - ** for the VdbeOp definition. - */ - //typedef struct VdbeFunc VdbeFunc; - //typedef struct Mem Mem; - //typedef struct SubProgram SubProgram; + /* + ** The names of the following types declared in vdbeInt.h are required + ** for the VdbeOp definition. + */ + //typedef struct VdbeFunc VdbeFunc; + //typedef struct Mem Mem; + //typedef struct SubProgram SubProgram; - /* - ** A single instruction of the virtual machine has an opcode - ** and as many as three operands. The instruction is recorded - ** as an instance of the following structure: - */ - public class union_p4 - { /* fourth parameter */ - public int i; /* Integer value if p4type==P4_INT32 */ - public object p; /* Generic pointer */ - //public string z; /* Pointer to data for string (char array) types */ - public string z; // In C# string is unicode, so use byte[] instead - public i64 pI64; /* Used when p4type is P4_INT64 */ - public double pReal; /* Used when p4type is P4_REAL */ - public FuncDef pFunc; /* Used when p4type is P4_FUNCDEF */ - public VdbeFunc pVdbeFunc; /* Used when p4type is P4_VDBEFUNC */ - public CollSeq pColl; /* Used when p4type is P4_COLLSEQ */ - public Mem pMem; /* Used when p4type is P4_MEM */ - public VTable pVtab; /* Used when p4type is P4_VTAB */ - public KeyInfo pKeyInfo; /* Used when p4type is P4_KEYINFO */ - public int[] ai; /* Used when p4type is P4_INTARRAY */ - public SubProgram pProgram; /* Used when p4type is P4_SUBPROGRAM */ - public dxDel pFuncDel; /* Used when p4type is P4_FUNCDEL */ - } ; - public class VdbeOp - { - public u8 opcode; /* What operation to perform */ - public int p4type; /* One of the P4_xxx constants for p4 */ - public u8 opflags; /* Mask of the OPFLG_* flags in opcodes.h */ - public u8 p5; /* Fifth parameter is an unsigned character */ + /* + ** A single instruction of the virtual machine has an opcode + ** and as many as three operands. The instruction is recorded + ** as an instance of the following structure: + */ + public class union_p4 { /* fourth parameter */ + public int i; /* Integer value if p4type==P4_INT32 */ + public object p; /* Generic pointer */ + //public string z; /* Pointer to data for string (char array) types */ + public string z; // In C# string is unicode, so use byte[] instead + public i64 pI64; /* Used when p4type is P4_INT64 */ + public double pReal; /* Used when p4type is P4_REAL */ + public FuncDef pFunc; /* Used when p4type is P4_FUNCDEF */ + public VdbeFunc pVdbeFunc; /* Used when p4type is P4_VDBEFUNC */ + public CollSeq pColl; /* Used when p4type is P4_COLLSEQ */ + public Mem pMem; /* Used when p4type is P4_MEM */ + public VTable pVtab; /* Used when p4type is P4_VTAB */ + public KeyInfo pKeyInfo; /* Used when p4type is P4_KEYINFO */ + public int[] ai; /* Used when p4type is P4_INTARRAY */ + public SubProgram pProgram; /* Used when p4type is P4_SUBPROGRAM */ + public dxDel pFuncDel; /* Used when p4type is P4_FUNCDEL */ + }; + public class VdbeOp { + public u8 opcode; /* What operation to perform */ + public int p4type; /* One of the P4_xxx constants for p4 */ + public u8 opflags; /* Mask of the OPFLG_* flags in opcodes.h */ + public u8 p5; /* Fifth parameter is an unsigned character */ #if DEBUG_CLASS_VDBEOP || DEBUG_CLASS_ALL public int _p1; /* First operand */ public int p1 @@ -100,212 +95,206 @@ public int p3 set { _p3 = value; } } #else - public int p1; /* First operand */ - public int p2; /* Second parameter (often the jump destination) */ - public int p3; /* The third parameter */ + public int p1; /* First operand */ + public int p2; /* Second parameter (often the jump destination) */ + public int p3; /* The third parameter */ #endif - public union_p4 p4 = new union_p4(); + public union_p4 p4 = new union_p4(); #if SQLITE_DEBUG || DEBUG - public string zComment; /* Comment to improve readability */ + public string zComment; /* Comment to improve readability */ #endif #if VDBE_PROFILE public int cnt; /* Number of times this instruction was executed */ public u64 cycles; /* Total time spend executing this instruction */ #endif - }; - //typedef struct VdbeOp VdbeOp; + }; + //typedef struct VdbeOp VdbeOp; - /* - ** A sub-routine used to implement a trigger program. - */ - public class SubProgram - { - public VdbeOp[] aOp; /* Array of opcodes for sub-program */ - public int nOp; /* Elements in aOp[] */ - public int nMem; /* Number of memory cells required */ - public int nCsr; /* Number of cursors required */ - public int token; /* id that may be used to recursive triggers */ - public SubProgram pNext; /* Next sub-program already visited */ - }; + /* + ** A sub-routine used to implement a trigger program. + */ + public class SubProgram { + public VdbeOp[] aOp; /* Array of opcodes for sub-program */ + public int nOp; /* Elements in aOp[] */ + public int nMem; /* Number of memory cells required */ + public int nCsr; /* Number of cursors required */ + public int token; /* id that may be used to recursive triggers */ + public SubProgram pNext; /* Next sub-program already visited */ + }; - /* - ** A smaller version of VdbeOp used for the VdbeAddOpList() function because - ** it takes up less space. - */ - public struct VdbeOpList - { - public u8 opcode; /* What operation to perform */ - public int p1; /* First operand */ - public int p2; /* Second parameter (often the jump destination) */ - public int p3; /* Third parameter */ - public VdbeOpList( u8 opcode, int p1, int p2, int p3 ) - { - this.opcode = opcode; - this.p1 = p1; - this.p2 = p2; - this.p3 = p3; - } + /* + ** A smaller version of VdbeOp used for the VdbeAddOpList() function because + ** it takes up less space. + */ + public struct VdbeOpList { + public u8 opcode; /* What operation to perform */ + public int p1; /* First operand */ + public int p2; /* Second parameter (often the jump destination) */ + public int p3; /* Third parameter */ + public VdbeOpList(u8 opcode, int p1, int p2, int p3) { + this.opcode = opcode; + this.p1 = p1; + this.p2 = p2; + this.p3 = p3; + } - }; - //typedef struct VdbeOpList VdbeOpList; + }; + //typedef struct VdbeOpList VdbeOpList; - /* - ** Allowed values of VdbeOp.p4type - */ - const int P4_NOTUSED = 0; /* The P4 parameter is not used */ - const int P4_DYNAMIC = ( -1 ); /* Pointer to a string obtained from sqliteMalloc=(); */ - const int P4_STATIC = ( -2 ); /* Pointer to a static string */ - const int P4_COLLSEQ = ( -4 ); /* P4 is a pointer to a CollSeq structure */ - const int P4_FUNCDEF = ( -5 ); /* P4 is a pointer to a FuncDef structure */ - const int P4_KEYINFO = ( -6 ); /* P4 is a pointer to a KeyInfo structure */ - const int P4_VDBEFUNC = ( -7 ); /* P4 is a pointer to a VdbeFunc structure */ - const int P4_MEM = ( -8 ); /* P4 is a pointer to a Mem* structure */ - const int P4_TRANSIENT = 0; /* P4 is a pointer to a transient string */ - const int P4_VTAB = ( -10 ); /* P4 is a pointer to an sqlite3_vtab structure */ - const int P4_MPRINTF = ( -11 ); /* P4 is a string obtained from sqlite3_mprintf=(); */ - const int P4_REAL = ( -12 ); /* P4 is a 64-bit floating point value */ - const int P4_INT64 = ( -13 ); /* P4 is a 64-bit signed integer */ - const int P4_INT32 = ( -14 ); /* P4 is a 32-bit signed integer */ - const int P4_INTARRAY = ( -15 ); /* #define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */ - const int P4_SUBPROGRAM = ( -18 );/* #define P4_SUBPROGRAM (-18) /* P4 is a pointer to a SubProgram structure */ + /* + ** Allowed values of VdbeOp.p4type + */ + const int P4_NOTUSED = 0; /* The P4 parameter is not used */ + const int P4_DYNAMIC = (-1); /* Pointer to a string obtained from sqliteMalloc=(); */ + const int P4_STATIC = (-2); /* Pointer to a static string */ + const int P4_COLLSEQ = (-4); /* P4 is a pointer to a CollSeq structure */ + const int P4_FUNCDEF = (-5); /* P4 is a pointer to a FuncDef structure */ + const int P4_KEYINFO = (-6); /* P4 is a pointer to a KeyInfo structure */ + const int P4_VDBEFUNC = (-7); /* P4 is a pointer to a VdbeFunc structure */ + const int P4_MEM = (-8); /* P4 is a pointer to a Mem* structure */ + const int P4_TRANSIENT = 0; /* P4 is a pointer to a transient string */ + const int P4_VTAB = (-10); /* P4 is a pointer to an sqlite3_vtab structure */ + const int P4_MPRINTF = (-11); /* P4 is a string obtained from sqlite3_mprintf=(); */ + const int P4_REAL = (-12); /* P4 is a 64-bit floating point value */ + const int P4_INT64 = (-13); /* P4 is a 64-bit signed integer */ + const int P4_INT32 = (-14); /* P4 is a 32-bit signed integer */ + const int P4_INTARRAY = (-15); /* #define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */ + const int P4_SUBPROGRAM = (-18);/* #define P4_SUBPROGRAM (-18) /* P4 is a pointer to a SubProgram structure */ - /* When adding a P4 argument using P4_KEYINFO, a copy of the KeyInfo structure - ** is made. That copy is freed when the Vdbe is finalized. But if the - ** argument is P4_KEYINFO_HANDOFF, the passed in pointer is used. It still - ** gets freed when the Vdbe is finalized so it still should be obtained - ** from a single sqliteMalloc(). But no copy is made and the calling - ** function should *not* try to free the KeyInfo. - */ - const int P4_KEYINFO_HANDOFF = ( -16 ); // #define P4_KEYINFO_HANDOFF (-16) - const int P4_KEYINFO_STATIC = ( -17 ); // #define P4_KEYINFO_STATIC (-17) + /* When adding a P4 argument using P4_KEYINFO, a copy of the KeyInfo structure + ** is made. That copy is freed when the Vdbe is finalized. But if the + ** argument is P4_KEYINFO_HANDOFF, the passed in pointer is used. It still + ** gets freed when the Vdbe is finalized so it still should be obtained + ** from a single sqliteMalloc(). But no copy is made and the calling + ** function should *not* try to free the KeyInfo. + */ + const int P4_KEYINFO_HANDOFF = (-16); // #define P4_KEYINFO_HANDOFF (-16) + const int P4_KEYINFO_STATIC = (-17); // #define P4_KEYINFO_STATIC (-17) - /* - ** The Vdbe.aColName array contains 5n Mem structures, where n is the - ** number of columns of data returned by the statement. - */ - //#define COLNAME_NAME 0 - //#define COLNAME_DECLTYPE 1 - //#define COLNAME_DATABASE 2 - //#define COLNAME_TABLE 3 - //#define COLNAME_COLUMN 4 - //#if SQLITE_ENABLE_COLUMN_METADATA - //# define COLNAME_N 5 /* Number of COLNAME_xxx symbols */ - //#else - //# ifdef SQLITE_OMIT_DECLTYPE - //# define COLNAME_N 1 /* Store only the name */ - //# else - //# define COLNAME_N 2 /* Store the name and decltype */ - //# endif - //#endif - const int COLNAME_NAME = 0; - const int COLNAME_DECLTYPE = 1; - const int COLNAME_DATABASE = 2; - const int COLNAME_TABLE = 3; - const int COLNAME_COLUMN = 4; + /* + ** The Vdbe.aColName array contains 5n Mem structures, where n is the + ** number of columns of data returned by the statement. + */ + //#define COLNAME_NAME 0 + //#define COLNAME_DECLTYPE 1 + //#define COLNAME_DATABASE 2 + //#define COLNAME_TABLE 3 + //#define COLNAME_COLUMN 4 + //#if SQLITE_ENABLE_COLUMN_METADATA + //# define COLNAME_N 5 /* Number of COLNAME_xxx symbols */ + //#else + //# ifdef SQLITE_OMIT_DECLTYPE + //# define COLNAME_N 1 /* Store only the name */ + //# else + //# define COLNAME_N 2 /* Store the name and decltype */ + //# endif + //#endif + const int COLNAME_NAME = 0; + const int COLNAME_DECLTYPE = 1; + const int COLNAME_DATABASE = 2; + const int COLNAME_TABLE = 3; + const int COLNAME_COLUMN = 4; #if SQLITE_ENABLE_COLUMN_METADATA -const int COLNAME_N = 5; /* Number of COLNAME_xxx symbols */ + const int COLNAME_N = 5; /* Number of COLNAME_xxx symbols */ #else -# if SQLITE_OMIT_DECLTYPE +#if SQLITE_OMIT_DECLTYPE const int COLNAME_N = 1; /* Number of COLNAME_xxx symbols */ -# else +#else const int COLNAME_N = 2; -# endif +#endif #endif - /* -** The following macro converts a relative address in the p2 field -** of a VdbeOp structure into a negative number so that -** sqlite3VdbeAddOpList() knows that the address is relative. Calling -** the macro again restores the address. -*/ - //#define ADDR(X) (-1-(X)) - static int ADDR( int x ) - { - return -1 - x; - } - /* - ** The makefile scans the vdbe.c source file and creates the "opcodes.h" - ** header file that defines a number for each opcode used by the VDBE. + /* + ** The following macro converts a relative address in the p2 field + ** of a VdbeOp structure into a negative number so that + ** sqlite3VdbeAddOpList() knows that the address is relative. Calling + ** the macro again restores the address. */ - //#include "opcodes.h" + //#define ADDR(X) (-1-(X)) + static int ADDR(int x) { + return -1 - x; + } + /* + ** The makefile scans the vdbe.c source file and creates the "opcodes.h" + ** header file that defines a number for each opcode used by the VDBE. + */ + //#include "opcodes.h" - /* - ** Prototypes for the VDBE interface. See comments on the implementation - ** for a description of what each of these routines does. - */ - /* - ** Prototypes for the VDBE interface. See comments on the implementation - ** for a description of what each of these routines does. - */ - //Vdbe *sqlite3VdbeCreate(sqlite3); - //int sqlite3VdbeAddOp0(Vdbe*,int); - //int sqlite3VdbeAddOp1(Vdbe*,int,int); - //int sqlite3VdbeAddOp2(Vdbe*,int,int,int); - //int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int); - //int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,string zP4,int); - //int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int); - //int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp); - //void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char); - //void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1); - //void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2); - //void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3); - //void sqlite3VdbeChangeP5(Vdbe*, u8 P5); - //void sqlite3VdbeJumpHere(Vdbe*, int addr); - //void sqlite3VdbeChangeToNoop(Vdbe*, int addr, int N); - //void sqlite3VdbeChangeP4(Vdbe*, int addr, string zP4, int N); - //void sqlite3VdbeUsesBtree(Vdbe*, int); - //VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); - //int sqlite3VdbeMakeLabel(Vdbe); - //void sqlite3VdbeRunOnlyOnce(Vdbe); - //void sqlite3VdbeDelete(Vdbe); - //void sqlite3VdbeDeleteObject(sqlite3*,Vdbe); - //void sqlite3VdbeMakeReady(Vdbe*,Parse); - //int sqlite3VdbeFinalize(Vdbe); - //void sqlite3VdbeResolveLabel(Vdbe*, int); - //int sqlite3VdbeCurrentAddr(Vdbe); - //#if SQLITE_DEBUG - // int sqlite3VdbeAssertMayAbort(Vdbe *, int); - // void sqlite3VdbeTrace(Vdbe*,FILE); - //#endif - //void sqlite3VdbeResetStepResult(Vdbe); - //void sqlite3VdbeRewind(Vdbe); - //int sqlite3VdbeReset(Vdbe); - //void sqlite3VdbeSetNumCols(Vdbe*,int); - //int sqlite3VdbeSetColName(Vdbe*, int, int, string , void()(void)); - //void sqlite3VdbeCountChanges(Vdbe); - //sqlite3 *sqlite3VdbeDb(Vdbe); - //void sqlite3VdbeSetSql(Vdbe*, string z, int n, int); - //void sqlite3VdbeSwap(Vdbe*,Vdbe); - //VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int); - //sqlite3_value *sqlite3VdbeGetValue(Vdbe*, int, u8); - //void sqlite3VdbeSetVarmask(Vdbe*, int); - //#if !SQLITE_OMIT_TRACE - // char *sqlite3VdbeExpandSql(Vdbe*, const char); - //#endif + /* + ** Prototypes for the VDBE interface. See comments on the implementation + ** for a description of what each of these routines does. + */ + /* + ** Prototypes for the VDBE interface. See comments on the implementation + ** for a description of what each of these routines does. + */ + //Vdbe *sqlite3VdbeCreate(sqlite3); + //int sqlite3VdbeAddOp0(Vdbe*,int); + //int sqlite3VdbeAddOp1(Vdbe*,int,int); + //int sqlite3VdbeAddOp2(Vdbe*,int,int,int); + //int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int); + //int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,string zP4,int); + //int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int); + //int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp); + //void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char); + //void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1); + //void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2); + //void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3); + //void sqlite3VdbeChangeP5(Vdbe*, u8 P5); + //void sqlite3VdbeJumpHere(Vdbe*, int addr); + //void sqlite3VdbeChangeToNoop(Vdbe*, int addr, int N); + //void sqlite3VdbeChangeP4(Vdbe*, int addr, string zP4, int N); + //void sqlite3VdbeUsesBtree(Vdbe*, int); + //VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); + //int sqlite3VdbeMakeLabel(Vdbe); + //void sqlite3VdbeRunOnlyOnce(Vdbe); + //void sqlite3VdbeDelete(Vdbe); + //void sqlite3VdbeDeleteObject(sqlite3*,Vdbe); + //void sqlite3VdbeMakeReady(Vdbe*,Parse); + //int sqlite3VdbeFinalize(Vdbe); + //void sqlite3VdbeResolveLabel(Vdbe*, int); + //int sqlite3VdbeCurrentAddr(Vdbe); + //#if SQLITE_DEBUG + // int sqlite3VdbeAssertMayAbort(Vdbe *, int); + // void sqlite3VdbeTrace(Vdbe*,FILE); + //#endif + //void sqlite3VdbeResetStepResult(Vdbe); + //void sqlite3VdbeRewind(Vdbe); + //int sqlite3VdbeReset(Vdbe); + //void sqlite3VdbeSetNumCols(Vdbe*,int); + //int sqlite3VdbeSetColName(Vdbe*, int, int, string , void()(void)); + //void sqlite3VdbeCountChanges(Vdbe); + //sqlite3 *sqlite3VdbeDb(Vdbe); + //void sqlite3VdbeSetSql(Vdbe*, string z, int n, int); + //void sqlite3VdbeSwap(Vdbe*,Vdbe); + //VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int); + //sqlite3_value *sqlite3VdbeGetValue(Vdbe*, int, u8); + //void sqlite3VdbeSetVarmask(Vdbe*, int); + //#if !SQLITE_OMIT_TRACE + // char *sqlite3VdbeExpandSql(Vdbe*, const char); + //#endif - //UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,char*,int); - //void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord); - //int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord); + //UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,char*,int); + //void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord); + //int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord); - //#if !SQLITE_OMIT_TRIGGER - //void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram ); - //#endif + //#if !SQLITE_OMIT_TRIGGER + //void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram ); + //#endif #if !NDEBUG - //void sqlite3VdbeComment(Vdbe*, const char*, ...); - static void VdbeComment( Vdbe v, string zFormat, params object[] ap ) - { - sqlite3VdbeComment( v, zFormat, ap ); - }//# define VdbeComment(X) sqlite3VdbeComment X - //void sqlite3VdbeNoopComment(Vdbe*, const char*, ...); - static void VdbeNoopComment( Vdbe v, string zFormat, params object[] ap ) - { - sqlite3VdbeNoopComment( v, zFormat, ap ); - }//# define VdbeNoopComment(X) sqlite3VdbeNoopComment X + //void sqlite3VdbeComment(Vdbe*, const char*, ...); + static void VdbeComment(Vdbe v, string zFormat, params object[] ap) { + sqlite3VdbeComment(v, zFormat, ap); + }//# define VdbeComment(X) sqlite3VdbeComment X + //void sqlite3VdbeNoopComment(Vdbe*, const char*, ...); + static void VdbeNoopComment(Vdbe v, string zFormat, params object[] ap) { + sqlite3VdbeNoopComment(v, zFormat, ap); + }//# define VdbeNoopComment(X) sqlite3VdbeNoopComment X #else //# define VdbeComment(X) static void VdbeComment( Vdbe v, string zFormat, params object[] ap ) { } //# define VdbeNoopComment(X) static void VdbeNoopComment( Vdbe v, string zFormat, params object[] ap ) { } #endif - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/_Custom.cs b/Src/IronPython.SQLite/c#sqlite/_Custom.cs index 06be9aa74..b0c0f7dc2 100644 --- a/Src/IronPython.SQLite/c#sqlite/_Custom.cs +++ b/Src/IronPython.SQLite/c#sqlite/_Custom.cs @@ -18,583 +18,483 @@ using u32 = System.UInt32; using time_t = System.Int64; -namespace Community.CsharpSqlite -{ - using sqlite3_value = Sqlite3.Mem; +namespace Community.CsharpSqlite { + using sqlite3_value = Sqlite3.Mem; - public partial class Sqlite3 - { + public partial class Sqlite3 { -static int atoi( byte[] inStr ) -{ - return atoi( Encoding.UTF8.GetString( inStr, 0, inStr.Length ) ); -} + static int atoi(byte[] inStr) { + return atoi(Encoding.UTF8.GetString(inStr, 0, inStr.Length)); + } -static int atoi( string inStr ) -{ - int i; - for ( i = 0; i < inStr.Length; i++ ) - { - if ( !sqlite3Isdigit( inStr[i] ) && inStr[i] != '-' ) - break; - } - int result = 0; -#if WINDOWS_MOBILE + static int atoi(string inStr) { + int i; + for (i = 0; i < inStr.Length; i++) { + if (!sqlite3Isdigit(inStr[i]) && inStr[i] != '-') + break; + } + int result = 0; +#if WINDOWS_MOBILE try { result = Int32.Parse(inStr.Substring(0, i)); } catch { } return result; #else - return ( Int32.TryParse( inStr.Substring( 0, i ), out result ) ? result : 0 ); + return (Int32.TryParse(inStr.Substring(0, i), out result) ? result : 0); #endif -} + } -static void fprintf( TextWriter tw, string zFormat, params object[] ap ) -{ - tw.Write( sqlite3_mprintf( zFormat, ap ) ); -} -static void printf( string zFormat, params object[] ap ) -{ + static void fprintf(TextWriter tw, string zFormat, params object[] ap) { + tw.Write(sqlite3_mprintf(zFormat, ap)); + } + static void printf(string zFormat, params object[] ap) { #if !SQLITE_WINRT - Console.Out.Write( sqlite3_mprintf( zFormat, ap ) ); + Console.Out.Write(sqlite3_mprintf(zFormat, ap)); #endif -} - - -//Byte Buffer Testing -static int memcmp( byte[] bA, byte[] bB, int Limit ) -{ - if ( bA.Length < Limit ) - return ( bA.Length < bB.Length ) ? -1 : +1; - if ( bB.Length < Limit ) - return +1; - for ( int i = 0; i < Limit; i++ ) - { - if ( bA[i] != bB[i] ) - return ( bA[i] < bB[i] ) ? -1 : 1; - } - return 0; -} + } -//Byte Buffer & String Testing -static int memcmp( string A, byte[] bB, int Limit ) -{ - if ( A.Length < Limit ) - return ( A.Length < bB.Length ) ? -1 : +1; - if ( bB.Length < Limit ) - return +1; - char[] cA = A.ToCharArray(); - for ( int i = 0; i < Limit; i++ ) - { - if ( cA[i] != bB[i] ) - return ( cA[i] < bB[i] ) ? -1 : 1; - } - return 0; -} -//byte with Offset & String Testing -static int memcmp( byte[] a, int Offset, byte[] b, int Limit ) -{ - if ( a.Length < Offset + Limit ) - return ( a.Length - Offset < b.Length ) ? -1 : +1; - if ( b.Length < Limit ) - return +1; - for ( int i = 0; i < Limit; i++ ) - { - if ( a[i + Offset] != b[i] ) - return ( a[i + Offset] < b[i] ) ? -1 : 1; - } - return 0; -} + //Byte Buffer Testing + static int memcmp(byte[] bA, byte[] bB, int Limit) { + if (bA.Length < Limit) + return (bA.Length < bB.Length) ? -1 : +1; + if (bB.Length < Limit) + return +1; + for (int i = 0; i < Limit; i++) { + if (bA[i] != bB[i]) + return (bA[i] < bB[i]) ? -1 : 1; + } + return 0; + } -//byte with Offset & String Testing -static int memcmp( byte[] a, int Aoffset, byte[] b, int Boffset, int Limit ) -{ - if ( a.Length < Aoffset + Limit ) - return ( a.Length - Aoffset < b.Length - Boffset ) ? -1 : +1; - if ( b.Length < Boffset + Limit ) - return +1; - for ( int i = 0; i < Limit; i++ ) - { - if ( a[i + Aoffset] != b[i + Boffset] ) - return ( a[i + Aoffset] < b[i + Boffset] ) ? -1 : 1; - } - return 0; -} + //Byte Buffer & String Testing + static int memcmp(string A, byte[] bB, int Limit) { + if (A.Length < Limit) + return (A.Length < bB.Length) ? -1 : +1; + if (bB.Length < Limit) + return +1; + char[] cA = A.ToCharArray(); + for (int i = 0; i < Limit; i++) { + if (cA[i] != bB[i]) + return (cA[i] < bB[i]) ? -1 : 1; + } + return 0; + } -static int memcmp( byte[] a, int Offset, string b, int Limit ) -{ - if ( a.Length < Offset + Limit ) - return ( a.Length - Offset < b.Length ) ? -1 : +1; - if ( b.Length < Limit ) - return +1; - for ( int i = 0; i < Limit; i++ ) - { - if ( a[i + Offset] != b[i] ) - return ( a[i + Offset] < b[i] ) ? -1 : 1; - } - return 0; -} -//String Testing -static int memcmp( string A, string B, int Limit ) -{ - if ( A.Length < Limit ) - return ( A.Length < B.Length ) ? -1 : +1; - if ( B.Length < Limit ) - return +1; - int rc; - if ( ( rc = String.Compare( A, 0, B, 0, Limit, StringComparison.Ordinal ) ) == 0 ) - return 0; - return rc < 0 ? -1 : +1; -} + //byte with Offset & String Testing + static int memcmp(byte[] a, int Offset, byte[] b, int Limit) { + if (a.Length < Offset + Limit) + return (a.Length - Offset < b.Length) ? -1 : +1; + if (b.Length < Limit) + return +1; + for (int i = 0; i < Limit; i++) { + if (a[i + Offset] != b[i]) + return (a[i + Offset] < b[i]) ? -1 : 1; + } + return 0; + } + //byte with Offset & String Testing + static int memcmp(byte[] a, int Aoffset, byte[] b, int Boffset, int Limit) { + if (a.Length < Aoffset + Limit) + return (a.Length - Aoffset < b.Length - Boffset) ? -1 : +1; + if (b.Length < Boffset + Limit) + return +1; + for (int i = 0; i < Limit; i++) { + if (a[i + Aoffset] != b[i + Boffset]) + return (a[i + Aoffset] < b[i + Boffset]) ? -1 : 1; + } + return 0; + } -// ---------------------------- -// ** Builtin Functions -// ---------------------------- + static int memcmp(byte[] a, int Offset, string b, int Limit) { + if (a.Length < Offset + Limit) + return (a.Length - Offset < b.Length) ? -1 : +1; + if (b.Length < Limit) + return +1; + for (int i = 0; i < Limit; i++) { + if (a[i + Offset] != b[i]) + return (a[i + Offset] < b[i]) ? -1 : 1; + } + return 0; + } + //String Testing + static int memcmp(string A, string B, int Limit) { + if (A.Length < Limit) + return (A.Length < B.Length) ? -1 : +1; + if (B.Length < Limit) + return +1; + int rc; + if ((rc = String.Compare(A, 0, B, 0, Limit, StringComparison.Ordinal)) == 0) + return 0; + return rc < 0 ? -1 : +1; + } -static Regex oRegex = null; -/* -** The regexp() function. two arguments are both strings -** Collating sequences are not used. -*/ -static void regexpFunc( -sqlite3_context context, -int argc, -sqlite3_value[] argv -) -{ - string zTest; /* The input string A */ - string zRegex; /* The regex string B */ - - Debug.Assert( argc == 2 ); - UNUSED_PARAMETER( argc ); - zRegex = sqlite3_value_text( argv[0] ); - zTest = sqlite3_value_text( argv[1] ); - - if ( zTest == null || String.IsNullOrEmpty( zRegex ) ) - { - sqlite3_result_int( context, 0 ); - return; - } - - if ( oRegex == null || oRegex.ToString() == zRegex ) - { - oRegex = new Regex( zRegex, RegexOptions.IgnoreCase ); - } - sqlite3_result_int( context, oRegex.IsMatch( zTest ) ? 1 : 0 ); -} + // ---------------------------- + // ** Builtin Functions + // ---------------------------- + + + static Regex oRegex = null; + /* + ** The regexp() function. two arguments are both strings + ** Collating sequences are not used. + */ + static void regexpFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + string zTest; /* The input string A */ + string zRegex; /* The regex string B */ + + Debug.Assert(argc == 2); + UNUSED_PARAMETER(argc); + zRegex = sqlite3_value_text(argv[0]); + zTest = sqlite3_value_text(argv[1]); + + if (zTest == null || String.IsNullOrEmpty(zRegex)) { + sqlite3_result_int(context, 0); + return; + } + + if (oRegex == null || oRegex.ToString() == zRegex) { + oRegex = new Regex(zRegex, RegexOptions.IgnoreCase); + } + sqlite3_result_int(context, oRegex.IsMatch(zTest) ? 1 : 0); + } -// ---------------------------- -// ** Convertion routines -// ---------------------------- -static Object lock_va_list = new Object(); + // ---------------------------- + // ** Convertion routines + // ---------------------------- + static Object lock_va_list = new Object(); -static string vaFORMAT; -static int vaNEXT; + static string vaFORMAT; + static int vaNEXT; -static void va_start( object[] ap, string zFormat ) -{ - vaFORMAT = zFormat; - vaNEXT = 0; -} + static void va_start(object[] ap, string zFormat) { + vaFORMAT = zFormat; + vaNEXT = 0; + } -static Boolean va_arg( object[] ap, Boolean sysType ) -{ - return Convert.ToBoolean( ap[vaNEXT++] ); -} + static Boolean va_arg(object[] ap, Boolean sysType) { + return Convert.ToBoolean(ap[vaNEXT++]); + } -static Byte[] va_arg( object[] ap, Byte[] sysType ) -{ - return (Byte[])ap[vaNEXT++]; -} + static Byte[] va_arg(object[] ap, Byte[] sysType) { + return (Byte[])ap[vaNEXT++]; + } -static Byte[][] va_arg( object[] ap, Byte[][] sysType ) -{ - if ( ap[vaNEXT] == null ) - { - { - vaNEXT++; - return null; - } - } - else - { - return (Byte[][])ap[vaNEXT++]; - } -} + static Byte[][] va_arg(object[] ap, Byte[][] sysType) { + if (ap[vaNEXT] == null) { + { + vaNEXT++; + return null; + } + } else { + return (Byte[][])ap[vaNEXT++]; + } + } -static Char va_arg( object[] ap, Char sysType ) -{ - if ( ap[vaNEXT] is Int32 && (int)ap[vaNEXT] == 0 ) - { - vaNEXT++; - return (char)'0'; - } - else - { - if ( ap[vaNEXT] is Int64 ) - if ( (i64)ap[vaNEXT] == 0 ) - { - vaNEXT++; - return (char)'0'; - } - else - return (char)( (i64)ap[vaNEXT++] ); - else - return (char)ap[vaNEXT++]; - } + static Char va_arg(object[] ap, Char sysType) { + if (ap[vaNEXT] is Int32 && (int)ap[vaNEXT] == 0) { + vaNEXT++; + return (char)'0'; + } else { + if (ap[vaNEXT] is Int64) + if ((i64)ap[vaNEXT] == 0) { + vaNEXT++; + return (char)'0'; + } else + return (char)((i64)ap[vaNEXT++]); + else + return (char)ap[vaNEXT++]; + } -} + } -static Double va_arg( object[] ap, Double sysType ) -{ - return Convert.ToDouble( ap[vaNEXT++] ); -} + static Double va_arg(object[] ap, Double sysType) { + return Convert.ToDouble(ap[vaNEXT++]); + } -static dxLog va_arg( object[] ap, dxLog sysType ) -{ - return (dxLog)ap[vaNEXT++]; -} + static dxLog va_arg(object[] ap, dxLog sysType) { + return (dxLog)ap[vaNEXT++]; + } -static Int64 va_arg( object[] ap, Int64 sysType ) -{ - if ( ap[vaNEXT] is System.Int64) - return Convert.ToInt64( ap[vaNEXT++] ); - else - return (Int64)( ap[vaNEXT++].GetHashCode() ); -} + static Int64 va_arg(object[] ap, Int64 sysType) { + if (ap[vaNEXT] is System.Int64) + return Convert.ToInt64(ap[vaNEXT++]); + else + return (Int64)(ap[vaNEXT++].GetHashCode()); + } -static Int32 va_arg( object[] ap, Int32 sysType ) -{ - if ( Convert.ToInt64( ap[vaNEXT] ) > 0 && ( Convert.ToUInt32( ap[vaNEXT] ) > Int32.MaxValue ) ) - return (Int32)( Convert.ToUInt32( ap[vaNEXT++] ) - System.UInt32.MaxValue - 1 ); - else - return (Int32)Convert.ToInt32( ap[vaNEXT++] ); -} + static Int32 va_arg(object[] ap, Int32 sysType) { + if (Convert.ToInt64(ap[vaNEXT]) > 0 && (Convert.ToUInt32(ap[vaNEXT]) > Int32.MaxValue)) + return (Int32)(Convert.ToUInt32(ap[vaNEXT++]) - System.UInt32.MaxValue - 1); + else + return (Int32)Convert.ToInt32(ap[vaNEXT++]); + } -static Int32[] va_arg( object[] ap, Int32[] sysType ) -{ - if ( ap[vaNEXT] == null ) - { - { - vaNEXT++; - return null; - } - } - else - { - return (Int32[])ap[vaNEXT++]; - } -} + static Int32[] va_arg(object[] ap, Int32[] sysType) { + if (ap[vaNEXT] == null) { + { + vaNEXT++; + return null; + } + } else { + return (Int32[])ap[vaNEXT++]; + } + } -static MemPage va_arg( object[] ap, MemPage sysType ) -{ - return (MemPage)ap[vaNEXT++]; -} + static MemPage va_arg(object[] ap, MemPage sysType) { + return (MemPage)ap[vaNEXT++]; + } -static Object va_arg( object[] ap, Object sysType ) -{ - return (Object)ap[vaNEXT++]; -} + static Object va_arg(object[] ap, Object sysType) { + return (Object)ap[vaNEXT++]; + } -static sqlite3 va_arg( object[] ap, sqlite3 sysType ) -{ - return (sqlite3)ap[vaNEXT++]; -} + static sqlite3 va_arg(object[] ap, sqlite3 sysType) { + return (sqlite3)ap[vaNEXT++]; + } -static sqlite3_mem_methods va_arg( object[] ap, sqlite3_mem_methods sysType ) -{ - return (sqlite3_mem_methods)ap[vaNEXT++]; -} + static sqlite3_mem_methods va_arg(object[] ap, sqlite3_mem_methods sysType) { + return (sqlite3_mem_methods)ap[vaNEXT++]; + } -static sqlite3_mutex_methods va_arg( object[] ap, sqlite3_mutex_methods sysType ) -{ - return (sqlite3_mutex_methods)ap[vaNEXT++]; -} + static sqlite3_mutex_methods va_arg(object[] ap, sqlite3_mutex_methods sysType) { + return (sqlite3_mutex_methods)ap[vaNEXT++]; + } -static SrcList va_arg( object[] ap, SrcList sysType ) -{ - return (SrcList)ap[vaNEXT++]; -} + static SrcList va_arg(object[] ap, SrcList sysType) { + return (SrcList)ap[vaNEXT++]; + } -static String va_arg( object[] ap, String sysType ) -{ - if ( ap.Length < vaNEXT - 1 || ap[vaNEXT] == null ) - { - vaNEXT++; - return "NULL"; - } - else - { - if ( ap[vaNEXT] is Byte[] ) - if ( Encoding.UTF8.GetString( (byte[])ap[vaNEXT], 0, ( (byte[])ap[vaNEXT] ).Length ) == "\0" ) - { - vaNEXT++; - return ""; - } - else - return Encoding.UTF8.GetString( (byte[])ap[vaNEXT], 0, ( (byte[])ap[vaNEXT++] ).Length ); - else if ( ap[vaNEXT] is Int32 ) - { - vaNEXT++; - return null; - } - else if ( ap[vaNEXT] is StringBuilder ) - return (String)ap[vaNEXT++].ToString(); - else if ( ap[vaNEXT] is Char ) - return ( (Char)ap[vaNEXT++] ).ToString(); - else - return (String)ap[vaNEXT++]; - } -} + static String va_arg(object[] ap, String sysType) { + if (ap.Length < vaNEXT - 1 || ap[vaNEXT] == null) { + vaNEXT++; + return "NULL"; + } else { + if (ap[vaNEXT] is Byte[]) + if (Encoding.UTF8.GetString((byte[])ap[vaNEXT], 0, ((byte[])ap[vaNEXT]).Length) == "\0") { + vaNEXT++; + return ""; + } else + return Encoding.UTF8.GetString((byte[])ap[vaNEXT], 0, ((byte[])ap[vaNEXT++]).Length); + else if (ap[vaNEXT] is Int32) { + vaNEXT++; + return null; + } else if (ap[vaNEXT] is StringBuilder) + return (String)ap[vaNEXT++].ToString(); + else if (ap[vaNEXT] is Char) + return ((Char)ap[vaNEXT++]).ToString(); + else + return (String)ap[vaNEXT++]; + } + } -static Token va_arg( object[] ap, Token sysType ) -{ - return (Token)ap[vaNEXT++]; -} + static Token va_arg(object[] ap, Token sysType) { + return (Token)ap[vaNEXT++]; + } -static UInt32 va_arg( object[] ap, UInt32 sysType ) -{ + static UInt32 va_arg(object[] ap, UInt32 sysType) { #if SQLITE_WINRT Type t = ap[vaNEXT].GetType(); if ( t.IsClass ) #else - if ( ap[vaNEXT].GetType().IsClass ) + if (ap[vaNEXT].GetType().IsClass) #endif - { - return (UInt32)ap[vaNEXT++].GetHashCode(); - } - else - { - return (UInt32)Convert.ToUInt32( ap[vaNEXT++] ); - } -} + { + return (UInt32)ap[vaNEXT++].GetHashCode(); + } else { + return (UInt32)Convert.ToUInt32(ap[vaNEXT++]); + } + } -static UInt64 va_arg( object[] ap, UInt64 sysType ) -{ + static UInt64 va_arg(object[] ap, UInt64 sysType) { #if SQLITE_WINRT Type t = ap[vaNEXT].GetType(); if (t.IsClass) #else - if ( ap[vaNEXT].GetType().IsClass ) + if (ap[vaNEXT].GetType().IsClass) #endif - { - return (UInt64)ap[vaNEXT++].GetHashCode(); - } - else - { - return (UInt64)Convert.ToUInt64( ap[vaNEXT++] ); - } -} - -static void_function va_arg( object[] ap, void_function sysType ) -{ - return (void_function)ap[vaNEXT++]; -} + { + return (UInt64)ap[vaNEXT++].GetHashCode(); + } else { + return (UInt64)Convert.ToUInt64(ap[vaNEXT++]); + } + } + static void_function va_arg(object[] ap, void_function sysType) { + return (void_function)ap[vaNEXT++]; + } -static void va_end( ref string[] ap ) -{ - ap = null; - vaNEXT = -1; - vaFORMAT = ""; -} -static void va_end( ref object[] ap ) -{ - ap = null; - vaNEXT = -1; - vaFORMAT = ""; -} + static void va_end(ref string[] ap) { + ap = null; + vaNEXT = -1; + vaFORMAT = ""; + } + static void va_end(ref object[] ap) { + ap = null; + vaNEXT = -1; + vaFORMAT = ""; + } -public static tm localtime( time_t baseTime ) -{ - System.DateTime RefTime = new System.DateTime( 1970, 1, 1, 0, 0, 0, 0 ); - RefTime = RefTime.AddSeconds( Convert.ToDouble( baseTime ) ).ToLocalTime(); - tm tm = new tm(); - tm.tm_sec = RefTime.Second; - tm.tm_min = RefTime.Minute; - tm.tm_hour = RefTime.Hour; - tm.tm_mday = RefTime.Day; - tm.tm_mon = RefTime.Month; - tm.tm_year = RefTime.Year; - tm.tm_wday = (int)RefTime.DayOfWeek; - tm.tm_yday = RefTime.DayOfYear; - tm.tm_isdst = RefTime.IsDaylightSavingTime() ? 1 : 0; - return tm; -} -public static long ToUnixtime( System.DateTime date ) -{ - System.DateTime unixStartTime = new System.DateTime( 1970, 1, 1, 0, 0, 0, 0 ); - System.TimeSpan timeSpan = date - unixStartTime; - return Convert.ToInt64( timeSpan.TotalSeconds ); -} + public static tm localtime(time_t baseTime) { + System.DateTime RefTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0); + RefTime = RefTime.AddSeconds(Convert.ToDouble(baseTime)).ToLocalTime(); + tm tm = new tm(); + tm.tm_sec = RefTime.Second; + tm.tm_min = RefTime.Minute; + tm.tm_hour = RefTime.Hour; + tm.tm_mday = RefTime.Day; + tm.tm_mon = RefTime.Month; + tm.tm_year = RefTime.Year; + tm.tm_wday = (int)RefTime.DayOfWeek; + tm.tm_yday = RefTime.DayOfYear; + tm.tm_isdst = RefTime.IsDaylightSavingTime() ? 1 : 0; + return tm; + } -public static System.DateTime ToCSharpTime( long unixTime ) -{ - System.DateTime unixStartTime = new System.DateTime( 1970, 1, 1, 0, 0, 0, 0 ); - return unixStartTime.AddSeconds( Convert.ToDouble( unixTime ) ); -} + public static long ToUnixtime(System.DateTime date) { + System.DateTime unixStartTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0); + System.TimeSpan timeSpan = date - unixStartTime; + return Convert.ToInt64(timeSpan.TotalSeconds); + } -public class tm -{ - public int tm_sec; /* seconds after the minute - [0,59] */ - public int tm_min; /* minutes after the hour - [0,59] */ - public int tm_hour; /* hours since midnight - [0,23] */ - public int tm_mday; /* day of the month - [1,31] */ - public int tm_mon; /* months since January - [0,11] */ - public int tm_year; /* years since 1900 */ - public int tm_wday; /* days since Sunday - [0,6] */ - public int tm_yday; /* days since January 1 - [0,365] */ - public int tm_isdst; /* daylight savings time flag */ -}; + public static System.DateTime ToCSharpTime(long unixTime) { + System.DateTime unixStartTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0); + return unixStartTime.AddSeconds(Convert.ToDouble(unixTime)); + } -public struct FILETIME -{ - public u32 dwLowDateTime; - public u32 dwHighDateTime; -} + public class tm { + public int tm_sec; /* seconds after the minute - [0,59] */ + public int tm_min; /* minutes after the hour - [0,59] */ + public int tm_hour; /* hours since midnight - [0,23] */ + public int tm_mday; /* day of the month - [1,31] */ + public int tm_mon; /* months since January - [0,11] */ + public int tm_year; /* years since 1900 */ + public int tm_wday; /* days since Sunday - [0,6] */ + public int tm_yday; /* days since January 1 - [0,365] */ + public int tm_isdst; /* daylight savings time flag */ + }; + + public struct FILETIME { + public u32 dwLowDateTime; + public u32 dwHighDateTime; + } -static void SWAP( ref T A, ref T B ) -{ - T t = A; - A = B; - B = t; -} + static void SWAP(ref T A, ref T B) { + T t = A; + A = B; + B = t; + } -static void x_CountStep( -sqlite3_context context, -int argc, -sqlite3_value[] argv -) -{ - SumCtx p; - - int type; - Debug.Assert( argc <= 1 ); - Mem pMem = sqlite3_aggregate_context( context, 1 );//sizeof(*p)); - if ( pMem._SumCtx == null ) - pMem._SumCtx = new SumCtx(); - p = pMem._SumCtx; - if ( p.Context == null ) - p.Context = pMem; - if ( argc == 0 || SQLITE_NULL == sqlite3_value_type( argv[0] ) ) - { - p.cnt++; - p.iSum += 1; - } - else - { - type = sqlite3_value_numeric_type( argv[0] ); - if ( p != null && type != SQLITE_NULL ) - { - p.cnt++; - if ( type == SQLITE_INTEGER ) - { - i64 v = sqlite3_value_int64( argv[0] ); - if ( v == 40 || v == 41 ) - { - sqlite3_result_error( context, "value of " + v + " handed to x_count", -1 ); - return; - } - else - { - p.iSum += v; - if ( !( p.approx | p.overflow != 0 ) ) - { - i64 iNewSum = p.iSum + v; - int s1 = (int)( p.iSum >> ( sizeof( i64 ) * 8 - 1 ) ); - int s2 = (int)( v >> ( sizeof( i64 ) * 8 - 1 ) ); - int s3 = (int)( iNewSum >> ( sizeof( i64 ) * 8 - 1 ) ); - p.overflow = ( ( s1 & s2 & ~s3 ) | ( ~s1 & ~s2 & s3 ) ) != 0 ? 1 : 0; - p.iSum = iNewSum; - } - } - } - else - { - p.rSum += sqlite3_value_double( argv[0] ); - p.approx = true; - } - } - } -} -static void x_CountFinalize( sqlite3_context context ) -{ - SumCtx p; - Mem pMem = sqlite3_aggregate_context( context, 0 ); - p = pMem._SumCtx; - if ( p != null && p.cnt > 0 ) - { - if ( p.overflow != 0 ) - { - sqlite3_result_error( context, "integer overflow", -1 ); - } - else if ( p.approx ) - { - sqlite3_result_double( context, p.rSum ); - } - else if ( p.iSum == 42 ) - { - sqlite3_result_error( context, "x_count totals to 42", -1 ); - } - else - { - sqlite3_result_int64( context, p.iSum ); - } - } -} + static void x_CountStep( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + SumCtx p; + + int type; + Debug.Assert(argc <= 1); + Mem pMem = sqlite3_aggregate_context(context, 1);//sizeof(*p)); + if (pMem._SumCtx == null) + pMem._SumCtx = new SumCtx(); + p = pMem._SumCtx; + if (p.Context == null) + p.Context = pMem; + if (argc == 0 || SQLITE_NULL == sqlite3_value_type(argv[0])) { + p.cnt++; + p.iSum += 1; + } else { + type = sqlite3_value_numeric_type(argv[0]); + if (p != null && type != SQLITE_NULL) { + p.cnt++; + if (type == SQLITE_INTEGER) { + i64 v = sqlite3_value_int64(argv[0]); + if (v == 40 || v == 41) { + sqlite3_result_error(context, "value of " + v + " handed to x_count", -1); + return; + } else { + p.iSum += v; + if (!(p.approx | p.overflow != 0)) { + i64 iNewSum = p.iSum + v; + int s1 = (int)(p.iSum >> (sizeof(i64) * 8 - 1)); + int s2 = (int)(v >> (sizeof(i64) * 8 - 1)); + int s3 = (int)(iNewSum >> (sizeof(i64) * 8 - 1)); + p.overflow = ((s1 & s2 & ~s3) | (~s1 & ~s2 & s3)) != 0 ? 1 : 0; + p.iSum = iNewSum; + } + } + } else { + p.rSum += sqlite3_value_double(argv[0]); + p.approx = true; + } + } + } + } + static void x_CountFinalize(sqlite3_context context) { + SumCtx p; + Mem pMem = sqlite3_aggregate_context(context, 0); + p = pMem._SumCtx; + if (p != null && p.cnt > 0) { + if (p.overflow != 0) { + sqlite3_result_error(context, "integer overflow", -1); + } else if (p.approx) { + sqlite3_result_double(context, p.rSum); + } else if (p.iSum == 42) { + sqlite3_result_error(context, "x_count totals to 42", -1); + } else { + sqlite3_result_int64(context, p.iSum); + } + } + } #if SQLITE_MUTEX_W32 -//---------------------WIN32 Definitions -static int GetCurrentThreadId() -{ - return Environment.CurrentManagedThreadId; -} -static long InterlockedIncrement( long location ) -{ - Interlocked.Increment( ref location ); - return location; -} -static void EnterCriticalSection( Object mtx ) -{ - //long mid = mtx.GetHashCode(); - //int tid = Thread.CurrentThread.ManagedThreadId; - //long ticks = cnt++; - //Debug.WriteLine(String.Format( "{2}: +EnterCriticalSection; Mutex {0} Thread {1}", mtx.GetHashCode(), Thread.CurrentThread.ManagedThreadId, ticks) ); - Monitor.Enter( mtx ); -} -static void InitializeCriticalSection( Object mtx ) -{ - //Debug.WriteLine(String.Format( "{2}: +InitializeCriticalSection; Mutex {0} Thread {1}", mtx.GetHashCode(), Thread.CurrentThread.ManagedThreadId, System.DateTime.Now.Ticks )); -} -static void DeleteCriticalSection( Object mtx ) -{ - //Debug.WriteLine(String.Format( "{2}: +DeleteCriticalSection; Mutex {0} Thread {1}", mtx.GetHashCode(), Thread.CurrentThread.ManagedThreadId, System.DateTime.Now.Ticks) ); -} -static void LeaveCriticalSection( Object mtx ) -{ - //Debug.WriteLine(String.Format("{2}: +LeaveCriticalSection; Mutex {0} Thread {1}", mtx.GetHashCode(), Thread.CurrentThread.ManagedThreadId, System.DateTime.Now.Ticks )); - Monitor.Exit( mtx ); -} + //---------------------WIN32 Definitions + static int GetCurrentThreadId() { + return Environment.CurrentManagedThreadId; + } + static long InterlockedIncrement(long location) { + Interlocked.Increment(ref location); + return location; + } + static void EnterCriticalSection(Object mtx) { + //long mid = mtx.GetHashCode(); + //int tid = Thread.CurrentThread.ManagedThreadId; + //long ticks = cnt++; + //Debug.WriteLine(String.Format( "{2}: +EnterCriticalSection; Mutex {0} Thread {1}", mtx.GetHashCode(), Thread.CurrentThread.ManagedThreadId, ticks) ); + Monitor.Enter(mtx); + } + static void InitializeCriticalSection(Object mtx) { + //Debug.WriteLine(String.Format( "{2}: +InitializeCriticalSection; Mutex {0} Thread {1}", mtx.GetHashCode(), Thread.CurrentThread.ManagedThreadId, System.DateTime.Now.Ticks )); + } + static void DeleteCriticalSection(Object mtx) { + //Debug.WriteLine(String.Format( "{2}: +DeleteCriticalSection; Mutex {0} Thread {1}", mtx.GetHashCode(), Thread.CurrentThread.ManagedThreadId, System.DateTime.Now.Ticks) ); + } + static void LeaveCriticalSection(Object mtx) { + //Debug.WriteLine(String.Format("{2}: +LeaveCriticalSection; Mutex {0} Thread {1}", mtx.GetHashCode(), Thread.CurrentThread.ManagedThreadId, System.DateTime.Now.Ticks )); + Monitor.Exit(mtx); + } #endif -// Miscellaneous Windows Constants -//#define ERROR_FILE_NOT_FOUND 2L -//#define ERROR_HANDLE_DISK_FULL 39L -//#define ERROR_NOT_SUPPORTED 50L -//#define ERROR_DISK_FULL 112L -const long ERROR_FILE_NOT_FOUND = 2L; -const long ERROR_HANDLE_DISK_FULL = 39L; -const long ERROR_NOT_SUPPORTED = 50L; -const long ERROR_DISK_FULL = 112L; - -private class SQLite3UpperToLower -{ - static int[] sqlite3UpperToLower = new int[] { + // Miscellaneous Windows Constants + //#define ERROR_FILE_NOT_FOUND 2L + //#define ERROR_HANDLE_DISK_FULL 39L + //#define ERROR_NOT_SUPPORTED 50L + //#define ERROR_DISK_FULL 112L + const long ERROR_FILE_NOT_FOUND = 2L; + const long ERROR_HANDLE_DISK_FULL = 39L; + const long ERROR_NOT_SUPPORTED = 50L; + const long ERROR_DISK_FULL = 112L; + + private class SQLite3UpperToLower { + static int[] sqlite3UpperToLower = new int[] { #if SQLITE_ASCII 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, @@ -613,31 +513,27 @@ private class SQLite3UpperToLower 252,253,254,255 #endif }; - public int this[int index] - { - get - { - if ( index < sqlite3UpperToLower.Length ) - return sqlite3UpperToLower[index]; - else - return index; - } - } - - public int this[u32 index] - { - get - { - if ( index < sqlite3UpperToLower.Length ) - return sqlite3UpperToLower[index]; - else - return (int)index; - } - } -} + public int this[int index] { + get { + if (index < sqlite3UpperToLower.Length) + return sqlite3UpperToLower[index]; + else + return index; + } + } + + public int this[u32 index] { + get { + if (index < sqlite3UpperToLower.Length) + return sqlite3UpperToLower[index]; + else + return (int)index; + } + } + } -static SQLite3UpperToLower sqlite3UpperToLower = new SQLite3UpperToLower(); -static SQLite3UpperToLower UpperToLower = sqlite3UpperToLower; + static SQLite3UpperToLower sqlite3UpperToLower = new SQLite3UpperToLower(); + static SQLite3UpperToLower UpperToLower = sqlite3UpperToLower; - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/alter_c.cs b/Src/IronPython.SQLite/c#sqlite/alter_c.cs index d2147ab74..f1eb50e99 100644 --- a/Src/IronPython.SQLite/c#sqlite/alter_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/alter_c.cs @@ -1,278 +1,259 @@ using System; using System.Diagnostics; -using System.Text; - -namespace Community.CsharpSqlite -{ - using sqlite3_value = Sqlite3.Mem; - - public partial class Sqlite3 - { -/* -** 2005 February 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. -** -************************************************************************* -** This file contains C code routines that used to generate VDBE code -** that implements the ALTER TABLE command. -************************************************************************* -** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart -** C#-SQLite is an independent reimplementation of the SQLite software library -** -** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 -** -************************************************************************* -*/ -//#include "sqliteInt.h" - -/* -** The code in this file only exists if we are not omitting the -** ALTER TABLE logic from the build. -*/ -#if !SQLITE_OMIT_ALTERTABLE +namespace Community.CsharpSqlite { + using sqlite3_value = Sqlite3.Mem; + + public partial class Sqlite3 { + /* + ** 2005 February 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. + ** + ************************************************************************* + ** This file contains C code routines that used to generate VDBE code + ** that implements the ALTER TABLE command. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + + /* + ** The code in this file only exists if we are not omitting the + ** ALTER TABLE logic from the build. + */ +#if !SQLITE_OMIT_ALTERTABLE -/* -** This function is used by SQL generated to implement the -** ALTER TABLE command. The first argument is the text of a CREATE TABLE or -** CREATE INDEX command. The second is a table name. The table name in -** the CREATE TABLE or CREATE INDEX statement is replaced with the third -** argument and the result returned. Examples: -** -** sqlite_rename_table('CREATE TABLE abc(a, b, c)', 'def') -** . 'CREATE TABLE def(a, b, c)' -** -** sqlite_rename_table('CREATE INDEX i ON abc(a)', 'def') -** . 'CREATE INDEX i ON def(a, b, c)' -*/ -static void renameTableFunc( -sqlite3_context context, -int NotUsed, -sqlite3_value[] argv -) -{ - string bResult = sqlite3_value_text( argv[0] ); - string zSql = bResult == null ? "" : bResult; - string zTableName = sqlite3_value_text( argv[1] ); - - int token = 0; - Token tname = new Token(); - int zCsr = 0; - int zLoc = 0; - int len = 0; - string zRet; - - sqlite3 db = sqlite3_context_db_handle( context ); - - UNUSED_PARAMETER( NotUsed ); - - /* The principle used to locate the table name in the CREATE TABLE - ** statement is that the table name is the first non-space token that - ** is immediately followed by a TK_LP or TK_USING token. - */ - if ( zSql != "" ) - { - do - { - if ( zCsr == zSql.Length ) - { - /* Ran out of input before finding an opening bracket. Return NULL. */ - return; - } - - /* Store the token that zCsr points to in tname. */ - zLoc = zCsr; - tname.z = zSql.Substring( zCsr );//(char*)zCsr; - tname.n = len; - - /* Advance zCsr to the next token. Store that token type in 'token', - ** and its length in 'len' (to be used next iteration of this loop). - */ - do - { - zCsr += len; - len = ( zCsr == zSql.Length ) ? 1 : sqlite3GetToken( zSql, zCsr, ref token ); - } while ( token == TK_SPACE ); - Debug.Assert( len > 0 ); - } while ( token != TK_LP && token != TK_USING ); - - zRet = sqlite3MPrintf( db, "%.*s\"%w\"%s", zLoc, zSql.Substring( 0, zLoc ), - zTableName, zSql.Substring( zLoc + tname.n ) ); - - sqlite3_result_text( context, zRet, -1, SQLITE_DYNAMIC ); - } -} -/* -** This C function implements an SQL user function that is used by SQL code -** generated by the ALTER TABLE ... RENAME command to modify the definition -** of any foreign key constraints that use the table being renamed as the -** parent table. It is passed three arguments: -** -** 1) The complete text of the CREATE TABLE statement being modified, -** 2) The old name of the table being renamed, and -** 3) The new name of the table being renamed. -** -** It returns the new CREATE TABLE statement. For example: -** -** sqlite_rename_parent('CREATE TABLE t1(a REFERENCES t2)', 't2', 't3') -** -> 'CREATE TABLE t1(a REFERENCES t3)' -*/ + /* + ** This function is used by SQL generated to implement the + ** ALTER TABLE command. The first argument is the text of a CREATE TABLE or + ** CREATE INDEX command. The second is a table name. The table name in + ** the CREATE TABLE or CREATE INDEX statement is replaced with the third + ** argument and the result returned. Examples: + ** + ** sqlite_rename_table('CREATE TABLE abc(a, b, c)', 'def') + ** . 'CREATE TABLE def(a, b, c)' + ** + ** sqlite_rename_table('CREATE INDEX i ON abc(a)', 'def') + ** . 'CREATE INDEX i ON def(a, b, c)' + */ + static void renameTableFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] argv + ) { + string bResult = sqlite3_value_text(argv[0]); + string zSql = bResult == null ? "" : bResult; + string zTableName = sqlite3_value_text(argv[1]); + + int token = 0; + Token tname = new Token(); + int zCsr = 0; + int zLoc = 0; + int len = 0; + string zRet; + + sqlite3 db = sqlite3_context_db_handle(context); + + UNUSED_PARAMETER(NotUsed); + + /* The principle used to locate the table name in the CREATE TABLE + ** statement is that the table name is the first non-space token that + ** is immediately followed by a TK_LP or TK_USING token. + */ + if (zSql != "") { + do { + if (zCsr == zSql.Length) { + /* Ran out of input before finding an opening bracket. Return NULL. */ + return; + } + + /* Store the token that zCsr points to in tname. */ + zLoc = zCsr; + tname.z = zSql.Substring(zCsr);//(char*)zCsr; + tname.n = len; + + /* Advance zCsr to the next token. Store that token type in 'token', + ** and its length in 'len' (to be used next iteration of this loop). + */ + do { + zCsr += len; + len = (zCsr == zSql.Length) ? 1 : sqlite3GetToken(zSql, zCsr, ref token); + } while (token == TK_SPACE); + Debug.Assert(len > 0); + } while (token != TK_LP && token != TK_USING); + + zRet = sqlite3MPrintf(db, "%.*s\"%w\"%s", zLoc, zSql.Substring(0, zLoc), + zTableName, zSql.Substring(zLoc + tname.n)); + + sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC); + } + } + + /* + ** This C function implements an SQL user function that is used by SQL code + ** generated by the ALTER TABLE ... RENAME command to modify the definition + ** of any foreign key constraints that use the table being renamed as the + ** parent table. It is passed three arguments: + ** + ** 1) The complete text of the CREATE TABLE statement being modified, + ** 2) The old name of the table being renamed, and + ** 3) The new name of the table being renamed. + ** + ** It returns the new CREATE TABLE statement. For example: + ** + ** sqlite_rename_parent('CREATE TABLE t1(a REFERENCES t2)', 't2', 't3') + ** -> 'CREATE TABLE t1(a REFERENCES t3)' + */ #if !SQLITE_OMIT_FOREIGN_KEY -static void renameParentFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] argv -) -{ - sqlite3 db = sqlite3_context_db_handle( context ); - string zOutput = ""; - string zResult; - string zInput = sqlite3_value_text( argv[0] ); - string zOld = sqlite3_value_text( argv[1] ); - string zNew = sqlite3_value_text( argv[2] ); - - int zIdx; /* Pointer to token */ - int zLeft = 0; /* Pointer to remainder of String */ - int n = 0; /* Length of token z */ - int token = 0; /* Type of token */ - - UNUSED_PARAMETER( NotUsed ); - for ( zIdx = 0; zIdx < zInput.Length; zIdx += n )//z=zInput; *z; z=z+n) - { - n = sqlite3GetToken( zInput, zIdx, ref token ); - if ( token == TK_REFERENCES ) - { - string zParent; - do - { - zIdx += n; - n = sqlite3GetToken( zInput, zIdx, ref token ); - } while ( token == TK_SPACE ); - - zParent = zIdx + n < zInput.Length ? zInput.Substring( zIdx, n ) : "";//sqlite3DbStrNDup(db, zIdx, n); - if ( String.IsNullOrEmpty( zParent ) ) - break; - sqlite3Dequote( ref zParent ); - if ( zOld.Equals( zParent, StringComparison.OrdinalIgnoreCase) ) - { - string zOut = sqlite3MPrintf( db, "%s%.*s\"%w\"", - zOutput, zIdx - zLeft, zInput.Substring( zLeft ), zNew - ); - sqlite3DbFree( db, ref zOutput ); - zOutput = zOut; - zIdx += n;// zInput = &z[n]; - zLeft = zIdx; - } - sqlite3DbFree( db, ref zParent ); - } - } - - zResult = sqlite3MPrintf( db, "%s%s", zOutput, zInput.Substring( zLeft ) ); - sqlite3_result_text( context, zResult, -1, SQLITE_DYNAMIC ); - sqlite3DbFree( db, ref zOutput ); -} + static void renameParentFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] argv + ) { + sqlite3 db = sqlite3_context_db_handle(context); + string zOutput = ""; + string zResult; + string zInput = sqlite3_value_text(argv[0]); + string zOld = sqlite3_value_text(argv[1]); + string zNew = sqlite3_value_text(argv[2]); + + int zIdx; /* Pointer to token */ + int zLeft = 0; /* Pointer to remainder of String */ + int n = 0; /* Length of token z */ + int token = 0; /* Type of token */ + + UNUSED_PARAMETER(NotUsed); + for (zIdx = 0; zIdx < zInput.Length; zIdx += n)//z=zInput; *z; z=z+n) + { + n = sqlite3GetToken(zInput, zIdx, ref token); + if (token == TK_REFERENCES) { + string zParent; + do { + zIdx += n; + n = sqlite3GetToken(zInput, zIdx, ref token); + } while (token == TK_SPACE); + + zParent = zIdx + n < zInput.Length ? zInput.Substring(zIdx, n) : "";//sqlite3DbStrNDup(db, zIdx, n); + if (String.IsNullOrEmpty(zParent)) + break; + sqlite3Dequote(ref zParent); + if (zOld.Equals(zParent, StringComparison.OrdinalIgnoreCase)) { + string zOut = sqlite3MPrintf(db, "%s%.*s\"%w\"", + zOutput, zIdx - zLeft, zInput.Substring(zLeft), zNew + ); + sqlite3DbFree(db, ref zOutput); + zOutput = zOut; + zIdx += n;// zInput = &z[n]; + zLeft = zIdx; + } + sqlite3DbFree(db, ref zParent); + } + } + + zResult = sqlite3MPrintf(db, "%s%s", zOutput, zInput.Substring(zLeft)); + sqlite3_result_text(context, zResult, -1, SQLITE_DYNAMIC); + sqlite3DbFree(db, ref zOutput); + } #endif #if !SQLITE_OMIT_TRIGGER -/* This function is used by SQL generated to implement the -** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER -** statement. The second is a table name. The table name in the CREATE -** TRIGGER statement is replaced with the third argument and the result -** returned. This is analagous to renameTableFunc() above, except for CREATE -** TRIGGER, not CREATE INDEX and CREATE TABLE. -*/ -static void renameTriggerFunc( -sqlite3_context context, -int NotUsed, -sqlite3_value[] argv -) -{ - string zSql = sqlite3_value_text( argv[0] ); - string zTableName = sqlite3_value_text( argv[1] ); - - int token = 0; - Token tname = new Token(); - int dist = 3; - int zCsr = 0; - int zLoc = 0; - int len = 1; - string zRet; - - sqlite3 db = sqlite3_context_db_handle( context ); - - UNUSED_PARAMETER( NotUsed ); - - /* The principle used to locate the table name in the CREATE TRIGGER - ** statement is that the table name is the first token that is immediatedly - ** preceded by either TK_ON or TK_DOT and immediatedly followed by one - ** of TK_WHEN, TK_BEGIN or TK_FOR. - */ - if ( zSql != null ) - { - do - { - - if ( zCsr == zSql.Length ) - { - /* Ran out of input before finding the table name. Return NULL. */ - return; - } - - /* Store the token that zCsr points to in tname. */ - zLoc = zCsr; - tname.z = zSql.Substring( zCsr, len );//(char*)zCsr; - tname.n = len; - - /* Advance zCsr to the next token. Store that token type in 'token', - ** and its length in 'len' (to be used next iteration of this loop). - */ - do - { - zCsr += len; - len = ( zCsr == zSql.Length ) ? 1 : sqlite3GetToken( zSql, zCsr, ref token ); - } while ( token == TK_SPACE ); - Debug.Assert( len > 0 ); - - /* Variable 'dist' stores the number of tokens read since the most - ** recent TK_DOT or TK_ON. This means that when a WHEN, FOR or BEGIN - ** token is read and 'dist' equals 2, the condition stated above - ** to be met. - ** - ** Note that ON cannot be a database, table or column name, so - ** there is no need to worry about syntax like - ** "CREATE TRIGGER ... ON ON.ON BEGIN ..." etc. - */ - dist++; - if ( token == TK_DOT || token == TK_ON ) - { - dist = 0; - } - } while ( dist != 2 || ( token != TK_WHEN && token != TK_FOR && token != TK_BEGIN ) ); - - /* Variable tname now contains the token that is the old table-name - ** in the CREATE TRIGGER statement. - */ - zRet = sqlite3MPrintf( db, "%.*s\"%w\"%s", zLoc, zSql.Substring( 0, zLoc ), - zTableName, zSql.Substring( zLoc + tname.n ) ); - sqlite3_result_text( context, zRet, -1, SQLITE_DYNAMIC ); - } -} + /* This function is used by SQL generated to implement the + ** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER + ** statement. The second is a table name. The table name in the CREATE + ** TRIGGER statement is replaced with the third argument and the result + ** returned. This is analagous to renameTableFunc() above, except for CREATE + ** TRIGGER, not CREATE INDEX and CREATE TABLE. + */ + static void renameTriggerFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] argv + ) { + string zSql = sqlite3_value_text(argv[0]); + string zTableName = sqlite3_value_text(argv[1]); + + int token = 0; + Token tname = new Token(); + int dist = 3; + int zCsr = 0; + int zLoc = 0; + int len = 1; + string zRet; + + sqlite3 db = sqlite3_context_db_handle(context); + + UNUSED_PARAMETER(NotUsed); + + /* The principle used to locate the table name in the CREATE TRIGGER + ** statement is that the table name is the first token that is immediatedly + ** preceded by either TK_ON or TK_DOT and immediatedly followed by one + ** of TK_WHEN, TK_BEGIN or TK_FOR. + */ + if (zSql != null) { + do { + + if (zCsr == zSql.Length) { + /* Ran out of input before finding the table name. Return NULL. */ + return; + } + + /* Store the token that zCsr points to in tname. */ + zLoc = zCsr; + tname.z = zSql.Substring(zCsr, len);//(char*)zCsr; + tname.n = len; + + /* Advance zCsr to the next token. Store that token type in 'token', + ** and its length in 'len' (to be used next iteration of this loop). + */ + do { + zCsr += len; + len = (zCsr == zSql.Length) ? 1 : sqlite3GetToken(zSql, zCsr, ref token); + } while (token == TK_SPACE); + Debug.Assert(len > 0); + + /* Variable 'dist' stores the number of tokens read since the most + ** recent TK_DOT or TK_ON. This means that when a WHEN, FOR or BEGIN + ** token is read and 'dist' equals 2, the condition stated above + ** to be met. + ** + ** Note that ON cannot be a database, table or column name, so + ** there is no need to worry about syntax like + ** "CREATE TRIGGER ... ON ON.ON BEGIN ..." etc. + */ + dist++; + if (token == TK_DOT || token == TK_ON) { + dist = 0; + } + } while (dist != 2 || (token != TK_WHEN && token != TK_FOR && token != TK_BEGIN)); + + /* Variable tname now contains the token that is the old table-name + ** in the CREATE TRIGGER statement. + */ + zRet = sqlite3MPrintf(db, "%.*s\"%w\"%s", zLoc, zSql.Substring(0, zLoc), + zTableName, zSql.Substring(zLoc + tname.n)); + sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC); + } + } #endif // * !SQLITE_OMIT_TRIGGER */ -/* -** Register built-in functions used to help implement ALTER TABLE -*/ -static FuncDef[] aAlterTableFuncs; -static void sqlite3AlterFunctions() -{ - aAlterTableFuncs = new FuncDef[] { + /* + ** Register built-in functions used to help implement ALTER TABLE + */ + static FuncDef[] aAlterTableFuncs; + static void sqlite3AlterFunctions() { + aAlterTableFuncs = new FuncDef[] { FUNCTION("sqlite_rename_table", 2, 0, 0, renameTableFunc), #if !SQLITE_OMIT_TRIGGER FUNCTION("sqlite_rename_trigger", 2, 0, 0, renameTriggerFunc), @@ -281,249 +262,227 @@ static void sqlite3AlterFunctions() FUNCTION("sqlite_rename_parent", 3, 0, 0, renameParentFunc), #endif }; - int i; + int i; #if SQLITE_OMIT_WSD FuncDefHash pHash = GLOBAL(FuncDefHash, sqlite3GlobalFunctions); FuncDef[] aFunc = GLOBAL(FuncDef, aAlterTableFuncs); #else - FuncDefHash pHash = sqlite3GlobalFunctions; - FuncDef[] aFunc = aAlterTableFuncs; + FuncDefHash pHash = sqlite3GlobalFunctions; + FuncDef[] aFunc = aAlterTableFuncs; #endif - for ( i = 0; i < ArraySize( aAlterTableFuncs ); i++ ) - { - sqlite3FuncDefInsert( pHash, aFunc[i] ); - } -} - -/* -** This function is used to create the text of expressions of the form: -** -** name= OR name= OR ... -** -** If argument zWhere is NULL, then a pointer string containing the text -** "name=" is returned, where is the quoted version -** of the string passed as argument zConstant. The returned buffer is -** allocated using sqlite3DbMalloc(). It is the responsibility of the -** caller to ensure that it is eventually freed. -** -** If argument zWhere is not NULL, then the string returned is -** " OR name=", where is the contents of zWhere. -** In this case zWhere is passed to sqlite3DbFree() before returning. -** -*/ -static string whereOrName( sqlite3 db, string zWhere, string zConstant ) -{ - string zNew; - if ( String.IsNullOrEmpty( zWhere ) ) - { - zNew = sqlite3MPrintf( db, "name=%Q", zConstant ); - } - else - { - zNew = sqlite3MPrintf( db, "%s OR name=%Q", zWhere, zConstant ); - sqlite3DbFree( db, ref zWhere ); - } - return zNew; -} + for (i = 0; i < ArraySize(aAlterTableFuncs); i++) { + sqlite3FuncDefInsert(pHash, aFunc[i]); + } + } + + /* + ** This function is used to create the text of expressions of the form: + ** + ** name= OR name= OR ... + ** + ** If argument zWhere is NULL, then a pointer string containing the text + ** "name=" is returned, where is the quoted version + ** of the string passed as argument zConstant. The returned buffer is + ** allocated using sqlite3DbMalloc(). It is the responsibility of the + ** caller to ensure that it is eventually freed. + ** + ** If argument zWhere is not NULL, then the string returned is + ** " OR name=", where is the contents of zWhere. + ** In this case zWhere is passed to sqlite3DbFree() before returning. + ** + */ + static string whereOrName(sqlite3 db, string zWhere, string zConstant) { + string zNew; + if (String.IsNullOrEmpty(zWhere)) { + zNew = sqlite3MPrintf(db, "name=%Q", zConstant); + } else { + zNew = sqlite3MPrintf(db, "%s OR name=%Q", zWhere, zConstant); + sqlite3DbFree(db, ref zWhere); + } + return zNew; + } #if !(SQLITE_OMIT_FOREIGN_KEY) && !(SQLITE_OMIT_TRIGGER) -/* -** Generate the text of a WHERE expression which can be used to select all -** tables that have foreign key constraints that refer to table pTab (i.e. -** constraints for which pTab is the parent table) from the sqlite_master -** table. -*/ -static string whereForeignKeys( Parse pParse, Table pTab ) -{ - FKey p; - string zWhere = ""; - for ( p = sqlite3FkReferences( pTab ); p != null; p = p.pNextTo ) - { - zWhere = whereOrName( pParse.db, zWhere, p.pFrom.zName ); - } - return zWhere; -} + /* + ** Generate the text of a WHERE expression which can be used to select all + ** tables that have foreign key constraints that refer to table pTab (i.e. + ** constraints for which pTab is the parent table) from the sqlite_master + ** table. + */ + static string whereForeignKeys(Parse pParse, Table pTab) { + FKey p; + string zWhere = ""; + for (p = sqlite3FkReferences(pTab); p != null; p = p.pNextTo) { + zWhere = whereOrName(pParse.db, zWhere, p.pFrom.zName); + } + return zWhere; + } #endif -/* -** Generate the text of a WHERE expression which can be used to select all -** temporary triggers on table pTab from the sqlite_temp_master table. If -** table pTab has no temporary triggers, or is itself stored in the -** temporary database, NULL is returned. -*/ -static string whereTempTriggers( Parse pParse, Table pTab ) -{ - Trigger pTrig; - string zWhere = ""; - Schema pTempSchema = pParse.db.aDb[1].pSchema; /* Temp db schema */ - - /* If the table is not located in the temp.db (in which case NULL is - ** returned, loop through the tables list of triggers. For each trigger - ** that is not part of the temp.db schema, add a clause to the WHERE - ** expression being built up in zWhere. - */ - if ( pTab.pSchema != pTempSchema ) - { - sqlite3 db = pParse.db; - for ( pTrig = sqlite3TriggerList( pParse, pTab ); pTrig != null; pTrig = pTrig.pNext ) - { - if ( pTrig.pSchema == pTempSchema ) - { - zWhere = whereOrName( db, zWhere, pTrig.zName ); - } - } - } - if ( !String.IsNullOrEmpty( zWhere ) ) - { - zWhere = sqlite3MPrintf( pParse.db, "type='trigger' AND (%s)", zWhere ); - //sqlite3DbFree( pParse.db, ref zWhere ); - //zWhere = zNew; - } - return zWhere; -} - -/* -** Generate code to drop and reload the internal representation of table -** pTab from the database, including triggers and temporary triggers. -** Argument zName is the name of the table in the database schema at -** the time the generated code is executed. This can be different from -** pTab.zName if this function is being called to code part of an -** "ALTER TABLE RENAME TO" statement. -*/ -static void reloadTableSchema( Parse pParse, Table pTab, string zName ) -{ - Vdbe v; - string zWhere; - int iDb; /* Index of database containing pTab */ + /* + ** Generate the text of a WHERE expression which can be used to select all + ** temporary triggers on table pTab from the sqlite_temp_master table. If + ** table pTab has no temporary triggers, or is itself stored in the + ** temporary database, NULL is returned. + */ + static string whereTempTriggers(Parse pParse, Table pTab) { + Trigger pTrig; + string zWhere = ""; + Schema pTempSchema = pParse.db.aDb[1].pSchema; /* Temp db schema */ + + /* If the table is not located in the temp.db (in which case NULL is + ** returned, loop through the tables list of triggers. For each trigger + ** that is not part of the temp.db schema, add a clause to the WHERE + ** expression being built up in zWhere. + */ + if (pTab.pSchema != pTempSchema) { + sqlite3 db = pParse.db; + for (pTrig = sqlite3TriggerList(pParse, pTab); pTrig != null; pTrig = pTrig.pNext) { + if (pTrig.pSchema == pTempSchema) { + zWhere = whereOrName(db, zWhere, pTrig.zName); + } + } + } + if (!String.IsNullOrEmpty(zWhere)) { + zWhere = sqlite3MPrintf(pParse.db, "type='trigger' AND (%s)", zWhere); + //sqlite3DbFree( pParse.db, ref zWhere ); + //zWhere = zNew; + } + return zWhere; + } + + /* + ** Generate code to drop and reload the internal representation of table + ** pTab from the database, including triggers and temporary triggers. + ** Argument zName is the name of the table in the database schema at + ** the time the generated code is executed. This can be different from + ** pTab.zName if this function is being called to code part of an + ** "ALTER TABLE RENAME TO" statement. + */ + static void reloadTableSchema(Parse pParse, Table pTab, string zName) { + Vdbe v; + string zWhere; + int iDb; /* Index of database containing pTab */ #if !SQLITE_OMIT_TRIGGER - Trigger pTrig; + Trigger pTrig; #endif - v = sqlite3GetVdbe( pParse ); - if ( NEVER( v == null ) ) - return; - Debug.Assert( sqlite3BtreeHoldsAllMutexes( pParse.db ) ); - iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema ); - Debug.Assert( iDb >= 0 ); + v = sqlite3GetVdbe(pParse); + if (NEVER(v == null)) + return; + Debug.Assert(sqlite3BtreeHoldsAllMutexes(pParse.db)); + iDb = sqlite3SchemaToIndex(pParse.db, pTab.pSchema); + Debug.Assert(iDb >= 0); #if !SQLITE_OMIT_TRIGGER - /* Drop any table triggers from the internal schema. */ - for ( pTrig = sqlite3TriggerList( pParse, pTab ); pTrig != null; pTrig = pTrig.pNext ) - { - int iTrigDb = sqlite3SchemaToIndex( pParse.db, pTrig.pSchema ); - Debug.Assert( iTrigDb == iDb || iTrigDb == 1 ); - sqlite3VdbeAddOp4( v, OP_DropTrigger, iTrigDb, 0, 0, pTrig.zName, 0 ); - } + /* Drop any table triggers from the internal schema. */ + for (pTrig = sqlite3TriggerList(pParse, pTab); pTrig != null; pTrig = pTrig.pNext) { + int iTrigDb = sqlite3SchemaToIndex(pParse.db, pTrig.pSchema); + Debug.Assert(iTrigDb == iDb || iTrigDb == 1); + sqlite3VdbeAddOp4(v, OP_DropTrigger, iTrigDb, 0, 0, pTrig.zName, 0); + } #endif - /* Drop the table and index from the internal schema. */ - sqlite3VdbeAddOp4( v, OP_DropTable, iDb, 0, 0, pTab.zName, 0 ); + /* Drop the table and index from the internal schema. */ + sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab.zName, 0); - /* Reload the table, index and permanent trigger schemas. */ - zWhere = sqlite3MPrintf( pParse.db, "tbl_name=%Q", zName ); - if ( zWhere == null ) - return; - sqlite3VdbeAddParseSchemaOp( v, iDb, zWhere ); + /* Reload the table, index and permanent trigger schemas. */ + zWhere = sqlite3MPrintf(pParse.db, "tbl_name=%Q", zName); + if (zWhere == null) + return; + sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere); #if !SQLITE_OMIT_TRIGGER - /* Now, if the table is not stored in the temp database, reload any temp -** triggers. Don't use IN(...) in case SQLITE_OMIT_SUBQUERY is defined. -*/ - if ( ( zWhere = whereTempTriggers( pParse, pTab ) ) != "" ) - { - sqlite3VdbeAddParseSchemaOp( v, 1, zWhere ); - } + /* Now, if the table is not stored in the temp database, reload any temp + ** triggers. Don't use IN(...) in case SQLITE_OMIT_SUBQUERY is defined. + */ + if ((zWhere = whereTempTriggers(pParse, pTab)) != "") { + sqlite3VdbeAddParseSchemaOp(v, 1, zWhere); + } #endif -} - -/* -** Parameter zName is the name of a table that is about to be altered -** (either with ALTER TABLE ... RENAME TO or ALTER TABLE ... ADD COLUMN). -** If the table is a system table, this function leaves an error message -** in pParse->zErr (system tables may not be altered) and returns non-zero. -** -** Or, if zName is not a system table, zero is returned. -*/ -static int isSystemTable( Parse pParse, string zName ) -{ - if (zName.StartsWith("sqlite_", System.StringComparison.OrdinalIgnoreCase)) - { - sqlite3ErrorMsg( pParse, "table %s may not be altered", zName ); - return 1; - } - return 0; -} - -/* -** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy" -** command. -*/ -static void sqlite3AlterRenameTable( -Parse pParse, /* Parser context. */ -SrcList pSrc, /* The table to rename. */ -Token pName /* The new table name. */ -) -{ - int iDb; /* Database that contains the table */ - string zDb; /* Name of database iDb */ - Table pTab; /* Table being renamed */ - string zName = null; /* NULL-terminated version of pName */ - sqlite3 db = pParse.db; /* Database connection */ - int nTabName; /* Number of UTF-8 characters in zTabName */ - string zTabName; /* Original name of the table */ - Vdbe v; + } + + /* + ** Parameter zName is the name of a table that is about to be altered + ** (either with ALTER TABLE ... RENAME TO or ALTER TABLE ... ADD COLUMN). + ** If the table is a system table, this function leaves an error message + ** in pParse->zErr (system tables may not be altered) and returns non-zero. + ** + ** Or, if zName is not a system table, zero is returned. + */ + static int isSystemTable(Parse pParse, string zName) { + if (zName.StartsWith("sqlite_", System.StringComparison.OrdinalIgnoreCase)) { + sqlite3ErrorMsg(pParse, "table %s may not be altered", zName); + return 1; + } + return 0; + } + + /* + ** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy" + ** command. + */ + static void sqlite3AlterRenameTable( + Parse pParse, /* Parser context. */ + SrcList pSrc, /* The table to rename. */ + Token pName /* The new table name. */ + ) { + int iDb; /* Database that contains the table */ + string zDb; /* Name of database iDb */ + Table pTab; /* Table being renamed */ + string zName = null; /* NULL-terminated version of pName */ + sqlite3 db = pParse.db; /* Database connection */ + int nTabName; /* Number of UTF-8 characters in zTabName */ + string zTabName; /* Original name of the table */ + Vdbe v; #if !SQLITE_OMIT_TRIGGER - string zWhere = ""; /* Where clause to locate temp triggers */ + string zWhere = ""; /* Where clause to locate temp triggers */ #endif - VTable pVTab = null; /* Non-zero if this is a v-tab with an xRename() */ - int savedDbFlags; /* Saved value of db->flags */ - - savedDbFlags = db.flags; - - //if ( NEVER( db.mallocFailed != 0 ) ) goto exit_rename_table; - Debug.Assert( pSrc.nSrc == 1 ); - Debug.Assert( sqlite3BtreeHoldsAllMutexes( pParse.db ) ); - pTab = sqlite3LocateTable( pParse, 0, pSrc.a[0].zName, pSrc.a[0].zDatabase ); - if ( pTab == null ) - goto exit_rename_table; - iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema ); - zDb = db.aDb[iDb].zName; - db.flags |= SQLITE_PreferBuiltin; - - /* Get a NULL terminated version of the new table name. */ - zName = sqlite3NameFromToken( db, pName ); - if ( zName == null ) - goto exit_rename_table; - - /* Check that a table or index named 'zName' does not already exist - ** in database iDb. If so, this is an error. - */ - if ( sqlite3FindTable( db, zName, zDb ) != null || sqlite3FindIndex( db, zName, zDb ) != null ) - { - sqlite3ErrorMsg( pParse, - "there is already another table or index with this name: %s", zName ); - goto exit_rename_table; - } - - /* Make sure it is not a system table being altered, or a reserved name - ** that the table is being renamed to. - */ - if ( SQLITE_OK!=isSystemTable(pParse, pTab.zName) ) - { - goto exit_rename_table; - } - if ( SQLITE_OK != sqlite3CheckObjectName( pParse, zName ) ) - { - goto exit_rename_table; - } + VTable pVTab = null; /* Non-zero if this is a v-tab with an xRename() */ + int savedDbFlags; /* Saved value of db->flags */ + + savedDbFlags = db.flags; + + //if ( NEVER( db.mallocFailed != 0 ) ) goto exit_rename_table; + Debug.Assert(pSrc.nSrc == 1); + Debug.Assert(sqlite3BtreeHoldsAllMutexes(pParse.db)); + pTab = sqlite3LocateTable(pParse, 0, pSrc.a[0].zName, pSrc.a[0].zDatabase); + if (pTab == null) + goto exit_rename_table; + iDb = sqlite3SchemaToIndex(pParse.db, pTab.pSchema); + zDb = db.aDb[iDb].zName; + db.flags |= SQLITE_PreferBuiltin; + + /* Get a NULL terminated version of the new table name. */ + zName = sqlite3NameFromToken(db, pName); + if (zName == null) + goto exit_rename_table; + + /* Check that a table or index named 'zName' does not already exist + ** in database iDb. If so, this is an error. + */ + if (sqlite3FindTable(db, zName, zDb) != null || sqlite3FindIndex(db, zName, zDb) != null) { + sqlite3ErrorMsg(pParse, + "there is already another table or index with this name: %s", zName); + goto exit_rename_table; + } + + /* Make sure it is not a system table being altered, or a reserved name + ** that the table is being renamed to. + */ + if (SQLITE_OK != isSystemTable(pParse, pTab.zName)) { + goto exit_rename_table; + } + if (SQLITE_OK != sqlite3CheckObjectName(pParse, zName)) { + goto exit_rename_table; + } #if !SQLITE_OMIT_VIEW - if ( pTab.pSelect != null ) - { - sqlite3ErrorMsg( pParse, "view %s may not be altered", pTab.zName ); - goto exit_rename_table; - } + if (pTab.pSelect != null) { + sqlite3ErrorMsg(pParse, "view %s may not be altered", pTab.zName); + goto exit_rename_table; + } #endif #if !SQLITE_OMIT_AUTHORIZATION @@ -533,207 +492,192 @@ static void sqlite3AlterRenameTable( } #endif - if ( sqlite3ViewGetColumnNames( pParse, pTab ) != 0 ) - { - goto exit_rename_table; - } + if (sqlite3ViewGetColumnNames(pParse, pTab) != 0) { + goto exit_rename_table; + } #if !SQLITE_OMIT_VIRTUALTABLE - if ( IsVirtual( pTab ) ) - { - pVTab = sqlite3GetVTable( db, pTab ); - if ( pVTab.pVtab.pModule.xRename == null ) - { - pVTab = null; - } - } + if (IsVirtual(pTab)) { + pVTab = sqlite3GetVTable(db, pTab); + if (pVTab.pVtab.pModule.xRename == null) { + pVTab = null; + } + } #endif - /* Begin a transaction and code the VerifyCookie for database iDb. -** Then modify the schema cookie (since the ALTER TABLE modifies the -** schema). Open a statement transaction if the table is a virtual -** table. -*/ - v = sqlite3GetVdbe( pParse ); - if ( v == null ) - { - goto exit_rename_table; - } - sqlite3BeginWriteOperation( pParse, pVTab != null ? 1 : 0, iDb ); - sqlite3ChangeCookie( pParse, iDb ); - - /* If this is a virtual table, invoke the xRename() function if - ** one is defined. The xRename() callback will modify the names - ** of any resources used by the v-table implementation (including other - ** SQLite tables) that are identified by the name of the virtual table. - */ -#if !SQLITE_OMIT_VIRTUALTABLE -if ( pVTab !=null) -{ -int i = ++pParse.nMem; -sqlite3VdbeAddOp4( v, OP_String8, 0, i, 0, zName, 0 ); -sqlite3VdbeAddOp4( v, OP_VRename, i, 0, 0, pVTab, P4_VTAB ); -sqlite3MayAbort(pParse); -} + /* Begin a transaction and code the VerifyCookie for database iDb. + ** Then modify the schema cookie (since the ALTER TABLE modifies the + ** schema). Open a statement transaction if the table is a virtual + ** table. + */ + v = sqlite3GetVdbe(pParse); + if (v == null) { + goto exit_rename_table; + } + sqlite3BeginWriteOperation(pParse, pVTab != null ? 1 : 0, iDb); + sqlite3ChangeCookie(pParse, iDb); + + /* If this is a virtual table, invoke the xRename() function if + ** one is defined. The xRename() callback will modify the names + ** of any resources used by the v-table implementation (including other + ** SQLite tables) that are identified by the name of the virtual table. + */ +#if !SQLITE_OMIT_VIRTUALTABLE + if (pVTab != null) { + int i = ++pParse.nMem; + sqlite3VdbeAddOp4(v, OP_String8, 0, i, 0, zName, 0); + sqlite3VdbeAddOp4(v, OP_VRename, i, 0, 0, pVTab, P4_VTAB); + sqlite3MayAbort(pParse); + } #endif - /* figure out how many UTF-8 characters are in zName */ - zTabName = pTab.zName; - nTabName = sqlite3Utf8CharLen( zTabName, -1 ); + /* figure out how many UTF-8 characters are in zName */ + zTabName = pTab.zName; + nTabName = sqlite3Utf8CharLen(zTabName, -1); #if !(SQLITE_OMIT_FOREIGN_KEY) && !(SQLITE_OMIT_TRIGGER) - if ( ( db.flags & SQLITE_ForeignKeys ) != 0 ) - { - /* If foreign-key support is enabled, rewrite the CREATE TABLE - ** statements corresponding to all child tables of foreign key constraints - ** for which the renamed table is the parent table. */ - if ( ( zWhere = whereForeignKeys( pParse, pTab ) ) != null ) - { - sqlite3NestedParse( pParse, - "UPDATE \"%w\".%s SET " + - "sql = sqlite_rename_parent(sql, %Q, %Q) " + - "WHERE %s;", zDb, SCHEMA_TABLE( iDb ), zTabName, zName, zWhere ); - sqlite3DbFree( db, ref zWhere ); - } - } + if ((db.flags & SQLITE_ForeignKeys) != 0) { + /* If foreign-key support is enabled, rewrite the CREATE TABLE + ** statements corresponding to all child tables of foreign key constraints + ** for which the renamed table is the parent table. */ + if ((zWhere = whereForeignKeys(pParse, pTab)) != null) { + sqlite3NestedParse(pParse, + "UPDATE \"%w\".%s SET " + + "sql = sqlite_rename_parent(sql, %Q, %Q) " + + "WHERE %s;", zDb, SCHEMA_TABLE(iDb), zTabName, zName, zWhere); + sqlite3DbFree(db, ref zWhere); + } + } #endif - /* Modify the sqlite_master table to use the new table name. */ - sqlite3NestedParse( pParse, - "UPDATE %Q.%s SET " + + /* Modify the sqlite_master table to use the new table name. */ + sqlite3NestedParse(pParse, + "UPDATE %Q.%s SET " + #if SQLITE_OMIT_TRIGGER "sql = sqlite_rename_table(sql, %Q), " + #else - "sql = CASE " + - "WHEN type = 'trigger' THEN sqlite_rename_trigger(sql, %Q)" + - "ELSE sqlite_rename_table(sql, %Q) END, " + + "sql = CASE " + + "WHEN type = 'trigger' THEN sqlite_rename_trigger(sql, %Q)" + + "ELSE sqlite_rename_table(sql, %Q) END, " + #endif - "tbl_name = %Q, " + - "name = CASE " + - "WHEN type='table' THEN %Q " + - "WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN " + - "'sqlite_autoindex_' || %Q || substr(name,%d+18) " + - "ELSE name END " + - "WHERE tbl_name=%Q AND " + - "(type='table' OR type='index' OR type='trigger');", - zDb, SCHEMA_TABLE( iDb ), zName, zName, zName, + "tbl_name = %Q, " + + "name = CASE " + + "WHEN type='table' THEN %Q " + + "WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN " + + "'sqlite_autoindex_' || %Q || substr(name,%d+18) " + + "ELSE name END " + + "WHERE tbl_name=%Q AND " + + "(type='table' OR type='index' OR type='trigger');", + zDb, SCHEMA_TABLE(iDb), zName, zName, zName, #if !SQLITE_OMIT_TRIGGER - zName, + zName, #endif - zName, nTabName, zTabName - ); + zName, nTabName, zTabName + ); #if !SQLITE_OMIT_AUTOINCREMENT - /* If the sqlite_sequence table exists in this database, then update -** it with the new table name. -*/ - if ( sqlite3FindTable( db, "sqlite_sequence", zDb ) != null ) - { - sqlite3NestedParse( pParse, - "UPDATE \"%w\".sqlite_sequence set name = %Q WHERE name = %Q", - zDb, zName, pTab.zName - ); - } + /* If the sqlite_sequence table exists in this database, then update + ** it with the new table name. + */ + if (sqlite3FindTable(db, "sqlite_sequence", zDb) != null) { + sqlite3NestedParse(pParse, + "UPDATE \"%w\".sqlite_sequence set name = %Q WHERE name = %Q", + zDb, zName, pTab.zName + ); + } #endif #if !SQLITE_OMIT_TRIGGER - /* If there are TEMP triggers on this table, modify the sqlite_temp_master -** table. Don't do this if the table being ALTERed is itself located in -** the temp database. -*/ - if ( ( zWhere = whereTempTriggers( pParse, pTab ) ) != "" ) - { - sqlite3NestedParse( pParse, - "UPDATE sqlite_temp_master SET " + - "sql = sqlite_rename_trigger(sql, %Q), " + - "tbl_name = %Q " + - "WHERE %s;", zName, zName, zWhere ); - sqlite3DbFree( db, ref zWhere ); - } + /* If there are TEMP triggers on this table, modify the sqlite_temp_master + ** table. Don't do this if the table being ALTERed is itself located in + ** the temp database. + */ + if ((zWhere = whereTempTriggers(pParse, pTab)) != "") { + sqlite3NestedParse(pParse, + "UPDATE sqlite_temp_master SET " + + "sql = sqlite_rename_trigger(sql, %Q), " + + "tbl_name = %Q " + + "WHERE %s;", zName, zName, zWhere); + sqlite3DbFree(db, ref zWhere); + } #endif #if !(SQLITE_OMIT_FOREIGN_KEY) && !(SQLITE_OMIT_TRIGGER) - if ( ( db.flags & SQLITE_ForeignKeys ) != 0 ) - { - FKey p; - for ( p = sqlite3FkReferences( pTab ); p != null; p = p.pNextTo ) - { - Table pFrom = p.pFrom; - if ( pFrom != pTab ) - { - reloadTableSchema( pParse, p.pFrom, pFrom.zName ); - } - } - } + if ((db.flags & SQLITE_ForeignKeys) != 0) { + FKey p; + for (p = sqlite3FkReferences(pTab); p != null; p = p.pNextTo) { + Table pFrom = p.pFrom; + if (pFrom != pTab) { + reloadTableSchema(pParse, p.pFrom, pFrom.zName); + } + } + } #endif - /* Drop and reload the internal table schema. */ - reloadTableSchema( pParse, pTab, zName ); - -exit_rename_table: - sqlite3SrcListDelete( db, ref pSrc ); - sqlite3DbFree( db, ref zName ); - db.flags = savedDbFlags; -} - -/* -** Generate code to make sure the file format number is at least minFormat. -** The generated code will increase the file format number if necessary. -*/ -static void sqlite3MinimumFileFormat( Parse pParse, int iDb, int minFormat ) -{ - Vdbe v; - v = sqlite3GetVdbe( pParse ); - /* The VDBE should have been allocated before this routine is called. - ** If that allocation failed, we would have quit before reaching this - ** point */ - if ( ALWAYS( v ) ) - { - int r1 = sqlite3GetTempReg( pParse ); - int r2 = sqlite3GetTempReg( pParse ); - int j1; - sqlite3VdbeAddOp3( v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT ); - sqlite3VdbeUsesBtree( v, iDb ); - sqlite3VdbeAddOp2( v, OP_Integer, minFormat, r2 ); - j1 = sqlite3VdbeAddOp3( v, OP_Ge, r2, 0, r1 ); - sqlite3VdbeAddOp3( v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, r2 ); - sqlite3VdbeJumpHere( v, j1 ); - sqlite3ReleaseTempReg( pParse, r1 ); - sqlite3ReleaseTempReg( pParse, r2 ); - } -} - -/* -** This function is called after an "ALTER TABLE ... ADD" statement -** has been parsed. Argument pColDef contains the text of the new -** column definition. -** -** The Table structure pParse.pNewTable was extended to include -** the new column during parsing. -*/ -static void sqlite3AlterFinishAddColumn( Parse pParse, Token pColDef ) -{ - Table pNew; /* Copy of pParse.pNewTable */ - Table pTab; /* Table being altered */ - int iDb; /* Database number */ - string zDb; /* Database name */ - string zTab; /* Table name */ - string zCol; /* Null-terminated column definition */ - Column pCol; /* The new column */ - Expr pDflt; /* Default value for the new column */ - sqlite3 db; /* The database connection; */ - - db = pParse.db; - if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) - return; - pNew = pParse.pNewTable; - Debug.Assert( pNew != null ); - Debug.Assert( sqlite3BtreeHoldsAllMutexes( db ) ); - iDb = sqlite3SchemaToIndex( db, pNew.pSchema ); - zDb = db.aDb[iDb].zName; - zTab = pNew.zName.Substring( 16 );// zTab = &pNew->zName[16]; /* Skip the "sqlite_altertab_" prefix on the name */ - pCol = pNew.aCol[pNew.nCol - 1]; - pDflt = pCol.pDflt; - pTab = sqlite3FindTable( db, zTab, zDb ); - Debug.Assert( pTab != null ); + /* Drop and reload the internal table schema. */ + reloadTableSchema(pParse, pTab, zName); + + exit_rename_table: + sqlite3SrcListDelete(db, ref pSrc); + sqlite3DbFree(db, ref zName); + db.flags = savedDbFlags; + } + + /* + ** Generate code to make sure the file format number is at least minFormat. + ** The generated code will increase the file format number if necessary. + */ + static void sqlite3MinimumFileFormat(Parse pParse, int iDb, int minFormat) { + Vdbe v; + v = sqlite3GetVdbe(pParse); + /* The VDBE should have been allocated before this routine is called. + ** If that allocation failed, we would have quit before reaching this + ** point */ + if (ALWAYS(v)) { + int r1 = sqlite3GetTempReg(pParse); + int r2 = sqlite3GetTempReg(pParse); + int j1; + sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT); + sqlite3VdbeUsesBtree(v, iDb); + sqlite3VdbeAddOp2(v, OP_Integer, minFormat, r2); + j1 = sqlite3VdbeAddOp3(v, OP_Ge, r2, 0, r1); + sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, r2); + sqlite3VdbeJumpHere(v, j1); + sqlite3ReleaseTempReg(pParse, r1); + sqlite3ReleaseTempReg(pParse, r2); + } + } + + /* + ** This function is called after an "ALTER TABLE ... ADD" statement + ** has been parsed. Argument pColDef contains the text of the new + ** column definition. + ** + ** The Table structure pParse.pNewTable was extended to include + ** the new column during parsing. + */ + static void sqlite3AlterFinishAddColumn(Parse pParse, Token pColDef) { + Table pNew; /* Copy of pParse.pNewTable */ + Table pTab; /* Table being altered */ + int iDb; /* Database number */ + string zDb; /* Database name */ + string zTab; /* Table name */ + string zCol; /* Null-terminated column definition */ + Column pCol; /* The new column */ + Expr pDflt; /* Default value for the new column */ + sqlite3 db; /* The database connection; */ + + db = pParse.db; + if (pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) + return; + pNew = pParse.pNewTable; + Debug.Assert(pNew != null); + Debug.Assert(sqlite3BtreeHoldsAllMutexes(db)); + iDb = sqlite3SchemaToIndex(db, pNew.pSchema); + zDb = db.aDb[iDb].zName; + zTab = pNew.zName.Substring(16);// zTab = &pNew->zName[16]; /* Skip the "sqlite_altertab_" prefix on the name */ + pCol = pNew.aCol[pNew.nCol - 1]; + pDflt = pCol.pDflt; + pTab = sqlite3FindTable(db, zTab, zDb); + Debug.Assert(pTab != null); #if !SQLITE_OMIT_AUTHORIZATION /* Invoke the authorization callback. */ @@ -742,194 +686,179 @@ static void sqlite3AlterFinishAddColumn( Parse pParse, Token pColDef ) } #endif - /* If the default value for the new column was specified with a -** literal NULL, then set pDflt to 0. This simplifies checking -** for an SQL NULL default below. -*/ - if ( pDflt != null && pDflt.op == TK_NULL ) - { - pDflt = null; - } - - /* Check that the new column is not specified as PRIMARY KEY or UNIQUE. - ** If there is a NOT NULL constraint, then the default value for the - ** column must not be NULL. - */ - if ( pCol.isPrimKey != 0 ) - { - sqlite3ErrorMsg( pParse, "Cannot add a PRIMARY KEY column" ); - return; - } - if ( pNew.pIndex != null ) - { - sqlite3ErrorMsg( pParse, "Cannot add a UNIQUE column" ); - return; - } - if ( ( db.flags & SQLITE_ForeignKeys ) != 0 && pNew.pFKey != null && pDflt != null ) - { - sqlite3ErrorMsg( pParse, - "Cannot add a REFERENCES column with non-NULL default value" ); - return; - } - if ( pCol.notNull != 0 && pDflt == null ) - { - sqlite3ErrorMsg( pParse, - "Cannot add a NOT NULL column with default value NULL" ); - return; - } - - /* Ensure the default expression is something that sqlite3ValueFromExpr() - ** can handle (i.e. not CURRENT_TIME etc.) - */ - if ( pDflt != null ) - { - sqlite3_value pVal = null; - if ( sqlite3ValueFromExpr( db, pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, ref pVal ) != 0 ) - { - // db.mallocFailed = 1; - return; - } - if ( pVal == null ) - { - sqlite3ErrorMsg( pParse, "Cannot add a column with non-constant default" ); - return; - } - sqlite3ValueFree( ref pVal ); - } - - /* Modify the CREATE TABLE statement. */ - zCol = pColDef.z.Substring( 0, pColDef.n ).Replace( ";", " " ).Trim();//sqlite3DbStrNDup(db, (char*)pColDef.z, pColDef.n); - if ( zCol != null ) - { - // char zEnd = zCol[pColDef.n-1]; - int savedDbFlags = db.flags; - // while( zEnd>zCol && (*zEnd==';' || sqlite3Isspace(*zEnd)) ){ - // zEnd-- = '\0'; - // } - db.flags |= SQLITE_PreferBuiltin; - sqlite3NestedParse( pParse, - "UPDATE \"%w\".%s SET " + - "sql = substr(sql,1,%d) || ', ' || %Q || substr(sql,%d) " + - "WHERE type = 'table' AND name = %Q", - zDb, SCHEMA_TABLE( iDb ), pNew.addColOffset, zCol, pNew.addColOffset + 1, - zTab - ); - sqlite3DbFree( db, ref zCol ); - db.flags = savedDbFlags; - } - - /* If the default value of the new column is NULL, then set the file - ** format to 2. If the default value of the new column is not NULL, - ** the file format becomes 3. - */ - sqlite3MinimumFileFormat( pParse, iDb, pDflt != null ? 3 : 2 ); - - /* Reload the schema of the modified table. */ - reloadTableSchema( pParse, pTab, pTab.zName ); -} - -/* -** This function is called by the parser after the table-name in -** an "ALTER TABLE ADD" statement is parsed. Argument -** pSrc is the full-name of the table being altered. -** -** This routine makes a (partial) copy of the Table structure -** for the table being altered and sets Parse.pNewTable to point -** to it. Routines called by the parser as the column definition -** is parsed (i.e. sqlite3AddColumn()) add the new Column data to -** the copy. The copy of the Table structure is deleted by tokenize.c -** after parsing is finished. -** -** Routine sqlite3AlterFinishAddColumn() will be called to complete -** coding the "ALTER TABLE ... ADD" statement. -*/ -static void sqlite3AlterBeginAddColumn( Parse pParse, SrcList pSrc ) -{ - Table pNew; - Table pTab; - Vdbe v; - int iDb; - int i; - int nAlloc; - sqlite3 db = pParse.db; - - /* Look up the table being altered. */ - Debug.Assert( pParse.pNewTable == null ); - Debug.Assert( sqlite3BtreeHoldsAllMutexes( db ) ); - // if ( db.mallocFailed != 0 ) goto exit_begin_add_column; - pTab = sqlite3LocateTable( pParse, 0, pSrc.a[0].zName, pSrc.a[0].zDatabase ); - if ( pTab == null ) - goto exit_begin_add_column; - - if ( IsVirtual( pTab ) ) - { - sqlite3ErrorMsg( pParse, "virtual tables may not be altered" ); - goto exit_begin_add_column; - } - - /* Make sure this is not an attempt to ALTER a view. */ - if ( pTab.pSelect != null ) - { - sqlite3ErrorMsg( pParse, "Cannot add a column to a view" ); - goto exit_begin_add_column; - } - if ( SQLITE_OK != isSystemTable( pParse, pTab.zName ) ) - { - goto exit_begin_add_column; - } - - Debug.Assert( pTab.addColOffset > 0 ); - iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); - - /* Put a copy of the Table struct in Parse.pNewTable for the - ** sqlite3AddColumn() function and friends to modify. But modify - ** the name by adding an "sqlite_altertab_" prefix. By adding this - ** prefix, we insure that the name will not collide with an existing - ** table because user table are not allowed to have the "sqlite_" - ** prefix on their name. - */ - pNew = new Table();// (Table*)sqlite3DbMallocZero( db, sizeof(Table)) - if ( pNew == null ) - goto exit_begin_add_column; - pParse.pNewTable = pNew; - pNew.nRef = 1; - pNew.nCol = pTab.nCol; - Debug.Assert( pNew.nCol > 0 ); - nAlloc = ( ( ( pNew.nCol - 1 ) / 8 ) * 8 ) + 8; - Debug.Assert( nAlloc >= pNew.nCol && nAlloc % 8 == 0 && nAlloc - pNew.nCol < 8 ); - pNew.aCol = new Column[nAlloc];// (Column*)sqlite3DbMallocZero( db, sizeof(Column) * nAlloc ); - pNew.zName = sqlite3MPrintf( db, "sqlite_altertab_%s", pTab.zName ); - if ( pNew.aCol == null || pNew.zName == null ) - { - // db.mallocFailed = 1; - goto exit_begin_add_column; - } - // memcpy( pNew.aCol, pTab.aCol, sizeof(Column) * pNew.nCol ); - for ( i = 0; i < pNew.nCol; i++ ) - { - Column pCol = pTab.aCol[i].Copy(); - // sqlite3DbStrDup( db, pCol.zName ); - pCol.zColl = null; - pCol.zType = null; - pCol.pDflt = null; - pCol.zDflt = null; - pNew.aCol[i] = pCol; - } - pNew.pSchema = db.aDb[iDb].pSchema; - pNew.addColOffset = pTab.addColOffset; - pNew.nRef = 1; - - /* Begin a transaction and increment the schema cookie. */ - sqlite3BeginWriteOperation( pParse, 0, iDb ); - v = sqlite3GetVdbe( pParse ); - if ( v == null ) - goto exit_begin_add_column; - sqlite3ChangeCookie( pParse, iDb ); - -exit_begin_add_column: - sqlite3SrcListDelete( db, ref pSrc ); - return; -} + /* If the default value for the new column was specified with a + ** literal NULL, then set pDflt to 0. This simplifies checking + ** for an SQL NULL default below. + */ + if (pDflt != null && pDflt.op == TK_NULL) { + pDflt = null; + } + + /* Check that the new column is not specified as PRIMARY KEY or UNIQUE. + ** If there is a NOT NULL constraint, then the default value for the + ** column must not be NULL. + */ + if (pCol.isPrimKey != 0) { + sqlite3ErrorMsg(pParse, "Cannot add a PRIMARY KEY column"); + return; + } + if (pNew.pIndex != null) { + sqlite3ErrorMsg(pParse, "Cannot add a UNIQUE column"); + return; + } + if ((db.flags & SQLITE_ForeignKeys) != 0 && pNew.pFKey != null && pDflt != null) { + sqlite3ErrorMsg(pParse, + "Cannot add a REFERENCES column with non-NULL default value"); + return; + } + if (pCol.notNull != 0 && pDflt == null) { + sqlite3ErrorMsg(pParse, + "Cannot add a NOT NULL column with default value NULL"); + return; + } + + /* Ensure the default expression is something that sqlite3ValueFromExpr() + ** can handle (i.e. not CURRENT_TIME etc.) + */ + if (pDflt != null) { + sqlite3_value pVal = null; + if (sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, ref pVal) != 0) { + // db.mallocFailed = 1; + return; + } + if (pVal == null) { + sqlite3ErrorMsg(pParse, "Cannot add a column with non-constant default"); + return; + } + sqlite3ValueFree(ref pVal); + } + + /* Modify the CREATE TABLE statement. */ + zCol = pColDef.z.Substring(0, pColDef.n).Replace(";", " ").Trim();//sqlite3DbStrNDup(db, (char*)pColDef.z, pColDef.n); + if (zCol != null) { + // char zEnd = zCol[pColDef.n-1]; + int savedDbFlags = db.flags; + // while( zEnd>zCol && (*zEnd==';' || sqlite3Isspace(*zEnd)) ){ + // zEnd-- = '\0'; + // } + db.flags |= SQLITE_PreferBuiltin; + sqlite3NestedParse(pParse, + "UPDATE \"%w\".%s SET " + + "sql = substr(sql,1,%d) || ', ' || %Q || substr(sql,%d) " + + "WHERE type = 'table' AND name = %Q", + zDb, SCHEMA_TABLE(iDb), pNew.addColOffset, zCol, pNew.addColOffset + 1, + zTab + ); + sqlite3DbFree(db, ref zCol); + db.flags = savedDbFlags; + } + + /* If the default value of the new column is NULL, then set the file + ** format to 2. If the default value of the new column is not NULL, + ** the file format becomes 3. + */ + sqlite3MinimumFileFormat(pParse, iDb, pDflt != null ? 3 : 2); + + /* Reload the schema of the modified table. */ + reloadTableSchema(pParse, pTab, pTab.zName); + } + + /* + ** This function is called by the parser after the table-name in + ** an "ALTER TABLE ADD" statement is parsed. Argument + ** pSrc is the full-name of the table being altered. + ** + ** This routine makes a (partial) copy of the Table structure + ** for the table being altered and sets Parse.pNewTable to point + ** to it. Routines called by the parser as the column definition + ** is parsed (i.e. sqlite3AddColumn()) add the new Column data to + ** the copy. The copy of the Table structure is deleted by tokenize.c + ** after parsing is finished. + ** + ** Routine sqlite3AlterFinishAddColumn() will be called to complete + ** coding the "ALTER TABLE ... ADD" statement. + */ + static void sqlite3AlterBeginAddColumn(Parse pParse, SrcList pSrc) { + Table pNew; + Table pTab; + Vdbe v; + int iDb; + int i; + int nAlloc; + sqlite3 db = pParse.db; + + /* Look up the table being altered. */ + Debug.Assert(pParse.pNewTable == null); + Debug.Assert(sqlite3BtreeHoldsAllMutexes(db)); + // if ( db.mallocFailed != 0 ) goto exit_begin_add_column; + pTab = sqlite3LocateTable(pParse, 0, pSrc.a[0].zName, pSrc.a[0].zDatabase); + if (pTab == null) + goto exit_begin_add_column; + + if (IsVirtual(pTab)) { + sqlite3ErrorMsg(pParse, "virtual tables may not be altered"); + goto exit_begin_add_column; + } + + /* Make sure this is not an attempt to ALTER a view. */ + if (pTab.pSelect != null) { + sqlite3ErrorMsg(pParse, "Cannot add a column to a view"); + goto exit_begin_add_column; + } + if (SQLITE_OK != isSystemTable(pParse, pTab.zName)) { + goto exit_begin_add_column; + } + + Debug.Assert(pTab.addColOffset > 0); + iDb = sqlite3SchemaToIndex(db, pTab.pSchema); + + /* Put a copy of the Table struct in Parse.pNewTable for the + ** sqlite3AddColumn() function and friends to modify. But modify + ** the name by adding an "sqlite_altertab_" prefix. By adding this + ** prefix, we insure that the name will not collide with an existing + ** table because user table are not allowed to have the "sqlite_" + ** prefix on their name. + */ + pNew = new Table();// (Table*)sqlite3DbMallocZero( db, sizeof(Table)) + if (pNew == null) + goto exit_begin_add_column; + pParse.pNewTable = pNew; + pNew.nRef = 1; + pNew.nCol = pTab.nCol; + Debug.Assert(pNew.nCol > 0); + nAlloc = (((pNew.nCol - 1) / 8) * 8) + 8; + Debug.Assert(nAlloc >= pNew.nCol && nAlloc % 8 == 0 && nAlloc - pNew.nCol < 8); + pNew.aCol = new Column[nAlloc];// (Column*)sqlite3DbMallocZero( db, sizeof(Column) * nAlloc ); + pNew.zName = sqlite3MPrintf(db, "sqlite_altertab_%s", pTab.zName); + if (pNew.aCol == null || pNew.zName == null) { + // db.mallocFailed = 1; + goto exit_begin_add_column; + } + // memcpy( pNew.aCol, pTab.aCol, sizeof(Column) * pNew.nCol ); + for (i = 0; i < pNew.nCol; i++) { + Column pCol = pTab.aCol[i].Copy(); + // sqlite3DbStrDup( db, pCol.zName ); + pCol.zColl = null; + pCol.zType = null; + pCol.pDflt = null; + pCol.zDflt = null; + pNew.aCol[i] = pCol; + } + pNew.pSchema = db.aDb[iDb].pSchema; + pNew.addColOffset = pTab.addColOffset; + pNew.nRef = 1; + + /* Begin a transaction and increment the schema cookie. */ + sqlite3BeginWriteOperation(pParse, 0, iDb); + v = sqlite3GetVdbe(pParse); + if (v == null) + goto exit_begin_add_column; + sqlite3ChangeCookie(pParse, iDb); + + exit_begin_add_column: + sqlite3SrcListDelete(db, ref pSrc); + return; + } #endif // * SQLITE_ALTER_TABLE */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/analyze_c.cs b/Src/IronPython.SQLite/c#sqlite/analyze_c.cs index 23d5cd4ce..899ab6392 100644 --- a/Src/IronPython.SQLite/c#sqlite/analyze_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/analyze_c.cs @@ -1,168 +1,152 @@ using System; using System.Diagnostics; -using System.Text; using u8 = System.Byte; -namespace Community.CsharpSqlite -{ - using sqlite3_int64 = System.Int64; - using sqlite3_stmt = Sqlite3.Vdbe; +namespace Community.CsharpSqlite { + using sqlite3_int64 = System.Int64; - public partial class Sqlite3 - { -/* -** 2005 July 8 -** -** 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 contains code associated with the ANALYZE command. -************************************************************************* -** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart -** C#-SQLite is an independent reimplementation of the SQLite software library -** -** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e -** -************************************************************************* -*/ + public partial class Sqlite3 { + /* + ** 2005 July 8 + ** + ** 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 contains code associated with the ANALYZE command. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ #if !SQLITE_OMIT_ANALYZE -//#include "sqliteInt.h" - -/* -** This routine generates code that opens the sqlite_stat1 table for -** writing with cursor iStatCur. If the library was built with the -** SQLITE_ENABLE_STAT2 macro defined, then the sqlite_stat2 table is -** opened for writing using cursor (iStatCur+1) -** -** If the sqlite_stat1 tables does not previously exist, it is created. -** Similarly, if the sqlite_stat2 table does not exist and the library -** is compiled with SQLITE_ENABLE_STAT2 defined, it is created. -** -** Argument zWhere may be a pointer to a buffer containing a table name, -** or it may be a NULL pointer. If it is not NULL, then all entries in -** the sqlite_stat1 and (if applicable) sqlite_stat2 tables associated -** with the named table are deleted. If zWhere==0, then code is generated -** to delete all stat table entries. -*/ -public struct _aTable -{ - public string zName; - public string zCols; - public _aTable( string zName, string zCols ) - { - this.zName = zName; - this.zCols = zCols; - } -}; -static _aTable[] aTable = new _aTable[]{ + //#include "sqliteInt.h" + + /* + ** This routine generates code that opens the sqlite_stat1 table for + ** writing with cursor iStatCur. If the library was built with the + ** SQLITE_ENABLE_STAT2 macro defined, then the sqlite_stat2 table is + ** opened for writing using cursor (iStatCur+1) + ** + ** If the sqlite_stat1 tables does not previously exist, it is created. + ** Similarly, if the sqlite_stat2 table does not exist and the library + ** is compiled with SQLITE_ENABLE_STAT2 defined, it is created. + ** + ** Argument zWhere may be a pointer to a buffer containing a table name, + ** or it may be a NULL pointer. If it is not NULL, then all entries in + ** the sqlite_stat1 and (if applicable) sqlite_stat2 tables associated + ** with the named table are deleted. If zWhere==0, then code is generated + ** to delete all stat table entries. + */ + public struct _aTable { + public string zName; + public string zCols; + public _aTable(string zName, string zCols) { + this.zName = zName; + this.zCols = zCols; + } + }; + static _aTable[] aTable = new _aTable[]{ new _aTable( "sqlite_stat1", "tbl,idx,stat" ), #if SQLITE_ENABLE_STAT2 new _aTable( "sqlite_stat2", "tbl,idx,sampleno,sample" ), #endif }; -static void openStatTable( -Parse pParse, /* Parsing context */ -int iDb, /* The database we are looking in */ -int iStatCur, /* Open the sqlite_stat1 table on this cursor */ -string zWhere, /* Delete entries for this table or index */ -string zWhereType /* Either "tbl" or "idx" */ -) -{ - int[] aRoot = new int[] { 0, 0 }; - u8[] aCreateTbl = new u8[] { 0, 0 }; - - int i; - sqlite3 db = pParse.db; - Db pDb; - Vdbe v = sqlite3GetVdbe( pParse ); - - if ( v == null ) - return; - Debug.Assert( sqlite3BtreeHoldsAllMutexes( db ) ); - Debug.Assert( sqlite3VdbeDb( v ) == db ); - pDb = db.aDb[iDb]; - - for ( i = 0; i < ArraySize( aTable ); i++ ) - { - string zTab = aTable[i].zName; - Table pStat; - if ( ( pStat = sqlite3FindTable( db, zTab, pDb.zName ) ) == null ) - { - /* The sqlite_stat[12] table does not exist. Create it. Note that a - ** side-effect of the CREATE TABLE statement is to leave the rootpage - ** of the new table in register pParse.regRoot. This is important - ** because the OpenWrite opcode below will be needing it. */ - sqlite3NestedParse( pParse, - "CREATE TABLE %Q.%s(%s)", pDb.zName, zTab, aTable[i].zCols - ); - aRoot[i] = pParse.regRoot; - aCreateTbl[i] = 1; - } - else - { - /* The table already exists. If zWhere is not NULL, delete all entries - ** associated with the table zWhere. If zWhere is NULL, delete the - ** entire contents of the table. */ - aRoot[i] = pStat.tnum; - sqlite3TableLock( pParse, iDb, aRoot[i], 1, zTab ); - if ( !String.IsNullOrEmpty( zWhere ) ) - { - sqlite3NestedParse( pParse, - "DELETE FROM %Q.%s WHERE %s=%Q", pDb.zName, zTab, zWhereType, zWhere - ); - } - else - { - /* The sqlite_stat[12] table already exists. Delete all rows. */ - sqlite3VdbeAddOp2( v, OP_Clear, aRoot[i], iDb ); - } - } - } + static void openStatTable( + Parse pParse, /* Parsing context */ + int iDb, /* The database we are looking in */ + int iStatCur, /* Open the sqlite_stat1 table on this cursor */ + string zWhere, /* Delete entries for this table or index */ + string zWhereType /* Either "tbl" or "idx" */ + ) { + int[] aRoot = new int[] { 0, 0 }; + u8[] aCreateTbl = new u8[] { 0, 0 }; + + int i; + sqlite3 db = pParse.db; + Db pDb; + Vdbe v = sqlite3GetVdbe(pParse); + + if (v == null) + return; + Debug.Assert(sqlite3BtreeHoldsAllMutexes(db)); + Debug.Assert(sqlite3VdbeDb(v) == db); + pDb = db.aDb[iDb]; + + for (i = 0; i < ArraySize(aTable); i++) { + string zTab = aTable[i].zName; + Table pStat; + if ((pStat = sqlite3FindTable(db, zTab, pDb.zName)) == null) { + /* The sqlite_stat[12] table does not exist. Create it. Note that a + ** side-effect of the CREATE TABLE statement is to leave the rootpage + ** of the new table in register pParse.regRoot. This is important + ** because the OpenWrite opcode below will be needing it. */ + sqlite3NestedParse(pParse, + "CREATE TABLE %Q.%s(%s)", pDb.zName, zTab, aTable[i].zCols + ); + aRoot[i] = pParse.regRoot; + aCreateTbl[i] = 1; + } else { + /* The table already exists. If zWhere is not NULL, delete all entries + ** associated with the table zWhere. If zWhere is NULL, delete the + ** entire contents of the table. */ + aRoot[i] = pStat.tnum; + sqlite3TableLock(pParse, iDb, aRoot[i], 1, zTab); + if (!String.IsNullOrEmpty(zWhere)) { + sqlite3NestedParse(pParse, + "DELETE FROM %Q.%s WHERE %s=%Q", pDb.zName, zTab, zWhereType, zWhere + ); + } else { + /* The sqlite_stat[12] table already exists. Delete all rows. */ + sqlite3VdbeAddOp2(v, OP_Clear, aRoot[i], iDb); + } + } + } - /* Open the sqlite_stat[12] tables for writing. */ - for ( i = 0; i < ArraySize( aTable ); i++ ) - { - sqlite3VdbeAddOp3( v, OP_OpenWrite, iStatCur + i, aRoot[i], iDb ); - sqlite3VdbeChangeP4( v, -1, 3, P4_INT32 ); - sqlite3VdbeChangeP5( v, aCreateTbl[i] ); - } -} + /* Open the sqlite_stat[12] tables for writing. */ + for (i = 0; i < ArraySize(aTable); i++) { + sqlite3VdbeAddOp3(v, OP_OpenWrite, iStatCur + i, aRoot[i], iDb); + sqlite3VdbeChangeP4(v, -1, 3, P4_INT32); + sqlite3VdbeChangeP5(v, aCreateTbl[i]); + } + } -/* -** Generate code to do an analysis of all indices associated with -** a single table. -*/ -static void analyzeOneTable( -Parse pParse, /* Parser context */ -Table pTab, /* Table whose indices are to be analyzed */ -Index pOnlyIdx, /* If not NULL, only analyze this one index */ -int iStatCur, /* Index of VdbeCursor that writes the sqlite_stat1 table */ -int iMem /* Available memory locations begin here */ -) -{ - sqlite3 db = pParse.db; /* Database handle */ - Index pIdx; /* An index to being analyzed */ - int iIdxCur; /* Cursor open on index being analyzed */ - Vdbe v; /* The virtual machine being built up */ - int i; /* Loop counter */ - int topOfLoop; /* The top of the loop */ - int endOfLoop; /* The end of the loop */ - int jZeroRows = -1; /* Jump from here if number of rows is zero */ - int iDb; /* Index of database containing pTab */ - int regTabname = iMem++; /* Register containing table name */ - int regIdxname = iMem++; /* Register containing index name */ - int regSampleno = iMem++; /* Register containing next sample number */ - int regCol = iMem++; /* Content of a column analyzed table */ - int regRec = iMem++; /* Register holding completed record */ - int regTemp = iMem++; /* Temporary use register */ - int regRowid = iMem++; /* Rowid for the inserted record */ + /* + ** Generate code to do an analysis of all indices associated with + ** a single table. + */ + static void analyzeOneTable( + Parse pParse, /* Parser context */ + Table pTab, /* Table whose indices are to be analyzed */ + Index pOnlyIdx, /* If not NULL, only analyze this one index */ + int iStatCur, /* Index of VdbeCursor that writes the sqlite_stat1 table */ + int iMem /* Available memory locations begin here */ + ) { + sqlite3 db = pParse.db; /* Database handle */ + Index pIdx; /* An index to being analyzed */ + int iIdxCur; /* Cursor open on index being analyzed */ + Vdbe v; /* The virtual machine being built up */ + int i; /* Loop counter */ + int topOfLoop; /* The top of the loop */ + int endOfLoop; /* The end of the loop */ + int jZeroRows = -1; /* Jump from here if number of rows is zero */ + int iDb; /* Index of database containing pTab */ + int regTabname = iMem++; /* Register containing table name */ + int regIdxname = iMem++; /* Register containing index name */ + int regSampleno = iMem++; /* Register containing next sample number */ + int regCol = iMem++; /* Content of a column analyzed table */ + int regRec = iMem++; /* Register holding completed record */ + int regTemp = iMem++; /* Temporary use register */ + int regRowid = iMem++; /* Rowid for the inserted record */ #if SQLITE_ENABLE_STAT2 int addr = 0; /* Instruction address */ @@ -173,25 +157,22 @@ int iMem /* Available memory locations begin here */ int regFirst = iMem++; /* Index of first sample to record */ #endif - v = sqlite3GetVdbe( pParse ); - if ( v == null || NEVER( pTab == null ) ) - { - return; - } - if ( pTab.tnum == 0 ) - { - /* Do not gather statistics on views or virtual tables */ - return; - } - if ( pTab.zName.StartsWith( "sqlite_", StringComparison.OrdinalIgnoreCase ) ) - { - /* Do not gather statistics on system tables */ - return; - } - Debug.Assert( sqlite3BtreeHoldsAllMutexes( db ) ); - iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); - Debug.Assert( iDb >= 0 ); - Debug.Assert( sqlite3SchemaMutexHeld(db, iDb, null) ); + v = sqlite3GetVdbe(pParse); + if (v == null || NEVER(pTab == null)) { + return; + } + if (pTab.tnum == 0) { + /* Do not gather statistics on views or virtual tables */ + return; + } + if (pTab.zName.StartsWith("sqlite_", StringComparison.OrdinalIgnoreCase)) { + /* Do not gather statistics on system tables */ + return; + } + Debug.Assert(sqlite3BtreeHoldsAllMutexes(db)); + iDb = sqlite3SchemaToIndex(db, pTab.pSchema); + Debug.Assert(iDb >= 0); + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); #if !SQLITE_OMIT_AUTHORIZATION if( sqlite3AuthCheck(pParse, SQLITE_ANALYZE, pTab.zName, 0, db.aDb[iDb].zName ) ){ @@ -199,33 +180,31 @@ int iMem /* Available memory locations begin here */ } #endif - /* Establish a read-lock on the table at the shared-cache level. */ - sqlite3TableLock( pParse, iDb, pTab.tnum, 0, pTab.zName ); - - iIdxCur = pParse.nTab++; - sqlite3VdbeAddOp4( v, OP_String8, 0, regTabname, 0, pTab.zName, 0 ); - for ( pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext ) - { - int nCol; - KeyInfo pKey; - if ( pOnlyIdx != null && pOnlyIdx != pIdx ) - continue; - nCol = pIdx.nColumn; - pKey = sqlite3IndexKeyinfo( pParse, pIdx ); - - if ( iMem + 1 + ( nCol * 2 ) > pParse.nMem ) - { - pParse.nMem = iMem + 1 + ( nCol * 2 ); - } + /* Establish a read-lock on the table at the shared-cache level. */ + sqlite3TableLock(pParse, iDb, pTab.tnum, 0, pTab.zName); + + iIdxCur = pParse.nTab++; + sqlite3VdbeAddOp4(v, OP_String8, 0, regTabname, 0, pTab.zName, 0); + for (pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext) { + int nCol; + KeyInfo pKey; + if (pOnlyIdx != null && pOnlyIdx != pIdx) + continue; + nCol = pIdx.nColumn; + pKey = sqlite3IndexKeyinfo(pParse, pIdx); + + if (iMem + 1 + (nCol * 2) > pParse.nMem) { + pParse.nMem = iMem + 1 + (nCol * 2); + } - /* Open a cursor to the index to be analyzed. */ - Debug.Assert( iDb == sqlite3SchemaToIndex( db, pIdx.pSchema ) ); - sqlite3VdbeAddOp4( v, OP_OpenRead, iIdxCur, pIdx.tnum, iDb, - pKey, P4_KEYINFO_HANDOFF ); - VdbeComment( v, "%s", pIdx.zName ); + /* Open a cursor to the index to be analyzed. */ + Debug.Assert(iDb == sqlite3SchemaToIndex(db, pIdx.pSchema)); + sqlite3VdbeAddOp4(v, OP_OpenRead, iIdxCur, pIdx.tnum, iDb, + pKey, P4_KEYINFO_HANDOFF); + VdbeComment(v, "%s", pIdx.zName); - /* Populate the registers containing the index names. */ - sqlite3VdbeAddOp4( v, OP_String8, 0, regIdxname, 0, pIdx.zName, 0 ); + /* Populate the registers containing the index names. */ + sqlite3VdbeAddOp4(v, OP_String8, 0, regIdxname, 0, pIdx.zName, 0); #if SQLITE_ENABLE_STAT2 @@ -254,44 +233,40 @@ int iMem /* Available memory locations begin here */ sqlite3VdbeAddOp2( v, OP_Copy, regFirst, regSamplerecno ); #endif - /* The block of memory cells initialized here is used as follows. -** -** iMem: -** The total number of rows in the table. -** -** iMem+1 .. iMem+nCol: -** Number of distinct entries in index considering the -** left-most N columns only, where N is between 1 and nCol, -** inclusive. -** -** iMem+nCol+1 .. Mem+2*nCol: -** Previous value of indexed columns, from left to right. -** -** Cells iMem through iMem+nCol are initialized to 0. The others are -** initialized to contain an SQL NULL. -*/ - for ( i = 0; i <= nCol; i++ ) - { - sqlite3VdbeAddOp2( v, OP_Integer, 0, iMem + i ); - } - for ( i = 0; i < nCol; i++ ) - { - sqlite3VdbeAddOp2( v, OP_Null, 0, iMem + nCol + i + 1 ); - } - - /* Start the analysis loop. This loop runs through all the entries in - ** the index b-tree. */ - endOfLoop = sqlite3VdbeMakeLabel( v ); - sqlite3VdbeAddOp2( v, OP_Rewind, iIdxCur, endOfLoop ); - topOfLoop = sqlite3VdbeCurrentAddr( v ); - sqlite3VdbeAddOp2( v, OP_AddImm, iMem, 1 ); + /* The block of memory cells initialized here is used as follows. + ** + ** iMem: + ** The total number of rows in the table. + ** + ** iMem+1 .. iMem+nCol: + ** Number of distinct entries in index considering the + ** left-most N columns only, where N is between 1 and nCol, + ** inclusive. + ** + ** iMem+nCol+1 .. Mem+2*nCol: + ** Previous value of indexed columns, from left to right. + ** + ** Cells iMem through iMem+nCol are initialized to 0. The others are + ** initialized to contain an SQL NULL. + */ + for (i = 0; i <= nCol; i++) { + sqlite3VdbeAddOp2(v, OP_Integer, 0, iMem + i); + } + for (i = 0; i < nCol; i++) { + sqlite3VdbeAddOp2(v, OP_Null, 0, iMem + nCol + i + 1); + } - for ( i = 0; i < nCol; i++ ) - { - sqlite3VdbeAddOp3( v, OP_Column, iIdxCur, i, regCol ); - CollSeq pColl; - if ( i == 0 ) - { + /* Start the analysis loop. This loop runs through all the entries in + ** the index b-tree. */ + endOfLoop = sqlite3VdbeMakeLabel(v); + sqlite3VdbeAddOp2(v, OP_Rewind, iIdxCur, endOfLoop); + topOfLoop = sqlite3VdbeCurrentAddr(v); + sqlite3VdbeAddOp2(v, OP_AddImm, iMem, 1); + + for (i = 0; i < nCol; i++) { + sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, regCol); + CollSeq pColl; + if (i == 0) { #if SQLITE_ENABLE_STAT2 /* Check if the record that cursor iIdxCur points to contains a ** value that should be stored in the sqlite_stat2 table. If so, @@ -323,353 +298,307 @@ int iMem /* Available memory locations begin here */ sqlite3VdbeAddOp2( v, OP_AddImm, regRecno, 1 ); #endif - /* Always record the very first row */ - sqlite3VdbeAddOp1( v, OP_IfNot, iMem + 1 ); - } - Debug.Assert( pIdx.azColl != null ); - Debug.Assert( pIdx.azColl[i] != null ); - pColl = sqlite3LocateCollSeq( pParse, pIdx.azColl[i] ); - sqlite3VdbeAddOp4( v, OP_Ne, regCol, 0, iMem + nCol + i + 1, - pColl, P4_COLLSEQ ); - sqlite3VdbeChangeP5( v, SQLITE_NULLEQ ); - } - //if( db.mallocFailed ){ - // /* If a malloc failure has occurred, then the result of the expression - // ** passed as the second argument to the call to sqlite3VdbeJumpHere() - // ** below may be negative. Which causes an Debug.Assert() to fail (or an - // ** out-of-bounds write if SQLITE_DEBUG is not defined). */ - // return; - //} - sqlite3VdbeAddOp2( v, OP_Goto, 0, endOfLoop ); - for ( i = 0; i < nCol; i++ ) - { - int addr2 = sqlite3VdbeCurrentAddr( v ) - ( nCol * 2 ); - if ( i == 0 ) - { - sqlite3VdbeJumpHere( v, addr2 - 1 ); /* Set jump dest for the OP_IfNot */ - } - sqlite3VdbeJumpHere( v, addr2 ); /* Set jump dest for the OP_Ne */ - sqlite3VdbeAddOp2( v, OP_AddImm, iMem + i + 1, 1 ); - sqlite3VdbeAddOp3( v, OP_Column, iIdxCur, i, iMem + nCol + i + 1 ); - } - - /* End of the analysis loop. */ - sqlite3VdbeResolveLabel( v, endOfLoop ); - sqlite3VdbeAddOp2( v, OP_Next, iIdxCur, topOfLoop ); - sqlite3VdbeAddOp1( v, OP_Close, iIdxCur ); - - /* Store the results in sqlite_stat1. - ** - ** The result is a single row of the sqlite_stat1 table. The first - ** two columns are the names of the table and index. The third column - ** is a string composed of a list of integer statistics about the - ** index. The first integer in the list is the total number of entries - ** in the index. There is one additional integer in the list for each - ** column of the table. This additional integer is a guess of how many - ** rows of the table the index will select. If D is the count of distinct - ** values and K is the total number of rows, then the integer is computed - ** as: - ** - ** I = (K+D-1)/D - ** - ** If K==0 then no entry is made into the sqlite_stat1 table. - ** If K>0 then it is always the case the D>0 so division by zero - ** is never possible. - */ - sqlite3VdbeAddOp2( v, OP_SCopy, iMem, regSampleno ); - if ( jZeroRows < 0 ) - { - jZeroRows = sqlite3VdbeAddOp1( v, OP_IfNot, iMem ); - } - for ( i = 0; i < nCol; i++ ) - { - sqlite3VdbeAddOp4( v, OP_String8, 0, regTemp, 0, " ", 0 ); - sqlite3VdbeAddOp3( v, OP_Concat, regTemp, regSampleno, regSampleno ); - sqlite3VdbeAddOp3( v, OP_Add, iMem, iMem + i + 1, regTemp ); - sqlite3VdbeAddOp2( v, OP_AddImm, regTemp, -1 ); - sqlite3VdbeAddOp3( v, OP_Divide, iMem + i + 1, regTemp, regTemp ); - sqlite3VdbeAddOp1( v, OP_ToInt, regTemp ); - sqlite3VdbeAddOp3( v, OP_Concat, regTemp, regSampleno, regSampleno ); - } - sqlite3VdbeAddOp4( v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0 ); - sqlite3VdbeAddOp2( v, OP_NewRowid, iStatCur, regRowid ); - sqlite3VdbeAddOp3( v, OP_Insert, iStatCur, regRec, regRowid ); - sqlite3VdbeChangeP5( v, OPFLAG_APPEND ); - } - - /* If the table has no indices, create a single sqlite_stat1 entry - ** containing NULL as the index name and the row count as the content. - */ - if ( pTab.pIndex == null ) - { - sqlite3VdbeAddOp3( v, OP_OpenRead, iIdxCur, pTab.tnum, iDb ); - VdbeComment( v, "%s", pTab.zName ); - sqlite3VdbeAddOp2( v, OP_Count, iIdxCur, regSampleno ); - sqlite3VdbeAddOp1( v, OP_Close, iIdxCur ); - jZeroRows = sqlite3VdbeAddOp1( v, OP_IfNot, regSampleno ); - } - else - { - sqlite3VdbeJumpHere( v, jZeroRows ); - jZeroRows = sqlite3VdbeAddOp0( v, OP_Goto ); - } - sqlite3VdbeAddOp2( v, OP_Null, 0, regIdxname ); - sqlite3VdbeAddOp4( v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0 ); - sqlite3VdbeAddOp2( v, OP_NewRowid, iStatCur, regRowid ); - sqlite3VdbeAddOp3( v, OP_Insert, iStatCur, regRec, regRowid ); - sqlite3VdbeChangeP5( v, OPFLAG_APPEND ); - if ( pParse.nMem < regRec ) - pParse.nMem = regRec; - sqlite3VdbeJumpHere( v, jZeroRows ); -} - -/* -** Generate code that will cause the most recent index analysis to -** be loaded into internal hash tables where is can be used. -*/ -static void loadAnalysis( Parse pParse, int iDb ) -{ - Vdbe v = sqlite3GetVdbe( pParse ); - if ( v != null ) - { - sqlite3VdbeAddOp1( v, OP_LoadAnalysis, iDb ); - } -} - -/* -** Generate code that will do an analysis of an entire database -*/ -static void analyzeDatabase( Parse pParse, int iDb ) -{ - sqlite3 db = pParse.db; - Schema pSchema = db.aDb[iDb].pSchema; /* Schema of database iDb */ - HashElem k; - int iStatCur; - int iMem; - - sqlite3BeginWriteOperation( pParse, 0, iDb ); - iStatCur = pParse.nTab; - pParse.nTab += 2; - openStatTable( pParse, iDb, iStatCur, null, null ); - iMem = pParse.nMem + 1; - Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); - //for(k=sqliteHashFirst(pSchema.tblHash); k; k=sqliteHashNext(k)){ - for ( k = pSchema.tblHash.first; k != null; k = k.next ) - { - Table pTab = (Table)k.data;// sqliteHashData( k ); - analyzeOneTable( pParse, pTab, null, iStatCur, iMem ); - } - loadAnalysis( pParse, iDb ); -} + /* Always record the very first row */ + sqlite3VdbeAddOp1(v, OP_IfNot, iMem + 1); + } + Debug.Assert(pIdx.azColl != null); + Debug.Assert(pIdx.azColl[i] != null); + pColl = sqlite3LocateCollSeq(pParse, pIdx.azColl[i]); + sqlite3VdbeAddOp4(v, OP_Ne, regCol, 0, iMem + nCol + i + 1, + pColl, P4_COLLSEQ); + sqlite3VdbeChangeP5(v, SQLITE_NULLEQ); + } + //if( db.mallocFailed ){ + // /* If a malloc failure has occurred, then the result of the expression + // ** passed as the second argument to the call to sqlite3VdbeJumpHere() + // ** below may be negative. Which causes an Debug.Assert() to fail (or an + // ** out-of-bounds write if SQLITE_DEBUG is not defined). */ + // return; + //} + sqlite3VdbeAddOp2(v, OP_Goto, 0, endOfLoop); + for (i = 0; i < nCol; i++) { + int addr2 = sqlite3VdbeCurrentAddr(v) - (nCol * 2); + if (i == 0) { + sqlite3VdbeJumpHere(v, addr2 - 1); /* Set jump dest for the OP_IfNot */ + } + sqlite3VdbeJumpHere(v, addr2); /* Set jump dest for the OP_Ne */ + sqlite3VdbeAddOp2(v, OP_AddImm, iMem + i + 1, 1); + sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, iMem + nCol + i + 1); + } -/* -** Generate code that will do an analysis of a single table in -** a database. If pOnlyIdx is not NULL then it is a single index -** in pTab that should be analyzed. -*/ -static void analyzeTable( Parse pParse, Table pTab, Index pOnlyIdx) -{ - int iDb; - int iStatCur; - - Debug.Assert( pTab != null ); - Debug.Assert( sqlite3BtreeHoldsAllMutexes( pParse.db ) ); - iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema ); - sqlite3BeginWriteOperation( pParse, 0, iDb ); - iStatCur = pParse.nTab; - pParse.nTab += 2; - if ( pOnlyIdx != null ) - { - openStatTable( pParse, iDb, iStatCur, pOnlyIdx.zName, "idx" ); - } - else - { - openStatTable( pParse, iDb, iStatCur, pTab.zName, "tbl" ); - } - analyzeOneTable( pParse, pTab, pOnlyIdx, iStatCur, pParse.nMem + 1 ); - loadAnalysis( pParse, iDb ); -} + /* End of the analysis loop. */ + sqlite3VdbeResolveLabel(v, endOfLoop); + sqlite3VdbeAddOp2(v, OP_Next, iIdxCur, topOfLoop); + sqlite3VdbeAddOp1(v, OP_Close, iIdxCur); + + /* Store the results in sqlite_stat1. + ** + ** The result is a single row of the sqlite_stat1 table. The first + ** two columns are the names of the table and index. The third column + ** is a string composed of a list of integer statistics about the + ** index. The first integer in the list is the total number of entries + ** in the index. There is one additional integer in the list for each + ** column of the table. This additional integer is a guess of how many + ** rows of the table the index will select. If D is the count of distinct + ** values and K is the total number of rows, then the integer is computed + ** as: + ** + ** I = (K+D-1)/D + ** + ** If K==0 then no entry is made into the sqlite_stat1 table. + ** If K>0 then it is always the case the D>0 so division by zero + ** is never possible. + */ + sqlite3VdbeAddOp2(v, OP_SCopy, iMem, regSampleno); + if (jZeroRows < 0) { + jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem); + } + for (i = 0; i < nCol; i++) { + sqlite3VdbeAddOp4(v, OP_String8, 0, regTemp, 0, " ", 0); + sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regSampleno, regSampleno); + sqlite3VdbeAddOp3(v, OP_Add, iMem, iMem + i + 1, regTemp); + sqlite3VdbeAddOp2(v, OP_AddImm, regTemp, -1); + sqlite3VdbeAddOp3(v, OP_Divide, iMem + i + 1, regTemp, regTemp); + sqlite3VdbeAddOp1(v, OP_ToInt, regTemp); + sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regSampleno, regSampleno); + } + sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0); + sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regRowid); + sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regRowid); + sqlite3VdbeChangeP5(v, OPFLAG_APPEND); + } -/* -** Generate code for the ANALYZE command. The parser calls this routine -** when it recognizes an ANALYZE command. -** -** ANALYZE -- 1 -** ANALYZE -- 2 -** ANALYZE ?.? -- 3 -** -** Form 1 causes all indices in all attached databases to be analyzed. -** Form 2 analyzes all indices the single database named. -** Form 3 analyzes all indices associated with the named table. -*/ -// OVERLOADS, so I don't need to rewrite parse.c -static void sqlite3Analyze( Parse pParse, int null_2, int null_3 ) -{ - sqlite3Analyze( pParse, null, null ); -} -static void sqlite3Analyze( Parse pParse, Token pName1, Token pName2 ) -{ - sqlite3 db = pParse.db; - int iDb; - int i; - string z, zDb; - Table pTab; - Index pIdx; - Token pTableName = null; - - /* Read the database schema. If an error occurs, leave an error message - ** and code in pParse and return NULL. */ - Debug.Assert( sqlite3BtreeHoldsAllMutexes( pParse.db ) ); - if ( SQLITE_OK != sqlite3ReadSchema( pParse ) ) - { - return; - } + /* If the table has no indices, create a single sqlite_stat1 entry + ** containing NULL as the index name and the row count as the content. + */ + if (pTab.pIndex == null) { + sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pTab.tnum, iDb); + VdbeComment(v, "%s", pTab.zName); + sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regSampleno); + sqlite3VdbeAddOp1(v, OP_Close, iIdxCur); + jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regSampleno); + } else { + sqlite3VdbeJumpHere(v, jZeroRows); + jZeroRows = sqlite3VdbeAddOp0(v, OP_Goto); + } + sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname); + sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0); + sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regRowid); + sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regRowid); + sqlite3VdbeChangeP5(v, OPFLAG_APPEND); + if (pParse.nMem < regRec) + pParse.nMem = regRec; + sqlite3VdbeJumpHere(v, jZeroRows); + } - Debug.Assert( pName2 != null || pName1 == null ); - if ( pName1 == null ) - { - /* Form 1: Analyze everything */ - for ( i = 0; i < db.nDb; i++ ) - { - if ( i == 1 ) - continue; /* Do not analyze the TEMP database */ - analyzeDatabase( pParse, i ); - } - } - else if ( pName2.n == 0 ) - { - /* Form 2: Analyze the database or table named */ - iDb = sqlite3FindDb( db, pName1 ); - if ( iDb >= 0 ) - { - analyzeDatabase( pParse, iDb ); - } - else - { - z = sqlite3NameFromToken( db, pName1 ); - if ( z != null ) - { - if ( ( pIdx = sqlite3FindIndex( db, z, null ) ) != null ) - { - analyzeTable( pParse, pIdx.pTable, pIdx ); + /* + ** Generate code that will cause the most recent index analysis to + ** be loaded into internal hash tables where is can be used. + */ + static void loadAnalysis(Parse pParse, int iDb) { + Vdbe v = sqlite3GetVdbe(pParse); + if (v != null) { + sqlite3VdbeAddOp1(v, OP_LoadAnalysis, iDb); + } } - else if ( ( pTab = sqlite3LocateTable( pParse, 0, z, null ) ) != null ) - { - analyzeTable( pParse, pTab, null ); + + /* + ** Generate code that will do an analysis of an entire database + */ + static void analyzeDatabase(Parse pParse, int iDb) { + sqlite3 db = pParse.db; + Schema pSchema = db.aDb[iDb].pSchema; /* Schema of database iDb */ + HashElem k; + int iStatCur; + int iMem; + + sqlite3BeginWriteOperation(pParse, 0, iDb); + iStatCur = pParse.nTab; + pParse.nTab += 2; + openStatTable(pParse, iDb, iStatCur, null, null); + iMem = pParse.nMem + 1; + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + //for(k=sqliteHashFirst(pSchema.tblHash); k; k=sqliteHashNext(k)){ + for (k = pSchema.tblHash.first; k != null; k = k.next) { + Table pTab = (Table)k.data;// sqliteHashData( k ); + analyzeOneTable(pParse, pTab, null, iStatCur, iMem); + } + loadAnalysis(pParse, iDb); } - z = null;//sqlite3DbFree( db, z ); - } - } - } - else - { - /* Form 3: Analyze the fully qualified table name */ - iDb = sqlite3TwoPartName( pParse, pName1, pName2, ref pTableName ); - if ( iDb >= 0 ) - { - zDb = db.aDb[iDb].zName; - z = sqlite3NameFromToken( db, pTableName ); - if ( z != null ) - { - if ( ( pIdx = sqlite3FindIndex( db, z, zDb ) ) != null ) - { - analyzeTable( pParse, pIdx.pTable, pIdx ); + + /* + ** Generate code that will do an analysis of a single table in + ** a database. If pOnlyIdx is not NULL then it is a single index + ** in pTab that should be analyzed. + */ + static void analyzeTable(Parse pParse, Table pTab, Index pOnlyIdx) { + int iDb; + int iStatCur; + + Debug.Assert(pTab != null); + Debug.Assert(sqlite3BtreeHoldsAllMutexes(pParse.db)); + iDb = sqlite3SchemaToIndex(pParse.db, pTab.pSchema); + sqlite3BeginWriteOperation(pParse, 0, iDb); + iStatCur = pParse.nTab; + pParse.nTab += 2; + if (pOnlyIdx != null) { + openStatTable(pParse, iDb, iStatCur, pOnlyIdx.zName, "idx"); + } else { + openStatTable(pParse, iDb, iStatCur, pTab.zName, "tbl"); + } + analyzeOneTable(pParse, pTab, pOnlyIdx, iStatCur, pParse.nMem + 1); + loadAnalysis(pParse, iDb); } - else if ( ( pTab = sqlite3LocateTable( pParse, 0, z, zDb ) ) != null ) - { - analyzeTable( pParse, pTab, null ); + + /* + ** Generate code for the ANALYZE command. The parser calls this routine + ** when it recognizes an ANALYZE command. + ** + ** ANALYZE -- 1 + ** ANALYZE -- 2 + ** ANALYZE ?.? -- 3 + ** + ** Form 1 causes all indices in all attached databases to be analyzed. + ** Form 2 analyzes all indices the single database named. + ** Form 3 analyzes all indices associated with the named table. + */ + // OVERLOADS, so I don't need to rewrite parse.c + static void sqlite3Analyze(Parse pParse, int null_2, int null_3) { + sqlite3Analyze(pParse, null, null); } - z = null; //sqlite3DbFree( db, z ); - } - } - } -} + static void sqlite3Analyze(Parse pParse, Token pName1, Token pName2) { + sqlite3 db = pParse.db; + int iDb; + int i; + string z, zDb; + Table pTab; + Index pIdx; + Token pTableName = null; + + /* Read the database schema. If an error occurs, leave an error message + ** and code in pParse and return NULL. */ + Debug.Assert(sqlite3BtreeHoldsAllMutexes(pParse.db)); + if (SQLITE_OK != sqlite3ReadSchema(pParse)) { + return; + } -/* -** Used to pass information from the analyzer reader through to the -** callback routine. -*/ -//typedef struct analysisInfo analysisInfo; -public struct analysisInfo -{ - public sqlite3 db; - public string zDatabase; -}; + Debug.Assert(pName2 != null || pName1 == null); + if (pName1 == null) { + /* Form 1: Analyze everything */ + for (i = 0; i < db.nDb; i++) { + if (i == 1) + continue; /* Do not analyze the TEMP database */ + analyzeDatabase(pParse, i); + } + } else if (pName2.n == 0) { + /* Form 2: Analyze the database or table named */ + iDb = sqlite3FindDb(db, pName1); + if (iDb >= 0) { + analyzeDatabase(pParse, iDb); + } else { + z = sqlite3NameFromToken(db, pName1); + if (z != null) { + if ((pIdx = sqlite3FindIndex(db, z, null)) != null) { + analyzeTable(pParse, pIdx.pTable, pIdx); + } else if ((pTab = sqlite3LocateTable(pParse, 0, z, null)) != null) { + analyzeTable(pParse, pTab, null); + } + z = null;//sqlite3DbFree( db, z ); + } + } + } else { + /* Form 3: Analyze the fully qualified table name */ + iDb = sqlite3TwoPartName(pParse, pName1, pName2, ref pTableName); + if (iDb >= 0) { + zDb = db.aDb[iDb].zName; + z = sqlite3NameFromToken(db, pTableName); + if (z != null) { + if ((pIdx = sqlite3FindIndex(db, z, zDb)) != null) { + analyzeTable(pParse, pIdx.pTable, pIdx); + } else if ((pTab = sqlite3LocateTable(pParse, 0, z, zDb)) != null) { + analyzeTable(pParse, pTab, null); + } + z = null; //sqlite3DbFree( db, z ); + } + } + } + } -/* -** This callback is invoked once for each index when reading the -** sqlite_stat1 table. -** -** argv[0] = name of the table -** argv[1] = name of the index (might be NULL) -** argv[2] = results of analysis - on integer for each column -** -** Entries for which argv[1]==NULL simply record the number of rows in -** the table. -*/ -static int analysisLoader( object pData, sqlite3_int64 argc, object Oargv, object NotUsed ) -{ - string[] argv = (string[])Oargv; - analysisInfo pInfo = (analysisInfo)pData; - Index pIndex; - Table pTable; - int i, c, n; - int v; - string z; - - Debug.Assert( argc == 3 ); - UNUSED_PARAMETER2( NotUsed, argc ); - if ( argv == null || argv[0] == null || argv[2] == null ) - { - return 0; - } - pTable = sqlite3FindTable( pInfo.db, argv[0], pInfo.zDatabase ); - if ( pTable == null ) - { - return 0; - } - if ( !String.IsNullOrEmpty( argv[1] ) ) - { - pIndex = sqlite3FindIndex( pInfo.db, argv[1], pInfo.zDatabase ); - } - else - { - pIndex = null; - } + /* + ** Used to pass information from the analyzer reader through to the + ** callback routine. + */ + //typedef struct analysisInfo analysisInfo; + public struct analysisInfo { + public sqlite3 db; + public string zDatabase; + }; + + /* + ** This callback is invoked once for each index when reading the + ** sqlite_stat1 table. + ** + ** argv[0] = name of the table + ** argv[1] = name of the index (might be NULL) + ** argv[2] = results of analysis - on integer for each column + ** + ** Entries for which argv[1]==NULL simply record the number of rows in + ** the table. + */ + static int analysisLoader(object pData, sqlite3_int64 argc, object Oargv, object NotUsed) { + string[] argv = (string[])Oargv; + analysisInfo pInfo = (analysisInfo)pData; + Index pIndex; + Table pTable; + int i, c, n; + int v; + string z; + + Debug.Assert(argc == 3); + UNUSED_PARAMETER2(NotUsed, argc); + if (argv == null || argv[0] == null || argv[2] == null) { + return 0; + } + pTable = sqlite3FindTable(pInfo.db, argv[0], pInfo.zDatabase); + if (pTable == null) { + return 0; + } + if (!String.IsNullOrEmpty(argv[1])) { + pIndex = sqlite3FindIndex(pInfo.db, argv[1], pInfo.zDatabase); + } else { + pIndex = null; + } - n = pIndex != null ? pIndex.nColumn : 0; - z = argv[2]; - int zIndex = 0; - for ( i = 0; z != null && i <= n; i++ ) - { - v = 0; - while ( zIndex < z.Length && ( c = z[zIndex] ) >= '0' && c <= '9' ) - { - v = v * 10 + c - '0'; - zIndex++; - } - if ( i == 0 ) - pTable.nRowEst = (uint)v; - if ( pIndex == null ) - break; - pIndex.aiRowEst[i] = v; - if ( zIndex < z.Length && z[zIndex] == ' ' ) - zIndex++; - if ( string.Equals(z.Substring(zIndex), "unordered", StringComparison.Ordinal) )//memcmp( z, "unordered", 10 ) == 0 ) - { - pIndex.bUnordered = 1; - break; - } - } - return 0; -} + n = pIndex != null ? pIndex.nColumn : 0; + z = argv[2]; + int zIndex = 0; + for (i = 0; z != null && i <= n; i++) { + v = 0; + while (zIndex < z.Length && (c = z[zIndex]) >= '0' && c <= '9') { + v = v * 10 + c - '0'; + zIndex++; + } + if (i == 0) + pTable.nRowEst = (uint)v; + if (pIndex == null) + break; + pIndex.aiRowEst[i] = v; + if (zIndex < z.Length && z[zIndex] == ' ') + zIndex++; + if (string.Equals(z.Substring(zIndex), "unordered", StringComparison.Ordinal))//memcmp( z, "unordered", 10 ) == 0 ) + { + pIndex.bUnordered = 1; + break; + } + } + return 0; + } -/* -** If the Index.aSample variable is not NULL, delete the aSample[] array -** and its contents. -*/ -static void sqlite3DeleteIndexSamples( sqlite3 db, Index pIdx ) -{ + /* + ** If the Index.aSample variable is not NULL, delete the aSample[] array + ** and its contents. + */ + static void sqlite3DeleteIndexSamples(sqlite3 db, Index pIdx) { #if SQLITE_ENABLE_STAT2 if ( pIdx.aSample != null ) { @@ -686,75 +615,72 @@ static void sqlite3DeleteIndexSamples( sqlite3 db, Index pIdx ) sqlite3DbFree( db, ref pIdx.aSample ); } #else -UNUSED_PARAMETER(db); -UNUSED_PARAMETER( pIdx ); + UNUSED_PARAMETER(db); + UNUSED_PARAMETER(pIdx); #endif -} + } -/* -** Load the content of the sqlite_stat1 and sqlite_stat2 tables. The -** contents of sqlite_stat1 are used to populate the Index.aiRowEst[] -** arrays. The contents of sqlite_stat2 are used to populate the -** Index.aSample[] arrays. -** -** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR -** is returned. In this case, even if SQLITE_ENABLE_STAT2 was defined -** during compilation and the sqlite_stat2 table is present, no data is -** read from it. -** -** If SQLITE_ENABLE_STAT2 was defined during compilation and the -** sqlite_stat2 table is not present in the database, SQLITE_ERROR is -** returned. However, in this case, data is read from the sqlite_stat1 -** table (if it is present) before returning. -** -** If an OOM error occurs, this function always sets db.mallocFailed. -** This means if the caller does not care about other errors, the return -** code may be ignored. -*/ -static int sqlite3AnalysisLoad( sqlite3 db, int iDb ) -{ - analysisInfo sInfo; - HashElem i; - string zSql; - int rc; - - Debug.Assert( iDb >= 0 && iDb < db.nDb ); - Debug.Assert( db.aDb[iDb].pBt != null ); - /* Clear any prior statistics */ - Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); - //for(i=sqliteHashFirst(&db.aDb[iDb].pSchema.idxHash);i;i=sqliteHashNext(i)){ - for ( i = db.aDb[iDb].pSchema.idxHash.first; i != null; i = i.next ) - { - Index pIdx = (Index)i.data;// sqliteHashData( i ); - sqlite3DefaultRowEst( pIdx ); - sqlite3DeleteIndexSamples( db, pIdx ); - pIdx.aSample = null; - } + /* + ** Load the content of the sqlite_stat1 and sqlite_stat2 tables. The + ** contents of sqlite_stat1 are used to populate the Index.aiRowEst[] + ** arrays. The contents of sqlite_stat2 are used to populate the + ** Index.aSample[] arrays. + ** + ** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR + ** is returned. In this case, even if SQLITE_ENABLE_STAT2 was defined + ** during compilation and the sqlite_stat2 table is present, no data is + ** read from it. + ** + ** If SQLITE_ENABLE_STAT2 was defined during compilation and the + ** sqlite_stat2 table is not present in the database, SQLITE_ERROR is + ** returned. However, in this case, data is read from the sqlite_stat1 + ** table (if it is present) before returning. + ** + ** If an OOM error occurs, this function always sets db.mallocFailed. + ** This means if the caller does not care about other errors, the return + ** code may be ignored. + */ + static int sqlite3AnalysisLoad(sqlite3 db, int iDb) { + analysisInfo sInfo; + HashElem i; + string zSql; + int rc; + + Debug.Assert(iDb >= 0 && iDb < db.nDb); + Debug.Assert(db.aDb[iDb].pBt != null); + /* Clear any prior statistics */ + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + //for(i=sqliteHashFirst(&db.aDb[iDb].pSchema.idxHash);i;i=sqliteHashNext(i)){ + for (i = db.aDb[iDb].pSchema.idxHash.first; i != null; i = i.next) { + Index pIdx = (Index)i.data;// sqliteHashData( i ); + sqlite3DefaultRowEst(pIdx); + sqlite3DeleteIndexSamples(db, pIdx); + pIdx.aSample = null; + } - /* Check to make sure the sqlite_stat1 table exists */ - sInfo.db = db; - sInfo.zDatabase = db.aDb[iDb].zName; - if ( sqlite3FindTable( db, "sqlite_stat1", sInfo.zDatabase ) == null ) - { - return SQLITE_ERROR; - } + /* Check to make sure the sqlite_stat1 table exists */ + sInfo.db = db; + sInfo.zDatabase = db.aDb[iDb].zName; + if (sqlite3FindTable(db, "sqlite_stat1", sInfo.zDatabase) == null) { + return SQLITE_ERROR; + } - /* Load new statistics out of the sqlite_stat1 table */ - zSql = sqlite3MPrintf( db, - "SELECT tbl, idx, stat FROM %Q.sqlite_stat1", sInfo.zDatabase ); - //if ( zSql == null ) - //{ - // rc = SQLITE_NOMEM; - //} - //else - { - rc = sqlite3_exec( db, zSql, (dxCallback)analysisLoader, sInfo, 0 ); - sqlite3DbFree( db, ref zSql ); - } + /* Load new statistics out of the sqlite_stat1 table */ + zSql = sqlite3MPrintf(db, + "SELECT tbl, idx, stat FROM %Q.sqlite_stat1", sInfo.zDatabase); + //if ( zSql == null ) + //{ + // rc = SQLITE_NOMEM; + //} + //else + { + rc = sqlite3_exec(db, zSql, (dxCallback)analysisLoader, sInfo, 0); + sqlite3DbFree(db, ref zSql); + } - /* Load the statistics from the sqlite_stat2 table. */ + /* Load the statistics from the sqlite_stat2 table. */ #if SQLITE_ENABLE_STAT2 if ( rc == SQLITE_OK && null == sqlite3FindTable( db, "sqlite_stat2", sInfo.zDatabase ) ) { @@ -855,12 +781,12 @@ static int sqlite3AnalysisLoad( sqlite3 db, int iDb ) } #endif - //if( rc==SQLITE_NOMEM ){ - // db.mallocFailed = 1; - //} - return rc; -} + //if( rc==SQLITE_NOMEM ){ + // db.mallocFailed = 1; + //} + return rc; + } #endif // * SQLITE_OMIT_ANALYZE */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/attach_c.cs b/Src/IronPython.SQLite/c#sqlite/attach_c.cs index ede667540..16149bd60 100644 --- a/Src/IronPython.SQLite/c#sqlite/attach_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/attach_c.cs @@ -3,214 +3,195 @@ using System.Text; using u8 = System.Byte; -using u32 = System.UInt32; -namespace Community.CsharpSqlite -{ - using sqlite3_value = Sqlite3.Mem; - - public partial class Sqlite3 - { -/* -** 2003 April 6 -** -** 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 contains code used to implement the ATTACH and DETACH commands. -************************************************************************* -** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart -** C#-SQLite is an independent reimplementation of the SQLite software library -** -** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 -** -************************************************************************* -*/ -//#include "sqliteInt.h" +namespace Community.CsharpSqlite { + using sqlite3_value = Sqlite3.Mem; + + public partial class Sqlite3 { + /* + ** 2003 April 6 + ** + ** 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 contains code used to implement the ATTACH and DETACH commands. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" #if !SQLITE_OMIT_ATTACH -/* -** Resolve an expression that was part of an ATTACH or DETACH statement. This -** is slightly different from resolving a normal SQL expression, because simple -** identifiers are treated as strings, not possible column names or aliases. -** -** i.e. if the parser sees: -** -** ATTACH DATABASE abc AS def -** -** it treats the two expressions as literal strings 'abc' and 'def' instead of -** looking for columns of the same name. -** -** This only applies to the root node of pExpr, so the statement: -** -** ATTACH DATABASE abc||def AS 'db2' -** -** will fail because neither abc or def can be resolved. -*/ -static int resolveAttachExpr( NameContext pName, Expr pExpr ) -{ - int rc = SQLITE_OK; - if ( pExpr != null ) - { - if ( pExpr.op != TK_ID ) - { - rc = sqlite3ResolveExprNames( pName, ref pExpr ); - if ( rc == SQLITE_OK && sqlite3ExprIsConstant( pExpr ) == 0 ) - { - sqlite3ErrorMsg( pName.pParse, "invalid name: \"%s\"", pExpr.u.zToken ); - return SQLITE_ERROR; - } - } - else - { - pExpr.op = TK_STRING; - } - } - return rc; -} - -/* -** An SQL user-function registered to do the work of an ATTACH statement. The -** three arguments to the function come directly from an attach statement: -** -** ATTACH DATABASE x AS y KEY z -** -** SELECT sqlite_attach(x, y, z) -** -** If the optional "KEY z" syntax is omitted, an SQL NULL is passed as the -** third argument. -*/ -static void attachFunc( -sqlite3_context context, -int NotUsed, -sqlite3_value[] argv -) -{ - int i; - int rc = 0; - sqlite3 db = sqlite3_context_db_handle( context ); - string zName; - string zFile; - string zPath = ""; - string zErr = ""; - int flags; - - Db aNew = null; - string zErrDyn = ""; - sqlite3_vfs pVfs = null; - - UNUSED_PARAMETER( NotUsed ); - - zFile = argv[0].z != null && ( argv[0].z.Length > 0 ) && argv[0].flags != MEM_Null ? sqlite3_value_text( argv[0] ) : ""; - zName = argv[1].z != null && ( argv[1].z.Length > 0 ) && argv[1].flags != MEM_Null ? sqlite3_value_text( argv[1] ) : ""; - //if( zFile==null ) zFile = ""; - //if ( zName == null ) zName = ""; - - - /* Check for the following errors: - ** - ** * Too many attached databases, - ** * Transaction currently open - ** * Specified database name already being used. - */ - if ( db.nDb >= db.aLimit[SQLITE_LIMIT_ATTACHED] + 2 ) - { - zErrDyn = sqlite3MPrintf( db, "too many attached databases - max %d", - db.aLimit[SQLITE_LIMIT_ATTACHED] - ); - goto attach_error; - } - if ( 0 == db.autoCommit ) - { - zErrDyn = sqlite3MPrintf( db, "cannot ATTACH database within transaction" ); - goto attach_error; - } - for ( i = 0; i < db.nDb; i++ ) - { - string z = db.aDb[i].zName; - Debug.Assert( z != null && zName != null ); - if ( z.Equals( zName, StringComparison.OrdinalIgnoreCase ) ) - { - zErrDyn = sqlite3MPrintf( db, "database %s is already in use", zName ); - goto attach_error; - } - } + /* + ** Resolve an expression that was part of an ATTACH or DETACH statement. This + ** is slightly different from resolving a normal SQL expression, because simple + ** identifiers are treated as strings, not possible column names or aliases. + ** + ** i.e. if the parser sees: + ** + ** ATTACH DATABASE abc AS def + ** + ** it treats the two expressions as literal strings 'abc' and 'def' instead of + ** looking for columns of the same name. + ** + ** This only applies to the root node of pExpr, so the statement: + ** + ** ATTACH DATABASE abc||def AS 'db2' + ** + ** will fail because neither abc or def can be resolved. + */ + static int resolveAttachExpr(NameContext pName, Expr pExpr) { + int rc = SQLITE_OK; + if (pExpr != null) { + if (pExpr.op != TK_ID) { + rc = sqlite3ResolveExprNames(pName, ref pExpr); + if (rc == SQLITE_OK && sqlite3ExprIsConstant(pExpr) == 0) { + sqlite3ErrorMsg(pName.pParse, "invalid name: \"%s\"", pExpr.u.zToken); + return SQLITE_ERROR; + } + } else { + pExpr.op = TK_STRING; + } + } + return rc; + } - /* Allocate the new entry in the db.aDb[] array and initialise the schema - ** hash tables. - */ - /* Allocate the new entry in the db.aDb[] array and initialise the schema - ** hash tables. - */ - //if( db.aDb==db.aDbStatic ){ - // aNew = sqlite3DbMallocRaw(db, sizeof(db.aDb[0])*3 ); - // if( aNew==0 ) return; - // memcpy(aNew, db.aDb, sizeof(db.aDb[0])*2); - //}else { - if ( db.aDb.Length <= db.nDb ) - Array.Resize( ref db.aDb, db.nDb + 1 );//aNew = sqlite3DbRealloc(db, db.aDb, sizeof(db.aDb[0])*(db.nDb+1) ); - if ( db.aDb == null ) - return; // if( aNew==0 ) return; - //} - db.aDb[db.nDb] = new Db();//db.aDb = aNew; - aNew = db.aDb[db.nDb];//memset(aNew, 0, sizeof(*aNew)); - // memset(aNew, 0, sizeof(*aNew)); - - /* Open the database file. If the btree is successfully opened, use - ** it to obtain the database schema. At this point the schema may - ** or may not be initialised. - */ - flags = (int)db.openFlags; - rc = sqlite3ParseUri( vfsList.zName, zFile, ref flags, ref pVfs, ref zPath, ref zErr ); - if ( rc != SQLITE_OK ) - { - //if ( rc == SQLITE_NOMEM ) - //db.mallocFailed = 1; - sqlite3_result_error( context, zErr, -1 ); - //sqlite3_free( zErr ); - return; - } - Debug.Assert( pVfs != null); - flags |= SQLITE_OPEN_MAIN_DB; - rc = sqlite3BtreeOpen( pVfs, zPath, db, ref aNew.pBt, 0, (int)flags ); - //sqlite3_free( zPath ); - - db.nDb++; - if ( rc == SQLITE_CONSTRAINT ) - { - rc = SQLITE_ERROR; - zErrDyn = sqlite3MPrintf( db, "database is already attached" ); - } - else if ( rc == SQLITE_OK ) - { - Pager pPager; - aNew.pSchema = sqlite3SchemaGet( db, aNew.pBt ); - //if ( aNew.pSchema == null ) - //{ - // rc = SQLITE_NOMEM; - //} - //else - if ( aNew.pSchema.file_format != 0 && aNew.pSchema.enc != ENC( db ) ) - { - zErrDyn = sqlite3MPrintf( db, - "attached databases must use the same text encoding as main database" ); - rc = SQLITE_ERROR; - } - pPager = sqlite3BtreePager( aNew.pBt ); - sqlite3PagerLockingMode( pPager, db.dfltLockMode ); - sqlite3BtreeSecureDelete( aNew.pBt, - sqlite3BtreeSecureDelete( db.aDb[0].pBt, -1 ) ); - } - aNew.safety_level = 3; - aNew.zName = zName;//sqlite3DbStrDup(db, zName); - //if( rc==SQLITE_OK && aNew.zName==0 ){ - // rc = SQLITE_NOMEM; - //} + /* + ** An SQL user-function registered to do the work of an ATTACH statement. The + ** three arguments to the function come directly from an attach statement: + ** + ** ATTACH DATABASE x AS y KEY z + ** + ** SELECT sqlite_attach(x, y, z) + ** + ** If the optional "KEY z" syntax is omitted, an SQL NULL is passed as the + ** third argument. + */ + static void attachFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] argv + ) { + int i; + int rc = 0; + sqlite3 db = sqlite3_context_db_handle(context); + string zName; + string zFile; + string zPath = ""; + string zErr = ""; + int flags; + + Db aNew = null; + string zErrDyn = ""; + sqlite3_vfs pVfs = null; + + UNUSED_PARAMETER(NotUsed); + + zFile = argv[0].z != null && (argv[0].z.Length > 0) && argv[0].flags != MEM_Null ? sqlite3_value_text(argv[0]) : ""; + zName = argv[1].z != null && (argv[1].z.Length > 0) && argv[1].flags != MEM_Null ? sqlite3_value_text(argv[1]) : ""; + //if( zFile==null ) zFile = ""; + //if ( zName == null ) zName = ""; + + + /* Check for the following errors: + ** + ** * Too many attached databases, + ** * Transaction currently open + ** * Specified database name already being used. + */ + if (db.nDb >= db.aLimit[SQLITE_LIMIT_ATTACHED] + 2) { + zErrDyn = sqlite3MPrintf(db, "too many attached databases - max %d", + db.aLimit[SQLITE_LIMIT_ATTACHED] + ); + goto attach_error; + } + if (0 == db.autoCommit) { + zErrDyn = sqlite3MPrintf(db, "cannot ATTACH database within transaction"); + goto attach_error; + } + for (i = 0; i < db.nDb; i++) { + string z = db.aDb[i].zName; + Debug.Assert(z != null && zName != null); + if (z.Equals(zName, StringComparison.OrdinalIgnoreCase)) { + zErrDyn = sqlite3MPrintf(db, "database %s is already in use", zName); + goto attach_error; + } + } + + /* Allocate the new entry in the db.aDb[] array and initialise the schema + ** hash tables. + */ + /* Allocate the new entry in the db.aDb[] array and initialise the schema + ** hash tables. + */ + //if( db.aDb==db.aDbStatic ){ + // aNew = sqlite3DbMallocRaw(db, sizeof(db.aDb[0])*3 ); + // if( aNew==0 ) return; + // memcpy(aNew, db.aDb, sizeof(db.aDb[0])*2); + //}else { + if (db.aDb.Length <= db.nDb) + Array.Resize(ref db.aDb, db.nDb + 1);//aNew = sqlite3DbRealloc(db, db.aDb, sizeof(db.aDb[0])*(db.nDb+1) ); + if (db.aDb == null) + return; // if( aNew==0 ) return; + //} + db.aDb[db.nDb] = new Db();//db.aDb = aNew; + aNew = db.aDb[db.nDb];//memset(aNew, 0, sizeof(*aNew)); + // memset(aNew, 0, sizeof(*aNew)); + + /* Open the database file. If the btree is successfully opened, use + ** it to obtain the database schema. At this point the schema may + ** or may not be initialised. + */ + flags = (int)db.openFlags; + rc = sqlite3ParseUri(vfsList.zName, zFile, ref flags, ref pVfs, ref zPath, ref zErr); + if (rc != SQLITE_OK) { + //if ( rc == SQLITE_NOMEM ) + //db.mallocFailed = 1; + sqlite3_result_error(context, zErr, -1); + //sqlite3_free( zErr ); + return; + } + Debug.Assert(pVfs != null); + flags |= SQLITE_OPEN_MAIN_DB; + rc = sqlite3BtreeOpen(pVfs, zPath, db, ref aNew.pBt, 0, (int)flags); + //sqlite3_free( zPath ); + + db.nDb++; + if (rc == SQLITE_CONSTRAINT) { + rc = SQLITE_ERROR; + zErrDyn = sqlite3MPrintf(db, "database is already attached"); + } else if (rc == SQLITE_OK) { + Pager pPager; + aNew.pSchema = sqlite3SchemaGet(db, aNew.pBt); + //if ( aNew.pSchema == null ) + //{ + // rc = SQLITE_NOMEM; + //} + //else + if (aNew.pSchema.file_format != 0 && aNew.pSchema.enc != ENC(db)) { + zErrDyn = sqlite3MPrintf(db, + "attached databases must use the same text encoding as main database"); + rc = SQLITE_ERROR; + } + pPager = sqlite3BtreePager(aNew.pBt); + sqlite3PagerLockingMode(pPager, db.dfltLockMode); + sqlite3BtreeSecureDelete(aNew.pBt, + sqlite3BtreeSecureDelete(db.aDb[0].pBt, -1)); + } + aNew.safety_level = 3; + aNew.zName = zName;//sqlite3DbStrDup(db, zName); + //if( rc==SQLITE_OK && aNew.zName==0 ){ + // rc = SQLITE_NOMEM; + //} #if SQLITE_HAS_CODEC if ( rc == SQLITE_OK ) @@ -247,151 +228,136 @@ sqlite3_value[] argv } #endif - /* If the file was opened successfully, read the schema for the new database. -** If this fails, or if opening the file failed, then close the file and -** remove the entry from the db.aDb[] array. i.e. put everything back the way -** we found it. -*/ - if ( rc == SQLITE_OK ) - { - sqlite3BtreeEnterAll( db ); - rc = sqlite3Init( db, ref zErrDyn ); - sqlite3BtreeLeaveAll( db ); - } - if ( rc != 0 ) - { - int iDb = db.nDb - 1; - Debug.Assert( iDb >= 2 ); - if ( db.aDb[iDb].pBt != null ) - { - sqlite3BtreeClose( ref db.aDb[iDb].pBt ); - db.aDb[iDb].pBt = null; - db.aDb[iDb].pSchema = null; - } - sqlite3ResetInternalSchema( db, -1 ); - db.nDb = iDb; - if ( rc == SQLITE_NOMEM || rc == SQLITE_IOERR_NOMEM ) - { - //// db.mallocFailed = 1; - sqlite3DbFree( db, ref zErrDyn ); - zErrDyn = sqlite3MPrintf( db, "out of memory" ); - } - else if ( zErrDyn == "" ) - { - zErrDyn = sqlite3MPrintf( db, "unable to open database: %s", zFile ); - } - goto attach_error; - } - - return; - -attach_error: - /* Return an error if we get here */ - if ( zErrDyn != "" ) - { - sqlite3_result_error( context, zErrDyn, -1 ); - sqlite3DbFree( db, ref zErrDyn ); - } - if ( rc != 0 ) - sqlite3_result_error_code( context, rc ); -} - -/* -** An SQL user-function registered to do the work of an DETACH statement. The -** three arguments to the function come directly from a detach statement: -** -** DETACH DATABASE x -** -** SELECT sqlite_detach(x) -*/ -static void detachFunc( -sqlite3_context context, -int NotUsed, -sqlite3_value[] argv -) -{ - string zName = zName = argv[0].z != null && ( argv[0].z.Length > 0 ) ? sqlite3_value_text( argv[0] ) : "";//(sqlite3_value_text(argv[0]); - sqlite3 db = sqlite3_context_db_handle( context ); - int i; - Db pDb = null; - StringBuilder zErr = new StringBuilder( 200 ); - - UNUSED_PARAMETER( NotUsed ); - - if ( zName == null ) - zName = ""; - for ( i = 0; i < db.nDb; i++ ) - { - pDb = db.aDb[i]; - if ( pDb.pBt == null ) - continue; - if ( pDb.zName.Equals( zName, StringComparison.OrdinalIgnoreCase ) ) - break; - } - - if ( i >= db.nDb ) - { - sqlite3_snprintf( 200, zErr, "no such database: %s", zName ); - goto detach_error; - } - if ( i < 2 ) - { - sqlite3_snprintf( 200, zErr, "cannot detach database %s", zName ); - goto detach_error; - } - if ( 0 == db.autoCommit ) - { - sqlite3_snprintf( 200, zErr, - "cannot DETACH database within transaction" ); - goto detach_error; - } - if ( sqlite3BtreeIsInReadTrans( pDb.pBt ) || sqlite3BtreeIsInBackup( pDb.pBt ) ) - { - sqlite3_snprintf( 200, zErr, "database %s is locked", zName ); - goto detach_error; - } + /* If the file was opened successfully, read the schema for the new database. + ** If this fails, or if opening the file failed, then close the file and + ** remove the entry from the db.aDb[] array. i.e. put everything back the way + ** we found it. + */ + if (rc == SQLITE_OK) { + sqlite3BtreeEnterAll(db); + rc = sqlite3Init(db, ref zErrDyn); + sqlite3BtreeLeaveAll(db); + } + if (rc != 0) { + int iDb = db.nDb - 1; + Debug.Assert(iDb >= 2); + if (db.aDb[iDb].pBt != null) { + sqlite3BtreeClose(ref db.aDb[iDb].pBt); + db.aDb[iDb].pBt = null; + db.aDb[iDb].pSchema = null; + } + sqlite3ResetInternalSchema(db, -1); + db.nDb = iDb; + if (rc == SQLITE_NOMEM || rc == SQLITE_IOERR_NOMEM) { + //// db.mallocFailed = 1; + sqlite3DbFree(db, ref zErrDyn); + zErrDyn = sqlite3MPrintf(db, "out of memory"); + } else if (zErrDyn == "") { + zErrDyn = sqlite3MPrintf(db, "unable to open database: %s", zFile); + } + goto attach_error; + } + + return; + + attach_error: + /* Return an error if we get here */ + if (zErrDyn != "") { + sqlite3_result_error(context, zErrDyn, -1); + sqlite3DbFree(db, ref zErrDyn); + } + if (rc != 0) + sqlite3_result_error_code(context, rc); + } - sqlite3BtreeClose( ref pDb.pBt ); - pDb.pBt = null; - pDb.pSchema = null; - sqlite3ResetInternalSchema( db, -1 ); - return; + /* + ** An SQL user-function registered to do the work of an DETACH statement. The + ** three arguments to the function come directly from a detach statement: + ** + ** DETACH DATABASE x + ** + ** SELECT sqlite_detach(x) + */ + static void detachFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] argv + ) { + string zName = zName = argv[0].z != null && (argv[0].z.Length > 0) ? sqlite3_value_text(argv[0]) : "";//(sqlite3_value_text(argv[0]); + sqlite3 db = sqlite3_context_db_handle(context); + int i; + Db pDb = null; + StringBuilder zErr = new StringBuilder(200); + + UNUSED_PARAMETER(NotUsed); + + if (zName == null) + zName = ""; + for (i = 0; i < db.nDb; i++) { + pDb = db.aDb[i]; + if (pDb.pBt == null) + continue; + if (pDb.zName.Equals(zName, StringComparison.OrdinalIgnoreCase)) + break; + } + + if (i >= db.nDb) { + sqlite3_snprintf(200, zErr, "no such database: %s", zName); + goto detach_error; + } + if (i < 2) { + sqlite3_snprintf(200, zErr, "cannot detach database %s", zName); + goto detach_error; + } + if (0 == db.autoCommit) { + sqlite3_snprintf(200, zErr, + "cannot DETACH database within transaction"); + goto detach_error; + } + if (sqlite3BtreeIsInReadTrans(pDb.pBt) || sqlite3BtreeIsInBackup(pDb.pBt)) { + sqlite3_snprintf(200, zErr, "database %s is locked", zName); + goto detach_error; + } + + sqlite3BtreeClose(ref pDb.pBt); + pDb.pBt = null; + pDb.pSchema = null; + sqlite3ResetInternalSchema(db, -1); + return; + + detach_error: + sqlite3_result_error(context, zErr.ToString(), -1); + } -detach_error: - sqlite3_result_error( context, zErr.ToString(), -1 ); -} - -/* -** This procedure generates VDBE code for a single invocation of either the -** sqlite_detach() or sqlite_attach() SQL user functions. -*/ -static void codeAttach( -Parse pParse, /* The parser context */ -int type, /* Either SQLITE_ATTACH or SQLITE_DETACH */ -FuncDef pFunc, /* FuncDef wrapper for detachFunc() or attachFunc() */ -Expr pAuthArg, /* Expression to pass to authorization callback */ -Expr pFilename, /* Name of database file */ -Expr pDbname, /* Name of the database to use internally */ -Expr pKey /* Database key for encryption extension */ -) -{ - NameContext sName; - Vdbe v; - sqlite3 db = pParse.db; - int regArgs; - - sName = new NameContext();// memset( &sName, 0, sizeof(NameContext)); - sName.pParse = pParse; - - if ( - SQLITE_OK != resolveAttachExpr( sName, pFilename ) || - SQLITE_OK != resolveAttachExpr( sName, pDbname ) || - SQLITE_OK != resolveAttachExpr( sName, pKey ) - ) - { - pParse.nErr++; - goto attach_end; - } + /* + ** This procedure generates VDBE code for a single invocation of either the + ** sqlite_detach() or sqlite_attach() SQL user functions. + */ + static void codeAttach( + Parse pParse, /* The parser context */ + int type, /* Either SQLITE_ATTACH or SQLITE_DETACH */ + FuncDef pFunc, /* FuncDef wrapper for detachFunc() or attachFunc() */ + Expr pAuthArg, /* Expression to pass to authorization callback */ + Expr pFilename, /* Name of database file */ + Expr pDbname, /* Name of the database to use internally */ + Expr pKey /* Database key for encryption extension */ + ) { + NameContext sName; + Vdbe v; + sqlite3 db = pParse.db; + int regArgs; + + sName = new NameContext();// memset( &sName, 0, sizeof(NameContext)); + sName.pParse = pParse; + + if ( + SQLITE_OK != resolveAttachExpr(sName, pFilename) || + SQLITE_OK != resolveAttachExpr(sName, pDbname) || + SQLITE_OK != resolveAttachExpr(sName, pKey) + ) { + pParse.nErr++; + goto attach_end; + } #if !SQLITE_OMIT_AUTHORIZATION if( pAuthArg ){ @@ -408,258 +374,230 @@ static void codeAttach( } #endif //* SQLITE_OMIT_AUTHORIZATION */ - v = sqlite3GetVdbe( pParse ); - regArgs = sqlite3GetTempRange( pParse, 4 ); - sqlite3ExprCode( pParse, pFilename, regArgs ); - sqlite3ExprCode( pParse, pDbname, regArgs + 1 ); - sqlite3ExprCode( pParse, pKey, regArgs + 2 ); - - Debug.Assert( v != null /*|| db.mallocFailed != 0 */ ); - if ( v != null ) - { - sqlite3VdbeAddOp3( v, OP_Function, 0, regArgs + 3 - pFunc.nArg, regArgs + 3 ); - Debug.Assert( pFunc.nArg == -1 || ( pFunc.nArg & 0xff ) == pFunc.nArg ); - sqlite3VdbeChangeP5( v, (u8)( pFunc.nArg ) ); - sqlite3VdbeChangeP4( v, -1, pFunc, P4_FUNCDEF ); - - /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this - ** statement only). For DETACH, set it to false (expire all existing - ** statements). - */ - sqlite3VdbeAddOp1( v, OP_Expire, ( type == SQLITE_ATTACH ) ? 1 : 0 ); - } - -attach_end: - sqlite3ExprDelete( db, ref pFilename ); - sqlite3ExprDelete( db, ref pDbname ); - sqlite3ExprDelete( db, ref pKey ); -} + v = sqlite3GetVdbe(pParse); + regArgs = sqlite3GetTempRange(pParse, 4); + sqlite3ExprCode(pParse, pFilename, regArgs); + sqlite3ExprCode(pParse, pDbname, regArgs + 1); + sqlite3ExprCode(pParse, pKey, regArgs + 2); + + Debug.Assert(v != null /*|| db.mallocFailed != 0 */ ); + if (v != null) { + sqlite3VdbeAddOp3(v, OP_Function, 0, regArgs + 3 - pFunc.nArg, regArgs + 3); + Debug.Assert(pFunc.nArg == -1 || (pFunc.nArg & 0xff) == pFunc.nArg); + sqlite3VdbeChangeP5(v, (u8)(pFunc.nArg)); + sqlite3VdbeChangeP4(v, -1, pFunc, P4_FUNCDEF); + + /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this + ** statement only). For DETACH, set it to false (expire all existing + ** statements). + */ + sqlite3VdbeAddOp1(v, OP_Expire, (type == SQLITE_ATTACH) ? 1 : 0); + } + + attach_end: + sqlite3ExprDelete(db, ref pFilename); + sqlite3ExprDelete(db, ref pDbname); + sqlite3ExprDelete(db, ref pKey); + } -/* -** Called by the parser to compile a DETACH statement. -** -** DETACH pDbname -*/ -static FuncDef detach_func = new FuncDef( -1, /* nArg */ -SQLITE_UTF8, /* iPrefEnc */ -0, /* flags */ -null, /* pUserData */ -null, /* pNext */ -detachFunc, /* xFunc */ -null, /* xStep */ -null, /* xFinalize */ -"sqlite_detach", /* zName */ -null, /* pHash */ -null /* pDestructor */ -); -static void sqlite3Detach( Parse pParse, Expr pDbname ) -{ - codeAttach( pParse, SQLITE_DETACH, detach_func, pDbname, null, null, pDbname ); -} + /* + ** Called by the parser to compile a DETACH statement. + ** + ** DETACH pDbname + */ + static FuncDef detach_func = new FuncDef( + 1, /* nArg */ + SQLITE_UTF8, /* iPrefEnc */ + 0, /* flags */ + null, /* pUserData */ + null, /* pNext */ + detachFunc, /* xFunc */ + null, /* xStep */ + null, /* xFinalize */ + "sqlite_detach", /* zName */ + null, /* pHash */ + null /* pDestructor */ + ); + static void sqlite3Detach(Parse pParse, Expr pDbname) { + codeAttach(pParse, SQLITE_DETACH, detach_func, pDbname, null, null, pDbname); + } -/* -** Called by the parser to compile an ATTACH statement. -** -** ATTACH p AS pDbname KEY pKey -*/ -static FuncDef attach_func = new FuncDef( -3, /* nArg */ -SQLITE_UTF8, /* iPrefEnc */ -0, /* flags */ -null, /* pUserData */ -null, /* pNext */ -attachFunc, /* xFunc */ -null, /* xStep */ -null, /* xFinalize */ -"sqlite_attach", /* zName */ -null, /* pHash */ -null /* pDestructor */ -); -static void sqlite3Attach( Parse pParse, Expr p, Expr pDbname, Expr pKey ) -{ - codeAttach( pParse, SQLITE_ATTACH, attach_func, p, p, pDbname, pKey ); -} + /* + ** Called by the parser to compile an ATTACH statement. + ** + ** ATTACH p AS pDbname KEY pKey + */ + static FuncDef attach_func = new FuncDef( + 3, /* nArg */ + SQLITE_UTF8, /* iPrefEnc */ + 0, /* flags */ + null, /* pUserData */ + null, /* pNext */ + attachFunc, /* xFunc */ + null, /* xStep */ + null, /* xFinalize */ + "sqlite_attach", /* zName */ + null, /* pHash */ + null /* pDestructor */ + ); + static void sqlite3Attach(Parse pParse, Expr p, Expr pDbname, Expr pKey) { + codeAttach(pParse, SQLITE_ATTACH, attach_func, p, p, pDbname, pKey); + } #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. -*/ -static 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 */ -string zType, /* "view", "trigger", or "index" */ -Token pName /* Name of the view, trigger, or index */ -) -{ - sqlite3 db; - - if ( NEVER( iDb < 0 ) || iDb == 1 ) - return 0; - db = pParse.db; - Debug.Assert( db.nDb > iDb ); - pFix.pParse = pParse; - pFix.zDb = db.aDb[iDb].zName; - pFix.zType = zType; - pFix.pName = pName; - return 1; -} + /* + ** 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. + */ + static 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 */ + string zType, /* "view", "trigger", or "index" */ + Token pName /* Name of the view, trigger, or index */ + ) { + sqlite3 db; + + if (NEVER(iDb < 0) || iDb == 1) + return 0; + db = pParse.db; + Debug.Assert(db.nDb > iDb); + pFix.pParse = pParse; + pFix.zDb = db.aDb[iDb].zName; + pFix.zType = zType; + pFix.pName = pName; + 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 -** was left unspecified in the original SQL statement. The pFix structure -** must have been initialized by a prior call to sqlite3FixInit(). -** -** These routines are used to make sure that an index, trigger, or -** view in one database does not refer to objects in a different database. -** (Exception: indices, triggers, and views in the TEMP database are -** allowed to refer to anything.) If a reference is explicitly made -** to an object in a different database, an error message is added to -** pParse.zErrMsg and these routines return non-zero. If everything -** checks out, these routines return 0. -*/ -static int sqlite3FixSrcList( -DbFixer pFix, /* Context of the fixation */ -SrcList pList /* The Source list to check and modify */ -) -{ - int i; - string zDb; - SrcList_item pItem; - - if ( NEVER( pList == null ) ) - return 0; - zDb = pFix.zDb; - for ( i = 0; i < pList.nSrc; i++ ) - {//, pItem++){ - pItem = pList.a[i]; - if ( pItem.zDatabase == null ) - { - pItem.zDatabase = zDb;// sqlite3DbStrDup( pFix.pParse.db, zDb ); - } - else if ( !pItem.zDatabase.Equals( zDb ,StringComparison.OrdinalIgnoreCase ) ) - { - sqlite3ErrorMsg( pFix.pParse, - "%s %T cannot reference objects in database %s", - pFix.zType, pFix.pName, pItem.zDatabase ); - 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 + ** was left unspecified in the original SQL statement. The pFix structure + ** must have been initialized by a prior call to sqlite3FixInit(). + ** + ** These routines are used to make sure that an index, trigger, or + ** view in one database does not refer to objects in a different database. + ** (Exception: indices, triggers, and views in the TEMP database are + ** allowed to refer to anything.) If a reference is explicitly made + ** to an object in a different database, an error message is added to + ** pParse.zErrMsg and these routines return non-zero. If everything + ** checks out, these routines return 0. + */ + static int sqlite3FixSrcList( + DbFixer pFix, /* Context of the fixation */ + SrcList pList /* The Source list to check and modify */ + ) { + int i; + string zDb; + SrcList_item pItem; + + if (NEVER(pList == null)) + return 0; + zDb = pFix.zDb; + for (i = 0; i < pList.nSrc; i++) {//, pItem++){ + pItem = pList.a[i]; + if (pItem.zDatabase == null) { + pItem.zDatabase = zDb;// sqlite3DbStrDup( pFix.pParse.db, zDb ); + } else if (!pItem.zDatabase.Equals(zDb, StringComparison.OrdinalIgnoreCase)) { + sqlite3ErrorMsg(pFix.pParse, + "%s %T cannot reference objects in database %s", + pFix.zType, pFix.pName, pItem.zDatabase); + return 1; + } #if !SQLITE_OMIT_VIEW || !SQLITE_OMIT_TRIGGER - if ( sqlite3FixSelect( pFix, pItem.pSelect ) != 0 ) - return 1; - if ( sqlite3FixExpr( pFix, pItem.pOn ) != 0 ) - return 1; + if (sqlite3FixSelect(pFix, pItem.pSelect) != 0) + return 1; + if (sqlite3FixExpr(pFix, pItem.pOn) != 0) + return 1; #endif - } - return 0; -} + } + return 0; + } #if !SQLITE_OMIT_VIEW || !SQLITE_OMIT_TRIGGER -static int sqlite3FixSelect( -DbFixer pFix, /* Context of the fixation */ -Select pSelect /* The SELECT statement to be fixed to one database */ -) -{ - while ( pSelect != null ) - { - if ( sqlite3FixExprList( pFix, pSelect.pEList ) != 0 ) - { - return 1; - } - if ( sqlite3FixSrcList( pFix, pSelect.pSrc ) != 0 ) - { - return 1; - } - if ( sqlite3FixExpr( pFix, pSelect.pWhere ) != 0 ) - { - return 1; - } - if ( sqlite3FixExpr( pFix, pSelect.pHaving ) != 0 ) - { - return 1; - } - pSelect = pSelect.pPrior; - } - return 0; -} -static int sqlite3FixExpr( -DbFixer pFix, /* Context of the fixation */ -Expr pExpr /* The expression to be fixed to one database */ -) -{ - while ( pExpr != null ) - { - if ( ExprHasAnyProperty( pExpr, EP_TokenOnly ) ) - break; - if ( ExprHasProperty( pExpr, EP_xIsSelect ) ) - { - if ( sqlite3FixSelect( pFix, pExpr.x.pSelect ) != 0 ) - return 1; - } - else - { - if ( sqlite3FixExprList( pFix, pExpr.x.pList ) != 0 ) - return 1; - } - if ( sqlite3FixExpr( pFix, pExpr.pRight ) != 0 ) - { - return 1; - } - pExpr = pExpr.pLeft; - } - return 0; -} -static int sqlite3FixExprList( -DbFixer pFix, /* Context of the fixation */ -ExprList pList /* The expression to be fixed to one database */ -) -{ - int i; - ExprList_item pItem; - if ( pList == null ) - return 0; - for ( i = 0; i < pList.nExpr; i++ )//, pItem++ ) - { - pItem = pList.a[i]; - if ( sqlite3FixExpr( pFix, pItem.pExpr ) != 0 ) - { - return 1; - } - } - return 0; -} + static int sqlite3FixSelect( + DbFixer pFix, /* Context of the fixation */ + Select pSelect /* The SELECT statement to be fixed to one database */ + ) { + while (pSelect != null) { + if (sqlite3FixExprList(pFix, pSelect.pEList) != 0) { + return 1; + } + if (sqlite3FixSrcList(pFix, pSelect.pSrc) != 0) { + return 1; + } + if (sqlite3FixExpr(pFix, pSelect.pWhere) != 0) { + return 1; + } + if (sqlite3FixExpr(pFix, pSelect.pHaving) != 0) { + return 1; + } + pSelect = pSelect.pPrior; + } + return 0; + } + static int sqlite3FixExpr( + DbFixer pFix, /* Context of the fixation */ + Expr pExpr /* The expression to be fixed to one database */ + ) { + while (pExpr != null) { + if (ExprHasAnyProperty(pExpr, EP_TokenOnly)) + break; + if (ExprHasProperty(pExpr, EP_xIsSelect)) { + if (sqlite3FixSelect(pFix, pExpr.x.pSelect) != 0) + return 1; + } else { + if (sqlite3FixExprList(pFix, pExpr.x.pList) != 0) + return 1; + } + if (sqlite3FixExpr(pFix, pExpr.pRight) != 0) { + return 1; + } + pExpr = pExpr.pLeft; + } + return 0; + } + static int sqlite3FixExprList( + DbFixer pFix, /* Context of the fixation */ + ExprList pList /* The expression to be fixed to one database */ + ) { + int i; + ExprList_item pItem; + if (pList == null) + return 0; + for (i = 0; i < pList.nExpr; i++)//, pItem++ ) + { + pItem = pList.a[i]; + if (sqlite3FixExpr(pFix, pItem.pExpr) != 0) { + return 1; + } + } + return 0; + } #endif #if !SQLITE_OMIT_TRIGGER -static int sqlite3FixTriggerStep( -DbFixer pFix, /* Context of the fixation */ -TriggerStep pStep /* The trigger step be fixed to one database */ -) -{ - while ( pStep != null ) - { - if ( sqlite3FixSelect( pFix, pStep.pSelect ) != 0 ) - { - return 1; - } - if ( sqlite3FixExpr( pFix, pStep.pWhere ) != 0 ) - { - return 1; - } - if ( sqlite3FixExprList( pFix, pStep.pExprList ) != 0 ) - { - return 1; - } - pStep = pStep.pNext; - } - return 0; -} + static int sqlite3FixTriggerStep( + DbFixer pFix, /* Context of the fixation */ + TriggerStep pStep /* The trigger step be fixed to one database */ + ) { + while (pStep != null) { + if (sqlite3FixSelect(pFix, pStep.pSelect) != 0) { + return 1; + } + if (sqlite3FixExpr(pFix, pStep.pWhere) != 0) { + return 1; + } + if (sqlite3FixExprList(pFix, pStep.pExprList) != 0) { + return 1; + } + pStep = pStep.pNext; + } + return 0; + } #endif - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/auth_c.cs b/Src/IronPython.SQLite/c#sqlite/auth_c.cs index f2ee6a610..846777e9f 100644 --- a/Src/IronPython.SQLite/c#sqlite/auth_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/auth_c.cs @@ -1,42 +1,34 @@ -using System; -using System.Diagnostics; -using System.Text; +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2003 January 11 + ** + ** 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 contains code used to implement the sqlite3_set_authorizer() + ** API. This facility is an optional feature of the library. Embedded + ** systems that do not need this facility may omit it by recompiling + ** the library with -DSQLITE_OMIT_AUTHORIZATION=1 + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" -namespace Community.CsharpSqlite -{ - using sqlite3_value = Sqlite3.Mem; - - public partial class Sqlite3 - { -/* -** 2003 January 11 -** -** 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 contains code used to implement the sqlite3_set_authorizer() -** API. This facility is an optional feature of the library. Embedded -** systems that do not need this facility may omit it by recompiling -** the library with -DSQLITE_OMIT_AUTHORIZATION=1 -************************************************************************* -** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart -** C#-SQLite is an independent reimplementation of the SQLite software library -** -** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 -** -************************************************************************* -*/ -//#include "sqliteInt.h" - -/* -** All of the code in this file may be omitted by defining a single -** macro. -*/ + /* + ** All of the code in this file may be omitted by defining a single + ** macro. + */ #if !SQLITE_OMIT_AUTHORIZATION /* @@ -263,5 +255,5 @@ void sqlite3AuthContextPop(AuthContext *pContext){ } #endif //* SQLITE_OMIT_AUTHORIZATION */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/backup_c.cs b/Src/IronPython.SQLite/c#sqlite/backup_c.cs index 7936670f6..51939abd2 100644 --- a/Src/IronPython.SQLite/c#sqlite/backup_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/backup_c.cs @@ -1,289 +1,263 @@ using System; using System.Diagnostics; -using System.Text; using i64 = System.Int64; -using u8 = System.Byte; +using Pgno = System.UInt32; using u32 = System.UInt32; -using Pgno = System.UInt32; +namespace Community.CsharpSqlite { + using DbPage = Sqlite3.PgHdr; + public partial class Sqlite3 { + /* + ** 2009 January 28 + ** + ** 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 contains the implementation of the sqlite3_backup_XXX() + ** API functions and the related features. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include "btreeInt.h" -namespace Community.CsharpSqlite -{ - using sqlite3_int64 = System.Int64; - using DbPage = Sqlite3.PgHdr; - public partial class Sqlite3 - { -/* -** 2009 January 28 -** -** 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 contains the implementation of the sqlite3_backup_XXX() -** API functions and the related features. -************************************************************************* -** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart -** C#-SQLite is an independent reimplementation of the SQLite software library -** -** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e -** -************************************************************************* -*/ -//#include "sqliteInt.h" -//#include "btreeInt.h" - -/* Macro to find the minimum of two numeric values. -*/ + /* Macro to find the minimum of two numeric values. + */ #if !MIN -//# define MIN(x,y) ((x)<(y)?(x):(y)) + //# define MIN(x,y) ((x)<(y)?(x):(y)) #endif -/* -** Structure allocated for each backup operation. -*/ -public class sqlite3_backup -{ - public sqlite3 pDestDb; /* Destination database handle */ - public Btree pDest; /* Destination b-tree file */ - public u32 iDestSchema; /* Original schema cookie in destination */ - public int bDestLocked; /* True once a write-transaction is open on pDest */ - - public Pgno iNext; /* Page number of the next source page to copy */ - public sqlite3 pSrcDb; /* Source database handle */ - public Btree pSrc; /* Source b-tree file */ - - public int rc; /* Backup process error code */ - - /* These two variables are set by every call to backup_step(). They are - ** read by calls to backup_remaining() and backup_pagecount(). - */ - public Pgno nRemaining; /* Number of pages left to copy */ - public Pgno nPagecount; /* Total number of pages to copy */ - - public int isAttached; /* True once backup has been registered with pager */ - public sqlite3_backup pNext; /* Next backup associated with source pager */ -}; - -/* -** THREAD SAFETY NOTES: -** -** Once it has been created using backup_init(), a single sqlite3_backup -** structure may be accessed via two groups of thread-safe entry points: -** -** * Via the sqlite3_backup_XXX() API function backup_step() and -** backup_finish(). Both these functions obtain the source database -** handle mutex and the mutex associated with the source BtShared -** structure, in that order. -** -** * Via the BackupUpdate() and BackupRestart() functions, which are -** invoked by the pager layer to report various state changes in -** the page cache associated with the source database. The mutex -** associated with the source database BtShared structure will always -** be held when either of these functions are invoked. -** -** The other sqlite3_backup_XXX() API functions, backup_remaining() and -** backup_pagecount() are not thread-safe functions. If they are called -** while some other thread is calling backup_step() or backup_finish(), -** the values returned may be invalid. There is no way for a call to -** BackupUpdate() or BackupRestart() to interfere with backup_remaining() -** or backup_pagecount(). -** -** Depending on the SQLite configuration, the database handles and/or -** the Btree objects may have their own mutexes that require locking. -** Non-sharable Btrees (in-memory databases for example), do not have -** associated mutexes. -*/ - -/* -** Return a pointer corresponding to database zDb (i.e. "main", "temp") -** in connection handle pDb. If such a database cannot be found, return -** a NULL pointer and write an error message to pErrorDb. -** -** If the "temp" database is requested, it may need to be opened by this -** function. If an error occurs while doing so, return 0 and write an -** error message to pErrorDb. -*/ -static Btree findBtree( sqlite3 pErrorDb, sqlite3 pDb, string zDb ) -{ - int i = sqlite3FindDbName( pDb, zDb ); - - if ( i == 1 ) - { - Parse pParse; - int rc = 0; - pParse = new Parse();//sqlite3StackAllocZero(pErrorDb, sizeof(*pParse)); - if ( pParse == null ) - { - sqlite3Error( pErrorDb, SQLITE_NOMEM, "out of memory" ); - rc = SQLITE_NOMEM; - } - else - { - pParse.db = pDb; - if ( sqlite3OpenTempDatabase( pParse ) != 0 ) - { - sqlite3Error( pErrorDb, pParse.rc, "%s", pParse.zErrMsg ); - rc = SQLITE_ERROR; - } - sqlite3DbFree( pErrorDb, ref pParse.zErrMsg ); - //sqlite3StackFree( pErrorDb, pParse ); - } - if ( rc != 0 ) - { - return null; - } - } - - if ( i < 0 ) - { - sqlite3Error( pErrorDb, SQLITE_ERROR, "unknown database %s", zDb ); - return null; - } - - return pDb.aDb[i].pBt; -} - -/* -** Attempt to set the page size of the destination to match the page size -** of the source. -*/ -static int setDestPgsz( sqlite3_backup p ) -{ - int rc; - rc = sqlite3BtreeSetPageSize( p.pDest, sqlite3BtreeGetPageSize( p.pSrc ), -1, 0 ); - return rc; -} - -/* -** Create an sqlite3_backup process to copy the contents of zSrcDb from -** connection handle pSrcDb to zDestDb in pDestDb. If successful, return -** a pointer to the new sqlite3_backup object. -** -** If an error occurs, NULL is returned and an error code and error message -** stored in database handle pDestDb. -*/ -static public sqlite3_backup sqlite3_backup_init( -sqlite3 pDestDb, /* Database to write to */ -string zDestDb, /* Name of database within pDestDb */ -sqlite3 pSrcDb, /* Database connection to read from */ -string zSrcDb /* Name of database within pSrcDb */ -) -{ - sqlite3_backup p; /* Value to return */ - - /* Lock the source database handle. The destination database - ** handle is not locked in this routine, but it is locked in - ** sqlite3_backup_step(). The user is required to ensure that no - ** other thread accesses the destination handle for the duration - ** of the backup operation. Any attempt to use the destination - ** database connection while a backup is in progress may cause - ** a malfunction or a deadlock. - */ - sqlite3_mutex_enter( pSrcDb.mutex ); - sqlite3_mutex_enter( pDestDb.mutex ); - - if ( pSrcDb == pDestDb ) - { - sqlite3Error( - pDestDb, SQLITE_ERROR, "source and destination must be distinct" - ); - p = null; - } - else - { - /* Allocate space for a new sqlite3_backup object... - ** EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a - ** call to sqlite3_backup_init() and is destroyed by a call to - ** sqlite3_backup_finish(). */ - p = new sqlite3_backup();// (sqlite3_backup)sqlite3_malloc( sizeof( sqlite3_backup ) ); - //if ( null == p ) - //{ - // sqlite3Error( pDestDb, SQLITE_NOMEM, 0 ); - //} - } + /* + ** Structure allocated for each backup operation. + */ + public class sqlite3_backup { + public sqlite3 pDestDb; /* Destination database handle */ + public Btree pDest; /* Destination b-tree file */ + public u32 iDestSchema; /* Original schema cookie in destination */ + public int bDestLocked; /* True once a write-transaction is open on pDest */ + + public Pgno iNext; /* Page number of the next source page to copy */ + public sqlite3 pSrcDb; /* Source database handle */ + public Btree pSrc; /* Source b-tree file */ + + public int rc; /* Backup process error code */ + + /* These two variables are set by every call to backup_step(). They are + ** read by calls to backup_remaining() and backup_pagecount(). + */ + public Pgno nRemaining; /* Number of pages left to copy */ + public Pgno nPagecount; /* Total number of pages to copy */ + + public int isAttached; /* True once backup has been registered with pager */ + public sqlite3_backup pNext; /* Next backup associated with source pager */ + }; + + /* + ** THREAD SAFETY NOTES: + ** + ** Once it has been created using backup_init(), a single sqlite3_backup + ** structure may be accessed via two groups of thread-safe entry points: + ** + ** * Via the sqlite3_backup_XXX() API function backup_step() and + ** backup_finish(). Both these functions obtain the source database + ** handle mutex and the mutex associated with the source BtShared + ** structure, in that order. + ** + ** * Via the BackupUpdate() and BackupRestart() functions, which are + ** invoked by the pager layer to report various state changes in + ** the page cache associated with the source database. The mutex + ** associated with the source database BtShared structure will always + ** be held when either of these functions are invoked. + ** + ** The other sqlite3_backup_XXX() API functions, backup_remaining() and + ** backup_pagecount() are not thread-safe functions. If they are called + ** while some other thread is calling backup_step() or backup_finish(), + ** the values returned may be invalid. There is no way for a call to + ** BackupUpdate() or BackupRestart() to interfere with backup_remaining() + ** or backup_pagecount(). + ** + ** Depending on the SQLite configuration, the database handles and/or + ** the Btree objects may have their own mutexes that require locking. + ** Non-sharable Btrees (in-memory databases for example), do not have + ** associated mutexes. + */ - /* If the allocation succeeded, populate the new object. */ - if ( p != null ) - { - // memset( p, 0, sizeof( sqlite3_backup ) ); - p.pSrc = findBtree( pDestDb, pSrcDb, zSrcDb ); - p.pDest = findBtree( pDestDb, pDestDb, zDestDb ); - p.pDestDb = pDestDb; - p.pSrcDb = pSrcDb; - p.iNext = 1; - p.isAttached = 0; - - if ( null == p.pSrc || null == p.pDest || setDestPgsz( p ) == SQLITE_NOMEM ) - { - /* One (or both) of the named databases did not exist or an OOM - ** error was hit. The error has already been written into the - ** pDestDb handle. All that is left to do here is free the - ** sqlite3_backup structure. - */ - //sqlite3_free( ref p ); - p = null; - } - } + /* + ** Return a pointer corresponding to database zDb (i.e. "main", "temp") + ** in connection handle pDb. If such a database cannot be found, return + ** a NULL pointer and write an error message to pErrorDb. + ** + ** If the "temp" database is requested, it may need to be opened by this + ** function. If an error occurs while doing so, return 0 and write an + ** error message to pErrorDb. + */ + static Btree findBtree(sqlite3 pErrorDb, sqlite3 pDb, string zDb) { + int i = sqlite3FindDbName(pDb, zDb); + + if (i == 1) { + Parse pParse; + int rc = 0; + pParse = new Parse();//sqlite3StackAllocZero(pErrorDb, sizeof(*pParse)); + if (pParse == null) { + sqlite3Error(pErrorDb, SQLITE_NOMEM, "out of memory"); + rc = SQLITE_NOMEM; + } else { + pParse.db = pDb; + if (sqlite3OpenTempDatabase(pParse) != 0) { + sqlite3Error(pErrorDb, pParse.rc, "%s", pParse.zErrMsg); + rc = SQLITE_ERROR; + } + sqlite3DbFree(pErrorDb, ref pParse.zErrMsg); + //sqlite3StackFree( pErrorDb, pParse ); + } + if (rc != 0) { + return null; + } + } + + if (i < 0) { + sqlite3Error(pErrorDb, SQLITE_ERROR, "unknown database %s", zDb); + return null; + } + + return pDb.aDb[i].pBt; + } - if ( p != null ) - { - p.pSrc.nBackup++; - } + /* + ** Attempt to set the page size of the destination to match the page size + ** of the source. + */ + static int setDestPgsz(sqlite3_backup p) { + int rc; + rc = sqlite3BtreeSetPageSize(p.pDest, sqlite3BtreeGetPageSize(p.pSrc), -1, 0); + return rc; + } - sqlite3_mutex_leave( pDestDb.mutex ); - sqlite3_mutex_leave( pSrcDb.mutex ); - return p; -} + /* + ** Create an sqlite3_backup process to copy the contents of zSrcDb from + ** connection handle pSrcDb to zDestDb in pDestDb. If successful, return + ** a pointer to the new sqlite3_backup object. + ** + ** If an error occurs, NULL is returned and an error code and error message + ** stored in database handle pDestDb. + */ + static public sqlite3_backup sqlite3_backup_init( + sqlite3 pDestDb, /* Database to write to */ + string zDestDb, /* Name of database within pDestDb */ + sqlite3 pSrcDb, /* Database connection to read from */ + string zSrcDb /* Name of database within pSrcDb */ + ) { + sqlite3_backup p; /* Value to return */ + + /* Lock the source database handle. The destination database + ** handle is not locked in this routine, but it is locked in + ** sqlite3_backup_step(). The user is required to ensure that no + ** other thread accesses the destination handle for the duration + ** of the backup operation. Any attempt to use the destination + ** database connection while a backup is in progress may cause + ** a malfunction or a deadlock. + */ + sqlite3_mutex_enter(pSrcDb.mutex); + sqlite3_mutex_enter(pDestDb.mutex); + + if (pSrcDb == pDestDb) { + sqlite3Error( + pDestDb, SQLITE_ERROR, "source and destination must be distinct" + ); + p = null; + } else { + /* Allocate space for a new sqlite3_backup object... + ** EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a + ** call to sqlite3_backup_init() and is destroyed by a call to + ** sqlite3_backup_finish(). */ + p = new sqlite3_backup();// (sqlite3_backup)sqlite3_malloc( sizeof( sqlite3_backup ) ); + //if ( null == p ) + //{ + // sqlite3Error( pDestDb, SQLITE_NOMEM, 0 ); + //} + } + + /* If the allocation succeeded, populate the new object. */ + if (p != null) { + // memset( p, 0, sizeof( sqlite3_backup ) ); + p.pSrc = findBtree(pDestDb, pSrcDb, zSrcDb); + p.pDest = findBtree(pDestDb, pDestDb, zDestDb); + p.pDestDb = pDestDb; + p.pSrcDb = pSrcDb; + p.iNext = 1; + p.isAttached = 0; + + if (null == p.pSrc || null == p.pDest || setDestPgsz(p) == SQLITE_NOMEM) { + /* One (or both) of the named databases did not exist or an OOM + ** error was hit. The error has already been written into the + ** pDestDb handle. All that is left to do here is free the + ** sqlite3_backup structure. + */ + //sqlite3_free( ref p ); + p = null; + } + } + + if (p != null) { + p.pSrc.nBackup++; + } + + sqlite3_mutex_leave(pDestDb.mutex); + sqlite3_mutex_leave(pSrcDb.mutex); + return p; + } -/* -** Argument rc is an SQLite error code. Return true if this error is -** considered fatal if encountered during a backup operation. All errors -** are considered fatal except for SQLITE_BUSY and SQLITE_LOCKED. -*/ -static bool isFatalError( int rc ) -{ - return ( rc != SQLITE_OK && rc != SQLITE_BUSY && ALWAYS( rc != SQLITE_LOCKED ) ); -} + /* + ** Argument rc is an SQLite error code. Return true if this error is + ** considered fatal if encountered during a backup operation. All errors + ** are considered fatal except for SQLITE_BUSY and SQLITE_LOCKED. + */ + static bool isFatalError(int rc) { + return (rc != SQLITE_OK && rc != SQLITE_BUSY && ALWAYS(rc != SQLITE_LOCKED)); + } -/* -** Parameter zSrcData points to a buffer containing the data for -** page iSrcPg from the source database. Copy this data into the -** destination database. -*/ -static int backupOnePage( sqlite3_backup p, Pgno iSrcPg, byte[] zSrcData ) -{ - Pager pDestPager = sqlite3BtreePager( p.pDest ); - int nSrcPgsz = sqlite3BtreeGetPageSize( p.pSrc ); - int nDestPgsz = sqlite3BtreeGetPageSize( p.pDest ); - int nCopy = MIN( nSrcPgsz, nDestPgsz ); - i64 iEnd = (i64)iSrcPg * (i64)nSrcPgsz; + /* + ** Parameter zSrcData points to a buffer containing the data for + ** page iSrcPg from the source database. Copy this data into the + ** destination database. + */ + static int backupOnePage(sqlite3_backup p, Pgno iSrcPg, byte[] zSrcData) { + Pager pDestPager = sqlite3BtreePager(p.pDest); + int nSrcPgsz = sqlite3BtreeGetPageSize(p.pSrc); + int nDestPgsz = sqlite3BtreeGetPageSize(p.pDest); + int nCopy = MIN(nSrcPgsz, nDestPgsz); + i64 iEnd = (i64)iSrcPg * (i64)nSrcPgsz; #if SQLITE_HAS_CODEC int nSrcReserve = sqlite3BtreeGetReserve(p.pSrc); int nDestReserve = sqlite3BtreeGetReserve(p.pDest); #endif - int rc = SQLITE_OK; - i64 iOff; + int rc = SQLITE_OK; + i64 iOff; - Debug.Assert( p.bDestLocked != 0 ); - Debug.Assert( !isFatalError( p.rc ) ); - Debug.Assert( iSrcPg != PENDING_BYTE_PAGE( p.pSrc.pBt ) ); - Debug.Assert( zSrcData != null ); + Debug.Assert(p.bDestLocked != 0); + Debug.Assert(!isFatalError(p.rc)); + Debug.Assert(iSrcPg != PENDING_BYTE_PAGE(p.pSrc.pBt)); + Debug.Assert(zSrcData != null); - /* Catch the case where the destination is an in-memory database and the - ** page sizes of the source and destination differ. - */ - if ( nSrcPgsz != nDestPgsz && sqlite3PagerIsMemdb( pDestPager ) ) - { - rc = SQLITE_READONLY; - } + /* Catch the case where the destination is an in-memory database and the + ** page sizes of the source and destination differ. + */ + if (nSrcPgsz != nDestPgsz && sqlite3PagerIsMemdb(pDestPager)) { + rc = SQLITE_READONLY; + } #if SQLITE_HAS_CODEC /* Backup is not possible if the page size of the destination is changing @@ -308,511 +282,456 @@ static int backupOnePage( sqlite3_backup p, Pgno iSrcPg, byte[] zSrcData ) } #endif - /* This loop runs once for each destination page spanned by the source - ** page. For each iteration, variable iOff is set to the byte offset - ** of the destination page. - */ - for ( iOff = iEnd - (i64)nSrcPgsz; rc == SQLITE_OK && iOff < iEnd; iOff += nDestPgsz ) - { - DbPage pDestPg = null; - u32 iDest = (u32)( iOff / nDestPgsz ) + 1; - if ( iDest == PENDING_BYTE_PAGE( p.pDest.pBt ) ) - continue; - if ( SQLITE_OK == ( rc = sqlite3PagerGet( pDestPager, iDest, ref pDestPg ) ) - && SQLITE_OK == ( rc = sqlite3PagerWrite( pDestPg ) ) - ) - { - //string zIn = &zSrcData[iOff%nSrcPgsz]; - byte[] zDestData = sqlite3PagerGetData( pDestPg ); - //string zOut = &zDestData[iOff % nDestPgsz]; - - /* Copy the data from the source page into the destination page. - ** Then clear the Btree layer MemPage.isInit flag. Both this module - ** and the pager code use this trick (clearing the first byte - ** of the page 'extra' space to invalidate the Btree layers - ** cached parse of the page). MemPage.isInit is marked - ** "MUST BE FIRST" for this purpose. - */ - Buffer.BlockCopy( zSrcData, (int)( iOff % nSrcPgsz ), zDestData, (int)( iOff % nDestPgsz ), nCopy );// memcpy( zOut, zIn, nCopy ); - sqlite3PagerGetExtra( pDestPg ).isInit = 0;// ( sqlite3PagerGetExtra( pDestPg ) )[0] = 0; - } - sqlite3PagerUnref( pDestPg ); - } - - return rc; -} - -/* -** If pFile is currently larger than iSize bytes, then truncate it to -** exactly iSize bytes. If pFile is not larger than iSize bytes, then -** this function is a no-op. -** -** Return SQLITE_OK if everything is successful, or an SQLite error -** code if an error occurs. -*/ -static int backupTruncateFile( sqlite3_file pFile, int iSize ) -{ - long iCurrent = 0; - int rc = sqlite3OsFileSize( pFile, ref iCurrent ); - if ( rc == SQLITE_OK && iCurrent > iSize ) - { - rc = sqlite3OsTruncate( pFile, iSize ); - } - return rc; -} - -/* -** Register this backup object with the associated source pager for -** callbacks when pages are changed or the cache invalidated. -*/ -static void attachBackupObject( sqlite3_backup p ) -{ - sqlite3_backup pp; - Debug.Assert( sqlite3BtreeHoldsMutex( p.pSrc ) ); - pp = sqlite3PagerBackupPtr( sqlite3BtreePager( p.pSrc ) ); - p.pNext = pp; - sqlite3BtreePager( p.pSrc ).pBackup = p; //*pp = p; - p.isAttached = 1; -} - -/* -** Copy nPage pages from the source b-tree to the destination. -*/ -static public int sqlite3_backup_step( sqlite3_backup p, int nPage ) -{ - int rc; - int destMode; /* Destination journal mode */ - int pgszSrc = 0; /* Source page size */ - int pgszDest = 0; /* Destination page size */ - - sqlite3_mutex_enter( p.pSrcDb.mutex ); - sqlite3BtreeEnter( p.pSrc ); - if ( p.pDestDb != null ) - { - sqlite3_mutex_enter( p.pDestDb.mutex ); - } - - rc = p.rc; - if ( !isFatalError( rc ) ) - { - Pager pSrcPager = sqlite3BtreePager( p.pSrc ); /* Source pager */ - Pager pDestPager = sqlite3BtreePager( p.pDest ); /* Dest pager */ - int ii; /* Iterator variable */ - Pgno nSrcPage = 0; /* Size of source db in pages */ - int bCloseTrans = 0; /* True if src db requires unlocking */ - - /* If the source pager is currently in a write-transaction, return - ** SQLITE_BUSY immediately. - */ - if ( p.pDestDb != null && p.pSrc.pBt.inTransaction == TRANS_WRITE ) - { - rc = SQLITE_BUSY; - } - else - { - rc = SQLITE_OK; - } - - /* Lock the destination database, if it is not locked already. */ - if ( SQLITE_OK == rc && p.bDestLocked == 0 - && SQLITE_OK == ( rc = sqlite3BtreeBeginTrans( p.pDest, 2 ) ) - ) - { - p.bDestLocked = 1; - sqlite3BtreeGetMeta( p.pDest, BTREE_SCHEMA_VERSION, ref p.iDestSchema ); - } - - /* If there is no open read-transaction on the source database, open - ** one now. If a transaction is opened here, then it will be closed - ** before this function exits. - */ - if ( rc == SQLITE_OK && !sqlite3BtreeIsInReadTrans( p.pSrc ) ) - { - rc = sqlite3BtreeBeginTrans( p.pSrc, 0 ); - bCloseTrans = 1; - } - - /* Do not allow backup if the destination database is in WAL mode - ** and the page sizes are different between source and destination */ - pgszSrc = sqlite3BtreeGetPageSize( p.pSrc ); - pgszDest = sqlite3BtreeGetPageSize( p.pDest ); - destMode = sqlite3PagerGetJournalMode( sqlite3BtreePager( p.pDest ) ); - if ( SQLITE_OK == rc && destMode == PAGER_JOURNALMODE_WAL && pgszSrc != pgszDest ) - { - rc = SQLITE_READONLY; - } - - /* Now that there is a read-lock on the source database, query the - ** source pager for the number of pages in the database. - */ - nSrcPage = sqlite3BtreeLastPage( p.pSrc ); - Debug.Assert( nSrcPage >= 0 ); - - for ( ii = 0; ( nPage < 0 || ii < nPage ) && p.iNext <= nSrcPage && 0 == rc; ii++ ) - { - Pgno iSrcPg = p.iNext; /* Source page number */ - if ( iSrcPg != PENDING_BYTE_PAGE( p.pSrc.pBt ) ) - { - DbPage pSrcPg = null; /* Source page object */ - rc = sqlite3PagerGet( pSrcPager, (u32)iSrcPg, ref pSrcPg ); - if ( rc == SQLITE_OK ) - { - rc = backupOnePage( p, iSrcPg, sqlite3PagerGetData( pSrcPg ) ); - sqlite3PagerUnref( pSrcPg ); + /* This loop runs once for each destination page spanned by the source + ** page. For each iteration, variable iOff is set to the byte offset + ** of the destination page. + */ + for (iOff = iEnd - (i64)nSrcPgsz; rc == SQLITE_OK && iOff < iEnd; iOff += nDestPgsz) { + DbPage pDestPg = null; + u32 iDest = (u32)(iOff / nDestPgsz) + 1; + if (iDest == PENDING_BYTE_PAGE(p.pDest.pBt)) + continue; + if (SQLITE_OK == (rc = sqlite3PagerGet(pDestPager, iDest, ref pDestPg)) + && SQLITE_OK == (rc = sqlite3PagerWrite(pDestPg)) + ) { + //string zIn = &zSrcData[iOff%nSrcPgsz]; + byte[] zDestData = sqlite3PagerGetData(pDestPg); + //string zOut = &zDestData[iOff % nDestPgsz]; + + /* Copy the data from the source page into the destination page. + ** Then clear the Btree layer MemPage.isInit flag. Both this module + ** and the pager code use this trick (clearing the first byte + ** of the page 'extra' space to invalidate the Btree layers + ** cached parse of the page). MemPage.isInit is marked + ** "MUST BE FIRST" for this purpose. + */ + Buffer.BlockCopy(zSrcData, (int)(iOff % nSrcPgsz), zDestData, (int)(iOff % nDestPgsz), nCopy);// memcpy( zOut, zIn, nCopy ); + sqlite3PagerGetExtra(pDestPg).isInit = 0;// ( sqlite3PagerGetExtra( pDestPg ) )[0] = 0; + } + sqlite3PagerUnref(pDestPg); + } + + return rc; } - } - p.iNext++; - } - if ( rc == SQLITE_OK ) - { - p.nPagecount = nSrcPage; - p.nRemaining = ( nSrcPage + 1 - p.iNext ); - if ( p.iNext > nSrcPage ) - { - rc = SQLITE_DONE; - } - else if ( 0 == p.isAttached ) - { - attachBackupObject( p ); - } - } - - /* Update the schema version field in the destination database. This - ** is to make sure that the schema-version really does change in - ** the case where the source and destination databases have the - ** same schema version. - */ - if ( rc == SQLITE_DONE - && ( rc = sqlite3BtreeUpdateMeta( p.pDest, 1, p.iDestSchema + 1 ) ) == SQLITE_OK - ) - { - Pgno nDestTruncate; - if ( p.pDestDb != null ) - { - sqlite3ResetInternalSchema( p.pDestDb, -1 ); - } - - /* Set nDestTruncate to the final number of pages in the destination - ** database. The complication here is that the destination page - ** size may be different to the source page size. - ** - ** If the source page size is smaller than the destination page size, - ** round up. In this case the call to sqlite3OsTruncate() below will - ** fix the size of the file. However it is important to call - ** sqlite3PagerTruncateImage() here so that any pages in the - ** destination file that lie beyond the nDestTruncate page mark are - ** journalled by PagerCommitPhaseOne() before they are destroyed - ** by the file truncation. - */ - Debug.Assert( pgszSrc == sqlite3BtreeGetPageSize( p.pSrc ) ); - Debug.Assert( pgszDest == sqlite3BtreeGetPageSize( p.pDest ) ); - if ( pgszSrc < pgszDest ) - { - int ratio = pgszDest / pgszSrc; - nDestTruncate = (Pgno)( ( nSrcPage + ratio - 1 ) / ratio ); - if ( nDestTruncate == (int)PENDING_BYTE_PAGE( p.pDest.pBt ) ) - { - nDestTruncate--; - } - } - else - { - nDestTruncate = (Pgno)( nSrcPage * ( pgszSrc / pgszDest ) ); - } - sqlite3PagerTruncateImage( pDestPager, nDestTruncate ); - - if ( pgszSrc < pgszDest ) - { - /* If the source page-size is smaller than the destination page-size, - ** two extra things may need to happen: - ** - ** * The destination may need to be truncated, and + /* + ** If pFile is currently larger than iSize bytes, then truncate it to + ** exactly iSize bytes. If pFile is not larger than iSize bytes, then + ** this function is a no-op. ** - ** * Data stored on the pages immediately following the - ** pending-byte page in the source database may need to be - ** copied into the destination database. + ** Return SQLITE_OK if everything is successful, or an SQLite error + ** code if an error occurs. */ - int iSize = (int)( pgszSrc * nSrcPage ); - sqlite3_file pFile = sqlite3PagerFile( pDestPager ); - i64 iOff; - i64 iEnd; - - Debug.Assert( pFile != null ); - Debug.Assert( (i64)nDestTruncate * (i64)pgszDest >= iSize || ( - nDestTruncate == (int)( PENDING_BYTE_PAGE( p.pDest.pBt ) - 1 ) - && iSize >= PENDING_BYTE && iSize <= PENDING_BYTE + pgszDest - ) ); - - /* This call ensures that all data required to recreate the original - ** database has been stored in the journal for pDestPager and the - ** journal synced to disk. So at this point we may safely modify - ** the database file in any way, knowing that if a power failure - ** occurs, the original database will be reconstructed from the - ** journal file. */ - rc = sqlite3PagerCommitPhaseOne( pDestPager, null, true ); - - /* Write the extra pages and truncate the database file as required. */ - iEnd = MIN( PENDING_BYTE + pgszDest, iSize ); - for ( - iOff = PENDING_BYTE + pgszSrc; - rc == SQLITE_OK && iOff < iEnd; - iOff += pgszSrc - ) - { - PgHdr pSrcPg = null; - u32 iSrcPg = (u32)( ( iOff / pgszSrc ) + 1 ); - rc = sqlite3PagerGet( pSrcPager, iSrcPg, ref pSrcPg ); - if ( rc == SQLITE_OK ) - { - byte[] zData = sqlite3PagerGetData( pSrcPg ); - rc = sqlite3OsWrite( pFile, zData, pgszSrc, iOff ); - } - sqlite3PagerUnref( pSrcPg ); - } - if ( rc == SQLITE_OK ) - { - rc = backupTruncateFile( pFile, (int)iSize ); + static int backupTruncateFile(sqlite3_file pFile, int iSize) { + long iCurrent = 0; + int rc = sqlite3OsFileSize(pFile, ref iCurrent); + if (rc == SQLITE_OK && iCurrent > iSize) { + rc = sqlite3OsTruncate(pFile, iSize); + } + return rc; } - /* Sync the database file to disk. */ - if ( rc == SQLITE_OK ) - { - rc = sqlite3PagerSync( pDestPager ); + /* + ** Register this backup object with the associated source pager for + ** callbacks when pages are changed or the cache invalidated. + */ + static void attachBackupObject(sqlite3_backup p) { + sqlite3_backup pp; + Debug.Assert(sqlite3BtreeHoldsMutex(p.pSrc)); + pp = sqlite3PagerBackupPtr(sqlite3BtreePager(p.pSrc)); + p.pNext = pp; + sqlite3BtreePager(p.pSrc).pBackup = p; //*pp = p; + p.isAttached = 1; } - } - else - { - rc = sqlite3PagerCommitPhaseOne( pDestPager, null, false ); - } - - /* Finish committing the transaction to the destination database. */ - if ( SQLITE_OK == rc - && SQLITE_OK == ( rc = sqlite3BtreeCommitPhaseTwo( p.pDest, 0 ) ) - ) - { - rc = SQLITE_DONE; - } - } - /* If bCloseTrans is true, then this function opened a read transaction - ** on the source database. Close the read transaction here. There is - ** no need to check the return values of the btree methods here, as - ** "committing" a read-only transaction cannot fail. - */ - if ( bCloseTrans != 0 ) - { + /* + ** Copy nPage pages from the source b-tree to the destination. + */ + static public int sqlite3_backup_step(sqlite3_backup p, int nPage) { + int rc; + int destMode; /* Destination journal mode */ + int pgszSrc = 0; /* Source page size */ + int pgszDest = 0; /* Destination page size */ + + sqlite3_mutex_enter(p.pSrcDb.mutex); + sqlite3BtreeEnter(p.pSrc); + if (p.pDestDb != null) { + sqlite3_mutex_enter(p.pDestDb.mutex); + } + + rc = p.rc; + if (!isFatalError(rc)) { + Pager pSrcPager = sqlite3BtreePager(p.pSrc); /* Source pager */ + Pager pDestPager = sqlite3BtreePager(p.pDest); /* Dest pager */ + int ii; /* Iterator variable */ + Pgno nSrcPage = 0; /* Size of source db in pages */ + int bCloseTrans = 0; /* True if src db requires unlocking */ + + /* If the source pager is currently in a write-transaction, return + ** SQLITE_BUSY immediately. + */ + if (p.pDestDb != null && p.pSrc.pBt.inTransaction == TRANS_WRITE) { + rc = SQLITE_BUSY; + } else { + rc = SQLITE_OK; + } + + /* Lock the destination database, if it is not locked already. */ + if (SQLITE_OK == rc && p.bDestLocked == 0 + && SQLITE_OK == (rc = sqlite3BtreeBeginTrans(p.pDest, 2)) + ) { + p.bDestLocked = 1; + sqlite3BtreeGetMeta(p.pDest, BTREE_SCHEMA_VERSION, ref p.iDestSchema); + } + + /* If there is no open read-transaction on the source database, open + ** one now. If a transaction is opened here, then it will be closed + ** before this function exits. + */ + if (rc == SQLITE_OK && !sqlite3BtreeIsInReadTrans(p.pSrc)) { + rc = sqlite3BtreeBeginTrans(p.pSrc, 0); + bCloseTrans = 1; + } + + /* Do not allow backup if the destination database is in WAL mode + ** and the page sizes are different between source and destination */ + pgszSrc = sqlite3BtreeGetPageSize(p.pSrc); + pgszDest = sqlite3BtreeGetPageSize(p.pDest); + destMode = sqlite3PagerGetJournalMode(sqlite3BtreePager(p.pDest)); + if (SQLITE_OK == rc && destMode == PAGER_JOURNALMODE_WAL && pgszSrc != pgszDest) { + rc = SQLITE_READONLY; + } + + /* Now that there is a read-lock on the source database, query the + ** source pager for the number of pages in the database. + */ + nSrcPage = sqlite3BtreeLastPage(p.pSrc); + Debug.Assert(nSrcPage >= 0); + + for (ii = 0; (nPage < 0 || ii < nPage) && p.iNext <= nSrcPage && 0 == rc; ii++) { + Pgno iSrcPg = p.iNext; /* Source page number */ + if (iSrcPg != PENDING_BYTE_PAGE(p.pSrc.pBt)) { + DbPage pSrcPg = null; /* Source page object */ + rc = sqlite3PagerGet(pSrcPager, (u32)iSrcPg, ref pSrcPg); + if (rc == SQLITE_OK) { + rc = backupOnePage(p, iSrcPg, sqlite3PagerGetData(pSrcPg)); + sqlite3PagerUnref(pSrcPg); + } + } + p.iNext++; + } + if (rc == SQLITE_OK) { + p.nPagecount = nSrcPage; + p.nRemaining = (nSrcPage + 1 - p.iNext); + if (p.iNext > nSrcPage) { + rc = SQLITE_DONE; + } else if (0 == p.isAttached) { + attachBackupObject(p); + } + } + + + /* Update the schema version field in the destination database. This + ** is to make sure that the schema-version really does change in + ** the case where the source and destination databases have the + ** same schema version. + */ + if (rc == SQLITE_DONE + && (rc = sqlite3BtreeUpdateMeta(p.pDest, 1, p.iDestSchema + 1)) == SQLITE_OK + ) { + Pgno nDestTruncate; + if (p.pDestDb != null) { + sqlite3ResetInternalSchema(p.pDestDb, -1); + } + + /* Set nDestTruncate to the final number of pages in the destination + ** database. The complication here is that the destination page + ** size may be different to the source page size. + ** + ** If the source page size is smaller than the destination page size, + ** round up. In this case the call to sqlite3OsTruncate() below will + ** fix the size of the file. However it is important to call + ** sqlite3PagerTruncateImage() here so that any pages in the + ** destination file that lie beyond the nDestTruncate page mark are + ** journalled by PagerCommitPhaseOne() before they are destroyed + ** by the file truncation. + */ + Debug.Assert(pgszSrc == sqlite3BtreeGetPageSize(p.pSrc)); + Debug.Assert(pgszDest == sqlite3BtreeGetPageSize(p.pDest)); + if (pgszSrc < pgszDest) { + int ratio = pgszDest / pgszSrc; + nDestTruncate = (Pgno)((nSrcPage + ratio - 1) / ratio); + if (nDestTruncate == (int)PENDING_BYTE_PAGE(p.pDest.pBt)) { + nDestTruncate--; + } + } else { + nDestTruncate = (Pgno)(nSrcPage * (pgszSrc / pgszDest)); + } + sqlite3PagerTruncateImage(pDestPager, nDestTruncate); + + if (pgszSrc < pgszDest) { + /* If the source page-size is smaller than the destination page-size, + ** two extra things may need to happen: + ** + ** * The destination may need to be truncated, and + ** + ** * Data stored on the pages immediately following the + ** pending-byte page in the source database may need to be + ** copied into the destination database. + */ + int iSize = (int)(pgszSrc * nSrcPage); + sqlite3_file pFile = sqlite3PagerFile(pDestPager); + i64 iOff; + i64 iEnd; + + Debug.Assert(pFile != null); + Debug.Assert((i64)nDestTruncate * (i64)pgszDest >= iSize || ( + nDestTruncate == (int)(PENDING_BYTE_PAGE(p.pDest.pBt) - 1) + && iSize >= PENDING_BYTE && iSize <= PENDING_BYTE + pgszDest + )); + + /* This call ensures that all data required to recreate the original + ** database has been stored in the journal for pDestPager and the + ** journal synced to disk. So at this point we may safely modify + ** the database file in any way, knowing that if a power failure + ** occurs, the original database will be reconstructed from the + ** journal file. */ + rc = sqlite3PagerCommitPhaseOne(pDestPager, null, true); + + /* Write the extra pages and truncate the database file as required. */ + iEnd = MIN(PENDING_BYTE + pgszDest, iSize); + for ( + iOff = PENDING_BYTE + pgszSrc; + rc == SQLITE_OK && iOff < iEnd; + iOff += pgszSrc + ) { + PgHdr pSrcPg = null; + u32 iSrcPg = (u32)((iOff / pgszSrc) + 1); + rc = sqlite3PagerGet(pSrcPager, iSrcPg, ref pSrcPg); + if (rc == SQLITE_OK) { + byte[] zData = sqlite3PagerGetData(pSrcPg); + rc = sqlite3OsWrite(pFile, zData, pgszSrc, iOff); + } + sqlite3PagerUnref(pSrcPg); + } + if (rc == SQLITE_OK) { + rc = backupTruncateFile(pFile, (int)iSize); + } + + /* Sync the database file to disk. */ + if (rc == SQLITE_OK) { + rc = sqlite3PagerSync(pDestPager); + } + } else { + rc = sqlite3PagerCommitPhaseOne(pDestPager, null, false); + } + + /* Finish committing the transaction to the destination database. */ + if (SQLITE_OK == rc + && SQLITE_OK == (rc = sqlite3BtreeCommitPhaseTwo(p.pDest, 0)) + ) { + rc = SQLITE_DONE; + } + } + + /* If bCloseTrans is true, then this function opened a read transaction + ** on the source database. Close the read transaction here. There is + ** no need to check the return values of the btree methods here, as + ** "committing" a read-only transaction cannot fail. + */ + if (bCloseTrans != 0) { #if !NDEBUG || SQLITE_COVERAGE_TEST - //TESTONLY( int rc2 ); - //TESTONLY( rc2 = ) sqlite3BtreeCommitPhaseOne(p.pSrc, 0); - //TESTONLY( rc2 |= ) sqlite3BtreeCommitPhaseTwo(p.pSrc); - int rc2; - rc2 = sqlite3BtreeCommitPhaseOne( p.pSrc, "" ); - rc2 |= sqlite3BtreeCommitPhaseTwo( p.pSrc, 0 ); - Debug.Assert( rc2 == SQLITE_OK ); + //TESTONLY( int rc2 ); + //TESTONLY( rc2 = ) sqlite3BtreeCommitPhaseOne(p.pSrc, 0); + //TESTONLY( rc2 |= ) sqlite3BtreeCommitPhaseTwo(p.pSrc); + int rc2; + rc2 = sqlite3BtreeCommitPhaseOne(p.pSrc, ""); + rc2 |= sqlite3BtreeCommitPhaseTwo(p.pSrc, 0); + Debug.Assert(rc2 == SQLITE_OK); #else sqlite3BtreeCommitPhaseOne(p.pSrc, null); sqlite3BtreeCommitPhaseTwo(p.pSrc, 0); #endif - } - - if ( rc == SQLITE_IOERR_NOMEM ) - { - rc = SQLITE_NOMEM; - } - p.rc = rc; - } - if ( p.pDestDb != null ) - { - sqlite3_mutex_leave( p.pDestDb.mutex ); - } - sqlite3BtreeLeave( p.pSrc ); - sqlite3_mutex_leave( p.pSrcDb.mutex ); - return rc; -} - -/* -** Release all resources associated with an sqlite3_backup* handle. -*/ -static public int sqlite3_backup_finish( sqlite3_backup p ) -{ - sqlite3_backup pp; /* Ptr to head of pagers backup list */ - sqlite3_mutex mutex; /* Mutex to protect source database */ - int rc; /* Value to return */ - - /* Enter the mutexes */ - if ( p == null ) - return SQLITE_OK; - sqlite3_mutex_enter( p.pSrcDb.mutex ); - sqlite3BtreeEnter( p.pSrc ); - mutex = p.pSrcDb.mutex; - if ( p.pDestDb != null ) - { - sqlite3_mutex_enter( p.pDestDb.mutex ); - } - - /* Detach this backup from the source pager. */ - if ( p.pDestDb != null ) - { - p.pSrc.nBackup--; - } - if ( p.isAttached != 0 ) - { - pp = sqlite3PagerBackupPtr( sqlite3BtreePager( p.pSrc ) ); - while ( pp != p ) - { - pp = ( pp ).pNext; - } - sqlite3BtreePager( p.pSrc ).pBackup = p.pNext; - } - - /* If a transaction is still open on the Btree, roll it back. */ - sqlite3BtreeRollback( p.pDest ); - - /* Set the error code of the destination database handle. */ - rc = ( p.rc == SQLITE_DONE ) ? SQLITE_OK : p.rc; - sqlite3Error( p.pDestDb, rc, 0 ); + } + + if (rc == SQLITE_IOERR_NOMEM) { + rc = SQLITE_NOMEM; + } + p.rc = rc; + } + if (p.pDestDb != null) { + sqlite3_mutex_leave(p.pDestDb.mutex); + } + sqlite3BtreeLeave(p.pSrc); + sqlite3_mutex_leave(p.pSrcDb.mutex); + return rc; + } - /* Exit the mutexes and free the backup context structure. */ - if ( p.pDestDb != null ) - { - sqlite3_mutex_leave( p.pDestDb.mutex ); - } - sqlite3BtreeLeave( p.pSrc ); - if ( p.pDestDb != null ) - { - /* EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a - ** call to sqlite3_backup_init() and is destroyed by a call to - ** sqlite3_backup_finish(). */ - //sqlite3_free( ref p ); - } - sqlite3_mutex_leave( mutex ); - return rc; -} + /* + ** Release all resources associated with an sqlite3_backup* handle. + */ + static public int sqlite3_backup_finish(sqlite3_backup p) { + sqlite3_backup pp; /* Ptr to head of pagers backup list */ + sqlite3_mutex mutex; /* Mutex to protect source database */ + int rc; /* Value to return */ + + /* Enter the mutexes */ + if (p == null) + return SQLITE_OK; + sqlite3_mutex_enter(p.pSrcDb.mutex); + sqlite3BtreeEnter(p.pSrc); + mutex = p.pSrcDb.mutex; + if (p.pDestDb != null) { + sqlite3_mutex_enter(p.pDestDb.mutex); + } + + /* Detach this backup from the source pager. */ + if (p.pDestDb != null) { + p.pSrc.nBackup--; + } + if (p.isAttached != 0) { + pp = sqlite3PagerBackupPtr(sqlite3BtreePager(p.pSrc)); + while (pp != p) { + pp = (pp).pNext; + } + sqlite3BtreePager(p.pSrc).pBackup = p.pNext; + } + + /* If a transaction is still open on the Btree, roll it back. */ + sqlite3BtreeRollback(p.pDest); + + /* Set the error code of the destination database handle. */ + rc = (p.rc == SQLITE_DONE) ? SQLITE_OK : p.rc; + sqlite3Error(p.pDestDb, rc, 0); + + /* Exit the mutexes and free the backup context structure. */ + if (p.pDestDb != null) { + sqlite3_mutex_leave(p.pDestDb.mutex); + } + sqlite3BtreeLeave(p.pSrc); + if (p.pDestDb != null) { + /* EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a + ** call to sqlite3_backup_init() and is destroyed by a call to + ** sqlite3_backup_finish(). */ + //sqlite3_free( ref p ); + } + sqlite3_mutex_leave(mutex); + return rc; + } -/* -** Return the number of pages still to be backed up as of the most recent -** call to sqlite3_backup_step(). -*/ -static int sqlite3_backup_remaining( sqlite3_backup p ) -{ - return (int)p.nRemaining; -} + /* + ** Return the number of pages still to be backed up as of the most recent + ** call to sqlite3_backup_step(). + */ + static int sqlite3_backup_remaining(sqlite3_backup p) { + return (int)p.nRemaining; + } -/* -** Return the total number of pages in the source database as of the most -** recent call to sqlite3_backup_step(). -*/ -static int sqlite3_backup_pagecount( sqlite3_backup p ) -{ - return (int)p.nPagecount; -} + /* + ** Return the total number of pages in the source database as of the most + ** recent call to sqlite3_backup_step(). + */ + static int sqlite3_backup_pagecount(sqlite3_backup p) { + return (int)p.nPagecount; + } -/* -** This function is called after the contents of page iPage of the -** source database have been modified. If page iPage has already been -** copied into the destination database, then the data written to the -** destination is now invalidated. The destination copy of iPage needs -** to be updated with the new data before the backup operation is -** complete. -** -** It is assumed that the mutex associated with the BtShared object -** corresponding to the source database is held when this function is -** called. -*/ -static void sqlite3BackupUpdate( sqlite3_backup pBackup, Pgno iPage, byte[] aData ) -{ - sqlite3_backup p; /* Iterator variable */ - for ( p = pBackup; p != null; p = p.pNext ) - { - Debug.Assert( sqlite3_mutex_held( p.pSrc.pBt.mutex ) ); - if ( !isFatalError( p.rc ) && iPage < p.iNext ) - { - /* The backup process p has already copied page iPage. But now it - ** has been modified by a transaction on the source pager. Copy - ** the new data into the backup. - */ - int rc; - Debug.Assert( p.pDestDb != null ); - sqlite3_mutex_enter( p.pDestDb.mutex ); - rc = backupOnePage( p, iPage, aData ); - sqlite3_mutex_leave( p.pDestDb.mutex ); - Debug.Assert( rc != SQLITE_BUSY && rc != SQLITE_LOCKED ); - if ( rc != SQLITE_OK ) - { - p.rc = rc; - } - } - } -} + /* + ** This function is called after the contents of page iPage of the + ** source database have been modified. If page iPage has already been + ** copied into the destination database, then the data written to the + ** destination is now invalidated. The destination copy of iPage needs + ** to be updated with the new data before the backup operation is + ** complete. + ** + ** It is assumed that the mutex associated with the BtShared object + ** corresponding to the source database is held when this function is + ** called. + */ + static void sqlite3BackupUpdate(sqlite3_backup pBackup, Pgno iPage, byte[] aData) { + sqlite3_backup p; /* Iterator variable */ + for (p = pBackup; p != null; p = p.pNext) { + Debug.Assert(sqlite3_mutex_held(p.pSrc.pBt.mutex)); + if (!isFatalError(p.rc) && iPage < p.iNext) { + /* The backup process p has already copied page iPage. But now it + ** has been modified by a transaction on the source pager. Copy + ** the new data into the backup. + */ + int rc; + Debug.Assert(p.pDestDb != null); + sqlite3_mutex_enter(p.pDestDb.mutex); + rc = backupOnePage(p, iPage, aData); + sqlite3_mutex_leave(p.pDestDb.mutex); + Debug.Assert(rc != SQLITE_BUSY && rc != SQLITE_LOCKED); + if (rc != SQLITE_OK) { + p.rc = rc; + } + } + } + } -/* -** Restart the backup process. This is called when the pager layer -** detects that the database has been modified by an external database -** connection. In this case there is no way of knowing which of the -** pages that have been copied into the destination database are still -** valid and which are not, so the entire process needs to be restarted. -** -** It is assumed that the mutex associated with the BtShared object -** corresponding to the source database is held when this function is -** called. -*/ -static void sqlite3BackupRestart( sqlite3_backup pBackup ) -{ - sqlite3_backup p; /* Iterator variable */ - for ( p = pBackup; p != null; p = p.pNext ) - { - Debug.Assert( sqlite3_mutex_held( p.pSrc.pBt.mutex ) ); - p.iNext = 1; - } -} + /* + ** Restart the backup process. This is called when the pager layer + ** detects that the database has been modified by an external database + ** connection. In this case there is no way of knowing which of the + ** pages that have been copied into the destination database are still + ** valid and which are not, so the entire process needs to be restarted. + ** + ** It is assumed that the mutex associated with the BtShared object + ** corresponding to the source database is held when this function is + ** called. + */ + static void sqlite3BackupRestart(sqlite3_backup pBackup) { + sqlite3_backup p; /* Iterator variable */ + for (p = pBackup; p != null; p = p.pNext) { + Debug.Assert(sqlite3_mutex_held(p.pSrc.pBt.mutex)); + p.iNext = 1; + } + } #if !SQLITE_OMIT_VACUUM -/* -** Copy the complete content of pBtFrom into pBtTo. A transaction -** must be active for both files. -** -** The size of file pTo may be reduced by this operation. If anything -** goes wrong, the transaction on pTo is rolled back. If successful, the -** transaction is committed before returning. -*/ -static int sqlite3BtreeCopyFile( Btree pTo, Btree pFrom ) -{ - int rc; - sqlite3_backup b; - sqlite3BtreeEnter( pTo ); - sqlite3BtreeEnter( pFrom ); - - /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set - ** to 0. This is used by the implementations of sqlite3_backup_step() - ** and sqlite3_backup_finish() to detect that they are being called - ** from this function, not directly by the user. - */ - b = new sqlite3_backup();// memset( &b, 0, sizeof( b ) ); - b.pSrcDb = pFrom.db; - b.pSrc = pFrom; - b.pDest = pTo; - b.iNext = 1; - - /* 0x7FFFFFFF is the hard limit for the number of pages in a database - ** file. By passing this as the number of pages to copy to - ** sqlite3_backup_step(), we can guarantee that the copy finishes - ** within a single call (unless an error occurs). The Debug.Assert() statement - ** checks this assumption - (p.rc) should be set to either SQLITE_DONE - ** or an error code. - */ - sqlite3_backup_step( b, 0x7FFFFFFF ); - Debug.Assert( b.rc != SQLITE_OK ); - rc = sqlite3_backup_finish( b ); - if ( rc == SQLITE_OK ) - { - pTo.pBt.pageSizeFixed = false; - } - - sqlite3BtreeLeave( pFrom ); - sqlite3BtreeLeave( pTo ); - return rc; -} + /* + ** Copy the complete content of pBtFrom into pBtTo. A transaction + ** must be active for both files. + ** + ** The size of file pTo may be reduced by this operation. If anything + ** goes wrong, the transaction on pTo is rolled back. If successful, the + ** transaction is committed before returning. + */ + static int sqlite3BtreeCopyFile(Btree pTo, Btree pFrom) { + int rc; + sqlite3_backup b; + sqlite3BtreeEnter(pTo); + sqlite3BtreeEnter(pFrom); + + /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set + ** to 0. This is used by the implementations of sqlite3_backup_step() + ** and sqlite3_backup_finish() to detect that they are being called + ** from this function, not directly by the user. + */ + b = new sqlite3_backup();// memset( &b, 0, sizeof( b ) ); + b.pSrcDb = pFrom.db; + b.pSrc = pFrom; + b.pDest = pTo; + b.iNext = 1; + + /* 0x7FFFFFFF is the hard limit for the number of pages in a database + ** file. By passing this as the number of pages to copy to + ** sqlite3_backup_step(), we can guarantee that the copy finishes + ** within a single call (unless an error occurs). The Debug.Assert() statement + ** checks this assumption - (p.rc) should be set to either SQLITE_DONE + ** or an error code. + */ + sqlite3_backup_step(b, 0x7FFFFFFF); + Debug.Assert(b.rc != SQLITE_OK); + rc = sqlite3_backup_finish(b); + if (rc == SQLITE_OK) { + pTo.pBt.pageSizeFixed = false; + } + + sqlite3BtreeLeave(pFrom); + sqlite3BtreeLeave(pTo); + return rc; + } #endif //* SQLITE_OMIT_VACUUM */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/bitvec_c.cs b/Src/IronPython.SQLite/c#sqlite/bitvec_c.cs index 6b7414ba0..7df896883 100644 --- a/Src/IronPython.SQLite/c#sqlite/bitvec_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/bitvec_c.cs @@ -1,534 +1,479 @@ using System; using System.Diagnostics; -using System.Runtime.InteropServices; -using Pgno = System.UInt32; +using BITVEC_TELEM = System.Byte; using i64 = System.Int64; using u32 = System.UInt32; -using BITVEC_TELEM = System.Byte; -namespace Community.CsharpSqlite -{ - - public partial class Sqlite3 - { -/* -** 2008 February 16 -** -** 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 implements an object that represents a fixed-length -** bitmap. Bits are numbered starting with 1. -** -** A bitmap is used to record which pages of a database file have been -** journalled during a transaction, or which pages have the "dont-write" -** property. Usually only a few pages are meet either condition. -** So the bitmap is usually sparse and has low cardinality. -** But sometimes (for example when during a DROP of a large table) most -** or all of the pages in a database can get journalled. In those cases, -** the bitmap becomes dense with high cardinality. The algorithm needs -** to handle both cases well. -** -** The size of the bitmap is fixed when the object is created. -** -** All bits are clear when the bitmap is created. Individual bits -** may be set or cleared one at a time. -** -** Test operations are about 100 times more common that set operations. -** Clear operations are exceedingly rare. There are usually between -** 5 and 500 set operations per Bitvec object, though the number of sets can -** sometimes grow into tens of thousands or larger. The size of the -** Bitvec object is the number of pages in the database file at the -** start of a transaction, and is thus usually less than a few thousand, -** but can be as large as 2 billion for a really big database. -************************************************************************* -** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart -** C#-SQLite is an independent reimplementation of the SQLite software library -** -** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 -** -************************************************************************* -*/ -//#include "sqliteInt.h" - -/* Size of the Bitvec structure in bytes. */ -static int BITVEC_SZ = 512; - - -/* Round the union size down to the nearest pointer boundary, since that's how -** it will be aligned within the Bitvec struct. */ -//#define BITVEC_USIZE (((BITVEC_SZ-(3*sizeof(u32)))/sizeof(Bitvec*))*sizeof(Bitvec*)) -static int BITVEC_USIZE = ( ( ( BITVEC_SZ - ( 3 * sizeof( u32 ) ) ) / 4 ) * 4 ); - -/* Type of the array "element" for the bitmap representation. -** Should be a power of 2, and ideally, evenly divide into BITVEC_USIZE. -** Setting this to the "natural word" size of your CPU may improve -** performance. */ -//#define BITVEC_TELEM u8 -//using BITVEC_TELEM = System.Byte; - -/* Size, in bits, of the bitmap element. */ -//#define BITVEC_SZELEM 8 -const int BITVEC_SZELEM = 8; - -/* Number of elements in a bitmap array. */ -//#define BITVEC_NELEM (BITVEC_USIZE/sizeof(BITVEC_TELEM)) -static int BITVEC_NELEM = (int)( BITVEC_USIZE / sizeof( BITVEC_TELEM ) ); - -/* Number of bits in the bitmap array. */ -//#define BITVEC_NBIT (BITVEC_NELEM*BITVEC_SZELEM) -static int BITVEC_NBIT = ( BITVEC_NELEM * BITVEC_SZELEM ); - -/* Number of u32 values in hash table. */ -//#define BITVEC_NINT (BITVEC_USIZE/sizeof(u32)) -static u32 BITVEC_NINT = (u32)( BITVEC_USIZE / sizeof( u32 ) ); - -/* Maximum number of entries in hash table before -** sub-dividing and re-hashing. */ -//#define BITVEC_MXHASH (BITVEC_NINT/2) -static int BITVEC_MXHASH = (int)( BITVEC_NINT / 2 ); - -/* Hashing function for the aHash representation. -** Empirical testing showed that the *37 multiplier -** (an arbitrary prime)in the hash function provided -** no fewer collisions than the no-op *1. */ -//#define BITVEC_HASH(X) (((X)*1)%BITVEC_NINT) -static u32 BITVEC_HASH( u32 X ) -{ - return (u32)( ( ( X ) * 1 ) % BITVEC_NINT ); -} +namespace Community.CsharpSqlite { + + public partial class Sqlite3 { + /* + ** 2008 February 16 + ** + ** 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 implements an object that represents a fixed-length + ** bitmap. Bits are numbered starting with 1. + ** + ** A bitmap is used to record which pages of a database file have been + ** journalled during a transaction, or which pages have the "dont-write" + ** property. Usually only a few pages are meet either condition. + ** So the bitmap is usually sparse and has low cardinality. + ** But sometimes (for example when during a DROP of a large table) most + ** or all of the pages in a database can get journalled. In those cases, + ** the bitmap becomes dense with high cardinality. The algorithm needs + ** to handle both cases well. + ** + ** The size of the bitmap is fixed when the object is created. + ** + ** All bits are clear when the bitmap is created. Individual bits + ** may be set or cleared one at a time. + ** + ** Test operations are about 100 times more common that set operations. + ** Clear operations are exceedingly rare. There are usually between + ** 5 and 500 set operations per Bitvec object, though the number of sets can + ** sometimes grow into tens of thousands or larger. The size of the + ** Bitvec object is the number of pages in the database file at the + ** start of a transaction, and is thus usually less than a few thousand, + ** but can be as large as 2 billion for a really big database. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + + /* Size of the Bitvec structure in bytes. */ + static int BITVEC_SZ = 512; + + + /* Round the union size down to the nearest pointer boundary, since that's how + ** it will be aligned within the Bitvec struct. */ + //#define BITVEC_USIZE (((BITVEC_SZ-(3*sizeof(u32)))/sizeof(Bitvec*))*sizeof(Bitvec*)) + static int BITVEC_USIZE = (((BITVEC_SZ - (3 * sizeof(u32))) / 4) * 4); + + /* Type of the array "element" for the bitmap representation. + ** Should be a power of 2, and ideally, evenly divide into BITVEC_USIZE. + ** Setting this to the "natural word" size of your CPU may improve + ** performance. */ + //#define BITVEC_TELEM u8 + //using BITVEC_TELEM = System.Byte; + + /* Size, in bits, of the bitmap element. */ + //#define BITVEC_SZELEM 8 + const int BITVEC_SZELEM = 8; + + /* Number of elements in a bitmap array. */ + //#define BITVEC_NELEM (BITVEC_USIZE/sizeof(BITVEC_TELEM)) + static int BITVEC_NELEM = (int)(BITVEC_USIZE / sizeof(BITVEC_TELEM)); + + /* Number of bits in the bitmap array. */ + //#define BITVEC_NBIT (BITVEC_NELEM*BITVEC_SZELEM) + static int BITVEC_NBIT = (BITVEC_NELEM * BITVEC_SZELEM); + + /* Number of u32 values in hash table. */ + //#define BITVEC_NINT (BITVEC_USIZE/sizeof(u32)) + static u32 BITVEC_NINT = (u32)(BITVEC_USIZE / sizeof(u32)); + + /* Maximum number of entries in hash table before + ** sub-dividing and re-hashing. */ + //#define BITVEC_MXHASH (BITVEC_NINT/2) + static int BITVEC_MXHASH = (int)(BITVEC_NINT / 2); + + /* Hashing function for the aHash representation. + ** Empirical testing showed that the *37 multiplier + ** (an arbitrary prime)in the hash function provided + ** no fewer collisions than the no-op *1. */ + //#define BITVEC_HASH(X) (((X)*1)%BITVEC_NINT) + static u32 BITVEC_HASH(u32 X) { + return (u32)(((X) * 1) % BITVEC_NINT); + } -static int BITVEC_NPTR = (int)( BITVEC_USIZE / 4 );//sizeof(Bitvec *)); - - -/* -** A bitmap is an instance of the following structure. -** -** This bitmap records the existence of zero or more bits -** with values between 1 and iSize, inclusive. -** -** There are three possible representations of the bitmap. -** If iSize<=BITVEC_NBIT, then Bitvec.u.aBitmap[] is a straight -** bitmap. The least significant bit is bit 1. -** -** If iSize>BITVEC_NBIT and iDivisor==0 then Bitvec.u.aHash[] is -** a hash table that will hold up to BITVEC_MXHASH distinct values. -** -** Otherwise, the value i is redirected into one of BITVEC_NPTR -** sub-bitmaps pointed to by Bitvec.u.apSub[]. Each subbitmap -** handles up to iDivisor separate values of i. apSub[0] holds -** values between 1 and iDivisor. apSub[1] holds values between -** iDivisor+1 and 2*iDivisor. apSub[N] holds values between -** N*iDivisor+1 and (N+1)*iDivisor. Each subbitmap is normalized -** to hold deal with values between 1 and iDivisor. -*/ -public class _u -{ - public BITVEC_TELEM[] aBitmap = new byte[BITVEC_NELEM]; /* Bitmap representation */ - public u32[] aHash = new u32[BITVEC_NINT]; /* Hash table representation */ - public Bitvec[] apSub = new Bitvec[BITVEC_NPTR]; /* Recursive representation */ -} -public class Bitvec -{ - public u32 iSize; /* Maximum bit index. Max iSize is 4,294,967,296. */ - public u32 nSet; /* Number of bits that are set - only valid for aHash + static int BITVEC_NPTR = (int)(BITVEC_USIZE / 4);//sizeof(Bitvec *)); + + + /* + ** A bitmap is an instance of the following structure. + ** + ** This bitmap records the existence of zero or more bits + ** with values between 1 and iSize, inclusive. + ** + ** There are three possible representations of the bitmap. + ** If iSize<=BITVEC_NBIT, then Bitvec.u.aBitmap[] is a straight + ** bitmap. The least significant bit is bit 1. + ** + ** If iSize>BITVEC_NBIT and iDivisor==0 then Bitvec.u.aHash[] is + ** a hash table that will hold up to BITVEC_MXHASH distinct values. + ** + ** Otherwise, the value i is redirected into one of BITVEC_NPTR + ** sub-bitmaps pointed to by Bitvec.u.apSub[]. Each subbitmap + ** handles up to iDivisor separate values of i. apSub[0] holds + ** values between 1 and iDivisor. apSub[1] holds values between + ** iDivisor+1 and 2*iDivisor. apSub[N] holds values between + ** N*iDivisor+1 and (N+1)*iDivisor. Each subbitmap is normalized + ** to hold deal with values between 1 and iDivisor. + */ + public class _u { + public BITVEC_TELEM[] aBitmap = new byte[BITVEC_NELEM]; /* Bitmap representation */ + public u32[] aHash = new u32[BITVEC_NINT]; /* Hash table representation */ + public Bitvec[] apSub = new Bitvec[BITVEC_NPTR]; /* Recursive representation */ + } + public class Bitvec { + public u32 iSize; /* Maximum bit index. Max iSize is 4,294,967,296. */ + public u32 nSet; /* Number of bits that are set - only valid for aHash ** element. Max is BITVEC_NINT. For BITVEC_SZ of 512, ** this would be 125. */ - public u32 iDivisor; /* Number of bits handled by each apSub[] entry. */ - /* Should >=0 for apSub element. */ - /* Max iDivisor is max(u32) / BITVEC_NPTR + 1. */ - /* For a BITVEC_SZ of 512, this would be 34,359,739. */ - public _u u = new _u(); - - public static implicit operator bool( Bitvec b ) - { - return ( b != null ); - } -}; - -/* -** Create a new bitmap object able to handle bits between 0 and iSize, -** inclusive. Return a pointer to the new object. Return NULL if -** malloc fails. -*/ -static Bitvec sqlite3BitvecCreate( u32 iSize ) -{ - Bitvec p; - //Debug.Assert( sizeof(p)==BITVEC_SZ ); - p = new Bitvec();//sqlite3MallocZero( sizeof(p) ); - if ( p != null ) - { - p.iSize = iSize; - } - return p; -} + public u32 iDivisor; /* Number of bits handled by each apSub[] entry. */ + /* Should >=0 for apSub element. */ + /* Max iDivisor is max(u32) / BITVEC_NPTR + 1. */ + /* For a BITVEC_SZ of 512, this would be 34,359,739. */ + public _u u = new _u(); + + public static implicit operator bool(Bitvec b) { + return (b != null); + } + }; + + /* + ** Create a new bitmap object able to handle bits between 0 and iSize, + ** inclusive. Return a pointer to the new object. Return NULL if + ** malloc fails. + */ + static Bitvec sqlite3BitvecCreate(u32 iSize) { + Bitvec p; + //Debug.Assert( sizeof(p)==BITVEC_SZ ); + p = new Bitvec();//sqlite3MallocZero( sizeof(p) ); + if (p != null) { + p.iSize = iSize; + } + return p; + } -/* -** Check to see if the i-th bit is set. Return true or false. -** If p is NULL (if the bitmap has not been created) or if -** i is out of range, then return false. -*/ -static int sqlite3BitvecTest( Bitvec p, u32 i ) -{ - if ( p == null || i == 0 ) - return 0; - if ( i > p.iSize ) - return 0; - i--; - while ( p.iDivisor != 0 ) - { - u32 bin = i / p.iDivisor; - i = i % p.iDivisor; - p = p.u.apSub[bin]; - if ( null == p ) - { - return 0; - } - } - if ( p.iSize <= BITVEC_NBIT ) - { - return ( ( p.u.aBitmap[i / BITVEC_SZELEM] & ( 1 << (int)( i & ( BITVEC_SZELEM - 1 ) ) ) ) != 0 ) ? 1 : 0; - } - else - { - u32 h = BITVEC_HASH( i++ ); - while ( p.u.aHash[h] != 0 ) - { - if ( p.u.aHash[h] == i ) - return 1; - h = ( h + 1 ) % BITVEC_NINT; - } - return 0; - } -} + /* + ** Check to see if the i-th bit is set. Return true or false. + ** If p is NULL (if the bitmap has not been created) or if + ** i is out of range, then return false. + */ + static int sqlite3BitvecTest(Bitvec p, u32 i) { + if (p == null || i == 0) + return 0; + if (i > p.iSize) + return 0; + i--; + while (p.iDivisor != 0) { + u32 bin = i / p.iDivisor; + i = i % p.iDivisor; + p = p.u.apSub[bin]; + if (null == p) { + return 0; + } + } + if (p.iSize <= BITVEC_NBIT) { + return ((p.u.aBitmap[i / BITVEC_SZELEM] & (1 << (int)(i & (BITVEC_SZELEM - 1)))) != 0) ? 1 : 0; + } else { + u32 h = BITVEC_HASH(i++); + while (p.u.aHash[h] != 0) { + if (p.u.aHash[h] == i) + return 1; + h = (h + 1) % BITVEC_NINT; + } + return 0; + } + } -/* -** Set the i-th bit. Return 0 on success and an error code if -** anything goes wrong. -** -** This routine might cause sub-bitmaps to be allocated. Failing -** to get the memory needed to hold the sub-bitmap is the only -** that can go wrong with an insert, assuming p and i are valid. -** -** The calling function must ensure that p is a valid Bitvec object -** and that the value for "i" is within range of the Bitvec object. -** Otherwise the behavior is undefined. -*/ -static int sqlite3BitvecSet( Bitvec p, u32 i ) -{ - u32 h; - if ( p == null ) - return SQLITE_OK; - Debug.Assert( i > 0 ); - Debug.Assert( i <= p.iSize ); - i--; - while ( ( p.iSize > BITVEC_NBIT ) && p.iDivisor != 0 ) - { - u32 bin = i / p.iDivisor; - i = i % p.iDivisor; - if ( p.u.apSub[bin] == null ) - { - p.u.apSub[bin] = sqlite3BitvecCreate( p.iDivisor ); - //if ( p.u.apSub[bin] == null ) - // return SQLITE_NOMEM; - } - p = p.u.apSub[bin]; - } - if ( p.iSize <= BITVEC_NBIT ) - { - p.u.aBitmap[i / BITVEC_SZELEM] |= (byte)( 1 << (int)( i & ( BITVEC_SZELEM - 1 ) ) ); - return SQLITE_OK; - } - h = BITVEC_HASH( i++ ); - /* if there wasn't a hash collision, and this doesn't */ - /* completely fill the hash, then just add it without */ - /* worring about sub-dividing and re-hashing. */ - if ( 0 == p.u.aHash[h] ) - { - if ( p.nSet < ( BITVEC_NINT - 1 ) ) - { - goto bitvec_set_end; - } - else - { - goto bitvec_set_rehash; - } - } - /* there was a collision, check to see if it's already */ - /* in hash, if not, try to find a spot for it */ - do - { - if ( p.u.aHash[h] == i ) - return SQLITE_OK; - h++; - if ( h >= BITVEC_NINT ) - h = 0; - } while ( p.u.aHash[h] != 0 ); -/* we didn't find it in the hash. h points to the first */ -/* available free spot. check to see if this is going to */ -/* make our hash too "full". */ -bitvec_set_rehash: - if ( p.nSet >= BITVEC_MXHASH ) - { - u32 j; - int rc; - u32[] aiValues = new u32[BITVEC_NINT];// = sqlite3StackAllocRaw(0, sizeof(p->u.aHash)); - //if ( aiValues == null ) - //{ - // return SQLITE_NOMEM; - //} - //else - { - - Buffer.BlockCopy( p.u.aHash, 0, aiValues, 0, aiValues.Length * ( sizeof( u32 ) ) );// memcpy(aiValues, p->u.aHash, sizeof(p->u.aHash)); - p.u.apSub = new Bitvec[BITVEC_NPTR];//memset(p->u.apSub, 0, sizeof(p->u.apSub)); - p.iDivisor = (u32)( ( p.iSize + BITVEC_NPTR - 1 ) / BITVEC_NPTR ); - rc = sqlite3BitvecSet( p, i ); - for ( j = 0; j < BITVEC_NINT; j++ ) - { - if ( aiValues[j] != 0 ) - rc |= sqlite3BitvecSet( p, aiValues[j] ); - } - //sqlite3StackFree( null, aiValues ); - return rc; - } - } -bitvec_set_end: - p.nSet++; - p.u.aHash[h] = i; - return SQLITE_OK; -} + /* + ** Set the i-th bit. Return 0 on success and an error code if + ** anything goes wrong. + ** + ** This routine might cause sub-bitmaps to be allocated. Failing + ** to get the memory needed to hold the sub-bitmap is the only + ** that can go wrong with an insert, assuming p and i are valid. + ** + ** The calling function must ensure that p is a valid Bitvec object + ** and that the value for "i" is within range of the Bitvec object. + ** Otherwise the behavior is undefined. + */ + static int sqlite3BitvecSet(Bitvec p, u32 i) { + u32 h; + if (p == null) + return SQLITE_OK; + Debug.Assert(i > 0); + Debug.Assert(i <= p.iSize); + i--; + while ((p.iSize > BITVEC_NBIT) && p.iDivisor != 0) { + u32 bin = i / p.iDivisor; + i = i % p.iDivisor; + if (p.u.apSub[bin] == null) { + p.u.apSub[bin] = sqlite3BitvecCreate(p.iDivisor); + //if ( p.u.apSub[bin] == null ) + // return SQLITE_NOMEM; + } + p = p.u.apSub[bin]; + } + if (p.iSize <= BITVEC_NBIT) { + p.u.aBitmap[i / BITVEC_SZELEM] |= (byte)(1 << (int)(i & (BITVEC_SZELEM - 1))); + return SQLITE_OK; + } + h = BITVEC_HASH(i++); + /* if there wasn't a hash collision, and this doesn't */ + /* completely fill the hash, then just add it without */ + /* worring about sub-dividing and re-hashing. */ + if (0 == p.u.aHash[h]) { + if (p.nSet < (BITVEC_NINT - 1)) { + goto bitvec_set_end; + } else { + goto bitvec_set_rehash; + } + } + /* there was a collision, check to see if it's already */ + /* in hash, if not, try to find a spot for it */ + do { + if (p.u.aHash[h] == i) + return SQLITE_OK; + h++; + if (h >= BITVEC_NINT) + h = 0; + } while (p.u.aHash[h] != 0); + /* we didn't find it in the hash. h points to the first */ + /* available free spot. check to see if this is going to */ + /* make our hash too "full". */ + bitvec_set_rehash: + if (p.nSet >= BITVEC_MXHASH) { + u32 j; + int rc; + u32[] aiValues = new u32[BITVEC_NINT];// = sqlite3StackAllocRaw(0, sizeof(p->u.aHash)); + //if ( aiValues == null ) + //{ + // return SQLITE_NOMEM; + //} + //else + { + + Buffer.BlockCopy(p.u.aHash, 0, aiValues, 0, aiValues.Length * (sizeof(u32)));// memcpy(aiValues, p->u.aHash, sizeof(p->u.aHash)); + p.u.apSub = new Bitvec[BITVEC_NPTR];//memset(p->u.apSub, 0, sizeof(p->u.apSub)); + p.iDivisor = (u32)((p.iSize + BITVEC_NPTR - 1) / BITVEC_NPTR); + rc = sqlite3BitvecSet(p, i); + for (j = 0; j < BITVEC_NINT; j++) { + if (aiValues[j] != 0) + rc |= sqlite3BitvecSet(p, aiValues[j]); + } + //sqlite3StackFree( null, aiValues ); + return rc; + } + } + bitvec_set_end: + p.nSet++; + p.u.aHash[h] = i; + return SQLITE_OK; + } -/* -** Clear the i-th bit. -** -** pBuf must be a pointer to at least BITVEC_SZ bytes of temporary storage -** that BitvecClear can use to rebuilt its hash table. -*/ -static void sqlite3BitvecClear( Bitvec p, u32 i, u32[] pBuf ) -{ - if ( p == null ) - return; - Debug.Assert( i > 0 ); - i--; - while ( p.iDivisor != 0 ) - { - u32 bin = i / p.iDivisor; - i = i % p.iDivisor; - p = p.u.apSub[bin]; - if ( null == p ) - { - return; - } - } - if ( p.iSize <= BITVEC_NBIT ) - { - p.u.aBitmap[i / BITVEC_SZELEM] &= (byte)~( ( 1 << (int)( i & ( BITVEC_SZELEM - 1 ) ) ) ); - } - else - { - u32 j; - u32[] aiValues = pBuf; - Array.Copy( p.u.aHash, aiValues, p.u.aHash.Length );//memcpy(aiValues, p->u.aHash, sizeof(p->u.aHash)); - p.u.aHash = new u32[aiValues.Length];// memset(p->u.aHash, 0, sizeof(p->u.aHash)); - p.nSet = 0; - for ( j = 0; j < BITVEC_NINT; j++ ) - { - if ( aiValues[j] != 0 && aiValues[j] != ( i + 1 ) ) - { - u32 h = BITVEC_HASH( aiValues[j] - 1 ); - p.nSet++; - while ( p.u.aHash[h] != 0 ) - { - h++; - if ( h >= BITVEC_NINT ) - h = 0; + /* + ** Clear the i-th bit. + ** + ** pBuf must be a pointer to at least BITVEC_SZ bytes of temporary storage + ** that BitvecClear can use to rebuilt its hash table. + */ + static void sqlite3BitvecClear(Bitvec p, u32 i, u32[] pBuf) { + if (p == null) + return; + Debug.Assert(i > 0); + i--; + while (p.iDivisor != 0) { + u32 bin = i / p.iDivisor; + i = i % p.iDivisor; + p = p.u.apSub[bin]; + if (null == p) { + return; + } + } + if (p.iSize <= BITVEC_NBIT) { + p.u.aBitmap[i / BITVEC_SZELEM] &= (byte)~((1 << (int)(i & (BITVEC_SZELEM - 1)))); + } else { + u32 j; + u32[] aiValues = pBuf; + Array.Copy(p.u.aHash, aiValues, p.u.aHash.Length);//memcpy(aiValues, p->u.aHash, sizeof(p->u.aHash)); + p.u.aHash = new u32[aiValues.Length];// memset(p->u.aHash, 0, sizeof(p->u.aHash)); + p.nSet = 0; + for (j = 0; j < BITVEC_NINT; j++) { + if (aiValues[j] != 0 && aiValues[j] != (i + 1)) { + u32 h = BITVEC_HASH(aiValues[j] - 1); + p.nSet++; + while (p.u.aHash[h] != 0) { + h++; + if (h >= BITVEC_NINT) + h = 0; + } + p.u.aHash[h] = aiValues[j]; + } + } + } } - p.u.aHash[h] = aiValues[j]; - } - } - } -} -/* -** Destroy a bitmap object. Reclaim all memory used. -*/ -static void sqlite3BitvecDestroy( ref Bitvec p ) -{ - if ( p == null ) - return; - if ( p.iDivisor != 0 ) - { - u32 i; - for ( i = 0; i < BITVEC_NPTR; i++ ) - { - sqlite3BitvecDestroy( ref p.u.apSub[i] ); - } - } - //sqlite3_free( ref p ); -} + /* + ** Destroy a bitmap object. Reclaim all memory used. + */ + static void sqlite3BitvecDestroy(ref Bitvec p) { + if (p == null) + return; + if (p.iDivisor != 0) { + u32 i; + for (i = 0; i < BITVEC_NPTR; i++) { + sqlite3BitvecDestroy(ref p.u.apSub[i]); + } + } + //sqlite3_free( ref p ); + } -/* -** Return the value of the iSize parameter specified when Bitvec *p -** was created. -*/ -static u32 sqlite3BitvecSize( Bitvec p ) -{ - return p.iSize; -} + /* + ** Return the value of the iSize parameter specified when Bitvec *p + ** was created. + */ + static u32 sqlite3BitvecSize(Bitvec p) { + return p.iSize; + } #if !SQLITE_OMIT_BUILTIN_TEST -/* -** Let V[] be an array of unsigned characters sufficient to hold -** up to N bits. Let I be an integer between 0 and N. 0<=I>3] |= (1<<(I&7)) -static void SETBIT( byte[] V, int I ) -{ - V[I >> 3] |= (byte)( 1 << ( I & 7 ) ); -} - -//#define CLEARBIT(V,I) V[I>>3] &= ~(1<<(I&7)) -static void CLEARBIT( byte[] V, int I ) -{ - V[I >> 3] &= (byte)~( 1 << ( I & 7 ) ); -} + /* + ** Let V[] be an array of unsigned characters sufficient to hold + ** up to N bits. Let I be an integer between 0 and N. 0<=I>3] |= (1<<(I&7)) + static void SETBIT(byte[] V, int I) { + V[I >> 3] |= (byte)(1 << (I & 7)); + } -//#define TESTBIT(V,I) (V[I>>3]&(1<<(I&7)))!=0 -static int TESTBIT( byte[] V, int I ) -{ - return ( V[I >> 3] & ( 1 << ( I & 7 ) ) ) != 0 ? 1 : 0; -} + //#define CLEARBIT(V,I) V[I>>3] &= ~(1<<(I&7)) + static void CLEARBIT(byte[] V, int I) { + V[I >> 3] &= (byte)~(1 << (I & 7)); + } -/* -** This routine runs an extensive test of the Bitvec code. -** -** The input is an array of integers that acts as a program -** to test the Bitvec. The integers are opcodes followed -** by 0, 1, or 3 operands, depending on the opcode. Another -** opcode follows immediately after the last operand. -** -** There are 6 opcodes numbered from 0 through 5. 0 is the -** "halt" opcode and causes the test to end. -** -** 0 Halt and return the number of errors -** 1 N S X Set N bits beginning with S and incrementing by X -** 2 N S X Clear N bits beginning with S and incrementing by X -** 3 N Set N randomly chosen bits -** 4 N Clear N randomly chosen bits -** 5 N S X Set N bits from S increment X in array only, not in bitvec -** -** The opcodes 1 through 4 perform set and clear operations are performed -** on both a Bitvec object and on a linear array of bits obtained from malloc. -** Opcode 5 works on the linear array only, not on the Bitvec. -** Opcode 5 is used to deliberately induce a fault in order to -** confirm that error detection works. -** -** At the conclusion of the test the linear array is compared -** against the Bitvec object. If there are any differences, -** an error is returned. If they are the same, zero is returned. -** -** If a memory allocation error occurs, return -1. -*/ -static int sqlite3BitvecBuiltinTest( u32 sz, int[] aOp ) -{ - Bitvec pBitvec = null; - byte[] pV = null; - int rc = -1; - int i, nx, pc, op; - u32[] pTmpSpace; - - /* Allocate the Bitvec to be tested and a linear array of - ** bits to act as the reference */ - pBitvec = sqlite3BitvecCreate( sz ); - pV = sqlite3_malloc( (int)( sz + 7 ) / 8 + 1 ); - pTmpSpace = new u32[BITVEC_SZ];// sqlite3_malloc( BITVEC_SZ ); - if ( pBitvec == null || pV == null || pTmpSpace == null ) - goto bitvec_end; - Array.Clear( pV, 0, (int)( sz + 7 ) / 8 + 1 );// memset( pV, 0, ( sz + 7 ) / 8 + 1 ); - - /* NULL pBitvec tests */ - sqlite3BitvecSet( null, (u32)1 ); - sqlite3BitvecClear( null, 1, pTmpSpace ); - - /* Run the program */ - pc = 0; - while ( ( op = aOp[pc] ) != 0 ) - { - switch ( op ) - { - case 1: - case 2: - case 5: - { - nx = 4; - i = aOp[pc + 2] - 1; - aOp[pc + 2] += aOp[pc + 3]; - break; + //#define TESTBIT(V,I) (V[I>>3]&(1<<(I&7)))!=0 + static int TESTBIT(byte[] V, int I) { + return (V[I >> 3] & (1 << (I & 7))) != 0 ? 1 : 0; } - case 3: - case 4: - default: - { - nx = 2; - i64 i64Temp = 0; - sqlite3_randomness( sizeof( i64 ), ref i64Temp ); - i = (int)i64Temp; - break; + + /* + ** This routine runs an extensive test of the Bitvec code. + ** + ** The input is an array of integers that acts as a program + ** to test the Bitvec. The integers are opcodes followed + ** by 0, 1, or 3 operands, depending on the opcode. Another + ** opcode follows immediately after the last operand. + ** + ** There are 6 opcodes numbered from 0 through 5. 0 is the + ** "halt" opcode and causes the test to end. + ** + ** 0 Halt and return the number of errors + ** 1 N S X Set N bits beginning with S and incrementing by X + ** 2 N S X Clear N bits beginning with S and incrementing by X + ** 3 N Set N randomly chosen bits + ** 4 N Clear N randomly chosen bits + ** 5 N S X Set N bits from S increment X in array only, not in bitvec + ** + ** The opcodes 1 through 4 perform set and clear operations are performed + ** on both a Bitvec object and on a linear array of bits obtained from malloc. + ** Opcode 5 works on the linear array only, not on the Bitvec. + ** Opcode 5 is used to deliberately induce a fault in order to + ** confirm that error detection works. + ** + ** At the conclusion of the test the linear array is compared + ** against the Bitvec object. If there are any differences, + ** an error is returned. If they are the same, zero is returned. + ** + ** If a memory allocation error occurs, return -1. + */ + static int sqlite3BitvecBuiltinTest(u32 sz, int[] aOp) { + Bitvec pBitvec = null; + byte[] pV = null; + int rc = -1; + int i, nx, pc, op; + u32[] pTmpSpace; + + /* Allocate the Bitvec to be tested and a linear array of + ** bits to act as the reference */ + pBitvec = sqlite3BitvecCreate(sz); + pV = sqlite3_malloc((int)(sz + 7) / 8 + 1); + pTmpSpace = new u32[BITVEC_SZ];// sqlite3_malloc( BITVEC_SZ ); + if (pBitvec == null || pV == null || pTmpSpace == null) + goto bitvec_end; + Array.Clear(pV, 0, (int)(sz + 7) / 8 + 1);// memset( pV, 0, ( sz + 7 ) / 8 + 1 ); + + /* NULL pBitvec tests */ + sqlite3BitvecSet(null, (u32)1); + sqlite3BitvecClear(null, 1, pTmpSpace); + + /* Run the program */ + pc = 0; + while ((op = aOp[pc]) != 0) { + switch (op) { + case 1: + case 2: + case 5: { + nx = 4; + i = aOp[pc + 2] - 1; + aOp[pc + 2] += aOp[pc + 3]; + break; + } + case 3: + case 4: + default: { + nx = 2; + i64 i64Temp = 0; + sqlite3_randomness(sizeof(i64), ref i64Temp); + i = (int)i64Temp; + break; + } + } + if ((--aOp[pc + 1]) > 0) + nx = 0; + pc += nx; + i = (int)((i & 0x7fffffff) % sz); + if ((op & 1) != 0) { + SETBIT(pV, (i + 1)); + if (op != 5) { + if (sqlite3BitvecSet(pBitvec, (u32)i + 1) != 0) + goto bitvec_end; + } + } else { + CLEARBIT(pV, (i + 1)); + sqlite3BitvecClear(pBitvec, (u32)i + 1, pTmpSpace); + } + } + + /* Test to make sure the linear array exactly matches the + ** Bitvec object. Start with the assumption that they do + ** match (rc==0). Change rc to non-zero if a discrepancy + ** is found. + */ + rc = sqlite3BitvecTest(null, 0) + sqlite3BitvecTest(pBitvec, sz + 1) + + sqlite3BitvecTest(pBitvec, 0) + + (int)(sqlite3BitvecSize(pBitvec) - sz); + for (i = 1; i <= sz; i++) { + if ((TESTBIT(pV, i)) != sqlite3BitvecTest(pBitvec, (u32)i)) { + rc = i; + break; + } + } + + /* Free allocated structure */ + bitvec_end: + //sqlite3_free( ref pTmpSpace ); + //sqlite3_free( ref pV ); + sqlite3BitvecDestroy(ref pBitvec); + return rc; } - } - if ( ( --aOp[pc + 1] ) > 0 ) - nx = 0; - pc += nx; - i = (int)( ( i & 0x7fffffff ) % sz ); - if ( ( op & 1 ) != 0 ) - { - SETBIT( pV, ( i + 1 ) ); - if ( op != 5 ) - { - if ( sqlite3BitvecSet( pBitvec, (u32)i + 1 ) != 0 ) - goto bitvec_end; - } - } - else - { - CLEARBIT( pV, ( i + 1 ) ); - sqlite3BitvecClear( pBitvec, (u32)i + 1, pTmpSpace ); - } - } - - /* Test to make sure the linear array exactly matches the - ** Bitvec object. Start with the assumption that they do - ** match (rc==0). Change rc to non-zero if a discrepancy - ** is found. - */ - rc = sqlite3BitvecTest( null, 0 ) + sqlite3BitvecTest( pBitvec, sz + 1 ) - + sqlite3BitvecTest( pBitvec, 0 ) - + (int)( sqlite3BitvecSize( pBitvec ) - sz ); - for ( i = 1; i <= sz; i++ ) - { - if ( ( TESTBIT( pV, i ) ) != sqlite3BitvecTest( pBitvec, (u32)i ) ) - { - rc = i; - break; - } - } - - /* Free allocated structure */ -bitvec_end: - //sqlite3_free( ref pTmpSpace ); - //sqlite3_free( ref pV ); - sqlite3BitvecDestroy( ref pBitvec ); - return rc; -} #endif //* SQLITE_OMIT_BUILTIN_TEST */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/btmutex_c.cs b/Src/IronPython.SQLite/c#sqlite/btmutex_c.cs index 1f814b85a..e7b134c50 100644 --- a/Src/IronPython.SQLite/c#sqlite/btmutex_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/btmutex_c.cs @@ -1,34 +1,30 @@ -using System.Diagnostics; - -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { -/* -** 2007 August 27 -** -** 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 contains code used to implement mutexes on Btree objects. -** This code really belongs in btree.c. But btree.c is getting too -** big and we want to break it down some. This packaged seemed like -** a good breakout. - ************************************************************************* -** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart -** C#-SQLite is an independent reimplementation of the SQLite software library -** -** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e -** -************************************************************************* -*/ -//#include "btreeInt.h" +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2007 August 27 + ** + ** 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 contains code used to implement mutexes on Btree objects. + ** This code really belongs in btree.c. But btree.c is getting too + ** big and we want to break it down some. This packaged seemed like + ** a good breakout. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ + //#include "btreeInt.h" #if !SQLITE_OMIT_SHARED_CACHE #if SQLITE_THREADSAFE @@ -299,5 +295,5 @@ void sqlite3BtreeEnterAll(sqlite3 db){ #endif //* if SQLITE_THREADSAFE */ #endif //* ifndef SQLITE_OMIT_SHARED_CACHE */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/btree_c.cs b/Src/IronPython.SQLite/c#sqlite/btree_c.cs index 611dcc5f1..273d6df86 100644 --- a/Src/IronPython.SQLite/c#sqlite/btree_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/btree_c.cs @@ -3,56 +3,54 @@ using System.Text; using i64 = System.Int64; -using u8 = System.Byte; +using Pgno = System.UInt32; +using sqlite3_int64 = System.Int64; using u16 = System.UInt16; using u32 = System.UInt32; using u64 = System.UInt64; -using sqlite3_int64 = System.Int64; -using Pgno = System.UInt32; +using u8 = System.Byte; -namespace Community.CsharpSqlite -{ - using DbPage = Sqlite3.PgHdr; +namespace Community.CsharpSqlite { + using DbPage = Sqlite3.PgHdr; - public partial class Sqlite3 - { -/* -** 2004 April 6 -** -** 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 implements a external (disk-based) database using BTrees. -** See the header comment on "btreeInt.h" for additional information. -** Including a description of file format and an overview of operation. -************************************************************************* -** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart -** C#-SQLite is an independent reimplementation of the SQLite software library -** -** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 -** -************************************************************************* -*/ -//#include "btreeInt.h" + public partial class Sqlite3 { + /* + ** 2004 April 6 + ** + ** 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 implements a external (disk-based) database using BTrees. + ** See the header comment on "btreeInt.h" for additional information. + ** Including a description of file format and an overview of operation. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "btreeInt.h" -/* -** The header string that appears at the beginning of every -** SQLite database. -*/ -static byte[] zMagicHeader = Encoding.UTF8.GetBytes( SQLITE_FILE_HEADER ); + /* + ** The header string that appears at the beginning of every + ** SQLite database. + */ + static byte[] zMagicHeader = Encoding.UTF8.GetBytes(SQLITE_FILE_HEADER); -/* -** Set this global variable to 1 to enable tracing using the TRACE -** macro. -*/ -#if TRACE -static bool sqlite3BtreeTrace=false; /* True to enable tracing */ -//# define TRACE(X) if(sqlite3BtreeTrace){printf X;fflush(stdout);} -static void TRACE(string X, params object[] ap) { if (sqlite3BtreeTrace) printf(X, ap); } + /* + ** Set this global variable to 1 to enable tracing using the TRACE + ** macro. + */ +#if TRACE + static bool sqlite3BtreeTrace = false; /* True to enable tracing */ + //# define TRACE(X) if(sqlite3BtreeTrace){printf X;fflush(stdout);} + static void TRACE(string X, params object[] ap) { if (sqlite3BtreeTrace) printf(X, ap); } #else //# define TRACE(X) static void TRACE( string X, params object[] ap ) @@ -62,20 +60,19 @@ static void TRACE( string X, params object[] ap ) -/* -** Extract a 2-byte big-endian integer from an array of unsigned bytes. -** But if the value is zero, make it 65536. -** -** This routine is used to extract the "offset to cell content area" value -** from the header of a btree page. If the page size is 65536 and the page -** is empty, the offset should be 65536, but the 2-byte value stores zero. -** This routine makes the necessary adjustment to 65536. -*/ -//#define get2byteNotZero(X) (((((int)get2byte(X))-1)&0xffff)+1) -static int get2byteNotZero( byte[] X, int offset ) -{ - return ( ( ( ( (int)get2byte( X, offset ) ) - 1 ) & 0xffff ) + 1 ); -} + /* + ** Extract a 2-byte big-endian integer from an array of unsigned bytes. + ** But if the value is zero, make it 65536. + ** + ** This routine is used to extract the "offset to cell content area" value + ** from the header of a btree page. If the page size is 65536 and the page + ** is empty, the offset should be 65536, but the 2-byte value stores zero. + ** This routine makes the necessary adjustment to 65536. + */ + //#define get2byteNotZero(X) (((((int)get2byte(X))-1)&0xffff)+1) + static int get2byteNotZero(byte[] X, int offset) { + return (((((int)get2byte(X, offset)) - 1) & 0xffff) + 1); + } #if !SQLITE_OMIT_SHARED_CACHE /* @@ -110,40 +107,35 @@ int sqlite3_enable_shared_cache(int enable){ #if SQLITE_OMIT_SHARED_CACHE -/* -** The functions querySharedCacheTableLock(), setSharedCacheTableLock(), -** and clearAllSharedCacheTableLocks() -** manipulate entries in the BtShared.pLock linked list used to store -** shared-cache table level locks. If the library is compiled with the -** shared-cache feature disabled, then there is only ever one user -** of each BtShared structure and so this locking is not necessary. -** So define the lock related functions as no-ops. -*/ -//#define querySharedCacheTableLock(a,b,c) SQLITE_OK -static int querySharedCacheTableLock( Btree p, Pgno iTab, u8 eLock ) -{ - return SQLITE_OK; -} + /* + ** The functions querySharedCacheTableLock(), setSharedCacheTableLock(), + ** and clearAllSharedCacheTableLocks() + ** manipulate entries in the BtShared.pLock linked list used to store + ** shared-cache table level locks. If the library is compiled with the + ** shared-cache feature disabled, then there is only ever one user + ** of each BtShared structure and so this locking is not necessary. + ** So define the lock related functions as no-ops. + */ + //#define querySharedCacheTableLock(a,b,c) SQLITE_OK + static int querySharedCacheTableLock(Btree p, Pgno iTab, u8 eLock) { + return SQLITE_OK; + } -//#define setSharedCacheTableLock(a,b,c) SQLITE_OK -//#define clearAllSharedCacheTableLocks(a) -static void clearAllSharedCacheTableLocks( Btree a ) -{ -} -//#define downgradeAllSharedCacheTableLocks(a) -static void downgradeAllSharedCacheTableLocks( Btree a ) -{ -} -//#define hasSharedCacheTableLock(a,b,c,d) 1 -static bool hasSharedCacheTableLock( Btree a, Pgno b, int c, int d ) -{ - return true; -} -//#define hasReadConflicts(a, b) 0 -static bool hasReadConflicts( Btree a, Pgno b ) -{ - return false; -} + //#define setSharedCacheTableLock(a,b,c) SQLITE_OK + //#define clearAllSharedCacheTableLocks(a) + static void clearAllSharedCacheTableLocks(Btree a) { + } + //#define downgradeAllSharedCacheTableLocks(a) + static void downgradeAllSharedCacheTableLocks(Btree a) { + } + //#define hasSharedCacheTableLock(a,b,c,d) 1 + static bool hasSharedCacheTableLock(Btree a, Pgno b, int c, int d) { + return true; + } + //#define hasReadConflicts(a, b) 0 + static bool hasReadConflicts(Btree a, Pgno b) { + return false; + } #endif #if !SQLITE_OMIT_SHARED_CACHE @@ -470,18 +462,17 @@ static void downgradeAllSharedCacheTableLocks(Btree p){ #endif //* SQLITE_OMIT_SHARED_CACHE */ -//static void releasePage(MemPage pPage); /* Forward reference */ + //static void releasePage(MemPage pPage); /* Forward reference */ -/* -***** This routine is used inside of assert() only **** -** -** Verify that the cursor holds the mutex on its BtShared -*/ + /* + ***** This routine is used inside of assert() only **** + ** + ** Verify that the cursor holds the mutex on its BtShared + */ #if SQLITE_DEBUG -static bool cursorHoldsMutex( BtCursor p ) -{ - return sqlite3_mutex_held( p.pBt.mutex ); -} + static bool cursorHoldsMutex(BtCursor p) { + return sqlite3_mutex_held(p.pBt.mutex); + } #else static bool cursorHoldsMutex(BtCursor p) { return true; } #endif @@ -538,430 +529,387 @@ static void invalidateIncrblobCursors( } #else -/* Stub functions when INCRBLOB is omitted */ -//#define invalidateOverflowCache(x) -static void invalidateOverflowCache( BtCursor pCur ) -{ -} -//#define invalidateAllOverflowCache(x) -static void invalidateAllOverflowCache( BtShared pBt ) -{ -} -//#define invalidateIncrblobCursors(x,y,z) -static void invalidateIncrblobCursors( Btree x, i64 y, int z ) -{ -} + /* Stub functions when INCRBLOB is omitted */ + //#define invalidateOverflowCache(x) + static void invalidateOverflowCache(BtCursor pCur) { + } + //#define invalidateAllOverflowCache(x) + static void invalidateAllOverflowCache(BtShared pBt) { + } + //#define invalidateIncrblobCursors(x,y,z) + static void invalidateIncrblobCursors(Btree x, i64 y, int z) { + } #endif //* SQLITE_OMIT_INCRBLOB */ -/* -** Set bit pgno of the BtShared.pHasContent bitvec. This is called -** when a page that previously contained data becomes a free-list leaf -** page. -** -** The BtShared.pHasContent bitvec exists to work around an obscure -** bug caused by the interaction of two useful IO optimizations surrounding -** free-list leaf pages: -** -** 1) When all data is deleted from a page and the page becomes -** a free-list leaf page, the page is not written to the database -** (as free-list leaf pages contain no meaningful data). Sometimes -** such a page is not even journalled (as it will not be modified, -** why bother journalling it?). -** -** 2) When a free-list leaf page is reused, its content is not read -** from the database or written to the journal file (why should it -** be, if it is not at all meaningful?). -** -** By themselves, these optimizations work fine and provide a handy -** performance boost to bulk delete or insert operations. However, if -** a page is moved to the free-list and then reused within the same -** transaction, a problem comes up. If the page is not journalled when -** it is moved to the free-list and it is also not journalled when it -** is extracted from the free-list and reused, then the original data -** may be lost. In the event of a rollback, it may not be possible -** to restore the database to its original configuration. -** -** The solution is the BtShared.pHasContent bitvec. Whenever a page is -** moved to become a free-list leaf page, the corresponding bit is -** set in the bitvec. Whenever a leaf page is extracted from the free-list, -** optimization 2 above is omitted if the corresponding bit is already -** set in BtShared.pHasContent. The contents of the bitvec are cleared -** at the end of every transaction. -*/ -static int btreeSetHasContent( BtShared pBt, Pgno pgno ) -{ - int rc = SQLITE_OK; - if ( null == pBt.pHasContent ) - { - Debug.Assert( pgno <= pBt.nPage ); - pBt.pHasContent = sqlite3BitvecCreate( pBt.nPage ); - //if ( null == pBt.pHasContent ) - //{ - // rc = SQLITE_NOMEM; - //} - } - if ( rc == SQLITE_OK && pgno <= sqlite3BitvecSize( pBt.pHasContent ) ) - { - rc = sqlite3BitvecSet( pBt.pHasContent, pgno ); - } - return rc; -} + /* + ** Set bit pgno of the BtShared.pHasContent bitvec. This is called + ** when a page that previously contained data becomes a free-list leaf + ** page. + ** + ** The BtShared.pHasContent bitvec exists to work around an obscure + ** bug caused by the interaction of two useful IO optimizations surrounding + ** free-list leaf pages: + ** + ** 1) When all data is deleted from a page and the page becomes + ** a free-list leaf page, the page is not written to the database + ** (as free-list leaf pages contain no meaningful data). Sometimes + ** such a page is not even journalled (as it will not be modified, + ** why bother journalling it?). + ** + ** 2) When a free-list leaf page is reused, its content is not read + ** from the database or written to the journal file (why should it + ** be, if it is not at all meaningful?). + ** + ** By themselves, these optimizations work fine and provide a handy + ** performance boost to bulk delete or insert operations. However, if + ** a page is moved to the free-list and then reused within the same + ** transaction, a problem comes up. If the page is not journalled when + ** it is moved to the free-list and it is also not journalled when it + ** is extracted from the free-list and reused, then the original data + ** may be lost. In the event of a rollback, it may not be possible + ** to restore the database to its original configuration. + ** + ** The solution is the BtShared.pHasContent bitvec. Whenever a page is + ** moved to become a free-list leaf page, the corresponding bit is + ** set in the bitvec. Whenever a leaf page is extracted from the free-list, + ** optimization 2 above is omitted if the corresponding bit is already + ** set in BtShared.pHasContent. The contents of the bitvec are cleared + ** at the end of every transaction. + */ + static int btreeSetHasContent(BtShared pBt, Pgno pgno) { + int rc = SQLITE_OK; + if (null == pBt.pHasContent) { + Debug.Assert(pgno <= pBt.nPage); + pBt.pHasContent = sqlite3BitvecCreate(pBt.nPage); + //if ( null == pBt.pHasContent ) + //{ + // rc = SQLITE_NOMEM; + //} + } + if (rc == SQLITE_OK && pgno <= sqlite3BitvecSize(pBt.pHasContent)) { + rc = sqlite3BitvecSet(pBt.pHasContent, pgno); + } + return rc; + } -/* -** Query the BtShared.pHasContent vector. -** -** This function is called when a free-list leaf page is removed from the -** free-list for reuse. It returns false if it is safe to retrieve the -** page from the pager layer with the 'no-content' flag set. True otherwise. -*/ -static bool btreeGetHasContent( BtShared pBt, Pgno pgno ) -{ - Bitvec p = pBt.pHasContent; - return ( p != null && ( pgno > sqlite3BitvecSize( p ) || sqlite3BitvecTest( p, pgno ) != 0 ) ); -} + /* + ** Query the BtShared.pHasContent vector. + ** + ** This function is called when a free-list leaf page is removed from the + ** free-list for reuse. It returns false if it is safe to retrieve the + ** page from the pager layer with the 'no-content' flag set. True otherwise. + */ + static bool btreeGetHasContent(BtShared pBt, Pgno pgno) { + Bitvec p = pBt.pHasContent; + return (p != null && (pgno > sqlite3BitvecSize(p) || sqlite3BitvecTest(p, pgno) != 0)); + } -/* -** Clear (destroy) the BtShared.pHasContent bitvec. This should be -** invoked at the conclusion of each write-transaction. -*/ -static void btreeClearHasContent( BtShared pBt ) -{ - sqlite3BitvecDestroy( ref pBt.pHasContent ); - pBt.pHasContent = null; -} + /* + ** Clear (destroy) the BtShared.pHasContent bitvec. This should be + ** invoked at the conclusion of each write-transaction. + */ + static void btreeClearHasContent(BtShared pBt) { + sqlite3BitvecDestroy(ref pBt.pHasContent); + pBt.pHasContent = null; + } -/* -** Save the current cursor position in the variables BtCursor.nKey -** and BtCursor.pKey. The cursor's state is set to CURSOR_REQUIRESEEK. -** -** The caller must ensure that the cursor is valid (has eState==CURSOR_VALID) -** prior to calling this routine. -*/ -static int saveCursorPosition( BtCursor pCur ) -{ - int rc; - - Debug.Assert( CURSOR_VALID == pCur.eState ); - Debug.Assert( null == pCur.pKey ); - Debug.Assert( cursorHoldsMutex( pCur ) ); - - rc = sqlite3BtreeKeySize( pCur, ref pCur.nKey ); - Debug.Assert( rc == SQLITE_OK ); /* KeySize() cannot fail */ - - /* If this is an intKey table, then the above call to BtreeKeySize() - ** stores the integer key in pCur.nKey. In this case this value is - ** all that is required. Otherwise, if pCur is not open on an intKey - ** table, then malloc space for and store the pCur.nKey bytes of key - ** data. - */ - if ( 0 == pCur.apPage[0].intKey ) - { - byte[] pKey = sqlite3Malloc( (int)pCur.nKey ); - //if( pKey !=null){ - rc = sqlite3BtreeKey( pCur, 0, (u32)pCur.nKey, pKey ); - if ( rc == SQLITE_OK ) - { - pCur.pKey = pKey; - } - //else{ - // sqlite3_free(ref pKey); - //} - //}else{ - // rc = SQLITE_NOMEM; - //} - } - Debug.Assert( 0 == pCur.apPage[0].intKey || null == pCur.pKey ); - - if ( rc == SQLITE_OK ) - { - int i; - for ( i = 0; i <= pCur.iPage; i++ ) - { - releasePage( pCur.apPage[i] ); - pCur.apPage[i] = null; - } - pCur.iPage = -1; - pCur.eState = CURSOR_REQUIRESEEK; - } + /* + ** Save the current cursor position in the variables BtCursor.nKey + ** and BtCursor.pKey. The cursor's state is set to CURSOR_REQUIRESEEK. + ** + ** The caller must ensure that the cursor is valid (has eState==CURSOR_VALID) + ** prior to calling this routine. + */ + static int saveCursorPosition(BtCursor pCur) { + int rc; + + Debug.Assert(CURSOR_VALID == pCur.eState); + Debug.Assert(null == pCur.pKey); + Debug.Assert(cursorHoldsMutex(pCur)); + + rc = sqlite3BtreeKeySize(pCur, ref pCur.nKey); + Debug.Assert(rc == SQLITE_OK); /* KeySize() cannot fail */ + + /* If this is an intKey table, then the above call to BtreeKeySize() + ** stores the integer key in pCur.nKey. In this case this value is + ** all that is required. Otherwise, if pCur is not open on an intKey + ** table, then malloc space for and store the pCur.nKey bytes of key + ** data. + */ + if (0 == pCur.apPage[0].intKey) { + byte[] pKey = sqlite3Malloc((int)pCur.nKey); + //if( pKey !=null){ + rc = sqlite3BtreeKey(pCur, 0, (u32)pCur.nKey, pKey); + if (rc == SQLITE_OK) { + pCur.pKey = pKey; + } + //else{ + // sqlite3_free(ref pKey); + //} + //}else{ + // rc = SQLITE_NOMEM; + //} + } + Debug.Assert(0 == pCur.apPage[0].intKey || null == pCur.pKey); + + if (rc == SQLITE_OK) { + int i; + for (i = 0; i <= pCur.iPage; i++) { + releasePage(pCur.apPage[i]); + pCur.apPage[i] = null; + } + pCur.iPage = -1; + pCur.eState = CURSOR_REQUIRESEEK; + } - invalidateOverflowCache( pCur ); - return rc; -} + invalidateOverflowCache(pCur); + return rc; + } -/* -** Save the positions of all cursors (except pExcept) that are open on -** the table with root-page iRoot. Usually, this is called just before cursor -** pExcept is used to modify the table (BtreeDelete() or BtreeInsert()). -*/ -static int saveAllCursors( BtShared pBt, Pgno iRoot, BtCursor pExcept ) -{ - BtCursor p; - Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); - Debug.Assert( pExcept == null || pExcept.pBt == pBt ); - for ( p = pBt.pCursor; p != null; p = p.pNext ) - { - if ( p != pExcept && ( 0 == iRoot || p.pgnoRoot == iRoot ) && - p.eState == CURSOR_VALID ) - { - int rc = saveCursorPosition( p ); - if ( SQLITE_OK != rc ) - { - return rc; - } - } - } - return SQLITE_OK; -} + /* + ** Save the positions of all cursors (except pExcept) that are open on + ** the table with root-page iRoot. Usually, this is called just before cursor + ** pExcept is used to modify the table (BtreeDelete() or BtreeInsert()). + */ + static int saveAllCursors(BtShared pBt, Pgno iRoot, BtCursor pExcept) { + BtCursor p; + Debug.Assert(sqlite3_mutex_held(pBt.mutex)); + Debug.Assert(pExcept == null || pExcept.pBt == pBt); + for (p = pBt.pCursor; p != null; p = p.pNext) { + if (p != pExcept && (0 == iRoot || p.pgnoRoot == iRoot) && + p.eState == CURSOR_VALID) { + int rc = saveCursorPosition(p); + if (SQLITE_OK != rc) { + return rc; + } + } + } + return SQLITE_OK; + } -/* -** Clear the current cursor position. -*/ -static void sqlite3BtreeClearCursor( BtCursor pCur ) -{ - Debug.Assert( cursorHoldsMutex( pCur ) ); - sqlite3_free( ref pCur.pKey ); - pCur.eState = CURSOR_INVALID; -} + /* + ** Clear the current cursor position. + */ + static void sqlite3BtreeClearCursor(BtCursor pCur) { + Debug.Assert(cursorHoldsMutex(pCur)); + sqlite3_free(ref pCur.pKey); + pCur.eState = CURSOR_INVALID; + } -/* -** In this version of BtreeMoveto, pKey is a packed index record -** such as is generated by the OP_MakeRecord opcode. Unpack the -** record and then call BtreeMovetoUnpacked() to do the work. -*/ -static int btreeMoveto( -BtCursor pCur, /* Cursor open on the btree to be searched */ -byte[] pKey, /* Packed key if the btree is an index */ -i64 nKey, /* Integer key for tables. Size of pKey for indices */ -int bias, /* Bias search to the high end */ -ref int pRes /* Write search results here */ -) -{ - int rc; /* Status code */ - UnpackedRecord pIdxKey; /* Unpacked index key */ - UnpackedRecord aSpace = new UnpackedRecord();//char aSpace[150]; /* Temp space for pIdxKey - to avoid a malloc */ - - if ( pKey != null ) - { - Debug.Assert( nKey == (i64)(int)nKey ); - pIdxKey = sqlite3VdbeRecordUnpack( pCur.pKeyInfo, (int)nKey, pKey, - aSpace, 16 );//sizeof( aSpace ) ); - //if ( pIdxKey == null ) - // return SQLITE_NOMEM; - } - else - { - pIdxKey = null; - } - rc = sqlite3BtreeMovetoUnpacked( pCur, pIdxKey, nKey, bias != 0 ? 1 : 0, ref pRes ); - - if ( pKey != null ) - { - sqlite3VdbeDeleteUnpackedRecord( pIdxKey ); - } - return rc; -} + /* + ** In this version of BtreeMoveto, pKey is a packed index record + ** such as is generated by the OP_MakeRecord opcode. Unpack the + ** record and then call BtreeMovetoUnpacked() to do the work. + */ + static int btreeMoveto( + BtCursor pCur, /* Cursor open on the btree to be searched */ + byte[] pKey, /* Packed key if the btree is an index */ + i64 nKey, /* Integer key for tables. Size of pKey for indices */ + int bias, /* Bias search to the high end */ + ref int pRes /* Write search results here */ + ) { + int rc; /* Status code */ + UnpackedRecord pIdxKey; /* Unpacked index key */ + UnpackedRecord aSpace = new UnpackedRecord();//char aSpace[150]; /* Temp space for pIdxKey - to avoid a malloc */ + + if (pKey != null) { + Debug.Assert(nKey == (i64)(int)nKey); + pIdxKey = sqlite3VdbeRecordUnpack(pCur.pKeyInfo, (int)nKey, pKey, + aSpace, 16);//sizeof( aSpace ) ); + //if ( pIdxKey == null ) + // return SQLITE_NOMEM; + } else { + pIdxKey = null; + } + rc = sqlite3BtreeMovetoUnpacked(pCur, pIdxKey, nKey, bias != 0 ? 1 : 0, ref pRes); -/* -** Restore the cursor to the position it was in (or as close to as possible) -** when saveCursorPosition() was called. Note that this call deletes the -** saved position info stored by saveCursorPosition(), so there can be -** at most one effective restoreCursorPosition() call after each -** saveCursorPosition(). -*/ -static int btreeRestoreCursorPosition( BtCursor pCur ) -{ - int rc; - Debug.Assert( cursorHoldsMutex( pCur ) ); - Debug.Assert( pCur.eState >= CURSOR_REQUIRESEEK ); - if ( pCur.eState == CURSOR_FAULT ) - { - return pCur.skipNext; - } - pCur.eState = CURSOR_INVALID; - rc = btreeMoveto( pCur, pCur.pKey, pCur.nKey, 0, ref pCur.skipNext ); - if ( rc == SQLITE_OK ) - { - //sqlite3_free(ref pCur.pKey); - pCur.pKey = null; - Debug.Assert( pCur.eState == CURSOR_VALID || pCur.eState == CURSOR_INVALID ); - } - return rc; -} + if (pKey != null) { + sqlite3VdbeDeleteUnpackedRecord(pIdxKey); + } + return rc; + } -//#define restoreCursorPosition(p) \ -// (p.eState>=CURSOR_REQUIRESEEK ? \ -// btreeRestoreCursorPosition(p) : \ -// SQLITE_OK) -static int restoreCursorPosition( BtCursor pCur ) -{ - if ( pCur.eState >= CURSOR_REQUIRESEEK ) - return btreeRestoreCursorPosition( pCur ); - else - return SQLITE_OK; -} + /* + ** Restore the cursor to the position it was in (or as close to as possible) + ** when saveCursorPosition() was called. Note that this call deletes the + ** saved position info stored by saveCursorPosition(), so there can be + ** at most one effective restoreCursorPosition() call after each + ** saveCursorPosition(). + */ + static int btreeRestoreCursorPosition(BtCursor pCur) { + int rc; + Debug.Assert(cursorHoldsMutex(pCur)); + Debug.Assert(pCur.eState >= CURSOR_REQUIRESEEK); + if (pCur.eState == CURSOR_FAULT) { + return pCur.skipNext; + } + pCur.eState = CURSOR_INVALID; + rc = btreeMoveto(pCur, pCur.pKey, pCur.nKey, 0, ref pCur.skipNext); + if (rc == SQLITE_OK) { + //sqlite3_free(ref pCur.pKey); + pCur.pKey = null; + Debug.Assert(pCur.eState == CURSOR_VALID || pCur.eState == CURSOR_INVALID); + } + return rc; + } -/* -** Determine whether or not a cursor has moved from the position it -** was last placed at. Cursors can move when the row they are pointing -** at is deleted out from under them. -** -** This routine returns an error code if something goes wrong. The -** integer pHasMoved is set to one if the cursor has moved and 0 if not. -*/ -static int sqlite3BtreeCursorHasMoved( BtCursor pCur, ref int pHasMoved ) -{ - int rc; - - rc = restoreCursorPosition( pCur ); - if ( rc != 0 ) - { - pHasMoved = 1; - return rc; - } - if ( pCur.eState != CURSOR_VALID || pCur.skipNext != 0 ) - { - pHasMoved = 1; - } - else - { - pHasMoved = 0; - } - return SQLITE_OK; -} + //#define restoreCursorPosition(p) \ + // (p.eState>=CURSOR_REQUIRESEEK ? \ + // btreeRestoreCursorPosition(p) : \ + // SQLITE_OK) + static int restoreCursorPosition(BtCursor pCur) { + if (pCur.eState >= CURSOR_REQUIRESEEK) + return btreeRestoreCursorPosition(pCur); + else + return SQLITE_OK; + } + + /* + ** Determine whether or not a cursor has moved from the position it + ** was last placed at. Cursors can move when the row they are pointing + ** at is deleted out from under them. + ** + ** This routine returns an error code if something goes wrong. The + ** integer pHasMoved is set to one if the cursor has moved and 0 if not. + */ + static int sqlite3BtreeCursorHasMoved(BtCursor pCur, ref int pHasMoved) { + int rc; + + rc = restoreCursorPosition(pCur); + if (rc != 0) { + pHasMoved = 1; + return rc; + } + if (pCur.eState != CURSOR_VALID || pCur.skipNext != 0) { + pHasMoved = 1; + } else { + pHasMoved = 0; + } + return SQLITE_OK; + } #if !SQLITE_OMIT_AUTOVACUUM -/* -** Given a page number of a regular database page, return the page -** number for the pointer-map page that contains the entry for the -** input page number. -** -** Return 0 (not a valid page) for pgno==1 since there is -** no pointer map associated with page 1. The integrity_check logic -** requires that ptrmapPageno(*,1)!=1. -*/ -static Pgno ptrmapPageno( BtShared pBt, Pgno pgno ) -{ - int nPagesPerMapPage; - Pgno iPtrMap, ret; - Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); - if ( pgno < 2 ) - return 0; - nPagesPerMapPage = (int)( pBt.usableSize / 5 + 1 ); - iPtrMap = (Pgno)( ( pgno - 2 ) / nPagesPerMapPage ); - ret = (Pgno)( iPtrMap * nPagesPerMapPage ) + 2; - if ( ret == PENDING_BYTE_PAGE( pBt ) ) - { - ret++; - } - return ret; -} + /* + ** Given a page number of a regular database page, return the page + ** number for the pointer-map page that contains the entry for the + ** input page number. + ** + ** Return 0 (not a valid page) for pgno==1 since there is + ** no pointer map associated with page 1. The integrity_check logic + ** requires that ptrmapPageno(*,1)!=1. + */ + static Pgno ptrmapPageno(BtShared pBt, Pgno pgno) { + int nPagesPerMapPage; + Pgno iPtrMap, ret; + Debug.Assert(sqlite3_mutex_held(pBt.mutex)); + if (pgno < 2) + return 0; + nPagesPerMapPage = (int)(pBt.usableSize / 5 + 1); + iPtrMap = (Pgno)((pgno - 2) / nPagesPerMapPage); + ret = (Pgno)(iPtrMap * nPagesPerMapPage) + 2; + if (ret == PENDING_BYTE_PAGE(pBt)) { + ret++; + } + return ret; + } -/* -** Write an entry into the pointer map. -** -** This routine updates the pointer map entry for page number 'key' -** so that it maps to type 'eType' and parent page number 'pgno'. -** -** If pRC is initially non-zero (non-SQLITE_OK) then this routine is -** a no-op. If an error occurs, the appropriate error code is written -** into pRC. -*/ -static void ptrmapPut( BtShared pBt, Pgno key, u8 eType, Pgno parent, ref int pRC ) -{ - PgHdr pDbPage = new PgHdr(); /* The pointer map page */ - u8[] pPtrmap; /* The pointer map data */ - Pgno iPtrmap; /* The pointer map page number */ - int offset; /* Offset in pointer map page */ - int rc; /* Return code from subfunctions */ - - if ( pRC != 0 ) - return; - - Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); - /* The master-journal page number must never be used as a pointer map page */ - Debug.Assert( false == PTRMAP_ISPAGE( pBt, PENDING_BYTE_PAGE( pBt ) ) ); - - Debug.Assert( pBt.autoVacuum ); - if ( key == 0 ) - { - pRC = SQLITE_CORRUPT_BKPT(); - return; - } - iPtrmap = PTRMAP_PAGENO( pBt, key ); - rc = sqlite3PagerGet( pBt.pPager, iPtrmap, ref pDbPage ); - if ( rc != SQLITE_OK ) - { - pRC = rc; - return; - } - offset = (int)PTRMAP_PTROFFSET( iPtrmap, key ); - if ( offset < 0 ) - { - pRC = SQLITE_CORRUPT_BKPT(); - goto ptrmap_exit; - } - Debug.Assert( offset <= (int)pBt.usableSize - 5 ); - pPtrmap = sqlite3PagerGetData( pDbPage ); - - if ( eType != pPtrmap[offset] || sqlite3Get4byte( pPtrmap, offset + 1 ) != parent ) - { - TRACE( "PTRMAP_UPDATE: %d->(%d,%d)\n", key, eType, parent ); - pRC = rc = sqlite3PagerWrite( pDbPage ); - if ( rc == SQLITE_OK ) - { - pPtrmap[offset] = eType; - sqlite3Put4byte( pPtrmap, offset + 1, parent ); - } - } + /* + ** Write an entry into the pointer map. + ** + ** This routine updates the pointer map entry for page number 'key' + ** so that it maps to type 'eType' and parent page number 'pgno'. + ** + ** If pRC is initially non-zero (non-SQLITE_OK) then this routine is + ** a no-op. If an error occurs, the appropriate error code is written + ** into pRC. + */ + static void ptrmapPut(BtShared pBt, Pgno key, u8 eType, Pgno parent, ref int pRC) { + PgHdr pDbPage = new PgHdr(); /* The pointer map page */ + u8[] pPtrmap; /* The pointer map data */ + Pgno iPtrmap; /* The pointer map page number */ + int offset; /* Offset in pointer map page */ + int rc; /* Return code from subfunctions */ + + if (pRC != 0) + return; + + Debug.Assert(sqlite3_mutex_held(pBt.mutex)); + /* The master-journal page number must never be used as a pointer map page */ + Debug.Assert(false == PTRMAP_ISPAGE(pBt, PENDING_BYTE_PAGE(pBt))); + + Debug.Assert(pBt.autoVacuum); + if (key == 0) { + pRC = SQLITE_CORRUPT_BKPT(); + return; + } + iPtrmap = PTRMAP_PAGENO(pBt, key); + rc = sqlite3PagerGet(pBt.pPager, iPtrmap, ref pDbPage); + if (rc != SQLITE_OK) { + pRC = rc; + return; + } + offset = (int)PTRMAP_PTROFFSET(iPtrmap, key); + if (offset < 0) { + pRC = SQLITE_CORRUPT_BKPT(); + goto ptrmap_exit; + } + Debug.Assert(offset <= (int)pBt.usableSize - 5); + pPtrmap = sqlite3PagerGetData(pDbPage); + + if (eType != pPtrmap[offset] || sqlite3Get4byte(pPtrmap, offset + 1) != parent) { + TRACE("PTRMAP_UPDATE: %d->(%d,%d)\n", key, eType, parent); + pRC = rc = sqlite3PagerWrite(pDbPage); + if (rc == SQLITE_OK) { + pPtrmap[offset] = eType; + sqlite3Put4byte(pPtrmap, offset + 1, parent); + } + } -ptrmap_exit: - sqlite3PagerUnref( pDbPage ); -} + ptrmap_exit: + sqlite3PagerUnref(pDbPage); + } -/* -** Read an entry from the pointer map. -** -** This routine retrieves the pointer map entry for page 'key', writing -** the type and parent page number to pEType and pPgno respectively. -** An error code is returned if something goes wrong, otherwise SQLITE_OK. -*/ -static int ptrmapGet( BtShared pBt, Pgno key, ref u8 pEType, ref Pgno pPgno ) -{ - PgHdr pDbPage = new PgHdr();/* The pointer map page */ - int iPtrmap; /* Pointer map page index */ - u8[] pPtrmap; /* Pointer map page data */ - int offset; /* Offset of entry in pointer map */ - int rc; - - Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); - - iPtrmap = (int)PTRMAP_PAGENO( pBt, key ); - rc = sqlite3PagerGet( pBt.pPager, (u32)iPtrmap, ref pDbPage ); - if ( rc != 0 ) - { - return rc; - } - pPtrmap = sqlite3PagerGetData( pDbPage ); - - offset = (int)PTRMAP_PTROFFSET( (u32)iPtrmap, key ); - if ( offset < 0 ) - { - sqlite3PagerUnref( pDbPage ); - return SQLITE_CORRUPT_BKPT(); - } - Debug.Assert( offset <= (int)pBt.usableSize - 5 ); - // Under C# pEType will always exist. No need to test; // - //Debug.Assert( pEType != 0 ); - pEType = pPtrmap[offset]; - // Under C# pPgno will always exist. No need to test; // - //if ( pPgno != 0 ) - pPgno = sqlite3Get4byte( pPtrmap, offset + 1 ); - - sqlite3PagerUnref( pDbPage ); - if ( pEType < 1 || pEType > 5 ) - return SQLITE_CORRUPT_BKPT(); - return SQLITE_OK; -} + /* + ** Read an entry from the pointer map. + ** + ** This routine retrieves the pointer map entry for page 'key', writing + ** the type and parent page number to pEType and pPgno respectively. + ** An error code is returned if something goes wrong, otherwise SQLITE_OK. + */ + static int ptrmapGet(BtShared pBt, Pgno key, ref u8 pEType, ref Pgno pPgno) { + PgHdr pDbPage = new PgHdr();/* The pointer map page */ + int iPtrmap; /* Pointer map page index */ + u8[] pPtrmap; /* Pointer map page data */ + int offset; /* Offset of entry in pointer map */ + int rc; + + Debug.Assert(sqlite3_mutex_held(pBt.mutex)); + + iPtrmap = (int)PTRMAP_PAGENO(pBt, key); + rc = sqlite3PagerGet(pBt.pPager, (u32)iPtrmap, ref pDbPage); + if (rc != 0) { + return rc; + } + pPtrmap = sqlite3PagerGetData(pDbPage); + + offset = (int)PTRMAP_PTROFFSET((u32)iPtrmap, key); + if (offset < 0) { + sqlite3PagerUnref(pDbPage); + return SQLITE_CORRUPT_BKPT(); + } + Debug.Assert(offset <= (int)pBt.usableSize - 5); + // Under C# pEType will always exist. No need to test; // + //Debug.Assert( pEType != 0 ); + pEType = pPtrmap[offset]; + // Under C# pPgno will always exist. No need to test; // + //if ( pPgno != 0 ) + pPgno = sqlite3Get4byte(pPtrmap, offset + 1); + + sqlite3PagerUnref(pDbPage); + if (pEType < 1 || pEType > 5) + return SQLITE_CORRUPT_BKPT(); + return SQLITE_OK; + } #else //* if defined SQLITE_OMIT_AUTOVACUUM */ //#define ptrmapPut(w,x,y,z,rc) @@ -969,374 +917,332 @@ static int ptrmapGet( BtShared pBt, Pgno key, ref u8 pEType, ref Pgno pPgno ) //#define ptrmapPutOvflPtr(x, y, rc) #endif -/* -** Given a btree page and a cell index (0 means the first cell on -** the page, 1 means the second cell, and so forth) return a pointer -** to the cell content. -** -** This routine works only for pages that do not contain overflow cells. -*/ -//#define findCell(P,I) \ -// ((P).aData + ((P).maskPage & get2byte((P).aData[(P).cellOffset+2*(I)]))) -static int findCell( MemPage pPage, int iCell ) -{ - return get2byte( pPage.aData, pPage.cellOffset + 2 * ( iCell ) ); -} + /* + ** Given a btree page and a cell index (0 means the first cell on + ** the page, 1 means the second cell, and so forth) return a pointer + ** to the cell content. + ** + ** This routine works only for pages that do not contain overflow cells. + */ + //#define findCell(P,I) \ + // ((P).aData + ((P).maskPage & get2byte((P).aData[(P).cellOffset+2*(I)]))) + static int findCell(MemPage pPage, int iCell) { + return get2byte(pPage.aData, pPage.cellOffset + 2 * (iCell)); + } -//#define findCellv2(D,M,O,I) (D+(M&get2byte(D+(O+2*(I))))) -static u8[] findCellv2( u8[] pPage, u16 iCell, u16 O, int I ) -{ - Debugger.Break(); - return pPage; -} + //#define findCellv2(D,M,O,I) (D+(M&get2byte(D+(O+2*(I))))) + static u8[] findCellv2(u8[] pPage, u16 iCell, u16 O, int I) { + Debugger.Break(); + return pPage; + } -/* -** This a more complex version of findCell() that works for -** pages that do contain overflow cells. -*/ -static int findOverflowCell( MemPage pPage, int iCell ) -{ - int i; - Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); - for ( i = pPage.nOverflow - 1; i >= 0; i-- ) - { - int k; - _OvflCell pOvfl; - pOvfl = pPage.aOvfl[i]; - k = pOvfl.idx; - if ( k <= iCell ) - { - if ( k == iCell ) - { - //return pOvfl.pCell; - return -i - 1; // Negative Offset means overflow cells - } - iCell--; - } - } - return findCell( pPage, iCell ); -} + /* + ** This a more complex version of findCell() that works for + ** pages that do contain overflow cells. + */ + static int findOverflowCell(MemPage pPage, int iCell) { + int i; + Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); + for (i = pPage.nOverflow - 1; i >= 0; i--) { + int k; + _OvflCell pOvfl; + pOvfl = pPage.aOvfl[i]; + k = pOvfl.idx; + if (k <= iCell) { + if (k == iCell) { + //return pOvfl.pCell; + return -i - 1; // Negative Offset means overflow cells + } + iCell--; + } + } + return findCell(pPage, iCell); + } -/* -** Parse a cell content block and fill in the CellInfo structure. There -** are two versions of this function. btreeParseCell() takes a -** cell index as the second argument and btreeParseCellPtr() -** takes a pointer to the body of the cell as its second argument. -** -** Within this file, the parseCell() macro can be called instead of -** btreeParseCellPtr(). Using some compilers, this will be faster. -*/ -//OVERLOADS -static void btreeParseCellPtr( -MemPage pPage, /* Page containing the cell */ -int iCell, /* Pointer to the cell text. */ -ref CellInfo pInfo /* Fill in this structure */ -) -{ - btreeParseCellPtr( pPage, pPage.aData, iCell, ref pInfo ); -} -static void btreeParseCellPtr( -MemPage pPage, /* Page containing the cell */ -byte[] pCell, /* The actual data */ -ref CellInfo pInfo /* Fill in this structure */ -) -{ - btreeParseCellPtr( pPage, pCell, 0, ref pInfo ); -} -static void btreeParseCellPtr( -MemPage pPage, /* Page containing the cell */ -u8[] pCell, /* Pointer to the cell text. */ -int iCell, /* Pointer to the cell text. */ -ref CellInfo pInfo /* Fill in this structure */ -) -{ - u16 n; /* Number bytes in cell content header */ - u32 nPayload = 0; /* Number of bytes of cell payload */ - - Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); - - if ( pInfo.pCell != pCell ) - pInfo.pCell = pCell; - pInfo.iCell = iCell; - Debug.Assert( pPage.leaf == 0 || pPage.leaf == 1 ); - n = pPage.childPtrSize; - Debug.Assert( n == 4 - 4 * pPage.leaf ); - if ( pPage.intKey != 0 ) - { - if ( pPage.hasData != 0 ) - { - n += (u16)getVarint32( pCell, iCell + n, out nPayload ); - } - else - { - nPayload = 0; - } - n += (u16)getVarint( pCell, iCell + n, out pInfo.nKey ); - pInfo.nData = nPayload; - } - else - { - pInfo.nData = 0; - n += (u16)getVarint32( pCell, iCell + n, out nPayload ); - pInfo.nKey = nPayload; - } - pInfo.nPayload = nPayload; - pInfo.nHeader = n; - testcase( nPayload == pPage.maxLocal ); - testcase( nPayload == pPage.maxLocal + 1 ); - if ( likely( nPayload <= pPage.maxLocal ) ) - { - /* This is the (easy) common case where the entire payload fits - ** on the local page. No overflow is required. - */ - if ( ( pInfo.nSize = (u16)( n + nPayload ) ) < 4 ) - pInfo.nSize = 4; - pInfo.nLocal = (u16)nPayload; - pInfo.iOverflow = 0; - } - else - { - /* If the payload will not fit completely on the local page, we have - ** to decide how much to store locally and how much to spill onto - ** overflow pages. The strategy is to minimize the amount of unused - ** space on overflow pages while keeping the amount of local storage - ** in between minLocal and maxLocal. - ** - ** Warning: changing the way overflow payload is distributed in any - ** way will result in an incompatible file format. - */ - int minLocal; /* Minimum amount of payload held locally */ - int maxLocal; /* Maximum amount of payload held locally */ - int surplus; /* Overflow payload available for local storage */ - - minLocal = pPage.minLocal; - maxLocal = pPage.maxLocal; - surplus = (int)( minLocal + ( nPayload - minLocal ) % ( pPage.pBt.usableSize - 4 ) ); - testcase( surplus == maxLocal ); - testcase( surplus == maxLocal + 1 ); - if ( surplus <= maxLocal ) - { - pInfo.nLocal = (u16)surplus; - } - else - { - pInfo.nLocal = (u16)minLocal; - } - pInfo.iOverflow = (u16)( pInfo.nLocal + n ); - pInfo.nSize = (u16)( pInfo.iOverflow + 4 ); - } -} -//#define parseCell(pPage, iCell, pInfo) \ -// btreeParseCellPtr((pPage), findCell((pPage), (iCell)), (pInfo)) -static void parseCell( MemPage pPage, int iCell, ref CellInfo pInfo ) -{ - btreeParseCellPtr( pPage, findCell( pPage, iCell ), ref pInfo ); -} + /* + ** Parse a cell content block and fill in the CellInfo structure. There + ** are two versions of this function. btreeParseCell() takes a + ** cell index as the second argument and btreeParseCellPtr() + ** takes a pointer to the body of the cell as its second argument. + ** + ** Within this file, the parseCell() macro can be called instead of + ** btreeParseCellPtr(). Using some compilers, this will be faster. + */ + //OVERLOADS + static void btreeParseCellPtr( + MemPage pPage, /* Page containing the cell */ + int iCell, /* Pointer to the cell text. */ + ref CellInfo pInfo /* Fill in this structure */ + ) { + btreeParseCellPtr(pPage, pPage.aData, iCell, ref pInfo); + } + static void btreeParseCellPtr( + MemPage pPage, /* Page containing the cell */ + byte[] pCell, /* The actual data */ + ref CellInfo pInfo /* Fill in this structure */ + ) { + btreeParseCellPtr(pPage, pCell, 0, ref pInfo); + } + static void btreeParseCellPtr( + MemPage pPage, /* Page containing the cell */ + u8[] pCell, /* Pointer to the cell text. */ + int iCell, /* Pointer to the cell text. */ + ref CellInfo pInfo /* Fill in this structure */ + ) { + u16 n; /* Number bytes in cell content header */ + u32 nPayload = 0; /* Number of bytes of cell payload */ + + Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); + + if (pInfo.pCell != pCell) + pInfo.pCell = pCell; + pInfo.iCell = iCell; + Debug.Assert(pPage.leaf == 0 || pPage.leaf == 1); + n = pPage.childPtrSize; + Debug.Assert(n == 4 - 4 * pPage.leaf); + if (pPage.intKey != 0) { + if (pPage.hasData != 0) { + n += (u16)getVarint32(pCell, iCell + n, out nPayload); + } else { + nPayload = 0; + } + n += (u16)getVarint(pCell, iCell + n, out pInfo.nKey); + pInfo.nData = nPayload; + } else { + pInfo.nData = 0; + n += (u16)getVarint32(pCell, iCell + n, out nPayload); + pInfo.nKey = nPayload; + } + pInfo.nPayload = nPayload; + pInfo.nHeader = n; + testcase(nPayload == pPage.maxLocal); + testcase(nPayload == pPage.maxLocal + 1); + if (likely(nPayload <= pPage.maxLocal)) { + /* This is the (easy) common case where the entire payload fits + ** on the local page. No overflow is required. + */ + if ((pInfo.nSize = (u16)(n + nPayload)) < 4) + pInfo.nSize = 4; + pInfo.nLocal = (u16)nPayload; + pInfo.iOverflow = 0; + } else { + /* If the payload will not fit completely on the local page, we have + ** to decide how much to store locally and how much to spill onto + ** overflow pages. The strategy is to minimize the amount of unused + ** space on overflow pages while keeping the amount of local storage + ** in between minLocal and maxLocal. + ** + ** Warning: changing the way overflow payload is distributed in any + ** way will result in an incompatible file format. + */ + int minLocal; /* Minimum amount of payload held locally */ + int maxLocal; /* Maximum amount of payload held locally */ + int surplus; /* Overflow payload available for local storage */ + + minLocal = pPage.minLocal; + maxLocal = pPage.maxLocal; + surplus = (int)(minLocal + (nPayload - minLocal) % (pPage.pBt.usableSize - 4)); + testcase(surplus == maxLocal); + testcase(surplus == maxLocal + 1); + if (surplus <= maxLocal) { + pInfo.nLocal = (u16)surplus; + } else { + pInfo.nLocal = (u16)minLocal; + } + pInfo.iOverflow = (u16)(pInfo.nLocal + n); + pInfo.nSize = (u16)(pInfo.iOverflow + 4); + } + } + //#define parseCell(pPage, iCell, pInfo) \ + // btreeParseCellPtr((pPage), findCell((pPage), (iCell)), (pInfo)) + static void parseCell(MemPage pPage, int iCell, ref CellInfo pInfo) { + btreeParseCellPtr(pPage, findCell(pPage, iCell), ref pInfo); + } -static void btreeParseCell( -MemPage pPage, /* Page containing the cell */ -int iCell, /* The cell index. First cell is 0 */ -ref CellInfo pInfo /* Fill in this structure */ -) -{ - parseCell( pPage, iCell, ref pInfo ); -} + static void btreeParseCell( + MemPage pPage, /* Page containing the cell */ + int iCell, /* The cell index. First cell is 0 */ + ref CellInfo pInfo /* Fill in this structure */ + ) { + parseCell(pPage, iCell, ref pInfo); + } -/* -** Compute the total number of bytes that a Cell needs in the cell -** data area of the btree-page. The return number includes the cell -** data header and the local payload, but not any overflow page or -** the space used by the cell pointer. -*/ -// Alternative form for C# -static u16 cellSizePtr( MemPage pPage, int iCell ) -{ - CellInfo info = new CellInfo(); - byte[] pCell = new byte[13]; - // Minimum Size = (2 bytes of Header or (4) Child Pointer) + (maximum of) 9 bytes data - if ( iCell < 0 )// Overflow Cell - Buffer.BlockCopy( pPage.aOvfl[-( iCell + 1 )].pCell, 0, pCell, 0, pCell.Length < pPage.aOvfl[-( iCell + 1 )].pCell.Length ? pCell.Length : pPage.aOvfl[-( iCell + 1 )].pCell.Length ); - else if ( iCell >= pPage.aData.Length + 1 - pCell.Length ) - Buffer.BlockCopy( pPage.aData, iCell, pCell, 0, pPage.aData.Length - iCell ); - else - Buffer.BlockCopy( pPage.aData, iCell, pCell, 0, pCell.Length ); - btreeParseCellPtr( pPage, pCell, ref info ); - return info.nSize; -} + /* + ** Compute the total number of bytes that a Cell needs in the cell + ** data area of the btree-page. The return number includes the cell + ** data header and the local payload, but not any overflow page or + ** the space used by the cell pointer. + */ + // Alternative form for C# + static u16 cellSizePtr(MemPage pPage, int iCell) { + CellInfo info = new CellInfo(); + byte[] pCell = new byte[13]; + // Minimum Size = (2 bytes of Header or (4) Child Pointer) + (maximum of) 9 bytes data + if (iCell < 0)// Overflow Cell + Buffer.BlockCopy(pPage.aOvfl[-(iCell + 1)].pCell, 0, pCell, 0, pCell.Length < pPage.aOvfl[-(iCell + 1)].pCell.Length ? pCell.Length : pPage.aOvfl[-(iCell + 1)].pCell.Length); + else if (iCell >= pPage.aData.Length + 1 - pCell.Length) + Buffer.BlockCopy(pPage.aData, iCell, pCell, 0, pPage.aData.Length - iCell); + else + Buffer.BlockCopy(pPage.aData, iCell, pCell, 0, pCell.Length); + btreeParseCellPtr(pPage, pCell, ref info); + return info.nSize; + } -// Alternative form for C# -static u16 cellSizePtr( MemPage pPage, byte[] pCell, int offset ) -{ - CellInfo info = new CellInfo(); - info.pCell = sqlite3Malloc( pCell.Length ); - Buffer.BlockCopy( pCell, offset, info.pCell, 0, pCell.Length - offset ); - btreeParseCellPtr( pPage, info.pCell, ref info ); - return info.nSize; -} + // Alternative form for C# + static u16 cellSizePtr(MemPage pPage, byte[] pCell, int offset) { + CellInfo info = new CellInfo(); + info.pCell = sqlite3Malloc(pCell.Length); + Buffer.BlockCopy(pCell, offset, info.pCell, 0, pCell.Length - offset); + btreeParseCellPtr(pPage, info.pCell, ref info); + return info.nSize; + } -static u16 cellSizePtr( MemPage pPage, u8[] pCell ) -{ - int _pIter = pPage.childPtrSize; //u8 pIter = &pCell[pPage.childPtrSize]; - u32 nSize = 0; + static u16 cellSizePtr(MemPage pPage, u8[] pCell) { + int _pIter = pPage.childPtrSize; //u8 pIter = &pCell[pPage.childPtrSize]; + u32 nSize = 0; #if SQLITE_DEBUG || DEBUG - /* The value returned by this function should always be the same as -** the (CellInfo.nSize) value found by doing a full parse of the -** cell. If SQLITE_DEBUG is defined, an Debug.Assert() at the bottom of -** this function verifies that this invariant is not violated. */ - CellInfo debuginfo = new CellInfo(); - btreeParseCellPtr( pPage, pCell, ref debuginfo ); + /* The value returned by this function should always be the same as + ** the (CellInfo.nSize) value found by doing a full parse of the + ** cell. If SQLITE_DEBUG is defined, an Debug.Assert() at the bottom of + ** this function verifies that this invariant is not violated. */ + CellInfo debuginfo = new CellInfo(); + btreeParseCellPtr(pPage, pCell, ref debuginfo); #else CellInfo debuginfo = new CellInfo(); #endif - if ( pPage.intKey != 0 ) - { - int pEnd; - if ( pPage.hasData != 0 ) - { - _pIter += getVarint32( pCell, out nSize );// pIter += getVarint32( pIter, out nSize ); - } - else - { - nSize = 0; - } + if (pPage.intKey != 0) { + int pEnd; + if (pPage.hasData != 0) { + _pIter += getVarint32(pCell, out nSize);// pIter += getVarint32( pIter, out nSize ); + } else { + nSize = 0; + } + + /* pIter now points at the 64-bit integer key value, a variable length + ** integer. The following block moves pIter to point at the first byte + ** past the end of the key value. */ + pEnd = _pIter + 9;//pEnd = &pIter[9]; + while (((pCell[_pIter++]) & 0x80) != 0 && _pIter < pEnd) + ;//while( (pIter++)&0x80 && pIter pPage.maxLocal ) - { - int minLocal = pPage.minLocal; - nSize = (u32)( minLocal + ( nSize - minLocal ) % ( pPage.pBt.usableSize - 4 ) ); - testcase( nSize == pPage.maxLocal ); - testcase( nSize == pPage.maxLocal + 1 ); - if ( nSize > pPage.maxLocal ) - { - nSize = (u32)minLocal; - } - nSize += 4; - } - nSize += (uint)_pIter;//nSize += (u32)(pIter - pCell); - - /* The minimum size of any cell is 4 bytes. */ - if ( nSize < 4 ) - { - nSize = 4; - } - - Debug.Assert( nSize == debuginfo.nSize ); - return (u16)nSize; -} + testcase(nSize == pPage.maxLocal); + testcase(nSize == pPage.maxLocal + 1); + if (nSize > pPage.maxLocal) { + int minLocal = pPage.minLocal; + nSize = (u32)(minLocal + (nSize - minLocal) % (pPage.pBt.usableSize - 4)); + testcase(nSize == pPage.maxLocal); + testcase(nSize == pPage.maxLocal + 1); + if (nSize > pPage.maxLocal) { + nSize = (u32)minLocal; + } + nSize += 4; + } + nSize += (uint)_pIter;//nSize += (u32)(pIter - pCell); + + /* The minimum size of any cell is 4 bytes. */ + if (nSize < 4) { + nSize = 4; + } + + Debug.Assert(nSize == debuginfo.nSize); + return (u16)nSize; + } #if SQLITE_DEBUG -/* This variation on cellSizePtr() is used inside of assert() statements -** only. */ -static u16 cellSize( MemPage pPage, int iCell ) -{ - return cellSizePtr( pPage, findCell( pPage, iCell ) ); -} + /* This variation on cellSizePtr() is used inside of assert() statements + ** only. */ + static u16 cellSize(MemPage pPage, int iCell) { + return cellSizePtr(pPage, findCell(pPage, iCell)); + } #else static int cellSize(MemPage pPage, int iCell) { return -1; } #endif #if !SQLITE_OMIT_AUTOVACUUM -/* -** If the cell pCell, part of page pPage contains a pointer -** to an overflow page, insert an entry into the pointer-map -** for the overflow page. -*/ -static void ptrmapPutOvflPtr( MemPage pPage, int pCell, ref int pRC ) -{ - if ( pRC != 0 ) - return; - CellInfo info = new CellInfo(); - Debug.Assert( pCell != 0 ); - btreeParseCellPtr( pPage, pCell, ref info ); - Debug.Assert( ( info.nData + ( pPage.intKey != 0 ? 0 : info.nKey ) ) == info.nPayload ); - if ( info.iOverflow != 0 ) - { - Pgno ovfl = sqlite3Get4byte( pPage.aData, pCell, info.iOverflow ); - ptrmapPut( pPage.pBt, ovfl, PTRMAP_OVERFLOW1, pPage.pgno, ref pRC ); - } -} + /* + ** If the cell pCell, part of page pPage contains a pointer + ** to an overflow page, insert an entry into the pointer-map + ** for the overflow page. + */ + static void ptrmapPutOvflPtr(MemPage pPage, int pCell, ref int pRC) { + if (pRC != 0) + return; + CellInfo info = new CellInfo(); + Debug.Assert(pCell != 0); + btreeParseCellPtr(pPage, pCell, ref info); + Debug.Assert((info.nData + (pPage.intKey != 0 ? 0 : info.nKey)) == info.nPayload); + if (info.iOverflow != 0) { + Pgno ovfl = sqlite3Get4byte(pPage.aData, pCell, info.iOverflow); + ptrmapPut(pPage.pBt, ovfl, PTRMAP_OVERFLOW1, pPage.pgno, ref pRC); + } + } -static void ptrmapPutOvflPtr( MemPage pPage, u8[] pCell, ref int pRC ) -{ - if ( pRC != 0 ) - return; - CellInfo info = new CellInfo(); - Debug.Assert( pCell != null ); - btreeParseCellPtr( pPage, pCell, ref info ); - Debug.Assert( ( info.nData + ( pPage.intKey != 0 ? 0 : info.nKey ) ) == info.nPayload ); - if ( info.iOverflow != 0 ) - { - Pgno ovfl = sqlite3Get4byte( pCell, info.iOverflow ); - ptrmapPut( pPage.pBt, ovfl, PTRMAP_OVERFLOW1, pPage.pgno, ref pRC ); - } -} + static void ptrmapPutOvflPtr(MemPage pPage, u8[] pCell, ref int pRC) { + if (pRC != 0) + return; + CellInfo info = new CellInfo(); + Debug.Assert(pCell != null); + btreeParseCellPtr(pPage, pCell, ref info); + Debug.Assert((info.nData + (pPage.intKey != 0 ? 0 : info.nKey)) == info.nPayload); + if (info.iOverflow != 0) { + Pgno ovfl = sqlite3Get4byte(pCell, info.iOverflow); + ptrmapPut(pPage.pBt, ovfl, PTRMAP_OVERFLOW1, pPage.pgno, ref pRC); + } + } #endif -/* -** Defragment the page given. All Cells are moved to the -** end of the page and all free space is collected into one -** big FreeBlk that occurs in between the header and cell -** pointer array and the cell content area. -*/ -static int defragmentPage( MemPage pPage ) -{ - int i; /* Loop counter */ - int pc; /* Address of a i-th cell */ - int addr; /* Offset of first byte after cell pointer array */ - int hdr; /* Offset to the page header */ - int size; /* Size of a cell */ - int usableSize; /* Number of usable bytes on a page */ - int cellOffset; /* Offset to the cell pointer array */ - int cbrk; /* Offset to the cell content area */ - int nCell; /* Number of cells on the page */ - byte[] data; /* The page data */ - byte[] temp; /* Temp area for cell content */ - int iCellFirst; /* First allowable cell index */ - int iCellLast; /* Last possible cell index */ - - - Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); - Debug.Assert( pPage.pBt != null ); - Debug.Assert( pPage.pBt.usableSize <= SQLITE_MAX_PAGE_SIZE ); - Debug.Assert( pPage.nOverflow == 0 ); - Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); - temp = sqlite3PagerTempSpace( pPage.pBt.pPager ); - data = pPage.aData; - hdr = pPage.hdrOffset; - cellOffset = pPage.cellOffset; - nCell = pPage.nCell; - Debug.Assert( nCell == get2byte( data, hdr + 3 ) ); - usableSize = (int)pPage.pBt.usableSize; - cbrk = get2byte( data, hdr + 5 ); - Buffer.BlockCopy( data, cbrk, temp, cbrk, usableSize - cbrk );//memcpy( temp[cbrk], ref data[cbrk], usableSize - cbrk ); - cbrk = usableSize; - iCellFirst = cellOffset + 2 * nCell; - iCellLast = usableSize - 4; - for ( i = 0; i < nCell; i++ ) - { - int pAddr; /* The i-th cell pointer */ - pAddr = cellOffset + i * 2; // &data[cellOffset + i * 2]; - pc = get2byte( data, pAddr ); - testcase( pc == iCellFirst ); - testcase( pc == iCellLast ); + /* + ** Defragment the page given. All Cells are moved to the + ** end of the page and all free space is collected into one + ** big FreeBlk that occurs in between the header and cell + ** pointer array and the cell content area. + */ + static int defragmentPage(MemPage pPage) { + int i; /* Loop counter */ + int pc; /* Address of a i-th cell */ + int addr; /* Offset of first byte after cell pointer array */ + int hdr; /* Offset to the page header */ + int size; /* Size of a cell */ + int usableSize; /* Number of usable bytes on a page */ + int cellOffset; /* Offset to the cell pointer array */ + int cbrk; /* Offset to the cell content area */ + int nCell; /* Number of cells on the page */ + byte[] data; /* The page data */ + byte[] temp; /* Temp area for cell content */ + int iCellFirst; /* First allowable cell index */ + int iCellLast; /* Last possible cell index */ + + + Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); + Debug.Assert(pPage.pBt != null); + Debug.Assert(pPage.pBt.usableSize <= SQLITE_MAX_PAGE_SIZE); + Debug.Assert(pPage.nOverflow == 0); + Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); + temp = sqlite3PagerTempSpace(pPage.pBt.pPager); + data = pPage.aData; + hdr = pPage.hdrOffset; + cellOffset = pPage.cellOffset; + nCell = pPage.nCell; + Debug.Assert(nCell == get2byte(data, hdr + 3)); + usableSize = (int)pPage.pBt.usableSize; + cbrk = get2byte(data, hdr + 5); + Buffer.BlockCopy(data, cbrk, temp, cbrk, usableSize - cbrk);//memcpy( temp[cbrk], ref data[cbrk], usableSize - cbrk ); + cbrk = usableSize; + iCellFirst = cellOffset + 2 * nCell; + iCellLast = usableSize - 4; + for (i = 0; i < nCell; i++) { + int pAddr; /* The i-th cell pointer */ + pAddr = cellOffset + i * 2; // &data[cellOffset + i * 2]; + pc = get2byte(data, pAddr); + testcase(pc == iCellFirst); + testcase(pc == iCellLast); #if !(SQLITE_ENABLE_OVERSIZE_CELL_CHECK) /* These conditions have already been verified in btreeInitPage() ** if SQLITE_ENABLE_OVERSIZE_CELL_CHECK is defined @@ -1346,737 +1252,670 @@ static int defragmentPage( MemPage pPage ) return SQLITE_CORRUPT_BKPT(); } #endif - Debug.Assert( pc >= iCellFirst && pc <= iCellLast ); - size = cellSizePtr( pPage, temp, pc ); - cbrk -= size; + Debug.Assert(pc >= iCellFirst && pc <= iCellLast); + size = cellSizePtr(pPage, temp, pc); + cbrk -= size; #if (SQLITE_ENABLE_OVERSIZE_CELL_CHECK) - if ( cbrk < iCellFirst || pc + size > usableSize ) - { - return SQLITE_CORRUPT_BKPT(); - } + if (cbrk < iCellFirst || pc + size > usableSize) { + return SQLITE_CORRUPT_BKPT(); + } #else if ( cbrk < iCellFirst || pc + size > usableSize ) { return SQLITE_CORRUPT_BKPT(); } #endif - Debug.Assert( cbrk + size <= usableSize && cbrk >= iCellFirst ); - testcase( cbrk + size == usableSize ); - testcase( pc + size == usableSize ); - Buffer.BlockCopy( temp, pc, data, cbrk, size );//memcpy(data[cbrk], ref temp[pc], size); - put2byte( data, pAddr, cbrk ); - } - Debug.Assert( cbrk >= iCellFirst ); - put2byte( data, hdr + 5, cbrk ); - data[hdr + 1] = 0; - data[hdr + 2] = 0; - data[hdr + 7] = 0; - addr = cellOffset + 2 * nCell; - Array.Clear( data, addr, cbrk - addr ); //memset(data[iCellFirst], 0, cbrk-iCellFirst); - Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); - if ( cbrk - iCellFirst != pPage.nFree ) - { - return SQLITE_CORRUPT_BKPT(); - } - return SQLITE_OK; -} + Debug.Assert(cbrk + size <= usableSize && cbrk >= iCellFirst); + testcase(cbrk + size == usableSize); + testcase(pc + size == usableSize); + Buffer.BlockCopy(temp, pc, data, cbrk, size);//memcpy(data[cbrk], ref temp[pc], size); + put2byte(data, pAddr, cbrk); + } + Debug.Assert(cbrk >= iCellFirst); + put2byte(data, hdr + 5, cbrk); + data[hdr + 1] = 0; + data[hdr + 2] = 0; + data[hdr + 7] = 0; + addr = cellOffset + 2 * nCell; + Array.Clear(data, addr, cbrk - addr); //memset(data[iCellFirst], 0, cbrk-iCellFirst); + Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); + if (cbrk - iCellFirst != pPage.nFree) { + return SQLITE_CORRUPT_BKPT(); + } + return SQLITE_OK; + } -/* -** Allocate nByte bytes of space from within the B-Tree page passed -** as the first argument. Write into pIdx the index into pPage.aData[] -** of the first byte of allocated space. Return either SQLITE_OK or -** an error code (usually SQLITE_CORRUPT). -** -** The caller guarantees that there is sufficient space to make the -** allocation. This routine might need to defragment in order to bring -** all the space together, however. This routine will avoid using -** the first two bytes past the cell pointer area since presumably this -** allocation is being made in order to insert a new cell, so we will -** also end up needing a new cell pointer. -*/ -static int allocateSpace( MemPage pPage, int nByte, ref int pIdx ) -{ - int hdr = pPage.hdrOffset; /* Local cache of pPage.hdrOffset */ - u8[] data = pPage.aData; /* Local cache of pPage.aData */ - int nFrag; /* Number of fragmented bytes on pPage */ - int top; /* First byte of cell content area */ - int gap; /* First byte of gap between cell pointers and cell content */ - int rc; /* Integer return code */ - u32 usableSize; /* Usable size of the page */ - - Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); - Debug.Assert( pPage.pBt != null ); - Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); - Debug.Assert( nByte >= 0 ); /* Minimum cell size is 4 */ - Debug.Assert( pPage.nFree >= nByte ); - Debug.Assert( pPage.nOverflow == 0 ); - usableSize = pPage.pBt.usableSize; - Debug.Assert( nByte < usableSize - 8 ); - - nFrag = data[hdr + 7]; - Debug.Assert( pPage.cellOffset == hdr + 12 - 4 * pPage.leaf ); - gap = pPage.cellOffset + 2 * pPage.nCell; - top = get2byteNotZero( data, hdr + 5 ); - if ( gap > top ) - return SQLITE_CORRUPT_BKPT(); - testcase( gap + 2 == top ); - testcase( gap + 1 == top ); - testcase( gap == top ); - - if ( nFrag >= 60 ) - { - /* Always defragment highly fragmented pages */ - rc = defragmentPage( pPage ); - if ( rc != 0 ) - return rc; - top = get2byteNotZero( data, hdr + 5 ); - } - else if ( gap + 2 <= top ) - { - /* Search the freelist looking for a free slot big enough to satisfy - ** the request. The allocation is made from the first free slot in - ** the list that is large enough to accomadate it. - */ - int pc, addr; - for ( addr = hdr + 1; ( pc = get2byte( data, addr ) ) > 0; addr = pc ) - { - int size; /* Size of free slot */ - if ( pc > usableSize - 4 || pc < addr + 4 ) - { - return SQLITE_CORRUPT_BKPT(); - } - size = get2byte( data, pc + 2 ); - if ( size >= nByte ) - { - int x = size - nByte; - testcase( x == 4 ); - testcase( x == 3 ); - if ( x < 4 ) - { - /* Remove the slot from the free-list. Update the number of - ** fragmented bytes within the page. */ - data[addr + 0] = data[pc + 0]; - data[addr + 1] = data[pc + 1]; //memcpy( data[addr], ref data[pc], 2 ); - data[hdr + 7] = (u8)( nFrag + x ); - } - else if ( size + pc > usableSize ) - { - return SQLITE_CORRUPT_BKPT(); - } - else - { - /* The slot remains on the free-list. Reduce its size to account - ** for the portion used by the new allocation. */ - put2byte( data, pc + 2, x ); - } - pIdx = pc + x; - return SQLITE_OK; - } - } - } - - /* Check to make sure there is enough space in the gap to satisfy - ** the allocation. If not, defragment. - */ - testcase( gap + 2 + nByte == top ); - if ( gap + 2 + nByte > top ) - { - rc = defragmentPage( pPage ); - if ( rc != 0 ) - return rc; - top = get2byteNotZero( data, hdr + 5 ); - Debug.Assert( gap + nByte <= top ); - } - - - /* Allocate memory from the gap in between the cell pointer array - ** and the cell content area. The btreeInitPage() call has already - ** validated the freelist. Given that the freelist is valid, there - ** is no way that the allocation can extend off the end of the page. - ** The Debug.Assert() below verifies the previous sentence. - */ - top -= nByte; - put2byte( data, hdr + 5, top ); - Debug.Assert( top + nByte <= (int)pPage.pBt.usableSize ); - pIdx = top; - return SQLITE_OK; -} + /* + ** Allocate nByte bytes of space from within the B-Tree page passed + ** as the first argument. Write into pIdx the index into pPage.aData[] + ** of the first byte of allocated space. Return either SQLITE_OK or + ** an error code (usually SQLITE_CORRUPT). + ** + ** The caller guarantees that there is sufficient space to make the + ** allocation. This routine might need to defragment in order to bring + ** all the space together, however. This routine will avoid using + ** the first two bytes past the cell pointer area since presumably this + ** allocation is being made in order to insert a new cell, so we will + ** also end up needing a new cell pointer. + */ + static int allocateSpace(MemPage pPage, int nByte, ref int pIdx) { + int hdr = pPage.hdrOffset; /* Local cache of pPage.hdrOffset */ + u8[] data = pPage.aData; /* Local cache of pPage.aData */ + int nFrag; /* Number of fragmented bytes on pPage */ + int top; /* First byte of cell content area */ + int gap; /* First byte of gap between cell pointers and cell content */ + int rc; /* Integer return code */ + u32 usableSize; /* Usable size of the page */ + + Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); + Debug.Assert(pPage.pBt != null); + Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); + Debug.Assert(nByte >= 0); /* Minimum cell size is 4 */ + Debug.Assert(pPage.nFree >= nByte); + Debug.Assert(pPage.nOverflow == 0); + usableSize = pPage.pBt.usableSize; + Debug.Assert(nByte < usableSize - 8); + + nFrag = data[hdr + 7]; + Debug.Assert(pPage.cellOffset == hdr + 12 - 4 * pPage.leaf); + gap = pPage.cellOffset + 2 * pPage.nCell; + top = get2byteNotZero(data, hdr + 5); + if (gap > top) + return SQLITE_CORRUPT_BKPT(); + testcase(gap + 2 == top); + testcase(gap + 1 == top); + testcase(gap == top); + + if (nFrag >= 60) { + /* Always defragment highly fragmented pages */ + rc = defragmentPage(pPage); + if (rc != 0) + return rc; + top = get2byteNotZero(data, hdr + 5); + } else if (gap + 2 <= top) { + /* Search the freelist looking for a free slot big enough to satisfy + ** the request. The allocation is made from the first free slot in + ** the list that is large enough to accomadate it. + */ + int pc, addr; + for (addr = hdr + 1; (pc = get2byte(data, addr)) > 0; addr = pc) { + int size; /* Size of free slot */ + if (pc > usableSize - 4 || pc < addr + 4) { + return SQLITE_CORRUPT_BKPT(); + } + size = get2byte(data, pc + 2); + if (size >= nByte) { + int x = size - nByte; + testcase(x == 4); + testcase(x == 3); + if (x < 4) { + /* Remove the slot from the free-list. Update the number of + ** fragmented bytes within the page. */ + data[addr + 0] = data[pc + 0]; + data[addr + 1] = data[pc + 1]; //memcpy( data[addr], ref data[pc], 2 ); + data[hdr + 7] = (u8)(nFrag + x); + } else if (size + pc > usableSize) { + return SQLITE_CORRUPT_BKPT(); + } else { + /* The slot remains on the free-list. Reduce its size to account + ** for the portion used by the new allocation. */ + put2byte(data, pc + 2, x); + } + pIdx = pc + x; + return SQLITE_OK; + } + } + } -/* -** Return a section of the pPage.aData to the freelist. -** The first byte of the new free block is pPage.aDisk[start] -** and the size of the block is "size" bytes. -** -** Most of the effort here is involved in coalesing adjacent -** free blocks into a single big free block. -*/ -static int freeSpace( MemPage pPage, u32 start, int size ) -{ - return freeSpace( pPage, (int)start, size ); -} -static int freeSpace( MemPage pPage, int start, int size ) -{ - int addr, pbegin, hdr; - int iLast; /* Largest possible freeblock offset */ - byte[] data = pPage.aData; - - Debug.Assert( pPage.pBt != null ); - Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); - Debug.Assert( start >= pPage.hdrOffset + 6 + pPage.childPtrSize ); - Debug.Assert( ( start + size ) <= (int)pPage.pBt.usableSize ); - Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); - Debug.Assert( size >= 0 ); /* Minimum cell size is 4 */ - - if ( pPage.pBt.secureDelete ) - { - /* Overwrite deleted information with zeros when the secure_delete - ** option is enabled */ - Array.Clear( data, start, size );// memset(&data[start], 0, size); - } - - /* Add the space back into the linked list of freeblocks. Note that - ** even though the freeblock list was checked by btreeInitPage(), - ** btreeInitPage() did not detect overlapping cells or - ** freeblocks that overlapped cells. Nor does it detect when the - ** cell content area exceeds the value in the page header. If these - ** situations arise, then subsequent insert operations might corrupt - ** the freelist. So we do need to check for corruption while scanning - ** the freelist. - */ - hdr = pPage.hdrOffset; - addr = hdr + 1; - iLast = (int)pPage.pBt.usableSize - 4; - Debug.Assert( start <= iLast ); - while ( ( pbegin = get2byte( data, addr ) ) < start && pbegin > 0 ) - { - if ( pbegin < addr + 4 ) - { - return SQLITE_CORRUPT_BKPT(); - } - addr = pbegin; - } - if ( pbegin > iLast ) - { - return SQLITE_CORRUPT_BKPT(); - } - Debug.Assert( pbegin > addr || pbegin == 0 ); - put2byte( data, addr, start ); - put2byte( data, start, pbegin ); - put2byte( data, start + 2, size ); - pPage.nFree = (u16)( pPage.nFree + size ); - - /* Coalesce adjacent free blocks */ - addr = hdr + 1; - while ( ( pbegin = get2byte( data, addr ) ) > 0 ) - { - int pnext, psize, x; - Debug.Assert( pbegin > addr ); - Debug.Assert( pbegin <= (int)pPage.pBt.usableSize - 4 ); - pnext = get2byte( data, pbegin ); - psize = get2byte( data, pbegin + 2 ); - if ( pbegin + psize + 3 >= pnext && pnext > 0 ) - { - int frag = pnext - ( pbegin + psize ); - if ( ( frag < 0 ) || ( frag > (int)data[hdr + 7] ) ) - { - return SQLITE_CORRUPT_BKPT(); - } - data[hdr + 7] -= (u8)frag; - x = get2byte( data, pnext ); - put2byte( data, pbegin, x ); - x = pnext + get2byte( data, pnext + 2 ) - pbegin; - put2byte( data, pbegin + 2, x ); - } - else - { - addr = pbegin; - } - } - - /* If the cell content area begins with a freeblock, remove it. */ - if ( data[hdr + 1] == data[hdr + 5] && data[hdr + 2] == data[hdr + 6] ) - { - int top; - pbegin = get2byte( data, hdr + 1 ); - put2byte( data, hdr + 1, get2byte( data, pbegin ) ); //memcpy( data[hdr + 1], ref data[pbegin], 2 ); - top = get2byte( data, hdr + 5 ) + get2byte( data, pbegin + 2 ); - put2byte( data, hdr + 5, top ); - } - Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); - return SQLITE_OK; -} + /* Check to make sure there is enough space in the gap to satisfy + ** the allocation. If not, defragment. + */ + testcase(gap + 2 + nByte == top); + if (gap + 2 + nByte > top) { + rc = defragmentPage(pPage); + if (rc != 0) + return rc; + top = get2byteNotZero(data, hdr + 5); + Debug.Assert(gap + nByte <= top); + } -/* -** Decode the flags byte (the first byte of the header) for a page -** and initialize fields of the MemPage structure accordingly. -** -** Only the following combinations are supported. Anything different -** indicates a corrupt database files: -** -** PTF_ZERODATA -** PTF_ZERODATA | PTF_LEAF -** PTF_LEAFDATA | PTF_INTKEY -** PTF_LEAFDATA | PTF_INTKEY | PTF_LEAF -*/ -static int decodeFlags( MemPage pPage, int flagByte ) -{ - BtShared pBt; /* A copy of pPage.pBt */ - - Debug.Assert( pPage.hdrOffset == ( pPage.pgno == 1 ? 100 : 0 ) ); - Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); - pPage.leaf = (u8)( flagByte >> 3 ); - Debug.Assert( PTF_LEAF == 1 << 3 ); - flagByte &= ~PTF_LEAF; - pPage.childPtrSize = (u8)( 4 - 4 * pPage.leaf ); - pBt = pPage.pBt; - if ( flagByte == ( PTF_LEAFDATA | PTF_INTKEY ) ) - { - pPage.intKey = 1; - pPage.hasData = pPage.leaf; - pPage.maxLocal = pBt.maxLeaf; - pPage.minLocal = pBt.minLeaf; - } - else if ( flagByte == PTF_ZERODATA ) - { - pPage.intKey = 0; - pPage.hasData = 0; - pPage.maxLocal = pBt.maxLocal; - pPage.minLocal = pBt.minLocal; - } - else - { - return SQLITE_CORRUPT_BKPT(); - } - return SQLITE_OK; -} -/* -** Initialize the auxiliary information for a disk block. -** -** Return SQLITE_OK on success. If we see that the page does -** not contain a well-formed database page, then return -** SQLITE_CORRUPT. Note that a return of SQLITE_OK does not -** guarantee that the page is well-formed. It only shows that -** we failed to detect any corruption. -*/ -static int btreeInitPage( MemPage pPage ) -{ + /* Allocate memory from the gap in between the cell pointer array + ** and the cell content area. The btreeInitPage() call has already + ** validated the freelist. Given that the freelist is valid, there + ** is no way that the allocation can extend off the end of the page. + ** The Debug.Assert() below verifies the previous sentence. + */ + top -= nByte; + put2byte(data, hdr + 5, top); + Debug.Assert(top + nByte <= (int)pPage.pBt.usableSize); + pIdx = top; + return SQLITE_OK; + } - Debug.Assert( pPage.pBt != null ); - Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); - Debug.Assert( pPage.pgno == sqlite3PagerPagenumber( pPage.pDbPage ) ); - Debug.Assert( pPage == sqlite3PagerGetExtra( pPage.pDbPage ) ); - Debug.Assert( pPage.aData == sqlite3PagerGetData( pPage.pDbPage ) ); - - if ( 0 == pPage.isInit ) - { - u16 pc; /* Address of a freeblock within pPage.aData[] */ - u8 hdr; /* Offset to beginning of page header */ - u8[] data; /* Equal to pPage.aData */ - BtShared pBt; /* The main btree structure */ - int usableSize; /* Amount of usable space on each page */ - u16 cellOffset; /* Offset from start of page to first cell pointer */ - int nFree; /* Number of unused bytes on the page */ - int top; /* First byte of the cell content area */ - int iCellFirst; /* First allowable cell or freeblock offset */ - int iCellLast; /* Last possible cell or freeblock offset */ - - pBt = pPage.pBt; - - hdr = pPage.hdrOffset; - data = pPage.aData; - if ( decodeFlags( pPage, data[hdr] ) != 0 ) - return SQLITE_CORRUPT_BKPT(); - Debug.Assert( pBt.pageSize >= 512 && pBt.pageSize <= 65536 ); - pPage.maskPage = (u16)( pBt.pageSize - 1 ); - pPage.nOverflow = 0; - usableSize = (int)pBt.usableSize; - pPage.cellOffset = ( cellOffset = (u16)( hdr + 12 - 4 * pPage.leaf ) ); - top = get2byteNotZero( data, hdr + 5 ); - pPage.nCell = (u16)( get2byte( data, hdr + 3 ) ); - if ( pPage.nCell > MX_CELL( pBt ) ) - { - /* To many cells for a single page. The page must be corrupt */ - return SQLITE_CORRUPT_BKPT(); - } - testcase( pPage.nCell == MX_CELL( pBt ) ); - - /* A malformed database page might cause us to read past the end - ** of page when parsing a cell. - ** - ** The following block of code checks early to see if a cell extends - ** past the end of a page boundary and causes SQLITE_CORRUPT to be - ** returned if it does. - */ - iCellFirst = cellOffset + 2 * pPage.nCell; - iCellLast = usableSize - 4; + /* + ** Return a section of the pPage.aData to the freelist. + ** The first byte of the new free block is pPage.aDisk[start] + ** and the size of the block is "size" bytes. + ** + ** Most of the effort here is involved in coalesing adjacent + ** free blocks into a single big free block. + */ + static int freeSpace(MemPage pPage, u32 start, int size) { + return freeSpace(pPage, (int)start, size); + } + static int freeSpace(MemPage pPage, int start, int size) { + int addr, pbegin, hdr; + int iLast; /* Largest possible freeblock offset */ + byte[] data = pPage.aData; + + Debug.Assert(pPage.pBt != null); + Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); + Debug.Assert(start >= pPage.hdrOffset + 6 + pPage.childPtrSize); + Debug.Assert((start + size) <= (int)pPage.pBt.usableSize); + Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); + Debug.Assert(size >= 0); /* Minimum cell size is 4 */ + + if (pPage.pBt.secureDelete) { + /* Overwrite deleted information with zeros when the secure_delete + ** option is enabled */ + Array.Clear(data, start, size);// memset(&data[start], 0, size); + } + + /* Add the space back into the linked list of freeblocks. Note that + ** even though the freeblock list was checked by btreeInitPage(), + ** btreeInitPage() did not detect overlapping cells or + ** freeblocks that overlapped cells. Nor does it detect when the + ** cell content area exceeds the value in the page header. If these + ** situations arise, then subsequent insert operations might corrupt + ** the freelist. So we do need to check for corruption while scanning + ** the freelist. + */ + hdr = pPage.hdrOffset; + addr = hdr + 1; + iLast = (int)pPage.pBt.usableSize - 4; + Debug.Assert(start <= iLast); + while ((pbegin = get2byte(data, addr)) < start && pbegin > 0) { + if (pbegin < addr + 4) { + return SQLITE_CORRUPT_BKPT(); + } + addr = pbegin; + } + if (pbegin > iLast) { + return SQLITE_CORRUPT_BKPT(); + } + Debug.Assert(pbegin > addr || pbegin == 0); + put2byte(data, addr, start); + put2byte(data, start, pbegin); + put2byte(data, start + 2, size); + pPage.nFree = (u16)(pPage.nFree + size); + + /* Coalesce adjacent free blocks */ + addr = hdr + 1; + while ((pbegin = get2byte(data, addr)) > 0) { + int pnext, psize, x; + Debug.Assert(pbegin > addr); + Debug.Assert(pbegin <= (int)pPage.pBt.usableSize - 4); + pnext = get2byte(data, pbegin); + psize = get2byte(data, pbegin + 2); + if (pbegin + psize + 3 >= pnext && pnext > 0) { + int frag = pnext - (pbegin + psize); + if ((frag < 0) || (frag > (int)data[hdr + 7])) { + return SQLITE_CORRUPT_BKPT(); + } + data[hdr + 7] -= (u8)frag; + x = get2byte(data, pnext); + put2byte(data, pbegin, x); + x = pnext + get2byte(data, pnext + 2) - pbegin; + put2byte(data, pbegin + 2, x); + } else { + addr = pbegin; + } + } + + /* If the cell content area begins with a freeblock, remove it. */ + if (data[hdr + 1] == data[hdr + 5] && data[hdr + 2] == data[hdr + 6]) { + int top; + pbegin = get2byte(data, hdr + 1); + put2byte(data, hdr + 1, get2byte(data, pbegin)); //memcpy( data[hdr + 1], ref data[pbegin], 2 ); + top = get2byte(data, hdr + 5) + get2byte(data, pbegin + 2); + put2byte(data, hdr + 5, top); + } + Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); + return SQLITE_OK; + } + + /* + ** Decode the flags byte (the first byte of the header) for a page + ** and initialize fields of the MemPage structure accordingly. + ** + ** Only the following combinations are supported. Anything different + ** indicates a corrupt database files: + ** + ** PTF_ZERODATA + ** PTF_ZERODATA | PTF_LEAF + ** PTF_LEAFDATA | PTF_INTKEY + ** PTF_LEAFDATA | PTF_INTKEY | PTF_LEAF + */ + static int decodeFlags(MemPage pPage, int flagByte) { + BtShared pBt; /* A copy of pPage.pBt */ + + Debug.Assert(pPage.hdrOffset == (pPage.pgno == 1 ? 100 : 0)); + Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); + pPage.leaf = (u8)(flagByte >> 3); + Debug.Assert(PTF_LEAF == 1 << 3); + flagByte &= ~PTF_LEAF; + pPage.childPtrSize = (u8)(4 - 4 * pPage.leaf); + pBt = pPage.pBt; + if (flagByte == (PTF_LEAFDATA | PTF_INTKEY)) { + pPage.intKey = 1; + pPage.hasData = pPage.leaf; + pPage.maxLocal = pBt.maxLeaf; + pPage.minLocal = pBt.minLeaf; + } else if (flagByte == PTF_ZERODATA) { + pPage.intKey = 0; + pPage.hasData = 0; + pPage.maxLocal = pBt.maxLocal; + pPage.minLocal = pBt.minLocal; + } else { + return SQLITE_CORRUPT_BKPT(); + } + return SQLITE_OK; + } + + /* + ** Initialize the auxiliary information for a disk block. + ** + ** Return SQLITE_OK on success. If we see that the page does + ** not contain a well-formed database page, then return + ** SQLITE_CORRUPT. Note that a return of SQLITE_OK does not + ** guarantee that the page is well-formed. It only shows that + ** we failed to detect any corruption. + */ + static int btreeInitPage(MemPage pPage) { + + Debug.Assert(pPage.pBt != null); + Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); + Debug.Assert(pPage.pgno == sqlite3PagerPagenumber(pPage.pDbPage)); + Debug.Assert(pPage == sqlite3PagerGetExtra(pPage.pDbPage)); + Debug.Assert(pPage.aData == sqlite3PagerGetData(pPage.pDbPage)); + + if (0 == pPage.isInit) { + u16 pc; /* Address of a freeblock within pPage.aData[] */ + u8 hdr; /* Offset to beginning of page header */ + u8[] data; /* Equal to pPage.aData */ + BtShared pBt; /* The main btree structure */ + int usableSize; /* Amount of usable space on each page */ + u16 cellOffset; /* Offset from start of page to first cell pointer */ + int nFree; /* Number of unused bytes on the page */ + int top; /* First byte of the cell content area */ + int iCellFirst; /* First allowable cell or freeblock offset */ + int iCellLast; /* Last possible cell or freeblock offset */ + + pBt = pPage.pBt; + + hdr = pPage.hdrOffset; + data = pPage.aData; + if (decodeFlags(pPage, data[hdr]) != 0) + return SQLITE_CORRUPT_BKPT(); + Debug.Assert(pBt.pageSize >= 512 && pBt.pageSize <= 65536); + pPage.maskPage = (u16)(pBt.pageSize - 1); + pPage.nOverflow = 0; + usableSize = (int)pBt.usableSize; + pPage.cellOffset = (cellOffset = (u16)(hdr + 12 - 4 * pPage.leaf)); + top = get2byteNotZero(data, hdr + 5); + pPage.nCell = (u16)(get2byte(data, hdr + 3)); + if (pPage.nCell > MX_CELL(pBt)) { + /* To many cells for a single page. The page must be corrupt */ + return SQLITE_CORRUPT_BKPT(); + } + testcase(pPage.nCell == MX_CELL(pBt)); + + /* A malformed database page might cause us to read past the end + ** of page when parsing a cell. + ** + ** The following block of code checks early to see if a cell extends + ** past the end of a page boundary and causes SQLITE_CORRUPT to be + ** returned if it does. + */ + iCellFirst = cellOffset + 2 * pPage.nCell; + iCellLast = usableSize - 4; #if (SQLITE_ENABLE_OVERSIZE_CELL_CHECK) - { - int i; /* Index into the cell pointer array */ - int sz; /* Size of a cell */ - - if ( 0 == pPage.leaf ) - iCellLast--; - for ( i = 0; i < pPage.nCell; i++ ) - { - pc = (u16)get2byte( data, cellOffset + i * 2 ); - testcase( pc == iCellFirst ); - testcase( pc == iCellLast ); - if ( pc < iCellFirst || pc > iCellLast ) - { - return SQLITE_CORRUPT_BKPT(); - } - sz = cellSizePtr( pPage, data, pc ); - testcase( pc + sz == usableSize ); - if ( pc + sz > usableSize ) - { - return SQLITE_CORRUPT_BKPT(); - } - } - if ( 0 == pPage.leaf ) - iCellLast++; - } + { + int i; /* Index into the cell pointer array */ + int sz; /* Size of a cell */ + + if (0 == pPage.leaf) + iCellLast--; + for (i = 0; i < pPage.nCell; i++) { + pc = (u16)get2byte(data, cellOffset + i * 2); + testcase(pc == iCellFirst); + testcase(pc == iCellLast); + if (pc < iCellFirst || pc > iCellLast) { + return SQLITE_CORRUPT_BKPT(); + } + sz = cellSizePtr(pPage, data, pc); + testcase(pc + sz == usableSize); + if (pc + sz > usableSize) { + return SQLITE_CORRUPT_BKPT(); + } + } + if (0 == pPage.leaf) + iCellLast++; + } #endif - /* Compute the total free space on the page */ - pc = (u16)get2byte( data, hdr + 1 ); - nFree = (u16)( data[hdr + 7] + top ); - while ( pc > 0 ) - { - u16 next, size; - if ( pc < iCellFirst || pc > iCellLast ) - { - /* Start of free block is off the page */ - return SQLITE_CORRUPT_BKPT(); - } - next = (u16)get2byte( data, pc ); - size = (u16)get2byte( data, pc + 2 ); - if ( ( next > 0 && next <= pc + size + 3 ) || pc + size > usableSize ) - { - /* Free blocks must be in ascending order. And the last byte of - ** the free-block must lie on the database page. */ - return SQLITE_CORRUPT_BKPT(); - } - nFree = (u16)( nFree + size ); - pc = next; - } + /* Compute the total free space on the page */ + pc = (u16)get2byte(data, hdr + 1); + nFree = (u16)(data[hdr + 7] + top); + while (pc > 0) { + u16 next, size; + if (pc < iCellFirst || pc > iCellLast) { + /* Start of free block is off the page */ + return SQLITE_CORRUPT_BKPT(); + } + next = (u16)get2byte(data, pc); + size = (u16)get2byte(data, pc + 2); + if ((next > 0 && next <= pc + size + 3) || pc + size > usableSize) { + /* Free blocks must be in ascending order. And the last byte of + ** the free-block must lie on the database page. */ + return SQLITE_CORRUPT_BKPT(); + } + nFree = (u16)(nFree + size); + pc = next; + } + + /* At this point, nFree contains the sum of the offset to the start + ** of the cell-content area plus the number of free bytes within + ** the cell-content area. If this is greater than the usable-size + ** of the page, then the page must be corrupted. This check also + ** serves to verify that the offset to the start of the cell-content + ** area, according to the page header, lies within the page. + */ + if (nFree > usableSize) { + return SQLITE_CORRUPT_BKPT(); + } + pPage.nFree = (u16)(nFree - iCellFirst); + pPage.isInit = 1; + } + return SQLITE_OK; + } - /* At this point, nFree contains the sum of the offset to the start - ** of the cell-content area plus the number of free bytes within - ** the cell-content area. If this is greater than the usable-size - ** of the page, then the page must be corrupted. This check also - ** serves to verify that the offset to the start of the cell-content - ** area, according to the page header, lies within the page. - */ - if ( nFree > usableSize ) - { - return SQLITE_CORRUPT_BKPT(); - } - pPage.nFree = (u16)( nFree - iCellFirst ); - pPage.isInit = 1; - } - return SQLITE_OK; -} + /* + ** Set up a raw page so that it looks like a database page holding + ** no entries. + */ + static void zeroPage(MemPage pPage, int flags) { + byte[] data = pPage.aData; + BtShared pBt = pPage.pBt; + u8 hdr = pPage.hdrOffset; + u16 first; + + Debug.Assert(sqlite3PagerPagenumber(pPage.pDbPage) == pPage.pgno); + Debug.Assert(sqlite3PagerGetExtra(pPage.pDbPage) == pPage); + Debug.Assert(sqlite3PagerGetData(pPage.pDbPage) == data); + Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); + Debug.Assert(sqlite3_mutex_held(pBt.mutex)); + if (pBt.secureDelete) { + Array.Clear(data, hdr, (int)(pBt.usableSize - hdr));//memset(&data[hdr], 0, pBt->usableSize - hdr); + } -/* -** Set up a raw page so that it looks like a database page holding -** no entries. -*/ -static void zeroPage( MemPage pPage, int flags ) -{ - byte[] data = pPage.aData; - BtShared pBt = pPage.pBt; - u8 hdr = pPage.hdrOffset; - u16 first; - - Debug.Assert( sqlite3PagerPagenumber( pPage.pDbPage ) == pPage.pgno ); - Debug.Assert( sqlite3PagerGetExtra( pPage.pDbPage ) == pPage ); - Debug.Assert( sqlite3PagerGetData( pPage.pDbPage ) == data ); - Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); - Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); - if ( pBt.secureDelete ) - { - Array.Clear( data, hdr, (int)( pBt.usableSize - hdr ) );//memset(&data[hdr], 0, pBt->usableSize - hdr); - } - - data[hdr] = (u8)flags; - first = (u16)( hdr + 8 + 4 * ( ( flags & PTF_LEAF ) == 0 ? 1 : 0 ) ); - Array.Clear( data, hdr + 1, 4 );//memset(data[hdr+1], 0, 4); - data[hdr + 7] = 0; - put2byte( data, hdr + 5, pBt.usableSize ); - pPage.nFree = (u16)( pBt.usableSize - first ); - decodeFlags( pPage, flags ); - pPage.hdrOffset = hdr; - pPage.cellOffset = first; - pPage.nOverflow = 0; - Debug.Assert( pBt.pageSize >= 512 && pBt.pageSize <= 65536 ); - pPage.maskPage = (u16)( pBt.pageSize - 1 ); - pPage.nCell = 0; - pPage.isInit = 1; -} + data[hdr] = (u8)flags; + first = (u16)(hdr + 8 + 4 * ((flags & PTF_LEAF) == 0 ? 1 : 0)); + Array.Clear(data, hdr + 1, 4);//memset(data[hdr+1], 0, 4); + data[hdr + 7] = 0; + put2byte(data, hdr + 5, pBt.usableSize); + pPage.nFree = (u16)(pBt.usableSize - first); + decodeFlags(pPage, flags); + pPage.hdrOffset = hdr; + pPage.cellOffset = first; + pPage.nOverflow = 0; + Debug.Assert(pBt.pageSize >= 512 && pBt.pageSize <= 65536); + pPage.maskPage = (u16)(pBt.pageSize - 1); + pPage.nCell = 0; + pPage.isInit = 1; + } -/* -** Convert a DbPage obtained from the pager into a MemPage used by -** the btree layer. -*/ -static MemPage btreePageFromDbPage( DbPage pDbPage, Pgno pgno, BtShared pBt ) -{ - MemPage pPage = (MemPage)sqlite3PagerGetExtra( pDbPage ); - pPage.aData = sqlite3PagerGetData( pDbPage ); - pPage.pDbPage = pDbPage; - pPage.pBt = pBt; - pPage.pgno = pgno; - pPage.hdrOffset = (u8)( pPage.pgno == 1 ? 100 : 0 ); - return pPage; -} + /* + ** Convert a DbPage obtained from the pager into a MemPage used by + ** the btree layer. + */ + static MemPage btreePageFromDbPage(DbPage pDbPage, Pgno pgno, BtShared pBt) { + MemPage pPage = (MemPage)sqlite3PagerGetExtra(pDbPage); + pPage.aData = sqlite3PagerGetData(pDbPage); + pPage.pDbPage = pDbPage; + pPage.pBt = pBt; + pPage.pgno = pgno; + pPage.hdrOffset = (u8)(pPage.pgno == 1 ? 100 : 0); + return pPage; + } -/* -** Get a page from the pager. Initialize the MemPage.pBt and -** MemPage.aData elements if needed. -** -** If the noContent flag is set, it means that we do not care about -** the content of the page at this time. So do not go to the disk -** to fetch the content. Just fill in the content with zeros for now. -** If in the future we call sqlite3PagerWrite() on this page, that -** means we have started to be concerned about content and the disk -** read should occur at that point. -*/ -static int btreeGetPage( -BtShared pBt, /* The btree */ -Pgno pgno, /* Number of the page to fetch */ -ref MemPage ppPage, /* Return the page in this parameter */ -int noContent /* Do not load page content if true */ -) -{ - int rc; - DbPage pDbPage = null; - - Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); - rc = sqlite3PagerAcquire( pBt.pPager, pgno, ref pDbPage, (u8)noContent ); - if ( rc != 0 ) - return rc; - ppPage = btreePageFromDbPage( pDbPage, pgno, pBt ); - return SQLITE_OK; -} + /* + ** Get a page from the pager. Initialize the MemPage.pBt and + ** MemPage.aData elements if needed. + ** + ** If the noContent flag is set, it means that we do not care about + ** the content of the page at this time. So do not go to the disk + ** to fetch the content. Just fill in the content with zeros for now. + ** If in the future we call sqlite3PagerWrite() on this page, that + ** means we have started to be concerned about content and the disk + ** read should occur at that point. + */ + static int btreeGetPage( + BtShared pBt, /* The btree */ + Pgno pgno, /* Number of the page to fetch */ + ref MemPage ppPage, /* Return the page in this parameter */ + int noContent /* Do not load page content if true */ + ) { + int rc; + DbPage pDbPage = null; + + Debug.Assert(sqlite3_mutex_held(pBt.mutex)); + rc = sqlite3PagerAcquire(pBt.pPager, pgno, ref pDbPage, (u8)noContent); + if (rc != 0) + return rc; + ppPage = btreePageFromDbPage(pDbPage, pgno, pBt); + return SQLITE_OK; + } -/* -** Retrieve a page from the pager cache. If the requested page is not -** already in the pager cache return NULL. Initialize the MemPage.pBt and -** MemPage.aData elements if needed. -*/ -static MemPage btreePageLookup( BtShared pBt, Pgno pgno ) -{ - DbPage pDbPage; - Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); - pDbPage = sqlite3PagerLookup( pBt.pPager, pgno ); - if ( pDbPage ) - { - return btreePageFromDbPage( pDbPage, pgno, pBt ); - } - return null; -} + /* + ** Retrieve a page from the pager cache. If the requested page is not + ** already in the pager cache return NULL. Initialize the MemPage.pBt and + ** MemPage.aData elements if needed. + */ + static MemPage btreePageLookup(BtShared pBt, Pgno pgno) { + DbPage pDbPage; + Debug.Assert(sqlite3_mutex_held(pBt.mutex)); + pDbPage = sqlite3PagerLookup(pBt.pPager, pgno); + if (pDbPage) { + return btreePageFromDbPage(pDbPage, pgno, pBt); + } + return null; + } -/* -** Return the size of the database file in pages. If there is any kind of -** error, return ((unsigned int)-1). -*/ -static Pgno btreePagecount( BtShared pBt ) -{ - return pBt.nPage; -} -static Pgno sqlite3BtreeLastPage( Btree p ) -{ - Debug.Assert( sqlite3BtreeHoldsMutex( p ) ); - Debug.Assert( ( ( p.pBt.nPage ) & 0x8000000 ) == 0 ); - return (Pgno)btreePagecount( p.pBt ); -} + /* + ** Return the size of the database file in pages. If there is any kind of + ** error, return ((unsigned int)-1). + */ + static Pgno btreePagecount(BtShared pBt) { + return pBt.nPage; + } + static Pgno sqlite3BtreeLastPage(Btree p) { + Debug.Assert(sqlite3BtreeHoldsMutex(p)); + Debug.Assert(((p.pBt.nPage) & 0x8000000) == 0); + return (Pgno)btreePagecount(p.pBt); + } -/* -** Get a page from the pager and initialize it. This routine is just a -** convenience wrapper around separate calls to btreeGetPage() and -** btreeInitPage(). -** -** If an error occurs, then the value ppPage is set to is undefined. It -** may remain unchanged, or it may be set to an invalid value. -*/ -static int getAndInitPage( -BtShared pBt, /* The database file */ -Pgno pgno, /* Number of the page to get */ -ref MemPage ppPage /* Write the page pointer here */ -) -{ - int rc; - Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); - - if ( pgno > btreePagecount( pBt ) ) - { - rc = SQLITE_CORRUPT_BKPT(); - } - else - { - rc = btreeGetPage( pBt, pgno, ref ppPage, 0 ); - if ( rc == SQLITE_OK ) - { - rc = btreeInitPage( ppPage ); - if ( rc != SQLITE_OK ) - { - releasePage( ppPage ); - } - } - } + /* + ** Get a page from the pager and initialize it. This routine is just a + ** convenience wrapper around separate calls to btreeGetPage() and + ** btreeInitPage(). + ** + ** If an error occurs, then the value ppPage is set to is undefined. It + ** may remain unchanged, or it may be set to an invalid value. + */ + static int getAndInitPage( + BtShared pBt, /* The database file */ + Pgno pgno, /* Number of the page to get */ + ref MemPage ppPage /* Write the page pointer here */ + ) { + int rc; + Debug.Assert(sqlite3_mutex_held(pBt.mutex)); + + if (pgno > btreePagecount(pBt)) { + rc = SQLITE_CORRUPT_BKPT(); + } else { + rc = btreeGetPage(pBt, pgno, ref ppPage, 0); + if (rc == SQLITE_OK) { + rc = btreeInitPage(ppPage); + if (rc != SQLITE_OK) { + releasePage(ppPage); + } + } + } - testcase( pgno == 0 ); - Debug.Assert( pgno != 0 || rc == SQLITE_CORRUPT ); + testcase(pgno == 0); + Debug.Assert(pgno != 0 || rc == SQLITE_CORRUPT); - return rc; -} + return rc; + } -/* -** Release a MemPage. This should be called once for each prior -** call to btreeGetPage. -*/ -static void releasePage( MemPage pPage ) -{ - if ( pPage != null ) - { - Debug.Assert( pPage.aData != null ); - Debug.Assert( pPage.pBt != null ); - //TODO -- find out why corrupt9 & diskfull fail on this tests - //Debug.Assert( sqlite3PagerGetExtra( pPage.pDbPage ) == pPage ); - //Debug.Assert( sqlite3PagerGetData( pPage.pDbPage ) == pPage.aData ); - Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); - sqlite3PagerUnref( pPage.pDbPage ); - } -} + /* + ** Release a MemPage. This should be called once for each prior + ** call to btreeGetPage. + */ + static void releasePage(MemPage pPage) { + if (pPage != null) { + Debug.Assert(pPage.aData != null); + Debug.Assert(pPage.pBt != null); + //TODO -- find out why corrupt9 & diskfull fail on this tests + //Debug.Assert( sqlite3PagerGetExtra( pPage.pDbPage ) == pPage ); + //Debug.Assert( sqlite3PagerGetData( pPage.pDbPage ) == pPage.aData ); + Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); + sqlite3PagerUnref(pPage.pDbPage); + } + } -/* -** During a rollback, when the pager reloads information into the cache -** so that the cache is restored to its original state at the start of -** the transaction, for each page restored this routine is called. -** -** This routine needs to reset the extra data section at the end of the -** page to agree with the restored data. -*/ -static void pageReinit( DbPage pData ) -{ - MemPage pPage; - pPage = sqlite3PagerGetExtra( pData ); - Debug.Assert( sqlite3PagerPageRefcount( pData ) > 0 ); - if ( pPage.isInit != 0 ) - { - Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); - pPage.isInit = 0; - if ( sqlite3PagerPageRefcount( pData ) > 1 ) - { - /* pPage might not be a btree page; it might be an overflow page - ** or ptrmap page or a free page. In those cases, the following - ** call to btreeInitPage() will likely return SQLITE_CORRUPT. - ** But no harm is done by this. And it is very important that - ** btreeInitPage() be called on every btree page so we make - ** the call for every page that comes in for re-initing. */ - btreeInitPage( pPage ); - } - } -} + /* + ** During a rollback, when the pager reloads information into the cache + ** so that the cache is restored to its original state at the start of + ** the transaction, for each page restored this routine is called. + ** + ** This routine needs to reset the extra data section at the end of the + ** page to agree with the restored data. + */ + static void pageReinit(DbPage pData) { + MemPage pPage; + pPage = sqlite3PagerGetExtra(pData); + Debug.Assert(sqlite3PagerPageRefcount(pData) > 0); + if (pPage.isInit != 0) { + Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); + pPage.isInit = 0; + if (sqlite3PagerPageRefcount(pData) > 1) { + /* pPage might not be a btree page; it might be an overflow page + ** or ptrmap page or a free page. In those cases, the following + ** call to btreeInitPage() will likely return SQLITE_CORRUPT. + ** But no harm is done by this. And it is very important that + ** btreeInitPage() be called on every btree page so we make + ** the call for every page that comes in for re-initing. */ + btreeInitPage(pPage); + } + } + } -/* -** Invoke the busy handler for a btree. -*/ -static int btreeInvokeBusyHandler( object pArg ) -{ - BtShared pBt = (BtShared)pArg; - Debug.Assert( pBt.db != null ); - Debug.Assert( sqlite3_mutex_held( pBt.db.mutex ) ); - return sqlite3InvokeBusyHandler( pBt.db.busyHandler ); -} + /* + ** Invoke the busy handler for a btree. + */ + static int btreeInvokeBusyHandler(object pArg) { + BtShared pBt = (BtShared)pArg; + Debug.Assert(pBt.db != null); + Debug.Assert(sqlite3_mutex_held(pBt.db.mutex)); + return sqlite3InvokeBusyHandler(pBt.db.busyHandler); + } -/* -** Open a database file. -** -** zFilename is the name of the database file. If zFilename is NULL -** then an ephemeral database is created. The ephemeral database might -** be exclusively in memory, or it might use a disk-based memory cache. -** Either way, the ephemeral database will be automatically deleted -** when sqlite3BtreeClose() is called. -** -** If zFilename is ":memory:" then an in-memory database is created -** that is automatically destroyed when it is closed. -** -** The "flags" parameter is a bitmask that might contain bits -** BTREE_OMIT_JOURNAL and/or BTREE_NO_READLOCK. The BTREE_NO_READLOCK -** bit is also set if the SQLITE_NoReadlock flags is set in db->flags. -** These flags are passed through into sqlite3PagerOpen() and must -** be the same values as PAGER_OMIT_JOURNAL and PAGER_NO_READLOCK. -** -** If the database is already opened in the same database connection -** and we are in shared cache mode, then the open will fail with an -** SQLITE_CONSTRAINT error. We cannot allow two or more BtShared -** objects in the same database connection since doing so will lead -** to problems with locking. -*/ -static int sqlite3BtreeOpen( -sqlite3_vfs pVfs, /* VFS to use for this b-tree */ -string zFilename, /* Name of the file containing the BTree database */ -sqlite3 db, /* Associated database handle */ -ref Btree ppBtree, /* Pointer to new Btree object written here */ -int flags, /* Options */ -int vfsFlags /* Flags passed through to sqlite3_vfs.xOpen() */ -) -{ - BtShared pBt = null; /* Shared part of btree structure */ - Btree p; /* Handle to return */ - sqlite3_mutex mutexOpen = null; /* Prevents a race condition. Ticket #3537 */ - int rc = SQLITE_OK; /* Result code from this function */ - u8 nReserve; /* Byte of unused space on each page */ - byte[] zDbHeader = new byte[100]; /* Database header content */ - - /* True if opening an ephemeral, temporary database */ - bool isTempDb = String.IsNullOrEmpty( zFilename );//zFilename==0 || zFilename[0]==0; - - /* Set the variable isMemdb to true for an in-memory database, or - ** false for a file-based database. - */ + /* + ** Open a database file. + ** + ** zFilename is the name of the database file. If zFilename is NULL + ** then an ephemeral database is created. The ephemeral database might + ** be exclusively in memory, or it might use a disk-based memory cache. + ** Either way, the ephemeral database will be automatically deleted + ** when sqlite3BtreeClose() is called. + ** + ** If zFilename is ":memory:" then an in-memory database is created + ** that is automatically destroyed when it is closed. + ** + ** The "flags" parameter is a bitmask that might contain bits + ** BTREE_OMIT_JOURNAL and/or BTREE_NO_READLOCK. The BTREE_NO_READLOCK + ** bit is also set if the SQLITE_NoReadlock flags is set in db->flags. + ** These flags are passed through into sqlite3PagerOpen() and must + ** be the same values as PAGER_OMIT_JOURNAL and PAGER_NO_READLOCK. + ** + ** If the database is already opened in the same database connection + ** and we are in shared cache mode, then the open will fail with an + ** SQLITE_CONSTRAINT error. We cannot allow two or more BtShared + ** objects in the same database connection since doing so will lead + ** to problems with locking. + */ + static int sqlite3BtreeOpen( + sqlite3_vfs pVfs, /* VFS to use for this b-tree */ + string zFilename, /* Name of the file containing the BTree database */ + sqlite3 db, /* Associated database handle */ + ref Btree ppBtree, /* Pointer to new Btree object written here */ + int flags, /* Options */ + int vfsFlags /* Flags passed through to sqlite3_vfs.xOpen() */ + ) { + BtShared pBt = null; /* Shared part of btree structure */ + Btree p; /* Handle to return */ + sqlite3_mutex mutexOpen = null; /* Prevents a race condition. Ticket #3537 */ + int rc = SQLITE_OK; /* Result code from this function */ + u8 nReserve; /* Byte of unused space on each page */ + byte[] zDbHeader = new byte[100]; /* Database header content */ + + /* True if opening an ephemeral, temporary database */ + bool isTempDb = String.IsNullOrEmpty(zFilename);//zFilename==0 || zFilename[0]==0; + + /* Set the variable isMemdb to true for an in-memory database, or + ** false for a file-based database. + */ #if SQLITE_OMIT_MEMORYDB bool isMemdb = false; #else - bool isMemdb = ( zFilename == ":memory:" ) - || ( isTempDb && sqlite3TempInMemory( db ) ); + bool isMemdb = (zFilename == ":memory:") + || (isTempDb && sqlite3TempInMemory(db)); #endif - Debug.Assert( db != null ); - Debug.Assert( pVfs != null ); - Debug.Assert( sqlite3_mutex_held( db.mutex ) ); - Debug.Assert( ( flags & 0xff ) == flags ); /* flags fit in 8 bits */ - - /* Only a BTREE_SINGLE database can be BTREE_UNORDERED */ - Debug.Assert( ( flags & BTREE_UNORDERED ) == 0 || ( flags & BTREE_SINGLE ) != 0 ); - - /* A BTREE_SINGLE database is always a temporary and/or ephemeral */ - Debug.Assert( ( flags & BTREE_SINGLE ) == 0 || isTempDb ); - - if ( ( db.flags & SQLITE_NoReadlock ) != 0 ) - { - flags |= BTREE_NO_READLOCK; - } - if ( isMemdb ) - { - flags |= BTREE_MEMORY; - } - if ( ( vfsFlags & SQLITE_OPEN_MAIN_DB ) != 0 && ( isMemdb || isTempDb ) ) - { - vfsFlags = ( vfsFlags & ~SQLITE_OPEN_MAIN_DB ) | SQLITE_OPEN_TEMP_DB; - } - - p = new Btree();//sqlite3MallocZero(sizeof(Btree)); - //if( !p ){ - // return SQLITE_NOMEM; - //} - p.inTrans = TRANS_NONE; - p.db = db; + Debug.Assert(db != null); + Debug.Assert(pVfs != null); + Debug.Assert(sqlite3_mutex_held(db.mutex)); + Debug.Assert((flags & 0xff) == flags); /* flags fit in 8 bits */ + + /* Only a BTREE_SINGLE database can be BTREE_UNORDERED */ + Debug.Assert((flags & BTREE_UNORDERED) == 0 || (flags & BTREE_SINGLE) != 0); + + /* A BTREE_SINGLE database is always a temporary and/or ephemeral */ + Debug.Assert((flags & BTREE_SINGLE) == 0 || isTempDb); + + if ((db.flags & SQLITE_NoReadlock) != 0) { + flags |= BTREE_NO_READLOCK; + } + if (isMemdb) { + flags |= BTREE_MEMORY; + } + if ((vfsFlags & SQLITE_OPEN_MAIN_DB) != 0 && (isMemdb || isTempDb)) { + vfsFlags = (vfsFlags & ~SQLITE_OPEN_MAIN_DB) | SQLITE_OPEN_TEMP_DB; + } + + p = new Btree();//sqlite3MallocZero(sizeof(Btree)); + //if( !p ){ + // return SQLITE_NOMEM; + //} + p.inTrans = TRANS_NONE; + p.db = db; #if !SQLITE_OMIT_SHARED_CACHE p.lock.pBtree = p; p.lock.iTable = 1; @@ -2137,79 +1976,72 @@ static int sqlite3BtreeOpen( #endif } #endif - if ( pBt == null ) - { - /* - ** The following asserts make sure that structures used by the btree are - ** the right size. This is to guard against size changes that result - ** when compiling on a different architecture. - */ - Debug.Assert( sizeof( i64 ) == 8 || sizeof( i64 ) == 4 ); - Debug.Assert( sizeof( u64 ) == 8 || sizeof( u64 ) == 4 ); - Debug.Assert( sizeof( u32 ) == 4 ); - Debug.Assert( sizeof( u16 ) == 2 ); - Debug.Assert( sizeof( Pgno ) == 4 ); - - pBt = new BtShared();//sqlite3MallocZero( sizeof(pBt) ); - //if( pBt==null ){ - // rc = SQLITE_NOMEM; - // goto btree_open_out; - //} - rc = sqlite3PagerOpen( pVfs, out pBt.pPager, zFilename, - EXTRA_SIZE, flags, vfsFlags, pageReinit ); - if ( rc == SQLITE_OK ) - { - rc = sqlite3PagerReadFileheader( pBt.pPager, zDbHeader.Length, zDbHeader ); - } - if ( rc != SQLITE_OK ) - { - goto btree_open_out; - } - pBt.openFlags = (u8)flags; - pBt.db = db; - sqlite3PagerSetBusyhandler( pBt.pPager, btreeInvokeBusyHandler, pBt ); - p.pBt = pBt; - - pBt.pCursor = null; - pBt.pPage1 = null; - pBt.readOnly = sqlite3PagerIsreadonly( pBt.pPager ); + if (pBt == null) { + /* + ** The following asserts make sure that structures used by the btree are + ** the right size. This is to guard against size changes that result + ** when compiling on a different architecture. + */ + Debug.Assert(sizeof(i64) == 8 || sizeof(i64) == 4); + Debug.Assert(sizeof(u64) == 8 || sizeof(u64) == 4); + Debug.Assert(sizeof(u32) == 4); + Debug.Assert(sizeof(u16) == 2); + Debug.Assert(sizeof(Pgno) == 4); + + pBt = new BtShared();//sqlite3MallocZero( sizeof(pBt) ); + //if( pBt==null ){ + // rc = SQLITE_NOMEM; + // goto btree_open_out; + //} + rc = sqlite3PagerOpen(pVfs, out pBt.pPager, zFilename, + EXTRA_SIZE, flags, vfsFlags, pageReinit); + if (rc == SQLITE_OK) { + rc = sqlite3PagerReadFileheader(pBt.pPager, zDbHeader.Length, zDbHeader); + } + if (rc != SQLITE_OK) { + goto btree_open_out; + } + pBt.openFlags = (u8)flags; + pBt.db = db; + sqlite3PagerSetBusyhandler(pBt.pPager, btreeInvokeBusyHandler, pBt); + p.pBt = pBt; + + pBt.pCursor = null; + pBt.pPage1 = null; + pBt.readOnly = sqlite3PagerIsreadonly(pBt.pPager); #if SQLITE_SECURE_DELETE pBt.secureDelete = true; #endif - pBt.pageSize = (u32)( ( zDbHeader[16] << 8 ) | ( zDbHeader[17] << 16 ) ); - if ( pBt.pageSize < 512 || pBt.pageSize > SQLITE_MAX_PAGE_SIZE - || ( ( pBt.pageSize - 1 ) & pBt.pageSize ) != 0 ) - { - pBt.pageSize = 0; + pBt.pageSize = (u32)((zDbHeader[16] << 8) | (zDbHeader[17] << 16)); + if (pBt.pageSize < 512 || pBt.pageSize > SQLITE_MAX_PAGE_SIZE + || ((pBt.pageSize - 1) & pBt.pageSize) != 0) { + pBt.pageSize = 0; #if !SQLITE_OMIT_AUTOVACUUM - /* If the magic name ":memory:" will create an in-memory database, then -** leave the autoVacuum mode at 0 (do not auto-vacuum), even if -** SQLITE_DEFAULT_AUTOVACUUM is true. On the other hand, if -** SQLITE_OMIT_MEMORYDB has been defined, then ":memory:" is just a -** regular file-name. In this case the auto-vacuum applies as per normal. -*/ - if ( zFilename != "" && !isMemdb ) - { - pBt.autoVacuum = ( SQLITE_DEFAULT_AUTOVACUUM != 0 ); - pBt.incrVacuum = ( SQLITE_DEFAULT_AUTOVACUUM == 2 ); - } + /* If the magic name ":memory:" will create an in-memory database, then + ** leave the autoVacuum mode at 0 (do not auto-vacuum), even if + ** SQLITE_DEFAULT_AUTOVACUUM is true. On the other hand, if + ** SQLITE_OMIT_MEMORYDB has been defined, then ":memory:" is just a + ** regular file-name. In this case the auto-vacuum applies as per normal. + */ + if (zFilename != "" && !isMemdb) { + pBt.autoVacuum = (SQLITE_DEFAULT_AUTOVACUUM != 0); + pBt.incrVacuum = (SQLITE_DEFAULT_AUTOVACUUM == 2); + } #endif - nReserve = 0; - } - else - { - nReserve = zDbHeader[20]; - pBt.pageSizeFixed = true; + nReserve = 0; + } else { + nReserve = zDbHeader[20]; + pBt.pageSizeFixed = true; #if !SQLITE_OMIT_AUTOVACUUM - pBt.autoVacuum = sqlite3Get4byte( zDbHeader, 36 + 4 * 4 ) != 0; - pBt.incrVacuum = sqlite3Get4byte( zDbHeader, 36 + 7 * 4 ) != 0; + pBt.autoVacuum = sqlite3Get4byte(zDbHeader, 36 + 4 * 4) != 0; + pBt.incrVacuum = sqlite3Get4byte(zDbHeader, 36 + 7 * 4) != 0; #endif - } - rc = sqlite3PagerSetPagesize( pBt.pPager, ref pBt.pageSize, nReserve ); - if ( rc != 0 ) - goto btree_open_out; - pBt.usableSize = (u16)( pBt.pageSize - nReserve ); - Debug.Assert( ( pBt.pageSize & 7 ) == 0 ); /* 8-byte alignment of pageSize */ + } + rc = sqlite3PagerSetPagesize(pBt.pPager, ref pBt.pageSize, nReserve); + if (rc != 0) + goto btree_open_out; + pBt.usableSize = (u16)(pBt.pageSize - nReserve); + Debug.Assert((pBt.pageSize & 7) == 0); /* 8-byte alignment of pageSize */ #if !(SQLITE_OMIT_SHARED_CACHE) && !(SQLITE_OMIT_DISKIO) /* Add the new BtShared object to the linked list sharable BtShareds. @@ -2232,7 +2064,7 @@ static int sqlite3BtreeOpen( sqlite3_mutex_leave(mutexShared); } #endif - } + } #if !(SQLITE_OMIT_SHARED_CACHE) && !(SQLITE_OMIT_DISKIO) /* If the new Btree uses a sharable pBtShared, then link the new @@ -2265,47 +2097,40 @@ static int sqlite3BtreeOpen( } } #endif - ppBtree = p; - -btree_open_out: - if ( rc != SQLITE_OK ) - { - if ( pBt != null && pBt.pPager != null ) - { - sqlite3PagerClose( pBt.pPager ); - } - pBt = null; // sqlite3_free(ref pBt); - p = null; // sqlite3_free(ref p); - ppBtree = null; - } - else - { - /* If the B-Tree was successfully opened, set the pager-cache size to the - ** default value. Except, when opening on an existing shared pager-cache, - ** do not change the pager-cache size. - */ - if ( sqlite3BtreeSchema( p, 0, null ) == null ) - { - sqlite3PagerSetCachesize( p.pBt.pPager, SQLITE_DEFAULT_CACHE_SIZE ); - } + ppBtree = p; + + btree_open_out: + if (rc != SQLITE_OK) { + if (pBt != null && pBt.pPager != null) { + sqlite3PagerClose(pBt.pPager); + } + pBt = null; // sqlite3_free(ref pBt); + p = null; // sqlite3_free(ref p); + ppBtree = null; + } else { + /* If the B-Tree was successfully opened, set the pager-cache size to the + ** default value. Except, when opening on an existing shared pager-cache, + ** do not change the pager-cache size. + */ + if (sqlite3BtreeSchema(p, 0, null) == null) { + sqlite3PagerSetCachesize(p.pBt.pPager, SQLITE_DEFAULT_CACHE_SIZE); + } - } - if ( mutexOpen != null ) - { - Debug.Assert( sqlite3_mutex_held( mutexOpen ) ); - sqlite3_mutex_leave( mutexOpen ); - } - return rc; -} + } + if (mutexOpen != null) { + Debug.Assert(sqlite3_mutex_held(mutexOpen)); + sqlite3_mutex_leave(mutexOpen); + } + return rc; + } -/* -** Decrement the BtShared.nRef counter. When it reaches zero, -** remove the BtShared structure from the sharing list. Return -** true if the BtShared.nRef counter reaches zero and return -** false if it is still positive. -*/ -static bool removeFromSharingList( BtShared pBt ) -{ + /* + ** Decrement the BtShared.nRef counter. When it reaches zero, + ** remove the BtShared structure from the sharing list. Return + ** true if the BtShared.nRef counter reaches zero and return + ** false if it is still positive. + */ + static bool removeFromSharingList(BtShared pBt) { #if !SQLITE_OMIT_SHARED_CACHE sqlite3_mutex pMaster; BtShared pList; @@ -2335,81 +2160,73 @@ static bool removeFromSharingList( BtShared pBt ) sqlite3_mutex_leave(pMaster); return removed; #else - return true; + return true; #endif -} + } -/* -** Make sure pBt.pTmpSpace points to an allocation of -** MX_CELL_SIZE(pBt) bytes. -*/ -static void allocateTempSpace( BtShared pBt ) -{ - if ( null == pBt.pTmpSpace ) - { - pBt.pTmpSpace = sqlite3Malloc( pBt.pageSize ); - } -} + /* + ** Make sure pBt.pTmpSpace points to an allocation of + ** MX_CELL_SIZE(pBt) bytes. + */ + static void allocateTempSpace(BtShared pBt) { + if (null == pBt.pTmpSpace) { + pBt.pTmpSpace = sqlite3Malloc(pBt.pageSize); + } + } -/* -** Free the pBt.pTmpSpace allocation -*/ -static void freeTempSpace( BtShared pBt ) -{ - sqlite3PageFree( ref pBt.pTmpSpace ); -} + /* + ** Free the pBt.pTmpSpace allocation + */ + static void freeTempSpace(BtShared pBt) { + sqlite3PageFree(ref pBt.pTmpSpace); + } -/* -** Close an open database and invalidate all cursors. -*/ -static int sqlite3BtreeClose( ref Btree p ) -{ - BtShared pBt = p.pBt; - BtCursor pCur; - - /* Close all cursors opened via this handle. */ - Debug.Assert( sqlite3_mutex_held( p.db.mutex ) ); - sqlite3BtreeEnter( p ); - pCur = pBt.pCursor; - while ( pCur != null ) - { - BtCursor pTmp = pCur; - pCur = pCur.pNext; - if ( pTmp.pBtree == p ) - { - sqlite3BtreeCloseCursor( pTmp ); - } - } - - /* Rollback any active transaction and free the handle structure. - ** The call to sqlite3BtreeRollback() drops any table-locks held by - ** this handle. - */ - sqlite3BtreeRollback( p ); - sqlite3BtreeLeave( p ); - - /* If there are still other outstanding references to the shared-btree - ** structure, return now. The remainder of this procedure cleans - ** up the shared-btree. - */ - Debug.Assert( p.wantToLock == 0 && !p.locked ); - if ( !p.sharable || removeFromSharingList( pBt ) ) - { - /* The pBt is no longer on the sharing list, so we can access - ** it without having to hold the mutex. - ** - ** Clean out and delete the BtShared object. - */ - Debug.Assert( null == pBt.pCursor ); - sqlite3PagerClose( pBt.pPager ); - if ( pBt.xFreeSchema != null && pBt.pSchema != null ) - { - pBt.xFreeSchema( pBt.pSchema ); - } - pBt.pSchema = null;// sqlite3DbFree(0, pBt->pSchema); - //freeTempSpace(pBt); - pBt = null; //sqlite3_free(ref pBt); - } + /* + ** Close an open database and invalidate all cursors. + */ + static int sqlite3BtreeClose(ref Btree p) { + BtShared pBt = p.pBt; + BtCursor pCur; + + /* Close all cursors opened via this handle. */ + Debug.Assert(sqlite3_mutex_held(p.db.mutex)); + sqlite3BtreeEnter(p); + pCur = pBt.pCursor; + while (pCur != null) { + BtCursor pTmp = pCur; + pCur = pCur.pNext; + if (pTmp.pBtree == p) { + sqlite3BtreeCloseCursor(pTmp); + } + } + + /* Rollback any active transaction and free the handle structure. + ** The call to sqlite3BtreeRollback() drops any table-locks held by + ** this handle. + */ + sqlite3BtreeRollback(p); + sqlite3BtreeLeave(p); + + /* If there are still other outstanding references to the shared-btree + ** structure, return now. The remainder of this procedure cleans + ** up the shared-btree. + */ + Debug.Assert(p.wantToLock == 0 && !p.locked); + if (!p.sharable || removeFromSharingList(pBt)) { + /* The pBt is no longer on the sharing list, so we can access + ** it without having to hold the mutex. + ** + ** Clean out and delete the BtShared object. + */ + Debug.Assert(null == pBt.pCursor); + sqlite3PagerClose(pBt.pPager); + if (pBt.xFreeSchema != null && pBt.pSchema != null) { + pBt.xFreeSchema(pBt.pSchema); + } + pBt.pSchema = null;// sqlite3DbFree(0, pBt->pSchema); + //freeTempSpace(pBt); + pBt = null; //sqlite3_free(ref pBt); + } #if !SQLITE_OMIT_SHARED_CACHE Debug.Assert( p.wantToLock==null ); @@ -2418,295 +2235,273 @@ static int sqlite3BtreeClose( ref Btree p ) if( p.pNext ) p.pNext.pPrev = p.pPrev; #endif - //sqlite3_free(ref p); - return SQLITE_OK; -} - -/* -** Change the limit on the number of pages allowed in the cache. -** -** The maximum number of cache pages is set to the absolute -** value of mxPage. If mxPage is negative, the pager will -** operate asynchronously - it will not stop to do fsync()s -** to insure data is written to the disk surface before -** continuing. Transactions still work if synchronous is off, -** and the database cannot be corrupted if this program -** crashes. But if the operating system crashes or there is -** an abrupt power failure when synchronous is off, the database -** could be left in an inconsistent and unrecoverable state. -** Synchronous is on by default so database corruption is not -** normally a worry. -*/ -static int sqlite3BtreeSetCacheSize( Btree p, int mxPage ) -{ - BtShared pBt = p.pBt; - Debug.Assert( sqlite3_mutex_held( p.db.mutex ) ); - sqlite3BtreeEnter( p ); - sqlite3PagerSetCachesize( pBt.pPager, mxPage ); - sqlite3BtreeLeave( p ); - return SQLITE_OK; -} + //sqlite3_free(ref p); + return SQLITE_OK; + } -/* -** Change the way data is synced to disk in order to increase or decrease -** how well the database resists damage due to OS crashes and power -** failures. Level 1 is the same as asynchronous (no syncs() occur and -** there is a high probability of damage) Level 2 is the default. There -** is a very low but non-zero probability of damage. Level 3 reduces the -** probability of damage to near zero but with a write performance reduction. -*/ + /* + ** Change the limit on the number of pages allowed in the cache. + ** + ** The maximum number of cache pages is set to the absolute + ** value of mxPage. If mxPage is negative, the pager will + ** operate asynchronously - it will not stop to do fsync()s + ** to insure data is written to the disk surface before + ** continuing. Transactions still work if synchronous is off, + ** and the database cannot be corrupted if this program + ** crashes. But if the operating system crashes or there is + ** an abrupt power failure when synchronous is off, the database + ** could be left in an inconsistent and unrecoverable state. + ** Synchronous is on by default so database corruption is not + ** normally a worry. + */ + static int sqlite3BtreeSetCacheSize(Btree p, int mxPage) { + BtShared pBt = p.pBt; + Debug.Assert(sqlite3_mutex_held(p.db.mutex)); + sqlite3BtreeEnter(p); + sqlite3PagerSetCachesize(pBt.pPager, mxPage); + sqlite3BtreeLeave(p); + return SQLITE_OK; + } + + /* + ** Change the way data is synced to disk in order to increase or decrease + ** how well the database resists damage due to OS crashes and power + ** failures. Level 1 is the same as asynchronous (no syncs() occur and + ** there is a high probability of damage) Level 2 is the default. There + ** is a very low but non-zero probability of damage. Level 3 reduces the + ** probability of damage to near zero but with a write performance reduction. + */ #if !SQLITE_OMIT_PAGER_PRAGMAS -static int sqlite3BtreeSetSafetyLevel( -Btree p, /* The btree to set the safety level on */ -int level, /* PRAGMA synchronous. 1=OFF, 2=NORMAL, 3=FULL */ -int fullSync, /* PRAGMA fullfsync. */ -int ckptFullSync /* PRAGMA checkpoint_fullfync */ -) -{ - BtShared pBt = p.pBt; - Debug.Assert( sqlite3_mutex_held( p.db.mutex ) ); - Debug.Assert( level >= 1 && level <= 3 ); - sqlite3BtreeEnter( p ); - sqlite3PagerSetSafetyLevel( pBt.pPager, level, fullSync, ckptFullSync ); - sqlite3BtreeLeave( p ); - return SQLITE_OK; -} + static int sqlite3BtreeSetSafetyLevel( + Btree p, /* The btree to set the safety level on */ + int level, /* PRAGMA synchronous. 1=OFF, 2=NORMAL, 3=FULL */ + int fullSync, /* PRAGMA fullfsync. */ + int ckptFullSync /* PRAGMA checkpoint_fullfync */ + ) { + BtShared pBt = p.pBt; + Debug.Assert(sqlite3_mutex_held(p.db.mutex)); + Debug.Assert(level >= 1 && level <= 3); + sqlite3BtreeEnter(p); + sqlite3PagerSetSafetyLevel(pBt.pPager, level, fullSync, ckptFullSync); + sqlite3BtreeLeave(p); + return SQLITE_OK; + } #endif -/* -** Return TRUE if the given btree is set to safety level 1. In other -** words, return TRUE if no sync() occurs on the disk files. -*/ -static int sqlite3BtreeSyncDisabled( Btree p ) -{ - BtShared pBt = p.pBt; - int rc; - Debug.Assert( sqlite3_mutex_held( p.db.mutex ) ); - sqlite3BtreeEnter( p ); - Debug.Assert( pBt != null && pBt.pPager != null ); - rc = sqlite3PagerNosync( pBt.pPager ) ? 1 : 0; - sqlite3BtreeLeave( p ); - return rc; -} + /* + ** Return TRUE if the given btree is set to safety level 1. In other + ** words, return TRUE if no sync() occurs on the disk files. + */ + static int sqlite3BtreeSyncDisabled(Btree p) { + BtShared pBt = p.pBt; + int rc; + Debug.Assert(sqlite3_mutex_held(p.db.mutex)); + sqlite3BtreeEnter(p); + Debug.Assert(pBt != null && pBt.pPager != null); + rc = sqlite3PagerNosync(pBt.pPager) ? 1 : 0; + sqlite3BtreeLeave(p); + return rc; + } -/* -** Change the default pages size and the number of reserved bytes per page. -** Or, if the page size has already been fixed, return SQLITE_READONLY -** without changing anything. -** -** The page size must be a power of 2 between 512 and 65536. If the page -** size supplied does not meet this constraint then the page size is not -** changed. -** -** Page sizes are constrained to be a power of two so that the region -** of the database file used for locking (beginning at PENDING_BYTE, -** the first byte past the 1GB boundary, 0x40000000) needs to occur -** at the beginning of a page. -** -** If parameter nReserve is less than zero, then the number of reserved -** bytes per page is left unchanged. -** -** If iFix!=0 then the pageSizeFixed flag is set so that the page size -** and autovacuum mode can no longer be changed. -*/ -static int sqlite3BtreeSetPageSize( Btree p, int pageSize, int nReserve, int iFix ) -{ - int rc = SQLITE_OK; - BtShared pBt = p.pBt; - Debug.Assert( nReserve >= -1 && nReserve <= 255 ); - sqlite3BtreeEnter( p ); - if ( pBt.pageSizeFixed ) - { - sqlite3BtreeLeave( p ); - return SQLITE_READONLY; - } - if ( nReserve < 0 ) - { - nReserve = (int)( pBt.pageSize - pBt.usableSize ); - } - Debug.Assert( nReserve >= 0 && nReserve <= 255 ); - if ( pageSize >= 512 && pageSize <= SQLITE_MAX_PAGE_SIZE && - ( ( pageSize - 1 ) & pageSize ) == 0 ) - { - Debug.Assert( ( pageSize & 7 ) == 0 ); - Debug.Assert( null == pBt.pPage1 && null == pBt.pCursor ); - pBt.pageSize = (u32)pageSize; - // freeTempSpace(pBt); - } - rc = sqlite3PagerSetPagesize( pBt.pPager, ref pBt.pageSize, nReserve ); - pBt.usableSize = (u16)( pBt.pageSize - nReserve ); - if ( iFix != 0 ) - pBt.pageSizeFixed = true; - sqlite3BtreeLeave( p ); - return rc; -} + /* + ** Change the default pages size and the number of reserved bytes per page. + ** Or, if the page size has already been fixed, return SQLITE_READONLY + ** without changing anything. + ** + ** The page size must be a power of 2 between 512 and 65536. If the page + ** size supplied does not meet this constraint then the page size is not + ** changed. + ** + ** Page sizes are constrained to be a power of two so that the region + ** of the database file used for locking (beginning at PENDING_BYTE, + ** the first byte past the 1GB boundary, 0x40000000) needs to occur + ** at the beginning of a page. + ** + ** If parameter nReserve is less than zero, then the number of reserved + ** bytes per page is left unchanged. + ** + ** If iFix!=0 then the pageSizeFixed flag is set so that the page size + ** and autovacuum mode can no longer be changed. + */ + static int sqlite3BtreeSetPageSize(Btree p, int pageSize, int nReserve, int iFix) { + int rc = SQLITE_OK; + BtShared pBt = p.pBt; + Debug.Assert(nReserve >= -1 && nReserve <= 255); + sqlite3BtreeEnter(p); + if (pBt.pageSizeFixed) { + sqlite3BtreeLeave(p); + return SQLITE_READONLY; + } + if (nReserve < 0) { + nReserve = (int)(pBt.pageSize - pBt.usableSize); + } + Debug.Assert(nReserve >= 0 && nReserve <= 255); + if (pageSize >= 512 && pageSize <= SQLITE_MAX_PAGE_SIZE && + ((pageSize - 1) & pageSize) == 0) { + Debug.Assert((pageSize & 7) == 0); + Debug.Assert(null == pBt.pPage1 && null == pBt.pCursor); + pBt.pageSize = (u32)pageSize; + // freeTempSpace(pBt); + } + rc = sqlite3PagerSetPagesize(pBt.pPager, ref pBt.pageSize, nReserve); + pBt.usableSize = (u16)(pBt.pageSize - nReserve); + if (iFix != 0) + pBt.pageSizeFixed = true; + sqlite3BtreeLeave(p); + return rc; + } -/* -** Return the currently defined page size -*/ -static int sqlite3BtreeGetPageSize( Btree p ) -{ - return (int)p.pBt.pageSize; -} + /* + ** Return the currently defined page size + */ + static int sqlite3BtreeGetPageSize(Btree p) { + return (int)p.pBt.pageSize; + } #if !(SQLITE_OMIT_PAGER_PRAGMAS) || !(SQLITE_OMIT_VACUUM) -/* -** Return the number of bytes of space at the end of every page that -** are intentually left unused. This is the "reserved" space that is -** sometimes used by extensions. -*/ -static int sqlite3BtreeGetReserve( Btree p ) -{ - int n; - sqlite3BtreeEnter( p ); - n = (int)( p.pBt.pageSize - p.pBt.usableSize ); - sqlite3BtreeLeave( p ); - return n; -} + /* + ** Return the number of bytes of space at the end of every page that + ** are intentually left unused. This is the "reserved" space that is + ** sometimes used by extensions. + */ + static int sqlite3BtreeGetReserve(Btree p) { + int n; + sqlite3BtreeEnter(p); + n = (int)(p.pBt.pageSize - p.pBt.usableSize); + sqlite3BtreeLeave(p); + return n; + } -/* -** Set the maximum page count for a database if mxPage is positive. -** No changes are made if mxPage is 0 or negative. -** Regardless of the value of mxPage, return the maximum page count. -*/ -static Pgno sqlite3BtreeMaxPageCount( Btree p, int mxPage ) -{ - Pgno n; - sqlite3BtreeEnter( p ); - n = sqlite3PagerMaxPageCount( p.pBt.pPager, mxPage ); - sqlite3BtreeLeave( p ); - return n; -} + /* + ** Set the maximum page count for a database if mxPage is positive. + ** No changes are made if mxPage is 0 or negative. + ** Regardless of the value of mxPage, return the maximum page count. + */ + static Pgno sqlite3BtreeMaxPageCount(Btree p, int mxPage) { + Pgno n; + sqlite3BtreeEnter(p); + n = sqlite3PagerMaxPageCount(p.pBt.pPager, mxPage); + sqlite3BtreeLeave(p); + return n; + } -/* -** Set the secureDelete flag if newFlag is 0 or 1. If newFlag is -1, -** then make no changes. Always return the value of the secureDelete -** setting after the change. -*/ -static int sqlite3BtreeSecureDelete( Btree p, int newFlag ) -{ - int b; - if ( p == null ) - return 0; - sqlite3BtreeEnter( p ); - if ( newFlag >= 0 ) - { - p.pBt.secureDelete = ( newFlag != 0 ); - } - b = p.pBt.secureDelete ? 1 : 0; - sqlite3BtreeLeave( p ); - return b; -} + /* + ** Set the secureDelete flag if newFlag is 0 or 1. If newFlag is -1, + ** then make no changes. Always return the value of the secureDelete + ** setting after the change. + */ + static int sqlite3BtreeSecureDelete(Btree p, int newFlag) { + int b; + if (p == null) + return 0; + sqlite3BtreeEnter(p); + if (newFlag >= 0) { + p.pBt.secureDelete = (newFlag != 0); + } + b = p.pBt.secureDelete ? 1 : 0; + sqlite3BtreeLeave(p); + return b; + } #endif //* !(SQLITE_OMIT_PAGER_PRAGMAS) || !(SQLITE_OMIT_VACUUM) */ -/* -** Change the 'auto-vacuum' property of the database. If the 'autoVacuum' -** parameter is non-zero, then auto-vacuum mode is enabled. If zero, it -** is disabled. The default value for the auto-vacuum property is -** determined by the SQLITE_DEFAULT_AUTOVACUUM macro. -*/ -static int sqlite3BtreeSetAutoVacuum( Btree p, int autoVacuum ) -{ + /* + ** Change the 'auto-vacuum' property of the database. If the 'autoVacuum' + ** parameter is non-zero, then auto-vacuum mode is enabled. If zero, it + ** is disabled. The default value for the auto-vacuum property is + ** determined by the SQLITE_DEFAULT_AUTOVACUUM macro. + */ + static int sqlite3BtreeSetAutoVacuum(Btree p, int autoVacuum) { #if SQLITE_OMIT_AUTOVACUUM return SQLITE_READONLY; #else - BtShared pBt = p.pBt; - int rc = SQLITE_OK; - u8 av = (u8)autoVacuum; - - sqlite3BtreeEnter( p ); - if ( pBt.pageSizeFixed && ( av != 0 ) != pBt.autoVacuum ) - { - rc = SQLITE_READONLY; - } - else - { - pBt.autoVacuum = av != 0; - pBt.incrVacuum = av == 2; - } - sqlite3BtreeLeave( p ); - return rc; + BtShared pBt = p.pBt; + int rc = SQLITE_OK; + u8 av = (u8)autoVacuum; + + sqlite3BtreeEnter(p); + if (pBt.pageSizeFixed && (av != 0) != pBt.autoVacuum) { + rc = SQLITE_READONLY; + } else { + pBt.autoVacuum = av != 0; + pBt.incrVacuum = av == 2; + } + sqlite3BtreeLeave(p); + return rc; #endif -} + } -/* -** Return the value of the 'auto-vacuum' property. If auto-vacuum is -** enabled 1 is returned. Otherwise 0. -*/ -static int sqlite3BtreeGetAutoVacuum( Btree p ) -{ + /* + ** Return the value of the 'auto-vacuum' property. If auto-vacuum is + ** enabled 1 is returned. Otherwise 0. + */ + static int sqlite3BtreeGetAutoVacuum(Btree p) { #if SQLITE_OMIT_AUTOVACUUM return BTREE_AUTOVACUUM_NONE; #else - int rc; - sqlite3BtreeEnter( p ); - rc = ( - ( !p.pBt.autoVacuum ) ? BTREE_AUTOVACUUM_NONE : - ( !p.pBt.incrVacuum ) ? BTREE_AUTOVACUUM_FULL : - BTREE_AUTOVACUUM_INCR - ); - sqlite3BtreeLeave( p ); - return rc; + int rc; + sqlite3BtreeEnter(p); + rc = ( + (!p.pBt.autoVacuum) ? BTREE_AUTOVACUUM_NONE : + (!p.pBt.incrVacuum) ? BTREE_AUTOVACUUM_FULL : + BTREE_AUTOVACUUM_INCR + ); + sqlite3BtreeLeave(p); + return rc; #endif -} + } -/* -** Get a reference to pPage1 of the database file. This will -** also acquire a readlock on that file. -** -** SQLITE_OK is returned on success. If the file is not a -** well-formed database file, then SQLITE_CORRUPT is returned. -** SQLITE_BUSY is returned if the database is locked. SQLITE_NOMEM -** is returned if we run out of memory. -*/ -static int lockBtree( BtShared pBt ) -{ - int rc; /* Result code from subfunctions */ - MemPage pPage1 = null; /* Page 1 of the database file */ - Pgno nPage; /* Number of pages in the database */ - Pgno nPageFile = 0; /* Number of pages in the database file */ - ////Pgno nPageHeader; /* Number of pages in the database according to hdr */ - - Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); - Debug.Assert( pBt.pPage1 == null ); - rc = sqlite3PagerSharedLock( pBt.pPager ); - if ( rc != SQLITE_OK ) - return rc; - rc = btreeGetPage( pBt, 1, ref pPage1, 0 ); - if ( rc != SQLITE_OK ) - return rc; - - /* Do some checking to help insure the file we opened really is - ** a valid database file. - */ - nPage = sqlite3Get4byte( pPage1.aData, 28 );//get4byte(28+(u8*)pPage1->aData); - sqlite3PagerPagecount( pBt.pPager, out nPageFile ); - if ( nPage == 0 || memcmp( pPage1.aData, 24, pPage1.aData, 92, 4 ) != 0 )//memcmp(24 + (u8*)pPage1.aData, 92 + (u8*)pPage1.aData, 4) != 0) - { - nPage = nPageFile; - } - if ( nPage > 0 ) - { - u32 pageSize; - u32 usableSize; - u8[] page1 = pPage1.aData; - rc = SQLITE_NOTADB; - if ( memcmp( page1, zMagicHeader, 16 ) != 0 ) - { - goto page1_init_failed; - } + /* + ** Get a reference to pPage1 of the database file. This will + ** also acquire a readlock on that file. + ** + ** SQLITE_OK is returned on success. If the file is not a + ** well-formed database file, then SQLITE_CORRUPT is returned. + ** SQLITE_BUSY is returned if the database is locked. SQLITE_NOMEM + ** is returned if we run out of memory. + */ + static int lockBtree(BtShared pBt) { + int rc; /* Result code from subfunctions */ + MemPage pPage1 = null; /* Page 1 of the database file */ + Pgno nPage; /* Number of pages in the database */ + Pgno nPageFile = 0; /* Number of pages in the database file */ + ////Pgno nPageHeader; /* Number of pages in the database according to hdr */ + + Debug.Assert(sqlite3_mutex_held(pBt.mutex)); + Debug.Assert(pBt.pPage1 == null); + rc = sqlite3PagerSharedLock(pBt.pPager); + if (rc != SQLITE_OK) + return rc; + rc = btreeGetPage(pBt, 1, ref pPage1, 0); + if (rc != SQLITE_OK) + return rc; + + /* Do some checking to help insure the file we opened really is + ** a valid database file. + */ + nPage = sqlite3Get4byte(pPage1.aData, 28);//get4byte(28+(u8*)pPage1->aData); + sqlite3PagerPagecount(pBt.pPager, out nPageFile); + if (nPage == 0 || memcmp(pPage1.aData, 24, pPage1.aData, 92, 4) != 0)//memcmp(24 + (u8*)pPage1.aData, 92 + (u8*)pPage1.aData, 4) != 0) + { + nPage = nPageFile; + } + if (nPage > 0) { + u32 pageSize; + u32 usableSize; + u8[] page1 = pPage1.aData; + rc = SQLITE_NOTADB; + if (memcmp(page1, zMagicHeader, 16) != 0) { + goto page1_init_failed; + } #if SQLITE_OMIT_WAL - if ( page1[18] > 1 ) - { - pBt.readOnly = true; - } - if ( page1[19] > 1 ) - { - pBt.pSchema.file_format = page1[19]; - goto page1_init_failed; - } + if (page1[18] > 1) { + pBt.readOnly = true; + } + if (page1[19] > 1) { + pBt.pSchema.file_format = page1[19]; + goto page1_init_failed; + } #else if( page1[18]>2 ){ pBt.readOnly = true; @@ -2736,212 +2531,201 @@ static int lockBtree( BtShared pBt ) } #endif - /* The maximum embedded fraction must be exactly 25%. And the minimum -** embedded fraction must be 12.5% for both leaf-data and non-leaf-data. -** The original design allowed these amounts to vary, but as of -** version 3.6.0, we require them to be fixed. -*/ - if ( memcmp( page1, 21, "\x0040\x0020\x0020", 3 ) != 0 )// "\100\040\040" - { - goto page1_init_failed; - } - pageSize = (u32)( ( page1[16] << 8 ) | ( page1[17] << 16 ) ); - if ( ( ( pageSize - 1 ) & pageSize ) != 0 - || pageSize > SQLITE_MAX_PAGE_SIZE - || pageSize <= 256 - ) - { - goto page1_init_failed; - } - Debug.Assert( ( pageSize & 7 ) == 0 ); - usableSize = pageSize - page1[20]; - if ( pageSize != pBt.pageSize ) - { - /* After reading the first page of the database assuming a page size - ** of BtShared.pageSize, we have discovered that the page-size is - ** actually pageSize. Unlock the database, leave pBt.pPage1 at - ** zero and return SQLITE_OK. The caller will call this function - ** again with the correct page-size. - */ - releasePage( pPage1 ); - pBt.usableSize = usableSize; - pBt.pageSize = pageSize; - // freeTempSpace(pBt); - rc = sqlite3PagerSetPagesize( pBt.pPager, ref pBt.pageSize, - (int)( pageSize - usableSize ) ); - return rc; - } - if ( ( pBt.db.flags & SQLITE_RecoveryMode ) == 0 && nPage > nPageFile ) - { - rc = SQLITE_CORRUPT_BKPT(); - goto page1_init_failed; - } - if ( usableSize < 480 ) - { - goto page1_init_failed; - } - pBt.pageSize = pageSize; - pBt.usableSize = usableSize; + /* The maximum embedded fraction must be exactly 25%. And the minimum + ** embedded fraction must be 12.5% for both leaf-data and non-leaf-data. + ** The original design allowed these amounts to vary, but as of + ** version 3.6.0, we require them to be fixed. + */ + if (memcmp(page1, 21, "\x0040\x0020\x0020", 3) != 0)// "\100\040\040" + { + goto page1_init_failed; + } + pageSize = (u32)((page1[16] << 8) | (page1[17] << 16)); + if (((pageSize - 1) & pageSize) != 0 + || pageSize > SQLITE_MAX_PAGE_SIZE + || pageSize <= 256 + ) { + goto page1_init_failed; + } + Debug.Assert((pageSize & 7) == 0); + usableSize = pageSize - page1[20]; + if (pageSize != pBt.pageSize) { + /* After reading the first page of the database assuming a page size + ** of BtShared.pageSize, we have discovered that the page-size is + ** actually pageSize. Unlock the database, leave pBt.pPage1 at + ** zero and return SQLITE_OK. The caller will call this function + ** again with the correct page-size. + */ + releasePage(pPage1); + pBt.usableSize = usableSize; + pBt.pageSize = pageSize; + // freeTempSpace(pBt); + rc = sqlite3PagerSetPagesize(pBt.pPager, ref pBt.pageSize, + (int)(pageSize - usableSize)); + return rc; + } + if ((pBt.db.flags & SQLITE_RecoveryMode) == 0 && nPage > nPageFile) { + rc = SQLITE_CORRUPT_BKPT(); + goto page1_init_failed; + } + if (usableSize < 480) { + goto page1_init_failed; + } + pBt.pageSize = pageSize; + pBt.usableSize = usableSize; #if !SQLITE_OMIT_AUTOVACUUM - pBt.autoVacuum = ( sqlite3Get4byte( page1, 36 + 4 * 4 ) != 0 ); - pBt.incrVacuum = ( sqlite3Get4byte( page1, 36 + 7 * 4 ) != 0 ); + pBt.autoVacuum = (sqlite3Get4byte(page1, 36 + 4 * 4) != 0); + pBt.incrVacuum = (sqlite3Get4byte(page1, 36 + 7 * 4) != 0); #endif - } - - /* maxLocal is the maximum amount of payload to store locally for - ** a cell. Make sure it is small enough so that at least minFanout - ** cells can will fit on one page. We assume a 10-byte page header. - ** Besides the payload, the cell must store: - ** 2-byte pointer to the cell - ** 4-byte child pointer - ** 9-byte nKey value - ** 4-byte nData value - ** 4-byte overflow page pointer - ** So a cell consists of a 2-byte pointer, a header which is as much as - ** 17 bytes long, 0 to N bytes of payload, and an optional 4 byte overflow - ** page pointer. - */ - pBt.maxLocal = (u16)( ( pBt.usableSize - 12 ) * 64 / 255 - 23 ); - pBt.minLocal = (u16)( ( pBt.usableSize - 12 ) * 32 / 255 - 23 ); - pBt.maxLeaf = (u16)( pBt.usableSize - 35 ); - pBt.minLeaf = (u16)( ( pBt.usableSize - 12 ) * 32 / 255 - 23 ); - Debug.Assert( pBt.maxLeaf + 23 <= MX_CELL_SIZE( pBt ) ); - pBt.pPage1 = pPage1; - pBt.nPage = nPage; - return SQLITE_OK; - -page1_init_failed: - releasePage( pPage1 ); - pBt.pPage1 = null; - return rc; -} + } -/* -** If there are no outstanding cursors and we are not in the middle -** of a transaction but there is a read lock on the database, then -** this routine unrefs the first page of the database file which -** has the effect of releasing the read lock. -** -** If there is a transaction in progress, this routine is a no-op. -*/ -static void unlockBtreeIfUnused( BtShared pBt ) -{ - Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); - Debug.Assert( pBt.pCursor == null || pBt.inTransaction > TRANS_NONE ); - if ( pBt.inTransaction == TRANS_NONE && pBt.pPage1 != null ) - { - Debug.Assert( pBt.pPage1.aData != null ); - //Debug.Assert( sqlite3PagerRefcount( pBt.pPager ) == 1 ); - releasePage( pBt.pPage1 ); - pBt.pPage1 = null; - } -} + /* maxLocal is the maximum amount of payload to store locally for + ** a cell. Make sure it is small enough so that at least minFanout + ** cells can will fit on one page. We assume a 10-byte page header. + ** Besides the payload, the cell must store: + ** 2-byte pointer to the cell + ** 4-byte child pointer + ** 9-byte nKey value + ** 4-byte nData value + ** 4-byte overflow page pointer + ** So a cell consists of a 2-byte pointer, a header which is as much as + ** 17 bytes long, 0 to N bytes of payload, and an optional 4 byte overflow + ** page pointer. + */ + pBt.maxLocal = (u16)((pBt.usableSize - 12) * 64 / 255 - 23); + pBt.minLocal = (u16)((pBt.usableSize - 12) * 32 / 255 - 23); + pBt.maxLeaf = (u16)(pBt.usableSize - 35); + pBt.minLeaf = (u16)((pBt.usableSize - 12) * 32 / 255 - 23); + Debug.Assert(pBt.maxLeaf + 23 <= MX_CELL_SIZE(pBt)); + pBt.pPage1 = pPage1; + pBt.nPage = nPage; + return SQLITE_OK; + + page1_init_failed: + releasePage(pPage1); + pBt.pPage1 = null; + return rc; + } -/* -** If pBt points to an empty file then convert that empty file -** into a new empty database by initializing the first page of -** the database. -*/ -static int newDatabase( BtShared pBt ) -{ - MemPage pP1; - byte[] data; - int rc; - - Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); - if ( pBt.nPage > 0 ) - { - return SQLITE_OK; - } - pP1 = pBt.pPage1; - Debug.Assert( pP1 != null ); - data = pP1.aData; - rc = sqlite3PagerWrite( pP1.pDbPage ); - if ( rc != 0 ) - return rc; - Buffer.BlockCopy( zMagicHeader, 0, data, 0, 16 );// memcpy(data, zMagicHeader, sizeof(zMagicHeader)); - Debug.Assert( zMagicHeader.Length == 16 ); - data[16] = (u8)( ( pBt.pageSize >> 8 ) & 0xff ); - data[17] = (u8)( ( pBt.pageSize >> 16 ) & 0xff ); - data[18] = 1; - data[19] = 1; - Debug.Assert( pBt.usableSize <= pBt.pageSize && pBt.usableSize + 255 >= pBt.pageSize ); - data[20] = (u8)( pBt.pageSize - pBt.usableSize ); - data[21] = 64; - data[22] = 32; - data[23] = 32; - //memset(&data[24], 0, 100-24); - zeroPage( pP1, PTF_INTKEY | PTF_LEAF | PTF_LEAFDATA ); - pBt.pageSizeFixed = true; + /* + ** If there are no outstanding cursors and we are not in the middle + ** of a transaction but there is a read lock on the database, then + ** this routine unrefs the first page of the database file which + ** has the effect of releasing the read lock. + ** + ** If there is a transaction in progress, this routine is a no-op. + */ + static void unlockBtreeIfUnused(BtShared pBt) { + Debug.Assert(sqlite3_mutex_held(pBt.mutex)); + Debug.Assert(pBt.pCursor == null || pBt.inTransaction > TRANS_NONE); + if (pBt.inTransaction == TRANS_NONE && pBt.pPage1 != null) { + Debug.Assert(pBt.pPage1.aData != null); + //Debug.Assert( sqlite3PagerRefcount( pBt.pPager ) == 1 ); + releasePage(pBt.pPage1); + pBt.pPage1 = null; + } + } + + /* + ** If pBt points to an empty file then convert that empty file + ** into a new empty database by initializing the first page of + ** the database. + */ + static int newDatabase(BtShared pBt) { + MemPage pP1; + byte[] data; + int rc; + + Debug.Assert(sqlite3_mutex_held(pBt.mutex)); + if (pBt.nPage > 0) { + return SQLITE_OK; + } + pP1 = pBt.pPage1; + Debug.Assert(pP1 != null); + data = pP1.aData; + rc = sqlite3PagerWrite(pP1.pDbPage); + if (rc != 0) + return rc; + Buffer.BlockCopy(zMagicHeader, 0, data, 0, 16);// memcpy(data, zMagicHeader, sizeof(zMagicHeader)); + Debug.Assert(zMagicHeader.Length == 16); + data[16] = (u8)((pBt.pageSize >> 8) & 0xff); + data[17] = (u8)((pBt.pageSize >> 16) & 0xff); + data[18] = 1; + data[19] = 1; + Debug.Assert(pBt.usableSize <= pBt.pageSize && pBt.usableSize + 255 >= pBt.pageSize); + data[20] = (u8)(pBt.pageSize - pBt.usableSize); + data[21] = 64; + data[22] = 32; + data[23] = 32; + //memset(&data[24], 0, 100-24); + zeroPage(pP1, PTF_INTKEY | PTF_LEAF | PTF_LEAFDATA); + pBt.pageSizeFixed = true; #if !SQLITE_OMIT_AUTOVACUUM - Debug.Assert( pBt.autoVacuum == true || pBt.autoVacuum == false ); - Debug.Assert( pBt.incrVacuum == true || pBt.incrVacuum == false ); - sqlite3Put4byte( data, 36 + 4 * 4, pBt.autoVacuum ? 1 : 0 ); - sqlite3Put4byte( data, 36 + 7 * 4, pBt.incrVacuum ? 1 : 0 ); + Debug.Assert(pBt.autoVacuum == true || pBt.autoVacuum == false); + Debug.Assert(pBt.incrVacuum == true || pBt.incrVacuum == false); + sqlite3Put4byte(data, 36 + 4 * 4, pBt.autoVacuum ? 1 : 0); + sqlite3Put4byte(data, 36 + 7 * 4, pBt.incrVacuum ? 1 : 0); #endif - pBt.nPage = 1; - data[31] = 1; - return SQLITE_OK; -} + pBt.nPage = 1; + data[31] = 1; + return SQLITE_OK; + } -/* -** Attempt to start a new transaction. A write-transaction -** is started if the second argument is nonzero, otherwise a read- -** transaction. If the second argument is 2 or more and exclusive -** transaction is started, meaning that no other process is allowed -** to access the database. A preexisting transaction may not be -** upgraded to exclusive by calling this routine a second time - the -** exclusivity flag only works for a new transaction. -** -** A write-transaction must be started before attempting any -** changes to the database. None of the following routines -** will work unless a transaction is started first: -** -** sqlite3BtreeCreateTable() -** sqlite3BtreeCreateIndex() -** sqlite3BtreeClearTable() -** sqlite3BtreeDropTable() -** sqlite3BtreeInsert() -** sqlite3BtreeDelete() -** sqlite3BtreeUpdateMeta() -** -** If an initial attempt to acquire the lock fails because of lock contention -** and the database was previously unlocked, then invoke the busy handler -** if there is one. But if there was previously a read-lock, do not -** invoke the busy handler - just return SQLITE_BUSY. SQLITE_BUSY is -** returned when there is already a read-lock in order to avoid a deadlock. -** -** Suppose there are two processes A and B. A has a read lock and B has -** a reserved lock. B tries to promote to exclusive but is blocked because -** of A's read lock. A tries to promote to reserved but is blocked by B. -** One or the other of the two processes must give way or there can be -** no progress. By returning SQLITE_BUSY and not invoking the busy callback -** when A already has a read lock, we encourage A to give up and let B -** proceed. -*/ -static int sqlite3BtreeBeginTrans( Btree p, int wrflag ) -{ - BtShared pBt = p.pBt; - int rc = SQLITE_OK; - - sqlite3BtreeEnter( p ); - btreeIntegrity( p ); - - /* If the btree is already in a write-transaction, or it - ** is already in a read-transaction and a read-transaction - ** is requested, this is a no-op. - */ - if ( p.inTrans == TRANS_WRITE || ( p.inTrans == TRANS_READ && 0 == wrflag ) ) - { - goto trans_begun; - } - - /* Write transactions are not possible on a read-only database */ - if ( pBt.readOnly && wrflag != 0 ) - { - rc = SQLITE_READONLY; - goto trans_begun; - } + /* + ** Attempt to start a new transaction. A write-transaction + ** is started if the second argument is nonzero, otherwise a read- + ** transaction. If the second argument is 2 or more and exclusive + ** transaction is started, meaning that no other process is allowed + ** to access the database. A preexisting transaction may not be + ** upgraded to exclusive by calling this routine a second time - the + ** exclusivity flag only works for a new transaction. + ** + ** A write-transaction must be started before attempting any + ** changes to the database. None of the following routines + ** will work unless a transaction is started first: + ** + ** sqlite3BtreeCreateTable() + ** sqlite3BtreeCreateIndex() + ** sqlite3BtreeClearTable() + ** sqlite3BtreeDropTable() + ** sqlite3BtreeInsert() + ** sqlite3BtreeDelete() + ** sqlite3BtreeUpdateMeta() + ** + ** If an initial attempt to acquire the lock fails because of lock contention + ** and the database was previously unlocked, then invoke the busy handler + ** if there is one. But if there was previously a read-lock, do not + ** invoke the busy handler - just return SQLITE_BUSY. SQLITE_BUSY is + ** returned when there is already a read-lock in order to avoid a deadlock. + ** + ** Suppose there are two processes A and B. A has a read lock and B has + ** a reserved lock. B tries to promote to exclusive but is blocked because + ** of A's read lock. A tries to promote to reserved but is blocked by B. + ** One or the other of the two processes must give way or there can be + ** no progress. By returning SQLITE_BUSY and not invoking the busy callback + ** when A already has a read lock, we encourage A to give up and let B + ** proceed. + */ + static int sqlite3BtreeBeginTrans(Btree p, int wrflag) { + BtShared pBt = p.pBt; + int rc = SQLITE_OK; + + sqlite3BtreeEnter(p); + btreeIntegrity(p); + + /* If the btree is already in a write-transaction, or it + ** is already in a read-transaction and a read-transaction + ** is requested, this is a no-op. + */ + if (p.inTrans == TRANS_WRITE || (p.inTrans == TRANS_READ && 0 == wrflag)) { + goto trans_begun; + } + + /* Write transactions are not possible on a read-only database */ + if (pBt.readOnly && wrflag != 0) { + rc = SQLITE_READONLY; + goto trans_begun; + } #if !SQLITE_OMIT_SHARED_CACHE /* If another database handle has already opened a write transaction @@ -2966,54 +2750,45 @@ static int sqlite3BtreeBeginTrans( Btree p, int wrflag ) } #endif - /* Any read-only or read-write transaction implies a read-lock on -** page 1. So if some other shared-cache client already has a write-lock -** on page 1, the transaction cannot be opened. */ - rc = querySharedCacheTableLock( p, MASTER_ROOT, READ_LOCK ); - if ( SQLITE_OK != rc ) - goto trans_begun; - - pBt.initiallyEmpty = pBt.nPage == 0; - do - { - /* Call lockBtree() until either pBt.pPage1 is populated or - ** lockBtree() returns something other than SQLITE_OK. lockBtree() - ** may return SQLITE_OK but leave pBt.pPage1 set to 0 if after - ** reading page 1 it discovers that the page-size of the database - ** file is not pBt.pageSize. In this case lockBtree() will update - ** pBt.pageSize to the page-size of the file on disk. - */ - while ( pBt.pPage1 == null && SQLITE_OK == ( rc = lockBtree( pBt ) ) ) - ; - - if ( rc == SQLITE_OK && wrflag != 0 ) - { - if ( pBt.readOnly ) - { - rc = SQLITE_READONLY; - } - else - { - rc = sqlite3PagerBegin( pBt.pPager, wrflag > 1, sqlite3TempInMemory( p.db ) ? 1 : 0 ); - if ( rc == SQLITE_OK ) - { - rc = newDatabase( pBt ); - } - } - } - - if ( rc != SQLITE_OK ) - { - unlockBtreeIfUnused( pBt ); - } - } while ( ( rc & 0xFF ) == SQLITE_BUSY && pBt.inTransaction == TRANS_NONE && - btreeInvokeBusyHandler( pBt ) != 0 ); - - if ( rc == SQLITE_OK ) - { - if ( p.inTrans == TRANS_NONE ) - { - pBt.nTransaction++; + /* Any read-only or read-write transaction implies a read-lock on + ** page 1. So if some other shared-cache client already has a write-lock + ** on page 1, the transaction cannot be opened. */ + rc = querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK); + if (SQLITE_OK != rc) + goto trans_begun; + + pBt.initiallyEmpty = pBt.nPage == 0; + do { + /* Call lockBtree() until either pBt.pPage1 is populated or + ** lockBtree() returns something other than SQLITE_OK. lockBtree() + ** may return SQLITE_OK but leave pBt.pPage1 set to 0 if after + ** reading page 1 it discovers that the page-size of the database + ** file is not pBt.pageSize. In this case lockBtree() will update + ** pBt.pageSize to the page-size of the file on disk. + */ + while (pBt.pPage1 == null && SQLITE_OK == (rc = lockBtree(pBt))) + ; + + if (rc == SQLITE_OK && wrflag != 0) { + if (pBt.readOnly) { + rc = SQLITE_READONLY; + } else { + rc = sqlite3PagerBegin(pBt.pPager, wrflag > 1, sqlite3TempInMemory(p.db) ? 1 : 0); + if (rc == SQLITE_OK) { + rc = newDatabase(pBt); + } + } + } + + if (rc != SQLITE_OK) { + unlockBtreeIfUnused(pBt); + } + } while ((rc & 0xFF) == SQLITE_BUSY && pBt.inTransaction == TRANS_NONE && + btreeInvokeBusyHandler(pBt) != 0); + + if (rc == SQLITE_OK) { + if (p.inTrans == TRANS_NONE) { + pBt.nTransaction++; #if !SQLITE_OMIT_SHARED_CACHE if( p.sharable ){ Debug.Assert( p.lock.pBtree==p && p.lock.iTable==1 ); @@ -3022,778 +2797,688 @@ static int sqlite3BtreeBeginTrans( Btree p, int wrflag ) pBt.pLock = &p.lock; } #endif - } - p.inTrans = ( wrflag != 0 ? TRANS_WRITE : TRANS_READ ); - if ( p.inTrans > pBt.inTransaction ) - { - pBt.inTransaction = p.inTrans; - } - if ( wrflag != 0 ) - { - MemPage pPage1 = pBt.pPage1; + } + p.inTrans = (wrflag != 0 ? TRANS_WRITE : TRANS_READ); + if (p.inTrans > pBt.inTransaction) { + pBt.inTransaction = p.inTrans; + } + if (wrflag != 0) { + MemPage pPage1 = pBt.pPage1; #if !SQLITE_OMIT_SHARED_CACHE Debug.Assert( !pBt.pWriter ); pBt.pWriter = p; pBt.isExclusive = (u8)(wrflag>1); #endif - /* If the db-size header field is incorrect (as it may be if an old -** client has been writing the database file), update it now. Doing -** this sooner rather than later means the database size can safely -** re-read the database size from page 1 if a savepoint or transaction -** rollback occurs within the transaction. -*/ - if ( pBt.nPage != sqlite3Get4byte( pPage1.aData, 28 ) ) - { - rc = sqlite3PagerWrite( pPage1.pDbPage ); - if ( rc == SQLITE_OK ) - { - sqlite3Put4byte( pPage1.aData, (u32)28, pBt.nPage ); - } - } - } - } - - -trans_begun: - if ( rc == SQLITE_OK && wrflag != 0 ) - { - /* This call makes sure that the pager has the correct number of - ** open savepoints. If the second parameter is greater than 0 and - ** the sub-journal is not already open, then it will be opened here. - */ - rc = sqlite3PagerOpenSavepoint( pBt.pPager, p.db.nSavepoint ); - } - - btreeIntegrity( p ); - sqlite3BtreeLeave( p ); - return rc; -} + /* If the db-size header field is incorrect (as it may be if an old + ** client has been writing the database file), update it now. Doing + ** this sooner rather than later means the database size can safely + ** re-read the database size from page 1 if a savepoint or transaction + ** rollback occurs within the transaction. + */ + if (pBt.nPage != sqlite3Get4byte(pPage1.aData, 28)) { + rc = sqlite3PagerWrite(pPage1.pDbPage); + if (rc == SQLITE_OK) { + sqlite3Put4byte(pPage1.aData, (u32)28, pBt.nPage); + } + } + } + } -#if !SQLITE_OMIT_AUTOVACUUM -/* -** Set the pointer-map entries for all children of page pPage. Also, if -** pPage contains cells that point to overflow pages, set the pointer -** map entries for the overflow pages as well. -*/ -static int setChildPtrmaps( MemPage pPage ) -{ - int i; /* Counter variable */ - int nCell; /* Number of cells in page pPage */ - int rc; /* Return code */ - BtShared pBt = pPage.pBt; - u8 isInitOrig = pPage.isInit; - Pgno pgno = pPage.pgno; - - Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); - rc = btreeInitPage( pPage ); - if ( rc != SQLITE_OK ) - { - goto set_child_ptrmaps_out; - } - nCell = pPage.nCell; - - for ( i = 0; i < nCell; i++ ) - { - int pCell = findCell( pPage, i ); - - ptrmapPutOvflPtr( pPage, pCell, ref rc ); - - if ( 0 == pPage.leaf ) - { - Pgno childPgno = sqlite3Get4byte( pPage.aData, pCell ); - ptrmapPut( pBt, childPgno, PTRMAP_BTREE, pgno, ref rc ); - } - } + trans_begun: + if (rc == SQLITE_OK && wrflag != 0) { + /* This call makes sure that the pager has the correct number of + ** open savepoints. If the second parameter is greater than 0 and + ** the sub-journal is not already open, then it will be opened here. + */ + rc = sqlite3PagerOpenSavepoint(pBt.pPager, p.db.nSavepoint); + } - if ( 0 == pPage.leaf ) - { - Pgno childPgno = sqlite3Get4byte( pPage.aData, pPage.hdrOffset + 8 ); - ptrmapPut( pBt, childPgno, PTRMAP_BTREE, pgno, ref rc ); - } + btreeIntegrity(p); + sqlite3BtreeLeave(p); + return rc; + } -set_child_ptrmaps_out: - pPage.isInit = isInitOrig; - return rc; -} +#if !SQLITE_OMIT_AUTOVACUUM -/* -** Somewhere on pPage is a pointer to page iFrom. Modify this pointer so -** that it points to iTo. Parameter eType describes the type of pointer to -** be modified, as follows: -** -** PTRMAP_BTREE: pPage is a btree-page. The pointer points at a child -** page of pPage. -** -** PTRMAP_OVERFLOW1: pPage is a btree-page. The pointer points at an overflow -** page pointed to by one of the cells on pPage. -** -** PTRMAP_OVERFLOW2: pPage is an overflow-page. The pointer points at the next -** overflow page in the list. -*/ -static int modifyPagePointer( MemPage pPage, Pgno iFrom, Pgno iTo, u8 eType ) -{ - Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); - Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); - if ( eType == PTRMAP_OVERFLOW2 ) - { - /* The pointer is always the first 4 bytes of the page in this case. */ - if ( sqlite3Get4byte( pPage.aData ) != iFrom ) - { - return SQLITE_CORRUPT_BKPT(); - } - sqlite3Put4byte( pPage.aData, iTo ); - } - else - { - u8 isInitOrig = pPage.isInit; - int i; - int nCell; - - btreeInitPage( pPage ); - nCell = pPage.nCell; - - for ( i = 0; i < nCell; i++ ) - { - int pCell = findCell( pPage, i ); - if ( eType == PTRMAP_OVERFLOW1 ) - { - CellInfo info = new CellInfo(); - btreeParseCellPtr( pPage, pCell, ref info ); - if ( info.iOverflow != 0 ) - { - if ( iFrom == sqlite3Get4byte( pPage.aData, pCell, info.iOverflow ) ) - { - sqlite3Put4byte( pPage.aData, pCell + info.iOverflow, (int)iTo ); - break; - } - } - } - else - { - if ( sqlite3Get4byte( pPage.aData, pCell ) == iFrom ) - { - sqlite3Put4byte( pPage.aData, pCell, (int)iTo ); - break; - } - } - } + /* + ** Set the pointer-map entries for all children of page pPage. Also, if + ** pPage contains cells that point to overflow pages, set the pointer + ** map entries for the overflow pages as well. + */ + static int setChildPtrmaps(MemPage pPage) { + int i; /* Counter variable */ + int nCell; /* Number of cells in page pPage */ + int rc; /* Return code */ + BtShared pBt = pPage.pBt; + u8 isInitOrig = pPage.isInit; + Pgno pgno = pPage.pgno; + + Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); + rc = btreeInitPage(pPage); + if (rc != SQLITE_OK) { + goto set_child_ptrmaps_out; + } + nCell = pPage.nCell; - if ( i == nCell ) - { - if ( eType != PTRMAP_BTREE || - sqlite3Get4byte( pPage.aData, pPage.hdrOffset + 8 ) != iFrom ) - { - return SQLITE_CORRUPT_BKPT(); - } - sqlite3Put4byte( pPage.aData, pPage.hdrOffset + 8, iTo ); - } + for (i = 0; i < nCell; i++) { + int pCell = findCell(pPage, i); - pPage.isInit = isInitOrig; - } - return SQLITE_OK; -} + ptrmapPutOvflPtr(pPage, pCell, ref rc); + if (0 == pPage.leaf) { + Pgno childPgno = sqlite3Get4byte(pPage.aData, pCell); + ptrmapPut(pBt, childPgno, PTRMAP_BTREE, pgno, ref rc); + } + } -/* -** Move the open database page pDbPage to location iFreePage in the -** database. The pDbPage reference remains valid. -** -** The isCommit flag indicates that there is no need to remember that -** the journal needs to be sync()ed before database page pDbPage.pgno -** can be written to. The caller has already promised not to write to that -** page. -*/ -static int relocatePage( -BtShared pBt, /* Btree */ -MemPage pDbPage, /* Open page to move */ -u8 eType, /* Pointer map 'type' entry for pDbPage */ -Pgno iPtrPage, /* Pointer map 'page-no' entry for pDbPage */ -Pgno iFreePage, /* The location to move pDbPage to */ -int isCommit /* isCommit flag passed to sqlite3PagerMovepage */ -) -{ - MemPage pPtrPage = new MemPage(); /* The page that contains a pointer to pDbPage */ - Pgno iDbPage = pDbPage.pgno; - Pager pPager = pBt.pPager; - int rc; - - Debug.Assert( eType == PTRMAP_OVERFLOW2 || eType == PTRMAP_OVERFLOW1 || - eType == PTRMAP_BTREE || eType == PTRMAP_ROOTPAGE ); - Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); - Debug.Assert( pDbPage.pBt == pBt ); - - /* Move page iDbPage from its current location to page number iFreePage */ - TRACE( "AUTOVACUUM: Moving %d to free page %d (ptr page %d type %d)\n", - iDbPage, iFreePage, iPtrPage, eType ); - rc = sqlite3PagerMovepage( pPager, pDbPage.pDbPage, iFreePage, isCommit ); - if ( rc != SQLITE_OK ) - { - return rc; - } - pDbPage.pgno = iFreePage; - - /* If pDbPage was a btree-page, then it may have child pages and/or cells - ** that point to overflow pages. The pointer map entries for all these - ** pages need to be changed. - ** - ** If pDbPage is an overflow page, then the first 4 bytes may store a - ** pointer to a subsequent overflow page. If this is the case, then - ** the pointer map needs to be updated for the subsequent overflow page. - */ - if ( eType == PTRMAP_BTREE || eType == PTRMAP_ROOTPAGE ) - { - rc = setChildPtrmaps( pDbPage ); - if ( rc != SQLITE_OK ) - { - return rc; - } - } - else - { - Pgno nextOvfl = sqlite3Get4byte( pDbPage.aData ); - if ( nextOvfl != 0 ) - { - ptrmapPut( pBt, nextOvfl, PTRMAP_OVERFLOW2, iFreePage, ref rc ); - if ( rc != SQLITE_OK ) - { - return rc; - } - } - } - - /* Fix the database pointer on page iPtrPage that pointed at iDbPage so - ** that it points at iFreePage. Also fix the pointer map entry for - ** iPtrPage. - */ - if ( eType != PTRMAP_ROOTPAGE ) - { - rc = btreeGetPage( pBt, iPtrPage, ref pPtrPage, 0 ); - if ( rc != SQLITE_OK ) - { - return rc; - } - rc = sqlite3PagerWrite( pPtrPage.pDbPage ); - if ( rc != SQLITE_OK ) - { - releasePage( pPtrPage ); - return rc; - } - rc = modifyPagePointer( pPtrPage, iDbPage, iFreePage, eType ); - releasePage( pPtrPage ); - if ( rc == SQLITE_OK ) - { - ptrmapPut( pBt, iFreePage, eType, iPtrPage, ref rc ); - } - } - return rc; -} + if (0 == pPage.leaf) { + Pgno childPgno = sqlite3Get4byte(pPage.aData, pPage.hdrOffset + 8); + ptrmapPut(pBt, childPgno, PTRMAP_BTREE, pgno, ref rc); + } -/* Forward declaration required by incrVacuumStep(). */ -//static int allocateBtreePage(BtShared *, MemPage **, Pgno *, Pgno, u8); + set_child_ptrmaps_out: + pPage.isInit = isInitOrig; + return rc; + } -/* -** Perform a single step of an incremental-vacuum. If successful, -** return SQLITE_OK. If there is no work to do (and therefore no -** point in calling this function again), return SQLITE_DONE. -** -** More specificly, this function attempts to re-organize the -** database so that the last page of the file currently in use -** is no longer in use. -** -** If the nFin parameter is non-zero, this function assumes -** that the caller will keep calling incrVacuumStep() until -** it returns SQLITE_DONE or an error, and that nFin is the -** number of pages the database file will contain after this -** process is complete. If nFin is zero, it is assumed that -** incrVacuumStep() will be called a finite amount of times -** which may or may not empty the freelist. A full autovacuum -** has nFin>0. A "PRAGMA incremental_vacuum" has nFin==null. -*/ -static int incrVacuumStep( BtShared pBt, Pgno nFin, Pgno iLastPg ) -{ - Pgno nFreeList; /* Number of pages still on the free-list */ - int rc; + /* + ** Somewhere on pPage is a pointer to page iFrom. Modify this pointer so + ** that it points to iTo. Parameter eType describes the type of pointer to + ** be modified, as follows: + ** + ** PTRMAP_BTREE: pPage is a btree-page. The pointer points at a child + ** page of pPage. + ** + ** PTRMAP_OVERFLOW1: pPage is a btree-page. The pointer points at an overflow + ** page pointed to by one of the cells on pPage. + ** + ** PTRMAP_OVERFLOW2: pPage is an overflow-page. The pointer points at the next + ** overflow page in the list. + */ + static int modifyPagePointer(MemPage pPage, Pgno iFrom, Pgno iTo, u8 eType) { + Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); + Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); + if (eType == PTRMAP_OVERFLOW2) { + /* The pointer is always the first 4 bytes of the page in this case. */ + if (sqlite3Get4byte(pPage.aData) != iFrom) { + return SQLITE_CORRUPT_BKPT(); + } + sqlite3Put4byte(pPage.aData, iTo); + } else { + u8 isInitOrig = pPage.isInit; + int i; + int nCell; + + btreeInitPage(pPage); + nCell = pPage.nCell; + + for (i = 0; i < nCell; i++) { + int pCell = findCell(pPage, i); + if (eType == PTRMAP_OVERFLOW1) { + CellInfo info = new CellInfo(); + btreeParseCellPtr(pPage, pCell, ref info); + if (info.iOverflow != 0) { + if (iFrom == sqlite3Get4byte(pPage.aData, pCell, info.iOverflow)) { + sqlite3Put4byte(pPage.aData, pCell + info.iOverflow, (int)iTo); + break; + } + } + } else { + if (sqlite3Get4byte(pPage.aData, pCell) == iFrom) { + sqlite3Put4byte(pPage.aData, pCell, (int)iTo); + break; + } + } + } + + if (i == nCell) { + if (eType != PTRMAP_BTREE || + sqlite3Get4byte(pPage.aData, pPage.hdrOffset + 8) != iFrom) { + return SQLITE_CORRUPT_BKPT(); + } + sqlite3Put4byte(pPage.aData, pPage.hdrOffset + 8, iTo); + } + + pPage.isInit = isInitOrig; + } + return SQLITE_OK; + } - Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); - Debug.Assert( iLastPg > nFin ); - if ( !PTRMAP_ISPAGE( pBt, iLastPg ) && iLastPg != PENDING_BYTE_PAGE( pBt ) ) - { - u8 eType = 0; - Pgno iPtrPage = 0; + /* + ** Move the open database page pDbPage to location iFreePage in the + ** database. The pDbPage reference remains valid. + ** + ** The isCommit flag indicates that there is no need to remember that + ** the journal needs to be sync()ed before database page pDbPage.pgno + ** can be written to. The caller has already promised not to write to that + ** page. + */ + static int relocatePage( + BtShared pBt, /* Btree */ + MemPage pDbPage, /* Open page to move */ + u8 eType, /* Pointer map 'type' entry for pDbPage */ + Pgno iPtrPage, /* Pointer map 'page-no' entry for pDbPage */ + Pgno iFreePage, /* The location to move pDbPage to */ + int isCommit /* isCommit flag passed to sqlite3PagerMovepage */ + ) { + MemPage pPtrPage = new MemPage(); /* The page that contains a pointer to pDbPage */ + Pgno iDbPage = pDbPage.pgno; + Pager pPager = pBt.pPager; + int rc; + + Debug.Assert(eType == PTRMAP_OVERFLOW2 || eType == PTRMAP_OVERFLOW1 || + eType == PTRMAP_BTREE || eType == PTRMAP_ROOTPAGE); + Debug.Assert(sqlite3_mutex_held(pBt.mutex)); + Debug.Assert(pDbPage.pBt == pBt); + + /* Move page iDbPage from its current location to page number iFreePage */ + TRACE("AUTOVACUUM: Moving %d to free page %d (ptr page %d type %d)\n", + iDbPage, iFreePage, iPtrPage, eType); + rc = sqlite3PagerMovepage(pPager, pDbPage.pDbPage, iFreePage, isCommit); + if (rc != SQLITE_OK) { + return rc; + } + pDbPage.pgno = iFreePage; + + /* If pDbPage was a btree-page, then it may have child pages and/or cells + ** that point to overflow pages. The pointer map entries for all these + ** pages need to be changed. + ** + ** If pDbPage is an overflow page, then the first 4 bytes may store a + ** pointer to a subsequent overflow page. If this is the case, then + ** the pointer map needs to be updated for the subsequent overflow page. + */ + if (eType == PTRMAP_BTREE || eType == PTRMAP_ROOTPAGE) { + rc = setChildPtrmaps(pDbPage); + if (rc != SQLITE_OK) { + return rc; + } + } else { + Pgno nextOvfl = sqlite3Get4byte(pDbPage.aData); + if (nextOvfl != 0) { + ptrmapPut(pBt, nextOvfl, PTRMAP_OVERFLOW2, iFreePage, ref rc); + if (rc != SQLITE_OK) { + return rc; + } + } + } - nFreeList = sqlite3Get4byte( pBt.pPage1.aData, 36 ); - if ( nFreeList == 0 ) - { - return SQLITE_DONE; - } + /* Fix the database pointer on page iPtrPage that pointed at iDbPage so + ** that it points at iFreePage. Also fix the pointer map entry for + ** iPtrPage. + */ + if (eType != PTRMAP_ROOTPAGE) { + rc = btreeGetPage(pBt, iPtrPage, ref pPtrPage, 0); + if (rc != SQLITE_OK) { + return rc; + } + rc = sqlite3PagerWrite(pPtrPage.pDbPage); + if (rc != SQLITE_OK) { + releasePage(pPtrPage); + return rc; + } + rc = modifyPagePointer(pPtrPage, iDbPage, iFreePage, eType); + releasePage(pPtrPage); + if (rc == SQLITE_OK) { + ptrmapPut(pBt, iFreePage, eType, iPtrPage, ref rc); + } + } + return rc; + } - rc = ptrmapGet( pBt, iLastPg, ref eType, ref iPtrPage ); - if ( rc != SQLITE_OK ) - { - return rc; - } - if ( eType == PTRMAP_ROOTPAGE ) - { - return SQLITE_CORRUPT_BKPT(); - } + /* Forward declaration required by incrVacuumStep(). */ + //static int allocateBtreePage(BtShared *, MemPage **, Pgno *, Pgno, u8); - if ( eType == PTRMAP_FREEPAGE ) - { - if ( nFin == 0 ) - { - /* Remove the page from the files free-list. This is not required - ** if nFin is non-zero. In that case, the free-list will be - ** truncated to zero after this function returns, so it doesn't - ** matter if it still contains some garbage entries. - */ - Pgno iFreePg = 0; - MemPage pFreePg = new MemPage(); - rc = allocateBtreePage( pBt, ref pFreePg, ref iFreePg, iLastPg, 1 ); - if ( rc != SQLITE_OK ) - { - return rc; - } - Debug.Assert( iFreePg == iLastPg ); - releasePage( pFreePg ); - } - } - else - { - Pgno iFreePg = 0; /* Index of free page to move pLastPg to */ - MemPage pLastPg = new MemPage(); - - rc = btreeGetPage( pBt, iLastPg, ref pLastPg, 0 ); - if ( rc != SQLITE_OK ) - { - return rc; - } - - /* If nFin is zero, this loop runs exactly once and page pLastPg - ** is swapped with the first free page pulled off the free list. - ** - ** On the other hand, if nFin is greater than zero, then keep - ** looping until a free-page located within the first nFin pages - ** of the file is found. - */ - do - { - MemPage pFreePg = new MemPage(); - rc = allocateBtreePage( pBt, ref pFreePg, ref iFreePg, 0, 0 ); - if ( rc != SQLITE_OK ) - { - releasePage( pLastPg ); - return rc; - } - releasePage( pFreePg ); - } while ( nFin != 0 && iFreePg > nFin ); - Debug.Assert( iFreePg < iLastPg ); - - rc = sqlite3PagerWrite( pLastPg.pDbPage ); - if ( rc == SQLITE_OK ) - { - rc = relocatePage( pBt, pLastPg, eType, iPtrPage, iFreePg, ( nFin != 0 ) ? 1 : 0 ); - } - releasePage( pLastPg ); - if ( rc != SQLITE_OK ) - { - return rc; - } - } - } + /* + ** Perform a single step of an incremental-vacuum. If successful, + ** return SQLITE_OK. If there is no work to do (and therefore no + ** point in calling this function again), return SQLITE_DONE. + ** + ** More specificly, this function attempts to re-organize the + ** database so that the last page of the file currently in use + ** is no longer in use. + ** + ** If the nFin parameter is non-zero, this function assumes + ** that the caller will keep calling incrVacuumStep() until + ** it returns SQLITE_DONE or an error, and that nFin is the + ** number of pages the database file will contain after this + ** process is complete. If nFin is zero, it is assumed that + ** incrVacuumStep() will be called a finite amount of times + ** which may or may not empty the freelist. A full autovacuum + ** has nFin>0. A "PRAGMA incremental_vacuum" has nFin==null. + */ + static int incrVacuumStep(BtShared pBt, Pgno nFin, Pgno iLastPg) { + Pgno nFreeList; /* Number of pages still on the free-list */ + int rc; + + Debug.Assert(sqlite3_mutex_held(pBt.mutex)); + Debug.Assert(iLastPg > nFin); + + if (!PTRMAP_ISPAGE(pBt, iLastPg) && iLastPg != PENDING_BYTE_PAGE(pBt)) { + u8 eType = 0; + Pgno iPtrPage = 0; + + nFreeList = sqlite3Get4byte(pBt.pPage1.aData, 36); + if (nFreeList == 0) { + return SQLITE_DONE; + } + + rc = ptrmapGet(pBt, iLastPg, ref eType, ref iPtrPage); + if (rc != SQLITE_OK) { + return rc; + } + if (eType == PTRMAP_ROOTPAGE) { + return SQLITE_CORRUPT_BKPT(); + } + + if (eType == PTRMAP_FREEPAGE) { + if (nFin == 0) { + /* Remove the page from the files free-list. This is not required + ** if nFin is non-zero. In that case, the free-list will be + ** truncated to zero after this function returns, so it doesn't + ** matter if it still contains some garbage entries. + */ + Pgno iFreePg = 0; + MemPage pFreePg = new MemPage(); + rc = allocateBtreePage(pBt, ref pFreePg, ref iFreePg, iLastPg, 1); + if (rc != SQLITE_OK) { + return rc; + } + Debug.Assert(iFreePg == iLastPg); + releasePage(pFreePg); + } + } else { + Pgno iFreePg = 0; /* Index of free page to move pLastPg to */ + MemPage pLastPg = new MemPage(); + + rc = btreeGetPage(pBt, iLastPg, ref pLastPg, 0); + if (rc != SQLITE_OK) { + return rc; + } + + /* If nFin is zero, this loop runs exactly once and page pLastPg + ** is swapped with the first free page pulled off the free list. + ** + ** On the other hand, if nFin is greater than zero, then keep + ** looping until a free-page located within the first nFin pages + ** of the file is found. + */ + do { + MemPage pFreePg = new MemPage(); + rc = allocateBtreePage(pBt, ref pFreePg, ref iFreePg, 0, 0); + if (rc != SQLITE_OK) { + releasePage(pLastPg); + return rc; + } + releasePage(pFreePg); + } while (nFin != 0 && iFreePg > nFin); + Debug.Assert(iFreePg < iLastPg); + + rc = sqlite3PagerWrite(pLastPg.pDbPage); + if (rc == SQLITE_OK) { + rc = relocatePage(pBt, pLastPg, eType, iPtrPage, iFreePg, (nFin != 0) ? 1 : 0); + } + releasePage(pLastPg); + if (rc != SQLITE_OK) { + return rc; + } + } + } - if ( nFin == 0 ) - { - iLastPg--; - while ( iLastPg == PENDING_BYTE_PAGE( pBt ) || PTRMAP_ISPAGE( pBt, iLastPg ) ) - { - if ( PTRMAP_ISPAGE( pBt, iLastPg ) ) - { - MemPage pPg = new MemPage(); - rc = btreeGetPage( pBt, iLastPg, ref pPg, 0 ); - if ( rc != SQLITE_OK ) - { - return rc; - } - rc = sqlite3PagerWrite( pPg.pDbPage ); - releasePage( pPg ); - if ( rc != SQLITE_OK ) - { - return rc; - } - } - iLastPg--; - } - sqlite3PagerTruncateImage( pBt.pPager, iLastPg ); - pBt.nPage = iLastPg; - } - return SQLITE_OK; -} + if (nFin == 0) { + iLastPg--; + while (iLastPg == PENDING_BYTE_PAGE(pBt) || PTRMAP_ISPAGE(pBt, iLastPg)) { + if (PTRMAP_ISPAGE(pBt, iLastPg)) { + MemPage pPg = new MemPage(); + rc = btreeGetPage(pBt, iLastPg, ref pPg, 0); + if (rc != SQLITE_OK) { + return rc; + } + rc = sqlite3PagerWrite(pPg.pDbPage); + releasePage(pPg); + if (rc != SQLITE_OK) { + return rc; + } + } + iLastPg--; + } + sqlite3PagerTruncateImage(pBt.pPager, iLastPg); + pBt.nPage = iLastPg; + } + return SQLITE_OK; + } -/* -** A write-transaction must be opened before calling this function. -** It performs a single unit of work towards an incremental vacuum. -** -** If the incremental vacuum is finished after this function has run, -** SQLITE_DONE is returned. If it is not finished, but no error occurred, -** SQLITE_OK is returned. Otherwise an SQLite error code. -*/ -static int sqlite3BtreeIncrVacuum( Btree p ) -{ - int rc; - BtShared pBt = p.pBt; - - sqlite3BtreeEnter( p ); - Debug.Assert( pBt.inTransaction == TRANS_WRITE && p.inTrans == TRANS_WRITE ); - if ( !pBt.autoVacuum ) - { - rc = SQLITE_DONE; - } - else - { - invalidateAllOverflowCache( pBt ); - rc = incrVacuumStep( pBt, 0, btreePagecount( pBt ) ); - if ( rc == SQLITE_OK ) - { - rc = sqlite3PagerWrite( pBt.pPage1.pDbPage ); - sqlite3Put4byte( pBt.pPage1.aData, (u32)28, pBt.nPage );//put4byte(&pBt->pPage1->aData[28], pBt->nPage); - } - } - sqlite3BtreeLeave( p ); - return rc; -} + /* + ** A write-transaction must be opened before calling this function. + ** It performs a single unit of work towards an incremental vacuum. + ** + ** If the incremental vacuum is finished after this function has run, + ** SQLITE_DONE is returned. If it is not finished, but no error occurred, + ** SQLITE_OK is returned. Otherwise an SQLite error code. + */ + static int sqlite3BtreeIncrVacuum(Btree p) { + int rc; + BtShared pBt = p.pBt; + + sqlite3BtreeEnter(p); + Debug.Assert(pBt.inTransaction == TRANS_WRITE && p.inTrans == TRANS_WRITE); + if (!pBt.autoVacuum) { + rc = SQLITE_DONE; + } else { + invalidateAllOverflowCache(pBt); + rc = incrVacuumStep(pBt, 0, btreePagecount(pBt)); + if (rc == SQLITE_OK) { + rc = sqlite3PagerWrite(pBt.pPage1.pDbPage); + sqlite3Put4byte(pBt.pPage1.aData, (u32)28, pBt.nPage);//put4byte(&pBt->pPage1->aData[28], pBt->nPage); + } + } + sqlite3BtreeLeave(p); + return rc; + } -/* -** This routine is called prior to sqlite3PagerCommit when a transaction -** is commited for an auto-vacuum database. -** -** If SQLITE_OK is returned, then pnTrunc is set to the number of pages -** the database file should be truncated to during the commit process. -** i.e. the database has been reorganized so that only the first pnTrunc -** pages are in use. -*/ -static int autoVacuumCommit( BtShared pBt ) -{ - int rc = SQLITE_OK; - Pager pPager = pBt.pPager; - // VVA_ONLY( int nRef = sqlite3PagerRefcount(pPager) ); + /* + ** This routine is called prior to sqlite3PagerCommit when a transaction + ** is commited for an auto-vacuum database. + ** + ** If SQLITE_OK is returned, then pnTrunc is set to the number of pages + ** the database file should be truncated to during the commit process. + ** i.e. the database has been reorganized so that only the first pnTrunc + ** pages are in use. + */ + static int autoVacuumCommit(BtShared pBt) { + int rc = SQLITE_OK; + Pager pPager = pBt.pPager; + // VVA_ONLY( int nRef = sqlite3PagerRefcount(pPager) ); #if !NDEBUG || DEBUG - int nRef = sqlite3PagerRefcount( pPager ); + int nRef = sqlite3PagerRefcount(pPager); #else int nRef=0; #endif - Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); - invalidateAllOverflowCache( pBt ); - Debug.Assert( pBt.autoVacuum ); - if ( !pBt.incrVacuum ) - { - Pgno nFin; /* Number of pages in database after autovacuuming */ - Pgno nFree; /* Number of pages on the freelist initially */ - Pgno nPtrmap; /* Number of PtrMap pages to be freed */ - Pgno iFree; /* The next page to be freed */ - int nEntry; /* Number of entries on one ptrmap page */ - Pgno nOrig; /* Database size before freeing */ - - nOrig = btreePagecount( pBt ); - if ( PTRMAP_ISPAGE( pBt, nOrig ) || nOrig == PENDING_BYTE_PAGE( pBt ) ) - { - /* It is not possible to create a database for which the final page - ** is either a pointer-map page or the pending-byte page. If one - ** is encountered, this indicates corruption. - */ - return SQLITE_CORRUPT_BKPT(); - } + Debug.Assert(sqlite3_mutex_held(pBt.mutex)); + invalidateAllOverflowCache(pBt); + Debug.Assert(pBt.autoVacuum); + if (!pBt.incrVacuum) { + Pgno nFin; /* Number of pages in database after autovacuuming */ + Pgno nFree; /* Number of pages on the freelist initially */ + Pgno nPtrmap; /* Number of PtrMap pages to be freed */ + Pgno iFree; /* The next page to be freed */ + int nEntry; /* Number of entries on one ptrmap page */ + Pgno nOrig; /* Database size before freeing */ + + nOrig = btreePagecount(pBt); + if (PTRMAP_ISPAGE(pBt, nOrig) || nOrig == PENDING_BYTE_PAGE(pBt)) { + /* It is not possible to create a database for which the final page + ** is either a pointer-map page or the pending-byte page. If one + ** is encountered, this indicates corruption. + */ + return SQLITE_CORRUPT_BKPT(); + } + + nFree = sqlite3Get4byte(pBt.pPage1.aData, 36); + nEntry = (int)pBt.usableSize / 5; + nPtrmap = (Pgno)((nFree - nOrig + PTRMAP_PAGENO(pBt, nOrig) + (Pgno)nEntry) / nEntry); + nFin = nOrig - nFree - nPtrmap; + if (nOrig > PENDING_BYTE_PAGE(pBt) && nFin < PENDING_BYTE_PAGE(pBt)) { + nFin--; + } + while (PTRMAP_ISPAGE(pBt, nFin) || nFin == PENDING_BYTE_PAGE(pBt)) { + nFin--; + } + if (nFin > nOrig) + return SQLITE_CORRUPT_BKPT(); + + for (iFree = nOrig; iFree > nFin && rc == SQLITE_OK; iFree--) { + rc = incrVacuumStep(pBt, nFin, iFree); + } + if ((rc == SQLITE_DONE || rc == SQLITE_OK) && nFree > 0) { + rc = sqlite3PagerWrite(pBt.pPage1.pDbPage); + sqlite3Put4byte(pBt.pPage1.aData, 32, 0); + sqlite3Put4byte(pBt.pPage1.aData, 36, 0); + sqlite3Put4byte(pBt.pPage1.aData, (u32)28, nFin); + sqlite3PagerTruncateImage(pBt.pPager, nFin); + pBt.nPage = nFin; + } + if (rc != SQLITE_OK) { + sqlite3PagerRollback(pPager); + } + } - nFree = sqlite3Get4byte( pBt.pPage1.aData, 36 ); - nEntry = (int)pBt.usableSize / 5; - nPtrmap = (Pgno)( ( nFree - nOrig + PTRMAP_PAGENO( pBt, nOrig ) + (Pgno)nEntry ) / nEntry ); - nFin = nOrig - nFree - nPtrmap; - if ( nOrig > PENDING_BYTE_PAGE( pBt ) && nFin < PENDING_BYTE_PAGE( pBt ) ) - { - nFin--; - } - while ( PTRMAP_ISPAGE( pBt, nFin ) || nFin == PENDING_BYTE_PAGE( pBt ) ) - { - nFin--; - } - if ( nFin > nOrig ) - return SQLITE_CORRUPT_BKPT(); - - for ( iFree = nOrig; iFree > nFin && rc == SQLITE_OK; iFree-- ) - { - rc = incrVacuumStep( pBt, nFin, iFree ); - } - if ( ( rc == SQLITE_DONE || rc == SQLITE_OK ) && nFree > 0 ) - { - rc = sqlite3PagerWrite( pBt.pPage1.pDbPage ); - sqlite3Put4byte( pBt.pPage1.aData, 32, 0 ); - sqlite3Put4byte( pBt.pPage1.aData, 36, 0 ); - sqlite3Put4byte( pBt.pPage1.aData, (u32)28, nFin ); - sqlite3PagerTruncateImage( pBt.pPager, nFin ); - pBt.nPage = nFin; - } - if ( rc != SQLITE_OK ) - { - sqlite3PagerRollback( pPager ); - } - } - - Debug.Assert( nRef == sqlite3PagerRefcount( pPager ) ); - return rc; -} + Debug.Assert(nRef == sqlite3PagerRefcount(pPager)); + return rc; + } #else //* ifndef SQLITE_OMIT_AUTOVACUUM */ //# define setChildPtrmaps(x) SQLITE_OK #endif -/* -** This routine does the first phase of a two-phase commit. This routine -** causes a rollback journal to be created (if it does not already exist) -** and populated with enough information so that if a power loss occurs -** the database can be restored to its original state by playing back -** the journal. Then the contents of the journal are flushed out to -** the disk. After the journal is safely on oxide, the changes to the -** database are written into the database file and flushed to oxide. -** At the end of this call, the rollback journal still exists on the -** disk and we are still holding all locks, so the transaction has not -** committed. See sqlite3BtreeCommitPhaseTwo() for the second phase of the -** commit process. -** -** This call is a no-op if no write-transaction is currently active on pBt. -** -** Otherwise, sync the database file for the btree pBt. zMaster points to -** the name of a master journal file that should be written into the -** individual journal file, or is NULL, indicating no master journal file -** (single database transaction). -** -** When this is called, the master journal should already have been -** created, populated with this journal pointer and synced to disk. -** -** Once this is routine has returned, the only thing required to commit -** the write-transaction for this database file is to delete the journal. -*/ -static int sqlite3BtreeCommitPhaseOne( Btree p, string zMaster ) -{ - int rc = SQLITE_OK; - if ( p.inTrans == TRANS_WRITE ) - { - BtShared pBt = p.pBt; - sqlite3BtreeEnter( p ); + /* + ** This routine does the first phase of a two-phase commit. This routine + ** causes a rollback journal to be created (if it does not already exist) + ** and populated with enough information so that if a power loss occurs + ** the database can be restored to its original state by playing back + ** the journal. Then the contents of the journal are flushed out to + ** the disk. After the journal is safely on oxide, the changes to the + ** database are written into the database file and flushed to oxide. + ** At the end of this call, the rollback journal still exists on the + ** disk and we are still holding all locks, so the transaction has not + ** committed. See sqlite3BtreeCommitPhaseTwo() for the second phase of the + ** commit process. + ** + ** This call is a no-op if no write-transaction is currently active on pBt. + ** + ** Otherwise, sync the database file for the btree pBt. zMaster points to + ** the name of a master journal file that should be written into the + ** individual journal file, or is NULL, indicating no master journal file + ** (single database transaction). + ** + ** When this is called, the master journal should already have been + ** created, populated with this journal pointer and synced to disk. + ** + ** Once this is routine has returned, the only thing required to commit + ** the write-transaction for this database file is to delete the journal. + */ + static int sqlite3BtreeCommitPhaseOne(Btree p, string zMaster) { + int rc = SQLITE_OK; + if (p.inTrans == TRANS_WRITE) { + BtShared pBt = p.pBt; + sqlite3BtreeEnter(p); #if !SQLITE_OMIT_AUTOVACUUM - if ( pBt.autoVacuum ) - { - rc = autoVacuumCommit( pBt ); - if ( rc != SQLITE_OK ) - { - sqlite3BtreeLeave( p ); - return rc; - } - } + if (pBt.autoVacuum) { + rc = autoVacuumCommit(pBt); + if (rc != SQLITE_OK) { + sqlite3BtreeLeave(p); + return rc; + } + } #endif - rc = sqlite3PagerCommitPhaseOne( pBt.pPager, zMaster, false ); - sqlite3BtreeLeave( p ); - } - return rc; -} - -/* -** This function is called from both BtreeCommitPhaseTwo() and BtreeRollback() -** at the conclusion of a transaction. -*/ -static void btreeEndTransaction( Btree p ) -{ - BtShared pBt = p.pBt; - Debug.Assert( sqlite3BtreeHoldsMutex( p ) ); - - btreeClearHasContent( pBt ); - if ( p.inTrans > TRANS_NONE && p.db.activeVdbeCnt > 1 ) - { - /* If there are other active statements that belong to this database - ** handle, downgrade to a read-only transaction. The other statements - ** may still be reading from the database. */ - - downgradeAllSharedCacheTableLocks( p ); - p.inTrans = TRANS_READ; - } - else - { - /* If the handle had any kind of transaction open, decrement the - ** transaction count of the shared btree. If the transaction count - ** reaches 0, set the shared state to TRANS_NONE. The unlockBtreeIfUnused() - ** call below will unlock the pager. */ - if ( p.inTrans != TRANS_NONE ) - { - clearAllSharedCacheTableLocks( p ); - pBt.nTransaction--; - if ( 0 == pBt.nTransaction ) - { - pBt.inTransaction = TRANS_NONE; - } - } + rc = sqlite3PagerCommitPhaseOne(pBt.pPager, zMaster, false); + sqlite3BtreeLeave(p); + } + return rc; + } - /* Set the current transaction state to TRANS_NONE and unlock the - ** pager if this call closed the only read or write transaction. */ - p.inTrans = TRANS_NONE; - unlockBtreeIfUnused( pBt ); - } + /* + ** This function is called from both BtreeCommitPhaseTwo() and BtreeRollback() + ** at the conclusion of a transaction. + */ + static void btreeEndTransaction(Btree p) { + BtShared pBt = p.pBt; + Debug.Assert(sqlite3BtreeHoldsMutex(p)); + + btreeClearHasContent(pBt); + if (p.inTrans > TRANS_NONE && p.db.activeVdbeCnt > 1) { + /* If there are other active statements that belong to this database + ** handle, downgrade to a read-only transaction. The other statements + ** may still be reading from the database. */ + + downgradeAllSharedCacheTableLocks(p); + p.inTrans = TRANS_READ; + } else { + /* If the handle had any kind of transaction open, decrement the + ** transaction count of the shared btree. If the transaction count + ** reaches 0, set the shared state to TRANS_NONE. The unlockBtreeIfUnused() + ** call below will unlock the pager. */ + if (p.inTrans != TRANS_NONE) { + clearAllSharedCacheTableLocks(p); + pBt.nTransaction--; + if (0 == pBt.nTransaction) { + pBt.inTransaction = TRANS_NONE; + } + } + + /* Set the current transaction state to TRANS_NONE and unlock the + ** pager if this call closed the only read or write transaction. */ + p.inTrans = TRANS_NONE; + unlockBtreeIfUnused(pBt); + } - btreeIntegrity( p ); -} + btreeIntegrity(p); + } -/* -** Commit the transaction currently in progress. -** -** This routine implements the second phase of a 2-phase commit. The -** sqlite3BtreeCommitPhaseOne() routine does the first phase and should -** be invoked prior to calling this routine. The sqlite3BtreeCommitPhaseOne() -** routine did all the work of writing information out to disk and flushing the -** contents so that they are written onto the disk platter. All this -** routine has to do is delete or truncate or zero the header in the -** the rollback journal (which causes the transaction to commit) and -** drop locks. -** -** Normally, if an error occurs while the pager layer is attempting to -** finalize the underlying journal file, this function returns an error and -** the upper layer will attempt a rollback. However, if the second argument -** is non-zero then this b-tree transaction is part of a multi-file -** transaction. In this case, the transaction has already been committed -** (by deleting a master journal file) and the caller will ignore this -** functions return code. So, even if an error occurs in the pager layer, -** reset the b-tree objects internal state to indicate that the write -** transaction has been closed. This is quite safe, as the pager will have -** transitioned to the error state. -** -** This will release the write lock on the database file. If there -** are no active cursors, it also releases the read lock. -*/ -static int sqlite3BtreeCommitPhaseTwo( Btree p, int bCleanup) -{ - if ( p.inTrans == TRANS_NONE ) - return SQLITE_OK; - sqlite3BtreeEnter( p ); - btreeIntegrity( p ); - - /* If the handle has a write-transaction open, commit the shared-btrees - ** transaction and set the shared state to TRANS_READ. - */ - if ( p.inTrans == TRANS_WRITE ) - { - int rc; - BtShared pBt = p.pBt; - Debug.Assert( pBt.inTransaction == TRANS_WRITE ); - Debug.Assert( pBt.nTransaction > 0 ); - rc = sqlite3PagerCommitPhaseTwo( pBt.pPager ); - if ( rc != SQLITE_OK && bCleanup == 0 ) - { - sqlite3BtreeLeave( p ); - return rc; - } - pBt.inTransaction = TRANS_READ; - } + /* + ** Commit the transaction currently in progress. + ** + ** This routine implements the second phase of a 2-phase commit. The + ** sqlite3BtreeCommitPhaseOne() routine does the first phase and should + ** be invoked prior to calling this routine. The sqlite3BtreeCommitPhaseOne() + ** routine did all the work of writing information out to disk and flushing the + ** contents so that they are written onto the disk platter. All this + ** routine has to do is delete or truncate or zero the header in the + ** the rollback journal (which causes the transaction to commit) and + ** drop locks. + ** + ** Normally, if an error occurs while the pager layer is attempting to + ** finalize the underlying journal file, this function returns an error and + ** the upper layer will attempt a rollback. However, if the second argument + ** is non-zero then this b-tree transaction is part of a multi-file + ** transaction. In this case, the transaction has already been committed + ** (by deleting a master journal file) and the caller will ignore this + ** functions return code. So, even if an error occurs in the pager layer, + ** reset the b-tree objects internal state to indicate that the write + ** transaction has been closed. This is quite safe, as the pager will have + ** transitioned to the error state. + ** + ** This will release the write lock on the database file. If there + ** are no active cursors, it also releases the read lock. + */ + static int sqlite3BtreeCommitPhaseTwo(Btree p, int bCleanup) { + if (p.inTrans == TRANS_NONE) + return SQLITE_OK; + sqlite3BtreeEnter(p); + btreeIntegrity(p); + + /* If the handle has a write-transaction open, commit the shared-btrees + ** transaction and set the shared state to TRANS_READ. + */ + if (p.inTrans == TRANS_WRITE) { + int rc; + BtShared pBt = p.pBt; + Debug.Assert(pBt.inTransaction == TRANS_WRITE); + Debug.Assert(pBt.nTransaction > 0); + rc = sqlite3PagerCommitPhaseTwo(pBt.pPager); + if (rc != SQLITE_OK && bCleanup == 0) { + sqlite3BtreeLeave(p); + return rc; + } + pBt.inTransaction = TRANS_READ; + } - btreeEndTransaction( p ); - sqlite3BtreeLeave( p ); - return SQLITE_OK; -} + btreeEndTransaction(p); + sqlite3BtreeLeave(p); + return SQLITE_OK; + } -/* -** Do both phases of a commit. -*/ -static int sqlite3BtreeCommit( Btree p ) -{ - int rc; - sqlite3BtreeEnter( p ); - rc = sqlite3BtreeCommitPhaseOne( p, null ); - if ( rc == SQLITE_OK ) - { - rc = sqlite3BtreeCommitPhaseTwo( p, 0 ); - } - sqlite3BtreeLeave( p ); - return rc; -} + /* + ** Do both phases of a commit. + */ + static int sqlite3BtreeCommit(Btree p) { + int rc; + sqlite3BtreeEnter(p); + rc = sqlite3BtreeCommitPhaseOne(p, null); + if (rc == SQLITE_OK) { + rc = sqlite3BtreeCommitPhaseTwo(p, 0); + } + sqlite3BtreeLeave(p); + return rc; + } #if !NDEBUG || DEBUG -/* -** Return the number of write-cursors open on this handle. This is for use -** in Debug.Assert() expressions, so it is only compiled if NDEBUG is not -** defined. -** -** For the purposes of this routine, a write-cursor is any cursor that -** is capable of writing to the databse. That means the cursor was -** originally opened for writing and the cursor has not be disabled -** by having its state changed to CURSOR_FAULT. -*/ -static int countWriteCursors( BtShared pBt ) -{ - BtCursor pCur; - int r = 0; - for ( pCur = pBt.pCursor; pCur != null; pCur = pCur.pNext ) - { - if ( pCur.wrFlag != 0 && pCur.eState != CURSOR_FAULT ) - r++; - } - return r; -} + /* + ** Return the number of write-cursors open on this handle. This is for use + ** in Debug.Assert() expressions, so it is only compiled if NDEBUG is not + ** defined. + ** + ** For the purposes of this routine, a write-cursor is any cursor that + ** is capable of writing to the databse. That means the cursor was + ** originally opened for writing and the cursor has not be disabled + ** by having its state changed to CURSOR_FAULT. + */ + static int countWriteCursors(BtShared pBt) { + BtCursor pCur; + int r = 0; + for (pCur = pBt.pCursor; pCur != null; pCur = pCur.pNext) { + if (pCur.wrFlag != 0 && pCur.eState != CURSOR_FAULT) + r++; + } + return r; + } #else static int countWriteCursors(BtShared pBt) { return -1; } #endif -/* -** This routine sets the state to CURSOR_FAULT and the error -** code to errCode for every cursor on BtShared that pBtree -** references. -** -** Every cursor is tripped, including cursors that belong -** to other database connections that happen to be sharing -** the cache with pBtree. -** -** This routine gets called when a rollback occurs. -** All cursors using the same cache must be tripped -** to prevent them from trying to use the btree after -** the rollback. The rollback may have deleted tables -** or moved root pages, so it is not sufficient to -** save the state of the cursor. The cursor must be -** invalidated. -*/ -static void sqlite3BtreeTripAllCursors( Btree pBtree, int errCode ) -{ - BtCursor p; - sqlite3BtreeEnter( pBtree ); - for ( p = pBtree.pBt.pCursor; p != null; p = p.pNext ) - { - int i; - sqlite3BtreeClearCursor( p ); - p.eState = CURSOR_FAULT; - p.skipNext = errCode; - for ( i = 0; i <= p.iPage; i++ ) - { - releasePage( p.apPage[i] ); - p.apPage[i] = null; - } - } - sqlite3BtreeLeave( pBtree ); -} + /* + ** This routine sets the state to CURSOR_FAULT and the error + ** code to errCode for every cursor on BtShared that pBtree + ** references. + ** + ** Every cursor is tripped, including cursors that belong + ** to other database connections that happen to be sharing + ** the cache with pBtree. + ** + ** This routine gets called when a rollback occurs. + ** All cursors using the same cache must be tripped + ** to prevent them from trying to use the btree after + ** the rollback. The rollback may have deleted tables + ** or moved root pages, so it is not sufficient to + ** save the state of the cursor. The cursor must be + ** invalidated. + */ + static void sqlite3BtreeTripAllCursors(Btree pBtree, int errCode) { + BtCursor p; + sqlite3BtreeEnter(pBtree); + for (p = pBtree.pBt.pCursor; p != null; p = p.pNext) { + int i; + sqlite3BtreeClearCursor(p); + p.eState = CURSOR_FAULT; + p.skipNext = errCode; + for (i = 0; i <= p.iPage; i++) { + releasePage(p.apPage[i]); + p.apPage[i] = null; + } + } + sqlite3BtreeLeave(pBtree); + } -/* -** Rollback the transaction in progress. All cursors will be -** invalided by this operation. Any attempt to use a cursor -** that was open at the beginning of this operation will result -** in an error. -** -** This will release the write lock on the database file. If there -** are no active cursors, it also releases the read lock. -*/ -static int sqlite3BtreeRollback( Btree p ) -{ - int rc; - BtShared pBt = p.pBt; - MemPage pPage1 = new MemPage(); + /* + ** Rollback the transaction in progress. All cursors will be + ** invalided by this operation. Any attempt to use a cursor + ** that was open at the beginning of this operation will result + ** in an error. + ** + ** This will release the write lock on the database file. If there + ** are no active cursors, it also releases the read lock. + */ + static int sqlite3BtreeRollback(Btree p) { + int rc; + BtShared pBt = p.pBt; + MemPage pPage1 = new MemPage(); - sqlite3BtreeEnter( p ); - rc = saveAllCursors( pBt, 0, null ); + sqlite3BtreeEnter(p); + rc = saveAllCursors(pBt, 0, null); #if !SQLITE_OMIT_SHARED_CACHE if( rc!=SQLITE_OK ){ /* This is a horrible situation. An IO or malloc() error occurred whilst @@ -3806,356 +3491,327 @@ static int sqlite3BtreeRollback( Btree p ) sqlite3BtreeTripAllCursors(p, rc); } #endif - btreeIntegrity( p ); - - if ( p.inTrans == TRANS_WRITE ) - { - int rc2; - - Debug.Assert( TRANS_WRITE == pBt.inTransaction ); - rc2 = sqlite3PagerRollback( pBt.pPager ); - if ( rc2 != SQLITE_OK ) - { - rc = rc2; - } + btreeIntegrity(p); + + if (p.inTrans == TRANS_WRITE) { + int rc2; + + Debug.Assert(TRANS_WRITE == pBt.inTransaction); + rc2 = sqlite3PagerRollback(pBt.pPager); + if (rc2 != SQLITE_OK) { + rc = rc2; + } + + /* The rollback may have destroyed the pPage1.aData value. So + ** call btreeGetPage() on page 1 again to make + ** sure pPage1.aData is set correctly. */ + if (btreeGetPage(pBt, 1, ref pPage1, 0) == SQLITE_OK) { + Pgno nPage = sqlite3Get4byte(pPage1.aData, 28); + testcase(nPage == 0); + if (nPage == 0) + sqlite3PagerPagecount(pBt.pPager, out nPage); + testcase(pBt.nPage != nPage); + pBt.nPage = nPage; + releasePage(pPage1); + } + Debug.Assert(countWriteCursors(pBt) == 0); + pBt.inTransaction = TRANS_READ; + } - /* The rollback may have destroyed the pPage1.aData value. So - ** call btreeGetPage() on page 1 again to make - ** sure pPage1.aData is set correctly. */ - if ( btreeGetPage( pBt, 1, ref pPage1, 0 ) == SQLITE_OK ) - { - Pgno nPage = sqlite3Get4byte( pPage1.aData, 28 ); - testcase( nPage == 0 ); - if ( nPage == 0 ) - sqlite3PagerPagecount( pBt.pPager, out nPage ); - testcase( pBt.nPage != nPage ); - pBt.nPage = nPage; - releasePage( pPage1 ); - } - Debug.Assert( countWriteCursors( pBt ) == 0 ); - pBt.inTransaction = TRANS_READ; - } + btreeEndTransaction(p); + sqlite3BtreeLeave(p); + return rc; + } - btreeEndTransaction( p ); - sqlite3BtreeLeave( p ); - return rc; -} + /* + ** Start a statement subtransaction. The subtransaction can can be rolled + ** back independently of the main transaction. You must start a transaction + ** before starting a subtransaction. The subtransaction is ended automatically + ** if the main transaction commits or rolls back. + ** + ** Statement subtransactions are used around individual SQL statements + ** that are contained within a BEGIN...COMMIT block. If a constraint + ** error occurs within the statement, the effect of that one statement + ** can be rolled back without having to rollback the entire transaction. + ** + ** A statement sub-transaction is implemented as an anonymous savepoint. The + ** value passed as the second parameter is the total number of savepoints, + ** including the new anonymous savepoint, open on the B-Tree. i.e. if there + ** are no active savepoints and no other statement-transactions open, + ** iStatement is 1. This anonymous savepoint can be released or rolled back + ** using the sqlite3BtreeSavepoint() function. + */ + static int sqlite3BtreeBeginStmt(Btree p, int iStatement) { + int rc; + BtShared pBt = p.pBt; + sqlite3BtreeEnter(p); + Debug.Assert(p.inTrans == TRANS_WRITE); + Debug.Assert(!pBt.readOnly); + Debug.Assert(iStatement > 0); + Debug.Assert(iStatement > p.db.nSavepoint); + Debug.Assert(pBt.inTransaction == TRANS_WRITE); + /* At the pager level, a statement transaction is a savepoint with + ** an index greater than all savepoints created explicitly using + ** SQL statements. It is illegal to open, release or rollback any + ** such savepoints while the statement transaction savepoint is active. + */ + rc = sqlite3PagerOpenSavepoint(pBt.pPager, iStatement); + sqlite3BtreeLeave(p); + return rc; + } -/* -** Start a statement subtransaction. The subtransaction can can be rolled -** back independently of the main transaction. You must start a transaction -** before starting a subtransaction. The subtransaction is ended automatically -** if the main transaction commits or rolls back. -** -** Statement subtransactions are used around individual SQL statements -** that are contained within a BEGIN...COMMIT block. If a constraint -** error occurs within the statement, the effect of that one statement -** can be rolled back without having to rollback the entire transaction. -** -** A statement sub-transaction is implemented as an anonymous savepoint. The -** value passed as the second parameter is the total number of savepoints, -** including the new anonymous savepoint, open on the B-Tree. i.e. if there -** are no active savepoints and no other statement-transactions open, -** iStatement is 1. This anonymous savepoint can be released or rolled back -** using the sqlite3BtreeSavepoint() function. -*/ -static int sqlite3BtreeBeginStmt( Btree p, int iStatement ) -{ - int rc; - BtShared pBt = p.pBt; - sqlite3BtreeEnter( p ); - Debug.Assert( p.inTrans == TRANS_WRITE ); - Debug.Assert( !pBt.readOnly ); - Debug.Assert( iStatement > 0 ); - Debug.Assert( iStatement > p.db.nSavepoint ); - Debug.Assert( pBt.inTransaction == TRANS_WRITE ); - /* At the pager level, a statement transaction is a savepoint with - ** an index greater than all savepoints created explicitly using - ** SQL statements. It is illegal to open, release or rollback any - ** such savepoints while the statement transaction savepoint is active. - */ - rc = sqlite3PagerOpenSavepoint( pBt.pPager, iStatement ); - sqlite3BtreeLeave( p ); - return rc; -} + /* + ** The second argument to this function, op, is always SAVEPOINT_ROLLBACK + ** or SAVEPOINT_RELEASE. This function either releases or rolls back the + ** savepoint identified by parameter iSavepoint, depending on the value + ** of op. + ** + ** Normally, iSavepoint is greater than or equal to zero. However, if op is + ** SAVEPOINT_ROLLBACK, then iSavepoint may also be -1. In this case the + ** contents of the entire transaction are rolled back. This is different + ** from a normal transaction rollback, as no locks are released and the + ** transaction remains open. + */ + static int sqlite3BtreeSavepoint(Btree p, int op, int iSavepoint) { + int rc = SQLITE_OK; + if (p != null && p.inTrans == TRANS_WRITE) { + BtShared pBt = p.pBt; + Debug.Assert(op == SAVEPOINT_RELEASE || op == SAVEPOINT_ROLLBACK); + Debug.Assert(iSavepoint >= 0 || (iSavepoint == -1 && op == SAVEPOINT_ROLLBACK)); + sqlite3BtreeEnter(p); + rc = sqlite3PagerSavepoint(pBt.pPager, op, iSavepoint); + if (rc == SQLITE_OK) { + if (iSavepoint < 0 && pBt.initiallyEmpty) + pBt.nPage = 0; + rc = newDatabase(pBt); + pBt.nPage = sqlite3Get4byte(pBt.pPage1.aData, 28); + /* The database size was written into the offset 28 of the header + ** when the transaction started, so we know that the value at offset + ** 28 is nonzero. */ + Debug.Assert(pBt.nPage > 0); + } + sqlite3BtreeLeave(p); + } + return rc; + } -/* -** The second argument to this function, op, is always SAVEPOINT_ROLLBACK -** or SAVEPOINT_RELEASE. This function either releases or rolls back the -** savepoint identified by parameter iSavepoint, depending on the value -** of op. -** -** Normally, iSavepoint is greater than or equal to zero. However, if op is -** SAVEPOINT_ROLLBACK, then iSavepoint may also be -1. In this case the -** contents of the entire transaction are rolled back. This is different -** from a normal transaction rollback, as no locks are released and the -** transaction remains open. -*/ -static int sqlite3BtreeSavepoint( Btree p, int op, int iSavepoint ) -{ - int rc = SQLITE_OK; - if ( p != null && p.inTrans == TRANS_WRITE ) - { - BtShared pBt = p.pBt; - Debug.Assert( op == SAVEPOINT_RELEASE || op == SAVEPOINT_ROLLBACK ); - Debug.Assert( iSavepoint >= 0 || ( iSavepoint == -1 && op == SAVEPOINT_ROLLBACK ) ); - sqlite3BtreeEnter( p ); - rc = sqlite3PagerSavepoint( pBt.pPager, op, iSavepoint ); - if ( rc == SQLITE_OK ) - { - if ( iSavepoint < 0 && pBt.initiallyEmpty ) - pBt.nPage = 0; - rc = newDatabase( pBt ); - pBt.nPage = sqlite3Get4byte( pBt.pPage1.aData, 28 ); - /* The database size was written into the offset 28 of the header - ** when the transaction started, so we know that the value at offset - ** 28 is nonzero. */ - Debug.Assert( pBt.nPage > 0 ); - } - sqlite3BtreeLeave( p ); - } - return rc; -} + /* + ** Create a new cursor for the BTree whose root is on the page + ** iTable. If a read-only cursor is requested, it is assumed that + ** the caller already has at least a read-only transaction open + ** on the database already. If a write-cursor is requested, then + ** the caller is assumed to have an open write transaction. + ** + ** If wrFlag==null, then the cursor can only be used for reading. + ** If wrFlag==1, then the cursor can be used for reading or for + ** writing if other conditions for writing are also met. These + ** are the conditions that must be met in order for writing to + ** be allowed: + ** + ** 1: The cursor must have been opened with wrFlag==1 + ** + ** 2: Other database connections that share the same pager cache + ** but which are not in the READ_UNCOMMITTED state may not have + ** cursors open with wrFlag==null on the same table. Otherwise + ** the changes made by this write cursor would be visible to + ** the read cursors in the other database connection. + ** + ** 3: The database must be writable (not on read-only media) + ** + ** 4: There must be an active transaction. + ** + ** No checking is done to make sure that page iTable really is the + ** root page of a b-tree. If it is not, then the cursor acquired + ** will not work correctly. + ** + ** It is assumed that the sqlite3BtreeCursorZero() has been called + ** on pCur to initialize the memory space prior to invoking this routine. + */ + static int btreeCursor( + Btree p, /* The btree */ + int iTable, /* Root page of table to open */ + int wrFlag, /* 1 to write. 0 read-only */ + KeyInfo pKeyInfo, /* First arg to comparison function */ + BtCursor pCur /* Space for new cursor */ + ) { + BtShared pBt = p.pBt; /* Shared b-tree handle */ + + Debug.Assert(sqlite3BtreeHoldsMutex(p)); + Debug.Assert(wrFlag == 0 || wrFlag == 1); + + /* The following Debug.Assert statements verify that if this is a sharable + ** b-tree database, the connection is holding the required table locks, + ** and that no other connection has any open cursor that conflicts with + ** this lock. */ + Debug.Assert(hasSharedCacheTableLock(p, (u32)iTable, pKeyInfo != null ? 1 : 0, wrFlag + 1)); + Debug.Assert(wrFlag == 0 || !hasReadConflicts(p, (u32)iTable)); + + /* Assert that the caller has opened the required transaction. */ + Debug.Assert(p.inTrans > TRANS_NONE); + Debug.Assert(wrFlag == 0 || p.inTrans == TRANS_WRITE); + Debug.Assert(pBt.pPage1 != null && pBt.pPage1.aData != null); + + if (NEVER(wrFlag != 0 && pBt.readOnly)) { + return SQLITE_READONLY; + } + if (iTable == 1 && btreePagecount(pBt) == 0) { + return SQLITE_EMPTY; + } -/* -** Create a new cursor for the BTree whose root is on the page -** iTable. If a read-only cursor is requested, it is assumed that -** the caller already has at least a read-only transaction open -** on the database already. If a write-cursor is requested, then -** the caller is assumed to have an open write transaction. -** -** If wrFlag==null, then the cursor can only be used for reading. -** If wrFlag==1, then the cursor can be used for reading or for -** writing if other conditions for writing are also met. These -** are the conditions that must be met in order for writing to -** be allowed: -** -** 1: The cursor must have been opened with wrFlag==1 -** -** 2: Other database connections that share the same pager cache -** but which are not in the READ_UNCOMMITTED state may not have -** cursors open with wrFlag==null on the same table. Otherwise -** the changes made by this write cursor would be visible to -** the read cursors in the other database connection. -** -** 3: The database must be writable (not on read-only media) -** -** 4: There must be an active transaction. -** -** No checking is done to make sure that page iTable really is the -** root page of a b-tree. If it is not, then the cursor acquired -** will not work correctly. -** -** It is assumed that the sqlite3BtreeCursorZero() has been called -** on pCur to initialize the memory space prior to invoking this routine. -*/ -static int btreeCursor( -Btree p, /* The btree */ -int iTable, /* Root page of table to open */ -int wrFlag, /* 1 to write. 0 read-only */ -KeyInfo pKeyInfo, /* First arg to comparison function */ -BtCursor pCur /* Space for new cursor */ -) -{ - BtShared pBt = p.pBt; /* Shared b-tree handle */ - - Debug.Assert( sqlite3BtreeHoldsMutex( p ) ); - Debug.Assert( wrFlag == 0 || wrFlag == 1 ); - - /* The following Debug.Assert statements verify that if this is a sharable - ** b-tree database, the connection is holding the required table locks, - ** and that no other connection has any open cursor that conflicts with - ** this lock. */ - Debug.Assert( hasSharedCacheTableLock( p, (u32)iTable, pKeyInfo != null ? 1 : 0, wrFlag + 1 ) ); - Debug.Assert( wrFlag == 0 || !hasReadConflicts( p, (u32)iTable ) ); - - /* Assert that the caller has opened the required transaction. */ - Debug.Assert( p.inTrans > TRANS_NONE ); - Debug.Assert( wrFlag == 0 || p.inTrans == TRANS_WRITE ); - Debug.Assert( pBt.pPage1 != null && pBt.pPage1.aData != null ); - - if ( NEVER( wrFlag != 0 && pBt.readOnly ) ) - { - return SQLITE_READONLY; - } - if ( iTable == 1 && btreePagecount( pBt ) == 0 ) - { - return SQLITE_EMPTY; - } - - /* Now that no other errors can occur, finish filling in the BtCursor - ** variables and link the cursor into the BtShared list. */ - pCur.pgnoRoot = (Pgno)iTable; - pCur.iPage = -1; - pCur.pKeyInfo = pKeyInfo; - pCur.pBtree = p; - pCur.pBt = pBt; - pCur.wrFlag = (u8)wrFlag; - pCur.pNext = pBt.pCursor; - if ( pCur.pNext != null ) - { - pCur.pNext.pPrev = pCur; - } - pBt.pCursor = pCur; - pCur.eState = CURSOR_INVALID; - pCur.cachedRowid = 0; - return SQLITE_OK; -} -static int sqlite3BtreeCursor( -Btree p, /* The btree */ -int iTable, /* Root page of table to open */ -int wrFlag, /* 1 to write. 0 read-only */ -KeyInfo pKeyInfo, /* First arg to xCompare() */ -BtCursor pCur /* Write new cursor here */ -) -{ - int rc; - sqlite3BtreeEnter( p ); - rc = btreeCursor( p, iTable, wrFlag, pKeyInfo, pCur ); - sqlite3BtreeLeave( p ); - return rc; -} + /* Now that no other errors can occur, finish filling in the BtCursor + ** variables and link the cursor into the BtShared list. */ + pCur.pgnoRoot = (Pgno)iTable; + pCur.iPage = -1; + pCur.pKeyInfo = pKeyInfo; + pCur.pBtree = p; + pCur.pBt = pBt; + pCur.wrFlag = (u8)wrFlag; + pCur.pNext = pBt.pCursor; + if (pCur.pNext != null) { + pCur.pNext.pPrev = pCur; + } + pBt.pCursor = pCur; + pCur.eState = CURSOR_INVALID; + pCur.cachedRowid = 0; + return SQLITE_OK; + } + static int sqlite3BtreeCursor( + Btree p, /* The btree */ + int iTable, /* Root page of table to open */ + int wrFlag, /* 1 to write. 0 read-only */ + KeyInfo pKeyInfo, /* First arg to xCompare() */ + BtCursor pCur /* Write new cursor here */ + ) { + int rc; + sqlite3BtreeEnter(p); + rc = btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur); + sqlite3BtreeLeave(p); + return rc; + } -/* -** Return the size of a BtCursor object in bytes. -** -** This interfaces is needed so that users of cursors can preallocate -** sufficient storage to hold a cursor. The BtCursor object is opaque -** to users so they cannot do the sizeof() themselves - they must call -** this routine. -*/ -static int sqlite3BtreeCursorSize() -{ - return -1; // Not Used -- return ROUND8(sizeof(BtCursor)); -} + /* + ** Return the size of a BtCursor object in bytes. + ** + ** This interfaces is needed so that users of cursors can preallocate + ** sufficient storage to hold a cursor. The BtCursor object is opaque + ** to users so they cannot do the sizeof() themselves - they must call + ** this routine. + */ + static int sqlite3BtreeCursorSize() { + return -1; // Not Used -- return ROUND8(sizeof(BtCursor)); + } -/* -** Initialize memory that will be converted into a BtCursor object. -** -** The simple approach here would be to memset() the entire object -** to zero. But it turns out that the apPage[] and aiIdx[] arrays -** do not need to be zeroed and they are large, so we can save a lot -** of run-time by skipping the initialization of those elements. -*/ -static void sqlite3BtreeCursorZero( BtCursor p ) -{ - p.Clear(); // memset( p, 0, offsetof( BtCursor, iPage ) ); -} + /* + ** Initialize memory that will be converted into a BtCursor object. + ** + ** The simple approach here would be to memset() the entire object + ** to zero. But it turns out that the apPage[] and aiIdx[] arrays + ** do not need to be zeroed and they are large, so we can save a lot + ** of run-time by skipping the initialization of those elements. + */ + static void sqlite3BtreeCursorZero(BtCursor p) { + p.Clear(); // memset( p, 0, offsetof( BtCursor, iPage ) ); + } -/* -** Set the cached rowid value of every cursor in the same database file -** as pCur and having the same root page number as pCur. The value is -** set to iRowid. -** -** Only positive rowid values are considered valid for this cache. -** The cache is initialized to zero, indicating an invalid cache. -** A btree will work fine with zero or negative rowids. We just cannot -** cache zero or negative rowids, which means tables that use zero or -** negative rowids might run a little slower. But in practice, zero -** or negative rowids are very uncommon so this should not be a problem. -*/ -static void sqlite3BtreeSetCachedRowid( BtCursor pCur, sqlite3_int64 iRowid ) -{ - BtCursor p; - for ( p = pCur.pBt.pCursor; p != null; p = p.pNext ) - { - if ( p.pgnoRoot == pCur.pgnoRoot ) - p.cachedRowid = iRowid; - } - Debug.Assert( pCur.cachedRowid == iRowid ); -} + /* + ** Set the cached rowid value of every cursor in the same database file + ** as pCur and having the same root page number as pCur. The value is + ** set to iRowid. + ** + ** Only positive rowid values are considered valid for this cache. + ** The cache is initialized to zero, indicating an invalid cache. + ** A btree will work fine with zero or negative rowids. We just cannot + ** cache zero or negative rowids, which means tables that use zero or + ** negative rowids might run a little slower. But in practice, zero + ** or negative rowids are very uncommon so this should not be a problem. + */ + static void sqlite3BtreeSetCachedRowid(BtCursor pCur, sqlite3_int64 iRowid) { + BtCursor p; + for (p = pCur.pBt.pCursor; p != null; p = p.pNext) { + if (p.pgnoRoot == pCur.pgnoRoot) + p.cachedRowid = iRowid; + } + Debug.Assert(pCur.cachedRowid == iRowid); + } -/* -** Return the cached rowid for the given cursor. A negative or zero -** return value indicates that the rowid cache is invalid and should be -** ignored. If the rowid cache has never before been set, then a -** zero is returned. -*/ -static sqlite3_int64 sqlite3BtreeGetCachedRowid( BtCursor pCur ) -{ - return pCur.cachedRowid; -} + /* + ** Return the cached rowid for the given cursor. A negative or zero + ** return value indicates that the rowid cache is invalid and should be + ** ignored. If the rowid cache has never before been set, then a + ** zero is returned. + */ + static sqlite3_int64 sqlite3BtreeGetCachedRowid(BtCursor pCur) { + return pCur.cachedRowid; + } -/* -** Close a cursor. The read lock on the database file is released -** when the last cursor is closed. -*/ -static int sqlite3BtreeCloseCursor( BtCursor pCur ) -{ - Btree pBtree = pCur.pBtree; - if ( pBtree != null ) - { - int i; - BtShared pBt = pCur.pBt; - sqlite3BtreeEnter( pBtree ); - sqlite3BtreeClearCursor( pCur ); - if ( pCur.pPrev != null ) - { - pCur.pPrev.pNext = pCur.pNext; - } - else - { - pBt.pCursor = pCur.pNext; - } - if ( pCur.pNext != null ) - { - pCur.pNext.pPrev = pCur.pPrev; - } - for ( i = 0; i <= pCur.iPage; i++ ) - { - releasePage( pCur.apPage[i] ); - } - unlockBtreeIfUnused( pBt ); - invalidateOverflowCache( pCur ); - /* sqlite3_free(ref pCur); */ - sqlite3BtreeLeave( pBtree ); - } - return SQLITE_OK; -} + /* + ** Close a cursor. The read lock on the database file is released + ** when the last cursor is closed. + */ + static int sqlite3BtreeCloseCursor(BtCursor pCur) { + Btree pBtree = pCur.pBtree; + if (pBtree != null) { + int i; + BtShared pBt = pCur.pBt; + sqlite3BtreeEnter(pBtree); + sqlite3BtreeClearCursor(pCur); + if (pCur.pPrev != null) { + pCur.pPrev.pNext = pCur.pNext; + } else { + pBt.pCursor = pCur.pNext; + } + if (pCur.pNext != null) { + pCur.pNext.pPrev = pCur.pPrev; + } + for (i = 0; i <= pCur.iPage; i++) { + releasePage(pCur.apPage[i]); + } + unlockBtreeIfUnused(pBt); + invalidateOverflowCache(pCur); + /* sqlite3_free(ref pCur); */ + sqlite3BtreeLeave(pBtree); + } + return SQLITE_OK; + } -/* -** Make sure the BtCursor* given in the argument has a valid -** BtCursor.info structure. If it is not already valid, call -** btreeParseCell() to fill it in. -** -** BtCursor.info is a cache of the information in the current cell. -** Using this cache reduces the number of calls to btreeParseCell(). -** -** 2007-06-25: There is a bug in some versions of MSVC that cause the -** compiler to crash when getCellInfo() is implemented as a macro. -** But there is a measureable speed advantage to using the macro on gcc -** (when less compiler optimizations like -Os or -O0 are used and the -** compiler is not doing agressive inlining.) So we use a real function -** for MSVC and a macro for everything else. Ticket #2457. -*/ + /* + ** Make sure the BtCursor* given in the argument has a valid + ** BtCursor.info structure. If it is not already valid, call + ** btreeParseCell() to fill it in. + ** + ** BtCursor.info is a cache of the information in the current cell. + ** Using this cache reduces the number of calls to btreeParseCell(). + ** + ** 2007-06-25: There is a bug in some versions of MSVC that cause the + ** compiler to crash when getCellInfo() is implemented as a macro. + ** But there is a measureable speed advantage to using the macro on gcc + ** (when less compiler optimizations like -Os or -O0 are used and the + ** compiler is not doing agressive inlining.) So we use a real function + ** for MSVC and a macro for everything else. Ticket #2457. + */ #if !NDEBUG -static void assertCellInfo( BtCursor pCur ) -{ - CellInfo info; - int iPage = pCur.iPage; - info = new CellInfo();//memset(info, 0, sizeof(info)); - btreeParseCell( pCur.apPage[iPage], pCur.aiIdx[iPage], ref info ); - Debug.Assert( info.GetHashCode() == pCur.info.GetHashCode() || info.Equals( pCur.info ) );//memcmp(info, pCur.info, sizeof(info))==0 ); -} + static void assertCellInfo(BtCursor pCur) { + CellInfo info; + int iPage = pCur.iPage; + info = new CellInfo();//memset(info, 0, sizeof(info)); + btreeParseCell(pCur.apPage[iPage], pCur.aiIdx[iPage], ref info); + Debug.Assert(info.GetHashCode() == pCur.info.GetHashCode() || info.Equals(pCur.info));//memcmp(info, pCur.info, sizeof(info))==0 ); + } #else // #define assertCellInfo(x) static void assertCellInfo(BtCursor pCur) { } #endif #if _MSC_VER -/* Use a real function in MSVC to work around bugs in that compiler. */ -static void getCellInfo( BtCursor pCur ) -{ - if ( pCur.info.nSize == 0 ) - { - int iPage = pCur.iPage; - btreeParseCell( pCur.apPage[iPage], pCur.aiIdx[iPage], ref pCur.info ); - pCur.validNKey = true; - } - else - { - assertCellInfo( pCur ); - } -} + /* Use a real function in MSVC to work around bugs in that compiler. */ + static void getCellInfo(BtCursor pCur) { + if (pCur.info.nSize == 0) { + int iPage = pCur.iPage; + btreeParseCell(pCur.apPage[iPage], pCur.aiIdx[iPage], ref pCur.info); + pCur.validNKey = true; + } else { + assertCellInfo(pCur); + } + } #else //* if not _MSC_VER */ /* Use a macro in all other compilers so that the function is inlined */ //#define getCellInfo(pCur) \ @@ -4169,299 +3825,271 @@ static void getCellInfo( BtCursor pCur ) #endif //* _MSC_VER */ #if !NDEBUG //* The next routine used only within Debug.Assert() statements */ -/* -** Return true if the given BtCursor is valid. A valid cursor is one -** that is currently pointing to a row in a (non-empty) table. -** This is a verification routine is used only within Debug.Assert() statements. -*/ -static bool sqlite3BtreeCursorIsValid( BtCursor pCur ) -{ - return pCur != null && pCur.eState == CURSOR_VALID; -} + /* + ** Return true if the given BtCursor is valid. A valid cursor is one + ** that is currently pointing to a row in a (non-empty) table. + ** This is a verification routine is used only within Debug.Assert() statements. + */ + static bool sqlite3BtreeCursorIsValid(BtCursor pCur) { + return pCur != null && pCur.eState == CURSOR_VALID; + } #else static bool sqlite3BtreeCursorIsValid(BtCursor pCur) { return true; } #endif //* NDEBUG */ -/* -** Set pSize to the size of the buffer needed to hold the value of -** the key for the current entry. If the cursor is not pointing -** to a valid entry, pSize is set to 0. -** -** For a table with the INTKEY flag set, this routine returns the key -** itself, not the number of bytes in the key. -** -** The caller must position the cursor prior to invoking this routine. -** -** This routine cannot fail. It always returns SQLITE_OK. -*/ -static int sqlite3BtreeKeySize( BtCursor pCur, ref i64 pSize ) -{ - Debug.Assert( cursorHoldsMutex( pCur ) ); - Debug.Assert( pCur.eState == CURSOR_INVALID || pCur.eState == CURSOR_VALID ); - if ( pCur.eState != CURSOR_VALID ) - { - pSize = 0; - } - else - { - getCellInfo( pCur ); - pSize = pCur.info.nKey; - } - return SQLITE_OK; -} - -/* -** Set pSize to the number of bytes of data in the entry the -** cursor currently points to. -** -** The caller must guarantee that the cursor is pointing to a non-NULL -** valid entry. In other words, the calling procedure must guarantee -** that the cursor has Cursor.eState==CURSOR_VALID. -** -** Failure is not possible. This function always returns SQLITE_OK. -** It might just as well be a procedure (returning void) but we continue -** to return an integer result code for historical reasons. -*/ -static int sqlite3BtreeDataSize( BtCursor pCur, ref u32 pSize ) -{ - Debug.Assert( cursorHoldsMutex( pCur ) ); - Debug.Assert( pCur.eState == CURSOR_VALID ); - getCellInfo( pCur ); - pSize = pCur.info.nData; - return SQLITE_OK; -} + /* + ** Set pSize to the size of the buffer needed to hold the value of + ** the key for the current entry. If the cursor is not pointing + ** to a valid entry, pSize is set to 0. + ** + ** For a table with the INTKEY flag set, this routine returns the key + ** itself, not the number of bytes in the key. + ** + ** The caller must position the cursor prior to invoking this routine. + ** + ** This routine cannot fail. It always returns SQLITE_OK. + */ + static int sqlite3BtreeKeySize(BtCursor pCur, ref i64 pSize) { + Debug.Assert(cursorHoldsMutex(pCur)); + Debug.Assert(pCur.eState == CURSOR_INVALID || pCur.eState == CURSOR_VALID); + if (pCur.eState != CURSOR_VALID) { + pSize = 0; + } else { + getCellInfo(pCur); + pSize = pCur.info.nKey; + } + return SQLITE_OK; + } -/* -** Given the page number of an overflow page in the database (parameter -** ovfl), this function finds the page number of the next page in the -** linked list of overflow pages. If possible, it uses the auto-vacuum -** pointer-map data instead of reading the content of page ovfl to do so. -** -** If an error occurs an SQLite error code is returned. Otherwise: -** -** The page number of the next overflow page in the linked list is -** written to pPgnoNext. If page ovfl is the last page in its linked -** list, pPgnoNext is set to zero. -** -** If ppPage is not NULL, and a reference to the MemPage object corresponding -** to page number pOvfl was obtained, then ppPage is set to point to that -** reference. It is the responsibility of the caller to call releasePage() -** on ppPage to free the reference. In no reference was obtained (because -** the pointer-map was used to obtain the value for pPgnoNext), then -** ppPage is set to zero. -*/ -static int getOverflowPage( -BtShared pBt, /* The database file */ -Pgno ovfl, /* Current overflow page number */ -out MemPage ppPage, /* OUT: MemPage handle (may be NULL) */ -out Pgno pPgnoNext /* OUT: Next overflow page number */ -) -{ - Pgno next = 0; - MemPage pPage = null; - ppPage = null; - int rc = SQLITE_OK; + /* + ** Set pSize to the number of bytes of data in the entry the + ** cursor currently points to. + ** + ** The caller must guarantee that the cursor is pointing to a non-NULL + ** valid entry. In other words, the calling procedure must guarantee + ** that the cursor has Cursor.eState==CURSOR_VALID. + ** + ** Failure is not possible. This function always returns SQLITE_OK. + ** It might just as well be a procedure (returning void) but we continue + ** to return an integer result code for historical reasons. + */ + static int sqlite3BtreeDataSize(BtCursor pCur, ref u32 pSize) { + Debug.Assert(cursorHoldsMutex(pCur)); + Debug.Assert(pCur.eState == CURSOR_VALID); + getCellInfo(pCur); + pSize = pCur.info.nData; + return SQLITE_OK; + } - Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); - // Debug.Assert( pPgnoNext); + /* + ** Given the page number of an overflow page in the database (parameter + ** ovfl), this function finds the page number of the next page in the + ** linked list of overflow pages. If possible, it uses the auto-vacuum + ** pointer-map data instead of reading the content of page ovfl to do so. + ** + ** If an error occurs an SQLite error code is returned. Otherwise: + ** + ** The page number of the next overflow page in the linked list is + ** written to pPgnoNext. If page ovfl is the last page in its linked + ** list, pPgnoNext is set to zero. + ** + ** If ppPage is not NULL, and a reference to the MemPage object corresponding + ** to page number pOvfl was obtained, then ppPage is set to point to that + ** reference. It is the responsibility of the caller to call releasePage() + ** on ppPage to free the reference. In no reference was obtained (because + ** the pointer-map was used to obtain the value for pPgnoNext), then + ** ppPage is set to zero. + */ + static int getOverflowPage( + BtShared pBt, /* The database file */ + Pgno ovfl, /* Current overflow page number */ + out MemPage ppPage, /* OUT: MemPage handle (may be NULL) */ + out Pgno pPgnoNext /* OUT: Next overflow page number */ + ) { + Pgno next = 0; + MemPage pPage = null; + ppPage = null; + int rc = SQLITE_OK; + + Debug.Assert(sqlite3_mutex_held(pBt.mutex)); + // Debug.Assert( pPgnoNext); #if !SQLITE_OMIT_AUTOVACUUM - /* Try to find the next page in the overflow list using the -** autovacuum pointer-map pages. Guess that the next page in -** the overflow list is page number (ovfl+1). If that guess turns -** out to be wrong, fall back to loading the data of page -** number ovfl to determine the next page number. -*/ - if ( pBt.autoVacuum ) - { - Pgno pgno = 0; - Pgno iGuess = ovfl + 1; - u8 eType = 0; - - while ( PTRMAP_ISPAGE( pBt, iGuess ) || iGuess == PENDING_BYTE_PAGE( pBt ) ) - { - iGuess++; - } - - if ( iGuess <= btreePagecount( pBt ) ) - { - rc = ptrmapGet( pBt, iGuess, ref eType, ref pgno ); - if ( rc == SQLITE_OK && eType == PTRMAP_OVERFLOW2 && pgno == ovfl ) - { - next = iGuess; - rc = SQLITE_DONE; - } - } - } + /* Try to find the next page in the overflow list using the + ** autovacuum pointer-map pages. Guess that the next page in + ** the overflow list is page number (ovfl+1). If that guess turns + ** out to be wrong, fall back to loading the data of page + ** number ovfl to determine the next page number. + */ + if (pBt.autoVacuum) { + Pgno pgno = 0; + Pgno iGuess = ovfl + 1; + u8 eType = 0; + + while (PTRMAP_ISPAGE(pBt, iGuess) || iGuess == PENDING_BYTE_PAGE(pBt)) { + iGuess++; + } + + if (iGuess <= btreePagecount(pBt)) { + rc = ptrmapGet(pBt, iGuess, ref eType, ref pgno); + if (rc == SQLITE_OK && eType == PTRMAP_OVERFLOW2 && pgno == ovfl) { + next = iGuess; + rc = SQLITE_DONE; + } + } + } #endif - Debug.Assert( next == 0 || rc == SQLITE_DONE ); - if ( rc == SQLITE_OK ) - { - rc = btreeGetPage( pBt, ovfl, ref pPage, 0 ); - Debug.Assert( rc == SQLITE_OK || pPage == null ); - if ( rc == SQLITE_OK ) - { - next = sqlite3Get4byte( pPage.aData ); - } - } - - pPgnoNext = next; - if ( ppPage != null ) - { - ppPage = pPage; - } - else - { - releasePage( pPage ); - } - return ( rc == SQLITE_DONE ? SQLITE_OK : rc ); -} + Debug.Assert(next == 0 || rc == SQLITE_DONE); + if (rc == SQLITE_OK) { + rc = btreeGetPage(pBt, ovfl, ref pPage, 0); + Debug.Assert(rc == SQLITE_OK || pPage == null); + if (rc == SQLITE_OK) { + next = sqlite3Get4byte(pPage.aData); + } + } -/* -** Copy data from a buffer to a page, or from a page to a buffer. -** -** pPayload is a pointer to data stored on database page pDbPage. -** If argument eOp is false, then nByte bytes of data are copied -** from pPayload to the buffer pointed at by pBuf. If eOp is true, -** then sqlite3PagerWrite() is called on pDbPage and nByte bytes -** of data are copied from the buffer pBuf to pPayload. -** -** SQLITE_OK is returned on success, otherwise an error code. -*/ -static int copyPayload( -byte[] pPayload, /* Pointer to page data */ -u32 payloadOffset, /* Offset into page data */ -byte[] pBuf, /* Pointer to buffer */ -u32 pBufOffset, /* Offset into buffer */ -u32 nByte, /* Number of bytes to copy */ -int eOp, /* 0 . copy from page, 1 . copy to page */ -DbPage pDbPage /* Page containing pPayload */ -) -{ - if ( eOp != 0 ) - { - /* Copy data from buffer to page (a write operation) */ - int rc = sqlite3PagerWrite( pDbPage ); - if ( rc != SQLITE_OK ) - { - return rc; - } - Buffer.BlockCopy( pBuf, (int)pBufOffset, pPayload, (int)payloadOffset, (int)nByte );// memcpy( pPayload, pBuf, nByte ); - } - else - { - /* Copy data from page to buffer (a read operation) */ - Buffer.BlockCopy( pPayload, (int)payloadOffset, pBuf, (int)pBufOffset, (int)nByte );//memcpy(pBuf, pPayload, nByte); - } - return SQLITE_OK; -} -//static int copyPayload( -// byte[] pPayload, /* Pointer to page data */ -// byte[] pBuf, /* Pointer to buffer */ -// int nByte, /* Number of bytes to copy */ -// int eOp, /* 0 -> copy from page, 1 -> copy to page */ -// DbPage pDbPage /* Page containing pPayload */ -//){ -// if( eOp!=0 ){ -// /* Copy data from buffer to page (a write operation) */ -// int rc = sqlite3PagerWrite(pDbPage); -// if( rc!=SQLITE_OK ){ -// return rc; -// } -// memcpy(pPayload, pBuf, nByte); -// }else{ -// /* Copy data from page to buffer (a read operation) */ -// memcpy(pBuf, pPayload, nByte); -// } -// return SQLITE_OK; -//} + pPgnoNext = next; + if (ppPage != null) { + ppPage = pPage; + } else { + releasePage(pPage); + } + return (rc == SQLITE_DONE ? SQLITE_OK : rc); + } -/* -** This function is used to read or overwrite payload information -** for the entry that the pCur cursor is pointing to. If the eOp -** parameter is 0, this is a read operation (data copied into -** buffer pBuf). If it is non-zero, a write (data copied from -** buffer pBuf). -** -** A total of "amt" bytes are read or written beginning at "offset". -** Data is read to or from the buffer pBuf. -** -** The content being read or written might appear on the main page -** or be scattered out on multiple overflow pages. -** -** If the BtCursor.isIncrblobHandle flag is set, and the current -** cursor entry uses one or more overflow pages, this function -** allocates space for and lazily popluates the overflow page-list -** cache array (BtCursor.aOverflow). Subsequent calls use this -** cache to make seeking to the supplied offset more efficient. -** -** Once an overflow page-list cache has been allocated, it may be -** invalidated if some other cursor writes to the same table, or if -** the cursor is moved to a different row. Additionally, in auto-vacuum -** mode, the following events may invalidate an overflow page-list cache. -** -** * An incremental vacuum, -** * A commit in auto_vacuum="full" mode, -** * Creating a table (may require moving an overflow page). -*/ -static int accessPayload( -BtCursor pCur, /* Cursor pointing to entry to read from */ -u32 offset, /* Begin reading this far into payload */ -u32 amt, /* Read this many bytes */ -byte[] pBuf, /* Write the bytes into this buffer */ -int eOp /* zero to read. non-zero to write. */ -) -{ - u32 pBufOffset = 0; - byte[] aPayload; - int rc = SQLITE_OK; - u32 nKey; - int iIdx = 0; - MemPage pPage = pCur.apPage[pCur.iPage]; /* Btree page of current entry */ - BtShared pBt = pCur.pBt; /* Btree this cursor belongs to */ - - Debug.Assert( pPage != null ); - Debug.Assert( pCur.eState == CURSOR_VALID ); - Debug.Assert( pCur.aiIdx[pCur.iPage] < pPage.nCell ); - Debug.Assert( cursorHoldsMutex( pCur ) ); - - getCellInfo( pCur ); - aPayload = pCur.info.pCell; //pCur.info.pCell + pCur.info.nHeader; - nKey = (u32)( pPage.intKey != 0 ? 0 : (int)pCur.info.nKey ); - - if ( NEVER( offset + amt > nKey + pCur.info.nData ) - || pCur.info.nLocal > pBt.usableSize//&aPayload[pCur.info.nLocal] > &pPage.aData[pBt.usableSize] - ) - { - /* Trying to read or write past the end of the data is an error */ - return SQLITE_CORRUPT_BKPT(); - } - - /* Check if data must be read/written to/from the btree page itself. */ - if ( offset < pCur.info.nLocal ) - { - int a = (int)amt; - if ( a + offset > pCur.info.nLocal ) - { - a = (int)( pCur.info.nLocal - offset ); - } - rc = copyPayload( aPayload, (u32)( offset + pCur.info.iCell + pCur.info.nHeader ), pBuf, pBufOffset, (u32)a, eOp, pPage.pDbPage ); - offset = 0; - pBufOffset += (u32)a; //pBuf += a; - amt -= (u32)a; - } - else - { - offset -= pCur.info.nLocal; - } - - if ( rc == SQLITE_OK && amt > 0 ) - { - u32 ovflSize = (u32)( pBt.usableSize - 4 ); /* Bytes content per ovfl page */ - Pgno nextPage; - - nextPage = sqlite3Get4byte( aPayload, pCur.info.nLocal + pCur.info.iCell + pCur.info.nHeader ); + /* + ** Copy data from a buffer to a page, or from a page to a buffer. + ** + ** pPayload is a pointer to data stored on database page pDbPage. + ** If argument eOp is false, then nByte bytes of data are copied + ** from pPayload to the buffer pointed at by pBuf. If eOp is true, + ** then sqlite3PagerWrite() is called on pDbPage and nByte bytes + ** of data are copied from the buffer pBuf to pPayload. + ** + ** SQLITE_OK is returned on success, otherwise an error code. + */ + static int copyPayload( + byte[] pPayload, /* Pointer to page data */ + u32 payloadOffset, /* Offset into page data */ + byte[] pBuf, /* Pointer to buffer */ + u32 pBufOffset, /* Offset into buffer */ + u32 nByte, /* Number of bytes to copy */ + int eOp, /* 0 . copy from page, 1 . copy to page */ + DbPage pDbPage /* Page containing pPayload */ + ) { + if (eOp != 0) { + /* Copy data from buffer to page (a write operation) */ + int rc = sqlite3PagerWrite(pDbPage); + if (rc != SQLITE_OK) { + return rc; + } + Buffer.BlockCopy(pBuf, (int)pBufOffset, pPayload, (int)payloadOffset, (int)nByte);// memcpy( pPayload, pBuf, nByte ); + } else { + /* Copy data from page to buffer (a read operation) */ + Buffer.BlockCopy(pPayload, (int)payloadOffset, pBuf, (int)pBufOffset, (int)nByte);//memcpy(pBuf, pPayload, nByte); + } + return SQLITE_OK; + } + //static int copyPayload( + // byte[] pPayload, /* Pointer to page data */ + // byte[] pBuf, /* Pointer to buffer */ + // int nByte, /* Number of bytes to copy */ + // int eOp, /* 0 -> copy from page, 1 -> copy to page */ + // DbPage pDbPage /* Page containing pPayload */ + //){ + // if( eOp!=0 ){ + // /* Copy data from buffer to page (a write operation) */ + // int rc = sqlite3PagerWrite(pDbPage); + // if( rc!=SQLITE_OK ){ + // return rc; + // } + // memcpy(pPayload, pBuf, nByte); + // }else{ + // /* Copy data from page to buffer (a read operation) */ + // memcpy(pBuf, pPayload, nByte); + // } + // return SQLITE_OK; + //} + + /* + ** This function is used to read or overwrite payload information + ** for the entry that the pCur cursor is pointing to. If the eOp + ** parameter is 0, this is a read operation (data copied into + ** buffer pBuf). If it is non-zero, a write (data copied from + ** buffer pBuf). + ** + ** A total of "amt" bytes are read or written beginning at "offset". + ** Data is read to or from the buffer pBuf. + ** + ** The content being read or written might appear on the main page + ** or be scattered out on multiple overflow pages. + ** + ** If the BtCursor.isIncrblobHandle flag is set, and the current + ** cursor entry uses one or more overflow pages, this function + ** allocates space for and lazily popluates the overflow page-list + ** cache array (BtCursor.aOverflow). Subsequent calls use this + ** cache to make seeking to the supplied offset more efficient. + ** + ** Once an overflow page-list cache has been allocated, it may be + ** invalidated if some other cursor writes to the same table, or if + ** the cursor is moved to a different row. Additionally, in auto-vacuum + ** mode, the following events may invalidate an overflow page-list cache. + ** + ** * An incremental vacuum, + ** * A commit in auto_vacuum="full" mode, + ** * Creating a table (may require moving an overflow page). + */ + static int accessPayload( + BtCursor pCur, /* Cursor pointing to entry to read from */ + u32 offset, /* Begin reading this far into payload */ + u32 amt, /* Read this many bytes */ + byte[] pBuf, /* Write the bytes into this buffer */ + int eOp /* zero to read. non-zero to write. */ + ) { + u32 pBufOffset = 0; + byte[] aPayload; + int rc = SQLITE_OK; + u32 nKey; + int iIdx = 0; + MemPage pPage = pCur.apPage[pCur.iPage]; /* Btree page of current entry */ + BtShared pBt = pCur.pBt; /* Btree this cursor belongs to */ + + Debug.Assert(pPage != null); + Debug.Assert(pCur.eState == CURSOR_VALID); + Debug.Assert(pCur.aiIdx[pCur.iPage] < pPage.nCell); + Debug.Assert(cursorHoldsMutex(pCur)); + + getCellInfo(pCur); + aPayload = pCur.info.pCell; //pCur.info.pCell + pCur.info.nHeader; + nKey = (u32)(pPage.intKey != 0 ? 0 : (int)pCur.info.nKey); + + if (NEVER(offset + amt > nKey + pCur.info.nData) + || pCur.info.nLocal > pBt.usableSize//&aPayload[pCur.info.nLocal] > &pPage.aData[pBt.usableSize] + ) { + /* Trying to read or write past the end of the data is an error */ + return SQLITE_CORRUPT_BKPT(); + } + + /* Check if data must be read/written to/from the btree page itself. */ + if (offset < pCur.info.nLocal) { + int a = (int)amt; + if (a + offset > pCur.info.nLocal) { + a = (int)(pCur.info.nLocal - offset); + } + rc = copyPayload(aPayload, (u32)(offset + pCur.info.iCell + pCur.info.nHeader), pBuf, pBufOffset, (u32)a, eOp, pPage.pDbPage); + offset = 0; + pBufOffset += (u32)a; //pBuf += a; + amt -= (u32)a; + } else { + offset -= pCur.info.nLocal; + } + + if (rc == SQLITE_OK && amt > 0) { + u32 ovflSize = (u32)(pBt.usableSize - 4); /* Bytes content per ovfl page */ + Pgno nextPage; + + nextPage = sqlite3Get4byte(aPayload, pCur.info.nLocal + pCur.info.iCell + pCur.info.nHeader); #if !SQLITE_OMIT_INCRBLOB /* If the isIncrblobHandle flag is set and the BtCursor.aOverflow[] @@ -4492,8 +4120,7 @@ int eOp /* zero to read. non-zero to write. */ } #endif - for ( ; rc == SQLITE_OK && amt > 0 && nextPage != 0; iIdx++ ) - { + for (; rc == SQLITE_OK && amt > 0 && nextPage != 0; iIdx++) { #if !SQLITE_OMIT_INCRBLOB /* If required, populate the overflow page-list cache. */ @@ -4503,89 +4130,81 @@ int eOp /* zero to read. non-zero to write. */ } #endif - MemPage MemPageDummy = null; - if ( offset >= ovflSize ) - { - /* The only reason to read this page is to obtain the page - ** number for the next page in the overflow chain. The page - ** data is not required. So first try to lookup the overflow - ** page-list cache, if any, then fall back to the getOverflowPage() - ** function. - */ + MemPage MemPageDummy = null; + if (offset >= ovflSize) { + /* The only reason to read this page is to obtain the page + ** number for the next page in the overflow chain. The page + ** data is not required. So first try to lookup the overflow + ** page-list cache, if any, then fall back to the getOverflowPage() + ** function. + */ #if !SQLITE_OMIT_INCRBLOB if( pCur.aOverflow && pCur.aOverflow[iIdx+1] ){ nextPage = pCur.aOverflow[iIdx+1]; } else #endif - rc = getOverflowPage( pBt, nextPage, out MemPageDummy, out nextPage ); - offset -= ovflSize; - } - else - { - /* Need to read this page properly. It contains some of the - ** range of data that is being read (eOp==null) or written (eOp!=null). - */ - PgHdr pDbPage = new PgHdr(); - int a = (int)amt; - rc = sqlite3PagerGet( pBt.pPager, nextPage, ref pDbPage ); - if ( rc == SQLITE_OK ) - { - aPayload = sqlite3PagerGetData( pDbPage ); - nextPage = sqlite3Get4byte( aPayload ); - if ( a + offset > ovflSize ) - { - a = (int)( ovflSize - offset ); - } - rc = copyPayload( aPayload, offset + 4, pBuf, pBufOffset, (u32)a, eOp, pDbPage ); - sqlite3PagerUnref( pDbPage ); - offset = 0; - amt -= (u32)a; - pBufOffset += (u32)a;//pBuf += a; - } - } - } - } + rc = getOverflowPage(pBt, nextPage, out MemPageDummy, out nextPage); + offset -= ovflSize; + } else { + /* Need to read this page properly. It contains some of the + ** range of data that is being read (eOp==null) or written (eOp!=null). + */ + PgHdr pDbPage = new PgHdr(); + int a = (int)amt; + rc = sqlite3PagerGet(pBt.pPager, nextPage, ref pDbPage); + if (rc == SQLITE_OK) { + aPayload = sqlite3PagerGetData(pDbPage); + nextPage = sqlite3Get4byte(aPayload); + if (a + offset > ovflSize) { + a = (int)(ovflSize - offset); + } + rc = copyPayload(aPayload, offset + 4, pBuf, pBufOffset, (u32)a, eOp, pDbPage); + sqlite3PagerUnref(pDbPage); + offset = 0; + amt -= (u32)a; + pBufOffset += (u32)a;//pBuf += a; + } + } + } + } - if ( rc == SQLITE_OK && amt > 0 ) - { - return SQLITE_CORRUPT_BKPT(); - } - return rc; -} + if (rc == SQLITE_OK && amt > 0) { + return SQLITE_CORRUPT_BKPT(); + } + return rc; + } -/* -** Read part of the key associated with cursor pCur. Exactly -** "amt" bytes will be transfered into pBuf[]. The transfer -** begins at "offset". -** -** The caller must ensure that pCur is pointing to a valid row -** in the table. -** -** Return SQLITE_OK on success or an error code if anything goes -** wrong. An error is returned if "offset+amt" is larger than -** the available payload. -*/ -static int sqlite3BtreeKey( BtCursor pCur, u32 offset, u32 amt, byte[] pBuf ) -{ - Debug.Assert( cursorHoldsMutex( pCur ) ); - Debug.Assert( pCur.eState == CURSOR_VALID ); - Debug.Assert( pCur.iPage >= 0 && pCur.apPage[pCur.iPage] != null ); - Debug.Assert( pCur.aiIdx[pCur.iPage] < pCur.apPage[pCur.iPage].nCell ); - return accessPayload( pCur, offset, amt, pBuf, 0 ); -} + /* + ** Read part of the key associated with cursor pCur. Exactly + ** "amt" bytes will be transfered into pBuf[]. The transfer + ** begins at "offset". + ** + ** The caller must ensure that pCur is pointing to a valid row + ** in the table. + ** + ** Return SQLITE_OK on success or an error code if anything goes + ** wrong. An error is returned if "offset+amt" is larger than + ** the available payload. + */ + static int sqlite3BtreeKey(BtCursor pCur, u32 offset, u32 amt, byte[] pBuf) { + Debug.Assert(cursorHoldsMutex(pCur)); + Debug.Assert(pCur.eState == CURSOR_VALID); + Debug.Assert(pCur.iPage >= 0 && pCur.apPage[pCur.iPage] != null); + Debug.Assert(pCur.aiIdx[pCur.iPage] < pCur.apPage[pCur.iPage].nCell); + return accessPayload(pCur, offset, amt, pBuf, 0); + } -/* -** Read part of the data associated with cursor pCur. Exactly -** "amt" bytes will be transfered into pBuf[]. The transfer -** begins at "offset". -** -** Return SQLITE_OK on success or an error code if anything goes -** wrong. An error is returned if "offset+amt" is larger than -** the available payload. -*/ -static int sqlite3BtreeData( BtCursor pCur, u32 offset, u32 amt, byte[] pBuf ) -{ - int rc; + /* + ** Read part of the data associated with cursor pCur. Exactly + ** "amt" bytes will be transfered into pBuf[]. The transfer + ** begins at "offset". + ** + ** Return SQLITE_OK on success or an error code if anything goes + ** wrong. An error is returned if "offset+amt" is larger than + ** the available payload. + */ + static int sqlite3BtreeData(BtCursor pCur, u32 offset, u32 amt, byte[] pBuf) { + int rc; #if !SQLITE_OMIT_INCRBLOB if ( pCur.eState==CURSOR_INVALID ){ @@ -4593,2100 +4212,1861 @@ static int sqlite3BtreeData( BtCursor pCur, u32 offset, u32 amt, byte[] pBuf ) } #endif - Debug.Assert( cursorHoldsMutex( pCur ) ); - rc = restoreCursorPosition( pCur ); - if ( rc == SQLITE_OK ) - { - Debug.Assert( pCur.eState == CURSOR_VALID ); - Debug.Assert( pCur.iPage >= 0 && pCur.apPage[pCur.iPage] != null ); - Debug.Assert( pCur.aiIdx[pCur.iPage] < pCur.apPage[pCur.iPage].nCell ); - rc = accessPayload( pCur, offset, amt, pBuf, 0 ); - } - return rc; -} + Debug.Assert(cursorHoldsMutex(pCur)); + rc = restoreCursorPosition(pCur); + if (rc == SQLITE_OK) { + Debug.Assert(pCur.eState == CURSOR_VALID); + Debug.Assert(pCur.iPage >= 0 && pCur.apPage[pCur.iPage] != null); + Debug.Assert(pCur.aiIdx[pCur.iPage] < pCur.apPage[pCur.iPage].nCell); + rc = accessPayload(pCur, offset, amt, pBuf, 0); + } + return rc; + } -/* -** Return a pointer to payload information from the entry that the -** pCur cursor is pointing to. The pointer is to the beginning of -** the key if skipKey==null and it points to the beginning of data if -** skipKey==1. The number of bytes of available key/data is written -** into pAmt. If pAmt==null, then the value returned will not be -** a valid pointer. -** -** This routine is an optimization. It is common for the entire key -** and data to fit on the local page and for there to be no overflow -** pages. When that is so, this routine can be used to access the -** key and data without making a copy. If the key and/or data spills -** onto overflow pages, then accessPayload() must be used to reassemble -** the key/data and copy it into a preallocated buffer. -** -** The pointer returned by this routine looks directly into the cached -** page of the database. The data might change or move the next time -** any btree routine is called. -*/ -static byte[] fetchPayload( -BtCursor pCur, /* Cursor pointing to entry to read from */ -ref int pAmt, /* Write the number of available bytes here */ -ref int outOffset, /* Offset into Buffer */ -bool skipKey /* read beginning at data if this is true */ -) -{ - byte[] aPayload; - MemPage pPage; - u32 nKey; - u32 nLocal; - - Debug.Assert( pCur != null && pCur.iPage >= 0 && pCur.apPage[pCur.iPage] != null ); - Debug.Assert( pCur.eState == CURSOR_VALID ); - Debug.Assert( cursorHoldsMutex( pCur ) ); - outOffset = -1; - pPage = pCur.apPage[pCur.iPage]; - Debug.Assert( pCur.aiIdx[pCur.iPage] < pPage.nCell ); - if ( NEVER( pCur.info.nSize == 0 ) ) - { - btreeParseCell( pCur.apPage[pCur.iPage], pCur.aiIdx[pCur.iPage], - ref pCur.info ); - } - //aPayload = pCur.info.pCell; - //aPayload += pCur.info.nHeader; - aPayload = sqlite3Malloc( pCur.info.nSize - pCur.info.nHeader ); - if ( pPage.intKey != 0 ) - { - nKey = 0; - } - else - { - nKey = (u32)pCur.info.nKey; - } - if ( skipKey ) - { - //aPayload += nKey; - outOffset = (int)( pCur.info.iCell + pCur.info.nHeader + nKey ); - Buffer.BlockCopy( pCur.info.pCell, outOffset, aPayload, 0, (int)( pCur.info.nSize - pCur.info.nHeader - nKey ) ); - nLocal = pCur.info.nLocal - nKey; - } - else - { - outOffset = (int)( pCur.info.iCell + pCur.info.nHeader ); - Buffer.BlockCopy( pCur.info.pCell, outOffset, aPayload, 0, pCur.info.nSize - pCur.info.nHeader ); - nLocal = pCur.info.nLocal; - Debug.Assert( nLocal <= nKey ); - } - pAmt = (int)nLocal; - return aPayload; -} + /* + ** Return a pointer to payload information from the entry that the + ** pCur cursor is pointing to. The pointer is to the beginning of + ** the key if skipKey==null and it points to the beginning of data if + ** skipKey==1. The number of bytes of available key/data is written + ** into pAmt. If pAmt==null, then the value returned will not be + ** a valid pointer. + ** + ** This routine is an optimization. It is common for the entire key + ** and data to fit on the local page and for there to be no overflow + ** pages. When that is so, this routine can be used to access the + ** key and data without making a copy. If the key and/or data spills + ** onto overflow pages, then accessPayload() must be used to reassemble + ** the key/data and copy it into a preallocated buffer. + ** + ** The pointer returned by this routine looks directly into the cached + ** page of the database. The data might change or move the next time + ** any btree routine is called. + */ + static byte[] fetchPayload( + BtCursor pCur, /* Cursor pointing to entry to read from */ + ref int pAmt, /* Write the number of available bytes here */ + ref int outOffset, /* Offset into Buffer */ + bool skipKey /* read beginning at data if this is true */ + ) { + byte[] aPayload; + MemPage pPage; + u32 nKey; + u32 nLocal; + + Debug.Assert(pCur != null && pCur.iPage >= 0 && pCur.apPage[pCur.iPage] != null); + Debug.Assert(pCur.eState == CURSOR_VALID); + Debug.Assert(cursorHoldsMutex(pCur)); + outOffset = -1; + pPage = pCur.apPage[pCur.iPage]; + Debug.Assert(pCur.aiIdx[pCur.iPage] < pPage.nCell); + if (NEVER(pCur.info.nSize == 0)) { + btreeParseCell(pCur.apPage[pCur.iPage], pCur.aiIdx[pCur.iPage], + ref pCur.info); + } + //aPayload = pCur.info.pCell; + //aPayload += pCur.info.nHeader; + aPayload = sqlite3Malloc(pCur.info.nSize - pCur.info.nHeader); + if (pPage.intKey != 0) { + nKey = 0; + } else { + nKey = (u32)pCur.info.nKey; + } + if (skipKey) { + //aPayload += nKey; + outOffset = (int)(pCur.info.iCell + pCur.info.nHeader + nKey); + Buffer.BlockCopy(pCur.info.pCell, outOffset, aPayload, 0, (int)(pCur.info.nSize - pCur.info.nHeader - nKey)); + nLocal = pCur.info.nLocal - nKey; + } else { + outOffset = (int)(pCur.info.iCell + pCur.info.nHeader); + Buffer.BlockCopy(pCur.info.pCell, outOffset, aPayload, 0, pCur.info.nSize - pCur.info.nHeader); + nLocal = pCur.info.nLocal; + Debug.Assert(nLocal <= nKey); + } + pAmt = (int)nLocal; + return aPayload; + } -/* -** For the entry that cursor pCur is point to, return as -** many bytes of the key or data as are available on the local -** b-tree page. Write the number of available bytes into pAmt. -** -** The pointer returned is ephemeral. The key/data may move -** or be destroyed on the next call to any Btree routine, -** including calls from other threads against the same cache. -** Hence, a mutex on the BtShared should be held prior to calling -** this routine. -** -** These routines is used to get quick access to key and data -** in the common case where no overflow pages are used. -*/ -static byte[] sqlite3BtreeKeyFetch( BtCursor pCur, ref int pAmt, ref int outOffset ) -{ - byte[] p = null; - Debug.Assert( sqlite3_mutex_held( pCur.pBtree.db.mutex ) ); - Debug.Assert( cursorHoldsMutex( pCur ) ); - if ( ALWAYS( pCur.eState == CURSOR_VALID ) ) - { - p = fetchPayload( pCur, ref pAmt, ref outOffset, false ); - } - return p; -} -static byte[] sqlite3BtreeDataFetch( BtCursor pCur, ref int pAmt, ref int outOffset ) -{ - byte[] p = null; - Debug.Assert( sqlite3_mutex_held( pCur.pBtree.db.mutex ) ); - Debug.Assert( cursorHoldsMutex( pCur ) ); - if ( ALWAYS( pCur.eState == CURSOR_VALID ) ) - { - p = fetchPayload( pCur, ref pAmt, ref outOffset, true ); - } - return p; -} + /* + ** For the entry that cursor pCur is point to, return as + ** many bytes of the key or data as are available on the local + ** b-tree page. Write the number of available bytes into pAmt. + ** + ** The pointer returned is ephemeral. The key/data may move + ** or be destroyed on the next call to any Btree routine, + ** including calls from other threads against the same cache. + ** Hence, a mutex on the BtShared should be held prior to calling + ** this routine. + ** + ** These routines is used to get quick access to key and data + ** in the common case where no overflow pages are used. + */ + static byte[] sqlite3BtreeKeyFetch(BtCursor pCur, ref int pAmt, ref int outOffset) { + byte[] p = null; + Debug.Assert(sqlite3_mutex_held(pCur.pBtree.db.mutex)); + Debug.Assert(cursorHoldsMutex(pCur)); + if (ALWAYS(pCur.eState == CURSOR_VALID)) { + p = fetchPayload(pCur, ref pAmt, ref outOffset, false); + } + return p; + } + static byte[] sqlite3BtreeDataFetch(BtCursor pCur, ref int pAmt, ref int outOffset) { + byte[] p = null; + Debug.Assert(sqlite3_mutex_held(pCur.pBtree.db.mutex)); + Debug.Assert(cursorHoldsMutex(pCur)); + if (ALWAYS(pCur.eState == CURSOR_VALID)) { + p = fetchPayload(pCur, ref pAmt, ref outOffset, true); + } + return p; + } -/* -** Move the cursor down to a new child page. The newPgno argument is the -** page number of the child page to move to. -** -** This function returns SQLITE_CORRUPT if the page-header flags field of -** the new child page does not match the flags field of the parent (i.e. -** if an intkey page appears to be the parent of a non-intkey page, or -** vice-versa). -*/ -static int moveToChild( BtCursor pCur, u32 newPgno ) -{ - int rc; - int i = pCur.iPage; - MemPage pNewPage = new MemPage(); - BtShared pBt = pCur.pBt; - - Debug.Assert( cursorHoldsMutex( pCur ) ); - Debug.Assert( pCur.eState == CURSOR_VALID ); - Debug.Assert( pCur.iPage < BTCURSOR_MAX_DEPTH ); - if ( pCur.iPage >= ( BTCURSOR_MAX_DEPTH - 1 ) ) - { - return SQLITE_CORRUPT_BKPT(); - } - rc = getAndInitPage( pBt, newPgno, ref pNewPage ); - if ( rc != 0 ) - return rc; - pCur.apPage[i + 1] = pNewPage; - pCur.aiIdx[i + 1] = 0; - pCur.iPage++; - - pCur.info.nSize = 0; - pCur.validNKey = false; - if ( pNewPage.nCell < 1 || pNewPage.intKey != pCur.apPage[i].intKey ) - { - return SQLITE_CORRUPT_BKPT(); - } - return SQLITE_OK; -} + /* + ** Move the cursor down to a new child page. The newPgno argument is the + ** page number of the child page to move to. + ** + ** This function returns SQLITE_CORRUPT if the page-header flags field of + ** the new child page does not match the flags field of the parent (i.e. + ** if an intkey page appears to be the parent of a non-intkey page, or + ** vice-versa). + */ + static int moveToChild(BtCursor pCur, u32 newPgno) { + int rc; + int i = pCur.iPage; + MemPage pNewPage = new MemPage(); + BtShared pBt = pCur.pBt; + + Debug.Assert(cursorHoldsMutex(pCur)); + Debug.Assert(pCur.eState == CURSOR_VALID); + Debug.Assert(pCur.iPage < BTCURSOR_MAX_DEPTH); + if (pCur.iPage >= (BTCURSOR_MAX_DEPTH - 1)) { + return SQLITE_CORRUPT_BKPT(); + } + rc = getAndInitPage(pBt, newPgno, ref pNewPage); + if (rc != 0) + return rc; + pCur.apPage[i + 1] = pNewPage; + pCur.aiIdx[i + 1] = 0; + pCur.iPage++; + + pCur.info.nSize = 0; + pCur.validNKey = false; + if (pNewPage.nCell < 1 || pNewPage.intKey != pCur.apPage[i].intKey) { + return SQLITE_CORRUPT_BKPT(); + } + return SQLITE_OK; + } #if !NDEBUG -/* -** Page pParent is an internal (non-leaf) tree page. This function -** asserts that page number iChild is the left-child if the iIdx'th -** cell in page pParent. Or, if iIdx is equal to the total number of -** cells in pParent, that page number iChild is the right-child of -** the page. -*/ -static void assertParentIndex( MemPage pParent, int iIdx, Pgno iChild ) -{ - Debug.Assert( iIdx <= pParent.nCell ); - if ( iIdx == pParent.nCell ) - { - Debug.Assert( sqlite3Get4byte( pParent.aData, pParent.hdrOffset + 8 ) == iChild ); - } - else - { - Debug.Assert( sqlite3Get4byte( pParent.aData, findCell( pParent, iIdx ) ) == iChild ); - } -} + /* + ** Page pParent is an internal (non-leaf) tree page. This function + ** asserts that page number iChild is the left-child if the iIdx'th + ** cell in page pParent. Or, if iIdx is equal to the total number of + ** cells in pParent, that page number iChild is the right-child of + ** the page. + */ + static void assertParentIndex(MemPage pParent, int iIdx, Pgno iChild) { + Debug.Assert(iIdx <= pParent.nCell); + if (iIdx == pParent.nCell) { + Debug.Assert(sqlite3Get4byte(pParent.aData, pParent.hdrOffset + 8) == iChild); + } else { + Debug.Assert(sqlite3Get4byte(pParent.aData, findCell(pParent, iIdx)) == iChild); + } + } #else //# define assertParentIndex(x,y,z) static void assertParentIndex(MemPage pParent, int iIdx, Pgno iChild) { } #endif -/* -** Move the cursor up to the parent page. -** -** pCur.idx is set to the cell index that contains the pointer -** to the page we are coming from. If we are coming from the -** right-most child page then pCur.idx is set to one more than -** the largest cell index. -*/ -static void moveToParent( BtCursor pCur ) -{ - Debug.Assert( cursorHoldsMutex( pCur ) ); - Debug.Assert( pCur.eState == CURSOR_VALID ); - Debug.Assert( pCur.iPage > 0 ); - Debug.Assert( pCur.apPage[pCur.iPage] != null ); - assertParentIndex( - pCur.apPage[pCur.iPage - 1], - pCur.aiIdx[pCur.iPage - 1], - pCur.apPage[pCur.iPage].pgno - ); - releasePage( pCur.apPage[pCur.iPage] ); - pCur.iPage--; - pCur.info.nSize = 0; - pCur.validNKey = false; -} + /* + ** Move the cursor up to the parent page. + ** + ** pCur.idx is set to the cell index that contains the pointer + ** to the page we are coming from. If we are coming from the + ** right-most child page then pCur.idx is set to one more than + ** the largest cell index. + */ + static void moveToParent(BtCursor pCur) { + Debug.Assert(cursorHoldsMutex(pCur)); + Debug.Assert(pCur.eState == CURSOR_VALID); + Debug.Assert(pCur.iPage > 0); + Debug.Assert(pCur.apPage[pCur.iPage] != null); + assertParentIndex( + pCur.apPage[pCur.iPage - 1], + pCur.aiIdx[pCur.iPage - 1], + pCur.apPage[pCur.iPage].pgno + ); + releasePage(pCur.apPage[pCur.iPage]); + pCur.iPage--; + pCur.info.nSize = 0; + pCur.validNKey = false; + } -/* -** Move the cursor to point to the root page of its b-tree structure. -** -** If the table has a virtual root page, then the cursor is moved to point -** to the virtual root page instead of the actual root page. A table has a -** virtual root page when the actual root page contains no cells and a -** single child page. This can only happen with the table rooted at page 1. -** -** If the b-tree structure is empty, the cursor state is set to -** CURSOR_INVALID. Otherwise, the cursor is set to point to the first -** cell located on the root (or virtual root) page and the cursor state -** is set to CURSOR_VALID. -** -** If this function returns successfully, it may be assumed that the -** page-header flags indicate that the [virtual] root-page is the expected -** kind of b-tree page (i.e. if when opening the cursor the caller did not -** specify a KeyInfo structure the flags byte is set to 0x05 or 0x0D, -** indicating a table b-tree, or if the caller did specify a KeyInfo -** structure the flags byte is set to 0x02 or 0x0A, indicating an index -** b-tree). -*/ -static int moveToRoot( BtCursor pCur ) -{ - MemPage pRoot; - int rc = SQLITE_OK; - Btree p = pCur.pBtree; - BtShared pBt = p.pBt; - - Debug.Assert( cursorHoldsMutex( pCur ) ); - Debug.Assert( CURSOR_INVALID < CURSOR_REQUIRESEEK ); - Debug.Assert( CURSOR_VALID < CURSOR_REQUIRESEEK ); - Debug.Assert( CURSOR_FAULT > CURSOR_REQUIRESEEK ); - if ( pCur.eState >= CURSOR_REQUIRESEEK ) - { - if ( pCur.eState == CURSOR_FAULT ) - { - Debug.Assert( pCur.skipNext != SQLITE_OK ); - return pCur.skipNext; - } - sqlite3BtreeClearCursor( pCur ); - } + /* + ** Move the cursor to point to the root page of its b-tree structure. + ** + ** If the table has a virtual root page, then the cursor is moved to point + ** to the virtual root page instead of the actual root page. A table has a + ** virtual root page when the actual root page contains no cells and a + ** single child page. This can only happen with the table rooted at page 1. + ** + ** If the b-tree structure is empty, the cursor state is set to + ** CURSOR_INVALID. Otherwise, the cursor is set to point to the first + ** cell located on the root (or virtual root) page and the cursor state + ** is set to CURSOR_VALID. + ** + ** If this function returns successfully, it may be assumed that the + ** page-header flags indicate that the [virtual] root-page is the expected + ** kind of b-tree page (i.e. if when opening the cursor the caller did not + ** specify a KeyInfo structure the flags byte is set to 0x05 or 0x0D, + ** indicating a table b-tree, or if the caller did specify a KeyInfo + ** structure the flags byte is set to 0x02 or 0x0A, indicating an index + ** b-tree). + */ + static int moveToRoot(BtCursor pCur) { + MemPage pRoot; + int rc = SQLITE_OK; + Btree p = pCur.pBtree; + BtShared pBt = p.pBt; + + Debug.Assert(cursorHoldsMutex(pCur)); + Debug.Assert(CURSOR_INVALID < CURSOR_REQUIRESEEK); + Debug.Assert(CURSOR_VALID < CURSOR_REQUIRESEEK); + Debug.Assert(CURSOR_FAULT > CURSOR_REQUIRESEEK); + if (pCur.eState >= CURSOR_REQUIRESEEK) { + if (pCur.eState == CURSOR_FAULT) { + Debug.Assert(pCur.skipNext != SQLITE_OK); + return pCur.skipNext; + } + sqlite3BtreeClearCursor(pCur); + } - if ( pCur.iPage >= 0 ) - { - int i; - for ( i = 1; i <= pCur.iPage; i++ ) - { - releasePage( pCur.apPage[i] ); - } - pCur.iPage = 0; - } - else - { - rc = getAndInitPage( pBt, pCur.pgnoRoot, ref pCur.apPage[0] ); - if ( rc != SQLITE_OK ) - { - pCur.eState = CURSOR_INVALID; - return rc; - } - pCur.iPage = 0; - - /* If pCur.pKeyInfo is not NULL, then the caller that opened this cursor - ** expected to open it on an index b-tree. Otherwise, if pKeyInfo is - ** NULL, the caller expects a table b-tree. If this is not the case, - ** return an SQLITE_CORRUPT error. */ - Debug.Assert( pCur.apPage[0].intKey == 1 || pCur.apPage[0].intKey == 0 ); - if ( ( pCur.pKeyInfo == null ) != ( pCur.apPage[0].intKey != 0 ) ) - { - return SQLITE_CORRUPT_BKPT(); - } - } - - /* Assert that the root page is of the correct type. This must be the - ** case as the call to this function that loaded the root-page (either - ** this call or a previous invocation) would have detected corruption - ** if the assumption were not true, and it is not possible for the flags - ** byte to have been modified while this cursor is holding a reference - ** to the page. */ - pRoot = pCur.apPage[0]; - Debug.Assert( pRoot.pgno == pCur.pgnoRoot ); - Debug.Assert( pRoot.isInit != 0 && ( pCur.pKeyInfo == null ) == ( pRoot.intKey != 0 ) ); - - pCur.aiIdx[0] = 0; - pCur.info.nSize = 0; - pCur.atLast = 0; - pCur.validNKey = false; - - if ( pRoot.nCell == 0 && 0 == pRoot.leaf ) - { - Pgno subpage; - if ( pRoot.pgno != 1 ) - return SQLITE_CORRUPT_BKPT(); - subpage = sqlite3Get4byte( pRoot.aData, pRoot.hdrOffset + 8 ); - pCur.eState = CURSOR_VALID; - rc = moveToChild( pCur, subpage ); - } - else - { - pCur.eState = ( ( pRoot.nCell > 0 ) ? CURSOR_VALID : CURSOR_INVALID ); - } - return rc; -} + if (pCur.iPage >= 0) { + int i; + for (i = 1; i <= pCur.iPage; i++) { + releasePage(pCur.apPage[i]); + } + pCur.iPage = 0; + } else { + rc = getAndInitPage(pBt, pCur.pgnoRoot, ref pCur.apPage[0]); + if (rc != SQLITE_OK) { + pCur.eState = CURSOR_INVALID; + return rc; + } + pCur.iPage = 0; + + /* If pCur.pKeyInfo is not NULL, then the caller that opened this cursor + ** expected to open it on an index b-tree. Otherwise, if pKeyInfo is + ** NULL, the caller expects a table b-tree. If this is not the case, + ** return an SQLITE_CORRUPT error. */ + Debug.Assert(pCur.apPage[0].intKey == 1 || pCur.apPage[0].intKey == 0); + if ((pCur.pKeyInfo == null) != (pCur.apPage[0].intKey != 0)) { + return SQLITE_CORRUPT_BKPT(); + } + } -/* -** Move the cursor down to the left-most leaf entry beneath the -** entry to which it is currently pointing. -** -** The left-most leaf is the one with the smallest key - the first -** in ascending order. -*/ -static int moveToLeftmost( BtCursor pCur ) -{ - Pgno pgno; - int rc = SQLITE_OK; - MemPage pPage; - - Debug.Assert( cursorHoldsMutex( pCur ) ); - Debug.Assert( pCur.eState == CURSOR_VALID ); - while ( rc == SQLITE_OK && 0 == ( pPage = pCur.apPage[pCur.iPage] ).leaf ) - { - Debug.Assert( pCur.aiIdx[pCur.iPage] < pPage.nCell ); - pgno = sqlite3Get4byte( pPage.aData, findCell( pPage, pCur.aiIdx[pCur.iPage] ) ); - rc = moveToChild( pCur, pgno ); - } - return rc; -} + /* Assert that the root page is of the correct type. This must be the + ** case as the call to this function that loaded the root-page (either + ** this call or a previous invocation) would have detected corruption + ** if the assumption were not true, and it is not possible for the flags + ** byte to have been modified while this cursor is holding a reference + ** to the page. */ + pRoot = pCur.apPage[0]; + Debug.Assert(pRoot.pgno == pCur.pgnoRoot); + Debug.Assert(pRoot.isInit != 0 && (pCur.pKeyInfo == null) == (pRoot.intKey != 0)); + + pCur.aiIdx[0] = 0; + pCur.info.nSize = 0; + pCur.atLast = 0; + pCur.validNKey = false; + + if (pRoot.nCell == 0 && 0 == pRoot.leaf) { + Pgno subpage; + if (pRoot.pgno != 1) + return SQLITE_CORRUPT_BKPT(); + subpage = sqlite3Get4byte(pRoot.aData, pRoot.hdrOffset + 8); + pCur.eState = CURSOR_VALID; + rc = moveToChild(pCur, subpage); + } else { + pCur.eState = ((pRoot.nCell > 0) ? CURSOR_VALID : CURSOR_INVALID); + } + return rc; + } -/* -** Move the cursor down to the right-most leaf entry beneath the -** page to which it is currently pointing. Notice the difference -** between moveToLeftmost() and moveToRightmost(). moveToLeftmost() -** finds the left-most entry beneath the *entry* whereas moveToRightmost() -** finds the right-most entry beneath the page*. -** -** The right-most entry is the one with the largest key - the last -** key in ascending order. -*/ -static int moveToRightmost( BtCursor pCur ) -{ - Pgno pgno; - int rc = SQLITE_OK; - MemPage pPage = null; - - Debug.Assert( cursorHoldsMutex( pCur ) ); - Debug.Assert( pCur.eState == CURSOR_VALID ); - while ( rc == SQLITE_OK && 0 == ( pPage = pCur.apPage[pCur.iPage] ).leaf ) - { - pgno = sqlite3Get4byte( pPage.aData, pPage.hdrOffset + 8 ); - pCur.aiIdx[pCur.iPage] = pPage.nCell; - rc = moveToChild( pCur, pgno ); - } - if ( rc == SQLITE_OK ) - { - pCur.aiIdx[pCur.iPage] = (u16)( pPage.nCell - 1 ); - pCur.info.nSize = 0; - pCur.validNKey = false; - } - return rc; -} + /* + ** Move the cursor down to the left-most leaf entry beneath the + ** entry to which it is currently pointing. + ** + ** The left-most leaf is the one with the smallest key - the first + ** in ascending order. + */ + static int moveToLeftmost(BtCursor pCur) { + Pgno pgno; + int rc = SQLITE_OK; + MemPage pPage; + + Debug.Assert(cursorHoldsMutex(pCur)); + Debug.Assert(pCur.eState == CURSOR_VALID); + while (rc == SQLITE_OK && 0 == (pPage = pCur.apPage[pCur.iPage]).leaf) { + Debug.Assert(pCur.aiIdx[pCur.iPage] < pPage.nCell); + pgno = sqlite3Get4byte(pPage.aData, findCell(pPage, pCur.aiIdx[pCur.iPage])); + rc = moveToChild(pCur, pgno); + } + return rc; + } -/* Move the cursor to the first entry in the table. Return SQLITE_OK -** on success. Set pRes to 0 if the cursor actually points to something -** or set pRes to 1 if the table is empty. -*/ -static int sqlite3BtreeFirst( BtCursor pCur, ref int pRes ) -{ - int rc; - - Debug.Assert( cursorHoldsMutex( pCur ) ); - Debug.Assert( sqlite3_mutex_held( pCur.pBtree.db.mutex ) ); - rc = moveToRoot( pCur ); - if ( rc == SQLITE_OK ) - { - if ( pCur.eState == CURSOR_INVALID ) - { - Debug.Assert( pCur.apPage[pCur.iPage].nCell == 0 ); - pRes = 1; - } - else - { - Debug.Assert( pCur.apPage[pCur.iPage].nCell > 0 ); - pRes = 0; - rc = moveToLeftmost( pCur ); - } - } - return rc; -} + /* + ** Move the cursor down to the right-most leaf entry beneath the + ** page to which it is currently pointing. Notice the difference + ** between moveToLeftmost() and moveToRightmost(). moveToLeftmost() + ** finds the left-most entry beneath the *entry* whereas moveToRightmost() + ** finds the right-most entry beneath the page*. + ** + ** The right-most entry is the one with the largest key - the last + ** key in ascending order. + */ + static int moveToRightmost(BtCursor pCur) { + Pgno pgno; + int rc = SQLITE_OK; + MemPage pPage = null; + + Debug.Assert(cursorHoldsMutex(pCur)); + Debug.Assert(pCur.eState == CURSOR_VALID); + while (rc == SQLITE_OK && 0 == (pPage = pCur.apPage[pCur.iPage]).leaf) { + pgno = sqlite3Get4byte(pPage.aData, pPage.hdrOffset + 8); + pCur.aiIdx[pCur.iPage] = pPage.nCell; + rc = moveToChild(pCur, pgno); + } + if (rc == SQLITE_OK) { + pCur.aiIdx[pCur.iPage] = (u16)(pPage.nCell - 1); + pCur.info.nSize = 0; + pCur.validNKey = false; + } + return rc; + } -/* Move the cursor to the last entry in the table. Return SQLITE_OK -** on success. Set pRes to 0 if the cursor actually points to something -** or set pRes to 1 if the table is empty. -*/ -static int sqlite3BtreeLast( BtCursor pCur, ref int pRes ) -{ - int rc; + /* Move the cursor to the first entry in the table. Return SQLITE_OK + ** on success. Set pRes to 0 if the cursor actually points to something + ** or set pRes to 1 if the table is empty. + */ + static int sqlite3BtreeFirst(BtCursor pCur, ref int pRes) { + int rc; + + Debug.Assert(cursorHoldsMutex(pCur)); + Debug.Assert(sqlite3_mutex_held(pCur.pBtree.db.mutex)); + rc = moveToRoot(pCur); + if (rc == SQLITE_OK) { + if (pCur.eState == CURSOR_INVALID) { + Debug.Assert(pCur.apPage[pCur.iPage].nCell == 0); + pRes = 1; + } else { + Debug.Assert(pCur.apPage[pCur.iPage].nCell > 0); + pRes = 0; + rc = moveToLeftmost(pCur); + } + } + return rc; + } - Debug.Assert( cursorHoldsMutex( pCur ) ); - Debug.Assert( sqlite3_mutex_held( pCur.pBtree.db.mutex ) ); + /* Move the cursor to the last entry in the table. Return SQLITE_OK + ** on success. Set pRes to 0 if the cursor actually points to something + ** or set pRes to 1 if the table is empty. + */ + static int sqlite3BtreeLast(BtCursor pCur, ref int pRes) { + int rc; + + Debug.Assert(cursorHoldsMutex(pCur)); + Debug.Assert(sqlite3_mutex_held(pCur.pBtree.db.mutex)); - /* If the cursor already points to the last entry, this is a no-op. */ - if ( CURSOR_VALID == pCur.eState && pCur.atLast != 0 ) - { + /* If the cursor already points to the last entry, this is a no-op. */ + if (CURSOR_VALID == pCur.eState && pCur.atLast != 0) { #if SQLITE_DEBUG - /* This block serves to Debug.Assert() that the cursor really does point -** to the last entry in the b-tree. */ - int ii; - for ( ii = 0; ii < pCur.iPage; ii++ ) - { - Debug.Assert( pCur.aiIdx[ii] == pCur.apPage[ii].nCell ); - } - Debug.Assert( pCur.aiIdx[pCur.iPage] == pCur.apPage[pCur.iPage].nCell - 1 ); - Debug.Assert( pCur.apPage[pCur.iPage].leaf != 0 ); + /* This block serves to Debug.Assert() that the cursor really does point + ** to the last entry in the b-tree. */ + int ii; + for (ii = 0; ii < pCur.iPage; ii++) { + Debug.Assert(pCur.aiIdx[ii] == pCur.apPage[ii].nCell); + } + Debug.Assert(pCur.aiIdx[pCur.iPage] == pCur.apPage[pCur.iPage].nCell - 1); + Debug.Assert(pCur.apPage[pCur.iPage].leaf != 0); #endif - return SQLITE_OK; - } + return SQLITE_OK; + } - rc = moveToRoot( pCur ); - if ( rc == SQLITE_OK ) - { - if ( CURSOR_INVALID == pCur.eState ) - { - Debug.Assert( pCur.apPage[pCur.iPage].nCell == 0 ); - pRes = 1; - } - else - { - Debug.Assert( pCur.eState == CURSOR_VALID ); - pRes = 0; - rc = moveToRightmost( pCur ); - pCur.atLast = (u8)( rc == SQLITE_OK ? 1 : 0 ); - } - } - return rc; -} + rc = moveToRoot(pCur); + if (rc == SQLITE_OK) { + if (CURSOR_INVALID == pCur.eState) { + Debug.Assert(pCur.apPage[pCur.iPage].nCell == 0); + pRes = 1; + } else { + Debug.Assert(pCur.eState == CURSOR_VALID); + pRes = 0; + rc = moveToRightmost(pCur); + pCur.atLast = (u8)(rc == SQLITE_OK ? 1 : 0); + } + } + return rc; + } -/* Move the cursor so that it points to an entry near the key -** specified by pIdxKey or intKey. Return a success code. -** -** For INTKEY tables, the intKey parameter is used. pIdxKey -** must be NULL. For index tables, pIdxKey is used and intKey -** is ignored. -** -** If an exact match is not found, then the cursor is always -** left pointing at a leaf page which would hold the entry if it -** were present. The cursor might point to an entry that comes -** before or after the key. -** -** An integer is written into pRes which is the result of -** comparing the key with the entry to which the cursor is -** pointing. The meaning of the integer written into -** pRes is as follows: -** -** pRes<0 The cursor is left pointing at an entry that -** is smaller than intKey/pIdxKey or if the table is empty -** and the cursor is therefore left point to nothing. -** -** pRes==null The cursor is left pointing at an entry that -** exactly matches intKey/pIdxKey. -** -** pRes>0 The cursor is left pointing at an entry that -** is larger than intKey/pIdxKey. -** -*/ -static int sqlite3BtreeMovetoUnpacked( -BtCursor pCur, /* The cursor to be moved */ -UnpackedRecord pIdxKey, /* Unpacked index key */ -i64 intKey, /* The table key */ -int biasRight, /* If true, bias the search to the high end */ -ref int pRes /* Write search results here */ -) -{ - int rc; - - Debug.Assert( cursorHoldsMutex( pCur ) ); - Debug.Assert( sqlite3_mutex_held( pCur.pBtree.db.mutex ) ); - // Not needed in C# // Debug.Assert( pRes != 0 ); - Debug.Assert( ( pIdxKey == null ) == ( pCur.pKeyInfo == null ) ); - - /* If the cursor is already positioned at the point we are trying - ** to move to, then just return without doing any work */ - if ( pCur.eState == CURSOR_VALID && pCur.validNKey - && pCur.apPage[0].intKey != 0 - ) - { - if ( pCur.info.nKey == intKey ) - { - pRes = 0; - return SQLITE_OK; - } - if ( pCur.atLast != 0 && pCur.info.nKey < intKey ) - { - pRes = -1; - return SQLITE_OK; - } - } - - rc = moveToRoot( pCur ); - if ( rc != 0 ) - { - return rc; - } - Debug.Assert( pCur.apPage[pCur.iPage] != null ); - Debug.Assert( pCur.apPage[pCur.iPage].isInit != 0 ); - Debug.Assert( pCur.apPage[pCur.iPage].nCell > 0 || pCur.eState == CURSOR_INVALID ); - if ( pCur.eState == CURSOR_INVALID ) - { - pRes = -1; - Debug.Assert( pCur.apPage[pCur.iPage].nCell == 0 ); - return SQLITE_OK; - } - Debug.Assert( pCur.apPage[0].intKey != 0 || pIdxKey != null ); - for ( ; ; ) - { - int lwr, upr, idx; - Pgno chldPg; - MemPage pPage = pCur.apPage[pCur.iPage]; - int c; - - /* pPage.nCell must be greater than zero. If this is the root-page - ** the cursor would have been INVALID above and this for(;;) loop - ** not run. If this is not the root-page, then the moveToChild() routine - ** would have already detected db corruption. Similarly, pPage must - ** be the right kind (index or table) of b-tree page. Otherwise - ** a moveToChild() or moveToRoot() call would have detected corruption. */ - Debug.Assert( pPage.nCell > 0 ); - Debug.Assert( pPage.intKey == ( ( pIdxKey == null ) ? 1 : 0 ) ); - lwr = 0; - upr = pPage.nCell - 1; - if ( biasRight != 0 ) - { - pCur.aiIdx[pCur.iPage] = (u16)( idx = upr ); - } - else - { - pCur.aiIdx[pCur.iPage] = (u16)( idx = ( upr + lwr ) / 2 ); - } - for ( ; ; ) - { - int pCell; /* Pointer to current cell in pPage */ - - Debug.Assert( idx == pCur.aiIdx[pCur.iPage] ); - pCur.info.nSize = 0; - pCell = findCell( pPage, idx ) + pPage.childPtrSize; - if ( pPage.intKey != 0 ) - { - i64 nCellKey = 0; - if ( pPage.hasData != 0 ) - { - u32 Dummy0 = 0; - pCell += getVarint32( pPage.aData, pCell, out Dummy0 ); - } - getVarint( pPage.aData, pCell, out nCellKey ); - if ( nCellKey == intKey ) - { - c = 0; - } - else if ( nCellKey < intKey ) - { - c = -1; - } - else - { - Debug.Assert( nCellKey > intKey ); - c = +1; - } - pCur.validNKey = true; - pCur.info.nKey = nCellKey; - } - else - { - /* The maximum supported page-size is 65536 bytes. This means that - ** the maximum number of record bytes stored on an index B-Tree - ** page is less than 16384 bytes and may be stored as a 2-byte - ** varint. This information is used to attempt to avoid parsing - ** the entire cell by checking for the cases where the record is - ** stored entirely within the b-tree page by inspecting the first - ** 2 bytes of the cell. - */ - int nCell = pPage.aData[pCell + 0]; //pCell[0]; - if ( 0 == ( nCell & 0x80 ) && nCell <= pPage.maxLocal ) - { - /* This branch runs if the record-size field of the cell is a - ** single byte varint and the record fits entirely on the main - ** b-tree page. */ - c = sqlite3VdbeRecordCompare( nCell, pPage.aData, pCell + 1, pIdxKey ); //c = sqlite3VdbeRecordCompare( nCell, (void*)&pCell[1], pIdxKey ); - } - else if ( 0 == ( pPage.aData[pCell + 1] & 0x80 )//!(pCell[1] & 0x80) - && ( nCell = ( ( nCell & 0x7f ) << 7 ) + pPage.aData[pCell + 1] ) <= pPage.maxLocal//pCell[1])<=pPage.maxLocal - ) - { - /* The record-size field is a 2 byte varint and the record - ** fits entirely on the main b-tree page. */ - c = sqlite3VdbeRecordCompare( nCell, pPage.aData, pCell + 2, pIdxKey ); //c = sqlite3VdbeRecordCompare( nCell, (void*)&pCell[2], pIdxKey ); - } - else - { - /* The record flows over onto one or more overflow pages. In - ** this case the whole cell needs to be parsed, a buffer allocated - ** and accessPayload() used to retrieve the record into the - ** buffer before VdbeRecordCompare() can be called. */ - u8[] pCellKey; - u8[] pCellBody = new u8[pPage.aData.Length - pCell + pPage.childPtrSize]; - Buffer.BlockCopy( pPage.aData, pCell - pPage.childPtrSize, pCellBody, 0, pCellBody.Length );// u8 * const pCellBody = pCell - pPage->childPtrSize; - btreeParseCellPtr( pPage, pCellBody, ref pCur.info ); - nCell = (int)pCur.info.nKey; - pCellKey = sqlite3Malloc( nCell ); - //if ( pCellKey == null ) - //{ - // rc = SQLITE_NOMEM; - // goto moveto_finish; - //} - rc = accessPayload( pCur, 0, (u32)nCell, pCellKey, 0 ); - if ( rc != 0 ) - { - pCellKey = null;// sqlite3_free(ref pCellKey ); - goto moveto_finish; - } - c = sqlite3VdbeRecordCompare( nCell, pCellKey, pIdxKey ); - pCellKey = null;// sqlite3_free(ref pCellKey ); - } - } - if ( c == 0 ) - { - if ( pPage.intKey != 0 && 0 == pPage.leaf ) - { - lwr = idx; - upr = lwr - 1; - break; - } - else - { - pRes = 0; - rc = SQLITE_OK; - goto moveto_finish; - } - } - if ( c < 0 ) - { - lwr = idx + 1; - } - else - { - upr = idx - 1; - } - if ( lwr > upr ) - { - break; - } - pCur.aiIdx[pCur.iPage] = (u16)( idx = ( lwr + upr ) / 2 ); - } - Debug.Assert( lwr == upr + 1 ); - Debug.Assert( pPage.isInit != 0 ); - if ( pPage.leaf != 0 ) - { - chldPg = 0; - } - else if ( lwr >= pPage.nCell ) - { - chldPg = sqlite3Get4byte( pPage.aData, pPage.hdrOffset + 8 ); - } - else - { - chldPg = sqlite3Get4byte( pPage.aData, findCell( pPage, lwr ) ); - } - if ( chldPg == 0 ) - { - Debug.Assert( pCur.aiIdx[pCur.iPage] < pCur.apPage[pCur.iPage].nCell ); - pRes = c; - rc = SQLITE_OK; - goto moveto_finish; - } - pCur.aiIdx[pCur.iPage] = (u16)lwr; - pCur.info.nSize = 0; - pCur.validNKey = false; - rc = moveToChild( pCur, chldPg ); - if ( rc != 0 ) - goto moveto_finish; - } -moveto_finish: - return rc; -} + /* Move the cursor so that it points to an entry near the key + ** specified by pIdxKey or intKey. Return a success code. + ** + ** For INTKEY tables, the intKey parameter is used. pIdxKey + ** must be NULL. For index tables, pIdxKey is used and intKey + ** is ignored. + ** + ** If an exact match is not found, then the cursor is always + ** left pointing at a leaf page which would hold the entry if it + ** were present. The cursor might point to an entry that comes + ** before or after the key. + ** + ** An integer is written into pRes which is the result of + ** comparing the key with the entry to which the cursor is + ** pointing. The meaning of the integer written into + ** pRes is as follows: + ** + ** pRes<0 The cursor is left pointing at an entry that + ** is smaller than intKey/pIdxKey or if the table is empty + ** and the cursor is therefore left point to nothing. + ** + ** pRes==null The cursor is left pointing at an entry that + ** exactly matches intKey/pIdxKey. + ** + ** pRes>0 The cursor is left pointing at an entry that + ** is larger than intKey/pIdxKey. + ** + */ + static int sqlite3BtreeMovetoUnpacked( + BtCursor pCur, /* The cursor to be moved */ + UnpackedRecord pIdxKey, /* Unpacked index key */ + i64 intKey, /* The table key */ + int biasRight, /* If true, bias the search to the high end */ + ref int pRes /* Write search results here */ + ) { + int rc; + + Debug.Assert(cursorHoldsMutex(pCur)); + Debug.Assert(sqlite3_mutex_held(pCur.pBtree.db.mutex)); + // Not needed in C# // Debug.Assert( pRes != 0 ); + Debug.Assert((pIdxKey == null) == (pCur.pKeyInfo == null)); + + /* If the cursor is already positioned at the point we are trying + ** to move to, then just return without doing any work */ + if (pCur.eState == CURSOR_VALID && pCur.validNKey + && pCur.apPage[0].intKey != 0 + ) { + if (pCur.info.nKey == intKey) { + pRes = 0; + return SQLITE_OK; + } + if (pCur.atLast != 0 && pCur.info.nKey < intKey) { + pRes = -1; + return SQLITE_OK; + } + } + rc = moveToRoot(pCur); + if (rc != 0) { + return rc; + } + Debug.Assert(pCur.apPage[pCur.iPage] != null); + Debug.Assert(pCur.apPage[pCur.iPage].isInit != 0); + Debug.Assert(pCur.apPage[pCur.iPage].nCell > 0 || pCur.eState == CURSOR_INVALID); + if (pCur.eState == CURSOR_INVALID) { + pRes = -1; + Debug.Assert(pCur.apPage[pCur.iPage].nCell == 0); + return SQLITE_OK; + } + Debug.Assert(pCur.apPage[0].intKey != 0 || pIdxKey != null); + for (; ; ) + { + int lwr, upr, idx; + Pgno chldPg; + MemPage pPage = pCur.apPage[pCur.iPage]; + int c; + + /* pPage.nCell must be greater than zero. If this is the root-page + ** the cursor would have been INVALID above and this for(;;) loop + ** not run. If this is not the root-page, then the moveToChild() routine + ** would have already detected db corruption. Similarly, pPage must + ** be the right kind (index or table) of b-tree page. Otherwise + ** a moveToChild() or moveToRoot() call would have detected corruption. */ + Debug.Assert(pPage.nCell > 0); + Debug.Assert(pPage.intKey == ((pIdxKey == null) ? 1 : 0)); + lwr = 0; + upr = pPage.nCell - 1; + if (biasRight != 0) { + pCur.aiIdx[pCur.iPage] = (u16)(idx = upr); + } else { + pCur.aiIdx[pCur.iPage] = (u16)(idx = (upr + lwr) / 2); + } + for (; ; ) + { + int pCell; /* Pointer to current cell in pPage */ + + Debug.Assert(idx == pCur.aiIdx[pCur.iPage]); + pCur.info.nSize = 0; + pCell = findCell(pPage, idx) + pPage.childPtrSize; + if (pPage.intKey != 0) { + i64 nCellKey = 0; + if (pPage.hasData != 0) { + u32 Dummy0 = 0; + pCell += getVarint32(pPage.aData, pCell, out Dummy0); + } + getVarint(pPage.aData, pCell, out nCellKey); + if (nCellKey == intKey) { + c = 0; + } else if (nCellKey < intKey) { + c = -1; + } else { + Debug.Assert(nCellKey > intKey); + c = +1; + } + pCur.validNKey = true; + pCur.info.nKey = nCellKey; + } else { + /* The maximum supported page-size is 65536 bytes. This means that + ** the maximum number of record bytes stored on an index B-Tree + ** page is less than 16384 bytes and may be stored as a 2-byte + ** varint. This information is used to attempt to avoid parsing + ** the entire cell by checking for the cases where the record is + ** stored entirely within the b-tree page by inspecting the first + ** 2 bytes of the cell. + */ + int nCell = pPage.aData[pCell + 0]; //pCell[0]; + if (0 == (nCell & 0x80) && nCell <= pPage.maxLocal) { + /* This branch runs if the record-size field of the cell is a + ** single byte varint and the record fits entirely on the main + ** b-tree page. */ + c = sqlite3VdbeRecordCompare(nCell, pPage.aData, pCell + 1, pIdxKey); //c = sqlite3VdbeRecordCompare( nCell, (void*)&pCell[1], pIdxKey ); + } else if (0 == (pPage.aData[pCell + 1] & 0x80)//!(pCell[1] & 0x80) + && (nCell = ((nCell & 0x7f) << 7) + pPage.aData[pCell + 1]) <= pPage.maxLocal//pCell[1])<=pPage.maxLocal + ) { + /* The record-size field is a 2 byte varint and the record + ** fits entirely on the main b-tree page. */ + c = sqlite3VdbeRecordCompare(nCell, pPage.aData, pCell + 2, pIdxKey); //c = sqlite3VdbeRecordCompare( nCell, (void*)&pCell[2], pIdxKey ); + } else { + /* The record flows over onto one or more overflow pages. In + ** this case the whole cell needs to be parsed, a buffer allocated + ** and accessPayload() used to retrieve the record into the + ** buffer before VdbeRecordCompare() can be called. */ + u8[] pCellKey; + u8[] pCellBody = new u8[pPage.aData.Length - pCell + pPage.childPtrSize]; + Buffer.BlockCopy(pPage.aData, pCell - pPage.childPtrSize, pCellBody, 0, pCellBody.Length);// u8 * const pCellBody = pCell - pPage->childPtrSize; + btreeParseCellPtr(pPage, pCellBody, ref pCur.info); + nCell = (int)pCur.info.nKey; + pCellKey = sqlite3Malloc(nCell); + //if ( pCellKey == null ) + //{ + // rc = SQLITE_NOMEM; + // goto moveto_finish; + //} + rc = accessPayload(pCur, 0, (u32)nCell, pCellKey, 0); + if (rc != 0) { + pCellKey = null;// sqlite3_free(ref pCellKey ); + goto moveto_finish; + } + c = sqlite3VdbeRecordCompare(nCell, pCellKey, pIdxKey); + pCellKey = null;// sqlite3_free(ref pCellKey ); + } + } + if (c == 0) { + if (pPage.intKey != 0 && 0 == pPage.leaf) { + lwr = idx; + upr = lwr - 1; + break; + } else { + pRes = 0; + rc = SQLITE_OK; + goto moveto_finish; + } + } + if (c < 0) { + lwr = idx + 1; + } else { + upr = idx - 1; + } + if (lwr > upr) { + break; + } + pCur.aiIdx[pCur.iPage] = (u16)(idx = (lwr + upr) / 2); + } + Debug.Assert(lwr == upr + 1); + Debug.Assert(pPage.isInit != 0); + if (pPage.leaf != 0) { + chldPg = 0; + } else if (lwr >= pPage.nCell) { + chldPg = sqlite3Get4byte(pPage.aData, pPage.hdrOffset + 8); + } else { + chldPg = sqlite3Get4byte(pPage.aData, findCell(pPage, lwr)); + } + if (chldPg == 0) { + Debug.Assert(pCur.aiIdx[pCur.iPage] < pCur.apPage[pCur.iPage].nCell); + pRes = c; + rc = SQLITE_OK; + goto moveto_finish; + } + pCur.aiIdx[pCur.iPage] = (u16)lwr; + pCur.info.nSize = 0; + pCur.validNKey = false; + rc = moveToChild(pCur, chldPg); + if (rc != 0) + goto moveto_finish; + } + moveto_finish: + return rc; + } -/* -** Return TRUE if the cursor is not pointing at an entry of the table. -** -** TRUE will be returned after a call to sqlite3BtreeNext() moves -** past the last entry in the table or sqlite3BtreePrev() moves past -** the first entry. TRUE is also returned if the table is empty. -*/ -static bool sqlite3BtreeEof( BtCursor pCur ) -{ - /* TODO: What if the cursor is in CURSOR_REQUIRESEEK but all table entries - ** have been deleted? This API will need to change to return an error code - ** as well as the boolean result value. - */ - return ( CURSOR_VALID != pCur.eState ); -} -/* -** Advance the cursor to the next entry in the database. If -** successful then set pRes=0. If the cursor -** was already pointing to the last entry in the database before -** this routine was called, then set pRes=1. -*/ -static int sqlite3BtreeNext( BtCursor pCur, ref int pRes ) -{ - int rc; - int idx; - MemPage pPage; - - Debug.Assert( cursorHoldsMutex( pCur ) ); - rc = restoreCursorPosition( pCur ); - if ( rc != SQLITE_OK ) - { - return rc; - } - // Not needed in C# // Debug.Assert( pRes != 0 ); - if ( CURSOR_INVALID == pCur.eState ) - { - pRes = 1; - return SQLITE_OK; - } - if ( pCur.skipNext > 0 ) - { - pCur.skipNext = 0; - pRes = 0; - return SQLITE_OK; - } - pCur.skipNext = 0; - - pPage = pCur.apPage[pCur.iPage]; - idx = ++pCur.aiIdx[pCur.iPage]; - Debug.Assert( pPage.isInit != 0 ); - Debug.Assert( idx <= pPage.nCell ); - - pCur.info.nSize = 0; - pCur.validNKey = false; - if ( idx >= pPage.nCell ) - { - if ( 0 == pPage.leaf ) - { - rc = moveToChild( pCur, sqlite3Get4byte( pPage.aData, pPage.hdrOffset + 8 ) ); - if ( rc != 0 ) - return rc; - rc = moveToLeftmost( pCur ); - pRes = 0; - return rc; - } - do - { - if ( pCur.iPage == 0 ) - { - pRes = 1; - pCur.eState = CURSOR_INVALID; - return SQLITE_OK; - } - moveToParent( pCur ); - pPage = pCur.apPage[pCur.iPage]; - } while ( pCur.aiIdx[pCur.iPage] >= pPage.nCell ); - pRes = 0; - if ( pPage.intKey != 0 ) - { - rc = sqlite3BtreeNext( pCur, ref pRes ); - } - else - { - rc = SQLITE_OK; - } - return rc; - } - pRes = 0; - if ( pPage.leaf != 0 ) - { - return SQLITE_OK; - } - rc = moveToLeftmost( pCur ); - return rc; -} + /* + ** Return TRUE if the cursor is not pointing at an entry of the table. + ** + ** TRUE will be returned after a call to sqlite3BtreeNext() moves + ** past the last entry in the table or sqlite3BtreePrev() moves past + ** the first entry. TRUE is also returned if the table is empty. + */ + static bool sqlite3BtreeEof(BtCursor pCur) { + /* TODO: What if the cursor is in CURSOR_REQUIRESEEK but all table entries + ** have been deleted? This API will need to change to return an error code + ** as well as the boolean result value. + */ + return (CURSOR_VALID != pCur.eState); + } + /* + ** Advance the cursor to the next entry in the database. If + ** successful then set pRes=0. If the cursor + ** was already pointing to the last entry in the database before + ** this routine was called, then set pRes=1. + */ + static int sqlite3BtreeNext(BtCursor pCur, ref int pRes) { + int rc; + int idx; + MemPage pPage; + + Debug.Assert(cursorHoldsMutex(pCur)); + rc = restoreCursorPosition(pCur); + if (rc != SQLITE_OK) { + return rc; + } + // Not needed in C# // Debug.Assert( pRes != 0 ); + if (CURSOR_INVALID == pCur.eState) { + pRes = 1; + return SQLITE_OK; + } + if (pCur.skipNext > 0) { + pCur.skipNext = 0; + pRes = 0; + return SQLITE_OK; + } + pCur.skipNext = 0; + + pPage = pCur.apPage[pCur.iPage]; + idx = ++pCur.aiIdx[pCur.iPage]; + Debug.Assert(pPage.isInit != 0); + Debug.Assert(idx <= pPage.nCell); + + pCur.info.nSize = 0; + pCur.validNKey = false; + if (idx >= pPage.nCell) { + if (0 == pPage.leaf) { + rc = moveToChild(pCur, sqlite3Get4byte(pPage.aData, pPage.hdrOffset + 8)); + if (rc != 0) + return rc; + rc = moveToLeftmost(pCur); + pRes = 0; + return rc; + } + do { + if (pCur.iPage == 0) { + pRes = 1; + pCur.eState = CURSOR_INVALID; + return SQLITE_OK; + } + moveToParent(pCur); + pPage = pCur.apPage[pCur.iPage]; + } while (pCur.aiIdx[pCur.iPage] >= pPage.nCell); + pRes = 0; + if (pPage.intKey != 0) { + rc = sqlite3BtreeNext(pCur, ref pRes); + } else { + rc = SQLITE_OK; + } + return rc; + } + pRes = 0; + if (pPage.leaf != 0) { + return SQLITE_OK; + } + rc = moveToLeftmost(pCur); + return rc; + } -/* -** Step the cursor to the back to the previous entry in the database. If -** successful then set pRes=0. If the cursor -** was already pointing to the first entry in the database before -** this routine was called, then set pRes=1. -*/ -static int sqlite3BtreePrevious( BtCursor pCur, ref int pRes ) -{ - int rc; - MemPage pPage; - - Debug.Assert( cursorHoldsMutex( pCur ) ); - rc = restoreCursorPosition( pCur ); - if ( rc != SQLITE_OK ) - { - return rc; - } - pCur.atLast = 0; - if ( CURSOR_INVALID == pCur.eState ) - { - pRes = 1; - return SQLITE_OK; - } - if ( pCur.skipNext < 0 ) - { - pCur.skipNext = 0; - pRes = 0; - return SQLITE_OK; - } - pCur.skipNext = 0; - - pPage = pCur.apPage[pCur.iPage]; - Debug.Assert( pPage.isInit != 0 ); - if ( 0 == pPage.leaf ) - { - int idx = pCur.aiIdx[pCur.iPage]; - rc = moveToChild( pCur, sqlite3Get4byte( pPage.aData, findCell( pPage, idx ) ) ); - if ( rc != 0 ) - { - return rc; - } - rc = moveToRightmost( pCur ); - } - else - { - while ( pCur.aiIdx[pCur.iPage] == 0 ) - { - if ( pCur.iPage == 0 ) - { - pCur.eState = CURSOR_INVALID; - pRes = 1; - return SQLITE_OK; - } - moveToParent( pCur ); - } - pCur.info.nSize = 0; - pCur.validNKey = false; - pCur.aiIdx[pCur.iPage]--; - pPage = pCur.apPage[pCur.iPage]; - if ( pPage.intKey != 0 && 0 == pPage.leaf ) - { - rc = sqlite3BtreePrevious( pCur, ref pRes ); - } - else - { - rc = SQLITE_OK; - } - } - pRes = 0; - return rc; -} + /* + ** Step the cursor to the back to the previous entry in the database. If + ** successful then set pRes=0. If the cursor + ** was already pointing to the first entry in the database before + ** this routine was called, then set pRes=1. + */ + static int sqlite3BtreePrevious(BtCursor pCur, ref int pRes) { + int rc; + MemPage pPage; + + Debug.Assert(cursorHoldsMutex(pCur)); + rc = restoreCursorPosition(pCur); + if (rc != SQLITE_OK) { + return rc; + } + pCur.atLast = 0; + if (CURSOR_INVALID == pCur.eState) { + pRes = 1; + return SQLITE_OK; + } + if (pCur.skipNext < 0) { + pCur.skipNext = 0; + pRes = 0; + return SQLITE_OK; + } + pCur.skipNext = 0; + + pPage = pCur.apPage[pCur.iPage]; + Debug.Assert(pPage.isInit != 0); + if (0 == pPage.leaf) { + int idx = pCur.aiIdx[pCur.iPage]; + rc = moveToChild(pCur, sqlite3Get4byte(pPage.aData, findCell(pPage, idx))); + if (rc != 0) { + return rc; + } + rc = moveToRightmost(pCur); + } else { + while (pCur.aiIdx[pCur.iPage] == 0) { + if (pCur.iPage == 0) { + pCur.eState = CURSOR_INVALID; + pRes = 1; + return SQLITE_OK; + } + moveToParent(pCur); + } + pCur.info.nSize = 0; + pCur.validNKey = false; + + pCur.aiIdx[pCur.iPage]--; + pPage = pCur.apPage[pCur.iPage]; + if (pPage.intKey != 0 && 0 == pPage.leaf) { + rc = sqlite3BtreePrevious(pCur, ref pRes); + } else { + rc = SQLITE_OK; + } + } + pRes = 0; + return rc; + } -/* -** Allocate a new page from the database file. -** -** The new page is marked as dirty. (In other words, sqlite3PagerWrite() -** has already been called on the new page.) The new page has also -** been referenced and the calling routine is responsible for calling -** sqlite3PagerUnref() on the new page when it is done. -** -** SQLITE_OK is returned on success. Any other return value indicates -** an error. ppPage and pPgno are undefined in the event of an error. -** Do not invoke sqlite3PagerUnref() on ppPage if an error is returned. -** -** If the "nearby" parameter is not 0, then a (feeble) effort is made to -** locate a page close to the page number "nearby". This can be used in an -** attempt to keep related pages close to each other in the database file, -** which in turn can make database access faster. -** -** If the "exact" parameter is not 0, and the page-number nearby exists -** anywhere on the free-list, then it is guarenteed to be returned. This -** is only used by auto-vacuum databases when allocating a new table. -*/ -static int allocateBtreePage( -BtShared pBt, -ref MemPage ppPage, -ref Pgno pPgno, -Pgno nearby, -u8 exact -) -{ - MemPage pPage1; - int rc; - u32 n; /* Number of pages on the freelist */ - u32 k; /* Number of leaves on the trunk of the freelist */ - MemPage pTrunk = null; - MemPage pPrevTrunk = null; - Pgno mxPage; /* Total size of the database file */ - - Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); - pPage1 = pBt.pPage1; - mxPage = btreePagecount( pBt ); - n = sqlite3Get4byte( pPage1.aData, 36 ); - testcase( n == mxPage - 1 ); - if ( n >= mxPage ) - { - return SQLITE_CORRUPT_BKPT(); - } - if ( n > 0 ) - { - /* There are pages on the freelist. Reuse one of those pages. */ - Pgno iTrunk; - u8 searchList = 0; /* If the free-list must be searched for 'nearby' */ - - /* If the 'exact' parameter was true and a query of the pointer-map - ** shows that the page 'nearby' is somewhere on the free-list, then - ** the entire-list will be searched for that page. - */ + /* + ** Allocate a new page from the database file. + ** + ** The new page is marked as dirty. (In other words, sqlite3PagerWrite() + ** has already been called on the new page.) The new page has also + ** been referenced and the calling routine is responsible for calling + ** sqlite3PagerUnref() on the new page when it is done. + ** + ** SQLITE_OK is returned on success. Any other return value indicates + ** an error. ppPage and pPgno are undefined in the event of an error. + ** Do not invoke sqlite3PagerUnref() on ppPage if an error is returned. + ** + ** If the "nearby" parameter is not 0, then a (feeble) effort is made to + ** locate a page close to the page number "nearby". This can be used in an + ** attempt to keep related pages close to each other in the database file, + ** which in turn can make database access faster. + ** + ** If the "exact" parameter is not 0, and the page-number nearby exists + ** anywhere on the free-list, then it is guarenteed to be returned. This + ** is only used by auto-vacuum databases when allocating a new table. + */ + static int allocateBtreePage( + BtShared pBt, + ref MemPage ppPage, + ref Pgno pPgno, + Pgno nearby, + u8 exact + ) { + MemPage pPage1; + int rc; + u32 n; /* Number of pages on the freelist */ + u32 k; /* Number of leaves on the trunk of the freelist */ + MemPage pTrunk = null; + MemPage pPrevTrunk = null; + Pgno mxPage; /* Total size of the database file */ + + Debug.Assert(sqlite3_mutex_held(pBt.mutex)); + pPage1 = pBt.pPage1; + mxPage = btreePagecount(pBt); + n = sqlite3Get4byte(pPage1.aData, 36); + testcase(n == mxPage - 1); + if (n >= mxPage) { + return SQLITE_CORRUPT_BKPT(); + } + if (n > 0) { + /* There are pages on the freelist. Reuse one of those pages. */ + Pgno iTrunk; + u8 searchList = 0; /* If the free-list must be searched for 'nearby' */ + + /* If the 'exact' parameter was true and a query of the pointer-map + ** shows that the page 'nearby' is somewhere on the free-list, then + ** the entire-list will be searched for that page. + */ #if !SQLITE_OMIT_AUTOVACUUM - if ( exact != 0 && nearby <= mxPage ) - { - u8 eType = 0; - Debug.Assert( nearby > 0 ); - Debug.Assert( pBt.autoVacuum ); - u32 Dummy0 = 0; - rc = ptrmapGet( pBt, nearby, ref eType, ref Dummy0 ); - if ( rc != 0 ) - return rc; - if ( eType == PTRMAP_FREEPAGE ) - { - searchList = 1; - } - pPgno = nearby; - } + if (exact != 0 && nearby <= mxPage) { + u8 eType = 0; + Debug.Assert(nearby > 0); + Debug.Assert(pBt.autoVacuum); + u32 Dummy0 = 0; + rc = ptrmapGet(pBt, nearby, ref eType, ref Dummy0); + if (rc != 0) + return rc; + if (eType == PTRMAP_FREEPAGE) { + searchList = 1; + } + pPgno = nearby; + } #endif - /* Decrement the free-list count by 1. Set iTrunk to the index of the -** first free-list trunk page. iPrevTrunk is initially 1. -*/ - rc = sqlite3PagerWrite( pPage1.pDbPage ); - if ( rc != 0 ) - return rc; - sqlite3Put4byte( pPage1.aData, (u32)36, n - 1 ); - - /* The code within this loop is run only once if the 'searchList' variable - ** is not true. Otherwise, it runs once for each trunk-page on the - ** free-list until the page 'nearby' is located. - */ - do - { - pPrevTrunk = pTrunk; - if ( pPrevTrunk != null ) - { - iTrunk = sqlite3Get4byte( pPrevTrunk.aData, 0 ); - } - else - { - iTrunk = sqlite3Get4byte( pPage1.aData, 32 ); - } - testcase( iTrunk == mxPage ); - if ( iTrunk > mxPage ) - { - rc = SQLITE_CORRUPT_BKPT(); - } - else - { - rc = btreeGetPage( pBt, iTrunk, ref pTrunk, 0 ); - } - if ( rc != 0 ) - { - pTrunk = null; - goto end_allocate_page; - } - - k = sqlite3Get4byte( pTrunk.aData, 4 ); /* # of leaves on this trunk page */ - if ( k == 0 && 0 == searchList ) - { - /* The trunk has no leaves and the list is not being searched. - ** So extract the trunk page itself and use it as the newly - ** allocated page */ - Debug.Assert( pPrevTrunk == null ); - rc = sqlite3PagerWrite( pTrunk.pDbPage ); - if ( rc != 0 ) - { - goto end_allocate_page; - } - pPgno = iTrunk; - Buffer.BlockCopy( pTrunk.aData, 0, pPage1.aData, 32, 4 );//memcpy( pPage1.aData[32], ref pTrunk.aData[0], 4 ); - ppPage = pTrunk; - pTrunk = null; - TRACE( "ALLOCATE: %d trunk - %d free pages left\n", pPgno, n - 1 ); - } - else if ( k > (u32)( pBt.usableSize / 4 - 2 ) ) - { - /* Value of k is out of range. Database corruption */ - rc = SQLITE_CORRUPT_BKPT(); - goto end_allocate_page; + /* Decrement the free-list count by 1. Set iTrunk to the index of the + ** first free-list trunk page. iPrevTrunk is initially 1. + */ + rc = sqlite3PagerWrite(pPage1.pDbPage); + if (rc != 0) + return rc; + sqlite3Put4byte(pPage1.aData, (u32)36, n - 1); + + /* The code within this loop is run only once if the 'searchList' variable + ** is not true. Otherwise, it runs once for each trunk-page on the + ** free-list until the page 'nearby' is located. + */ + do { + pPrevTrunk = pTrunk; + if (pPrevTrunk != null) { + iTrunk = sqlite3Get4byte(pPrevTrunk.aData, 0); + } else { + iTrunk = sqlite3Get4byte(pPage1.aData, 32); + } + testcase(iTrunk == mxPage); + if (iTrunk > mxPage) { + rc = SQLITE_CORRUPT_BKPT(); + } else { + rc = btreeGetPage(pBt, iTrunk, ref pTrunk, 0); + } + if (rc != 0) { + pTrunk = null; + goto end_allocate_page; + } + + k = sqlite3Get4byte(pTrunk.aData, 4); /* # of leaves on this trunk page */ + if (k == 0 && 0 == searchList) { + /* The trunk has no leaves and the list is not being searched. + ** So extract the trunk page itself and use it as the newly + ** allocated page */ + Debug.Assert(pPrevTrunk == null); + rc = sqlite3PagerWrite(pTrunk.pDbPage); + if (rc != 0) { + goto end_allocate_page; + } + pPgno = iTrunk; + Buffer.BlockCopy(pTrunk.aData, 0, pPage1.aData, 32, 4);//memcpy( pPage1.aData[32], ref pTrunk.aData[0], 4 ); + ppPage = pTrunk; + pTrunk = null; + TRACE("ALLOCATE: %d trunk - %d free pages left\n", pPgno, n - 1); + } else if (k > (u32)(pBt.usableSize / 4 - 2)) { + /* Value of k is out of range. Database corruption */ + rc = SQLITE_CORRUPT_BKPT(); + goto end_allocate_page; #if !SQLITE_OMIT_AUTOVACUUM - } - else if ( searchList != 0 && nearby == iTrunk ) - { - /* The list is being searched and this trunk page is the page - ** to allocate, regardless of whether it has leaves. - */ - Debug.Assert( pPgno == iTrunk ); - ppPage = pTrunk; - searchList = 0; - rc = sqlite3PagerWrite( pTrunk.pDbPage ); - if ( rc != 0 ) - { - goto end_allocate_page; - } - if ( k == 0 ) - { - if ( null == pPrevTrunk ) - { - //memcpy(pPage1.aData[32], pTrunk.aData[0], 4); - pPage1.aData[32 + 0] = pTrunk.aData[0 + 0]; - pPage1.aData[32 + 1] = pTrunk.aData[0 + 1]; - pPage1.aData[32 + 2] = pTrunk.aData[0 + 2]; - pPage1.aData[32 + 3] = pTrunk.aData[0 + 3]; - } - else - { - rc = sqlite3PagerWrite( pPrevTrunk.pDbPage ); - if ( rc != SQLITE_OK ) - { - goto end_allocate_page; - } - //memcpy(pPrevTrunk.aData[0], pTrunk.aData[0], 4); - pPrevTrunk.aData[0 + 0] = pTrunk.aData[0 + 0]; - pPrevTrunk.aData[0 + 1] = pTrunk.aData[0 + 1]; - pPrevTrunk.aData[0 + 2] = pTrunk.aData[0 + 2]; - pPrevTrunk.aData[0 + 3] = pTrunk.aData[0 + 3]; - } - } - else - { - /* The trunk page is required by the caller but it contains - ** pointers to free-list leaves. The first leaf becomes a trunk - ** page in this case. - */ - MemPage pNewTrunk = new MemPage(); - Pgno iNewTrunk = sqlite3Get4byte( pTrunk.aData, 8 ); - if ( iNewTrunk > mxPage ) - { - rc = SQLITE_CORRUPT_BKPT(); - goto end_allocate_page; - } - testcase( iNewTrunk == mxPage ); - rc = btreeGetPage( pBt, iNewTrunk, ref pNewTrunk, 0 ); - if ( rc != SQLITE_OK ) - { - goto end_allocate_page; - } - rc = sqlite3PagerWrite( pNewTrunk.pDbPage ); - if ( rc != SQLITE_OK ) - { - releasePage( pNewTrunk ); - goto end_allocate_page; - } - //memcpy(pNewTrunk.aData[0], pTrunk.aData[0], 4); - pNewTrunk.aData[0 + 0] = pTrunk.aData[0 + 0]; - pNewTrunk.aData[0 + 1] = pTrunk.aData[0 + 1]; - pNewTrunk.aData[0 + 2] = pTrunk.aData[0 + 2]; - pNewTrunk.aData[0 + 3] = pTrunk.aData[0 + 3]; - sqlite3Put4byte( pNewTrunk.aData, (u32)4, (u32)( k - 1 ) ); - Buffer.BlockCopy( pTrunk.aData, 12, pNewTrunk.aData, 8, (int)( k - 1 ) * 4 );//memcpy( pNewTrunk.aData[8], ref pTrunk.aData[12], ( k - 1 ) * 4 ); - releasePage( pNewTrunk ); - if ( null == pPrevTrunk ) - { - Debug.Assert( sqlite3PagerIswriteable( pPage1.pDbPage ) ); - sqlite3Put4byte( pPage1.aData, (u32)32, iNewTrunk ); - } - else - { - rc = sqlite3PagerWrite( pPrevTrunk.pDbPage ); - if ( rc != 0 ) - { - goto end_allocate_page; - } - sqlite3Put4byte( pPrevTrunk.aData, (u32)0, iNewTrunk ); - } - } - pTrunk = null; - TRACE( "ALLOCATE: %d trunk - %d free pages left\n", pPgno, n - 1 ); + } else if (searchList != 0 && nearby == iTrunk) { + /* The list is being searched and this trunk page is the page + ** to allocate, regardless of whether it has leaves. + */ + Debug.Assert(pPgno == iTrunk); + ppPage = pTrunk; + searchList = 0; + rc = sqlite3PagerWrite(pTrunk.pDbPage); + if (rc != 0) { + goto end_allocate_page; + } + if (k == 0) { + if (null == pPrevTrunk) { + //memcpy(pPage1.aData[32], pTrunk.aData[0], 4); + pPage1.aData[32 + 0] = pTrunk.aData[0 + 0]; + pPage1.aData[32 + 1] = pTrunk.aData[0 + 1]; + pPage1.aData[32 + 2] = pTrunk.aData[0 + 2]; + pPage1.aData[32 + 3] = pTrunk.aData[0 + 3]; + } else { + rc = sqlite3PagerWrite(pPrevTrunk.pDbPage); + if (rc != SQLITE_OK) { + goto end_allocate_page; + } + //memcpy(pPrevTrunk.aData[0], pTrunk.aData[0], 4); + pPrevTrunk.aData[0 + 0] = pTrunk.aData[0 + 0]; + pPrevTrunk.aData[0 + 1] = pTrunk.aData[0 + 1]; + pPrevTrunk.aData[0 + 2] = pTrunk.aData[0 + 2]; + pPrevTrunk.aData[0 + 3] = pTrunk.aData[0 + 3]; + } + } else { + /* The trunk page is required by the caller but it contains + ** pointers to free-list leaves. The first leaf becomes a trunk + ** page in this case. + */ + MemPage pNewTrunk = new MemPage(); + Pgno iNewTrunk = sqlite3Get4byte(pTrunk.aData, 8); + if (iNewTrunk > mxPage) { + rc = SQLITE_CORRUPT_BKPT(); + goto end_allocate_page; + } + testcase(iNewTrunk == mxPage); + rc = btreeGetPage(pBt, iNewTrunk, ref pNewTrunk, 0); + if (rc != SQLITE_OK) { + goto end_allocate_page; + } + rc = sqlite3PagerWrite(pNewTrunk.pDbPage); + if (rc != SQLITE_OK) { + releasePage(pNewTrunk); + goto end_allocate_page; + } + //memcpy(pNewTrunk.aData[0], pTrunk.aData[0], 4); + pNewTrunk.aData[0 + 0] = pTrunk.aData[0 + 0]; + pNewTrunk.aData[0 + 1] = pTrunk.aData[0 + 1]; + pNewTrunk.aData[0 + 2] = pTrunk.aData[0 + 2]; + pNewTrunk.aData[0 + 3] = pTrunk.aData[0 + 3]; + sqlite3Put4byte(pNewTrunk.aData, (u32)4, (u32)(k - 1)); + Buffer.BlockCopy(pTrunk.aData, 12, pNewTrunk.aData, 8, (int)(k - 1) * 4);//memcpy( pNewTrunk.aData[8], ref pTrunk.aData[12], ( k - 1 ) * 4 ); + releasePage(pNewTrunk); + if (null == pPrevTrunk) { + Debug.Assert(sqlite3PagerIswriteable(pPage1.pDbPage)); + sqlite3Put4byte(pPage1.aData, (u32)32, iNewTrunk); + } else { + rc = sqlite3PagerWrite(pPrevTrunk.pDbPage); + if (rc != 0) { + goto end_allocate_page; + } + sqlite3Put4byte(pPrevTrunk.aData, (u32)0, iNewTrunk); + } + } + pTrunk = null; + TRACE("ALLOCATE: %d trunk - %d free pages left\n", pPgno, n - 1); #endif - } - else if ( k > 0 ) - { - /* Extract a leaf from the trunk */ - u32 closest; - Pgno iPage; - byte[] aData = pTrunk.aData; - if ( nearby > 0 ) - { - u32 i; - int dist; - closest = 0; - dist = sqlite3AbsInt32( (int)(sqlite3Get4byte( aData, 8 ) - nearby )); - for ( i = 1; i < k; i++ ) - { - int d2 = sqlite3AbsInt32( (int)(sqlite3Get4byte( aData, 8 + i * 4 ) - nearby )); - if ( d2 < dist ) - { - closest = i; - dist = d2; - } - } - } - else - { - closest = 0; - } - - iPage = sqlite3Get4byte( aData, 8 + closest * 4 ); - testcase( iPage == mxPage ); - if ( iPage > mxPage ) - { - rc = SQLITE_CORRUPT_BKPT(); - goto end_allocate_page; - } - testcase( iPage == mxPage ); - if ( 0 == searchList || iPage == nearby ) - { - int noContent; - pPgno = iPage; - TRACE( "ALLOCATE: %d was leaf %d of %d on trunk %d" + - ": %d more free pages\n", - pPgno, closest + 1, k, pTrunk.pgno, n - 1 ); - rc = sqlite3PagerWrite( pTrunk.pDbPage ); - if ( rc != 0) - goto end_allocate_page; - if ( closest < k - 1 ) - { - Buffer.BlockCopy( aData, (int)( 4 + k * 4 ), aData, 8 + (int)closest * 4, 4 );//memcpy( aData[8 + closest * 4], ref aData[4 + k * 4], 4 ); - } - sqlite3Put4byte( aData, (u32)4, ( k - 1 ) );// sqlite3Put4byte( aData, 4, k - 1 ); - noContent = !btreeGetHasContent( pBt, pPgno ) ? 1 : 0; - rc = btreeGetPage( pBt, pPgno, ref ppPage, noContent ); - if ( rc == SQLITE_OK ) - { - rc = sqlite3PagerWrite( ( ppPage ).pDbPage ); - if ( rc != SQLITE_OK ) - { - releasePage( ppPage ); - } - } - searchList = 0; - } - } - releasePage( pPrevTrunk ); - pPrevTrunk = null; - } while ( searchList != 0 ); - } - else - { - /* There are no pages on the freelist, so create a new page at the - ** end of the file */ - rc = sqlite3PagerWrite( pBt.pPage1.pDbPage ); - if ( rc != 0 ) - return rc; - pBt.nPage++; - if ( pBt.nPage == PENDING_BYTE_PAGE( pBt ) ) - pBt.nPage++; + } else if (k > 0) { + /* Extract a leaf from the trunk */ + u32 closest; + Pgno iPage; + byte[] aData = pTrunk.aData; + if (nearby > 0) { + u32 i; + int dist; + closest = 0; + dist = sqlite3AbsInt32((int)(sqlite3Get4byte(aData, 8) - nearby)); + for (i = 1; i < k; i++) { + int d2 = sqlite3AbsInt32((int)(sqlite3Get4byte(aData, 8 + i * 4) - nearby)); + if (d2 < dist) { + closest = i; + dist = d2; + } + } + } else { + closest = 0; + } + + iPage = sqlite3Get4byte(aData, 8 + closest * 4); + testcase(iPage == mxPage); + if (iPage > mxPage) { + rc = SQLITE_CORRUPT_BKPT(); + goto end_allocate_page; + } + testcase(iPage == mxPage); + if (0 == searchList || iPage == nearby) { + int noContent; + pPgno = iPage; + TRACE("ALLOCATE: %d was leaf %d of %d on trunk %d" + + ": %d more free pages\n", + pPgno, closest + 1, k, pTrunk.pgno, n - 1); + rc = sqlite3PagerWrite(pTrunk.pDbPage); + if (rc != 0) + goto end_allocate_page; + if (closest < k - 1) { + Buffer.BlockCopy(aData, (int)(4 + k * 4), aData, 8 + (int)closest * 4, 4);//memcpy( aData[8 + closest * 4], ref aData[4 + k * 4], 4 ); + } + sqlite3Put4byte(aData, (u32)4, (k - 1));// sqlite3Put4byte( aData, 4, k - 1 ); + noContent = !btreeGetHasContent(pBt, pPgno) ? 1 : 0; + rc = btreeGetPage(pBt, pPgno, ref ppPage, noContent); + if (rc == SQLITE_OK) { + rc = sqlite3PagerWrite((ppPage).pDbPage); + if (rc != SQLITE_OK) { + releasePage(ppPage); + } + } + searchList = 0; + } + } + releasePage(pPrevTrunk); + pPrevTrunk = null; + } while (searchList != 0); + } else { + /* There are no pages on the freelist, so create a new page at the + ** end of the file */ + rc = sqlite3PagerWrite(pBt.pPage1.pDbPage); + if (rc != 0) + return rc; + pBt.nPage++; + if (pBt.nPage == PENDING_BYTE_PAGE(pBt)) + pBt.nPage++; #if !SQLITE_OMIT_AUTOVACUUM - if ( pBt.autoVacuum && PTRMAP_ISPAGE( pBt, pBt.nPage ) ) - { - /* If pPgno refers to a pointer-map page, allocate two new pages - ** at the end of the file instead of one. The first allocated page - ** becomes a new pointer-map page, the second is used by the caller. - */ - MemPage pPg = null; - TRACE( "ALLOCATE: %d from end of file (pointer-map page)\n", pPgno ); - Debug.Assert( pBt.nPage != PENDING_BYTE_PAGE( pBt ) ); - rc = btreeGetPage( pBt, pBt.nPage, ref pPg, 1 ); - if ( rc == SQLITE_OK ) - { - rc = sqlite3PagerWrite( pPg.pDbPage ); - releasePage( pPg ); - } - if ( rc != 0 ) - return rc; - pBt.nPage++; - if ( pBt.nPage == PENDING_BYTE_PAGE( pBt ) ) - { - pBt.nPage++; - } - } + if (pBt.autoVacuum && PTRMAP_ISPAGE(pBt, pBt.nPage)) { + /* If pPgno refers to a pointer-map page, allocate two new pages + ** at the end of the file instead of one. The first allocated page + ** becomes a new pointer-map page, the second is used by the caller. + */ + MemPage pPg = null; + TRACE("ALLOCATE: %d from end of file (pointer-map page)\n", pPgno); + Debug.Assert(pBt.nPage != PENDING_BYTE_PAGE(pBt)); + rc = btreeGetPage(pBt, pBt.nPage, ref pPg, 1); + if (rc == SQLITE_OK) { + rc = sqlite3PagerWrite(pPg.pDbPage); + releasePage(pPg); + } + if (rc != 0) + return rc; + pBt.nPage++; + if (pBt.nPage == PENDING_BYTE_PAGE(pBt)) { + pBt.nPage++; + } + } #endif - sqlite3Put4byte( pBt.pPage1.aData, (u32)28, pBt.nPage ); - pPgno = pBt.nPage; - - Debug.Assert( pPgno != PENDING_BYTE_PAGE( pBt ) ); - rc = btreeGetPage( pBt, pPgno, ref ppPage, 1 ); - if ( rc != 0 ) - return rc; - rc = sqlite3PagerWrite( ( ppPage ).pDbPage ); - if ( rc != SQLITE_OK ) - { - releasePage( ppPage ); - } - TRACE( "ALLOCATE: %d from end of file\n", pPgno ); - } + sqlite3Put4byte(pBt.pPage1.aData, (u32)28, pBt.nPage); + pPgno = pBt.nPage; + + Debug.Assert(pPgno != PENDING_BYTE_PAGE(pBt)); + rc = btreeGetPage(pBt, pPgno, ref ppPage, 1); + if (rc != 0) + return rc; + rc = sqlite3PagerWrite((ppPage).pDbPage); + if (rc != SQLITE_OK) { + releasePage(ppPage); + } + TRACE("ALLOCATE: %d from end of file\n", pPgno); + } - Debug.Assert( pPgno != PENDING_BYTE_PAGE( pBt ) ); + Debug.Assert(pPgno != PENDING_BYTE_PAGE(pBt)); + + end_allocate_page: + releasePage(pTrunk); + releasePage(pPrevTrunk); + if (rc == SQLITE_OK) { + if (sqlite3PagerPageRefcount((ppPage).pDbPage) > 1) { + releasePage(ppPage); + return SQLITE_CORRUPT_BKPT(); + } + (ppPage).isInit = 0; + } else { + ppPage = null; + } + Debug.Assert(rc != SQLITE_OK || sqlite3PagerIswriteable((ppPage).pDbPage)); + return rc; + } -end_allocate_page: - releasePage( pTrunk ); - releasePage( pPrevTrunk ); - if ( rc == SQLITE_OK ) - { - if ( sqlite3PagerPageRefcount( ( ppPage ).pDbPage ) > 1 ) - { - releasePage( ppPage ); - return SQLITE_CORRUPT_BKPT(); - } - ( ppPage ).isInit = 0; - } - else - { - ppPage = null; - } - Debug.Assert( rc != SQLITE_OK || sqlite3PagerIswriteable( ( ppPage ).pDbPage ) ); - return rc; -} + /* + ** This function is used to add page iPage to the database file free-list. + ** It is assumed that the page is not already a part of the free-list. + ** + ** The value passed as the second argument to this function is optional. + ** If the caller happens to have a pointer to the MemPage object + ** corresponding to page iPage handy, it may pass it as the second value. + ** Otherwise, it may pass NULL. + ** + ** If a pointer to a MemPage object is passed as the second argument, + ** its reference count is not altered by this function. + */ + static int freePage2(BtShared pBt, MemPage pMemPage, Pgno iPage) { + MemPage pTrunk = null; /* Free-list trunk page */ + Pgno iTrunk = 0; /* Page number of free-list trunk page */ + MemPage pPage1 = pBt.pPage1; /* Local reference to page 1 */ + MemPage pPage; /* Page being freed. May be NULL. */ + int rc; /* Return Code */ + int nFree; /* Initial number of pages on free-list */ + + Debug.Assert(sqlite3_mutex_held(pBt.mutex)); + Debug.Assert(iPage > 1); + Debug.Assert(null == pMemPage || pMemPage.pgno == iPage); + + if (pMemPage != null) { + pPage = pMemPage; + sqlite3PagerRef(pPage.pDbPage); + } else { + pPage = btreePageLookup(pBt, iPage); + } -/* -** This function is used to add page iPage to the database file free-list. -** It is assumed that the page is not already a part of the free-list. -** -** The value passed as the second argument to this function is optional. -** If the caller happens to have a pointer to the MemPage object -** corresponding to page iPage handy, it may pass it as the second value. -** Otherwise, it may pass NULL. -** -** If a pointer to a MemPage object is passed as the second argument, -** its reference count is not altered by this function. -*/ -static int freePage2( BtShared pBt, MemPage pMemPage, Pgno iPage ) -{ - MemPage pTrunk = null; /* Free-list trunk page */ - Pgno iTrunk = 0; /* Page number of free-list trunk page */ - MemPage pPage1 = pBt.pPage1; /* Local reference to page 1 */ - MemPage pPage; /* Page being freed. May be NULL. */ - int rc; /* Return Code */ - int nFree; /* Initial number of pages on free-list */ - - Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); - Debug.Assert( iPage > 1 ); - Debug.Assert( null == pMemPage || pMemPage.pgno == iPage ); - - if ( pMemPage != null ) - { - pPage = pMemPage; - sqlite3PagerRef( pPage.pDbPage ); - } - else - { - pPage = btreePageLookup( pBt, iPage ); - } - - /* Increment the free page count on pPage1 */ - rc = sqlite3PagerWrite( pPage1.pDbPage ); - if ( rc != 0 ) - goto freepage_out; - nFree = (int)sqlite3Get4byte( pPage1.aData, 36 ); - sqlite3Put4byte( pPage1.aData, 36, nFree + 1 ); - - if ( pBt.secureDelete ) - { - /* If the secure_delete option is enabled, then - ** always fully overwrite deleted information with zeros. - */ - if ( ( null == pPage && ( ( rc = btreeGetPage( pBt, iPage, ref pPage, 0 ) ) != 0 ) ) - || ( ( rc = sqlite3PagerWrite( pPage.pDbPage ) ) != 0 ) - ) - { - goto freepage_out; - } - Array.Clear( pPage.aData, 0, (int)pPage.pBt.pageSize );//memset(pPage->aData, 0, pPage->pBt->pageSize); - } + /* Increment the free page count on pPage1 */ + rc = sqlite3PagerWrite(pPage1.pDbPage); + if (rc != 0) + goto freepage_out; + nFree = (int)sqlite3Get4byte(pPage1.aData, 36); + sqlite3Put4byte(pPage1.aData, 36, nFree + 1); + + if (pBt.secureDelete) { + /* If the secure_delete option is enabled, then + ** always fully overwrite deleted information with zeros. + */ + if ((null == pPage && ((rc = btreeGetPage(pBt, iPage, ref pPage, 0)) != 0)) + || ((rc = sqlite3PagerWrite(pPage.pDbPage)) != 0) + ) { + goto freepage_out; + } + Array.Clear(pPage.aData, 0, (int)pPage.pBt.pageSize);//memset(pPage->aData, 0, pPage->pBt->pageSize); + } - /* If the database supports auto-vacuum, write an entry in the pointer-map - ** to indicate that the page is free. - */ + /* If the database supports auto-vacuum, write an entry in the pointer-map + ** to indicate that the page is free. + */ #if !SQLITE_OMIT_AUTOVACUUM // if ( ISAUTOVACUUM ) - if ( pBt.autoVacuum ) + if (pBt.autoVacuum) #else if (false) #endif - { - ptrmapPut( pBt, iPage, PTRMAP_FREEPAGE, 0, ref rc ); - if ( rc != 0 ) - goto freepage_out; - } - - /* Now manipulate the actual database free-list structure. There are two - ** possibilities. If the free-list is currently empty, or if the first - ** trunk page in the free-list is full, then this page will become a - ** new free-list trunk page. Otherwise, it will become a leaf of the - ** first trunk page in the current free-list. This block tests if it - ** is possible to add the page as a new free-list leaf. - */ - if ( nFree != 0 ) - { - u32 nLeaf; /* Initial number of leaf cells on trunk page */ - - iTrunk = sqlite3Get4byte( pPage1.aData, 32 ); - rc = btreeGetPage( pBt, iTrunk, ref pTrunk, 0 ); - if ( rc != SQLITE_OK ) - { - goto freepage_out; - } + { + ptrmapPut(pBt, iPage, PTRMAP_FREEPAGE, 0, ref rc); + if (rc != 0) + goto freepage_out; + } - nLeaf = sqlite3Get4byte( pTrunk.aData, 4 ); - Debug.Assert( pBt.usableSize > 32 ); - if ( nLeaf > (u32)pBt.usableSize / 4 - 2 ) - { - rc = SQLITE_CORRUPT_BKPT(); - goto freepage_out; - } - if ( nLeaf < (u32)pBt.usableSize / 4 - 8 ) - { - /* In this case there is room on the trunk page to insert the page - ** being freed as a new leaf. - ** - ** Note that the trunk page is not really full until it contains - ** usableSize/4 - 2 entries, not usableSize/4 - 8 entries as we have - ** coded. But due to a coding error in versions of SQLite prior to - ** 3.6.0, databases with freelist trunk pages holding more than - ** usableSize/4 - 8 entries will be reported as corrupt. In order - ** to maintain backwards compatibility with older versions of SQLite, - ** we will continue to restrict the number of entries to usableSize/4 - 8 - ** for now. At some point in the future (once everyone has upgraded - ** to 3.6.0 or later) we should consider fixing the conditional above - ** to read "usableSize/4-2" instead of "usableSize/4-8". - */ - rc = sqlite3PagerWrite( pTrunk.pDbPage ); - if ( rc == SQLITE_OK ) - { - sqlite3Put4byte( pTrunk.aData, (u32)4, nLeaf + 1 ); - sqlite3Put4byte( pTrunk.aData, (u32)8 + nLeaf * 4, iPage ); - if ( pPage != null && !pBt.secureDelete ) - { - sqlite3PagerDontWrite( pPage.pDbPage ); - } - rc = btreeSetHasContent( pBt, iPage ); - } - TRACE( "FREE-PAGE: %d leaf on trunk page %d\n", iPage, pTrunk.pgno ); - goto freepage_out; - } - } - - /* If control flows to this point, then it was not possible to add the - ** the page being freed as a leaf page of the first trunk in the free-list. - ** Possibly because the free-list is empty, or possibly because the - ** first trunk in the free-list is full. Either way, the page being freed - ** will become the new first trunk page in the free-list. - */ - if ( pPage == null && SQLITE_OK != ( rc = btreeGetPage( pBt, iPage, ref pPage, 0 ) ) ) - { - goto freepage_out; - } - rc = sqlite3PagerWrite( pPage.pDbPage ); - if ( rc != SQLITE_OK ) - { - goto freepage_out; - } - sqlite3Put4byte( pPage.aData, iTrunk ); - sqlite3Put4byte( pPage.aData, 4, 0 ); - sqlite3Put4byte( pPage1.aData, (u32)32, iPage ); - TRACE( "FREE-PAGE: %d new trunk page replacing %d\n", pPage.pgno, iTrunk ); - -freepage_out: - if ( pPage != null ) - { - pPage.isInit = 0; - } - releasePage( pPage ); - releasePage( pTrunk ); - return rc; -} -static void freePage( MemPage pPage, ref int pRC ) -{ - if ( ( pRC ) == SQLITE_OK ) - { - pRC = freePage2( pPage.pBt, pPage, pPage.pgno ); - } -} + /* Now manipulate the actual database free-list structure. There are two + ** possibilities. If the free-list is currently empty, or if the first + ** trunk page in the free-list is full, then this page will become a + ** new free-list trunk page. Otherwise, it will become a leaf of the + ** first trunk page in the current free-list. This block tests if it + ** is possible to add the page as a new free-list leaf. + */ + if (nFree != 0) { + u32 nLeaf; /* Initial number of leaf cells on trunk page */ + + iTrunk = sqlite3Get4byte(pPage1.aData, 32); + rc = btreeGetPage(pBt, iTrunk, ref pTrunk, 0); + if (rc != SQLITE_OK) { + goto freepage_out; + } + + nLeaf = sqlite3Get4byte(pTrunk.aData, 4); + Debug.Assert(pBt.usableSize > 32); + if (nLeaf > (u32)pBt.usableSize / 4 - 2) { + rc = SQLITE_CORRUPT_BKPT(); + goto freepage_out; + } + if (nLeaf < (u32)pBt.usableSize / 4 - 8) { + /* In this case there is room on the trunk page to insert the page + ** being freed as a new leaf. + ** + ** Note that the trunk page is not really full until it contains + ** usableSize/4 - 2 entries, not usableSize/4 - 8 entries as we have + ** coded. But due to a coding error in versions of SQLite prior to + ** 3.6.0, databases with freelist trunk pages holding more than + ** usableSize/4 - 8 entries will be reported as corrupt. In order + ** to maintain backwards compatibility with older versions of SQLite, + ** we will continue to restrict the number of entries to usableSize/4 - 8 + ** for now. At some point in the future (once everyone has upgraded + ** to 3.6.0 or later) we should consider fixing the conditional above + ** to read "usableSize/4-2" instead of "usableSize/4-8". + */ + rc = sqlite3PagerWrite(pTrunk.pDbPage); + if (rc == SQLITE_OK) { + sqlite3Put4byte(pTrunk.aData, (u32)4, nLeaf + 1); + sqlite3Put4byte(pTrunk.aData, (u32)8 + nLeaf * 4, iPage); + if (pPage != null && !pBt.secureDelete) { + sqlite3PagerDontWrite(pPage.pDbPage); + } + rc = btreeSetHasContent(pBt, iPage); + } + TRACE("FREE-PAGE: %d leaf on trunk page %d\n", iPage, pTrunk.pgno); + goto freepage_out; + } + } -/* -** Free any overflow pages associated with the given Cell. -*/ -static int clearCell( MemPage pPage, int pCell ) -{ - BtShared pBt = pPage.pBt; - CellInfo info = new CellInfo(); - Pgno ovflPgno; - int rc; - int nOvfl; - u32 ovflPageSize; - - Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); - btreeParseCellPtr( pPage, pCell, ref info ); - if ( info.iOverflow == 0 ) - { - return SQLITE_OK; /* No overflow pages. Return without doing anything */ - } - ovflPgno = sqlite3Get4byte( pPage.aData, pCell, info.iOverflow ); - Debug.Assert( pBt.usableSize > 4 ); - ovflPageSize = (u16)( pBt.usableSize - 4 ); - nOvfl = (int)( ( info.nPayload - info.nLocal + ovflPageSize - 1 ) / ovflPageSize ); - Debug.Assert( ovflPgno == 0 || nOvfl > 0 ); - while ( nOvfl-- != 0 ) - { - Pgno iNext = 0; - MemPage pOvfl = null; - if ( ovflPgno < 2 || ovflPgno > btreePagecount( pBt ) ) - { - /* 0 is not a legal page number and page 1 cannot be an - ** overflow page. Therefore if ovflPgno<2 or past the end of the - ** file the database must be corrupt. */ - return SQLITE_CORRUPT_BKPT(); - } - if ( nOvfl != 0 ) - { - rc = getOverflowPage( pBt, ovflPgno, out pOvfl, out iNext ); - if ( rc != 0 ) - return rc; - } + /* If control flows to this point, then it was not possible to add the + ** the page being freed as a leaf page of the first trunk in the free-list. + ** Possibly because the free-list is empty, or possibly because the + ** first trunk in the free-list is full. Either way, the page being freed + ** will become the new first trunk page in the free-list. + */ + if (pPage == null && SQLITE_OK != (rc = btreeGetPage(pBt, iPage, ref pPage, 0))) { + goto freepage_out; + } + rc = sqlite3PagerWrite(pPage.pDbPage); + if (rc != SQLITE_OK) { + goto freepage_out; + } + sqlite3Put4byte(pPage.aData, iTrunk); + sqlite3Put4byte(pPage.aData, 4, 0); + sqlite3Put4byte(pPage1.aData, (u32)32, iPage); + TRACE("FREE-PAGE: %d new trunk page replacing %d\n", pPage.pgno, iTrunk); + + freepage_out: + if (pPage != null) { + pPage.isInit = 0; + } + releasePage(pPage); + releasePage(pTrunk); + return rc; + } + static void freePage(MemPage pPage, ref int pRC) { + if ((pRC) == SQLITE_OK) { + pRC = freePage2(pPage.pBt, pPage, pPage.pgno); + } + } - if ( ( pOvfl != null || ( ( pOvfl = btreePageLookup( pBt, ovflPgno ) ) != null ) ) - && sqlite3PagerPageRefcount( pOvfl.pDbPage ) != 1 - ) - { - /* There is no reason any cursor should have an outstanding reference - ** to an overflow page belonging to a cell that is being deleted/updated. - ** So if there exists more than one reference to this page, then it - ** must not really be an overflow page and the database must be corrupt. - ** It is helpful to detect this before calling freePage2(), as - ** freePage2() may zero the page contents if secure-delete mode is - ** enabled. If this 'overflow' page happens to be a page that the - ** caller is iterating through or using in some other way, this - ** can be problematic. - */ - rc = SQLITE_CORRUPT_BKPT(); - } - else - { - rc = freePage2( pBt, pOvfl, ovflPgno ); - } - if ( pOvfl != null ) - { - sqlite3PagerUnref( pOvfl.pDbPage ); - } - if ( rc != 0 ) - return rc; - ovflPgno = iNext; - } - return SQLITE_OK; -} + /* + ** Free any overflow pages associated with the given Cell. + */ + static int clearCell(MemPage pPage, int pCell) { + BtShared pBt = pPage.pBt; + CellInfo info = new CellInfo(); + Pgno ovflPgno; + int rc; + int nOvfl; + u32 ovflPageSize; + + Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); + btreeParseCellPtr(pPage, pCell, ref info); + if (info.iOverflow == 0) { + return SQLITE_OK; /* No overflow pages. Return without doing anything */ + } + ovflPgno = sqlite3Get4byte(pPage.aData, pCell, info.iOverflow); + Debug.Assert(pBt.usableSize > 4); + ovflPageSize = (u16)(pBt.usableSize - 4); + nOvfl = (int)((info.nPayload - info.nLocal + ovflPageSize - 1) / ovflPageSize); + Debug.Assert(ovflPgno == 0 || nOvfl > 0); + while (nOvfl-- != 0) { + Pgno iNext = 0; + MemPage pOvfl = null; + if (ovflPgno < 2 || ovflPgno > btreePagecount(pBt)) { + /* 0 is not a legal page number and page 1 cannot be an + ** overflow page. Therefore if ovflPgno<2 or past the end of the + ** file the database must be corrupt. */ + return SQLITE_CORRUPT_BKPT(); + } + if (nOvfl != 0) { + rc = getOverflowPage(pBt, ovflPgno, out pOvfl, out iNext); + if (rc != 0) + return rc; + } + + if ((pOvfl != null || ((pOvfl = btreePageLookup(pBt, ovflPgno)) != null)) + && sqlite3PagerPageRefcount(pOvfl.pDbPage) != 1 + ) { + /* There is no reason any cursor should have an outstanding reference + ** to an overflow page belonging to a cell that is being deleted/updated. + ** So if there exists more than one reference to this page, then it + ** must not really be an overflow page and the database must be corrupt. + ** It is helpful to detect this before calling freePage2(), as + ** freePage2() may zero the page contents if secure-delete mode is + ** enabled. If this 'overflow' page happens to be a page that the + ** caller is iterating through or using in some other way, this + ** can be problematic. + */ + rc = SQLITE_CORRUPT_BKPT(); + } else { + rc = freePage2(pBt, pOvfl, ovflPgno); + } + if (pOvfl != null) { + sqlite3PagerUnref(pOvfl.pDbPage); + } + if (rc != 0) + return rc; + ovflPgno = iNext; + } + return SQLITE_OK; + } -/* -** Create the byte sequence used to represent a cell on page pPage -** and write that byte sequence into pCell[]. Overflow pages are -** allocated and filled in as necessary. The calling procedure -** is responsible for making sure sufficient space has been allocated -** for pCell[]. -** -** Note that pCell does not necessary need to point to the pPage.aData -** area. pCell might point to some temporary storage. The cell will -** be constructed in this temporary area then copied into pPage.aData -** later. -*/ -static int fillInCell( -MemPage pPage, /* The page that contains the cell */ -byte[] pCell, /* Complete text of the cell */ -byte[] pKey, i64 nKey, /* The key */ -byte[] pData, int nData, /* The data */ -int nZero, /* Extra zero bytes to append to pData */ -ref int pnSize /* Write cell size here */ -) -{ - int nPayload; - u8[] pSrc; - int pSrcIndex = 0; - int nSrc, n, rc; - int spaceLeft; - MemPage pOvfl = null; - MemPage pToRelease = null; - byte[] pPrior; - int pPriorIndex = 0; - byte[] pPayload; - int pPayloadIndex = 0; - BtShared pBt = pPage.pBt; - Pgno pgnoOvfl = 0; - int nHeader; - CellInfo info = new CellInfo(); - - Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); - - /* pPage is not necessarily writeable since pCell might be auxiliary - ** buffer space that is separate from the pPage buffer area */ - // TODO -- Determine if the following Assert is needed under c# - //Debug.Assert( pCell < pPage.aData || pCell >= &pPage.aData[pBt.pageSize] - // || sqlite3PagerIswriteable(pPage.pDbPage) ); - - /* Fill in the header. */ - nHeader = 0; - if ( 0 == pPage.leaf ) - { - nHeader += 4; - } - if ( pPage.hasData != 0 ) - { - nHeader += (int)putVarint( pCell, nHeader, (int)( nData + nZero ) ); //putVarint( pCell[nHeader], nData + nZero ); - } - else - { - nData = nZero = 0; - } - nHeader += putVarint( pCell, nHeader, (u64)nKey ); //putVarint( pCell[nHeader], *(u64*)&nKey ); - btreeParseCellPtr( pPage, pCell, ref info ); - Debug.Assert( info.nHeader == nHeader ); - Debug.Assert( info.nKey == nKey ); - Debug.Assert( info.nData == (u32)( nData + nZero ) ); - - /* Fill in the payload */ - nPayload = nData + nZero; - if ( pPage.intKey != 0 ) - { - pSrc = pData; - nSrc = nData; - nData = 0; - } - else - { - if ( NEVER( nKey > 0x7fffffff || pKey == null ) ) - { - return SQLITE_CORRUPT_BKPT(); - } - nPayload += (int)nKey; - pSrc = pKey; - nSrc = (int)nKey; - } - pnSize = info.nSize; - spaceLeft = info.nLocal; - // pPayload = &pCell[nHeader]; - pPayload = pCell; - pPayloadIndex = nHeader; - // pPrior = &pCell[info.iOverflow]; - pPrior = pCell; - pPriorIndex = info.iOverflow; - - while ( nPayload > 0 ) - { - if ( spaceLeft == 0 ) - { + /* + ** Create the byte sequence used to represent a cell on page pPage + ** and write that byte sequence into pCell[]. Overflow pages are + ** allocated and filled in as necessary. The calling procedure + ** is responsible for making sure sufficient space has been allocated + ** for pCell[]. + ** + ** Note that pCell does not necessary need to point to the pPage.aData + ** area. pCell might point to some temporary storage. The cell will + ** be constructed in this temporary area then copied into pPage.aData + ** later. + */ + static int fillInCell( + MemPage pPage, /* The page that contains the cell */ + byte[] pCell, /* Complete text of the cell */ + byte[] pKey, i64 nKey, /* The key */ + byte[] pData, int nData, /* The data */ + int nZero, /* Extra zero bytes to append to pData */ + ref int pnSize /* Write cell size here */ + ) { + int nPayload; + u8[] pSrc; + int pSrcIndex = 0; + int nSrc, n, rc; + int spaceLeft; + MemPage pOvfl = null; + MemPage pToRelease = null; + byte[] pPrior; + int pPriorIndex = 0; + byte[] pPayload; + int pPayloadIndex = 0; + BtShared pBt = pPage.pBt; + Pgno pgnoOvfl = 0; + int nHeader; + CellInfo info = new CellInfo(); + + Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); + + /* pPage is not necessarily writeable since pCell might be auxiliary + ** buffer space that is separate from the pPage buffer area */ + // TODO -- Determine if the following Assert is needed under c# + //Debug.Assert( pCell < pPage.aData || pCell >= &pPage.aData[pBt.pageSize] + // || sqlite3PagerIswriteable(pPage.pDbPage) ); + + /* Fill in the header. */ + nHeader = 0; + if (0 == pPage.leaf) { + nHeader += 4; + } + if (pPage.hasData != 0) { + nHeader += (int)putVarint(pCell, nHeader, (int)(nData + nZero)); //putVarint( pCell[nHeader], nData + nZero ); + } else { + nData = nZero = 0; + } + nHeader += putVarint(pCell, nHeader, (u64)nKey); //putVarint( pCell[nHeader], *(u64*)&nKey ); + btreeParseCellPtr(pPage, pCell, ref info); + Debug.Assert(info.nHeader == nHeader); + Debug.Assert(info.nKey == nKey); + Debug.Assert(info.nData == (u32)(nData + nZero)); + + /* Fill in the payload */ + nPayload = nData + nZero; + if (pPage.intKey != 0) { + pSrc = pData; + nSrc = nData; + nData = 0; + } else { + if (NEVER(nKey > 0x7fffffff || pKey == null)) { + return SQLITE_CORRUPT_BKPT(); + } + nPayload += (int)nKey; + pSrc = pKey; + nSrc = (int)nKey; + } + pnSize = info.nSize; + spaceLeft = info.nLocal; + // pPayload = &pCell[nHeader]; + pPayload = pCell; + pPayloadIndex = nHeader; + // pPrior = &pCell[info.iOverflow]; + pPrior = pCell; + pPriorIndex = info.iOverflow; + + while (nPayload > 0) { + if (spaceLeft == 0) { #if !SQLITE_OMIT_AUTOVACUUM - Pgno pgnoPtrmap = pgnoOvfl; /* Overflow page pointer-map entry page */ - if ( pBt.autoVacuum ) - { - do - { - pgnoOvfl++; - } while ( - PTRMAP_ISPAGE( pBt, pgnoOvfl ) || pgnoOvfl == PENDING_BYTE_PAGE( pBt ) - ); - } + Pgno pgnoPtrmap = pgnoOvfl; /* Overflow page pointer-map entry page */ + if (pBt.autoVacuum) { + do { + pgnoOvfl++; + } while ( + PTRMAP_ISPAGE(pBt, pgnoOvfl) || pgnoOvfl == PENDING_BYTE_PAGE(pBt) + ); + } #endif - rc = allocateBtreePage( pBt, ref pOvfl, ref pgnoOvfl, pgnoOvfl, 0 ); + rc = allocateBtreePage(pBt, ref pOvfl, ref pgnoOvfl, pgnoOvfl, 0); #if !SQLITE_OMIT_AUTOVACUUM - /* If the database supports auto-vacuum, and the second or subsequent -** overflow page is being allocated, add an entry to the pointer-map -** for that page now. -** -** If this is the first overflow page, then write a partial entry -** to the pointer-map. If we write nothing to this pointer-map slot, -** then the optimistic overflow chain processing in clearCell() -** may misinterpret the uninitialised values and delete the -** wrong pages from the database. -*/ - if ( pBt.autoVacuum && rc == SQLITE_OK ) - { - u8 eType = (u8)( pgnoPtrmap != 0 ? PTRMAP_OVERFLOW2 : PTRMAP_OVERFLOW1 ); - ptrmapPut( pBt, pgnoOvfl, eType, pgnoPtrmap, ref rc ); - if ( rc != 0 ) - { - releasePage( pOvfl ); - } - } + /* If the database supports auto-vacuum, and the second or subsequent + ** overflow page is being allocated, add an entry to the pointer-map + ** for that page now. + ** + ** If this is the first overflow page, then write a partial entry + ** to the pointer-map. If we write nothing to this pointer-map slot, + ** then the optimistic overflow chain processing in clearCell() + ** may misinterpret the uninitialised values and delete the + ** wrong pages from the database. + */ + if (pBt.autoVacuum && rc == SQLITE_OK) { + u8 eType = (u8)(pgnoPtrmap != 0 ? PTRMAP_OVERFLOW2 : PTRMAP_OVERFLOW1); + ptrmapPut(pBt, pgnoOvfl, eType, pgnoPtrmap, ref rc); + if (rc != 0) { + releasePage(pOvfl); + } + } #endif - if ( rc != 0 ) - { - releasePage( pToRelease ); - return rc; - } - - /* If pToRelease is not zero than pPrior points into the data area - ** of pToRelease. Make sure pToRelease is still writeable. */ - Debug.Assert( pToRelease == null || sqlite3PagerIswriteable( pToRelease.pDbPage ) ); - - /* If pPrior is part of the data area of pPage, then make sure pPage - ** is still writeable */ - // TODO -- Determine if the following Assert is needed under c# - //Debug.Assert( pPrior < pPage.aData || pPrior >= &pPage.aData[pBt.pageSize] - // || sqlite3PagerIswriteable(pPage.pDbPage) ); - - sqlite3Put4byte( pPrior, pPriorIndex, pgnoOvfl ); - releasePage( pToRelease ); - pToRelease = pOvfl; - pPrior = pOvfl.aData; - pPriorIndex = 0; - sqlite3Put4byte( pPrior, 0 ); - pPayload = pOvfl.aData; - pPayloadIndex = 4; //&pOvfl.aData[4]; - spaceLeft = (int)pBt.usableSize - 4; - } - n = nPayload; - if ( n > spaceLeft ) - n = spaceLeft; - - /* If pToRelease is not zero than pPayload points into the data area - ** of pToRelease. Make sure pToRelease is still writeable. */ - Debug.Assert( pToRelease == null || sqlite3PagerIswriteable( pToRelease.pDbPage ) ); - - /* If pPayload is part of the data area of pPage, then make sure pPage - ** is still writeable */ - // TODO -- Determine if the following Assert is needed under c# - //Debug.Assert( pPayload < pPage.aData || pPayload >= &pPage.aData[pBt.pageSize] - // || sqlite3PagerIswriteable(pPage.pDbPage) ); - - if ( nSrc > 0 ) - { - if ( n > nSrc ) - n = nSrc; - Debug.Assert( pSrc != null ); - Buffer.BlockCopy( pSrc, pSrcIndex, pPayload, pPayloadIndex, n );//memcpy(pPayload, pSrc, n); - } - else - { - byte[] pZeroBlob = sqlite3Malloc( n ); // memset(pPayload, 0, n); - Buffer.BlockCopy( pZeroBlob, 0, pPayload, pPayloadIndex, n ); - } - nPayload -= n; - pPayloadIndex += n;// pPayload += n; - pSrcIndex += n;// pSrc += n; - nSrc -= n; - spaceLeft -= n; - if ( nSrc == 0 ) - { - nSrc = nData; - pSrc = pData; - } - } - releasePage( pToRelease ); - return SQLITE_OK; -} - -/* -** Remove the i-th cell from pPage. This routine effects pPage only. -** The cell content is not freed or deallocated. It is assumed that -** the cell content has been copied someplace else. This routine just -** removes the reference to the cell from pPage. -** -** "sz" must be the number of bytes in the cell. -*/ -static void dropCell( MemPage pPage, int idx, int sz, ref int pRC ) -{ - u32 pc; /* Offset to cell content of cell being deleted */ - u8[] data; /* pPage.aData */ - int ptr; /* Used to move bytes around within data[] */ - int endPtr; /* End of loop */ - int rc; /* The return code */ - int hdr; /* Beginning of the header. 0 most pages. 100 page 1 */ - - if ( pRC != 0 ) - return; + if (rc != 0) { + releasePage(pToRelease); + return rc; + } + + /* If pToRelease is not zero than pPrior points into the data area + ** of pToRelease. Make sure pToRelease is still writeable. */ + Debug.Assert(pToRelease == null || sqlite3PagerIswriteable(pToRelease.pDbPage)); + + /* If pPrior is part of the data area of pPage, then make sure pPage + ** is still writeable */ + // TODO -- Determine if the following Assert is needed under c# + //Debug.Assert( pPrior < pPage.aData || pPrior >= &pPage.aData[pBt.pageSize] + // || sqlite3PagerIswriteable(pPage.pDbPage) ); + + sqlite3Put4byte(pPrior, pPriorIndex, pgnoOvfl); + releasePage(pToRelease); + pToRelease = pOvfl; + pPrior = pOvfl.aData; + pPriorIndex = 0; + sqlite3Put4byte(pPrior, 0); + pPayload = pOvfl.aData; + pPayloadIndex = 4; //&pOvfl.aData[4]; + spaceLeft = (int)pBt.usableSize - 4; + } + n = nPayload; + if (n > spaceLeft) + n = spaceLeft; + + /* If pToRelease is not zero than pPayload points into the data area + ** of pToRelease. Make sure pToRelease is still writeable. */ + Debug.Assert(pToRelease == null || sqlite3PagerIswriteable(pToRelease.pDbPage)); + + /* If pPayload is part of the data area of pPage, then make sure pPage + ** is still writeable */ + // TODO -- Determine if the following Assert is needed under c# + //Debug.Assert( pPayload < pPage.aData || pPayload >= &pPage.aData[pBt.pageSize] + // || sqlite3PagerIswriteable(pPage.pDbPage) ); + + if (nSrc > 0) { + if (n > nSrc) + n = nSrc; + Debug.Assert(pSrc != null); + Buffer.BlockCopy(pSrc, pSrcIndex, pPayload, pPayloadIndex, n);//memcpy(pPayload, pSrc, n); + } else { + byte[] pZeroBlob = sqlite3Malloc(n); // memset(pPayload, 0, n); + Buffer.BlockCopy(pZeroBlob, 0, pPayload, pPayloadIndex, n); + } + nPayload -= n; + pPayloadIndex += n;// pPayload += n; + pSrcIndex += n;// pSrc += n; + nSrc -= n; + spaceLeft -= n; + if (nSrc == 0) { + nSrc = nData; + pSrc = pData; + } + } + releasePage(pToRelease); + return SQLITE_OK; + } - Debug.Assert( idx >= 0 && idx < pPage.nCell ); + /* + ** Remove the i-th cell from pPage. This routine effects pPage only. + ** The cell content is not freed or deallocated. It is assumed that + ** the cell content has been copied someplace else. This routine just + ** removes the reference to the cell from pPage. + ** + ** "sz" must be the number of bytes in the cell. + */ + static void dropCell(MemPage pPage, int idx, int sz, ref int pRC) { + u32 pc; /* Offset to cell content of cell being deleted */ + u8[] data; /* pPage.aData */ + int ptr; /* Used to move bytes around within data[] */ + int endPtr; /* End of loop */ + int rc; /* The return code */ + int hdr; /* Beginning of the header. 0 most pages. 100 page 1 */ + + if (pRC != 0) + return; + + Debug.Assert(idx >= 0 && idx < pPage.nCell); #if SQLITE_DEBUG - Debug.Assert( sz == cellSize( pPage, idx ) ); + Debug.Assert(sz == cellSize(pPage, idx)); #endif - Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); - Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); - data = pPage.aData; - ptr = pPage.cellOffset + 2 * idx; //ptr = &data[pPage.cellOffset + 2 * idx]; - pc = (u32)get2byte( data, ptr ); - hdr = pPage.hdrOffset; - testcase( pc == get2byte( data, hdr + 5 ) ); - testcase( pc + sz == pPage.pBt.usableSize ); - if ( pc < (u32)get2byte( data, hdr + 5 ) || pc + sz > pPage.pBt.usableSize ) - { - pRC = SQLITE_CORRUPT_BKPT(); - return; - } - rc = freeSpace( pPage, pc, sz ); - if ( rc != 0 ) - { - pRC = rc; - return; - } - //endPtr = &data[pPage->cellOffset + 2*pPage->nCell - 2]; - //assert( (SQLITE_PTR_TO_INT(ptr)&1)==0 ); /* ptr is always 2-byte aligned */ - //while( ptr> 8 ); - data[pPage.hdrOffset + 4] = (byte)( pPage.nCell ); //put2byte( data, hdr + 3, pPage.nCell ); - pPage.nFree += 2; -} + Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); + Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); + data = pPage.aData; + ptr = pPage.cellOffset + 2 * idx; //ptr = &data[pPage.cellOffset + 2 * idx]; + pc = (u32)get2byte(data, ptr); + hdr = pPage.hdrOffset; + testcase(pc == get2byte(data, hdr + 5)); + testcase(pc + sz == pPage.pBt.usableSize); + if (pc < (u32)get2byte(data, hdr + 5) || pc + sz > pPage.pBt.usableSize) { + pRC = SQLITE_CORRUPT_BKPT(); + return; + } + rc = freeSpace(pPage, pc, sz); + if (rc != 0) { + pRC = rc; + return; + } + //endPtr = &data[pPage->cellOffset + 2*pPage->nCell - 2]; + //assert( (SQLITE_PTR_TO_INT(ptr)&1)==0 ); /* ptr is always 2-byte aligned */ + //while( ptr> 8); + data[pPage.hdrOffset + 4] = (byte)(pPage.nCell); //put2byte( data, hdr + 3, pPage.nCell ); + pPage.nFree += 2; + } -/* -** Insert a new cell on pPage at cell index "i". pCell points to the -** content of the cell. -** -** If the cell content will fit on the page, then put it there. If it -** will not fit, then make a copy of the cell content into pTemp if -** pTemp is not null. Regardless of pTemp, allocate a new entry -** in pPage.aOvfl[] and make it point to the cell content (either -** in pTemp or the original pCell) and also record its index. -** Allocating a new entry in pPage.aCell[] implies that -** pPage.nOverflow is incremented. -** -** If nSkip is non-zero, then do not copy the first nSkip bytes of the -** cell. The caller will overwrite them after this function returns. If -** nSkip is non-zero, then pCell may not point to an invalid memory location -** (but pCell+nSkip is always valid). -*/ -static void insertCell( -MemPage pPage, /* Page into which we are copying */ -int i, /* New cell becomes the i-th cell of the page */ -u8[] pCell, /* Content of the new cell */ -int sz, /* Bytes of content in pCell */ -u8[] pTemp, /* Temp storage space for pCell, if needed */ -Pgno iChild, /* If non-zero, replace first 4 bytes with this value */ -ref int pRC /* Read and write return code from here */ -) -{ - int idx = 0; /* Where to write new cell content in data[] */ - int j; /* Loop counter */ - int end; /* First byte past the last cell pointer in data[] */ - int ins; /* Index in data[] where new cell pointer is inserted */ - int cellOffset; /* Address of first cell pointer in data[] */ - u8[] data; /* The content of the whole page */ - u8 ptr; /* Used for moving information around in data[] */ - u8 endPtr; /* End of the loop */ - - int nSkip = ( iChild != 0 ? 4 : 0 ); - - if ( pRC != 0 ) - return; - - Debug.Assert( i >= 0 && i <= pPage.nCell + pPage.nOverflow ); - Debug.Assert( pPage.nCell <= MX_CELL( pPage.pBt ) && MX_CELL( pPage.pBt ) <= 10921 ); - Debug.Assert( pPage.nOverflow <= ArraySize( pPage.aOvfl ) ); - Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); - /* The cell should normally be sized correctly. However, when moving a - ** malformed cell from a leaf page to an interior page, if the cell size - ** wanted to be less than 4 but got rounded up to 4 on the leaf, then size - ** might be less than 8 (leaf-size + pointer) on the interior node. Hence - ** the term after the || in the following assert(). */ - Debug.Assert( sz == cellSizePtr( pPage, pCell ) || ( sz == 8 && iChild > 0 ) ); - if ( pPage.nOverflow != 0 || sz + 2 > pPage.nFree ) - { - if ( pTemp != null ) - { - Buffer.BlockCopy( pCell, nSkip, pTemp, nSkip, sz - nSkip );//memcpy(pTemp+nSkip, pCell+nSkip, sz-nSkip); - pCell = pTemp; - } - if ( iChild != 0 ) - { - sqlite3Put4byte( pCell, iChild ); - } - j = pPage.nOverflow++; - Debug.Assert( j < pPage.aOvfl.Length );//(int)(sizeof(pPage.aOvfl)/sizeof(pPage.aOvfl[0])) ); - pPage.aOvfl[j].pCell = pCell; - pPage.aOvfl[j].idx = (u16)i; - } - else - { - int rc = sqlite3PagerWrite( pPage.pDbPage ); - if ( rc != SQLITE_OK ) - { - pRC = rc; - return; - } - Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); - data = pPage.aData; - cellOffset = pPage.cellOffset; - end = cellOffset + 2 * pPage.nCell; - ins = cellOffset + 2 * i; - rc = allocateSpace( pPage, sz, ref idx ); - if ( rc != 0 ) - { - pRC = rc; - return; - } - /* The allocateSpace() routine guarantees the following two properties - ** if it returns success */ - Debug.Assert( idx >= end + 2 ); - Debug.Assert( idx + sz <= (int)pPage.pBt.usableSize ); - pPage.nCell++; - pPage.nFree -= (u16)( 2 + sz ); - Buffer.BlockCopy( pCell, nSkip, data, idx + nSkip, sz - nSkip ); //memcpy( data[idx + nSkip], pCell + nSkip, sz - nSkip ); - if ( iChild != 0 ) - { - sqlite3Put4byte( data, idx, iChild ); - } - //ptr = &data[end]; - //endPtr = &data[ins]; - //assert( ( SQLITE_PTR_TO_INT( ptr ) & 1 ) == 0 ); /* ptr is always 2-byte aligned */ - //while ( ptr > endPtr ) - //{ - // *(u16*)ptr = *(u16*)&ptr[-2]; - // ptr -= 2; - //} - for ( j = end; j > ins; j -= 2 ) - { - data[j + 0] = data[j - 2]; - data[j + 1] = data[j - 1]; - } - put2byte( data, ins, idx ); - put2byte( data, pPage.hdrOffset + 3, pPage.nCell ); + /* + ** Insert a new cell on pPage at cell index "i". pCell points to the + ** content of the cell. + ** + ** If the cell content will fit on the page, then put it there. If it + ** will not fit, then make a copy of the cell content into pTemp if + ** pTemp is not null. Regardless of pTemp, allocate a new entry + ** in pPage.aOvfl[] and make it point to the cell content (either + ** in pTemp or the original pCell) and also record its index. + ** Allocating a new entry in pPage.aCell[] implies that + ** pPage.nOverflow is incremented. + ** + ** If nSkip is non-zero, then do not copy the first nSkip bytes of the + ** cell. The caller will overwrite them after this function returns. If + ** nSkip is non-zero, then pCell may not point to an invalid memory location + ** (but pCell+nSkip is always valid). + */ + static void insertCell( + MemPage pPage, /* Page into which we are copying */ + int i, /* New cell becomes the i-th cell of the page */ + u8[] pCell, /* Content of the new cell */ + int sz, /* Bytes of content in pCell */ + u8[] pTemp, /* Temp storage space for pCell, if needed */ + Pgno iChild, /* If non-zero, replace first 4 bytes with this value */ + ref int pRC /* Read and write return code from here */ + ) { + int idx = 0; /* Where to write new cell content in data[] */ + int j; /* Loop counter */ + int end; /* First byte past the last cell pointer in data[] */ + int ins; /* Index in data[] where new cell pointer is inserted */ + int cellOffset; /* Address of first cell pointer in data[] */ + u8[] data; /* The content of the whole page */ + u8 ptr; /* Used for moving information around in data[] */ + u8 endPtr; /* End of the loop */ + + int nSkip = (iChild != 0 ? 4 : 0); + + if (pRC != 0) + return; + + Debug.Assert(i >= 0 && i <= pPage.nCell + pPage.nOverflow); + Debug.Assert(pPage.nCell <= MX_CELL(pPage.pBt) && MX_CELL(pPage.pBt) <= 10921); + Debug.Assert(pPage.nOverflow <= ArraySize(pPage.aOvfl)); + Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); + /* The cell should normally be sized correctly. However, when moving a + ** malformed cell from a leaf page to an interior page, if the cell size + ** wanted to be less than 4 but got rounded up to 4 on the leaf, then size + ** might be less than 8 (leaf-size + pointer) on the interior node. Hence + ** the term after the || in the following assert(). */ + Debug.Assert(sz == cellSizePtr(pPage, pCell) || (sz == 8 && iChild > 0)); + if (pPage.nOverflow != 0 || sz + 2 > pPage.nFree) { + if (pTemp != null) { + Buffer.BlockCopy(pCell, nSkip, pTemp, nSkip, sz - nSkip);//memcpy(pTemp+nSkip, pCell+nSkip, sz-nSkip); + pCell = pTemp; + } + if (iChild != 0) { + sqlite3Put4byte(pCell, iChild); + } + j = pPage.nOverflow++; + Debug.Assert(j < pPage.aOvfl.Length);//(int)(sizeof(pPage.aOvfl)/sizeof(pPage.aOvfl[0])) ); + pPage.aOvfl[j].pCell = pCell; + pPage.aOvfl[j].idx = (u16)i; + } else { + int rc = sqlite3PagerWrite(pPage.pDbPage); + if (rc != SQLITE_OK) { + pRC = rc; + return; + } + Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); + data = pPage.aData; + cellOffset = pPage.cellOffset; + end = cellOffset + 2 * pPage.nCell; + ins = cellOffset + 2 * i; + rc = allocateSpace(pPage, sz, ref idx); + if (rc != 0) { + pRC = rc; + return; + } + /* The allocateSpace() routine guarantees the following two properties + ** if it returns success */ + Debug.Assert(idx >= end + 2); + Debug.Assert(idx + sz <= (int)pPage.pBt.usableSize); + pPage.nCell++; + pPage.nFree -= (u16)(2 + sz); + Buffer.BlockCopy(pCell, nSkip, data, idx + nSkip, sz - nSkip); //memcpy( data[idx + nSkip], pCell + nSkip, sz - nSkip ); + if (iChild != 0) { + sqlite3Put4byte(data, idx, iChild); + } + //ptr = &data[end]; + //endPtr = &data[ins]; + //assert( ( SQLITE_PTR_TO_INT( ptr ) & 1 ) == 0 ); /* ptr is always 2-byte aligned */ + //while ( ptr > endPtr ) + //{ + // *(u16*)ptr = *(u16*)&ptr[-2]; + // ptr -= 2; + //} + for (j = end; j > ins; j -= 2) { + data[j + 0] = data[j - 2]; + data[j + 1] = data[j - 1]; + } + put2byte(data, ins, idx); + put2byte(data, pPage.hdrOffset + 3, pPage.nCell); #if !SQLITE_OMIT_AUTOVACUUM - if ( pPage.pBt.autoVacuum ) - { - /* The cell may contain a pointer to an overflow page. If so, write - ** the entry for the overflow page into the pointer map. - */ - ptrmapPutOvflPtr( pPage, pCell, ref pRC ); - } + if (pPage.pBt.autoVacuum) { + /* The cell may contain a pointer to an overflow page. If so, write + ** the entry for the overflow page into the pointer map. + */ + ptrmapPutOvflPtr(pPage, pCell, ref pRC); + } #endif - } -} + } + } -/* -** Add a list of cells to a page. The page should be initially empty. -** The cells are guaranteed to fit on the page. -*/ -static void assemblePage( -MemPage pPage, /* The page to be assemblied */ -int nCell, /* The number of cells to add to this page */ -u8[] apCell, /* Pointer to a single the cell bodies */ -int[] aSize /* Sizes of the cells bodie*/ -) -{ - int i; /* Loop counter */ - int pCellptr; /* Address of next cell pointer */ - int cellbody; /* Address of next cell body */ - byte[] data = pPage.aData; /* Pointer to data for pPage */ - int hdr = pPage.hdrOffset; /* Offset of header on pPage */ - int nUsable = (int)pPage.pBt.usableSize; /* Usable size of page */ - - Debug.Assert( pPage.nOverflow == 0 ); - Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); - Debug.Assert( nCell >= 0 && nCell <= (int)MX_CELL( pPage.pBt ) - && (int)MX_CELL( pPage.pBt ) <= 10921 ); - - Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); - - /* Check that the page has just been zeroed by zeroPage() */ - Debug.Assert( pPage.nCell == 0 ); - Debug.Assert( get2byteNotZero( data, hdr + 5 ) == nUsable ); - - pCellptr = pPage.cellOffset + nCell * 2; //data[pPage.cellOffset + nCell * 2]; - cellbody = nUsable; - for ( i = nCell - 1; i >= 0; i-- ) - { - u16 sz = (u16)aSize[i]; - pCellptr -= 2; - cellbody -= sz; - put2byte( data, pCellptr, cellbody ); - Buffer.BlockCopy( apCell, 0, data, cellbody, sz );// memcpy(&data[cellbody], apCell[i], sz); - } - put2byte( data, hdr + 3, nCell ); - put2byte( data, hdr + 5, cellbody ); - pPage.nFree -= (u16)( nCell * 2 + nUsable - cellbody ); - pPage.nCell = (u16)nCell; -} -static void assemblePage( -MemPage pPage, /* The page to be assemblied */ -int nCell, /* The number of cells to add to this page */ -u8[][] apCell, /* Pointers to cell bodies */ -u16[] aSize, /* Sizes of the cells */ -int offset /* Offset into the cell bodies, for c# */ -) -{ - int i; /* Loop counter */ - int pCellptr; /* Address of next cell pointer */ - int cellbody; /* Address of next cell body */ - byte[] data = pPage.aData; /* Pointer to data for pPage */ - int hdr = pPage.hdrOffset; /* Offset of header on pPage */ - int nUsable = (int)pPage.pBt.usableSize; /* Usable size of page */ - - Debug.Assert( pPage.nOverflow == 0 ); - Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); - Debug.Assert( nCell >= 0 && nCell <= MX_CELL( pPage.pBt ) && MX_CELL( pPage.pBt ) <= 5460 ); - Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); - - /* Check that the page has just been zeroed by zeroPage() */ - Debug.Assert( pPage.nCell == 0 ); - Debug.Assert( get2byte( data, hdr + 5 ) == nUsable ); - - pCellptr = pPage.cellOffset + nCell * 2; //data[pPage.cellOffset + nCell * 2]; - cellbody = nUsable; - for ( i = nCell - 1; i >= 0; i-- ) - { - pCellptr -= 2; - cellbody -= aSize[i + offset]; - put2byte( data, pCellptr, cellbody ); - Buffer.BlockCopy( apCell[offset + i], 0, data, cellbody, aSize[i + offset] );// memcpy(&data[cellbody], apCell[i], aSize[i]); - } - put2byte( data, hdr + 3, nCell ); - put2byte( data, hdr + 5, cellbody ); - pPage.nFree -= (u16)( nCell * 2 + nUsable - cellbody ); - pPage.nCell = (u16)nCell; -} + /* + ** Add a list of cells to a page. The page should be initially empty. + ** The cells are guaranteed to fit on the page. + */ + static void assemblePage( + MemPage pPage, /* The page to be assemblied */ + int nCell, /* The number of cells to add to this page */ + u8[] apCell, /* Pointer to a single the cell bodies */ + int[] aSize /* Sizes of the cells bodie*/ + ) { + int i; /* Loop counter */ + int pCellptr; /* Address of next cell pointer */ + int cellbody; /* Address of next cell body */ + byte[] data = pPage.aData; /* Pointer to data for pPage */ + int hdr = pPage.hdrOffset; /* Offset of header on pPage */ + int nUsable = (int)pPage.pBt.usableSize; /* Usable size of page */ + + Debug.Assert(pPage.nOverflow == 0); + Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); + Debug.Assert(nCell >= 0 && nCell <= (int)MX_CELL(pPage.pBt) + && (int)MX_CELL(pPage.pBt) <= 10921); + + Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); + + /* Check that the page has just been zeroed by zeroPage() */ + Debug.Assert(pPage.nCell == 0); + Debug.Assert(get2byteNotZero(data, hdr + 5) == nUsable); + + pCellptr = pPage.cellOffset + nCell * 2; //data[pPage.cellOffset + nCell * 2]; + cellbody = nUsable; + for (i = nCell - 1; i >= 0; i--) { + u16 sz = (u16)aSize[i]; + pCellptr -= 2; + cellbody -= sz; + put2byte(data, pCellptr, cellbody); + Buffer.BlockCopy(apCell, 0, data, cellbody, sz);// memcpy(&data[cellbody], apCell[i], sz); + } + put2byte(data, hdr + 3, nCell); + put2byte(data, hdr + 5, cellbody); + pPage.nFree -= (u16)(nCell * 2 + nUsable - cellbody); + pPage.nCell = (u16)nCell; + } + static void assemblePage( + MemPage pPage, /* The page to be assemblied */ + int nCell, /* The number of cells to add to this page */ + u8[][] apCell, /* Pointers to cell bodies */ + u16[] aSize, /* Sizes of the cells */ + int offset /* Offset into the cell bodies, for c# */ + ) { + int i; /* Loop counter */ + int pCellptr; /* Address of next cell pointer */ + int cellbody; /* Address of next cell body */ + byte[] data = pPage.aData; /* Pointer to data for pPage */ + int hdr = pPage.hdrOffset; /* Offset of header on pPage */ + int nUsable = (int)pPage.pBt.usableSize; /* Usable size of page */ + + Debug.Assert(pPage.nOverflow == 0); + Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); + Debug.Assert(nCell >= 0 && nCell <= MX_CELL(pPage.pBt) && MX_CELL(pPage.pBt) <= 5460); + Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); + + /* Check that the page has just been zeroed by zeroPage() */ + Debug.Assert(pPage.nCell == 0); + Debug.Assert(get2byte(data, hdr + 5) == nUsable); + + pCellptr = pPage.cellOffset + nCell * 2; //data[pPage.cellOffset + nCell * 2]; + cellbody = nUsable; + for (i = nCell - 1; i >= 0; i--) { + pCellptr -= 2; + cellbody -= aSize[i + offset]; + put2byte(data, pCellptr, cellbody); + Buffer.BlockCopy(apCell[offset + i], 0, data, cellbody, aSize[i + offset]);// memcpy(&data[cellbody], apCell[i], aSize[i]); + } + put2byte(data, hdr + 3, nCell); + put2byte(data, hdr + 5, cellbody); + pPage.nFree -= (u16)(nCell * 2 + nUsable - cellbody); + pPage.nCell = (u16)nCell; + } -static void assemblePage( -MemPage pPage, /* The page to be assemblied */ -int nCell, /* The number of cells to add to this page */ -u8[] apCell, /* Pointers to cell bodies */ -u16[] aSize /* Sizes of the cells */ -) -{ - int i; /* Loop counter */ - int pCellptr; /* Address of next cell pointer */ - int cellbody; /* Address of next cell body */ - u8[] data = pPage.aData; /* Pointer to data for pPage */ - int hdr = pPage.hdrOffset; /* Offset of header on pPage */ - int nUsable = (int)pPage.pBt.usableSize; /* Usable size of page */ - - Debug.Assert( pPage.nOverflow == 0 ); - Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); - Debug.Assert( nCell >= 0 && nCell <= MX_CELL( pPage.pBt ) && MX_CELL( pPage.pBt ) <= 5460 ); - Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); - - /* Check that the page has just been zeroed by zeroPage() */ - Debug.Assert( pPage.nCell == 0 ); - Debug.Assert( get2byte( data, hdr + 5 ) == nUsable ); - - pCellptr = pPage.cellOffset + nCell * 2; //&data[pPage.cellOffset + nCell * 2]; - cellbody = nUsable; - for ( i = nCell - 1; i >= 0; i-- ) - { - pCellptr -= 2; - cellbody -= aSize[i]; - put2byte( data, pCellptr, cellbody ); - Buffer.BlockCopy( apCell, 0, data, cellbody, aSize[i] );//memcpy( data[cellbody], apCell[i], aSize[i] ); - } - put2byte( data, hdr + 3, nCell ); - put2byte( data, hdr + 5, cellbody ); - pPage.nFree -= (u16)( nCell * 2 + nUsable - cellbody ); - pPage.nCell = (u16)nCell; -} + static void assemblePage( + MemPage pPage, /* The page to be assemblied */ + int nCell, /* The number of cells to add to this page */ + u8[] apCell, /* Pointers to cell bodies */ + u16[] aSize /* Sizes of the cells */ + ) { + int i; /* Loop counter */ + int pCellptr; /* Address of next cell pointer */ + int cellbody; /* Address of next cell body */ + u8[] data = pPage.aData; /* Pointer to data for pPage */ + int hdr = pPage.hdrOffset; /* Offset of header on pPage */ + int nUsable = (int)pPage.pBt.usableSize; /* Usable size of page */ + + Debug.Assert(pPage.nOverflow == 0); + Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); + Debug.Assert(nCell >= 0 && nCell <= MX_CELL(pPage.pBt) && MX_CELL(pPage.pBt) <= 5460); + Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); + + /* Check that the page has just been zeroed by zeroPage() */ + Debug.Assert(pPage.nCell == 0); + Debug.Assert(get2byte(data, hdr + 5) == nUsable); + + pCellptr = pPage.cellOffset + nCell * 2; //&data[pPage.cellOffset + nCell * 2]; + cellbody = nUsable; + for (i = nCell - 1; i >= 0; i--) { + pCellptr -= 2; + cellbody -= aSize[i]; + put2byte(data, pCellptr, cellbody); + Buffer.BlockCopy(apCell, 0, data, cellbody, aSize[i]);//memcpy( data[cellbody], apCell[i], aSize[i] ); + } + put2byte(data, hdr + 3, nCell); + put2byte(data, hdr + 5, cellbody); + pPage.nFree -= (u16)(nCell * 2 + nUsable - cellbody); + pPage.nCell = (u16)nCell; + } -/* -** The following parameters determine how many adjacent pages get involved -** in a balancing operation. NN is the number of neighbors on either side -** of the page that participate in the balancing operation. NB is the -** total number of pages that participate, including the target page and -** NN neighbors on either side. -** -** The minimum value of NN is 1 (of course). Increasing NN above 1 -** (to 2 or 3) gives a modest improvement in SELECT and DELETE performance -** in exchange for a larger degradation in INSERT and UPDATE performance. -** The value of NN appears to give the best results overall. -*/ -static int NN = 1; /* Number of neighbors on either side of pPage */ -static int NB = ( NN * 2 + 1 ); /* Total pages involved in the balance */ + /* + ** The following parameters determine how many adjacent pages get involved + ** in a balancing operation. NN is the number of neighbors on either side + ** of the page that participate in the balancing operation. NB is the + ** total number of pages that participate, including the target page and + ** NN neighbors on either side. + ** + ** The minimum value of NN is 1 (of course). Increasing NN above 1 + ** (to 2 or 3) gives a modest improvement in SELECT and DELETE performance + ** in exchange for a larger degradation in INSERT and UPDATE performance. + ** The value of NN appears to give the best results overall. + */ + static int NN = 1; /* Number of neighbors on either side of pPage */ + static int NB = (NN * 2 + 1); /* Total pages involved in the balance */ #if !SQLITE_OMIT_QUICKBALANCE -/* -** This version of balance() handles the common special case where -** a new entry is being inserted on the extreme right-end of the -** tree, in other words, when the new entry will become the largest -** entry in the tree. -** -** Instead of trying to balance the 3 right-most leaf pages, just add -** a new page to the right-hand side and put the one new entry in -** that page. This leaves the right side of the tree somewhat -** unbalanced. But odds are that we will be inserting new entries -** at the end soon afterwards so the nearly empty page will quickly -** fill up. On average. -** -** pPage is the leaf page which is the right-most page in the tree. -** pParent is its parent. pPage must have a single overflow entry -** which is also the right-most entry on the page. -** -** The pSpace buffer is used to store a temporary copy of the divider -** cell that will be inserted into pParent. Such a cell consists of a 4 -** byte page number followed by a variable length integer. In other -** words, at most 13 bytes. Hence the pSpace buffer must be at -** least 13 bytes in size. -*/ -static int balance_quick( MemPage pParent, MemPage pPage, u8[] pSpace ) -{ - BtShared pBt = pPage.pBt; /* B-Tree Database */ - MemPage pNew = new MemPage();/* Newly allocated page */ - int rc; /* Return Code */ - Pgno pgnoNew = 0; /* Page number of pNew */ - - Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); - Debug.Assert( sqlite3PagerIswriteable( pParent.pDbPage ) ); - Debug.Assert( pPage.nOverflow == 1 ); - - /* This error condition is now caught prior to reaching this function */ - if ( pPage.nCell <= 0 ) - return SQLITE_CORRUPT_BKPT(); - - /* Allocate a new page. This page will become the right-sibling of - ** pPage. Make the parent page writable, so that the new divider cell - ** may be inserted. If both these operations are successful, proceed. - */ - rc = allocateBtreePage( pBt, ref pNew, ref pgnoNew, 0, 0 ); - - if ( rc == SQLITE_OK ) - { - - int pOut = 4;//u8 pOut = &pSpace[4]; - u8[] pCell = pPage.aOvfl[0].pCell; - int[] szCell = new int[1]; - szCell[0] = cellSizePtr( pPage, pCell ); - int pStop; - - Debug.Assert( sqlite3PagerIswriteable( pNew.pDbPage ) ); - Debug.Assert( pPage.aData[0] == ( PTF_INTKEY | PTF_LEAFDATA | PTF_LEAF ) ); - zeroPage( pNew, PTF_INTKEY | PTF_LEAFDATA | PTF_LEAF ); - assemblePage( pNew, 1, pCell, szCell ); - - /* If this is an auto-vacuum database, update the pointer map - ** with entries for the new page, and any pointer from the - ** cell on the page to an overflow page. If either of these - ** operations fails, the return code is set, but the contents - ** of the parent page are still manipulated by thh code below. - ** That is Ok, at this point the parent page is guaranteed to - ** be marked as dirty. Returning an error code will cause a - ** rollback, undoing any changes made to the parent page. - */ + /* + ** This version of balance() handles the common special case where + ** a new entry is being inserted on the extreme right-end of the + ** tree, in other words, when the new entry will become the largest + ** entry in the tree. + ** + ** Instead of trying to balance the 3 right-most leaf pages, just add + ** a new page to the right-hand side and put the one new entry in + ** that page. This leaves the right side of the tree somewhat + ** unbalanced. But odds are that we will be inserting new entries + ** at the end soon afterwards so the nearly empty page will quickly + ** fill up. On average. + ** + ** pPage is the leaf page which is the right-most page in the tree. + ** pParent is its parent. pPage must have a single overflow entry + ** which is also the right-most entry on the page. + ** + ** The pSpace buffer is used to store a temporary copy of the divider + ** cell that will be inserted into pParent. Such a cell consists of a 4 + ** byte page number followed by a variable length integer. In other + ** words, at most 13 bytes. Hence the pSpace buffer must be at + ** least 13 bytes in size. + */ + static int balance_quick(MemPage pParent, MemPage pPage, u8[] pSpace) { + BtShared pBt = pPage.pBt; /* B-Tree Database */ + MemPage pNew = new MemPage();/* Newly allocated page */ + int rc; /* Return Code */ + Pgno pgnoNew = 0; /* Page number of pNew */ + + Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); + Debug.Assert(sqlite3PagerIswriteable(pParent.pDbPage)); + Debug.Assert(pPage.nOverflow == 1); + + /* This error condition is now caught prior to reaching this function */ + if (pPage.nCell <= 0) + return SQLITE_CORRUPT_BKPT(); + + /* Allocate a new page. This page will become the right-sibling of + ** pPage. Make the parent page writable, so that the new divider cell + ** may be inserted. If both these operations are successful, proceed. + */ + rc = allocateBtreePage(pBt, ref pNew, ref pgnoNew, 0, 0); + + if (rc == SQLITE_OK) { + + int pOut = 4;//u8 pOut = &pSpace[4]; + u8[] pCell = pPage.aOvfl[0].pCell; + int[] szCell = new int[1]; + szCell[0] = cellSizePtr(pPage, pCell); + int pStop; + + Debug.Assert(sqlite3PagerIswriteable(pNew.pDbPage)); + Debug.Assert(pPage.aData[0] == (PTF_INTKEY | PTF_LEAFDATA | PTF_LEAF)); + zeroPage(pNew, PTF_INTKEY | PTF_LEAFDATA | PTF_LEAF); + assemblePage(pNew, 1, pCell, szCell); + + /* If this is an auto-vacuum database, update the pointer map + ** with entries for the new page, and any pointer from the + ** cell on the page to an overflow page. If either of these + ** operations fails, the return code is set, but the contents + ** of the parent page are still manipulated by thh code below. + ** That is Ok, at this point the parent page is guaranteed to + ** be marked as dirty. Returning an error code will cause a + ** rollback, undoing any changes made to the parent page. + */ #if !SQLITE_OMIT_AUTOVACUUM // if ( ISAUTOVACUUM ) - if ( pBt.autoVacuum ) + if (pBt.autoVacuum) #else if (false) #endif - { - ptrmapPut( pBt, pgnoNew, PTRMAP_BTREE, pParent.pgno, ref rc ); - if ( szCell[0] > pNew.minLocal ) - { - ptrmapPutOvflPtr( pNew, pCell, ref rc ); - } - } + { + ptrmapPut(pBt, pgnoNew, PTRMAP_BTREE, pParent.pgno, ref rc); + if (szCell[0] > pNew.minLocal) { + ptrmapPutOvflPtr(pNew, pCell, ref rc); + } + } + + /* Create a divider cell to insert into pParent. The divider cell + ** consists of a 4-byte page number (the page number of pPage) and + ** a variable length key value (which must be the same value as the + ** largest key on pPage). + ** + ** To find the largest key value on pPage, first find the right-most + ** cell on pPage. The first two fields of this cell are the + ** record-length (a variable length integer at most 32-bits in size) + ** and the key value (a variable length integer, may have any value). + ** The first of the while(...) loops below skips over the record-length + ** field. The second while(...) loop copies the key value from the + ** cell on pPage into the pSpace buffer. + */ + int iCell = findCell(pPage, pPage.nCell - 1); //pCell = findCell( pPage, pPage.nCell - 1 ); + pCell = pPage.aData; + int _pCell = iCell; + pStop = _pCell + 9; //pStop = &pCell[9]; + while (((pCell[_pCell++]) & 0x80) != 0 && _pCell < pStop) + ; //while ( ( *( pCell++ ) & 0x80 ) && pCell < pStop ) ; + pStop = _pCell + 9;//pStop = &pCell[9]; + while (((pSpace[pOut++] = pCell[_pCell++]) & 0x80) != 0 && _pCell < pStop) + ; //while ( ( ( *( pOut++ ) = *( pCell++ ) ) & 0x80 ) && pCell < pStop ) ; + + /* Insert the new divider cell into pParent. */ + insertCell(pParent, pParent.nCell, pSpace, pOut, //(int)(pOut-pSpace), + null, pPage.pgno, ref rc); + + /* Set the right-child pointer of pParent to point to the new page. */ + sqlite3Put4byte(pParent.aData, pParent.hdrOffset + 8, pgnoNew); + + /* Release the reference to the new page. */ + releasePage(pNew); + } - /* Create a divider cell to insert into pParent. The divider cell - ** consists of a 4-byte page number (the page number of pPage) and - ** a variable length key value (which must be the same value as the - ** largest key on pPage). - ** - ** To find the largest key value on pPage, first find the right-most - ** cell on pPage. The first two fields of this cell are the - ** record-length (a variable length integer at most 32-bits in size) - ** and the key value (a variable length integer, may have any value). - ** The first of the while(...) loops below skips over the record-length - ** field. The second while(...) loop copies the key value from the - ** cell on pPage into the pSpace buffer. - */ - int iCell = findCell( pPage, pPage.nCell - 1 ); //pCell = findCell( pPage, pPage.nCell - 1 ); - pCell = pPage.aData; - int _pCell = iCell; - pStop = _pCell + 9; //pStop = &pCell[9]; - while ( ( ( pCell[_pCell++] ) & 0x80 ) != 0 && _pCell < pStop ) - ; //while ( ( *( pCell++ ) & 0x80 ) && pCell < pStop ) ; - pStop = _pCell + 9;//pStop = &pCell[9]; - while ( ( ( pSpace[pOut++] = pCell[_pCell++] ) & 0x80 ) != 0 && _pCell < pStop ) - ; //while ( ( ( *( pOut++ ) = *( pCell++ ) ) & 0x80 ) && pCell < pStop ) ; - - /* Insert the new divider cell into pParent. */ - insertCell( pParent, pParent.nCell, pSpace, pOut, //(int)(pOut-pSpace), - null, pPage.pgno, ref rc ); - - /* Set the right-child pointer of pParent to point to the new page. */ - sqlite3Put4byte( pParent.aData, pParent.hdrOffset + 8, pgnoNew ); - - /* Release the reference to the new page. */ - releasePage( pNew ); - } - - return rc; -} + return rc; + } #endif //* SQLITE_OMIT_QUICKBALANCE */ #if FALSE @@ -6731,815 +6111,746 @@ static int ptrmapCheckPages(MemPage **apPage, int nPage){ } #endif -/* -** This function is used to copy the contents of the b-tree node stored -** on page pFrom to page pTo. If page pFrom was not a leaf page, then -** the pointer-map entries for each child page are updated so that the -** parent page stored in the pointer map is page pTo. If pFrom contained -** any cells with overflow page pointers, then the corresponding pointer -** map entries are also updated so that the parent page is page pTo. -** -** If pFrom is currently carrying any overflow cells (entries in the -** MemPage.aOvfl[] array), they are not copied to pTo. -** -** Before returning, page pTo is reinitialized using btreeInitPage(). -** -** The performance of this function is not critical. It is only used by -** the balance_shallower() and balance_deeper() procedures, neither of -** which are called often under normal circumstances. -*/ -static void copyNodeContent( MemPage pFrom, MemPage pTo, ref int pRC ) -{ - if ( ( pRC ) == SQLITE_OK ) - { - BtShared pBt = pFrom.pBt; - u8[] aFrom = pFrom.aData; - u8[] aTo = pTo.aData; - int iFromHdr = pFrom.hdrOffset; - int iToHdr = ( ( pTo.pgno == 1 ) ? 100 : 0 ); - int rc; - int iData; - - - Debug.Assert( pFrom.isInit != 0 ); - Debug.Assert( pFrom.nFree >= iToHdr ); - Debug.Assert( get2byte( aFrom, iFromHdr + 5 ) <= (int)pBt.usableSize ); - - /* Copy the b-tree node content from page pFrom to page pTo. */ - iData = get2byte( aFrom, iFromHdr + 5 ); - Buffer.BlockCopy( aFrom, iData, aTo, iData, (int)pBt.usableSize - iData );//memcpy(aTo[iData], ref aFrom[iData], pBt.usableSize-iData); - Buffer.BlockCopy( aFrom, iFromHdr, aTo, iToHdr, pFrom.cellOffset + 2 * pFrom.nCell );//memcpy(aTo[iToHdr], ref aFrom[iFromHdr], pFrom.cellOffset + 2*pFrom.nCell); - - /* Reinitialize page pTo so that the contents of the MemPage structure - ** match the new data. The initialization of pTo can actually fail under - ** fairly obscure circumstances, even though it is a copy of initialized - ** page pFrom. - */ - pTo.isInit = 0; - rc = btreeInitPage( pTo ); - if ( rc != SQLITE_OK ) - { - pRC = rc; - return; - } - - /* If this is an auto-vacuum database, update the pointer-map entries - ** for any b-tree or overflow pages that pTo now contains the pointers to. - */ + /* + ** This function is used to copy the contents of the b-tree node stored + ** on page pFrom to page pTo. If page pFrom was not a leaf page, then + ** the pointer-map entries for each child page are updated so that the + ** parent page stored in the pointer map is page pTo. If pFrom contained + ** any cells with overflow page pointers, then the corresponding pointer + ** map entries are also updated so that the parent page is page pTo. + ** + ** If pFrom is currently carrying any overflow cells (entries in the + ** MemPage.aOvfl[] array), they are not copied to pTo. + ** + ** Before returning, page pTo is reinitialized using btreeInitPage(). + ** + ** The performance of this function is not critical. It is only used by + ** the balance_shallower() and balance_deeper() procedures, neither of + ** which are called often under normal circumstances. + */ + static void copyNodeContent(MemPage pFrom, MemPage pTo, ref int pRC) { + if ((pRC) == SQLITE_OK) { + BtShared pBt = pFrom.pBt; + u8[] aFrom = pFrom.aData; + u8[] aTo = pTo.aData; + int iFromHdr = pFrom.hdrOffset; + int iToHdr = ((pTo.pgno == 1) ? 100 : 0); + int rc; + int iData; + + + Debug.Assert(pFrom.isInit != 0); + Debug.Assert(pFrom.nFree >= iToHdr); + Debug.Assert(get2byte(aFrom, iFromHdr + 5) <= (int)pBt.usableSize); + + /* Copy the b-tree node content from page pFrom to page pTo. */ + iData = get2byte(aFrom, iFromHdr + 5); + Buffer.BlockCopy(aFrom, iData, aTo, iData, (int)pBt.usableSize - iData);//memcpy(aTo[iData], ref aFrom[iData], pBt.usableSize-iData); + Buffer.BlockCopy(aFrom, iFromHdr, aTo, iToHdr, pFrom.cellOffset + 2 * pFrom.nCell);//memcpy(aTo[iToHdr], ref aFrom[iFromHdr], pFrom.cellOffset + 2*pFrom.nCell); + + /* Reinitialize page pTo so that the contents of the MemPage structure + ** match the new data. The initialization of pTo can actually fail under + ** fairly obscure circumstances, even though it is a copy of initialized + ** page pFrom. + */ + pTo.isInit = 0; + rc = btreeInitPage(pTo); + if (rc != SQLITE_OK) { + pRC = rc; + return; + } + + /* If this is an auto-vacuum database, update the pointer-map entries + ** for any b-tree or overflow pages that pTo now contains the pointers to. + */ #if !SQLITE_OMIT_AUTOVACUUM // if ( ISAUTOVACUUM ) - if ( pBt.autoVacuum ) + if (pBt.autoVacuum) #else if (false) #endif - { - pRC = setChildPtrmaps( pTo ); - } - } -} - -/* -** This routine redistributes cells on the iParentIdx'th child of pParent -** (hereafter "the page") and up to 2 siblings so that all pages have about the -** same amount of free space. Usually a single sibling on either side of the -** page are used in the balancing, though both siblings might come from one -** side if the page is the first or last child of its parent. If the page -** has fewer than 2 siblings (something which can only happen if the page -** is a root page or a child of a root page) then all available siblings -** participate in the balancing. -** -** The number of siblings of the page might be increased or decreased by -** one or two in an effort to keep pages nearly full but not over full. -** -** Note that when this routine is called, some of the cells on the page -** might not actually be stored in MemPage.aData[]. This can happen -** if the page is overfull. This routine ensures that all cells allocated -** to the page and its siblings fit into MemPage.aData[] before returning. -** -** In the course of balancing the page and its siblings, cells may be -** inserted into or removed from the parent page (pParent). Doing so -** may cause the parent page to become overfull or underfull. If this -** happens, it is the responsibility of the caller to invoke the correct -** balancing routine to fix this problem (see the balance() routine). -** -** If this routine fails for any reason, it might leave the database -** in a corrupted state. So if this routine fails, the database should -** be rolled back. -** -** The third argument to this function, aOvflSpace, is a pointer to a -** buffer big enough to hold one page. If while inserting cells into the parent -** page (pParent) the parent page becomes overfull, this buffer is -** used to store the parent's overflow cells. Because this function inserts -** a maximum of four divider cells into the parent page, and the maximum -** size of a cell stored within an internal node is always less than 1/4 -** of the page-size, the aOvflSpace[] buffer is guaranteed to be large -** enough for all overflow cells. -** -** If aOvflSpace is set to a null pointer, this function returns -** SQLITE_NOMEM. -*/ + { + pRC = setChildPtrmaps(pTo); + } + } + } -// under C#; Try to reuse Memory + /* + ** This routine redistributes cells on the iParentIdx'th child of pParent + ** (hereafter "the page") and up to 2 siblings so that all pages have about the + ** same amount of free space. Usually a single sibling on either side of the + ** page are used in the balancing, though both siblings might come from one + ** side if the page is the first or last child of its parent. If the page + ** has fewer than 2 siblings (something which can only happen if the page + ** is a root page or a child of a root page) then all available siblings + ** participate in the balancing. + ** + ** The number of siblings of the page might be increased or decreased by + ** one or two in an effort to keep pages nearly full but not over full. + ** + ** Note that when this routine is called, some of the cells on the page + ** might not actually be stored in MemPage.aData[]. This can happen + ** if the page is overfull. This routine ensures that all cells allocated + ** to the page and its siblings fit into MemPage.aData[] before returning. + ** + ** In the course of balancing the page and its siblings, cells may be + ** inserted into or removed from the parent page (pParent). Doing so + ** may cause the parent page to become overfull or underfull. If this + ** happens, it is the responsibility of the caller to invoke the correct + ** balancing routine to fix this problem (see the balance() routine). + ** + ** If this routine fails for any reason, it might leave the database + ** in a corrupted state. So if this routine fails, the database should + ** be rolled back. + ** + ** The third argument to this function, aOvflSpace, is a pointer to a + ** buffer big enough to hold one page. If while inserting cells into the parent + ** page (pParent) the parent page becomes overfull, this buffer is + ** used to store the parent's overflow cells. Because this function inserts + ** a maximum of four divider cells into the parent page, and the maximum + ** size of a cell stored within an internal node is always less than 1/4 + ** of the page-size, the aOvflSpace[] buffer is guaranteed to be large + ** enough for all overflow cells. + ** + ** If aOvflSpace is set to a null pointer, this function returns + ** SQLITE_NOMEM. + */ -static int balance_nonroot( -MemPage pParent, /* Parent page of siblings being balanced */ -int iParentIdx, /* Index of "the page" in pParent */ -u8[] aOvflSpace, /* page-size bytes of space for parent ovfl */ -int isRoot /* True if pParent is a root-page */ -) -{ - MemPage[] apOld = new MemPage[NB]; /* pPage and up to two siblings */ - MemPage[] apCopy = new MemPage[NB]; /* Private copies of apOld[] pages */ - MemPage[] apNew = new MemPage[NB + 2];/* pPage and up to NB siblings after balancing */ - int[] apDiv = new int[NB - 1]; /* Divider cells in pParent */ - int[] cntNew = new int[NB + 2]; /* Index in aCell[] of cell after i-th page */ - int[] szNew = new int[NB + 2]; /* Combined size of cells place on i-th page */ - u16[] szCell = new u16[1]; /* Local size of all cells in apCell[] */ - BtShared pBt; /* The whole database */ - int nCell = 0; /* Number of cells in apCell[] */ - int nMaxCells = 0; /* Allocated size of apCell, szCell, aFrom. */ - int nNew = 0; /* Number of pages in apNew[] */ - int nOld; /* Number of pages in apOld[] */ - int i, j, k; /* Loop counters */ - int nxDiv; /* Next divider slot in pParent.aCell[] */ - int rc = SQLITE_OK; /* The return code */ - u16 leafCorrection; /* 4 if pPage is a leaf. 0 if not */ - int leafData; /* True if pPage is a leaf of a LEAFDATA tree */ - int usableSpace; /* Bytes in pPage beyond the header */ - int pageFlags; /* Value of pPage.aData[0] */ - int subtotal; /* Subtotal of bytes in cells on one page */ - //int iSpace1 = 0; /* First unused byte of aSpace1[] */ - int iOvflSpace = 0; /* First unused byte of aOvflSpace[] */ - int szScratch; /* Size of scratch memory requested */ - int pRight; /* Location in parent of right-sibling pointer */ - u8[][] apCell = null; /* All cells begin balanced */ - //u16[] szCell; /* Local size of all cells in apCell[] */ - //u8[] aSpace1; /* Space for copies of dividers cells */ - Pgno pgno; /* Temp var to store a page number in */ - - pBt = pParent.pBt; - Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); - Debug.Assert( sqlite3PagerIswriteable( pParent.pDbPage ) ); + // under C#; Try to reuse Memory + + static int balance_nonroot( + MemPage pParent, /* Parent page of siblings being balanced */ + int iParentIdx, /* Index of "the page" in pParent */ + u8[] aOvflSpace, /* page-size bytes of space for parent ovfl */ + int isRoot /* True if pParent is a root-page */ + ) { + MemPage[] apOld = new MemPage[NB]; /* pPage and up to two siblings */ + MemPage[] apCopy = new MemPage[NB]; /* Private copies of apOld[] pages */ + MemPage[] apNew = new MemPage[NB + 2];/* pPage and up to NB siblings after balancing */ + int[] apDiv = new int[NB - 1]; /* Divider cells in pParent */ + int[] cntNew = new int[NB + 2]; /* Index in aCell[] of cell after i-th page */ + int[] szNew = new int[NB + 2]; /* Combined size of cells place on i-th page */ + u16[] szCell = new u16[1]; /* Local size of all cells in apCell[] */ + BtShared pBt; /* The whole database */ + int nCell = 0; /* Number of cells in apCell[] */ + int nMaxCells = 0; /* Allocated size of apCell, szCell, aFrom. */ + int nNew = 0; /* Number of pages in apNew[] */ + int nOld; /* Number of pages in apOld[] */ + int i, j, k; /* Loop counters */ + int nxDiv; /* Next divider slot in pParent.aCell[] */ + int rc = SQLITE_OK; /* The return code */ + u16 leafCorrection; /* 4 if pPage is a leaf. 0 if not */ + int leafData; /* True if pPage is a leaf of a LEAFDATA tree */ + int usableSpace; /* Bytes in pPage beyond the header */ + int pageFlags; /* Value of pPage.aData[0] */ + int subtotal; /* Subtotal of bytes in cells on one page */ + //int iSpace1 = 0; /* First unused byte of aSpace1[] */ + int iOvflSpace = 0; /* First unused byte of aOvflSpace[] */ + int szScratch; /* Size of scratch memory requested */ + int pRight; /* Location in parent of right-sibling pointer */ + u8[][] apCell = null; /* All cells begin balanced */ + //u16[] szCell; /* Local size of all cells in apCell[] */ + //u8[] aSpace1; /* Space for copies of dividers cells */ + Pgno pgno; /* Temp var to store a page number in */ + + pBt = pParent.pBt; + Debug.Assert(sqlite3_mutex_held(pBt.mutex)); + Debug.Assert(sqlite3PagerIswriteable(pParent.pDbPage)); #if FALSE TRACE("BALANCE: begin page %d child of %d\n", pPage.pgno, pParent.pgno); #endif - /* At this point pParent may have at most one overflow cell. And if -** this overflow cell is present, it must be the cell with -** index iParentIdx. This scenario comes about when this function -** is called (indirectly) from sqlite3BtreeDelete(). -*/ - Debug.Assert( pParent.nOverflow == 0 || pParent.nOverflow == 1 ); - Debug.Assert( pParent.nOverflow == 0 || pParent.aOvfl[0].idx == iParentIdx ); - - //if( !aOvflSpace ){ - // return SQLITE_NOMEM; - //} - - /* Find the sibling pages to balance. Also locate the cells in pParent - ** that divide the siblings. An attempt is made to find NN siblings on - ** either side of pPage. More siblings are taken from one side, however, - ** if there are fewer than NN siblings on the other side. If pParent - ** has NB or fewer children then all children of pParent are taken. - ** - ** This loop also drops the divider cells from the parent page. This - ** way, the remainder of the function does not have to deal with any - ** overflow cells in the parent page, since if any existed they will - ** have already been removed. - */ - i = pParent.nOverflow + pParent.nCell; - if ( i < 2 ) - { - nxDiv = 0; - nOld = i + 1; - } - else - { - nOld = 3; - if ( iParentIdx == 0 ) - { - nxDiv = 0; - } - else if ( iParentIdx == i ) - { - nxDiv = i - 2; - } - else - { - nxDiv = iParentIdx - 1; - } - i = 2; - } - if ( ( i + nxDiv - pParent.nOverflow ) == pParent.nCell ) - { - pRight = pParent.hdrOffset + 8; //&pParent.aData[pParent.hdrOffset + 8]; - } - else - { - pRight = findCell( pParent, i + nxDiv - pParent.nOverflow ); - } - pgno = sqlite3Get4byte( pParent.aData, pRight ); - while ( true ) - { - rc = getAndInitPage( pBt, pgno, ref apOld[i] ); - if ( rc != 0 ) - { - //memset(apOld, 0, (i+1)*sizeof(MemPage*)); - goto balance_cleanup; - } - nMaxCells += 1 + apOld[i].nCell + apOld[i].nOverflow; - if ( ( i-- ) == 0 ) - break; + /* At this point pParent may have at most one overflow cell. And if + ** this overflow cell is present, it must be the cell with + ** index iParentIdx. This scenario comes about when this function + ** is called (indirectly) from sqlite3BtreeDelete(). + */ + Debug.Assert(pParent.nOverflow == 0 || pParent.nOverflow == 1); + Debug.Assert(pParent.nOverflow == 0 || pParent.aOvfl[0].idx == iParentIdx); + + //if( !aOvflSpace ){ + // return SQLITE_NOMEM; + //} + + /* Find the sibling pages to balance. Also locate the cells in pParent + ** that divide the siblings. An attempt is made to find NN siblings on + ** either side of pPage. More siblings are taken from one side, however, + ** if there are fewer than NN siblings on the other side. If pParent + ** has NB or fewer children then all children of pParent are taken. + ** + ** This loop also drops the divider cells from the parent page. This + ** way, the remainder of the function does not have to deal with any + ** overflow cells in the parent page, since if any existed they will + ** have already been removed. + */ + i = pParent.nOverflow + pParent.nCell; + if (i < 2) { + nxDiv = 0; + nOld = i + 1; + } else { + nOld = 3; + if (iParentIdx == 0) { + nxDiv = 0; + } else if (iParentIdx == i) { + nxDiv = i - 2; + } else { + nxDiv = iParentIdx - 1; + } + i = 2; + } + if ((i + nxDiv - pParent.nOverflow) == pParent.nCell) { + pRight = pParent.hdrOffset + 8; //&pParent.aData[pParent.hdrOffset + 8]; + } else { + pRight = findCell(pParent, i + nxDiv - pParent.nOverflow); + } + pgno = sqlite3Get4byte(pParent.aData, pRight); + while (true) { + rc = getAndInitPage(pBt, pgno, ref apOld[i]); + if (rc != 0) { + //memset(apOld, 0, (i+1)*sizeof(MemPage*)); + goto balance_cleanup; + } + nMaxCells += 1 + apOld[i].nCell + apOld[i].nOverflow; + if ((i--) == 0) + break; + + if (i + nxDiv == pParent.aOvfl[0].idx && pParent.nOverflow != 0) { + apDiv[i] = 0;// = pParent.aOvfl[0].pCell; + pgno = sqlite3Get4byte(pParent.aOvfl[0].pCell, apDiv[i]); + szNew[i] = cellSizePtr(pParent, apDiv[i]); + pParent.nOverflow = 0; + } else { + apDiv[i] = findCell(pParent, i + nxDiv - pParent.nOverflow); + pgno = sqlite3Get4byte(pParent.aData, apDiv[i]); + szNew[i] = cellSizePtr(pParent, apDiv[i]); + + /* Drop the cell from the parent page. apDiv[i] still points to + ** the cell within the parent, even though it has been dropped. + ** This is safe because dropping a cell only overwrites the first + ** four bytes of it, and this function does not need the first + ** four bytes of the divider cell. So the pointer is safe to use + ** later on. + ** + ** Unless SQLite is compiled in secure-delete mode. In this case, + ** the dropCell() routine will overwrite the entire cell with zeroes. + ** In this case, temporarily copy the cell into the aOvflSpace[] + ** buffer. It will be copied out again as soon as the aSpace[] buffer + ** is allocated. */ + //if (pBt.secureDelete) + //{ + // int iOff = (int)(apDiv[i]) - (int)(pParent.aData); //SQLITE_PTR_TO_INT(apDiv[i]) - SQLITE_PTR_TO_INT(pParent.aData); + // if( (iOff+szNew[i])>(int)pBt->usableSize ) + // { + // rc = SQLITE_CORRUPT_BKPT(); + // Array.Clear(apOld[0].aData,0,apOld[0].aData.Length); //memset(apOld, 0, (i + 1) * sizeof(MemPage*)); + // goto balance_cleanup; + // } + // else + // { + // memcpy(&aOvflSpace[iOff], apDiv[i], szNew[i]); + // apDiv[i] = &aOvflSpace[apDiv[i] - pParent.aData]; + // } + //} + dropCell(pParent, i + nxDiv - pParent.nOverflow, szNew[i], ref rc); + } + } - if ( i + nxDiv == pParent.aOvfl[0].idx && pParent.nOverflow != 0 ) - { - apDiv[i] = 0;// = pParent.aOvfl[0].pCell; - pgno = sqlite3Get4byte( pParent.aOvfl[0].pCell, apDiv[i] ); - szNew[i] = cellSizePtr( pParent, apDiv[i] ); - pParent.nOverflow = 0; - } - else - { - apDiv[i] = findCell( pParent, i + nxDiv - pParent.nOverflow ); - pgno = sqlite3Get4byte( pParent.aData, apDiv[i] ); - szNew[i] = cellSizePtr( pParent, apDiv[i] ); - - /* Drop the cell from the parent page. apDiv[i] still points to - ** the cell within the parent, even though it has been dropped. - ** This is safe because dropping a cell only overwrites the first - ** four bytes of it, and this function does not need the first - ** four bytes of the divider cell. So the pointer is safe to use - ** later on. - ** - ** Unless SQLite is compiled in secure-delete mode. In this case, - ** the dropCell() routine will overwrite the entire cell with zeroes. - ** In this case, temporarily copy the cell into the aOvflSpace[] - ** buffer. It will be copied out again as soon as the aSpace[] buffer - ** is allocated. */ - //if (pBt.secureDelete) - //{ - // int iOff = (int)(apDiv[i]) - (int)(pParent.aData); //SQLITE_PTR_TO_INT(apDiv[i]) - SQLITE_PTR_TO_INT(pParent.aData); - // if( (iOff+szNew[i])>(int)pBt->usableSize ) - // { - // rc = SQLITE_CORRUPT_BKPT(); - // Array.Clear(apOld[0].aData,0,apOld[0].aData.Length); //memset(apOld, 0, (i + 1) * sizeof(MemPage*)); - // goto balance_cleanup; - // } - // else - // { - // memcpy(&aOvflSpace[iOff], apDiv[i], szNew[i]); - // apDiv[i] = &aOvflSpace[apDiv[i] - pParent.aData]; - // } - //} - dropCell( pParent, i + nxDiv - pParent.nOverflow, szNew[i], ref rc ); - } - } - - /* Make nMaxCells a multiple of 4 in order to preserve 8-byte - ** alignment */ - nMaxCells = ( nMaxCells + 3 ) & ~3; - - /* - ** Allocate space for memory structures - */ - //k = pBt.pageSize + ROUND8(sizeof(MemPage)); - //szScratch = - // nMaxCells*sizeof(u8*) /* apCell */ - // + nMaxCells*sizeof(u16) /* szCell */ - // + pBt.pageSize /* aSpace1 */ - // + k*nOld; /* Page copies (apCopy) */ - apCell = sqlite3ScratchMalloc( apCell, nMaxCells ); - //if( apCell==null ){ - // rc = SQLITE_NOMEM; - // goto balance_cleanup; - //} - if ( szCell.Length < nMaxCells ) - Array.Resize( ref szCell, nMaxCells ); //(u16*)&apCell[nMaxCells]; - //aSpace1 = new byte[pBt.pageSize * (nMaxCells)];// aSpace1 = (u8*)&szCell[nMaxCells]; - //Debug.Assert( EIGHT_BYTE_ALIGNMENT(aSpace1) ); - - /* - ** Load pointers to all cells on sibling pages and the divider cells - ** into the local apCell[] array. Make copies of the divider cells - ** into space obtained from aSpace1[] and remove the the divider Cells - ** from pParent. - ** - ** If the siblings are on leaf pages, then the child pointers of the - ** divider cells are stripped from the cells before they are copied - ** into aSpace1[]. In this way, all cells in apCell[] are without - ** child pointers. If siblings are not leaves, then all cell in - ** apCell[] include child pointers. Either way, all cells in apCell[] - ** are alike. - ** - ** leafCorrection: 4 if pPage is a leaf. 0 if pPage is not a leaf. - ** leafData: 1 if pPage holds key+data and pParent holds only keys. - */ - leafCorrection = (u16)( apOld[0].leaf * 4 ); - leafData = apOld[0].hasData; - for ( i = 0; i < nOld; i++ ) - { - int limit; - - /* Before doing anything else, take a copy of the i'th original sibling - ** The rest of this function will use data from the copies rather - ** that the original pages since the original pages will be in the - ** process of being overwritten. */ - //MemPage pOld = apCopy[i] = (MemPage*)&aSpace1[pBt.pageSize + k*i]; - //memcpy(pOld, apOld[i], sizeof(MemPage)); - //pOld.aData = (void*)&pOld[1]; - //memcpy(pOld.aData, apOld[i].aData, pBt.pageSize); - MemPage pOld = apCopy[i] = apOld[i].Copy(); - - limit = pOld.nCell + pOld.nOverflow; - if( pOld.nOverflow>0 || true){ - for ( j = 0; j < limit; j++ ) - { - Debug.Assert( nCell < nMaxCells ); - //apCell[nCell] = findOverflowCell( pOld, j ); - //szCell[nCell] = cellSizePtr( pOld, apCell, nCell ); - int iFOFC = findOverflowCell( pOld, j ); - szCell[nCell] = cellSizePtr( pOld, iFOFC ); - // Copy the Data Locally - if ( apCell[nCell] == null ) - apCell[nCell] = new u8[szCell[nCell]]; - else if ( apCell[nCell].Length < szCell[nCell] ) - Array.Resize( ref apCell[nCell], szCell[nCell] ); - if ( iFOFC < 0 ) // Overflow Cell - Buffer.BlockCopy( pOld.aOvfl[-( iFOFC + 1 )].pCell, 0, apCell[nCell], 0, szCell[nCell] ); - else - Buffer.BlockCopy( pOld.aData, iFOFC, apCell[nCell], 0, szCell[nCell] ); - nCell++; - } - } - else - { - u8[] aData = pOld.aData; - u16 maskPage = pOld.maskPage; - u16 cellOffset = pOld.cellOffset; - for ( j = 0; j < limit; j++ ) - { - Debugger.Break(); - Debug.Assert( nCell < nMaxCells ); - apCell[nCell] = findCellv2( aData, maskPage, cellOffset, j ); - szCell[nCell] = cellSizePtr( pOld, apCell[nCell] ); - nCell++; - } - } - if ( i < nOld - 1 && 0 == leafData ) - { - u16 sz = (u16)szNew[i]; - byte[] pTemp = sqlite3Malloc( sz + leafCorrection ); - Debug.Assert( nCell < nMaxCells ); - szCell[nCell] = sz; - //pTemp = &aSpace1[iSpace1]; - //iSpace1 += sz; - Debug.Assert( sz <= pBt.maxLocal + 23 ); - //Debug.Assert(iSpace1 <= (int)pBt.pageSize); - Buffer.BlockCopy( pParent.aData, apDiv[i], pTemp, 0, sz );//memcpy( pTemp, apDiv[i], sz ); - if ( apCell[nCell] == null || apCell[nCell].Length < sz ) - Array.Resize( ref apCell[nCell], sz ); - Buffer.BlockCopy( pTemp, leafCorrection, apCell[nCell], 0, sz );//apCell[nCell] = pTemp + leafCorrection; - Debug.Assert( leafCorrection == 0 || leafCorrection == 4 ); - szCell[nCell] = (u16)( szCell[nCell] - leafCorrection ); - if ( 0 == pOld.leaf ) - { - Debug.Assert( leafCorrection == 0 ); - Debug.Assert( pOld.hdrOffset == 0 ); - /* The right pointer of the child page pOld becomes the left - ** pointer of the divider cell */ - Buffer.BlockCopy( pOld.aData, 8, apCell[nCell], 0, 4 );//memcpy( apCell[nCell], ref pOld.aData[8], 4 ); - } - else - { - Debug.Assert( leafCorrection == 4 ); - if ( szCell[nCell] < 4 ) - { - /* Do not allow any cells smaller than 4 bytes. */ - szCell[nCell] = 4; - } - } - nCell++; - } - } - - /* - ** Figure out the number of pages needed to hold all nCell cells. - ** Store this number in "k". Also compute szNew[] which is the total - ** size of all cells on the i-th page and cntNew[] which is the index - ** in apCell[] of the cell that divides page i from page i+1. - ** cntNew[k] should equal nCell. - ** - ** Values computed by this block: - ** - ** k: The total number of sibling pages - ** szNew[i]: Spaced used on the i-th sibling page. - ** cntNew[i]: Index in apCell[] and szCell[] for the first cell to - ** the right of the i-th sibling page. - ** usableSpace: Number of bytes of space available on each sibling. - ** - */ - usableSpace = (int)pBt.usableSize - 12 + leafCorrection; - for ( subtotal = k = i = 0; i < nCell; i++ ) - { - Debug.Assert( i < nMaxCells ); - subtotal += szCell[i] + 2; - if ( subtotal > usableSpace ) - { - szNew[k] = subtotal - szCell[i]; - cntNew[k] = i; - if ( leafData != 0 ) - { - i--; - } - subtotal = 0; - k++; - if ( k > NB + 1 ) - { - rc = SQLITE_CORRUPT_BKPT(); - goto balance_cleanup; - } - } - } - szNew[k] = subtotal; - cntNew[k] = nCell; - k++; - - /* - ** The packing computed by the previous block is biased toward the siblings - ** on the left side. The left siblings are always nearly full, while the - ** right-most sibling might be nearly empty. This block of code attempts - ** to adjust the packing of siblings to get a better balance. - ** - ** This adjustment is more than an optimization. The packing above might - ** be so out of balance as to be illegal. For example, the right-most - ** sibling might be completely empty. This adjustment is not optional. - */ - for ( i = k - 1; i > 0; i-- ) - { - int szRight = szNew[i]; /* Size of sibling on the right */ - int szLeft = szNew[i - 1]; /* Size of sibling on the left */ - int r; /* Index of right-most cell in left sibling */ - int d; /* Index of first cell to the left of right sibling */ - - r = cntNew[i - 1] - 1; - d = r + 1 - leafData; - Debug.Assert( d < nMaxCells ); - Debug.Assert( r < nMaxCells ); - while ( szRight == 0 || szRight + szCell[d] + 2 <= szLeft - ( szCell[r] + 2 ) ) - { - szRight += szCell[d] + 2; - szLeft -= szCell[r] + 2; - cntNew[i - 1]--; - r = cntNew[i - 1] - 1; - d = r + 1 - leafData; - } - szNew[i] = szRight; - szNew[i - 1] = szLeft; - } - - /* Either we found one or more cells (cntnew[0])>0) or pPage is - ** a virtual root page. A virtual root page is when the real root - ** page is page 1 and we are the only child of that page. - */ - Debug.Assert( cntNew[0] > 0 || ( pParent.pgno == 1 && pParent.nCell == 0 ) ); - - TRACE( "BALANCE: old: %d %d %d ", - apOld[0].pgno, - nOld >= 2 ? apOld[1].pgno : 0, - nOld >= 3 ? apOld[2].pgno : 0 - ); - - /* - ** Allocate k new pages. Reuse old pages where possible. - */ - if ( apOld[0].pgno <= 1 ) - { - rc = SQLITE_CORRUPT_BKPT(); - goto balance_cleanup; - } - pageFlags = apOld[0].aData[0]; - for ( i = 0; i < k; i++ ) - { - MemPage pNew = new MemPage(); - if ( i < nOld ) - { - pNew = apNew[i] = apOld[i]; - apOld[i] = null; - rc = sqlite3PagerWrite( pNew.pDbPage ); - nNew++; - if ( rc != 0 ) - goto balance_cleanup; - } - else - { - Debug.Assert( i > 0 ); - rc = allocateBtreePage( pBt, ref pNew, ref pgno, pgno, 0 ); - if ( rc != 0 ) - goto balance_cleanup; - apNew[i] = pNew; - nNew++; - - /* Set the pointer-map entry for the new sibling page. */ + /* Make nMaxCells a multiple of 4 in order to preserve 8-byte + ** alignment */ + nMaxCells = (nMaxCells + 3) & ~3; + + /* + ** Allocate space for memory structures + */ + //k = pBt.pageSize + ROUND8(sizeof(MemPage)); + //szScratch = + // nMaxCells*sizeof(u8*) /* apCell */ + // + nMaxCells*sizeof(u16) /* szCell */ + // + pBt.pageSize /* aSpace1 */ + // + k*nOld; /* Page copies (apCopy) */ + apCell = sqlite3ScratchMalloc(apCell, nMaxCells); + //if( apCell==null ){ + // rc = SQLITE_NOMEM; + // goto balance_cleanup; + //} + if (szCell.Length < nMaxCells) + Array.Resize(ref szCell, nMaxCells); //(u16*)&apCell[nMaxCells]; + //aSpace1 = new byte[pBt.pageSize * (nMaxCells)];// aSpace1 = (u8*)&szCell[nMaxCells]; + //Debug.Assert( EIGHT_BYTE_ALIGNMENT(aSpace1) ); + + /* + ** Load pointers to all cells on sibling pages and the divider cells + ** into the local apCell[] array. Make copies of the divider cells + ** into space obtained from aSpace1[] and remove the the divider Cells + ** from pParent. + ** + ** If the siblings are on leaf pages, then the child pointers of the + ** divider cells are stripped from the cells before they are copied + ** into aSpace1[]. In this way, all cells in apCell[] are without + ** child pointers. If siblings are not leaves, then all cell in + ** apCell[] include child pointers. Either way, all cells in apCell[] + ** are alike. + ** + ** leafCorrection: 4 if pPage is a leaf. 0 if pPage is not a leaf. + ** leafData: 1 if pPage holds key+data and pParent holds only keys. + */ + leafCorrection = (u16)(apOld[0].leaf * 4); + leafData = apOld[0].hasData; + for (i = 0; i < nOld; i++) { + int limit; + + /* Before doing anything else, take a copy of the i'th original sibling + ** The rest of this function will use data from the copies rather + ** that the original pages since the original pages will be in the + ** process of being overwritten. */ + //MemPage pOld = apCopy[i] = (MemPage*)&aSpace1[pBt.pageSize + k*i]; + //memcpy(pOld, apOld[i], sizeof(MemPage)); + //pOld.aData = (void*)&pOld[1]; + //memcpy(pOld.aData, apOld[i].aData, pBt.pageSize); + MemPage pOld = apCopy[i] = apOld[i].Copy(); + + limit = pOld.nCell + pOld.nOverflow; + if (pOld.nOverflow > 0 || true) { + for (j = 0; j < limit; j++) { + Debug.Assert(nCell < nMaxCells); + //apCell[nCell] = findOverflowCell( pOld, j ); + //szCell[nCell] = cellSizePtr( pOld, apCell, nCell ); + int iFOFC = findOverflowCell(pOld, j); + szCell[nCell] = cellSizePtr(pOld, iFOFC); + // Copy the Data Locally + if (apCell[nCell] == null) + apCell[nCell] = new u8[szCell[nCell]]; + else if (apCell[nCell].Length < szCell[nCell]) + Array.Resize(ref apCell[nCell], szCell[nCell]); + if (iFOFC < 0) // Overflow Cell + Buffer.BlockCopy(pOld.aOvfl[-(iFOFC + 1)].pCell, 0, apCell[nCell], 0, szCell[nCell]); + else + Buffer.BlockCopy(pOld.aData, iFOFC, apCell[nCell], 0, szCell[nCell]); + nCell++; + } + } else { + u8[] aData = pOld.aData; + u16 maskPage = pOld.maskPage; + u16 cellOffset = pOld.cellOffset; + for (j = 0; j < limit; j++) { + Debugger.Break(); + Debug.Assert(nCell < nMaxCells); + apCell[nCell] = findCellv2(aData, maskPage, cellOffset, j); + szCell[nCell] = cellSizePtr(pOld, apCell[nCell]); + nCell++; + } + } + if (i < nOld - 1 && 0 == leafData) { + u16 sz = (u16)szNew[i]; + byte[] pTemp = sqlite3Malloc(sz + leafCorrection); + Debug.Assert(nCell < nMaxCells); + szCell[nCell] = sz; + //pTemp = &aSpace1[iSpace1]; + //iSpace1 += sz; + Debug.Assert(sz <= pBt.maxLocal + 23); + //Debug.Assert(iSpace1 <= (int)pBt.pageSize); + Buffer.BlockCopy(pParent.aData, apDiv[i], pTemp, 0, sz);//memcpy( pTemp, apDiv[i], sz ); + if (apCell[nCell] == null || apCell[nCell].Length < sz) + Array.Resize(ref apCell[nCell], sz); + Buffer.BlockCopy(pTemp, leafCorrection, apCell[nCell], 0, sz);//apCell[nCell] = pTemp + leafCorrection; + Debug.Assert(leafCorrection == 0 || leafCorrection == 4); + szCell[nCell] = (u16)(szCell[nCell] - leafCorrection); + if (0 == pOld.leaf) { + Debug.Assert(leafCorrection == 0); + Debug.Assert(pOld.hdrOffset == 0); + /* The right pointer of the child page pOld becomes the left + ** pointer of the divider cell */ + Buffer.BlockCopy(pOld.aData, 8, apCell[nCell], 0, 4);//memcpy( apCell[nCell], ref pOld.aData[8], 4 ); + } else { + Debug.Assert(leafCorrection == 4); + if (szCell[nCell] < 4) { + /* Do not allow any cells smaller than 4 bytes. */ + szCell[nCell] = 4; + } + } + nCell++; + } + } + + /* + ** Figure out the number of pages needed to hold all nCell cells. + ** Store this number in "k". Also compute szNew[] which is the total + ** size of all cells on the i-th page and cntNew[] which is the index + ** in apCell[] of the cell that divides page i from page i+1. + ** cntNew[k] should equal nCell. + ** + ** Values computed by this block: + ** + ** k: The total number of sibling pages + ** szNew[i]: Spaced used on the i-th sibling page. + ** cntNew[i]: Index in apCell[] and szCell[] for the first cell to + ** the right of the i-th sibling page. + ** usableSpace: Number of bytes of space available on each sibling. + ** + */ + usableSpace = (int)pBt.usableSize - 12 + leafCorrection; + for (subtotal = k = i = 0; i < nCell; i++) { + Debug.Assert(i < nMaxCells); + subtotal += szCell[i] + 2; + if (subtotal > usableSpace) { + szNew[k] = subtotal - szCell[i]; + cntNew[k] = i; + if (leafData != 0) { + i--; + } + subtotal = 0; + k++; + if (k > NB + 1) { + rc = SQLITE_CORRUPT_BKPT(); + goto balance_cleanup; + } + } + } + szNew[k] = subtotal; + cntNew[k] = nCell; + k++; + + /* + ** The packing computed by the previous block is biased toward the siblings + ** on the left side. The left siblings are always nearly full, while the + ** right-most sibling might be nearly empty. This block of code attempts + ** to adjust the packing of siblings to get a better balance. + ** + ** This adjustment is more than an optimization. The packing above might + ** be so out of balance as to be illegal. For example, the right-most + ** sibling might be completely empty. This adjustment is not optional. + */ + for (i = k - 1; i > 0; i--) { + int szRight = szNew[i]; /* Size of sibling on the right */ + int szLeft = szNew[i - 1]; /* Size of sibling on the left */ + int r; /* Index of right-most cell in left sibling */ + int d; /* Index of first cell to the left of right sibling */ + + r = cntNew[i - 1] - 1; + d = r + 1 - leafData; + Debug.Assert(d < nMaxCells); + Debug.Assert(r < nMaxCells); + while (szRight == 0 || szRight + szCell[d] + 2 <= szLeft - (szCell[r] + 2)) { + szRight += szCell[d] + 2; + szLeft -= szCell[r] + 2; + cntNew[i - 1]--; + r = cntNew[i - 1] - 1; + d = r + 1 - leafData; + } + szNew[i] = szRight; + szNew[i - 1] = szLeft; + } + + /* Either we found one or more cells (cntnew[0])>0) or pPage is + ** a virtual root page. A virtual root page is when the real root + ** page is page 1 and we are the only child of that page. + */ + Debug.Assert(cntNew[0] > 0 || (pParent.pgno == 1 && pParent.nCell == 0)); + + TRACE("BALANCE: old: %d %d %d ", + apOld[0].pgno, + nOld >= 2 ? apOld[1].pgno : 0, + nOld >= 3 ? apOld[2].pgno : 0 + ); + + /* + ** Allocate k new pages. Reuse old pages where possible. + */ + if (apOld[0].pgno <= 1) { + rc = SQLITE_CORRUPT_BKPT(); + goto balance_cleanup; + } + pageFlags = apOld[0].aData[0]; + for (i = 0; i < k; i++) { + MemPage pNew = new MemPage(); + if (i < nOld) { + pNew = apNew[i] = apOld[i]; + apOld[i] = null; + rc = sqlite3PagerWrite(pNew.pDbPage); + nNew++; + if (rc != 0) + goto balance_cleanup; + } else { + Debug.Assert(i > 0); + rc = allocateBtreePage(pBt, ref pNew, ref pgno, pgno, 0); + if (rc != 0) + goto balance_cleanup; + apNew[i] = pNew; + nNew++; + + /* Set the pointer-map entry for the new sibling page. */ #if !SQLITE_OMIT_AUTOVACUUM // if ( ISAUTOVACUUM ) - if ( pBt.autoVacuum ) + if (pBt.autoVacuum) #else if (false) #endif - { - ptrmapPut( pBt, pNew.pgno, PTRMAP_BTREE, pParent.pgno, ref rc ); - if ( rc != SQLITE_OK ) - { - goto balance_cleanup; - } - } - } - } - - /* Free any old pages that were not reused as new pages. - */ - while ( i < nOld ) - { - freePage( apOld[i], ref rc ); - if ( rc != 0 ) - goto balance_cleanup; - releasePage( apOld[i] ); - apOld[i] = null; - i++; - } - - /* - ** Put the new pages in accending order. This helps to - ** keep entries in the disk file in order so that a scan - ** of the table is a linear scan through the file. That - ** in turn helps the operating system to deliver pages - ** from the disk more rapidly. - ** - ** An O(n^2) insertion sort algorithm is used, but since - ** n is never more than NB (a small constant), that should - ** not be a problem. - ** - ** When NB==3, this one optimization makes the database - ** about 25% faster for large insertions and deletions. - */ - for ( i = 0; i < k - 1; i++ ) - { - int minV = (int)apNew[i].pgno; - int minI = i; - for ( j = i + 1; j < k; j++ ) - { - if ( apNew[j].pgno < (u32)minV ) - { - minI = j; - minV = (int)apNew[j].pgno; - } - } - if ( minI > i ) - { - MemPage pT; - pT = apNew[i]; - apNew[i] = apNew[minI]; - apNew[minI] = pT; - } - } - TRACE( "new: %d(%d) %d(%d) %d(%d) %d(%d) %d(%d)\n", - apNew[0].pgno, szNew[0], - nNew >= 2 ? apNew[1].pgno : 0, nNew >= 2 ? szNew[1] : 0, - nNew >= 3 ? apNew[2].pgno : 0, nNew >= 3 ? szNew[2] : 0, - nNew >= 4 ? apNew[3].pgno : 0, nNew >= 4 ? szNew[3] : 0, - nNew >= 5 ? apNew[4].pgno : 0, nNew >= 5 ? szNew[4] : 0 ); - - Debug.Assert( sqlite3PagerIswriteable( pParent.pDbPage ) ); - sqlite3Put4byte( pParent.aData, pRight, apNew[nNew - 1].pgno ); - - /* - ** Evenly distribute the data in apCell[] across the new pages. - ** Insert divider cells into pParent as necessary. - */ - j = 0; - for ( i = 0; i < nNew; i++ ) - { - /* Assemble the new sibling page. */ - MemPage pNew = apNew[i]; - Debug.Assert( j < nMaxCells ); - zeroPage( pNew, pageFlags ); - assemblePage( pNew, cntNew[i] - j, apCell, szCell, j ); - Debug.Assert( pNew.nCell > 0 || ( nNew == 1 && cntNew[0] == 0 ) ); - Debug.Assert( pNew.nOverflow == 0 ); - - j = cntNew[i]; - - /* If the sibling page assembled above was not the right-most sibling, - ** insert a divider cell into the parent page. - */ - Debug.Assert( i < nNew - 1 || j == nCell ); - if ( j < nCell ) - { - u8[] pCell; - u8[] pTemp; - int sz; - - Debug.Assert( j < nMaxCells ); - pCell = apCell[j]; - sz = szCell[j] + leafCorrection; - pTemp = sqlite3Malloc( sz );//&aOvflSpace[iOvflSpace]; - if ( 0 == pNew.leaf ) - { - Buffer.BlockCopy( pCell, 0, pNew.aData, 8, 4 );//memcpy( pNew.aData[8], pCell, 4 ); - } - else if ( leafData != 0 ) - { - /* If the tree is a leaf-data tree, and the siblings are leaves, - ** then there is no divider cell in apCell[]. Instead, the divider - ** cell consists of the integer key for the right-most cell of - ** the sibling-page assembled above only. - */ - CellInfo info = new CellInfo(); - j--; - btreeParseCellPtr( pNew, apCell[j], ref info ); - pCell = pTemp; - sz = 4 + putVarint( pCell, 4, (u64)info.nKey ); - pTemp = null; - } - else - { - //------------ pCell -= 4; - byte[] _pCell_4 = sqlite3Malloc( pCell.Length + 4 ); - Buffer.BlockCopy( pCell, 0, _pCell_4, 4, pCell.Length ); - pCell = _pCell_4; - // - /* Obscure case for non-leaf-data trees: If the cell at pCell was - ** previously stored on a leaf node, and its reported size was 4 - ** bytes, then it may actually be smaller than this - ** (see btreeParseCellPtr(), 4 bytes is the minimum size of - ** any cell). But it is important to pass the correct size to - ** insertCell(), so reparse the cell now. - ** - ** Note that this can never happen in an SQLite data file, as all - ** cells are at least 4 bytes. It only happens in b-trees used - ** to evaluate "IN (SELECT ...)" and similar clauses. - */ - if ( szCell[j] == 4 ) - { - Debug.Assert( leafCorrection == 4 ); - sz = cellSizePtr( pParent, pCell ); - } - } - iOvflSpace += sz; - Debug.Assert( sz <= pBt.maxLocal + 23 ); - Debug.Assert( iOvflSpace <= (int)pBt.pageSize ); - insertCell( pParent, nxDiv, pCell, sz, pTemp, pNew.pgno, ref rc ); - if ( rc != SQLITE_OK ) - goto balance_cleanup; - Debug.Assert( sqlite3PagerIswriteable( pParent.pDbPage ) ); - - j++; - nxDiv++; - } - } - Debug.Assert( j == nCell ); - Debug.Assert( nOld > 0 ); - Debug.Assert( nNew > 0 ); - if ( ( pageFlags & PTF_LEAF ) == 0 ) - { - Buffer.BlockCopy( apCopy[nOld - 1].aData, 8, apNew[nNew - 1].aData, 8, 4 ); //u8* zChild = &apCopy[nOld - 1].aData[8]; - //memcpy( apNew[nNew - 1].aData[8], zChild, 4 ); - } - - if ( isRoot != 0 && pParent.nCell == 0 && pParent.hdrOffset <= apNew[0].nFree ) - { - /* The root page of the b-tree now contains no cells. The only sibling - ** page is the right-child of the parent. Copy the contents of the - ** child page into the parent, decreasing the overall height of the - ** b-tree structure by one. This is described as the "balance-shallower" - ** sub-algorithm in some documentation. - ** - ** If this is an auto-vacuum database, the call to copyNodeContent() - ** sets all pointer-map entries corresponding to database image pages - ** for which the pointer is stored within the content being copied. - ** - ** The second Debug.Assert below verifies that the child page is defragmented - ** (it must be, as it was just reconstructed using assemblePage()). This - ** is important if the parent page happens to be page 1 of the database - ** image. */ - Debug.Assert( nNew == 1 ); - Debug.Assert( apNew[0].nFree == - ( get2byte( apNew[0].aData, 5 ) - apNew[0].cellOffset - apNew[0].nCell * 2 ) - ); - copyNodeContent( apNew[0], pParent, ref rc ); - freePage( apNew[0], ref rc ); - } - else + { + ptrmapPut(pBt, pNew.pgno, PTRMAP_BTREE, pParent.pgno, ref rc); + if (rc != SQLITE_OK) { + goto balance_cleanup; + } + } + } + } + + /* Free any old pages that were not reused as new pages. + */ + while (i < nOld) { + freePage(apOld[i], ref rc); + if (rc != 0) + goto balance_cleanup; + releasePage(apOld[i]); + apOld[i] = null; + i++; + } + + /* + ** Put the new pages in accending order. This helps to + ** keep entries in the disk file in order so that a scan + ** of the table is a linear scan through the file. That + ** in turn helps the operating system to deliver pages + ** from the disk more rapidly. + ** + ** An O(n^2) insertion sort algorithm is used, but since + ** n is never more than NB (a small constant), that should + ** not be a problem. + ** + ** When NB==3, this one optimization makes the database + ** about 25% faster for large insertions and deletions. + */ + for (i = 0; i < k - 1; i++) { + int minV = (int)apNew[i].pgno; + int minI = i; + for (j = i + 1; j < k; j++) { + if (apNew[j].pgno < (u32)minV) { + minI = j; + minV = (int)apNew[j].pgno; + } + } + if (minI > i) { + MemPage pT; + pT = apNew[i]; + apNew[i] = apNew[minI]; + apNew[minI] = pT; + } + } + TRACE("new: %d(%d) %d(%d) %d(%d) %d(%d) %d(%d)\n", + apNew[0].pgno, szNew[0], + nNew >= 2 ? apNew[1].pgno : 0, nNew >= 2 ? szNew[1] : 0, + nNew >= 3 ? apNew[2].pgno : 0, nNew >= 3 ? szNew[2] : 0, + nNew >= 4 ? apNew[3].pgno : 0, nNew >= 4 ? szNew[3] : 0, + nNew >= 5 ? apNew[4].pgno : 0, nNew >= 5 ? szNew[4] : 0); + + Debug.Assert(sqlite3PagerIswriteable(pParent.pDbPage)); + sqlite3Put4byte(pParent.aData, pRight, apNew[nNew - 1].pgno); + + /* + ** Evenly distribute the data in apCell[] across the new pages. + ** Insert divider cells into pParent as necessary. + */ + j = 0; + for (i = 0; i < nNew; i++) { + /* Assemble the new sibling page. */ + MemPage pNew = apNew[i]; + Debug.Assert(j < nMaxCells); + zeroPage(pNew, pageFlags); + assemblePage(pNew, cntNew[i] - j, apCell, szCell, j); + Debug.Assert(pNew.nCell > 0 || (nNew == 1 && cntNew[0] == 0)); + Debug.Assert(pNew.nOverflow == 0); + + j = cntNew[i]; + + /* If the sibling page assembled above was not the right-most sibling, + ** insert a divider cell into the parent page. + */ + Debug.Assert(i < nNew - 1 || j == nCell); + if (j < nCell) { + u8[] pCell; + u8[] pTemp; + int sz; + + Debug.Assert(j < nMaxCells); + pCell = apCell[j]; + sz = szCell[j] + leafCorrection; + pTemp = sqlite3Malloc(sz);//&aOvflSpace[iOvflSpace]; + if (0 == pNew.leaf) { + Buffer.BlockCopy(pCell, 0, pNew.aData, 8, 4);//memcpy( pNew.aData[8], pCell, 4 ); + } else if (leafData != 0) { + /* If the tree is a leaf-data tree, and the siblings are leaves, + ** then there is no divider cell in apCell[]. Instead, the divider + ** cell consists of the integer key for the right-most cell of + ** the sibling-page assembled above only. + */ + CellInfo info = new CellInfo(); + j--; + btreeParseCellPtr(pNew, apCell[j], ref info); + pCell = pTemp; + sz = 4 + putVarint(pCell, 4, (u64)info.nKey); + pTemp = null; + } else { + //------------ pCell -= 4; + byte[] _pCell_4 = sqlite3Malloc(pCell.Length + 4); + Buffer.BlockCopy(pCell, 0, _pCell_4, 4, pCell.Length); + pCell = _pCell_4; + // + /* Obscure case for non-leaf-data trees: If the cell at pCell was + ** previously stored on a leaf node, and its reported size was 4 + ** bytes, then it may actually be smaller than this + ** (see btreeParseCellPtr(), 4 bytes is the minimum size of + ** any cell). But it is important to pass the correct size to + ** insertCell(), so reparse the cell now. + ** + ** Note that this can never happen in an SQLite data file, as all + ** cells are at least 4 bytes. It only happens in b-trees used + ** to evaluate "IN (SELECT ...)" and similar clauses. + */ + if (szCell[j] == 4) { + Debug.Assert(leafCorrection == 4); + sz = cellSizePtr(pParent, pCell); + } + } + iOvflSpace += sz; + Debug.Assert(sz <= pBt.maxLocal + 23); + Debug.Assert(iOvflSpace <= (int)pBt.pageSize); + insertCell(pParent, nxDiv, pCell, sz, pTemp, pNew.pgno, ref rc); + if (rc != SQLITE_OK) + goto balance_cleanup; + Debug.Assert(sqlite3PagerIswriteable(pParent.pDbPage)); + + j++; + nxDiv++; + } + } + Debug.Assert(j == nCell); + Debug.Assert(nOld > 0); + Debug.Assert(nNew > 0); + if ((pageFlags & PTF_LEAF) == 0) { + Buffer.BlockCopy(apCopy[nOld - 1].aData, 8, apNew[nNew - 1].aData, 8, 4); //u8* zChild = &apCopy[nOld - 1].aData[8]; + //memcpy( apNew[nNew - 1].aData[8], zChild, 4 ); + } + + if (isRoot != 0 && pParent.nCell == 0 && pParent.hdrOffset <= apNew[0].nFree) { + /* The root page of the b-tree now contains no cells. The only sibling + ** page is the right-child of the parent. Copy the contents of the + ** child page into the parent, decreasing the overall height of the + ** b-tree structure by one. This is described as the "balance-shallower" + ** sub-algorithm in some documentation. + ** + ** If this is an auto-vacuum database, the call to copyNodeContent() + ** sets all pointer-map entries corresponding to database image pages + ** for which the pointer is stored within the content being copied. + ** + ** The second Debug.Assert below verifies that the child page is defragmented + ** (it must be, as it was just reconstructed using assemblePage()). This + ** is important if the parent page happens to be page 1 of the database + ** image. */ + Debug.Assert(nNew == 1); + Debug.Assert(apNew[0].nFree == + (get2byte(apNew[0].aData, 5) - apNew[0].cellOffset - apNew[0].nCell * 2) + ); + copyNodeContent(apNew[0], pParent, ref rc); + freePage(apNew[0], ref rc); + } else #if !SQLITE_OMIT_AUTOVACUUM // if ( ISAUTOVACUUM ) - if ( pBt.autoVacuum ) + if (pBt.autoVacuum) #else if (false) #endif - { - /* Fix the pointer-map entries for all the cells that were shifted around. - ** There are several different types of pointer-map entries that need to - ** be dealt with by this routine. Some of these have been set already, but - ** many have not. The following is a summary: - ** - ** 1) The entries associated with new sibling pages that were not - ** siblings when this function was called. These have already - ** been set. We don't need to worry about old siblings that were - ** moved to the free-list - the freePage() code has taken care - ** of those. - ** - ** 2) The pointer-map entries associated with the first overflow - ** page in any overflow chains used by new divider cells. These - ** have also already been taken care of by the insertCell() code. - ** - ** 3) If the sibling pages are not leaves, then the child pages of - ** cells stored on the sibling pages may need to be updated. - ** - ** 4) If the sibling pages are not internal intkey nodes, then any - ** overflow pages used by these cells may need to be updated - ** (internal intkey nodes never contain pointers to overflow pages). - ** - ** 5) If the sibling pages are not leaves, then the pointer-map - ** entries for the right-child pages of each sibling may need - ** to be updated. - ** - ** Cases 1 and 2 are dealt with above by other code. The next - ** block deals with cases 3 and 4 and the one after that, case 5. Since - ** setting a pointer map entry is a relatively expensive operation, this - ** code only sets pointer map entries for child or overflow pages that have - ** actually moved between pages. */ - MemPage pNew = apNew[0]; - MemPage pOld = apCopy[0]; - int nOverflow = pOld.nOverflow; - int iNextOld = pOld.nCell + nOverflow; - int iOverflow = ( nOverflow != 0 ? pOld.aOvfl[0].idx : -1 ); - j = 0; /* Current 'old' sibling page */ - k = 0; /* Current 'new' sibling page */ - for ( i = 0; i < nCell; i++ ) - { - int isDivider = 0; - while ( i == iNextOld ) - { - /* Cell i is the cell immediately following the last cell on old - ** sibling page j. If the siblings are not leaf pages of an - ** intkey b-tree, then cell i was a divider cell. */ - pOld = apCopy[++j]; - iNextOld = i + ( 0 == leafData ? 1 : 0 ) + pOld.nCell + pOld.nOverflow; - if ( pOld.nOverflow != 0 ) - { - nOverflow = pOld.nOverflow; - iOverflow = i + ( 0 == leafData ? 1 : 0 ) + pOld.aOvfl[0].idx; - } - isDivider = 0 == leafData ? 1 : 0; - } - - Debug.Assert( nOverflow > 0 || iOverflow < i ); - Debug.Assert( nOverflow < 2 || pOld.aOvfl[0].idx == pOld.aOvfl[1].idx - 1 ); - Debug.Assert( nOverflow < 3 || pOld.aOvfl[1].idx == pOld.aOvfl[2].idx - 1 ); - if ( i == iOverflow ) - { - isDivider = 1; - if ( ( --nOverflow ) > 0 ) - { - iOverflow++; - } - } - - if ( i == cntNew[k] ) - { - /* Cell i is the cell immediately following the last cell on new - ** sibling page k. If the siblings are not leaf pages of an - ** intkey b-tree, then cell i is a divider cell. */ - pNew = apNew[++k]; - if ( 0 == leafData ) - continue; - } - Debug.Assert( j < nOld ); - Debug.Assert( k < nNew ); - - /* If the cell was originally divider cell (and is not now) or - ** an overflow cell, or if the cell was located on a different sibling - ** page before the balancing, then the pointer map entries associated - ** with any child or overflow pages need to be updated. */ - if ( isDivider != 0 || pOld.pgno != pNew.pgno ) - { - if ( 0 == leafCorrection ) - { - ptrmapPut( pBt, sqlite3Get4byte( apCell[i] ), PTRMAP_BTREE, pNew.pgno, ref rc ); - } - if ( szCell[i] > pNew.minLocal ) - { - ptrmapPutOvflPtr( pNew, apCell[i], ref rc ); - } - } - } - - if ( 0 == leafCorrection ) - { - for ( i = 0; i < nNew; i++ ) - { - u32 key = sqlite3Get4byte( apNew[i].aData, 8 ); - ptrmapPut( pBt, key, PTRMAP_BTREE, apNew[i].pgno, ref rc ); - } - } + { + /* Fix the pointer-map entries for all the cells that were shifted around. + ** There are several different types of pointer-map entries that need to + ** be dealt with by this routine. Some of these have been set already, but + ** many have not. The following is a summary: + ** + ** 1) The entries associated with new sibling pages that were not + ** siblings when this function was called. These have already + ** been set. We don't need to worry about old siblings that were + ** moved to the free-list - the freePage() code has taken care + ** of those. + ** + ** 2) The pointer-map entries associated with the first overflow + ** page in any overflow chains used by new divider cells. These + ** have also already been taken care of by the insertCell() code. + ** + ** 3) If the sibling pages are not leaves, then the child pages of + ** cells stored on the sibling pages may need to be updated. + ** + ** 4) If the sibling pages are not internal intkey nodes, then any + ** overflow pages used by these cells may need to be updated + ** (internal intkey nodes never contain pointers to overflow pages). + ** + ** 5) If the sibling pages are not leaves, then the pointer-map + ** entries for the right-child pages of each sibling may need + ** to be updated. + ** + ** Cases 1 and 2 are dealt with above by other code. The next + ** block deals with cases 3 and 4 and the one after that, case 5. Since + ** setting a pointer map entry is a relatively expensive operation, this + ** code only sets pointer map entries for child or overflow pages that have + ** actually moved between pages. */ + MemPage pNew = apNew[0]; + MemPage pOld = apCopy[0]; + int nOverflow = pOld.nOverflow; + int iNextOld = pOld.nCell + nOverflow; + int iOverflow = (nOverflow != 0 ? pOld.aOvfl[0].idx : -1); + j = 0; /* Current 'old' sibling page */ + k = 0; /* Current 'new' sibling page */ + for (i = 0; i < nCell; i++) { + int isDivider = 0; + while (i == iNextOld) { + /* Cell i is the cell immediately following the last cell on old + ** sibling page j. If the siblings are not leaf pages of an + ** intkey b-tree, then cell i was a divider cell. */ + pOld = apCopy[++j]; + iNextOld = i + (0 == leafData ? 1 : 0) + pOld.nCell + pOld.nOverflow; + if (pOld.nOverflow != 0) { + nOverflow = pOld.nOverflow; + iOverflow = i + (0 == leafData ? 1 : 0) + pOld.aOvfl[0].idx; + } + isDivider = 0 == leafData ? 1 : 0; + } + + Debug.Assert(nOverflow > 0 || iOverflow < i); + Debug.Assert(nOverflow < 2 || pOld.aOvfl[0].idx == pOld.aOvfl[1].idx - 1); + Debug.Assert(nOverflow < 3 || pOld.aOvfl[1].idx == pOld.aOvfl[2].idx - 1); + if (i == iOverflow) { + isDivider = 1; + if ((--nOverflow) > 0) { + iOverflow++; + } + } + + if (i == cntNew[k]) { + /* Cell i is the cell immediately following the last cell on new + ** sibling page k. If the siblings are not leaf pages of an + ** intkey b-tree, then cell i is a divider cell. */ + pNew = apNew[++k]; + if (0 == leafData) + continue; + } + Debug.Assert(j < nOld); + Debug.Assert(k < nNew); + + /* If the cell was originally divider cell (and is not now) or + ** an overflow cell, or if the cell was located on a different sibling + ** page before the balancing, then the pointer map entries associated + ** with any child or overflow pages need to be updated. */ + if (isDivider != 0 || pOld.pgno != pNew.pgno) { + if (0 == leafCorrection) { + ptrmapPut(pBt, sqlite3Get4byte(apCell[i]), PTRMAP_BTREE, pNew.pgno, ref rc); + } + if (szCell[i] > pNew.minLocal) { + ptrmapPutOvflPtr(pNew, apCell[i], ref rc); + } + } + } + + if (0 == leafCorrection) { + for (i = 0; i < nNew; i++) { + u32 key = sqlite3Get4byte(apNew[i].aData, 8); + ptrmapPut(pBt, key, PTRMAP_BTREE, apNew[i].pgno, ref rc); + } + } #if FALSE /* The ptrmapCheckPages() contains Debug.Assert() statements that verify that @@ -7549,579 +6860,539 @@ static int balance_nonroot( ptrmapCheckPages(apNew, nNew); ptrmapCheckPages(pParent, 1); #endif - } + } - Debug.Assert( pParent.isInit != 0 ); - TRACE( "BALANCE: finished: old=%d new=%d cells=%d\n", - nOld, nNew, nCell ); + Debug.Assert(pParent.isInit != 0); + TRACE("BALANCE: finished: old=%d new=%d cells=%d\n", + nOld, nNew, nCell); -/* -** Cleanup before returning. -*/ -balance_cleanup: - sqlite3ScratchFree( apCell ); - for ( i = 0; i < nOld; i++ ) - { - releasePage( apOld[i] ); - } - for ( i = 0; i < nNew; i++ ) - { - releasePage( apNew[i] ); - } - - return rc; -} + /* + ** Cleanup before returning. + */ + balance_cleanup: + sqlite3ScratchFree(apCell); + for (i = 0; i < nOld; i++) { + releasePage(apOld[i]); + } + for (i = 0; i < nNew; i++) { + releasePage(apNew[i]); + } + + return rc; + } -/* -** This function is called when the root page of a b-tree structure is -** overfull (has one or more overflow pages). -** -** A new child page is allocated and the contents of the current root -** page, including overflow cells, are copied into the child. The root -** page is then overwritten to make it an empty page with the right-child -** pointer pointing to the new page. -** -** Before returning, all pointer-map entries corresponding to pages -** that the new child-page now contains pointers to are updated. The -** entry corresponding to the new right-child pointer of the root -** page is also updated. -** -** If successful, ppChild is set to contain a reference to the child -** page and SQLITE_OK is returned. In this case the caller is required -** to call releasePage() on ppChild exactly once. If an error occurs, -** an error code is returned and ppChild is set to 0. -*/ -static int balance_deeper( MemPage pRoot, ref MemPage ppChild ) -{ - int rc; /* Return value from subprocedures */ - MemPage pChild = null; /* Pointer to a new child page */ - Pgno pgnoChild = 0; /* Page number of the new child page */ - BtShared pBt = pRoot.pBt; /* The BTree */ - - Debug.Assert( pRoot.nOverflow > 0 ); - Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); - - /* Make pRoot, the root page of the b-tree, writable. Allocate a new - ** page that will become the new right-child of pPage. Copy the contents - ** of the node stored on pRoot into the new child page. - */ - rc = sqlite3PagerWrite( pRoot.pDbPage ); - if ( rc == SQLITE_OK ) - { - rc = allocateBtreePage( pBt, ref pChild, ref pgnoChild, pRoot.pgno, 0 ); - copyNodeContent( pRoot, pChild, ref rc ); + /* + ** This function is called when the root page of a b-tree structure is + ** overfull (has one or more overflow pages). + ** + ** A new child page is allocated and the contents of the current root + ** page, including overflow cells, are copied into the child. The root + ** page is then overwritten to make it an empty page with the right-child + ** pointer pointing to the new page. + ** + ** Before returning, all pointer-map entries corresponding to pages + ** that the new child-page now contains pointers to are updated. The + ** entry corresponding to the new right-child pointer of the root + ** page is also updated. + ** + ** If successful, ppChild is set to contain a reference to the child + ** page and SQLITE_OK is returned. In this case the caller is required + ** to call releasePage() on ppChild exactly once. If an error occurs, + ** an error code is returned and ppChild is set to 0. + */ + static int balance_deeper(MemPage pRoot, ref MemPage ppChild) { + int rc; /* Return value from subprocedures */ + MemPage pChild = null; /* Pointer to a new child page */ + Pgno pgnoChild = 0; /* Page number of the new child page */ + BtShared pBt = pRoot.pBt; /* The BTree */ + + Debug.Assert(pRoot.nOverflow > 0); + Debug.Assert(sqlite3_mutex_held(pBt.mutex)); + + /* Make pRoot, the root page of the b-tree, writable. Allocate a new + ** page that will become the new right-child of pPage. Copy the contents + ** of the node stored on pRoot into the new child page. + */ + rc = sqlite3PagerWrite(pRoot.pDbPage); + if (rc == SQLITE_OK) { + rc = allocateBtreePage(pBt, ref pChild, ref pgnoChild, pRoot.pgno, 0); + copyNodeContent(pRoot, pChild, ref rc); #if !SQLITE_OMIT_AUTOVACUUM // if ( ISAUTOVACUUM ) - if ( pBt.autoVacuum ) + if (pBt.autoVacuum) #else if (false) #endif - { - ptrmapPut( pBt, pgnoChild, PTRMAP_BTREE, pRoot.pgno, ref rc ); - } - } - if ( rc != 0 ) - { - ppChild = null; - releasePage( pChild ); - return rc; - } - Debug.Assert( sqlite3PagerIswriteable( pChild.pDbPage ) ); - Debug.Assert( sqlite3PagerIswriteable( pRoot.pDbPage ) ); - Debug.Assert( pChild.nCell == pRoot.nCell ); - - TRACE( "BALANCE: copy root %d into %d\n", pRoot.pgno, pChild.pgno ); - - /* Copy the overflow cells from pRoot to pChild */ - Array.Copy( pRoot.aOvfl, pChild.aOvfl, pRoot.nOverflow );//memcpy(pChild.aOvfl, pRoot.aOvfl, pRoot.nOverflow*sizeof(pRoot.aOvfl[0])); - pChild.nOverflow = pRoot.nOverflow; - - /* Zero the contents of pRoot. Then install pChild as the right-child. */ - zeroPage( pRoot, pChild.aData[0] & ~PTF_LEAF ); - sqlite3Put4byte( pRoot.aData, pRoot.hdrOffset + 8, pgnoChild ); - - ppChild = pChild; - return SQLITE_OK; -} + { + ptrmapPut(pBt, pgnoChild, PTRMAP_BTREE, pRoot.pgno, ref rc); + } + } + if (rc != 0) { + ppChild = null; + releasePage(pChild); + return rc; + } + Debug.Assert(sqlite3PagerIswriteable(pChild.pDbPage)); + Debug.Assert(sqlite3PagerIswriteable(pRoot.pDbPage)); + Debug.Assert(pChild.nCell == pRoot.nCell); -/* -** The page that pCur currently points to has just been modified in -** some way. This function figures out if this modification means the -** tree needs to be balanced, and if so calls the appropriate balancing -** routine. Balancing routines are: -** -** balance_quick() -** balance_deeper() -** balance_nonroot() -*/ -static u8[] aBalanceQuickSpace = new u8[13]; -static int balance( BtCursor pCur ) -{ - int rc = SQLITE_OK; - int nMin = (int)pCur.pBt.usableSize * 2 / 3; + TRACE("BALANCE: copy root %d into %d\n", pRoot.pgno, pChild.pgno); + + /* Copy the overflow cells from pRoot to pChild */ + Array.Copy(pRoot.aOvfl, pChild.aOvfl, pRoot.nOverflow);//memcpy(pChild.aOvfl, pRoot.aOvfl, pRoot.nOverflow*sizeof(pRoot.aOvfl[0])); + pChild.nOverflow = pRoot.nOverflow; + + /* Zero the contents of pRoot. Then install pChild as the right-child. */ + zeroPage(pRoot, pChild.aData[0] & ~PTF_LEAF); + sqlite3Put4byte(pRoot.aData, pRoot.hdrOffset + 8, pgnoChild); + + ppChild = pChild; + return SQLITE_OK; + } - //u8[] pFree = null; + /* + ** The page that pCur currently points to has just been modified in + ** some way. This function figures out if this modification means the + ** tree needs to be balanced, and if so calls the appropriate balancing + ** routine. Balancing routines are: + ** + ** balance_quick() + ** balance_deeper() + ** balance_nonroot() + */ + static u8[] aBalanceQuickSpace = new u8[13]; + static int balance(BtCursor pCur) { + int rc = SQLITE_OK; + int nMin = (int)pCur.pBt.usableSize * 2 / 3; + + //u8[] pFree = null; #if !NDEBUG || SQLITE_COVERAGE_TEST || DEBUG - int balance_quick_called = 0;//TESTONLY( int balance_quick_called = 0 ); - int balance_deeper_called = 0;//TESTONLY( int balance_deeper_called = 0 ); + int balance_quick_called = 0;//TESTONLY( int balance_quick_called = 0 ); + int balance_deeper_called = 0;//TESTONLY( int balance_deeper_called = 0 ); #else int balance_quick_called = 0; int balance_deeper_called = 0; #endif - do - { - int iPage = pCur.iPage; - MemPage pPage = pCur.apPage[iPage]; + do { + int iPage = pCur.iPage; + MemPage pPage = pCur.apPage[iPage]; + + if (iPage == 0) { + if (pPage.nOverflow != 0) { + /* The root page of the b-tree is overfull. In this case call the + ** balance_deeper() function to create a new child for the root-page + ** and copy the current contents of the root-page to it. The + ** next iteration of the do-loop will balance the child page. + */ + Debug.Assert((balance_deeper_called++) == 0); + rc = balance_deeper(pPage, ref pCur.apPage[1]); + if (rc == SQLITE_OK) { + pCur.iPage = 1; + pCur.aiIdx[0] = 0; + pCur.aiIdx[1] = 0; + Debug.Assert(pCur.apPage[1].nOverflow != 0); + } + } else { + break; + } + } else if (pPage.nOverflow == 0 && pPage.nFree <= nMin) { + break; + } else { + MemPage pParent = pCur.apPage[iPage - 1]; + int iIdx = pCur.aiIdx[iPage - 1]; + + rc = sqlite3PagerWrite(pParent.pDbPage); + if (rc == SQLITE_OK) { +#if !SQLITE_OMIT_QUICKBALANCE + if (pPage.hasData != 0 + && pPage.nOverflow == 1 + && pPage.aOvfl[0].idx == pPage.nCell + && pParent.pgno != 1 + && pParent.nCell == iIdx + ) { + /* Call balance_quick() to create a new sibling of pPage on which + ** to store the overflow cell. balance_quick() inserts a new cell + ** into pParent, which may cause pParent overflow. If this + ** happens, the next interation of the do-loop will balance pParent + ** use either balance_nonroot() or balance_deeper(). Until this + ** happens, the overflow cell is stored in the aBalanceQuickSpace[] + ** buffer. + ** + ** The purpose of the following Debug.Assert() is to check that only a + ** single call to balance_quick() is made for each call to this + ** function. If this were not verified, a subtle bug involving reuse + ** of the aBalanceQuickSpace[] might sneak in. + */ + Debug.Assert((balance_quick_called++) == 0); + rc = balance_quick(pParent, pPage, aBalanceQuickSpace); + } else +#endif + { + /* In this case, call balance_nonroot() to redistribute cells + ** between pPage and up to 2 of its sibling pages. This involves + ** modifying the contents of pParent, which may cause pParent to + ** become overfull or underfull. The next iteration of the do-loop + ** will balance the parent page to correct this. + ** + ** If the parent page becomes overfull, the overflow cell or cells + ** are stored in the pSpace buffer allocated immediately below. + ** A subsequent iteration of the do-loop will deal with this by + ** calling balance_nonroot() (balance_deeper() may be called first, + ** but it doesn't deal with overflow cells - just moves them to a + ** different page). Once this subsequent call to balance_nonroot() + ** has completed, it is safe to release the pSpace buffer used by + ** the previous call, as the overflow cell data will have been + ** copied either into the body of a database page or into the new + ** pSpace buffer passed to the latter call to balance_nonroot(). + */ + ////u8[] pSpace = new u8[pCur.pBt.pageSize];// u8 pSpace = sqlite3PageMalloc( pCur.pBt.pageSize ); + rc = balance_nonroot(pParent, iIdx, null, iPage == 1 ? 1 : 0); + //if (pFree != null) + //{ + // /* If pFree is not NULL, it points to the pSpace buffer used + // ** by a previous call to balance_nonroot(). Its contents are + // ** now stored either on real database pages or within the + // ** new pSpace buffer, so it may be safely freed here. */ + // sqlite3PageFree(ref pFree); + //} + + /* The pSpace buffer will be freed after the next call to + ** balance_nonroot(), or just before this function returns, whichever + ** comes first. */ + //pFree = pSpace; + } + } + + pPage.nOverflow = 0; + + /* The next iteration of the do-loop balances the parent page. */ + releasePage(pPage); + pCur.iPage--; + } + } while (rc == SQLITE_OK); + + //if (pFree != null) + //{ + // sqlite3PageFree(ref pFree); + //} + return rc; + } - if ( iPage == 0 ) - { - if ( pPage.nOverflow != 0 ) - { - /* The root page of the b-tree is overfull. In this case call the - ** balance_deeper() function to create a new child for the root-page - ** and copy the current contents of the root-page to it. The - ** next iteration of the do-loop will balance the child page. - */ - Debug.Assert( ( balance_deeper_called++ ) == 0 ); - rc = balance_deeper( pPage, ref pCur.apPage[1] ); - if ( rc == SQLITE_OK ) - { - pCur.iPage = 1; - pCur.aiIdx[0] = 0; - pCur.aiIdx[1] = 0; - Debug.Assert( pCur.apPage[1].nOverflow != 0 ); - } - } - else - { - break; - } - } - else if ( pPage.nOverflow == 0 && pPage.nFree <= nMin ) - { - break; - } - else - { - MemPage pParent = pCur.apPage[iPage - 1]; - int iIdx = pCur.aiIdx[iPage - 1]; - rc = sqlite3PagerWrite( pParent.pDbPage ); - if ( rc == SQLITE_OK ) - { -#if !SQLITE_OMIT_QUICKBALANCE - if ( pPage.hasData != 0 - && pPage.nOverflow == 1 - && pPage.aOvfl[0].idx == pPage.nCell - && pParent.pgno != 1 - && pParent.nCell == iIdx - ) - { - /* Call balance_quick() to create a new sibling of pPage on which - ** to store the overflow cell. balance_quick() inserts a new cell - ** into pParent, which may cause pParent overflow. If this - ** happens, the next interation of the do-loop will balance pParent - ** use either balance_nonroot() or balance_deeper(). Until this - ** happens, the overflow cell is stored in the aBalanceQuickSpace[] - ** buffer. - ** - ** The purpose of the following Debug.Assert() is to check that only a - ** single call to balance_quick() is made for each call to this - ** function. If this were not verified, a subtle bug involving reuse - ** of the aBalanceQuickSpace[] might sneak in. - */ - Debug.Assert( ( balance_quick_called++ ) == 0 ); - rc = balance_quick( pParent, pPage, aBalanceQuickSpace ); + /* + ** Insert a new record into the BTree. The key is given by (pKey,nKey) + ** and the data is given by (pData,nData). The cursor is used only to + ** define what table the record should be inserted into. The cursor + ** is left pointing at a random location. + ** + ** For an INTKEY table, only the nKey value of the key is used. pKey is + ** ignored. For a ZERODATA table, the pData and nData are both ignored. + ** + ** If the seekResult parameter is non-zero, then a successful call to + ** MovetoUnpacked() to seek cursor pCur to (pKey, nKey) has already + ** been performed. seekResult is the search result returned (a negative + ** number if pCur points at an entry that is smaller than (pKey, nKey), or + ** a positive value if pCur points at an etry that is larger than + ** (pKey, nKey)). + ** + ** If the seekResult parameter is non-zero, then the caller guarantees that + ** cursor pCur is pointing at the existing copy of a row that is to be + ** overwritten. If the seekResult parameter is 0, then cursor pCur may + ** point to any entry or to no entry at all and so this function has to seek + ** the cursor before the new key can be inserted. + */ + static int sqlite3BtreeInsert( + BtCursor pCur, /* Insert data into the table of this cursor */ + byte[] pKey, i64 nKey, /* The key of the new record */ + byte[] pData, int nData, /* The data of the new record */ + int nZero, /* Number of extra 0 bytes to append to data */ + int appendBias, /* True if this is likely an append */ + int seekResult /* Result of prior MovetoUnpacked() call */ + ) { + int rc; + int loc = seekResult; /* -1: before desired location +1: after */ + int szNew = 0; + int idx; + MemPage pPage; + Btree p = pCur.pBtree; + BtShared pBt = p.pBt; + int oldCell; + byte[] newCell = null; + + if (pCur.eState == CURSOR_FAULT) { + Debug.Assert(pCur.skipNext != SQLITE_OK); + return pCur.skipNext; + } + + Debug.Assert(cursorHoldsMutex(pCur)); + Debug.Assert(pCur.wrFlag != 0 && pBt.inTransaction == TRANS_WRITE && !pBt.readOnly); + Debug.Assert(hasSharedCacheTableLock(p, pCur.pgnoRoot, pCur.pKeyInfo != null ? 1 : 0, 2)); + + /* Assert that the caller has been consistent. If this cursor was opened + ** expecting an index b-tree, then the caller should be inserting blob + ** keys with no associated data. If the cursor was opened expecting an + ** intkey table, the caller should be inserting integer keys with a + ** blob of associated data. */ + Debug.Assert((pKey == null) == (pCur.pKeyInfo == null)); + + /* If this is an insert into a table b-tree, invalidate any incrblob + ** cursors open on the row being replaced (assuming this is a replace + ** operation - if it is not, the following is a no-op). */ + if (pCur.pKeyInfo == null) { + invalidateIncrblobCursors(p, nKey, 0); + } + + /* Save the positions of any other cursors open on this table. + ** + ** In some cases, the call to btreeMoveto() below is a no-op. For + ** example, when inserting data into a table with auto-generated integer + ** keys, the VDBE layer invokes sqlite3BtreeLast() to figure out the + ** integer key to use. It then calls this function to actually insert the + ** data into the intkey B-Tree. In this case btreeMoveto() recognizes + ** that the cursor is already where it needs to be and returns without + ** doing any work. To avoid thwarting these optimizations, it is important + ** not to clear the cursor here. + */ + rc = saveAllCursors(pBt, pCur.pgnoRoot, pCur); + if (rc != 0) + return rc; + if (0 == loc) { + rc = btreeMoveto(pCur, pKey, nKey, appendBias, ref loc); + if (rc != 0) + return rc; + } + Debug.Assert(pCur.eState == CURSOR_VALID || (pCur.eState == CURSOR_INVALID && loc != 0)); + + pPage = pCur.apPage[pCur.iPage]; + Debug.Assert(pPage.intKey != 0 || nKey >= 0); + Debug.Assert(pPage.leaf != 0 || 0 == pPage.intKey); + + TRACE("INSERT: table=%d nkey=%lld ndata=%d page=%d %s\n", + pCur.pgnoRoot, nKey, nData, pPage.pgno, + loc == 0 ? "overwrite" : "new entry"); + Debug.Assert(pPage.isInit != 0); + allocateTempSpace(pBt); + newCell = pBt.pTmpSpace; + //if (newCell == null) return SQLITE_NOMEM; + rc = fillInCell(pPage, newCell, pKey, nKey, pData, nData, nZero, ref szNew); + if (rc != 0) + goto end_insert; + Debug.Assert(szNew == cellSizePtr(pPage, newCell)); + Debug.Assert(szNew <= MX_CELL_SIZE(pBt)); + idx = pCur.aiIdx[pCur.iPage]; + if (loc == 0) { + u16 szOld; + Debug.Assert(idx < pPage.nCell); + rc = sqlite3PagerWrite(pPage.pDbPage); + if (rc != 0) { + goto end_insert; + } + oldCell = findCell(pPage, idx); + if (0 == pPage.leaf) { + //memcpy(newCell, oldCell, 4); + newCell[0] = pPage.aData[oldCell + 0]; + newCell[1] = pPage.aData[oldCell + 1]; + newCell[2] = pPage.aData[oldCell + 2]; + newCell[3] = pPage.aData[oldCell + 3]; + } + szOld = cellSizePtr(pPage, oldCell); + rc = clearCell(pPage, oldCell); + dropCell(pPage, idx, szOld, ref rc); + if (rc != 0) + goto end_insert; + } else if (loc < 0 && pPage.nCell > 0) { + Debug.Assert(pPage.leaf != 0); + idx = ++pCur.aiIdx[pCur.iPage]; + } else { + Debug.Assert(pPage.leaf != 0); + } + insertCell(pPage, idx, newCell, szNew, null, 0, ref rc); + Debug.Assert(rc != SQLITE_OK || pPage.nCell > 0 || pPage.nOverflow > 0); + + /* If no error has occured and pPage has an overflow cell, call balance() + ** to redistribute the cells within the tree. Since balance() may move + ** the cursor, zero the BtCursor.info.nSize and BtCursor.validNKey + ** variables. + ** + ** Previous versions of SQLite called moveToRoot() to move the cursor + ** back to the root page as balance() used to invalidate the contents + ** of BtCursor.apPage[] and BtCursor.aiIdx[]. Instead of doing that, + ** set the cursor state to "invalid". This makes common insert operations + ** slightly faster. + ** + ** There is a subtle but important optimization here too. When inserting + ** multiple records into an intkey b-tree using a single cursor (as can + ** happen while processing an "INSERT INTO ... SELECT" statement), it + ** is advantageous to leave the cursor pointing to the last entry in + ** the b-tree if possible. If the cursor is left pointing to the last + ** entry in the table, and the next row inserted has an integer key + ** larger than the largest existing key, it is possible to insert the + ** row without seeking the cursor. This can be a big performance boost. + */ + pCur.info.nSize = 0; + pCur.validNKey = false; + if (rc == SQLITE_OK && pPage.nOverflow != 0) { + rc = balance(pCur); + + /* Must make sure nOverflow is reset to zero even if the balance() + ** fails. Internal data structure corruption will result otherwise. + ** Also, set the cursor state to invalid. This stops saveCursorPosition() + ** from trying to save the current position of the cursor. */ + pCur.apPage[pCur.iPage].nOverflow = 0; + pCur.eState = CURSOR_INVALID; + } + Debug.Assert(pCur.apPage[pCur.iPage].nOverflow == 0); + + end_insert: + return rc; } - else -#endif - { - /* In this case, call balance_nonroot() to redistribute cells - ** between pPage and up to 2 of its sibling pages. This involves - ** modifying the contents of pParent, which may cause pParent to - ** become overfull or underfull. The next iteration of the do-loop - ** will balance the parent page to correct this. - ** - ** If the parent page becomes overfull, the overflow cell or cells - ** are stored in the pSpace buffer allocated immediately below. - ** A subsequent iteration of the do-loop will deal with this by - ** calling balance_nonroot() (balance_deeper() may be called first, - ** but it doesn't deal with overflow cells - just moves them to a - ** different page). Once this subsequent call to balance_nonroot() - ** has completed, it is safe to release the pSpace buffer used by - ** the previous call, as the overflow cell data will have been - ** copied either into the body of a database page or into the new - ** pSpace buffer passed to the latter call to balance_nonroot(). - */ - ////u8[] pSpace = new u8[pCur.pBt.pageSize];// u8 pSpace = sqlite3PageMalloc( pCur.pBt.pageSize ); - rc = balance_nonroot( pParent, iIdx, null, iPage == 1 ? 1 : 0 ); - //if (pFree != null) - //{ - // /* If pFree is not NULL, it points to the pSpace buffer used - // ** by a previous call to balance_nonroot(). Its contents are - // ** now stored either on real database pages or within the - // ** new pSpace buffer, so it may be safely freed here. */ - // sqlite3PageFree(ref pFree); - //} - - /* The pSpace buffer will be freed after the next call to - ** balance_nonroot(), or just before this function returns, whichever - ** comes first. */ - //pFree = pSpace; - } - } - - pPage.nOverflow = 0; - - /* The next iteration of the do-loop balances the parent page. */ - releasePage( pPage ); - pCur.iPage--; - } - } while ( rc == SQLITE_OK ); - //if (pFree != null) - //{ - // sqlite3PageFree(ref pFree); - //} - return rc; -} + /* + ** Delete the entry that the cursor is pointing to. The cursor + ** is left pointing at a arbitrary location. + */ + static int sqlite3BtreeDelete(BtCursor pCur) { + Btree p = pCur.pBtree; + BtShared pBt = p.pBt; + int rc; /* Return code */ + MemPage pPage; /* Page to delete cell from */ + int pCell; /* Pointer to cell to delete */ + int iCellIdx; /* Index of cell to delete */ + int iCellDepth; /* Depth of node containing pCell */ + + Debug.Assert(cursorHoldsMutex(pCur)); + Debug.Assert(pBt.inTransaction == TRANS_WRITE); + Debug.Assert(!pBt.readOnly); + Debug.Assert(pCur.wrFlag != 0); + Debug.Assert(hasSharedCacheTableLock(p, pCur.pgnoRoot, pCur.pKeyInfo != null ? 1 : 0, 2)); + Debug.Assert(!hasReadConflicts(p, pCur.pgnoRoot)); + + if (NEVER(pCur.aiIdx[pCur.iPage] >= pCur.apPage[pCur.iPage].nCell) + || NEVER(pCur.eState != CURSOR_VALID) + ) { + return SQLITE_ERROR; /* Something has gone awry. */ + } + + /* If this is a delete operation to remove a row from a table b-tree, + ** invalidate any incrblob cursors open on the row being deleted. */ + if (pCur.pKeyInfo == null) { + invalidateIncrblobCursors(p, pCur.info.nKey, 0); + } + iCellDepth = pCur.iPage; + iCellIdx = pCur.aiIdx[iCellDepth]; + pPage = pCur.apPage[iCellDepth]; + pCell = findCell(pPage, iCellIdx); + + /* If the page containing the entry to delete is not a leaf page, move + ** the cursor to the largest entry in the tree that is smaller than + ** the entry being deleted. This cell will replace the cell being deleted + ** from the internal node. The 'previous' entry is used for this instead + ** of the 'next' entry, as the previous entry is always a part of the + ** sub-tree headed by the child page of the cell being deleted. This makes + ** balancing the tree following the delete operation easier. */ + if (0 == pPage.leaf) { + int notUsed = 0; + rc = sqlite3BtreePrevious(pCur, ref notUsed); + if (rc != 0) + return rc; + } -/* -** Insert a new record into the BTree. The key is given by (pKey,nKey) -** and the data is given by (pData,nData). The cursor is used only to -** define what table the record should be inserted into. The cursor -** is left pointing at a random location. -** -** For an INTKEY table, only the nKey value of the key is used. pKey is -** ignored. For a ZERODATA table, the pData and nData are both ignored. -** -** If the seekResult parameter is non-zero, then a successful call to -** MovetoUnpacked() to seek cursor pCur to (pKey, nKey) has already -** been performed. seekResult is the search result returned (a negative -** number if pCur points at an entry that is smaller than (pKey, nKey), or -** a positive value if pCur points at an etry that is larger than -** (pKey, nKey)). -** -** If the seekResult parameter is non-zero, then the caller guarantees that -** cursor pCur is pointing at the existing copy of a row that is to be -** overwritten. If the seekResult parameter is 0, then cursor pCur may -** point to any entry or to no entry at all and so this function has to seek -** the cursor before the new key can be inserted. -*/ -static int sqlite3BtreeInsert( -BtCursor pCur, /* Insert data into the table of this cursor */ -byte[] pKey, i64 nKey, /* The key of the new record */ -byte[] pData, int nData, /* The data of the new record */ -int nZero, /* Number of extra 0 bytes to append to data */ -int appendBias, /* True if this is likely an append */ -int seekResult /* Result of prior MovetoUnpacked() call */ -) -{ - int rc; - int loc = seekResult; /* -1: before desired location +1: after */ - int szNew = 0; - int idx; - MemPage pPage; - Btree p = pCur.pBtree; - BtShared pBt = p.pBt; - int oldCell; - byte[] newCell = null; - - if ( pCur.eState == CURSOR_FAULT ) - { - Debug.Assert( pCur.skipNext != SQLITE_OK ); - return pCur.skipNext; - } - - Debug.Assert( cursorHoldsMutex( pCur ) ); - Debug.Assert( pCur.wrFlag != 0 && pBt.inTransaction == TRANS_WRITE && !pBt.readOnly ); - Debug.Assert( hasSharedCacheTableLock( p, pCur.pgnoRoot, pCur.pKeyInfo != null ? 1 : 0, 2 ) ); - - /* Assert that the caller has been consistent. If this cursor was opened - ** expecting an index b-tree, then the caller should be inserting blob - ** keys with no associated data. If the cursor was opened expecting an - ** intkey table, the caller should be inserting integer keys with a - ** blob of associated data. */ - Debug.Assert( ( pKey == null ) == ( pCur.pKeyInfo == null ) ); - - /* If this is an insert into a table b-tree, invalidate any incrblob - ** cursors open on the row being replaced (assuming this is a replace - ** operation - if it is not, the following is a no-op). */ - if ( pCur.pKeyInfo == null ) - { - invalidateIncrblobCursors( p, nKey, 0 ); - } - - /* Save the positions of any other cursors open on this table. - ** - ** In some cases, the call to btreeMoveto() below is a no-op. For - ** example, when inserting data into a table with auto-generated integer - ** keys, the VDBE layer invokes sqlite3BtreeLast() to figure out the - ** integer key to use. It then calls this function to actually insert the - ** data into the intkey B-Tree. In this case btreeMoveto() recognizes - ** that the cursor is already where it needs to be and returns without - ** doing any work. To avoid thwarting these optimizations, it is important - ** not to clear the cursor here. - */ - rc = saveAllCursors( pBt, pCur.pgnoRoot, pCur ); - if ( rc != 0 ) - return rc; - if ( 0 == loc ) - { - rc = btreeMoveto( pCur, pKey, nKey, appendBias, ref loc ); - if ( rc != 0 ) - return rc; - } - Debug.Assert( pCur.eState == CURSOR_VALID || ( pCur.eState == CURSOR_INVALID && loc != 0 ) ); - - pPage = pCur.apPage[pCur.iPage]; - Debug.Assert( pPage.intKey != 0 || nKey >= 0 ); - Debug.Assert( pPage.leaf != 0 || 0 == pPage.intKey ); - - TRACE( "INSERT: table=%d nkey=%lld ndata=%d page=%d %s\n", - pCur.pgnoRoot, nKey, nData, pPage.pgno, - loc == 0 ? "overwrite" : "new entry" ); - Debug.Assert( pPage.isInit != 0 ); - allocateTempSpace( pBt ); - newCell = pBt.pTmpSpace; - //if (newCell == null) return SQLITE_NOMEM; - rc = fillInCell( pPage, newCell, pKey, nKey, pData, nData, nZero, ref szNew ); - if ( rc != 0 ) - goto end_insert; - Debug.Assert( szNew == cellSizePtr( pPage, newCell ) ); - Debug.Assert( szNew <= MX_CELL_SIZE( pBt ) ); - idx = pCur.aiIdx[pCur.iPage]; - if ( loc == 0 ) - { - u16 szOld; - Debug.Assert( idx < pPage.nCell ); - rc = sqlite3PagerWrite( pPage.pDbPage ); - if ( rc != 0 ) - { - goto end_insert; - } - oldCell = findCell( pPage, idx ); - if ( 0 == pPage.leaf ) - { - //memcpy(newCell, oldCell, 4); - newCell[0] = pPage.aData[oldCell + 0]; - newCell[1] = pPage.aData[oldCell + 1]; - newCell[2] = pPage.aData[oldCell + 2]; - newCell[3] = pPage.aData[oldCell + 3]; - } - szOld = cellSizePtr( pPage, oldCell ); - rc = clearCell( pPage, oldCell ); - dropCell( pPage, idx, szOld, ref rc ); - if ( rc != 0 ) - goto end_insert; - } - else if ( loc < 0 && pPage.nCell > 0 ) - { - Debug.Assert( pPage.leaf != 0 ); - idx = ++pCur.aiIdx[pCur.iPage]; - } - else - { - Debug.Assert( pPage.leaf != 0 ); - } - insertCell( pPage, idx, newCell, szNew, null, 0, ref rc ); - Debug.Assert( rc != SQLITE_OK || pPage.nCell > 0 || pPage.nOverflow > 0 ); - - /* If no error has occured and pPage has an overflow cell, call balance() - ** to redistribute the cells within the tree. Since balance() may move - ** the cursor, zero the BtCursor.info.nSize and BtCursor.validNKey - ** variables. - ** - ** Previous versions of SQLite called moveToRoot() to move the cursor - ** back to the root page as balance() used to invalidate the contents - ** of BtCursor.apPage[] and BtCursor.aiIdx[]. Instead of doing that, - ** set the cursor state to "invalid". This makes common insert operations - ** slightly faster. - ** - ** There is a subtle but important optimization here too. When inserting - ** multiple records into an intkey b-tree using a single cursor (as can - ** happen while processing an "INSERT INTO ... SELECT" statement), it - ** is advantageous to leave the cursor pointing to the last entry in - ** the b-tree if possible. If the cursor is left pointing to the last - ** entry in the table, and the next row inserted has an integer key - ** larger than the largest existing key, it is possible to insert the - ** row without seeking the cursor. This can be a big performance boost. - */ - pCur.info.nSize = 0; - pCur.validNKey = false; - if ( rc == SQLITE_OK && pPage.nOverflow != 0 ) - { - rc = balance( pCur ); - - /* Must make sure nOverflow is reset to zero even if the balance() - ** fails. Internal data structure corruption will result otherwise. - ** Also, set the cursor state to invalid. This stops saveCursorPosition() - ** from trying to save the current position of the cursor. */ - pCur.apPage[pCur.iPage].nOverflow = 0; - pCur.eState = CURSOR_INVALID; - } - Debug.Assert( pCur.apPage[pCur.iPage].nOverflow == 0 ); - -end_insert: - return rc; -} + /* Save the positions of any other cursors open on this table before + ** making any modifications. Make the page containing the entry to be + ** deleted writable. Then free any overflow pages associated with the + ** entry and finally remove the cell itself from within the page. + */ + rc = saveAllCursors(pBt, pCur.pgnoRoot, pCur); + if (rc != 0) + return rc; + rc = sqlite3PagerWrite(pPage.pDbPage); + if (rc != 0) + return rc; + rc = clearCell(pPage, pCell); + dropCell(pPage, iCellIdx, cellSizePtr(pPage, pCell), ref rc); + if (rc != 0) + return rc; + + /* If the cell deleted was not located on a leaf page, then the cursor + ** is currently pointing to the largest entry in the sub-tree headed + ** by the child-page of the cell that was just deleted from an internal + ** node. The cell from the leaf node needs to be moved to the internal + ** node to replace the deleted cell. */ + if (0 == pPage.leaf) { + MemPage pLeaf = pCur.apPage[pCur.iPage]; + int nCell; + Pgno n = pCur.apPage[iCellDepth + 1].pgno; + //byte[] pTmp; + + pCell = findCell(pLeaf, pLeaf.nCell - 1); + nCell = cellSizePtr(pLeaf, pCell); + Debug.Assert(MX_CELL_SIZE(pBt) >= nCell); + + //allocateTempSpace(pBt); + //pTmp = pBt.pTmpSpace; + + rc = sqlite3PagerWrite(pLeaf.pDbPage); + byte[] pNext_4 = sqlite3Malloc(nCell + 4); + Buffer.BlockCopy(pLeaf.aData, pCell - 4, pNext_4, 0, nCell + 4); + insertCell(pPage, iCellIdx, pNext_4, nCell + 4, null, n, ref rc); //insertCell( pPage, iCellIdx, pCell - 4, nCell + 4, pTmp, n, ref rc ); + dropCell(pLeaf, pLeaf.nCell - 1, nCell, ref rc); + if (rc != 0) + return rc; + } -/* -** Delete the entry that the cursor is pointing to. The cursor -** is left pointing at a arbitrary location. -*/ -static int sqlite3BtreeDelete( BtCursor pCur ) -{ - Btree p = pCur.pBtree; - BtShared pBt = p.pBt; - int rc; /* Return code */ - MemPage pPage; /* Page to delete cell from */ - int pCell; /* Pointer to cell to delete */ - int iCellIdx; /* Index of cell to delete */ - int iCellDepth; /* Depth of node containing pCell */ - - Debug.Assert( cursorHoldsMutex( pCur ) ); - Debug.Assert( pBt.inTransaction == TRANS_WRITE ); - Debug.Assert( !pBt.readOnly ); - Debug.Assert( pCur.wrFlag != 0 ); - Debug.Assert( hasSharedCacheTableLock( p, pCur.pgnoRoot, pCur.pKeyInfo != null ? 1 : 0, 2 ) ); - Debug.Assert( !hasReadConflicts( p, pCur.pgnoRoot ) ); - - if ( NEVER( pCur.aiIdx[pCur.iPage] >= pCur.apPage[pCur.iPage].nCell ) - || NEVER( pCur.eState != CURSOR_VALID ) - ) - { - return SQLITE_ERROR; /* Something has gone awry. */ - } - - /* If this is a delete operation to remove a row from a table b-tree, - ** invalidate any incrblob cursors open on the row being deleted. */ - if ( pCur.pKeyInfo == null ) - { - invalidateIncrblobCursors( p, pCur.info.nKey, 0 ); - } - - iCellDepth = pCur.iPage; - iCellIdx = pCur.aiIdx[iCellDepth]; - pPage = pCur.apPage[iCellDepth]; - pCell = findCell( pPage, iCellIdx ); - - /* If the page containing the entry to delete is not a leaf page, move - ** the cursor to the largest entry in the tree that is smaller than - ** the entry being deleted. This cell will replace the cell being deleted - ** from the internal node. The 'previous' entry is used for this instead - ** of the 'next' entry, as the previous entry is always a part of the - ** sub-tree headed by the child page of the cell being deleted. This makes - ** balancing the tree following the delete operation easier. */ - if ( 0 == pPage.leaf ) - { - int notUsed = 0; - rc = sqlite3BtreePrevious( pCur, ref notUsed ); - if ( rc != 0 ) - return rc; - } - - /* Save the positions of any other cursors open on this table before - ** making any modifications. Make the page containing the entry to be - ** deleted writable. Then free any overflow pages associated with the - ** entry and finally remove the cell itself from within the page. - */ - rc = saveAllCursors( pBt, pCur.pgnoRoot, pCur ); - if ( rc != 0 ) - return rc; - rc = sqlite3PagerWrite( pPage.pDbPage ); - if ( rc != 0 ) - return rc; - rc = clearCell( pPage, pCell ); - dropCell( pPage, iCellIdx, cellSizePtr( pPage, pCell ), ref rc ); - if ( rc != 0 ) - return rc; - - /* If the cell deleted was not located on a leaf page, then the cursor - ** is currently pointing to the largest entry in the sub-tree headed - ** by the child-page of the cell that was just deleted from an internal - ** node. The cell from the leaf node needs to be moved to the internal - ** node to replace the deleted cell. */ - if ( 0 == pPage.leaf ) - { - MemPage pLeaf = pCur.apPage[pCur.iPage]; - int nCell; - Pgno n = pCur.apPage[iCellDepth + 1].pgno; - //byte[] pTmp; - - pCell = findCell( pLeaf, pLeaf.nCell - 1 ); - nCell = cellSizePtr( pLeaf, pCell ); - Debug.Assert( MX_CELL_SIZE( pBt ) >= nCell ); - - //allocateTempSpace(pBt); - //pTmp = pBt.pTmpSpace; - - rc = sqlite3PagerWrite( pLeaf.pDbPage ); - byte[] pNext_4 = sqlite3Malloc( nCell + 4 ); - Buffer.BlockCopy( pLeaf.aData, pCell - 4, pNext_4, 0, nCell + 4 ); - insertCell( pPage, iCellIdx, pNext_4, nCell + 4, null, n, ref rc ); //insertCell( pPage, iCellIdx, pCell - 4, nCell + 4, pTmp, n, ref rc ); - dropCell( pLeaf, pLeaf.nCell - 1, nCell, ref rc ); - if ( rc != 0 ) - return rc; - } - - /* Balance the tree. If the entry deleted was located on a leaf page, - ** then the cursor still points to that page. In this case the first - ** call to balance() repairs the tree, and the if(...) condition is - ** never true. - ** - ** Otherwise, if the entry deleted was on an internal node page, then - ** pCur is pointing to the leaf page from which a cell was removed to - ** replace the cell deleted from the internal node. This is slightly - ** tricky as the leaf node may be underfull, and the internal node may - ** be either under or overfull. In this case run the balancing algorithm - ** on the leaf node first. If the balance proceeds far enough up the - ** tree that we can be sure that any problem in the internal node has - ** been corrected, so be it. Otherwise, after balancing the leaf node, - ** walk the cursor up the tree to the internal node and balance it as - ** well. */ - rc = balance( pCur ); - if ( rc == SQLITE_OK && pCur.iPage > iCellDepth ) - { - while ( pCur.iPage > iCellDepth ) - { - releasePage( pCur.apPage[pCur.iPage--] ); - } - rc = balance( pCur ); - } - - if ( rc == SQLITE_OK ) - { - moveToRoot( pCur ); - } - return rc; -} + /* Balance the tree. If the entry deleted was located on a leaf page, + ** then the cursor still points to that page. In this case the first + ** call to balance() repairs the tree, and the if(...) condition is + ** never true. + ** + ** Otherwise, if the entry deleted was on an internal node page, then + ** pCur is pointing to the leaf page from which a cell was removed to + ** replace the cell deleted from the internal node. This is slightly + ** tricky as the leaf node may be underfull, and the internal node may + ** be either under or overfull. In this case run the balancing algorithm + ** on the leaf node first. If the balance proceeds far enough up the + ** tree that we can be sure that any problem in the internal node has + ** been corrected, so be it. Otherwise, after balancing the leaf node, + ** walk the cursor up the tree to the internal node and balance it as + ** well. */ + rc = balance(pCur); + if (rc == SQLITE_OK && pCur.iPage > iCellDepth) { + while (pCur.iPage > iCellDepth) { + releasePage(pCur.apPage[pCur.iPage--]); + } + rc = balance(pCur); + } -/* -** Create a new BTree table. Write into piTable the page -** number for the root page of the new table. -** -** The type of type is determined by the flags parameter. Only the -** following values of flags are currently in use. Other values for -** flags might not work: -** -** BTREE_INTKEY|BTREE_LEAFDATA Used for SQL tables with rowid keys -** BTREE_ZERODATA Used for SQL indices -*/ -static int btreeCreateTable( Btree p, ref int piTable, int createTabFlags ) -{ - BtShared pBt = p.pBt; - MemPage pRoot = new MemPage(); - Pgno pgnoRoot = 0; - int rc; - int ptfFlags; /* Page-type flage for the root page of new table */ + if (rc == SQLITE_OK) { + moveToRoot(pCur); + } + return rc; + } + + /* + ** Create a new BTree table. Write into piTable the page + ** number for the root page of the new table. + ** + ** The type of type is determined by the flags parameter. Only the + ** following values of flags are currently in use. Other values for + ** flags might not work: + ** + ** BTREE_INTKEY|BTREE_LEAFDATA Used for SQL tables with rowid keys + ** BTREE_ZERODATA Used for SQL indices + */ + static int btreeCreateTable(Btree p, ref int piTable, int createTabFlags) { + BtShared pBt = p.pBt; + MemPage pRoot = new MemPage(); + Pgno pgnoRoot = 0; + int rc; + int ptfFlags; /* Page-type flage for the root page of new table */ - Debug.Assert( sqlite3BtreeHoldsMutex( p ) ); - Debug.Assert( pBt.inTransaction == TRANS_WRITE ); - Debug.Assert( !pBt.readOnly ); + Debug.Assert(sqlite3BtreeHoldsMutex(p)); + Debug.Assert(pBt.inTransaction == TRANS_WRITE); + Debug.Assert(!pBt.readOnly); #if SQLITE_OMIT_AUTOVACUUM rc = allocateBtreePage(pBt, ref pRoot, ref pgnoRoot, 1, 0); @@ -8129,1216 +7400,1079 @@ static int btreeCreateTable( Btree p, ref int piTable, int createTabFlags ) return rc; } #else - if ( pBt.autoVacuum ) - { - Pgno pgnoMove = 0; /* Move a page here to make room for the root-page */ - MemPage pPageMove = new MemPage(); /* The page to move to. */ - - /* Creating a new table may probably require moving an existing database - ** to make room for the new tables root page. In case this page turns - ** out to be an overflow page, delete all overflow page-map caches - ** held by open cursors. - */ - invalidateAllOverflowCache( pBt ); - - /* Read the value of meta[3] from the database to determine where the - ** root page of the new table should go. meta[3] is the largest root-page - ** created so far, so the new root-page is (meta[3]+1). - */ - sqlite3BtreeGetMeta( p, BTREE_LARGEST_ROOT_PAGE, ref pgnoRoot ); - pgnoRoot++; - - /* The new root-page may not be allocated on a pointer-map page, or the - ** PENDING_BYTE page. - */ - while ( pgnoRoot == PTRMAP_PAGENO( pBt, pgnoRoot ) || - pgnoRoot == PENDING_BYTE_PAGE( pBt ) ) - { - pgnoRoot++; - } - Debug.Assert( pgnoRoot >= 3 ); - - /* Allocate a page. The page that currently resides at pgnoRoot will - ** be moved to the allocated page (unless the allocated page happens - ** to reside at pgnoRoot). - */ - rc = allocateBtreePage( pBt, ref pPageMove, ref pgnoMove, pgnoRoot, 1 ); - if ( rc != SQLITE_OK ) - { - return rc; - } + if (pBt.autoVacuum) { + Pgno pgnoMove = 0; /* Move a page here to make room for the root-page */ + MemPage pPageMove = new MemPage(); /* The page to move to. */ + + /* Creating a new table may probably require moving an existing database + ** to make room for the new tables root page. In case this page turns + ** out to be an overflow page, delete all overflow page-map caches + ** held by open cursors. + */ + invalidateAllOverflowCache(pBt); + + /* Read the value of meta[3] from the database to determine where the + ** root page of the new table should go. meta[3] is the largest root-page + ** created so far, so the new root-page is (meta[3]+1). + */ + sqlite3BtreeGetMeta(p, BTREE_LARGEST_ROOT_PAGE, ref pgnoRoot); + pgnoRoot++; + + /* The new root-page may not be allocated on a pointer-map page, or the + ** PENDING_BYTE page. + */ + while (pgnoRoot == PTRMAP_PAGENO(pBt, pgnoRoot) || + pgnoRoot == PENDING_BYTE_PAGE(pBt)) { + pgnoRoot++; + } + Debug.Assert(pgnoRoot >= 3); + + /* Allocate a page. The page that currently resides at pgnoRoot will + ** be moved to the allocated page (unless the allocated page happens + ** to reside at pgnoRoot). + */ + rc = allocateBtreePage(pBt, ref pPageMove, ref pgnoMove, pgnoRoot, 1); + if (rc != SQLITE_OK) { + return rc; + } + + if (pgnoMove != pgnoRoot) { + /* pgnoRoot is the page that will be used for the root-page of + ** the new table (assuming an error did not occur). But we were + ** allocated pgnoMove. If required (i.e. if it was not allocated + ** by extending the file), the current page at position pgnoMove + ** is already journaled. + */ + u8 eType = 0; + Pgno iPtrPage = 0; + + releasePage(pPageMove); + + /* Move the page currently at pgnoRoot to pgnoMove. */ + rc = btreeGetPage(pBt, pgnoRoot, ref pRoot, 0); + if (rc != SQLITE_OK) { + return rc; + } + rc = ptrmapGet(pBt, pgnoRoot, ref eType, ref iPtrPage); + if (eType == PTRMAP_ROOTPAGE || eType == PTRMAP_FREEPAGE) { + rc = SQLITE_CORRUPT_BKPT(); + } + if (rc != SQLITE_OK) { + releasePage(pRoot); + return rc; + } + Debug.Assert(eType != PTRMAP_ROOTPAGE); + Debug.Assert(eType != PTRMAP_FREEPAGE); + rc = relocatePage(pBt, pRoot, eType, iPtrPage, pgnoMove, 0); + releasePage(pRoot); + + /* Obtain the page at pgnoRoot */ + if (rc != SQLITE_OK) { + return rc; + } + rc = btreeGetPage(pBt, pgnoRoot, ref pRoot, 0); + if (rc != SQLITE_OK) { + return rc; + } + rc = sqlite3PagerWrite(pRoot.pDbPage); + if (rc != SQLITE_OK) { + releasePage(pRoot); + return rc; + } + } else { + pRoot = pPageMove; + } + + /* Update the pointer-map and meta-data with the new root-page number. */ + ptrmapPut(pBt, pgnoRoot, PTRMAP_ROOTPAGE, 0, ref rc); + if (rc != 0) { + releasePage(pRoot); + return rc; + } + + /* When the new root page was allocated, page 1 was made writable in + ** order either to increase the database filesize, or to decrement the + ** freelist count. Hence, the sqlite3BtreeUpdateMeta() call cannot fail. + */ + Debug.Assert(sqlite3PagerIswriteable(pBt.pPage1.pDbPage)); + rc = sqlite3BtreeUpdateMeta(p, 4, pgnoRoot); + if (NEVER(rc != 0)) { + releasePage(pRoot); + return rc; + } + + } else { + rc = allocateBtreePage(pBt, ref pRoot, ref pgnoRoot, 1, 0); + if (rc != 0) + return rc; + } +#endif + Debug.Assert(sqlite3PagerIswriteable(pRoot.pDbPage)); + if ((createTabFlags & BTREE_INTKEY) != 0) { + ptfFlags = PTF_INTKEY | PTF_LEAFDATA | PTF_LEAF; + } else { + ptfFlags = PTF_ZERODATA | PTF_LEAF; + } + zeroPage(pRoot, ptfFlags); + sqlite3PagerUnref(pRoot.pDbPage); + Debug.Assert((pBt.openFlags & BTREE_SINGLE) == 0 || pgnoRoot == 2); + piTable = (int)pgnoRoot; + return SQLITE_OK; + } + static int sqlite3BtreeCreateTable(Btree p, ref int piTable, int flags) { + int rc; + sqlite3BtreeEnter(p); + rc = btreeCreateTable(p, ref piTable, flags); + sqlite3BtreeLeave(p); + return rc; + } - if ( pgnoMove != pgnoRoot ) - { - /* pgnoRoot is the page that will be used for the root-page of - ** the new table (assuming an error did not occur). But we were - ** allocated pgnoMove. If required (i.e. if it was not allocated - ** by extending the file), the current page at position pgnoMove - ** is already journaled. - */ - u8 eType = 0; - Pgno iPtrPage = 0; - - releasePage( pPageMove ); - - /* Move the page currently at pgnoRoot to pgnoMove. */ - rc = btreeGetPage( pBt, pgnoRoot, ref pRoot, 0 ); - if ( rc != SQLITE_OK ) - { - return rc; - } - rc = ptrmapGet( pBt, pgnoRoot, ref eType, ref iPtrPage ); - if ( eType == PTRMAP_ROOTPAGE || eType == PTRMAP_FREEPAGE ) - { - rc = SQLITE_CORRUPT_BKPT(); - } - if ( rc != SQLITE_OK ) - { - releasePage( pRoot ); - return rc; - } - Debug.Assert( eType != PTRMAP_ROOTPAGE ); - Debug.Assert( eType != PTRMAP_FREEPAGE ); - rc = relocatePage( pBt, pRoot, eType, iPtrPage, pgnoMove, 0 ); - releasePage( pRoot ); - - /* Obtain the page at pgnoRoot */ - if ( rc != SQLITE_OK ) - { - return rc; - } - rc = btreeGetPage( pBt, pgnoRoot, ref pRoot, 0 ); - if ( rc != SQLITE_OK ) - { - return rc; - } - rc = sqlite3PagerWrite( pRoot.pDbPage ); - if ( rc != SQLITE_OK ) - { - releasePage( pRoot ); - return rc; - } - } - else - { - pRoot = pPageMove; - } + /* + ** Erase the given database page and all its children. Return + ** the page to the freelist. + */ + static int clearDatabasePage( + BtShared pBt, /* The BTree that contains the table */ + Pgno pgno, /* Page number to clear */ + int freePageFlag, /* Deallocate page if true */ + ref int pnChange /* Add number of Cells freed to this counter */ + ) { + MemPage pPage = new MemPage(); + int rc; + byte[] pCell; + int i; + + Debug.Assert(sqlite3_mutex_held(pBt.mutex)); + if (pgno > btreePagecount(pBt)) { + return SQLITE_CORRUPT_BKPT(); + } - /* Update the pointer-map and meta-data with the new root-page number. */ - ptrmapPut( pBt, pgnoRoot, PTRMAP_ROOTPAGE, 0, ref rc ); - if ( rc != 0 ) - { - releasePage( pRoot ); - return rc; - } + rc = getAndInitPage(pBt, pgno, ref pPage); + if (rc != 0) + return rc; + for (i = 0; i < pPage.nCell; i++) { + int iCell = findCell(pPage, i); + pCell = pPage.aData; // pCell = findCell( pPage, i ); + if (0 == pPage.leaf) { + rc = clearDatabasePage(pBt, sqlite3Get4byte(pCell, iCell), 1, ref pnChange); + if (rc != 0) + goto cleardatabasepage_out; + } + rc = clearCell(pPage, iCell); + if (rc != 0) + goto cleardatabasepage_out; + } + if (0 == pPage.leaf) { + rc = clearDatabasePage(pBt, sqlite3Get4byte(pPage.aData, 8), 1, ref pnChange); + if (rc != 0) + goto cleardatabasepage_out; + } else //if (pnChange != 0) + { + //Debug.Assert(pPage.intKey != 0); + pnChange += pPage.nCell; + } + if (freePageFlag != 0) { + freePage(pPage, ref rc); + } else if ((rc = sqlite3PagerWrite(pPage.pDbPage)) == 0) { + zeroPage(pPage, pPage.aData[0] | PTF_LEAF); + } - /* When the new root page was allocated, page 1 was made writable in - ** order either to increase the database filesize, or to decrement the - ** freelist count. Hence, the sqlite3BtreeUpdateMeta() call cannot fail. - */ - Debug.Assert( sqlite3PagerIswriteable( pBt.pPage1.pDbPage ) ); - rc = sqlite3BtreeUpdateMeta( p, 4, pgnoRoot ); - if ( NEVER( rc != 0 ) ) - { - releasePage( pRoot ); - return rc; - } + cleardatabasepage_out: + releasePage(pPage); + return rc; + } - } - else - { - rc = allocateBtreePage( pBt, ref pRoot, ref pgnoRoot, 1, 0 ); - if ( rc != 0 ) - return rc; - } -#endif - Debug.Assert( sqlite3PagerIswriteable( pRoot.pDbPage ) ); - if ( ( createTabFlags & BTREE_INTKEY ) != 0 ) - { - ptfFlags = PTF_INTKEY | PTF_LEAFDATA | PTF_LEAF; - } - else - { - ptfFlags = PTF_ZERODATA | PTF_LEAF; - } - zeroPage( pRoot, ptfFlags ); - sqlite3PagerUnref( pRoot.pDbPage ); - Debug.Assert( ( pBt.openFlags & BTREE_SINGLE ) == 0 || pgnoRoot == 2 ); - piTable = (int)pgnoRoot; - return SQLITE_OK; -} -static int sqlite3BtreeCreateTable( Btree p, ref int piTable, int flags ) -{ - int rc; - sqlite3BtreeEnter( p ); - rc = btreeCreateTable( p, ref piTable, flags ); - sqlite3BtreeLeave( p ); - return rc; -} + /* + ** Delete all information from a single table in the database. iTable is + ** the page number of the root of the table. After this routine returns, + ** the root page is empty, but still exists. + ** + ** This routine will fail with SQLITE_LOCKED if there are any open + ** read cursors on the table. Open write cursors are moved to the + ** root of the table. + ** + ** If pnChange is not NULL, then table iTable must be an intkey table. The + ** integer value pointed to by pnChange is incremented by the number of + ** entries in the table. + */ + static int sqlite3BtreeClearTable(Btree p, int iTable, ref int pnChange) { + int rc; + BtShared pBt = p.pBt; + sqlite3BtreeEnter(p); + Debug.Assert(p.inTrans == TRANS_WRITE); + + /* Invalidate all incrblob cursors open on table iTable (assuming iTable + ** is the root of a table b-tree - if it is not, the following call is + ** a no-op). */ + invalidateIncrblobCursors(p, 0, 1); + + rc = saveAllCursors(pBt, (Pgno)iTable, null); + if (SQLITE_OK == rc) { + rc = clearDatabasePage(pBt, (Pgno)iTable, 0, ref pnChange); + } + sqlite3BtreeLeave(p); + return rc; + } -/* -** Erase the given database page and all its children. Return -** the page to the freelist. -*/ -static int clearDatabasePage( -BtShared pBt, /* The BTree that contains the table */ -Pgno pgno, /* Page number to clear */ -int freePageFlag, /* Deallocate page if true */ -ref int pnChange /* Add number of Cells freed to this counter */ -) -{ - MemPage pPage = new MemPage(); - int rc; - byte[] pCell; - int i; - - Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); - if ( pgno > btreePagecount( pBt ) ) - { - return SQLITE_CORRUPT_BKPT(); - } - - rc = getAndInitPage( pBt, pgno, ref pPage ); - if ( rc != 0 ) - return rc; - for ( i = 0; i < pPage.nCell; i++ ) - { - int iCell = findCell( pPage, i ); - pCell = pPage.aData; // pCell = findCell( pPage, i ); - if ( 0 == pPage.leaf ) - { - rc = clearDatabasePage( pBt, sqlite3Get4byte( pCell, iCell ), 1, ref pnChange ); - if ( rc != 0 ) - goto cleardatabasepage_out; - } - rc = clearCell( pPage, iCell ); - if ( rc != 0 ) - goto cleardatabasepage_out; - } - if ( 0 == pPage.leaf ) - { - rc = clearDatabasePage( pBt, sqlite3Get4byte( pPage.aData, 8 ), 1, ref pnChange ); - if ( rc != 0 ) - goto cleardatabasepage_out; - } - else //if (pnChange != 0) - { - //Debug.Assert(pPage.intKey != 0); - pnChange += pPage.nCell; - } - if ( freePageFlag != 0 ) - { - freePage( pPage, ref rc ); - } - else if ( ( rc = sqlite3PagerWrite( pPage.pDbPage ) ) == 0 ) - { - zeroPage( pPage, pPage.aData[0] | PTF_LEAF ); - } - -cleardatabasepage_out: - releasePage( pPage ); - return rc; -} + /* + ** Erase all information in a table and add the root of the table to + ** the freelist. Except, the root of the principle table (the one on + ** page 1) is never added to the freelist. + ** + ** This routine will fail with SQLITE_LOCKED if there are any open + ** cursors on the table. + ** + ** If AUTOVACUUM is enabled and the page at iTable is not the last + ** root page in the database file, then the last root page + ** in the database file is moved into the slot formerly occupied by + ** iTable and that last slot formerly occupied by the last root page + ** is added to the freelist instead of iTable. In this say, all + ** root pages are kept at the beginning of the database file, which + ** is necessary for AUTOVACUUM to work right. piMoved is set to the + ** page number that used to be the last root page in the file before + ** the move. If no page gets moved, piMoved is set to 0. + ** The last root page is recorded in meta[3] and the value of + ** meta[3] is updated by this procedure. + */ + static int btreeDropTable(Btree p, Pgno iTable, ref int piMoved) { + int rc; + MemPage pPage = null; + BtShared pBt = p.pBt; + + Debug.Assert(sqlite3BtreeHoldsMutex(p)); + Debug.Assert(p.inTrans == TRANS_WRITE); + + /* It is illegal to drop a table if any cursors are open on the + ** database. This is because in auto-vacuum mode the backend may + ** need to move another root-page to fill a gap left by the deleted + ** root page. If an open cursor was using this page a problem would + ** occur. + ** + ** This error is caught long before control reaches this point. + */ + if (NEVER(pBt.pCursor)) { + sqlite3ConnectionBlocked(p.db, pBt.pCursor.pBtree.db); + return SQLITE_LOCKED_SHAREDCACHE; + } -/* -** Delete all information from a single table in the database. iTable is -** the page number of the root of the table. After this routine returns, -** the root page is empty, but still exists. -** -** This routine will fail with SQLITE_LOCKED if there are any open -** read cursors on the table. Open write cursors are moved to the -** root of the table. -** -** If pnChange is not NULL, then table iTable must be an intkey table. The -** integer value pointed to by pnChange is incremented by the number of -** entries in the table. -*/ -static int sqlite3BtreeClearTable( Btree p, int iTable, ref int pnChange ) -{ - int rc; - BtShared pBt = p.pBt; - sqlite3BtreeEnter( p ); - Debug.Assert( p.inTrans == TRANS_WRITE ); - - /* Invalidate all incrblob cursors open on table iTable (assuming iTable - ** is the root of a table b-tree - if it is not, the following call is - ** a no-op). */ - invalidateIncrblobCursors( p, 0, 1 ); - - rc = saveAllCursors( pBt, (Pgno)iTable, null ); - if ( SQLITE_OK == rc ) - { - rc = clearDatabasePage( pBt, (Pgno)iTable, 0, ref pnChange ); - } - sqlite3BtreeLeave( p ); - return rc; -} + rc = btreeGetPage(pBt, (Pgno)iTable, ref pPage, 0); + if (rc != 0) + return rc; + int Dummy0 = 0; + rc = sqlite3BtreeClearTable(p, (int)iTable, ref Dummy0); + if (rc != 0) { + releasePage(pPage); + return rc; + } -/* -** Erase all information in a table and add the root of the table to -** the freelist. Except, the root of the principle table (the one on -** page 1) is never added to the freelist. -** -** This routine will fail with SQLITE_LOCKED if there are any open -** cursors on the table. -** -** If AUTOVACUUM is enabled and the page at iTable is not the last -** root page in the database file, then the last root page -** in the database file is moved into the slot formerly occupied by -** iTable and that last slot formerly occupied by the last root page -** is added to the freelist instead of iTable. In this say, all -** root pages are kept at the beginning of the database file, which -** is necessary for AUTOVACUUM to work right. piMoved is set to the -** page number that used to be the last root page in the file before -** the move. If no page gets moved, piMoved is set to 0. -** The last root page is recorded in meta[3] and the value of -** meta[3] is updated by this procedure. -*/ -static int btreeDropTable( Btree p, Pgno iTable, ref int piMoved ) -{ - int rc; - MemPage pPage = null; - BtShared pBt = p.pBt; - - Debug.Assert( sqlite3BtreeHoldsMutex( p ) ); - Debug.Assert( p.inTrans == TRANS_WRITE ); - - /* It is illegal to drop a table if any cursors are open on the - ** database. This is because in auto-vacuum mode the backend may - ** need to move another root-page to fill a gap left by the deleted - ** root page. If an open cursor was using this page a problem would - ** occur. - ** - ** This error is caught long before control reaches this point. - */ - if ( NEVER( pBt.pCursor ) ) - { - sqlite3ConnectionBlocked( p.db, pBt.pCursor.pBtree.db ); - return SQLITE_LOCKED_SHAREDCACHE; - } - - rc = btreeGetPage( pBt, (Pgno)iTable, ref pPage, 0 ); - if ( rc != 0 ) - return rc; - int Dummy0 = 0; - rc = sqlite3BtreeClearTable( p, (int)iTable, ref Dummy0 ); - if ( rc != 0 ) - { - releasePage( pPage ); - return rc; - } - - piMoved = 0; - - if ( iTable > 1 ) - { + piMoved = 0; + + if (iTable > 1) { #if SQLITE_OMIT_AUTOVACUUM freePage(pPage, ref rc); releasePage(pPage); #else - if ( pBt.autoVacuum ) - { - Pgno maxRootPgno = 0; - sqlite3BtreeGetMeta( p, BTREE_LARGEST_ROOT_PAGE, ref maxRootPgno ); - - if ( iTable == maxRootPgno ) - { - /* If the table being dropped is the table with the largest root-page - ** number in the database, put the root page on the free list. - */ - freePage( pPage, ref rc ); - releasePage( pPage ); - if ( rc != SQLITE_OK ) - { - return rc; - } - } - else - { - /* The table being dropped does not have the largest root-page - ** number in the database. So move the page that does into the - ** gap left by the deleted root-page. - */ - MemPage pMove = new MemPage(); - releasePage( pPage ); - rc = btreeGetPage( pBt, maxRootPgno, ref pMove, 0 ); - if ( rc != SQLITE_OK ) - { - return rc; - } - rc = relocatePage( pBt, pMove, PTRMAP_ROOTPAGE, 0, iTable, 0 ); - releasePage( pMove ); - if ( rc != SQLITE_OK ) - { - return rc; - } - pMove = null; - rc = btreeGetPage( pBt, maxRootPgno, ref pMove, 0 ); - freePage( pMove, ref rc ); - releasePage( pMove ); - if ( rc != SQLITE_OK ) - { - return rc; - } - piMoved = (int)maxRootPgno; - } - - /* Set the new 'max-root-page' value in the database header. This - ** is the old value less one, less one more if that happens to - ** be a root-page number, less one again if that is the - ** PENDING_BYTE_PAGE. - */ - maxRootPgno--; - while ( maxRootPgno == PENDING_BYTE_PAGE( pBt ) - || PTRMAP_ISPAGE( pBt, maxRootPgno ) ) - { - maxRootPgno--; - } - Debug.Assert( maxRootPgno != PENDING_BYTE_PAGE( pBt ) ); - - rc = sqlite3BtreeUpdateMeta( p, 4, maxRootPgno ); - } - else - { - freePage( pPage, ref rc ); - releasePage( pPage ); - } + if (pBt.autoVacuum) { + Pgno maxRootPgno = 0; + sqlite3BtreeGetMeta(p, BTREE_LARGEST_ROOT_PAGE, ref maxRootPgno); + + if (iTable == maxRootPgno) { + /* If the table being dropped is the table with the largest root-page + ** number in the database, put the root page on the free list. + */ + freePage(pPage, ref rc); + releasePage(pPage); + if (rc != SQLITE_OK) { + return rc; + } + } else { + /* The table being dropped does not have the largest root-page + ** number in the database. So move the page that does into the + ** gap left by the deleted root-page. + */ + MemPage pMove = new MemPage(); + releasePage(pPage); + rc = btreeGetPage(pBt, maxRootPgno, ref pMove, 0); + if (rc != SQLITE_OK) { + return rc; + } + rc = relocatePage(pBt, pMove, PTRMAP_ROOTPAGE, 0, iTable, 0); + releasePage(pMove); + if (rc != SQLITE_OK) { + return rc; + } + pMove = null; + rc = btreeGetPage(pBt, maxRootPgno, ref pMove, 0); + freePage(pMove, ref rc); + releasePage(pMove); + if (rc != SQLITE_OK) { + return rc; + } + piMoved = (int)maxRootPgno; + } + + /* Set the new 'max-root-page' value in the database header. This + ** is the old value less one, less one more if that happens to + ** be a root-page number, less one again if that is the + ** PENDING_BYTE_PAGE. + */ + maxRootPgno--; + while (maxRootPgno == PENDING_BYTE_PAGE(pBt) + || PTRMAP_ISPAGE(pBt, maxRootPgno)) { + maxRootPgno--; + } + Debug.Assert(maxRootPgno != PENDING_BYTE_PAGE(pBt)); + + rc = sqlite3BtreeUpdateMeta(p, 4, maxRootPgno); + } else { + freePage(pPage, ref rc); + releasePage(pPage); + } #endif - } - else - { - /* If sqlite3BtreeDropTable was called on page 1. - ** This really never should happen except in a corrupt - ** database. - */ - zeroPage( pPage, PTF_INTKEY | PTF_LEAF ); - releasePage( pPage ); - } - return rc; -} -static int sqlite3BtreeDropTable( Btree p, int iTable, ref int piMoved ) -{ - int rc; - sqlite3BtreeEnter( p ); - rc = btreeDropTable( p, (u32)iTable, ref piMoved ); - sqlite3BtreeLeave( p ); - return rc; -} + } else { + /* If sqlite3BtreeDropTable was called on page 1. + ** This really never should happen except in a corrupt + ** database. + */ + zeroPage(pPage, PTF_INTKEY | PTF_LEAF); + releasePage(pPage); + } + return rc; + } + static int sqlite3BtreeDropTable(Btree p, int iTable, ref int piMoved) { + int rc; + sqlite3BtreeEnter(p); + rc = btreeDropTable(p, (u32)iTable, ref piMoved); + sqlite3BtreeLeave(p); + return rc; + } -/* -** This function may only be called if the b-tree connection already -** has a read or write transaction open on the database. -** -** Read the meta-information out of a database file. Meta[0] -** is the number of free pages currently in the database. Meta[1] -** through meta[15] are available for use by higher layers. Meta[0] -** is read-only, the others are read/write. -** -** The schema layer numbers meta values differently. At the schema -** layer (and the SetCookie and ReadCookie opcodes) the number of -** free pages is not visible. So Cookie[0] is the same as Meta[1]. -*/ -static void sqlite3BtreeGetMeta( Btree p, int idx, ref u32 pMeta ) -{ - BtShared pBt = p.pBt; + /* + ** This function may only be called if the b-tree connection already + ** has a read or write transaction open on the database. + ** + ** Read the meta-information out of a database file. Meta[0] + ** is the number of free pages currently in the database. Meta[1] + ** through meta[15] are available for use by higher layers. Meta[0] + ** is read-only, the others are read/write. + ** + ** The schema layer numbers meta values differently. At the schema + ** layer (and the SetCookie and ReadCookie opcodes) the number of + ** free pages is not visible. So Cookie[0] is the same as Meta[1]. + */ + static void sqlite3BtreeGetMeta(Btree p, int idx, ref u32 pMeta) { + BtShared pBt = p.pBt; - sqlite3BtreeEnter( p ); - Debug.Assert( p.inTrans > TRANS_NONE ); - Debug.Assert( SQLITE_OK == querySharedCacheTableLock( p, MASTER_ROOT, READ_LOCK ) ); - Debug.Assert( pBt.pPage1 != null ); - Debug.Assert( idx >= 0 && idx <= 15 ); + sqlite3BtreeEnter(p); + Debug.Assert(p.inTrans > TRANS_NONE); + Debug.Assert(SQLITE_OK == querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK)); + Debug.Assert(pBt.pPage1 != null); + Debug.Assert(idx >= 0 && idx <= 15); - pMeta = sqlite3Get4byte( pBt.pPage1.aData, 36 + idx * 4 ); + pMeta = sqlite3Get4byte(pBt.pPage1.aData, 36 + idx * 4); - /* If auto-vacuum is disabled in this build and this is an auto-vacuum - ** database, mark the database as read-only. */ + /* If auto-vacuum is disabled in this build and this is an auto-vacuum + ** database, mark the database as read-only. */ #if SQLITE_OMIT_AUTOVACUUM if( idx==BTREE_LARGEST_ROOT_PAGE && pMeta>0 ) pBt.readOnly = 1; #endif - sqlite3BtreeLeave( p ); -} + sqlite3BtreeLeave(p); + } -/* -** Write meta-information back into the database. Meta[0] is -** read-only and may not be written. -*/ -static int sqlite3BtreeUpdateMeta( Btree p, int idx, u32 iMeta ) -{ - BtShared pBt = p.pBt; - byte[] pP1; - int rc; - Debug.Assert( idx >= 1 && idx <= 15 ); - sqlite3BtreeEnter( p ); - Debug.Assert( p.inTrans == TRANS_WRITE ); - Debug.Assert( pBt.pPage1 != null ); - pP1 = pBt.pPage1.aData; - rc = sqlite3PagerWrite( pBt.pPage1.pDbPage ); - if ( rc == SQLITE_OK ) - { - sqlite3Put4byte( pP1, 36 + idx * 4, iMeta ); + /* + ** Write meta-information back into the database. Meta[0] is + ** read-only and may not be written. + */ + static int sqlite3BtreeUpdateMeta(Btree p, int idx, u32 iMeta) { + BtShared pBt = p.pBt; + byte[] pP1; + int rc; + Debug.Assert(idx >= 1 && idx <= 15); + sqlite3BtreeEnter(p); + Debug.Assert(p.inTrans == TRANS_WRITE); + Debug.Assert(pBt.pPage1 != null); + pP1 = pBt.pPage1.aData; + rc = sqlite3PagerWrite(pBt.pPage1.pDbPage); + if (rc == SQLITE_OK) { + sqlite3Put4byte(pP1, 36 + idx * 4, iMeta); #if !SQLITE_OMIT_AUTOVACUUM - if ( idx == BTREE_INCR_VACUUM ) - { - Debug.Assert( pBt.autoVacuum || iMeta == 0 ); - Debug.Assert( iMeta == 0 || iMeta == 1 ); - pBt.incrVacuum = iMeta != 0; - } + if (idx == BTREE_INCR_VACUUM) { + Debug.Assert(pBt.autoVacuum || iMeta == 0); + Debug.Assert(iMeta == 0 || iMeta == 1); + pBt.incrVacuum = iMeta != 0; + } #endif - } - sqlite3BtreeLeave( p ); - return rc; -} + } + sqlite3BtreeLeave(p); + return rc; + } #if !SQLITE_OMIT_BTREECOUNT -/* -** The first argument, pCur, is a cursor opened on some b-tree. Count the -** number of entries in the b-tree and write the result to pnEntry. -** -** SQLITE_OK is returned if the operation is successfully executed. -** Otherwise, if an error is encountered (i.e. an IO error or database -** corruption) an SQLite error code is returned. -*/ -static int sqlite3BtreeCount( BtCursor pCur, ref i64 pnEntry ) -{ - i64 nEntry = 0; /* Value to return in pnEntry */ - int rc; /* Return code */ - rc = moveToRoot( pCur ); - - /* Unless an error occurs, the following loop runs one iteration for each - ** page in the B-Tree structure (not including overflow pages). - */ - while ( rc == SQLITE_OK ) - { - int iIdx; /* Index of child node in parent */ - MemPage pPage; /* Current page of the b-tree */ - - /* If this is a leaf page or the tree is not an int-key tree, then - ** this page contains countable entries. Increment the entry counter - ** accordingly. - */ - pPage = pCur.apPage[pCur.iPage]; - if ( pPage.leaf != 0 || 0 == pPage.intKey ) - { - nEntry += pPage.nCell; - } - - /* pPage is a leaf node. This loop navigates the cursor so that it - ** points to the first interior cell that it points to the parent of - ** the next page in the tree that has not yet been visited. The - ** pCur.aiIdx[pCur.iPage] value is set to the index of the parent cell - ** of the page, or to the number of cells in the page if the next page - ** to visit is the right-child of its parent. - ** - ** If all pages in the tree have been visited, return SQLITE_OK to the - ** caller. - */ - if ( pPage.leaf != 0 ) - { - do - { - if ( pCur.iPage == 0 ) - { - /* All pages of the b-tree have been visited. Return successfully. */ - pnEntry = nEntry; - return SQLITE_OK; - } - moveToParent( pCur ); - } while ( pCur.aiIdx[pCur.iPage] >= pCur.apPage[pCur.iPage].nCell ); - - pCur.aiIdx[pCur.iPage]++; - pPage = pCur.apPage[pCur.iPage]; - } - - /* Descend to the child node of the cell that the cursor currently - ** points at. This is the right-child if (iIdx==pPage.nCell). - */ - iIdx = pCur.aiIdx[pCur.iPage]; - if ( iIdx == pPage.nCell ) - { - rc = moveToChild( pCur, sqlite3Get4byte( pPage.aData, pPage.hdrOffset + 8 ) ); - } - else - { - rc = moveToChild( pCur, sqlite3Get4byte( pPage.aData, findCell( pPage, iIdx ) ) ); - } - } + /* + ** The first argument, pCur, is a cursor opened on some b-tree. Count the + ** number of entries in the b-tree and write the result to pnEntry. + ** + ** SQLITE_OK is returned if the operation is successfully executed. + ** Otherwise, if an error is encountered (i.e. an IO error or database + ** corruption) an SQLite error code is returned. + */ + static int sqlite3BtreeCount(BtCursor pCur, ref i64 pnEntry) { + i64 nEntry = 0; /* Value to return in pnEntry */ + int rc; /* Return code */ + rc = moveToRoot(pCur); + + /* Unless an error occurs, the following loop runs one iteration for each + ** page in the B-Tree structure (not including overflow pages). + */ + while (rc == SQLITE_OK) { + int iIdx; /* Index of child node in parent */ + MemPage pPage; /* Current page of the b-tree */ + + /* If this is a leaf page or the tree is not an int-key tree, then + ** this page contains countable entries. Increment the entry counter + ** accordingly. + */ + pPage = pCur.apPage[pCur.iPage]; + if (pPage.leaf != 0 || 0 == pPage.intKey) { + nEntry += pPage.nCell; + } + + /* pPage is a leaf node. This loop navigates the cursor so that it + ** points to the first interior cell that it points to the parent of + ** the next page in the tree that has not yet been visited. The + ** pCur.aiIdx[pCur.iPage] value is set to the index of the parent cell + ** of the page, or to the number of cells in the page if the next page + ** to visit is the right-child of its parent. + ** + ** If all pages in the tree have been visited, return SQLITE_OK to the + ** caller. + */ + if (pPage.leaf != 0) { + do { + if (pCur.iPage == 0) { + /* All pages of the b-tree have been visited. Return successfully. */ + pnEntry = nEntry; + return SQLITE_OK; + } + moveToParent(pCur); + } while (pCur.aiIdx[pCur.iPage] >= pCur.apPage[pCur.iPage].nCell); + + pCur.aiIdx[pCur.iPage]++; + pPage = pCur.apPage[pCur.iPage]; + } + + /* Descend to the child node of the cell that the cursor currently + ** points at. This is the right-child if (iIdx==pPage.nCell). + */ + iIdx = pCur.aiIdx[pCur.iPage]; + if (iIdx == pPage.nCell) { + rc = moveToChild(pCur, sqlite3Get4byte(pPage.aData, pPage.hdrOffset + 8)); + } else { + rc = moveToChild(pCur, sqlite3Get4byte(pPage.aData, findCell(pPage, iIdx))); + } + } - /* An error has occurred. Return an error code. */ - return rc; -} + /* An error has occurred. Return an error code. */ + return rc; + } #endif -/* -** Return the pager associated with a BTree. This routine is used for -** testing and debugging only. -*/ -static Pager sqlite3BtreePager( Btree p ) -{ - return p.pBt.pPager; -} + /* + ** Return the pager associated with a BTree. This routine is used for + ** testing and debugging only. + */ + static Pager sqlite3BtreePager(Btree p) { + return p.pBt.pPager; + } #if !SQLITE_OMIT_INTEGRITY_CHECK -/* -** Append a message to the error message string. -*/ -static void checkAppendMsg( -IntegrityCk pCheck, -string zMsg1, -string zFormat, -params object[] ap -) -{ - if ( 0 == pCheck.mxErr ) - return; - //va_list ap; - lock ( lock_va_list ) - { - pCheck.mxErr--; - pCheck.nErr++; - va_start( ap, zFormat ); - if ( pCheck.errMsg.zText.Length != 0 ) - { - sqlite3StrAccumAppend( pCheck.errMsg, "\n", 1 ); - } - if ( zMsg1.Length > 0 ) - { - sqlite3StrAccumAppend( pCheck.errMsg, zMsg1.ToString(), -1 ); - } - sqlite3VXPrintf( pCheck.errMsg, 1, zFormat, ap ); - va_end( ref ap ); - } -} + /* + ** Append a message to the error message string. + */ + static void checkAppendMsg( + IntegrityCk pCheck, + string zMsg1, + string zFormat, + params object[] ap + ) { + if (0 == pCheck.mxErr) + return; + //va_list ap; + lock (lock_va_list) { + pCheck.mxErr--; + pCheck.nErr++; + va_start(ap, zFormat); + if (pCheck.errMsg.zText.Length != 0) { + sqlite3StrAccumAppend(pCheck.errMsg, "\n", 1); + } + if (zMsg1.Length > 0) { + sqlite3StrAccumAppend(pCheck.errMsg, zMsg1.ToString(), -1); + } + sqlite3VXPrintf(pCheck.errMsg, 1, zFormat, ap); + va_end(ref ap); + } + } -static void checkAppendMsg( -IntegrityCk pCheck, -StringBuilder zMsg1, -string zFormat, -params object[] ap -) -{ - if ( 0 == pCheck.mxErr ) - return; - //va_list ap; - lock ( lock_va_list ) - { - pCheck.mxErr--; - pCheck.nErr++; - va_start( ap, zFormat ); - if ( pCheck.errMsg.zText.Length != 0 ) - { - sqlite3StrAccumAppend( pCheck.errMsg, "\n", 1 ); - } - if ( zMsg1.Length > 0 ) - { - sqlite3StrAccumAppend( pCheck.errMsg, zMsg1.ToString(), -1 ); - } - sqlite3VXPrintf( pCheck.errMsg, 1, zFormat, ap ); - va_end( ref ap ); - } - //if( pCheck.errMsg.mallocFailed ){ - // pCheck.mallocFailed = 1; - //} -} + static void checkAppendMsg( + IntegrityCk pCheck, + StringBuilder zMsg1, + string zFormat, + params object[] ap + ) { + if (0 == pCheck.mxErr) + return; + //va_list ap; + lock (lock_va_list) { + pCheck.mxErr--; + pCheck.nErr++; + va_start(ap, zFormat); + if (pCheck.errMsg.zText.Length != 0) { + sqlite3StrAccumAppend(pCheck.errMsg, "\n", 1); + } + if (zMsg1.Length > 0) { + sqlite3StrAccumAppend(pCheck.errMsg, zMsg1.ToString(), -1); + } + sqlite3VXPrintf(pCheck.errMsg, 1, zFormat, ap); + va_end(ref ap); + } + //if( pCheck.errMsg.mallocFailed ){ + // pCheck.mallocFailed = 1; + //} + } #endif //* SQLITE_OMIT_INTEGRITY_CHECK */ #if !SQLITE_OMIT_INTEGRITY_CHECK -/* -** Add 1 to the reference count for page iPage. If this is the second -** reference to the page, add an error message to pCheck.zErrMsg. -** Return 1 if there are 2 ore more references to the page and 0 if -** if this is the first reference to the page. -** -** Also check that the page number is in bounds. -*/ -static int checkRef( IntegrityCk pCheck, Pgno iPage, string zContext ) -{ - if ( iPage == 0 ) - return 1; - if ( iPage > pCheck.nPage ) - { - checkAppendMsg( pCheck, zContext, "invalid page number %d", iPage ); - return 1; - } - if ( pCheck.anRef[iPage] == 1 ) - { - checkAppendMsg( pCheck, zContext, "2nd reference to page %d", iPage ); - return 1; - } - return ( ( pCheck.anRef[iPage]++ ) > 1 ) ? 1 : 0; -} + /* + ** Add 1 to the reference count for page iPage. If this is the second + ** reference to the page, add an error message to pCheck.zErrMsg. + ** Return 1 if there are 2 ore more references to the page and 0 if + ** if this is the first reference to the page. + ** + ** Also check that the page number is in bounds. + */ + static int checkRef(IntegrityCk pCheck, Pgno iPage, string zContext) { + if (iPage == 0) + return 1; + if (iPage > pCheck.nPage) { + checkAppendMsg(pCheck, zContext, "invalid page number %d", iPage); + return 1; + } + if (pCheck.anRef[iPage] == 1) { + checkAppendMsg(pCheck, zContext, "2nd reference to page %d", iPage); + return 1; + } + return ((pCheck.anRef[iPage]++) > 1) ? 1 : 0; + } #if !SQLITE_OMIT_AUTOVACUUM -/* -** Check that the entry in the pointer-map for page iChild maps to -** page iParent, pointer type ptrType. If not, append an error message -** to pCheck. -*/ -static void checkPtrmap( -IntegrityCk pCheck, /* Integrity check context */ -Pgno iChild, /* Child page number */ -u8 eType, /* Expected pointer map type */ -Pgno iParent, /* Expected pointer map parent page number */ -string zContext /* Context description (used for error msg) */ -) -{ - int rc; - u8 ePtrmapType = 0; - Pgno iPtrmapParent = 0; - - rc = ptrmapGet( pCheck.pBt, iChild, ref ePtrmapType, ref iPtrmapParent ); - if ( rc != SQLITE_OK ) - { - //if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ) pCheck.mallocFailed = 1; - checkAppendMsg( pCheck, zContext, "Failed to read ptrmap key=%d", iChild ); - return; - } - - if ( ePtrmapType != eType || iPtrmapParent != iParent ) - { - checkAppendMsg( pCheck, zContext, - "Bad ptr map entry key=%d expected=(%d,%d) got=(%d,%d)", - iChild, eType, iParent, ePtrmapType, iPtrmapParent ); - } -} + /* + ** Check that the entry in the pointer-map for page iChild maps to + ** page iParent, pointer type ptrType. If not, append an error message + ** to pCheck. + */ + static void checkPtrmap( + IntegrityCk pCheck, /* Integrity check context */ + Pgno iChild, /* Child page number */ + u8 eType, /* Expected pointer map type */ + Pgno iParent, /* Expected pointer map parent page number */ + string zContext /* Context description (used for error msg) */ + ) { + int rc; + u8 ePtrmapType = 0; + Pgno iPtrmapParent = 0; + + rc = ptrmapGet(pCheck.pBt, iChild, ref ePtrmapType, ref iPtrmapParent); + if (rc != SQLITE_OK) { + //if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ) pCheck.mallocFailed = 1; + checkAppendMsg(pCheck, zContext, "Failed to read ptrmap key=%d", iChild); + return; + } + + if (ePtrmapType != eType || iPtrmapParent != iParent) { + checkAppendMsg(pCheck, zContext, + "Bad ptr map entry key=%d expected=(%d,%d) got=(%d,%d)", + iChild, eType, iParent, ePtrmapType, iPtrmapParent); + } + } #endif -/* -** Check the integrity of the freelist or of an overflow page list. -** Verify that the number of pages on the list is N. -*/ -static void checkList( -IntegrityCk pCheck, /* Integrity checking context */ -int isFreeList, /* True for a freelist. False for overflow page list */ -int iPage, /* Page number for first page in the list */ -int N, /* Expected number of pages in the list */ -string zContext /* Context for error messages */ -) -{ - int i; - int expected = N; - int iFirst = iPage; - while ( N-- > 0 && pCheck.mxErr != 0 ) - { - PgHdr pOvflPage = new PgHdr(); - byte[] pOvflData; - if ( iPage < 1 ) - { - checkAppendMsg( pCheck, zContext, - "%d of %d pages missing from overflow list starting at %d", - N + 1, expected, iFirst ); - break; - } - if ( checkRef( pCheck, (u32)iPage, zContext ) != 0 ) - break; - if ( sqlite3PagerGet( pCheck.pPager, (Pgno)iPage, ref pOvflPage ) != 0 ) - { - checkAppendMsg( pCheck, zContext, "failed to get page %d", iPage ); - break; - } - pOvflData = sqlite3PagerGetData( pOvflPage ); - if ( isFreeList != 0 ) - { - int n = (int)sqlite3Get4byte( pOvflData, 4 ); + /* + ** Check the integrity of the freelist or of an overflow page list. + ** Verify that the number of pages on the list is N. + */ + static void checkList( + IntegrityCk pCheck, /* Integrity checking context */ + int isFreeList, /* True for a freelist. False for overflow page list */ + int iPage, /* Page number for first page in the list */ + int N, /* Expected number of pages in the list */ + string zContext /* Context for error messages */ + ) { + int i; + int expected = N; + int iFirst = iPage; + while (N-- > 0 && pCheck.mxErr != 0) { + PgHdr pOvflPage = new PgHdr(); + byte[] pOvflData; + if (iPage < 1) { + checkAppendMsg(pCheck, zContext, + "%d of %d pages missing from overflow list starting at %d", + N + 1, expected, iFirst); + break; + } + if (checkRef(pCheck, (u32)iPage, zContext) != 0) + break; + if (sqlite3PagerGet(pCheck.pPager, (Pgno)iPage, ref pOvflPage) != 0) { + checkAppendMsg(pCheck, zContext, "failed to get page %d", iPage); + break; + } + pOvflData = sqlite3PagerGetData(pOvflPage); + if (isFreeList != 0) { + int n = (int)sqlite3Get4byte(pOvflData, 4); #if !SQLITE_OMIT_AUTOVACUUM - if ( pCheck.pBt.autoVacuum ) - { - checkPtrmap( pCheck, (u32)iPage, PTRMAP_FREEPAGE, 0, zContext ); - } + if (pCheck.pBt.autoVacuum) { + checkPtrmap(pCheck, (u32)iPage, PTRMAP_FREEPAGE, 0, zContext); + } #endif - if ( n > (int)pCheck.pBt.usableSize / 4 - 2 ) - { - checkAppendMsg( pCheck, zContext, - "freelist leaf count too big on page %d", iPage ); - N--; - } - else - { - for ( i = 0; i < n; i++ ) - { - Pgno iFreePage = sqlite3Get4byte( pOvflData, 8 + i * 4 ); + if (n > (int)pCheck.pBt.usableSize / 4 - 2) { + checkAppendMsg(pCheck, zContext, + "freelist leaf count too big on page %d", iPage); + N--; + } else { + for (i = 0; i < n; i++) { + Pgno iFreePage = sqlite3Get4byte(pOvflData, 8 + i * 4); #if !SQLITE_OMIT_AUTOVACUUM - if ( pCheck.pBt.autoVacuum ) - { - checkPtrmap( pCheck, iFreePage, PTRMAP_FREEPAGE, 0, zContext ); - } + if (pCheck.pBt.autoVacuum) { + checkPtrmap(pCheck, iFreePage, PTRMAP_FREEPAGE, 0, zContext); + } #endif - checkRef( pCheck, iFreePage, zContext ); - } - N -= n; - } - } + checkRef(pCheck, iFreePage, zContext); + } + N -= n; + } + } #if !SQLITE_OMIT_AUTOVACUUM - else - { - /* If this database supports auto-vacuum and iPage is not the last - ** page in this overflow list, check that the pointer-map entry for - ** the following page matches iPage. - */ - if ( pCheck.pBt.autoVacuum && N > 0 ) - { - i = (int)sqlite3Get4byte( pOvflData ); - checkPtrmap( pCheck, (u32)i, PTRMAP_OVERFLOW2, (u32)iPage, zContext ); - } - } + else { + /* If this database supports auto-vacuum and iPage is not the last + ** page in this overflow list, check that the pointer-map entry for + ** the following page matches iPage. + */ + if (pCheck.pBt.autoVacuum && N > 0) { + i = (int)sqlite3Get4byte(pOvflData); + checkPtrmap(pCheck, (u32)i, PTRMAP_OVERFLOW2, (u32)iPage, zContext); + } + } #endif - iPage = (int)sqlite3Get4byte( pOvflData ); - sqlite3PagerUnref( pOvflPage ); - } -} + iPage = (int)sqlite3Get4byte(pOvflData); + sqlite3PagerUnref(pOvflPage); + } + } #endif //* SQLITE_OMIT_INTEGRITY_CHECK */ #if !SQLITE_OMIT_INTEGRITY_CHECK -/* -** Do various sanity checks on a single page of a tree. Return -** the tree depth. Root pages return 0. Parents of root pages -** return 1, and so forth. -** -** These checks are done: -** -** 1. Make sure that cells and freeblocks do not overlap -** but combine to completely cover the page. -** NO 2. Make sure cell keys are in order. -** NO 3. Make sure no key is less than or equal to zLowerBound. -** NO 4. Make sure no key is greater than or equal to zUpperBound. -** 5. Check the integrity of overflow pages. -** 6. Recursively call checkTreePage on all children. -** 7. Verify that the depth of all children is the same. -** 8. Make sure this page is at least 33% full or else it is -** the root of the tree. -*/ + /* + ** Do various sanity checks on a single page of a tree. Return + ** the tree depth. Root pages return 0. Parents of root pages + ** return 1, and so forth. + ** + ** These checks are done: + ** + ** 1. Make sure that cells and freeblocks do not overlap + ** but combine to completely cover the page. + ** NO 2. Make sure cell keys are in order. + ** NO 3. Make sure no key is less than or equal to zLowerBound. + ** NO 4. Make sure no key is greater than or equal to zUpperBound. + ** 5. Check the integrity of overflow pages. + ** 6. Recursively call checkTreePage on all children. + ** 7. Verify that the depth of all children is the same. + ** 8. Make sure this page is at least 33% full or else it is + ** the root of the tree. + */ -static i64 refNULL = 0; //Dummy for C# ref NULL - -static int checkTreePage( -IntegrityCk pCheck, /* Context for the sanity check */ -int iPage, /* Page number of the page to check */ -string zParentContext, /* Parent context */ -ref i64 pnParentMinKey, -ref i64 pnParentMaxKey, -object _pnParentMinKey, /* C# Needed to determine if content passed*/ -object _pnParentMaxKey /* C# Needed to determine if content passed*/ -) -{ - MemPage pPage = new MemPage(); - int i, rc, depth, d2, pgno, cnt; - int hdr, cellStart; - int nCell; - u8[] data; - BtShared pBt; - int usableSize; - StringBuilder zContext = new StringBuilder( 100 ); - byte[] hit = null; - i64 nMinKey = 0; - i64 nMaxKey = 0; - - - sqlite3_snprintf( 200, zContext, "Page %d: ", iPage ); - - /* Check that the page exists - */ - pBt = pCheck.pBt; - usableSize = (int)pBt.usableSize; - if ( iPage == 0 ) - return 0; - if ( checkRef( pCheck, (u32)iPage, zParentContext ) != 0 ) - return 0; - if ( ( rc = btreeGetPage( pBt, (Pgno)iPage, ref pPage, 0 ) ) != 0 ) - { - checkAppendMsg( pCheck, zContext.ToString(), - "unable to get the page. error code=%d", rc ); - return 0; - } - - /* Clear MemPage.isInit to make sure the corruption detection code in - ** btreeInitPage() is executed. */ - pPage.isInit = 0; - if ( ( rc = btreeInitPage( pPage ) ) != 0 ) - { - Debug.Assert( rc == SQLITE_CORRUPT ); /* The only possible error from InitPage */ - checkAppendMsg( pCheck, zContext.ToString(), - "btreeInitPage() returns error code %d", rc ); - releasePage( pPage ); - return 0; - } - - /* Check out all the cells. - */ - depth = 0; - for ( i = 0; i < pPage.nCell && pCheck.mxErr != 0; i++ ) - { - u8[] pCell; - u32 sz; - CellInfo info = new CellInfo(); - - /* Check payload overflow pages - */ - sqlite3_snprintf( 200, zContext, - "On tree page %d cell %d: ", iPage, i ); - int iCell = findCell( pPage, i ); //pCell = findCell( pPage, i ); - pCell = pPage.aData; - btreeParseCellPtr( pPage, iCell, ref info ); //btreeParseCellPtr( pPage, pCell, info ); - sz = info.nData; - if ( 0 == pPage.intKey ) - sz += (u32)info.nKey; - /* For intKey pages, check that the keys are in order. - */ - else if ( i == 0 ) - nMinKey = nMaxKey = info.nKey; - else - { - if ( info.nKey <= nMaxKey ) - { - checkAppendMsg( pCheck, zContext.ToString(), - "Rowid %lld out of order (previous was %lld)", info.nKey, nMaxKey ); - } - nMaxKey = info.nKey; - } - Debug.Assert( sz == info.nPayload ); - if ( ( sz > info.nLocal ) - //&& (pCell[info.iOverflow]<=&pPage.aData[pBt.usableSize]) - ) - { - int nPage = (int)( sz - info.nLocal + usableSize - 5 ) / ( usableSize - 4 ); - Pgno pgnoOvfl = sqlite3Get4byte( pCell, iCell, info.iOverflow ); + static i64 refNULL = 0; //Dummy for C# ref NULL + + static int checkTreePage( + IntegrityCk pCheck, /* Context for the sanity check */ + int iPage, /* Page number of the page to check */ + string zParentContext, /* Parent context */ + ref i64 pnParentMinKey, + ref i64 pnParentMaxKey, + object _pnParentMinKey, /* C# Needed to determine if content passed*/ + object _pnParentMaxKey /* C# Needed to determine if content passed*/ + ) { + MemPage pPage = new MemPage(); + int i, rc, depth, d2, pgno, cnt; + int hdr, cellStart; + int nCell; + u8[] data; + BtShared pBt; + int usableSize; + StringBuilder zContext = new StringBuilder(100); + byte[] hit = null; + i64 nMinKey = 0; + i64 nMaxKey = 0; + + + sqlite3_snprintf(200, zContext, "Page %d: ", iPage); + + /* Check that the page exists + */ + pBt = pCheck.pBt; + usableSize = (int)pBt.usableSize; + if (iPage == 0) + return 0; + if (checkRef(pCheck, (u32)iPage, zParentContext) != 0) + return 0; + if ((rc = btreeGetPage(pBt, (Pgno)iPage, ref pPage, 0)) != 0) { + checkAppendMsg(pCheck, zContext.ToString(), + "unable to get the page. error code=%d", rc); + return 0; + } + + /* Clear MemPage.isInit to make sure the corruption detection code in + ** btreeInitPage() is executed. */ + pPage.isInit = 0; + if ((rc = btreeInitPage(pPage)) != 0) { + Debug.Assert(rc == SQLITE_CORRUPT); /* The only possible error from InitPage */ + checkAppendMsg(pCheck, zContext.ToString(), + "btreeInitPage() returns error code %d", rc); + releasePage(pPage); + return 0; + } + + /* Check out all the cells. + */ + depth = 0; + for (i = 0; i < pPage.nCell && pCheck.mxErr != 0; i++) { + u8[] pCell; + u32 sz; + CellInfo info = new CellInfo(); + + /* Check payload overflow pages + */ + sqlite3_snprintf(200, zContext, + "On tree page %d cell %d: ", iPage, i); + int iCell = findCell(pPage, i); //pCell = findCell( pPage, i ); + pCell = pPage.aData; + btreeParseCellPtr(pPage, iCell, ref info); //btreeParseCellPtr( pPage, pCell, info ); + sz = info.nData; + if (0 == pPage.intKey) + sz += (u32)info.nKey; + /* For intKey pages, check that the keys are in order. + */ + else if (i == 0) + nMinKey = nMaxKey = info.nKey; + else { + if (info.nKey <= nMaxKey) { + checkAppendMsg(pCheck, zContext.ToString(), + "Rowid %lld out of order (previous was %lld)", info.nKey, nMaxKey); + } + nMaxKey = info.nKey; + } + Debug.Assert(sz == info.nPayload); + if ((sz > info.nLocal) + //&& (pCell[info.iOverflow]<=&pPage.aData[pBt.usableSize]) + ) { + int nPage = (int)(sz - info.nLocal + usableSize - 5) / (usableSize - 4); + Pgno pgnoOvfl = sqlite3Get4byte(pCell, iCell, info.iOverflow); #if !SQLITE_OMIT_AUTOVACUUM - if ( pBt.autoVacuum ) - { - checkPtrmap( pCheck, pgnoOvfl, PTRMAP_OVERFLOW1, (u32)iPage, zContext.ToString() ); - } + if (pBt.autoVacuum) { + checkPtrmap(pCheck, pgnoOvfl, PTRMAP_OVERFLOW1, (u32)iPage, zContext.ToString()); + } #endif - checkList( pCheck, 0, (int)pgnoOvfl, nPage, zContext.ToString() ); - } + checkList(pCheck, 0, (int)pgnoOvfl, nPage, zContext.ToString()); + } - /* Check sanity of left child page. - */ - if ( 0 == pPage.leaf ) - { - pgno = (int)sqlite3Get4byte( pCell, iCell ); //sqlite3Get4byte( pCell ); + /* Check sanity of left child page. + */ + if (0 == pPage.leaf) { + pgno = (int)sqlite3Get4byte(pCell, iCell); //sqlite3Get4byte( pCell ); #if !SQLITE_OMIT_AUTOVACUUM - if ( pBt.autoVacuum ) - { - checkPtrmap( pCheck, (u32)pgno, PTRMAP_BTREE, (u32)iPage, zContext.ToString() ); - } + if (pBt.autoVacuum) { + checkPtrmap(pCheck, (u32)pgno, PTRMAP_BTREE, (u32)iPage, zContext.ToString()); + } #endif - if ( i == 0 ) - d2 = checkTreePage( pCheck, pgno, zContext.ToString(), ref nMinKey, ref refNULL, pCheck, null ); - else - d2 = checkTreePage( pCheck, pgno, zContext.ToString(), ref nMinKey, ref nMaxKey, pCheck, pCheck ); - - if ( i > 0 && d2 != depth ) - { - checkAppendMsg( pCheck, zContext, "Child page depth differs" ); - } - depth = d2; - } - } - if ( 0 == pPage.leaf ) - { - pgno = (int)sqlite3Get4byte( pPage.aData, pPage.hdrOffset + 8 ); - sqlite3_snprintf( 200, zContext, - "On page %d at right child: ", iPage ); + if (i == 0) + d2 = checkTreePage(pCheck, pgno, zContext.ToString(), ref nMinKey, ref refNULL, pCheck, null); + else + d2 = checkTreePage(pCheck, pgno, zContext.ToString(), ref nMinKey, ref nMaxKey, pCheck, pCheck); + + if (i > 0 && d2 != depth) { + checkAppendMsg(pCheck, zContext, "Child page depth differs"); + } + depth = d2; + } + } + if (0 == pPage.leaf) { + pgno = (int)sqlite3Get4byte(pPage.aData, pPage.hdrOffset + 8); + sqlite3_snprintf(200, zContext, + "On page %d at right child: ", iPage); #if !SQLITE_OMIT_AUTOVACUUM - if ( pBt.autoVacuum ) - { - checkPtrmap( pCheck, (u32)pgno, PTRMAP_BTREE, (u32)iPage, zContext.ToString() ); - } + if (pBt.autoVacuum) { + checkPtrmap(pCheck, (u32)pgno, PTRMAP_BTREE, (u32)iPage, zContext.ToString()); + } #endif - // checkTreePage(pCheck, pgno, zContext, NULL, !pPage->nCell ? NULL : &nMaxKey); - if ( 0 == pPage.nCell ) - checkTreePage( pCheck, pgno, zContext.ToString(), ref refNULL, ref refNULL, null, null ); - else - checkTreePage( pCheck, pgno, zContext.ToString(), ref refNULL, ref nMaxKey, null, pCheck ); - } - - /* For intKey leaf pages, check that the min/max keys are in order - ** with any left/parent/right pages. - */ - if ( pPage.leaf != 0 && pPage.intKey != 0 ) - { - /* if we are a left child page */ - if ( _pnParentMinKey != null ) - { - /* if we are the left most child page */ - if ( _pnParentMaxKey == null ) - { - if ( nMaxKey > pnParentMinKey ) - { - checkAppendMsg( pCheck, zContext, - "Rowid %lld out of order (max larger than parent min of %lld)", - nMaxKey, pnParentMinKey ); - } - } - else - { - if ( nMinKey <= pnParentMinKey ) - { - checkAppendMsg( pCheck, zContext, - "Rowid %lld out of order (min less than parent min of %lld)", - nMinKey, pnParentMinKey ); - } - if ( nMaxKey > pnParentMaxKey ) - { - checkAppendMsg( pCheck, zContext, - "Rowid %lld out of order (max larger than parent max of %lld)", - nMaxKey, pnParentMaxKey ); - } - pnParentMinKey = nMaxKey; - } - /* else if we're a right child page */ - } - else if ( _pnParentMaxKey != null ) - { - if ( nMinKey <= pnParentMaxKey ) - { - checkAppendMsg( pCheck, zContext, - "Rowid %lld out of order (min less than parent max of %lld)", - nMinKey, pnParentMaxKey ); - } - } - } - - /* Check for complete coverage of the page - */ - data = pPage.aData; - hdr = pPage.hdrOffset; - hit = sqlite3Malloc( pBt.pageSize ); - //if( hit==null ){ - // pCheck.mallocFailed = 1; - //}else - { - int contentOffset = get2byteNotZero( data, hdr + 5 ); - Debug.Assert( contentOffset <= usableSize ); /* Enforced by btreeInitPage() */ - Array.Clear( hit, contentOffset, usableSize - contentOffset );//memset(hit+contentOffset, 0, usableSize-contentOffset); - for ( int iLoop = contentOffset - 1; iLoop >= 0; iLoop-- ) - hit[iLoop] = 1;//memset(hit, 1, contentOffset); - nCell = get2byte( data, hdr + 3 ); - cellStart = hdr + 12 - 4 * pPage.leaf; - for ( i = 0; i < nCell; i++ ) - { - int pc = get2byte( data, cellStart + i * 2 ); - u32 size = 65536; - int j; - if ( pc <= usableSize - 4 ) - { - size = cellSizePtr( pPage, data, pc ); - } - if ( (int)( pc + size - 1 ) >= usableSize ) - { - checkAppendMsg( pCheck, "", - "Corruption detected in cell %d on page %d", i, iPage ); - } - else - { - for ( j = (int)( pc + size - 1 ); j >= pc; j-- ) - hit[j]++; - } - } - i = get2byte( data, hdr + 1 ); - while ( i > 0 ) - { - int size, j; - Debug.Assert( i <= usableSize - 4 ); /* Enforced by btreeInitPage() */ - size = get2byte( data, i + 2 ); - Debug.Assert( i + size <= usableSize ); /* Enforced by btreeInitPage() */ - for ( j = i + size - 1; j >= i; j-- ) - hit[j]++; - j = get2byte( data, i ); - Debug.Assert( j == 0 || j > i + size ); /* Enforced by btreeInitPage() */ - Debug.Assert( j <= usableSize - 4 ); /* Enforced by btreeInitPage() */ - i = j; - } - for ( i = cnt = 0; i < usableSize; i++ ) - { - if ( hit[i] == 0 ) - { - cnt++; - } - else if ( hit[i] > 1 ) - { - checkAppendMsg( pCheck, "", - "Multiple uses for byte %d of page %d", i, iPage ); - break; - } - } - if ( cnt != data[hdr + 7] ) - { - checkAppendMsg( pCheck, "", - "Fragmentation of %d bytes reported as %d on page %d", - cnt, data[hdr + 7], iPage ); - } - } - sqlite3PageFree( ref hit ); - releasePage( pPage ); - return depth + 1; -} + // checkTreePage(pCheck, pgno, zContext, NULL, !pPage->nCell ? NULL : &nMaxKey); + if (0 == pPage.nCell) + checkTreePage(pCheck, pgno, zContext.ToString(), ref refNULL, ref refNULL, null, null); + else + checkTreePage(pCheck, pgno, zContext.ToString(), ref refNULL, ref nMaxKey, null, pCheck); + } + + /* For intKey leaf pages, check that the min/max keys are in order + ** with any left/parent/right pages. + */ + if (pPage.leaf != 0 && pPage.intKey != 0) { + /* if we are a left child page */ + if (_pnParentMinKey != null) { + /* if we are the left most child page */ + if (_pnParentMaxKey == null) { + if (nMaxKey > pnParentMinKey) { + checkAppendMsg(pCheck, zContext, + "Rowid %lld out of order (max larger than parent min of %lld)", + nMaxKey, pnParentMinKey); + } + } else { + if (nMinKey <= pnParentMinKey) { + checkAppendMsg(pCheck, zContext, + "Rowid %lld out of order (min less than parent min of %lld)", + nMinKey, pnParentMinKey); + } + if (nMaxKey > pnParentMaxKey) { + checkAppendMsg(pCheck, zContext, + "Rowid %lld out of order (max larger than parent max of %lld)", + nMaxKey, pnParentMaxKey); + } + pnParentMinKey = nMaxKey; + } + /* else if we're a right child page */ + } else if (_pnParentMaxKey != null) { + if (nMinKey <= pnParentMaxKey) { + checkAppendMsg(pCheck, zContext, + "Rowid %lld out of order (min less than parent max of %lld)", + nMinKey, pnParentMaxKey); + } + } + } + + /* Check for complete coverage of the page + */ + data = pPage.aData; + hdr = pPage.hdrOffset; + hit = sqlite3Malloc(pBt.pageSize); + //if( hit==null ){ + // pCheck.mallocFailed = 1; + //}else + { + int contentOffset = get2byteNotZero(data, hdr + 5); + Debug.Assert(contentOffset <= usableSize); /* Enforced by btreeInitPage() */ + Array.Clear(hit, contentOffset, usableSize - contentOffset);//memset(hit+contentOffset, 0, usableSize-contentOffset); + for (int iLoop = contentOffset - 1; iLoop >= 0; iLoop--) + hit[iLoop] = 1;//memset(hit, 1, contentOffset); + nCell = get2byte(data, hdr + 3); + cellStart = hdr + 12 - 4 * pPage.leaf; + for (i = 0; i < nCell; i++) { + int pc = get2byte(data, cellStart + i * 2); + u32 size = 65536; + int j; + if (pc <= usableSize - 4) { + size = cellSizePtr(pPage, data, pc); + } + if ((int)(pc + size - 1) >= usableSize) { + checkAppendMsg(pCheck, "", + "Corruption detected in cell %d on page %d", i, iPage); + } else { + for (j = (int)(pc + size - 1); j >= pc; j--) + hit[j]++; + } + } + i = get2byte(data, hdr + 1); + while (i > 0) { + int size, j; + Debug.Assert(i <= usableSize - 4); /* Enforced by btreeInitPage() */ + size = get2byte(data, i + 2); + Debug.Assert(i + size <= usableSize); /* Enforced by btreeInitPage() */ + for (j = i + size - 1; j >= i; j--) + hit[j]++; + j = get2byte(data, i); + Debug.Assert(j == 0 || j > i + size); /* Enforced by btreeInitPage() */ + Debug.Assert(j <= usableSize - 4); /* Enforced by btreeInitPage() */ + i = j; + } + for (i = cnt = 0; i < usableSize; i++) { + if (hit[i] == 0) { + cnt++; + } else if (hit[i] > 1) { + checkAppendMsg(pCheck, "", + "Multiple uses for byte %d of page %d", i, iPage); + break; + } + } + if (cnt != data[hdr + 7]) { + checkAppendMsg(pCheck, "", + "Fragmentation of %d bytes reported as %d on page %d", + cnt, data[hdr + 7], iPage); + } + } + sqlite3PageFree(ref hit); + releasePage(pPage); + return depth + 1; + } #endif //* SQLITE_OMIT_INTEGRITY_CHECK */ #if !SQLITE_OMIT_INTEGRITY_CHECK -/* -** This routine does a complete check of the given BTree file. aRoot[] is -** an array of pages numbers were each page number is the root page of -** a table. nRoot is the number of entries in aRoot. -** -** A read-only or read-write transaction must be opened before calling -** this function. -** -** Write the number of error seen in pnErr. Except for some memory -** allocation errors, an error message held in memory obtained from -** malloc is returned if pnErr is non-zero. If pnErr==null then NULL is -** returned. If a memory allocation error occurs, NULL is returned. -*/ -static string sqlite3BtreeIntegrityCheck( -Btree p, /* The btree to be checked */ -int[] aRoot, /* An array of root pages numbers for individual trees */ -int nRoot, /* Number of entries in aRoot[] */ -int mxErr, /* Stop reporting errors after this many */ -ref int pnErr /* Write number of errors seen to this variable */ -) -{ - Pgno i; - int nRef; - IntegrityCk sCheck = new IntegrityCk(); - BtShared pBt = p.pBt; - - sqlite3BtreeEnter( p ); - Debug.Assert( p.inTrans > TRANS_NONE && pBt.inTransaction > TRANS_NONE ); - nRef = sqlite3PagerRefcount( pBt.pPager ); - sCheck.pBt = pBt; - sCheck.pPager = pBt.pPager; - sCheck.nPage = btreePagecount( sCheck.pBt ); - sCheck.mxErr = mxErr; - sCheck.nErr = 0; - //sCheck.mallocFailed = 0; - pnErr = 0; - if ( sCheck.nPage == 0 ) - { - sqlite3BtreeLeave( p ); - return ""; - } - sCheck.anRef = sqlite3Malloc( sCheck.anRef, (int)sCheck.nPage + 1 ); - //if( !sCheck.anRef ){ - // pnErr = 1; - // sqlite3BtreeLeave(p); - // return 0; - //} - // for (i = 0; i <= sCheck.nPage; i++) { sCheck.anRef[i] = 0; } - i = PENDING_BYTE_PAGE( pBt ); - if ( i <= sCheck.nPage ) - { - sCheck.anRef[i] = 1; - } - sqlite3StrAccumInit( sCheck.errMsg, null, 1000, 20000 ); - //sCheck.errMsg.useMalloc = 2; - - /* Check the integrity of the freelist - */ - checkList( sCheck, 1, (int)sqlite3Get4byte( pBt.pPage1.aData, 32 ), - (int)sqlite3Get4byte( pBt.pPage1.aData, 36 ), "Main freelist: " ); - - /* Check all the tables. - */ - for ( i = 0; (int)i < nRoot && sCheck.mxErr != 0; i++ ) - { - if ( aRoot[i] == 0 ) - continue; + /* + ** This routine does a complete check of the given BTree file. aRoot[] is + ** an array of pages numbers were each page number is the root page of + ** a table. nRoot is the number of entries in aRoot. + ** + ** A read-only or read-write transaction must be opened before calling + ** this function. + ** + ** Write the number of error seen in pnErr. Except for some memory + ** allocation errors, an error message held in memory obtained from + ** malloc is returned if pnErr is non-zero. If pnErr==null then NULL is + ** returned. If a memory allocation error occurs, NULL is returned. + */ + static string sqlite3BtreeIntegrityCheck( + Btree p, /* The btree to be checked */ + int[] aRoot, /* An array of root pages numbers for individual trees */ + int nRoot, /* Number of entries in aRoot[] */ + int mxErr, /* Stop reporting errors after this many */ + ref int pnErr /* Write number of errors seen to this variable */ + ) { + Pgno i; + int nRef; + IntegrityCk sCheck = new IntegrityCk(); + BtShared pBt = p.pBt; + + sqlite3BtreeEnter(p); + Debug.Assert(p.inTrans > TRANS_NONE && pBt.inTransaction > TRANS_NONE); + nRef = sqlite3PagerRefcount(pBt.pPager); + sCheck.pBt = pBt; + sCheck.pPager = pBt.pPager; + sCheck.nPage = btreePagecount(sCheck.pBt); + sCheck.mxErr = mxErr; + sCheck.nErr = 0; + //sCheck.mallocFailed = 0; + pnErr = 0; + if (sCheck.nPage == 0) { + sqlite3BtreeLeave(p); + return ""; + } + sCheck.anRef = sqlite3Malloc(sCheck.anRef, (int)sCheck.nPage + 1); + //if( !sCheck.anRef ){ + // pnErr = 1; + // sqlite3BtreeLeave(p); + // return 0; + //} + // for (i = 0; i <= sCheck.nPage; i++) { sCheck.anRef[i] = 0; } + i = PENDING_BYTE_PAGE(pBt); + if (i <= sCheck.nPage) { + sCheck.anRef[i] = 1; + } + sqlite3StrAccumInit(sCheck.errMsg, null, 1000, 20000); + //sCheck.errMsg.useMalloc = 2; + + /* Check the integrity of the freelist + */ + checkList(sCheck, 1, (int)sqlite3Get4byte(pBt.pPage1.aData, 32), + (int)sqlite3Get4byte(pBt.pPage1.aData, 36), "Main freelist: "); + + /* Check all the tables. + */ + for (i = 0; (int)i < nRoot && sCheck.mxErr != 0; i++) { + if (aRoot[i] == 0) + continue; #if !SQLITE_OMIT_AUTOVACUUM - if ( pBt.autoVacuum && aRoot[i] > 1 ) - { - checkPtrmap( sCheck, (u32)aRoot[i], PTRMAP_ROOTPAGE, 0, "" ); - } + if (pBt.autoVacuum && aRoot[i] > 1) { + checkPtrmap(sCheck, (u32)aRoot[i], PTRMAP_ROOTPAGE, 0, ""); + } #endif - checkTreePage( sCheck, aRoot[i], "List of tree roots: ", ref refNULL, ref refNULL, null, null ); - } + checkTreePage(sCheck, aRoot[i], "List of tree roots: ", ref refNULL, ref refNULL, null, null); + } - /* Make sure every page in the file is referenced - */ - for ( i = 1; i <= sCheck.nPage && sCheck.mxErr != 0; i++ ) - { + /* Make sure every page in the file is referenced + */ + for (i = 1; i <= sCheck.nPage && sCheck.mxErr != 0; i++) { #if SQLITE_OMIT_AUTOVACUUM if( sCheck.anRef[i]==null ){ checkAppendMsg(sCheck, 0, "Page %d is never used", i); } #else - /* If the database supports auto-vacuum, make sure no tables contain -** references to pointer-map pages. -*/ - if ( sCheck.anRef[i] == 0 && - ( PTRMAP_PAGENO( pBt, i ) != i || !pBt.autoVacuum ) ) - { - checkAppendMsg( sCheck, "", "Page %d is never used", i ); - } - if ( sCheck.anRef[i] != 0 && - ( PTRMAP_PAGENO( pBt, i ) == i && pBt.autoVacuum ) ) - { - checkAppendMsg( sCheck, "", "Pointer map page %d is referenced", i ); - } + /* If the database supports auto-vacuum, make sure no tables contain + ** references to pointer-map pages. + */ + if (sCheck.anRef[i] == 0 && + (PTRMAP_PAGENO(pBt, i) != i || !pBt.autoVacuum)) { + checkAppendMsg(sCheck, "", "Page %d is never used", i); + } + if (sCheck.anRef[i] != 0 && + (PTRMAP_PAGENO(pBt, i) == i && pBt.autoVacuum)) { + checkAppendMsg(sCheck, "", "Pointer map page %d is referenced", i); + } #endif - } - - /* Make sure this analysis did not leave any unref() pages. - ** This is an internal consistency check; an integrity check - ** of the integrity check. - */ - if ( NEVER( nRef != sqlite3PagerRefcount( pBt.pPager ) ) ) - { - checkAppendMsg( sCheck, "", - "Outstanding page count goes from %d to %d during this analysis", - nRef, sqlite3PagerRefcount( pBt.pPager ) - ); - } - - /* Clean up and report errors. - */ - sqlite3BtreeLeave( p ); - sCheck.anRef = null;// sqlite3_free( ref sCheck.anRef ); - //if( sCheck.mallocFailed ){ - // sqlite3StrAccumReset(sCheck.errMsg); - // pnErr = sCheck.nErr+1; - // return 0; - //} - pnErr = sCheck.nErr; - if ( sCheck.nErr == 0 ) - sqlite3StrAccumReset( sCheck.errMsg ); - return sqlite3StrAccumFinish( sCheck.errMsg ); -} + } + + /* Make sure this analysis did not leave any unref() pages. + ** This is an internal consistency check; an integrity check + ** of the integrity check. + */ + if (NEVER(nRef != sqlite3PagerRefcount(pBt.pPager))) { + checkAppendMsg(sCheck, "", + "Outstanding page count goes from %d to %d during this analysis", + nRef, sqlite3PagerRefcount(pBt.pPager) + ); + } + + /* Clean up and report errors. + */ + sqlite3BtreeLeave(p); + sCheck.anRef = null;// sqlite3_free( ref sCheck.anRef ); + //if( sCheck.mallocFailed ){ + // sqlite3StrAccumReset(sCheck.errMsg); + // pnErr = sCheck.nErr+1; + // return 0; + //} + pnErr = sCheck.nErr; + if (sCheck.nErr == 0) + sqlite3StrAccumReset(sCheck.errMsg); + return sqlite3StrAccumFinish(sCheck.errMsg); + } #endif //* SQLITE_OMIT_INTEGRITY_CHECK */ -/* -** Return the full pathname of the underlying database file. -** -** The pager filename is invariant as long as the pager is -** open so it is safe to access without the BtShared mutex. -*/ -static string sqlite3BtreeGetFilename( Btree p ) -{ - Debug.Assert( p.pBt.pPager != null ); - return sqlite3PagerFilename( p.pBt.pPager ); -} + /* + ** Return the full pathname of the underlying database file. + ** + ** The pager filename is invariant as long as the pager is + ** open so it is safe to access without the BtShared mutex. + */ + static string sqlite3BtreeGetFilename(Btree p) { + Debug.Assert(p.pBt.pPager != null); + return sqlite3PagerFilename(p.pBt.pPager); + } -/* -** Return the pathname of the journal file for this database. The return -** value of this routine is the same regardless of whether the journal file -** has been created or not. -** -** The pager journal filename is invariant as long as the pager is -** open so it is safe to access without the BtShared mutex. -*/ -static string sqlite3BtreeGetJournalname( Btree p ) -{ - Debug.Assert( p.pBt.pPager != null ); - return sqlite3PagerJournalname( p.pBt.pPager ); -} + /* + ** Return the pathname of the journal file for this database. The return + ** value of this routine is the same regardless of whether the journal file + ** has been created or not. + ** + ** The pager journal filename is invariant as long as the pager is + ** open so it is safe to access without the BtShared mutex. + */ + static string sqlite3BtreeGetJournalname(Btree p) { + Debug.Assert(p.pBt.pPager != null); + return sqlite3PagerJournalname(p.pBt.pPager); + } -/* -** Return non-zero if a transaction is active. -*/ -static bool sqlite3BtreeIsInTrans( Btree p ) -{ - Debug.Assert( p == null || sqlite3_mutex_held( p.db.mutex ) ); - return ( p != null && ( p.inTrans == TRANS_WRITE ) ); -} + /* + ** Return non-zero if a transaction is active. + */ + static bool sqlite3BtreeIsInTrans(Btree p) { + Debug.Assert(p == null || sqlite3_mutex_held(p.db.mutex)); + return (p != null && (p.inTrans == TRANS_WRITE)); + } #if !SQLITE_OMIT_WAL /* @@ -9365,71 +8499,66 @@ static bool sqlite3BtreeIsInTrans( Btree p ) } #endif -/* -** Return non-zero if a read (or write) transaction is active. -*/ -static bool sqlite3BtreeIsInReadTrans( Btree p ) -{ - Debug.Assert( p != null ); - Debug.Assert( sqlite3_mutex_held( p.db.mutex ) ); - return p.inTrans != TRANS_NONE; -} + /* + ** Return non-zero if a read (or write) transaction is active. + */ + static bool sqlite3BtreeIsInReadTrans(Btree p) { + Debug.Assert(p != null); + Debug.Assert(sqlite3_mutex_held(p.db.mutex)); + return p.inTrans != TRANS_NONE; + } -static bool sqlite3BtreeIsInBackup( Btree p ) -{ - Debug.Assert( p != null ); - Debug.Assert( sqlite3_mutex_held( p.db.mutex ) ); - return p.nBackup != 0; -} + static bool sqlite3BtreeIsInBackup(Btree p) { + Debug.Assert(p != null); + Debug.Assert(sqlite3_mutex_held(p.db.mutex)); + return p.nBackup != 0; + } -/* -** This function returns a pointer to a blob of memory associated with -** a single shared-btree. The memory is used by client code for its own -** purposes (for example, to store a high-level schema associated with -** the shared-btree). The btree layer manages reference counting issues. -** -** The first time this is called on a shared-btree, nBytes bytes of memory -** are allocated, zeroed, and returned to the caller. For each subsequent -** call the nBytes parameter is ignored and a pointer to the same blob -** of memory returned. -** -** If the nBytes parameter is 0 and the blob of memory has not yet been -** allocated, a null pointer is returned. If the blob has already been -** allocated, it is returned as normal. -** -** Just before the shared-btree is closed, the function passed as the -** xFree argument when the memory allocation was made is invoked on the -** blob of allocated memory. The xFree function should not call sqlite3_free() -** on the memory, the btree layer does that. -*/ -static Schema sqlite3BtreeSchema( Btree p, int nBytes, dxFreeSchema xFree ) -{ - BtShared pBt = p.pBt; - sqlite3BtreeEnter( p ); - if ( null == pBt.pSchema && nBytes != 0 ) - { - pBt.pSchema = new Schema();//sqlite3DbMallocZero(0, nBytes); - pBt.xFreeSchema = xFree; - } - sqlite3BtreeLeave( p ); - return pBt.pSchema; -} + /* + ** This function returns a pointer to a blob of memory associated with + ** a single shared-btree. The memory is used by client code for its own + ** purposes (for example, to store a high-level schema associated with + ** the shared-btree). The btree layer manages reference counting issues. + ** + ** The first time this is called on a shared-btree, nBytes bytes of memory + ** are allocated, zeroed, and returned to the caller. For each subsequent + ** call the nBytes parameter is ignored and a pointer to the same blob + ** of memory returned. + ** + ** If the nBytes parameter is 0 and the blob of memory has not yet been + ** allocated, a null pointer is returned. If the blob has already been + ** allocated, it is returned as normal. + ** + ** Just before the shared-btree is closed, the function passed as the + ** xFree argument when the memory allocation was made is invoked on the + ** blob of allocated memory. The xFree function should not call sqlite3_free() + ** on the memory, the btree layer does that. + */ + static Schema sqlite3BtreeSchema(Btree p, int nBytes, dxFreeSchema xFree) { + BtShared pBt = p.pBt; + sqlite3BtreeEnter(p); + if (null == pBt.pSchema && nBytes != 0) { + pBt.pSchema = new Schema();//sqlite3DbMallocZero(0, nBytes); + pBt.xFreeSchema = xFree; + } + sqlite3BtreeLeave(p); + return pBt.pSchema; + } -/* -** Return SQLITE_LOCKED_SHAREDCACHE if another user of the same shared -** btree as the argument handle holds an exclusive lock on the -** sqlite_master table. Otherwise SQLITE_OK. -*/ -static int sqlite3BtreeSchemaLocked( Btree p ) -{ - int rc; - Debug.Assert( sqlite3_mutex_held( p.db.mutex ) ); - sqlite3BtreeEnter( p ); - rc = querySharedCacheTableLock( p, MASTER_ROOT, READ_LOCK ); - Debug.Assert( rc == SQLITE_OK || rc == SQLITE_LOCKED_SHAREDCACHE ); - sqlite3BtreeLeave( p ); - return rc; -} + /* + ** Return SQLITE_LOCKED_SHAREDCACHE if another user of the same shared + ** btree as the argument handle holds an exclusive lock on the + ** sqlite_master table. Otherwise SQLITE_OK. + */ + static int sqlite3BtreeSchemaLocked(Btree p) { + int rc; + Debug.Assert(sqlite3_mutex_held(p.db.mutex)); + sqlite3BtreeEnter(p); + rc = querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK); + Debug.Assert(rc == SQLITE_OK || rc == SQLITE_LOCKED_SHAREDCACHE); + sqlite3BtreeLeave(p); + return rc; + } #if !SQLITE_OMIT_SHARED_CACHE @@ -9519,45 +8648,40 @@ static void sqlite3BtreeCacheOverflow(BtCursor pCur){ } #endif -/* -** Set both the "read version" (single byte at byte offset 18) and -** "write version" (single byte at byte offset 19) fields in the database -** header to iVersion. -*/ -static int sqlite3BtreeSetVersion( Btree pBtree, int iVersion ) -{ - BtShared pBt = pBtree.pBt; - int rc; /* Return code */ - - Debug.Assert( pBtree.inTrans == TRANS_NONE ); - Debug.Assert( iVersion == 1 || iVersion == 2 ); - - /* If setting the version fields to 1, do not automatically open the - ** WAL connection, even if the version fields are currently set to 2. - */ - pBt.doNotUseWAL = iVersion == 1; - - rc = sqlite3BtreeBeginTrans( pBtree, 0 ); - if ( rc == SQLITE_OK ) - { - u8[] aData = pBt.pPage1.aData; - if ( aData[18] != (u8)iVersion || aData[19] != (u8)iVersion ) - { - rc = sqlite3BtreeBeginTrans( pBtree, 2 ); - if ( rc == SQLITE_OK ) - { - rc = sqlite3PagerWrite( pBt.pPage1.pDbPage ); - if ( rc == SQLITE_OK ) - { - aData[18] = (u8)iVersion; - aData[19] = (u8)iVersion; - } - } - } - } + /* + ** Set both the "read version" (single byte at byte offset 18) and + ** "write version" (single byte at byte offset 19) fields in the database + ** header to iVersion. + */ + static int sqlite3BtreeSetVersion(Btree pBtree, int iVersion) { + BtShared pBt = pBtree.pBt; + int rc; /* Return code */ + + Debug.Assert(pBtree.inTrans == TRANS_NONE); + Debug.Assert(iVersion == 1 || iVersion == 2); + + /* If setting the version fields to 1, do not automatically open the + ** WAL connection, even if the version fields are currently set to 2. + */ + pBt.doNotUseWAL = iVersion == 1; + + rc = sqlite3BtreeBeginTrans(pBtree, 0); + if (rc == SQLITE_OK) { + u8[] aData = pBt.pPage1.aData; + if (aData[18] != (u8)iVersion || aData[19] != (u8)iVersion) { + rc = sqlite3BtreeBeginTrans(pBtree, 2); + if (rc == SQLITE_OK) { + rc = sqlite3PagerWrite(pBt.pPage1.pDbPage); + if (rc == SQLITE_OK) { + aData[18] = (u8)iVersion; + aData[19] = (u8)iVersion; + } + } + } + } - pBt.doNotUseWAL = false; - return rc; -} - } + pBt.doNotUseWAL = false; + return rc; + } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/build_c.cs b/Src/IronPython.SQLite/c#sqlite/build_c.cs index 0050bf2f0..754334f1c 100644 --- a/Src/IronPython.SQLite/c#sqlite/build_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/build_c.cs @@ -8,8 +8,6 @@ using u16 = System.UInt16; using u32 = System.UInt32; -using Pgno = System.UInt32; - /* ** The yDbMask datatype for the bitmask of all attached databases. */ @@ -18,55 +16,52 @@ using yDbMask = System.Int64; #else // typedef unsigned int yDbMask; -using yDbMask = System.Int32; +using yDbMask = System.Int32; #endif -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 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. - ** - ************************************************************************* - ** This file contains C code routines that are called by the SQLite parser - ** when syntax rules are reduced. The routines in this file handle the - ** following kinds of SQL syntax: - ** - ** CREATE TABLE - ** DROP TABLE - ** CREATE INDEX - ** DROP INDEX - ** creating ID lists - ** BEGIN TRANSACTION - ** COMMIT - ** ROLLBACK - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** This file contains C code routines that are called by the SQLite parser + ** when syntax rules are reduced. The routines in this file handle the + ** following kinds of SQL syntax: + ** + ** CREATE TABLE + ** DROP TABLE + ** CREATE INDEX + ** DROP INDEX + ** creating ID lists + ** BEGIN TRANSACTION + ** COMMIT + ** ROLLBACK + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" - /* - ** This routine is called when a new SQL statement is beginning to - ** be parsed. Initialize the pParse structure as needed. - */ - static void sqlite3BeginParse( Parse pParse, int explainFlag ) - { - pParse.explain = (byte)explainFlag; - pParse.nVar = 0; - } + /* + ** This routine is called when a new SQL statement is beginning to + ** be parsed. Initialize the pParse structure as needed. + */ + static void sqlite3BeginParse(Parse pParse, int explainFlag) { + pParse.explain = (byte)explainFlag; + pParse.nVar = 0; + } #if !SQLITE_OMIT_SHARED_CACHE /* @@ -154,496 +149,450 @@ static void codeTableLocks( Parse pParse ) } } #else - // #define codeTableLocks(x) - static void codeTableLocks( Parse pParse ) - { - } + // #define codeTableLocks(x) + static void codeTableLocks(Parse pParse) { + } #endif - /* -** This routine is called after a single SQL statement has been -** parsed and a VDBE program to execute that statement has been -** prepared. This routine puts the finishing touches on the -** VDBE program and resets the pParse structure for the next -** parse. -** -** Note that if an error occurred, it might be the case that -** no VDBE code was generated. -*/ - static void sqlite3FinishCoding( Parse pParse ) - { - sqlite3 db; - Vdbe v; - - db = pParse.db; - // if ( db.mallocFailed != 0 ) return; - if ( pParse.nested != 0 ) - return; - if ( pParse.nErr != 0 ) - return; - - /* Begin by generating some termination code at the end of the - ** vdbe program - */ - v = sqlite3GetVdbe( pParse ); - Debug.Assert( 0 == pParse.isMultiWrite -#if SQLITE_DEBUG - || sqlite3VdbeAssertMayAbort( v, pParse.mayAbort ) != 0 + /* + ** This routine is called after a single SQL statement has been + ** parsed and a VDBE program to execute that statement has been + ** prepared. This routine puts the finishing touches on the + ** VDBE program and resets the pParse structure for the next + ** parse. + ** + ** Note that if an error occurred, it might be the case that + ** no VDBE code was generated. + */ + static void sqlite3FinishCoding(Parse pParse) { + sqlite3 db; + Vdbe v; + + db = pParse.db; + // if ( db.mallocFailed != 0 ) return; + if (pParse.nested != 0) + return; + if (pParse.nErr != 0) + return; + + /* Begin by generating some termination code at the end of the + ** vdbe program + */ + v = sqlite3GetVdbe(pParse); + Debug.Assert(0 == pParse.isMultiWrite +#if SQLITE_DEBUG + || sqlite3VdbeAssertMayAbort(v, pParse.mayAbort) != 0 #endif - ); - if ( v != null ) - { - sqlite3VdbeAddOp0( v, OP_Halt ); - - /* The cookie mask contains one bit for each database file open. - ** (Bit 0 is for main, bit 1 is for temp, and so forth.) Bits are - ** set for each database that is used. Generate code to start a - ** transaction on each used database and to verify the schema cookie - ** on each used database. - */ - if ( pParse.cookieGoto > 0 ) - { - u32 mask; - int iDb; - sqlite3VdbeJumpHere( v, pParse.cookieGoto - 1 ); - for ( iDb = 0, mask = 1; iDb < db.nDb; mask <<= 1, iDb++ ) - { - if ( ( mask & pParse.cookieMask ) == 0 ) - continue; - sqlite3VdbeUsesBtree( v, iDb ); - sqlite3VdbeAddOp2( v, OP_Transaction, iDb, ( mask & pParse.writeMask ) != 0 ); - if ( db.init.busy == 0 ) - { - Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); - sqlite3VdbeAddOp3( v, OP_VerifyCookie, - iDb, pParse.cookieValue[iDb], - (int)db.aDb[iDb].pSchema.iGeneration ); - } - } + ); + if (v != null) { + sqlite3VdbeAddOp0(v, OP_Halt); + + /* The cookie mask contains one bit for each database file open. + ** (Bit 0 is for main, bit 1 is for temp, and so forth.) Bits are + ** set for each database that is used. Generate code to start a + ** transaction on each used database and to verify the schema cookie + ** on each used database. + */ + if (pParse.cookieGoto > 0) { + u32 mask; + int iDb; + sqlite3VdbeJumpHere(v, pParse.cookieGoto - 1); + for (iDb = 0, mask = 1; iDb < db.nDb; mask <<= 1, iDb++) { + if ((mask & pParse.cookieMask) == 0) + continue; + sqlite3VdbeUsesBtree(v, iDb); + sqlite3VdbeAddOp2(v, OP_Transaction, iDb, (mask & pParse.writeMask) != 0); + if (db.init.busy == 0) { + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + sqlite3VdbeAddOp3(v, OP_VerifyCookie, + iDb, pParse.cookieValue[iDb], + (int)db.aDb[iDb].pSchema.iGeneration); + } + } #if !SQLITE_OMIT_VIRTUALTABLE - { - int i; - for ( i = 0; i < pParse.nVtabLock; i++ ) - { - VTable vtab = sqlite3GetVTable( db, pParse.apVtabLock[i] ); - sqlite3VdbeAddOp4( v, OP_VBegin, 0, 0, 0, vtab, P4_VTAB ); - } - pParse.nVtabLock = 0; - } + { + int i; + for (i = 0; i < pParse.nVtabLock; i++) { + VTable vtab = sqlite3GetVTable(db, pParse.apVtabLock[i]); + sqlite3VdbeAddOp4(v, OP_VBegin, 0, 0, 0, vtab, P4_VTAB); + } + pParse.nVtabLock = 0; + } #endif - /* Once all the cookies have been verified and transactions opened, -** obtain the required table-locks. This is a no-op unless the -** shared-cache feature is enabled. -*/ - codeTableLocks( pParse ); - - /* Initialize any AUTOINCREMENT data structures required. + /* Once all the cookies have been verified and transactions opened, + ** obtain the required table-locks. This is a no-op unless the + ** shared-cache feature is enabled. */ - sqlite3AutoincrementBegin( pParse ); + codeTableLocks(pParse); - /* Finally, jump back to the beginning of the executable code. */ - sqlite3VdbeAddOp2( v, OP_Goto, 0, pParse.cookieGoto ); - } - } + /* Initialize any AUTOINCREMENT data structures required. + */ + sqlite3AutoincrementBegin(pParse); + /* Finally, jump back to the beginning of the executable code. */ + sqlite3VdbeAddOp2(v, OP_Goto, 0, pParse.cookieGoto); + } + } - /* Get the VDBE program ready for execution - */ - if ( v != null && ALWAYS( pParse.nErr == 0 ) /* && 0 == db.mallocFailed */ ) - { -#if SQLITE_DEBUG && !SQLITE_WINRT - TextWriter trace = ( db.flags & SQLITE_VdbeTrace ) != 0 ? Console.Out : null; - sqlite3VdbeTrace( v, trace ); -#endif - Debug.Assert( pParse.iCacheLevel == 0 ); /* Disables and re-enables match */ - /* A minimum of one cursor is required if autoincrement is used - * See ticket [a696379c1f08866] */ - if ( pParse.pAinc != null && pParse.nTab == 0 ) - pParse.nTab = 1; - sqlite3VdbeMakeReady( v, pParse); - pParse.rc = SQLITE_DONE; - pParse.colNamesSet = 0; - } - else - { - pParse.rc = SQLITE_ERROR; - } - pParse.nTab = 0; - pParse.nMem = 0; - pParse.nSet = 0; - pParse.nVar = 0; - pParse.cookieMask = 0; - pParse.cookieGoto = 0; - } - /* - ** Run the parser and code generator recursively in order to generate - ** code for the SQL statement given onto the end of the pParse context - ** currently under construction. When the parser is run recursively - ** this way, the final OP_Halt is not appended and other initialization - ** and finalization steps are omitted because those are handling by the - ** outermost parser. - ** - ** Not everything is nestable. This facility is designed to permit - ** INSERT, UPDATE, and DELETE operations against SQLITE_MASTER. Use - ** care if you decide to try to use this routine for some other purposes. - */ - static void sqlite3NestedParse( Parse pParse, string zFormat, params object[] ap ) - { - string zSql; // string zSql; - string zErrMsg = "";// char* zErrMsg = 0; - sqlite3 db = pParse.db; - - //# define SAVE_SZ (Parse.Length - offsetof(Parse,nVar)) - // char saveBuf[SAVE_SZ]; - - if ( pParse.nErr != 0 ) - return; - Debug.Assert( pParse.nested < 10 ); /* Nesting should only be of limited depth */ - // va_list ap; - lock ( lock_va_list ) - { - va_start( ap, zFormat ); - zSql = sqlite3VMPrintf( db, zFormat, ap ); - va_end( ref ap ); - } - //if( zSql=="" ){ - // return; /* A malloc must have failed */ - //} - lock ( nestingLock ) - { - pParse.nested++; - pParse.SaveMembers(); // memcpy(saveBuf, pParse.nVar, SAVE_SZ); - pParse.ResetMembers(); // memset(pParse.nVar, 0, SAVE_SZ); - sqlite3RunParser( pParse, zSql, ref zErrMsg ); - sqlite3DbFree( db, ref zErrMsg ); - sqlite3DbFree( db, ref zSql ); - pParse.RestoreMembers(); // memcpy(pParse.nVar, saveBuf, SAVE_SZ); - pParse.nested--; - } - } - static Object nestingLock = new Object(); + /* Get the VDBE program ready for execution + */ + if (v != null && ALWAYS(pParse.nErr == 0) /* && 0 == db.mallocFailed */ ) { +#if SQLITE_DEBUG && !SQLITE_WINRT + TextWriter trace = (db.flags & SQLITE_VdbeTrace) != 0 ? Console.Out : null; + sqlite3VdbeTrace(v, trace); +#endif + Debug.Assert(pParse.iCacheLevel == 0); /* Disables and re-enables match */ + /* A minimum of one cursor is required if autoincrement is used + * See ticket [a696379c1f08866] */ + if (pParse.pAinc != null && pParse.nTab == 0) + pParse.nTab = 1; + sqlite3VdbeMakeReady(v, pParse); + pParse.rc = SQLITE_DONE; + pParse.colNamesSet = 0; + } else { + pParse.rc = SQLITE_ERROR; + } + pParse.nTab = 0; + pParse.nMem = 0; + pParse.nSet = 0; + pParse.nVar = 0; + pParse.cookieMask = 0; + pParse.cookieGoto = 0; + } - /* - ** Locate the in-memory structure that describes a particular database - ** table given the name of that table and (optionally) the name of the - ** database containing the table. Return NULL if not found. - ** - ** If zDatabase is 0, all databases are searched for the table and the - ** first matching table is returned. (No checking for duplicate table - ** names is done.) The search order is TEMP first, then MAIN, then any - ** auxiliary databases added using the ATTACH command. - ** - ** See also sqlite3LocateTable(). - */ - static Table sqlite3FindTable( sqlite3 db, string zName, string zDatabase ) - { - Table p = null; - int i; - int nName; - Debug.Assert( zName != null ); - nName = sqlite3Strlen30( zName ); - /* All mutexes are required for schema access. Make sure we hold them. */ - Debug.Assert( zDatabase != null || sqlite3BtreeHoldsAllMutexes( db ) ); - for ( i = OMIT_TEMPDB; i < db.nDb; i++ ) - { - int j = ( i < 2 ) ? i ^ 1 : i; /* Search TEMP before MAIN */ - if ( zDatabase != null && !zDatabase.Equals( db.aDb[j].zName, StringComparison.OrdinalIgnoreCase ) ) - continue; - Debug.Assert( sqlite3SchemaMutexHeld( db, j, null ) ); - p = sqlite3HashFind( db.aDb[j].pSchema.tblHash, zName, nName, (Table)null ); - if ( p != null ) - break; - } - return p; - } + /* + ** Run the parser and code generator recursively in order to generate + ** code for the SQL statement given onto the end of the pParse context + ** currently under construction. When the parser is run recursively + ** this way, the final OP_Halt is not appended and other initialization + ** and finalization steps are omitted because those are handling by the + ** outermost parser. + ** + ** Not everything is nestable. This facility is designed to permit + ** INSERT, UPDATE, and DELETE operations against SQLITE_MASTER. Use + ** care if you decide to try to use this routine for some other purposes. + */ + static void sqlite3NestedParse(Parse pParse, string zFormat, params object[] ap) { + string zSql; // string zSql; + string zErrMsg = "";// char* zErrMsg = 0; + sqlite3 db = pParse.db; + + //# define SAVE_SZ (Parse.Length - offsetof(Parse,nVar)) + // char saveBuf[SAVE_SZ]; + + if (pParse.nErr != 0) + return; + Debug.Assert(pParse.nested < 10); /* Nesting should only be of limited depth */ + // va_list ap; + lock (lock_va_list) { + va_start(ap, zFormat); + zSql = sqlite3VMPrintf(db, zFormat, ap); + va_end(ref ap); + } + //if( zSql=="" ){ + // return; /* A malloc must have failed */ + //} + lock (nestingLock) { + pParse.nested++; + pParse.SaveMembers(); // memcpy(saveBuf, pParse.nVar, SAVE_SZ); + pParse.ResetMembers(); // memset(pParse.nVar, 0, SAVE_SZ); + sqlite3RunParser(pParse, zSql, ref zErrMsg); + sqlite3DbFree(db, ref zErrMsg); + sqlite3DbFree(db, ref zSql); + pParse.RestoreMembers(); // memcpy(pParse.nVar, saveBuf, SAVE_SZ); + pParse.nested--; + } + } + static Object nestingLock = new Object(); - /* - ** Locate the in-memory structure that describes a particular database - ** table given the name of that table and (optionally) the name of the - ** database containing the table. Return NULL if not found. Also leave an - ** error message in pParse.zErrMsg. - ** - ** The difference between this routine and sqlite3FindTable() is that this - ** routine leaves an error message in pParse.zErrMsg where - ** sqlite3FindTable() does not. - */ - static Table sqlite3LocateTable( - Parse pParse, /* context in which to report errors */ - int isView, /* True if looking for a VIEW rather than a TABLE */ - string zName, /* Name of the table we are looking for */ - string zDbase /* Name of the database. Might be NULL */ - ) - { - Table p; - - /* Read the database schema. If an error occurs, leave an error message - ** and code in pParse and return NULL. */ - if ( SQLITE_OK != sqlite3ReadSchema( pParse ) ) - { - return null; - } - - p = sqlite3FindTable( pParse.db, zName, zDbase ); - if ( p == null ) - { - string zMsg = isView != 0 ? "no such view" : "no such table"; - if ( zDbase != null ) - { - sqlite3ErrorMsg( pParse, "%s: %s.%s", zMsg, zDbase, zName ); + /* + ** Locate the in-memory structure that describes a particular database + ** table given the name of that table and (optionally) the name of the + ** database containing the table. Return NULL if not found. + ** + ** If zDatabase is 0, all databases are searched for the table and the + ** first matching table is returned. (No checking for duplicate table + ** names is done.) The search order is TEMP first, then MAIN, then any + ** auxiliary databases added using the ATTACH command. + ** + ** See also sqlite3LocateTable(). + */ + static Table sqlite3FindTable(sqlite3 db, string zName, string zDatabase) { + Table p = null; + int i; + int nName; + Debug.Assert(zName != null); + nName = sqlite3Strlen30(zName); + /* All mutexes are required for schema access. Make sure we hold them. */ + Debug.Assert(zDatabase != null || sqlite3BtreeHoldsAllMutexes(db)); + for (i = OMIT_TEMPDB; i < db.nDb; i++) { + int j = (i < 2) ? i ^ 1 : i; /* Search TEMP before MAIN */ + if (zDatabase != null && !zDatabase.Equals(db.aDb[j].zName, StringComparison.OrdinalIgnoreCase)) + continue; + Debug.Assert(sqlite3SchemaMutexHeld(db, j, null)); + p = sqlite3HashFind(db.aDb[j].pSchema.tblHash, zName, nName, (Table)null); + if (p != null) + break; + } + return p; } - else - { - sqlite3ErrorMsg( pParse, "%s: %s", zMsg, zName ); + + /* + ** Locate the in-memory structure that describes a particular database + ** table given the name of that table and (optionally) the name of the + ** database containing the table. Return NULL if not found. Also leave an + ** error message in pParse.zErrMsg. + ** + ** The difference between this routine and sqlite3FindTable() is that this + ** routine leaves an error message in pParse.zErrMsg where + ** sqlite3FindTable() does not. + */ + static Table sqlite3LocateTable( + Parse pParse, /* context in which to report errors */ + int isView, /* True if looking for a VIEW rather than a TABLE */ + string zName, /* Name of the table we are looking for */ + string zDbase /* Name of the database. Might be NULL */ + ) { + Table p; + + /* Read the database schema. If an error occurs, leave an error message + ** and code in pParse and return NULL. */ + if (SQLITE_OK != sqlite3ReadSchema(pParse)) { + return null; + } + + p = sqlite3FindTable(pParse.db, zName, zDbase); + if (p == null) { + string zMsg = isView != 0 ? "no such view" : "no such table"; + if (zDbase != null) { + sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName); + } else { + sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName); + } + pParse.checkSchema = 1; + } + return p; } - pParse.checkSchema = 1; - } - return p; - } - /* - ** Locate the in-memory structure that describes - ** a particular index given the name of that index - ** and the name of the database that contains the index. - ** Return NULL if not found. - ** - ** If zDatabase is 0, all databases are searched for the - ** table and the first matching index is returned. (No checking - ** for duplicate index names is done.) The search order is - ** TEMP first, then MAIN, then any auxiliary databases added - ** using the ATTACH command. - */ - static Index sqlite3FindIndex( sqlite3 db, string zName, string zDb ) - { - Index p = null; - int i; - int nName = sqlite3Strlen30( zName ); - /* All mutexes are required for schema access. Make sure we hold them. */ - Debug.Assert( zDb != null || sqlite3BtreeHoldsAllMutexes( db ) ); - for ( i = OMIT_TEMPDB; i < db.nDb; i++ ) - { - int j = ( i < 2 ) ? i ^ 1 : i; /* Search TEMP before MAIN */ - Schema pSchema = db.aDb[j].pSchema; - Debug.Assert( pSchema != null ); - if ( zDb != null && !zDb.Equals( db.aDb[j].zName, StringComparison.OrdinalIgnoreCase ) ) - continue; - Debug.Assert( sqlite3SchemaMutexHeld( db, j, null ) ); - p = sqlite3HashFind( pSchema.idxHash, zName, nName, (Index)null ); - if ( p != null ) - break; - } - return p; - } + /* + ** Locate the in-memory structure that describes + ** a particular index given the name of that index + ** and the name of the database that contains the index. + ** Return NULL if not found. + ** + ** If zDatabase is 0, all databases are searched for the + ** table and the first matching index is returned. (No checking + ** for duplicate index names is done.) The search order is + ** TEMP first, then MAIN, then any auxiliary databases added + ** using the ATTACH command. + */ + static Index sqlite3FindIndex(sqlite3 db, string zName, string zDb) { + Index p = null; + int i; + int nName = sqlite3Strlen30(zName); + /* All mutexes are required for schema access. Make sure we hold them. */ + Debug.Assert(zDb != null || sqlite3BtreeHoldsAllMutexes(db)); + for (i = OMIT_TEMPDB; i < db.nDb; i++) { + int j = (i < 2) ? i ^ 1 : i; /* Search TEMP before MAIN */ + Schema pSchema = db.aDb[j].pSchema; + Debug.Assert(pSchema != null); + if (zDb != null && !zDb.Equals(db.aDb[j].zName, StringComparison.OrdinalIgnoreCase)) + continue; + Debug.Assert(sqlite3SchemaMutexHeld(db, j, null)); + p = sqlite3HashFind(pSchema.idxHash, zName, nName, (Index)null); + if (p != null) + break; + } + return p; + } - /* - ** Reclaim the memory used by an index - */ - static void freeIndex( sqlite3 db, ref Index p ) - { + /* + ** Reclaim the memory used by an index + */ + static void freeIndex(sqlite3 db, ref Index p) { #if !SQLITE_OMIT_ANALYZE - sqlite3DeleteIndexSamples( db, p ); + sqlite3DeleteIndexSamples(db, p); #endif - sqlite3DbFree( db, ref p.zColAff ); - sqlite3DbFree( db, ref p ); - } - - /* - ** For the index called zIdxName which is found in the database iDb, - ** unlike that index from its Table then remove the index from - ** the index hash table and free all memory structures associated - ** with the index. - */ - static void sqlite3UnlinkAndDeleteIndex( sqlite3 db, int iDb, string zIdxName ) - { - Index pIndex; - int len; - Hash pHash; - - Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); - pHash = db.aDb[iDb].pSchema.idxHash; - - len = sqlite3Strlen30( zIdxName ); - pIndex = sqlite3HashInsert( ref pHash, zIdxName, len, (Index)null ); - if ( ALWAYS(pIndex) ) - { - if ( pIndex.pTable.pIndex == pIndex ) - { - pIndex.pTable.pIndex = pIndex.pNext; + sqlite3DbFree(db, ref p.zColAff); + sqlite3DbFree(db, ref p); } - else - { - Index p; - /* Justification of ALWAYS(); The index must be on the list of - ** indices. */ - p = pIndex.pTable.pIndex; - while ( ALWAYS( p != null ) && p.pNext != pIndex ) - { - p = p.pNext; - } - if ( ALWAYS( p != null && p.pNext == pIndex ) ) - { - p.pNext = pIndex.pNext; - } - } - freeIndex( db, ref pIndex ); - } - db.flags |= SQLITE_InternChanges; - } - /* - ** Erase all schema information from the in-memory hash tables of - ** a single database. This routine is called to reclaim memory - ** before the database closes. It is also called during a rollback - ** if there were schema changes during the transaction or if a - ** schema-cookie mismatch occurs. - ** - ** If iDb<0 then reset the internal schema tables for all database - ** files. If iDb>=0 then reset the internal schema for only the - ** single file indicated. - */ - static void sqlite3ResetInternalSchema( sqlite3 db, int iDb ) - { - int i, j; - Debug.Assert( iDb < db.nDb ); - - if ( iDb >= 0 ) - { - /* Case 1: Reset the single schema identified by iDb */ - Db pDb = db.aDb[iDb]; - Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); - Debug.Assert( pDb.pSchema != null); - sqlite3SchemaClear( pDb.pSchema ); - - /* If any database other than TEMP is reset, then also reset TEMP - ** since TEMP might be holding triggers that reference tables in the - ** other database. + /* + ** For the index called zIdxName which is found in the database iDb, + ** unlike that index from its Table then remove the index from + ** the index hash table and free all memory structures associated + ** with the index. */ - if ( iDb != 1 ) - { - pDb = db.aDb[1]; - Debug.Assert( pDb.pSchema != null ); - sqlite3SchemaClear( pDb.pSchema ); - } - return; - } - /* Case 2 (from here to the end): Reset all schemas for all attached - ** databases. */ - Debug.Assert( iDb < 0 ); - sqlite3BtreeEnterAll( db ); - for ( i = 0; i < db.nDb; i++ ) - { - Db pDb = db.aDb[i]; - if ( pDb.pSchema != null ) - { - sqlite3SchemaClear( pDb.pSchema ); - } - } - db.flags &= ~SQLITE_InternChanges; - sqlite3VtabUnlockList( db ); - sqlite3BtreeLeaveAll( db ); - /* If one or more of the auxiliary database files has been closed, - ** then remove them from the auxiliary database list. We take the - ** opportunity to do this here since we have just deleted all of the - ** schema hash tables and therefore do not have to make any changes - ** to any of those tables. - */ - for ( i = j = 2; i < db.nDb; i++ ) - { - Db pDb = db.aDb[i]; - if ( pDb.pBt == null ) - { - sqlite3DbFree( db, ref pDb.zName ); - continue; + static void sqlite3UnlinkAndDeleteIndex(sqlite3 db, int iDb, string zIdxName) { + Index pIndex; + int len; + Hash pHash; + + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + pHash = db.aDb[iDb].pSchema.idxHash; + + len = sqlite3Strlen30(zIdxName); + pIndex = sqlite3HashInsert(ref pHash, zIdxName, len, (Index)null); + if (ALWAYS(pIndex)) { + if (pIndex.pTable.pIndex == pIndex) { + pIndex.pTable.pIndex = pIndex.pNext; + } else { + Index p; + /* Justification of ALWAYS(); The index must be on the list of + ** indices. */ + p = pIndex.pTable.pIndex; + while (ALWAYS(p != null) && p.pNext != pIndex) { + p = p.pNext; + } + if (ALWAYS(p != null && p.pNext == pIndex)) { + p.pNext = pIndex.pNext; + } + } + freeIndex(db, ref pIndex); + } + db.flags |= SQLITE_InternChanges; } - if ( j < i ) - { - db.aDb[j] = db.aDb[i]; + + /* + ** Erase all schema information from the in-memory hash tables of + ** a single database. This routine is called to reclaim memory + ** before the database closes. It is also called during a rollback + ** if there were schema changes during the transaction or if a + ** schema-cookie mismatch occurs. + ** + ** If iDb<0 then reset the internal schema tables for all database + ** files. If iDb>=0 then reset the internal schema for only the + ** single file indicated. + */ + static void sqlite3ResetInternalSchema(sqlite3 db, int iDb) { + int i, j; + Debug.Assert(iDb < db.nDb); + + if (iDb >= 0) { + /* Case 1: Reset the single schema identified by iDb */ + Db pDb = db.aDb[iDb]; + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + Debug.Assert(pDb.pSchema != null); + sqlite3SchemaClear(pDb.pSchema); + + /* If any database other than TEMP is reset, then also reset TEMP + ** since TEMP might be holding triggers that reference tables in the + ** other database. + */ + if (iDb != 1) { + pDb = db.aDb[1]; + Debug.Assert(pDb.pSchema != null); + sqlite3SchemaClear(pDb.pSchema); + } + return; + } + /* Case 2 (from here to the end): Reset all schemas for all attached + ** databases. */ + Debug.Assert(iDb < 0); + sqlite3BtreeEnterAll(db); + for (i = 0; i < db.nDb; i++) { + Db pDb = db.aDb[i]; + if (pDb.pSchema != null) { + sqlite3SchemaClear(pDb.pSchema); + } + } + db.flags &= ~SQLITE_InternChanges; + sqlite3VtabUnlockList(db); + sqlite3BtreeLeaveAll(db); + /* If one or more of the auxiliary database files has been closed, + ** then remove them from the auxiliary database list. We take the + ** opportunity to do this here since we have just deleted all of the + ** schema hash tables and therefore do not have to make any changes + ** to any of those tables. + */ + for (i = j = 2; i < db.nDb; i++) { + Db pDb = db.aDb[i]; + if (pDb.pBt == null) { + sqlite3DbFree(db, ref pDb.zName); + continue; + } + if (j < i) { + db.aDb[j] = db.aDb[i]; + } + j++; + } + if (db.nDb != j) + db.aDb[j] = new Db();//memset(db.aDb[j], 0, (db.nDb-j)*sizeof(db.aDb[j])); + db.nDb = j; + if (db.nDb <= 2 && db.aDb != db.aDbStatic) { + Array.Copy(db.aDb, db.aDbStatic, 2);// memcpy(db.aDbStatic, db.aDb, 2*sizeof(db.aDb[0])); + //sqlite3DbFree( db, ref db.aDb ); + //db.aDb = db.aDbStatic; + } } - j++; - } - if ( db.nDb != j ) - db.aDb[j] = new Db();//memset(db.aDb[j], 0, (db.nDb-j)*sizeof(db.aDb[j])); - db.nDb = j; - if ( db.nDb <= 2 && db.aDb != db.aDbStatic ) - { - Array.Copy( db.aDb, db.aDbStatic, 2 );// memcpy(db.aDbStatic, db.aDb, 2*sizeof(db.aDb[0])); - //sqlite3DbFree( db, ref db.aDb ); - //db.aDb = db.aDbStatic; - } - } - /* - ** This routine is called when a commit occurs. - */ - static void sqlite3CommitInternalChanges( sqlite3 db ) - { - db.flags &= ~SQLITE_InternChanges; - } + /* + ** This routine is called when a commit occurs. + */ + static void sqlite3CommitInternalChanges(sqlite3 db) { + db.flags &= ~SQLITE_InternChanges; + } - /* - ** Delete memory allocated for the column names of a table or view (the - ** Table.aCol[] array). - */ - static void sqliteDeleteColumnNames( sqlite3 db, Table pTable ) - { - int i; - Column pCol; - Debug.Assert( pTable != null ); - for ( i = 0; i < pTable.nCol; i++ ) - { - pCol = pTable.aCol[i]; - if ( pCol != null ) - { - sqlite3DbFree( db, ref pCol.zName ); - sqlite3ExprDelete( db, ref pCol.pDflt ); - sqlite3DbFree( db, ref pCol.zDflt ); - sqlite3DbFree( db, ref pCol.zType ); - sqlite3DbFree( db, ref pCol.zColl ); + /* + ** Delete memory allocated for the column names of a table or view (the + ** Table.aCol[] array). + */ + static void sqliteDeleteColumnNames(sqlite3 db, Table pTable) { + int i; + Column pCol; + Debug.Assert(pTable != null); + for (i = 0; i < pTable.nCol; i++) { + pCol = pTable.aCol[i]; + if (pCol != null) { + sqlite3DbFree(db, ref pCol.zName); + sqlite3ExprDelete(db, ref pCol.pDflt); + sqlite3DbFree(db, ref pCol.zDflt); + sqlite3DbFree(db, ref pCol.zType); + sqlite3DbFree(db, ref pCol.zColl); + } + } } - } - } - /* - ** Remove the memory data structures associated with the given - ** Table. No changes are made to disk by this routine. - ** - ** This routine just deletes the data structure. It does not unlink - ** the table data structure from the hash table. But it does destroy - ** memory structures of the indices and foreign keys associated with - ** the table. - */ - static void sqlite3DeleteTable( sqlite3 db, ref Table pTable ) - { - Index pIndex; - Index pNext; - - Debug.Assert( null == pTable || pTable.nRef > 0 ); - - /* Do not delete the table until the reference count reaches zero. */ - if ( null == pTable ) - return; - if ( (// ( !db || db->pnBytesFreed == 0 ) && - ( --pTable.nRef ) > 0 ) ) - return; - - /* Delete all indices associated with this table. */ - for ( pIndex = pTable.pIndex; pIndex != null; pIndex = pNext ) - { - pNext = pIndex.pNext; - Debug.Assert( pIndex.pSchema == pTable.pSchema ); - //if( null==db || db.pnBytesFreed==0 ){ - string zName = pIndex.zName; - // + /* + ** Remove the memory data structures associated with the given + ** Table. No changes are made to disk by this routine. + ** + ** This routine just deletes the data structure. It does not unlink + ** the table data structure from the hash table. But it does destroy + ** memory structures of the indices and foreign keys associated with + ** the table. + */ + static void sqlite3DeleteTable(sqlite3 db, ref Table pTable) { + Index pIndex; + Index pNext; + + Debug.Assert(null == pTable || pTable.nRef > 0); + + /* Do not delete the table until the reference count reaches zero. */ + if (null == pTable) + return; + if ((// ( !db || db->pnBytesFreed == 0 ) && + (--pTable.nRef) > 0)) + return; + + /* Delete all indices associated with this table. */ + for (pIndex = pTable.pIndex; pIndex != null; pIndex = pNext) { + pNext = pIndex.pNext; + Debug.Assert(pIndex.pSchema == pTable.pSchema); + //if( null==db || db.pnBytesFreed==0 ){ + string zName = pIndex.zName; + // #if !NDEBUG || SQLITE_COVERAGE_TEST - // TESTONLY ( Index pOld = ) sqlite3HashInsert( - //ref pIndex.pSchema.idxHash, zName, sqlite3Strlen30(zName), 0 - // ); - Index pOld = sqlite3HashInsert( - ref pIndex.pSchema.idxHash, zName, sqlite3Strlen30( zName ), (Index)null - ); - Debug.Assert( db == null || sqlite3SchemaMutexHeld( db, 0, pIndex.pSchema ) ); - Debug.Assert( pOld == pIndex || pOld == null ); + // TESTONLY ( Index pOld = ) sqlite3HashInsert( + //ref pIndex.pSchema.idxHash, zName, sqlite3Strlen30(zName), 0 + // ); + Index pOld = sqlite3HashInsert( + ref pIndex.pSchema.idxHash, zName, sqlite3Strlen30(zName), (Index)null + ); + Debug.Assert(db == null || sqlite3SchemaMutexHeld(db, 0, pIndex.pSchema)); + Debug.Assert(pOld == pIndex || pOld == null); #else // TESTONLY ( Index pOld = ) sqlite3HashInsert( //ref pIndex.pSchema.idxHash, zName, sqlite3Strlen30(zName), 0 @@ -652,280 +601,257 @@ static void sqlite3DeleteTable( sqlite3 db, ref Table pTable ) ref pIndex.pSchema.idxHash, zName, sqlite3Strlen30(zName),(Index)null ); #endif - //} - freeIndex( db, ref pIndex ); - } + //} + freeIndex(db, ref pIndex); + } - /* Delete any foreign keys attached to this table. */ - sqlite3FkDelete( db, pTable ); + /* Delete any foreign keys attached to this table. */ + sqlite3FkDelete(db, pTable); - /* Delete the Table structure itself. -*/ - sqliteDeleteColumnNames( db, pTable ); - sqlite3DbFree( db, ref pTable.zName ); - sqlite3DbFree( db, ref pTable.zColAff ); - sqlite3SelectDelete( db, ref pTable.pSelect ); + /* Delete the Table structure itself. + */ + sqliteDeleteColumnNames(db, pTable); + sqlite3DbFree(db, ref pTable.zName); + sqlite3DbFree(db, ref pTable.zColAff); + sqlite3SelectDelete(db, ref pTable.pSelect); #if !SQLITE_OMIT_CHECK - sqlite3ExprDelete( db, ref pTable.pCheck ); + sqlite3ExprDelete(db, ref pTable.pCheck); #endif #if !SQLITE_OMIT_VIRTUALTABLE - sqlite3VtabClear(db, pTable); + sqlite3VtabClear(db, pTable); #endif - pTable = null;// sqlite3DbFree( db, ref pTable ); - } - - /* - ** Unlink the given table from the hash tables and the delete the - ** table structure with all its indices and foreign keys. - */ - static void sqlite3UnlinkAndDeleteTable( sqlite3 db, int iDb, string zTabName ) - { - Table p; - Db pDb; - - Debug.Assert( db != null ); - Debug.Assert( iDb >= 0 && iDb < db.nDb ); - Debug.Assert( zTabName != null ); - Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); - testcase( zTabName.Length == 0 ); /* Zero-length table names are allowed */ - pDb = db.aDb[iDb]; - p = sqlite3HashInsert( ref pDb.pSchema.tblHash, zTabName, - sqlite3Strlen30( zTabName ), (Table)null ); - sqlite3DeleteTable( db, ref p ); - db.flags |= SQLITE_InternChanges; - } + pTable = null;// sqlite3DbFree( db, ref pTable ); + } - /* - ** Given a token, return a string that consists of the text of that - ** token. Space to hold the returned string - ** is obtained from sqliteMalloc() and must be freed by the calling - ** function. - ** - ** Any quotation marks (ex: "name", 'name', [name], or `name`) that - ** surround the body of the token are removed. - ** - ** Tokens are often just pointers into the original SQL text and so - ** are not \000 terminated and are not persistent. The returned string - ** is \000 terminated and is persistent. - */ - static string sqlite3NameFromToken( sqlite3 db, Token pName ) - { - string zName; - if ( pName != null && pName.z != null ) - { - zName = pName.z.Substring( 0, pName.n );//sqlite3DbStrNDup(db, (char)pName.z, pName.n); - sqlite3Dequote( ref zName ); - } - else - { - return null; - } - return zName; - } + /* + ** Unlink the given table from the hash tables and the delete the + ** table structure with all its indices and foreign keys. + */ + static void sqlite3UnlinkAndDeleteTable(sqlite3 db, int iDb, string zTabName) { + Table p; + Db pDb; + + Debug.Assert(db != null); + Debug.Assert(iDb >= 0 && iDb < db.nDb); + Debug.Assert(zTabName != null); + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + testcase(zTabName.Length == 0); /* Zero-length table names are allowed */ + pDb = db.aDb[iDb]; + p = sqlite3HashInsert(ref pDb.pSchema.tblHash, zTabName, + sqlite3Strlen30(zTabName), (Table)null); + sqlite3DeleteTable(db, ref p); + db.flags |= SQLITE_InternChanges; + } - /* - ** Open the sqlite_master table stored in database number iDb for - ** writing. The table is opened using cursor 0. - */ - static void sqlite3OpenMasterTable( Parse p, int iDb ) - { - Vdbe v = sqlite3GetVdbe( p ); - sqlite3TableLock( p, iDb, MASTER_ROOT, 1, SCHEMA_TABLE( iDb ) ); - sqlite3VdbeAddOp3( v, OP_OpenWrite, 0, MASTER_ROOT, iDb ); - sqlite3VdbeChangeP4( v, -1, (int)5, P4_INT32 ); /* 5 column table */ - if ( p.nTab == 0 ) - { - p.nTab = 1; - } - } + /* + ** Given a token, return a string that consists of the text of that + ** token. Space to hold the returned string + ** is obtained from sqliteMalloc() and must be freed by the calling + ** function. + ** + ** Any quotation marks (ex: "name", 'name', [name], or `name`) that + ** surround the body of the token are removed. + ** + ** Tokens are often just pointers into the original SQL text and so + ** are not \000 terminated and are not persistent. The returned string + ** is \000 terminated and is persistent. + */ + static string sqlite3NameFromToken(sqlite3 db, Token pName) { + string zName; + if (pName != null && pName.z != null) { + zName = pName.z.Substring(0, pName.n);//sqlite3DbStrNDup(db, (char)pName.z, pName.n); + sqlite3Dequote(ref zName); + } else { + return null; + } + return zName; + } - /* - ** Parameter zName points to a nul-terminated buffer containing the name - ** of a database ("main", "temp" or the name of an attached db). This - ** function returns the index of the named database in db->aDb[], or - ** -1 if the named db cannot be found. - */ - static int sqlite3FindDbName( sqlite3 db, string zName ) - { - int i = -1; /* Database number */ - if ( zName != null ) - { - Db pDb; - int n = sqlite3Strlen30( zName ); - for ( i = ( db.nDb - 1 ); i >= 0; i-- ) - { - pDb = db.aDb[i]; - if ( ( OMIT_TEMPDB == 0 || i != 1 ) && n == sqlite3Strlen30( pDb.zName ) && - pDb.zName.Equals( zName, StringComparison.OrdinalIgnoreCase ) ) - { - break; - } + /* + ** Open the sqlite_master table stored in database number iDb for + ** writing. The table is opened using cursor 0. + */ + static void sqlite3OpenMasterTable(Parse p, int iDb) { + Vdbe v = sqlite3GetVdbe(p); + sqlite3TableLock(p, iDb, MASTER_ROOT, 1, SCHEMA_TABLE(iDb)); + sqlite3VdbeAddOp3(v, OP_OpenWrite, 0, MASTER_ROOT, iDb); + sqlite3VdbeChangeP4(v, -1, (int)5, P4_INT32); /* 5 column table */ + if (p.nTab == 0) { + p.nTab = 1; + } } - } - return i; - } - /* - ** The token *pName contains the name of a database (either "main" or - ** "temp" or the name of an attached db). This routine returns the - ** index of the named database in db->aDb[], or -1 if the named db - ** does not exist. - */ - static int sqlite3FindDb( sqlite3 db, Token pName ) - { - int i; /* Database number */ - string zName; /* Name we are searching for */ - zName = sqlite3NameFromToken( db, pName ); - i = sqlite3FindDbName( db, zName ); - sqlite3DbFree( db, ref zName ); - return i; - } + /* + ** Parameter zName points to a nul-terminated buffer containing the name + ** of a database ("main", "temp" or the name of an attached db). This + ** function returns the index of the named database in db->aDb[], or + ** -1 if the named db cannot be found. + */ + static int sqlite3FindDbName(sqlite3 db, string zName) { + int i = -1; /* Database number */ + if (zName != null) { + Db pDb; + int n = sqlite3Strlen30(zName); + for (i = (db.nDb - 1); i >= 0; i--) { + pDb = db.aDb[i]; + if ((OMIT_TEMPDB == 0 || i != 1) && n == sqlite3Strlen30(pDb.zName) && + pDb.zName.Equals(zName, StringComparison.OrdinalIgnoreCase)) { + break; + } + } + } + return i; + } - /* The table or view or trigger name is passed to this routine via tokens - ** pName1 and pName2. If the table name was fully qualified, for example: - ** - ** CREATE TABLE xxx.yyy (...); - ** - ** Then pName1 is set to "xxx" and pName2 "yyy". On the other hand if - ** the table name is not fully qualified, i.e.: - ** - ** CREATE TABLE yyy(...); - ** - ** Then pName1 is set to "yyy" and pName2 is "". - ** - ** This routine sets the ppUnqual pointer to point at the token (pName1 or - ** pName2) that stores the unqualified table name. The index of the - ** database "xxx" is returned. - */ - static int sqlite3TwoPartName( - Parse pParse, /* Parsing and code generating context */ - Token pName1, /* The "xxx" in the name "xxx.yyy" or "xxx" */ - Token pName2, /* The "yyy" in the name "xxx.yyy" */ - ref Token pUnqual /* Write the unqualified object name here */ - ) - { - int iDb; /* Database holding the object */ - sqlite3 db = pParse.db; - - if ( ALWAYS( pName2 != null ) && pName2.n > 0 ) - { - if ( db.init.busy != 0 ) - { - sqlite3ErrorMsg( pParse, "corrupt database" ); - pParse.nErr++; - return -1; + /* + ** The token *pName contains the name of a database (either "main" or + ** "temp" or the name of an attached db). This routine returns the + ** index of the named database in db->aDb[], or -1 if the named db + ** does not exist. + */ + static int sqlite3FindDb(sqlite3 db, Token pName) { + int i; /* Database number */ + string zName; /* Name we are searching for */ + zName = sqlite3NameFromToken(db, pName); + i = sqlite3FindDbName(db, zName); + sqlite3DbFree(db, ref zName); + return i; } - pUnqual = pName2; - iDb = sqlite3FindDb( db, pName1 ); - if ( iDb < 0 ) - { - sqlite3ErrorMsg( pParse, "unknown database %T", pName1 ); - pParse.nErr++; - return -1; + + /* The table or view or trigger name is passed to this routine via tokens + ** pName1 and pName2. If the table name was fully qualified, for example: + ** + ** CREATE TABLE xxx.yyy (...); + ** + ** Then pName1 is set to "xxx" and pName2 "yyy". On the other hand if + ** the table name is not fully qualified, i.e.: + ** + ** CREATE TABLE yyy(...); + ** + ** Then pName1 is set to "yyy" and pName2 is "". + ** + ** This routine sets the ppUnqual pointer to point at the token (pName1 or + ** pName2) that stores the unqualified table name. The index of the + ** database "xxx" is returned. + */ + static int sqlite3TwoPartName( + Parse pParse, /* Parsing and code generating context */ + Token pName1, /* The "xxx" in the name "xxx.yyy" or "xxx" */ + Token pName2, /* The "yyy" in the name "xxx.yyy" */ + ref Token pUnqual /* Write the unqualified object name here */ + ) { + int iDb; /* Database holding the object */ + sqlite3 db = pParse.db; + + if (ALWAYS(pName2 != null) && pName2.n > 0) { + if (db.init.busy != 0) { + sqlite3ErrorMsg(pParse, "corrupt database"); + pParse.nErr++; + return -1; + } + pUnqual = pName2; + iDb = sqlite3FindDb(db, pName1); + if (iDb < 0) { + sqlite3ErrorMsg(pParse, "unknown database %T", pName1); + pParse.nErr++; + return -1; + } + } else { + Debug.Assert(db.init.iDb == 0 || db.init.busy != 0); + iDb = db.init.iDb; + pUnqual = pName1; + } + return iDb; } - } - else - { - Debug.Assert( db.init.iDb == 0 || db.init.busy != 0 ); - iDb = db.init.iDb; - pUnqual = pName1; - } - return iDb; - } - /* - ** This routine is used to check if the UTF-8 string zName is a legal - ** unqualified name for a new schema object (vtable, index, view or - ** trigger). All names are legal except those that begin with the string - ** "sqlite_" (in upper, lower or mixed case). This portion of the namespace - ** is reserved for internal use. - */ - static int sqlite3CheckObjectName( Parse pParse, string zName ) - { - if ( 0 == pParse.db.init.busy && pParse.nested == 0 - && ( pParse.db.flags & SQLITE_WriteSchema ) == 0 - && zName.StartsWith( "sqlite_", System.StringComparison.OrdinalIgnoreCase ) ) - { - sqlite3ErrorMsg( pParse, "object name reserved for internal use: %s", zName ); - return SQLITE_ERROR; - } - return SQLITE_OK; - } + /* + ** This routine is used to check if the UTF-8 string zName is a legal + ** unqualified name for a new schema object (vtable, index, view or + ** trigger). All names are legal except those that begin with the string + ** "sqlite_" (in upper, lower or mixed case). This portion of the namespace + ** is reserved for internal use. + */ + static int sqlite3CheckObjectName(Parse pParse, string zName) { + if (0 == pParse.db.init.busy && pParse.nested == 0 + && (pParse.db.flags & SQLITE_WriteSchema) == 0 + && zName.StartsWith("sqlite_", System.StringComparison.OrdinalIgnoreCase)) { + sqlite3ErrorMsg(pParse, "object name reserved for internal use: %s", zName); + return SQLITE_ERROR; + } + return SQLITE_OK; + } - /* - ** Begin constructing a new table representation in memory. This is - ** the first of several action routines that get called in response - ** to a CREATE TABLE statement. In particular, this routine is called - ** after seeing tokens "CREATE" and "TABLE" and the table name. The isTemp - ** flag is true if the table should be stored in the auxiliary database - ** file instead of in the main database file. This is normally the case - ** when the "TEMP" or "TEMPORARY" keyword occurs in between - ** CREATE and TABLE. - ** - ** The new table record is initialized and put in pParse.pNewTable. - ** As more of the CREATE TABLE statement is parsed, additional action - ** routines will be called to add more information to this record. - ** At the end of the CREATE TABLE statement, the sqlite3EndTable() routine - ** is called to complete the construction of the new table record. - */ - static void sqlite3StartTable( - Parse pParse, /* Parser context */ - Token pName1, /* First part of the name of the table or view */ - Token pName2, /* Second part of the name of the table or view */ - int isTemp, /* True if this is a TEMP table */ - int isView, /* True if this is a VIEW */ - int isVirtual, /* True if this is a VIRTUAL table */ - int noErr /* Do nothing if table already exists */ - ) - { - Table pTable; - string zName = null; /* The name of the new table */ - sqlite3 db = pParse.db; - Vdbe v; - int iDb; /* Database number to create the table in */ - Token pName = new Token(); /* Unqualified name of the table to create */ - - /* The table or view name to create is passed to this routine via tokens - ** pName1 and pName2. If the table name was fully qualified, for example: - ** - ** CREATE TABLE xxx.yyy (...); - ** - ** Then pName1 is set to "xxx" and pName2 "yyy". On the other hand if - ** the table name is not fully qualified, i.e.: - ** - ** CREATE TABLE yyy(...); - ** - ** Then pName1 is set to "yyy" and pName2 is "". - ** - ** The call below sets the pName pointer to point at the token (pName1 or - ** pName2) that stores the unqualified table name. The variable iDb is - ** set to the index of the database that the table or view is to be - ** created in. - */ - iDb = sqlite3TwoPartName( pParse, pName1, pName2, ref pName ); - if ( iDb < 0 ) - return; - if ( 0 == OMIT_TEMPDB && isTemp != 0 && pName2.n > 0 && iDb != 1 ) - { - /* If creating a temp table, the name may not be qualified. Unless - ** the database name is "temp" anyway. */ - - sqlite3ErrorMsg( pParse, "temporary table name must be unqualified" ); - return; - } - if ( OMIT_TEMPDB == 0 && isTemp != 0 ) - iDb = 1; - - pParse.sNameToken = pName; - zName = sqlite3NameFromToken( db, pName ); - if ( zName == null ) - return; - if ( SQLITE_OK != sqlite3CheckObjectName( pParse, zName ) ) - { - goto begin_table_error; - } - if ( db.init.iDb == 1 ) - isTemp = 1; + /* + ** Begin constructing a new table representation in memory. This is + ** the first of several action routines that get called in response + ** to a CREATE TABLE statement. In particular, this routine is called + ** after seeing tokens "CREATE" and "TABLE" and the table name. The isTemp + ** flag is true if the table should be stored in the auxiliary database + ** file instead of in the main database file. This is normally the case + ** when the "TEMP" or "TEMPORARY" keyword occurs in between + ** CREATE and TABLE. + ** + ** The new table record is initialized and put in pParse.pNewTable. + ** As more of the CREATE TABLE statement is parsed, additional action + ** routines will be called to add more information to this record. + ** At the end of the CREATE TABLE statement, the sqlite3EndTable() routine + ** is called to complete the construction of the new table record. + */ + static void sqlite3StartTable( + Parse pParse, /* Parser context */ + Token pName1, /* First part of the name of the table or view */ + Token pName2, /* Second part of the name of the table or view */ + int isTemp, /* True if this is a TEMP table */ + int isView, /* True if this is a VIEW */ + int isVirtual, /* True if this is a VIRTUAL table */ + int noErr /* Do nothing if table already exists */ + ) { + Table pTable; + string zName = null; /* The name of the new table */ + sqlite3 db = pParse.db; + Vdbe v; + int iDb; /* Database number to create the table in */ + Token pName = new Token(); /* Unqualified name of the table to create */ + + /* The table or view name to create is passed to this routine via tokens + ** pName1 and pName2. If the table name was fully qualified, for example: + ** + ** CREATE TABLE xxx.yyy (...); + ** + ** Then pName1 is set to "xxx" and pName2 "yyy". On the other hand if + ** the table name is not fully qualified, i.e.: + ** + ** CREATE TABLE yyy(...); + ** + ** Then pName1 is set to "yyy" and pName2 is "". + ** + ** The call below sets the pName pointer to point at the token (pName1 or + ** pName2) that stores the unqualified table name. The variable iDb is + ** set to the index of the database that the table or view is to be + ** created in. + */ + iDb = sqlite3TwoPartName(pParse, pName1, pName2, ref pName); + if (iDb < 0) + return; + if (0 == OMIT_TEMPDB && isTemp != 0 && pName2.n > 0 && iDb != 1) { + /* If creating a temp table, the name may not be qualified. Unless + ** the database name is "temp" anyway. */ + + sqlite3ErrorMsg(pParse, "temporary table name must be unqualified"); + return; + } + if (OMIT_TEMPDB == 0 && isTemp != 0) + iDb = 1; + + pParse.sNameToken = pName; + zName = sqlite3NameFromToken(db, pName); + if (zName == null) + return; + if (SQLITE_OK != sqlite3CheckObjectName(pParse, zName)) { + goto begin_table_error; + } + if (db.init.iDb == 1) + isTemp = 1; #if !SQLITE_OMIT_AUTHORIZATION Debug.Assert( (isTemp & 1)==isTemp ); { @@ -953,1102 +879,1001 @@ static void sqlite3StartTable( } #endif - /* Make sure the new table name does not collide with an existing -** index or table name in the same database. Issue an error message if -** it does. The exception is if the statement being parsed was passed -** to an sqlite3_declare_vtab() call. In that case only the column names -** and types will be used, so there is no need to test for namespace -** collisions. -*/ - if ( !IN_DECLARE_VTAB( pParse ) ) - { - String zDb = db.aDb[iDb].zName; - if ( SQLITE_OK != sqlite3ReadSchema( pParse ) ) - { - goto begin_table_error; - } - pTable = sqlite3FindTable( db, zName, zDb ); - if ( pTable != null ) - { - if ( noErr == 0 ) - { - sqlite3ErrorMsg( pParse, "table %T already exists", pName ); - } - else - { - Debug.Assert( 0 == db.init.busy ); - sqlite3CodeVerifySchema( pParse, iDb ); - } - goto begin_table_error; - } - if ( sqlite3FindIndex( db, zName, zDb ) != null ) - { - sqlite3ErrorMsg( pParse, "there is already an index named %s", zName ); - goto begin_table_error; - } - } - - pTable = new Table();// sqlite3DbMallocZero(db, Table).Length; - //if ( pTable == null ) - //{ - // db.mallocFailed = 1; - // pParse.rc = SQLITE_NOMEM; - // pParse.nErr++; - // goto begin_table_error; - //} - pTable.zName = zName; - pTable.iPKey = -1; - pTable.pSchema = db.aDb[iDb].pSchema; - pTable.nRef = 1; - pTable.nRowEst = 1000000; - Debug.Assert( pParse.pNewTable == null ); - 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 - ** so that INSERT can find the table easily. + /* Make sure the new table name does not collide with an existing + ** index or table name in the same database. Issue an error message if + ** it does. The exception is if the statement being parsed was passed + ** to an sqlite3_declare_vtab() call. In that case only the column names + ** and types will be used, so there is no need to test for namespace + ** collisions. */ + if (!IN_DECLARE_VTAB(pParse)) { + String zDb = db.aDb[iDb].zName; + if (SQLITE_OK != sqlite3ReadSchema(pParse)) { + goto begin_table_error; + } + pTable = sqlite3FindTable(db, zName, zDb); + if (pTable != null) { + if (noErr == 0) { + sqlite3ErrorMsg(pParse, "table %T already exists", pName); + } else { + Debug.Assert(0 == db.init.busy); + sqlite3CodeVerifySchema(pParse, iDb); + } + goto begin_table_error; + } + if (sqlite3FindIndex(db, zName, zDb) != null) { + sqlite3ErrorMsg(pParse, "there is already an index named %s", zName); + goto begin_table_error; + } + } + + pTable = new Table();// sqlite3DbMallocZero(db, Table).Length; + //if ( pTable == null ) + //{ + // db.mallocFailed = 1; + // pParse.rc = SQLITE_NOMEM; + // pParse.nErr++; + // goto begin_table_error; + //} + pTable.zName = zName; + pTable.iPKey = -1; + pTable.pSchema = db.aDb[iDb].pSchema; + pTable.nRef = 1; + pTable.nRowEst = 1000000; + Debug.Assert(pParse.pNewTable == null); + 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 + ** so that INSERT can find the table easily. + */ #if !SQLITE_OMIT_AUTOINCREMENT - if ( pParse.nested == 0 && zName == "sqlite_sequence" ) - { - Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); - pTable.pSchema.pSeqTab = pTable; - } + if (pParse.nested == 0 && zName == "sqlite_sequence") { + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + pTable.pSchema.pSeqTab = pTable; + } #endif - /* Begin generating the code that will insert the table record into -** the SQLITE_MASTER table. Note in particular that we must go ahead -** and allocate the record number for the table entry now. Before any -** PRIMARY KEY or UNIQUE keywords are parsed. Those keywords will cause -** indices to be created and the table record must come before the -** indices. Hence, the record number for the table must be allocated -** now. -*/ - if ( 0 == db.init.busy && ( v = sqlite3GetVdbe( pParse ) ) != null ) - { - int j1; - int fileFormat; - int reg1, reg2, reg3; - sqlite3BeginWriteOperation( pParse, 0, iDb ); - - if ( isVirtual != 0 ) - { - sqlite3VdbeAddOp0( v, OP_VBegin ); + /* Begin generating the code that will insert the table record into + ** the SQLITE_MASTER table. Note in particular that we must go ahead + ** and allocate the record number for the table entry now. Before any + ** PRIMARY KEY or UNIQUE keywords are parsed. Those keywords will cause + ** indices to be created and the table record must come before the + ** indices. Hence, the record number for the table must be allocated + ** now. + */ + if (0 == db.init.busy && (v = sqlite3GetVdbe(pParse)) != null) { + int j1; + int fileFormat; + int reg1, reg2, reg3; + sqlite3BeginWriteOperation(pParse, 0, iDb); + + if (isVirtual != 0) { + sqlite3VdbeAddOp0(v, OP_VBegin); + } + + /* If the file format and encoding in the database have not been set, + ** set them now. + */ + reg1 = pParse.regRowid = ++pParse.nMem; + reg2 = pParse.regRoot = ++pParse.nMem; + reg3 = ++pParse.nMem; + sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, reg3, BTREE_FILE_FORMAT); + sqlite3VdbeUsesBtree(v, iDb); + j1 = sqlite3VdbeAddOp1(v, OP_If, reg3); + fileFormat = (db.flags & SQLITE_LegacyFileFmt) != 0 ? + 1 : SQLITE_MAX_FILE_FORMAT; + sqlite3VdbeAddOp2(v, OP_Integer, fileFormat, reg3); + sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, reg3); + sqlite3VdbeAddOp2(v, OP_Integer, ENC(db), reg3); + sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_TEXT_ENCODING, reg3); + sqlite3VdbeJumpHere(v, j1); + + /* This just creates a place-holder record in the sqlite_master table. + ** The record created does not contain anything yet. It will be replaced + ** by the real entry in code generated at sqlite3EndTable(). + ** + ** The rowid for the new entry is left in register pParse->regRowid. + ** The root page number of the new table is left in reg pParse->regRoot. + ** The rowid and root page number values are needed by the code that + ** sqlite3EndTable will generate. + */ + if (isView != 0 || isVirtual != 0) { + sqlite3VdbeAddOp2(v, OP_Integer, 0, reg2); + } else { + sqlite3VdbeAddOp2(v, OP_CreateTable, iDb, reg2); + } + sqlite3OpenMasterTable(pParse, iDb); + sqlite3VdbeAddOp2(v, OP_NewRowid, 0, reg1); + sqlite3VdbeAddOp2(v, OP_Null, 0, reg3); + sqlite3VdbeAddOp3(v, OP_Insert, 0, reg3, reg1); + sqlite3VdbeChangeP5(v, OPFLAG_APPEND); + sqlite3VdbeAddOp0(v, OP_Close); + } + + /* Normal (non-error) return. */ + return; + + /* If an error occurs, we jump here */ + begin_table_error: + sqlite3DbFree(db, ref zName); + return; } - /* If the file format and encoding in the database have not been set, - ** set them now. + /* + ** This macro is used to compare two strings in a case-insensitive manner. + ** It is slightly faster than calling sqlite3StrICmp() directly, but + ** produces larger code. + ** + ** WARNING: This macro is not compatible with the strcmp() family. It + ** returns true if the two strings are equal, otherwise false. */ - reg1 = pParse.regRowid = ++pParse.nMem; - reg2 = pParse.regRoot = ++pParse.nMem; - reg3 = ++pParse.nMem; - sqlite3VdbeAddOp3( v, OP_ReadCookie, iDb, reg3, BTREE_FILE_FORMAT ); - sqlite3VdbeUsesBtree( v, iDb ); - j1 = sqlite3VdbeAddOp1( v, OP_If, reg3 ); - fileFormat = ( db.flags & SQLITE_LegacyFileFmt ) != 0 ? - 1 : SQLITE_MAX_FILE_FORMAT; - sqlite3VdbeAddOp2( v, OP_Integer, fileFormat, reg3 ); - sqlite3VdbeAddOp3( v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, reg3 ); - sqlite3VdbeAddOp2( v, OP_Integer, ENC( db ), reg3 ); - sqlite3VdbeAddOp3( v, OP_SetCookie, iDb, BTREE_TEXT_ENCODING, reg3 ); - sqlite3VdbeJumpHere( v, j1 ); - - /* This just creates a place-holder record in the sqlite_master table. - ** The record created does not contain anything yet. It will be replaced - ** by the real entry in code generated at sqlite3EndTable(). + //#define STRICMP(x, y) (\ + //sqlite3UpperToLower[*(unsigned char )(x)]== \ + //sqlite3UpperToLower[*(unsigned char )(y)] \ + //&& sqlite3StrICmp((x)+1,(y)+1)==0 ) + + /* + ** Add a new column to the table currently being constructed. ** - ** The rowid for the new entry is left in register pParse->regRowid. - ** The root page number of the new table is left in reg pParse->regRoot. - ** The rowid and root page number values are needed by the code that - ** sqlite3EndTable will generate. + ** The parser calls this routine once for each column declaration + ** in a CREATE TABLE statement. sqlite3StartTable() gets called + ** first to get things going. Then this routine is called for each + ** column. */ - if ( isView != 0 || isVirtual != 0 ) - { - sqlite3VdbeAddOp2( v, OP_Integer, 0, reg2 ); + static void sqlite3AddColumn(Parse pParse, Token pName) { + Table p; + int i; + string z; + Column pCol; + sqlite3 db = pParse.db; + if ((p = pParse.pNewTable) == null) + return; +#if SQLITE_MAX_COLUMN || !SQLITE_MAX_COLUMN + if (p.nCol + 1 > db.aLimit[SQLITE_LIMIT_COLUMN]) { + sqlite3ErrorMsg(pParse, "too many columns on %s", p.zName); + return; + } +#endif + z = sqlite3NameFromToken(db, pName); + if (z == null) + return; + for (i = 0; i < p.nCol; i++) { + if (z.Equals(p.aCol[i].zName, StringComparison.OrdinalIgnoreCase)) {//STRICMP(z, p.aCol[i].zName) ){ + sqlite3ErrorMsg(pParse, "duplicate column name: %s", z); + sqlite3DbFree(db, ref z); + return; + } + } + if ((p.nCol & 0x7) == 0) { + //aNew = sqlite3DbRealloc(db,p.aCol,(p.nCol+8)*sizeof(p.aCol[0])); + //if( aNew==0 ){ + // sqlite3DbFree(db,ref z); + // return; + //} + Array.Resize(ref p.aCol, p.nCol + 8); + } + p.aCol[p.nCol] = new Column(); + pCol = p.aCol[p.nCol]; + //memset(pCol, 0, sizeof(p.aCol[0])); + pCol.zName = z; + + /* 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; + p.nCol++; } - else - { - sqlite3VdbeAddOp2( v, OP_CreateTable, iDb, reg2 ); + + /* + ** This routine is called by the parser while in the middle of + ** parsing a CREATE TABLE statement. A "NOT NULL" constraint has + ** been seen on a column. This routine sets the notNull flag on + ** the column currently under construction. + */ + static void sqlite3AddNotNull(Parse pParse, int onError) { + Table p; + p = pParse.pNewTable; + if (p == null || NEVER(p.nCol < 1)) + return; + p.aCol[p.nCol - 1].notNull = (u8)onError; } - sqlite3OpenMasterTable( pParse, iDb ); - sqlite3VdbeAddOp2( v, OP_NewRowid, 0, reg1 ); - sqlite3VdbeAddOp2( v, OP_Null, 0, reg3 ); - sqlite3VdbeAddOp3( v, OP_Insert, 0, reg3, reg1 ); - sqlite3VdbeChangeP5( v, OPFLAG_APPEND ); - sqlite3VdbeAddOp0( v, OP_Close ); - } - - /* Normal (non-error) return. */ - return; - /* If an error occurs, we jump here */ -begin_table_error: - sqlite3DbFree( db, ref zName ); - return; - } + /* + ** Scan the column type name zType (length nType) and return the + ** associated affinity type. + ** + ** This routine does a case-independent search of zType for the + ** substrings in the following table. If one of the substrings is + ** found, the corresponding affinity is returned. If zType contains + ** more than one of the substrings, entries toward the top of + ** the table take priority. For example, if zType is 'BLOBINT', + ** SQLITE_AFF_INTEGER is returned. + ** + ** Substring | Affinity + ** -------------------------------- + ** 'INT' | SQLITE_AFF_INTEGER + ** 'CHAR' | SQLITE_AFF_TEXT + ** 'CLOB' | SQLITE_AFF_TEXT + ** 'TEXT' | SQLITE_AFF_TEXT + ** 'BLOB' | SQLITE_AFF_NONE + ** 'REAL' | SQLITE_AFF_REAL + ** 'FLOA' | SQLITE_AFF_REAL + ** 'DOUB' | SQLITE_AFF_REAL + ** + ** If none of the substrings in the above table are found, + ** SQLITE_AFF_NUMERIC is returned. + */ + static char sqlite3AffinityType(string zIn) { + //u32 h = 0; + //char aff = SQLITE_AFF_NUMERIC; + zIn = zIn.ToLowerInvariant(); + if (zIn.Contains("char") || zIn.Contains("clob") || zIn.Contains("text")) + return SQLITE_AFF_TEXT; + if (zIn.Contains("blob")) + return SQLITE_AFF_NONE; + if (zIn.Contains("doub") || zIn.Contains("floa") || zIn.Contains("real")) + return SQLITE_AFF_REAL; + if (zIn.Contains("int")) + return SQLITE_AFF_INTEGER; + return SQLITE_AFF_NUMERIC; + // string zEnd = pType.z.Substring(pType.n); + + // while( zIn!=zEnd ){ + // h = (h<<8) + sqlite3UpperToLower[*zIn]; + // zIn++; + // if( h==(('c'<<24)+('h'<<16)+('a'<<8)+'r') ){ /* CHAR */ + // 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 !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 */ + // && aff==SQLITE_AFF_NUMERIC ){ + // aff = SQLITE_AFF_REAL; + // }else if( h==(('d'<<24)+('o'<<16)+('u'<<8)+'b') /* DOUB */ + // && aff==SQLITE_AFF_NUMERIC ){ + // aff = SQLITE_AFF_REAL; + //#endif + // }else if( (h&0x00FFFFFF)==(('i'<<16)+('n'<<8)+'t') ){ /* INT */ + // aff = SQLITE_AFF_INTEGER; + // break; + // } + // } + + // return aff; + } - /* - ** This macro is used to compare two strings in a case-insensitive manner. - ** It is slightly faster than calling sqlite3StrICmp() directly, but - ** produces larger code. - ** - ** WARNING: This macro is not compatible with the strcmp() family. It - ** returns true if the two strings are equal, otherwise false. - */ - //#define STRICMP(x, y) (\ - //sqlite3UpperToLower[*(unsigned char )(x)]== \ - //sqlite3UpperToLower[*(unsigned char )(y)] \ - //&& sqlite3StrICmp((x)+1,(y)+1)==0 ) + /* + ** This routine is called by the parser while in the middle of + ** parsing a CREATE TABLE statement. The pFirst token is the first + ** token in the sequence of tokens that describe the type of the + ** column currently under construction. pLast is the last token + ** in the sequence. Use this information to construct a string + ** that contains the typename of the column and store that string + ** in zType. + */ + static void sqlite3AddColumnType(Parse pParse, Token pType) { + Table p; + Column pCol; - /* - ** Add a new column to the table currently being constructed. - ** - ** The parser calls this routine once for each column declaration - ** in a CREATE TABLE statement. sqlite3StartTable() gets called - ** first to get things going. Then this routine is called for each - ** column. - */ - static void sqlite3AddColumn( Parse pParse, Token pName ) - { - Table p; - int i; - string z; - Column pCol; - sqlite3 db = pParse.db; - if ( ( p = pParse.pNewTable ) == null ) - return; -#if SQLITE_MAX_COLUMN || !SQLITE_MAX_COLUMN - if ( p.nCol + 1 > db.aLimit[SQLITE_LIMIT_COLUMN] ) - { - sqlite3ErrorMsg( pParse, "too many columns on %s", p.zName ); - return; - } -#endif - z = sqlite3NameFromToken( db, pName ); - if ( z == null ) - return; - for ( i = 0; i < p.nCol; i++ ) - { - if ( z.Equals( p.aCol[i].zName, StringComparison.OrdinalIgnoreCase ) ) - {//STRICMP(z, p.aCol[i].zName) ){ - sqlite3ErrorMsg( pParse, "duplicate column name: %s", z ); - sqlite3DbFree( db, ref z ); - return; + p = pParse.pNewTable; + if (p == null || NEVER(p.nCol < 1)) + return; + pCol = p.aCol[p.nCol - 1]; + Debug.Assert(pCol.zType == null); + pCol.zType = sqlite3NameFromToken(pParse.db, pType); + pCol.affinity = sqlite3AffinityType(pCol.zType); } - } - if ( ( p.nCol & 0x7 ) == 0 ) - { - //aNew = sqlite3DbRealloc(db,p.aCol,(p.nCol+8)*sizeof(p.aCol[0])); - //if( aNew==0 ){ - // sqlite3DbFree(db,ref z); - // return; - //} - Array.Resize( ref p.aCol, p.nCol + 8 ); - } - p.aCol[p.nCol] = new Column(); - pCol = p.aCol[p.nCol]; - //memset(pCol, 0, sizeof(p.aCol[0])); - pCol.zName = z; - - /* 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; - p.nCol++; - } - - /* - ** This routine is called by the parser while in the middle of - ** parsing a CREATE TABLE statement. A "NOT NULL" constraint has - ** been seen on a column. This routine sets the notNull flag on - ** the column currently under construction. - */ - static void sqlite3AddNotNull( Parse pParse, int onError ) - { - Table p; - p = pParse.pNewTable; - if ( p == null || NEVER( p.nCol < 1 ) ) - return; - p.aCol[p.nCol - 1].notNull = (u8)onError; - } - - /* - ** Scan the column type name zType (length nType) and return the - ** associated affinity type. - ** - ** This routine does a case-independent search of zType for the - ** substrings in the following table. If one of the substrings is - ** found, the corresponding affinity is returned. If zType contains - ** more than one of the substrings, entries toward the top of - ** the table take priority. For example, if zType is 'BLOBINT', - ** SQLITE_AFF_INTEGER is returned. - ** - ** Substring | Affinity - ** -------------------------------- - ** 'INT' | SQLITE_AFF_INTEGER - ** 'CHAR' | SQLITE_AFF_TEXT - ** 'CLOB' | SQLITE_AFF_TEXT - ** 'TEXT' | SQLITE_AFF_TEXT - ** 'BLOB' | SQLITE_AFF_NONE - ** 'REAL' | SQLITE_AFF_REAL - ** 'FLOA' | SQLITE_AFF_REAL - ** 'DOUB' | SQLITE_AFF_REAL - ** - ** If none of the substrings in the above table are found, - ** SQLITE_AFF_NUMERIC is returned. - */ - static char sqlite3AffinityType( string zIn ) - { - //u32 h = 0; - //char aff = SQLITE_AFF_NUMERIC; - zIn = zIn.ToLowerInvariant(); - if ( zIn.Contains( "char" ) || zIn.Contains( "clob" ) || zIn.Contains( "text" ) ) - return SQLITE_AFF_TEXT; - if ( zIn.Contains( "blob" ) ) - return SQLITE_AFF_NONE; - if ( zIn.Contains( "doub" ) || zIn.Contains( "floa" ) || zIn.Contains( "real" ) ) - return SQLITE_AFF_REAL; - if ( zIn.Contains( "int" ) ) - return SQLITE_AFF_INTEGER; - return SQLITE_AFF_NUMERIC; - // string zEnd = pType.z.Substring(pType.n); - - // while( zIn!=zEnd ){ - // h = (h<<8) + sqlite3UpperToLower[*zIn]; - // zIn++; - // if( h==(('c'<<24)+('h'<<16)+('a'<<8)+'r') ){ /* CHAR */ - // 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 !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 */ - // && aff==SQLITE_AFF_NUMERIC ){ - // aff = SQLITE_AFF_REAL; - // }else if( h==(('d'<<24)+('o'<<16)+('u'<<8)+'b') /* DOUB */ - // && aff==SQLITE_AFF_NUMERIC ){ - // aff = SQLITE_AFF_REAL; - //#endif - // }else if( (h&0x00FFFFFF)==(('i'<<16)+('n'<<8)+'t') ){ /* INT */ - // aff = SQLITE_AFF_INTEGER; - // break; - // } - // } - - // return aff; - } - - /* - ** This routine is called by the parser while in the middle of - ** parsing a CREATE TABLE statement. The pFirst token is the first - ** token in the sequence of tokens that describe the type of the - ** column currently under construction. pLast is the last token - ** in the sequence. Use this information to construct a string - ** that contains the typename of the column and store that string - ** in zType. - */ - static void sqlite3AddColumnType( Parse pParse, Token pType ) - { - Table p; - Column pCol; - - p = pParse.pNewTable; - if ( p == null || NEVER( p.nCol < 1 ) ) - return; - pCol = p.aCol[p.nCol - 1]; - Debug.Assert( pCol.zType == null ); - pCol.zType = sqlite3NameFromToken( pParse.db, pType ); - pCol.affinity = sqlite3AffinityType( pCol.zType ); - } - /* - ** The expression is the default value for the most recently added column - ** of the table currently under construction. - ** - ** Default value expressions must be constant. Raise an exception if this - ** is not the case. - ** - ** This routine is called by the parser while in the middle of - ** parsing a CREATE TABLE statement. - */ - static void sqlite3AddDefaultValue( Parse pParse, ExprSpan pSpan ) - { - Table p; - Column pCol; - sqlite3 db = pParse.db; - p = pParse.pNewTable; - if ( p != null ) - { - pCol = ( p.aCol[p.nCol - 1] ); - if ( sqlite3ExprIsConstantOrFunction( pSpan.pExpr ) == 0 ) - { - sqlite3ErrorMsg( pParse, "default value of column [%s] is not constant", - pCol.zName ); - } - else - { - /* A copy of pExpr is used instead of the original, as pExpr contains - ** tokens that point to volatile memory. The 'span' of the expression - ** is required by pragma table_info. - */ - sqlite3ExprDelete( db, ref pCol.pDflt ); - pCol.pDflt = sqlite3ExprDup( db, pSpan.pExpr, EXPRDUP_REDUCE ); - sqlite3DbFree( db, ref pCol.zDflt ); - pCol.zDflt = pSpan.zStart.Substring( 0, pSpan.zStart.Length - pSpan.zEnd.Length ); - //sqlite3DbStrNDup( db, pSpan.zStart, - // (int)( pSpan.zEnd.Length - pSpan.zStart.Length ) ); + /* + ** The expression is the default value for the most recently added column + ** of the table currently under construction. + ** + ** Default value expressions must be constant. Raise an exception if this + ** is not the case. + ** + ** This routine is called by the parser while in the middle of + ** parsing a CREATE TABLE statement. + */ + static void sqlite3AddDefaultValue(Parse pParse, ExprSpan pSpan) { + Table p; + Column pCol; + sqlite3 db = pParse.db; + p = pParse.pNewTable; + if (p != null) { + pCol = (p.aCol[p.nCol - 1]); + if (sqlite3ExprIsConstantOrFunction(pSpan.pExpr) == 0) { + sqlite3ErrorMsg(pParse, "default value of column [%s] is not constant", + pCol.zName); + } else { + /* A copy of pExpr is used instead of the original, as pExpr contains + ** tokens that point to volatile memory. The 'span' of the expression + ** is required by pragma table_info. + */ + sqlite3ExprDelete(db, ref pCol.pDflt); + pCol.pDflt = sqlite3ExprDup(db, pSpan.pExpr, EXPRDUP_REDUCE); + sqlite3DbFree(db, ref pCol.zDflt); + pCol.zDflt = pSpan.zStart.Substring(0, pSpan.zStart.Length - pSpan.zEnd.Length); + //sqlite3DbStrNDup( db, pSpan.zStart, + // (int)( pSpan.zEnd.Length - pSpan.zStart.Length ) ); + } + } + sqlite3ExprDelete(db, ref pSpan.pExpr); } - } - sqlite3ExprDelete( db, ref pSpan.pExpr ); - } - /* - ** Designate the PRIMARY KEY for the table. pList is a list of names - ** of columns that form the primary key. If pList is NULL, then the - ** most recently added column of the table is the primary key. - ** - ** A table can have at most one primary key. If the table already has - ** a primary key (and this is the second primary key) then create an - ** error. - ** - ** If the PRIMARY KEY is on a single column whose datatype is INTEGER, - ** then we will try to use that column as the rowid. Set the Table.iPKey - ** field of the table under construction to be the index of the - ** INTEGER PRIMARY KEY column. Table.iPKey is set to -1 if there is - ** no INTEGER PRIMARY KEY. - ** - ** If the key is not an INTEGER PRIMARY KEY, then create a unique - ** index for the key. No index is created for INTEGER PRIMARY KEYs. - */ - // OVERLOADS, so I don't need to rewrite parse.c - static void sqlite3AddPrimaryKey( Parse pParse, int null_2, int onError, int autoInc, int sortOrder ) - { - sqlite3AddPrimaryKey( pParse, null, onError, autoInc, sortOrder ); - } - static void sqlite3AddPrimaryKey( - Parse pParse, /* Parsing context */ - ExprList pList, /* List of field names to be indexed */ - int onError, /* What to do with a uniqueness conflict */ - int autoInc, /* True if the AUTOINCREMENT keyword is present */ - int sortOrder /* SQLITE_SO_ASC or SQLITE_SO_DESC */ - ) - { - Table pTab = pParse.pNewTable; - string zType = null; - int iCol = -1, i; - if ( pTab == null || IN_DECLARE_VTAB( pParse ) ) - goto primary_key_exit; - if ( ( pTab.tabFlags & TF_HasPrimaryKey ) != 0 ) - { - sqlite3ErrorMsg( pParse, - "table \"%s\" has more than one primary key", pTab.zName ); - goto primary_key_exit; - } - pTab.tabFlags |= TF_HasPrimaryKey; - if ( pList == null ) - { - iCol = pTab.nCol - 1; - pTab.aCol[iCol].isPrimKey = 1; - } - else - { - for ( i = 0; i < pList.nExpr; i++ ) - { - for ( iCol = 0; iCol < pTab.nCol; iCol++ ) - { - if ( pList.a[i].zName.Equals( pTab.aCol[iCol].zName, StringComparison.OrdinalIgnoreCase ) ) - { - break; + /* + ** Designate the PRIMARY KEY for the table. pList is a list of names + ** of columns that form the primary key. If pList is NULL, then the + ** most recently added column of the table is the primary key. + ** + ** A table can have at most one primary key. If the table already has + ** a primary key (and this is the second primary key) then create an + ** error. + ** + ** If the PRIMARY KEY is on a single column whose datatype is INTEGER, + ** then we will try to use that column as the rowid. Set the Table.iPKey + ** field of the table under construction to be the index of the + ** INTEGER PRIMARY KEY column. Table.iPKey is set to -1 if there is + ** no INTEGER PRIMARY KEY. + ** + ** If the key is not an INTEGER PRIMARY KEY, then create a unique + ** index for the key. No index is created for INTEGER PRIMARY KEYs. + */ + // OVERLOADS, so I don't need to rewrite parse.c + static void sqlite3AddPrimaryKey(Parse pParse, int null_2, int onError, int autoInc, int sortOrder) { + sqlite3AddPrimaryKey(pParse, null, onError, autoInc, sortOrder); + } + static void sqlite3AddPrimaryKey( + Parse pParse, /* Parsing context */ + ExprList pList, /* List of field names to be indexed */ + int onError, /* What to do with a uniqueness conflict */ + int autoInc, /* True if the AUTOINCREMENT keyword is present */ + int sortOrder /* SQLITE_SO_ASC or SQLITE_SO_DESC */ + ) { + Table pTab = pParse.pNewTable; + string zType = null; + int iCol = -1, i; + if (pTab == null || IN_DECLARE_VTAB(pParse)) + goto primary_key_exit; + if ((pTab.tabFlags & TF_HasPrimaryKey) != 0) { + sqlite3ErrorMsg(pParse, + "table \"%s\" has more than one primary key", pTab.zName); + goto primary_key_exit; } - } - if ( iCol < pTab.nCol ) - { - pTab.aCol[iCol].isPrimKey = 1; - } - } - if ( pList.nExpr > 1 ) - iCol = -1; - } - if ( iCol >= 0 && iCol < pTab.nCol ) - { - zType = pTab.aCol[iCol].zType; - } - if ( zType != null && zType.Equals( "INTEGER", StringComparison.OrdinalIgnoreCase ) - && sortOrder == SQLITE_SO_ASC ) - { - pTab.iPKey = iCol; - pTab.keyConf = (byte)onError; - Debug.Assert( autoInc == 0 || autoInc == 1 ); - pTab.tabFlags |= (u8)( autoInc * TF_Autoincrement ); - } - else if ( autoInc != 0 ) - { + pTab.tabFlags |= TF_HasPrimaryKey; + if (pList == null) { + iCol = pTab.nCol - 1; + pTab.aCol[iCol].isPrimKey = 1; + } else { + for (i = 0; i < pList.nExpr; i++) { + for (iCol = 0; iCol < pTab.nCol; iCol++) { + if (pList.a[i].zName.Equals(pTab.aCol[iCol].zName, StringComparison.OrdinalIgnoreCase)) { + break; + } + } + if (iCol < pTab.nCol) { + pTab.aCol[iCol].isPrimKey = 1; + } + } + if (pList.nExpr > 1) + iCol = -1; + } + if (iCol >= 0 && iCol < pTab.nCol) { + zType = pTab.aCol[iCol].zType; + } + if (zType != null && zType.Equals("INTEGER", StringComparison.OrdinalIgnoreCase) + && sortOrder == SQLITE_SO_ASC) { + pTab.iPKey = iCol; + pTab.keyConf = (byte)onError; + Debug.Assert(autoInc == 0 || autoInc == 1); + pTab.tabFlags |= (u8)(autoInc * TF_Autoincrement); + } else if (autoInc != 0) { #if !SQLITE_OMIT_AUTOINCREMENT - sqlite3ErrorMsg( pParse, "AUTOINCREMENT is only allowed on an " + - "INTEGER PRIMARY KEY" ); + sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an " + + "INTEGER PRIMARY KEY"); #endif - } - else - { - Index p; - p = sqlite3CreateIndex( pParse, 0, 0, 0, pList, onError, 0, 0, sortOrder, 0 ); - if ( p != null ) - { - p.autoIndex = 2; - } - pList = null; - } + } else { + Index p; + p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, 0, sortOrder, 0); + if (p != null) { + p.autoIndex = 2; + } + pList = null; + } -primary_key_exit: - sqlite3ExprListDelete( pParse.db, ref pList ); - return; - } + primary_key_exit: + sqlite3ExprListDelete(pParse.db, ref pList); + return; + } - /* - ** Add a new CHECK constraint to the table currently under construction. - */ - static void sqlite3AddCheckConstraint( - Parse pParse, /* Parsing context */ - Expr pCheckExpr /* The check expression */ - ) - { - sqlite3 db = pParse.db; + /* + ** Add a new CHECK constraint to the table currently under construction. + */ + static void sqlite3AddCheckConstraint( + Parse pParse, /* Parsing context */ + Expr pCheckExpr /* The check expression */ + ) { + sqlite3 db = pParse.db; #if !SQLITE_OMIT_CHECK - Table pTab = pParse.pNewTable; - if ( pTab != null && !IN_DECLARE_VTAB( pParse ) ) - { - pTab.pCheck = sqlite3ExprAnd( db, pTab.pCheck, pCheckExpr ); - } - else + Table pTab = pParse.pNewTable; + if (pTab != null && !IN_DECLARE_VTAB(pParse)) { + pTab.pCheck = sqlite3ExprAnd(db, pTab.pCheck, pCheckExpr); + } else #endif - { - sqlite3ExprDelete( db, ref pCheckExpr ); - } - } - /* - ** Set the collation function of the most recently parsed table column - ** to the CollSeq given. - */ - static void sqlite3AddCollateType( Parse pParse, Token pToken ) - { - Table p; - int i; - string zColl; /* Dequoted name of collation sequence */ - sqlite3 db; - - if ( ( p = pParse.pNewTable ) == null ) - return; - i = p.nCol - 1; - db = pParse.db; - zColl = sqlite3NameFromToken( db, pToken ); - if ( zColl == null ) - return; - - if ( sqlite3LocateCollSeq( pParse, zColl ) != null ) - { - Index pIdx; - p.aCol[i].zColl = zColl; - - /* If the column is declared as " PRIMARY KEY COLLATE ", - ** then an index may have been created on this column before the - ** collation type was added. Correct this if it is the case. + { + sqlite3ExprDelete(db, ref pCheckExpr); + } + } + /* + ** Set the collation function of the most recently parsed table column + ** to the CollSeq given. */ - for ( pIdx = p.pIndex; pIdx != null; pIdx = pIdx.pNext ) - { - Debug.Assert( pIdx.nColumn == 1 ); - if ( pIdx.aiColumn[0] == i ) - { - pIdx.azColl[0] = p.aCol[i].zColl; - } + static void sqlite3AddCollateType(Parse pParse, Token pToken) { + Table p; + int i; + string zColl; /* Dequoted name of collation sequence */ + sqlite3 db; + + if ((p = pParse.pNewTable) == null) + return; + i = p.nCol - 1; + db = pParse.db; + zColl = sqlite3NameFromToken(db, pToken); + if (zColl == null) + return; + + if (sqlite3LocateCollSeq(pParse, zColl) != null) { + Index pIdx; + p.aCol[i].zColl = zColl; + + /* If the column is declared as " PRIMARY KEY COLLATE ", + ** then an index may have been created on this column before the + ** collation type was added. Correct this if it is the case. + */ + for (pIdx = p.pIndex; pIdx != null; pIdx = pIdx.pNext) { + Debug.Assert(pIdx.nColumn == 1); + if (pIdx.aiColumn[0] == i) { + pIdx.azColl[0] = p.aCol[i].zColl; + } + } + } else { + sqlite3DbFree(db, ref zColl); + } } - } - else - { - sqlite3DbFree( db, ref zColl ); - } - } - /* - ** This function returns the collation sequence for database native text - ** encoding identified by the string zName, length nName. - ** - ** If the requested collation sequence is not available, or not available - ** in the database native encoding, the collation factory is invoked to - ** request it. If the collation factory does not supply such a sequence, - ** and the sequence is available in another text encoding, then that is - ** returned instead. - ** - ** If no versions of the requested collations sequence are available, or - ** another error occurs, NULL is returned and an error message written into - ** pParse. - ** - ** This routine is a wrapper around sqlite3FindCollSeq(). This routine - ** invokes the collation factory if the named collation cannot be found - ** and generates an error message. - ** - ** See also: sqlite3FindCollSeq(), sqlite3GetCollSeq() - */ - static CollSeq sqlite3LocateCollSeq( Parse pParse, string zName ) - { - sqlite3 db = pParse.db; - u8 enc = db.aDb[0].pSchema.enc;// ENC(db); - u8 initbusy = db.init.busy; - CollSeq pColl; - - pColl = sqlite3FindCollSeq( db, enc, zName, initbusy ); - if ( 0 == initbusy && ( pColl == null || pColl.xCmp == null ) ) - { - pColl = sqlite3GetCollSeq( db, enc, pColl, zName ); - if ( pColl == null ) - { - sqlite3ErrorMsg( pParse, "no such collation sequence: %s", zName ); - } - } + /* + ** This function returns the collation sequence for database native text + ** encoding identified by the string zName, length nName. + ** + ** If the requested collation sequence is not available, or not available + ** in the database native encoding, the collation factory is invoked to + ** request it. If the collation factory does not supply such a sequence, + ** and the sequence is available in another text encoding, then that is + ** returned instead. + ** + ** If no versions of the requested collations sequence are available, or + ** another error occurs, NULL is returned and an error message written into + ** pParse. + ** + ** This routine is a wrapper around sqlite3FindCollSeq(). This routine + ** invokes the collation factory if the named collation cannot be found + ** and generates an error message. + ** + ** See also: sqlite3FindCollSeq(), sqlite3GetCollSeq() + */ + static CollSeq sqlite3LocateCollSeq(Parse pParse, string zName) { + sqlite3 db = pParse.db; + u8 enc = db.aDb[0].pSchema.enc;// ENC(db); + u8 initbusy = db.init.busy; + CollSeq pColl; + + pColl = sqlite3FindCollSeq(db, enc, zName, initbusy); + if (0 == initbusy && (pColl == null || pColl.xCmp == null)) { + pColl = sqlite3GetCollSeq(db, enc, pColl, zName); + if (pColl == null) { + sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName); + } + } - return pColl; - } + return pColl; + } - /* - ** Generate code that will increment the schema cookie. - ** - ** The schema cookie is used to determine when the schema for the - ** database changes. After each schema change, the cookie value - ** changes. When a process first reads the schema it records the - ** cookie. Thereafter, whenever it goes to access the database, - ** it checks the cookie to make sure the schema has not changed - ** since it was last read. - ** - ** This plan is not completely bullet-proof. It is possible for - ** the schema to change multiple times and for the cookie to be - ** set back to prior value. But schema changes are infrequent - ** and the probability of hitting the same cookie value is only - ** 1 chance in 2^32. So we're safe enough. - */ - static void sqlite3ChangeCookie( Parse pParse, int iDb ) - { - int r1 = sqlite3GetTempReg( pParse ); - sqlite3 db = pParse.db; - Vdbe v = pParse.pVdbe; - Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); - sqlite3VdbeAddOp2( v, OP_Integer, db.aDb[iDb].pSchema.schema_cookie + 1, r1 ); - sqlite3VdbeAddOp3( v, OP_SetCookie, iDb, BTREE_SCHEMA_VERSION, r1 ); - sqlite3ReleaseTempReg( pParse, r1 ); - } + /* + ** Generate code that will increment the schema cookie. + ** + ** The schema cookie is used to determine when the schema for the + ** database changes. After each schema change, the cookie value + ** changes. When a process first reads the schema it records the + ** cookie. Thereafter, whenever it goes to access the database, + ** it checks the cookie to make sure the schema has not changed + ** since it was last read. + ** + ** This plan is not completely bullet-proof. It is possible for + ** the schema to change multiple times and for the cookie to be + ** set back to prior value. But schema changes are infrequent + ** and the probability of hitting the same cookie value is only + ** 1 chance in 2^32. So we're safe enough. + */ + static void sqlite3ChangeCookie(Parse pParse, int iDb) { + int r1 = sqlite3GetTempReg(pParse); + sqlite3 db = pParse.db; + Vdbe v = pParse.pVdbe; + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + sqlite3VdbeAddOp2(v, OP_Integer, db.aDb[iDb].pSchema.schema_cookie + 1, r1); + sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_SCHEMA_VERSION, r1); + sqlite3ReleaseTempReg(pParse, r1); + } - /* - ** Measure the number of characters needed to output the given - ** identifier. The number returned includes any quotes used - ** but does not include the null terminator. - ** - ** The estimate is conservative. It might be larger that what is - ** really needed. - */ - static int identLength( string z ) - { - int n; - for ( n = 0; n < z.Length; n++ ) - { - if ( z[n] == (byte)'"' ) - { - n++; + /* + ** Measure the number of characters needed to output the given + ** identifier. The number returned includes any quotes used + ** but does not include the null terminator. + ** + ** The estimate is conservative. It might be larger that what is + ** really needed. + */ + static int identLength(string z) { + int n; + for (n = 0; n < z.Length; n++) { + if (z[n] == (byte)'"') { + n++; + } + } + return n + 2; } - } - return n + 2; - } - /* - ** The first parameter is a pointer to an output buffer. The second - ** parameter is a pointer to an integer that contains the offset at - ** which to write into the output buffer. This function copies the - ** nul-terminated string pointed to by the third parameter, zSignedIdent, - ** to the specified offset in the buffer and updates *pIdx to refer - ** to the first byte after the last byte written before returning. - ** - ** If the string zSignedIdent consists entirely of alpha-numeric - ** characters, does not begin with a digit and is not an SQL keyword, - ** then it is copied to the output buffer exactly as it is. Otherwise, - ** it is quoted using double-quotes. - */ - static void identPut( StringBuilder z, ref int pIdx, string zSignedIdent ) - { - string zIdent = zSignedIdent; - int i; - int j; - bool needQuote; - i = pIdx; - for ( j = 0; j < zIdent.Length; j++ ) - { - if ( !sqlite3Isalnum( zIdent[j] ) && zIdent[j] != '_' ) - break; - } - needQuote = sqlite3Isdigit( zIdent[0] ) || sqlite3KeywordCode( zIdent, j ) != TK_ID; - if ( !needQuote ) - { - needQuote = ( j < zIdent.Length && zIdent[j] != 0 ); - } - if ( needQuote ) - { - if ( i == z.Length ) - z.Append( '\0' ); - z[i++] = '"'; - } - for ( j = 0; j < zIdent.Length; j++ ) - { - if ( i == z.Length ) - z.Append( '\0' ); - z[i++] = zIdent[j]; - if ( zIdent[j] == '"' ) - { - if ( i == z.Length ) - z.Append( '\0' ); - z[i++] = '"'; + /* + ** The first parameter is a pointer to an output buffer. The second + ** parameter is a pointer to an integer that contains the offset at + ** which to write into the output buffer. This function copies the + ** nul-terminated string pointed to by the third parameter, zSignedIdent, + ** to the specified offset in the buffer and updates *pIdx to refer + ** to the first byte after the last byte written before returning. + ** + ** If the string zSignedIdent consists entirely of alpha-numeric + ** characters, does not begin with a digit and is not an SQL keyword, + ** then it is copied to the output buffer exactly as it is. Otherwise, + ** it is quoted using double-quotes. + */ + static void identPut(StringBuilder z, ref int pIdx, string zSignedIdent) { + string zIdent = zSignedIdent; + int i; + int j; + bool needQuote; + i = pIdx; + for (j = 0; j < zIdent.Length; j++) { + if (!sqlite3Isalnum(zIdent[j]) && zIdent[j] != '_') + break; + } + needQuote = sqlite3Isdigit(zIdent[0]) || sqlite3KeywordCode(zIdent, j) != TK_ID; + if (!needQuote) { + needQuote = (j < zIdent.Length && zIdent[j] != 0); + } + if (needQuote) { + if (i == z.Length) + z.Append('\0'); + z[i++] = '"'; + } + for (j = 0; j < zIdent.Length; j++) { + if (i == z.Length) + z.Append('\0'); + z[i++] = zIdent[j]; + if (zIdent[j] == '"') { + if (i == z.Length) + z.Append('\0'); + z[i++] = '"'; + } + } + if (needQuote) { + if (i == z.Length) + z.Append('\0'); + z[i++] = '"'; + } + //z[i] = 0; + pIdx = i; } - } - if ( needQuote ) - { - if ( i == z.Length ) - z.Append( '\0' ); - z[i++] = '"'; - } - //z[i] = 0; - pIdx = i; - } - /* - ** Generate a CREATE TABLE statement appropriate for the given - ** table. Memory to hold the text of the statement is obtained - ** from sqliteMalloc() and must be freed by the calling function. - */ - static string createTableStmt( sqlite3 db, Table p ) - { - int i, k, n; - StringBuilder zStmt; - string zSep; - string zSep2; - string zEnd; - Column pCol; - n = 0; - for ( i = 0; i < p.nCol; i++ ) - {//, pCol++){ - pCol = p.aCol[i]; - n += identLength( pCol.zName ) + 5; - } - n += identLength( p.zName ); - if ( n < 50 ) - { - zSep = ""; - zSep2 = ","; - zEnd = ")"; - } - else - { - zSep = "\n "; - zSep2 = ",\n "; - zEnd = "\n)"; - } - n += 35 + 6 * p.nCol; - zStmt = new StringBuilder( n ); - //zStmt = sqlite3DbMallocRaw(0, n); - //if( zStmt==0 ){ - // db.mallocFailed = 1; - // return 0; - //} - //sqlite3_snprintf(n, zStmt,"CREATE TABLE "); - zStmt.Append( "CREATE TABLE " ); - k = sqlite3Strlen30( zStmt ); - identPut( zStmt, ref k, p.zName ); - zStmt.Append( '(' );//zStmt[k++] = '('; - for ( i = 0; i < p.nCol; i++ ) - {//, pCol++){ - pCol = p.aCol[i]; - string[] azType = new string[] { + /* + ** Generate a CREATE TABLE statement appropriate for the given + ** table. Memory to hold the text of the statement is obtained + ** from sqliteMalloc() and must be freed by the calling function. + */ + static string createTableStmt(sqlite3 db, Table p) { + int i, k, n; + StringBuilder zStmt; + string zSep; + string zSep2; + string zEnd; + Column pCol; + n = 0; + for (i = 0; i < p.nCol; i++) {//, pCol++){ + pCol = p.aCol[i]; + n += identLength(pCol.zName) + 5; + } + n += identLength(p.zName); + if (n < 50) { + zSep = ""; + zSep2 = ","; + zEnd = ")"; + } else { + zSep = "\n "; + zSep2 = ",\n "; + zEnd = "\n)"; + } + n += 35 + 6 * p.nCol; + zStmt = new StringBuilder(n); + //zStmt = sqlite3DbMallocRaw(0, n); + //if( zStmt==0 ){ + // db.mallocFailed = 1; + // return 0; + //} + //sqlite3_snprintf(n, zStmt,"CREATE TABLE "); + zStmt.Append("CREATE TABLE "); + k = sqlite3Strlen30(zStmt); + identPut(zStmt, ref k, p.zName); + zStmt.Append('(');//zStmt[k++] = '('; + for (i = 0; i < p.nCol; i++) {//, pCol++){ + pCol = p.aCol[i]; + string[] azType = new string[] { /* SQLITE_AFF_TEXT */ " TEXT", /* SQLITE_AFF_NONE */ "", /* SQLITE_AFF_NUMERIC */ " NUM", /* SQLITE_AFF_INTEGER */ " INT", /* SQLITE_AFF_REAL */ " REAL" }; - int len; - string zType; - - zStmt.Append( zSep );// sqlite3_snprintf(n-k, zStmt[k], zSep); - k = sqlite3Strlen30( zStmt );// k += strlen(zStmt[k]); - zSep = zSep2; - identPut( zStmt, ref k, pCol.zName ); - Debug.Assert( pCol.affinity - SQLITE_AFF_TEXT >= 0 ); - Debug.Assert( pCol.affinity - SQLITE_AFF_TEXT < ArraySize( azType ) ); - testcase( pCol.affinity == SQLITE_AFF_TEXT ); - testcase( pCol.affinity == SQLITE_AFF_NONE ); - testcase( pCol.affinity == SQLITE_AFF_NUMERIC ); - testcase( pCol.affinity == SQLITE_AFF_INTEGER ); - testcase( pCol.affinity == SQLITE_AFF_REAL ); - - zType = azType[pCol.affinity - SQLITE_AFF_TEXT]; - len = sqlite3Strlen30( zType ); - Debug.Assert( pCol.affinity == SQLITE_AFF_NONE - || pCol.affinity == sqlite3AffinityType( zType ) ); - zStmt.Append( zType );// memcpy( &zStmt[k], zType, len ); - k += len; - Debug.Assert( k <= n ); - } - zStmt.Append( zEnd );//sqlite3_snprintf(n-k, zStmt[k], "%s", zEnd); - return zStmt.ToString(); - } - - /* - ** This routine is called to report the final ")" that terminates - ** a CREATE TABLE statement. - ** - ** The table structure that other action routines have been building - ** is added to the internal hash tables, assuming no errors have - ** occurred. - ** - ** An entry for the table is made in the master table on disk, unless - ** this is a temporary table or db.init.busy==1. When db.init.busy==1 - ** it means we are reading the sqlite_master table because we just - ** connected to the database or because the sqlite_master table has - ** recently changed, so the entry for this table already exists in - ** the sqlite_master table. We do not want to create it again. - ** - ** If the pSelect argument is not NULL, it means that this routine - ** was called to create a table generated from a - ** "CREATE TABLE ... AS SELECT ..." statement. The column names of - ** the new table will match the result set of the SELECT. - */ - // OVERLOADS, so I don't need to rewrite parse.c - static void sqlite3EndTable( Parse pParse, Token pCons, Token pEnd, int null_4 ) - { - sqlite3EndTable( pParse, pCons, pEnd, null ); - } - static void sqlite3EndTable( Parse pParse, int null_2, int null_3, Select pSelect ) - { - sqlite3EndTable( pParse, null, null, pSelect ); - } - - static void sqlite3EndTable( - 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; - sqlite3 db = pParse.db; - int iDb; + int len; + string zType; + + zStmt.Append(zSep);// sqlite3_snprintf(n-k, zStmt[k], zSep); + k = sqlite3Strlen30(zStmt);// k += strlen(zStmt[k]); + zSep = zSep2; + identPut(zStmt, ref k, pCol.zName); + Debug.Assert(pCol.affinity - SQLITE_AFF_TEXT >= 0); + Debug.Assert(pCol.affinity - SQLITE_AFF_TEXT < ArraySize(azType)); + testcase(pCol.affinity == SQLITE_AFF_TEXT); + testcase(pCol.affinity == SQLITE_AFF_NONE); + testcase(pCol.affinity == SQLITE_AFF_NUMERIC); + testcase(pCol.affinity == SQLITE_AFF_INTEGER); + testcase(pCol.affinity == SQLITE_AFF_REAL); + + zType = azType[pCol.affinity - SQLITE_AFF_TEXT]; + len = sqlite3Strlen30(zType); + Debug.Assert(pCol.affinity == SQLITE_AFF_NONE + || pCol.affinity == sqlite3AffinityType(zType)); + zStmt.Append(zType);// memcpy( &zStmt[k], zType, len ); + k += len; + Debug.Assert(k <= n); + } + zStmt.Append(zEnd);//sqlite3_snprintf(n-k, zStmt[k], "%s", zEnd); + return zStmt.ToString(); + } - if ( ( pEnd == null && pSelect == null ) /*|| db.mallocFailed != 0 */ ) - { - return; - } - p = pParse.pNewTable; - if ( p == null ) - return; + /* + ** This routine is called to report the final ")" that terminates + ** a CREATE TABLE statement. + ** + ** The table structure that other action routines have been building + ** is added to the internal hash tables, assuming no errors have + ** occurred. + ** + ** An entry for the table is made in the master table on disk, unless + ** this is a temporary table or db.init.busy==1. When db.init.busy==1 + ** it means we are reading the sqlite_master table because we just + ** connected to the database or because the sqlite_master table has + ** recently changed, so the entry for this table already exists in + ** the sqlite_master table. We do not want to create it again. + ** + ** If the pSelect argument is not NULL, it means that this routine + ** was called to create a table generated from a + ** "CREATE TABLE ... AS SELECT ..." statement. The column names of + ** the new table will match the result set of the SELECT. + */ + // OVERLOADS, so I don't need to rewrite parse.c + static void sqlite3EndTable(Parse pParse, Token pCons, Token pEnd, int null_4) { + sqlite3EndTable(pParse, pCons, pEnd, null); + } + static void sqlite3EndTable(Parse pParse, int null_2, int null_3, Select pSelect) { + sqlite3EndTable(pParse, null, null, pSelect); + } + + static void sqlite3EndTable( + 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; + sqlite3 db = pParse.db; + int iDb; + + if ((pEnd == null && pSelect == null) /*|| db.mallocFailed != 0 */ ) { + return; + } + p = pParse.pNewTable; + if (p == null) + return; - Debug.Assert( 0 == db.init.busy || pSelect == null ); + Debug.Assert(0 == db.init.busy || pSelect == null); - iDb = sqlite3SchemaToIndex( db, p.pSchema ); + iDb = sqlite3SchemaToIndex(db, p.pSchema); #if !SQLITE_OMIT_CHECK - /* Resolve names in all CHECK constraint expressions. -*/ - if ( p.pCheck != null ) - { - SrcList sSrc; /* Fake SrcList for pParse.pNewTable */ - NameContext sNC; /* Name context for pParse.pNewTable */ - - sNC = new NameContext();// memset(sNC, 0, sizeof(sNC)); - sSrc = new SrcList();// memset(sSrc, 0, sizeof(sSrc)); - sSrc.nSrc = 1; - sSrc.a = new SrcList_item[1]; - sSrc.a[0] = new SrcList_item(); - sSrc.a[0].zName = p.zName; - sSrc.a[0].pTab = p; - sSrc.a[0].iCursor = -1; - sNC.pParse = pParse; - sNC.pSrcList = sSrc; - sNC.isCheck = 1; - if ( sqlite3ResolveExprNames( sNC, ref p.pCheck ) != 0 ) - { - return; - } - } + /* Resolve names in all CHECK constraint expressions. + */ + if (p.pCheck != null) { + SrcList sSrc; /* Fake SrcList for pParse.pNewTable */ + NameContext sNC; /* Name context for pParse.pNewTable */ + + sNC = new NameContext();// memset(sNC, 0, sizeof(sNC)); + sSrc = new SrcList();// memset(sSrc, 0, sizeof(sSrc)); + sSrc.nSrc = 1; + sSrc.a = new SrcList_item[1]; + sSrc.a[0] = new SrcList_item(); + sSrc.a[0].zName = p.zName; + sSrc.a[0].pTab = p; + sSrc.a[0].iCursor = -1; + sNC.pParse = pParse; + sNC.pSrcList = sSrc; + sNC.isCheck = 1; + if (sqlite3ResolveExprNames(sNC, ref p.pCheck) != 0) { + return; + } + } #endif // * !SQLITE_OMIT_CHECK) */ - /* 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.) -*/ - if ( db.init.busy != 0 ) - { - p.tnum = db.init.newTnum; - } - - /* If not initializing, then create a record for the new table - ** in the SQLITE_MASTER table of the database. - ** - ** If this is a TEMPORARY table, write the entry into the auxiliary - ** file instead of into the main database file. + /* 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.) */ - if ( 0 == db.init.busy ) - { - int n; - Vdbe v; - String zType = ""; /* "view" or "table" */ - String zType2 = ""; /* "VIEW" or "TABLE" */ - String zStmt = ""; /* Text of the CREATE TABLE or CREATE VIEW statement */ - - v = sqlite3GetVdbe( pParse ); - if ( NEVER( v == null ) ) - return; - - sqlite3VdbeAddOp1( v, OP_Close, 0 ); + if (db.init.busy != 0) { + p.tnum = db.init.newTnum; + } - /* - ** Initialize zType for the new view or table. - */ - if ( p.pSelect == null ) - { - /* A regular table */ - zType = "table"; - zType2 = "TABLE"; + /* If not initializing, then create a record for the new table + ** in the SQLITE_MASTER table of the database. + ** + ** If this is a TEMPORARY table, write the entry into the auxiliary + ** file instead of into the main database file. + */ + if (0 == db.init.busy) { + int n; + Vdbe v; + String zType = ""; /* "view" or "table" */ + String zType2 = ""; /* "VIEW" or "TABLE" */ + String zStmt = ""; /* Text of the CREATE TABLE or CREATE VIEW statement */ + + v = sqlite3GetVdbe(pParse); + if (NEVER(v == null)) + return; + + sqlite3VdbeAddOp1(v, OP_Close, 0); + + /* + ** Initialize zType for the new view or table. + */ + if (p.pSelect == null) { + /* A regular table */ + zType = "table"; + zType2 = "TABLE"; #if !SQLITE_OMIT_VIEW - } - else - { - /* A view */ - zType = "view"; - zType2 = "VIEW"; + } else { + /* A view */ + zType = "view"; + zType2 = "VIEW"; #endif - } - - /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT - ** statement to populate the new table. The root-page number for the - ** new table is in register pParse->regRoot. - ** - ** Once the SELECT has been coded by sqlite3Select(), it is in a - ** suitable state to query for the column names and types to be used - ** by the new table. - ** - ** A shared-cache write-lock is not required to write to the new table, - ** as a schema-lock must have already been obtained to create it. Since - ** a schema-lock excludes all other database users, the write-lock would - ** be redundant. - */ - if ( pSelect != null ) - { - SelectDest dest = new SelectDest(); - Table pSelTab; - - Debug.Assert( pParse.nTab == 1 ); - sqlite3VdbeAddOp3( v, OP_OpenWrite, 1, pParse.regRoot, iDb ); - sqlite3VdbeChangeP5( v, 1 ); - pParse.nTab = 2; - sqlite3SelectDestInit( dest, SRT_Table, 1 ); - sqlite3Select( pParse, pSelect, ref dest ); - sqlite3VdbeAddOp1( v, OP_Close, 1 ); - if ( pParse.nErr == 0 ) - { - pSelTab = sqlite3ResultSetOfSelect( pParse, pSelect ); - if ( pSelTab == null ) - return; - Debug.Assert( p.aCol == null ); - p.nCol = pSelTab.nCol; - p.aCol = pSelTab.aCol; - pSelTab.nCol = 0; - pSelTab.aCol = null; - sqlite3DeleteTable( db, ref pSelTab ); - } - } - - /* Compute the complete text of the CREATE statement */ - if ( pSelect != null ) - { - zStmt = createTableStmt( db, p ); - } - else - { - n = (int)( pParse.sNameToken.z.Length - pEnd.z.Length ) + 1; - zStmt = sqlite3MPrintf( db, - "CREATE %s %.*s", zType2, n, pParse.sNameToken.z - ); - } - - /* A slot for the record has already been allocated in the - ** SQLITE_MASTER table. We just need to update that slot with all - ** the information we've collected. - */ - sqlite3NestedParse( pParse, - "UPDATE %Q.%s " + - "SET type='%s', name=%Q, tbl_name=%Q, rootpage=#%d, sql=%Q " + - "WHERE rowid=#%d", - db.aDb[iDb].zName, SCHEMA_TABLE( iDb ), - zType, - p.zName, - p.zName, - pParse.regRoot, - zStmt, - pParse.regRowid - ); - sqlite3DbFree( db, ref zStmt ); - sqlite3ChangeCookie( pParse, iDb ); + } + + /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT + ** statement to populate the new table. The root-page number for the + ** new table is in register pParse->regRoot. + ** + ** Once the SELECT has been coded by sqlite3Select(), it is in a + ** suitable state to query for the column names and types to be used + ** by the new table. + ** + ** A shared-cache write-lock is not required to write to the new table, + ** as a schema-lock must have already been obtained to create it. Since + ** a schema-lock excludes all other database users, the write-lock would + ** be redundant. + */ + if (pSelect != null) { + SelectDest dest = new SelectDest(); + Table pSelTab; + + Debug.Assert(pParse.nTab == 1); + sqlite3VdbeAddOp3(v, OP_OpenWrite, 1, pParse.regRoot, iDb); + sqlite3VdbeChangeP5(v, 1); + pParse.nTab = 2; + sqlite3SelectDestInit(dest, SRT_Table, 1); + sqlite3Select(pParse, pSelect, ref dest); + sqlite3VdbeAddOp1(v, OP_Close, 1); + if (pParse.nErr == 0) { + pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect); + if (pSelTab == null) + return; + Debug.Assert(p.aCol == null); + p.nCol = pSelTab.nCol; + p.aCol = pSelTab.aCol; + pSelTab.nCol = 0; + pSelTab.aCol = null; + sqlite3DeleteTable(db, ref pSelTab); + } + } + + /* Compute the complete text of the CREATE statement */ + if (pSelect != null) { + zStmt = createTableStmt(db, p); + } else { + n = (int)(pParse.sNameToken.z.Length - pEnd.z.Length) + 1; + zStmt = sqlite3MPrintf(db, + "CREATE %s %.*s", zType2, n, pParse.sNameToken.z + ); + } + + /* A slot for the record has already been allocated in the + ** SQLITE_MASTER table. We just need to update that slot with all + ** the information we've collected. + */ + sqlite3NestedParse(pParse, + "UPDATE %Q.%s " + + "SET type='%s', name=%Q, tbl_name=%Q, rootpage=#%d, sql=%Q " + + "WHERE rowid=#%d", + db.aDb[iDb].zName, SCHEMA_TABLE(iDb), + zType, + p.zName, + p.zName, + pParse.regRoot, + zStmt, + pParse.regRowid + ); + sqlite3DbFree(db, ref zStmt); + sqlite3ChangeCookie(pParse, iDb); #if !SQLITE_OMIT_AUTOINCREMENT - /* Check to see if we need to create an sqlite_sequence table for -** keeping track of autoincrement keys. -*/ - if ( ( p.tabFlags & TF_Autoincrement ) != 0 ) - { - Db pDb = db.aDb[iDb]; - Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); - if ( pDb.pSchema.pSeqTab == null ) - { - sqlite3NestedParse( pParse, - "CREATE TABLE %Q.sqlite_sequence(name,seq)", - pDb.zName - ); - } - } + /* Check to see if we need to create an sqlite_sequence table for + ** keeping track of autoincrement keys. + */ + if ((p.tabFlags & TF_Autoincrement) != 0) { + Db pDb = db.aDb[iDb]; + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + if (pDb.pSchema.pSeqTab == null) { + sqlite3NestedParse(pParse, + "CREATE TABLE %Q.sqlite_sequence(name,seq)", + pDb.zName + ); + } + } #endif - /* Reparse everything to update our internal data structures */ - sqlite3VdbeAddParseSchemaOp( v, iDb, - sqlite3MPrintf( db, "tbl_name='%q'", p.zName ) ); - } + /* Reparse everything to update our internal data structures */ + sqlite3VdbeAddParseSchemaOp(v, iDb, + sqlite3MPrintf(db, "tbl_name='%q'", p.zName)); + } - /* Add the table to the in-memory representation of the database. - */ - if ( db.init.busy != 0 ) - { - Table pOld; - Schema pSchema = p.pSchema; - Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); - pOld = sqlite3HashInsert( ref pSchema.tblHash, p.zName, - sqlite3Strlen30( p.zName ), p ); - if ( pOld != null ) - { - Debug.Assert( p == pOld ); /* Malloc must have failed inside HashInsert() */ - // db.mallocFailed = 1; - return; - } - pParse.pNewTable = null; - db.nTable++; - db.flags |= SQLITE_InternChanges; + /* Add the table to the in-memory representation of the database. + */ + if (db.init.busy != 0) { + Table pOld; + Schema pSchema = p.pSchema; + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + pOld = sqlite3HashInsert(ref pSchema.tblHash, p.zName, + sqlite3Strlen30(p.zName), p); + if (pOld != null) { + Debug.Assert(p == pOld); /* Malloc must have failed inside HashInsert() */ + // db.mallocFailed = 1; + return; + } + pParse.pNewTable = null; + db.nTable++; + db.flags |= SQLITE_InternChanges; #if !SQLITE_OMIT_ALTERTABLE - if ( p.pSelect == null ) - { - string zName = pParse.sNameToken.z; - int nName; - Debug.Assert( pSelect == null && pCons != null && pEnd != null ); - if ( pCons.z == null ) - { - pCons = pEnd; - } - nName = zName.Length - pCons.z.Length; - p.addColOffset = 13 + nName; // sqlite3Utf8CharLen(zName, nName); - } + if (p.pSelect == null) { + string zName = pParse.sNameToken.z; + int nName; + Debug.Assert(pSelect == null && pCons != null && pEnd != null); + if (pCons.z == null) { + pCons = pEnd; + } + nName = zName.Length - pCons.z.Length; + p.addColOffset = 13 + nName; // sqlite3Utf8CharLen(zName, nName); + } #endif - } - } + } + } #if !SQLITE_OMIT_VIEW - /* -** The parser calls this routine in order to create a new VIEW -*/ - static void sqlite3CreateView( - Parse pParse, /* The parsing context */ - Token pBegin, /* The CREATE token that begins the statement */ - Token pName1, /* The token that holds the name of the view */ - Token pName2, /* The token that holds the name of the view */ - Select pSelect, /* A SELECT statement that will become the new view */ - int isTemp, /* TRUE for a TEMPORARY view */ - int noErr /* Suppress error messages if VIEW already exists */ - ) - { - Table p; - int n; - string z;//string z; - Token sEnd; - DbFixer sFix = new DbFixer(); - Token pName = null; - int iDb; - sqlite3 db = pParse.db; - - if ( pParse.nVar > 0 ) - { - sqlite3ErrorMsg( pParse, "parameters are not allowed in views" ); - sqlite3SelectDelete( db, ref pSelect ); - return; - } - sqlite3StartTable( pParse, pName1, pName2, isTemp, 1, 0, noErr ); - p = pParse.pNewTable; - if ( p == null || pParse.nErr != 0 ) - { - sqlite3SelectDelete( db, ref pSelect ); - return; - } - sqlite3TwoPartName( pParse, pName1, pName2, ref pName ); - iDb = sqlite3SchemaToIndex( db, p.pSchema ); - if ( sqlite3FixInit( sFix, pParse, iDb, "view", pName ) != 0 - && sqlite3FixSelect( sFix, pSelect ) != 0 - ) - { - sqlite3SelectDelete( db, ref pSelect ); - return; - } - - /* Make a copy of the entire SELECT statement that defines the view. - ** This will force all the Expr.token.z values to be dynamically - ** allocated rather than point to the input string - which means that - ** they will persist after the current sqlite3_exec() call returns. - */ - p.pSelect = sqlite3SelectDup( db, pSelect, EXPRDUP_REDUCE ); - sqlite3SelectDelete( db, ref pSelect ); - //if ( db.mallocFailed != 0 ) - //{ - // return; - //} - if ( 0 == db.init.busy ) - { - sqlite3ViewGetColumnNames( pParse, p ); - } - - /* Locate the end of the CREATE VIEW statement. Make sEnd point to - ** the end. - */ - sEnd = pParse.sLastToken; - if ( ALWAYS( sEnd.z[0] != 0 ) && sEnd.z[0] != ';' ) - { - sEnd.z = sEnd.z.Substring( sEnd.n ); - } - sEnd.n = 0; - n = (int)( pBegin.z.Length - sEnd.z.Length );//sEnd.z - pBegin.z; - z = pBegin.z; - while ( ALWAYS( n > 0 ) && sqlite3Isspace( z[n - 1] ) ) - { - n--; - } - sEnd.z = z.Substring( n - 1 ); - sEnd.n = 1; - - /* Use sqlite3EndTable() to add the view to the SQLITE_MASTER table */ - sqlite3EndTable( pParse, null, sEnd, null ); - return; - } + /* + ** The parser calls this routine in order to create a new VIEW + */ + static void sqlite3CreateView( + Parse pParse, /* The parsing context */ + Token pBegin, /* The CREATE token that begins the statement */ + Token pName1, /* The token that holds the name of the view */ + Token pName2, /* The token that holds the name of the view */ + Select pSelect, /* A SELECT statement that will become the new view */ + int isTemp, /* TRUE for a TEMPORARY view */ + int noErr /* Suppress error messages if VIEW already exists */ + ) { + Table p; + int n; + string z;//string z; + Token sEnd; + DbFixer sFix = new DbFixer(); + Token pName = null; + int iDb; + sqlite3 db = pParse.db; + + if (pParse.nVar > 0) { + sqlite3ErrorMsg(pParse, "parameters are not allowed in views"); + sqlite3SelectDelete(db, ref pSelect); + return; + } + sqlite3StartTable(pParse, pName1, pName2, isTemp, 1, 0, noErr); + p = pParse.pNewTable; + if (p == null || pParse.nErr != 0) { + sqlite3SelectDelete(db, ref pSelect); + return; + } + sqlite3TwoPartName(pParse, pName1, pName2, ref pName); + iDb = sqlite3SchemaToIndex(db, p.pSchema); + if (sqlite3FixInit(sFix, pParse, iDb, "view", pName) != 0 + && sqlite3FixSelect(sFix, pSelect) != 0 + ) { + sqlite3SelectDelete(db, ref pSelect); + return; + } + + /* Make a copy of the entire SELECT statement that defines the view. + ** This will force all the Expr.token.z values to be dynamically + ** allocated rather than point to the input string - which means that + ** they will persist after the current sqlite3_exec() call returns. + */ + p.pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE); + sqlite3SelectDelete(db, ref pSelect); + //if ( db.mallocFailed != 0 ) + //{ + // return; + //} + if (0 == db.init.busy) { + sqlite3ViewGetColumnNames(pParse, p); + } + + /* Locate the end of the CREATE VIEW statement. Make sEnd point to + ** the end. + */ + sEnd = pParse.sLastToken; + if (ALWAYS(sEnd.z[0] != 0) && sEnd.z[0] != ';') { + sEnd.z = sEnd.z.Substring(sEnd.n); + } + sEnd.n = 0; + n = (int)(pBegin.z.Length - sEnd.z.Length);//sEnd.z - pBegin.z; + z = pBegin.z; + while (ALWAYS(n > 0) && sqlite3Isspace(z[n - 1])) { + n--; + } + sEnd.z = z.Substring(n - 1); + sEnd.n = 1; + + /* Use sqlite3EndTable() to add the view to the SQLITE_MASTER table */ + sqlite3EndTable(pParse, null, sEnd, null); + return; + } #else static void sqlite3CreateView( Parse pParse, /* The parsing context */ @@ -2064,137 +1889,125 @@ static void sqlite3CreateView( #endif // * SQLITE_OMIT_VIEW */ #if !SQLITE_OMIT_VIEW || !SQLITE_OMIT_VIRTUALTABLE - /* -** The Table structure pTable is really a VIEW. Fill in the names of -** the columns of the view in the pTable structure. Return the number -** of errors. If an error is seen leave an error message in pParse.zErrMsg. -*/ - static int sqlite3ViewGetColumnNames( Parse pParse, Table pTable ) - { - Table pSelTab; /* A fake table from which we get the result set */ - Select pSel; /* Copy of the SELECT that implements the view */ - int nErr = 0; /* Number of errors encountered */ - int n; /* Temporarily holds the number of cursors assigned */ - sqlite3 db = pParse.db; /* Database connection for malloc errors */ - dxAuth xAuth; //)(void*,int,const char*,const char*,const char*,const char); + /* + ** The Table structure pTable is really a VIEW. Fill in the names of + ** the columns of the view in the pTable structure. Return the number + ** of errors. If an error is seen leave an error message in pParse.zErrMsg. + */ + static int sqlite3ViewGetColumnNames(Parse pParse, Table pTable) { + Table pSelTab; /* A fake table from which we get the result set */ + Select pSel; /* Copy of the SELECT that implements the view */ + int nErr = 0; /* Number of errors encountered */ + int n; /* Temporarily holds the number of cursors assigned */ + sqlite3 db = pParse.db; /* Database connection for malloc errors */ + dxAuth xAuth; //)(void*,int,const char*,const char*,const char*,const char); - Debug.Assert( pTable != null ); + Debug.Assert(pTable != null); #if !SQLITE_OMIT_VIRTUALTABLE -if ( sqlite3VtabCallConnect( pParse, pTable )!=0 ) -{ -return SQLITE_ERROR; -} + if (sqlite3VtabCallConnect(pParse, pTable) != 0) { + return SQLITE_ERROR; + } #endif - if ( IsVirtual( pTable ) ) - return 0; + if (IsVirtual(pTable)) + return 0; #if !SQLITE_OMIT_VIEW - /* A positive nCol means the columns names for this view are -** already known. -*/ - if ( pTable.nCol > 0 ) - return 0; - - /* A negative nCol is a special marker meaning that we are currently - ** trying to compute the column names. If we enter this routine with - ** a negative nCol, it means two or more views form a loop, like this: - ** - ** CREATE VIEW one AS SELECT * FROM two; - ** CREATE VIEW two AS SELECT * FROM one; - ** - ** Actually, the error above is now caught prior to reaching this point. - ** But the following test is still important as it does come up - ** in the following: - ** - ** CREATE TABLE main.ex1(a); - ** CREATE TEMP VIEW ex1 AS SELECT a FROM ex1; - ** SELECT * FROM temp.ex1; - */ - if ( pTable.nCol < 0 ) - { - sqlite3ErrorMsg( pParse, "view %s is circularly defined", pTable.zName ); - return 1; - } - Debug.Assert( pTable.nCol >= 0 ); - - /* If we get this far, it means we need to compute the table names. - ** Note that the call to sqlite3ResultSetOfSelect() will expand any - ** "*" elements in the results set of the view and will assign cursors - ** to the elements of the FROM clause. But we do not want these changes - ** to be permanent. So the computation is done on a copy of the SELECT - ** statement that defines the view. + /* A positive nCol means the columns names for this view are + ** already known. */ - Debug.Assert( pTable.pSelect != null ); - pSel = sqlite3SelectDup( db, pTable.pSelect, 0 ); - if ( pSel != null ) - { - u8 enableLookaside = db.lookaside.bEnabled; - n = pParse.nTab; - sqlite3SrcListAssignCursors( pParse, pSel.pSrc ); - pTable.nCol = -1; - db.lookaside.bEnabled = 0; + if (pTable.nCol > 0) + return 0; + + /* A negative nCol is a special marker meaning that we are currently + ** trying to compute the column names. If we enter this routine with + ** a negative nCol, it means two or more views form a loop, like this: + ** + ** CREATE VIEW one AS SELECT * FROM two; + ** CREATE VIEW two AS SELECT * FROM one; + ** + ** Actually, the error above is now caught prior to reaching this point. + ** But the following test is still important as it does come up + ** in the following: + ** + ** CREATE TABLE main.ex1(a); + ** CREATE TEMP VIEW ex1 AS SELECT a FROM ex1; + ** SELECT * FROM temp.ex1; + */ + if (pTable.nCol < 0) { + sqlite3ErrorMsg(pParse, "view %s is circularly defined", pTable.zName); + return 1; + } + Debug.Assert(pTable.nCol >= 0); + + /* If we get this far, it means we need to compute the table names. + ** Note that the call to sqlite3ResultSetOfSelect() will expand any + ** "*" elements in the results set of the view and will assign cursors + ** to the elements of the FROM clause. But we do not want these changes + ** to be permanent. So the computation is done on a copy of the SELECT + ** statement that defines the view. + */ + Debug.Assert(pTable.pSelect != null); + pSel = sqlite3SelectDup(db, pTable.pSelect, 0); + if (pSel != null) { + u8 enableLookaside = db.lookaside.bEnabled; + n = pParse.nTab; + sqlite3SrcListAssignCursors(pParse, pSel.pSrc); + pTable.nCol = -1; + db.lookaside.bEnabled = 0; #if !SQLITE_OMIT_AUTHORIZATION xAuth = db.xAuth; db.xAuth = 0; pSelTab = sqlite3ResultSetOfSelect(pParse, pSel); db.xAuth = xAuth; #else - pSelTab = sqlite3ResultSetOfSelect( pParse, pSel ); + pSelTab = sqlite3ResultSetOfSelect(pParse, pSel); #endif - db.lookaside.bEnabled = enableLookaside; - pParse.nTab = n; - if ( pSelTab != null ) - { - Debug.Assert( pTable.aCol == null ); - pTable.nCol = pSelTab.nCol; - pTable.aCol = pSelTab.aCol; - pSelTab.nCol = 0; - pSelTab.aCol = null; - sqlite3DeleteTable( db, ref pSelTab ); - Debug.Assert( sqlite3SchemaMutexHeld( db, 0, pTable.pSchema ) ); - pTable.pSchema.flags |= DB_UnresetViews; - } - else - { - pTable.nCol = 0; - nErr++; - } - sqlite3SelectDelete( db, ref pSel ); - } - else - { - nErr++; - } + db.lookaside.bEnabled = enableLookaside; + pParse.nTab = n; + if (pSelTab != null) { + Debug.Assert(pTable.aCol == null); + pTable.nCol = pSelTab.nCol; + pTable.aCol = pSelTab.aCol; + pSelTab.nCol = 0; + pSelTab.aCol = null; + sqlite3DeleteTable(db, ref pSelTab); + Debug.Assert(sqlite3SchemaMutexHeld(db, 0, pTable.pSchema)); + pTable.pSchema.flags |= DB_UnresetViews; + } else { + pTable.nCol = 0; + nErr++; + } + sqlite3SelectDelete(db, ref pSel); + } else { + nErr++; + } #endif // * SQLITE_OMIT_VIEW */ - return nErr; - } + return nErr; + } #endif // * !SQLITE_OMIT_VIEW) || !SQLITE_OMIT_VIRTUALTABLE) */ #if !SQLITE_OMIT_VIEW - /* -** Clear the column names from every VIEW in database idx. -*/ - static void sqliteViewResetAll( sqlite3 db, int idx ) - { - HashElem i; - Debug.Assert( sqlite3SchemaMutexHeld( db, idx, null ) ); - if ( !DbHasProperty( db, idx, DB_UnresetViews ) ) - return; - //for(i=sqliteHashFirst(&db.aDb[idx].pSchema.tblHash); i;i=sqliteHashNext(i)){ - for ( i = db.aDb[idx].pSchema.tblHash.first; i != null; i = i.next ) - { - Table pTab = (Table)i.data;// sqliteHashData( i ); - if ( pTab.pSelect != null ) - { - sqliteDeleteColumnNames( db, pTab ); - pTab.aCol = null; - pTab.nCol = 0; - + /* + ** Clear the column names from every VIEW in database idx. + */ + static void sqliteViewResetAll(sqlite3 db, int idx) { + HashElem i; + Debug.Assert(sqlite3SchemaMutexHeld(db, idx, null)); + if (!DbHasProperty(db, idx, DB_UnresetViews)) + return; + //for(i=sqliteHashFirst(&db.aDb[idx].pSchema.tblHash); i;i=sqliteHashNext(i)){ + for (i = db.aDb[idx].pSchema.tblHash.first; i != null; i = i.next) { + Table pTab = (Table)i.data;// sqliteHashData( i ); + if (pTab.pSelect != null) { + sqliteDeleteColumnNames(db, pTab); + pTab.aCol = null; + pTab.nCol = 0; + + } + } + DbClearProperty(db, idx, DB_UnresetViews); } - } - DbClearProperty( db, idx, DB_UnresetViews ); - } #else //# define sqliteViewResetAll(A,B) static void sqliteViewResetAll( sqlite3 A, int B ) @@ -2202,92 +2015,87 @@ static void sqliteViewResetAll( sqlite3 A, int B ) } #endif // * SQLITE_OMIT_VIEW */ - /* -** This function is called by the VDBE to adjust the internal schema -** used by SQLite when the btree layer moves a table root page. The -** root-page of a table or index in database iDb has changed from iFrom -** to iTo. -** -** Ticket #1728: The symbol table might still contain information -** on tables and/or indices that are the process of being deleted. -** If you are unlucky, one of those deleted indices or tables might -** have the same rootpage number as the real table or index that is -** being moved. So we cannot stop searching after the first match -** because the first match might be for one of the deleted indices -** or tables and not the table/index that is actually being moved. -** We must continue looping until all tables and indices with -** rootpage==iFrom have been converted to have a rootpage of iTo -** in order to be certain that we got the right one. -*/ + /* + ** This function is called by the VDBE to adjust the internal schema + ** used by SQLite when the btree layer moves a table root page. The + ** root-page of a table or index in database iDb has changed from iFrom + ** to iTo. + ** + ** Ticket #1728: The symbol table might still contain information + ** on tables and/or indices that are the process of being deleted. + ** If you are unlucky, one of those deleted indices or tables might + ** have the same rootpage number as the real table or index that is + ** being moved. So we cannot stop searching after the first match + ** because the first match might be for one of the deleted indices + ** or tables and not the table/index that is actually being moved. + ** We must continue looping until all tables and indices with + ** rootpage==iFrom have been converted to have a rootpage of iTo + ** in order to be certain that we got the right one. + */ #if !SQLITE_OMIT_AUTOVACUUM - static void sqlite3RootPageMoved( sqlite3 db, int iDb, int iFrom, int iTo ) - { - HashElem pElem; - Hash pHash; - Db pDb; - - Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); - pDb = db.aDb[iDb]; - - pHash = pDb.pSchema.tblHash; - for ( pElem = pHash.first; pElem != null; pElem = pElem.next )// ( pElem = sqliteHashFirst( pHash ) ; pElem ; pElem = sqliteHashNext( pElem ) ) - { - Table pTab = (Table)pElem.data;// sqliteHashData( pElem ); - if ( pTab.tnum == iFrom ) - { - pTab.tnum = iTo; - } - } - pHash = pDb.pSchema.idxHash; - for ( pElem = pHash.first; pElem != null; pElem = pElem.next )// ( pElem = sqliteHashFirst( pHash ) ; pElem ; pElem = sqliteHashNext( pElem ) ) - { - Index pIdx = (Index)pElem.data;// sqliteHashData( pElem ); - if ( pIdx.tnum == iFrom ) - { - pIdx.tnum = iTo; + static void sqlite3RootPageMoved(sqlite3 db, int iDb, int iFrom, int iTo) { + HashElem pElem; + Hash pHash; + Db pDb; + + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + pDb = db.aDb[iDb]; + + pHash = pDb.pSchema.tblHash; + for (pElem = pHash.first; pElem != null; pElem = pElem.next)// ( pElem = sqliteHashFirst( pHash ) ; pElem ; pElem = sqliteHashNext( pElem ) ) + { + Table pTab = (Table)pElem.data;// sqliteHashData( pElem ); + if (pTab.tnum == iFrom) { + pTab.tnum = iTo; + } + } + pHash = pDb.pSchema.idxHash; + for (pElem = pHash.first; pElem != null; pElem = pElem.next)// ( pElem = sqliteHashFirst( pHash ) ; pElem ; pElem = sqliteHashNext( pElem ) ) + { + Index pIdx = (Index)pElem.data;// sqliteHashData( pElem ); + if (pIdx.tnum == iFrom) { + pIdx.tnum = iTo; + } + } } - } - } #endif - /* -** Write code to erase the table with root-page iTable from database iDb. -** Also write code to modify the sqlite_master table and internal schema -** if a root-page of another table is moved by the btree-layer whilst -** erasing iTable (this can happen with an auto-vacuum database). -*/ - static void destroyRootPage( Parse pParse, int iTable, int iDb ) - { - Vdbe v = sqlite3GetVdbe( pParse ); - int r1 = sqlite3GetTempReg( pParse ); - sqlite3VdbeAddOp3( v, OP_Destroy, iTable, r1, iDb ); - sqlite3MayAbort( pParse ); + /* + ** Write code to erase the table with root-page iTable from database iDb. + ** Also write code to modify the sqlite_master table and internal schema + ** if a root-page of another table is moved by the btree-layer whilst + ** erasing iTable (this can happen with an auto-vacuum database). + */ + static void destroyRootPage(Parse pParse, int iTable, int iDb) { + Vdbe v = sqlite3GetVdbe(pParse); + int r1 = sqlite3GetTempReg(pParse); + sqlite3VdbeAddOp3(v, OP_Destroy, iTable, r1, iDb); + sqlite3MayAbort(pParse); #if !SQLITE_OMIT_AUTOVACUUM - /* OP_Destroy stores an in integer r1. If this integer -** is non-zero, then it is the root page number of a table moved to -** location iTable. The following code modifies the sqlite_master table to -** reflect this. -** -** The "#NNN" in the SQL is a special constant that means whatever value -** is in register NNN. See grammar rules associated with the TK_REGISTER -** token for additional information. -*/ - sqlite3NestedParse( pParse, - "UPDATE %Q.%s SET rootpage=%d WHERE #%d AND rootpage=#%d", - pParse.db.aDb[iDb].zName, SCHEMA_TABLE( iDb ), iTable, r1, r1 ); + /* OP_Destroy stores an in integer r1. If this integer + ** is non-zero, then it is the root page number of a table moved to + ** location iTable. The following code modifies the sqlite_master table to + ** reflect this. + ** + ** The "#NNN" in the SQL is a special constant that means whatever value + ** is in register NNN. See grammar rules associated with the TK_REGISTER + ** token for additional information. + */ + sqlite3NestedParse(pParse, + "UPDATE %Q.%s SET rootpage=%d WHERE #%d AND rootpage=#%d", + pParse.db.aDb[iDb].zName, SCHEMA_TABLE(iDb), iTable, r1, r1); #endif - sqlite3ReleaseTempReg( pParse, r1 ); - } + sqlite3ReleaseTempReg(pParse, r1); + } - /* - ** Write VDBE code to erase table pTab and all associated indices on disk. - ** Code to update the sqlite_master tables and internal schema definitions - ** in case a root-page belonging to another table is moved by the btree layer - ** is also added (this can happen with an auto-vacuum database). - */ - static void destroyTable( Parse pParse, Table pTab ) - { -#if SQLITE_OMIT_AUTOVACUUM + /* + ** Write VDBE code to erase table pTab and all associated indices on disk. + ** Code to update the sqlite_master tables and internal schema definitions + ** in case a root-page belonging to another table is moved by the btree layer + ** is also added (this can happen with an auto-vacuum database). + */ + static void destroyTable(Parse pParse, Table pTab) { +#if SQLITE_OMIT_AUTOVACUUM Index pIdx; int iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema ); destroyRootPage( pParse, pTab.tnum, iDb ); @@ -2296,97 +2104,87 @@ static void destroyTable( Parse pParse, Table pTab ) destroyRootPage( pParse, pIdx.tnum, iDb ); } #else - /* If the database may be auto-vacuum capable (if SQLITE_OMIT_AUTOVACUUM -** is not defined), then it is important to call OP_Destroy on the -** table and index root-pages in order, starting with the numerically -** largest root-page number. This guarantees that none of the root-pages -** to be destroyed is relocated by an earlier OP_Destroy. i.e. if the -** following were coded: -** -** OP_Destroy 4 0 -** ... -** OP_Destroy 5 0 -** -** and root page 5 happened to be the largest root-page number in the -** database, then root page 5 would be moved to page 4 by the -** "OP_Destroy 4 0" opcode. The subsequent "OP_Destroy 5 0" would hit -** a free-list page. -*/ - int iTab = pTab.tnum; - int iDestroyed = 0; - - while ( true ) - { - Index pIdx; - int iLargest = 0; - - if ( iDestroyed == 0 || iTab < iDestroyed ) - { - iLargest = iTab; - } - for ( pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext ) - { - int iIdx = pIdx.tnum; - Debug.Assert( pIdx.pSchema == pTab.pSchema ); - if ( ( iDestroyed == 0 || ( iIdx < iDestroyed ) ) && iIdx > iLargest ) - { - iLargest = iIdx; - } - } - if ( iLargest == 0 ) - { - return; - } - else - { - int iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema ); - destroyRootPage( pParse, iLargest, iDb ); - iDestroyed = iLargest; - } - } + /* If the database may be auto-vacuum capable (if SQLITE_OMIT_AUTOVACUUM + ** is not defined), then it is important to call OP_Destroy on the + ** table and index root-pages in order, starting with the numerically + ** largest root-page number. This guarantees that none of the root-pages + ** to be destroyed is relocated by an earlier OP_Destroy. i.e. if the + ** following were coded: + ** + ** OP_Destroy 4 0 + ** ... + ** OP_Destroy 5 0 + ** + ** and root page 5 happened to be the largest root-page number in the + ** database, then root page 5 would be moved to page 4 by the + ** "OP_Destroy 4 0" opcode. The subsequent "OP_Destroy 5 0" would hit + ** a free-list page. + */ + int iTab = pTab.tnum; + int iDestroyed = 0; + + while (true) { + Index pIdx; + int iLargest = 0; + + if (iDestroyed == 0 || iTab < iDestroyed) { + iLargest = iTab; + } + for (pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext) { + int iIdx = pIdx.tnum; + Debug.Assert(pIdx.pSchema == pTab.pSchema); + if ((iDestroyed == 0 || (iIdx < iDestroyed)) && iIdx > iLargest) { + iLargest = iIdx; + } + } + if (iLargest == 0) { + return; + } else { + int iDb = sqlite3SchemaToIndex(pParse.db, pTab.pSchema); + destroyRootPage(pParse, iLargest, iDb); + iDestroyed = iLargest; + } + } #endif - } + } - /* - ** This routine is called to do the work of a DROP TABLE statement. - ** pName is the name of the table to be dropped. - */ - static void sqlite3DropTable( Parse pParse, SrcList pName, int isView, int noErr ) - { - Table pTab; - Vdbe v; - sqlite3 db = pParse.db; - int iDb; - - //if ( db.mallocFailed != 0 ) - //{ - // goto exit_drop_table; - //} - Debug.Assert( pParse.nErr == 0 ); - Debug.Assert( pName.nSrc == 1 ); - if ( noErr != 0 ) - db.suppressErr++; - pTab = sqlite3LocateTable( pParse, isView, - pName.a[0].zName, pName.a[0].zDatabase ); - if ( noErr != 0 ) - db.suppressErr--; - - if ( pTab == null ) - { - if ( noErr != 0) - sqlite3CodeVerifyNamedSchema( pParse, pName.a[0].zDatabase ); - goto exit_drop_table; - } - iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); - Debug.Assert( iDb >= 0 && iDb < db.nDb ); - - /* If pTab is a virtual table, call ViewGetColumnNames() to ensure - ** it is initialized. - */ - if ( IsVirtual( pTab ) && sqlite3ViewGetColumnNames( pParse, pTab ) != 0 ) - { - goto exit_drop_table; - } + /* + ** This routine is called to do the work of a DROP TABLE statement. + ** pName is the name of the table to be dropped. + */ + static void sqlite3DropTable(Parse pParse, SrcList pName, int isView, int noErr) { + Table pTab; + Vdbe v; + sqlite3 db = pParse.db; + int iDb; + + //if ( db.mallocFailed != 0 ) + //{ + // goto exit_drop_table; + //} + Debug.Assert(pParse.nErr == 0); + Debug.Assert(pName.nSrc == 1); + if (noErr != 0) + db.suppressErr++; + pTab = sqlite3LocateTable(pParse, isView, + pName.a[0].zName, pName.a[0].zDatabase); + if (noErr != 0) + db.suppressErr--; + + if (pTab == null) { + if (noErr != 0) + sqlite3CodeVerifyNamedSchema(pParse, pName.a[0].zDatabase); + goto exit_drop_table; + } + iDb = sqlite3SchemaToIndex(db, pTab.pSchema); + Debug.Assert(iDb >= 0 && iDb < db.nDb); + + /* If pTab is a virtual table, call ViewGetColumnNames() to ensure + ** it is initialized. + */ + if (IsVirtual(pTab) && sqlite3ViewGetColumnNames(pParse, pTab) != 0) { + goto exit_drop_table; + } #if !SQLITE_OMIT_AUTHORIZATION { int code; @@ -2420,316 +2218,285 @@ static void sqlite3DropTable( Parse pParse, SrcList pName, int isView, int noErr } } #endif - if ( pTab.zName.StartsWith( "sqlite_", System.StringComparison.OrdinalIgnoreCase ) ) - { - sqlite3ErrorMsg( pParse, "table %s may not be dropped", pTab.zName ); - goto exit_drop_table; - } + if (pTab.zName.StartsWith("sqlite_", System.StringComparison.OrdinalIgnoreCase)) { + sqlite3ErrorMsg(pParse, "table %s may not be dropped", pTab.zName); + goto exit_drop_table; + } #if !SQLITE_OMIT_VIEW - /* Ensure DROP TABLE is not used on a view, and DROP VIEW is not used -** on a table. -*/ - if ( isView != 0 && pTab.pSelect == null ) - { - sqlite3ErrorMsg( pParse, "use DROP TABLE to delete table %s", pTab.zName ); - goto exit_drop_table; - } - if ( 0 == isView && pTab.pSelect != null ) - { - sqlite3ErrorMsg( pParse, "use DROP VIEW to delete view %s", pTab.zName ); - goto exit_drop_table; - } + /* Ensure DROP TABLE is not used on a view, and DROP VIEW is not used + ** on a table. + */ + if (isView != 0 && pTab.pSelect == null) { + sqlite3ErrorMsg(pParse, "use DROP TABLE to delete table %s", pTab.zName); + goto exit_drop_table; + } + if (0 == isView && pTab.pSelect != null) { + sqlite3ErrorMsg(pParse, "use DROP VIEW to delete view %s", pTab.zName); + goto exit_drop_table; + } #endif - /* Generate code to remove the table from the master table -** on disk. -*/ - v = sqlite3GetVdbe( pParse ); - if ( v != null ) - { - Trigger pTrigger; - Db pDb = db.aDb[iDb]; - sqlite3BeginWriteOperation( pParse, 1, iDb ); + /* Generate code to remove the table from the master table + ** on disk. + */ + v = sqlite3GetVdbe(pParse); + if (v != null) { + Trigger pTrigger; + Db pDb = db.aDb[iDb]; + sqlite3BeginWriteOperation(pParse, 1, iDb); #if !SQLITE_OMIT_VIRTUALTABLE - if ( IsVirtual( pTab ) ) - { - sqlite3VdbeAddOp0( v, OP_VBegin ); - } + if (IsVirtual(pTab)) { + sqlite3VdbeAddOp0(v, OP_VBegin); + } #endif - sqlite3FkDropTable( pParse, pName, pTab ); - - /* Drop all triggers associated with the table being dropped. Code - ** is generated to remove entries from sqlite_master and/or - ** sqlite_temp_master if required. - */ - pTrigger = sqlite3TriggerList( pParse, pTab ); - while ( pTrigger != null ) - { - Debug.Assert( pTrigger.pSchema == pTab.pSchema || - pTrigger.pSchema == db.aDb[1].pSchema ); - sqlite3DropTriggerPtr( pParse, pTrigger ); - pTrigger = pTrigger.pNext; - } + sqlite3FkDropTable(pParse, pName, pTab); + + /* Drop all triggers associated with the table being dropped. Code + ** is generated to remove entries from sqlite_master and/or + ** sqlite_temp_master if required. + */ + pTrigger = sqlite3TriggerList(pParse, pTab); + while (pTrigger != null) { + Debug.Assert(pTrigger.pSchema == pTab.pSchema || + pTrigger.pSchema == db.aDb[1].pSchema); + sqlite3DropTriggerPtr(pParse, pTrigger); + pTrigger = pTrigger.pNext; + } #if !SQLITE_OMIT_AUTOINCREMENT - /* Remove any entries of the sqlite_sequence table associated with -** the table being dropped. This is done before the table is dropped -** at the btree level, in case the sqlite_sequence table needs to -** move as a result of the drop (can happen in auto-vacuum mode). -*/ - if ( ( pTab.tabFlags & TF_Autoincrement ) != 0 ) - { - sqlite3NestedParse( pParse, - "DELETE FROM %s.sqlite_sequence WHERE name=%Q", - pDb.zName, pTab.zName - ); - } + /* Remove any entries of the sqlite_sequence table associated with + ** the table being dropped. This is done before the table is dropped + ** at the btree level, in case the sqlite_sequence table needs to + ** move as a result of the drop (can happen in auto-vacuum mode). + */ + if ((pTab.tabFlags & TF_Autoincrement) != 0) { + sqlite3NestedParse(pParse, + "DELETE FROM %s.sqlite_sequence WHERE name=%Q", + pDb.zName, pTab.zName + ); + } #endif - /* Drop all SQLITE_MASTER table and index entries that refer to the -** table. The program name loops through the master table and deletes -** every row that refers to a table of the same name as the one being -** dropped. Triggers are handled seperately because a trigger can be -** created in the temp database that refers to a table in another -** database. -*/ - sqlite3NestedParse( pParse, - "DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'", - pDb.zName, SCHEMA_TABLE( iDb ), pTab.zName ); - - /* Drop any statistics from the sqlite_stat1 table, if it exists */ - if ( sqlite3FindTable( db, "sqlite_stat1", db.aDb[iDb].zName ) != null ) - { - sqlite3NestedParse( pParse, - "DELETE FROM %Q.sqlite_stat1 WHERE tbl=%Q", pDb.zName, pTab.zName - ); - } + /* Drop all SQLITE_MASTER table and index entries that refer to the + ** table. The program name loops through the master table and deletes + ** every row that refers to a table of the same name as the one being + ** dropped. Triggers are handled seperately because a trigger can be + ** created in the temp database that refers to a table in another + ** database. + */ + sqlite3NestedParse(pParse, + "DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'", + pDb.zName, SCHEMA_TABLE(iDb), pTab.zName); + + /* Drop any statistics from the sqlite_stat1 table, if it exists */ + if (sqlite3FindTable(db, "sqlite_stat1", db.aDb[iDb].zName) != null) { + sqlite3NestedParse(pParse, + "DELETE FROM %Q.sqlite_stat1 WHERE tbl=%Q", pDb.zName, pTab.zName + ); + } + + if (0 == isView && !IsVirtual(pTab)) { + destroyTable(pParse, pTab); + } + + /* Remove the table entry from SQLite's internal schema and modify + ** the schema cookie. + */ + if (IsVirtual(pTab)) { + sqlite3VdbeAddOp4(v, OP_VDestroy, iDb, 0, 0, pTab.zName, 0); + } + sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab.zName, 0); + sqlite3ChangeCookie(pParse, iDb); + } + sqliteViewResetAll(db, iDb); - if ( 0 == isView && !IsVirtual( pTab ) ) - { - destroyTable( pParse, pTab ); + exit_drop_table: + sqlite3SrcListDelete(db, ref pName); } - /* Remove the table entry from SQLite's internal schema and modify - ** the schema cookie. + /* + ** This routine is called to create a new foreign key on the table + ** currently under construction. pFromCol determines which columns + ** in the current table point to the foreign key. If pFromCol==0 then + ** connect the key to the last column inserted. pTo is the name of + ** the table referred to. pToCol is a list of tables in the other + ** pTo table that the foreign key points to. flags contains all + ** information about the conflict resolution algorithms specified + ** in the ON DELETE, ON UPDATE and ON INSERT clauses. + ** + ** An FKey structure is created and added to the table currently + ** under construction in the pParse.pNewTable field. + ** + ** The foreign key is set for IMMEDIATE processing. A subsequent call + ** to sqlite3DeferForeignKey() might change this to DEFERRED. */ - if ( IsVirtual( pTab ) ) - { - sqlite3VdbeAddOp4( v, OP_VDestroy, iDb, 0, 0, pTab.zName, 0 ); - } - sqlite3VdbeAddOp4( v, OP_DropTable, iDb, 0, 0, pTab.zName, 0 ); - sqlite3ChangeCookie( pParse, iDb ); - } - sqliteViewResetAll( db, iDb ); - -exit_drop_table: - sqlite3SrcListDelete( db, ref pName ); - } - - /* - ** This routine is called to create a new foreign key on the table - ** currently under construction. pFromCol determines which columns - ** in the current table point to the foreign key. If pFromCol==0 then - ** connect the key to the last column inserted. pTo is the name of - ** the table referred to. pToCol is a list of tables in the other - ** pTo table that the foreign key points to. flags contains all - ** information about the conflict resolution algorithms specified - ** in the ON DELETE, ON UPDATE and ON INSERT clauses. - ** - ** An FKey structure is created and added to the table currently - ** under construction in the pParse.pNewTable field. - ** - ** The foreign key is set for IMMEDIATE processing. A subsequent call - ** to sqlite3DeferForeignKey() might change this to DEFERRED. - */ - // OVERLOADS, so I don't need to rewrite parse.c - static void sqlite3CreateForeignKey( Parse pParse, int null_2, Token pTo, ExprList pToCol, int flags ) - { - sqlite3CreateForeignKey( pParse, null, pTo, pToCol, flags ); - } - static void sqlite3CreateForeignKey( - Parse pParse, /* Parsing context */ - ExprList pFromCol, /* Columns in this table that point to other table */ - Token pTo, /* Name of the other table */ - ExprList pToCol, /* Columns in the other table */ - int flags /* Conflict resolution algorithms. */ - ) - { - sqlite3 db = pParse.db; + // OVERLOADS, so I don't need to rewrite parse.c + static void sqlite3CreateForeignKey(Parse pParse, int null_2, Token pTo, ExprList pToCol, int flags) { + sqlite3CreateForeignKey(pParse, null, pTo, pToCol, flags); + } + static void sqlite3CreateForeignKey( + Parse pParse, /* Parsing context */ + ExprList pFromCol, /* Columns in this table that point to other table */ + Token pTo, /* Name of the other table */ + ExprList pToCol, /* Columns in the other table */ + int flags /* Conflict resolution algorithms. */ + ) { + sqlite3 db = pParse.db; #if !SQLITE_OMIT_FOREIGN_KEY - FKey pFKey = null; - FKey pNextTo; - Table p = pParse.pNewTable; - int nByte; - int i; - int nCol; - //string z; - - Debug.Assert( pTo != null ); - if ( p == null || IN_DECLARE_VTAB( pParse ) ) - goto fk_end; - if ( pFromCol == null ) - { - int iCol = p.nCol - 1; - if ( NEVER( iCol < 0 ) ) - goto fk_end; - if ( pToCol != null && pToCol.nExpr != 1 ) - { - sqlite3ErrorMsg( pParse, "foreign key on %s" + - " should reference only one column of table %T", - p.aCol[iCol].zName, pTo ); - goto fk_end; - } - nCol = 1; - } - else if ( pToCol != null && pToCol.nExpr != pFromCol.nExpr ) - { - sqlite3ErrorMsg( pParse, - "number of columns in foreign key does not match the number of " + - "columns in the referenced table" ); - goto fk_end; - } - else - { - nCol = pFromCol.nExpr; - } - //nByte = sizeof(*pFKey) + (nCol-1)*sizeof(pFKey.aCol[0]) + pTo.n + 1; - //if( pToCol ){ - // for(i=0; ia[i].zName) + 1; - // } - //} - pFKey = new FKey();//sqlite3DbMallocZero(db, nByte ); - if ( pFKey == null ) - { - goto fk_end; - } - pFKey.pFrom = p; - pFKey.pNextFrom = p.pFKey; - //z = pFKey.aCol[nCol].zCol; - pFKey.aCol = new FKey.sColMap[nCol];// z; - pFKey.aCol[0] = new FKey.sColMap(); - pFKey.zTo = pTo.z.Substring( 0, pTo.n ); //memcpy( z, pTo.z, pTo.n ); - //z[pTo.n] = 0; - sqlite3Dequote( ref pFKey.zTo ); - //z += pTo.n + 1; - pFKey.nCol = nCol; - if ( pFromCol == null ) - { - pFKey.aCol[0].iFrom = p.nCol - 1; - } - else - { - for ( i = 0; i < nCol; i++ ) - { - if ( pFKey.aCol[i] == null ) - pFKey.aCol[i] = new FKey.sColMap(); - int j; - for ( j = 0; j < p.nCol; j++ ) - { - if ( p.aCol[j].zName.Equals( pFromCol.a[i].zName, StringComparison.OrdinalIgnoreCase ) ) - { - pFKey.aCol[i].iFrom = j; - break; - } - } - if ( j >= p.nCol ) - { - sqlite3ErrorMsg( pParse, - "unknown column \"%s\" in foreign key definition", - pFromCol.a[i].zName ); - goto fk_end; - } - } - } - if ( pToCol != null ) - { - for ( i = 0; i < nCol; i++ ) - { - ////int n = sqlite3Strlen30( pToCol.a[i].zName ); - if ( pFKey.aCol[i] == null ) - pFKey.aCol[i] = new FKey.sColMap(); - pFKey.aCol[i].zCol = pToCol.a[i].zName; - //memcpy( z, pToCol.a[i].zName, n ); - //z[n] = 0; - //z += n + 1; - } - } - pFKey.isDeferred = 0; - pFKey.aAction[0] = (u8)( flags & 0xff ); /* ON DELETE action */ - pFKey.aAction[1] = (u8)( ( flags >> 8 ) & 0xff ); /* ON UPDATE action */ - - Debug.Assert( sqlite3SchemaMutexHeld( db, 0, p.pSchema ) ); - pNextTo = sqlite3HashInsert( ref p.pSchema.fkeyHash, - pFKey.zTo, sqlite3Strlen30( pFKey.zTo ), pFKey - ); - //if( pNextTo==pFKey ){ - // db.mallocFailed = 1; - // goto fk_end; - //} - if ( pNextTo != null ) - { - Debug.Assert( pNextTo.pPrevTo == null ); - pFKey.pNextTo = pNextTo; - pNextTo.pPrevTo = pFKey; - } - /* Link the foreign key to the table as the last step. - */ - p.pFKey = pFKey; - pFKey = null; + FKey pFKey = null; + FKey pNextTo; + Table p = pParse.pNewTable; + int nByte; + int i; + int nCol; + //string z; + + Debug.Assert(pTo != null); + if (p == null || IN_DECLARE_VTAB(pParse)) + goto fk_end; + if (pFromCol == null) { + int iCol = p.nCol - 1; + if (NEVER(iCol < 0)) + goto fk_end; + if (pToCol != null && pToCol.nExpr != 1) { + sqlite3ErrorMsg(pParse, "foreign key on %s" + + " should reference only one column of table %T", + p.aCol[iCol].zName, pTo); + goto fk_end; + } + nCol = 1; + } else if (pToCol != null && pToCol.nExpr != pFromCol.nExpr) { + sqlite3ErrorMsg(pParse, + "number of columns in foreign key does not match the number of " + + "columns in the referenced table"); + goto fk_end; + } else { + nCol = pFromCol.nExpr; + } + //nByte = sizeof(*pFKey) + (nCol-1)*sizeof(pFKey.aCol[0]) + pTo.n + 1; + //if( pToCol ){ + // for(i=0; ia[i].zName) + 1; + // } + //} + pFKey = new FKey();//sqlite3DbMallocZero(db, nByte ); + if (pFKey == null) { + goto fk_end; + } + pFKey.pFrom = p; + pFKey.pNextFrom = p.pFKey; + //z = pFKey.aCol[nCol].zCol; + pFKey.aCol = new FKey.sColMap[nCol];// z; + pFKey.aCol[0] = new FKey.sColMap(); + pFKey.zTo = pTo.z.Substring(0, pTo.n); //memcpy( z, pTo.z, pTo.n ); + //z[pTo.n] = 0; + sqlite3Dequote(ref pFKey.zTo); + //z += pTo.n + 1; + pFKey.nCol = nCol; + if (pFromCol == null) { + pFKey.aCol[0].iFrom = p.nCol - 1; + } else { + for (i = 0; i < nCol; i++) { + if (pFKey.aCol[i] == null) + pFKey.aCol[i] = new FKey.sColMap(); + int j; + for (j = 0; j < p.nCol; j++) { + if (p.aCol[j].zName.Equals(pFromCol.a[i].zName, StringComparison.OrdinalIgnoreCase)) { + pFKey.aCol[i].iFrom = j; + break; + } + } + if (j >= p.nCol) { + sqlite3ErrorMsg(pParse, + "unknown column \"%s\" in foreign key definition", + pFromCol.a[i].zName); + goto fk_end; + } + } + } + if (pToCol != null) { + for (i = 0; i < nCol; i++) { + ////int n = sqlite3Strlen30( pToCol.a[i].zName ); + if (pFKey.aCol[i] == null) + pFKey.aCol[i] = new FKey.sColMap(); + pFKey.aCol[i].zCol = pToCol.a[i].zName; + //memcpy( z, pToCol.a[i].zName, n ); + //z[n] = 0; + //z += n + 1; + } + } + pFKey.isDeferred = 0; + pFKey.aAction[0] = (u8)(flags & 0xff); /* ON DELETE action */ + pFKey.aAction[1] = (u8)((flags >> 8) & 0xff); /* ON UPDATE action */ + + Debug.Assert(sqlite3SchemaMutexHeld(db, 0, p.pSchema)); + pNextTo = sqlite3HashInsert(ref p.pSchema.fkeyHash, + pFKey.zTo, sqlite3Strlen30(pFKey.zTo), pFKey + ); + //if( pNextTo==pFKey ){ + // db.mallocFailed = 1; + // goto fk_end; + //} + if (pNextTo != null) { + Debug.Assert(pNextTo.pPrevTo == null); + pFKey.pNextTo = pNextTo; + pNextTo.pPrevTo = pFKey; + } + /* Link the foreign key to the table as the last step. + */ + p.pFKey = pFKey; + pFKey = null; -fk_end: - sqlite3DbFree( db, ref pFKey ); + fk_end: + sqlite3DbFree(db, ref pFKey); #endif // * !SQLITE_OMIT_FOREIGN_KEY) */ - sqlite3ExprListDelete( db, ref pFromCol ); - sqlite3ExprListDelete( db, ref pToCol ); - } + sqlite3ExprListDelete(db, ref pFromCol); + sqlite3ExprListDelete(db, ref pToCol); + } - /* - ** This routine is called when an INITIALLY IMMEDIATE or INITIALLY DEFERRED - ** clause is seen as part of a foreign key definition. The isDeferred - ** parameter is 1 for INITIALLY DEFERRED and 0 for INITIALLY IMMEDIATE. - ** The behavior of the most recently created foreign key is adjusted - ** accordingly. - */ - static void sqlite3DeferForeignKey( Parse pParse, int isDeferred ) - { + /* + ** This routine is called when an INITIALLY IMMEDIATE or INITIALLY DEFERRED + ** clause is seen as part of a foreign key definition. The isDeferred + ** parameter is 1 for INITIALLY DEFERRED and 0 for INITIALLY IMMEDIATE. + ** The behavior of the most recently created foreign key is adjusted + ** accordingly. + */ + static void sqlite3DeferForeignKey(Parse pParse, int isDeferred) { #if !SQLITE_OMIT_FOREIGN_KEY - Table pTab; - FKey pFKey; - if ( ( pTab = pParse.pNewTable ) == null || ( pFKey = pTab.pFKey ) == null ) - return; - Debug.Assert( isDeferred == 0 || isDeferred == 1 ); /* EV: R-30323-21917 */ - pFKey.isDeferred = (u8)isDeferred; + Table pTab; + FKey pFKey; + if ((pTab = pParse.pNewTable) == null || (pFKey = pTab.pFKey) == null) + return; + Debug.Assert(isDeferred == 0 || isDeferred == 1); /* EV: R-30323-21917 */ + pFKey.isDeferred = (u8)isDeferred; #endif - } + } - /* - ** Generate code that will erase and refill index pIdx. This is - ** used to initialize a newly created index or to recompute the - ** content of an index in response to a REINDEX command. - ** - ** if memRootPage is not negative, it means that the index is newly - ** created. The register specified by memRootPage contains the - ** root page number of the index. If memRootPage is negative, then - ** the index already exists and must be cleared before being refilled and - ** the root page number of the index is taken from pIndex.tnum. - */ - static void sqlite3RefillIndex( Parse pParse, Index pIndex, int memRootPage ) - { - Table pTab = pIndex.pTable; /* The table that is indexed */ - int iTab = pParse.nTab++; /* Btree cursor used for pTab */ - int iIdx = pParse.nTab++; /* Btree cursor used for pIndex */ - int addr1; /* Address of top of loop */ - int tnum; /* Root page of index */ - Vdbe v; /* Generate code into this virtual machine */ - KeyInfo pKey; /* KeyInfo for index */ - int regIdxKey; /* Registers containing the index key */ - int regRecord; /* Register holding assemblied index record */ - sqlite3 db = pParse.db; /* The database connection */ - int iDb = sqlite3SchemaToIndex( db, pIndex.pSchema ); + /* + ** Generate code that will erase and refill index pIdx. This is + ** used to initialize a newly created index or to recompute the + ** content of an index in response to a REINDEX command. + ** + ** if memRootPage is not negative, it means that the index is newly + ** created. The register specified by memRootPage contains the + ** root page number of the index. If memRootPage is negative, then + ** the index already exists and must be cleared before being refilled and + ** the root page number of the index is taken from pIndex.tnum. + */ + static void sqlite3RefillIndex(Parse pParse, Index pIndex, int memRootPage) { + Table pTab = pIndex.pTable; /* The table that is indexed */ + int iTab = pParse.nTab++; /* Btree cursor used for pTab */ + int iIdx = pParse.nTab++; /* Btree cursor used for pIndex */ + int addr1; /* Address of top of loop */ + int tnum; /* Root page of index */ + Vdbe v; /* Generate code into this virtual machine */ + KeyInfo pKey; /* KeyInfo for index */ + int regIdxKey; /* Registers containing the index key */ + int regRecord; /* Register holding assemblied index record */ + sqlite3 db = pParse.db; /* The database connection */ + int iDb = sqlite3SchemaToIndex(db, pIndex.pSchema); #if !SQLITE_OMIT_AUTHORIZATION if( sqlite3AuthCheck(pParse, SQLITE_REINDEX, pIndex.zName, 0, @@ -2738,263 +2505,232 @@ static void sqlite3RefillIndex( Parse pParse, Index pIndex, int memRootPage ) } #endif - /* Require a write-lock on the table to perform this operation */ - sqlite3TableLock( pParse, iDb, pTab.tnum, 1, pTab.zName ); - v = sqlite3GetVdbe( pParse ); - if ( v == null ) - return; - if ( memRootPage >= 0 ) - { - tnum = memRootPage; - } - else - { - tnum = pIndex.tnum; - sqlite3VdbeAddOp2( v, OP_Clear, tnum, iDb ); - } - pKey = sqlite3IndexKeyinfo( pParse, pIndex ); - sqlite3VdbeAddOp4( v, OP_OpenWrite, iIdx, tnum, iDb, - pKey, P4_KEYINFO_HANDOFF ); - if ( memRootPage >= 0 ) - { - sqlite3VdbeChangeP5( v, 1 ); - } - sqlite3OpenTable( pParse, iTab, iDb, pTab, OP_OpenRead ); - addr1 = sqlite3VdbeAddOp2( v, OP_Rewind, iTab, 0 ); - regRecord = sqlite3GetTempReg( pParse ); - regIdxKey = sqlite3GenerateIndexKey( pParse, pIndex, iTab, regRecord, true ); - if ( pIndex.onError != OE_None ) - { - int regRowid = regIdxKey + pIndex.nColumn; - int j2 = sqlite3VdbeCurrentAddr( v ) + 2; - int pRegKey = regIdxKey;// SQLITE_INT_TO_PTR( regIdxKey ); - - /* The registers accessed by the OP_IsUnique opcode were allocated - ** using sqlite3GetTempRange() inside of the sqlite3GenerateIndexKey() - ** call above. Just before that function was freed they were released - ** (made available to the compiler for reuse) using - ** sqlite3ReleaseTempRange(). So in some ways having the OP_IsUnique - ** opcode use the values stored within seems dangerous. However, since - ** we can be sure that no other temp registers have been allocated - ** since sqlite3ReleaseTempRange() was called, it is safe to do so. + /* Require a write-lock on the table to perform this operation */ + sqlite3TableLock(pParse, iDb, pTab.tnum, 1, pTab.zName); + v = sqlite3GetVdbe(pParse); + if (v == null) + return; + if (memRootPage >= 0) { + tnum = memRootPage; + } else { + tnum = pIndex.tnum; + sqlite3VdbeAddOp2(v, OP_Clear, tnum, iDb); + } + pKey = sqlite3IndexKeyinfo(pParse, pIndex); + sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, tnum, iDb, + pKey, P4_KEYINFO_HANDOFF); + if (memRootPage >= 0) { + sqlite3VdbeChangeP5(v, 1); + } + sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead); + addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0); + regRecord = sqlite3GetTempReg(pParse); + regIdxKey = sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, true); + if (pIndex.onError != OE_None) { + int regRowid = regIdxKey + pIndex.nColumn; + int j2 = sqlite3VdbeCurrentAddr(v) + 2; + int pRegKey = regIdxKey;// SQLITE_INT_TO_PTR( regIdxKey ); + + /* The registers accessed by the OP_IsUnique opcode were allocated + ** using sqlite3GetTempRange() inside of the sqlite3GenerateIndexKey() + ** call above. Just before that function was freed they were released + ** (made available to the compiler for reuse) using + ** sqlite3ReleaseTempRange(). So in some ways having the OP_IsUnique + ** opcode use the values stored within seems dangerous. However, since + ** we can be sure that no other temp registers have been allocated + ** since sqlite3ReleaseTempRange() was called, it is safe to do so. + */ + sqlite3VdbeAddOp4(v, OP_IsUnique, iIdx, j2, regRowid, pRegKey, P4_INT32); + sqlite3HaltConstraint( + pParse, OE_Abort, "indexed columns are not unique", P4_STATIC); + } + sqlite3VdbeAddOp2(v, OP_IdxInsert, iIdx, regRecord); + sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); + sqlite3ReleaseTempReg(pParse, regRecord); + sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1 + 1); + sqlite3VdbeJumpHere(v, addr1); + sqlite3VdbeAddOp1(v, OP_Close, iTab); + sqlite3VdbeAddOp1(v, OP_Close, iIdx); + } + + /* + ** Create a new index for an SQL table. pName1.pName2 is the name of the index + ** and pTblList is the name of the table that is to be indexed. Both will + ** be NULL for a primary key or an index that is created to satisfy a + ** UNIQUE constraint. If pTable and pIndex are NULL, use pParse.pNewTable + ** as the table to be indexed. pParse.pNewTable is a table that is + ** currently being constructed by a CREATE TABLE statement. + ** + ** pList is a list of columns to be indexed. pList will be NULL if this + ** is a primary key or unique-constraint on the most recent column added + ** to the table currently under construction. + ** + ** If the index is created successfully, return a pointer to the new Index + ** structure. This is used by sqlite3AddPrimaryKey() to mark the index + ** as the tables primary key (Index.autoIndex==2). */ - sqlite3VdbeAddOp4( v, OP_IsUnique, iIdx, j2, regRowid, pRegKey, P4_INT32 ); - sqlite3HaltConstraint( - pParse, OE_Abort, "indexed columns are not unique", P4_STATIC ); - } - sqlite3VdbeAddOp2( v, OP_IdxInsert, iIdx, regRecord ); - sqlite3VdbeChangeP5( v, OPFLAG_USESEEKRESULT ); - sqlite3ReleaseTempReg( pParse, regRecord ); - sqlite3VdbeAddOp2( v, OP_Next, iTab, addr1 + 1 ); - sqlite3VdbeJumpHere( v, addr1 ); - sqlite3VdbeAddOp1( v, OP_Close, iTab ); - sqlite3VdbeAddOp1( v, OP_Close, iIdx ); - } + // OVERLOADS, so I don't need to rewrite parse.c + static Index sqlite3CreateIndex(Parse pParse, int null_2, int null_3, int null_4, int null_5, int onError, int null_7, int null_8, int sortOrder, int ifNotExist) { + return sqlite3CreateIndex(pParse, null, null, null, null, onError, null, null, sortOrder, ifNotExist); + } + static Index sqlite3CreateIndex(Parse pParse, int null_2, int null_3, int null_4, ExprList pList, int onError, int null_7, int null_8, int sortOrder, int ifNotExist) { + return sqlite3CreateIndex(pParse, null, null, null, pList, onError, null, null, sortOrder, ifNotExist); + } + static Index sqlite3CreateIndex( + Parse pParse, /* All information about this Parse */ + Token pName1, /* First part of index name. May be NULL */ + Token pName2, /* Second part of index name. May be NULL */ + SrcList pTblName, /* Table to index. Use pParse.pNewTable if 0 */ + ExprList pList, /* A list of columns to be indexed */ + int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ + Token pStart, /* The CREATE token that begins this statement */ + Token pEnd, /* The ")" that closes the CREATE INDEX statement */ + int sortOrder, /* Sort order of primary key when pList==NULL */ + int ifNotExist /* Omit error if index already exists */ + ) { + Index pRet = null; /* Pointer to return */ + Table pTab = null; /* Table to be indexed */ + Index pIndex = null; /* The index to be created */ + string zName = null; /* Name of the index */ + int nName; /* Number of characters in zName */ + int i, j; + Token nullId = new Token(); /* Fake token for an empty ID list */ + DbFixer sFix = new DbFixer(); /* For assigning database names to pTable */ + int sortOrderMask; /* 1 to honor DESC in index. 0 to ignore. */ + 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 = null; /* Unqualified name of the index to create */ + ExprList_item pListItem; /* For looping over pList */ + int nCol; + int nExtra = 0; + StringBuilder zExtra = new StringBuilder(); + + Debug.Assert(pStart == null || pEnd != null); /* pEnd must be non-NULL if pStart is */ + Debug.Assert(pParse.nErr == 0); /* Never called with prior errors */ + if ( /* db.mallocFailed != 0 || */ + IN_DECLARE_VTAB(pParse)) { + goto exit_create_index; + } + if (SQLITE_OK != sqlite3ReadSchema(pParse)) { + goto exit_create_index; + } - /* - ** Create a new index for an SQL table. pName1.pName2 is the name of the index - ** and pTblList is the name of the table that is to be indexed. Both will - ** be NULL for a primary key or an index that is created to satisfy a - ** UNIQUE constraint. If pTable and pIndex are NULL, use pParse.pNewTable - ** as the table to be indexed. pParse.pNewTable is a table that is - ** currently being constructed by a CREATE TABLE statement. - ** - ** pList is a list of columns to be indexed. pList will be NULL if this - ** is a primary key or unique-constraint on the most recent column added - ** to the table currently under construction. - ** - ** If the index is created successfully, return a pointer to the new Index - ** structure. This is used by sqlite3AddPrimaryKey() to mark the index - ** as the tables primary key (Index.autoIndex==2). - */ - // OVERLOADS, so I don't need to rewrite parse.c - static Index sqlite3CreateIndex( Parse pParse, int null_2, int null_3, int null_4, int null_5, int onError, int null_7, int null_8, int sortOrder, int ifNotExist ) - { - return sqlite3CreateIndex( pParse, null, null, null, null, onError, null, null, sortOrder, ifNotExist ); - } - static Index sqlite3CreateIndex( Parse pParse, int null_2, int null_3, int null_4, ExprList pList, int onError, int null_7, int null_8, int sortOrder, int ifNotExist ) - { - return sqlite3CreateIndex( pParse, null, null, null, pList, onError, null, null, sortOrder, ifNotExist ); - } - static Index sqlite3CreateIndex( - Parse pParse, /* All information about this Parse */ - Token pName1, /* First part of index name. May be NULL */ - Token pName2, /* Second part of index name. May be NULL */ - SrcList pTblName, /* Table to index. Use pParse.pNewTable if 0 */ - ExprList pList, /* A list of columns to be indexed */ - int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ - Token pStart, /* The CREATE token that begins this statement */ - Token pEnd, /* The ")" that closes the CREATE INDEX statement */ - int sortOrder, /* Sort order of primary key when pList==NULL */ - int ifNotExist /* Omit error if index already exists */ - ) - { - Index pRet = null; /* Pointer to return */ - Table pTab = null; /* Table to be indexed */ - Index pIndex = null; /* The index to be created */ - string zName = null; /* Name of the index */ - int nName; /* Number of characters in zName */ - int i, j; - Token nullId = new Token(); /* Fake token for an empty ID list */ - DbFixer sFix = new DbFixer(); /* For assigning database names to pTable */ - int sortOrderMask; /* 1 to honor DESC in index. 0 to ignore. */ - 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 = null; /* Unqualified name of the index to create */ - ExprList_item pListItem; /* For looping over pList */ - int nCol; - int nExtra = 0; - StringBuilder zExtra = new StringBuilder(); - - Debug.Assert( pStart == null || pEnd != null ); /* pEnd must be non-NULL if pStart is */ - Debug.Assert( pParse.nErr == 0 ); /* Never called with prior errors */ - if ( /* db.mallocFailed != 0 || */ - IN_DECLARE_VTAB( pParse ) ) - { - goto exit_create_index; - } - if ( SQLITE_OK != sqlite3ReadSchema( pParse ) ) - { - goto exit_create_index; - } - - /* - ** Find the table that is to be indexed. Return early if not found. - */ - if ( pTblName != null ) - { + /* + ** Find the table that is to be indexed. Return early if not found. + */ + if (pTblName != null) { - /* Use the two-part index name to determine the database - ** to search for the table. 'Fix' the table name to this db - ** before looking up the table. - */ - Debug.Assert( pName1 != null && pName2 != null ); - iDb = sqlite3TwoPartName( pParse, pName1, pName2, ref pName ); - if ( iDb < 0 ) - goto exit_create_index; + /* Use the two-part index name to determine the database + ** to search for the table. 'Fix' the table name to this db + ** before looking up the table. + */ + Debug.Assert(pName1 != null && pName2 != null); + iDb = sqlite3TwoPartName(pParse, pName1, pName2, ref pName); + if (iDb < 0) + goto exit_create_index; #if !SQLITE_OMIT_TEMPDB - /* If the index name was unqualified, check if the the table -** is a temp table. If so, set the database to 1. Do not do this -** if initialising a database schema. -*/ - if ( 0 == db.init.busy ) - { - pTab = sqlite3SrcListLookup( pParse, pTblName ); - if ( pName2.n == 0 && pTab != null && pTab.pSchema == db.aDb[1].pSchema ) - { - iDb = 1; - } - } + /* If the index name was unqualified, check if the the table + ** is a temp table. If so, set the database to 1. Do not do this + ** if initialising a database schema. + */ + if (0 == db.init.busy) { + pTab = sqlite3SrcListLookup(pParse, pTblName); + if (pName2.n == 0 && pTab != null && pTab.pSchema == db.aDb[1].pSchema) { + iDb = 1; + } + } #endif - if ( sqlite3FixInit( sFix, pParse, iDb, "index", pName ) != 0 && - sqlite3FixSrcList( sFix, pTblName ) != 0 - ) - { - /* Because the parser constructs pTblName from a single identifier, - ** sqlite3FixSrcList can never fail. */ - Debugger.Break(); - } - pTab = sqlite3LocateTable( pParse, 0, pTblName.a[0].zName, - pTblName.a[0].zDatabase ); - if ( pTab == null /*|| db.mallocFailed != 0 */ ) - goto exit_create_index; - Debug.Assert( db.aDb[iDb].pSchema == pTab.pSchema ); - } - else - { - Debug.Assert( pName == null ); - pTab = pParse.pNewTable; - if ( pTab == null ) - goto exit_create_index; - iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); - } - pDb = db.aDb[iDb]; - - Debug.Assert( pTab != null ); - Debug.Assert( pParse.nErr == 0 ); - - if ( pTab.zName.StartsWith( "sqlite_", System.StringComparison.OrdinalIgnoreCase ) - && !pTab.zName.StartsWith( "sqlite_altertab_", System.StringComparison.OrdinalIgnoreCase ) ) - { - sqlite3ErrorMsg( pParse, "table %s may not be indexed", pTab.zName ); - goto exit_create_index; - } + if (sqlite3FixInit(sFix, pParse, iDb, "index", pName) != 0 && + sqlite3FixSrcList(sFix, pTblName) != 0 + ) { + /* Because the parser constructs pTblName from a single identifier, + ** sqlite3FixSrcList can never fail. */ + Debugger.Break(); + } + pTab = sqlite3LocateTable(pParse, 0, pTblName.a[0].zName, + pTblName.a[0].zDatabase); + if (pTab == null /*|| db.mallocFailed != 0 */ ) + goto exit_create_index; + Debug.Assert(db.aDb[iDb].pSchema == pTab.pSchema); + } else { + Debug.Assert(pName == null); + pTab = pParse.pNewTable; + if (pTab == null) + goto exit_create_index; + iDb = sqlite3SchemaToIndex(db, pTab.pSchema); + } + pDb = db.aDb[iDb]; + + Debug.Assert(pTab != null); + Debug.Assert(pParse.nErr == 0); + + if (pTab.zName.StartsWith("sqlite_", System.StringComparison.OrdinalIgnoreCase) + && !pTab.zName.StartsWith("sqlite_altertab_", System.StringComparison.OrdinalIgnoreCase)) { + sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab.zName); + goto exit_create_index; + } #if !SQLITE_OMIT_VIEW - if ( pTab.pSelect != null ) - { - sqlite3ErrorMsg( pParse, "views may not be indexed" ); - goto exit_create_index; - } + if (pTab.pSelect != null) { + sqlite3ErrorMsg(pParse, "views may not be indexed"); + goto exit_create_index; + } #endif - if ( IsVirtual( pTab ) ) - { - sqlite3ErrorMsg( pParse, "virtual tables may not be indexed" ); - goto exit_create_index; - } - - /* - ** Find the name of the index. Make sure there is not already another - ** index or table with the same name. - ** - ** Exception: If we are reading the names of permanent indices from the - ** sqlite_master table (because some other process changed the schema) and - ** one of the index names collides with the name of a temporary table or - ** index, then we will continue to process this index. - ** - ** If pName==0 it means that we are - ** dealing with a primary key or UNIQUE constraint. We have to invent our - ** own name. - */ - if ( pName != null ) - { - zName = sqlite3NameFromToken( db, pName ); - if ( zName == null ) - goto exit_create_index; - if ( SQLITE_OK != sqlite3CheckObjectName( pParse, zName ) ) - { - goto exit_create_index; - } - if ( 0 == db.init.busy ) - { - if ( sqlite3FindTable( db, zName, null ) != null ) - { - sqlite3ErrorMsg( pParse, "there is already a table named %s", zName ); - goto exit_create_index; - } - } - if ( sqlite3FindIndex( db, zName, pDb.zName ) != null ) - { - if ( ifNotExist == 0 ) - { - sqlite3ErrorMsg( pParse, "index %s already exists", zName ); - } - else - { - Debug.Assert( 0 == db.init.busy ); - sqlite3CodeVerifySchema( pParse, iDb ); - } - goto exit_create_index; - } - } - else - { - int n = 0; - Index pLoop; - for ( pLoop = pTab.pIndex, n = 1; pLoop != null; pLoop = pLoop.pNext, n++ ) - { - } - zName = sqlite3MPrintf( db, "sqlite_autoindex_%s_%d", pTab.zName, n ); - if ( zName == null ) - { - goto exit_create_index; - } - } + if (IsVirtual(pTab)) { + sqlite3ErrorMsg(pParse, "virtual tables may not be indexed"); + goto exit_create_index; + } - /* Check for authorization to create an index. - */ + /* + ** Find the name of the index. Make sure there is not already another + ** index or table with the same name. + ** + ** Exception: If we are reading the names of permanent indices from the + ** sqlite_master table (because some other process changed the schema) and + ** one of the index names collides with the name of a temporary table or + ** index, then we will continue to process this index. + ** + ** If pName==0 it means that we are + ** dealing with a primary key or UNIQUE constraint. We have to invent our + ** own name. + */ + if (pName != null) { + zName = sqlite3NameFromToken(db, pName); + if (zName == null) + goto exit_create_index; + if (SQLITE_OK != sqlite3CheckObjectName(pParse, zName)) { + goto exit_create_index; + } + if (0 == db.init.busy) { + if (sqlite3FindTable(db, zName, null) != null) { + sqlite3ErrorMsg(pParse, "there is already a table named %s", zName); + goto exit_create_index; + } + } + if (sqlite3FindIndex(db, zName, pDb.zName) != null) { + if (ifNotExist == 0) { + sqlite3ErrorMsg(pParse, "index %s already exists", zName); + } else { + Debug.Assert(0 == db.init.busy); + sqlite3CodeVerifySchema(pParse, iDb); + } + goto exit_create_index; + } + } else { + int n = 0; + Index pLoop; + for (pLoop = pTab.pIndex, n = 1; pLoop != null; pLoop = pLoop.pNext, n++) { + } + zName = sqlite3MPrintf(db, "sqlite_autoindex_%s_%d", pTab.zName, n); + if (zName == null) { + goto exit_create_index; + } + } + + /* Check for authorization to create an index. + */ #if !SQLITE_OMIT_AUTHORIZATION { string zDb = pDb.zName; @@ -3009,445 +2745,399 @@ static Index sqlite3CreateIndex( } #endif - /* If pList==0, it means this routine was called to make a primary -** key out of the last column added to the table under construction. -** So create a fake list to simulate this. -*/ - if ( pList == null ) - { - nullId.z = pTab.aCol[pTab.nCol - 1].zName; - nullId.n = sqlite3Strlen30( nullId.z ); - pList = sqlite3ExprListAppend( pParse, null, null ); - if ( pList == null ) - goto exit_create_index; - sqlite3ExprListSetName( pParse, pList, nullId, 0 ); - pList.a[0].sortOrder = (u8)sortOrder; - } - - /* Figure out how many bytes of space are required to store explicitly - ** specified collation sequence names. + /* If pList==0, it means this routine was called to make a primary + ** key out of the last column added to the table under construction. + ** So create a fake list to simulate this. */ - for ( i = 0; i < pList.nExpr; i++ ) - { - Expr pExpr = pList.a[i].pExpr; - if ( pExpr != null ) - { - CollSeq pColl = pExpr.pColl; - /* Either pColl!=0 or there was an OOM failure. But if an OOM - ** failure we have quit before reaching this point. */ - if ( ALWAYS( pColl != null ) ) - { - nExtra += ( 1 + sqlite3Strlen30( pColl.zName ) ); - } - } - } + if (pList == null) { + nullId.z = pTab.aCol[pTab.nCol - 1].zName; + nullId.n = sqlite3Strlen30(nullId.z); + pList = sqlite3ExprListAppend(pParse, null, null); + if (pList == null) + goto exit_create_index; + sqlite3ExprListSetName(pParse, pList, nullId, 0); + pList.a[0].sortOrder = (u8)sortOrder; + } - /* - ** Allocate the index structure. - */ - nName = sqlite3Strlen30( zName ); - nCol = pList.nExpr; - pIndex = new Index(); - // sqlite3DbMallocZero( db, - // Index.Length + /* Index structure */ - // sizeof( int ) * nCol + /* Index.aiColumn */ - // sizeof( int ) * ( nCol + 1 ) + /* Index.aiRowEst */ - // sizeof( char* ) * nCol + /* Index.azColl */ - // u8.Length * nCol + /* Index.aSortOrder */ - // nName + 1 + /* Index.zName */ - // nExtra /* Collation sequence names */ - //); - //if ( db.mallocFailed != 0 ) - //{ - // goto exit_create_index; - //} - pIndex.azColl = new string[nCol + 1];//(char*)(pIndex[1]); - pIndex.aiColumn = new int[nCol + 1];//(int )(pIndex->azColl[nCol]); - pIndex.aiRowEst = new int[nCol + 1];//(unsigned )(pIndex->aiColumn[nCol]); - pIndex.aSortOrder = new byte[nCol + 1];//(u8 )(pIndex->aiRowEst[nCol+1]); - //pIndex.zName = null;// (char)( &pIndex->aSortOrder[nCol] ); - zExtra = new StringBuilder( nName + 1 );// (char)( &pIndex.zName[nName + 1] ); - if ( zName.Length == nName ) - pIndex.zName = zName; - else - { - pIndex.zName = zName.Substring( 0, nName ); - }// memcpy( pIndex.zName, zName, nName + 1 ); - pIndex.pTable = pTab; - pIndex.nColumn = pList.nExpr; - pIndex.onError = (u8)onError; - pIndex.autoIndex = (u8)( pName == null ? 1 : 0 ); - pIndex.pSchema = db.aDb[iDb].pSchema; - Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); - - /* Check to see if we should honor DESC requests on index columns - */ - if ( pDb.pSchema.file_format >= 4 ) - { - sortOrderMask = 1; /* Honor DESC */ - } - else - { - sortOrderMask = 0; /* Ignore DESC */ - } - - /* Scan the names of the columns of the table to be indexed and - ** load the column indices into the Index structure. Report an error - ** if any column is not found. - ** - ** TODO: Add a test to make sure that the same column is not named - ** more than once within the same index. Only the first instance of - ** the column will ever be used by the optimizer. Note that using the - ** same column more than once cannot be an error because that would - ** break backwards compatibility - it needs to be a warning. - */ - for ( i = 0; i < pList.nExpr; i++ ) - {//, pListItem++){ - pListItem = pList.a[i]; - string zColName = pListItem.zName; - Column pTabCol; - byte requestedSortOrder; - string zColl; /* Collation sequence name */ - - for ( j = 0; j < pTab.nCol; j++ ) - {//, pTabCol++){ - pTabCol = pTab.aCol[j]; - if ( zColName.Equals( pTabCol.zName, StringComparison.OrdinalIgnoreCase ) ) - break; - } - if ( j >= pTab.nCol ) - { - sqlite3ErrorMsg( pParse, "table %s has no column named %s", - pTab.zName, zColName ); - pParse.checkSchema = 1; - goto exit_create_index; - } - pIndex.aiColumn[i] = j; - /* Justification of the ALWAYS(pListItem->pExpr->pColl): Because of - ** the way the "idxlist" non-terminal is constructed by the parser, - ** if pListItem->pExpr is not null then either pListItem->pExpr->pColl - ** must exist or else there must have been an OOM error. But if there - ** was an OOM error, we would never reach this point. */ - if ( pListItem.pExpr != null && ALWAYS( pListItem.pExpr.pColl ) ) - { - int nColl; - zColl = pListItem.pExpr.pColl.zName; - nColl = sqlite3Strlen30( zColl ); - Debug.Assert( nExtra >= nColl ); - zExtra = new StringBuilder( zColl.Substring( 0, nColl ) );// memcpy( zExtra, zColl, nColl ); - zColl = zExtra.ToString(); - //zExtra += nColl; - nExtra -= nColl; - } - else - { - zColl = pTab.aCol[j].zColl; - if ( zColl == null ) - { - zColl = db.pDfltColl.zName; - } - } - if ( 0 == db.init.busy && sqlite3LocateCollSeq( pParse, zColl ) == null ) - { - goto exit_create_index; - } - pIndex.azColl[i] = zColl; - requestedSortOrder = (u8)( ( pListItem.sortOrder & sortOrderMask ) != 0 ? 1 : 0 ); - pIndex.aSortOrder[i] = (u8)requestedSortOrder; - } - sqlite3DefaultRowEst( 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. - ** i.e. one of: - ** - ** CREATE TABLE t(x PRIMARY KEY, y); - ** CREATE TABLE t(x, y, UNIQUE(x, y)); - ** - ** Either way, check to see if the table already has such an index. If - ** so, don't bother creating this one. This only applies to - ** automatically created indices. Users can do as they wish with - ** explicit indices. - ** - ** Two UNIQUE or PRIMARY KEY constraints are considered equivalent - ** (and thus suppressing the second one) even if they have different - ** sort orders. - ** - ** If there are different collating sequences or if the columns of - ** the constraint occur in different orders, then the constraints are - ** considered distinct and both result in separate indices. - */ - Index pIdx; - for ( pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext ) - { - int k; - Debug.Assert( pIdx.onError != OE_None ); - Debug.Assert( pIdx.autoIndex != 0 ); - Debug.Assert( pIndex.onError != OE_None ); - - if ( pIdx.nColumn != pIndex.nColumn ) - continue; - for ( k = 0; k < pIdx.nColumn; k++ ) - { - string z1; - string z2; - if ( pIdx.aiColumn[k] != pIndex.aiColumn[k] ) - break; - z1 = pIdx.azColl[k]; - z2 = pIndex.azColl[k]; - if ( z1 != z2 && !z1.Equals( z2, StringComparison.OrdinalIgnoreCase ) ) - break; - } - if ( k == pIdx.nColumn ) - { - if ( pIdx.onError != pIndex.onError ) - { - /* This constraint creates the same index as a previous - ** constraint specified somewhere in the CREATE TABLE statement. - ** However the ON CONFLICT clauses are different. If both this - ** constraint and the previous equivalent constraint have explicit - ** ON CONFLICT clauses this is an error. Otherwise, use the - ** explicitly specified behavior for the index. - */ - if ( !( pIdx.onError == OE_Default || pIndex.onError == OE_Default ) ) - { - sqlite3ErrorMsg( pParse, - "conflicting ON CONFLICT clauses specified", 0 ); - } - if ( pIdx.onError == OE_Default ) - { - pIdx.onError = pIndex.onError; - } + /* Figure out how many bytes of space are required to store explicitly + ** specified collation sequence names. + */ + for (i = 0; i < pList.nExpr; i++) { + Expr pExpr = pList.a[i].pExpr; + if (pExpr != null) { + CollSeq pColl = pExpr.pColl; + /* Either pColl!=0 or there was an OOM failure. But if an OOM + ** failure we have quit before reaching this point. */ + if (ALWAYS(pColl != null)) { + nExtra += (1 + sqlite3Strlen30(pColl.zName)); + } + } } - goto exit_create_index; - } - } - } - /* Link the new Index structure to its table and to the other - ** in-memory database structures. - */ - if ( db.init.busy != 0 ) - { - Index p; - Debug.Assert( sqlite3SchemaMutexHeld( db, 0, pIndex.pSchema ) ); - p = sqlite3HashInsert( ref pIndex.pSchema.idxHash, - pIndex.zName, sqlite3Strlen30( pIndex.zName ), - pIndex ); - if ( p != null ) - { - Debug.Assert( p == pIndex ); /* Malloc must have failed */ - // db.mallocFailed = 1; - goto exit_create_index; - } - db.flags |= SQLITE_InternChanges; - if ( pTblName != null ) - { - pIndex.tnum = db.init.newTnum; - } - } - - /* If the db.init.busy is 0 then create the index on disk. This - ** involves writing the index into the master table and filling in the - ** index with the current table contents. - ** - ** The db.init.busy is 0 when the user first enters a CREATE INDEX - ** command. db.init.busy is 1 when a database is opened and - ** CREATE INDEX statements are read out of the master table. In - ** the latter case the index already exists on disk, which is why - ** we don't want to recreate it. - ** - ** If pTblName==0 it means this index is generated as a primary key - ** or UNIQUE constraint of a CREATE TABLE statement. Since the table - ** has just been created, it contains no data and the index initialization - ** step can be skipped. - */ - else //if ( 0 == db.init.busy ) - { - Vdbe v; - string zStmt; - int iMem = ++pParse.nMem; + /* + ** Allocate the index structure. + */ + nName = sqlite3Strlen30(zName); + nCol = pList.nExpr; + pIndex = new Index(); + // sqlite3DbMallocZero( db, + // Index.Length + /* Index structure */ + // sizeof( int ) * nCol + /* Index.aiColumn */ + // sizeof( int ) * ( nCol + 1 ) + /* Index.aiRowEst */ + // sizeof( char* ) * nCol + /* Index.azColl */ + // u8.Length * nCol + /* Index.aSortOrder */ + // nName + 1 + /* Index.zName */ + // nExtra /* Collation sequence names */ + //); + //if ( db.mallocFailed != 0 ) + //{ + // goto exit_create_index; + //} + pIndex.azColl = new string[nCol + 1];//(char*)(pIndex[1]); + pIndex.aiColumn = new int[nCol + 1];//(int )(pIndex->azColl[nCol]); + pIndex.aiRowEst = new int[nCol + 1];//(unsigned )(pIndex->aiColumn[nCol]); + pIndex.aSortOrder = new byte[nCol + 1];//(u8 )(pIndex->aiRowEst[nCol+1]); + //pIndex.zName = null;// (char)( &pIndex->aSortOrder[nCol] ); + zExtra = new StringBuilder(nName + 1);// (char)( &pIndex.zName[nName + 1] ); + if (zName.Length == nName) + pIndex.zName = zName; + else { + pIndex.zName = zName.Substring(0, nName); + }// memcpy( pIndex.zName, zName, nName + 1 ); + pIndex.pTable = pTab; + pIndex.nColumn = pList.nExpr; + pIndex.onError = (u8)onError; + pIndex.autoIndex = (u8)(pName == null ? 1 : 0); + pIndex.pSchema = db.aDb[iDb].pSchema; + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + + /* Check to see if we should honor DESC requests on index columns + */ + if (pDb.pSchema.file_format >= 4) { + sortOrderMask = 1; /* Honor DESC */ + } else { + sortOrderMask = 0; /* Ignore DESC */ + } - v = sqlite3GetVdbe( pParse ); - if ( v == null ) - goto exit_create_index; + /* Scan the names of the columns of the table to be indexed and + ** load the column indices into the Index structure. Report an error + ** if any column is not found. + ** + ** TODO: Add a test to make sure that the same column is not named + ** more than once within the same index. Only the first instance of + ** the column will ever be used by the optimizer. Note that using the + ** same column more than once cannot be an error because that would + ** break backwards compatibility - it needs to be a warning. + */ + for (i = 0; i < pList.nExpr; i++) {//, pListItem++){ + pListItem = pList.a[i]; + string zColName = pListItem.zName; + Column pTabCol; + byte requestedSortOrder; + string zColl; /* Collation sequence name */ + + for (j = 0; j < pTab.nCol; j++) {//, pTabCol++){ + pTabCol = pTab.aCol[j]; + if (zColName.Equals(pTabCol.zName, StringComparison.OrdinalIgnoreCase)) + break; + } + if (j >= pTab.nCol) { + sqlite3ErrorMsg(pParse, "table %s has no column named %s", + pTab.zName, zColName); + pParse.checkSchema = 1; + goto exit_create_index; + } + pIndex.aiColumn[i] = j; + /* Justification of the ALWAYS(pListItem->pExpr->pColl): Because of + ** the way the "idxlist" non-terminal is constructed by the parser, + ** if pListItem->pExpr is not null then either pListItem->pExpr->pColl + ** must exist or else there must have been an OOM error. But if there + ** was an OOM error, we would never reach this point. */ + if (pListItem.pExpr != null && ALWAYS(pListItem.pExpr.pColl)) { + int nColl; + zColl = pListItem.pExpr.pColl.zName; + nColl = sqlite3Strlen30(zColl); + Debug.Assert(nExtra >= nColl); + zExtra = new StringBuilder(zColl.Substring(0, nColl));// memcpy( zExtra, zColl, nColl ); + zColl = zExtra.ToString(); + //zExtra += nColl; + nExtra -= nColl; + } else { + zColl = pTab.aCol[j].zColl; + if (zColl == null) { + zColl = db.pDfltColl.zName; + } + } + if (0 == db.init.busy && sqlite3LocateCollSeq(pParse, zColl) == null) { + goto exit_create_index; + } + pIndex.azColl[i] = zColl; + requestedSortOrder = (u8)((pListItem.sortOrder & sortOrderMask) != 0 ? 1 : 0); + pIndex.aSortOrder[i] = (u8)requestedSortOrder; + } + sqlite3DefaultRowEst(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. + ** i.e. one of: + ** + ** CREATE TABLE t(x PRIMARY KEY, y); + ** CREATE TABLE t(x, y, UNIQUE(x, y)); + ** + ** Either way, check to see if the table already has such an index. If + ** so, don't bother creating this one. This only applies to + ** automatically created indices. Users can do as they wish with + ** explicit indices. + ** + ** Two UNIQUE or PRIMARY KEY constraints are considered equivalent + ** (and thus suppressing the second one) even if they have different + ** sort orders. + ** + ** If there are different collating sequences or if the columns of + ** the constraint occur in different orders, then the constraints are + ** considered distinct and both result in separate indices. + */ + Index pIdx; + for (pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext) { + int k; + Debug.Assert(pIdx.onError != OE_None); + Debug.Assert(pIdx.autoIndex != 0); + Debug.Assert(pIndex.onError != OE_None); + + if (pIdx.nColumn != pIndex.nColumn) + continue; + for (k = 0; k < pIdx.nColumn; k++) { + string z1; + string z2; + if (pIdx.aiColumn[k] != pIndex.aiColumn[k]) + break; + z1 = pIdx.azColl[k]; + z2 = pIndex.azColl[k]; + if (z1 != z2 && !z1.Equals(z2, StringComparison.OrdinalIgnoreCase)) + break; + } + if (k == pIdx.nColumn) { + if (pIdx.onError != pIndex.onError) { + /* This constraint creates the same index as a previous + ** constraint specified somewhere in the CREATE TABLE statement. + ** However the ON CONFLICT clauses are different. If both this + ** constraint and the previous equivalent constraint have explicit + ** ON CONFLICT clauses this is an error. Otherwise, use the + ** explicitly specified behavior for the index. + */ + if (!(pIdx.onError == OE_Default || pIndex.onError == OE_Default)) { + sqlite3ErrorMsg(pParse, + "conflicting ON CONFLICT clauses specified", 0); + } + if (pIdx.onError == OE_Default) { + pIdx.onError = pIndex.onError; + } + } + goto exit_create_index; + } + } + } + /* Link the new Index structure to its table and to the other + ** in-memory database structures. + */ + if (db.init.busy != 0) { + Index p; + Debug.Assert(sqlite3SchemaMutexHeld(db, 0, pIndex.pSchema)); + p = sqlite3HashInsert(ref pIndex.pSchema.idxHash, + pIndex.zName, sqlite3Strlen30(pIndex.zName), + pIndex); + if (p != null) { + Debug.Assert(p == pIndex); /* Malloc must have failed */ + // db.mallocFailed = 1; + goto exit_create_index; + } + db.flags |= SQLITE_InternChanges; + if (pTblName != null) { + pIndex.tnum = db.init.newTnum; + } + } - /* Create the rootpage for the index - */ - sqlite3BeginWriteOperation( pParse, 1, iDb ); - sqlite3VdbeAddOp2( v, OP_CreateIndex, iDb, iMem ); + /* If the db.init.busy is 0 then create the index on disk. This + ** involves writing the index into the master table and filling in the + ** index with the current table contents. + ** + ** The db.init.busy is 0 when the user first enters a CREATE INDEX + ** command. db.init.busy is 1 when a database is opened and + ** CREATE INDEX statements are read out of the master table. In + ** the latter case the index already exists on disk, which is why + ** we don't want to recreate it. + ** + ** If pTblName==0 it means this index is generated as a primary key + ** or UNIQUE constraint of a CREATE TABLE statement. Since the table + ** has just been created, it contains no data and the index initialization + ** step can be skipped. + */ + else //if ( 0 == db.init.busy ) + { + Vdbe v; + string zStmt; + int iMem = ++pParse.nMem; + + v = sqlite3GetVdbe(pParse); + if (v == null) + goto exit_create_index; + + + /* Create the rootpage for the index + */ + sqlite3BeginWriteOperation(pParse, 1, iDb); + sqlite3VdbeAddOp2(v, OP_CreateIndex, iDb, iMem); + + /* Gather the complete text of the CREATE INDEX statement into + ** the zStmt variable + */ + if (pStart != null) { + Debug.Assert(pEnd != null); + /* A named index with an explicit CREATE INDEX statement */ + zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s", + onError == OE_None ? "" : " UNIQUE", + (int)(pName.z.Length - pEnd.z.Length) + 1, + pName.z); + } else { + /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */ + /* zStmt = sqlite3MPrintf(""); */ + zStmt = null; + } + + /* Add an entry in sqlite_master for this index + */ + sqlite3NestedParse(pParse, + "INSERT INTO %Q.%s VALUES('index',%Q,%Q,#%d,%Q);", + db.aDb[iDb].zName, SCHEMA_TABLE(iDb), + pIndex.zName, + pTab.zName, + iMem, + zStmt + ); + sqlite3DbFree(db, ref zStmt); + + /* Fill the index with data and reparse the schema. Code an OP_Expire + ** to invalidate all pre-compiled statements. + */ + if (pTblName != null) { + sqlite3RefillIndex(pParse, pIndex, iMem); + sqlite3ChangeCookie(pParse, iDb); + sqlite3VdbeAddParseSchemaOp(v, iDb, + sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex.zName)); + sqlite3VdbeAddOp1(v, OP_Expire, 0); + } + } - /* Gather the complete text of the CREATE INDEX statement into - ** the zStmt variable - */ - if ( pStart != null ) - { - Debug.Assert( pEnd != null ); - /* A named index with an explicit CREATE INDEX statement */ - zStmt = sqlite3MPrintf( db, "CREATE%s INDEX %.*s", - onError == OE_None ? "" : " UNIQUE", - (int)(pName.z.Length - pEnd.z.Length) + 1, - pName.z ); - } - else - { - /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */ - /* zStmt = sqlite3MPrintf(""); */ - zStmt = null; - } + /* When adding an index to the list of indices for a table, make + ** sure all indices labeled OE_Replace come after all those labeled + ** OE_Ignore. This is necessary for the correct constraint check + ** processing (in sqlite3GenerateConstraintChecks()) as part of + ** UPDATE and INSERT statements. + */ + if (db.init.busy != 0 || pTblName == null) { + if (onError != OE_Replace || pTab.pIndex == null + || pTab.pIndex.onError == OE_Replace) { + pIndex.pNext = pTab.pIndex; + pTab.pIndex = pIndex; + } else { + Index pOther = pTab.pIndex; + while (pOther.pNext != null && pOther.pNext.onError != OE_Replace) { + pOther = pOther.pNext; + } + pIndex.pNext = pOther.pNext; + pOther.pNext = pIndex; + } + pRet = pIndex; + pIndex = null; + } - /* Add an entry in sqlite_master for this index - */ - sqlite3NestedParse( pParse, - "INSERT INTO %Q.%s VALUES('index',%Q,%Q,#%d,%Q);", - db.aDb[iDb].zName, SCHEMA_TABLE( iDb ), - pIndex.zName, - pTab.zName, - iMem, - zStmt - ); - sqlite3DbFree( db, ref zStmt ); - - /* Fill the index with data and reparse the schema. Code an OP_Expire - ** to invalidate all pre-compiled statements. - */ - if ( pTblName != null ) - { - sqlite3RefillIndex( pParse, pIndex, iMem ); - sqlite3ChangeCookie( pParse, iDb ); - sqlite3VdbeAddParseSchemaOp( v, iDb, - sqlite3MPrintf( db, "name='%q' AND type='index'", pIndex.zName ) ); - sqlite3VdbeAddOp1( v, OP_Expire, 0 ); + /* Clean up before exiting */ + exit_create_index: + if (pIndex != null) { + //sqlite3DbFree(db, ref pIndex.zColAff ); + sqlite3DbFree(db, ref pIndex); + } + sqlite3ExprListDelete(db, ref pList); + sqlite3SrcListDelete(db, ref pTblName); + sqlite3DbFree(db, ref zName); + return pRet; } - } - /* When adding an index to the list of indices for a table, make - ** sure all indices labeled OE_Replace come after all those labeled - ** OE_Ignore. This is necessary for the correct constraint check - ** processing (in sqlite3GenerateConstraintChecks()) as part of - ** UPDATE and INSERT statements. - */ - if ( db.init.busy != 0 || pTblName == null ) - { - if ( onError != OE_Replace || pTab.pIndex == null - || pTab.pIndex.onError == OE_Replace ) - { - pIndex.pNext = pTab.pIndex; - pTab.pIndex = pIndex; - } - else - { - Index pOther = pTab.pIndex; - while ( pOther.pNext != null && pOther.pNext.onError != OE_Replace ) - { - pOther = pOther.pNext; - } - pIndex.pNext = pOther.pNext; - pOther.pNext = pIndex; + /* + ** Fill the Index.aiRowEst[] array with default information - information + ** to be used when we have not run the ANALYZE command. + ** + ** aiRowEst[0] is suppose to contain the number of elements in the index. + ** Since we do not know, guess 1 million. aiRowEst[1] is an estimate of the + ** number of rows in the table that match any particular value of the + ** first column of the index. aiRowEst[2] is an estimate of the number + ** of rows that match any particular combiniation of the first 2 columns + ** of the index. And so forth. It must always be the case that + * + ** aiRowEst[N]<=aiRowEst[N-1] + ** aiRowEst[N]>=1 + ** + ** Apart from that, we have little to go on besides intuition as to + ** how aiRowEst[] should be initialized. The numbers generated here + ** are based on typical values found in actual indices. + */ + static void sqlite3DefaultRowEst(Index pIdx) { + int[] a = pIdx.aiRowEst; + int i; + int n; + Debug.Assert(a != null); + a[0] = (int)pIdx.pTable.nRowEst; + if (a[0] < 10) + a[0] = 10; + n = 10; + for (i = 1; i <= pIdx.nColumn; i++) { + a[i] = n; + if (n > 5) + n--; + } + if (pIdx.onError != OE_None) { + a[pIdx.nColumn] = 1; + } } - pRet = pIndex; - pIndex = null; - } - /* Clean up before exiting */ -exit_create_index: - if ( pIndex != null ) - { - //sqlite3DbFree(db, ref pIndex.zColAff ); - sqlite3DbFree( db, ref pIndex ); - } - sqlite3ExprListDelete( db, ref pList ); - sqlite3SrcListDelete( db, ref pTblName ); - sqlite3DbFree( db, ref zName ); - return pRet; - } - - /* - ** Fill the Index.aiRowEst[] array with default information - information - ** to be used when we have not run the ANALYZE command. - ** - ** aiRowEst[0] is suppose to contain the number of elements in the index. - ** Since we do not know, guess 1 million. aiRowEst[1] is an estimate of the - ** number of rows in the table that match any particular value of the - ** first column of the index. aiRowEst[2] is an estimate of the number - ** of rows that match any particular combiniation of the first 2 columns - ** of the index. And so forth. It must always be the case that - * - ** aiRowEst[N]<=aiRowEst[N-1] - ** aiRowEst[N]>=1 - ** - ** Apart from that, we have little to go on besides intuition as to - ** how aiRowEst[] should be initialized. The numbers generated here - ** are based on typical values found in actual indices. - */ - static void sqlite3DefaultRowEst( Index pIdx ) - { - int[] a = pIdx.aiRowEst; - int i; - int n; - Debug.Assert( a != null ); - a[0] = (int)pIdx.pTable.nRowEst; - if ( a[0] < 10 ) - a[0] = 10; - n = 10; - for ( i = 1; i <= pIdx.nColumn; i++ ) - { - a[i] = n; - if ( n > 5 ) - n--; - } - if ( pIdx.onError != OE_None ) - { - a[pIdx.nColumn] = 1; - } - } - - /* - ** This routine will drop an existing named index. This routine - ** implements the DROP INDEX statement. - */ - static void sqlite3DropIndex( Parse pParse, SrcList pName, int ifExists ) - { - Index pIndex; - Vdbe v; - sqlite3 db = pParse.db; - int iDb; - - Debug.Assert( pParse.nErr == 0 ); /* Never called with prior errors */ - //if ( db.mallocFailed != 0 ) - //{ - // goto exit_drop_index; - //} - Debug.Assert( pName.nSrc == 1 ); - if ( SQLITE_OK != sqlite3ReadSchema( pParse ) ) - { - goto exit_drop_index; - } - pIndex = sqlite3FindIndex( db, pName.a[0].zName, pName.a[0].zDatabase ); - if ( pIndex == null ) - { - if ( ifExists == 0 ) - { - sqlite3ErrorMsg( pParse, "no such index: %S", pName, 0 ); - } - else - { - sqlite3CodeVerifyNamedSchema( pParse, pName.a[0].zDatabase ); - } - pParse.checkSchema = 1; - goto exit_drop_index; - } - if ( pIndex.autoIndex != 0 ) - { - sqlite3ErrorMsg( pParse, "index associated with UNIQUE " + - "or PRIMARY KEY constraint cannot be dropped", 0 ); - goto exit_drop_index; - } - iDb = sqlite3SchemaToIndex( db, pIndex.pSchema ); + /* + ** This routine will drop an existing named index. This routine + ** implements the DROP INDEX statement. + */ + static void sqlite3DropIndex(Parse pParse, SrcList pName, int ifExists) { + Index pIndex; + Vdbe v; + sqlite3 db = pParse.db; + int iDb; + + Debug.Assert(pParse.nErr == 0); /* Never called with prior errors */ + //if ( db.mallocFailed != 0 ) + //{ + // goto exit_drop_index; + //} + Debug.Assert(pName.nSrc == 1); + if (SQLITE_OK != sqlite3ReadSchema(pParse)) { + goto exit_drop_index; + } + pIndex = sqlite3FindIndex(db, pName.a[0].zName, pName.a[0].zDatabase); + if (pIndex == null) { + if (ifExists == 0) { + sqlite3ErrorMsg(pParse, "no such index: %S", pName, 0); + } else { + sqlite3CodeVerifyNamedSchema(pParse, pName.a[0].zDatabase); + } + pParse.checkSchema = 1; + goto exit_drop_index; + } + if (pIndex.autoIndex != 0) { + sqlite3ErrorMsg(pParse, "index associated with UNIQUE " + + "or PRIMARY KEY constraint cannot be dropped", 0); + goto exit_drop_index; + } + iDb = sqlite3SchemaToIndex(db, pIndex.pSchema); #if !SQLITE_OMIT_AUTHORIZATION { int code = SQLITE_DROP_INDEX; @@ -3464,959 +3154,866 @@ static void sqlite3DropIndex( Parse pParse, SrcList pName, int ifExists ) } #endif - /* Generate code to remove the index and from the master table */ - v = sqlite3GetVdbe( pParse ); - if ( v != null ) - { - sqlite3BeginWriteOperation( pParse, 1, iDb ); - sqlite3NestedParse( pParse, - "DELETE FROM %Q.%s WHERE name=%Q AND type='index'", - db.aDb[iDb].zName, SCHEMA_TABLE( iDb ), - pIndex.zName - ); - if ( sqlite3FindTable( db, "sqlite_stat1", db.aDb[iDb].zName ) != null ) - { - sqlite3NestedParse( pParse, - "DELETE FROM %Q.sqlite_stat1 WHERE idx=%Q", - db.aDb[iDb].zName, pIndex.zName - ); + /* Generate code to remove the index and from the master table */ + v = sqlite3GetVdbe(pParse); + if (v != null) { + sqlite3BeginWriteOperation(pParse, 1, iDb); + sqlite3NestedParse(pParse, + "DELETE FROM %Q.%s WHERE name=%Q AND type='index'", + db.aDb[iDb].zName, SCHEMA_TABLE(iDb), + pIndex.zName + ); + if (sqlite3FindTable(db, "sqlite_stat1", db.aDb[iDb].zName) != null) { + sqlite3NestedParse(pParse, + "DELETE FROM %Q.sqlite_stat1 WHERE idx=%Q", + db.aDb[iDb].zName, pIndex.zName + ); + } + sqlite3ChangeCookie(pParse, iDb); + destroyRootPage(pParse, pIndex.tnum, iDb); + sqlite3VdbeAddOp4(v, OP_DropIndex, iDb, 0, 0, pIndex.zName, 0); + } + + exit_drop_index: + sqlite3SrcListDelete(db, ref pName); } - sqlite3ChangeCookie( pParse, iDb ); - destroyRootPage( pParse, pIndex.tnum, iDb ); - sqlite3VdbeAddOp4( v, OP_DropIndex, iDb, 0, 0, pIndex.zName, 0 ); - } -exit_drop_index: - sqlite3SrcListDelete( db, ref pName ); - } + /* + ** pArray is a pointer to an array of objects. Each object in the + ** array is szEntry bytes in size. This routine allocates a new + ** object on the end of the array. + ** + ** pnEntry is the number of entries already in use. pnAlloc is + ** the previously allocated size of the array. initSize is the + ** suggested initial array size allocation. + ** + ** The index of the new entry is returned in pIdx. + ** + ** This routine returns a pointer to the array of objects. This + ** might be the same as the pArray parameter or it might be a different + ** pointer if the array was resized. + */ + static T[] sqlite3ArrayAllocate( + sqlite3 db, /* Connection to notify of malloc failures */ + T[] pArray, /* Array of objects. Might be reallocated */ + int szEntry, /* Size of each object in the array */ + int initSize, /* Suggested initial allocation, in elements */ + ref int pnEntry, /* Number of objects currently in use */ + ref int pnAlloc, /* Current size of the allocation, in elements */ + ref int pIdx /* Write the index of a new slot here */ + ) where T : new() { + //char* z; + if (pnEntry >= pnAlloc) { + //void* pNew; + int newSize; + newSize = (pnAlloc) * 2 + initSize; + //pNew = sqlite3DbRealloc(db, pArray, newSize * szEntry); + //if (pNew == 0) + //{ + // pIdx = -1; + // return pArray; + //} + pnAlloc = newSize; //sqlite3DbMallocSize(db, pNew)/szEntry; + //pArray = pNew; + Array.Resize(ref pArray, newSize); + } + pArray[pnEntry] = new T(); + //z = (char)pArray; + //memset(z[*pnEntry * szEntry], 0, szEntry); + pIdx = pnEntry; + ++pnEntry; + return pArray; + } - /* - ** pArray is a pointer to an array of objects. Each object in the - ** array is szEntry bytes in size. This routine allocates a new - ** object on the end of the array. - ** - ** pnEntry is the number of entries already in use. pnAlloc is - ** the previously allocated size of the array. initSize is the - ** suggested initial array size allocation. - ** - ** The index of the new entry is returned in pIdx. - ** - ** This routine returns a pointer to the array of objects. This - ** might be the same as the pArray parameter or it might be a different - ** pointer if the array was resized. - */ - static T[] sqlite3ArrayAllocate( - sqlite3 db, /* Connection to notify of malloc failures */ - T[] pArray, /* Array of objects. Might be reallocated */ - int szEntry, /* Size of each object in the array */ - int initSize, /* Suggested initial allocation, in elements */ - ref int pnEntry, /* Number of objects currently in use */ - ref int pnAlloc, /* Current size of the allocation, in elements */ - ref int pIdx /* Write the index of a new slot here */ - ) where T : new() - { - //char* z; - if ( pnEntry >= pnAlloc ) - { - //void* pNew; - int newSize; - newSize = ( pnAlloc ) * 2 + initSize; - //pNew = sqlite3DbRealloc(db, pArray, newSize * szEntry); - //if (pNew == 0) - //{ - // pIdx = -1; - // return pArray; - //} - pnAlloc = newSize; //sqlite3DbMallocSize(db, pNew)/szEntry; - //pArray = pNew; - Array.Resize( ref pArray, newSize ); - } - pArray[pnEntry] = new T(); - //z = (char)pArray; - //memset(z[*pnEntry * szEntry], 0, szEntry); - pIdx = pnEntry; - ++pnEntry; - return pArray; - } + /* + ** Append a new element to the given IdList. Create a new IdList if + ** need be. + ** + ** A new IdList is returned, or NULL if malloc() fails. + */ + // OVERLOADS, so I don't need to rewrite parse.c + static IdList sqlite3IdListAppend(sqlite3 db, int null_2, Token pToken) { + return sqlite3IdListAppend(db, null, pToken); + } + static IdList sqlite3IdListAppend(sqlite3 db, IdList pList, Token pToken) { + int i = 0; + if (pList == null) { + pList = new IdList();//sqlite3DbMallocZero(db, sizeof(IdList)); + if (pList == null) + return null; + pList.nAlloc = 0; + } + pList.a = (IdList_item[])sqlite3ArrayAllocate( + db, + pList.a, + -1,//sizeof(pList.a[0]), + 5, + ref pList.nId, + ref pList.nAlloc, + ref i + ); + if (i < 0) { + sqlite3IdListDelete(db, ref pList); + return null; + } + pList.a[i].zName = sqlite3NameFromToken(db, pToken); + return pList; + } - /* - ** Append a new element to the given IdList. Create a new IdList if - ** need be. - ** - ** A new IdList is returned, or NULL if malloc() fails. - */ - // OVERLOADS, so I don't need to rewrite parse.c - static IdList sqlite3IdListAppend( sqlite3 db, int null_2, Token pToken ) - { - return sqlite3IdListAppend( db, null, pToken ); - } - static IdList sqlite3IdListAppend( sqlite3 db, IdList pList, Token pToken ) - { - int i = 0; - if ( pList == null ) - { - pList = new IdList();//sqlite3DbMallocZero(db, sizeof(IdList)); - if ( pList == null ) - return null; - pList.nAlloc = 0; - } - pList.a = (IdList_item[])sqlite3ArrayAllocate( - db, - pList.a, - -1,//sizeof(pList.a[0]), - 5, - ref pList.nId, - ref pList.nAlloc, - ref i - ); - if ( i < 0 ) - { - sqlite3IdListDelete( db, ref pList ); - return null; - } - pList.a[i].zName = sqlite3NameFromToken( db, pToken ); - return pList; - } + /* + ** Delete an IdList. + */ + static void sqlite3IdListDelete(sqlite3 db, ref IdList pList) { + int i; + if (pList == null) + return; + for (i = 0; i < pList.nId; i++) { + sqlite3DbFree(db, ref pList.a[i].zName); + } + sqlite3DbFree(db, ref pList.a); + sqlite3DbFree(db, ref pList); + } - /* - ** Delete an IdList. - */ - static void sqlite3IdListDelete( sqlite3 db, ref IdList pList ) - { - int i; - if ( pList == null ) - return; - for ( i = 0; i < pList.nId; i++ ) - { - sqlite3DbFree( db, ref pList.a[i].zName ); - } - sqlite3DbFree( db, ref pList.a ); - sqlite3DbFree( db, ref pList ); - } + /* + ** Return the index in pList of the identifier named zId. Return -1 + ** if not found. + */ + static int sqlite3IdListIndex(IdList pList, string zName) { + int i; + if (pList == null) + return -1; + for (i = 0; i < pList.nId; i++) { + if (pList.a[i].zName.Equals(zName, StringComparison.OrdinalIgnoreCase)) + return i; + } + return -1; + } - /* - ** Return the index in pList of the identifier named zId. Return -1 - ** if not found. - */ - static int sqlite3IdListIndex( IdList pList, string zName ) - { - int i; - if ( pList == null ) - return -1; - for ( i = 0; i < pList.nId; i++ ) - { - if ( pList.a[i].zName.Equals( zName, StringComparison.OrdinalIgnoreCase ) ) - return i; - } - return -1; - } + /* + ** Expand the space allocated for the given SrcList object by + ** creating nExtra new slots beginning at iStart. iStart is zero based. + ** New slots are zeroed. + ** + ** For example, suppose a SrcList initially contains two entries: A,B. + ** To append 3 new entries onto the end, do this: + ** + ** sqlite3SrcListEnlarge(db, pSrclist, 3, 2); + ** + ** After the call above it would contain: A, B, nil, nil, nil. + ** If the iStart argument had been 1 instead of 2, then the result + ** would have been: A, nil, nil, nil, B. To prepend the new slots, + ** the iStart value would be 0. The result then would + ** be: nil, nil, nil, A, B. + ** + ** If a memory allocation fails the SrcList is unchanged. The + ** db.mallocFailed flag will be set to true. + */ + static SrcList sqlite3SrcListEnlarge( + sqlite3 db, /* Database connection to notify of OOM errors */ + SrcList pSrc, /* The SrcList to be enlarged */ + int nExtra, /* Number of new slots to add to pSrc.a[] */ + int iStart /* Index in pSrc.a[] of first new slot */ + ) { + int i; - /* - ** Expand the space allocated for the given SrcList object by - ** creating nExtra new slots beginning at iStart. iStart is zero based. - ** New slots are zeroed. - ** - ** For example, suppose a SrcList initially contains two entries: A,B. - ** To append 3 new entries onto the end, do this: - ** - ** sqlite3SrcListEnlarge(db, pSrclist, 3, 2); - ** - ** After the call above it would contain: A, B, nil, nil, nil. - ** If the iStart argument had been 1 instead of 2, then the result - ** would have been: A, nil, nil, nil, B. To prepend the new slots, - ** the iStart value would be 0. The result then would - ** be: nil, nil, nil, A, B. - ** - ** If a memory allocation fails the SrcList is unchanged. The - ** db.mallocFailed flag will be set to true. - */ - static SrcList sqlite3SrcListEnlarge( - sqlite3 db, /* Database connection to notify of OOM errors */ - SrcList pSrc, /* The SrcList to be enlarged */ - int nExtra, /* Number of new slots to add to pSrc.a[] */ - int iStart /* Index in pSrc.a[] of first new slot */ - ) - { - int i; - - /* Sanity checking on calling parameters */ - Debug.Assert( iStart >= 0 ); - Debug.Assert( nExtra >= 1 ); - Debug.Assert( pSrc != null ); - Debug.Assert( iStart <= pSrc.nSrc ); - - /* Allocate additional space if needed */ - if ( pSrc.nSrc + nExtra > pSrc.nAlloc ) - { - int nAlloc = pSrc.nSrc + nExtra; - int nGot; - // sqlite3DbRealloc(db, pSrc, - // sizeof(*pSrc) + (nAlloc-1)*sizeof(pSrc.a[0]) ); - pSrc.nAlloc = (i16)nAlloc; - Array.Resize( ref pSrc.a, nAlloc ); - // nGot = (sqlite3DbMallocSize(db, pNew) - sizeof(*pSrc))/sizeof(pSrc->a[0])+1; - //pSrc->nAlloc = (u16)nGot; - } - - /* Move existing slots that come after the newly inserted slots - ** out of the way */ - for ( i = pSrc.nSrc - 1; i >= iStart; i-- ) - { - pSrc.a[i + nExtra] = pSrc.a[i]; - } - pSrc.nSrc += (i16)nExtra; - - /* Zero the newly allocated slots */ - //memset(&pSrc.a[iStart], 0, sizeof(pSrc.a[0])*nExtra); - for ( i = iStart; i < iStart + nExtra; i++ ) - { - pSrc.a[i] = new SrcList_item(); - pSrc.a[i].iCursor = -1; - } - - /* Return a pointer to the enlarged SrcList */ - return pSrc; - } + /* Sanity checking on calling parameters */ + Debug.Assert(iStart >= 0); + Debug.Assert(nExtra >= 1); + Debug.Assert(pSrc != null); + Debug.Assert(iStart <= pSrc.nSrc); + + /* Allocate additional space if needed */ + if (pSrc.nSrc + nExtra > pSrc.nAlloc) { + int nAlloc = pSrc.nSrc + nExtra; + int nGot; + // sqlite3DbRealloc(db, pSrc, + // sizeof(*pSrc) + (nAlloc-1)*sizeof(pSrc.a[0]) ); + pSrc.nAlloc = (i16)nAlloc; + Array.Resize(ref pSrc.a, nAlloc); + // nGot = (sqlite3DbMallocSize(db, pNew) - sizeof(*pSrc))/sizeof(pSrc->a[0])+1; + //pSrc->nAlloc = (u16)nGot; + } + /* Move existing slots that come after the newly inserted slots + ** out of the way */ + for (i = pSrc.nSrc - 1; i >= iStart; i--) { + pSrc.a[i + nExtra] = pSrc.a[i]; + } + pSrc.nSrc += (i16)nExtra; - /* - ** Append a new table name to the given SrcList. Create a new SrcList if - ** need be. A new entry is created in the SrcList even if pTable is NULL. - ** - ** A SrcList is returned, or NULL if there is an OOM error. The returned - ** SrcList might be the same as the SrcList that was input or it might be - ** a new one. If an OOM error does occurs, then the prior value of pList - ** that is input to this routine is automatically freed. - ** - ** If pDatabase is not null, it means that the table has an optional - ** database name prefix. Like this: "database.table". The pDatabase - ** points to the table name and the pTable points to the database name. - ** The SrcList.a[].zName field is filled with the table name which might - ** come from pTable (if pDatabase is NULL) or from pDatabase. - ** SrcList.a[].zDatabase is filled with the database name from pTable, - ** or with NULL if no database is specified. - ** - ** In other words, if call like this: - ** - ** sqlite3SrcListAppend(D,A,B,0); - ** - ** Then B is a table name and the database name is unspecified. If called - ** like this: - ** - ** sqlite3SrcListAppend(D,A,B,C); - ** - ** Then C is the table name and B is the database name. If C is defined - ** then so is B. In other words, we never have a case where: - ** - ** sqlite3SrcListAppend(D,A,0,C); - ** - ** Both pTable and pDatabase are assumed to be quoted. They are dequoted - ** before being added to the SrcList. - */ - // OVERLOADS, so I don't need to rewrite parse.c - static SrcList sqlite3SrcListAppend( sqlite3 db, int null_2, Token pTable, int null_4 ) - { - return sqlite3SrcListAppend( db, null, pTable, null ); - } - static SrcList sqlite3SrcListAppend( sqlite3 db, int null_2, Token pTable, Token pDatabase ) - { - return sqlite3SrcListAppend( db, null, pTable, pDatabase ); - } - static SrcList sqlite3SrcListAppend( - sqlite3 db, /* Connection to notify of malloc failures */ - SrcList pList, /* Append to this SrcList. NULL creates a new SrcList */ - Token pTable, /* Table to append */ - Token pDatabase /* Database of the table */ - ) - { - SrcList_item pItem; - Debug.Assert( pDatabase == null || pTable != null ); /* Cannot have C without B */ - if ( pList == null ) - { - pList = new SrcList();//sqlite3DbMallocZero(db, SrcList.Length ); - //if ( pList == null ) return null; - pList.nAlloc = 1; - pList.a = new SrcList_item[1]; - } - pList = sqlite3SrcListEnlarge( db, pList, 1, pList.nSrc ); - //if ( db.mallocFailed != 0 ) - //{ - // sqlite3SrcListDelete( db, ref pList ); - // return null; - //} - pItem = pList.a[pList.nSrc - 1]; - if ( pDatabase != null && String.IsNullOrEmpty( pDatabase.z ) ) - { - pDatabase = null; - } - if ( pDatabase != null ) - { - Token pTemp = pDatabase; - pDatabase = pTable; - pTable = pTemp; - } - pItem.zName = sqlite3NameFromToken( db, pTable ); - pItem.zDatabase = sqlite3NameFromToken( db, pDatabase ); - return pList; - } + /* Zero the newly allocated slots */ + //memset(&pSrc.a[iStart], 0, sizeof(pSrc.a[0])*nExtra); + for (i = iStart; i < iStart + nExtra; i++) { + pSrc.a[i] = new SrcList_item(); + pSrc.a[i].iCursor = -1; + } - /* - ** Assign VdbeCursor index numbers to all tables in a SrcList - */ - static void sqlite3SrcListAssignCursors( Parse pParse, SrcList pList ) - { - int i; - SrcList_item pItem; - Debug.Assert( pList != null /* || pParse.db.mallocFailed != 0 */ ); - if ( pList != null ) - { - for ( i = 0; i < pList.nSrc; i++ ) - { - pItem = pList.a[i]; - if ( pItem.iCursor >= 0 ) - break; - pItem.iCursor = pParse.nTab++; - if ( pItem.pSelect != null ) - { - sqlite3SrcListAssignCursors( pParse, pItem.pSelect.pSrc ); - } + /* Return a pointer to the enlarged SrcList */ + return pSrc; } - } - } - /* - ** Delete an entire SrcList including all its substructure. - */ - static void sqlite3SrcListDelete( sqlite3 db, ref SrcList pList ) - { - int i; - SrcList_item pItem; - if ( pList == null ) - return; - for ( i = 0; i < pList.nSrc; i++ ) - {//, pItem++){ - pItem = pList.a[i]; - sqlite3DbFree( db, ref pItem.zDatabase ); - sqlite3DbFree( db, ref pItem.zName ); - sqlite3DbFree( db, ref pItem.zAlias ); - sqlite3DbFree( db, ref pItem.zIndex ); - sqlite3DeleteTable( db, ref pItem.pTab ); - sqlite3SelectDelete( db, ref pItem.pSelect ); - sqlite3ExprDelete( db, ref pItem.pOn ); - sqlite3IdListDelete( db, ref pItem.pUsing ); - } - sqlite3DbFree( db, ref pList ); - } - /* - ** This routine is called by the parser to add a new term to the - ** end of a growing FROM clause. The "p" parameter is the part of - ** the FROM clause that has already been constructed. "p" is NULL - ** if this is the first term of the FROM clause. pTable and pDatabase - ** are the name of the table and database named in the FROM clause term. - ** pDatabase is NULL if the database name qualifier is missing - the - ** usual case. If the term has a alias, then pAlias points to the - ** alias token. If the term is a subquery, then pSubquery is the - ** SELECT statement that the subquery encodes. The pTable and - ** pDatabase parameters are NULL for subqueries. The pOn and pUsing - ** parameters are the content of the ON and USING clauses. - ** - ** Return a new SrcList which encodes is the FROM with the new - ** term added. - */ - // OVERLOADS, so I don't need to rewrite parse.c - static SrcList sqlite3SrcListAppendFromTerm( Parse pParse, SrcList p, int null_3, int null_4, Token pAlias, Select pSubquery, Expr pOn, IdList pUsing ) - { - return sqlite3SrcListAppendFromTerm( pParse, p, null, null, pAlias, pSubquery, pOn, pUsing ); - } - static SrcList sqlite3SrcListAppendFromTerm( Parse pParse, SrcList p, Token pTable, Token pDatabase, Token pAlias, int null_6, Expr pOn, IdList pUsing ) - { - return sqlite3SrcListAppendFromTerm( pParse, p, pTable, pDatabase, pAlias, null, pOn, pUsing ); - } - static SrcList sqlite3SrcListAppendFromTerm( - Parse pParse, /* Parsing context */ - SrcList p, /* The left part of the FROM clause already seen */ - Token pTable, /* Name of the table to add to the FROM clause */ - Token pDatabase, /* Name of the database containing pTable */ - Token pAlias, /* The right-hand side of the AS subexpression */ - Select pSubquery, /* A subquery used in place of a table name */ - Expr pOn, /* The ON clause of a join */ - IdList pUsing /* The USING clause of a join */ - ) - { - SrcList_item pItem; - sqlite3 db = pParse.db; - if ( null == p && ( pOn != null || pUsing != null ) ) - { - sqlite3ErrorMsg( pParse, "a JOIN clause is required before %s", - ( pOn != null ? "ON" : "USING" ) - ); - goto append_from_error; - } - p = sqlite3SrcListAppend( db, p, pTable, pDatabase ); - //if ( p == null || NEVER( p.nSrc == 0 ) ) - //{ - // goto append_from_error; - //} - pItem = p.a[p.nSrc - 1]; - Debug.Assert( pAlias != null ); - if ( pAlias.n != 0 ) - { - pItem.zAlias = sqlite3NameFromToken( db, pAlias ); - } - pItem.pSelect = pSubquery; - pItem.pOn = pOn; - pItem.pUsing = pUsing; - return p; -append_from_error: - Debug.Assert( p == null ); - sqlite3ExprDelete( db, ref pOn ); - sqlite3IdListDelete( db, ref pUsing ); - sqlite3SelectDelete( db, ref pSubquery ); - return null; - } + /* + ** Append a new table name to the given SrcList. Create a new SrcList if + ** need be. A new entry is created in the SrcList even if pTable is NULL. + ** + ** A SrcList is returned, or NULL if there is an OOM error. The returned + ** SrcList might be the same as the SrcList that was input or it might be + ** a new one. If an OOM error does occurs, then the prior value of pList + ** that is input to this routine is automatically freed. + ** + ** If pDatabase is not null, it means that the table has an optional + ** database name prefix. Like this: "database.table". The pDatabase + ** points to the table name and the pTable points to the database name. + ** The SrcList.a[].zName field is filled with the table name which might + ** come from pTable (if pDatabase is NULL) or from pDatabase. + ** SrcList.a[].zDatabase is filled with the database name from pTable, + ** or with NULL if no database is specified. + ** + ** In other words, if call like this: + ** + ** sqlite3SrcListAppend(D,A,B,0); + ** + ** Then B is a table name and the database name is unspecified. If called + ** like this: + ** + ** sqlite3SrcListAppend(D,A,B,C); + ** + ** Then C is the table name and B is the database name. If C is defined + ** then so is B. In other words, we never have a case where: + ** + ** sqlite3SrcListAppend(D,A,0,C); + ** + ** Both pTable and pDatabase are assumed to be quoted. They are dequoted + ** before being added to the SrcList. + */ + // OVERLOADS, so I don't need to rewrite parse.c + static SrcList sqlite3SrcListAppend(sqlite3 db, int null_2, Token pTable, int null_4) { + return sqlite3SrcListAppend(db, null, pTable, null); + } + static SrcList sqlite3SrcListAppend(sqlite3 db, int null_2, Token pTable, Token pDatabase) { + return sqlite3SrcListAppend(db, null, pTable, pDatabase); + } + static SrcList sqlite3SrcListAppend( + sqlite3 db, /* Connection to notify of malloc failures */ + SrcList pList, /* Append to this SrcList. NULL creates a new SrcList */ + Token pTable, /* Table to append */ + Token pDatabase /* Database of the table */ + ) { + SrcList_item pItem; + Debug.Assert(pDatabase == null || pTable != null); /* Cannot have C without B */ + if (pList == null) { + pList = new SrcList();//sqlite3DbMallocZero(db, SrcList.Length ); + //if ( pList == null ) return null; + pList.nAlloc = 1; + pList.a = new SrcList_item[1]; + } + pList = sqlite3SrcListEnlarge(db, pList, 1, pList.nSrc); + //if ( db.mallocFailed != 0 ) + //{ + // sqlite3SrcListDelete( db, ref pList ); + // return null; + //} + pItem = pList.a[pList.nSrc - 1]; + if (pDatabase != null && String.IsNullOrEmpty(pDatabase.z)) { + pDatabase = null; + } + if (pDatabase != null) { + Token pTemp = pDatabase; + pDatabase = pTable; + pTable = pTemp; + } + pItem.zName = sqlite3NameFromToken(db, pTable); + pItem.zDatabase = sqlite3NameFromToken(db, pDatabase); + return pList; + } - /* - ** Add an INDEXED BY or NOT INDEXED clause to the most recently added - ** element of the source-list passed as the second argument. - */ - static void sqlite3SrcListIndexedBy( Parse pParse, SrcList p, Token pIndexedBy ) - { - Debug.Assert( pIndexedBy != null ); - if ( p != null && ALWAYS( p.nSrc > 0 ) ) - { - SrcList_item pItem = p.a[p.nSrc - 1]; - Debug.Assert( 0 == pItem.notIndexed && pItem.zIndex == null ); - if ( pIndexedBy.n == 1 && null == pIndexedBy.z ) - { - /* A "NOT INDEXED" clause was supplied. See parse.y - ** construct "indexed_opt" for details. */ - pItem.notIndexed = 1; + /* + ** Assign VdbeCursor index numbers to all tables in a SrcList + */ + static void sqlite3SrcListAssignCursors(Parse pParse, SrcList pList) { + int i; + SrcList_item pItem; + Debug.Assert(pList != null /* || pParse.db.mallocFailed != 0 */ ); + if (pList != null) { + for (i = 0; i < pList.nSrc; i++) { + pItem = pList.a[i]; + if (pItem.iCursor >= 0) + break; + pItem.iCursor = pParse.nTab++; + if (pItem.pSelect != null) { + sqlite3SrcListAssignCursors(pParse, pItem.pSelect.pSrc); + } + } + } } - else - { - pItem.zIndex = sqlite3NameFromToken( pParse.db, pIndexedBy ); + + /* + ** Delete an entire SrcList including all its substructure. + */ + static void sqlite3SrcListDelete(sqlite3 db, ref SrcList pList) { + int i; + SrcList_item pItem; + if (pList == null) + return; + for (i = 0; i < pList.nSrc; i++) {//, pItem++){ + pItem = pList.a[i]; + sqlite3DbFree(db, ref pItem.zDatabase); + sqlite3DbFree(db, ref pItem.zName); + sqlite3DbFree(db, ref pItem.zAlias); + sqlite3DbFree(db, ref pItem.zIndex); + sqlite3DeleteTable(db, ref pItem.pTab); + sqlite3SelectDelete(db, ref pItem.pSelect); + sqlite3ExprDelete(db, ref pItem.pOn); + sqlite3IdListDelete(db, ref pItem.pUsing); + } + sqlite3DbFree(db, ref pList); } - } - } - /* - ** When building up a FROM clause in the parser, the join operator - ** is initially attached to the left operand. But the code generator - ** expects the join operator to be on the right operand. This routine - ** Shifts all join operators from left to right for an entire FROM - ** clause. - ** - ** Example: Suppose the join is like this: - ** - ** A natural cross join B - ** - ** The operator is "natural cross join". The A and B operands are stored - ** in p.a[0] and p.a[1], respectively. The parser initially stores the - ** operator with A. This routine shifts that operator over to B. - */ - static void sqlite3SrcListShiftJoinType( SrcList p ) - { - if ( p != null && p.a != null ) - { - int i; - for ( i = p.nSrc - 1; i > 0; i-- ) - { - p.a[i].jointype = p.a[i - 1].jointype; + /* + ** This routine is called by the parser to add a new term to the + ** end of a growing FROM clause. The "p" parameter is the part of + ** the FROM clause that has already been constructed. "p" is NULL + ** if this is the first term of the FROM clause. pTable and pDatabase + ** are the name of the table and database named in the FROM clause term. + ** pDatabase is NULL if the database name qualifier is missing - the + ** usual case. If the term has a alias, then pAlias points to the + ** alias token. If the term is a subquery, then pSubquery is the + ** SELECT statement that the subquery encodes. The pTable and + ** pDatabase parameters are NULL for subqueries. The pOn and pUsing + ** parameters are the content of the ON and USING clauses. + ** + ** Return a new SrcList which encodes is the FROM with the new + ** term added. + */ + // OVERLOADS, so I don't need to rewrite parse.c + static SrcList sqlite3SrcListAppendFromTerm(Parse pParse, SrcList p, int null_3, int null_4, Token pAlias, Select pSubquery, Expr pOn, IdList pUsing) { + return sqlite3SrcListAppendFromTerm(pParse, p, null, null, pAlias, pSubquery, pOn, pUsing); + } + static SrcList sqlite3SrcListAppendFromTerm(Parse pParse, SrcList p, Token pTable, Token pDatabase, Token pAlias, int null_6, Expr pOn, IdList pUsing) { + return sqlite3SrcListAppendFromTerm(pParse, p, pTable, pDatabase, pAlias, null, pOn, pUsing); + } + static SrcList sqlite3SrcListAppendFromTerm( + Parse pParse, /* Parsing context */ + SrcList p, /* The left part of the FROM clause already seen */ + Token pTable, /* Name of the table to add to the FROM clause */ + Token pDatabase, /* Name of the database containing pTable */ + Token pAlias, /* The right-hand side of the AS subexpression */ + Select pSubquery, /* A subquery used in place of a table name */ + Expr pOn, /* The ON clause of a join */ + IdList pUsing /* The USING clause of a join */ + ) { + SrcList_item pItem; + sqlite3 db = pParse.db; + if (null == p && (pOn != null || pUsing != null)) { + sqlite3ErrorMsg(pParse, "a JOIN clause is required before %s", + (pOn != null ? "ON" : "USING") + ); + goto append_from_error; + } + p = sqlite3SrcListAppend(db, p, pTable, pDatabase); + //if ( p == null || NEVER( p.nSrc == 0 ) ) + //{ + // goto append_from_error; + //} + pItem = p.a[p.nSrc - 1]; + Debug.Assert(pAlias != null); + if (pAlias.n != 0) { + pItem.zAlias = sqlite3NameFromToken(db, pAlias); + } + pItem.pSelect = pSubquery; + pItem.pOn = pOn; + pItem.pUsing = pUsing; + return p; + append_from_error: + Debug.Assert(p == null); + sqlite3ExprDelete(db, ref pOn); + sqlite3IdListDelete(db, ref pUsing); + sqlite3SelectDelete(db, ref pSubquery); + return null; } - p.a[0].jointype = 0; - } - } - /* - ** Begin a transaction - */ - static void sqlite3BeginTransaction( Parse pParse, int type ) - { - sqlite3 db; - Vdbe v; - int i; - - Debug.Assert( pParse != null ); - db = pParse.db; - Debug.Assert( db != null ); - /* if( db.aDb[0].pBt==0 ) return; */ - if ( sqlite3AuthCheck( pParse, SQLITE_TRANSACTION, "BEGIN", null, null ) != 0 ) - { - return; - } - v = sqlite3GetVdbe( pParse ); - if ( v == null ) - return; - if ( type != TK_DEFERRED ) - { - for ( i = 0; i < db.nDb; i++ ) - { - sqlite3VdbeAddOp2( v, OP_Transaction, i, ( type == TK_EXCLUSIVE ) ? 2 : 1 ); - sqlite3VdbeUsesBtree( v, i ); + /* + ** Add an INDEXED BY or NOT INDEXED clause to the most recently added + ** element of the source-list passed as the second argument. + */ + static void sqlite3SrcListIndexedBy(Parse pParse, SrcList p, Token pIndexedBy) { + Debug.Assert(pIndexedBy != null); + if (p != null && ALWAYS(p.nSrc > 0)) { + SrcList_item pItem = p.a[p.nSrc - 1]; + Debug.Assert(0 == pItem.notIndexed && pItem.zIndex == null); + if (pIndexedBy.n == 1 && null == pIndexedBy.z) { + /* A "NOT INDEXED" clause was supplied. See parse.y + ** construct "indexed_opt" for details. */ + pItem.notIndexed = 1; + } else { + pItem.zIndex = sqlite3NameFromToken(pParse.db, pIndexedBy); + } + } } - } - sqlite3VdbeAddOp2( v, OP_AutoCommit, 0, 0 ); - } - /* - ** Commit a transaction - */ - static void sqlite3CommitTransaction( Parse pParse ) - { - sqlite3 db; - Vdbe v; - - Debug.Assert( pParse != null ); - db = pParse.db; - Debug.Assert( db != null ); - /* if( db.aDb[0].pBt==0 ) return; */ - if ( sqlite3AuthCheck( pParse, SQLITE_TRANSACTION, "COMMIT", null, null ) != 0 ) - { - return; - } - v = sqlite3GetVdbe( pParse ); - if ( v != null ) - { - sqlite3VdbeAddOp2( v, OP_AutoCommit, 1, 0 ); - } - } + /* + ** When building up a FROM clause in the parser, the join operator + ** is initially attached to the left operand. But the code generator + ** expects the join operator to be on the right operand. This routine + ** Shifts all join operators from left to right for an entire FROM + ** clause. + ** + ** Example: Suppose the join is like this: + ** + ** A natural cross join B + ** + ** The operator is "natural cross join". The A and B operands are stored + ** in p.a[0] and p.a[1], respectively. The parser initially stores the + ** operator with A. This routine shifts that operator over to B. + */ + static void sqlite3SrcListShiftJoinType(SrcList p) { + if (p != null && p.a != null) { + int i; + for (i = p.nSrc - 1; i > 0; i--) { + p.a[i].jointype = p.a[i - 1].jointype; + } + p.a[0].jointype = 0; + } + } - /* - ** Rollback a transaction - */ - static void sqlite3RollbackTransaction( Parse pParse ) - { - sqlite3 db; - Vdbe v; - - Debug.Assert( pParse != null ); - db = pParse.db; - Debug.Assert( db != null ); - /* if( db.aDb[0].pBt==0 ) return; */ - if ( sqlite3AuthCheck( pParse, SQLITE_TRANSACTION, "ROLLBACK", null, null ) != 0 ) - { - return; - } - v = sqlite3GetVdbe( pParse ); - if ( v != null ) - { - sqlite3VdbeAddOp2( v, OP_AutoCommit, 1, 1 ); - } - } + /* + ** Begin a transaction + */ + static void sqlite3BeginTransaction(Parse pParse, int type) { + sqlite3 db; + Vdbe v; + int i; - /* - ** This function is called by the parser when it parses a command to create, - ** release or rollback an SQL savepoint. - */ + Debug.Assert(pParse != null); + db = pParse.db; + Debug.Assert(db != null); + /* if( db.aDb[0].pBt==0 ) return; */ + if (sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "BEGIN", null, null) != 0) { + return; + } + v = sqlite3GetVdbe(pParse); + if (v == null) + return; + if (type != TK_DEFERRED) { + for (i = 0; i < db.nDb; i++) { + sqlite3VdbeAddOp2(v, OP_Transaction, i, (type == TK_EXCLUSIVE) ? 2 : 1); + sqlite3VdbeUsesBtree(v, i); + } + } + sqlite3VdbeAddOp2(v, OP_AutoCommit, 0, 0); + } + + /* + ** Commit a transaction + */ + static void sqlite3CommitTransaction(Parse pParse) { + sqlite3 db; + Vdbe v; + + Debug.Assert(pParse != null); + db = pParse.db; + Debug.Assert(db != null); + /* if( db.aDb[0].pBt==0 ) return; */ + if (sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "COMMIT", null, null) != 0) { + return; + } + v = sqlite3GetVdbe(pParse); + if (v != null) { + sqlite3VdbeAddOp2(v, OP_AutoCommit, 1, 0); + } + } + + /* + ** Rollback a transaction + */ + static void sqlite3RollbackTransaction(Parse pParse) { + sqlite3 db; + Vdbe v; + + Debug.Assert(pParse != null); + db = pParse.db; + Debug.Assert(db != null); + /* if( db.aDb[0].pBt==0 ) return; */ + if (sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "ROLLBACK", null, null) != 0) { + return; + } + v = sqlite3GetVdbe(pParse); + if (v != null) { + sqlite3VdbeAddOp2(v, OP_AutoCommit, 1, 1); + } + } + + /* + ** This function is called by the parser when it parses a command to create, + ** release or rollback an SQL savepoint. + */ #if !SQLITE_OMIT_AUTHORIZATION const string[] az = { "BEGIN", "RELEASE", "ROLLBACK" }; #endif - static void sqlite3Savepoint( Parse pParse, int op, Token pName ) - { - string zName = sqlite3NameFromToken( pParse.db, pName ); - if ( zName != null ) - { - Vdbe v = sqlite3GetVdbe( pParse ); + static void sqlite3Savepoint(Parse pParse, int op, Token pName) { + string zName = sqlite3NameFromToken(pParse.db, pName); + if (zName != null) { + Vdbe v = sqlite3GetVdbe(pParse); #if !SQLITE_OMIT_AUTHORIZATION Debug.Assert( !SAVEPOINT_BEGIN && SAVEPOINT_RELEASE==1 && SAVEPOINT_ROLLBACK==2 ); #endif - if ( null == v + if (null == v #if !SQLITE_OMIT_AUTHORIZATION || sqlite3AuthCheck(pParse, SQLITE_SAVEPOINT, az[op], zName, 0) #endif - ) - { - sqlite3DbFree( pParse.db, ref zName ); - return; + ) { + sqlite3DbFree(pParse.db, ref zName); + return; + } + sqlite3VdbeAddOp4(v, OP_Savepoint, op, 0, 0, zName, P4_DYNAMIC); + } } - sqlite3VdbeAddOp4( v, OP_Savepoint, op, 0, 0, zName, P4_DYNAMIC ); - } - } - /* - ** Make sure the TEMP database is open and available for use. Return - ** the number of errors. Leave any error messages in the pParse structure. - */ - static int sqlite3OpenTempDatabase( Parse pParse ) - { - sqlite3 db = pParse.db; - if ( db.aDb[1].pBt == null && pParse.explain == 0 ) - { - int rc; - Btree pBt = null; - const int flags = - SQLITE_OPEN_READWRITE | - SQLITE_OPEN_CREATE | - SQLITE_OPEN_EXCLUSIVE | - SQLITE_OPEN_DELETEONCLOSE | - SQLITE_OPEN_TEMP_DB; - - rc = sqlite3BtreeOpen(db.pVfs, null, db, ref pBt, 0, flags ); - if ( rc != SQLITE_OK ) - { - sqlite3ErrorMsg( pParse, "unable to open a temporary database " + - "file for storing temporary tables" ); - pParse.rc = rc; - return 1; - } - db.aDb[1].pBt = pBt; - Debug.Assert( db.aDb[1].pSchema != null ); - if ( SQLITE_NOMEM == sqlite3BtreeSetPageSize( pBt, db.nextPagesize, -1, 0 ) ) - { - // db.mallocFailed = 1; + /* + ** Make sure the TEMP database is open and available for use. Return + ** the number of errors. Leave any error messages in the pParse structure. + */ + static int sqlite3OpenTempDatabase(Parse pParse) { + sqlite3 db = pParse.db; + if (db.aDb[1].pBt == null && pParse.explain == 0) { + int rc; + Btree pBt = null; + const int flags = + SQLITE_OPEN_READWRITE | + SQLITE_OPEN_CREATE | + SQLITE_OPEN_EXCLUSIVE | + SQLITE_OPEN_DELETEONCLOSE | + SQLITE_OPEN_TEMP_DB; + + rc = sqlite3BtreeOpen(db.pVfs, null, db, ref pBt, 0, flags); + if (rc != SQLITE_OK) { + sqlite3ErrorMsg(pParse, "unable to open a temporary database " + + "file for storing temporary tables"); + pParse.rc = rc; + return 1; + } + db.aDb[1].pBt = pBt; + Debug.Assert(db.aDb[1].pSchema != null); + if (SQLITE_NOMEM == sqlite3BtreeSetPageSize(pBt, db.nextPagesize, -1, 0)) { + // db.mallocFailed = 1; + } + } + return 0; } - } - return 0; - } - /* - ** Generate VDBE code that will verify the schema cookie and start - ** a read-transaction for all named database files. - ** - ** It is important that all schema cookies be verified and all - ** read transactions be started before anything else happens in - ** the VDBE program. But this routine can be called after much other - ** code has been generated. So here is what we do: - ** - ** The first time this routine is called, we code an OP_Goto that - ** will jump to a subroutine at the end of the program. Then we - ** record every database that needs its schema verified in the - ** pParse.cookieMask field. Later, after all other code has been - ** generated, the subroutine that does the cookie verifications and - ** starts the transactions will be coded and the OP_Goto P2 value - ** will be made to point to that subroutine. The generation of the - ** cookie verification subroutine code happens in sqlite3FinishCoding(). - ** - ** If iDb<0 then code the OP_Goto only - don't set flag to verify the - ** schema on any databases. This can be used to position the OP_Goto - ** early in the code, before we know if any database tables will be used. - */ - static void sqlite3CodeVerifySchema( Parse pParse, int iDb ) - { - Parse pToplevel = sqlite3ParseToplevel( pParse ); - - if ( pToplevel.cookieGoto == 0 ) - { - Vdbe v = sqlite3GetVdbe( pToplevel ); - if ( v == null ) - return; /* This only happens if there was a prior error */ - pToplevel.cookieGoto = sqlite3VdbeAddOp2( v, OP_Goto, 0, 0 ) + 1; - } - if ( iDb >= 0 ) - { - sqlite3 db = pToplevel.db; - yDbMask mask; - Debug.Assert( iDb < db.nDb ); - Debug.Assert( db.aDb[iDb].pBt != null || iDb == 1 ); - Debug.Assert( iDb < SQLITE_MAX_ATTACHED + 2 ); - Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); - mask = ( (yDbMask)1 ) << iDb; - if ( ( pToplevel.cookieMask & mask ) == 0 ) - { - pToplevel.cookieMask |= mask; - pToplevel.cookieValue[iDb] = db.aDb[iDb].pSchema.schema_cookie; - if ( 0 == OMIT_TEMPDB && iDb == 1 ) - { - sqlite3OpenTempDatabase( pToplevel ); - } + /* + ** Generate VDBE code that will verify the schema cookie and start + ** a read-transaction for all named database files. + ** + ** It is important that all schema cookies be verified and all + ** read transactions be started before anything else happens in + ** the VDBE program. But this routine can be called after much other + ** code has been generated. So here is what we do: + ** + ** The first time this routine is called, we code an OP_Goto that + ** will jump to a subroutine at the end of the program. Then we + ** record every database that needs its schema verified in the + ** pParse.cookieMask field. Later, after all other code has been + ** generated, the subroutine that does the cookie verifications and + ** starts the transactions will be coded and the OP_Goto P2 value + ** will be made to point to that subroutine. The generation of the + ** cookie verification subroutine code happens in sqlite3FinishCoding(). + ** + ** If iDb<0 then code the OP_Goto only - don't set flag to verify the + ** schema on any databases. This can be used to position the OP_Goto + ** early in the code, before we know if any database tables will be used. + */ + static void sqlite3CodeVerifySchema(Parse pParse, int iDb) { + Parse pToplevel = sqlite3ParseToplevel(pParse); + + if (pToplevel.cookieGoto == 0) { + Vdbe v = sqlite3GetVdbe(pToplevel); + if (v == null) + return; /* This only happens if there was a prior error */ + pToplevel.cookieGoto = sqlite3VdbeAddOp2(v, OP_Goto, 0, 0) + 1; + } + if (iDb >= 0) { + sqlite3 db = pToplevel.db; + yDbMask mask; + Debug.Assert(iDb < db.nDb); + Debug.Assert(db.aDb[iDb].pBt != null || iDb == 1); + Debug.Assert(iDb < SQLITE_MAX_ATTACHED + 2); + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + mask = ((yDbMask)1) << iDb; + if ((pToplevel.cookieMask & mask) == 0) { + pToplevel.cookieMask |= mask; + pToplevel.cookieValue[iDb] = db.aDb[iDb].pSchema.schema_cookie; + if (0 == OMIT_TEMPDB && iDb == 1) { + sqlite3OpenTempDatabase(pToplevel); + } + } + } } - } - } - /* - ** If argument zDb is NULL, then call sqlite3CodeVerifySchema() for each - ** attached database. Otherwise, invoke it for the database named zDb only. - */ - static void sqlite3CodeVerifyNamedSchema( Parse pParse, string zDb ) - { - sqlite3 db = pParse.db; - int i; - for ( i = 0; i < db.nDb; i++ ) - { - Db pDb = db.aDb[i]; - if ( pDb.pBt != null && ( null == zDb || string.Equals( zDb, pDb.zName, StringComparison.Ordinal ) ) ) - { - sqlite3CodeVerifySchema( pParse, i ); + /* + ** If argument zDb is NULL, then call sqlite3CodeVerifySchema() for each + ** attached database. Otherwise, invoke it for the database named zDb only. + */ + static void sqlite3CodeVerifyNamedSchema(Parse pParse, string zDb) { + sqlite3 db = pParse.db; + int i; + for (i = 0; i < db.nDb; i++) { + Db pDb = db.aDb[i]; + if (pDb.pBt != null && (null == zDb || string.Equals(zDb, pDb.zName, StringComparison.Ordinal))) { + sqlite3CodeVerifySchema(pParse, i); + } + } + } + /* + ** Generate VDBE code that prepares for doing an operation that + ** might change the database. + ** + ** This routine starts a new transaction if we are not already within + ** a transaction. If we are already within a transaction, then a checkpoint + ** is set if the setStatement parameter is true. A checkpoint should + ** be set for operations that might fail (due to a constraint) part of + ** the way through and which will need to undo some writes without having to + ** rollback the whole transaction. For operations where all constraints + ** can be checked before any changes are made to the database, it is never + ** necessary to undo a write and the checkpoint should not be set. + */ + static void sqlite3BeginWriteOperation(Parse pParse, int setStatement, int iDb) { + Parse pToplevel = sqlite3ParseToplevel(pParse); + sqlite3CodeVerifySchema(pParse, iDb); + pToplevel.writeMask |= ((yDbMask)1) << iDb; + pToplevel.isMultiWrite |= (u8)setStatement; } - } - } - /* - ** Generate VDBE code that prepares for doing an operation that - ** might change the database. - ** - ** This routine starts a new transaction if we are not already within - ** a transaction. If we are already within a transaction, then a checkpoint - ** is set if the setStatement parameter is true. A checkpoint should - ** be set for operations that might fail (due to a constraint) part of - ** the way through and which will need to undo some writes without having to - ** rollback the whole transaction. For operations where all constraints - ** can be checked before any changes are made to the database, it is never - ** necessary to undo a write and the checkpoint should not be set. - */ - static void sqlite3BeginWriteOperation( Parse pParse, int setStatement, int iDb ) - { - Parse pToplevel = sqlite3ParseToplevel( pParse ); - sqlite3CodeVerifySchema( pParse, iDb ); - pToplevel.writeMask |= ( (yDbMask)1 ) << iDb; - pToplevel.isMultiWrite |= (u8)setStatement; - } - /* - ** Indicate that the statement currently under construction might write - ** more than one entry (example: deleting one row then inserting another, - ** inserting multiple rows in a table, or inserting a row and index entries.) - ** If an abort occurs after some of these writes have completed, then it will - ** be necessary to undo the completed writes. - */ - static void sqlite3MultiWrite( Parse pParse ) - { - Parse pToplevel = sqlite3ParseToplevel( pParse ); - pToplevel.isMultiWrite = 1; - } + /* + ** Indicate that the statement currently under construction might write + ** more than one entry (example: deleting one row then inserting another, + ** inserting multiple rows in a table, or inserting a row and index entries.) + ** If an abort occurs after some of these writes have completed, then it will + ** be necessary to undo the completed writes. + */ + static void sqlite3MultiWrite(Parse pParse) { + Parse pToplevel = sqlite3ParseToplevel(pParse); + pToplevel.isMultiWrite = 1; + } - /* - ** The code generator calls this routine if is discovers that it is - ** possible to abort a statement prior to completion. In order to - ** perform this abort without corrupting the database, we need to make - ** sure that the statement is protected by a statement transaction. - ** - ** Technically, we only need to set the mayAbort flag if the - ** isMultiWrite flag was previously set. There is a time dependency - ** such that the abort must occur after the multiwrite. This makes - ** some statements involving the REPLACE conflict resolution algorithm - ** go a little faster. But taking advantage of this time dependency - ** makes it more difficult to prove that the code is correct (in - ** particular, it prevents us from writing an effective - ** implementation of sqlite3AssertMayAbort()) and so we have chosen - ** to take the safe route and skip the optimization. - */ - static void sqlite3MayAbort( Parse pParse ) - { - Parse pToplevel = sqlite3ParseToplevel( pParse ); - pToplevel.mayAbort = 1; - } + /* + ** The code generator calls this routine if is discovers that it is + ** possible to abort a statement prior to completion. In order to + ** perform this abort without corrupting the database, we need to make + ** sure that the statement is protected by a statement transaction. + ** + ** Technically, we only need to set the mayAbort flag if the + ** isMultiWrite flag was previously set. There is a time dependency + ** such that the abort must occur after the multiwrite. This makes + ** some statements involving the REPLACE conflict resolution algorithm + ** go a little faster. But taking advantage of this time dependency + ** makes it more difficult to prove that the code is correct (in + ** particular, it prevents us from writing an effective + ** implementation of sqlite3AssertMayAbort()) and so we have chosen + ** to take the safe route and skip the optimization. + */ + static void sqlite3MayAbort(Parse pParse) { + Parse pToplevel = sqlite3ParseToplevel(pParse); + pToplevel.mayAbort = 1; + } - /* - ** Code an OP_Halt that causes the vdbe to return an SQLITE_CONSTRAINT - ** error. The onError parameter determines which (if any) of the statement - ** and/or current transaction is rolled back. - */ - static void sqlite3HaltConstraint( Parse pParse, int onError, string p4, int p4type ) - { - Vdbe v = sqlite3GetVdbe( pParse ); - if ( onError == OE_Abort ) - { - sqlite3MayAbort( pParse ); - } - sqlite3VdbeAddOp4( v, OP_Halt, SQLITE_CONSTRAINT, onError, 0, p4, p4type ); - } + /* + ** Code an OP_Halt that causes the vdbe to return an SQLITE_CONSTRAINT + ** error. The onError parameter determines which (if any) of the statement + ** and/or current transaction is rolled back. + */ + static void sqlite3HaltConstraint(Parse pParse, int onError, string p4, int p4type) { + Vdbe v = sqlite3GetVdbe(pParse); + if (onError == OE_Abort) { + sqlite3MayAbort(pParse); + } + sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_CONSTRAINT, onError, 0, p4, p4type); + } - static void sqlite3HaltConstraint( Parse pParse, int onError, byte[] p4, int p4type ) - { - Vdbe v = sqlite3GetVdbe( pParse ); - if ( onError == OE_Abort ) - { - sqlite3MayAbort( pParse ); - } - sqlite3VdbeAddOp4( v, OP_Halt, SQLITE_CONSTRAINT, onError, 0, p4, p4type ); - } + static void sqlite3HaltConstraint(Parse pParse, int onError, byte[] p4, int p4type) { + Vdbe v = sqlite3GetVdbe(pParse); + if (onError == OE_Abort) { + sqlite3MayAbort(pParse); + } + sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_CONSTRAINT, onError, 0, p4, p4type); + } - /* - ** Check to see if pIndex uses the collating sequence pColl. Return - ** true if it does and false if it does not. - */ + /* + ** Check to see if pIndex uses the collating sequence pColl. Return + ** true if it does and false if it does not. + */ #if !SQLITE_OMIT_REINDEX - static bool collationMatch( string zColl, Index pIndex ) - { - int i; - Debug.Assert( zColl != null ); - for ( i = 0; i < pIndex.nColumn; i++ ) - { - string z = pIndex.azColl[i]; - Debug.Assert( z != null ); - if ( z.Equals( zColl, StringComparison.OrdinalIgnoreCase ) ) - { - return true; + static bool collationMatch(string zColl, Index pIndex) { + int i; + Debug.Assert(zColl != null); + for (i = 0; i < pIndex.nColumn; i++) { + string z = pIndex.azColl[i]; + Debug.Assert(z != null); + if (z.Equals(zColl, StringComparison.OrdinalIgnoreCase)) { + return true; + } + } + return false; } - } - return false; - } #endif - /* -** Recompute all indices of pTab that use the collating sequence pColl. -** If pColl == null then recompute all indices of pTab. -*/ + /* + ** Recompute all indices of pTab that use the collating sequence pColl. + ** If pColl == null then recompute all indices of pTab. + */ #if !SQLITE_OMIT_REINDEX - static void reindexTable( Parse pParse, Table pTab, string zColl ) - { - Index pIndex; /* An index associated with pTab */ - - for ( pIndex = pTab.pIndex; pIndex != null; pIndex = pIndex.pNext ) - { - if ( zColl == null || collationMatch( zColl, pIndex ) ) - { - int iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema ); - sqlite3BeginWriteOperation( pParse, 0, iDb ); - sqlite3RefillIndex( pParse, pIndex, -1 ); + static void reindexTable(Parse pParse, Table pTab, string zColl) { + Index pIndex; /* An index associated with pTab */ + + for (pIndex = pTab.pIndex; pIndex != null; pIndex = pIndex.pNext) { + if (zColl == null || collationMatch(zColl, pIndex)) { + int iDb = sqlite3SchemaToIndex(pParse.db, pTab.pSchema); + sqlite3BeginWriteOperation(pParse, 0, iDb); + sqlite3RefillIndex(pParse, pIndex, -1); + } + } } - } - } #endif - /* -** Recompute all indices of all tables in all databases where the -** indices use the collating sequence pColl. If pColl == null then recompute -** all indices everywhere. -*/ + /* + ** Recompute all indices of all tables in all databases where the + ** indices use the collating sequence pColl. If pColl == null then recompute + ** all indices everywhere. + */ #if !SQLITE_OMIT_REINDEX - static void reindexDatabases( Parse pParse, string zColl ) - { - Db pDb; /* A single database */ - int iDb; /* The database index number */ - sqlite3 db = pParse.db; /* The database connection */ - HashElem k; /* For looping over tables in pDb */ - Table pTab; /* A table in the database */ - - Debug.Assert( sqlite3BtreeHoldsAllMutexes( db ) ); /* Needed for schema access */ - for ( iDb = 0; iDb < db.nDb; iDb++ )//, pDb++ ) - { - pDb = db.aDb[iDb]; - Debug.Assert( pDb != null ); - for ( k = pDb.pSchema.tblHash.first; k != null; k = k.next ) //for ( k = sqliteHashFirst( pDb.pSchema.tblHash ) ; k != null ; k = sqliteHashNext( k ) ) - { - pTab = (Table)k.data;// sqliteHashData( k ); - reindexTable( pParse, pTab, zColl ); + static void reindexDatabases(Parse pParse, string zColl) { + Db pDb; /* A single database */ + int iDb; /* The database index number */ + sqlite3 db = pParse.db; /* The database connection */ + HashElem k; /* For looping over tables in pDb */ + Table pTab; /* A table in the database */ + + Debug.Assert(sqlite3BtreeHoldsAllMutexes(db)); /* Needed for schema access */ + for (iDb = 0; iDb < db.nDb; iDb++)//, pDb++ ) + { + pDb = db.aDb[iDb]; + Debug.Assert(pDb != null); + for (k = pDb.pSchema.tblHash.first; k != null; k = k.next) //for ( k = sqliteHashFirst( pDb.pSchema.tblHash ) ; k != null ; k = sqliteHashNext( k ) ) + { + pTab = (Table)k.data;// sqliteHashData( k ); + reindexTable(pParse, pTab, zColl); + } + } } - } - } #endif - /* -** Generate code for the REINDEX command. -** -** REINDEX -- 1 -** REINDEX -- 2 -** REINDEX ?.? -- 3 -** REINDEX ?.? -- 4 -** -** Form 1 causes all indices in all attached databases to be rebuilt. -** Form 2 rebuilds all indices in all databases that use the named -** collating function. Forms 3 and 4 rebuild the named index or all -** indices associated with the named table. -*/ + /* + ** Generate code for the REINDEX command. + ** + ** REINDEX -- 1 + ** REINDEX -- 2 + ** REINDEX ?.? -- 3 + ** REINDEX ?.? -- 4 + ** + ** Form 1 causes all indices in all attached databases to be rebuilt. + ** Form 2 rebuilds all indices in all databases that use the named + ** collating function. Forms 3 and 4 rebuild the named index or all + ** indices associated with the named table. + */ #if !SQLITE_OMIT_REINDEX - // OVERLOADS, so I don't need to rewrite parse.c - static void sqlite3Reindex( Parse pParse, int null_2, int null_3 ) - { - sqlite3Reindex( pParse, null, null ); - } - static void sqlite3Reindex( Parse pParse, Token pName1, Token pName2 ) - { - CollSeq pColl; /* Collating sequence to be reindexed, or NULL */ - string z; /* Name of a table or index */ - string zDb; /* Name of the database */ - Table pTab; /* A table in the database */ - Index pIndex; /* An index associated with pTab */ - int iDb; /* The database index number */ - sqlite3 db = pParse.db; /* The database connection */ - Token pObjName = new Token(); /* Name of the table or index to be reindexed */ - - /* Read the database schema. If an error occurs, leave an error message - ** and code in pParse and return NULL. */ - if ( SQLITE_OK != sqlite3ReadSchema( pParse ) ) - { - return; - } - - if ( pName1 == null ) - { - reindexDatabases( pParse, null ); - return; - } - else if ( NEVER( pName2 == null ) || pName2.z == null || pName2.z.Length == 0 ) - { - string zColl; - Debug.Assert( pName1.z != null ); - zColl = sqlite3NameFromToken( pParse.db, pName1 ); - if ( zColl == null ) - return; - pColl = sqlite3FindCollSeq( db, ENC( db ), zColl, 0 ); - if ( pColl != null ) - { - reindexDatabases( pParse, zColl ); - sqlite3DbFree( db, ref zColl ); - return; + // OVERLOADS, so I don't need to rewrite parse.c + static void sqlite3Reindex(Parse pParse, int null_2, int null_3) { + sqlite3Reindex(pParse, null, null); + } + static void sqlite3Reindex(Parse pParse, Token pName1, Token pName2) { + CollSeq pColl; /* Collating sequence to be reindexed, or NULL */ + string z; /* Name of a table or index */ + string zDb; /* Name of the database */ + Table pTab; /* A table in the database */ + Index pIndex; /* An index associated with pTab */ + int iDb; /* The database index number */ + sqlite3 db = pParse.db; /* The database connection */ + Token pObjName = new Token(); /* Name of the table or index to be reindexed */ + + /* Read the database schema. If an error occurs, leave an error message + ** and code in pParse and return NULL. */ + if (SQLITE_OK != sqlite3ReadSchema(pParse)) { + return; + } + + if (pName1 == null) { + reindexDatabases(pParse, null); + return; + } else if (NEVER(pName2 == null) || pName2.z == null || pName2.z.Length == 0) { + string zColl; + Debug.Assert(pName1.z != null); + zColl = sqlite3NameFromToken(pParse.db, pName1); + if (zColl == null) + return; + pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0); + if (pColl != null) { + reindexDatabases(pParse, zColl); + sqlite3DbFree(db, ref zColl); + return; + } + sqlite3DbFree(db, ref zColl); + } + iDb = sqlite3TwoPartName(pParse, pName1, pName2, ref pObjName); + if (iDb < 0) + return; + z = sqlite3NameFromToken(db, pObjName); + if (z == null) + return; + zDb = db.aDb[iDb].zName; + pTab = sqlite3FindTable(db, z, zDb); + if (pTab != null) { + reindexTable(pParse, pTab, null); + sqlite3DbFree(db, ref z); + return; + } + pIndex = sqlite3FindIndex(db, z, zDb); + sqlite3DbFree(db, ref z); + if (pIndex != null) { + sqlite3BeginWriteOperation(pParse, 0, iDb); + sqlite3RefillIndex(pParse, pIndex, -1); + return; + } + sqlite3ErrorMsg(pParse, "unable to identify the object to be reindexed"); } - sqlite3DbFree( db, ref zColl ); - } - iDb = sqlite3TwoPartName( pParse, pName1, pName2, ref pObjName ); - if ( iDb < 0 ) - return; - z = sqlite3NameFromToken( db, pObjName ); - if ( z == null ) - return; - zDb = db.aDb[iDb].zName; - pTab = sqlite3FindTable( db, z, zDb ); - if ( pTab != null ) - { - reindexTable( pParse, pTab, null ); - sqlite3DbFree( db, ref z ); - return; - } - pIndex = sqlite3FindIndex( db, z, zDb ); - sqlite3DbFree( db, ref z ); - if ( pIndex != null ) - { - sqlite3BeginWriteOperation( pParse, 0, iDb ); - sqlite3RefillIndex( pParse, pIndex, -1 ); - return; - } - sqlite3ErrorMsg( pParse, "unable to identify the object to be reindexed" ); - } #endif - /* -** Return a dynamicly allocated KeyInfo structure that can be used -** with OP_OpenRead or OP_OpenWrite to access database index pIdx. -** -** If successful, a pointer to the new structure is returned. In this case -** the caller is responsible for calling sqlite3DbFree(db, ) on the returned -** pointer. If an error occurs (out of memory or missing collation -** sequence), NULL is returned and the state of pParse updated to reflect -** the error. -*/ - static KeyInfo sqlite3IndexKeyinfo( Parse pParse, Index pIdx ) - { - int i; - int nCol = pIdx.nColumn; - //int nBytes = KeyInfo.Length + (nCol - 1) * CollSeq*.Length + nCol; - sqlite3 db = pParse.db; - KeyInfo pKey = new KeyInfo();// (KeyInfo)sqlite3DbMallocZero(db, nBytes); - - if ( pKey != null ) - { - pKey.db = pParse.db; - pKey.aSortOrder = new byte[nCol]; - pKey.aColl = new CollSeq[nCol];// (u8)&(pKey.aColl[nCol]); - // Debug.Assert(pKey.aSortOrder[nCol] == (((u8)pKey)[nBytes])); - for ( i = 0; i < nCol; i++ ) - { - string zColl = pIdx.azColl[i]; - Debug.Assert( zColl != null ); - pKey.aColl[i] = sqlite3LocateCollSeq( pParse, zColl ); - pKey.aSortOrder[i] = pIdx.aSortOrder[i]; + /* + ** Return a dynamicly allocated KeyInfo structure that can be used + ** with OP_OpenRead or OP_OpenWrite to access database index pIdx. + ** + ** If successful, a pointer to the new structure is returned. In this case + ** the caller is responsible for calling sqlite3DbFree(db, ) on the returned + ** pointer. If an error occurs (out of memory or missing collation + ** sequence), NULL is returned and the state of pParse updated to reflect + ** the error. + */ + static KeyInfo sqlite3IndexKeyinfo(Parse pParse, Index pIdx) { + int i; + int nCol = pIdx.nColumn; + //int nBytes = KeyInfo.Length + (nCol - 1) * CollSeq*.Length + nCol; + sqlite3 db = pParse.db; + KeyInfo pKey = new KeyInfo();// (KeyInfo)sqlite3DbMallocZero(db, nBytes); + + if (pKey != null) { + pKey.db = pParse.db; + pKey.aSortOrder = new byte[nCol]; + pKey.aColl = new CollSeq[nCol];// (u8)&(pKey.aColl[nCol]); + // Debug.Assert(pKey.aSortOrder[nCol] == (((u8)pKey)[nBytes])); + for (i = 0; i < nCol; i++) { + string zColl = pIdx.azColl[i]; + Debug.Assert(zColl != null); + pKey.aColl[i] = sqlite3LocateCollSeq(pParse, zColl); + pKey.aSortOrder[i] = pIdx.aSortOrder[i]; + } + pKey.nField = (u16)nCol; + } + + if (pParse.nErr != 0) { + pKey = null; + sqlite3DbFree(db, ref pKey); + } + return pKey; } - pKey.nField = (u16)nCol; - } - - if ( pParse.nErr != 0 ) - { - pKey = null; - sqlite3DbFree( db, ref pKey ); - } - return pKey; } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/callback_c.cs b/Src/IronPython.SQLite/c#sqlite/callback_c.cs index 914f86f22..a014b9d1c 100644 --- a/Src/IronPython.SQLite/c#sqlite/callback_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/callback_c.cs @@ -1,57 +1,50 @@ using System; using System.Diagnostics; -using System.Text; using i16 = System.Int16; -using u8 = System.Byte; using u16 = System.UInt16; +using u8 = System.Byte; -namespace Community.CsharpSqlite -{ - using sqlite3_value = Sqlite3.Mem; - - public partial class Sqlite3 - { - /* - ** 2005 May 23 - ** - ** 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 contains functions used to access the internal hash tables - ** of user defined functions and collation sequences. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2005 May 23 + ** + ** 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 contains functions used to access the internal hash tables + ** of user defined functions and collation sequences. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ - //#include "sqliteInt.h" + //#include "sqliteInt.h" - /* - ** Invoke the 'collation needed' callback to request a collation sequence - ** in the encoding enc of name zName, length nName. - */ - static void callCollNeeded( sqlite3 db, int enc, string zName ) - { - Debug.Assert( db.xCollNeeded == null || db.xCollNeeded16 == null ); - if ( db.xCollNeeded != null ) - { - string zExternal = zName;// sqlite3DbStrDup(db, zName); - if ( zExternal == null ) - return; - db.xCollNeeded( db.pCollNeededArg, db, enc, zExternal ); - sqlite3DbFree( db, ref zExternal ); - } + /* + ** Invoke the 'collation needed' callback to request a collation sequence + ** in the encoding enc of name zName, length nName. + */ + static void callCollNeeded(sqlite3 db, int enc, string zName) { + Debug.Assert(db.xCollNeeded == null || db.xCollNeeded16 == null); + if (db.xCollNeeded != null) { + string zExternal = zName;// sqlite3DbStrDup(db, zName); + if (zExternal == null) + return; + db.xCollNeeded(db.pCollNeededArg, db, enc, zExternal); + sqlite3DbFree(db, ref zExternal); + } #if !SQLITE_OMIT_UTF16 if( db.xCollNeeded16!=null ){ string zExternal; @@ -64,496 +57,445 @@ static void callCollNeeded( sqlite3 db, int enc, string zName ) sqlite3ValueFree(ref pTmp); } #endif - } - - /* - ** This routine is called if the collation factory fails to deliver a - ** collation function in the best encoding but there may be other versions - ** of this collation function (for other text encodings) available. Use one - ** of these instead if they exist. Avoid a UTF-8 <. UTF-16 conversion if - ** possible. - */ - static int synthCollSeq( sqlite3 db, CollSeq pColl ) - { - CollSeq pColl2; - string z = pColl.zName; - int i; - byte[] aEnc = { SQLITE_UTF16BE, SQLITE_UTF16LE, SQLITE_UTF8 }; - for ( i = 0; i < 3; i++ ) - { - pColl2 = sqlite3FindCollSeq( db, aEnc[i], z, 0 ); - if ( pColl2.xCmp != null ) - { - pColl = pColl2.Copy(); //memcpy(pColl, pColl2, sizeof(CollSeq)); - pColl.xDel = null; /* Do not copy the destructor */ - return SQLITE_OK; } - } - return SQLITE_ERROR; - } - /* - ** This function is responsible for invoking the collation factory callback - ** or substituting a collation sequence of a different encoding when the - ** requested collation sequence is not available in the desired encoding. - ** - ** If it is not NULL, then pColl must point to the database native encoding - ** collation sequence with name zName, length nName. - ** - ** The return value is either the collation sequence to be used in database - ** db for collation type name zName, length nName, or NULL, if no collation - ** sequence can be found. - ** - ** See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq() - */ - static CollSeq sqlite3GetCollSeq( - sqlite3 db, /* The database connection */ - u8 enc, /* The desired encoding for the collating sequence */ - CollSeq pColl, /* Collating sequence with native encoding, or NULL */ - string zName /* Collating sequence name */ - ) - { - CollSeq p; + /* + ** This routine is called if the collation factory fails to deliver a + ** collation function in the best encoding but there may be other versions + ** of this collation function (for other text encodings) available. Use one + ** of these instead if they exist. Avoid a UTF-8 <. UTF-16 conversion if + ** possible. + */ + static int synthCollSeq(sqlite3 db, CollSeq pColl) { + CollSeq pColl2; + string z = pColl.zName; + int i; + byte[] aEnc = { SQLITE_UTF16BE, SQLITE_UTF16LE, SQLITE_UTF8 }; + for (i = 0; i < 3; i++) { + pColl2 = sqlite3FindCollSeq(db, aEnc[i], z, 0); + if (pColl2.xCmp != null) { + pColl = pColl2.Copy(); //memcpy(pColl, pColl2, sizeof(CollSeq)); + pColl.xDel = null; /* Do not copy the destructor */ + return SQLITE_OK; + } + } + return SQLITE_ERROR; + } - p = pColl; - if ( p == null ) - { - p = sqlite3FindCollSeq( db, enc, zName, 0 ); - } - if ( p == null || p.xCmp == null ) - { - /* No collation sequence of this type for this encoding is registered. - ** Call the collation factory to see if it can supply us with one. + /* + ** This function is responsible for invoking the collation factory callback + ** or substituting a collation sequence of a different encoding when the + ** requested collation sequence is not available in the desired encoding. + ** + ** If it is not NULL, then pColl must point to the database native encoding + ** collation sequence with name zName, length nName. + ** + ** The return value is either the collation sequence to be used in database + ** db for collation type name zName, length nName, or NULL, if no collation + ** sequence can be found. + ** + ** See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq() */ - callCollNeeded( db, enc, zName ); - p = sqlite3FindCollSeq( db, enc, zName, 0 ); - } - if ( p != null && p.xCmp == null && synthCollSeq( db, p ) != 0 ) - { - p = null; - } - Debug.Assert( p == null || p.xCmp != null ); - return p; - } + static CollSeq sqlite3GetCollSeq( + sqlite3 db, /* The database connection */ + u8 enc, /* The desired encoding for the collating sequence */ + CollSeq pColl, /* Collating sequence with native encoding, or NULL */ + string zName /* Collating sequence name */ + ) { + CollSeq p; - /* - ** This routine is called on a collation sequence before it is used to - ** check that it is defined. An undefined collation sequence exists when - ** a database is loaded that contains references to collation sequences - ** that have not been defined by sqlite3_create_collation() etc. - ** - ** If required, this routine calls the 'collation needed' callback to - ** request a definition of the collating sequence. If this doesn't work, - ** an equivalent collating sequence that uses a text encoding different - ** from the main database is substituted, if one is available. - */ - static int sqlite3CheckCollSeq( Parse pParse, CollSeq pColl ) - { - if ( pColl != null ) - { - string zName = pColl.zName; - sqlite3 db = pParse.db; - CollSeq p = sqlite3GetCollSeq( db, ENC( db ), pColl, zName ); - if ( null == p ) - { - sqlite3ErrorMsg( pParse, "no such collation sequence: %s", zName ); - pParse.nErr++; - return SQLITE_ERROR; - } - // - //Debug.Assert(p == pColl); - if ( p != pColl ) // Had to lookup appropriate sequence - { - pColl.enc = p.enc; - pColl.pUser = p.pUser; - pColl.type = p.type; - pColl.xCmp = p.xCmp; - pColl.xDel = p.xDel; + p = pColl; + if (p == null) { + p = sqlite3FindCollSeq(db, enc, zName, 0); + } + if (p == null || p.xCmp == null) { + /* No collation sequence of this type for this encoding is registered. + ** Call the collation factory to see if it can supply us with one. + */ + callCollNeeded(db, enc, zName); + p = sqlite3FindCollSeq(db, enc, zName, 0); + } + if (p != null && p.xCmp == null && synthCollSeq(db, p) != 0) { + p = null; + } + Debug.Assert(p == null || p.xCmp != null); + return p; } - } - return SQLITE_OK; - } - + /* + ** This routine is called on a collation sequence before it is used to + ** check that it is defined. An undefined collation sequence exists when + ** a database is loaded that contains references to collation sequences + ** that have not been defined by sqlite3_create_collation() etc. + ** + ** If required, this routine calls the 'collation needed' callback to + ** request a definition of the collating sequence. If this doesn't work, + ** an equivalent collating sequence that uses a text encoding different + ** from the main database is substituted, if one is available. + */ + static int sqlite3CheckCollSeq(Parse pParse, CollSeq pColl) { + if (pColl != null) { + string zName = pColl.zName; + sqlite3 db = pParse.db; + CollSeq p = sqlite3GetCollSeq(db, ENC(db), pColl, zName); + if (null == p) { + sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName); + pParse.nErr++; + return SQLITE_ERROR; + } + // + //Debug.Assert(p == pColl); + if (p != pColl) // Had to lookup appropriate sequence + { + pColl.enc = p.enc; + pColl.pUser = p.pUser; + pColl.type = p.type; + pColl.xCmp = p.xCmp; + pColl.xDel = p.xDel; + } + } + return SQLITE_OK; + } - /* - ** Locate and return an entry from the db.aCollSeq hash table. If the entry - ** specified by zName and nName is not found and parameter 'create' is - ** true, then create a new entry. Otherwise return NULL. - ** - ** Each pointer stored in the sqlite3.aCollSeq hash table contains an - ** array of three CollSeq structures. The first is the collation sequence - ** prefferred for UTF-8, the second UTF-16le, and the third UTF-16be. - ** - ** Stored immediately after the three collation sequences is a copy of - ** the collation sequence name. A pointer to this string is stored in - ** each collation sequence structure. - */ - static CollSeq[] findCollSeqEntry( - sqlite3 db, /* Database connection */ - string zName, /* Name of the collating sequence */ - int create /* Create a new entry if true */ - ) - { - CollSeq[] pColl; - int nName = sqlite3Strlen30( zName ); - pColl = sqlite3HashFind( db.aCollSeq, zName, nName, (CollSeq[])null ); - if ( ( null == pColl ) && create != 0 ) - { - pColl = new CollSeq[3]; //sqlite3DbMallocZero(db, 3*sizeof(*pColl) + nName + 1 ); - if ( pColl != null ) - { - CollSeq pDel = null; - pColl[0] = new CollSeq(); - pColl[0].zName = zName; - pColl[0].enc = SQLITE_UTF8; - pColl[1] = new CollSeq(); - pColl[1].zName = zName; - pColl[1].enc = SQLITE_UTF16LE; - pColl[2] = new CollSeq(); - pColl[2].zName = zName; - pColl[2].enc = SQLITE_UTF16BE; - //memcpy(pColl[0].zName, zName, nName); - //pColl[0].zName[nName] = 0; - CollSeq[] pDelArray = sqlite3HashInsert( ref db.aCollSeq, pColl[0].zName, nName, pColl ); - if ( pDelArray != null ) - pDel = pDelArray[0]; - /* If a malloc() failure occurred in sqlite3HashInsert(), it will - ** return the pColl pointer to be deleted (because it wasn't added - ** to the hash table). - */ - Debug.Assert( pDel == null || pDel == pColl[0] ); - if ( pDel != null ) - { - //// db.mallocFailed = 1; - pDel = null; //was sqlite3DbFree(db,ref pDel); - pColl = null; - } - } - } - return pColl; - } - /* - ** Parameter zName points to a UTF-8 encoded string nName bytes long. - ** Return the CollSeq* pointer for the collation sequence named zName - ** for the encoding 'enc' from the database 'db'. - ** - ** If the entry specified is not found and 'create' is true, then create a - ** new entry. Otherwise return NULL. - ** - ** A separate function sqlite3LocateCollSeq() is a wrapper around - ** this routine. sqlite3LocateCollSeq() invokes the collation factory - ** if necessary and generates an error message if the collating sequence - ** cannot be found. - ** - ** See also: sqlite3LocateCollSeq(), sqlite3GetCollSeq() - */ - static CollSeq sqlite3FindCollSeq( - sqlite3 db, - u8 enc, - string zName, - u8 create - ) - { - CollSeq[] pColl; - if ( zName != null ) - { - pColl = findCollSeqEntry( db, zName, create ); - } - else - { - pColl = new CollSeq[enc]; - pColl[enc - 1] = db.pDfltColl; - } - Debug.Assert( SQLITE_UTF8 == 1 && SQLITE_UTF16LE == 2 && SQLITE_UTF16BE == 3 ); - Debug.Assert( enc >= SQLITE_UTF8 && enc <= SQLITE_UTF16BE ); - if ( pColl != null ) - { - enc -= 1; // if (pColl != null) pColl += enc - 1; - return pColl[enc]; - } - else - return null; - } + /* + ** Locate and return an entry from the db.aCollSeq hash table. If the entry + ** specified by zName and nName is not found and parameter 'create' is + ** true, then create a new entry. Otherwise return NULL. + ** + ** Each pointer stored in the sqlite3.aCollSeq hash table contains an + ** array of three CollSeq structures. The first is the collation sequence + ** prefferred for UTF-8, the second UTF-16le, and the third UTF-16be. + ** + ** Stored immediately after the three collation sequences is a copy of + ** the collation sequence name. A pointer to this string is stored in + ** each collation sequence structure. + */ + static CollSeq[] findCollSeqEntry( + sqlite3 db, /* Database connection */ + string zName, /* Name of the collating sequence */ + int create /* Create a new entry if true */ + ) { + CollSeq[] pColl; + int nName = sqlite3Strlen30(zName); + pColl = sqlite3HashFind(db.aCollSeq, zName, nName, (CollSeq[])null); - /* During the search for the best function definition, this procedure - ** is called to test how well the function passed as the first argument - ** matches the request for a function with nArg arguments in a system - ** that uses encoding enc. The value returned indicates how well the - ** request is matched. A higher value indicates a better match. - ** - ** The returned value is always between 0 and 6, as follows: - ** - ** 0: Not a match, or if nArg<0 and the function is has no implementation. - ** 1: A variable arguments function that prefers UTF-8 when a UTF-16 - ** encoding is requested, or vice versa. - ** 2: A variable arguments function that uses UTF-16BE when UTF-16LE is - ** requested, or vice versa. - ** 3: A variable arguments function using the same text encoding. - ** 4: A function with the exact number of arguments requested that - ** prefers UTF-8 when a UTF-16 encoding is requested, or vice versa. - ** 5: A function with the exact number of arguments requested that - ** prefers UTF-16LE when UTF-16BE is requested, or vice versa. - ** 6: An exact match. - ** - */ - static int matchQuality( FuncDef p, int nArg, int enc ) - { - int match = 0; - if ( p.nArg == -1 || p.nArg == nArg - || ( nArg == -1 && ( p.xFunc != null || p.xStep != null ) ) - ) - { - match = 1; - if ( p.nArg == nArg || nArg == -1 ) - { - match = 4; + if ((null == pColl) && create != 0) { + pColl = new CollSeq[3]; //sqlite3DbMallocZero(db, 3*sizeof(*pColl) + nName + 1 ); + if (pColl != null) { + CollSeq pDel = null; + pColl[0] = new CollSeq(); + pColl[0].zName = zName; + pColl[0].enc = SQLITE_UTF8; + pColl[1] = new CollSeq(); + pColl[1].zName = zName; + pColl[1].enc = SQLITE_UTF16LE; + pColl[2] = new CollSeq(); + pColl[2].zName = zName; + pColl[2].enc = SQLITE_UTF16BE; + //memcpy(pColl[0].zName, zName, nName); + //pColl[0].zName[nName] = 0; + CollSeq[] pDelArray = sqlite3HashInsert(ref db.aCollSeq, pColl[0].zName, nName, pColl); + if (pDelArray != null) + pDel = pDelArray[0]; + /* If a malloc() failure occurred in sqlite3HashInsert(), it will + ** return the pColl pointer to be deleted (because it wasn't added + ** to the hash table). + */ + Debug.Assert(pDel == null || pDel == pColl[0]); + if (pDel != null) { + //// db.mallocFailed = 1; + pDel = null; //was sqlite3DbFree(db,ref pDel); + pColl = null; + } + } + } + return pColl; } - if ( enc == p.iPrefEnc ) - { - match += 2; + + /* + ** Parameter zName points to a UTF-8 encoded string nName bytes long. + ** Return the CollSeq* pointer for the collation sequence named zName + ** for the encoding 'enc' from the database 'db'. + ** + ** If the entry specified is not found and 'create' is true, then create a + ** new entry. Otherwise return NULL. + ** + ** A separate function sqlite3LocateCollSeq() is a wrapper around + ** this routine. sqlite3LocateCollSeq() invokes the collation factory + ** if necessary and generates an error message if the collating sequence + ** cannot be found. + ** + ** See also: sqlite3LocateCollSeq(), sqlite3GetCollSeq() + */ + static CollSeq sqlite3FindCollSeq( + sqlite3 db, + u8 enc, + string zName, + u8 create + ) { + CollSeq[] pColl; + if (zName != null) { + pColl = findCollSeqEntry(db, zName, create); + } else { + pColl = new CollSeq[enc]; + pColl[enc - 1] = db.pDfltColl; + } + Debug.Assert(SQLITE_UTF8 == 1 && SQLITE_UTF16LE == 2 && SQLITE_UTF16BE == 3); + Debug.Assert(enc >= SQLITE_UTF8 && enc <= SQLITE_UTF16BE); + if (pColl != null) { + enc -= 1; // if (pColl != null) pColl += enc - 1; + return pColl[enc]; + } else + return null; } - else if ( ( enc == SQLITE_UTF16LE && p.iPrefEnc == SQLITE_UTF16BE ) || - ( enc == SQLITE_UTF16BE && p.iPrefEnc == SQLITE_UTF16LE ) ) - { - match += 1; + + /* During the search for the best function definition, this procedure + ** is called to test how well the function passed as the first argument + ** matches the request for a function with nArg arguments in a system + ** that uses encoding enc. The value returned indicates how well the + ** request is matched. A higher value indicates a better match. + ** + ** The returned value is always between 0 and 6, as follows: + ** + ** 0: Not a match, or if nArg<0 and the function is has no implementation. + ** 1: A variable arguments function that prefers UTF-8 when a UTF-16 + ** encoding is requested, or vice versa. + ** 2: A variable arguments function that uses UTF-16BE when UTF-16LE is + ** requested, or vice versa. + ** 3: A variable arguments function using the same text encoding. + ** 4: A function with the exact number of arguments requested that + ** prefers UTF-8 when a UTF-16 encoding is requested, or vice versa. + ** 5: A function with the exact number of arguments requested that + ** prefers UTF-16LE when UTF-16BE is requested, or vice versa. + ** 6: An exact match. + ** + */ + static int matchQuality(FuncDef p, int nArg, int enc) { + int match = 0; + if (p.nArg == -1 || p.nArg == nArg + || (nArg == -1 && (p.xFunc != null || p.xStep != null)) + ) { + match = 1; + if (p.nArg == nArg || nArg == -1) { + match = 4; + } + if (enc == p.iPrefEnc) { + match += 2; + } else if ((enc == SQLITE_UTF16LE && p.iPrefEnc == SQLITE_UTF16BE) || + (enc == SQLITE_UTF16BE && p.iPrefEnc == SQLITE_UTF16LE)) { + match += 1; + } + } + return match; } - } - return match; - } - /* - ** Search a FuncDefHash for a function with the given name. Return - ** a pointer to the matching FuncDef if found, or 0 if there is no match. - */ - static FuncDef functionSearch( - FuncDefHash pHash, /* Hash table to search */ - int h, /* Hash of the name */ - string zFunc, /* Name of function */ - int nFunc /* Number of bytes in zFunc */ - ) - { - FuncDef p; - for ( p = pHash.a[h]; p != null; p = p.pHash ) - { - if ( p.zName.Length == nFunc && p.zName.StartsWith( zFunc, StringComparison.OrdinalIgnoreCase ) ) - { - return p; + /* + ** Search a FuncDefHash for a function with the given name. Return + ** a pointer to the matching FuncDef if found, or 0 if there is no match. + */ + static FuncDef functionSearch( + FuncDefHash pHash, /* Hash table to search */ + int h, /* Hash of the name */ + string zFunc, /* Name of function */ + int nFunc /* Number of bytes in zFunc */ + ) { + FuncDef p; + for (p = pHash.a[h]; p != null; p = p.pHash) { + if (p.zName.Length == nFunc && p.zName.StartsWith(zFunc, StringComparison.OrdinalIgnoreCase)) { + return p; + } + } + return null; } - } - return null; - } - /* - ** Insert a new FuncDef into a FuncDefHash hash table. - */ - static void sqlite3FuncDefInsert( - FuncDefHash pHash, /* The hash table into which to insert */ - FuncDef pDef /* The function definition to insert */ - ) - { - FuncDef pOther; - int nName = sqlite3Strlen30( pDef.zName ); - u8 c1 = (u8)pDef.zName[0]; - int h = ( sqlite3UpperToLower[c1] + nName ) % ArraySize( pHash.a ); - pOther = functionSearch( pHash, h, pDef.zName, nName ); - if ( pOther != null ) - { - Debug.Assert( pOther != pDef && pOther.pNext != pDef ); - pDef.pNext = pOther.pNext; - pOther.pNext = pDef; - } - else - { - pDef.pNext = null; - pDef.pHash = pHash.a[h]; - pHash.a[h] = pDef; - } - } + /* + ** Insert a new FuncDef into a FuncDefHash hash table. + */ + static void sqlite3FuncDefInsert( + FuncDefHash pHash, /* The hash table into which to insert */ + FuncDef pDef /* The function definition to insert */ + ) { + FuncDef pOther; + int nName = sqlite3Strlen30(pDef.zName); + u8 c1 = (u8)pDef.zName[0]; + int h = (sqlite3UpperToLower[c1] + nName) % ArraySize(pHash.a); + pOther = functionSearch(pHash, h, pDef.zName, nName); + if (pOther != null) { + Debug.Assert(pOther != pDef && pOther.pNext != pDef); + pDef.pNext = pOther.pNext; + pOther.pNext = pDef; + } else { + pDef.pNext = null; + pDef.pHash = pHash.a[h]; + pHash.a[h] = pDef; + } + } - /* - ** Locate a user function given a name, a number of arguments and a flag - ** indicating whether the function prefers UTF-16 over UTF-8. Return a - ** pointer to the FuncDef structure that defines that function, or return - ** NULL if the function does not exist. - ** - ** If the createFlag argument is true, then a new (blank) FuncDef - ** structure is created and liked into the "db" structure if a - ** no matching function previously existed. When createFlag is true - ** and the nArg parameter is -1, then only a function that accepts - ** any number of arguments will be returned. - ** - ** If createFlag is false and nArg is -1, then the first valid - ** function found is returned. A function is valid if either xFunc - ** or xStep is non-zero. - ** - ** If createFlag is false, then a function with the required name and - ** number of arguments may be returned even if the eTextRep flag does not - ** match that requested. - */ + /* + ** Locate a user function given a name, a number of arguments and a flag + ** indicating whether the function prefers UTF-16 over UTF-8. Return a + ** pointer to the FuncDef structure that defines that function, or return + ** NULL if the function does not exist. + ** + ** If the createFlag argument is true, then a new (blank) FuncDef + ** structure is created and liked into the "db" structure if a + ** no matching function previously existed. When createFlag is true + ** and the nArg parameter is -1, then only a function that accepts + ** any number of arguments will be returned. + ** + ** If createFlag is false and nArg is -1, then the first valid + ** function found is returned. A function is valid if either xFunc + ** or xStep is non-zero. + ** + ** If createFlag is false, then a function with the required name and + ** number of arguments may be returned even if the eTextRep flag does not + ** match that requested. + */ - static FuncDef sqlite3FindFunction( - sqlite3 db, /* An open database */ - string zName, /* Name of the function. Not null-terminated */ - int nName, /* Number of characters in the name */ - int nArg, /* Number of arguments. -1 means any number */ - u8 enc, /* Preferred text encoding */ - u8 createFlag /* Create new entry if true and does not otherwise exist */ - ) - { - FuncDef p; /* Iterator variable */ - FuncDef pBest = null; /* Best match found so far */ - int bestScore = 0; - int h; /* Hash value */ + static FuncDef sqlite3FindFunction( + sqlite3 db, /* An open database */ + string zName, /* Name of the function. Not null-terminated */ + int nName, /* Number of characters in the name */ + int nArg, /* Number of arguments. -1 means any number */ + u8 enc, /* Preferred text encoding */ + u8 createFlag /* Create new entry if true and does not otherwise exist */ + ) { + FuncDef p; /* Iterator variable */ + FuncDef pBest = null; /* Best match found so far */ + int bestScore = 0; + int h; /* Hash value */ - Debug.Assert( enc == SQLITE_UTF8 || enc == SQLITE_UTF16LE || enc == SQLITE_UTF16BE ); - h = ( sqlite3UpperToLower[(u8)zName[0]] + nName ) % ArraySize( db.aFunc.a ); + Debug.Assert(enc == SQLITE_UTF8 || enc == SQLITE_UTF16LE || enc == SQLITE_UTF16BE); + h = (sqlite3UpperToLower[(u8)zName[0]] + nName) % ArraySize(db.aFunc.a); - /* First search for a match amongst the application-defined functions. - */ - p = functionSearch( db.aFunc, h, zName, nName ); - while ( p != null ) - { - int score = matchQuality( p, nArg, enc ); - if ( score > bestScore ) - { - pBest = p; - bestScore = score; + /* First search for a match amongst the application-defined functions. + */ + p = functionSearch(db.aFunc, h, zName, nName); + while (p != null) { + int score = matchQuality(p, nArg, enc); + if (score > bestScore) { + pBest = p; + bestScore = score; - } - p = p.pNext; - } + } + p = p.pNext; + } - /* If no match is found, search the built-in functions. - ** - ** If the SQLITE_PreferBuiltin flag is set, then search the built-in - ** functions even if a prior app-defined function was found. And give - ** priority to built-in functions. - ** - ** Except, if createFlag is true, that means that we are trying to - ** install a new function. Whatever FuncDef structure is returned it will - ** have fields overwritten with new information appropriate for the - ** new function. But the FuncDefs for built-in functions are read-only. - ** So we must not search for built-ins when creating a new function. - */ - if ( 0 == createFlag && ( pBest == null || ( db.flags & SQLITE_PreferBuiltin ) != 0 ) ) - { + /* If no match is found, search the built-in functions. + ** + ** If the SQLITE_PreferBuiltin flag is set, then search the built-in + ** functions even if a prior app-defined function was found. And give + ** priority to built-in functions. + ** + ** Except, if createFlag is true, that means that we are trying to + ** install a new function. Whatever FuncDef structure is returned it will + ** have fields overwritten with new information appropriate for the + ** new function. But the FuncDefs for built-in functions are read-only. + ** So we must not search for built-ins when creating a new function. + */ + if (0 == createFlag && (pBest == null || (db.flags & SQLITE_PreferBuiltin) != 0)) { #if SQLITE_OMIT_WSD FuncDefHash pHash = GLOBAL( FuncDefHash, sqlite3GlobalFunctions ); #else - FuncDefHash pHash = sqlite3GlobalFunctions; + FuncDefHash pHash = sqlite3GlobalFunctions; #endif - bestScore = 0; - p = functionSearch( pHash, h, zName, nName ); - while ( p != null ) - { - int score = matchQuality( p, nArg, enc ); - if ( score > bestScore ) - { - pBest = p; - bestScore = score; - } - p = p.pNext; - } - } + bestScore = 0; + p = functionSearch(pHash, h, zName, nName); + while (p != null) { + int score = matchQuality(p, nArg, enc); + if (score > bestScore) { + pBest = p; + bestScore = score; + } + p = p.pNext; + } + } - /* If the createFlag parameter is true and the search did not reveal an - ** exact match for the name, number of arguments and encoding, then add a - ** new entry to the hash table and return it. - */ - if ( createFlag != 0 && ( bestScore < 6 || pBest.nArg != nArg ) && - ( pBest = new FuncDef() ) != null ) - { //sqlite3DbMallocZero(db, sizeof(*pBest)+nName+1))!=0 ){ - //pBest.zName = (char *)&pBest[1]; - pBest.nArg = (i16)nArg; - pBest.iPrefEnc = enc; - pBest.zName = zName; //memcpy(pBest.zName, zName, nName); - //pBest.zName[nName] = 0; - sqlite3FuncDefInsert( db.aFunc, pBest ); - } + /* If the createFlag parameter is true and the search did not reveal an + ** exact match for the name, number of arguments and encoding, then add a + ** new entry to the hash table and return it. + */ + if (createFlag != 0 && (bestScore < 6 || pBest.nArg != nArg) && + (pBest = new FuncDef()) != null) { //sqlite3DbMallocZero(db, sizeof(*pBest)+nName+1))!=0 ){ + //pBest.zName = (char *)&pBest[1]; + pBest.nArg = (i16)nArg; + pBest.iPrefEnc = enc; + pBest.zName = zName; //memcpy(pBest.zName, zName, nName); + //pBest.zName[nName] = 0; + sqlite3FuncDefInsert(db.aFunc, pBest); + } - if ( pBest != null && ( pBest.xStep != null || pBest.xFunc != null || createFlag != 0 ) ) - { - return pBest; - } - return null; - } + if (pBest != null && (pBest.xStep != null || pBest.xFunc != null || createFlag != 0)) { + return pBest; + } + return null; + } - /* - ** Free all resources held by the schema structure. The void* argument points - ** at a Schema struct. This function does not call sqlite3DbFree(db, ) on the - ** pointer itself, it just cleans up subsidiary resources (i.e. the contents - ** of the schema hash tables). - ** - ** The Schema.cache_size variable is not cleared. - */ - static void sqlite3SchemaClear( Schema p ) - { - Hash temp1; - Hash temp2; - HashElem pElem; - Schema pSchema = p; + /* + ** Free all resources held by the schema structure. The void* argument points + ** at a Schema struct. This function does not call sqlite3DbFree(db, ) on the + ** pointer itself, it just cleans up subsidiary resources (i.e. the contents + ** of the schema hash tables). + ** + ** The Schema.cache_size variable is not cleared. + */ + static void sqlite3SchemaClear(Schema p) { + Hash temp1; + Hash temp2; + HashElem pElem; + Schema pSchema = p; - temp1 = pSchema.tblHash; - temp2 = pSchema.trigHash; - sqlite3HashInit( pSchema.trigHash ); - sqlite3HashClear( pSchema.idxHash ); - for ( pElem = sqliteHashFirst( temp2 ); pElem != null; pElem = sqliteHashNext( pElem ) ) - { - Trigger pTrigger = (Trigger)sqliteHashData( pElem ); - sqlite3DeleteTrigger( null, ref pTrigger ); - } - sqlite3HashClear( temp2 ); - sqlite3HashInit( pSchema.trigHash ); - for ( pElem = temp1.first; pElem != null; pElem = pElem.next )//sqliteHashFirst(&temp1); pElem; pElem = sqliteHashNext(pElem)) - { - Table pTab = (Table)pElem.data; //sqliteHashData(pElem); - sqlite3DeleteTable( null, ref pTab ); - } - sqlite3HashClear( temp1 ); - sqlite3HashClear( pSchema.fkeyHash ); - pSchema.pSeqTab = null; - if ( ( pSchema.flags & DB_SchemaLoaded ) != 0 ) - { - pSchema.iGeneration++; - pSchema.flags = (u16)( pSchema.flags & ( ~DB_SchemaLoaded ) ); - } - p.Clear(); - } + temp1 = pSchema.tblHash; + temp2 = pSchema.trigHash; + sqlite3HashInit(pSchema.trigHash); + sqlite3HashClear(pSchema.idxHash); + for (pElem = sqliteHashFirst(temp2); pElem != null; pElem = sqliteHashNext(pElem)) { + Trigger pTrigger = (Trigger)sqliteHashData(pElem); + sqlite3DeleteTrigger(null, ref pTrigger); + } + sqlite3HashClear(temp2); + sqlite3HashInit(pSchema.trigHash); + for (pElem = temp1.first; pElem != null; pElem = pElem.next)//sqliteHashFirst(&temp1); pElem; pElem = sqliteHashNext(pElem)) + { + Table pTab = (Table)pElem.data; //sqliteHashData(pElem); + sqlite3DeleteTable(null, ref pTab); + } + sqlite3HashClear(temp1); + sqlite3HashClear(pSchema.fkeyHash); + pSchema.pSeqTab = null; + if ((pSchema.flags & DB_SchemaLoaded) != 0) { + pSchema.iGeneration++; + pSchema.flags = (u16)(pSchema.flags & (~DB_SchemaLoaded)); + } + p.Clear(); + } - /* - ** Find and return the schema associated with a BTree. Create - ** a new one if necessary. - */ - static Schema sqlite3SchemaGet( sqlite3 db, Btree pBt ) - { - Schema p; - if ( pBt != null ) - { - p = sqlite3BtreeSchema( pBt, -1, (dxFreeSchema)sqlite3SchemaClear );//Schema.Length, sqlite3SchemaFree); - } - else - { - p = new Schema(); // (Schema *)sqlite3DbMallocZero(0, sizeof(Schema)); - } - if ( p == null ) - { - //// db.mallocFailed = 1; - } - else if ( 0 == p.file_format ) - { - sqlite3HashInit( p.tblHash ); - sqlite3HashInit( p.idxHash ); - sqlite3HashInit( p.trigHash ); - sqlite3HashInit( p.fkeyHash ); - p.enc = SQLITE_UTF8; - } - return p; + /* + ** Find and return the schema associated with a BTree. Create + ** a new one if necessary. + */ + static Schema sqlite3SchemaGet(sqlite3 db, Btree pBt) { + Schema p; + if (pBt != null) { + p = sqlite3BtreeSchema(pBt, -1, (dxFreeSchema)sqlite3SchemaClear);//Schema.Length, sqlite3SchemaFree); + } else { + p = new Schema(); // (Schema *)sqlite3DbMallocZero(0, sizeof(Schema)); + } + if (p == null) { + //// db.mallocFailed = 1; + } else if (0 == p.file_format) { + sqlite3HashInit(p.tblHash); + sqlite3HashInit(p.idxHash); + sqlite3HashInit(p.trigHash); + sqlite3HashInit(p.fkeyHash); + p.enc = SQLITE_UTF8; + } + return p; + } } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/complete_c.cs b/Src/IronPython.SQLite/c#sqlite/complete_c.cs index e231fa9f4..c1556e9d2 100644 --- a/Src/IronPython.SQLite/c#sqlite/complete_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/complete_c.cs @@ -1,137 +1,131 @@ -using System.Diagnostics; +namespace Community.CsharpSqlite { -namespace Community.CsharpSqlite -{ + using u8 = System.Byte; - using u8 = System.Byte; - - public partial class Sqlite3 - { - /* - ** 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. - ** - ************************************************************************* - ** An tokenizer for SQL - ** - ** This file contains C code that implements the sqlite3_complete() API. - ** This code used to be part of the tokenizer.c source file. But by - ** separating it out, the code will be automatically omitted from - ** static links that do not use it. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** An tokenizer for SQL + ** + ** This file contains C code that implements the sqlite3_complete() API. + ** This code used to be part of the tokenizer.c source file. But by + ** separating it out, the code will be automatically omitted from + ** static links that do not use it. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" #if !SQLITE_OMIT_COMPLETE - /* -** This is defined in tokenize.c. We just have to import the definition. -*/ + /* + ** This is defined in tokenize.c. We just have to import the definition. + */ #if !SQLITE_AMALGAMATION -#if SQLITE_ASCII - //#define IdChar(C) ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0) - static bool IdChar( u8 C ) - { - return ( sqlite3CtypeMap[(char)C] & 0x46 ) != 0; - } +#if SQLITE_ASCII + //#define IdChar(C) ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0) + static bool IdChar(u8 C) { + return (sqlite3CtypeMap[(char)C] & 0x46) != 0; + } #endif -//#if SQLITE_EBCDIC -//extern const char sqlite3IsEbcdicIdChar[]; -//#define IdChar(C) (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40])) -//#endif + //#if SQLITE_EBCDIC + //extern const char sqlite3IsEbcdicIdChar[]; + //#define IdChar(C) (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40])) + //#endif #endif // * SQLITE_AMALGAMATION */ - /* -** Token types used by the sqlite3_complete() routine. See the header -** comments on that procedure for additional information. -*/ - const int tkSEMI = 0; - const int tkWS = 1; - const int tkOTHER = 2; + /* + ** Token types used by the sqlite3_complete() routine. See the header + ** comments on that procedure for additional information. + */ + const int tkSEMI = 0; + const int tkWS = 1; + const int tkOTHER = 2; #if !SQLITE_OMIT_TRIGGER - const int tkEXPLAIN = 3; - const int tkCREATE = 4; - const int tkTEMP = 5; - const int tkTRIGGER = 6; - const int tkEND = 7; + const int tkEXPLAIN = 3; + const int tkCREATE = 4; + const int tkTEMP = 5; + const int tkTRIGGER = 6; + const int tkEND = 7; #endif - /* -** Return TRUE if the given SQL string ends in a semicolon. -** -** Special handling is require for CREATE TRIGGER statements. -** Whenever the CREATE TRIGGER keywords are seen, the statement -** must end with ";END;". -** -** This implementation uses a state machine with 8 states: -** -** (0) INVALID We have not yet seen a non-whitespace character. -** -** (1) START At the beginning or end of an SQL statement. This routine -** returns 1 if it ends in the START state and 0 if it ends -** in any other state. -** -** (2) NORMAL We are in the middle of statement which ends with a single -** semicolon. -** -** (3) EXPLAIN The keyword EXPLAIN has been seen at the beginning of -** a statement. -** -** (4) CREATE The keyword CREATE has been seen at the beginning of a -** statement, possibly preceeded by EXPLAIN and/or followed by -** TEMP or TEMPORARY -** -** (5) TRIGGER We are in the middle of a trigger definition that must be -** ended by a semicolon, the keyword END, and another semicolon. -** -** (6) SEMI We've seen the first semicolon in the ";END;" that occurs at -** the end of a trigger definition. -** -** (7) END We've seen the ";END" of the ";END;" that occurs at the end -** of a trigger difinition. -** -** Transitions between states above are determined by tokens extracted -** from the input. The following tokens are significant: -** -** (0) tkSEMI A semicolon. -** (1) tkWS Whitespace. -** (2) tkOTHER Any other SQL token. -** (3) tkEXPLAIN The "explain" keyword. -** (4) tkCREATE The "create" keyword. -** (5) tkTEMP The "temp" or "temporary" keyword. -** (6) tkTRIGGER The "trigger" keyword. -** (7) tkEND The "end" keyword. -** -** Whitespace never causes a state transition and is always ignored. -** This means that a SQL string of all whitespace is invalid. -** -** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed -** to recognize the end of a trigger can be omitted. All we have to do -** is look for a semicolon that is not part of an string or comment. -*/ + /* + ** Return TRUE if the given SQL string ends in a semicolon. + ** + ** Special handling is require for CREATE TRIGGER statements. + ** Whenever the CREATE TRIGGER keywords are seen, the statement + ** must end with ";END;". + ** + ** This implementation uses a state machine with 8 states: + ** + ** (0) INVALID We have not yet seen a non-whitespace character. + ** + ** (1) START At the beginning or end of an SQL statement. This routine + ** returns 1 if it ends in the START state and 0 if it ends + ** in any other state. + ** + ** (2) NORMAL We are in the middle of statement which ends with a single + ** semicolon. + ** + ** (3) EXPLAIN The keyword EXPLAIN has been seen at the beginning of + ** a statement. + ** + ** (4) CREATE The keyword CREATE has been seen at the beginning of a + ** statement, possibly preceeded by EXPLAIN and/or followed by + ** TEMP or TEMPORARY + ** + ** (5) TRIGGER We are in the middle of a trigger definition that must be + ** ended by a semicolon, the keyword END, and another semicolon. + ** + ** (6) SEMI We've seen the first semicolon in the ";END;" that occurs at + ** the end of a trigger definition. + ** + ** (7) END We've seen the ";END" of the ";END;" that occurs at the end + ** of a trigger difinition. + ** + ** Transitions between states above are determined by tokens extracted + ** from the input. The following tokens are significant: + ** + ** (0) tkSEMI A semicolon. + ** (1) tkWS Whitespace. + ** (2) tkOTHER Any other SQL token. + ** (3) tkEXPLAIN The "explain" keyword. + ** (4) tkCREATE The "create" keyword. + ** (5) tkTEMP The "temp" or "temporary" keyword. + ** (6) tkTRIGGER The "trigger" keyword. + ** (7) tkEND The "end" keyword. + ** + ** Whitespace never causes a state transition and is always ignored. + ** This means that a SQL string of all whitespace is invalid. + ** + ** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed + ** to recognize the end of a trigger can be omitted. All we have to do + ** is look for a semicolon that is not part of an string or comment. + */ - static public int sqlite3_complete( string zSql ) - { - int state = 0; /* Current state, using numbers defined in header comment */ - int token; /* Value of the next token */ + static public int sqlite3_complete(string zSql) { + int state = 0; /* Current state, using numbers defined in header comment */ + int token; /* Value of the next token */ #if !SQLITE_OMIT_TRIGGER - /* A complex statement machine used to detect the end of a CREATE TRIGGER -** statement. This is the normal case. -*/ - u8[][] trans = new u8[][] { + /* A complex statement machine used to detect the end of a CREATE TRIGGER + ** statement. This is the normal case. + */ + u8[][] trans = new u8[][] { /* Token: */ /* State: ** SEMI WS OTHER EXPLAIN CREATE TEMP TRIGGER END */ /* 0 INVALID: */ new u8[]{ 1, 0, 2, 3, 4, 2, 2, 2, }, @@ -156,179 +150,141 @@ static public int sqlite3_complete( string zSql ) }; #endif // * SQLITE_OMIT_TRIGGER */ - int zIdx = 0; - while ( zIdx < zSql.Length ) - { - switch ( zSql[zIdx] ) - { - case ';': - { /* A semicolon */ - token = tkSEMI; - break; - } - case ' ': - case '\r': - case '\t': - case '\n': - case '\f': - { /* White space is ignored */ - token = tkWS; - break; - } - case '/': - { /* C-style comments */ - if ( zSql[zIdx + 1] != '*' ) - { - token = tkOTHER; - break; - } - zIdx += 2; - while ( zIdx < zSql.Length && zSql[zIdx] != '*' || zIdx < zSql.Length - 1 && zSql[zIdx + 1] != '/' ) - { - zIdx++; - } - if ( zIdx == zSql.Length ) - return 0; - zIdx++; - token = tkWS; - break; - } - case '-': - { /* SQL-style comments from "--" to end of line */ - if ( zSql[zIdx + 1] != '-' ) - { - token = tkOTHER; - break; - } - while ( zIdx < zSql.Length && zSql[zIdx] != '\n' ) - { - zIdx++; - } - if ( zIdx == zSql.Length ) - return state == 1 ? 1 : 0;//if( *zSql==0 ) return state==1; - token = tkWS; - break; - } - case '[': - { /* Microsoft-style identifiers in [...] */ - zIdx++; - while ( zIdx < zSql.Length && zSql[zIdx] != ']' ) - { - zIdx++; - } - if ( zIdx == zSql.Length ) - return 0; - token = tkOTHER; - break; - } - case '`': /* Grave-accent quoted symbols used by MySQL */ - case '"': /* single- and double-quoted strings */ - case '\'': - { - int c = zSql[zIdx]; - zIdx++; - while ( zIdx < zSql.Length && zSql[zIdx] != c ) - { - zIdx++; - } - if ( zIdx == zSql.Length ) - return 0; - token = tkOTHER; - break; - } - default: - { -//#if SQLITE_EBCDIC -// unsigned char c; -//#endif - if ( IdChar( (u8)zSql[zIdx] ) ) - { - /* Keywords and unquoted identifiers */ - int nId; - for ( nId = 1; ( zIdx + nId ) < zSql.Length && IdChar( (u8)zSql[zIdx + nId] ); nId++ ) - { - } -#if SQLITE_OMIT_TRIGGER + int zIdx = 0; + while (zIdx < zSql.Length) { + switch (zSql[zIdx]) { + case ';': { /* A semicolon */ + token = tkSEMI; + break; + } + case ' ': + case '\r': + case '\t': + case '\n': + case '\f': { /* White space is ignored */ + token = tkWS; + break; + } + case '/': { /* C-style comments */ + if (zSql[zIdx + 1] != '*') { + token = tkOTHER; + break; + } + zIdx += 2; + while (zIdx < zSql.Length && zSql[zIdx] != '*' || zIdx < zSql.Length - 1 && zSql[zIdx + 1] != '/') { + zIdx++; + } + if (zIdx == zSql.Length) + return 0; + zIdx++; + token = tkWS; + break; + } + case '-': { /* SQL-style comments from "--" to end of line */ + if (zSql[zIdx + 1] != '-') { + token = tkOTHER; + break; + } + while (zIdx < zSql.Length && zSql[zIdx] != '\n') { + zIdx++; + } + if (zIdx == zSql.Length) + return state == 1 ? 1 : 0;//if( *zSql==0 ) return state==1; + token = tkWS; + break; + } + case '[': { /* Microsoft-style identifiers in [...] */ + zIdx++; + while (zIdx < zSql.Length && zSql[zIdx] != ']') { + zIdx++; + } + if (zIdx == zSql.Length) + return 0; + token = tkOTHER; + break; + } + case '`': /* Grave-accent quoted symbols used by MySQL */ + case '"': /* single- and double-quoted strings */ + case '\'': { + int c = zSql[zIdx]; + zIdx++; + while (zIdx < zSql.Length && zSql[zIdx] != c) { + zIdx++; + } + if (zIdx == zSql.Length) + return 0; + token = tkOTHER; + break; + } + default: { + //#if SQLITE_EBCDIC + // unsigned char c; + //#endif + if (IdChar((u8)zSql[zIdx])) { + /* Keywords and unquoted identifiers */ + int nId; + for (nId = 1; (zIdx + nId) < zSql.Length && IdChar((u8)zSql[zIdx + nId]); nId++) { + } +#if SQLITE_OMIT_TRIGGER token = tkOTHER; #else - switch ( zSql[zIdx] ) - { - case 'c': - case 'C': - { - if ( nId == 6 && sqlite3StrNICmp( zSql, zIdx, "create", 6 ) == 0 ) - { - token = tkCREATE; - } - else - { - token = tkOTHER; - } - break; - } - case 't': - case 'T': - { - if ( nId == 7 && sqlite3StrNICmp( zSql, zIdx, "trigger", 7 ) == 0 ) - { - token = tkTRIGGER; - } - else if ( nId == 4 && sqlite3StrNICmp( zSql, zIdx, "temp", 4 ) == 0 ) - { - token = tkTEMP; - } - else if ( nId == 9 && sqlite3StrNICmp( zSql, zIdx, "temporary", 9 ) == 0 ) - { - token = tkTEMP; - } - else - { - token = tkOTHER; - } - break; - } - case 'e': - case 'E': - { - if ( nId == 3 && sqlite3StrNICmp( zSql, zIdx, "end", 3 ) == 0 ) - { - token = tkEND; - } - else + switch (zSql[zIdx]) { + case 'c': + case 'C': { + if (nId == 6 && sqlite3StrNICmp(zSql, zIdx, "create", 6) == 0) { + token = tkCREATE; + } else { + token = tkOTHER; + } + break; + } + case 't': + case 'T': { + if (nId == 7 && sqlite3StrNICmp(zSql, zIdx, "trigger", 7) == 0) { + token = tkTRIGGER; + } else if (nId == 4 && sqlite3StrNICmp(zSql, zIdx, "temp", 4) == 0) { + token = tkTEMP; + } else if (nId == 9 && sqlite3StrNICmp(zSql, zIdx, "temporary", 9) == 0) { + token = tkTEMP; + } else { + token = tkOTHER; + } + break; + } + case 'e': + case 'E': { + if (nId == 3 && sqlite3StrNICmp(zSql, zIdx, "end", 3) == 0) { + token = tkEND; + } else #if !SQLITE_OMIT_EXPLAIN - if ( nId == 7 && sqlite3StrNICmp( zSql, zIdx, "explain", 7 ) == 0 ) - { - token = tkEXPLAIN; - } - else + if (nId == 7 && sqlite3StrNICmp(zSql, zIdx, "explain", 7) == 0) { + token = tkEXPLAIN; + } else #endif - { - token = tkOTHER; + { + token = tkOTHER; + } + break; + } + default: { + token = tkOTHER; + break; + } + } +#endif // * SQLITE_OMIT_TRIGGER */ + zIdx += nId - 1; + } else { + /* Operators and special symbols */ + token = tkOTHER; + } + break; } - break; - } - default: - { - token = tkOTHER; - break; - } } -#endif // * SQLITE_OMIT_TRIGGER */ - zIdx += nId - 1; - } - else - { - /* Operators and special symbols */ - token = tkOTHER; - } - break; + state = trans[state][token]; + zIdx++; } + return (state == 1) ? 1 : 0;//return state==1; } - state = trans[state][token]; - zIdx++; - } - return ( state == 1 ) ? 1 : 0;//return state==1; - } #if !SQLITE_OMIT_UTF16 /* @@ -358,5 +314,5 @@ int sqlite3_complete16(const void *zSql){ } #endif // * SQLITE_OMIT_UTF16 */ #endif // * SQLITE_OMIT_COMPLETE */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/crypto.cs b/Src/IronPython.SQLite/c#sqlite/crypto.cs index 5c3eec460..7c409ea59 100644 --- a/Src/IronPython.SQLite/c#sqlite/crypto.cs +++ b/Src/IronPython.SQLite/c#sqlite/crypto.cs @@ -1,63 +1,49 @@ -using System; -using System.Diagnostics; -using System.Text; - -using u8 = System.Byte; -using u16 = System.UInt16; -using Pgno = System.UInt32; - -namespace Community.CsharpSqlite -{ - using sqlite3_int64 = System.Int64; - using sqlite3_stmt = Sqlite3.Vdbe; -#if !SQLITE_WINRT - using System.Security.Cryptography; - using System.IO; +namespace Community.CsharpSqlite { +#if !SQLITE_WINRT #endif - public partial class Sqlite3 - { - /* - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2010 Noah B Hart, Diego Torres - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ************************************************************************* - */ - - /* - ** SQLCipher - ** crypto.c developed by Stephen Lombardo (Zetetic LLC) - ** sjlombardo at zetetic dot net - ** http://zetetic.net - ** - ** Copyright (c) 2009, ZETETIC LLC - ** All rights reserved. - ** - ** Redistribution and use in source and binary forms, with or without - ** modification, are permitted provided that the following conditions are met: - ** * Redistributions of source code must retain the above copyright - ** notice, this list of conditions and the following disclaimer. - ** * Redistributions in binary form must reproduce the above copyright - ** notice, this list of conditions and the following disclaimer in the - ** documentation and/or other materials provided with the distribution. - ** * Neither the name of the ZETETIC LLC nor the - ** names of its contributors may be used to endorse or promote products - ** derived from this software without specific prior written permission. - ** - ** THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY - ** EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - ** DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY - ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ** - */ - /* BEGIN CRYPTO */ + public partial class Sqlite3 { + /* + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2010 Noah B Hart, Diego Torres + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ************************************************************************* + */ + + /* + ** SQLCipher + ** crypto.c developed by Stephen Lombardo (Zetetic LLC) + ** sjlombardo at zetetic dot net + ** http://zetetic.net + ** + ** Copyright (c) 2009, ZETETIC LLC + ** All rights reserved. + ** + ** Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions are met: + ** * Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** * Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in the + ** documentation and/or other materials provided with the distribution. + ** * Neither the name of the ZETETIC LLC nor the + ** names of its contributors may be used to endorse or promote products + ** derived from this software without specific prior written permission. + ** + ** THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY + ** EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + ** DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY + ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ** + */ + /* BEGIN CRYPTO */ #if SQLITE_HAS_CODEC //#include @@ -758,8 +744,8 @@ static void sqlite3CodecGetKey( sqlite3 db, int nDb, out string zKey, out int nK } /* END CRYPTO */ #endif - const int SQLITE_ENCRYPT_WRITE_CTX = 6; /* Encode page */ - const int SQLITE_ENCRYPT_READ_CTX = 7; /* Encode page */ - const int SQLITE_DECRYPT = 3; /* Decode page */ - } + const int SQLITE_ENCRYPT_WRITE_CTX = 6; /* Encode page */ + const int SQLITE_ENCRYPT_READ_CTX = 7; /* Encode page */ + const int SQLITE_DECRYPT = 3; /* Decode page */ + } } diff --git a/Src/IronPython.SQLite/c#sqlite/ctime_c.cs b/Src/IronPython.SQLite/c#sqlite/ctime_c.cs index 5f7917a0e..8e2a85a7b 100644 --- a/Src/IronPython.SQLite/c#sqlite/ctime_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/ctime_c.cs @@ -1,48 +1,45 @@ #pragma warning disable CA1865 // Use char overload -namespace Community.CsharpSqlite -{ - using sqlite3_value = Sqlite3.Mem; - using System; +namespace Community.CsharpSqlite { + using System; - public partial class Sqlite3 - { - /* - ** 2010 February 23 - ** - ** 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 implements routines used to report what compile-time options - ** SQLite was built with. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-01-28 17:03:50 ed759d5a9edb3bba5f48f243df47be29e3fe8cd7 - ** - ************************************************************************* - */ + public partial class Sqlite3 { + /* + ** 2010 February 23 + ** + ** 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 implements routines used to report what compile-time options + ** SQLite was built with. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-01-28 17:03:50 ed759d5a9edb3bba5f48f243df47be29e3fe8cd7 + ** + ************************************************************************* + */ #if !SQLITE_OMIT_COMPILEOPTION_DIAGS - //#include "sqliteInt.h" + //#include "sqliteInt.h" - /* - ** An array of names of all compile-time options. This array should - ** be sorted A-Z. - ** - ** This array looks large, but in a typical installation actually uses - ** only a handful of compile-time options, so most times this array is usually - ** rather short and uses little memory space. - */ - static string[] azCompileOpt = { + /* + ** An array of names of all compile-time options. This array should + ** be sorted A-Z. + ** + ** This array looks large, but in a typical installation actually uses + ** only a handful of compile-time options, so most times this array is usually + ** rather short and uses little memory space. + */ + static string[] azCompileOpt = { /* These macros are provided to "stringify" the value of the define ** for those options in which the value is meaningful. */ @@ -376,47 +373,43 @@ public partial class Sqlite3 #endif }; - /* - ** Given the name of a compile-time option, return true if that option - ** was used and false if not. - ** - ** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix - ** is not required for a match. - */ - static int sqlite3_compileoption_used( string zOptName ) - { - if ( zOptName.EndsWith( "=", StringComparison.Ordinal ) ) - return 0; - int i, n = 0; - if ( zOptName.StartsWith( "SQLITE_", System.StringComparison.OrdinalIgnoreCase ) ) - n = 7; - //n = sqlite3Strlen30(zOptName); + /* + ** Given the name of a compile-time option, return true if that option + ** was used and false if not. + ** + ** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix + ** is not required for a match. + */ + static int sqlite3_compileoption_used(string zOptName) { + if (zOptName.EndsWith("=", StringComparison.Ordinal)) + return 0; + int i, n = 0; + if (zOptName.StartsWith("SQLITE_", System.StringComparison.OrdinalIgnoreCase)) + n = 7; + //n = sqlite3Strlen30(zOptName); - /* Since ArraySize(azCompileOpt) is normally in single digits, a - ** linear search is adequate. No need for a binary search. */ - if ( !String.IsNullOrEmpty( zOptName ) ) - for ( i = 0; i < ArraySize( azCompileOpt ); i++ ) - { - int n1 = ( zOptName.Length-n < azCompileOpt[i].Length ) ? zOptName.Length-n : azCompileOpt[i].Length; - if ( String.Compare( zOptName, n, azCompileOpt[i], 0, n1, StringComparison.OrdinalIgnoreCase ) == 0 ) - return 1; + /* Since ArraySize(azCompileOpt) is normally in single digits, a + ** linear search is adequate. No need for a binary search. */ + if (!String.IsNullOrEmpty(zOptName)) + for (i = 0; i < ArraySize(azCompileOpt); i++) { + int n1 = (zOptName.Length - n < azCompileOpt[i].Length) ? zOptName.Length - n : azCompileOpt[i].Length; + if (String.Compare(zOptName, n, azCompileOpt[i], 0, n1, StringComparison.OrdinalIgnoreCase) == 0) + return 1; + } + return 0; } - return 0; - } - /* - ** Return the N-th compile-time option string. If N is out of range, - ** return a NULL pointer. - */ - static string sqlite3_compileoption_get( int N ) - { - if ( N >= 0 && N < ArraySize( azCompileOpt ) ) - { - return azCompileOpt[N]; - } - return null; - } + /* + ** Return the N-th compile-time option string. If N is out of range, + ** return a NULL pointer. + */ + static string sqlite3_compileoption_get(int N) { + if (N >= 0 && N < ArraySize(azCompileOpt)) { + return azCompileOpt[N]; + } + return null; + } #endif //* SQLITE_OMIT_COMPILEOPTION_DIAGS */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/date_c.cs b/Src/IronPython.SQLite/c#sqlite/date_c.cs index 4497a7722..9b30ea8a3 100644 --- a/Src/IronPython.SQLite/c#sqlite/date_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/date_c.cs @@ -2,577 +2,515 @@ using System.Diagnostics; using System.Text; -using time_t = System.Int64; -using sqlite3_int64 = System.Int64; using i64 = System.Int64; +using sqlite3_int64 = System.Int64; +using time_t = System.Int64; using u64 = System.UInt64; -namespace Community.CsharpSqlite -{ - using sqlite3_value = Sqlite3.Mem; +namespace Community.CsharpSqlite { + using sqlite3_value = Sqlite3.Mem; - public partial class Sqlite3 - { - /* - ** 2003 October 31 - ** - ** 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 contains the C functions that implement date and time - ** functions for SQLite. - ** - ** There is only one exported symbol in this file - the function - ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file. - ** All other code has file scope. - ** - ** SQLite processes all times and dates as Julian Day numbers. The - ** dates and times are stored as the number of days since noon - ** in Greenwich on November 24, 4714 B.C. according to the Gregorian - ** calendar system. - ** - ** 1970-01-01 00:00:00 is JD 2440587.5 - ** 2000-01-01 00:00:00 is JD 2451544.5 - ** - ** This implemention requires years to be expressed as a 4-digit number - ** which means that only dates between 0000-01-01 and 9999-12-31 can - ** be represented, even though julian day numbers allow a much wider - ** range of dates. - ** - ** The Gregorian calendar system is used for all dates and times, - ** even those that predate the Gregorian calendar. Historians usually - ** use the Julian calendar for dates prior to 1582-10-15 and for some - ** dates afterwards, depending on locale. Beware of this difference. - ** - ** The conversion algorithms are implemented based on descriptions - ** in the following text: - ** - ** Jean Meeus - ** Astronomical Algorithms, 2nd Edition, 1998 - ** ISBM 0-943396-61-1 - ** Willmann-Bell, Inc - ** Richmond, Virginia (USA) - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include - //#include - //#include + public partial class Sqlite3 { + /* + ** 2003 October 31 + ** + ** 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 contains the C functions that implement date and time + ** functions for SQLite. + ** + ** There is only one exported symbol in this file - the function + ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file. + ** All other code has file scope. + ** + ** SQLite processes all times and dates as Julian Day numbers. The + ** dates and times are stored as the number of days since noon + ** in Greenwich on November 24, 4714 B.C. according to the Gregorian + ** calendar system. + ** + ** 1970-01-01 00:00:00 is JD 2440587.5 + ** 2000-01-01 00:00:00 is JD 2451544.5 + ** + ** This implemention requires years to be expressed as a 4-digit number + ** which means that only dates between 0000-01-01 and 9999-12-31 can + ** be represented, even though julian day numbers allow a much wider + ** range of dates. + ** + ** The Gregorian calendar system is used for all dates and times, + ** even those that predate the Gregorian calendar. Historians usually + ** use the Julian calendar for dates prior to 1582-10-15 and for some + ** dates afterwards, depending on locale. Beware of this difference. + ** + ** The conversion algorithms are implemented based on descriptions + ** in the following text: + ** + ** Jean Meeus + ** Astronomical Algorithms, 2nd Edition, 1998 + ** ISBM 0-943396-61-1 + ** Willmann-Bell, Inc + ** Richmond, Virginia (USA) + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include + //#include + //#include #if !SQLITE_OMIT_DATETIME_FUNCS - /* - ** A structure for holding a single date and time. - */ - //typedef struct DateTime DateTime; - public class DateTime - { - public sqlite3_int64 iJD; /* The julian day number times 86400000 */ - public int Y, M, D; /* Year, month, and day */ - public int h, m; /* Hour and minutes */ - public int tz; /* Timezone offset in minutes */ - public double s; /* Seconds */ - public byte validYMD; /* True (1) if Y,M,D are valid */ - public byte validHMS; /* True (1) if h,m,s are valid */ - public byte validJD; /* True (1) if iJD is valid */ - public byte validTZ; /* True (1) if tz is valid */ + /* + ** A structure for holding a single date and time. + */ + //typedef struct DateTime DateTime; + public class DateTime { + public sqlite3_int64 iJD; /* The julian day number times 86400000 */ + public int Y, M, D; /* Year, month, and day */ + public int h, m; /* Hour and minutes */ + public int tz; /* Timezone offset in minutes */ + public double s; /* Seconds */ + public byte validYMD; /* True (1) if Y,M,D are valid */ + public byte validHMS; /* True (1) if h,m,s are valid */ + public byte validJD; /* True (1) if iJD is valid */ + public byte validTZ; /* True (1) if tz is valid */ - public void CopyTo( DateTime ct ) - { - ct.iJD = iJD; - ct.Y = Y; - ct.M = M; - ct.D = D; - ct.h = h; - ct.m = m; - ct.tz = tz; - ct.s = s; - ct.validYMD = validYMD; - ct.validHMS = validHMS; - ct.validJD = validJD; - ct.validTZ = validJD; - } - }; + public void CopyTo(DateTime ct) { + ct.iJD = iJD; + ct.Y = Y; + ct.M = M; + ct.D = D; + ct.h = h; + ct.m = m; + ct.tz = tz; + ct.s = s; + ct.validYMD = validYMD; + ct.validHMS = validHMS; + ct.validJD = validJD; + ct.validTZ = validJD; + } + }; - // Temporary String for use in this module - static StringBuilder zdtTemp = new StringBuilder( 100 ); - static StringBuilder zdtBuf = new StringBuilder( 100 ); + // Temporary String for use in this module + static StringBuilder zdtTemp = new StringBuilder(100); + static StringBuilder zdtBuf = new StringBuilder(100); - /* - ** Convert zDate into one or more integers. Additional arguments - ** come in groups of 5 as follows: - ** - ** N number of digits in the integer - ** min minimum allowed value of the integer - ** max maximum allowed value of the integer - ** nextC first character after the integer - ** pVal where to write the integers value. - ** - ** Conversions continue until one with nextC==0 is encountered. - ** The function returns the number of successful conversions. - */ - static int getDigits( string zDate, int N0, int min0, int max0, char nextC0, ref int pVal0, int N1, int min1, int max1, char nextC1, ref int pVal1 ) - { - int c0 = getDigits( zDate + '\0', N0, min0, max0, nextC0, ref pVal0 ); - return c0 == 0 ? 0 : c0 + getDigits( zDate.Substring( zDate.IndexOf( nextC0 ) + 1 ) + '\0', N1, min1, max1, nextC1, ref pVal1 ); - } - static int getDigits( string zDate, int N0, int min0, int max0, char nextC0, ref int pVal0, int N1, int min1, int max1, char nextC1, ref int pVal1, int N2, int min2, int max2, char nextC2, ref int pVal2 ) - { - int c0 = getDigits( zDate + '\0', N0, min0, max0, nextC0, ref pVal0 ); - if ( c0 == 0 ) - return 0; - string zDate1 = zDate.Substring( zDate.IndexOf( nextC0 ) + 1 ); - int c1 = getDigits( zDate1 + '\0', N1, min1, max1, nextC1, ref pVal1 ); - if ( c1 == 0 ) - return c0; - return c0 + c1 + getDigits( zDate1.Substring( zDate1.IndexOf( nextC1 ) + 1 ) + '\0', N2, min2, max2, nextC2, ref pVal2 ); - } - static int getDigits( string zDate, int N, int min, int max, char nextC, ref int pVal ) - { - //va_list ap; - int val; - //int N; - //int min; - //int max; - //char nextC; - //int pVal; - int cnt = 0; - //va_start( ap, zDate ); - int zIndex = 0; - //do - //{ - //N = va_arg( ap, ( Int32 ) 0 ); - //min = va_arg( ap, ( Int32 ) 0 ); - //max = va_arg( ap, ( Int32 ) 0 ); - //nextC = (char)va_arg( ap, "char" ); - //pVal = va_arg( ap, ( Int32 ) 0 ); - val = 0; - while ( N-- != 0 ) - { - if ( !sqlite3Isdigit( zDate[zIndex] ) ) - { - goto end_getDigits; + /* + ** Convert zDate into one or more integers. Additional arguments + ** come in groups of 5 as follows: + ** + ** N number of digits in the integer + ** min minimum allowed value of the integer + ** max maximum allowed value of the integer + ** nextC first character after the integer + ** pVal where to write the integers value. + ** + ** Conversions continue until one with nextC==0 is encountered. + ** The function returns the number of successful conversions. + */ + static int getDigits(string zDate, int N0, int min0, int max0, char nextC0, ref int pVal0, int N1, int min1, int max1, char nextC1, ref int pVal1) { + int c0 = getDigits(zDate + '\0', N0, min0, max0, nextC0, ref pVal0); + return c0 == 0 ? 0 : c0 + getDigits(zDate.Substring(zDate.IndexOf(nextC0) + 1) + '\0', N1, min1, max1, nextC1, ref pVal1); + } + static int getDigits(string zDate, int N0, int min0, int max0, char nextC0, ref int pVal0, int N1, int min1, int max1, char nextC1, ref int pVal1, int N2, int min2, int max2, char nextC2, ref int pVal2) { + int c0 = getDigits(zDate + '\0', N0, min0, max0, nextC0, ref pVal0); + if (c0 == 0) + return 0; + string zDate1 = zDate.Substring(zDate.IndexOf(nextC0) + 1); + int c1 = getDigits(zDate1 + '\0', N1, min1, max1, nextC1, ref pVal1); + if (c1 == 0) + return c0; + return c0 + c1 + getDigits(zDate1.Substring(zDate1.IndexOf(nextC1) + 1) + '\0', N2, min2, max2, nextC2, ref pVal2); + } + static int getDigits(string zDate, int N, int min, int max, char nextC, ref int pVal) { + //va_list ap; + int val; + //int N; + //int min; + //int max; + //char nextC; + //int pVal; + int cnt = 0; + //va_start( ap, zDate ); + int zIndex = 0; + //do + //{ + //N = va_arg( ap, ( Int32 ) 0 ); + //min = va_arg( ap, ( Int32 ) 0 ); + //max = va_arg( ap, ( Int32 ) 0 ); + //nextC = (char)va_arg( ap, "char" ); + //pVal = va_arg( ap, ( Int32 ) 0 ); + val = 0; + while (N-- != 0) { + if (!sqlite3Isdigit(zDate[zIndex])) { + goto end_getDigits; + } + val = val * 10 + zDate[zIndex] - '0'; + zIndex++; + } + if (val < min || val > max || zIndex < zDate.Length && (nextC != 0 && nextC != zDate[zIndex])) { + goto end_getDigits; + } + pVal = val; + zIndex++; + cnt++; + //} while ( nextC != 0 && zIndex < zDate.Length ); + end_getDigits: + //va_end( ap ); + return cnt; } - val = val * 10 + zDate[zIndex] - '0'; - zIndex++; - } - if ( val < min || val > max || zIndex < zDate.Length && ( nextC != 0 && nextC != zDate[zIndex] ) ) - { - goto end_getDigits; - } - pVal = val; - zIndex++; - cnt++; -//} while ( nextC != 0 && zIndex < zDate.Length ); -end_getDigits: - //va_end( ap ); - return cnt; - } - - /* - ** Parse a timezone extension on the end of a date-time. - ** The extension is of the form: - ** - ** (+/-)HH:MM - ** - ** - ** Or the "zulu" notation: - ** - ** Z - ** - ** If the parse is successful, write the number of minutes - ** of change in p.tz and return 0. If a parser error occurs, - ** return non-zero. - ** - ** A missing specifier is not considered an error. - */ - static int parseTimezone( string zDate, DateTime p ) - { - int sgn = 0; - int nHr = 0; - int nMn = 0; - char c; - zDate = zDate.Trim();// while ( sqlite3Isspace( *(u8)zDate ) ) { zDate++; } - p.tz = 0; - c = zDate.Length == 0 ? '\0' : zDate[0]; - if ( c == '-' ) - { - sgn = -1; - } - else if ( c == '+' ) - { - sgn = +1; - } - else if ( c == 'Z' || c == 'z' ) - { - zDate = zDate.Substring( 1 ).Trim();//zDate++; - goto zulu_time; - } - else - { - return c != '\0' ? 1 : 0; - } - //zDate++; - if ( getDigits( zDate.Substring( 1 ), 2, 0, 14, ':', ref nHr, 2, 0, 59, '\0', ref nMn ) != 2 ) - { - return 1; - } - //zDate += 5; - p.tz = sgn * ( nMn + nHr * 60 ); - if ( zDate.Length == 6 ) - zDate = ""; - else if ( zDate.Length > 6 ) - zDate = zDate.Substring( 6 ).Trim();// while ( sqlite3Isspace( *(u8)zDate ) ) { zDate++; } -zulu_time: - return zDate != "" ? 1 : 0; - } - /* - ** Parse times of the form HH:MM or HH:MM:SS or HH:MM:SS.FFFF. - ** The HH, MM, and SS must each be exactly 2 digits. The - ** fractional seconds FFFF can be one or more digits. - ** - ** Return 1 if there is a parsing error and 0 on success. - */ - static int parseHhMmSs( string zDate, DateTime p ) - { - int h = 0; - int m = 0; - int s = 0; - double ms = 0.0; - if ( getDigits( zDate, 2, 0, 24, ':', ref h, 2, 0, 59, '\0', ref m ) != 2 ) - { - return 1; - } - int zIndex = 5;// zDate += 5; - if ( zIndex < zDate.Length && zDate[zIndex] == ':' ) - { - zIndex++;// zDate++; - if ( getDigits( zDate.Substring( zIndex ), 2, 0, 59, '\0', ref s ) != 1 ) - { - return 1; + /* + ** Parse a timezone extension on the end of a date-time. + ** The extension is of the form: + ** + ** (+/-)HH:MM + ** + ** + ** Or the "zulu" notation: + ** + ** Z + ** + ** If the parse is successful, write the number of minutes + ** of change in p.tz and return 0. If a parser error occurs, + ** return non-zero. + ** + ** A missing specifier is not considered an error. + */ + static int parseTimezone(string zDate, DateTime p) { + int sgn = 0; + int nHr = 0; + int nMn = 0; + char c; + zDate = zDate.Trim();// while ( sqlite3Isspace( *(u8)zDate ) ) { zDate++; } + p.tz = 0; + c = zDate.Length == 0 ? '\0' : zDate[0]; + if (c == '-') { + sgn = -1; + } else if (c == '+') { + sgn = +1; + } else if (c == 'Z' || c == 'z') { + zDate = zDate.Substring(1).Trim();//zDate++; + goto zulu_time; + } else { + return c != '\0' ? 1 : 0; + } + //zDate++; + if (getDigits(zDate.Substring(1), 2, 0, 14, ':', ref nHr, 2, 0, 59, '\0', ref nMn) != 2) { + return 1; + } + //zDate += 5; + p.tz = sgn * (nMn + nHr * 60); + if (zDate.Length == 6) + zDate = ""; + else if (zDate.Length > 6) + zDate = zDate.Substring(6).Trim();// while ( sqlite3Isspace( *(u8)zDate ) ) { zDate++; } + zulu_time: + return zDate != "" ? 1 : 0; } - zIndex += 2;// zDate += 2; - if ( zIndex + 1 < zDate.Length && zDate[zIndex] == '.' && sqlite3Isdigit( zDate[zIndex + 1] ) ) - { - double rScale = 1.0; - zIndex++;// zDate++; - while ( zIndex < zDate.Length && sqlite3Isdigit( zDate[zIndex] ) - ) - { - ms = ms * 10.0 + zDate[zIndex] - '0'; - rScale *= 10.0; - zIndex++;//zDate++; - } - ms /= rScale; + + /* + ** Parse times of the form HH:MM or HH:MM:SS or HH:MM:SS.FFFF. + ** The HH, MM, and SS must each be exactly 2 digits. The + ** fractional seconds FFFF can be one or more digits. + ** + ** Return 1 if there is a parsing error and 0 on success. + */ + static int parseHhMmSs(string zDate, DateTime p) { + int h = 0; + int m = 0; + int s = 0; + double ms = 0.0; + if (getDigits(zDate, 2, 0, 24, ':', ref h, 2, 0, 59, '\0', ref m) != 2) { + return 1; + } + int zIndex = 5;// zDate += 5; + if (zIndex < zDate.Length && zDate[zIndex] == ':') { + zIndex++;// zDate++; + if (getDigits(zDate.Substring(zIndex), 2, 0, 59, '\0', ref s) != 1) { + return 1; + } + zIndex += 2;// zDate += 2; + if (zIndex + 1 < zDate.Length && zDate[zIndex] == '.' && sqlite3Isdigit(zDate[zIndex + 1])) { + double rScale = 1.0; + zIndex++;// zDate++; + while (zIndex < zDate.Length && sqlite3Isdigit(zDate[zIndex]) + ) { + ms = ms * 10.0 + zDate[zIndex] - '0'; + rScale *= 10.0; + zIndex++;//zDate++; + } + ms /= rScale; + } + } else { + s = 0; + } + p.validJD = 0; + p.validHMS = 1; + p.h = h; + p.m = m; + p.s = s + ms; + if (zIndex < zDate.Length && parseTimezone(zDate.Substring(zIndex), p) != 0) + return 1; + p.validTZ = (byte)((p.tz != 0) ? 1 : 0); + return 0; } - } - else - { - s = 0; - } - p.validJD = 0; - p.validHMS = 1; - p.h = h; - p.m = m; - p.s = s + ms; - if ( zIndex < zDate.Length && parseTimezone( zDate.Substring( zIndex ), p ) != 0 ) - return 1; - p.validTZ = (byte)( ( p.tz != 0 ) ? 1 : 0 ); - return 0; - } - /* - ** Convert from YYYY-MM-DD HH:MM:SS to julian day. We always assume - ** that the YYYY-MM-DD is according to the Gregorian calendar. - ** - ** Reference: Meeus page 61 - */ - static void computeJD( DateTime p ) - { - int Y, M, D, A, B, X1, X2; + /* + ** Convert from YYYY-MM-DD HH:MM:SS to julian day. We always assume + ** that the YYYY-MM-DD is according to the Gregorian calendar. + ** + ** Reference: Meeus page 61 + */ + static void computeJD(DateTime p) { + int Y, M, D, A, B, X1, X2; - if ( p.validJD != 0 ) - return; - if ( p.validYMD != 0 ) - { - Y = p.Y; - M = p.M; - D = p.D; - } - else - { - Y = 2000; /* If no YMD specified, assume 2000-Jan-01 */ - M = 1; - D = 1; - } - if ( M <= 2 ) - { - Y--; - M += 12; - } - A = Y / 100; - B = 2 - A + ( A / 4 ); - X1 = (int)( 36525 * ( Y + 4716 ) / 100 ); - X2 = (int)( 306001 * ( M + 1 ) / 10000 ); - p.iJD = (long)( ( X1 + X2 + D + B - 1524.5 ) * 86400000 ); - p.validJD = 1; - if ( p.validHMS != 0 ) - { - p.iJD += (long)( p.h * 3600000 + p.m * 60000 + p.s * 1000 ); - if ( p.validTZ != 0 ) - { - p.iJD -= p.tz * 60000; - p.validYMD = 0; - p.validHMS = 0; - p.validTZ = 0; + if (p.validJD != 0) + return; + if (p.validYMD != 0) { + Y = p.Y; + M = p.M; + D = p.D; + } else { + Y = 2000; /* If no YMD specified, assume 2000-Jan-01 */ + M = 1; + D = 1; + } + if (M <= 2) { + Y--; + M += 12; + } + A = Y / 100; + B = 2 - A + (A / 4); + X1 = (int)(36525 * (Y + 4716) / 100); + X2 = (int)(306001 * (M + 1) / 10000); + p.iJD = (long)((X1 + X2 + D + B - 1524.5) * 86400000); + p.validJD = 1; + if (p.validHMS != 0) { + p.iJD += (long)(p.h * 3600000 + p.m * 60000 + p.s * 1000); + if (p.validTZ != 0) { + p.iJD -= p.tz * 60000; + p.validYMD = 0; + p.validHMS = 0; + p.validTZ = 0; + } + } } - } - } - /* - ** Parse dates of the form - ** - ** YYYY-MM-DD HH:MM:SS.FFF - ** YYYY-MM-DD HH:MM:SS - ** YYYY-MM-DD HH:MM - ** YYYY-MM-DD - ** - ** Write the result into the DateTime structure and return 0 - ** on success and 1 if the input string is not a well-formed - ** date. - */ - static int parseYyyyMmDd( string zDate, DateTime p ) - { - int Y = 0; - int M = 0; - int D = 0; - bool neg; + /* + ** Parse dates of the form + ** + ** YYYY-MM-DD HH:MM:SS.FFF + ** YYYY-MM-DD HH:MM:SS + ** YYYY-MM-DD HH:MM + ** YYYY-MM-DD + ** + ** Write the result into the DateTime structure and return 0 + ** on success and 1 if the input string is not a well-formed + ** date. + */ + static int parseYyyyMmDd(string zDate, DateTime p) { + int Y = 0; + int M = 0; + int D = 0; + bool neg; - int zIndex = 0; - if ( zDate[zIndex] == '-' ) - { - zIndex++;// zDate++; - neg = true; - } - else - { - neg = false; - } - if ( getDigits( zDate.Substring( zIndex ), 4, 0, 9999, '-', ref Y, 2, 1, 12, '-', ref M, 2, 1, 31, '\0', ref D ) != 3 ) - { - return 1; - } - zIndex += 10;// zDate += 10; - while ( zIndex < zDate.Length && ( sqlite3Isspace( zDate[zIndex] ) || 'T' == zDate[zIndex] ) ) - { - zIndex++; - }//zDate++; } - if ( zIndex < zDate.Length && parseHhMmSs( zDate.Substring( zIndex ), p ) == 0 ) - { - /* We got the time */ - } - else if ( zIndex >= zDate.Length )// zDate[zIndex] == '\0') - { - p.validHMS = 0; - } - else - { - return 1; - } - p.validJD = 0; - p.validYMD = 1; - p.Y = neg ? -Y : Y; - p.M = M; - p.D = D; - if ( p.validTZ != 0 ) - { - computeJD( p ); - } - return 0; - } + int zIndex = 0; + if (zDate[zIndex] == '-') { + zIndex++;// zDate++; + neg = true; + } else { + neg = false; + } + if (getDigits(zDate.Substring(zIndex), 4, 0, 9999, '-', ref Y, 2, 1, 12, '-', ref M, 2, 1, 31, '\0', ref D) != 3) { + return 1; + } + zIndex += 10;// zDate += 10; + while (zIndex < zDate.Length && (sqlite3Isspace(zDate[zIndex]) || 'T' == zDate[zIndex])) { + zIndex++; + }//zDate++; } + if (zIndex < zDate.Length && parseHhMmSs(zDate.Substring(zIndex), p) == 0) { + /* We got the time */ + } else if (zIndex >= zDate.Length)// zDate[zIndex] == '\0') + { + p.validHMS = 0; + } else { + return 1; + } + p.validJD = 0; + p.validYMD = 1; + p.Y = neg ? -Y : Y; + p.M = M; + p.D = D; + if (p.validTZ != 0) { + computeJD(p); + } + return 0; + } - /* - ** Set the time to the current time reported by the VFS - */ - static void setDateTimeToCurrent( sqlite3_context context, DateTime p ) - { - sqlite3 db = sqlite3_context_db_handle( context ); - sqlite3OsCurrentTimeInt64( db.pVfs, ref p.iJD ); - p.validJD = 1; - } + /* + ** Set the time to the current time reported by the VFS + */ + static void setDateTimeToCurrent(sqlite3_context context, DateTime p) { + sqlite3 db = sqlite3_context_db_handle(context); + sqlite3OsCurrentTimeInt64(db.pVfs, ref p.iJD); + p.validJD = 1; + } - /* - ** Attempt to parse the given string into a Julian Day Number. Return - ** the number of errors. - ** - ** The following are acceptable forms for the input string: - ** - ** YYYY-MM-DD HH:MM:SS.FFF +/-HH:MM - ** DDDD.DD - ** now - ** - ** In the first form, the +/-HH:MM is always optional. The fractional - ** seconds extension (the ".FFF") is optional. The seconds portion - ** (":SS.FFF") is option. The year and date can be omitted as long - ** as there is a time string. The time string can be omitted as long - ** as there is a year and date. - */ - static int parseDateOrTime( - sqlite3_context context, - string zDate, - ref DateTime p - ) - { - double r = 0.0; - if ( parseYyyyMmDd( zDate, p ) == 0 ) - { - return 0; - } - else if ( parseHhMmSs( zDate, p ) == 0 ) - { - return 0; - } - else if ( zDate.Equals( "now", StringComparison.OrdinalIgnoreCase ) ) - { - setDateTimeToCurrent( context, p ); - return 0; - } - else if ( sqlite3AtoF( zDate, ref r, sqlite3Strlen30( zDate ), SQLITE_UTF8 ) ) - { - p.iJD = (sqlite3_int64)( r * 86400000.0 + 0.5 ); - p.validJD = 1; - return 0; - } - return 1; - } + /* + ** Attempt to parse the given string into a Julian Day Number. Return + ** the number of errors. + ** + ** The following are acceptable forms for the input string: + ** + ** YYYY-MM-DD HH:MM:SS.FFF +/-HH:MM + ** DDDD.DD + ** now + ** + ** In the first form, the +/-HH:MM is always optional. The fractional + ** seconds extension (the ".FFF") is optional. The seconds portion + ** (":SS.FFF") is option. The year and date can be omitted as long + ** as there is a time string. The time string can be omitted as long + ** as there is a year and date. + */ + static int parseDateOrTime( + sqlite3_context context, + string zDate, + ref DateTime p + ) { + double r = 0.0; + if (parseYyyyMmDd(zDate, p) == 0) { + return 0; + } else if (parseHhMmSs(zDate, p) == 0) { + return 0; + } else if (zDate.Equals("now", StringComparison.OrdinalIgnoreCase)) { + setDateTimeToCurrent(context, p); + return 0; + } else if (sqlite3AtoF(zDate, ref r, sqlite3Strlen30(zDate), SQLITE_UTF8)) { + p.iJD = (sqlite3_int64)(r * 86400000.0 + 0.5); + p.validJD = 1; + return 0; + } + return 1; + } - /* - ** Compute the Year, Month, and Day from the julian day number. - */ - static void computeYMD( DateTime p ) - { - int Z, A, B, C, D, E, X1; - if ( p.validYMD != 0 ) - return; - if ( 0 == p.validJD ) - { - p.Y = 2000; - p.M = 1; - p.D = 1; - } - else - { - Z = (int)( ( p.iJD + 43200000 ) / 86400000 ); - A = (int)( ( Z - 1867216.25 ) / 36524.25 ); - A = Z + 1 + A - ( A / 4 ); - B = A + 1524; - C = (int)( ( B - 122.1 ) / 365.25 ); - D = (int)( ( 36525 * C ) / 100 ); - E = (int)( ( B - D ) / 30.6001 ); - X1 = (int)( 30.6001 * E ); - p.D = B - D - X1; - p.M = E < 14 ? E - 1 : E - 13; - p.Y = p.M > 2 ? C - 4716 : C - 4715; - } - p.validYMD = 1; - } + /* + ** Compute the Year, Month, and Day from the julian day number. + */ + static void computeYMD(DateTime p) { + int Z, A, B, C, D, E, X1; + if (p.validYMD != 0) + return; + if (0 == p.validJD) { + p.Y = 2000; + p.M = 1; + p.D = 1; + } else { + Z = (int)((p.iJD + 43200000) / 86400000); + A = (int)((Z - 1867216.25) / 36524.25); + A = Z + 1 + A - (A / 4); + B = A + 1524; + C = (int)((B - 122.1) / 365.25); + D = (int)((36525 * C) / 100); + E = (int)((B - D) / 30.6001); + X1 = (int)(30.6001 * E); + p.D = B - D - X1; + p.M = E < 14 ? E - 1 : E - 13; + p.Y = p.M > 2 ? C - 4716 : C - 4715; + } + p.validYMD = 1; + } - /* - ** Compute the Hour, Minute, and Seconds from the julian day number. - */ - static void computeHMS( DateTime p ) - { - int s; - if ( p.validHMS != 0 ) - return; - computeJD( p ); - s = (int)( ( p.iJD + 43200000 ) % 86400000 ); - p.s = s / 1000.0; - s = (int)p.s; - p.s -= s; - p.h = s / 3600; - s -= p.h * 3600; - p.m = s / 60; - p.s += s - p.m * 60; - p.validHMS = 1; - } + /* + ** Compute the Hour, Minute, and Seconds from the julian day number. + */ + static void computeHMS(DateTime p) { + int s; + if (p.validHMS != 0) + return; + computeJD(p); + s = (int)((p.iJD + 43200000) % 86400000); + p.s = s / 1000.0; + s = (int)p.s; + p.s -= s; + p.h = s / 3600; + s -= p.h * 3600; + p.m = s / 60; + p.s += s - p.m * 60; + p.validHMS = 1; + } - /* - ** Compute both YMD and HMS - */ - static void computeYMD_HMS( DateTime p ) - { - computeYMD( p ); - computeHMS( p ); - } + /* + ** Compute both YMD and HMS + */ + static void computeYMD_HMS(DateTime p) { + computeYMD(p); + computeHMS(p); + } - /* - ** Clear the YMD and HMS and the TZ - */ - static void clearYMD_HMS_TZ( DateTime p ) - { - p.validYMD = 0; - p.validHMS = 0; - p.validTZ = 0; - } + /* + ** Clear the YMD and HMS and the TZ + */ + static void clearYMD_HMS_TZ(DateTime p) { + p.validYMD = 0; + p.validHMS = 0; + p.validTZ = 0; + } - /* - ** On recent Windows platforms, the localtime_s() function is available - ** as part of the "Secure CRT". It is essentially equivalent to - ** localtime_r() available under most POSIX platforms, except that the - ** order of the parameters is reversed. - ** - ** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx. - ** - ** If the user has not indicated to use localtime_r() or localtime_s() - ** already, check for an MSVC build environment that provides - ** localtime_s(). - */ - //#if !defined(HAVE_LOCALTIME_R) && !defined(HAVE_LOCALTIME_S) && \ - // defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE) - //#define HAVE_LOCALTIME_S 1 - //#endif + /* + ** On recent Windows platforms, the localtime_s() function is available + ** as part of the "Secure CRT". It is essentially equivalent to + ** localtime_r() available under most POSIX platforms, except that the + ** order of the parameters is reversed. + ** + ** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx. + ** + ** If the user has not indicated to use localtime_r() or localtime_s() + ** already, check for an MSVC build environment that provides + ** localtime_s(). + */ + //#if !defined(HAVE_LOCALTIME_R) && !defined(HAVE_LOCALTIME_S) && \ + // defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE) + //#define HAVE_LOCALTIME_S 1 + //#endif #if !SQLITE_OMIT_LOCALTIME - /* - ** The following routine implements the rough equivalent of localtime_r() - ** using whatever operating-system specific localtime facility that - ** 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. - */ - static int osLocaltime( time_t t, ref tm pTm ) - { - int rc; + /* + ** The following routine implements the rough equivalent of localtime_r() + ** using whatever operating-system specific localtime facility that + ** 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. + */ + static int osLocaltime(time_t t, ref tm pTm) { + int rc; #if (!(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) && (!(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S) - tm pX; - sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); - sqlite3_mutex_enter( mutex ); - pX = localtime( t ); + tm pX; + sqlite3_mutex mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); + sqlite3_mutex_enter(mutex); + pX = localtime(t); #if !SQLITE_OMIT_BUILTIN_TEST - if ( sqlite3GlobalConfig.bLocaltimeFault ) - pX = null; + if (sqlite3GlobalConfig.bLocaltimeFault) + pX = null; #endif - if ( pX != null ) - pTm = pX; - sqlite3_mutex_leave( mutex ); - rc = pX == null ? 1 : 0; + if (pX != null) + pTm = pX; + sqlite3_mutex_leave(mutex); + rc = pX == null ? 1 : 0; #else #if !SQLITE_OMIT_BUILTIN_TEST if( sqlite3GlobalConfig.bLocaltimeFault ) return 1; @@ -583,746 +521,662 @@ static int osLocaltime( time_t t, ref tm pTm ) rc = localtime_s(pTm, t); #endif //* HAVE_LOCALTIME_R */ #endif //* HAVE_LOCALTIME_R || HAVE_LOCALTIME_S */ - return rc; - } + return rc; + } #endif //* SQLITE_OMIT_LOCALTIME */ #if !SQLITE_OMIT_LOCALTIME - /* -** Compute the difference (in milliseconds) between localtime and UTC -** (a.k.a. GMT) for the time value p where p is in UTC. If no error occurs, -** return this value and set *pRc to SQLITE_OK. -** -** Or, if an error does occur, set *pRc to SQLITE_ERROR. The returned value -** is undefined in this case. -*/ - static sqlite3_int64 localtimeOffset( - DateTime p, /* Date at which to calculate offset */ - sqlite3_context pCtx, /* Write error here if one occurs */ - out int pRc /* OUT: Error code. SQLITE_OK or ERROR */ - ) - { - DateTime x; - DateTime y = new DateTime(); - time_t t; - tm sLocal = new tm(); + /* + ** Compute the difference (in milliseconds) between localtime and UTC + ** (a.k.a. GMT) for the time value p where p is in UTC. If no error occurs, + ** return this value and set *pRc to SQLITE_OK. + ** + ** Or, if an error does occur, set *pRc to SQLITE_ERROR. The returned value + ** is undefined in this case. + */ + static sqlite3_int64 localtimeOffset( + DateTime p, /* Date at which to calculate offset */ + sqlite3_context pCtx, /* Write error here if one occurs */ + out int pRc /* OUT: Error code. SQLITE_OK or ERROR */ + ) { + DateTime x; + DateTime y = new DateTime(); + time_t t; + tm sLocal = new tm(); - /* Initialize the contents of sLocal to avoid a compiler warning. */ - //memset(&sLocal, 0, sizeof(sLocal)); + /* Initialize the contents of sLocal to avoid a compiler warning. */ + //memset(&sLocal, 0, sizeof(sLocal)); - x = p; - computeYMD_HMS( x ); - if ( x.Y < 1971 || x.Y >= 2038 ) - { - x.Y = 2000; - x.M = 1; - x.D = 1; - x.h = 0; - x.m = 0; - x.s = 0.0; - } - else - { - int s = (int)( x.s + 0.5 ); - x.s = s; - } - x.tz = 0; - x.validJD = 0; - computeJD( x ); - t = (long)( x.iJD / 1000 - 210866760000L );// (time_t)(x.iJD/1000 - 21086676*(i64)10000); - if ( osLocaltime( t, ref sLocal ) != 0 ) - { - sqlite3_result_error( pCtx, "local time unavailable", -1 ); - pRc = SQLITE_ERROR; - return 0; - } - y.Y = sLocal.tm_year;// +1900; - y.M = sLocal.tm_mon;// +1; - y.D = sLocal.tm_mday; - y.h = sLocal.tm_hour; - y.m = sLocal.tm_min; - y.s = sLocal.tm_sec; - y.validYMD = 1; - y.validHMS = 1; - y.validJD = 0; - y.validTZ = 0; - computeJD( y ); - pRc = SQLITE_OK; - return (int)( y.iJD - x.iJD ); - } + x = p; + computeYMD_HMS(x); + if (x.Y < 1971 || x.Y >= 2038) { + x.Y = 2000; + x.M = 1; + x.D = 1; + x.h = 0; + x.m = 0; + x.s = 0.0; + } else { + int s = (int)(x.s + 0.5); + x.s = s; + } + x.tz = 0; + x.validJD = 0; + computeJD(x); + t = (long)(x.iJD / 1000 - 210866760000L);// (time_t)(x.iJD/1000 - 21086676*(i64)10000); + if (osLocaltime(t, ref sLocal) != 0) { + sqlite3_result_error(pCtx, "local time unavailable", -1); + pRc = SQLITE_ERROR; + return 0; + } + y.Y = sLocal.tm_year;// +1900; + y.M = sLocal.tm_mon;// +1; + y.D = sLocal.tm_mday; + y.h = sLocal.tm_hour; + y.m = sLocal.tm_min; + y.s = sLocal.tm_sec; + y.validYMD = 1; + y.validHMS = 1; + y.validJD = 0; + y.validTZ = 0; + computeJD(y); + pRc = SQLITE_OK; + return (int)(y.iJD - x.iJD); + } #endif //* SQLITE_OMIT_LOCALTIME */ - /* -** Process a modifier to a date-time stamp. The modifiers are -** as follows: -** -** NNN days -** NNN hours -** NNN minutes -** NNN.NNNN seconds -** NNN months -** NNN years -** start of month -** start of year -** start of week -** start of day -** weekday N -** unixepoch -** localtime -** utc -** -** Return 0 on success and 1 if there is any kind of error. If the error -** is in a system call (i.e. localtime()), then an error message is written -** to context pCtx. If the error is an unrecognized modifier, no error is -** written to pCtx. -*/ - static int parseModifier( sqlite3_context pCtx, string zMod, DateTime p ) - { - int rc = 1; - int n; - double r = 0; - StringBuilder z = new StringBuilder( zMod.ToLowerInvariant() ); - zdtBuf.Length = 0; - //z = zdtBuf; - //for(n=0; niJD = p->iJD/86400 + 21086676*(i64)10000000; - clearYMD_HMS_TZ( p ); - rc = 0; - } -#if !SQLITE_OMIT_LOCALTIME - else if ( z.ToString() == "utc" ) - { - long c1; - computeJD( p ); - c1 = localtimeOffset( p, pCtx, out rc ); - if ( rc == SQLITE_OK ) - { - p.iJD -= c1; - clearYMD_HMS_TZ( p ); - p.iJD += c1 - localtimeOffset( p, pCtx, out rc ); - } - } + case 'u': { + /* + ** unixepoch + ** + ** Treat the current value of p.iJD as the number of + ** seconds since 1970. Convert to a real julian day number. + */ + if (z.ToString() == "unixepoch" && p.validJD != 0) { + p.iJD = (long)((p.iJD + 43200) / 86400 + 210866760000000L);//p->iJD = p->iJD/86400 + 21086676*(i64)10000000; + clearYMD_HMS_TZ(p); + rc = 0; + } +#if !SQLITE_OMIT_LOCALTIME + else if (z.ToString() == "utc") { + long c1; + computeJD(p); + c1 = localtimeOffset(p, pCtx, out rc); + if (rc == SQLITE_OK) { + p.iJD -= c1; + clearYMD_HMS_TZ(p); + p.iJD += c1 - localtimeOffset(p, pCtx, out rc); + } + } #endif - break; - } - case 'w': - { - /* - ** weekday N - ** - ** Move the date to the same time on the next occurrence of - ** weekday N where 0==Sunday, 1==Monday, and so forth. If the - ** date is already on the appropriate weekday, this is a no-op. - */ - if ( z.ToString().StartsWith( "weekday ", StringComparison.Ordinal ) - && sqlite3AtoF( z.ToString().Substring( 8 ), ref r, sqlite3Strlen30( z.ToString().Substring( 8 ) ), SQLITE_UTF8 ) - && ( n = (int)r ) == r && n >= 0 && r < 7 ) - { - sqlite3_int64 Z; - computeYMD_HMS( p ); - p.validTZ = 0; - p.validJD = 0; - computeJD( p ); - Z = ( ( p.iJD + 129600000 ) / 86400000 ) % 7; - if ( Z > n ) - Z -= 7; - p.iJD += ( n - Z ) * 86400000; - clearYMD_HMS_TZ( p ); - rc = 0; - } - break; - } - case 's': - { - /* - ** start of TTTTT - ** - ** Move the date backwards to the beginning of the current day, - ** or month or year. - */ - if ( z.Length <= 9 ) - z.Length = 0; - else - z.Remove( 0, 9 );//z += 9; - computeYMD( p ); - p.validHMS = 1; - p.h = p.m = 0; - p.s = 0.0; - p.validTZ = 0; - p.validJD = 0; - if ( z.ToString() == "month" ) - { - p.D = 1; - rc = 0; - } - else if ( z.ToString() == "year" ) - { - computeYMD( p ); - p.M = 1; - p.D = 1; - rc = 0; - } - else if ( z.ToString() == "day" ) - { - rc = 0; - } - break; - } - case '+': - case '-': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - double rRounder; - for ( n = 1; n < z.Length && z[n] != ':' && !sqlite3Isspace( z[n] ); n++ ) - { - } - if ( !sqlite3AtoF( z.ToString(), ref r, n, SQLITE_UTF8 ) ) - { - rc = 1; - break; - } - Debug.Assert( n >= 1 ); - if ( z[n] == ':' ) - { - /* A modifier of the form (+|-)HH:MM:SS.FFF adds (or subtracts) the - ** specified number of hours, minutes, seconds, and fractional seconds - ** to the time. The ".FFF" may be omitted. The ":SS.FFF" may be - ** omitted. - */ - string z2 = z.ToString(); - DateTime tx; - sqlite3_int64 day; - int z2Index = 0; - if ( !sqlite3Isdigit( z2[z2Index] ) ) - z2Index++;// z2++; - tx = new DateTime();// memset( &tx, 0, sizeof(tx)); - if ( parseHhMmSs( z2.Substring( z2Index ), tx ) != 0 ) - break; - computeJD( tx ); - tx.iJD -= 43200000; - day = tx.iJD / 86400000; - tx.iJD -= day * 86400000; - if ( z[0] == '-' ) - tx.iJD = -tx.iJD; - computeJD( p ); - clearYMD_HMS_TZ( p ); - p.iJD += tx.iJD; - rc = 0; - break; - } - //z += n; - while ( sqlite3Isspace( z[n] ) ) - n++;// z++; - z = z.Remove( 0, n ); - n = sqlite3Strlen30( z ); - if ( n > 10 || n < 3 ) - break; - if ( z[n - 1] == 's' ) - { - z.Length = --n; - }// z[n - 1] = '\0'; n--; } - computeJD( p ); - rc = 0; - rRounder = r < 0 ? -0.5 : +0.5; - if ( n == 3 && z.ToString() == "day" ) - { - p.iJD += (long)( r * 86400000.0 + rRounder ); - } - else if ( n == 4 && z.ToString() == "hour" ) - { - p.iJD += (long)( r * ( 86400000.0 / 24.0 ) + rRounder ); - } - else if ( n == 6 && z.ToString() == "minute" ) - { - p.iJD += (long)( r * ( 86400000.0 / ( 24.0 * 60.0 ) ) + rRounder ); - } - else if ( n == 6 && z.ToString() == "second" ) - { - p.iJD += (long)( r * ( 86400000.0 / ( 24.0 * 60.0 * 60.0 ) ) + rRounder ); + break; + } + case 'w': { + /* + ** weekday N + ** + ** Move the date to the same time on the next occurrence of + ** weekday N where 0==Sunday, 1==Monday, and so forth. If the + ** date is already on the appropriate weekday, this is a no-op. + */ + if (z.ToString().StartsWith("weekday ", StringComparison.Ordinal) + && sqlite3AtoF(z.ToString().Substring(8), ref r, sqlite3Strlen30(z.ToString().Substring(8)), SQLITE_UTF8) + && (n = (int)r) == r && n >= 0 && r < 7) { + sqlite3_int64 Z; + computeYMD_HMS(p); + p.validTZ = 0; + p.validJD = 0; + computeJD(p); + Z = ((p.iJD + 129600000) / 86400000) % 7; + if (Z > n) + Z -= 7; + p.iJD += (n - Z) * 86400000; + clearYMD_HMS_TZ(p); + rc = 0; + } + break; + } + case 's': { + /* + ** start of TTTTT + ** + ** Move the date backwards to the beginning of the current day, + ** or month or year. + */ + if (z.Length <= 9) + z.Length = 0; + else + z.Remove(0, 9);//z += 9; + computeYMD(p); + p.validHMS = 1; + p.h = p.m = 0; + p.s = 0.0; + p.validTZ = 0; + p.validJD = 0; + if (z.ToString() == "month") { + p.D = 1; + rc = 0; + } else if (z.ToString() == "year") { + computeYMD(p); + p.M = 1; + p.D = 1; + rc = 0; + } else if (z.ToString() == "day") { + rc = 0; + } + break; + } + case '+': + case '-': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': { + double rRounder; + for (n = 1; n < z.Length && z[n] != ':' && !sqlite3Isspace(z[n]); n++) { + } + if (!sqlite3AtoF(z.ToString(), ref r, n, SQLITE_UTF8)) { + rc = 1; + break; + } + Debug.Assert(n >= 1); + if (z[n] == ':') { + /* A modifier of the form (+|-)HH:MM:SS.FFF adds (or subtracts) the + ** specified number of hours, minutes, seconds, and fractional seconds + ** to the time. The ".FFF" may be omitted. The ":SS.FFF" may be + ** omitted. + */ + string z2 = z.ToString(); + DateTime tx; + sqlite3_int64 day; + int z2Index = 0; + if (!sqlite3Isdigit(z2[z2Index])) + z2Index++;// z2++; + tx = new DateTime();// memset( &tx, 0, sizeof(tx)); + if (parseHhMmSs(z2.Substring(z2Index), tx) != 0) + break; + computeJD(tx); + tx.iJD -= 43200000; + day = tx.iJD / 86400000; + tx.iJD -= day * 86400000; + if (z[0] == '-') + tx.iJD = -tx.iJD; + computeJD(p); + clearYMD_HMS_TZ(p); + p.iJD += tx.iJD; + rc = 0; + break; + } + //z += n; + while (sqlite3Isspace(z[n])) + n++;// z++; + z = z.Remove(0, n); + n = sqlite3Strlen30(z); + if (n > 10 || n < 3) + break; + if (z[n - 1] == 's') { + z.Length = --n; + }// z[n - 1] = '\0'; n--; } + computeJD(p); + rc = 0; + rRounder = r < 0 ? -0.5 : +0.5; + if (n == 3 && z.ToString() == "day") { + p.iJD += (long)(r * 86400000.0 + rRounder); + } else if (n == 4 && z.ToString() == "hour") { + p.iJD += (long)(r * (86400000.0 / 24.0) + rRounder); + } else if (n == 6 && z.ToString() == "minute") { + p.iJD += (long)(r * (86400000.0 / (24.0 * 60.0)) + rRounder); + } else if (n == 6 && z.ToString() == "second") { + p.iJD += (long)(r * (86400000.0 / (24.0 * 60.0 * 60.0)) + rRounder); + } else if (n == 5 && z.ToString() == "month") { + int x, y; + computeYMD_HMS(p); + p.M += (int)r; + x = p.M > 0 ? (p.M - 1) / 12 : (p.M - 12) / 12; + p.Y += x; + p.M -= x * 12; + p.validJD = 0; + computeJD(p); + y = (int)r; + if (y != r) { + p.iJD += (long)((r - y) * 30.0 * 86400000.0 + rRounder); + } + } else if (n == 4 && z.ToString() == "year") { + int y = (int)r; + computeYMD_HMS(p); + p.Y += y; + p.validJD = 0; + computeJD(p); + if (y != r) { + p.iJD += (sqlite3_int64)((r - y) * 365.0 * 86400000.0 + rRounder); + } + } else { + rc = 1; + } + clearYMD_HMS_TZ(p); + break; + } + default: { + break; + } } - else if ( n == 5 && z.ToString() == "month" ) - { - int x, y; - computeYMD_HMS( p ); - p.M += (int)r; - x = p.M > 0 ? ( p.M - 1 ) / 12 : ( p.M - 12 ) / 12; - p.Y += x; - p.M -= x * 12; - p.validJD = 0; - computeJD( p ); - y = (int)r; - if ( y != r ) - { - p.iJD += (long)( ( r - y ) * 30.0 * 86400000.0 + rRounder ); - } - } - else if ( n == 4 && z.ToString() == "year" ) - { - int y = (int)r; - computeYMD_HMS( p ); - p.Y += y; - p.validJD = 0; - computeJD( p ); - if ( y != r ) - { - p.iJD += (sqlite3_int64)( ( r - y ) * 365.0 * 86400000.0 + rRounder ); - } + return rc; + } + + /* + ** Process time function arguments. argv[0] is a date-time stamp. + ** argv[1] and following are modifiers. Parse them all and write + ** the resulting time into the DateTime structure p. Return 0 + ** on success and 1 if there are any errors. + ** + ** If there are zero parameters (if even argv[0] is undefined) + ** then assume a default value of "now" for argv[0]. + */ + static int isDate( + sqlite3_context context, + int argc, + sqlite3_value[] argv, + ref DateTime p + ) { + int i; + string z; + int eType; + p = new DateTime();//memset(p, 0, sizeof(*p)); + if (argc == 0) { + setDateTimeToCurrent(context, p); + } else if ((eType = sqlite3_value_type(argv[0])) == SQLITE_FLOAT + || eType == SQLITE_INTEGER) { + p.iJD = (long)(sqlite3_value_double(argv[0]) * 86400000.0 + 0.5); + p.validJD = 1; + } else { + z = sqlite3_value_text(argv[0]); + if (String.IsNullOrEmpty(z) || parseDateOrTime(context, z, ref p) != 0) { + return 1; + } } - else - { - rc = 1; + for (i = 1; i < argc; i++) { + z = sqlite3_value_text(argv[i]); + if (String.IsNullOrEmpty(z) || parseModifier(context, z, p) != 0) + return 1; } - clearYMD_HMS_TZ( p ); - break; - } - default: - { - break; - } - } - return rc; - } - - /* - ** Process time function arguments. argv[0] is a date-time stamp. - ** argv[1] and following are modifiers. Parse them all and write - ** the resulting time into the DateTime structure p. Return 0 - ** on success and 1 if there are any errors. - ** - ** If there are zero parameters (if even argv[0] is undefined) - ** then assume a default value of "now" for argv[0]. - */ - static int isDate( - sqlite3_context context, - int argc, - sqlite3_value[] argv, - ref DateTime p - ) - { - int i; - string z; - int eType; - p = new DateTime();//memset(p, 0, sizeof(*p)); - if ( argc == 0 ) - { - setDateTimeToCurrent( context, p ); - } - else if ( ( eType = sqlite3_value_type( argv[0] ) ) == SQLITE_FLOAT - || eType == SQLITE_INTEGER ) - { - p.iJD = (long)( sqlite3_value_double( argv[0] ) * 86400000.0 + 0.5 ); - p.validJD = 1; - } - else - { - z = sqlite3_value_text( argv[0] ); - if ( String.IsNullOrEmpty( z ) || parseDateOrTime( context, z, ref p ) != 0 ) - { - return 1; + return 0; } - } - for ( i = 1; i < argc; i++ ) - { - z = sqlite3_value_text( argv[i] ); - if ( String.IsNullOrEmpty( z ) || parseModifier( context, z, p ) != 0 ) - return 1; - } - return 0; - } - - - /* - ** The following routines implement the various date and time functions - ** of SQLite. - */ - - /* - ** julianday( TIMESTRING, MOD, MOD, ...) - ** - ** Return the julian day number of the date specified in the arguments - */ - static void juliandayFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - DateTime x = null; - if ( isDate( context, argc, argv, ref x ) == 0 ) - { - computeJD( x ); - sqlite3_result_double( context, x.iJD / 86400000.0 ); - } - } - - /* - ** datetime( TIMESTRING, MOD, MOD, ...) - ** - ** Return YYYY-MM-DD HH:MM:SS - */ - static void datetimeFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - DateTime x = null; - if ( isDate( context, argc, argv, ref x ) == 0 ) - { - zdtBuf.Length = 0; - computeYMD_HMS( x ); - sqlite3_snprintf( 100, zdtBuf, "%04d-%02d-%02d %02d:%02d:%02d", - x.Y, x.M, x.D, x.h, x.m, (int)( x.s ) ); - sqlite3_result_text( context, zdtBuf, -1, SQLITE_TRANSIENT ); - } - } - /* - ** time( TIMESTRING, MOD, MOD, ...) - ** - ** Return HH:MM:SS - */ - static void timeFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - DateTime x = new DateTime(); - if ( isDate( context, argc, argv, ref x ) == 0 ) - { - zdtBuf.Length = 0; - computeHMS( x ); - sqlite3_snprintf( 100, zdtBuf, "%02d:%02d:%02d", x.h, x.m, (int)x.s ); - sqlite3_result_text( context, zdtBuf, -1, SQLITE_TRANSIENT ); - } - } - /* - ** date( TIMESTRING, MOD, MOD, ...) - ** - ** Return YYYY-MM-DD - */ - static void dateFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - DateTime x = null; - if ( isDate( context, argc, argv, ref x ) == 0 ) - { - StringBuilder zdtBuf = new StringBuilder( 100 ); - computeYMD( x ); - sqlite3_snprintf( 100, zdtBuf, "%04d-%02d-%02d", x.Y, x.M, x.D ); - sqlite3_result_text( context, zdtBuf, -1, SQLITE_TRANSIENT ); - } - } + /* + ** The following routines implement the various date and time functions + ** of SQLite. + */ - /* - ** strftime( FORMAT, TIMESTRING, MOD, MOD, ...) - ** - ** Return a string described by FORMAT. Conversions as follows: - ** - ** %d day of month - ** %f ** fractional seconds SS.SSS - ** %H hour 00-24 - ** %j day of year 000-366 - ** %J ** Julian day number - ** %m month 01-12 - ** %M minute 00-59 - ** %s seconds since 1970-01-01 - ** %S seconds 00-59 - ** %w day of week 0-6 sunday==0 - ** %W week of year 00-53 - ** %Y year 0000-9999 - ** %% % - */ - static void strftimeFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - { - DateTime x = new DateTime(); - u64 n; - int i, j; - StringBuilder z; - sqlite3 db; - string zFmt = sqlite3_value_text( argv[0] ); - StringBuilder zdtBuf = new StringBuilder( 100 ); - sqlite3_value[] argv1 = new sqlite3_value[argc - 1]; - for ( i = 0; i < argc - 1; i++ ) - { - argv[i + 1].CopyTo( ref argv1[i] ); - } - if ( String.IsNullOrEmpty( zFmt ) || isDate( context, argc - 1, argv1, ref x ) != 0 ) - return; - db = sqlite3_context_db_handle( context ); - for ( i = 0, n = 1; i < zFmt.Length; i++, n++ ) - { - if ( zFmt[i] == '%' ) - { - switch ( (char)zFmt[i + 1] ) - { - case 'd': - case 'H': - case 'm': - case 'M': - case 'S': - case 'W': - n++; - break; - /* fall thru */ - case 'w': - case '%': - break; - case 'f': - n += 8; - break; - case 'j': - n += 3; - break; - case 'Y': - n += 8; - break; - case 's': - case 'J': - n += 50; - break; - default: - return; /* ERROR. return a NULL */ + /* + ** julianday( TIMESTRING, MOD, MOD, ...) + ** + ** Return the julian day number of the date specified in the arguments + */ + static void juliandayFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + DateTime x = null; + if (isDate(context, argc, argv, ref x) == 0) { + computeJD(x); + sqlite3_result_double(context, x.iJD / 86400000.0); } - i++; - } } - testcase( n == (u64)( zdtBuf.Length - 1 ) ); - testcase( n == (u64)zdtBuf.Length ); - testcase( n == (u64)db.aLimit[SQLITE_LIMIT_LENGTH] + 1 ); - testcase( n == (u64)db.aLimit[SQLITE_LIMIT_LENGTH] ); - if ( n < (u64)zdtBuf.Capacity ) - { - z = zdtBuf; + + /* + ** datetime( TIMESTRING, MOD, MOD, ...) + ** + ** Return YYYY-MM-DD HH:MM:SS + */ + static void datetimeFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + DateTime x = null; + if (isDate(context, argc, argv, ref x) == 0) { + zdtBuf.Length = 0; + computeYMD_HMS(x); + sqlite3_snprintf(100, zdtBuf, "%04d-%02d-%02d %02d:%02d:%02d", + x.Y, x.M, x.D, x.h, x.m, (int)(x.s)); + sqlite3_result_text(context, zdtBuf, -1, SQLITE_TRANSIENT); + } } - else if ( n > (u64)db.aLimit[SQLITE_LIMIT_LENGTH] ) - { - sqlite3_result_error_toobig( context ); - return; + + /* + ** time( TIMESTRING, MOD, MOD, ...) + ** + ** Return HH:MM:SS + */ + static void timeFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + DateTime x = new DateTime(); + if (isDate(context, argc, argv, ref x) == 0) { + zdtBuf.Length = 0; + computeHMS(x); + sqlite3_snprintf(100, zdtBuf, "%02d:%02d:%02d", x.h, x.m, (int)x.s); + sqlite3_result_text(context, zdtBuf, -1, SQLITE_TRANSIENT); + } } - else - { - z = new StringBuilder( (int)n );// sqlite3DbMallocRaw( db, n ); - //if ( z == 0 ) - //{ - // sqlite3_result_error_nomem( context ); - // return; - //} + + /* + ** date( TIMESTRING, MOD, MOD, ...) + ** + ** Return YYYY-MM-DD + */ + static void dateFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + DateTime x = null; + if (isDate(context, argc, argv, ref x) == 0) { + StringBuilder zdtBuf = new StringBuilder(100); + computeYMD(x); + sqlite3_snprintf(100, zdtBuf, "%04d-%02d-%02d", x.Y, x.M, x.D); + sqlite3_result_text(context, zdtBuf, -1, SQLITE_TRANSIENT); + } } - computeJD( x ); - computeYMD_HMS( x ); - for ( i = j = 0; i < zFmt.Length; i++ ) - { - if ( zFmt[i] != '%' ) - { - z.Append( (char)zFmt[i] ); - } - else - { - i++; - zdtTemp.Length = 0; - switch ( (char)zFmt[i] ) + + /* + ** strftime( FORMAT, TIMESTRING, MOD, MOD, ...) + ** + ** Return a string described by FORMAT. Conversions as follows: + ** + ** %d day of month + ** %f ** fractional seconds SS.SSS + ** %H hour 00-24 + ** %j day of year 000-366 + ** %J ** Julian day number + ** %m month 01-12 + ** %M minute 00-59 + ** %s seconds since 1970-01-01 + ** %S seconds 00-59 + ** %w day of week 0-6 sunday==0 + ** %W week of year 00-53 + ** %Y year 0000-9999 + ** %% % + */ + static void strftimeFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { { - case 'd': - sqlite3_snprintf( 3, zdtTemp, "%02d", x.D ); - z.Append( zdtTemp ); - j += 2; - break; - case 'f': - { - double s = x.s; - if ( s > 59.999 ) - s = 59.999; - sqlite3_snprintf( 7, zdtTemp, "%06.3f", s ); - z.Append( zdtTemp ); - j = sqlite3Strlen30( z ); - break; + DateTime x = new DateTime(); + u64 n; + int i, j; + StringBuilder z; + sqlite3 db; + string zFmt = sqlite3_value_text(argv[0]); + StringBuilder zdtBuf = new StringBuilder(100); + sqlite3_value[] argv1 = new sqlite3_value[argc - 1]; + for (i = 0; i < argc - 1; i++) { + argv[i + 1].CopyTo(ref argv1[i]); } - case 'H': - sqlite3_snprintf( 3, zdtTemp, "%02d", x.h ); - z.Append( zdtTemp ); - j += 2; - break; - case 'W': /* Fall thru */ - case 'j': - { - int nDay; /* Number of days since 1st day of year */ - DateTime y = new DateTime(); - x.CopyTo( y ); - y.validJD = 0; - y.M = 1; - y.D = 1; - computeJD( y ); - nDay = (int)( ( x.iJD - y.iJD + 43200000 ) / 86400000 ); - if ( zFmt[i] == 'W' ) - { - int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */ - wd = (int)( ( ( x.iJD + 43200000 ) / 86400000 ) % 7 ); - sqlite3_snprintf( 3, zdtTemp, "%02d", ( nDay + 7 - wd ) / 7 ); - z.Append( zdtTemp ); - j += 2; - } - else - { - sqlite3_snprintf( 4, zdtTemp, "%03d", nDay + 1 ); - z.Append( zdtTemp ); - j += 3; - } - break; + if (String.IsNullOrEmpty(zFmt) || isDate(context, argc - 1, argv1, ref x) != 0) + return; + db = sqlite3_context_db_handle(context); + for (i = 0, n = 1; i < zFmt.Length; i++, n++) { + if (zFmt[i] == '%') { + switch ((char)zFmt[i + 1]) { + case 'd': + case 'H': + case 'm': + case 'M': + case 'S': + case 'W': + n++; + break; + /* fall thru */ + case 'w': + case '%': + break; + case 'f': + n += 8; + break; + case 'j': + n += 3; + break; + case 'Y': + n += 8; + break; + case 's': + case 'J': + n += 50; + break; + default: + return; /* ERROR. return a NULL */ + } + i++; + } } - case 'J': - { - sqlite3_snprintf( 20, zdtTemp, "%.16g", x.iJD / 86400000.0 ); - z.Append( zdtTemp ); - j = sqlite3Strlen30( z ); - break; + testcase(n == (u64)(zdtBuf.Length - 1)); + testcase(n == (u64)zdtBuf.Length); + testcase(n == (u64)db.aLimit[SQLITE_LIMIT_LENGTH] + 1); + testcase(n == (u64)db.aLimit[SQLITE_LIMIT_LENGTH]); + if (n < (u64)zdtBuf.Capacity) { + z = zdtBuf; + } else if (n > (u64)db.aLimit[SQLITE_LIMIT_LENGTH]) { + sqlite3_result_error_toobig(context); + return; + } else { + z = new StringBuilder((int)n);// sqlite3DbMallocRaw( db, n ); + //if ( z == 0 ) + //{ + // sqlite3_result_error_nomem( context ); + // return; + //} } - case 'm': - sqlite3_snprintf( 3, zdtTemp, "%02d", x.M ); - z.Append( zdtTemp ); - j += 2; - break; - case 'M': - sqlite3_snprintf( 3, zdtTemp, "%02d", x.m ); - z.Append( zdtTemp ); - j += 2; - break; - case 's': - { - sqlite3_snprintf( 30, zdtTemp, "%lld", - (i64)( x.iJD / 1000 - 21086676 * (i64)10000 ) ); - z.Append( zdtTemp ); - j = sqlite3Strlen30( z ); - break; + computeJD(x); + computeYMD_HMS(x); + for (i = j = 0; i < zFmt.Length; i++) { + if (zFmt[i] != '%') { + z.Append((char)zFmt[i]); + } else { + i++; + zdtTemp.Length = 0; + switch ((char)zFmt[i]) { + case 'd': + sqlite3_snprintf(3, zdtTemp, "%02d", x.D); + z.Append(zdtTemp); + j += 2; + break; + case 'f': { + double s = x.s; + if (s > 59.999) + s = 59.999; + sqlite3_snprintf(7, zdtTemp, "%06.3f", s); + z.Append(zdtTemp); + j = sqlite3Strlen30(z); + break; + } + case 'H': + sqlite3_snprintf(3, zdtTemp, "%02d", x.h); + z.Append(zdtTemp); + j += 2; + break; + case 'W': /* Fall thru */ + case 'j': { + int nDay; /* Number of days since 1st day of year */ + DateTime y = new DateTime(); + x.CopyTo(y); + y.validJD = 0; + y.M = 1; + y.D = 1; + computeJD(y); + nDay = (int)((x.iJD - y.iJD + 43200000) / 86400000); + if (zFmt[i] == 'W') { + int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */ + wd = (int)(((x.iJD + 43200000) / 86400000) % 7); + sqlite3_snprintf(3, zdtTemp, "%02d", (nDay + 7 - wd) / 7); + z.Append(zdtTemp); + j += 2; + } else { + sqlite3_snprintf(4, zdtTemp, "%03d", nDay + 1); + z.Append(zdtTemp); + j += 3; + } + break; + } + case 'J': { + sqlite3_snprintf(20, zdtTemp, "%.16g", x.iJD / 86400000.0); + z.Append(zdtTemp); + j = sqlite3Strlen30(z); + break; + } + case 'm': + sqlite3_snprintf(3, zdtTemp, "%02d", x.M); + z.Append(zdtTemp); + j += 2; + break; + case 'M': + sqlite3_snprintf(3, zdtTemp, "%02d", x.m); + z.Append(zdtTemp); + j += 2; + break; + case 's': { + sqlite3_snprintf(30, zdtTemp, "%lld", + (i64)(x.iJD / 1000 - 21086676 * (i64)10000)); + z.Append(zdtTemp); + j = sqlite3Strlen30(z); + break; + } + case 'S': + sqlite3_snprintf(3, zdtTemp, "%02d", (int)x.s); + z.Append(zdtTemp); + j += 2; + break; + case 'w': { + z.Append((((x.iJD + 129600000) / 86400000) % 7)); + break; + } + case 'Y': { + sqlite3_snprintf(5, zdtTemp, "%04d", x.Y); + z.Append(zdtTemp); + j = sqlite3Strlen30(z); + break; + } + default: + z.Append('%'); + break; + } + } } - case 'S': - sqlite3_snprintf( 3, zdtTemp, "%02d", (int)x.s ); - z.Append( zdtTemp ); - j += 2; - break; - case 'w': - { - z.Append( ( ( ( x.iJD + 129600000 ) / 86400000 ) % 7 ) ); - break; - } - case 'Y': - { - sqlite3_snprintf( 5, zdtTemp, "%04d", x.Y ); - z.Append( zdtTemp ); - j = sqlite3Strlen30( z ); - break; - } - default: - z.Append( '%' ); - break; + //z[j] = 0; + sqlite3_result_text(context, z, -1, + z == zdtBuf ? SQLITE_TRANSIENT : SQLITE_DYNAMIC); } - } } - //z[j] = 0; - sqlite3_result_text( context, z, -1, - z == zdtBuf ? SQLITE_TRANSIENT : SQLITE_DYNAMIC ); - } - } - /* - ** current_time() - ** - ** This function returns the same value as time('now'). - */ - static void ctimeFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] NotUsed2 - ) - { - UNUSED_PARAMETER2( NotUsed, NotUsed2 ); - timeFunc( context, 0, null ); - } + /* + ** current_time() + ** + ** This function returns the same value as time('now'). + */ + static void ctimeFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] NotUsed2 + ) { + UNUSED_PARAMETER2(NotUsed, NotUsed2); + timeFunc(context, 0, null); + } - /* - ** current_date() - ** - ** This function returns the same value as date('now'). - */ - static void cdateFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] NotUsed2 - ) - { - UNUSED_PARAMETER2( NotUsed, NotUsed2 ); - dateFunc( context, 0, null ); - } + /* + ** current_date() + ** + ** This function returns the same value as date('now'). + */ + static void cdateFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] NotUsed2 + ) { + UNUSED_PARAMETER2(NotUsed, NotUsed2); + dateFunc(context, 0, null); + } - /* - ** current_timestamp() - ** - ** This function returns the same value as datetime('now'). - */ - static void ctimestampFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] NotUsed2 - ) - { - UNUSED_PARAMETER2( NotUsed, NotUsed2 ); - datetimeFunc( context, 0, null ); - } + /* + ** current_timestamp() + ** + ** This function returns the same value as datetime('now'). + */ + static void ctimestampFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] NotUsed2 + ) { + UNUSED_PARAMETER2(NotUsed, NotUsed2); + datetimeFunc(context, 0, null); + } #endif // * !SQLITE_OMIT_DATETIME_FUNCS) */ -#if SQLITE_OMIT_DATETIME_FUNCS +#if SQLITE_OMIT_DATETIME_FUNCS /* ** If the library is compiled to omit the full-scale date and time ** handling (to get a smaller binary), the following minimal version @@ -1370,14 +1224,13 @@ sqlite3_value[] NotUsed2 #endif - /* -** This function registered all of the above C functions as SQL -** functions. This should be the only routine in this file with -** external linkage. -*/ - static void sqlite3RegisterDateTimeFunctions() - { - FuncDef[] aDateTimeFuncs = new FuncDef[] { + /* + ** This function registered all of the above C functions as SQL + ** functions. This should be the only routine in this file with + ** external linkage. + */ + static void sqlite3RegisterDateTimeFunctions() { + FuncDef[] aDateTimeFuncs = new FuncDef[] { #if !SQLITE_OMIT_DATETIME_FUNCS FUNCTION("julianday", -1, 0, 0, (dxFunc)juliandayFunc ), FUNCTION("date", -1, 0, 0, (dxFunc)dateFunc ), @@ -1393,18 +1246,17 @@ static void sqlite3RegisterDateTimeFunctions() STR_FUNCTION("current_timestamp", 0, "%Y-%m-%d %H:%M:%S", 0, currentTimeFunc), #endif }; - int i; + int i; #if SQLITE_OMIT_WSD FuncDefHash pHash = GLOBAL( FuncDefHash, sqlite3GlobalFunctions ); FuncDef[] aFunc = (FuncDef)GLOBAL( FuncDef, aDateTimeFuncs ); #else - FuncDefHash pHash = sqlite3GlobalFunctions; - FuncDef[] aFunc = aDateTimeFuncs; + FuncDefHash pHash = sqlite3GlobalFunctions; + FuncDef[] aFunc = aDateTimeFuncs; #endif - for ( i = 0; i < ArraySize( aDateTimeFuncs ); i++ ) - { - sqlite3FuncDefInsert( pHash, aFunc[i] ); - } + for (i = 0; i < ArraySize(aDateTimeFuncs); i++) { + sqlite3FuncDefInsert(pHash, aFunc[i]); + } + } } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/delete_c.cs b/Src/IronPython.SQLite/c#sqlite/delete_c.cs index e291faa56..abf16d39d 100644 --- a/Src/IronPython.SQLite/c#sqlite/delete_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/delete_c.cs @@ -1,152 +1,139 @@ -using System; using System.Diagnostics; -using System.Text; -using u8 = System.Byte; using u32 = System.UInt32; -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 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. - ** - ************************************************************************* - ** This file contains C code routines that are called by the parser - ** in order to generate code for DELETE FROM statements. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - - /* - ** While a SrcList can in general represent multiple tables and subqueries - ** (as in the FROM clause of a SELECT statement) in this case it contains - ** the name of a single table, as one might find in an INSERT, DELETE, - ** or UPDATE statement. Look up that table in the symbol table and - ** return a pointer. Set an error message and return NULL if the table - ** name is not found or if any other error occurs. - ** - ** The following fields are initialized appropriate in pSrc: - ** - ** pSrc->a[0].pTab Pointer to the Table object - ** pSrc->a[0].pIndex Pointer to the INDEXED BY index, if there is one - ** - */ - static Table sqlite3SrcListLookup( Parse pParse, SrcList pSrc ) - { - SrcList_item pItem = pSrc.a[0]; - Table pTab; - Debug.Assert( pItem != null && pSrc.nSrc == 1 ); - pTab = sqlite3LocateTable( pParse, 0, pItem.zName, pItem.zDatabase ); - sqlite3DeleteTable( pParse.db, ref pItem.pTab ); - pItem.pTab = pTab; - if ( pTab != null ) - { - pTab.nRef++; - } - if ( sqlite3IndexedByLookup( pParse, pItem ) != 0 ) - { - pTab = null; - } - return pTab; - } +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** This file contains C code routines that are called by the parser + ** in order to generate code for DELETE FROM statements. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + + /* + ** While a SrcList can in general represent multiple tables and subqueries + ** (as in the FROM clause of a SELECT statement) in this case it contains + ** the name of a single table, as one might find in an INSERT, DELETE, + ** or UPDATE statement. Look up that table in the symbol table and + ** return a pointer. Set an error message and return NULL if the table + ** name is not found or if any other error occurs. + ** + ** The following fields are initialized appropriate in pSrc: + ** + ** pSrc->a[0].pTab Pointer to the Table object + ** pSrc->a[0].pIndex Pointer to the INDEXED BY index, if there is one + ** + */ + static Table sqlite3SrcListLookup(Parse pParse, SrcList pSrc) { + SrcList_item pItem = pSrc.a[0]; + Table pTab; + Debug.Assert(pItem != null && pSrc.nSrc == 1); + pTab = sqlite3LocateTable(pParse, 0, pItem.zName, pItem.zDatabase); + sqlite3DeleteTable(pParse.db, ref pItem.pTab); + pItem.pTab = pTab; + if (pTab != null) { + pTab.nRef++; + } + if (sqlite3IndexedByLookup(pParse, pItem) != 0) { + pTab = null; + } + return pTab; + } - /* - ** Check to make sure the given table is writable. If it is not - ** writable, generate an error message and return 1. If it is - ** writable return 0; - */ - static bool sqlite3IsReadOnly( Parse pParse, Table pTab, int viewOk ) - { - /* A table is not writable under the following circumstances: - ** - ** 1) It is a virtual table and no implementation of the xUpdate method - ** has been provided, or - ** 2) It is a system table (i.e. sqlite_master), this call is not - ** part of a nested parse and writable_schema pragma has not - ** been specified. - ** - ** In either case leave an error message in pParse and return non-zero. - */ - if ( - ( IsVirtual( pTab ) - && sqlite3GetVTable( pParse.db, pTab ).pMod.pModule.xUpdate == null ) - || ( ( pTab.tabFlags & TF_Readonly ) != 0 - && ( pParse.db.flags & SQLITE_WriteSchema ) == 0 - && pParse.nested == 0 ) - ) - { - sqlite3ErrorMsg( pParse, "table %s may not be modified", pTab.zName ); - return true; - } + /* + ** Check to make sure the given table is writable. If it is not + ** writable, generate an error message and return 1. If it is + ** writable return 0; + */ + static bool sqlite3IsReadOnly(Parse pParse, Table pTab, int viewOk) { + /* A table is not writable under the following circumstances: + ** + ** 1) It is a virtual table and no implementation of the xUpdate method + ** has been provided, or + ** 2) It is a system table (i.e. sqlite_master), this call is not + ** part of a nested parse and writable_schema pragma has not + ** been specified. + ** + ** In either case leave an error message in pParse and return non-zero. + */ + if ( + (IsVirtual(pTab) + && sqlite3GetVTable(pParse.db, pTab).pMod.pModule.xUpdate == null) + || ((pTab.tabFlags & TF_Readonly) != 0 + && (pParse.db.flags & SQLITE_WriteSchema) == 0 + && pParse.nested == 0) + ) { + sqlite3ErrorMsg(pParse, "table %s may not be modified", pTab.zName); + return true; + } #if !SQLITE_OMIT_VIEW - if ( viewOk == 0 && pTab.pSelect != null ) - { - sqlite3ErrorMsg( pParse, "cannot modify %s because it is a view", pTab.zName ); - return true; - } + if (viewOk == 0 && pTab.pSelect != null) { + sqlite3ErrorMsg(pParse, "cannot modify %s because it is a view", pTab.zName); + return true; + } #endif - return false; - } + return false; + } #if !SQLITE_OMIT_VIEW && !SQLITE_OMIT_TRIGGER - /* -** Evaluate a view and store its result in an ephemeral table. The -** pWhere argument is an optional WHERE clause that restricts the -** set of rows in the view that are to be added to the ephemeral table. -*/ - static void sqlite3MaterializeView( - Parse pParse, /* Parsing context */ - Table pView, /* View definition */ - Expr pWhere, /* Optional WHERE clause to be added */ - int iCur /* VdbeCursor number for ephemerial table */ - ) - { - SelectDest dest = new SelectDest(); - Select pDup; - sqlite3 db = pParse.db; - - pDup = sqlite3SelectDup( db, pView.pSelect, 0 ); - if ( pWhere != null ) - { - SrcList pFrom; - - pWhere = sqlite3ExprDup( db, pWhere, 0 ); - pFrom = sqlite3SrcListAppend( db, null, null, null ); - //if ( pFrom != null ) - //{ - Debug.Assert( pFrom.nSrc == 1 ); - pFrom.a[0].zAlias = pView.zName;// sqlite3DbStrDup( db, pView.zName ); - pFrom.a[0].pSelect = pDup; - Debug.Assert( pFrom.a[0].pOn == null ); - Debug.Assert( pFrom.a[0].pUsing == null ); - //} - //else - //{ - // sqlite3SelectDelete( db, ref pDup ); - //} - pDup = sqlite3SelectNew( pParse, null, pFrom, pWhere, null, null, null, 0, null, null ); - } - sqlite3SelectDestInit( dest, SRT_EphemTab, iCur ); - sqlite3Select( pParse, pDup, ref dest ); - sqlite3SelectDelete( db, ref pDup ); - } + /* + ** Evaluate a view and store its result in an ephemeral table. The + ** pWhere argument is an optional WHERE clause that restricts the + ** set of rows in the view that are to be added to the ephemeral table. + */ + static void sqlite3MaterializeView( + Parse pParse, /* Parsing context */ + Table pView, /* View definition */ + Expr pWhere, /* Optional WHERE clause to be added */ + int iCur /* VdbeCursor number for ephemerial table */ + ) { + SelectDest dest = new SelectDest(); + Select pDup; + sqlite3 db = pParse.db; + + pDup = sqlite3SelectDup(db, pView.pSelect, 0); + if (pWhere != null) { + SrcList pFrom; + + pWhere = sqlite3ExprDup(db, pWhere, 0); + pFrom = sqlite3SrcListAppend(db, null, null, null); + //if ( pFrom != null ) + //{ + Debug.Assert(pFrom.nSrc == 1); + pFrom.a[0].zAlias = pView.zName;// sqlite3DbStrDup( db, pView.zName ); + pFrom.a[0].pSelect = pDup; + Debug.Assert(pFrom.a[0].pOn == null); + Debug.Assert(pFrom.a[0].pUsing == null); + //} + //else + //{ + // sqlite3SelectDelete( db, ref pDup ); + //} + pDup = sqlite3SelectNew(pParse, null, pFrom, pWhere, null, null, null, 0, null, null); + } + sqlite3SelectDestInit(dest, SRT_EphemTab, iCur); + sqlite3Select(pParse, pDup, ref dest); + sqlite3SelectDelete(db, ref pDup); + } #endif //* !SQLITE_OMIT_VIEW) && !SQLITE_OMIT_TRIGGER) */ #if (SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !(SQLITE_OMIT_SUBQUERY) @@ -244,62 +231,60 @@ char zStmtType /* Either DELETE or UPDATE. For error messages. */ } #endif //* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) */ - /* -** Generate code for a DELETE FROM statement. -** -** DELETE FROM table_wxyz WHERE a<5 AND b NOT NULL; -** \________/ \________________/ -** pTabList pWhere -*/ - static void sqlite3DeleteFrom( - Parse pParse, /* The parser context */ - SrcList pTabList, /* The table from which we should delete things */ - Expr pWhere /* The WHERE clause. May be null */ - ) - { - Vdbe v; /* The virtual database engine */ - Table pTab; /* The table from which records will be deleted */ - int end, addr = 0; /* A couple addresses of generated code */ - int i; /* Loop counter */ - WhereInfo pWInfo; /* Information about the WHERE clause */ - Index pIdx; /* For looping over indices of the table */ - int iCur; /* VDBE VdbeCursor number for pTab */ - sqlite3 db; /* Main database structure */ - AuthContext sContext; /* Authorization context */ - NameContext sNC; /* Name context to resolve expressions in */ - int iDb; /* Database number */ - int memCnt = -1; /* Memory cell used for change counting */ - int rcauth; /* Value returned by authorization callback */ + /* + ** Generate code for a DELETE FROM statement. + ** + ** DELETE FROM table_wxyz WHERE a<5 AND b NOT NULL; + ** \________/ \________________/ + ** pTabList pWhere + */ + static void sqlite3DeleteFrom( + Parse pParse, /* The parser context */ + SrcList pTabList, /* The table from which we should delete things */ + Expr pWhere /* The WHERE clause. May be null */ + ) { + Vdbe v; /* The virtual database engine */ + Table pTab; /* The table from which records will be deleted */ + int end, addr = 0; /* A couple addresses of generated code */ + int i; /* Loop counter */ + WhereInfo pWInfo; /* Information about the WHERE clause */ + Index pIdx; /* For looping over indices of the table */ + int iCur; /* VDBE VdbeCursor number for pTab */ + sqlite3 db; /* Main database structure */ + AuthContext sContext; /* Authorization context */ + NameContext sNC; /* Name context to resolve expressions in */ + int iDb; /* Database number */ + int memCnt = -1; /* Memory cell used for change counting */ + int rcauth; /* Value returned by authorization callback */ #if !SQLITE_OMIT_TRIGGER - bool isView; /* True if attempting to delete from a view */ - Trigger pTrigger; /* List of table triggers, if required */ + bool isView; /* True if attempting to delete from a view */ + Trigger pTrigger; /* List of table triggers, if required */ #endif - sContext = new AuthContext();//memset(&sContext, 0, sizeof(sContext)); - - db = pParse.db; - if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) - { - goto delete_from_cleanup; - } - Debug.Assert( pTabList.nSrc == 1 ); - - /* Locate the table which we want to delete. This table has to be - ** put in an SrcList structure because some of the subroutines we - ** will be calling are designed to work with multiple tables and expect - ** an SrcList* parameter instead of just a Table* parameter. - */ - pTab = sqlite3SrcListLookup( pParse, pTabList ); - if ( pTab == null ) - goto delete_from_cleanup; - - /* Figure out if we have any triggers and if the table being - ** deleted from is a view - */ + sContext = new AuthContext();//memset(&sContext, 0, sizeof(sContext)); + + db = pParse.db; + if (pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) { + goto delete_from_cleanup; + } + Debug.Assert(pTabList.nSrc == 1); + + /* Locate the table which we want to delete. This table has to be + ** put in an SrcList structure because some of the subroutines we + ** will be calling are designed to work with multiple tables and expect + ** an SrcList* parameter instead of just a Table* parameter. + */ + pTab = sqlite3SrcListLookup(pParse, pTabList); + if (pTab == null) + goto delete_from_cleanup; + + /* Figure out if we have any triggers and if the table being + ** deleted from is a view + */ #if !SQLITE_OMIT_TRIGGER - int iDummy; - pTrigger = sqlite3TriggersExist( pParse, pTab, TK_DELETE, null, out iDummy ); - isView = pTab.pSelect != null; + int iDummy; + pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, null, out iDummy); + isView = pTab.pSelect != null; #else const Trigger pTrigger = null; bool isView = false; @@ -309,40 +294,36 @@ Expr pWhere /* The WHERE clause. May be null */ isView = false; #endif - /* If pTab is really a view, make sure it has been initialized. -*/ - if ( sqlite3ViewGetColumnNames( pParse, pTab ) != 0 ) - { - goto delete_from_cleanup; - } - - if ( sqlite3IsReadOnly( pParse, pTab, ( pTrigger != null ? 1 : 0 ) ) ) - { - goto delete_from_cleanup; - } - iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); - Debug.Assert( iDb < db.nDb ); + /* If pTab is really a view, make sure it has been initialized. + */ + if (sqlite3ViewGetColumnNames(pParse, pTab) != 0) { + goto delete_from_cleanup; + } + + if (sqlite3IsReadOnly(pParse, pTab, (pTrigger != null ? 1 : 0))) { + goto delete_from_cleanup; + } + iDb = sqlite3SchemaToIndex(db, pTab.pSchema); + Debug.Assert(iDb < db.nDb); #if !SQLITE_OMIT_AUTHORIZATION string zDb = db.aDb[iDb].zName; /* Name of database holding pTab */ rcauth = sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb); #else - rcauth = SQLITE_OK; + rcauth = SQLITE_OK; #endif - Debug.Assert( rcauth == SQLITE_OK || rcauth == SQLITE_DENY || rcauth == SQLITE_IGNORE ); - if ( rcauth == SQLITE_DENY ) - { - goto delete_from_cleanup; - } - Debug.Assert( !isView || pTrigger != null ); - - /* Assign cursor number to the table and all its indices. - */ - Debug.Assert( pTabList.nSrc == 1 ); - iCur = pTabList.a[0].iCursor = pParse.nTab++; - for ( pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext ) - { - pParse.nTab++; - } + Debug.Assert(rcauth == SQLITE_OK || rcauth == SQLITE_DENY || rcauth == SQLITE_IGNORE); + if (rcauth == SQLITE_DENY) { + goto delete_from_cleanup; + } + Debug.Assert(!isView || pTrigger != null); + + /* Assign cursor number to the table and all its indices. + */ + Debug.Assert(pTabList.nSrc == 1); + iCur = pTabList.a[0].iCursor = pParse.nTab++; + for (pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext) { + pParse.nTab++; + } #if !SQLITE_OMIT_AUTHORIZATION /* Start the view context @@ -351,396 +332,363 @@ Expr pWhere /* The WHERE clause. May be null */ sqlite3AuthContextPush(pParse, sContext, pTab.zName); } #endif - /* Begin generating code. -*/ - v = sqlite3GetVdbe( pParse ); - if ( v == null ) - { - goto delete_from_cleanup; - } - if ( pParse.nested == 0 ) - sqlite3VdbeCountChanges( v ); - sqlite3BeginWriteOperation( pParse, 1, iDb ); - - /* If we are trying to delete from a view, realize that view into - ** a ephemeral table. + /* Begin generating code. */ + v = sqlite3GetVdbe(pParse); + if (v == null) { + goto delete_from_cleanup; + } + if (pParse.nested == 0) + sqlite3VdbeCountChanges(v); + sqlite3BeginWriteOperation(pParse, 1, iDb); + + /* If we are trying to delete from a view, realize that view into + ** a ephemeral table. + */ #if !(SQLITE_OMIT_VIEW) && !(SQLITE_OMIT_TRIGGER) - if ( isView ) - { - sqlite3MaterializeView( pParse, pTab, pWhere, iCur ); - } + if (isView) { + sqlite3MaterializeView(pParse, pTab, pWhere, iCur); + } #endif - /* Resolve the column names in the WHERE clause. + /* Resolve the column names in the WHERE clause. + */ + sNC = new NameContext();// memset( &sNC, 0, sizeof( sNC ) ); + sNC.pParse = pParse; + sNC.pSrcList = pTabList; + if (sqlite3ResolveExprNames(sNC, ref pWhere) != 0) { + goto delete_from_cleanup; + } + + /* Initialize the counter of the number of rows deleted, if + ** we are counting rows. */ - sNC = new NameContext();// memset( &sNC, 0, sizeof( sNC ) ); - sNC.pParse = pParse; - sNC.pSrcList = pTabList; - if ( sqlite3ResolveExprNames( sNC, ref pWhere ) != 0 ) - { - goto delete_from_cleanup; - } - - /* Initialize the counter of the number of rows deleted, if -** we are counting rows. -*/ - if ( ( db.flags & SQLITE_CountRows ) != 0 ) - { - memCnt = ++pParse.nMem; - sqlite3VdbeAddOp2( v, OP_Integer, 0, memCnt ); - } + if ((db.flags & SQLITE_CountRows) != 0) { + memCnt = ++pParse.nMem; + sqlite3VdbeAddOp2(v, OP_Integer, 0, memCnt); + } #if !SQLITE_OMIT_TRUNCATE_OPTIMIZATION - /* Special case: A DELETE without a WHERE clause deletes everything. - ** It is easier just to erase the whole table. Prior to version 3.6.5, - ** this optimization caused the row change count (the value returned by - ** API function sqlite3_count_changes) to be set incorrectly. */ - if ( rcauth == SQLITE_OK && pWhere == null && null == pTrigger && !IsVirtual( pTab ) - && 0 == sqlite3FkRequired( pParse, pTab, null, 0 ) - ) - { - Debug.Assert( !isView ); - sqlite3VdbeAddOp4( v, OP_Clear, pTab.tnum, iDb, memCnt, - pTab.zName, P4_STATIC ); - for ( pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext ) - { - Debug.Assert( pIdx.pSchema == pTab.pSchema ); - sqlite3VdbeAddOp2( v, OP_Clear, pIdx.tnum, iDb ); - } - } - else + /* Special case: A DELETE without a WHERE clause deletes everything. + ** It is easier just to erase the whole table. Prior to version 3.6.5, + ** this optimization caused the row change count (the value returned by + ** API function sqlite3_count_changes) to be set incorrectly. */ + if (rcauth == SQLITE_OK && pWhere == null && null == pTrigger && !IsVirtual(pTab) + && 0 == sqlite3FkRequired(pParse, pTab, null, 0) + ) { + Debug.Assert(!isView); + sqlite3VdbeAddOp4(v, OP_Clear, pTab.tnum, iDb, memCnt, + pTab.zName, P4_STATIC); + for (pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext) { + Debug.Assert(pIdx.pSchema == pTab.pSchema); + sqlite3VdbeAddOp2(v, OP_Clear, pIdx.tnum, iDb); + } + } else #endif //* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */ - /* The usual case: There is a WHERE clause so we have to scan through -** the table and pick which records to delete. -*/ - { - int iRowSet = ++pParse.nMem; /* Register for rowset of rows to delete */ - int iRowid = ++pParse.nMem; /* Used for storing rowid values. */ - int regRowid; /* Actual register containing rowids */ - - /* Collect rowids of every row to be deleted. + /* The usual case: There is a WHERE clause so we have to scan through + ** the table and pick which records to delete. */ - sqlite3VdbeAddOp2( v, OP_Null, 0, iRowSet ); - ExprList elDummy = null; - pWInfo = sqlite3WhereBegin( pParse, pTabList, pWhere, ref elDummy, WHERE_DUPLICATES_OK ); - if ( pWInfo == null ) - goto delete_from_cleanup; - regRowid = sqlite3ExprCodeGetColumn( pParse, pTab, -1, iCur, iRowid ); - sqlite3VdbeAddOp2( v, OP_RowSetAdd, iRowSet, regRowid ); - if ( ( db.flags & SQLITE_CountRows ) != 0 ) - { - sqlite3VdbeAddOp2( v, OP_AddImm, memCnt, 1 ); - } - - sqlite3WhereEnd( pWInfo ); - - /* Delete every item whose key was written to the list during the - ** database scan. We have to delete items after the scan is complete - ** because deleting an item can change the scan order. */ - end = sqlite3VdbeMakeLabel( v ); - - /* Unless this is a view, open cursors for the table we are - ** deleting from and all its indices. If this is a view, then the - ** only effect this statement has is to fire the INSTEAD OF - ** triggers. */ - if ( !isView ) - { - sqlite3OpenTableAndIndices( pParse, pTab, iCur, OP_OpenWrite ); - } - - addr = sqlite3VdbeAddOp3( v, OP_RowSetRead, iRowSet, end, iRowid ); - - /* Delete the row */ + { + int iRowSet = ++pParse.nMem; /* Register for rowset of rows to delete */ + int iRowid = ++pParse.nMem; /* Used for storing rowid values. */ + int regRowid; /* Actual register containing rowids */ + + /* Collect rowids of every row to be deleted. + */ + sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet); + ExprList elDummy = null; + pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, ref elDummy, WHERE_DUPLICATES_OK); + if (pWInfo == null) + goto delete_from_cleanup; + regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid); + sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, regRowid); + if ((db.flags & SQLITE_CountRows) != 0) { + sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1); + } + + sqlite3WhereEnd(pWInfo); + + /* Delete every item whose key was written to the list during the + ** database scan. We have to delete items after the scan is complete + ** because deleting an item can change the scan order. */ + end = sqlite3VdbeMakeLabel(v); + + /* Unless this is a view, open cursors for the table we are + ** deleting from and all its indices. If this is a view, then the + ** only effect this statement has is to fire the INSTEAD OF + ** triggers. */ + if (!isView) { + sqlite3OpenTableAndIndices(pParse, pTab, iCur, OP_OpenWrite); + } + + addr = sqlite3VdbeAddOp3(v, OP_RowSetRead, iRowSet, end, iRowid); + + /* Delete the row */ #if !SQLITE_OMIT_VIRTUALTABLE - if ( IsVirtual( pTab ) ) - { - VTable pVTab = sqlite3GetVTable( db, pTab ); - sqlite3VtabMakeWritable( pParse, pTab ); - sqlite3VdbeAddOp4( v, OP_VUpdate, 0, 1, iRowid, pVTab, P4_VTAB ); - sqlite3VdbeChangeP5( v, OE_Abort ); - sqlite3MayAbort( pParse ); - } - else + if (IsVirtual(pTab)) { + VTable pVTab = sqlite3GetVTable(db, pTab); + sqlite3VtabMakeWritable(pParse, pTab); + sqlite3VdbeAddOp4(v, OP_VUpdate, 0, 1, iRowid, pVTab, P4_VTAB); + sqlite3VdbeChangeP5(v, OE_Abort); + sqlite3MayAbort(pParse); + } else #endif - { - int count = ( pParse.nested == 0 ) ? 1 : 0; /* True to count changes */ - sqlite3GenerateRowDelete( pParse, pTab, iCur, iRowid, count, pTrigger, OE_Default ); - } - - /* End of the delete loop */ - sqlite3VdbeAddOp2( v, OP_Goto, 0, addr ); - sqlite3VdbeResolveLabel( v, end ); - - /* Close the cursors open on the table and its indexes. */ - if ( !isView && !IsVirtual( pTab ) ) - { - for ( i = 1, pIdx = pTab.pIndex; pIdx != null; i++, pIdx = pIdx.pNext ) - { - sqlite3VdbeAddOp2( v, OP_Close, iCur + i, pIdx.tnum ); - } - sqlite3VdbeAddOp1( v, OP_Close, iCur ); - } - } - - /* Update the sqlite_sequence table by storing the content of the - ** maximum rowid counter values recorded while inserting into - ** autoincrement tables. - */ - if ( pParse.nested == 0 && pParse.pTriggerTab == null ) - { - sqlite3AutoincrementEnd( pParse ); - } - - /* Return the number of rows that were deleted. If this routine is - ** generating code because of a call to sqlite3NestedParse(), do not - ** invoke the callback function. - */ - - if ( ( db.flags & SQLITE_CountRows ) != 0 && 0 == pParse.nested && null == pParse.pTriggerTab ) - { - sqlite3VdbeAddOp2( v, OP_ResultRow, memCnt, 1 ); - sqlite3VdbeSetNumCols( v, 1 ); - sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "rows deleted", SQLITE_STATIC ); - } - -delete_from_cleanup: + { + int count = (pParse.nested == 0) ? 1 : 0; /* True to count changes */ + sqlite3GenerateRowDelete(pParse, pTab, iCur, iRowid, count, pTrigger, OE_Default); + } + + /* End of the delete loop */ + sqlite3VdbeAddOp2(v, OP_Goto, 0, addr); + sqlite3VdbeResolveLabel(v, end); + + /* Close the cursors open on the table and its indexes. */ + if (!isView && !IsVirtual(pTab)) { + for (i = 1, pIdx = pTab.pIndex; pIdx != null; i++, pIdx = pIdx.pNext) { + sqlite3VdbeAddOp2(v, OP_Close, iCur + i, pIdx.tnum); + } + sqlite3VdbeAddOp1(v, OP_Close, iCur); + } + } + + /* Update the sqlite_sequence table by storing the content of the + ** maximum rowid counter values recorded while inserting into + ** autoincrement tables. + */ + if (pParse.nested == 0 && pParse.pTriggerTab == null) { + sqlite3AutoincrementEnd(pParse); + } + + /* Return the number of rows that were deleted. If this routine is + ** generating code because of a call to sqlite3NestedParse(), do not + ** invoke the callback function. + */ + + if ((db.flags & SQLITE_CountRows) != 0 && 0 == pParse.nested && null == pParse.pTriggerTab) { + sqlite3VdbeAddOp2(v, OP_ResultRow, memCnt, 1); + sqlite3VdbeSetNumCols(v, 1); + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows deleted", SQLITE_STATIC); + } + + delete_from_cleanup: #if !SQLITE_OMIT_AUTHORIZATION sqlite3AuthContextPop(sContext); #endif - sqlite3SrcListDelete( db, ref pTabList ); - sqlite3ExprDelete( db, ref pWhere ); - return; - } - - /* Make sure "isView" and other macros defined above are undefined. Otherwise - ** thely may interfere with compilation of other functions in this file - ** (or in another file, if this file becomes part of the amalgamation). */ - //#if isView - // #undef isView - //#endif - //#if pTrigger - // #undef pTrigger - //#endif - - /* - ** This routine generates VDBE code that causes a single row of a - ** single table to be deleted. - ** - ** The VDBE must be in a particular state when this routine is called. - ** These are the requirements: - ** - ** 1. A read/write cursor pointing to pTab, the table containing the row - ** to be deleted, must be opened as cursor number $iCur. - ** - ** 2. Read/write cursors for all indices of pTab must be open as - ** cursor number base+i for the i-th index. - ** - ** 3. The record number of the row to be deleted must be stored in - ** memory cell iRowid. - ** - ** This routine generates code to remove both the table record and all - ** index entries that point to that record. - */ - static void sqlite3GenerateRowDelete( - Parse pParse, /* Parsing context */ - Table pTab, /* Table containing the row to be deleted */ - int iCur, /* VdbeCursor number for the table */ - int iRowid, /* Memory cell that contains the rowid to delete */ - int count, /* If non-zero, increment the row change counter */ - Trigger pTrigger, /* List of triggers to (potentially) fire */ - int onconf /* Default ON CONFLICT policy for triggers */ -) - { - Vdbe v = pParse.pVdbe; /* Vdbe */ - int iOld = 0; /* First register in OLD.* array */ - int iLabel; /* Label resolved to end of generated code */ - - /* Vdbe is guaranteed to have been allocated by this stage. */ - Debug.Assert( v != null ); - - /* Seek cursor iCur to the row to delete. If this row no longer exists - ** (this can happen if a trigger program has already deleted it), do - ** not attempt to delete it or fire any DELETE triggers. */ - iLabel = sqlite3VdbeMakeLabel( v ); - sqlite3VdbeAddOp3( v, OP_NotExists, iCur, iLabel, iRowid ); - - /* If there are any triggers to fire, allocate a range of registers to - ** use for the old.* references in the triggers. */ - if ( sqlite3FkRequired( pParse, pTab, null, 0 ) != 0 || pTrigger != null ) - { - u32 mask; /* Mask of OLD.* columns in use */ - int iCol; /* Iterator used while populating OLD.* */ - - /* TODO: Could use temporary registers here. Also could attempt to - ** avoid copying the contents of the rowid register. */ - mask = sqlite3TriggerColmask( - pParse, pTrigger, null, 0, TRIGGER_BEFORE | TRIGGER_AFTER, pTab, onconf - ); - mask |= sqlite3FkOldmask( pParse, pTab ); - iOld = pParse.nMem + 1; - pParse.nMem += ( 1 + pTab.nCol ); - - /* Populate the OLD.* pseudo-table register array. These values will be - ** used by any BEFORE and AFTER triggers that exist. */ - sqlite3VdbeAddOp2( v, OP_Copy, iRowid, iOld ); - for ( iCol = 0; iCol < pTab.nCol; iCol++ ) - { - if ( mask == 0xffffffff || ( mask & ( 1 << iCol ) ) != 0 ) - { - sqlite3ExprCodeGetColumnOfTable( v, pTab, iCur, iCol, iOld + iCol + 1 ); - } + sqlite3SrcListDelete(db, ref pTabList); + sqlite3ExprDelete(db, ref pWhere); + return; } - /* Invoke BEFORE DELETE trigger programs. */ - sqlite3CodeRowTrigger( pParse, pTrigger, - TK_DELETE, null, TRIGGER_BEFORE, pTab, iOld, onconf, iLabel - ); - - /* Seek the cursor to the row to be deleted again. It may be that - ** the BEFORE triggers coded above have already removed the row - ** being deleted. Do not attempt to delete the row a second time, and - ** do not fire AFTER triggers. */ - sqlite3VdbeAddOp3( v, OP_NotExists, iCur, iLabel, iRowid ); - - /* Do FK processing. This call checks that any FK constraints that - ** refer to this table (i.e. constraints attached to other tables) - ** are not violated by deleting this row. */ - sqlite3FkCheck( pParse, pTab, iOld, 0 ); - } - - /* Delete the index and table entries. Skip this step if pTab is really - ** a view (in which case the only effect of the DELETE statement is to - ** fire the INSTEAD OF triggers). */ - if ( pTab.pSelect == null ) - { - sqlite3GenerateRowIndexDelete( pParse, pTab, iCur, 0 ); - sqlite3VdbeAddOp2( v, OP_Delete, iCur, ( count != 0 ? (int)OPFLAG_NCHANGE : 0 ) ); - if ( count != 0 ) - { - sqlite3VdbeChangeP4( v, -1, pTab.zName, P4_TRANSIENT ); + /* Make sure "isView" and other macros defined above are undefined. Otherwise + ** thely may interfere with compilation of other functions in this file + ** (or in another file, if this file becomes part of the amalgamation). */ + //#if isView + // #undef isView + //#endif + //#if pTrigger + // #undef pTrigger + //#endif + + /* + ** This routine generates VDBE code that causes a single row of a + ** single table to be deleted. + ** + ** The VDBE must be in a particular state when this routine is called. + ** These are the requirements: + ** + ** 1. A read/write cursor pointing to pTab, the table containing the row + ** to be deleted, must be opened as cursor number $iCur. + ** + ** 2. Read/write cursors for all indices of pTab must be open as + ** cursor number base+i for the i-th index. + ** + ** 3. The record number of the row to be deleted must be stored in + ** memory cell iRowid. + ** + ** This routine generates code to remove both the table record and all + ** index entries that point to that record. + */ + static void sqlite3GenerateRowDelete( + Parse pParse, /* Parsing context */ + Table pTab, /* Table containing the row to be deleted */ + int iCur, /* VdbeCursor number for the table */ + int iRowid, /* Memory cell that contains the rowid to delete */ + int count, /* If non-zero, increment the row change counter */ + Trigger pTrigger, /* List of triggers to (potentially) fire */ + int onconf /* Default ON CONFLICT policy for triggers */ + ) { + Vdbe v = pParse.pVdbe; /* Vdbe */ + int iOld = 0; /* First register in OLD.* array */ + int iLabel; /* Label resolved to end of generated code */ + + /* Vdbe is guaranteed to have been allocated by this stage. */ + Debug.Assert(v != null); + + /* Seek cursor iCur to the row to delete. If this row no longer exists + ** (this can happen if a trigger program has already deleted it), do + ** not attempt to delete it or fire any DELETE triggers. */ + iLabel = sqlite3VdbeMakeLabel(v); + sqlite3VdbeAddOp3(v, OP_NotExists, iCur, iLabel, iRowid); + + /* If there are any triggers to fire, allocate a range of registers to + ** use for the old.* references in the triggers. */ + if (sqlite3FkRequired(pParse, pTab, null, 0) != 0 || pTrigger != null) { + u32 mask; /* Mask of OLD.* columns in use */ + int iCol; /* Iterator used while populating OLD.* */ + + /* TODO: Could use temporary registers here. Also could attempt to + ** avoid copying the contents of the rowid register. */ + mask = sqlite3TriggerColmask( + pParse, pTrigger, null, 0, TRIGGER_BEFORE | TRIGGER_AFTER, pTab, onconf + ); + mask |= sqlite3FkOldmask(pParse, pTab); + iOld = pParse.nMem + 1; + pParse.nMem += (1 + pTab.nCol); + + /* Populate the OLD.* pseudo-table register array. These values will be + ** used by any BEFORE and AFTER triggers that exist. */ + sqlite3VdbeAddOp2(v, OP_Copy, iRowid, iOld); + for (iCol = 0; iCol < pTab.nCol; iCol++) { + if (mask == 0xffffffff || (mask & (1 << iCol)) != 0) { + sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, iCol, iOld + iCol + 1); + } + } + + /* Invoke BEFORE DELETE trigger programs. */ + sqlite3CodeRowTrigger(pParse, pTrigger, + TK_DELETE, null, TRIGGER_BEFORE, pTab, iOld, onconf, iLabel + ); + + /* Seek the cursor to the row to be deleted again. It may be that + ** the BEFORE triggers coded above have already removed the row + ** being deleted. Do not attempt to delete the row a second time, and + ** do not fire AFTER triggers. */ + sqlite3VdbeAddOp3(v, OP_NotExists, iCur, iLabel, iRowid); + + /* Do FK processing. This call checks that any FK constraints that + ** refer to this table (i.e. constraints attached to other tables) + ** are not violated by deleting this row. */ + sqlite3FkCheck(pParse, pTab, iOld, 0); + } + + /* Delete the index and table entries. Skip this step if pTab is really + ** a view (in which case the only effect of the DELETE statement is to + ** fire the INSTEAD OF triggers). */ + if (pTab.pSelect == null) { + sqlite3GenerateRowIndexDelete(pParse, pTab, iCur, 0); + sqlite3VdbeAddOp2(v, OP_Delete, iCur, (count != 0 ? (int)OPFLAG_NCHANGE : 0)); + if (count != 0) { + sqlite3VdbeChangeP4(v, -1, pTab.zName, P4_TRANSIENT); + } + } + + /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to + ** handle rows (possibly in other tables) that refer via a foreign key + ** to the row just deleted. */ + sqlite3FkActions(pParse, pTab, null, iOld); + + /* Invoke AFTER DELETE trigger programs. */ + sqlite3CodeRowTrigger(pParse, pTrigger, + TK_DELETE, null, TRIGGER_AFTER, pTab, iOld, onconf, iLabel + ); + + /* Jump here if the row had already been deleted before any BEFORE + ** trigger programs were invoked. Or if a trigger program throws a + ** RAISE(IGNORE) exception. */ + sqlite3VdbeResolveLabel(v, iLabel); } - } - - /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to - ** handle rows (possibly in other tables) that refer via a foreign key - ** to the row just deleted. */ - sqlite3FkActions( pParse, pTab, null, iOld ); - - /* Invoke AFTER DELETE trigger programs. */ - sqlite3CodeRowTrigger( pParse, pTrigger, - TK_DELETE, null, TRIGGER_AFTER, pTab, iOld, onconf, iLabel - ); - - /* Jump here if the row had already been deleted before any BEFORE - ** trigger programs were invoked. Or if a trigger program throws a - ** RAISE(IGNORE) exception. */ - sqlite3VdbeResolveLabel( v, iLabel ); - } - /* - ** This routine generates VDBE code that causes the deletion of all - ** index entries associated with a single row of a single table. - ** - ** The VDBE must be in a particular state when this routine is called. - ** These are the requirements: - ** - ** 1. A read/write cursor pointing to pTab, the table containing the row - ** to be deleted, must be opened as cursor number "iCur". - ** - ** 2. Read/write cursors for all indices of pTab must be open as - ** cursor number iCur+i for the i-th index. - ** - ** 3. The "iCur" cursor must be pointing to the row that is to be - ** deleted. - */ - static void sqlite3GenerateRowIndexDelete( - Parse pParse, /* Parsing and code generating context */ - Table pTab, /* Table containing the row to be deleted */ - int iCur, /* VdbeCursor number for the table */ - int nothing /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */ - ) - { - int[] aRegIdx = null; - sqlite3GenerateRowIndexDelete( pParse, pTab, iCur, aRegIdx ); - } - static void sqlite3GenerateRowIndexDelete( - Parse pParse, /* Parsing and code generating context */ - Table pTab, /* Table containing the row to be deleted */ - int iCur, /* VdbeCursor number for the table */ - int[] aRegIdx /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */ - ) - { - int i; - Index pIdx; - int r1; - - for ( i = 1, pIdx = pTab.pIndex; pIdx != null; i++, pIdx = pIdx.pNext ) - { - if ( aRegIdx != null && aRegIdx[i - 1] == 0 ) - continue; - r1 = sqlite3GenerateIndexKey( pParse, pIdx, iCur, 0, false ); - sqlite3VdbeAddOp3( pParse.pVdbe, OP_IdxDelete, iCur + i, r1, pIdx.nColumn + 1 ); - } - } - - /* - ** Generate code that will assemble an index key and put it in register - ** regOut. The key with be for index pIdx which is an index on pTab. - ** iCur is the index of a cursor open on the pTab table and pointing to - ** the entry that needs indexing. - ** - ** Return a register number which is the first in a block of - ** registers that holds the elements of the index key. The - ** block of registers has already been deallocated by the time - ** this routine returns. - */ - static int sqlite3GenerateIndexKey( - Parse pParse, /* Parsing context */ - Index pIdx, /* The index for which to generate a key */ - int iCur, /* VdbeCursor number for the pIdx.pTable table */ - int regOut, /* Write the new index key to this register */ - bool doMakeRec /* Run the OP_MakeRecord instruction if true */ - ) - { - Vdbe v = pParse.pVdbe; - int j; - Table pTab = pIdx.pTable; - int regBase; - int nCol; - - nCol = pIdx.nColumn; - regBase = sqlite3GetTempRange( pParse, nCol + 1 ); - sqlite3VdbeAddOp2( v, OP_Rowid, iCur, regBase + nCol ); - for ( j = 0; j < nCol; j++ ) - { - int idx = pIdx.aiColumn[j]; - if ( idx == pTab.iPKey ) - { - sqlite3VdbeAddOp2( v, OP_SCopy, regBase + nCol, regBase + j ); - } - else - { - sqlite3VdbeAddOp3( v, OP_Column, iCur, idx, regBase + j ); - sqlite3ColumnDefault( v, pTab, idx, -1 ); + /* + ** This routine generates VDBE code that causes the deletion of all + ** index entries associated with a single row of a single table. + ** + ** The VDBE must be in a particular state when this routine is called. + ** These are the requirements: + ** + ** 1. A read/write cursor pointing to pTab, the table containing the row + ** to be deleted, must be opened as cursor number "iCur". + ** + ** 2. Read/write cursors for all indices of pTab must be open as + ** cursor number iCur+i for the i-th index. + ** + ** 3. The "iCur" cursor must be pointing to the row that is to be + ** deleted. + */ + static void sqlite3GenerateRowIndexDelete( + Parse pParse, /* Parsing and code generating context */ + Table pTab, /* Table containing the row to be deleted */ + int iCur, /* VdbeCursor number for the table */ + int nothing /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */ + ) { + int[] aRegIdx = null; + sqlite3GenerateRowIndexDelete(pParse, pTab, iCur, aRegIdx); } - } - if ( doMakeRec ) - { - string zAff; - if ( pTab.pSelect != null|| ( pParse.db.flags & SQLITE_IdxRealAsInt ) != 0 ) - { - zAff = ""; + static void sqlite3GenerateRowIndexDelete( + Parse pParse, /* Parsing and code generating context */ + Table pTab, /* Table containing the row to be deleted */ + int iCur, /* VdbeCursor number for the table */ + int[] aRegIdx /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */ + ) { + int i; + Index pIdx; + int r1; + + for (i = 1, pIdx = pTab.pIndex; pIdx != null; i++, pIdx = pIdx.pNext) { + if (aRegIdx != null && aRegIdx[i - 1] == 0) + continue; + r1 = sqlite3GenerateIndexKey(pParse, pIdx, iCur, 0, false); + sqlite3VdbeAddOp3(pParse.pVdbe, OP_IdxDelete, iCur + i, r1, pIdx.nColumn + 1); + } } - else - { - zAff = sqlite3IndexAffinityStr( v, pIdx ); + + /* + ** Generate code that will assemble an index key and put it in register + ** regOut. The key with be for index pIdx which is an index on pTab. + ** iCur is the index of a cursor open on the pTab table and pointing to + ** the entry that needs indexing. + ** + ** Return a register number which is the first in a block of + ** registers that holds the elements of the index key. The + ** block of registers has already been deallocated by the time + ** this routine returns. + */ + static int sqlite3GenerateIndexKey( + Parse pParse, /* Parsing context */ + Index pIdx, /* The index for which to generate a key */ + int iCur, /* VdbeCursor number for the pIdx.pTable table */ + int regOut, /* Write the new index key to this register */ + bool doMakeRec /* Run the OP_MakeRecord instruction if true */ + ) { + Vdbe v = pParse.pVdbe; + int j; + Table pTab = pIdx.pTable; + int regBase; + int nCol; + + nCol = pIdx.nColumn; + regBase = sqlite3GetTempRange(pParse, nCol + 1); + sqlite3VdbeAddOp2(v, OP_Rowid, iCur, regBase + nCol); + for (j = 0; j < nCol; j++) { + int idx = pIdx.aiColumn[j]; + if (idx == pTab.iPKey) { + sqlite3VdbeAddOp2(v, OP_SCopy, regBase + nCol, regBase + j); + } else { + sqlite3VdbeAddOp3(v, OP_Column, iCur, idx, regBase + j); + sqlite3ColumnDefault(v, pTab, idx, -1); + } + } + if (doMakeRec) { + string zAff; + if (pTab.pSelect != null || (pParse.db.flags & SQLITE_IdxRealAsInt) != 0) { + zAff = ""; + } else { + zAff = sqlite3IndexAffinityStr(v, pIdx); + } + sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol + 1, regOut); + sqlite3VdbeChangeP4(v, -1, zAff, P4_TRANSIENT); + } + sqlite3ReleaseTempRange(pParse, regBase, nCol + 1); + return regBase; } - sqlite3VdbeAddOp3( v, OP_MakeRecord, regBase, nCol + 1, regOut ); - sqlite3VdbeChangeP4( v, -1, zAff, P4_TRANSIENT ); - } - sqlite3ReleaseTempRange( pParse, regBase, nCol + 1 ); - return regBase; } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/expr_c.cs b/Src/IronPython.SQLite/c#sqlite/expr_c.cs index c90409775..a8dcd7921 100644 --- a/Src/IronPython.SQLite/c#sqlite/expr_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/expr_c.cs @@ -2,1209 +2,1061 @@ using System; using System.Diagnostics; -using System.Text; -using Bitmask = System.UInt64; using i64 = System.Int64; using u8 = System.Byte; using u32 = System.UInt32; using u16 = System.UInt16; -using Pgno = System.UInt32; - #if !SQLITE_MAX_VARIABLE_NUMBER using ynVar = System.Int16; #else using ynVar = System.Int32; #endif -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 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. - ** - ************************************************************************* - ** This file contains routines used for analyzing expressions and - ** for generating VDBE code that evaluates expressions in SQLite. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** This file contains routines used for analyzing expressions and + ** for generating VDBE code that evaluates expressions in SQLite. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" - /* - ** Return the 'affinity' of the expression pExpr if any. - ** - ** If pExpr is a column, a reference to a column via an 'AS' alias, - ** or a sub-select with a column as the return value, then the - ** affinity of that column is returned. Otherwise, 0x00 is returned, - ** indicating no affinity for the expression. - ** - ** i.e. the WHERE clause expresssions in the following statements all - ** have an affinity: - ** - ** CREATE TABLE t1(a); - ** SELECT * FROM t1 WHERE a; - ** SELECT a AS b FROM t1 WHERE b; - ** SELECT * FROM t1 WHERE (select a from t1); - */ - static char sqlite3ExprAffinity( Expr pExpr ) - { - int op = pExpr.op; - if ( op == TK_SELECT ) - { - Debug.Assert( ( pExpr.flags & EP_xIsSelect ) != 0 ); - return sqlite3ExprAffinity( pExpr.x.pSelect.pEList.a[0].pExpr ); - } + /* + ** Return the 'affinity' of the expression pExpr if any. + ** + ** If pExpr is a column, a reference to a column via an 'AS' alias, + ** or a sub-select with a column as the return value, then the + ** affinity of that column is returned. Otherwise, 0x00 is returned, + ** indicating no affinity for the expression. + ** + ** i.e. the WHERE clause expresssions in the following statements all + ** have an affinity: + ** + ** CREATE TABLE t1(a); + ** SELECT * FROM t1 WHERE a; + ** SELECT a AS b FROM t1 WHERE b; + ** SELECT * FROM t1 WHERE (select a from t1); + */ + static char sqlite3ExprAffinity(Expr pExpr) { + int op = pExpr.op; + if (op == TK_SELECT) { + Debug.Assert((pExpr.flags & EP_xIsSelect) != 0); + return sqlite3ExprAffinity(pExpr.x.pSelect.pEList.a[0].pExpr); + } #if !SQLITE_OMIT_CAST - if ( op == TK_CAST ) - { - Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); - return sqlite3AffinityType( pExpr.u.zToken ); - } + if (op == TK_CAST) { + Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); + return sqlite3AffinityType(pExpr.u.zToken); + } #endif - if ( ( op == TK_AGG_COLUMN || op == TK_COLUMN || op == TK_REGISTER ) - && pExpr.pTab != null - ) - { - /* op==TK_REGISTER && pExpr.pTab!=0 happens when pExpr was originally - ** a TK_COLUMN but was previously evaluated and cached in a register */ - int j = pExpr.iColumn; - if ( j < 0 ) - return SQLITE_AFF_INTEGER; - Debug.Assert( pExpr.pTab != null && j < pExpr.pTab.nCol ); - return pExpr.pTab.aCol[j].affinity; - } - return pExpr.affinity; - } - - /* - ** Set the explicit collating sequence for an expression to the - ** collating sequence supplied in the second argument. - */ - static Expr sqlite3ExprSetColl( Expr pExpr, CollSeq pColl ) - { - if ( pExpr != null && pColl != null ) - { - pExpr.pColl = pColl; - pExpr.flags |= EP_ExpCollate; - } - return pExpr; - } + if ((op == TK_AGG_COLUMN || op == TK_COLUMN || op == TK_REGISTER) + && pExpr.pTab != null + ) { + /* op==TK_REGISTER && pExpr.pTab!=0 happens when pExpr was originally + ** a TK_COLUMN but was previously evaluated and cached in a register */ + int j = pExpr.iColumn; + if (j < 0) + return SQLITE_AFF_INTEGER; + Debug.Assert(pExpr.pTab != null && j < pExpr.pTab.nCol); + return pExpr.pTab.aCol[j].affinity; + } + return pExpr.affinity; + } - /* - ** Set the collating sequence for expression pExpr to be the collating - ** sequence named by pToken. Return a pointer to the revised expression. - ** The collating sequence is marked as "explicit" using the EP_ExpCollate - ** flag. An explicit collating sequence will override implicit - ** collating sequences. - */ - static Expr sqlite3ExprSetCollByToken( Parse pParse, Expr pExpr, Token pCollName ) - { - string zColl; /* Dequoted name of collation sequence */ - CollSeq pColl; - sqlite3 db = pParse.db; - zColl = sqlite3NameFromToken( db, pCollName ); - pColl = sqlite3LocateCollSeq( pParse, zColl ); - sqlite3ExprSetColl( pExpr, pColl ); - sqlite3DbFree( db, ref zColl ); - return pExpr; - } + /* + ** Set the explicit collating sequence for an expression to the + ** collating sequence supplied in the second argument. + */ + static Expr sqlite3ExprSetColl(Expr pExpr, CollSeq pColl) { + if (pExpr != null && pColl != null) { + pExpr.pColl = pColl; + pExpr.flags |= EP_ExpCollate; + } + return pExpr; + } - /* - ** Return the default collation sequence for the expression pExpr. If - ** there is no default collation type, return 0. - */ - static CollSeq sqlite3ExprCollSeq( Parse pParse, Expr pExpr ) - { - CollSeq pColl = null; - Expr p = pExpr; - while ( ALWAYS( p ) ) - { - int op; - pColl = pExpr.pColl; - if ( pColl != null ) - break; - op = p.op; - if ( p.pTab != null && ( - op == TK_AGG_COLUMN || op == TK_COLUMN || op == TK_REGISTER || op == TK_TRIGGER - ) ) - { - /* op==TK_REGISTER && p->pTab!=0 happens when pExpr was originally - ** a TK_COLUMN but was previously evaluated and cached in a register */ - string zColl; - int j = p.iColumn; - if ( j >= 0 ) - { + /* + ** Set the collating sequence for expression pExpr to be the collating + ** sequence named by pToken. Return a pointer to the revised expression. + ** The collating sequence is marked as "explicit" using the EP_ExpCollate + ** flag. An explicit collating sequence will override implicit + ** collating sequences. + */ + static Expr sqlite3ExprSetCollByToken(Parse pParse, Expr pExpr, Token pCollName) { + string zColl; /* Dequoted name of collation sequence */ + CollSeq pColl; sqlite3 db = pParse.db; - zColl = p.pTab.aCol[j].zColl; - pColl = sqlite3FindCollSeq( db, ENC( db ), zColl, 0 ); - pExpr.pColl = pColl; - } - break; - } - if ( op != TK_CAST && op != TK_UPLUS ) - { - break; + zColl = sqlite3NameFromToken(db, pCollName); + pColl = sqlite3LocateCollSeq(pParse, zColl); + sqlite3ExprSetColl(pExpr, pColl); + sqlite3DbFree(db, ref zColl); + return pExpr; } - p = p.pLeft; - } - if ( sqlite3CheckCollSeq( pParse, pColl ) != 0 ) - { - pColl = null; - } - return pColl; - } - /* - ** pExpr is an operand of a comparison operator. aff2 is the - ** type affinity of the other operand. This routine returns the - ** type affinity that should be used for the comparison operator. - */ - static char sqlite3CompareAffinity( Expr pExpr, char aff2 ) - { - char aff1 = sqlite3ExprAffinity( pExpr ); - if ( aff1 != '\0' && aff2 != '\0' ) - { - /* Both sides of the comparison are columns. If one has numeric - ** affinity, use that. Otherwise use no affinity. + /* + ** Return the default collation sequence for the expression pExpr. If + ** there is no default collation type, return 0. */ - if ( aff1 >= SQLITE_AFF_NUMERIC || aff2 >= SQLITE_AFF_NUMERIC ) - // if (sqlite3IsNumericAffinity(aff1) || sqlite3IsNumericAffinity(aff2)) - { - return SQLITE_AFF_NUMERIC; - } - else - { - return SQLITE_AFF_NONE; + static CollSeq sqlite3ExprCollSeq(Parse pParse, Expr pExpr) { + CollSeq pColl = null; + Expr p = pExpr; + while (ALWAYS(p)) { + int op; + pColl = pExpr.pColl; + if (pColl != null) + break; + op = p.op; + if (p.pTab != null && ( + op == TK_AGG_COLUMN || op == TK_COLUMN || op == TK_REGISTER || op == TK_TRIGGER + )) { + /* op==TK_REGISTER && p->pTab!=0 happens when pExpr was originally + ** a TK_COLUMN but was previously evaluated and cached in a register */ + string zColl; + int j = p.iColumn; + if (j >= 0) { + sqlite3 db = pParse.db; + zColl = p.pTab.aCol[j].zColl; + pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0); + pExpr.pColl = pColl; + } + break; + } + if (op != TK_CAST && op != TK_UPLUS) { + break; + } + p = p.pLeft; + } + if (sqlite3CheckCollSeq(pParse, pColl) != 0) { + pColl = null; + } + return pColl; } - } - else if ( aff1 == '\0' && aff2 == '\0' ) - { - /* Neither side of the comparison is a column. Compare the - ** results directly. + + /* + ** pExpr is an operand of a comparison operator. aff2 is the + ** type affinity of the other operand. This routine returns the + ** type affinity that should be used for the comparison operator. */ - return SQLITE_AFF_NONE; - } - else - { - /* One side is a column, the other is not. Use the columns affinity. */ - Debug.Assert( aff1 == 0 || aff2 == 0 ); - return ( aff1 != '\0' ? aff1 : aff2 ); - } - } + static char sqlite3CompareAffinity(Expr pExpr, char aff2) { + char aff1 = sqlite3ExprAffinity(pExpr); + if (aff1 != '\0' && aff2 != '\0') { + /* Both sides of the comparison are columns. If one has numeric + ** affinity, use that. Otherwise use no affinity. + */ + if (aff1 >= SQLITE_AFF_NUMERIC || aff2 >= SQLITE_AFF_NUMERIC) + // if (sqlite3IsNumericAffinity(aff1) || sqlite3IsNumericAffinity(aff2)) + { + return SQLITE_AFF_NUMERIC; + } else { + return SQLITE_AFF_NONE; + } + } else if (aff1 == '\0' && aff2 == '\0') { + /* Neither side of the comparison is a column. Compare the + ** results directly. + */ + return SQLITE_AFF_NONE; + } else { + /* One side is a column, the other is not. Use the columns affinity. */ + Debug.Assert(aff1 == 0 || aff2 == 0); + return (aff1 != '\0' ? aff1 : aff2); + } + } - /* - ** pExpr is a comparison operator. Return the type affinity that should - ** be applied to both operands prior to doing the comparison. - */ - static char comparisonAffinity( Expr pExpr ) - { - char aff; - Debug.Assert( pExpr.op == TK_EQ || pExpr.op == TK_IN || pExpr.op == TK_LT || - pExpr.op == TK_GT || pExpr.op == TK_GE || pExpr.op == TK_LE || - pExpr.op == TK_NE || pExpr.op == TK_IS || pExpr.op == TK_ISNOT ); - Debug.Assert( pExpr.pLeft != null ); - aff = sqlite3ExprAffinity( pExpr.pLeft ); - if ( pExpr.pRight != null ) - { - aff = sqlite3CompareAffinity( pExpr.pRight, aff ); - } - else if ( ExprHasProperty( pExpr, EP_xIsSelect ) ) - { - aff = sqlite3CompareAffinity( pExpr.x.pSelect.pEList.a[0].pExpr, aff ); - } - else if ( aff == '\0' ) - { - aff = SQLITE_AFF_NONE; - } - return aff; - } + /* + ** pExpr is a comparison operator. Return the type affinity that should + ** be applied to both operands prior to doing the comparison. + */ + static char comparisonAffinity(Expr pExpr) { + char aff; + Debug.Assert(pExpr.op == TK_EQ || pExpr.op == TK_IN || pExpr.op == TK_LT || + pExpr.op == TK_GT || pExpr.op == TK_GE || pExpr.op == TK_LE || + pExpr.op == TK_NE || pExpr.op == TK_IS || pExpr.op == TK_ISNOT); + Debug.Assert(pExpr.pLeft != null); + aff = sqlite3ExprAffinity(pExpr.pLeft); + if (pExpr.pRight != null) { + aff = sqlite3CompareAffinity(pExpr.pRight, aff); + } else if (ExprHasProperty(pExpr, EP_xIsSelect)) { + aff = sqlite3CompareAffinity(pExpr.x.pSelect.pEList.a[0].pExpr, aff); + } else if (aff == '\0') { + aff = SQLITE_AFF_NONE; + } + return aff; + } - /* - ** pExpr is a comparison expression, eg. '=', '<', IN(...) etc. - ** idx_affinity is the affinity of an indexed column. Return true - ** if the index with affinity idx_affinity may be used to implement - ** the comparison in pExpr. - */ - static bool sqlite3IndexAffinityOk( Expr pExpr, char idx_affinity ) - { - char aff = comparisonAffinity( pExpr ); - switch ( aff ) - { - case SQLITE_AFF_NONE: - return true; - case SQLITE_AFF_TEXT: - return idx_affinity == SQLITE_AFF_TEXT; - default: - return idx_affinity >= SQLITE_AFF_NUMERIC;// sqlite3IsNumericAffinity(idx_affinity); - } - } + /* + ** pExpr is a comparison expression, eg. '=', '<', IN(...) etc. + ** idx_affinity is the affinity of an indexed column. Return true + ** if the index with affinity idx_affinity may be used to implement + ** the comparison in pExpr. + */ + static bool sqlite3IndexAffinityOk(Expr pExpr, char idx_affinity) { + char aff = comparisonAffinity(pExpr); + switch (aff) { + case SQLITE_AFF_NONE: + return true; + case SQLITE_AFF_TEXT: + return idx_affinity == SQLITE_AFF_TEXT; + default: + return idx_affinity >= SQLITE_AFF_NUMERIC;// sqlite3IsNumericAffinity(idx_affinity); + } + } - /* - ** Return the P5 value that should be used for a binary comparison - ** opcode (OP_Eq, OP_Ge etc.) used to compare pExpr1 and pExpr2. - */ - static u8 binaryCompareP5( Expr pExpr1, Expr pExpr2, int jumpIfNull ) - { - u8 aff = (u8)sqlite3ExprAffinity( pExpr2 ); - aff = (u8)( (u8)sqlite3CompareAffinity( pExpr1, (char)aff ) | (u8)jumpIfNull ); - return aff; - } + /* + ** Return the P5 value that should be used for a binary comparison + ** opcode (OP_Eq, OP_Ge etc.) used to compare pExpr1 and pExpr2. + */ + static u8 binaryCompareP5(Expr pExpr1, Expr pExpr2, int jumpIfNull) { + u8 aff = (u8)sqlite3ExprAffinity(pExpr2); + aff = (u8)((u8)sqlite3CompareAffinity(pExpr1, (char)aff) | (u8)jumpIfNull); + return aff; + } - /* - ** Return a pointer to the collation sequence that should be used by - ** a binary comparison operator comparing pLeft and pRight. - ** - ** If the left hand expression has a collating sequence type, then it is - ** used. Otherwise the collation sequence for the right hand expression - ** is used, or the default (BINARY) if neither expression has a collating - ** type. - ** - ** Argument pRight (but not pLeft) may be a null pointer. In this case, - ** it is not considered. - */ - static CollSeq sqlite3BinaryCompareCollSeq( - Parse pParse, - Expr pLeft, - Expr pRight - ) - { - CollSeq pColl; - Debug.Assert( pLeft != null ); - if ( ( pLeft.flags & EP_ExpCollate ) != 0 ) - { - Debug.Assert( pLeft.pColl != null ); - pColl = pLeft.pColl; - } - else if ( pRight != null && ( ( pRight.flags & EP_ExpCollate ) != 0 ) ) - { - Debug.Assert( pRight.pColl != null ); - pColl = pRight.pColl; - } - else - { - pColl = sqlite3ExprCollSeq( pParse, pLeft ); - if ( pColl == null ) - { - pColl = sqlite3ExprCollSeq( pParse, pRight ); + /* + ** Return a pointer to the collation sequence that should be used by + ** a binary comparison operator comparing pLeft and pRight. + ** + ** If the left hand expression has a collating sequence type, then it is + ** used. Otherwise the collation sequence for the right hand expression + ** is used, or the default (BINARY) if neither expression has a collating + ** type. + ** + ** Argument pRight (but not pLeft) may be a null pointer. In this case, + ** it is not considered. + */ + static CollSeq sqlite3BinaryCompareCollSeq( + Parse pParse, + Expr pLeft, + Expr pRight + ) { + CollSeq pColl; + Debug.Assert(pLeft != null); + if ((pLeft.flags & EP_ExpCollate) != 0) { + Debug.Assert(pLeft.pColl != null); + pColl = pLeft.pColl; + } else if (pRight != null && ((pRight.flags & EP_ExpCollate) != 0)) { + Debug.Assert(pRight.pColl != null); + pColl = pRight.pColl; + } else { + pColl = sqlite3ExprCollSeq(pParse, pLeft); + if (pColl == null) { + pColl = sqlite3ExprCollSeq(pParse, pRight); + } + } + return pColl; } - } - return pColl; - } - /* - ** Generate code for a comparison operator. - */ - static int codeCompare( - Parse pParse, /* The parsing (and code generating) context */ - Expr pLeft, /* The left operand */ - Expr pRight, /* The right operand */ - int opcode, /* The comparison opcode */ - int in1, int in2, /* Register holding operands */ - int dest, /* Jump here if true. */ - int jumpIfNull /* If true, jump if either operand is NULL */ - ) - { - int p5; - int addr; - CollSeq p4; - - p4 = sqlite3BinaryCompareCollSeq( pParse, pLeft, pRight ); - p5 = binaryCompareP5( pLeft, pRight, jumpIfNull ); - addr = sqlite3VdbeAddOp4( pParse.pVdbe, opcode, in2, dest, in1, - p4, P4_COLLSEQ ); - sqlite3VdbeChangeP5( pParse.pVdbe, (u8)p5 ); - return addr; - } + /* + ** Generate code for a comparison operator. + */ + static int codeCompare( + Parse pParse, /* The parsing (and code generating) context */ + Expr pLeft, /* The left operand */ + Expr pRight, /* The right operand */ + int opcode, /* The comparison opcode */ + int in1, int in2, /* Register holding operands */ + int dest, /* Jump here if true. */ + int jumpIfNull /* If true, jump if either operand is NULL */ + ) { + int p5; + int addr; + CollSeq p4; + + p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight); + p5 = binaryCompareP5(pLeft, pRight, jumpIfNull); + addr = sqlite3VdbeAddOp4(pParse.pVdbe, opcode, in2, dest, in1, + p4, P4_COLLSEQ); + sqlite3VdbeChangeP5(pParse.pVdbe, (u8)p5); + return addr; + } #if SQLITE_MAX_EXPR_DEPTH //>0 - /* -** Check that argument nHeight is less than or equal to the maximum -** expression depth allowed. If it is not, leave an error message in -** pParse. -*/ - static int sqlite3ExprCheckHeight( Parse pParse, int nHeight ) - { - int rc = SQLITE_OK; - int mxHeight = pParse.db.aLimit[SQLITE_LIMIT_EXPR_DEPTH]; - if ( nHeight > mxHeight ) - { - sqlite3ErrorMsg( pParse, - "Expression tree is too large (maximum depth %d)", mxHeight - ); - rc = SQLITE_ERROR; - } - return rc; - } + /* + ** Check that argument nHeight is less than or equal to the maximum + ** expression depth allowed. If it is not, leave an error message in + ** pParse. + */ + static int sqlite3ExprCheckHeight(Parse pParse, int nHeight) { + int rc = SQLITE_OK; + int mxHeight = pParse.db.aLimit[SQLITE_LIMIT_EXPR_DEPTH]; + if (nHeight > mxHeight) { + sqlite3ErrorMsg(pParse, + "Expression tree is too large (maximum depth %d)", mxHeight + ); + rc = SQLITE_ERROR; + } + return rc; + } - /* The following three functions, heightOfExpr(), heightOfExprList() - ** and heightOfSelect(), are used to determine the maximum height - ** of any expression tree referenced by the structure passed as the - ** first argument. - ** - ** If this maximum height is greater than the current value pointed - ** to by pnHeight, the second parameter, then set pnHeight to that - ** value. - */ - static void heightOfExpr( Expr p, ref int pnHeight ) - { - if ( p != null ) - { - if ( p.nHeight > pnHeight ) - { - pnHeight = p.nHeight; + /* The following three functions, heightOfExpr(), heightOfExprList() + ** and heightOfSelect(), are used to determine the maximum height + ** of any expression tree referenced by the structure passed as the + ** first argument. + ** + ** If this maximum height is greater than the current value pointed + ** to by pnHeight, the second parameter, then set pnHeight to that + ** value. + */ + static void heightOfExpr(Expr p, ref int pnHeight) { + if (p != null) { + if (p.nHeight > pnHeight) { + pnHeight = p.nHeight; + } + } } - } - } - static void heightOfExprList( ExprList p, ref int pnHeight ) - { - if ( p != null ) - { - int i; - for ( i = 0; i < p.nExpr; i++ ) - { - heightOfExpr( p.a[i].pExpr, ref pnHeight ); + static void heightOfExprList(ExprList p, ref int pnHeight) { + if (p != null) { + int i; + for (i = 0; i < p.nExpr; i++) { + heightOfExpr(p.a[i].pExpr, ref pnHeight); + } + } + } + static void heightOfSelect(Select p, ref int pnHeight) { + if (p != null) { + heightOfExpr(p.pWhere, ref pnHeight); + heightOfExpr(p.pHaving, ref pnHeight); + heightOfExpr(p.pLimit, ref pnHeight); + heightOfExpr(p.pOffset, ref pnHeight); + heightOfExprList(p.pEList, ref pnHeight); + heightOfExprList(p.pGroupBy, ref pnHeight); + heightOfExprList(p.pOrderBy, ref pnHeight); + heightOfSelect(p.pPrior, ref pnHeight); + } } - } - } - static void heightOfSelect( Select p, ref int pnHeight ) - { - if ( p != null ) - { - heightOfExpr( p.pWhere, ref pnHeight ); - heightOfExpr( p.pHaving, ref pnHeight ); - heightOfExpr( p.pLimit, ref pnHeight ); - heightOfExpr( p.pOffset, ref pnHeight ); - heightOfExprList( p.pEList, ref pnHeight ); - heightOfExprList( p.pGroupBy, ref pnHeight ); - heightOfExprList( p.pOrderBy, ref pnHeight ); - heightOfSelect( p.pPrior, ref pnHeight ); - } - } - /* - ** Set the Expr.nHeight variable in the structure passed as an - ** argument. An expression with no children, Expr.x.pList or - ** Expr.x.pSelect member has a height of 1. Any other expression - ** has a height equal to the maximum height of any other - ** referenced Expr plus one. - */ - static void exprSetHeight( Expr p ) - { - int nHeight = 0; - heightOfExpr( p.pLeft, ref nHeight ); - heightOfExpr( p.pRight, ref nHeight ); - if ( ExprHasProperty( p, EP_xIsSelect ) ) - { - heightOfSelect( p.x.pSelect, ref nHeight ); - } - else - { - heightOfExprList( p.x.pList, ref nHeight ); - } - p.nHeight = nHeight + 1; - } + /* + ** Set the Expr.nHeight variable in the structure passed as an + ** argument. An expression with no children, Expr.x.pList or + ** Expr.x.pSelect member has a height of 1. Any other expression + ** has a height equal to the maximum height of any other + ** referenced Expr plus one. + */ + static void exprSetHeight(Expr p) { + int nHeight = 0; + heightOfExpr(p.pLeft, ref nHeight); + heightOfExpr(p.pRight, ref nHeight); + if (ExprHasProperty(p, EP_xIsSelect)) { + heightOfSelect(p.x.pSelect, ref nHeight); + } else { + heightOfExprList(p.x.pList, ref nHeight); + } + p.nHeight = nHeight + 1; + } - /* - ** Set the Expr.nHeight variable using the exprSetHeight() function. If - ** the height is greater than the maximum allowed expression depth, - ** leave an error in pParse. - */ - static void sqlite3ExprSetHeight( Parse pParse, Expr p ) - { - exprSetHeight( p ); - sqlite3ExprCheckHeight( pParse, p.nHeight ); - } + /* + ** Set the Expr.nHeight variable using the exprSetHeight() function. If + ** the height is greater than the maximum allowed expression depth, + ** leave an error in pParse. + */ + static void sqlite3ExprSetHeight(Parse pParse, Expr p) { + exprSetHeight(p); + sqlite3ExprCheckHeight(pParse, p.nHeight); + } - /* - ** Return the maximum height of any expression tree referenced - ** by the select statement passed as an argument. - */ - static int sqlite3SelectExprHeight( Select p ) - { - int nHeight = 0; - heightOfSelect( p, ref nHeight ); - return nHeight; - } + /* + ** Return the maximum height of any expression tree referenced + ** by the select statement passed as an argument. + */ + static int sqlite3SelectExprHeight(Select p) { + int nHeight = 0; + heightOfSelect(p, ref nHeight); + return nHeight; + } #else //#define exprSetHeight(y) #endif //* SQLITE_MAX_EXPR_DEPTH>0 */ - /* -** This routine is the core allocator for Expr nodes. -** -** Construct a new expression node and return a pointer to it. Memory -** for this node and for the pToken argument is a single allocation -** obtained from sqlite3DbMalloc(). The calling function -** is responsible for making sure the node eventually gets freed. -** -** If dequote is true, then the token (if it exists) is dequoted. -** If dequote is false, no dequoting is performance. The deQuote -** parameter is ignored if pToken is NULL or if the token does not -** appear to be quoted. If the quotes were of the form "..." (double-quotes) -** then the EP_DblQuoted flag is set on the expression node. -** -** Special case: If op==TK_INTEGER and pToken points to a string that -** can be translated into a 32-bit integer, then the token is not -** stored in u.zToken. Instead, the integer values is written -** into u.iValue and the EP_IntValue flag is set. No extra storage -** is allocated to hold the integer text and the dequote flag is ignored. -*/ - static Expr sqlite3ExprAlloc( - sqlite3 db, /* Handle for sqlite3DbMallocZero() (may be null) */ - int op, /* Expression opcode */ - Token pToken, /* Token argument. Might be NULL */ - int dequote /* True to dequote */ - ) - { - Expr pNew; - int nExtra = 0; - int iValue = 0; - - if ( pToken != null ) - { - if ( op != TK_INTEGER || pToken.z == null || pToken.z.Length == 0 - || sqlite3GetInt32( pToken.z.ToString(), ref iValue ) == false ) - { - nExtra = pToken.n + 1; - Debug.Assert( iValue >= 0 ); - } - } - pNew = new Expr();//sqlite3DbMallocZero(db, sizeof(Expr)+nExtra); - if ( pNew != null ) - { - pNew.op = (u8)op; - pNew.iAgg = -1; - if ( pToken != null ) - { - if ( nExtra == 0 ) - { - pNew.flags |= EP_IntValue; - pNew.u.iValue = iValue; - } - else - { - int c; - //pNew.u.zToken = (char)&pNew[1]; - if ( pToken.n > 0 ) - pNew.u.zToken = pToken.z.Substring( 0, pToken.n );//memcpy(pNew.u.zToken, pToken.z, pToken.n); - else if ( pToken.n == 0 && string.IsNullOrEmpty(pToken.z)) - pNew.u.zToken = string.Empty; - //pNew.u.zToken[pToken.n] = 0; - if ( dequote != 0 && nExtra >= 3 - && ( ( c = pToken.z[0] ) == '\'' || c == '"' || c == '[' || c == '`' ) ) - { + /* + ** This routine is the core allocator for Expr nodes. + ** + ** Construct a new expression node and return a pointer to it. Memory + ** for this node and for the pToken argument is a single allocation + ** obtained from sqlite3DbMalloc(). The calling function + ** is responsible for making sure the node eventually gets freed. + ** + ** If dequote is true, then the token (if it exists) is dequoted. + ** If dequote is false, no dequoting is performance. The deQuote + ** parameter is ignored if pToken is NULL or if the token does not + ** appear to be quoted. If the quotes were of the form "..." (double-quotes) + ** then the EP_DblQuoted flag is set on the expression node. + ** + ** Special case: If op==TK_INTEGER and pToken points to a string that + ** can be translated into a 32-bit integer, then the token is not + ** stored in u.zToken. Instead, the integer values is written + ** into u.iValue and the EP_IntValue flag is set. No extra storage + ** is allocated to hold the integer text and the dequote flag is ignored. + */ + static Expr sqlite3ExprAlloc( + sqlite3 db, /* Handle for sqlite3DbMallocZero() (may be null) */ + int op, /* Expression opcode */ + Token pToken, /* Token argument. Might be NULL */ + int dequote /* True to dequote */ + ) { + Expr pNew; + int nExtra = 0; + int iValue = 0; + + if (pToken != null) { + if (op != TK_INTEGER || pToken.z == null || pToken.z.Length == 0 + || sqlite3GetInt32(pToken.z.ToString(), ref iValue) == false) { + nExtra = pToken.n + 1; + Debug.Assert(iValue >= 0); + } + } + pNew = new Expr();//sqlite3DbMallocZero(db, sizeof(Expr)+nExtra); + if (pNew != null) { + pNew.op = (u8)op; + pNew.iAgg = -1; + if (pToken != null) { + if (nExtra == 0) { + pNew.flags |= EP_IntValue; + pNew.u.iValue = iValue; + } else { + int c; + //pNew.u.zToken = (char)&pNew[1]; + if (pToken.n > 0) + pNew.u.zToken = pToken.z.Substring(0, pToken.n);//memcpy(pNew.u.zToken, pToken.z, pToken.n); + else if (pToken.n == 0 && string.IsNullOrEmpty(pToken.z)) + pNew.u.zToken = string.Empty; + //pNew.u.zToken[pToken.n] = 0; + if (dequote != 0 && nExtra >= 3 + && ((c = pToken.z[0]) == '\'' || c == '"' || c == '[' || c == '`')) { #if DEBUG_CLASS_EXPR || DEBUG_CLASS_ALL sqlite3Dequote(ref pNew.u._zToken); #else - sqlite3Dequote( ref pNew.u.zToken ); + sqlite3Dequote(ref pNew.u.zToken); #endif - if ( c == '"' ) - pNew.flags |= EP_DblQuoted; - } - } - } + if (c == '"') + pNew.flags |= EP_DblQuoted; + } + } + } #if SQLITE_MAX_EXPR_DEPTH//>0 - pNew.nHeight = 1; + pNew.nHeight = 1; #endif - } - return pNew; - } - - /* - ** Allocate a new expression node from a zero-terminated token that has - ** already been dequoted. - */ - static Expr sqlite3Expr( - sqlite3 db, /* Handle for sqlite3DbMallocZero() (may be null) */ - int op, /* Expression opcode */ - string zToken /* Token argument. Might be NULL */ - ) - { - Token x = new Token(); - x.z = zToken; - x.n = !string.IsNullOrEmpty( zToken ) ? sqlite3Strlen30( zToken ) : 0; - return sqlite3ExprAlloc( db, op, x, 0 ); - } - - /* - ** Attach subtrees pLeft and pRight to the Expr node pRoot. - ** - ** If pRoot==NULL that means that a memory allocation error has occurred. - ** In that case, delete the subtrees pLeft and pRight. - */ - static void sqlite3ExprAttachSubtrees( - sqlite3 db, - Expr pRoot, - Expr pLeft, - Expr pRight - ) - { - if ( pRoot == null ) - { - //Debug.Assert( db.mallocFailed != 0 ); - sqlite3ExprDelete( db, ref pLeft ); - sqlite3ExprDelete( db, ref pRight ); - } - else - { - if ( pRight != null ) - { - pRoot.pRight = pRight; - if ( ( pRight.flags & EP_ExpCollate ) != 0 ) - { - pRoot.flags |= EP_ExpCollate; - pRoot.pColl = pRight.pColl; - } + } + return pNew; } - if ( pLeft != null ) - { - pRoot.pLeft = pLeft; - if ( ( pLeft.flags & EP_ExpCollate ) != 0 ) - { - pRoot.flags |= EP_ExpCollate; - pRoot.pColl = pLeft.pColl; - } + + /* + ** Allocate a new expression node from a zero-terminated token that has + ** already been dequoted. + */ + static Expr sqlite3Expr( + sqlite3 db, /* Handle for sqlite3DbMallocZero() (may be null) */ + int op, /* Expression opcode */ + string zToken /* Token argument. Might be NULL */ + ) { + Token x = new Token(); + x.z = zToken; + x.n = !string.IsNullOrEmpty(zToken) ? sqlite3Strlen30(zToken) : 0; + return sqlite3ExprAlloc(db, op, x, 0); } - exprSetHeight( pRoot ); - } - } - /* - ** Allocate a Expr node which joins as many as two subtrees. - ** - ** One or both of the subtrees can be NULL. Return a pointer to the new - ** Expr node. Or, if an OOM error occurs, set pParse->db->mallocFailed, - ** free the subtrees and return NULL. - */ - // OVERLOADS, so I don't need to rewrite parse.c - static Expr sqlite3PExpr( Parse pParse, int op, int null_3, int null_4, int null_5 ) - { - return sqlite3PExpr( pParse, op, null, null, null ); - } - static Expr sqlite3PExpr( Parse pParse, int op, int null_3, int null_4, Token pToken ) - { - return sqlite3PExpr( pParse, op, null, null, pToken ); - } - static Expr sqlite3PExpr( Parse pParse, int op, Expr pLeft, int null_4, int null_5 ) - { - return sqlite3PExpr( pParse, op, pLeft, null, null ); - } - static Expr sqlite3PExpr( Parse pParse, int op, Expr pLeft, int null_4, Token pToken ) - { - return sqlite3PExpr( pParse, op, pLeft, null, pToken ); - } - static Expr sqlite3PExpr( Parse pParse, int op, Expr pLeft, Expr pRight, int null_5 ) - { - return sqlite3PExpr( pParse, op, pLeft, pRight, null ); - } - static Expr sqlite3PExpr( - Parse pParse, /* Parsing context */ - int op, /* Expression opcode */ - Expr pLeft, /* Left operand */ - Expr pRight, /* Right operand */ - Token pToken /* Argument Token */ - ) - { - Expr p = sqlite3ExprAlloc( pParse.db, op, pToken, 1 ); - sqlite3ExprAttachSubtrees( pParse.db, p, pLeft, pRight ); - if ( p != null ) - { - sqlite3ExprCheckHeight( pParse, p.nHeight ); - } - return p; - } + /* + ** Attach subtrees pLeft and pRight to the Expr node pRoot. + ** + ** If pRoot==NULL that means that a memory allocation error has occurred. + ** In that case, delete the subtrees pLeft and pRight. + */ + static void sqlite3ExprAttachSubtrees( + sqlite3 db, + Expr pRoot, + Expr pLeft, + Expr pRight + ) { + if (pRoot == null) { + //Debug.Assert( db.mallocFailed != 0 ); + sqlite3ExprDelete(db, ref pLeft); + sqlite3ExprDelete(db, ref pRight); + } else { + if (pRight != null) { + pRoot.pRight = pRight; + if ((pRight.flags & EP_ExpCollate) != 0) { + pRoot.flags |= EP_ExpCollate; + pRoot.pColl = pRight.pColl; + } + } + if (pLeft != null) { + pRoot.pLeft = pLeft; + if ((pLeft.flags & EP_ExpCollate) != 0) { + pRoot.flags |= EP_ExpCollate; + pRoot.pColl = pLeft.pColl; + } + } + exprSetHeight(pRoot); + } + } - /* - ** Join two expressions using an AND operator. If either expression is - ** NULL, then just return the other expression. - */ - static Expr sqlite3ExprAnd( sqlite3 db, Expr pLeft, Expr pRight ) - { - if ( pLeft == null ) - { - return pRight; - } - else if ( pRight == null ) - { - return pLeft; - } - else - { - Expr pNew = sqlite3ExprAlloc( db, TK_AND, null, 0 ); - sqlite3ExprAttachSubtrees( db, pNew, pLeft, pRight ); - return pNew; - } - } + /* + ** Allocate a Expr node which joins as many as two subtrees. + ** + ** One or both of the subtrees can be NULL. Return a pointer to the new + ** Expr node. Or, if an OOM error occurs, set pParse->db->mallocFailed, + ** free the subtrees and return NULL. + */ + // OVERLOADS, so I don't need to rewrite parse.c + static Expr sqlite3PExpr(Parse pParse, int op, int null_3, int null_4, int null_5) { + return sqlite3PExpr(pParse, op, null, null, null); + } + static Expr sqlite3PExpr(Parse pParse, int op, int null_3, int null_4, Token pToken) { + return sqlite3PExpr(pParse, op, null, null, pToken); + } + static Expr sqlite3PExpr(Parse pParse, int op, Expr pLeft, int null_4, int null_5) { + return sqlite3PExpr(pParse, op, pLeft, null, null); + } + static Expr sqlite3PExpr(Parse pParse, int op, Expr pLeft, int null_4, Token pToken) { + return sqlite3PExpr(pParse, op, pLeft, null, pToken); + } + static Expr sqlite3PExpr(Parse pParse, int op, Expr pLeft, Expr pRight, int null_5) { + return sqlite3PExpr(pParse, op, pLeft, pRight, null); + } + static Expr sqlite3PExpr( + Parse pParse, /* Parsing context */ + int op, /* Expression opcode */ + Expr pLeft, /* Left operand */ + Expr pRight, /* Right operand */ + Token pToken /* Argument Token */ + ) { + Expr p = sqlite3ExprAlloc(pParse.db, op, pToken, 1); + sqlite3ExprAttachSubtrees(pParse.db, p, pLeft, pRight); + if (p != null) { + sqlite3ExprCheckHeight(pParse, p.nHeight); + } + return p; + } - /* - ** Construct a new expression node for a function with multiple - ** arguments. - */ - // OVERLOADS, so I don't need to rewrite parse.c - static Expr sqlite3ExprFunction( Parse pParse, int null_2, Token pToken ) - { - return sqlite3ExprFunction( pParse, null, pToken ); - } - static Expr sqlite3ExprFunction( Parse pParse, ExprList pList, int null_3 ) - { - return sqlite3ExprFunction( pParse, pList, null ); - } - static Expr sqlite3ExprFunction( Parse pParse, ExprList pList, Token pToken ) - { - Expr pNew; - sqlite3 db = pParse.db; - Debug.Assert( pToken != null ); - pNew = sqlite3ExprAlloc( db, TK_FUNCTION, pToken, 1 ); - if ( pNew == null ) - { - sqlite3ExprListDelete( db, ref pList ); /* Avoid memory leak when malloc fails */ - return null; - } - pNew.x.pList = pList; - Debug.Assert( !ExprHasProperty( pNew, EP_xIsSelect ) ); - - sqlite3ExprSetHeight( pParse, pNew ); - return pNew; - } + /* + ** Join two expressions using an AND operator. If either expression is + ** NULL, then just return the other expression. + */ + static Expr sqlite3ExprAnd(sqlite3 db, Expr pLeft, Expr pRight) { + if (pLeft == null) { + return pRight; + } else if (pRight == null) { + return pLeft; + } else { + Expr pNew = sqlite3ExprAlloc(db, TK_AND, null, 0); + sqlite3ExprAttachSubtrees(db, pNew, pLeft, pRight); + return pNew; + } + } - /* - ** Assign a variable number to an expression that encodes a wildcard - ** in the original SQL statement. - ** - ** Wildcards consisting of a single "?" are assigned the next sequential - ** variable number. - ** - ** Wildcards of the form "?nnn" are assigned the number "nnn". We make - ** sure "nnn" is not too be to avoid a denial of service attack when - ** the SQL statement comes from an external source. - ** - ** Wildcards of the form ":aaa", "@aaa" or "$aaa" are assigned the same number - ** as the previous instance of the same wildcard. Or if this is the first - ** instance of the wildcard, the next sequenial variable number is - ** assigned. - */ - static void sqlite3ExprAssignVarNumber( Parse pParse, Expr pExpr ) - { - sqlite3 db = pParse.db; - string z; - - if ( pExpr == null ) - return; - Debug.Assert( !ExprHasAnyProperty( pExpr, EP_IntValue | EP_Reduced | EP_TokenOnly ) ); - z = pExpr.u.zToken; - Debug.Assert( z != null ); - Debug.Assert( z.Length != 0 ); - if ( z.Length == 1 ) - { - /* Wildcard of the form "?". Assign the next variable number */ - Debug.Assert( z[0] == '?' ); - pExpr.iColumn = (ynVar)( ++pParse.nVar ); - }else{ - ynVar x = 0; - int n = sqlite3Strlen30(z); - if( z[0]=='?' ){ - /* Wildcard of the form "?nnn". Convert "nnn" to an integer and - ** use it as the variable number */ - i64 i = 0; - bool bOk = 0 == sqlite3Atoi64( z.Substring( 1 ), ref i, n - 1, SQLITE_UTF8 ); - pExpr.iColumn = x=(ynVar)i; - testcase( i == 0 ); - testcase( i == 1 ); - testcase( i == db.aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] - 1 ); - testcase( i == db.aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ); - if ( bOk == false || i < 1 || i > db.aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ) - { - sqlite3ErrorMsg( pParse, "variable number must be between ?1 and ?%d", - db.aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ); - x=0; + /* + ** Construct a new expression node for a function with multiple + ** arguments. + */ + // OVERLOADS, so I don't need to rewrite parse.c + static Expr sqlite3ExprFunction(Parse pParse, int null_2, Token pToken) { + return sqlite3ExprFunction(pParse, null, pToken); } - if ( i > pParse.nVar ) - { - pParse.nVar = (int)i; + static Expr sqlite3ExprFunction(Parse pParse, ExprList pList, int null_3) { + return sqlite3ExprFunction(pParse, pList, null); + } + static Expr sqlite3ExprFunction(Parse pParse, ExprList pList, Token pToken) { + Expr pNew; + sqlite3 db = pParse.db; + Debug.Assert(pToken != null); + pNew = sqlite3ExprAlloc(db, TK_FUNCTION, pToken, 1); + if (pNew == null) { + sqlite3ExprListDelete(db, ref pList); /* Avoid memory leak when malloc fails */ + return null; + } + pNew.x.pList = pList; + Debug.Assert(!ExprHasProperty(pNew, EP_xIsSelect)); + + sqlite3ExprSetHeight(pParse, pNew); + return pNew; } - } - else - { - /* Wildcards like ":aaa", "$aaa" or "@aaa". Reuse the same variable - ** number as the prior appearance of the same name, or if the name - ** has never appeared before, reuse the same variable number + + /* + ** Assign a variable number to an expression that encodes a wildcard + ** in the original SQL statement. + ** + ** Wildcards consisting of a single "?" are assigned the next sequential + ** variable number. + ** + ** Wildcards of the form "?nnn" are assigned the number "nnn". We make + ** sure "nnn" is not too be to avoid a denial of service attack when + ** the SQL statement comes from an external source. + ** + ** Wildcards of the form ":aaa", "@aaa" or "$aaa" are assigned the same number + ** as the previous instance of the same wildcard. Or if this is the first + ** instance of the wildcard, the next sequenial variable number is + ** assigned. */ - ynVar i; - for(i=0; i db.aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]) { + sqlite3ErrorMsg(pParse, "variable number must be between ?1 and ?%d", + db.aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]); + x = 0; + } + if (i > pParse.nVar) { + pParse.nVar = (int)i; + } + } else { + /* Wildcards like ":aaa", "$aaa" or "@aaa". Reuse the same variable + ** number as the prior appearance of the same name, or if the name + ** has never appeared before, reuse the same variable number + */ + ynVar i; + for (i = 0; i < pParse.nzVar; i++) { + if (pParse.azVar[i] != null && string.Equals(z, pParse.azVar[i], StringComparison.Ordinal)) //memcmp(pParse.azVar[i],z,n+1)==0 ) + { + pExpr.iColumn = x = (ynVar)(i + 1); + break; + } + } + if (x == 0) x = pExpr.iColumn = (ynVar)(++pParse.nVar); + } + if (x > 0) { + if (x > pParse.nzVar) { + //char **a; + //a = sqlite3DbRealloc(db, pParse.azVar, x*sizeof(a[0])); + //if( a==0 ) return; /* Error reported through db.mallocFailed */ + //pParse.azVar = a; + //memset(&a[pParse.nzVar], 0, (x-pParse.nzVar)*sizeof(a[0])); + Array.Resize(ref pParse.azVar, x); + pParse.nzVar = x; + } + if (z[0] != '?' || pParse.azVar[x - 1] == null) { + //sqlite3DbFree(db, pParse.azVar[x-1]); + pParse.azVar[x - 1] = z.Substring(0, n);//sqlite3DbStrNDup( db, z, n ); + } + } + } + if (pParse.nErr == 0 && pParse.nVar > db.aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]) { + sqlite3ErrorMsg(pParse, "too many SQL variables"); + } } - } - if( x==0 ) x = pExpr.iColumn = (ynVar)(++pParse.nVar); - } - if( x>0 ){ - if( x>pParse.nzVar ){ - //char **a; - //a = sqlite3DbRealloc(db, pParse.azVar, x*sizeof(a[0])); - //if( a==0 ) return; /* Error reported through db.mallocFailed */ - //pParse.azVar = a; - //memset(&a[pParse.nzVar], 0, (x-pParse.nzVar)*sizeof(a[0])); - Array.Resize( ref pParse.azVar, x ); - pParse.nzVar = x; - } - if( z[0]!='?' || pParse.azVar[x-1]==null ) - { - //sqlite3DbFree(db, pParse.azVar[x-1]); - pParse.azVar[x - 1] = z.Substring( 0, n );//sqlite3DbStrNDup( db, z, n ); - } - } - } - if ( pParse.nErr == 0 && pParse.nVar > db.aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ) - { - sqlite3ErrorMsg( pParse, "too many SQL variables" ); - } - } - /* - ** Recursively delete an expression tree. - */ - static void sqlite3ExprDelete( sqlite3 db, ref Expr p ) - { - if ( p == null ) - return; - /* Sanity check: Assert that the IntValue is non-negative if it exists */ - Debug.Assert( !ExprHasProperty( p, EP_IntValue ) || p.u.iValue >= 0 ); - if ( !ExprHasAnyProperty( p, EP_TokenOnly ) ) - { - sqlite3ExprDelete( db, ref p.pLeft ); - sqlite3ExprDelete( db, ref p.pRight ); - if ( !ExprHasProperty( p, EP_Reduced ) && ( p.flags2 & EP2_MallocedToken ) != 0 ) - { + /* + ** Recursively delete an expression tree. + */ + static void sqlite3ExprDelete(sqlite3 db, ref Expr p) { + if (p == null) + return; + /* Sanity check: Assert that the IntValue is non-negative if it exists */ + Debug.Assert(!ExprHasProperty(p, EP_IntValue) || p.u.iValue >= 0); + if (!ExprHasAnyProperty(p, EP_TokenOnly)) { + sqlite3ExprDelete(db, ref p.pLeft); + sqlite3ExprDelete(db, ref p.pRight); + if (!ExprHasProperty(p, EP_Reduced) && (p.flags2 & EP2_MallocedToken) != 0) { #if DEBUG_CLASS_EXPR || DEBUG_CLASS_ALL sqlite3DbFree( db, ref p.u._zToken ); #else - sqlite3DbFree( db, ref p.u.zToken ); + sqlite3DbFree(db, ref p.u.zToken); #endif + } + if (ExprHasProperty(p, EP_xIsSelect)) { + sqlite3SelectDelete(db, ref p.x.pSelect); + } else { + sqlite3ExprListDelete(db, ref p.x.pList); + } + } + if (!ExprHasProperty(p, EP_Static)) { + sqlite3DbFree(db, ref p); + } } - if ( ExprHasProperty( p, EP_xIsSelect ) ) - { - sqlite3SelectDelete( db, ref p.x.pSelect ); - } - else - { - sqlite3ExprListDelete( db, ref p.x.pList ); - } - } - if ( !ExprHasProperty( p, EP_Static ) ) - { - sqlite3DbFree( db, ref p ); - } - } - - /* - ** Return the number of bytes allocated for the expression structure - ** passed as the first argument. This is always one of EXPR_FULLSIZE, - ** EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE. - */ - static int exprStructSize( Expr p ) - { - if ( ExprHasProperty( p, EP_TokenOnly ) ) - return EXPR_TOKENONLYSIZE; - if ( ExprHasProperty( p, EP_Reduced ) ) - return EXPR_REDUCEDSIZE; - return EXPR_FULLSIZE; - } - /* - ** The dupedExpr*Size() routines each return the number of bytes required - ** to store a copy of an expression or expression tree. They differ in - ** how much of the tree is measured. - ** - ** dupedExprStructSize() Size of only the Expr structure - ** dupedExprNodeSize() Size of Expr + space for token - ** dupedExprSize() Expr + token + subtree components - ** - *************************************************************************** - ** - ** The dupedExprStructSize() function returns two values OR-ed together: - ** (1) the space required for a copy of the Expr structure only and - ** (2) the EP_xxx flags that indicate what the structure size should be. - ** The return values is always one of: - ** - ** EXPR_FULLSIZE - ** EXPR_REDUCEDSIZE | EP_Reduced - ** EXPR_TOKENONLYSIZE | EP_TokenOnly - ** - ** The size of the structure can be found by masking the return value - ** of this routine with 0xfff. The flags can be found by masking the - ** return value with EP_Reduced|EP_TokenOnly. - ** - ** Note that with flags==EXPRDUP_REDUCE, this routines works on full-size - ** (unreduced) Expr objects as they or originally constructed by the parser. - ** During expression analysis, extra information is computed and moved into - ** later parts of teh Expr object and that extra information might get chopped - ** off if the expression is reduced. Note also that it does not work to - ** make a EXPRDUP_REDUCE copy of a reduced expression. It is only legal - ** to reduce a pristine expression tree from the parser. The implementation - ** of dupedExprStructSize() contain multiple Debug.Assert() statements that attempt - ** to enforce this constraint. - */ - static int dupedExprStructSize( Expr p, int flags ) - { - int nSize; - Debug.Assert( flags == EXPRDUP_REDUCE || flags == 0 ); /* Only one flag value allowed */ - if ( 0 == ( flags & EXPRDUP_REDUCE ) ) - { - nSize = EXPR_FULLSIZE; - } - else - { - Debug.Assert( !ExprHasAnyProperty( p, EP_TokenOnly | EP_Reduced ) ); - Debug.Assert( !ExprHasProperty( p, EP_FromJoin ) ); - Debug.Assert( ( p.flags2 & EP2_MallocedToken ) == 0 ); - Debug.Assert( ( p.flags2 & EP2_Irreducible ) == 0 ); - if ( p.pLeft != null || p.pRight != null || p.pColl != null || p.x.pList != null || p.x.pSelect != null ) - { - nSize = EXPR_REDUCEDSIZE | EP_Reduced; - } - else - { - nSize = EXPR_TOKENONLYSIZE | EP_TokenOnly; + /* + ** Return the number of bytes allocated for the expression structure + ** passed as the first argument. This is always one of EXPR_FULLSIZE, + ** EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE. + */ + static int exprStructSize(Expr p) { + if (ExprHasProperty(p, EP_TokenOnly)) + return EXPR_TOKENONLYSIZE; + if (ExprHasProperty(p, EP_Reduced)) + return EXPR_REDUCEDSIZE; + return EXPR_FULLSIZE; } - } - return nSize; - } - - /* - ** This function returns the space in bytes required to store the copy - ** of the Expr structure and a copy of the Expr.u.zToken string (if that - ** string is defined.) - */ - static int dupedExprNodeSize( Expr p, int flags ) - { - int nByte = dupedExprStructSize( p, flags ) & 0xfff; - if ( !ExprHasProperty( p, EP_IntValue ) && p.u.zToken != null ) - { - nByte += sqlite3Strlen30( p.u.zToken ) + 1; - } - return ROUND8( nByte ); - } - /* - ** Return the number of bytes required to create a duplicate of the - ** expression passed as the first argument. The second argument is a - ** mask containing EXPRDUP_XXX flags. - ** - ** The value returned includes space to create a copy of the Expr struct - ** itself and the buffer referred to by Expr.u.zToken, if any. - ** - ** If the EXPRDUP_REDUCE flag is set, then the return value includes - ** space to duplicate all Expr nodes in the tree formed by Expr.pLeft - ** and Expr.pRight variables (but not for any structures pointed to or - ** descended from the Expr.x.pList or Expr.x.pSelect variables). - */ - static int dupedExprSize( Expr p, int flags ) - { - int nByte = 0; - if ( p != null ) - { - nByte = dupedExprNodeSize( p, flags ); - if ( ( flags & EXPRDUP_REDUCE ) != 0 ) - { - nByte += dupedExprSize( p.pLeft, flags ) + dupedExprSize( p.pRight, flags ); + /* + ** The dupedExpr*Size() routines each return the number of bytes required + ** to store a copy of an expression or expression tree. They differ in + ** how much of the tree is measured. + ** + ** dupedExprStructSize() Size of only the Expr structure + ** dupedExprNodeSize() Size of Expr + space for token + ** dupedExprSize() Expr + token + subtree components + ** + *************************************************************************** + ** + ** The dupedExprStructSize() function returns two values OR-ed together: + ** (1) the space required for a copy of the Expr structure only and + ** (2) the EP_xxx flags that indicate what the structure size should be. + ** The return values is always one of: + ** + ** EXPR_FULLSIZE + ** EXPR_REDUCEDSIZE | EP_Reduced + ** EXPR_TOKENONLYSIZE | EP_TokenOnly + ** + ** The size of the structure can be found by masking the return value + ** of this routine with 0xfff. The flags can be found by masking the + ** return value with EP_Reduced|EP_TokenOnly. + ** + ** Note that with flags==EXPRDUP_REDUCE, this routines works on full-size + ** (unreduced) Expr objects as they or originally constructed by the parser. + ** During expression analysis, extra information is computed and moved into + ** later parts of teh Expr object and that extra information might get chopped + ** off if the expression is reduced. Note also that it does not work to + ** make a EXPRDUP_REDUCE copy of a reduced expression. It is only legal + ** to reduce a pristine expression tree from the parser. The implementation + ** of dupedExprStructSize() contain multiple Debug.Assert() statements that attempt + ** to enforce this constraint. + */ + static int dupedExprStructSize(Expr p, int flags) { + int nSize; + Debug.Assert(flags == EXPRDUP_REDUCE || flags == 0); /* Only one flag value allowed */ + if (0 == (flags & EXPRDUP_REDUCE)) { + nSize = EXPR_FULLSIZE; + } else { + Debug.Assert(!ExprHasAnyProperty(p, EP_TokenOnly | EP_Reduced)); + Debug.Assert(!ExprHasProperty(p, EP_FromJoin)); + Debug.Assert((p.flags2 & EP2_MallocedToken) == 0); + Debug.Assert((p.flags2 & EP2_Irreducible) == 0); + if (p.pLeft != null || p.pRight != null || p.pColl != null || p.x.pList != null || p.x.pSelect != null) { + nSize = EXPR_REDUCEDSIZE | EP_Reduced; + } else { + nSize = EXPR_TOKENONLYSIZE | EP_TokenOnly; + } + } + return nSize; } - } - return nByte; - } - /* - ** This function is similar to sqlite3ExprDup(), except that if pzBuffer - ** is not NULL then *pzBuffer is assumed to point to a buffer large enough - ** to store the copy of expression p, the copies of p->u.zToken - ** (if applicable), and the copies of the p->pLeft and p->pRight expressions, - ** if any. Before returning, *pzBuffer is set to the first byte passed the - ** portion of the buffer copied into by this function. - */ - static Expr exprDup( sqlite3 db, Expr p, int flags, ref Expr pzBuffer ) - { - Expr pNew = null; /* Value to return */ - if ( p != null ) - { - bool isReduced = ( flags & EXPRDUP_REDUCE ) != 0; - ////Expr zAlloc = new Expr(); - u32 staticFlag = 0; - - Debug.Assert( pzBuffer == null || isReduced ); - - /* Figure out where to write the new Expr structure. */ - //if ( pzBuffer !=null) - //{ - // zAlloc = pzBuffer; - // staticFlag = EP_Static; - //} - //else - //{ - ///Expr zAlloc = new Expr();//sqlite3DbMallocRaw( db, dupedExprSize( p, flags ) ); - //} - // (Expr)zAlloc; - - //if ( pNew != null ) - { - /* Set nNewSize to the size allocated for the structure pointed to - ** by pNew. This is either EXPR_FULLSIZE, EXPR_REDUCEDSIZE or - ** EXPR_TOKENONLYSIZE. nToken is set to the number of bytes consumed - ** by the copy of the p->u.zToken string (if any). - */ - int nStructSize = dupedExprStructSize( p, flags ); - ////int nNewSize = nStructSize & 0xfff; - ////int nToken; - ////if ( !ExprHasProperty( p, EP_IntValue ) && !string.IsNullOrEmpty( p.u.zToken ) ) - ////{ - //// nToken = sqlite3Strlen30( p.u.zToken ); - ////} - ////else - ////{ - //// nToken = 0; - ////} - if ( isReduced ) - { - Debug.Assert( !ExprHasProperty( p, EP_Reduced ) ); - pNew = p.Copy( EXPR_TOKENONLYSIZE );////memcpy( zAlloc, p, nNewSize ); - } - else - { - ////int nSize = exprStructSize( p ); - ////memcpy( zAlloc, p, nSize ); - pNew = p.Copy(); - ////memset( &zAlloc[nSize], 0, EXPR_FULLSIZE - nSize ); - } + /* + ** This function returns the space in bytes required to store the copy + ** of the Expr structure and a copy of the Expr.u.zToken string (if that + ** string is defined.) + */ + static int dupedExprNodeSize(Expr p, int flags) { + int nByte = dupedExprStructSize(p, flags) & 0xfff; + if (!ExprHasProperty(p, EP_IntValue) && p.u.zToken != null) { + nByte += sqlite3Strlen30(p.u.zToken) + 1; + } + return ROUND8(nByte); + } - /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */ - unchecked - { - pNew.flags &= (ushort)( ~( EP_Reduced | EP_TokenOnly | EP_Static ) ); - } - pNew.flags |= (ushort)( nStructSize & ( EP_Reduced | EP_TokenOnly ) ); - pNew.flags |= (ushort)staticFlag; + /* + ** Return the number of bytes required to create a duplicate of the + ** expression passed as the first argument. The second argument is a + ** mask containing EXPRDUP_XXX flags. + ** + ** The value returned includes space to create a copy of the Expr struct + ** itself and the buffer referred to by Expr.u.zToken, if any. + ** + ** If the EXPRDUP_REDUCE flag is set, then the return value includes + ** space to duplicate all Expr nodes in the tree formed by Expr.pLeft + ** and Expr.pRight variables (but not for any structures pointed to or + ** descended from the Expr.x.pList or Expr.x.pSelect variables). + */ + static int dupedExprSize(Expr p, int flags) { + int nByte = 0; + if (p != null) { + nByte = dupedExprNodeSize(p, flags); + if ((flags & EXPRDUP_REDUCE) != 0) { + nByte += dupedExprSize(p.pLeft, flags) + dupedExprSize(p.pRight, flags); + } + } + return nByte; + } - /* Copy the p->u.zToken string, if any. */ - ////if ( nToken != 0 ) - ////{ - //// string zToken;// = pNew.u.zToken = (char)&zAlloc[nNewSize]; - //// zToken = p.u.zToken.Substring( 0, nToken );// memcpy( zToken, p.u.zToken, nToken ); - ////} + /* + ** This function is similar to sqlite3ExprDup(), except that if pzBuffer + ** is not NULL then *pzBuffer is assumed to point to a buffer large enough + ** to store the copy of expression p, the copies of p->u.zToken + ** (if applicable), and the copies of the p->pLeft and p->pRight expressions, + ** if any. Before returning, *pzBuffer is set to the first byte passed the + ** portion of the buffer copied into by this function. + */ + static Expr exprDup(sqlite3 db, Expr p, int flags, ref Expr pzBuffer) { + Expr pNew = null; /* Value to return */ + if (p != null) { + bool isReduced = (flags & EXPRDUP_REDUCE) != 0; + ////Expr zAlloc = new Expr(); + u32 staticFlag = 0; + + Debug.Assert(pzBuffer == null || isReduced); + + /* Figure out where to write the new Expr structure. */ + //if ( pzBuffer !=null) + //{ + // zAlloc = pzBuffer; + // staticFlag = EP_Static; + //} + //else + //{ + ///Expr zAlloc = new Expr();//sqlite3DbMallocRaw( db, dupedExprSize( p, flags ) ); + //} + // (Expr)zAlloc; + + //if ( pNew != null ) + { + /* Set nNewSize to the size allocated for the structure pointed to + ** by pNew. This is either EXPR_FULLSIZE, EXPR_REDUCEDSIZE or + ** EXPR_TOKENONLYSIZE. nToken is set to the number of bytes consumed + ** by the copy of the p->u.zToken string (if any). + */ + int nStructSize = dupedExprStructSize(p, flags); + ////int nNewSize = nStructSize & 0xfff; + ////int nToken; + ////if ( !ExprHasProperty( p, EP_IntValue ) && !string.IsNullOrEmpty( p.u.zToken ) ) + ////{ + //// nToken = sqlite3Strlen30( p.u.zToken ); + ////} + ////else + ////{ + //// nToken = 0; + ////} + if (isReduced) { + Debug.Assert(!ExprHasProperty(p, EP_Reduced)); + pNew = p.Copy(EXPR_TOKENONLYSIZE);////memcpy( zAlloc, p, nNewSize ); + } else { + ////int nSize = exprStructSize( p ); + ////memcpy( zAlloc, p, nSize ); + pNew = p.Copy(); + ////memset( &zAlloc[nSize], 0, EXPR_FULLSIZE - nSize ); + } - if ( 0 == ( ( p.flags | pNew.flags ) & EP_TokenOnly ) ) - { - /* Fill in the pNew.x.pSelect or pNew.x.pList member. */ - if ( ExprHasProperty( p, EP_xIsSelect ) ) - { - pNew.x.pSelect = sqlite3SelectDup( db, p.x.pSelect, isReduced ? 1 : 0 ); - } - else - { - pNew.x.pList = sqlite3ExprListDup( db, p.x.pList, isReduced ? 1 : 0 ); - } - } + /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */ + unchecked { + pNew.flags &= (ushort)(~(EP_Reduced | EP_TokenOnly | EP_Static)); + } + pNew.flags |= (ushort)(nStructSize & (EP_Reduced | EP_TokenOnly)); + pNew.flags |= (ushort)staticFlag; + + /* Copy the p->u.zToken string, if any. */ + ////if ( nToken != 0 ) + ////{ + //// string zToken;// = pNew.u.zToken = (char)&zAlloc[nNewSize]; + //// zToken = p.u.zToken.Substring( 0, nToken );// memcpy( zToken, p.u.zToken, nToken ); + ////} + + if (0 == ((p.flags | pNew.flags) & EP_TokenOnly)) { + /* Fill in the pNew.x.pSelect or pNew.x.pList member. */ + if (ExprHasProperty(p, EP_xIsSelect)) { + pNew.x.pSelect = sqlite3SelectDup(db, p.x.pSelect, isReduced ? 1 : 0); + } else { + pNew.x.pList = sqlite3ExprListDup(db, p.x.pList, isReduced ? 1 : 0); + } + } - /* Fill in pNew.pLeft and pNew.pRight. */ - if ( ExprHasAnyProperty( pNew, EP_Reduced | EP_TokenOnly ) ) - { - //zAlloc += dupedExprNodeSize( p, flags ); - if ( ExprHasProperty( pNew, EP_Reduced ) ) - { - pNew.pLeft = exprDup( db, p.pLeft, EXPRDUP_REDUCE, ref pzBuffer ); - pNew.pRight = exprDup( db, p.pRight, EXPRDUP_REDUCE, ref pzBuffer ); - } - //if ( pzBuffer != null ) - //{ - // pzBuffer = zAlloc; - //} - } - else - { - pNew.flags2 = 0; - if ( !ExprHasAnyProperty( p, EP_TokenOnly ) ) - { - pNew.pLeft = sqlite3ExprDup( db, p.pLeft, 0 ); - pNew.pRight = sqlite3ExprDup( db, p.pRight, 0 ); + /* Fill in pNew.pLeft and pNew.pRight. */ + if (ExprHasAnyProperty(pNew, EP_Reduced | EP_TokenOnly)) { + //zAlloc += dupedExprNodeSize( p, flags ); + if (ExprHasProperty(pNew, EP_Reduced)) { + pNew.pLeft = exprDup(db, p.pLeft, EXPRDUP_REDUCE, ref pzBuffer); + pNew.pRight = exprDup(db, p.pRight, EXPRDUP_REDUCE, ref pzBuffer); + } + //if ( pzBuffer != null ) + //{ + // pzBuffer = zAlloc; + //} + } else { + pNew.flags2 = 0; + if (!ExprHasAnyProperty(p, EP_TokenOnly)) { + pNew.pLeft = sqlite3ExprDup(db, p.pLeft, 0); + pNew.pRight = sqlite3ExprDup(db, p.pRight, 0); + } + } + } } - } + return pNew; } - } - return pNew; - } - /* - ** The following group of routines make deep copies of expressions, - ** expression lists, ID lists, and select statements. The copies can - ** be deleted (by being passed to their respective ...Delete() routines) - ** without effecting the originals. - ** - ** The expression list, ID, and source lists return by sqlite3ExprListDup(), - ** sqlite3IdListDup(), and sqlite3SrcListDup() can not be further expanded - ** by subsequent calls to sqlite*ListAppend() routines. - ** - ** Any tables that the SrcList might point to are not duplicated. - ** - ** The flags parameter contains a combination of the EXPRDUP_XXX flags. - ** If the EXPRDUP_REDUCE flag is set, then the structure returned is a - ** truncated version of the usual Expr structure that will be stored as - ** part of the in-memory representation of the database schema. - */ - static Expr sqlite3ExprDup( sqlite3 db, Expr p, int flags ) - { - Expr ExprDummy = null; - return exprDup( db, p, flags, ref ExprDummy ); - } + /* + ** The following group of routines make deep copies of expressions, + ** expression lists, ID lists, and select statements. The copies can + ** be deleted (by being passed to their respective ...Delete() routines) + ** without effecting the originals. + ** + ** The expression list, ID, and source lists return by sqlite3ExprListDup(), + ** sqlite3IdListDup(), and sqlite3SrcListDup() can not be further expanded + ** by subsequent calls to sqlite*ListAppend() routines. + ** + ** Any tables that the SrcList might point to are not duplicated. + ** + ** The flags parameter contains a combination of the EXPRDUP_XXX flags. + ** If the EXPRDUP_REDUCE flag is set, then the structure returned is a + ** truncated version of the usual Expr structure that will be stored as + ** part of the in-memory representation of the database schema. + */ + static Expr sqlite3ExprDup(sqlite3 db, Expr p, int flags) { + Expr ExprDummy = null; + return exprDup(db, p, flags, ref ExprDummy); + } - static ExprList sqlite3ExprListDup( sqlite3 db, ExprList p, int flags ) - { - ExprList pNew; - ExprList_item pItem; - ExprList_item pOldItem; - - if ( p == null ) - return null; - pNew = new ExprList();//sqlite3DbMallocRaw(db, sizeof(*pNew) ); - //if ( pNew == null ) return null; - pNew.iECursor = 0; - pNew.nExpr = pNew.nAlloc = p.nExpr; - pNew.a = new ExprList_item[p.nExpr];//sqlite3DbMallocRaw(db, p.nExpr*sizeof(p.a[0]) ); - //if( pItem==null ){ - // sqlite3DbFree(db,ref pNew); - // return null; - //} - //pOldItem = p.a; - for (int i = 0; i < p.nExpr; i++ ) - {//pItem++, pOldItem++){ - pItem = pNew.a[i] = new ExprList_item(); - pOldItem = p.a[i]; - Expr pOldExpr = pOldItem.pExpr; - pItem.pExpr = sqlite3ExprDup( db, pOldExpr, flags ); - pItem.zName = pOldItem.zName;// sqlite3DbStrDup(db, pOldItem.zName); - pItem.zSpan = pOldItem.zSpan;// sqlite3DbStrDup( db, pOldItem.zSpan ); - pItem.sortOrder = pOldItem.sortOrder; - pItem.done = 0; - pItem.iCol = pOldItem.iCol; - pItem.iAlias = pOldItem.iAlias; - } - return pNew; - } + static ExprList sqlite3ExprListDup(sqlite3 db, ExprList p, int flags) { + ExprList pNew; + ExprList_item pItem; + ExprList_item pOldItem; + + if (p == null) + return null; + pNew = new ExprList();//sqlite3DbMallocRaw(db, sizeof(*pNew) ); + //if ( pNew == null ) return null; + pNew.iECursor = 0; + pNew.nExpr = pNew.nAlloc = p.nExpr; + pNew.a = new ExprList_item[p.nExpr];//sqlite3DbMallocRaw(db, p.nExpr*sizeof(p.a[0]) ); + //if( pItem==null ){ + // sqlite3DbFree(db,ref pNew); + // return null; + //} + //pOldItem = p.a; + for (int i = 0; i < p.nExpr; i++) {//pItem++, pOldItem++){ + pItem = pNew.a[i] = new ExprList_item(); + pOldItem = p.a[i]; + Expr pOldExpr = pOldItem.pExpr; + pItem.pExpr = sqlite3ExprDup(db, pOldExpr, flags); + pItem.zName = pOldItem.zName;// sqlite3DbStrDup(db, pOldItem.zName); + pItem.zSpan = pOldItem.zSpan;// sqlite3DbStrDup( db, pOldItem.zSpan ); + pItem.sortOrder = pOldItem.sortOrder; + pItem.done = 0; + pItem.iCol = pOldItem.iCol; + pItem.iAlias = pOldItem.iAlias; + } + return pNew; + } - /* - ** If cursors, triggers, views and subqueries are all omitted from - ** the build, then none of the following routines, except for - ** sqlite3SelectDup(), can be called. sqlite3SelectDup() is sometimes - ** called with a NULL argument. - */ -#if !SQLITE_OMIT_VIEW || !SQLITE_OMIT_TRIGGER || !SQLITE_OMIT_SUBQUERY - static SrcList sqlite3SrcListDup( sqlite3 db, SrcList p, int flags ) - { - SrcList pNew; - int nByte; - if ( p == null ) - return null; - //nByte = sizeof(*p) + (p.nSrc>0 ? sizeof(p.a[0]) * (p.nSrc-1) : 0); - pNew = new SrcList();//sqlite3DbMallocRaw(db, nByte ); - if ( p.nSrc > 0 ) - pNew.a = new SrcList_item[p.nSrc]; - if ( pNew == null ) - return null; - pNew.nSrc = pNew.nAlloc = p.nSrc; - for (int i = 0; i < p.nSrc; i++ ) - { - pNew.a[i] = new SrcList_item(); - SrcList_item pNewItem = pNew.a[i]; - SrcList_item pOldItem = p.a[i]; - Table pTab; - pNewItem.zDatabase = pOldItem.zDatabase;// sqlite3DbStrDup(db, pOldItem.zDatabase); - pNewItem.zName = pOldItem.zName;// sqlite3DbStrDup(db, pOldItem.zName); - pNewItem.zAlias = pOldItem.zAlias;// sqlite3DbStrDup(db, pOldItem.zAlias); - pNewItem.jointype = pOldItem.jointype; - pNewItem.iCursor = pOldItem.iCursor; - pNewItem.isPopulated = pOldItem.isPopulated; - pNewItem.zIndex = pOldItem.zIndex;// sqlite3DbStrDup( db, pOldItem.zIndex ); - pNewItem.notIndexed = pOldItem.notIndexed; - pNewItem.pIndex = pOldItem.pIndex; - pTab = pNewItem.pTab = pOldItem.pTab; - if ( pTab != null ) - { - pTab.nRef++; + /* + ** If cursors, triggers, views and subqueries are all omitted from + ** the build, then none of the following routines, except for + ** sqlite3SelectDup(), can be called. sqlite3SelectDup() is sometimes + ** called with a NULL argument. + */ +#if !SQLITE_OMIT_VIEW || !SQLITE_OMIT_TRIGGER || !SQLITE_OMIT_SUBQUERY + static SrcList sqlite3SrcListDup(sqlite3 db, SrcList p, int flags) { + SrcList pNew; + int nByte; + if (p == null) + return null; + //nByte = sizeof(*p) + (p.nSrc>0 ? sizeof(p.a[0]) * (p.nSrc-1) : 0); + pNew = new SrcList();//sqlite3DbMallocRaw(db, nByte ); + if (p.nSrc > 0) + pNew.a = new SrcList_item[p.nSrc]; + if (pNew == null) + return null; + pNew.nSrc = pNew.nAlloc = p.nSrc; + for (int i = 0; i < p.nSrc; i++) { + pNew.a[i] = new SrcList_item(); + SrcList_item pNewItem = pNew.a[i]; + SrcList_item pOldItem = p.a[i]; + Table pTab; + pNewItem.zDatabase = pOldItem.zDatabase;// sqlite3DbStrDup(db, pOldItem.zDatabase); + pNewItem.zName = pOldItem.zName;// sqlite3DbStrDup(db, pOldItem.zName); + pNewItem.zAlias = pOldItem.zAlias;// sqlite3DbStrDup(db, pOldItem.zAlias); + pNewItem.jointype = pOldItem.jointype; + pNewItem.iCursor = pOldItem.iCursor; + pNewItem.isPopulated = pOldItem.isPopulated; + pNewItem.zIndex = pOldItem.zIndex;// sqlite3DbStrDup( db, pOldItem.zIndex ); + pNewItem.notIndexed = pOldItem.notIndexed; + pNewItem.pIndex = pOldItem.pIndex; + pTab = pNewItem.pTab = pOldItem.pTab; + if (pTab != null) { + pTab.nRef++; + } + pNewItem.pSelect = sqlite3SelectDup(db, pOldItem.pSelect, flags); + pNewItem.pOn = sqlite3ExprDup(db, pOldItem.pOn, flags); + pNewItem.pUsing = sqlite3IdListDup(db, pOldItem.pUsing); + pNewItem.colUsed = pOldItem.colUsed; + } + return pNew; } - pNewItem.pSelect = sqlite3SelectDup( db, pOldItem.pSelect, flags ); - pNewItem.pOn = sqlite3ExprDup( db, pOldItem.pOn, flags ); - pNewItem.pUsing = sqlite3IdListDup( db, pOldItem.pUsing ); - pNewItem.colUsed = pOldItem.colUsed; - } - return pNew; - } - static IdList sqlite3IdListDup( sqlite3 db, IdList p ) - { - IdList pNew; - int i; - if ( p == null ) - return null; - pNew = new IdList();//sqlite3DbMallocRaw(db, sizeof(*pNew) ); - if ( pNew == null ) - return null; - pNew.nId = pNew.nAlloc = p.nId; - pNew.a = new IdList_item[p.nId];//sqlite3DbMallocRaw(db, p.nId*sizeof(p.a[0]) ); - if ( pNew.a == null ) - { - sqlite3DbFree( db, ref pNew ); - return null; - } - for ( i = 0; i < p.nId; i++ ) - { - pNew.a[i] = new IdList_item(); - IdList_item pNewItem = pNew.a[i]; - IdList_item pOldItem = p.a[i]; - pNewItem.zName = pOldItem.zName;// sqlite3DbStrDup(db, pOldItem.zName); - pNewItem.idx = pOldItem.idx; - } - return pNew; - } + static IdList sqlite3IdListDup(sqlite3 db, IdList p) { + IdList pNew; + int i; + if (p == null) + return null; + pNew = new IdList();//sqlite3DbMallocRaw(db, sizeof(*pNew) ); + if (pNew == null) + return null; + pNew.nId = pNew.nAlloc = p.nId; + pNew.a = new IdList_item[p.nId];//sqlite3DbMallocRaw(db, p.nId*sizeof(p.a[0]) ); + if (pNew.a == null) { + sqlite3DbFree(db, ref pNew); + return null; + } + for (i = 0; i < p.nId; i++) { + pNew.a[i] = new IdList_item(); + IdList_item pNewItem = pNew.a[i]; + IdList_item pOldItem = p.a[i]; + pNewItem.zName = pOldItem.zName;// sqlite3DbStrDup(db, pOldItem.zName); + pNewItem.idx = pOldItem.idx; + } + return pNew; + } - static Select sqlite3SelectDup( sqlite3 db, Select p, int flags ) - { - Select pNew; - if ( p == null ) - return null; - pNew = new Select();//sqlite3DbMallocRaw(db, sizeof(*p) ); - //if ( pNew == null ) return null; - pNew.pEList = sqlite3ExprListDup( db, p.pEList, flags ); - pNew.pSrc = sqlite3SrcListDup( db, p.pSrc, flags ); - pNew.pWhere = sqlite3ExprDup( db, p.pWhere, flags ); - pNew.pGroupBy = sqlite3ExprListDup( db, p.pGroupBy, flags ); - pNew.pHaving = sqlite3ExprDup( db, p.pHaving, flags ); - pNew.pOrderBy = sqlite3ExprListDup( db, p.pOrderBy, flags ); - pNew.op = p.op; - pNew.pPrior = sqlite3SelectDup( db, p.pPrior, flags ); - pNew.pLimit = sqlite3ExprDup( db, p.pLimit, flags ); - pNew.pOffset = sqlite3ExprDup( db, p.pOffset, flags ); - pNew.iLimit = 0; - pNew.iOffset = 0; - pNew.selFlags = (u16)( p.selFlags & ~SF_UsesEphemeral ); - pNew.pRightmost = null; - pNew.addrOpenEphm[0] = -1; - pNew.addrOpenEphm[1] = -1; - pNew.addrOpenEphm[2] = -1; - return pNew; - } + static Select sqlite3SelectDup(sqlite3 db, Select p, int flags) { + Select pNew; + if (p == null) + return null; + pNew = new Select();//sqlite3DbMallocRaw(db, sizeof(*p) ); + //if ( pNew == null ) return null; + pNew.pEList = sqlite3ExprListDup(db, p.pEList, flags); + pNew.pSrc = sqlite3SrcListDup(db, p.pSrc, flags); + pNew.pWhere = sqlite3ExprDup(db, p.pWhere, flags); + pNew.pGroupBy = sqlite3ExprListDup(db, p.pGroupBy, flags); + pNew.pHaving = sqlite3ExprDup(db, p.pHaving, flags); + pNew.pOrderBy = sqlite3ExprListDup(db, p.pOrderBy, flags); + pNew.op = p.op; + pNew.pPrior = sqlite3SelectDup(db, p.pPrior, flags); + pNew.pLimit = sqlite3ExprDup(db, p.pLimit, flags); + pNew.pOffset = sqlite3ExprDup(db, p.pOffset, flags); + pNew.iLimit = 0; + pNew.iOffset = 0; + pNew.selFlags = (u16)(p.selFlags & ~SF_UsesEphemeral); + pNew.pRightmost = null; + pNew.addrOpenEphm[0] = -1; + pNew.addrOpenEphm[1] = -1; + pNew.addrOpenEphm[2] = -1; + return pNew; + } #else Select sqlite3SelectDup(sqlite3 db, Select p, int flags){ Debug.Assert( p==null ); @@ -1213,1212 +1065,1102 @@ Select sqlite3SelectDup(sqlite3 db, Select p, int flags){ #endif - /* -** Add a new element to the end of an expression list. If pList is -** initially NULL, then create a new expression list. -** -** If a memory allocation error occurs, the entire list is freed and -** NULL is returned. If non-NULL is returned, then it is guaranteed -** that the new entry was successfully appended. -*/ - // OVERLOADS, so I don't need to rewrite parse.c - static ExprList sqlite3ExprListAppend( Parse pParse, int null_2, Expr pExpr ) - { - return sqlite3ExprListAppend( pParse, null, pExpr ); - } - static ExprList sqlite3ExprListAppend( - Parse pParse, /* Parsing context */ - ExprList pList, /* List to which to append. Might be NULL */ - Expr pExpr /* Expression to be appended. Might be NULL */ - ) - { - ////sqlite3 db = pParse.db; - if ( pList == null ) - { - pList = new ExprList(); //sqlite3DbMallocZero(db, ExprList).Length; - //if ( pList == null ) - //{ - // goto no_mem; - //} - Debug.Assert( pList.nAlloc == 0 ); - } - if ( pList.nAlloc <= pList.nExpr ) - { - ExprList_item a; - int n = pList.nAlloc * 2 + 4; - //a = sqlite3DbRealloc(db, pList.a, n*sizeof(pList.a[0])); - //if( a==0 ){ - // goto no_mem; - //} - Array.Resize( ref pList.a, n );// = a; - pList.nAlloc = pList.a.Length;// sqlite3DbMallocSize(db, a)/sizeof(a[0]); - } - Debug.Assert( pList.a != null ); - if ( true ) - { - pList.a[pList.nExpr] = new ExprList_item(); - //ExprList_item pItem = pList.a[pList.nExpr++]; - //pItem = new ExprList_item();//memset(pItem, 0, sizeof(*pItem)); - //pItem.pExpr = pExpr; - pList.a[pList.nExpr++].pExpr = pExpr; - } - return pList; - - //no_mem: - // /* Avoid leaking memory if malloc has failed. */ - // sqlite3ExprDelete( db, ref pExpr ); - // sqlite3ExprListDelete( db, ref pList ); - // return null; - } - - /* - ** Set the ExprList.a[].zName element of the most recently added item - ** on the expression list. - ** - ** pList might be NULL following an OOM error. But pName should never be - ** NULL. If a memory allocation fails, the pParse.db.mallocFailed flag - ** is set. - */ - static void sqlite3ExprListSetName( - Parse pParse, /* Parsing context */ - ExprList pList, /* List to which to add the span. */ - Token pName, /* Name to be added */ - int dequote /* True to cause the name to be dequoted */ - ) - { - Debug.Assert( pList != null /* || pParse.db.mallocFailed != 0 */ ); - if ( pList != null ) - { - ExprList_item pItem; - Debug.Assert( pList.nExpr > 0 ); - pItem = pList.a[pList.nExpr - 1]; - Debug.Assert( pItem.zName == null ); - pItem.zName = pName.z.Substring( 0, pName.n );//sqlite3DbStrNDup(pParse.db, pName.z, pName.n); - if ( dequote != 0 && !string.IsNullOrEmpty( pItem.zName ) ) - sqlite3Dequote( ref pItem.zName ); - } - } - - /* - ** Set the ExprList.a[].zSpan element of the most recently added item - ** on the expression list. + /* + ** Add a new element to the end of an expression list. If pList is + ** initially NULL, then create a new expression list. ** - ** pList might be NULL following an OOM error. But pSpan should never be - ** NULL. If a memory allocation fails, the pParse.db.mallocFailed flag - ** is set. + ** If a memory allocation error occurs, the entire list is freed and + ** NULL is returned. If non-NULL is returned, then it is guaranteed + ** that the new entry was successfully appended. */ - static void sqlite3ExprListSetSpan( - Parse pParse, /* Parsing context */ - ExprList pList, /* List to which to add the span. */ - ExprSpan pSpan /* The span to be added */ - ) - { - sqlite3 db = pParse.db; - Debug.Assert( pList != null /*|| db.mallocFailed != 0 */ ); - if ( pList != null ) - { - ExprList_item pItem = pList.a[pList.nExpr - 1]; - Debug.Assert( pList.nExpr > 0 ); - Debug.Assert( /* db.mallocFailed != 0 || */ pItem.pExpr == pSpan.pExpr ); - sqlite3DbFree( db, ref pItem.zSpan ); - pItem.zSpan = pSpan.zStart.Substring( 0, pSpan.zStart.Length <= pSpan.zEnd.Length ? pSpan.zStart.Length : pSpan.zStart.Length - pSpan.zEnd.Length );// sqlite3DbStrNDup( db, pSpan.zStart, - //(int)( pSpan.zEnd- pSpan.zStart) ); - } - } - - /* - ** If the expression list pEList contains more than iLimit elements, - ** leave an error message in pParse. - */ - static void sqlite3ExprListCheckLength( - Parse pParse, - ExprList pEList, - string zObject - ) - { - int mx = pParse.db.aLimit[SQLITE_LIMIT_COLUMN]; - testcase( pEList != null && pEList.nExpr == mx ); - testcase( pEList != null && pEList.nExpr == mx + 1 ); - if ( pEList != null && pEList.nExpr > mx ) - { - sqlite3ErrorMsg( pParse, "too many columns in %s", zObject ); - } - } - - - /* - ** Delete an entire expression list. - */ - static void sqlite3ExprListDelete( sqlite3 db, ref ExprList pList ) - { - int i; - ExprList_item pItem; - if ( pList == null ) - return; - Debug.Assert( pList.a != null || ( pList.nExpr == 0 && pList.nAlloc == 0 ) ); - Debug.Assert( pList.nExpr <= pList.nAlloc ); - for ( i = 0; i < pList.nExpr; i++ ) - { - if ( ( pItem = pList.a[i] ) != null ) - { - sqlite3ExprDelete( db, ref pItem.pExpr ); - sqlite3DbFree( db, ref pItem.zName ); - sqlite3DbFree( db, ref pItem.zSpan ); + // OVERLOADS, so I don't need to rewrite parse.c + static ExprList sqlite3ExprListAppend(Parse pParse, int null_2, Expr pExpr) { + return sqlite3ExprListAppend(pParse, null, pExpr); } - } - sqlite3DbFree( db, ref pList.a ); - sqlite3DbFree( db, ref pList ); - } - - /* - ** These routines are Walker callbacks. Walker.u.pi is a pointer - ** to an integer. These routines are checking an expression to see - ** if it is a constant. Set *Walker.u.pi to 0 if the expression is - ** not constant. - ** - ** These callback routines are used to implement the following: - ** - ** sqlite3ExprIsConstant() - ** sqlite3ExprIsConstantNotJoin() - ** sqlite3ExprIsConstantOrFunction() - ** - */ - static int exprNodeIsConstant( Walker pWalker, ref 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 && ExprHasAnyProperty( pExpr, EP_FromJoin ) ) - { - pWalker.u.i = 0; - return WRC_Abort; - } - - switch ( pExpr.op ) - { - /* Consider functions to be constant if all their arguments are constant - ** and pWalker.u.i==2 */ - case TK_FUNCTION: - if ( ( pWalker.u.i ) == 2 ) - return 0; - goto case TK_ID; - /* Fall through */ - case TK_ID: - case TK_COLUMN: - case TK_AGG_FUNCTION: - case TK_AGG_COLUMN: - testcase( pExpr.op == TK_ID ); - testcase( pExpr.op == TK_COLUMN ); - testcase( pExpr.op == TK_AGG_FUNCTION ); - testcase( pExpr.op == TK_AGG_COLUMN ); - pWalker.u.i = 0; - return WRC_Abort; - default: - testcase( pExpr.op == TK_SELECT ); /* selectNodeIsConstant will disallow */ - testcase( pExpr.op == TK_EXISTS ); /* selectNodeIsConstant will disallow */ - return WRC_Continue; - } - } - - static int selectNodeIsConstant( Walker pWalker, Select NotUsed ) - { - UNUSED_PARAMETER( NotUsed ); - pWalker.u.i = 0; - return WRC_Abort; - } - static int exprIsConst( Expr p, int initFlag ) - { - Walker w = new Walker(); - w.u.i = initFlag; - w.xExprCallback = exprNodeIsConstant; - w.xSelectCallback = selectNodeIsConstant; - sqlite3WalkExpr( w, ref p ); - return w.u.i; - } - - /* - ** Walk an expression tree. Return 1 if the expression is constant - ** and 0 if it involves variables or function calls. - ** - ** For the purposes of this function, a double-quoted string (ex: "abc") - ** is considered a variable but a single-quoted string (ex: 'abc') is - ** a constant. - */ - static int sqlite3ExprIsConstant( Expr p ) - { - return exprIsConst( p, 1 ); - } + static ExprList sqlite3ExprListAppend( + Parse pParse, /* Parsing context */ + ExprList pList, /* List to which to append. Might be NULL */ + Expr pExpr /* Expression to be appended. Might be NULL */ + ) { + ////sqlite3 db = pParse.db; + if (pList == null) { + pList = new ExprList(); //sqlite3DbMallocZero(db, ExprList).Length; + //if ( pList == null ) + //{ + // goto no_mem; + //} + Debug.Assert(pList.nAlloc == 0); + } + if (pList.nAlloc <= pList.nExpr) { + ExprList_item a; + int n = pList.nAlloc * 2 + 4; + //a = sqlite3DbRealloc(db, pList.a, n*sizeof(pList.a[0])); + //if( a==0 ){ + // goto no_mem; + //} + Array.Resize(ref pList.a, n);// = a; + pList.nAlloc = pList.a.Length;// sqlite3DbMallocSize(db, a)/sizeof(a[0]); + } + Debug.Assert(pList.a != null); + if (true) { + pList.a[pList.nExpr] = new ExprList_item(); + //ExprList_item pItem = pList.a[pList.nExpr++]; + //pItem = new ExprList_item();//memset(pItem, 0, sizeof(*pItem)); + //pItem.pExpr = pExpr; + pList.a[pList.nExpr++].pExpr = pExpr; + } + return pList; - /* - ** Walk an expression tree. Return 1 if the expression is constant - ** that does no originate from the ON or USING clauses of a join. - ** Return 0 if it involves variables or function calls or terms from - ** an ON or USING clause. - */ - static int sqlite3ExprIsConstantNotJoin( Expr p ) - { - return exprIsConst( p, 3 ); - } + //no_mem: + // /* Avoid leaking memory if malloc has failed. */ + // sqlite3ExprDelete( db, ref pExpr ); + // sqlite3ExprListDelete( db, ref pList ); + // return null; + } - /* - ** Walk an expression tree. Return 1 if the expression is constant - ** or a function call with constant arguments. Return and 0 if there - ** are any variables. - ** - ** For the purposes of this function, a double-quoted string (ex: "abc") - ** is considered a variable but a single-quoted string (ex: 'abc') is - ** a constant. - */ - static int sqlite3ExprIsConstantOrFunction( Expr p ) - { - return exprIsConst( p, 2 ); - } + /* + ** Set the ExprList.a[].zName element of the most recently added item + ** on the expression list. + ** + ** pList might be NULL following an OOM error. But pName should never be + ** NULL. If a memory allocation fails, the pParse.db.mallocFailed flag + ** is set. + */ + static void sqlite3ExprListSetName( + Parse pParse, /* Parsing context */ + ExprList pList, /* List to which to add the span. */ + Token pName, /* Name to be added */ + int dequote /* True to cause the name to be dequoted */ + ) { + Debug.Assert(pList != null /* || pParse.db.mallocFailed != 0 */ ); + if (pList != null) { + ExprList_item pItem; + Debug.Assert(pList.nExpr > 0); + pItem = pList.a[pList.nExpr - 1]; + Debug.Assert(pItem.zName == null); + pItem.zName = pName.z.Substring(0, pName.n);//sqlite3DbStrNDup(pParse.db, pName.z, pName.n); + if (dequote != 0 && !string.IsNullOrEmpty(pItem.zName)) + sqlite3Dequote(ref pItem.zName); + } + } - /* - ** If the expression p codes a constant integer that is small enough - ** to fit in a 32-bit integer, return 1 and put the value of the integer - ** in pValue. If the expression is not an integer or if it is too big - ** to fit in a signed 32-bit integer, return 0 and leave pValue unchanged. - */ - static int sqlite3ExprIsInteger( Expr p, ref int pValue ) - { - int rc = 0; - - /* If an expression is an integer literal that fits in a signed 32-bit - ** integer, then the EP_IntValue flag will have already been set */ - Debug.Assert( p.op != TK_INTEGER || ( p.flags & EP_IntValue ) != 0 - || !sqlite3GetInt32( p.u.zToken, ref rc ) ); - - if ( ( p.flags & EP_IntValue ) != 0 ) - { - pValue = (int)p.u.iValue; - return 1; - } - switch ( p.op ) - { - case TK_UPLUS: - { - rc = sqlite3ExprIsInteger( p.pLeft, ref pValue ); - break; - } - case TK_UMINUS: - { - int v = 0; - if ( sqlite3ExprIsInteger( p.pLeft, ref v ) != 0 ) - { - pValue = -v; - rc = 1; + /* + ** Set the ExprList.a[].zSpan element of the most recently added item + ** on the expression list. + ** + ** pList might be NULL following an OOM error. But pSpan should never be + ** NULL. If a memory allocation fails, the pParse.db.mallocFailed flag + ** is set. + */ + static void sqlite3ExprListSetSpan( + Parse pParse, /* Parsing context */ + ExprList pList, /* List to which to add the span. */ + ExprSpan pSpan /* The span to be added */ + ) { + sqlite3 db = pParse.db; + Debug.Assert(pList != null /*|| db.mallocFailed != 0 */ ); + if (pList != null) { + ExprList_item pItem = pList.a[pList.nExpr - 1]; + Debug.Assert(pList.nExpr > 0); + Debug.Assert( /* db.mallocFailed != 0 || */ pItem.pExpr == pSpan.pExpr); + sqlite3DbFree(db, ref pItem.zSpan); + pItem.zSpan = pSpan.zStart.Substring(0, pSpan.zStart.Length <= pSpan.zEnd.Length ? pSpan.zStart.Length : pSpan.zStart.Length - pSpan.zEnd.Length);// sqlite3DbStrNDup( db, pSpan.zStart, + //(int)( pSpan.zEnd- pSpan.zStart) ); } - break; - } - default: - break; - } - return rc; - } + } - /* - ** Return FALSE if there is no chance that the expression can be NULL. - ** - ** If the expression might be NULL or if the expression is too complex - ** to tell return TRUE. - ** - ** This routine is used as an optimization, to skip OP_IsNull opcodes - ** when we know that a value cannot be NULL. Hence, a false positive - ** (returning TRUE when in fact the expression can never be NULL) might - ** be a small performance hit but is otherwise harmless. On the other - ** hand, a false negative (returning FALSE when the result could be NULL) - ** will likely result in an incorrect answer. So when in doubt, return - ** TRUE. - */ - static int sqlite3ExprCanBeNull( Expr p ) - { - u8 op; - while ( p.op == TK_UPLUS || p.op == TK_UMINUS ) - { - p = p.pLeft; - } - op = p.op; - if ( op == TK_REGISTER ) - op = p.op2; - switch ( op ) - { - case TK_INTEGER: - case TK_STRING: - case TK_FLOAT: - case TK_BLOB: - return 0; - default: - return 1; - } - } + /* + ** If the expression list pEList contains more than iLimit elements, + ** leave an error message in pParse. + */ + static void sqlite3ExprListCheckLength( + Parse pParse, + ExprList pEList, + string zObject + ) { + int mx = pParse.db.aLimit[SQLITE_LIMIT_COLUMN]; + testcase(pEList != null && pEList.nExpr == mx); + testcase(pEList != null && pEList.nExpr == mx + 1); + if (pEList != null && pEList.nExpr > mx) { + sqlite3ErrorMsg(pParse, "too many columns in %s", zObject); + } + } - /* - ** Generate an OP_IsNull instruction that tests register iReg and jumps - ** to location iDest if the value in iReg is NULL. The value in iReg - ** was computed by pExpr. If we can look at pExpr at compile-time and - ** determine that it can never generate a NULL, then the OP_IsNull operation - ** can be omitted. - */ - static void sqlite3ExprCodeIsNullJump( - Vdbe v, /* The VDBE under construction */ - Expr pExpr, /* Only generate OP_IsNull if this expr can be NULL */ - int iReg, /* Test the value in this register for NULL */ - int iDest /* Jump here if the value is null */ - ) - { - if ( sqlite3ExprCanBeNull( pExpr ) != 0 ) - { - sqlite3VdbeAddOp2( v, OP_IsNull, iReg, iDest ); - } - } - /* - ** Return TRUE if the given expression is a constant which would be - ** unchanged by OP_Affinity with the affinity given in the second - ** argument. - ** - ** This routine is used to determine if the OP_Affinity operation - ** can be omitted. When in doubt return FALSE. A false negative - ** is harmless. A false positive, however, can result in the wrong - ** answer. - */ - static int sqlite3ExprNeedsNoAffinityChange( Expr p, char aff ) - { - u8 op; - if ( aff == SQLITE_AFF_NONE ) - return 1; - while ( p.op == TK_UPLUS || p.op == TK_UMINUS ) - { - p = p.pLeft; - } - op = p.op; - if ( op == TK_REGISTER ) - op = p.op2; - switch ( op ) - { - case TK_INTEGER: - { - return ( aff == SQLITE_AFF_INTEGER || aff == SQLITE_AFF_NUMERIC ) ? 1 : 0; - } - case TK_FLOAT: - { - return ( aff == SQLITE_AFF_REAL || aff == SQLITE_AFF_NUMERIC ) ? 1 : 0; - } - case TK_STRING: - { - return ( aff == SQLITE_AFF_TEXT ) ? 1 : 0; - } - case TK_BLOB: - { - return 1; - } - case TK_COLUMN: - { - Debug.Assert( p.iTable >= 0 ); /* p cannot be part of a CHECK constraint */ - return ( p.iColumn < 0 - && ( aff == SQLITE_AFF_INTEGER || aff == SQLITE_AFF_NUMERIC ) ) ? 1 : 0; - } - default: - { - return 0; - } - } - } + /* + ** Delete an entire expression list. + */ + static void sqlite3ExprListDelete(sqlite3 db, ref ExprList pList) { + int i; + ExprList_item pItem; + if (pList == null) + return; + Debug.Assert(pList.a != null || (pList.nExpr == 0 && pList.nAlloc == 0)); + Debug.Assert(pList.nExpr <= pList.nAlloc); + for (i = 0; i < pList.nExpr; i++) { + if ((pItem = pList.a[i]) != null) { + sqlite3ExprDelete(db, ref pItem.pExpr); + sqlite3DbFree(db, ref pItem.zName); + sqlite3DbFree(db, ref pItem.zSpan); + } + } + sqlite3DbFree(db, ref pList.a); + sqlite3DbFree(db, ref pList); + } - /* - ** Return TRUE if the given string is a row-id column name. - */ - static bool sqlite3IsRowid( string z ) - { - if ( z.Equals( "_ROWID_", StringComparison.OrdinalIgnoreCase ) ) - return true; - if ( z.Equals( "ROWID", StringComparison.OrdinalIgnoreCase ) ) - return true; - if ( z.Equals( "OID", StringComparison.OrdinalIgnoreCase ) ) - return true; - return false; - } + /* + ** These routines are Walker callbacks. Walker.u.pi is a pointer + ** to an integer. These routines are checking an expression to see + ** if it is a constant. Set *Walker.u.pi to 0 if the expression is + ** not constant. + ** + ** These callback routines are used to implement the following: + ** + ** sqlite3ExprIsConstant() + ** sqlite3ExprIsConstantNotJoin() + ** sqlite3ExprIsConstantOrFunction() + ** + */ + static int exprNodeIsConstant(Walker pWalker, ref 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 && ExprHasAnyProperty(pExpr, EP_FromJoin)) { + pWalker.u.i = 0; + return WRC_Abort; + } + switch (pExpr.op) { + /* Consider functions to be constant if all their arguments are constant + ** and pWalker.u.i==2 */ + case TK_FUNCTION: + if ((pWalker.u.i) == 2) + return 0; + goto case TK_ID; + /* Fall through */ + case TK_ID: + case TK_COLUMN: + case TK_AGG_FUNCTION: + case TK_AGG_COLUMN: + testcase(pExpr.op == TK_ID); + testcase(pExpr.op == TK_COLUMN); + testcase(pExpr.op == TK_AGG_FUNCTION); + testcase(pExpr.op == TK_AGG_COLUMN); + pWalker.u.i = 0; + return WRC_Abort; + default: + testcase(pExpr.op == TK_SELECT); /* selectNodeIsConstant will disallow */ + testcase(pExpr.op == TK_EXISTS); /* selectNodeIsConstant will disallow */ + return WRC_Continue; + } + } - /* - ** Return true if we are able to the IN operator optimization on a - ** query of the form - ** - ** x IN (SELECT ...) - ** - ** Where the SELECT... clause is as specified by the parameter to this - ** routine. - ** - ** The Select object passed in has already been preprocessed and no - ** errors have been found. - */ -#if !SQLITE_OMIT_SUBQUERY - static int isCandidateForInOpt( Select p ) - { - SrcList pSrc; - ExprList pEList; - Table pTab; - if ( p == null ) - return 0; /* right-hand side of IN is SELECT */ - if ( p.pPrior != null ) - return 0; /* Not a compound SELECT */ - if ( ( p.selFlags & ( SF_Distinct | SF_Aggregate ) ) != 0 ) - { - testcase( ( p.selFlags & ( SF_Distinct | SF_Aggregate ) ) == SF_Distinct ); - testcase( ( p.selFlags & ( SF_Distinct | SF_Aggregate ) ) == SF_Aggregate ); - return 0; /* No DISTINCT keyword and no aggregate functions */ - } - Debug.Assert( p.pGroupBy == null ); /* Has no GROUP BY clause */ - if ( p.pLimit != null ) - return 0; /* Has no LIMIT clause */ - Debug.Assert( p.pOffset == null ); /* No LIMIT means no OFFSET */ - - if ( p.pWhere != null ) - return 0; /* Has no WHERE clause */ - pSrc = p.pSrc; - Debug.Assert( pSrc != null ); - if ( pSrc.nSrc != 1 ) - return 0; /* Single term in FROM clause */ - if ( pSrc.a[0].pSelect != null ) - return 0; /* FROM is not a subquery or view */ - pTab = pSrc.a[0].pTab; - if ( NEVER( pTab == null ) ) - return 0; - Debug.Assert( pTab.pSelect == null ); /* FROM clause is not a view */ - if ( IsVirtual( pTab ) ) - return 0; /* FROM clause not a virtual table */ - pEList = p.pEList; - if ( pEList.nExpr != 1 ) - return 0; /* One column in the result set */ - if ( pEList.a[0].pExpr.op != TK_COLUMN ) - return 0; /* Result is a column */ - return 1; - } -#endif //* SQLITE_OMIT_SUBQUERY */ + static int selectNodeIsConstant(Walker pWalker, Select NotUsed) { + UNUSED_PARAMETER(NotUsed); + pWalker.u.i = 0; + return WRC_Abort; + } + static int exprIsConst(Expr p, int initFlag) { + Walker w = new Walker(); + w.u.i = initFlag; + w.xExprCallback = exprNodeIsConstant; + w.xSelectCallback = selectNodeIsConstant; + sqlite3WalkExpr(w, ref p); + return w.u.i; + } - /* -** This function is used by the implementation of the IN (...) operator. -** It's job is to find or create a b-tree structure that may be used -** either to test for membership of the (...) set or to iterate through -** its members, skipping duplicates. -** -** The index of the cursor opened on the b-tree (database table, database index -** or ephermal table) is stored in pX->iTable before this function returns. -** The returned value of this function indicates the b-tree type, as follows: -** -** IN_INDEX_ROWID - The cursor was opened on a database table. -** IN_INDEX_INDEX - The cursor was opened on a database index. -** IN_INDEX_EPH - The cursor was opened on a specially created and -** populated epheremal table. -** -** An existing b-tree may only be used if the SELECT is of the simple -** form: -** -** SELECT FROM -** -** If the prNotFound parameter is 0, then the b-tree will be used to iterate -** through the set members, skipping any duplicates. In this case an -** epheremal table must be used unless the selected is guaranteed -** to be unique - either because it is an INTEGER PRIMARY KEY or it -** has a UNIQUE constraint or UNIQUE index. -** -** If the prNotFound parameter is not 0, then the b-tree will be used -** for fast set membership tests. In this case an epheremal table must -** be used unless is an INTEGER PRIMARY KEY or an index can -** be found with as its left-most column. -** -** When the b-tree is being used for membership tests, the calling function -** needs to know whether or not the structure contains an SQL NULL -** value in order to correctly evaluate expressions like "X IN (Y, Z)". -** If there is any chance that the (...) might contain a NULL value at -** runtime, then a register is allocated and the register number written -** to *prNotFound. If there is no chance that the (...) contains a -** NULL value, then *prNotFound is left unchanged. -** -** If a register is allocated and its location stored in *prNotFound, then -** its initial value is NULL. If the (...) does not remain constant -** for the duration of the query (i.e. the SELECT within the (...) -** is a correlated subquery) then the value of the allocated register is -** reset to NULL each time the subquery is rerun. This allows the -** caller to use vdbe code equivalent to the following: -** -** if( register==NULL ){ -** has_null = -** register = 1 -** } -** -** in order to avoid running the -** test more often than is necessary. -*/ -#if !SQLITE_OMIT_SUBQUERY - static int sqlite3FindInIndex( Parse pParse, Expr pX, ref int prNotFound ) - { - Select p; /* SELECT to the right of IN operator */ - int eType = 0; /* Type of RHS table. IN_INDEX_* */ - int iTab = pParse.nTab++; /* Cursor of the RHS table */ - bool mustBeUnique = ( prNotFound != 0 ); /* True if RHS must be unique */ - - Debug.Assert( pX.op == TK_IN ); - - /* Check to see if an existing table or index can be used to - ** satisfy the query. This is preferable to generating a new - ** ephemeral table. - */ - p = ( ExprHasProperty( pX, EP_xIsSelect ) ? pX.x.pSelect : null ); - if ( ALWAYS( pParse.nErr == 0 ) && isCandidateForInOpt( p ) != 0 ) - { - sqlite3 db = pParse.db; /* Database connection */ - Expr pExpr = p.pEList.a[0].pExpr; /* Expression */ - int iCol = pExpr.iColumn; /* Index of column */ - Vdbe v = sqlite3GetVdbe( pParse ); /* Virtual machine being coded */ - Table pTab = p.pSrc.a[0].pTab; /* Table
. */ - int iDb; /* Database idx for pTab */ - - /* Code an OP_VerifyCookie and OP_TableLock for
. */ - iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); - sqlite3CodeVerifySchema( pParse, iDb ); - sqlite3TableLock( pParse, iDb, pTab.tnum, 0, pTab.zName ); - - /* This function is only called from two places. In both cases the vdbe - ** has already been allocated. So assume sqlite3GetVdbe() is always - ** successful here. + /* + ** Walk an expression tree. Return 1 if the expression is constant + ** and 0 if it involves variables or function calls. + ** + ** For the purposes of this function, a double-quoted string (ex: "abc") + ** is considered a variable but a single-quoted string (ex: 'abc') is + ** a constant. */ - Debug.Assert( v != null ); - if ( iCol < 0 ) - { - int iMem = ++pParse.nMem; - int iAddr; - - iAddr = sqlite3VdbeAddOp1( v, OP_If, iMem ); - sqlite3VdbeAddOp2( v, OP_Integer, 1, iMem ); + static int sqlite3ExprIsConstant(Expr p) { + return exprIsConst(p, 1); + } - sqlite3OpenTable( pParse, iTab, iDb, pTab, OP_OpenRead ); - eType = IN_INDEX_ROWID; + /* + ** Walk an expression tree. Return 1 if the expression is constant + ** that does no originate from the ON or USING clauses of a join. + ** Return 0 if it involves variables or function calls or terms from + ** an ON or USING clause. + */ + static int sqlite3ExprIsConstantNotJoin(Expr p) { + return exprIsConst(p, 3); + } - sqlite3VdbeJumpHere( v, iAddr ); + /* + ** Walk an expression tree. Return 1 if the expression is constant + ** or a function call with constant arguments. Return and 0 if there + ** are any variables. + ** + ** For the purposes of this function, a double-quoted string (ex: "abc") + ** is considered a variable but a single-quoted string (ex: 'abc') is + ** a constant. + */ + static int sqlite3ExprIsConstantOrFunction(Expr p) { + return exprIsConst(p, 2); } - else - { - Index pIdx; /* Iterator variable */ - /* The collation sequence used by the comparison. If an index is to - ** be used in place of a temp.table, it must be ordered according - ** to this collation sequence. */ - CollSeq pReq = sqlite3BinaryCompareCollSeq( pParse, pX.pLeft, pExpr ); - - /* Check that the affinity that will be used to perform the - ** comparison is the same as the affinity of the column. If - ** it is not, it is not possible to use any index. - */ - char aff = comparisonAffinity( pX ); - bool affinity_ok = ( pTab.aCol[iCol].affinity == aff || aff == SQLITE_AFF_NONE ); - - for ( pIdx = pTab.pIndex; pIdx != null && eType == 0 && affinity_ok; pIdx = pIdx.pNext ) - { - if ( ( pIdx.aiColumn[0] == iCol ) - && ( sqlite3FindCollSeq( db, ENC( db ), pIdx.azColl[0], 0 ) == pReq ) - && ( mustBeUnique == false || ( pIdx.nColumn == 1 && pIdx.onError != OE_None ) ) - ) - { - int iMem = ++pParse.nMem; - int iAddr; - KeyInfo pKey; - pKey = sqlite3IndexKeyinfo( pParse, pIdx ); + /* + ** If the expression p codes a constant integer that is small enough + ** to fit in a 32-bit integer, return 1 and put the value of the integer + ** in pValue. If the expression is not an integer or if it is too big + ** to fit in a signed 32-bit integer, return 0 and leave pValue unchanged. + */ + static int sqlite3ExprIsInteger(Expr p, ref int pValue) { + int rc = 0; - iAddr = sqlite3VdbeAddOp1( v, OP_If, iMem ); - sqlite3VdbeAddOp2( v, OP_Integer, 1, iMem ); + /* If an expression is an integer literal that fits in a signed 32-bit + ** integer, then the EP_IntValue flag will have already been set */ + Debug.Assert(p.op != TK_INTEGER || (p.flags & EP_IntValue) != 0 + || !sqlite3GetInt32(p.u.zToken, ref rc)); - sqlite3VdbeAddOp4( v, OP_OpenRead, iTab, pIdx.tnum, iDb, - pKey, P4_KEYINFO_HANDOFF ); -#if SQLITE_DEBUG - VdbeComment( v, "%s", pIdx.zName ); -#endif - eType = IN_INDEX_INDEX; - - sqlite3VdbeJumpHere( v, iAddr ); - if ( //prNotFound != null && -- always exists under C# - pTab.aCol[iCol].notNull == 0 ) - { - prNotFound = ++pParse.nMem; - } + if ((p.flags & EP_IntValue) != 0) { + pValue = (int)p.u.iValue; + return 1; } - } + switch (p.op) { + case TK_UPLUS: { + rc = sqlite3ExprIsInteger(p.pLeft, ref pValue); + break; + } + case TK_UMINUS: { + int v = 0; + if (sqlite3ExprIsInteger(p.pLeft, ref v) != 0) { + pValue = -v; + rc = 1; + } + break; + } + default: + break; + } + return rc; } - } - if ( eType == 0 ) - { - /* Could not found an existing table or index to use as the RHS b-tree. - ** We will have to generate an ephemeral table to do the job. + /* + ** Return FALSE if there is no chance that the expression can be NULL. + ** + ** If the expression might be NULL or if the expression is too complex + ** to tell return TRUE. + ** + ** This routine is used as an optimization, to skip OP_IsNull opcodes + ** when we know that a value cannot be NULL. Hence, a false positive + ** (returning TRUE when in fact the expression can never be NULL) might + ** be a small performance hit but is otherwise harmless. On the other + ** hand, a false negative (returning FALSE when the result could be NULL) + ** will likely result in an incorrect answer. So when in doubt, return + ** TRUE. */ - double savedNQueryLoop = pParse.nQueryLoop; - int rMayHaveNull = 0; - eType = IN_INDEX_EPH; - if ( prNotFound != -1 ) // Klude to show prNotFound not available - { - prNotFound = rMayHaveNull = ++pParse.nMem; - } - else - { - testcase( pParse.nQueryLoop > (double)1 ); - pParse.nQueryLoop = (double)1; - if ( pX.pLeft.iColumn < 0 && !ExprHasAnyProperty( pX, EP_xIsSelect ) ) - { - eType = IN_INDEX_ROWID; - } + static int sqlite3ExprCanBeNull(Expr p) { + u8 op; + while (p.op == TK_UPLUS || p.op == TK_UMINUS) { + p = p.pLeft; + } + op = p.op; + if (op == TK_REGISTER) + op = p.op2; + switch (op) { + case TK_INTEGER: + case TK_STRING: + case TK_FLOAT: + case TK_BLOB: + return 0; + default: + return 1; + } } - sqlite3CodeSubselect( pParse, pX, rMayHaveNull, eType == IN_INDEX_ROWID ); - pParse.nQueryLoop = savedNQueryLoop; - } - else - { - pX.iTable = iTab; - } - return eType; - } -#endif - - /* -** Generate code for scalar subqueries used as a subquery expression, EXISTS, -** or IN operators. Examples: -** -** (SELECT a FROM b) -- subquery -** EXISTS (SELECT a FROM b) -- EXISTS subquery -** x IN (4,5,11) -- IN operator with list on right-hand side -** x IN (SELECT a FROM b) -- IN operator with subquery on the right -** -** The pExpr parameter describes the expression that contains the IN -** operator or subquery. -** -** If parameter isRowid is non-zero, then expression pExpr is guaranteed -** to be of the form " IN (?, ?, ?)", where is a reference -** to some integer key column of a table B-Tree. In this case, use an -** intkey B-Tree to store the set of IN(...) values instead of the usual -** (slower) variable length keys B-Tree. -** -** If rMayHaveNull is non-zero, that means that the operation is an IN -** (not a SELECT or EXISTS) and that the RHS might contains NULLs. -** Furthermore, the IN is in a WHERE clause and that we really want -** to iterate over the RHS of the IN operator in order to quickly locate -** all corresponding LHS elements. All this routine does is initialize -** the register given by rMayHaveNull to NULL. Calling routines will take -** care of changing this register value to non-NULL if the RHS is NULL-free. -** -** If rMayHaveNull is zero, that means that the subquery is being used -** for membership testing only. There is no need to initialize any -** registers to indicate the presense or absence of NULLs on the RHS. -** -** For a SELECT or EXISTS operator, return the register that holds the -** result. For IN operators or if an error occurs, the return value is 0. -*/ -#if !SQLITE_OMIT_SUBQUERY - static int sqlite3CodeSubselect( - Parse pParse, /* Parsing context */ - Expr pExpr, /* The IN, SELECT, or EXISTS operator */ - int rMayHaveNull, /* Register that records whether NULLs exist in RHS */ - bool isRowid /* If true, LHS of IN operator is a rowid */ - ) - { - int testAddr = 0; /* One-time test address */ - int rReg = 0; /* Register storing resulting */ - Vdbe v = sqlite3GetVdbe( pParse ); - if ( NEVER( v == null ) ) - return 0; - sqlite3ExprCachePush( pParse ); - - /* This code must be run in its entirety every time it is encountered - ** if any of the following is true: - ** - ** * The right-hand side is a correlated subquery - ** * The right-hand side is an expression list containing variables - ** * 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 ( !ExprHasAnyProperty( pExpr, EP_VarSelect ) && null == pParse.pTriggerTab ) - { - int mem = ++pParse.nMem; - sqlite3VdbeAddOp1( v, OP_If, mem ); - testAddr = sqlite3VdbeAddOp2( v, OP_Integer, 1, mem ); - Debug.Assert( testAddr > 0 /* || pParse.db.mallocFailed != 0 */ ); - } -#if !SQLITE_OMIT_EXPLAIN - if ( pParse.explain == 2 ) - { - string zMsg = sqlite3MPrintf( - pParse.db, "EXECUTE %s%s SUBQUERY %d", testAddr != 0 ? string.Empty : "CORRELATED ", - pExpr.op == TK_IN ? "LIST" : "SCALAR", pParse.iNextSelectId - ); - sqlite3VdbeAddOp4( v, OP_Explain, pParse.iSelectId, 0, 0, zMsg, P4_DYNAMIC ); - } -#endif - - switch ( pExpr.op ) - { - case TK_IN: - { - char affinity; /* Affinity of the LHS of the IN */ - KeyInfo keyInfo; /* Keyinfo for the generated table */ - int addr; /* Address of OP_OpenEphemeral instruction */ - Expr pLeft = pExpr.pLeft; /* the LHS of the IN operator */ + /* + ** Generate an OP_IsNull instruction that tests register iReg and jumps + ** to location iDest if the value in iReg is NULL. The value in iReg + ** was computed by pExpr. If we can look at pExpr at compile-time and + ** determine that it can never generate a NULL, then the OP_IsNull operation + ** can be omitted. + */ + static void sqlite3ExprCodeIsNullJump( + Vdbe v, /* The VDBE under construction */ + Expr pExpr, /* Only generate OP_IsNull if this expr can be NULL */ + int iReg, /* Test the value in this register for NULL */ + int iDest /* Jump here if the value is null */ + ) { + if (sqlite3ExprCanBeNull(pExpr) != 0) { + sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iDest); + } + } - if ( rMayHaveNull != 0 ) - { - sqlite3VdbeAddOp2( v, OP_Null, 0, rMayHaveNull ); + /* + ** Return TRUE if the given expression is a constant which would be + ** unchanged by OP_Affinity with the affinity given in the second + ** argument. + ** + ** This routine is used to determine if the OP_Affinity operation + ** can be omitted. When in doubt return FALSE. A false negative + ** is harmless. A false positive, however, can result in the wrong + ** answer. + */ + static int sqlite3ExprNeedsNoAffinityChange(Expr p, char aff) { + u8 op; + if (aff == SQLITE_AFF_NONE) + return 1; + while (p.op == TK_UPLUS || p.op == TK_UMINUS) { + p = p.pLeft; + } + op = p.op; + if (op == TK_REGISTER) + op = p.op2; + switch (op) { + case TK_INTEGER: { + return (aff == SQLITE_AFF_INTEGER || aff == SQLITE_AFF_NUMERIC) ? 1 : 0; + } + case TK_FLOAT: { + return (aff == SQLITE_AFF_REAL || aff == SQLITE_AFF_NUMERIC) ? 1 : 0; + } + case TK_STRING: { + return (aff == SQLITE_AFF_TEXT) ? 1 : 0; + } + case TK_BLOB: { + return 1; + } + case TK_COLUMN: { + Debug.Assert(p.iTable >= 0); /* p cannot be part of a CHECK constraint */ + return (p.iColumn < 0 + && (aff == SQLITE_AFF_INTEGER || aff == SQLITE_AFF_NUMERIC)) ? 1 : 0; + } + default: { + return 0; + } } + } - affinity = sqlite3ExprAffinity( pLeft ); + /* + ** Return TRUE if the given string is a row-id column name. + */ + static bool sqlite3IsRowid(string z) { + if (z.Equals("_ROWID_", StringComparison.OrdinalIgnoreCase)) + return true; + if (z.Equals("ROWID", StringComparison.OrdinalIgnoreCase)) + return true; + if (z.Equals("OID", StringComparison.OrdinalIgnoreCase)) + return true; + return false; + } - /* Whether this is an 'x IN(SELECT...)' or an 'x IN()' - ** expression it is handled the same way. An ephemeral table is - ** filled with single-field index keys representing the results - ** from the SELECT or the . - ** - ** If the 'x' expression is a column value, or the SELECT... - ** statement returns a column value, then the affinity of that - ** column is used to build the index keys. If both 'x' and the - ** SELECT... statement are columns, then numeric affinity is used - ** if either column has NUMERIC or INTEGER affinity. If neither - ** 'x' nor the SELECT... statement are columns, then numeric affinity - ** is used. - */ - pExpr.iTable = pParse.nTab++; - addr = sqlite3VdbeAddOp2( v, OP_OpenEphemeral, (int)pExpr.iTable, !isRowid ); - if ( rMayHaveNull == 0 ) - sqlite3VdbeChangeP5( v, BTREE_UNORDERED ); - keyInfo = new KeyInfo();// memset( &keyInfo, 0, sizeof(keyInfo )); - keyInfo.nField = 1; - - if ( ExprHasProperty( pExpr, EP_xIsSelect ) ) - { - /* Case 1: expr IN (SELECT ...) - ** - ** Generate code to write the results of the select into the temporary - ** table allocated and opened above. - */ - SelectDest dest = new SelectDest(); - ExprList pEList; - - Debug.Assert( !isRowid ); - sqlite3SelectDestInit( dest, SRT_Set, pExpr.iTable ); - dest.affinity = (char)affinity; - Debug.Assert( ( pExpr.iTable & 0x0000FFFF ) == pExpr.iTable ); - pExpr.x.pSelect.iLimit = 0; - if ( sqlite3Select( pParse, pExpr.x.pSelect, ref dest ) != 0 ) - { - return 0; - } - pEList = pExpr.x.pSelect.pEList; - if ( ALWAYS( pEList != null ) && pEList.nExpr > 0 ) - { - keyInfo.aColl[0] = sqlite3BinaryCompareCollSeq( pParse, pExpr.pLeft, - pEList.a[0].pExpr ); - } + + /* + ** Return true if we are able to the IN operator optimization on a + ** query of the form + ** + ** x IN (SELECT ...) + ** + ** Where the SELECT... clause is as specified by the parameter to this + ** routine. + ** + ** The Select object passed in has already been preprocessed and no + ** errors have been found. + */ +#if !SQLITE_OMIT_SUBQUERY + static int isCandidateForInOpt(Select p) { + SrcList pSrc; + ExprList pEList; + Table pTab; + if (p == null) + return 0; /* right-hand side of IN is SELECT */ + if (p.pPrior != null) + return 0; /* Not a compound SELECT */ + if ((p.selFlags & (SF_Distinct | SF_Aggregate)) != 0) { + testcase((p.selFlags & (SF_Distinct | SF_Aggregate)) == SF_Distinct); + testcase((p.selFlags & (SF_Distinct | SF_Aggregate)) == SF_Aggregate); + return 0; /* No DISTINCT keyword and no aggregate functions */ } - else if ( ALWAYS( pExpr.x.pList != null ) ) - { - /* Case 2: expr IN (exprlist) - ** - ** For each expression, build an index key from the evaluation and - ** store it in the temporary table. If is a column, then use - ** that columns affinity when building index keys. If is not - ** a column, use numeric affinity. - */ - int i; - ExprList pList = pExpr.x.pList; - ExprList_item pItem; - int r1, r2, r3; - - if ( affinity == '\0' ) - { - affinity = SQLITE_AFF_NONE; - } - keyInfo.aColl[0] = sqlite3ExprCollSeq( pParse, pExpr.pLeft ); - - /* Loop through each expression in . */ - r1 = sqlite3GetTempReg( pParse ); - r2 = sqlite3GetTempReg( pParse ); - sqlite3VdbeAddOp2( v, OP_Null, 0, r2 ); - for ( i = 0; i < pList.nExpr; i++ ) - {//, pItem++){ - pItem = pList.a[i]; - Expr pE2 = pItem.pExpr; - int iValToIns = 0; + Debug.Assert(p.pGroupBy == null); /* Has no GROUP BY clause */ + if (p.pLimit != null) + return 0; /* Has no LIMIT clause */ + Debug.Assert(p.pOffset == null); /* No LIMIT means no OFFSET */ + + if (p.pWhere != null) + return 0; /* Has no WHERE clause */ + pSrc = p.pSrc; + Debug.Assert(pSrc != null); + if (pSrc.nSrc != 1) + return 0; /* Single term in FROM clause */ + if (pSrc.a[0].pSelect != null) + return 0; /* FROM is not a subquery or view */ + pTab = pSrc.a[0].pTab; + if (NEVER(pTab == null)) + return 0; + Debug.Assert(pTab.pSelect == null); /* FROM clause is not a view */ + if (IsVirtual(pTab)) + return 0; /* FROM clause not a virtual table */ + pEList = p.pEList; + if (pEList.nExpr != 1) + return 0; /* One column in the result set */ + if (pEList.a[0].pExpr.op != TK_COLUMN) + return 0; /* Result is a column */ + return 1; + } +#endif //* SQLITE_OMIT_SUBQUERY */ + + /* + ** This function is used by the implementation of the IN (...) operator. + ** It's job is to find or create a b-tree structure that may be used + ** either to test for membership of the (...) set or to iterate through + ** its members, skipping duplicates. + ** + ** The index of the cursor opened on the b-tree (database table, database index + ** or ephermal table) is stored in pX->iTable before this function returns. + ** The returned value of this function indicates the b-tree type, as follows: + ** + ** IN_INDEX_ROWID - The cursor was opened on a database table. + ** IN_INDEX_INDEX - The cursor was opened on a database index. + ** IN_INDEX_EPH - The cursor was opened on a specially created and + ** populated epheremal table. + ** + ** An existing b-tree may only be used if the SELECT is of the simple + ** form: + ** + ** SELECT FROM
+ ** + ** If the prNotFound parameter is 0, then the b-tree will be used to iterate + ** through the set members, skipping any duplicates. In this case an + ** epheremal table must be used unless the selected is guaranteed + ** to be unique - either because it is an INTEGER PRIMARY KEY or it + ** has a UNIQUE constraint or UNIQUE index. + ** + ** If the prNotFound parameter is not 0, then the b-tree will be used + ** for fast set membership tests. In this case an epheremal table must + ** be used unless is an INTEGER PRIMARY KEY or an index can + ** be found with as its left-most column. + ** + ** When the b-tree is being used for membership tests, the calling function + ** needs to know whether or not the structure contains an SQL NULL + ** value in order to correctly evaluate expressions like "X IN (Y, Z)". + ** If there is any chance that the (...) might contain a NULL value at + ** runtime, then a register is allocated and the register number written + ** to *prNotFound. If there is no chance that the (...) contains a + ** NULL value, then *prNotFound is left unchanged. + ** + ** If a register is allocated and its location stored in *prNotFound, then + ** its initial value is NULL. If the (...) does not remain constant + ** for the duration of the query (i.e. the SELECT within the (...) + ** is a correlated subquery) then the value of the allocated register is + ** reset to NULL each time the subquery is rerun. This allows the + ** caller to use vdbe code equivalent to the following: + ** + ** if( register==NULL ){ + ** has_null = + ** register = 1 + ** } + ** + ** in order to avoid running the + ** test more often than is necessary. + */ +#if !SQLITE_OMIT_SUBQUERY + static int sqlite3FindInIndex(Parse pParse, Expr pX, ref int prNotFound) { + Select p; /* SELECT to the right of IN operator */ + int eType = 0; /* Type of RHS table. IN_INDEX_* */ + int iTab = pParse.nTab++; /* Cursor of the RHS table */ + bool mustBeUnique = (prNotFound != 0); /* True if RHS must be unique */ - /* If the expression is not constant then we will need to - ** disable the test that was generated above that makes sure - ** this code only executes once. Because for a non-constant - ** expression we need to rerun this code each time. + Debug.Assert(pX.op == TK_IN); + + /* Check to see if an existing table or index can be used to + ** satisfy the query. This is preferable to generating a new + ** ephemeral table. + */ + p = (ExprHasProperty(pX, EP_xIsSelect) ? pX.x.pSelect : null); + if (ALWAYS(pParse.nErr == 0) && isCandidateForInOpt(p) != 0) { + sqlite3 db = pParse.db; /* Database connection */ + Expr pExpr = p.pEList.a[0].pExpr; /* Expression */ + int iCol = pExpr.iColumn; /* Index of column */ + Vdbe v = sqlite3GetVdbe(pParse); /* Virtual machine being coded */ + Table pTab = p.pSrc.a[0].pTab; /* Table
. */ + int iDb; /* Database idx for pTab */ + + /* Code an OP_VerifyCookie and OP_TableLock for
. */ + iDb = sqlite3SchemaToIndex(db, pTab.pSchema); + sqlite3CodeVerifySchema(pParse, iDb); + sqlite3TableLock(pParse, iDb, pTab.tnum, 0, pTab.zName); + + /* This function is only called from two places. In both cases the vdbe + ** has already been allocated. So assume sqlite3GetVdbe() is always + ** successful here. */ - if ( testAddr != 0 && sqlite3ExprIsConstant( pE2 ) == 0 ) - { - sqlite3VdbeChangeToNoop( v, testAddr - 1, 2 ); - testAddr = 0; - } + Debug.Assert(v != null); + if (iCol < 0) { + int iMem = ++pParse.nMem; + int iAddr; + + iAddr = sqlite3VdbeAddOp1(v, OP_If, iMem); + sqlite3VdbeAddOp2(v, OP_Integer, 1, iMem); + + sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead); + eType = IN_INDEX_ROWID; + + sqlite3VdbeJumpHere(v, iAddr); + } else { + Index pIdx; /* Iterator variable */ + /* The collation sequence used by the comparison. If an index is to + ** be used in place of a temp.table, it must be ordered according + ** to this collation sequence. */ + CollSeq pReq = sqlite3BinaryCompareCollSeq(pParse, pX.pLeft, pExpr); + + /* Check that the affinity that will be used to perform the + ** comparison is the same as the affinity of the column. If + ** it is not, it is not possible to use any index. + */ + char aff = comparisonAffinity(pX); + bool affinity_ok = (pTab.aCol[iCol].affinity == aff || aff == SQLITE_AFF_NONE); + + for (pIdx = pTab.pIndex; pIdx != null && eType == 0 && affinity_ok; pIdx = pIdx.pNext) { + if ((pIdx.aiColumn[0] == iCol) + && (sqlite3FindCollSeq(db, ENC(db), pIdx.azColl[0], 0) == pReq) + && (mustBeUnique == false || (pIdx.nColumn == 1 && pIdx.onError != OE_None)) + ) { + int iMem = ++pParse.nMem; + int iAddr; + KeyInfo pKey; + + pKey = sqlite3IndexKeyinfo(pParse, pIdx); + + iAddr = sqlite3VdbeAddOp1(v, OP_If, iMem); + sqlite3VdbeAddOp2(v, OP_Integer, 1, iMem); + + sqlite3VdbeAddOp4(v, OP_OpenRead, iTab, pIdx.tnum, iDb, + pKey, P4_KEYINFO_HANDOFF); +#if SQLITE_DEBUG + VdbeComment(v, "%s", pIdx.zName); +#endif + eType = IN_INDEX_INDEX; - /* Evaluate the expression and insert it into the temp table */ - if ( isRowid && sqlite3ExprIsInteger( pE2, ref iValToIns ) != 0 ) - { - sqlite3VdbeAddOp3( v, OP_InsertInt, pExpr.iTable, r2, iValToIns ); + sqlite3VdbeJumpHere(v, iAddr); + if ( //prNotFound != null && -- always exists under C# + pTab.aCol[iCol].notNull == 0) { + prNotFound = ++pParse.nMem; + } + } + } } - else + } + + if (eType == 0) { + /* Could not found an existing table or index to use as the RHS b-tree. + ** We will have to generate an ephemeral table to do the job. + */ + double savedNQueryLoop = pParse.nQueryLoop; + int rMayHaveNull = 0; + eType = IN_INDEX_EPH; + if (prNotFound != -1) // Klude to show prNotFound not available { - r3 = sqlite3ExprCodeTarget( pParse, pE2, r1 ); - if ( isRowid ) - { - sqlite3VdbeAddOp2( v, OP_MustBeInt, r3, - sqlite3VdbeCurrentAddr( v ) + 2 ); - sqlite3VdbeAddOp3( v, OP_Insert, pExpr.iTable, r2, r3 ); - } - else - { - sqlite3VdbeAddOp4( v, OP_MakeRecord, r3, 1, r2, affinity, 1 ); - sqlite3ExprCacheAffinityChange( pParse, r3, 1 ); - sqlite3VdbeAddOp2( v, OP_IdxInsert, pExpr.iTable, r2 ); - } + prNotFound = rMayHaveNull = ++pParse.nMem; + } else { + testcase(pParse.nQueryLoop > (double)1); + pParse.nQueryLoop = (double)1; + if (pX.pLeft.iColumn < 0 && !ExprHasAnyProperty(pX, EP_xIsSelect)) { + eType = IN_INDEX_ROWID; + } } - } - sqlite3ReleaseTempReg( pParse, r1 ); - sqlite3ReleaseTempReg( pParse, r2 ); + sqlite3CodeSubselect(pParse, pX, rMayHaveNull, eType == IN_INDEX_ROWID); + pParse.nQueryLoop = savedNQueryLoop; + } else { + pX.iTable = iTab; } - if ( !isRowid ) - { - sqlite3VdbeChangeP4( v, addr, keyInfo, P4_KEYINFO ); - } - break; - } + return eType; + } +#endif - case TK_EXISTS: - case TK_SELECT: - default: - { - /* If this has to be a scalar SELECT. Generate code to put the - ** value of this select in a memory cell and record the number - ** of the memory cell in iColumn. If this is an EXISTS, write - ** an integer 0 (not exists) or 1 (exists) into a memory cell - ** and record that memory cell in iColumn. + /* + ** Generate code for scalar subqueries used as a subquery expression, EXISTS, + ** or IN operators. Examples: + ** + ** (SELECT a FROM b) -- subquery + ** EXISTS (SELECT a FROM b) -- EXISTS subquery + ** x IN (4,5,11) -- IN operator with list on right-hand side + ** x IN (SELECT a FROM b) -- IN operator with subquery on the right + ** + ** The pExpr parameter describes the expression that contains the IN + ** operator or subquery. + ** + ** If parameter isRowid is non-zero, then expression pExpr is guaranteed + ** to be of the form " IN (?, ?, ?)", where is a reference + ** to some integer key column of a table B-Tree. In this case, use an + ** intkey B-Tree to store the set of IN(...) values instead of the usual + ** (slower) variable length keys B-Tree. + ** + ** If rMayHaveNull is non-zero, that means that the operation is an IN + ** (not a SELECT or EXISTS) and that the RHS might contains NULLs. + ** Furthermore, the IN is in a WHERE clause and that we really want + ** to iterate over the RHS of the IN operator in order to quickly locate + ** all corresponding LHS elements. All this routine does is initialize + ** the register given by rMayHaveNull to NULL. Calling routines will take + ** care of changing this register value to non-NULL if the RHS is NULL-free. + ** + ** If rMayHaveNull is zero, that means that the subquery is being used + ** for membership testing only. There is no need to initialize any + ** registers to indicate the presense or absence of NULLs on the RHS. + ** + ** For a SELECT or EXISTS operator, return the register that holds the + ** result. For IN operators or if an error occurs, the return value is 0. + */ +#if !SQLITE_OMIT_SUBQUERY + static int sqlite3CodeSubselect( + Parse pParse, /* Parsing context */ + Expr pExpr, /* The IN, SELECT, or EXISTS operator */ + int rMayHaveNull, /* Register that records whether NULLs exist in RHS */ + bool isRowid /* If true, LHS of IN operator is a rowid */ + ) { + int testAddr = 0; /* One-time test address */ + int rReg = 0; /* Register storing resulting */ + Vdbe v = sqlite3GetVdbe(pParse); + if (NEVER(v == null)) + return 0; + sqlite3ExprCachePush(pParse); + + /* This code must be run in its entirety every time it is encountered + ** if any of the following is true: + ** + ** * The right-hand side is a correlated subquery + ** * The right-hand side is an expression list containing variables + ** * 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. */ - Select pSel; /* SELECT statement to encode */ - SelectDest dest = new SelectDest(); /* How to deal with SELECt result */ + if (!ExprHasAnyProperty(pExpr, EP_VarSelect) && null == pParse.pTriggerTab) { + int mem = ++pParse.nMem; + sqlite3VdbeAddOp1(v, OP_If, mem); + testAddr = sqlite3VdbeAddOp2(v, OP_Integer, 1, mem); + Debug.Assert(testAddr > 0 /* || pParse.db.mallocFailed != 0 */ ); + } + +#if !SQLITE_OMIT_EXPLAIN + if (pParse.explain == 2) { + string zMsg = sqlite3MPrintf( + pParse.db, "EXECUTE %s%s SUBQUERY %d", testAddr != 0 ? string.Empty : "CORRELATED ", + pExpr.op == TK_IN ? "LIST" : "SCALAR", pParse.iNextSelectId + ); + sqlite3VdbeAddOp4(v, OP_Explain, pParse.iSelectId, 0, 0, zMsg, P4_DYNAMIC); + } +#endif - testcase( pExpr.op == TK_EXISTS ); - testcase( pExpr.op == TK_SELECT ); - Debug.Assert( pExpr.op == TK_EXISTS || pExpr.op == TK_SELECT ); + switch (pExpr.op) { + case TK_IN: { + char affinity; /* Affinity of the LHS of the IN */ + KeyInfo keyInfo; /* Keyinfo for the generated table */ + int addr; /* Address of OP_OpenEphemeral instruction */ + Expr pLeft = pExpr.pLeft; /* the LHS of the IN operator */ - Debug.Assert( ExprHasProperty( pExpr, EP_xIsSelect ) ); - pSel = pExpr.x.pSelect; - sqlite3SelectDestInit( dest, 0, ++pParse.nMem ); - if ( pExpr.op == TK_SELECT ) - { - dest.eDest = SRT_Mem; - sqlite3VdbeAddOp2( v, OP_Null, 0, dest.iParm ); + if (rMayHaveNull != 0) { + sqlite3VdbeAddOp2(v, OP_Null, 0, rMayHaveNull); + } + + affinity = sqlite3ExprAffinity(pLeft); + + /* Whether this is an 'x IN(SELECT...)' or an 'x IN()' + ** expression it is handled the same way. An ephemeral table is + ** filled with single-field index keys representing the results + ** from the SELECT or the . + ** + ** If the 'x' expression is a column value, or the SELECT... + ** statement returns a column value, then the affinity of that + ** column is used to build the index keys. If both 'x' and the + ** SELECT... statement are columns, then numeric affinity is used + ** if either column has NUMERIC or INTEGER affinity. If neither + ** 'x' nor the SELECT... statement are columns, then numeric affinity + ** is used. + */ + pExpr.iTable = pParse.nTab++; + addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, (int)pExpr.iTable, !isRowid); + if (rMayHaveNull == 0) + sqlite3VdbeChangeP5(v, BTREE_UNORDERED); + keyInfo = new KeyInfo();// memset( &keyInfo, 0, sizeof(keyInfo )); + keyInfo.nField = 1; + + if (ExprHasProperty(pExpr, EP_xIsSelect)) { + /* Case 1: expr IN (SELECT ...) + ** + ** Generate code to write the results of the select into the temporary + ** table allocated and opened above. + */ + SelectDest dest = new SelectDest(); + ExprList pEList; + + Debug.Assert(!isRowid); + sqlite3SelectDestInit(dest, SRT_Set, pExpr.iTable); + dest.affinity = (char)affinity; + Debug.Assert((pExpr.iTable & 0x0000FFFF) == pExpr.iTable); + pExpr.x.pSelect.iLimit = 0; + if (sqlite3Select(pParse, pExpr.x.pSelect, ref dest) != 0) { + return 0; + } + pEList = pExpr.x.pSelect.pEList; + if (ALWAYS(pEList != null) && pEList.nExpr > 0) { + keyInfo.aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr.pLeft, + pEList.a[0].pExpr); + } + } else if (ALWAYS(pExpr.x.pList != null)) { + /* Case 2: expr IN (exprlist) + ** + ** For each expression, build an index key from the evaluation and + ** store it in the temporary table. If is a column, then use + ** that columns affinity when building index keys. If is not + ** a column, use numeric affinity. + */ + int i; + ExprList pList = pExpr.x.pList; + ExprList_item pItem; + int r1, r2, r3; + + if (affinity == '\0') { + affinity = SQLITE_AFF_NONE; + } + keyInfo.aColl[0] = sqlite3ExprCollSeq(pParse, pExpr.pLeft); + + /* Loop through each expression in . */ + r1 = sqlite3GetTempReg(pParse); + r2 = sqlite3GetTempReg(pParse); + sqlite3VdbeAddOp2(v, OP_Null, 0, r2); + for (i = 0; i < pList.nExpr; i++) {//, pItem++){ + pItem = pList.a[i]; + Expr pE2 = pItem.pExpr; + int iValToIns = 0; + + /* If the expression is not constant then we will need to + ** disable the test that was generated above that makes sure + ** this code only executes once. Because for a non-constant + ** expression we need to rerun this code each time. + */ + if (testAddr != 0 && sqlite3ExprIsConstant(pE2) == 0) { + sqlite3VdbeChangeToNoop(v, testAddr - 1, 2); + testAddr = 0; + } + + /* Evaluate the expression and insert it into the temp table */ + if (isRowid && sqlite3ExprIsInteger(pE2, ref iValToIns) != 0) { + sqlite3VdbeAddOp3(v, OP_InsertInt, pExpr.iTable, r2, iValToIns); + } else { + r3 = sqlite3ExprCodeTarget(pParse, pE2, r1); + if (isRowid) { + sqlite3VdbeAddOp2(v, OP_MustBeInt, r3, + sqlite3VdbeCurrentAddr(v) + 2); + sqlite3VdbeAddOp3(v, OP_Insert, pExpr.iTable, r2, r3); + } else { + sqlite3VdbeAddOp4(v, OP_MakeRecord, r3, 1, r2, affinity, 1); + sqlite3ExprCacheAffinityChange(pParse, r3, 1); + sqlite3VdbeAddOp2(v, OP_IdxInsert, pExpr.iTable, r2); + } + } + } + sqlite3ReleaseTempReg(pParse, r1); + sqlite3ReleaseTempReg(pParse, r2); + } + if (!isRowid) { + sqlite3VdbeChangeP4(v, addr, keyInfo, P4_KEYINFO); + } + break; + } + + case TK_EXISTS: + case TK_SELECT: + default: { + /* If this has to be a scalar SELECT. Generate code to put the + ** value of this select in a memory cell and record the number + ** of the memory cell in iColumn. If this is an EXISTS, write + ** an integer 0 (not exists) or 1 (exists) into a memory cell + ** and record that memory cell in iColumn. + */ + Select pSel; /* SELECT statement to encode */ + SelectDest dest = new SelectDest(); /* How to deal with SELECt result */ + + testcase(pExpr.op == TK_EXISTS); + testcase(pExpr.op == TK_SELECT); + Debug.Assert(pExpr.op == TK_EXISTS || pExpr.op == TK_SELECT); + + Debug.Assert(ExprHasProperty(pExpr, EP_xIsSelect)); + pSel = pExpr.x.pSelect; + sqlite3SelectDestInit(dest, 0, ++pParse.nMem); + if (pExpr.op == TK_SELECT) { + dest.eDest = SRT_Mem; + sqlite3VdbeAddOp2(v, OP_Null, 0, dest.iParm); #if SQLITE_DEBUG - VdbeComment( v, "Init subquery result" ); + VdbeComment(v, "Init subquery result"); #endif - } - else - { - dest.eDest = SRT_Exists; - sqlite3VdbeAddOp2( v, OP_Integer, 0, dest.iParm ); + } else { + dest.eDest = SRT_Exists; + sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iParm); #if SQLITE_DEBUG - VdbeComment( v, "Init EXISTS result" ); + VdbeComment(v, "Init EXISTS result"); #endif + } + sqlite3ExprDelete(pParse.db, ref pSel.pLimit); + pSel.pLimit = sqlite3PExpr(pParse, TK_INTEGER, null, null, sqlite3IntTokens[1]); + pSel.iLimit = 0; + if (sqlite3Select(pParse, pSel, ref dest) != 0) { + return 0; + } + rReg = dest.iParm; + ExprSetIrreducible(pExpr); + break; + } } - sqlite3ExprDelete( pParse.db, ref pSel.pLimit ); - pSel.pLimit = sqlite3PExpr( pParse, TK_INTEGER, null, null, sqlite3IntTokens[1] ); - pSel.iLimit = 0; - if ( sqlite3Select( pParse, pSel, ref dest ) != 0 ) - { - return 0; - } - rReg = dest.iParm; - ExprSetIrreducible( pExpr ); - break; - } - } - if ( testAddr != 0 ) - { - sqlite3VdbeJumpHere( v, testAddr - 1 ); - } - sqlite3ExprCachePop( pParse, 1 ); + if (testAddr != 0) { + sqlite3VdbeJumpHere(v, testAddr - 1); + } + sqlite3ExprCachePop(pParse, 1); - return rReg; - } + return rReg; + } #endif // * SQLITE_OMIT_SUBQUERY */ #if !SQLITE_OMIT_SUBQUERY - /* -** Generate code for an IN expression. -** -** x IN (SELECT ...) -** x IN (value, value, ...) -** -** The left-hand side (LHS) is a scalar expression. The right-hand side (RHS) -** is an array of zero or more values. The expression is true if the LHS is -** contained within the RHS. The value of the expression is unknown (NULL) -** if the LHS is NULL or if the LHS is not contained within the RHS and the -** RHS contains one or more NULL values. -** -** This routine generates code will jump to destIfFalse if the LHS is not -** contained within the RHS. If due to NULLs we cannot determine if the LHS -** is contained in the RHS then jump to destIfNull. If the LHS is contained -** within the RHS then fall through. -*/ - static void sqlite3ExprCodeIN( - Parse pParse, /* Parsing and code generating context */ - Expr pExpr, /* The IN expression */ - int destIfFalse, /* Jump here if LHS is not contained in the RHS */ - int destIfNull /* Jump here if the results are unknown due to NULLs */ - ) - { - int rRhsHasNull = 0; /* Register that is true if RHS contains NULL values */ - char affinity; /* Comparison affinity to use */ - int eType; /* Type of the RHS */ - int r1; /* Temporary use register */ - Vdbe v; /* Statement under construction */ - - /* Compute the RHS. After this step, the table with cursor - ** pExpr.iTable will contains the values that make up the RHS. - */ - v = pParse.pVdbe; - Debug.Assert( v != null ); /* OOM detected prior to this routine */ - VdbeNoopComment( v, "begin IN expr" ); - eType = sqlite3FindInIndex( pParse, pExpr, ref rRhsHasNull ); - - /* Figure out the affinity to use to create a key from the results - ** of the expression. affinityStr stores a static string suitable for - ** P4 of OP_MakeRecord. - */ - affinity = comparisonAffinity( pExpr ); - - /* Code the LHS, the from " IN (...)". - */ - sqlite3ExprCachePush( pParse ); - r1 = sqlite3GetTempReg( pParse ); - sqlite3ExprCode( pParse, pExpr.pLeft, r1 ); - - /* If the LHS is NULL, then the result is either false or NULL depending - ** on whether the RHS is empty or not, respectively. - */ - if ( destIfNull == destIfFalse ) - { - /* Shortcut for the common case where the false and NULL outcomes are - ** the same. */ - sqlite3VdbeAddOp2( v, OP_IsNull, r1, destIfNull ); - } - else - { - int addr1 = sqlite3VdbeAddOp1( v, OP_NotNull, r1 ); - sqlite3VdbeAddOp2( v, OP_Rewind, pExpr.iTable, destIfFalse ); - sqlite3VdbeAddOp2( v, OP_Goto, 0, destIfNull ); - sqlite3VdbeJumpHere( v, addr1 ); - } - - if ( eType == IN_INDEX_ROWID ) - { - /* In this case, the RHS is the ROWID of table b-tree - */ - sqlite3VdbeAddOp2( v, OP_MustBeInt, r1, destIfFalse ); - sqlite3VdbeAddOp3( v, OP_NotExists, pExpr.iTable, destIfFalse, r1 ); - } - else - { - /* In this case, the RHS is an index b-tree. - */ - sqlite3VdbeAddOp4( v, OP_Affinity, r1, 1, 0, affinity, 1 ); + /* + ** Generate code for an IN expression. + ** + ** x IN (SELECT ...) + ** x IN (value, value, ...) + ** + ** The left-hand side (LHS) is a scalar expression. The right-hand side (RHS) + ** is an array of zero or more values. The expression is true if the LHS is + ** contained within the RHS. The value of the expression is unknown (NULL) + ** if the LHS is NULL or if the LHS is not contained within the RHS and the + ** RHS contains one or more NULL values. + ** + ** This routine generates code will jump to destIfFalse if the LHS is not + ** contained within the RHS. If due to NULLs we cannot determine if the LHS + ** is contained in the RHS then jump to destIfNull. If the LHS is contained + ** within the RHS then fall through. + */ + static void sqlite3ExprCodeIN( + Parse pParse, /* Parsing and code generating context */ + Expr pExpr, /* The IN expression */ + int destIfFalse, /* Jump here if LHS is not contained in the RHS */ + int destIfNull /* Jump here if the results are unknown due to NULLs */ + ) { + int rRhsHasNull = 0; /* Register that is true if RHS contains NULL values */ + char affinity; /* Comparison affinity to use */ + int eType; /* Type of the RHS */ + int r1; /* Temporary use register */ + Vdbe v; /* Statement under construction */ + + /* Compute the RHS. After this step, the table with cursor + ** pExpr.iTable will contains the values that make up the RHS. + */ + v = pParse.pVdbe; + Debug.Assert(v != null); /* OOM detected prior to this routine */ + VdbeNoopComment(v, "begin IN expr"); + eType = sqlite3FindInIndex(pParse, pExpr, ref rRhsHasNull); + + /* Figure out the affinity to use to create a key from the results + ** of the expression. affinityStr stores a static string suitable for + ** P4 of OP_MakeRecord. + */ + affinity = comparisonAffinity(pExpr); - /* If the set membership test fails, then the result of the - ** "x IN (...)" expression must be either 0 or NULL. If the set - ** contains no NULL values, then the result is 0. If the set - ** contains one or more NULL values, then the result of the - ** expression is also NULL. - */ - if ( rRhsHasNull == 0 || destIfFalse == destIfNull ) - { - /* This branch runs if it is known at compile time that the RHS - ** cannot contain NULL values. This happens as the result - ** of a "NOT NULL" constraint in the database schema. - ** - ** Also run this branch if NULL is equivalent to FALSE - ** for this particular IN operator. - */ - sqlite3VdbeAddOp4Int( v, OP_NotFound, pExpr.iTable, destIfFalse, r1, 1 ); + /* Code the LHS, the from " IN (...)". + */ + sqlite3ExprCachePush(pParse); + r1 = sqlite3GetTempReg(pParse); + sqlite3ExprCode(pParse, pExpr.pLeft, r1); + /* If the LHS is NULL, then the result is either false or NULL depending + ** on whether the RHS is empty or not, respectively. + */ + if (destIfNull == destIfFalse) { + /* Shortcut for the common case where the false and NULL outcomes are + ** the same. */ + sqlite3VdbeAddOp2(v, OP_IsNull, r1, destIfNull); + } else { + int addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, r1); + sqlite3VdbeAddOp2(v, OP_Rewind, pExpr.iTable, destIfFalse); + sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfNull); + sqlite3VdbeJumpHere(v, addr1); + } + + if (eType == IN_INDEX_ROWID) { + /* In this case, the RHS is the ROWID of table b-tree + */ + sqlite3VdbeAddOp2(v, OP_MustBeInt, r1, destIfFalse); + sqlite3VdbeAddOp3(v, OP_NotExists, pExpr.iTable, destIfFalse, r1); + } else { + /* In this case, the RHS is an index b-tree. + */ + sqlite3VdbeAddOp4(v, OP_Affinity, r1, 1, 0, affinity, 1); + + /* If the set membership test fails, then the result of the + ** "x IN (...)" expression must be either 0 or NULL. If the set + ** contains no NULL values, then the result is 0. If the set + ** contains one or more NULL values, then the result of the + ** expression is also NULL. + */ + if (rRhsHasNull == 0 || destIfFalse == destIfNull) { + /* This branch runs if it is known at compile time that the RHS + ** cannot contain NULL values. This happens as the result + ** of a "NOT NULL" constraint in the database schema. + ** + ** Also run this branch if NULL is equivalent to FALSE + ** for this particular IN operator. + */ + sqlite3VdbeAddOp4Int(v, OP_NotFound, pExpr.iTable, destIfFalse, r1, 1); + + } else { + /* In this branch, the RHS of the IN might contain a NULL and + ** the presence of a NULL on the RHS makes a difference in the + ** outcome. + */ + int j1, j2, j3; + + /* First check to see if the LHS is contained in the RHS. If so, + ** then the presence of NULLs in the RHS does not matter, so jump + ** over all of the code that follows. + */ + j1 = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr.iTable, 0, r1, 1); + + /* Here we begin generating code that runs if the LHS is not + ** contained within the RHS. Generate additional code that + ** tests the RHS for NULLs. If the RHS contains a NULL then + ** jump to destIfNull. If there are no NULLs in the RHS then + ** jump to destIfFalse. + */ + j2 = sqlite3VdbeAddOp1(v, OP_NotNull, rRhsHasNull); + j3 = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr.iTable, 0, rRhsHasNull, 1); + sqlite3VdbeAddOp2(v, OP_Integer, -1, rRhsHasNull); + sqlite3VdbeJumpHere(v, j3); + sqlite3VdbeAddOp2(v, OP_AddImm, rRhsHasNull, 1); + sqlite3VdbeJumpHere(v, j2); + + /* Jump to the appropriate target depending on whether or not + ** the RHS contains a NULL + */ + sqlite3VdbeAddOp2(v, OP_If, rRhsHasNull, destIfNull); + sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfFalse); + + /* The OP_Found at the top of this branch jumps here when true, + ** causing the overall IN expression evaluation to fall through. + */ + sqlite3VdbeJumpHere(v, j1); + } + } + sqlite3ReleaseTempReg(pParse, r1); + sqlite3ExprCachePop(pParse, 1); + VdbeComment(v, "end IN expr"); } - else - { - /* In this branch, the RHS of the IN might contain a NULL and - ** the presence of a NULL on the RHS makes a difference in the - ** outcome. - */ - int j1, j2, j3; - - /* First check to see if the LHS is contained in the RHS. If so, - ** then the presence of NULLs in the RHS does not matter, so jump - ** over all of the code that follows. - */ - j1 = sqlite3VdbeAddOp4Int( v, OP_Found, pExpr.iTable, 0, r1, 1 ); - - /* Here we begin generating code that runs if the LHS is not - ** contained within the RHS. Generate additional code that - ** tests the RHS for NULLs. If the RHS contains a NULL then - ** jump to destIfNull. If there are no NULLs in the RHS then - ** jump to destIfFalse. - */ - j2 = sqlite3VdbeAddOp1( v, OP_NotNull, rRhsHasNull ); - j3 = sqlite3VdbeAddOp4Int( v, OP_Found, pExpr.iTable, 0, rRhsHasNull, 1 ); - sqlite3VdbeAddOp2( v, OP_Integer, -1, rRhsHasNull ); - sqlite3VdbeJumpHere( v, j3 ); - sqlite3VdbeAddOp2( v, OP_AddImm, rRhsHasNull, 1 ); - sqlite3VdbeJumpHere( v, j2 ); - - /* Jump to the appropriate target depending on whether or not - ** the RHS contains a NULL - */ - sqlite3VdbeAddOp2( v, OP_If, rRhsHasNull, destIfNull ); - sqlite3VdbeAddOp2( v, OP_Goto, 0, destIfFalse ); - - /* The OP_Found at the top of this branch jumps here when true, - ** causing the overall IN expression evaluation to fall through. - */ - sqlite3VdbeJumpHere( v, j1 ); - } - } - sqlite3ReleaseTempReg( pParse, r1 ); - sqlite3ExprCachePop( pParse, 1 ); - VdbeComment( v, "end IN expr" ); - } #endif //* SQLITE_OMIT_SUBQUERY */ - /* -** Duplicate an 8-byte value -*/ - //static char *dup8bytes(Vdbe v, string in){ - // char *out = sqlite3DbMallocRaw(sqlite3VdbeDb(v), 8); - // if( out ){ - // memcpy(out, in, 8); - // } - // return out; - //} + /* + ** Duplicate an 8-byte value + */ + //static char *dup8bytes(Vdbe v, string in){ + // char *out = sqlite3DbMallocRaw(sqlite3VdbeDb(v), 8); + // if( out ){ + // memcpy(out, in, 8); + // } + // return out; + //} #if !SQLITE_OMIT_FLOATING_POINT - /* -** Generate an instruction that will put the floating point -** value described by z[0..n-1] into register iMem. -** -** The z[] string will probably not be zero-terminated. But the -** z[n] character is guaranteed to be something that does not look -** like the continuation of the number. -*/ - static void codeReal( Vdbe v, string z, bool negateFlag, int iMem ) - { - if ( ALWAYS( !string.IsNullOrEmpty( z ) ) ) - { - double value = 0; - //string zV; - sqlite3AtoF( z, ref value, sqlite3Strlen30( z ), SQLITE_UTF8 ); - Debug.Assert( !sqlite3IsNaN( value ) ); /* The new AtoF never returns NaN */ - if ( negateFlag ) - value = -value; - //zV = dup8bytes(v, value); - sqlite3VdbeAddOp4( v, OP_Real, 0, iMem, 0, value, P4_REAL ); - } - } + /* + ** Generate an instruction that will put the floating point + ** value described by z[0..n-1] into register iMem. + ** + ** The z[] string will probably not be zero-terminated. But the + ** z[n] character is guaranteed to be something that does not look + ** like the continuation of the number. + */ + static void codeReal(Vdbe v, string z, bool negateFlag, int iMem) { + if (ALWAYS(!string.IsNullOrEmpty(z))) { + double value = 0; + //string zV; + sqlite3AtoF(z, ref value, sqlite3Strlen30(z), SQLITE_UTF8); + Debug.Assert(!sqlite3IsNaN(value)); /* The new AtoF never returns NaN */ + if (negateFlag) + value = -value; + //zV = dup8bytes(v, value); + sqlite3VdbeAddOp4(v, OP_Real, 0, iMem, 0, value, P4_REAL); + } + } #endif - /* - ** Generate an instruction that will put the integer describe by - ** text z[0..n-1] into register iMem. - ** - ** Expr.u.zToken is always UTF8 and zero-terminated. - */ - static void codeInteger( Parse pParse, Expr pExpr, bool negFlag, int iMem ) - { - Vdbe v = pParse.pVdbe; - if ( ( pExpr.flags & EP_IntValue ) != 0 ) - { - int i = pExpr.u.iValue; - Debug.Assert( i >= 0 ); - if ( negFlag ) - i = -i; - sqlite3VdbeAddOp2( v, OP_Integer, i, iMem ); - } - else - { - int c; - i64 value = 0; - string z = pExpr.u.zToken; - Debug.Assert( !string.IsNullOrEmpty( z ) ); - c = sqlite3Atoi64( z, ref value, sqlite3Strlen30( z ), SQLITE_UTF8 ); - if ( c == 0 || ( c == 2 && negFlag ) ) - { - //char* zV; - if ( negFlag ) - { - value = c == 2 ? SMALLEST_INT64 : -value; - } - sqlite3VdbeAddOp4( v, OP_Int64, 0, iMem, 0, value, P4_INT64 ); - } - else - { + /* + ** Generate an instruction that will put the integer describe by + ** text z[0..n-1] into register iMem. + ** + ** Expr.u.zToken is always UTF8 and zero-terminated. + */ + static void codeInteger(Parse pParse, Expr pExpr, bool negFlag, int iMem) { + Vdbe v = pParse.pVdbe; + if ((pExpr.flags & EP_IntValue) != 0) { + int i = pExpr.u.iValue; + Debug.Assert(i >= 0); + if (negFlag) + i = -i; + sqlite3VdbeAddOp2(v, OP_Integer, i, iMem); + } else { + int c; + i64 value = 0; + string z = pExpr.u.zToken; + Debug.Assert(!string.IsNullOrEmpty(z)); + c = sqlite3Atoi64(z, ref value, sqlite3Strlen30(z), SQLITE_UTF8); + if (c == 0 || (c == 2 && negFlag)) { + //char* zV; + if (negFlag) { + value = c == 2 ? SMALLEST_INT64 : -value; + } + sqlite3VdbeAddOp4(v, OP_Int64, 0, iMem, 0, value, P4_INT64); + } else { #if SQLITE_OMIT_FLOATING_POINT sqlite3ErrorMsg(pParse, "oversized integer: %s%s", negFlag ? "-" : string.Empty, z); #else - codeReal( v, z, negFlag, iMem ); + codeReal(v, z, negFlag, iMem); #endif + } + } } - } - } - /* - ** Clear a cache entry. - */ - static void cacheEntryClear( Parse pParse, yColCache p ) - { - if ( p.tempReg != 0 ) - { - if ( pParse.nTempReg < ArraySize( pParse.aTempReg ) ) - { - pParse.aTempReg[pParse.nTempReg++] = p.iReg; + /* + ** Clear a cache entry. + */ + static void cacheEntryClear(Parse pParse, yColCache p) { + if (p.tempReg != 0) { + if (pParse.nTempReg < ArraySize(pParse.aTempReg)) { + pParse.aTempReg[pParse.nTempReg++] = p.iReg; + } + p.tempReg = 0; + } } - p.tempReg = 0; - } - } - /* - ** Record in the column cache that a particular column from a - ** particular table is stored in a particular register. - */ - static void sqlite3ExprCacheStore( Parse pParse, int iTab, int iCol, int iReg ) - { - int i; - int minLru; - int idxLru; - yColCache p = new yColCache(); - - Debug.Assert( iReg > 0 ); /* Register numbers are always positive */ - Debug.Assert( iCol >= -1 && iCol < 32768 ); /* Finite column numbers */ - - /* The SQLITE_ColumnCache flag disables the column cache. This is used - ** for testing only - to verify that SQLite always gets the same answer - ** with and without the column cache. - */ - if ( ( pParse.db.flags & SQLITE_ColumnCache ) != 0 ) - return; - - /* First replace any existing entry. - ** - ** Actually, the way the column cache is currently used, we are guaranteed - ** that the object will never already be in cache. Verify this guarantee. - */ + /* + ** Record in the column cache that a particular column from a + ** particular table is stored in a particular register. + */ + static void sqlite3ExprCacheStore(Parse pParse, int iTab, int iCol, int iReg) { + int i; + int minLru; + int idxLru; + yColCache p = new yColCache(); + + Debug.Assert(iReg > 0); /* Register numbers are always positive */ + Debug.Assert(iCol >= -1 && iCol < 32768); /* Finite column numbers */ + + /* The SQLITE_ColumnCache flag disables the column cache. This is used + ** for testing only - to verify that SQLite always gets the same answer + ** with and without the column cache. + */ + if ((pParse.db.flags & SQLITE_ColumnCache) != 0) + return; + + /* First replace any existing entry. + ** + ** Actually, the way the column cache is currently used, we are guaranteed + ** that the object will never already be in cache. Verify this guarantee. + */ #if !NDEBUG - for ( i = 0; i < SQLITE_N_COLCACHE; i++ )//p=pParse.aColCache... p++) - { + for (i = 0; i < SQLITE_N_COLCACHE; i++)//p=pParse.aColCache... p++) + { #if FALSE //* This code wold remove the entry from the cache if it existed */ p = pParse.aColCache[i]; if ( p.iReg != 0 && p.iTable == iTab && p.iColumn == iCol ) @@ -2430,1415 +2172,1268 @@ static void sqlite3ExprCacheStore( Parse pParse, int iTab, int iCol, int iReg ) return; } #endif - Debug.Assert( p.iReg == 0 || p.iTable != iTab || p.iColumn != iCol ); - } + Debug.Assert(p.iReg == 0 || p.iTable != iTab || p.iColumn != iCol); + } #endif - /* Find an empty slot and replace it */ - for ( i = 0; i < SQLITE_N_COLCACHE; i++ )//p=pParse.aColCache... p++) - { - p = pParse.aColCache[i]; - if ( p.iReg == 0 ) - { - p.iLevel = pParse.iCacheLevel; - p.iTable = iTab; - p.iColumn = iCol; - p.iReg = iReg; - p.tempReg = 0; - p.lru = pParse.iCacheCnt++; - return; - } - } - - /* Replace the last recently used */ - minLru = 0x7fffffff; - idxLru = -1; - for ( i = 0; i < SQLITE_N_COLCACHE; i++ )//p=pParse.aColCache..., p++) - { - p = pParse.aColCache[i]; - if ( p.lru < minLru ) - { - idxLru = i; - minLru = p.lru; + /* Find an empty slot and replace it */ + for (i = 0; i < SQLITE_N_COLCACHE; i++)//p=pParse.aColCache... p++) + { + p = pParse.aColCache[i]; + if (p.iReg == 0) { + p.iLevel = pParse.iCacheLevel; + p.iTable = iTab; + p.iColumn = iCol; + p.iReg = iReg; + p.tempReg = 0; + p.lru = pParse.iCacheCnt++; + return; + } + } + + /* Replace the last recently used */ + minLru = 0x7fffffff; + idxLru = -1; + for (i = 0; i < SQLITE_N_COLCACHE; i++)//p=pParse.aColCache..., p++) + { + p = pParse.aColCache[i]; + if (p.lru < minLru) { + idxLru = i; + minLru = p.lru; + } + } + if (ALWAYS(idxLru >= 0)) { + p = pParse.aColCache[idxLru]; + p.iLevel = pParse.iCacheLevel; + p.iTable = iTab; + p.iColumn = iCol; + p.iReg = iReg; + p.tempReg = 0; + p.lru = pParse.iCacheCnt++; + return; + } } - } - if ( ALWAYS( idxLru >= 0 ) ) - { - p = pParse.aColCache[idxLru]; - p.iLevel = pParse.iCacheLevel; - p.iTable = iTab; - p.iColumn = iCol; - p.iReg = iReg; - p.tempReg = 0; - p.lru = pParse.iCacheCnt++; - return; - } - } - /* - ** Indicate that registers between iReg..iReg+nReg-1 are being overwritten. - ** Purge the range of registers from the column cache. - */ - static void sqlite3ExprCacheRemove( Parse pParse, int iReg, int nReg ) - { - int i; - int iLast = iReg + nReg - 1; - yColCache p; - for ( i = 0; i < SQLITE_N_COLCACHE; i++ )//p=pParse.aColCache... p++) - { - p = pParse.aColCache[i]; - int r = p.iReg; - if ( r >= iReg && r <= iLast ) - { - cacheEntryClear( pParse, p ); - p.iReg = 0; + /* + ** Indicate that registers between iReg..iReg+nReg-1 are being overwritten. + ** Purge the range of registers from the column cache. + */ + static void sqlite3ExprCacheRemove(Parse pParse, int iReg, int nReg) { + int i; + int iLast = iReg + nReg - 1; + yColCache p; + for (i = 0; i < SQLITE_N_COLCACHE; i++)//p=pParse.aColCache... p++) + { + p = pParse.aColCache[i]; + int r = p.iReg; + if (r >= iReg && r <= iLast) { + cacheEntryClear(pParse, p); + p.iReg = 0; + } + } } - } - } - /* - ** Remember the current column cache context. Any new entries added - ** added to the column cache after this call are removed when the - ** corresponding pop occurs. - */ - static void sqlite3ExprCachePush( Parse pParse ) - { - pParse.iCacheLevel++; - } + /* + ** Remember the current column cache context. Any new entries added + ** added to the column cache after this call are removed when the + ** corresponding pop occurs. + */ + static void sqlite3ExprCachePush(Parse pParse) { + pParse.iCacheLevel++; + } - /* - ** Remove from the column cache any entries that were added since the - ** the previous N Push operations. In other words, restore the cache - ** to the state it was in N Pushes ago. - */ - static void sqlite3ExprCachePop( Parse pParse, int N ) - { - int i; - yColCache p; - Debug.Assert( N > 0 ); - Debug.Assert( pParse.iCacheLevel >= N ); - pParse.iCacheLevel -= N; - for ( i = 0; i < SQLITE_N_COLCACHE; i++ )// p++) - { - p = pParse.aColCache[i]; - if ( p.iReg != 0 && p.iLevel > pParse.iCacheLevel ) - { - cacheEntryClear( pParse, p ); - p.iReg = 0; + /* + ** Remove from the column cache any entries that were added since the + ** the previous N Push operations. In other words, restore the cache + ** to the state it was in N Pushes ago. + */ + static void sqlite3ExprCachePop(Parse pParse, int N) { + int i; + yColCache p; + Debug.Assert(N > 0); + Debug.Assert(pParse.iCacheLevel >= N); + pParse.iCacheLevel -= N; + for (i = 0; i < SQLITE_N_COLCACHE; i++)// p++) + { + p = pParse.aColCache[i]; + if (p.iReg != 0 && p.iLevel > pParse.iCacheLevel) { + cacheEntryClear(pParse, p); + p.iReg = 0; + } + } } - } - } - /* - ** When a cached column is reused, make sure that its register is - ** no longer available as a temp register. ticket #3879: that same - ** register might be in the cache in multiple places, so be sure to - ** get them all. - */ - static void sqlite3ExprCachePinRegister( Parse pParse, int iReg ) - { - int i; - yColCache p; - for ( i = 0; i < SQLITE_N_COLCACHE; i++ )//p=pParse->aColCache; iaColCache; i= 0 ) - { - sqlite3ColumnDefault( v, pTab, iCol, regOut ); - } - } + /* + ** Generate code to extract the value of the iCol-th column of a table. + */ + static void sqlite3ExprCodeGetColumnOfTable( + Vdbe v, /* The VDBE under construction */ + Table pTab, /* The table containing the value */ + int iTabCur, /* The cursor for this table */ + int iCol, /* Index of the column to extract */ + int regOut /* Extract the value into this register */ + ) { + if (iCol < 0 || iCol == pTab.iPKey) { + sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut); + } else { + int op = IsVirtual(pTab) ? OP_VColumn : OP_Column; + sqlite3VdbeAddOp3(v, op, iTabCur, iCol, regOut); + } + if (iCol >= 0) { + sqlite3ColumnDefault(v, pTab, iCol, regOut); + } + } - /* - ** Generate code that will extract the iColumn-th column from - ** table pTab and store the column value in a register. An effort - ** is made to store the column value in register iReg, but this is - ** not guaranteed. The location of the column value is returned. - ** - ** There must be an open cursor to pTab in iTable when this routine - ** is called. If iColumn<0 then code is generated that extracts the rowid. - */ - static int sqlite3ExprCodeGetColumn( - Parse pParse, /* Parsing and code generating context */ - Table pTab, /* Description of the table we are reading from */ - int iColumn, /* Index of the table column */ - int iTable, /* The cursor pointing to the table */ - int iReg /* Store results here */ - ) - { - Vdbe v = pParse.pVdbe; - int i; - yColCache p; - - for ( i = 0; i < SQLITE_N_COLCACHE; i++ ) - {// p=pParse.aColCache, p++ - p = pParse.aColCache[i]; - if ( p.iReg > 0 && p.iTable == iTable && p.iColumn == iColumn ) - { - p.lru = pParse.iCacheCnt++; - sqlite3ExprCachePinRegister( pParse, p.iReg ); - return p.iReg; + /* + ** Generate code that will extract the iColumn-th column from + ** table pTab and store the column value in a register. An effort + ** is made to store the column value in register iReg, but this is + ** not guaranteed. The location of the column value is returned. + ** + ** There must be an open cursor to pTab in iTable when this routine + ** is called. If iColumn<0 then code is generated that extracts the rowid. + */ + static int sqlite3ExprCodeGetColumn( + Parse pParse, /* Parsing and code generating context */ + Table pTab, /* Description of the table we are reading from */ + int iColumn, /* Index of the table column */ + int iTable, /* The cursor pointing to the table */ + int iReg /* Store results here */ + ) { + Vdbe v = pParse.pVdbe; + int i; + yColCache p; + + for (i = 0; i < SQLITE_N_COLCACHE; i++) {// p=pParse.aColCache, p++ + p = pParse.aColCache[i]; + if (p.iReg > 0 && p.iTable == iTable && p.iColumn == iColumn) { + p.lru = pParse.iCacheCnt++; + sqlite3ExprCachePinRegister(pParse, p.iReg); + return p.iReg; + } + } + Debug.Assert(v != null); + sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg); + sqlite3ExprCacheStore(pParse, iTable, iColumn, iReg); + return iReg; } - } - Debug.Assert( v != null ); - sqlite3ExprCodeGetColumnOfTable( v, pTab, iTable, iColumn, iReg ); - sqlite3ExprCacheStore( pParse, iTable, iColumn, iReg ); - return iReg; - } - /* - ** Clear all column cache entries. - */ - static void sqlite3ExprCacheClear( Parse pParse ) - { - int i; - yColCache p; - - for ( i = 0; i < SQLITE_N_COLCACHE; i++ )// p=pParse.aColCache... p++) - { - p = pParse.aColCache[i]; - if ( p.iReg != 0 ) - { - cacheEntryClear( pParse, p ); - p.iReg = 0; + /* + ** Clear all column cache entries. + */ + static void sqlite3ExprCacheClear(Parse pParse) { + int i; + yColCache p; + + for (i = 0; i < SQLITE_N_COLCACHE; i++)// p=pParse.aColCache... p++) + { + p = pParse.aColCache[i]; + if (p.iReg != 0) { + cacheEntryClear(pParse, p); + p.iReg = 0; + } + } } - } - } - /* - ** Record the fact that an affinity change has occurred on iCount - ** registers starting with iStart. - */ - static void sqlite3ExprCacheAffinityChange( Parse pParse, int iStart, int iCount ) - { - sqlite3ExprCacheRemove( pParse, iStart, iCount ); - } + /* + ** Record the fact that an affinity change has occurred on iCount + ** registers starting with iStart. + */ + static void sqlite3ExprCacheAffinityChange(Parse pParse, int iStart, int iCount) { + sqlite3ExprCacheRemove(pParse, iStart, iCount); + } - /* - ** Generate code to move content from registers iFrom...iFrom+nReg-1 - ** over to iTo..iTo+nReg-1. Keep the column cache up-to-date. - */ - static void sqlite3ExprCodeMove( Parse pParse, int iFrom, int iTo, int nReg ) - { - int i; - yColCache p; - if ( NEVER( iFrom == iTo ) ) - return; - sqlite3VdbeAddOp3( pParse.pVdbe, OP_Move, iFrom, iTo, nReg ); - for ( i = 0; i < SQLITE_N_COLCACHE; i++ )// p=pParse.aColCache... p++) - { - p = pParse.aColCache[i]; - int x = p.iReg; - if ( x >= iFrom && x < iFrom + nReg ) - { - p.iReg += iTo - iFrom; + /* + ** Generate code to move content from registers iFrom...iFrom+nReg-1 + ** over to iTo..iTo+nReg-1. Keep the column cache up-to-date. + */ + static void sqlite3ExprCodeMove(Parse pParse, int iFrom, int iTo, int nReg) { + int i; + yColCache p; + if (NEVER(iFrom == iTo)) + return; + sqlite3VdbeAddOp3(pParse.pVdbe, OP_Move, iFrom, iTo, nReg); + for (i = 0; i < SQLITE_N_COLCACHE; i++)// p=pParse.aColCache... p++) + { + p = pParse.aColCache[i]; + int x = p.iReg; + if (x >= iFrom && x < iFrom + nReg) { + p.iReg += iTo - iFrom; + } + } } - } - } - /* - ** Generate code to copy content from registers iFrom...iFrom+nReg-1 - ** over to iTo..iTo+nReg-1. - */ - static void sqlite3ExprCodeCopy( Parse pParse, int iFrom, int iTo, int nReg ) - { - int i; - if ( NEVER( iFrom == iTo ) ) - return; - for ( i = 0; i < nReg; i++ ) - { - sqlite3VdbeAddOp2( pParse.pVdbe, OP_Copy, iFrom + i, iTo + i ); - } - } + /* + ** Generate code to copy content from registers iFrom...iFrom+nReg-1 + ** over to iTo..iTo+nReg-1. + */ + static void sqlite3ExprCodeCopy(Parse pParse, int iFrom, int iTo, int nReg) { + int i; + if (NEVER(iFrom == iTo)) + return; + for (i = 0; i < nReg; i++) { + sqlite3VdbeAddOp2(pParse.pVdbe, OP_Copy, iFrom + i, iTo + i); + } + } #if (SQLITE_DEBUG) || (SQLITE_COVERAGE_TEST) - /* -** Return true if any register in the range iFrom..iTo (inclusive) -** is used as part of the column cache. -** -** This routine is used within Debug.Assert() and testcase() macros only -** and does not appear in a normal build. -*/ - static int usedAsColumnCache( Parse pParse, int iFrom, int iTo ) - { - int i; - yColCache p; - for ( i = 0; i < SQLITE_N_COLCACHE; i++ )//p=pParse.aColCache... p++) - { - p = pParse.aColCache[i]; - int r = p.iReg; - if ( r >= iFrom && r <= iTo ) - return 1; /*NO_TEST*/ - } - return 0; - } + /* + ** Return true if any register in the range iFrom..iTo (inclusive) + ** is used as part of the column cache. + ** + ** This routine is used within Debug.Assert() and testcase() macros only + ** and does not appear in a normal build. + */ + static int usedAsColumnCache(Parse pParse, int iFrom, int iTo) { + int i; + yColCache p; + for (i = 0; i < SQLITE_N_COLCACHE; i++)//p=pParse.aColCache... p++) + { + p = pParse.aColCache[i]; + int r = p.iReg; + if (r >= iFrom && r <= iTo) + return 1; /*NO_TEST*/ + } + return 0; + } #else static int usedAsColumnCache( Parse pParse, int iFrom, int iTo ){return 0;} #endif //* SQLITE_DEBUG || SQLITE_COVERAGE_TEST */ - /* - ** 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. - ** - ** With this routine, there is no guarantee that results will - ** be stored in target. The result might be stored in some other - ** register if it is convenient to do so. The calling function - ** must check the return code and move the results to the desired - ** register. - */ - static int sqlite3ExprCodeTarget( Parse pParse, Expr pExpr, int target ) - { - Vdbe v = pParse.pVdbe; /* The VM under construction */ - int op; /* The opcode being coded */ - int inReg = target; /* Results stored in register inReg */ - int regFree1 = 0; /* If non-zero free this temporary register */ - int regFree2 = 0; /* If non-zero free this temporary register */ - int r1 = 0, r2 = 0, r3 = 0, r4 = 0; /* Various register numbers */ - sqlite3 db = pParse.db; /* The database connection */ - - Debug.Assert( target > 0 && target <= pParse.nMem ); - if ( v == null ) - { - //Debug.Assert( pParse.db.mallocFailed != 0 ); - return 0; - } - - if ( pExpr == null ) - { - op = TK_NULL; - } - else - { - op = pExpr.op; - } - switch ( op ) - { - case TK_AGG_COLUMN: - { - AggInfo pAggInfo = pExpr.pAggInfo; - AggInfo_col pCol = pAggInfo.aCol[pExpr.iAgg]; - if ( pAggInfo.directMode == 0 ) - { - Debug.Assert( pCol.iMem > 0 ); - inReg = pCol.iMem; - break; - } - else if ( pAggInfo.useSortingIdx != 0 ) - { - sqlite3VdbeAddOp3( v, OP_Column, pAggInfo.sortingIdx, - pCol.iSorterColumn, target ); - break; - } - /* Otherwise, fall thru into the TK_COLUMN case */ - } - goto case TK_COLUMN; - case TK_COLUMN: - { - if ( pExpr.iTable < 0 ) - { - /* This only happens when coding check constraints */ - Debug.Assert( pParse.ckBase > 0 ); - inReg = pExpr.iColumn + pParse.ckBase; + /* + ** 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. + ** + ** With this routine, there is no guarantee that results will + ** be stored in target. The result might be stored in some other + ** register if it is convenient to do so. The calling function + ** must check the return code and move the results to the desired + ** register. + */ + static int sqlite3ExprCodeTarget(Parse pParse, Expr pExpr, int target) { + Vdbe v = pParse.pVdbe; /* The VM under construction */ + int op; /* The opcode being coded */ + int inReg = target; /* Results stored in register inReg */ + int regFree1 = 0; /* If non-zero free this temporary register */ + int regFree2 = 0; /* If non-zero free this temporary register */ + int r1 = 0, r2 = 0, r3 = 0, r4 = 0; /* Various register numbers */ + sqlite3 db = pParse.db; /* The database connection */ + + Debug.Assert(target > 0 && target <= pParse.nMem); + if (v == null) { + //Debug.Assert( pParse.db.mallocFailed != 0 ); + return 0; } - else - { - inReg = sqlite3ExprCodeGetColumn( pParse, pExpr.pTab, - pExpr.iColumn, pExpr.iTable, target ); + + if (pExpr == null) { + op = TK_NULL; + } else { + op = pExpr.op; } - break; - } - case TK_INTEGER: - { - codeInteger( pParse, pExpr, false, target ); - break; - } + switch (op) { + case TK_AGG_COLUMN: { + AggInfo pAggInfo = pExpr.pAggInfo; + AggInfo_col pCol = pAggInfo.aCol[pExpr.iAgg]; + if (pAggInfo.directMode == 0) { + Debug.Assert(pCol.iMem > 0); + inReg = pCol.iMem; + break; + } else if (pAggInfo.useSortingIdx != 0) { + sqlite3VdbeAddOp3(v, OP_Column, pAggInfo.sortingIdx, + pCol.iSorterColumn, target); + break; + } + /* Otherwise, fall thru into the TK_COLUMN case */ + } + goto case TK_COLUMN; + case TK_COLUMN: { + if (pExpr.iTable < 0) { + /* This only happens when coding check constraints */ + Debug.Assert(pParse.ckBase > 0); + inReg = pExpr.iColumn + pParse.ckBase; + } else { + inReg = sqlite3ExprCodeGetColumn(pParse, pExpr.pTab, + pExpr.iColumn, pExpr.iTable, target); + } + break; + } + case TK_INTEGER: { + codeInteger(pParse, pExpr, false, target); + break; + } #if !SQLITE_OMIT_FLOATING_POINT - case TK_FLOAT: - { - Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); - codeReal( v, pExpr.u.zToken, false, target ); - break; - } + case TK_FLOAT: { + Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); + codeReal(v, pExpr.u.zToken, false, target); + break; + } #endif - case TK_STRING: - { - Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); - sqlite3VdbeAddOp4( v, OP_String8, 0, target, 0, pExpr.u.zToken, 0 ); - break; - } - case TK_NULL: - { - sqlite3VdbeAddOp2( v, OP_Null, 0, target ); - break; - } + case TK_STRING: { + Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); + sqlite3VdbeAddOp4(v, OP_String8, 0, target, 0, pExpr.u.zToken, 0); + break; + } + case TK_NULL: { + sqlite3VdbeAddOp2(v, OP_Null, 0, target); + break; + } #if !SQLITE_OMIT_BLOB_LITERAL - case TK_BLOB: - { - int n; - string z; - byte[] zBlob; - Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); - Debug.Assert( pExpr.u.zToken[0] == 'x' || pExpr.u.zToken[0] == 'X' ); - Debug.Assert( pExpr.u.zToken[1] == '\'' ); - z = pExpr.u.zToken.Substring( 2 ); - n = sqlite3Strlen30( z ) - 1; - Debug.Assert( z[n] == '\'' ); - zBlob = sqlite3HexToBlob( sqlite3VdbeDb( v ), z, n ); - sqlite3VdbeAddOp4( v, OP_Blob, n / 2, target, 0, zBlob, P4_DYNAMIC ); - break; - } + case TK_BLOB: { + int n; + string z; + byte[] zBlob; + Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); + Debug.Assert(pExpr.u.zToken[0] == 'x' || pExpr.u.zToken[0] == 'X'); + Debug.Assert(pExpr.u.zToken[1] == '\''); + z = pExpr.u.zToken.Substring(2); + n = sqlite3Strlen30(z) - 1; + Debug.Assert(z[n] == '\''); + zBlob = sqlite3HexToBlob(sqlite3VdbeDb(v), z, n); + sqlite3VdbeAddOp4(v, OP_Blob, n / 2, target, 0, zBlob, P4_DYNAMIC); + break; + } #endif - case TK_VARIABLE: - { - Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); - Debug.Assert( pExpr.u.zToken != null ); - Debug.Assert( pExpr.u.zToken.Length != 0 ); - sqlite3VdbeAddOp2( v, OP_Variable, pExpr.iColumn, target ); - if ( pExpr.u.zToken.Length > 1 ) - { - Debug.Assert( pExpr.u.zToken[0] == '?' - || string.Equals(pExpr.u.zToken, pParse.azVar[pExpr.iColumn - 1], StringComparison.Ordinal) ); - sqlite3VdbeChangeP4( v, -1, pParse.azVar[pExpr.iColumn - 1], P4_STATIC ); - } - break; - } - case TK_REGISTER: - { - inReg = pExpr.iTable; - break; - } - case TK_AS: - { - inReg = sqlite3ExprCodeTarget( pParse, pExpr.pLeft, target ); - break; - } + case TK_VARIABLE: { + Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); + Debug.Assert(pExpr.u.zToken != null); + Debug.Assert(pExpr.u.zToken.Length != 0); + sqlite3VdbeAddOp2(v, OP_Variable, pExpr.iColumn, target); + if (pExpr.u.zToken.Length > 1) { + Debug.Assert(pExpr.u.zToken[0] == '?' + || string.Equals(pExpr.u.zToken, pParse.azVar[pExpr.iColumn - 1], StringComparison.Ordinal)); + sqlite3VdbeChangeP4(v, -1, pParse.azVar[pExpr.iColumn - 1], P4_STATIC); + } + break; + } + case TK_REGISTER: { + inReg = pExpr.iTable; + break; + } + case TK_AS: { + inReg = sqlite3ExprCodeTarget(pParse, pExpr.pLeft, target); + break; + } #if !SQLITE_OMIT_CAST - case TK_CAST: - { - /* Expressions of the form: CAST(pLeft AS token) */ - int aff, to_op; - inReg = sqlite3ExprCodeTarget( pParse, pExpr.pLeft, target ); - Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); - aff = sqlite3AffinityType( pExpr.u.zToken ); - to_op = aff - SQLITE_AFF_TEXT + OP_ToText; - Debug.Assert( to_op == OP_ToText || aff != SQLITE_AFF_TEXT ); - Debug.Assert( to_op == OP_ToBlob || aff != SQLITE_AFF_NONE ); - Debug.Assert( to_op == OP_ToNumeric || aff != SQLITE_AFF_NUMERIC ); - Debug.Assert( to_op == OP_ToInt || aff != SQLITE_AFF_INTEGER ); - Debug.Assert( to_op == OP_ToReal || aff != SQLITE_AFF_REAL ); - testcase( to_op == OP_ToText ); - testcase( to_op == OP_ToBlob ); - testcase( to_op == OP_ToNumeric ); - testcase( to_op == OP_ToInt ); - testcase( to_op == OP_ToReal ); - if ( inReg != target ) - { - sqlite3VdbeAddOp2( v, OP_SCopy, inReg, target ); - inReg = target; - } - sqlite3VdbeAddOp1( v, to_op, inReg ); - testcase( usedAsColumnCache( pParse, inReg, inReg ) != 0 ); - sqlite3ExprCacheAffinityChange( pParse, inReg, 1 ); - break; - } + case TK_CAST: { + /* Expressions of the form: CAST(pLeft AS token) */ + int aff, to_op; + inReg = sqlite3ExprCodeTarget(pParse, pExpr.pLeft, target); + Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); + aff = sqlite3AffinityType(pExpr.u.zToken); + to_op = aff - SQLITE_AFF_TEXT + OP_ToText; + Debug.Assert(to_op == OP_ToText || aff != SQLITE_AFF_TEXT); + Debug.Assert(to_op == OP_ToBlob || aff != SQLITE_AFF_NONE); + Debug.Assert(to_op == OP_ToNumeric || aff != SQLITE_AFF_NUMERIC); + Debug.Assert(to_op == OP_ToInt || aff != SQLITE_AFF_INTEGER); + Debug.Assert(to_op == OP_ToReal || aff != SQLITE_AFF_REAL); + testcase(to_op == OP_ToText); + testcase(to_op == OP_ToBlob); + testcase(to_op == OP_ToNumeric); + testcase(to_op == OP_ToInt); + testcase(to_op == OP_ToReal); + if (inReg != target) { + sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target); + inReg = target; + } + sqlite3VdbeAddOp1(v, to_op, inReg); + testcase(usedAsColumnCache(pParse, inReg, inReg) != 0); + sqlite3ExprCacheAffinityChange(pParse, inReg, 1); + break; + } #endif // * SQLITE_OMIT_CAST */ - case TK_LT: - case TK_LE: - case TK_GT: - case TK_GE: - case TK_NE: - case TK_EQ: - { - Debug.Assert( TK_LT == OP_Lt ); - Debug.Assert( TK_LE == OP_Le ); - Debug.Assert( TK_GT == OP_Gt ); - Debug.Assert( TK_GE == OP_Ge ); - Debug.Assert( TK_EQ == OP_Eq ); - Debug.Assert( TK_NE == OP_Ne ); - testcase( op == TK_LT ); - testcase( op == TK_LE ); - testcase( op == TK_GT ); - testcase( op == TK_GE ); - testcase( op == TK_EQ ); - testcase( op == TK_NE ); - r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); - r2 = sqlite3ExprCodeTemp( pParse, pExpr.pRight, ref regFree2 ); - codeCompare( pParse, pExpr.pLeft, pExpr.pRight, op, - r1, r2, inReg, SQLITE_STOREP2 ); - testcase( regFree1 == 0 ); - testcase( regFree2 == 0 ); - break; - } - case TK_IS: - case TK_ISNOT: - { - testcase( op == TK_IS ); - testcase( op == TK_ISNOT ); - r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); - r2 = sqlite3ExprCodeTemp( pParse, pExpr.pRight, ref regFree2 ); - op = ( op == TK_IS ) ? TK_EQ : TK_NE; - codeCompare( pParse, pExpr.pLeft, pExpr.pRight, op, - r1, r2, inReg, SQLITE_STOREP2 | SQLITE_NULLEQ ); - testcase( regFree1 == 0 ); - testcase( regFree2 == 0 ); - break; - } - case TK_AND: - case TK_OR: - case TK_PLUS: - case TK_STAR: - case TK_MINUS: - case TK_REM: - case TK_BITAND: - case TK_BITOR: - case TK_SLASH: - case TK_LSHIFT: - case TK_RSHIFT: - case TK_CONCAT: - { - Debug.Assert( TK_AND == OP_And ); - Debug.Assert( TK_OR == OP_Or ); - Debug.Assert( TK_PLUS == OP_Add ); - Debug.Assert( TK_MINUS == OP_Subtract ); - Debug.Assert( TK_REM == OP_Remainder ); - Debug.Assert( TK_BITAND == OP_BitAnd ); - Debug.Assert( TK_BITOR == OP_BitOr ); - Debug.Assert( TK_SLASH == OP_Divide ); - Debug.Assert( TK_LSHIFT == OP_ShiftLeft ); - Debug.Assert( TK_RSHIFT == OP_ShiftRight ); - Debug.Assert( TK_CONCAT == OP_Concat ); - testcase( op == TK_AND ); - testcase( op == TK_OR ); - testcase( op == TK_PLUS ); - testcase( op == TK_MINUS ); - testcase( op == TK_REM ); - testcase( op == TK_BITAND ); - testcase( op == TK_BITOR ); - testcase( op == TK_SLASH ); - testcase( op == TK_LSHIFT ); - testcase( op == TK_RSHIFT ); - testcase( op == TK_CONCAT ); - r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); - r2 = sqlite3ExprCodeTemp( pParse, pExpr.pRight, ref regFree2 ); - sqlite3VdbeAddOp3( v, op, r2, r1, target ); - testcase( regFree1 == 0 ); - testcase( regFree2 == 0 ); - break; - } - case TK_UMINUS: - { - Expr pLeft = pExpr.pLeft; - Debug.Assert( pLeft != null ); - if ( pLeft.op == TK_INTEGER ) - { - codeInteger( pParse, pLeft, true, target ); + case TK_LT: + case TK_LE: + case TK_GT: + case TK_GE: + case TK_NE: + case TK_EQ: { + Debug.Assert(TK_LT == OP_Lt); + Debug.Assert(TK_LE == OP_Le); + Debug.Assert(TK_GT == OP_Gt); + Debug.Assert(TK_GE == OP_Ge); + Debug.Assert(TK_EQ == OP_Eq); + Debug.Assert(TK_NE == OP_Ne); + testcase(op == TK_LT); + testcase(op == TK_LE); + testcase(op == TK_GT); + testcase(op == TK_GE); + testcase(op == TK_EQ); + testcase(op == TK_NE); + r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); + r2 = sqlite3ExprCodeTemp(pParse, pExpr.pRight, ref regFree2); + codeCompare(pParse, pExpr.pLeft, pExpr.pRight, op, + r1, r2, inReg, SQLITE_STOREP2); + testcase(regFree1 == 0); + testcase(regFree2 == 0); + break; + } + case TK_IS: + case TK_ISNOT: { + testcase(op == TK_IS); + testcase(op == TK_ISNOT); + r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); + r2 = sqlite3ExprCodeTemp(pParse, pExpr.pRight, ref regFree2); + op = (op == TK_IS) ? TK_EQ : TK_NE; + codeCompare(pParse, pExpr.pLeft, pExpr.pRight, op, + r1, r2, inReg, SQLITE_STOREP2 | SQLITE_NULLEQ); + testcase(regFree1 == 0); + testcase(regFree2 == 0); + break; + } + case TK_AND: + case TK_OR: + case TK_PLUS: + case TK_STAR: + case TK_MINUS: + case TK_REM: + case TK_BITAND: + case TK_BITOR: + case TK_SLASH: + case TK_LSHIFT: + case TK_RSHIFT: + case TK_CONCAT: { + Debug.Assert(TK_AND == OP_And); + Debug.Assert(TK_OR == OP_Or); + Debug.Assert(TK_PLUS == OP_Add); + Debug.Assert(TK_MINUS == OP_Subtract); + Debug.Assert(TK_REM == OP_Remainder); + Debug.Assert(TK_BITAND == OP_BitAnd); + Debug.Assert(TK_BITOR == OP_BitOr); + Debug.Assert(TK_SLASH == OP_Divide); + Debug.Assert(TK_LSHIFT == OP_ShiftLeft); + Debug.Assert(TK_RSHIFT == OP_ShiftRight); + Debug.Assert(TK_CONCAT == OP_Concat); + testcase(op == TK_AND); + testcase(op == TK_OR); + testcase(op == TK_PLUS); + testcase(op == TK_MINUS); + testcase(op == TK_REM); + testcase(op == TK_BITAND); + testcase(op == TK_BITOR); + testcase(op == TK_SLASH); + testcase(op == TK_LSHIFT); + testcase(op == TK_RSHIFT); + testcase(op == TK_CONCAT); + r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); + r2 = sqlite3ExprCodeTemp(pParse, pExpr.pRight, ref regFree2); + sqlite3VdbeAddOp3(v, op, r2, r1, target); + testcase(regFree1 == 0); + testcase(regFree2 == 0); + break; + } + case TK_UMINUS: { + Expr pLeft = pExpr.pLeft; + Debug.Assert(pLeft != null); + if (pLeft.op == TK_INTEGER) { + codeInteger(pParse, pLeft, true, target); #if !SQLITE_OMIT_FLOATING_POINT - } - else if ( pLeft.op == TK_FLOAT ) - { - Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); - codeReal( v, pLeft.u.zToken, true, target ); + } else if (pLeft.op == TK_FLOAT) { + Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); + codeReal(v, pLeft.u.zToken, true, target); #endif - } - else - { - regFree1 = r1 = sqlite3GetTempReg( pParse ); - sqlite3VdbeAddOp2( v, OP_Integer, 0, r1 ); - r2 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree2 ); - sqlite3VdbeAddOp3( v, OP_Subtract, r2, r1, target ); - testcase( regFree2 == 0 ); - } - inReg = target; - break; - } - case TK_BITNOT: - case TK_NOT: - { - Debug.Assert( TK_BITNOT == OP_BitNot ); - Debug.Assert( TK_NOT == OP_Not ); - testcase( op == TK_BITNOT ); - testcase( op == TK_NOT ); - r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); - testcase( regFree1 == 0 ); - inReg = target; - sqlite3VdbeAddOp2( v, op, r1, inReg ); - break; - } - case TK_ISNULL: - case TK_NOTNULL: - { - int addr; - Debug.Assert( TK_ISNULL == OP_IsNull ); - Debug.Assert( TK_NOTNULL == OP_NotNull ); - testcase( op == TK_ISNULL ); - testcase( op == TK_NOTNULL ); - sqlite3VdbeAddOp2( v, OP_Integer, 1, target ); - r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); - testcase( regFree1 == 0 ); - addr = sqlite3VdbeAddOp1( v, op, r1 ); - sqlite3VdbeAddOp2( v, OP_AddImm, target, -1 ); - sqlite3VdbeJumpHere( v, addr ); - break; - } - case TK_AGG_FUNCTION: - { - AggInfo pInfo = pExpr.pAggInfo; - if ( pInfo == null ) - { - Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); - sqlite3ErrorMsg( pParse, "misuse of aggregate: %s()", pExpr.u.zToken ); - } - else - { - inReg = pInfo.aFunc[pExpr.iAgg].iMem; - } - break; - } - case TK_CONST_FUNC: - case TK_FUNCTION: - { - ExprList pFarg; /* List of function arguments */ - int nFarg; /* Number of function arguments */ - FuncDef pDef; /* The function definition object */ - int nId; /* Length of the function name in bytes */ - string zId; /* The function name */ - int constMask = 0; /* Mask of function arguments that are constant */ - int i; /* Loop counter */ - u8 enc = ENC( db ); /* The text encoding used by this database */ - CollSeq pColl = null; /* A collating sequence */ - - Debug.Assert( !ExprHasProperty( pExpr, EP_xIsSelect ) ); - testcase( op == TK_CONST_FUNC ); - testcase( op == TK_FUNCTION ); - if ( ExprHasAnyProperty( pExpr, EP_TokenOnly ) ) - { - pFarg = null; - } - else - { - pFarg = pExpr.x.pList; - } - nFarg = pFarg != null ? pFarg.nExpr : 0; - Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); - zId = pExpr.u.zToken; - nId = sqlite3Strlen30( zId ); - pDef = sqlite3FindFunction( pParse.db, zId, nId, nFarg, enc, 0 ); - if ( pDef == null ) - { - sqlite3ErrorMsg( pParse, "unknown function: %.*s()", nId, zId ); - break; - } + } else { + regFree1 = r1 = sqlite3GetTempReg(pParse); + sqlite3VdbeAddOp2(v, OP_Integer, 0, r1); + r2 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree2); + sqlite3VdbeAddOp3(v, OP_Subtract, r2, r1, target); + testcase(regFree2 == 0); + } + inReg = target; + break; + } + case TK_BITNOT: + case TK_NOT: { + Debug.Assert(TK_BITNOT == OP_BitNot); + Debug.Assert(TK_NOT == OP_Not); + testcase(op == TK_BITNOT); + testcase(op == TK_NOT); + r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); + testcase(regFree1 == 0); + inReg = target; + sqlite3VdbeAddOp2(v, op, r1, inReg); + break; + } + case TK_ISNULL: + case TK_NOTNULL: { + int addr; + Debug.Assert(TK_ISNULL == OP_IsNull); + Debug.Assert(TK_NOTNULL == OP_NotNull); + testcase(op == TK_ISNULL); + testcase(op == TK_NOTNULL); + sqlite3VdbeAddOp2(v, OP_Integer, 1, target); + r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); + testcase(regFree1 == 0); + addr = sqlite3VdbeAddOp1(v, op, r1); + sqlite3VdbeAddOp2(v, OP_AddImm, target, -1); + sqlite3VdbeJumpHere(v, addr); + break; + } + case TK_AGG_FUNCTION: { + AggInfo pInfo = pExpr.pAggInfo; + if (pInfo == null) { + Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); + sqlite3ErrorMsg(pParse, "misuse of aggregate: %s()", pExpr.u.zToken); + } else { + inReg = pInfo.aFunc[pExpr.iAgg].iMem; + } + break; + } + case TK_CONST_FUNC: + case TK_FUNCTION: { + ExprList pFarg; /* List of function arguments */ + int nFarg; /* Number of function arguments */ + FuncDef pDef; /* The function definition object */ + int nId; /* Length of the function name in bytes */ + string zId; /* The function name */ + int constMask = 0; /* Mask of function arguments that are constant */ + int i; /* Loop counter */ + u8 enc = ENC(db); /* The text encoding used by this database */ + CollSeq pColl = null; /* A collating sequence */ + + Debug.Assert(!ExprHasProperty(pExpr, EP_xIsSelect)); + testcase(op == TK_CONST_FUNC); + testcase(op == TK_FUNCTION); + if (ExprHasAnyProperty(pExpr, EP_TokenOnly)) { + pFarg = null; + } else { + pFarg = pExpr.x.pList; + } + nFarg = pFarg != null ? pFarg.nExpr : 0; + Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); + zId = pExpr.u.zToken; + nId = sqlite3Strlen30(zId); + pDef = sqlite3FindFunction(pParse.db, zId, nId, nFarg, enc, 0); + if (pDef == null) { + sqlite3ErrorMsg(pParse, "unknown function: %.*s()", nId, zId); + break; + } - /* Attempt a direct implementation of the built-in COALESCE() and - ** IFNULL() functions. This avoids unnecessary evalation of - ** arguments past the first non-NULL argument. - */ - if ( ( pDef.flags & SQLITE_FUNC_COALESCE ) != 0 ) - { - int endCoalesce = sqlite3VdbeMakeLabel( v ); - Debug.Assert( nFarg >= 2 ); - sqlite3ExprCode( pParse, pFarg.a[0].pExpr, target ); - for ( i = 1; i < nFarg; i++ ) - { - sqlite3VdbeAddOp2( v, OP_NotNull, target, endCoalesce ); - sqlite3ExprCacheRemove( pParse, target, 1 ); - sqlite3ExprCachePush( pParse ); - sqlite3ExprCode( pParse, pFarg.a[i].pExpr, target ); - sqlite3ExprCachePop( pParse, 1 ); - } - sqlite3VdbeResolveLabel( v, endCoalesce ); - break; - } + /* Attempt a direct implementation of the built-in COALESCE() and + ** IFNULL() functions. This avoids unnecessary evalation of + ** arguments past the first non-NULL argument. + */ + if ((pDef.flags & SQLITE_FUNC_COALESCE) != 0) { + int endCoalesce = sqlite3VdbeMakeLabel(v); + Debug.Assert(nFarg >= 2); + sqlite3ExprCode(pParse, pFarg.a[0].pExpr, target); + for (i = 1; i < nFarg; i++) { + sqlite3VdbeAddOp2(v, OP_NotNull, target, endCoalesce); + sqlite3ExprCacheRemove(pParse, target, 1); + sqlite3ExprCachePush(pParse); + sqlite3ExprCode(pParse, pFarg.a[i].pExpr, target); + sqlite3ExprCachePop(pParse, 1); + } + sqlite3VdbeResolveLabel(v, endCoalesce); + break; + } - if ( pFarg != null ) - { - r1 = sqlite3GetTempRange( pParse, nFarg ); - sqlite3ExprCachePush( pParse ); /* Ticket 2ea2425d34be */ - sqlite3ExprCodeExprList( pParse, pFarg, r1, true ); - sqlite3ExprCachePop( pParse, 1 ); /* Ticket 2ea2425d34be */ - } - else - { - r1 = 0; - } + if (pFarg != null) { + r1 = sqlite3GetTempRange(pParse, nFarg); + sqlite3ExprCachePush(pParse); /* Ticket 2ea2425d34be */ + sqlite3ExprCodeExprList(pParse, pFarg, r1, true); + sqlite3ExprCachePop(pParse, 1); /* Ticket 2ea2425d34be */ + } else { + r1 = 0; + } #if !SQLITE_OMIT_VIRTUALTABLE -/* Possibly overload the function if the first argument is -** a virtual table column. -** -** For infix functions (LIKE, GLOB, REGEXP, and MATCH) use the -** second argument, not the first, as the argument to test to -** see if it is a column in a virtual table. This is done because -** the left operand of infix functions (the operand we want to -** control overloading) ends up as the second argument to the -** function. The expression "A glob B" is equivalent to -** "glob(B,A). We want to use the A in "A glob B" to test -** for function overloading. But we use the B term in "glob(B,A)". -*/ - if ( nFarg >= 2 && ( pExpr.flags & EP_InfixFunc ) != 0 ) - { - pDef = sqlite3VtabOverloadFunction( db, pDef, nFarg, pFarg.a[1].pExpr ); - } - else if ( nFarg > 0 ) - { - pDef = sqlite3VtabOverloadFunction( db, pDef, nFarg, pFarg.a[0].pExpr ); - } + /* Possibly overload the function if the first argument is + ** a virtual table column. + ** + ** For infix functions (LIKE, GLOB, REGEXP, and MATCH) use the + ** second argument, not the first, as the argument to test to + ** see if it is a column in a virtual table. This is done because + ** the left operand of infix functions (the operand we want to + ** control overloading) ends up as the second argument to the + ** function. The expression "A glob B" is equivalent to + ** "glob(B,A). We want to use the A in "A glob B" to test + ** for function overloading. But we use the B term in "glob(B,A)". + */ + if (nFarg >= 2 && (pExpr.flags & EP_InfixFunc) != 0) { + pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg.a[1].pExpr); + } else if (nFarg > 0) { + pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg.a[0].pExpr); + } #endif - for ( i = 0; i < nFarg; i++ ) - { - if ( i < 32 && sqlite3ExprIsConstant( pFarg.a[i].pExpr ) != 0 ) - { - constMask |= ( 1 << i ); - } - if ( ( pDef.flags & SQLITE_FUNC_NEEDCOLL ) != 0 && null == pColl ) - { - pColl = sqlite3ExprCollSeq( pParse, pFarg.a[i].pExpr ); - } - } - if ( ( pDef.flags & SQLITE_FUNC_NEEDCOLL ) != 0 ) - { - if ( null == pColl ) - pColl = db.pDfltColl; - sqlite3VdbeAddOp4( v, OP_CollSeq, 0, 0, 0, pColl, P4_COLLSEQ ); - } - sqlite3VdbeAddOp4( v, OP_Function, constMask, r1, target, - pDef, P4_FUNCDEF ); - sqlite3VdbeChangeP5( v, (u8)nFarg ); - if ( nFarg != 0 ) - { - sqlite3ReleaseTempRange( pParse, r1, nFarg ); - } - break; - } + for (i = 0; i < nFarg; i++) { + if (i < 32 && sqlite3ExprIsConstant(pFarg.a[i].pExpr) != 0) { + constMask |= (1 << i); + } + if ((pDef.flags & SQLITE_FUNC_NEEDCOLL) != 0 && null == pColl) { + pColl = sqlite3ExprCollSeq(pParse, pFarg.a[i].pExpr); + } + } + if ((pDef.flags & SQLITE_FUNC_NEEDCOLL) != 0) { + if (null == pColl) + pColl = db.pDfltColl; + sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, pColl, P4_COLLSEQ); + } + sqlite3VdbeAddOp4(v, OP_Function, constMask, r1, target, + pDef, P4_FUNCDEF); + sqlite3VdbeChangeP5(v, (u8)nFarg); + if (nFarg != 0) { + sqlite3ReleaseTempRange(pParse, r1, nFarg); + } + break; + } #if !SQLITE_OMIT_SUBQUERY - case TK_EXISTS: - case TK_SELECT: - { - testcase( op == TK_EXISTS ); - testcase( op == TK_SELECT ); - inReg = sqlite3CodeSubselect( pParse, pExpr, 0, false ); - break; - } - case TK_IN: - { - int destIfFalse = sqlite3VdbeMakeLabel( v ); - int destIfNull = sqlite3VdbeMakeLabel( v ); - sqlite3VdbeAddOp2( v, OP_Null, 0, target ); - sqlite3ExprCodeIN( pParse, pExpr, destIfFalse, destIfNull ); - sqlite3VdbeAddOp2( v, OP_Integer, 1, target ); - sqlite3VdbeResolveLabel( v, destIfFalse ); - sqlite3VdbeAddOp2( v, OP_AddImm, target, 0 ); - sqlite3VdbeResolveLabel( v, destIfNull ); - break; - } + case TK_EXISTS: + case TK_SELECT: { + testcase(op == TK_EXISTS); + testcase(op == TK_SELECT); + inReg = sqlite3CodeSubselect(pParse, pExpr, 0, false); + break; + } + case TK_IN: { + int destIfFalse = sqlite3VdbeMakeLabel(v); + int destIfNull = sqlite3VdbeMakeLabel(v); + sqlite3VdbeAddOp2(v, OP_Null, 0, target); + sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull); + sqlite3VdbeAddOp2(v, OP_Integer, 1, target); + sqlite3VdbeResolveLabel(v, destIfFalse); + sqlite3VdbeAddOp2(v, OP_AddImm, target, 0); + sqlite3VdbeResolveLabel(v, destIfNull); + break; + } #endif //* SQLITE_OMIT_SUBQUERY */ - /* -** x BETWEEN y AND z -** -** This is equivalent to -** -** x>=y AND x<=z -** -** X is stored in pExpr.pLeft. -** Y is stored in pExpr.x.pList.a[0].pExpr. -** Z is stored in pExpr.x.pList.a[1].pExpr. -*/ - case TK_BETWEEN: - { - Expr pLeft = pExpr.pLeft; - ExprList_item pLItem = pExpr.x.pList.a[0]; - Expr pRight = pLItem.pExpr; - r1 = sqlite3ExprCodeTemp( pParse, pLeft, ref regFree1 ); - r2 = sqlite3ExprCodeTemp( pParse, pRight, ref regFree2 ); - testcase( regFree1 == 0 ); - testcase( regFree2 == 0 ); - r3 = sqlite3GetTempReg( pParse ); - r4 = sqlite3GetTempReg( pParse ); - codeCompare( pParse, pLeft, pRight, OP_Ge, - r1, r2, r3, SQLITE_STOREP2 ); - pLItem = pExpr.x.pList.a[1];// pLItem++; - pRight = pLItem.pExpr; - sqlite3ReleaseTempReg( pParse, regFree2 ); - r2 = sqlite3ExprCodeTemp( pParse, pRight, ref regFree2 ); - testcase( regFree2 == 0 ); - codeCompare( pParse, pLeft, pRight, OP_Le, r1, r2, r4, SQLITE_STOREP2 ); - sqlite3VdbeAddOp3( v, OP_And, r3, r4, target ); - sqlite3ReleaseTempReg( pParse, r3 ); - sqlite3ReleaseTempReg( pParse, r4 ); - break; - } - case TK_UPLUS: - { - inReg = sqlite3ExprCodeTarget( pParse, pExpr.pLeft, target ); - break; - } - case TK_TRIGGER: - { - /* If the opcode is TK_TRIGGER, then the expression is a reference - ** to a column in the new.* or old.* pseudo-tables available to - ** trigger programs. In this case Expr.iTable is set to 1 for the - ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn - ** is set to the column of the pseudo-table to read, or to -1 to - ** read the rowid field. - ** - ** The expression is implemented using an OP_Param opcode. The p1 - ** parameter is set to 0 for an old.rowid reference, or to (i+1) - ** to reference another column of the old.* pseudo-table, where - ** i is the index of the column. For a new.rowid reference, p1 is - ** set to (n+1), where n is the number of columns in each pseudo-table. - ** For a reference to any other column in the new.* pseudo-table, p1 - ** is set to (n+2+i), where n and i are as defined previously. For - ** example, if the table on which triggers are being fired is - ** declared as: - ** - ** CREATE TABLE t1(a, b); - ** - ** Then p1 is interpreted as follows: - ** - ** p1==0 . old.rowid p1==3 . new.rowid - ** p1==1 . old.a p1==4 . new.a - ** p1==2 . old.b p1==5 . new.b - */ - Table pTab = pExpr.pTab; - int p1 = pExpr.iTable * ( pTab.nCol + 1 ) + 1 + pExpr.iColumn; - - Debug.Assert( pExpr.iTable == 0 || pExpr.iTable == 1 ); - Debug.Assert( pExpr.iColumn >= -1 && pExpr.iColumn < pTab.nCol ); - Debug.Assert( pTab.iPKey < 0 || pExpr.iColumn != pTab.iPKey ); - Debug.Assert( p1 >= 0 && p1 < ( pTab.nCol * 2 + 2 ) ); - - sqlite3VdbeAddOp2( v, OP_Param, p1, target ); - VdbeComment( v, "%s.%s -> $%d", - ( pExpr.iTable != 0 ? "new" : "old" ), - ( pExpr.iColumn < 0 ? "rowid" : pExpr.pTab.aCol[pExpr.iColumn].zName ), - target - ); - - /* If the column has REAL affinity, it may currently be stored as an - ** integer. Use OP_RealAffinity to make sure it is really real. */ - if ( pExpr.iColumn >= 0 - && pTab.aCol[pExpr.iColumn].affinity == SQLITE_AFF_REAL - ) - { - sqlite3VdbeAddOp1( v, OP_RealAffinity, target ); - } - break; - } - - /* - ** Form A: - ** CASE x WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END + /* + ** x BETWEEN y AND z ** - ** Form B: - ** CASE WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END + ** This is equivalent to ** - ** 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>=y AND x<=z ** - ** X (if it exists) is in pExpr.pLeft. - ** 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.x.pList.a[i*2] and Ri is pExpr.x.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. + ** X is stored in pExpr.pLeft. + ** Y is stored in pExpr.x.pList.a[0].pExpr. + ** Z is stored in pExpr.x.pList.a[1].pExpr. */ - default: - { - Debug.Assert( op == TK_CASE ); - int endLabel; /* GOTO label for end of CASE stmt */ - int nextCase; /* GOTO label for next WHEN clause */ - int nExpr; /* 2x number of WHEN terms */ - int i; /* Loop counter */ - ExprList pEList; /* List of WHEN terms */ - ExprList_item[] aListelem; /* Array of WHEN terms */ - Expr opCompare = new Expr(); /* The X==Ei expression */ - Expr cacheX; /* Cached expression X */ - Expr pX; /* The X expression */ - Expr pTest = null; /* X==Ei (form A) or just Ei (form B) */ + case TK_BETWEEN: { + Expr pLeft = pExpr.pLeft; + ExprList_item pLItem = pExpr.x.pList.a[0]; + Expr pRight = pLItem.pExpr; + r1 = sqlite3ExprCodeTemp(pParse, pLeft, ref regFree1); + r2 = sqlite3ExprCodeTemp(pParse, pRight, ref regFree2); + testcase(regFree1 == 0); + testcase(regFree2 == 0); + r3 = sqlite3GetTempReg(pParse); + r4 = sqlite3GetTempReg(pParse); + codeCompare(pParse, pLeft, pRight, OP_Ge, + r1, r2, r3, SQLITE_STOREP2); + pLItem = pExpr.x.pList.a[1];// pLItem++; + pRight = pLItem.pExpr; + sqlite3ReleaseTempReg(pParse, regFree2); + r2 = sqlite3ExprCodeTemp(pParse, pRight, ref regFree2); + testcase(regFree2 == 0); + codeCompare(pParse, pLeft, pRight, OP_Le, r1, r2, r4, SQLITE_STOREP2); + sqlite3VdbeAddOp3(v, OP_And, r3, r4, target); + sqlite3ReleaseTempReg(pParse, r3); + sqlite3ReleaseTempReg(pParse, r4); + break; + } + case TK_UPLUS: { + inReg = sqlite3ExprCodeTarget(pParse, pExpr.pLeft, target); + break; + } + case TK_TRIGGER: { + /* If the opcode is TK_TRIGGER, then the expression is a reference + ** to a column in the new.* or old.* pseudo-tables available to + ** trigger programs. In this case Expr.iTable is set to 1 for the + ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn + ** is set to the column of the pseudo-table to read, or to -1 to + ** read the rowid field. + ** + ** The expression is implemented using an OP_Param opcode. The p1 + ** parameter is set to 0 for an old.rowid reference, or to (i+1) + ** to reference another column of the old.* pseudo-table, where + ** i is the index of the column. For a new.rowid reference, p1 is + ** set to (n+1), where n is the number of columns in each pseudo-table. + ** For a reference to any other column in the new.* pseudo-table, p1 + ** is set to (n+2+i), where n and i are as defined previously. For + ** example, if the table on which triggers are being fired is + ** declared as: + ** + ** CREATE TABLE t1(a, b); + ** + ** Then p1 is interpreted as follows: + ** + ** p1==0 . old.rowid p1==3 . new.rowid + ** p1==1 . old.a p1==4 . new.a + ** p1==2 . old.b p1==5 . new.b + */ + Table pTab = pExpr.pTab; + int p1 = pExpr.iTable * (pTab.nCol + 1) + 1 + pExpr.iColumn; + + Debug.Assert(pExpr.iTable == 0 || pExpr.iTable == 1); + Debug.Assert(pExpr.iColumn >= -1 && pExpr.iColumn < pTab.nCol); + Debug.Assert(pTab.iPKey < 0 || pExpr.iColumn != pTab.iPKey); + Debug.Assert(p1 >= 0 && p1 < (pTab.nCol * 2 + 2)); + + sqlite3VdbeAddOp2(v, OP_Param, p1, target); + VdbeComment(v, "%s.%s -> $%d", + (pExpr.iTable != 0 ? "new" : "old"), + (pExpr.iColumn < 0 ? "rowid" : pExpr.pTab.aCol[pExpr.iColumn].zName), + target + ); + + /* If the column has REAL affinity, it may currently be stored as an + ** integer. Use OP_RealAffinity to make sure it is really real. */ + if (pExpr.iColumn >= 0 + && pTab.aCol[pExpr.iColumn].affinity == SQLITE_AFF_REAL + ) { + sqlite3VdbeAddOp1(v, OP_RealAffinity, target); + } + break; + } + + /* + ** Form A: + ** CASE x WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END + ** + ** Form B: + ** CASE WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END + ** + ** 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 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.x.pList.a[i*2] and Ri is pExpr.x.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. + */ + default: { + Debug.Assert(op == TK_CASE); + int endLabel; /* GOTO label for end of CASE stmt */ + int nextCase; /* GOTO label for next WHEN clause */ + int nExpr; /* 2x number of WHEN terms */ + int i; /* Loop counter */ + ExprList pEList; /* List of WHEN terms */ + ExprList_item[] aListelem; /* Array of WHEN terms */ + Expr opCompare = new Expr(); /* The X==Ei expression */ + Expr cacheX; /* Cached expression X */ + Expr pX; /* The X expression */ + Expr pTest = null; /* X==Ei (form A) or just Ei (form B) */ #if !NDEBUG - int iCacheLevel = pParse.iCacheLevel; - //VVA_ONLY( int iCacheLevel = pParse.iCacheLevel; ) + int iCacheLevel = pParse.iCacheLevel; + //VVA_ONLY( int iCacheLevel = pParse.iCacheLevel; ) #endif - Debug.Assert( !ExprHasProperty( pExpr, EP_xIsSelect ) && pExpr.x.pList != null ); - Debug.Assert( ( pExpr.x.pList.nExpr % 2 ) == 0 ); - Debug.Assert( pExpr.x.pList.nExpr > 0 ); - pEList = pExpr.x.pList; - aListelem = pEList.a; - nExpr = pEList.nExpr; - endLabel = sqlite3VdbeMakeLabel( v ); - if ( ( pX = pExpr.pLeft ) != null ) - { - cacheX = pX; - testcase( pX.op == TK_COLUMN ); - testcase( pX.op == TK_REGISTER ); - cacheX.iTable = sqlite3ExprCodeTemp( pParse, pX, ref regFree1 ); - 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; i < nExpr; i = i + 2 ) - { - sqlite3ExprCachePush( pParse ); - if ( pX != null ) - { - Debug.Assert( pTest != null ); - opCompare.pRight = aListelem[i].pExpr; - } - else - { - pTest = aListelem[i].pExpr; - } - nextCase = sqlite3VdbeMakeLabel( v ); - testcase( pTest.op == TK_COLUMN ); - sqlite3ExprIfFalse( pParse, pTest, nextCase, SQLITE_JUMPIFNULL ); - testcase( aListelem[i + 1].pExpr.op == TK_COLUMN ); - testcase( aListelem[i + 1].pExpr.op == TK_REGISTER ); - sqlite3ExprCode( pParse, aListelem[i + 1].pExpr, target ); - sqlite3VdbeAddOp2( v, OP_Goto, 0, endLabel ); - sqlite3ExprCachePop( pParse, 1 ); - sqlite3VdbeResolveLabel( v, nextCase ); - } - if ( pExpr.pRight != null ) - { - sqlite3ExprCachePush( pParse ); - sqlite3ExprCode( pParse, pExpr.pRight, target ); - sqlite3ExprCachePop( pParse, 1 ); - } - else - { - sqlite3VdbeAddOp2( v, OP_Null, 0, target ); - } + Debug.Assert(!ExprHasProperty(pExpr, EP_xIsSelect) && pExpr.x.pList != null); + Debug.Assert((pExpr.x.pList.nExpr % 2) == 0); + Debug.Assert(pExpr.x.pList.nExpr > 0); + pEList = pExpr.x.pList; + aListelem = pEList.a; + nExpr = pEList.nExpr; + endLabel = sqlite3VdbeMakeLabel(v); + if ((pX = pExpr.pLeft) != null) { + cacheX = pX; + testcase(pX.op == TK_COLUMN); + testcase(pX.op == TK_REGISTER); + cacheX.iTable = sqlite3ExprCodeTemp(pParse, pX, ref regFree1); + 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; i < nExpr; i = i + 2) { + sqlite3ExprCachePush(pParse); + if (pX != null) { + Debug.Assert(pTest != null); + opCompare.pRight = aListelem[i].pExpr; + } else { + pTest = aListelem[i].pExpr; + } + nextCase = sqlite3VdbeMakeLabel(v); + testcase(pTest.op == TK_COLUMN); + sqlite3ExprIfFalse(pParse, pTest, nextCase, SQLITE_JUMPIFNULL); + testcase(aListelem[i + 1].pExpr.op == TK_COLUMN); + testcase(aListelem[i + 1].pExpr.op == TK_REGISTER); + sqlite3ExprCode(pParse, aListelem[i + 1].pExpr, target); + sqlite3VdbeAddOp2(v, OP_Goto, 0, endLabel); + sqlite3ExprCachePop(pParse, 1); + sqlite3VdbeResolveLabel(v, nextCase); + } + if (pExpr.pRight != null) { + sqlite3ExprCachePush(pParse); + sqlite3ExprCode(pParse, pExpr.pRight, target); + sqlite3ExprCachePop(pParse, 1); + } else { + sqlite3VdbeAddOp2(v, OP_Null, 0, target); + } #if !NDEBUG - Debug.Assert( /* db.mallocFailed != 0 || */ pParse.nErr > 0 - || pParse.iCacheLevel == iCacheLevel ); + Debug.Assert( /* db.mallocFailed != 0 || */ pParse.nErr > 0 + || pParse.iCacheLevel == iCacheLevel); #endif - sqlite3VdbeResolveLabel( v, endLabel ); - break; - } + sqlite3VdbeResolveLabel(v, endLabel); + break; + } #if !SQLITE_OMIT_TRIGGER - case TK_RAISE: - { - Debug.Assert( pExpr.affinity == OE_Rollback - || pExpr.affinity == OE_Abort - || pExpr.affinity == OE_Fail - || pExpr.affinity == OE_Ignore - ); - if ( null == pParse.pTriggerTab ) - { - sqlite3ErrorMsg( pParse, - "RAISE() may only be used within a trigger-program" ); - return 0; - } - if ( pExpr.affinity == OE_Abort ) - { - sqlite3MayAbort( pParse ); - } - Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); - if ( pExpr.affinity == OE_Ignore ) - { - sqlite3VdbeAddOp4( - v, OP_Halt, SQLITE_OK, OE_Ignore, 0, pExpr.u.zToken, 0 ); - } - else - { - sqlite3HaltConstraint( pParse, pExpr.affinity, pExpr.u.zToken, 0 ); - } + case TK_RAISE: { + Debug.Assert(pExpr.affinity == OE_Rollback + || pExpr.affinity == OE_Abort + || pExpr.affinity == OE_Fail + || pExpr.affinity == OE_Ignore + ); + if (null == pParse.pTriggerTab) { + sqlite3ErrorMsg(pParse, + "RAISE() may only be used within a trigger-program"); + return 0; + } + if (pExpr.affinity == OE_Abort) { + sqlite3MayAbort(pParse); + } + Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); + if (pExpr.affinity == OE_Ignore) { + sqlite3VdbeAddOp4( + v, OP_Halt, SQLITE_OK, OE_Ignore, 0, pExpr.u.zToken, 0); + } else { + sqlite3HaltConstraint(pParse, pExpr.affinity, pExpr.u.zToken, 0); + } - break; - } + break; + } #endif - } - sqlite3ReleaseTempReg( pParse, regFree1 ); - sqlite3ReleaseTempReg( pParse, regFree2 ); - return inReg; - } + } + sqlite3ReleaseTempReg(pParse, regFree1); + sqlite3ReleaseTempReg(pParse, regFree2); + return inReg; + } - /* - ** Generate code to evaluate an expression and store the results - ** into a register. Return the register number where the results - ** are stored. - ** - ** If the register is a temporary register that can be deallocated, - ** then write its number into pReg. If the result register is not - ** a temporary, then set pReg to zero. - */ - static int sqlite3ExprCodeTemp( Parse pParse, Expr pExpr, ref int pReg ) - { - int r1 = sqlite3GetTempReg( pParse ); - int r2 = sqlite3ExprCodeTarget( pParse, pExpr, r1 ); - if ( r2 == r1 ) - { - pReg = r1; - } - else - { - sqlite3ReleaseTempReg( pParse, r1 ); - pReg = 0; - } - return r2; - } + /* + ** Generate code to evaluate an expression and store the results + ** into a register. Return the register number where the results + ** are stored. + ** + ** If the register is a temporary register that can be deallocated, + ** then write its number into pReg. If the result register is not + ** a temporary, then set pReg to zero. + */ + static int sqlite3ExprCodeTemp(Parse pParse, Expr pExpr, ref int pReg) { + int r1 = sqlite3GetTempReg(pParse); + int r2 = sqlite3ExprCodeTarget(pParse, pExpr, r1); + if (r2 == r1) { + pReg = r1; + } else { + sqlite3ReleaseTempReg(pParse, r1); + pReg = 0; + } + return r2; + } - /* - ** Generate code that will evaluate expression pExpr and store the - ** results in register target. The results are guaranteed to appear - ** in register target. - */ - static int sqlite3ExprCode( Parse pParse, Expr pExpr, int target ) - { - int inReg; - - Debug.Assert( target > 0 && target <= pParse.nMem ); - if ( pExpr != null && pExpr.op == TK_REGISTER ) - { - sqlite3VdbeAddOp2( pParse.pVdbe, OP_Copy, pExpr.iTable, target ); - } - else - { - inReg = sqlite3ExprCodeTarget( pParse, pExpr, target ); - Debug.Assert( pParse.pVdbe != null /* || pParse.db.mallocFailed != 0 */ ); - if ( inReg != target && pParse.pVdbe != null ) - { - sqlite3VdbeAddOp2( pParse.pVdbe, OP_SCopy, inReg, target ); + /* + ** Generate code that will evaluate expression pExpr and store the + ** results in register target. The results are guaranteed to appear + ** in register target. + */ + static int sqlite3ExprCode(Parse pParse, Expr pExpr, int target) { + int inReg; + + Debug.Assert(target > 0 && target <= pParse.nMem); + if (pExpr != null && pExpr.op == TK_REGISTER) { + sqlite3VdbeAddOp2(pParse.pVdbe, OP_Copy, pExpr.iTable, target); + } else { + inReg = sqlite3ExprCodeTarget(pParse, pExpr, target); + Debug.Assert(pParse.pVdbe != null /* || pParse.db.mallocFailed != 0 */ ); + if (inReg != target && pParse.pVdbe != null) { + sqlite3VdbeAddOp2(pParse.pVdbe, OP_SCopy, inReg, target); + } + } + return target; } - } - return target; - } - /* - ** Generate code that evalutes the given expression and puts the result - ** in register target. - ** - ** Also make a copy of the expression results into another "cache" register - ** and modify the expression so that the next time it is evaluated, - ** the result is a copy of the cache register. - ** - ** This routine is used for expressions that are used multiple - ** times. They are evaluated once and the results of the expression - ** are reused. - */ - static int sqlite3ExprCodeAndCache( Parse pParse, Expr pExpr, int target ) - { - Vdbe v = pParse.pVdbe; - int inReg; - inReg = sqlite3ExprCode( pParse, pExpr, target ); - Debug.Assert( target > 0 ); - /* This routine is called for terms to INSERT or UPDATE. And the only - ** other place where expressions can be converted into TK_REGISTER is - ** in WHERE clause processing. So as currently implemented, there is - ** no way for a TK_REGISTER to exist here. But it seems prudent to - ** keep the ALWAYS() in case the conditions above change with future - ** modifications or enhancements. */ - if ( ALWAYS( pExpr.op != TK_REGISTER ) ) - { - int iMem; - iMem = ++pParse.nMem; - sqlite3VdbeAddOp2( v, OP_Copy, inReg, iMem ); - pExpr.iTable = iMem; - pExpr.op2 = pExpr.op; - pExpr.op = TK_REGISTER; - } - return inReg; - } + /* + ** Generate code that evalutes the given expression and puts the result + ** in register target. + ** + ** Also make a copy of the expression results into another "cache" register + ** and modify the expression so that the next time it is evaluated, + ** the result is a copy of the cache register. + ** + ** This routine is used for expressions that are used multiple + ** times. They are evaluated once and the results of the expression + ** are reused. + */ + static int sqlite3ExprCodeAndCache(Parse pParse, Expr pExpr, int target) { + Vdbe v = pParse.pVdbe; + int inReg; + inReg = sqlite3ExprCode(pParse, pExpr, target); + Debug.Assert(target > 0); + /* This routine is called for terms to INSERT or UPDATE. And the only + ** other place where expressions can be converted into TK_REGISTER is + ** in WHERE clause processing. So as currently implemented, there is + ** no way for a TK_REGISTER to exist here. But it seems prudent to + ** keep the ALWAYS() in case the conditions above change with future + ** modifications or enhancements. */ + if (ALWAYS(pExpr.op != TK_REGISTER)) { + int iMem; + iMem = ++pParse.nMem; + sqlite3VdbeAddOp2(v, OP_Copy, inReg, iMem); + pExpr.iTable = iMem; + pExpr.op2 = pExpr.op; + pExpr.op = TK_REGISTER; + } + return inReg; + } - /* - ** Return TRUE if pExpr is an constant expression that is appropriate - ** for factoring out of a loop. Appropriate expressions are: - ** - ** * Any expression that evaluates to two or more opcodes. - ** - ** * Any OP_Integer, OP_Real, OP_String, OP_Blob, OP_Null, - ** or OP_Variable that does not need to be placed in a - ** specific register. - ** - ** There is no point in factoring out single-instruction constant - ** expressions that need to be placed in a particular register. - ** We could factor them out, but then we would end up adding an - ** OP_SCopy instruction to move the value into the correct register - ** later. We might as well just use the original instruction and - ** avoid the OP_SCopy. - */ - static int isAppropriateForFactoring( Expr p ) - { - if ( sqlite3ExprIsConstantNotJoin( p ) == 0 ) - { - return 0; /* Only constant expressions are appropriate for factoring */ - } - if ( ( p.flags & EP_FixedDest ) == 0 ) - { - return 1; /* Any constant without a fixed destination is appropriate */ - } - while ( p.op == TK_UPLUS ) - p = p.pLeft; - switch ( p.op ) - { -#if !SQLITE_OMIT_BLOB_LITERAL - case TK_BLOB: -#endif - case TK_VARIABLE: - case TK_INTEGER: - case TK_FLOAT: - case TK_NULL: - case TK_STRING: - { - testcase( p.op == TK_BLOB ); - testcase( p.op == TK_VARIABLE ); - testcase( p.op == TK_INTEGER ); - testcase( p.op == TK_FLOAT ); - testcase( p.op == TK_NULL ); - testcase( p.op == TK_STRING ); - /* Single-instruction constants with a fixed destination are - ** better done in-line. If we factor them, they will just end - ** up generating an OP_SCopy to move the value to the destination - ** register. */ - return 0; - } - case TK_UMINUS: - { - if ( p.pLeft.op == TK_FLOAT || p.pLeft.op == TK_INTEGER ) - { - return 0; + /* + ** Return TRUE if pExpr is an constant expression that is appropriate + ** for factoring out of a loop. Appropriate expressions are: + ** + ** * Any expression that evaluates to two or more opcodes. + ** + ** * Any OP_Integer, OP_Real, OP_String, OP_Blob, OP_Null, + ** or OP_Variable that does not need to be placed in a + ** specific register. + ** + ** There is no point in factoring out single-instruction constant + ** expressions that need to be placed in a particular register. + ** We could factor them out, but then we would end up adding an + ** OP_SCopy instruction to move the value into the correct register + ** later. We might as well just use the original instruction and + ** avoid the OP_SCopy. + */ + static int isAppropriateForFactoring(Expr p) { + if (sqlite3ExprIsConstantNotJoin(p) == 0) { + return 0; /* Only constant expressions are appropriate for factoring */ + } + if ((p.flags & EP_FixedDest) == 0) { + return 1; /* Any constant without a fixed destination is appropriate */ } - break; - } - default: - { - break; - } - } - return 1; - } + while (p.op == TK_UPLUS) + p = p.pLeft; + switch (p.op) { +#if !SQLITE_OMIT_BLOB_LITERAL + case TK_BLOB: +#endif + case TK_VARIABLE: + case TK_INTEGER: + case TK_FLOAT: + case TK_NULL: + case TK_STRING: { + testcase(p.op == TK_BLOB); + testcase(p.op == TK_VARIABLE); + testcase(p.op == TK_INTEGER); + testcase(p.op == TK_FLOAT); + testcase(p.op == TK_NULL); + testcase(p.op == TK_STRING); + /* Single-instruction constants with a fixed destination are + ** better done in-line. If we factor them, they will just end + ** up generating an OP_SCopy to move the value to the destination + ** register. */ + return 0; + } + case TK_UMINUS: { + if (p.pLeft.op == TK_FLOAT || p.pLeft.op == TK_INTEGER) { + return 0; + } + break; + } + default: { + break; + } + } + return 1; + } - /* - ** If pExpr is a constant expression that is appropriate for - ** factoring out of a loop, then evaluate the expression - ** into a register and convert the expression into a TK_REGISTER - ** expression. - */ - static int evalConstExpr( Walker pWalker, ref Expr pExpr ) - { - Parse pParse = pWalker.pParse; - switch ( pExpr.op ) - { - case TK_IN: - case TK_REGISTER: - { - return WRC_Prune; - } - case TK_FUNCTION: - case TK_AGG_FUNCTION: - case TK_CONST_FUNC: - { - /* The arguments to a function have a fixed destination. - ** Mark them this way to avoid generated unneeded OP_SCopy - ** instructions. - */ - ExprList pList = pExpr.x.pList; - Debug.Assert( !ExprHasProperty( pExpr, EP_xIsSelect ) ); - if ( pList != null ) - { - int i = pList.nExpr; - ExprList_item pItem;//= pList.a; - for ( ; i > 0; i-- ) - {//, pItem++){ - pItem = pList.a[pList.nExpr - i]; - if ( ALWAYS( pItem.pExpr != null ) ) - pItem.pExpr.flags |= EP_FixedDest; - } + /* + ** If pExpr is a constant expression that is appropriate for + ** factoring out of a loop, then evaluate the expression + ** into a register and convert the expression into a TK_REGISTER + ** expression. + */ + static int evalConstExpr(Walker pWalker, ref Expr pExpr) { + Parse pParse = pWalker.pParse; + switch (pExpr.op) { + case TK_IN: + case TK_REGISTER: { + return WRC_Prune; + } + case TK_FUNCTION: + case TK_AGG_FUNCTION: + case TK_CONST_FUNC: { + /* The arguments to a function have a fixed destination. + ** Mark them this way to avoid generated unneeded OP_SCopy + ** instructions. + */ + ExprList pList = pExpr.x.pList; + Debug.Assert(!ExprHasProperty(pExpr, EP_xIsSelect)); + if (pList != null) { + int i = pList.nExpr; + ExprList_item pItem;//= pList.a; + for (; i > 0; i--) {//, pItem++){ + pItem = pList.a[pList.nExpr - i]; + if (ALWAYS(pItem.pExpr != null)) + pItem.pExpr.flags |= EP_FixedDest; + } + } + break; + } } - break; - } - } - if ( isAppropriateForFactoring( pExpr ) != 0 ) - { - int r1 = ++pParse.nMem; - int r2; - r2 = sqlite3ExprCodeTarget( pParse, pExpr, r1 ); - if ( NEVER( r1 != r2 ) ) - sqlite3ReleaseTempReg( pParse, r1 ); - pExpr.op2 = pExpr.op; - pExpr.op = TK_REGISTER; - pExpr.iTable = r2; - return WRC_Prune; - } - return WRC_Continue; - } + if (isAppropriateForFactoring(pExpr) != 0) { + int r1 = ++pParse.nMem; + int r2; + r2 = sqlite3ExprCodeTarget(pParse, pExpr, r1); + if (NEVER(r1 != r2)) + sqlite3ReleaseTempReg(pParse, r1); + pExpr.op2 = pExpr.op; + pExpr.op = TK_REGISTER; + pExpr.iTable = r2; + return WRC_Prune; + } + return WRC_Continue; + } - /* - ** Preevaluate constant subexpressions within pExpr and store the - ** results in registers. Modify pExpr so that the constant subexpresions - ** are TK_REGISTER opcodes that refer to the precomputed values. - ** - ** This routine is a no-op if the jump to the cookie-check code has - ** already occur. Since the cookie-check jump is generated prior to - ** any other serious processing, this check ensures that there is no - ** way to accidently bypass the constant initializations. - ** - ** This routine is also a no-op if the SQLITE_FactorOutConst optimization - ** is disabled via the sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS) - ** interface. This allows test logic to verify that the same answer is - ** obtained for queries regardless of whether or not constants are - ** precomputed into registers or if they are inserted in-line. - */ - static void sqlite3ExprCodeConstants( Parse pParse, Expr pExpr ) - { - Walker w; - if ( pParse.cookieGoto != 0 ) - return; - if ( ( pParse.db.flags & SQLITE_FactorOutConst ) != 0 ) - return; - w = new Walker(); - w.xExprCallback = (dxExprCallback)evalConstExpr; - w.xSelectCallback = null; - w.pParse = pParse; - sqlite3WalkExpr( w, ref pExpr ); - } + /* + ** Preevaluate constant subexpressions within pExpr and store the + ** results in registers. Modify pExpr so that the constant subexpresions + ** are TK_REGISTER opcodes that refer to the precomputed values. + ** + ** This routine is a no-op if the jump to the cookie-check code has + ** already occur. Since the cookie-check jump is generated prior to + ** any other serious processing, this check ensures that there is no + ** way to accidently bypass the constant initializations. + ** + ** This routine is also a no-op if the SQLITE_FactorOutConst optimization + ** is disabled via the sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS) + ** interface. This allows test logic to verify that the same answer is + ** obtained for queries regardless of whether or not constants are + ** precomputed into registers or if they are inserted in-line. + */ + static void sqlite3ExprCodeConstants(Parse pParse, Expr pExpr) { + Walker w; + if (pParse.cookieGoto != 0) + return; + if ((pParse.db.flags & SQLITE_FactorOutConst) != 0) + return; + w = new Walker(); + w.xExprCallback = (dxExprCallback)evalConstExpr; + w.xSelectCallback = null; + w.pParse = pParse; + sqlite3WalkExpr(w, ref pExpr); + } - /* - ** Generate code that pushes the value of every element of the given - ** expression list into a sequence of registers beginning at target. - ** - ** Return the number of elements evaluated. - */ - static int sqlite3ExprCodeExprList( - Parse pParse, /* Parsing context */ - ExprList pList, /* The expression list to be coded */ - int target, /* Where to write results */ - bool doHardCopy /* Make a hard copy of every element */ - ) - { - ExprList_item pItem; - int i, n; - Debug.Assert( pList != null ); - Debug.Assert( target > 0 ); - Debug.Assert( pParse.pVdbe != null ); /* Never gets this far otherwise */ - n = pList.nExpr; - for ( i = 0; i < n; i++ )// pItem++) - { - pItem = pList.a[i]; - Expr pExpr = pItem.pExpr; - int inReg = sqlite3ExprCodeTarget( pParse, pExpr, target + i ); - if ( inReg != target + i ) - { - sqlite3VdbeAddOp2( pParse.pVdbe, doHardCopy ? OP_Copy : OP_SCopy, - inReg, target + i ); + /* + ** Generate code that pushes the value of every element of the given + ** expression list into a sequence of registers beginning at target. + ** + ** Return the number of elements evaluated. + */ + static int sqlite3ExprCodeExprList( + Parse pParse, /* Parsing context */ + ExprList pList, /* The expression list to be coded */ + int target, /* Where to write results */ + bool doHardCopy /* Make a hard copy of every element */ + ) { + ExprList_item pItem; + int i, n; + Debug.Assert(pList != null); + Debug.Assert(target > 0); + Debug.Assert(pParse.pVdbe != null); /* Never gets this far otherwise */ + n = pList.nExpr; + for (i = 0; i < n; i++)// pItem++) + { + pItem = pList.a[i]; + Expr pExpr = pItem.pExpr; + int inReg = sqlite3ExprCodeTarget(pParse, pExpr, target + i); + if (inReg != target + i) { + sqlite3VdbeAddOp2(pParse.pVdbe, doHardCopy ? OP_Copy : OP_SCopy, + inReg, target + i); + } + } + return n; } - } - return n; - } - /* - ** Generate code for a BETWEEN operator. - ** - ** x BETWEEN y AND z - ** - ** The above is equivalent to - ** - ** x>=y AND x<=z - ** - ** Code it as such, taking care to do the common subexpression - ** elementation of x. - */ - static void exprCodeBetween( - Parse pParse, /* Parsing and code generating context */ - Expr pExpr, /* The BETWEEN expression */ - int dest, /* Jump here if the jump is taken */ - int jumpIfTrue, /* Take the jump if the BETWEEN is true */ - int jumpIfNull /* Take the jump if the BETWEEN is NULL */ - ) - { - Expr exprAnd = new Expr(); /* The AND operator in x>=y AND x<=z */ - Expr compLeft = new Expr(); /* The x>=y term */ - Expr compRight = new Expr(); /* The x<=z term */ - Expr exprX; /* The x subexpression */ - int regFree1 = 0; /* Temporary use register */ - - Debug.Assert( !ExprHasProperty( pExpr, EP_xIsSelect ) ); - exprX = pExpr.pLeft.Copy(); - exprAnd.op = TK_AND; - exprAnd.pLeft = compLeft; - exprAnd.pRight = compRight; - compLeft.op = TK_GE; - 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; - exprX.iTable = sqlite3ExprCodeTemp( pParse, exprX, ref regFree1 ); - exprX.op = TK_REGISTER; - if ( jumpIfTrue != 0 ) - { - sqlite3ExprIfTrue( pParse, exprAnd, dest, jumpIfNull ); - } - else - { - sqlite3ExprIfFalse( pParse, exprAnd, dest, jumpIfNull ); - } - sqlite3ReleaseTempReg( pParse, regFree1 ); - - /* Ensure adequate test coverage */ - testcase( jumpIfTrue == 0 && jumpIfNull == 0 && regFree1 == 0 ); - testcase( jumpIfTrue == 0 && jumpIfNull == 0 && regFree1 != 0 ); - testcase( jumpIfTrue == 0 && jumpIfNull != 0 && regFree1 == 0 ); - testcase( jumpIfTrue == 0 && jumpIfNull != 0 && regFree1 != 0 ); - testcase( jumpIfTrue != 0 && jumpIfNull == 0 && regFree1 == 0 ); - testcase( jumpIfTrue != 0 && jumpIfNull == 0 && regFree1 != 0 ); - testcase( jumpIfTrue != 0 && jumpIfNull != 0 && regFree1 == 0 ); - testcase( jumpIfTrue != 0 && jumpIfNull != 0 && regFree1 != 0 ); - } - /* - ** Generate code for a boolean expression such that a jump is made - ** to the label "dest" if the expression is true but execution - ** continues straight thru if the expression is false. - ** - ** If the expression evaluates to NULL (neither true nor false), then - ** take the jump if the jumpIfNull flag is SQLITE_JUMPIFNULL. - ** - ** This code depends on the fact that certain token values (ex: TK_EQ) - ** are the same as opcode values (ex: OP_Eq) that implement the corresponding - ** operation. Special comments in vdbe.c and the mkopcodeh.awk script in - ** the make process cause these values to align. Assert()s in the code - ** below verify that the numbers are aligned correctly. - */ - static void sqlite3ExprIfTrue( Parse pParse, Expr pExpr, int dest, int jumpIfNull ) - { - Vdbe v = pParse.pVdbe; - int op = 0; - int regFree1 = 0; - int regFree2 = 0; - int r1 = 0, r2 = 0; - - Debug.Assert( jumpIfNull == SQLITE_JUMPIFNULL || jumpIfNull == 0 ); - if ( NEVER( v == null ) ) - return; /* Existance of VDBE checked by caller */ - if ( NEVER( pExpr == null ) ) - return; /* No way this can happen */ - op = pExpr.op; - switch ( op ) - { - case TK_AND: - { - int d2 = sqlite3VdbeMakeLabel( v ); - testcase( jumpIfNull == 0 ); - sqlite3ExprCachePush( pParse ); - sqlite3ExprIfFalse( pParse, pExpr.pLeft, d2, jumpIfNull ^ SQLITE_JUMPIFNULL ); - sqlite3ExprIfTrue( pParse, pExpr.pRight, dest, jumpIfNull ); - sqlite3VdbeResolveLabel( v, d2 ); - sqlite3ExprCachePop( pParse, 1 ); - break; - } - case TK_OR: - { - testcase( jumpIfNull == 0 ); - sqlite3ExprIfTrue( pParse, pExpr.pLeft, dest, jumpIfNull ); - sqlite3ExprIfTrue( pParse, pExpr.pRight, dest, jumpIfNull ); - break; - } - case TK_NOT: - { - testcase( jumpIfNull == 0 ); - sqlite3ExprIfFalse( pParse, pExpr.pLeft, dest, jumpIfNull ); - break; - } - case TK_LT: - case TK_LE: - case TK_GT: - case TK_GE: - case TK_NE: - case TK_EQ: - { - Debug.Assert( TK_LT == OP_Lt ); - Debug.Assert( TK_LE == OP_Le ); - Debug.Assert( TK_GT == OP_Gt ); - Debug.Assert( TK_GE == OP_Ge ); - Debug.Assert( TK_EQ == OP_Eq ); - Debug.Assert( TK_NE == OP_Ne ); - testcase( op == TK_LT ); - testcase( op == TK_LE ); - testcase( op == TK_GT ); - testcase( op == TK_GE ); - testcase( op == TK_EQ ); - testcase( op == TK_NE ); - testcase( jumpIfNull == 0 ); - r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); - r2 = sqlite3ExprCodeTemp( pParse, pExpr.pRight, ref regFree2 ); - codeCompare( pParse, pExpr.pLeft, pExpr.pRight, op, - r1, r2, dest, jumpIfNull ); - testcase( regFree1 == 0 ); - testcase( regFree2 == 0 ); - break; - } - case TK_IS: - case TK_ISNOT: - { - testcase( op == TK_IS ); - testcase( op == TK_ISNOT ); - r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); - r2 = sqlite3ExprCodeTemp( pParse, pExpr.pRight, ref regFree2 ); - op = ( op == TK_IS ) ? TK_EQ : TK_NE; - codeCompare( pParse, pExpr.pLeft, pExpr.pRight, op, - r1, r2, dest, SQLITE_NULLEQ ); - testcase( regFree1 == 0 ); - testcase( regFree2 == 0 ); - break; - } - case TK_ISNULL: - case TK_NOTNULL: - { - Debug.Assert( TK_ISNULL == OP_IsNull ); - Debug.Assert( TK_NOTNULL == OP_NotNull ); - testcase( op == TK_ISNULL ); - testcase( op == TK_NOTNULL ); - r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); - sqlite3VdbeAddOp2( v, op, r1, dest ); - testcase( regFree1 == 0 ); - break; - } - case TK_BETWEEN: - { - testcase( jumpIfNull == 0 ); - exprCodeBetween( pParse, pExpr, dest, 1, jumpIfNull ); - break; - } + /* + ** Generate code for a BETWEEN operator. + ** + ** x BETWEEN y AND z + ** + ** The above is equivalent to + ** + ** x>=y AND x<=z + ** + ** Code it as such, taking care to do the common subexpression + ** elementation of x. + */ + static void exprCodeBetween( + Parse pParse, /* Parsing and code generating context */ + Expr pExpr, /* The BETWEEN expression */ + int dest, /* Jump here if the jump is taken */ + int jumpIfTrue, /* Take the jump if the BETWEEN is true */ + int jumpIfNull /* Take the jump if the BETWEEN is NULL */ + ) { + Expr exprAnd = new Expr(); /* The AND operator in x>=y AND x<=z */ + Expr compLeft = new Expr(); /* The x>=y term */ + Expr compRight = new Expr(); /* The x<=z term */ + Expr exprX; /* The x subexpression */ + int regFree1 = 0; /* Temporary use register */ + + Debug.Assert(!ExprHasProperty(pExpr, EP_xIsSelect)); + exprX = pExpr.pLeft.Copy(); + exprAnd.op = TK_AND; + exprAnd.pLeft = compLeft; + exprAnd.pRight = compRight; + compLeft.op = TK_GE; + 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; + exprX.iTable = sqlite3ExprCodeTemp(pParse, exprX, ref regFree1); + exprX.op = TK_REGISTER; + if (jumpIfTrue != 0) { + sqlite3ExprIfTrue(pParse, exprAnd, dest, jumpIfNull); + } else { + sqlite3ExprIfFalse(pParse, exprAnd, dest, jumpIfNull); + } + sqlite3ReleaseTempReg(pParse, regFree1); + + /* Ensure adequate test coverage */ + testcase(jumpIfTrue == 0 && jumpIfNull == 0 && regFree1 == 0); + testcase(jumpIfTrue == 0 && jumpIfNull == 0 && regFree1 != 0); + testcase(jumpIfTrue == 0 && jumpIfNull != 0 && regFree1 == 0); + testcase(jumpIfTrue == 0 && jumpIfNull != 0 && regFree1 != 0); + testcase(jumpIfTrue != 0 && jumpIfNull == 0 && regFree1 == 0); + testcase(jumpIfTrue != 0 && jumpIfNull == 0 && regFree1 != 0); + testcase(jumpIfTrue != 0 && jumpIfNull != 0 && regFree1 == 0); + testcase(jumpIfTrue != 0 && jumpIfNull != 0 && regFree1 != 0); + } + /* + ** Generate code for a boolean expression such that a jump is made + ** to the label "dest" if the expression is true but execution + ** continues straight thru if the expression is false. + ** + ** If the expression evaluates to NULL (neither true nor false), then + ** take the jump if the jumpIfNull flag is SQLITE_JUMPIFNULL. + ** + ** This code depends on the fact that certain token values (ex: TK_EQ) + ** are the same as opcode values (ex: OP_Eq) that implement the corresponding + ** operation. Special comments in vdbe.c and the mkopcodeh.awk script in + ** the make process cause these values to align. Assert()s in the code + ** below verify that the numbers are aligned correctly. + */ + static void sqlite3ExprIfTrue(Parse pParse, Expr pExpr, int dest, int jumpIfNull) { + Vdbe v = pParse.pVdbe; + int op = 0; + int regFree1 = 0; + int regFree2 = 0; + int r1 = 0, r2 = 0; + + Debug.Assert(jumpIfNull == SQLITE_JUMPIFNULL || jumpIfNull == 0); + if (NEVER(v == null)) + return; /* Existance of VDBE checked by caller */ + if (NEVER(pExpr == null)) + return; /* No way this can happen */ + op = pExpr.op; + switch (op) { + case TK_AND: { + int d2 = sqlite3VdbeMakeLabel(v); + testcase(jumpIfNull == 0); + sqlite3ExprCachePush(pParse); + sqlite3ExprIfFalse(pParse, pExpr.pLeft, d2, jumpIfNull ^ SQLITE_JUMPIFNULL); + sqlite3ExprIfTrue(pParse, pExpr.pRight, dest, jumpIfNull); + sqlite3VdbeResolveLabel(v, d2); + sqlite3ExprCachePop(pParse, 1); + break; + } + case TK_OR: { + testcase(jumpIfNull == 0); + sqlite3ExprIfTrue(pParse, pExpr.pLeft, dest, jumpIfNull); + sqlite3ExprIfTrue(pParse, pExpr.pRight, dest, jumpIfNull); + break; + } + case TK_NOT: { + testcase(jumpIfNull == 0); + sqlite3ExprIfFalse(pParse, pExpr.pLeft, dest, jumpIfNull); + break; + } + case TK_LT: + case TK_LE: + case TK_GT: + case TK_GE: + case TK_NE: + case TK_EQ: { + Debug.Assert(TK_LT == OP_Lt); + Debug.Assert(TK_LE == OP_Le); + Debug.Assert(TK_GT == OP_Gt); + Debug.Assert(TK_GE == OP_Ge); + Debug.Assert(TK_EQ == OP_Eq); + Debug.Assert(TK_NE == OP_Ne); + testcase(op == TK_LT); + testcase(op == TK_LE); + testcase(op == TK_GT); + testcase(op == TK_GE); + testcase(op == TK_EQ); + testcase(op == TK_NE); + testcase(jumpIfNull == 0); + r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); + r2 = sqlite3ExprCodeTemp(pParse, pExpr.pRight, ref regFree2); + codeCompare(pParse, pExpr.pLeft, pExpr.pRight, op, + r1, r2, dest, jumpIfNull); + testcase(regFree1 == 0); + testcase(regFree2 == 0); + break; + } + case TK_IS: + case TK_ISNOT: { + testcase(op == TK_IS); + testcase(op == TK_ISNOT); + r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); + r2 = sqlite3ExprCodeTemp(pParse, pExpr.pRight, ref regFree2); + op = (op == TK_IS) ? TK_EQ : TK_NE; + codeCompare(pParse, pExpr.pLeft, pExpr.pRight, op, + r1, r2, dest, SQLITE_NULLEQ); + testcase(regFree1 == 0); + testcase(regFree2 == 0); + break; + } + case TK_ISNULL: + case TK_NOTNULL: { + Debug.Assert(TK_ISNULL == OP_IsNull); + Debug.Assert(TK_NOTNULL == OP_NotNull); + testcase(op == TK_ISNULL); + testcase(op == TK_NOTNULL); + r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); + sqlite3VdbeAddOp2(v, op, r1, dest); + testcase(regFree1 == 0); + break; + } + case TK_BETWEEN: { + testcase(jumpIfNull == 0); + exprCodeBetween(pParse, pExpr, dest, 1, jumpIfNull); + break; + } #if SQLITE_OMIT_SUBQUERY case TK_IN: { @@ -3850,151 +3445,141 @@ static void sqlite3ExprIfTrue( Parse pParse, Expr pExpr, int dest, int jumpIfNul break; } #endif - default: - { - r1 = sqlite3ExprCodeTemp( pParse, pExpr, ref regFree1 ); - sqlite3VdbeAddOp3( v, OP_If, r1, dest, jumpIfNull != 0 ? 1 : 0 ); - testcase( regFree1 == 0 ); - testcase( jumpIfNull == 0 ); - break; - } - } - sqlite3ReleaseTempReg( pParse, regFree1 ); - sqlite3ReleaseTempReg( pParse, regFree2 ); - } + default: { + r1 = sqlite3ExprCodeTemp(pParse, pExpr, ref regFree1); + sqlite3VdbeAddOp3(v, OP_If, r1, dest, jumpIfNull != 0 ? 1 : 0); + testcase(regFree1 == 0); + testcase(jumpIfNull == 0); + break; + } + } + sqlite3ReleaseTempReg(pParse, regFree1); + sqlite3ReleaseTempReg(pParse, regFree2); + } - /* - ** Generate code for a boolean expression such that a jump is made - ** to the label "dest" if the expression is false but execution - ** continues straight thru if the expression is true. - ** - ** If the expression evaluates to NULL (neither true nor false) then - ** jump if jumpIfNull is SQLITE_JUMPIFNULL or fall through if jumpIfNull - ** is 0. - */ - static void sqlite3ExprIfFalse( Parse pParse, Expr pExpr, int dest, int jumpIfNull ) - { - Vdbe v = pParse.pVdbe; - int op = 0; - int regFree1 = 0; - int regFree2 = 0; - int r1 = 0, r2 = 0; - - Debug.Assert( jumpIfNull == SQLITE_JUMPIFNULL || jumpIfNull == 0 ); - if ( NEVER( v == null ) ) - return; /* Existance of VDBE checked by caller */ - if ( pExpr == null ) - return; - - /* The value of pExpr.op and op are related as follows: - ** - ** pExpr.op op - ** --------- ---------- - ** TK_ISNULL OP_NotNull - ** TK_NOTNULL OP_IsNull - ** TK_NE OP_Eq - ** TK_EQ OP_Ne - ** TK_GT OP_Le - ** TK_LE OP_Gt - ** TK_GE OP_Lt - ** TK_LT OP_Ge - ** - ** For other values of pExpr.op, op is undefined and unused. - ** The value of TK_ and OP_ constants are arranged such that we - ** can compute the mapping above using the following expression. - ** Assert()s verify that the computation is correct. - */ - op = ( ( pExpr.op + ( TK_ISNULL & 1 ) ) ^ 1 ) - ( TK_ISNULL & 1 ); - - /* Verify correct alignment of TK_ and OP_ constants - */ - Debug.Assert( pExpr.op != TK_ISNULL || op == OP_NotNull ); - Debug.Assert( pExpr.op != TK_NOTNULL || op == OP_IsNull ); - Debug.Assert( pExpr.op != TK_NE || op == OP_Eq ); - Debug.Assert( pExpr.op != TK_EQ || op == OP_Ne ); - Debug.Assert( pExpr.op != TK_LT || op == OP_Ge ); - Debug.Assert( pExpr.op != TK_LE || op == OP_Gt ); - Debug.Assert( pExpr.op != TK_GT || op == OP_Le ); - Debug.Assert( pExpr.op != TK_GE || op == OP_Lt ); - - switch ( pExpr.op ) - { - case TK_AND: - { - testcase( jumpIfNull == 0 ); - sqlite3ExprIfFalse( pParse, pExpr.pLeft, dest, jumpIfNull ); - sqlite3ExprIfFalse( pParse, pExpr.pRight, dest, jumpIfNull ); - break; - } - case TK_OR: - { - int d2 = sqlite3VdbeMakeLabel( v ); - testcase( jumpIfNull == 0 ); - sqlite3ExprCachePush( pParse ); - sqlite3ExprIfTrue( pParse, pExpr.pLeft, d2, jumpIfNull ^ SQLITE_JUMPIFNULL ); - sqlite3ExprIfFalse( pParse, pExpr.pRight, dest, jumpIfNull ); - sqlite3VdbeResolveLabel( v, d2 ); - sqlite3ExprCachePop( pParse, 1 ); - break; - } - case TK_NOT: - { - testcase( jumpIfNull == 0 ); - sqlite3ExprIfTrue( pParse, pExpr.pLeft, dest, jumpIfNull ); - break; - } - case TK_LT: - case TK_LE: - case TK_GT: - case TK_GE: - case TK_NE: - case TK_EQ: - { - testcase( op == TK_LT ); - testcase( op == TK_LE ); - testcase( op == TK_GT ); - testcase( op == TK_GE ); - testcase( op == TK_EQ ); - testcase( op == TK_NE ); - testcase( jumpIfNull == 0 ); - r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); - r2 = sqlite3ExprCodeTemp( pParse, pExpr.pRight, ref regFree2 ); - codeCompare( pParse, pExpr.pLeft, pExpr.pRight, op, - r1, r2, dest, jumpIfNull ); - testcase( regFree1 == 0 ); - testcase( regFree2 == 0 ); - break; - } - case TK_IS: - case TK_ISNOT: - { - testcase( pExpr.op == TK_IS ); - testcase( pExpr.op == TK_ISNOT ); - r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); - r2 = sqlite3ExprCodeTemp( pParse, pExpr.pRight, ref regFree2 ); - op = ( pExpr.op == TK_IS ) ? TK_NE : TK_EQ; - codeCompare( pParse, pExpr.pLeft, pExpr.pRight, op, - r1, r2, dest, SQLITE_NULLEQ ); - testcase( regFree1 == 0 ); - testcase( regFree2 == 0 ); - break; - } - case TK_ISNULL: - case TK_NOTNULL: - { - testcase( op == TK_ISNULL ); - testcase( op == TK_NOTNULL ); - r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); - sqlite3VdbeAddOp2( v, op, r1, dest ); - testcase( regFree1 == 0 ); - break; - } - case TK_BETWEEN: - { - testcase( jumpIfNull == 0 ); - exprCodeBetween( pParse, pExpr, dest, 0, jumpIfNull ); - break; - } + /* + ** Generate code for a boolean expression such that a jump is made + ** to the label "dest" if the expression is false but execution + ** continues straight thru if the expression is true. + ** + ** If the expression evaluates to NULL (neither true nor false) then + ** jump if jumpIfNull is SQLITE_JUMPIFNULL or fall through if jumpIfNull + ** is 0. + */ + static void sqlite3ExprIfFalse(Parse pParse, Expr pExpr, int dest, int jumpIfNull) { + Vdbe v = pParse.pVdbe; + int op = 0; + int regFree1 = 0; + int regFree2 = 0; + int r1 = 0, r2 = 0; + + Debug.Assert(jumpIfNull == SQLITE_JUMPIFNULL || jumpIfNull == 0); + if (NEVER(v == null)) + return; /* Existance of VDBE checked by caller */ + if (pExpr == null) + return; + + /* The value of pExpr.op and op are related as follows: + ** + ** pExpr.op op + ** --------- ---------- + ** TK_ISNULL OP_NotNull + ** TK_NOTNULL OP_IsNull + ** TK_NE OP_Eq + ** TK_EQ OP_Ne + ** TK_GT OP_Le + ** TK_LE OP_Gt + ** TK_GE OP_Lt + ** TK_LT OP_Ge + ** + ** For other values of pExpr.op, op is undefined and unused. + ** The value of TK_ and OP_ constants are arranged such that we + ** can compute the mapping above using the following expression. + ** Assert()s verify that the computation is correct. + */ + op = ((pExpr.op + (TK_ISNULL & 1)) ^ 1) - (TK_ISNULL & 1); + + /* Verify correct alignment of TK_ and OP_ constants + */ + Debug.Assert(pExpr.op != TK_ISNULL || op == OP_NotNull); + Debug.Assert(pExpr.op != TK_NOTNULL || op == OP_IsNull); + Debug.Assert(pExpr.op != TK_NE || op == OP_Eq); + Debug.Assert(pExpr.op != TK_EQ || op == OP_Ne); + Debug.Assert(pExpr.op != TK_LT || op == OP_Ge); + Debug.Assert(pExpr.op != TK_LE || op == OP_Gt); + Debug.Assert(pExpr.op != TK_GT || op == OP_Le); + Debug.Assert(pExpr.op != TK_GE || op == OP_Lt); + + switch (pExpr.op) { + case TK_AND: { + testcase(jumpIfNull == 0); + sqlite3ExprIfFalse(pParse, pExpr.pLeft, dest, jumpIfNull); + sqlite3ExprIfFalse(pParse, pExpr.pRight, dest, jumpIfNull); + break; + } + case TK_OR: { + int d2 = sqlite3VdbeMakeLabel(v); + testcase(jumpIfNull == 0); + sqlite3ExprCachePush(pParse); + sqlite3ExprIfTrue(pParse, pExpr.pLeft, d2, jumpIfNull ^ SQLITE_JUMPIFNULL); + sqlite3ExprIfFalse(pParse, pExpr.pRight, dest, jumpIfNull); + sqlite3VdbeResolveLabel(v, d2); + sqlite3ExprCachePop(pParse, 1); + break; + } + case TK_NOT: { + testcase(jumpIfNull == 0); + sqlite3ExprIfTrue(pParse, pExpr.pLeft, dest, jumpIfNull); + break; + } + case TK_LT: + case TK_LE: + case TK_GT: + case TK_GE: + case TK_NE: + case TK_EQ: { + testcase(op == TK_LT); + testcase(op == TK_LE); + testcase(op == TK_GT); + testcase(op == TK_GE); + testcase(op == TK_EQ); + testcase(op == TK_NE); + testcase(jumpIfNull == 0); + r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); + r2 = sqlite3ExprCodeTemp(pParse, pExpr.pRight, ref regFree2); + codeCompare(pParse, pExpr.pLeft, pExpr.pRight, op, + r1, r2, dest, jumpIfNull); + testcase(regFree1 == 0); + testcase(regFree2 == 0); + break; + } + case TK_IS: + case TK_ISNOT: { + testcase(pExpr.op == TK_IS); + testcase(pExpr.op == TK_ISNOT); + r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); + r2 = sqlite3ExprCodeTemp(pParse, pExpr.pRight, ref regFree2); + op = (pExpr.op == TK_IS) ? TK_NE : TK_EQ; + codeCompare(pParse, pExpr.pLeft, pExpr.pRight, op, + r1, r2, dest, SQLITE_NULLEQ); + testcase(regFree1 == 0); + testcase(regFree2 == 0); + break; + } + case TK_ISNULL: + case TK_NOTNULL: { + testcase(op == TK_ISNULL); + testcase(op == TK_NOTNULL); + r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); + sqlite3VdbeAddOp2(v, op, r1, dest); + testcase(regFree1 == 0); + break; + } + case TK_BETWEEN: { + testcase(jumpIfNull == 0); + exprCodeBetween(pParse, pExpr, dest, 0, jumpIfNull); + break; + } #if SQLITE_OMIT_SUBQUERY case TK_IN: { @@ -4011,432 +3596,379 @@ static void sqlite3ExprIfFalse( Parse pParse, Expr pExpr, int dest, int jumpIfNu break; } #endif - default: - { - r1 = sqlite3ExprCodeTemp( pParse, pExpr, ref regFree1 ); - sqlite3VdbeAddOp3( v, OP_IfNot, r1, dest, jumpIfNull != 0 ? 1 : 0 ); - testcase( regFree1 == 0 ); - testcase( jumpIfNull == 0 ); - break; - } - } - sqlite3ReleaseTempReg( pParse, regFree1 ); - sqlite3ReleaseTempReg( pParse, regFree2 ); - } - - /* - ** Do a deep comparison of two expression trees. Return 0 if the two - ** expressions are completely identical. Return 1 if they differ only - ** by a COLLATE operator at the top level. Return 2 if there are differences - ** other than the top-level COLLATE operator. - ** - ** Sometimes this routine will return 2 even if the two expressions - ** really are equivalent. If we cannot prove that the expressions are - ** identical, we return 2 just to be safe. So if this routine - ** returns 2, then you do not really know for certain if the two - ** expressions are the same. But if you get a 0 or 1 return, then you - ** can be sure the expressions are the same. In the places where - ** this routine is used, it does not hurt to get an extra 2 - that - ** just might result in some slightly slower code. But returning - ** an incorrect 0 or 1 could lead to a malfunction. - */ - static int sqlite3ExprCompare( Expr pA, Expr pB ) - { - if ( pA == null || pB == null ) - { - return pB == pA ? 0 : 2; - } - Debug.Assert( !ExprHasAnyProperty( pA, EP_TokenOnly | EP_Reduced ) ); - Debug.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 ) - return 2; - if ( sqlite3ExprCompare( pA.pLeft, pB.pLeft ) != 0 ) - return 2; - if ( sqlite3ExprCompare( pA.pRight, pB.pRight ) != 0 ) - return 2; - if ( sqlite3ExprListCompare( pA.x.pList, pB.x.pList ) != 0 ) - return 2; - if ( pA.iTable != pB.iTable || pA.iColumn != pB.iColumn ) - return 2; - if ( ExprHasProperty( pA, EP_IntValue ) ) - { - if ( !ExprHasProperty( pB, EP_IntValue ) || pA.u.iValue != pB.u.iValue ) - { - return 2; + default: { + r1 = sqlite3ExprCodeTemp(pParse, pExpr, ref regFree1); + sqlite3VdbeAddOp3(v, OP_IfNot, r1, dest, jumpIfNull != 0 ? 1 : 0); + testcase(regFree1 == 0); + testcase(jumpIfNull == 0); + break; + } + } + sqlite3ReleaseTempReg(pParse, regFree1); + sqlite3ReleaseTempReg(pParse, regFree2); } - } - else if ( pA.op != TK_COLUMN && pA.u.zToken != null ) - { - if ( ExprHasProperty( pB, EP_IntValue ) || NEVER( pB.u.zToken == null ) ) - return 2; - if ( !pA.u.zToken.Equals( pB.u.zToken ,StringComparison.OrdinalIgnoreCase ) ) - { - return 2; + + /* + ** Do a deep comparison of two expression trees. Return 0 if the two + ** expressions are completely identical. Return 1 if they differ only + ** by a COLLATE operator at the top level. Return 2 if there are differences + ** other than the top-level COLLATE operator. + ** + ** Sometimes this routine will return 2 even if the two expressions + ** really are equivalent. If we cannot prove that the expressions are + ** identical, we return 2 just to be safe. So if this routine + ** returns 2, then you do not really know for certain if the two + ** expressions are the same. But if you get a 0 or 1 return, then you + ** can be sure the expressions are the same. In the places where + ** this routine is used, it does not hurt to get an extra 2 - that + ** just might result in some slightly slower code. But returning + ** an incorrect 0 or 1 could lead to a malfunction. + */ + static int sqlite3ExprCompare(Expr pA, Expr pB) { + if (pA == null || pB == null) { + return pB == pA ? 0 : 2; + } + Debug.Assert(!ExprHasAnyProperty(pA, EP_TokenOnly | EP_Reduced)); + Debug.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) + return 2; + if (sqlite3ExprCompare(pA.pLeft, pB.pLeft) != 0) + return 2; + if (sqlite3ExprCompare(pA.pRight, pB.pRight) != 0) + return 2; + if (sqlite3ExprListCompare(pA.x.pList, pB.x.pList) != 0) + return 2; + if (pA.iTable != pB.iTable || pA.iColumn != pB.iColumn) + return 2; + if (ExprHasProperty(pA, EP_IntValue)) { + if (!ExprHasProperty(pB, EP_IntValue) || pA.u.iValue != pB.u.iValue) { + return 2; + } + } else if (pA.op != TK_COLUMN && pA.u.zToken != null) { + if (ExprHasProperty(pB, EP_IntValue) || NEVER(pB.u.zToken == null)) + return 2; + if (!pA.u.zToken.Equals(pB.u.zToken, StringComparison.OrdinalIgnoreCase)) { + return 2; + } + } + if ((pA.flags & EP_ExpCollate) != (pB.flags & EP_ExpCollate)) + return 1; + if ((pA.flags & EP_ExpCollate) != 0 && pA.pColl != pB.pColl) + return 2; + return 0; } - } - if ( ( pA.flags & EP_ExpCollate ) != ( pB.flags & EP_ExpCollate ) ) - return 1; - if ( ( pA.flags & EP_ExpCollate ) != 0 && pA.pColl != pB.pColl ) - return 2; - return 0; - } - /* - ** Compare two ExprList objects. Return 0 if they are identical and - ** non-zero if they differ in any way. - ** - ** This routine might return non-zero for equivalent ExprLists. The - ** only consequence will be disabled optimizations. But this routine - ** must never return 0 if the two ExprList objects are different, or - ** a malfunction will result. - ** - ** Two NULL pointers are considered to be the same. But a NULL pointer - ** always differs from a non-NULL pointer. - */ - static int sqlite3ExprListCompare( ExprList pA, ExprList pB ) - { - int i; - if ( pA == null && pB == null ) - return 0; - if ( pA == null || pB == null ) - return 1; - if ( pA.nExpr != pB.nExpr ) - return 1; - for ( i = 0; i < pA.nExpr; i++ ) - { - Expr pExprA = pA.a[i].pExpr; - Expr pExprB = pB.a[i].pExpr; - if ( pA.a[i].sortOrder != pB.a[i].sortOrder ) - return 1; - if ( sqlite3ExprCompare( pExprA, pExprB ) != 0 ) - return 1; - } - return 0; - } + /* + ** Compare two ExprList objects. Return 0 if they are identical and + ** non-zero if they differ in any way. + ** + ** This routine might return non-zero for equivalent ExprLists. The + ** only consequence will be disabled optimizations. But this routine + ** must never return 0 if the two ExprList objects are different, or + ** a malfunction will result. + ** + ** Two NULL pointers are considered to be the same. But a NULL pointer + ** always differs from a non-NULL pointer. + */ + static int sqlite3ExprListCompare(ExprList pA, ExprList pB) { + int i; + if (pA == null && pB == null) + return 0; + if (pA == null || pB == null) + return 1; + if (pA.nExpr != pB.nExpr) + return 1; + for (i = 0; i < pA.nExpr; i++) { + Expr pExprA = pA.a[i].pExpr; + Expr pExprB = pB.a[i].pExpr; + if (pA.a[i].sortOrder != pB.a[i].sortOrder) + return 1; + if (sqlite3ExprCompare(pExprA, pExprB) != 0) + return 1; + } + return 0; + } - /* - ** Add a new element to the pAggInfo.aCol[] array. Return the index of - ** the new element. Return a negative number if malloc fails. - */ - static int addAggInfoColumn( sqlite3 db, AggInfo pInfo ) - { - int i = 0; - pInfo.aCol = sqlite3ArrayAllocate( - db, - pInfo.aCol, - -1,//sizeof(pInfo.aCol[0]), - 3, - ref pInfo.nColumn, - ref pInfo.nColumnAlloc, - ref i - ); - return i; - } + /* + ** Add a new element to the pAggInfo.aCol[] array. Return the index of + ** the new element. Return a negative number if malloc fails. + */ + static int addAggInfoColumn(sqlite3 db, AggInfo pInfo) { + int i = 0; + pInfo.aCol = sqlite3ArrayAllocate( + db, + pInfo.aCol, + -1,//sizeof(pInfo.aCol[0]), + 3, + ref pInfo.nColumn, + ref pInfo.nColumnAlloc, + ref i + ); + return i; + } - /* - ** Add a new element to the pAggInfo.aFunc[] array. Return the index of - ** the new element. Return a negative number if malloc fails. - */ - static int addAggInfoFunc( sqlite3 db, AggInfo pInfo ) - { - int i = 0; - pInfo.aFunc = sqlite3ArrayAllocate( - db, - pInfo.aFunc, - -1,//sizeof(pInfo.aFunc[0]), - 3, - ref pInfo.nFunc, - ref pInfo.nFuncAlloc, - ref i - ); - return i; - } + /* + ** Add a new element to the pAggInfo.aFunc[] array. Return the index of + ** the new element. Return a negative number if malloc fails. + */ + static int addAggInfoFunc(sqlite3 db, AggInfo pInfo) { + int i = 0; + pInfo.aFunc = sqlite3ArrayAllocate( + db, + pInfo.aFunc, + -1,//sizeof(pInfo.aFunc[0]), + 3, + ref pInfo.nFunc, + ref pInfo.nFuncAlloc, + ref i + ); + return i; + } - /* - ** This is the xExprCallback for a tree walker. It is used to - ** implement sqlite3ExprAnalyzeAggregates(). See sqlite3ExprAnalyzeAggregates - ** for additional information. - */ - static int analyzeAggregate( Walker pWalker, ref Expr pExpr ) - { - int i; - NameContext pNC = pWalker.u.pNC; - Parse pParse = pNC.pParse; - SrcList pSrcList = pNC.pSrcList; - AggInfo pAggInfo = pNC.pAggInfo; - - switch ( pExpr.op ) - { - case TK_AGG_COLUMN: - case TK_COLUMN: - { - testcase( pExpr.op == TK_AGG_COLUMN ); - testcase( pExpr.op == TK_COLUMN ); - /* Check to see if the column is in one of the tables in the FROM - ** clause of the aggregate query */ - if ( ALWAYS( pSrcList != null ) ) - { - SrcList_item pItem;// = pSrcList.a; - for ( i = 0; i < pSrcList.nSrc; i++ ) - {//, pItem++){ - pItem = pSrcList.a[i]; - AggInfo_col pCol; - Debug.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 - ** is not an entry there already. - */ - int k; - //pCol = pAggInfo.aCol; - for ( k = 0; k < pAggInfo.nColumn; k++ ) - {//, pCol++){ - pCol = pAggInfo.aCol[k]; - if ( pCol.iTable == pExpr.iTable && - pCol.iColumn == pExpr.iColumn ) - { - break; - } - } - if ( ( k >= pAggInfo.nColumn ) - && ( k = addAggInfoColumn( pParse.db, pAggInfo ) ) >= 0 - ) - { - pCol = pAggInfo.aCol[k]; - pCol.pTab = pExpr.pTab; - pCol.iTable = pExpr.iTable; - pCol.iColumn = pExpr.iColumn; - pCol.iMem = ++pParse.nMem; - pCol.iSorterColumn = -1; - pCol.pExpr = pExpr; - if ( pAggInfo.pGroupBy != null ) - { - int j, n; - ExprList pGB = pAggInfo.pGroupBy; - ExprList_item pTerm;// = pGB.a; - n = pGB.nExpr; - for ( j = 0; j < n; j++ ) - {//, pTerm++){ - pTerm = pGB.a[j]; - Expr pE = pTerm.pExpr; - if ( pE.op == TK_COLUMN && pE.iTable == pExpr.iTable && - pE.iColumn == pExpr.iColumn ) - { - pCol.iSorterColumn = j; - break; + /* + ** This is the xExprCallback for a tree walker. It is used to + ** implement sqlite3ExprAnalyzeAggregates(). See sqlite3ExprAnalyzeAggregates + ** for additional information. + */ + static int analyzeAggregate(Walker pWalker, ref Expr pExpr) { + int i; + NameContext pNC = pWalker.u.pNC; + Parse pParse = pNC.pParse; + SrcList pSrcList = pNC.pSrcList; + AggInfo pAggInfo = pNC.pAggInfo; + + switch (pExpr.op) { + case TK_AGG_COLUMN: + case TK_COLUMN: { + testcase(pExpr.op == TK_AGG_COLUMN); + testcase(pExpr.op == TK_COLUMN); + /* Check to see if the column is in one of the tables in the FROM + ** clause of the aggregate query */ + if (ALWAYS(pSrcList != null)) { + SrcList_item pItem;// = pSrcList.a; + for (i = 0; i < pSrcList.nSrc; i++) {//, pItem++){ + pItem = pSrcList.a[i]; + AggInfo_col pCol; + Debug.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 + ** is not an entry there already. + */ + int k; + //pCol = pAggInfo.aCol; + for (k = 0; k < pAggInfo.nColumn; k++) {//, pCol++){ + pCol = pAggInfo.aCol[k]; + if (pCol.iTable == pExpr.iTable && + pCol.iColumn == pExpr.iColumn) { + break; + } + } + if ((k >= pAggInfo.nColumn) + && (k = addAggInfoColumn(pParse.db, pAggInfo)) >= 0 + ) { + pCol = pAggInfo.aCol[k]; + pCol.pTab = pExpr.pTab; + pCol.iTable = pExpr.iTable; + pCol.iColumn = pExpr.iColumn; + pCol.iMem = ++pParse.nMem; + pCol.iSorterColumn = -1; + pCol.pExpr = pExpr; + if (pAggInfo.pGroupBy != null) { + int j, n; + ExprList pGB = pAggInfo.pGroupBy; + ExprList_item pTerm;// = pGB.a; + n = pGB.nExpr; + for (j = 0; j < n; j++) {//, pTerm++){ + pTerm = pGB.a[j]; + Expr pE = pTerm.pExpr; + if (pE.op == TK_COLUMN && pE.iTable == pExpr.iTable && + pE.iColumn == pExpr.iColumn) { + pCol.iSorterColumn = j; + break; + } + } + } + if (pCol.iSorterColumn < 0) { + pCol.iSorterColumn = pAggInfo.nSortingColumn++; + } + } + /* 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. + */ + ExprSetIrreducible(pExpr); + pExpr.pAggInfo = pAggInfo; + pExpr.op = TK_AGG_COLUMN; + pExpr.iAgg = (short)k; + break; + } /* endif pExpr.iTable==pItem.iCursor */ + } /* end loop over pSrcList */ } - } + return WRC_Prune; } - if ( pCol.iSorterColumn < 0 ) - { - pCol.iSorterColumn = pAggInfo.nSortingColumn++; + case TK_AGG_FUNCTION: { + /* The pNC.nDepth==0 test causes aggregate functions in subqueries + ** to be ignored */ + if (pNC.nDepth == 0) { + /* Check to see if pExpr is a duplicate of another aggregate + ** function that is already in the pAggInfo structure + */ + AggInfo_func pItem;// = pAggInfo.aFunc; + for (i = 0; i < pAggInfo.nFunc; i++) {//, pItem++){ + pItem = pAggInfo.aFunc[i]; + if (sqlite3ExprCompare(pItem.pExpr, pExpr) == 0) { + break; + } + } + if (i >= pAggInfo.nFunc) { + /* pExpr is original. Make a new entry in pAggInfo.aFunc[] + */ + u8 enc = pParse.db.aDbStatic[0].pSchema.enc;// ENC(pParse.db); + i = addAggInfoFunc(pParse.db, pAggInfo); + if (i >= 0) { + Debug.Assert(!ExprHasProperty(pExpr, EP_xIsSelect)); + pItem = pAggInfo.aFunc[i]; + pItem.pExpr = pExpr; + pItem.iMem = ++pParse.nMem; + Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); + pItem.pFunc = sqlite3FindFunction(pParse.db, + pExpr.u.zToken, sqlite3Strlen30(pExpr.u.zToken), + pExpr.x.pList != null ? pExpr.x.pList.nExpr : 0, enc, 0); + if ((pExpr.flags & EP_Distinct) != 0) { + pItem.iDistinct = pParse.nTab++; + } else { + pItem.iDistinct = -1; + } + } + } + /* Make pExpr point to the appropriate pAggInfo.aFunc[] entry + */ + Debug.Assert(!ExprHasAnyProperty(pExpr, EP_TokenOnly | EP_Reduced)); + ExprSetIrreducible(pExpr); + pExpr.iAgg = (short)i; + pExpr.pAggInfo = pAggInfo; + return WRC_Prune; + } + break; } - } - /* 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. - */ - ExprSetIrreducible( pExpr ); - pExpr.pAggInfo = pAggInfo; - pExpr.op = TK_AGG_COLUMN; - pExpr.iAgg = (short)k; - break; - } /* endif pExpr.iTable==pItem.iCursor */ - } /* end loop over pSrcList */ - } - return WRC_Prune; - } - case TK_AGG_FUNCTION: - { - /* The pNC.nDepth==0 test causes aggregate functions in subqueries - ** to be ignored */ - if ( pNC.nDepth == 0 ) - { - /* Check to see if pExpr is a duplicate of another aggregate - ** function that is already in the pAggInfo structure - */ - AggInfo_func pItem;// = pAggInfo.aFunc; - for ( i = 0; i < pAggInfo.nFunc; i++ ) - {//, pItem++){ - pItem = pAggInfo.aFunc[i]; - if ( sqlite3ExprCompare( pItem.pExpr, pExpr ) == 0 ) - { - break; - } - } - if ( i >= pAggInfo.nFunc ) - { - /* pExpr is original. Make a new entry in pAggInfo.aFunc[] - */ - u8 enc = pParse.db.aDbStatic[0].pSchema.enc;// ENC(pParse.db); - i = addAggInfoFunc( pParse.db, pAggInfo ); - if ( i >= 0 ) - { - Debug.Assert( !ExprHasProperty( pExpr, EP_xIsSelect ) ); - pItem = pAggInfo.aFunc[i]; - pItem.pExpr = pExpr; - pItem.iMem = ++pParse.nMem; - Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); - pItem.pFunc = sqlite3FindFunction( pParse.db, - pExpr.u.zToken, sqlite3Strlen30( pExpr.u.zToken ), - pExpr.x.pList != null ? pExpr.x.pList.nExpr : 0, enc, 0 ); - if ( ( pExpr.flags & EP_Distinct ) != 0 ) - { - pItem.iDistinct = pParse.nTab++; - } - else - { - pItem.iDistinct = -1; - } - } - } - /* Make pExpr point to the appropriate pAggInfo.aFunc[] entry - */ - Debug.Assert( !ExprHasAnyProperty( pExpr, EP_TokenOnly | EP_Reduced ) ); - ExprSetIrreducible( pExpr ); - pExpr.iAgg = (short)i; - pExpr.pAggInfo = pAggInfo; - return WRC_Prune; } - break; - } - } - return WRC_Continue; - } + return WRC_Continue; + } - static int analyzeAggregatesInSelect( Walker pWalker, Select pSelect ) - { - NameContext pNC = pWalker.u.pNC; - if ( pNC.nDepth == 0 ) - { - pNC.nDepth++; - sqlite3WalkSelect( pWalker, pSelect ); - pNC.nDepth--; - return WRC_Prune; - } - else - { - return WRC_Continue; - } - } + static int analyzeAggregatesInSelect(Walker pWalker, Select pSelect) { + NameContext pNC = pWalker.u.pNC; + if (pNC.nDepth == 0) { + pNC.nDepth++; + sqlite3WalkSelect(pWalker, pSelect); + pNC.nDepth--; + return WRC_Prune; + } else { + return WRC_Continue; + } + } - /* - ** Analyze the given expression looking for aggregate functions and - ** for variables that need to be added to the pParse.aAgg[] array. - ** Make additional entries to the pParse.aAgg[] array as necessary. - ** - ** This routine should only be called after the expression has been - ** analyzed by sqlite3ResolveExprNames(). - */ - static void sqlite3ExprAnalyzeAggregates( NameContext pNC, ref Expr pExpr ) - { - Walker w = new Walker(); - w.xExprCallback = (dxExprCallback)analyzeAggregate; - w.xSelectCallback = (dxSelectCallback)analyzeAggregatesInSelect; - w.u.pNC = pNC; - Debug.Assert( pNC.pSrcList != null ); - sqlite3WalkExpr( w, ref pExpr ); - } + /* + ** Analyze the given expression looking for aggregate functions and + ** for variables that need to be added to the pParse.aAgg[] array. + ** Make additional entries to the pParse.aAgg[] array as necessary. + ** + ** This routine should only be called after the expression has been + ** analyzed by sqlite3ResolveExprNames(). + */ + static void sqlite3ExprAnalyzeAggregates(NameContext pNC, ref Expr pExpr) { + Walker w = new Walker(); + w.xExprCallback = (dxExprCallback)analyzeAggregate; + w.xSelectCallback = (dxSelectCallback)analyzeAggregatesInSelect; + w.u.pNC = pNC; + Debug.Assert(pNC.pSrcList != null); + sqlite3WalkExpr(w, ref pExpr); + } - /* - ** Call sqlite3ExprAnalyzeAggregates() for every expression in an - ** expression list. Return the number of errors. - ** - ** If an error is found, the analysis is cut short. - */ - static void sqlite3ExprAnalyzeAggList( NameContext pNC, ExprList pList ) - { - ExprList_item pItem; - int i; - if ( pList != null ) - { - for ( i = 0; i < pList.nExpr; i++ )//, pItem++) - { - pItem = pList.a[i]; - sqlite3ExprAnalyzeAggregates( pNC, ref pItem.pExpr ); + /* + ** Call sqlite3ExprAnalyzeAggregates() for every expression in an + ** expression list. Return the number of errors. + ** + ** If an error is found, the analysis is cut short. + */ + static void sqlite3ExprAnalyzeAggList(NameContext pNC, ExprList pList) { + ExprList_item pItem; + int i; + if (pList != null) { + for (i = 0; i < pList.nExpr; i++)//, pItem++) + { + pItem = pList.a[i]; + sqlite3ExprAnalyzeAggregates(pNC, ref pItem.pExpr); + } + } } - } - } - /* - ** Allocate a single new register for use to hold some intermediate result. - */ - static int sqlite3GetTempReg( Parse pParse ) - { - if ( pParse.nTempReg == 0 ) - { - return ++pParse.nMem; - } - return pParse.aTempReg[--pParse.nTempReg]; - } + /* + ** Allocate a single new register for use to hold some intermediate result. + */ + static int sqlite3GetTempReg(Parse pParse) { + if (pParse.nTempReg == 0) { + return ++pParse.nMem; + } + return pParse.aTempReg[--pParse.nTempReg]; + } - /* - ** Deallocate a register, making available for reuse for some other - ** purpose. - ** - ** If a register is currently being used by the column cache, then - ** the dallocation is deferred until the column cache line that uses - ** the register becomes stale. - */ - static void sqlite3ReleaseTempReg( Parse pParse, int iReg ) - { - if ( iReg != 0 && pParse.nTempReg < ArraySize( pParse.aTempReg ) ) - { - int i; - yColCache p; - for ( i = 0; i < SQLITE_N_COLCACHE; i++ )//p=pParse.aColCache... p++) - { - p = pParse.aColCache[i]; - if ( p.iReg == iReg ) - { - p.tempReg = 1; - return; - } + /* + ** Deallocate a register, making available for reuse for some other + ** purpose. + ** + ** If a register is currently being used by the column cache, then + ** the dallocation is deferred until the column cache line that uses + ** the register becomes stale. + */ + static void sqlite3ReleaseTempReg(Parse pParse, int iReg) { + if (iReg != 0 && pParse.nTempReg < ArraySize(pParse.aTempReg)) { + int i; + yColCache p; + for (i = 0; i < SQLITE_N_COLCACHE; i++)//p=pParse.aColCache... p++) + { + p = pParse.aColCache[i]; + if (p.iReg == iReg) { + p.tempReg = 1; + return; + } + } + pParse.aTempReg[pParse.nTempReg++] = iReg; + } } - pParse.aTempReg[pParse.nTempReg++] = iReg; - } - } - /* - ** Allocate or deallocate a block of nReg consecutive registers - */ - static int sqlite3GetTempRange( Parse pParse, int nReg ) - { - int i, n; - i = pParse.iRangeReg; - n = pParse.nRangeReg; - if ( nReg <= n ) - { - //Debug.Assert( 1 == usedAsColumnCache( pParse, i, i + n - 1 ) ); - pParse.iRangeReg += nReg; - pParse.nRangeReg -= nReg; - } - else - { - i = pParse.nMem + 1; - pParse.nMem += nReg; - } - return i; - } - static void sqlite3ReleaseTempRange( Parse pParse, int iReg, int nReg ) - { - sqlite3ExprCacheRemove( pParse, iReg, nReg ); - if ( nReg > pParse.nRangeReg ) - { - pParse.nRangeReg = nReg; - pParse.iRangeReg = iReg; - } + /* + ** Allocate or deallocate a block of nReg consecutive registers + */ + static int sqlite3GetTempRange(Parse pParse, int nReg) { + int i, n; + i = pParse.iRangeReg; + n = pParse.nRangeReg; + if (nReg <= n) { + //Debug.Assert( 1 == usedAsColumnCache( pParse, i, i + n - 1 ) ); + pParse.iRangeReg += nReg; + pParse.nRangeReg -= nReg; + } else { + i = pParse.nMem + 1; + pParse.nMem += nReg; + } + return i; + } + static void sqlite3ReleaseTempRange(Parse pParse, int iReg, int nReg) { + sqlite3ExprCacheRemove(pParse, iReg, nReg); + if (nReg > pParse.nRangeReg) { + pParse.nRangeReg = nReg; + pParse.iRangeReg = iReg; + } + } } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/fault_c.cs b/Src/IronPython.SQLite/c#sqlite/fault_c.cs index d94636d7e..2faf4fa51 100644 --- a/Src/IronPython.SQLite/c#sqlite/fault_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/fault_c.cs @@ -1,116 +1,104 @@ -using System; -using System.Diagnostics; - -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 2008 Jan 22 - ** - ** 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 contains code to support the concept of "benign" - ** malloc failures (when the xMalloc() or xRealloc() method of the - ** sqlite3_mem_methods structure fails to allocate a block of memory - ** and returns 0). - ** - ** Most malloc failures are non-benign. After they occur, SQLite - ** abandons the current operation and returns an error code (usually - ** SQLITE_NOMEM) to the user. However, sometimes a fault is not necessarily - ** fatal. For example, if a malloc fails while resizing a hash table, this - ** is completely recoverable simply by not carrying out the resize. The - ** hash table will continue to function normally. So a malloc failure - ** during a hash table resize is a benign fault. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2008 Jan 22 + ** + ** 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 contains code to support the concept of "benign" + ** malloc failures (when the xMalloc() or xRealloc() method of the + ** sqlite3_mem_methods structure fails to allocate a block of memory + ** and returns 0). + ** + ** Most malloc failures are non-benign. After they occur, SQLite + ** abandons the current operation and returns an error code (usually + ** SQLITE_NOMEM) to the user. However, sometimes a fault is not necessarily + ** fatal. For example, if a malloc fails while resizing a hash table, this + ** is completely recoverable simply by not carrying out the resize. The + ** hash table will continue to function normally. So a malloc failure + ** during a hash table resize is a benign fault. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" #if !SQLITE_OMIT_BUILTIN_TEST - /* -** Global variables. -*/ - //typedef struct BenignMallocHooks BenignMallocHooks; - public struct BenignMallocHooks// - { - public void_function xBenignBegin;//void (*xBenignBegin)(void); - public void_function xBenignEnd; //void (*xBenignEnd)(void); - public BenignMallocHooks( void_function xBenignBegin, void_function xBenignEnd ) - { - this.xBenignBegin = xBenignBegin; - this.xBenignEnd = xBenignEnd; - } - } - static BenignMallocHooks sqlite3Hooks = new BenignMallocHooks( null, null ); - - /* The "wsdHooks" macro will resolve to the appropriate BenignMallocHooks - ** structure. If writable static data is unsupported on the target, - ** we have to locate the state vector at run-time. In the more common - ** case where writable static data is supported, wsdHooks can refer directly - ** to the "sqlite3Hooks" state vector declared above. + /* + ** Global variables. */ + //typedef struct BenignMallocHooks BenignMallocHooks; + public struct BenignMallocHooks// + { + public void_function xBenignBegin;//void (*xBenignBegin)(void); + public void_function xBenignEnd; //void (*xBenignEnd)(void); + public BenignMallocHooks(void_function xBenignBegin, void_function xBenignEnd) { + this.xBenignBegin = xBenignBegin; + this.xBenignEnd = xBenignEnd; + } + } + static BenignMallocHooks sqlite3Hooks = new BenignMallocHooks(null, null); + + /* The "wsdHooks" macro will resolve to the appropriate BenignMallocHooks + ** structure. If writable static data is unsupported on the target, + ** we have to locate the state vector at run-time. In the more common + ** case where writable static data is supported, wsdHooks can refer directly + ** to the "sqlite3Hooks" state vector declared above. + */ #if SQLITE_OMIT_WSD //# define wsdHooksInit \ BenignMallocHooks *x = &GLOBAL(BenignMallocHooks,sqlite3Hooks) //# define wsdHooks x[0] #else - //# define wsdHooksInit - static void wsdHooksInit() - { - } - //# define wsdHooks sqlite3Hooks - static BenignMallocHooks wsdHooks = sqlite3Hooks; + //# define wsdHooksInit + static void wsdHooksInit() { + } + //# define wsdHooks sqlite3Hooks + static BenignMallocHooks wsdHooks = sqlite3Hooks; #endif - /* -** Register hooks to call when sqlite3BeginBenignMalloc() and -** sqlite3EndBenignMalloc() are called, respectively. -*/ - static void sqlite3BenignMallocHooks( - void_function xBenignBegin, //void (*xBenignBegin)(void), - void_function xBenignEnd //void (*xBenignEnd)(void) - ) - { - wsdHooksInit(); - wsdHooks.xBenignBegin = xBenignBegin; - wsdHooks.xBenignEnd = xBenignEnd; - } - - /* - ** This (sqlite3EndBenignMalloc()) is called by SQLite code to indicate that - ** subsequent malloc failures are benign. A call to sqlite3EndBenignMalloc() - ** indicates that subsequent malloc failures are non-benign. + /* + ** Register hooks to call when sqlite3BeginBenignMalloc() and + ** sqlite3EndBenignMalloc() are called, respectively. */ - static void sqlite3BeginBenignMalloc() - { - wsdHooksInit(); - if ( wsdHooks.xBenignBegin != null ) - { - wsdHooks.xBenignBegin(); - } - } - static void sqlite3EndBenignMalloc() - { - wsdHooksInit(); - if ( wsdHooks.xBenignEnd != null ) - { - wsdHooks.xBenignEnd(); - } - } + static void sqlite3BenignMallocHooks( + void_function xBenignBegin, //void (*xBenignBegin)(void), + void_function xBenignEnd //void (*xBenignEnd)(void) + ) { + wsdHooksInit(); + wsdHooks.xBenignBegin = xBenignBegin; + wsdHooks.xBenignEnd = xBenignEnd; + } + + /* + ** This (sqlite3EndBenignMalloc()) is called by SQLite code to indicate that + ** subsequent malloc failures are benign. A call to sqlite3EndBenignMalloc() + ** indicates that subsequent malloc failures are non-benign. + */ + static void sqlite3BeginBenignMalloc() { + wsdHooksInit(); + if (wsdHooks.xBenignBegin != null) { + wsdHooks.xBenignBegin(); + } + } + static void sqlite3EndBenignMalloc() { + wsdHooksInit(); + if (wsdHooks.xBenignEnd != null) { + wsdHooks.xBenignEnd(); + } + } #endif //* SQLITE_OMIT_BUILTIN_TEST */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/fkey_c.cs b/Src/IronPython.SQLite/c#sqlite/fkey_c.cs index fc3a967ec..76c124190 100644 --- a/Src/IronPython.SQLite/c#sqlite/fkey_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/fkey_c.cs @@ -1,854 +1,786 @@ using System; using System.Diagnostics; -using System.Text; -using Bitmask = System.UInt64; -using u8 = System.Byte; using u32 = System.UInt32; +using u8 = System.Byte; + +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** + ** 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 contains code used by the compiler to add foreign key + ** support to compiled SQL statements. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* */ + //#include "sqliteInt.h" -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* +#if !SQLITE_OMIT_FOREIGN_KEY +#if !SQLITE_OMIT_TRIGGER + + /* + ** Deferred and Immediate FKs + ** -------------------------- ** - ** The author disclaims copyright to this source code. In place of - ** a legal notice, here is a blessing: + ** Foreign keys in SQLite come in two flavours: deferred and immediate. + ** If an immediate foreign key constraint is violated, SQLITE_CONSTRAINT + ** is returned and the current statement transaction rolled back. If a + ** deferred foreign key constraint is violated, no action is taken + ** immediately. However if the application attempts to commit the + ** transaction before fixing the constraint violation, the attempt fails. ** - ** 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. + ** Deferred constraints are implemented using a simple counter associated + ** with the database handle. The counter is set to zero each time a + ** database transaction is opened. Each time a statement is executed + ** that causes a foreign key violation, the counter is incremented. Each + ** time a statement is executed that removes an existing violation from + ** the database, the counter is decremented. When the transaction is + ** committed, the commit fails if the current value of the counter is + ** greater than zero. This scheme has two big drawbacks: ** - ************************************************************************* - ** This file contains code used by the compiler to add foreign key - ** support to compiled SQL statements. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library + ** * When a commit fails due to a deferred foreign key constraint, + ** there is no way to tell which foreign constraint is not satisfied, + ** or which row it is not satisfied for. ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** * If the database contains foreign key violations when the + ** transaction is opened, this may cause the mechanism to malfunction. ** - ************************************************************************* */ - //#include "sqliteInt.h" - -#if !SQLITE_OMIT_FOREIGN_KEY -#if !SQLITE_OMIT_TRIGGER - - /* -** Deferred and Immediate FKs -** -------------------------- -** -** Foreign keys in SQLite come in two flavours: deferred and immediate. -** If an immediate foreign key constraint is violated, SQLITE_CONSTRAINT -** is returned and the current statement transaction rolled back. If a -** deferred foreign key constraint is violated, no action is taken -** immediately. However if the application attempts to commit the -** transaction before fixing the constraint violation, the attempt fails. -** -** Deferred constraints are implemented using a simple counter associated -** with the database handle. The counter is set to zero each time a -** database transaction is opened. Each time a statement is executed -** that causes a foreign key violation, the counter is incremented. Each -** time a statement is executed that removes an existing violation from -** the database, the counter is decremented. When the transaction is -** committed, the commit fails if the current value of the counter is -** greater than zero. This scheme has two big drawbacks: -** -** * When a commit fails due to a deferred foreign key constraint, -** there is no way to tell which foreign constraint is not satisfied, -** or which row it is not satisfied for. -** -** * If the database contains foreign key violations when the -** transaction is opened, this may cause the mechanism to malfunction. -** -** Despite these problems, this approach is adopted as it seems simpler -** than the alternatives. -** -** INSERT operations: -** -** I.1) For each FK for which the table is the child table, search -** the parent table for a match. If none is found increment the -** constraint counter. -** -** I.2) For each FK for which the table is the parent table, -** search the child table for rows that correspond to the new -** row in the parent table. Decrement the counter for each row -** found (as the constraint is now satisfied). -** -** DELETE operations: -** -** D.1) For each FK for which the table is the child table, -** search the parent table for a row that corresponds to the -** deleted row in the child table. If such a row is not found, -** decrement the counter. -** -** D.2) For each FK for which the table is the parent table, search -** the child table for rows that correspond to the deleted row -** in the parent table. For each found increment the counter. -** -** UPDATE operations: -** -** An UPDATE command requires that all 4 steps above are taken, but only -** for FK constraints for which the affected columns are actually -** modified (values must be compared at runtime). -** -** Note that I.1 and D.1 are very similar operations, as are I.2 and D.2. -** This simplifies the implementation a bit. -** -** For the purposes of immediate FK constraints, the OR REPLACE conflict -** resolution is considered to delete rows before the new row is inserted. -** If a delete caused by OR REPLACE violates an FK constraint, an exception -** is thrown, even if the FK constraint would be satisfied after the new -** row is inserted. -** -** Immediate constraints are usually handled similarly. The only difference -** is that the counter used is stored as part of each individual statement -** object (struct Vdbe). If, after the statement has run, its immediate -** constraint counter is greater than zero, it returns SQLITE_CONSTRAINT -** and the statement transaction is rolled back. An exception is an INSERT -** statement that inserts a single row only (no triggers). In this case, -** instead of using a counter, an exception is thrown immediately if the -** INSERT violates a foreign key constraint. This is necessary as such -** an INSERT does not open a statement transaction. -** -** TODO: How should dropping a table be handled? How should renaming a -** table be handled? -** -** -** Query API Notes -** --------------- -** -** Before coding an UPDATE or DELETE row operation, the code-generator -** for those two operations needs to know whether or not the operation -** requires any FK processing and, if so, which columns of the original -** row are required by the FK processing VDBE code (i.e. if FKs were -** implemented using triggers, which of the old.* columns would be -** accessed). No information is required by the code-generator before -** coding an INSERT operation. The functions used by the UPDATE/DELETE -** generation code to query for this information are: -** -** sqlite3FkRequired() - Test to see if FK processing is required. -** sqlite3FkOldmask() - Query for the set of required old.* columns. -** -** -** Externally accessible module functions -** -------------------------------------- -** -** sqlite3FkCheck() - Check for foreign key violations. -** sqlite3FkActions() - Code triggers for ON UPDATE/ON DELETE actions. -** sqlite3FkDelete() - Delete an FKey structure. -*/ - - /* - ** VDBE Calling Convention - ** ----------------------- + ** Despite these problems, this approach is adopted as it seems simpler + ** than the alternatives. ** - ** Example: + ** INSERT operations: ** - ** For the following INSERT statement: + ** I.1) For each FK for which the table is the child table, search + ** the parent table for a match. If none is found increment the + ** constraint counter. ** - ** CREATE TABLE t1(a, b INTEGER PRIMARY KEY, c); - ** INSERT INTO t1 VALUES(1, 2, 3.1); + ** I.2) For each FK for which the table is the parent table, + ** search the child table for rows that correspond to the new + ** row in the parent table. Decrement the counter for each row + ** found (as the constraint is now satisfied). ** - ** Register (x): 2 (type integer) - ** Register (x+1): 1 (type integer) - ** Register (x+2): NULL (type NULL) - ** Register (x+3): 3.1 (type real) - */ - - /* - ** A foreign key constraint requires that the key columns in the parent - ** table are collectively subject to a UNIQUE or PRIMARY KEY constraint. - ** Given that pParent is the parent table for foreign key constraint pFKey, - ** search the schema a unique index on the parent key columns. + ** DELETE operations: ** - ** If successful, zero is returned. If the parent key is an INTEGER PRIMARY - ** KEY column, then output variable *ppIdx is set to NULL. Otherwise, *ppIdx - ** is set to point to the unique index. - ** - ** If the parent key consists of a single column (the foreign key constraint - ** is not a composite foreign key), refput variable *paiCol is set to NULL. - ** Otherwise, it is set to point to an allocated array of size N, where - ** N is the number of columns in the parent key. The first element of the - ** array is the index of the child table column that is mapped by the FK - ** constraint to the parent table column stored in the left-most column - ** of index *ppIdx. The second element of the array is the index of the - ** child table column that corresponds to the second left-most column of - ** *ppIdx, and so on. + ** D.1) For each FK for which the table is the child table, + ** search the parent table for a row that corresponds to the + ** deleted row in the child table. If such a row is not found, + ** decrement the counter. ** - ** If the required index cannot be found, either because: + ** D.2) For each FK for which the table is the parent table, search + ** the child table for rows that correspond to the deleted row + ** in the parent table. For each found increment the counter. ** - ** 1) The named parent key columns do not exist, or + ** UPDATE operations: ** - ** 2) The named parent key columns do exist, but are not subject to a - ** UNIQUE or PRIMARY KEY constraint, or + ** An UPDATE command requires that all 4 steps above are taken, but only + ** for FK constraints for which the affected columns are actually + ** modified (values must be compared at runtime). ** - ** 3) No parent key columns were provided explicitly as part of the - ** foreign key definition, and the parent table does not have a - ** PRIMARY KEY, or + ** Note that I.1 and D.1 are very similar operations, as are I.2 and D.2. + ** This simplifies the implementation a bit. ** - ** 4) No parent key columns were provided explicitly as part of the - ** foreign key definition, and the PRIMARY KEY of the parent table - ** consists of a different number of columns to the child key in - ** the child table. + ** For the purposes of immediate FK constraints, the OR REPLACE conflict + ** resolution is considered to delete rows before the new row is inserted. + ** If a delete caused by OR REPLACE violates an FK constraint, an exception + ** is thrown, even if the FK constraint would be satisfied after the new + ** row is inserted. ** - ** then non-zero is returned, and a "foreign key mismatch" error loaded - ** into pParse. If an OOM error occurs, non-zero is returned and the - ** pParse.db.mallocFailed flag is set. - */ - static int locateFkeyIndex( - Parse pParse, /* Parse context to store any error in */ - Table pParent, /* Parent table of FK constraint pFKey */ - FKey pFKey, /* Foreign key to find index for */ - out Index ppIdx, /* OUT: Unique index on parent table */ - out int[] paiCol /* OUT: Map of index columns in pFKey */ - ) - { - Index pIdx = null; /* Value to return via *ppIdx */ - ppIdx = null; - int[] aiCol = null; /* Value to return via *paiCol */ - paiCol = null; - - int nCol = pFKey.nCol; /* Number of columns in parent key */ - string zKey = pFKey.aCol[0].zCol; /* Name of left-most parent key column */ - - /* The caller is responsible for zeroing output parameters. */ - //assert( ppIdx && *ppIdx==0 ); - //assert( !paiCol || *paiCol==0 ); - Debug.Assert( pParse != null ); - - /* If this is a non-composite (single column) foreign key, check if it - ** maps to the INTEGER PRIMARY KEY of table pParent. If so, leave *ppIdx - ** and *paiCol set to zero and return early. - ** - ** Otherwise, for a composite foreign key (more than one column), allocate - ** space for the aiCol array (returned via output parameter *paiCol). - ** Non-composite foreign keys do not require the aiCol array. - */ - if ( nCol == 1 ) - { - /* The FK maps to the IPK if any of the following are true: - ** - ** 1) There is an INTEGER PRIMARY KEY column and the FK is implicitly - ** mapped to the primary key of table pParent, or - ** 2) The FK is explicitly mapped to a column declared as INTEGER - ** PRIMARY KEY. - */ - if ( pParent.iPKey >= 0 ) - { - if ( null == zKey ) - return 0; - if ( pParent.aCol[pParent.iPKey].zName.Equals( zKey ,StringComparison.OrdinalIgnoreCase ) ) - return 0; - } - } - else //if( paiCol ){ - { - Debug.Assert( nCol > 1 ); - aiCol = new int[nCol];// (int*)sqlite3DbMallocRaw( pParse.db, nCol * sizeof( int ) ); - //if( !aiCol ) return 1; - paiCol = aiCol; - } - - for ( pIdx = pParent.pIndex; pIdx != null; pIdx = pIdx.pNext ) - { - if ( pIdx.nColumn == nCol && pIdx.onError != OE_None ) - { - /* pIdx is a UNIQUE index (or a PRIMARY KEY) and has the right number - ** of columns. If each indexed column corresponds to a foreign key - ** column of pFKey, then this index is a winner. */ - - if ( zKey == null ) - { - /* If zKey is NULL, then this foreign key is implicitly mapped to - ** the PRIMARY KEY of table pParent. The PRIMARY KEY index may be - ** identified by the test (Index.autoIndex==2). */ - if ( pIdx.autoIndex == 2 ) - { - if ( aiCol != null ) - { - int i; - for ( i = 0; i < nCol; i++ ) - aiCol[i] = pFKey.aCol[i].iFrom; - } - break; - } - } - else - { - /* If zKey is non-NULL, then this foreign key was declared to - ** map to an explicit list of columns in table pParent. Check if this - ** index matches those columns. Also, check that the index uses - ** the default collation sequences for each column. */ - int i, j; - for ( i = 0; i < nCol; i++ ) - { - int iCol = pIdx.aiColumn[i]; /* Index of column in parent tbl */ - string zDfltColl; /* Def. collation for column */ - string zIdxCol; /* Name of indexed column */ - - /* If the index uses a collation sequence that is different from - ** the default collation sequence for the column, this index is - ** unusable. Bail out early in this case. */ - zDfltColl = pParent.aCol[iCol].zColl; - if ( String.IsNullOrEmpty( zDfltColl ) ) - { - zDfltColl = "BINARY"; - } - if ( !pIdx.azColl[i].Equals( zDfltColl ,StringComparison.OrdinalIgnoreCase ) ) - break; - - zIdxCol = pParent.aCol[iCol].zName; - for ( j = 0; j < nCol; j++ ) - { - if ( pFKey.aCol[j].zCol.Equals( zIdxCol ,StringComparison.OrdinalIgnoreCase ) ) - { - if ( aiCol != null ) - aiCol[i] = pFKey.aCol[j].iFrom; - break; - } - } - if ( j == nCol ) - break; - } - if ( i == nCol ) - break; /* pIdx is usable */ - } - } - } - - if ( null == pIdx ) - { - if ( 0 == pParse.disableTriggers ) - { - sqlite3ErrorMsg( pParse, "foreign key mismatch" ); - } - sqlite3DbFree( pParse.db, ref aiCol ); - return 1; - } - - ppIdx = pIdx; - return 0; - } - - /* - ** This function is called when a row is inserted into or deleted from the - ** child table of foreign key constraint pFKey. If an SQL UPDATE is executed - ** on the child table of pFKey, this function is invoked twice for each row - ** affected - once to "delete" the old row, and then again to "insert" the - ** new row. + ** Immediate constraints are usually handled similarly. The only difference + ** is that the counter used is stored as part of each individual statement + ** object (struct Vdbe). If, after the statement has run, its immediate + ** constraint counter is greater than zero, it returns SQLITE_CONSTRAINT + ** and the statement transaction is rolled back. An exception is an INSERT + ** statement that inserts a single row only (no triggers). In this case, + ** instead of using a counter, an exception is thrown immediately if the + ** INSERT violates a foreign key constraint. This is necessary as such + ** an INSERT does not open a statement transaction. ** - ** Each time it is called, this function generates VDBE code to locate the - ** row in the parent table that corresponds to the row being inserted into - ** or deleted from the child table. If the parent row can be found, no - ** special action is taken. Otherwise, if the parent row can *not* be - ** found in the parent table: + ** TODO: How should dropping a table be handled? How should renaming a + ** table be handled? ** - ** Operation | FK type | Action taken - ** -------------------------------------------------------------------------- - ** INSERT immediate Increment the "immediate constraint counter". ** - ** DELETE immediate Decrement the "immediate constraint counter". + ** Query API Notes + ** --------------- ** - ** INSERT deferred Increment the "deferred constraint counter". + ** Before coding an UPDATE or DELETE row operation, the code-generator + ** for those two operations needs to know whether or not the operation + ** requires any FK processing and, if so, which columns of the original + ** row are required by the FK processing VDBE code (i.e. if FKs were + ** implemented using triggers, which of the old.* columns would be + ** accessed). No information is required by the code-generator before + ** coding an INSERT operation. The functions used by the UPDATE/DELETE + ** generation code to query for this information are: ** - ** DELETE deferred Decrement the "deferred constraint counter". + ** sqlite3FkRequired() - Test to see if FK processing is required. + ** sqlite3FkOldmask() - Query for the set of required old.* columns. ** - ** These operations are identified in the comment at the top of this file - ** (fkey.c) as "I.1" and "D.1". + ** + ** Externally accessible module functions + ** -------------------------------------- + ** + ** sqlite3FkCheck() - Check for foreign key violations. + ** sqlite3FkActions() - Code triggers for ON UPDATE/ON DELETE actions. + ** sqlite3FkDelete() - Delete an FKey structure. */ - static void fkLookupParent( - Parse pParse, /* Parse context */ - int iDb, /* Index of database housing pTab */ - Table pTab, /* Parent table of FK pFKey */ - Index pIdx, /* Unique index on parent key columns in pTab */ - FKey pFKey, /* Foreign key constraint */ - int[] aiCol, /* Map from parent key columns to child table columns */ - int regData, /* Address of array containing child table row */ - int nIncr, /* Increment constraint counter by this */ - int isIgnore /* If true, pretend pTab contains all NULL values */ - ) - { - int i; /* Iterator variable */ - Vdbe v = sqlite3GetVdbe( pParse ); /* Vdbe to add code to */ - int iCur = pParse.nTab - 1; /* Cursor number to use */ - int iOk = sqlite3VdbeMakeLabel( v ); /* jump here if parent key found */ - - /* If nIncr is less than zero, then check at runtime if there are any - ** outstanding constraints to resolve. If there are not, there is no need - ** to check if deleting this row resolves any outstanding violations. - ** - ** Check if any of the key columns in the child table row are NULL. If - ** any are, then the constraint is considered satisfied. No need to - ** search for a matching row in the parent table. */ - if ( nIncr < 0 ) - { - sqlite3VdbeAddOp2( v, OP_FkIfZero, pFKey.isDeferred, iOk ); - } - for ( i = 0; i < pFKey.nCol; i++ ) - { - int iReg = aiCol[i] + regData + 1; - sqlite3VdbeAddOp2( v, OP_IsNull, iReg, iOk ); - } - if ( isIgnore == 0 ) - { - if ( pIdx == null ) - { - /* If pIdx is NULL, then the parent key is the INTEGER PRIMARY KEY - ** column of the parent table (table pTab). */ - int iMustBeInt; /* Address of MustBeInt instruction */ - int regTemp = sqlite3GetTempReg( pParse ); - - /* Invoke MustBeInt to coerce the child key value to an integer (i.e. - ** apply the affinity of the parent key). If this fails, then there - ** is no matching parent key. Before using MustBeInt, make a copy of - ** the value. Otherwise, the value inserted into the child key column - ** will have INTEGER affinity applied to it, which may not be correct. */ - sqlite3VdbeAddOp2( v, OP_SCopy, aiCol[0] + 1 + regData, regTemp ); - iMustBeInt = sqlite3VdbeAddOp2( v, OP_MustBeInt, regTemp, 0 ); - - /* If the parent table is the same as the child table, and we are about - ** to increment the constraint-counter (i.e. this is an INSERT operation), - ** then check if the row being inserted matches itself. If so, do not - ** increment the constraint-counter. */ - if ( pTab == pFKey.pFrom && nIncr == 1 ) - { - sqlite3VdbeAddOp3( v, OP_Eq, regData, iOk, regTemp ); - } - - sqlite3OpenTable( pParse, iCur, iDb, pTab, OP_OpenRead ); - sqlite3VdbeAddOp3( v, OP_NotExists, iCur, 0, regTemp ); - sqlite3VdbeAddOp2( v, OP_Goto, 0, iOk ); - sqlite3VdbeJumpHere( v, sqlite3VdbeCurrentAddr( v ) - 2 ); - sqlite3VdbeJumpHere( v, iMustBeInt ); - sqlite3ReleaseTempReg( pParse, regTemp ); - } - else - { - int nCol = pFKey.nCol; - int regTemp = sqlite3GetTempRange( pParse, nCol ); - int regRec = sqlite3GetTempReg( pParse ); - KeyInfo pKey = sqlite3IndexKeyinfo( pParse, pIdx ); - - sqlite3VdbeAddOp3( v, OP_OpenRead, iCur, pIdx.tnum, iDb ); - sqlite3VdbeChangeP4( v, -1, pKey, P4_KEYINFO_HANDOFF ); - for ( i = 0; i < nCol; i++ ) - { - sqlite3VdbeAddOp2( v, OP_Copy, aiCol[i] + 1 + regData, regTemp + i ); - } - - /* If the parent table is the same as the child table, and we are about - ** to increment the constraint-counter (i.e. this is an INSERT operation), - ** then check if the row being inserted matches itself. If so, do not - ** increment the constraint-counter. - ** - ** If any of the parent-key values are NULL, then the row cannot match - ** itself. So set JUMPIFNULL to make sure we do the OP_Found if any - ** of the parent-key values are NULL (at this point it is known that - ** none of the child key values are). - */ - if ( pTab == pFKey.pFrom && nIncr == 1 ) - { - int iJump = sqlite3VdbeCurrentAddr( v ) + nCol + 1; - for ( i = 0; i < nCol; i++ ) - { - int iChild = aiCol[i] + 1 + regData; - int iParent = pIdx.aiColumn[i] + 1 + regData; - Debug.Assert( aiCol[i] != pTab.iPKey ); - if ( pIdx.aiColumn[i] == pTab.iPKey ) + /* + ** VDBE Calling Convention + ** ----------------------- + ** + ** Example: + ** + ** For the following INSERT statement: + ** + ** CREATE TABLE t1(a, b INTEGER PRIMARY KEY, c); + ** INSERT INTO t1 VALUES(1, 2, 3.1); + ** + ** Register (x): 2 (type integer) + ** Register (x+1): 1 (type integer) + ** Register (x+2): NULL (type NULL) + ** Register (x+3): 3.1 (type real) + */ + + /* + ** A foreign key constraint requires that the key columns in the parent + ** table are collectively subject to a UNIQUE or PRIMARY KEY constraint. + ** Given that pParent is the parent table for foreign key constraint pFKey, + ** search the schema a unique index on the parent key columns. + ** + ** If successful, zero is returned. If the parent key is an INTEGER PRIMARY + ** KEY column, then output variable *ppIdx is set to NULL. Otherwise, *ppIdx + ** is set to point to the unique index. + ** + ** If the parent key consists of a single column (the foreign key constraint + ** is not a composite foreign key), refput variable *paiCol is set to NULL. + ** Otherwise, it is set to point to an allocated array of size N, where + ** N is the number of columns in the parent key. The first element of the + ** array is the index of the child table column that is mapped by the FK + ** constraint to the parent table column stored in the left-most column + ** of index *ppIdx. The second element of the array is the index of the + ** child table column that corresponds to the second left-most column of + ** *ppIdx, and so on. + ** + ** If the required index cannot be found, either because: + ** + ** 1) The named parent key columns do not exist, or + ** + ** 2) The named parent key columns do exist, but are not subject to a + ** UNIQUE or PRIMARY KEY constraint, or + ** + ** 3) No parent key columns were provided explicitly as part of the + ** foreign key definition, and the parent table does not have a + ** PRIMARY KEY, or + ** + ** 4) No parent key columns were provided explicitly as part of the + ** foreign key definition, and the PRIMARY KEY of the parent table + ** consists of a different number of columns to the child key in + ** the child table. + ** + ** then non-zero is returned, and a "foreign key mismatch" error loaded + ** into pParse. If an OOM error occurs, non-zero is returned and the + ** pParse.db.mallocFailed flag is set. + */ + static int locateFkeyIndex( + Parse pParse, /* Parse context to store any error in */ + Table pParent, /* Parent table of FK constraint pFKey */ + FKey pFKey, /* Foreign key to find index for */ + out Index ppIdx, /* OUT: Unique index on parent table */ + out int[] paiCol /* OUT: Map of index columns in pFKey */ + ) { + Index pIdx = null; /* Value to return via *ppIdx */ + ppIdx = null; + int[] aiCol = null; /* Value to return via *paiCol */ + paiCol = null; + + int nCol = pFKey.nCol; /* Number of columns in parent key */ + string zKey = pFKey.aCol[0].zCol; /* Name of left-most parent key column */ + + /* The caller is responsible for zeroing output parameters. */ + //assert( ppIdx && *ppIdx==0 ); + //assert( !paiCol || *paiCol==0 ); + Debug.Assert(pParse != null); + + /* If this is a non-composite (single column) foreign key, check if it + ** maps to the INTEGER PRIMARY KEY of table pParent. If so, leave *ppIdx + ** and *paiCol set to zero and return early. + ** + ** Otherwise, for a composite foreign key (more than one column), allocate + ** space for the aiCol array (returned via output parameter *paiCol). + ** Non-composite foreign keys do not require the aiCol array. + */ + if (nCol == 1) { + /* The FK maps to the IPK if any of the following are true: + ** + ** 1) There is an INTEGER PRIMARY KEY column and the FK is implicitly + ** mapped to the primary key of table pParent, or + ** 2) The FK is explicitly mapped to a column declared as INTEGER + ** PRIMARY KEY. + */ + if (pParent.iPKey >= 0) { + if (null == zKey) + return 0; + if (pParent.aCol[pParent.iPKey].zName.Equals(zKey, StringComparison.OrdinalIgnoreCase)) + return 0; + } + } else //if( paiCol ){ { - /* The parent key is a composite key that includes the IPK column */ - iParent = regData; - } - sqlite3VdbeAddOp3( v, OP_Ne, iChild, iJump, iParent ); - sqlite3VdbeChangeP5( v, SQLITE_JUMPIFNULL ); + Debug.Assert(nCol > 1); + aiCol = new int[nCol];// (int*)sqlite3DbMallocRaw( pParse.db, nCol * sizeof( int ) ); + //if( !aiCol ) return 1; + paiCol = aiCol; } - sqlite3VdbeAddOp2( v, OP_Goto, 0, iOk ); - } - sqlite3VdbeAddOp3( v, OP_MakeRecord, regTemp, nCol, regRec ); - sqlite3VdbeChangeP4( v, -1, sqlite3IndexAffinityStr( v, pIdx ), P4_TRANSIENT ); - sqlite3VdbeAddOp4Int( v, OP_Found, iCur, iOk, regRec, 0 ); + for (pIdx = pParent.pIndex; pIdx != null; pIdx = pIdx.pNext) { + if (pIdx.nColumn == nCol && pIdx.onError != OE_None) { + /* pIdx is a UNIQUE index (or a PRIMARY KEY) and has the right number + ** of columns. If each indexed column corresponds to a foreign key + ** column of pFKey, then this index is a winner. */ + + if (zKey == null) { + /* If zKey is NULL, then this foreign key is implicitly mapped to + ** the PRIMARY KEY of table pParent. The PRIMARY KEY index may be + ** identified by the test (Index.autoIndex==2). */ + if (pIdx.autoIndex == 2) { + if (aiCol != null) { + int i; + for (i = 0; i < nCol; i++) + aiCol[i] = pFKey.aCol[i].iFrom; + } + break; + } + } else { + /* If zKey is non-NULL, then this foreign key was declared to + ** map to an explicit list of columns in table pParent. Check if this + ** index matches those columns. Also, check that the index uses + ** the default collation sequences for each column. */ + int i, j; + for (i = 0; i < nCol; i++) { + int iCol = pIdx.aiColumn[i]; /* Index of column in parent tbl */ + string zDfltColl; /* Def. collation for column */ + string zIdxCol; /* Name of indexed column */ + + /* If the index uses a collation sequence that is different from + ** the default collation sequence for the column, this index is + ** unusable. Bail out early in this case. */ + zDfltColl = pParent.aCol[iCol].zColl; + if (String.IsNullOrEmpty(zDfltColl)) { + zDfltColl = "BINARY"; + } + if (!pIdx.azColl[i].Equals(zDfltColl, StringComparison.OrdinalIgnoreCase)) + break; + + zIdxCol = pParent.aCol[iCol].zName; + for (j = 0; j < nCol; j++) { + if (pFKey.aCol[j].zCol.Equals(zIdxCol, StringComparison.OrdinalIgnoreCase)) { + if (aiCol != null) + aiCol[i] = pFKey.aCol[j].iFrom; + break; + } + } + if (j == nCol) + break; + } + if (i == nCol) + break; /* pIdx is usable */ + } + } + } - sqlite3ReleaseTempReg( pParse, regRec ); - sqlite3ReleaseTempRange( pParse, regTemp, nCol ); - } - } + if (null == pIdx) { + if (0 == pParse.disableTriggers) { + sqlite3ErrorMsg(pParse, "foreign key mismatch"); + } + sqlite3DbFree(pParse.db, ref aiCol); + return 1; + } - if ( 0 == pFKey.isDeferred && null == pParse.pToplevel && 0 == pParse.isMultiWrite ) - { - /* Special case: If this is an INSERT statement that will insert exactly - ** one row into the table, raise a constraint immediately instead of - ** incrementing a counter. This is necessary as the VM code is being - ** generated for will not open a statement transaction. */ - Debug.Assert( nIncr == 1 ); - sqlite3HaltConstraint( - pParse, OE_Abort, "foreign key constraint failed", P4_STATIC - ); - } - else - { - if ( nIncr > 0 && pFKey.isDeferred == 0 ) - { - sqlite3ParseToplevel( pParse ).mayAbort = 1; + ppIdx = pIdx; + return 0; } - sqlite3VdbeAddOp2( v, OP_FkCounter, pFKey.isDeferred, nIncr ); - } - sqlite3VdbeResolveLabel( v, iOk ); - sqlite3VdbeAddOp1( v, OP_Close, iCur ); - } + /* + ** This function is called when a row is inserted into or deleted from the + ** child table of foreign key constraint pFKey. If an SQL UPDATE is executed + ** on the child table of pFKey, this function is invoked twice for each row + ** affected - once to "delete" the old row, and then again to "insert" the + ** new row. + ** + ** Each time it is called, this function generates VDBE code to locate the + ** row in the parent table that corresponds to the row being inserted into + ** or deleted from the child table. If the parent row can be found, no + ** special action is taken. Otherwise, if the parent row can *not* be + ** found in the parent table: + ** + ** Operation | FK type | Action taken + ** -------------------------------------------------------------------------- + ** INSERT immediate Increment the "immediate constraint counter". + ** + ** DELETE immediate Decrement the "immediate constraint counter". + ** + ** INSERT deferred Increment the "deferred constraint counter". + ** + ** DELETE deferred Decrement the "deferred constraint counter". + ** + ** These operations are identified in the comment at the top of this file + ** (fkey.c) as "I.1" and "D.1". + */ + static void fkLookupParent( + Parse pParse, /* Parse context */ + int iDb, /* Index of database housing pTab */ + Table pTab, /* Parent table of FK pFKey */ + Index pIdx, /* Unique index on parent key columns in pTab */ + FKey pFKey, /* Foreign key constraint */ + int[] aiCol, /* Map from parent key columns to child table columns */ + int regData, /* Address of array containing child table row */ + int nIncr, /* Increment constraint counter by this */ + int isIgnore /* If true, pretend pTab contains all NULL values */ + ) { + int i; /* Iterator variable */ + Vdbe v = sqlite3GetVdbe(pParse); /* Vdbe to add code to */ + int iCur = pParse.nTab - 1; /* Cursor number to use */ + int iOk = sqlite3VdbeMakeLabel(v); /* jump here if parent key found */ + + /* If nIncr is less than zero, then check at runtime if there are any + ** outstanding constraints to resolve. If there are not, there is no need + ** to check if deleting this row resolves any outstanding violations. + ** + ** Check if any of the key columns in the child table row are NULL. If + ** any are, then the constraint is considered satisfied. No need to + ** search for a matching row in the parent table. */ + if (nIncr < 0) { + sqlite3VdbeAddOp2(v, OP_FkIfZero, pFKey.isDeferred, iOk); + } + for (i = 0; i < pFKey.nCol; i++) { + int iReg = aiCol[i] + regData + 1; + sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iOk); + } - /* - ** This function is called to generate code executed when a row is deleted - ** from the parent table of foreign key constraint pFKey and, if pFKey is - ** deferred, when a row is inserted into the same table. When generating - ** code for an SQL UPDATE operation, this function may be called twice - - ** once to "delete" the old row and once to "insert" the new row. - ** - ** The code generated by this function scans through the rows in the child - ** table that correspond to the parent table row being deleted or inserted. - ** For each child row found, one of the following actions is taken: - ** - ** Operation | FK type | Action taken - ** -------------------------------------------------------------------------- - ** DELETE immediate Increment the "immediate constraint counter". - ** Or, if the ON (UPDATE|DELETE) action is RESTRICT, - ** throw a "foreign key constraint failed" exception. - ** - ** INSERT immediate Decrement the "immediate constraint counter". - ** - ** DELETE deferred Increment the "deferred constraint counter". - ** Or, if the ON (UPDATE|DELETE) action is RESTRICT, - ** throw a "foreign key constraint failed" exception. - ** - ** INSERT deferred Decrement the "deferred constraint counter". - ** - ** These operations are identified in the comment at the top of this file - ** (fkey.c) as "I.2" and "D.2". - */ - static void fkScanChildren( - Parse pParse, /* Parse context */ - SrcList pSrc, /* SrcList containing the table to scan */ - Table pTab, - Index pIdx, /* Foreign key index */ - FKey pFKey, /* Foreign key relationship */ - int[] aiCol, /* Map from pIdx cols to child table cols */ - int regData, /* Referenced table data starts here */ - int nIncr /* Amount to increment deferred counter by */ - ) - { - sqlite3 db = pParse.db; /* Database handle */ - int i; /* Iterator variable */ - Expr pWhere = null; /* WHERE clause to scan with */ - NameContext sNameContext; /* Context used to resolve WHERE clause */ - WhereInfo pWInfo; /* Context used by sqlite3WhereXXX() */ - int iFkIfZero = 0; /* Address of OP_FkIfZero */ - Vdbe v = sqlite3GetVdbe( pParse ); - - Debug.Assert( null == pIdx || pIdx.pTable == pTab ); - - if ( nIncr < 0 ) - { - iFkIfZero = sqlite3VdbeAddOp2( v, OP_FkIfZero, pFKey.isDeferred, 0 ); - } + if (isIgnore == 0) { + if (pIdx == null) { + /* If pIdx is NULL, then the parent key is the INTEGER PRIMARY KEY + ** column of the parent table (table pTab). */ + int iMustBeInt; /* Address of MustBeInt instruction */ + int regTemp = sqlite3GetTempReg(pParse); + + /* Invoke MustBeInt to coerce the child key value to an integer (i.e. + ** apply the affinity of the parent key). If this fails, then there + ** is no matching parent key. Before using MustBeInt, make a copy of + ** the value. Otherwise, the value inserted into the child key column + ** will have INTEGER affinity applied to it, which may not be correct. */ + sqlite3VdbeAddOp2(v, OP_SCopy, aiCol[0] + 1 + regData, regTemp); + iMustBeInt = sqlite3VdbeAddOp2(v, OP_MustBeInt, regTemp, 0); + + /* If the parent table is the same as the child table, and we are about + ** to increment the constraint-counter (i.e. this is an INSERT operation), + ** then check if the row being inserted matches itself. If so, do not + ** increment the constraint-counter. */ + if (pTab == pFKey.pFrom && nIncr == 1) { + sqlite3VdbeAddOp3(v, OP_Eq, regData, iOk, regTemp); + } + + sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenRead); + sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regTemp); + sqlite3VdbeAddOp2(v, OP_Goto, 0, iOk); + sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v) - 2); + sqlite3VdbeJumpHere(v, iMustBeInt); + sqlite3ReleaseTempReg(pParse, regTemp); + } else { + int nCol = pFKey.nCol; + int regTemp = sqlite3GetTempRange(pParse, nCol); + int regRec = sqlite3GetTempReg(pParse); + KeyInfo pKey = sqlite3IndexKeyinfo(pParse, pIdx); + + sqlite3VdbeAddOp3(v, OP_OpenRead, iCur, pIdx.tnum, iDb); + sqlite3VdbeChangeP4(v, -1, pKey, P4_KEYINFO_HANDOFF); + for (i = 0; i < nCol; i++) { + sqlite3VdbeAddOp2(v, OP_Copy, aiCol[i] + 1 + regData, regTemp + i); + } + + /* If the parent table is the same as the child table, and we are about + ** to increment the constraint-counter (i.e. this is an INSERT operation), + ** then check if the row being inserted matches itself. If so, do not + ** increment the constraint-counter. + ** + ** If any of the parent-key values are NULL, then the row cannot match + ** itself. So set JUMPIFNULL to make sure we do the OP_Found if any + ** of the parent-key values are NULL (at this point it is known that + ** none of the child key values are). + */ + if (pTab == pFKey.pFrom && nIncr == 1) { + int iJump = sqlite3VdbeCurrentAddr(v) + nCol + 1; + for (i = 0; i < nCol; i++) { + int iChild = aiCol[i] + 1 + regData; + int iParent = pIdx.aiColumn[i] + 1 + regData; + Debug.Assert(aiCol[i] != pTab.iPKey); + if (pIdx.aiColumn[i] == pTab.iPKey) { + /* The parent key is a composite key that includes the IPK column */ + iParent = regData; + } + sqlite3VdbeAddOp3(v, OP_Ne, iChild, iJump, iParent); + sqlite3VdbeChangeP5(v, SQLITE_JUMPIFNULL); + } + sqlite3VdbeAddOp2(v, OP_Goto, 0, iOk); + } + + sqlite3VdbeAddOp3(v, OP_MakeRecord, regTemp, nCol, regRec); + sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), P4_TRANSIENT); + sqlite3VdbeAddOp4Int(v, OP_Found, iCur, iOk, regRec, 0); + + sqlite3ReleaseTempReg(pParse, regRec); + sqlite3ReleaseTempRange(pParse, regTemp, nCol); + } + } - /* Create an Expr object representing an SQL expression like: - ** - ** = AND = ... - ** - ** The collation sequence used for the comparison should be that of - ** the parent key columns. The affinity of the parent key column should - ** be applied to each child key value before the comparison takes place. - */ - for ( i = 0; i < pFKey.nCol; i++ ) - { - Expr pLeft; /* Value from parent table row */ - Expr pRight; /* Column ref to child table */ - Expr pEq; /* Expression (pLeft = pRight) */ - int iCol; /* Index of column in child table */ - string zCol; /* Name of column in child table */ - - pLeft = sqlite3Expr( db, TK_REGISTER, null ); - if ( pLeft != null ) - { - /* Set the collation sequence and affinity of the LHS of each TK_EQ - ** expression to the parent key column defaults. */ - if ( pIdx != null ) - { - Column pCol; - iCol = pIdx.aiColumn[i]; - pCol = pTab.aCol[iCol]; - if ( pTab.iPKey == iCol ) - iCol = -1; - pLeft.iTable = regData + iCol + 1; - pLeft.affinity = pCol.affinity; - pLeft.pColl = sqlite3LocateCollSeq( pParse, pCol.zColl ); - } - else - { - pLeft.iTable = regData; - pLeft.affinity = SQLITE_AFF_INTEGER; - } - } - iCol = aiCol != null ? aiCol[i] : pFKey.aCol[0].iFrom; - Debug.Assert( iCol >= 0 ); - zCol = pFKey.pFrom.aCol[iCol].zName; - pRight = sqlite3Expr( db, TK_ID, zCol ); - pEq = sqlite3PExpr( pParse, TK_EQ, pLeft, pRight, 0 ); - pWhere = sqlite3ExprAnd( db, pWhere, pEq ); - } + if (0 == pFKey.isDeferred && null == pParse.pToplevel && 0 == pParse.isMultiWrite) { + /* Special case: If this is an INSERT statement that will insert exactly + ** one row into the table, raise a constraint immediately instead of + ** incrementing a counter. This is necessary as the VM code is being + ** generated for will not open a statement transaction. */ + Debug.Assert(nIncr == 1); + sqlite3HaltConstraint( + pParse, OE_Abort, "foreign key constraint failed", P4_STATIC + ); + } else { + if (nIncr > 0 && pFKey.isDeferred == 0) { + sqlite3ParseToplevel(pParse).mayAbort = 1; + } + sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey.isDeferred, nIncr); + } - /* If the child table is the same as the parent table, and this scan - ** is taking place as part of a DELETE operation (operation D.2), omit the - ** row being deleted from the scan by adding ($rowid != rowid) to the WHERE - ** clause, where $rowid is the rowid of the row being deleted. */ - if ( pTab == pFKey.pFrom && nIncr > 0 ) - { - Expr pEq; /* Expression (pLeft = pRight) */ - Expr pLeft; /* Value from parent table row */ - Expr pRight; /* Column ref to child table */ - pLeft = sqlite3Expr( db, TK_REGISTER, null ); - pRight = sqlite3Expr( db, TK_COLUMN, null ); - if ( pLeft != null && pRight != null ) - { - pLeft.iTable = regData; - pLeft.affinity = SQLITE_AFF_INTEGER; - pRight.iTable = pSrc.a[0].iCursor; - pRight.iColumn = -1; + sqlite3VdbeResolveLabel(v, iOk); + sqlite3VdbeAddOp1(v, OP_Close, iCur); } - pEq = sqlite3PExpr( pParse, TK_NE, pLeft, pRight, 0 ); - pWhere = sqlite3ExprAnd( db, pWhere, pEq ); - } - /* Resolve the references in the WHERE clause. */ - sNameContext = new NameContext();// memset( &sNameContext, 0, sizeof( NameContext ) ); - sNameContext.pSrcList = pSrc; - sNameContext.pParse = pParse; - sqlite3ResolveExprNames( sNameContext, ref pWhere ); - - /* Create VDBE to loop through the entries in pSrc that match the WHERE - ** clause. If the constraint is not deferred, throw an exception for - ** each row found. Otherwise, for deferred constraints, increment the - ** deferred constraint counter by nIncr for each row selected. */ - ExprList elDummy = null; - pWInfo = sqlite3WhereBegin( pParse, pSrc, pWhere, ref elDummy, 0 ); - if ( nIncr > 0 && pFKey.isDeferred == 0 ) - { - sqlite3ParseToplevel( pParse ).mayAbort = 1; - } - sqlite3VdbeAddOp2( v, OP_FkCounter, pFKey.isDeferred, nIncr ); - if ( pWInfo != null ) - { - sqlite3WhereEnd( pWInfo ); - } + /* + ** This function is called to generate code executed when a row is deleted + ** from the parent table of foreign key constraint pFKey and, if pFKey is + ** deferred, when a row is inserted into the same table. When generating + ** code for an SQL UPDATE operation, this function may be called twice - + ** once to "delete" the old row and once to "insert" the new row. + ** + ** The code generated by this function scans through the rows in the child + ** table that correspond to the parent table row being deleted or inserted. + ** For each child row found, one of the following actions is taken: + ** + ** Operation | FK type | Action taken + ** -------------------------------------------------------------------------- + ** DELETE immediate Increment the "immediate constraint counter". + ** Or, if the ON (UPDATE|DELETE) action is RESTRICT, + ** throw a "foreign key constraint failed" exception. + ** + ** INSERT immediate Decrement the "immediate constraint counter". + ** + ** DELETE deferred Increment the "deferred constraint counter". + ** Or, if the ON (UPDATE|DELETE) action is RESTRICT, + ** throw a "foreign key constraint failed" exception. + ** + ** INSERT deferred Decrement the "deferred constraint counter". + ** + ** These operations are identified in the comment at the top of this file + ** (fkey.c) as "I.2" and "D.2". + */ + static void fkScanChildren( + Parse pParse, /* Parse context */ + SrcList pSrc, /* SrcList containing the table to scan */ + Table pTab, + Index pIdx, /* Foreign key index */ + FKey pFKey, /* Foreign key relationship */ + int[] aiCol, /* Map from pIdx cols to child table cols */ + int regData, /* Referenced table data starts here */ + int nIncr /* Amount to increment deferred counter by */ + ) { + sqlite3 db = pParse.db; /* Database handle */ + int i; /* Iterator variable */ + Expr pWhere = null; /* WHERE clause to scan with */ + NameContext sNameContext; /* Context used to resolve WHERE clause */ + WhereInfo pWInfo; /* Context used by sqlite3WhereXXX() */ + int iFkIfZero = 0; /* Address of OP_FkIfZero */ + Vdbe v = sqlite3GetVdbe(pParse); + + Debug.Assert(null == pIdx || pIdx.pTable == pTab); + + if (nIncr < 0) { + iFkIfZero = sqlite3VdbeAddOp2(v, OP_FkIfZero, pFKey.isDeferred, 0); + } - /* Clean up the WHERE clause constructed above. */ - sqlite3ExprDelete( db, ref pWhere ); - if ( iFkIfZero != 0 ) - { - sqlite3VdbeJumpHere( v, iFkIfZero ); - } - } + /* Create an Expr object representing an SQL expression like: + ** + ** = AND = ... + ** + ** The collation sequence used for the comparison should be that of + ** the parent key columns. The affinity of the parent key column should + ** be applied to each child key value before the comparison takes place. + */ + for (i = 0; i < pFKey.nCol; i++) { + Expr pLeft; /* Value from parent table row */ + Expr pRight; /* Column ref to child table */ + Expr pEq; /* Expression (pLeft = pRight) */ + int iCol; /* Index of column in child table */ + string zCol; /* Name of column in child table */ + + pLeft = sqlite3Expr(db, TK_REGISTER, null); + if (pLeft != null) { + /* Set the collation sequence and affinity of the LHS of each TK_EQ + ** expression to the parent key column defaults. */ + if (pIdx != null) { + Column pCol; + iCol = pIdx.aiColumn[i]; + pCol = pTab.aCol[iCol]; + if (pTab.iPKey == iCol) + iCol = -1; + pLeft.iTable = regData + iCol + 1; + pLeft.affinity = pCol.affinity; + pLeft.pColl = sqlite3LocateCollSeq(pParse, pCol.zColl); + } else { + pLeft.iTable = regData; + pLeft.affinity = SQLITE_AFF_INTEGER; + } + } + iCol = aiCol != null ? aiCol[i] : pFKey.aCol[0].iFrom; + Debug.Assert(iCol >= 0); + zCol = pFKey.pFrom.aCol[iCol].zName; + pRight = sqlite3Expr(db, TK_ID, zCol); + pEq = sqlite3PExpr(pParse, TK_EQ, pLeft, pRight, 0); + pWhere = sqlite3ExprAnd(db, pWhere, pEq); + } - /* - ** This function returns a pointer to the head of a linked list of FK - ** constraints for which table pTab is the parent table. For example, - ** given the following schema: - ** - ** CREATE TABLE t1(a PRIMARY KEY); - ** CREATE TABLE t2(b REFERENCES t1(a); - ** - ** Calling this function with table "t1" as an argument returns a pointer - ** to the FKey structure representing the foreign key constraint on table - ** "t2". Calling this function with "t2" as the argument would return a - ** NULL pointer (as there are no FK constraints for which t2 is the parent - ** table). - */ - static FKey sqlite3FkReferences( Table pTab ) - { - int nName = sqlite3Strlen30( pTab.zName ); - return sqlite3HashFind( pTab.pSchema.fkeyHash, pTab.zName, nName, (FKey)null ); - } + /* If the child table is the same as the parent table, and this scan + ** is taking place as part of a DELETE operation (operation D.2), omit the + ** row being deleted from the scan by adding ($rowid != rowid) to the WHERE + ** clause, where $rowid is the rowid of the row being deleted. */ + if (pTab == pFKey.pFrom && nIncr > 0) { + Expr pEq; /* Expression (pLeft = pRight) */ + Expr pLeft; /* Value from parent table row */ + Expr pRight; /* Column ref to child table */ + pLeft = sqlite3Expr(db, TK_REGISTER, null); + pRight = sqlite3Expr(db, TK_COLUMN, null); + if (pLeft != null && pRight != null) { + pLeft.iTable = regData; + pLeft.affinity = SQLITE_AFF_INTEGER; + pRight.iTable = pSrc.a[0].iCursor; + pRight.iColumn = -1; + } + pEq = sqlite3PExpr(pParse, TK_NE, pLeft, pRight, 0); + pWhere = sqlite3ExprAnd(db, pWhere, pEq); + } - /* - ** The second argument is a Trigger structure allocated by the - ** fkActionTrigger() routine. This function deletes the Trigger structure - ** and all of its sub-components. - ** - ** The Trigger structure or any of its sub-components may be allocated from - ** the lookaside buffer belonging to database handle dbMem. - */ - static void fkTriggerDelete( sqlite3 dbMem, Trigger p ) - { - if ( p != null ) - { - TriggerStep pStep = p.step_list; - sqlite3ExprDelete( dbMem, ref pStep.pWhere ); - sqlite3ExprListDelete( dbMem, ref pStep.pExprList ); - sqlite3SelectDelete( dbMem, ref pStep.pSelect ); - sqlite3ExprDelete( dbMem, ref p.pWhen ); - sqlite3DbFree( dbMem, ref p ); - } - } + /* Resolve the references in the WHERE clause. */ + sNameContext = new NameContext();// memset( &sNameContext, 0, sizeof( NameContext ) ); + sNameContext.pSrcList = pSrc; + sNameContext.pParse = pParse; + sqlite3ResolveExprNames(sNameContext, ref pWhere); + + /* Create VDBE to loop through the entries in pSrc that match the WHERE + ** clause. If the constraint is not deferred, throw an exception for + ** each row found. Otherwise, for deferred constraints, increment the + ** deferred constraint counter by nIncr for each row selected. */ + ExprList elDummy = null; + pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, ref elDummy, 0); + if (nIncr > 0 && pFKey.isDeferred == 0) { + sqlite3ParseToplevel(pParse).mayAbort = 1; + } + sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey.isDeferred, nIncr); + if (pWInfo != null) { + sqlite3WhereEnd(pWInfo); + } - /* - ** This function is called to generate code that runs when table pTab is - ** being dropped from the database. The SrcList passed as the second argument - ** to this function contains a single entry guaranteed to resolve to - ** table pTab. - ** - ** Normally, no code is required. However, if either - ** - ** (a) The table is the parent table of a FK constraint, or - ** (b) The table is the child table of a deferred FK constraint and it is - ** determined at runtime that there are outstanding deferred FK - ** constraint violations in the database, - ** - ** then the equivalent of "DELETE FROM " is executed before dropping - ** the table from the database. Triggers are disabled while running this - ** DELETE, but foreign key actions are not. - */ - static void sqlite3FkDropTable( Parse pParse, SrcList pName, Table pTab ) - { - sqlite3 db = pParse.db; - if ( ( db.flags & SQLITE_ForeignKeys ) != 0 && !IsVirtual( pTab ) && null == pTab.pSelect ) - { - int iSkip = 0; - Vdbe v = sqlite3GetVdbe( pParse ); - - Debug.Assert( v != null ); /* VDBE has already been allocated */ - if ( sqlite3FkReferences( pTab ) == null ) - { - /* Search for a deferred foreign key constraint for which this table - ** is the child table. If one cannot be found, return without - ** 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 != null; p = p.pNextFrom ) - { - if ( p.isDeferred != 0 ) - break; - } - if ( null == p ) - return; - iSkip = sqlite3VdbeMakeLabel( v ); - sqlite3VdbeAddOp2( v, OP_FkIfZero, 1, iSkip ); + /* Clean up the WHERE clause constructed above. */ + sqlite3ExprDelete(db, ref pWhere); + if (iFkIfZero != 0) { + sqlite3VdbeJumpHere(v, iFkIfZero); + } } - pParse.disableTriggers = 1; - sqlite3DeleteFrom( pParse, sqlite3SrcListDup( db, pName, 0 ), null ); - 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. */ - sqlite3VdbeAddOp2( v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr( v ) + 2 ); - sqlite3HaltConstraint( - pParse, OE_Abort, "foreign key constraint failed", P4_STATIC - ); - - if ( iSkip != 0 ) - { - sqlite3VdbeResolveLabel( v, iSkip ); + /* + ** This function returns a pointer to the head of a linked list of FK + ** constraints for which table pTab is the parent table. For example, + ** given the following schema: + ** + ** CREATE TABLE t1(a PRIMARY KEY); + ** CREATE TABLE t2(b REFERENCES t1(a); + ** + ** Calling this function with table "t1" as an argument returns a pointer + ** to the FKey structure representing the foreign key constraint on table + ** "t2". Calling this function with "t2" as the argument would return a + ** NULL pointer (as there are no FK constraints for which t2 is the parent + ** table). + */ + static FKey sqlite3FkReferences(Table pTab) { + int nName = sqlite3Strlen30(pTab.zName); + return sqlite3HashFind(pTab.pSchema.fkeyHash, pTab.zName, nName, (FKey)null); } - } - } - /* - ** This function is called when inserting, deleting or updating a row of - ** table pTab to generate VDBE code to perform foreign key constraint - ** processing for the operation. - ** - ** For a DELETE operation, parameter regOld is passed the index of the - ** first register in an array of (pTab.nCol+1) registers containing the - ** rowid of the row being deleted, followed by each of the column values - ** of the row being deleted, from left to right. Parameter regNew is passed - ** zero in this case. - ** - ** For an INSERT operation, regOld is passed zero and regNew is passed the - ** first register of an array of (pTab.nCol+1) registers containing the new - ** row data. - ** - ** For an UPDATE operation, this function is called twice. Once before - ** the original record is deleted from the table using the calling convention - ** described for DELETE. Then again after the original record is deleted - ** but before the new record is inserted using the INSERT convention. - */ - static void sqlite3FkCheck( - Parse pParse, /* Parse context */ - Table pTab, /* Row is being deleted from this table */ - int regOld, /* Previous row data is stored here */ - int regNew /* New row data is stored here */ - ) - { - sqlite3 db = pParse.db; /* Database handle */ - FKey pFKey; /* Used to iterate through FKs */ - int iDb; /* Index of database containing pTab */ - string zDb; /* Name of database containing pTab */ - int isIgnoreErrors = pParse.disableTriggers; - - /* Exactly one of regOld and regNew should be non-zero. */ - Debug.Assert( ( regOld == 0 ) != ( regNew == 0 ) ); - - /* If foreign-keys are disabled, this function is a no-op. */ - if ( ( db.flags & SQLITE_ForeignKeys ) == 0 ) - return; - - iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); - zDb = db.aDb[iDb].zName; - - /* Loop through all the foreign key constraints for which pTab is the - ** child table (the table that the foreign key definition is part of). */ - for ( pFKey = pTab.pFKey; pFKey != null; pFKey = pFKey.pNextFrom ) - { - Table pTo; /* Parent table of foreign key pFKey */ - Index pIdx = null; /* Index on key columns in pTo */ - int[] aiFree = null; - int[] aiCol; - int iCol; - int i; - int isIgnore = 0; - - /* Find the parent table of this foreign key. Also find a unique index - ** on the parent key columns in the parent table. If either of these - ** schema items cannot be located, set an error in pParse and return - ** early. */ - if ( pParse.disableTriggers != 0 ) - { - pTo = sqlite3FindTable( db, pFKey.zTo, zDb ); - } - else - { - pTo = sqlite3LocateTable( pParse, 0, pFKey.zTo, zDb ); - } - if ( null == pTo || locateFkeyIndex( pParse, pTo, pFKey, out pIdx, out aiFree ) != 0 ) - { - if ( 0 == isIgnoreErrors /* || db.mallocFailed */) - return; - continue; + /* + ** The second argument is a Trigger structure allocated by the + ** fkActionTrigger() routine. This function deletes the Trigger structure + ** and all of its sub-components. + ** + ** The Trigger structure or any of its sub-components may be allocated from + ** the lookaside buffer belonging to database handle dbMem. + */ + static void fkTriggerDelete(sqlite3 dbMem, Trigger p) { + if (p != null) { + TriggerStep pStep = p.step_list; + sqlite3ExprDelete(dbMem, ref pStep.pWhere); + sqlite3ExprListDelete(dbMem, ref pStep.pExprList); + sqlite3SelectDelete(dbMem, ref pStep.pSelect); + sqlite3ExprDelete(dbMem, ref p.pWhen); + sqlite3DbFree(dbMem, ref p); + } } - Debug.Assert( pFKey.nCol == 1 || ( aiFree != null && pIdx != null ) ); - if ( aiFree != null ) - { - aiCol = aiFree; - } - else - { - iCol = pFKey.aCol[0].iFrom; - aiCol = new int[1]; - aiCol[0] = iCol; + /* + ** This function is called to generate code that runs when table pTab is + ** being dropped from the database. The SrcList passed as the second argument + ** to this function contains a single entry guaranteed to resolve to + ** table pTab. + ** + ** Normally, no code is required. However, if either + ** + ** (a) The table is the parent table of a FK constraint, or + ** (b) The table is the child table of a deferred FK constraint and it is + ** determined at runtime that there are outstanding deferred FK + ** constraint violations in the database, + ** + ** then the equivalent of "DELETE FROM " is executed before dropping + ** the table from the database. Triggers are disabled while running this + ** DELETE, but foreign key actions are not. + */ + static void sqlite3FkDropTable(Parse pParse, SrcList pName, Table pTab) { + sqlite3 db = pParse.db; + if ((db.flags & SQLITE_ForeignKeys) != 0 && !IsVirtual(pTab) && null == pTab.pSelect) { + int iSkip = 0; + Vdbe v = sqlite3GetVdbe(pParse); + + Debug.Assert(v != null); /* VDBE has already been allocated */ + if (sqlite3FkReferences(pTab) == null) { + /* Search for a deferred foreign key constraint for which this table + ** is the child table. If one cannot be found, return without + ** 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 != null; p = p.pNextFrom) { + if (p.isDeferred != 0) + break; + } + if (null == p) + return; + iSkip = sqlite3VdbeMakeLabel(v); + sqlite3VdbeAddOp2(v, OP_FkIfZero, 1, iSkip); + } + + pParse.disableTriggers = 1; + sqlite3DeleteFrom(pParse, sqlite3SrcListDup(db, pName, 0), null); + 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. */ + sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v) + 2); + sqlite3HaltConstraint( + pParse, OE_Abort, "foreign key constraint failed", P4_STATIC + ); + + if (iSkip != 0) { + sqlite3VdbeResolveLabel(v, iSkip); + } + } } - for ( i = 0; i < pFKey.nCol; i++ ) - { - if ( aiCol[i] == pTab.iPKey ) - { - aiCol[i] = -1; - } + + /* + ** This function is called when inserting, deleting or updating a row of + ** table pTab to generate VDBE code to perform foreign key constraint + ** processing for the operation. + ** + ** For a DELETE operation, parameter regOld is passed the index of the + ** first register in an array of (pTab.nCol+1) registers containing the + ** rowid of the row being deleted, followed by each of the column values + ** of the row being deleted, from left to right. Parameter regNew is passed + ** zero in this case. + ** + ** For an INSERT operation, regOld is passed zero and regNew is passed the + ** first register of an array of (pTab.nCol+1) registers containing the new + ** row data. + ** + ** For an UPDATE operation, this function is called twice. Once before + ** the original record is deleted from the table using the calling convention + ** described for DELETE. Then again after the original record is deleted + ** but before the new record is inserted using the INSERT convention. + */ + static void sqlite3FkCheck( + Parse pParse, /* Parse context */ + Table pTab, /* Row is being deleted from this table */ + int regOld, /* Previous row data is stored here */ + int regNew /* New row data is stored here */ + ) { + sqlite3 db = pParse.db; /* Database handle */ + FKey pFKey; /* Used to iterate through FKs */ + int iDb; /* Index of database containing pTab */ + string zDb; /* Name of database containing pTab */ + int isIgnoreErrors = pParse.disableTriggers; + + /* Exactly one of regOld and regNew should be non-zero. */ + Debug.Assert((regOld == 0) != (regNew == 0)); + + /* If foreign-keys are disabled, this function is a no-op. */ + if ((db.flags & SQLITE_ForeignKeys) == 0) + return; + + iDb = sqlite3SchemaToIndex(db, pTab.pSchema); + zDb = db.aDb[iDb].zName; + + /* Loop through all the foreign key constraints for which pTab is the + ** child table (the table that the foreign key definition is part of). */ + for (pFKey = pTab.pFKey; pFKey != null; pFKey = pFKey.pNextFrom) { + Table pTo; /* Parent table of foreign key pFKey */ + Index pIdx = null; /* Index on key columns in pTo */ + int[] aiFree = null; + int[] aiCol; + int iCol; + int i; + int isIgnore = 0; + + /* Find the parent table of this foreign key. Also find a unique index + ** on the parent key columns in the parent table. If either of these + ** schema items cannot be located, set an error in pParse and return + ** early. */ + if (pParse.disableTriggers != 0) { + pTo = sqlite3FindTable(db, pFKey.zTo, zDb); + } else { + pTo = sqlite3LocateTable(pParse, 0, pFKey.zTo, zDb); + } + if (null == pTo || locateFkeyIndex(pParse, pTo, pFKey, out pIdx, out aiFree) != 0) { + if (0 == isIgnoreErrors /* || db.mallocFailed */) + return; + continue; + } + Debug.Assert(pFKey.nCol == 1 || (aiFree != null && pIdx != null)); + + if (aiFree != null) { + aiCol = aiFree; + } else { + iCol = pFKey.aCol[0].iFrom; + aiCol = new int[1]; + aiCol[0] = iCol; + } + for (i = 0; i < pFKey.nCol; i++) { + if (aiCol[i] == pTab.iPKey) { + aiCol[i] = -1; + } #if !SQLITE_OMIT_AUTHORIZATION /* Request permission to read the parent key columns. If the ** authorization callback returns SQLITE_IGNORE, behave as if any @@ -860,516 +792,463 @@ int regNew /* New row data is stored here */ isIgnore = (rcauth==SQLITE_IGNORE); } #endif - } + } - /* Take a shared-cache advisory read-lock on the parent table. Allocate - ** a cursor to use to search the unique index on the parent key columns - ** in the parent table. */ - sqlite3TableLock( pParse, iDb, pTo.tnum, 0, pTo.zName ); - pParse.nTab++; - - if ( regOld != 0 ) - { - /* A row is being removed from the child table. Search for the parent. - ** If the parent does not exist, removing the child row resolves an - ** outstanding foreign key constraint violation. */ - fkLookupParent( pParse, iDb, pTo, pIdx, pFKey, aiCol, regOld, -1, isIgnore ); - } - if ( regNew != 0 ) - { - /* A row is being added to the child table. If a parent row cannot - ** be found, adding the child row has violated the FK constraint. */ - fkLookupParent( pParse, iDb, pTo, pIdx, pFKey, aiCol, regNew, +1, isIgnore ); - } + /* Take a shared-cache advisory read-lock on the parent table. Allocate + ** a cursor to use to search the unique index on the parent key columns + ** in the parent table. */ + sqlite3TableLock(pParse, iDb, pTo.tnum, 0, pTo.zName); + pParse.nTab++; + + if (regOld != 0) { + /* A row is being removed from the child table. Search for the parent. + ** If the parent does not exist, removing the child row resolves an + ** outstanding foreign key constraint violation. */ + fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regOld, -1, isIgnore); + } + if (regNew != 0) { + /* A row is being added to the child table. If a parent row cannot + ** be found, adding the child row has violated the FK constraint. */ + fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regNew, +1, isIgnore); + } - sqlite3DbFree( db, ref aiFree ); - } + sqlite3DbFree(db, ref aiFree); + } - /* Loop through all the foreign key constraints that refer to this table */ - for ( pFKey = sqlite3FkReferences( pTab ); pFKey != null; pFKey = pFKey.pNextTo ) - { - Index pIdx = null; /* Foreign key index for pFKey */ - SrcList pSrc; - int[] aiCol = null; - - if ( 0 == pFKey.isDeferred && null == pParse.pToplevel && 0 == pParse.isMultiWrite ) - { - Debug.Assert( regOld == 0 && regNew != 0 ); - /* Inserting a single row into a parent table cannot cause an immediate - ** foreign key violation. So do nothing in this case. */ - continue; - } + /* Loop through all the foreign key constraints that refer to this table */ + for (pFKey = sqlite3FkReferences(pTab); pFKey != null; pFKey = pFKey.pNextTo) { + Index pIdx = null; /* Foreign key index for pFKey */ + SrcList pSrc; + int[] aiCol = null; + + if (0 == pFKey.isDeferred && null == pParse.pToplevel && 0 == pParse.isMultiWrite) { + Debug.Assert(regOld == 0 && regNew != 0); + /* Inserting a single row into a parent table cannot cause an immediate + ** foreign key violation. So do nothing in this case. */ + continue; + } - if ( locateFkeyIndex( pParse, pTab, pFKey, out pIdx, out aiCol ) != 0 ) - { - if ( 0 == isIgnoreErrors /*|| db.mallocFailed */) - return; - continue; - } - Debug.Assert( aiCol != null || pFKey.nCol == 1 ); - - /* Create a SrcList structure containing a single table (the table - ** the foreign key that refers to this table is attached to). This - ** is required for the sqlite3WhereXXX() interface. */ - pSrc = sqlite3SrcListAppend( db, 0, null, null ); - if ( pSrc != null ) - { - SrcList_item pItem = pSrc.a[0]; - pItem.pTab = pFKey.pFrom; - pItem.zName = pFKey.pFrom.zName; - pItem.pTab.nRef++; - pItem.iCursor = pParse.nTab++; - - if ( regNew != 0 ) - { - fkScanChildren( pParse, pSrc, pTab, pIdx, pFKey, aiCol, regNew, -1 ); - } - if ( regOld != 0 ) - { - /* If there is a RESTRICT action configured for the current operation - ** on the parent table of this FK, then throw an exception - ** immediately if the FK constraint is violated, even if this is a - ** deferred trigger. That's what RESTRICT means. To defer checking - ** the constraint, the FK should specify NO ACTION (represented - ** using OE_None). NO ACTION is the default. */ - fkScanChildren( pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1 ); - } - pItem.zName = null; - sqlite3SrcListDelete( db, ref pSrc ); + if (locateFkeyIndex(pParse, pTab, pFKey, out pIdx, out aiCol) != 0) { + if (0 == isIgnoreErrors /*|| db.mallocFailed */) + return; + continue; + } + Debug.Assert(aiCol != null || pFKey.nCol == 1); + + /* Create a SrcList structure containing a single table (the table + ** the foreign key that refers to this table is attached to). This + ** is required for the sqlite3WhereXXX() interface. */ + pSrc = sqlite3SrcListAppend(db, 0, null, null); + if (pSrc != null) { + SrcList_item pItem = pSrc.a[0]; + pItem.pTab = pFKey.pFrom; + pItem.zName = pFKey.pFrom.zName; + pItem.pTab.nRef++; + pItem.iCursor = pParse.nTab++; + + if (regNew != 0) { + fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regNew, -1); + } + if (regOld != 0) { + /* If there is a RESTRICT action configured for the current operation + ** on the parent table of this FK, then throw an exception + ** immediately if the FK constraint is violated, even if this is a + ** deferred trigger. That's what RESTRICT means. To defer checking + ** the constraint, the FK should specify NO ACTION (represented + ** using OE_None). NO ACTION is the default. */ + fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1); + } + pItem.zName = null; + sqlite3SrcListDelete(db, ref pSrc); + } + sqlite3DbFree(db, ref aiCol); + } } - sqlite3DbFree( db, ref aiCol ); - } - } - - //#define COLUMN_MASK(x) (((x)>31) ? 0xffffffff : ((u32)1<<(x))) - static uint COLUMN_MASK( int x ) - { - return ( ( x ) > 31 ) ? 0xffffffff : ( (u32)1 << ( x ) ); - } - /* - ** This function is called before generating code to update or delete a - ** row contained in table pTab. - */ - static u32 sqlite3FkOldmask( - Parse pParse, /* Parse context */ - Table pTab /* Table being modified */ - ) - { - u32 mask = 0; - if ( ( pParse.db.flags & SQLITE_ForeignKeys ) != 0 ) - { - FKey p; - int i; - for ( p = pTab.pFKey; p != null; p = p.pNextFrom ) - { - for ( i = 0; i < p.nCol; i++ ) - mask |= COLUMN_MASK( p.aCol[i].iFrom ); - } - for ( p = sqlite3FkReferences( pTab ); p != null; p = p.pNextTo ) - { - Index pIdx; - int[] iDummy; - locateFkeyIndex( pParse, pTab, p, out pIdx, out iDummy ); - if ( pIdx != null ) - { - for ( i = 0; i < pIdx.nColumn; i++ ) - mask |= COLUMN_MASK( pIdx.aiColumn[i] ); - } + //#define COLUMN_MASK(x) (((x)>31) ? 0xffffffff : ((u32)1<<(x))) + static uint COLUMN_MASK(int x) { + return ((x) > 31) ? 0xffffffff : ((u32)1 << (x)); } - } - return mask; - } - /* - ** This function is called before generating code to update or delete a - ** row contained in table pTab. If the operation is a DELETE, then - ** parameter aChange is passed a NULL value. For an UPDATE, aChange points - ** to an array of size N, where N is the number of columns in table pTab. - ** If the i'th column is not modified by the UPDATE, then the corresponding - ** entry in the aChange[] array is set to -1. If the column is modified, - ** the value is 0 or greater. Parameter chngRowid is set to true if the - ** UPDATE statement modifies the rowid fields of the table. - ** - ** If any foreign key processing will be required, this function returns - ** true. If there is no foreign key related processing, this function - ** returns false. - */ - static int sqlite3FkRequired( - Parse pParse, /* Parse context */ - Table pTab, /* Table being modified */ - int[] aChange, /* Non-NULL for UPDATE operations */ - int chngRowid /* True for UPDATE that affects rowid */ - ) - { - if ( ( pParse.db.flags & SQLITE_ForeignKeys ) != 0 ) - { - if ( null == aChange ) - { - /* A DELETE operation. Foreign key processing is required if the - ** table in question is either the child or parent table for any - ** foreign key constraint. */ - return ( sqlite3FkReferences( pTab ) != null || pTab.pFKey != null ) ? 1 : 0; - } - else - { - /* This is an UPDATE. Foreign key processing is only required if the - ** operation modifies one or more child or parent key columns. */ - int i; - FKey p; - - /* Check if any child key columns are being modified. */ - for ( p = pTab.pFKey; p != null; p = p.pNextFrom ) - { - for ( i = 0; i < p.nCol; i++ ) - { - int iChildKey = p.aCol[i].iFrom; - if ( aChange[iChildKey] >= 0 ) - return 1; - if ( iChildKey == pTab.iPKey && chngRowid != 0 ) - return 1; - } - } - - /* Check if any parent key columns are being modified. */ - for ( p = sqlite3FkReferences( pTab ); p != null; p = p.pNextTo ) - { - for ( i = 0; i < p.nCol; i++ ) - { - string zKey = p.aCol[i].zCol; - int iKey; - for ( iKey = 0; iKey < pTab.nCol; iKey++ ) - { - Column pCol = pTab.aCol[iKey]; - if ( ( !String.IsNullOrEmpty( zKey ) ? pCol.zName.Equals( zKey, StringComparison.OrdinalIgnoreCase ) : pCol.isPrimKey != 0 ) ) - { - if ( aChange[iKey] >= 0 ) - return 1; - if ( iKey == pTab.iPKey && chngRowid != 0 ) - return 1; + /* + ** This function is called before generating code to update or delete a + ** row contained in table pTab. + */ + static u32 sqlite3FkOldmask( + Parse pParse, /* Parse context */ + Table pTab /* Table being modified */ + ) { + u32 mask = 0; + if ((pParse.db.flags & SQLITE_ForeignKeys) != 0) { + FKey p; + int i; + for (p = pTab.pFKey; p != null; p = p.pNextFrom) { + for (i = 0; i < p.nCol; i++) + mask |= COLUMN_MASK(p.aCol[i].iFrom); + } + for (p = sqlite3FkReferences(pTab); p != null; p = p.pNextTo) { + Index pIdx; + int[] iDummy; + locateFkeyIndex(pParse, pTab, p, out pIdx, out iDummy); + if (pIdx != null) { + for (i = 0; i < pIdx.nColumn; i++) + mask |= COLUMN_MASK(pIdx.aiColumn[i]); + } } - } } - } + return mask; } - } - return 0; - } - /* - ** This function is called when an UPDATE or DELETE operation is being - ** compiled on table pTab, which is the parent table of foreign-key pFKey. - ** If the current operation is an UPDATE, then the pChanges parameter is - ** passed a pointer to the list of columns being modified. If it is a - ** DELETE, pChanges is passed a NULL pointer. - ** - ** It returns a pointer to a Trigger structure containing a trigger - ** equivalent to the ON UPDATE or ON DELETE action specified by pFKey. - ** If the action is "NO ACTION" or "RESTRICT", then a NULL pointer is - ** returned (these actions require no special handling by the triggers - ** sub-system, code for them is created by fkScanChildren()). - ** - ** For example, if pFKey is the foreign key and pTab is table "p" in - ** the following schema: - ** - ** CREATE TABLE p(pk PRIMARY KEY); - ** CREATE TABLE c(ck REFERENCES p ON DELETE CASCADE); - ** - ** then the returned trigger structure is equivalent to: - ** - ** CREATE TRIGGER ... DELETE ON p BEGIN - ** DELETE FROM c WHERE ck = old.pk; - ** END; - ** - ** The returned pointer is cached as part of the foreign key object. It - ** is eventually freed along with the rest of the foreign key object by - ** sqlite3FkDelete(). - */ - static Trigger fkActionTrigger( - Parse pParse, /* Parse context */ - Table pTab, /* Table being updated or deleted from */ - FKey pFKey, /* Foreign key to get action for */ - ExprList pChanges /* Change-list for UPDATE, NULL for DELETE */ - ) - { - sqlite3 db = pParse.db; /* Database handle */ - int action; /* One of OE_None, OE_Cascade etc. */ - Trigger pTrigger; /* Trigger definition to return */ - int iAction = ( pChanges != null ) ? 1 : 0; /* 1 for UPDATE, 0 for DELETE */ - - action = pFKey.aAction[iAction]; - pTrigger = pFKey.apTrigger[iAction]; - - if ( action != OE_None && null == pTrigger ) - { - u8 enableLookaside; /* Copy of db.lookaside.bEnabled */ - string zFrom; /* Name of child table */ - int nFrom; /* Length in bytes of zFrom */ - Index pIdx = null; /* Parent key index for this FK */ - int[] aiCol = null; /* child table cols . parent key cols */ - TriggerStep pStep = null; /* First (only) step of trigger program */ - Expr pWhere = null; /* WHERE clause of trigger step */ - ExprList pList = null; /* Changes list if ON UPDATE CASCADE */ - Select pSelect = null; /* If RESTRICT, "SELECT RAISE(...)" */ - int i; /* Iterator variable */ - Expr pWhen = null; /* WHEN clause for the trigger */ - - if ( locateFkeyIndex( pParse, pTab, pFKey, out pIdx, out aiCol ) != 0 ) - return null; - Debug.Assert( aiCol != null || pFKey.nCol == 1 ); - - for ( i = 0; i < pFKey.nCol; i++ ) - { - Token tOld = new Token( "old", 3 ); /* Literal "old" token */ - Token tNew = new Token( "new", 3 ); /* Literal "new" token */ - Token tFromCol = new Token(); /* Name of column in child table */ - Token tToCol = new Token(); /* Name of column in parent table */ - int iFromCol; /* Idx of column in child table */ - Expr pEq; /* tFromCol = OLD.tToCol */ - - iFromCol = aiCol != null ? aiCol[i] : pFKey.aCol[0].iFrom; - Debug.Assert( iFromCol >= 0 ); - tToCol.z = pIdx != null ? pTab.aCol[pIdx.aiColumn[i]].zName : "oid"; - tFromCol.z = pFKey.pFrom.aCol[iFromCol].zName; - - tToCol.n = sqlite3Strlen30( tToCol.z ); - tFromCol.n = sqlite3Strlen30( tFromCol.z ); - - /* Create the expression "OLD.zToCol = zFromCol". It is important - ** that the "OLD.zToCol" term is on the LHS of the = operator, so - ** that the affinity and collation sequence associated with the - ** parent table are used for the comparison. */ - pEq = sqlite3PExpr( pParse, TK_EQ, - sqlite3PExpr( pParse, TK_DOT, - sqlite3PExpr( pParse, TK_ID, null, null, tOld ), - sqlite3PExpr( pParse, TK_ID, null, null, tToCol ) - , 0 ), - sqlite3PExpr( pParse, TK_ID, null, null, tFromCol ) - , 0 ); - pWhere = sqlite3ExprAnd( db, pWhere, pEq ); - - /* For ON UPDATE, construct the next term of the WHEN clause. - ** The final WHEN clause will be like this: - ** - ** WHEN NOT(old.col1 IS new.col1 AND ... AND old.colN IS new.colN) - */ - if ( pChanges != null ) - { - pEq = sqlite3PExpr( pParse, TK_IS, - sqlite3PExpr( pParse, TK_DOT, - sqlite3PExpr( pParse, TK_ID, null, null, tOld ), - sqlite3PExpr( pParse, TK_ID, null, null, tToCol ), - 0 ), - sqlite3PExpr( pParse, TK_DOT, - sqlite3PExpr( pParse, TK_ID, null, null, tNew ), - sqlite3PExpr( pParse, TK_ID, null, null, tToCol ), - 0 ), - 0 ); - pWhen = sqlite3ExprAnd( db, pWhen, pEq ); - } - - if ( action != OE_Restrict && ( action != OE_Cascade || pChanges != null ) ) - { - Expr pNew; - if ( action == OE_Cascade ) - { - pNew = sqlite3PExpr( pParse, TK_DOT, - sqlite3PExpr( pParse, TK_ID, null, null, tNew ), - sqlite3PExpr( pParse, TK_ID, null, null, tToCol ) - , 0 ); - } - else if ( action == OE_SetDflt ) - { - Expr pDflt = pFKey.pFrom.aCol[iFromCol].pDflt; - if ( pDflt != null ) - { - pNew = sqlite3ExprDup( db, pDflt, 0 ); - } - else - { - pNew = sqlite3PExpr( pParse, TK_NULL, 0, 0, 0 ); - } - } - else - { - pNew = sqlite3PExpr( pParse, TK_NULL, 0, 0, 0 ); + /* + ** This function is called before generating code to update or delete a + ** row contained in table pTab. If the operation is a DELETE, then + ** parameter aChange is passed a NULL value. For an UPDATE, aChange points + ** to an array of size N, where N is the number of columns in table pTab. + ** If the i'th column is not modified by the UPDATE, then the corresponding + ** entry in the aChange[] array is set to -1. If the column is modified, + ** the value is 0 or greater. Parameter chngRowid is set to true if the + ** UPDATE statement modifies the rowid fields of the table. + ** + ** If any foreign key processing will be required, this function returns + ** true. If there is no foreign key related processing, this function + ** returns false. + */ + static int sqlite3FkRequired( + Parse pParse, /* Parse context */ + Table pTab, /* Table being modified */ + int[] aChange, /* Non-NULL for UPDATE operations */ + int chngRowid /* True for UPDATE that affects rowid */ + ) { + if ((pParse.db.flags & SQLITE_ForeignKeys) != 0) { + if (null == aChange) { + /* A DELETE operation. Foreign key processing is required if the + ** table in question is either the child or parent table for any + ** foreign key constraint. */ + return (sqlite3FkReferences(pTab) != null || pTab.pFKey != null) ? 1 : 0; + } else { + /* This is an UPDATE. Foreign key processing is only required if the + ** operation modifies one or more child or parent key columns. */ + int i; + FKey p; + + /* Check if any child key columns are being modified. */ + for (p = pTab.pFKey; p != null; p = p.pNextFrom) { + for (i = 0; i < p.nCol; i++) { + int iChildKey = p.aCol[i].iFrom; + if (aChange[iChildKey] >= 0) + return 1; + if (iChildKey == pTab.iPKey && chngRowid != 0) + return 1; + } + } + + /* Check if any parent key columns are being modified. */ + for (p = sqlite3FkReferences(pTab); p != null; p = p.pNextTo) { + for (i = 0; i < p.nCol; i++) { + string zKey = p.aCol[i].zCol; + int iKey; + for (iKey = 0; iKey < pTab.nCol; iKey++) { + Column pCol = pTab.aCol[iKey]; + if ((!String.IsNullOrEmpty(zKey) ? pCol.zName.Equals(zKey, StringComparison.OrdinalIgnoreCase) : pCol.isPrimKey != 0)) { + if (aChange[iKey] >= 0) + return 1; + if (iKey == pTab.iPKey && chngRowid != 0) + return 1; + } + } + } + } + } } - pList = sqlite3ExprListAppend( pParse, pList, pNew ); - sqlite3ExprListSetName( pParse, pList, tFromCol, 0 ); - } - } - sqlite3DbFree( db, ref aiCol ); - - zFrom = pFKey.pFrom.zName; - nFrom = sqlite3Strlen30( zFrom ); - - if ( action == OE_Restrict ) - { - Token tFrom = new Token(); - Expr pRaise; - - tFrom.z = zFrom; - tFrom.n = nFrom; - pRaise = sqlite3Expr( db, TK_RAISE, "foreign key constraint failed" ); - if ( pRaise != null ) - { - pRaise.affinity = (char)OE_Abort; - } - pSelect = sqlite3SelectNew( pParse, - sqlite3ExprListAppend( pParse, 0, pRaise ), - sqlite3SrcListAppend( db, 0, tFrom, null ), - pWhere, - null, null, null, 0, null, null - ); - pWhere = null; + return 0; } - /* Disable lookaside memory allocation */ - enableLookaside = db.lookaside.bEnabled; - db.lookaside.bEnabled = 0; - - pTrigger = new Trigger(); - //(Trigger*)sqlite3DbMallocZero( db, - // sizeof( Trigger ) + /* struct Trigger */ - // sizeof( TriggerStep ) + /* Single step in trigger program */ - // nFrom + 1 /* Space for pStep.target.z */ - // ); - //if ( pTrigger ) - { - - pStep = pTrigger.step_list = new TriggerStep();// = (TriggerStep)pTrigger[1]; - //pStep.target.z = pStep[1]; - pStep.target.n = nFrom; - pStep.target.z = zFrom;// memcpy( (char*)pStep.target.z, zFrom, nFrom ); - - pStep.pWhere = sqlite3ExprDup( db, pWhere, EXPRDUP_REDUCE ); - pStep.pExprList = sqlite3ExprListDup( db, pList, EXPRDUP_REDUCE ); - pStep.pSelect = sqlite3SelectDup( db, pSelect, EXPRDUP_REDUCE ); - if ( pWhen != null ) - { - pWhen = sqlite3PExpr( pParse, TK_NOT, pWhen, 0, 0 ); - pTrigger.pWhen = sqlite3ExprDup( db, pWhen, EXPRDUP_REDUCE ); - } + /* + ** This function is called when an UPDATE or DELETE operation is being + ** compiled on table pTab, which is the parent table of foreign-key pFKey. + ** If the current operation is an UPDATE, then the pChanges parameter is + ** passed a pointer to the list of columns being modified. If it is a + ** DELETE, pChanges is passed a NULL pointer. + ** + ** It returns a pointer to a Trigger structure containing a trigger + ** equivalent to the ON UPDATE or ON DELETE action specified by pFKey. + ** If the action is "NO ACTION" or "RESTRICT", then a NULL pointer is + ** returned (these actions require no special handling by the triggers + ** sub-system, code for them is created by fkScanChildren()). + ** + ** For example, if pFKey is the foreign key and pTab is table "p" in + ** the following schema: + ** + ** CREATE TABLE p(pk PRIMARY KEY); + ** CREATE TABLE c(ck REFERENCES p ON DELETE CASCADE); + ** + ** then the returned trigger structure is equivalent to: + ** + ** CREATE TRIGGER ... DELETE ON p BEGIN + ** DELETE FROM c WHERE ck = old.pk; + ** END; + ** + ** The returned pointer is cached as part of the foreign key object. It + ** is eventually freed along with the rest of the foreign key object by + ** sqlite3FkDelete(). + */ + static Trigger fkActionTrigger( + Parse pParse, /* Parse context */ + Table pTab, /* Table being updated or deleted from */ + FKey pFKey, /* Foreign key to get action for */ + ExprList pChanges /* Change-list for UPDATE, NULL for DELETE */ + ) { + sqlite3 db = pParse.db; /* Database handle */ + int action; /* One of OE_None, OE_Cascade etc. */ + Trigger pTrigger; /* Trigger definition to return */ + int iAction = (pChanges != null) ? 1 : 0; /* 1 for UPDATE, 0 for DELETE */ + + action = pFKey.aAction[iAction]; + pTrigger = pFKey.apTrigger[iAction]; + + if (action != OE_None && null == pTrigger) { + u8 enableLookaside; /* Copy of db.lookaside.bEnabled */ + string zFrom; /* Name of child table */ + int nFrom; /* Length in bytes of zFrom */ + Index pIdx = null; /* Parent key index for this FK */ + int[] aiCol = null; /* child table cols . parent key cols */ + TriggerStep pStep = null; /* First (only) step of trigger program */ + Expr pWhere = null; /* WHERE clause of trigger step */ + ExprList pList = null; /* Changes list if ON UPDATE CASCADE */ + Select pSelect = null; /* If RESTRICT, "SELECT RAISE(...)" */ + int i; /* Iterator variable */ + Expr pWhen = null; /* WHEN clause for the trigger */ + + if (locateFkeyIndex(pParse, pTab, pFKey, out pIdx, out aiCol) != 0) + return null; + Debug.Assert(aiCol != null || pFKey.nCol == 1); + + for (i = 0; i < pFKey.nCol; i++) { + Token tOld = new Token("old", 3); /* Literal "old" token */ + Token tNew = new Token("new", 3); /* Literal "new" token */ + Token tFromCol = new Token(); /* Name of column in child table */ + Token tToCol = new Token(); /* Name of column in parent table */ + int iFromCol; /* Idx of column in child table */ + Expr pEq; /* tFromCol = OLD.tToCol */ + + iFromCol = aiCol != null ? aiCol[i] : pFKey.aCol[0].iFrom; + Debug.Assert(iFromCol >= 0); + tToCol.z = pIdx != null ? pTab.aCol[pIdx.aiColumn[i]].zName : "oid"; + tFromCol.z = pFKey.pFrom.aCol[iFromCol].zName; + + tToCol.n = sqlite3Strlen30(tToCol.z); + tFromCol.n = sqlite3Strlen30(tFromCol.z); + + /* Create the expression "OLD.zToCol = zFromCol". It is important + ** that the "OLD.zToCol" term is on the LHS of the = operator, so + ** that the affinity and collation sequence associated with the + ** parent table are used for the comparison. */ + pEq = sqlite3PExpr(pParse, TK_EQ, + sqlite3PExpr(pParse, TK_DOT, + sqlite3PExpr(pParse, TK_ID, null, null, tOld), + sqlite3PExpr(pParse, TK_ID, null, null, tToCol) + , 0), + sqlite3PExpr(pParse, TK_ID, null, null, tFromCol) + , 0); + pWhere = sqlite3ExprAnd(db, pWhere, pEq); + + /* For ON UPDATE, construct the next term of the WHEN clause. + ** The final WHEN clause will be like this: + ** + ** WHEN NOT(old.col1 IS new.col1 AND ... AND old.colN IS new.colN) + */ + if (pChanges != null) { + pEq = sqlite3PExpr(pParse, TK_IS, + sqlite3PExpr(pParse, TK_DOT, + sqlite3PExpr(pParse, TK_ID, null, null, tOld), + sqlite3PExpr(pParse, TK_ID, null, null, tToCol), + 0), + sqlite3PExpr(pParse, TK_DOT, + sqlite3PExpr(pParse, TK_ID, null, null, tNew), + sqlite3PExpr(pParse, TK_ID, null, null, tToCol), + 0), + 0); + pWhen = sqlite3ExprAnd(db, pWhen, pEq); + } + + if (action != OE_Restrict && (action != OE_Cascade || pChanges != null)) { + Expr pNew; + if (action == OE_Cascade) { + pNew = sqlite3PExpr(pParse, TK_DOT, + sqlite3PExpr(pParse, TK_ID, null, null, tNew), + sqlite3PExpr(pParse, TK_ID, null, null, tToCol) + , 0); + } else if (action == OE_SetDflt) { + Expr pDflt = pFKey.pFrom.aCol[iFromCol].pDflt; + if (pDflt != null) { + pNew = sqlite3ExprDup(db, pDflt, 0); + } else { + pNew = sqlite3PExpr(pParse, TK_NULL, 0, 0, 0); + } + } else { + pNew = sqlite3PExpr(pParse, TK_NULL, 0, 0, 0); + } + pList = sqlite3ExprListAppend(pParse, pList, pNew); + sqlite3ExprListSetName(pParse, pList, tFromCol, 0); + } + } + sqlite3DbFree(db, ref aiCol); + + zFrom = pFKey.pFrom.zName; + nFrom = sqlite3Strlen30(zFrom); + + if (action == OE_Restrict) { + Token tFrom = new Token(); + Expr pRaise; + + tFrom.z = zFrom; + tFrom.n = nFrom; + pRaise = sqlite3Expr(db, TK_RAISE, "foreign key constraint failed"); + if (pRaise != null) { + pRaise.affinity = (char)OE_Abort; + } + pSelect = sqlite3SelectNew(pParse, + sqlite3ExprListAppend(pParse, 0, pRaise), + sqlite3SrcListAppend(db, 0, tFrom, null), + pWhere, + null, null, null, 0, null, null + ); + pWhere = null; + } + + /* Disable lookaside memory allocation */ + enableLookaside = db.lookaside.bEnabled; + db.lookaside.bEnabled = 0; + + pTrigger = new Trigger(); + //(Trigger*)sqlite3DbMallocZero( db, + // sizeof( Trigger ) + /* struct Trigger */ + // sizeof( TriggerStep ) + /* Single step in trigger program */ + // nFrom + 1 /* Space for pStep.target.z */ + // ); + //if ( pTrigger ) + { + + pStep = pTrigger.step_list = new TriggerStep();// = (TriggerStep)pTrigger[1]; + //pStep.target.z = pStep[1]; + pStep.target.n = nFrom; + pStep.target.z = zFrom;// memcpy( (char*)pStep.target.z, zFrom, nFrom ); + + pStep.pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE); + pStep.pExprList = sqlite3ExprListDup(db, pList, EXPRDUP_REDUCE); + pStep.pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE); + if (pWhen != null) { + pWhen = sqlite3PExpr(pParse, TK_NOT, pWhen, 0, 0); + pTrigger.pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE); + } + } + + /* Re-enable the lookaside buffer, if it was disabled earlier. */ + db.lookaside.bEnabled = enableLookaside; + + sqlite3ExprDelete(db, ref pWhere); + sqlite3ExprDelete(db, ref pWhen); + sqlite3ExprListDelete(db, ref pList); + sqlite3SelectDelete(db, ref pSelect); + //if ( db.mallocFailed == 1 ) + //{ + // fkTriggerDelete( db, pTrigger ); + // return 0; + //} + + switch (action) { + case OE_Restrict: + pStep.op = TK_SELECT; + break; + case OE_Cascade: + if (null == pChanges) { + pStep.op = TK_DELETE; + break; + } + goto default; + default: + pStep.op = TK_UPDATE; + break; + } + pStep.pTrig = pTrigger; + pTrigger.pSchema = pTab.pSchema; + pTrigger.pTabSchema = pTab.pSchema; + pFKey.apTrigger[iAction] = pTrigger; + pTrigger.op = (byte)(pChanges != null ? TK_UPDATE : TK_DELETE); + } + + return pTrigger; } - /* Re-enable the lookaside buffer, if it was disabled earlier. */ - db.lookaside.bEnabled = enableLookaside; - - sqlite3ExprDelete( db, ref pWhere ); - sqlite3ExprDelete( db, ref pWhen ); - sqlite3ExprListDelete( db, ref pList ); - sqlite3SelectDelete( db, ref pSelect ); - //if ( db.mallocFailed == 1 ) - //{ - // fkTriggerDelete( db, pTrigger ); - // return 0; - //} - - switch ( action ) - { - case OE_Restrict: - pStep.op = TK_SELECT; - break; - case OE_Cascade: - if ( null == pChanges ) - { - pStep.op = TK_DELETE; - break; + /* + ** This function is called when deleting or updating a row to implement + ** any required CASCADE, SET NULL or SET DEFAULT actions. + */ + static void sqlite3FkActions( + Parse pParse, /* Parse context */ + Table pTab, /* Table being updated or deleted from */ + ExprList pChanges, /* Change-list for UPDATE, NULL for DELETE */ + int regOld /* Address of array containing old row */ + ) { + /* If foreign-key support is enabled, iterate through all FKs that + ** refer to table pTab. If there is an action a6ssociated with the FK + ** for this operation (either update or delete), invoke the associated + ** trigger sub-program. */ + if ((pParse.db.flags & SQLITE_ForeignKeys) != 0) { + FKey pFKey; /* Iterator variable */ + for (pFKey = sqlite3FkReferences(pTab); pFKey != null; pFKey = pFKey.pNextTo) { + Trigger pAction = fkActionTrigger(pParse, pTab, pFKey, pChanges); + if (pAction != null) { + sqlite3CodeRowTriggerDirect(pParse, pAction, pTab, regOld, OE_Abort, 0); + } + } } - goto default; - default: - pStep.op = TK_UPDATE; - break; } - pStep.pTrig = pTrigger; - pTrigger.pSchema = pTab.pSchema; - pTrigger.pTabSchema = pTab.pSchema; - pFKey.apTrigger[iAction] = pTrigger; - pTrigger.op = (byte)( pChanges != null ? TK_UPDATE : TK_DELETE ); - } - return pTrigger; - } +#endif //* ifndef SQLITE_OMIT_TRIGGER */ - /* - ** This function is called when deleting or updating a row to implement - ** any required CASCADE, SET NULL or SET DEFAULT actions. + /* + ** Free all memory associated with foreign key definitions attached to + ** table pTab. Remove the deleted foreign keys from the Schema.fkeyHash + ** hash table. */ - static void sqlite3FkActions( - Parse pParse, /* Parse context */ - Table pTab, /* Table being updated or deleted from */ - ExprList pChanges, /* Change-list for UPDATE, NULL for DELETE */ - int regOld /* Address of array containing old row */ - ) - { - /* If foreign-key support is enabled, iterate through all FKs that - ** refer to table pTab. If there is an action a6ssociated with the FK - ** for this operation (either update or delete), invoke the associated - ** trigger sub-program. */ - if ( ( pParse.db.flags & SQLITE_ForeignKeys ) != 0 ) - { - FKey pFKey; /* Iterator variable */ - for ( pFKey = sqlite3FkReferences( pTab ); pFKey != null; pFKey = pFKey.pNextTo ) - { - Trigger pAction = fkActionTrigger( pParse, pTab, pFKey, pChanges ); - if ( pAction != null ) - { - sqlite3CodeRowTriggerDirect( pParse, pAction, pTab, regOld, OE_Abort, 0 ); - } - } - } - } + static void sqlite3FkDelete(sqlite3 db, Table pTab) { + FKey pFKey; /* Iterator variable */ + FKey pNext; /* Copy of pFKey.pNextFrom */ -#endif //* ifndef SQLITE_OMIT_TRIGGER */ + Debug.Assert(db == null || sqlite3SchemaMutexHeld(db, 0, pTab.pSchema)); + for (pFKey = pTab.pFKey; pFKey != null; pFKey = pNext) { - /* -** Free all memory associated with foreign key definitions attached to -** table pTab. Remove the deleted foreign keys from the Schema.fkeyHash -** hash table. -*/ - static void sqlite3FkDelete( sqlite3 db, Table pTab ) - { - FKey pFKey; /* Iterator variable */ - FKey pNext; /* Copy of pFKey.pNextFrom */ - - Debug.Assert( db == null || sqlite3SchemaMutexHeld( db, 0, pTab.pSchema ) ); - for ( pFKey = pTab.pFKey; pFKey != null; pFKey = pNext ) - { - - /* Remove the FK from the fkeyHash hash table. */ - //if ( null == db || db.pnBytesFreed == 0 ) - { - if ( pFKey.pPrevTo != null ) - { - pFKey.pPrevTo.pNextTo = pFKey.pNextTo; - } - else - { - FKey p = pFKey.pNextTo; - string z = ( p != null ? pFKey.pNextTo.zTo : pFKey.zTo ); - sqlite3HashInsert( ref pTab.pSchema.fkeyHash, z, sqlite3Strlen30( z ), p ); - } - if ( pFKey.pNextTo != null ) - { - pFKey.pNextTo.pPrevTo = pFKey.pPrevTo; - } - } + /* Remove the FK from the fkeyHash hash table. */ + //if ( null == db || db.pnBytesFreed == 0 ) + { + if (pFKey.pPrevTo != null) { + pFKey.pPrevTo.pNextTo = pFKey.pNextTo; + } else { + FKey p = pFKey.pNextTo; + string z = (p != null ? pFKey.pNextTo.zTo : pFKey.zTo); + sqlite3HashInsert(ref pTab.pSchema.fkeyHash, z, sqlite3Strlen30(z), p); + } + if (pFKey.pNextTo != null) { + pFKey.pNextTo.pPrevTo = pFKey.pPrevTo; + } + } - /* EV: R-30323-21917 Each foreign key constraint in SQLite is - ** classified as either immediate or deferred. - */ - Debug.Assert( pFKey.isDeferred == 0 || pFKey.isDeferred == 1 ); + /* EV: R-30323-21917 Each foreign key constraint in SQLite is + ** classified as either immediate or deferred. + */ + Debug.Assert(pFKey.isDeferred == 0 || pFKey.isDeferred == 1); - /* Delete any triggers created to implement actions for this FK. */ + /* Delete any triggers created to implement actions for this FK. */ #if !SQLITE_OMIT_TRIGGER - fkTriggerDelete( db, pFKey.apTrigger[0] ); - fkTriggerDelete( db, pFKey.apTrigger[1] ); + fkTriggerDelete(db, pFKey.apTrigger[0]); + fkTriggerDelete(db, pFKey.apTrigger[1]); #endif - pNext = pFKey.pNextFrom; - sqlite3DbFree( db, ref pFKey ); - } - } + pNext = pFKey.pNextFrom; + sqlite3DbFree(db, ref pFKey); + } + } #endif //* ifndef SQLITE_OMIT_FOREIGN_KEY */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/func_c.cs b/Src/IronPython.SQLite/c#sqlite/func_c.cs index bc4097cda..a55142321 100644 --- a/Src/IronPython.SQLite/c#sqlite/func_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/func_c.cs @@ -2,507 +2,449 @@ using System.Diagnostics; using System.Text; -using sqlite3_int64 = System.Int64; using i64 = System.Int64; -using u8 = System.Byte; +using sqlite3_int64 = System.Int64; using u32 = System.UInt32; -using u64 = System.UInt64; +using u8 = System.Byte; -namespace Community.CsharpSqlite -{ - using sqlite3_value = Sqlite3.Mem; - using sqlite_int64 = System.Int64; +namespace Community.CsharpSqlite { + using sqlite_int64 = System.Int64; + using sqlite3_value = Sqlite3.Mem; + + public partial class Sqlite3 { + /* + ** 2002 February 23 + ** + ** 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 contains the C functions that implement various SQL + ** functions of SQLite. + ** + ** There is only one exported symbol in this file - the function + ** sqliteRegisterBuildinFunctions() found at the bottom of the file. + ** All other code has file scope. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include + //#include + //#include "vdbeInt.h" - public partial class Sqlite3 - { - /* - ** 2002 February 23 - ** - ** 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 contains the C functions that implement various SQL - ** functions of SQLite. - ** - ** There is only one exported symbol in this file - the function - ** sqliteRegisterBuildinFunctions() found at the bottom of the file. - ** All other code has file scope. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include - //#include - //#include "vdbeInt.h" + /* + ** Return the collating function associated with a function. + */ + static CollSeq sqlite3GetFuncCollSeq(sqlite3_context context) { + return context.pColl; + } - /* - ** Return the collating function associated with a function. - */ - static CollSeq sqlite3GetFuncCollSeq( sqlite3_context context ) - { - return context.pColl; - } + /* + ** Implementation of the non-aggregate min() and max() functions + */ + static void minmaxFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + int i; + int mask; /* 0 for min() or 0xffffffff for max() */ + int iBest; + CollSeq pColl; + + Debug.Assert(argc > 1); + mask = (int)sqlite3_user_data(context) == 0 ? 0 : -1; + pColl = sqlite3GetFuncCollSeq(context); + Debug.Assert(pColl != null); + Debug.Assert(mask == -1 || mask == 0); + testcase(mask == 0); + iBest = 0; + if (sqlite3_value_type(argv[0]) == SQLITE_NULL) + return; + for (i = 1; i < argc; i++) { + if (sqlite3_value_type(argv[i]) == SQLITE_NULL) + return; + if ((sqlite3MemCompare(argv[iBest], argv[i], pColl) ^ mask) >= 0) { + iBest = i; + } + } + sqlite3_result_value(context, argv[iBest]); + } - /* - ** Implementation of the non-aggregate min() and max() functions - */ - static void minmaxFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - int i; - int mask; /* 0 for min() or 0xffffffff for max() */ - int iBest; - CollSeq pColl; - - Debug.Assert( argc > 1 ); - mask = (int)sqlite3_user_data( context ) == 0 ? 0 : -1; - pColl = sqlite3GetFuncCollSeq( context ); - Debug.Assert( pColl != null ); - Debug.Assert( mask == -1 || mask == 0 ); - testcase( mask == 0 ); - iBest = 0; - if ( sqlite3_value_type( argv[0] ) == SQLITE_NULL ) - return; - for ( i = 1; i < argc; i++ ) - { - if ( sqlite3_value_type( argv[i] ) == SQLITE_NULL ) - return; - if ( ( sqlite3MemCompare( argv[iBest], argv[i], pColl ) ^ mask ) >= 0 ) - { - iBest = i; + /* + ** Return the type of the argument. + */ + static void typeofFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] argv + ) { + string z = ""; + UNUSED_PARAMETER(NotUsed); + switch (sqlite3_value_type(argv[0])) { + case SQLITE_INTEGER: + z = "integer"; + break; + case SQLITE_TEXT: + z = "text"; + break; + case SQLITE_FLOAT: + z = "real"; + break; + case SQLITE_BLOB: + z = "blob"; + break; + default: + z = "null"; + break; + } + sqlite3_result_text(context, z, -1, SQLITE_STATIC); } - } - sqlite3_result_value( context, argv[iBest] ); - } - /* - ** Return the type of the argument. - */ - static void typeofFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] argv - ) - { - string z = ""; - UNUSED_PARAMETER( NotUsed ); - switch ( sqlite3_value_type( argv[0] ) ) - { - case SQLITE_INTEGER: - z = "integer"; - break; - case SQLITE_TEXT: - z = "text"; - break; - case SQLITE_FLOAT: - z = "real"; - break; - case SQLITE_BLOB: - z = "blob"; - break; - default: - z = "null"; - break; - } - sqlite3_result_text( context, z, -1, SQLITE_STATIC ); - } + /* + ** Implementation of the length() function + */ + static void lengthFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + int len; + + Debug.Assert(argc == 1); + UNUSED_PARAMETER(argc); + switch (sqlite3_value_type(argv[0])) { + case SQLITE_BLOB: + case SQLITE_INTEGER: + case SQLITE_FLOAT: { + sqlite3_result_int(context, sqlite3_value_bytes(argv[0])); + break; + } + case SQLITE_TEXT: { + byte[] z = sqlite3_value_blob(argv[0]); + if (z == null) + return; + len = 0; + int iz = 0; + while (iz < z.Length && z[iz] != '\0') { + len++; + SQLITE_SKIP_UTF8(z, ref iz); + } + sqlite3_result_int(context, len); + break; + } + default: { + sqlite3_result_null(context); + break; + } + } + } - /* - ** Implementation of the length() function - */ - static void lengthFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - int len; - - Debug.Assert( argc == 1 ); - UNUSED_PARAMETER( argc ); - switch ( sqlite3_value_type( argv[0] ) ) - { - case SQLITE_BLOB: - case SQLITE_INTEGER: - case SQLITE_FLOAT: - { - sqlite3_result_int( context, sqlite3_value_bytes( argv[0] ) ); - break; - } - case SQLITE_TEXT: - { - byte[] z = sqlite3_value_blob( argv[0] ); - if ( z == null ) - return; - len = 0; - int iz = 0; - while ( iz < z.Length && z[iz] != '\0' ) - { - len++; - SQLITE_SKIP_UTF8( z, ref iz ); + /* + ** Implementation of the abs() function. + ** + ** IMP: R-23979-26855 The abs(X) function returns the absolute value of + ** the numeric argument X. + */ + static void absFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + Debug.Assert(argc == 1); + UNUSED_PARAMETER(argc); + switch (sqlite3_value_type(argv[0])) { + case SQLITE_INTEGER: { + i64 iVal = sqlite3_value_int64(argv[0]); + if (iVal < 0) { + if ((iVal << 1) == 0) { + /* IMP: R-35460-15084 If X is the integer -9223372036854775807 then + ** abs(X) throws an integer overflow error since there is no + ** equivalent positive 64-bit two complement value. */ + sqlite3_result_error(context, "integer overflow", -1); + return; + } + iVal = -iVal; + } + sqlite3_result_int64(context, iVal); + break; + } + case SQLITE_NULL: { + /* IMP: R-37434-19929 Abs(X) returns NULL if X is NULL. */ + sqlite3_result_null(context); + break; + } + default: { + /* Because sqlite3_value_double() returns 0.0 if the argument is not + ** something that can be converted into a number, we have: + ** IMP: R-57326-31541 Abs(X) return 0.0 if X is a string or blob that + ** cannot be converted to a numeric value. + */ + double rVal = sqlite3_value_double(argv[0]); + if (rVal < 0) + rVal = -rVal; + sqlite3_result_double(context, rVal); + break; + } } - sqlite3_result_int( context, len ); - break; - } - default: - { - sqlite3_result_null( context ); - break; - } - } - } + } - /* - ** Implementation of the abs() function. - ** - ** IMP: R-23979-26855 The abs(X) function returns the absolute value of - ** the numeric argument X. - */ - static void absFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - Debug.Assert( argc == 1 ); - UNUSED_PARAMETER( argc ); - switch ( sqlite3_value_type( argv[0] ) ) - { - case SQLITE_INTEGER: - { - i64 iVal = sqlite3_value_int64( argv[0] ); - if ( iVal < 0 ) - { - if ( ( iVal << 1 ) == 0 ) - { - /* IMP: R-35460-15084 If X is the integer -9223372036854775807 then - ** abs(X) throws an integer overflow error since there is no - ** equivalent positive 64-bit two complement value. */ - sqlite3_result_error( context, "integer overflow", -1 ); + /* + ** Implementation of the substr() function. + ** + ** substr(x,p1,p2) returns p2 characters of x[] beginning with p1. + ** p1 is 1-indexed. So substr(x,1,1) returns the first character + ** of x. If x is text, then we actually count UTF-8 characters. + ** If x is a blob, then we count bytes. + ** + ** If p1 is negative, then we begin abs(p1) from the end of x[]. + ** + ** If p2 is negative, return the p2 characters preceeding p1. + */ + static void substrFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + string z = ""; + byte[] zBLOB = null; + string z2; + int len; + int p0type; + int p1, p2; + int negP2 = 0; + + Debug.Assert(argc == 3 || argc == 2); + if (sqlite3_value_type(argv[1]) == SQLITE_NULL + || (argc == 3 && sqlite3_value_type(argv[2]) == SQLITE_NULL) + ) { return; - } - iVal = -iVal; } - sqlite3_result_int64( context, iVal ); - break; - } - case SQLITE_NULL: - { - /* IMP: R-37434-19929 Abs(X) returns NULL if X is NULL. */ - sqlite3_result_null( context ); - break; - } - default: - { - /* Because sqlite3_value_double() returns 0.0 if the argument is not - ** something that can be converted into a number, we have: - ** IMP: R-57326-31541 Abs(X) return 0.0 if X is a string or blob that - ** cannot be converted to a numeric value. - */ - double rVal = sqlite3_value_double( argv[0] ); - if ( rVal < 0 ) - rVal = -rVal; - sqlite3_result_double( context, rVal ); - break; - } - } - } + p0type = sqlite3_value_type(argv[0]); + p1 = sqlite3_value_int(argv[1]); + if (p0type == SQLITE_BLOB) { + len = sqlite3_value_bytes(argv[0]); + zBLOB = argv[0].zBLOB; + if (zBLOB == null) + return; + Debug.Assert(len == zBLOB.Length); + } else { + z = sqlite3_value_text(argv[0]); + if (String.IsNullOrEmpty(z)) + return; + len = 0; + if (p1 < 0) { + len = z.Length; + //for ( z2 = z ; z2 != "" ; len++ ) + //{ + // SQLITE_SKIP_UTF8( ref z2 ); + //} + } + } + if (argc == 3) { + p2 = sqlite3_value_int(argv[2]); + if (p2 < 0) { + p2 = -p2; + negP2 = 1; + } + } else { + p2 = (sqlite3_context_db_handle(context)).aLimit[SQLITE_LIMIT_LENGTH]; + } + if (p1 < 0) { + p1 += len; + if (p1 < 0) { + p2 += p1; + if (p2 < 0) + p2 = 0; + p1 = 0; + } + } else if (p1 > 0) { + p1--; + } else if (p2 > 0) { + p2--; + } + if (negP2 != 0) { + p1 -= p2; + if (p1 < 0) { + p2 += p1; + p1 = 0; + } + } + Debug.Assert(p1 >= 0 && p2 >= 0); + if (p0type != SQLITE_BLOB) { + //while ( z != "" && p1 != 0 ) + //{ + // SQLITE_SKIP_UTF8( ref z ); + // p1--; + //} + //for ( z2 = z ; z2 != "" && p2 != 0 ; p2-- ) + //{ + // SQLITE_SKIP_UTF8( ref z2 ); + //} + sqlite3_result_text(context, z, p1, p2 <= z.Length - p1 ? p2 : z.Length - p1, SQLITE_TRANSIENT); + } else { + if (p1 + p2 > len) { + p2 = len - p1; + if (p2 < 0) + p2 = 0; + } + StringBuilder sb = new StringBuilder(zBLOB.Length); + if (zBLOB.Length == 0 || p1 > zBLOB.Length) + sb.Length = 0; + else { + for (int i = p1; i < p1 + p2; i++) { + sb.Append((char)zBLOB[i]); + } + } - /* - ** Implementation of the substr() function. - ** - ** substr(x,p1,p2) returns p2 characters of x[] beginning with p1. - ** p1 is 1-indexed. So substr(x,1,1) returns the first character - ** of x. If x is text, then we actually count UTF-8 characters. - ** If x is a blob, then we count bytes. - ** - ** If p1 is negative, then we begin abs(p1) from the end of x[]. - ** - ** If p2 is negative, return the p2 characters preceeding p1. - */ - static void substrFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - string z = ""; - byte[] zBLOB = null; - string z2; - int len; - int p0type; - int p1, p2; - int negP2 = 0; - - Debug.Assert( argc == 3 || argc == 2 ); - if ( sqlite3_value_type( argv[1] ) == SQLITE_NULL - || ( argc == 3 && sqlite3_value_type( argv[2] ) == SQLITE_NULL ) - ) - { - return; - } - p0type = sqlite3_value_type( argv[0] ); - p1 = sqlite3_value_int( argv[1] ); - if ( p0type == SQLITE_BLOB ) - { - len = sqlite3_value_bytes( argv[0] ); - zBLOB = argv[0].zBLOB; - if ( zBLOB == null ) - return; - Debug.Assert( len == zBLOB.Length ); - } - else - { - z = sqlite3_value_text( argv[0] ); - if ( String.IsNullOrEmpty( z ) ) - return; - len = 0; - if ( p1 < 0 ) - { - len = z.Length; - //for ( z2 = z ; z2 != "" ; len++ ) - //{ - // SQLITE_SKIP_UTF8( ref z2 ); - //} - } - } - if ( argc == 3 ) - { - p2 = sqlite3_value_int( argv[2] ); - if ( p2 < 0 ) - { - p2 = -p2; - negP2 = 1; - } - } - else - { - p2 = ( sqlite3_context_db_handle( context ) ).aLimit[SQLITE_LIMIT_LENGTH]; - } - if ( p1 < 0 ) - { - p1 += len; - if ( p1 < 0 ) - { - p2 += p1; - if ( p2 < 0 ) - p2 = 0; - p1 = 0; - } - } - else if ( p1 > 0 ) - { - p1--; - } - else if ( p2 > 0 ) - { - p2--; - } - if ( negP2 != 0 ) - { - p1 -= p2; - if ( p1 < 0 ) - { - p2 += p1; - p1 = 0; - } - } - Debug.Assert( p1 >= 0 && p2 >= 0 ); - if ( p0type != SQLITE_BLOB ) - { - //while ( z != "" && p1 != 0 ) - //{ - // SQLITE_SKIP_UTF8( ref z ); - // p1--; - //} - //for ( z2 = z ; z2 != "" && p2 != 0 ; p2-- ) - //{ - // SQLITE_SKIP_UTF8( ref z2 ); - //} - sqlite3_result_text( context, z, p1, p2 <= z.Length - p1 ? p2 : z.Length - p1, SQLITE_TRANSIENT ); - } - else - { - if ( p1 + p2 > len ) - { - p2 = len - p1; - if ( p2 < 0 ) - p2 = 0; - } - StringBuilder sb = new StringBuilder( zBLOB.Length ); - if ( zBLOB.Length == 0 || p1 > zBLOB.Length ) - sb.Length = 0; - else - { - for ( int i = p1; i < p1 + p2; i++ ) - { - sb.Append( (char)zBLOB[i] ); - } + sqlite3_result_blob(context, sb.ToString(), (int)p2, SQLITE_TRANSIENT); + } } - sqlite3_result_blob( context, sb.ToString(), (int)p2, SQLITE_TRANSIENT ); - } - } - - /* - ** Implementation of the round() function - */ + /* + ** Implementation of the round() function + */ #if !SQLITE_OMIT_FLOATING_POINT - static void roundFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - int n = 0; - double r; - string zBuf = ""; - Debug.Assert( argc == 1 || argc == 2 ); - if ( argc == 2 ) - { - if ( SQLITE_NULL == sqlite3_value_type( argv[1] ) ) - return; - n = sqlite3_value_int( argv[1] ); - if ( n > 30 ) - n = 30; - if ( n < 0 ) - n = 0; - } - if ( sqlite3_value_type( argv[0] ) == SQLITE_NULL ) - return; - r = sqlite3_value_double( argv[0] ); - /* If Y==0 and X will fit in a 64-bit int, - ** handle the rounding directly, - ** otherwise use printf. - */ - if ( n == 0 && r >= 0 && r < LARGEST_INT64 - 1 ) - { - r = (double)( (sqlite_int64)( r + 0.5 ) ); - } - else if ( n == 0 && r < 0 && ( -r ) < LARGEST_INT64 - 1 ) - { - r = -(double)( (sqlite_int64)( ( -r ) + 0.5 ) ); - } - else - { - zBuf = sqlite3_mprintf( "%.*f", n, r ); - if ( zBuf == null ) - { - sqlite3_result_error_nomem( context ); - return; + static void roundFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + int n = 0; + double r; + string zBuf = ""; + Debug.Assert(argc == 1 || argc == 2); + if (argc == 2) { + if (SQLITE_NULL == sqlite3_value_type(argv[1])) + return; + n = sqlite3_value_int(argv[1]); + if (n > 30) + n = 30; + if (n < 0) + n = 0; + } + if (sqlite3_value_type(argv[0]) == SQLITE_NULL) + return; + r = sqlite3_value_double(argv[0]); + /* If Y==0 and X will fit in a 64-bit int, + ** handle the rounding directly, + ** otherwise use printf. + */ + if (n == 0 && r >= 0 && r < LARGEST_INT64 - 1) { + r = (double)((sqlite_int64)(r + 0.5)); + } else if (n == 0 && r < 0 && (-r) < LARGEST_INT64 - 1) { + r = -(double)((sqlite_int64)((-r) + 0.5)); + } else { + zBuf = sqlite3_mprintf("%.*f", n, r); + if (zBuf == null) { + sqlite3_result_error_nomem(context); + return; + } + sqlite3AtoF(zBuf, ref r, sqlite3Strlen30(zBuf), SQLITE_UTF8); + //sqlite3_free( ref zBuf ); + } + sqlite3_result_double(context, r); } - sqlite3AtoF( zBuf, ref r, sqlite3Strlen30( zBuf ), SQLITE_UTF8 ); - //sqlite3_free( ref zBuf ); - } - sqlite3_result_double( context, r ); - } #endif - /* -** Allocate nByte bytes of space using sqlite3_malloc(). If the -** allocation fails, call sqlite3_result_error_nomem() to notify -** the database handle that malloc() has failed and return NULL. -** If nByte is larger than the maximum string or blob length, then -** raise an SQLITE_TOOBIG exception and return NULL. -*/ - //static void* contextMalloc( sqlite3_context* context, i64 nByte ) - //{ - // char* z; - // sqlite3* db = sqlite3_context_db_handle( context ); - // assert( nByte > 0 ); - // testcase( nByte == db->aLimit[SQLITE_LIMIT_LENGTH] ); - // testcase( nByte == db->aLimit[SQLITE_LIMIT_LENGTH] + 1 ); - // if ( nByte > db->aLimit[SQLITE_LIMIT_LENGTH] ) - // { - // sqlite3_result_error_toobig( context ); - // z = 0; - // } - // else - // { - // z = sqlite3Malloc( (int)nByte ); - // if ( !z ) - // { - // sqlite3_result_error_nomem( context ); - // } - // } - // return z; - //} - - /* - ** Implementation of the upper() and lower() SQL functions. + /* + ** Allocate nByte bytes of space using sqlite3_malloc(). If the + ** allocation fails, call sqlite3_result_error_nomem() to notify + ** the database handle that malloc() has failed and return NULL. + ** If nByte is larger than the maximum string or blob length, then + ** raise an SQLITE_TOOBIG exception and return NULL. */ - static void upperFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - string z1; - string z2; - int i, n; - UNUSED_PARAMETER( argc ); - z2 = sqlite3_value_text( argv[0] ); - n = sqlite3_value_bytes( argv[0] ); - /* Verify that the call to _bytes() does not invalidate the _text() pointer */ - //Debug.Assert( z2 == sqlite3_value_text( argv[0] ) ); - if ( z2 != null ) - { - //z1 = new byte[n];// contextMalloc(context, ((i64)n)+1); - //if ( z1 !=null) - //{ - // memcpy( z1, z2, n + 1 ); - //for ( i = 0 ; i< z1.Length ; i++ ) + //static void* contextMalloc( sqlite3_context* context, i64 nByte ) //{ - //(char)sqlite3Toupper( z1[i] ); - //} - sqlite3_result_text( context, z2.Length == 0 ? "" : z2.Substring( 0, n ).ToUpperInvariant(), -1, null ); //sqlite3_free ); - // } - } - } - - static void lowerFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - string z1; - string z2; - int i, n; - UNUSED_PARAMETER( argc ); - z2 = sqlite3_value_text( argv[0] ); - n = sqlite3_value_bytes( argv[0] ); - /* Verify that the call to _bytes() does not invalidate the _text() pointer */ - //Debug.Assert( z2 == sqlite3_value_text( argv[0] ) ); - if ( z2 != null ) - { - //z1 = contextMalloc(context, ((i64)n)+1); - //if ( z1 ) - //{ - // memcpy( z1, z2, n + 1 ); - // for ( i = 0 ; z1[i] ; i++ ) + // char* z; + // sqlite3* db = sqlite3_context_db_handle( context ); + // assert( nByte > 0 ); + // testcase( nByte == db->aLimit[SQLITE_LIMIT_LENGTH] ); + // testcase( nByte == db->aLimit[SQLITE_LIMIT_LENGTH] + 1 ); + // if ( nByte > db->aLimit[SQLITE_LIMIT_LENGTH] ) + // { + // sqlite3_result_error_toobig( context ); + // z = 0; + // } + // else // { - // z1[i] = (char)sqlite3Tolower( z1[i] ); + // z = sqlite3Malloc( (int)nByte ); + // if ( !z ) + // { + // sqlite3_result_error_nomem( context ); + // } // } - sqlite3_result_text( context, z2.Length == 0 ? "" : z2.Substring( 0, n ).ToLowerInvariant(), -1, null );//sqlite3_free ); + // return z; //} - } - } + + /* + ** Implementation of the upper() and lower() SQL functions. + */ + static void upperFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + string z1; + string z2; + int i, n; + UNUSED_PARAMETER(argc); + z2 = sqlite3_value_text(argv[0]); + n = sqlite3_value_bytes(argv[0]); + /* Verify that the call to _bytes() does not invalidate the _text() pointer */ + //Debug.Assert( z2 == sqlite3_value_text( argv[0] ) ); + if (z2 != null) { + //z1 = new byte[n];// contextMalloc(context, ((i64)n)+1); + //if ( z1 !=null) + //{ + // memcpy( z1, z2, n + 1 ); + //for ( i = 0 ; i< z1.Length ; i++ ) + //{ + //(char)sqlite3Toupper( z1[i] ); + //} + sqlite3_result_text(context, z2.Length == 0 ? "" : z2.Substring(0, n).ToUpperInvariant(), -1, null); //sqlite3_free ); + // } + } + } + + static void lowerFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + string z1; + string z2; + int i, n; + UNUSED_PARAMETER(argc); + z2 = sqlite3_value_text(argv[0]); + n = sqlite3_value_bytes(argv[0]); + /* Verify that the call to _bytes() does not invalidate the _text() pointer */ + //Debug.Assert( z2 == sqlite3_value_text( argv[0] ) ); + if (z2 != null) { + //z1 = contextMalloc(context, ((i64)n)+1); + //if ( z1 ) + //{ + // memcpy( z1, z2, n + 1 ); + // for ( i = 0 ; z1[i] ; i++ ) + // { + // z1[i] = (char)sqlite3Tolower( z1[i] ); + // } + sqlite3_result_text(context, z2.Length == 0 ? "" : z2.Substring(0, n).ToLowerInvariant(), -1, null);//sqlite3_free ); + //} + } + } #if FALSE //* This function is never used. */ /* @@ -533,357 +475,306 @@ sqlite3_value[] argv } } #endif //* NOT USED */ - //#define ifnullFunc versionFunc /* Substitute function - never called */ + //#define ifnullFunc versionFunc /* Substitute function - never called */ - /* - ** Implementation of random(). Return a random integer. - */ - static void randomFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] NotUsed2 - ) - { - sqlite_int64 r = 0; - UNUSED_PARAMETER2( NotUsed, NotUsed2 ); - sqlite3_randomness( sizeof( sqlite_int64 ), ref r ); - if ( r < 0 ) - { - /* We need to prevent a random number of 0x8000000000000000 - ** (or -9223372036854775808) since when you do abs() of that - ** number of you get the same value back again. To do this - ** in a way that is testable, mask the sign bit off of negative - ** values, resulting in a positive value. Then take the - ** 2s complement of that positive value. The end result can - ** therefore be no less than -9223372036854775807. + /* + ** Implementation of random(). Return a random integer. */ - r = -( r ^ ( ( (sqlite3_int64)1 ) << 63 ) ); - } - sqlite3_result_int64( context, r ); - } - - /* - ** Implementation of randomblob(N). Return a random blob - ** that is N bytes long. - */ - static void randomBlob( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - int n; - char[] p; - Debug.Assert( argc == 1 ); - UNUSED_PARAMETER( argc ); - n = sqlite3_value_int( argv[0] ); - if ( n < 1 ) - { - n = 1; - } - if ( n > sqlite3_context_db_handle(context).aLimit[SQLITE_LIMIT_LENGTH] ) - { - sqlite3_result_error_toobig( context ); - p = null; - } - else - { - p = new char[n]; //contextMalloc( context, n ); - } - if ( p != null ) - { - i64 _p = 0; - for ( int i = 0; i < n; i++ ) - { - sqlite3_randomness( sizeof( u8 ), ref _p ); - p[i] = (char)( _p & 0x7F ); + static void randomFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] NotUsed2 + ) { + sqlite_int64 r = 0; + UNUSED_PARAMETER2(NotUsed, NotUsed2); + sqlite3_randomness(sizeof(sqlite_int64), ref r); + if (r < 0) { + /* We need to prevent a random number of 0x8000000000000000 + ** (or -9223372036854775808) since when you do abs() of that + ** number of you get the same value back again. To do this + ** in a way that is testable, mask the sign bit off of negative + ** values, resulting in a positive value. Then take the + ** 2s complement of that positive value. The end result can + ** therefore be no less than -9223372036854775807. + */ + r = -(r ^ (((sqlite3_int64)1) << 63)); + } + sqlite3_result_int64(context, r); } - sqlite3_result_blob( context, new string( p ), n, null );//sqlite3_free ); - } - } - /* - ** Implementation of the last_insert_rowid() SQL function. The return - ** value is the same as the sqlite3_last_insert_rowid() API function. - */ - static void last_insert_rowid( - sqlite3_context context, - int NotUsed, - sqlite3_value[] NotUsed2 - ) - { - sqlite3 db = sqlite3_context_db_handle( context ); - UNUSED_PARAMETER2( NotUsed, NotUsed2 ); - /* IMP: R-51513-12026 The last_insert_rowid() SQL function is a - ** wrapper around the sqlite3_last_insert_rowid() C/C++ interface - ** function. */ - sqlite3_result_int64( context, sqlite3_last_insert_rowid( db ) ); - } - - /* - ** Implementation of the changes() SQL function. - ** - ** IMP: R-62073-11209 The changes() SQL function is a wrapper - ** around the sqlite3_changes() C/C++ function and hence follows the same - ** rules for counting changes. - */ - static void changes( - sqlite3_context context, - int NotUsed, - sqlite3_value[] NotUsed2 - ) - { - sqlite3 db = sqlite3_context_db_handle( context ); - UNUSED_PARAMETER2( NotUsed, NotUsed2 ); - sqlite3_result_int( context, sqlite3_changes( db ) ); - } - - /* - ** Implementation of the total_changes() SQL function. The return value is - ** the same as the sqlite3_total_changes() API function. - */ - static void total_changes( - sqlite3_context context, - int NotUsed, - sqlite3_value[] NotUsed2 - ) - { - sqlite3 db = (sqlite3)sqlite3_context_db_handle( context ); - UNUSED_PARAMETER2( NotUsed, NotUsed2 ); - /* IMP: R-52756-41993 This function is a wrapper around the - ** sqlite3_total_changes() C/C++ interface. */ - sqlite3_result_int( context, sqlite3_total_changes( db ) ); - } - - /* - ** A structure defining how to do GLOB-style comparisons. - */ - struct compareInfo - { - public char matchAll; - public char matchOne; - public char matchSet; - public bool noCase; - public compareInfo( char matchAll, char matchOne, char matchSet, bool noCase ) - { - this.matchAll = matchAll; - this.matchOne = matchOne; - this.matchSet = matchSet; - this.noCase = noCase; - } - }; - - /* - ** For LIKE and GLOB matching on EBCDIC machines, assume that every - ** character is exactly one byte in size. Also, all characters are - ** 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,C) (*(A++)) - //# define GlogUpperToLower(A) A = sqlite3UpperToLower[A] - //#else - //# define GlogUpperToLower(A) if( !((A)&~0x7f) ){ A = sqlite3UpperToLower[A]; } - //#endif - - static compareInfo globInfo = new compareInfo( '*', '?', '[', false ); - /* The correct SQL-92 behavior is for the LIKE operator to ignore - ** case. Thus 'a' LIKE 'A' would be true. */ - static compareInfo likeInfoNorm = new compareInfo( '%', '_', '\0', true ); - /* If SQLITE_CASE_SENSITIVE_LIKE is defined, then the LIKE operator - ** is case sensitive causing 'a' LIKE 'A' to be false */ - static compareInfo likeInfoAlt = new compareInfo( '%', '_', '\0', false ); - - /* - ** Compare two UTF-8 strings for equality where the first string can - ** potentially be a "glob" expression. Return true (1) if they - ** are the same and false (0) if they are different. - ** - ** Globbing rules: - ** - ** '*' Matches any sequence of zero or more characters. - ** - ** '?' Matches exactly one character. - ** - ** [...] Matches one character from the enclosed list of - ** characters. - ** - ** [^...] Matches one character not in the enclosed list. - ** - ** With the [...] and [^...] matching, a ']' character can be included - ** in the list by making it the first character after '[' or '^'. A - ** range of characters can be specified using '-'. Example: - ** "[a-z]" matches any single lower-case letter. To match a '-', make - ** it the last character in the list. - ** - ** This routine is usually quick, but can be N**2 in the worst case. - ** - ** Hints: to match '*' or '?', put them in "[]". Like this: - ** - ** abc[*]xyz Matches "abc*xyz" only - */ - static bool patternCompare( - string zPattern, /* The glob pattern */ - string zString, /* The string to compare against the glob */ - compareInfo pInfo, /* Information about how to do the compare */ - u32 esc /* The escape character */ - ) - { - u32 c, c2; - int invert; - int seen; - int matchOne = (int)pInfo.matchOne; - int matchAll = (int)pInfo.matchAll; - int matchSet = (int)pInfo.matchSet; - bool noCase = pInfo.noCase; - bool prevEscape = false; /* True if the previous character was 'escape' */ - string inPattern = zPattern; //Entered Pattern - - while ( ( c = sqlite3Utf8Read( zPattern, ref zPattern ) ) != 0 ) - { - if ( !prevEscape && c == matchAll ) - { - while ( ( c = sqlite3Utf8Read( zPattern, ref zPattern ) ) == matchAll - || c == matchOne ) - { - if ( c == matchOne && sqlite3Utf8Read( zString, ref zString ) == 0 ) - { - return false; - } - } - if ( c == 0 ) - { - return true; - } - else if ( c == esc ) - { - c = sqlite3Utf8Read( zPattern, ref zPattern ); - if ( c == 0 ) - { - return false; - } - } - else if ( c == matchSet ) - { - Debug.Assert( esc == 0 ); /* This is GLOB, not LIKE */ - Debug.Assert( matchSet < 0x80 ); /* '[' is a single-byte character */ - int len = 0; - while ( len < zString.Length && patternCompare( inPattern.Substring( inPattern.Length - zPattern.Length - 1 ), zString.Substring( len ), pInfo, esc ) == false ) - { - SQLITE_SKIP_UTF8( zString, ref len ); + /* + ** Implementation of randomblob(N). Return a random blob + ** that is N bytes long. + */ + static void randomBlob( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + int n; + char[] p; + Debug.Assert(argc == 1); + UNUSED_PARAMETER(argc); + n = sqlite3_value_int(argv[0]); + if (n < 1) { + n = 1; } - return len < zString.Length; - } - while ( ( c2 = sqlite3Utf8Read( zString, ref zString ) ) != 0 ) - { - if ( noCase ) - { - if( 0==((c2)&~0x7f) ) - c2 = (u32)sqlite3UpperToLower[c2]; //GlogUpperToLower(c2); - if ( 0 == ( ( c ) & ~0x7f ) ) - c = (u32)sqlite3UpperToLower[c]; //GlogUpperToLower(c); - while ( c2 != 0 && c2 != c ) - { - c2 = sqlite3Utf8Read( zString, ref zString ); - if ( 0 == ( ( c2 ) & ~0x7f ) ) - c2 = (u32)sqlite3UpperToLower[c2]; //GlogUpperToLower(c2); - } + if (n > sqlite3_context_db_handle(context).aLimit[SQLITE_LIMIT_LENGTH]) { + sqlite3_result_error_toobig(context); + p = null; + } else { + p = new char[n]; //contextMalloc( context, n ); } - else - { - while ( c2 != 0 && c2 != c ) - { - c2 = sqlite3Utf8Read( zString, ref zString ); - } + if (p != null) { + i64 _p = 0; + for (int i = 0; i < n; i++) { + sqlite3_randomness(sizeof(u8), ref _p); + p[i] = (char)(_p & 0x7F); + } + sqlite3_result_blob(context, new string(p), n, null);//sqlite3_free ); } - if ( c2 == 0 ) - return false; - if ( patternCompare( zPattern, zString, pInfo, esc ) ) - return true; - } - return false; } - else if ( !prevEscape && c == matchOne ) - { - if ( sqlite3Utf8Read( zString, ref zString ) == 0 ) - { - return false; - } + + /* + ** Implementation of the last_insert_rowid() SQL function. The return + ** value is the same as the sqlite3_last_insert_rowid() API function. + */ + static void last_insert_rowid( + sqlite3_context context, + int NotUsed, + sqlite3_value[] NotUsed2 + ) { + sqlite3 db = sqlite3_context_db_handle(context); + UNUSED_PARAMETER2(NotUsed, NotUsed2); + /* IMP: R-51513-12026 The last_insert_rowid() SQL function is a + ** wrapper around the sqlite3_last_insert_rowid() C/C++ interface + ** function. */ + sqlite3_result_int64(context, sqlite3_last_insert_rowid(db)); } - else if ( c == matchSet ) - { - u32 prior_c = 0; - Debug.Assert( esc == 0 ); /* This only occurs for GLOB, not LIKE */ - seen = 0; - invert = 0; - c = sqlite3Utf8Read( zString, ref zString ); - if ( c == 0 ) - return false; - c2 = sqlite3Utf8Read( zPattern, ref zPattern ); - if ( c2 == '^' ) - { - invert = 1; - c2 = sqlite3Utf8Read( zPattern, ref zPattern ); - } - if ( c2 == ']' ) - { - if ( c == ']' ) - seen = 1; - c2 = sqlite3Utf8Read( zPattern, ref zPattern ); - } - while ( c2 != 0 && c2 != ']' ) - { - if ( c2 == '-' && zPattern[0] != ']' && zPattern[0] != 0 && prior_c > 0 ) - { - c2 = sqlite3Utf8Read( zPattern, ref zPattern ); - if ( c >= prior_c && c <= c2 ) - seen = 1; - prior_c = 0; - } - else - { - if ( c == c2 ) - { - seen = 1; - } - prior_c = c2; - } - c2 = sqlite3Utf8Read( zPattern, ref zPattern ); - } - if ( c2 == 0 || ( seen ^ invert ) == 0 ) - { - return false; - } + + /* + ** Implementation of the changes() SQL function. + ** + ** IMP: R-62073-11209 The changes() SQL function is a wrapper + ** around the sqlite3_changes() C/C++ function and hence follows the same + ** rules for counting changes. + */ + static void changes( + sqlite3_context context, + int NotUsed, + sqlite3_value[] NotUsed2 + ) { + sqlite3 db = sqlite3_context_db_handle(context); + UNUSED_PARAMETER2(NotUsed, NotUsed2); + sqlite3_result_int(context, sqlite3_changes(db)); } - else if ( esc == c && !prevEscape ) - { - prevEscape = true; + + /* + ** Implementation of the total_changes() SQL function. The return value is + ** the same as the sqlite3_total_changes() API function. + */ + static void total_changes( + sqlite3_context context, + int NotUsed, + sqlite3_value[] NotUsed2 + ) { + sqlite3 db = (sqlite3)sqlite3_context_db_handle(context); + UNUSED_PARAMETER2(NotUsed, NotUsed2); + /* IMP: R-52756-41993 This function is a wrapper around the + ** sqlite3_total_changes() C/C++ interface. */ + sqlite3_result_int(context, sqlite3_total_changes(db)); } - else - { - c2 = sqlite3Utf8Read( zString, ref zString ); - if ( noCase ) - { - if ( c < 0x80 ) - c = (u32)sqlite3UpperToLower[c]; //GlogUpperToLower(c); - if ( c2 < 0x80 ) - c2 = (u32)sqlite3UpperToLower[c2]; //GlogUpperToLower(c2); - } - if ( c != c2 ) - { - return false; - } - prevEscape = false; + + /* + ** A structure defining how to do GLOB-style comparisons. + */ + struct compareInfo { + public char matchAll; + public char matchOne; + public char matchSet; + public bool noCase; + public compareInfo(char matchAll, char matchOne, char matchSet, bool noCase) { + this.matchAll = matchAll; + this.matchOne = matchOne; + this.matchSet = matchSet; + this.noCase = noCase; + } + }; + + /* + ** For LIKE and GLOB matching on EBCDIC machines, assume that every + ** character is exactly one byte in size. Also, all characters are + ** 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,C) (*(A++)) + //# define GlogUpperToLower(A) A = sqlite3UpperToLower[A] + //#else + //# define GlogUpperToLower(A) if( !((A)&~0x7f) ){ A = sqlite3UpperToLower[A]; } + //#endif + + static compareInfo globInfo = new compareInfo('*', '?', '[', false); + /* The correct SQL-92 behavior is for the LIKE operator to ignore + ** case. Thus 'a' LIKE 'A' would be true. */ + static compareInfo likeInfoNorm = new compareInfo('%', '_', '\0', true); + /* If SQLITE_CASE_SENSITIVE_LIKE is defined, then the LIKE operator + ** is case sensitive causing 'a' LIKE 'A' to be false */ + static compareInfo likeInfoAlt = new compareInfo('%', '_', '\0', false); + + /* + ** Compare two UTF-8 strings for equality where the first string can + ** potentially be a "glob" expression. Return true (1) if they + ** are the same and false (0) if they are different. + ** + ** Globbing rules: + ** + ** '*' Matches any sequence of zero or more characters. + ** + ** '?' Matches exactly one character. + ** + ** [...] Matches one character from the enclosed list of + ** characters. + ** + ** [^...] Matches one character not in the enclosed list. + ** + ** With the [...] and [^...] matching, a ']' character can be included + ** in the list by making it the first character after '[' or '^'. A + ** range of characters can be specified using '-'. Example: + ** "[a-z]" matches any single lower-case letter. To match a '-', make + ** it the last character in the list. + ** + ** This routine is usually quick, but can be N**2 in the worst case. + ** + ** Hints: to match '*' or '?', put them in "[]". Like this: + ** + ** abc[*]xyz Matches "abc*xyz" only + */ + static bool patternCompare( + string zPattern, /* The glob pattern */ + string zString, /* The string to compare against the glob */ + compareInfo pInfo, /* Information about how to do the compare */ + u32 esc /* The escape character */ + ) { + u32 c, c2; + int invert; + int seen; + int matchOne = (int)pInfo.matchOne; + int matchAll = (int)pInfo.matchAll; + int matchSet = (int)pInfo.matchSet; + bool noCase = pInfo.noCase; + bool prevEscape = false; /* True if the previous character was 'escape' */ + string inPattern = zPattern; //Entered Pattern + + while ((c = sqlite3Utf8Read(zPattern, ref zPattern)) != 0) { + if (!prevEscape && c == matchAll) { + while ((c = sqlite3Utf8Read(zPattern, ref zPattern)) == matchAll + || c == matchOne) { + if (c == matchOne && sqlite3Utf8Read(zString, ref zString) == 0) { + return false; + } + } + if (c == 0) { + return true; + } else if (c == esc) { + c = sqlite3Utf8Read(zPattern, ref zPattern); + if (c == 0) { + return false; + } + } else if (c == matchSet) { + Debug.Assert(esc == 0); /* This is GLOB, not LIKE */ + Debug.Assert(matchSet < 0x80); /* '[' is a single-byte character */ + int len = 0; + while (len < zString.Length && patternCompare(inPattern.Substring(inPattern.Length - zPattern.Length - 1), zString.Substring(len), pInfo, esc) == false) { + SQLITE_SKIP_UTF8(zString, ref len); + } + return len < zString.Length; + } + while ((c2 = sqlite3Utf8Read(zString, ref zString)) != 0) { + if (noCase) { + if (0 == ((c2) & ~0x7f)) + c2 = (u32)sqlite3UpperToLower[c2]; //GlogUpperToLower(c2); + if (0 == ((c) & ~0x7f)) + c = (u32)sqlite3UpperToLower[c]; //GlogUpperToLower(c); + while (c2 != 0 && c2 != c) { + c2 = sqlite3Utf8Read(zString, ref zString); + if (0 == ((c2) & ~0x7f)) + c2 = (u32)sqlite3UpperToLower[c2]; //GlogUpperToLower(c2); + } + } else { + while (c2 != 0 && c2 != c) { + c2 = sqlite3Utf8Read(zString, ref zString); + } + } + if (c2 == 0) + return false; + if (patternCompare(zPattern, zString, pInfo, esc)) + return true; + } + return false; + } else if (!prevEscape && c == matchOne) { + if (sqlite3Utf8Read(zString, ref zString) == 0) { + return false; + } + } else if (c == matchSet) { + u32 prior_c = 0; + Debug.Assert(esc == 0); /* This only occurs for GLOB, not LIKE */ + seen = 0; + invert = 0; + c = sqlite3Utf8Read(zString, ref zString); + if (c == 0) + return false; + c2 = sqlite3Utf8Read(zPattern, ref zPattern); + if (c2 == '^') { + invert = 1; + c2 = sqlite3Utf8Read(zPattern, ref zPattern); + } + if (c2 == ']') { + if (c == ']') + seen = 1; + c2 = sqlite3Utf8Read(zPattern, ref zPattern); + } + while (c2 != 0 && c2 != ']') { + if (c2 == '-' && zPattern[0] != ']' && zPattern[0] != 0 && prior_c > 0) { + c2 = sqlite3Utf8Read(zPattern, ref zPattern); + if (c >= prior_c && c <= c2) + seen = 1; + prior_c = 0; + } else { + if (c == c2) { + seen = 1; + } + prior_c = c2; + } + c2 = sqlite3Utf8Read(zPattern, ref zPattern); + } + if (c2 == 0 || (seen ^ invert) == 0) { + return false; + } + } else if (esc == c && !prevEscape) { + prevEscape = true; + } else { + c2 = sqlite3Utf8Read(zString, ref zString); + if (noCase) { + if (c < 0x80) + c = (u32)sqlite3UpperToLower[c]; //GlogUpperToLower(c); + if (c2 < 0x80) + c2 = (u32)sqlite3UpperToLower[c2]; //GlogUpperToLower(c2); + } + if (c != c2) { + return false; + } + prevEscape = false; + } + } + return zString.Length == 0; } - } - return zString.Length == 0; - } - /* - ** Count the number of times that the LIKE operator (or GLOB which is - ** just a variation of LIKE) gets called. This is used for testing - ** only. - */ + /* + ** Count the number of times that the LIKE operator (or GLOB which is + ** just a variation of LIKE) gets called. This is used for testing + ** only. + */ #if SQLITE_TEST #if !TCLSH static int sqlite3_like_count = 0; @@ -893,64 +784,59 @@ u32 esc /* The escape character */ #endif - /* -** Implementation of the like() SQL function. This function implements -** the build-in LIKE operator. The first argument to the function is the -** pattern and the second argument is the string. So, the SQL statements: -** -** A LIKE B -** -** is implemented as like(B,A). -** -** This same function (with a different compareInfo structure) computes -** the GLOB operator. -*/ - static void likeFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - string zA, zB; - u32 escape = 0; - int nPat; - sqlite3 db = sqlite3_context_db_handle( context ); - - zB = sqlite3_value_text( argv[0] ); - zA = sqlite3_value_text( argv[1] ); - - /* Limit the length of the LIKE or GLOB pattern to avoid problems - ** of deep recursion and N*N behavior in patternCompare(). - */ - nPat = sqlite3_value_bytes( argv[0] ); - testcase( nPat == db.aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] ); - testcase( nPat == db.aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] + 1 ); - if ( nPat > db.aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] ) - { - sqlite3_result_error( context, "LIKE or GLOB pattern too complex", -1 ); - return; - } - //Debug.Assert( zB == sqlite3_value_text( argv[0] ) ); /* Encoding did not change */ - - if ( argc == 3 ) - { - /* The escape character string must consist of a single UTF-8 character. - ** Otherwise, return an error. - */ - string zEsc = sqlite3_value_text( argv[2] ); - if ( zEsc == null ) - return; - if ( sqlite3Utf8CharLen( zEsc, -1 ) != 1 ) - { - sqlite3_result_error( context, - "ESCAPE expression must be a single character", -1 ); - return; - } - escape = sqlite3Utf8Read( zEsc, ref zEsc ); - } - if ( zA != null && zB != null ) - { - compareInfo pInfo = (compareInfo)sqlite3_user_data( context ); + /* + ** Implementation of the like() SQL function. This function implements + ** the build-in LIKE operator. The first argument to the function is the + ** pattern and the second argument is the string. So, the SQL statements: + ** + ** A LIKE B + ** + ** is implemented as like(B,A). + ** + ** This same function (with a different compareInfo structure) computes + ** the GLOB operator. + */ + static void likeFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + string zA, zB; + u32 escape = 0; + int nPat; + sqlite3 db = sqlite3_context_db_handle(context); + + zB = sqlite3_value_text(argv[0]); + zA = sqlite3_value_text(argv[1]); + + /* Limit the length of the LIKE or GLOB pattern to avoid problems + ** of deep recursion and N*N behavior in patternCompare(). + */ + nPat = sqlite3_value_bytes(argv[0]); + testcase(nPat == db.aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]); + testcase(nPat == db.aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] + 1); + if (nPat > db.aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]) { + sqlite3_result_error(context, "LIKE or GLOB pattern too complex", -1); + return; + } + //Debug.Assert( zB == sqlite3_value_text( argv[0] ) ); /* Encoding did not change */ + + if (argc == 3) { + /* The escape character string must consist of a single UTF-8 character. + ** Otherwise, return an error. + */ + string zEsc = sqlite3_value_text(argv[2]); + if (zEsc == null) + return; + if (sqlite3Utf8CharLen(zEsc, -1) != 1) { + sqlite3_result_error(context, + "ESCAPE expression must be a single character", -1); + return; + } + escape = sqlite3Utf8Read(zEsc, ref zEsc); + } + if (zA != null && zB != null) { + compareInfo pInfo = (compareInfo)sqlite3_user_data(context); #if SQLITE_TEST #if !TCLSH sqlite3_like_count++; @@ -958,530 +844,473 @@ sqlite3_value[] argv sqlite3_like_count.iValue++; #endif #endif - sqlite3_result_int( context, patternCompare( zB, zA, pInfo, escape ) ? 1 : 0 ); - } - } + sqlite3_result_int(context, patternCompare(zB, zA, pInfo, escape) ? 1 : 0); + } + } - /* - ** Implementation of the NULLIF(x,y) function. The result is the first - ** argument if the arguments are different. The result is NULL if the - ** arguments are equal to each other. - */ - static void nullifFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] argv - ) - { - CollSeq pColl = sqlite3GetFuncCollSeq( context ); - UNUSED_PARAMETER( NotUsed ); - if ( sqlite3MemCompare( argv[0], argv[1], pColl ) != 0 ) - { - sqlite3_result_value( context, argv[0] ); - } - } + /* + ** Implementation of the NULLIF(x,y) function. The result is the first + ** argument if the arguments are different. The result is NULL if the + ** arguments are equal to each other. + */ + static void nullifFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] argv + ) { + CollSeq pColl = sqlite3GetFuncCollSeq(context); + UNUSED_PARAMETER(NotUsed); + if (sqlite3MemCompare(argv[0], argv[1], pColl) != 0) { + sqlite3_result_value(context, argv[0]); + } + } - /* - ** Implementation of the sqlite_version() function. The result is the version - ** of the SQLite library that is running. - */ - static void versionFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] NotUsed2 - ) - { - UNUSED_PARAMETER2( NotUsed, NotUsed2 ); - /* IMP: R-48699-48617 This function is an SQL wrapper around the - ** sqlite3_libversion() C-interface. */ - sqlite3_result_text( context, sqlite3_libversion(), -1, SQLITE_STATIC ); - } + /* + ** Implementation of the sqlite_version() function. The result is the version + ** of the SQLite library that is running. + */ + static void versionFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] NotUsed2 + ) { + UNUSED_PARAMETER2(NotUsed, NotUsed2); + /* IMP: R-48699-48617 This function is an SQL wrapper around the + ** sqlite3_libversion() C-interface. */ + sqlite3_result_text(context, sqlite3_libversion(), -1, SQLITE_STATIC); + } - /* - ** Implementation of the sqlite_source_id() function. The result is a string - ** that identifies the particular version of the source code used to build - ** SQLite. - */ - static void sourceidFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] NotUsed2 - ) - { - UNUSED_PARAMETER2( NotUsed, NotUsed2 ); - /* IMP: R-24470-31136 This function is an SQL wrapper around the - ** sqlite3_sourceid() C interface. */ - sqlite3_result_text( context, sqlite3_sourceid(), -1, SQLITE_STATIC ); - } + /* + ** Implementation of the sqlite_source_id() function. The result is a string + ** that identifies the particular version of the source code used to build + ** SQLite. + */ + static void sourceidFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] NotUsed2 + ) { + UNUSED_PARAMETER2(NotUsed, NotUsed2); + /* IMP: R-24470-31136 This function is an SQL wrapper around the + ** sqlite3_sourceid() C interface. */ + sqlite3_result_text(context, sqlite3_sourceid(), -1, SQLITE_STATIC); + } - /* - ** Implementation of the sqlite_log() function. This is a wrapper around - ** sqlite3_log(). The return value is NULL. The function exists purely for - ** its side-effects. - */ - static void errlogFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - UNUSED_PARAMETER( argc ); - UNUSED_PARAMETER( context ); - sqlite3_log( sqlite3_value_int( argv[0] ), "%s", sqlite3_value_text( argv[1] ) ); - } + /* + ** Implementation of the sqlite_log() function. This is a wrapper around + ** sqlite3_log(). The return value is NULL. The function exists purely for + ** its side-effects. + */ + static void errlogFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + UNUSED_PARAMETER(argc); + UNUSED_PARAMETER(context); + sqlite3_log(sqlite3_value_int(argv[0]), "%s", sqlite3_value_text(argv[1])); + } - /* - ** Implementation of the sqlite_compileoption_used() function. - ** The result is an integer that identifies if the compiler option - ** was used to build SQLite. - */ + /* + ** Implementation of the sqlite_compileoption_used() function. + ** The result is an integer that identifies if the compiler option + ** was used to build SQLite. + */ #if !SQLITE_OMIT_COMPILEOPTION_DIAGS - static void compileoptionusedFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - string zOptName; - Debug.Assert( argc == 1 ); - UNUSED_PARAMETER( argc ); - /* IMP: R-39564-36305 The sqlite_compileoption_used() SQL - ** function is a wrapper around the sqlite3_compileoption_used() C/C++ - ** function. - */ - if ( ( zOptName = sqlite3_value_text( argv[0] ) ) != null ) - { - sqlite3_result_int( context, sqlite3_compileoption_used( zOptName ) ); - } - } + static void compileoptionusedFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + string zOptName; + Debug.Assert(argc == 1); + UNUSED_PARAMETER(argc); + /* IMP: R-39564-36305 The sqlite_compileoption_used() SQL + ** function is a wrapper around the sqlite3_compileoption_used() C/C++ + ** function. + */ + if ((zOptName = sqlite3_value_text(argv[0])) != null) { + sqlite3_result_int(context, sqlite3_compileoption_used(zOptName)); + } + } #endif //* SQLITE_OMIT_COMPILEOPTION_DIAGS */ - /* -** Implementation of the sqlite_compileoption_get() function. -** The result is a string that identifies the compiler options -** used to build SQLite. -*/ + /* + ** Implementation of the sqlite_compileoption_get() function. + ** The result is a string that identifies the compiler options + ** used to build SQLite. + */ #if !SQLITE_OMIT_COMPILEOPTION_DIAGS - static void compileoptiongetFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - int n; - Debug.Assert( argc == 1 ); - UNUSED_PARAMETER( argc ); - /* IMP: R-04922-24076 The sqlite_compileoption_get() SQL function - ** is a wrapper around the sqlite3_compileoption_get() C/C++ function. - */ - n = sqlite3_value_int( argv[0] ); - sqlite3_result_text( context, sqlite3_compileoption_get( n ), -1, SQLITE_STATIC ); - } + static void compileoptiongetFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + int n; + Debug.Assert(argc == 1); + UNUSED_PARAMETER(argc); + /* IMP: R-04922-24076 The sqlite_compileoption_get() SQL function + ** is a wrapper around the sqlite3_compileoption_get() C/C++ function. + */ + n = sqlite3_value_int(argv[0]); + sqlite3_result_text(context, sqlite3_compileoption_get(n), -1, SQLITE_STATIC); + } #endif //* SQLITE_OMIT_COMPILEOPTION_DIAGS */ - /* Array for converting from half-bytes (nybbles) into ASCII hex -** digits. */ - static char[] hexdigits = new char[] { + /* Array for converting from half-bytes (nybbles) into ASCII hex + ** digits. */ + static char[] hexdigits = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - /* - ** EXPERIMENTAL - This is not an official function. The interface may - ** change. This function may disappear. Do not write code that depends - ** on this function. - ** - ** Implementation of the QUOTE() function. This function takes a single - ** argument. If the argument is numeric, the return value is the same as - ** the argument. If the argument is NULL, the return value is the string - ** "NULL". Otherwise, the argument is enclosed in single quotes with - ** single-quote escapes. - */ - static void quoteFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - Debug.Assert( argc == 1 ); - UNUSED_PARAMETER( argc ); - - switch ( sqlite3_value_type( argv[0] ) ) - { - case SQLITE_INTEGER: - case SQLITE_FLOAT: - { - sqlite3_result_value( context, argv[0] ); - break; - } - case SQLITE_BLOB: - { - StringBuilder zText; - byte[] zBlob = sqlite3_value_blob( argv[0] ); - int nBlob = sqlite3_value_bytes( argv[0] ); - Debug.Assert( zBlob.Length == sqlite3_value_blob( argv[0] ).Length ); /* No encoding change */ - zText = new StringBuilder( 2 * nBlob + 4 );//(char*)contextMalloc(context, (2*(i64)nBlob)+4); - zText.Append( "X'" ); - if ( zText != null ) - { - int i; - for ( i = 0; i < nBlob; i++ ) - { - zText.Append( hexdigits[( zBlob[i] >> 4 ) & 0x0F] ); - zText.Append( hexdigits[( zBlob[i] ) & 0x0F] ); - } - zText.Append( "'" ); - //zText[( nBlob * 2 ) + 2] = '\''; - //zText[( nBlob * 2 ) + 3] = '\0'; - //zText[0] = 'X'; - //zText[1] = '\''; - sqlite3_result_text( context, zText, -1, SQLITE_TRANSIENT ); - //sqlite3_free( zText ); - } - break; - } - case SQLITE_TEXT: - { - int i, j; - int n; - string zArg = sqlite3_value_text( argv[0] ); - StringBuilder z; - - if ( zArg == null || zArg.Length == 0 ) - return; - for ( i = 0, n = 0; i < zArg.Length; i++ ) - { - if ( zArg[i] == '\'' ) - n++; + /* + ** EXPERIMENTAL - This is not an official function. The interface may + ** change. This function may disappear. Do not write code that depends + ** on this function. + ** + ** Implementation of the QUOTE() function. This function takes a single + ** argument. If the argument is numeric, the return value is the same as + ** the argument. If the argument is NULL, the return value is the string + ** "NULL". Otherwise, the argument is enclosed in single quotes with + ** single-quote escapes. + */ + static void quoteFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + Debug.Assert(argc == 1); + UNUSED_PARAMETER(argc); + + switch (sqlite3_value_type(argv[0])) { + case SQLITE_INTEGER: + case SQLITE_FLOAT: { + sqlite3_result_value(context, argv[0]); + break; + } + case SQLITE_BLOB: { + StringBuilder zText; + byte[] zBlob = sqlite3_value_blob(argv[0]); + int nBlob = sqlite3_value_bytes(argv[0]); + Debug.Assert(zBlob.Length == sqlite3_value_blob(argv[0]).Length); /* No encoding change */ + zText = new StringBuilder(2 * nBlob + 4);//(char*)contextMalloc(context, (2*(i64)nBlob)+4); + zText.Append("X'"); + if (zText != null) { + int i; + for (i = 0; i < nBlob; i++) { + zText.Append(hexdigits[(zBlob[i] >> 4) & 0x0F]); + zText.Append(hexdigits[(zBlob[i]) & 0x0F]); + } + zText.Append("'"); + //zText[( nBlob * 2 ) + 2] = '\''; + //zText[( nBlob * 2 ) + 3] = '\0'; + //zText[0] = 'X'; + //zText[1] = '\''; + sqlite3_result_text(context, zText, -1, SQLITE_TRANSIENT); + //sqlite3_free( zText ); + } + break; + } + case SQLITE_TEXT: { + int i, j; + int n; + string zArg = sqlite3_value_text(argv[0]); + StringBuilder z; + + if (zArg == null || zArg.Length == 0) + return; + for (i = 0, n = 0; i < zArg.Length; i++) { + if (zArg[i] == '\'') + n++; + } + z = new StringBuilder(i + n + 3);// contextMalloc(context, ((i64)i)+((i64)n)+3); + if (z != null) { + z.Append('\''); + for (i = 0, j = 1; i < zArg.Length && zArg[i] != 0; i++) { + z.Append((char)zArg[i]); + j++; + if (zArg[i] == '\'') { + z.Append('\''); + j++; + } + } + z.Append('\''); + j++; + //z[j] = '\0'; ; + sqlite3_result_text(context, z, j, null);//sqlite3_free ); + } + break; + } + default: { + Debug.Assert(sqlite3_value_type(argv[0]) == SQLITE_NULL); + sqlite3_result_text(context, "NULL", 4, SQLITE_STATIC); + break; + } } - z = new StringBuilder( i + n + 3 );// contextMalloc(context, ((i64)i)+((i64)n)+3); - if ( z != null ) - { - z.Append( '\'' ); - for ( i = 0, j = 1; i < zArg.Length && zArg[i] != 0; i++ ) - { - z.Append( (char)zArg[i] ); - j++; - if ( zArg[i] == '\'' ) - { - z.Append( '\'' ); - j++; + } + + /* + ** The hex() function. Interpret the argument as a blob. Return + ** a hexadecimal rendering as text. + */ + static void hexFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + int i, n; + byte[] pBlob; + //string zHex, z; + Debug.Assert(argc == 1); + UNUSED_PARAMETER(argc); + pBlob = sqlite3_value_blob(argv[0]); + n = sqlite3_value_bytes(argv[0]); + Debug.Assert(n == (pBlob == null ? 0 : pBlob.Length)); /* No encoding change */ + StringBuilder zHex = new StringBuilder(n * 2 + 1); + // z = zHex = contextMalloc(context, ((i64)n)*2 + 1); + if (zHex != null) { + for (i = 0; i < n; i++) {//, pBlob++){ + byte c = pBlob[i]; + zHex.Append(hexdigits[(c >> 4) & 0xf]); + zHex.Append(hexdigits[c & 0xf]); } - } - z.Append( '\'' ); - j++; - //z[j] = '\0'; ; - sqlite3_result_text( context, z, j, null );//sqlite3_free ); + sqlite3_result_text(context, zHex, n * 2, null); //sqlite3_free ); } - break; - } - default: - { - Debug.Assert( sqlite3_value_type( argv[0] ) == SQLITE_NULL ); - sqlite3_result_text( context, "NULL", 4, SQLITE_STATIC ); - break; - } - } - } - - /* - ** The hex() function. Interpret the argument as a blob. Return - ** a hexadecimal rendering as text. - */ - static void hexFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - int i, n; - byte[] pBlob; - //string zHex, z; - Debug.Assert( argc == 1 ); - UNUSED_PARAMETER( argc ); - pBlob = sqlite3_value_blob( argv[0] ); - n = sqlite3_value_bytes( argv[0] ); - Debug.Assert( n == ( pBlob == null ? 0 : pBlob.Length ) ); /* No encoding change */ - StringBuilder zHex = new StringBuilder( n * 2 + 1 ); - // z = zHex = contextMalloc(context, ((i64)n)*2 + 1); - if ( zHex != null ) - { - for ( i = 0; i < n; i++ ) - {//, pBlob++){ - byte c = pBlob[i]; - zHex.Append( hexdigits[( c >> 4 ) & 0xf] ); - zHex.Append( hexdigits[c & 0xf] ); } - sqlite3_result_text( context, zHex, n * 2, null ); //sqlite3_free ); - } - } - /* - ** The zeroblob(N) function returns a zero-filled blob of size N bytes. - */ - static void zeroblobFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - i64 n; - sqlite3 db = sqlite3_context_db_handle( context ); - Debug.Assert( argc == 1 ); - UNUSED_PARAMETER( argc ); - n = sqlite3_value_int64( argv[0] ); - testcase( n == db.aLimit[SQLITE_LIMIT_LENGTH] ); - testcase( n == db.aLimit[SQLITE_LIMIT_LENGTH] + 1 ); - if ( n > db.aLimit[SQLITE_LIMIT_LENGTH] ) - { - sqlite3_result_error_toobig( context ); - } - else - { - sqlite3_result_zeroblob( context, (int)n );/* IMP: R-00293-64994 */ - } - } - - /* - ** The replace() function. Three arguments are all strings: call - ** them A, B, and C. The result is also a string which is derived - ** from A by replacing every occurance of B with C. The match - ** must be exact. Collating sequences are not used. - */ - static void replaceFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - string zStr; /* The input string A */ - string zPattern; /* The pattern string B */ - string zRep; /* The replacement string C */ - string zOut = null; /* The output */ - int nStr; /* Size of zStr */ - int nOut; /* Maximum size of zOut */ - //int loopLimit; /* Last zStr[] that might match zPattern[] */ - int i, j = 0; /* Loop counters */ - - Debug.Assert( argc == 3 ); - UNUSED_PARAMETER( argc ); - zStr = sqlite3_value_text( argv[0] ); - if ( zStr == null ) - return; - nStr = sqlite3_value_bytes( argv[0] ); - Debug.Assert( zStr == sqlite3_value_text( argv[0] ) ); /* No encoding change */ - zPattern = sqlite3_value_text( argv[1] ); - if ( zPattern == null ) - { - Debug.Assert( sqlite3_value_type( argv[1] ) == SQLITE_NULL - //|| sqlite3_context_db_handle( context ).mallocFailed != 0 - ); - return; - } - if ( zPattern == "" ) - { - Debug.Assert( sqlite3_value_type( argv[1] ) != SQLITE_NULL ); - sqlite3_result_value( context, argv[0] ); - return; - } - ////nPattern = sqlite3_value_bytes( argv[1] ); - Debug.Assert( zPattern == sqlite3_value_text( argv[1] ) ); /* No encoding change */ - zRep = sqlite3_value_text( argv[2] ); - if ( zRep == null ) - return; - ////nRep = sqlite3_value_bytes( argv[2] ); - Debug.Assert( zRep == sqlite3_value_text( argv[2] ) ); - nOut = nStr + 1; - Debug.Assert( nOut < SQLITE_MAX_LENGTH ); - if ( nOut <= sqlite3_context_db_handle( context ).aLimit[SQLITE_LIMIT_LENGTH] ) - { - //int nPattern; /* Size of zPattern */ - //int nRep; /* Size of zRep */ - //zOut = contextMalloc(context, (i64)nOut); - //if( zOut==0 ){ - // return; - //} - //loopLimit = nStr - nPattern; - //for(i=j=0; i<=loopLimit; i++){ - // if( zStr[i]!=zPattern[0] || memcmp(&zStr[i], zPattern, nPattern) ){ - // zOut[j++] = zStr[i]; - // }else{ - // u8 *zOld; - // sqlite3 db = sqlite3_context_db_handle( context ); - // nOut += nRep - nPattern; - //testcase( nOut-1==db->aLimit[SQLITE_LIMIT_LENGTH] ); - //testcase( nOut-2==db->aLimit[SQLITE_LIMIT_LENGTH] ); - //if( nOut-1>db->aLimit[SQLITE_LIMIT_LENGTH] ){ - // sqlite3_result_error_toobig(context); - // sqlite3_free(zOut); - // return; - // } - // zOld = zOut; - // zOut = sqlite3_realloc(zOut, (int)nOut); - // if( zOut==0 ){ - // sqlite3_result_error_nomem(context); - // sqlite3_free(zOld); - // return; - // } - // memcpy(&zOut[j], zRep, nRep); - // j += nRep; - // i += nPattern-1; - // } - //} - //Debug.Assert( j+nStr-i+1==nOut ); - //memcpy(&zOut[j], zStr[i], nStr-i); - //j += nStr - i; - //Debug.Assert( j<=nOut ); - //zOut[j] = 0; - try - { - zOut = zStr.Replace( zPattern, zRep ); - j = zOut.Length; - } - catch - { - j = 0; + /* + ** The zeroblob(N) function returns a zero-filled blob of size N bytes. + */ + static void zeroblobFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + i64 n; + sqlite3 db = sqlite3_context_db_handle(context); + Debug.Assert(argc == 1); + UNUSED_PARAMETER(argc); + n = sqlite3_value_int64(argv[0]); + testcase(n == db.aLimit[SQLITE_LIMIT_LENGTH]); + testcase(n == db.aLimit[SQLITE_LIMIT_LENGTH] + 1); + if (n > db.aLimit[SQLITE_LIMIT_LENGTH]) { + sqlite3_result_error_toobig(context); + } else { + sqlite3_result_zeroblob(context, (int)n);/* IMP: R-00293-64994 */ + } } - } - if ( j == 0 || j > sqlite3_context_db_handle( context ).aLimit[SQLITE_LIMIT_LENGTH] ) - { - sqlite3_result_error_toobig( context ); - } - else - { - sqlite3_result_text( context, zOut, j, null );//sqlite3_free ); - } - } - /* - ** Implementation of the TRIM(), LTRIM(), and RTRIM() functions. - ** The userdata is 0x1 for left trim, 0x2 for right trim, 0x3 for both. - */ - static void trimFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - string zIn; /* Input string */ - string zCharSet; /* Set of characters to trim */ - int nIn; /* Number of bytes in input */ - int izIn = 0; /* C# string pointer */ - int flags; /* 1: trimleft 2: trimright 3: trim */ - int i; /* Loop counter */ - int[] aLen = null; /* Length of each character in zCharSet */ - byte[][] azChar = null; /* Individual characters in zCharSet */ - int nChar = 0; /* Number of characters in zCharSet */ - byte[] zBytes = null; - byte[] zBlob = null; - - if ( sqlite3_value_type( argv[0] ) == SQLITE_NULL ) - { - return; - } - zIn = sqlite3_value_text( argv[0] ); - if ( zIn == null ) - return; - nIn = sqlite3_value_bytes( argv[0] ); - zBlob = sqlite3_value_blob( argv[0] ); - //Debug.Assert( zIn == sqlite3_value_text( argv[0] ) ); - if ( argc == 1 ) - { - int[] lenOne = new int[] { 1 }; - byte[] azOne = new byte[] { (u8)' ' };//static unsigned char * const azOne[] = { (u8*)" " }; - nChar = 1; - aLen = lenOne; - azChar = new byte[1][]; - azChar[0] = azOne; - zCharSet = null; - } - else if ( ( zCharSet = sqlite3_value_text( argv[1] ) ) == null ) - { - return; - } - else - { - if ( ( zBytes = sqlite3_value_blob( argv[1] ) ) != null ) - { - int iz = 0; - for ( nChar = 0; iz < zBytes.Length; nChar++ ) - { - SQLITE_SKIP_UTF8( zBytes, ref iz ); - } - if ( nChar > 0 ) - { - azChar = new byte[nChar][];//contextMalloc(context, ((i64)nChar)*(sizeof(char*)+1)); - if ( azChar == null ) - { - return; + /* + ** The replace() function. Three arguments are all strings: call + ** them A, B, and C. The result is also a string which is derived + ** from A by replacing every occurance of B with C. The match + ** must be exact. Collating sequences are not used. + */ + static void replaceFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + string zStr; /* The input string A */ + string zPattern; /* The pattern string B */ + string zRep; /* The replacement string C */ + string zOut = null; /* The output */ + int nStr; /* Size of zStr */ + int nOut; /* Maximum size of zOut */ + //int loopLimit; /* Last zStr[] that might match zPattern[] */ + int i, j = 0; /* Loop counters */ + + Debug.Assert(argc == 3); + UNUSED_PARAMETER(argc); + zStr = sqlite3_value_text(argv[0]); + if (zStr == null) + return; + nStr = sqlite3_value_bytes(argv[0]); + Debug.Assert(zStr == sqlite3_value_text(argv[0])); /* No encoding change */ + zPattern = sqlite3_value_text(argv[1]); + if (zPattern == null) { + Debug.Assert(sqlite3_value_type(argv[1]) == SQLITE_NULL + //|| sqlite3_context_db_handle( context ).mallocFailed != 0 + ); + return; } - aLen = new int[nChar]; - - int iz0 = 0; - int iz1 = 0; - for ( int ii = 0; ii < nChar; ii++ ) - { - SQLITE_SKIP_UTF8( zBytes, ref iz1 ); - aLen[ii] = iz1 - iz0; - azChar[ii] = new byte[aLen[ii]]; - Buffer.BlockCopy( zBytes, iz0, azChar[ii], 0, azChar[ii].Length ); - iz0 = iz1; + if (zPattern == "") { + Debug.Assert(sqlite3_value_type(argv[1]) != SQLITE_NULL); + sqlite3_result_value(context, argv[0]); + return; } - } - } - } - if ( nChar > 0 ) - { - flags = (int)sqlite3_user_data( context ); // flags = SQLITE_PTR_TO_INT(sqlite3_user_data(context)); - if ( ( flags & 1 ) != 0 ) - { - while ( nIn > 0 ) - { - int len = 0; - for ( i = 0; i < nChar; i++ ) - { - len = aLen[i]; - if ( len <= nIn && memcmp( zBlob, izIn, azChar[i], len ) == 0 ) - break; + ////nPattern = sqlite3_value_bytes( argv[1] ); + Debug.Assert(zPattern == sqlite3_value_text(argv[1])); /* No encoding change */ + zRep = sqlite3_value_text(argv[2]); + if (zRep == null) + return; + ////nRep = sqlite3_value_bytes( argv[2] ); + Debug.Assert(zRep == sqlite3_value_text(argv[2])); + nOut = nStr + 1; + Debug.Assert(nOut < SQLITE_MAX_LENGTH); + if (nOut <= sqlite3_context_db_handle(context).aLimit[SQLITE_LIMIT_LENGTH]) { + //int nPattern; /* Size of zPattern */ + //int nRep; /* Size of zRep */ + //zOut = contextMalloc(context, (i64)nOut); + //if( zOut==0 ){ + // return; + //} + //loopLimit = nStr - nPattern; + //for(i=j=0; i<=loopLimit; i++){ + // if( zStr[i]!=zPattern[0] || memcmp(&zStr[i], zPattern, nPattern) ){ + // zOut[j++] = zStr[i]; + // }else{ + // u8 *zOld; + // sqlite3 db = sqlite3_context_db_handle( context ); + // nOut += nRep - nPattern; + //testcase( nOut-1==db->aLimit[SQLITE_LIMIT_LENGTH] ); + //testcase( nOut-2==db->aLimit[SQLITE_LIMIT_LENGTH] ); + //if( nOut-1>db->aLimit[SQLITE_LIMIT_LENGTH] ){ + // sqlite3_result_error_toobig(context); + // sqlite3_free(zOut); + // return; + // } + // zOld = zOut; + // zOut = sqlite3_realloc(zOut, (int)nOut); + // if( zOut==0 ){ + // sqlite3_result_error_nomem(context); + // sqlite3_free(zOld); + // return; + // } + // memcpy(&zOut[j], zRep, nRep); + // j += nRep; + // i += nPattern-1; + // } + //} + //Debug.Assert( j+nStr-i+1==nOut ); + //memcpy(&zOut[j], zStr[i], nStr-i); + //j += nStr - i; + //Debug.Assert( j<=nOut ); + //zOut[j] = 0; + try { + zOut = zStr.Replace(zPattern, zRep); + j = zOut.Length; + } catch { + j = 0; + } } - if ( i >= nChar ) - break; - izIn += len; - nIn -= len; - } - } - if ( ( flags & 2 ) != 0 ) - { - while ( nIn > 0 ) - { - int len = 0; - for ( i = 0; i < nChar; i++ ) - { - len = aLen[i]; - if ( len <= nIn && memcmp( zBlob, izIn + nIn - len, azChar[i], len ) == 0 ) - break; + if (j == 0 || j > sqlite3_context_db_handle(context).aLimit[SQLITE_LIMIT_LENGTH]) { + sqlite3_result_error_toobig(context); + } else { + sqlite3_result_text(context, zOut, j, null);//sqlite3_free ); } - if ( i >= nChar ) - break; - nIn -= len; - } } - if ( zCharSet != null ) - { - //sqlite3_free( ref azChar ); + + /* + ** Implementation of the TRIM(), LTRIM(), and RTRIM() functions. + ** The userdata is 0x1 for left trim, 0x2 for right trim, 0x3 for both. + */ + static void trimFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + string zIn; /* Input string */ + string zCharSet; /* Set of characters to trim */ + int nIn; /* Number of bytes in input */ + int izIn = 0; /* C# string pointer */ + int flags; /* 1: trimleft 2: trimright 3: trim */ + int i; /* Loop counter */ + int[] aLen = null; /* Length of each character in zCharSet */ + byte[][] azChar = null; /* Individual characters in zCharSet */ + int nChar = 0; /* Number of characters in zCharSet */ + byte[] zBytes = null; + byte[] zBlob = null; + + if (sqlite3_value_type(argv[0]) == SQLITE_NULL) { + return; + } + zIn = sqlite3_value_text(argv[0]); + if (zIn == null) + return; + nIn = sqlite3_value_bytes(argv[0]); + zBlob = sqlite3_value_blob(argv[0]); + //Debug.Assert( zIn == sqlite3_value_text( argv[0] ) ); + if (argc == 1) { + int[] lenOne = new int[] { 1 }; + byte[] azOne = new byte[] { (u8)' ' };//static unsigned char * const azOne[] = { (u8*)" " }; + nChar = 1; + aLen = lenOne; + azChar = new byte[1][]; + azChar[0] = azOne; + zCharSet = null; + } else if ((zCharSet = sqlite3_value_text(argv[1])) == null) { + return; + } else { + if ((zBytes = sqlite3_value_blob(argv[1])) != null) { + int iz = 0; + for (nChar = 0; iz < zBytes.Length; nChar++) { + SQLITE_SKIP_UTF8(zBytes, ref iz); + } + if (nChar > 0) { + azChar = new byte[nChar][];//contextMalloc(context, ((i64)nChar)*(sizeof(char*)+1)); + if (azChar == null) { + return; + } + aLen = new int[nChar]; + + int iz0 = 0; + int iz1 = 0; + for (int ii = 0; ii < nChar; ii++) { + SQLITE_SKIP_UTF8(zBytes, ref iz1); + aLen[ii] = iz1 - iz0; + azChar[ii] = new byte[aLen[ii]]; + Buffer.BlockCopy(zBytes, iz0, azChar[ii], 0, azChar[ii].Length); + iz0 = iz1; + } + } + } + } + if (nChar > 0) { + flags = (int)sqlite3_user_data(context); // flags = SQLITE_PTR_TO_INT(sqlite3_user_data(context)); + if ((flags & 1) != 0) { + while (nIn > 0) { + int len = 0; + for (i = 0; i < nChar; i++) { + len = aLen[i]; + if (len <= nIn && memcmp(zBlob, izIn, azChar[i], len) == 0) + break; + } + if (i >= nChar) + break; + izIn += len; + nIn -= len; + } + } + if ((flags & 2) != 0) { + while (nIn > 0) { + int len = 0; + for (i = 0; i < nChar; i++) { + len = aLen[i]; + if (len <= nIn && memcmp(zBlob, izIn + nIn - len, azChar[i], len) == 0) + break; + } + if (i >= nChar) + break; + nIn -= len; + } + } + if (zCharSet != null) { + //sqlite3_free( ref azChar ); + } + } + StringBuilder sb = new StringBuilder(nIn); + for (i = 0; i < nIn; i++) + sb.Append((char)zBlob[izIn + i]); + sqlite3_result_text(context, sb, nIn, SQLITE_TRANSIENT); } - } - StringBuilder sb = new StringBuilder( nIn ); - for ( i = 0; i < nIn; i++ ) - sb.Append( (char)zBlob[izIn + i] ); - sqlite3_result_text( context, sb, nIn, SQLITE_TRANSIENT ); - } - /* IMP: R-25361-16150 This function is omitted from SQLite by default. It - ** is only available if the SQLITE_SOUNDEX compile-time option is used - ** when SQLite is built. - */ + /* IMP: R-25361-16150 This function is omitted from SQLite by default. It + ** is only available if the SQLITE_SOUNDEX compile-time option is used + ** when SQLite is built. + */ #if SQLITE_SOUNDEX /* ** Compute the soundex encoding of a word. @@ -1541,213 +1370,179 @@ sqlite3_value[] argv #endif //* SQLITE_SOUNDEX */ #if !SQLITE_OMIT_LOAD_EXTENSION - /* -** A function that loads a shared-library extension then returns NULL. -*/ - static void loadExt( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - string zFile = sqlite3_value_text( argv[0] ); - string zProc; - sqlite3 db = (sqlite3)sqlite3_context_db_handle( context ); - string zErrMsg = ""; - - if ( argc == 2 ) - { - zProc = sqlite3_value_text( argv[1] ); - } - else - { - zProc = ""; - } - if ( zFile != null && sqlite3_load_extension( db, zFile, zProc, ref zErrMsg ) != 0 ) - { - sqlite3_result_error( context, zErrMsg, -1 ); - sqlite3DbFree( db, ref zErrMsg ); - } - } -#endif - - /* -** An instance of the following structure holds the context of a -** sum() or avg() aggregate computation. -*/ - //typedef struct SumCtx SumCtx; - public class SumCtx - { - public double rSum; /* Floating point sum */ - public i64 iSum; /* Integer sum */ - public i64 cnt; /* Number of elements summed */ - public int overflow; /* True if integer overflow seen */ - public bool approx; /* True if non-integer value was input to the sum */ - public Mem _M; - public Mem Context - { - get - { - return _M; - } - set - { - _M = value; - if ( _M == null || _M.z == null ) - iSum = 0; - else - iSum = Convert.ToInt64( _M.z ); + /* + ** A function that loads a shared-library extension then returns NULL. + */ + static void loadExt( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + string zFile = sqlite3_value_text(argv[0]); + string zProc; + sqlite3 db = (sqlite3)sqlite3_context_db_handle(context); + string zErrMsg = ""; + + if (argc == 2) { + zProc = sqlite3_value_text(argv[1]); + } else { + zProc = ""; + } + if (zFile != null && sqlite3_load_extension(db, zFile, zProc, ref zErrMsg) != 0) { + sqlite3_result_error(context, zErrMsg, -1); + sqlite3DbFree(db, ref zErrMsg); + } } - } - }; +#endif - /* - ** Routines used to compute the sum, average, and total. - ** - ** The SUM() function follows the (broken) SQL standard which means - ** that it returns NULL if it sums over no inputs. TOTAL returns - ** 0.0 in that case. In addition, TOTAL always returns a float where - ** SUM might return an integer if it never encounters a floating point - ** value. TOTAL never fails, but SUM might through an exception if - ** it overflows an integer. + /* + ** An instance of the following structure holds the context of a + ** sum() or avg() aggregate computation. */ - static void sumStep( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - SumCtx p; - - int type; - Debug.Assert( argc == 1 ); - UNUSED_PARAMETER( argc ); - Mem pMem = sqlite3_aggregate_context( context, 1 );//sizeof(*p)); - if ( pMem._SumCtx == null ) - pMem._SumCtx = new SumCtx(); - p = pMem._SumCtx; - if ( p.Context == null ) - p.Context = pMem; - type = sqlite3_value_numeric_type( argv[0] ); - if ( p != null && type != SQLITE_NULL ) - { - p.cnt++; - if ( type == SQLITE_INTEGER ) - { - i64 v = sqlite3_value_int64( argv[0] ); - p.rSum += v; - if ( !( p.approx | p.overflow != 0 ) && 0 != sqlite3AddInt64( ref p.iSum, v ) ) - { - p.overflow = 1; - } - } - else - { - p.rSum += sqlite3_value_double( argv[0] ); - p.approx = true; - } - } - } - static void sumFinalize( sqlite3_context context ) - { - SumCtx p = null; - Mem pMem = sqlite3_aggregate_context( context, 0 ); - if ( pMem != null ) - p = pMem._SumCtx; - if ( p != null && p.cnt > 0 ) - { - if ( p.overflow != 0 ) - { - sqlite3_result_error( context, "integer overflow", -1 ); - } - else if ( p.approx ) - { - sqlite3_result_double( context, p.rSum ); + //typedef struct SumCtx SumCtx; + public class SumCtx { + public double rSum; /* Floating point sum */ + public i64 iSum; /* Integer sum */ + public i64 cnt; /* Number of elements summed */ + public int overflow; /* True if integer overflow seen */ + public bool approx; /* True if non-integer value was input to the sum */ + public Mem _M; + public Mem Context { + get { + return _M; + } + set { + _M = value; + if (_M == null || _M.z == null) + iSum = 0; + else + iSum = Convert.ToInt64(_M.z); + } + } + }; + + /* + ** Routines used to compute the sum, average, and total. + ** + ** The SUM() function follows the (broken) SQL standard which means + ** that it returns NULL if it sums over no inputs. TOTAL returns + ** 0.0 in that case. In addition, TOTAL always returns a float where + ** SUM might return an integer if it never encounters a floating point + ** value. TOTAL never fails, but SUM might through an exception if + ** it overflows an integer. + */ + static void sumStep( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + SumCtx p; + + int type; + Debug.Assert(argc == 1); + UNUSED_PARAMETER(argc); + Mem pMem = sqlite3_aggregate_context(context, 1);//sizeof(*p)); + if (pMem._SumCtx == null) + pMem._SumCtx = new SumCtx(); + p = pMem._SumCtx; + if (p.Context == null) + p.Context = pMem; + type = sqlite3_value_numeric_type(argv[0]); + if (p != null && type != SQLITE_NULL) { + p.cnt++; + if (type == SQLITE_INTEGER) { + i64 v = sqlite3_value_int64(argv[0]); + p.rSum += v; + if (!(p.approx | p.overflow != 0) && 0 != sqlite3AddInt64(ref p.iSum, v)) { + p.overflow = 1; + } + } else { + p.rSum += sqlite3_value_double(argv[0]); + p.approx = true; + } + } } - else - { - sqlite3_result_int64( context, p.iSum ); + static void sumFinalize(sqlite3_context context) { + SumCtx p = null; + Mem pMem = sqlite3_aggregate_context(context, 0); + if (pMem != null) + p = pMem._SumCtx; + if (p != null && p.cnt > 0) { + if (p.overflow != 0) { + sqlite3_result_error(context, "integer overflow", -1); + } else if (p.approx) { + sqlite3_result_double(context, p.rSum); + } else { + sqlite3_result_int64(context, p.iSum); + } + p.cnt = 0; // Reset for C# + } } - p.cnt = 0; // Reset for C# - } - } - - static void avgFinalize( sqlite3_context context ) - { - SumCtx p = null; - Mem pMem = sqlite3_aggregate_context( context, 0 ); - if ( pMem != null ) - p = pMem._SumCtx; - if ( p != null && p.cnt > 0 ) - { - sqlite3_result_double( context, p.rSum / (double)p.cnt ); - } - } - - static void totalFinalize( sqlite3_context context ) - { - SumCtx p = null; - Mem pMem = sqlite3_aggregate_context( context, 0 ); - if ( pMem != null ) - p = pMem._SumCtx; - /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ - sqlite3_result_double( context, p != null ? p.rSum : (double)0 ); - } - /* - ** The following structure keeps track of state information for the - ** count() aggregate function. - */ - //typedef struct CountCtx CountCtx; - public class CountCtx - { - i64 _n; - Mem _M; - public Mem Context - { - get - { - return _M; - } - set - { - _M = value; - if ( _M == null || _M.z == null ) - _n = 0; - else - _n = Convert.ToInt64( _M.z ); + static void avgFinalize(sqlite3_context context) { + SumCtx p = null; + Mem pMem = sqlite3_aggregate_context(context, 0); + if (pMem != null) + p = pMem._SumCtx; + if (p != null && p.cnt > 0) { + sqlite3_result_double(context, p.rSum / (double)p.cnt); + } } - } - public i64 n - { - get - { - return _n; + + static void totalFinalize(sqlite3_context context) { + SumCtx p = null; + Mem pMem = sqlite3_aggregate_context(context, 0); + if (pMem != null) + p = pMem._SumCtx; + /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ + sqlite3_result_double(context, p != null ? p.rSum : (double)0); } - set - { - _n = value; - if ( _M != null ) - _M.z = _n.ToString(); + + /* + ** The following structure keeps track of state information for the + ** count() aggregate function. + */ + //typedef struct CountCtx CountCtx; + public class CountCtx { + i64 _n; + Mem _M; + public Mem Context { + get { + return _M; + } + set { + _M = value; + if (_M == null || _M.z == null) + _n = 0; + else + _n = Convert.ToInt64(_M.z); + } + } + public i64 n { + get { + return _n; + } + set { + _n = value; + if (_M != null) + _M.z = _n.ToString(); + } + } } - } - } - /* - ** Routines to implement the count() aggregate function. - */ - static void countStep( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - CountCtx p = new CountCtx(); - p.Context = sqlite3_aggregate_context( context, 1 );//sizeof(*p)); - if ( ( argc == 0 || SQLITE_NULL != sqlite3_value_type( argv[0] ) ) && p.Context != null ) - { - p.n++; - } + /* + ** Routines to implement the count() aggregate function. + */ + static void countStep( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + CountCtx p = new CountCtx(); + p.Context = sqlite3_aggregate_context(context, 1);//sizeof(*p)); + if ((argc == 0 || SQLITE_NULL != sqlite3_value_type(argv[0])) && p.Context != null) { + p.n++; + } #if !SQLITE_OMIT_DEPRECATED /* The sqlite3_aggregate_count() function is deprecated. But just to make ** sure it still operates correctly, verify that its count agrees with our @@ -1756,302 +1551,268 @@ sqlite3_value[] argv Debug.Assert( argc == 1 || p == null || p.n > 0x7fffffff || p.n == sqlite3_aggregate_count( context ) ); #endif - } + } - static void countFinalize( sqlite3_context context ) - { - CountCtx p = new CountCtx(); - p.Context = sqlite3_aggregate_context( context, 0 ); - sqlite3_result_int64( context, p != null ? p.n : 0 ); - } + static void countFinalize(sqlite3_context context) { + CountCtx p = new CountCtx(); + p.Context = sqlite3_aggregate_context(context, 0); + sqlite3_result_int64(context, p != null ? p.n : 0); + } - /* - ** Routines to implement min() and max() aggregate functions. - */ - static void minmaxStep( - sqlite3_context context, - int NotUsed, - sqlite3_value[] argv - ) - { - Mem pArg = (Mem)argv[0]; - Mem pBest; - UNUSED_PARAMETER( NotUsed ); - - if ( sqlite3_value_type( argv[0] ) == SQLITE_NULL ) - return; - pBest = (Mem)sqlite3_aggregate_context( context, 1 );//sizeof(*pBest)); - //if ( pBest == null ) return; - - if ( pBest.flags != 0 ) - { - bool max; - int cmp; - CollSeq pColl = sqlite3GetFuncCollSeq( context ); - /* This step function is used for both the min() and max() aggregates, - ** the only difference between the two being that the sense of the - ** comparison is inverted. For the max() aggregate, the - ** sqlite3_context_db_handle() function returns (void *)-1. For min() it - ** returns (void *)db, where db is the sqlite3* database pointer. - ** Therefore the next statement sets variable 'max' to 1 for the max() - ** aggregate, or 0 for min(). + /* + ** Routines to implement min() and max() aggregate functions. */ - max = sqlite3_context_db_handle( context ) != null && (int)sqlite3_user_data( context ) != 0; - cmp = sqlite3MemCompare( pBest, pArg, pColl ); - if ( ( max && cmp < 0 ) || ( !max && cmp > 0 ) ) - { - sqlite3VdbeMemCopy( pBest, pArg ); + static void minmaxStep( + sqlite3_context context, + int NotUsed, + sqlite3_value[] argv + ) { + Mem pArg = (Mem)argv[0]; + Mem pBest; + UNUSED_PARAMETER(NotUsed); + + if (sqlite3_value_type(argv[0]) == SQLITE_NULL) + return; + pBest = (Mem)sqlite3_aggregate_context(context, 1);//sizeof(*pBest)); + //if ( pBest == null ) return; + + if (pBest.flags != 0) { + bool max; + int cmp; + CollSeq pColl = sqlite3GetFuncCollSeq(context); + /* This step function is used for both the min() and max() aggregates, + ** the only difference between the two being that the sense of the + ** comparison is inverted. For the max() aggregate, the + ** sqlite3_context_db_handle() function returns (void *)-1. For min() it + ** returns (void *)db, where db is the sqlite3* database pointer. + ** Therefore the next statement sets variable 'max' to 1 for the max() + ** aggregate, or 0 for min(). + */ + max = sqlite3_context_db_handle(context) != null && (int)sqlite3_user_data(context) != 0; + cmp = sqlite3MemCompare(pBest, pArg, pColl); + if ((max && cmp < 0) || (!max && cmp > 0)) { + sqlite3VdbeMemCopy(pBest, pArg); + } + } else { + sqlite3VdbeMemCopy(pBest, pArg); + } } - } - else - { - sqlite3VdbeMemCopy( pBest, pArg ); - } - } - static void minMaxFinalize( sqlite3_context context ) - { - sqlite3_value pRes; - pRes = (sqlite3_value)sqlite3_aggregate_context( context, 0 ); - if ( pRes != null ) - { - if ( ALWAYS( pRes.flags != 0 ) ) - { - sqlite3_result_value( context, pRes ); + static void minMaxFinalize(sqlite3_context context) { + sqlite3_value pRes; + pRes = (sqlite3_value)sqlite3_aggregate_context(context, 0); + if (pRes != null) { + if (ALWAYS(pRes.flags != 0)) { + sqlite3_result_value(context, pRes); + } + sqlite3VdbeMemRelease(pRes); + } } - sqlite3VdbeMemRelease( pRes ); - } - } - /* - ** group_concat(EXPR, ?SEPARATOR?) - */ - static void groupConcatStep( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) - { - string zVal; - //StrAccum pAccum; - string zSep; - int nVal, nSep; - Debug.Assert( argc == 1 || argc == 2 ); - if ( sqlite3_value_type( argv[0] ) == SQLITE_NULL ) - return; - Mem pMem = sqlite3_aggregate_context( context, 1 );//sizeof(*pAccum)); - if ( pMem._StrAccum == null ) - pMem._StrAccum = new StrAccum( 100 ); - //pAccum = pMem._StrAccum; - - //if ( pMem._StrAccum != null ) - //{ - sqlite3 db = sqlite3_context_db_handle( context ); - //int firstTerm = pMem._StrAccum.useMalloc == 0 ? 1 : 0; - //pMem._StrAccum.useMalloc = 2; - pMem._StrAccum.mxAlloc = db.aLimit[SQLITE_LIMIT_LENGTH]; - if ( pMem._StrAccum.Context == null ) // first term - pMem._StrAccum.Context = pMem; - else - { - if ( argc == 2 ) - { - zSep = sqlite3_value_text( argv[1] ); - nSep = sqlite3_value_bytes( argv[1] ); + /* + ** group_concat(EXPR, ?SEPARATOR?) + */ + static void groupConcatStep( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) { + string zVal; + //StrAccum pAccum; + string zSep; + int nVal, nSep; + Debug.Assert(argc == 1 || argc == 2); + if (sqlite3_value_type(argv[0]) == SQLITE_NULL) + return; + Mem pMem = sqlite3_aggregate_context(context, 1);//sizeof(*pAccum)); + if (pMem._StrAccum == null) + pMem._StrAccum = new StrAccum(100); + //pAccum = pMem._StrAccum; + + //if ( pMem._StrAccum != null ) + //{ + sqlite3 db = sqlite3_context_db_handle(context); + //int firstTerm = pMem._StrAccum.useMalloc == 0 ? 1 : 0; + //pMem._StrAccum.useMalloc = 2; + pMem._StrAccum.mxAlloc = db.aLimit[SQLITE_LIMIT_LENGTH]; + if (pMem._StrAccum.Context == null) // first term + pMem._StrAccum.Context = pMem; + else { + if (argc == 2) { + zSep = sqlite3_value_text(argv[1]); + nSep = sqlite3_value_bytes(argv[1]); + } else { + zSep = ","; + nSep = 1; + } + sqlite3StrAccumAppend(pMem._StrAccum, zSep, nSep); + } + zVal = sqlite3_value_text(argv[0]); + nVal = sqlite3_value_bytes(argv[0]); + sqlite3StrAccumAppend(pMem._StrAccum, zVal, nVal); + //} } - else - { - zSep = ","; - nSep = 1; + + static void groupConcatFinalize(sqlite3_context context) { + //StrAccum pAccum = null; + Mem pMem = sqlite3_aggregate_context(context, 0); + if (pMem != null) { + if (pMem._StrAccum == null) + pMem._StrAccum = new StrAccum(100); + StrAccum pAccum = pMem._StrAccum; + //} + //if ( pAccum != null ) + //{ + if (pAccum.tooBig) { + sqlite3_result_error_toobig(context); + } + //else if ( pAccum.mallocFailed != 0 ) + //{ + // sqlite3_result_error_nomem( context ); + //} + else { + sqlite3_result_text(context, sqlite3StrAccumFinish(pAccum), -1, + null); //sqlite3_free ); + } + } } - sqlite3StrAccumAppend( pMem._StrAccum, zSep, nSep ); - } - zVal = sqlite3_value_text( argv[0] ); - nVal = sqlite3_value_bytes( argv[0] ); - sqlite3StrAccumAppend( pMem._StrAccum, zVal, nVal ); - //} - } - static void groupConcatFinalize( sqlite3_context context ) - { - //StrAccum pAccum = null; - Mem pMem = sqlite3_aggregate_context( context, 0 ); - if ( pMem != null ) - { - if ( pMem._StrAccum == null ) - pMem._StrAccum = new StrAccum( 100 ); - StrAccum pAccum = pMem._StrAccum; - //} - //if ( pAccum != null ) - //{ - if ( pAccum.tooBig ) - { - sqlite3_result_error_toobig( context ); + /* + ** This routine does per-connection function registration. Most + ** of the built-in functions above are part of the global function set. + ** This routine only deals with those that are not global. + */ + public struct sFuncs { + public string zName; + public sbyte nArg; + public u8 argType; /* 1: 0, 2: 1, 3: 2,... N: N-1. */ + public u8 eTextRep; /* 1: UTF-16. 0: UTF-8 */ + public u8 needCollSeq; + public dxFunc xFunc; //(sqlite3_context*,int,sqlite3_value **); + + // Constructor + public sFuncs(string zName, sbyte nArg, u8 argType, u8 eTextRep, u8 needCollSeq, dxFunc xFunc) { + this.zName = zName; + this.nArg = nArg; + this.argType = argType; + this.eTextRep = eTextRep; + this.needCollSeq = needCollSeq; + this.xFunc = xFunc; + } + }; + + public struct sAggs { + public string zName; + public sbyte nArg; + public u8 argType; + public u8 needCollSeq; + public dxStep xStep; //(sqlite3_context*,int,sqlite3_value**); + public dxFinal xFinalize; //(sqlite3_context*); + // Constructor + public sAggs(string zName, sbyte nArg, u8 argType, u8 needCollSeq, dxStep xStep, dxFinal xFinalize) { + this.zName = zName; + this.nArg = nArg; + this.argType = argType; + this.needCollSeq = needCollSeq; + this.xStep = xStep; + this.xFinalize = xFinalize; + } } - //else if ( pAccum.mallocFailed != 0 ) - //{ - // sqlite3_result_error_nomem( context ); - //} - else - { - sqlite3_result_text( context, sqlite3StrAccumFinish( pAccum ), -1, - null ); //sqlite3_free ); + static void sqlite3RegisterBuiltinFunctions(sqlite3 db) { + int rc = sqlite3_overload_function(db, "MATCH", 2); + Debug.Assert(rc == SQLITE_NOMEM || rc == SQLITE_OK); + if (rc == SQLITE_NOMEM) { + //// db.mallocFailed = 1; + } } - } - } - /* - ** This routine does per-connection function registration. Most - ** of the built-in functions above are part of the global function set. - ** This routine only deals with those that are not global. - */ - public struct sFuncs - { - public string zName; - public sbyte nArg; - public u8 argType; /* 1: 0, 2: 1, 3: 2,... N: N-1. */ - public u8 eTextRep; /* 1: UTF-16. 0: UTF-8 */ - public u8 needCollSeq; - public dxFunc xFunc; //(sqlite3_context*,int,sqlite3_value **); - - // Constructor - public sFuncs( string zName, sbyte nArg, u8 argType, u8 eTextRep, u8 needCollSeq, dxFunc xFunc ) - { - this.zName = zName; - this.nArg = nArg; - this.argType = argType; - this.eTextRep = eTextRep; - this.needCollSeq = needCollSeq; - this.xFunc = xFunc; - } - }; - - public struct sAggs - { - public string zName; - public sbyte nArg; - public u8 argType; - public u8 needCollSeq; - public dxStep xStep; //(sqlite3_context*,int,sqlite3_value**); - public dxFinal xFinalize; //(sqlite3_context*); - // Constructor - public sAggs( string zName, sbyte nArg, u8 argType, u8 needCollSeq, dxStep xStep, dxFinal xFinalize ) - { - this.zName = zName; - this.nArg = nArg; - this.argType = argType; - this.needCollSeq = needCollSeq; - this.xStep = xStep; - this.xFinalize = xFinalize; - } - } - static void sqlite3RegisterBuiltinFunctions( sqlite3 db ) - { - int rc = sqlite3_overload_function( db, "MATCH", 2 ); - Debug.Assert( rc == SQLITE_NOMEM || rc == SQLITE_OK ); - if ( rc == SQLITE_NOMEM ) - { - //// db.mallocFailed = 1; - } - } + /* + ** Set the LIKEOPT flag on the 2-argument function with the given name. + */ + static void setLikeOptFlag(sqlite3 db, string zName, int flagVal) { + FuncDef pDef; + pDef = sqlite3FindFunction(db, zName, sqlite3Strlen30(zName), + 2, SQLITE_UTF8, 0); + if (ALWAYS(pDef != null)) { + pDef.flags = (byte)flagVal; + } + } - /* - ** Set the LIKEOPT flag on the 2-argument function with the given name. - */ - static void setLikeOptFlag( sqlite3 db, string zName, int flagVal ) - { - FuncDef pDef; - pDef = sqlite3FindFunction( db, zName, sqlite3Strlen30( zName ), - 2, SQLITE_UTF8, 0 ); - if ( ALWAYS( pDef != null ) ) - { - pDef.flags = (byte)flagVal; - } - } + /* + ** Register the built-in LIKE and GLOB functions. The caseSensitive + ** parameter determines whether or not the LIKE operator is case + ** sensitive. GLOB is always case sensitive. + */ + static void sqlite3RegisterLikeFunctions(sqlite3 db, int caseSensitive) { + compareInfo pInfo; + if (caseSensitive != 0) { + pInfo = likeInfoAlt; + } else { + pInfo = likeInfoNorm; + } + sqlite3CreateFunc(db, "like", 2, SQLITE_UTF8, pInfo, (dxFunc)likeFunc, null, null, null); + sqlite3CreateFunc(db, "like", 3, SQLITE_UTF8, pInfo, (dxFunc)likeFunc, null, null, null); + sqlite3CreateFunc(db, "glob", 2, SQLITE_UTF8, + globInfo, (dxFunc)likeFunc, null, null, null); + setLikeOptFlag(db, "glob", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE); + setLikeOptFlag(db, "like", + caseSensitive != 0 ? (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) : SQLITE_FUNC_LIKE); + } - /* - ** Register the built-in LIKE and GLOB functions. The caseSensitive - ** parameter determines whether or not the LIKE operator is case - ** sensitive. GLOB is always case sensitive. - */ - static void sqlite3RegisterLikeFunctions( sqlite3 db, int caseSensitive ) - { - compareInfo pInfo; - if ( caseSensitive != 0 ) - { - pInfo = likeInfoAlt; - } - else - { - pInfo = likeInfoNorm; - } - sqlite3CreateFunc( db, "like", 2, SQLITE_UTF8, pInfo, (dxFunc)likeFunc, null, null, null ); - sqlite3CreateFunc( db, "like", 3, SQLITE_UTF8, pInfo, (dxFunc)likeFunc, null, null, null ); - sqlite3CreateFunc( db, "glob", 2, SQLITE_UTF8, - globInfo, (dxFunc)likeFunc, null, null, null ); - setLikeOptFlag( db, "glob", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE ); - setLikeOptFlag( db, "like", - caseSensitive != 0 ? ( SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE ) : SQLITE_FUNC_LIKE ); - } + /* + ** pExpr points to an expression which implements a function. If + ** it is appropriate to apply the LIKE optimization to that function + ** then set aWc[0] through aWc[2] to the wildcard characters and + ** return TRUE. If the function is not a LIKE-style function then + ** return FALSE. + */ + static bool sqlite3IsLikeFunction(sqlite3 db, Expr pExpr, ref bool pIsNocase, char[] aWc) { + FuncDef pDef; + if (pExpr.op != TK_FUNCTION + || null == pExpr.x.pList + || pExpr.x.pList.nExpr != 2 + ) { + return false; + } + Debug.Assert(!ExprHasProperty(pExpr, EP_xIsSelect)); + pDef = sqlite3FindFunction(db, pExpr.u.zToken, sqlite3Strlen30(pExpr.u.zToken), + 2, SQLITE_UTF8, 0); + if (NEVER(pDef == null) || (pDef.flags & SQLITE_FUNC_LIKE) == 0) { + return false; + } - /* - ** pExpr points to an expression which implements a function. If - ** it is appropriate to apply the LIKE optimization to that function - ** then set aWc[0] through aWc[2] to the wildcard characters and - ** return TRUE. If the function is not a LIKE-style function then - ** return FALSE. - */ - static bool sqlite3IsLikeFunction( sqlite3 db, Expr pExpr, ref bool pIsNocase, char[] aWc ) - { - FuncDef pDef; - if ( pExpr.op != TK_FUNCTION - || null == pExpr.x.pList - || pExpr.x.pList.nExpr != 2 - ) - { - return false; - } - Debug.Assert( !ExprHasProperty( pExpr, EP_xIsSelect ) ); - pDef = sqlite3FindFunction( db, pExpr.u.zToken, sqlite3Strlen30( pExpr.u.zToken ), - 2, SQLITE_UTF8, 0 ); - if ( NEVER( pDef == null ) || ( pDef.flags & SQLITE_FUNC_LIKE ) == 0 ) - { - return false; - } - - /* The memcpy() statement assumes that the wildcard characters are - ** the first three statements in the compareInfo structure. The - ** Debug.Asserts() that follow verify that assumption - */ - //memcpy( aWc, pDef.pUserData, 3 ); - aWc[0] = ( (compareInfo)pDef.pUserData ).matchAll; - aWc[1] = ( (compareInfo)pDef.pUserData ).matchOne; - aWc[2] = ( (compareInfo)pDef.pUserData ).matchSet; - // Debug.Assert((char*)&likeInfoAlt == (char*)&likeInfoAlt.matchAll); - // Debug.Assert(&((char*)&likeInfoAlt)[1] == (char*)&likeInfoAlt.matchOne); - // Debug.Assert(&((char*)&likeInfoAlt)[2] == (char*)&likeInfoAlt.matchSet); - pIsNocase = ( pDef.flags & SQLITE_FUNC_CASE ) == 0; - return true; - } + /* The memcpy() statement assumes that the wildcard characters are + ** the first three statements in the compareInfo structure. The + ** Debug.Asserts() that follow verify that assumption + */ + //memcpy( aWc, pDef.pUserData, 3 ); + aWc[0] = ((compareInfo)pDef.pUserData).matchAll; + aWc[1] = ((compareInfo)pDef.pUserData).matchOne; + aWc[2] = ((compareInfo)pDef.pUserData).matchSet; + // Debug.Assert((char*)&likeInfoAlt == (char*)&likeInfoAlt.matchAll); + // Debug.Assert(&((char*)&likeInfoAlt)[1] == (char*)&likeInfoAlt.matchOne); + // Debug.Assert(&((char*)&likeInfoAlt)[2] == (char*)&likeInfoAlt.matchSet); + pIsNocase = (pDef.flags & SQLITE_FUNC_CASE) == 0; + return true; + } - /* - ** All all of the FuncDef structures in the aBuiltinFunc[] array above - ** to the global function hash table. This occurs at start-time (as - ** a consequence of calling sqlite3_initialize()). - ** - ** After this routine runs - */ - static void sqlite3RegisterGlobalFunctions() - { - /* - ** The following array holds FuncDef structures for all of the functions - ** defined in this file. - ** - ** The array cannot be constant since changes are made to the - ** FuncDef.pHash elements at start-time. The elements of this array - ** are read-only after initialization is complete. - */ - FuncDef[] aBuiltinFunc = { + /* + ** All all of the FuncDef structures in the aBuiltinFunc[] array above + ** to the global function hash table. This occurs at start-time (as + ** a consequence of calling sqlite3_initialize()). + ** + ** After this routine runs + */ + static void sqlite3RegisterGlobalFunctions() { + /* + ** The following array holds FuncDef structures for all of the functions + ** defined in this file. + ** + ** The array cannot be constant since changes are made to the + ** FuncDef.pHash elements at start-time. The elements of this array + ** are read-only after initialization is complete. + */ + FuncDef[] aBuiltinFunc = { FUNCTION("ltrim", 1, 1, 0, trimFunc ), FUNCTION("ltrim", 2, 1, 0, trimFunc ), FUNCTION("rtrim", 1, 2, 0, trimFunc ), @@ -2079,7 +1840,7 @@ static void sqlite3RegisterGlobalFunctions() FUNCTION("coalesce", 0, 0, 0, null ), /* FUNCTION(coalesce, -1, 0, 0, ifnullFunc ), */ // use versionFunc here just for a dummy placeholder -new FuncDef(-1,SQLITE_UTF8,SQLITE_FUNC_COALESCE,null,null,versionFunc,null,null,"coalesce",null,null), +new FuncDef(-1,SQLITE_UTF8,SQLITE_FUNC_COALESCE,null,null,versionFunc,null,null,"coalesce",null,null), FUNCTION("hex", 1, 0, 0, hexFunc ), /* FUNCTION(ifnull, 2, 0, 0, ifnullFunc ), */ // use versionFunc here just for a dummy placeholder @@ -2126,22 +1887,21 @@ static void sqlite3RegisterGlobalFunctions() LIKEFUNC("like", 3, likeInfoNorm, SQLITE_FUNC_LIKE), #endif FUNCTION("regexp", 2, 0, 0, regexpFunc ),}; - int i; + int i; #if SQLITE_OMIT_WSD FuncDefHash pHash = GLOBAL( FuncDefHash, sqlite3GlobalFunctions ); FuncDef[] aFunc = (FuncDef[])GLOBAL( FuncDef, aBuiltinFunc ); #else - FuncDefHash pHash = sqlite3GlobalFunctions; - FuncDef[] aFunc = aBuiltinFunc; + FuncDefHash pHash = sqlite3GlobalFunctions; + FuncDef[] aFunc = aBuiltinFunc; #endif - for ( i = 0; i < ArraySize( aBuiltinFunc ); i++ ) - { - sqlite3FuncDefInsert( pHash, aFunc[i] ); - } - sqlite3RegisterDateTimeFunctions(); + for (i = 0; i < ArraySize(aBuiltinFunc); i++) { + sqlite3FuncDefInsert(pHash, aFunc[i]); + } + sqlite3RegisterDateTimeFunctions(); #if !SQLITE_OMIT_ALTERTABLE - sqlite3AlterFunctions(); + sqlite3AlterFunctions(); #endif + } } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/global_c.cs b/Src/IronPython.SQLite/c#sqlite/global_c.cs index 5b8eb8102..5f48e98be 100644 --- a/Src/IronPython.SQLite/c#sqlite/global_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/global_c.cs @@ -1,119 +1,111 @@ -using System; -using System.Diagnostics; -using System.Text; +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2008 June 13 + ** + ** 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 contains definitions of global variables and contants. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" -namespace Community.CsharpSqlite -{ - using sqlite3_value = Sqlite3.Mem; - public partial class Sqlite3 - { - /* - ** 2008 June 13 - ** - ** 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 contains definitions of global variables and contants. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - - - /* An array to map all upper-case characters into their corresponding - ** lower-case character. - ** - ** SQLite only considers US-ASCII (or EBCDIC) characters. We do not - ** handle case conversions for the UTF character set since the tables - ** involved are nearly as big or bigger than SQLite itself. - */ - /* An array to map all upper-case characters into their corresponding - ** lower-case character. - */ -// -// Replaced in C# with sqlite3UpperToLower class -// static int[] sqlite3UpperToLower = new int[] { -//#if SQLITE_ASCII -//0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, -//18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -//36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, -//54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 97, 98, 99,100,101,102,103, -//104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121, -//122, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,102,103,104,105,106,107, -//108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125, -//126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, -//144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161, -//162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179, -//180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197, -//198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215, -//216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233, -//234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251, -//252,253,254,255 -//#endif -//#if SQLITE_EBCDIC -//0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 0x */ -//16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 1x */ -//32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 2x */ -//48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 3x */ -//64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 4x */ -//80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 5x */ -//96, 97, 66, 67, 68, 69, 70, 71, 72, 73,106,107,108,109,110,111, /* 6x */ -//112, 81, 82, 83, 84, 85, 86, 87, 88, 89,122,123,124,125,126,127, /* 7x */ -//128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, /* 8x */ -//144,145,146,147,148,149,150,151,152,153,154,155,156,157,156,159, /* 9x */ -//160,161,162,163,164,165,166,167,168,169,170,171,140,141,142,175, /* Ax */ -//176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, /* Bx */ -//192,129,130,131,132,133,134,135,136,137,202,203,204,205,206,207, /* Cx */ -//208,145,146,147,148,149,150,151,152,153,218,219,220,221,222,223, /* Dx */ -//224,225,162,163,164,165,166,167,168,169,232,203,204,205,206,207, /* Ex */ -//239,240,241,242,243,244,245,246,247,248,249,219,220,221,222,255, /* Fx */ -//#endif -//}; + /* An array to map all upper-case characters into their corresponding + ** lower-case character. + ** + ** SQLite only considers US-ASCII (or EBCDIC) characters. We do not + ** handle case conversions for the UTF character set since the tables + ** involved are nearly as big or bigger than SQLite itself. + */ + /* An array to map all upper-case characters into their corresponding + ** lower-case character. + */ + // + // Replaced in C# with sqlite3UpperToLower class + // static int[] sqlite3UpperToLower = new int[] { + //#if SQLITE_ASCII + //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + //18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + //36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + //54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 97, 98, 99,100,101,102,103, + //104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121, + //122, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,102,103,104,105,106,107, + //108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125, + //126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, + //144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161, + //162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179, + //180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197, + //198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215, + //216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233, + //234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251, + //252,253,254,255 + //#endif + //#if SQLITE_EBCDIC + //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 0x */ + //16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 1x */ + //32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 2x */ + //48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 3x */ + //64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 4x */ + //80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 5x */ + //96, 97, 66, 67, 68, 69, 70, 71, 72, 73,106,107,108,109,110,111, /* 6x */ + //112, 81, 82, 83, 84, 85, 86, 87, 88, 89,122,123,124,125,126,127, /* 7x */ + //128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, /* 8x */ + //144,145,146,147,148,149,150,151,152,153,154,155,156,157,156,159, /* 9x */ + //160,161,162,163,164,165,166,167,168,169,170,171,140,141,142,175, /* Ax */ + //176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, /* Bx */ + //192,129,130,131,132,133,134,135,136,137,202,203,204,205,206,207, /* Cx */ + //208,145,146,147,148,149,150,151,152,153,218,219,220,221,222,223, /* Dx */ + //224,225,162,163,164,165,166,167,168,169,232,203,204,205,206,207, /* Ex */ + //239,240,241,242,243,244,245,246,247,248,249,219,220,221,222,255, /* Fx */ + //#endif + //}; - /* - ** The following 256 byte lookup table is used to support SQLites built-in - ** equivalents to the following standard library functions: - ** - ** isspace() 0x01 - ** isalpha() 0x02 - ** isdigit() 0x04 - ** isalnum() 0x06 - ** isxdigit() 0x08 - ** toupper() 0x20 - ** SQLite identifier character 0x40 - ** - ** Bit 0x20 is set if the mapped character requires translation to upper - ** case. i.e. if the character is a lower-case ASCII character. - ** If x is a lower-case ASCII character, then its upper-case equivalent - ** is (x - 0x20). Therefore toupper() can be implemented as: - ** - ** (x & ~(map[x]&0x20)) - ** - ** Standard function tolower() is implemented using the sqlite3UpperToLower[] - ** array. tolower() is used more often than toupper() by SQLite. - ** - ** Bit 0x40 is set if the character non-alphanumeric and can be used in an - ** SQLite identifier. Identifiers are alphanumerics, "_", "$", and any - ** non-ASCII UTF character. Hence the test for whether or not a character is - ** part of an identifier is 0x46. - ** - ** SQLite's versions are identical to the standard versions assuming a - ** locale of "C". They are implemented as macros in sqliteInt.h. - */ + /* + ** The following 256 byte lookup table is used to support SQLites built-in + ** equivalents to the following standard library functions: + ** + ** isspace() 0x01 + ** isalpha() 0x02 + ** isdigit() 0x04 + ** isalnum() 0x06 + ** isxdigit() 0x08 + ** toupper() 0x20 + ** SQLite identifier character 0x40 + ** + ** Bit 0x20 is set if the mapped character requires translation to upper + ** case. i.e. if the character is a lower-case ASCII character. + ** If x is a lower-case ASCII character, then its upper-case equivalent + ** is (x - 0x20). Therefore toupper() can be implemented as: + ** + ** (x & ~(map[x]&0x20)) + ** + ** Standard function tolower() is implemented using the sqlite3UpperToLower[] + ** array. tolower() is used more often than toupper() by SQLite. + ** + ** Bit 0x40 is set if the character non-alphanumeric and can be used in an + ** SQLite identifier. Identifiers are alphanumerics, "_", "$", and any + ** non-ASCII UTF character. Hence the test for whether or not a character is + ** part of an identifier is 0x46. + ** + ** SQLite's versions are identical to the standard versions assuming a + ** locale of "C". They are implemented as macros in sqliteInt.h. + */ #if SQLITE_ASCII - static byte[] sqlite3CtypeMap = new byte[] { + static byte[] sqlite3CtypeMap = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00..07 ........ */ 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, /* 08..0f ........ */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 10..17 ........ */ @@ -155,92 +147,92 @@ public partial class Sqlite3 #if SQLITE_USE_URI const bool SQLITE_USE_URI = true; #else -//# define SQLITE_USE_URI 0 - const bool SQLITE_USE_URI = false; + //# define SQLITE_USE_URI 0 + const bool SQLITE_USE_URI = false; #endif - /* -** The following singleton contains the global configuration for -** the SQLite library. -*/ - static Sqlite3Config sqlite3Config = new Sqlite3Config( - SQLITE_DEFAULT_MEMSTATUS, /* bMemstat */ - 1, /* bCoreMutex */ - SQLITE_THREADSAFE != 0, /* bFullMutex */ - SQLITE_USE_URI, /* bOpenUri */ - 0x7ffffffe, /* mxStrlen */ - 100, /* szLookaside */ - 500, /* nLookaside */ - new sqlite3_mem_methods(), /* m */ - new sqlite3_mutex_methods( null, null, null, null, null, null, null, null, null ), /* mutex */ - new sqlite3_pcache_methods(),/* pcache */ - null, /* pHeap */ - 0, /* nHeap */ - 0, 0, /* mnHeap, mxHeap */ - null, /* pScratch */ - 0, /* szScratch */ - 0, /* nScratch */ - null, /* pPage */ - SQLITE_DEFAULT_PAGE_SIZE, /* szPage */ - 0, /* nPage */ - 0, /* mxParserStack */ - false, /* sharedCacheEnabled */ - /* All the rest should always be initialized to zero */ - 0, /* isInit */ - 0, /* inProgress */ - 0, /* isMutexInit */ - 0, /* isMallocInit */ - 0, /* isPCacheInit */ - null, /* pInitMutex */ - 0, /* nRefInitMutex */ - null, /* xLog */ - 0, /* pLogArg */ - false /* bLocaltimeFault */ - ); - - /* - ** Hash table for global functions - functions common to all - ** database connections. After initialization, this table is - ** read-only. - */ - static FuncDefHash sqlite3GlobalFunctions; - /* - ** Constant tokens for values 0 and 1. + /* + ** The following singleton contains the global configuration for + ** the SQLite library. */ - static Token[] sqlite3IntTokens = { + static Sqlite3Config sqlite3Config = new Sqlite3Config( + SQLITE_DEFAULT_MEMSTATUS, /* bMemstat */ + 1, /* bCoreMutex */ + SQLITE_THREADSAFE != 0, /* bFullMutex */ + SQLITE_USE_URI, /* bOpenUri */ + 0x7ffffffe, /* mxStrlen */ + 100, /* szLookaside */ + 500, /* nLookaside */ + new sqlite3_mem_methods(), /* m */ + new sqlite3_mutex_methods(null, null, null, null, null, null, null, null, null), /* mutex */ + new sqlite3_pcache_methods(),/* pcache */ + null, /* pHeap */ + 0, /* nHeap */ + 0, 0, /* mnHeap, mxHeap */ + null, /* pScratch */ + 0, /* szScratch */ + 0, /* nScratch */ + null, /* pPage */ + SQLITE_DEFAULT_PAGE_SIZE, /* szPage */ + 0, /* nPage */ + 0, /* mxParserStack */ + false, /* sharedCacheEnabled */ + /* All the rest should always be initialized to zero */ + 0, /* isInit */ + 0, /* inProgress */ + 0, /* isMutexInit */ + 0, /* isMallocInit */ + 0, /* isPCacheInit */ + null, /* pInitMutex */ + 0, /* nRefInitMutex */ + null, /* xLog */ + 0, /* pLogArg */ + false /* bLocaltimeFault */ + ); + + /* + ** Hash table for global functions - functions common to all + ** database connections. After initialization, this table is + ** read-only. + */ + static FuncDefHash sqlite3GlobalFunctions; + /* + ** Constant tokens for values 0 and 1. + */ + static Token[] sqlite3IntTokens = { new Token( "0", 1 ), new Token( "1", 1 ) }; - /* - ** The value of the "pending" byte must be 0x40000000 (1 byte past the - ** 1-gibabyte boundary) in a compatible database. SQLite never uses - ** the database page that contains the pending byte. It never attempts - ** to read or write that page. The pending byte page is set assign - ** for use by the VFS layers as space for managing file locks. - ** - ** During testing, it is often desirable to move the pending byte to - ** a different position in the file. This allows code that has to - ** deal with the pending byte to run on files that are much smaller - ** than 1 GiB. The sqlite3_test_control() interface can be used to - ** move the pending byte. - ** - ** IMPORTANT: Changing the pending byte to any value other than - ** 0x40000000 results in an incompatible database file format! - ** Changing the pending byte during operating results in undefined - ** and dileterious behavior. - */ + /* + ** The value of the "pending" byte must be 0x40000000 (1 byte past the + ** 1-gibabyte boundary) in a compatible database. SQLite never uses + ** the database page that contains the pending byte. It never attempts + ** to read or write that page. The pending byte page is set assign + ** for use by the VFS layers as space for managing file locks. + ** + ** During testing, it is often desirable to move the pending byte to + ** a different position in the file. This allows code that has to + ** deal with the pending byte to run on files that are much smaller + ** than 1 GiB. The sqlite3_test_control() interface can be used to + ** move the pending byte. + ** + ** IMPORTANT: Changing the pending byte to any value other than + ** 0x40000000 results in an incompatible database file format! + ** Changing the pending byte during operating results in undefined + ** and dileterious behavior. + */ #if !SQLITE_OMIT_WSD - static int sqlite3PendingByte = 0x40000000; + static int sqlite3PendingByte = 0x40000000; #endif - //#include "opcodes.h" - /* - ** Properties of opcodes. The OPFLG_INITIALIZER macro is - ** created by mkopcodeh.awk during compilation. Data is obtained - ** from the comments following the "case OP_xxxx:" statements in - ** the vdbe.c file. - */ - public static int[] sqlite3OpcodeProperty; - } + //#include "opcodes.h" + /* + ** Properties of opcodes. The OPFLG_INITIALIZER macro is + ** created by mkopcodeh.awk during compilation. Data is obtained + ** from the comments following the "case OP_xxxx:" statements in + ** the vdbe.c file. + */ + public static int[] sqlite3OpcodeProperty; + } } diff --git a/Src/IronPython.SQLite/c#sqlite/hash_c.cs b/Src/IronPython.SQLite/c#sqlite/hash_c.cs index 6bdc08c51..f276dde05 100644 --- a/Src/IronPython.SQLite/c#sqlite/hash_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/hash_c.cs @@ -1,148 +1,127 @@ using System; using System.Diagnostics; -using System.Text; -using u8 = System.Byte; using u32 = System.UInt32; -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 2001 September 22 - ** - ** 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 is the implementation of generic hash-tables - ** used in SQLite. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2001 September 22 + ** + ** 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 is the implementation of generic hash-tables + ** used in SQLite. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include - /* Turn bulk memory into a hash table object by initializing the - ** fields of the Hash structure. - ** - ** "pNew" is a pointer to the hash table that is to be initialized. - */ - static void sqlite3HashInit( Hash pNew ) - { - Debug.Assert( pNew != null ); - pNew.first = null; - pNew.count = 0; - pNew.htsize = 0; - pNew.ht = null; - } - - /* Remove all entries from a hash table. Reclaim all memory. - ** Call this routine to delete a hash table or to reset a hash table - ** to the empty state. - */ - static void sqlite3HashClear( Hash pH ) - { - HashElem elem; /* For looping over all elements of the table */ - - Debug.Assert( pH != null ); - elem = pH.first; - pH.first = null; - //sqlite3_free( ref pH.ht ); - pH.ht = null; - pH.htsize = 0; - while ( elem != null ) - { - HashElem next_elem = elem.next; - ////sqlite3_free(ref elem ); - elem = next_elem; - } - pH.count = 0; - } + /* Turn bulk memory into a hash table object by initializing the + ** fields of the Hash structure. + ** + ** "pNew" is a pointer to the hash table that is to be initialized. + */ + static void sqlite3HashInit(Hash pNew) { + Debug.Assert(pNew != null); + pNew.first = null; + pNew.count = 0; + pNew.htsize = 0; + pNew.ht = null; + } - /* - ** The hashing function. - */ - static u32 strHash( string z, int nKey ) - { - int h = 0; - Debug.Assert( nKey >= 0 ); - int _z = 0; - while ( nKey > 0 ) - { - h = ( h << 3 ) ^ h ^ ( ( _z < z.Length ) ? (int)sqlite3UpperToLower[(byte)z[_z++]] : 0 ); - nKey--; - } - return (u32)h; - } + /* Remove all entries from a hash table. Reclaim all memory. + ** Call this routine to delete a hash table or to reset a hash table + ** to the empty state. + */ + static void sqlite3HashClear(Hash pH) { + HashElem elem; /* For looping over all elements of the table */ - /* Link pNew element into the hash table pH. If pEntry!=0 then also - ** insert pNew into the pEntry hash bucket. - */ - static void insertElement( - Hash pH, /* The complete hash table */ - _ht pEntry, /* The entry into which pNew is inserted */ - HashElem pNew /* The element to be inserted */ - ) - { - HashElem pHead; /* First element already in pEntry */ - if ( pEntry != null ) - { - pHead = pEntry.count != 0 ? pEntry.chain : null; - pEntry.count++; - pEntry.chain = pNew; - } - else - { - pHead = null; - } - if ( pHead != null ) - { - pNew.next = pHead; - pNew.prev = pHead.prev; - if ( pHead.prev != null ) - { - pHead.prev.next = pNew; + Debug.Assert(pH != null); + elem = pH.first; + pH.first = null; + //sqlite3_free( ref pH.ht ); + pH.ht = null; + pH.htsize = 0; + while (elem != null) { + HashElem next_elem = elem.next; + ////sqlite3_free(ref elem ); + elem = next_elem; + } + pH.count = 0; } - else - { - pH.first = pNew; + + /* + ** The hashing function. + */ + static u32 strHash(string z, int nKey) { + int h = 0; + Debug.Assert(nKey >= 0); + int _z = 0; + while (nKey > 0) { + h = (h << 3) ^ h ^ ((_z < z.Length) ? (int)sqlite3UpperToLower[(byte)z[_z++]] : 0); + nKey--; + } + return (u32)h; } - pHead.prev = pNew; - } - else - { - pNew.next = pH.first; - if ( pH.first != null ) - { - pH.first.prev = pNew; + + /* Link pNew element into the hash table pH. If pEntry!=0 then also + ** insert pNew into the pEntry hash bucket. + */ + static void insertElement( + Hash pH, /* The complete hash table */ + _ht pEntry, /* The entry into which pNew is inserted */ + HashElem pNew /* The element to be inserted */ + ) { + HashElem pHead; /* First element already in pEntry */ + if (pEntry != null) { + pHead = pEntry.count != 0 ? pEntry.chain : null; + pEntry.count++; + pEntry.chain = pNew; + } else { + pHead = null; + } + if (pHead != null) { + pNew.next = pHead; + pNew.prev = pHead.prev; + if (pHead.prev != null) { + pHead.prev.next = pNew; + } else { + pH.first = pNew; + } + pHead.prev = pNew; + } else { + pNew.next = pH.first; + if (pH.first != null) { + pH.first.prev = pNew; + } + pNew.prev = null; + pH.first = pNew; + } } - pNew.prev = null; - pH.first = pNew; - } - } - /* Resize the hash table so that it cantains "new_size" buckets. - ** - ** The hash table might fail to resize if sqlite3_malloc() fails or - ** if the new size is the same as the prior size. - ** Return TRUE if the resize occurs and false if not. - */ - static bool rehash( ref Hash pH, u32 new_size ) - { - _ht[] new_ht; /* The new hash table */ - HashElem elem; - HashElem next_elem; /* For looping over existing elements */ + /* Resize the hash table so that it cantains "new_size" buckets. + ** + ** The hash table might fail to resize if sqlite3_malloc() fails or + ** if the new size is the same as the prior size. + ** Return TRUE if the resize occurs and false if not. + */ + static bool rehash(ref Hash pH, u32 new_size) { + _ht[] new_ht; /* The new hash table */ + HashElem elem; + HashElem next_elem; /* For looping over existing elements */ #if SQLITE_MALLOC_SOFT_LIMIT if( new_size*sizeof(struct _ht)>SQLITE_MALLOC_SOFT_LIMIT ){ @@ -151,213 +130,181 @@ static bool rehash( ref Hash pH, u32 new_size ) if( new_size==pH->htsize ) return false; #endif - /* There is a call to sqlite3Malloc() inside rehash(). If there is -** already an allocation at pH.ht, then if this malloc() fails it -** is benign (since failing to resize a hash table is a performance -** hit only, not a fatal error). -*/ - sqlite3BeginBenignMalloc(); - new_ht = new _ht[new_size]; //(struct _ht )sqlite3Malloc( new_size*sizeof(struct _ht) ); - for ( int i = 0; i < new_size; i++ ) - new_ht[i] = new _ht(); - sqlite3EndBenignMalloc(); + /* There is a call to sqlite3Malloc() inside rehash(). If there is + ** already an allocation at pH.ht, then if this malloc() fails it + ** is benign (since failing to resize a hash table is a performance + ** hit only, not a fatal error). + */ + sqlite3BeginBenignMalloc(); + new_ht = new _ht[new_size]; //(struct _ht )sqlite3Malloc( new_size*sizeof(struct _ht) ); + for (int i = 0; i < new_size; i++) + new_ht[i] = new _ht(); + sqlite3EndBenignMalloc(); - if ( new_ht == null ) - return false; - //sqlite3_free( ref pH.ht ); - pH.ht = new_ht; - // pH.htsize = new_size = sqlite3MallocSize(new_ht)/sizeof(struct _ht); - //memset(new_ht, 0, new_size*sizeof(struct _ht)); - pH.htsize = new_size; + if (new_ht == null) + return false; + //sqlite3_free( ref pH.ht ); + pH.ht = new_ht; + // pH.htsize = new_size = sqlite3MallocSize(new_ht)/sizeof(struct _ht); + //memset(new_ht, 0, new_size*sizeof(struct _ht)); + pH.htsize = new_size; - for ( elem = pH.first, pH.first = null; elem != null; elem = next_elem ) - { - u32 h = strHash( elem.pKey, elem.nKey ) % new_size; - next_elem = elem.next; - insertElement( pH, new_ht[h], elem ); - } - return true; - } + for (elem = pH.first, pH.first = null; elem != null; elem = next_elem) { + u32 h = strHash(elem.pKey, elem.nKey) % new_size; + next_elem = elem.next; + insertElement(pH, new_ht[h], elem); + } + return true; + } - /* This function (for internal use only) locates an element in an - ** hash table that matches the given key. The hash for this key has - ** already been computed and is passed as the 4th parameter. - */ - static HashElem findElementGivenHash( - Hash pH, /* The pH to be searched */ - string pKey, /* The key we are searching for */ - int nKey, /* Bytes in key (not counting zero terminator) */ - u32 h /* The hash for this key. */ - ) - { - HashElem elem; /* Used to loop thru the element list */ - int count; /* Number of elements left to test */ + /* This function (for internal use only) locates an element in an + ** hash table that matches the given key. The hash for this key has + ** already been computed and is passed as the 4th parameter. + */ + static HashElem findElementGivenHash( + Hash pH, /* The pH to be searched */ + string pKey, /* The key we are searching for */ + int nKey, /* Bytes in key (not counting zero terminator) */ + u32 h /* The hash for this key. */ + ) { + HashElem elem; /* Used to loop thru the element list */ + int count; /* Number of elements left to test */ - if ( pH.ht != null && pH.ht[h] != null ) - { - _ht pEntry = pH.ht[h]; - elem = pEntry.chain; - count = (int)pEntry.count; - } - else - { - elem = pH.first; - count = (int)pH.count; - } - while ( count-- > 0 && ALWAYS( elem ) ) - { - if ( elem.nKey == nKey && elem.pKey.Equals( pKey, StringComparison.OrdinalIgnoreCase ) ) - { - return elem; + if (pH.ht != null && pH.ht[h] != null) { + _ht pEntry = pH.ht[h]; + elem = pEntry.chain; + count = (int)pEntry.count; + } else { + elem = pH.first; + count = (int)pH.count; + } + while (count-- > 0 && ALWAYS(elem)) { + if (elem.nKey == nKey && elem.pKey.Equals(pKey, StringComparison.OrdinalIgnoreCase)) { + return elem; + } + elem = elem.next; + } + return null; } - elem = elem.next; - } - return null; - } - /* Remove a single entry from the hash table given a pointer to that - ** element and a hash on the element's key. - */ - static void removeElementGivenHash( - Hash pH, /* The pH containing "elem" */ - ref HashElem elem, /* The element to be removed from the pH */ - u32 h /* Hash value for the element */ - ) - { - _ht pEntry; - if ( elem.prev != null ) - { - elem.prev.next = elem.next; - } - else - { - pH.first = elem.next; - } - if ( elem.next != null ) - { - elem.next.prev = elem.prev; - } - if ( pH.ht != null && pH.ht[h] != null ) - { - pEntry = pH.ht[h]; - if ( pEntry.chain == elem ) - { - pEntry.chain = elem.next; + /* Remove a single entry from the hash table given a pointer to that + ** element and a hash on the element's key. + */ + static void removeElementGivenHash( + Hash pH, /* The pH containing "elem" */ + ref HashElem elem, /* The element to be removed from the pH */ + u32 h /* Hash value for the element */ + ) { + _ht pEntry; + if (elem.prev != null) { + elem.prev.next = elem.next; + } else { + pH.first = elem.next; + } + if (elem.next != null) { + elem.next.prev = elem.prev; + } + if (pH.ht != null && pH.ht[h] != null) { + pEntry = pH.ht[h]; + if (pEntry.chain == elem) { + pEntry.chain = elem.next; + } + pEntry.count--; + Debug.Assert(pEntry.count >= 0); + } + //sqlite3_free( ref elem ); + pH.count--; + if (pH.count <= 0) { + Debug.Assert(pH.first == null); + Debug.Assert(pH.count == 0); + sqlite3HashClear(pH); + } } - pEntry.count--; - Debug.Assert( pEntry.count >= 0 ); - } - //sqlite3_free( ref elem ); - pH.count--; - if ( pH.count <= 0 ) - { - Debug.Assert( pH.first == null ); - Debug.Assert( pH.count == 0 ); - sqlite3HashClear( pH ); - } - } - /* Attempt to locate an element of the hash table pH with a key - ** that matches pKey,nKey. Return the data for this element if it is - ** found, or NULL if there is no match. - */ - static T sqlite3HashFind( Hash pH, string pKey, int nKey, T nullType ) where T : class - { - HashElem elem; /* The element that matches key */ - u32 h; /* A hash on key */ + /* Attempt to locate an element of the hash table pH with a key + ** that matches pKey,nKey. Return the data for this element if it is + ** found, or NULL if there is no match. + */ + static T sqlite3HashFind(Hash pH, string pKey, int nKey, T nullType) where T : class { + HashElem elem; /* The element that matches key */ + u32 h; /* A hash on key */ - Debug.Assert( pH != null ); - Debug.Assert( pKey != null ); - Debug.Assert( nKey >= 0 ); - if ( pH.ht != null ) - { - h = strHash( pKey, nKey ) % pH.htsize; - } - else - { - h = 0; - } - elem = findElementGivenHash( pH, pKey, nKey, h ); - return elem != null ? (T)elem.data : nullType; - } + Debug.Assert(pH != null); + Debug.Assert(pKey != null); + Debug.Assert(nKey >= 0); + if (pH.ht != null) { + h = strHash(pKey, nKey) % pH.htsize; + } else { + h = 0; + } + elem = findElementGivenHash(pH, pKey, nKey, h); + return elem != null ? (T)elem.data : nullType; + } - /* Insert an element into the hash table pH. The key is pKey,nKey - ** and the data is "data". - ** - ** If no element exists with a matching key, then a new - ** element is created and NULL is returned. - ** - ** If another element already exists with the same key, then the - ** new data replaces the old data and the old data is returned. - ** The key is not copied in this instance. If a malloc fails, then - ** the new data is returned and the hash table is unchanged. - ** - ** If the "data" parameter to this function is NULL, then the - ** element corresponding to "key" is removed from the hash table. - */ - static T sqlite3HashInsert( ref Hash pH, string pKey, int nKey, T data ) where T : class - { - u32 h; /* the hash of the key modulo hash table size */ + /* Insert an element into the hash table pH. The key is pKey,nKey + ** and the data is "data". + ** + ** If no element exists with a matching key, then a new + ** element is created and NULL is returned. + ** + ** If another element already exists with the same key, then the + ** new data replaces the old data and the old data is returned. + ** The key is not copied in this instance. If a malloc fails, then + ** the new data is returned and the hash table is unchanged. + ** + ** If the "data" parameter to this function is NULL, then the + ** element corresponding to "key" is removed from the hash table. + */ + static T sqlite3HashInsert(ref Hash pH, string pKey, int nKey, T data) where T : class { + u32 h; /* the hash of the key modulo hash table size */ - HashElem elem; /* Used to loop thru the element list */ - HashElem new_elem; /* New element added to the pH */ + HashElem elem; /* Used to loop thru the element list */ + HashElem new_elem; /* New element added to the pH */ - Debug.Assert( pH != null ); - Debug.Assert( pKey != null ); - Debug.Assert( nKey >= 0 ); + Debug.Assert(pH != null); + Debug.Assert(pKey != null); + Debug.Assert(nKey >= 0); - if ( pH.htsize != 0 ) - { - h = strHash( pKey, nKey ) % pH.htsize; - } - else - { - h = 0; - } - elem = findElementGivenHash( pH, pKey, nKey, h ); - if ( elem != null ) - { - T old_data = (T)elem.data; - if ( data == null ) - { - removeElementGivenHash( pH, ref elem, h ); - } - else - { - elem.data = data; - elem.pKey = pKey; - Debug.Assert( nKey == elem.nKey ); - } - return old_data; - } - if ( data == null ) - return data; - new_elem = new HashElem();//(HashElem)sqlite3Malloc( sizeof(HashElem) ); - if ( new_elem == null ) - return data; - new_elem.pKey = pKey; - new_elem.nKey = nKey; - new_elem.data = data; - pH.count++; - if ( pH.count >= 10 && pH.count > 2 * pH.htsize ) - { - if ( rehash( ref pH, pH.count * 2 ) ) - { - Debug.Assert( pH.htsize > 0 ); - h = strHash( pKey, nKey ) % pH.htsize; + if (pH.htsize != 0) { + h = strHash(pKey, nKey) % pH.htsize; + } else { + h = 0; + } + elem = findElementGivenHash(pH, pKey, nKey, h); + if (elem != null) { + T old_data = (T)elem.data; + if (data == null) { + removeElementGivenHash(pH, ref elem, h); + } else { + elem.data = data; + elem.pKey = pKey; + Debug.Assert(nKey == elem.nKey); + } + return old_data; + } + if (data == null) + return data; + new_elem = new HashElem();//(HashElem)sqlite3Malloc( sizeof(HashElem) ); + if (new_elem == null) + return data; + new_elem.pKey = pKey; + new_elem.nKey = nKey; + new_elem.data = data; + pH.count++; + if (pH.count >= 10 && pH.count > 2 * pH.htsize) { + if (rehash(ref pH, pH.count * 2)) { + Debug.Assert(pH.htsize > 0); + h = strHash(pKey, nKey) % pH.htsize; + } + } + if (pH.ht != null) { + insertElement(pH, pH.ht[h], new_elem); + + } else { + insertElement(pH, null, new_elem); + } + return null; } - } - if ( pH.ht != null ) - { - insertElement( pH, pH.ht[h], new_elem ); - } - else - { - insertElement( pH, null, new_elem ); - } - return null; } - - } } diff --git a/Src/IronPython.SQLite/c#sqlite/hwtime_c.cs b/Src/IronPython.SQLite/c#sqlite/hwtime_c.cs index 8fcb8ca3a..688f21d22 100644 --- a/Src/IronPython.SQLite/c#sqlite/hwtime_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/hwtime_c.cs @@ -1,42 +1,40 @@ -namespace Community.CsharpSqlite -{ - using sqlite_u3264 = System.UInt64; - - public partial class Sqlite3 - { - /* - ** 2008 May 27 - ** - ** 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 contains inline asm code for retrieving "high-performance" - ** counters for x86 class CPUs. - ** - ** $Id: hwtime.h,v 1.3 2008/08/01 14:33:15 shane Exp $ - ** - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ************************************************************************* - */ - //#if !_HWTIME_H_ - //#define _HWTIME_H_ - - /* - ** The following routine only works on pentium-class (or newer) processors. - ** It uses the RDTSC opcode to read the cycle count value out of the - ** processor and returns that value. This can be used for high-res - ** profiling. - */ -#if ((__GNUC__) || (_MSC_VER)) && ((i386) || (__i386__) || (_M_IX86)) +namespace Community.CsharpSqlite { + using sqlite_u3264 = System.UInt64; + + public partial class Sqlite3 { + /* + ** 2008 May 27 + ** + ** 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 contains inline asm code for retrieving "high-performance" + ** counters for x86 class CPUs. + ** + ** $Id: hwtime.h,v 1.3 2008/08/01 14:33:15 shane Exp $ + ** + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ************************************************************************* + */ + //#if !_HWTIME_H_ + //#define _HWTIME_H_ + + /* + ** The following routine only works on pentium-class (or newer) processors. + ** It uses the RDTSC opcode to read the cycle count value out of the + ** processor and returns that value. This can be used for high-res + ** profiling. + */ +#if ((__GNUC__) || (_MSC_VER)) && ((i386) || (__i386__) || (_M_IX86)) #if (__GNUC__) @@ -46,7 +44,7 @@ __inline__ sqlite_u3264 sqlite3Hwtime(void){ return (sqlite_u3264)hi << 32 | lo; } -#elif (_MSC_VER) +#elif (_MSC_VER) __declspec(naked) __inline sqlite_u3264 __cdecl sqlite3Hwtime(void){ __asm { @@ -65,7 +63,7 @@ __inline__ sqlite_u3264 sqlite3Hwtime(void){ return val; } -#elif ( (__GNUC__) && (__ppc__)) +#elif ((__GNUC__) && (__ppc__)) __inline__ sqlite_u3264 sqlite3Hwtime(void){ unsigned long long retval; @@ -82,22 +80,21 @@ bne 1b" #else - //#error Need implementation of sqlite3Hwtime() for your platform. + //#error Need implementation of sqlite3Hwtime() for your platform. - /* - ** To compile without implementing sqlite3Hwtime() for your platform, - ** you can remove the above #error and use the following - ** stub function. You will lose timing support for many - ** of the debugging and testing utilities, but it should at - ** least compile and run. - */ - static sqlite_u3264 sqlite3Hwtime() - { - return (sqlite_u3264)System.DateTime.Now.Ticks; - }// (sqlite_u3264)0 ); } + /* + ** To compile without implementing sqlite3Hwtime() for your platform, + ** you can remove the above #error and use the following + ** stub function. You will lose timing support for many + ** of the debugging and testing utilities, but it should at + ** least compile and run. + */ + static sqlite_u3264 sqlite3Hwtime() { + return (sqlite_u3264)System.DateTime.Now.Ticks; + }// (sqlite_u3264)0 ); } #endif - //#endif //* !_HWTIME_H_) */ - } + //#endif //* !_HWTIME_H_) */ + } } diff --git a/Src/IronPython.SQLite/c#sqlite/insert_c.cs b/Src/IronPython.SQLite/c#sqlite/insert_c.cs index f95558619..81566bb7f 100644 --- a/Src/IronPython.SQLite/c#sqlite/insert_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/insert_c.cs @@ -2,361 +2,332 @@ using System.Diagnostics; using System.Text; -using Pgno = System.UInt32; using u8 = System.Byte; -using u32 = System.UInt32; -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 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. - ** - ************************************************************************* - ** This file contains C code routines that are called by the parser - ** to handle INSERT statements in SQLite. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** This file contains C code routines that are called by the parser + ** to handle INSERT statements in SQLite. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" - /* - ** Generate code that will open a table for reading. - */ - static void sqlite3OpenTable( - Parse p, /* Generate code into this VDBE */ - int iCur, /* The cursor number of the table */ - int iDb, /* The database index in sqlite3.aDb[] */ - Table pTab, /* The table to be opened */ - int opcode /* OP_OpenRead or OP_OpenWrite */ - ) - { - Vdbe v; - if ( IsVirtual( pTab ) ) - return; - v = sqlite3GetVdbe( p ); - Debug.Assert( opcode == OP_OpenWrite || opcode == OP_OpenRead ); - sqlite3TableLock( p, iDb, pTab.tnum, ( opcode == OP_OpenWrite ) ? (byte)1 : (byte)0, pTab.zName ); - sqlite3VdbeAddOp3( v, opcode, iCur, pTab.tnum, iDb ); - sqlite3VdbeChangeP4( v, -1, ( pTab.nCol ), P4_INT32 );//SQLITE_INT_TO_PTR( pTab.nCol ), P4_INT32 ); - VdbeComment( v, "%s", pTab.zName ); - } + /* + ** Generate code that will open a table for reading. + */ + static void sqlite3OpenTable( + Parse p, /* Generate code into this VDBE */ + int iCur, /* The cursor number of the table */ + int iDb, /* The database index in sqlite3.aDb[] */ + Table pTab, /* The table to be opened */ + int opcode /* OP_OpenRead or OP_OpenWrite */ + ) { + Vdbe v; + if (IsVirtual(pTab)) + return; + v = sqlite3GetVdbe(p); + Debug.Assert(opcode == OP_OpenWrite || opcode == OP_OpenRead); + sqlite3TableLock(p, iDb, pTab.tnum, (opcode == OP_OpenWrite) ? (byte)1 : (byte)0, pTab.zName); + sqlite3VdbeAddOp3(v, opcode, iCur, pTab.tnum, iDb); + sqlite3VdbeChangeP4(v, -1, (pTab.nCol), P4_INT32);//SQLITE_INT_TO_PTR( pTab.nCol ), P4_INT32 ); + VdbeComment(v, "%s", pTab.zName); + } - /* - ** Return a pointer to the column affinity string associated with index - ** pIdx. A column affinity string has one character for each column in - ** the table, according to the affinity of the column: - ** - ** Character Column affinity - ** ------------------------------ - ** 'a' TEXT - ** 'b' NONE - ** 'c' NUMERIC - ** 'd' INTEGER - ** 'e' REAL - ** - ** An extra 'b' is appended to the end of the string to cover the - ** rowid that appears as the last column in every index. - ** - ** Memory for the buffer containing the column index affinity string - ** is managed along with the rest of the Index structure. It will be - ** released when sqlite3DeleteIndex() is called. - */ - static string sqlite3IndexAffinityStr( Vdbe v, Index pIdx ) - { - if ( pIdx.zColAff == null || pIdx.zColAff[0] == '\0' ) - { - /* The first time a column affinity string for a particular index is - ** required, it is allocated and populated here. It is then stored as - ** a member of the Index structure for subsequent use. + /* + ** Return a pointer to the column affinity string associated with index + ** pIdx. A column affinity string has one character for each column in + ** the table, according to the affinity of the column: + ** + ** Character Column affinity + ** ------------------------------ + ** 'a' TEXT + ** 'b' NONE + ** 'c' NUMERIC + ** 'd' INTEGER + ** 'e' REAL ** - ** The column affinity string will eventually be deleted by - ** sqliteDeleteIndex() when the Index structure itself is cleaned - ** up. + ** An extra 'b' is appended to the end of the string to cover the + ** rowid that appears as the last column in every index. + ** + ** Memory for the buffer containing the column index affinity string + ** is managed along with the rest of the Index structure. It will be + ** released when sqlite3DeleteIndex() is called. */ - int n; - Table pTab = pIdx.pTable; - sqlite3 db = sqlite3VdbeDb( v ); - StringBuilder pIdx_zColAff = new StringBuilder( pIdx.nColumn + 2 );// (char )sqlite3DbMallocRaw(0, pIdx->nColumn+2); - // if ( pIdx_zColAff == null ) - // { - // db.mallocFailed = 1; - // return null; - // } - for ( n = 0; n < pIdx.nColumn; n++ ) - { - pIdx_zColAff.Append( pTab.aCol[pIdx.aiColumn[n]].affinity ); + static string sqlite3IndexAffinityStr(Vdbe v, Index pIdx) { + if (pIdx.zColAff == null || pIdx.zColAff[0] == '\0') { + /* The first time a column affinity string for a particular index is + ** required, it is allocated and populated here. It is then stored as + ** a member of the Index structure for subsequent use. + ** + ** The column affinity string will eventually be deleted by + ** sqliteDeleteIndex() when the Index structure itself is cleaned + ** up. + */ + int n; + Table pTab = pIdx.pTable; + sqlite3 db = sqlite3VdbeDb(v); + StringBuilder pIdx_zColAff = new StringBuilder(pIdx.nColumn + 2);// (char )sqlite3DbMallocRaw(0, pIdx->nColumn+2); + // if ( pIdx_zColAff == null ) + // { + // db.mallocFailed = 1; + // return null; + // } + for (n = 0; n < pIdx.nColumn; n++) { + pIdx_zColAff.Append(pTab.aCol[pIdx.aiColumn[n]].affinity); + } + pIdx_zColAff.Append(SQLITE_AFF_NONE); + pIdx_zColAff.Append('\0'); + pIdx.zColAff = pIdx_zColAff.ToString(); + } + return pIdx.zColAff; } - pIdx_zColAff.Append( SQLITE_AFF_NONE ); - pIdx_zColAff.Append( '\0' ); - pIdx.zColAff = pIdx_zColAff.ToString(); - } - return pIdx.zColAff; - } - /* - ** Set P4 of the most recently inserted opcode to a column affinity - ** string for table pTab. A column affinity string has one character - ** for each column indexed by the index, according to the affinity of the - ** column: - ** - ** Character Column affinity - ** ------------------------------ - ** 'a' TEXT - ** 'b' NONE - ** 'c' NUMERIC - ** 'd' INTEGER - ** 'e' REAL - */ - static void sqlite3TableAffinityStr( Vdbe v, Table pTab ) - { - /* The first time a column affinity string for a particular table - ** is required, it is allocated and populated here. It is then - ** stored as a member of the Table structure for subsequent use. - ** - ** The column affinity string will eventually be deleted by - ** sqlite3DeleteTable() when the Table structure itself is cleaned up. - */ - if ( pTab.zColAff == null ) - { - StringBuilder zColAff; - int i; - sqlite3 db = sqlite3VdbeDb( v ); - - zColAff = new StringBuilder( pTab.nCol + 1 );// (char)sqlite3DbMallocRaw(0, pTab->nCol+1); - if ( zColAff == null ) - { - //// db.mallocFailed = 1; - return; - } + /* + ** Set P4 of the most recently inserted opcode to a column affinity + ** string for table pTab. A column affinity string has one character + ** for each column indexed by the index, according to the affinity of the + ** column: + ** + ** Character Column affinity + ** ------------------------------ + ** 'a' TEXT + ** 'b' NONE + ** 'c' NUMERIC + ** 'd' INTEGER + ** 'e' REAL + */ + static void sqlite3TableAffinityStr(Vdbe v, Table pTab) { + /* The first time a column affinity string for a particular table + ** is required, it is allocated and populated here. It is then + ** stored as a member of the Table structure for subsequent use. + ** + ** The column affinity string will eventually be deleted by + ** sqlite3DeleteTable() when the Table structure itself is cleaned up. + */ + if (pTab.zColAff == null) { + StringBuilder zColAff; + int i; + sqlite3 db = sqlite3VdbeDb(v); + + zColAff = new StringBuilder(pTab.nCol + 1);// (char)sqlite3DbMallocRaw(0, pTab->nCol+1); + if (zColAff == null) { + //// db.mallocFailed = 1; + return; + } - for ( i = 0; i < pTab.nCol; i++ ) - { - zColAff.Append( pTab.aCol[i].affinity ); - } - //zColAff.Append( '\0' ); + for (i = 0; i < pTab.nCol; i++) { + zColAff.Append(pTab.aCol[i].affinity); + } + //zColAff.Append( '\0' ); - pTab.zColAff = zColAff.ToString(); - } + pTab.zColAff = zColAff.ToString(); + } - sqlite3VdbeChangeP4( v, -1, pTab.zColAff, P4_TRANSIENT ); - } + sqlite3VdbeChangeP4(v, -1, pTab.zColAff, P4_TRANSIENT); + } - /* - ** Return non-zero if the table pTab in database iDb or any of its indices - ** have been opened at any point in the VDBE program beginning at location - ** iStartAddr throught the end of the program. This is used to see if - ** a statement of the form "INSERT INTO SELECT ..." can - ** run without using temporary table for the results of the SELECT. - */ - static bool readsTable( Parse p, int iStartAddr, int iDb, Table pTab ) - { - Vdbe v = sqlite3GetVdbe( p ); - int i; - int iEnd = sqlite3VdbeCurrentAddr( v ); + /* + ** Return non-zero if the table pTab in database iDb or any of its indices + ** have been opened at any point in the VDBE program beginning at location + ** iStartAddr throught the end of the program. This is used to see if + ** a statement of the form "INSERT INTO SELECT ..." can + ** run without using temporary table for the results of the SELECT. + */ + static bool readsTable(Parse p, int iStartAddr, int iDb, Table pTab) { + Vdbe v = sqlite3GetVdbe(p); + int i; + int iEnd = sqlite3VdbeCurrentAddr(v); #if !SQLITE_OMIT_VIRTUALTABLE - VTable pVTab = IsVirtual( pTab ) ? sqlite3GetVTable( p.db, pTab ) : null; + VTable pVTab = IsVirtual(pTab) ? sqlite3GetVTable(p.db, pTab) : null; #endif - for ( i = iStartAddr; i < iEnd; i++ ) - { - VdbeOp pOp = sqlite3VdbeGetOp( v, i ); - Debug.Assert( pOp != null ); - if ( pOp.opcode == OP_OpenRead && pOp.p3 == iDb ) - { - Index pIndex; - int tnum = pOp.p2; - if ( tnum == pTab.tnum ) - { - return true; - } - for ( pIndex = pTab.pIndex; pIndex != null; pIndex = pIndex.pNext ) - { - if ( tnum == pIndex.tnum ) - { - return true; - } - } - } + for (i = iStartAddr; i < iEnd; i++) { + VdbeOp pOp = sqlite3VdbeGetOp(v, i); + Debug.Assert(pOp != null); + if (pOp.opcode == OP_OpenRead && pOp.p3 == iDb) { + Index pIndex; + int tnum = pOp.p2; + if (tnum == pTab.tnum) { + return true; + } + for (pIndex = pTab.pIndex; pIndex != null; pIndex = pIndex.pNext) { + if (tnum == pIndex.tnum) { + return true; + } + } + } #if !SQLITE_OMIT_VIRTUALTABLE - if ( pOp.opcode == OP_VOpen && pOp.p4.pVtab == pVTab ) - { - Debug.Assert( pOp.p4.pVtab != null ); - Debug.Assert( pOp.p4type == P4_VTAB ); - return true; - } + if (pOp.opcode == OP_VOpen && pOp.p4.pVtab == pVTab) { + Debug.Assert(pOp.p4.pVtab != null); + Debug.Assert(pOp.p4type == P4_VTAB); + return true; + } #endif - } - return false; - } + } + return false; + } #if !SQLITE_OMIT_AUTOINCREMENT - /* -** Locate or create an AutoincInfo structure associated with table pTab -** which is in database iDb. Return the register number for the register -** that holds the maximum rowid. -** -** There is at most one AutoincInfo structure per table even if the -** same table is autoincremented multiple times due to inserts within -** triggers. A new AutoincInfo structure is created if this is the -** first use of table pTab. On 2nd and subsequent uses, the original -** AutoincInfo structure is used. -** -** Three memory locations are allocated: -** -** (1) Register to hold the name of the pTab table. -** (2) Register to hold the maximum ROWID of pTab. -** (3) Register to hold the rowid in sqlite_sequence of pTab -** -** The 2nd register is the one that is returned. That is all the -** insert routine needs to know about. -*/ - static int autoIncBegin( - Parse pParse, /* Parsing context */ - int iDb, /* Index of the database holding pTab */ - Table pTab /* The table we are writing to */ - ) - { - int memId = 0; /* Register holding maximum rowid */ - if ( ( pTab.tabFlags & TF_Autoincrement ) != 0 ) - { - Parse pToplevel = sqlite3ParseToplevel( pParse ); - AutoincInfo pInfo; - - pInfo = pToplevel.pAinc; - while ( pInfo != null && pInfo.pTab != pTab ) - { - pInfo = pInfo.pNext; - } - if ( pInfo == null ) - { - pInfo = new AutoincInfo();//sqlite3DbMallocRaw(pParse.db, sizeof(*pInfo)); - //if( pInfo==0 ) return 0; - pInfo.pNext = pToplevel.pAinc; - pToplevel.pAinc = pInfo; - pInfo.pTab = pTab; - pInfo.iDb = iDb; - pToplevel.nMem++; /* Register to hold name of table */ - pInfo.regCtr = ++pToplevel.nMem; /* Max rowid register */ - pToplevel.nMem++; /* Rowid in sqlite_sequence */ + /* + ** Locate or create an AutoincInfo structure associated with table pTab + ** which is in database iDb. Return the register number for the register + ** that holds the maximum rowid. + ** + ** There is at most one AutoincInfo structure per table even if the + ** same table is autoincremented multiple times due to inserts within + ** triggers. A new AutoincInfo structure is created if this is the + ** first use of table pTab. On 2nd and subsequent uses, the original + ** AutoincInfo structure is used. + ** + ** Three memory locations are allocated: + ** + ** (1) Register to hold the name of the pTab table. + ** (2) Register to hold the maximum ROWID of pTab. + ** (3) Register to hold the rowid in sqlite_sequence of pTab + ** + ** The 2nd register is the one that is returned. That is all the + ** insert routine needs to know about. + */ + static int autoIncBegin( + Parse pParse, /* Parsing context */ + int iDb, /* Index of the database holding pTab */ + Table pTab /* The table we are writing to */ + ) { + int memId = 0; /* Register holding maximum rowid */ + if ((pTab.tabFlags & TF_Autoincrement) != 0) { + Parse pToplevel = sqlite3ParseToplevel(pParse); + AutoincInfo pInfo; + + pInfo = pToplevel.pAinc; + while (pInfo != null && pInfo.pTab != pTab) { + pInfo = pInfo.pNext; + } + if (pInfo == null) { + pInfo = new AutoincInfo();//sqlite3DbMallocRaw(pParse.db, sizeof(*pInfo)); + //if( pInfo==0 ) return 0; + pInfo.pNext = pToplevel.pAinc; + pToplevel.pAinc = pInfo; + pInfo.pTab = pTab; + pInfo.iDb = iDb; + pToplevel.nMem++; /* Register to hold name of table */ + pInfo.regCtr = ++pToplevel.nMem; /* Max rowid register */ + pToplevel.nMem++; /* Rowid in sqlite_sequence */ + } + memId = pInfo.regCtr; + } + return memId; } - memId = pInfo.regCtr; - } - return memId; - } - /* - ** This routine generates code that will initialize all of the - ** register used by the autoincrement tracker. - */ - static void sqlite3AutoincrementBegin( Parse pParse ) - { - AutoincInfo p; /* Information about an AUTOINCREMENT */ - sqlite3 db = pParse.db; /* The database connection */ - Db pDb; /* Database only autoinc table */ - int memId; /* Register holding max rowid */ - int addr; /* A VDBE address */ - Vdbe v = pParse.pVdbe; /* VDBE under construction */ - - /* This routine is never called during trigger-generation. It is - ** only called from the top-level */ - Debug.Assert( pParse.pTriggerTab == null ); - Debug.Assert( pParse == sqlite3ParseToplevel( pParse ) ); - - Debug.Assert( v != null ); /* We failed long ago if this is not so */ - for ( p = pParse.pAinc; p != null; p = p.pNext ) - { - pDb = db.aDb[p.iDb]; - memId = p.regCtr; - Debug.Assert( sqlite3SchemaMutexHeld( db, 0, pDb.pSchema ) ); - sqlite3OpenTable( pParse, 0, p.iDb, pDb.pSchema.pSeqTab, OP_OpenRead ); - addr = sqlite3VdbeCurrentAddr( v ); - sqlite3VdbeAddOp4( v, OP_String8, 0, memId - 1, 0, p.pTab.zName, 0 ); - sqlite3VdbeAddOp2( v, OP_Rewind, 0, addr + 9 ); - sqlite3VdbeAddOp3( v, OP_Column, 0, 0, memId ); - sqlite3VdbeAddOp3( v, OP_Ne, memId - 1, addr + 7, memId ); - sqlite3VdbeChangeP5( v, SQLITE_JUMPIFNULL ); - sqlite3VdbeAddOp2( v, OP_Rowid, 0, memId + 1 ); - sqlite3VdbeAddOp3( v, OP_Column, 0, 1, memId ); - sqlite3VdbeAddOp2( v, OP_Goto, 0, addr + 9 ); - sqlite3VdbeAddOp2( v, OP_Next, 0, addr + 2 ); - sqlite3VdbeAddOp2( v, OP_Integer, 0, memId ); - sqlite3VdbeAddOp0( v, OP_Close ); - } - } + /* + ** This routine generates code that will initialize all of the + ** register used by the autoincrement tracker. + */ + static void sqlite3AutoincrementBegin(Parse pParse) { + AutoincInfo p; /* Information about an AUTOINCREMENT */ + sqlite3 db = pParse.db; /* The database connection */ + Db pDb; /* Database only autoinc table */ + int memId; /* Register holding max rowid */ + int addr; /* A VDBE address */ + Vdbe v = pParse.pVdbe; /* VDBE under construction */ + + /* This routine is never called during trigger-generation. It is + ** only called from the top-level */ + Debug.Assert(pParse.pTriggerTab == null); + Debug.Assert(pParse == sqlite3ParseToplevel(pParse)); + + Debug.Assert(v != null); /* We failed long ago if this is not so */ + for (p = pParse.pAinc; p != null; p = p.pNext) { + pDb = db.aDb[p.iDb]; + memId = p.regCtr; + Debug.Assert(sqlite3SchemaMutexHeld(db, 0, pDb.pSchema)); + sqlite3OpenTable(pParse, 0, p.iDb, pDb.pSchema.pSeqTab, OP_OpenRead); + addr = sqlite3VdbeCurrentAddr(v); + sqlite3VdbeAddOp4(v, OP_String8, 0, memId - 1, 0, p.pTab.zName, 0); + sqlite3VdbeAddOp2(v, OP_Rewind, 0, addr + 9); + sqlite3VdbeAddOp3(v, OP_Column, 0, 0, memId); + sqlite3VdbeAddOp3(v, OP_Ne, memId - 1, addr + 7, memId); + sqlite3VdbeChangeP5(v, SQLITE_JUMPIFNULL); + sqlite3VdbeAddOp2(v, OP_Rowid, 0, memId + 1); + sqlite3VdbeAddOp3(v, OP_Column, 0, 1, memId); + sqlite3VdbeAddOp2(v, OP_Goto, 0, addr + 9); + sqlite3VdbeAddOp2(v, OP_Next, 0, addr + 2); + sqlite3VdbeAddOp2(v, OP_Integer, 0, memId); + sqlite3VdbeAddOp0(v, OP_Close); + } + } - /* - ** Update the maximum rowid for an autoincrement calculation. - ** - ** This routine should be called when the top of the stack holds a - ** new rowid that is about to be inserted. If that new rowid is - ** larger than the maximum rowid in the memId memory cell, then the - ** memory cell is updated. The stack is unchanged. - */ - static void autoIncStep( Parse pParse, int memId, int regRowid ) - { - if ( memId > 0 ) - { - sqlite3VdbeAddOp2( pParse.pVdbe, OP_MemMax, memId, regRowid ); - } - } + /* + ** Update the maximum rowid for an autoincrement calculation. + ** + ** This routine should be called when the top of the stack holds a + ** new rowid that is about to be inserted. If that new rowid is + ** larger than the maximum rowid in the memId memory cell, then the + ** memory cell is updated. The stack is unchanged. + */ + static void autoIncStep(Parse pParse, int memId, int regRowid) { + if (memId > 0) { + sqlite3VdbeAddOp2(pParse.pVdbe, OP_MemMax, memId, regRowid); + } + } - /* - ** This routine generates the code needed to write autoincrement - ** maximum rowid values back into the sqlite_sequence register. - ** Every statement that might do an INSERT into an autoincrement - ** table (either directly or through triggers) needs to call this - ** routine just before the "exit" code. - */ - static void sqlite3AutoincrementEnd( Parse pParse ) - { - AutoincInfo p; - Vdbe v = pParse.pVdbe; - sqlite3 db = pParse.db; - - Debug.Assert( v != null ); - for ( p = pParse.pAinc; p != null; p = p.pNext ) - { - Db pDb = db.aDb[p.iDb]; - int j1, j2, j3, j4, j5; - int iRec; - int memId = p.regCtr; - - iRec = sqlite3GetTempReg( pParse ); - Debug.Assert( sqlite3SchemaMutexHeld( db, 0, pDb.pSchema ) ); - sqlite3OpenTable( pParse, 0, p.iDb, pDb.pSchema.pSeqTab, OP_OpenWrite ); - j1 = sqlite3VdbeAddOp1( v, OP_NotNull, memId + 1 ); - j2 = sqlite3VdbeAddOp0( v, OP_Rewind ); - j3 = sqlite3VdbeAddOp3( v, OP_Column, 0, 0, iRec ); - j4 = sqlite3VdbeAddOp3( v, OP_Eq, memId - 1, 0, iRec ); - sqlite3VdbeAddOp2( v, OP_Next, 0, j3 ); - sqlite3VdbeJumpHere( v, j2 ); - sqlite3VdbeAddOp2( v, OP_NewRowid, 0, memId + 1 ); - j5 = sqlite3VdbeAddOp0( v, OP_Goto ); - sqlite3VdbeJumpHere( v, j4 ); - sqlite3VdbeAddOp2( v, OP_Rowid, 0, memId + 1 ); - sqlite3VdbeJumpHere( v, j1 ); - sqlite3VdbeJumpHere( v, j5 ); - sqlite3VdbeAddOp3( v, OP_MakeRecord, memId - 1, 2, iRec ); - sqlite3VdbeAddOp3( v, OP_Insert, 0, iRec, memId + 1 ); - sqlite3VdbeChangeP5( v, OPFLAG_APPEND ); - sqlite3VdbeAddOp0( v, OP_Close ); - sqlite3ReleaseTempReg( pParse, iRec ); - } - } + /* + ** This routine generates the code needed to write autoincrement + ** maximum rowid values back into the sqlite_sequence register. + ** Every statement that might do an INSERT into an autoincrement + ** table (either directly or through triggers) needs to call this + ** routine just before the "exit" code. + */ + static void sqlite3AutoincrementEnd(Parse pParse) { + AutoincInfo p; + Vdbe v = pParse.pVdbe; + sqlite3 db = pParse.db; + + Debug.Assert(v != null); + for (p = pParse.pAinc; p != null; p = p.pNext) { + Db pDb = db.aDb[p.iDb]; + int j1, j2, j3, j4, j5; + int iRec; + int memId = p.regCtr; + + iRec = sqlite3GetTempReg(pParse); + Debug.Assert(sqlite3SchemaMutexHeld(db, 0, pDb.pSchema)); + sqlite3OpenTable(pParse, 0, p.iDb, pDb.pSchema.pSeqTab, OP_OpenWrite); + j1 = sqlite3VdbeAddOp1(v, OP_NotNull, memId + 1); + j2 = sqlite3VdbeAddOp0(v, OP_Rewind); + j3 = sqlite3VdbeAddOp3(v, OP_Column, 0, 0, iRec); + j4 = sqlite3VdbeAddOp3(v, OP_Eq, memId - 1, 0, iRec); + sqlite3VdbeAddOp2(v, OP_Next, 0, j3); + sqlite3VdbeJumpHere(v, j2); + sqlite3VdbeAddOp2(v, OP_NewRowid, 0, memId + 1); + j5 = sqlite3VdbeAddOp0(v, OP_Goto); + sqlite3VdbeJumpHere(v, j4); + sqlite3VdbeAddOp2(v, OP_Rowid, 0, memId + 1); + sqlite3VdbeJumpHere(v, j1); + sqlite3VdbeJumpHere(v, j5); + sqlite3VdbeAddOp3(v, OP_MakeRecord, memId - 1, 2, iRec); + sqlite3VdbeAddOp3(v, OP_Insert, 0, iRec, memId + 1); + sqlite3VdbeChangeP5(v, OPFLAG_APPEND); + sqlite3VdbeAddOp0(v, OP_Close); + sqlite3ReleaseTempReg(pParse, iRec); + } + } #else /* ** If SQLITE_OMIT_AUTOINCREMENT is defined, then the three routines @@ -367,201 +338,195 @@ static void sqlite3AutoincrementEnd( Parse pParse ) #endif // * SQLITE_OMIT_AUTOINCREMENT */ - /* Forward declaration */ - //static int xferOptimization( - // Parse pParse, /* Parser context */ - // Table pDest, /* The table we are inserting into */ - // Select pSelect, /* A SELECT statement to use as the data source */ - // int onError, /* How to handle constraint errors */ - // int iDbDest /* The database of pDest */ - //); + /* Forward declaration */ + //static int xferOptimization( + // Parse pParse, /* Parser context */ + // Table pDest, /* The table we are inserting into */ + // Select pSelect, /* A SELECT statement to use as the data source */ + // int onError, /* How to handle constraint errors */ + // int iDbDest /* The database of pDest */ + //); - /* - ** This routine is call to handle SQL of the following forms: - ** - ** insert into TABLE (IDLIST) values(EXPRLIST) - ** insert into TABLE (IDLIST) select - ** - ** The IDLIST following the table name is always optional. If omitted, - ** then a list of all columns for the table is substituted. The IDLIST - ** appears in the pColumn parameter. pColumn is NULL if IDLIST is omitted. - ** - ** The pList parameter holds EXPRLIST in the first form of the INSERT - ** statement above, and pSelect is NULL. For the second form, pList is - ** NULL and pSelect is a pointer to the select statement used to generate - ** data for the insert. - ** - ** The code generated follows one of four templates. For a simple - ** select with data coming from a VALUES clause, the code executes - ** once straight down through. Pseudo-code follows (we call this - ** the "1st template"): - ** - ** open write cursor to
and its indices - ** puts VALUES clause expressions onto the stack - ** write the resulting record into
- ** cleanup - ** - ** The three remaining templates assume the statement is of the form - ** - ** INSERT INTO
SELECT ... - ** - ** If the SELECT clause is of the restricted form "SELECT * FROM " - - ** in other words if the SELECT pulls all columns from a single table - ** and there is no WHERE or LIMIT or GROUP BY or ORDER BY clauses, and - ** if and are distinct tables but have identical - ** schemas, including all the same indices, then a special optimization - ** is invoked that copies raw records from over to . - ** See the xferOptimization() function for the implementation of this - ** template. This is the 2nd template. - ** - ** open a write cursor to
- ** open read cursor on - ** transfer all records in over to
- ** close cursors - ** foreach index on
- ** open a write cursor on the
index - ** open a read cursor on the corresponding index - ** transfer all records from the read to the write cursors - ** close cursors - ** end foreach - ** - ** The 3rd template is for when the second template does not apply - ** and the SELECT clause does not read from
at any time. - ** The generated code follows this template: - ** - ** EOF <- 0 - ** X <- A - ** goto B - ** A: setup for the SELECT - ** loop over the rows in the SELECT - ** load values into registers R..R+n - ** yield X - ** end loop - ** cleanup after the SELECT - ** EOF <- 1 - ** yield X - ** goto A - ** B: open write cursor to
and its indices - ** C: yield X - ** if EOF goto D - ** insert the select result into
from R..R+n - ** goto C - ** D: cleanup - ** - ** The 4th template is used if the insert statement takes its - ** values from a SELECT but the data is being inserted into a table - ** that is also read as part of the SELECT. In the third form, - ** we have to use a intermediate table to store the results of - ** the select. The template is like this: - ** - ** EOF <- 0 - ** X <- A - ** goto B - ** A: setup for the SELECT - ** loop over the tables in the SELECT - ** load value into register R..R+n - ** yield X - ** end loop - ** cleanup after the SELECT - ** EOF <- 1 - ** yield X - ** halt-error - ** B: open temp table - ** L: yield X - ** if EOF goto M - ** insert row from R..R+n into temp table - ** goto L - ** M: open write cursor to
and its indices - ** rewind temp table - ** C: loop over rows of intermediate table - ** transfer values form intermediate table into
- ** end loop - ** D: cleanup - */ - // OVERLOADS, so I don't need to rewrite parse.c - static void sqlite3Insert( Parse pParse, SrcList pTabList, int null_3, int null_4, IdList pColumn, int onError ) - { - sqlite3Insert( pParse, pTabList, null, null, pColumn, onError ); - } - static void sqlite3Insert( Parse pParse, SrcList pTabList, int null_3, Select pSelect, IdList pColumn, int onError ) - { - sqlite3Insert( pParse, pTabList, null, pSelect, pColumn, onError ); - } - static void sqlite3Insert( Parse pParse, SrcList pTabList, ExprList pList, int null_4, IdList pColumn, int onError ) - { - sqlite3Insert( pParse, pTabList, pList, null, pColumn, onError ); - } - static void sqlite3Insert( - Parse pParse, /* Parser context */ - SrcList pTabList, /* Name of table into which we are inserting */ - ExprList pList, /* List of values to be inserted */ - Select pSelect, /* A SELECT statement to use as the data source */ - IdList pColumn, /* Column names corresponding to IDLIST. */ - int onError /* How to handle constraint errors */ - ) - { - sqlite3 db; /* The main database structure */ - Table pTab; /* The table to insert into. aka TABLE */ - string zTab; /* Name of the table into which we are inserting */ - int i = 0; - int j = 0; - int idx = 0; /* Loop counters */ - Vdbe v; /* Generate code into this virtual machine */ - Index pIdx; /* For looping over indices of the table */ - int nColumn; /* Number of columns in the data */ - int nHidden = 0; /* Number of hidden columns if TABLE is virtual */ - int baseCur = 0; /* VDBE VdbeCursor number for pTab */ - int keyColumn = -1; /* Column that is the INTEGER PRIMARY KEY */ - int endOfLoop = 0; /* Label for the end of the insertion loop */ - bool useTempTable = false; /* Store SELECT results in intermediate table */ - int srcTab = 0; /* Data comes from this temporary cursor if >=0 */ - int addrInsTop = 0; /* Jump to label "D" */ - int addrCont = 0; /* Top of insert loop. Label "C" in templates 3 and 4 */ - int addrSelect = 0; /* Address of coroutine that implements the SELECT */ - SelectDest dest; /* Destination for SELECT on rhs of INSERT */ - int iDb; /* Index of database holding TABLE */ - Db pDb; /* The database containing table being inserted into */ - bool appendFlag = false; /* True if the insert is likely to be an append */ - - /* Register allocations */ - int regFromSelect = 0; /* Base register for data coming from SELECT */ - int regAutoinc = 0; /* Register holding the AUTOINCREMENT counter */ - int regRowCount = 0; /* Memory cell used for the row counter */ - int regIns; /* Block of regs holding rowid+data being inserted */ - int regRowid; /* registers holding insert rowid */ - int regData; /* register holding first column to insert */ - int regEof = 0; /* Register recording end of SELECT data */ - int[] aRegIdx = null; /* One register allocated to each index */ + /* + ** This routine is call to handle SQL of the following forms: + ** + ** insert into TABLE (IDLIST) values(EXPRLIST) + ** insert into TABLE (IDLIST) select + ** + ** The IDLIST following the table name is always optional. If omitted, + ** then a list of all columns for the table is substituted. The IDLIST + ** appears in the pColumn parameter. pColumn is NULL if IDLIST is omitted. + ** + ** The pList parameter holds EXPRLIST in the first form of the INSERT + ** statement above, and pSelect is NULL. For the second form, pList is + ** NULL and pSelect is a pointer to the select statement used to generate + ** data for the insert. + ** + ** The code generated follows one of four templates. For a simple + ** select with data coming from a VALUES clause, the code executes + ** once straight down through. Pseudo-code follows (we call this + ** the "1st template"): + ** + ** open write cursor to
and its indices + ** puts VALUES clause expressions onto the stack + ** write the resulting record into
+ ** cleanup + ** + ** The three remaining templates assume the statement is of the form + ** + ** INSERT INTO
SELECT ... + ** + ** If the SELECT clause is of the restricted form "SELECT * FROM " - + ** in other words if the SELECT pulls all columns from a single table + ** and there is no WHERE or LIMIT or GROUP BY or ORDER BY clauses, and + ** if and are distinct tables but have identical + ** schemas, including all the same indices, then a special optimization + ** is invoked that copies raw records from over to . + ** See the xferOptimization() function for the implementation of this + ** template. This is the 2nd template. + ** + ** open a write cursor to
+ ** open read cursor on + ** transfer all records in over to
+ ** close cursors + ** foreach index on
+ ** open a write cursor on the
index + ** open a read cursor on the corresponding index + ** transfer all records from the read to the write cursors + ** close cursors + ** end foreach + ** + ** The 3rd template is for when the second template does not apply + ** and the SELECT clause does not read from
at any time. + ** The generated code follows this template: + ** + ** EOF <- 0 + ** X <- A + ** goto B + ** A: setup for the SELECT + ** loop over the rows in the SELECT + ** load values into registers R..R+n + ** yield X + ** end loop + ** cleanup after the SELECT + ** EOF <- 1 + ** yield X + ** goto A + ** B: open write cursor to
and its indices + ** C: yield X + ** if EOF goto D + ** insert the select result into
from R..R+n + ** goto C + ** D: cleanup + ** + ** The 4th template is used if the insert statement takes its + ** values from a SELECT but the data is being inserted into a table + ** that is also read as part of the SELECT. In the third form, + ** we have to use a intermediate table to store the results of + ** the select. The template is like this: + ** + ** EOF <- 0 + ** X <- A + ** goto B + ** A: setup for the SELECT + ** loop over the tables in the SELECT + ** load value into register R..R+n + ** yield X + ** end loop + ** cleanup after the SELECT + ** EOF <- 1 + ** yield X + ** halt-error + ** B: open temp table + ** L: yield X + ** if EOF goto M + ** insert row from R..R+n into temp table + ** goto L + ** M: open write cursor to
and its indices + ** rewind temp table + ** C: loop over rows of intermediate table + ** transfer values form intermediate table into
+ ** end loop + ** D: cleanup + */ + // OVERLOADS, so I don't need to rewrite parse.c + static void sqlite3Insert(Parse pParse, SrcList pTabList, int null_3, int null_4, IdList pColumn, int onError) { + sqlite3Insert(pParse, pTabList, null, null, pColumn, onError); + } + static void sqlite3Insert(Parse pParse, SrcList pTabList, int null_3, Select pSelect, IdList pColumn, int onError) { + sqlite3Insert(pParse, pTabList, null, pSelect, pColumn, onError); + } + static void sqlite3Insert(Parse pParse, SrcList pTabList, ExprList pList, int null_4, IdList pColumn, int onError) { + sqlite3Insert(pParse, pTabList, pList, null, pColumn, onError); + } + static void sqlite3Insert( + Parse pParse, /* Parser context */ + SrcList pTabList, /* Name of table into which we are inserting */ + ExprList pList, /* List of values to be inserted */ + Select pSelect, /* A SELECT statement to use as the data source */ + IdList pColumn, /* Column names corresponding to IDLIST. */ + int onError /* How to handle constraint errors */ + ) { + sqlite3 db; /* The main database structure */ + Table pTab; /* The table to insert into. aka TABLE */ + string zTab; /* Name of the table into which we are inserting */ + int i = 0; + int j = 0; + int idx = 0; /* Loop counters */ + Vdbe v; /* Generate code into this virtual machine */ + Index pIdx; /* For looping over indices of the table */ + int nColumn; /* Number of columns in the data */ + int nHidden = 0; /* Number of hidden columns if TABLE is virtual */ + int baseCur = 0; /* VDBE VdbeCursor number for pTab */ + int keyColumn = -1; /* Column that is the INTEGER PRIMARY KEY */ + int endOfLoop = 0; /* Label for the end of the insertion loop */ + bool useTempTable = false; /* Store SELECT results in intermediate table */ + int srcTab = 0; /* Data comes from this temporary cursor if >=0 */ + int addrInsTop = 0; /* Jump to label "D" */ + int addrCont = 0; /* Top of insert loop. Label "C" in templates 3 and 4 */ + int addrSelect = 0; /* Address of coroutine that implements the SELECT */ + SelectDest dest; /* Destination for SELECT on rhs of INSERT */ + int iDb; /* Index of database holding TABLE */ + Db pDb; /* The database containing table being inserted into */ + bool appendFlag = false; /* True if the insert is likely to be an append */ + + /* Register allocations */ + int regFromSelect = 0; /* Base register for data coming from SELECT */ + int regAutoinc = 0; /* Register holding the AUTOINCREMENT counter */ + int regRowCount = 0; /* Memory cell used for the row counter */ + int regIns; /* Block of regs holding rowid+data being inserted */ + int regRowid; /* registers holding insert rowid */ + int regData; /* register holding first column to insert */ + int regEof = 0; /* Register recording end of SELECT data */ + int[] aRegIdx = null; /* One register allocated to each index */ #if !SQLITE_OMIT_TRIGGER - bool isView = false; /* True if attempting to insert into a view */ - Trigger pTrigger; /* List of triggers on pTab, if required */ - int tmask = 0; /* Mask of trigger times */ + bool isView = false; /* True if attempting to insert into a view */ + Trigger pTrigger; /* List of triggers on pTab, if required */ + int tmask = 0; /* Mask of trigger times */ #endif - db = pParse.db; - dest = new SelectDest();// memset( &dest, 0, sizeof( dest ) ); + db = pParse.db; + dest = new SelectDest();// memset( &dest, 0, sizeof( dest ) ); - if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) - { - goto insert_cleanup; - } + if (pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) { + goto insert_cleanup; + } - /* Locate the table into which we will be inserting new information. - */ - Debug.Assert( pTabList.nSrc == 1 ); - zTab = pTabList.a[0].zName; - if ( NEVER( zTab == null ) ) - goto insert_cleanup; - pTab = sqlite3SrcListLookup( pParse, pTabList ); - if ( pTab == null ) - { - goto insert_cleanup; - } - iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); - Debug.Assert( iDb < db.nDb ); - pDb = db.aDb[iDb]; + /* Locate the table into which we will be inserting new information. + */ + Debug.Assert(pTabList.nSrc == 1); + zTab = pTabList.a[0].zName; + if (NEVER(zTab == null)) + goto insert_cleanup; + pTab = sqlite3SrcListLookup(pParse, pTabList); + if (pTab == null) { + goto insert_cleanup; + } + iDb = sqlite3SchemaToIndex(db, pTab.pSchema); + Debug.Assert(iDb < db.nDb); + pDb = db.aDb[iDb]; #if !SQLITE_OMIT_AUTHORIZATION string zDb; /* Name of the database holding this table */ zDb = pDb.zName; @@ -569,1209 +534,1053 @@ int onError /* How to handle constraint errors */ goto insert_cleanup; } #endif - /* Figure out if we have any triggers and if the table being -** inserted into is a view -*/ + /* Figure out if we have any triggers and if the table being + ** inserted into is a view + */ #if !SQLITE_OMIT_TRIGGER - pTrigger = sqlite3TriggersExist( pParse, pTab, TK_INSERT, null, out tmask ); - isView = pTab.pSelect != null; + pTrigger = sqlite3TriggersExist(pParse, pTab, TK_INSERT, null, out tmask); + isView = pTab.pSelect != null; #else Trigger pTrigger = null; //# define pTrigger 0 int tmask = 0; //# define tmask 0 bool isView = false; #endif -#if SQLITE_OMIT_VIEW +#if SQLITE_OMIT_VIEW //# undef isView isView = false; #endif #if !SQLITE_OMIT_TRIGGER - Debug.Assert( ( pTrigger != null && tmask != 0 ) || ( pTrigger == null && tmask == 0 ) ); + Debug.Assert((pTrigger != null && tmask != 0) || (pTrigger == null && tmask == 0)); #endif #if !SQLITE_OMIT_VIEW - /* If pTab is really a view, make sure it has been initialized. - ** ViewGetColumnNames() is a no-op if pTab is not a view (or virtual - ** module table). - */ - if ( sqlite3ViewGetColumnNames( pParse, pTab ) != -0 ) - { - goto insert_cleanup; - } + /* If pTab is really a view, make sure it has been initialized. + ** ViewGetColumnNames() is a no-op if pTab is not a view (or virtual + ** module table). + */ + if (sqlite3ViewGetColumnNames(pParse, pTab) != -0) { + goto insert_cleanup; + } #endif - /* Ensure that: - * (a) the table is not read-only, - * (b) that if it is a view then ON INSERT triggers exist - */ - if ( sqlite3IsReadOnly( pParse, pTab, tmask ) ) - { - goto insert_cleanup; - } + /* Ensure that: + * (a) the table is not read-only, + * (b) that if it is a view then ON INSERT triggers exist + */ + if (sqlite3IsReadOnly(pParse, pTab, tmask)) { + goto insert_cleanup; + } - /* Allocate a VDBE - */ - v = sqlite3GetVdbe( pParse ); - if ( v == null ) - goto insert_cleanup; - if ( pParse.nested == 0 ) - sqlite3VdbeCountChanges( v ); - sqlite3BeginWriteOperation( pParse, ( pSelect != null || pTrigger != null ) ? 1 : 0, iDb ); + /* Allocate a VDBE + */ + v = sqlite3GetVdbe(pParse); + if (v == null) + goto insert_cleanup; + if (pParse.nested == 0) + sqlite3VdbeCountChanges(v); + sqlite3BeginWriteOperation(pParse, (pSelect != null || pTrigger != null) ? 1 : 0, iDb); #if !SQLITE_OMIT_XFER_OPT - /* If the statement is of the form -** -** INSERT INTO SELECT * FROM ; -** -** Then special optimizations can be applied that make the transfer -** very fast and which reduce fragmentation of indices. -** -** This is the 2nd template. -*/ - if ( pColumn == null && xferOptimization( pParse, pTab, pSelect, onError, iDb ) != 0 ) - { - Debug.Assert( null == pTrigger ); - Debug.Assert( pList == null ); - goto insert_end; - } + /* If the statement is of the form + ** + ** INSERT INTO SELECT * FROM ; + ** + ** Then special optimizations can be applied that make the transfer + ** very fast and which reduce fragmentation of indices. + ** + ** This is the 2nd template. + */ + if (pColumn == null && xferOptimization(pParse, pTab, pSelect, onError, iDb) != 0) { + Debug.Assert(null == pTrigger); + Debug.Assert(pList == null); + goto insert_end; + } #endif // * SQLITE_OMIT_XFER_OPT */ - /* If this is an AUTOINCREMENT table, look up the sequence number in the -** sqlite_sequence table and store it in memory cell regAutoinc. -*/ - regAutoinc = autoIncBegin( pParse, iDb, pTab ); - - /* Figure out how many columns of data are supplied. If the data - ** is coming from a SELECT statement, then generate a co-routine that - ** produces a single row of the SELECT on each invocation. The - ** co-routine is the common header to the 3rd and 4th templates. + /* If this is an AUTOINCREMENT table, look up the sequence number in the + ** sqlite_sequence table and store it in memory cell regAutoinc. */ - if ( pSelect != null ) - { - /* Data is coming from a SELECT. Generate code to implement that SELECT - ** as a co-routine. The code is common to both the 3rd and 4th - ** templates: - ** - ** EOF <- 0 - ** X <- A - ** goto B - ** A: setup for the SELECT - ** loop over the tables in the SELECT - ** load value into register R..R+n - ** yield X - ** end loop - ** cleanup after the SELECT - ** EOF <- 1 - ** yield X - ** halt-error - ** - ** On each invocation of the co-routine, it puts a single row of the - ** SELECT result into registers dest.iMem...dest.iMem+dest.nMem-1. - ** (These output registers are allocated by sqlite3Select().) When - ** the SELECT completes, it sets the EOF flag stored in regEof. - */ - int rc = 0, j1; - - regEof = ++pParse.nMem; - sqlite3VdbeAddOp2( v, OP_Integer, 0, regEof ); /* EOF <- 0 */ + regAutoinc = autoIncBegin(pParse, iDb, pTab); + + /* Figure out how many columns of data are supplied. If the data + ** is coming from a SELECT statement, then generate a co-routine that + ** produces a single row of the SELECT on each invocation. The + ** co-routine is the common header to the 3rd and 4th templates. + */ + if (pSelect != null) { + /* Data is coming from a SELECT. Generate code to implement that SELECT + ** as a co-routine. The code is common to both the 3rd and 4th + ** templates: + ** + ** EOF <- 0 + ** X <- A + ** goto B + ** A: setup for the SELECT + ** loop over the tables in the SELECT + ** load value into register R..R+n + ** yield X + ** end loop + ** cleanup after the SELECT + ** EOF <- 1 + ** yield X + ** halt-error + ** + ** On each invocation of the co-routine, it puts a single row of the + ** SELECT result into registers dest.iMem...dest.iMem+dest.nMem-1. + ** (These output registers are allocated by sqlite3Select().) When + ** the SELECT completes, it sets the EOF flag stored in regEof. + */ + int rc = 0, j1; + + regEof = ++pParse.nMem; + sqlite3VdbeAddOp2(v, OP_Integer, 0, regEof); /* EOF <- 0 */ #if SQLITE_DEBUG - VdbeComment( v, "SELECT eof flag" ); + VdbeComment(v, "SELECT eof flag"); #endif - sqlite3SelectDestInit( dest, SRT_Coroutine, ++pParse.nMem ); - addrSelect = sqlite3VdbeCurrentAddr( v ) + 2; - sqlite3VdbeAddOp2( v, OP_Integer, addrSelect - 1, dest.iParm ); - j1 = sqlite3VdbeAddOp2( v, OP_Goto, 0, 0 ); + sqlite3SelectDestInit(dest, SRT_Coroutine, ++pParse.nMem); + addrSelect = sqlite3VdbeCurrentAddr(v) + 2; + sqlite3VdbeAddOp2(v, OP_Integer, addrSelect - 1, dest.iParm); + j1 = sqlite3VdbeAddOp2(v, OP_Goto, 0, 0); #if SQLITE_DEBUG - VdbeComment( v, "Jump over SELECT coroutine" ); + VdbeComment(v, "Jump over SELECT coroutine"); #endif - /* Resolve the expressions in the SELECT statement and execute it. */ - rc = sqlite3Select( pParse, pSelect, ref dest ); - Debug.Assert( pParse.nErr == 0 || rc != 0 ); - if ( rc != 0 || NEVER( pParse.nErr != 0 ) /*|| db.mallocFailed != 0 */ ) - { - goto insert_cleanup; - } - sqlite3VdbeAddOp2( v, OP_Integer, 1, regEof ); /* EOF <- 1 */ - sqlite3VdbeAddOp1( v, OP_Yield, dest.iParm ); /* yield X */ - sqlite3VdbeAddOp2( v, OP_Halt, SQLITE_INTERNAL, OE_Abort ); + /* Resolve the expressions in the SELECT statement and execute it. */ + rc = sqlite3Select(pParse, pSelect, ref dest); + Debug.Assert(pParse.nErr == 0 || rc != 0); + if (rc != 0 || NEVER(pParse.nErr != 0) /*|| db.mallocFailed != 0 */ ) { + goto insert_cleanup; + } + sqlite3VdbeAddOp2(v, OP_Integer, 1, regEof); /* EOF <- 1 */ + sqlite3VdbeAddOp1(v, OP_Yield, dest.iParm); /* yield X */ + sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_INTERNAL, OE_Abort); #if SQLITE_DEBUG - VdbeComment( v, "End of SELECT coroutine" ); + VdbeComment(v, "End of SELECT coroutine"); #endif - sqlite3VdbeJumpHere( v, j1 ); /* label B: */ + sqlite3VdbeJumpHere(v, j1); /* label B: */ + + regFromSelect = dest.iMem; + Debug.Assert(pSelect.pEList != null); + nColumn = pSelect.pEList.nExpr; + Debug.Assert(dest.nMem == nColumn); + + /* Set useTempTable to TRUE if the result of the SELECT statement + ** should be written into a temporary table (template 4). Set to + ** FALSE if each* row of the SELECT can be written directly into + ** the destination table (template 3). + ** + ** A temp table must be used if the table being updated is also one + ** of the tables being read by the SELECT statement. Also use a + ** temp table in the case of row triggers. + */ + if (pTrigger != null || readsTable(pParse, addrSelect, iDb, pTab)) { + useTempTable = true; + } - regFromSelect = dest.iMem; - Debug.Assert( pSelect.pEList != null ); - nColumn = pSelect.pEList.nExpr; - Debug.Assert( dest.nMem == nColumn ); + if (useTempTable) { + /* Invoke the coroutine to extract information from the SELECT + ** and add it to a transient table srcTab. The code generated + ** here is from the 4th template: + ** + ** B: open temp table + ** L: yield X + ** if EOF goto M + ** insert row from R..R+n into temp table + ** goto L + ** M: ... + */ + int regRec; /* Register to hold packed record */ + int regTempRowid; /* Register to hold temp table ROWID */ + int addrTop; /* Label "L" */ + int addrIf; /* Address of jump to M */ + + srcTab = pParse.nTab++; + regRec = sqlite3GetTempReg(pParse); + regTempRowid = sqlite3GetTempReg(pParse); + sqlite3VdbeAddOp2(v, OP_OpenEphemeral, srcTab, nColumn); + addrTop = sqlite3VdbeAddOp1(v, OP_Yield, dest.iParm); + addrIf = sqlite3VdbeAddOp1(v, OP_If, regEof); + sqlite3VdbeAddOp3(v, OP_MakeRecord, regFromSelect, nColumn, regRec); + sqlite3VdbeAddOp2(v, OP_NewRowid, srcTab, regTempRowid); + sqlite3VdbeAddOp3(v, OP_Insert, srcTab, regRec, regTempRowid); + sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop); + sqlite3VdbeJumpHere(v, addrIf); + sqlite3ReleaseTempReg(pParse, regRec); + sqlite3ReleaseTempReg(pParse, regTempRowid); + } + } else { + /* This is the case if the data for the INSERT is coming from a VALUES + ** clause + */ + NameContext sNC; + sNC = new NameContext();// memset( &sNC, 0, sNC ).Length; + sNC.pParse = pParse; + srcTab = -1; + Debug.Assert(!useTempTable); + nColumn = pList != null ? pList.nExpr : 0; + for (i = 0; i < nColumn; i++) { + if (sqlite3ResolveExprNames(sNC, ref pList.a[i].pExpr) != 0) { + goto insert_cleanup; + } + } + } - /* Set useTempTable to TRUE if the result of the SELECT statement - ** should be written into a temporary table (template 4). Set to - ** FALSE if each* row of the SELECT can be written directly into - ** the destination table (template 3). - ** - ** A temp table must be used if the table being updated is also one - ** of the tables being read by the SELECT statement. Also use a - ** temp table in the case of row triggers. - */ - if ( pTrigger != null || readsTable( pParse, addrSelect, iDb, pTab ) ) - { - useTempTable = true; - } + /* Make sure the number of columns in the source data matches the number + ** of columns to be inserted into the table. + */ + if (IsVirtual(pTab)) { + for (i = 0; i < pTab.nCol; i++) { + nHidden += (IsHiddenColumn(pTab.aCol[i]) ? 1 : 0); + } + } + if (pColumn == null && nColumn != 0 && nColumn != (pTab.nCol - nHidden)) { + sqlite3ErrorMsg(pParse, + "table %S has %d columns but %d values were supplied", + pTabList, 0, pTab.nCol - nHidden, nColumn); + goto insert_cleanup; + } + if (pColumn != null && nColumn != pColumn.nId) { + sqlite3ErrorMsg(pParse, "%d values for %d columns", nColumn, pColumn.nId); + goto insert_cleanup; + } - if ( useTempTable ) - { - /* Invoke the coroutine to extract information from the SELECT - ** and add it to a transient table srcTab. The code generated - ** here is from the 4th template: - ** - ** B: open temp table - ** L: yield X - ** if EOF goto M - ** insert row from R..R+n into temp table - ** goto L - ** M: ... - */ - int regRec; /* Register to hold packed record */ - int regTempRowid; /* Register to hold temp table ROWID */ - int addrTop; /* Label "L" */ - int addrIf; /* Address of jump to M */ - - srcTab = pParse.nTab++; - regRec = sqlite3GetTempReg( pParse ); - regTempRowid = sqlite3GetTempReg( pParse ); - sqlite3VdbeAddOp2( v, OP_OpenEphemeral, srcTab, nColumn ); - addrTop = sqlite3VdbeAddOp1( v, OP_Yield, dest.iParm ); - addrIf = sqlite3VdbeAddOp1( v, OP_If, regEof ); - sqlite3VdbeAddOp3( v, OP_MakeRecord, regFromSelect, nColumn, regRec ); - sqlite3VdbeAddOp2( v, OP_NewRowid, srcTab, regTempRowid ); - sqlite3VdbeAddOp3( v, OP_Insert, srcTab, regRec, regTempRowid ); - sqlite3VdbeAddOp2( v, OP_Goto, 0, addrTop ); - sqlite3VdbeJumpHere( v, addrIf ); - sqlite3ReleaseTempReg( pParse, regRec ); - sqlite3ReleaseTempReg( pParse, regTempRowid ); - } - } - else - { - /* This is the case if the data for the INSERT is coming from a VALUES - ** clause - */ - NameContext sNC; - sNC = new NameContext();// memset( &sNC, 0, sNC ).Length; - sNC.pParse = pParse; - srcTab = -1; - Debug.Assert( !useTempTable ); - nColumn = pList != null ? pList.nExpr : 0; - for ( i = 0; i < nColumn; i++ ) - { - if ( sqlite3ResolveExprNames( sNC, ref pList.a[i].pExpr ) != 0 ) - { - goto insert_cleanup; - } - } - } + /* If the INSERT statement included an IDLIST term, then make sure + ** all elements of the IDLIST really are columns of the table and + ** remember the column indices. + ** + ** If the table has an INTEGER PRIMARY KEY column and that column + ** is named in the IDLIST, then record in the keyColumn variable + ** the index into IDLIST of the primary key column. keyColumn is + ** the index of the primary key as it appears in IDLIST, not as + ** is appears in the original table. (The index of the primary + ** key in the original table is pTab.iPKey.) + */ + if (pColumn != null) { + for (i = 0; i < pColumn.nId; i++) { + pColumn.a[i].idx = -1; + } + for (i = 0; i < pColumn.nId; i++) { + for (j = 0; j < pTab.nCol; j++) { + if (pColumn.a[i].zName.Equals(pTab.aCol[j].zName, StringComparison.OrdinalIgnoreCase)) { + pColumn.a[i].idx = j; + if (j == pTab.iPKey) { + keyColumn = i; + } + break; + } + } + if (j >= pTab.nCol) { + if (sqlite3IsRowid(pColumn.a[i].zName)) { + keyColumn = i; + } else { + sqlite3ErrorMsg(pParse, "table %S has no column named %s", + pTabList, 0, pColumn.a[i].zName); + pParse.checkSchema = 1; + goto insert_cleanup; + } + } + } + } - /* Make sure the number of columns in the source data matches the number - ** of columns to be inserted into the table. - */ - if ( IsVirtual( pTab ) ) - { - for ( i = 0; i < pTab.nCol; i++ ) - { - nHidden += ( IsHiddenColumn( pTab.aCol[i] ) ? 1 : 0 ); - } - } - if ( pColumn == null && nColumn != 0 && nColumn != ( pTab.nCol - nHidden ) ) - { - sqlite3ErrorMsg( pParse, - "table %S has %d columns but %d values were supplied", - pTabList, 0, pTab.nCol - nHidden, nColumn ); - goto insert_cleanup; - } - if ( pColumn != null && nColumn != pColumn.nId ) - { - sqlite3ErrorMsg( pParse, "%d values for %d columns", nColumn, pColumn.nId ); - goto insert_cleanup; - } + /* If there is no IDLIST term but the table has an integer primary + ** key, the set the keyColumn variable to the primary key column index + ** in the original table definition. + */ + if (pColumn == null && nColumn > 0) { + keyColumn = pTab.iPKey; + } - /* If the INSERT statement included an IDLIST term, then make sure - ** all elements of the IDLIST really are columns of the table and - ** remember the column indices. - ** - ** If the table has an INTEGER PRIMARY KEY column and that column - ** is named in the IDLIST, then record in the keyColumn variable - ** the index into IDLIST of the primary key column. keyColumn is - ** the index of the primary key as it appears in IDLIST, not as - ** is appears in the original table. (The index of the primary - ** key in the original table is pTab.iPKey.) - */ - if ( pColumn != null ) - { - for ( i = 0; i < pColumn.nId; i++ ) - { - pColumn.a[i].idx = -1; - } - for ( i = 0; i < pColumn.nId; i++ ) - { - for ( j = 0; j < pTab.nCol; j++ ) - { - if ( pColumn.a[i].zName.Equals( pTab.aCol[j].zName ,StringComparison.OrdinalIgnoreCase ) ) - { - pColumn.a[i].idx = j; - if ( j == pTab.iPKey ) - { - keyColumn = i; - } - break; - } - } - if ( j >= pTab.nCol ) - { - if ( sqlite3IsRowid( pColumn.a[i].zName ) ) - { - keyColumn = i; + /* Initialize the count of rows to be inserted + */ + if ((db.flags & SQLITE_CountRows) != 0) { + regRowCount = ++pParse.nMem; + sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount); } - else - { - sqlite3ErrorMsg( pParse, "table %S has no column named %s", - pTabList, 0, pColumn.a[i].zName ); - pParse.checkSchema = 1; - goto insert_cleanup; + + /* If this is not a view, open the table and and all indices */ + if (!isView) { + int nIdx; + + baseCur = pParse.nTab; + nIdx = sqlite3OpenTableAndIndices(pParse, pTab, baseCur, OP_OpenWrite); + aRegIdx = new int[nIdx + 1];// sqlite3DbMallocRaw( db, sizeof( int ) * ( nIdx + 1 ) ); + if (aRegIdx == null) { + goto insert_cleanup; + } + for (i = 0; i < nIdx; i++) { + aRegIdx[i] = ++pParse.nMem; + } } - } - } - } - /* If there is no IDLIST term but the table has an integer primary - ** key, the set the keyColumn variable to the primary key column index - ** in the original table definition. - */ - if ( pColumn == null && nColumn > 0 ) - { - keyColumn = pTab.iPKey; - } + /* This is the top of the main insertion loop */ + if (useTempTable) { + /* This block codes the top of loop only. The complete loop is the + ** following pseudocode (template 4): + ** + ** rewind temp table + ** C: loop over rows of intermediate table + ** transfer values form intermediate table into
+ ** end loop + ** D: ... + */ + addrInsTop = sqlite3VdbeAddOp1(v, OP_Rewind, srcTab); + addrCont = sqlite3VdbeCurrentAddr(v); + } else if (pSelect != null) { + /* This block codes the top of loop only. The complete loop is the + ** following pseudocode (template 3): + ** + ** C: yield X + ** if EOF goto D + ** insert the select result into
from R..R+n + ** goto C + ** D: ... + */ + addrCont = sqlite3VdbeAddOp1(v, OP_Yield, dest.iParm); + addrInsTop = sqlite3VdbeAddOp1(v, OP_If, regEof); + } - /* Initialize the count of rows to be inserted - */ - if ( ( db.flags & SQLITE_CountRows ) != 0 ) - { - regRowCount = ++pParse.nMem; - sqlite3VdbeAddOp2( v, OP_Integer, 0, regRowCount ); - } + /* Allocate registers for holding the rowid of the new row, + ** the content of the new row, and the assemblied row record. + */ + regRowid = regIns = pParse.nMem + 1; + pParse.nMem += pTab.nCol + 1; + if (IsVirtual(pTab)) { + regRowid++; + pParse.nMem++; + } + regData = regRowid + 1; - /* If this is not a view, open the table and and all indices */ - if ( !isView ) - { - int nIdx; - - baseCur = pParse.nTab; - nIdx = sqlite3OpenTableAndIndices( pParse, pTab, baseCur, OP_OpenWrite ); - aRegIdx = new int[nIdx + 1];// sqlite3DbMallocRaw( db, sizeof( int ) * ( nIdx + 1 ) ); - if ( aRegIdx == null ) - { - goto insert_cleanup; - } - for ( i = 0; i < nIdx; i++ ) - { - aRegIdx[i] = ++pParse.nMem; - } - } + /* Run the BEFORE and INSTEAD OF triggers, if there are any + */ + endOfLoop = sqlite3VdbeMakeLabel(v); +#if !SQLITE_OMIT_TRIGGER + if ((tmask & TRIGGER_BEFORE) != 0) { + int regCols = sqlite3GetTempRange(pParse, pTab.nCol + 1); + + /* build the NEW.* reference row. Note that if there is an INTEGER + ** PRIMARY KEY into which a NULL is being inserted, that NULL will be + ** translated into a unique ID for the row. But on a BEFORE trigger, + ** we do not know what the unique ID will be (because the insert has + ** not happened yet) so we substitute a rowid of -1 + */ + if (keyColumn < 0) { + sqlite3VdbeAddOp2(v, OP_Integer, -1, regCols); + } else { + int j1; + if (useTempTable) { + sqlite3VdbeAddOp3(v, OP_Column, srcTab, keyColumn, regCols); + } else { + Debug.Assert(pSelect == null); /* Otherwise useTempTable is true */ + sqlite3ExprCode(pParse, pList.a[keyColumn].pExpr, regCols); + } + j1 = sqlite3VdbeAddOp1(v, OP_NotNull, regCols); + sqlite3VdbeAddOp2(v, OP_Integer, -1, regCols); + sqlite3VdbeJumpHere(v, j1); + sqlite3VdbeAddOp1(v, OP_MustBeInt, regCols); + } + /* Cannot have triggers on a virtual table. If it were possible, + ** this block would have to account for hidden column. + */ + Debug.Assert(!IsVirtual(pTab)); + /* Create the new column data + */ + for (i = 0; i < pTab.nCol; i++) { + if (pColumn == null) { + j = i; + } else { + for (j = 0; j < pColumn.nId; j++) { + if (pColumn.a[j].idx == i) + break; + } + } + if ((!useTempTable && null == pList) || (pColumn != null && j >= pColumn.nId)) { + sqlite3ExprCode(pParse, pTab.aCol[i].pDflt, regCols + i + 1); + } else if (useTempTable) { + sqlite3VdbeAddOp3(v, OP_Column, srcTab, j, regCols + i + 1); + } else { + Debug.Assert(pSelect == null); /* Otherwise useTempTable is true */ + sqlite3ExprCodeAndCache(pParse, pList.a[j].pExpr, regCols + i + 1); + } + } - /* This is the top of the main insertion loop */ - if ( useTempTable ) - { - /* This block codes the top of loop only. The complete loop is the - ** following pseudocode (template 4): - ** - ** rewind temp table - ** C: loop over rows of intermediate table - ** transfer values form intermediate table into
- ** end loop - ** D: ... - */ - addrInsTop = sqlite3VdbeAddOp1( v, OP_Rewind, srcTab ); - addrCont = sqlite3VdbeCurrentAddr( v ); - } - else if ( pSelect != null ) - { - /* This block codes the top of loop only. The complete loop is the - ** following pseudocode (template 3): - ** - ** C: yield X - ** if EOF goto D - ** insert the select result into
from R..R+n - ** goto C - ** D: ... - */ - addrCont = sqlite3VdbeAddOp1( v, OP_Yield, dest.iParm ); - addrInsTop = sqlite3VdbeAddOp1( v, OP_If, regEof ); - } - - /* Allocate registers for holding the rowid of the new row, - ** the content of the new row, and the assemblied row record. - */ - regRowid = regIns = pParse.nMem + 1; - pParse.nMem += pTab.nCol + 1; - if ( IsVirtual( pTab ) ) - { - regRowid++; - pParse.nMem++; - } - regData = regRowid + 1; - - /* Run the BEFORE and INSTEAD OF triggers, if there are any - */ - endOfLoop = sqlite3VdbeMakeLabel( v ); -#if !SQLITE_OMIT_TRIGGER - if ( ( tmask & TRIGGER_BEFORE ) != 0 ) - { - int regCols = sqlite3GetTempRange( pParse, pTab.nCol + 1 ); - - /* build the NEW.* reference row. Note that if there is an INTEGER - ** PRIMARY KEY into which a NULL is being inserted, that NULL will be - ** translated into a unique ID for the row. But on a BEFORE trigger, - ** we do not know what the unique ID will be (because the insert has - ** not happened yet) so we substitute a rowid of -1 - */ - if ( keyColumn < 0 ) - { - sqlite3VdbeAddOp2( v, OP_Integer, -1, regCols ); - } - else - { - int j1; - if ( useTempTable ) - { - sqlite3VdbeAddOp3( v, OP_Column, srcTab, keyColumn, regCols ); - } - else - { - Debug.Assert( pSelect == null ); /* Otherwise useTempTable is true */ - sqlite3ExprCode( pParse, pList.a[keyColumn].pExpr, regCols ); - } - j1 = sqlite3VdbeAddOp1( v, OP_NotNull, regCols ); - sqlite3VdbeAddOp2( v, OP_Integer, -1, regCols ); - sqlite3VdbeJumpHere( v, j1 ); - sqlite3VdbeAddOp1( v, OP_MustBeInt, regCols ); - } - /* Cannot have triggers on a virtual table. If it were possible, - ** this block would have to account for hidden column. - */ - Debug.Assert( !IsVirtual( pTab ) ); - /* Create the new column data - */ - for ( i = 0; i < pTab.nCol; i++ ) - { - if ( pColumn == null ) - { - j = i; - } - else - { - for ( j = 0; j < pColumn.nId; j++ ) - { - if ( pColumn.a[j].idx == i ) - break; - } - } - if ( ( !useTempTable && null == pList ) || ( pColumn != null && j >= pColumn.nId ) ) - { - sqlite3ExprCode( pParse, pTab.aCol[i].pDflt, regCols + i + 1 ); - } - else if ( useTempTable ) - { - sqlite3VdbeAddOp3( v, OP_Column, srcTab, j, regCols + i + 1 ); - } - else - { - Debug.Assert( pSelect == null ); /* Otherwise useTempTable is true */ - sqlite3ExprCodeAndCache( pParse, pList.a[j].pExpr, regCols + i + 1 ); - } - } - - /* If this is an INSERT on a view with an INSTEAD OF INSERT trigger, - ** do not attempt any conversions before assembling the record. - ** If this is a real table, attempt conversions as required by the - ** table column affinities. - */ - if ( !isView ) - { - sqlite3VdbeAddOp2( v, OP_Affinity, regCols + 1, pTab.nCol ); - sqlite3TableAffinityStr( v, pTab ); - } - - /* Fire BEFORE or INSTEAD OF triggers */ - sqlite3CodeRowTrigger( pParse, pTrigger, TK_INSERT, null, TRIGGER_BEFORE, - pTab, regCols - pTab.nCol - 1, onError, endOfLoop ); + /* If this is an INSERT on a view with an INSTEAD OF INSERT trigger, + ** do not attempt any conversions before assembling the record. + ** If this is a real table, attempt conversions as required by the + ** table column affinities. + */ + if (!isView) { + sqlite3VdbeAddOp2(v, OP_Affinity, regCols + 1, pTab.nCol); + sqlite3TableAffinityStr(v, pTab); + } - sqlite3ReleaseTempRange( pParse, regCols, pTab.nCol + 1 ); - } -#endif + /* Fire BEFORE or INSTEAD OF triggers */ + sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, null, TRIGGER_BEFORE, + pTab, regCols - pTab.nCol - 1, onError, endOfLoop); - /* Push the record number for the new entry onto the stack. The -** record number is a randomly generate integer created by NewRowid -** except when the table has an INTEGER PRIMARY KEY column, in which -** case the record number is the same as that column. -*/ - if ( !isView ) - { - if ( IsVirtual( pTab ) ) - { - /* The row that the VUpdate opcode will delete: none */ - sqlite3VdbeAddOp2( v, OP_Null, 0, regIns ); - } - if ( keyColumn >= 0 ) - { - if ( useTempTable ) - { - sqlite3VdbeAddOp3( v, OP_Column, srcTab, keyColumn, regRowid ); - } - else if ( pSelect != null ) - { - sqlite3VdbeAddOp2( v, OP_SCopy, regFromSelect + keyColumn, regRowid ); - } - else - { - VdbeOp pOp; - sqlite3ExprCode( pParse, pList.a[keyColumn].pExpr, regRowid ); - pOp = sqlite3VdbeGetOp( v, -1 ); - if ( ALWAYS( pOp != null ) && pOp.opcode == OP_Null && !IsVirtual( pTab ) ) - { - appendFlag = true; - pOp.opcode = OP_NewRowid; - pOp.p1 = baseCur; - pOp.p2 = regRowid; - pOp.p3 = regAutoinc; - } - } - /* If the PRIMARY KEY expression is NULL, then use OP_NewRowid - ** to generate a unique primary key value. - */ - if ( !appendFlag ) - { - int j1; - if ( !IsVirtual( pTab ) ) - { - j1 = sqlite3VdbeAddOp1( v, OP_NotNull, regRowid ); - sqlite3VdbeAddOp3( v, OP_NewRowid, baseCur, regRowid, regAutoinc ); - sqlite3VdbeJumpHere( v, j1 ); + sqlite3ReleaseTempRange(pParse, regCols, pTab.nCol + 1); } - else - { - j1 = sqlite3VdbeCurrentAddr( v ); - sqlite3VdbeAddOp2( v, OP_IsNull, regRowid, j1 + 2 ); - } - sqlite3VdbeAddOp1( v, OP_MustBeInt, regRowid ); - } - } - else if ( IsVirtual( pTab ) ) - { - sqlite3VdbeAddOp2( v, OP_Null, 0, regRowid ); - } - else - { - sqlite3VdbeAddOp3( v, OP_NewRowid, baseCur, regRowid, regAutoinc ); - appendFlag = true; - } - autoIncStep( pParse, regAutoinc, regRowid ); +#endif - /* Push onto the stack, data for all columns of the new entry, beginning - ** with the first column. - */ - nHidden = 0; - for ( i = 0; i < pTab.nCol; i++ ) - { - int iRegStore = regRowid + 1 + i; - if ( i == pTab.iPKey ) - { - /* The value of the INTEGER PRIMARY KEY column is always a NULL. - ** Whenever this column is read, the record number will be substituted - ** in its place. So will fill this column with a NULL to avoid - ** taking up data space with information that will never be used. */ - sqlite3VdbeAddOp2( v, OP_Null, 0, iRegStore ); - continue; - } - if ( pColumn == null ) - { - if ( IsHiddenColumn( pTab.aCol[i] ) ) - { - Debug.Assert( IsVirtual( pTab ) ); - j = -1; - nHidden++; - } - else - { - j = i - nHidden; - } - } - else - { - for ( j = 0; j < pColumn.nId; j++ ) - { - if ( pColumn.a[j].idx == i ) - break; - } - } - if ( j < 0 || nColumn == 0 || ( pColumn != null && j >= pColumn.nId ) ) - { - sqlite3ExprCode( pParse, pTab.aCol[i].pDflt, iRegStore ); - } - else if ( useTempTable ) - { - sqlite3VdbeAddOp3( v, OP_Column, srcTab, j, iRegStore ); - } - else if ( pSelect != null ) - { - sqlite3VdbeAddOp2( v, OP_SCopy, regFromSelect + j, iRegStore ); - } - else - { - sqlite3ExprCode( pParse, pList.a[j].pExpr, iRegStore ); - } - } + /* Push the record number for the new entry onto the stack. The + ** record number is a randomly generate integer created by NewRowid + ** except when the table has an INTEGER PRIMARY KEY column, in which + ** case the record number is the same as that column. + */ + if (!isView) { + if (IsVirtual(pTab)) { + /* The row that the VUpdate opcode will delete: none */ + sqlite3VdbeAddOp2(v, OP_Null, 0, regIns); + } + if (keyColumn >= 0) { + if (useTempTable) { + sqlite3VdbeAddOp3(v, OP_Column, srcTab, keyColumn, regRowid); + } else if (pSelect != null) { + sqlite3VdbeAddOp2(v, OP_SCopy, regFromSelect + keyColumn, regRowid); + } else { + VdbeOp pOp; + sqlite3ExprCode(pParse, pList.a[keyColumn].pExpr, regRowid); + pOp = sqlite3VdbeGetOp(v, -1); + if (ALWAYS(pOp != null) && pOp.opcode == OP_Null && !IsVirtual(pTab)) { + appendFlag = true; + pOp.opcode = OP_NewRowid; + pOp.p1 = baseCur; + pOp.p2 = regRowid; + pOp.p3 = regAutoinc; + } + } + /* If the PRIMARY KEY expression is NULL, then use OP_NewRowid + ** to generate a unique primary key value. + */ + if (!appendFlag) { + int j1; + if (!IsVirtual(pTab)) { + j1 = sqlite3VdbeAddOp1(v, OP_NotNull, regRowid); + sqlite3VdbeAddOp3(v, OP_NewRowid, baseCur, regRowid, regAutoinc); + sqlite3VdbeJumpHere(v, j1); + } else { + j1 = sqlite3VdbeCurrentAddr(v); + sqlite3VdbeAddOp2(v, OP_IsNull, regRowid, j1 + 2); + } + sqlite3VdbeAddOp1(v, OP_MustBeInt, regRowid); + } + } else if (IsVirtual(pTab)) { + sqlite3VdbeAddOp2(v, OP_Null, 0, regRowid); + } else { + sqlite3VdbeAddOp3(v, OP_NewRowid, baseCur, regRowid, regAutoinc); + appendFlag = true; + } + autoIncStep(pParse, regAutoinc, regRowid); + + /* Push onto the stack, data for all columns of the new entry, beginning + ** with the first column. + */ + nHidden = 0; + for (i = 0; i < pTab.nCol; i++) { + int iRegStore = regRowid + 1 + i; + if (i == pTab.iPKey) { + /* The value of the INTEGER PRIMARY KEY column is always a NULL. + ** Whenever this column is read, the record number will be substituted + ** in its place. So will fill this column with a NULL to avoid + ** taking up data space with information that will never be used. */ + sqlite3VdbeAddOp2(v, OP_Null, 0, iRegStore); + continue; + } + if (pColumn == null) { + if (IsHiddenColumn(pTab.aCol[i])) { + Debug.Assert(IsVirtual(pTab)); + j = -1; + nHidden++; + } else { + j = i - nHidden; + } + } else { + for (j = 0; j < pColumn.nId; j++) { + if (pColumn.a[j].idx == i) + break; + } + } + if (j < 0 || nColumn == 0 || (pColumn != null && j >= pColumn.nId)) { + sqlite3ExprCode(pParse, pTab.aCol[i].pDflt, iRegStore); + } else if (useTempTable) { + sqlite3VdbeAddOp3(v, OP_Column, srcTab, j, iRegStore); + } else if (pSelect != null) { + sqlite3VdbeAddOp2(v, OP_SCopy, regFromSelect + j, iRegStore); + } else { + sqlite3ExprCode(pParse, pList.a[j].pExpr, iRegStore); + } + } - /* Generate code to check constraints and generate index keys and - ** do the insertion. - */ + /* Generate code to check constraints and generate index keys and + ** do the insertion. + */ #if !SQLITE_OMIT_VIRTUALTABLE - if ( IsVirtual( pTab ) ) - { - VTable pVTab = sqlite3GetVTable( db, pTab ); - sqlite3VtabMakeWritable( pParse, pTab ); - sqlite3VdbeAddOp4( v, OP_VUpdate, 1, pTab.nCol + 2, regIns, pVTab, P4_VTAB ); - sqlite3VdbeChangeP5( v, (byte)( onError == OE_Default ? OE_Abort : onError ) ); - sqlite3MayAbort( pParse ); - } - else + if (IsVirtual(pTab)) { + VTable pVTab = sqlite3GetVTable(db, pTab); + sqlite3VtabMakeWritable(pParse, pTab); + sqlite3VdbeAddOp4(v, OP_VUpdate, 1, pTab.nCol + 2, regIns, pVTab, P4_VTAB); + sqlite3VdbeChangeP5(v, (byte)(onError == OE_Default ? OE_Abort : onError)); + sqlite3MayAbort(pParse); + } else #endif - { - int isReplace = 0; /* Set to true if constraints may cause a replace */ - sqlite3GenerateConstraintChecks( pParse, pTab, baseCur, regIns, aRegIdx, - keyColumn >= 0 ? 1 : 0, false, onError, endOfLoop, out isReplace - ); - sqlite3FkCheck( pParse, pTab, 0, regIns ); - sqlite3CompleteInsertion( - pParse, pTab, baseCur, regIns, aRegIdx, false, appendFlag, isReplace == 0 - ); - } - } + { + int isReplace = 0; /* Set to true if constraints may cause a replace */ + sqlite3GenerateConstraintChecks(pParse, pTab, baseCur, regIns, aRegIdx, + keyColumn >= 0 ? 1 : 0, false, onError, endOfLoop, out isReplace + ); + sqlite3FkCheck(pParse, pTab, 0, regIns); + sqlite3CompleteInsertion( + pParse, pTab, baseCur, regIns, aRegIdx, false, appendFlag, isReplace == 0 + ); + } + } - /* Update the count of rows that are inserted - */ - if ( ( db.flags & SQLITE_CountRows ) != 0 ) - { - sqlite3VdbeAddOp2( v, OP_AddImm, regRowCount, 1 ); - } + /* Update the count of rows that are inserted + */ + if ((db.flags & SQLITE_CountRows) != 0) { + sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1); + } #if !SQLITE_OMIT_TRIGGER - if ( pTrigger != null ) - { - /* Code AFTER triggers */ - sqlite3CodeRowTrigger( pParse, pTrigger, TK_INSERT, null, TRIGGER_AFTER, - pTab, regData - 2 - pTab.nCol, onError, endOfLoop ); - } + if (pTrigger != null) { + /* Code AFTER triggers */ + sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, null, TRIGGER_AFTER, + pTab, regData - 2 - pTab.nCol, onError, endOfLoop); + } #endif - /* The bottom of the main insertion loop, if the data source -** is a SELECT statement. -*/ - sqlite3VdbeResolveLabel( v, endOfLoop ); - if ( useTempTable ) - { - sqlite3VdbeAddOp2( v, OP_Next, srcTab, addrCont ); - sqlite3VdbeJumpHere( v, addrInsTop ); - sqlite3VdbeAddOp1( v, OP_Close, srcTab ); - } - else if ( pSelect != null ) - { - sqlite3VdbeAddOp2( v, OP_Goto, 0, addrCont ); - sqlite3VdbeJumpHere( v, addrInsTop ); - } - - if ( !IsVirtual( pTab ) && !isView ) - { - /* Close all tables opened */ - sqlite3VdbeAddOp1( v, OP_Close, baseCur ); - for ( idx = 1, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, idx++ ) - { - sqlite3VdbeAddOp1( v, OP_Close, idx + baseCur ); - } - } - -insert_end: - /* Update the sqlite_sequence table by storing the content of the - ** maximum rowid counter values recorded while inserting into - ** autoincrement tables. + /* The bottom of the main insertion loop, if the data source + ** is a SELECT statement. */ - if ( pParse.nested == 0 && pParse.pTriggerTab == null ) - { - sqlite3AutoincrementEnd( pParse ); - } + sqlite3VdbeResolveLabel(v, endOfLoop); + if (useTempTable) { + sqlite3VdbeAddOp2(v, OP_Next, srcTab, addrCont); + sqlite3VdbeJumpHere(v, addrInsTop); + sqlite3VdbeAddOp1(v, OP_Close, srcTab); + } else if (pSelect != null) { + sqlite3VdbeAddOp2(v, OP_Goto, 0, addrCont); + sqlite3VdbeJumpHere(v, addrInsTop); + } - /* - ** Return the number of rows inserted. If this routine is - ** generating code because of a call to sqlite3NestedParse(), do not - ** invoke the callback function. - */ - if ( ( db.flags & SQLITE_CountRows ) != 0 && 0 == pParse.nested && null == pParse.pTriggerTab ) - { - sqlite3VdbeAddOp2( v, OP_ResultRow, regRowCount, 1 ); - sqlite3VdbeSetNumCols( v, 1 ); - sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "rows inserted", SQLITE_STATIC ); - } + if (!IsVirtual(pTab) && !isView) { + /* Close all tables opened */ + sqlite3VdbeAddOp1(v, OP_Close, baseCur); + for (idx = 1, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, idx++) { + sqlite3VdbeAddOp1(v, OP_Close, idx + baseCur); + } + } -insert_cleanup: - sqlite3SrcListDelete( db, ref pTabList ); - sqlite3ExprListDelete( db, ref pList ); - sqlite3SelectDelete( db, ref pSelect ); - sqlite3IdListDelete( db, ref pColumn ); - sqlite3DbFree( db, ref aRegIdx ); - } + insert_end: + /* Update the sqlite_sequence table by storing the content of the + ** maximum rowid counter values recorded while inserting into + ** autoincrement tables. + */ + if (pParse.nested == 0 && pParse.pTriggerTab == null) { + sqlite3AutoincrementEnd(pParse); + } - /* Make sure "isView" and other macros defined above are undefined. Otherwise - ** thely may interfere with compilation of other functions in this file - ** (or in another file, if this file becomes part of the amalgamation). */ - //#if isView - // #undef isView - //#endif - //#if pTrigger - // #undef pTrigger - //#endif - //#if tmask - // #undef tmask - //#endif + /* + ** Return the number of rows inserted. If this routine is + ** generating code because of a call to sqlite3NestedParse(), do not + ** invoke the callback function. + */ + if ((db.flags & SQLITE_CountRows) != 0 && 0 == pParse.nested && null == pParse.pTriggerTab) { + sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1); + sqlite3VdbeSetNumCols(v, 1); + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows inserted", SQLITE_STATIC); + } - /* - ** Generate code to do constraint checks prior to an INSERT or an UPDATE. - ** - ** The input is a range of consecutive registers as follows: - ** - ** 1. The rowid of the row after the update. - ** - ** 2. The data in the first column of the entry after the update. - ** - ** i. Data from middle columns... - ** - ** N. The data in the last column of the entry after the update. - ** - ** The regRowid parameter is the index of the register containing (1). - ** - ** If isUpdate is true and rowidChng is non-zero, then rowidChng contains - ** the address of a register containing the rowid before the update takes - ** place. isUpdate is true for UPDATEs and false for INSERTs. If isUpdate - ** is false, indicating an INSERT statement, then a non-zero rowidChng - ** indicates that the rowid was explicitly specified as part of the - ** INSERT statement. If rowidChng is false, it means that the rowid is - ** computed automatically in an insert or that the rowid value is not - ** modified by an update. - ** - ** The code generated by this routine store new index entries into - ** registers identified by aRegIdx[]. No index entry is created for - ** indices where aRegIdx[i]==0. The order of indices in aRegIdx[] is - ** the same as the order of indices on the linked list of indices - ** attached to the table. - ** - ** This routine also generates code to check constraints. NOT NULL, - ** CHECK, and UNIQUE constraints are all checked. If a constraint fails, - ** then the appropriate action is performed. There are five possible - ** actions: ROLLBACK, ABORT, FAIL, REPLACE, and IGNORE. - ** - ** Constraint type Action What Happens - ** --------------- ---------- ---------------------------------------- - ** any ROLLBACK The current transaction is rolled back and - ** sqlite3_exec() returns immediately with a - ** return code of SQLITE_CONSTRAINT. - ** - ** any ABORT Back out changes from the current command - ** only (do not do a complete rollback) then - ** cause sqlite3_exec() to return immediately - ** with SQLITE_CONSTRAINT. - ** - ** any FAIL Sqlite_exec() returns immediately with a - ** return code of SQLITE_CONSTRAINT. The - ** transaction is not rolled back and any - ** prior changes are retained. - ** - ** any IGNORE The record number and data is popped from - ** the stack and there is an immediate jump - ** to label ignoreDest. - ** - ** NOT NULL REPLACE The NULL value is replace by the default - ** value for that column. If the default value - ** is NULL, the action is the same as ABORT. - ** - ** UNIQUE REPLACE The other row that conflicts with the row - ** being inserted is removed. - ** - ** CHECK REPLACE Illegal. The results in an exception. - ** - ** Which action to take is determined by the overrideError parameter. - ** Or if overrideError==OE_Default, then the pParse.onError parameter - ** is used. Or if pParse.onError==OE_Default then the onError value - ** for the constraint is used. - ** - ** The calling routine must open a read/write cursor for pTab with - ** cursor number "baseCur". All indices of pTab must also have open - ** read/write cursors with cursor number baseCur+i for the i-th cursor. - ** Except, if there is no possibility of a REPLACE action then - ** cursors do not need to be open for indices where aRegIdx[i]==0. - */ - static void sqlite3GenerateConstraintChecks( - Parse pParse, /* The parser context */ - Table pTab, /* the table into which we are inserting */ - int baseCur, /* Index of a read/write cursor pointing at pTab */ - int regRowid, /* Index of the range of input registers */ - int[] aRegIdx, /* Register used by each index. 0 for unused indices */ - int rowidChng, /* True if the rowid might collide with existing entry */ - bool isUpdate, /* True for UPDATE, False for INSERT */ - int overrideError, /* Override onError to this if not OE_Default */ - int ignoreDest, /* Jump to this label on an OE_Ignore resolution */ - out int pbMayReplace /* OUT: Set to true if constraint may cause a replace */ - ) - { - - int i; /* loop counter */ - Vdbe v; /* VDBE under constrution */ - int nCol; /* Number of columns */ - int onError; /* Conflict resolution strategy */ - int j1; /* Addresss of jump instruction */ - int j2 = 0, j3; /* Addresses of jump instructions */ - int regData; /* Register containing first data column */ - int iCur; /* Table cursor number */ - Index pIdx; /* Pointer to one of the indices */ - bool seenReplace = false; /* True if REPLACE is used to resolve INT PK conflict */ - int regOldRowid = ( rowidChng != 0 && isUpdate ) ? rowidChng : regRowid; - - v = sqlite3GetVdbe( pParse ); - Debug.Assert( v != null ); - Debug.Assert( pTab.pSelect == null ); /* This table is not a VIEW */ - nCol = pTab.nCol; - regData = regRowid + 1; - - - /* Test all NOT NULL constraints. - */ - for ( i = 0; i < nCol; i++ ) - { - if ( i == pTab.iPKey ) - { - continue; - } - onError = pTab.aCol[i].notNull; - if ( onError == OE_None ) - continue; - if ( overrideError != OE_Default ) - { - onError = overrideError; + insert_cleanup: + sqlite3SrcListDelete(db, ref pTabList); + sqlite3ExprListDelete(db, ref pList); + sqlite3SelectDelete(db, ref pSelect); + sqlite3IdListDelete(db, ref pColumn); + sqlite3DbFree(db, ref aRegIdx); } - else if ( onError == OE_Default ) - { - onError = OE_Abort; - } - if ( onError == OE_Replace && pTab.aCol[i].pDflt == null ) - { - onError = OE_Abort; - } - Debug.Assert( onError == OE_Rollback || onError == OE_Abort || onError == OE_Fail - || onError == OE_Ignore || onError == OE_Replace ); - switch ( onError ) - { - case OE_Abort: - { - sqlite3MayAbort( pParse ); - goto case OE_Fail; - } - case OE_Rollback: - case OE_Fail: - { - string zMsg; - sqlite3VdbeAddOp3( v, OP_HaltIfNull, - SQLITE_CONSTRAINT, onError, regData + i ); - zMsg = sqlite3MPrintf( pParse.db, "%s.%s may not be NULL", - pTab.zName, pTab.aCol[i].zName ); - sqlite3VdbeChangeP4( v, -1, zMsg, P4_DYNAMIC ); - break; - } - case OE_Ignore: - { - sqlite3VdbeAddOp2( v, OP_IsNull, regData + i, ignoreDest ); - break; - } - default: - { - Debug.Assert( onError == OE_Replace ); - j1 = sqlite3VdbeAddOp1( v, OP_NotNull, regData + i ); - sqlite3ExprCode( pParse, pTab.aCol[i].pDflt, regData + i ); - sqlite3VdbeJumpHere( v, j1 ); - break; + + /* Make sure "isView" and other macros defined above are undefined. Otherwise + ** thely may interfere with compilation of other functions in this file + ** (or in another file, if this file becomes part of the amalgamation). */ + //#if isView + // #undef isView + //#endif + //#if pTrigger + // #undef pTrigger + //#endif + //#if tmask + // #undef tmask + //#endif + + /* + ** Generate code to do constraint checks prior to an INSERT or an UPDATE. + ** + ** The input is a range of consecutive registers as follows: + ** + ** 1. The rowid of the row after the update. + ** + ** 2. The data in the first column of the entry after the update. + ** + ** i. Data from middle columns... + ** + ** N. The data in the last column of the entry after the update. + ** + ** The regRowid parameter is the index of the register containing (1). + ** + ** If isUpdate is true and rowidChng is non-zero, then rowidChng contains + ** the address of a register containing the rowid before the update takes + ** place. isUpdate is true for UPDATEs and false for INSERTs. If isUpdate + ** is false, indicating an INSERT statement, then a non-zero rowidChng + ** indicates that the rowid was explicitly specified as part of the + ** INSERT statement. If rowidChng is false, it means that the rowid is + ** computed automatically in an insert or that the rowid value is not + ** modified by an update. + ** + ** The code generated by this routine store new index entries into + ** registers identified by aRegIdx[]. No index entry is created for + ** indices where aRegIdx[i]==0. The order of indices in aRegIdx[] is + ** the same as the order of indices on the linked list of indices + ** attached to the table. + ** + ** This routine also generates code to check constraints. NOT NULL, + ** CHECK, and UNIQUE constraints are all checked. If a constraint fails, + ** then the appropriate action is performed. There are five possible + ** actions: ROLLBACK, ABORT, FAIL, REPLACE, and IGNORE. + ** + ** Constraint type Action What Happens + ** --------------- ---------- ---------------------------------------- + ** any ROLLBACK The current transaction is rolled back and + ** sqlite3_exec() returns immediately with a + ** return code of SQLITE_CONSTRAINT. + ** + ** any ABORT Back out changes from the current command + ** only (do not do a complete rollback) then + ** cause sqlite3_exec() to return immediately + ** with SQLITE_CONSTRAINT. + ** + ** any FAIL Sqlite_exec() returns immediately with a + ** return code of SQLITE_CONSTRAINT. The + ** transaction is not rolled back and any + ** prior changes are retained. + ** + ** any IGNORE The record number and data is popped from + ** the stack and there is an immediate jump + ** to label ignoreDest. + ** + ** NOT NULL REPLACE The NULL value is replace by the default + ** value for that column. If the default value + ** is NULL, the action is the same as ABORT. + ** + ** UNIQUE REPLACE The other row that conflicts with the row + ** being inserted is removed. + ** + ** CHECK REPLACE Illegal. The results in an exception. + ** + ** Which action to take is determined by the overrideError parameter. + ** Or if overrideError==OE_Default, then the pParse.onError parameter + ** is used. Or if pParse.onError==OE_Default then the onError value + ** for the constraint is used. + ** + ** The calling routine must open a read/write cursor for pTab with + ** cursor number "baseCur". All indices of pTab must also have open + ** read/write cursors with cursor number baseCur+i for the i-th cursor. + ** Except, if there is no possibility of a REPLACE action then + ** cursors do not need to be open for indices where aRegIdx[i]==0. + */ + static void sqlite3GenerateConstraintChecks( + Parse pParse, /* The parser context */ + Table pTab, /* the table into which we are inserting */ + int baseCur, /* Index of a read/write cursor pointing at pTab */ + int regRowid, /* Index of the range of input registers */ + int[] aRegIdx, /* Register used by each index. 0 for unused indices */ + int rowidChng, /* True if the rowid might collide with existing entry */ + bool isUpdate, /* True for UPDATE, False for INSERT */ + int overrideError, /* Override onError to this if not OE_Default */ + int ignoreDest, /* Jump to this label on an OE_Ignore resolution */ + out int pbMayReplace /* OUT: Set to true if constraint may cause a replace */ + ) { + + int i; /* loop counter */ + Vdbe v; /* VDBE under constrution */ + int nCol; /* Number of columns */ + int onError; /* Conflict resolution strategy */ + int j1; /* Addresss of jump instruction */ + int j2 = 0, j3; /* Addresses of jump instructions */ + int regData; /* Register containing first data column */ + int iCur; /* Table cursor number */ + Index pIdx; /* Pointer to one of the indices */ + bool seenReplace = false; /* True if REPLACE is used to resolve INT PK conflict */ + int regOldRowid = (rowidChng != 0 && isUpdate) ? rowidChng : regRowid; + + v = sqlite3GetVdbe(pParse); + Debug.Assert(v != null); + Debug.Assert(pTab.pSelect == null); /* This table is not a VIEW */ + nCol = pTab.nCol; + regData = regRowid + 1; + + + /* Test all NOT NULL constraints. + */ + for (i = 0; i < nCol; i++) { + if (i == pTab.iPKey) { + continue; + } + onError = pTab.aCol[i].notNull; + if (onError == OE_None) + continue; + if (overrideError != OE_Default) { + onError = overrideError; + } else if (onError == OE_Default) { + onError = OE_Abort; + } + if (onError == OE_Replace && pTab.aCol[i].pDflt == null) { + onError = OE_Abort; + } + Debug.Assert(onError == OE_Rollback || onError == OE_Abort || onError == OE_Fail + || onError == OE_Ignore || onError == OE_Replace); + switch (onError) { + case OE_Abort: { + sqlite3MayAbort(pParse); + goto case OE_Fail; + } + case OE_Rollback: + case OE_Fail: { + string zMsg; + sqlite3VdbeAddOp3(v, OP_HaltIfNull, + SQLITE_CONSTRAINT, onError, regData + i); + zMsg = sqlite3MPrintf(pParse.db, "%s.%s may not be NULL", + pTab.zName, pTab.aCol[i].zName); + sqlite3VdbeChangeP4(v, -1, zMsg, P4_DYNAMIC); + break; + } + case OE_Ignore: { + sqlite3VdbeAddOp2(v, OP_IsNull, regData + i, ignoreDest); + break; + } + default: { + Debug.Assert(onError == OE_Replace); + j1 = sqlite3VdbeAddOp1(v, OP_NotNull, regData + i); + sqlite3ExprCode(pParse, pTab.aCol[i].pDflt, regData + i); + sqlite3VdbeJumpHere(v, j1); + break; + } + } } - } - } - /* Test all CHECK constraints - */ + /* Test all CHECK constraints + */ #if !SQLITE_OMIT_CHECK - if ( pTab.pCheck != null && ( pParse.db.flags & SQLITE_IgnoreChecks ) == 0 ) - { - int allOk = sqlite3VdbeMakeLabel( v ); - pParse.ckBase = regData; - sqlite3ExprIfTrue( pParse, pTab.pCheck, allOk, SQLITE_JUMPIFNULL ); - onError = overrideError != OE_Default ? overrideError : OE_Abort; - if ( onError == OE_Ignore ) - { - sqlite3VdbeAddOp2( v, OP_Goto, 0, ignoreDest ); - } - else - { - if ( onError == OE_Replace ) - onError = OE_Abort; /* IMP: R-15569-63625 */ - sqlite3HaltConstraint( pParse, onError, (string)null, 0 ); - } - sqlite3VdbeResolveLabel( v, allOk ); - } + if (pTab.pCheck != null && (pParse.db.flags & SQLITE_IgnoreChecks) == 0) { + int allOk = sqlite3VdbeMakeLabel(v); + pParse.ckBase = regData; + sqlite3ExprIfTrue(pParse, pTab.pCheck, allOk, SQLITE_JUMPIFNULL); + onError = overrideError != OE_Default ? overrideError : OE_Abort; + if (onError == OE_Ignore) { + sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest); + } else { + if (onError == OE_Replace) + onError = OE_Abort; /* IMP: R-15569-63625 */ + sqlite3HaltConstraint(pParse, onError, (string)null, 0); + } + sqlite3VdbeResolveLabel(v, allOk); + } #endif // * !SQLITE_OMIT_CHECK) */ - /* If we have an INTEGER PRIMARY KEY, make sure the primary key -** of the new record does not previously exist. Except, if this -** is an UPDATE and the primary key is not changing, that is OK. -*/ - if ( rowidChng != 0 ) - { - onError = pTab.keyConf; - if ( overrideError != OE_Default ) - { - onError = overrideError; - } - else if ( onError == OE_Default ) - { - onError = OE_Abort; - } + /* If we have an INTEGER PRIMARY KEY, make sure the primary key + ** of the new record does not previously exist. Except, if this + ** is an UPDATE and the primary key is not changing, that is OK. + */ + if (rowidChng != 0) { + onError = pTab.keyConf; + if (overrideError != OE_Default) { + onError = overrideError; + } else if (onError == OE_Default) { + onError = OE_Abort; + } - if ( isUpdate ) - { - j2 = sqlite3VdbeAddOp3( v, OP_Eq, regRowid, 0, rowidChng ); - } - j3 = sqlite3VdbeAddOp3( v, OP_NotExists, baseCur, 0, regRowid ); - switch ( onError ) - { - default: - { - onError = OE_Abort; - /* Fall thru into the next case */ - } - goto case OE_Rollback; - case OE_Rollback: - case OE_Abort: - case OE_Fail: - { - sqlite3HaltConstraint( - pParse, onError, "PRIMARY KEY must be unique", P4_STATIC ); - break; - } - case OE_Replace: - { - /* If there are DELETE triggers on this table and the - ** recursive-triggers flag is set, call GenerateRowDelete() to - ** remove the conflicting row from the the table. This will fire - ** the triggers and remove both the table and index b-tree entries. - ** - ** Otherwise, if there are no triggers or the recursive-triggers - ** flag is not set, but the table has one or more indexes, call - ** GenerateRowIndexDelete(). This removes the index b-tree entries - ** only. The table b-tree entry will be replaced by the new entry - ** when it is inserted. - ** - ** If either GenerateRowDelete() or GenerateRowIndexDelete() is called, - ** also invoke MultiWrite() to indicate that this VDBE may require - ** statement rollback (if the statement is aborted after the delete - ** takes place). Earlier versions called sqlite3MultiWrite() regardless, - ** but being more selective here allows statements like: - ** - ** REPLACE INTO t(rowid) VALUES($newrowid) - ** - ** to run without a statement journal if there are no indexes on the - ** table. - */ - Trigger pTrigger = null; - if ( ( pParse.db.flags & SQLITE_RecTriggers ) != 0 ) - { - int iDummy; - pTrigger = sqlite3TriggersExist( pParse, pTab, TK_DELETE, null, out iDummy ); - } - if ( pTrigger != null || sqlite3FkRequired( pParse, pTab, null, 0 ) != 0 ) - { - sqlite3MultiWrite( pParse ); - sqlite3GenerateRowDelete( - pParse, pTab, baseCur, regRowid, 0, pTrigger, OE_Replace - ); - } - else - if ( pTab.pIndex != null ) - { - sqlite3MultiWrite( pParse ); - sqlite3GenerateRowIndexDelete( pParse, pTab, baseCur, 0 ); + if (isUpdate) { + j2 = sqlite3VdbeAddOp3(v, OP_Eq, regRowid, 0, rowidChng); + } + j3 = sqlite3VdbeAddOp3(v, OP_NotExists, baseCur, 0, regRowid); + switch (onError) { + default: { + onError = OE_Abort; + /* Fall thru into the next case */ + } + goto case OE_Rollback; + case OE_Rollback: + case OE_Abort: + case OE_Fail: { + sqlite3HaltConstraint( + pParse, onError, "PRIMARY KEY must be unique", P4_STATIC); + break; + } + case OE_Replace: { + /* If there are DELETE triggers on this table and the + ** recursive-triggers flag is set, call GenerateRowDelete() to + ** remove the conflicting row from the the table. This will fire + ** the triggers and remove both the table and index b-tree entries. + ** + ** Otherwise, if there are no triggers or the recursive-triggers + ** flag is not set, but the table has one or more indexes, call + ** GenerateRowIndexDelete(). This removes the index b-tree entries + ** only. The table b-tree entry will be replaced by the new entry + ** when it is inserted. + ** + ** If either GenerateRowDelete() or GenerateRowIndexDelete() is called, + ** also invoke MultiWrite() to indicate that this VDBE may require + ** statement rollback (if the statement is aborted after the delete + ** takes place). Earlier versions called sqlite3MultiWrite() regardless, + ** but being more selective here allows statements like: + ** + ** REPLACE INTO t(rowid) VALUES($newrowid) + ** + ** to run without a statement journal if there are no indexes on the + ** table. + */ + Trigger pTrigger = null; + if ((pParse.db.flags & SQLITE_RecTriggers) != 0) { + int iDummy; + pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, null, out iDummy); + } + if (pTrigger != null || sqlite3FkRequired(pParse, pTab, null, 0) != 0) { + sqlite3MultiWrite(pParse); + sqlite3GenerateRowDelete( + pParse, pTab, baseCur, regRowid, 0, pTrigger, OE_Replace + ); + } else + if (pTab.pIndex != null) { + sqlite3MultiWrite(pParse); + sqlite3GenerateRowIndexDelete(pParse, pTab, baseCur, 0); + } + seenReplace = true; + break; + } + case OE_Ignore: { + Debug.Assert(!seenReplace); + sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest); + break; + } + } + sqlite3VdbeJumpHere(v, j3); + if (isUpdate) { + sqlite3VdbeJumpHere(v, j2); } - seenReplace = true; - break; - } - case OE_Ignore: - { - Debug.Assert( !seenReplace ); - sqlite3VdbeAddOp2( v, OP_Goto, 0, ignoreDest ); - break; } - } - sqlite3VdbeJumpHere( v, j3 ); - if ( isUpdate ) - { - sqlite3VdbeJumpHere( v, j2 ); - } - } - /* Test all UNIQUE constraints by creating entries for each UNIQUE - ** index and making sure that duplicate entries do not already exist. - ** Add the new records to the indices as we go. - */ - for ( iCur = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, iCur++ ) - { - int regIdx; - int regR; - - if ( aRegIdx[iCur] == 0 ) - continue; /* Skip unused indices */ - - /* Create a key for accessing the index entry */ - regIdx = sqlite3GetTempRange( pParse, pIdx.nColumn + 1 ); - for ( i = 0; i < pIdx.nColumn; i++ ) - { - int idx = pIdx.aiColumn[i]; - if ( idx == pTab.iPKey ) - { - sqlite3VdbeAddOp2( v, OP_SCopy, regRowid, regIdx + i ); - } - else - { - sqlite3VdbeAddOp2( v, OP_SCopy, regData + idx, regIdx + i ); - } - } - sqlite3VdbeAddOp2( v, OP_SCopy, regRowid, regIdx + i ); - sqlite3VdbeAddOp3( v, OP_MakeRecord, regIdx, pIdx.nColumn + 1, aRegIdx[iCur] ); - sqlite3VdbeChangeP4( v, -1, sqlite3IndexAffinityStr( v, pIdx ), P4_TRANSIENT ); - sqlite3ExprCacheAffinityChange( pParse, regIdx, pIdx.nColumn + 1 ); - - /* Find out what action to take in case there is an indexing conflict */ - onError = pIdx.onError; - if ( onError == OE_None ) - { - sqlite3ReleaseTempRange( pParse, regIdx, pIdx.nColumn + 1 ); - continue; /* pIdx is not a UNIQUE index */ - } + /* Test all UNIQUE constraints by creating entries for each UNIQUE + ** index and making sure that duplicate entries do not already exist. + ** Add the new records to the indices as we go. + */ + for (iCur = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, iCur++) { + int regIdx; + int regR; + + if (aRegIdx[iCur] == 0) + continue; /* Skip unused indices */ + + /* Create a key for accessing the index entry */ + regIdx = sqlite3GetTempRange(pParse, pIdx.nColumn + 1); + for (i = 0; i < pIdx.nColumn; i++) { + int idx = pIdx.aiColumn[i]; + if (idx == pTab.iPKey) { + sqlite3VdbeAddOp2(v, OP_SCopy, regRowid, regIdx + i); + } else { + sqlite3VdbeAddOp2(v, OP_SCopy, regData + idx, regIdx + i); + } + } + sqlite3VdbeAddOp2(v, OP_SCopy, regRowid, regIdx + i); + sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx.nColumn + 1, aRegIdx[iCur]); + sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), P4_TRANSIENT); + sqlite3ExprCacheAffinityChange(pParse, regIdx, pIdx.nColumn + 1); + + /* Find out what action to take in case there is an indexing conflict */ + onError = pIdx.onError; + if (onError == OE_None) { + sqlite3ReleaseTempRange(pParse, regIdx, pIdx.nColumn + 1); + continue; /* pIdx is not a UNIQUE index */ + } - if ( overrideError != OE_Default ) - { - onError = overrideError; - } - else if ( onError == OE_Default ) - { - onError = OE_Abort; - } - if ( seenReplace ) - { - if ( onError == OE_Ignore ) - onError = OE_Replace; - else if ( onError == OE_Fail ) - onError = OE_Abort; - } + if (overrideError != OE_Default) { + onError = overrideError; + } else if (onError == OE_Default) { + onError = OE_Abort; + } + if (seenReplace) { + if (onError == OE_Ignore) + onError = OE_Replace; + else if (onError == OE_Fail) + onError = OE_Abort; + } - /* Check to see if the new index entry will be unique */ - regR = sqlite3GetTempReg( pParse ); - sqlite3VdbeAddOp2( v, OP_SCopy, regOldRowid, regR ); - j3 = sqlite3VdbeAddOp4( v, OP_IsUnique, baseCur + iCur + 1, 0, - regR, regIdx,//regR, SQLITE_INT_TO_PTR(regIdx), - P4_INT32 ); - sqlite3ReleaseTempRange( pParse, regIdx, pIdx.nColumn + 1 ); - - /* Generate code that executes if the new index entry is not unique */ - Debug.Assert( onError == OE_Rollback || onError == OE_Abort || onError == OE_Fail - || onError == OE_Ignore || onError == OE_Replace ); - switch ( onError ) - { - case OE_Rollback: - case OE_Abort: - case OE_Fail: - { - int j; - StrAccum errMsg = new StrAccum( 200 ); - string zSep; - string zErr; - - sqlite3StrAccumInit( errMsg, null, 0, 200 ); - errMsg.db = pParse.db; - zSep = pIdx.nColumn > 1 ? "columns " : "column "; - for ( j = 0; j < pIdx.nColumn; j++ ) - { - string zCol = pTab.aCol[pIdx.aiColumn[j]].zName; - sqlite3StrAccumAppend( errMsg, zSep, -1 ); - zSep = ", "; - sqlite3StrAccumAppend( errMsg, zCol, -1 ); - } - sqlite3StrAccumAppend( errMsg, - pIdx.nColumn > 1 ? " are not unique" : " is not unique", -1 ); - zErr = sqlite3StrAccumFinish( errMsg ); - sqlite3HaltConstraint( pParse, onError, zErr, 0 ); - sqlite3DbFree( errMsg.db, ref zErr ); - break; - } - case OE_Ignore: - { - Debug.Assert( !seenReplace ); - sqlite3VdbeAddOp2( v, OP_Goto, 0, ignoreDest ); - break; + /* Check to see if the new index entry will be unique */ + regR = sqlite3GetTempReg(pParse); + sqlite3VdbeAddOp2(v, OP_SCopy, regOldRowid, regR); + j3 = sqlite3VdbeAddOp4(v, OP_IsUnique, baseCur + iCur + 1, 0, + regR, regIdx,//regR, SQLITE_INT_TO_PTR(regIdx), + P4_INT32); + sqlite3ReleaseTempRange(pParse, regIdx, pIdx.nColumn + 1); + + /* Generate code that executes if the new index entry is not unique */ + Debug.Assert(onError == OE_Rollback || onError == OE_Abort || onError == OE_Fail + || onError == OE_Ignore || onError == OE_Replace); + switch (onError) { + case OE_Rollback: + case OE_Abort: + case OE_Fail: { + int j; + StrAccum errMsg = new StrAccum(200); + string zSep; + string zErr; + + sqlite3StrAccumInit(errMsg, null, 0, 200); + errMsg.db = pParse.db; + zSep = pIdx.nColumn > 1 ? "columns " : "column "; + for (j = 0; j < pIdx.nColumn; j++) { + string zCol = pTab.aCol[pIdx.aiColumn[j]].zName; + sqlite3StrAccumAppend(errMsg, zSep, -1); + zSep = ", "; + sqlite3StrAccumAppend(errMsg, zCol, -1); + } + sqlite3StrAccumAppend(errMsg, + pIdx.nColumn > 1 ? " are not unique" : " is not unique", -1); + zErr = sqlite3StrAccumFinish(errMsg); + sqlite3HaltConstraint(pParse, onError, zErr, 0); + sqlite3DbFree(errMsg.db, ref zErr); + break; + } + case OE_Ignore: { + Debug.Assert(!seenReplace); + sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest); + break; + } + default: { + Trigger pTrigger = null; + Debug.Assert(onError == OE_Replace); + sqlite3MultiWrite(pParse); + if ((pParse.db.flags & SQLITE_RecTriggers) != 0) { + int iDummy; + pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, null, out iDummy); + } + sqlite3GenerateRowDelete( + pParse, pTab, baseCur, regR, 0, pTrigger, OE_Replace + ); + seenReplace = true; + break; + } + } + sqlite3VdbeJumpHere(v, j3); + sqlite3ReleaseTempReg(pParse, regR); } - default: + //if ( pbMayReplace ) { - Trigger pTrigger = null; - Debug.Assert( onError == OE_Replace ); - sqlite3MultiWrite( pParse ); - if ( ( pParse.db.flags & SQLITE_RecTriggers ) != 0 ) - { - int iDummy; - pTrigger = sqlite3TriggersExist( pParse, pTab, TK_DELETE, null, out iDummy ); - } - sqlite3GenerateRowDelete( - pParse, pTab, baseCur, regR, 0, pTrigger, OE_Replace - ); - seenReplace = true; - break; + pbMayReplace = seenReplace ? 1 : 0; } } - sqlite3VdbeJumpHere( v, j3 ); - sqlite3ReleaseTempReg( pParse, regR ); - } - //if ( pbMayReplace ) - { - pbMayReplace = seenReplace ? 1 : 0; - } - } - /* - ** This routine generates code to finish the INSERT or UPDATE operation - ** that was started by a prior call to sqlite3GenerateConstraintChecks. - ** A consecutive range of registers starting at regRowid contains the - ** rowid and the content to be inserted. - ** - ** The arguments to this routine should be the same as the first six - ** arguments to sqlite3GenerateConstraintChecks. - */ - static void sqlite3CompleteInsertion( - Parse pParse, /* The parser context */ - Table pTab, /* the table into which we are inserting */ - int baseCur, /* Index of a read/write cursor pointing at pTab */ - int regRowid, /* Range of content */ - int[] aRegIdx, /* Register used by each index. 0 for unused indices */ - bool isUpdate, /* True for UPDATE, False for INSERT */ - bool appendBias, /* True if this is likely to be an append */ - bool useSeekResult /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */ - ) - { - int i; - Vdbe v; - int nIdx; - Index pIdx; - u8 pik_flags; - int regData; - int regRec; - - v = sqlite3GetVdbe( pParse ); - Debug.Assert( v != null ); - Debug.Assert( pTab.pSelect == null ); /* This table is not a VIEW */ - for ( nIdx = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, nIdx++ ) - { - } - for ( i = nIdx - 1; i >= 0; i-- ) - { - if ( aRegIdx[i] == 0 ) - continue; - sqlite3VdbeAddOp2( v, OP_IdxInsert, baseCur + i + 1, aRegIdx[i] ); - if ( useSeekResult ) - { - sqlite3VdbeChangeP5( v, OPFLAG_USESEEKRESULT ); + /* + ** This routine generates code to finish the INSERT or UPDATE operation + ** that was started by a prior call to sqlite3GenerateConstraintChecks. + ** A consecutive range of registers starting at regRowid contains the + ** rowid and the content to be inserted. + ** + ** The arguments to this routine should be the same as the first six + ** arguments to sqlite3GenerateConstraintChecks. + */ + static void sqlite3CompleteInsertion( + Parse pParse, /* The parser context */ + Table pTab, /* the table into which we are inserting */ + int baseCur, /* Index of a read/write cursor pointing at pTab */ + int regRowid, /* Range of content */ + int[] aRegIdx, /* Register used by each index. 0 for unused indices */ + bool isUpdate, /* True for UPDATE, False for INSERT */ + bool appendBias, /* True if this is likely to be an append */ + bool useSeekResult /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */ + ) { + int i; + Vdbe v; + int nIdx; + Index pIdx; + u8 pik_flags; + int regData; + int regRec; + + v = sqlite3GetVdbe(pParse); + Debug.Assert(v != null); + Debug.Assert(pTab.pSelect == null); /* This table is not a VIEW */ + for (nIdx = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, nIdx++) { + } + for (i = nIdx - 1; i >= 0; i--) { + if (aRegIdx[i] == 0) + continue; + sqlite3VdbeAddOp2(v, OP_IdxInsert, baseCur + i + 1, aRegIdx[i]); + if (useSeekResult) { + sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); + } + } + regData = regRowid + 1; + regRec = sqlite3GetTempReg(pParse); + sqlite3VdbeAddOp3(v, OP_MakeRecord, regData, pTab.nCol, regRec); + sqlite3TableAffinityStr(v, pTab); + sqlite3ExprCacheAffinityChange(pParse, regData, pTab.nCol); + if (pParse.nested != 0) { + pik_flags = 0; + } else { + pik_flags = OPFLAG_NCHANGE; + pik_flags |= (isUpdate ? OPFLAG_ISUPDATE : OPFLAG_LASTROWID); + } + if (appendBias) { + pik_flags |= OPFLAG_APPEND; + } + if (useSeekResult) { + pik_flags |= OPFLAG_USESEEKRESULT; + } + sqlite3VdbeAddOp3(v, OP_Insert, baseCur, regRec, regRowid); + if (pParse.nested == 0) { + sqlite3VdbeChangeP4(v, -1, pTab.zName, P4_TRANSIENT); + } + sqlite3VdbeChangeP5(v, pik_flags); } - } - regData = regRowid + 1; - regRec = sqlite3GetTempReg( pParse ); - sqlite3VdbeAddOp3( v, OP_MakeRecord, regData, pTab.nCol, regRec ); - sqlite3TableAffinityStr( v, pTab ); - sqlite3ExprCacheAffinityChange( pParse, regData, pTab.nCol ); - if ( pParse.nested != 0 ) - { - pik_flags = 0; - } - else - { - pik_flags = OPFLAG_NCHANGE; - pik_flags |= ( isUpdate ? OPFLAG_ISUPDATE : OPFLAG_LASTROWID ); - } - if ( appendBias ) - { - pik_flags |= OPFLAG_APPEND; - } - if ( useSeekResult ) - { - pik_flags |= OPFLAG_USESEEKRESULT; - } - sqlite3VdbeAddOp3( v, OP_Insert, baseCur, regRec, regRowid ); - if ( pParse.nested == 0 ) - { - sqlite3VdbeChangeP4( v, -1, pTab.zName, P4_TRANSIENT ); - } - sqlite3VdbeChangeP5( v, pik_flags ); - } - /* - ** Generate code that will open cursors for a table and for all - ** indices of that table. The "baseCur" parameter is the cursor number used - ** for the table. Indices are opened on subsequent cursors. - ** - ** Return the number of indices on the table. - */ - static int sqlite3OpenTableAndIndices( - Parse pParse, /* Parsing context */ - Table pTab, /* Table to be opened */ - int baseCur, /* VdbeCursor number assigned to the table */ - int op /* OP_OpenRead or OP_OpenWrite */ - ) - { - int i; - int iDb; - Index pIdx; - Vdbe v; - - if ( IsVirtual( pTab ) ) - return 0; - iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema ); - v = sqlite3GetVdbe( pParse ); - Debug.Assert( v != null ); - sqlite3OpenTable( pParse, baseCur, iDb, pTab, op ); - for ( i = 1, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, i++ ) - { - KeyInfo pKey = sqlite3IndexKeyinfo( pParse, pIdx ); - Debug.Assert( pIdx.pSchema == pTab.pSchema ); - sqlite3VdbeAddOp4( v, op, i + baseCur, pIdx.tnum, iDb, - pKey, P4_KEYINFO_HANDOFF ); + /* + ** Generate code that will open cursors for a table and for all + ** indices of that table. The "baseCur" parameter is the cursor number used + ** for the table. Indices are opened on subsequent cursors. + ** + ** Return the number of indices on the table. + */ + static int sqlite3OpenTableAndIndices( + Parse pParse, /* Parsing context */ + Table pTab, /* Table to be opened */ + int baseCur, /* VdbeCursor number assigned to the table */ + int op /* OP_OpenRead or OP_OpenWrite */ + ) { + int i; + int iDb; + Index pIdx; + Vdbe v; + + if (IsVirtual(pTab)) + return 0; + iDb = sqlite3SchemaToIndex(pParse.db, pTab.pSchema); + v = sqlite3GetVdbe(pParse); + Debug.Assert(v != null); + sqlite3OpenTable(pParse, baseCur, iDb, pTab, op); + for (i = 1, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, i++) { + KeyInfo pKey = sqlite3IndexKeyinfo(pParse, pIdx); + Debug.Assert(pIdx.pSchema == pTab.pSchema); + sqlite3VdbeAddOp4(v, op, i + baseCur, pIdx.tnum, iDb, + pKey, P4_KEYINFO_HANDOFF); #if SQLITE_DEBUG - VdbeComment( v, "%s", pIdx.zName ); + VdbeComment(v, "%s", pIdx.zName); #endif - } - if ( pParse.nTab < baseCur + i ) - { - pParse.nTab = baseCur + i; - } - return i - 1; - } + } + if (pParse.nTab < baseCur + i) { + pParse.nTab = baseCur + i; + } + return i - 1; + } -#if SQLITE_TEST +#if SQLITE_TEST /* ** The following global variable is incremented whenever the ** transfer optimization is used. This is used for testing @@ -1787,387 +1596,332 @@ int op /* OP_OpenRead or OP_OpenWrite */ #if !SQLITE_OMIT_XFER_OPT - /* -** Check to collation names to see if they are compatible. -*/ - static bool xferCompatibleCollation( string z1, string z2 ) - { - if ( z1 == null ) - { - return z2 == null; - } - if ( z2 == null ) - { - return false; - } - return z1.Equals( z2 ,StringComparison.OrdinalIgnoreCase ) ; - } - - - /* - ** Check to see if index pSrc is compatible as a source of data - ** for index pDest in an insert transfer optimization. The rules - ** for a compatible index: - ** - ** * The index is over the same set of columns - ** * The same DESC and ASC markings occurs on all columns - ** * The same onError processing (OE_Abort, OE_Ignore, etc) - ** * The same collating sequence on each column + /* + ** Check to collation names to see if they are compatible. */ - static bool xferCompatibleIndex( Index pDest, Index pSrc ) - { - int i; - Debug.Assert( pDest != null && pSrc != null ); - Debug.Assert( pDest.pTable != pSrc.pTable ); - if ( pDest.nColumn != pSrc.nColumn ) - { - return false; /* Different number of columns */ - } - if ( pDest.onError != pSrc.onError ) - { - return false; /* Different conflict resolution strategies */ - } - for ( i = 0; i < pSrc.nColumn; i++ ) - { - if ( pSrc.aiColumn[i] != pDest.aiColumn[i] ) - { - return false; /* Different columns indexed */ - } - if ( pSrc.aSortOrder[i] != pDest.aSortOrder[i] ) - { - return false; /* Different sort orders */ - } - if ( !xferCompatibleCollation( pSrc.azColl[i], pDest.azColl[i] ) ) - { - return false; /* Different collating sequences */ + static bool xferCompatibleCollation(string z1, string z2) { + if (z1 == null) { + return z2 == null; + } + if (z2 == null) { + return false; + } + return z1.Equals(z2, StringComparison.OrdinalIgnoreCase); } - } - /* If no test above fails then the indices must be compatible */ - return true; - } - /* - ** Attempt the transfer optimization on INSERTs of the form - ** - ** INSERT INTO tab1 SELECT * FROM tab2; - ** - ** This optimization is only attempted if - ** - ** (1) tab1 and tab2 have identical schemas including all the - ** same indices and constraints - ** - ** (2) tab1 and tab2 are different tables - ** - ** (3) There must be no triggers on tab1 - ** - ** (4) The result set of the SELECT statement is "*" - ** - ** (5) The SELECT statement has no WHERE, HAVING, ORDER BY, GROUP BY, - ** or LIMIT clause. - ** - ** (6) The SELECT statement is a simple (not a compound) select that - ** contains only tab2 in its FROM clause - ** - ** This method for implementing the INSERT transfers raw records from - ** tab2 over to tab1. The columns are not decoded. Raw records from - ** the indices of tab2 are transfered to tab1 as well. In so doing, - ** the resulting tab1 has much less fragmentation. - ** - ** This routine returns TRUE if the optimization is attempted. If any - ** of the conditions above fail so that the optimization should not - ** be attempted, then this routine returns FALSE. - */ - static int xferOptimization( - Parse pParse, /* Parser context */ - Table pDest, /* The table we are inserting into */ - Select pSelect, /* A SELECT statement to use as the data source */ - int onError, /* How to handle constraint errors */ - int iDbDest /* The database of pDest */ - ) - { - ExprList pEList; /* The result set of the SELECT */ - Table pSrc; /* The table in the FROM clause of SELECT */ - Index pSrcIdx, pDestIdx; /* Source and destination indices */ - SrcList_item pItem; /* An element of pSelect.pSrc */ - int i; /* Loop counter */ - int iDbSrc; /* The database of pSrc */ - int iSrc, iDest; /* Cursors from source and destination */ - int addr1, addr2; /* Loop addresses */ - int emptyDestTest; /* Address of test for empty pDest */ - int emptySrcTest; /* Address of test for empty pSrc */ - Vdbe v; /* The VDBE we are building */ - KeyInfo pKey; /* Key information for an index */ - int regAutoinc; /* Memory register used by AUTOINC */ - bool destHasUniqueIdx = false; /* True if pDest has a UNIQUE index */ - int regData, regRowid; /* Registers holding data and rowid */ - - if ( pSelect == null ) - { - return 0; /* Must be of the form INSERT INTO ... SELECT ... */ - } + /* + ** Check to see if index pSrc is compatible as a source of data + ** for index pDest in an insert transfer optimization. The rules + ** for a compatible index: + ** + ** * The index is over the same set of columns + ** * The same DESC and ASC markings occurs on all columns + ** * The same onError processing (OE_Abort, OE_Ignore, etc) + ** * The same collating sequence on each column + */ + static bool xferCompatibleIndex(Index pDest, Index pSrc) { + int i; + Debug.Assert(pDest != null && pSrc != null); + Debug.Assert(pDest.pTable != pSrc.pTable); + if (pDest.nColumn != pSrc.nColumn) { + return false; /* Different number of columns */ + } + if (pDest.onError != pSrc.onError) { + return false; /* Different conflict resolution strategies */ + } + for (i = 0; i < pSrc.nColumn; i++) { + if (pSrc.aiColumn[i] != pDest.aiColumn[i]) { + return false; /* Different columns indexed */ + } + if (pSrc.aSortOrder[i] != pDest.aSortOrder[i]) { + return false; /* Different sort orders */ + } + if (!xferCompatibleCollation(pSrc.azColl[i], pDest.azColl[i])) { + return false; /* Different collating sequences */ + } + } + + /* If no test above fails then the indices must be compatible */ + return true; + } + + /* + ** Attempt the transfer optimization on INSERTs of the form + ** + ** INSERT INTO tab1 SELECT * FROM tab2; + ** + ** This optimization is only attempted if + ** + ** (1) tab1 and tab2 have identical schemas including all the + ** same indices and constraints + ** + ** (2) tab1 and tab2 are different tables + ** + ** (3) There must be no triggers on tab1 + ** + ** (4) The result set of the SELECT statement is "*" + ** + ** (5) The SELECT statement has no WHERE, HAVING, ORDER BY, GROUP BY, + ** or LIMIT clause. + ** + ** (6) The SELECT statement is a simple (not a compound) select that + ** contains only tab2 in its FROM clause + ** + ** This method for implementing the INSERT transfers raw records from + ** tab2 over to tab1. The columns are not decoded. Raw records from + ** the indices of tab2 are transfered to tab1 as well. In so doing, + ** the resulting tab1 has much less fragmentation. + ** + ** This routine returns TRUE if the optimization is attempted. If any + ** of the conditions above fail so that the optimization should not + ** be attempted, then this routine returns FALSE. + */ + static int xferOptimization( + Parse pParse, /* Parser context */ + Table pDest, /* The table we are inserting into */ + Select pSelect, /* A SELECT statement to use as the data source */ + int onError, /* How to handle constraint errors */ + int iDbDest /* The database of pDest */ + ) { + ExprList pEList; /* The result set of the SELECT */ + Table pSrc; /* The table in the FROM clause of SELECT */ + Index pSrcIdx, pDestIdx; /* Source and destination indices */ + SrcList_item pItem; /* An element of pSelect.pSrc */ + int i; /* Loop counter */ + int iDbSrc; /* The database of pSrc */ + int iSrc, iDest; /* Cursors from source and destination */ + int addr1, addr2; /* Loop addresses */ + int emptyDestTest; /* Address of test for empty pDest */ + int emptySrcTest; /* Address of test for empty pSrc */ + Vdbe v; /* The VDBE we are building */ + KeyInfo pKey; /* Key information for an index */ + int regAutoinc; /* Memory register used by AUTOINC */ + bool destHasUniqueIdx = false; /* True if pDest has a UNIQUE index */ + int regData, regRowid; /* Registers holding data and rowid */ + + if (pSelect == null) { + return 0; /* Must be of the form INSERT INTO ... SELECT ... */ + } #if !SQLITE_OMIT_TRIGGER - if ( sqlite3TriggerList( pParse, pDest ) != null ) - { - return 0; /* tab1 must not have triggers */ - } + if (sqlite3TriggerList(pParse, pDest) != null) { + return 0; /* tab1 must not have triggers */ + } #endif - if ( ( pDest.tabFlags & TF_Virtual ) != 0 ) - { - return 0; /* tab1 must not be a virtual table */ - } - if ( onError == OE_Default ) - { - onError = OE_Abort; - } - if ( onError != OE_Abort && onError != OE_Rollback ) - { - return 0; /* Cannot do OR REPLACE or OR IGNORE or OR FAIL */ - } - Debug.Assert( pSelect.pSrc != null ); /* allocated even if there is no FROM clause */ - if ( pSelect.pSrc.nSrc != 1 ) - { - return 0; /* FROM clause must have exactly one term */ - } - if ( pSelect.pSrc.a[0].pSelect != null ) - { - return 0; /* FROM clause cannot contain a subquery */ - } - if ( pSelect.pWhere != null ) - { - return 0; /* SELECT may not have a WHERE clause */ - } - if ( pSelect.pOrderBy != null ) - { - return 0; /* SELECT may not have an ORDER BY clause */ - } - /* Do not need to test for a HAVING clause. If HAVING is present but - ** there is no ORDER BY, we will get an error. */ - if ( pSelect.pGroupBy != null ) - { - return 0; /* SELECT may not have a GROUP BY clause */ - } - if ( pSelect.pLimit != null ) - { - return 0; /* SELECT may not have a LIMIT clause */ - } - Debug.Assert( pSelect.pOffset == null ); /* Must be so if pLimit==0 */ - if ( pSelect.pPrior != null ) - { - return 0; /* SELECT may not be a compound query */ - } - if ( ( pSelect.selFlags & SF_Distinct ) != 0 ) - { - return 0; /* SELECT may not be DISTINCT */ - } - pEList = pSelect.pEList; - Debug.Assert( pEList != null ); - if ( pEList.nExpr != 1 ) - { - return 0; /* The result set must have exactly one column */ - } - Debug.Assert( pEList.a[0].pExpr != null ); - if ( pEList.a[0].pExpr.op != TK_ALL ) - { - return 0; /* The result set must be the special operator "*" */ - } + if ((pDest.tabFlags & TF_Virtual) != 0) { + return 0; /* tab1 must not be a virtual table */ + } + if (onError == OE_Default) { + onError = OE_Abort; + } + if (onError != OE_Abort && onError != OE_Rollback) { + return 0; /* Cannot do OR REPLACE or OR IGNORE or OR FAIL */ + } + Debug.Assert(pSelect.pSrc != null); /* allocated even if there is no FROM clause */ + if (pSelect.pSrc.nSrc != 1) { + return 0; /* FROM clause must have exactly one term */ + } + if (pSelect.pSrc.a[0].pSelect != null) { + return 0; /* FROM clause cannot contain a subquery */ + } + if (pSelect.pWhere != null) { + return 0; /* SELECT may not have a WHERE clause */ + } + if (pSelect.pOrderBy != null) { + return 0; /* SELECT may not have an ORDER BY clause */ + } + /* Do not need to test for a HAVING clause. If HAVING is present but + ** there is no ORDER BY, we will get an error. */ + if (pSelect.pGroupBy != null) { + return 0; /* SELECT may not have a GROUP BY clause */ + } + if (pSelect.pLimit != null) { + return 0; /* SELECT may not have a LIMIT clause */ + } + Debug.Assert(pSelect.pOffset == null); /* Must be so if pLimit==0 */ + if (pSelect.pPrior != null) { + return 0; /* SELECT may not be a compound query */ + } + if ((pSelect.selFlags & SF_Distinct) != 0) { + return 0; /* SELECT may not be DISTINCT */ + } + pEList = pSelect.pEList; + Debug.Assert(pEList != null); + if (pEList.nExpr != 1) { + return 0; /* The result set must have exactly one column */ + } + Debug.Assert(pEList.a[0].pExpr != null); + if (pEList.a[0].pExpr.op != TK_ALL) { + return 0; /* The result set must be the special operator "*" */ + } - /* At this point we have established that the statement is of the - ** correct syntactic form to participate in this optimization. Now - ** we have to check the semantics. - */ - pItem = pSelect.pSrc.a[0]; - pSrc = sqlite3LocateTable( pParse, 0, pItem.zName, pItem.zDatabase ); - if ( pSrc == null ) - { - return 0; /* FROM clause does not contain a real table */ - } - if ( pSrc == pDest ) - { - return 0; /* tab1 and tab2 may not be the same table */ - } - if ( ( pSrc.tabFlags & TF_Virtual ) != 0 ) - { - return 0; /* tab2 must not be a virtual table */ - } - if ( pSrc.pSelect != null ) - { - return 0; /* tab2 may not be a view */ - } - if ( pDest.nCol != pSrc.nCol ) - { - return 0; /* Number of columns must be the same in tab1 and tab2 */ - } - if ( pDest.iPKey != pSrc.iPKey ) - { - return 0; /* Both tables must have the same INTEGER PRIMARY KEY */ - } - for ( i = 0; i < pDest.nCol; i++ ) - { - if ( pDest.aCol[i].affinity != pSrc.aCol[i].affinity ) - { - return 0; /* Affinity must be the same on all columns */ - } - if ( !xferCompatibleCollation( pDest.aCol[i].zColl, pSrc.aCol[i].zColl ) ) - { - return 0; /* Collating sequence must be the same on all columns */ - } - if ( pDest.aCol[i].notNull != 0 && pSrc.aCol[i].notNull == 0 ) - { - return 0; /* tab2 must be NOT NULL if tab1 is */ - } - } - for ( pDestIdx = pDest.pIndex; pDestIdx != null; pDestIdx = pDestIdx.pNext ) - { - if ( pDestIdx.onError != OE_None ) - { - destHasUniqueIdx = true; - } - for ( pSrcIdx = pSrc.pIndex; pSrcIdx != null; pSrcIdx = pSrcIdx.pNext ) - { - if ( xferCompatibleIndex( pDestIdx, pSrcIdx ) ) - break; - } - if ( pSrcIdx == null ) - { - return 0; /* pDestIdx has no corresponding index in pSrc */ - } - } + /* At this point we have established that the statement is of the + ** correct syntactic form to participate in this optimization. Now + ** we have to check the semantics. + */ + pItem = pSelect.pSrc.a[0]; + pSrc = sqlite3LocateTable(pParse, 0, pItem.zName, pItem.zDatabase); + if (pSrc == null) { + return 0; /* FROM clause does not contain a real table */ + } + if (pSrc == pDest) { + return 0; /* tab1 and tab2 may not be the same table */ + } + if ((pSrc.tabFlags & TF_Virtual) != 0) { + return 0; /* tab2 must not be a virtual table */ + } + if (pSrc.pSelect != null) { + return 0; /* tab2 may not be a view */ + } + if (pDest.nCol != pSrc.nCol) { + return 0; /* Number of columns must be the same in tab1 and tab2 */ + } + if (pDest.iPKey != pSrc.iPKey) { + return 0; /* Both tables must have the same INTEGER PRIMARY KEY */ + } + for (i = 0; i < pDest.nCol; i++) { + if (pDest.aCol[i].affinity != pSrc.aCol[i].affinity) { + return 0; /* Affinity must be the same on all columns */ + } + if (!xferCompatibleCollation(pDest.aCol[i].zColl, pSrc.aCol[i].zColl)) { + return 0; /* Collating sequence must be the same on all columns */ + } + if (pDest.aCol[i].notNull != 0 && pSrc.aCol[i].notNull == 0) { + return 0; /* tab2 must be NOT NULL if tab1 is */ + } + } + for (pDestIdx = pDest.pIndex; pDestIdx != null; pDestIdx = pDestIdx.pNext) { + if (pDestIdx.onError != OE_None) { + destHasUniqueIdx = true; + } + for (pSrcIdx = pSrc.pIndex; pSrcIdx != null; pSrcIdx = pSrcIdx.pNext) { + if (xferCompatibleIndex(pDestIdx, pSrcIdx)) + break; + } + if (pSrcIdx == null) { + return 0; /* pDestIdx has no corresponding index in pSrc */ + } + } #if !SQLITE_OMIT_CHECK - if ( pDest.pCheck != null && 0 != sqlite3ExprCompare( pSrc.pCheck, pDest.pCheck ) ) - { - return 0; /* Tables have different CHECK constraints. Ticket #2252 */ - } + if (pDest.pCheck != null && 0 != sqlite3ExprCompare(pSrc.pCheck, pDest.pCheck)) { + return 0; /* Tables have different CHECK constraints. Ticket #2252 */ + } #endif #if !SQLITE_OMIT_FOREIGN_KEY - /* Disallow the transfer optimization if the destination table constains - ** any foreign key constraints. This is more restrictive than necessary. - ** But the main beneficiary of the transfer optimization is the VACUUM - ** command, and the VACUUM command disables foreign key constraints. So - ** the extra complication to make this rule less restrictive is probably - ** not worth the effort. Ticket [6284df89debdfa61db8073e062908af0c9b6118e] - */ - if ( ( pParse.db.flags & SQLITE_ForeignKeys ) != 0 && pDest.pFKey != null ) - { - return 0; - } + /* Disallow the transfer optimization if the destination table constains + ** any foreign key constraints. This is more restrictive than necessary. + ** But the main beneficiary of the transfer optimization is the VACUUM + ** command, and the VACUUM command disables foreign key constraints. So + ** the extra complication to make this rule less restrictive is probably + ** not worth the effort. Ticket [6284df89debdfa61db8073e062908af0c9b6118e] + */ + if ((pParse.db.flags & SQLITE_ForeignKeys) != 0 && pDest.pFKey != null) { + return 0; + } #endif - /* If we get this far, it means either: - ** - ** * We can always do the transfer if the table contains an - ** an integer primary key - ** - ** * We can conditionally do the transfer if the destination - ** table is empty. - */ -#if SQLITE_TEST + /* If we get this far, it means either: + ** + ** * We can always do the transfer if the table contains an + ** an integer primary key + ** + ** * We can conditionally do the transfer if the destination + ** table is empty. + */ +#if SQLITE_TEST #if !TCLSH sqlite3_xferopt_count++; #else sqlite3_xferopt_count.iValue++; #endif #endif - iDbSrc = sqlite3SchemaToIndex( pParse.db, pSrc.pSchema ); - v = sqlite3GetVdbe( pParse ); - sqlite3CodeVerifySchema( pParse, iDbSrc ); - iSrc = pParse.nTab++; - iDest = pParse.nTab++; - regAutoinc = autoIncBegin( pParse, iDbDest, pDest ); - sqlite3OpenTable( pParse, iDest, iDbDest, pDest, OP_OpenWrite ); - if ( ( pDest.iPKey < 0 && pDest.pIndex != null ) || destHasUniqueIdx ) - { - /* If tables do not have an INTEGER PRIMARY KEY and there - ** are indices to be copied and the destination is not empty, - ** we have to disallow the transfer optimization because the - ** the rowids might change which will mess up indexing. - ** - ** Or if the destination has a UNIQUE index and is not empty, - ** we also disallow the transfer optimization because we cannot - ** insure that all entries in the union of DEST and SRC will be - ** unique. - */ - addr1 = sqlite3VdbeAddOp2( v, OP_Rewind, iDest, 0 ); - emptyDestTest = sqlite3VdbeAddOp2( v, OP_Goto, 0, 0 ); - sqlite3VdbeJumpHere( v, addr1 ); - } - else - { - emptyDestTest = 0; - } - sqlite3OpenTable( pParse, iSrc, iDbSrc, pSrc, OP_OpenRead ); - emptySrcTest = sqlite3VdbeAddOp2( v, OP_Rewind, iSrc, 0 ); - regData = sqlite3GetTempReg( pParse ); - regRowid = sqlite3GetTempReg( pParse ); - if ( pDest.iPKey >= 0 ) - { - addr1 = sqlite3VdbeAddOp2( v, OP_Rowid, iSrc, regRowid ); - addr2 = sqlite3VdbeAddOp3( v, OP_NotExists, iDest, 0, regRowid ); - sqlite3HaltConstraint( - pParse, onError, "PRIMARY KEY must be unique", P4_STATIC ); - sqlite3VdbeJumpHere( v, addr2 ); - autoIncStep( pParse, regAutoinc, regRowid ); - } - else if ( pDest.pIndex == null ) - { - addr1 = sqlite3VdbeAddOp2( v, OP_NewRowid, iDest, regRowid ); - } - else - { - addr1 = sqlite3VdbeAddOp2( v, OP_Rowid, iSrc, regRowid ); - Debug.Assert( ( pDest.tabFlags & TF_Autoincrement ) == 0 ); - } - sqlite3VdbeAddOp2( v, OP_RowData, iSrc, regData ); - sqlite3VdbeAddOp3( v, OP_Insert, iDest, regData, regRowid ); - sqlite3VdbeChangeP5( v, OPFLAG_NCHANGE | OPFLAG_LASTROWID | OPFLAG_APPEND ); - sqlite3VdbeChangeP4( v, -1, pDest.zName, 0 ); - sqlite3VdbeAddOp2( v, OP_Next, iSrc, addr1 ); - for ( pDestIdx = pDest.pIndex; pDestIdx != null; pDestIdx = pDestIdx.pNext ) - { - for ( pSrcIdx = pSrc.pIndex; pSrcIdx != null; pSrcIdx = pSrcIdx.pNext ) - { - if ( xferCompatibleIndex( pDestIdx, pSrcIdx ) ) - break; - } - Debug.Assert( pSrcIdx != null ); - sqlite3VdbeAddOp2( v, OP_Close, iSrc, 0 ); - sqlite3VdbeAddOp2( v, OP_Close, iDest, 0 ); - pKey = sqlite3IndexKeyinfo( pParse, pSrcIdx ); - sqlite3VdbeAddOp4( v, OP_OpenRead, iSrc, pSrcIdx.tnum, iDbSrc, - pKey, P4_KEYINFO_HANDOFF ); + iDbSrc = sqlite3SchemaToIndex(pParse.db, pSrc.pSchema); + v = sqlite3GetVdbe(pParse); + sqlite3CodeVerifySchema(pParse, iDbSrc); + iSrc = pParse.nTab++; + iDest = pParse.nTab++; + regAutoinc = autoIncBegin(pParse, iDbDest, pDest); + sqlite3OpenTable(pParse, iDest, iDbDest, pDest, OP_OpenWrite); + if ((pDest.iPKey < 0 && pDest.pIndex != null) || destHasUniqueIdx) { + /* If tables do not have an INTEGER PRIMARY KEY and there + ** are indices to be copied and the destination is not empty, + ** we have to disallow the transfer optimization because the + ** the rowids might change which will mess up indexing. + ** + ** Or if the destination has a UNIQUE index and is not empty, + ** we also disallow the transfer optimization because we cannot + ** insure that all entries in the union of DEST and SRC will be + ** unique. + */ + addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iDest, 0); + emptyDestTest = sqlite3VdbeAddOp2(v, OP_Goto, 0, 0); + sqlite3VdbeJumpHere(v, addr1); + } else { + emptyDestTest = 0; + } + sqlite3OpenTable(pParse, iSrc, iDbSrc, pSrc, OP_OpenRead); + emptySrcTest = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0); + regData = sqlite3GetTempReg(pParse); + regRowid = sqlite3GetTempReg(pParse); + if (pDest.iPKey >= 0) { + addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid); + addr2 = sqlite3VdbeAddOp3(v, OP_NotExists, iDest, 0, regRowid); + sqlite3HaltConstraint( + pParse, onError, "PRIMARY KEY must be unique", P4_STATIC); + sqlite3VdbeJumpHere(v, addr2); + autoIncStep(pParse, regAutoinc, regRowid); + } else if (pDest.pIndex == null) { + addr1 = sqlite3VdbeAddOp2(v, OP_NewRowid, iDest, regRowid); + } else { + addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid); + Debug.Assert((pDest.tabFlags & TF_Autoincrement) == 0); + } + sqlite3VdbeAddOp2(v, OP_RowData, iSrc, regData); + sqlite3VdbeAddOp3(v, OP_Insert, iDest, regData, regRowid); + sqlite3VdbeChangeP5(v, OPFLAG_NCHANGE | OPFLAG_LASTROWID | OPFLAG_APPEND); + sqlite3VdbeChangeP4(v, -1, pDest.zName, 0); + sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1); + for (pDestIdx = pDest.pIndex; pDestIdx != null; pDestIdx = pDestIdx.pNext) { + for (pSrcIdx = pSrc.pIndex; pSrcIdx != null; pSrcIdx = pSrcIdx.pNext) { + if (xferCompatibleIndex(pDestIdx, pSrcIdx)) + break; + } + Debug.Assert(pSrcIdx != null); + sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0); + sqlite3VdbeAddOp2(v, OP_Close, iDest, 0); + pKey = sqlite3IndexKeyinfo(pParse, pSrcIdx); + sqlite3VdbeAddOp4(v, OP_OpenRead, iSrc, pSrcIdx.tnum, iDbSrc, + pKey, P4_KEYINFO_HANDOFF); #if SQLITE_DEBUG - VdbeComment( v, "%s", pSrcIdx.zName ); + VdbeComment(v, "%s", pSrcIdx.zName); #endif - pKey = sqlite3IndexKeyinfo( pParse, pDestIdx ); - sqlite3VdbeAddOp4( v, OP_OpenWrite, iDest, pDestIdx.tnum, iDbDest, - pKey, P4_KEYINFO_HANDOFF ); + pKey = sqlite3IndexKeyinfo(pParse, pDestIdx); + sqlite3VdbeAddOp4(v, OP_OpenWrite, iDest, pDestIdx.tnum, iDbDest, + pKey, P4_KEYINFO_HANDOFF); #if SQLITE_DEBUG - VdbeComment( v, "%s", pDestIdx.zName ); + VdbeComment(v, "%s", pDestIdx.zName); #endif - 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 ); - sqlite3VdbeJumpHere( v, addr1 ); - } - sqlite3VdbeJumpHere( v, emptySrcTest ); - sqlite3ReleaseTempReg( pParse, regRowid ); - sqlite3ReleaseTempReg( pParse, regData ); - sqlite3VdbeAddOp2( v, OP_Close, iSrc, 0 ); - sqlite3VdbeAddOp2( v, OP_Close, iDest, 0 ); - if ( emptyDestTest != 0 ) - { - sqlite3VdbeAddOp2( v, OP_Halt, SQLITE_OK, 0 ); - sqlite3VdbeJumpHere( v, emptyDestTest ); - sqlite3VdbeAddOp2( v, OP_Close, iDest, 0 ); - return 0; - } - else - { - return 1; - } - } + 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); + sqlite3VdbeJumpHere(v, addr1); + } + sqlite3VdbeJumpHere(v, emptySrcTest); + sqlite3ReleaseTempReg(pParse, regRowid); + sqlite3ReleaseTempReg(pParse, regData); + sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0); + sqlite3VdbeAddOp2(v, OP_Close, iDest, 0); + if (emptyDestTest != 0) { + sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_OK, 0); + sqlite3VdbeJumpHere(v, emptyDestTest); + sqlite3VdbeAddOp2(v, OP_Close, iDest, 0); + return 0; + } else { + return 1; + } + } #endif // * SQLITE_OMIT_XFER_OPT */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/journal_c.cs b/Src/IronPython.SQLite/c#sqlite/journal_c.cs index e6aaf7551..e95257878 100644 --- a/Src/IronPython.SQLite/c#sqlite/journal_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/journal_c.cs @@ -1,40 +1,38 @@ -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 2007 August 22 - ** - ** 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 implements a special kind of sqlite3_file object used - ** by SQLite to create journal files if the atomic-write optimization - ** is enabled. - ** - ** The distinctive characteristic of this sqlite3_file is that the - ** actual on disk file is created lazily. When the file is created, - ** the caller specifies a buffer size for an in-memory buffer to - ** be used to service read() and write() requests. The actual file - ** on disk is not created or populated until either: - ** - ** 1) The in-memory representation grows too large for the allocated - ** buffer, or - ** 2) The sqlite3JournalCreate() function is called. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2007 August 22 + ** + ** 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 implements a special kind of sqlite3_file object used + ** by SQLite to create journal files if the atomic-write optimization + ** is enabled. + ** + ** The distinctive characteristic of this sqlite3_file is that the + ** actual on disk file is created lazily. When the file is created, + ** the caller specifies a buffer size for an in-memory buffer to + ** be used to service read() and write() requests. The actual file + ** on disk is not created or populated until either: + ** + ** 1) The in-memory representation grows too large for the allocated + ** buffer, or + ** 2) The sqlite3JournalCreate() function is called. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ #if SQLITE_ENABLE_ATOMIC_WRITE //#include "sqliteInt.h" @@ -246,5 +244,5 @@ int sqlite3JournalSize(sqlite3_vfs pVfs){ return (pVfs->szOsFile+sizeof(JournalFile)); } #endif - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/keywordhash_h.cs b/Src/IronPython.SQLite/c#sqlite/keywordhash_h.cs index 1e3389a5c..4d26744ef 100644 --- a/Src/IronPython.SQLite/c#sqlite/keywordhash_h.cs +++ b/Src/IronPython.SQLite/c#sqlite/keywordhash_h.cs @@ -1,43 +1,40 @@ -using System.Diagnostics; using System; -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /***** This file contains automatically generated code ****** - ** - ** The code in this file has been automatically generated by - ** - ** sqlite/tool/mkkeywordhash.c - ** - ** The code in this file implements a function that determines whether - ** or not a given identifier is really an SQL keyword. The same thing - ** might be implemented more directly using a hand-written hash table. - ** But by using this automatically generated code, the size of the code - ** is substantially reduced. This is important for embedded applications - ** on platforms with limited memory. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - /* Hash score: 175 */ - /* zText[] encodes 811 bytes of keywords in 541 bytes */ - /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */ - /* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */ - /* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */ - /* UNIQUERYATTACHAVINGROUPDATEBEGINNERELEASEBETWEENOTNULLIKE */ - /* CASCADELETECASECOLLATECREATECURRENT_DATEDETACHIMMEDIATEJOIN */ - /* SERTMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMITWHENWHERENAME */ - /* AFTEREPLACEANDEFAULTAUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSS */ - /* CURRENT_TIMESTAMPRIMARYDEFERREDISTINCTDROPFAILFROMFULLGLOBYIF */ - /* ISNULLORDERESTRICTOUTERIGHTROLLBACKROWUNIONUSINGVACUUMVIEW */ - /* INITIALLY */ -static string zText = new string( new char[540] { +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /***** This file contains automatically generated code ****** + ** + ** The code in this file has been automatically generated by + ** + ** sqlite/tool/mkkeywordhash.c + ** + ** The code in this file implements a function that determines whether + ** or not a given identifier is really an SQL keyword. The same thing + ** might be implemented more directly using a hand-written hash table. + ** But by using this automatically generated code, the size of the code + ** is substantially reduced. This is important for embedded applications + ** on platforms with limited memory. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + /* Hash score: 175 */ + /* zText[] encodes 811 bytes of keywords in 541 bytes */ + /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */ + /* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */ + /* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */ + /* UNIQUERYATTACHAVINGROUPDATEBEGINNERELEASEBETWEENOTNULLIKE */ + /* CASCADELETECASECOLLATECREATECURRENT_DATEDETACHIMMEDIATEJOIN */ + /* SERTMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMITWHENWHERENAME */ + /* AFTEREPLACEANDEFAULTAUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSS */ + /* CURRENT_TIMESTAMPRIMARYDEFERREDISTINCTDROPFAILFROMFULLGLOBYIF */ + /* ISNULLORDERESTRICTOUTERIGHTROLLBACKROWUNIONUSINGVACUUMVIEW */ + /* INITIALLY */ + static string zText = new string(new char[540] { 'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H', 'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G', 'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A', @@ -79,9 +76,9 @@ public partial class Sqlite3 'T','R','I','C','T','O','U','T','E','R','I','G','H','T','R','O','L','L', 'B','A','C','K','R','O','W','U','N','I','O','N','U','S','I','N','G','V', 'A','C','U','U','M','V','I','E','W','I','N','I','T','I','A','L','L','Y', -} ); +}); -static byte[] aHash = { //aHash[127] + static byte[] aHash = { //aHash[127] 72, 101, 114, 70, 0, 45, 0, 0, 78, 0, 73, 0, 0, 42, 12, 74, 15, 0, 113, 81, 50, 108, 0, 19, 0, 0, 118, 0, 116, 111, 0, 22, 89, 0, 9, 0, 0, 66, 67, @@ -93,7 +90,7 @@ public partial class Sqlite3 58, 46, 80, 0, 0, 90, 40, 0, 112, 0, 36, 0, 0, 29, 0, 82, 59, 60, 0, 20, 57, 0, 52, }; -static byte[] aNext = { //aNext[121] + static byte[] aNext = { //aNext[121] 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -105,7 +102,7 @@ public partial class Sqlite3 103, 0, 83, 0, 71, 0, 0, 110, 27, 37, 69, 79, 0, 35, 64, 0, 0, }; -static byte[] aLen = { //aLen[121] + static byte[] aLen = { //aLen[121] 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6, 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6, 11, 6, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10, @@ -117,7 +114,7 @@ public partial class Sqlite3 4, 4, 2, 2, 6, 5, 8, 5, 5, 8, 3, 5, 5, 6, 4, 9, 3, }; - static int[] aOffset = { //aOffset[121] + static int[] aOffset = { //aOffset[121] 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33, 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81, 86, 91, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152, @@ -129,175 +126,171 @@ public partial class Sqlite3 462, 466, 469, 471, 473, 479, 483, 491, 495, 500, 508, 511, 516, 521, 527, 531, 536, }; -static byte[] aCode = { //aCode[121 - TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE, - TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN, - TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD, - TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE, - TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE, - TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW, - TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT, - TK_INTERSECT, TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO, - TK_OFFSET, TK_OF, TK_SET, TK_TEMP, TK_TEMP, - TK_OR, TK_UNIQUE, TK_QUERY, TK_ATTACH, TK_HAVING, - TK_GROUP, TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RELEASE, - TK_BETWEEN, TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, - TK_LIKE_KW, TK_CASCADE, TK_ASC, TK_DELETE, TK_CASE, - TK_COLLATE, TK_CREATE, TK_CTIME_KW, TK_DETACH, TK_IMMEDIATE, - TK_JOIN, TK_INSERT, TK_MATCH, TK_PLAN, TK_ANALYZE, - TK_PRAGMA, TK_ABORT, TK_VALUES, TK_VIRTUAL, TK_LIMIT, - TK_WHEN, TK_WHERE, TK_RENAME, TK_AFTER, TK_REPLACE, - TK_AND, TK_DEFAULT, TK_AUTOINCR, TK_TO, TK_IN, - TK_CAST, TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, - TK_CTIME_KW, TK_CTIME_KW, TK_PRIMARY, TK_DEFERRED, TK_DISTINCT, - TK_IS, TK_DROP, TK_FAIL, TK_FROM, TK_JOIN_KW, - TK_LIKE_KW, TK_BY, TK_IF, TK_ISNULL, TK_ORDER, - TK_RESTRICT, TK_JOIN_KW, TK_JOIN_KW, TK_ROLLBACK, TK_ROW, - TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_INITIALLY, - TK_ALL, + static byte[] aCode = { //aCode[121 + TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE, + TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN, + TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD, + TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE, + TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE, + TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW, + TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT, + TK_INTERSECT, TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO, + TK_OFFSET, TK_OF, TK_SET, TK_TEMP, TK_TEMP, + TK_OR, TK_UNIQUE, TK_QUERY, TK_ATTACH, TK_HAVING, + TK_GROUP, TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RELEASE, + TK_BETWEEN, TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, + TK_LIKE_KW, TK_CASCADE, TK_ASC, TK_DELETE, TK_CASE, + TK_COLLATE, TK_CREATE, TK_CTIME_KW, TK_DETACH, TK_IMMEDIATE, + TK_JOIN, TK_INSERT, TK_MATCH, TK_PLAN, TK_ANALYZE, + TK_PRAGMA, TK_ABORT, TK_VALUES, TK_VIRTUAL, TK_LIMIT, + TK_WHEN, TK_WHERE, TK_RENAME, TK_AFTER, TK_REPLACE, + TK_AND, TK_DEFAULT, TK_AUTOINCR, TK_TO, TK_IN, + TK_CAST, TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, + TK_CTIME_KW, TK_CTIME_KW, TK_PRIMARY, TK_DEFERRED, TK_DISTINCT, + TK_IS, TK_DROP, TK_FAIL, TK_FROM, TK_JOIN_KW, + TK_LIKE_KW, TK_BY, TK_IF, TK_ISNULL, TK_ORDER, + TK_RESTRICT, TK_JOIN_KW, TK_JOIN_KW, TK_ROLLBACK, TK_ROW, + TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_INITIALLY, + TK_ALL, }; -static int keywordCode( string z, int iOffset, int n ) -{ - int h, i; - if ( n < 2 ) - return TK_ID; - h = ( ( sqlite3UpperToLower[z[iOffset + 0]] ) * 4 ^//(charMap(z[iOffset+0]) * 4) ^ - ( sqlite3UpperToLower[z[iOffset + n - 1]] * 3 ) ^ //(charMap(z[iOffset+n - 1]) * 3) ^ - n ) % 127; - for ( i = ( aHash[h] ) - 1; i >= 0; i = ( aNext[i] ) - 1 ) - { - if ( aLen[i] == n && String.Compare( zText, aOffset[i], z, iOffset, n, StringComparison.OrdinalIgnoreCase ) == 0 ) - { - testcase( i == 0 ); /* REINDEX */ - testcase( i == 1 ); /* INDEXED */ - testcase( i == 2 ); /* INDEX */ - testcase( i == 3 ); /* DESC */ - testcase( i == 4 ); /* ESCAPE */ - testcase( i == 5 ); /* EACH */ - testcase( i == 6 ); /* CHECK */ - testcase( i == 7 ); /* KEY */ - testcase( i == 8 ); /* BEFORE */ - testcase( i == 9 ); /* FOREIGN */ - testcase( i == 10 ); /* FOR */ - testcase( i == 11 ); /* IGNORE */ - testcase( i == 12 ); /* REGEXP */ - testcase( i == 13 ); /* EXPLAIN */ - testcase( i == 14 ); /* INSTEAD */ - testcase( i == 15 ); /* ADD */ - testcase( i == 16 ); /* DATABASE */ - testcase( i == 17 ); /* AS */ - testcase( i == 18 ); /* SELECT */ - testcase( i == 19 ); /* TABLE */ - testcase( i == 20 ); /* LEFT */ - testcase( i == 21 ); /* THEN */ - testcase( i == 22 ); /* END */ - testcase( i == 23 ); /* DEFERRABLE */ - testcase( i == 24 ); /* ELSE */ - testcase( i == 25 ); /* EXCEPT */ - testcase( i == 26 ); /* TRANSACTION */ - testcase( i == 27 ); /* ACTION */ - testcase( i == 28 ); /* ON */ - testcase( i == 29 ); /* NATURAL */ - testcase( i == 30 ); /* ALTER */ - testcase( i == 31 ); /* RAISE */ - testcase( i == 32 ); /* EXCLUSIVE */ - testcase( i == 33 ); /* EXISTS */ - testcase( i == 34 ); /* SAVEPOINT */ - testcase( i == 35 ); /* INTERSECT */ - testcase( i == 36 ); /* TRIGGER */ - testcase( i == 37 ); /* REFERENCES */ - testcase( i == 38 ); /* CONSTRAINT */ - testcase( i == 39 ); /* INTO */ - testcase( i == 40 ); /* OFFSET */ - testcase( i == 41 ); /* OF */ - testcase( i == 42 ); /* SET */ - testcase( i == 43 ); /* TEMPORARY */ - testcase( i == 44 ); /* TEMP */ - testcase( i == 45 ); /* OR */ - testcase( i == 46 ); /* UNIQUE */ - testcase( i == 47 ); /* QUERY */ - testcase( i == 48 ); /* ATTACH */ - testcase( i == 49 ); /* HAVING */ - testcase( i == 50 ); /* GROUP */ - testcase( i == 51 ); /* UPDATE */ - testcase( i == 52 ); /* BEGIN */ - testcase( i == 53 ); /* INNER */ - testcase( i == 54 ); /* RELEASE */ - testcase( i == 55 ); /* BETWEEN */ - testcase( i == 56 ); /* NOTNULL */ - testcase( i == 57 ); /* NOT */ - testcase( i == 58 ); /* NO */ - testcase( i == 59 ); /* NULL */ - testcase( i == 60 ); /* LIKE */ - testcase( i == 61 ); /* CASCADE */ - testcase( i == 62 ); /* ASC */ - testcase( i == 63 ); /* DELETE */ - testcase( i == 64 ); /* CASE */ - testcase( i == 65 ); /* COLLATE */ - testcase( i == 66 ); /* CREATE */ - testcase( i == 67 ); /* CURRENT_DATE */ - testcase( i == 68 ); /* DETACH */ - testcase( i == 69 ); /* IMMEDIATE */ - testcase( i == 70 ); /* JOIN */ - testcase( i == 71 ); /* INSERT */ - testcase( i == 72 ); /* MATCH */ - testcase( i == 73 ); /* PLAN */ - testcase( i == 74 ); /* ANALYZE */ - testcase( i == 75 ); /* PRAGMA */ - testcase( i == 76 ); /* ABORT */ - testcase( i == 77 ); /* VALUES */ - testcase( i == 78 ); /* VIRTUAL */ - testcase( i == 79 ); /* LIMIT */ - testcase( i == 80 ); /* WHEN */ - testcase( i == 81 ); /* WHERE */ - testcase( i == 82 ); /* RENAME */ - testcase( i == 83 ); /* AFTER */ - testcase( i == 84 ); /* REPLACE */ - testcase( i == 85 ); /* AND */ - testcase( i == 86 ); /* DEFAULT */ - testcase( i == 87 ); /* AUTOINCREMENT */ - testcase( i == 88 ); /* TO */ - testcase( i == 89 ); /* IN */ - testcase( i == 90 ); /* CAST */ - testcase( i == 91 ); /* COLUMN */ - testcase( i == 92 ); /* COMMIT */ - testcase( i == 93 ); /* CONFLICT */ - testcase( i == 94 ); /* CROSS */ - testcase( i == 95 ); /* CURRENT_TIMESTAMP */ - testcase( i == 96 ); /* CURRENT_TIME */ - testcase( i == 97 ); /* PRIMARY */ - testcase( i == 98 ); /* DEFERRED */ - testcase( i == 99 ); /* DISTINCT */ - testcase( i == 100 ); /* IS */ - testcase( i == 101 ); /* DROP */ - testcase( i == 102 ); /* FAIL */ - testcase( i == 103 ); /* FROM */ - testcase( i == 104 ); /* FULL */ - testcase( i == 105 ); /* GLOB */ - testcase( i == 106 ); /* BY */ - testcase( i == 107 ); /* IF */ - testcase( i == 108 ); /* ISNULL */ - testcase( i == 109 ); /* ORDER */ - testcase( i == 110 ); /* RESTRICT */ - testcase( i == 111 ); /* OUTER */ - testcase( i == 112 ); /* RIGHT */ - testcase( i == 113 ); /* ROLLBACK */ - testcase( i == 114 ); /* ROW */ - testcase( i == 115 ); /* UNION */ - testcase( i == 116 ); /* USING */ - testcase( i == 117 ); /* VACUUM */ - testcase( i == 118 ); /* VIEW */ - testcase( i == 119 ); /* INITIALLY */ - testcase( i == 120 ); /* ALL */ - return aCode[i]; + static int keywordCode(string z, int iOffset, int n) { + int h, i; + if (n < 2) + return TK_ID; + h = ((sqlite3UpperToLower[z[iOffset + 0]]) * 4 ^//(charMap(z[iOffset+0]) * 4) ^ + (sqlite3UpperToLower[z[iOffset + n - 1]] * 3) ^ //(charMap(z[iOffset+n - 1]) * 3) ^ + n) % 127; + for (i = (aHash[h]) - 1; i >= 0; i = (aNext[i]) - 1) { + if (aLen[i] == n && String.Compare(zText, aOffset[i], z, iOffset, n, StringComparison.OrdinalIgnoreCase) == 0) { + testcase(i == 0); /* REINDEX */ + testcase(i == 1); /* INDEXED */ + testcase(i == 2); /* INDEX */ + testcase(i == 3); /* DESC */ + testcase(i == 4); /* ESCAPE */ + testcase(i == 5); /* EACH */ + testcase(i == 6); /* CHECK */ + testcase(i == 7); /* KEY */ + testcase(i == 8); /* BEFORE */ + testcase(i == 9); /* FOREIGN */ + testcase(i == 10); /* FOR */ + testcase(i == 11); /* IGNORE */ + testcase(i == 12); /* REGEXP */ + testcase(i == 13); /* EXPLAIN */ + testcase(i == 14); /* INSTEAD */ + testcase(i == 15); /* ADD */ + testcase(i == 16); /* DATABASE */ + testcase(i == 17); /* AS */ + testcase(i == 18); /* SELECT */ + testcase(i == 19); /* TABLE */ + testcase(i == 20); /* LEFT */ + testcase(i == 21); /* THEN */ + testcase(i == 22); /* END */ + testcase(i == 23); /* DEFERRABLE */ + testcase(i == 24); /* ELSE */ + testcase(i == 25); /* EXCEPT */ + testcase(i == 26); /* TRANSACTION */ + testcase(i == 27); /* ACTION */ + testcase(i == 28); /* ON */ + testcase(i == 29); /* NATURAL */ + testcase(i == 30); /* ALTER */ + testcase(i == 31); /* RAISE */ + testcase(i == 32); /* EXCLUSIVE */ + testcase(i == 33); /* EXISTS */ + testcase(i == 34); /* SAVEPOINT */ + testcase(i == 35); /* INTERSECT */ + testcase(i == 36); /* TRIGGER */ + testcase(i == 37); /* REFERENCES */ + testcase(i == 38); /* CONSTRAINT */ + testcase(i == 39); /* INTO */ + testcase(i == 40); /* OFFSET */ + testcase(i == 41); /* OF */ + testcase(i == 42); /* SET */ + testcase(i == 43); /* TEMPORARY */ + testcase(i == 44); /* TEMP */ + testcase(i == 45); /* OR */ + testcase(i == 46); /* UNIQUE */ + testcase(i == 47); /* QUERY */ + testcase(i == 48); /* ATTACH */ + testcase(i == 49); /* HAVING */ + testcase(i == 50); /* GROUP */ + testcase(i == 51); /* UPDATE */ + testcase(i == 52); /* BEGIN */ + testcase(i == 53); /* INNER */ + testcase(i == 54); /* RELEASE */ + testcase(i == 55); /* BETWEEN */ + testcase(i == 56); /* NOTNULL */ + testcase(i == 57); /* NOT */ + testcase(i == 58); /* NO */ + testcase(i == 59); /* NULL */ + testcase(i == 60); /* LIKE */ + testcase(i == 61); /* CASCADE */ + testcase(i == 62); /* ASC */ + testcase(i == 63); /* DELETE */ + testcase(i == 64); /* CASE */ + testcase(i == 65); /* COLLATE */ + testcase(i == 66); /* CREATE */ + testcase(i == 67); /* CURRENT_DATE */ + testcase(i == 68); /* DETACH */ + testcase(i == 69); /* IMMEDIATE */ + testcase(i == 70); /* JOIN */ + testcase(i == 71); /* INSERT */ + testcase(i == 72); /* MATCH */ + testcase(i == 73); /* PLAN */ + testcase(i == 74); /* ANALYZE */ + testcase(i == 75); /* PRAGMA */ + testcase(i == 76); /* ABORT */ + testcase(i == 77); /* VALUES */ + testcase(i == 78); /* VIRTUAL */ + testcase(i == 79); /* LIMIT */ + testcase(i == 80); /* WHEN */ + testcase(i == 81); /* WHERE */ + testcase(i == 82); /* RENAME */ + testcase(i == 83); /* AFTER */ + testcase(i == 84); /* REPLACE */ + testcase(i == 85); /* AND */ + testcase(i == 86); /* DEFAULT */ + testcase(i == 87); /* AUTOINCREMENT */ + testcase(i == 88); /* TO */ + testcase(i == 89); /* IN */ + testcase(i == 90); /* CAST */ + testcase(i == 91); /* COLUMN */ + testcase(i == 92); /* COMMIT */ + testcase(i == 93); /* CONFLICT */ + testcase(i == 94); /* CROSS */ + testcase(i == 95); /* CURRENT_TIMESTAMP */ + testcase(i == 96); /* CURRENT_TIME */ + testcase(i == 97); /* PRIMARY */ + testcase(i == 98); /* DEFERRED */ + testcase(i == 99); /* DISTINCT */ + testcase(i == 100); /* IS */ + testcase(i == 101); /* DROP */ + testcase(i == 102); /* FAIL */ + testcase(i == 103); /* FROM */ + testcase(i == 104); /* FULL */ + testcase(i == 105); /* GLOB */ + testcase(i == 106); /* BY */ + testcase(i == 107); /* IF */ + testcase(i == 108); /* ISNULL */ + testcase(i == 109); /* ORDER */ + testcase(i == 110); /* RESTRICT */ + testcase(i == 111); /* OUTER */ + testcase(i == 112); /* RIGHT */ + testcase(i == 113); /* ROLLBACK */ + testcase(i == 114); /* ROW */ + testcase(i == 115); /* UNION */ + testcase(i == 116); /* USING */ + testcase(i == 117); /* VACUUM */ + testcase(i == 118); /* VIEW */ + testcase(i == 119); /* INITIALLY */ + testcase(i == 120); /* ALL */ + return aCode[i]; + } + } + return TK_ID; } - } - return TK_ID; - } - static int sqlite3KeywordCode( string z, int n ) - { - return keywordCode( z, 0, n ); + static int sqlite3KeywordCode(string z, int n) { + return keywordCode(z, 0, n); + } + public const int SQLITE_N_KEYWORD = 121;//#define SQLITE_N_KEYWORD 121 } - public const int SQLITE_N_KEYWORD = 121;//#define SQLITE_N_KEYWORD 121 - } } diff --git a/Src/IronPython.SQLite/c#sqlite/legacy_c.cs b/Src/IronPython.SQLite/c#sqlite/legacy_c.cs index 69f76bef2..40fbeb5d5 100644 --- a/Src/IronPython.SQLite/c#sqlite/legacy_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/legacy_c.cs @@ -1,235 +1,208 @@ -using System; using System.Diagnostics; -using System.Text; - -namespace Community.CsharpSqlite -{ - using sqlite3_callback = Sqlite3.dxCallback; - using sqlite3_stmt = Sqlite3.Vdbe; - - public partial class Sqlite3 - { - /* - ** 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. - ** - ************************************************************************* - ** Main file for the SQLite library. The routines in this file - ** implement the programmer interface to the library. Routines in - ** other files are for internal use by SQLite and should not be - ** accessed by users of the library. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - - //#include "sqliteInt.h" - - /* - ** Execute SQL code. Return one of the SQLITE_ success/failure - ** codes. Also write an error message into memory obtained from - ** malloc() and make pzErrMsg point to that message. - ** - ** If the SQL is a query, then for each row in the query result - ** the xCallback() function is called. pArg becomes the first - ** argument to xCallback(). If xCallback=NULL then no callback - ** is invoked, even for queries. - */ - //C# Alias - static public int exec( sqlite3 db, /* The database on which the SQL executes */ string zSql, /* The SQL to be executed */ int NoCallback, int NoArgs, int NoErrors ) - { - string Errors = ""; - return sqlite3_exec( db, zSql, null, null, ref Errors ); - } - static public int exec( sqlite3 db, /* The database on which the SQL executes */ string zSql, /* The SQL to be executed */ sqlite3_callback xCallback, /* Invoke this callback routine */ object pArg, /* First argument to xCallback() */ int NoErrors ) - { - string Errors = ""; - return sqlite3_exec( db, zSql, xCallback, pArg, ref Errors ); - } - static public int exec( sqlite3 db, /* The database on which the SQL executes */ string zSql, /* The SQL to be executed */ sqlite3_callback xCallback, /* Invoke this callback routine */ object pArg, /* First argument to xCallback() */ ref string pzErrMsg /* Write error messages here */) - { - return sqlite3_exec( db, zSql, xCallback, pArg, ref pzErrMsg ); - } +namespace Community.CsharpSqlite { + using sqlite3_callback = Sqlite3.dxCallback; + using sqlite3_stmt = Sqlite3.Vdbe; + + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** Main file for the SQLite library. The routines in this file + ** implement the programmer interface to the library. Routines in + ** other files are for internal use by SQLite and should not be + ** accessed by users of the library. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + + //#include "sqliteInt.h" + + /* + ** Execute SQL code. Return one of the SQLITE_ success/failure + ** codes. Also write an error message into memory obtained from + ** malloc() and make pzErrMsg point to that message. + ** + ** If the SQL is a query, then for each row in the query result + ** the xCallback() function is called. pArg becomes the first + ** argument to xCallback(). If xCallback=NULL then no callback + ** is invoked, even for queries. + */ + //C# Alias + static public int exec(sqlite3 db, /* The database on which the SQL executes */ string zSql, /* The SQL to be executed */ int NoCallback, int NoArgs, int NoErrors) { + string Errors = ""; + return sqlite3_exec(db, zSql, null, null, ref Errors); + } - //OVERLOADS - static public int sqlite3_exec( - sqlite3 db, /* The database on which the SQL executes */ - string zSql, /* The SQL to be executed */ - int NoCallback, int NoArgs, int NoErrors - ) - { - string Errors = ""; - return sqlite3_exec( db, zSql, null, null, ref Errors ); - } + static public int exec(sqlite3 db, /* The database on which the SQL executes */ string zSql, /* The SQL to be executed */ sqlite3_callback xCallback, /* Invoke this callback routine */ object pArg, /* First argument to xCallback() */ int NoErrors) { + string Errors = ""; + return sqlite3_exec(db, zSql, xCallback, pArg, ref Errors); + } + static public int exec(sqlite3 db, /* The database on which the SQL executes */ string zSql, /* The SQL to be executed */ sqlite3_callback xCallback, /* Invoke this callback routine */ object pArg, /* First argument to xCallback() */ ref string pzErrMsg /* Write error messages here */) { + return sqlite3_exec(db, zSql, xCallback, pArg, ref pzErrMsg); + } - static public int sqlite3_exec( - sqlite3 db, /* The database on which the SQL executes */ - string zSql, /* The SQL to be executed */ - sqlite3_callback xCallback, /* Invoke this callback routine */ - object pArg, /* First argument to xCallback() */ - int NoErrors - ) - { - string Errors = ""; - return sqlite3_exec( db, zSql, xCallback, pArg, ref Errors ); - } - static public int sqlite3_exec( - sqlite3 db, /* The database on which the SQL executes */ - string zSql, /* The SQL to be executed */ - sqlite3_callback xCallback, /* Invoke this callback routine */ - object pArg, /* First argument to xCallback() */ - ref string pzErrMsg /* Write error messages here */ - ) - { - - int rc = SQLITE_OK; /* Return code */ - string zLeftover = ""; /* Tail of unprocessed SQL */ - sqlite3_stmt pStmt = null; /* The current SQL statement */ - string[] azCols = null; /* Names of result columns */ - int nRetry = 0; /* Number of retry attempts */ - int callbackIsInit; /* True if callback data is initialized */ - - if ( !sqlite3SafetyCheckOk( db ) ) - return SQLITE_MISUSE_BKPT(); - - if ( zSql == null ) - zSql = ""; - - sqlite3_mutex_enter( db.mutex ); - sqlite3Error( db, SQLITE_OK, 0 ); - while ( ( rc == SQLITE_OK || ( rc == SQLITE_SCHEMA && ( ++nRetry ) < 2 ) ) && zSql != "" ) - { - int nCol; - string[] azVals = null; - - pStmt = null; - rc = sqlite3_prepare( db, zSql, -1, ref pStmt, ref zLeftover ); - Debug.Assert( rc == SQLITE_OK || pStmt == null ); - if ( rc != SQLITE_OK ) - { - continue; + //OVERLOADS + static public int sqlite3_exec( + sqlite3 db, /* The database on which the SQL executes */ + string zSql, /* The SQL to be executed */ + int NoCallback, int NoArgs, int NoErrors + ) { + string Errors = ""; + return sqlite3_exec(db, zSql, null, null, ref Errors); } - if ( pStmt == null ) - { - /* this happens for a comment or white-space */ - zSql = zLeftover; - continue; + + static public int sqlite3_exec( + sqlite3 db, /* The database on which the SQL executes */ + string zSql, /* The SQL to be executed */ + sqlite3_callback xCallback, /* Invoke this callback routine */ + object pArg, /* First argument to xCallback() */ + int NoErrors + ) { + string Errors = ""; + return sqlite3_exec(db, zSql, xCallback, pArg, ref Errors); } + static public int sqlite3_exec( + sqlite3 db, /* The database on which the SQL executes */ + string zSql, /* The SQL to be executed */ + sqlite3_callback xCallback, /* Invoke this callback routine */ + object pArg, /* First argument to xCallback() */ + ref string pzErrMsg /* Write error messages here */ + ) { + + int rc = SQLITE_OK; /* Return code */ + string zLeftover = ""; /* Tail of unprocessed SQL */ + sqlite3_stmt pStmt = null; /* The current SQL statement */ + string[] azCols = null; /* Names of result columns */ + int nRetry = 0; /* Number of retry attempts */ + int callbackIsInit; /* True if callback data is initialized */ + + if (!sqlite3SafetyCheckOk(db)) + return SQLITE_MISUSE_BKPT(); + + if (zSql == null) + zSql = ""; + + sqlite3_mutex_enter(db.mutex); + sqlite3Error(db, SQLITE_OK, 0); + while ((rc == SQLITE_OK || (rc == SQLITE_SCHEMA && (++nRetry) < 2)) && zSql != "") { + int nCol; + string[] azVals = null; + + pStmt = null; + rc = sqlite3_prepare(db, zSql, -1, ref pStmt, ref zLeftover); + Debug.Assert(rc == SQLITE_OK || pStmt == null); + if (rc != SQLITE_OK) { + continue; + } + if (pStmt == null) { + /* this happens for a comment or white-space */ + zSql = zLeftover; + continue; + } - callbackIsInit = 0; - nCol = sqlite3_column_count( pStmt ); - - while ( true ) - { - int i; - rc = sqlite3_step( pStmt ); - - /* Invoke the callback function if required */ - if ( xCallback != null && ( SQLITE_ROW == rc || - ( SQLITE_DONE == rc && callbackIsInit == 0 - && ( db.flags & SQLITE_NullCallback ) != 0 ) ) ) - { - if ( 0 == callbackIsInit ) - { - azCols = new string[nCol];//sqlite3DbMallocZero(db, 2*nCol*sizeof(const char*) + 1); - //if ( azCols == null ) - //{ - // goto exec_out; - //} - for ( i = 0; i < nCol; i++ ) - { - azCols[i] = sqlite3_column_name( pStmt, i ); - /* sqlite3VdbeSetColName() installs column names as UTF8 - ** strings so there is no way for sqlite3_column_name() to fail. */ - Debug.Assert( azCols[i] != null ); - } - callbackIsInit = 1; - } - if ( rc == SQLITE_ROW ) - { - azVals = new string[nCol];// azCols[nCol]; - for ( i = 0; i < nCol; i++ ) - { - azVals[i] = sqlite3_column_text( pStmt, i ); - if ( azVals[i] == null && sqlite3_column_type( pStmt, i ) != SQLITE_NULL ) - { - //db.mallocFailed = 1; - //goto exec_out; + callbackIsInit = 0; + nCol = sqlite3_column_count(pStmt); + + while (true) { + int i; + rc = sqlite3_step(pStmt); + + /* Invoke the callback function if required */ + if (xCallback != null && (SQLITE_ROW == rc || + (SQLITE_DONE == rc && callbackIsInit == 0 + && (db.flags & SQLITE_NullCallback) != 0))) { + if (0 == callbackIsInit) { + azCols = new string[nCol];//sqlite3DbMallocZero(db, 2*nCol*sizeof(const char*) + 1); + //if ( azCols == null ) + //{ + // goto exec_out; + //} + for (i = 0; i < nCol; i++) { + azCols[i] = sqlite3_column_name(pStmt, i); + /* sqlite3VdbeSetColName() installs column names as UTF8 + ** strings so there is no way for sqlite3_column_name() to fail. */ + Debug.Assert(azCols[i] != null); + } + callbackIsInit = 1; + } + if (rc == SQLITE_ROW) { + azVals = new string[nCol];// azCols[nCol]; + for (i = 0; i < nCol; i++) { + azVals[i] = sqlite3_column_text(pStmt, i); + if (azVals[i] == null && sqlite3_column_type(pStmt, i) != SQLITE_NULL) { + //db.mallocFailed = 1; + //goto exec_out; + } + } + } + if (xCallback(pArg, nCol, azVals, azCols) != 0) { + rc = SQLITE_ABORT; + sqlite3VdbeFinalize(ref pStmt); + pStmt = null; + sqlite3Error(db, SQLITE_ABORT, 0); + goto exec_out; + } + } + + if (rc != SQLITE_ROW) { + rc = sqlite3VdbeFinalize(ref pStmt); + pStmt = null; + if (rc != SQLITE_SCHEMA) { + nRetry = 0; + if ((zSql = zLeftover) != "") { + int zindex = 0; + while (zindex < zSql.Length && sqlite3Isspace(zSql[zindex])) + zindex++; + if (zindex != 0) + zSql = zindex < zSql.Length ? zSql.Substring(zindex) : ""; + } + } + break; + } } - } - } - if ( xCallback( pArg, nCol, azVals, azCols ) != 0 ) - { - rc = SQLITE_ABORT; - sqlite3VdbeFinalize( ref pStmt ); - pStmt = null; - sqlite3Error( db, SQLITE_ABORT, 0 ); - goto exec_out; + + sqlite3DbFree(db, ref azCols); + azCols = null; } - } - - if ( rc != SQLITE_ROW ) - { - rc = sqlite3VdbeFinalize( ref pStmt ); - pStmt = null; - if ( rc != SQLITE_SCHEMA ) - { - nRetry = 0; - if ( ( zSql = zLeftover ) != "" ) - { - int zindex = 0; - while ( zindex < zSql.Length && sqlite3Isspace( zSql[zindex] ) ) - zindex++; - if ( zindex != 0 ) - zSql = zindex < zSql.Length ? zSql.Substring( zindex ) : ""; - } + + exec_out: + if (pStmt != null) + sqlite3VdbeFinalize(ref pStmt); + sqlite3DbFree(db, ref azCols); + + rc = sqlite3ApiExit(db, rc); + if (rc != SQLITE_OK && ALWAYS(rc == sqlite3_errcode(db)) && pzErrMsg != null) { + //int nErrMsg = 1 + sqlite3Strlen30(sqlite3_errmsg(db)); + //pzErrMsg = sqlite3Malloc(nErrMsg); + //if (pzErrMsg) + //{ + // memcpy(pzErrMsg, sqlite3_errmsg(db), nErrMsg); + //}else{ + //rc = SQLITE_NOMEM; + //sqlite3Error(db, SQLITE_NOMEM, 0); + //} + pzErrMsg = sqlite3_errmsg(db); + } else if (pzErrMsg != "") { + pzErrMsg = ""; } - break; - } - } - sqlite3DbFree( db, ref azCols ); - azCols = null; - } - -exec_out: - if ( pStmt != null ) - sqlite3VdbeFinalize( ref pStmt ); - sqlite3DbFree( db, ref azCols ); - - rc = sqlite3ApiExit( db, rc ); - if ( rc != SQLITE_OK && ALWAYS( rc == sqlite3_errcode( db ) ) && pzErrMsg != null ) - { - //int nErrMsg = 1 + sqlite3Strlen30(sqlite3_errmsg(db)); - //pzErrMsg = sqlite3Malloc(nErrMsg); - //if (pzErrMsg) - //{ - // memcpy(pzErrMsg, sqlite3_errmsg(db), nErrMsg); - //}else{ - //rc = SQLITE_NOMEM; - //sqlite3Error(db, SQLITE_NOMEM, 0); - //} - pzErrMsg = sqlite3_errmsg( db ); - } - else if ( pzErrMsg != "" ) - { - pzErrMsg = ""; - } - - Debug.Assert( ( rc & db.errMask ) == rc ); - sqlite3_mutex_leave( db.mutex ); - return rc; + Debug.Assert((rc & db.errMask) == rc); + sqlite3_mutex_leave(db.mutex); + return rc; + } } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/loadext_c.cs b/Src/IronPython.SQLite/c#sqlite/loadext_c.cs index e9b4bafba..0407eac7f 100644 --- a/Src/IronPython.SQLite/c#sqlite/loadext_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/loadext_c.cs @@ -1,48 +1,47 @@ using System; using System.Diagnostics; -using HANDLE = System.IntPtr; using System.Text; -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 2006 June 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 contains code used to dynamically load extensions into - ** the SQLite library. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ +using HANDLE = System.IntPtr; + +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2006 June 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 contains code used to dynamically load extensions into + ** the SQLite library. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ #if !SQLITE_CORE - //#define SQLITE_CORE 1 /* Disable the API redefinition in sqlite3ext.h */ - const int SQLITE_CORE = 1; + //#define SQLITE_CORE 1 /* Disable the API redefinition in sqlite3ext.h */ + const int SQLITE_CORE = 1; #endif - //#include "sqlite3ext.h" - //#include "sqliteInt.h" - //#include + //#include "sqlite3ext.h" + //#include "sqliteInt.h" + //#include #if !SQLITE_OMIT_LOAD_EXTENSION - /* -** Some API routines are omitted when various features are -** excluded from a build of SQLite. Substitute a NULL pointer -** for any missing APIs. -*/ + /* + ** Some API routines are omitted when various features are + ** excluded from a build of SQLite. Substitute a NULL pointer + ** for any missing APIs. + */ #if !SQLITE_ENABLE_COLUMN_METADATA //# define sqlite3_column_database_name 0 //# define sqlite3_column_database_name16 0 @@ -54,39 +53,37 @@ public partial class Sqlite3 #endif #if SQLITE_OMIT_AUTHORIZATION - //# define sqlite3_set_authorizer 0 + //# define sqlite3_set_authorizer 0 #endif #if SQLITE_OMIT_UTF16 - //# define sqlite3_bind_text16 0 - //# define sqlite3_collation_needed16 0 - //# define sqlite3_column_decltype16 0 - //# define sqlite3_column_name16 0 - //# define sqlite3_column_text16 0 - //# define sqlite3_complete16 0 - //# define sqlite3_create_collation16 0 - //# define sqlite3_create_function16 0 - //# define sqlite3_errmsg16 0 - static string sqlite3_errmsg16( sqlite3 db ) - { - return ""; - } - //# define sqlite3_open16 0 - //# define sqlite3_prepare16 0 - //# define sqlite3_prepare16_v2 0 - //# define sqlite3_result_error16 0 - //# define sqlite3_result_text16 0 - static void sqlite3_result_text16( sqlite3_context pCtx, string z, int n, dxDel xDel ) - { - } - //# define sqlite3_result_text16be 0 - //# define sqlite3_result_text16le 0 - //# define sqlite3_value_text16 0 - //# define sqlite3_value_text16be 0 - //# define sqlite3_value_text16le 0 - //# define sqlite3_column_database_name16 0 - //# define sqlite3_column_table_name16 0 - //# define sqlite3_column_origin_name16 0 + //# define sqlite3_bind_text16 0 + //# define sqlite3_collation_needed16 0 + //# define sqlite3_column_decltype16 0 + //# define sqlite3_column_name16 0 + //# define sqlite3_column_text16 0 + //# define sqlite3_complete16 0 + //# define sqlite3_create_collation16 0 + //# define sqlite3_create_function16 0 + //# define sqlite3_errmsg16 0 + static string sqlite3_errmsg16(sqlite3 db) { + return ""; + } + //# define sqlite3_open16 0 + //# define sqlite3_prepare16 0 + //# define sqlite3_prepare16_v2 0 + //# define sqlite3_result_error16 0 + //# define sqlite3_result_text16 0 + static void sqlite3_result_text16(sqlite3_context pCtx, string z, int n, dxDel xDel) { + } + //# define sqlite3_result_text16be 0 + //# define sqlite3_result_text16le 0 + //# define sqlite3_value_text16 0 + //# define sqlite3_value_text16be 0 + //# define sqlite3_value_text16le 0 + //# define sqlite3_column_database_name16 0 + //# define sqlite3_column_table_name16 0 + //# define sqlite3_column_origin_name16 0 #endif #if SQLITE_OMIT_COMPLETE @@ -111,7 +108,7 @@ static void sqlite3_progress_handler (sqlite3 db, int nOps, dxProgress xPr #endif #if SQLITE_OMIT_SHARED_CACHE - //# define sqlite3_enable_shared_cache 0 + //# define sqlite3_enable_shared_cache 0 #endif #if SQLITE_OMIT_TRACE @@ -120,233 +117,230 @@ static void sqlite3_progress_handler (sqlite3 db, int nOps, dxProgress xPr #endif #if SQLITE_OMIT_GET_TABLE - //# define //sqlite3_free_table 0 - static public int sqlite3_free_table(ref string[] pazResult) { pazResult = null; return 0; } - - static public int sqlite3_get_table( - sqlite3 db, /* An open database */ - string zSql, /* SQL to be evaluated */ - ref string[] pazResult, /* Results of the query */ - ref int pnRow, /* Number of result rows written here */ - object dummy, - ref string pzErrmsg /* Error msg written here */ - ) - { - int iDummy = 0; - return sqlite3_get_table(db, zSql, ref pazResult, ref pnRow, ref iDummy, ref pzErrmsg); - } + //# define //sqlite3_free_table 0 + static public int sqlite3_free_table(ref string[] pazResult) { pazResult = null; return 0; } + + static public int sqlite3_get_table( + sqlite3 db, /* An open database */ + string zSql, /* SQL to be evaluated */ + ref string[] pazResult, /* Results of the query */ + ref int pnRow, /* Number of result rows written here */ + object dummy, + ref string pzErrmsg /* Error msg written here */ + ) { + int iDummy = 0; + return sqlite3_get_table(db, zSql, ref pazResult, ref pnRow, ref iDummy, ref pzErrmsg); + } //# define sqlite3_get_table 0 - static public int sqlite3_get_table( - sqlite3 db, /* An open database */ - string zSql, /* SQL to be evaluated */ - ref string[] pazResult, /* Results of the query */ - ref int pnRow, /* Number of result rows written here */ - ref int pnColumn, /* Number of result columns written here */ - ref string pzErrmsg /* Error msg written here */ - ) - { - return 0; - } + static public int sqlite3_get_table( + sqlite3 db, /* An open database */ + string zSql, /* SQL to be evaluated */ + ref string[] pazResult, /* Results of the query */ + ref int pnRow, /* Number of result rows written here */ + ref int pnColumn, /* Number of result columns written here */ + ref string pzErrmsg /* Error msg written here */ + ) { + return 0; + } #endif #if SQLITE_OMIT_INCRBLOB - //#define sqlite3_bind_zeroblob 0 - //#define sqlite3_blob_bytes 0 - //#define sqlite3_blob_close 0 - //#define sqlite3_blob_open 0 - //#define sqlite3_blob_read 0 - //#define sqlite3_blob_write 0 + //#define sqlite3_bind_zeroblob 0 + //#define sqlite3_blob_bytes 0 + //#define sqlite3_blob_close 0 + //#define sqlite3_blob_open 0 + //#define sqlite3_blob_read 0 + //#define sqlite3_blob_write 0 #endif - /* -** The following structure contains pointers to all SQLite API routines. -** A pointer to this structure is passed into extensions when they are -** loaded so that the extension can make calls back into the SQLite -** library. -** -** When adding new APIs, add them to the bottom of this structure -** in order to preserve backwards compatibility. -** -** Extensions that use newer APIs should first call the -** sqlite3_libversion_number() to make sure that the API they -** intend to use is supported by the library. Extensions should -** also check to make sure that the pointer to the function is -** not NULL before calling it. -*/ - public class sqlite3_api_routines - { - public sqlite3 context_db_handle; - }; - - static sqlite3_api_routines sqlite3Apis = new sqlite3_api_routines(); - //{ - // sqlite3_aggregate_context, + /* + ** The following structure contains pointers to all SQLite API routines. + ** A pointer to this structure is passed into extensions when they are + ** loaded so that the extension can make calls back into the SQLite + ** library. + ** + ** When adding new APIs, add them to the bottom of this structure + ** in order to preserve backwards compatibility. + ** + ** Extensions that use newer APIs should first call the + ** sqlite3_libversion_number() to make sure that the API they + ** intend to use is supported by the library. Extensions should + ** also check to make sure that the pointer to the function is + ** not NULL before calling it. + */ + public class sqlite3_api_routines { + public sqlite3 context_db_handle; + }; + + static sqlite3_api_routines sqlite3Apis = new sqlite3_api_routines(); + //{ + // sqlite3_aggregate_context, #if !SQLITE_OMIT_DEPRECATED / sqlite3_aggregate_count, #else - // 0, + // 0, #endif - // sqlite3_bind_blob, - // sqlite3_bind_double, - // sqlite3_bind_int, - // sqlite3_bind_int64, - // sqlite3_bind_null, - // sqlite3_bind_parameter_count, - // sqlite3_bind_parameter_index, - // sqlite3_bind_parameter_name, - // sqlite3_bind_text, - // sqlite3_bind_text16, - // sqlite3_bind_value, - // sqlite3_busy_handler, - // sqlite3_busy_timeout, - // sqlite3_changes, - // sqlite3_close, - // sqlite3_collation_needed, - // sqlite3_collation_needed16, - // sqlite3_column_blob, - // sqlite3_column_bytes, - // sqlite3_column_bytes16, - // sqlite3_column_count, - // sqlite3_column_database_name, - // sqlite3_column_database_name16, - // sqlite3_column_decltype, - // sqlite3_column_decltype16, - // sqlite3_column_double, - // sqlite3_column_int, - // sqlite3_column_int64, - // sqlite3_column_name, - // sqlite3_column_name16, - // sqlite3_column_origin_name, - // sqlite3_column_origin_name16, - // sqlite3_column_table_name, - // sqlite3_column_table_name16, - // sqlite3_column_text, - // sqlite3_column_text16, - // sqlite3_column_type, - // sqlite3_column_value, - // sqlite3_commit_hook, - // sqlite3_complete, - // sqlite3_complete16, - // sqlite3_create_collation, - // sqlite3_create_collation16, - // sqlite3_create_function, - // sqlite3_create_function16, - // sqlite3_create_module, - // sqlite3_data_count, - // sqlite3_db_handle, - // sqlite3_declare_vtab, - // sqlite3_enable_shared_cache, - // sqlite3_errcode, - // sqlite3_errmsg, - // sqlite3_errmsg16, - // sqlite3_exec, + // sqlite3_bind_blob, + // sqlite3_bind_double, + // sqlite3_bind_int, + // sqlite3_bind_int64, + // sqlite3_bind_null, + // sqlite3_bind_parameter_count, + // sqlite3_bind_parameter_index, + // sqlite3_bind_parameter_name, + // sqlite3_bind_text, + // sqlite3_bind_text16, + // sqlite3_bind_value, + // sqlite3_busy_handler, + // sqlite3_busy_timeout, + // sqlite3_changes, + // sqlite3_close, + // sqlite3_collation_needed, + // sqlite3_collation_needed16, + // sqlite3_column_blob, + // sqlite3_column_bytes, + // sqlite3_column_bytes16, + // sqlite3_column_count, + // sqlite3_column_database_name, + // sqlite3_column_database_name16, + // sqlite3_column_decltype, + // sqlite3_column_decltype16, + // sqlite3_column_double, + // sqlite3_column_int, + // sqlite3_column_int64, + // sqlite3_column_name, + // sqlite3_column_name16, + // sqlite3_column_origin_name, + // sqlite3_column_origin_name16, + // sqlite3_column_table_name, + // sqlite3_column_table_name16, + // sqlite3_column_text, + // sqlite3_column_text16, + // sqlite3_column_type, + // sqlite3_column_value, + // sqlite3_commit_hook, + // sqlite3_complete, + // sqlite3_complete16, + // sqlite3_create_collation, + // sqlite3_create_collation16, + // sqlite3_create_function, + // sqlite3_create_function16, + // sqlite3_create_module, + // sqlite3_data_count, + // sqlite3_db_handle, + // sqlite3_declare_vtab, + // sqlite3_enable_shared_cache, + // sqlite3_errcode, + // sqlite3_errmsg, + // sqlite3_errmsg16, + // sqlite3_exec, #if !SQLITE_OMIT_DEPRECATED //sqlite3_expired, #else - //0, + //0, #endif - // sqlite3_finalize, - // //sqlite3_free, - // //sqlite3_free_table, - // sqlite3_get_autocommit, - // sqlite3_get_auxdata, - // sqlite3_get_table, - // 0, /* Was sqlite3_global_recover(), but that function is deprecated */ - // sqlite3_interrupt, - // sqlite3_last_insert_rowid, - // sqlite3_libversion, - // sqlite3_libversion_number, - // sqlite3_malloc, - // sqlite3_mprintf, - // sqlite3_open, - // sqlite3_open16, - // sqlite3_prepare, - // sqlite3_prepare16, - // sqlite3_profile, - // sqlite3_progress_handler, - // sqlite3_realloc, - // sqlite3_reset, - // sqlite3_result_blob, - // sqlite3_result_double, - // sqlite3_result_error, - // sqlite3_result_error16, - // sqlite3_result_int, - // sqlite3_result_int64, - // sqlite3_result_null, - // sqlite3_result_text, - // sqlite3_result_text16, - // sqlite3_result_text16be, - // sqlite3_result_text16le, - // sqlite3_result_value, - // sqlite3_rollback_hook, - // sqlite3_set_authorizer, - // sqlite3_set_auxdata, - // sqlite3_snprintf, - // sqlite3_step, - // sqlite3_table_column_metadata, + // sqlite3_finalize, + // //sqlite3_free, + // //sqlite3_free_table, + // sqlite3_get_autocommit, + // sqlite3_get_auxdata, + // sqlite3_get_table, + // 0, /* Was sqlite3_global_recover(), but that function is deprecated */ + // sqlite3_interrupt, + // sqlite3_last_insert_rowid, + // sqlite3_libversion, + // sqlite3_libversion_number, + // sqlite3_malloc, + // sqlite3_mprintf, + // sqlite3_open, + // sqlite3_open16, + // sqlite3_prepare, + // sqlite3_prepare16, + // sqlite3_profile, + // sqlite3_progress_handler, + // sqlite3_realloc, + // sqlite3_reset, + // sqlite3_result_blob, + // sqlite3_result_double, + // sqlite3_result_error, + // sqlite3_result_error16, + // sqlite3_result_int, + // sqlite3_result_int64, + // sqlite3_result_null, + // sqlite3_result_text, + // sqlite3_result_text16, + // sqlite3_result_text16be, + // sqlite3_result_text16le, + // sqlite3_result_value, + // sqlite3_rollback_hook, + // sqlite3_set_authorizer, + // sqlite3_set_auxdata, + // sqlite3_snprintf, + // sqlite3_step, + // sqlite3_table_column_metadata, #if !SQLITE_OMIT_DEPRECATED //sqlite3_thread_cleanup, #else - // 0, + // 0, #endif - // sqlite3_total_changes, - // sqlite3_trace, + // sqlite3_total_changes, + // sqlite3_trace, #if !SQLITE_OMIT_DEPRECATED //sqlite3_transfer_bindings, #else - // 0, + // 0, #endif - // sqlite3_update_hook, - // sqlite3_user_data, - // sqlite3_value_blob, - // sqlite3_value_bytes, - // sqlite3_value_bytes16, - // sqlite3_value_double, - // sqlite3_value_int, - // sqlite3_value_int64, - // sqlite3_value_numeric_type, - // sqlite3_value_text, - // sqlite3_value_text16, - // sqlite3_value_text16be, - // sqlite3_value_text16le, - // sqlite3_value_type, - // sqlite3_vmprintf, - // /* - // ** The original API set ends here. All extensions can call any - // ** of the APIs above provided that the pointer is not NULL. But - // ** before calling APIs that follow, extension should check the - // ** sqlite3_libversion_number() to make sure they are dealing with - // ** a library that is new enough to support that API. - // ************************************************************************* - // */ - // sqlite3_overload_function, - - // /* - // ** Added after 3.3.13 - // */ - // sqlite3_prepare_v2, - // sqlite3_prepare16_v2, - // sqlite3_clear_bindings, - - // /* - // ** Added for 3.4.1 - // */ - // sqlite3_create_module_v2, - - // /* - // ** Added for 3.5.0 - // */ - // sqlite3_bind_zeroblob, - // sqlite3_blob_bytes, - // sqlite3_blob_close, - // sqlite3_blob_open, - // sqlite3_blob_read, - // sqlite3_blob_write, - // sqlite3_create_collation_v2, - // sqlite3_file_control, - // sqlite3_memory_highwater, - // sqlite3_memory_used, + // sqlite3_update_hook, + // sqlite3_user_data, + // sqlite3_value_blob, + // sqlite3_value_bytes, + // sqlite3_value_bytes16, + // sqlite3_value_double, + // sqlite3_value_int, + // sqlite3_value_int64, + // sqlite3_value_numeric_type, + // sqlite3_value_text, + // sqlite3_value_text16, + // sqlite3_value_text16be, + // sqlite3_value_text16le, + // sqlite3_value_type, + // sqlite3_vmprintf, + // /* + // ** The original API set ends here. All extensions can call any + // ** of the APIs above provided that the pointer is not NULL. But + // ** before calling APIs that follow, extension should check the + // ** sqlite3_libversion_number() to make sure they are dealing with + // ** a library that is new enough to support that API. + // ************************************************************************* + // */ + // sqlite3_overload_function, + + // /* + // ** Added after 3.3.13 + // */ + // sqlite3_prepare_v2, + // sqlite3_prepare16_v2, + // sqlite3_clear_bindings, + + // /* + // ** Added for 3.4.1 + // */ + // sqlite3_create_module_v2, + + // /* + // ** Added for 3.5.0 + // */ + // sqlite3_bind_zeroblob, + // sqlite3_blob_bytes, + // sqlite3_blob_close, + // sqlite3_blob_open, + // sqlite3_blob_read, + // sqlite3_blob_write, + // sqlite3_create_collation_v2, + // sqlite3_file_control, + // sqlite3_memory_highwater, + // sqlite3_memory_used, #if SQLITE_MUTEX_OMIT // 0, // 0, @@ -354,406 +348,381 @@ public class sqlite3_api_routines // 0, // 0, #else -// sqlite3MutexAlloc, -// sqlite3_mutex_enter, -// sqlite3_mutex_free, -// sqlite3_mutex_leave, -// sqlite3_mutex_try, + // sqlite3MutexAlloc, + // sqlite3_mutex_enter, + // sqlite3_mutex_free, + // sqlite3_mutex_leave, + // sqlite3_mutex_try, #endif - // sqlite3_open_v2, - // sqlite3_release_memory, - // sqlite3_result_error_nomem, - // sqlite3_result_error_toobig, - // sqlite3_sleep, - // sqlite3_soft_heap_limit, - // sqlite3_vfs_find, - // sqlite3_vfs_register, - // sqlite3_vfs_unregister, - - // /* - // ** Added for 3.5.8 - // */ - // sqlite3_threadsafe, - // sqlite3_result_zeroblob, - // sqlite3_result_error_code, - // sqlite3_test_control, - // sqlite3_randomness, - // sqlite3_context_db_handle, - - // /* - // ** Added for 3.6.0 - // */ - // sqlite3_extended_result_codes, - // sqlite3_limit, - // sqlite3_next_stmt, - // sqlite3_sql, - // sqlite3_status, - - // /* - // ** Added for 3.7.4 - // */ - // sqlite3_backup_finish, - // sqlite3_backup_init, - // sqlite3_backup_pagecount, - // sqlite3_backup_remaining, - // sqlite3_backup_step, - //#if !SQLITE_OMIT_COMPILEOPTION_DIAGS - // sqlite3_compileoption_get, - // sqlite3_compileoption_used, - //#else - // 0, - // 0, - //#endif - // sqlite3_create_function_v2, - // sqlite3_db_config, - // sqlite3_db_mutex, - // sqlite3_db_status, - // sqlite3_extended_errcode, - // sqlite3_log, - // sqlite3_soft_heap_limit64, - // sqlite3_sourceid, - // sqlite3_stmt_status, - // sqlite3_strnicmp, - //#if SQLITE_ENABLE_UNLOCK_NOTIFY - // sqlite3_unlock_notify, - //#else - // 0, - //#endif - //#if !SQLITE_OMIT_WAL - // sqlite3_wal_autocheckpoint, - // sqlite3_wal_checkpoint, - // sqlite3_wal_hook, - //#else - // 0, - // 0, - // 0, - //#endif - //}; - - /* - ** Attempt to load an SQLite extension library contained in the file - ** zFile. The entry point is zProc. zProc may be 0 in which case a - ** default entry point name (sqlite3_extension_init) is used. Use - ** of the default name is recommended. - ** - ** Return SQLITE_OK on success and SQLITE_ERROR if something goes wrong. - ** - ** If an error occurs and pzErrMsg is not 0, then fill pzErrMsg with - ** error message text. The calling function should free this memory - ** by calling sqlite3DbFree(db, ). - */ - static int sqlite3LoadExtension( - sqlite3 db, /* Load the extension into this database connection */ - string zFile, /* Name of the shared library containing extension */ - string zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */ - ref string pzErrMsg /* Put error message here if not 0 */ - ) - { - sqlite3_vfs pVfs = db.pVfs; - HANDLE handle; - dxInit xInit; //int (*xInit)(sqlite3*,char**,const sqlite3_api_routines); - StringBuilder zErrmsg = new StringBuilder( 100 ); - //object aHandle; - const int nMsg = 300; - if ( pzErrMsg != null ) - pzErrMsg = null; - - - /* Ticket #1863. To avoid a creating security problems for older - ** applications that relink against newer versions of SQLite, the - ** ability to run load_extension is turned off by default. One - ** must call sqlite3_enable_load_extension() to turn on extension - ** loading. Otherwise you get the following error. - */ - if ( ( db.flags & SQLITE_LoadExtension ) == 0 ) - { - //if( pzErrMsg != null){ - pzErrMsg = sqlite3_mprintf( "not authorized" ); - //} - return SQLITE_ERROR; - } - - if ( zProc == null || zProc == "" ) - { - zProc = "sqlite3_extension_init"; - } - - handle = sqlite3OsDlOpen( pVfs, zFile ); - if ( handle == IntPtr.Zero ) - { - // if( pzErrMsg ){ - pzErrMsg = "";//*pzErrMsg = zErrmsg = sqlite3_malloc(nMsg); - //if( zErrmsg !=null){ - sqlite3_snprintf( nMsg, zErrmsg, - "unable to open shared library [%s]", zFile ); - sqlite3OsDlError( pVfs, nMsg - 1, zErrmsg.ToString() ); - return SQLITE_ERROR; - } - //xInit = (int()(sqlite3*,char**,const sqlite3_api_routines)) - // sqlite3OsDlSym(pVfs, handle, zProc); - xInit = (dxInit)sqlite3OsDlSym( pVfs, handle, ref zProc ); - Debugger.Break(); // TODO -- - //if( xInit==0 ){ - // if( pzErrMsg ){ - // *pzErrMsg = zErrmsg = sqlite3_malloc(nMsg); - // if( zErrmsg ){ - // sqlite3_snprintf(nMsg, zErrmsg, - // "no entry point [%s] in shared library [%s]", zProc,zFile); - // sqlite3OsDlError(pVfs, nMsg-1, zErrmsg); - // } - // sqlite3OsDlClose(pVfs, handle); - // } - // return SQLITE_ERROR; - // }else if( xInit(db, ref zErrmsg, sqlite3Apis) ){ - //// if( pzErrMsg !=null){ - // pzErrMsg = sqlite3_mprintf("error during initialization: %s", zErrmsg); - // //} - // sqlite3DbFree(db,ref zErrmsg); - // sqlite3OsDlClose(pVfs, ref handle); - // return SQLITE_ERROR; - // } - - // /* Append the new shared library handle to the db.aExtension array. */ - // aHandle = sqlite3DbMallocZero(db, sizeof(handle)*db.nExtension+1); - // if( aHandle==null ){ - // return SQLITE_NOMEM; - // } - // if( db.nExtension>0 ){ - // memcpy(aHandle, db.aExtension, sizeof(handle)*(db.nExtension)); - // } - // sqlite3DbFree(db,ref db.aExtension); - // db.aExtension = aHandle; - - // db.aExtension[db.nExtension++] = handle; - return SQLITE_OK; - } + // sqlite3_open_v2, + // sqlite3_release_memory, + // sqlite3_result_error_nomem, + // sqlite3_result_error_toobig, + // sqlite3_sleep, + // sqlite3_soft_heap_limit, + // sqlite3_vfs_find, + // sqlite3_vfs_register, + // sqlite3_vfs_unregister, + + // /* + // ** Added for 3.5.8 + // */ + // sqlite3_threadsafe, + // sqlite3_result_zeroblob, + // sqlite3_result_error_code, + // sqlite3_test_control, + // sqlite3_randomness, + // sqlite3_context_db_handle, + + // /* + // ** Added for 3.6.0 + // */ + // sqlite3_extended_result_codes, + // sqlite3_limit, + // sqlite3_next_stmt, + // sqlite3_sql, + // sqlite3_status, + + // /* + // ** Added for 3.7.4 + // */ + // sqlite3_backup_finish, + // sqlite3_backup_init, + // sqlite3_backup_pagecount, + // sqlite3_backup_remaining, + // sqlite3_backup_step, + //#if !SQLITE_OMIT_COMPILEOPTION_DIAGS + // sqlite3_compileoption_get, + // sqlite3_compileoption_used, + //#else + // 0, + // 0, + //#endif + // sqlite3_create_function_v2, + // sqlite3_db_config, + // sqlite3_db_mutex, + // sqlite3_db_status, + // sqlite3_extended_errcode, + // sqlite3_log, + // sqlite3_soft_heap_limit64, + // sqlite3_sourceid, + // sqlite3_stmt_status, + // sqlite3_strnicmp, + //#if SQLITE_ENABLE_UNLOCK_NOTIFY + // sqlite3_unlock_notify, + //#else + // 0, + //#endif + //#if !SQLITE_OMIT_WAL + // sqlite3_wal_autocheckpoint, + // sqlite3_wal_checkpoint, + // sqlite3_wal_hook, + //#else + // 0, + // 0, + // 0, + //#endif + //}; + + /* + ** Attempt to load an SQLite extension library contained in the file + ** zFile. The entry point is zProc. zProc may be 0 in which case a + ** default entry point name (sqlite3_extension_init) is used. Use + ** of the default name is recommended. + ** + ** Return SQLITE_OK on success and SQLITE_ERROR if something goes wrong. + ** + ** If an error occurs and pzErrMsg is not 0, then fill pzErrMsg with + ** error message text. The calling function should free this memory + ** by calling sqlite3DbFree(db, ). + */ + static int sqlite3LoadExtension( + sqlite3 db, /* Load the extension into this database connection */ + string zFile, /* Name of the shared library containing extension */ + string zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */ + ref string pzErrMsg /* Put error message here if not 0 */ + ) { + sqlite3_vfs pVfs = db.pVfs; + HANDLE handle; + dxInit xInit; //int (*xInit)(sqlite3*,char**,const sqlite3_api_routines); + StringBuilder zErrmsg = new StringBuilder(100); + //object aHandle; + const int nMsg = 300; + if (pzErrMsg != null) + pzErrMsg = null; + + + /* Ticket #1863. To avoid a creating security problems for older + ** applications that relink against newer versions of SQLite, the + ** ability to run load_extension is turned off by default. One + ** must call sqlite3_enable_load_extension() to turn on extension + ** loading. Otherwise you get the following error. + */ + if ((db.flags & SQLITE_LoadExtension) == 0) { + //if( pzErrMsg != null){ + pzErrMsg = sqlite3_mprintf("not authorized"); + //} + return SQLITE_ERROR; + } + + if (zProc == null || zProc == "") { + zProc = "sqlite3_extension_init"; + } + + handle = sqlite3OsDlOpen(pVfs, zFile); + if (handle == IntPtr.Zero) { + // if( pzErrMsg ){ + pzErrMsg = "";//*pzErrMsg = zErrmsg = sqlite3_malloc(nMsg); + //if( zErrmsg !=null){ + sqlite3_snprintf(nMsg, zErrmsg, + "unable to open shared library [%s]", zFile); + sqlite3OsDlError(pVfs, nMsg - 1, zErrmsg.ToString()); + return SQLITE_ERROR; + } + //xInit = (int()(sqlite3*,char**,const sqlite3_api_routines)) + // sqlite3OsDlSym(pVfs, handle, zProc); + xInit = (dxInit)sqlite3OsDlSym(pVfs, handle, ref zProc); + Debugger.Break(); // TODO -- + //if( xInit==0 ){ + // if( pzErrMsg ){ + // *pzErrMsg = zErrmsg = sqlite3_malloc(nMsg); + // if( zErrmsg ){ + // sqlite3_snprintf(nMsg, zErrmsg, + // "no entry point [%s] in shared library [%s]", zProc,zFile); + // sqlite3OsDlError(pVfs, nMsg-1, zErrmsg); + // } + // sqlite3OsDlClose(pVfs, handle); + // } + // return SQLITE_ERROR; + // }else if( xInit(db, ref zErrmsg, sqlite3Apis) ){ + //// if( pzErrMsg !=null){ + // pzErrMsg = sqlite3_mprintf("error during initialization: %s", zErrmsg); + // //} + // sqlite3DbFree(db,ref zErrmsg); + // sqlite3OsDlClose(pVfs, ref handle); + // return SQLITE_ERROR; + // } + + // /* Append the new shared library handle to the db.aExtension array. */ + // aHandle = sqlite3DbMallocZero(db, sizeof(handle)*db.nExtension+1); + // if( aHandle==null ){ + // return SQLITE_NOMEM; + // } + // if( db.nExtension>0 ){ + // memcpy(aHandle, db.aExtension, sizeof(handle)*(db.nExtension)); + // } + // sqlite3DbFree(db,ref db.aExtension); + // db.aExtension = aHandle; + + // db.aExtension[db.nExtension++] = handle; + return SQLITE_OK; + } - static public int sqlite3_load_extension( - sqlite3 db, /* Load the extension into this database connection */ - string zFile, /* Name of the shared library containing extension */ - string zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */ - ref string pzErrMsg /* Put error message here if not 0 */ - ) - { - int rc; - sqlite3_mutex_enter( db.mutex ); - rc = sqlite3LoadExtension( db, zFile, zProc, ref pzErrMsg ); - rc = sqlite3ApiExit( db, rc ); - sqlite3_mutex_leave( db.mutex ); - return rc; - } + static public int sqlite3_load_extension( + sqlite3 db, /* Load the extension into this database connection */ + string zFile, /* Name of the shared library containing extension */ + string zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */ + ref string pzErrMsg /* Put error message here if not 0 */ + ) { + int rc; + sqlite3_mutex_enter(db.mutex); + rc = sqlite3LoadExtension(db, zFile, zProc, ref pzErrMsg); + rc = sqlite3ApiExit(db, rc); + sqlite3_mutex_leave(db.mutex); + return rc; + } - /* - ** Call this routine when the database connection is closing in order - ** to clean up loaded extensions - */ - static void sqlite3CloseExtensions( sqlite3 db ) - { - int i; - Debug.Assert( sqlite3_mutex_held( db.mutex ) ); - for ( i = 0; i < db.nExtension; i++ ) - { - sqlite3OsDlClose( db.pVfs, (HANDLE)db.aExtension[i] ); - } - sqlite3DbFree( db, ref db.aExtension ); - } + /* + ** Call this routine when the database connection is closing in order + ** to clean up loaded extensions + */ + static void sqlite3CloseExtensions(sqlite3 db) { + int i; + Debug.Assert(sqlite3_mutex_held(db.mutex)); + for (i = 0; i < db.nExtension; i++) { + sqlite3OsDlClose(db.pVfs, (HANDLE)db.aExtension[i]); + } + sqlite3DbFree(db, ref db.aExtension); + } - /* - ** Enable or disable extension loading. Extension loading is disabled by - ** default so as not to open security holes in older applications. - */ - static public int sqlite3_enable_load_extension( sqlite3 db, int onoff ) - { - sqlite3_mutex_enter( db.mutex ); - if ( onoff != 0 ) - { - db.flags |= SQLITE_LoadExtension; - } - else - { - db.flags &= ~SQLITE_LoadExtension; - } - sqlite3_mutex_leave( db.mutex ); - return SQLITE_OK; - } + /* + ** Enable or disable extension loading. Extension loading is disabled by + ** default so as not to open security holes in older applications. + */ + static public int sqlite3_enable_load_extension(sqlite3 db, int onoff) { + sqlite3_mutex_enter(db.mutex); + if (onoff != 0) { + db.flags |= SQLITE_LoadExtension; + } else { + db.flags &= ~SQLITE_LoadExtension; + } + sqlite3_mutex_leave(db.mutex); + return SQLITE_OK; + } #endif //* SQLITE_OMIT_LOAD_EXTENSION */ - /* -** The auto-extension code added regardless of whether or not extension -** loading is supported. We need a dummy sqlite3Apis pointer for that -** code if regular extension loading is not available. This is that -** dummy pointer. -*/ + /* + ** The auto-extension code added regardless of whether or not extension + ** loading is supported. We need a dummy sqlite3Apis pointer for that + ** code if regular extension loading is not available. This is that + ** dummy pointer. + */ #if SQLITE_OMIT_LOAD_EXTENSION const sqlite3_api_routines sqlite3Apis = null; #endif - /* -** The following object holds the list of automatically loaded -** extensions. -** -** This list is shared across threads. The SQLITE_MUTEX_STATIC_MASTER -** mutex must be held while accessing this list. -*/ - //typedef struct sqlite3AutoExtList sqlite3AutoExtList; - public class sqlite3AutoExtList - { - public int nExt = 0; /* Number of entries in aExt[] */ - public dxInit[] aExt = null; /* Pointers to the extension init functions */ - public sqlite3AutoExtList( int nExt, dxInit[] aExt ) - { - this.nExt = nExt; - this.aExt = aExt; - } - } - static sqlite3AutoExtList sqlite3Autoext = new sqlite3AutoExtList( 0, null ); - /* The "wsdAutoext" macro will resolve to the autoextension - ** state vector. If writable static data is unsupported on the target, - ** we have to locate the state vector at run-time. In the more common - ** case where writable static data is supported, wsdStat can refer directly - ** to the "sqlite3Autoext" state vector declared above. + /* + ** The following object holds the list of automatically loaded + ** extensions. + ** + ** This list is shared across threads. The SQLITE_MUTEX_STATIC_MASTER + ** mutex must be held while accessing this list. */ + //typedef struct sqlite3AutoExtList sqlite3AutoExtList; + public class sqlite3AutoExtList { + public int nExt = 0; /* Number of entries in aExt[] */ + public dxInit[] aExt = null; /* Pointers to the extension init functions */ + public sqlite3AutoExtList(int nExt, dxInit[] aExt) { + this.nExt = nExt; + this.aExt = aExt; + } + } + static sqlite3AutoExtList sqlite3Autoext = new sqlite3AutoExtList(0, null); + /* The "wsdAutoext" macro will resolve to the autoextension + ** state vector. If writable static data is unsupported on the target, + ** we have to locate the state vector at run-time. In the more common + ** case where writable static data is supported, wsdStat can refer directly + ** to the "sqlite3Autoext" state vector declared above. + */ #if SQLITE_OMIT_WSD //# define wsdAutoextInit \ sqlite3AutoExtList *x = &GLOBAL(sqlite3AutoExtList,sqlite3Autoext) //# define wsdAutoext x[0] #else - //# define wsdAutoextInit - static void wsdAutoextInit() - { - } - //# define wsdAutoext sqlite3Autoext - static sqlite3AutoExtList wsdAutoext = sqlite3Autoext; + //# define wsdAutoextInit + static void wsdAutoextInit() { + } + //# define wsdAutoext sqlite3Autoext + static sqlite3AutoExtList wsdAutoext = sqlite3Autoext; #endif - /* -** Register a statically linked extension that is automatically -** loaded by every new database connection. -*/ - static int sqlite3_auto_extension( dxInit xInit ) - { - int rc = SQLITE_OK; + /* + ** Register a statically linked extension that is automatically + ** loaded by every new database connection. + */ + static int sqlite3_auto_extension(dxInit xInit) { + int rc = SQLITE_OK; #if !SQLITE_OMIT_AUTOINIT - rc = sqlite3_initialize(); - if ( rc != 0 ) - { - return rc; - } - else + rc = sqlite3_initialize(); + if (rc != 0) { + return rc; + } else #endif - { - int i; + { + int i; #if SQLITE_THREADSAFE - sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); + sqlite3_mutex mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); #else sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); #endif - wsdAutoextInit(); - sqlite3_mutex_enter( mutex ); - for ( i = 0; i < wsdAutoext.nExt; i++ ) - { - if ( wsdAutoext.aExt[i] == xInit ) - break; + wsdAutoextInit(); + sqlite3_mutex_enter(mutex); + for (i = 0; i < wsdAutoext.nExt; i++) { + if (wsdAutoext.aExt[i] == xInit) + break; + } + //if( i==wsdAutoext.nExt ){ + // int nByte = (wsdAutoext.nExt+1)*sizeof(wsdAutoext.aExt[0]); + // void **aNew; + // aNew = sqlite3_realloc(wsdAutoext.aExt, nByte); + // if( aNew==0 ){ + // rc = SQLITE_NOMEM; + // }else{ + Array.Resize(ref wsdAutoext.aExt, wsdAutoext.nExt + 1);// wsdAutoext.aExt = aNew; + wsdAutoext.aExt[wsdAutoext.nExt] = xInit; + wsdAutoext.nExt++; + //} + sqlite3_mutex_leave(mutex); + Debug.Assert((rc & 0xff) == rc); + return rc; + } } - //if( i==wsdAutoext.nExt ){ - // int nByte = (wsdAutoext.nExt+1)*sizeof(wsdAutoext.aExt[0]); - // void **aNew; - // aNew = sqlite3_realloc(wsdAutoext.aExt, nByte); - // if( aNew==0 ){ - // rc = SQLITE_NOMEM; - // }else{ - Array.Resize( ref wsdAutoext.aExt, wsdAutoext.nExt + 1 );// wsdAutoext.aExt = aNew; - wsdAutoext.aExt[wsdAutoext.nExt] = xInit; - wsdAutoext.nExt++; - //} - sqlite3_mutex_leave( mutex ); - Debug.Assert( ( rc & 0xff ) == rc ); - return rc; - } - } - /* - ** Reset the automatic extension loading mechanism. - */ - static void sqlite3_reset_auto_extension() - { + /* + ** Reset the automatic extension loading mechanism. + */ + static void sqlite3_reset_auto_extension() { #if !SQLITE_OMIT_AUTOINIT - if ( sqlite3_initialize() == SQLITE_OK ) + if (sqlite3_initialize() == SQLITE_OK) #endif - { + { #if SQLITE_THREADSAFE - sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); + sqlite3_mutex mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); #else sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); #endif - wsdAutoextInit(); - sqlite3_mutex_enter( mutex ); + wsdAutoextInit(); + sqlite3_mutex_enter(mutex); #if SQLITE_OMIT_WSD //sqlite3_free( ref wsdAutoext.aExt ); wsdAutoext.aExt = null; wsdAutoext.nExt = 0; #else - //sqlite3_free( ref sqlite3Autoext.aExt ); - sqlite3Autoext.aExt = null; - sqlite3Autoext.nExt = 0; + //sqlite3_free( ref sqlite3Autoext.aExt ); + sqlite3Autoext.aExt = null; + sqlite3Autoext.nExt = 0; #endif - sqlite3_mutex_leave( mutex ); - } - } - - /* - ** Load all automatic extensions. - ** - ** If anything goes wrong, set an error in the database connection. - */ - static void sqlite3AutoLoadExtensions( sqlite3 db ) - { - int i; - bool go = true; - dxInit xInit;//)(sqlite3*,char**,const sqlite3_api_routines); + sqlite3_mutex_leave(mutex); + } + } - wsdAutoextInit(); + /* + ** Load all automatic extensions. + ** + ** If anything goes wrong, set an error in the database connection. + */ + static void sqlite3AutoLoadExtensions(sqlite3 db) { + int i; + bool go = true; + dxInit xInit;//)(sqlite3*,char**,const sqlite3_api_routines); + + wsdAutoextInit(); #if SQLITE_OMIT_WSD if ( wsdAutoext.nExt == 0 ) #else - if ( sqlite3Autoext.nExt == 0 ) + if (sqlite3Autoext.nExt == 0) #endif - { - /* Common case: early out without every having to acquire a mutex */ - return; - } - for ( i = 0; go; i++ ) - { - string zErrmsg = ""; + { + /* Common case: early out without every having to acquire a mutex */ + return; + } + for (i = 0; go; i++) { + string zErrmsg = ""; #if SQLITE_THREADSAFE - sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); + sqlite3_mutex mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); #else sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); #endif - sqlite3_mutex_enter( mutex ); - if ( i >= wsdAutoext.nExt ) - { - xInit = null; - go = false; - } - else - { - xInit = (dxInit) - wsdAutoext.aExt[i]; - } - sqlite3_mutex_leave( mutex ); - zErrmsg = ""; - if ( xInit != null && xInit( db, ref zErrmsg, (sqlite3_api_routines)sqlite3Apis ) != 0 ) - { - sqlite3Error( db, SQLITE_ERROR, - "automatic extension loading failed: %s", zErrmsg ); - go = false; + sqlite3_mutex_enter(mutex); + if (i >= wsdAutoext.nExt) { + xInit = null; + go = false; + } else { + xInit = (dxInit) + wsdAutoext.aExt[i]; + } + sqlite3_mutex_leave(mutex); + zErrmsg = ""; + if (xInit != null && xInit(db, ref zErrmsg, (sqlite3_api_routines)sqlite3Apis) != 0) { + sqlite3Error(db, SQLITE_ERROR, + "automatic extension loading failed: %s", zErrmsg); + go = false; + } + sqlite3DbFree(db, ref zErrmsg); + } } - sqlite3DbFree( db, ref zErrmsg ); - } } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/main_c.cs b/Src/IronPython.SQLite/c#sqlite/main_c.cs index 81b995857..cc817d900 100644 --- a/Src/IronPython.SQLite/c#sqlite/main_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/main_c.cs @@ -2,49 +2,39 @@ using System.Diagnostics; using System.Text; -using sqlite_int64 = System.Int64; -using unsigned = System.Int32; - using i16 = System.Int16; -using u8 = System.Byte; -using u16 = System.UInt16; -using u32 = System.UInt32; -using u64 = System.UInt64; - -using Pgno = System.UInt32; +using sqlite_int64 = System.Int64; using sqlite3_int64 = System.Int64; +using u32 = System.UInt32; +using u8 = System.Byte; -namespace Community.CsharpSqlite -{ - using sqlite3_value = Sqlite3.Mem; - - public partial class Sqlite3 - { - /* - ** 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. - ** - ************************************************************************* - ** Main file for the SQLite library. The routines in this file - ** implement the programmer interface to the library. Routines in - ** other files are for internal use by SQLite and should not be - ** accessed by users of the library. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" -#if SQLITE_ENABLE_FTS3 +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** Main file for the SQLite library. The routines in this file + ** implement the programmer interface to the library. Routines in + ** other files are for internal use by SQLite and should not be + ** accessed by users of the library. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" +#if SQLITE_ENABLE_FTS3 //# include "fts3.h" #endif #if SQLITE_ENABLE_RTREE @@ -55,45 +45,41 @@ public partial class Sqlite3 #endif #if !SQLITE_AMALGAMATION - /* IMPLEMENTATION-OF: R-46656-45156 The sqlite3_version[] string constant -** contains the text of SQLITE_VERSION macro. -*/ - public static string sqlite3_version = SQLITE_VERSION; + /* IMPLEMENTATION-OF: R-46656-45156 The sqlite3_version[] string constant + ** contains the text of SQLITE_VERSION macro. + */ + public static string sqlite3_version = SQLITE_VERSION; #endif - /* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns -** a pointer to the to the sqlite3_version[] string constant. -*/ - public static string sqlite3_libversion() - { - return sqlite3_version; - } - - /* IMPLEMENTATION-OF: R-63124-39300 The sqlite3_sourceid() function returns a - ** pointer to a string constant whose value is the same as the - ** SQLITE_SOURCE_ID C preprocessor macro. + /* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns + ** a pointer to the to the sqlite3_version[] string constant. */ - public static string sqlite3_sourceid() - { - return SQLITE_SOURCE_ID; - } + public static string sqlite3_libversion() { + return sqlite3_version; + } - /* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function - ** returns an integer equal to SQLITE_VERSION_NUMBER. - */ - public static int sqlite3_libversion_number() - { - return SQLITE_VERSION_NUMBER; - } + /* IMPLEMENTATION-OF: R-63124-39300 The sqlite3_sourceid() function returns a + ** pointer to a string constant whose value is the same as the + ** SQLITE_SOURCE_ID C preprocessor macro. + */ + public static string sqlite3_sourceid() { + return SQLITE_SOURCE_ID; + } - /* IMPLEMENTATION-OF: R-54823-41343 The sqlite3_threadsafe() function returns - ** zero if and only if SQLite was compiled mutexing code omitted due to - ** the SQLITE_THREADSAFE compile-time option being set to 0. - */ - public static int sqlite3_threadsafe() - { - return SQLITE_THREADSAFE; - } + /* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function + ** returns an integer equal to SQLITE_VERSION_NUMBER. + */ + public static int sqlite3_libversion_number() { + return SQLITE_VERSION_NUMBER; + } + + /* IMPLEMENTATION-OF: R-54823-41343 The sqlite3_threadsafe() function returns + ** zero if and only if SQLite was compiled mutexing code omitted due to + ** the SQLITE_THREADSAFE compile-time option being set to 0. + */ + public static int sqlite3_threadsafe() { + return SQLITE_THREADSAFE; + } #if !SQLITE_OMIT_TRACE && SQLITE_ENABLE_IOTRACE /* @@ -106,62 +92,61 @@ public static int sqlite3_threadsafe() static void sqlite3IoTrace( string X, params object[] ap ) { } #endif - /* -** If the following global variable points to a string which is the -** name of a directory, then that directory will be used to store -** temporary files. -** -** See also the "PRAGMA temp_store_directory" SQL command. -*/ - static string sqlite3_temp_directory = "";//string sqlite3_temp_directory = 0; - - /* - ** Initialize SQLite. + /* + ** If the following global variable points to a string which is the + ** name of a directory, then that directory will be used to store + ** temporary files. ** - ** This routine must be called to initialize the memory allocation, - ** VFS, and mutex subsystems prior to doing any serious work with - ** SQLite. But as long as you do not compile with SQLITE_OMIT_AUTOINIT - ** this routine will be called automatically by key routines such as - ** sqlite3_open(). - ** - ** This routine is a no-op except on its very first call for the process, - ** or for the first call after a call to sqlite3_shutdown. - ** - ** The first thread to call this routine runs the initialization to - ** completion. If subsequent threads call this routine before the first - ** thread has finished the initialization process, then the subsequent - ** threads must block until the first thread finishes with the initialization. - ** - ** The first thread might call this routine recursively. Recursive - ** calls to this routine should not block, of course. Otherwise the - ** initialization process would never complete. - ** - ** Let X be the first thread to enter this routine. Let Y be some other - ** thread. Then while the initial invocation of this routine by X is - ** incomplete, it is required that: - ** - ** * Calls to this routine from Y must block until the outer-most - ** call by X completes. - ** - ** * Recursive calls to this routine from thread X return immediately - ** without blocking. + ** See also the "PRAGMA temp_store_directory" SQL command. */ - static public int sqlite3_initialize() - { - //-------------------------------------------------------------------- - // Under C#, Need to initialize some static variables - // - if ( sqlite3_version == null ) - sqlite3_version = SQLITE_VERSION; - if ( sqlite3OpcodeProperty == null ) - sqlite3OpcodeProperty = OPFLG_INITIALIZER; - if ( sqlite3GlobalConfig == null ) - sqlite3GlobalConfig = sqlite3Config; - //-------------------------------------------------------------------- - - - sqlite3_mutex pMaster; /* The main static mutex */ - int rc; /* Result code */ + static string sqlite3_temp_directory = "";//string sqlite3_temp_directory = 0; + + /* + ** Initialize SQLite. + ** + ** This routine must be called to initialize the memory allocation, + ** VFS, and mutex subsystems prior to doing any serious work with + ** SQLite. But as long as you do not compile with SQLITE_OMIT_AUTOINIT + ** this routine will be called automatically by key routines such as + ** sqlite3_open(). + ** + ** This routine is a no-op except on its very first call for the process, + ** or for the first call after a call to sqlite3_shutdown. + ** + ** The first thread to call this routine runs the initialization to + ** completion. If subsequent threads call this routine before the first + ** thread has finished the initialization process, then the subsequent + ** threads must block until the first thread finishes with the initialization. + ** + ** The first thread might call this routine recursively. Recursive + ** calls to this routine should not block, of course. Otherwise the + ** initialization process would never complete. + ** + ** Let X be the first thread to enter this routine. Let Y be some other + ** thread. Then while the initial invocation of this routine by X is + ** incomplete, it is required that: + ** + ** * Calls to this routine from Y must block until the outer-most + ** call by X completes. + ** + ** * Recursive calls to this routine from thread X return immediately + ** without blocking. + */ + static public int sqlite3_initialize() { + //-------------------------------------------------------------------- + // Under C#, Need to initialize some static variables + // + if (sqlite3_version == null) + sqlite3_version = SQLITE_VERSION; + if (sqlite3OpcodeProperty == null) + sqlite3OpcodeProperty = OPFLG_INITIALIZER; + if (sqlite3GlobalConfig == null) + sqlite3GlobalConfig = sqlite3Config; + //-------------------------------------------------------------------- + + + sqlite3_mutex pMaster; /* The main static mutex */ + int rc; /* Result code */ #if SQLITE_OMIT_WSD rc = sqlite3_wsd_init(4096, 24); @@ -169,405 +154,350 @@ static public int sqlite3_initialize() return rc; } #endif - /* If SQLite is already completely initialized, then this call -** to sqlite3_initialize() should be a no-op. But the initialization -** must be complete. So isInit must not be set until the very end -** of this routine. -*/ - if ( sqlite3GlobalConfig.isInit != 0 ) - return SQLITE_OK; - - /* Make sure the mutex subsystem is initialized. If unable to - ** initialize the mutex subsystem, return early with the error. - ** If the system is so sick that we are unable to allocate a mutex, - ** there is not much SQLite is going to be able to do. - ** - ** The mutex subsystem must take care of serializing its own - ** initialization. - */ - rc = sqlite3MutexInit(); - if ( rc != 0 ) - return rc; - - /* Initialize the malloc() system and the recursive pInitMutex mutex. - ** This operation is protected by the STATIC_MASTER mutex. Note that - ** MutexAlloc() is called for a static mutex prior to initializing the - ** malloc subsystem - this implies that the allocation of a static - ** mutex must not require support from the malloc subsystem. + /* If SQLite is already completely initialized, then this call + ** to sqlite3_initialize() should be a no-op. But the initialization + ** must be complete. So isInit must not be set until the very end + ** of this routine. */ - pMaster = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); - //sqlite3_mutex_enter( pMaster ); - lock ( pMaster ) - { - sqlite3GlobalConfig.isMutexInit = 1; - if ( sqlite3GlobalConfig.isMallocInit == 0 ) - { - rc = sqlite3MallocInit(); - } - if ( rc == SQLITE_OK ) - { - sqlite3GlobalConfig.isMallocInit = 1; - if ( sqlite3GlobalConfig.pInitMutex == null ) - { - sqlite3GlobalConfig.pInitMutex = - sqlite3MutexAlloc( SQLITE_MUTEX_RECURSIVE ); - if ( sqlite3GlobalConfig.bCoreMutex && sqlite3GlobalConfig.pInitMutex == null ) - { - rc = SQLITE_NOMEM; + if (sqlite3GlobalConfig.isInit != 0) + return SQLITE_OK; + + /* Make sure the mutex subsystem is initialized. If unable to + ** initialize the mutex subsystem, return early with the error. + ** If the system is so sick that we are unable to allocate a mutex, + ** there is not much SQLite is going to be able to do. + ** + ** The mutex subsystem must take care of serializing its own + ** initialization. + */ + rc = sqlite3MutexInit(); + if (rc != 0) + return rc; + + /* Initialize the malloc() system and the recursive pInitMutex mutex. + ** This operation is protected by the STATIC_MASTER mutex. Note that + ** MutexAlloc() is called for a static mutex prior to initializing the + ** malloc subsystem - this implies that the allocation of a static + ** mutex must not require support from the malloc subsystem. + */ + pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); + //sqlite3_mutex_enter( pMaster ); + lock (pMaster) { + sqlite3GlobalConfig.isMutexInit = 1; + if (sqlite3GlobalConfig.isMallocInit == 0) { + rc = sqlite3MallocInit(); + } + if (rc == SQLITE_OK) { + sqlite3GlobalConfig.isMallocInit = 1; + if (sqlite3GlobalConfig.pInitMutex == null) { + sqlite3GlobalConfig.pInitMutex = + sqlite3MutexAlloc(SQLITE_MUTEX_RECURSIVE); + if (sqlite3GlobalConfig.bCoreMutex && sqlite3GlobalConfig.pInitMutex == null) { + rc = SQLITE_NOMEM; + } + } + } + if (rc == SQLITE_OK) { + sqlite3GlobalConfig.nRefInitMutex++; + } } - } - } - if ( rc == SQLITE_OK ) - { - sqlite3GlobalConfig.nRefInitMutex++; - } - } - //sqlite3_mutex_leave( pMaster ); - - /* If rc is not SQLITE_OK at this point, then either the malloc - ** subsystem could not be initialized or the system failed to allocate - ** the pInitMutex mutex. Return an error in either case. */ - if ( rc != SQLITE_OK ) - { - return rc; - } + //sqlite3_mutex_leave( pMaster ); - /* Do the rest of the initialization under the recursive mutex so - ** that we will be able to handle recursive calls into - ** sqlite3_initialize(). The recursive calls normally come through - ** sqlite3_os_init() when it invokes sqlite3_vfs_register(), but other - ** recursive calls might also be possible. - ** - ** IMPLEMENTATION-OF: R-00140-37445 SQLite automatically serializes calls - ** to the xInit method, so the xInit method need not be threadsafe. - ** - ** The following mutex is what serializes access to the appdef pcache xInit - ** methods. The sqlite3_pcache_methods.xInit() all is embedded in the - ** call to sqlite3PcacheInitialize(). - */ - //sqlite3_mutex_enter( sqlite3GlobalConfig.pInitMutex ); - lock ( sqlite3GlobalConfig.pInitMutex ) - { - if ( sqlite3GlobalConfig.isInit == 0 && sqlite3GlobalConfig.inProgress == 0 ) - { - sqlite3GlobalConfig.inProgress = 1; + /* If rc is not SQLITE_OK at this point, then either the malloc + ** subsystem could not be initialized or the system failed to allocate + ** the pInitMutex mutex. Return an error in either case. */ + if (rc != SQLITE_OK) { + return rc; + } + + /* Do the rest of the initialization under the recursive mutex so + ** that we will be able to handle recursive calls into + ** sqlite3_initialize(). The recursive calls normally come through + ** sqlite3_os_init() when it invokes sqlite3_vfs_register(), but other + ** recursive calls might also be possible. + ** + ** IMPLEMENTATION-OF: R-00140-37445 SQLite automatically serializes calls + ** to the xInit method, so the xInit method need not be threadsafe. + ** + ** The following mutex is what serializes access to the appdef pcache xInit + ** methods. The sqlite3_pcache_methods.xInit() all is embedded in the + ** call to sqlite3PcacheInitialize(). + */ + //sqlite3_mutex_enter( sqlite3GlobalConfig.pInitMutex ); + lock (sqlite3GlobalConfig.pInitMutex) { + if (sqlite3GlobalConfig.isInit == 0 && sqlite3GlobalConfig.inProgress == 0) { + sqlite3GlobalConfig.inProgress = 1; #if SQLITE_OMIT_WSD FuncDefHash *pHash = GLOBAL(FuncDefHash, sqlite3GlobalFunctions); memset( pHash, 0, sizeof( sqlite3GlobalFunctions ) ); #else - sqlite3GlobalFunctions = new FuncDefHash(); - ////FuncDefHash pHash = sqlite3GlobalFunctions; + sqlite3GlobalFunctions = new FuncDefHash(); + ////FuncDefHash pHash = sqlite3GlobalFunctions; #endif - sqlite3RegisterGlobalFunctions(); - if ( sqlite3GlobalConfig.isPCacheInit == 0 ) - { - rc = sqlite3PcacheInitialize(); - } - if ( rc == SQLITE_OK ) - { - sqlite3GlobalConfig.isPCacheInit = 1; - rc = sqlite3_os_init(); - } - if ( rc == SQLITE_OK ) - { - sqlite3PCacheBufferSetup( sqlite3GlobalConfig.pPage, - sqlite3GlobalConfig.szPage, sqlite3GlobalConfig.nPage ); - sqlite3GlobalConfig.isInit = 1; - } - sqlite3GlobalConfig.inProgress = 0; - } - } - //sqlite3_mutex_leave( sqlite3GlobalConfig.pInitMutex ); - - /* Go back under the static mutex and clean up the recursive - ** mutex to prevent a resource leak. - */ - //sqlite3_mutex_enter( pMaster ); - lock ( pMaster ) - { - sqlite3GlobalConfig.nRefInitMutex--; - if ( sqlite3GlobalConfig.nRefInitMutex <= 0 ) - { - Debug.Assert( sqlite3GlobalConfig.nRefInitMutex == 0 ); - //sqlite3_mutex_free( ref sqlite3GlobalConfig.pInitMutex ); - sqlite3GlobalConfig.pInitMutex = null; - } - } - //sqlite3_mutex_leave( pMaster ); + sqlite3RegisterGlobalFunctions(); + if (sqlite3GlobalConfig.isPCacheInit == 0) { + rc = sqlite3PcacheInitialize(); + } + if (rc == SQLITE_OK) { + sqlite3GlobalConfig.isPCacheInit = 1; + rc = sqlite3_os_init(); + } + if (rc == SQLITE_OK) { + sqlite3PCacheBufferSetup(sqlite3GlobalConfig.pPage, + sqlite3GlobalConfig.szPage, sqlite3GlobalConfig.nPage); + sqlite3GlobalConfig.isInit = 1; + } + sqlite3GlobalConfig.inProgress = 0; + } + } + //sqlite3_mutex_leave( sqlite3GlobalConfig.pInitMutex ); + + /* Go back under the static mutex and clean up the recursive + ** mutex to prevent a resource leak. + */ + //sqlite3_mutex_enter( pMaster ); + lock (pMaster) { + sqlite3GlobalConfig.nRefInitMutex--; + if (sqlite3GlobalConfig.nRefInitMutex <= 0) { + Debug.Assert(sqlite3GlobalConfig.nRefInitMutex == 0); + //sqlite3_mutex_free( ref sqlite3GlobalConfig.pInitMutex ); + sqlite3GlobalConfig.pInitMutex = null; + } + } + //sqlite3_mutex_leave( pMaster ); - /* The following is just a sanity check to make sure SQLite has - ** been compiled correctly. It is important to run this code, but - ** we don't want to run it too often and soak up CPU cycles for no - ** reason. So we run it once during initialization. - */ + /* The following is just a sanity check to make sure SQLite has + ** been compiled correctly. It is important to run this code, but + ** we don't want to run it too often and soak up CPU cycles for no + ** reason. So we run it once during initialization. + */ #if !NDEBUG #if !SQLITE_OMIT_FLOATING_POINT - /* This section of code's only "output" is via Debug.Assert() statements. */ - if ( rc == SQLITE_OK ) - { - //u64 x = ( ( (u64)1 ) << 63 ) - 1; - //double y; - //Debug.Assert( sizeof( u64 ) == 8 ); - //Debug.Assert( sizeof( u64 ) == sizeof( double ) ); - //memcpy( &y, x, 8 ); - //Debug.Assert( sqlite3IsNaN( y ) ); - } + /* This section of code's only "output" is via Debug.Assert() statements. */ + if (rc == SQLITE_OK) { + //u64 x = ( ( (u64)1 ) << 63 ) - 1; + //double y; + //Debug.Assert( sizeof( u64 ) == 8 ); + //Debug.Assert( sizeof( u64 ) == sizeof( double ) ); + //memcpy( &y, x, 8 ); + //Debug.Assert( sqlite3IsNaN( y ) ); + } #endif #endif - return rc; - } - - /* - ** Undo the effects of sqlite3_initialize(). Must not be called while - ** there are outstanding database connections or memory allocations or - ** while any part of SQLite is otherwise in use in any thread. This - ** routine is not threadsafe. But it is safe to invoke this routine - ** on when SQLite is already shut down. If SQLite is already shut down - ** when this routine is invoked, then this routine is a harmless no-op. - */ - public static int sqlite3_shutdown() - { - if ( sqlite3GlobalConfig.isInit != 0 ) - { - sqlite3_os_end(); - sqlite3_reset_auto_extension(); - sqlite3GlobalConfig.isInit = 0; - } - if ( sqlite3GlobalConfig.isPCacheInit != 0 ) - { - sqlite3PcacheShutdown(); - sqlite3GlobalConfig.isPCacheInit = 0; - } - if ( sqlite3GlobalConfig.isMallocInit != 0 ) - { - sqlite3MallocEnd(); - sqlite3GlobalConfig.isMallocInit = 0; - } - if ( sqlite3GlobalConfig.isMutexInit != 0 ) - { - sqlite3MutexEnd(); - sqlite3GlobalConfig.isMutexInit = 0; - } - return SQLITE_OK; - } - - /* - ** This API allows applications to modify the global configuration of - ** the SQLite library at run-time. - ** - ** This routine should only be called when there are no outstanding - ** database connections or memory allocations. This routine is not - ** threadsafe. Failure to heed these warnings can lead to unpredictable - ** behavior. - */ - // Overloads for ap assignments - static public int sqlite3_config( int op, sqlite3_pcache_methods ap ) - { // va_list ap; - int rc = SQLITE_OK; - switch ( op ) - { - case SQLITE_CONFIG_PCACHE: - { - /* Specify an alternative malloc implementation */ - sqlite3GlobalConfig.pcache = ap; //sqlite3GlobalConfig.pcache = (sqlite3_pcache_methods)va_arg(ap, "sqlite3_pcache_methods"); - break; - } - } - return rc; - } - - static public int sqlite3_config(int op, ref sqlite3_pcache_methods ap) - { // va_list ap; - int rc = SQLITE_OK; - switch ( op ) - { - case SQLITE_CONFIG_GETPCACHE: - { - if ( sqlite3GlobalConfig.pcache.xInit == null ) - { - sqlite3PCacheSetDefault(); - } - ap = sqlite3GlobalConfig.pcache;//va_arg(ap, sqlite3_pcache_methods) = sqlite3GlobalConfig.pcache; - break; - } - } - return rc; - } - - static public int sqlite3_config(int op, sqlite3_mem_methods ap) - { // va_list ap; - int rc = SQLITE_OK; - switch ( op ) - { - case SQLITE_CONFIG_MALLOC: - { - /* Specify an alternative malloc implementation */ - sqlite3GlobalConfig.m = ap;// (sqlite3_mem_methods)va_arg( ap, "sqlite3_mem_methods" ); - break; - } - } - return rc; - } - - static public int sqlite3_config(int op, ref sqlite3_mem_methods ap) - { // va_list ap; - int rc = SQLITE_OK; - switch ( op ) - { - case SQLITE_CONFIG_GETMALLOC: - { - /* Retrieve the current malloc() implementation */ - //if ( sqlite3GlobalConfig.m.xMalloc == null ) sqlite3MemSetDefault(); - ap = sqlite3GlobalConfig.m;//va_arg(ap, sqlite3_mem_methods) = sqlite3GlobalConfig.m; - break; - } - } - return rc; - } - -#if SQLITE_THREADSAFE // && SQLITE_THREADSAFE>0 - static public int sqlite3_config( int op, sqlite3_mutex_methods ap ) - { - // va_list ap; - int rc = SQLITE_OK; - switch ( op ) - { - case SQLITE_CONFIG_MUTEX: - { - /* Specify an alternative mutex implementation */ - sqlite3GlobalConfig.mutex = ap;// (sqlite3_mutex_methods)va_arg( ap, "sqlite3_mutex_methods" ); - break; - } - } - return rc; - } - - static public int sqlite3_config( int op, ref sqlite3_mutex_methods ap ) - { - // va_list ap; - int rc = SQLITE_OK; - switch ( op ) - { - case SQLITE_CONFIG_GETMUTEX: - { - /* Retrieve the current mutex implementation */ - ap = sqlite3GlobalConfig.mutex;// *va_arg(ap, sqlite3_mutex_methods) = sqlite3GlobalConfig.mutex; - break; - } - } - return rc; - } -#endif + return rc; + } - static public int sqlite3_config(int op, params object[] ap) - { - // va_list ap; - int rc = SQLITE_OK; - - /* sqlite3_config() shall return SQLITE_MISUSE if it is invoked while - ** the SQLite library is in use. */ - if ( sqlite3GlobalConfig.isInit != 0 ) - return SQLITE_MISUSE_BKPT(); - - lock ( lock_va_list ) - { - va_start( ap, null ); - switch ( op ) - { - - /* Mutex configuration options are only available in a threadsafe - ** compile. - */ -#if SQLITE_THREADSAFE - case SQLITE_CONFIG_SINGLETHREAD: - { - /* Disable all mutexing */ - sqlite3GlobalConfig.bCoreMutex = false; - sqlite3GlobalConfig.bFullMutex = false; - break; - } - case SQLITE_CONFIG_MULTITHREAD: - { - /* Disable mutexing of database connections */ - /* Enable mutexing of core data structures */ - sqlite3GlobalConfig.bCoreMutex = true; - sqlite3GlobalConfig.bFullMutex = false; - break; - } - case SQLITE_CONFIG_SERIALIZED: - { - /* Enable all mutexing */ - sqlite3GlobalConfig.bCoreMutex = true; - sqlite3GlobalConfig.bFullMutex = true; - break; + /* + ** Undo the effects of sqlite3_initialize(). Must not be called while + ** there are outstanding database connections or memory allocations or + ** while any part of SQLite is otherwise in use in any thread. This + ** routine is not threadsafe. But it is safe to invoke this routine + ** on when SQLite is already shut down. If SQLite is already shut down + ** when this routine is invoked, then this routine is a harmless no-op. + */ + public static int sqlite3_shutdown() { + if (sqlite3GlobalConfig.isInit != 0) { + sqlite3_os_end(); + sqlite3_reset_auto_extension(); + sqlite3GlobalConfig.isInit = 0; } - case SQLITE_CONFIG_MUTEX: - { - /* Specify an alternative mutex implementation */ - sqlite3GlobalConfig.mutex = va_arg( ap, (sqlite3_mutex_methods)null ); - break; + if (sqlite3GlobalConfig.isPCacheInit != 0) { + sqlite3PcacheShutdown(); + sqlite3GlobalConfig.isPCacheInit = 0; } - case SQLITE_CONFIG_GETMUTEX: - { - /* Retrieve the current mutex implementation */ - // TODO -- *va_arg(ap, sqlite3_mutex_methods) = sqlite3GlobalConfig.mutex; - break; + if (sqlite3GlobalConfig.isMallocInit != 0) { + sqlite3MallocEnd(); + sqlite3GlobalConfig.isMallocInit = 0; } -#endif - case SQLITE_CONFIG_MALLOC: - { - /* Specify an alternative malloc implementation */ - // TODO -- sqlite3GlobalConfig.m = va_arg(ap, (sqlite3_mem_methods)null); - break; + if (sqlite3GlobalConfig.isMutexInit != 0) { + sqlite3MutexEnd(); + sqlite3GlobalConfig.isMutexInit = 0; } - case SQLITE_CONFIG_GETMALLOC: - { - /* Retrieve the current malloc() implementation */ - //if ( sqlite3GlobalConfig.m.xMalloc == null ) sqlite3MemSetDefault(); - // TODO --//va_arg(ap, sqlite3_mem_methods) = sqlite3GlobalConfig.m; - break; + return SQLITE_OK; + } + + /* + ** This API allows applications to modify the global configuration of + ** the SQLite library at run-time. + ** + ** This routine should only be called when there are no outstanding + ** database connections or memory allocations. This routine is not + ** threadsafe. Failure to heed these warnings can lead to unpredictable + ** behavior. + */ + // Overloads for ap assignments + static public int sqlite3_config(int op, sqlite3_pcache_methods ap) { // va_list ap; + int rc = SQLITE_OK; + switch (op) { + case SQLITE_CONFIG_PCACHE: { + /* Specify an alternative malloc implementation */ + sqlite3GlobalConfig.pcache = ap; //sqlite3GlobalConfig.pcache = (sqlite3_pcache_methods)va_arg(ap, "sqlite3_pcache_methods"); + break; + } } - case SQLITE_CONFIG_MEMSTATUS: - { - /* Enable or disable the malloc status collection */ - sqlite3GlobalConfig.bMemstat = va_arg( ap, ( Int32 ) 0 ) != 0; - break; + return rc; + } + + static public int sqlite3_config(int op, ref sqlite3_pcache_methods ap) { // va_list ap; + int rc = SQLITE_OK; + switch (op) { + case SQLITE_CONFIG_GETPCACHE: { + if (sqlite3GlobalConfig.pcache.xInit == null) { + sqlite3PCacheSetDefault(); + } + ap = sqlite3GlobalConfig.pcache;//va_arg(ap, sqlite3_pcache_methods) = sqlite3GlobalConfig.pcache; + break; + } } - case SQLITE_CONFIG_SCRATCH: - { - /* Designate a buffer for scratch memory space */ - sqlite3GlobalConfig.pScratch = va_arg( ap, (Byte[][])null ); - sqlite3GlobalConfig.szScratch = va_arg( ap, (Int32)0 ); - sqlite3GlobalConfig.nScratch = va_arg( ap, ( Int32 ) 0 ); - break; + return rc; + } + + static public int sqlite3_config(int op, sqlite3_mem_methods ap) { // va_list ap; + int rc = SQLITE_OK; + switch (op) { + case SQLITE_CONFIG_MALLOC: { + /* Specify an alternative malloc implementation */ + sqlite3GlobalConfig.m = ap;// (sqlite3_mem_methods)va_arg( ap, "sqlite3_mem_methods" ); + break; + } } + return rc; + } - case SQLITE_CONFIG_PAGECACHE: - { - /* Designate a buffer for page cache memory space */ - sqlite3GlobalConfig.pPage = va_arg( ap, (MemPage) null ); - sqlite3GlobalConfig.szPage = va_arg( ap, ( Int32 ) 0 ); - sqlite3GlobalConfig.nPage = va_arg( ap, ( Int32 ) 0 ); - break; + static public int sqlite3_config(int op, ref sqlite3_mem_methods ap) { // va_list ap; + int rc = SQLITE_OK; + switch (op) { + case SQLITE_CONFIG_GETMALLOC: { + /* Retrieve the current malloc() implementation */ + //if ( sqlite3GlobalConfig.m.xMalloc == null ) sqlite3MemSetDefault(); + ap = sqlite3GlobalConfig.m;//va_arg(ap, sqlite3_mem_methods) = sqlite3GlobalConfig.m; + break; + } } + return rc; + } - case SQLITE_CONFIG_PCACHE: - { - /* Specify an alternative page cache implementation */ - // TODO --sqlite3GlobalConfig.pcache = (sqlite3_pcache_methods)va_arg(ap, "sqlite3_pcache_methods"); - break; +#if SQLITE_THREADSAFE // && SQLITE_THREADSAFE>0 + static public int sqlite3_config(int op, sqlite3_mutex_methods ap) { + // va_list ap; + int rc = SQLITE_OK; + switch (op) { + case SQLITE_CONFIG_MUTEX: { + /* Specify an alternative mutex implementation */ + sqlite3GlobalConfig.mutex = ap;// (sqlite3_mutex_methods)va_arg( ap, "sqlite3_mutex_methods" ); + break; + } } + return rc; + } - case SQLITE_CONFIG_GETPCACHE: - { - if ( sqlite3GlobalConfig.pcache.xInit == null ) - { - sqlite3PCacheSetDefault(); - } - // TODO -- *va_arg(ap, sqlite3_pcache_methods) = sqlite3GlobalConfig.pcache; - break; + static public int sqlite3_config(int op, ref sqlite3_mutex_methods ap) { + // va_list ap; + int rc = SQLITE_OK; + switch (op) { + case SQLITE_CONFIG_GETMUTEX: { + /* Retrieve the current mutex implementation */ + ap = sqlite3GlobalConfig.mutex;// *va_arg(ap, sqlite3_mutex_methods) = sqlite3GlobalConfig.mutex; + break; + } } + return rc; + } +#endif + + static public int sqlite3_config(int op, params object[] ap) { + // va_list ap; + int rc = SQLITE_OK; + + /* sqlite3_config() shall return SQLITE_MISUSE if it is invoked while + ** the SQLite library is in use. */ + if (sqlite3GlobalConfig.isInit != 0) + return SQLITE_MISUSE_BKPT(); + + lock (lock_va_list) { + va_start(ap, null); + switch (op) { + + /* Mutex configuration options are only available in a threadsafe + ** compile. + */ +#if SQLITE_THREADSAFE + case SQLITE_CONFIG_SINGLETHREAD: { + /* Disable all mutexing */ + sqlite3GlobalConfig.bCoreMutex = false; + sqlite3GlobalConfig.bFullMutex = false; + break; + } + case SQLITE_CONFIG_MULTITHREAD: { + /* Disable mutexing of database connections */ + /* Enable mutexing of core data structures */ + sqlite3GlobalConfig.bCoreMutex = true; + sqlite3GlobalConfig.bFullMutex = false; + break; + } + case SQLITE_CONFIG_SERIALIZED: { + /* Enable all mutexing */ + sqlite3GlobalConfig.bCoreMutex = true; + sqlite3GlobalConfig.bFullMutex = true; + break; + } + case SQLITE_CONFIG_MUTEX: { + /* Specify an alternative mutex implementation */ + sqlite3GlobalConfig.mutex = va_arg(ap, (sqlite3_mutex_methods)null); + break; + } + case SQLITE_CONFIG_GETMUTEX: { + /* Retrieve the current mutex implementation */ + // TODO -- *va_arg(ap, sqlite3_mutex_methods) = sqlite3GlobalConfig.mutex; + break; + } +#endif + case SQLITE_CONFIG_MALLOC: { + /* Specify an alternative malloc implementation */ + // TODO -- sqlite3GlobalConfig.m = va_arg(ap, (sqlite3_mem_methods)null); + break; + } + case SQLITE_CONFIG_GETMALLOC: { + /* Retrieve the current malloc() implementation */ + //if ( sqlite3GlobalConfig.m.xMalloc == null ) sqlite3MemSetDefault(); + // TODO --//va_arg(ap, sqlite3_mem_methods) = sqlite3GlobalConfig.m; + break; + } + case SQLITE_CONFIG_MEMSTATUS: { + /* Enable or disable the malloc status collection */ + sqlite3GlobalConfig.bMemstat = va_arg(ap, (Int32)0) != 0; + break; + } + case SQLITE_CONFIG_SCRATCH: { + /* Designate a buffer for scratch memory space */ + sqlite3GlobalConfig.pScratch = va_arg(ap, (Byte[][])null); + sqlite3GlobalConfig.szScratch = va_arg(ap, (Int32)0); + sqlite3GlobalConfig.nScratch = va_arg(ap, (Int32)0); + break; + } + + case SQLITE_CONFIG_PAGECACHE: { + /* Designate a buffer for page cache memory space */ + sqlite3GlobalConfig.pPage = va_arg(ap, (MemPage)null); + sqlite3GlobalConfig.szPage = va_arg(ap, (Int32)0); + sqlite3GlobalConfig.nPage = va_arg(ap, (Int32)0); + break; + } + + case SQLITE_CONFIG_PCACHE: { + /* Specify an alternative page cache implementation */ + // TODO --sqlite3GlobalConfig.pcache = (sqlite3_pcache_methods)va_arg(ap, "sqlite3_pcache_methods"); + break; + } + + case SQLITE_CONFIG_GETPCACHE: { + if (sqlite3GlobalConfig.pcache.xInit == null) { + sqlite3PCacheSetDefault(); + } + // TODO -- *va_arg(ap, sqlite3_pcache_methods) = sqlite3GlobalConfig.pcache; + break; + } #if SQLITE_ENABLE_MEMSYS3 || SQLITE_ENABLE_MEMSYS5 case SQLITE_CONFIG_HEAP: { @@ -606,530 +536,469 @@ static public int sqlite3_config(int op, params object[] ap) } #endif - case SQLITE_CONFIG_LOOKASIDE: - { - sqlite3GlobalConfig.szLookaside = va_arg( ap, ( Int32 ) 0 ); - sqlite3GlobalConfig.nLookaside = va_arg( ap, ( Int32 ) 0 ); - break; - } - - /* Record a pointer to the logger funcction and its first argument. - ** The default is NULL. Logging is disabled if the function pointer is - ** NULL. - */ - case SQLITE_CONFIG_LOG: - { - /* MSVC is picky about pulling func ptrs from va lists. - ** http://support.microsoft.com/kb/47961 - ** sqlite3GlobalConfig.xLog = va_arg(ap, void()(void*,int,const char)); - */ - //typedef void(*LOGFUNC_t)(void*,int,const char); - sqlite3GlobalConfig.xLog = va_arg( ap, (dxLog)null );//"LOGFUNC_t" ); - sqlite3GlobalConfig.pLogArg = va_arg( ap, (Object)null ); - break; - } - case SQLITE_CONFIG_URI: { - sqlite3GlobalConfig.bOpenUri = va_arg( ap, (Boolean)true ); - break; - } - default: - { - rc = SQLITE_ERROR; - break; + case SQLITE_CONFIG_LOOKASIDE: { + sqlite3GlobalConfig.szLookaside = va_arg(ap, (Int32)0); + sqlite3GlobalConfig.nLookaside = va_arg(ap, (Int32)0); + break; + } + + /* Record a pointer to the logger funcction and its first argument. + ** The default is NULL. Logging is disabled if the function pointer is + ** NULL. + */ + case SQLITE_CONFIG_LOG: { + /* MSVC is picky about pulling func ptrs from va lists. + ** http://support.microsoft.com/kb/47961 + ** sqlite3GlobalConfig.xLog = va_arg(ap, void()(void*,int,const char)); + */ + //typedef void(*LOGFUNC_t)(void*,int,const char); + sqlite3GlobalConfig.xLog = va_arg(ap, (dxLog)null);//"LOGFUNC_t" ); + sqlite3GlobalConfig.pLogArg = va_arg(ap, (Object)null); + break; + } + case SQLITE_CONFIG_URI: { + sqlite3GlobalConfig.bOpenUri = va_arg(ap, (Boolean)true); + break; + } + default: { + rc = SQLITE_ERROR; + break; + } + } + va_end(ref ap); } + return rc; } - va_end( ref ap ); - } - return rc; - } - /* - ** Set up the lookaside buffers for a database connection. - ** Return SQLITE_OK on success. - ** If lookaside is already active, return SQLITE_BUSY. - ** - ** The sz parameter is the number of bytes in each lookaside slot. - ** The cnt parameter is the number of slots. If pStart is NULL the - ** space for the lookaside memory is obtained from sqlite3_malloc(). - ** If pStart is not NULL then it is sz*cnt bytes of memory to use for - ** the lookaside memory. - */ - static int setupLookaside( sqlite3 db, byte[] pBuf, int sz, int cnt ) - { - //void* pStart; - //if ( db.lookaside.nOut ) - //{ - // return SQLITE_BUSY; - //} - ///* Free any existing lookaside buffer for this handle before - //** allocating a new one so we don't have to have space for - //** both at the same time. - //*/ - //if ( db.lookaside.bMalloced ) - //{ - // //sqlite3_free( db.lookaside.pStart ); - //} - ///* The size of a lookaside slot needs to be larger than a pointer - //** to be useful. - //*/ - //if ( sz <= (int)sizeof( LookasideSlot* ) ) sz = 0; - //if ( cnt < 0 ) cnt = 0; - //if ( sz == 0 || cnt == 0 ) - //{ - // sz = 0; - // pStart = 0; - //} - //else if ( pBuf == 0 ) - //{ - // sz = ROUNDDOWN8(sz); /* IMP: R-33038-09382 */ - // sqlite3BeginBenignMalloc(); - // pStart = sqlite3Malloc( sz*cnt ); /* IMP: R-61949-35727 */ - // sqlite3EndBenignMalloc(); - //}else{ - // sz = ROUNDDOWN8(sz); /* IMP: R-33038-09382 */ - // pStart = pBuf; - //} - //db.lookaside.pStart = pStart; - //db.lookaside.pFree = 0; - //db.lookaside.sz = (u16)sz; - //if ( pStart ) - //{ - // int i; - // LookasideSlot* p; - // Debug.Assert( sz > sizeof( LookasideSlot* ) ); - // p = (LookasideSlot)pStart; - // for ( i = cnt - 1 ; i >= 0 ; i-- ) - // { - // p.pNext = db.lookaside.pFree; - // db.lookaside.pFree = p; - // p = (LookasideSlot)&( (u8)p )[sz]; - // } - // db.lookaside.pEnd = p; - // db.lookaside.bEnabled = 1; - // db.lookaside.bMalloced = pBuf == 0 ? 1 : 0; - //} - //else - //{ - // db.lookaside.pEnd = 0; - // db.lookaside.bEnabled = 0; - // db.lookaside.bMalloced = 0; - //} - return SQLITE_OK; - } - - /* - ** Return the mutex associated with a database connection. - */ - static sqlite3_mutex sqlite3_db_mutex( sqlite3 db ) - { - return db.mutex; - } + /* + ** Set up the lookaside buffers for a database connection. + ** Return SQLITE_OK on success. + ** If lookaside is already active, return SQLITE_BUSY. + ** + ** The sz parameter is the number of bytes in each lookaside slot. + ** The cnt parameter is the number of slots. If pStart is NULL the + ** space for the lookaside memory is obtained from sqlite3_malloc(). + ** If pStart is not NULL then it is sz*cnt bytes of memory to use for + ** the lookaside memory. + */ + static int setupLookaside(sqlite3 db, byte[] pBuf, int sz, int cnt) { + //void* pStart; + //if ( db.lookaside.nOut ) + //{ + // return SQLITE_BUSY; + //} + ///* Free any existing lookaside buffer for this handle before + //** allocating a new one so we don't have to have space for + //** both at the same time. + //*/ + //if ( db.lookaside.bMalloced ) + //{ + // //sqlite3_free( db.lookaside.pStart ); + //} + ///* The size of a lookaside slot needs to be larger than a pointer + //** to be useful. + //*/ + //if ( sz <= (int)sizeof( LookasideSlot* ) ) sz = 0; + //if ( cnt < 0 ) cnt = 0; + //if ( sz == 0 || cnt == 0 ) + //{ + // sz = 0; + // pStart = 0; + //} + //else if ( pBuf == 0 ) + //{ + // sz = ROUNDDOWN8(sz); /* IMP: R-33038-09382 */ + // sqlite3BeginBenignMalloc(); + // pStart = sqlite3Malloc( sz*cnt ); /* IMP: R-61949-35727 */ + // sqlite3EndBenignMalloc(); + //}else{ + // sz = ROUNDDOWN8(sz); /* IMP: R-33038-09382 */ + // pStart = pBuf; + //} + //db.lookaside.pStart = pStart; + //db.lookaside.pFree = 0; + //db.lookaside.sz = (u16)sz; + //if ( pStart ) + //{ + // int i; + // LookasideSlot* p; + // Debug.Assert( sz > sizeof( LookasideSlot* ) ); + // p = (LookasideSlot)pStart; + // for ( i = cnt - 1 ; i >= 0 ; i-- ) + // { + // p.pNext = db.lookaside.pFree; + // db.lookaside.pFree = p; + // p = (LookasideSlot)&( (u8)p )[sz]; + // } + // db.lookaside.pEnd = p; + // db.lookaside.bEnabled = 1; + // db.lookaside.bMalloced = pBuf == 0 ? 1 : 0; + //} + //else + //{ + // db.lookaside.pEnd = 0; + // db.lookaside.bEnabled = 0; + // db.lookaside.bMalloced = 0; + //} + return SQLITE_OK; + } - public class _aFlagOp - { - public int op; /* The opcode */ - public u32 mask; /* Mask of the bit in sqlite3.flags to set/clear */ + /* + ** Return the mutex associated with a database connection. + */ + static sqlite3_mutex sqlite3_db_mutex(sqlite3 db) { + return db.mutex; + } - public _aFlagOp( int op, u32 mask ) - { - this.op = op; - this.mask = mask; - } - } + public class _aFlagOp { + public int op; /* The opcode */ + public u32 mask; /* Mask of the bit in sqlite3.flags to set/clear */ - /* - ** Configuration settings for an individual database connection - */ - static int sqlite3_db_config( sqlite3 db, int op, params object[] ap ) - { - int rc; - //va_list ap; - lock ( lock_va_list ) - { - va_start( ap, "" ); - switch ( op ) - { - case SQLITE_DBCONFIG_LOOKASIDE: - { - byte[] pBuf = va_arg( ap, (byte[])null ); /* IMP: R-26835-10964 */ - int sz = va_arg( ap, (Int32)0 ); /* IMP: R-47871-25994 */ - int cnt = va_arg( ap, ( Int32 ) 0 ); /* IMP: R-04460-53386 */ - rc = setupLookaside( db, pBuf, sz, cnt ); - break; + public _aFlagOp(int op, u32 mask) { + this.op = op; + this.mask = mask; } - default: - { - _aFlagOp[] aFlagOp = new _aFlagOp[]{ + } + + /* + ** Configuration settings for an individual database connection + */ + static int sqlite3_db_config(sqlite3 db, int op, params object[] ap) { + int rc; + //va_list ap; + lock (lock_va_list) { + va_start(ap, ""); + switch (op) { + case SQLITE_DBCONFIG_LOOKASIDE: { + byte[] pBuf = va_arg(ap, (byte[])null); /* IMP: R-26835-10964 */ + int sz = va_arg(ap, (Int32)0); /* IMP: R-47871-25994 */ + int cnt = va_arg(ap, (Int32)0); /* IMP: R-04460-53386 */ + rc = setupLookaside(db, pBuf, sz, cnt); + break; + } + default: { + _aFlagOp[] aFlagOp = new _aFlagOp[]{ new _aFlagOp( SQLITE_DBCONFIG_ENABLE_FKEY, SQLITE_ForeignKeys ), new _aFlagOp( SQLITE_DBCONFIG_ENABLE_TRIGGER, SQLITE_EnableTrigger ), }; - uint i; - - rc = SQLITE_ERROR; /* IMP: R-42790-23372 */ - for ( i = 0; i < ArraySize( aFlagOp ); i++ ) - { - if ( aFlagOp[i].op == op ) - { - int onoff = va_arg( ap, ( Int32 ) 0 ); - int pRes = va_arg( ap, (Int32)0 ); - int oldFlags = db.flags; - if ( onoff > 0 ) - { - db.flags = (int)( (u32)db.flags | aFlagOp[i].mask ); - } - else if ( onoff == 0 ) - { - db.flags = (int)( db.flags & ~aFlagOp[i].mask ); - } - if ( oldFlags != db.flags ) - { - sqlite3ExpirePreparedStatements( db ); - } - if ( pRes != 0 ) - { - pRes = ( db.flags & aFlagOp[i].mask ) != 0 ? 1 : 0; - } - rc = SQLITE_OK; - break; + uint i; + + rc = SQLITE_ERROR; /* IMP: R-42790-23372 */ + for (i = 0; i < ArraySize(aFlagOp); i++) { + if (aFlagOp[i].op == op) { + int onoff = va_arg(ap, (Int32)0); + int pRes = va_arg(ap, (Int32)0); + int oldFlags = db.flags; + if (onoff > 0) { + db.flags = (int)((u32)db.flags | aFlagOp[i].mask); + } else if (onoff == 0) { + db.flags = (int)(db.flags & ~aFlagOp[i].mask); + } + if (oldFlags != db.flags) { + sqlite3ExpirePreparedStatements(db); + } + if (pRes != 0) { + pRes = (db.flags & aFlagOp[i].mask) != 0 ? 1 : 0; + } + rc = SQLITE_OK; + break; + } + } + break; + } } - } - break; + va_end(ref ap); } + return rc; } - va_end( ref ap ); - } - return rc; - } - /* - ** Return true if the buffer z[0..n-1] contains all spaces. - */ - static bool allSpaces( string z, int iStart, int n ) - { - while ( n > 0 && z[iStart + n - 1] == ' ' ) - { - n--; - } - return n == 0; - } - - /* - ** This is the default collating function named "BINARY" which is always - ** available. - ** - ** If the padFlag argument is not NULL then space padding at the end - ** of strings is ignored. This implements the RTRIM collation. - */ - static int binCollFunc( - object padFlag, - int nKey1, string pKey1, - int nKey2, string pKey2 - ) - { - int rc, n; - n = nKey1 < nKey2 ? nKey1 : nKey2; - rc = memcmp( pKey1, pKey2, n ); - if ( rc == 0 ) - { - if ( (int)padFlag != 0 && allSpaces( pKey1, n, nKey1 - n ) && allSpaces( pKey2, n, nKey2 - n ) ) - { - /* Leave rc unchanged at 0 */ - } - else - { - rc = nKey1 - nKey2; + /* + ** Return true if the buffer z[0..n-1] contains all spaces. + */ + static bool allSpaces(string z, int iStart, int n) { + while (n > 0 && z[iStart + n - 1] == ' ') { + n--; + } + return n == 0; } - } - return rc; - } - - /* - ** Another built-in collating sequence: NOCASE. - ** - ** This collating sequence is intended to be used for "case independant - ** comparison". SQLite's knowledge of upper and lower case equivalents - ** extends only to the 26 characters used in the English language. - ** - ** At the moment there is only a UTF-8 implementation. - */ - static int nocaseCollatingFunc( - object NotUsed, - int nKey1, string pKey1, - int nKey2, string pKey2 - ) - { - ////int n = ( nKey1 < nKey2 ) ? nKey1 : nKey2; - int r = sqlite3StrNICmp( pKey1, pKey2, ( nKey1 < nKey2 ) ? nKey1 : nKey2 ); - UNUSED_PARAMETER( NotUsed ); - if ( 0 == r ) - { - r = nKey1 - nKey2; - } - return r; - } - - /* - ** Return the ROWID of the most recent insert - */ - static public sqlite_int64 sqlite3_last_insert_rowid( sqlite3 db ) - { - return db.lastRowid; - } - - /* - ** Return the number of changes in the most recent call to sqlite3_exec(). - */ - static public int sqlite3_changes( sqlite3 db ) - { - return db.nChange; - } - - /* - ** Return the number of changes since the database handle was opened. - */ - static public int sqlite3_total_changes( sqlite3 db ) - { - return db.nTotalChange; - } - /* - ** Close all open savepoints. This function only manipulates fields of the - ** database handle object, it does not close any savepoints that may be open - ** at the b-tree/pager level. - */ - static void sqlite3CloseSavepoints( sqlite3 db ) - { - while ( db.pSavepoint != null ) - { - Savepoint pTmp = db.pSavepoint; - db.pSavepoint = pTmp.pNext; - sqlite3DbFree( db, ref pTmp ); - } - db.nSavepoint = 0; - db.nStatement = 0; - db.isTransactionSavepoint = 0; - } - - /* - ** Invoke the destructor function associated with FuncDef p, if any. Except, - ** if this is not the last copy of the function, do not invoke it. Multiple - ** copies of a single function are created when create_function() is called - ** with SQLITE_ANY as the encoding. - */ - static void functionDestroy( sqlite3 db, FuncDef p ) - { - FuncDestructor pDestructor = p.pDestructor; - if ( pDestructor != null ) - { - pDestructor.nRef--; - if ( pDestructor.nRef == 0 ) - { - //pDestructor.xDestroy( pDestructor.pUserData ); - sqlite3DbFree( db, ref pDestructor ); + /* + ** This is the default collating function named "BINARY" which is always + ** available. + ** + ** If the padFlag argument is not NULL then space padding at the end + ** of strings is ignored. This implements the RTRIM collation. + */ + static int binCollFunc( + object padFlag, + int nKey1, string pKey1, + int nKey2, string pKey2 + ) { + int rc, n; + n = nKey1 < nKey2 ? nKey1 : nKey2; + rc = memcmp(pKey1, pKey2, n); + if (rc == 0) { + if ((int)padFlag != 0 && allSpaces(pKey1, n, nKey1 - n) && allSpaces(pKey2, n, nKey2 - n)) { + /* Leave rc unchanged at 0 */ + } else { + rc = nKey1 - nKey2; + } + } + return rc; } - } - } - /* - ** Close an existing SQLite database - */ - public static int sqlite3_close( sqlite3 db ) - { - HashElem i; /* Hash table iterator */ - int j; - - if ( db == null ) - { - return SQLITE_OK; - } - if ( !sqlite3SafetyCheckSickOrOk( db ) ) - { - return SQLITE_MISUSE_BKPT(); - } - sqlite3_mutex_enter( db.mutex ); + /* + ** Another built-in collating sequence: NOCASE. + ** + ** This collating sequence is intended to be used for "case independant + ** comparison". SQLite's knowledge of upper and lower case equivalents + ** extends only to the 26 characters used in the English language. + ** + ** At the moment there is only a UTF-8 implementation. + */ + static int nocaseCollatingFunc( + object NotUsed, + int nKey1, string pKey1, + int nKey2, string pKey2 + ) { + ////int n = ( nKey1 < nKey2 ) ? nKey1 : nKey2; + int r = sqlite3StrNICmp(pKey1, pKey2, (nKey1 < nKey2) ? nKey1 : nKey2); + UNUSED_PARAMETER(NotUsed); + if (0 == r) { + r = nKey1 - nKey2; + } + return r; + } - /* Force xDestroy calls on all virtual tables */ - sqlite3ResetInternalSchema( db, -1 ); + /* + ** Return the ROWID of the most recent insert + */ + static public sqlite_int64 sqlite3_last_insert_rowid(sqlite3 db) { + return db.lastRowid; + } - /* If a transaction is open, the ResetInternalSchema() call above - ** will not have called the xDisconnect() method on any virtual - ** tables in the db->aVTrans[] array. The following sqlite3VtabRollback() - ** call will do so. We need to do this before the check for active - ** SQL statements below, as the v-table implementation may be storing - ** some prepared statements internally. - */ - sqlite3VtabRollback( db ); + /* + ** Return the number of changes in the most recent call to sqlite3_exec(). + */ + static public int sqlite3_changes(sqlite3 db) { + return db.nChange; + } - /* If there are any outstanding VMs, return SQLITE_BUSY. */ + /* + ** Return the number of changes since the database handle was opened. + */ + static public int sqlite3_total_changes(sqlite3 db) { + return db.nTotalChange; + } - if ( db.pVdbe != null ) - { - sqlite3Error( db, SQLITE_BUSY, - "unable to close due to unfinalised statements" ); - sqlite3_mutex_leave( db.mutex ); - return SQLITE_BUSY; - } - Debug.Assert( sqlite3SafetyCheckSickOrOk( db ) ); - - for ( j = 0; j < db.nDb; j++ ) - { - Btree pBt = db.aDb[j].pBt; - if ( pBt != null && sqlite3BtreeIsInBackup( pBt ) ) - { - sqlite3Error( db, SQLITE_BUSY, - "unable to close due to unfinished backup operation" ); - sqlite3_mutex_leave( db.mutex ); - return SQLITE_BUSY; + /* + ** Close all open savepoints. This function only manipulates fields of the + ** database handle object, it does not close any savepoints that may be open + ** at the b-tree/pager level. + */ + static void sqlite3CloseSavepoints(sqlite3 db) { + while (db.pSavepoint != null) { + Savepoint pTmp = db.pSavepoint; + db.pSavepoint = pTmp.pNext; + sqlite3DbFree(db, ref pTmp); + } + db.nSavepoint = 0; + db.nStatement = 0; + db.isTransactionSavepoint = 0; } - } - /* Free any outstanding Savepoint structures. */ - sqlite3CloseSavepoints( db ); - - for ( j = 0; j < db.nDb; j++ ) - { - Db pDb = db.aDb[j]; - if ( pDb.pBt != null ) - { - sqlite3BtreeClose( ref pDb.pBt ); - pDb.pBt = null; - if ( j != 1 ) - { - pDb.pSchema = null; - } + /* + ** Invoke the destructor function associated with FuncDef p, if any. Except, + ** if this is not the last copy of the function, do not invoke it. Multiple + ** copies of a single function are created when create_function() is called + ** with SQLITE_ANY as the encoding. + */ + static void functionDestroy(sqlite3 db, FuncDef p) { + FuncDestructor pDestructor = p.pDestructor; + if (pDestructor != null) { + pDestructor.nRef--; + if (pDestructor.nRef == 0) { + //pDestructor.xDestroy( pDestructor.pUserData ); + sqlite3DbFree(db, ref pDestructor); + } + } } - } - sqlite3ResetInternalSchema( db, -1 ); - /* Tell the code in notify.c that the connection no longer holds any - ** locks and does not require any further unlock-notify callbacks. - */ - sqlite3ConnectionClosed( db ); - - Debug.Assert( db.nDb <= 2 ); - Debug.Assert( db.aDb[0].Equals( db.aDbStatic[0] ) ); - for ( j = 0; j < ArraySize( db.aFunc.a ); j++ ) - { - FuncDef pNext, pHash, p; - for ( p = db.aFunc.a[j]; p != null; p = pHash ) - { - pHash = p.pHash; - while ( p != null ) - { - functionDestroy( db, p ); - pNext = p.pNext; - sqlite3DbFree( db, ref p ); - p = pNext; - } + /* + ** Close an existing SQLite database + */ + public static int sqlite3_close(sqlite3 db) { + HashElem i; /* Hash table iterator */ + int j; - } - } + if (db == null) { + return SQLITE_OK; + } + if (!sqlite3SafetyCheckSickOrOk(db)) { + return SQLITE_MISUSE_BKPT(); + } + sqlite3_mutex_enter(db.mutex); + + /* Force xDestroy calls on all virtual tables */ + sqlite3ResetInternalSchema(db, -1); + + /* If a transaction is open, the ResetInternalSchema() call above + ** will not have called the xDisconnect() method on any virtual + ** tables in the db->aVTrans[] array. The following sqlite3VtabRollback() + ** call will do so. We need to do this before the check for active + ** SQL statements below, as the v-table implementation may be storing + ** some prepared statements internally. + */ + sqlite3VtabRollback(db); + + /* If there are any outstanding VMs, return SQLITE_BUSY. */ + + if (db.pVdbe != null) { + sqlite3Error(db, SQLITE_BUSY, + "unable to close due to unfinalised statements"); + sqlite3_mutex_leave(db.mutex); + return SQLITE_BUSY; + } + Debug.Assert(sqlite3SafetyCheckSickOrOk(db)); + + for (j = 0; j < db.nDb; j++) { + Btree pBt = db.aDb[j].pBt; + if (pBt != null && sqlite3BtreeIsInBackup(pBt)) { + sqlite3Error(db, SQLITE_BUSY, + "unable to close due to unfinished backup operation"); + sqlite3_mutex_leave(db.mutex); + return SQLITE_BUSY; + } + } - for ( i = db.aCollSeq.first; i != null; i = i.next ) - {//sqliteHashFirst(db.aCollSeq); i!=null; i=sqliteHashNext(i)){ - CollSeq[] pColl = (CollSeq[])i.data;// sqliteHashData(i); - /* Invoke any destructors registered for collation sequence user data. */ - for ( j = 0; j < 3; j++ ) - { - if ( pColl[j].xDel != null ) - { - pColl[j].xDel( ref pColl[j].pUser ); - } - } - sqlite3DbFree( db, ref pColl ); - } - sqlite3HashClear( db.aCollSeq ); + /* Free any outstanding Savepoint structures. */ + sqlite3CloseSavepoints(db); + + for (j = 0; j < db.nDb; j++) { + Db pDb = db.aDb[j]; + if (pDb.pBt != null) { + sqlite3BtreeClose(ref pDb.pBt); + pDb.pBt = null; + if (j != 1) { + pDb.pSchema = null; + } + } + } + sqlite3ResetInternalSchema(db, -1); + + /* Tell the code in notify.c that the connection no longer holds any + ** locks and does not require any further unlock-notify callbacks. + */ + sqlite3ConnectionClosed(db); + + Debug.Assert(db.nDb <= 2); + Debug.Assert(db.aDb[0].Equals(db.aDbStatic[0])); + for (j = 0; j < ArraySize(db.aFunc.a); j++) { + FuncDef pNext, pHash, p; + for (p = db.aFunc.a[j]; p != null; p = pHash) { + pHash = p.pHash; + while (p != null) { + functionDestroy(db, p); + pNext = p.pNext; + sqlite3DbFree(db, ref p); + p = pNext; + } + + } + } + + for (i = db.aCollSeq.first; i != null; i = i.next) {//sqliteHashFirst(db.aCollSeq); i!=null; i=sqliteHashNext(i)){ + CollSeq[] pColl = (CollSeq[])i.data;// sqliteHashData(i); + /* Invoke any destructors registered for collation sequence user data. */ + for (j = 0; j < 3; j++) { + if (pColl[j].xDel != null) { + pColl[j].xDel(ref pColl[j].pUser); + } + } + sqlite3DbFree(db, ref pColl); + } + sqlite3HashClear(db.aCollSeq); #if !SQLITE_OMIT_VIRTUALTABLE - for ( i = sqliteHashFirst( db.aModule ); i != null; i = sqliteHashNext( i ) ) - { - Module pMod = (Module)sqliteHashData( i ); - if ( pMod.xDestroy != null ) - { - pMod.xDestroy( ref pMod.pAux ); - } - sqlite3DbFree( db, ref pMod ); - } - sqlite3HashClear( db.aModule ); + for (i = sqliteHashFirst(db.aModule); i != null; i = sqliteHashNext(i)) { + Module pMod = (Module)sqliteHashData(i); + if (pMod.xDestroy != null) { + pMod.xDestroy(ref pMod.pAux); + } + sqlite3DbFree(db, ref pMod); + } + sqlite3HashClear(db.aModule); #endif - sqlite3Error( db, SQLITE_OK, 0 ); /* Deallocates any cached error strings. */ - if ( db.pErr != null ) - { - sqlite3ValueFree( ref db.pErr ); - } + sqlite3Error(db, SQLITE_OK, 0); /* Deallocates any cached error strings. */ + if (db.pErr != null) { + sqlite3ValueFree(ref db.pErr); + } #if !SQLITE_OMIT_LOAD_EXTENSION - sqlite3CloseExtensions( db ); + sqlite3CloseExtensions(db); #endif - db.magic = SQLITE_MAGIC_ERROR; - - /* The temp.database schema is allocated differently from the other schema - ** objects (using sqliteMalloc() directly, instead of sqlite3BtreeSchema()). - ** So it needs to be freed here. Todo: Why not roll the temp schema into - ** the same sqliteMalloc() as the one that allocates the database - ** structure? - */ - sqlite3DbFree( db, ref db.aDb[1].pSchema ); - sqlite3_mutex_leave( db.mutex ); - db.magic = SQLITE_MAGIC_CLOSED; - sqlite3_mutex_free( db.mutex ); - Debug.Assert( db.lookaside.nOut == 0 ); /* Fails on a lookaside memory leak */ - //if ( db.lookaside.bMalloced ) - //{ - // sqlite3_free( ref db.lookaside.pStart ); - //} - //sqlite3_free( ref db ); - return SQLITE_OK; - } - - /* - ** Rollback all database files. - */ - static void sqlite3RollbackAll( sqlite3 db ) - { - int i; - int inTrans = 0; - Debug.Assert( sqlite3_mutex_held( db.mutex ) ); - sqlite3BeginBenignMalloc(); - for ( i = 0; i < db.nDb; i++ ) - { - if ( db.aDb[i].pBt != null ) - { - if ( sqlite3BtreeIsInTrans( db.aDb[i].pBt ) ) - { - inTrans = 1; - } - sqlite3BtreeRollback( db.aDb[i].pBt ); - db.aDb[i].inTrans = 0; + db.magic = SQLITE_MAGIC_ERROR; + + /* The temp.database schema is allocated differently from the other schema + ** objects (using sqliteMalloc() directly, instead of sqlite3BtreeSchema()). + ** So it needs to be freed here. Todo: Why not roll the temp schema into + ** the same sqliteMalloc() as the one that allocates the database + ** structure? + */ + sqlite3DbFree(db, ref db.aDb[1].pSchema); + sqlite3_mutex_leave(db.mutex); + db.magic = SQLITE_MAGIC_CLOSED; + sqlite3_mutex_free(db.mutex); + Debug.Assert(db.lookaside.nOut == 0); /* Fails on a lookaside memory leak */ + //if ( db.lookaside.bMalloced ) + //{ + // sqlite3_free( ref db.lookaside.pStart ); + //} + //sqlite3_free( ref db ); + return SQLITE_OK; } - } - sqlite3VtabRollback( db ); - sqlite3EndBenignMalloc(); - if ( ( db.flags & SQLITE_InternChanges ) != 0 ) - { - sqlite3ExpirePreparedStatements( db ); - sqlite3ResetInternalSchema( db, -1 ); - } + /* + ** Rollback all database files. + */ + static void sqlite3RollbackAll(sqlite3 db) { + int i; + int inTrans = 0; + Debug.Assert(sqlite3_mutex_held(db.mutex)); + sqlite3BeginBenignMalloc(); + for (i = 0; i < db.nDb; i++) { + if (db.aDb[i].pBt != null) { + if (sqlite3BtreeIsInTrans(db.aDb[i].pBt)) { + inTrans = 1; + } + sqlite3BtreeRollback(db.aDb[i].pBt); + db.aDb[i].inTrans = 0; + } + } - /* Any deferred constraint violations have now been resolved. */ - db.nDeferredCons = 0; + sqlite3VtabRollback(db); + sqlite3EndBenignMalloc(); + if ((db.flags & SQLITE_InternChanges) != 0) { + sqlite3ExpirePreparedStatements(db); + sqlite3ResetInternalSchema(db, -1); + } - /* If one has been configured, invoke the rollback-hook callback */ - if ( db.xRollbackCallback != null && ( inTrans != 0 || 0 == db.autoCommit ) ) - { - db.xRollbackCallback( db.pRollbackArg ); - } - } + /* Any deferred constraint violations have now been resolved. */ + db.nDeferredCons = 0; - /* - ** Return a static string that describes the kind of error specified in the - ** argument. - */ - static string sqlite3ErrStr( int rc ) - { - string[] aMsg = new string[]{ + /* If one has been configured, invoke the rollback-hook callback */ + if (db.xRollbackCallback != null && (inTrans != 0 || 0 == db.autoCommit)) { + db.xRollbackCallback(db.pRollbackArg); + } + } + + /* + ** Return a static string that describes the kind of error specified in the + ** argument. + */ + static string sqlite3ErrStr(int rc) { + string[] aMsg = new string[]{ /* SQLITE_OK */ "not an error", /* SQLITE_ERROR */ "SQL logic error or missing database", /* SQLITE_INTERNAL */ "", @@ -1158,56 +1027,49 @@ static string sqlite3ErrStr( int rc ) /* SQLITE_RANGE */ "bind or column index out of range", /* SQLITE_NOTADB */ "file is encrypted or is not a database", }; - rc &= 0xff; - if ( ALWAYS( rc >= 0 ) && rc < aMsg.Length && aMsg[rc] != "" )//(int)(sizeof(aMsg)/sizeof(aMsg[0])) - { - return aMsg[rc]; - } - else - { - return "unknown error"; - } - } + rc &= 0xff; + if (ALWAYS(rc >= 0) && rc < aMsg.Length && aMsg[rc] != "")//(int)(sizeof(aMsg)/sizeof(aMsg[0])) + { + return aMsg[rc]; + } else { + return "unknown error"; + } + } - /* - ** This routine implements a busy callback that sleeps and tries - ** again until a timeout value is reached. The timeout value is - ** an integer number of milliseconds passed in as the first - ** argument. - */ - static int sqliteDefaultBusyCallback( - object ptr, /* Database connection */ - int count /* Number of times table has been busy */ - ) - { + /* + ** This routine implements a busy callback that sleeps and tries + ** again until a timeout value is reached. The timeout value is + ** an integer number of milliseconds passed in as the first + ** argument. + */ + static int sqliteDefaultBusyCallback( + object ptr, /* Database connection */ + int count /* Number of times table has been busy */ + ) { #if SQLITE_OS_WIN || HAVE_USLEEP - u8[] delays = new u8[] { 1, 2, 5, 10, 15, 20, 25, 25, 25, 50, 50, 100 }; - u8[] totals = new u8[] { 0, 1, 3, 8, 18, 33, 53, 78, 103, 128, 178, 228 }; - //# define NDELAY ArraySize(delays) - int NDELAY = ArraySize( delays ); - sqlite3 db = (sqlite3)ptr; - int timeout = db.busyTimeout; - int delay, prior; - - Debug.Assert( count >= 0 ); - if ( count < NDELAY ) - { - delay = delays[count]; - prior = totals[count]; - } - else - { - delay = delays[NDELAY - 1]; - prior = totals[NDELAY - 1] + delay * ( count - ( NDELAY - 1 ) ); - } - if ( prior + delay > timeout ) - { - delay = timeout - prior; - if ( delay <= 0 ) - return 0; - } - sqlite3OsSleep( db.pVfs, delay * 1000 ); - return 1; + u8[] delays = new u8[] { 1, 2, 5, 10, 15, 20, 25, 25, 25, 50, 50, 100 }; + u8[] totals = new u8[] { 0, 1, 3, 8, 18, 33, 53, 78, 103, 128, 178, 228 }; + //# define NDELAY ArraySize(delays) + int NDELAY = ArraySize(delays); + sqlite3 db = (sqlite3)ptr; + int timeout = db.busyTimeout; + int delay, prior; + + Debug.Assert(count >= 0); + if (count < NDELAY) { + delay = delays[count]; + prior = totals[count]; + } else { + delay = delays[NDELAY - 1]; + prior = totals[NDELAY - 1] + delay * (count - (NDELAY - 1)); + } + if (prior + delay > timeout) { + delay = timeout - prior; + if (delay <= 0) + return 0; + } + sqlite3OsSleep(db.pVfs, delay * 1000); + return 1; #else sqlite3 db = (sqlite3)ptr; int timeout = ( (sqlite3)ptr ).busyTimeout; @@ -1218,139 +1080,123 @@ int count /* Number of times table has been busy */ sqlite3OsSleep( db.pVfs, 1000000 ); return 1; #endif - } + } - /* - ** Invoke the given busy handler. - ** - ** This routine is called when an operation failed with a lock. - ** If this routine returns non-zero, the lock is retried. If it - ** returns 0, the operation aborts with an SQLITE_BUSY error. - */ - static int sqlite3InvokeBusyHandler( BusyHandler p ) - { - int rc; - if ( NEVER( p == null ) || p.xFunc == null || p.nBusy < 0 ) - return 0; - rc = p.xFunc( p.pArg, p.nBusy ); - if ( rc == 0 ) - { - p.nBusy = -1; - } - else - { - p.nBusy++; - } - return rc; - } + /* + ** Invoke the given busy handler. + ** + ** This routine is called when an operation failed with a lock. + ** If this routine returns non-zero, the lock is retried. If it + ** returns 0, the operation aborts with an SQLITE_BUSY error. + */ + static int sqlite3InvokeBusyHandler(BusyHandler p) { + int rc; + if (NEVER(p == null) || p.xFunc == null || p.nBusy < 0) + return 0; + rc = p.xFunc(p.pArg, p.nBusy); + if (rc == 0) { + p.nBusy = -1; + } else { + p.nBusy++; + } + return rc; + } - /* - ** This routine sets the busy callback for an Sqlite database to the - ** given callback function with the given argument. - */ - static int sqlite3_busy_handler( - sqlite3 db, - dxBusy xBusy, - object pArg - ) - { - sqlite3_mutex_enter( db.mutex ); - db.busyHandler.xFunc = xBusy; - db.busyHandler.pArg = pArg; - db.busyHandler.nBusy = 0; - sqlite3_mutex_leave( db.mutex ); - return SQLITE_OK; - } + /* + ** This routine sets the busy callback for an Sqlite database to the + ** given callback function with the given argument. + */ + static int sqlite3_busy_handler( + sqlite3 db, + dxBusy xBusy, + object pArg + ) { + sqlite3_mutex_enter(db.mutex); + db.busyHandler.xFunc = xBusy; + db.busyHandler.pArg = pArg; + db.busyHandler.nBusy = 0; + sqlite3_mutex_leave(db.mutex); + return SQLITE_OK; + } #if !SQLITE_OMIT_PROGRESS_CALLBACK - /* -** This routine sets the progress callback for an Sqlite database to the -** given callback function with the given argument. The progress callback will -** be invoked every nOps opcodes. -*/ - static void sqlite3_progress_handler( - sqlite3 db, - int nOps, - dxProgress xProgress, //int (xProgress)(void), - object pArg - ) - { - sqlite3_mutex_enter( db.mutex ); - if ( nOps > 0 ) - { - db.xProgress = xProgress; - db.nProgressOps = nOps; - db.pProgressArg = pArg; - } - else - { - db.xProgress = null; - db.nProgressOps = 0; - db.pProgressArg = null; - } - sqlite3_mutex_leave( db.mutex ); - } + /* + ** This routine sets the progress callback for an Sqlite database to the + ** given callback function with the given argument. The progress callback will + ** be invoked every nOps opcodes. + */ + static void sqlite3_progress_handler( + sqlite3 db, + int nOps, + dxProgress xProgress, //int (xProgress)(void), + object pArg + ) { + sqlite3_mutex_enter(db.mutex); + if (nOps > 0) { + db.xProgress = xProgress; + db.nProgressOps = nOps; + db.pProgressArg = pArg; + } else { + db.xProgress = null; + db.nProgressOps = 0; + db.pProgressArg = null; + } + sqlite3_mutex_leave(db.mutex); + } #endif - /* -** This routine installs a default busy handler that waits for the -** specified number of milliseconds before returning 0. -*/ - static public int sqlite3_busy_timeout( sqlite3 db, int ms ) - { - if ( ms > 0 ) - { - db.busyTimeout = ms; - sqlite3_busy_handler( db, sqliteDefaultBusyCallback, db ); - } - else - { - sqlite3_busy_handler( db, null, null ); - } - return SQLITE_OK; - } - - /* - ** Cause any pending operation to stop at its earliest opportunity. + /* + ** This routine installs a default busy handler that waits for the + ** specified number of milliseconds before returning 0. */ - public static void sqlite3_interrupt( sqlite3 db ) - { - db.u1.isInterrupted = true; - } + static public int sqlite3_busy_timeout(sqlite3 db, int ms) { + if (ms > 0) { + db.busyTimeout = ms; + sqlite3_busy_handler(db, sqliteDefaultBusyCallback, db); + } else { + sqlite3_busy_handler(db, null, null); + } + return SQLITE_OK; + } + /* + ** Cause any pending operation to stop at its earliest opportunity. + */ + public static void sqlite3_interrupt(sqlite3 db) { + db.u1.isInterrupted = true; + } - /* - ** This function is exactly the same as sqlite3_create_function(), except - ** that it is designed to be called by internal code. The difference is - ** that if a malloc() fails in sqlite3_create_function(), an error code - ** is returned and the mallocFailed flag cleared. - */ - static int sqlite3CreateFunc( - sqlite3 db, - string zFunctionName, - int nArg, - u8 enc, - object pUserData, - dxFunc xFunc, //)(sqlite3_context*,int,sqlite3_value *), - dxStep xStep,//)(sqlite3_context*,int,sqlite3_value *), - dxFinal xFinal, //)(sqlite3_context), - FuncDestructor pDestructor - ) - { - FuncDef p; - int nName; - - Debug.Assert( sqlite3_mutex_held( db.mutex ) ); - if ( zFunctionName == null || - ( xFunc != null && ( xFinal != null || xStep != null ) ) || - ( xFunc == null && ( xFinal != null && xStep == null ) ) || - ( xFunc == null && ( xFinal == null && xStep != null ) ) || - ( nArg < -1 || nArg > SQLITE_MAX_FUNCTION_ARG ) || - ( 255 < ( nName = sqlite3Strlen30( zFunctionName ) ) ) ) - { - return SQLITE_MISUSE_BKPT(); - } + + /* + ** This function is exactly the same as sqlite3_create_function(), except + ** that it is designed to be called by internal code. The difference is + ** that if a malloc() fails in sqlite3_create_function(), an error code + ** is returned and the mallocFailed flag cleared. + */ + static int sqlite3CreateFunc( + sqlite3 db, + string zFunctionName, + int nArg, + u8 enc, + object pUserData, + dxFunc xFunc, //)(sqlite3_context*,int,sqlite3_value *), + dxStep xStep,//)(sqlite3_context*,int,sqlite3_value *), + dxFinal xFinal, //)(sqlite3_context), + FuncDestructor pDestructor + ) { + FuncDef p; + int nName; + + Debug.Assert(sqlite3_mutex_held(db.mutex)); + if (zFunctionName == null || + (xFunc != null && (xFinal != null || xStep != null)) || + (xFunc == null && (xFinal != null && xStep == null)) || + (xFunc == null && (xFinal == null && xStep != null)) || + (nArg < -1 || nArg > SQLITE_MAX_FUNCTION_ARG) || + (255 < (nName = sqlite3Strlen30(zFunctionName)))) { + return SQLITE_MISUSE_BKPT(); + } #if !SQLITE_OMIT_UTF16 /* If SQLITE_UTF16 is specified as the encoding type, transform this @@ -1376,110 +1222,101 @@ FuncDestructor pDestructor enc = SQLITE_UTF16BE; } #else - enc = SQLITE_UTF8; + enc = SQLITE_UTF8; #endif - /* Check if an existing function is being overridden or deleted. If so, -** and there are active VMs, then return SQLITE_BUSY. If a function -** is being overridden/deleted but there are no active VMs, allow the -** operation to continue but invalidate all precompiled statements. -*/ - p = sqlite3FindFunction( db, zFunctionName, nName, nArg, enc, 0 ); - if ( p != null && p.iPrefEnc == enc && p.nArg == nArg ) - { - if ( db.activeVdbeCnt != 0 ) - { - sqlite3Error( db, SQLITE_BUSY, - "unable to delete/modify user-function due to active statements" ); - //Debug.Assert( 0 == db.mallocFailed ); - return SQLITE_BUSY; - } - else - { - sqlite3ExpirePreparedStatements( db ); - } - } + /* Check if an existing function is being overridden or deleted. If so, + ** and there are active VMs, then return SQLITE_BUSY. If a function + ** is being overridden/deleted but there are no active VMs, allow the + ** operation to continue but invalidate all precompiled statements. + */ + p = sqlite3FindFunction(db, zFunctionName, nName, nArg, enc, 0); + if (p != null && p.iPrefEnc == enc && p.nArg == nArg) { + if (db.activeVdbeCnt != 0) { + sqlite3Error(db, SQLITE_BUSY, + "unable to delete/modify user-function due to active statements"); + //Debug.Assert( 0 == db.mallocFailed ); + return SQLITE_BUSY; + } else { + sqlite3ExpirePreparedStatements(db); + } + } - p = sqlite3FindFunction( db, zFunctionName, nName, nArg, enc, 1 ); - Debug.Assert( p != null /*|| db.mallocFailed != 0 */ ); - //if ( p == null ) - //{ - // return SQLITE_NOMEM; - //} + p = sqlite3FindFunction(db, zFunctionName, nName, nArg, enc, 1); + Debug.Assert(p != null /*|| db.mallocFailed != 0 */ ); + //if ( p == null ) + //{ + // return SQLITE_NOMEM; + //} - /* If an older version of the function with a configured destructor is - ** being replaced invoke the destructor function here. */ - functionDestroy( db, p ); + /* If an older version of the function with a configured destructor is + ** being replaced invoke the destructor function here. */ + functionDestroy(db, p); - if ( pDestructor != null ) - { - pDestructor.nRef++; - } - p.pDestructor = pDestructor; - p.flags = 0; - p.xFunc = xFunc; - p.xStep = xStep; - p.xFinalize = xFinal; - p.pUserData = pUserData; - p.nArg = (i16)nArg; - return SQLITE_OK; - } + if (pDestructor != null) { + pDestructor.nRef++; + } + p.pDestructor = pDestructor; + p.flags = 0; + p.xFunc = xFunc; + p.xStep = xStep; + p.xFinalize = xFinal; + p.pUserData = pUserData; + p.nArg = (i16)nArg; + return SQLITE_OK; + } - /* - ** Create new user functions. - */ - static public int sqlite3_create_function( - sqlite3 db, - string zFunc, - int nArg, - u8 enc, - object p, - dxFunc xFunc, //)(sqlite3_context*,int,sqlite3_value *), - dxStep xStep,//)(sqlite3_context*,int,sqlite3_value *), - dxFinal xFinal//)(sqlite3_context) - ) - { - return sqlite3_create_function_v2( db, zFunc, nArg, enc, p, xFunc, xStep, - xFinal, null ); - } + /* + ** Create new user functions. + */ + static public int sqlite3_create_function( + sqlite3 db, + string zFunc, + int nArg, + u8 enc, + object p, + dxFunc xFunc, //)(sqlite3_context*,int,sqlite3_value *), + dxStep xStep,//)(sqlite3_context*,int,sqlite3_value *), + dxFinal xFinal//)(sqlite3_context) + ) { + return sqlite3_create_function_v2(db, zFunc, nArg, enc, p, xFunc, xStep, + xFinal, null); + } - static int sqlite3_create_function_v2( - sqlite3 db, - string zFunc, - int nArg, - int enc, - object p, - dxFunc xFunc, //)(sqlite3_context*,int,sqlite3_value *), - dxStep xStep,//)(sqlite3_context*,int,sqlite3_value *), - dxFinal xFinal,//)(sqlite3_context) - dxFDestroy xDestroy//)(void ) - ) - { - int rc = SQLITE_ERROR; - FuncDestructor pArg = null; - sqlite3_mutex_enter( db.mutex ); - if ( xDestroy != null ) - { - pArg = new FuncDestructor();//(FuncDestructor )sqlite3DbMallocZero(db, sizeof(FuncDestructor)); - //if( null==pArg ){ - // xDestroy(p); - // goto out; - //} - pArg.xDestroy = xDestroy; - pArg.pUserData = p; - } - rc = sqlite3CreateFunc( db, zFunc, nArg, (byte)enc, p, xFunc, xStep, xFinal, pArg ); - if ( pArg != null && pArg.nRef == 0 ) - { - Debug.Assert( rc != SQLITE_OK ); - //xDestroy(p); - sqlite3DbFree( db, ref pArg ); - } - //_out: - rc = sqlite3ApiExit( db, rc ); - sqlite3_mutex_leave( db.mutex ); - return rc; - } + static int sqlite3_create_function_v2( + sqlite3 db, + string zFunc, + int nArg, + int enc, + object p, + dxFunc xFunc, //)(sqlite3_context*,int,sqlite3_value *), + dxStep xStep,//)(sqlite3_context*,int,sqlite3_value *), + dxFinal xFinal,//)(sqlite3_context) + dxFDestroy xDestroy//)(void ) + ) { + int rc = SQLITE_ERROR; + FuncDestructor pArg = null; + sqlite3_mutex_enter(db.mutex); + if (xDestroy != null) { + pArg = new FuncDestructor();//(FuncDestructor )sqlite3DbMallocZero(db, sizeof(FuncDestructor)); + //if( null==pArg ){ + // xDestroy(p); + // goto out; + //} + pArg.xDestroy = xDestroy; + pArg.pUserData = p; + } + rc = sqlite3CreateFunc(db, zFunc, nArg, (byte)enc, p, xFunc, xStep, xFinal, pArg); + if (pArg != null && pArg.nRef == 0) { + Debug.Assert(rc != SQLITE_OK); + //xDestroy(p); + sqlite3DbFree(db, ref pArg); + } + //_out: + rc = sqlite3ApiExit(db, rc); + sqlite3_mutex_leave(db.mutex); + return rc; + } #if !SQLITE_OMIT_UTF16 static int sqlite3_create_function16( @@ -1506,138 +1343,131 @@ static int sqlite3_create_function16( #endif - /* -** Declare that a function has been overloaded by a virtual table. -** -** If the function already exists as a regular global function, then -** this routine is a no-op. If the function does not exist, then create -** a new one that always throws a run-time error. -** -** When virtual tables intend to provide an overloaded function, they -** should call this routine to make sure the global function exists. -** A global function must exist in order for name resolution to work -** properly. -*/ - static int sqlite3_overload_function( - sqlite3 db, - string zName, - int nArg - ) - { - int nName = sqlite3Strlen30( zName ); - int rc; - sqlite3_mutex_enter( db.mutex ); - if ( sqlite3FindFunction( db, zName, nName, nArg, SQLITE_UTF8, 0 ) == null ) - { - sqlite3CreateFunc( db, zName, nArg, SQLITE_UTF8, - 0, (dxFunc)sqlite3InvalidFunction, null, null, null ); - } - rc = sqlite3ApiExit( db, SQLITE_OK ); - sqlite3_mutex_leave( db.mutex ); - return rc; - } + /* + ** Declare that a function has been overloaded by a virtual table. + ** + ** If the function already exists as a regular global function, then + ** this routine is a no-op. If the function does not exist, then create + ** a new one that always throws a run-time error. + ** + ** When virtual tables intend to provide an overloaded function, they + ** should call this routine to make sure the global function exists. + ** A global function must exist in order for name resolution to work + ** properly. + */ + static int sqlite3_overload_function( + sqlite3 db, + string zName, + int nArg + ) { + int nName = sqlite3Strlen30(zName); + int rc; + sqlite3_mutex_enter(db.mutex); + if (sqlite3FindFunction(db, zName, nName, nArg, SQLITE_UTF8, 0) == null) { + sqlite3CreateFunc(db, zName, nArg, SQLITE_UTF8, + 0, (dxFunc)sqlite3InvalidFunction, null, null, null); + } + rc = sqlite3ApiExit(db, SQLITE_OK); + sqlite3_mutex_leave(db.mutex); + return rc; + } #if !SQLITE_OMIT_TRACE - /* -** Register a trace function. The pArg from the previously registered trace -** is returned. -** -** A NULL trace function means that no tracing is executes. A non-NULL -** trace is a pointer to a function that is invoked at the start of each -** SQL statement. -*/ - static object sqlite3_trace( sqlite3 db, dxTrace xTrace, object pArg ) - {// (*xTrace)(void*,const char), object pArg){ - object pOld; - sqlite3_mutex_enter( db.mutex ); - pOld = db.pTraceArg; - db.xTrace = xTrace; - db.pTraceArg = pArg; - sqlite3_mutex_leave( db.mutex ); - return pOld; - } - /* - ** Register a profile function. The pArg from the previously registered - ** profile function is returned. + /* + ** Register a trace function. The pArg from the previously registered trace + ** is returned. ** - ** A NULL profile function means that no profiling is executes. A non-NULL - ** profile is a pointer to a function that is invoked at the conclusion of - ** each SQL statement that is run. + ** A NULL trace function means that no tracing is executes. A non-NULL + ** trace is a pointer to a function that is invoked at the start of each + ** SQL statement. */ - static object sqlite3_profile( - sqlite3 db, - dxProfile xProfile,//void (*xProfile)(void*,const char*,sqlite_u3264), - object pArg - ) - { - object pOld; - sqlite3_mutex_enter( db.mutex ); - pOld = db.pProfileArg; - db.xProfile = xProfile; - db.pProfileArg = pArg; - sqlite3_mutex_leave( db.mutex ); - return pOld; - } + static object sqlite3_trace(sqlite3 db, dxTrace xTrace, object pArg) {// (*xTrace)(void*,const char), object pArg){ + object pOld; + sqlite3_mutex_enter(db.mutex); + pOld = db.pTraceArg; + db.xTrace = xTrace; + db.pTraceArg = pArg; + sqlite3_mutex_leave(db.mutex); + return pOld; + } + /* + ** Register a profile function. The pArg from the previously registered + ** profile function is returned. + ** + ** A NULL profile function means that no profiling is executes. A non-NULL + ** profile is a pointer to a function that is invoked at the conclusion of + ** each SQL statement that is run. + */ + static object sqlite3_profile( + sqlite3 db, + dxProfile xProfile,//void (*xProfile)(void*,const char*,sqlite_u3264), + object pArg + ) { + object pOld; + sqlite3_mutex_enter(db.mutex); + pOld = db.pProfileArg; + db.xProfile = xProfile; + db.pProfileArg = pArg; + sqlite3_mutex_leave(db.mutex); + return pOld; + } #endif // * SQLITE_OMIT_TRACE */ - /*** EXPERIMENTAL *** -** -** Register a function to be invoked when a transaction comments. -** If the invoked function returns non-zero, then the commit becomes a -** rollback. -*/ - public static object sqlite3_commit_hook( - sqlite3 db, /* Attach the hook to this database */ - dxCommitCallback xCallback, //int (*xCallback)(void), /* Function to invoke on each commit */ - object pArg /* Argument to the function */ - ) - { - object pOld; - sqlite3_mutex_enter( db.mutex ); - pOld = db.pCommitArg; - db.xCommitCallback = xCallback; - db.pCommitArg = pArg; - sqlite3_mutex_leave( db.mutex ); - return pOld; - } - - /* - ** Register a callback to be invoked each time a row is updated, - ** inserted or deleted using this database connection. + /*** EXPERIMENTAL *** + ** + ** Register a function to be invoked when a transaction comments. + ** If the invoked function returns non-zero, then the commit becomes a + ** rollback. */ - public static object sqlite3_update_hook( - sqlite3 db, /* Attach the hook to this database */ - dxUpdateCallback xCallback, //void (*xCallback)(void*,int,char const *,char const *,sqlite_int64), - object pArg /* Argument to the function */ - ) - { - object pRet; - sqlite3_mutex_enter( db.mutex ); - pRet = db.pUpdateArg; - db.xUpdateCallback = xCallback; - db.pUpdateArg = pArg; - sqlite3_mutex_leave( db.mutex ); - return pRet; - } + public static object sqlite3_commit_hook( + sqlite3 db, /* Attach the hook to this database */ + dxCommitCallback xCallback, //int (*xCallback)(void), /* Function to invoke on each commit */ + object pArg /* Argument to the function */ + ) { + object pOld; + sqlite3_mutex_enter(db.mutex); + pOld = db.pCommitArg; + db.xCommitCallback = xCallback; + db.pCommitArg = pArg; + sqlite3_mutex_leave(db.mutex); + return pOld; + } - /* - ** Register a callback to be invoked each time a transaction is rolled - ** back by this database connection. - */ - public static object sqlite3_rollback_hook( - sqlite3 db, /* Attach the hook to this database */ - dxRollbackCallback xCallback, //void (*xCallback)(void), /* Callback function */ - object pArg /* Argument to the function */ - ) - { - object pRet; - sqlite3_mutex_enter( db.mutex ); - pRet = db.pRollbackArg; - db.xRollbackCallback = xCallback; - db.pRollbackArg = pArg; - sqlite3_mutex_leave( db.mutex ); - return pRet; - } + /* + ** Register a callback to be invoked each time a row is updated, + ** inserted or deleted using this database connection. + */ + public static object sqlite3_update_hook( + sqlite3 db, /* Attach the hook to this database */ + dxUpdateCallback xCallback, //void (*xCallback)(void*,int,char const *,char const *,sqlite_int64), + object pArg /* Argument to the function */ + ) { + object pRet; + sqlite3_mutex_enter(db.mutex); + pRet = db.pUpdateArg; + db.xUpdateCallback = xCallback; + db.pUpdateArg = pArg; + sqlite3_mutex_leave(db.mutex); + return pRet; + } + + /* + ** Register a callback to be invoked each time a transaction is rolled + ** back by this database connection. + */ + public static object sqlite3_rollback_hook( + sqlite3 db, /* Attach the hook to this database */ + dxRollbackCallback xCallback, //void (*xCallback)(void), /* Callback function */ + object pArg /* Argument to the function */ + ) { + object pRet; + sqlite3_mutex_enter(db.mutex); + pRet = db.pRollbackArg; + db.xRollbackCallback = xCallback; + db.pRollbackArg = pArg; + sqlite3_mutex_leave(db.mutex); + return pRet; + } #if !SQLITE_OMIT_WAL /* @@ -1661,22 +1491,21 @@ int nFrame /* Size of WAL */ } #endif //* SQLITE_OMIT_WAL */ - /* -** Configure an sqlite3_wal_hook() callback to automatically checkpoint -** a database after committing a transaction if there are nFrame or -** more frames in the log file. Passing zero or a negative value as the -** nFrame parameter disables automatic checkpoints entirely. -** -** The callback registered by this function replaces any existing callback -** registered using sqlite3_wal_hook(). Likewise, registering a callback -** using sqlite3_wal_hook() disables the automatic checkpoint mechanism -** configured by this function. -*/ - static int sqlite3_wal_autocheckpoint( sqlite3 db, int nFrame ) - { + /* + ** Configure an sqlite3_wal_hook() callback to automatically checkpoint + ** a database after committing a transaction if there are nFrame or + ** more frames in the log file. Passing zero or a negative value as the + ** nFrame parameter disables automatic checkpoints entirely. + ** + ** The callback registered by this function replaces any existing callback + ** registered using sqlite3_wal_hook(). Likewise, registering a callback + ** using sqlite3_wal_hook() disables the automatic checkpoint mechanism + ** configured by this function. + */ + static int sqlite3_wal_autocheckpoint(sqlite3 db, int nFrame) { #if SQLITE_OMIT_WAL - UNUSED_PARAMETER( db ); - UNUSED_PARAMETER( nFrame ); + UNUSED_PARAMETER(db); + UNUSED_PARAMETER(nFrame); #else if( nFrame>0 ){ sqlite3_wal_hook(db, sqlite3WalDefaultHook, SQLITE_INT_TO_PTR(nFrame)); @@ -1684,19 +1513,18 @@ static int sqlite3_wal_autocheckpoint( sqlite3 db, int nFrame ) sqlite3_wal_hook(db, 0, 0); } #endif - return SQLITE_OK; - } + return SQLITE_OK; + } - /* - ** Register a callback to be invoked each time a transaction is written - ** into the write-ahead-log by this database connection. - */ - static object sqlite3_wal_hook( - sqlite3 db, /* Attach the hook to this db handle */ - dxWalCallback xCallback, //int(*xCallback)(void *, sqlite3*, const char*, int), - object pArg /* First argument passed to xCallback() */ - ) - { + /* + ** Register a callback to be invoked each time a transaction is written + ** into the write-ahead-log by this database connection. + */ + static object sqlite3_wal_hook( + sqlite3 db, /* Attach the hook to this db handle */ + dxWalCallback xCallback, //int(*xCallback)(void *, sqlite3*, const char*, int), + object pArg /* First argument passed to xCallback() */ + ) { #if !SQLITE_OMIT_WAL void *pRet; sqlite3_mutex_enter(db.mutex); @@ -1706,26 +1534,25 @@ static object sqlite3_wal_hook( sqlite3_mutex_leave(db.mutex); return pRet; #else - return null; + return null; #endif - } + } - /* - ** Checkpoint database zDb. - */ - static int sqlite3_wal_checkpoint_v2( - sqlite3 db, /* Database handle */ - string zDb, /* Name of attached database (or NULL) */ - int eMode, /* SQLITE_CHECKPOINT_* value */ - out int pnLog, /* OUT: Size of WAL log in frames */ - out int pnCkpt /* OUT: Total number of frames checkpointed */ - ) - { + /* + ** Checkpoint database zDb. + */ + static int sqlite3_wal_checkpoint_v2( + sqlite3 db, /* Database handle */ + string zDb, /* Name of attached database (or NULL) */ + int eMode, /* SQLITE_CHECKPOINT_* value */ + out int pnLog, /* OUT: Size of WAL log in frames */ + out int pnCkpt /* OUT: Total number of frames checkpointed */ + ) { #if SQLITE_OMIT_WAL - pnLog = 0; - pnCkpt = 0; - return SQLITE_OK; + pnLog = 0; + pnCkpt = 0; + return SQLITE_OK; #else int rc; /* Return code */ int iDb = SQLITE_MAX_ATTACHED; /* sqlite3.aDb[] index of db to checkpoint */ @@ -1756,19 +1583,18 @@ static int sqlite3_wal_checkpoint_v2( sqlite3_mutex_leave(db->mutex); return rc; #endif - } + } - /* - ** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points - ** to contains a zero-length string, all attached databases are - ** checkpointed. - */ - static int sqlite3_wal_checkpoint( sqlite3 db, string zDb ) - { - int dummy; - return sqlite3_wal_checkpoint_v2( db, zDb, SQLITE_CHECKPOINT_PASSIVE, out dummy, out dummy ); - } + /* + ** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points + ** to contains a zero-length string, all attached databases are + ** checkpointed. + */ + static int sqlite3_wal_checkpoint(sqlite3 db, string zDb) { + int dummy; + return sqlite3_wal_checkpoint_v2(db, zDb, SQLITE_CHECKPOINT_PASSIVE, out dummy, out dummy); + } #if !SQLITE_OMIT_WAL /* @@ -1813,81 +1639,76 @@ int sqlite3Checkpoint(sqlite3 db, int iDb, int eMode, int *pnLog, int *pnCkpt){ return (rc==SQLITE_OK && bBusy) ? SQLITE_BUSY : rc; } -#endif //* SQLITE_OMIT_WAL */ - - /* - /* - ** This function returns true if main-memory should be used instead of - ** a temporary file for transient pager files and statement journals. - ** The value returned depends on the value of db->temp_store (runtime - ** parameter) and the compile time value of SQLITE_TEMP_STORE. The - ** following table describes the relationship between these two values - ** and this functions return value. - ** - ** SQLITE_TEMP_STORE db->temp_store Location of temporary database - ** ----------------- -------------- ------------------------------ - ** 0 any file (return 0) - ** 1 1 file (return 0) - ** 1 2 memory (return 1) - ** 1 0 file (return 0) - ** 2 1 file (return 0) - ** 2 2 memory (return 1) - ** 2 0 memory (return 1) - ** 3 any memory (return 1) - */ - static bool sqlite3TempInMemory( sqlite3 db ) - { - //#if SQLITE_TEMP_STORE==1 - if ( SQLITE_TEMP_STORE == 1 ) - return ( db.temp_store == 2 ); - //#endif - //#if SQLITE_TEMP_STORE==2 - if ( SQLITE_TEMP_STORE == 2 ) - return ( db.temp_store != 1 ); - //#endif - //#if SQLITE_TEMP_STORE==3 - if ( SQLITE_TEMP_STORE == 3 ) - return true; - //#endif - //#if SQLITE_TEMP_STORE<1 || SQLITE_TEMP_STORE>3 - if ( SQLITE_TEMP_STORE < 1 || SQLITE_TEMP_STORE > 3 ) - return false; - //#endif - return false; - } +#endif //* SQLITE_OMIT_WAL */ - /* - ** Return UTF-8 encoded English language explanation of the most recent - ** error. - */ - public static string sqlite3_errmsg( sqlite3 db ) - { - string z; - if ( db == null ) - { - return sqlite3ErrStr( SQLITE_NOMEM ); - } - if ( !sqlite3SafetyCheckSickOrOk( db ) ) - { - return sqlite3ErrStr( SQLITE_MISUSE_BKPT() ); - } - sqlite3_mutex_enter( db.mutex ); - //if ( db.mallocFailed != 0 ) - //{ - // z = sqlite3ErrStr( SQLITE_NOMEM ); - //} - //else - { - z = sqlite3_value_text( db.pErr ); - //Debug.Assert( 0 == db.mallocFailed ); - if ( String.IsNullOrEmpty( z ) ) - { - z = sqlite3ErrStr( db.errCode ); + /* + /* + ** This function returns true if main-memory should be used instead of + ** a temporary file for transient pager files and statement journals. + ** The value returned depends on the value of db->temp_store (runtime + ** parameter) and the compile time value of SQLITE_TEMP_STORE. The + ** following table describes the relationship between these two values + ** and this functions return value. + ** + ** SQLITE_TEMP_STORE db->temp_store Location of temporary database + ** ----------------- -------------- ------------------------------ + ** 0 any file (return 0) + ** 1 1 file (return 0) + ** 1 2 memory (return 1) + ** 1 0 file (return 0) + ** 2 1 file (return 0) + ** 2 2 memory (return 1) + ** 2 0 memory (return 1) + ** 3 any memory (return 1) + */ + static bool sqlite3TempInMemory(sqlite3 db) { + //#if SQLITE_TEMP_STORE==1 + if (SQLITE_TEMP_STORE == 1) + return (db.temp_store == 2); + //#endif + //#if SQLITE_TEMP_STORE==2 + if (SQLITE_TEMP_STORE == 2) + return (db.temp_store != 1); + //#endif + //#if SQLITE_TEMP_STORE==3 + if (SQLITE_TEMP_STORE == 3) + return true; + //#endif + //#if SQLITE_TEMP_STORE<1 || SQLITE_TEMP_STORE>3 + if (SQLITE_TEMP_STORE < 1 || SQLITE_TEMP_STORE > 3) + return false; + //#endif + return false; + } + + /* + ** Return UTF-8 encoded English language explanation of the most recent + ** error. + */ + public static string sqlite3_errmsg(sqlite3 db) { + string z; + if (db == null) { + return sqlite3ErrStr(SQLITE_NOMEM); + } + if (!sqlite3SafetyCheckSickOrOk(db)) { + return sqlite3ErrStr(SQLITE_MISUSE_BKPT()); + } + sqlite3_mutex_enter(db.mutex); + //if ( db.mallocFailed != 0 ) + //{ + // z = sqlite3ErrStr( SQLITE_NOMEM ); + //} + //else + { + z = sqlite3_value_text(db.pErr); + //Debug.Assert( 0 == db.mallocFailed ); + if (String.IsNullOrEmpty(z)) { + z = sqlite3ErrStr(db.errCode); + } + } + sqlite3_mutex_leave(db.mutex); + return z; } - } - sqlite3_mutex_leave( db.mutex ); - return z; - } #if !SQLITE_OMIT_UTF16 /* @@ -1936,128 +1757,113 @@ public static string sqlite3_errmsg( sqlite3 db ) } #endif // * SQLITE_OMIT_UTF16 */ - /* -** Return the most recent error code generated by an SQLite routine. If NULL is -** passed to this function, we assume a malloc() failed during sqlite3_open(). -*/ - static public int sqlite3_errcode( sqlite3 db ) - { - if ( db != null && !sqlite3SafetyCheckSickOrOk( db ) ) - { - return SQLITE_MISUSE_BKPT(); - } - if ( null == db /*|| db.mallocFailed != 0 */ ) - { - return SQLITE_NOMEM; - } - return db.errCode & db.errMask; - } - static int sqlite3_extended_errcode( sqlite3 db ) - { - if ( db != null && !sqlite3SafetyCheckSickOrOk( db ) ) - { - return SQLITE_MISUSE_BKPT(); - } - if ( null == db /*|| db.mallocFailed != 0 */ ) - { - return SQLITE_NOMEM; - } - return db.errCode; - } - /* - ** Create a new collating function for database "db". The name is zName - ** and the encoding is enc. + /* + ** Return the most recent error code generated by an SQLite routine. If NULL is + ** passed to this function, we assume a malloc() failed during sqlite3_open(). */ - static int createCollation( - sqlite3 db, - string zName, - u8 enc, - u8 collType, - object pCtx, - dxCompare xCompare,//)(void*,int,const void*,int,const void), - dxDelCollSeq xDel//)(void) - ) - { - CollSeq pColl; - int enc2; - int nName = sqlite3Strlen30( zName ); - - Debug.Assert( sqlite3_mutex_held( db.mutex ) ); - - /* If SQLITE_UTF16 is specified as the encoding type, transform this - ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the - ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally. - */ - enc2 = enc; - testcase( enc2 == SQLITE_UTF16 ); - testcase( enc2 == SQLITE_UTF16_ALIGNED ); - if ( enc2 == SQLITE_UTF16 || enc2 == SQLITE_UTF16_ALIGNED ) - { - enc2 = SQLITE_UTF16NATIVE; - } - if ( enc2 < SQLITE_UTF8 || enc2 > SQLITE_UTF16BE ) - { - return SQLITE_MISUSE_BKPT(); - } - - /* Check if this call is removing or replacing an existing collation - ** sequence. If so, and there are active VMs, return busy. If there - ** are no active VMs, invalidate any pre-compiled statements. - */ - pColl = sqlite3FindCollSeq( db, (u8)enc2, zName, 0 ); - if ( pColl != null && pColl.xCmp != null ) - { - if ( db.activeVdbeCnt != 0 ) - { - sqlite3Error( db, SQLITE_BUSY, - "unable to delete/modify collation sequence due to active statements" ); - return SQLITE_BUSY; - } - sqlite3ExpirePreparedStatements( db ); - - /* If collation sequence pColl was created directly by a call to - ** sqlite3_create_collation, and not generated by synthCollSeq(), - ** then any copies made by synthCollSeq() need to be invalidated. - ** Also, collation destructor - CollSeq.xDel() - function may need - ** to be called. - */ - if ( ( pColl.enc & ~SQLITE_UTF16_ALIGNED ) == enc2 ) - { - CollSeq[] aColl = sqlite3HashFind( db.aCollSeq, zName, nName, (CollSeq[])null ); - int j; - for ( j = 0; j < 3; j++ ) - { - CollSeq p = aColl[j]; - if ( p.enc == pColl.enc ) - { - if ( p.xDel != null ) - { - p.xDel( ref p.pUser ); - } - p.xCmp = null; + static public int sqlite3_errcode(sqlite3 db) { + if (db != null && !sqlite3SafetyCheckSickOrOk(db)) { + return SQLITE_MISUSE_BKPT(); + } + if (null == db /*|| db.mallocFailed != 0 */ ) { + return SQLITE_NOMEM; } - } + return db.errCode & db.errMask; } - } + static int sqlite3_extended_errcode(sqlite3 db) { + if (db != null && !sqlite3SafetyCheckSickOrOk(db)) { + return SQLITE_MISUSE_BKPT(); + } + if (null == db /*|| db.mallocFailed != 0 */ ) { + return SQLITE_NOMEM; + } + return db.errCode; + } + /* + ** Create a new collating function for database "db". The name is zName + ** and the encoding is enc. + */ + static int createCollation( + sqlite3 db, + string zName, + u8 enc, + u8 collType, + object pCtx, + dxCompare xCompare,//)(void*,int,const void*,int,const void), + dxDelCollSeq xDel//)(void) + ) { + CollSeq pColl; + int enc2; + int nName = sqlite3Strlen30(zName); + + Debug.Assert(sqlite3_mutex_held(db.mutex)); + + /* If SQLITE_UTF16 is specified as the encoding type, transform this + ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the + ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally. + */ + enc2 = enc; + testcase(enc2 == SQLITE_UTF16); + testcase(enc2 == SQLITE_UTF16_ALIGNED); + if (enc2 == SQLITE_UTF16 || enc2 == SQLITE_UTF16_ALIGNED) { + enc2 = SQLITE_UTF16NATIVE; + } + if (enc2 < SQLITE_UTF8 || enc2 > SQLITE_UTF16BE) { + return SQLITE_MISUSE_BKPT(); + } - pColl = sqlite3FindCollSeq( db, (u8)enc2, zName, 1 ); - //if ( pColl == null ) - // return SQLITE_NOMEM; - pColl.xCmp = xCompare; - pColl.pUser = pCtx; - pColl.xDel = xDel; - pColl.enc = (u8)( enc2 | ( enc & SQLITE_UTF16_ALIGNED ) ); - pColl.type = collType; - sqlite3Error( db, SQLITE_OK, 0 ); - return SQLITE_OK; - } + /* Check if this call is removing or replacing an existing collation + ** sequence. If so, and there are active VMs, return busy. If there + ** are no active VMs, invalidate any pre-compiled statements. + */ + pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, 0); + if (pColl != null && pColl.xCmp != null) { + if (db.activeVdbeCnt != 0) { + sqlite3Error(db, SQLITE_BUSY, + "unable to delete/modify collation sequence due to active statements"); + return SQLITE_BUSY; + } + sqlite3ExpirePreparedStatements(db); + + /* If collation sequence pColl was created directly by a call to + ** sqlite3_create_collation, and not generated by synthCollSeq(), + ** then any copies made by synthCollSeq() need to be invalidated. + ** Also, collation destructor - CollSeq.xDel() - function may need + ** to be called. + */ + if ((pColl.enc & ~SQLITE_UTF16_ALIGNED) == enc2) { + CollSeq[] aColl = sqlite3HashFind(db.aCollSeq, zName, nName, (CollSeq[])null); + int j; + for (j = 0; j < 3; j++) { + CollSeq p = aColl[j]; + if (p.enc == pColl.enc) { + if (p.xDel != null) { + p.xDel(ref p.pUser); + } + p.xCmp = null; + } + } + } + } - /* - ** This array defines hard upper bounds on limit values. The - ** initializer must be kept in sync with the SQLITE_LIMIT_* - ** #defines in sqlite3.h. - */ - static int[] aHardLimit = new int[] { + pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, 1); + //if ( pColl == null ) + // return SQLITE_NOMEM; + pColl.xCmp = xCompare; + pColl.pUser = pCtx; + pColl.xDel = xDel; + pColl.enc = (u8)(enc2 | (enc & SQLITE_UTF16_ALIGNED)); + pColl.type = collType; + sqlite3Error(db, SQLITE_OK, 0); + return SQLITE_OK; + } + + /* + ** This array defines hard upper bounds on limit values. The + ** initializer must be kept in sync with the SQLITE_LIMIT_* + ** #defines in sqlite3.h. + */ + static int[] aHardLimit = new int[] { SQLITE_MAX_LENGTH, SQLITE_MAX_SQL_LENGTH, SQLITE_MAX_COLUMN, @@ -2071,455 +1877,435 @@ static int createCollation( SQLITE_MAX_TRIGGER_DEPTH, }; - /* - ** Make sure the hard limits are set to reasonable values - */ - //#if SQLITE_MAX_LENGTH<100 - //# error SQLITE_MAX_LENGTH must be at least 100 - //#endif - //#if SQLITE_MAX_SQL_LENGTH<100 - //# error SQLITE_MAX_SQL_LENGTH must be at least 100 - //#endif - //#if SQLITE_MAX_SQL_LENGTH>SQLITE_MAX_LENGTH - //# error SQLITE_MAX_SQL_LENGTH must not be greater than SQLITE_MAX_LENGTH - //#endif - //#if SQLITE_MAX_COMPOUND_SELECT<2 - //# error SQLITE_MAX_COMPOUND_SELECT must be at least 2 - //#endif - //#if SQLITE_MAX_VDBE_OP<40 - //# error SQLITE_MAX_VDBE_OP must be at least 40 - //#endif - //#if SQLITE_MAX_FUNCTION_ARG<0 || SQLITE_MAX_FUNCTION_ARG>1000 - //# error SQLITE_MAX_FUNCTION_ARG must be between 0 and 1000 - //#endif - //#if SQLITE_MAX_ATTACHED<0 || SQLITE_MAX_ATTACHED>62 - //# error SQLITE_MAX_ATTACHED must be between 0 and 62 - //#endif - //#if SQLITE_MAX_LIKE_PATTERN_LENGTH<1 - //# error SQLITE_MAX_LIKE_PATTERN_LENGTH must be at least 1 - //#endif - //#if SQLITE_MAX_COLUMN>32767 - //# error SQLITE_MAX_COLUMN must not exceed 32767 - //#endif - //#if SQLITE_MAX_TRIGGER_DEPTH<1 - //# error SQLITE_MAX_TRIGGER_DEPTH must be at least 1 - //#endif - - /* - ** Change the value of a limit. Report the old value. - ** If an invalid limit index is supplied, report -1. - ** Make no changes but still report the old value if the - ** new limit is negative. - ** - ** A new lower limit does not shrink existing constructs. - ** It merely prevents new constructs that exceed the limit - ** from forming. - */ - static int sqlite3_limit( sqlite3 db, int limitId, int newLimit ) - { - int oldLimit; - - - /* EVIDENCE-OF: R-30189-54097 For each limit category SQLITE_LIMIT_NAME - ** there is a hard upper bound set at compile-time by a C preprocessor - ** macro called SQLITE_MAX_NAME. (The "_LIMIT_" in the name is changed to - ** "_MAX_".) - */ - Debug.Assert( aHardLimit[SQLITE_LIMIT_LENGTH] == SQLITE_MAX_LENGTH ); - Debug.Assert( aHardLimit[SQLITE_LIMIT_SQL_LENGTH] == SQLITE_MAX_SQL_LENGTH ); - Debug.Assert( aHardLimit[SQLITE_LIMIT_COLUMN] == SQLITE_MAX_COLUMN ); - Debug.Assert( aHardLimit[SQLITE_LIMIT_EXPR_DEPTH] == SQLITE_MAX_EXPR_DEPTH ); - Debug.Assert( aHardLimit[SQLITE_LIMIT_COMPOUND_SELECT] == SQLITE_MAX_COMPOUND_SELECT ); - Debug.Assert( aHardLimit[SQLITE_LIMIT_VDBE_OP] == SQLITE_MAX_VDBE_OP ); - Debug.Assert( aHardLimit[SQLITE_LIMIT_FUNCTION_ARG] == SQLITE_MAX_FUNCTION_ARG ); - Debug.Assert( aHardLimit[SQLITE_LIMIT_ATTACHED] == SQLITE_MAX_ATTACHED ); - Debug.Assert( aHardLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] == - SQLITE_MAX_LIKE_PATTERN_LENGTH ); - Debug.Assert( aHardLimit[SQLITE_LIMIT_VARIABLE_NUMBER] == SQLITE_MAX_VARIABLE_NUMBER ); - Debug.Assert( aHardLimit[SQLITE_LIMIT_TRIGGER_DEPTH] == SQLITE_MAX_TRIGGER_DEPTH ); - Debug.Assert( SQLITE_LIMIT_TRIGGER_DEPTH == ( SQLITE_N_LIMIT - 1 ) ); - - - if ( limitId < 0 || limitId >= SQLITE_N_LIMIT ) - { - return -1; - } - oldLimit = db.aLimit[limitId]; - if ( newLimit >= 0 ) /* IMP: R-52476-28732 */ - { - if ( newLimit > aHardLimit[limitId] ) - { - newLimit = aHardLimit[limitId]; /* IMP: R-51463-25634 */ - } - db.aLimit[limitId] = newLimit; - } - return oldLimit; /* IMP: R-53341-35419 */ - } - - class OpenMode { - public string z; - public int mode; + /* + ** Make sure the hard limits are set to reasonable values + */ + //#if SQLITE_MAX_LENGTH<100 + //# error SQLITE_MAX_LENGTH must be at least 100 + //#endif + //#if SQLITE_MAX_SQL_LENGTH<100 + //# error SQLITE_MAX_SQL_LENGTH must be at least 100 + //#endif + //#if SQLITE_MAX_SQL_LENGTH>SQLITE_MAX_LENGTH + //# error SQLITE_MAX_SQL_LENGTH must not be greater than SQLITE_MAX_LENGTH + //#endif + //#if SQLITE_MAX_COMPOUND_SELECT<2 + //# error SQLITE_MAX_COMPOUND_SELECT must be at least 2 + //#endif + //#if SQLITE_MAX_VDBE_OP<40 + //# error SQLITE_MAX_VDBE_OP must be at least 40 + //#endif + //#if SQLITE_MAX_FUNCTION_ARG<0 || SQLITE_MAX_FUNCTION_ARG>1000 + //# error SQLITE_MAX_FUNCTION_ARG must be between 0 and 1000 + //#endif + //#if SQLITE_MAX_ATTACHED<0 || SQLITE_MAX_ATTACHED>62 + //# error SQLITE_MAX_ATTACHED must be between 0 and 62 + //#endif + //#if SQLITE_MAX_LIKE_PATTERN_LENGTH<1 + //# error SQLITE_MAX_LIKE_PATTERN_LENGTH must be at least 1 + //#endif + //#if SQLITE_MAX_COLUMN>32767 + //# error SQLITE_MAX_COLUMN must not exceed 32767 + //#endif + //#if SQLITE_MAX_TRIGGER_DEPTH<1 + //# error SQLITE_MAX_TRIGGER_DEPTH must be at least 1 + //#endif + + /* + ** Change the value of a limit. Report the old value. + ** If an invalid limit index is supplied, report -1. + ** Make no changes but still report the old value if the + ** new limit is negative. + ** + ** A new lower limit does not shrink existing constructs. + ** It merely prevents new constructs that exceed the limit + ** from forming. + */ + static int sqlite3_limit(sqlite3 db, int limitId, int newLimit) { + int oldLimit; + + + /* EVIDENCE-OF: R-30189-54097 For each limit category SQLITE_LIMIT_NAME + ** there is a hard upper bound set at compile-time by a C preprocessor + ** macro called SQLITE_MAX_NAME. (The "_LIMIT_" in the name is changed to + ** "_MAX_".) + */ + Debug.Assert(aHardLimit[SQLITE_LIMIT_LENGTH] == SQLITE_MAX_LENGTH); + Debug.Assert(aHardLimit[SQLITE_LIMIT_SQL_LENGTH] == SQLITE_MAX_SQL_LENGTH); + Debug.Assert(aHardLimit[SQLITE_LIMIT_COLUMN] == SQLITE_MAX_COLUMN); + Debug.Assert(aHardLimit[SQLITE_LIMIT_EXPR_DEPTH] == SQLITE_MAX_EXPR_DEPTH); + Debug.Assert(aHardLimit[SQLITE_LIMIT_COMPOUND_SELECT] == SQLITE_MAX_COMPOUND_SELECT); + Debug.Assert(aHardLimit[SQLITE_LIMIT_VDBE_OP] == SQLITE_MAX_VDBE_OP); + Debug.Assert(aHardLimit[SQLITE_LIMIT_FUNCTION_ARG] == SQLITE_MAX_FUNCTION_ARG); + Debug.Assert(aHardLimit[SQLITE_LIMIT_ATTACHED] == SQLITE_MAX_ATTACHED); + Debug.Assert(aHardLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] == + SQLITE_MAX_LIKE_PATTERN_LENGTH); + Debug.Assert(aHardLimit[SQLITE_LIMIT_VARIABLE_NUMBER] == SQLITE_MAX_VARIABLE_NUMBER); + Debug.Assert(aHardLimit[SQLITE_LIMIT_TRIGGER_DEPTH] == SQLITE_MAX_TRIGGER_DEPTH); + Debug.Assert(SQLITE_LIMIT_TRIGGER_DEPTH == (SQLITE_N_LIMIT - 1)); + + + if (limitId < 0 || limitId >= SQLITE_N_LIMIT) { + return -1; + } + oldLimit = db.aLimit[limitId]; + if (newLimit >= 0) /* IMP: R-52476-28732 */ + { + if (newLimit > aHardLimit[limitId]) { + newLimit = aHardLimit[limitId]; /* IMP: R-51463-25634 */ + } + db.aLimit[limitId] = newLimit; + } + return oldLimit; /* IMP: R-53341-35419 */ + } - public OpenMode(string z, int mode) - { - this.z=z; - this.mode=mode; - } - } - /* -** This function is used to parse both URIs and non-URI filenames passed by the -** user to API functions sqlite3_open() or sqlite3_open_v2(), and for database -** URIs specified as part of ATTACH statements. -** -** The first argument to this function is the name of the VFS to use (or -** a NULL to signify the default VFS) if the URI does not contain a "vfs=xxx" -** query parameter. The second argument contains the URI (or non-URI filename) -** itself. When this function is called the *pFlags variable should contain -** the default flags to open the database handle with. The value stored in -** *pFlags may be updated before returning if the URI filename contains -** "cache=xxx" or "mode=xxx" query parameters. -** -** If successful, SQLITE_OK is returned. In this case *ppVfs is set to point to -** the VFS that should be used to open the database file. *pzFile is set to -** point to a buffer containing the name of the file to open. It is the -** responsibility of the caller to eventually call sqlite3_free() to release -** this buffer. -** -** If an error occurs, then an SQLite error code is returned and *pzErrMsg -** may be set to point to a buffer containing an English language error -** message. It is the responsibility of the caller to eventually release -** this buffer by calling sqlite3_free(). -*/ -static int sqlite3ParseUri( - string zDefaultVfs, /* VFS to use if no "vfs=xxx" query option */ - string zUri, /* Nul-terminated URI to parse */ - ref int pFlags, /* IN/OUT: SQLITE_OPEN_XXX flags */ - ref sqlite3_vfs ppVfs, /* OUT: VFS to use */ - ref string pzFile, /* OUT: Filename component of URI */ - ref string pzErrMsg /* OUT: Error message (if rc!=SQLITE_OK) */ -){ - int rc = SQLITE_OK; - int flags = pFlags; - string zVfs = zDefaultVfs; - StringBuilder zFile = null; - char c; - int nUri = sqlite3Strlen30(zUri); - pzErrMsg = null; - ppVfs = null; - - if( ((flags & SQLITE_OPEN_URI) != 0 || sqlite3GlobalConfig.bOpenUri) - && nUri>=5 && memcmp(zUri, "file:", 5)==0 - ){ - string zOpt; - int eState; /* Parser state when parsing URI */ - int iIn; /* Input character index */ - //int iOut = 0; /* Output character index */ - int nByte = nUri+2; /* Bytes of space to allocate */ - - /* Make sure the SQLITE_OPEN_URI flag is set to indicate to the VFS xOpen - ** method that there may be extra parameters following the file-name. */ - flags |= SQLITE_OPEN_URI; - - for ( iIn = 0; iIn < nUri; iIn++ ) - nByte += ( zUri[iIn] == '&' ) ? 1 : 0; - //zFile = sqlite3_malloc(nByte); - //if( null==zFile ) return SQLITE_NOMEM; - zFile = new StringBuilder( nByte ); - - /* Discard the scheme and authority segments of the URI. */ - if( zUri[5]=='/' && zUri[6]=='/' ){ - iIn = 7; - while ( iIn < nUri && zUri[iIn] != '/' ) - iIn++; - - if ( iIn != 7 && ( iIn != 16 || !string.Equals("localhost", zUri.Substring( 7, 9 ), StringComparison.OrdinalIgnoreCase)) )//memcmp("localhost", &zUri[7], 9)) ) - { - pzErrMsg = sqlite3_mprintf("invalid uri authority: %.*s", - iIn-7, zUri.Substring(7)); - rc = SQLITE_ERROR; - goto parse_uri_out; - } - }else{ - iIn = 5; - } + class OpenMode { + public string z; + public int mode; - /* Copy the filename and any query parameters into the zFile buffer. - ** Decode %HH escape codes along the way. + public OpenMode(string z, int mode) { + this.z = z; + this.mode = mode; + } + } + /* + ** This function is used to parse both URIs and non-URI filenames passed by the + ** user to API functions sqlite3_open() or sqlite3_open_v2(), and for database + ** URIs specified as part of ATTACH statements. ** - ** Within this loop, variable eState may be set to 0, 1 or 2, depending - ** on the parsing context. As follows: + ** The first argument to this function is the name of the VFS to use (or + ** a NULL to signify the default VFS) if the URI does not contain a "vfs=xxx" + ** query parameter. The second argument contains the URI (or non-URI filename) + ** itself. When this function is called the *pFlags variable should contain + ** the default flags to open the database handle with. The value stored in + ** *pFlags may be updated before returning if the URI filename contains + ** "cache=xxx" or "mode=xxx" query parameters. ** - ** 0: Parsing file-name. - ** 1: Parsing name section of a name=value query parameter. - ** 2: Parsing value section of a name=value query parameter. + ** If successful, SQLITE_OK is returned. In this case *ppVfs is set to point to + ** the VFS that should be used to open the database file. *pzFile is set to + ** point to a buffer containing the name of the file to open. It is the + ** responsibility of the caller to eventually call sqlite3_free() to release + ** this buffer. + ** + ** If an error occurs, then an SQLite error code is returned and *pzErrMsg + ** may be set to point to a buffer containing an English language error + ** message. It is the responsibility of the caller to eventually release + ** this buffer by calling sqlite3_free(). */ - eState = 0; - while ( iIn < nUri&& ( c = zUri[iIn] ) != 0 && c != '#' ) - { - iIn++; - if( c=='%' - && sqlite3Isxdigit(zUri[iIn]) - && sqlite3Isxdigit(zUri[iIn+1]) - ){ - int octet = (sqlite3HexToInt(zUri[iIn++]) << 4); - octet += sqlite3HexToInt(zUri[iIn++]); - - Debug.Assert( octet >= 0 && octet < 256 ); - if ( octet == 0 ) - { - /* This branch is taken when "%00" appears within the URI. In this - ** case we ignore all text in the remainder of the path, name or - ** value currently being parsed. So ignore the current character - ** and skip to the next "?", "=" or "&", as appropriate. */ - while ( iIn < nUri && ( c = zUri[iIn] ) != 0 && c != '#' - && (eState!=0 || c!='?') - && (eState!=1 || (c!='=' && c!='&')) - && (eState!=2 || c!='&') - ){ - iIn++; - } - continue; - } - c = (char)octet; - }else if( eState==1 && (c=='&' || c=='=') ){ - if ( zFile[zFile.Length-1] == '\0' ) - { - /* An empty option name. Ignore this option altogether. */ - while( zUri[iIn] != '\0' && zUri[iIn]!='#' && zUri[iIn-1]!='&' ) iIn++; - continue; - } - if( c=='&' ){ - zFile.Append('\0');//[iOut++] = '\0'; - }else{ - eState = 2; - } - c = '\0'; - }else if( (eState==0 && c=='?') || (eState==2 && c=='&') ){ - c = '\0'; - eState = 1; - } - zFile.Append(c);// zFile[iOut++] = c; - } - if ( eState == 1 ) - zFile.Append( '\0' );//[iOut++] = '\0'; - zFile.Append( '\0' );//[iOut++] = '\0'; - zFile.Append( '\0' );//[iOut++] = '\0'; - - /* Check if there were any options specified that should be interpreted - ** here. Options that are interpreted here include "vfs" and those that - ** correspond to flags that may be passed to the sqlite3_open_v2() - ** method. */ - zOpt = zFile.ToString().Substring(sqlite3Strlen30( zFile ) + 1); - while( zOpt.Length>0 ){ - int nOpt = sqlite3Strlen30(zOpt); - string zVal = zOpt.Substring( nOpt );//zOpt[nOpt + 1]; - int nVal = sqlite3Strlen30(zVal); - - if( nOpt==3 && memcmp("vfs", zOpt, 3)==0 ){ - zVfs = zVal; - }else{ - OpenMode[] aMode = null; - string zModeType = ""; - int mask = 0; - int limit = 0; - - if( nOpt==5 && memcmp("cache", zOpt, 5)==0 ){ - OpenMode[] aCacheMode = new OpenMode[] { + static int sqlite3ParseUri( + string zDefaultVfs, /* VFS to use if no "vfs=xxx" query option */ + string zUri, /* Nul-terminated URI to parse */ + ref int pFlags, /* IN/OUT: SQLITE_OPEN_XXX flags */ + ref sqlite3_vfs ppVfs, /* OUT: VFS to use */ + ref string pzFile, /* OUT: Filename component of URI */ + ref string pzErrMsg /* OUT: Error message (if rc!=SQLITE_OK) */ + ) { + int rc = SQLITE_OK; + int flags = pFlags; + string zVfs = zDefaultVfs; + StringBuilder zFile = null; + char c; + int nUri = sqlite3Strlen30(zUri); + pzErrMsg = null; + ppVfs = null; + + if (((flags & SQLITE_OPEN_URI) != 0 || sqlite3GlobalConfig.bOpenUri) + && nUri >= 5 && memcmp(zUri, "file:", 5) == 0 + ) { + string zOpt; + int eState; /* Parser state when parsing URI */ + int iIn; /* Input character index */ + //int iOut = 0; /* Output character index */ + int nByte = nUri + 2; /* Bytes of space to allocate */ + + /* Make sure the SQLITE_OPEN_URI flag is set to indicate to the VFS xOpen + ** method that there may be extra parameters following the file-name. */ + flags |= SQLITE_OPEN_URI; + + for (iIn = 0; iIn < nUri; iIn++) + nByte += (zUri[iIn] == '&') ? 1 : 0; + //zFile = sqlite3_malloc(nByte); + //if( null==zFile ) return SQLITE_NOMEM; + zFile = new StringBuilder(nByte); + + /* Discard the scheme and authority segments of the URI. */ + if (zUri[5] == '/' && zUri[6] == '/') { + iIn = 7; + while (iIn < nUri && zUri[iIn] != '/') + iIn++; + + if (iIn != 7 && (iIn != 16 || !string.Equals("localhost", zUri.Substring(7, 9), StringComparison.OrdinalIgnoreCase)))//memcmp("localhost", &zUri[7], 9)) ) + { + pzErrMsg = sqlite3_mprintf("invalid uri authority: %.*s", + iIn - 7, zUri.Substring(7)); + rc = SQLITE_ERROR; + goto parse_uri_out; + } + } else { + iIn = 5; + } + + /* Copy the filename and any query parameters into the zFile buffer. + ** Decode %HH escape codes along the way. + ** + ** Within this loop, variable eState may be set to 0, 1 or 2, depending + ** on the parsing context. As follows: + ** + ** 0: Parsing file-name. + ** 1: Parsing name section of a name=value query parameter. + ** 2: Parsing value section of a name=value query parameter. + */ + eState = 0; + while (iIn < nUri && (c = zUri[iIn]) != 0 && c != '#') { + iIn++; + if (c == '%' + && sqlite3Isxdigit(zUri[iIn]) + && sqlite3Isxdigit(zUri[iIn + 1]) + ) { + int octet = (sqlite3HexToInt(zUri[iIn++]) << 4); + octet += sqlite3HexToInt(zUri[iIn++]); + + Debug.Assert(octet >= 0 && octet < 256); + if (octet == 0) { + /* This branch is taken when "%00" appears within the URI. In this + ** case we ignore all text in the remainder of the path, name or + ** value currently being parsed. So ignore the current character + ** and skip to the next "?", "=" or "&", as appropriate. */ + while (iIn < nUri && (c = zUri[iIn]) != 0 && c != '#' + && (eState != 0 || c != '?') + && (eState != 1 || (c != '=' && c != '&')) + && (eState != 2 || c != '&') + ) { + iIn++; + } + continue; + } + c = (char)octet; + } else if (eState == 1 && (c == '&' || c == '=')) { + if (zFile[zFile.Length - 1] == '\0') { + /* An empty option name. Ignore this option altogether. */ + while (zUri[iIn] != '\0' && zUri[iIn] != '#' && zUri[iIn - 1] != '&') iIn++; + continue; + } + if (c == '&') { + zFile.Append('\0');//[iOut++] = '\0'; + } else { + eState = 2; + } + c = '\0'; + } else if ((eState == 0 && c == '?') || (eState == 2 && c == '&')) { + c = '\0'; + eState = 1; + } + zFile.Append(c);// zFile[iOut++] = c; + } + if (eState == 1) + zFile.Append('\0');//[iOut++] = '\0'; + zFile.Append('\0');//[iOut++] = '\0'; + zFile.Append('\0');//[iOut++] = '\0'; + + /* Check if there were any options specified that should be interpreted + ** here. Options that are interpreted here include "vfs" and those that + ** correspond to flags that may be passed to the sqlite3_open_v2() + ** method. */ + zOpt = zFile.ToString().Substring(sqlite3Strlen30(zFile) + 1); + while (zOpt.Length > 0) { + int nOpt = sqlite3Strlen30(zOpt); + string zVal = zOpt.Substring(nOpt);//zOpt[nOpt + 1]; + int nVal = sqlite3Strlen30(zVal); + + if (nOpt == 3 && memcmp("vfs", zOpt, 3) == 0) { + zVfs = zVal; + } else { + OpenMode[] aMode = null; + string zModeType = ""; + int mask = 0; + int limit = 0; + + if (nOpt == 5 && memcmp("cache", zOpt, 5) == 0) { + OpenMode[] aCacheMode = new OpenMode[] { new OpenMode( "shared", SQLITE_OPEN_SHAREDCACHE ), new OpenMode( "private", SQLITE_OPEN_PRIVATECACHE ), new OpenMode( null, 0 ) }; - mask = SQLITE_OPEN_SHAREDCACHE|SQLITE_OPEN_PRIVATECACHE; - aMode = aCacheMode; - limit = mask; - zModeType = "cache"; - } - if( nOpt==4 && memcmp("mode", zOpt, 4)==0 ){ - OpenMode[] aOpenMode = new OpenMode[] { + mask = SQLITE_OPEN_SHAREDCACHE | SQLITE_OPEN_PRIVATECACHE; + aMode = aCacheMode; + limit = mask; + zModeType = "cache"; + } + if (nOpt == 4 && memcmp("mode", zOpt, 4) == 0) { + OpenMode[] aOpenMode = new OpenMode[] { new OpenMode( "ro", SQLITE_OPEN_READONLY ), - new OpenMode( "rw", SQLITE_OPEN_READWRITE ), + new OpenMode( "rw", SQLITE_OPEN_READWRITE ), new OpenMode( "rwc", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE ), new OpenMode( null, 0 ) }; - mask = SQLITE_OPEN_READONLY|SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE; - aMode = aOpenMode; - limit = mask & flags; - zModeType = "access"; - } - - if( aMode != null){ - int i; - int mode = 0; - for(i=0; aMode[i].z!= null; i++){ - string z = aMode[i].z; - if( nVal==sqlite3Strlen30(z) && 0==memcmp(zVal, z, nVal) ){ - mode = aMode[i].mode; - break; - } - } - if( mode==0 ){ - pzErrMsg = sqlite3_mprintf("no such %s mode: %s", zModeType, zVal); - rc = SQLITE_ERROR; - goto parse_uri_out; - } - if( mode>limit ){ - pzErrMsg = sqlite3_mprintf("%s mode not allowed: %s", - zModeType, zVal); - rc = SQLITE_PERM; - goto parse_uri_out; - } - flags = ((flags & ~mask) | mode); - } - } - - zOpt = zVal.Substring(nVal+1); - } + mask = SQLITE_OPEN_READONLY | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; + aMode = aOpenMode; + limit = mask & flags; + zModeType = "access"; + } + + if (aMode != null) { + int i; + int mode = 0; + for (i = 0; aMode[i].z != null; i++) { + string z = aMode[i].z; + if (nVal == sqlite3Strlen30(z) && 0 == memcmp(zVal, z, nVal)) { + mode = aMode[i].mode; + break; + } + } + if (mode == 0) { + pzErrMsg = sqlite3_mprintf("no such %s mode: %s", zModeType, zVal); + rc = SQLITE_ERROR; + goto parse_uri_out; + } + if (mode > limit) { + pzErrMsg = sqlite3_mprintf("%s mode not allowed: %s", + zModeType, zVal); + rc = SQLITE_PERM; + goto parse_uri_out; + } + flags = ((flags & ~mask) | mode); + } + } + + zOpt = zVal.Substring(nVal + 1); + } - }else{ - //zFile = sqlite3_malloc(nUri+2); - //if( null==zFile ) return SQLITE_NOMEM; - //memcpy(zFile, zUri, nUri); - zFile = zUri == null ? new StringBuilder() : new StringBuilder(zUri.Substring( 0, nUri )); - zFile.Append( '\0' );//[iOut++] = '\0'; - zFile.Append( '\0' );//[iOut++] = '\0'; - } + } else { + //zFile = sqlite3_malloc(nUri+2); + //if( null==zFile ) return SQLITE_NOMEM; + //memcpy(zFile, zUri, nUri); + zFile = zUri == null ? new StringBuilder() : new StringBuilder(zUri.Substring(0, nUri)); + zFile.Append('\0');//[iOut++] = '\0'; + zFile.Append('\0');//[iOut++] = '\0'; + } - ppVfs = sqlite3_vfs_find(zVfs); - if( ppVfs==null ){ - pzErrMsg = sqlite3_mprintf("no such vfs: %s", zVfs); - rc = SQLITE_ERROR; - } - parse_uri_out: - if( rc!=SQLITE_OK ){ - //sqlite3_free(zFile); - zFile = null; - } - pFlags = flags; - pzFile = zFile == null ? null : zFile.ToString().Substring( 0, sqlite3Strlen30( zFile.ToString() ) ); - return rc; -} + ppVfs = sqlite3_vfs_find(zVfs); + if (ppVfs == null) { + pzErrMsg = sqlite3_mprintf("no such vfs: %s", zVfs); + rc = SQLITE_ERROR; + } + parse_uri_out: + if (rc != SQLITE_OK) { + //sqlite3_free(zFile); + zFile = null; + } + pFlags = flags; + pzFile = zFile == null ? null : zFile.ToString().Substring(0, sqlite3Strlen30(zFile.ToString())); + return rc; + } - /* - ** This routine does the work of opening a database on behalf of - ** sqlite3_open() and sqlite3_open16(). The database filename "zFilename" - ** is UTF-8 encoded. - */ - static int openDatabase( - string zFilename, /* Database filename UTF-8 encoded */ - out sqlite3 ppDb, /* OUT: Returned database handle */ - int flags, /* Operational flags */ - string zVfs /* Name of the VFS to use */ - ) - { - sqlite3 db; /* Store allocated handle here */ - int rc; /* Return code */ - int isThreadsafe; /* True for threadsafe connections */ - string zOpen = ""; /* Filename argument to pass to BtreeOpen() */ - string zErrMsg = ""; /* Error message from sqlite3ParseUri() */ - - ppDb = null; + /* + ** This routine does the work of opening a database on behalf of + ** sqlite3_open() and sqlite3_open16(). The database filename "zFilename" + ** is UTF-8 encoded. + */ + static int openDatabase( + string zFilename, /* Database filename UTF-8 encoded */ + out sqlite3 ppDb, /* OUT: Returned database handle */ + int flags, /* Operational flags */ + string zVfs /* Name of the VFS to use */ + ) { + sqlite3 db; /* Store allocated handle here */ + int rc; /* Return code */ + int isThreadsafe; /* True for threadsafe connections */ + string zOpen = ""; /* Filename argument to pass to BtreeOpen() */ + string zErrMsg = ""; /* Error message from sqlite3ParseUri() */ + + ppDb = null; #if !SQLITE_OMIT_AUTOINIT - rc = sqlite3_initialize(); - if ( rc != 0 ) - return rc; + rc = sqlite3_initialize(); + if (rc != 0) + return rc; #endif - /* Only allow sensible combinations of bits in the flags argument. -** Throw an error if any non-sense combination is used. If we -** do not block illegal combinations here, it could trigger -** Debug.Assert() statements in deeper layers. Sensible combinations -** are: -** -** 1: SQLITE_OPEN_READONLY -** 2: SQLITE_OPEN_READWRITE -** 6: SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE -*/ - Debug.Assert( SQLITE_OPEN_READONLY == 0x01 ); - Debug.Assert( SQLITE_OPEN_READWRITE == 0x02 ); - Debug.Assert( SQLITE_OPEN_CREATE == 0x04 ); - testcase( ( 1 << ( flags & 7 ) ) == 0x02 ); /* READONLY */ - testcase( ( 1 << ( flags & 7 ) ) == 0x04 ); /* READWRITE */ - testcase( ( 1 << ( flags & 7 ) ) == 0x40 ); /* READWRITE | CREATE */ - if ( ( ( 1 << ( flags & 7 ) ) & 0x46 ) == 0 ) return SQLITE_MISUSE_BKPT(); - - if ( sqlite3GlobalConfig.bCoreMutex == false ) - { - isThreadsafe = 0; - } - else if ( ( flags & SQLITE_OPEN_NOMUTEX ) != 0 ) - { - isThreadsafe = 0; - } - else if ( ( flags & SQLITE_OPEN_FULLMUTEX ) != 0 ) - { - isThreadsafe = 1; - } - else - { - isThreadsafe = sqlite3GlobalConfig.bFullMutex ? 1 : 0; - } - if ( ( flags & SQLITE_OPEN_PRIVATECACHE ) != 0 ) - { - flags &= ~SQLITE_OPEN_SHAREDCACHE; - } - else if ( sqlite3GlobalConfig.sharedCacheEnabled ) - { - flags |= SQLITE_OPEN_SHAREDCACHE; - } - - /* Remove harmful bits from the flags parameter + /* Only allow sensible combinations of bits in the flags argument. + ** Throw an error if any non-sense combination is used. If we + ** do not block illegal combinations here, it could trigger + ** Debug.Assert() statements in deeper layers. Sensible combinations + ** are: ** - ** The SQLITE_OPEN_NOMUTEX and SQLITE_OPEN_FULLMUTEX flags were - ** dealt with in the previous code block. Besides these, the only - ** valid input flags for sqlite3_open_v2() are SQLITE_OPEN_READONLY, - ** SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE, SQLITE_OPEN_SHAREDCACHE, - ** SQLITE_OPEN_PRIVATECACHE, and some reserved bits. Silently mask - ** off all other flags. + ** 1: SQLITE_OPEN_READONLY + ** 2: SQLITE_OPEN_READWRITE + ** 6: SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE */ - flags &= ~( SQLITE_OPEN_DELETEONCLOSE | - SQLITE_OPEN_EXCLUSIVE | - SQLITE_OPEN_MAIN_DB | - SQLITE_OPEN_TEMP_DB | - SQLITE_OPEN_TRANSIENT_DB | - SQLITE_OPEN_MAIN_JOURNAL | - SQLITE_OPEN_TEMP_JOURNAL | - SQLITE_OPEN_SUBJOURNAL | - SQLITE_OPEN_MASTER_JOURNAL | - SQLITE_OPEN_NOMUTEX | - SQLITE_OPEN_FULLMUTEX | - SQLITE_OPEN_WAL - ); - - - /* Allocate the sqlite data structure */ - db = new sqlite3();//sqlite3MallocZero( sqlite3.Length ); - if ( db == null ) - goto opendb_out; - if ( sqlite3GlobalConfig.bFullMutex && isThreadsafe != 0 ) - { - db.mutex = sqlite3MutexAlloc( SQLITE_MUTEX_RECURSIVE ); - if ( db.mutex == null ) - { - //sqlite3_free( ref db ); - goto opendb_out; - } - } - sqlite3_mutex_enter( db.mutex ); - db.errMask = 0xff; - db.nDb = 2; - db.magic = SQLITE_MAGIC_BUSY; - Array.Copy( db.aDbStatic, db.aDb, db.aDbStatic.Length );// db.aDb = db.aDbStatic; - Debug.Assert( db.aLimit.Length == aHardLimit.Length ); - Buffer.BlockCopy( aHardLimit, 0, db.aLimit, 0, aHardLimit.Length * sizeof( int ) );//memcpy(db.aLimit, aHardLimit, sizeof(db.aLimit)); - db.autoCommit = 1; - db.nextAutovac = -1; - db.nextPagesize = 0; - db.flags |= SQLITE_ShortColNames | SQLITE_AutoIndex | SQLITE_EnableTrigger; - if ( SQLITE_DEFAULT_FILE_FORMAT < 4 ) - db.flags |= SQLITE_LegacyFileFmt -#if SQLITE_ENABLE_LOAD_EXTENSION + Debug.Assert(SQLITE_OPEN_READONLY == 0x01); + Debug.Assert(SQLITE_OPEN_READWRITE == 0x02); + Debug.Assert(SQLITE_OPEN_CREATE == 0x04); + testcase((1 << (flags & 7)) == 0x02); /* READONLY */ + testcase((1 << (flags & 7)) == 0x04); /* READWRITE */ + testcase((1 << (flags & 7)) == 0x40); /* READWRITE | CREATE */ + if (((1 << (flags & 7)) & 0x46) == 0) return SQLITE_MISUSE_BKPT(); + + if (sqlite3GlobalConfig.bCoreMutex == false) { + isThreadsafe = 0; + } else if ((flags & SQLITE_OPEN_NOMUTEX) != 0) { + isThreadsafe = 0; + } else if ((flags & SQLITE_OPEN_FULLMUTEX) != 0) { + isThreadsafe = 1; + } else { + isThreadsafe = sqlite3GlobalConfig.bFullMutex ? 1 : 0; + } + if ((flags & SQLITE_OPEN_PRIVATECACHE) != 0) { + flags &= ~SQLITE_OPEN_SHAREDCACHE; + } else if (sqlite3GlobalConfig.sharedCacheEnabled) { + flags |= SQLITE_OPEN_SHAREDCACHE; + } + + /* Remove harmful bits from the flags parameter + ** + ** The SQLITE_OPEN_NOMUTEX and SQLITE_OPEN_FULLMUTEX flags were + ** dealt with in the previous code block. Besides these, the only + ** valid input flags for sqlite3_open_v2() are SQLITE_OPEN_READONLY, + ** SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE, SQLITE_OPEN_SHAREDCACHE, + ** SQLITE_OPEN_PRIVATECACHE, and some reserved bits. Silently mask + ** off all other flags. + */ + flags &= ~(SQLITE_OPEN_DELETEONCLOSE | + SQLITE_OPEN_EXCLUSIVE | + SQLITE_OPEN_MAIN_DB | + SQLITE_OPEN_TEMP_DB | + SQLITE_OPEN_TRANSIENT_DB | + SQLITE_OPEN_MAIN_JOURNAL | + SQLITE_OPEN_TEMP_JOURNAL | + SQLITE_OPEN_SUBJOURNAL | + SQLITE_OPEN_MASTER_JOURNAL | + SQLITE_OPEN_NOMUTEX | + SQLITE_OPEN_FULLMUTEX | + SQLITE_OPEN_WAL + ); + + + /* Allocate the sqlite data structure */ + db = new sqlite3();//sqlite3MallocZero( sqlite3.Length ); + if (db == null) + goto opendb_out; + if (sqlite3GlobalConfig.bFullMutex && isThreadsafe != 0) { + db.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_RECURSIVE); + if (db.mutex == null) { + //sqlite3_free( ref db ); + goto opendb_out; + } + } + sqlite3_mutex_enter(db.mutex); + db.errMask = 0xff; + db.nDb = 2; + db.magic = SQLITE_MAGIC_BUSY; + Array.Copy(db.aDbStatic, db.aDb, db.aDbStatic.Length);// db.aDb = db.aDbStatic; + Debug.Assert(db.aLimit.Length == aHardLimit.Length); + Buffer.BlockCopy(aHardLimit, 0, db.aLimit, 0, aHardLimit.Length * sizeof(int));//memcpy(db.aLimit, aHardLimit, sizeof(db.aLimit)); + db.autoCommit = 1; + db.nextAutovac = -1; + db.nextPagesize = 0; + db.flags |= SQLITE_ShortColNames | SQLITE_AutoIndex | SQLITE_EnableTrigger; + if (SQLITE_DEFAULT_FILE_FORMAT < 4) + db.flags |= SQLITE_LegacyFileFmt +#if SQLITE_ENABLE_LOAD_EXTENSION | SQLITE_LoadExtension #endif #if SQLITE_DEFAULT_RECURSIVE_TRIGGERS @@ -2528,115 +2314,112 @@ string zVfs /* Name of the VFS to use */ #if (SQLITE_DEFAULT_FOREIGN_KEYS) //&& SQLITE_DEFAULT_FOREIGN_KEYS | SQLITE_ForeignKeys #endif -; - sqlite3HashInit( db.aCollSeq ); + ; + sqlite3HashInit(db.aCollSeq); #if !SQLITE_OMIT_VIRTUALTABLE - db.aModule = new Hash(); - sqlite3HashInit( db.aModule ); + db.aModule = new Hash(); + sqlite3HashInit(db.aModule); #endif - /* Add the default collation sequence BINARY. BINARY works for both UTF-8 - ** and UTF-16, so add a version for each to avoid any unnecessary - ** conversions. The only error that can occur here is a malloc() failure. - */ - createCollation( db, "BINARY", SQLITE_UTF8, SQLITE_COLL_BINARY, 0, - binCollFunc, null ); - createCollation( db, "BINARY", SQLITE_UTF16BE, SQLITE_COLL_BINARY, 0, - binCollFunc, null ); - createCollation( db, "BINARY", SQLITE_UTF16LE, SQLITE_COLL_BINARY, 0, - binCollFunc, null ); - createCollation( db, "RTRIM", SQLITE_UTF8, SQLITE_COLL_USER, 1, - binCollFunc, null ); - //if ( db.mallocFailed != 0 ) - //{ - // goto opendb_out; - //} - db.pDfltColl = sqlite3FindCollSeq( db, SQLITE_UTF8, "BINARY", 0 ); - Debug.Assert( db.pDfltColl != null ); - - /* Also add a UTF-8 case-insensitive collation sequence. */ - createCollation( db, "NOCASE", SQLITE_UTF8, SQLITE_COLL_NOCASE, 0, - nocaseCollatingFunc, null ); - - /* Parse the filename/URI argument. */ - db.openFlags = flags; - rc = sqlite3ParseUri( zVfs, zFilename, ref flags, ref db.pVfs, ref zOpen, ref zErrMsg ); - if( rc!=SQLITE_OK ){ - //if( rc==SQLITE_NOMEM ) db.mallocFailed = 1; - sqlite3Error(db, rc, zErrMsg.Length>0 ? "%s" : "", zErrMsg); - //sqlite3_free(zErrMsg); - goto opendb_out; - } - - /* Open the backend database driver */ - rc = sqlite3BtreeOpen(db.pVfs, zOpen, db, ref db.aDb[0].pBt, 0, - flags | SQLITE_OPEN_MAIN_DB); -if ( rc != SQLITE_OK ) - { - if ( rc == SQLITE_IOERR_NOMEM ) - { - rc = SQLITE_NOMEM; - } - sqlite3Error( db, rc, 0 ); - goto opendb_out; - } - db.aDb[0].pSchema = sqlite3SchemaGet( db, db.aDb[0].pBt ); - db.aDb[1].pSchema = sqlite3SchemaGet( db, null ); - - - /* The default safety_level for the main database is 'full'; for the temp - ** database it is 'NONE'. This matches the pager layer defaults. - */ - db.aDb[0].zName = "main"; - db.aDb[0].safety_level = 3; - db.aDb[1].zName = "temp"; - db.aDb[1].safety_level = 1; - - db.magic = SQLITE_MAGIC_OPEN; - //if ( db.mallocFailed != 0 ) - //{ - // goto opendb_out; - //} - - /* Register all built-in functions, but do not attempt to read the - ** database schema yet. This is delayed until the first time the database - ** is accessed. - */ - sqlite3Error( db, SQLITE_OK, 0 ); - sqlite3RegisterBuiltinFunctions( db ); + /* Add the default collation sequence BINARY. BINARY works for both UTF-8 + ** and UTF-16, so add a version for each to avoid any unnecessary + ** conversions. The only error that can occur here is a malloc() failure. + */ + createCollation(db, "BINARY", SQLITE_UTF8, SQLITE_COLL_BINARY, 0, + binCollFunc, null); + createCollation(db, "BINARY", SQLITE_UTF16BE, SQLITE_COLL_BINARY, 0, + binCollFunc, null); + createCollation(db, "BINARY", SQLITE_UTF16LE, SQLITE_COLL_BINARY, 0, + binCollFunc, null); + createCollation(db, "RTRIM", SQLITE_UTF8, SQLITE_COLL_USER, 1, + binCollFunc, null); + //if ( db.mallocFailed != 0 ) + //{ + // goto opendb_out; + //} + db.pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 0); + Debug.Assert(db.pDfltColl != null); + + /* Also add a UTF-8 case-insensitive collation sequence. */ + createCollation(db, "NOCASE", SQLITE_UTF8, SQLITE_COLL_NOCASE, 0, + nocaseCollatingFunc, null); + + /* Parse the filename/URI argument. */ + db.openFlags = flags; + rc = sqlite3ParseUri(zVfs, zFilename, ref flags, ref db.pVfs, ref zOpen, ref zErrMsg); + if (rc != SQLITE_OK) { + //if( rc==SQLITE_NOMEM ) db.mallocFailed = 1; + sqlite3Error(db, rc, zErrMsg.Length > 0 ? "%s" : "", zErrMsg); + //sqlite3_free(zErrMsg); + goto opendb_out; + } - /* Load automatic extensions - extensions that have been registered - ** using the sqlite3_automatic_extension() API. - */ - sqlite3AutoLoadExtensions( db ); - rc = sqlite3_errcode( db ); - if ( rc != SQLITE_OK ) - { - goto opendb_out; - } + /* Open the backend database driver */ + rc = sqlite3BtreeOpen(db.pVfs, zOpen, db, ref db.aDb[0].pBt, 0, + flags | SQLITE_OPEN_MAIN_DB); + if (rc != SQLITE_OK) { + if (rc == SQLITE_IOERR_NOMEM) { + rc = SQLITE_NOMEM; + } + sqlite3Error(db, rc, 0); + goto opendb_out; + } + db.aDb[0].pSchema = sqlite3SchemaGet(db, db.aDb[0].pBt); + db.aDb[1].pSchema = sqlite3SchemaGet(db, null); + + + /* The default safety_level for the main database is 'full'; for the temp + ** database it is 'NONE'. This matches the pager layer defaults. + */ + db.aDb[0].zName = "main"; + db.aDb[0].safety_level = 3; + db.aDb[1].zName = "temp"; + db.aDb[1].safety_level = 1; + + db.magic = SQLITE_MAGIC_OPEN; + //if ( db.mallocFailed != 0 ) + //{ + // goto opendb_out; + //} + + /* Register all built-in functions, but do not attempt to read the + ** database schema yet. This is delayed until the first time the database + ** is accessed. + */ + sqlite3Error(db, SQLITE_OK, 0); + sqlite3RegisterBuiltinFunctions(db); + + /* Load automatic extensions - extensions that have been registered + ** using the sqlite3_automatic_extension() API. + */ + sqlite3AutoLoadExtensions(db); + rc = sqlite3_errcode(db); + if (rc != SQLITE_OK) { + goto opendb_out; + } -#if SQLITE_ENABLE_FTS1 +#if SQLITE_ENABLE_FTS1 if( 0==db.mallocFailed ){ extern int sqlite3Fts1Init(sqlite3); rc = sqlite3Fts1Init(db); } #endif -#if SQLITE_ENABLE_FTS2 +#if SQLITE_ENABLE_FTS2 if( 0==db.mallocFailed && rc==SQLITE_OK ){ extern int sqlite3Fts2Init(sqlite3); rc = sqlite3Fts2Init(db); } #endif -#if SQLITE_ENABLE_FTS3 +#if SQLITE_ENABLE_FTS3 if( 0==db.mallocFailed && rc==SQLITE_OK ){ rc = sqlite3Fts3Init(db); } #endif -#if SQLITE_ENABLE_ICU +#if SQLITE_ENABLE_ICU if( 0==db.mallocFailed && rc==SQLITE_OK ){ extern int sqlite3IcuInit(sqlite3); rc = sqlite3IcuInit(db); @@ -2649,66 +2432,60 @@ string zVfs /* Name of the VFS to use */ } #endif - sqlite3Error( db, rc, 0 ); + sqlite3Error(db, rc, 0); - /* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking - ** mode. -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking - ** mode. Doing nothing at all also makes NORMAL the default. - */ -#if SQLITE_DEFAULT_LOCKING_MODE + /* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking + ** mode. -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking + ** mode. Doing nothing at all also makes NORMAL the default. + */ +#if SQLITE_DEFAULT_LOCKING_MODE db.dfltLockMode = SQLITE_DEFAULT_LOCKING_MODE; sqlite3PagerLockingMode(sqlite3BtreePager(db.aDb[0].pBt), SQLITE_DEFAULT_LOCKING_MODE); #endif - /* Enable the lookaside-malloc subsystem */ - setupLookaside( db, null, sqlite3GlobalConfig.szLookaside, - sqlite3GlobalConfig.nLookaside ); + /* Enable the lookaside-malloc subsystem */ + setupLookaside(db, null, sqlite3GlobalConfig.szLookaside, + sqlite3GlobalConfig.nLookaside); - sqlite3_wal_autocheckpoint( db, SQLITE_DEFAULT_WAL_AUTOCHECKPOINT ); + sqlite3_wal_autocheckpoint(db, SQLITE_DEFAULT_WAL_AUTOCHECKPOINT); -opendb_out: - //sqlite3_free(zOpen); - if ( db != null ) - { - Debug.Assert( db.mutex != null || isThreadsafe == 0 || !sqlite3GlobalConfig.bFullMutex ); - sqlite3_mutex_leave( db.mutex ); - } - rc = sqlite3_errcode( db ); - if ( rc == SQLITE_NOMEM ) - { - sqlite3_close( db ); - db = null; - } - else if ( rc != SQLITE_OK ) - { - db.magic = SQLITE_MAGIC_SICK; - } - ppDb = db; - return sqlite3ApiExit( 0, rc ); - } + opendb_out: + //sqlite3_free(zOpen); + if (db != null) { + Debug.Assert(db.mutex != null || isThreadsafe == 0 || !sqlite3GlobalConfig.bFullMutex); + sqlite3_mutex_leave(db.mutex); + } + rc = sqlite3_errcode(db); + if (rc == SQLITE_NOMEM) { + sqlite3_close(db); + db = null; + } else if (rc != SQLITE_OK) { + db.magic = SQLITE_MAGIC_SICK; + } + ppDb = db; + return sqlite3ApiExit(0, rc); + } - /* - ** Open a new database handle. - */ - static public int sqlite3_open( - string zFilename, - out sqlite3 ppDb - ) - { - return openDatabase( zFilename, out ppDb, - SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, null ); - } + /* + ** Open a new database handle. + */ + static public int sqlite3_open( + string zFilename, + out sqlite3 ppDb + ) { + return openDatabase(zFilename, out ppDb, + SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, null); + } - static public int sqlite3_open_v2( - string filename, /* Database filename (UTF-8) */ - out sqlite3 ppDb, /* OUT: SQLite db handle */ - int flags, /* Flags */ - string zVfs /* Name of VFS module to use */ - ) - { - return openDatabase( filename, out ppDb, flags, zVfs ); - } + static public int sqlite3_open_v2( + string filename, /* Database filename (UTF-8) */ + out sqlite3 ppDb, /* OUT: SQLite db handle */ + int flags, /* Flags */ + string zVfs /* Name of VFS module to use */ + ) { + return openDatabase(filename, out ppDb, flags, zVfs); + } #if !SQLITE_OMIT_UTF16 @@ -2749,46 +2526,44 @@ int sqlite3_open16( } #endif // * SQLITE_OMIT_UTF16 */ - /* -** Register a new collation sequence with the database handle db. -*/ - public static int sqlite3_create_collation( - sqlite3 db, - string zName, - int enc, - object pCtx, - dxCompare xCompare - ) - { - int rc; - sqlite3_mutex_enter( db.mutex ); - //Debug.Assert( 0 == db.mallocFailed ); - rc = createCollation( db, zName, (u8)enc, SQLITE_COLL_USER, pCtx, xCompare, null ); - rc = sqlite3ApiExit( db, rc ); - sqlite3_mutex_leave( db.mutex ); - return rc; - } - - /* + /* ** Register a new collation sequence with the database handle db. */ - static int sqlite3_create_collation_v2( - sqlite3 db, - string zName, - int enc, - object pCtx, - dxCompare xCompare, //int(*xCompare)(void*,int,const void*,int,const void), - dxDelCollSeq xDel //void(*xDel)(void) - ) - { - int rc; - sqlite3_mutex_enter( db.mutex ); - //Debug.Assert( 0 == db.mallocFailed ); - rc = createCollation( db, zName, (u8)enc, SQLITE_COLL_USER, pCtx, xCompare, xDel ); - rc = sqlite3ApiExit( db, rc ); - sqlite3_mutex_leave( db.mutex ); - return rc; - } + public static int sqlite3_create_collation( + sqlite3 db, + string zName, + int enc, + object pCtx, + dxCompare xCompare + ) { + int rc; + sqlite3_mutex_enter(db.mutex); + //Debug.Assert( 0 == db.mallocFailed ); + rc = createCollation(db, zName, (u8)enc, SQLITE_COLL_USER, pCtx, xCompare, null); + rc = sqlite3ApiExit(db, rc); + sqlite3_mutex_leave(db.mutex); + return rc; + } + + /* + ** Register a new collation sequence with the database handle db. + */ + static int sqlite3_create_collation_v2( + sqlite3 db, + string zName, + int enc, + object pCtx, + dxCompare xCompare, //int(*xCompare)(void*,int,const void*,int,const void), + dxDelCollSeq xDel //void(*xDel)(void) + ) { + int rc; + sqlite3_mutex_enter(db.mutex); + //Debug.Assert( 0 == db.mallocFailed ); + rc = createCollation(db, zName, (u8)enc, SQLITE_COLL_USER, pCtx, xCompare, xDel); + rc = sqlite3ApiExit(db, rc); + sqlite3_mutex_leave(db.mutex); + return rc; + } #if !SQLITE_OMIT_UTF16 /* @@ -2816,23 +2591,22 @@ static int sqlite3_create_collation_v2( //} #endif // * SQLITE_OMIT_UTF16 */ - /* -** Register a collation sequence factory callback with the database handle -** db. Replace any previously installed collation sequence factory. -*/ - static int sqlite3_collation_needed( - sqlite3 db, - object pCollNeededArg, - dxCollNeeded xCollNeeded - ) - { - sqlite3_mutex_enter( db.mutex ); - db.xCollNeeded = xCollNeeded; - db.xCollNeeded16 = null; - db.pCollNeededArg = pCollNeededArg; - sqlite3_mutex_leave( db.mutex ); - return SQLITE_OK; - } + /* + ** Register a collation sequence factory callback with the database handle + ** db. Replace any previously installed collation sequence factory. + */ + static int sqlite3_collation_needed( + sqlite3 db, + object pCollNeededArg, + dxCollNeeded xCollNeeded + ) { + sqlite3_mutex_enter(db.mutex); + db.xCollNeeded = xCollNeeded; + db.xCollNeeded16 = null; + db.pCollNeededArg = pCollNeededArg; + sqlite3_mutex_leave(db.mutex); + return SQLITE_OK; + } #if !SQLITE_OMIT_UTF16 /* @@ -2864,54 +2638,50 @@ static int sqlite3_global_recover() } #endif - /* -** Test to see whether or not the database connection is in autocommit -** mode. Return TRUE if it is and FALSE if not. Autocommit mode is on -** by default. Autocommit is disabled by a BEGIN statement and reenabled -** by the next COMMIT or ROLLBACK. -** -******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ****** -*/ - static u8 sqlite3_get_autocommit( sqlite3 db ) - { - return db.autoCommit; - } - - /* - ** The following routines are subtitutes for constants SQLITE_CORRUPT, - ** SQLITE_MISUSE, SQLITE_CANTOPEN, SQLITE_IOERR and possibly other error - ** constants. They server two purposes: - ** - ** 1. Serve as a convenient place to set a breakpoint in a debugger - ** to detect when version error conditions occurs. + /* + ** Test to see whether or not the database connection is in autocommit + ** mode. Return TRUE if it is and FALSE if not. Autocommit mode is on + ** by default. Autocommit is disabled by a BEGIN statement and reenabled + ** by the next COMMIT or ROLLBACK. ** - ** 2. Invoke sqlite3_log() to provide the source code location where - ** a low-level error is first detected. + ******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ****** */ - static int sqlite3CorruptError( int lineno ) - { - testcase( sqlite3GlobalConfig.xLog != null ); - sqlite3_log( SQLITE_CORRUPT, - "database corruption at line %d of [%.10s]", - lineno, 20 + sqlite3_sourceid() ); - return SQLITE_CORRUPT; - } - static int sqlite3MisuseError( int lineno ) - { - testcase( sqlite3GlobalConfig.xLog != null ); - sqlite3_log( SQLITE_MISUSE, - "misuse at line %d of [%.10s]", - lineno, 20 + sqlite3_sourceid() ); - return SQLITE_MISUSE; - } - static int sqlite3CantopenError( int lineno ) - { - testcase( sqlite3GlobalConfig.xLog != null ); - sqlite3_log( SQLITE_CANTOPEN, - "cannot open file at line %d of [%.10s]", - lineno, 20 + sqlite3_sourceid() ); - return SQLITE_CANTOPEN; - } + static u8 sqlite3_get_autocommit(sqlite3 db) { + return db.autoCommit; + } + + /* + ** The following routines are subtitutes for constants SQLITE_CORRUPT, + ** SQLITE_MISUSE, SQLITE_CANTOPEN, SQLITE_IOERR and possibly other error + ** constants. They server two purposes: + ** + ** 1. Serve as a convenient place to set a breakpoint in a debugger + ** to detect when version error conditions occurs. + ** + ** 2. Invoke sqlite3_log() to provide the source code location where + ** a low-level error is first detected. + */ + static int sqlite3CorruptError(int lineno) { + testcase(sqlite3GlobalConfig.xLog != null); + sqlite3_log(SQLITE_CORRUPT, + "database corruption at line %d of [%.10s]", + lineno, 20 + sqlite3_sourceid()); + return SQLITE_CORRUPT; + } + static int sqlite3MisuseError(int lineno) { + testcase(sqlite3GlobalConfig.xLog != null); + sqlite3_log(SQLITE_MISUSE, + "misuse at line %d of [%.10s]", + lineno, 20 + sqlite3_sourceid()); + return SQLITE_MISUSE; + } + static int sqlite3CantopenError(int lineno) { + testcase(sqlite3GlobalConfig.xLog != null); + sqlite3_log(SQLITE_CANTOPEN, + "cannot open file at line %d of [%.10s]", + lineno, 20 + sqlite3_sourceid()); + return SQLITE_CANTOPEN; + } #if !SQLITE_OMIT_DEPRECATED /* @@ -2925,505 +2695,459 @@ void sqlite3_thread_cleanup() { } #endif - /* -** Return meta information about a specific column of a database table. -** See comment in sqlite3.h (sqlite.h.in) for details. -*/ + /* + ** Return meta information about a specific column of a database table. + ** See comment in sqlite3.h (sqlite.h.in) for details. + */ #if SQLITE_ENABLE_COLUMN_METADATA - public static int sqlite3_table_column_metadata( - sqlite3 db, /* Connection handle */ - string zDbName, /* Database name or NULL */ - string zTableName, /* Table name */ - string zColumnName, /* Column name */ - ref string pzDataType, /* OUTPUT: Declared data type */ - ref string pzCollSeq, /* OUTPUT: Collation sequence name */ - ref int pNotNull, /* OUTPUT: True if NOT NULL constraint exists */ - ref int pPrimaryKey, /* OUTPUT: True if column part of PK */ - ref int pAutoinc /* OUTPUT: True if column is auto-increment */ - ) - { - int rc; - string zErrMsg = ""; - Table pTab = null; - Column pCol = null; - int iCol; - - string zDataType = null; - string zCollSeq = null; - int notnull = 0; - int primarykey = 0; - int autoinc = 0; - - /* Ensure the database schema has been loaded */ - sqlite3_mutex_enter( db.mutex ); - sqlite3BtreeEnterAll( db ); - rc = sqlite3Init( db, ref zErrMsg ); - if ( SQLITE_OK != rc ) - { - goto error_out; - } - - /* Locate the table in question */ - pTab = sqlite3FindTable( db, zTableName, zDbName ); - if ( null == pTab || pTab.pSelect != null ) - { - pTab = null; - goto error_out; - } + public static int sqlite3_table_column_metadata( + sqlite3 db, /* Connection handle */ + string zDbName, /* Database name or NULL */ + string zTableName, /* Table name */ + string zColumnName, /* Column name */ + ref string pzDataType, /* OUTPUT: Declared data type */ + ref string pzCollSeq, /* OUTPUT: Collation sequence name */ + ref int pNotNull, /* OUTPUT: True if NOT NULL constraint exists */ + ref int pPrimaryKey, /* OUTPUT: True if column part of PK */ + ref int pAutoinc /* OUTPUT: True if column is auto-increment */ + ) { + int rc; + string zErrMsg = ""; + Table pTab = null; + Column pCol = null; + int iCol; + + string zDataType = null; + string zCollSeq = null; + int notnull = 0; + int primarykey = 0; + int autoinc = 0; + + /* Ensure the database schema has been loaded */ + sqlite3_mutex_enter(db.mutex); + sqlite3BtreeEnterAll(db); + rc = sqlite3Init(db, ref zErrMsg); + if (SQLITE_OK != rc) { + goto error_out; + } - /* Find the column for which info is requested */ - if ( sqlite3IsRowid( zColumnName ) ) - { - iCol = pTab.iPKey; - if ( iCol >= 0 ) - { - pCol = pTab.aCol[iCol]; - } - } - else - { - for ( iCol = 0; iCol < pTab.nCol; iCol++ ) - { - pCol = pTab.aCol[iCol]; - if ( pCol.zName.Equals( zColumnName, StringComparison.OrdinalIgnoreCase ) ) - { - break; - } - } - if ( iCol == pTab.nCol ) - { - pTab = null; - goto error_out; - } - } + /* Locate the table in question */ + pTab = sqlite3FindTable(db, zTableName, zDbName); + if (null == pTab || pTab.pSelect != null) { + pTab = null; + goto error_out; + } - /* The following block stores the meta information that will be returned - ** to the caller in local variables zDataType, zCollSeq, notnull, primarykey - ** and autoinc. At this point there are two possibilities: - ** - ** 1. The specified column name was rowid", "oid" or "_rowid_" - ** and there is no explicitly declared IPK column. - ** - ** 2. The table is not a view and the column name identified an - ** explicitly declared column. Copy meta information from pCol. - */ - if ( pCol != null ) - { - zDataType = pCol.zType; - zCollSeq = pCol.zColl; - notnull = pCol.notNull != 0 ? 1 : 0; - primarykey = pCol.isPrimKey != 0 ? 1 : 0; - autoinc = ( pTab.iPKey == iCol && ( pTab.tabFlags & TF_Autoincrement ) != 0 ) ? 1 : 0; - } - else - { - zDataType = "INTEGER"; - primarykey = 1; - } - if ( String.IsNullOrEmpty( zCollSeq ) ) - { - zCollSeq = "BINARY"; - } + /* Find the column for which info is requested */ + if (sqlite3IsRowid(zColumnName)) { + iCol = pTab.iPKey; + if (iCol >= 0) { + pCol = pTab.aCol[iCol]; + } + } else { + for (iCol = 0; iCol < pTab.nCol; iCol++) { + pCol = pTab.aCol[iCol]; + if (pCol.zName.Equals(zColumnName, StringComparison.OrdinalIgnoreCase)) { + break; + } + } + if (iCol == pTab.nCol) { + pTab = null; + goto error_out; + } + } -error_out: - sqlite3BtreeLeaveAll( db ); + /* The following block stores the meta information that will be returned + ** to the caller in local variables zDataType, zCollSeq, notnull, primarykey + ** and autoinc. At this point there are two possibilities: + ** + ** 1. The specified column name was rowid", "oid" or "_rowid_" + ** and there is no explicitly declared IPK column. + ** + ** 2. The table is not a view and the column name identified an + ** explicitly declared column. Copy meta information from pCol. + */ + if (pCol != null) { + zDataType = pCol.zType; + zCollSeq = pCol.zColl; + notnull = pCol.notNull != 0 ? 1 : 0; + primarykey = pCol.isPrimKey != 0 ? 1 : 0; + autoinc = (pTab.iPKey == iCol && (pTab.tabFlags & TF_Autoincrement) != 0) ? 1 : 0; + } else { + zDataType = "INTEGER"; + primarykey = 1; + } + if (String.IsNullOrEmpty(zCollSeq)) { + zCollSeq = "BINARY"; + } - /* Whether the function call succeeded or failed, set the output parameters - ** to whatever their local counterparts contain. If an error did occur, - ** this has the effect of zeroing all output parameters. - */ - //if ( pzDataType ) - pzDataType = zDataType; - //if ( pzCollSeq ) - pzCollSeq = zCollSeq; - //if ( pNotNull ) - pNotNull = notnull; - //if ( pPrimaryKey ) - pPrimaryKey = primarykey; - //if ( pAutoinc ) - pAutoinc = autoinc; - - if ( SQLITE_OK == rc && null == pTab ) - { - sqlite3DbFree( db, ref zErrMsg ); - zErrMsg = sqlite3MPrintf( db, "no such table column: %s.%s", zTableName, - zColumnName ); - rc = SQLITE_ERROR; - } - sqlite3Error( db, rc, ( !String.IsNullOrEmpty( zErrMsg ) ? "%s" : null ), zErrMsg ); - sqlite3DbFree( db, ref zErrMsg ); - rc = sqlite3ApiExit( db, rc ); - sqlite3_mutex_leave( db.mutex ); - return rc; - } + error_out: + sqlite3BtreeLeaveAll(db); + + /* Whether the function call succeeded or failed, set the output parameters + ** to whatever their local counterparts contain. If an error did occur, + ** this has the effect of zeroing all output parameters. + */ + //if ( pzDataType ) + pzDataType = zDataType; + //if ( pzCollSeq ) + pzCollSeq = zCollSeq; + //if ( pNotNull ) + pNotNull = notnull; + //if ( pPrimaryKey ) + pPrimaryKey = primarykey; + //if ( pAutoinc ) + pAutoinc = autoinc; + + if (SQLITE_OK == rc && null == pTab) { + sqlite3DbFree(db, ref zErrMsg); + zErrMsg = sqlite3MPrintf(db, "no such table column: %s.%s", zTableName, + zColumnName); + rc = SQLITE_ERROR; + } + sqlite3Error(db, rc, (!String.IsNullOrEmpty(zErrMsg) ? "%s" : null), zErrMsg); + sqlite3DbFree(db, ref zErrMsg); + rc = sqlite3ApiExit(db, rc); + sqlite3_mutex_leave(db.mutex); + return rc; + } #endif - /* -** Sleep for a little while. Return the amount of time slept. -*/ - static public int sqlite3_sleep( int ms ) - { - sqlite3_vfs pVfs; - int rc; - pVfs = sqlite3_vfs_find( null ); - if ( pVfs == null ) - return 0; - - /* This function works in milliseconds, but the underlying OsSleep() - ** API uses microseconds. Hence the 1000's. - */ - rc = ( sqlite3OsSleep( pVfs, 1000 * ms ) / 1000 ); - return rc; - } - - /* - ** Enable or disable the extended result codes. + /* + ** Sleep for a little while. Return the amount of time slept. */ - static int sqlite3_extended_result_codes( sqlite3 db, bool onoff ) - { - sqlite3_mutex_enter( db.mutex ); - db.errMask = (int)( onoff ? 0xffffffff : 0xff ); - sqlite3_mutex_leave( db.mutex ); - return SQLITE_OK; - } + static public int sqlite3_sleep(int ms) { + sqlite3_vfs pVfs; + int rc; + pVfs = sqlite3_vfs_find(null); + if (pVfs == null) + return 0; + + /* This function works in milliseconds, but the underlying OsSleep() + ** API uses microseconds. Hence the 1000's. + */ + rc = (sqlite3OsSleep(pVfs, 1000 * ms) / 1000); + return rc; + } - /* - ** Invoke the xFileControl method on a particular database. - */ - static int sqlite3_file_control( sqlite3 db, string zDbName, int op, ref sqlite3_int64 pArg ) - { - int rc = SQLITE_ERROR; - int iDb; - sqlite3_mutex_enter( db.mutex ); - if ( zDbName == null ) - { - iDb = 0; - } - else - { - for ( iDb = 0; iDb < db.nDb; iDb++ ) - { - if ( db.aDb[iDb].zName == zDbName ) - break; + /* + ** Enable or disable the extended result codes. + */ + static int sqlite3_extended_result_codes(sqlite3 db, bool onoff) { + sqlite3_mutex_enter(db.mutex); + db.errMask = (int)(onoff ? 0xffffffff : 0xff); + sqlite3_mutex_leave(db.mutex); + return SQLITE_OK; } - } - if ( iDb < db.nDb ) - { - Btree pBtree = db.aDb[iDb].pBt; - if ( pBtree != null ) - { - Pager pPager; - sqlite3_file fd; - sqlite3BtreeEnter( pBtree ); - pPager = sqlite3BtreePager( pBtree ); - Debug.Assert( pPager != null ); - fd = sqlite3PagerFile( pPager ); - Debug.Assert( fd != null ); - if ( op == SQLITE_FCNTL_FILE_POINTER ) - { + + /* + ** Invoke the xFileControl method on a particular database. + */ + static int sqlite3_file_control(sqlite3 db, string zDbName, int op, ref sqlite3_int64 pArg) { + int rc = SQLITE_ERROR; + int iDb; + sqlite3_mutex_enter(db.mutex); + if (zDbName == null) { + iDb = 0; + } else { + for (iDb = 0; iDb < db.nDb; iDb++) { + if (db.aDb[iDb].zName == zDbName) + break; + } + } + if (iDb < db.nDb) { + Btree pBtree = db.aDb[iDb].pBt; + if (pBtree != null) { + Pager pPager; + sqlite3_file fd; + sqlite3BtreeEnter(pBtree); + pPager = sqlite3BtreePager(pBtree); + Debug.Assert(pPager != null); + fd = sqlite3PagerFile(pPager); + Debug.Assert(fd != null); + if (op == SQLITE_FCNTL_FILE_POINTER) { #if (SQLITE_SILVERLIGHT || WINDOWS_MOBILE || SQLITE_WINRT) pArg = (long)-1; // not supported #else - pArg = (long)fd.fs.Handle; + pArg = (long)fd.fs.Handle; #endif - rc = SQLITE_OK; - } - else if ( fd.pMethods != null ) - { - rc = sqlite3OsFileControl( fd, (u32)op, ref pArg ); - } - else - { - rc = SQLITE_NOTFOUND; - } - sqlite3BtreeLeave( pBtree ); + rc = SQLITE_OK; + } else if (fd.pMethods != null) { + rc = sqlite3OsFileControl(fd, (u32)op, ref pArg); + } else { + rc = SQLITE_NOTFOUND; + } + sqlite3BtreeLeave(pBtree); + } + } + sqlite3_mutex_leave(db.mutex); + return rc; } - } - sqlite3_mutex_leave( db.mutex ); - return rc; - } - /* - ** Interface to the testing logic. - */ - static public int sqlite3_test_control(int op, params object[] ap) - { - int rc = 0; + /* + ** Interface to the testing logic. + */ + static public int sqlite3_test_control(int op, params object[] ap) { + int rc = 0; #if !SQLITE_OMIT_BUILTIN_TEST - // va_list ap; - lock ( lock_va_list ) - { - va_start( ap, "op" ); - switch ( op ) - { - - /* - ** Save the current state of the PRNG. - */ - case SQLITE_TESTCTRL_PRNG_SAVE: - { - sqlite3PrngSaveState(); - break; - } - - /* - ** Restore the state of the PRNG to the last state saved using - ** PRNG_SAVE. If PRNG_SAVE has never before been called, then - ** this verb acts like PRNG_RESET. - */ - case SQLITE_TESTCTRL_PRNG_RESTORE: - { - sqlite3PrngRestoreState(); - break; - } - - /* - ** Reset the PRNG back to its uninitialized state. The next call - ** to sqlite3_randomness() will reseed the PRNG using a single call - ** to the xRandomness method of the default VFS. - */ - case SQLITE_TESTCTRL_PRNG_RESET: - { - sqlite3PrngResetState(); - break; - } - - /* - ** sqlite3_test_control(BITVEC_TEST, size, program) - ** - ** Run a test against a Bitvec object of size. The program argument - ** is an array of integers that defines the test. Return -1 on a - ** memory allocation error, 0 on success, or non-zero for an error. - ** See the sqlite3BitvecBuiltinTest() for additional information. - */ - case SQLITE_TESTCTRL_BITVEC_TEST: - { - int sz = va_arg( ap, ( Int32 ) 0 ); - int[] aProg = va_arg( ap, (Int32[])null ); - rc = sqlite3BitvecBuiltinTest( (u32)sz, aProg ); - break; - } - - /* - ** sqlite3_test_control(BENIGN_MALLOC_HOOKS, xBegin, xEnd) - ** - ** Register hooks to call to indicate which malloc() failures - ** are benign. - */ - case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: - { - //typedef void (*void_function)(void); - void_function xBenignBegin; - void_function xBenignEnd; - xBenignBegin = va_arg( ap, (void_function)null ); - xBenignEnd = va_arg( ap, (void_function)null ); - sqlite3BenignMallocHooks( xBenignBegin, xBenignEnd ); - break; - } - /* - ** sqlite3_test_control(SQLITE_TESTCTRL_PENDING_BYTE, unsigned int X) - ** - ** Set the PENDING byte to the value in the argument, if X>0. - ** Make no changes if X==0. Return the value of the pending byte - ** as it existing before this routine was called. - ** - ** IMPORTANT: Changing the PENDING byte from 0x40000000 results in - ** an incompatible database file format. Changing the PENDING byte - ** while any database connection is open results in undefined and - ** dileterious behavior. - */ - case SQLITE_TESTCTRL_PENDING_BYTE: - { - rc = PENDING_BYTE; + // va_list ap; + lock (lock_va_list) { + va_start(ap, "op"); + switch (op) { + + /* + ** Save the current state of the PRNG. + */ + case SQLITE_TESTCTRL_PRNG_SAVE: { + sqlite3PrngSaveState(); + break; + } + + /* + ** Restore the state of the PRNG to the last state saved using + ** PRNG_SAVE. If PRNG_SAVE has never before been called, then + ** this verb acts like PRNG_RESET. + */ + case SQLITE_TESTCTRL_PRNG_RESTORE: { + sqlite3PrngRestoreState(); + break; + } + + /* + ** Reset the PRNG back to its uninitialized state. The next call + ** to sqlite3_randomness() will reseed the PRNG using a single call + ** to the xRandomness method of the default VFS. + */ + case SQLITE_TESTCTRL_PRNG_RESET: { + sqlite3PrngResetState(); + break; + } + + /* + ** sqlite3_test_control(BITVEC_TEST, size, program) + ** + ** Run a test against a Bitvec object of size. The program argument + ** is an array of integers that defines the test. Return -1 on a + ** memory allocation error, 0 on success, or non-zero for an error. + ** See the sqlite3BitvecBuiltinTest() for additional information. + */ + case SQLITE_TESTCTRL_BITVEC_TEST: { + int sz = va_arg(ap, (Int32)0); + int[] aProg = va_arg(ap, (Int32[])null); + rc = sqlite3BitvecBuiltinTest((u32)sz, aProg); + break; + } + + /* + ** sqlite3_test_control(BENIGN_MALLOC_HOOKS, xBegin, xEnd) + ** + ** Register hooks to call to indicate which malloc() failures + ** are benign. + */ + case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: { + //typedef void (*void_function)(void); + void_function xBenignBegin; + void_function xBenignEnd; + xBenignBegin = va_arg(ap, (void_function)null); + xBenignEnd = va_arg(ap, (void_function)null); + sqlite3BenignMallocHooks(xBenignBegin, xBenignEnd); + break; + } + /* + ** sqlite3_test_control(SQLITE_TESTCTRL_PENDING_BYTE, unsigned int X) + ** + ** Set the PENDING byte to the value in the argument, if X>0. + ** Make no changes if X==0. Return the value of the pending byte + ** as it existing before this routine was called. + ** + ** IMPORTANT: Changing the PENDING byte from 0x40000000 results in + ** an incompatible database file format. Changing the PENDING byte + ** while any database connection is open results in undefined and + ** dileterious behavior. + */ + case SQLITE_TESTCTRL_PENDING_BYTE: { + rc = PENDING_BYTE; #if !SQLITE_OMIT_WSD - { - u32 newVal = va_arg( ap, (UInt32)0 ); - if ( newVal != 0 ) - { - if ( sqlite3PendingByte != newVal ) - sqlite3PendingByte = (int)newVal; + { + u32 newVal = va_arg(ap, (UInt32)0); + if (newVal != 0) { + if (sqlite3PendingByte != newVal) + sqlite3PendingByte = (int)newVal; #if DEBUG && TCLSH TCLsqlite3PendingByte.iValue = sqlite3PendingByte; #endif - PENDING_BYTE = sqlite3PendingByte; - } - } + PENDING_BYTE = sqlite3PendingByte; + } + } #endif - break; - } - - /* - ** sqlite3_test_control(SQLITE_TESTCTRL_ASSERT, int X) - ** - ** This action provides a run-time test to see whether or not - ** Debug.Assert() was enabled at compile-time. If X is true and Debug.Assert() - ** is enabled, then the return value is true. If X is true and - ** Debug.Assert() is disabled, then the return value is zero. If X is - ** false and Debug.Assert() is enabled, then the assertion fires and the - ** process aborts. If X is false and Debug.Assert() is disabled, then the - ** return value is zero. - */ - case SQLITE_TESTCTRL_ASSERT: - { - int x = 0; - Debug.Assert( ( x = va_arg( ap, ( Int32 ) 0 ) ) != 0 ); - rc = x; - break; - } - - - /* - ** sqlite3_test_control(SQLITE_TESTCTRL_ALWAYS, int X) - ** - ** This action provides a run-time test to see how the ALWAYS and - ** NEVER macros were defined at compile-time. - ** - ** The return value is ALWAYS(X). - ** - ** The recommended test is X==2. If the return value is 2, that means - ** ALWAYS() and NEVER() are both no-op pass-through macros, which is the - ** default setting. If the return value is 1, then ALWAYS() is either - ** hard-coded to true or else it asserts if its argument is false. - ** The first behavior (hard-coded to true) is the case if - ** SQLITE_TESTCTRL_ASSERT shows that Debug.Assert() is disabled and the second - ** behavior (assert if the argument to ALWAYS() is false) is the case if - ** SQLITE_TESTCTRL_ASSERT shows that Debug.Assert() is enabled. - ** - ** The run-time test procedure might look something like this: - ** - ** if( sqlite3_test_control(SQLITE_TESTCTRL_ALWAYS, 2)==2 ){ - ** // ALWAYS() and NEVER() are no-op pass-through macros - ** }else if( sqlite3_test_control(SQLITE_TESTCTRL_ASSERT, 1) ){ - ** // ALWAYS(x) asserts that x is true. NEVER(x) asserts x is false. - ** }else{ - ** // ALWAYS(x) is a constant 1. NEVER(x) is a constant 0. - ** } - */ - case SQLITE_TESTCTRL_ALWAYS: - { - int x = va_arg( ap, ( Int32 ) 0 ); - rc = ALWAYS( x ); - break; - } + break; + } + + /* + ** sqlite3_test_control(SQLITE_TESTCTRL_ASSERT, int X) + ** + ** This action provides a run-time test to see whether or not + ** Debug.Assert() was enabled at compile-time. If X is true and Debug.Assert() + ** is enabled, then the return value is true. If X is true and + ** Debug.Assert() is disabled, then the return value is zero. If X is + ** false and Debug.Assert() is enabled, then the assertion fires and the + ** process aborts. If X is false and Debug.Assert() is disabled, then the + ** return value is zero. + */ + case SQLITE_TESTCTRL_ASSERT: { + int x = 0; + Debug.Assert((x = va_arg(ap, (Int32)0)) != 0); + rc = x; + break; + } + + + /* + ** sqlite3_test_control(SQLITE_TESTCTRL_ALWAYS, int X) + ** + ** This action provides a run-time test to see how the ALWAYS and + ** NEVER macros were defined at compile-time. + ** + ** The return value is ALWAYS(X). + ** + ** The recommended test is X==2. If the return value is 2, that means + ** ALWAYS() and NEVER() are both no-op pass-through macros, which is the + ** default setting. If the return value is 1, then ALWAYS() is either + ** hard-coded to true or else it asserts if its argument is false. + ** The first behavior (hard-coded to true) is the case if + ** SQLITE_TESTCTRL_ASSERT shows that Debug.Assert() is disabled and the second + ** behavior (assert if the argument to ALWAYS() is false) is the case if + ** SQLITE_TESTCTRL_ASSERT shows that Debug.Assert() is enabled. + ** + ** The run-time test procedure might look something like this: + ** + ** if( sqlite3_test_control(SQLITE_TESTCTRL_ALWAYS, 2)==2 ){ + ** // ALWAYS() and NEVER() are no-op pass-through macros + ** }else if( sqlite3_test_control(SQLITE_TESTCTRL_ASSERT, 1) ){ + ** // ALWAYS(x) asserts that x is true. NEVER(x) asserts x is false. + ** }else{ + ** // ALWAYS(x) is a constant 1. NEVER(x) is a constant 0. + ** } + */ + case SQLITE_TESTCTRL_ALWAYS: { + int x = va_arg(ap, (Int32)0); + rc = ALWAYS(x); + break; + } + + /* sqlite3_test_control(SQLITE_TESTCTRL_RESERVE, sqlite3 db, int N) + ** + ** Set the nReserve size to N for the main database on the database + ** connection db. + */ + case SQLITE_TESTCTRL_RESERVE: { + sqlite3 db = va_arg(ap, (sqlite3)null); + int x = va_arg(ap, (Int32)0); + sqlite3_mutex_enter(db.mutex); + sqlite3BtreeSetPageSize(db.aDb[0].pBt, 0, x, 0); + sqlite3_mutex_leave(db.mutex); + break; + } + + /* sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, sqlite3 db, int N) + ** + ** Enable or disable various optimizations for testing purposes. The + ** argument N is a bitmask of optimizations to be disabled. For normal + ** operation N should be 0. The idea is that a test program (like the + ** SQL Logic Test or SLT test module) can run the same SQL multiple times + ** with various optimizations disabled to verify that the same answer + ** is obtained in every case. + */ + case SQLITE_TESTCTRL_OPTIMIZATIONS: { + sqlite3 db = va_arg(ap, (sqlite3)null);//sqlite3 db = va_arg(ap, sqlite3); + int x = va_arg(ap, (Int32)0);//int x = va_arg(ap,int); + db.flags = (x & SQLITE_OptMask) | (db.flags & ~SQLITE_OptMask); + break; + } + + //#if SQLITE_N_KEYWORD + /* sqlite3_test_control(SQLITE_TESTCTRL_ISKEYWORD, const string zWord) + ** + ** If zWord is a keyword recognized by the parser, then return the + ** number of keywords. Or if zWord is not a keyword, return 0. + ** + ** This test feature is only available in the amalgamation since + ** the SQLITE_N_KEYWORD macro is not defined in this file if SQLite + ** is built using separate source files. + */ + case SQLITE_TESTCTRL_ISKEYWORD: { + string zWord = (string)va_arg(ap, "char*"); + int n = sqlite3Strlen30(zWord); + rc = (sqlite3KeywordCode(zWord, n) != TK_ID) ? SQLITE_N_KEYWORD : 0; + break; + } + //#endif + /* sqlite3_test_control(SQLITE_TESTCTRL_PGHDRSZ) + ** + ** Return the size of a pcache header in bytes. + */ + case SQLITE_TESTCTRL_PGHDRSZ: { + rc = -1;// sizeof(PgHdr); + break; + } + + /* sqlite3_test_control(SQLITE_TESTCTRL_SCRATCHMALLOC, sz, &pNew, pFree); + ** + ** Pass pFree into sqlite3ScratchFree(). + ** If sz>0 then allocate a scratch buffer into pNew. + */ + case SQLITE_TESTCTRL_SCRATCHMALLOC: { + //void pFree, *ppNew; + //int sz; + //sz = va_arg(ap, int); + //ppNew = va_arg(ap, void*); + //pFree = va_arg(ap, void); + //if( sz ) *ppNew = sqlite3ScratchMalloc(sz); + //sqlite3ScratchFree(pFree); + break; + } + /* sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, int onoff); + ** + ** If parameter onoff is non-zero, configure the wrappers so that all + ** subsequent calls to localtime() and variants fail. If onoff is zero, + ** undo this setting. + */ + case SQLITE_TESTCTRL_LOCALTIME_FAULT: { + sqlite3GlobalConfig.bLocaltimeFault = va_arg(ap, (Boolean)true); + break; + } - /* sqlite3_test_control(SQLITE_TESTCTRL_RESERVE, sqlite3 db, int N) - ** - ** Set the nReserve size to N for the main database on the database - ** connection db. - */ - case SQLITE_TESTCTRL_RESERVE: - { - sqlite3 db = va_arg( ap, (sqlite3)null ); - int x = va_arg( ap, ( Int32 ) 0 ); - sqlite3_mutex_enter( db.mutex ); - sqlite3BtreeSetPageSize( db.aDb[0].pBt, 0, x, 0 ); - sqlite3_mutex_leave( db.mutex ); - break; - } - - /* sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, sqlite3 db, int N) - ** - ** Enable or disable various optimizations for testing purposes. The - ** argument N is a bitmask of optimizations to be disabled. For normal - ** operation N should be 0. The idea is that a test program (like the - ** SQL Logic Test or SLT test module) can run the same SQL multiple times - ** with various optimizations disabled to verify that the same answer - ** is obtained in every case. - */ - case SQLITE_TESTCTRL_OPTIMIZATIONS: - { - sqlite3 db = va_arg( ap, (sqlite3)null );//sqlite3 db = va_arg(ap, sqlite3); - int x = va_arg( ap, (Int32)0 );//int x = va_arg(ap,int); - db.flags = ( x & SQLITE_OptMask ) | ( db.flags & ~SQLITE_OptMask ); - break; - } - - //#if SQLITE_N_KEYWORD - /* sqlite3_test_control(SQLITE_TESTCTRL_ISKEYWORD, const string zWord) - ** - ** If zWord is a keyword recognized by the parser, then return the - ** number of keywords. Or if zWord is not a keyword, return 0. - ** - ** This test feature is only available in the amalgamation since - ** the SQLITE_N_KEYWORD macro is not defined in this file if SQLite - ** is built using separate source files. - */ - case SQLITE_TESTCTRL_ISKEYWORD: - { - string zWord = (string)va_arg( ap, "char*" ); - int n = sqlite3Strlen30( zWord ); - rc = ( sqlite3KeywordCode( zWord, n ) != TK_ID ) ? SQLITE_N_KEYWORD : 0; - break; - } - //#endif - /* sqlite3_test_control(SQLITE_TESTCTRL_PGHDRSZ) - ** - ** Return the size of a pcache header in bytes. - */ - case SQLITE_TESTCTRL_PGHDRSZ: - { - rc = -1;// sizeof(PgHdr); - break; + } + va_end(ref ap); } - - /* sqlite3_test_control(SQLITE_TESTCTRL_SCRATCHMALLOC, sz, &pNew, pFree); - ** - ** Pass pFree into sqlite3ScratchFree(). - ** If sz>0 then allocate a scratch buffer into pNew. - */ - case SQLITE_TESTCTRL_SCRATCHMALLOC: - { - //void pFree, *ppNew; - //int sz; - //sz = va_arg(ap, int); - //ppNew = va_arg(ap, void*); - //pFree = va_arg(ap, void); - //if( sz ) *ppNew = sqlite3ScratchMalloc(sz); - //sqlite3ScratchFree(pFree); - break; - } - /* sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, int onoff); - ** - ** If parameter onoff is non-zero, configure the wrappers so that all - ** subsequent calls to localtime() and variants fail. If onoff is zero, - ** undo this setting. - */ - case SQLITE_TESTCTRL_LOCALTIME_FAULT: { - sqlite3GlobalConfig.bLocaltimeFault = va_arg( ap, (Boolean)true ); - break; - } - - } - va_end( ref ap ); - } #endif //* SQLITE_OMIT_BUILTIN_TEST */ - return rc; - } + return rc; + } -/* -** This is a utility routine, useful to VFS implementations, that checks -** to see if a database file was a URI that contained a specific query -** parameter, and if so obtains the value of the query parameter. -** -** The zFilename argument is the filename pointer passed into the xOpen() -** method of a VFS implementation. The zParam argument is the name of the -** query parameter we seek. This routine returns the value of the zParam -** parameter if it exists. If the parameter does not exist, this routine -** returns a NULL pointer. -*/ -static string sqlite3_uri_parameter(string zFilename, string zParam){ - // TODO -- Implement URI - //zFilename += sqlite3Strlen30(zFilename) + 1; - //while( zFilename[0] ){ - // int x = strcmp(zFilename, zParam); - // zFilename += sqlite3Strlen30(zFilename) + 1; - // if( x==0 ) return zFilename; - // zFilename += sqlite3Strlen30(zFilename) + 1; - //} - return null; -} + /* + ** This is a utility routine, useful to VFS implementations, that checks + ** to see if a database file was a URI that contained a specific query + ** parameter, and if so obtains the value of the query parameter. + ** + ** The zFilename argument is the filename pointer passed into the xOpen() + ** method of a VFS implementation. The zParam argument is the name of the + ** query parameter we seek. This routine returns the value of the zParam + ** parameter if it exists. If the parameter does not exist, this routine + ** returns a NULL pointer. + */ + static string sqlite3_uri_parameter(string zFilename, string zParam) { + // TODO -- Implement URI + //zFilename += sqlite3Strlen30(zFilename) + 1; + //while( zFilename[0] ){ + // int x = strcmp(zFilename, zParam); + // zFilename += sqlite3Strlen30(zFilename) + 1; + // if( x==0 ) return zFilename; + // zFilename += sqlite3Strlen30(zFilename) + 1; + //} + return null; + } -} + } } diff --git a/Src/IronPython.SQLite/c#sqlite/malloc_c.cs b/Src/IronPython.SQLite/c#sqlite/malloc_c.cs index 2b45c6ce9..554f7b860 100644 --- a/Src/IronPython.SQLite/c#sqlite/malloc_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/malloc_c.cs @@ -1,156 +1,146 @@ using System.Diagnostics; -using System.Text; -namespace Community.CsharpSqlite -{ - using sqlite3_int64 = System.Int64; - using i64 = System.Int64; - using sqlite3_uint64 = System.UInt64; - using u32 = System.UInt32; - using System; - - public partial class Sqlite3 - { - /* - ** 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. - ** - ************************************************************************* - ** - ** Memory allocation functions used throughout sqlite. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include - - /* - ** Attempt to release up to n bytes of non-essential memory currently - ** held by SQLite. An example of non-essential memory is memory used to - ** cache database pages that are not currently in use. - */ - static int sqlite3_release_memory( int n ) - { +namespace Community.CsharpSqlite { + using System; + + using sqlite3_int64 = System.Int64; + using u32 = System.UInt32; + + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** + ** Memory allocation functions used throughout sqlite. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include + + /* + ** Attempt to release up to n bytes of non-essential memory currently + ** held by SQLite. An example of non-essential memory is memory used to + ** cache database pages that are not currently in use. + */ + static int sqlite3_release_memory(int n) { #if SQLITE_ENABLE_MEMORY_MANAGEMENT int nRet = 0; nRet += sqlite3PcacheReleaseMemory(n-nRet); return nRet; #else - UNUSED_PARAMETER( n ); - return SQLITE_OK; + UNUSED_PARAMETER(n); + return SQLITE_OK; #endif - } - - /* - ** State information local to the memory allocation subsystem. - */ - //static SQLITE_WSD struct Mem0Global { - public class Mem0Global - {/* Number of free pages for scratch and page-cache memory */ - public int nScratchFree; - public int nPageFree; - - public sqlite3_mutex mutex; /* Mutex to serialize access */ - - /* - ** The alarm callback and its arguments. The mem0.mutex lock will - ** be held while the callback is running. Recursive calls into - ** the memory subsystem are allowed, but no new callbacks will be - ** issued. - */ - public sqlite3_int64 alarmThreshold; - public dxalarmCallback alarmCallback; // (*alarmCallback)(void*, sqlite3_int64,int); - public object alarmArg; - - /* - ** Pointers to the end of sqlite3GlobalConfig.pScratch and - ** sqlite3GlobalConfig.pPage to a block of memory that records - ** which pages are available. - */ - //u32 *aScratchFree; - /* - ** True if heap is nearly "full" where "full" is defined by the - ** sqlite3_soft_heap_limit() setting. - */ - public bool nearlyFull; - - public byte[][][] aByte; - public int[] aByteSize; - public int[] aByte_used; - public int[][] aInt; - public Mem[] aMem; - public BtCursor[] aBtCursor; - - public struct memstat - { - public int alloc; // # of allocation requests - public int dealloc; // # of deallocations - public int cached; // # of cache hits - public int next; // # Next slot to use - public int max; // # Max slot used - } - - public memstat msByte; - public memstat msInt; - public memstat msMem; - public memstat msBtCursor; - - public Mem0Global() - { - } - - public Mem0Global( int nScratchFree, int nPageFree, sqlite3_mutex mutex, sqlite3_int64 alarmThreshold, dxalarmCallback alarmCallback, object alarmArg, int Byte_Allocation, int Int_Allocation, int Mem_Allocation, int BtCursor_Allocation ) - { - this.nScratchFree = nScratchFree; - this.nPageFree = nPageFree; - this.mutex = mutex; - this.alarmThreshold = alarmThreshold; - this.alarmCallback = alarmCallback; - this.alarmArg = alarmArg; - this.msByte.next = -1; - this.msInt.next = -1; - this.msMem.next = -1; - this.aByteSize = new int[] { 32, 256, 1024, 8192, 0 }; - this.aByte_used = new int[] { -1, -1, -1, -1, -1 }; - this.aByte = new byte[this.aByteSize.Length][][]; - for ( int i = 0; i < this.aByteSize.Length; i++ ) - this.aByte[i] = new byte[Byte_Allocation][]; - this.aInt = new int[Int_Allocation][]; - this.aMem = new Mem[Mem_Allocation <= 4 ? 4 : Mem_Allocation]; - this.aBtCursor = new BtCursor[BtCursor_Allocation <= 4 ? 4 : BtCursor_Allocation]; - this.nearlyFull = false; - } - } - //mem0 = { 0, 0, 0, 0, 0, 0, 0, 0 }; - - //#define mem0 GLOBAL(struct Mem0Global, mem0) - static Mem0Global mem0 = new Mem0Global(); + } - /* - ** This routine runs when the memory allocator sees that the - ** total memory allocation is about to exceed the soft heap - ** limit. - */ - static void softHeapLimitEnforcer( - object NotUsed, - sqlite3_int64 NotUsed2, - int allocSize - ) - { - UNUSED_PARAMETER2( NotUsed, NotUsed2 ); - sqlite3_release_memory( allocSize ); - } + /* + ** State information local to the memory allocation subsystem. + */ + //static SQLITE_WSD struct Mem0Global { + public class Mem0Global {/* Number of free pages for scratch and page-cache memory */ + public int nScratchFree; + public int nPageFree; + + public sqlite3_mutex mutex; /* Mutex to serialize access */ + + /* + ** The alarm callback and its arguments. The mem0.mutex lock will + ** be held while the callback is running. Recursive calls into + ** the memory subsystem are allowed, but no new callbacks will be + ** issued. + */ + public sqlite3_int64 alarmThreshold; + public dxalarmCallback alarmCallback; // (*alarmCallback)(void*, sqlite3_int64,int); + public object alarmArg; + + /* + ** Pointers to the end of sqlite3GlobalConfig.pScratch and + ** sqlite3GlobalConfig.pPage to a block of memory that records + ** which pages are available. + */ + //u32 *aScratchFree; + /* + ** True if heap is nearly "full" where "full" is defined by the + ** sqlite3_soft_heap_limit() setting. + */ + public bool nearlyFull; + + public byte[][][] aByte; + public int[] aByteSize; + public int[] aByte_used; + public int[][] aInt; + public Mem[] aMem; + public BtCursor[] aBtCursor; + + public struct memstat { + public int alloc; // # of allocation requests + public int dealloc; // # of deallocations + public int cached; // # of cache hits + public int next; // # Next slot to use + public int max; // # Max slot used + } + + public memstat msByte; + public memstat msInt; + public memstat msMem; + public memstat msBtCursor; + + public Mem0Global() { + } + + public Mem0Global(int nScratchFree, int nPageFree, sqlite3_mutex mutex, sqlite3_int64 alarmThreshold, dxalarmCallback alarmCallback, object alarmArg, int Byte_Allocation, int Int_Allocation, int Mem_Allocation, int BtCursor_Allocation) { + this.nScratchFree = nScratchFree; + this.nPageFree = nPageFree; + this.mutex = mutex; + this.alarmThreshold = alarmThreshold; + this.alarmCallback = alarmCallback; + this.alarmArg = alarmArg; + this.msByte.next = -1; + this.msInt.next = -1; + this.msMem.next = -1; + this.aByteSize = new int[] { 32, 256, 1024, 8192, 0 }; + this.aByte_used = new int[] { -1, -1, -1, -1, -1 }; + this.aByte = new byte[this.aByteSize.Length][][]; + for (int i = 0; i < this.aByteSize.Length; i++) + this.aByte[i] = new byte[Byte_Allocation][]; + this.aInt = new int[Int_Allocation][]; + this.aMem = new Mem[Mem_Allocation <= 4 ? 4 : Mem_Allocation]; + this.aBtCursor = new BtCursor[BtCursor_Allocation <= 4 ? 4 : BtCursor_Allocation]; + this.nearlyFull = false; + } + } + //mem0 = { 0, 0, 0, 0, 0, 0, 0, 0 }; + + //#define mem0 GLOBAL(struct Mem0Global, mem0) + static Mem0Global mem0 = new Mem0Global(); + + /* + ** This routine runs when the memory allocator sees that the + ** total memory allocation is about to exceed the soft heap + ** limit. + */ + static void softHeapLimitEnforcer( + object NotUsed, + sqlite3_int64 NotUsed2, + int allocSize + ) { + UNUSED_PARAMETER2(NotUsed, NotUsed2); + sqlite3_release_memory(allocSize); + } #if !SQLITE_OMIT_DEPRECATED /* @@ -166,614 +156,531 @@ sqlite3_int64 iThreshold } #endif - /* -** Set the soft heap-size limit for the library. Passing a zero or -** negative value indicates no limit. -*/ - static sqlite3_int64 sqlite3_soft_heap_limit64( sqlite3_int64 n ) - { - sqlite3_int64 priorLimit; - sqlite3_int64 excess; + /* + ** Set the soft heap-size limit for the library. Passing a zero or + ** negative value indicates no limit. + */ + static sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n) { + sqlite3_int64 priorLimit; + sqlite3_int64 excess; #if !SQLITE_OMIT_AUTOINIT - sqlite3_initialize(); + sqlite3_initialize(); #endif - sqlite3_mutex_enter( mem0.mutex ); - priorLimit = mem0.alarmThreshold; - sqlite3_mutex_leave( mem0.mutex ); - if ( n < 0 ) - return priorLimit; - if ( n > 0 ) - { - sqlite3MemoryAlarm( softHeapLimitEnforcer, 0, n ); - } - else - { - sqlite3MemoryAlarm( null, 0, 0 ); - } - excess = sqlite3_memory_used() - n; - if ( excess > 0 ) - sqlite3_release_memory( (int)( excess & 0x7fffffff ) ); - return priorLimit; - } - void sqlite3_soft_heap_limit( int n ) - { - if ( n < 0 ) - n = 0; - sqlite3_soft_heap_limit64( n ); - } - - /* - ** Initialize the memory allocation subsystem. - */ - static int sqlite3MallocInit() - { - if ( sqlite3GlobalConfig.m.xMalloc == null ) - { - sqlite3MemSetDefault(); - } - mem0 = new Mem0Global( 0, 0, null, 0, null, null, 1, 1, 8, 8 ); //memset(&mem0, 0, sizeof(mem0)); - if ( sqlite3GlobalConfig.bCoreMutex ) - { - mem0.mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MEM ); - } - if ( sqlite3GlobalConfig.pScratch != null && sqlite3GlobalConfig.szScratch >= 100 - && sqlite3GlobalConfig.nScratch >= 0 ) - { - int i; - sqlite3GlobalConfig.szScratch = ROUNDDOWN8( sqlite3GlobalConfig.szScratch - 4 ); - //mem0.aScratchFree = (u32)&((char)sqlite3GlobalConfig.pScratch) - // [sqlite3GlobalConfig.szScratch*sqlite3GlobalConfig.nScratch]; - //for(i=0; i 0) { + sqlite3MemoryAlarm(softHeapLimitEnforcer, 0, n); + } else { + sqlite3MemoryAlarm(null, 0, 0); + } + excess = sqlite3_memory_used() - n; + if (excess > 0) + sqlite3_release_memory((int)(excess & 0x7fffffff)); + return priorLimit; + } + void sqlite3_soft_heap_limit(int n) { + if (n < 0) + n = 0; + sqlite3_soft_heap_limit64(n); + } - /* - ** Deinitialize the memory allocation subsystem. - */ - static void sqlite3MallocEnd() - { - if ( sqlite3GlobalConfig.m.xShutdown != null ) - { - sqlite3GlobalConfig.m.xShutdown( sqlite3GlobalConfig.m.pAppData ); - } - mem0 = new Mem0Global();//memset(&mem0, 0, sizeof(mem0)); - } + /* + ** Initialize the memory allocation subsystem. + */ + static int sqlite3MallocInit() { + if (sqlite3GlobalConfig.m.xMalloc == null) { + sqlite3MemSetDefault(); + } + mem0 = new Mem0Global(0, 0, null, 0, null, null, 1, 1, 8, 8); //memset(&mem0, 0, sizeof(mem0)); + if (sqlite3GlobalConfig.bCoreMutex) { + mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); + } + if (sqlite3GlobalConfig.pScratch != null && sqlite3GlobalConfig.szScratch >= 100 + && sqlite3GlobalConfig.nScratch >= 0) { + int i; + sqlite3GlobalConfig.szScratch = ROUNDDOWN8(sqlite3GlobalConfig.szScratch - 4); + //mem0.aScratchFree = (u32)&((char)sqlite3GlobalConfig.pScratch) + // [sqlite3GlobalConfig.szScratch*sqlite3GlobalConfig.nScratch]; + //for(i=0; i 0 && iThreshold <= nUsed ); - sqlite3_mutex_leave( mem0.mutex ); - return SQLITE_OK; - } + /* + ** Return the amount of memory currently checked out. + */ + static sqlite3_int64 sqlite3_memory_used() { + int n = 0, mx = 0; + sqlite3_int64 res; + sqlite3_status(SQLITE_STATUS_MEMORY_USED, ref n, ref mx, 0); + res = (sqlite3_int64)n; /* Work around bug in Borland C. Ticket #3216 */ + return res; + } - /* - ** Trigger the alarm - */ - static void sqlite3MallocAlarm( int nByte ) - { - dxalarmCallback xCallback;//void (*xCallback)(void*,sqlite3_int64,int); - sqlite3_int64 nowUsed; - object pArg;// void* pArg; - if ( mem0.alarmCallback == null ) - return; - xCallback = mem0.alarmCallback; - nowUsed = sqlite3StatusValue( SQLITE_STATUS_MEMORY_USED ); - pArg = mem0.alarmArg; - mem0.alarmCallback = null; - sqlite3_mutex_leave( mem0.mutex ); - xCallback( pArg, nowUsed, nByte ); - sqlite3_mutex_enter( mem0.mutex ); - mem0.alarmCallback = xCallback; - mem0.alarmArg = pArg; - } + /* + ** Return the maximum amount of memory that has ever been + ** checked out since either the beginning of this process + ** or since the most recent reset. + */ + static sqlite3_int64 sqlite3_memory_highwater(int resetFlag) { + int n = 0, mx = 0; + sqlite3_int64 res; + sqlite3_status(SQLITE_STATUS_MEMORY_USED, ref n, ref mx, resetFlag); + res = (sqlite3_int64)mx; /* Work around bug in Borland C. Ticket #3216 */ + return res; + } - /* - ** Do a memory allocation with statistics and alarms. Assume the - ** lock is already held. - */ - static int mallocWithAlarm( int n, ref int[] pp ) - { - int nFull; - int[] p; - Debug.Assert( sqlite3_mutex_held( mem0.mutex ) ); - nFull = sqlite3GlobalConfig.m.xRoundup( n ); - sqlite3StatusSet( SQLITE_STATUS_MALLOC_SIZE, n ); - if ( mem0.alarmCallback != null ) - { - int nUsed = sqlite3StatusValue( SQLITE_STATUS_MEMORY_USED ); - if ( nUsed >= mem0.alarmThreshold - nFull ) - { - mem0.nearlyFull = true; - sqlite3MallocAlarm( nFull ); + /* + ** Change the alarm callback + */ + static int sqlite3MemoryAlarm( + dxalarmCallback xCallback, //void(*xCallback)(object pArg, sqlite3_int64 used,int N), + object pArg, + sqlite3_int64 iThreshold + ) { + int nUsed; + sqlite3_mutex_enter(mem0.mutex); + mem0.alarmCallback = xCallback; + mem0.alarmArg = pArg; + mem0.alarmThreshold = iThreshold; + nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); + mem0.nearlyFull = (iThreshold > 0 && iThreshold <= nUsed); + sqlite3_mutex_leave(mem0.mutex); + return SQLITE_OK; } - else - { - mem0.nearlyFull = false; + + /* + ** Trigger the alarm + */ + static void sqlite3MallocAlarm(int nByte) { + dxalarmCallback xCallback;//void (*xCallback)(void*,sqlite3_int64,int); + sqlite3_int64 nowUsed; + object pArg;// void* pArg; + if (mem0.alarmCallback == null) + return; + xCallback = mem0.alarmCallback; + nowUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); + pArg = mem0.alarmArg; + mem0.alarmCallback = null; + sqlite3_mutex_leave(mem0.mutex); + xCallback(pArg, nowUsed, nByte); + sqlite3_mutex_enter(mem0.mutex); + mem0.alarmCallback = xCallback; + mem0.alarmArg = pArg; } - } - p = sqlite3GlobalConfig.m.xMallocInt( nFull ); + + /* + ** Do a memory allocation with statistics and alarms. Assume the + ** lock is already held. + */ + static int mallocWithAlarm(int n, ref int[] pp) { + int nFull; + int[] p; + Debug.Assert(sqlite3_mutex_held(mem0.mutex)); + nFull = sqlite3GlobalConfig.m.xRoundup(n); + sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, n); + if (mem0.alarmCallback != null) { + int nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); + if (nUsed >= mem0.alarmThreshold - nFull) { + mem0.nearlyFull = true; + sqlite3MallocAlarm(nFull); + } else { + mem0.nearlyFull = false; + } + } + p = sqlite3GlobalConfig.m.xMallocInt(nFull); #if SQLITE_ENABLE_MEMORY_MANAGEMENT if( p==null && mem0.alarmCallback!=null ){ sqlite3MallocAlarm(nFull); p = sqlite3GlobalConfig.m.xMalloc(nFull); } #endif - if ( p != null ) - { - nFull = sqlite3MallocSize( p ); - sqlite3StatusAdd( SQLITE_STATUS_MEMORY_USED, nFull ); - } - pp = p; - return nFull; - } - static int mallocWithAlarm( int n, ref byte[] pp ) - { - int nFull; - byte[] p; - Debug.Assert( sqlite3_mutex_held( mem0.mutex ) ); - nFull = sqlite3GlobalConfig.m.xRoundup( n ); - sqlite3StatusSet( SQLITE_STATUS_MALLOC_SIZE, n ); - if ( mem0.alarmCallback != null ) - { - int nUsed = sqlite3StatusValue( SQLITE_STATUS_MEMORY_USED ); - if ( nUsed + nFull >= mem0.alarmThreshold ) - { - sqlite3MallocAlarm( nFull ); + if (p != null) { + nFull = sqlite3MallocSize(p); + sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nFull); + } + pp = p; + return nFull; + } + static int mallocWithAlarm(int n, ref byte[] pp) { + int nFull; + byte[] p; + Debug.Assert(sqlite3_mutex_held(mem0.mutex)); + nFull = sqlite3GlobalConfig.m.xRoundup(n); + sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, n); + if (mem0.alarmCallback != null) { + int nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); + if (nUsed + nFull >= mem0.alarmThreshold) { + sqlite3MallocAlarm(nFull); + } + } + p = sqlite3GlobalConfig.m.xMalloc(nFull); + if (p == null && mem0.alarmCallback != null) { + sqlite3MallocAlarm(nFull); + p = sqlite3GlobalConfig.m.xMalloc(nFull); + } + if (p != null) { + nFull = sqlite3MallocSize(p); + sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nFull); + sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, 1); + } + pp = p; + return nFull; } - } - p = sqlite3GlobalConfig.m.xMalloc( nFull ); - if ( p == null && mem0.alarmCallback != null ) - { - sqlite3MallocAlarm( nFull ); - p = sqlite3GlobalConfig.m.xMalloc( nFull ); - } - if ( p != null ) - { - nFull = sqlite3MallocSize( p ); - sqlite3StatusAdd( SQLITE_STATUS_MEMORY_USED, nFull ); - sqlite3StatusAdd( SQLITE_STATUS_MALLOC_COUNT, 1 ); - } - pp = p; - return nFull; - } - /* - ** Allocate memory. This routine is like sqlite3_malloc() except that it - ** assumes the memory subsystem has already been initialized. - */ - static Mem sqlite3Malloc( Mem pMem ) - { - return sqlite3GlobalConfig.m.xMallocMem( pMem ); - } - static int[] sqlite3Malloc( int[] pInt, u32 n ) - { - return sqlite3Malloc( pInt, (int)n ); - } + /* + ** Allocate memory. This routine is like sqlite3_malloc() except that it + ** assumes the memory subsystem has already been initialized. + */ + static Mem sqlite3Malloc(Mem pMem) { + return sqlite3GlobalConfig.m.xMallocMem(pMem); + } + static int[] sqlite3Malloc(int[] pInt, u32 n) { + return sqlite3Malloc(pInt, (int)n); + } - static int[] sqlite3Malloc( int[] pInt, int n ) - { - int[] p = null; - if ( n < 0 || n >= 0x7fffff00 ) - { - /* A memory allocation of a number of bytes which is near the maximum - ** signed integer value might cause an integer overflow inside of the - ** xMalloc(). Hence we limit the maximum size to 0x7fffff00, giving - ** 255 bytes of overhead. SQLite itself will never use anything near - ** this amount. The only way to reach the limit is with sqlite3_malloc() */ - p = null; - } - else if ( sqlite3GlobalConfig.bMemstat ) - { - sqlite3_mutex_enter( mem0.mutex ); - mallocWithAlarm( n, ref p ); - sqlite3_mutex_leave( mem0.mutex ); - } - else - { - p = sqlite3GlobalConfig.m.xMallocInt( n ); - } - return p; - } + static int[] sqlite3Malloc(int[] pInt, int n) { + int[] p = null; + if (n < 0 || n >= 0x7fffff00) { + /* A memory allocation of a number of bytes which is near the maximum + ** signed integer value might cause an integer overflow inside of the + ** xMalloc(). Hence we limit the maximum size to 0x7fffff00, giving + ** 255 bytes of overhead. SQLite itself will never use anything near + ** this amount. The only way to reach the limit is with sqlite3_malloc() */ + p = null; + } else if (sqlite3GlobalConfig.bMemstat) { + sqlite3_mutex_enter(mem0.mutex); + mallocWithAlarm(n, ref p); + sqlite3_mutex_leave(mem0.mutex); + } else { + p = sqlite3GlobalConfig.m.xMallocInt(n); + } + return p; + } - static byte[] sqlite3Malloc( u32 n ) - { - return sqlite3Malloc( (int)n ); - } - static byte[] sqlite3Malloc( int n ) - { - byte[] p = null; - if ( n < 0 || n >= 0x7fffff00 ) - { - /* A memory allocation of a number of bytes which is near the maximum - ** signed integer value might cause an integer overflow inside of the - ** xMalloc(). Hence we limit the maximum size to 0x7fffff00, giving - ** 255 bytes of overhead. SQLite itself will never use anything near - ** this amount. The only way to reach the limit is with sqlite3_malloc() */ - p = null; - } - else if ( sqlite3GlobalConfig.bMemstat ) - { - sqlite3_mutex_enter( mem0.mutex ); - mallocWithAlarm( n, ref p ); - sqlite3_mutex_leave( mem0.mutex ); - } - else - { - p = sqlite3GlobalConfig.m.xMalloc( n ); - } - return p; - } + static byte[] sqlite3Malloc(u32 n) { + return sqlite3Malloc((int)n); + } + static byte[] sqlite3Malloc(int n) { + byte[] p = null; + if (n < 0 || n >= 0x7fffff00) { + /* A memory allocation of a number of bytes which is near the maximum + ** signed integer value might cause an integer overflow inside of the + ** xMalloc(). Hence we limit the maximum size to 0x7fffff00, giving + ** 255 bytes of overhead. SQLite itself will never use anything near + ** this amount. The only way to reach the limit is with sqlite3_malloc() */ + p = null; + } else if (sqlite3GlobalConfig.bMemstat) { + sqlite3_mutex_enter(mem0.mutex); + mallocWithAlarm(n, ref p); + sqlite3_mutex_leave(mem0.mutex); + } else { + p = sqlite3GlobalConfig.m.xMalloc(n); + } + return p; + } - /* - ** This version of the memory allocation is for use by the application. - ** First make sure the memory subsystem is initialized, then do the - ** allocation. - */ - static public byte[] sqlite3_malloc( int n ) - { + /* + ** This version of the memory allocation is for use by the application. + ** First make sure the memory subsystem is initialized, then do the + ** allocation. + */ + static public byte[] sqlite3_malloc(int n) { #if !SQLITE_OMIT_AUTOINIT - if ( sqlite3_initialize() != 0 ) - return null; + if (sqlite3_initialize() != 0) + return null; #endif - return sqlite3Malloc( n ); - } + return sqlite3Malloc(n); + } - /* - ** Each thread may only have a single outstanding allocation from - ** xScratchMalloc(). We verify this constraint in the single-threaded - ** case by setting scratchAllocOut to 1 when an allocation - ** is outstanding clearing it when the allocation is freed. - */ + /* + ** Each thread may only have a single outstanding allocation from + ** xScratchMalloc(). We verify this constraint in the single-threaded + ** case by setting scratchAllocOut to 1 when an allocation + ** is outstanding clearing it when the allocation is freed. + */ #if SQLITE_THREADSAFE && !(NDEBUG) - static int scratchAllocOut = 0; + static int scratchAllocOut = 0; #endif - /* -** Allocate memory that is to be used and released right away. -** This routine is similar to alloca() in that it is not intended -** for situations where the memory might be held long-term. This -** routine is intended to get memory to old large transient data -** structures that would not normally fit on the stack of an -** embedded processor. -*/ - static byte[][] sqlite3ScratchMalloc( byte[][] apCell, int n ) - { - apCell = sqlite3GlobalConfig.pScratch2; - if ( apCell == null ) - apCell = new byte[n < 200 ? 200 : n][]; - else if ( apCell.Length < n ) - Array.Resize( ref apCell, n ); - sqlite3GlobalConfig.pScratch2 = null; - return apCell; - } + /* + ** Allocate memory that is to be used and released right away. + ** This routine is similar to alloca() in that it is not intended + ** for situations where the memory might be held long-term. This + ** routine is intended to get memory to old large transient data + ** structures that would not normally fit on the stack of an + ** embedded processor. + */ + static byte[][] sqlite3ScratchMalloc(byte[][] apCell, int n) { + apCell = sqlite3GlobalConfig.pScratch2; + if (apCell == null) + apCell = new byte[n < 200 ? 200 : n][]; + else if (apCell.Length < n) + Array.Resize(ref apCell, n); + sqlite3GlobalConfig.pScratch2 = null; + return apCell; + } - static byte[] sqlite3ScratchMalloc( int n ) - { - byte[] p = null; - Debug.Assert( n > 0 ); + static byte[] sqlite3ScratchMalloc(int n) { + byte[] p = null; + Debug.Assert(n > 0); #if SQLITE_THREADSAFE && !(NDEBUG) - /* Verify that no more than two scratch allocation per thread -** is outstanding at one time. (This is only checked in the -** single-threaded case since checking in the multi-threaded case -** would be much more complicated.) */ - Debug.Assert( scratchAllocOut <= 1 ); + /* Verify that no more than two scratch allocation per thread + ** is outstanding at one time. (This is only checked in the + ** single-threaded case since checking in the multi-threaded case + ** would be much more complicated.) */ + Debug.Assert(scratchAllocOut <= 1); #endif - if ( sqlite3GlobalConfig.szScratch < n ) - { - goto scratch_overflow; - } - else - { - sqlite3_mutex_enter( mem0.mutex ); - if ( mem0.nScratchFree == 0 ) - { - sqlite3_mutex_leave( mem0.mutex ); - goto scratch_overflow; - } - else - { - int i; - //i = mem0.aScratchFree[--mem0.nScratchFree]; - //i *= sqlite3GlobalConfig.szScratch; - for ( i = 0; i < sqlite3GlobalConfig.pScratch.Length; i++ ) - { - if ( sqlite3GlobalConfig.pScratch[i] == null || sqlite3GlobalConfig.pScratch[i].Length < n ) - continue; - p = sqlite3GlobalConfig.pScratch[i];// (void)&((char)sqlite3GlobalConfig.pScratch)[i]; - sqlite3GlobalConfig.pScratch[i] = null; - break; - } - sqlite3_mutex_leave( mem0.mutex ); - if ( p == null ) - goto scratch_overflow; - sqlite3StatusAdd( SQLITE_STATUS_SCRATCH_USED, 1 ); - sqlite3StatusSet( SQLITE_STATUS_SCRATCH_SIZE, n ); - //Debug.Assert( (((u8)p - (u8)0) & 7)==0 ); - } - } + if (sqlite3GlobalConfig.szScratch < n) { + goto scratch_overflow; + } else { + sqlite3_mutex_enter(mem0.mutex); + if (mem0.nScratchFree == 0) { + sqlite3_mutex_leave(mem0.mutex); + goto scratch_overflow; + } else { + int i; + //i = mem0.aScratchFree[--mem0.nScratchFree]; + //i *= sqlite3GlobalConfig.szScratch; + for (i = 0; i < sqlite3GlobalConfig.pScratch.Length; i++) { + if (sqlite3GlobalConfig.pScratch[i] == null || sqlite3GlobalConfig.pScratch[i].Length < n) + continue; + p = sqlite3GlobalConfig.pScratch[i];// (void)&((char)sqlite3GlobalConfig.pScratch)[i]; + sqlite3GlobalConfig.pScratch[i] = null; + break; + } + sqlite3_mutex_leave(mem0.mutex); + if (p == null) + goto scratch_overflow; + sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, 1); + sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n); + //Debug.Assert( (((u8)p - (u8)0) & 7)==0 ); + } + } #if SQLITE_THREADSAFE && !(NDEBUG) - scratchAllocOut = ( p != null ? 1 : 0 ); + scratchAllocOut = (p != null ? 1 : 0); #endif - return p; - -scratch_overflow: - if ( sqlite3GlobalConfig.bMemstat ) - { - sqlite3_mutex_enter( mem0.mutex ); - sqlite3StatusSet( SQLITE_STATUS_SCRATCH_SIZE, n ); - n = mallocWithAlarm( n, ref p ); - if ( p != null ) - sqlite3StatusAdd( SQLITE_STATUS_SCRATCH_OVERFLOW, n ); - sqlite3_mutex_leave( mem0.mutex ); - } - else - { - p = sqlite3GlobalConfig.m.xMalloc( n ); - } - sqlite3MemdebugSetType( p, MEMTYPE_SCRATCH ); + return p; + + scratch_overflow: + if (sqlite3GlobalConfig.bMemstat) { + sqlite3_mutex_enter(mem0.mutex); + sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n); + n = mallocWithAlarm(n, ref p); + if (p != null) + sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, n); + sqlite3_mutex_leave(mem0.mutex); + } else { + p = sqlite3GlobalConfig.m.xMalloc(n); + } + sqlite3MemdebugSetType(p, MEMTYPE_SCRATCH); #if SQLITE_THREADSAFE && !(NDEBUG) - scratchAllocOut = ( p != null ) ? 1 : 0; + scratchAllocOut = (p != null) ? 1 : 0; #endif - return p; - } - static void sqlite3ScratchFree( byte[][] p ) - { - if ( p != null ) - { - - if ( sqlite3GlobalConfig.pScratch2 == null || sqlite3GlobalConfig.pScratch2.Length < p.Length ) - { - Debug.Assert( sqlite3MemdebugHasType( p, MEMTYPE_SCRATCH ) ); - Debug.Assert( sqlite3MemdebugNoType( p, ~MEMTYPE_SCRATCH ) ); - sqlite3MemdebugSetType( p, MEMTYPE_HEAP ); - if ( sqlite3GlobalConfig.bMemstat ) - { - int iSize = sqlite3MallocSize( p ); - sqlite3_mutex_enter( mem0.mutex ); - sqlite3StatusAdd( SQLITE_STATUS_SCRATCH_OVERFLOW, -iSize ); - sqlite3StatusAdd( SQLITE_STATUS_MEMORY_USED, -iSize ); - sqlite3StatusAdd( SQLITE_STATUS_MALLOC_COUNT, -1 ); - sqlite3GlobalConfig.pScratch2 = p;// sqlite3GlobalConfig.m.xFree(ref p); - sqlite3_mutex_leave( mem0.mutex ); - } - else - { - sqlite3GlobalConfig.pScratch2 = p;//sqlite3GlobalConfig.m.xFree(ref p); - } + return p; } - else // larger Scratch 2 already in use, let the C# GC handle - { - //int i; - //i = (int)((u8)p - (u8)sqlite3GlobalConfig.pScratch); - //i /= sqlite3GlobalConfig.szScratch; - //Debug.Assert(i >= 0 && i < sqlite3GlobalConfig.nScratch); - //sqlite3_mutex_enter(mem0.mutex); - //Debug.Assert(mem0.nScratchFree < (u32)sqlite3GlobalConfig.nScratch); - //mem0.aScratchFree[mem0.nScratchFree++] = i; - //sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, -1); - //sqlite3_mutex_leave(mem0.mutex); + static void sqlite3ScratchFree(byte[][] p) { + if (p != null) { + + if (sqlite3GlobalConfig.pScratch2 == null || sqlite3GlobalConfig.pScratch2.Length < p.Length) { + Debug.Assert(sqlite3MemdebugHasType(p, MEMTYPE_SCRATCH)); + Debug.Assert(sqlite3MemdebugNoType(p, ~MEMTYPE_SCRATCH)); + sqlite3MemdebugSetType(p, MEMTYPE_HEAP); + if (sqlite3GlobalConfig.bMemstat) { + int iSize = sqlite3MallocSize(p); + sqlite3_mutex_enter(mem0.mutex); + sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, -iSize); + sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -iSize); + sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, -1); + sqlite3GlobalConfig.pScratch2 = p;// sqlite3GlobalConfig.m.xFree(ref p); + sqlite3_mutex_leave(mem0.mutex); + } else { + sqlite3GlobalConfig.pScratch2 = p;//sqlite3GlobalConfig.m.xFree(ref p); + } + } else // larger Scratch 2 already in use, let the C# GC handle + { + //int i; + //i = (int)((u8)p - (u8)sqlite3GlobalConfig.pScratch); + //i /= sqlite3GlobalConfig.szScratch; + //Debug.Assert(i >= 0 && i < sqlite3GlobalConfig.nScratch); + //sqlite3_mutex_enter(mem0.mutex); + //Debug.Assert(mem0.nScratchFree < (u32)sqlite3GlobalConfig.nScratch); + //mem0.aScratchFree[mem0.nScratchFree++] = i; + //sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, -1); + //sqlite3_mutex_leave(mem0.mutex); #if SQLITE_THREADSAFE && !(NDEBUG) - /* Verify that no more than two scratch allocation per thread -** is outstanding at one time. (This is only checked in the -** single-threaded case since checking in the multi-threaded case -** would be much more complicated.) */ - Debug.Assert( scratchAllocOut >= 1 && scratchAllocOut <= 2 ); - scratchAllocOut = 0; + /* Verify that no more than two scratch allocation per thread + ** is outstanding at one time. (This is only checked in the + ** single-threaded case since checking in the multi-threaded case + ** would be much more complicated.) */ + Debug.Assert(scratchAllocOut >= 1 && scratchAllocOut <= 2); + scratchAllocOut = 0; #endif + } + //if( p>=sqlite3GlobalConfig.pScratch && ppNext = mem0.pScratchFree; + // mem0.pScratchFree = pSlot; + // mem0.nScratchFree++; + // Debug.Assert( mem0.nScratchFree <= (u32)sqlite3GlobalConfig.nScratch ); + // sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, -1); + // sqlite3_mutex_leave(mem0.mutex); + //}else{ + // /* Release memory back to the heap */ + // Debug.Assert( sqlite3MemdebugHasType(p, MEMTYPE_SCRATCH) ); + // Debug.Assert( sqlite3MemdebugNoType(p, ~MEMTYPE_SCRATCH) ); + // sqlite3MemdebugSetType(p, MEMTYPE_HEAP); + // if( sqlite3GlobalConfig.bMemstat ){ + // int iSize = sqlite3MallocSize(p); + // sqlite3_mutex_enter(mem0.mutex); + // sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, -iSize); + // sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -iSize); + // sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, -1); + // sqlite3GlobalConfig.m.xFree(p); + // sqlite3_mutex_leave(mem0.mutex); + // }else{ + // sqlite3GlobalConfig.m.xFree(p); + // } + p = null; + } } - //if( p>=sqlite3GlobalConfig.pScratch && ppNext = mem0.pScratchFree; - // mem0.pScratchFree = pSlot; - // mem0.nScratchFree++; - // Debug.Assert( mem0.nScratchFree <= (u32)sqlite3GlobalConfig.nScratch ); - // sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, -1); - // sqlite3_mutex_leave(mem0.mutex); - //}else{ - // /* Release memory back to the heap */ - // Debug.Assert( sqlite3MemdebugHasType(p, MEMTYPE_SCRATCH) ); - // Debug.Assert( sqlite3MemdebugNoType(p, ~MEMTYPE_SCRATCH) ); - // sqlite3MemdebugSetType(p, MEMTYPE_HEAP); - // if( sqlite3GlobalConfig.bMemstat ){ - // int iSize = sqlite3MallocSize(p); - // sqlite3_mutex_enter(mem0.mutex); - // sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, -iSize); - // sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -iSize); - // sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, -1); - // sqlite3GlobalConfig.m.xFree(p); - // sqlite3_mutex_leave(mem0.mutex); - // }else{ - // sqlite3GlobalConfig.m.xFree(p); - // } - p = null; - } - } - /* - ** TRUE if p is a lookaside memory allocation from db - */ + /* + ** TRUE if p is a lookaside memory allocation from db + */ #if !SQLITE_OMIT_LOOKASIDE static int isLookaside(sqlite3 db, object *p){ return p && p>=db.lookaside.pStart && p= 0x7fffff00 ) - { - /* The 0x7ffff00 limit term is explained in comments on sqlite3Malloc() */ - return null; - } - nOld = sqlite3MallocSize( pOld ); - nNew = sqlite3GlobalConfig.m.xRoundup( nBytes ); - if ( nOld == nNew ) - { - pNew = pOld; - } - else if ( sqlite3GlobalConfig.bMemstat ) - { - sqlite3_mutex_enter( mem0.mutex ); - sqlite3StatusSet( SQLITE_STATUS_MALLOC_SIZE, nBytes ); - nDiff = nNew - nOld; - if ( sqlite3StatusValue( SQLITE_STATUS_MEMORY_USED ) >= - mem0.alarmThreshold - nDiff ) - { - sqlite3MallocAlarm( nDiff ); + //{ + // Debug.Assert( sqlite3MemdebugHasType( p, MEMTYPE_DB ) ); + // Debug.Assert( sqlite3MemdebugHasType( p, MEMTYPE_LOOKASIDE | MEMTYPE_HEAP ) ); + // Debug.Assert( db != null || sqlite3MemdebugNoType( p, MEMTYPE_LOOKASIDE ) ); + // sqlite3MemdebugSetType( p, MEMTYPE_HEAP ); + // sqlite3_free( ref p ); + //} + } } - Debug.Assert( sqlite3MemdebugHasType( pOld, MEMTYPE_HEAP ) ); - Debug.Assert( sqlite3MemdebugNoType( pOld, ~MEMTYPE_HEAP ) ); - pNew = sqlite3GlobalConfig.m.xRealloc( pOld, nNew ); - if ( pNew == null && mem0.alarmCallback != null ) - { - sqlite3MallocAlarm( nBytes ); - pNew = sqlite3GlobalConfig.m.xRealloc( pOld, nNew ); - } - if ( pNew != null ) - { - nNew = sqlite3MallocSize( pNew ); - sqlite3StatusAdd( SQLITE_STATUS_MEMORY_USED, nNew - nOld ); + + /* + ** Change the size of an existing memory allocation + */ + static byte[] sqlite3Realloc(byte[] pOld, int nBytes) { + int nOld, nNew, nDiff; + byte[] pNew; + if (pOld == null) { + pOld = sqlite3Malloc(nBytes); + return pOld; + } + if (nBytes < 0) { + sqlite3_free(ref pOld); + return null; + } + if (nBytes >= 0x7fffff00) { + /* The 0x7ffff00 limit term is explained in comments on sqlite3Malloc() */ + return null; + } + nOld = sqlite3MallocSize(pOld); + nNew = sqlite3GlobalConfig.m.xRoundup(nBytes); + if (nOld == nNew) { + pNew = pOld; + } else if (sqlite3GlobalConfig.bMemstat) { + sqlite3_mutex_enter(mem0.mutex); + sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, nBytes); + nDiff = nNew - nOld; + if (sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED) >= + mem0.alarmThreshold - nDiff) { + sqlite3MallocAlarm(nDiff); + } + Debug.Assert(sqlite3MemdebugHasType(pOld, MEMTYPE_HEAP)); + Debug.Assert(sqlite3MemdebugNoType(pOld, ~MEMTYPE_HEAP)); + pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew); + if (pNew == null && mem0.alarmCallback != null) { + sqlite3MallocAlarm(nBytes); + pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew); + } + if (pNew != null) { + nNew = sqlite3MallocSize(pNew); + sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nNew - nOld); + } + sqlite3_mutex_leave(mem0.mutex); + } else { + pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew); + } + return pNew; } - sqlite3_mutex_leave( mem0.mutex ); - } - else - { - pNew = sqlite3GlobalConfig.m.xRealloc( pOld, nNew ); - } - return pNew; - } - /* - ** The public interface to sqlite3Realloc. Make sure that the memory - ** subsystem is initialized prior to invoking sqliteRealloc. - */ - static byte[] sqlite3_realloc( byte[] pOld, int n ) - { + /* + ** The public interface to sqlite3Realloc. Make sure that the memory + ** subsystem is initialized prior to invoking sqliteRealloc. + */ + static byte[] sqlite3_realloc(byte[] pOld, int n) { #if !SQLITE_OMIT_AUTOINIT - if ( sqlite3_initialize() != 0 ) - return null; + if (sqlite3_initialize() != 0) + return null; #endif - return sqlite3Realloc( pOld, n ); - } + return sqlite3Realloc(pOld, n); + } - /* - ** Allocate and zero memory. - */ - static byte[] sqlite3MallocZero( int n ) - { - byte[] p = sqlite3Malloc( n ); - if ( p != null ) - { - Array.Clear( p, 0, n );// memset(p, 0, n); - } - return p; - } + /* + ** Allocate and zero memory. + */ + static byte[] sqlite3MallocZero(int n) { + byte[] p = sqlite3Malloc(n); + if (p != null) { + Array.Clear(p, 0, n);// memset(p, 0, n); + } + return p; + } - /* - ** Allocate and zero memory. If the allocation fails, make - ** the mallocFailed flag in the connection pointer. - */ - static Mem sqlite3DbMallocZero( sqlite3 db, Mem m ) - { - return new Mem(); - } + /* + ** Allocate and zero memory. If the allocation fails, make + ** the mallocFailed flag in the connection pointer. + */ + static Mem sqlite3DbMallocZero(sqlite3 db, Mem m) { + return new Mem(); + } - static byte[] sqlite3DbMallocZero( sqlite3 db, int n ) - { - byte[] p = sqlite3DbMallocRaw( db, n ); - if ( p != null ) - { - Array.Clear( p, 0, n );// memset(p, 0, n); - } - return p; - } + static byte[] sqlite3DbMallocZero(sqlite3 db, int n) { + byte[] p = sqlite3DbMallocRaw(db, n); + if (p != null) { + Array.Clear(p, 0, n);// memset(p, 0, n); + } + return p; + } - /* - ** Allocate and zero memory. If the allocation fails, make - ** the mallocFailed flag in the connection pointer. - ** - ** If db!=0 and db->mallocFailed is true (indicating a prior malloc - ** failure on the same database connection) then always return 0. - ** Hence for a particular database connection, once malloc starts - ** failing, it fails consistently until mallocFailed is reset. - ** This is an important assumption. There are many places in the - ** code that do things like this: - ** - ** int *a = (int)sqlite3DbMallocRaw(db, 100); - ** int *b = (int)sqlite3DbMallocRaw(db, 200); - ** if( b ) a[10] = 9; - ** - ** In other words, if a subsequent malloc (ex: "b") worked, it is assumed - ** that all prior mallocs (ex: "a") worked too. - */ - static byte[] sqlite3DbMallocRaw( sqlite3 db, int n ) - { - byte[] p; - Debug.Assert( db == null || sqlite3_mutex_held( db.mutex ) ); - Debug.Assert( db == null || db.pnBytesFreed == 0 ); + /* + ** Allocate and zero memory. If the allocation fails, make + ** the mallocFailed flag in the connection pointer. + ** + ** If db!=0 and db->mallocFailed is true (indicating a prior malloc + ** failure on the same database connection) then always return 0. + ** Hence for a particular database connection, once malloc starts + ** failing, it fails consistently until mallocFailed is reset. + ** This is an important assumption. There are many places in the + ** code that do things like this: + ** + ** int *a = (int)sqlite3DbMallocRaw(db, 100); + ** int *b = (int)sqlite3DbMallocRaw(db, 200); + ** if( b ) a[10] = 9; + ** + ** In other words, if a subsequent malloc (ex: "b") worked, it is assumed + ** that all prior mallocs (ex: "a") worked too. + */ + static byte[] sqlite3DbMallocRaw(sqlite3 db, int n) { + byte[] p; + Debug.Assert(db == null || sqlite3_mutex_held(db.mutex)); + Debug.Assert(db == null || db.pnBytesFreed == 0); #if !SQLITE_OMIT_LOOKASIDE if( db ){ LookasideSlot *pBuf; @@ -944,35 +832,33 @@ static byte[] sqlite3DbMallocRaw( sqlite3 db, int n ) } } #else - //if( db && db->mallocFailed ){ - // return 0; - //} + //if( db && db->mallocFailed ){ + // return 0; + //} #endif - p = sqlite3Malloc( n ); - //if( null==p && db ){ - // db->mallocFailed = 1; - //} + p = sqlite3Malloc(n); + //if( null==p && db ){ + // db->mallocFailed = 1; + //} #if !SQLITE_OMIT_LOOKASIDE sqlite3MemdebugSetType(p, MEMTYPE_DB | ((db !=null && db.lookaside.bEnabled) ? MEMTYPE_LOOKASIDE : MEMTYPE_HEAP)); #endif - return p; - } + return p; + } - /* - ** Resize the block of memory pointed to by p to n bytes. If the - ** resize fails, set the mallocFailed flag in the connection object. - */ - static byte[] sqlite3DbRealloc( sqlite3 db, byte[] p, int n ) - { - byte[] pNew = null; - Debug.Assert( db != null ); - Debug.Assert( sqlite3_mutex_held( db.mutex ) ); - //if( db->mallocFailed==0 ){ - if ( p == null ) - { - return sqlite3DbMallocRaw( db, n ); - } + /* + ** Resize the block of memory pointed to by p to n bytes. If the + ** resize fails, set the mallocFailed flag in the connection object. + */ + static byte[] sqlite3DbRealloc(sqlite3 db, byte[] p, int n) { + byte[] pNew = null; + Debug.Assert(db != null); + Debug.Assert(sqlite3_mutex_held(db.mutex)); + //if( db->mallocFailed==0 ){ + if (p == null) { + return sqlite3DbMallocRaw(db, n); + } #if !SQLITE_OMIT_LOOKASIDE if( isLookaside(db, p) ){ if( n<=db->lookaside.sz ){ @@ -985,131 +871,124 @@ static byte[] sqlite3DbRealloc( sqlite3 db, byte[] p, int n ) } }else #else - { - { + { + { #endif - Debug.Assert( sqlite3MemdebugHasType( p, MEMTYPE_DB ) ); - Debug.Assert( sqlite3MemdebugHasType( p, MEMTYPE_LOOKASIDE | MEMTYPE_HEAP ) ); - sqlite3MemdebugSetType( p, MEMTYPE_HEAP ); - pNew = sqlite3_realloc( p, n ); - //if( null==pNew ){ - //sqlite3MemdebugSetType(p, MEMTYPE_DB|MEMTYPE_HEAP); - // db->mallocFailed = 1; - //} + Debug.Assert(sqlite3MemdebugHasType(p, MEMTYPE_DB)); + Debug.Assert(sqlite3MemdebugHasType(p, MEMTYPE_LOOKASIDE | MEMTYPE_HEAP)); + sqlite3MemdebugSetType(p, MEMTYPE_HEAP); + pNew = sqlite3_realloc(p, n); + //if( null==pNew ){ + //sqlite3MemdebugSetType(p, MEMTYPE_DB|MEMTYPE_HEAP); + // db->mallocFailed = 1; + //} #if !SQLITE_OMIT_LOOKASIDE sqlite3MemdebugSetType(pNew, MEMTYPE_DB | (db.lookaside.bEnabled ? MEMTYPE_LOOKASIDE : MEMTYPE_HEAP)); #endif + } + } + return pNew; } - } - return pNew; - } - /* - ** Attempt to reallocate p. If the reallocation fails, then free p - ** and set the mallocFailed flag in the database connection. - */ - static byte[] sqlite3DbReallocOrFree( sqlite3 db, byte[] p, int n ) - { - byte[] pNew; - pNew = sqlite3DbRealloc( db, p, n ); - if ( null == pNew ) - { - sqlite3DbFree( db, ref p ); - } - return pNew; - } + /* + ** Attempt to reallocate p. If the reallocation fails, then free p + ** and set the mallocFailed flag in the database connection. + */ + static byte[] sqlite3DbReallocOrFree(sqlite3 db, byte[] p, int n) { + byte[] pNew; + pNew = sqlite3DbRealloc(db, p, n); + if (null == pNew) { + sqlite3DbFree(db, ref p); + } + return pNew; + } - /* - ** Make a copy of a string in memory obtained from sqliteMalloc(). These - ** functions call sqlite3MallocRaw() directly instead of sqliteMalloc(). This - ** is because when memory debugging is turned on, these two functions are - ** called via macros that record the current file and line number in the - ** ThreadData structure. - */ - //char *sqlite3DbStrDup(sqlite3 db, string z){ - // string zNew; - // size_t n; - // if( z==0 ){ - // return 0; - // } - // n = sqlite3Strlen30(z) + 1; - // Debug.Assert( (n&0x7fffffff)==n ); - // zNew = sqlite3DbMallocRaw(db, (int)n); - // if( zNew ){ - // memcpy(zNew, z, n); - // } - // return zNew; - //} - //char *sqlite3DbStrNDup(sqlite3 db, string z, int n){ - // string zNew; - // if( z==0 ){ - // return 0; - // } - // Debug.Assert( (n&0x7fffffff)==n ); - // zNew = sqlite3DbMallocRaw(db, n+1); - // if( zNew ){ - // memcpy(zNew, z, n); - // zNew[n] = 0; - // } - // return zNew; - //} + /* + ** Make a copy of a string in memory obtained from sqliteMalloc(). These + ** functions call sqlite3MallocRaw() directly instead of sqliteMalloc(). This + ** is because when memory debugging is turned on, these two functions are + ** called via macros that record the current file and line number in the + ** ThreadData structure. + */ + //char *sqlite3DbStrDup(sqlite3 db, string z){ + // string zNew; + // size_t n; + // if( z==0 ){ + // return 0; + // } + // n = sqlite3Strlen30(z) + 1; + // Debug.Assert( (n&0x7fffffff)==n ); + // zNew = sqlite3DbMallocRaw(db, (int)n); + // if( zNew ){ + // memcpy(zNew, z, n); + // } + // return zNew; + //} + //char *sqlite3DbStrNDup(sqlite3 db, string z, int n){ + // string zNew; + // if( z==0 ){ + // return 0; + // } + // Debug.Assert( (n&0x7fffffff)==n ); + // zNew = sqlite3DbMallocRaw(db, n+1); + // if( zNew ){ + // memcpy(zNew, z, n); + // zNew[n] = 0; + // } + // return zNew; + //} - /* - ** Create a string from the zFromat argument and the va_list that follows. - ** Store the string in memory obtained from sqliteMalloc() and make pz - ** point to that string. - */ - static void sqlite3SetString( ref string pz, sqlite3 db, string zFormat, params string[] ap ) - { - //va_list ap; - lock ( lock_va_list ) - { - string z; + /* + ** Create a string from the zFromat argument and the va_list that follows. + ** Store the string in memory obtained from sqliteMalloc() and make pz + ** point to that string. + */ + static void sqlite3SetString(ref string pz, sqlite3 db, string zFormat, params string[] ap) { + //va_list ap; + lock (lock_va_list) { + string z; - va_start( ap, zFormat ); - z = sqlite3VMPrintf( db, zFormat, ap ); - va_end( ref ap ); - sqlite3DbFree( db, ref pz ); - pz = z; - } - } + va_start(ap, zFormat); + z = sqlite3VMPrintf(db, zFormat, ap); + va_end(ref ap); + sqlite3DbFree(db, ref pz); + pz = z; + } + } - /* - ** This function must be called before exiting any API function (i.e. - ** returning control to the user) that has called sqlite3_malloc or - ** sqlite3_realloc. - ** - ** The returned value is normally a copy of the second argument to this - ** function. However, if a malloc() failure has occurred since the previous - ** invocation SQLITE_NOMEM is returned instead. - ** - ** If the first argument, db, is not NULL and a malloc() error has occurred, - ** then the connection error-code (the value returned by sqlite3_errcode()) - ** is set to SQLITE_NOMEM. - */ - static int sqlite3ApiExit( int zero, int rc ) - { - sqlite3 db = null; - return sqlite3ApiExit( db, rc ); - } + /* + ** This function must be called before exiting any API function (i.e. + ** returning control to the user) that has called sqlite3_malloc or + ** sqlite3_realloc. + ** + ** The returned value is normally a copy of the second argument to this + ** function. However, if a malloc() failure has occurred since the previous + ** invocation SQLITE_NOMEM is returned instead. + ** + ** If the first argument, db, is not NULL and a malloc() error has occurred, + ** then the connection error-code (the value returned by sqlite3_errcode()) + ** is set to SQLITE_NOMEM. + */ + static int sqlite3ApiExit(int zero, int rc) { + sqlite3 db = null; + return sqlite3ApiExit(db, rc); + } - static int sqlite3ApiExit( sqlite3 db, int rc ) - { - /* If the db handle is not NULL, then we must hold the connection handle - ** mutex here. Otherwise the read (and possible write) of db.mallocFailed - ** is unsafe, as is the call to sqlite3Error(). - */ - Debug.Assert( db == null || sqlite3_mutex_held( db.mutex ) ); - if ( /*db != null && db.mallocFailed != 0 || */ rc == SQLITE_IOERR_NOMEM ) - { - sqlite3Error( db, SQLITE_NOMEM, "" ); - //db.mallocFailed = 0; - rc = SQLITE_NOMEM; - } - return rc & ( db != null ? db.errMask : 0xff ); + static int sqlite3ApiExit(sqlite3 db, int rc) { + /* If the db handle is not NULL, then we must hold the connection handle + ** mutex here. Otherwise the read (and possible write) of db.mallocFailed + ** is unsafe, as is the call to sqlite3Error(). + */ + Debug.Assert(db == null || sqlite3_mutex_held(db.mutex)); + if ( /*db != null && db.mallocFailed != 0 || */ rc == SQLITE_IOERR_NOMEM) { + sqlite3Error(db, SQLITE_NOMEM, ""); + //db.mallocFailed = 0; + rc = SQLITE_NOMEM; + } + return rc & (db != null ? db.errMask : 0xff); + } } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/mem_Pool.cs b/Src/IronPython.SQLite/c#sqlite/mem_Pool.cs index bd4986555..3e5d2f5b1 100644 --- a/Src/IronPython.SQLite/c#sqlite/mem_Pool.cs +++ b/Src/IronPython.SQLite/c#sqlite/mem_Pool.cs @@ -1,34 +1,26 @@ using System; -using System.Diagnostics; -using System.Runtime.InteropServices; -using sqlite3_int64 = System.Int64; -using u32 = System.UInt32; -using System.Text; +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ************************************************************************* + ** + ** This file contains low-level memory & pool allocation drivers + ** + ** This file contains implementations of the low-level memory allocation + ** routines specified in the sqlite3_mem_methods object. + ** + ************************************************************************* + */ -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ************************************************************************* - ** - ** This file contains low-level memory & pool allocation drivers - ** - ** This file contains implementations of the low-level memory allocation - ** routines specified in the sqlite3_mem_methods object. - ** - ************************************************************************* - */ - - /* - ** Like malloc(), but remember the size of the allocation - ** so that we can find it later using sqlite3MemSize(). - ** - ** For this low-level routine, we are guaranteed that nByte>0 because - ** cases of nByte<=0 will be intercepted and dealt with by higher level - ** routines. - */ + /* + ** Like malloc(), but remember the size of the allocation + ** so that we can find it later using sqlite3MemSize(). + ** + ** For this low-level routine, we are guaranteed that nByte>0 because + ** cases of nByte<=0 will be intercepted and dealt with by higher level + ** routines. + */ #if SQLITE_POOL_MEM #if TRUE static byte[] sqlite3MemMalloc( u32 nByte ) @@ -149,28 +141,26 @@ static BtCursor sqlite3MemMallocBtCursor( BtCursor dummy ) return pBtCursor; } #endif - /* - ** Free memory. - */ - // -- overloads --------------------------------------- - static void sqlite3MemFree( ref T x ) where T : class - { - x = null; - } - static void sqlite3MemFree( ref string x ) - { - x = null; - } - // + /* + ** Free memory. + */ + // -- overloads --------------------------------------- + static void sqlite3MemFree(ref T x) where T : class { + x = null; + } + static void sqlite3MemFree(ref string x) { + x = null; + } + // - /* - ** Like free() but works for allocations obtained from sqlite3MemMalloc() - ** or sqlite3MemRealloc(). - ** - ** For this low-level routine, we already know that pPrior!=0 since - ** cases where pPrior==0 will have been intecepted and dealt with - ** by higher-level routines. - */ + /* + ** Like free() but works for allocations obtained from sqlite3MemMalloc() + ** or sqlite3MemRealloc(). + ** + ** For this low-level routine, we already know that pPrior!=0 since + ** cases where pPrior==0 will have been intecepted and dealt with + ** by higher-level routines. + */ #if SQLITE_POOL_MEM #if TRUE static void sqlite3MemFreeInt( ref int[] pPrior ) @@ -321,120 +311,108 @@ static byte[] sqlite3MemRealloc( ref byte[] pPrior, int nByte ) return pPrior; } #else - /* -** No-op versions of all memory allocation routines -*/ -static byte[] sqlite3MemMalloc(int nByte) { return new byte[nByte]; } -static int[] sqlite3MemMallocInt(int nInt) { return new int[nInt]; } -static Mem sqlite3MemMallocMem( Mem pMem) { return new Mem(); } -static void sqlite3MemFree( ref byte[] pPrior ) { pPrior = null; } -static void sqlite3MemFreeInt( ref int[] pPrior ) { pPrior = null; } -static void sqlite3MemFreeMem(ref Mem pPrior) { pPrior = null; } -static int sqlite3MemInit() { return SQLITE_OK; } -static void sqlite3MemShutdown() { } -static BtCursor sqlite3MemMallocBtCursor( BtCursor dummy ){return new BtCursor();} -static void sqlite3MemFreeBtCursor(ref BtCursor pPrior) { pPrior = null; } + /* + ** No-op versions of all memory allocation routines + */ + static byte[] sqlite3MemMalloc(int nByte) { return new byte[nByte]; } + static int[] sqlite3MemMallocInt(int nInt) { return new int[nInt]; } + static Mem sqlite3MemMallocMem(Mem pMem) { return new Mem(); } + static void sqlite3MemFree(ref byte[] pPrior) { pPrior = null; } + static void sqlite3MemFreeInt(ref int[] pPrior) { pPrior = null; } + static void sqlite3MemFreeMem(ref Mem pPrior) { pPrior = null; } + static int sqlite3MemInit() { return SQLITE_OK; } + static void sqlite3MemShutdown() { } + static BtCursor sqlite3MemMallocBtCursor(BtCursor dummy) { return new BtCursor(); } + static void sqlite3MemFreeBtCursor(ref BtCursor pPrior) { pPrior = null; } #endif - static byte[] sqlite3MemRealloc( byte[] pPrior, int nByte ) - { - Array.Resize( ref pPrior, nByte ); - return pPrior; - } + static byte[] sqlite3MemRealloc(byte[] pPrior, int nByte) { + Array.Resize(ref pPrior, nByte); + return pPrior; + } - /* - ** Report the allocated size of a prior return from xMalloc() - ** or xRealloc(). - */ - static int sqlite3MemSize( byte[] pPrior ) - { - // sqlite3_int64 p; - // if( pPrior==0 ) return 0; - // p = (sqlite3_int64*)pPrior; - // p--; - // return p[0]; - return pPrior == null ? 0 : (int)pPrior.Length; - } + /* + ** Report the allocated size of a prior return from xMalloc() + ** or xRealloc(). + */ + static int sqlite3MemSize(byte[] pPrior) { + // sqlite3_int64 p; + // if( pPrior==0 ) return 0; + // p = (sqlite3_int64*)pPrior; + // p--; + // return p[0]; + return pPrior == null ? 0 : (int)pPrior.Length; + } - /* - ** Round up a request size to the next valid allocation size. - */ - static int sqlite3MemRoundup( int n ) - { - return n;// ROUND8( n ); - } + /* + ** Round up a request size to the next valid allocation size. + */ + static int sqlite3MemRoundup(int n) { + return n;// ROUND8( n ); + } - /* - ** Initialize this module. - */ - static int sqlite3MemInit( object NotUsed ) - { - UNUSED_PARAMETER( NotUsed ); - if ( !sqlite3GlobalConfig.bMemstat ) - { - /* If memory status is enabled, then the malloc.c wrapper will already - ** hold the STATIC_MEM mutex when the routines here are invoked. */ - mem0.mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MEM ); - } - return SQLITE_OK; - } + /* + ** Initialize this module. + */ + static int sqlite3MemInit(object NotUsed) { + UNUSED_PARAMETER(NotUsed); + if (!sqlite3GlobalConfig.bMemstat) { + /* If memory status is enabled, then the malloc.c wrapper will already + ** hold the STATIC_MEM mutex when the routines here are invoked. */ + mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); + } + return SQLITE_OK; + } - /* - ** Deinitialize this module. - */ - static void sqlite3MemShutdown( object NotUsed ) - { + /* + ** Deinitialize this module. + */ + static void sqlite3MemShutdown(object NotUsed) { - UNUSED_PARAMETER( NotUsed ); - return; - } + UNUSED_PARAMETER(NotUsed); + return; + } - /* - ** This routine is the only routine in this file with external linkage. - ** - ** Populate the low-level memory allocation function pointers in - ** sqlite3GlobalConfig.m with pointers to the routines in this file. - */ - static void sqlite3MemSetDefault() - { - sqlite3_mem_methods defaultMethods = new sqlite3_mem_methods( - sqlite3MemMalloc, - sqlite3MemMallocInt, - sqlite3MemMallocMem, - sqlite3MemFree, - sqlite3MemFreeInt, - sqlite3MemFreeMem, - sqlite3MemRealloc, - sqlite3MemSize, - sqlite3MemRoundup, - (dxMemInit)sqlite3MemInit, - (dxMemShutdown)sqlite3MemShutdown, - 0 - ); - sqlite3_config( SQLITE_CONFIG_MALLOC, defaultMethods ); - } + /* + ** This routine is the only routine in this file with external linkage. + ** + ** Populate the low-level memory allocation function pointers in + ** sqlite3GlobalConfig.m with pointers to the routines in this file. + */ + static void sqlite3MemSetDefault() { + sqlite3_mem_methods defaultMethods = new sqlite3_mem_methods( + sqlite3MemMalloc, + sqlite3MemMallocInt, + sqlite3MemMallocMem, + sqlite3MemFree, + sqlite3MemFreeInt, + sqlite3MemFreeMem, + sqlite3MemRealloc, + sqlite3MemSize, + sqlite3MemRoundup, + (dxMemInit)sqlite3MemInit, + (dxMemShutdown)sqlite3MemShutdown, + 0 + ); + sqlite3_config(SQLITE_CONFIG_MALLOC, defaultMethods); + } - static void sqlite3DbFree( sqlite3 db, ref int[] pPrior ) - { - if ( pPrior != null ) - sqlite3MemFreeInt( ref pPrior ); - } - static void sqlite3DbFree( sqlite3 db, ref Mem pPrior ) - { - if ( pPrior != null ) - sqlite3MemFreeMem( ref pPrior ); - } - static void sqlite3DbFree( sqlite3 db, ref Mem[] pPrior ) - { - if ( pPrior != null ) - for ( int i = 0; i < pPrior.Length; i++ ) - sqlite3MemFreeMem( ref pPrior[i] ); - } - static void sqlite3DbFree( sqlite3 db, ref T pT ) where T : class - { - } - static void sqlite3DbFree( sqlite3 db, ref string pString ) - { + static void sqlite3DbFree(sqlite3 db, ref int[] pPrior) { + if (pPrior != null) + sqlite3MemFreeInt(ref pPrior); + } + static void sqlite3DbFree(sqlite3 db, ref Mem pPrior) { + if (pPrior != null) + sqlite3MemFreeMem(ref pPrior); + } + static void sqlite3DbFree(sqlite3 db, ref Mem[] pPrior) { + if (pPrior != null) + for (int i = 0; i < pPrior.Length; i++) + sqlite3MemFreeMem(ref pPrior[i]); + } + static void sqlite3DbFree(sqlite3 db, ref T pT) where T : class { + } + static void sqlite3DbFree(sqlite3 db, ref string pString) { + } } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/memjournal_c.cs b/Src/IronPython.SQLite/c#sqlite/memjournal_c.cs index bc7423ae9..1a61baa15 100644 --- a/Src/IronPython.SQLite/c#sqlite/memjournal_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/memjournal_c.cs @@ -1,321 +1,290 @@ using System; using System.Diagnostics; -using System.Text; -using Bitmask = System.UInt64; -using u8 = System.Byte; -using u16 = System.UInt16; using u32 = System.UInt32; -namespace Community.CsharpSqlite -{ - using sqlite3_int64 = System.Int64; - using MemJournal = Sqlite3.sqlite3_file; +namespace Community.CsharpSqlite { + using MemJournal = Sqlite3.sqlite3_file; + using sqlite3_int64 = System.Int64; - public partial class Sqlite3 - { - /* - ** 2007 August 22 - ** - ** 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 contains code use to implement an in-memory rollback journal. - ** The in-memory rollback journal is used to journal transactions for - ** ":memory:" databases and when the journal_mode=MEMORY pragma is used. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-12-07 20:14:09 a586a4deeb25330037a49df295b36aaf624d0f45 - ** - ************************************************************************* - */ + public partial class Sqlite3 { + /* + ** 2007 August 22 + ** + ** 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 contains code use to implement an in-memory rollback journal. + ** The in-memory rollback journal is used to journal transactions for + ** ":memory:" databases and when the journal_mode=MEMORY pragma is used. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-12-07 20:14:09 a586a4deeb25330037a49df295b36aaf624d0f45 + ** + ************************************************************************* + */ - //#include "sqliteInt.h" + //#include "sqliteInt.h" - /* Forward references to internal structures */ - //typedef struct MemJournal MemJournal; - //typedef struct FilePoint FilePoint; - //typedef struct FileChunk FileChunk; + /* Forward references to internal structures */ + //typedef struct MemJournal MemJournal; + //typedef struct FilePoint FilePoint; + //typedef struct FileChunk FileChunk; - /* Space to hold the rollback journal is allocated in increments of - ** this many bytes. - ** - ** The size chosen is a little less than a power of two. That way, - ** the FileChunk object will have a size that almost exactly fills - ** a power-of-two allocation. This mimimizes wasted space in power-of-two - ** memory allocators. - */ - //#define JOURNAL_CHUNKSIZE ((int)(1024-sizeof(FileChunk*))) - const int JOURNAL_CHUNKSIZE = 4096; + /* Space to hold the rollback journal is allocated in increments of + ** this many bytes. + ** + ** The size chosen is a little less than a power of two. That way, + ** the FileChunk object will have a size that almost exactly fills + ** a power-of-two allocation. This mimimizes wasted space in power-of-two + ** memory allocators. + */ + //#define JOURNAL_CHUNKSIZE ((int)(1024-sizeof(FileChunk*))) + const int JOURNAL_CHUNKSIZE = 4096; - /* Macro to find the minimum of two numeric values. - */ - //#if !MIN - //# define MIN(x,y) ((x)<(y)?(x):(y)) - //#endif - static int MIN( int x, int y ) - { - return ( x < y ) ? x : y; - } - static int MIN( int x, u32 y ) - { - return ( x < y ) ? x : (int)y; - } + /* Macro to find the minimum of two numeric values. + */ + //#if !MIN + //# define MIN(x,y) ((x)<(y)?(x):(y)) + //#endif + static int MIN(int x, int y) { + return (x < y) ? x : y; + } + static int MIN(int x, u32 y) { + return (x < y) ? x : (int)y; + } - /* - ** The rollback journal is composed of a linked list of these structures. - */ - public class FileChunk - { - public FileChunk pNext; /* Next chunk in the journal */ - public byte[] zChunk = new byte[JOURNAL_CHUNKSIZE]; /* Content of this chunk */ - }; + /* + ** The rollback journal is composed of a linked list of these structures. + */ + public class FileChunk { + public FileChunk pNext; /* Next chunk in the journal */ + public byte[] zChunk = new byte[JOURNAL_CHUNKSIZE]; /* Content of this chunk */ + }; - /* - ** An instance of this object serves as a cursor into the rollback journal. - ** The cursor can be either for reading or writing. - */ - public class FilePoint - { - public long iOffset; /* Offset from the beginning of the file */ - public FileChunk pChunk; /* Specific chunk into which cursor points */ - }; + /* + ** An instance of this object serves as a cursor into the rollback journal. + ** The cursor can be either for reading or writing. + */ + public class FilePoint { + public long iOffset; /* Offset from the beginning of the file */ + public FileChunk pChunk; /* Specific chunk into which cursor points */ + }; - /* - ** This subclass is a subclass of sqlite3_file. Each open memory-journal - ** is an instance of this class. - */ - public partial class sqlite3_file - { - //public sqlite3_io_methods pMethods; /* Parent class. MUST BE FIRST */ - public FileChunk pFirst; /* Head of in-memory chunk-list */ - public FilePoint endpoint; /* Pointer to the end of the file */ - public FilePoint readpoint; /* Pointer to the end of the last xRead() */ - }; + /* + ** This subclass is a subclass of sqlite3_file. Each open memory-journal + ** is an instance of this class. + */ + public partial class sqlite3_file { + //public sqlite3_io_methods pMethods; /* Parent class. MUST BE FIRST */ + public FileChunk pFirst; /* Head of in-memory chunk-list */ + public FilePoint endpoint; /* Pointer to the end of the file */ + public FilePoint readpoint; /* Pointer to the end of the last xRead() */ + }; - /* - ** Read data from the in-memory journal file. This is the implementation - ** of the sqlite3_vfs.xRead method. - */ - static int memjrnlRead( - sqlite3_file pJfd, /* The journal file from which to read */ - byte[] zBuf, /* Put the results here */ - int iAmt, /* Number of bytes to read */ - sqlite3_int64 iOfst /* Begin reading at this offset */ - ) - { - MemJournal p = (MemJournal)pJfd; - byte[] zOut = zBuf; - int nRead = iAmt; - int iChunkOffset; - FileChunk pChunk; + /* + ** Read data from the in-memory journal file. This is the implementation + ** of the sqlite3_vfs.xRead method. + */ + static int memjrnlRead( + sqlite3_file pJfd, /* The journal file from which to read */ + byte[] zBuf, /* Put the results here */ + int iAmt, /* Number of bytes to read */ + sqlite3_int64 iOfst /* Begin reading at this offset */ + ) { + MemJournal p = (MemJournal)pJfd; + byte[] zOut = zBuf; + int nRead = iAmt; + int iChunkOffset; + FileChunk pChunk; - /* SQLite never tries to read past the end of a rollback journal file */ - Debug.Assert( iOfst + iAmt <= p.endpoint.iOffset ); + /* SQLite never tries to read past the end of a rollback journal file */ + Debug.Assert(iOfst + iAmt <= p.endpoint.iOffset); - if ( p.readpoint.iOffset != iOfst || iOfst == 0 ) - { - int iOff = 0; - for ( pChunk = p.pFirst; - ALWAYS( pChunk != null ) && ( iOff + JOURNAL_CHUNKSIZE ) <= iOfst; - pChunk = pChunk.pNext - ) - { - iOff += JOURNAL_CHUNKSIZE; - } - } - else - { - pChunk = p.readpoint.pChunk; - } + if (p.readpoint.iOffset != iOfst || iOfst == 0) { + int iOff = 0; + for (pChunk = p.pFirst; + ALWAYS(pChunk != null) && (iOff + JOURNAL_CHUNKSIZE) <= iOfst; + pChunk = pChunk.pNext + ) { + iOff += JOURNAL_CHUNKSIZE; + } + } else { + pChunk = p.readpoint.pChunk; + } - iChunkOffset = (int)( iOfst % JOURNAL_CHUNKSIZE ); - int izOut = 0; - do - { - int iSpace = JOURNAL_CHUNKSIZE - iChunkOffset; - int nCopy = MIN( nRead, ( JOURNAL_CHUNKSIZE - iChunkOffset ) ); - Buffer.BlockCopy( pChunk.zChunk, iChunkOffset, zOut, izOut, nCopy ); //memcpy( zOut, pChunk.zChunk[iChunkOffset], nCopy ); - izOut += nCopy;// zOut += nCopy; - nRead -= iSpace; - iChunkOffset = 0; - } while ( nRead >= 0 && ( pChunk = pChunk.pNext ) != null && nRead > 0 ); - p.readpoint.iOffset = (int)( iOfst + iAmt ); - p.readpoint.pChunk = pChunk; + iChunkOffset = (int)(iOfst % JOURNAL_CHUNKSIZE); + int izOut = 0; + do { + int iSpace = JOURNAL_CHUNKSIZE - iChunkOffset; + int nCopy = MIN(nRead, (JOURNAL_CHUNKSIZE - iChunkOffset)); + Buffer.BlockCopy(pChunk.zChunk, iChunkOffset, zOut, izOut, nCopy); //memcpy( zOut, pChunk.zChunk[iChunkOffset], nCopy ); + izOut += nCopy;// zOut += nCopy; + nRead -= iSpace; + iChunkOffset = 0; + } while (nRead >= 0 && (pChunk = pChunk.pNext) != null && nRead > 0); + p.readpoint.iOffset = (int)(iOfst + iAmt); + p.readpoint.pChunk = pChunk; - return SQLITE_OK; - } + return SQLITE_OK; + } - /* - ** Write data to the file. - */ - static int memjrnlWrite( - sqlite3_file pJfd, /* The journal file into which to write */ - byte[] zBuf, /* Take data to be written from here */ - int iAmt, /* Number of bytes to write */ - sqlite3_int64 iOfst /* Begin writing at this offset into the file */ - ) - { - MemJournal p = (MemJournal)pJfd; - int nWrite = iAmt; - byte[] zWrite = zBuf; - int izWrite = 0; + /* + ** Write data to the file. + */ + static int memjrnlWrite( + sqlite3_file pJfd, /* The journal file into which to write */ + byte[] zBuf, /* Take data to be written from here */ + int iAmt, /* Number of bytes to write */ + sqlite3_int64 iOfst /* Begin writing at this offset into the file */ + ) { + MemJournal p = (MemJournal)pJfd; + int nWrite = iAmt; + byte[] zWrite = zBuf; + int izWrite = 0; - /* An in-memory journal file should only ever be appended to. Random - ** access writes are not required by sqlite. - */ - Debug.Assert( iOfst == p.endpoint.iOffset ); - UNUSED_PARAMETER( iOfst ); + /* An in-memory journal file should only ever be appended to. Random + ** access writes are not required by sqlite. + */ + Debug.Assert(iOfst == p.endpoint.iOffset); + UNUSED_PARAMETER(iOfst); - while ( nWrite > 0 ) - { - FileChunk pChunk = p.endpoint.pChunk; - int iChunkOffset = (int)( p.endpoint.iOffset % JOURNAL_CHUNKSIZE ); - int iSpace = MIN( nWrite, JOURNAL_CHUNKSIZE - iChunkOffset ); + while (nWrite > 0) { + FileChunk pChunk = p.endpoint.pChunk; + int iChunkOffset = (int)(p.endpoint.iOffset % JOURNAL_CHUNKSIZE); + int iSpace = MIN(nWrite, JOURNAL_CHUNKSIZE - iChunkOffset); - if ( iChunkOffset == 0 ) - { - /* New chunk is required to extend the file. */ - FileChunk pNew = new FileChunk();// sqlite3_malloc( sizeof( FileChunk ) ); - if ( null == pNew ) - { - return SQLITE_IOERR_NOMEM; - } - pNew.pNext = null; - if ( pChunk != null ) - { - Debug.Assert( p.pFirst != null ); - pChunk.pNext = pNew; - } - else - { - Debug.Assert( null == p.pFirst ); - p.pFirst = pNew; - } - p.endpoint.pChunk = pNew; - } + if (iChunkOffset == 0) { + /* New chunk is required to extend the file. */ + FileChunk pNew = new FileChunk();// sqlite3_malloc( sizeof( FileChunk ) ); + if (null == pNew) { + return SQLITE_IOERR_NOMEM; + } + pNew.pNext = null; + if (pChunk != null) { + Debug.Assert(p.pFirst != null); + pChunk.pNext = pNew; + } else { + Debug.Assert(null == p.pFirst); + p.pFirst = pNew; + } + p.endpoint.pChunk = pNew; + } - Buffer.BlockCopy( zWrite, izWrite, p.endpoint.pChunk.zChunk, iChunkOffset, iSpace ); //memcpy( &p.endpoint.pChunk.zChunk[iChunkOffset], zWrite, iSpace ); - izWrite += iSpace;//zWrite += iSpace; - nWrite -= iSpace; - p.endpoint.iOffset += iSpace; - } + Buffer.BlockCopy(zWrite, izWrite, p.endpoint.pChunk.zChunk, iChunkOffset, iSpace); //memcpy( &p.endpoint.pChunk.zChunk[iChunkOffset], zWrite, iSpace ); + izWrite += iSpace;//zWrite += iSpace; + nWrite -= iSpace; + p.endpoint.iOffset += iSpace; + } - return SQLITE_OK; - } + return SQLITE_OK; + } - /* - ** Truncate the file. - */ - static int memjrnlTruncate( sqlite3_file pJfd, sqlite3_int64 size ) - { - MemJournal p = (MemJournal)pJfd; - ////FileChunk pChunk; - Debug.Assert( size == 0 ); - UNUSED_PARAMETER( size ); - ////pChunk = p.pFirst; - ////while ( pChunk != null ) - ////{ - ////FileChunk pTmp = pChunk; - ////pChunk = pChunk.pNext; - ////sqlite3_free( ref pTmp ); - ////} - sqlite3MemJournalOpen( pJfd ); - return SQLITE_OK; - } + /* + ** Truncate the file. + */ + static int memjrnlTruncate(sqlite3_file pJfd, sqlite3_int64 size) { + MemJournal p = (MemJournal)pJfd; + ////FileChunk pChunk; + Debug.Assert(size == 0); + UNUSED_PARAMETER(size); + ////pChunk = p.pFirst; + ////while ( pChunk != null ) + ////{ + ////FileChunk pTmp = pChunk; + ////pChunk = pChunk.pNext; + ////sqlite3_free( ref pTmp ); + ////} + sqlite3MemJournalOpen(pJfd); + return SQLITE_OK; + } - /* - ** Close the file. - */ - static int memjrnlClose( MemJournal pJfd ) - { - memjrnlTruncate( pJfd, 0 ); - return SQLITE_OK; - } + /* + ** Close the file. + */ + static int memjrnlClose(MemJournal pJfd) { + memjrnlTruncate(pJfd, 0); + return SQLITE_OK; + } - /* - ** Sync the file. - ** - ** Syncing an in-memory journal is a no-op. And, in fact, this routine - ** is never called in a working implementation. This implementation - ** exists purely as a contingency, in case some malfunction in some other - ** part of SQLite causes Sync to be called by mistake. - */ - static int memjrnlSync( sqlite3_file NotUsed, int NotUsed2 ) - { - UNUSED_PARAMETER2( NotUsed, NotUsed2 ); - return SQLITE_OK; - } + /* + ** Sync the file. + ** + ** Syncing an in-memory journal is a no-op. And, in fact, this routine + ** is never called in a working implementation. This implementation + ** exists purely as a contingency, in case some malfunction in some other + ** part of SQLite causes Sync to be called by mistake. + */ + static int memjrnlSync(sqlite3_file NotUsed, int NotUsed2) { + UNUSED_PARAMETER2(NotUsed, NotUsed2); + return SQLITE_OK; + } - /* - ** Query the size of the file in bytes. - */ - static int memjrnlFileSize( sqlite3_file pJfd, ref long pSize ) - { - MemJournal p = (MemJournal)pJfd; - pSize = p.endpoint.iOffset; - return SQLITE_OK; - } + /* + ** Query the size of the file in bytes. + */ + static int memjrnlFileSize(sqlite3_file pJfd, ref long pSize) { + MemJournal p = (MemJournal)pJfd; + pSize = p.endpoint.iOffset; + return SQLITE_OK; + } - /* - ** Table of methods for MemJournal sqlite3_file object. - */ - static sqlite3_io_methods MemJournalMethods = new sqlite3_io_methods( - 1, /* iVersion */ - (dxClose)memjrnlClose, /* xClose */ - (dxRead)memjrnlRead, /* xRead */ - (dxWrite)memjrnlWrite, /* xWrite */ - (dxTruncate)memjrnlTruncate, /* xTruncate */ - (dxSync)memjrnlSync, /* xSync */ - (dxFileSize)memjrnlFileSize, /* xFileSize */ - null, /* xLock */ - null, /* xUnlock */ - null, /* xCheckReservedLock */ - null, /* xFileControl */ - null, /* xSectorSize */ - null, /* xDeviceCharacteristics */ - null, /* xShmMap */ - null, /* xShmLock */ - null, /* xShmBarrier */ - null /* xShmUnlock */ - ); + /* + ** Table of methods for MemJournal sqlite3_file object. + */ + static sqlite3_io_methods MemJournalMethods = new sqlite3_io_methods( + 1, /* iVersion */ + (dxClose)memjrnlClose, /* xClose */ + (dxRead)memjrnlRead, /* xRead */ + (dxWrite)memjrnlWrite, /* xWrite */ + (dxTruncate)memjrnlTruncate, /* xTruncate */ + (dxSync)memjrnlSync, /* xSync */ + (dxFileSize)memjrnlFileSize, /* xFileSize */ + null, /* xLock */ + null, /* xUnlock */ + null, /* xCheckReservedLock */ + null, /* xFileControl */ + null, /* xSectorSize */ + null, /* xDeviceCharacteristics */ + null, /* xShmMap */ + null, /* xShmLock */ + null, /* xShmBarrier */ + null /* xShmUnlock */ + ); - /* - ** Open a journal file. - */ - static void sqlite3MemJournalOpen( sqlite3_file pJfd ) - { - MemJournal p = (MemJournal)pJfd; - //memset( p, 0, sqlite3MemJournalSize() ); - p.pFirst = null; - p.endpoint = new FilePoint(); - p.readpoint = new FilePoint(); - p.pMethods = MemJournalMethods;//(sqlite3_io_methods*)&MemJournalMethods; - } + /* + ** Open a journal file. + */ + static void sqlite3MemJournalOpen(sqlite3_file pJfd) { + MemJournal p = (MemJournal)pJfd; + //memset( p, 0, sqlite3MemJournalSize() ); + p.pFirst = null; + p.endpoint = new FilePoint(); + p.readpoint = new FilePoint(); + p.pMethods = MemJournalMethods;//(sqlite3_io_methods*)&MemJournalMethods; + } - /* - ** Return true if the file-handle passed as an argument is - ** an in-memory journal - */ - static bool sqlite3IsMemJournal( sqlite3_file pJfd ) - { - return pJfd.pMethods == MemJournalMethods; - } + /* + ** Return true if the file-handle passed as an argument is + ** an in-memory journal + */ + static bool sqlite3IsMemJournal(sqlite3_file pJfd) { + return pJfd.pMethods == MemJournalMethods; + } - /* - ** Return the number of bytes required to store a MemJournal file descriptor. - */ - static int sqlite3MemJournalSize() - { - return 3096; // sizeof( MemJournal ); + /* + ** Return the number of bytes required to store a MemJournal file descriptor. + */ + static int sqlite3MemJournalSize() { + return 3096; // sizeof( MemJournal ); + } } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/mutex_c.cs b/Src/IronPython.SQLite/c#sqlite/mutex_c.cs index 09824d576..b09628257 100644 --- a/Src/IronPython.SQLite/c#sqlite/mutex_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/mutex_c.cs @@ -1,169 +1,165 @@ -using System; using System.Diagnostics; -using System.Threading; - -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 2007 August 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 file contains the C functions that implement mutexes. - ** - ** This file contains code that is common across all mutex implementations. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ - //#include "sqliteInt.h" + +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2007 August 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 file contains the C functions that implement mutexes. + ** + ** This file contains code that is common across all mutex implementations. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ + //#include "sqliteInt.h" #if (SQLITE_DEBUG) && !(SQLITE_MUTEX_OMIT) -/* -** For debugging purposes, record when the mutex subsystem is initialized -** and uninitialized so that we can assert() if there is an attempt to -** allocate a mutex while the system is uninitialized. -*/ -static int mutexIsInit = 0; + /* + ** For debugging purposes, record when the mutex subsystem is initialized + ** and uninitialized so that we can assert() if there is an attempt to + ** allocate a mutex while the system is uninitialized. + */ + static int mutexIsInit = 0; #endif //* SQLITE_DEBUG */ #if !SQLITE_MUTEX_OMIT -/* -** Initialize the mutex system. -*/ -static int sqlite3MutexInit(){ - int rc = SQLITE_OK; - if( null==sqlite3GlobalConfig.mutex.xMutexAlloc ){ - /* If the xMutexAlloc method has not been set, then the user did not - ** install a mutex implementation via sqlite3_config() prior to - ** sqlite3_initialize() being called. This block copies pointers to - ** the default implementation into the sqlite3GlobalConfig structure. - */ - sqlite3_mutex_methods pFrom; - sqlite3_mutex_methods pTo = sqlite3GlobalConfig.mutex; - - if( sqlite3GlobalConfig.bCoreMutex ){ - pFrom = sqlite3DefaultMutex(); - }else{ - pFrom = sqlite3NoopMutex(); - } - //memcpy(pTo, pFrom, offsetof(sqlite3_mutex_methods, xMutexAlloc)); - //memcpy(pTo.xMutexFree, pFrom.xMutexFree, - // sizeof(*pTo) - offsetof(sqlite3_mutex_methods, xMutexFree)); - pTo.Copy(pFrom); - } - rc = sqlite3GlobalConfig.mutex.xMutexInit(); + /* + ** Initialize the mutex system. + */ + static int sqlite3MutexInit() { + int rc = SQLITE_OK; + if (null == sqlite3GlobalConfig.mutex.xMutexAlloc) { + /* If the xMutexAlloc method has not been set, then the user did not + ** install a mutex implementation via sqlite3_config() prior to + ** sqlite3_initialize() being called. This block copies pointers to + ** the default implementation into the sqlite3GlobalConfig structure. + */ + sqlite3_mutex_methods pFrom; + sqlite3_mutex_methods pTo = sqlite3GlobalConfig.mutex; + + if (sqlite3GlobalConfig.bCoreMutex) { + pFrom = sqlite3DefaultMutex(); + } else { + pFrom = sqlite3NoopMutex(); + } + //memcpy(pTo, pFrom, offsetof(sqlite3_mutex_methods, xMutexAlloc)); + //memcpy(pTo.xMutexFree, pFrom.xMutexFree, + // sizeof(*pTo) - offsetof(sqlite3_mutex_methods, xMutexFree)); + pTo.Copy(pFrom); + } + rc = sqlite3GlobalConfig.mutex.xMutexInit(); #if SQLITE_DEBUG - mutexIsInit = 1; //GLOBAL(int, mutexIsInit) = 1; + mutexIsInit = 1; //GLOBAL(int, mutexIsInit) = 1; #endif - return rc; -} + return rc; + } -/* -** Shutdown the mutex system. This call frees resources allocated by -** sqlite3MutexInit(). -*/ -static int sqlite3MutexEnd(){ - int rc = SQLITE_OK; - if( sqlite3GlobalConfig.mutex.xMutexEnd !=null){ - rc = sqlite3GlobalConfig.mutex.xMutexEnd(); - } - -#if SQLITE_DEBUG - mutexIsInit = 0;//GLOBAL(int, mutexIsInit) = 0; + /* + ** Shutdown the mutex system. This call frees resources allocated by + ** sqlite3MutexInit(). + */ + static int sqlite3MutexEnd() { + int rc = SQLITE_OK; + if (sqlite3GlobalConfig.mutex.xMutexEnd != null) { + rc = sqlite3GlobalConfig.mutex.xMutexEnd(); + } + +#if SQLITE_DEBUG + mutexIsInit = 0;//GLOBAL(int, mutexIsInit) = 0; #endif - return rc; -} + return rc; + } -/* -** Retrieve a pointer to a static mutex or allocate a new dynamic one. -*/ -static sqlite3_mutex sqlite3_mutex_alloc(int id){ + /* + ** Retrieve a pointer to a static mutex or allocate a new dynamic one. + */ + static sqlite3_mutex sqlite3_mutex_alloc(int id) { #if !SQLITE_OMIT_AUTOINIT - if( sqlite3_initialize()!=0 ) return null; + if (sqlite3_initialize() != 0) return null; #endif - return sqlite3GlobalConfig.mutex.xMutexAlloc(id); -} - -static sqlite3_mutex sqlite3MutexAlloc(int id){ - if( !sqlite3GlobalConfig.bCoreMutex ){ - return null; - } - Debug.Assert( mutexIsInit !=0 );//assert( GLOBAL(int, mutexIsInit) ); - return sqlite3GlobalConfig.mutex.xMutexAlloc(id); -} - -/* -** Free a dynamic mutex. -*/ -static void sqlite3_mutex_free( sqlite3_mutex p){ - if( p!=null ){ - sqlite3GlobalConfig.mutex.xMutexFree( p); - } -} - -/* -** Obtain the mutex p. If some other thread already has the mutex, block -** until it can be obtained. -*/ -static void sqlite3_mutex_enter(sqlite3_mutex p){ - if( p !=null){ - sqlite3GlobalConfig.mutex.xMutexEnter(p); - } -} - -/* -** Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another -** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY. -*/ -static int sqlite3_mutex_try(sqlite3_mutex p){ - int rc = SQLITE_OK; - if( p!=null ){ - return sqlite3GlobalConfig.mutex.xMutexTry(p); - } - return rc; -} - -/* -** The sqlite3_mutex_leave() routine exits a mutex that was previously -** entered by the same thread. The behavior is undefined if the mutex -** is not currently entered. If a NULL pointer is passed as an argument -** this function is a no-op. -*/ -static void sqlite3_mutex_leave(sqlite3_mutex p){ - if( p !=null){ - sqlite3GlobalConfig.mutex.xMutexLeave(p); - } -} + return sqlite3GlobalConfig.mutex.xMutexAlloc(id); + } + + static sqlite3_mutex sqlite3MutexAlloc(int id) { + if (!sqlite3GlobalConfig.bCoreMutex) { + return null; + } + Debug.Assert(mutexIsInit != 0);//assert( GLOBAL(int, mutexIsInit) ); + return sqlite3GlobalConfig.mutex.xMutexAlloc(id); + } + + /* + ** Free a dynamic mutex. + */ + static void sqlite3_mutex_free(sqlite3_mutex p) { + if (p != null) { + sqlite3GlobalConfig.mutex.xMutexFree(p); + } + } + + /* + ** Obtain the mutex p. If some other thread already has the mutex, block + ** until it can be obtained. + */ + static void sqlite3_mutex_enter(sqlite3_mutex p) { + if (p != null) { + sqlite3GlobalConfig.mutex.xMutexEnter(p); + } + } + + /* + ** Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another + ** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY. + */ + static int sqlite3_mutex_try(sqlite3_mutex p) { + int rc = SQLITE_OK; + if (p != null) { + return sqlite3GlobalConfig.mutex.xMutexTry(p); + } + return rc; + } + + /* + ** The sqlite3_mutex_leave() routine exits a mutex that was previously + ** entered by the same thread. The behavior is undefined if the mutex + ** is not currently entered. If a NULL pointer is passed as an argument + ** this function is a no-op. + */ + static void sqlite3_mutex_leave(sqlite3_mutex p) { + if (p != null) { + sqlite3GlobalConfig.mutex.xMutexLeave(p); + } + } #if !NDEBUG -/* -** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are -** intended for use inside assert() statements. -*/ -static bool sqlite3_mutex_held(sqlite3_mutex p){ - return p==null || sqlite3GlobalConfig.mutex.xMutexHeld(p); -} - - static bool sqlite3_mutex_notheld(sqlite3_mutex p){ - return p == null || sqlite3GlobalConfig.mutex.xMutexNotheld( p ); -} + /* + ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are + ** intended for use inside assert() statements. + */ + static bool sqlite3_mutex_held(sqlite3_mutex p) { + return p == null || sqlite3GlobalConfig.mutex.xMutexHeld(p); + } + + static bool sqlite3_mutex_notheld(sqlite3_mutex p) { + return p == null || sqlite3GlobalConfig.mutex.xMutexNotheld(p); + } #else static bool sqlite3_mutex_held(sqlite3_mutex p) { return true; @@ -175,5 +171,5 @@ static bool sqlite3_mutex_notheld(sqlite3_mutex p) { #endif #endif //* SQLITE_MUTEX_OMIT */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/mutex_h.cs b/Src/IronPython.SQLite/c#sqlite/mutex_h.cs index 30318869b..63f206adb 100644 --- a/Src/IronPython.SQLite/c#sqlite/mutex_h.cs +++ b/Src/IronPython.SQLite/c#sqlite/mutex_h.cs @@ -1,72 +1,70 @@ #define SQLITE_OS_WIN -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 2007 August 28 - ** - ** 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 contains the common header for all mutex implementations. - ** The sqliteInt.h header #includes this file so that it is available - ** to all source files. We break it out in an effort to keep the code - ** better organized. - ** - ** NOTE: source files should *not* #include this header file directly. - ** Source files should #include the sqliteInt.h file and let that file - ** include this one indirectly. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-12-07 20:14:09 a586a4deeb25330037a49df295b36aaf624d0f45 - ** - ************************************************************************* - */ +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2007 August 28 + ** + ** 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 contains the common header for all mutex implementations. + ** The sqliteInt.h header #includes this file so that it is available + ** to all source files. We break it out in an effort to keep the code + ** better organized. + ** + ** NOTE: source files should *not* #include this header file directly. + ** Source files should #include the sqliteInt.h file and let that file + ** include this one indirectly. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-12-07 20:14:09 a586a4deeb25330037a49df295b36aaf624d0f45 + ** + ************************************************************************* + */ - /* - ** Figure out what version of the code to use. The choices are - ** - ** SQLITE_MUTEX_OMIT No mutex logic. Not even stubs. The - ** mutexes implemention cannot be overridden - ** at start-time. - ** - ** SQLITE_MUTEX_NOOP For single-threaded applications. No - ** mutual exclusion is provided. But this - ** implementation can be overridden at - ** start-time. - ** - ** SQLITE_MUTEX_PTHREADS For multi-threaded applications on Unix. - ** - ** SQLITE_MUTEX_W32 For multi-threaded applications on Win32. - ** - ** SQLITE_MUTEX_OS2 For multi-threaded applications on OS/2. - */ + /* + ** Figure out what version of the code to use. The choices are + ** + ** SQLITE_MUTEX_OMIT No mutex logic. Not even stubs. The + ** mutexes implemention cannot be overridden + ** at start-time. + ** + ** SQLITE_MUTEX_NOOP For single-threaded applications. No + ** mutual exclusion is provided. But this + ** implementation can be overridden at + ** start-time. + ** + ** SQLITE_MUTEX_PTHREADS For multi-threaded applications on Unix. + ** + ** SQLITE_MUTEX_W32 For multi-threaded applications on Win32. + ** + ** SQLITE_MUTEX_OS2 For multi-threaded applications on OS/2. + */ - //#if !SQLITE_THREADSAFE - //# define SQLITE_MUTEX_OMIT - //#endif - //#if SQLITE_THREADSAFE && !defined(SQLITE_MUTEX_NOOP) - //# if SQLITE_OS_UNIX - //# define SQLITE_MUTEX_PTHREADS - //# elif SQLITE_OS_WIN - //# define SQLITE_MUTEX_W32 - //# elif SQLITE_OS_OS2 - //# define SQLITE_MUTEX_OS2 - //# else - //# define SQLITE_MUTEX_NOOP - //# endif - //#endif + //#if !SQLITE_THREADSAFE + //# define SQLITE_MUTEX_OMIT + //#endif + //#if SQLITE_THREADSAFE && !defined(SQLITE_MUTEX_NOOP) + //# if SQLITE_OS_UNIX + //# define SQLITE_MUTEX_PTHREADS + //# elif SQLITE_OS_WIN + //# define SQLITE_MUTEX_W32 + //# elif SQLITE_OS_OS2 + //# define SQLITE_MUTEX_OS2 + //# else + //# define SQLITE_MUTEX_NOOP + //# endif + //#endif #if WINDOWS_PHONE && SQLITE_THREADSAFE #error Cannot compile with both WINDOWS_PHONE and SQLITE_THREADSAFE @@ -145,5 +143,5 @@ static void sqlite3MutexEnd() { } //#define sqlite3MutexEnd() #endif //* defined(SQLITE_MUTEX_OMIT) */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/mutex_noop_c.cs b/Src/IronPython.SQLite/c#sqlite/mutex_noop_c.cs index 225a24b28..bceb47f2a 100644 --- a/Src/IronPython.SQLite/c#sqlite/mutex_noop_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/mutex_noop_c.cs @@ -1,46 +1,42 @@ -using System; using System.Diagnostics; -using System.Threading; - -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 2008 October 07 - ** - ** 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 contains the C functions that implement mutexes. - ** - ** This implementation in this file does not provide any mutual - ** exclusion and is thus suitable for use only in applications - ** that use SQLite in a single thread. The routines defined - ** here are place-holders. Applications can substitute working - ** mutex routines at start-time using the - ** - ** sqlite3_config(SQLITE_CONFIG_MUTEX,...) - ** - ** interface. - ** - ** If compiled with SQLITE_DEBUG, then additional logic is inserted - ** that does error checking on mutexes to make sure they are being - ** called correctly. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2009-12-07 16:39:13 1ed88e9d01e9eda5cbc622e7614277f29bcc551c - ** - ************************************************************************* - */ - //#include "sqliteInt.h" + +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2008 October 07 + ** + ** 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 contains the C functions that implement mutexes. + ** + ** This implementation in this file does not provide any mutual + ** exclusion and is thus suitable for use only in applications + ** that use SQLite in a single thread. The routines defined + ** here are place-holders. Applications can substitute working + ** mutex routines at start-time using the + ** + ** sqlite3_config(SQLITE_CONFIG_MUTEX,...) + ** + ** interface. + ** + ** If compiled with SQLITE_DEBUG, then additional logic is inserted + ** that does error checking on mutexes to make sure they are being + ** called correctly. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2009-12-07 16:39:13 1ed88e9d01e9eda5cbc622e7614277f29bcc551c + ** + ************************************************************************* + */ + //#include "sqliteInt.h" #if !SQLITE_DEBUG @@ -82,161 +78,146 @@ sqlite3_mutex_methods sqlite3NoopMutex(){ #endif //* !SQLITE_DEBUG */ #if SQLITE_DEBUG && !SQLITE_MUTEX_OMIT - /* -** In this implementation, error checking is provided for testing -** and debugging purposes. The mutexes still do not provide any -** mutual exclusion. -*/ - - /* - ** The mutex object + /* + ** In this implementation, error checking is provided for testing + ** and debugging purposes. The mutexes still do not provide any + ** mutual exclusion. */ - public class sqlite3_debug_mutex : sqlite3_mutex - { - //public int id; /* The mutex type */ - public int cnt; /* Number of entries without a matching leave */ - }; - - /* - ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are - ** intended for use inside Debug.Assert() statements. - */ - static bool debugMutexHeld( sqlite3_mutex pX ) - { - sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; - return p == null || p.cnt > 0; - } - static bool debugMutexNotheld( sqlite3_mutex pX ) - { - sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; - return p == null || p.cnt == 0; - } - /* - ** Initialize and deinitialize the mutex subsystem. - */ - static int debugMutexInit() - { - return SQLITE_OK; - } - static int debugMutexEnd() - { - return SQLITE_OK; - } - - /* - ** The sqlite3_mutex_alloc() routine allocates a new - ** mutex and returns a pointer to it. If it returns NULL - ** that means that a mutex could not be allocated. - */ - static sqlite3_mutex debugMutexAlloc( int id ) - { - sqlite3_debug_mutex[] aStatic = new sqlite3_debug_mutex[6]; - sqlite3_debug_mutex pNew = null; - switch ( id ) - { - case SQLITE_MUTEX_FAST: - case SQLITE_MUTEX_RECURSIVE: - { - pNew = new sqlite3_debug_mutex();//sqlite3Malloc(sizeof(*pNew)); - if ( pNew != null ) - { - pNew.id = id; - pNew.cnt = 0; + /* + ** The mutex object + */ + public class sqlite3_debug_mutex : sqlite3_mutex { + //public int id; /* The mutex type */ + public int cnt; /* Number of entries without a matching leave */ + }; + + /* + ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are + ** intended for use inside Debug.Assert() statements. + */ + static bool debugMutexHeld(sqlite3_mutex pX) { + sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; + return p == null || p.cnt > 0; + } + static bool debugMutexNotheld(sqlite3_mutex pX) { + sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; + return p == null || p.cnt == 0; + } + + /* + ** Initialize and deinitialize the mutex subsystem. + */ + static int debugMutexInit() { + return SQLITE_OK; + } + static int debugMutexEnd() { + return SQLITE_OK; + } + + /* + ** The sqlite3_mutex_alloc() routine allocates a new + ** mutex and returns a pointer to it. If it returns NULL + ** that means that a mutex could not be allocated. + */ + static sqlite3_mutex debugMutexAlloc(int id) { + sqlite3_debug_mutex[] aStatic = new sqlite3_debug_mutex[6]; + sqlite3_debug_mutex pNew = null; + switch (id) { + case SQLITE_MUTEX_FAST: + case SQLITE_MUTEX_RECURSIVE: { + pNew = new sqlite3_debug_mutex();//sqlite3Malloc(sizeof(*pNew)); + if (pNew != null) { + pNew.id = id; + pNew.cnt = 0; + } + break; + } + default: { + Debug.Assert(id - 2 >= 0); + Debug.Assert(id - 2 < aStatic.Length);//(int)(sizeof(aStatic)/sizeof(aStatic[0])) ); + pNew = aStatic[id - 2]; + pNew.id = id; + break; + } } - break; - } - default: - { - Debug.Assert( id - 2 >= 0 ); - Debug.Assert( id - 2 < aStatic.Length );//(int)(sizeof(aStatic)/sizeof(aStatic[0])) ); - pNew = aStatic[id - 2]; - pNew.id = id; - break; - } - } - return pNew; - } - - /* - ** This routine deallocates a previously allocated mutex. - */ - static void debugMutexFree( sqlite3_mutex pX ) - { - sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; - Debug.Assert( p.cnt == 0 ); - Debug.Assert( p.id == SQLITE_MUTEX_FAST || p.id == SQLITE_MUTEX_RECURSIVE ); - //sqlite3_free(ref p); - } - - /* - ** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt - ** to enter a mutex. If another thread is already within the mutex, - ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return - ** SQLITE_BUSY. The sqlite3_mutex_try() interface returns SQLITE_OK - ** upon successful entry. Mutexes created using SQLITE_MUTEX_RECURSIVE can - ** be entered multiple times by the same thread. In such cases the, - ** mutex must be exited an equal number of times before another thread - ** can enter. If the same thread tries to enter any other kind of mutex - ** more than once, the behavior is undefined. - */ - static void debugMutexEnter( sqlite3_mutex pX ) - { - sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; - Debug.Assert( p.id == SQLITE_MUTEX_RECURSIVE || debugMutexNotheld( p ) ); - p.cnt++; - } - - static int debugMutexTry( sqlite3_mutex pX ) - { - sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; - Debug.Assert( p.id == SQLITE_MUTEX_RECURSIVE || debugMutexNotheld( p ) ); - p.cnt++; - return SQLITE_OK; - } - - /* - ** The sqlite3_mutex_leave() routine exits a mutex that was - ** previously entered by the same thread. The behavior - ** is undefined if the mutex is not currently entered or - ** is not currently allocated. SQLite will never do either. - */ - static void debugMutexLeave( sqlite3_mutex pX ) - { - sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; - Debug.Assert( debugMutexHeld( p ) ); - p.cnt--; - Debug.Assert( p.id == SQLITE_MUTEX_RECURSIVE || debugMutexNotheld( p ) ); - } - - static sqlite3_mutex_methods sqlite3NoopMutex() - { - sqlite3_mutex_methods sMutex = new sqlite3_mutex_methods( - (dxMutexInit)debugMutexInit, - (dxMutexEnd)debugMutexEnd, - (dxMutexAlloc)debugMutexAlloc, - (dxMutexFree)debugMutexFree, - (dxMutexEnter)debugMutexEnter, - (dxMutexTry)debugMutexTry, - (dxMutexLeave)debugMutexLeave, - - (dxMutexHeld)debugMutexHeld, - (dxMutexNotheld)debugMutexNotheld - ); - - return sMutex; - } + return pNew; + } + + /* + ** This routine deallocates a previously allocated mutex. + */ + static void debugMutexFree(sqlite3_mutex pX) { + sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; + Debug.Assert(p.cnt == 0); + Debug.Assert(p.id == SQLITE_MUTEX_FAST || p.id == SQLITE_MUTEX_RECURSIVE); + //sqlite3_free(ref p); + } + + /* + ** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt + ** to enter a mutex. If another thread is already within the mutex, + ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return + ** SQLITE_BUSY. The sqlite3_mutex_try() interface returns SQLITE_OK + ** upon successful entry. Mutexes created using SQLITE_MUTEX_RECURSIVE can + ** be entered multiple times by the same thread. In such cases the, + ** mutex must be exited an equal number of times before another thread + ** can enter. If the same thread tries to enter any other kind of mutex + ** more than once, the behavior is undefined. + */ + static void debugMutexEnter(sqlite3_mutex pX) { + sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; + Debug.Assert(p.id == SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(p)); + p.cnt++; + } + + static int debugMutexTry(sqlite3_mutex pX) { + sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; + Debug.Assert(p.id == SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(p)); + p.cnt++; + return SQLITE_OK; + } + + /* + ** The sqlite3_mutex_leave() routine exits a mutex that was + ** previously entered by the same thread. The behavior + ** is undefined if the mutex is not currently entered or + ** is not currently allocated. SQLite will never do either. + */ + static void debugMutexLeave(sqlite3_mutex pX) { + sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; + Debug.Assert(debugMutexHeld(p)); + p.cnt--; + Debug.Assert(p.id == SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(p)); + } + + static sqlite3_mutex_methods sqlite3NoopMutex() { + sqlite3_mutex_methods sMutex = new sqlite3_mutex_methods( + (dxMutexInit)debugMutexInit, + (dxMutexEnd)debugMutexEnd, + (dxMutexAlloc)debugMutexAlloc, + (dxMutexFree)debugMutexFree, + (dxMutexEnter)debugMutexEnter, + (dxMutexTry)debugMutexTry, + (dxMutexLeave)debugMutexLeave, + + (dxMutexHeld)debugMutexHeld, + (dxMutexNotheld)debugMutexNotheld + ); + + return sMutex; + } #endif //* SQLITE_DEBUG */ - /* -** If compiled with SQLITE_MUTEX_NOOP, then the no-op mutex implementation -** is used regardless of the run-time threadsafety setting. -*/ + /* + ** If compiled with SQLITE_MUTEX_NOOP, then the no-op mutex implementation + ** is used regardless of the run-time threadsafety setting. + */ #if SQLITE_MUTEX_NOOP sqlite3_mutex_methods const sqlite3DefaultMutex(void){ return sqlite3NoopMutex(); } #endif //* SQLITE_MUTEX_NOOP */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/mutex_w32.cs b/Src/IronPython.SQLite/c#sqlite/mutex_w32.cs index 16d114d3c..96dce6757 100644 --- a/Src/IronPython.SQLite/c#sqlite/mutex_w32.cs +++ b/Src/IronPython.SQLite/c#sqlite/mutex_w32.cs @@ -1,100 +1,96 @@ +using System; using System.Diagnostics; -using DWORD = System.Int32; using System.Threading; -using System; -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 2007 August 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 file contains the C functions that implement mutexes for win32 - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-03-09 19:31:43 4ae453ea7be69018d8c16eb8dabe05617397dc4d - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +using DWORD = System.Int32; - /* - ** The code in this file is only used if we are compiling multithreaded - ** on a win32 system. - */ +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2007 August 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 file contains the C functions that implement mutexes for win32 + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-03-09 19:31:43 4ae453ea7be69018d8c16eb8dabe05617397dc4d + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + + /* + ** The code in this file is only used if we are compiling multithreaded + ** on a win32 system. + */ #if SQLITE_MUTEX_W32 - /* -** Each recursive mutex is an instance of the following structure. -*/ - public partial class sqlite3_mutex - { - public Object mutex; /* Mutex controlling the lock */ - public int id; /* Mutex type */ - public int nRef; /* Number of enterances */ - public DWORD owner; /* Thread holding this mutex */ + /* + ** Each recursive mutex is an instance of the following structure. + */ + public partial class sqlite3_mutex { + public Object mutex; /* Mutex controlling the lock */ + public int id; /* Mutex type */ + public int nRef; /* Number of enterances */ + public DWORD owner; /* Thread holding this mutex */ #if SQLITE_DEBUG - public int trace; /* True to trace changes */ + public int trace; /* True to trace changes */ #endif - public sqlite3_mutex() - { - mutex = new Object(); - } + public sqlite3_mutex() { + mutex = new Object(); + } - public sqlite3_mutex( Mutex mutex, int id, int nRef, DWORD owner + public sqlite3_mutex(Mutex mutex, int id, int nRef, DWORD owner #if SQLITE_DEBUG -, int trace + , int trace #endif - ) - { - this.mutex = mutex; - this.id = id; - this.nRef = nRef; - this.owner = owner; + ) { + this.mutex = mutex; + this.id = id; + this.nRef = nRef; + this.owner = owner; #if SQLITE_DEBUG - this.trace = 0; + this.trace = 0; #endif - } - }; + } + }; - //#define SQLITE_W32_MUTEX_INITIALIZER { 0 } - static Mutex SQLITE_W32_MUTEX_INITIALIZER = null; + //#define SQLITE_W32_MUTEX_INITIALIZER { 0 } + static Mutex SQLITE_W32_MUTEX_INITIALIZER = null; #if SQLITE_DEBUG - //#define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER, 0, 0L, (DWORD)0, 0 } + //#define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER, 0, 0L, (DWORD)0, 0 } #else //#define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER, 0, 0L, (DWORD)0 } #endif - /* -** Return true (non-zero) if we are running under WinNT, Win2K, WinXP, -** or WinCE. Return false (zero) for Win95, Win98, or WinME. -** -** Here is an interesting observation: Win95, Win98, and WinME lack -** the LockFileEx() API. But we can still statically link against that -** API as long as we don't call it win 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. -** -** mutexIsNT() is only used for the TryEnterCriticalSection() API call, -** which is only available if your application was compiled with -** _WIN32_WINNT defined to a value >= 0x0400. Currently, the only -** call to TryEnterCriticalSection() is #ifdef'ed out, so #if -** this out as well. -*/ + /* + ** Return true (non-zero) if we are running under WinNT, Win2K, WinXP, + ** or WinCE. Return false (zero) for Win95, Win98, or WinME. + ** + ** Here is an interesting observation: Win95, Win98, and WinME lack + ** the LockFileEx() API. But we can still statically link against that + ** API as long as we don't call it win 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. + ** + ** mutexIsNT() is only used for the TryEnterCriticalSection() API call, + ** which is only available if your application was compiled with + ** _WIN32_WINNT defined to a value >= 0x0400. Currently, the only + ** call to TryEnterCriticalSection() is #ifdef'ed out, so #if + ** this out as well. + */ #if FALSE #if SQLITE_OS_WINCE //# define mutexIsNT() (1) @@ -113,31 +109,28 @@ static int mutexIsNT(void){ #endif #if SQLITE_DEBUG - /* -** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are -** intended for use only inside Debug.Assert() statements. -*/ - static bool winMutexHeld( sqlite3_mutex p ) - { - return p.nRef != 0 && p.owner == GetCurrentThreadId(); - } - static bool winMutexNotheld2( sqlite3_mutex p, DWORD tid ) - { - return p.nRef == 0 || p.owner != tid; - } - static bool winMutexNotheld( sqlite3_mutex p ) - { - DWORD tid = GetCurrentThreadId(); - return winMutexNotheld2( p, tid ); - } + /* + ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are + ** intended for use only inside Debug.Assert() statements. + */ + static bool winMutexHeld(sqlite3_mutex p) { + return p.nRef != 0 && p.owner == GetCurrentThreadId(); + } + static bool winMutexNotheld2(sqlite3_mutex p, DWORD tid) { + return p.nRef == 0 || p.owner != tid; + } + static bool winMutexNotheld(sqlite3_mutex p) { + DWORD tid = GetCurrentThreadId(); + return winMutexNotheld2(p, tid); + } #endif - /* -** Initialize and deinitialize the mutex subsystem. -*/ - //No MACROS under C#; Cannot use SQLITE3_MUTEX_INITIALIZER, - static sqlite3_mutex[] winMutex_staticMutexes = new sqlite3_mutex[]{ + /* + ** Initialize and deinitialize the mutex subsystem. + */ + //No MACROS under C#; Cannot use SQLITE3_MUTEX_INITIALIZER, + static sqlite3_mutex[] winMutex_staticMutexes = new sqlite3_mutex[]{ new sqlite3_mutex( SQLITE_W32_MUTEX_INITIALIZER, 0, 0, (DWORD)0 #if SQLITE_DEBUG , 0 @@ -169,190 +162,175 @@ static bool winMutexNotheld( sqlite3_mutex p ) #endif ),// SQLITE3_MUTEX_INITIALIZER, }; - static int winMutex_isInit = 0; - /* As winMutexInit() and winMutexEnd() are called as part - ** of the sqlite3_initialize and sqlite3_shutdown() - ** processing, the "interlocked" magic is probably not - ** strictly necessary. - */ - static long winMutex_lock = 0; + static int winMutex_isInit = 0; + /* As winMutexInit() and winMutexEnd() are called as part + ** of the sqlite3_initialize and sqlite3_shutdown() + ** processing, the "interlocked" magic is probably not + ** strictly necessary. + */ + static long winMutex_lock = 0; - private static System.Object lockThis = new System.Object(); - static int winMutexInit() - { - /* The first to increment to 1 does actual initialization */ + private static System.Object lockThis = new System.Object(); + static int winMutexInit() { + /* The first to increment to 1 does actual initialization */ - lock ( lockThis ) - //if ( Interlocked.CompareExchange(ref winMutex_lock, 1, 0 ) == 0 ) - { - int i; - for ( i = 0; i < ArraySize( winMutex_staticMutexes ); i++ ) - { - if (winMutex_staticMutexes[i].mutex== null) winMutex_staticMutexes[i].mutex = new Mutex(); - //InitializeCriticalSection( winMutex_staticMutexes[i].mutex ); + lock (lockThis) + //if ( Interlocked.CompareExchange(ref winMutex_lock, 1, 0 ) == 0 ) + { + int i; + for (i = 0; i < ArraySize(winMutex_staticMutexes); i++) { + if (winMutex_staticMutexes[i].mutex == null) winMutex_staticMutexes[i].mutex = new Mutex(); + //InitializeCriticalSection( winMutex_staticMutexes[i].mutex ); + } + winMutex_isInit = 1; + } + //else + //{ + // /* Someone else is in the process of initing the static mutexes */ + // while ( 0 == winMutex_isInit ) + // { + // Thread.Sleep( 1 ); + // } + //} + return SQLITE_OK; } - winMutex_isInit = 1; - } - //else - //{ - // /* Someone else is in the process of initing the static mutexes */ - // while ( 0 == winMutex_isInit ) - // { - // Thread.Sleep( 1 ); - // } - //} - return SQLITE_OK; - } - static int winMutexEnd() - { - /* The first to decrement to 0 does actual shutdown - ** (which should be the last to shutdown.) */ - if ( Interlocked.CompareExchange( ref winMutex_lock, 0, 1 ) == 1 ) - { - if ( winMutex_isInit == 1 ) - { - int i; - for ( i = 0; i < ArraySize( winMutex_staticMutexes ); i++ ) - { - DeleteCriticalSection( winMutex_staticMutexes[i].mutex ); - } - winMutex_isInit = 0; + static int winMutexEnd() { + /* The first to decrement to 0 does actual shutdown + ** (which should be the last to shutdown.) */ + if (Interlocked.CompareExchange(ref winMutex_lock, 0, 1) == 1) { + if (winMutex_isInit == 1) { + int i; + for (i = 0; i < ArraySize(winMutex_staticMutexes); i++) { + DeleteCriticalSection(winMutex_staticMutexes[i].mutex); + } + winMutex_isInit = 0; + } + } + return SQLITE_OK; } - } - return SQLITE_OK; - } - /* - ** The sqlite3_mutex_alloc() routine allocates a new - ** mutex and returns a pointer to it. If it returns NULL - ** that means that a mutex could not be allocated. SQLite - ** will unwind its stack and return an error. The argument - ** to sqlite3_mutex_alloc() is one of these integer constants: - ** - **
    - **
  • SQLITE_MUTEX_FAST - **
  • SQLITE_MUTEX_RECURSIVE - **
  • SQLITE_MUTEX_STATIC_MASTER - **
  • SQLITE_MUTEX_STATIC_MEM - **
  • SQLITE_MUTEX_STATIC_MEM2 - **
  • SQLITE_MUTEX_STATIC_PRNG - **
  • SQLITE_MUTEX_STATIC_LRU - **
  • SQLITE_MUTEX_STATIC_LRU2 - **
- ** - ** The first two constants cause sqlite3_mutex_alloc() to create - ** a new mutex. The new mutex is recursive when SQLITE_MUTEX_RECURSIVE - ** is used but not necessarily so when SQLITE_MUTEX_FAST is used. - ** The mutex implementation does not need to make a distinction - ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does - ** not want to. But SQLite will only request a recursive mutex in - ** cases where it really needs one. If a faster non-recursive mutex - ** implementation is available on the host platform, the mutex subsystem - ** might return such a mutex in response to SQLITE_MUTEX_FAST. - ** - ** The other allowed parameters to sqlite3_mutex_alloc() each return - ** a pointer to a static preexisting mutex. Six static mutexes are - ** used by the current version of SQLite. Future versions of SQLite - ** may add additional static mutexes. Static mutexes are for internal - ** use by SQLite only. Applications that use SQLite mutexes should - ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or - ** SQLITE_MUTEX_RECURSIVE. - ** - ** Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST - ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() - ** returns a different mutex on every call. But for the static - ** mutex types, the same mutex is returned on every call that has - ** the same type number. - */ - static sqlite3_mutex winMutexAlloc( int iType ) - { - sqlite3_mutex p; + /* + ** The sqlite3_mutex_alloc() routine allocates a new + ** mutex and returns a pointer to it. If it returns NULL + ** that means that a mutex could not be allocated. SQLite + ** will unwind its stack and return an error. The argument + ** to sqlite3_mutex_alloc() is one of these integer constants: + ** + **
    + **
  • SQLITE_MUTEX_FAST + **
  • SQLITE_MUTEX_RECURSIVE + **
  • SQLITE_MUTEX_STATIC_MASTER + **
  • SQLITE_MUTEX_STATIC_MEM + **
  • SQLITE_MUTEX_STATIC_MEM2 + **
  • SQLITE_MUTEX_STATIC_PRNG + **
  • SQLITE_MUTEX_STATIC_LRU + **
  • SQLITE_MUTEX_STATIC_LRU2 + **
+ ** + ** The first two constants cause sqlite3_mutex_alloc() to create + ** a new mutex. The new mutex is recursive when SQLITE_MUTEX_RECURSIVE + ** is used but not necessarily so when SQLITE_MUTEX_FAST is used. + ** The mutex implementation does not need to make a distinction + ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does + ** not want to. But SQLite will only request a recursive mutex in + ** cases where it really needs one. If a faster non-recursive mutex + ** implementation is available on the host platform, the mutex subsystem + ** might return such a mutex in response to SQLITE_MUTEX_FAST. + ** + ** The other allowed parameters to sqlite3_mutex_alloc() each return + ** a pointer to a static preexisting mutex. Six static mutexes are + ** used by the current version of SQLite. Future versions of SQLite + ** may add additional static mutexes. Static mutexes are for internal + ** use by SQLite only. Applications that use SQLite mutexes should + ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or + ** SQLITE_MUTEX_RECURSIVE. + ** + ** Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST + ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() + ** returns a different mutex on every call. But for the static + ** mutex types, the same mutex is returned on every call that has + ** the same type number. + */ + static sqlite3_mutex winMutexAlloc(int iType) { + sqlite3_mutex p; - switch ( iType ) - { - case SQLITE_MUTEX_FAST: - case SQLITE_MUTEX_RECURSIVE: - { - p = new sqlite3_mutex();//sqlite3MallocZero( sizeof(*p) ); - if ( p != null ) - { - p.id = iType; - InitializeCriticalSection( p.mutex ); + switch (iType) { + case SQLITE_MUTEX_FAST: + case SQLITE_MUTEX_RECURSIVE: { + p = new sqlite3_mutex();//sqlite3MallocZero( sizeof(*p) ); + if (p != null) { + p.id = iType; + InitializeCriticalSection(p.mutex); + } + break; + } + default: { + Debug.Assert(winMutex_isInit == 1); + Debug.Assert(iType - 2 >= 0); + Debug.Assert(iType - 2 < ArraySize(winMutex_staticMutexes)); + p = winMutex_staticMutexes[iType - 2]; + p.id = iType; + break; + } } - break; - } - default: - { - Debug.Assert( winMutex_isInit == 1 ); - Debug.Assert( iType - 2 >= 0 ); - Debug.Assert( iType - 2 < ArraySize( winMutex_staticMutexes ) ); - p = winMutex_staticMutexes[iType - 2]; - p.id = iType; - break; - } - } - return p; - } + return p; + } - /* - ** This routine deallocates a previously - ** allocated mutex. SQLite is careful to deallocate every - ** mutex that it allocates. - */ - static void winMutexFree( sqlite3_mutex p ) - { - Debug.Assert( p != null ); - Debug.Assert( p.nRef == 0 ); - Debug.Assert( p.id == SQLITE_MUTEX_FAST || p.id == SQLITE_MUTEX_RECURSIVE ); - DeleteCriticalSection( p.mutex ); - p.owner = 0; - //sqlite3_free( p ); - } + /* + ** This routine deallocates a previously + ** allocated mutex. SQLite is careful to deallocate every + ** mutex that it allocates. + */ + static void winMutexFree(sqlite3_mutex p) { + Debug.Assert(p != null); + Debug.Assert(p.nRef == 0); + Debug.Assert(p.id == SQLITE_MUTEX_FAST || p.id == SQLITE_MUTEX_RECURSIVE); + DeleteCriticalSection(p.mutex); + p.owner = 0; + //sqlite3_free( p ); + } - /* - ** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt - ** to enter a mutex. If another thread is already within the mutex, - ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return - ** SQLITE_BUSY. The sqlite3_mutex_try() interface returns SQLITE_OK - ** upon successful entry. Mutexes created using SQLITE_MUTEX_RECURSIVE can - ** be entered multiple times by the same thread. In such cases the, - ** mutex must be exited an equal number of times before another thread - ** can enter. If the same thread tries to enter any other kind of mutex - ** more than once, the behavior is undefined. - */ - static void winMutexEnter( sqlite3_mutex p ) - { - DWORD tid = GetCurrentThreadId(); - Debug.Assert( p.id == SQLITE_MUTEX_RECURSIVE || winMutexNotheld2( p, tid ) ); - EnterCriticalSection( p.mutex ); - p.owner = tid; - p.nRef++; + /* + ** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt + ** to enter a mutex. If another thread is already within the mutex, + ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return + ** SQLITE_BUSY. The sqlite3_mutex_try() interface returns SQLITE_OK + ** upon successful entry. Mutexes created using SQLITE_MUTEX_RECURSIVE can + ** be entered multiple times by the same thread. In such cases the, + ** mutex must be exited an equal number of times before another thread + ** can enter. If the same thread tries to enter any other kind of mutex + ** more than once, the behavior is undefined. + */ + static void winMutexEnter(sqlite3_mutex p) { + DWORD tid = GetCurrentThreadId(); + Debug.Assert(p.id == SQLITE_MUTEX_RECURSIVE || winMutexNotheld2(p, tid)); + EnterCriticalSection(p.mutex); + p.owner = tid; + p.nRef++; #if SQLITE_DEBUG - if ( p.trace != 0 ) - { - printf( "enter mutex {0} ({1}) with nRef={2}\n", p.GetHashCode(), p.owner, p.nRef ); - } + if (p.trace != 0) { + printf("enter mutex {0} ({1}) with nRef={2}\n", p.GetHashCode(), p.owner, p.nRef); + } #endif - } + } - static int winMutexTry( sqlite3_mutex p ) - { - DWORD tid = GetCurrentThreadId(); - int rc = SQLITE_BUSY; - Debug.Assert( p.id == SQLITE_MUTEX_RECURSIVE || winMutexNotheld2( p, tid ) ); - /* - ** The sqlite3_mutex_try() routine is very rarely used, and when it - ** is used it is merely an optimization. So it is OK for it to always - ** fail. - ** - ** The TryEnterCriticalSection() interface is only available on WinNT. - ** And some windows compilers complain if you try to use it without - ** first doing some #defines that prevent SQLite from building on Win98. - ** For that reason, we will omit this optimization for now. See - ** ticket #2685. - */ + static int winMutexTry(sqlite3_mutex p) { + DWORD tid = GetCurrentThreadId(); + int rc = SQLITE_BUSY; + Debug.Assert(p.id == SQLITE_MUTEX_RECURSIVE || winMutexNotheld2(p, tid)); + /* + ** The sqlite3_mutex_try() routine is very rarely used, and when it + ** is used it is merely an optimization. So it is OK for it to always + ** fail. + ** + ** The TryEnterCriticalSection() interface is only available on WinNT. + ** And some windows compilers complain if you try to use it without + ** first doing some #defines that prevent SQLite from building on Win98. + ** For that reason, we will omit this optimization for now. See + ** ticket #2685. + */ #if FALSE if( mutexIsNT() && TryEnterCriticalSection(p.mutex) ){ p.owner = tid; @@ -360,62 +338,58 @@ static int winMutexTry( sqlite3_mutex p ) rc = SQLITE_OK; } #else - UNUSED_PARAMETER( p ); + UNUSED_PARAMETER(p); #endif #if SQLITE_DEBUG - if ( rc == SQLITE_OK && p.trace != 0 ) - { - printf( "try mutex {0} ({1}) with nRef={2}\n", p.GetHashCode(), p.owner, p.nRef ); - } + if (rc == SQLITE_OK && p.trace != 0) { + printf("try mutex {0} ({1}) with nRef={2}\n", p.GetHashCode(), p.owner, p.nRef); + } #endif - return rc; - } + return rc; + } - /* - ** The sqlite3_mutex_leave() routine exits a mutex that was - ** previously entered by the same thread. The behavior - ** is undefined if the mutex is not currently entered or - ** is not currently allocated. SQLite will never do either. - */ - static void winMutexLeave( sqlite3_mutex p ) - { - DWORD tid = GetCurrentThreadId(); - Debug.Assert( p.nRef > 0 ); - Debug.Assert( p.owner == tid ); - p.nRef--; - Debug.Assert( p.nRef == 0 || p.id == SQLITE_MUTEX_RECURSIVE ); - if ( p.nRef == 0 ) p.owner = 0; - LeaveCriticalSection( p.mutex ); + /* + ** The sqlite3_mutex_leave() routine exits a mutex that was + ** previously entered by the same thread. The behavior + ** is undefined if the mutex is not currently entered or + ** is not currently allocated. SQLite will never do either. + */ + static void winMutexLeave(sqlite3_mutex p) { + DWORD tid = GetCurrentThreadId(); + Debug.Assert(p.nRef > 0); + Debug.Assert(p.owner == tid); + p.nRef--; + Debug.Assert(p.nRef == 0 || p.id == SQLITE_MUTEX_RECURSIVE); + if (p.nRef == 0) p.owner = 0; + LeaveCriticalSection(p.mutex); #if SQLITE_DEBUG - if ( p.trace != 0 ) - { - printf( "leave mutex {0} ({1}) with nRef={2}\n", p.GetHashCode(), p.owner, p.nRef ); - } + if (p.trace != 0) { + printf("leave mutex {0} ({1}) with nRef={2}\n", p.GetHashCode(), p.owner, p.nRef); + } #endif - } + } - static sqlite3_mutex_methods sqlite3DefaultMutex() - { - sqlite3_mutex_methods sMutex = new sqlite3_mutex_methods ( -(dxMutexInit)winMutexInit, -(dxMutexEnd)winMutexEnd, -(dxMutexAlloc)winMutexAlloc, -(dxMutexFree)winMutexFree, -(dxMutexEnter)winMutexEnter, -(dxMutexTry)winMutexTry, -(dxMutexLeave)winMutexLeave, + static sqlite3_mutex_methods sqlite3DefaultMutex() { + sqlite3_mutex_methods sMutex = new sqlite3_mutex_methods( + (dxMutexInit)winMutexInit, + (dxMutexEnd)winMutexEnd, + (dxMutexAlloc)winMutexAlloc, + (dxMutexFree)winMutexFree, + (dxMutexEnter)winMutexEnter, + (dxMutexTry)winMutexTry, + (dxMutexLeave)winMutexLeave, #if SQLITE_DEBUG -(dxMutexHeld)winMutexHeld, -(dxMutexNotheld)winMutexNotheld + (dxMutexHeld)winMutexHeld, + (dxMutexNotheld)winMutexNotheld #else null, null #endif -); + ); - return sMutex; - } + return sMutex; + } #endif // * SQLITE_MUTEX_W32 */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/notify_c.cs b/Src/IronPython.SQLite/c#sqlite/notify_c.cs index 983341169..6eabfc6d4 100644 --- a/Src/IronPython.SQLite/c#sqlite/notify_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/notify_c.cs @@ -1,35 +1,31 @@ -using System.Diagnostics; +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2009 March 3 + ** + ** 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 contains the implementation of the sqlite3_unlock_notify() + ** API method and its associated functionality. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2009-12-07 16:39:13 1ed88e9d01e9eda5cbc622e7614277f29bcc551c + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include "btreeInt.h" -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 2009 March 3 - ** - ** 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 contains the implementation of the sqlite3_unlock_notify() - ** API method and its associated functionality. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2009-12-07 16:39:13 1ed88e9d01e9eda5cbc622e7614277f29bcc551c - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include "btreeInt.h" - - /* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */ + /* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */ #if SQLITE_ENABLE_UNLOCK_NOTIFY /* @@ -342,5 +338,5 @@ void sqlite3ConnectionClosed(sqlite3 *db){ leaveMutex(); } #endif - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/opcodes_c.cs b/Src/IronPython.SQLite/c#sqlite/opcodes_c.cs index 593f10853..73484e952 100644 --- a/Src/IronPython.SQLite/c#sqlite/opcodes_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/opcodes_c.cs @@ -7,16 +7,13 @@ ** ************************************************************************* */ -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* Automatically generated. Do not edit */ - /* See the mkopcodec.awk script for details. */ +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* Automatically generated. Do not edit */ + /* See the mkopcodec.awk script for details. */ #if !SQLITE_OMIT_EXPLAIN || !NDEBUG || VDBE_PROFILE || SQLITE_DEBUG - static string sqlite3OpcodeName( int i ) - { - string[] azName = { "?", + static string sqlite3OpcodeName(int i) { + string[] azName = { "?", /* 1 */ "Goto", /* 2 */ "Gosub", /* 3 */ "Return", @@ -163,8 +160,8 @@ static string sqlite3OpcodeName( int i ) /* 144 */ "ToInt", /* 145 */ "ToReal", }; - return azName[i]; - } + return azName[i]; + } #endif - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/opcodes_h.cs b/Src/IronPython.SQLite/c#sqlite/opcodes_h.cs index a723c6124..aeb7c4a24 100644 --- a/Src/IronPython.SQLite/c#sqlite/opcodes_h.cs +++ b/Src/IronPython.SQLite/c#sqlite/opcodes_h.cs @@ -1,329 +1,327 @@ -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* Automatically generated. Do not edit */ - /* See the mkopcodeh.awk script for details */ - /* Automatically generated. Do not edit */ - /* See the mkopcodeh.awk script for details */ - //#define OP_Goto 1 - //#define OP_Gosub 2 - //#define OP_Return 3 - //#define OP_Yield 4 - //#define OP_HaltIfNull 5 - //#define OP_Halt 6 - //#define OP_Integer 7 - //#define OP_Int64 8 - //#define OP_Real 130 /* same as TK_FLOAT */ - //#define OP_String8 94 /* same as TK_STRING */ - //#define OP_String 9 - //#define OP_Null 10 - //#define OP_Blob 11 - //#define OP_Variable 12 - //#define OP_Move 13 - //#define OP_Copy 14 - //#define OP_SCopy 15 - //#define OP_ResultRow 16 - //#define OP_Concat 91 /* same as TK_CONCAT */ - //#define OP_Add 86 /* same as TK_PLUS */ - //#define OP_Subtract 87 /* same as TK_MINUS */ - //#define OP_Multiply 88 /* same as TK_STAR */ - //#define OP_Divide 89 /* same as TK_SLASH */ - //#define OP_Remainder 90 /* same as TK_REM */ - //#define OP_CollSeq 17 - //#define OP_Function 18 - //#define OP_BitAnd 82 /* same as TK_BITAND */ - //#define OP_BitOr 83 /* same as TK_BITOR */ - //#define OP_ShiftLeft 84 /* same as TK_LSHIFT */ - //#define OP_ShiftRight 85 /* same as TK_RSHIFT */ - //#define OP_AddImm 20 - //#define OP_MustBeInt 21 - //#define OP_RealAffinity 22 - //#define OP_ToText 141 /* same as TK_TO_TEXT */ - //#define OP_ToBlob 142 /* same as TK_TO_BLOB */ - //#define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/ - //#define OP_ToInt 144 /* same as TK_TO_INT */ - //#define OP_ToReal 145 /* same as TK_TO_REAL */ - //#define OP_Eq 76 /* same as TK_EQ */ - //#define OP_Ne 75 /* same as TK_NE */ - //#define OP_Lt 79 /* same as TK_LT */ - //#define OP_Le 78 /* same as TK_LE */ - //#define OP_Gt 77 /* same as TK_GT */ - //#define OP_Ge 80 /* same as TK_GE */ - //#define OP_Permutation 23 - //#define OP_Compare 24 - //#define OP_Jump 25 - //#define OP_And 69 /* same as TK_AND */ - //#define OP_Or 68 /* same as TK_OR */ - //#define OP_Not 19 /* same as TK_NOT */ - //#define OP_BitNot 93 /* same as TK_BITNOT */ - //#define OP_If 26 - //#define OP_IfNot 27 - //#define OP_IsNull 73 /* same as TK_ISNULL */ - //#define OP_NotNull 74 /* same as TK_NOTNULL */ - //#define OP_Column 28 - //#define OP_Affinity 29 - //#define OP_MakeRecord 30 - //#define OP_Count 31 - //#define OP_Savepoint 32 - //#define OP_AutoCommit 33 - //#define OP_Transaction 34 - //#define OP_ReadCookie 35 - //#define OP_SetCookie 36 - //#define OP_VerifyCookie 37 - //#define OP_OpenRead 38 - //#define OP_OpenWrite 39 - //#define OP_OpenAutoindex 40 - //#define OP_OpenEphemeral 41 - //#define OP_OpenPseudo 42 - //#define OP_Close 43 - //#define OP_SeekLt 44 - //#define OP_SeekLe 45 - //#define OP_SeekGe 46 - //#define OP_SeekGt 47 - //#define OP_Seek 48 - //#define OP_NotFound 49 - //#define OP_Found 50 - //#define OP_IsUnique 51 - //#define OP_NotExists 52 - //#define OP_Sequence 53 - //#define OP_NewRowid 54 - //#define OP_Insert 55 - //#define OP_InsertInt 56 - //#define OP_Delete 57 - //#define OP_ResetCount 58 - //#define OP_RowKey 59 - //#define OP_RowData 60 - //#define OP_Rowid 61 - //#define OP_NullRow 62 - //#define OP_Last 63 - //#define OP_Sort 64 - //#define OP_Rewind 65 - //#define OP_Prev 66 - //#define OP_Next 67 - //#define OP_IdxInsert 70 - //#define OP_IdxDelete 71 - //#define OP_IdxRowid 72 - //#define OP_IdxLT 81 - //#define OP_IdxGE 92 - //#define OP_Destroy 95 - //#define OP_Clear 96 - //#define OP_CreateIndex 97 - //#define OP_CreateTable 98 - //#define OP_ParseSchema 99 - //#define OP_LoadAnalysis 100 - //#define OP_DropTable 101 - //#define OP_DropIndex 102 - //#define OP_DropTrigger 103 - //#define OP_IntegrityCk 104 - //#define OP_RowSetAdd 105 - //#define OP_RowSetRead 106 - //#define OP_RowSetTest 107 - //#define OP_Program 108 - //#define OP_Param 109 - //#define OP_FkCounter 110 - //#define OP_FkIfZero 111 - //#define OP_MemMax 112 - //#define OP_IfPos 113 - //#define OP_IfNeg 114 - //#define OP_IfZero 115 - //#define OP_AggStep 116 - //#define OP_AggFinal 117 - //#define OP_Checkpoint 118 - //#define OP_JournalMode 119 - //#define OP_Vacuum 120 - //#define OP_IncrVacuum 121 - //#define OP_Expire 122 - //#define OP_TableLock 123 - //#define OP_VBegin 124 - //#define OP_VCreate 125 - //#define OP_VDestroy 126 - //#define OP_VOpen 127 - //#define OP_VFilter 128 - //#define OP_VColumn 129 - //#define OP_VNext 131 - //#define OP_VRename 132 - //#define OP_VUpdate 133 - //#define OP_Pagecount 134 - //#define OP_MaxPgcnt 135 - //#define OP_Trace 136 - //#define OP_Noop 137 - //#define OP_Explain 138 +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* Automatically generated. Do not edit */ + /* See the mkopcodeh.awk script for details */ + /* Automatically generated. Do not edit */ + /* See the mkopcodeh.awk script for details */ + //#define OP_Goto 1 + //#define OP_Gosub 2 + //#define OP_Return 3 + //#define OP_Yield 4 + //#define OP_HaltIfNull 5 + //#define OP_Halt 6 + //#define OP_Integer 7 + //#define OP_Int64 8 + //#define OP_Real 130 /* same as TK_FLOAT */ + //#define OP_String8 94 /* same as TK_STRING */ + //#define OP_String 9 + //#define OP_Null 10 + //#define OP_Blob 11 + //#define OP_Variable 12 + //#define OP_Move 13 + //#define OP_Copy 14 + //#define OP_SCopy 15 + //#define OP_ResultRow 16 + //#define OP_Concat 91 /* same as TK_CONCAT */ + //#define OP_Add 86 /* same as TK_PLUS */ + //#define OP_Subtract 87 /* same as TK_MINUS */ + //#define OP_Multiply 88 /* same as TK_STAR */ + //#define OP_Divide 89 /* same as TK_SLASH */ + //#define OP_Remainder 90 /* same as TK_REM */ + //#define OP_CollSeq 17 + //#define OP_Function 18 + //#define OP_BitAnd 82 /* same as TK_BITAND */ + //#define OP_BitOr 83 /* same as TK_BITOR */ + //#define OP_ShiftLeft 84 /* same as TK_LSHIFT */ + //#define OP_ShiftRight 85 /* same as TK_RSHIFT */ + //#define OP_AddImm 20 + //#define OP_MustBeInt 21 + //#define OP_RealAffinity 22 + //#define OP_ToText 141 /* same as TK_TO_TEXT */ + //#define OP_ToBlob 142 /* same as TK_TO_BLOB */ + //#define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/ + //#define OP_ToInt 144 /* same as TK_TO_INT */ + //#define OP_ToReal 145 /* same as TK_TO_REAL */ + //#define OP_Eq 76 /* same as TK_EQ */ + //#define OP_Ne 75 /* same as TK_NE */ + //#define OP_Lt 79 /* same as TK_LT */ + //#define OP_Le 78 /* same as TK_LE */ + //#define OP_Gt 77 /* same as TK_GT */ + //#define OP_Ge 80 /* same as TK_GE */ + //#define OP_Permutation 23 + //#define OP_Compare 24 + //#define OP_Jump 25 + //#define OP_And 69 /* same as TK_AND */ + //#define OP_Or 68 /* same as TK_OR */ + //#define OP_Not 19 /* same as TK_NOT */ + //#define OP_BitNot 93 /* same as TK_BITNOT */ + //#define OP_If 26 + //#define OP_IfNot 27 + //#define OP_IsNull 73 /* same as TK_ISNULL */ + //#define OP_NotNull 74 /* same as TK_NOTNULL */ + //#define OP_Column 28 + //#define OP_Affinity 29 + //#define OP_MakeRecord 30 + //#define OP_Count 31 + //#define OP_Savepoint 32 + //#define OP_AutoCommit 33 + //#define OP_Transaction 34 + //#define OP_ReadCookie 35 + //#define OP_SetCookie 36 + //#define OP_VerifyCookie 37 + //#define OP_OpenRead 38 + //#define OP_OpenWrite 39 + //#define OP_OpenAutoindex 40 + //#define OP_OpenEphemeral 41 + //#define OP_OpenPseudo 42 + //#define OP_Close 43 + //#define OP_SeekLt 44 + //#define OP_SeekLe 45 + //#define OP_SeekGe 46 + //#define OP_SeekGt 47 + //#define OP_Seek 48 + //#define OP_NotFound 49 + //#define OP_Found 50 + //#define OP_IsUnique 51 + //#define OP_NotExists 52 + //#define OP_Sequence 53 + //#define OP_NewRowid 54 + //#define OP_Insert 55 + //#define OP_InsertInt 56 + //#define OP_Delete 57 + //#define OP_ResetCount 58 + //#define OP_RowKey 59 + //#define OP_RowData 60 + //#define OP_Rowid 61 + //#define OP_NullRow 62 + //#define OP_Last 63 + //#define OP_Sort 64 + //#define OP_Rewind 65 + //#define OP_Prev 66 + //#define OP_Next 67 + //#define OP_IdxInsert 70 + //#define OP_IdxDelete 71 + //#define OP_IdxRowid 72 + //#define OP_IdxLT 81 + //#define OP_IdxGE 92 + //#define OP_Destroy 95 + //#define OP_Clear 96 + //#define OP_CreateIndex 97 + //#define OP_CreateTable 98 + //#define OP_ParseSchema 99 + //#define OP_LoadAnalysis 100 + //#define OP_DropTable 101 + //#define OP_DropIndex 102 + //#define OP_DropTrigger 103 + //#define OP_IntegrityCk 104 + //#define OP_RowSetAdd 105 + //#define OP_RowSetRead 106 + //#define OP_RowSetTest 107 + //#define OP_Program 108 + //#define OP_Param 109 + //#define OP_FkCounter 110 + //#define OP_FkIfZero 111 + //#define OP_MemMax 112 + //#define OP_IfPos 113 + //#define OP_IfNeg 114 + //#define OP_IfZero 115 + //#define OP_AggStep 116 + //#define OP_AggFinal 117 + //#define OP_Checkpoint 118 + //#define OP_JournalMode 119 + //#define OP_Vacuum 120 + //#define OP_IncrVacuum 121 + //#define OP_Expire 122 + //#define OP_TableLock 123 + //#define OP_VBegin 124 + //#define OP_VCreate 125 + //#define OP_VDestroy 126 + //#define OP_VOpen 127 + //#define OP_VFilter 128 + //#define OP_VColumn 129 + //#define OP_VNext 131 + //#define OP_VRename 132 + //#define OP_VUpdate 133 + //#define OP_Pagecount 134 + //#define OP_MaxPgcnt 135 + //#define OP_Trace 136 + //#define OP_Noop 137 + //#define OP_Explain 138 - public const int OP_Goto = 1; - public const int OP_Gosub = 2; - public const int OP_Return = 3; - public const int OP_Yield = 4; - public const int OP_HaltIfNull = 5; - public const int OP_Halt = 6; - public const int OP_Integer = 7; - public const int OP_Int64 = 8; - public const int OP_Real = 130 /* same as TK_FLOAT */; - public const int OP_String8 = 94 /* same as TK_STRING */; - public const int OP_String = 9; - public const int OP_Null = 10; - public const int OP_Blob = 11; - public const int OP_Variable = 12; - public const int OP_Move = 13; - public const int OP_Copy = 14; - public const int OP_SCopy = 15; - public const int OP_ResultRow = 16; - public const int OP_Concat = 91 /* same as TK_CONCAT */; - public const int OP_Add = 86 /* same as TK_PLUS */; - public const int OP_Subtract = 87 /* same as TK_MINUS */; - public const int OP_Multiply = 88 /* same as TK_STAR */; - public const int OP_Divide = 89 /* same as TK_SLASH */; - public const int OP_Remainder = 90 /* same as TK_REM */; - public const int OP_CollSeq = 17; - public const int OP_Function = 18; - public const int OP_BitAnd = 82 /* same as TK_BITAND */; - public const int OP_BitOr = 83 /* same as TK_BITOR */; - public const int OP_ShiftLeft = 84 /* same as TK_LSHIFT */; - public const int OP_ShiftRight = 85 /* same as TK_RSHIFT */; - public const int OP_AddImm = 20; - public const int OP_MustBeInt = 21; - public const int OP_RealAffinity = 22; - public const int OP_ToText = 141 /* same as TK_TO_TEXT */; - public const int OP_ToBlob = 142 /* same as TK_TO_BLOB */; - public const int OP_ToNumeric = 143 /* same as TK_TO_NUMERIC*/; - public const int OP_ToInt = 144 /* same as TK_TO_INT */; - public const int OP_ToReal = 145 /* same as TK_TO_REAL */; - public const int OP_Eq = 76 /* same as TK_EQ */; - public const int OP_Ne = 75 /* same as TK_NE */; - public const int OP_Lt = 79 /* same as TK_LT */; - public const int OP_Le = 78 /* same as TK_LE */; - public const int OP_Gt = 77 /* same as TK_GT */; - public const int OP_Ge = 80 /* same as TK_GE */; - public const int OP_Permutation = 23; - public const int OP_Compare = 24; - public const int OP_Jump = 25; - public const int OP_And = 69 /* same as TK_AND */; - public const int OP_Or = 68 /* same as TK_OR */; - public const int OP_Not = 19 /* same as TK_NOT */; - public const int OP_BitNot = 93 /* same as TK_BITNOT */; - public const int OP_If = 26; - public const int OP_IfNot = 27; - public const int OP_IsNull = 73 /* same as TK_ISNULL */; - public const int OP_NotNull = 74 /* same as TK_NOTNULL */; - public const int OP_Column = 28; - public const int OP_Affinity = 29; - public const int OP_MakeRecord = 30; - public const int OP_Count = 31; - public const int OP_Savepoint = 32; - public const int OP_AutoCommit = 33; - public const int OP_Transaction = 34; - public const int OP_ReadCookie = 35; - public const int OP_SetCookie = 36; - public const int OP_VerifyCookie = 37; - public const int OP_OpenRead = 38; - public const int OP_OpenWrite = 39; - public const int OP_OpenAutoindex = 40; - public const int OP_OpenEphemeral = 41; - public const int OP_OpenPseudo = 42; - public const int OP_Close = 43; - public const int OP_SeekLt = 44; - public const int OP_SeekLe = 45; - public const int OP_SeekGe = 46; - public const int OP_SeekGt = 47; - public const int OP_Seek = 48; - public const int OP_NotFound = 49; - public const int OP_Found = 50; - public const int OP_IsUnique = 51; - public const int OP_NotExists = 52; - public const int OP_Sequence = 53; - public const int OP_NewRowid = 54; - public const int OP_Insert = 55; - public const int OP_InsertInt = 56; - public const int OP_Delete = 57; - public const int OP_ResetCount = 58; - public const int OP_RowKey = 59; - public const int OP_RowData = 60; - public const int OP_Rowid = 61; - public const int OP_NullRow = 62; - public const int OP_Last = 63; - public const int OP_Sort = 64; - public const int OP_Rewind = 65; - public const int OP_Prev = 66; - public const int OP_Next = 67; - public const int OP_IdxInsert = 70; - public const int OP_IdxDelete = 71; - public const int OP_IdxRowid = 72; - public const int OP_IdxLT = 81; - public const int OP_IdxGE = 92; - public const int OP_Destroy = 95; - public const int OP_Clear = 96; - public const int OP_CreateIndex = 97; - public const int OP_CreateTable = 98; - public const int OP_ParseSchema = 99; - public const int OP_LoadAnalysis = 100; - public const int OP_DropTable = 101; - public const int OP_DropIndex = 102; - public const int OP_DropTrigger = 103; - public const int OP_IntegrityCk = 104; - public const int OP_RowSetAdd = 105; - public const int OP_RowSetRead = 106; - public const int OP_RowSetTest = 107; - public const int OP_Program = 108; - public const int OP_Param = 109; - public const int OP_FkCounter = 110; - public const int OP_FkIfZero = 111; - public const int OP_MemMax = 112; - public const int OP_IfPos = 113; - public const int OP_IfNeg = 114; - public const int OP_IfZero = 115; - public const int OP_AggStep = 116; - public const int OP_AggFinal = 117; - public const int OP_Checkpoint = 118; - public const int OP_JournalMode = 119; - public const int OP_Vacuum = 120; - public const int OP_IncrVacuum = 121; - public const int OP_Expire = 122; - public const int OP_TableLock = 123; - public const int OP_VBegin = 124; - public const int OP_VCreate = 125; - public const int OP_VDestroy = 126; - public const int OP_VOpen = 127; - public const int OP_VFilter = 128; - public const int OP_VColumn = 129; - public const int OP_VNext = 131; - public const int OP_VRename = 132; - public const int OP_VUpdate = 133; - public const int OP_Pagecount = 134; - public const int OP_MaxPgcnt = 135; - public const int OP_Trace = 136; - public const int OP_Noop = 137; - public const int OP_Explain = 138; + public const int OP_Goto = 1; + public const int OP_Gosub = 2; + public const int OP_Return = 3; + public const int OP_Yield = 4; + public const int OP_HaltIfNull = 5; + public const int OP_Halt = 6; + public const int OP_Integer = 7; + public const int OP_Int64 = 8; + public const int OP_Real = 130 /* same as TK_FLOAT */; + public const int OP_String8 = 94 /* same as TK_STRING */; + public const int OP_String = 9; + public const int OP_Null = 10; + public const int OP_Blob = 11; + public const int OP_Variable = 12; + public const int OP_Move = 13; + public const int OP_Copy = 14; + public const int OP_SCopy = 15; + public const int OP_ResultRow = 16; + public const int OP_Concat = 91 /* same as TK_CONCAT */; + public const int OP_Add = 86 /* same as TK_PLUS */; + public const int OP_Subtract = 87 /* same as TK_MINUS */; + public const int OP_Multiply = 88 /* same as TK_STAR */; + public const int OP_Divide = 89 /* same as TK_SLASH */; + public const int OP_Remainder = 90 /* same as TK_REM */; + public const int OP_CollSeq = 17; + public const int OP_Function = 18; + public const int OP_BitAnd = 82 /* same as TK_BITAND */; + public const int OP_BitOr = 83 /* same as TK_BITOR */; + public const int OP_ShiftLeft = 84 /* same as TK_LSHIFT */; + public const int OP_ShiftRight = 85 /* same as TK_RSHIFT */; + public const int OP_AddImm = 20; + public const int OP_MustBeInt = 21; + public const int OP_RealAffinity = 22; + public const int OP_ToText = 141 /* same as TK_TO_TEXT */; + public const int OP_ToBlob = 142 /* same as TK_TO_BLOB */; + public const int OP_ToNumeric = 143 /* same as TK_TO_NUMERIC*/; + public const int OP_ToInt = 144 /* same as TK_TO_INT */; + public const int OP_ToReal = 145 /* same as TK_TO_REAL */; + public const int OP_Eq = 76 /* same as TK_EQ */; + public const int OP_Ne = 75 /* same as TK_NE */; + public const int OP_Lt = 79 /* same as TK_LT */; + public const int OP_Le = 78 /* same as TK_LE */; + public const int OP_Gt = 77 /* same as TK_GT */; + public const int OP_Ge = 80 /* same as TK_GE */; + public const int OP_Permutation = 23; + public const int OP_Compare = 24; + public const int OP_Jump = 25; + public const int OP_And = 69 /* same as TK_AND */; + public const int OP_Or = 68 /* same as TK_OR */; + public const int OP_Not = 19 /* same as TK_NOT */; + public const int OP_BitNot = 93 /* same as TK_BITNOT */; + public const int OP_If = 26; + public const int OP_IfNot = 27; + public const int OP_IsNull = 73 /* same as TK_ISNULL */; + public const int OP_NotNull = 74 /* same as TK_NOTNULL */; + public const int OP_Column = 28; + public const int OP_Affinity = 29; + public const int OP_MakeRecord = 30; + public const int OP_Count = 31; + public const int OP_Savepoint = 32; + public const int OP_AutoCommit = 33; + public const int OP_Transaction = 34; + public const int OP_ReadCookie = 35; + public const int OP_SetCookie = 36; + public const int OP_VerifyCookie = 37; + public const int OP_OpenRead = 38; + public const int OP_OpenWrite = 39; + public const int OP_OpenAutoindex = 40; + public const int OP_OpenEphemeral = 41; + public const int OP_OpenPseudo = 42; + public const int OP_Close = 43; + public const int OP_SeekLt = 44; + public const int OP_SeekLe = 45; + public const int OP_SeekGe = 46; + public const int OP_SeekGt = 47; + public const int OP_Seek = 48; + public const int OP_NotFound = 49; + public const int OP_Found = 50; + public const int OP_IsUnique = 51; + public const int OP_NotExists = 52; + public const int OP_Sequence = 53; + public const int OP_NewRowid = 54; + public const int OP_Insert = 55; + public const int OP_InsertInt = 56; + public const int OP_Delete = 57; + public const int OP_ResetCount = 58; + public const int OP_RowKey = 59; + public const int OP_RowData = 60; + public const int OP_Rowid = 61; + public const int OP_NullRow = 62; + public const int OP_Last = 63; + public const int OP_Sort = 64; + public const int OP_Rewind = 65; + public const int OP_Prev = 66; + public const int OP_Next = 67; + public const int OP_IdxInsert = 70; + public const int OP_IdxDelete = 71; + public const int OP_IdxRowid = 72; + public const int OP_IdxLT = 81; + public const int OP_IdxGE = 92; + public const int OP_Destroy = 95; + public const int OP_Clear = 96; + public const int OP_CreateIndex = 97; + public const int OP_CreateTable = 98; + public const int OP_ParseSchema = 99; + public const int OP_LoadAnalysis = 100; + public const int OP_DropTable = 101; + public const int OP_DropIndex = 102; + public const int OP_DropTrigger = 103; + public const int OP_IntegrityCk = 104; + public const int OP_RowSetAdd = 105; + public const int OP_RowSetRead = 106; + public const int OP_RowSetTest = 107; + public const int OP_Program = 108; + public const int OP_Param = 109; + public const int OP_FkCounter = 110; + public const int OP_FkIfZero = 111; + public const int OP_MemMax = 112; + public const int OP_IfPos = 113; + public const int OP_IfNeg = 114; + public const int OP_IfZero = 115; + public const int OP_AggStep = 116; + public const int OP_AggFinal = 117; + public const int OP_Checkpoint = 118; + public const int OP_JournalMode = 119; + public const int OP_Vacuum = 120; + public const int OP_IncrVacuum = 121; + public const int OP_Expire = 122; + public const int OP_TableLock = 123; + public const int OP_VBegin = 124; + public const int OP_VCreate = 125; + public const int OP_VDestroy = 126; + public const int OP_VOpen = 127; + public const int OP_VFilter = 128; + public const int OP_VColumn = 129; + public const int OP_VNext = 131; + public const int OP_VRename = 132; + public const int OP_VUpdate = 133; + public const int OP_Pagecount = 134; + public const int OP_MaxPgcnt = 135; + public const int OP_Trace = 136; + public const int OP_Noop = 137; + public const int OP_Explain = 138; - /* The following opcode values are never used */ - //#define OP_NotUsed_139 139 - //#define OP_NotUsed_140 140 + /* The following opcode values are never used */ + //#define OP_NotUsed_139 139 + //#define OP_NotUsed_140 140 - /* The following opcode values are never used */ - public const int OP_NotUsed_138 = 138; - public const int OP_NotUsed_139 = 139; - public const int OP_NotUsed_140 = 140; + /* The following opcode values are never used */ + public const int OP_NotUsed_138 = 138; + public const int OP_NotUsed_139 = 139; + public const int OP_NotUsed_140 = 140; - /* Properties such as "out2" or "jump" that are specified in - ** comments following the "case" for each opcode in the vdbe.c - ** are encoded into bitvectors as follows: - */ - //#define OPFLG_JUMP 0x0001 /* jump: P2 holds jmp target */ - //#define OPFLG_OUT2_PRERELEASE 0x0002 /* out2-prerelease: */ - //#define OPFLG_IN1 0x0004 /* in1: P1 is an input */ - //#define OPFLG_IN2 0x0008 /* in2: P2 is an input */ - //#define OPFLG_IN3 0x0010 /* in3: P3 is an input */ - //#define OPFLG_OUT2 0x0020 /* out2: P2 is an output */ - //#define OPFLG_OUT3 0x0040 /* out3: P3 is an output */ + /* Properties such as "out2" or "jump" that are specified in + ** comments following the "case" for each opcode in the vdbe.c + ** are encoded into bitvectors as follows: + */ + //#define OPFLG_JUMP 0x0001 /* jump: P2 holds jmp target */ + //#define OPFLG_OUT2_PRERELEASE 0x0002 /* out2-prerelease: */ + //#define OPFLG_IN1 0x0004 /* in1: P1 is an input */ + //#define OPFLG_IN2 0x0008 /* in2: P2 is an input */ + //#define OPFLG_IN3 0x0010 /* in3: P3 is an input */ + //#define OPFLG_OUT2 0x0020 /* out2: P2 is an output */ + //#define OPFLG_OUT3 0x0040 /* out3: P3 is an output */ - public const int OPFLG_JUMP = 0x0001; /* jump: P2 holds jmp target */ - public const int OPFLG_OUT2_PRERELEASE = 0x0002; /* out2-prerelease: */ - public const int OPFLG_IN1 = 0x0004; /* in1: P1 is an input */ - public const int OPFLG_IN2 = 0x0008; /* in2: P2 is an input */ - public const int OPFLG_IN3 = 0x0010; /* in3: P3 is an input */ - public const int OPFLG_OUT2 = 0x0020; /* out2: P2 is an output */ - public const int OPFLG_OUT3 = 0x0040; /* out3: P3 is an output */ - public static int[] OPFLG_INITIALIZER = new int[]{ + public const int OPFLG_JUMP = 0x0001; /* jump: P2 holds jmp target */ + public const int OPFLG_OUT2_PRERELEASE = 0x0002; /* out2-prerelease: */ + public const int OPFLG_IN1 = 0x0004; /* in1: P1 is an input */ + public const int OPFLG_IN2 = 0x0008; /* in2: P2 is an input */ + public const int OPFLG_IN3 = 0x0010; /* in3: P3 is an input */ + public const int OPFLG_OUT2 = 0x0020; /* out2: P2 is an output */ + public const int OPFLG_OUT3 = 0x0040; /* out3: P3 is an output */ + public static int[] OPFLG_INITIALIZER = new int[]{ /* 0 */ 0x00, 0x01, 0x05, 0x04, 0x04, 0x10, 0x00, 0x02, /* 8 */ 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x24, 0x24, /* 16 */ 0x00, 0x00, 0x00, 0x24, 0x04, 0x05, 0x04, 0x00, @@ -344,5 +342,5 @@ public partial class Sqlite3 /* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, /* 144 */ 0x04, 0x04 }; - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/os_c.cs b/Src/IronPython.SQLite/c#sqlite/os_c.cs index c396dfbe3..6bd1c4aaf 100644 --- a/Src/IronPython.SQLite/c#sqlite/os_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/os_c.cs @@ -3,57 +3,55 @@ using HANDLE = System.IntPtr; using i64 = System.Int64; -using u32 = System.UInt32; using sqlite3_int64 = System.Int64; +using u32 = System.UInt32; -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { +namespace Community.CsharpSqlite { + public partial class Sqlite3 { - /* - ** 2005 November 29 - ** - ** 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 contains OS interface code that is common to all - ** architectures. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-12-07 20:14:09 a586a4deeb25330037a49df295b36aaf624d0f45 - ** - ************************************************************************* - */ - //#define _SQLITE_OS_C_ 1 - //#include "sqliteInt.h" - //#undef _SQLITE_OS_C_ + /* + ** 2005 November 29 + ** + ** 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 contains OS interface code that is common to all + ** architectures. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-12-07 20:14:09 a586a4deeb25330037a49df295b36aaf624d0f45 + ** + ************************************************************************* + */ + //#define _SQLITE_OS_C_ 1 + //#include "sqliteInt.h" + //#undef _SQLITE_OS_C_ - /* - ** The default SQLite sqlite3_vfs implementations do not allocate - ** memory (actually, os_unix.c allocates a small amount of memory - ** from within OsOpen()), but some third-party implementations may. - ** So we test the effects of a malloc() failing and the sqlite3OsXXX() - ** function returning SQLITE_IOERR_NOMEM using the DO_OS_MALLOC_TEST macro. - ** - ** The following functions are instrumented for malloc() failure - ** testing: - ** - ** sqlite3OsOpen() - ** sqlite3OsRead() - ** sqlite3OsWrite() - ** sqlite3OsSync() - ** sqlite3OsLock() - ** - */ + /* + ** The default SQLite sqlite3_vfs implementations do not allocate + ** memory (actually, os_unix.c allocates a small amount of memory + ** from within OsOpen()), but some third-party implementations may. + ** So we test the effects of a malloc() failing and the sqlite3OsXXX() + ** function returning SQLITE_IOERR_NOMEM using the DO_OS_MALLOC_TEST macro. + ** + ** The following functions are instrumented for malloc() failure + ** testing: + ** + ** sqlite3OsOpen() + ** sqlite3OsRead() + ** sqlite3OsWrite() + ** sqlite3OsSync() + ** sqlite3OsLock() + ** + */ #if (SQLITE_TEST) static int sqlite3_memdebug_vfs_oom_test = 1; @@ -67,353 +65,300 @@ static void DO_OS_MALLOC_TEST( sqlite3_file x ) { } #else - //#define DO_OS_MALLOC_TEST(x) - static void DO_OS_MALLOC_TEST( sqlite3_file x ) { } + //#define DO_OS_MALLOC_TEST(x) + static void DO_OS_MALLOC_TEST(sqlite3_file x) { } #endif - /* -** The following routines are convenience wrappers around methods -** of the sqlite3_file object. This is mostly just syntactic sugar. All -** of this would be completely automatic if SQLite were coded using -** C++ instead of plain old C. -*/ - static int sqlite3OsClose( sqlite3_file pId ) - { - int rc = SQLITE_OK; - if ( pId.pMethods != null ) - { - rc = pId.pMethods.xClose( pId ); - pId.pMethods = null; - } - return rc; - } - static int sqlite3OsRead( sqlite3_file id, byte[] pBuf, int amt, i64 offset ) - { - DO_OS_MALLOC_TEST( id ); - if ( pBuf == null ) - pBuf = sqlite3Malloc( amt ); - return id.pMethods.xRead( id, pBuf, amt, offset ); - } - static int sqlite3OsWrite( sqlite3_file id, byte[] pBuf, int amt, i64 offset ) - { - DO_OS_MALLOC_TEST( id ); - return id.pMethods.xWrite( id, pBuf, amt, offset ); - } - static int sqlite3OsTruncate( sqlite3_file id, i64 size ) - { - return id.pMethods.xTruncate( id, size ); - } - static int sqlite3OsSync( sqlite3_file id, int flags ) - { - DO_OS_MALLOC_TEST( id ); - return id.pMethods.xSync( id, flags ); - } - static int sqlite3OsFileSize( sqlite3_file id, ref long pSize ) - { - return id.pMethods.xFileSize( id, ref pSize ); - } - static int sqlite3OsLock( sqlite3_file id, int lockType ) - { - DO_OS_MALLOC_TEST( id ); - return id.pMethods.xLock( id, lockType ); - } - static int sqlite3OsUnlock( sqlite3_file id, int lockType ) - { - return id.pMethods.xUnlock( id, lockType ); - } - static int sqlite3OsCheckReservedLock( sqlite3_file id, ref int pResOut ) - { - DO_OS_MALLOC_TEST( id ); - return id.pMethods.xCheckReservedLock( id, ref pResOut ); - } - static int sqlite3OsFileControl( sqlite3_file id, u32 op, ref sqlite3_int64 pArg ) - { - return id.pMethods.xFileControl( id, (int)op, ref pArg ); - } + /* + ** The following routines are convenience wrappers around methods + ** of the sqlite3_file object. This is mostly just syntactic sugar. All + ** of this would be completely automatic if SQLite were coded using + ** C++ instead of plain old C. + */ + static int sqlite3OsClose(sqlite3_file pId) { + int rc = SQLITE_OK; + if (pId.pMethods != null) { + rc = pId.pMethods.xClose(pId); + pId.pMethods = null; + } + return rc; + } + static int sqlite3OsRead(sqlite3_file id, byte[] pBuf, int amt, i64 offset) { + DO_OS_MALLOC_TEST(id); + if (pBuf == null) + pBuf = sqlite3Malloc(amt); + return id.pMethods.xRead(id, pBuf, amt, offset); + } + static int sqlite3OsWrite(sqlite3_file id, byte[] pBuf, int amt, i64 offset) { + DO_OS_MALLOC_TEST(id); + return id.pMethods.xWrite(id, pBuf, amt, offset); + } + static int sqlite3OsTruncate(sqlite3_file id, i64 size) { + return id.pMethods.xTruncate(id, size); + } + static int sqlite3OsSync(sqlite3_file id, int flags) { + DO_OS_MALLOC_TEST(id); + return id.pMethods.xSync(id, flags); + } + static int sqlite3OsFileSize(sqlite3_file id, ref long pSize) { + return id.pMethods.xFileSize(id, ref pSize); + } + static int sqlite3OsLock(sqlite3_file id, int lockType) { + DO_OS_MALLOC_TEST(id); + return id.pMethods.xLock(id, lockType); + } + static int sqlite3OsUnlock(sqlite3_file id, int lockType) { + return id.pMethods.xUnlock(id, lockType); + } + static int sqlite3OsCheckReservedLock(sqlite3_file id, ref int pResOut) { + DO_OS_MALLOC_TEST(id); + return id.pMethods.xCheckReservedLock(id, ref pResOut); + } + static int sqlite3OsFileControl(sqlite3_file id, u32 op, ref sqlite3_int64 pArg) { + return id.pMethods.xFileControl(id, (int)op, ref pArg); + } - static int sqlite3OsSectorSize( sqlite3_file id ) - { - dxSectorSize xSectorSize = id.pMethods.xSectorSize; - return ( xSectorSize != null ? xSectorSize( id ) : SQLITE_DEFAULT_SECTOR_SIZE ); - } - static int sqlite3OsDeviceCharacteristics( sqlite3_file id ) - { - return id.pMethods.xDeviceCharacteristics( id ); - } + static int sqlite3OsSectorSize(sqlite3_file id) { + dxSectorSize xSectorSize = id.pMethods.xSectorSize; + return (xSectorSize != null ? xSectorSize(id) : SQLITE_DEFAULT_SECTOR_SIZE); + } + static int sqlite3OsDeviceCharacteristics(sqlite3_file id) { + return id.pMethods.xDeviceCharacteristics(id); + } - static int sqlite3OsShmLock( sqlite3_file id, int offset, int n, int flags ) - { - return id.pMethods.xShmLock( id, offset, n, flags ); - } - static void sqlite3OsShmBarrier( sqlite3_file id ) - { - id.pMethods.xShmBarrier( id ); - } + static int sqlite3OsShmLock(sqlite3_file id, int offset, int n, int flags) { + return id.pMethods.xShmLock(id, offset, n, flags); + } + static void sqlite3OsShmBarrier(sqlite3_file id) { + id.pMethods.xShmBarrier(id); + } - static int sqlite3OsShmUnmap( sqlite3_file id, int deleteFlag ) - { - return id.pMethods.xShmUnmap( id, deleteFlag ); - } - static int sqlite3OsShmMap( -sqlite3_file id, /* Database file handle */ -int iPage, -int pgsz, -int bExtend, /* True to extend file if necessary */ -out object pp /* OUT: Pointer to mapping */ -) - { - return id.pMethods.xShmMap( id, iPage, pgsz, bExtend, out pp ); - } + static int sqlite3OsShmUnmap(sqlite3_file id, int deleteFlag) { + return id.pMethods.xShmUnmap(id, deleteFlag); + } + static int sqlite3OsShmMap( + sqlite3_file id, /* Database file handle */ + int iPage, + int pgsz, + int bExtend, /* True to extend file if necessary */ + out object pp /* OUT: Pointer to mapping */ + ) { + return id.pMethods.xShmMap(id, iPage, pgsz, bExtend, out pp); + } - /* - ** The next group of routines are convenience wrappers around the - ** VFS methods. - */ - static int sqlite3OsOpen( - sqlite3_vfs pVfs, - string zPath, - sqlite3_file pFile, - int flags, - ref int pFlagsOut - ) - { - int rc; - DO_OS_MALLOC_TEST( null ); - /* 0x87f3f is a mask of SQLITE_OPEN_ flags that are valid to be passed - ** down into the VFS layer. Some SQLITE_OPEN_ flags (for example, - ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before - ** reaching the VFS. */ - rc = pVfs.xOpen( pVfs, zPath, pFile, flags & 0x87f3f, out pFlagsOut ); - Debug.Assert( rc == SQLITE_OK || pFile.pMethods == null ); - return rc; - } - static int sqlite3OsDelete( sqlite3_vfs pVfs, string zPath, int dirSync ) - { - return pVfs.xDelete( pVfs, zPath, dirSync ); - } - static int sqlite3OsAccess( sqlite3_vfs pVfs, string zPath, int flags, ref int pResOut ) - { - DO_OS_MALLOC_TEST( null ); - return pVfs.xAccess( pVfs, zPath, flags, out pResOut ); - } - static int sqlite3OsFullPathname( - sqlite3_vfs pVfs, - string zPath, - int nPathOut, - StringBuilder zPathOut - ) - { - zPathOut.Length = 0;//zPathOut[0] = 0; - return pVfs.xFullPathname( pVfs, zPath, nPathOut, zPathOut ); - } + /* + ** The next group of routines are convenience wrappers around the + ** VFS methods. + */ + static int sqlite3OsOpen( + sqlite3_vfs pVfs, + string zPath, + sqlite3_file pFile, + int flags, + ref int pFlagsOut + ) { + int rc; + DO_OS_MALLOC_TEST(null); + /* 0x87f3f is a mask of SQLITE_OPEN_ flags that are valid to be passed + ** down into the VFS layer. Some SQLITE_OPEN_ flags (for example, + ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before + ** reaching the VFS. */ + rc = pVfs.xOpen(pVfs, zPath, pFile, flags & 0x87f3f, out pFlagsOut); + Debug.Assert(rc == SQLITE_OK || pFile.pMethods == null); + return rc; + } + static int sqlite3OsDelete(sqlite3_vfs pVfs, string zPath, int dirSync) { + return pVfs.xDelete(pVfs, zPath, dirSync); + } + static int sqlite3OsAccess(sqlite3_vfs pVfs, string zPath, int flags, ref int pResOut) { + DO_OS_MALLOC_TEST(null); + return pVfs.xAccess(pVfs, zPath, flags, out pResOut); + } + static int sqlite3OsFullPathname( + sqlite3_vfs pVfs, + string zPath, + int nPathOut, + StringBuilder zPathOut + ) { + zPathOut.Length = 0;//zPathOut[0] = 0; + return pVfs.xFullPathname(pVfs, zPath, nPathOut, zPathOut); + } #if !SQLITE_OMIT_LOAD_EXTENSION - static HANDLE sqlite3OsDlOpen( sqlite3_vfs pVfs, string zPath ) - { - return pVfs.xDlOpen( pVfs, zPath ); - } + static HANDLE sqlite3OsDlOpen(sqlite3_vfs pVfs, string zPath) { + return pVfs.xDlOpen(pVfs, zPath); + } - static void sqlite3OsDlError( sqlite3_vfs pVfs, int nByte, string zBufOut ) - { - pVfs.xDlError( pVfs, nByte, zBufOut ); - } - static object sqlite3OsDlSym( sqlite3_vfs pVfs, HANDLE pHdle, ref string zSym ) - { - return pVfs.xDlSym( pVfs, pHdle, zSym ); - } - static void sqlite3OsDlClose( sqlite3_vfs pVfs, HANDLE pHandle ) - { - pVfs.xDlClose( pVfs, pHandle ); - } + static void sqlite3OsDlError(sqlite3_vfs pVfs, int nByte, string zBufOut) { + pVfs.xDlError(pVfs, nByte, zBufOut); + } + static object sqlite3OsDlSym(sqlite3_vfs pVfs, HANDLE pHdle, ref string zSym) { + return pVfs.xDlSym(pVfs, pHdle, zSym); + } + static void sqlite3OsDlClose(sqlite3_vfs pVfs, HANDLE pHandle) { + pVfs.xDlClose(pVfs, pHandle); + } #endif - static int sqlite3OsRandomness( sqlite3_vfs pVfs, int nByte, byte[] zBufOut ) - { - return pVfs.xRandomness( pVfs, nByte, zBufOut ); - } - static int sqlite3OsSleep( sqlite3_vfs pVfs, int nMicro ) - { - return pVfs.xSleep( pVfs, nMicro ); - } + static int sqlite3OsRandomness(sqlite3_vfs pVfs, int nByte, byte[] zBufOut) { + return pVfs.xRandomness(pVfs, nByte, zBufOut); + } + static int sqlite3OsSleep(sqlite3_vfs pVfs, int nMicro) { + return pVfs.xSleep(pVfs, nMicro); + } - static int sqlite3OsCurrentTimeInt64( sqlite3_vfs pVfs, ref sqlite3_int64 pTimeOut ) - { - int rc; - /* IMPLEMENTATION-OF: R-49045-42493 SQLite will use the xCurrentTimeInt64() - ** method to get the current date and time if that method is available - ** (if iVersion is 2 or greater and the function pointer is not NULL) and - ** will fall back to xCurrentTime() if xCurrentTimeInt64() is - ** unavailable. - */ - if ( pVfs.iVersion >= 2 && pVfs.xCurrentTimeInt64 != null ) - { - rc = pVfs.xCurrentTimeInt64( pVfs, ref pTimeOut ); - } - else - { - double r = 0; - rc = pVfs.xCurrentTime( pVfs, ref r ); - pTimeOut = (sqlite3_int64)( r * 86400000.0 ); - } - return rc; - } + static int sqlite3OsCurrentTimeInt64(sqlite3_vfs pVfs, ref sqlite3_int64 pTimeOut) { + int rc; + /* IMPLEMENTATION-OF: R-49045-42493 SQLite will use the xCurrentTimeInt64() + ** method to get the current date and time if that method is available + ** (if iVersion is 2 or greater and the function pointer is not NULL) and + ** will fall back to xCurrentTime() if xCurrentTimeInt64() is + ** unavailable. + */ + if (pVfs.iVersion >= 2 && pVfs.xCurrentTimeInt64 != null) { + rc = pVfs.xCurrentTimeInt64(pVfs, ref pTimeOut); + } else { + double r = 0; + rc = pVfs.xCurrentTime(pVfs, ref r); + pTimeOut = (sqlite3_int64)(r * 86400000.0); + } + return rc; + } - static int sqlite3OsOpenMalloc( - ref sqlite3_vfs pVfs, - string zFile, - ref sqlite3_file ppFile, - int flags, - ref int pOutFlags - ) - { - int rc = SQLITE_NOMEM; - sqlite3_file pFile; - pFile = new sqlite3_file(); //sqlite3Malloc(ref pVfs.szOsFile); - if ( pFile != null ) - { - rc = sqlite3OsOpen( pVfs, zFile, pFile, flags, ref pOutFlags ); - if ( rc != SQLITE_OK ) - { - pFile = null; // was sqlite3DbFree(db,ref pFile); - } - else - { - ppFile = pFile; - } - } - return rc; - } - static int sqlite3OsCloseFree( sqlite3_file pFile ) - { - int rc = SQLITE_OK; - Debug.Assert( pFile != null ); - rc = sqlite3OsClose( pFile ); - //sqlite3_free( ref pFile ); - return rc; - } + static int sqlite3OsOpenMalloc( + ref sqlite3_vfs pVfs, + string zFile, + ref sqlite3_file ppFile, + int flags, + ref int pOutFlags + ) { + int rc = SQLITE_NOMEM; + sqlite3_file pFile; + pFile = new sqlite3_file(); //sqlite3Malloc(ref pVfs.szOsFile); + if (pFile != null) { + rc = sqlite3OsOpen(pVfs, zFile, pFile, flags, ref pOutFlags); + if (rc != SQLITE_OK) { + pFile = null; // was sqlite3DbFree(db,ref pFile); + } else { + ppFile = pFile; + } + } + return rc; + } + static int sqlite3OsCloseFree(sqlite3_file pFile) { + int rc = SQLITE_OK; + Debug.Assert(pFile != null); + rc = sqlite3OsClose(pFile); + //sqlite3_free( ref pFile ); + return rc; + } - /* - ** This function is a wrapper around the OS specific implementation of - ** sqlite3_os_init(). The purpose of the wrapper is to provide the - ** ability to simulate a malloc failure, so that the handling of an - ** error in sqlite3_os_init() by the upper layers can be tested. - */ - static int sqlite3OsInit() - { - //void *p = sqlite3_malloc(10); - //if( p==null ) return SQLITE_NOMEM; - //sqlite3_free(ref p); - return sqlite3_os_init(); - } - /* - ** The list of all registered VFS implementations. - */ - static sqlite3_vfs vfsList; - //#define vfsList GLOBAL(sqlite3_vfs *, vfsList) + /* + ** This function is a wrapper around the OS specific implementation of + ** sqlite3_os_init(). The purpose of the wrapper is to provide the + ** ability to simulate a malloc failure, so that the handling of an + ** error in sqlite3_os_init() by the upper layers can be tested. + */ + static int sqlite3OsInit() { + //void *p = sqlite3_malloc(10); + //if( p==null ) return SQLITE_NOMEM; + //sqlite3_free(ref p); + return sqlite3_os_init(); + } + /* + ** The list of all registered VFS implementations. + */ + static sqlite3_vfs vfsList; + //#define vfsList GLOBAL(sqlite3_vfs *, vfsList) - /* - ** Locate a VFS by name. If no name is given, simply return the - ** first VFS on the list. - */ - static bool isInit = false; + /* + ** Locate a VFS by name. If no name is given, simply return the + ** first VFS on the list. + */ + static bool isInit = false; - static public sqlite3_vfs sqlite3_vfs_find(string zVfs) - { - sqlite3_vfs pVfs = null; + static public sqlite3_vfs sqlite3_vfs_find(string zVfs) { + sqlite3_vfs pVfs = null; #if SQLITE_THREADSAFE - sqlite3_mutex mutex; + sqlite3_mutex mutex; #endif #if !SQLITE_OMIT_AUTOINIT - int rc = sqlite3_initialize(); - if ( rc != 0 ) - return null; + int rc = sqlite3_initialize(); + if (rc != 0) + return null; #endif #if SQLITE_THREADSAFE - mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); + mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); #endif - sqlite3_mutex_enter( mutex ); - for ( pVfs = vfsList; pVfs != null; pVfs = pVfs.pNext ) - { - if ( zVfs == null || zVfs == "" ) - break; - if ( zVfs == pVfs.zName ) - break; //strcmp(zVfs, pVfs.zName) == null) break; - } - sqlite3_mutex_leave( mutex ); - return pVfs; - } + sqlite3_mutex_enter(mutex); + for (pVfs = vfsList; pVfs != null; pVfs = pVfs.pNext) { + if (zVfs == null || zVfs == "") + break; + if (zVfs == pVfs.zName) + break; //strcmp(zVfs, pVfs.zName) == null) break; + } + sqlite3_mutex_leave(mutex); + return pVfs; + } - /* - ** Unlink a VFS from the linked list - */ - static void vfsUnlink( sqlite3_vfs pVfs ) - { - Debug.Assert( sqlite3_mutex_held( sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ) ) ); - if ( pVfs == null ) - { - /* No-op */ - } - else if ( vfsList == pVfs ) - { - vfsList = pVfs.pNext; - } - else if ( vfsList != null ) - { - sqlite3_vfs p = vfsList; - while ( p.pNext != null && p.pNext != pVfs ) - { - p = p.pNext; - } - if ( p.pNext == pVfs ) - { - p.pNext = pVfs.pNext; - } - } - } + /* + ** Unlink a VFS from the linked list + */ + static void vfsUnlink(sqlite3_vfs pVfs) { + Debug.Assert(sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER))); + if (pVfs == null) { + /* No-op */ + } else if (vfsList == pVfs) { + vfsList = pVfs.pNext; + } else if (vfsList != null) { + sqlite3_vfs p = vfsList; + while (p.pNext != null && p.pNext != pVfs) { + p = p.pNext; + } + if (p.pNext == pVfs) { + p.pNext = pVfs.pNext; + } + } + } - /* - ** Register a VFS with the system. It is harmless to register the same - ** VFS multiple times. The new VFS becomes the default if makeDflt is - ** true. - */ - static public int sqlite3_vfs_register( sqlite3_vfs pVfs, int makeDflt ) - { - sqlite3_mutex mutex; + /* + ** Register a VFS with the system. It is harmless to register the same + ** VFS multiple times. The new VFS becomes the default if makeDflt is + ** true. + */ + static public int sqlite3_vfs_register(sqlite3_vfs pVfs, int makeDflt) { + sqlite3_mutex mutex; #if !SQLITE_OMIT_AUTOINIT - int rc = sqlite3_initialize(); - if ( rc != 0 ) - return rc; + int rc = sqlite3_initialize(); + if (rc != 0) + return rc; #endif - mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); - sqlite3_mutex_enter( mutex ); - vfsUnlink( pVfs ); - if ( makeDflt != 0 || vfsList == null ) - { - pVfs.pNext = vfsList; - vfsList = pVfs; - } - else - { - pVfs.pNext = vfsList.pNext; - vfsList.pNext = pVfs; - } - Debug.Assert( vfsList != null ); - sqlite3_mutex_leave( mutex ); - return SQLITE_OK; - } + mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); + sqlite3_mutex_enter(mutex); + vfsUnlink(pVfs); + if (makeDflt != 0 || vfsList == null) { + pVfs.pNext = vfsList; + vfsList = pVfs; + } else { + pVfs.pNext = vfsList.pNext; + vfsList.pNext = pVfs; + } + Debug.Assert(vfsList != null); + sqlite3_mutex_leave(mutex); + return SQLITE_OK; + } - /* - ** Unregister a VFS so that it is no longer accessible. - */ - static int sqlite3_vfs_unregister( sqlite3_vfs pVfs ) - { + /* + ** Unregister a VFS so that it is no longer accessible. + */ + static int sqlite3_vfs_unregister(sqlite3_vfs pVfs) { #if SQLITE_THREADSAFE - sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); + sqlite3_mutex mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); #endif - sqlite3_mutex_enter( mutex ); - vfsUnlink( pVfs ); - sqlite3_mutex_leave( mutex ); - return SQLITE_OK; + sqlite3_mutex_enter(mutex); + vfsUnlink(pVfs); + sqlite3_mutex_leave(mutex); + return SQLITE_OK; + } } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/os_common_h.cs b/Src/IronPython.SQLite/c#sqlite/os_common_h.cs index 2f7567d31..92a64782a 100644 --- a/Src/IronPython.SQLite/c#sqlite/os_common_h.cs +++ b/Src/IronPython.SQLite/c#sqlite/os_common_h.cs @@ -1,64 +1,60 @@ -using System.Diagnostics; using va_list = System.Object; -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 2004 May 22 - ** - ** 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 contains macros and a little bit of code that is common to - ** all of the platform-specific files (os_*.c) and is #included into those - ** files. - ** - ** This file should be #included by the os_*.c files only. It is not a - ** general purpose header file. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#if !_OS_COMMON_H_ - //#define _OS_COMMON_H_ - /* - ** At least two bugs have slipped in because we changed the MEMORY_DEBUG - ** macro to SQLITE_DEBUG and some older makefiles have not yet made the - ** switch. The following code should catch this problem at compile-time. - */ +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2004 May 22 + ** + ** 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 contains macros and a little bit of code that is common to + ** all of the platform-specific files (os_*.c) and is #included into those + ** files. + ** + ** This file should be #included by the os_*.c files only. It is not a + ** general purpose header file. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + //#if !_OS_COMMON_H_ + //#define _OS_COMMON_H_ + /* + ** At least two bugs have slipped in because we changed the MEMORY_DEBUG + ** macro to SQLITE_DEBUG and some older makefiles have not yet made the + ** switch. The following code should catch this problem at compile-time. + */ #if MEMORY_DEBUG //# error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead." #endif #if SQLITE_DEBUG || TRACE - static bool sqlite3OsTrace = false; - //#define OSTRACE(X) if( sqlite3OSTrace ) sqlite3DebugPrintf X - static void OSTRACE( string X, params va_list[] ap ) - { - if ( sqlite3OsTrace ) - sqlite3DebugPrintf( X, ap ); - } + static bool sqlite3OsTrace = false; + //#define OSTRACE(X) if( sqlite3OSTrace ) sqlite3DebugPrintf X + static void OSTRACE(string X, params va_list[] ap) { + if (sqlite3OsTrace) + sqlite3DebugPrintf(X, ap); + } #else //#define OSTRACE(X) static void OSTRACE( string X, params object[] ap) { } #endif - /* -** Macros for performance tracing. Normally turned off. Only works -** on i486 hardware. -*/ + /* + ** Macros for performance tracing. Normally turned off. Only works + ** on i486 hardware. + */ #if SQLITE_PERFORMANCE_TRACE /* @@ -73,16 +69,16 @@ static void OSTRACE( string X, params object[] ap) { } //#define TIMER_END g_elapsed=sqlite3Hwtime()-g_start //#define TIMER_ELAPSED g_elapsed #else - const int TIMER_START = 0; //#define TIMER_START - const int TIMER_END = 0; //#define TIMER_END - const int TIMER_ELAPSED = 0; //#define TIMER_ELAPSED ((sqlite_u3264)0) + const int TIMER_START = 0; //#define TIMER_START + const int TIMER_END = 0; //#define TIMER_END + const int TIMER_ELAPSED = 0; //#define TIMER_ELAPSED ((sqlite_u3264)0) #endif - /* -** If we compile with the SQLITE_TEST macro set, then the following block -** of code will give us the ability to simulate a disk I/O error. This -** is used for testing the I/O recovery logic. -*/ + /* + ** If we compile with the SQLITE_TEST macro set, then the following block + ** of code will give us the ability to simulate a disk I/O error. This + ** is used for testing the I/O recovery logic. + */ #if SQLITE_TEST #if !TCLSH @@ -191,17 +187,17 @@ static bool SimulateDiskfullError() return false; } #else - static bool SimulateIOError() { return false; } -//#define SimulateIOErrorBenign(X) - static void SimulateIOErrorBenign( int x ) { } + static bool SimulateIOError() { return false; } + //#define SimulateIOErrorBenign(X) + static void SimulateIOErrorBenign(int x) { } -//#define SimulateIOError(A) -//#define SimulateDiskfullError(A) + //#define SimulateIOError(A) + //#define SimulateDiskfullError(A) #endif - /* -** When testing, keep a count of the number of open files. -*/ + /* + ** When testing, keep a count of the number of open files. + */ #if SQLITE_TEST #if !TCLSH static int sqlite3_open_file_count = 0; @@ -218,8 +214,8 @@ static void OpenCounter( int X ) #endif } #else -//#define OpenCounter(X) + //#define OpenCounter(X) #endif - //#endif //* !_OS_COMMON_H_) */ - } + //#endif //* !_OS_COMMON_H_) */ + } } diff --git a/Src/IronPython.SQLite/c#sqlite/os_h.cs b/Src/IronPython.SQLite/c#sqlite/os_h.cs index 2c54c9de8..f48b14312 100644 --- a/Src/IronPython.SQLite/c#sqlite/os_h.cs +++ b/Src/IronPython.SQLite/c#sqlite/os_h.cs @@ -1,109 +1,107 @@ #define SQLITE_OS_WIN using u32 = System.UInt32; -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 2001 September 16 - ** - ** 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 header file (together with is companion C source-code file - ** "os.c") attempt to abstract the underlying operating system so that - ** the SQLite library will work on both POSIX and windows systems. - ** - ** This header file is #include-ed by sqliteInt.h and thus ends up - ** being included by every source file. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2001 September 16 + ** + ** 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 header file (together with is companion C source-code file + ** "os.c") attempt to abstract the underlying operating system so that + ** the SQLite library will work on both POSIX and windows systems. + ** + ** This header file is #include-ed by sqliteInt.h and thus ends up + ** being included by every source file. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ #if !_SQLITE_OS_H_ - //#define _SQLITE_OS_H_ + //#define _SQLITE_OS_H_ - /* - ** Figure out if we are dealing with Unix, Windows, or some other - ** operating system. After the following block of preprocess macros, - ** all of SQLITE_OS_UNIX, SQLITE_OS_WIN, SQLITE_OS_OS2, and SQLITE_OS_OTHER - ** will defined to either 1 or 0. One of the four will be 1. The other - ** three will be 0. - */ - //#if (SQLITE_OS_OTHER) - //# if SQLITE_OS_OTHER==1 - //# undef SQLITE_OS_UNIX - //# define SQLITE_OS_UNIX 0 - //# undef SQLITE_OS_WIN - //# define SQLITE_OS_WIN 0 - //# undef SQLITE_OS_OS2 - //# define SQLITE_OS_OS2 0 - //# else - //# undef SQLITE_OS_OTHER - //# endif - //#endif - //#if !(SQLITE_OS_UNIX) && !SQLITE_OS_OTHER) - //# define SQLITE_OS_OTHER 0 - //# ifndef SQLITE_OS_WIN - //# if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__) - //# define SQLITE_OS_WIN 1 - //# define SQLITE_OS_UNIX 0 - //# define SQLITE_OS_OS2 0 - //# elif defined(__EMX__) || defined(_OS2) || defined(OS2) || defined(_OS2_) || defined(__OS2__) - //# define SQLITE_OS_WIN 0 - //# define SQLITE_OS_UNIX 0 - //# define SQLITE_OS_OS2 1 - //# else - //# define SQLITE_OS_WIN 0 - //# define SQLITE_OS_UNIX 1 - //# define SQLITE_OS_OS2 0 - //# endif - //# else - //# define SQLITE_OS_UNIX 0 - //# define SQLITE_OS_OS2 0 - //# endif - //#else - //# ifndef SQLITE_OS_WIN - //# define SQLITE_OS_WIN 0 - //# endif - //#endif + /* + ** Figure out if we are dealing with Unix, Windows, or some other + ** operating system. After the following block of preprocess macros, + ** all of SQLITE_OS_UNIX, SQLITE_OS_WIN, SQLITE_OS_OS2, and SQLITE_OS_OTHER + ** will defined to either 1 or 0. One of the four will be 1. The other + ** three will be 0. + */ + //#if (SQLITE_OS_OTHER) + //# if SQLITE_OS_OTHER==1 + //# undef SQLITE_OS_UNIX + //# define SQLITE_OS_UNIX 0 + //# undef SQLITE_OS_WIN + //# define SQLITE_OS_WIN 0 + //# undef SQLITE_OS_OS2 + //# define SQLITE_OS_OS2 0 + //# else + //# undef SQLITE_OS_OTHER + //# endif + //#endif + //#if !(SQLITE_OS_UNIX) && !SQLITE_OS_OTHER) + //# define SQLITE_OS_OTHER 0 + //# ifndef SQLITE_OS_WIN + //# if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__) + //# define SQLITE_OS_WIN 1 + //# define SQLITE_OS_UNIX 0 + //# define SQLITE_OS_OS2 0 + //# elif defined(__EMX__) || defined(_OS2) || defined(OS2) || defined(_OS2_) || defined(__OS2__) + //# define SQLITE_OS_WIN 0 + //# define SQLITE_OS_UNIX 0 + //# define SQLITE_OS_OS2 1 + //# else + //# define SQLITE_OS_WIN 0 + //# define SQLITE_OS_UNIX 1 + //# define SQLITE_OS_OS2 0 + //# endif + //# else + //# define SQLITE_OS_UNIX 0 + //# define SQLITE_OS_OS2 0 + //# endif + //#else + //# ifndef SQLITE_OS_WIN + //# define SQLITE_OS_WIN 0 + //# endif + //#endif - const bool SQLITE_OS_WIN = true; - const bool SQLITE_OS_UNIX = false; - const bool SQLITE_OS_OS2 = false; + const bool SQLITE_OS_WIN = true; + const bool SQLITE_OS_UNIX = false; + const bool SQLITE_OS_OS2 = false; - /* - ** Determine if we are dealing with WindowsCE - which has a much - ** reduced API. - */ - //#if (_WIN32_WCE) - //# define SQLITE_OS_WINCE 1 - //#else - //# define SQLITE_OS_WINCE 0 - //#endif + /* + ** Determine if we are dealing with WindowsCE - which has a much + ** reduced API. + */ + //#if (_WIN32_WCE) + //# define SQLITE_OS_WINCE 1 + //#else + //# define SQLITE_OS_WINCE 0 + //#endif - /* - ** Define the maximum size of a temporary filename - */ + /* + ** Define the maximum size of a temporary filename + */ #if SQLITE_OS_WIN - //# include - const int MAX_PATH = 260; - const int SQLITE_TEMPNAME_SIZE = ( MAX_PATH + 50 ); //# define SQLITE_TEMPNAME_SIZE (MAX_PATH+50) + //# include + const int MAX_PATH = 260; + const int SQLITE_TEMPNAME_SIZE = (MAX_PATH + 50); //# define SQLITE_TEMPNAME_SIZE (MAX_PATH+50) #elif SQLITE_OS_OS2 -# if FALSE //(__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 3) && OS2_HIGH_MEMORY) +#if FALSE //(__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 3) && OS2_HIGH_MEMORY) //# include /* has to be included before os2.h for linking to work */ -# endif +#endif //# define INCL_DOSDATETIME //# define INCL_DOSFILEMGR //# define INCL_DOSERRORS @@ -118,187 +116,187 @@ public partial class Sqlite3 //# define SQLITE_TEMPNAME_SIZE 200 #endif - /* If the SET_FULLSYNC macro is not defined above, then make it -** a no-op -*/ - //#if !SET_FULLSYNC - //# define SET_FULLSYNC(x,y) - //#endif - - /* - ** The default size of a disk sector + /* If the SET_FULLSYNC macro is not defined above, then make it + ** a no-op */ + //#if !SET_FULLSYNC + //# define SET_FULLSYNC(x,y) + //#endif + + /* + ** The default size of a disk sector + */ #if !SQLITE_DEFAULT_SECTOR_SIZE - const int SQLITE_DEFAULT_SECTOR_SIZE = 512;//# define SQLITE_DEFAULT_SECTOR_SIZE 512 + const int SQLITE_DEFAULT_SECTOR_SIZE = 512;//# define SQLITE_DEFAULT_SECTOR_SIZE 512 #endif - /* -** Temporary files are named starting with this prefix followed by 16 random -** alphanumeric characters, and no file extension. They are stored in the -** OS's standard temporary file directory, and are deleted prior to exit. -** If sqlite is being embedded in another program, you may wish to change the -** prefix to reflect your program's name, so that if your program exits -** prematurely, old temporary files can be easily identified. This can be done -** using -DSQLITE_TEMP_FILE_PREFIX=myprefix_ on the compiler command line. -** -** 2006-10-31: The default prefix used to be "sqlite_". But then -** Mcafee started using SQLite in their anti-virus product and it -** started putting files with the "sqlite" name in the c:/temp folder. -** This annoyed many windows users. Those users would then do a -** Google search for "sqlite", find the telephone numbers of the -** developers and call to wake them up at night and complain. -** For this reason, the default name prefix is changed to be "sqlite" -** spelled backwards. So the temp files are still identified, but -** anybody smart enough to figure out the code is also likely smart -** enough to know that calling the developer will not help get rid -** of the file. -*/ + /* + ** Temporary files are named starting with this prefix followed by 16 random + ** alphanumeric characters, and no file extension. They are stored in the + ** OS's standard temporary file directory, and are deleted prior to exit. + ** If sqlite is being embedded in another program, you may wish to change the + ** prefix to reflect your program's name, so that if your program exits + ** prematurely, old temporary files can be easily identified. This can be done + ** using -DSQLITE_TEMP_FILE_PREFIX=myprefix_ on the compiler command line. + ** + ** 2006-10-31: The default prefix used to be "sqlite_". But then + ** Mcafee started using SQLite in their anti-virus product and it + ** started putting files with the "sqlite" name in the c:/temp folder. + ** This annoyed many windows users. Those users would then do a + ** Google search for "sqlite", find the telephone numbers of the + ** developers and call to wake them up at night and complain. + ** For this reason, the default name prefix is changed to be "sqlite" + ** spelled backwards. So the temp files are still identified, but + ** anybody smart enough to figure out the code is also likely smart + ** enough to know that calling the developer will not help get rid + ** of the file. + */ #if !SQLITE_TEMP_FILE_PREFIX - const string SQLITE_TEMP_FILE_PREFIX = "etilqs_"; //# define SQLITE_TEMP_FILE_PREFIX "etilqs_" + const string SQLITE_TEMP_FILE_PREFIX = "etilqs_"; //# define SQLITE_TEMP_FILE_PREFIX "etilqs_" #endif - /* -** The following values may be passed as the second argument to -** sqlite3OsLock(). The various locks exhibit the following semantics: -** -** SHARED: Any number of processes may hold a SHARED lock simultaneously. -** RESERVED: A single process may hold a RESERVED lock on a file at -** any time. Other processes may hold and obtain new SHARED locks. -** PENDING: A single process may hold a PENDING lock on a file at -** any one time. Existing SHARED locks may persist, but no new -** SHARED locks may be obtained by other processes. -** EXCLUSIVE: An EXCLUSIVE lock precludes all other locks. -** -** PENDING_LOCK may not be passed directly to sqlite3OsLock(). Instead, a -** process that requests an EXCLUSIVE lock may actually obtain a PENDING -** lock. This can be upgraded to an EXCLUSIVE lock by a subsequent call to -** sqlite3OsLock(). -*/ - const int NO_LOCK = 0; - const int SHARED_LOCK = 1; - const int RESERVED_LOCK = 2; - const int PENDING_LOCK = 3; - const int EXCLUSIVE_LOCK = 4; - - /* - ** File Locking Notes: (Mostly about windows but also some info for Unix) - ** - ** We cannot use LockFileEx() or UnlockFileEx() on Win95/98/ME because - ** those functions are not available. So we use only LockFile() and - ** UnlockFile(). - ** - ** LockFile() prevents not just writing but also reading by other processes. - ** A SHARED_LOCK is obtained by locking a single randomly-chosen - ** byte out of a specific range of bytes. The lock byte is obtained at - ** random so two separate readers can probably access the file at the - ** same time, unless they are unlucky and choose the same lock byte. - ** An EXCLUSIVE_LOCK is obtained by locking all bytes in the range. - ** There can only be one writer. A RESERVED_LOCK is obtained by locking - ** a single byte of the file that is designated as the reserved lock byte. - ** A PENDING_LOCK is obtained by locking a designated byte different from - ** the RESERVED_LOCK byte. - ** - ** On WinNT/2K/XP systems, LockFileEx() and UnlockFileEx() are available, - ** which means we can use reader/writer locks. When reader/writer locks - ** are used, the lock is placed on the same range of bytes that is used - ** for probabilistic locking in Win95/98/ME. Hence, the locking scheme - ** will support two or more Win95 readers or two or more WinNT readers. - ** But a single Win95 reader will lock out all WinNT readers and a single - ** WinNT reader will lock out all other Win95 readers. - ** - ** The following #defines specify the range of bytes used for locking. - ** SHARED_SIZE is the number of bytes available in the pool from which - ** a random byte is selected for a shared lock. The pool of bytes for - ** shared locks begins at SHARED_FIRST. + /* + ** The following values may be passed as the second argument to + ** sqlite3OsLock(). The various locks exhibit the following semantics: ** - ** The same locking strategy and - ** byte ranges are used for Unix. This leaves open the possiblity of having - ** clients on win95, winNT, and unix all talking to the same shared file - ** and all locking correctly. To do so would require that samba (or whatever - ** tool is being used for file sharing) implements locks correctly between - ** windows and unix. I'm guessing that isn't likely to happen, but by - ** using the same locking range we are at least open to the possibility. - ** - ** Locking in windows is manditory. For this reason, we cannot store - ** actual data in the bytes used for locking. The pager never allocates - ** the pages involved in locking therefore. SHARED_SIZE is selected so - ** that all locks will fit on a single page even at the minimum page size. - ** PENDING_BYTE defines the beginning of the locks. By default PENDING_BYTE - ** is set high so that we don't have to allocate an unused page except - ** for very large databases. But one should test the page skipping logic - ** by setting PENDING_BYTE low and running the entire regression suite. - ** - ** Changing the value of PENDING_BYTE results in a subtly incompatible - ** file format. Depending on how it is changed, you might not notice - ** the incompatibility right away, even running a full regression test. - ** The default location of PENDING_BYTE is the first byte past the - ** 1GB boundary. + ** SHARED: Any number of processes may hold a SHARED lock simultaneously. + ** RESERVED: A single process may hold a RESERVED lock on a file at + ** any time. Other processes may hold and obtain new SHARED locks. + ** PENDING: A single process may hold a PENDING lock on a file at + ** any one time. Existing SHARED locks may persist, but no new + ** SHARED locks may be obtained by other processes. + ** EXCLUSIVE: An EXCLUSIVE lock precludes all other locks. ** + ** PENDING_LOCK may not be passed directly to sqlite3OsLock(). Instead, a + ** process that requests an EXCLUSIVE lock may actually obtain a PENDING + ** lock. This can be upgraded to an EXCLUSIVE lock by a subsequent call to + ** sqlite3OsLock(). */ + const int NO_LOCK = 0; + const int SHARED_LOCK = 1; + const int RESERVED_LOCK = 2; + const int PENDING_LOCK = 3; + const int EXCLUSIVE_LOCK = 4; + + /* + ** File Locking Notes: (Mostly about windows but also some info for Unix) + ** + ** We cannot use LockFileEx() or UnlockFileEx() on Win95/98/ME because + ** those functions are not available. So we use only LockFile() and + ** UnlockFile(). + ** + ** LockFile() prevents not just writing but also reading by other processes. + ** A SHARED_LOCK is obtained by locking a single randomly-chosen + ** byte out of a specific range of bytes. The lock byte is obtained at + ** random so two separate readers can probably access the file at the + ** same time, unless they are unlucky and choose the same lock byte. + ** An EXCLUSIVE_LOCK is obtained by locking all bytes in the range. + ** There can only be one writer. A RESERVED_LOCK is obtained by locking + ** a single byte of the file that is designated as the reserved lock byte. + ** A PENDING_LOCK is obtained by locking a designated byte different from + ** the RESERVED_LOCK byte. + ** + ** On WinNT/2K/XP systems, LockFileEx() and UnlockFileEx() are available, + ** which means we can use reader/writer locks. When reader/writer locks + ** are used, the lock is placed on the same range of bytes that is used + ** for probabilistic locking in Win95/98/ME. Hence, the locking scheme + ** will support two or more Win95 readers or two or more WinNT readers. + ** But a single Win95 reader will lock out all WinNT readers and a single + ** WinNT reader will lock out all other Win95 readers. + ** + ** The following #defines specify the range of bytes used for locking. + ** SHARED_SIZE is the number of bytes available in the pool from which + ** a random byte is selected for a shared lock. The pool of bytes for + ** shared locks begins at SHARED_FIRST. + ** + ** The same locking strategy and + ** byte ranges are used for Unix. This leaves open the possiblity of having + ** clients on win95, winNT, and unix all talking to the same shared file + ** and all locking correctly. To do so would require that samba (or whatever + ** tool is being used for file sharing) implements locks correctly between + ** windows and unix. I'm guessing that isn't likely to happen, but by + ** using the same locking range we are at least open to the possibility. + ** + ** Locking in windows is manditory. For this reason, we cannot store + ** actual data in the bytes used for locking. The pager never allocates + ** the pages involved in locking therefore. SHARED_SIZE is selected so + ** that all locks will fit on a single page even at the minimum page size. + ** PENDING_BYTE defines the beginning of the locks. By default PENDING_BYTE + ** is set high so that we don't have to allocate an unused page except + ** for very large databases. But one should test the page skipping logic + ** by setting PENDING_BYTE low and running the entire regression suite. + ** + ** Changing the value of PENDING_BYTE results in a subtly incompatible + ** file format. Depending on how it is changed, you might not notice + ** the incompatibility right away, even running a full regression test. + ** The default location of PENDING_BYTE is the first byte past the + ** 1GB boundary. + ** + */ #if SQLITE_OMIT_WSD //# define PENDING_BYTE (0x40000000) static int PENDING_BYTE = 0x40000000; #else - //# define PENDING_BYTE sqlite3PendingByte - static int PENDING_BYTE = 0x40000000; + //# define PENDING_BYTE sqlite3PendingByte + static int PENDING_BYTE = 0x40000000; #endif - static int RESERVED_BYTE = ( PENDING_BYTE + 1 ); - static int SHARED_FIRST = ( PENDING_BYTE + 2 ); - static int SHARED_SIZE = 510; + static int RESERVED_BYTE = (PENDING_BYTE + 1); + static int SHARED_FIRST = (PENDING_BYTE + 2); + static int SHARED_SIZE = 510; - /* - ** Wrapper around OS specific sqlite3_os_init() function. - */ - //int sqlite3OsInit(void); + /* + ** Wrapper around OS specific sqlite3_os_init() function. + */ + //int sqlite3OsInit(void); - /* - ** Functions for accessing sqlite3_file methods - */ - //int sqlite3OsClose(sqlite3_file); - //int sqlite3OsRead(sqlite3_file*, void*, int amt, i64 offset); - //int sqlite3OsWrite(sqlite3_file*, const void*, int amt, i64 offset); - //int sqlite3OsTruncate(sqlite3_file*, i64 size); - //int sqlite3OsSync(sqlite3_file*, int); - //int sqlite3OsFileSize(sqlite3_file*, i64 pSize); - //int sqlite3OsLock(sqlite3_file*, int); - //int sqlite3OsUnlock(sqlite3_file*, int); - //int sqlite3OsCheckReservedLock(sqlite3_file *id, int pResOut); - //int sqlite3OsFileControl(sqlite3_file*,int,void); - //#define SQLITE_FCNTL_DB_UNCHANGED 0xca093fa0 - const u32 SQLITE_FCNTL_DB_UNCHANGED = 0xca093fa0; + /* + ** Functions for accessing sqlite3_file methods + */ + //int sqlite3OsClose(sqlite3_file); + //int sqlite3OsRead(sqlite3_file*, void*, int amt, i64 offset); + //int sqlite3OsWrite(sqlite3_file*, const void*, int amt, i64 offset); + //int sqlite3OsTruncate(sqlite3_file*, i64 size); + //int sqlite3OsSync(sqlite3_file*, int); + //int sqlite3OsFileSize(sqlite3_file*, i64 pSize); + //int sqlite3OsLock(sqlite3_file*, int); + //int sqlite3OsUnlock(sqlite3_file*, int); + //int sqlite3OsCheckReservedLock(sqlite3_file *id, int pResOut); + //int sqlite3OsFileControl(sqlite3_file*,int,void); + //#define SQLITE_FCNTL_DB_UNCHANGED 0xca093fa0 + const u32 SQLITE_FCNTL_DB_UNCHANGED = 0xca093fa0; - //int sqlite3OsSectorSize(sqlite3_file *id); - //int sqlite3OsDeviceCharacteristics(sqlite3_file *id); - //int sqlite3OsShmMap(sqlite3_file *,int,int,int,object volatile *); - //int sqlite3OsShmLock(sqlite3_file *id, int, int, int); - //void sqlite3OsShmBarrier(sqlite3_file *id); - //int sqlite3OsShmUnmap(sqlite3_file *id, int); + //int sqlite3OsSectorSize(sqlite3_file *id); + //int sqlite3OsDeviceCharacteristics(sqlite3_file *id); + //int sqlite3OsShmMap(sqlite3_file *,int,int,int,object volatile *); + //int sqlite3OsShmLock(sqlite3_file *id, int, int, int); + //void sqlite3OsShmBarrier(sqlite3_file *id); + //int sqlite3OsShmUnmap(sqlite3_file *id, int); - /* - ** Functions for accessing sqlite3_vfs methods - */ - //int sqlite3OsOpen(sqlite3_vfs *, string , sqlite3_file*, int, int ); - //int sqlite3OsDelete(sqlite3_vfs *, string , int); - //int sqlite3OsAccess(sqlite3_vfs *, string , int, int pResOut); - //int sqlite3OsFullPathname(sqlite3_vfs *, string , int, char ); + /* + ** Functions for accessing sqlite3_vfs methods + */ + //int sqlite3OsOpen(sqlite3_vfs *, string , sqlite3_file*, int, int ); + //int sqlite3OsDelete(sqlite3_vfs *, string , int); + //int sqlite3OsAccess(sqlite3_vfs *, string , int, int pResOut); + //int sqlite3OsFullPathname(sqlite3_vfs *, string , int, char ); #if !SQLITE_OMIT_LOAD_EXTENSION - //void *sqlite3OsDlOpen(sqlite3_vfs *, string ); - //void sqlite3OsDlError(sqlite3_vfs *, int, char ); - //void (*sqlite3OsDlSym(sqlite3_vfs *, object *, string ))(void); - //void sqlite3OsDlClose(sqlite3_vfs *, object ); + //void *sqlite3OsDlOpen(sqlite3_vfs *, string ); + //void sqlite3OsDlError(sqlite3_vfs *, int, char ); + //void (*sqlite3OsDlSym(sqlite3_vfs *, object *, string ))(void); + //void sqlite3OsDlClose(sqlite3_vfs *, object ); #endif - //int sqlite3OsRandomness(sqlite3_vfs *, int, char ); - //int sqlite3OsSleep(sqlite3_vfs *, int); - //int sqlite3OsCurrentTimeInt64(sqlite3_vfs *, sqlite3_int64); + //int sqlite3OsRandomness(sqlite3_vfs *, int, char ); + //int sqlite3OsSleep(sqlite3_vfs *, int); + //int sqlite3OsCurrentTimeInt64(sqlite3_vfs *, sqlite3_int64); - /* - ** Convenience functions for opening and closing files using - ** sqlite3Malloc() to obtain space for the file-handle structure. - */ - //int sqlite3OsOpenMalloc(sqlite3_vfs *, string , sqlite3_file **, int,int); - //int sqlite3OsCloseFree(sqlite3_file ); + /* + ** Convenience functions for opening and closing files using + ** sqlite3Malloc() to obtain space for the file-handle structure. + */ + //int sqlite3OsOpenMalloc(sqlite3_vfs *, string , sqlite3_file **, int,int); + //int sqlite3OsCloseFree(sqlite3_file ); #endif // * _SQLITE_OS_H_ */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/os_win_c.cs b/Src/IronPython.SQLite/c#sqlite/os_win_c.cs index 014b0a2da..2e691efd0 100644 --- a/Src/IronPython.SQLite/c#sqlite/os_win_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/os_win_c.cs @@ -4,9 +4,9 @@ using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; -using System.Runtime.Versioning; using System.Text; using System.Threading; + using DWORD = System.UInt64; using HANDLE = System.IntPtr; using i64 = System.Int64; @@ -21,103 +21,101 @@ #elif WINDOWS_PHONE || SQLITE_SILVERLIGHT using System.IO.IsolatedStorage; #endif -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 2004 May 22 - ** - ** 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. - ** - ****************************************************************************** +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2004 May 22 + ** + ** 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 contains code that is specific to windows. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" +#if SQLITE_OS_WIN // * This file is used for windows only */ + + /* + ** A Note About Memory Allocation: ** - ** This file contains code that is specific to windows. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library + ** This driver uses malloc()/free() directly rather than going through + ** the SQLite-wrappers sqlite3Malloc()/sqlite3DbFree(db,ref ). Those wrappers + ** are designed for use on embedded systems where memory is scarce and + ** malloc failures happen frequently. Win32 does not typically run on + ** embedded systems, and when it does the developers normally have bigger + ** problems to worry about than running out of memory. So there is not + ** a compelling need to use the wrappers. ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** But there is a good reason to not use the wrappers. If we use the + ** wrappers then we will get simulated malloc() failures within this + ** driver. And that causes all kinds of problems for our tests. We + ** could enhance SQLite to deal with simulated malloc failures within + ** the OS driver, but the code to deal with those failure would not + ** be exercised on Linux (which does not need to malloc() in the driver) + ** and so we would have difficulty writing coverage tests for that + ** code. Better to leave the code out, we think. ** - ************************************************************************* + ** The point of this discussion is as follows: When creating a new + ** OS layer for an embedded system, if you use this file as an example, + ** avoid the use of malloc()/free(). Those routines work ok on windows + ** desktops but not so well in embedded systems. */ - //#include "sqliteInt.h" -#if SQLITE_OS_WIN // * This file is used for windows only */ - - /* -** A Note About Memory Allocation: -** -** This driver uses malloc()/free() directly rather than going through -** the SQLite-wrappers sqlite3Malloc()/sqlite3DbFree(db,ref ). Those wrappers -** are designed for use on embedded systems where memory is scarce and -** malloc failures happen frequently. Win32 does not typically run on -** embedded systems, and when it does the developers normally have bigger -** problems to worry about than running out of memory. So there is not -** a compelling need to use the wrappers. -** -** But there is a good reason to not use the wrappers. If we use the -** wrappers then we will get simulated malloc() failures within this -** driver. And that causes all kinds of problems for our tests. We -** could enhance SQLite to deal with simulated malloc failures within -** the OS driver, but the code to deal with those failure would not -** be exercised on Linux (which does not need to malloc() in the driver) -** and so we would have difficulty writing coverage tests for that -** code. Better to leave the code out, we think. -** -** The point of this discussion is as follows: When creating a new -** OS layer for an embedded system, if you use this file as an example, -** avoid the use of malloc()/free(). Those routines work ok on windows -** desktops but not so well in embedded systems. -*/ - //#include + //#include #if __CYGWIN__ //# include #endif - /* -** Macros used to determine whether or not to use threads. -*/ + /* + ** Macros used to determine whether or not to use threads. + */ #if THREADSAFE //# define SQLITE_W32_THREADS 1 #endif - /* -** Include code that is common to all os_*.c files -*/ - //#include "os_common.h" - - /* - ** Some microsoft compilers lack this definition. + /* + ** Include code that is common to all os_*.c files */ + //#include "os_common.h" + + /* + ** Some microsoft compilers lack this definition. + */ #if !INVALID_FILE_ATTRIBUTES - //# define INVALID_FILE_ATTRIBUTES ((DWORD)-1) - const int INVALID_FILE_ATTRIBUTES = -1; + //# define INVALID_FILE_ATTRIBUTES ((DWORD)-1) + const int INVALID_FILE_ATTRIBUTES = -1; #endif - /* -** Determine if we are dealing with WindowsCE - which has a much -** reduced API. -*/ + /* + ** Determine if we are dealing with WindowsCE - which has a much + ** reduced API. + */ #if SQLITE_OS_WINCE //# define AreFileApisANSI() 1 //# define GetDiskFreeSpaceW() 0 #endif - /* Forward references */ - //typedef struct winShm winShm; /* A connection to shared-memory */ - //typedef struct winShmNode winShmNode; /* A region of shared-memory */ + /* Forward references */ + //typedef struct winShm winShm; /* A connection to shared-memory */ + //typedef struct winShmNode winShmNode; /* A region of shared-memory */ - /* - ** WinCE lacks native support for file locking so we have to fake it - ** with some code of our own. - */ + /* + ** WinCE lacks native support for file locking so we have to fake it + ** with some code of our own. + */ #if SQLITE_OS_WINCE typedef struct winceLock { int nReaders; /* Number of reader locks obtained */ @@ -127,33 +125,32 @@ typedef struct winceLock { } winceLock; #endif - private static LockingStrategy lockingStrategy = HelperMethods.IsRunningMediumTrust() ? new MediumTrustLockingStrategy() : new LockingStrategy(); + private static LockingStrategy lockingStrategy = HelperMethods.IsRunningMediumTrust() ? new MediumTrustLockingStrategy() : new LockingStrategy(); - /* - ** The winFile structure is a subclass of sqlite3_file* specific to the win32 - ** portability layer. - */ - //typedef struct sqlite3_file sqlite3_file; - public partial class sqlite3_file - { - public sqlite3_vfs pVfs; /* The VFS used to open this file */ + /* + ** The winFile structure is a subclass of sqlite3_file* specific to the win32 + ** portability layer. + */ + //typedef struct sqlite3_file sqlite3_file; + public partial class sqlite3_file { + public sqlite3_vfs pVfs; /* The VFS used to open this file */ #if SQLITE_WINRT public IRandomAccessStream fs; #else - public FileStream fs; /* Filestream access to this file*/ + public FileStream fs; /* Filestream access to this file*/ #endif - // public HANDLE h; /* Handle for accessing the file */ - public int locktype; /* Type of lock currently held on this file */ - public int sharedLockByte; /* Randomly chosen byte used as a shared lock */ - public DWORD lastErrno; /* The Windows errno from the last I/O error */ - public DWORD sectorSize; /* Sector size of the device file is on */ + // public HANDLE h; /* Handle for accessing the file */ + public int locktype; /* Type of lock currently held on this file */ + public int sharedLockByte; /* Randomly chosen byte used as a shared lock */ + public DWORD lastErrno; /* The Windows errno from the last I/O error */ + public DWORD sectorSize; /* Sector size of the device file is on */ #if !SQLITE_OMIT_WAL public winShm pShm; /* Instance of shared memory on this file */ #else - public object pShm; /* DUMMY Instance of shared memory on this file */ + public object pShm; /* DUMMY Instance of shared memory on this file */ #endif - public string zPath; /* Full pathname of this file */ - public int szChunk; /* Chunk size configured by FCNTL_CHUNK_SIZE */ + public string zPath; /* Full pathname of this file */ + public int szChunk; /* Chunk size configured by FCNTL_CHUNK_SIZE */ #if SQLITE_OS_WINCE Wstring zDeleteOnClose; /* Name of file to delete when closing */ HANDLE hMutex; /* Mutex used to control access to shared lock */ @@ -162,321 +159,317 @@ public partial class sqlite3_file winceLock *shared; /* Global shared lock memory for the file */ #endif - public void Clear() - { - pMethods = null; - fs = null; - locktype = 0; - sharedLockByte = 0; - lastErrno = 0; - sectorSize = 0; - } - }; + public void Clear() { + pMethods = null; + fs = null; + locktype = 0; + sharedLockByte = 0; + lastErrno = 0; + sectorSize = 0; + } + }; - /* - ** Forward prototypes. - */ - //static int getSectorSize( - // sqlite3_vfs *pVfs, - // string zRelative /* UTF-8 file name */ - //); + /* + ** Forward prototypes. + */ + //static int getSectorSize( + // sqlite3_vfs *pVfs, + // string zRelative /* UTF-8 file name */ + //); - /* - ** The following variable is (normally) set once and never changes - ** thereafter. It records whether the operating system is Win95 - ** or WinNT. - ** - ** 0: Operating system unknown. - ** 1: Operating system is Win95. - ** 2: Operating system is WinNT. - ** - ** In order to facilitate testing on a WinNT system, the test fixture - ** can manually set this value to 1 to emulate Win98 behavior. - */ + /* + ** The following variable is (normally) set once and never changes + ** thereafter. It records whether the operating system is Win95 + ** or WinNT. + ** + ** 0: Operating system unknown. + ** 1: Operating system is Win95. + ** 2: Operating system is WinNT. + ** + ** In order to facilitate testing on a WinNT system, the test fixture + ** can manually set this value to 1 to emulate Win98 behavior. + */ #if SQLITE_TEST int sqlite3_os_type = 0; #else -static int sqlite3_os_type = 0; + static int sqlite3_os_type = 0; #endif - /* -** Return true (non-zero) if we are running under WinNT, Win2K, WinXP, -** or WinCE. Return false (zero) for Win95, Win98, or WinME. -** -** Here is an interesting observation: Win95, Win98, and WinME lack -** the LockFileEx() API. But we can still statically link against that -** 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. -*/ + /* + ** Return true (non-zero) if we are running under WinNT, Win2K, WinXP, + ** or WinCE. Return false (zero) for Win95, Win98, or WinME. + ** + ** Here is an interesting observation: Win95, Win98, and WinME lack + ** the LockFileEx() API. But we can still statically link against that + ** 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. + */ #if SQLITE_OS_WINCE //# define isNT() (1) #elif SQLITE_WINRT static bool isNT() { return true; } #else - static bool isNT() - { - //if (sqlite3_os_type == 0) - //{ - // OSVERSIONINFO sInfo; - // sInfo.dwOSVersionInfoSize = sInfo.Length; - // GetVersionEx(&sInfo); - // sqlite3_os_type = sInfo.dwPlatformId == VER_PLATFORM_WIN32_NT ? 2 : 1; - //} - //return sqlite3_os_type == 2; - return Environment.OSVersion.Platform == PlatformID.Win32NT || Environment.OSVersion.Platform == PlatformID.Unix; - } + static bool isNT() { + //if (sqlite3_os_type == 0) + //{ + // OSVERSIONINFO sInfo; + // sInfo.dwOSVersionInfoSize = sInfo.Length; + // GetVersionEx(&sInfo); + // sqlite3_os_type = sInfo.dwPlatformId == VER_PLATFORM_WIN32_NT ? 2 : 1; + //} + //return sqlite3_os_type == 2; + return Environment.OSVersion.Platform == PlatformID.Win32NT || Environment.OSVersion.Platform == PlatformID.Unix; + } #endif // * SQLITE_OS_WINCE */ - /* -** Convert a UTF-8 string to microsoft unicode (UTF-16?). -** -** Space to hold the returned string is obtained from malloc. -*/ - //static WCHAR *utf8ToUnicode(string zFilename){ - // int nChar; - // Wstring zWideFilename; - - // nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0); - // zWideFilename = malloc( nChar*sizeof(zWideFilename[0]) ); - // if( zWideFilename==0 ){ - // return 0; - // } - // nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, zWideFilename, nChar); - // if( nChar==0 ){ - // free(zWideFilename); - // zWideFileName = ""; - // } - // return zWideFilename; - //} - - /* - ** Convert microsoft unicode to UTF-8. Space to hold the returned string is - ** obtained from malloc(). - */ - //static char *unicodeToUtf8(const Wstring zWideFilename){ - // int nByte; - // string zFilename; - - // nByte = WideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, 0, 0, 0, 0); - // zFilename = malloc( nByte ); - // if( zFilename==0 ){ - // return 0; - // } - // nByte = WideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, zFilename, nByte, - // 0, 0); - // if( nByte == 0 ){ - // free(zFilename); - // zFileName = ""; - // } - // return zFilename; - //} - - /* - ** Convert an ansi string to microsoft unicode, based on the - ** current codepage settings for file apis. + /* + ** Convert a UTF-8 string to microsoft unicode (UTF-16?). ** - ** Space to hold the returned string is obtained - ** from malloc. + ** Space to hold the returned string is obtained from malloc. */ - //static WCHAR *mbcsToUnicode(string zFilename){ - // int nByte; - // Wstring zMbcsFilename; - // int codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP; - - // nByte = MultiByteToWideChar(codepage, 0, zFilename, -1, NULL,0)*WCHAR.Length; - // zMbcsFilename = malloc( nByte*sizeof(zMbcsFilename[0]) ); - // if( zMbcsFilename==0 ){ - // return 0; - // } - // nByte = MultiByteToWideChar(codepage, 0, zFilename, -1, zMbcsFilename, nByte); - // if( nByte==0 ){ - // free(zMbcsFilename); - // zMbcsFileName = ""; - // } - // return zMbcsFilename; - //} + //static WCHAR *utf8ToUnicode(string zFilename){ + // int nChar; + // Wstring zWideFilename; + + // nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0); + // zWideFilename = malloc( nChar*sizeof(zWideFilename[0]) ); + // if( zWideFilename==0 ){ + // return 0; + // } + // nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, zWideFilename, nChar); + // if( nChar==0 ){ + // free(zWideFilename); + // zWideFileName = ""; + // } + // return zWideFilename; + //} - /* - ** Convert microsoft unicode to multibyte character string, based on the - ** user's Ansi codepage. - ** - ** Space to hold the returned string is obtained from - ** malloc(). - */ - //static char *unicodeToMbcs(const Wstring zWideFilename){ - // int nByte; - // string zFilename; - // int codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP; - - // nByte = WideCharToMultiByte(codepage, 0, zWideFilename, -1, 0, 0, 0, 0); - // zFilename = malloc( nByte ); - // if( zFilename==0 ){ - // return 0; - // } - // nByte = WideCharToMultiByte(codepage, 0, zWideFilename, -1, zFilename, nByte, - // 0, 0); - // if( nByte == 0 ){ - // free(zFilename); - // zFileName = ""; - // } - // return zFilename; - //} + /* + ** Convert microsoft unicode to UTF-8. Space to hold the returned string is + ** obtained from malloc(). + */ + //static char *unicodeToUtf8(const Wstring zWideFilename){ + // int nByte; + // string zFilename; + + // nByte = WideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, 0, 0, 0, 0); + // zFilename = malloc( nByte ); + // if( zFilename==0 ){ + // return 0; + // } + // nByte = WideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, zFilename, nByte, + // 0, 0); + // if( nByte == 0 ){ + // free(zFilename); + // zFileName = ""; + // } + // return zFilename; + //} - /* - ** Convert multibyte character string to UTF-8. Space to hold the - ** returned string is obtained from malloc(). - */ - //static char *sqlite3_win32_mbcs_to_utf8(string zFilename){ - // string zFilenameUtf8; - // Wstring zTmpWide; - - // zTmpWide = mbcsToUnicode(zFilename); - // if( zTmpWide==0 ){ - // return 0; - // } - // zFilenameUtf8 = unicodeToUtf8(zTmpWide); - // free(zTmpWide); - // return zFilenameUtf8; - //} + /* + ** Convert an ansi string to microsoft unicode, based on the + ** current codepage settings for file apis. + ** + ** Space to hold the returned string is obtained + ** from malloc. + */ + //static WCHAR *mbcsToUnicode(string zFilename){ + // int nByte; + // Wstring zMbcsFilename; + // int codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP; + + // nByte = MultiByteToWideChar(codepage, 0, zFilename, -1, NULL,0)*WCHAR.Length; + // zMbcsFilename = malloc( nByte*sizeof(zMbcsFilename[0]) ); + // if( zMbcsFilename==0 ){ + // return 0; + // } + // nByte = MultiByteToWideChar(codepage, 0, zFilename, -1, zMbcsFilename, nByte); + // if( nByte==0 ){ + // free(zMbcsFilename); + // zMbcsFileName = ""; + // } + // return zMbcsFilename; + //} - /* - ** Convert UTF-8 to multibyte character string. Space to hold the - ** returned string is obtained from malloc(). - */ - //char *sqlite3_win32_utf8_to_mbcs(string zFilename){ - // string zFilenameMbcs; - // Wstring zTmpWide; - - // zTmpWide = utf8ToUnicode(zFilename); - // if( zTmpWide==0 ){ - // return 0; - // } - // zFilenameMbcs = unicodeToMbcs(zTmpWide); - // free(zTmpWide); - // return zFilenameMbcs; - //} + /* + ** Convert microsoft unicode to multibyte character string, based on the + ** user's Ansi codepage. + ** + ** Space to hold the returned string is obtained from + ** malloc(). + */ + //static char *unicodeToMbcs(const Wstring zWideFilename){ + // int nByte; + // string zFilename; + // int codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP; + + // nByte = WideCharToMultiByte(codepage, 0, zWideFilename, -1, 0, 0, 0, 0); + // zFilename = malloc( nByte ); + // if( zFilename==0 ){ + // return 0; + // } + // nByte = WideCharToMultiByte(codepage, 0, zWideFilename, -1, zFilename, nByte, + // 0, 0); + // if( nByte == 0 ){ + // free(zFilename); + // zFileName = ""; + // } + // return zFilename; + //} -/* -** The return value of getLastErrorMsg -** is zero if the error message fits in the buffer, or non-zero -** otherwise (if the message was truncated). -*/ -static int getLastErrorMsg(int nBuf, ref string zBuf){ - /* FormatMessage returns 0 on failure. Otherwise it - ** returns the number of TCHARs written to the output - ** buffer, excluding the terminating null char. - */ - //DWORD error = GetLastError(); - //DWORD dwLen = 0; - //string zOut = ""; - - //if( isNT() ){ - //Wstring zTempWide = NULL; - //dwLen = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - // NULL, - // error, - // 0, - // (LPWSTR) &zTempWide, - // 0, - // 0); - zBuf = HelperMethods.GetLastError().ToString();//new Win32Exception( Marshal.GetLastWin32Error() ).Message; - - //if( dwLen > 0 ){ - // /* allocate a buffer and convert to UTF8 */ - // zOut = unicodeToUtf8(zTempWide); - // /* free the system buffer allocated by FormatMessage */ - // LocalFree(zTempWide); - //} -/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. -** Since the ASCII version of these Windows API do not exist for WINCE, -** it's important to not reference them for WINCE builds. -*/ -//#if !SQLITE_OS_WINCE //==0 -// }else{ -// string zTemp = null; -// dwLen = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, -// null, -// error, -// 0, -// ref zTemp, -// 0, -// 0); -// if( dwLen > 0 ){ -// /* allocate a buffer and convert to UTF8 */ -// zOut = sqlite3_win32_mbcs_to_utf8(zTemp); -// /* free the system buffer allocated by FormatMessage */ -// LocalFree(zTemp); -// } -//#endif -// } - //if( 0 == dwLen ){ - // sqlite3_snprintf(nBuf, zBuf, "OsError 0x%x (%u)", error, error); - //}else{ - // /* copy a maximum of nBuf chars to output buffer */ - // sqlite3_snprintf(nBuf, zBuf, "%s", zOut); - // /* free the UTF8 buffer */ - // free(zOut); - //} - return 0; -} + /* + ** Convert multibyte character string to UTF-8. Space to hold the + ** returned string is obtained from malloc(). + */ + //static char *sqlite3_win32_mbcs_to_utf8(string zFilename){ + // string zFilenameUtf8; + // Wstring zTmpWide; + + // zTmpWide = mbcsToUnicode(zFilename); + // if( zTmpWide==0 ){ + // return 0; + // } + // zFilenameUtf8 = unicodeToUtf8(zTmpWide); + // free(zTmpWide); + // return zFilenameUtf8; + //} -/* -** -** This function - winLogErrorAtLine() - is only ever called via the macro -** winLogError(). -** -** This routine is invoked after an error occurs in an OS function. -** It logs a message using sqlite3_log() containing the current value of -** error code and, if possible, the human-readable equivalent from -** FormatMessage. -** -** The first argument passed to the macro should be the error code that -** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN). -** The two subsequent arguments should be the name of the OS function that -** failed and the the associated file-system path, if any. -*/ -//#define winLogError(a,b,c) winLogErrorAtLine(a,b,c,__LINE__) -static int winLogError( int a, string b, string c ) -{ - StackTrace st = new StackTrace( new StackFrame( true ) ); - StackFrame sf = st.GetFrame( 0 ); - - return winLogErrorAtLine( a, b, c, sf.GetFileLineNumber() ); -} + /* + ** Convert UTF-8 to multibyte character string. Space to hold the + ** returned string is obtained from malloc(). + */ + //char *sqlite3_win32_utf8_to_mbcs(string zFilename){ + // string zFilenameMbcs; + // Wstring zTmpWide; + + // zTmpWide = utf8ToUnicode(zFilename); + // if( zTmpWide==0 ){ + // return 0; + // } + // zFilenameMbcs = unicodeToMbcs(zTmpWide); + // free(zTmpWide); + // return zFilenameMbcs; + //} -static int winLogErrorAtLine( - int errcode, /* SQLite error code */ - string zFunc, /* Name of OS function that failed */ - string zPath, /* File path associated with error */ - int iLine /* Source line number where error occurred */ -){ - string zMsg = null; /* Human readable error text */ - int i; /* Loop counter */ - DWORD iErrno;// = GetLastError(); /* Error code */ + /* + ** The return value of getLastErrorMsg + ** is zero if the error message fits in the buffer, or non-zero + ** otherwise (if the message was truncated). + */ + static int getLastErrorMsg(int nBuf, ref string zBuf) { + /* FormatMessage returns 0 on failure. Otherwise it + ** returns the number of TCHARs written to the output + ** buffer, excluding the terminating null char. + */ + //DWORD error = GetLastError(); + //DWORD dwLen = 0; + //string zOut = ""; + + //if( isNT() ){ + //Wstring zTempWide = NULL; + //dwLen = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + // NULL, + // error, + // 0, + // (LPWSTR) &zTempWide, + // 0, + // 0); + zBuf = HelperMethods.GetLastError().ToString();//new Win32Exception( Marshal.GetLastWin32Error() ).Message; + + //if( dwLen > 0 ){ + // /* allocate a buffer and convert to UTF8 */ + // zOut = unicodeToUtf8(zTempWide); + // /* free the system buffer allocated by FormatMessage */ + // LocalFree(zTempWide); + //} + /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. + ** Since the ASCII version of these Windows API do not exist for WINCE, + ** it's important to not reference them for WINCE builds. + */ + //#if !SQLITE_OS_WINCE //==0 + // }else{ + // string zTemp = null; + // dwLen = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + // null, + // error, + // 0, + // ref zTemp, + // 0, + // 0); + // if( dwLen > 0 ){ + // /* allocate a buffer and convert to UTF8 */ + // zOut = sqlite3_win32_mbcs_to_utf8(zTemp); + // /* free the system buffer allocated by FormatMessage */ + // LocalFree(zTemp); + // } + //#endif + // } + //if( 0 == dwLen ){ + // sqlite3_snprintf(nBuf, zBuf, "OsError 0x%x (%u)", error, error); + //}else{ + // /* copy a maximum of nBuf chars to output buffer */ + // sqlite3_snprintf(nBuf, zBuf, "%s", zOut); + // /* free the UTF8 buffer */ + // free(zOut); + //} + return 0; + } + + /* + ** + ** This function - winLogErrorAtLine() - is only ever called via the macro + ** winLogError(). + ** + ** This routine is invoked after an error occurs in an OS function. + ** It logs a message using sqlite3_log() containing the current value of + ** error code and, if possible, the human-readable equivalent from + ** FormatMessage. + ** + ** The first argument passed to the macro should be the error code that + ** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN). + ** The two subsequent arguments should be the name of the OS function that + ** failed and the the associated file-system path, if any. + */ + //#define winLogError(a,b,c) winLogErrorAtLine(a,b,c,__LINE__) + static int winLogError(int a, string b, string c) { + StackTrace st = new StackTrace(new StackFrame(true)); + StackFrame sf = st.GetFrame(0); + + return winLogErrorAtLine(a, b, c, sf.GetFileLineNumber()); + } + + static int winLogErrorAtLine( + int errcode, /* SQLite error code */ + string zFunc, /* Name of OS function that failed */ + string zPath, /* File path associated with error */ + int iLine /* Source line number where error occurred */ + ) { + string zMsg = null; /* Human readable error text */ + int i; /* Loop counter */ + DWORD iErrno;// = GetLastError(); /* Error code */ #if SQLITE_SILVERLIGHT || SQLITE_WINRT iErrno = (int)ERROR_NOT_SUPPORTED; #else - iErrno = (u32)HelperMethods.GetLastError(); + iErrno = (u32)HelperMethods.GetLastError(); #endif - //zMsg[0] = 0; - getLastErrorMsg( 500, ref zMsg ); - Debug.Assert( errcode != SQLITE_OK ); - if ( zPath == null ) - zPath = ""; - for ( i = 0; i < zMsg.Length && zMsg[i] != '\r' && zMsg[i] != '\n'; i++ ) - { - } - zMsg = zMsg.Substring( 0, i ); - sqlite3_log(errcode, - "os_win.c:%d: (%d) %s(%s) - %s", - iLine, iErrno, zFunc, zPath, zMsg - ); + //zMsg[0] = 0; + getLastErrorMsg(500, ref zMsg); + Debug.Assert(errcode != SQLITE_OK); + if (zPath == null) + zPath = ""; + for (i = 0; i < zMsg.Length && zMsg[i] != '\r' && zMsg[i] != '\n'; i++) { + } + zMsg = zMsg.Substring(0, i); + sqlite3_log(errcode, + "os_win.c:%d: (%d) %s(%s) - %s", + iLine, iErrno, zFunc, zPath, zMsg + ); - return errcode; -} + return errcode; + } #if SQLITE_OS_WINCE @@ -799,101 +792,95 @@ LPOVERLAPPED lpOverlapped *****************************************************************************/ #endif // * SQLITE_OS_WINCE */ - /***************************************************************************** -** The next group of routines implement the I/O methods specified -** by the sqlite3_io_methods object. -******************************************************************************/ + /***************************************************************************** + ** The next group of routines implement the I/O methods specified + ** by the sqlite3_io_methods object. + ******************************************************************************/ - /* - ** Some microsoft compilers lack this definition. - */ + /* + ** Some microsoft compilers lack this definition. + */ #if !INVALID_SET_FILE_POINTER - //# define INVALID_SET_FILE_POINTER ((DWORD)-1) - const int INVALID_SET_FILE_POINTER = -1; + //# define INVALID_SET_FILE_POINTER ((DWORD)-1) + const int INVALID_SET_FILE_POINTER = -1; #endif - /* -** Move the current position of the file handle passed as the first -** argument to offset iOffset within the file. If successful, return 0. -** Otherwise, set pFile->lastErrno and return non-zero. -*/ - static int seekWinFile( sqlite3_file id, sqlite3_int64 iOffset ) - { - //LONG upperBits; /* Most sig. 32 bits of new offset */ - //LONG lowerBits; /* Least sig. 32 bits of new offset */ - DWORD dwRet; /* Value returned by SetFilePointer() */ - sqlite3_file pFile = id; - - //upperBits = (LONG)((iOffset>>32) & 0x7fffffff); - //lowerBits = (LONG)(iOffset & 0xffffffff); - - /* API oddity: If successful, SetFilePointer() returns a dword - ** containing the lower 32-bits of the new file-offset. Or, if it fails, - ** it returns INVALID_SET_FILE_POINTER. However according to MSDN, - ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine - ** whether an error has actually occured, it is also necessary to call - ** GetLastError(). - */ - //dwRet = SetFilePointer(id, lowerBits, &upperBits, FILE_BEGIN); - //if( (dwRet==INVALID_SET_FILE_POINTER && GetLastError()!=NO_ERROR) ){ - // pFile->lastErrno = GetLastError(); - // winLogError(SQLITE_IOERR_SEEK, "seekWinFile", pFile->zPath); - try - { + /* + ** Move the current position of the file handle passed as the first + ** argument to offset iOffset within the file. If successful, return 0. + ** Otherwise, set pFile->lastErrno and return non-zero. + */ + static int seekWinFile(sqlite3_file id, sqlite3_int64 iOffset) { + //LONG upperBits; /* Most sig. 32 bits of new offset */ + //LONG lowerBits; /* Least sig. 32 bits of new offset */ + DWORD dwRet; /* Value returned by SetFilePointer() */ + sqlite3_file pFile = id; + + //upperBits = (LONG)((iOffset>>32) & 0x7fffffff); + //lowerBits = (LONG)(iOffset & 0xffffffff); + + /* API oddity: If successful, SetFilePointer() returns a dword + ** containing the lower 32-bits of the new file-offset. Or, if it fails, + ** it returns INVALID_SET_FILE_POINTER. However according to MSDN, + ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine + ** whether an error has actually occured, it is also necessary to call + ** GetLastError(). + */ + //dwRet = SetFilePointer(id, lowerBits, &upperBits, FILE_BEGIN); + //if( (dwRet==INVALID_SET_FILE_POINTER && GetLastError()!=NO_ERROR) ){ + // pFile->lastErrno = GetLastError(); + // winLogError(SQLITE_IOERR_SEEK, "seekWinFile", pFile->zPath); + try { #if SQLITE_WINRT id.fs.Seek( (ulong)iOffset ); // SetFilePointer(pFile.fs.Name, lowerBits, upperBits, FILE_BEGIN); #else - id.fs.Seek( iOffset, SeekOrigin.Begin ); // SetFilePointer(pFile.fs.Name, lowerBits, upperBits, FILE_BEGIN); + id.fs.Seek(iOffset, SeekOrigin.Begin); // SetFilePointer(pFile.fs.Name, lowerBits, upperBits, FILE_BEGIN); #endif - } - catch ( Exception e ) - { + } catch (Exception e) { #if SQLITE_SILVERLIGHT || SQLITE_WINRT pFile.lastErrno = 1; #else - pFile.lastErrno = (u32)HelperMethods.GetLastError(); + pFile.lastErrno = (u32)HelperMethods.GetLastError(); #endif - winLogError(SQLITE_IOERR_SEEK, "seekWinFile", pFile.zPath); - return 1; - } - - return 0; - } + winLogError(SQLITE_IOERR_SEEK, "seekWinFile", pFile.zPath); + return 1; + } - /* - ** Close a file. - ** - ** It is reported that an attempt to close a handle might sometimes - ** fail. This is a very unreasonable result, but windows is notorious - ** for being unreasonable so I do not doubt that it might happen. If - ** the close fails, we pause for 100 milliseconds and try again. As - ** many as MX_CLOSE_ATTEMPT attempts to close the handle are made before - ** giving up and returning an error. - */ - public static int MX_CLOSE_ATTEMPT = 3; - static int winClose( sqlite3_file id ) - { - bool rc; - int cnt = 0; - sqlite3_file pFile = (sqlite3_file)id; + return 0; + } - Debug.Assert( id != null ); - Debug.Assert( pFile.pShm == null ); + /* + ** Close a file. + ** + ** It is reported that an attempt to close a handle might sometimes + ** fail. This is a very unreasonable result, but windows is notorious + ** for being unreasonable so I do not doubt that it might happen. If + ** the close fails, we pause for 100 milliseconds and try again. As + ** many as MX_CLOSE_ATTEMPT attempts to close the handle are made before + ** giving up and returning an error. + */ + public static int MX_CLOSE_ATTEMPT = 3; + static int winClose(sqlite3_file id) { + bool rc; + int cnt = 0; + sqlite3_file pFile = (sqlite3_file)id; + + Debug.Assert(id != null); + Debug.Assert(pFile.pShm == null); #if SQLITE_DEBUG - OSTRACE( "CLOSE %d (%s)\n", pFile.fs.GetHashCode(), pFile.fs.Name ); + OSTRACE("CLOSE %d (%s)\n", pFile.fs.GetHashCode(), pFile.fs.Name); #endif - do - { + do { #if SQLITE_WINRT pFile.fs.Dispose(); #else - pFile.fs.Close(); + pFile.fs.Close(); #endif - rc = true; - // rc = CloseHandle(pFile.h); - /* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */ - // if (!rc && ++cnt < MX_CLOSE_ATTEMPT) Thread.Sleep(100); //, 1) ); - } while ( !rc && ++cnt < MX_CLOSE_ATTEMPT ); //, 1) ); + rc = true; + // rc = CloseHandle(pFile.h); + /* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */ + // if (!rc && ++cnt < MX_CLOSE_ATTEMPT) Thread.Sleep(100); //, 1) ); + } while (!rc && ++cnt < MX_CLOSE_ATTEMPT); //, 1) ); #if SQLITE_OS_WINCE //#define WINCE_DELETION_ATTEMPTS 3 winceDestroyLock(pFile); @@ -913,44 +900,41 @@ static int winClose( sqlite3_file id ) OSTRACE( "CLOSE %d %s\n", pFile.fs.GetHashCode(), rc ? "ok" : "failed" ); OpenCounter( -1 ); #endif - return rc ? SQLITE_OK : winLogError(SQLITE_IOERR_CLOSE, "winClose", pFile.zPath); - } - - - /* - ** Read data from a file into a buffer. Return SQLITE_OK if all - ** bytes were read successfully and SQLITE_IOERR if anything goes - ** wrong. - */ - static int winRead( - sqlite3_file id, /* File to read from */ - byte[] pBuf, /* Write content into this buffer */ - int amt, /* Number of bytes to read */ - sqlite3_int64 offset /* Begin reading at this offset */ - ) - { + return rc ? SQLITE_OK : winLogError(SQLITE_IOERR_CLOSE, "winClose", pFile.zPath); + } - long rc; - sqlite3_file pFile = id; - int nRead; /* Number of bytes actually read from file */ - Debug.Assert( id != null ); + /* + ** Read data from a file into a buffer. Return SQLITE_OK if all + ** bytes were read successfully and SQLITE_IOERR if anything goes + ** wrong. + */ + static int winRead( + sqlite3_file id, /* File to read from */ + byte[] pBuf, /* Write content into this buffer */ + int amt, /* Number of bytes to read */ + sqlite3_int64 offset /* Begin reading at this offset */ + ) { + + long rc; + sqlite3_file pFile = id; + int nRead; /* Number of bytes actually read from file */ + + Debug.Assert(id != null); #if SQLITE_TEST if ( SimulateIOError() ) return SQLITE_IOERR_READ; #endif #if SQLITE_DEBUG - OSTRACE( "READ %d lock=%d\n", pFile.fs.GetHashCode(), pFile.locktype ); + OSTRACE("READ %d lock=%d\n", pFile.fs.GetHashCode(), pFile.locktype); #endif - if ( !id.fs.CanRead ) - return SQLITE_IOERR_READ; - if ( seekWinFile( pFile, offset ) != 0 ) - { - return SQLITE_FULL; - } + if (!id.fs.CanRead) + return SQLITE_IOERR_READ; + if (seekWinFile(pFile, offset) != 0) { + return SQLITE_FULL; + } - try - { + try { #if SQLITE_WINRT using (IInputStream inputStream = id.fs.GetInputStreamAt((ulong)offset)) { @@ -959,43 +943,39 @@ sqlite3_int64 offset /* Begin reading at this offset */ nRead = (int)buffer.Length; } #else - nRead = id.fs.Read( pBuf, 0, amt ); // i if( null==ReadFile(pFile->h, pBuf, amt, &nRead, 0) ){ + nRead = id.fs.Read(pBuf, 0, amt); // i if( null==ReadFile(pFile->h, pBuf, amt, &nRead, 0) ){ #endif - } - catch ( Exception e ) - { + } catch (Exception e) { #if SQLITE_SILVERLIGHT || SQLITE_WINRT pFile.lastErrno = 1; #else - pFile.lastErrno = (u32)HelperMethods.GetLastError(); + pFile.lastErrno = (u32)HelperMethods.GetLastError(); #endif - return winLogError(SQLITE_IOERR_READ, "winRead", pFile.zPath); - } - if ( nRead < amt ) - { - /* Unread parts of the buffer must be zero-filled */ - Array.Clear( pBuf, (int)nRead, (int)( amt - nRead ) ); // memset(&((char)pBuf)[nRead], 0, amt-nRead); - return SQLITE_IOERR_SHORT_READ; - } - return SQLITE_OK; - } - - /* - ** Write data from a buffer into a file. Return SQLITE_OK on success - ** or some other error code on failure. - */ - static int winWrite( - sqlite3_file id, /* File to write into */ - byte[] pBuf, /* The bytes to be written */ - int amt, /* Number of bytes to write */ - sqlite3_int64 offset /* Offset into the file to begin writing at */ - ) - { - int rc; /* True if error has occured, else false */ - sqlite3_file pFile = id; /* File handle */ + return winLogError(SQLITE_IOERR_READ, "winRead", pFile.zPath); + } + if (nRead < amt) { + /* Unread parts of the buffer must be zero-filled */ + Array.Clear(pBuf, (int)nRead, (int)(amt - nRead)); // memset(&((char)pBuf)[nRead], 0, amt-nRead); + return SQLITE_IOERR_SHORT_READ; + } + return SQLITE_OK; + } - Debug.Assert( amt > 0 ); - Debug.Assert( pFile != null ); + /* + ** Write data from a buffer into a file. Return SQLITE_OK on success + ** or some other error code on failure. + */ + static int winWrite( + sqlite3_file id, /* File to write into */ + byte[] pBuf, /* The bytes to be written */ + int amt, /* Number of bytes to write */ + sqlite3_int64 offset /* Offset into the file to begin writing at */ + ) { + int rc; /* True if error has occured, else false */ + sqlite3_file pFile = id; /* File handle */ + + Debug.Assert(amt > 0); + Debug.Assert(pFile != null); #if SQLITE_TEST if ( SimulateIOError() ) @@ -1004,26 +984,25 @@ sqlite3_int64 offset /* Offset into the file to begin writing at */ return SQLITE_FULL; #endif #if SQLITE_DEBUG - OSTRACE( "WRITE %d lock=%d\n", id.fs.GetHashCode(), id.locktype ); -#endif - rc = seekWinFile( pFile, offset ); - //if( rc==0 ){ - // u8 *aRem = (u8 )pBuf; /* Data yet to be written */ - // int nRem = amt; /* Number of bytes yet to be written */ - // DWORD nWrite; /* Bytes written by each WriteFile() call */ - - // while( nRem>0 && WriteFile(pFile->h, aRem, nRem, &nWrite, 0) && nWrite>0 ){ - // aRem += nWrite; - // nRem -= nWrite; - // } + OSTRACE("WRITE %d lock=%d\n", id.fs.GetHashCode(), id.locktype); +#endif + rc = seekWinFile(pFile, offset); + //if( rc==0 ){ + // u8 *aRem = (u8 )pBuf; /* Data yet to be written */ + // int nRem = amt; /* Number of bytes yet to be written */ + // DWORD nWrite; /* Bytes written by each WriteFile() call */ + + // while( nRem>0 && WriteFile(pFile->h, aRem, nRem, &nWrite, 0) && nWrite>0 ){ + // aRem += nWrite; + // nRem -= nWrite; + // } #if SQLITE_WINRT ulong wrote = id.fs.Position; #else - long wrote = id.fs.Position; + long wrote = id.fs.Position; #endif - try - { - Debug.Assert( pBuf.Length >= amt ); + try { + Debug.Assert(pBuf.Length >= amt); #if SQLITE_WINRT using (IOutputStream outStream = id.fs.GetOutputStreamAt((ulong)offset)) { @@ -1032,50 +1011,43 @@ sqlite3_int64 offset /* Offset into the file to begin writing at */ wrote = (ulong)amt; } #else - id.fs.Write( pBuf, 0, amt ); - wrote = id.fs.Position - wrote; + id.fs.Write(pBuf, 0, amt); + wrote = id.fs.Position - wrote; #endif - rc = 1;// Success - } - catch ( IOException e ) - { - return SQLITE_READONLY; - } + rc = 1;// Success + } catch (IOException e) { + return SQLITE_READONLY; + } - if ( rc == 0 || amt > (int)wrote ) - { + if (rc == 0 || amt > (int)wrote) { #if SQLITE_SILVERLIGHT || SQLITE_WINRT id.lastErrno = 1; #else - id.lastErrno = (u32)HelperMethods.GetLastError(); + id.lastErrno = (u32)HelperMethods.GetLastError(); #endif - if (( id.lastErrno == ERROR_HANDLE_DISK_FULL ) - || ( id.lastErrno == ERROR_DISK_FULL )) - { - return SQLITE_FULL; - } - else - { - return winLogError(SQLITE_IOERR_WRITE, "winWrite", pFile.zPath); + if ((id.lastErrno == ERROR_HANDLE_DISK_FULL) + || (id.lastErrno == ERROR_DISK_FULL)) { + return SQLITE_FULL; + } else { + return winLogError(SQLITE_IOERR_WRITE, "winWrite", pFile.zPath); + } + } + return SQLITE_OK; } - } - return SQLITE_OK; - } - /* - ** Truncate an open file to a specified size - */ - static int winTruncate( sqlite3_file id, sqlite3_int64 nByte ) - { - sqlite3_file pFile = id; /* File handle object */ - int rc = SQLITE_OK; /* Return code for this function */ + /* + ** Truncate an open file to a specified size + */ + static int winTruncate(sqlite3_file id, sqlite3_int64 nByte) { + sqlite3_file pFile = id; /* File handle object */ + int rc = SQLITE_OK; /* Return code for this function */ - Debug.Assert( pFile != null ); + Debug.Assert(pFile != null); #if SQLITE_DEBUG #if WINDOWS_PHONE || SQLITE_SILVERLIGHT OSTRACE( "TRUNCATE %d %lld\n", id.fs.GetHashCode(), nByte ); #else - OSTRACE( "TRUNCATE %s %lld\n", id.fs.Name, nByte ); + OSTRACE("TRUNCATE %s %lld\n", id.fs.Name, nByte); #endif #endif #if SQLITE_TEST @@ -1085,47 +1057,43 @@ static int winTruncate( sqlite3_file id, sqlite3_int64 nByte ) return SQLITE_IOERR_TRUNCATE; #endif - /* If the user has configured a chunk-size for this file, truncate the -** file so that it consists of an integer number of chunks (i.e. the -** actual file size after the operation may be larger than the requested -** size). -*/ + /* If the user has configured a chunk-size for this file, truncate the + ** file so that it consists of an integer number of chunks (i.e. the + ** actual file size after the operation may be larger than the requested + ** size). + */ - if ( pFile.szChunk != 0 ) - { - nByte = ( ( nByte + pFile.szChunk - 1 ) / pFile.szChunk ) * pFile.szChunk; - } + if (pFile.szChunk != 0) { + nByte = ((nByte + pFile.szChunk - 1) / pFile.szChunk) * pFile.szChunk; + } - /* SetEndOfFile() returns non-zero when successful, or zero when it fails. */ - //if ( seekWinFile( pFile, nByte ) ) - //{ - // rc = winLogError(SQLITE_IOERR_TRUNCATE, "winTruncate1", pFile->zPath); - //} - //else if( 0==SetEndOfFile(pFile->h) ){ - // pFile->lastErrno = GetLastError(); - // rc = winLogError(SQLITE_IOERR_TRUNCATE, "winTruncate2", pFile->zPath); - //} - try - { + /* SetEndOfFile() returns non-zero when successful, or zero when it fails. */ + //if ( seekWinFile( pFile, nByte ) ) + //{ + // rc = winLogError(SQLITE_IOERR_TRUNCATE, "winTruncate1", pFile->zPath); + //} + //else if( 0==SetEndOfFile(pFile->h) ){ + // pFile->lastErrno = GetLastError(); + // rc = winLogError(SQLITE_IOERR_TRUNCATE, "winTruncate2", pFile->zPath); + //} + try { #if SQLITE_WINRT id.fs.Size = (ulong)nByte; #else - id.fs.SetLength( nByte ); + id.fs.SetLength(nByte); #endif - rc = SQLITE_OK; - } - catch ( IOException e ) - { + rc = SQLITE_OK; + } catch (IOException e) { #if SQLITE_SILVERLIGHT || SQLITE_WINRT id.lastErrno = 1; #else - id.lastErrno = (u32)HelperMethods.GetLastError(); + id.lastErrno = (u32)HelperMethods.GetLastError(); #endif - rc = winLogError(SQLITE_IOERR_TRUNCATE, "winTruncate2", pFile.zPath); - } - OSTRACE( "TRUNCATE %d %lld %s\n", id.fs.GetHashCode(), nByte, rc == SQLITE_OK ? "ok" : "failed" ); - return rc; - } + rc = winLogError(SQLITE_IOERR_TRUNCATE, "winTruncate2", pFile.zPath); + } + OSTRACE("TRUNCATE %d %lld %s\n", id.fs.GetHashCode(), nByte, rc == SQLITE_OK ? "ok" : "failed"); + return rc; + } #if SQLITE_TEST /* @@ -1141,34 +1109,33 @@ static int winTruncate( sqlite3_file id, sqlite3_int64 nByte ) #endif #endif - /* -** Make sure all writes to a particular file are committed to disk. -*/ - static int winSync( sqlite3_file id, int flags ) - { + /* + ** Make sure all writes to a particular file are committed to disk. + */ + static int winSync(sqlite3_file id, int flags) { #if !(NDEBUG) || !(SQLITE_NO_SYNC) || (SQLITE_DEBUG) - sqlite3_file pFile = (sqlite3_file)id; - bool rc; + sqlite3_file pFile = (sqlite3_file)id; + bool rc; #else UNUSED_PARAMETER(id); #endif - Debug.Assert( pFile != null ); - /* Check that one of SQLITE_SYNC_NORMAL or FULL was passed */ - Debug.Assert( ( flags & 0x0F ) == SQLITE_SYNC_NORMAL - || ( flags & 0x0F ) == SQLITE_SYNC_FULL - ); + Debug.Assert(pFile != null); + /* Check that one of SQLITE_SYNC_NORMAL or FULL was passed */ + Debug.Assert((flags & 0x0F) == SQLITE_SYNC_NORMAL + || (flags & 0x0F) == SQLITE_SYNC_FULL + ); - OSTRACE( "SYNC %d lock=%d\n", pFile.fs.GetHashCode(), pFile.locktype ); + OSTRACE("SYNC %d lock=%d\n", pFile.fs.GetHashCode(), pFile.locktype); - /* Unix cannot, but some systems may return SQLITE_FULL from here. This - ** line is to test that doing so does not cause any problems. - */ + /* Unix cannot, but some systems may return SQLITE_FULL from here. This + ** line is to test that doing so does not cause any problems. + */ #if SQLITE_TEST if ( SimulateDiskfullError() ) return SQLITE_FULL; #endif #if !SQLITE_TEST -UNUSED_PARAMETER(flags); + UNUSED_PARAMETER(flags); #else if ( (flags&0x0F)==SQLITE_SYNC_FULL ) { @@ -1184,9 +1151,9 @@ static int winSync( sqlite3_file id, int flags ) #endif - /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a -** no-op -*/ + /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a + ** no-op + */ #if SQLITE_NO_SYNC return SQLITE_OK; #else @@ -1194,511 +1161,444 @@ static int winSync( sqlite3_file id, int flags ) Stream stream = pFile.fs.AsStreamForWrite(); stream.Flush(); #else - pFile.fs.Flush(); + pFile.fs.Flush(); #endif - return SQLITE_OK; - //rc = FlushFileBuffers(pFile->h); - //SimulateIOError( rc=FALSE ); - //if( rc ){ - // return SQLITE_OK; - //}else{ - // pFile->lastErrno = GetLastError(); - // return winLogError(SQLITE_IOERR_FSYNC, "winSync", pFile->zPath); - //} + return SQLITE_OK; + //rc = FlushFileBuffers(pFile->h); + //SimulateIOError( rc=FALSE ); + //if( rc ){ + // return SQLITE_OK; + //}else{ + // pFile->lastErrno = GetLastError(); + // return winLogError(SQLITE_IOERR_FSYNC, "winSync", pFile->zPath); + //} #endif - } + } - /* - ** Determine the current size of a file in bytes - */ - static int winFileSize( sqlite3_file id, ref long pSize ) - { - //DWORD upperBits; - //DWORD lowerBits; - // sqlite3_file pFile = (sqlite3_file)id; - // DWORD error; - Debug.Assert( id != null ); + /* + ** Determine the current size of a file in bytes + */ + static int winFileSize(sqlite3_file id, ref long pSize) { + //DWORD upperBits; + //DWORD lowerBits; + // sqlite3_file pFile = (sqlite3_file)id; + // DWORD error; + Debug.Assert(id != null); #if SQLITE_TEST if ( SimulateIOError() ) return SQLITE_IOERR_FSTAT; #endif - //lowerBits = GetFileSize(pFile.fs.Name, upperBits); - //if ( ( lowerBits == INVALID_FILE_SIZE ) - // && ( ( error = GetLastError() ) != NO_ERROR ) ) - //{ - // pFile.lastErrno = error; - // return winLogError(SQLITE_IOERR_FSTAT, "winFileSize", pFile->zPath); - //} - //pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits; + //lowerBits = GetFileSize(pFile.fs.Name, upperBits); + //if ( ( lowerBits == INVALID_FILE_SIZE ) + // && ( ( error = GetLastError() ) != NO_ERROR ) ) + //{ + // pFile.lastErrno = error; + // return winLogError(SQLITE_IOERR_FSTAT, "winFileSize", pFile->zPath); + //} + //pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits; #if SQLITE_WINRT pSize = id.fs.CanRead ? (long)id.fs.Size : 0; #else - pSize = id.fs.CanRead ? id.fs.Length : 0; + pSize = id.fs.CanRead ? id.fs.Length : 0; #endif - return SQLITE_OK; - } + return SQLITE_OK; + } - /* - ** Acquire a reader lock. - ** Different API routines are called depending on whether or not this - ** is Win95 or WinNT. - */ - static int getReadLock( sqlite3_file pFile ) - { - int res = 0; - if ( isNT() ) - { - res = lockingStrategy.SharedLockFile( pFile, SHARED_FIRST, SHARED_SIZE ); - } - /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. - */ + /* + ** Acquire a reader lock. + ** Different API routines are called depending on whether or not this + ** is Win95 or WinNT. + */ + static int getReadLock(sqlite3_file pFile) { + int res = 0; + if (isNT()) { + res = lockingStrategy.SharedLockFile(pFile, SHARED_FIRST, SHARED_SIZE); + } + /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. + */ #if !SQLITE_OS_WINCE - //else - //{ - // int lk; - // sqlite3_randomness(lk.Length, lk); - // pFile.sharedLockByte = (u16)((lk & 0x7fffffff)%(SHARED_SIZE - 1)); - // res = pFile.fs.Lock( SHARED_FIRST + pFile.sharedLockByte, 0, 1, 0); -#endif - //} - if (res == 0) { - pFile.lastErrno = (u32)HelperMethods.GetLastError(); + //else + //{ + // int lk; + // sqlite3_randomness(lk.Length, lk); + // pFile.sharedLockByte = (u16)((lk & 0x7fffffff)%(SHARED_SIZE - 1)); + // res = pFile.fs.Lock( SHARED_FIRST + pFile.sharedLockByte, 0, 1, 0); +#endif + //} + if (res == 0) { + pFile.lastErrno = (u32)HelperMethods.GetLastError(); + } + /* No need to log a failure to lock */ + return res; } - /* No need to log a failure to lock */ - return res; - } - /* - ** Undo a readlock - */ - static int unlockReadLock( sqlite3_file pFile ) - { - int res = 1; - if ( isNT() ) - { - try - { - lockingStrategy.UnlockFile( pFile, SHARED_FIRST, SHARED_SIZE ); // res = UnlockFile(pFile.h, SHARED_FIRST, 0, SHARED_SIZE, 0); - } - catch ( Exception e ) - { - res = 0; - } - } - /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. - */ + /* + ** Undo a readlock + */ + static int unlockReadLock(sqlite3_file pFile) { + int res = 1; + if (isNT()) { + try { + lockingStrategy.UnlockFile(pFile, SHARED_FIRST, SHARED_SIZE); // res = UnlockFile(pFile.h, SHARED_FIRST, 0, SHARED_SIZE, 0); + } catch (Exception e) { + res = 0; + } + } + /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. + */ #if !SQLITE_OS_WINCE - else - { - Debugger.Break(); // res = UnlockFile(pFile.h, SHARED_FIRST + pFilE.sharedLockByte, 0, 1, 0); - } + else { + Debugger.Break(); // res = UnlockFile(pFile.h, SHARED_FIRST + pFilE.sharedLockByte, 0, 1, 0); + } #endif - if (res == 0) { - pFile.lastErrno = (u32)HelperMethods.GetLastError(); + if (res == 0) { + pFile.lastErrno = (u32)HelperMethods.GetLastError(); - winLogError(SQLITE_IOERR_UNLOCK, "unlockReadLock", pFile.zPath); - } + winLogError(SQLITE_IOERR_UNLOCK, "unlockReadLock", pFile.zPath); + } - return res; - } + return res; + } - /* - ** Lock the file with the lock specified by parameter locktype - one - ** of the following: - ** - ** (1) SHARED_LOCK - ** (2) RESERVED_LOCK - ** (3) PENDING_LOCK - ** (4) EXCLUSIVE_LOCK - ** - ** Sometimes when requesting one lock state, additional lock states - ** are inserted in between. The locking might fail on one of the later - ** transitions leaving the lock state different from what it started but - ** still short of its goal. The following chart shows the allowed - ** transitions and the inserted intermediate states: - ** - ** UNLOCKED . SHARED - ** SHARED . RESERVED - ** SHARED . (PENDING) . EXCLUSIVE - ** RESERVED . (PENDING) . EXCLUSIVE - ** PENDING . EXCLUSIVE - ** - ** This routine will only increase a lock. The winUnlock() routine - ** erases all locks at once and returns us immediately to locking level 0. - ** It is not possible to lower the locking level one step at a time. You - ** must go straight to locking level 0. - */ - static int winLock( sqlite3_file id, int locktype ) - { - int rc = SQLITE_OK; /* Return code from subroutines */ - int res = 1; /* Result of a windows lock call */ - int newLocktype; /* Set pFile.locktype to this value before exiting */ - bool gotPendingLock = false;/* True if we acquired a PENDING lock this time */ - sqlite3_file pFile = (sqlite3_file)id; - DWORD error = NO_ERROR; - - Debug.Assert( id != null ); + /* + ** Lock the file with the lock specified by parameter locktype - one + ** of the following: + ** + ** (1) SHARED_LOCK + ** (2) RESERVED_LOCK + ** (3) PENDING_LOCK + ** (4) EXCLUSIVE_LOCK + ** + ** Sometimes when requesting one lock state, additional lock states + ** are inserted in between. The locking might fail on one of the later + ** transitions leaving the lock state different from what it started but + ** still short of its goal. The following chart shows the allowed + ** transitions and the inserted intermediate states: + ** + ** UNLOCKED . SHARED + ** SHARED . RESERVED + ** SHARED . (PENDING) . EXCLUSIVE + ** RESERVED . (PENDING) . EXCLUSIVE + ** PENDING . EXCLUSIVE + ** + ** This routine will only increase a lock. The winUnlock() routine + ** erases all locks at once and returns us immediately to locking level 0. + ** It is not possible to lower the locking level one step at a time. You + ** must go straight to locking level 0. + */ + static int winLock(sqlite3_file id, int locktype) { + int rc = SQLITE_OK; /* Return code from subroutines */ + int res = 1; /* Result of a windows lock call */ + int newLocktype; /* Set pFile.locktype to this value before exiting */ + bool gotPendingLock = false;/* True if we acquired a PENDING lock this time */ + sqlite3_file pFile = (sqlite3_file)id; + DWORD error = NO_ERROR; + + Debug.Assert(id != null); #if SQLITE_DEBUG - OSTRACE( "LOCK %d %d was %d(%d)\n", - pFile.fs.GetHashCode(), locktype, pFile.locktype, pFile.sharedLockByte ); + OSTRACE("LOCK %d %d was %d(%d)\n", + pFile.fs.GetHashCode(), locktype, pFile.locktype, pFile.sharedLockByte); #endif - /* If there is already a lock of this type or more restrictive on the -** OsFile, do nothing. Don't use the end_lock: exit path, as -** sqlite3OsEnterMutex() hasn't been called yet. -*/ - if ( pFile.locktype >= locktype ) - { - return SQLITE_OK; - } - - /* Make sure the locking sequence is correct + /* If there is already a lock of this type or more restrictive on the + ** OsFile, do nothing. Don't use the end_lock: exit path, as + ** sqlite3OsEnterMutex() hasn't been called yet. */ - Debug.Assert( pFile.locktype != NO_LOCK || locktype == SHARED_LOCK ); - Debug.Assert( locktype != PENDING_LOCK ); - Debug.Assert( locktype != RESERVED_LOCK || pFile.locktype == SHARED_LOCK ); + if (pFile.locktype >= locktype) { + return SQLITE_OK; + } - /* Lock the PENDING_LOCK byte if we need to acquire a PENDING lock or - ** a SHARED lock. If we are acquiring a SHARED lock, the acquisition of - ** the PENDING_LOCK byte is temporary. - */ - newLocktype = pFile.locktype; - if ( pFile.locktype == NO_LOCK - || ( ( locktype == EXCLUSIVE_LOCK ) - && ( pFile.locktype == RESERVED_LOCK ) ) - ) - { - int cnt = 3; - res = 0; - while ( cnt-- > 0 && res == 0 )//(res = LockFile(pFile.fs.SafeFileHandle.DangerousGetHandle().ToInt32(), PENDING_BYTE, 0, 1, 0)) == 0) - { - try - { - lockingStrategy.LockFile( pFile, PENDING_BYTE, 1 ); - res = 1; - } - catch ( Exception e ) - { - /* Try 3 times to get the pending lock. The pending lock might be - ** held by another reader process who will release it momentarily. + /* Make sure the locking sequence is correct + */ + Debug.Assert(pFile.locktype != NO_LOCK || locktype == SHARED_LOCK); + Debug.Assert(locktype != PENDING_LOCK); + Debug.Assert(locktype != RESERVED_LOCK || pFile.locktype == SHARED_LOCK); + + /* Lock the PENDING_LOCK byte if we need to acquire a PENDING lock or + ** a SHARED lock. If we are acquiring a SHARED lock, the acquisition of + ** the PENDING_LOCK byte is temporary. */ + newLocktype = pFile.locktype; + if (pFile.locktype == NO_LOCK + || ((locktype == EXCLUSIVE_LOCK) + && (pFile.locktype == RESERVED_LOCK)) + ) { + int cnt = 3; + res = 0; + while (cnt-- > 0 && res == 0)//(res = LockFile(pFile.fs.SafeFileHandle.DangerousGetHandle().ToInt32(), PENDING_BYTE, 0, 1, 0)) == 0) + { + try { + lockingStrategy.LockFile(pFile, PENDING_BYTE, 1); + res = 1; + } catch (Exception e) { + /* Try 3 times to get the pending lock. The pending lock might be + ** held by another reader process who will release it momentarily. + */ #if SQLITE_DEBUG - OSTRACE( "could not get a PENDING lock. cnt=%d\n", cnt ); + OSTRACE("could not get a PENDING lock. cnt=%d\n", cnt); #endif #if SQLITE_WINRT System.Threading.Tasks.Task.Delay(1).Wait(); #else - Thread.Sleep( 1 ); + Thread.Sleep(1); #endif - } - } - gotPendingLock = ( res != 0 ); - if ( 0 == res ) - { + } + } + gotPendingLock = (res != 0); + if (0 == res) { #if SQLITE_SILVERLIGHT || SQLITE_WINRT error = 1; #else - error = (u32)HelperMethods.GetLastError(); + error = (u32)HelperMethods.GetLastError(); #endif - } - } + } + } - /* Acquire a shared lock - */ - if ( locktype == SHARED_LOCK && res != 0 ) - { - Debug.Assert( pFile.locktype == NO_LOCK ); - res = getReadLock( pFile ); - if ( res != 0 ) - { - newLocktype = SHARED_LOCK; - } - else - { + /* Acquire a shared lock + */ + if (locktype == SHARED_LOCK && res != 0) { + Debug.Assert(pFile.locktype == NO_LOCK); + res = getReadLock(pFile); + if (res != 0) { + newLocktype = SHARED_LOCK; + } else { #if SQLITE_SILVERLIGHT || SQLITE_WINRT error = 1; #else - error = (u32)HelperMethods.GetLastError(); + error = (u32)HelperMethods.GetLastError(); #endif - } - } + } + } - /* Acquire a RESERVED lock - */ - if ( ( locktype == RESERVED_LOCK ) && res != 0 ) - { - Debug.Assert( pFile.locktype == SHARED_LOCK ); - try - { - lockingStrategy.LockFile( pFile, RESERVED_BYTE, 1 );//res = LockFile(pFile.fs.SafeFileHandle.DangerousGetHandle().ToInt32(), RESERVED_BYTE, 0, 1, 0); - newLocktype = RESERVED_LOCK; - res = 1; - } - catch ( Exception e ) - { - res = 0; + /* Acquire a RESERVED lock + */ + if ((locktype == RESERVED_LOCK) && res != 0) { + Debug.Assert(pFile.locktype == SHARED_LOCK); + try { + lockingStrategy.LockFile(pFile, RESERVED_BYTE, 1);//res = LockFile(pFile.fs.SafeFileHandle.DangerousGetHandle().ToInt32(), RESERVED_BYTE, 0, 1, 0); + newLocktype = RESERVED_LOCK; + res = 1; + } catch (Exception e) { + res = 0; #if SQLITE_SILVERLIGHT || SQLITE_WINRT error = 1; #else - error = (u32)HelperMethods.GetLastError(); + error = (u32)HelperMethods.GetLastError(); #endif - } - if ( res != 0 ) - { - newLocktype = RESERVED_LOCK; - } - else - { + } + if (res != 0) { + newLocktype = RESERVED_LOCK; + } else { #if SQLITE_SILVERLIGHT error = 1; #else - error = (u32)HelperMethods.GetLastError(); + error = (u32)HelperMethods.GetLastError(); #endif - } - } + } + } - /* Acquire a PENDING lock - */ - if ( locktype == EXCLUSIVE_LOCK && res != 0 ) - { - newLocktype = PENDING_LOCK; - gotPendingLock = false; - } + /* Acquire a PENDING lock + */ + if (locktype == EXCLUSIVE_LOCK && res != 0) { + newLocktype = PENDING_LOCK; + gotPendingLock = false; + } - /* Acquire an EXCLUSIVE lock - */ - if ( locktype == EXCLUSIVE_LOCK && res != 0 ) - { - Debug.Assert( pFile.locktype >= SHARED_LOCK ); - res = unlockReadLock( pFile ); + /* Acquire an EXCLUSIVE lock + */ + if (locktype == EXCLUSIVE_LOCK && res != 0) { + Debug.Assert(pFile.locktype >= SHARED_LOCK); + res = unlockReadLock(pFile); #if SQLITE_DEBUG - OSTRACE( "unreadlock = %d\n", res ); -#endif - //res = LockFile(pFile.fs.SafeFileHandle.DangerousGetHandle().ToInt32(), SHARED_FIRST, 0, SHARED_SIZE, 0); - try - { - lockingStrategy.LockFile( pFile, SHARED_FIRST, SHARED_SIZE ); - newLocktype = EXCLUSIVE_LOCK; - res = 1; - } - catch ( Exception e ) - { - res = 0; - } - if ( res != 0 ) - { - newLocktype = EXCLUSIVE_LOCK; - } - else - { + OSTRACE("unreadlock = %d\n", res); +#endif + //res = LockFile(pFile.fs.SafeFileHandle.DangerousGetHandle().ToInt32(), SHARED_FIRST, 0, SHARED_SIZE, 0); + try { + lockingStrategy.LockFile(pFile, SHARED_FIRST, SHARED_SIZE); + newLocktype = EXCLUSIVE_LOCK; + res = 1; + } catch (Exception e) { + res = 0; + } + if (res != 0) { + newLocktype = EXCLUSIVE_LOCK; + } else { #if SQLITE_SILVERLIGHT || SQLITE_WINRT error = 1; #else - error = (u32)HelperMethods.GetLastError(); + error = (u32)HelperMethods.GetLastError(); #endif #if SQLITE_DEBUG - OSTRACE( "error-code = %d\n", error ); + OSTRACE("error-code = %d\n", error); #endif - getReadLock( pFile ); - } - } + getReadLock(pFile); + } + } - /* If we are holding a PENDING lock that ought to be released, then - ** release it now. - */ - if ( gotPendingLock && locktype == SHARED_LOCK ) - { - lockingStrategy.UnlockFile( pFile, PENDING_BYTE, 1 ); - } + /* If we are holding a PENDING lock that ought to be released, then + ** release it now. + */ + if (gotPendingLock && locktype == SHARED_LOCK) { + lockingStrategy.UnlockFile(pFile, PENDING_BYTE, 1); + } - /* Update the state of the lock has held in the file descriptor then - ** return the appropriate result code. - */ - if ( res != 0 ) - { - rc = SQLITE_OK; - } - else - { + /* Update the state of the lock has held in the file descriptor then + ** return the appropriate result code. + */ + if (res != 0) { + rc = SQLITE_OK; + } else { #if SQLITE_DEBUG - OSTRACE( "LOCK FAILED %d trying for %d but got %d\n", pFile.fs.GetHashCode(), - locktype, newLocktype ); + OSTRACE("LOCK FAILED %d trying for %d but got %d\n", pFile.fs.GetHashCode(), + locktype, newLocktype); #endif - pFile.lastErrno = error; - rc = SQLITE_BUSY; - } - pFile.locktype = (u8)newLocktype; - return rc; - } + pFile.lastErrno = error; + rc = SQLITE_BUSY; + } + pFile.locktype = (u8)newLocktype; + return rc; + } - /* - ** This routine checks if there is a RESERVED lock held on the specified - ** file by this or any other process. If such a lock is held, return - ** non-zero, otherwise zero. - */ - static int winCheckReservedLock( sqlite3_file id, ref int pResOut ) - { - int rc; - sqlite3_file pFile = (sqlite3_file)id; + /* + ** This routine checks if there is a RESERVED lock held on the specified + ** file by this or any other process. If such a lock is held, return + ** non-zero, otherwise zero. + */ + static int winCheckReservedLock(sqlite3_file id, ref int pResOut) { + int rc; + sqlite3_file pFile = (sqlite3_file)id; - if ( SimulateIOError() ) - return SQLITE_IOERR_CHECKRESERVEDLOCK; + if (SimulateIOError()) + return SQLITE_IOERR_CHECKRESERVEDLOCK; - Debug.Assert( id != null ); - if ( pFile.locktype >= RESERVED_LOCK ) - { - rc = 1; + Debug.Assert(id != null); + if (pFile.locktype >= RESERVED_LOCK) { + rc = 1; #if SQLITE_DEBUG - OSTRACE( "TEST WR-LOCK %s %d (local)\n", pFile.fs.Name, rc ); -#endif - } - else - { - try - { - lockingStrategy.LockFile( pFile, RESERVED_BYTE, 1 ); - lockingStrategy.UnlockFile( pFile, RESERVED_BYTE, 1 ); - rc = 1; - } - catch ( IOException e ) - { - rc = 0; - } - rc = 1 - rc; // !rc + OSTRACE("TEST WR-LOCK %s %d (local)\n", pFile.fs.Name, rc); +#endif + } else { + try { + lockingStrategy.LockFile(pFile, RESERVED_BYTE, 1); + lockingStrategy.UnlockFile(pFile, RESERVED_BYTE, 1); + rc = 1; + } catch (IOException e) { + rc = 0; + } + rc = 1 - rc; // !rc #if SQLITE_DEBUG - OSTRACE( "TEST WR-LOCK %d %d (remote)\n", pFile.fs.GetHashCode(), rc ); + OSTRACE("TEST WR-LOCK %d %d (remote)\n", pFile.fs.GetHashCode(), rc); #endif - } - pResOut = rc; - return SQLITE_OK; - } + } + pResOut = rc; + return SQLITE_OK; + } - /* - ** Lower the locking level on file descriptor id to locktype. locktype - ** must be either NO_LOCK or SHARED_LOCK. - ** - ** If the locking level of the file descriptor is already at or below - ** the requested locking level, this routine is a no-op. - ** - ** It is not possible for this routine to fail if the second argument - ** is NO_LOCK. If the second argument is SHARED_LOCK then this routine - ** might return SQLITE_IOERR; - */ - static int winUnlock( sqlite3_file id, int locktype ) - { - int type; - sqlite3_file pFile = (sqlite3_file)id; - int rc = SQLITE_OK; - Debug.Assert( pFile != null ); - Debug.Assert( locktype <= SHARED_LOCK ); + /* + ** Lower the locking level on file descriptor id to locktype. locktype + ** must be either NO_LOCK or SHARED_LOCK. + ** + ** If the locking level of the file descriptor is already at or below + ** the requested locking level, this routine is a no-op. + ** + ** It is not possible for this routine to fail if the second argument + ** is NO_LOCK. If the second argument is SHARED_LOCK then this routine + ** might return SQLITE_IOERR; + */ + static int winUnlock(sqlite3_file id, int locktype) { + int type; + sqlite3_file pFile = (sqlite3_file)id; + int rc = SQLITE_OK; + Debug.Assert(pFile != null); + Debug.Assert(locktype <= SHARED_LOCK); #if SQLITE_DEBUG - OSTRACE( "UNLOCK %d to %d was %d(%d)\n", pFile.fs.GetHashCode(), locktype, - pFile.locktype, pFile.sharedLockByte ); -#endif - type = pFile.locktype; - if ( type >= EXCLUSIVE_LOCK ) - { - lockingStrategy.UnlockFile( pFile, SHARED_FIRST, SHARED_SIZE ); // UnlockFile(pFile.h, SHARED_FIRST, 0, SHARED_SIZE, 0); - if ( locktype == SHARED_LOCK && getReadLock( pFile ) == 0 ) - { - /* This should never happen. We should always be able to - ** reacquire the read lock */ - rc = winLogError(SQLITE_IOERR_UNLOCK, "winUnlock", pFile.zPath); - } - } - if ( type >= RESERVED_LOCK ) - { - try - { - lockingStrategy.UnlockFile( pFile, RESERVED_BYTE, 1 );// UnlockFile(pFile.h, RESERVED_BYTE, 0, 1, 0); - } - catch ( Exception e ) - { - } - } - if ( locktype == NO_LOCK && type >= SHARED_LOCK ) - { - unlockReadLock( pFile ); - } - if ( type >= PENDING_LOCK ) - { - try - { - lockingStrategy.UnlockFile( pFile, PENDING_BYTE, 1 );// UnlockFile(pFile.h, PENDING_BYTE, 0, 1, 0); - } - catch ( Exception e ) - { + OSTRACE("UNLOCK %d to %d was %d(%d)\n", pFile.fs.GetHashCode(), locktype, + pFile.locktype, pFile.sharedLockByte); +#endif + type = pFile.locktype; + if (type >= EXCLUSIVE_LOCK) { + lockingStrategy.UnlockFile(pFile, SHARED_FIRST, SHARED_SIZE); // UnlockFile(pFile.h, SHARED_FIRST, 0, SHARED_SIZE, 0); + if (locktype == SHARED_LOCK && getReadLock(pFile) == 0) { + /* This should never happen. We should always be able to + ** reacquire the read lock */ + rc = winLogError(SQLITE_IOERR_UNLOCK, "winUnlock", pFile.zPath); + } + } + if (type >= RESERVED_LOCK) { + try { + lockingStrategy.UnlockFile(pFile, RESERVED_BYTE, 1);// UnlockFile(pFile.h, RESERVED_BYTE, 0, 1, 0); + } catch (Exception e) { + } + } + if (locktype == NO_LOCK && type >= SHARED_LOCK) { + unlockReadLock(pFile); + } + if (type >= PENDING_LOCK) { + try { + lockingStrategy.UnlockFile(pFile, PENDING_BYTE, 1);// UnlockFile(pFile.h, PENDING_BYTE, 0, 1, 0); + } catch (Exception e) { + } + } + pFile.locktype = (u8)locktype; + return rc; } - } - pFile.locktype = (u8)locktype; - return rc; - } - /* - ** Control and query of the open file handle. - */ - static int winFileControl( sqlite3_file id, int op, ref sqlite3_int64 pArg ) - { - switch ( op ) - { - case SQLITE_FCNTL_LOCKSTATE: - { - pArg = (int)( (sqlite3_file)id ).locktype; - return SQLITE_OK; - } - case SQLITE_LAST_ERRNO: - { - pArg = (int)( (sqlite3_file)id ).lastErrno; - return SQLITE_OK; - } - case SQLITE_FCNTL_CHUNK_SIZE: - { - ( (sqlite3_file)id ).szChunk = (int)pArg; - return SQLITE_OK; - } - case SQLITE_FCNTL_SIZE_HINT: - { - sqlite3_int64 sz = (sqlite3_int64)pArg; - SimulateIOErrorBenign( 1 ); - winTruncate( id, sz ); - SimulateIOErrorBenign( 0 ); - return SQLITE_OK; - } - case SQLITE_FCNTL_SYNC_OMITTED: - { - return SQLITE_OK; - } - } - return SQLITE_NOTFOUND; - } + /* + ** Control and query of the open file handle. + */ + static int winFileControl(sqlite3_file id, int op, ref sqlite3_int64 pArg) { + switch (op) { + case SQLITE_FCNTL_LOCKSTATE: { + pArg = (int)((sqlite3_file)id).locktype; + return SQLITE_OK; + } + case SQLITE_LAST_ERRNO: { + pArg = (int)((sqlite3_file)id).lastErrno; + return SQLITE_OK; + } + case SQLITE_FCNTL_CHUNK_SIZE: { + ((sqlite3_file)id).szChunk = (int)pArg; + return SQLITE_OK; + } + case SQLITE_FCNTL_SIZE_HINT: { + sqlite3_int64 sz = (sqlite3_int64)pArg; + SimulateIOErrorBenign(1); + winTruncate(id, sz); + SimulateIOErrorBenign(0); + return SQLITE_OK; + } + case SQLITE_FCNTL_SYNC_OMITTED: { + return SQLITE_OK; + } + } + return SQLITE_NOTFOUND; + } - /* - ** Return the sector size in bytes of the underlying block device for - ** the specified file. This is almost always 512 bytes, but may be - ** larger for some devices. - ** - ** SQLite code assumes this function cannot fail. It also assumes that - ** if two files are created in the same file-system directory (i.e. - ** a database and its journal file) that the sector size will be the - ** same for both. - */ - static int winSectorSize( sqlite3_file id ) - { - Debug.Assert( id != null ); - return (int)( id.sectorSize ); - } + /* + ** Return the sector size in bytes of the underlying block device for + ** the specified file. This is almost always 512 bytes, but may be + ** larger for some devices. + ** + ** SQLite code assumes this function cannot fail. It also assumes that + ** if two files are created in the same file-system directory (i.e. + ** a database and its journal file) that the sector size will be the + ** same for both. + */ + static int winSectorSize(sqlite3_file id) { + Debug.Assert(id != null); + return (int)(id.sectorSize); + } - /* - ** Return a vector of device characteristics. - */ - static int winDeviceCharacteristics( sqlite3_file id ) - { - UNUSED_PARAMETER( id ); - return 0; - } + /* + ** Return a vector of device characteristics. + */ + static int winDeviceCharacteristics(sqlite3_file id) { + UNUSED_PARAMETER(id); + return 0; + } #if !SQLITE_OMIT_WAL @@ -2324,383 +2224,360 @@ struct ShmRegion *apNew; /* New aRegion[] array */ } #else - //# define winShmMap 0 - static int winShmMap( - sqlite3_file fd, /* Handle open on database file */ - int iRegion, /* Region to retrieve */ - int szRegion, /* Size of regions */ - int isWrite, /* True to extend file if necessary */ - out object pp /* OUT: Mapped memory */ - ) - { - pp = null; - return 0; - } + //# define winShmMap 0 + static int winShmMap( + sqlite3_file fd, /* Handle open on database file */ + int iRegion, /* Region to retrieve */ + int szRegion, /* Size of regions */ + int isWrite, /* True to extend file if necessary */ + out object pp /* OUT: Mapped memory */ + ) { + pp = null; + return 0; + } - //# define winShmLock 0 - static int winShmLock( - sqlite3_file fd, /* Database file holding the shared memory */ - int ofst, /* First lock to acquire or release */ - int n, /* Number of locks to acquire or release */ - int flags /* What to do with the lock */ - ) - { - return 0; - } + //# define winShmLock 0 + static int winShmLock( + sqlite3_file fd, /* Database file holding the shared memory */ + int ofst, /* First lock to acquire or release */ + int n, /* Number of locks to acquire or release */ + int flags /* What to do with the lock */ + ) { + return 0; + } - //# define winShmBarrier 0 - static void winShmBarrier( - sqlite3_file fd /* Database holding the shared memory */ - ) - { - } + //# define winShmBarrier 0 + static void winShmBarrier( + sqlite3_file fd /* Database holding the shared memory */ + ) { + } - //# define winShmUnmap 0 - static int winShmUnmap( - sqlite3_file fd, /* Database holding shared memory */ - int deleteFlag /* Delete after closing if true */ - ) - { - return 0; - } + //# define winShmUnmap 0 + static int winShmUnmap( + sqlite3_file fd, /* Database holding shared memory */ + int deleteFlag /* Delete after closing if true */ + ) { + return 0; + } #endif //* #if !SQLITE_OMIT_WAL */ - /* -** Here ends the implementation of all sqlite3_file methods. -** -********************** End sqlite3_file Methods ******************************* -******************************************************************************/ + /* + ** Here ends the implementation of all sqlite3_file methods. + ** + ********************** End sqlite3_file Methods ******************************* + ******************************************************************************/ - /* - ** This vector defines all the methods that can operate on an - ** sqlite3_file for win32. - */ - static sqlite3_io_methods winIoMethod = new sqlite3_io_methods( - 2, /* iVersion */ - (dxClose)winClose, /* xClose */ - (dxRead)winRead, /* xRead */ - (dxWrite)winWrite, /* xWrite */ - (dxTruncate)winTruncate, /* xTruncate */ - (dxSync)winSync, /* xSync */ - (dxFileSize)winFileSize, /* xFileSize */ - (dxLock)winLock, /* xLock */ - (dxUnlock)winUnlock, /* xUnlock */ - (dxCheckReservedLock)winCheckReservedLock, /* xCheckReservedLock */ - (dxFileControl)winFileControl, /* xFileControl */ - (dxSectorSize)winSectorSize, /* xSectorSize */ - (dxDeviceCharacteristics)winDeviceCharacteristics, /* xDeviceCharacteristics */ - (dxShmMap)winShmMap, /* xShmMap */ - (dxShmLock)winShmLock, /* xShmLock */ - (dxShmBarrier)winShmBarrier, /* xShmBarrier */ - (dxShmUnmap)winShmUnmap /* xShmUnmap */ - ); + /* + ** This vector defines all the methods that can operate on an + ** sqlite3_file for win32. + */ + static sqlite3_io_methods winIoMethod = new sqlite3_io_methods( + 2, /* iVersion */ + (dxClose)winClose, /* xClose */ + (dxRead)winRead, /* xRead */ + (dxWrite)winWrite, /* xWrite */ + (dxTruncate)winTruncate, /* xTruncate */ + (dxSync)winSync, /* xSync */ + (dxFileSize)winFileSize, /* xFileSize */ + (dxLock)winLock, /* xLock */ + (dxUnlock)winUnlock, /* xUnlock */ + (dxCheckReservedLock)winCheckReservedLock, /* xCheckReservedLock */ + (dxFileControl)winFileControl, /* xFileControl */ + (dxSectorSize)winSectorSize, /* xSectorSize */ + (dxDeviceCharacteristics)winDeviceCharacteristics, /* xDeviceCharacteristics */ + (dxShmMap)winShmMap, /* xShmMap */ + (dxShmLock)winShmLock, /* xShmLock */ + (dxShmBarrier)winShmBarrier, /* xShmBarrier */ + (dxShmUnmap)winShmUnmap /* xShmUnmap */ + ); - /**************************************************************************** - **************************** sqlite3_vfs methods **************************** - ** - ** This division contains the implementation of methods on the - ** sqlite3_vfs object. - */ + /**************************************************************************** + **************************** sqlite3_vfs methods **************************** + ** + ** This division contains the implementation of methods on the + ** sqlite3_vfs object. + */ - /* - ** Convert a UTF-8 filename into whatever form the underlying - ** operating system wants filenames in. Space to hold the result - ** is obtained from malloc and must be freed by the calling - ** function. - */ - static string convertUtf8Filename( string zFilename ) - { - return zFilename; - // string zConverted = ""; - //if (isNT()) - //{ - // zConverted = utf8ToUnicode(zFilename); - /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. - */ + /* + ** Convert a UTF-8 filename into whatever form the underlying + ** operating system wants filenames in. Space to hold the result + ** is obtained from malloc and must be freed by the calling + ** function. + */ + static string convertUtf8Filename(string zFilename) { + return zFilename; + // string zConverted = ""; + //if (isNT()) + //{ + // zConverted = utf8ToUnicode(zFilename); + /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. + */ #if !SQLITE_OS_WINCE - //} - //else - //{ - // zConverted = sqlite3_win32_utf8_to_mbcs(zFilename); -#endif - //} - /* caller will handle out of memory */ - //return zConverted; - } + //} + //else + //{ + // zConverted = sqlite3_win32_utf8_to_mbcs(zFilename); +#endif + //} + /* caller will handle out of memory */ + //return zConverted; + } - /* - ** Create a temporary file name in zBuf. zBuf must be big enough to - ** hold at pVfs.mxPathname characters. - */ - static int getTempname( int nBuf, StringBuilder zBuf ) - { - const string zChars = "abcdefghijklmnopqrstuvwxyz0123456789"; - //static char zChars[] = - // "abcdefghijklmnopqrstuvwxyz" - // "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - // "0123456789"; - //size_t i, j; - //char zTempPath[MAX_PATH+1]; - - /* It's odd to simulate an io-error here, but really this is just - ** using the io-error infrastructure to test that SQLite handles this - ** function failing. - */ + /* + ** Create a temporary file name in zBuf. zBuf must be big enough to + ** hold at pVfs.mxPathname characters. + */ + static int getTempname(int nBuf, StringBuilder zBuf) { + const string zChars = "abcdefghijklmnopqrstuvwxyz0123456789"; + //static char zChars[] = + // "abcdefghijklmnopqrstuvwxyz" + // "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // "0123456789"; + //size_t i, j; + //char zTempPath[MAX_PATH+1]; + + /* It's odd to simulate an io-error here, but really this is just + ** using the io-error infrastructure to test that SQLite handles this + ** function failing. + */ #if SQLITE_TEST if ( SimulateIOError() ) return SQLITE_IOERR; #endif - //if( sqlite3_temp_directory ){ - // sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory); - //}else if( isNT() ){ - // string zMulti; - // WCHAR zWidePath[MAX_PATH]; - // GetTempPathW(MAX_PATH-30, zWidePath); - // zMulti = unicodeToUtf8(zWidePath); - // if( zMulti ){ - // sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti); - // free(zMulti); - // }else{ - // return SQLITE_NOMEM; - // } - /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. - ** Since the ASCII version of these Windows API do not exist for WINCE, - ** it's important to not reference them for WINCE builds. - */ + //if( sqlite3_temp_directory ){ + // sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory); + //}else if( isNT() ){ + // string zMulti; + // WCHAR zWidePath[MAX_PATH]; + // GetTempPathW(MAX_PATH-30, zWidePath); + // zMulti = unicodeToUtf8(zWidePath); + // if( zMulti ){ + // sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti); + // free(zMulti); + // }else{ + // return SQLITE_NOMEM; + // } + /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. + ** Since the ASCII version of these Windows API do not exist for WINCE, + ** it's important to not reference them for WINCE builds. + */ #if !SQLITE_OS_WINCE - //}else{ - // string zUtf8; - // char zMbcsPath[MAX_PATH]; - // GetTempPathA(MAX_PATH-30, zMbcsPath); - // zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath); - // if( zUtf8 ){ - // sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8); - // free(zUtf8); - // }else{ - // return SQLITE_NOMEM; - // } -#endif - //} - - /* Check that the output buffer is large enough for the temporary file - ** name. If it is not, return SQLITE_ERROR. - */ - //if( (sqlite3Strlen30(zTempPath) + sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX) + 17) >= nBuf ){ - // return SQLITE_ERROR; - //} - - StringBuilder zRandom = new StringBuilder( 20 ); - i64 iRandom = 0; - for ( int i = 0; i < 15; i++ ) - { - sqlite3_randomness( 1, ref iRandom ); - zRandom.Append( (char)zChars[(int)( iRandom % ( zChars.Length - 1 ) )] ); - } - // zBuf[j] = 0; + //}else{ + // string zUtf8; + // char zMbcsPath[MAX_PATH]; + // GetTempPathA(MAX_PATH-30, zMbcsPath); + // zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath); + // if( zUtf8 ){ + // sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8); + // free(zUtf8); + // }else{ + // return SQLITE_NOMEM; + // } +#endif + //} + + /* Check that the output buffer is large enough for the temporary file + ** name. If it is not, return SQLITE_ERROR. + */ + //if( (sqlite3Strlen30(zTempPath) + sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX) + 17) >= nBuf ){ + // return SQLITE_ERROR; + //} + + StringBuilder zRandom = new StringBuilder(20); + i64 iRandom = 0; + for (int i = 0; i < 15; i++) { + sqlite3_randomness(1, ref iRandom); + zRandom.Append((char)zChars[(int)(iRandom % (zChars.Length - 1))]); + } + // zBuf[j] = 0; #if SQLITE_WINRT zBuf.Append( Path.Combine(ApplicationData.Current.LocalFolder.Path, SQLITE_TEMP_FILE_PREFIX + zRandom.ToString()) ); #else - zBuf.Append( Path.GetTempPath() + SQLITE_TEMP_FILE_PREFIX + zRandom.ToString() ); -#endif - //for(i=sqlite3Strlen30(zTempPath); i>0 && zTempPath[i-1]=='\\'; i--){} - //zTempPath[i] = 0; - //sqlite3_snprintf(nBuf-17, zBuf, - // "%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPath); - //j = sqlite3Strlen30(zBuf); - //sqlite3_randomness(15, zBuf[j]); - //for(i=0; i<15; i++, j++){ - // zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; - //} - //zBuf[j] = 0; + zBuf.Append(Path.GetTempPath() + SQLITE_TEMP_FILE_PREFIX + zRandom.ToString()); +#endif + //for(i=sqlite3Strlen30(zTempPath); i>0 && zTempPath[i-1]=='\\'; i--){} + //zTempPath[i] = 0; + //sqlite3_snprintf(nBuf-17, zBuf, + // "%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPath); + //j = sqlite3Strlen30(zBuf); + //sqlite3_randomness(15, zBuf[j]); + //for(i=0; i<15; i++, j++){ + // zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; + //} + //zBuf[j] = 0; #if SQLITE_DEBUG - OSTRACE( "TEMP FILENAME: %s\n", zBuf.ToString() ); + OSTRACE("TEMP FILENAME: %s\n", zBuf.ToString()); #endif - return SQLITE_OK; - } + return SQLITE_OK; + } - /* - ** Open a file. - */ - static int winOpen( - sqlite3_vfs pVfs, /* Not used */ - string zName, /* Name of the file (UTF-8) */ - sqlite3_file pFile, /* Write the SQLite file handle here */ - int flags, /* Open mode flags */ - out int pOutFlags /* Status return flags */ - ) - { - //HANDLE h; + /* + ** Open a file. + */ + static int winOpen( + sqlite3_vfs pVfs, /* Not used */ + string zName, /* Name of the file (UTF-8) */ + sqlite3_file pFile, /* Write the SQLite file handle here */ + int flags, /* Open mode flags */ + out int pOutFlags /* Status return flags */ + ) { + //HANDLE h; #if SQLITE_WINRT IRandomAccessStream fs = null; DWORD dwDesiredAccess = 0; #else - FileStream fs = null; - FileAccess dwDesiredAccess; - FileShare dwShareMode; - FileMode dwCreationDisposition; + FileStream fs = null; + FileAccess dwDesiredAccess; + FileShare dwShareMode; + FileMode dwCreationDisposition; #endif #if !(SQLITE_SILVERLIGHT || WINDOWS_MOBILE || SQLITE_WINRT) - FileOptions dwFlagsAndAttributes; + FileOptions dwFlagsAndAttributes; #endif #if SQLITE_OS_WINCE int isTemp = 0; #endif - //winFile* pFile = (winFile)id; - string zConverted; /* Filename in OS encoding */ - string zUtf8Name = zName; /* Filename in UTF-8 encoding */ - pOutFlags = 0; - - /* If argument zPath is a NULL pointer, this function is required to open - ** a temporary file. Use this buffer to store the file name in. - */ - StringBuilder zTmpname = new StringBuilder( MAX_PATH + 1 ); /* Buffer used to create temp filename */ - - int rc = SQLITE_OK; /* Function Return Code */ - int eType = (int)( flags & 0xFFFFFF00 ); /* Type of file to open */ - bool isExclusive = ( flags & SQLITE_OPEN_EXCLUSIVE ) != 0; - bool isDelete = ( flags & SQLITE_OPEN_DELETEONCLOSE ) != 0; - bool isCreate = ( flags & SQLITE_OPEN_CREATE ) != 0; - bool isReadonly = ( flags & SQLITE_OPEN_READONLY ) != 0; - bool isReadWrite = ( flags & SQLITE_OPEN_READWRITE ) != 0; - bool isOpenJournal = ( isCreate && ( - eType == SQLITE_OPEN_MASTER_JOURNAL - || eType == SQLITE_OPEN_MAIN_JOURNAL - || eType == SQLITE_OPEN_WAL - ) ); - - /* Check the following statements are true: -** -** (a) Exactly one of the READWRITE and READONLY flags must be set, and -** (b) if CREATE is set, then READWRITE must also be set, and -** (c) if EXCLUSIVE is set, then CREATE must also be set. -** (d) if DELETEONCLOSE is set, then CREATE must also be set. -*/ - Debug.Assert( ( isReadonly == false || isReadWrite == false ) && ( isReadWrite || isReadonly ) ); - Debug.Assert( isCreate == false || isReadWrite ); - Debug.Assert( isExclusive == false || isCreate ); - Debug.Assert( isDelete == false || isCreate ); - - /* The main DB, main journal, WAL file and master journal are never - ** automatically deleted. Nor are they ever temporary files. */ - //Debug.Assert( ( !isDelete && !String.IsNullOrEmpty(zName) ) || eType != SQLITE_OPEN_MAIN_DB ); - Debug.Assert( ( !isDelete && !String.IsNullOrEmpty( zName ) ) || eType != SQLITE_OPEN_MAIN_JOURNAL ); - Debug.Assert( ( !isDelete && !String.IsNullOrEmpty( zName ) ) || eType != SQLITE_OPEN_MASTER_JOURNAL ); - Debug.Assert( ( !isDelete && !String.IsNullOrEmpty( zName ) ) || eType != SQLITE_OPEN_WAL ); - - /* Assert that the upper layer has set one of the "file-type" flags. */ - Debug.Assert( eType == SQLITE_OPEN_MAIN_DB || eType == SQLITE_OPEN_TEMP_DB - || eType == SQLITE_OPEN_MAIN_JOURNAL || eType == SQLITE_OPEN_TEMP_JOURNAL - || eType == SQLITE_OPEN_SUBJOURNAL || eType == SQLITE_OPEN_MASTER_JOURNAL - || eType == SQLITE_OPEN_TRANSIENT_DB || eType == SQLITE_OPEN_WAL - ); + //winFile* pFile = (winFile)id; + string zConverted; /* Filename in OS encoding */ + string zUtf8Name = zName; /* Filename in UTF-8 encoding */ + pOutFlags = 0; - //assert( id!=0 ); - UNUSED_PARAMETER( pVfs ); - - pFile.fs = null;//.h = INVALID_HANDLE_VALUE; - - /* If the second argument to this function is NULL, generate a - ** temporary file name to use + /* If argument zPath is a NULL pointer, this function is required to open + ** a temporary file. Use this buffer to store the file name in. + */ + StringBuilder zTmpname = new StringBuilder(MAX_PATH + 1); /* Buffer used to create temp filename */ + + int rc = SQLITE_OK; /* Function Return Code */ + int eType = (int)(flags & 0xFFFFFF00); /* Type of file to open */ + bool isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE) != 0; + bool isDelete = (flags & SQLITE_OPEN_DELETEONCLOSE) != 0; + bool isCreate = (flags & SQLITE_OPEN_CREATE) != 0; + bool isReadonly = (flags & SQLITE_OPEN_READONLY) != 0; + bool isReadWrite = (flags & SQLITE_OPEN_READWRITE) != 0; + bool isOpenJournal = (isCreate && ( + eType == SQLITE_OPEN_MASTER_JOURNAL + || eType == SQLITE_OPEN_MAIN_JOURNAL + || eType == SQLITE_OPEN_WAL + )); + + /* Check the following statements are true: + ** + ** (a) Exactly one of the READWRITE and READONLY flags must be set, and + ** (b) if CREATE is set, then READWRITE must also be set, and + ** (c) if EXCLUSIVE is set, then CREATE must also be set. + ** (d) if DELETEONCLOSE is set, then CREATE must also be set. */ - if ( String.IsNullOrEmpty( zUtf8Name ) ) - { - Debug.Assert( isDelete && !isOpenJournal ); - rc = getTempname( MAX_PATH + 1, zTmpname ); - if ( rc != SQLITE_OK ) - { - return rc; - } - zUtf8Name = zTmpname.ToString(); - } + Debug.Assert((isReadonly == false || isReadWrite == false) && (isReadWrite || isReadonly)); + Debug.Assert(isCreate == false || isReadWrite); + Debug.Assert(isExclusive == false || isCreate); + Debug.Assert(isDelete == false || isCreate); + + /* The main DB, main journal, WAL file and master journal are never + ** automatically deleted. Nor are they ever temporary files. */ + //Debug.Assert( ( !isDelete && !String.IsNullOrEmpty(zName) ) || eType != SQLITE_OPEN_MAIN_DB ); + Debug.Assert((!isDelete && !String.IsNullOrEmpty(zName)) || eType != SQLITE_OPEN_MAIN_JOURNAL); + Debug.Assert((!isDelete && !String.IsNullOrEmpty(zName)) || eType != SQLITE_OPEN_MASTER_JOURNAL); + Debug.Assert((!isDelete && !String.IsNullOrEmpty(zName)) || eType != SQLITE_OPEN_WAL); + + /* Assert that the upper layer has set one of the "file-type" flags. */ + Debug.Assert(eType == SQLITE_OPEN_MAIN_DB || eType == SQLITE_OPEN_TEMP_DB + || eType == SQLITE_OPEN_MAIN_JOURNAL || eType == SQLITE_OPEN_TEMP_JOURNAL + || eType == SQLITE_OPEN_SUBJOURNAL || eType == SQLITE_OPEN_MASTER_JOURNAL + || eType == SQLITE_OPEN_TRANSIENT_DB || eType == SQLITE_OPEN_WAL + ); + + //assert( id!=0 ); + UNUSED_PARAMETER(pVfs); + + pFile.fs = null;//.h = INVALID_HANDLE_VALUE; + + /* If the second argument to this function is NULL, generate a + ** temporary file name to use + */ + if (String.IsNullOrEmpty(zUtf8Name)) { + Debug.Assert(isDelete && !isOpenJournal); + rc = getTempname(MAX_PATH + 1, zTmpname); + if (rc != SQLITE_OK) { + return rc; + } + zUtf8Name = zTmpname.ToString(); + } - // /* Convert the filename to the system encoding. */ - zConverted = zUtf8Name;// convertUtf8Filename( zUtf8Name ); - //if ( zConverted.StartsWith( "/", StringComparison.Ordinal ) && !zConverted.StartsWith( "//", StringComparison.Ordinal ) ) - // zConverted = zConverted.Substring( 1 ); - //if ( String.IsNullOrEmpty( zConverted ) ) - //{ - // return SQLITE_NOMEM; - //} + // /* Convert the filename to the system encoding. */ + zConverted = zUtf8Name;// convertUtf8Filename( zUtf8Name ); + //if ( zConverted.StartsWith( "/", StringComparison.Ordinal ) && !zConverted.StartsWith( "//", StringComparison.Ordinal ) ) + // zConverted = zConverted.Substring( 1 ); + //if ( String.IsNullOrEmpty( zConverted ) ) + //{ + // return SQLITE_NOMEM; + //} #if !SQLITE_WINRT - if ( isReadWrite ) - { - dwDesiredAccess = FileAccess.Read | FileAccess.Write; // GENERIC_READ | GENERIC_WRITE; - } - else - { - dwDesiredAccess = FileAccess.Read; // GENERIC_READ; - } - - /* SQLITE_OPEN_EXCLUSIVE is used to make sure that a new file is - ** created. SQLite doesn't use it to indicate "exclusive access" - ** as it is usually understood. - */ - if ( isExclusive ) - { - /* Creates a new file, only if it does not already exist. */ - /* If the file exists, it fails. */ - dwCreationDisposition = FileMode.CreateNew;// CREATE_NEW; - } - else if ( isCreate ) - { - /* Open existing file, or create if it doesn't exist */ - dwCreationDisposition = FileMode.OpenOrCreate;// OPEN_ALWAYS; - } - else - { - /* Opens a file, only if it exists. */ - dwCreationDisposition = FileMode.Open;//OPEN_EXISTING; - } + if (isReadWrite) { + dwDesiredAccess = FileAccess.Read | FileAccess.Write; // GENERIC_READ | GENERIC_WRITE; + } else { + dwDesiredAccess = FileAccess.Read; // GENERIC_READ; + } - dwShareMode = FileShare.Read | FileShare.Write;// FILE_SHARE_READ | FILE_SHARE_WRITE; + /* SQLITE_OPEN_EXCLUSIVE is used to make sure that a new file is + ** created. SQLite doesn't use it to indicate "exclusive access" + ** as it is usually understood. + */ + if (isExclusive) { + /* Creates a new file, only if it does not already exist. */ + /* If the file exists, it fails. */ + dwCreationDisposition = FileMode.CreateNew;// CREATE_NEW; + } else if (isCreate) { + /* Open existing file, or create if it doesn't exist */ + dwCreationDisposition = FileMode.OpenOrCreate;// OPEN_ALWAYS; + } else { + /* Opens a file, only if it exists. */ + dwCreationDisposition = FileMode.Open;//OPEN_EXISTING; + } + + dwShareMode = FileShare.Read | FileShare.Write;// FILE_SHARE_READ | FILE_SHARE_WRITE; #endif - if ( isDelete ) - { + if (isDelete) { #if SQLITE_OS_WINCE dwFlagsAndAttributes = FILE_ATTRIBUTE_HIDDEN; isTemp = 1; #else #if !(SQLITE_SILVERLIGHT || WINDOWS_MOBILE || SQLITE_WINRT) - dwFlagsAndAttributes = FileOptions.DeleteOnClose; // FILE_ATTRIBUTE_TEMPORARY - //| FILE_ATTRIBUTE_HIDDEN - //| FILE_FLAG_DELETE_ON_CLOSE; + dwFlagsAndAttributes = FileOptions.DeleteOnClose; // FILE_ATTRIBUTE_TEMPORARY + //| FILE_ATTRIBUTE_HIDDEN + //| FILE_FLAG_DELETE_ON_CLOSE; #endif #endif - } - else - { + } else { #if !(SQLITE_SILVERLIGHT || WINDOWS_MOBILE || SQLITE_WINRT) - dwFlagsAndAttributes = FileOptions.None; // FILE_ATTRIBUTE_NORMAL; + dwFlagsAndAttributes = FileOptions.None; // FILE_ATTRIBUTE_NORMAL; #endif - } - /* Reports from the internet are that performance is always - ** better if FILE_FLAG_RANDOM_ACCESS is used. Ticket #2699. */ + } + /* Reports from the internet are that performance is always + ** better if FILE_FLAG_RANDOM_ACCESS is used. Ticket #2699. */ #if SQLITE_OS_WINCE dwFlagsAndAttributes |= FileOptions.RandomAccess; // FILE_FLAG_RANDOM_ACCESS; #endif - if ( isNT() ) - { - //h = CreateFileW((WCHAR)zConverted, - // dwDesiredAccess, - // dwShareMode, - // NULL, - // dwCreationDisposition, - // dwFlagsAndAttributes, - // NULL - //); - - // - // retry opening the file a few times; this is because of a racing condition between a delete and open call to the FS - // - int retries = 3; - while ( ( fs == null ) && ( retries > 0 ) ) - try - { - retries--; + if (isNT()) { + //h = CreateFileW((WCHAR)zConverted, + // dwDesiredAccess, + // dwShareMode, + // NULL, + // dwCreationDisposition, + // dwFlagsAndAttributes, + // NULL + //); + + // + // retry opening the file a few times; this is because of a racing condition between a delete and open call to the FS + // + int retries = 3; + while ((fs == null) && (retries > 0)) + try { + retries--; #if SQLITE_WINRT Task fileTask = null; @@ -2739,10 +2616,10 @@ static int winOpen( Task streamTask = fileTask.Result.OpenAsync(FileAccessMode.ReadWrite).AsTask(); streamTask.Wait(); fs = streamTask.Result; -#elif WINDOWS_PHONE || SQLITE_SILVERLIGHT +#elif WINDOWS_PHONE || SQLITE_SILVERLIGHT fs = new IsolatedStorageFileStream(zConverted, dwCreationDisposition, dwDesiredAccess, dwShareMode, IsolatedStorageFile.GetUserStoreForApplication()); #elif !(SQLITE_SILVERLIGHT || WINDOWS_MOBILE) - fs = new FileStream( zConverted, dwCreationDisposition, dwDesiredAccess, dwShareMode, 4096, dwFlagsAndAttributes ); + fs = new FileStream(zConverted, dwCreationDisposition, dwDesiredAccess, dwShareMode, 4096, dwFlagsAndAttributes); #else fs = new FileStream( zConverted, dwCreationDisposition, dwDesiredAccess, dwShareMode, 4096); #endif @@ -2751,91 +2628,81 @@ static int winOpen( #if WINDOWS_PHONE || SQLITE_SILVERLIGHT OSTRACE( "OPEN %d (%s)\n", fs.GetHashCode(), zName ); #else - OSTRACE("OPEN %d (%s)\n", fs.GetHashCode(), fs.Name); + OSTRACE("OPEN %d (%s)\n", fs.GetHashCode(), fs.Name); #endif #endif - } - catch ( Exception e ) - { + } catch (Exception e) { #if SQLITE_WINRT System.Threading.Tasks.Task.Delay(100).Wait(); #else - Thread.Sleep(100); + Thread.Sleep(100); #endif - } + } - /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. - ** Since the ASCII version of these Windows API do not exist for WINCE, - ** it's important to not reference them for WINCE builds. - */ + /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. + ** Since the ASCII version of these Windows API do not exist for WINCE, + ** it's important to not reference them for WINCE builds. + */ #if !SQLITE_OS_WINCE - } - else - { - Debugger.Break(); // Not NT - //h = CreateFileA((char)zConverted, - // dwDesiredAccess, - // dwShareMode, - // NULL, - // dwCreationDisposition, - // dwFlagsAndAttributes, - // NULL - //); + } else { + Debugger.Break(); // Not NT + //h = CreateFileA((char)zConverted, + // dwDesiredAccess, + // dwShareMode, + // NULL, + // dwCreationDisposition, + // dwFlagsAndAttributes, + // NULL + //); #endif - } + } - OSTRACE( "OPEN %d %s 0x%lx %s\n", - pFile.GetHashCode(), zName, dwDesiredAccess, - fs == null ? "failed" : "ok" ); - if ( fs == null - || + OSTRACE("OPEN %d %s 0x%lx %s\n", + pFile.GetHashCode(), zName, dwDesiredAccess, + fs == null ? "failed" : "ok"); + if (fs == null + || #if !(SQLITE_SILVERLIGHT || WINDOWS_MOBILE || SQLITE_WINRT) - fs.SafeFileHandle.IsInvalid + fs.SafeFileHandle.IsInvalid #else !fs.CanRead #endif - ) //(h == INVALID_HANDLE_VALUE) - { + ) //(h == INVALID_HANDLE_VALUE) + { #if SQLITE_SILVERLIGHT || SQLITE_WINRT pFile.lastErrno = 1; #else - // pFile.lastErrno = GetLastError(); - pFile.lastErrno = (u32)HelperMethods.GetLastError(); -#endif - winLogError(SQLITE_CANTOPEN, "winOpen", zUtf8Name); - // free(zConverted); - if ( isReadWrite ) - { - return winOpen( pVfs, zName, pFile, - ( ( flags | SQLITE_OPEN_READONLY ) & ~( SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE ) ), out pOutFlags ); - } - else - { - return SQLITE_CANTOPEN_BKPT(); - } - } + // pFile.lastErrno = GetLastError(); + pFile.lastErrno = (u32)HelperMethods.GetLastError(); +#endif + winLogError(SQLITE_CANTOPEN, "winOpen", zUtf8Name); + // free(zConverted); + if (isReadWrite) { + return winOpen(pVfs, zName, pFile, + ((flags | SQLITE_OPEN_READONLY) & ~(SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE)), out pOutFlags); + } else { + return SQLITE_CANTOPEN_BKPT(); + } + } - //if ( pOutFlags ) - //{ - if ( isReadWrite ) - { - pOutFlags = SQLITE_OPEN_READWRITE; - } - else - { - pOutFlags = SQLITE_OPEN_READONLY; - } - //} - - pFile.Clear(); // memset(pFile, 0, sizeof(*pFile)); - pFile.pMethods = winIoMethod; - pFile.fs = fs; - pFile.lastErrno = NO_ERROR; - pFile.pVfs = pVfs; - pFile.pShm = null; - pFile.zPath = zName; - pFile.sectorSize = (ulong)getSectorSize( pVfs, zUtf8Name ); + //if ( pOutFlags ) + //{ + if (isReadWrite) { + pOutFlags = SQLITE_OPEN_READWRITE; + } else { + pOutFlags = SQLITE_OPEN_READONLY; + } + //} + + pFile.Clear(); // memset(pFile, 0, sizeof(*pFile)); + pFile.pMethods = winIoMethod; + pFile.fs = fs; + pFile.lastErrno = NO_ERROR; + pFile.pVfs = pVfs; + pFile.pShm = null; + pFile.zPath = zName; + pFile.sectorSize = (ulong)getSectorSize(pVfs, zUtf8Name); #if SQLITE_OS_WINCE if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB && !winceCreateLock(zName, pFile) @@ -2848,73 +2715,70 @@ static int winOpen( pFile.zDeleteOnClose = zConverted; }else #endif - { - // free(zConverted); - } + { + // free(zConverted); + } #if SQLITE_TEST OpenCounter( +1 ); #endif - return rc; - } + return rc; + } - /* - ** Delete the named file. - ** - ** Note that windows does not allow a file to be deleted if some other - ** process has it open. Sometimes a virus scanner or indexing program - ** will open a journal file shortly after it is created in order to do - ** whatever it does. While this other process is holding the - ** file open, we will be unable to delete it. To work around this - ** problem, we delay 100 milliseconds and try to delete again. Up - ** to MX_DELETION_ATTEMPTs deletion attempts are run before giving - ** up and returning an error. - */ - static int MX_DELETION_ATTEMPTS = 5; - static int winDelete( - sqlite3_vfs pVfs, /* Not used on win32 */ - string zFilename, /* Name of file to delete */ - int syncDir /* Not used on win32 */ - ) - { - int cnt = 0; - int rc = SQLITE_ERROR; - int error; - string zConverted; - UNUSED_PARAMETER( pVfs ); - UNUSED_PARAMETER( syncDir ); + /* + ** Delete the named file. + ** + ** Note that windows does not allow a file to be deleted if some other + ** process has it open. Sometimes a virus scanner or indexing program + ** will open a journal file shortly after it is created in order to do + ** whatever it does. While this other process is holding the + ** file open, we will be unable to delete it. To work around this + ** problem, we delay 100 milliseconds and try to delete again. Up + ** to MX_DELETION_ATTEMPTs deletion attempts are run before giving + ** up and returning an error. + */ + static int MX_DELETION_ATTEMPTS = 5; + static int winDelete( + sqlite3_vfs pVfs, /* Not used on win32 */ + string zFilename, /* Name of file to delete */ + int syncDir /* Not used on win32 */ + ) { + int cnt = 0; + int rc = SQLITE_ERROR; + int error; + string zConverted; + UNUSED_PARAMETER(pVfs); + UNUSED_PARAMETER(syncDir); #if SQLITE_TEST if ( SimulateIOError() ) return SQLITE_IOERR_DELETE; #endif - zConverted = convertUtf8Filename( zFilename ); - //if ( zConverted == null || zConverted == "" ) - //{ - // return SQLITE_NOMEM; - //} - if ( isNT() ) - { - do - // DeleteFileW(zConverted); - //}while( ( ((rc = GetFileAttributesW(zConverted)) != INVALID_FILE_ATTRIBUTES) - // || ((error = GetLastError()) == ERROR_ACCESS_DENIED)) - // && (++cnt < MX_DELETION_ATTEMPTS) - // && (Sleep(100), 1) ); - { + zConverted = convertUtf8Filename(zFilename); + //if ( zConverted == null || zConverted == "" ) + //{ + // return SQLITE_NOMEM; + //} + if (isNT()) { + do + // DeleteFileW(zConverted); + //}while( ( ((rc = GetFileAttributesW(zConverted)) != INVALID_FILE_ATTRIBUTES) + // || ((error = GetLastError()) == ERROR_ACCESS_DENIED)) + // && (++cnt < MX_DELETION_ATTEMPTS) + // && (Sleep(100), 1) ); + { #if SQLITE_WINRT if(!HelperMethods.FileExists(zFilename)) #elif WINDOWS_PHONE if ( !System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication().FileExists( zFilename ) ) #else - if ( !File.Exists( zFilename ) ) + if (!File.Exists(zFilename)) #endif - { - rc = SQLITE_IOERR; - break; - } - try - { + { + rc = SQLITE_IOERR; + break; + } + try { #if SQLITE_WINRT Task fileTask = StorageFile.GetFileFromPathAsync(zConverted).AsTask(); fileTask.Wait(); @@ -2924,82 +2788,72 @@ int syncDir /* Not used on win32 */ #elif SQLITE_SILVERLIGHT IsolatedStorageFile.GetUserStoreForApplication().DeleteFile(zFilename); #else - File.Delete( zConverted ); + File.Delete(zConverted); #endif - rc = SQLITE_OK; - } - catch ( IOException e ) - { - rc = SQLITE_IOERR; + rc = SQLITE_OK; + } catch (IOException e) { + rc = SQLITE_IOERR; #if SQLITE_WINRT System.Threading.Tasks.Task.Delay(100).Wait(); #else - Thread.Sleep(100); -#endif - } - } while ( rc != SQLITE_OK && ++cnt < MX_DELETION_ATTEMPTS ); - /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. - ** Since the ASCII version of these Windows API do not exist for WINCE, - ** it's important to not reference them for WINCE builds. - */ + Thread.Sleep(100); +#endif + } + } while (rc != SQLITE_OK && ++cnt < MX_DELETION_ATTEMPTS); + /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. + ** Since the ASCII version of these Windows API do not exist for WINCE, + ** it's important to not reference them for WINCE builds. + */ #if !SQLITE_OS_WINCE && !SQLITE_WINRT - } - else - { - do - { - //DeleteFileA( zConverted ); - //}while( ( ((rc = GetFileAttributesA(zConverted)) != INVALID_FILE_ATTRIBUTES) - // || ((error = GetLastError()) == ERROR_ACCESS_DENIED)) - // && (cnt++ < MX_DELETION_ATTEMPTS) - // && (Sleep(100), 1) ); - if ( !File.Exists( zFilename ) ) - { - rc = SQLITE_IOERR; - break; - } - try - { - File.Delete( zConverted ); - rc = SQLITE_OK; - } - catch ( IOException e ) - { - rc = SQLITE_IOERR; - Thread.Sleep( 100 ); - } - } while ( rc != SQLITE_OK && cnt++ < MX_DELETION_ATTEMPTS ); + } else { + do { + //DeleteFileA( zConverted ); + //}while( ( ((rc = GetFileAttributesA(zConverted)) != INVALID_FILE_ATTRIBUTES) + // || ((error = GetLastError()) == ERROR_ACCESS_DENIED)) + // && (cnt++ < MX_DELETION_ATTEMPTS) + // && (Sleep(100), 1) ); + if (!File.Exists(zFilename)) { + rc = SQLITE_IOERR; + break; + } + try { + File.Delete(zConverted); + rc = SQLITE_OK; + } catch (IOException e) { + rc = SQLITE_IOERR; + Thread.Sleep(100); + } + } while (rc != SQLITE_OK && cnt++ < MX_DELETION_ATTEMPTS); #endif - } - //free(zConverted); + } + //free(zConverted); #if SQLITE_DEBUG - OSTRACE( "DELETE \"%s\"\n", zFilename ); + OSTRACE("DELETE \"%s\"\n", zFilename); #endif - if ( rc == SQLITE_OK ) - return rc; + if (rc == SQLITE_OK) + return rc; - error = HelperMethods.GetLastError(); + error = HelperMethods.GetLastError(); - return ( ( rc == INVALID_FILE_ATTRIBUTES ) - && ( error == ERROR_FILE_NOT_FOUND ) ) ? SQLITE_OK : - winLogError(SQLITE_IOERR_DELETE, "winDelete", zFilename); - } + return ((rc == INVALID_FILE_ATTRIBUTES) + && (error == ERROR_FILE_NOT_FOUND)) ? SQLITE_OK : + winLogError(SQLITE_IOERR_DELETE, "winDelete", zFilename); + } - /* - ** Check the existence and status of a file. - */ - static int winAccess( - sqlite3_vfs pVfs, /* Not used on win32 */ - string zFilename, /* Name of file to check */ - int flags, /* Type of test to make on this file */ - out int pResOut /* OUT: Result */ - ) - { - FileAttributes attr = 0; // DWORD attr; - int rc = 0; - // void *zConverted; - UNUSED_PARAMETER( pVfs ); + /* + ** Check the existence and status of a file. + */ + static int winAccess( + sqlite3_vfs pVfs, /* Not used on win32 */ + string zFilename, /* Name of file to check */ + int flags, /* Type of test to make on this file */ + out int pResOut /* OUT: Result */ + ) { + FileAttributes attr = 0; // DWORD attr; + int rc = 0; + // void *zConverted; + UNUSED_PARAMETER(pVfs); #if SQLITE_TEST if ( SimulateIOError() ) @@ -3008,16 +2862,15 @@ static int winAccess( return SQLITE_IOERR_ACCESS; } #endif - //zConverted = convertUtf8Filename(zFilename); - // if( zConverted==0 ){ - // return SQLITE_NOMEM; - // } - //if ( isNT() ) - //{ - // - // Do a quick test to prevent the try/catch block - if ( flags == SQLITE_ACCESS_EXISTS ) - { + //zConverted = convertUtf8Filename(zFilename); + // if( zConverted==0 ){ + // return SQLITE_NOMEM; + // } + //if ( isNT() ) + //{ + // + // Do a quick test to prevent the try/catch block + if (flags == SQLITE_ACCESS_EXISTS) { #if SQLITE_WINRT pResOut = HelperMethods.FileExists(zFilename) ? 1 : 0; #elif WINDOWS_PHONE @@ -3025,37 +2878,36 @@ static int winAccess( #elif SQLITE_SILVERLIGHT pResOut = IsolatedStorageFile.GetUserStoreForApplication().FileExists(zFilename) ? 1 : 0; #else - pResOut = File.Exists( zFilename ) ? 1 : 0; + pResOut = File.Exists(zFilename) ? 1 : 0; #endif - return SQLITE_OK; - } - // - try - { - //WIN32_FILE_ATTRIBUTE_DATA sAttrData; - //memset(&sAttrData, 0, sizeof(sAttrData)); - //if( GetFileAttributesExW((WCHAR)zConverted, - // GetFileExInfoStandard, - // &sAttrData) ){ - // /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file - // ** as if it does not exist. - // */ - // if( flags==SQLITE_ACCESS_EXISTS - // && sAttrData.nFileSizeHigh==0 - // && sAttrData.nFileSizeLow==0 ){ - // attr = INVALID_FILE_ATTRIBUTES; - // }else{ - // attr = sAttrData.dwFileAttributes; - // } - //}else{ - // if( GetLastError()!=ERROR_FILE_NOT_FOUND ){ - // winLogError(SQLITE_IOERR_ACCESS, "winAccess", zFilename); - // free(zConverted); - // return SQLITE_IOERR_ACCESS; - // }else{ - // attr = INVALID_FILE_ATTRIBUTES; - // } - //} + return SQLITE_OK; + } + // + try { + //WIN32_FILE_ATTRIBUTE_DATA sAttrData; + //memset(&sAttrData, 0, sizeof(sAttrData)); + //if( GetFileAttributesExW((WCHAR)zConverted, + // GetFileExInfoStandard, + // &sAttrData) ){ + // /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file + // ** as if it does not exist. + // */ + // if( flags==SQLITE_ACCESS_EXISTS + // && sAttrData.nFileSizeHigh==0 + // && sAttrData.nFileSizeLow==0 ){ + // attr = INVALID_FILE_ATTRIBUTES; + // }else{ + // attr = sAttrData.dwFileAttributes; + // } + //}else{ + // if( GetLastError()!=ERROR_FILE_NOT_FOUND ){ + // winLogError(SQLITE_IOERR_ACCESS, "winAccess", zFilename); + // free(zConverted); + // return SQLITE_IOERR_ACCESS; + // }else{ + // attr = INVALID_FILE_ATTRIBUTES; + // } + //} #if SQLITE_WINRT attr = FileAttributes.Normal; } @@ -3067,14 +2919,13 @@ static int winAccess( #elif WINDOWS_PHONE || SQLITE_SILVERLIGHT if (System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication().DirectoryExists(zFilename)) #else - if (Directory.Exists( zFilename )) + if (Directory.Exists(zFilename)) #endif - { - try - { - var tempName = new StringBuilder(); - getTempname(MAX_PATH + 1, tempName); - string name = Path.Combine(zFilename, Path.GetFileNameWithoutExtension(tempName.ToString())); + { + try { + var tempName = new StringBuilder(); + getTempname(MAX_PATH + 1, tempName); + string name = Path.Combine(zFilename, Path.GetFileNameWithoutExtension(tempName.ToString())); #if SQLITE_WINRT Task fileTask = StorageFolder.GetFolderFromPathAsync(path).AsTask(); @@ -3085,73 +2936,68 @@ static int winAccess( stream.Close(); IsolatedStorageFile.GetUserStoreForApplication().DeleteFile(name); #else - FileStream fs = File.Create( name ); - fs.Close(); - File.Delete( name ); -#endif - attr = FileAttributes.Normal; - } - catch ( IOException e ) - { - attr = FileAttributes.ReadOnly; - } - } - } - /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. - ** Since the ASCII version of these Windows API do not exist for WINCE, - ** it's important to not reference them for WINCE builds. - */ + FileStream fs = File.Create(name); + fs.Close(); + File.Delete(name); +#endif + attr = FileAttributes.Normal; + } catch (IOException e) { + attr = FileAttributes.ReadOnly; + } + } + } + /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. + ** Since the ASCII version of these Windows API do not exist for WINCE, + ** it's important to not reference them for WINCE builds. + */ #if !SQLITE_OS_WINCE - //} - //else - //{ - // attr = GetFileAttributesA( (char)zConverted ); + //} + //else + //{ + // attr = GetFileAttributesA( (char)zConverted ); #endif #endif - //} - catch ( IOException e ) - { - winLogError(SQLITE_IOERR_ACCESS, "winAccess", zFilename); - } - // free(zConverted); - switch ( flags ) - { - case SQLITE_ACCESS_READ: - case SQLITE_ACCESS_EXISTS: -#if SQLITE_WINRT + //} + catch (IOException e) { + winLogError(SQLITE_IOERR_ACCESS, "winAccess", zFilename); + } + // free(zConverted); + switch (flags) { + case SQLITE_ACCESS_READ: + case SQLITE_ACCESS_EXISTS: +#if SQLITE_WINRT rc = attr == FileAttributes.Normal ? 1 : 0;// != INVALID_FILE_ATTRIBUTES; #else - rc = attr != 0 ? 1 : 0;// != INVALID_FILE_ATTRIBUTES; + rc = attr != 0 ? 1 : 0;// != INVALID_FILE_ATTRIBUTES; #endif - break; - case SQLITE_ACCESS_READWRITE: -#if SQLITE_WINRT + break; + case SQLITE_ACCESS_READWRITE: +#if SQLITE_WINRT rc = attr != FileAttributes.Normal ? 0 : (int)( attr & FileAttributes.ReadOnly ) != 0 ? 0 : 1; //FILE_ATTRIBUTE_READONLY ) == 0; #else - rc = attr == 0 ? 0 : (int)( attr & FileAttributes.ReadOnly ) != 0 ? 0 : 1; //FILE_ATTRIBUTE_READONLY ) == 0; + rc = attr == 0 ? 0 : (int)(attr & FileAttributes.ReadOnly) != 0 ? 0 : 1; //FILE_ATTRIBUTE_READONLY ) == 0; #endif - break; - default: - Debug.Assert( "" == "Invalid flags argument" ); - rc = 0; - break; - } - pResOut = rc; - return SQLITE_OK; - } + break; + default: + Debug.Assert("" == "Invalid flags argument"); + rc = 0; + break; + } + pResOut = rc; + return SQLITE_OK; + } - /* - ** Turn a relative pathname into a full pathname. Write the full - ** pathname into zOut[]. zOut[] will be at least pVfs.mxPathname - ** bytes in size. - */ - static int winFullPathname( - sqlite3_vfs pVfs, /* Pointer to vfs object */ - string zRelative, /* Possibly relative input path */ - int nFull, /* Size of output buffer in bytes */ - StringBuilder zFull /* Output buffer */ - ) - { + /* + ** Turn a relative pathname into a full pathname. Write the full + ** pathname into zOut[]. zOut[] will be at least pVfs.mxPathname + ** bytes in size. + */ + static int winFullPathname( + sqlite3_vfs pVfs, /* Pointer to vfs object */ + string zRelative, /* Possibly relative input path */ + int nFull, /* Size of output buffer in bytes */ + StringBuilder zFull /* Output buffer */ + ) { #if __CYGWIN__ SimulateIOError( return SQLITE_ERROR ); @@ -3169,110 +3015,97 @@ StringBuilder zFull /* Output buffer */ #endif #if !SQLITE_OS_WINCE && !__CYGWIN__ - int nByte; - //string zConverted; - string zOut = null; + int nByte; + //string zConverted; + string zOut = null; - /* If this path name begins with "/X:", where "X" is any alphabetic - ** character, discard the initial "/" from the pathname. - */ - if( zRelative.Length >= 3 && zRelative[0]=='/' && Char.IsLetter(zRelative[1]) && zRelative[2]==':' ){ - zRelative = zRelative.Substring(1); - } + /* If this path name begins with "/X:", where "X" is any alphabetic + ** character, discard the initial "/" from the pathname. + */ + if (zRelative.Length >= 3 && zRelative[0] == '/' && Char.IsLetter(zRelative[1]) && zRelative[2] == ':') { + zRelative = zRelative.Substring(1); + } - /* It's odd to simulate an io-error here, but really this is just - ** using the io-error infrastructure to test that SQLite handles this - ** function failing. This function could fail if, for example, the - ** current working directory has been unlinked. - */ + /* It's odd to simulate an io-error here, but really this is just + ** using the io-error infrastructure to test that SQLite handles this + ** function failing. This function could fail if, for example, the + ** current working directory has been unlinked. + */ #if SQLITE_TEST if ( SimulateIOError() ) return SQLITE_ERROR; #endif - UNUSED_PARAMETER( nFull ); - //convertUtf8Filename(zRelative)); - if ( isNT() ) - { - //string zTemp; - //nByte = GetFullPathNameW( zConverted, 0, 0, 0) + 3; - //zTemp = malloc( nByte*sizeof(zTemp[0]) ); - //if( zTemp==0 ){ - // free(zConverted); - // return SQLITE_NOMEM; - //} - //zTemp = GetFullPathNameW(zConverted, nByte, zTemp, 0); - // will happen on exit; was free(zConverted); - try - { -#if WINDOWS_PHONE || SQLITE_SILVERLIGHT || SQLITE_WINRT + UNUSED_PARAMETER(nFull); + //convertUtf8Filename(zRelative)); + if (isNT()) { + //string zTemp; + //nByte = GetFullPathNameW( zConverted, 0, 0, 0) + 3; + //zTemp = malloc( nByte*sizeof(zTemp[0]) ); + //if( zTemp==0 ){ + // free(zConverted); + // return SQLITE_NOMEM; + //} + //zTemp = GetFullPathNameW(zConverted, nByte, zTemp, 0); + // will happen on exit; was free(zConverted); + try { +#if WINDOWS_PHONE || SQLITE_SILVERLIGHT || SQLITE_WINRT zOut = zRelative; #else - if (Environment.OSVersion.Platform == PlatformID.Unix - && zRelative.Length > 2 && zRelative[0] == '~' && (zRelative[1] == '/' || zRelative[1] == '\\')) - { - string home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); - zOut = Path.GetFullPath(home + zRelative.Substring(1)); - } - else - { - zOut = Path.GetFullPath( zRelative ); // was unicodeToUtf8(zTemp); - } -#endif - } - catch ( Exception e ) - { - zOut = zRelative; - } - // will happen on exit; was free(zTemp); - /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. - ** Since the ASCII version of these Windows API do not exist for WINCE, - ** it's important to not reference them for WINCE builds. - */ + if (Environment.OSVersion.Platform == PlatformID.Unix + && zRelative.Length > 2 && zRelative[0] == '~' && (zRelative[1] == '/' || zRelative[1] == '\\')) { + string home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); + zOut = Path.GetFullPath(home + zRelative.Substring(1)); + } else { + zOut = Path.GetFullPath(zRelative); // was unicodeToUtf8(zTemp); + } +#endif + } catch (Exception e) { + zOut = zRelative; + } + // will happen on exit; was free(zTemp); + /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. + ** Since the ASCII version of these Windows API do not exist for WINCE, + ** it's important to not reference them for WINCE builds. + */ #if !SQLITE_OS_WINCE - } - else - { - Debugger.Break(); // -- Not Running under NT - //string zTemp; - //nByte = GetFullPathNameA(zConverted, 0, 0, 0) + 3; - //zTemp = malloc( nByte*sizeof(zTemp[0]) ); - //if( zTemp==0 ){ - // free(zConverted); - // return SQLITE_NOMEM; - //} - //GetFullPathNameA( zConverted, nByte, zTemp, 0); - // free(zConverted); - //zOut = sqlite3_win32_mbcs_to_utf8(zTemp); - // free(zTemp); + } else { + Debugger.Break(); // -- Not Running under NT + //string zTemp; + //nByte = GetFullPathNameA(zConverted, 0, 0, 0) + 3; + //zTemp = malloc( nByte*sizeof(zTemp[0]) ); + //if( zTemp==0 ){ + // free(zConverted); + // return SQLITE_NOMEM; + //} + //GetFullPathNameA( zConverted, nByte, zTemp, 0); + // free(zConverted); + //zOut = sqlite3_win32_mbcs_to_utf8(zTemp); + // free(zTemp); #endif - } - if ( zOut != null ) - { - // sqlite3_snprintf(pVfs.mxPathname, zFull, "%s", zOut); - if ( zFull.Length > pVfs.mxPathname ) - zFull.Length = pVfs.mxPathname; - zFull.Append( zOut ); - - // will happen on exit; was free(zOut); - return SQLITE_OK; - } - else - { - return SQLITE_NOMEM; - } + } + if (zOut != null) { + // sqlite3_snprintf(pVfs.mxPathname, zFull, "%s", zOut); + if (zFull.Length > pVfs.mxPathname) + zFull.Length = pVfs.mxPathname; + zFull.Append(zOut); + + // will happen on exit; was free(zOut); + return SQLITE_OK; + } else { + return SQLITE_NOMEM; + } #endif - } + } - /* - ** Get the sector size of the device used to store - ** file. - */ - static int getSectorSize( - sqlite3_vfs pVfs, - string zRelative /* UTF-8 file name */ - ) - { + /* + ** Get the sector size of the device used to store + ** file. + */ + static int getSectorSize( + sqlite3_vfs pVfs, + string zRelative /* UTF-8 file name */ + ) { #if FALSE int bytesPerSector = SQLITE_DEFAULT_SECTOR_SIZE; /* GetDiskFreeSpace is not supported under WINCE */ @@ -3356,76 +3189,72 @@ string zRelative /* UTF-8 file name */ #endif return bytesPerSector == 0 ? SQLITE_DEFAULT_SECTOR_SIZE : bytesPerSector; #endif - return SQLITE_DEFAULT_SECTOR_SIZE; - } + return SQLITE_DEFAULT_SECTOR_SIZE; + } #if !SQLITE_OMIT_LOAD_EXTENSION - /* -** Interfaces for opening a shared library, finding entry points -** within the shared library, and closing the shared library. -*/ - /* + /* ** Interfaces for opening a shared library, finding entry points ** within the shared library, and closing the shared library. */ - //static void winDlOpen(sqlite3_vfs pVfs, string zFilename){ - // HANDLE h; - // void *zConverted = convertUtf8Filename(zFilename); - // UNUSED_PARAMETER(pVfs); - // if( zConverted==0 ){ - // return 0; - // } - // if( isNT() ){ - // h = LoadLibraryW((WCHAR)zConverted); - /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. - ** Since the ASCII version of these Windows API do not exist for WINCE, - ** it's important to not reference them for WINCE builds. - */ + /* + ** Interfaces for opening a shared library, finding entry points + ** within the shared library, and closing the shared library. + */ + //static void winDlOpen(sqlite3_vfs pVfs, string zFilename){ + // HANDLE h; + // void *zConverted = convertUtf8Filename(zFilename); + // UNUSED_PARAMETER(pVfs); + // if( zConverted==0 ){ + // return 0; + // } + // if( isNT() ){ + // h = LoadLibraryW((WCHAR)zConverted); + /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. + ** Since the ASCII version of these Windows API do not exist for WINCE, + ** it's important to not reference them for WINCE builds. + */ #if !SQLITE_OS_WINCE - // }else{ - // h = LoadLibraryA((char)zConverted); -#endif - // } - // free(zConverted); - // return (void)h; - //} - //static void winDlError(sqlite3_vfs pVfs, int nBuf, string zBufOut){ - // UNUSED_PARAMETER(pVfs); - // getLastErrorMsg(nBuf, zBufOut); - //} - // static object winDlSym(sqlite3_vfs pVfs, HANDLE pHandle, String zSymbol){ - // UNUSED_PARAMETER(pVfs); - //#if SQLITE_OS_WINCE - // /* The GetProcAddressA() routine is only available on wince. */ - // return GetProcAddressA((HANDLE)pHandle, zSymbol); - //#else - // /* All other windows platforms expect GetProcAddress() to take - // ** an Ansi string regardless of the _UNICODE setting */ - // return GetProcAddress((HANDLE)pHandle, zSymbol); - //#endif - // } - // static void winDlClose( sqlite3_vfs pVfs, HANDLE pHandle ) - // { - // UNUSED_PARAMETER(pVfs); - // FreeLibrary((HANDLE)pHandle); - // } - //TODO -- Fix This - static HANDLE winDlOpen( sqlite3_vfs vfs, string zFilename ) - { - return new HANDLE(); - } - static int winDlError( sqlite3_vfs vfs, int nByte, string zErrMsg ) - { - return 0; - } - static HANDLE winDlSym( sqlite3_vfs vfs, HANDLE data, string zSymbol ) - { - return new HANDLE(); - } - static int winDlClose( sqlite3_vfs vfs, HANDLE data ) - { - return 0; - } + // }else{ + // h = LoadLibraryA((char)zConverted); +#endif + // } + // free(zConverted); + // return (void)h; + //} + //static void winDlError(sqlite3_vfs pVfs, int nBuf, string zBufOut){ + // UNUSED_PARAMETER(pVfs); + // getLastErrorMsg(nBuf, zBufOut); + //} + // static object winDlSym(sqlite3_vfs pVfs, HANDLE pHandle, String zSymbol){ + // UNUSED_PARAMETER(pVfs); + //#if SQLITE_OS_WINCE + // /* The GetProcAddressA() routine is only available on wince. */ + // return GetProcAddressA((HANDLE)pHandle, zSymbol); + //#else + // /* All other windows platforms expect GetProcAddress() to take + // ** an Ansi string regardless of the _UNICODE setting */ + // return GetProcAddress((HANDLE)pHandle, zSymbol); + //#endif + // } + // static void winDlClose( sqlite3_vfs pVfs, HANDLE pHandle ) + // { + // UNUSED_PARAMETER(pVfs); + // FreeLibrary((HANDLE)pHandle); + // } + //TODO -- Fix This + static HANDLE winDlOpen(sqlite3_vfs vfs, string zFilename) { + return new HANDLE(); + } + static int winDlError(sqlite3_vfs vfs, int nByte, string zErrMsg) { + return 0; + } + static HANDLE winDlSym(sqlite3_vfs vfs, HANDLE data, string zSymbol) { + return new HANDLE(); + } + static int winDlClose(sqlite3_vfs vfs, HANDLE data) { + return 0; + } #else // * if SQLITE_OMIT_LOAD_EXTENSION is defined: */ static object winDlOpen(ref sqlite3_vfs vfs, string zFilename) { return null; } static int winDlError(ref sqlite3_vfs vfs, int nByte, ref string zErrMsg) { return 0; } @@ -3434,92 +3263,87 @@ static int winDlClose( sqlite3_vfs vfs, HANDLE data ) #endif - /* -** Write up to nBuf bytes of randomness into zBuf. -*/ + /* + ** Write up to nBuf bytes of randomness into zBuf. + */ - //[StructLayout( LayoutKind.Explicit, Size = 16, CharSet = CharSet.Ansi )] - //public class _SYSTEMTIME - //{ - // [FieldOffset( 0 )] - // public u32 byte_0_3; - // [FieldOffset( 4 )] - // public u32 byte_4_7; - // [FieldOffset( 8 )] - // public u32 byte_8_11; - // [FieldOffset( 12 )] - // public u32 byte_12_15; - //} - //[DllImport( "Kernel32.dll" )] - //private static extern bool QueryPerformanceCounter( out long lpPerformanceCount ); - - static int winRandomness( sqlite3_vfs pVfs, int nBuf, byte[] zBuf ) - { - int n = 0; - UNUSED_PARAMETER( pVfs ); + //[StructLayout( LayoutKind.Explicit, Size = 16, CharSet = CharSet.Ansi )] + //public class _SYSTEMTIME + //{ + // [FieldOffset( 0 )] + // public u32 byte_0_3; + // [FieldOffset( 4 )] + // public u32 byte_4_7; + // [FieldOffset( 8 )] + // public u32 byte_8_11; + // [FieldOffset( 12 )] + // public u32 byte_12_15; + //} + //[DllImport( "Kernel32.dll" )] + //private static extern bool QueryPerformanceCounter( out long lpPerformanceCount ); + + static int winRandomness(sqlite3_vfs pVfs, int nBuf, byte[] zBuf) { + int n = 0; + UNUSED_PARAMETER(pVfs); #if (SQLITE_TEST) n = nBuf; Array.Clear( zBuf, 0, n );// memset( zBuf, 0, nBuf ); #else -byte[] sBuf = BitConverter.GetBytes(System.DateTime.Now.Ticks); -zBuf[0] = sBuf[0]; -zBuf[1] = sBuf[1]; -zBuf[2] = sBuf[2]; -zBuf[3] = sBuf[3]; -;// memcpy(&zBuf[n], x, sizeof(x)) -n += 16;// sizeof(x); -if ( sizeof( DWORD ) <= nBuf - n ) -{ -//DWORD pid = GetCurrentProcessId(); -u32 processId; + byte[] sBuf = BitConverter.GetBytes(System.DateTime.Now.Ticks); + zBuf[0] = sBuf[0]; + zBuf[1] = sBuf[1]; + zBuf[2] = sBuf[2]; + zBuf[3] = sBuf[3]; + ;// memcpy(&zBuf[n], x, sizeof(x)) + n += 16;// sizeof(x); + if (sizeof(DWORD) <= nBuf - n) { + //DWORD pid = GetCurrentProcessId(); + u32 processId; #if !(SQLITE_SILVERLIGHT || SQLITE_WINRT) -processId = (u32)Process.GetCurrentProcess().Id; + processId = (u32)Process.GetCurrentProcess().Id; #else processId = 28376023; #endif -put32bits( zBuf, n, processId);//(memcpy(&zBuf[n], pid, sizeof(pid)); -n += 4;// sizeof(pid); -} -if ( sizeof( DWORD ) <= nBuf - n ) -{ -//DWORD cnt = GetTickCount(); -System.DateTime dt = new System.DateTime(); -put32bits( zBuf, n, (u32)dt.Ticks );// memcpy(&zBuf[n], cnt, sizeof(cnt)); -n += 4;// cnt.Length; -} -if ( sizeof( long ) <= nBuf - n ) -{ -long i; -i = System.DateTime.UtcNow.Millisecond;// QueryPerformanceCounter(out i); -put32bits( zBuf, n, (u32)( i & 0xFFFFFFFF ) );//memcpy(&zBuf[n], i, sizeof(i)); -put32bits( zBuf, n, (u32)( i >> 32 ) ); -n += sizeof( long ); -} + put32bits(zBuf, n, processId);//(memcpy(&zBuf[n], pid, sizeof(pid)); + n += 4;// sizeof(pid); + } + if (sizeof(DWORD) <= nBuf - n) { + //DWORD cnt = GetTickCount(); + System.DateTime dt = new System.DateTime(); + put32bits(zBuf, n, (u32)dt.Ticks);// memcpy(&zBuf[n], cnt, sizeof(cnt)); + n += 4;// cnt.Length; + } + if (sizeof(long) <= nBuf - n) { + long i; + i = System.DateTime.UtcNow.Millisecond;// QueryPerformanceCounter(out i); + put32bits(zBuf, n, (u32)(i & 0xFFFFFFFF));//memcpy(&zBuf[n], i, sizeof(i)); + put32bits(zBuf, n, (u32)(i >> 32)); + n += sizeof(long); + } #endif - return n; - } + return n; + } - /* - ** Sleep for a little while. Return the amount of time slept. - */ - static int winSleep( sqlite3_vfs pVfs, int microsec ) - { + /* + ** Sleep for a little while. Return the amount of time slept. + */ + static int winSleep(sqlite3_vfs pVfs, int microsec) { #if SQLITE_WINRT System.Threading.Tasks.Task.Delay(((microsec + 999) / 1000)).Wait(); #else - Thread.Sleep(((microsec + 999) / 1000)); + Thread.Sleep(((microsec + 999) / 1000)); #endif - UNUSED_PARAMETER( pVfs ); - return ( ( microsec + 999 ) / 1000 ) * 1000; - } + UNUSED_PARAMETER(pVfs); + return ((microsec + 999) / 1000) * 1000; + } - /* - ** The following variable, if set to a non-zero value, is interpreted as - ** the number of seconds since 1970 and is used to set the result of - ** sqlite3OsCurrentTime() during testing. - */ + /* + ** The following variable, if set to a non-zero value, is interpreted as + ** the number of seconds since 1970 and is used to set the result of + ** sqlite3OsCurrentTime() during testing. + */ #if SQLITE_TEST #if !TCLSH static int sqlite3_current_time = 0;// /* Fake system time in seconds since 1970. */ @@ -3528,53 +3352,52 @@ static int winSleep( sqlite3_vfs pVfs, int microsec ) #endif #endif - /* -** Find the current time (in Universal Coordinated Time). Write into *piNow -** the current time and date as a Julian Day number times 86_400_000. In -** other words, write into *piNow the number of milliseconds since the Julian -** epoch of noon in Greenwich on November 24, 4714 B.C according to the -** proleptic Gregorian calendar. -** -** On success, return 0. Return 1 if the time and date cannot be found. -*/ - static int winCurrentTimeInt64( sqlite3_vfs pVfs, ref sqlite3_int64 piNow ) - { - /* FILETIME structure is a 64-bit value representing the number of - 100-nanosecond intervals since January 1, 1601 (= JD 2305813.5). - */ - //var ft = new FILETIME(); + /* + ** Find the current time (in Universal Coordinated Time). Write into *piNow + ** the current time and date as a Julian Day number times 86_400_000. In + ** other words, write into *piNow the number of milliseconds since the Julian + ** epoch of noon in Greenwich on November 24, 4714 B.C according to the + ** proleptic Gregorian calendar. + ** + ** On success, return 0. Return 1 if the time and date cannot be found. + */ + static int winCurrentTimeInt64(sqlite3_vfs pVfs, ref sqlite3_int64 piNow) { + /* FILETIME structure is a 64-bit value representing the number of + 100-nanosecond intervals since January 1, 1601 (= JD 2305813.5). + */ + //var ft = new FILETIME(); #if SQLITE_WINRT const sqlite3_int64 winRtEpoc = 17214255 * (sqlite3_int64)8640000; #else - const sqlite3_int64 winFiletimeEpoch = 23058135 * (sqlite3_int64)8640000; + const sqlite3_int64 winFiletimeEpoch = 23058135 * (sqlite3_int64)8640000; #endif #if SQLITE_TEST const sqlite3_int64 unixEpoch = 24405875 * (sqlite3_int64)8640000; #endif - ///* 2^32 - to avoid use of LL and warnings in gcc */ - //const sqlite3_int64 max32BitValue = - //(sqlite3_int64)2000000000 + (sqlite3_int64)2000000000 + (sqlite3_int64)294967296; - - //#if SQLITE_OS_WINCE - //SYSTEMTIME time; - //GetSystemTime(&time); - ///* if SystemTimeToFileTime() fails, it returns zero. */ - //if (!SystemTimeToFileTime(&time,&ft)){ - //return 1; - //} - //#else - // GetSystemTimeAsFileTime( ref ft ); - // ft = System.DateTime.UtcNow.ToFileTime(); - //#endif - //sqlite3_int64 ft = System.DateTime.UtcNow.ToFileTime(); - //piNow = winFiletimeEpoch + ft; - //((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) + - // (sqlite3_int64)ft.dwLowDateTime)/(sqlite3_int64)10000; + ///* 2^32 - to avoid use of LL and warnings in gcc */ + //const sqlite3_int64 max32BitValue = + //(sqlite3_int64)2000000000 + (sqlite3_int64)2000000000 + (sqlite3_int64)294967296; + + //#if SQLITE_OS_WINCE + //SYSTEMTIME time; + //GetSystemTime(&time); + ///* if SystemTimeToFileTime() fails, it returns zero. */ + //if (!SystemTimeToFileTime(&time,&ft)){ + //return 1; + //} + //#else + // GetSystemTimeAsFileTime( ref ft ); + // ft = System.DateTime.UtcNow.ToFileTime(); + //#endif + //sqlite3_int64 ft = System.DateTime.UtcNow.ToFileTime(); + //piNow = winFiletimeEpoch + ft; + //((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) + + // (sqlite3_int64)ft.dwLowDateTime)/(sqlite3_int64)10000; #if SQLITE_WINRT piNow = winRtEpoc + System.DateTime.UtcNow.Ticks / (sqlite3_int64)10000; #else - piNow = winFiletimeEpoch + System.DateTime.UtcNow.ToFileTimeUtc() / (sqlite3_int64)10000; + piNow = winFiletimeEpoch + System.DateTime.UtcNow.ToFileTimeUtc() / (sqlite3_int64)10000; #endif #if SQLITE_TEST #if !TCLSH @@ -3589,95 +3412,91 @@ static int winCurrentTimeInt64( sqlite3_vfs pVfs, ref sqlite3_int64 piNow ) } #endif #endif - UNUSED_PARAMETER( pVfs ); - return 0; - } + UNUSED_PARAMETER(pVfs); + return 0; + } - /* - ** Find the current time (in Universal Coordinated Time). Write the - ** current time and date as a Julian Day number into *prNow and - ** return 0. Return 1 if the time and date cannot be found. - */ - static int winCurrentTime( sqlite3_vfs pVfs, ref double prNow ) - { - int rc; - sqlite3_int64 i = 0; - rc = winCurrentTimeInt64( pVfs, ref i ); - if ( 0 == rc ) - { - prNow = i / 86400000.0; - } - return rc; - } + /* + ** Find the current time (in Universal Coordinated Time). Write the + ** current time and date as a Julian Day number into *prNow and + ** return 0. Return 1 if the time and date cannot be found. + */ + static int winCurrentTime(sqlite3_vfs pVfs, ref double prNow) { + int rc; + sqlite3_int64 i = 0; + rc = winCurrentTimeInt64(pVfs, ref i); + if (0 == rc) { + prNow = i / 86400000.0; + } + return rc; + } - /* - ** The idea is that this function works like a combination of - ** GetLastError() and FormatMessage() on windows (or errno and - ** strerror_r() on unix). After an error is returned by an OS - ** function, SQLite calls this function with zBuf pointing to - ** a buffer of nBuf bytes. The OS layer should populate the - ** buffer with a nul-terminated UTF-8 encoded error message - ** describing the last IO error to have occurred within the calling - ** thread. - ** - ** If the error message is too large for the supplied buffer, - ** it should be truncated. The return value of xGetLastError - ** is zero if the error message fits in the buffer, or non-zero - ** otherwise (if the message was truncated). If non-zero is returned, - ** then it is not necessary to include the nul-terminator character - ** in the output buffer. - ** - ** Not supplying an error message will have no adverse effect - ** on SQLite. It is fine to have an implementation that never - ** returns an error message: - ** - ** int xGetLastError(sqlite3_vfs pVfs, int nBuf, string zBuf){ - ** Debug.Assert(zBuf[0]=='\0'); - ** return 0; - ** } - ** - ** However if an error message is supplied, it will be incorporated - ** by sqlite into the error message available to the user using - ** sqlite3_errmsg(), possibly making IO errors easier to debug. - */ - static int winGetLastError( sqlite3_vfs pVfs, int nBuf, ref string zBuf ) - { - UNUSED_PARAMETER( pVfs ); - return getLastErrorMsg( nBuf, ref zBuf ); - } + /* + ** The idea is that this function works like a combination of + ** GetLastError() and FormatMessage() on windows (or errno and + ** strerror_r() on unix). After an error is returned by an OS + ** function, SQLite calls this function with zBuf pointing to + ** a buffer of nBuf bytes. The OS layer should populate the + ** buffer with a nul-terminated UTF-8 encoded error message + ** describing the last IO error to have occurred within the calling + ** thread. + ** + ** If the error message is too large for the supplied buffer, + ** it should be truncated. The return value of xGetLastError + ** is zero if the error message fits in the buffer, or non-zero + ** otherwise (if the message was truncated). If non-zero is returned, + ** then it is not necessary to include the nul-terminator character + ** in the output buffer. + ** + ** Not supplying an error message will have no adverse effect + ** on SQLite. It is fine to have an implementation that never + ** returns an error message: + ** + ** int xGetLastError(sqlite3_vfs pVfs, int nBuf, string zBuf){ + ** Debug.Assert(zBuf[0]=='\0'); + ** return 0; + ** } + ** + ** However if an error message is supplied, it will be incorporated + ** by sqlite into the error message available to the user using + ** sqlite3_errmsg(), possibly making IO errors easier to debug. + */ + static int winGetLastError(sqlite3_vfs pVfs, int nBuf, ref string zBuf) { + UNUSED_PARAMETER(pVfs); + return getLastErrorMsg(nBuf, ref zBuf); + } - static sqlite3_vfs winVfs = new sqlite3_vfs( - 3, /* iVersion */ - -1, //sqlite3_file.Length, /* szOsFile */ - MAX_PATH, /* mxPathname */ - null, /* pNext */ - "win32", /* zName */ - 0, /* pAppData */ - - (dxOpen)winOpen, /* xOpen */ - (dxDelete)winDelete, /* xDelete */ - (dxAccess)winAccess, /* xAccess */ - (dxFullPathname)winFullPathname,/* xFullPathname */ - (dxDlOpen)winDlOpen, /* xDlOpen */ - (dxDlError)winDlError, /* xDlError */ - (dxDlSym)winDlSym, /* xDlSym */ - (dxDlClose)winDlClose, /* xDlClose */ - (dxRandomness)winRandomness, /* xRandomness */ - (dxSleep)winSleep, /* xSleep */ - (dxCurrentTime)winCurrentTime, /* xCurrentTime */ - (dxGetLastError)winGetLastError,/* xGetLastError */ - (dxCurrentTimeInt64)winCurrentTimeInt64, /* xCurrentTimeInt64 */ - null, /* xSetSystemCall */ - null, /* xGetSystemCall */ - null /* xNextSystemCall */ - ); + static sqlite3_vfs winVfs = new sqlite3_vfs( + 3, /* iVersion */ + -1, //sqlite3_file.Length, /* szOsFile */ + MAX_PATH, /* mxPathname */ + null, /* pNext */ + "win32", /* zName */ + 0, /* pAppData */ + + (dxOpen)winOpen, /* xOpen */ + (dxDelete)winDelete, /* xDelete */ + (dxAccess)winAccess, /* xAccess */ + (dxFullPathname)winFullPathname,/* xFullPathname */ + (dxDlOpen)winDlOpen, /* xDlOpen */ + (dxDlError)winDlError, /* xDlError */ + (dxDlSym)winDlSym, /* xDlSym */ + (dxDlClose)winDlClose, /* xDlClose */ + (dxRandomness)winRandomness, /* xRandomness */ + (dxSleep)winSleep, /* xSleep */ + (dxCurrentTime)winCurrentTime, /* xCurrentTime */ + (dxGetLastError)winGetLastError,/* xGetLastError */ + (dxCurrentTimeInt64)winCurrentTimeInt64, /* xCurrentTimeInt64 */ + null, /* xSetSystemCall */ + null, /* xGetSystemCall */ + null /* xNextSystemCall */ + ); - /* - ** Initialize and deinitialize the operating system interface. - */ - static int sqlite3_os_init() - { + /* + ** Initialize and deinitialize the operating system interface. + */ + static int sqlite3_os_init() { #if !SQLITE_OMIT_WAL /* get memory map allocation granularity */ memset(&winSysInfo, 0, sizeof(SYSTEM_INFO)); @@ -3685,104 +3504,93 @@ static int sqlite3_os_init() Debug.Assert(winSysInfo.dwAllocationGranularity > 0); #endif - sqlite3_vfs_register( winVfs, 1 ); - return SQLITE_OK; - } + sqlite3_vfs_register(winVfs, 1); + return SQLITE_OK; + } - static int sqlite3_os_end() - { - return SQLITE_OK; - } + static int sqlite3_os_end() { + return SQLITE_OK; + } #endif // * SQLITE_OS_WIN */ - // - // Windows DLL definitions - // - - const int NO_ERROR = 0; - /// - /// Basic locking strategy for Console/Winform applications - /// - private class LockingStrategy - { + // + // Windows DLL definitions + // + + const int NO_ERROR = 0; + /// + /// Basic locking strategy for Console/Winform applications + /// + private class LockingStrategy { #if !(SQLITE_SILVERLIGHT || WINDOWS_MOBILE || SQLITE_WINRT) - [DllImport( "kernel32.dll" )] - static extern bool LockFileEx( IntPtr hFile, uint dwFlags, uint dwReserved, - uint nNumberOfBytesToLockLow, uint nNumberOfBytesToLockHigh, - [In] ref System.Threading.NativeOverlapped lpOverlapped ); + [DllImport("kernel32.dll")] + static extern bool LockFileEx(IntPtr hFile, uint dwFlags, uint dwReserved, + uint nNumberOfBytesToLockLow, uint nNumberOfBytesToLockHigh, + [In] ref System.Threading.NativeOverlapped lpOverlapped); - const int LOCKFILE_FAIL_IMMEDIATELY = 1; + const int LOCKFILE_FAIL_IMMEDIATELY = 1; #endif - public virtual void LockFile( sqlite3_file pFile, long offset, long length ) - { + public virtual void LockFile(sqlite3_file pFile, long offset, long length) { #pragma warning disable CA1416 // Validate platform compatibility - pFile.fs.Lock( offset, length ); + pFile.fs.Lock(offset, length); #pragma warning restore CA1416 // Validate platform compatibility - } + } - public virtual int SharedLockFile( sqlite3_file pFile, long offset, long length ) - { + public virtual int SharedLockFile(sqlite3_file pFile, long offset, long length) { #if !(SQLITE_SILVERLIGHT || WINDOWS_MOBILE || SQLITE_WINRT) #if FEATURE_RUNTIMEINFORMATION - Debug.Assert(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); + Debug.Assert(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); #endif - Debug.Assert( length == SHARED_SIZE ); - Debug.Assert( offset == SHARED_FIRST ); - NativeOverlapped ovlp = new NativeOverlapped(); - ovlp.OffsetLow = (int)offset; - ovlp.OffsetHigh = 0; - ovlp.EventHandle = IntPtr.Zero; + Debug.Assert(length == SHARED_SIZE); + Debug.Assert(offset == SHARED_FIRST); + NativeOverlapped ovlp = new NativeOverlapped(); + ovlp.OffsetLow = (int)offset; + ovlp.OffsetHigh = 0; + ovlp.EventHandle = IntPtr.Zero; - return LockFileEx( pFile.fs.Handle, LOCKFILE_FAIL_IMMEDIATELY, 0, (uint)length, 0, ref ovlp ) ? 1 : 0; + return LockFileEx(pFile.fs.Handle, LOCKFILE_FAIL_IMMEDIATELY, 0, (uint)length, 0, ref ovlp) ? 1 : 0; #else return 1; #endif - } + } - public virtual void UnlockFile( sqlite3_file pFile, long offset, long length ) - { + public virtual void UnlockFile(sqlite3_file pFile, long offset, long length) { #if !(SQLITE_SILVERLIGHT || WINDOWS_MOBILE || SQLITE_WINRT) #pragma warning disable CA1416 // Validate platform compatibility - pFile.fs.Unlock( offset, length ); + pFile.fs.Unlock(offset, length); #pragma warning restore CA1416 // Validate platform compatibility #endif - } - } + } + } - /// - /// Locking strategy for Medium Trust. It uses the same trick used in the native code for WIN_CE - /// which doesn't support LockFileEx as well. - /// - private class MediumTrustLockingStrategy : LockingStrategy - { - public override int SharedLockFile( sqlite3_file pFile, long offset, long length ) - { + /// + /// Locking strategy for Medium Trust. It uses the same trick used in the native code for WIN_CE + /// which doesn't support LockFileEx as well. + /// + private class MediumTrustLockingStrategy : LockingStrategy { + public override int SharedLockFile(sqlite3_file pFile, long offset, long length) { #if !(SQLITE_SILVERLIGHT || WINDOWS_MOBILE || SQLITE_WINRT) - Debug.Assert( length == SHARED_SIZE ); - Debug.Assert( offset == SHARED_FIRST ); - try - { + Debug.Assert(length == SHARED_SIZE); + Debug.Assert(offset == SHARED_FIRST); + try { #pragma warning disable CA1416 // Validate platform compatibility - pFile.fs.Lock( offset + pFile.sharedLockByte, 1 ); + pFile.fs.Lock(offset + pFile.sharedLockByte, 1); #pragma warning restore CA1416 // Validate platform compatibility - } - catch ( IOException ) - { - return 0; - } + } catch (IOException) { + return 0; + } #endif - return 1; - } + return 1; + } + } } - } - internal static class HelperMethods - { - public static bool IsRunningMediumTrust() { - // placeholder method - // this is where it needs to check if it's running in an ASP.Net MediumTrust or lower environment - // in order to pick the appropriate locking strategy - return Environment.OSVersion.Platform == PlatformID.Unix; - } + internal static class HelperMethods { + public static bool IsRunningMediumTrust() { + // placeholder method + // this is where it needs to check if it's running in an ASP.Net MediumTrust or lower environment + // in order to pick the appropriate locking strategy + return Environment.OSVersion.Platform == PlatformID.Unix; + } #if SQLITE_WINRT public static bool FileExists(string path) @@ -3803,9 +3611,8 @@ public static bool FileExists(string path) } #endif - public static int GetLastError() - { - return Marshal.GetLastWin32Error(); + public static int GetLastError() { + return Marshal.GetLastWin32Error(); + } } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/pager_c.cs b/Src/IronPython.SQLite/c#sqlite/pager_c.cs index 5f1d731ea..d1c33acd3 100644 --- a/Src/IronPython.SQLite/c#sqlite/pager_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/pager_c.cs @@ -1,150 +1,146 @@ using System; using System.Diagnostics; -using System.IO; using i16 = System.Int16; using i64 = System.Int64; - -using u8 = System.Byte; +using Pgno = System.UInt32; +using sqlite3_int64 = System.Int64; using u16 = System.UInt16; using u32 = System.UInt32; +using u8 = System.Byte; -using Pgno = System.UInt32; -using sqlite3_int64 = System.Int64; +namespace Community.CsharpSqlite { + using System.Text; -namespace Community.CsharpSqlite -{ - using System.Text; - using DbPage = Sqlite3.PgHdr; - public partial class Sqlite3 - { - /* - ** 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. - ** - ************************************************************************* - ** This is the implementation of the page cache subsystem or "pager". - ** - ** The pager is used to access a database disk file. It implements - ** atomic commit and rollback through the use of a journal file that - ** is separate from the database file. The pager also implements file - ** locking to prevent two processes from writing the same database - ** file simultaneously, or one process from reading the database while - ** another is writing. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ + using DbPage = Sqlite3.PgHdr; + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** This is the implementation of the page cache subsystem or "pager". + ** + ** The pager is used to access a database disk file. It implements + ** atomic commit and rollback through the use of a journal file that + ** is separate from the database file. The pager also implements file + ** locking to prevent two processes from writing the same database + ** file simultaneously, or one process from reading the database while + ** another is writing. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ #if !SQLITE_OMIT_DISKIO - //#include "sqliteInt.h" - //#include "wal.h" + //#include "sqliteInt.h" + //#include "wal.h" - /******************* NOTES ON THE DESIGN OF THE PAGER ************************ - ** - ** This comment block describes invariants that hold when using a rollback - ** journal. These invariants do not apply for journal_mode=WAL, - ** journal_mode=MEMORY, or journal_mode=OFF. - ** - ** Within this comment block, a page is deemed to have been synced - ** automatically as soon as it is written when PRAGMA synchronous=OFF. - ** Otherwise, the page is not synced until the xSync method of the VFS - ** is called successfully on the file containing the page. - ** - ** Definition: A page of the database file is said to be "overwriteable" if - ** one or more of the following are true about the page: - ** - ** (a) The original content of the page as it was at the beginning of - ** the transaction has been written into the rollback journal and - ** synced. - ** - ** (b) The page was a freelist leaf page at the start of the transaction. - ** - ** (c) The page number is greater than the largest page that existed in - ** the database file at the start of the transaction. - ** - ** (1) A page of the database file is never overwritten unless one of the - ** following are true: - ** - ** (a) The page and all other pages on the same sector are overwriteable. - ** - ** (b) The atomic page write optimization is enabled, and the entire - ** transaction other than the update of the transaction sequence - ** number consists of a single page change. - ** - ** (2) The content of a page written into the rollback journal exactly matches - ** both the content in the database when the rollback journal was written - ** and the content in the database at the beginning of the current - ** transaction. - ** - ** (3) Writes to the database file are an integer multiple of the page size - ** in length and are aligned on a page boundary. - ** - ** (4) Reads from the database file are either aligned on a page boundary and - ** an integer multiple of the page size in length or are taken from the - ** first 100 bytes of the database file. - ** - ** (5) All writes to the database file are synced prior to the rollback journal - ** being deleted, truncated, or zeroed. - ** - ** (6) If a master journal file is used, then all writes to the database file - ** are synced prior to the master journal being deleted. - ** - ** Definition: Two databases (or the same database at two points it time) - ** are said to be "logically equivalent" if they give the same answer to - ** all queries. Note in particular the the content of freelist leaf - ** pages can be changed arbitarily without effecting the logical equivalence - ** of the database. - ** - ** (7) At any time, if any subset, including the empty set and the total set, - ** of the unsynced changes to a rollback journal are removed and the - ** journal is rolled back, the resulting database file will be logical - ** equivalent to the database file at the beginning of the transaction. - ** - ** (8) When a transaction is rolled back, the xTruncate method of the VFS - ** is called to restore the database file to the same size it was at - ** the beginning of the transaction. (In some VFSes, the xTruncate - ** method is a no-op, but that does not change the fact the SQLite will - ** invoke it.) - ** - ** (9) Whenever the database file is modified, at least one bit in the range - ** of bytes from 24 through 39 inclusive will be changed prior to releasing - ** the EXCLUSIVE lock, thus signaling other connections on the same - ** database to flush their caches. - ** - ** (10) The pattern of bits in bytes 24 through 39 shall not repeat in less - ** than one billion transactions. - ** - ** (11) A database file is well-formed at the beginning and at the conclusion - ** of every transaction. - ** - ** (12) An EXCLUSIVE lock is held on the database file when writing to - ** the database file. - ** - ** (13) A SHARED lock is held on the database file while reading any - ** content out of the database file. - ** - ******************************************************************************/ + /******************* NOTES ON THE DESIGN OF THE PAGER ************************ + ** + ** This comment block describes invariants that hold when using a rollback + ** journal. These invariants do not apply for journal_mode=WAL, + ** journal_mode=MEMORY, or journal_mode=OFF. + ** + ** Within this comment block, a page is deemed to have been synced + ** automatically as soon as it is written when PRAGMA synchronous=OFF. + ** Otherwise, the page is not synced until the xSync method of the VFS + ** is called successfully on the file containing the page. + ** + ** Definition: A page of the database file is said to be "overwriteable" if + ** one or more of the following are true about the page: + ** + ** (a) The original content of the page as it was at the beginning of + ** the transaction has been written into the rollback journal and + ** synced. + ** + ** (b) The page was a freelist leaf page at the start of the transaction. + ** + ** (c) The page number is greater than the largest page that existed in + ** the database file at the start of the transaction. + ** + ** (1) A page of the database file is never overwritten unless one of the + ** following are true: + ** + ** (a) The page and all other pages on the same sector are overwriteable. + ** + ** (b) The atomic page write optimization is enabled, and the entire + ** transaction other than the update of the transaction sequence + ** number consists of a single page change. + ** + ** (2) The content of a page written into the rollback journal exactly matches + ** both the content in the database when the rollback journal was written + ** and the content in the database at the beginning of the current + ** transaction. + ** + ** (3) Writes to the database file are an integer multiple of the page size + ** in length and are aligned on a page boundary. + ** + ** (4) Reads from the database file are either aligned on a page boundary and + ** an integer multiple of the page size in length or are taken from the + ** first 100 bytes of the database file. + ** + ** (5) All writes to the database file are synced prior to the rollback journal + ** being deleted, truncated, or zeroed. + ** + ** (6) If a master journal file is used, then all writes to the database file + ** are synced prior to the master journal being deleted. + ** + ** Definition: Two databases (or the same database at two points it time) + ** are said to be "logically equivalent" if they give the same answer to + ** all queries. Note in particular the the content of freelist leaf + ** pages can be changed arbitarily without effecting the logical equivalence + ** of the database. + ** + ** (7) At any time, if any subset, including the empty set and the total set, + ** of the unsynced changes to a rollback journal are removed and the + ** journal is rolled back, the resulting database file will be logical + ** equivalent to the database file at the beginning of the transaction. + ** + ** (8) When a transaction is rolled back, the xTruncate method of the VFS + ** is called to restore the database file to the same size it was at + ** the beginning of the transaction. (In some VFSes, the xTruncate + ** method is a no-op, but that does not change the fact the SQLite will + ** invoke it.) + ** + ** (9) Whenever the database file is modified, at least one bit in the range + ** of bytes from 24 through 39 inclusive will be changed prior to releasing + ** the EXCLUSIVE lock, thus signaling other connections on the same + ** database to flush their caches. + ** + ** (10) The pattern of bits in bytes 24 through 39 shall not repeat in less + ** than one billion transactions. + ** + ** (11) A database file is well-formed at the beginning and at the conclusion + ** of every transaction. + ** + ** (12) An EXCLUSIVE lock is held on the database file when writing to + ** the database file. + ** + ** (13) A SHARED lock is held on the database file while reading any + ** content out of the database file. + ** + ******************************************************************************/ - /* - ** Macros for troubleshooting. Normally turned off - */ + /* + ** Macros for troubleshooting. Normally turned off + */ #if TRACE -static bool sqlite3PagerTrace = false; /* True to enable tracing */ -//#define sqlite3DebugPrintf printf -//#define PAGERTRACE(X) if( sqlite3PagerTrace ){ sqlite3DebugPrintf X; } -static void PAGERTRACE( string T, params object[] ap ) { if ( sqlite3PagerTrace )sqlite3DebugPrintf( T, ap ); } + static bool sqlite3PagerTrace = false; /* True to enable tracing */ + //#define sqlite3DebugPrintf printf + //#define PAGERTRACE(X) if( sqlite3PagerTrace ){ sqlite3DebugPrintf X; } + static void PAGERTRACE(string T, params object[] ap) { if (sqlite3PagerTrace) sqlite3DebugPrintf(T, ap); } #else //#define PAGERTRACE(X) static void PAGERTRACE( string T, params object[] ap ) @@ -152,317 +148,315 @@ static void PAGERTRACE( string T, params object[] ap ) } #endif - /* -** The following two macros are used within the PAGERTRACE() macros above -** to print out file-descriptors. -** -** PAGERID() takes a pointer to a Pager struct as its argument. The -** associated file-descriptor is returned. FILEHANDLEID() takes an sqlite3_file -** struct as its argument. -*/ - //#define PAGERID(p) ((int)(p.fd)) - static int PAGERID( Pager p ) - { - return p.GetHashCode(); - } - - //#define FILEHANDLEID(fd) ((int)fd) - static int FILEHANDLEID( sqlite3_file fd ) - { - return fd.GetHashCode(); - } - - /* - ** The Pager.eState variable stores the current 'state' of a pager. A - ** pager may be in any one of the seven states shown in the following - ** state diagram. - ** - ** OPEN <------+------+ - ** | | | - ** V | | - ** +---------> READER-------+ | - ** | | | - ** | V | - ** |<-------WRITER_LOCKED------> ERROR - ** | | ^ - ** | V | - ** |<------WRITER_CACHEMOD-------->| - ** | | | - ** | V | - ** |<-------WRITER_DBMOD---------->| - ** | | | - ** | V | - ** +<------WRITER_FINISHED-------->+ - ** - ** - ** List of state transitions and the C [function] that performs each: - ** - ** OPEN -> READER [sqlite3PagerSharedLock] - ** READER -> OPEN [pager_unlock] - ** - ** READER -> WRITER_LOCKED [sqlite3PagerBegin] - ** WRITER_LOCKED -> WRITER_CACHEMOD [pager_open_journal] - ** WRITER_CACHEMOD -> WRITER_DBMOD [syncJournal] - ** WRITER_DBMOD -> WRITER_FINISHED [sqlite3PagerCommitPhaseOne] - ** WRITER_*** -> READER [pager_end_transaction] - ** - ** WRITER_*** -> ERROR [pager_error] - ** ERROR -> OPEN [pager_unlock] - ** - ** - ** OPEN: - ** - ** The pager starts up in this state. Nothing is guaranteed in this - ** state - the file may or may not be locked and the database size is - ** unknown. The database may not be read or written. - ** - ** * No read or write transaction is active. - ** * Any lock, or no lock at all, may be held on the database file. - ** * The dbSize, dbOrigSize and dbFileSize variables may not be trusted. - ** - ** READER: - ** - ** In this state all the requirements for reading the database in - ** rollback (non-WAL) mode are met. Unless the pager is (or recently - ** was) in exclusive-locking mode, a user-level read transaction is - ** open. The database size is known in this state. - ** - ** A connection running with locking_mode=normal enters this state when - ** it opens a read-transaction on the database and returns to state - ** OPEN after the read-transaction is completed. However a connection - ** running in locking_mode=exclusive (including temp databases) remains in - ** this state even after the read-transaction is closed. The only way - ** a locking_mode=exclusive connection can transition from READER to OPEN - ** is via the ERROR state (see below). - ** - ** * A read transaction may be active (but a write-transaction cannot). - ** * A SHARED or greater lock is held on the database file. - ** * The dbSize variable may be trusted (even if a user-level read - ** transaction is not active). The dbOrigSize and dbFileSize variables - ** may not be trusted at this point. - ** * If the database is a WAL database, then the WAL connection is open. - ** * Even if a read-transaction is not open, it is guaranteed that - ** there is no hot-journal in the file-system. - ** - ** WRITER_LOCKED: - ** - ** The pager moves to this state from READER when a write-transaction - ** is first opened on the database. In WRITER_LOCKED state, all locks - ** required to start a write-transaction are held, but no actual - ** modifications to the cache or database have taken place. - ** - ** In rollback mode, a RESERVED or (if the transaction was opened with - ** BEGIN EXCLUSIVE) EXCLUSIVE lock is obtained on the database file when - ** moving to this state, but the journal file is not written to or opened - ** to in this state. If the transaction is committed or rolled back while - ** in WRITER_LOCKED state, all that is required is to unlock the database - ** file. - ** - ** IN WAL mode, WalBeginWriteTransaction() is called to lock the log file. - ** If the connection is running with locking_mode=exclusive, an attempt - ** is made to obtain an EXCLUSIVE lock on the database file. - ** - ** * A write transaction is active. - ** * If the connection is open in rollback-mode, a RESERVED or greater - ** lock is held on the database file. - ** * If the connection is open in WAL-mode, a WAL write transaction - ** is open (i.e. sqlite3WalBeginWriteTransaction() has been successfully - ** called). - ** * The dbSize, dbOrigSize and dbFileSize variables are all valid. - ** * The contents of the pager cache have not been modified. - ** * The journal file may or may not be open. - ** * Nothing (not even the first header) has been written to the journal. - ** - ** WRITER_CACHEMOD: - ** - ** A pager moves from WRITER_LOCKED state to this state when a page is - ** first modified by the upper layer. In rollback mode the journal file - ** is opened (if it is not already open) and a header written to the - ** start of it. The database file on disk has not been modified. - ** - ** * A write transaction is active. - ** * A RESERVED or greater lock is held on the database file. - ** * The journal file is open and the first header has been written - ** to it, but the header has not been synced to disk. - ** * The contents of the page cache have been modified. - ** - ** WRITER_DBMOD: - ** - ** The pager transitions from WRITER_CACHEMOD into WRITER_DBMOD state - ** when it modifies the contents of the database file. WAL connections - ** never enter this state (since they do not modify the database file, - ** just the log file). - ** - ** * A write transaction is active. - ** * An EXCLUSIVE or greater lock is held on the database file. - ** * The journal file is open and the first header has been written - ** and synced to disk. - ** * The contents of the page cache have been modified (and possibly - ** written to disk). - ** - ** WRITER_FINISHED: - ** - ** It is not possible for a WAL connection to enter this state. - ** - ** A rollback-mode pager changes to WRITER_FINISHED state from WRITER_DBMOD - ** state after the entire transaction has been successfully written into the - ** database file. In this state the transaction may be committed simply - ** by finalizing the journal file. Once in WRITER_FINISHED state, it is - ** not possible to modify the database further. At this point, the upper - ** layer must either commit or rollback the transaction. - ** - ** * A write transaction is active. - ** * An EXCLUSIVE or greater lock is held on the database file. - ** * All writing and syncing of journal and database data has finished. - ** If no error occured, all that remains is to finalize the journal to - ** commit the transaction. If an error did occur, the caller will need - ** to rollback the transaction. - ** - ** ERROR: - ** - ** The ERROR state is entered when an IO or disk-full error (including - ** SQLITE_IOERR_NOMEM) occurs at a point in the code that makes it - ** difficult to be sure that the in-memory pager state (cache contents, - ** db size etc.) are consistent with the contents of the file-system. - ** - ** Temporary pager files may enter the ERROR state, but in-memory pagers - ** cannot. - ** - ** For example, if an IO error occurs while performing a rollback, - ** the contents of the page-cache may be left in an inconsistent state. - ** At this point it would be dangerous to change back to READER state - ** (as usually happens after a rollback). Any subsequent readers might - ** report database corruption (due to the inconsistent cache), and if - ** they upgrade to writers, they may inadvertently corrupt the database - ** file. To avoid this hazard, the pager switches into the ERROR state - ** instead of READER following such an error. - ** - ** Once it has entered the ERROR state, any attempt to use the pager - ** to read or write data returns an error. Eventually, once all - ** outstanding transactions have been abandoned, the pager is able to - ** transition back to OPEN state, discarding the contents of the - ** page-cache and any other in-memory state at the same time. Everything - ** is reloaded from disk (and, if necessary, hot-journal rollback peformed) - ** when a read-transaction is next opened on the pager (transitioning - ** the pager into READER state). At that point the system has recovered - ** from the error. - ** - ** Specifically, the pager jumps into the ERROR state if: - ** - ** 1. An error occurs while attempting a rollback. This happens in - ** function sqlite3PagerRollback(). - ** - ** 2. An error occurs while attempting to finalize a journal file - ** following a commit in function sqlite3PagerCommitPhaseTwo(). - ** - ** 3. An error occurs while attempting to write to the journal or - ** database file in function pagerStress() in order to free up - ** memory. - ** - ** In other cases, the error is returned to the b-tree layer. The b-tree - ** layer then attempts a rollback operation. If the error condition - ** persists, the pager enters the ERROR state via condition (1) above. - ** - ** Condition (3) is necessary because it can be triggered by a read-only - ** statement executed within a transaction. In this case, if the error - ** code were simply returned to the user, the b-tree layer would not - ** automatically attempt a rollback, as it assumes that an error in a - ** read-only statement cannot leave the pager in an internally inconsistent - ** state. - ** - ** * The Pager.errCode variable is set to something other than SQLITE_OK. - ** * There are one or more outstanding references to pages (after the - ** last reference is dropped the pager should move back to OPEN state). - ** * The pager is not an in-memory pager. - ** - ** - ** Notes: - ** - ** * A pager is never in WRITER_DBMOD or WRITER_FINISHED state if the - ** connection is open in WAL mode. A WAL connection is always in one - ** of the first four states. - ** - ** * Normally, a connection open in exclusive mode is never in PAGER_OPEN - ** state. There are two exceptions: immediately after exclusive-mode has - ** been turned on (and before any read or write transactions are - ** executed), and when the pager is leaving the "error state". + /* + ** The following two macros are used within the PAGERTRACE() macros above + ** to print out file-descriptors. ** - ** * See also: assert_pager_state(). + ** PAGERID() takes a pointer to a Pager struct as its argument. The + ** associated file-descriptor is returned. FILEHANDLEID() takes an sqlite3_file + ** struct as its argument. */ + //#define PAGERID(p) ((int)(p.fd)) + static int PAGERID(Pager p) { + return p.GetHashCode(); + } - //#define PAGER_OPEN 0 - //#define PAGER_READER 1 - //#define PAGER_WRITER_LOCKED 2 - //#define PAGER_WRITER_CACHEMOD 3 - //#define PAGER_WRITER_DBMOD 4 - //#define PAGER_WRITER_FINISHED 5 - //#define PAGER_ERROR 6 - const int PAGER_OPEN = 0; - const int PAGER_READER = 1; - const int PAGER_WRITER_LOCKED = 2; - const int PAGER_WRITER_CACHEMOD = 3; - const int PAGER_WRITER_DBMOD = 4; - const int PAGER_WRITER_FINISHED = 5; - const int PAGER_ERROR = 6; + //#define FILEHANDLEID(fd) ((int)fd) + static int FILEHANDLEID(sqlite3_file fd) { + return fd.GetHashCode(); + } - /* - ** The Pager.eLock variable is almost always set to one of the - ** following locking-states, according to the lock currently held on - ** the database file: NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK. - ** This variable is kept up to date as locks are taken and released by - ** the pagerLockDb() and pagerUnlockDb() wrappers. - ** - ** If the VFS xLock() or xUnlock() returns an error other than SQLITE_BUSY - ** (i.e. one of the SQLITE_IOERR subtypes), it is not clear whether or not - ** the operation was successful. In these circumstances pagerLockDb() and - ** pagerUnlockDb() take a conservative approach - eLock is always updated - ** when unlocking the file, and only updated when locking the file if the - ** VFS call is successful. This way, the Pager.eLock variable may be set - ** to a less exclusive (lower) value than the lock that is actually held - ** at the system level, but it is never set to a more exclusive value. - ** - ** This is usually safe. If an xUnlock fails or appears to fail, there may - ** be a few redundant xLock() calls or a lock may be held for longer than - ** required, but nothing really goes wrong. - ** - ** The exception is when the database file is unlocked as the pager moves - ** from ERROR to OPEN state. At this point there may be a hot-journal file - ** in the file-system that needs to be rolled back (as part of a OPEN->SHARED - ** transition, by the same pager or any other). If the call to xUnlock() - ** fails at this point and the pager is left holding an EXCLUSIVE lock, this - ** can confuse the call to xCheckReservedLock() call made later as part - ** of hot-journal detection. - ** - ** xCheckReservedLock() is defined as returning true "if there is a RESERVED - ** lock held by this process or any others". So xCheckReservedLock may - ** return true because the caller itself is holding an EXCLUSIVE lock (but - ** doesn't know it because of a previous error in xUnlock). If this happens - ** a hot-journal may be mistaken for a journal being created by an active - ** transaction in another process, causing SQLite to read from the database - ** without rolling it back. - ** - ** To work around this, if a call to xUnlock() fails when unlocking the - ** database in the ERROR state, Pager.eLock is set to UNKNOWN_LOCK. It - ** is only changed back to a real locking state after a successful call - ** to xLock(EXCLUSIVE). Also, the code to do the OPEN->SHARED state transition - ** omits the check for a hot-journal if Pager.eLock is set to UNKNOWN_LOCK - ** lock. Instead, it assumes a hot-journal exists and obtains an EXCLUSIVE - ** lock on the database file before attempting to roll it back. See function - ** PagerSharedLock() for more detail. - ** - ** Pager.eLock may only be set to UNKNOWN_LOCK when the pager is in - ** PAGER_OPEN state. - */ - //#define UNKNOWN_LOCK (EXCLUSIVE_LOCK+1) - const int UNKNOWN_LOCK = ( EXCLUSIVE_LOCK + 1 ); + /* + ** The Pager.eState variable stores the current 'state' of a pager. A + ** pager may be in any one of the seven states shown in the following + ** state diagram. + ** + ** OPEN <------+------+ + ** | | | + ** V | | + ** +---------> READER-------+ | + ** | | | + ** | V | + ** |<-------WRITER_LOCKED------> ERROR + ** | | ^ + ** | V | + ** |<------WRITER_CACHEMOD-------->| + ** | | | + ** | V | + ** |<-------WRITER_DBMOD---------->| + ** | | | + ** | V | + ** +<------WRITER_FINISHED-------->+ + ** + ** + ** List of state transitions and the C [function] that performs each: + ** + ** OPEN -> READER [sqlite3PagerSharedLock] + ** READER -> OPEN [pager_unlock] + ** + ** READER -> WRITER_LOCKED [sqlite3PagerBegin] + ** WRITER_LOCKED -> WRITER_CACHEMOD [pager_open_journal] + ** WRITER_CACHEMOD -> WRITER_DBMOD [syncJournal] + ** WRITER_DBMOD -> WRITER_FINISHED [sqlite3PagerCommitPhaseOne] + ** WRITER_*** -> READER [pager_end_transaction] + ** + ** WRITER_*** -> ERROR [pager_error] + ** ERROR -> OPEN [pager_unlock] + ** + ** + ** OPEN: + ** + ** The pager starts up in this state. Nothing is guaranteed in this + ** state - the file may or may not be locked and the database size is + ** unknown. The database may not be read or written. + ** + ** * No read or write transaction is active. + ** * Any lock, or no lock at all, may be held on the database file. + ** * The dbSize, dbOrigSize and dbFileSize variables may not be trusted. + ** + ** READER: + ** + ** In this state all the requirements for reading the database in + ** rollback (non-WAL) mode are met. Unless the pager is (or recently + ** was) in exclusive-locking mode, a user-level read transaction is + ** open. The database size is known in this state. + ** + ** A connection running with locking_mode=normal enters this state when + ** it opens a read-transaction on the database and returns to state + ** OPEN after the read-transaction is completed. However a connection + ** running in locking_mode=exclusive (including temp databases) remains in + ** this state even after the read-transaction is closed. The only way + ** a locking_mode=exclusive connection can transition from READER to OPEN + ** is via the ERROR state (see below). + ** + ** * A read transaction may be active (but a write-transaction cannot). + ** * A SHARED or greater lock is held on the database file. + ** * The dbSize variable may be trusted (even if a user-level read + ** transaction is not active). The dbOrigSize and dbFileSize variables + ** may not be trusted at this point. + ** * If the database is a WAL database, then the WAL connection is open. + ** * Even if a read-transaction is not open, it is guaranteed that + ** there is no hot-journal in the file-system. + ** + ** WRITER_LOCKED: + ** + ** The pager moves to this state from READER when a write-transaction + ** is first opened on the database. In WRITER_LOCKED state, all locks + ** required to start a write-transaction are held, but no actual + ** modifications to the cache or database have taken place. + ** + ** In rollback mode, a RESERVED or (if the transaction was opened with + ** BEGIN EXCLUSIVE) EXCLUSIVE lock is obtained on the database file when + ** moving to this state, but the journal file is not written to or opened + ** to in this state. If the transaction is committed or rolled back while + ** in WRITER_LOCKED state, all that is required is to unlock the database + ** file. + ** + ** IN WAL mode, WalBeginWriteTransaction() is called to lock the log file. + ** If the connection is running with locking_mode=exclusive, an attempt + ** is made to obtain an EXCLUSIVE lock on the database file. + ** + ** * A write transaction is active. + ** * If the connection is open in rollback-mode, a RESERVED or greater + ** lock is held on the database file. + ** * If the connection is open in WAL-mode, a WAL write transaction + ** is open (i.e. sqlite3WalBeginWriteTransaction() has been successfully + ** called). + ** * The dbSize, dbOrigSize and dbFileSize variables are all valid. + ** * The contents of the pager cache have not been modified. + ** * The journal file may or may not be open. + ** * Nothing (not even the first header) has been written to the journal. + ** + ** WRITER_CACHEMOD: + ** + ** A pager moves from WRITER_LOCKED state to this state when a page is + ** first modified by the upper layer. In rollback mode the journal file + ** is opened (if it is not already open) and a header written to the + ** start of it. The database file on disk has not been modified. + ** + ** * A write transaction is active. + ** * A RESERVED or greater lock is held on the database file. + ** * The journal file is open and the first header has been written + ** to it, but the header has not been synced to disk. + ** * The contents of the page cache have been modified. + ** + ** WRITER_DBMOD: + ** + ** The pager transitions from WRITER_CACHEMOD into WRITER_DBMOD state + ** when it modifies the contents of the database file. WAL connections + ** never enter this state (since they do not modify the database file, + ** just the log file). + ** + ** * A write transaction is active. + ** * An EXCLUSIVE or greater lock is held on the database file. + ** * The journal file is open and the first header has been written + ** and synced to disk. + ** * The contents of the page cache have been modified (and possibly + ** written to disk). + ** + ** WRITER_FINISHED: + ** + ** It is not possible for a WAL connection to enter this state. + ** + ** A rollback-mode pager changes to WRITER_FINISHED state from WRITER_DBMOD + ** state after the entire transaction has been successfully written into the + ** database file. In this state the transaction may be committed simply + ** by finalizing the journal file. Once in WRITER_FINISHED state, it is + ** not possible to modify the database further. At this point, the upper + ** layer must either commit or rollback the transaction. + ** + ** * A write transaction is active. + ** * An EXCLUSIVE or greater lock is held on the database file. + ** * All writing and syncing of journal and database data has finished. + ** If no error occured, all that remains is to finalize the journal to + ** commit the transaction. If an error did occur, the caller will need + ** to rollback the transaction. + ** + ** ERROR: + ** + ** The ERROR state is entered when an IO or disk-full error (including + ** SQLITE_IOERR_NOMEM) occurs at a point in the code that makes it + ** difficult to be sure that the in-memory pager state (cache contents, + ** db size etc.) are consistent with the contents of the file-system. + ** + ** Temporary pager files may enter the ERROR state, but in-memory pagers + ** cannot. + ** + ** For example, if an IO error occurs while performing a rollback, + ** the contents of the page-cache may be left in an inconsistent state. + ** At this point it would be dangerous to change back to READER state + ** (as usually happens after a rollback). Any subsequent readers might + ** report database corruption (due to the inconsistent cache), and if + ** they upgrade to writers, they may inadvertently corrupt the database + ** file. To avoid this hazard, the pager switches into the ERROR state + ** instead of READER following such an error. + ** + ** Once it has entered the ERROR state, any attempt to use the pager + ** to read or write data returns an error. Eventually, once all + ** outstanding transactions have been abandoned, the pager is able to + ** transition back to OPEN state, discarding the contents of the + ** page-cache and any other in-memory state at the same time. Everything + ** is reloaded from disk (and, if necessary, hot-journal rollback peformed) + ** when a read-transaction is next opened on the pager (transitioning + ** the pager into READER state). At that point the system has recovered + ** from the error. + ** + ** Specifically, the pager jumps into the ERROR state if: + ** + ** 1. An error occurs while attempting a rollback. This happens in + ** function sqlite3PagerRollback(). + ** + ** 2. An error occurs while attempting to finalize a journal file + ** following a commit in function sqlite3PagerCommitPhaseTwo(). + ** + ** 3. An error occurs while attempting to write to the journal or + ** database file in function pagerStress() in order to free up + ** memory. + ** + ** In other cases, the error is returned to the b-tree layer. The b-tree + ** layer then attempts a rollback operation. If the error condition + ** persists, the pager enters the ERROR state via condition (1) above. + ** + ** Condition (3) is necessary because it can be triggered by a read-only + ** statement executed within a transaction. In this case, if the error + ** code were simply returned to the user, the b-tree layer would not + ** automatically attempt a rollback, as it assumes that an error in a + ** read-only statement cannot leave the pager in an internally inconsistent + ** state. + ** + ** * The Pager.errCode variable is set to something other than SQLITE_OK. + ** * There are one or more outstanding references to pages (after the + ** last reference is dropped the pager should move back to OPEN state). + ** * The pager is not an in-memory pager. + ** + ** + ** Notes: + ** + ** * A pager is never in WRITER_DBMOD or WRITER_FINISHED state if the + ** connection is open in WAL mode. A WAL connection is always in one + ** of the first four states. + ** + ** * Normally, a connection open in exclusive mode is never in PAGER_OPEN + ** state. There are two exceptions: immediately after exclusive-mode has + ** been turned on (and before any read or write transactions are + ** executed), and when the pager is leaving the "error state". + ** + ** * See also: assert_pager_state(). + */ - /* - ** A macro used for invoking the codec if there is one - */ + //#define PAGER_OPEN 0 + //#define PAGER_READER 1 + //#define PAGER_WRITER_LOCKED 2 + //#define PAGER_WRITER_CACHEMOD 3 + //#define PAGER_WRITER_DBMOD 4 + //#define PAGER_WRITER_FINISHED 5 + //#define PAGER_ERROR 6 + const int PAGER_OPEN = 0; + const int PAGER_READER = 1; + const int PAGER_WRITER_LOCKED = 2; + const int PAGER_WRITER_CACHEMOD = 3; + const int PAGER_WRITER_DBMOD = 4; + const int PAGER_WRITER_FINISHED = 5; + const int PAGER_ERROR = 6; - // The E parameter is what executes when there is an error, - // cannot implement here, since this is not really a macro - // calling code must be modified to call E when truen + /* + ** The Pager.eLock variable is almost always set to one of the + ** following locking-states, according to the lock currently held on + ** the database file: NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK. + ** This variable is kept up to date as locks are taken and released by + ** the pagerLockDb() and pagerUnlockDb() wrappers. + ** + ** If the VFS xLock() or xUnlock() returns an error other than SQLITE_BUSY + ** (i.e. one of the SQLITE_IOERR subtypes), it is not clear whether or not + ** the operation was successful. In these circumstances pagerLockDb() and + ** pagerUnlockDb() take a conservative approach - eLock is always updated + ** when unlocking the file, and only updated when locking the file if the + ** VFS call is successful. This way, the Pager.eLock variable may be set + ** to a less exclusive (lower) value than the lock that is actually held + ** at the system level, but it is never set to a more exclusive value. + ** + ** This is usually safe. If an xUnlock fails or appears to fail, there may + ** be a few redundant xLock() calls or a lock may be held for longer than + ** required, but nothing really goes wrong. + ** + ** The exception is when the database file is unlocked as the pager moves + ** from ERROR to OPEN state. At this point there may be a hot-journal file + ** in the file-system that needs to be rolled back (as part of a OPEN->SHARED + ** transition, by the same pager or any other). If the call to xUnlock() + ** fails at this point and the pager is left holding an EXCLUSIVE lock, this + ** can confuse the call to xCheckReservedLock() call made later as part + ** of hot-journal detection. + ** + ** xCheckReservedLock() is defined as returning true "if there is a RESERVED + ** lock held by this process or any others". So xCheckReservedLock may + ** return true because the caller itself is holding an EXCLUSIVE lock (but + ** doesn't know it because of a previous error in xUnlock). If this happens + ** a hot-journal may be mistaken for a journal being created by an active + ** transaction in another process, causing SQLite to read from the database + ** without rolling it back. + ** + ** To work around this, if a call to xUnlock() fails when unlocking the + ** database in the ERROR state, Pager.eLock is set to UNKNOWN_LOCK. It + ** is only changed back to a real locking state after a successful call + ** to xLock(EXCLUSIVE). Also, the code to do the OPEN->SHARED state transition + ** omits the check for a hot-journal if Pager.eLock is set to UNKNOWN_LOCK + ** lock. Instead, it assumes a hot-journal exists and obtains an EXCLUSIVE + ** lock on the database file before attempting to roll it back. See function + ** PagerSharedLock() for more detail. + ** + ** Pager.eLock may only be set to UNKNOWN_LOCK when the pager is in + ** PAGER_OPEN state. + */ + //#define UNKNOWN_LOCK (EXCLUSIVE_LOCK+1) + const int UNKNOWN_LOCK = (EXCLUSIVE_LOCK + 1); + + /* + ** A macro used for invoking the codec if there is one + */ + + // The E parameter is what executes when there is an error, + // cannot implement here, since this is not really a macro + // calling code must be modified to call E when truen #if SQLITE_HAS_CODEC //# define CODEC1(P,D,N,X,E) \ @@ -492,303 +486,300 @@ static bool CODEC2( Pager P, byte[] D, uint N, int X, ref byte[] O ) } } #else -//# define CODEC1(P,D,N,X,E) /* NO-OP */ -static bool CODEC1 (Pager P, byte[] D, uint N /* page number */, int X /* E (moved to caller */) { return false; } -//# define CODEC2(P,D,N,X,E,O) O=(char*)D -static bool CODEC2( Pager P, byte[] D, uint N, int X, ref byte[] O ) { O = D; return false; } + //# define CODEC1(P,D,N,X,E) /* NO-OP */ + static bool CODEC1(Pager P, byte[] D, uint N /* page number */, int X /* E (moved to caller */) { return false; } + //# define CODEC2(P,D,N,X,E,O) O=(char*)D + static bool CODEC2(Pager P, byte[] D, uint N, int X, ref byte[] O) { O = D; return false; } #endif - /* -** The maximum allowed sector size. 64KiB. If the xSectorsize() method -** returns a value larger than this, then MAX_SECTOR_SIZE is used instead. -** This could conceivably cause corruption following a power failure on -** such a system. This is currently an undocumented limit. -*/ - //#define MAX_SECTOR_SIZE 0x10000 - const int MAX_SECTOR_SIZE = 0x10000; - - /* - ** An instance of the following structure is allocated for each active - ** savepoint and statement transaction in the system. All such structures - ** are stored in the Pager.aSavepoint[] array, which is allocated and - ** resized using sqlite3Realloc(). - ** - ** When a savepoint is created, the PagerSavepoint.iHdrOffset field is - ** set to 0. If a journal-header is written into the main journal while - ** the savepoint is active, then iHdrOffset is set to the byte offset - ** immediately following the last journal record written into the main - ** journal before the journal-header. This is required during savepoint - ** rollback (see pagerPlaybackSavepoint()). + /* + ** The maximum allowed sector size. 64KiB. If the xSectorsize() method + ** returns a value larger than this, then MAX_SECTOR_SIZE is used instead. + ** This could conceivably cause corruption following a power failure on + ** such a system. This is currently an undocumented limit. */ - //typedef struct PagerSavepoint PagerSavepoint; - public class PagerSavepoint - { - public i64 iOffset; /* Starting offset in main journal */ - public i64 iHdrOffset; /* See above */ - public Bitvec pInSavepoint; /* Set of pages in this savepoint */ - public Pgno nOrig; /* Original number of pages in file */ - public Pgno iSubRec; /* Index of first record in sub-journal */ + //#define MAX_SECTOR_SIZE 0x10000 + const int MAX_SECTOR_SIZE = 0x10000; + + /* + ** An instance of the following structure is allocated for each active + ** savepoint and statement transaction in the system. All such structures + ** are stored in the Pager.aSavepoint[] array, which is allocated and + ** resized using sqlite3Realloc(). + ** + ** When a savepoint is created, the PagerSavepoint.iHdrOffset field is + ** set to 0. If a journal-header is written into the main journal while + ** the savepoint is active, then iHdrOffset is set to the byte offset + ** immediately following the last journal record written into the main + ** journal before the journal-header. This is required during savepoint + ** rollback (see pagerPlaybackSavepoint()). + */ + //typedef struct PagerSavepoint PagerSavepoint; + public class PagerSavepoint { + public i64 iOffset; /* Starting offset in main journal */ + public i64 iHdrOffset; /* See above */ + public Bitvec pInSavepoint; /* Set of pages in this savepoint */ + public Pgno nOrig; /* Original number of pages in file */ + public Pgno iSubRec; /* Index of first record in sub-journal */ #if !SQLITE_OMIT_WAL public u32 aWalData[WAL_SAVEPOINT_NDATA]; /* WAL savepoint context */ #else - public object aWalData = null; /* Used for C# convenience */ + public object aWalData = null; /* Used for C# convenience */ #endif - public static implicit operator bool( PagerSavepoint b ) - { - return ( b != null ); - } - }; - + public static implicit operator bool(PagerSavepoint b) { + return (b != null); + } + }; - /* - ** A open page cache is an instance of struct Pager. A description of - ** some of the more important member variables follows: - ** - ** eState - ** - ** The current 'state' of the pager object. See the comment and state - ** diagram above for a description of the pager state. - ** - ** eLock - ** - ** For a real on-disk database, the current lock held on the database file - - ** NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK. - ** - ** For a temporary or in-memory database (neither of which require any - ** locks), this variable is always set to EXCLUSIVE_LOCK. Since such - ** databases always have Pager.exclusiveMode==1, this tricks the pager - ** logic into thinking that it already has all the locks it will ever - ** need (and no reason to release them). - ** - ** In some (obscure) circumstances, this variable may also be set to - ** UNKNOWN_LOCK. See the comment above the #define of UNKNOWN_LOCK for - ** details. - ** - ** changeCountDone - ** - ** This boolean variable is used to make sure that the change-counter - ** (the 4-byte header field at byte offset 24 of the database file) is - ** not updated more often than necessary. - ** - ** It is set to true when the change-counter field is updated, which - ** can only happen if an exclusive lock is held on the database file. - ** It is cleared (set to false) whenever an exclusive lock is - ** relinquished on the database file. Each time a transaction is committed, - ** The changeCountDone flag is inspected. If it is true, the work of - ** updating the change-counter is omitted for the current transaction. - ** - ** This mechanism means that when running in exclusive mode, a connection - ** need only update the change-counter once, for the first transaction - ** committed. - ** - ** setMaster - ** - ** When PagerCommitPhaseOne() is called to commit a transaction, it may - ** (or may not) specify a master-journal name to be written into the - ** journal file before it is synced to disk. - ** - ** Whether or not a journal file contains a master-journal pointer affects - ** the way in which the journal file is finalized after the transaction is - ** committed or rolled back when running in "journal_mode=PERSIST" mode. - ** If a journal file does not contain a master-journal pointer, it is - ** finalized by overwriting the first journal header with zeroes. If - ** it does contain a master-journal pointer the journal file is finalized - ** by truncating it to zero bytes, just as if the connection were - ** running in "journal_mode=truncate" mode. - ** - ** Journal files that contain master journal pointers cannot be finalized - ** simply by overwriting the first journal-header with zeroes, as the - ** master journal pointer could interfere with hot-journal rollback of any - ** subsequently interrupted transaction that reuses the journal file. - ** - ** The flag is cleared as soon as the journal file is finalized (either - ** by PagerCommitPhaseTwo or PagerRollback). If an IO error prevents the - ** journal file from being successfully finalized, the setMaster flag - ** is cleared anyway (and the pager will move to ERROR state). - ** - ** doNotSpill, doNotSyncSpill - ** - ** These two boolean variables control the behaviour of cache-spills - ** (calls made by the pcache module to the pagerStress() routine to - ** write cached data to the file-system in order to free up memory). - ** - ** When doNotSpill is non-zero, writing to the database from pagerStress() - ** is disabled altogether. This is done in a very obscure case that - ** comes up during savepoint rollback that requires the pcache module - ** to allocate a new page to prevent the journal file from being written - ** while it is being traversed by code in pager_playback(). - ** - ** If doNotSyncSpill is non-zero, writing to the database from pagerStress() - ** is permitted, but syncing the journal file is not. This flag is set - ** by sqlite3PagerWrite() when the file-system sector-size is larger than - ** the database page-size in order to prevent a journal sync from happening - ** in between the journalling of two pages on the same sector. - ** - ** subjInMemory - ** - ** This is a boolean variable. If true, then any required sub-journal - ** is opened as an in-memory journal file. If false, then in-memory - ** sub-journals are only used for in-memory pager files. - ** - ** This variable is updated by the upper layer each time a new - ** write-transaction is opened. - ** - ** dbSize, dbOrigSize, dbFileSize - ** - ** Variable dbSize is set to the number of pages in the database file. - ** It is valid in PAGER_READER and higher states (all states except for - ** OPEN and ERROR). - ** - ** dbSize is set based on the size of the database file, which may be - ** larger than the size of the database (the value stored at offset - ** 28 of the database header by the btree). If the size of the file - ** is not an integer multiple of the page-size, the value stored in - ** dbSize is rounded down (i.e. a 5KB file with 2K page-size has dbSize==2). - ** Except, any file that is greater than 0 bytes in size is considered - ** to have at least one page. (i.e. a 1KB file with 2K page-size leads - ** to dbSize==1). - ** - ** During a write-transaction, if pages with page-numbers greater than - ** dbSize are modified in the cache, dbSize is updated accordingly. - ** Similarly, if the database is truncated using PagerTruncateImage(), - ** dbSize is updated. - ** - ** Variables dbOrigSize and dbFileSize are valid in states - ** PAGER_WRITER_LOCKED and higher. dbOrigSize is a copy of the dbSize - ** variable at the start of the transaction. It is used during rollback, - ** and to determine whether or not pages need to be journalled before - ** being modified. - ** - ** Throughout a write-transaction, dbFileSize contains the size of - ** the file on disk in pages. It is set to a copy of dbSize when the - ** write-transaction is first opened, and updated when VFS calls are made - ** to write or truncate the database file on disk. - ** - ** The only reason the dbFileSize variable is required is to suppress - ** unnecessary calls to xTruncate() after committing a transaction. If, - ** when a transaction is committed, the dbFileSize variable indicates - ** that the database file is larger than the database image (Pager.dbSize), - ** pager_truncate() is called. The pager_truncate() call uses xFilesize() - ** to measure the database file on disk, and then truncates it if required. - ** dbFileSize is not used when rolling back a transaction. In this case - ** pager_truncate() is called unconditionally (which means there may be - ** a call to xFilesize() that is not strictly required). In either case, - ** pager_truncate() may cause the file to become smaller or larger. - ** - ** dbHintSize - ** - ** The dbHintSize variable is used to limit the number of calls made to - ** the VFS xFileControl(FCNTL_SIZE_HINT) method. - ** - ** dbHintSize is set to a copy of the dbSize variable when a - ** write-transaction is opened (at the same time as dbFileSize and - ** dbOrigSize). If the xFileControl(FCNTL_SIZE_HINT) method is called, - ** dbHintSize is increased to the number of pages that correspond to the - ** size-hint passed to the method call. See pager_write_pagelist() for - ** details. - ** - ** errCode - ** - ** The Pager.errCode variable is only ever used in PAGER_ERROR state. It - ** is set to zero in all other states. In PAGER_ERROR state, Pager.errCode - ** is always set to SQLITE_FULL, SQLITE_IOERR or one of the SQLITE_IOERR_XXX - ** sub-codes. - */ - public class Pager - { - public sqlite3_vfs pVfs; /* OS functions to use for IO */ - public bool exclusiveMode; /* Boolean. True if locking_mode==EXCLUSIVE */ - public u8 journalMode; /* One of the PAGER_JOURNALMODE_* values */ - public u8 useJournal; /* Use a rollback journal on this file */ - public u8 noReadlock; /* Do not bother to obtain readlocks */ - public bool noSync; /* Do not sync the journal if true */ - public bool fullSync; /* Do extra syncs of the journal for robustness */ - public u8 ckptSyncFlags; /* SYNC_NORMAL or SYNC_FULL for checkpoint */ - public u8 syncFlags; /* SYNC_NORMAL or SYNC_FULL otherwise */ - public bool tempFile; /* zFilename is a temporary file */ - public bool readOnly; /* True for a read-only database */ - public bool alwaysRollback; /* Disable DontRollback() for all pages */ - public u8 memDb; /* True to inhibit all file I/O */ - /************************************************************************** - ** The following block contains those class members that change during - ** routine opertion. Class members not in this block are either fixed - ** when the pager is first created or else only change when there is a - ** significant mode change (such as changing the page_size, locking_mode, - ** or the journal_mode). From another view, these class members describe - ** the "state" of the pager, while other class members describe the - ** "configuration" of the pager. - */ - public u8 eState; /* Pager state (OPEN, READER, WRITER_LOCKED..) */ - public u8 eLock; /* Current lock held on database file */ - public bool changeCountDone; /* Set after incrementing the change-counter */ - public int setMaster; /* True if a m-j name has been written to jrnl */ - public u8 doNotSpill; /* Do not spill the cache when non-zero */ - public u8 doNotSyncSpill; /* Do not do a spill that requires jrnl sync */ - public u8 subjInMemory; /* True to use in-memory sub-journals */ - public Pgno dbSize; /* Number of pages in the database */ - public Pgno dbOrigSize; /* dbSize before the current transaction */ - public Pgno dbFileSize; /* Number of pages in the database file */ - public Pgno dbHintSize; /* Value passed to FCNTL_SIZE_HINT call */ - public int errCode; /* One of several kinds of errors */ - public int nRec; /* Pages journalled since last j-header written */ - public u32 cksumInit; /* Quasi-random value added to every checksum */ - public u32 nSubRec; /* Number of records written to sub-journal */ - public Bitvec pInJournal; /* One bit for each page in the database file */ - public sqlite3_file fd; /* File descriptor for database */ - public sqlite3_file jfd; /* File descriptor for main journal */ - public sqlite3_file sjfd; /* File descriptor for sub-journal */ - public i64 journalOff; /* Current write offset in the journal file */ - public i64 journalHdr; /* Byte offset to previous journal header */ - public sqlite3_backup pBackup; /* Pointer to list of ongoing backup processes */ - public PagerSavepoint[] aSavepoint;/* Array of active savepoints */ - public int nSavepoint; /* Number of elements in aSavepoint[] */ - public u8[] dbFileVers = new u8[16];/* Changes whenever database file changes */ - /* - ** End of the routinely-changing class members - ***************************************************************************/ - - public u16 nExtra; /* Add this many bytes to each in-memory page */ - public i16 nReserve; /* Number of unused bytes at end of each page */ - public u32 vfsFlags; /* Flags for sqlite3_vfs.xOpen() */ - public u32 sectorSize; /* Assumed sector size during rollback */ - public int pageSize; /* Number of bytes in a page */ - public Pgno mxPgno; /* Maximum allowed size of the database */ - public i64 journalSizeLimit; /* Size limit for persistent journal files */ - public string zFilename; /* Name of the database file */ - public string zJournal; /* Name of the journal file */ - public dxBusyHandler xBusyHandler; /* Function to call when busy */ - public object pBusyHandlerArg; /* Context argument for xBusyHandler */ -#if SQLITE_TEST || DEBUG - public int nHit, nMiss; /* Cache hits and missing */ - public int nRead, nWrite; /* Database pages read/written */ -#else -public int nHit; -#endif - public dxReiniter xReiniter; //(DbPage*,int);/* Call this routine when reloading pages */ -#if SQLITE_HAS_CODEC - //void *(*xCodec)(void*,void*,Pgno,int); - public dxCodec xCodec; /* Routine for en/decoding data */ - //void (*xCodecSizeChng)(void*,int,int); - public dxCodecSizeChng xCodecSizeChng; /* Notify of page size changes */ - //void (*xCodecFree)(void*); - public dxCodecFree xCodecFree; /* Destructor for the codec */ - public codec_ctx pCodec; /* First argument to xCodec... methods */ -#endif - public byte[] pTmpSpace; /* Pager.pageSize bytes of space for tmp use */ - public PCache pPCache; /* Pointer to page cache object */ -#if !SQLITE_OMIT_WAL -public Wal pWal; /* Write-ahead log used by "journal_mode=wal" */ -public string zWal; /* File name for write-ahead log */ -#else - public sqlite3_vfs pWal = null; /* Having this dummy here makes C# easier */ -#endif - }; - /* - ** The following global variables hold counters used for - ** testing purposes only. These variables do not exist in - ** a non-testing build. These variables are not thread-safe. - */ + /* + ** A open page cache is an instance of struct Pager. A description of + ** some of the more important member variables follows: + ** + ** eState + ** + ** The current 'state' of the pager object. See the comment and state + ** diagram above for a description of the pager state. + ** + ** eLock + ** + ** For a real on-disk database, the current lock held on the database file - + ** NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK. + ** + ** For a temporary or in-memory database (neither of which require any + ** locks), this variable is always set to EXCLUSIVE_LOCK. Since such + ** databases always have Pager.exclusiveMode==1, this tricks the pager + ** logic into thinking that it already has all the locks it will ever + ** need (and no reason to release them). + ** + ** In some (obscure) circumstances, this variable may also be set to + ** UNKNOWN_LOCK. See the comment above the #define of UNKNOWN_LOCK for + ** details. + ** + ** changeCountDone + ** + ** This boolean variable is used to make sure that the change-counter + ** (the 4-byte header field at byte offset 24 of the database file) is + ** not updated more often than necessary. + ** + ** It is set to true when the change-counter field is updated, which + ** can only happen if an exclusive lock is held on the database file. + ** It is cleared (set to false) whenever an exclusive lock is + ** relinquished on the database file. Each time a transaction is committed, + ** The changeCountDone flag is inspected. If it is true, the work of + ** updating the change-counter is omitted for the current transaction. + ** + ** This mechanism means that when running in exclusive mode, a connection + ** need only update the change-counter once, for the first transaction + ** committed. + ** + ** setMaster + ** + ** When PagerCommitPhaseOne() is called to commit a transaction, it may + ** (or may not) specify a master-journal name to be written into the + ** journal file before it is synced to disk. + ** + ** Whether or not a journal file contains a master-journal pointer affects + ** the way in which the journal file is finalized after the transaction is + ** committed or rolled back when running in "journal_mode=PERSIST" mode. + ** If a journal file does not contain a master-journal pointer, it is + ** finalized by overwriting the first journal header with zeroes. If + ** it does contain a master-journal pointer the journal file is finalized + ** by truncating it to zero bytes, just as if the connection were + ** running in "journal_mode=truncate" mode. + ** + ** Journal files that contain master journal pointers cannot be finalized + ** simply by overwriting the first journal-header with zeroes, as the + ** master journal pointer could interfere with hot-journal rollback of any + ** subsequently interrupted transaction that reuses the journal file. + ** + ** The flag is cleared as soon as the journal file is finalized (either + ** by PagerCommitPhaseTwo or PagerRollback). If an IO error prevents the + ** journal file from being successfully finalized, the setMaster flag + ** is cleared anyway (and the pager will move to ERROR state). + ** + ** doNotSpill, doNotSyncSpill + ** + ** These two boolean variables control the behaviour of cache-spills + ** (calls made by the pcache module to the pagerStress() routine to + ** write cached data to the file-system in order to free up memory). + ** + ** When doNotSpill is non-zero, writing to the database from pagerStress() + ** is disabled altogether. This is done in a very obscure case that + ** comes up during savepoint rollback that requires the pcache module + ** to allocate a new page to prevent the journal file from being written + ** while it is being traversed by code in pager_playback(). + ** + ** If doNotSyncSpill is non-zero, writing to the database from pagerStress() + ** is permitted, but syncing the journal file is not. This flag is set + ** by sqlite3PagerWrite() when the file-system sector-size is larger than + ** the database page-size in order to prevent a journal sync from happening + ** in between the journalling of two pages on the same sector. + ** + ** subjInMemory + ** + ** This is a boolean variable. If true, then any required sub-journal + ** is opened as an in-memory journal file. If false, then in-memory + ** sub-journals are only used for in-memory pager files. + ** + ** This variable is updated by the upper layer each time a new + ** write-transaction is opened. + ** + ** dbSize, dbOrigSize, dbFileSize + ** + ** Variable dbSize is set to the number of pages in the database file. + ** It is valid in PAGER_READER and higher states (all states except for + ** OPEN and ERROR). + ** + ** dbSize is set based on the size of the database file, which may be + ** larger than the size of the database (the value stored at offset + ** 28 of the database header by the btree). If the size of the file + ** is not an integer multiple of the page-size, the value stored in + ** dbSize is rounded down (i.e. a 5KB file with 2K page-size has dbSize==2). + ** Except, any file that is greater than 0 bytes in size is considered + ** to have at least one page. (i.e. a 1KB file with 2K page-size leads + ** to dbSize==1). + ** + ** During a write-transaction, if pages with page-numbers greater than + ** dbSize are modified in the cache, dbSize is updated accordingly. + ** Similarly, if the database is truncated using PagerTruncateImage(), + ** dbSize is updated. + ** + ** Variables dbOrigSize and dbFileSize are valid in states + ** PAGER_WRITER_LOCKED and higher. dbOrigSize is a copy of the dbSize + ** variable at the start of the transaction. It is used during rollback, + ** and to determine whether or not pages need to be journalled before + ** being modified. + ** + ** Throughout a write-transaction, dbFileSize contains the size of + ** the file on disk in pages. It is set to a copy of dbSize when the + ** write-transaction is first opened, and updated when VFS calls are made + ** to write or truncate the database file on disk. + ** + ** The only reason the dbFileSize variable is required is to suppress + ** unnecessary calls to xTruncate() after committing a transaction. If, + ** when a transaction is committed, the dbFileSize variable indicates + ** that the database file is larger than the database image (Pager.dbSize), + ** pager_truncate() is called. The pager_truncate() call uses xFilesize() + ** to measure the database file on disk, and then truncates it if required. + ** dbFileSize is not used when rolling back a transaction. In this case + ** pager_truncate() is called unconditionally (which means there may be + ** a call to xFilesize() that is not strictly required). In either case, + ** pager_truncate() may cause the file to become smaller or larger. + ** + ** dbHintSize + ** + ** The dbHintSize variable is used to limit the number of calls made to + ** the VFS xFileControl(FCNTL_SIZE_HINT) method. + ** + ** dbHintSize is set to a copy of the dbSize variable when a + ** write-transaction is opened (at the same time as dbFileSize and + ** dbOrigSize). If the xFileControl(FCNTL_SIZE_HINT) method is called, + ** dbHintSize is increased to the number of pages that correspond to the + ** size-hint passed to the method call. See pager_write_pagelist() for + ** details. + ** + ** errCode + ** + ** The Pager.errCode variable is only ever used in PAGER_ERROR state. It + ** is set to zero in all other states. In PAGER_ERROR state, Pager.errCode + ** is always set to SQLITE_FULL, SQLITE_IOERR or one of the SQLITE_IOERR_XXX + ** sub-codes. + */ + public class Pager { + public sqlite3_vfs pVfs; /* OS functions to use for IO */ + public bool exclusiveMode; /* Boolean. True if locking_mode==EXCLUSIVE */ + public u8 journalMode; /* One of the PAGER_JOURNALMODE_* values */ + public u8 useJournal; /* Use a rollback journal on this file */ + public u8 noReadlock; /* Do not bother to obtain readlocks */ + public bool noSync; /* Do not sync the journal if true */ + public bool fullSync; /* Do extra syncs of the journal for robustness */ + public u8 ckptSyncFlags; /* SYNC_NORMAL or SYNC_FULL for checkpoint */ + public u8 syncFlags; /* SYNC_NORMAL or SYNC_FULL otherwise */ + public bool tempFile; /* zFilename is a temporary file */ + public bool readOnly; /* True for a read-only database */ + public bool alwaysRollback; /* Disable DontRollback() for all pages */ + public u8 memDb; /* True to inhibit all file I/O */ + /************************************************************************** + ** The following block contains those class members that change during + ** routine opertion. Class members not in this block are either fixed + ** when the pager is first created or else only change when there is a + ** significant mode change (such as changing the page_size, locking_mode, + ** or the journal_mode). From another view, these class members describe + ** the "state" of the pager, while other class members describe the + ** "configuration" of the pager. + */ + public u8 eState; /* Pager state (OPEN, READER, WRITER_LOCKED..) */ + public u8 eLock; /* Current lock held on database file */ + public bool changeCountDone; /* Set after incrementing the change-counter */ + public int setMaster; /* True if a m-j name has been written to jrnl */ + public u8 doNotSpill; /* Do not spill the cache when non-zero */ + public u8 doNotSyncSpill; /* Do not do a spill that requires jrnl sync */ + public u8 subjInMemory; /* True to use in-memory sub-journals */ + public Pgno dbSize; /* Number of pages in the database */ + public Pgno dbOrigSize; /* dbSize before the current transaction */ + public Pgno dbFileSize; /* Number of pages in the database file */ + public Pgno dbHintSize; /* Value passed to FCNTL_SIZE_HINT call */ + public int errCode; /* One of several kinds of errors */ + public int nRec; /* Pages journalled since last j-header written */ + public u32 cksumInit; /* Quasi-random value added to every checksum */ + public u32 nSubRec; /* Number of records written to sub-journal */ + public Bitvec pInJournal; /* One bit for each page in the database file */ + public sqlite3_file fd; /* File descriptor for database */ + public sqlite3_file jfd; /* File descriptor for main journal */ + public sqlite3_file sjfd; /* File descriptor for sub-journal */ + public i64 journalOff; /* Current write offset in the journal file */ + public i64 journalHdr; /* Byte offset to previous journal header */ + public sqlite3_backup pBackup; /* Pointer to list of ongoing backup processes */ + public PagerSavepoint[] aSavepoint;/* Array of active savepoints */ + public int nSavepoint; /* Number of elements in aSavepoint[] */ + public u8[] dbFileVers = new u8[16];/* Changes whenever database file changes */ + /* + ** End of the routinely-changing class members + ***************************************************************************/ + + public u16 nExtra; /* Add this many bytes to each in-memory page */ + public i16 nReserve; /* Number of unused bytes at end of each page */ + public u32 vfsFlags; /* Flags for sqlite3_vfs.xOpen() */ + public u32 sectorSize; /* Assumed sector size during rollback */ + public int pageSize; /* Number of bytes in a page */ + public Pgno mxPgno; /* Maximum allowed size of the database */ + public i64 journalSizeLimit; /* Size limit for persistent journal files */ + public string zFilename; /* Name of the database file */ + public string zJournal; /* Name of the journal file */ + public dxBusyHandler xBusyHandler; /* Function to call when busy */ + public object pBusyHandlerArg; /* Context argument for xBusyHandler */ +#if SQLITE_TEST || DEBUG + public int nHit, nMiss; /* Cache hits and missing */ + public int nRead, nWrite; /* Database pages read/written */ +#else +public int nHit; +#endif + public dxReiniter xReiniter; //(DbPage*,int);/* Call this routine when reloading pages */ +#if SQLITE_HAS_CODEC + //void *(*xCodec)(void*,void*,Pgno,int); + public dxCodec xCodec; /* Routine for en/decoding data */ + //void (*xCodecSizeChng)(void*,int,int); + public dxCodecSizeChng xCodecSizeChng; /* Notify of page size changes */ + //void (*xCodecFree)(void*); + public dxCodecFree xCodecFree; /* Destructor for the codec */ + public codec_ctx pCodec; /* First argument to xCodec... methods */ +#endif + public byte[] pTmpSpace; /* Pager.pageSize bytes of space for tmp use */ + public PCache pPCache; /* Pointer to page cache object */ +#if !SQLITE_OMIT_WAL +public Wal pWal; /* Write-ahead log used by "journal_mode=wal" */ +public string zWal; /* File name for write-ahead log */ +#else + public sqlite3_vfs pWal = null; /* Having this dummy here makes C# easier */ +#endif + }; + + /* + ** The following global variables hold counters used for + ** testing purposes only. These variables do not exist in + ** a non-testing build. These variables are not thread-safe. + */ #if SQLITE_TEST #if !TCLSH static int sqlite3_pager_readdb_count = 0; /* Number of full pages read from DB */ @@ -804,127 +795,119 @@ static void PAGER_INCR( ref int v ) v++; } #else -//# define PAGER_INCR(v) -static void PAGER_INCR(ref int v) {} + //# define PAGER_INCR(v) + static void PAGER_INCR(ref int v) { } #endif - /* -** Journal files begin with the following magic string. The data -** was obtained from /dev/random. It is used only as a sanity check. -** -** Since version 2.8.0, the journal format contains additional sanity -** checking information. If the power fails while the journal is being -** written, semi-random garbage data might appear in the journal -** file after power is restored. If an attempt is then made -** to roll the journal back, the database could be corrupted. The additional -** sanity checking data is an attempt to discover the garbage in the -** journal and ignore it. -** -** The sanity checking information for the new journal format consists -** of a 32-bit checksum on each page of data. The checksum covers both -** the page number and the pPager.pageSize bytes of data for the page. -** This cksum is initialized to a 32-bit random value that appears in the -** journal file right after the header. The random initializer is important, -** because garbage data that appears at the end of a journal is likely -** data that was once in other files that have now been deleted. If the -** garbage data came from an obsolete journal file, the checksums might -** be correct. But by initializing the checksum to random value which -** is different for every journal, we minimize that risk. -*/ - static byte[] aJournalMagic = new byte[] { + /* + ** Journal files begin with the following magic string. The data + ** was obtained from /dev/random. It is used only as a sanity check. + ** + ** Since version 2.8.0, the journal format contains additional sanity + ** checking information. If the power fails while the journal is being + ** written, semi-random garbage data might appear in the journal + ** file after power is restored. If an attempt is then made + ** to roll the journal back, the database could be corrupted. The additional + ** sanity checking data is an attempt to discover the garbage in the + ** journal and ignore it. + ** + ** The sanity checking information for the new journal format consists + ** of a 32-bit checksum on each page of data. The checksum covers both + ** the page number and the pPager.pageSize bytes of data for the page. + ** This cksum is initialized to a 32-bit random value that appears in the + ** journal file right after the header. The random initializer is important, + ** because garbage data that appears at the end of a journal is likely + ** data that was once in other files that have now been deleted. If the + ** garbage data came from an obsolete journal file, the checksums might + ** be correct. But by initializing the checksum to random value which + ** is different for every journal, we minimize that risk. + */ + static byte[] aJournalMagic = new byte[] { 0xd9, 0xd5, 0x05, 0xf9, 0x20, 0xa1, 0x63, 0xd7, }; - /* - ** The size of the of each page record in the journal is given by - ** the following macro. - */ - //#define JOURNAL_PG_SZ(pPager) ((pPager.pageSize) + 8) - static int JOURNAL_PG_SZ( Pager pPager ) - { - return ( pPager.pageSize + 8 ); - } + /* + ** The size of the of each page record in the journal is given by + ** the following macro. + */ + //#define JOURNAL_PG_SZ(pPager) ((pPager.pageSize) + 8) + static int JOURNAL_PG_SZ(Pager pPager) { + return (pPager.pageSize + 8); + } - /* - ** The journal header size for this pager. This is usually the same - ** size as a single disk sector. See also setSectorSize(). - */ - //#define JOURNAL_HDR_SZ(pPager) (pPager.sectorSize) - static u32 JOURNAL_HDR_SZ( Pager pPager ) - { - return ( pPager.sectorSize ); - } + /* + ** The journal header size for this pager. This is usually the same + ** size as a single disk sector. See also setSectorSize(). + */ + //#define JOURNAL_HDR_SZ(pPager) (pPager.sectorSize) + static u32 JOURNAL_HDR_SZ(Pager pPager) { + return (pPager.sectorSize); + } - /* - ** The macro MEMDB is true if we are dealing with an in-memory database. - ** We do this as a macro so that if the SQLITE_OMIT_MEMORYDB macro is set, - ** the value of MEMDB will be a constant and the compiler will optimize - ** out code that would never execute. - */ + /* + ** The macro MEMDB is true if we are dealing with an in-memory database. + ** We do this as a macro so that if the SQLITE_OMIT_MEMORYDB macro is set, + ** the value of MEMDB will be a constant and the compiler will optimize + ** out code that would never execute. + */ #if SQLITE_OMIT_MEMORYDB //# define MEMDB 0 const int MEMDB = 0; #else - //# define MEMDB pPager.memDb + //# define MEMDB pPager.memDb #endif - /* -** The maximum legal page number is (2^31 - 1). -*/ - //#define PAGER_MAX_PGNO 2147483647 - const int PAGER_MAX_PGNO = 2147483647; - - /* - ** The argument to this macro is a file descriptor (type sqlite3_file*). - ** Return 0 if it is not open, or non-zero (but not 1) if it is. - ** - ** This is so that expressions can be written as: - ** - ** if( isOpen(pPager.jfd) ){ ... - ** - ** instead of - ** - ** if( pPager.jfd->pMethods ){ ... + /* + ** The maximum legal page number is (2^31 - 1). */ - //#define isOpen(pFd) ((pFd)->pMethods) - static bool isOpen( sqlite3_file pFd ) - { - return pFd.pMethods != null; - } + //#define PAGER_MAX_PGNO 2147483647 + const int PAGER_MAX_PGNO = 2147483647; - /* - ** Return true if this pager uses a write-ahead log instead of the usual - ** rollback journal. Otherwise false. - */ + /* + ** The argument to this macro is a file descriptor (type sqlite3_file*). + ** Return 0 if it is not open, or non-zero (but not 1) if it is. + ** + ** This is so that expressions can be written as: + ** + ** if( isOpen(pPager.jfd) ){ ... + ** + ** instead of + ** + ** if( pPager.jfd->pMethods ){ ... + */ + //#define isOpen(pFd) ((pFd)->pMethods) + static bool isOpen(sqlite3_file pFd) { + return pFd.pMethods != null; + } + + /* + ** Return true if this pager uses a write-ahead log instead of the usual + ** rollback journal. Otherwise false. + */ #if !SQLITE_OMIT_WAL static int pagerUseWal(Pager *pPager){ return (pPager->pWal!=0); } #else - //# define pagerUseWal(x) 0 - static bool pagerUseWal( Pager x ) - { - return false; - } - //# define pagerRollbackWal(x) 0 - static int pagerRollbackWal( Pager x ) - { - return 0; - } - //# define pagerWalFrames(v,w,x,y,z) 0 - static int pagerWalFrames( Pager v, PgHdr w, Pgno x, int y, int z ) - { - return 0; - } - //# define pagerOpenWalIfPresent(z) SQLITE_OK - static int pagerOpenWalIfPresent( Pager z ) - { - return SQLITE_OK; - } - //# define pagerBeginReadTransaction(z) SQLITE_OK - static int pagerBeginReadTransaction( Pager z ) - { - return SQLITE_OK; - } + //# define pagerUseWal(x) 0 + static bool pagerUseWal(Pager x) { + return false; + } + //# define pagerRollbackWal(x) 0 + static int pagerRollbackWal(Pager x) { + return 0; + } + //# define pagerWalFrames(v,w,x,y,z) 0 + static int pagerWalFrames(Pager v, PgHdr w, Pgno x, int y, int z) { + return 0; + } + //# define pagerOpenWalIfPresent(z) SQLITE_OK + static int pagerOpenWalIfPresent(Pager z) { + return SQLITE_OK; + } + //# define pagerBeginReadTransaction(z) SQLITE_OK + static int pagerBeginReadTransaction(Pager z) { + return SQLITE_OK; + } #endif #if NDEBUG @@ -1081,239 +1064,217 @@ static bool assert_pager_state( Pager p ) return true; } #else - static bool assert_pager_state( Pager pPager ) - { - return true; - } + static bool assert_pager_state(Pager pPager) { + return true; + } #endif //* ifndef NDEBUG */ #if SQLITE_DEBUG - /* -** Return a pointer to a human readable string in a static buffer -** containing the state of the Pager object passed as an argument. This -** is intended to be used within debuggers. For example, as an alternative -** to "print *pPager" in gdb: -** -** (gdb) printf "%s", print_pager_state(pPager) -*/ - static string print_pager_state( Pager p ) - { - StringBuilder zRet = new StringBuilder( 1024 ); - - sqlite3_snprintf( 1024, zRet, - "Filename: %s\n" + - "State: %s errCode=%d\n" + - "Lock: %s\n" + - "Locking mode: locking_mode=%s\n" + - "Journal mode: journal_mode=%s\n" + - "Backing store: tempFile=%d memDb=%d useJournal=%d\n" + - "Journal: journalOff=%lld journalHdr=%lld\n" + - "Size: dbsize=%d dbOrigSize=%d dbFileSize=%d\n" - , p.zFilename - , p.eState == PAGER_OPEN ? "OPEN" : - p.eState == PAGER_READER ? "READER" : - p.eState == PAGER_WRITER_LOCKED ? "WRITER_LOCKED" : - p.eState == PAGER_WRITER_CACHEMOD ? "WRITER_CACHEMOD" : - p.eState == PAGER_WRITER_DBMOD ? "WRITER_DBMOD" : - p.eState == PAGER_WRITER_FINISHED ? "WRITER_FINISHED" : - p.eState == PAGER_ERROR ? "ERROR" : "?error?" - , (int)p.errCode - , p.eLock == NO_LOCK ? "NO_LOCK" : - p.eLock == RESERVED_LOCK ? "RESERVED" : - p.eLock == EXCLUSIVE_LOCK ? "EXCLUSIVE" : - p.eLock == SHARED_LOCK ? "SHARED" : - p.eLock == UNKNOWN_LOCK ? "UNKNOWN" : "?error?" - , p.exclusiveMode ? "exclusive" : "normal" - , p.journalMode == PAGER_JOURNALMODE_MEMORY ? "memory" : - p.journalMode == PAGER_JOURNALMODE_OFF ? "off" : - p.journalMode == PAGER_JOURNALMODE_DELETE ? "delete" : - p.journalMode == PAGER_JOURNALMODE_PERSIST ? "persist" : - p.journalMode == PAGER_JOURNALMODE_TRUNCATE ? "truncate" : - p.journalMode == PAGER_JOURNALMODE_WAL ? "wal" : "?error?" - , p.tempFile ? 1 : 0, (int)p.memDb, (int)p.useJournal - , p.journalOff, p.journalHdr - , (int)p.dbSize, (int)p.dbOrigSize, (int)p.dbFileSize - ); + /* + ** Return a pointer to a human readable string in a static buffer + ** containing the state of the Pager object passed as an argument. This + ** is intended to be used within debuggers. For example, as an alternative + ** to "print *pPager" in gdb: + ** + ** (gdb) printf "%s", print_pager_state(pPager) + */ + static string print_pager_state(Pager p) { + StringBuilder zRet = new StringBuilder(1024); + + sqlite3_snprintf(1024, zRet, + "Filename: %s\n" + + "State: %s errCode=%d\n" + + "Lock: %s\n" + + "Locking mode: locking_mode=%s\n" + + "Journal mode: journal_mode=%s\n" + + "Backing store: tempFile=%d memDb=%d useJournal=%d\n" + + "Journal: journalOff=%lld journalHdr=%lld\n" + + "Size: dbsize=%d dbOrigSize=%d dbFileSize=%d\n" + , p.zFilename + , p.eState == PAGER_OPEN ? "OPEN" : + p.eState == PAGER_READER ? "READER" : + p.eState == PAGER_WRITER_LOCKED ? "WRITER_LOCKED" : + p.eState == PAGER_WRITER_CACHEMOD ? "WRITER_CACHEMOD" : + p.eState == PAGER_WRITER_DBMOD ? "WRITER_DBMOD" : + p.eState == PAGER_WRITER_FINISHED ? "WRITER_FINISHED" : + p.eState == PAGER_ERROR ? "ERROR" : "?error?" + , (int)p.errCode + , p.eLock == NO_LOCK ? "NO_LOCK" : + p.eLock == RESERVED_LOCK ? "RESERVED" : + p.eLock == EXCLUSIVE_LOCK ? "EXCLUSIVE" : + p.eLock == SHARED_LOCK ? "SHARED" : + p.eLock == UNKNOWN_LOCK ? "UNKNOWN" : "?error?" + , p.exclusiveMode ? "exclusive" : "normal" + , p.journalMode == PAGER_JOURNALMODE_MEMORY ? "memory" : + p.journalMode == PAGER_JOURNALMODE_OFF ? "off" : + p.journalMode == PAGER_JOURNALMODE_DELETE ? "delete" : + p.journalMode == PAGER_JOURNALMODE_PERSIST ? "persist" : + p.journalMode == PAGER_JOURNALMODE_TRUNCATE ? "truncate" : + p.journalMode == PAGER_JOURNALMODE_WAL ? "wal" : "?error?" + , p.tempFile ? 1 : 0, (int)p.memDb, (int)p.useJournal + , p.journalOff, p.journalHdr + , (int)p.dbSize, (int)p.dbOrigSize, (int)p.dbFileSize + ); - return zRet.ToString(); - } + return zRet.ToString(); + } #endif - /* -** Return true if it is necessary to write page *pPg into the sub-journal. -** A page needs to be written into the sub-journal if there exists one -** or more open savepoints for which: -** -** * The page-number is less than or equal to PagerSavepoint.nOrig, and -** * The bit corresponding to the page-number is not set in -** PagerSavepoint.pInSavepoint. -*/ - static bool subjRequiresPage( PgHdr pPg ) - { - u32 pgno = pPg.pgno; - Pager pPager = pPg.pPager; - int i; - for ( i = 0; i < pPager.nSavepoint; i++ ) - { - PagerSavepoint p = pPager.aSavepoint[i]; - if ( p.nOrig >= pgno && 0 == sqlite3BitvecTest( p.pInSavepoint, pgno ) ) - { - return true; + /* + ** Return true if it is necessary to write page *pPg into the sub-journal. + ** A page needs to be written into the sub-journal if there exists one + ** or more open savepoints for which: + ** + ** * The page-number is less than or equal to PagerSavepoint.nOrig, and + ** * The bit corresponding to the page-number is not set in + ** PagerSavepoint.pInSavepoint. + */ + static bool subjRequiresPage(PgHdr pPg) { + u32 pgno = pPg.pgno; + Pager pPager = pPg.pPager; + int i; + for (i = 0; i < pPager.nSavepoint; i++) { + PagerSavepoint p = pPager.aSavepoint[i]; + if (p.nOrig >= pgno && 0 == sqlite3BitvecTest(p.pInSavepoint, pgno)) { + return true; + } + } + return false; } - } - return false; - } - /* - ** Return true if the page is already in the journal file. - */ - static bool pageInJournal( PgHdr pPg ) - { - return sqlite3BitvecTest( pPg.pPager.pInJournal, pPg.pgno ) != 0; - } + /* + ** Return true if the page is already in the journal file. + */ + static bool pageInJournal(PgHdr pPg) { + return sqlite3BitvecTest(pPg.pPager.pInJournal, pPg.pgno) != 0; + } - /* - ** Read a 32-bit integer from the given file descriptor. Store the integer - ** that is read in pRes. Return SQLITE_OK if everything worked, or an - ** error code is something goes wrong. - ** - ** All values are stored on disk as big-endian. - */ - static int read32bits( sqlite3_file fd, int offset, ref int pRes ) - { - u32 u32_pRes = 0; - int rc = read32bits( fd, offset, ref u32_pRes ); - pRes = (int)u32_pRes; - return rc; - } - static int read32bits( sqlite3_file fd, i64 offset, ref u32 pRes ) - { - int rc = read32bits( fd, (int)offset, ref pRes ); - return rc; - } - static int read32bits( sqlite3_file fd, int offset, ref u32 pRes ) - { - byte[] ac = new byte[4]; - int rc = sqlite3OsRead( fd, ac, ac.Length, offset ); - if ( rc == SQLITE_OK ) - { - pRes = sqlite3Get4byte( ac ); - } - else - pRes = 0; - return rc; - } + /* + ** Read a 32-bit integer from the given file descriptor. Store the integer + ** that is read in pRes. Return SQLITE_OK if everything worked, or an + ** error code is something goes wrong. + ** + ** All values are stored on disk as big-endian. + */ + static int read32bits(sqlite3_file fd, int offset, ref int pRes) { + u32 u32_pRes = 0; + int rc = read32bits(fd, offset, ref u32_pRes); + pRes = (int)u32_pRes; + return rc; + } + static int read32bits(sqlite3_file fd, i64 offset, ref u32 pRes) { + int rc = read32bits(fd, (int)offset, ref pRes); + return rc; + } + static int read32bits(sqlite3_file fd, int offset, ref u32 pRes) { + byte[] ac = new byte[4]; + int rc = sqlite3OsRead(fd, ac, ac.Length, offset); + if (rc == SQLITE_OK) { + pRes = sqlite3Get4byte(ac); + } else + pRes = 0; + return rc; + } - /* - ** Write a 32-bit integer into a string buffer in big-endian byte order. - */ - //#define put32bits(A,B) sqlite3sqlite3Put4byte((u8*)A,B) - static void put32bits( string ac, int offset, int val ) - { - byte[] A = new byte[4]; - A[0] = (byte)ac[offset + 0]; - A[1] = (byte)ac[offset + 1]; - A[2] = (byte)ac[offset + 2]; - A[3] = (byte)ac[offset + 3]; - sqlite3Put4byte( A, 0, val ); - } - static void put32bits( byte[] ac, int offset, int val ) - { - sqlite3Put4byte( ac, offset, (u32)val ); - } - static void put32bits( byte[] ac, u32 val ) - { - sqlite3Put4byte( ac, 0U, val ); - } - static void put32bits( byte[] ac, int offset, u32 val ) - { - sqlite3Put4byte( ac, offset, val ); - } + /* + ** Write a 32-bit integer into a string buffer in big-endian byte order. + */ + //#define put32bits(A,B) sqlite3sqlite3Put4byte((u8*)A,B) + static void put32bits(string ac, int offset, int val) { + byte[] A = new byte[4]; + A[0] = (byte)ac[offset + 0]; + A[1] = (byte)ac[offset + 1]; + A[2] = (byte)ac[offset + 2]; + A[3] = (byte)ac[offset + 3]; + sqlite3Put4byte(A, 0, val); + } + static void put32bits(byte[] ac, int offset, int val) { + sqlite3Put4byte(ac, offset, (u32)val); + } + static void put32bits(byte[] ac, u32 val) { + sqlite3Put4byte(ac, 0U, val); + } + static void put32bits(byte[] ac, int offset, u32 val) { + sqlite3Put4byte(ac, offset, val); + } - /* - ** Write a 32-bit integer into the given file descriptor. Return SQLITE_OK - ** on success or an error code is something goes wrong. - */ - static int write32bits( sqlite3_file fd, i64 offset, u32 val ) - { - byte[] ac = new byte[4]; - put32bits( ac, val ); - return sqlite3OsWrite( fd, ac, 4, offset ); - } + /* + ** Write a 32-bit integer into the given file descriptor. Return SQLITE_OK + ** on success or an error code is something goes wrong. + */ + static int write32bits(sqlite3_file fd, i64 offset, u32 val) { + byte[] ac = new byte[4]; + put32bits(ac, val); + return sqlite3OsWrite(fd, ac, 4, offset); + } - /* - ** Unlock the database file to level eLock, which must be either NO_LOCK - ** or SHARED_LOCK. Regardless of whether or not the call to xUnlock() - ** succeeds, set the Pager.eLock variable to match the (attempted) new lock. - ** - ** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is - ** called, do not modify it. See the comment above the #define of - ** UNKNOWN_LOCK for an explanation of this. - */ - static int pagerUnlockDb( Pager pPager, int eLock ) - { - int rc = SQLITE_OK; + /* + ** Unlock the database file to level eLock, which must be either NO_LOCK + ** or SHARED_LOCK. Regardless of whether or not the call to xUnlock() + ** succeeds, set the Pager.eLock variable to match the (attempted) new lock. + ** + ** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is + ** called, do not modify it. See the comment above the #define of + ** UNKNOWN_LOCK for an explanation of this. + */ + static int pagerUnlockDb(Pager pPager, int eLock) { + int rc = SQLITE_OK; - Debug.Assert( !pPager.exclusiveMode || pPager.eLock == eLock ); - Debug.Assert( eLock == NO_LOCK || eLock == SHARED_LOCK ); - Debug.Assert( eLock != NO_LOCK || pagerUseWal( pPager ) == false ); - if ( isOpen( pPager.fd ) ) - { - Debug.Assert( pPager.eLock >= eLock ); - rc = sqlite3OsUnlock( pPager.fd, eLock ); - if ( pPager.eLock != UNKNOWN_LOCK ) - { - pPager.eLock = (u8)eLock; + Debug.Assert(!pPager.exclusiveMode || pPager.eLock == eLock); + Debug.Assert(eLock == NO_LOCK || eLock == SHARED_LOCK); + Debug.Assert(eLock != NO_LOCK || pagerUseWal(pPager) == false); + if (isOpen(pPager.fd)) { + Debug.Assert(pPager.eLock >= eLock); + rc = sqlite3OsUnlock(pPager.fd, eLock); + if (pPager.eLock != UNKNOWN_LOCK) { + pPager.eLock = (u8)eLock; + } + IOTRACE("UNLOCK %p %d\n", pPager, eLock); + } + return rc; } - IOTRACE( "UNLOCK %p %d\n", pPager, eLock ); - } - return rc; - } - /* - ** Lock the database file to level eLock, which must be either SHARED_LOCK, - ** RESERVED_LOCK or EXCLUSIVE_LOCK. If the caller is successful, set the - ** Pager.eLock variable to the new locking state. - ** - ** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is - ** called, do not modify it unless the new locking state is EXCLUSIVE_LOCK. - ** See the comment above the #define of UNKNOWN_LOCK for an explanation - ** of this. - */ - static int pagerLockDb( Pager pPager, int eLock ) - { - int rc = SQLITE_OK; + /* + ** Lock the database file to level eLock, which must be either SHARED_LOCK, + ** RESERVED_LOCK or EXCLUSIVE_LOCK. If the caller is successful, set the + ** Pager.eLock variable to the new locking state. + ** + ** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is + ** called, do not modify it unless the new locking state is EXCLUSIVE_LOCK. + ** See the comment above the #define of UNKNOWN_LOCK for an explanation + ** of this. + */ + static int pagerLockDb(Pager pPager, int eLock) { + int rc = SQLITE_OK; - Debug.Assert( eLock == SHARED_LOCK || eLock == RESERVED_LOCK || eLock == EXCLUSIVE_LOCK ); - if ( pPager.eLock < eLock || pPager.eLock == UNKNOWN_LOCK ) - { - rc = sqlite3OsLock( pPager.fd, eLock ); - if ( rc == SQLITE_OK && ( pPager.eLock != UNKNOWN_LOCK || eLock == EXCLUSIVE_LOCK ) ) - { - pPager.eLock = (u8)eLock; - IOTRACE( "LOCK %p %d\n", pPager, eLock ); + Debug.Assert(eLock == SHARED_LOCK || eLock == RESERVED_LOCK || eLock == EXCLUSIVE_LOCK); + if (pPager.eLock < eLock || pPager.eLock == UNKNOWN_LOCK) { + rc = sqlite3OsLock(pPager.fd, eLock); + if (rc == SQLITE_OK && (pPager.eLock != UNKNOWN_LOCK || eLock == EXCLUSIVE_LOCK)) { + pPager.eLock = (u8)eLock; + IOTRACE("LOCK %p %d\n", pPager, eLock); + } + } + return rc; } - } - return rc; - } - /* - ** This function determines whether or not the atomic-write optimization - ** can be used with this pager. The optimization can be used if: - ** - ** (a) the value returned by OsDeviceCharacteristics() indicates that - ** a database page may be written atomically, and - ** (b) the value returned by OsSectorSize() is less than or equal - ** to the page size. - ** - ** The optimization is also always enabled for temporary files. It is - ** an error to call this function if pPager is opened on an in-memory - ** database. - ** - ** If the optimization cannot be used, 0 is returned. If it can be used, - ** then the value returned is the size of the journal file when it - ** contains rollback data for exactly one page. - */ + /* + ** This function determines whether or not the atomic-write optimization + ** can be used with this pager. The optimization can be used if: + ** + ** (a) the value returned by OsDeviceCharacteristics() indicates that + ** a database page may be written atomically, and + ** (b) the value returned by OsSectorSize() is less than or equal + ** to the page size. + ** + ** The optimization is also always enabled for temporary files. It is + ** an error to call this function if pPager is opened on an in-memory + ** database. + ** + ** If the optimization cannot be used, 0 is returned. If it can be used, + ** then the value returned is the size of the journal file when it + ** contains rollback data for exactly one page. + */ #if SQLITE_ENABLE_ATOMIC_WRITE static int jrnlBufferSize(Pager *pPager){ Debug.Assert( 0==MEMDB ); @@ -1338,11 +1299,11 @@ static int jrnlBufferSize(Pager *pPager){ } #endif - /* -** If SQLITE_CHECK_PAGES is defined then we do some sanity checking -** on the cache using a hash function. This is used for testing -** and debugging only. -*/ + /* + ** If SQLITE_CHECK_PAGES is defined then we do some sanity checking + ** on the cache using a hash function. This is used for testing + ** and debugging only. + */ #if SQLITE_CHECK_PAGES /* ** Return a 32-bit hash of the page data for pPage. @@ -1375,882 +1336,809 @@ static void checkPage(PgHdr pPg){ } #else - //#define pager_datahash(X,Y) 0 - static int pager_datahash( int X, byte[] Y ) - { - return 0; - } + //#define pager_datahash(X,Y) 0 + static int pager_datahash(int X, byte[] Y) { + return 0; + } - //#define pager_pagehash(X) 0 - static int pager_pagehash( PgHdr X ) - { - return 0; - } + //#define pager_pagehash(X) 0 + static int pager_pagehash(PgHdr X) { + return 0; + } - //#define pager_set_pagehash(X) - static void pager_set_pagehash( PgHdr X ) - { - } + //#define pager_set_pagehash(X) + static void pager_set_pagehash(PgHdr X) { + } - //#define CHECK_PAGE(x) + //#define CHECK_PAGE(x) #endif //* SQLITE_CHECK_PAGES */ - /* -** When this is called the journal file for pager pPager must be open. -** This function attempts to read a master journal file name from the -** end of the file and, if successful, copies it into memory supplied -** by the caller. See comments above writeMasterJournal() for the format -** used to store a master journal file name at the end of a journal file. -** -** zMaster must point to a buffer of at least nMaster bytes allocated by -** the caller. This should be sqlite3_vfs.mxPathname+1 (to ensure there is -** enough space to write the master journal name). If the master journal -** name in the journal is longer than nMaster bytes (including a -** nul-terminator), then this is handled as if no master journal name -** were present in the journal. -** -** If a master journal file name is present at the end of the journal -** file, then it is copied into the buffer pointed to by zMaster. A -** nul-terminator byte is appended to the buffer following the master -** journal file name. -** -** If it is determined that no master journal file name is present -** zMaster[0] is set to 0 and SQLITE_OK returned. -** -** If an error occurs while reading from the journal file, an SQLite -** error code is returned. -*/ - static int readMasterJournal( sqlite3_file pJrnl, byte[] zMaster, u32 nMaster ) - { - int rc; /* Return code */ - int len = 0; /* Length in bytes of master journal name */ - i64 szJ = 0; /* Total size in bytes of journal file pJrnl */ - u32 cksum = 0; /* MJ checksum value read from journal */ - int u; /* Unsigned loop counter */ - byte[] aMagic = new byte[8]; /* A buffer to hold the magic header */ - - zMaster[0] = 0; - - if ( SQLITE_OK != ( rc = sqlite3OsFileSize( pJrnl, ref szJ ) ) - || szJ < 16 - || SQLITE_OK != ( rc = read32bits( pJrnl, (int)( szJ - 16 ), ref len ) ) - || len >= nMaster - || SQLITE_OK != ( rc = read32bits( pJrnl, szJ - 12, ref cksum ) ) - || SQLITE_OK != ( rc = sqlite3OsRead( pJrnl, aMagic, 8, szJ - 8 ) ) - || memcmp( aMagic, aJournalMagic, 8 ) != 0 - || SQLITE_OK != ( rc = sqlite3OsRead( pJrnl, zMaster, len, (long)( szJ - 16 - len ) ) ) - ) - { - return rc; - } - - /* See if the checksum matches the master journal name */ - for ( u = 0; u < len; u++ ) - { - cksum -= zMaster[u]; - } - if ( cksum != 0 ) - { - /* If the checksum doesn't add up, then one or more of the disk sectors - ** containing the master journal filename is corrupted. This means - ** definitely roll back, so just return SQLITE_OK and report a (nul) - ** master-journal filename. - */ - len = 0; - } - if ( len == 0 ) - zMaster[0] = 0; - - return SQLITE_OK; - } - - /* - ** Return the offset of the sector boundary at or immediately - ** following the value in pPager.journalOff, assuming a sector - ** size of pPager.sectorSize bytes. - ** - ** i.e for a sector size of 512: - ** - ** Pager.journalOff Return value - ** --------------------------------------- - ** 0 0 - ** 512 512 - ** 100 512 - ** 2000 2048 - ** + /* + ** When this is called the journal file for pager pPager must be open. + ** This function attempts to read a master journal file name from the + ** end of the file and, if successful, copies it into memory supplied + ** by the caller. See comments above writeMasterJournal() for the format + ** used to store a master journal file name at the end of a journal file. + ** + ** zMaster must point to a buffer of at least nMaster bytes allocated by + ** the caller. This should be sqlite3_vfs.mxPathname+1 (to ensure there is + ** enough space to write the master journal name). If the master journal + ** name in the journal is longer than nMaster bytes (including a + ** nul-terminator), then this is handled as if no master journal name + ** were present in the journal. + ** + ** If a master journal file name is present at the end of the journal + ** file, then it is copied into the buffer pointed to by zMaster. A + ** nul-terminator byte is appended to the buffer following the master + ** journal file name. + ** + ** If it is determined that no master journal file name is present + ** zMaster[0] is set to 0 and SQLITE_OK returned. + ** + ** If an error occurs while reading from the journal file, an SQLite + ** error code is returned. */ - static i64 journalHdrOffset( Pager pPager ) - { - i64 offset = 0; - i64 c = pPager.journalOff; - if ( c != 0 ) - { - offset = (int)( ( ( c - 1 ) / pPager.sectorSize + 1 ) * pPager.sectorSize );//offset = ((c-1)/JOURNAL_HDR_SZ(pPager) + 1) * JOURNAL_HDR_SZ(pPager); - } - Debug.Assert( offset % pPager.sectorSize == 0 ); //Debug.Assert(offset % JOURNAL_HDR_SZ(pPager) == 0); - Debug.Assert( offset >= c ); - Debug.Assert( ( offset - c ) < pPager.sectorSize );//Debug.Assert( (offset-c)= nMaster + || SQLITE_OK != (rc = read32bits(pJrnl, szJ - 12, ref cksum)) + || SQLITE_OK != (rc = sqlite3OsRead(pJrnl, aMagic, 8, szJ - 8)) + || memcmp(aMagic, aJournalMagic, 8) != 0 + || SQLITE_OK != (rc = sqlite3OsRead(pJrnl, zMaster, len, (long)(szJ - 16 - len))) + ) { + return rc; + } - /* - ** The journal file must be open when this function is called. - ** - ** This function is a no-op if the journal file has not been written to - ** within the current transaction (i.e. if Pager.journalOff==0). - ** - ** If doTruncate is non-zero or the Pager.journalSizeLimit variable is - ** set to 0, then truncate the journal file to zero bytes in size. Otherwise, - ** zero the 28-byte header at the start of the journal file. In either case, - ** if the pager is not in no-sync mode, sync the journal file immediately - ** after writing or truncating it. - ** - ** If Pager.journalSizeLimit is set to a positive, non-zero value, and - ** following the truncation or zeroing described above the size of the - ** journal file in bytes is larger than this value, then truncate the - ** journal file to Pager.journalSizeLimit bytes. The journal file does - ** not need to be synced following this operation. - ** - ** If an IO error occurs, abandon processing and return the IO error code. - ** Otherwise, return SQLITE_OK. - */ - static int zeroJournalHdr( Pager pPager, int doTruncate ) - { - int rc = SQLITE_OK; /* Return code */ - Debug.Assert( isOpen( pPager.jfd ) ); + /* See if the checksum matches the master journal name */ + for (u = 0; u < len; u++) { + cksum -= zMaster[u]; + } + if (cksum != 0) { + /* If the checksum doesn't add up, then one or more of the disk sectors + ** containing the master journal filename is corrupted. This means + ** definitely roll back, so just return SQLITE_OK and report a (nul) + ** master-journal filename. + */ + len = 0; + } + if (len == 0) + zMaster[0] = 0; - if ( pPager.journalOff != 0 ) - { - i64 iLimit = pPager.journalSizeLimit; /* Local cache of jsl */ - IOTRACE( "JZEROHDR %p\n", pPager ); - if ( doTruncate != 0 || iLimit == 0 ) - { - rc = sqlite3OsTruncate( pPager.jfd, 0 ); - } - else - { - byte[] zeroHdr = new byte[28];// = {0}; - rc = sqlite3OsWrite( pPager.jfd, zeroHdr, zeroHdr.Length, 0 ); - } - if ( rc == SQLITE_OK && !pPager.noSync ) - { - rc = sqlite3OsSync( pPager.jfd, SQLITE_SYNC_DATAONLY | pPager.syncFlags ); + return SQLITE_OK; } - /* At this point the transaction is committed but the write lock - ** is still held on the file. If there is a size limit configured for - ** the persistent journal and the journal file currently consumes more - ** space than that limit allows for, truncate it now. There is no need - ** to sync the file following this operation. + /* + ** Return the offset of the sector boundary at or immediately + ** following the value in pPager.journalOff, assuming a sector + ** size of pPager.sectorSize bytes. + ** + ** i.e for a sector size of 512: + ** + ** Pager.journalOff Return value + ** --------------------------------------- + ** 0 0 + ** 512 512 + ** 100 512 + ** 2000 2048 + ** */ - if ( rc == SQLITE_OK && iLimit > 0 ) - { - i64 sz = 0; - rc = sqlite3OsFileSize( pPager.jfd, ref sz ); - if ( rc == SQLITE_OK && sz > iLimit ) - { - rc = sqlite3OsTruncate( pPager.jfd, iLimit ); - } + static i64 journalHdrOffset(Pager pPager) { + i64 offset = 0; + i64 c = pPager.journalOff; + if (c != 0) { + offset = (int)(((c - 1) / pPager.sectorSize + 1) * pPager.sectorSize);//offset = ((c-1)/JOURNAL_HDR_SZ(pPager) + 1) * JOURNAL_HDR_SZ(pPager); + } + Debug.Assert(offset % pPager.sectorSize == 0); //Debug.Assert(offset % JOURNAL_HDR_SZ(pPager) == 0); + Debug.Assert(offset >= c); + Debug.Assert((offset - c) < pPager.sectorSize);//Debug.Assert( (offset-c) JOURNAL_HDR_SZ( pPager ) ) - { - nHeader = JOURNAL_HDR_SZ( pPager ); - } - /* If there are active savepoints and any of them were created - ** since the most recent journal header was written, update the - ** PagerSavepoint.iHdrOffset fields now. - */ - for ( ii = 0; ii < pPager.nSavepoint; ii++ ) - { - if ( pPager.aSavepoint[ii].iHdrOffset == 0 ) - { - pPager.aSavepoint[ii].iHdrOffset = pPager.journalOff; + static void seekJournalHdr(Pager pPager) { + pPager.journalOff = journalHdrOffset(pPager); } - } - pPager.journalHdr = pPager.journalOff = journalHdrOffset( pPager ); - - /* - ** Write the nRec Field - the number of page records that follow this - ** journal header. Normally, zero is written to this value at this time. - ** After the records are added to the journal (and the journal synced, - ** if in full-sync mode), the zero is overwritten with the true number - ** of records (see syncJournal()). - ** - ** A faster alternative is to write 0xFFFFFFFF to the nRec field. When - ** reading the journal this value tells SQLite to assume that the - ** rest of the journal file contains valid page records. This assumption - ** is dangerous, as if a failure occurred whilst writing to the journal - ** file it may contain some garbage data. There are two scenarios - ** where this risk can be ignored: - ** - ** * When the pager is in no-sync mode. Corruption can follow a - ** power failure in this case anyway. - ** - ** * When the SQLITE_IOCAP_SAFE_APPEND flag is set. This guarantees - ** that garbage data is never appended to the journal file. - */ - Debug.Assert( isOpen( pPager.fd ) || pPager.noSync ); - if ( pPager.noSync || ( pPager.journalMode == PAGER_JOURNALMODE_MEMORY ) - || ( sqlite3OsDeviceCharacteristics( pPager.fd ) & SQLITE_IOCAP_SAFE_APPEND ) != 0 - ) - { - aJournalMagic.CopyTo( zHeader, 0 );// memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic)); - put32bits( zHeader, aJournalMagic.Length, 0xffffffff ); - } - else - { - Array.Clear( zHeader, 0, aJournalMagic.Length + 4 );//memset(zHeader, 0, sizeof(aJournalMagic)+4); - } - /* The random check-hash initialiser */ - i64 i64Temp = 0; - sqlite3_randomness( sizeof( i64 ), ref i64Temp ); - pPager.cksumInit = (u32)i64Temp; - put32bits( zHeader, aJournalMagic.Length + 4, pPager.cksumInit ); - /* The initial database size */ - put32bits( zHeader, aJournalMagic.Length + 8, pPager.dbOrigSize ); - /* The assumed sector size for this process */ - put32bits( zHeader, aJournalMagic.Length + 12, pPager.sectorSize ); - /* The page size */ - put32bits( zHeader, aJournalMagic.Length + 16, (u32)pPager.pageSize ); - - /* Initializing the tail of the buffer is not necessary. Everything - ** works find if the following memset() is omitted. But initializing - ** the memory prevents valgrind from complaining, so we are willing to - ** take the performance hit. - */ - // memset(&zHeader[sizeof(aJournalMagic)+20], 0, - // nHeader-(sizeof(aJournalMagic)+20)); - Array.Clear( zHeader, aJournalMagic.Length + 20, (int)nHeader - ( aJournalMagic.Length + 20 ) ); - - /* In theory, it is only necessary to write the 28 bytes that the - ** journal header consumes to the journal file here. Then increment the - ** Pager.journalOff variable by JOURNAL_HDR_SZ so that the next - ** record is written to the following sector (leaving a gap in the file - ** that will be implicitly filled in by the OS). - ** - ** However it has been discovered that on some systems this pattern can - ** be significantly slower than contiguously writing data to the file, - ** even if that means explicitly writing data to the block of - ** (JOURNAL_HDR_SZ - 28) bytes that will not be used. So that is what - ** is done. - ** - ** The loop is required here in case the sector-size is larger than the - ** database page size. Since the zHeader buffer is only Pager.pageSize - ** bytes in size, more than one call to sqlite3OsWrite() may be required - ** to populate the entire journal header sector. - */ - for ( nWrite = 0; rc == SQLITE_OK && nWrite < JOURNAL_HDR_SZ( pPager ); nWrite += nHeader ) - { - IOTRACE( "JHDR %p %lld %d\n", pPager, pPager.journalHdr, nHeader ); - rc = sqlite3OsWrite( pPager.jfd, zHeader, (int)nHeader, pPager.journalOff ); - Debug.Assert( pPager.journalHdr <= pPager.journalOff ); - pPager.journalOff += (int)nHeader; - } - return rc; - } - - /* - ** The journal file must be open when this is called. A journal header file - ** (JOURNAL_HDR_SZ bytes) is read from the current location in the journal - ** file. The current location in the journal file is given by - ** pPager.journalOff. See comments above function writeJournalHdr() for - ** a description of the journal header format. - ** - ** If the header is read successfully, *pNRec is set to the number of - ** page records following this header and *pDbSize is set to the size of the - ** database before the transaction began, in pages. Also, pPager.cksumInit - ** is set to the value read from the journal header. SQLITE_OK is returned - ** in this case. - ** - ** If the journal header file appears to be corrupted, SQLITE_DONE is - ** returned and *pNRec and *PDbSize are undefined. If JOURNAL_HDR_SZ bytes - ** cannot be read from the journal file an error code is returned. - */ - static int readJournalHdr( - Pager pPager, /* Pager object */ - int isHot, - i64 journalSize, /* Size of the open journal file in bytes */ - out u32 pNRec, /* OUT: Value read from the nRec field */ - out u32 pDbSize /* OUT: Value of original database size field */ - ) - { - int rc; /* Return code */ - byte[] aMagic = new byte[8]; /* A buffer to hold the magic header */ - i64 iHdrOff; /* Offset of journal header being read */ + /* + ** The journal file must be open when this function is called. + ** + ** This function is a no-op if the journal file has not been written to + ** within the current transaction (i.e. if Pager.journalOff==0). + ** + ** If doTruncate is non-zero or the Pager.journalSizeLimit variable is + ** set to 0, then truncate the journal file to zero bytes in size. Otherwise, + ** zero the 28-byte header at the start of the journal file. In either case, + ** if the pager is not in no-sync mode, sync the journal file immediately + ** after writing or truncating it. + ** + ** If Pager.journalSizeLimit is set to a positive, non-zero value, and + ** following the truncation or zeroing described above the size of the + ** journal file in bytes is larger than this value, then truncate the + ** journal file to Pager.journalSizeLimit bytes. The journal file does + ** not need to be synced following this operation. + ** + ** If an IO error occurs, abandon processing and return the IO error code. + ** Otherwise, return SQLITE_OK. + */ + static int zeroJournalHdr(Pager pPager, int doTruncate) { + int rc = SQLITE_OK; /* Return code */ + Debug.Assert(isOpen(pPager.jfd)); + + if (pPager.journalOff != 0) { + i64 iLimit = pPager.journalSizeLimit; /* Local cache of jsl */ + IOTRACE("JZEROHDR %p\n", pPager); + if (doTruncate != 0 || iLimit == 0) { + rc = sqlite3OsTruncate(pPager.jfd, 0); + } else { + byte[] zeroHdr = new byte[28];// = {0}; + rc = sqlite3OsWrite(pPager.jfd, zeroHdr, zeroHdr.Length, 0); + } + if (rc == SQLITE_OK && !pPager.noSync) { + rc = sqlite3OsSync(pPager.jfd, SQLITE_SYNC_DATAONLY | pPager.syncFlags); + } - Debug.Assert( isOpen( pPager.jfd ) ); /* Journal file must be open. */ + /* At this point the transaction is committed but the write lock + ** is still held on the file. If there is a size limit configured for + ** the persistent journal and the journal file currently consumes more + ** space than that limit allows for, truncate it now. There is no need + ** to sync the file following this operation. + */ + if (rc == SQLITE_OK && iLimit > 0) { + i64 sz = 0; + rc = sqlite3OsFileSize(pPager.jfd, ref sz); + if (rc == SQLITE_OK && sz > iLimit) { + rc = sqlite3OsTruncate(pPager.jfd, iLimit); + } + } + } + return rc; + } - pNRec = 0; - pDbSize = 0; + /* + ** The journal file must be open when this routine is called. A journal + ** header (JOURNAL_HDR_SZ bytes) is written into the journal file at the + ** current location. + ** + ** The format for the journal header is as follows: + ** - 8 bytes: Magic identifying journal format. + ** - 4 bytes: Number of records in journal, or -1 no-sync mode is on. + ** - 4 bytes: Random number used for page hash. + ** - 4 bytes: Initial database page count. + ** - 4 bytes: Sector size used by the process that wrote this journal. + ** - 4 bytes: Database page size. + ** + ** Followed by (JOURNAL_HDR_SZ - 28) bytes of unused space. + */ + static int writeJournalHdr(Pager pPager) { - /* Advance Pager.journalOff to the start of the next sector. If the - ** journal file is too small for there to be a header stored at this - ** point, return SQLITE_DONE. - */ - pPager.journalOff = journalHdrOffset( pPager ); - if ( pPager.journalOff + JOURNAL_HDR_SZ( pPager ) > journalSize ) - { - return SQLITE_DONE; - } - iHdrOff = pPager.journalOff; + int rc = SQLITE_OK; /* Return code */ + byte[] zHeader = pPager.pTmpSpace; /* Temporary space used to build header */ + u32 nHeader = (u32)pPager.pageSize; /* Size of buffer pointed to by zHeader */ + u32 nWrite; /* Bytes of header sector written */ + int ii; /* Loop counter */ - /* Read in the first 8 bytes of the journal header. If they do not match - ** the magic string found at the start of each journal header, return - ** SQLITE_DONE. If an IO error occurs, return an error code. Otherwise, - ** proceed. - */ - if ( isHot != 0 || iHdrOff != pPager.journalHdr ) - { - rc = sqlite3OsRead( pPager.jfd, aMagic, aMagic.Length, iHdrOff ); - if ( rc != 0 ) - { - return rc; - } - if ( memcmp( aMagic, aJournalMagic, aMagic.Length ) != 0 ) - { - return SQLITE_DONE; - } - } - /* Read the first three 32-bit fields of the journal header: The nRec - ** field, the checksum-initializer and the database size at the start - ** of the transaction. Return an error code if anything goes wrong. - */ - if ( SQLITE_OK != ( rc = read32bits( pPager.jfd, iHdrOff + 8, ref pNRec ) ) - || SQLITE_OK != ( rc = read32bits( pPager.jfd, iHdrOff + 12, ref pPager.cksumInit ) ) - || SQLITE_OK != ( rc = read32bits( pPager.jfd, iHdrOff + 16, ref pDbSize ) ) - ) - { - return rc; - } + Debug.Assert(isOpen(pPager.jfd)); /* Journal file must be open. */ - if ( pPager.journalOff == 0 ) - { - u32 iPageSize = 0; /* Page-size field of journal header */ - u32 iSectorSize = 0; /* Sector-size field of journal header */ - - /* Read the page-size and sector-size journal header fields. */ - if ( SQLITE_OK != ( rc = read32bits( pPager.jfd, iHdrOff + 20, ref iSectorSize ) ) - || SQLITE_OK != ( rc = read32bits( pPager.jfd, iHdrOff + 24, ref iPageSize ) ) - ) - { - return rc; - } + if (nHeader > JOURNAL_HDR_SZ(pPager)) { + nHeader = JOURNAL_HDR_SZ(pPager); + } + /* If there are active savepoints and any of them were created + ** since the most recent journal header was written, update the + ** PagerSavepoint.iHdrOffset fields now. + */ + for (ii = 0; ii < pPager.nSavepoint; ii++) { + if (pPager.aSavepoint[ii].iHdrOffset == 0) { + pPager.aSavepoint[ii].iHdrOffset = pPager.journalOff; + } + } + pPager.journalHdr = pPager.journalOff = journalHdrOffset(pPager); + + /* + ** Write the nRec Field - the number of page records that follow this + ** journal header. Normally, zero is written to this value at this time. + ** After the records are added to the journal (and the journal synced, + ** if in full-sync mode), the zero is overwritten with the true number + ** of records (see syncJournal()). + ** + ** A faster alternative is to write 0xFFFFFFFF to the nRec field. When + ** reading the journal this value tells SQLite to assume that the + ** rest of the journal file contains valid page records. This assumption + ** is dangerous, as if a failure occurred whilst writing to the journal + ** file it may contain some garbage data. There are two scenarios + ** where this risk can be ignored: + ** + ** * When the pager is in no-sync mode. Corruption can follow a + ** power failure in this case anyway. + ** + ** * When the SQLITE_IOCAP_SAFE_APPEND flag is set. This guarantees + ** that garbage data is never appended to the journal file. + */ + Debug.Assert(isOpen(pPager.fd) || pPager.noSync); + if (pPager.noSync || (pPager.journalMode == PAGER_JOURNALMODE_MEMORY) + || (sqlite3OsDeviceCharacteristics(pPager.fd) & SQLITE_IOCAP_SAFE_APPEND) != 0 + ) { + aJournalMagic.CopyTo(zHeader, 0);// memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic)); + put32bits(zHeader, aJournalMagic.Length, 0xffffffff); + } else { + Array.Clear(zHeader, 0, aJournalMagic.Length + 4);//memset(zHeader, 0, sizeof(aJournalMagic)+4); + } - /* Versions of SQLite prior to 3.5.8 set the page-size field of the - ** journal header to zero. In this case, assume that the Pager.pageSize - ** variable is already set to the correct page size. - */ - if ( iPageSize == 0 ) - { - iPageSize = (u32)pPager.pageSize; + /* The random check-hash initialiser */ + i64 i64Temp = 0; + sqlite3_randomness(sizeof(i64), ref i64Temp); + pPager.cksumInit = (u32)i64Temp; + put32bits(zHeader, aJournalMagic.Length + 4, pPager.cksumInit); + /* The initial database size */ + put32bits(zHeader, aJournalMagic.Length + 8, pPager.dbOrigSize); + /* The assumed sector size for this process */ + put32bits(zHeader, aJournalMagic.Length + 12, pPager.sectorSize); + /* The page size */ + put32bits(zHeader, aJournalMagic.Length + 16, (u32)pPager.pageSize); + + /* Initializing the tail of the buffer is not necessary. Everything + ** works find if the following memset() is omitted. But initializing + ** the memory prevents valgrind from complaining, so we are willing to + ** take the performance hit. + */ + // memset(&zHeader[sizeof(aJournalMagic)+20], 0, + // nHeader-(sizeof(aJournalMagic)+20)); + Array.Clear(zHeader, aJournalMagic.Length + 20, (int)nHeader - (aJournalMagic.Length + 20)); + + /* In theory, it is only necessary to write the 28 bytes that the + ** journal header consumes to the journal file here. Then increment the + ** Pager.journalOff variable by JOURNAL_HDR_SZ so that the next + ** record is written to the following sector (leaving a gap in the file + ** that will be implicitly filled in by the OS). + ** + ** However it has been discovered that on some systems this pattern can + ** be significantly slower than contiguously writing data to the file, + ** even if that means explicitly writing data to the block of + ** (JOURNAL_HDR_SZ - 28) bytes that will not be used. So that is what + ** is done. + ** + ** The loop is required here in case the sector-size is larger than the + ** database page size. Since the zHeader buffer is only Pager.pageSize + ** bytes in size, more than one call to sqlite3OsWrite() may be required + ** to populate the entire journal header sector. + */ + for (nWrite = 0; rc == SQLITE_OK && nWrite < JOURNAL_HDR_SZ(pPager); nWrite += nHeader) { + IOTRACE("JHDR %p %lld %d\n", pPager, pPager.journalHdr, nHeader); + rc = sqlite3OsWrite(pPager.jfd, zHeader, (int)nHeader, pPager.journalOff); + Debug.Assert(pPager.journalHdr <= pPager.journalOff); + pPager.journalOff += (int)nHeader; + } + return rc; } - /* Check that the values read from the page-size and sector-size fields - ** are within range. To be 'in range', both values need to be a power - ** of two greater than or equal to 512 or 32, and not greater than their - ** respective compile time maximum limits. + /* + ** The journal file must be open when this is called. A journal header file + ** (JOURNAL_HDR_SZ bytes) is read from the current location in the journal + ** file. The current location in the journal file is given by + ** pPager.journalOff. See comments above function writeJournalHdr() for + ** a description of the journal header format. + ** + ** If the header is read successfully, *pNRec is set to the number of + ** page records following this header and *pDbSize is set to the size of the + ** database before the transaction began, in pages. Also, pPager.cksumInit + ** is set to the value read from the journal header. SQLITE_OK is returned + ** in this case. + ** + ** If the journal header file appears to be corrupted, SQLITE_DONE is + ** returned and *pNRec and *PDbSize are undefined. If JOURNAL_HDR_SZ bytes + ** cannot be read from the journal file an error code is returned. */ - if ( iPageSize < 512 || iSectorSize < 32 - || iPageSize > SQLITE_MAX_PAGE_SIZE || iSectorSize > MAX_SECTOR_SIZE - || ( ( iPageSize - 1 ) & iPageSize ) != 0 || ( ( iSectorSize - 1 ) & iSectorSize ) != 0 - ) - { - /* If the either the page-size or sector-size in the journal-header is - ** invalid, then the process that wrote the journal-header must have - ** crashed before the header was synced. In this case stop reading - ** the journal file here. - */ - return SQLITE_DONE; - } + static int readJournalHdr( + Pager pPager, /* Pager object */ + int isHot, + i64 journalSize, /* Size of the open journal file in bytes */ + out u32 pNRec, /* OUT: Value read from the nRec field */ + out u32 pDbSize /* OUT: Value of original database size field */ + ) { + int rc; /* Return code */ + byte[] aMagic = new byte[8]; /* A buffer to hold the magic header */ + i64 iHdrOff; /* Offset of journal header being read */ + + Debug.Assert(isOpen(pPager.jfd)); /* Journal file must be open. */ + + pNRec = 0; + pDbSize = 0; + + /* Advance Pager.journalOff to the start of the next sector. If the + ** journal file is too small for there to be a header stored at this + ** point, return SQLITE_DONE. + */ + pPager.journalOff = journalHdrOffset(pPager); + if (pPager.journalOff + JOURNAL_HDR_SZ(pPager) > journalSize) { + return SQLITE_DONE; + } + iHdrOff = pPager.journalOff; - /* Update the page-size to match the value read from the journal. - ** Use a testcase() macro to make sure that malloc failure within - ** PagerSetPagesize() is tested. - */ - rc = sqlite3PagerSetPagesize( pPager, ref iPageSize, -1 ); - testcase( rc != SQLITE_OK ); - - /* Update the assumed sector-size to match the value used by - ** the process that created this journal. If this journal was - ** created by a process other than this one, then this routine - ** is being called from within pager_playback(). The local value - ** of Pager.sectorSize is restored at the end of that routine. - */ - pPager.sectorSize = iSectorSize; - } + /* Read in the first 8 bytes of the journal header. If they do not match + ** the magic string found at the start of each journal header, return + ** SQLITE_DONE. If an IO error occurs, return an error code. Otherwise, + ** proceed. + */ + if (isHot != 0 || iHdrOff != pPager.journalHdr) { + rc = sqlite3OsRead(pPager.jfd, aMagic, aMagic.Length, iHdrOff); + if (rc != 0) { + return rc; + } + if (memcmp(aMagic, aJournalMagic, aMagic.Length) != 0) { + return SQLITE_DONE; + } + } + /* Read the first three 32-bit fields of the journal header: The nRec + ** field, the checksum-initializer and the database size at the start + ** of the transaction. Return an error code if anything goes wrong. + */ + if (SQLITE_OK != (rc = read32bits(pPager.jfd, iHdrOff + 8, ref pNRec)) + || SQLITE_OK != (rc = read32bits(pPager.jfd, iHdrOff + 12, ref pPager.cksumInit)) + || SQLITE_OK != (rc = read32bits(pPager.jfd, iHdrOff + 16, ref pDbSize)) + ) { + return rc; + } - pPager.journalOff += (int)JOURNAL_HDR_SZ( pPager ); - return rc; - } + if (pPager.journalOff == 0) { + u32 iPageSize = 0; /* Page-size field of journal header */ + u32 iSectorSize = 0; /* Sector-size field of journal header */ - /* - ** Write the supplied master journal name into the journal file for pager - ** pPager at the current location. The master journal name must be the last - ** thing written to a journal file. If the pager is in full-sync mode, the - ** journal file descriptor is advanced to the next sector boundary before - ** anything is written. The format is: - ** - ** + 4 bytes: PAGER_MJ_PGNO. - ** + N bytes: Master journal filename in utf-8. - ** + 4 bytes: N (length of master journal name in bytes, no nul-terminator). - ** + 4 bytes: Master journal name checksum. - ** + 8 bytes: aJournalMagic[]. - ** - ** The master journal page checksum is the sum of the bytes in the master - ** journal name, where each byte is interpreted as a signed 8-bit integer. - ** - ** If zMaster is a NULL pointer (occurs for a single database transaction), - ** this call is a no-op. - */ - static int writeMasterJournal( Pager pPager, string zMaster ) - { - int rc; /* Return code */ - int nMaster; /* Length of string zMaster */ - i64 iHdrOff; /* Offset of header in journal file */ - i64 jrnlSize = 0; /* Size of journal file on disk */ - u32 cksum = 0; /* Checksum of string zMaster */ - - Debug.Assert( pPager.setMaster == 0 ); - Debug.Assert( !pagerUseWal( pPager ) ); - if ( null == zMaster - || pPager.journalMode == PAGER_JOURNALMODE_MEMORY - || pPager.journalMode == PAGER_JOURNALMODE_OFF - ) - { - return SQLITE_OK; - } + /* Read the page-size and sector-size journal header fields. */ + if (SQLITE_OK != (rc = read32bits(pPager.jfd, iHdrOff + 20, ref iSectorSize)) + || SQLITE_OK != (rc = read32bits(pPager.jfd, iHdrOff + 24, ref iPageSize)) + ) { + return rc; + } - pPager.setMaster = 1; - Debug.Assert( isOpen( pPager.jfd ) ); - Debug.Assert( pPager.journalHdr <= pPager.journalOff ); + /* Versions of SQLite prior to 3.5.8 set the page-size field of the + ** journal header to zero. In this case, assume that the Pager.pageSize + ** variable is already set to the correct page size. + */ + if (iPageSize == 0) { + iPageSize = (u32)pPager.pageSize; + } - /* Calculate the length in bytes and the checksum of zMaster */ - for ( nMaster = 0; nMaster < zMaster.Length && zMaster[nMaster] != 0; nMaster++ ) - { - cksum += zMaster[nMaster]; - } + /* Check that the values read from the page-size and sector-size fields + ** are within range. To be 'in range', both values need to be a power + ** of two greater than or equal to 512 or 32, and not greater than their + ** respective compile time maximum limits. + */ + if (iPageSize < 512 || iSectorSize < 32 + || iPageSize > SQLITE_MAX_PAGE_SIZE || iSectorSize > MAX_SECTOR_SIZE + || ((iPageSize - 1) & iPageSize) != 0 || ((iSectorSize - 1) & iSectorSize) != 0 + ) { + /* If the either the page-size or sector-size in the journal-header is + ** invalid, then the process that wrote the journal-header must have + ** crashed before the header was synced. In this case stop reading + ** the journal file here. + */ + return SQLITE_DONE; + } - /* If in full-sync mode, advance to the next disk sector before writing - ** the master journal name. This is in case the previous page written to - ** the journal has already been synced. - */ - if ( pPager.fullSync ) - { - pPager.journalOff = journalHdrOffset( pPager ); - } - iHdrOff = pPager.journalOff; - /* Write the master journal data to the end of the journal file. If - ** an error occurs, return the error code to the caller. - */ - if ( ( 0 != ( rc = write32bits( pPager.jfd, iHdrOff, (u32)PAGER_MJ_PGNO( pPager ) ) ) ) - || ( 0 != ( rc = sqlite3OsWrite( pPager.jfd, Encoding.UTF8.GetBytes( zMaster ), nMaster, iHdrOff + 4 ) ) ) - || ( 0 != ( rc = write32bits( pPager.jfd, iHdrOff + 4 + nMaster, (u32)nMaster ) ) ) - || ( 0 != ( rc = write32bits( pPager.jfd, iHdrOff + 4 + nMaster + 4, cksum ) ) ) - || ( 0 != ( rc = sqlite3OsWrite( pPager.jfd, aJournalMagic, 8, iHdrOff + 4 + nMaster + 8 ) ) ) - ) - { - return rc; - } - pPager.journalOff += ( nMaster + 20 ); - - /* If the pager is in peristent-journal mode, then the physical - ** journal-file may extend past the end of the master-journal name - ** and 8 bytes of magic data just written to the file. This is - ** dangerous because the code to rollback a hot-journal file - ** will not be able to find the master-journal name to determine - ** whether or not the journal is hot. - ** - ** Easiest thing to do in this scenario is to truncate the journal - ** file to the required size. - */ - if ( SQLITE_OK == ( rc = sqlite3OsFileSize( pPager.jfd, ref jrnlSize ) ) - && jrnlSize > pPager.journalOff - ) - { - rc = sqlite3OsTruncate( pPager.jfd, pPager.journalOff ); - } + /* Update the page-size to match the value read from the journal. + ** Use a testcase() macro to make sure that malloc failure within + ** PagerSetPagesize() is tested. + */ + rc = sqlite3PagerSetPagesize(pPager, ref iPageSize, -1); + testcase(rc != SQLITE_OK); + + /* Update the assumed sector-size to match the value used by + ** the process that created this journal. If this journal was + ** created by a process other than this one, then this routine + ** is being called from within pager_playback(). The local value + ** of Pager.sectorSize is restored at the end of that routine. + */ + pPager.sectorSize = iSectorSize; + } - return rc; - } + pPager.journalOff += (int)JOURNAL_HDR_SZ(pPager); + return rc; + } - /* - ** Find a page in the hash table given its page number. Return - ** a pointer to the page or NULL if the requested page is not - ** already in memory. - */ - static PgHdr pager_lookup( Pager pPager, u32 pgno ) - { - PgHdr p = null; /* Return value */ - /* It is not possible for a call to PcacheFetch() with createFlag==0 to - ** fail, since no attempt to allocate dynamic memory will be made. - */ - sqlite3PcacheFetch( pPager.pPCache, pgno, 0, ref p ); - return p; - } + /* + ** Write the supplied master journal name into the journal file for pager + ** pPager at the current location. The master journal name must be the last + ** thing written to a journal file. If the pager is in full-sync mode, the + ** journal file descriptor is advanced to the next sector boundary before + ** anything is written. The format is: + ** + ** + 4 bytes: PAGER_MJ_PGNO. + ** + N bytes: Master journal filename in utf-8. + ** + 4 bytes: N (length of master journal name in bytes, no nul-terminator). + ** + 4 bytes: Master journal name checksum. + ** + 8 bytes: aJournalMagic[]. + ** + ** The master journal page checksum is the sum of the bytes in the master + ** journal name, where each byte is interpreted as a signed 8-bit integer. + ** + ** If zMaster is a NULL pointer (occurs for a single database transaction), + ** this call is a no-op. + */ + static int writeMasterJournal(Pager pPager, string zMaster) { + int rc; /* Return code */ + int nMaster; /* Length of string zMaster */ + i64 iHdrOff; /* Offset of header in journal file */ + i64 jrnlSize = 0; /* Size of journal file on disk */ + u32 cksum = 0; /* Checksum of string zMaster */ + + Debug.Assert(pPager.setMaster == 0); + Debug.Assert(!pagerUseWal(pPager)); + if (null == zMaster + || pPager.journalMode == PAGER_JOURNALMODE_MEMORY + || pPager.journalMode == PAGER_JOURNALMODE_OFF + ) { + return SQLITE_OK; + } - /* - ** Discard the entire contents of the in-memory page-cache. - */ - static void pager_reset( Pager pPager ) - { - sqlite3BackupRestart( pPager.pBackup ); - sqlite3PcacheClear( pPager.pPCache ); - } + pPager.setMaster = 1; + Debug.Assert(isOpen(pPager.jfd)); + Debug.Assert(pPager.journalHdr <= pPager.journalOff); - /* - ** Free all structures in the Pager.aSavepoint[] array and set both - ** Pager.aSavepoint and Pager.nSavepoint to zero. Close the sub-journal - ** if it is open and the pager is not in exclusive mode. - */ - static void releaseAllSavepoints( Pager pPager ) - { - int ii; /* Iterator for looping through Pager.aSavepoint */ - for ( ii = 0; ii < pPager.nSavepoint; ii++ ) - { - sqlite3BitvecDestroy( ref pPager.aSavepoint[ii].pInSavepoint ); - } - if ( !pPager.exclusiveMode || sqlite3IsMemJournal( pPager.sjfd ) ) - { - sqlite3OsClose( pPager.sjfd ); - } - //sqlite3_free( ref pPager.aSavepoint ); - pPager.aSavepoint = null; - pPager.nSavepoint = 0; - pPager.nSubRec = 0; - } + /* Calculate the length in bytes and the checksum of zMaster */ + for (nMaster = 0; nMaster < zMaster.Length && zMaster[nMaster] != 0; nMaster++) { + cksum += zMaster[nMaster]; + } - /* - ** Set the bit number pgno in the PagerSavepoint.pInSavepoint - ** bitvecs of all open savepoints. Return SQLITE_OK if successful - ** or SQLITE_NOMEM if a malloc failure occurs. - */ - static int addToSavepointBitvecs( Pager pPager, u32 pgno ) - { - int ii; /* Loop counter */ - int rc = SQLITE_OK; /* Result code */ + /* If in full-sync mode, advance to the next disk sector before writing + ** the master journal name. This is in case the previous page written to + ** the journal has already been synced. + */ + if (pPager.fullSync) { + pPager.journalOff = journalHdrOffset(pPager); + } + iHdrOff = pPager.journalOff; + /* Write the master journal data to the end of the journal file. If + ** an error occurs, return the error code to the caller. + */ + if ((0 != (rc = write32bits(pPager.jfd, iHdrOff, (u32)PAGER_MJ_PGNO(pPager)))) + || (0 != (rc = sqlite3OsWrite(pPager.jfd, Encoding.UTF8.GetBytes(zMaster), nMaster, iHdrOff + 4))) + || (0 != (rc = write32bits(pPager.jfd, iHdrOff + 4 + nMaster, (u32)nMaster))) + || (0 != (rc = write32bits(pPager.jfd, iHdrOff + 4 + nMaster + 4, cksum))) + || (0 != (rc = sqlite3OsWrite(pPager.jfd, aJournalMagic, 8, iHdrOff + 4 + nMaster + 8))) + ) { + return rc; + } + pPager.journalOff += (nMaster + 20); + + /* If the pager is in peristent-journal mode, then the physical + ** journal-file may extend past the end of the master-journal name + ** and 8 bytes of magic data just written to the file. This is + ** dangerous because the code to rollback a hot-journal file + ** will not be able to find the master-journal name to determine + ** whether or not the journal is hot. + ** + ** Easiest thing to do in this scenario is to truncate the journal + ** file to the required size. + */ + if (SQLITE_OK == (rc = sqlite3OsFileSize(pPager.jfd, ref jrnlSize)) + && jrnlSize > pPager.journalOff + ) { + rc = sqlite3OsTruncate(pPager.jfd, pPager.journalOff); + } - for ( ii = 0; ii < pPager.nSavepoint; ii++ ) - { - PagerSavepoint p = pPager.aSavepoint[ii]; - if ( pgno <= p.nOrig ) - { - rc |= sqlite3BitvecSet( p.pInSavepoint, pgno ); - testcase( rc == SQLITE_NOMEM ); - Debug.Assert( rc == SQLITE_OK || rc == SQLITE_NOMEM ); + return rc; } - } - return rc; - } - - /* - ** This function is a no-op if the pager is in exclusive mode and not - ** in the ERROR state. Otherwise, it switches the pager to PAGER_OPEN - ** state. - ** - ** If the pager is not in exclusive-access mode, the database file is - ** completely unlocked. If the file is unlocked and the file-system does - ** not exhibit the UNDELETABLE_WHEN_OPEN property, the journal file is - ** closed (if it is open). - ** - ** If the pager is in ERROR state when this function is called, the - ** contents of the pager cache are discarded before switching back to - ** the OPEN state. Regardless of whether the pager is in exclusive-mode - ** or not, any journal file left in the file-system will be treated - ** as a hot-journal and rolled back the next time a read-transaction - ** is opened (by this or by any other connection). - */ - static void pager_unlock( Pager pPager ) - { - - Debug.Assert( pPager.eState == PAGER_READER - || pPager.eState == PAGER_OPEN - || pPager.eState == PAGER_ERROR - ); - - sqlite3BitvecDestroy( ref pPager.pInJournal ); - pPager.pInJournal = null; - releaseAllSavepoints( pPager ); - if ( pagerUseWal( pPager ) ) - { - Debug.Assert( !isOpen( pPager.jfd ) ); - sqlite3WalEndReadTransaction( pPager.pWal ); - pPager.eState = PAGER_OPEN; - } - else if ( !pPager.exclusiveMode ) - { - int rc; /* Error code returned by pagerUnlockDb() */ - int iDc = isOpen( pPager.fd ) ? sqlite3OsDeviceCharacteristics( pPager.fd ) : 0; + /* + ** Find a page in the hash table given its page number. Return + ** a pointer to the page or NULL if the requested page is not + ** already in memory. + */ + static PgHdr pager_lookup(Pager pPager, u32 pgno) { + PgHdr p = null; /* Return value */ + /* It is not possible for a call to PcacheFetch() with createFlag==0 to + ** fail, since no attempt to allocate dynamic memory will be made. + */ + sqlite3PcacheFetch(pPager.pPCache, pgno, 0, ref p); + return p; + } - /* If the operating system support deletion of open files, then - ** close the journal file when dropping the database lock. Otherwise - ** another connection with journal_mode=delete might delete the file - ** out from under us. + /* + ** Discard the entire contents of the in-memory page-cache. */ - Debug.Assert( ( PAGER_JOURNALMODE_MEMORY & 5 ) != 1 ); - Debug.Assert( ( PAGER_JOURNALMODE_OFF & 5 ) != 1 ); - Debug.Assert( ( PAGER_JOURNALMODE_WAL & 5 ) != 1 ); - Debug.Assert( ( PAGER_JOURNALMODE_DELETE & 5 ) != 1 ); - Debug.Assert( ( PAGER_JOURNALMODE_TRUNCATE & 5 ) == 1 ); - Debug.Assert( ( PAGER_JOURNALMODE_PERSIST & 5 ) == 1 ); - if ( 0 == ( iDc & SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN ) - || 1 != ( pPager.journalMode & 5 ) - ) - { - sqlite3OsClose( pPager.jfd ); + static void pager_reset(Pager pPager) { + sqlite3BackupRestart(pPager.pBackup); + sqlite3PcacheClear(pPager.pPCache); } + /* + ** Free all structures in the Pager.aSavepoint[] array and set both + ** Pager.aSavepoint and Pager.nSavepoint to zero. Close the sub-journal + ** if it is open and the pager is not in exclusive mode. + */ + static void releaseAllSavepoints(Pager pPager) { + int ii; /* Iterator for looping through Pager.aSavepoint */ + for (ii = 0; ii < pPager.nSavepoint; ii++) { + sqlite3BitvecDestroy(ref pPager.aSavepoint[ii].pInSavepoint); + } + if (!pPager.exclusiveMode || sqlite3IsMemJournal(pPager.sjfd)) { + sqlite3OsClose(pPager.sjfd); + } + //sqlite3_free( ref pPager.aSavepoint ); + pPager.aSavepoint = null; + pPager.nSavepoint = 0; + pPager.nSubRec = 0; + } - /* If the pager is in the ERROR state and the call to unlock the database - ** file fails, set the current lock to UNKNOWN_LOCK. See the comment - ** above the #define for UNKNOWN_LOCK for an explanation of why this - ** is necessary. + /* + ** Set the bit number pgno in the PagerSavepoint.pInSavepoint + ** bitvecs of all open savepoints. Return SQLITE_OK if successful + ** or SQLITE_NOMEM if a malloc failure occurs. */ - rc = pagerUnlockDb( pPager, NO_LOCK ); - if ( rc != SQLITE_OK && pPager.eState == PAGER_ERROR ) - { - pPager.eLock = UNKNOWN_LOCK; + static int addToSavepointBitvecs(Pager pPager, u32 pgno) { + int ii; /* Loop counter */ + int rc = SQLITE_OK; /* Result code */ + + for (ii = 0; ii < pPager.nSavepoint; ii++) { + PagerSavepoint p = pPager.aSavepoint[ii]; + if (pgno <= p.nOrig) { + rc |= sqlite3BitvecSet(p.pInSavepoint, pgno); + testcase(rc == SQLITE_NOMEM); + Debug.Assert(rc == SQLITE_OK || rc == SQLITE_NOMEM); + } + } + return rc; } - /* The pager state may be changed from PAGER_ERROR to PAGER_OPEN here - ** without clearing the error code. This is intentional - the error - ** code is cleared and the cache reset in the block below. + /* + ** This function is a no-op if the pager is in exclusive mode and not + ** in the ERROR state. Otherwise, it switches the pager to PAGER_OPEN + ** state. + ** + ** If the pager is not in exclusive-access mode, the database file is + ** completely unlocked. If the file is unlocked and the file-system does + ** not exhibit the UNDELETABLE_WHEN_OPEN property, the journal file is + ** closed (if it is open). + ** + ** If the pager is in ERROR state when this function is called, the + ** contents of the pager cache are discarded before switching back to + ** the OPEN state. Regardless of whether the pager is in exclusive-mode + ** or not, any journal file left in the file-system will be treated + ** as a hot-journal and rolled back the next time a read-transaction + ** is opened (by this or by any other connection). */ - Debug.Assert( pPager.errCode != 0 || pPager.eState != PAGER_ERROR ); - pPager.changeCountDone = false; - pPager.eState = PAGER_OPEN; - } + static void pager_unlock(Pager pPager) { - /* If Pager.errCode is set, the contents of the pager cache cannot be - ** trusted. Now that there are no outstanding references to the pager, - ** it can safely move back to PAGER_OPEN state. This happens in both - ** normal and exclusive-locking mode. - */ - if ( pPager.errCode != 0 ) - { - Debug.Assert( + Debug.Assert(pPager.eState == PAGER_READER + || pPager.eState == PAGER_OPEN + || pPager.eState == PAGER_ERROR + ); + + sqlite3BitvecDestroy(ref pPager.pInJournal); + pPager.pInJournal = null; + releaseAllSavepoints(pPager); + + if (pagerUseWal(pPager)) { + Debug.Assert(!isOpen(pPager.jfd)); + sqlite3WalEndReadTransaction(pPager.pWal); + pPager.eState = PAGER_OPEN; + } else if (!pPager.exclusiveMode) { + int rc; /* Error code returned by pagerUnlockDb() */ + int iDc = isOpen(pPager.fd) ? sqlite3OsDeviceCharacteristics(pPager.fd) : 0; + + /* If the operating system support deletion of open files, then + ** close the journal file when dropping the database lock. Otherwise + ** another connection with journal_mode=delete might delete the file + ** out from under us. + */ + Debug.Assert((PAGER_JOURNALMODE_MEMORY & 5) != 1); + Debug.Assert((PAGER_JOURNALMODE_OFF & 5) != 1); + Debug.Assert((PAGER_JOURNALMODE_WAL & 5) != 1); + Debug.Assert((PAGER_JOURNALMODE_DELETE & 5) != 1); + Debug.Assert((PAGER_JOURNALMODE_TRUNCATE & 5) == 1); + Debug.Assert((PAGER_JOURNALMODE_PERSIST & 5) == 1); + if (0 == (iDc & SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN) + || 1 != (pPager.journalMode & 5) + ) { + sqlite3OsClose(pPager.jfd); + } + + + /* If the pager is in the ERROR state and the call to unlock the database + ** file fails, set the current lock to UNKNOWN_LOCK. See the comment + ** above the #define for UNKNOWN_LOCK for an explanation of why this + ** is necessary. + */ + rc = pagerUnlockDb(pPager, NO_LOCK); + if (rc != SQLITE_OK && pPager.eState == PAGER_ERROR) { + pPager.eLock = UNKNOWN_LOCK; + } + + /* The pager state may be changed from PAGER_ERROR to PAGER_OPEN here + ** without clearing the error code. This is intentional - the error + ** code is cleared and the cache reset in the block below. + */ + Debug.Assert(pPager.errCode != 0 || pPager.eState != PAGER_ERROR); + pPager.changeCountDone = false; + pPager.eState = PAGER_OPEN; + } + + /* If Pager.errCode is set, the contents of the pager cache cannot be + ** trusted. Now that there are no outstanding references to the pager, + ** it can safely move back to PAGER_OPEN state. This happens in both + ** normal and exclusive-locking mode. + */ + if (pPager.errCode != 0) { + Debug.Assert( #if SQLITE_OMIT_MEMORYDB 0==MEMDB #else - 0 == pPager.memDb + 0 == pPager.memDb #endif - ); - pager_reset( pPager ); - pPager.changeCountDone = pPager.tempFile; - pPager.eState = PAGER_OPEN; - pPager.errCode = SQLITE_OK; - } + ); + pager_reset(pPager); + pPager.changeCountDone = pPager.tempFile; + pPager.eState = PAGER_OPEN; + pPager.errCode = SQLITE_OK; + } - pPager.journalOff = 0; - pPager.journalHdr = 0; - pPager.setMaster = 0; - } + pPager.journalOff = 0; + pPager.journalHdr = 0; + pPager.setMaster = 0; + } - /* - ** This function is called whenever an IOERR or FULL error that requires - ** the pager to transition into the ERROR state may ahve occurred. - ** The first argument is a pointer to the pager structure, the second - ** the error-code about to be returned by a pager API function. The - ** value returned is a copy of the second argument to this function. - ** - ** If the second argument is SQLITE_FULL, SQLITE_IOERR or one of the - ** IOERR sub-codes, the pager enters the ERROR state and the error code - ** is stored in Pager.errCode. While the pager remains in the ERROR state, - ** all major API calls on the Pager will immediately return Pager.errCode. - ** - ** The ERROR state indicates that the contents of the pager-cache - ** cannot be trusted. This state can be cleared by completely discarding - ** the contents of the pager-cache. If a transaction was active when - ** the persistent error occurred, then the rollback journal may need - ** to be replayed to restore the contents of the database file (as if - ** it were a hot-journal). - */ - static int pager_error( Pager pPager, int rc ) - { - int rc2 = rc & 0xff; - Debug.Assert( rc == SQLITE_OK || + /* + ** This function is called whenever an IOERR or FULL error that requires + ** the pager to transition into the ERROR state may ahve occurred. + ** The first argument is a pointer to the pager structure, the second + ** the error-code about to be returned by a pager API function. The + ** value returned is a copy of the second argument to this function. + ** + ** If the second argument is SQLITE_FULL, SQLITE_IOERR or one of the + ** IOERR sub-codes, the pager enters the ERROR state and the error code + ** is stored in Pager.errCode. While the pager remains in the ERROR state, + ** all major API calls on the Pager will immediately return Pager.errCode. + ** + ** The ERROR state indicates that the contents of the pager-cache + ** cannot be trusted. This state can be cleared by completely discarding + ** the contents of the pager-cache. If a transaction was active when + ** the persistent error occurred, then the rollback journal may need + ** to be replayed to restore the contents of the database file (as if + ** it were a hot-journal). + */ + static int pager_error(Pager pPager, int rc) { + int rc2 = rc & 0xff; + Debug.Assert(rc == SQLITE_OK || #if SQLITE_OMIT_MEMORYDB 0==MEMDB #else - 0 == pPager.memDb + 0 == pPager.memDb #endif - ); - Debug.Assert( - pPager.errCode == SQLITE_FULL || - pPager.errCode == SQLITE_OK || - ( pPager.errCode & 0xff ) == SQLITE_IOERR - ); - if ( - rc2 == SQLITE_FULL || rc2 == SQLITE_IOERR ) - { - pPager.errCode = rc; - pPager.eState = PAGER_ERROR; - } - return rc; - } - - /* - ** This routine ends a transaction. A transaction is usually ended by - ** either a COMMIT or a ROLLBACK operation. This routine may be called - ** after rollback of a hot-journal, or if an error occurs while opening - ** the journal file or writing the very first journal-header of a - ** database transaction. - ** - ** This routine is never called in PAGER_ERROR state. If it is called - ** in PAGER_NONE or PAGER_SHARED state and the lock held is less - ** exclusive than a RESERVED lock, it is a no-op. - ** - ** Otherwise, any active savepoints are released. - ** - ** If the journal file is open, then it is "finalized". Once a journal - ** file has been finalized it is not possible to use it to roll back a - ** transaction. Nor will it be considered to be a hot-journal by this - ** or any other database connection. Exactly how a journal is finalized - ** depends on whether or not the pager is running in exclusive mode and - ** the current journal-mode (Pager.journalMode value), as follows: - ** - ** journalMode==MEMORY - ** Journal file descriptor is simply closed. This destroys an - ** in-memory journal. - ** - ** journalMode==TRUNCATE - ** Journal file is truncated to zero bytes in size. - ** - ** journalMode==PERSIST - ** The first 28 bytes of the journal file are zeroed. This invalidates - ** the first journal header in the file, and hence the entire journal - ** file. An invalid journal file cannot be rolled back. - ** - ** journalMode==DELETE - ** The journal file is closed and deleted using sqlite3OsDelete(). - ** - ** If the pager is running in exclusive mode, this method of finalizing - ** the journal file is never used. Instead, if the journalMode is - ** DELETE and the pager is in exclusive mode, the method described under - ** journalMode==PERSIST is used instead. - ** - ** After the journal is finalized, the pager moves to PAGER_READER state. - ** If running in non-exclusive rollback mode, the lock on the file is - ** downgraded to a SHARED_LOCK. - ** - ** SQLITE_OK is returned if no error occurs. If an error occurs during - ** any of the IO operations to finalize the journal file or unlock the - ** database then the IO error code is returned to the user. If the - ** operation to finalize the journal file fails, then the code still - ** tries to unlock the database file if not in exclusive mode. If the - ** unlock operation fails as well, then the first error code related - ** to the first error encountered (the journal finalization one) is - ** returned. - */ - static int pager_end_transaction( Pager pPager, int hasMaster ) - { - int rc = SQLITE_OK; /* Error code from journal finalization operation */ - int rc2 = SQLITE_OK; /* Error code from db file unlock operation */ - /* Do nothing if the pager does not have an open write transaction - ** or at least a RESERVED lock. This function may be called when there - ** is no write-transaction active but a RESERVED or greater lock is - ** held under two circumstances: - ** - ** 1. After a successful hot-journal rollback, it is called with - ** eState==PAGER_NONE and eLock==EXCLUSIVE_LOCK. - ** - ** 2. If a connection with locking_mode=exclusive holding an EXCLUSIVE - ** lock switches back to locking_mode=normal and then executes a - ** read-transaction, this function is called with eState==PAGER_READER - ** and eLock==EXCLUSIVE_LOCK when the read-transaction is closed. - */ - Debug.Assert( assert_pager_state( pPager ) ); - Debug.Assert( pPager.eState != PAGER_ERROR ); - if ( pPager.eState < PAGER_WRITER_LOCKED && pPager.eLock < RESERVED_LOCK ) - { - return SQLITE_OK; - } + ); + Debug.Assert( + pPager.errCode == SQLITE_FULL || + pPager.errCode == SQLITE_OK || + (pPager.errCode & 0xff) == SQLITE_IOERR + ); + if ( + rc2 == SQLITE_FULL || rc2 == SQLITE_IOERR) { + pPager.errCode = rc; + pPager.eState = PAGER_ERROR; + } + return rc; + } - releaseAllSavepoints( pPager ); - Debug.Assert( isOpen( pPager.jfd ) || pPager.pInJournal == null ); - if ( isOpen( pPager.jfd ) ) - { - Debug.Assert( !pagerUseWal( pPager ) ); + /* + ** This routine ends a transaction. A transaction is usually ended by + ** either a COMMIT or a ROLLBACK operation. This routine may be called + ** after rollback of a hot-journal, or if an error occurs while opening + ** the journal file or writing the very first journal-header of a + ** database transaction. + ** + ** This routine is never called in PAGER_ERROR state. If it is called + ** in PAGER_NONE or PAGER_SHARED state and the lock held is less + ** exclusive than a RESERVED lock, it is a no-op. + ** + ** Otherwise, any active savepoints are released. + ** + ** If the journal file is open, then it is "finalized". Once a journal + ** file has been finalized it is not possible to use it to roll back a + ** transaction. Nor will it be considered to be a hot-journal by this + ** or any other database connection. Exactly how a journal is finalized + ** depends on whether or not the pager is running in exclusive mode and + ** the current journal-mode (Pager.journalMode value), as follows: + ** + ** journalMode==MEMORY + ** Journal file descriptor is simply closed. This destroys an + ** in-memory journal. + ** + ** journalMode==TRUNCATE + ** Journal file is truncated to zero bytes in size. + ** + ** journalMode==PERSIST + ** The first 28 bytes of the journal file are zeroed. This invalidates + ** the first journal header in the file, and hence the entire journal + ** file. An invalid journal file cannot be rolled back. + ** + ** journalMode==DELETE + ** The journal file is closed and deleted using sqlite3OsDelete(). + ** + ** If the pager is running in exclusive mode, this method of finalizing + ** the journal file is never used. Instead, if the journalMode is + ** DELETE and the pager is in exclusive mode, the method described under + ** journalMode==PERSIST is used instead. + ** + ** After the journal is finalized, the pager moves to PAGER_READER state. + ** If running in non-exclusive rollback mode, the lock on the file is + ** downgraded to a SHARED_LOCK. + ** + ** SQLITE_OK is returned if no error occurs. If an error occurs during + ** any of the IO operations to finalize the journal file or unlock the + ** database then the IO error code is returned to the user. If the + ** operation to finalize the journal file fails, then the code still + ** tries to unlock the database file if not in exclusive mode. If the + ** unlock operation fails as well, then the first error code related + ** to the first error encountered (the journal finalization one) is + ** returned. + */ + static int pager_end_transaction(Pager pPager, int hasMaster) { + int rc = SQLITE_OK; /* Error code from journal finalization operation */ + int rc2 = SQLITE_OK; /* Error code from db file unlock operation */ + /* Do nothing if the pager does not have an open write transaction + ** or at least a RESERVED lock. This function may be called when there + ** is no write-transaction active but a RESERVED or greater lock is + ** held under two circumstances: + ** + ** 1. After a successful hot-journal rollback, it is called with + ** eState==PAGER_NONE and eLock==EXCLUSIVE_LOCK. + ** + ** 2. If a connection with locking_mode=exclusive holding an EXCLUSIVE + ** lock switches back to locking_mode=normal and then executes a + ** read-transaction, this function is called with eState==PAGER_READER + ** and eLock==EXCLUSIVE_LOCK when the read-transaction is closed. + */ + Debug.Assert(assert_pager_state(pPager)); + Debug.Assert(pPager.eState != PAGER_ERROR); + if (pPager.eState < PAGER_WRITER_LOCKED && pPager.eLock < RESERVED_LOCK) { + return SQLITE_OK; + } - /* Finalize the journal file. */ - if ( sqlite3IsMemJournal( pPager.jfd ) ) - { - Debug.Assert( pPager.journalMode == PAGER_JOURNALMODE_MEMORY ); - sqlite3OsClose( pPager.jfd ); - } - else if ( pPager.journalMode == PAGER_JOURNALMODE_TRUNCATE ) - { - if ( pPager.journalOff == 0 ) - { - rc = SQLITE_OK; - } - else - { - rc = sqlite3OsTruncate( pPager.jfd, 0 ); - } - pPager.journalOff = 0; - } - else if ( pPager.journalMode == PAGER_JOURNALMODE_PERSIST - || ( pPager.exclusiveMode && pPager.journalMode != PAGER_JOURNALMODE_WAL ) - ) - { - rc = zeroJournalHdr( pPager, hasMaster ); - pPager.journalOff = 0; - } - else - { - /* This branch may be executed with Pager.journalMode==MEMORY if - ** a hot-journal was just rolled back. In this case the journal - ** file should be closed and deleted. If this connection writes to - ** the database file, it will do so using an in-memory journal. - */ - Debug.Assert( pPager.journalMode == PAGER_JOURNALMODE_DELETE - || pPager.journalMode == PAGER_JOURNALMODE_MEMORY - || pPager.journalMode == PAGER_JOURNALMODE_WAL - ); - sqlite3OsClose( pPager.jfd ); - if ( !pPager.tempFile ) - { - rc = sqlite3OsDelete( pPager.pVfs, pPager.zJournal, 0 ); - } - } - } + releaseAllSavepoints(pPager); + Debug.Assert(isOpen(pPager.jfd) || pPager.pInJournal == null); + if (isOpen(pPager.jfd)) { + Debug.Assert(!pagerUseWal(pPager)); + + /* Finalize the journal file. */ + if (sqlite3IsMemJournal(pPager.jfd)) { + Debug.Assert(pPager.journalMode == PAGER_JOURNALMODE_MEMORY); + sqlite3OsClose(pPager.jfd); + } else if (pPager.journalMode == PAGER_JOURNALMODE_TRUNCATE) { + if (pPager.journalOff == 0) { + rc = SQLITE_OK; + } else { + rc = sqlite3OsTruncate(pPager.jfd, 0); + } + pPager.journalOff = 0; + } else if (pPager.journalMode == PAGER_JOURNALMODE_PERSIST + || (pPager.exclusiveMode && pPager.journalMode != PAGER_JOURNALMODE_WAL) + ) { + rc = zeroJournalHdr(pPager, hasMaster); + pPager.journalOff = 0; + } else { + /* This branch may be executed with Pager.journalMode==MEMORY if + ** a hot-journal was just rolled back. In this case the journal + ** file should be closed and deleted. If this connection writes to + ** the database file, it will do so using an in-memory journal. + */ + Debug.Assert(pPager.journalMode == PAGER_JOURNALMODE_DELETE + || pPager.journalMode == PAGER_JOURNALMODE_MEMORY + || pPager.journalMode == PAGER_JOURNALMODE_WAL + ); + sqlite3OsClose(pPager.jfd); + if (!pPager.tempFile) { + rc = sqlite3OsDelete(pPager.pVfs, pPager.zJournal, 0); + } + } + } #if SQLITE_CHECK_PAGES sqlite3PcacheIterateDirty(pPager.pPCache, pager_set_pagehash); if( pPager.dbSize==0 && sqlite3PcacheRefCount(pPager.pPCache)>0 ){ @@ -2261,1008 +2149,933 @@ static int pager_end_transaction( Pager pPager, int hasMaster ) } } #endif - sqlite3BitvecDestroy( ref pPager.pInJournal ); - pPager.pInJournal = null; - pPager.nRec = 0; - sqlite3PcacheCleanAll( pPager.pPCache ); - sqlite3PcacheTruncate( pPager.pPCache, pPager.dbSize ); - - if ( pagerUseWal( pPager ) ) - { - /* Drop the WAL write-lock, if any. Also, if the connection was in - ** locking_mode=exclusive mode but is no longer, drop the EXCLUSIVE - ** lock held on the database file. - */ - rc2 = sqlite3WalEndWriteTransaction( pPager.pWal ); - Debug.Assert( rc2 == SQLITE_OK ); - } - if ( !pPager.exclusiveMode - && ( !pagerUseWal( pPager ) || sqlite3WalExclusiveMode( pPager.pWal, 0 ) ) - ) - { - rc2 = pagerUnlockDb( pPager, SHARED_LOCK ); - pPager.changeCountDone = false; - } - pPager.eState = PAGER_READER; - pPager.setMaster = 0; - - return ( rc == SQLITE_OK ? rc2 : rc ); - } - - /* - ** Execute a rollback if a transaction is active and unlock the - ** database file. - ** - ** If the pager has already entered the ERROR state, do not attempt - ** the rollback at this time. Instead, pager_unlock() is called. The - ** call to pager_unlock() will discard all in-memory pages, unlock - ** the database file and move the pager back to OPEN state. If this - ** means that there is a hot-journal left in the file-system, the next - ** connection to obtain a shared lock on the pager (which may be this one) - ** will roll it back. - ** - ** If the pager has not already entered the ERROR state, but an IO or - ** malloc error occurs during a rollback, then this will itself cause - ** the pager to enter the ERROR state. Which will be cleared by the - ** call to pager_unlock(), as described above. - */ - static void pagerUnlockAndRollback( Pager pPager ) - { - if ( pPager.eState != PAGER_ERROR && pPager.eState != PAGER_OPEN ) - { - Debug.Assert( assert_pager_state( pPager ) ); - if ( pPager.eState >= PAGER_WRITER_LOCKED ) - { - sqlite3BeginBenignMalloc(); - sqlite3PagerRollback( pPager ); - sqlite3EndBenignMalloc(); - } - else if ( !pPager.exclusiveMode ) - { - Debug.Assert( pPager.eState == PAGER_READER ); - pager_end_transaction( pPager, 0 ); - } - } - pager_unlock( pPager ); - } - - /* - ** Parameter aData must point to a buffer of pPager.pageSize bytes - ** of data. Compute and return a checksum based ont the contents of the - ** page of data and the current value of pPager.cksumInit. - ** - ** This is not a real checksum. It is really just the sum of the - ** random initial value (pPager.cksumInit) and every 200th byte - ** of the page data, starting with byte offset (pPager.pageSize%200). - ** Each byte is interpreted as an 8-bit unsigned integer. - ** - ** Changing the formula used to compute this checksum results in an - ** incompatible journal file format. - ** - ** If journal corruption occurs due to a power failure, the most likely - ** scenario is that one end or the other of the record will be changed. - ** It is much less likely that the two ends of the journal record will be - ** correct and the middle be corrupt. Thus, this "checksum" scheme, - ** though fast and simple, catches the mostly likely kind of corruption. - */ - static u32 pager_cksum( Pager pPager, byte[] aData ) - { - u32 cksum = pPager.cksumInit; /* Checksum value to return */ - int i = pPager.pageSize - 200; /* Loop counter */ - while ( i > 0 ) - { - cksum += aData[i]; - i -= 200; - } - return cksum; - } - - /* - ** Report the current page size and number of reserved bytes back - ** to the codec. - */ -#if SQLITE_HAS_CODEC - static void pagerReportSize( Pager pPager ) - { - if ( pPager.xCodecSizeChng != null ) - { - pPager.xCodecSizeChng( pPager.pCodec, pPager.pageSize, - pPager.nReserve ); - } - } -#else -//# define pagerReportSize(X) /* No-op if we do not support a codec */ -static void pagerReportSize(Pager X){} -#endif + sqlite3BitvecDestroy(ref pPager.pInJournal); + pPager.pInJournal = null; + pPager.nRec = 0; + sqlite3PcacheCleanAll(pPager.pPCache); + sqlite3PcacheTruncate(pPager.pPCache, pPager.dbSize); - /* -** Read a single page from either the journal file (if isMainJrnl==1) or -** from the sub-journal (if isMainJrnl==0) and playback that page. -** The page begins at offset *pOffset into the file. The *pOffset -** value is increased to the start of the next page in the journal. -** -** The main rollback journal uses checksums - the statement journal does -** not. -** -** If the page number of the page record read from the (sub-)journal file -** is greater than the current value of Pager.dbSize, then playback is -** skipped and SQLITE_OK is returned. -** -** If pDone is not NULL, then it is a record of pages that have already -** been played back. If the page at *pOffset has already been played back -** (if the corresponding pDone bit is set) then skip the playback. -** Make sure the pDone bit corresponding to the *pOffset page is set -** prior to returning. -** -** If the page record is successfully read from the (sub-)journal file -** and played back, then SQLITE_OK is returned. If an IO error occurs -** while reading the record from the (sub-)journal file or while writing -** to the database file, then the IO error code is returned. If data -** is successfully read from the (sub-)journal file but appears to be -** corrupted, SQLITE_DONE is returned. Data is considered corrupted in -** two circumstances: -** -** * If the record page-number is illegal (0 or PAGER_MJ_PGNO), or -** * If the record is being rolled back from the main journal file -** and the checksum field does not match the record content. -** -** Neither of these two scenarios are possible during a savepoint rollback. -** -** If this is a savepoint rollback, then memory may have to be dynamically -** allocated by this function. If this is the case and an allocation fails, -** SQLITE_NOMEM is returned. -*/ - static int pager_playback_one_page( - Pager pPager, /* The pager being played back */ - ref i64 pOffset, /* Offset of record to playback */ - Bitvec pDone, /* Bitvec of pages already played back */ - int isMainJrnl, /* True for main rollback journal. False for Stmt jrnl */ - int isSavepnt /* True for a savepoint rollback */ - ) - { - int rc; - PgHdr pPg; /* An existing page in the cache */ - Pgno pgno = 0; /* The page number of a page in journal */ - u32 cksum = 0; /* Checksum used for sanity checking */ - byte[] aData; /* Temporary storage for the page */ - sqlite3_file jfd; /* The file descriptor for the journal file */ - bool isSynced; /* True if journal page is synced */ - - Debug.Assert( ( isMainJrnl & ~1 ) == 0 ); /* isMainJrnl is 0 or 1 */ - Debug.Assert( ( isSavepnt & ~1 ) == 0 ); /* isSavepnt is 0 or 1 */ - Debug.Assert( isMainJrnl != 0 || pDone != null ); /* pDone always used on sub-journals */ - Debug.Assert( isSavepnt != 0 || pDone == null ); /* pDone never used on non-savepoint */ - - aData = pPager.pTmpSpace; - Debug.Assert( aData != null ); /* Temp storage must have already been allocated */ - Debug.Assert( pagerUseWal( pPager ) == false || ( 0 == isMainJrnl && isSavepnt != 0 ) ); - - /* Either the state is greater than PAGER_WRITER_CACHEMOD (a transaction - ** or savepoint rollback done at the request of the caller) or this is - ** a hot-journal rollback. If it is a hot-journal rollback, the pager - ** is in state OPEN and holds an EXCLUSIVE lock. Hot-journal rollback - ** only reads from the main journal, not the sub-journal. - */ - Debug.Assert( pPager.eState >= PAGER_WRITER_CACHEMOD - || ( pPager.eState == PAGER_OPEN && pPager.eLock == EXCLUSIVE_LOCK ) - ); - Debug.Assert( pPager.eState >= PAGER_WRITER_CACHEMOD || isMainJrnl != 0 ); + if (pagerUseWal(pPager)) { + /* Drop the WAL write-lock, if any. Also, if the connection was in + ** locking_mode=exclusive mode but is no longer, drop the EXCLUSIVE + ** lock held on the database file. + */ + rc2 = sqlite3WalEndWriteTransaction(pPager.pWal); + Debug.Assert(rc2 == SQLITE_OK); + } + if (!pPager.exclusiveMode + && (!pagerUseWal(pPager) || sqlite3WalExclusiveMode(pPager.pWal, 0)) + ) { + rc2 = pagerUnlockDb(pPager, SHARED_LOCK); + pPager.changeCountDone = false; + } + pPager.eState = PAGER_READER; + pPager.setMaster = 0; - /* Read the page number and page data from the journal or sub-journal - ** file. Return an error code to the caller if an IO error occurs. - */ - jfd = isMainJrnl != 0 ? pPager.jfd : pPager.sjfd; - - rc = read32bits( jfd, pOffset, ref pgno ); - if ( rc != SQLITE_OK ) - return rc; - rc = sqlite3OsRead( jfd, aData, pPager.pageSize, ( pOffset ) + 4 ); - if ( rc != SQLITE_OK ) - return rc; - pOffset += pPager.pageSize + 4 + isMainJrnl * 4; - - /* Sanity checking on the page. This is more important that I originally - ** thought. If a power failure occurs while the journal is being written, - ** it could cause invalid data to be written into the journal. We need to - ** detect this invalid data (with high probability) and ignore it. - */ - if ( pgno == 0 || pgno == PAGER_MJ_PGNO( pPager ) ) - { - Debug.Assert( 0 == isSavepnt ); - return SQLITE_DONE; - } - if ( pgno > pPager.dbSize || sqlite3BitvecTest( pDone, pgno ) != 0 ) - { - return SQLITE_OK; - } - if ( isMainJrnl != 0 ) - { - rc = read32bits( jfd, ( pOffset ) - 4, ref cksum ); - if ( rc != 0 ) - return rc; - if ( 0 == isSavepnt && pager_cksum( pPager, aData ) != cksum ) - { - return SQLITE_DONE; + return (rc == SQLITE_OK ? rc2 : rc); } - } - - /* If this page has already been played by before during the current - ** rollback, then don't bother to play it back again. - */ - if ( pDone != null && ( rc = sqlite3BitvecSet( pDone, pgno ) ) != SQLITE_OK ) - { - return rc; - } - - /* When playing back page 1, restore the nReserve setting - */ - if ( pgno == 1 && pPager.nReserve != ( aData )[20] ) - { - pPager.nReserve = ( aData )[20]; - pagerReportSize( pPager ); - } - /* If the pager is in CACHEMOD state, then there must be a copy of this - ** page in the pager cache. In this case just update the pager cache, - ** not the database file. The page is left marked dirty in this case. - ** - ** An exception to the above rule: If the database is in no-sync mode - ** and a page is moved during an incremental vacuum then the page may - ** not be in the pager cache. Later: if a malloc() or IO error occurs - ** during a Movepage() call, then the page may not be in the cache - ** either. So the condition described in the above paragraph is not - ** assert()able. - ** - ** If in WRITER_DBMOD, WRITER_FINISHED or OPEN state, then we update the - ** pager cache if it exists and the main file. The page is then marked - ** not dirty. Since this code is only executed in PAGER_OPEN state for - ** a hot-journal rollback, it is guaranteed that the page-cache is empty - ** if the pager is in OPEN state. - ** - ** Ticket #1171: The statement journal might contain page content that is - ** different from the page content at the start of the transaction. - ** This occurs when a page is changed prior to the start of a statement - ** then changed again within the statement. When rolling back such a - ** statement we must not write to the original database unless we know - ** for certain that original page contents are synced into the main rollback - ** journal. Otherwise, a power loss might leave modified data in the - ** database file without an entry in the rollback journal that can - ** restore the database to its original form. Two conditions must be - ** met before writing to the database files. (1) the database must be - ** locked. (2) we know that the original page content is fully synced - ** in the main journal either because the page is not in cache or else - ** the page is marked as needSync==0. - ** - ** 2008-04-14: When attempting to vacuum a corrupt database file, it - ** is possible to fail a statement on a database that does not yet exist. - ** Do not attempt to write if database file has never been opened. - */ - if ( pagerUseWal( pPager ) ) - { - pPg = null; - } - else - { - pPg = pager_lookup( pPager, pgno ); - } - Debug.Assert( pPg != null || -#if SQLITE_OMIT_MEMORYDB -0==MEMDB -#else - pPager.memDb == 0 -#endif - ); - Debug.Assert( pPager.eState != PAGER_OPEN || pPg == null ); - - PAGERTRACE( "PLAYBACK %d page %d hash(%08x) %s\n", - PAGERID( pPager ), pgno, pager_datahash( pPager.pageSize, aData ), - ( isMainJrnl != 0 ? "main-journal" : "sub-journal" ) - ); - if ( isMainJrnl != 0 ) - { - isSynced = pPager.noSync || ( pOffset <= pPager.journalHdr ); - } - else - { - isSynced = ( pPg == null || 0 == ( pPg.flags & PGHDR_NEED_SYNC ) ); - } - if ( isOpen( pPager.fd ) - && ( pPager.eState >= PAGER_WRITER_DBMOD || pPager.eState == PAGER_OPEN ) - && isSynced - ) - { - i64 ofst = ( pgno - 1 ) * pPager.pageSize; - testcase( 0 == isSavepnt && pPg != null && ( pPg.flags & PGHDR_NEED_SYNC ) != 0 ); - Debug.Assert( !pagerUseWal( pPager ) ); - rc = sqlite3OsWrite( pPager.fd, aData, pPager.pageSize, ofst ); - if ( pgno > pPager.dbFileSize ) - { - pPager.dbFileSize = pgno; - } - if ( pPager.pBackup != null ) - { - if ( CODEC1( pPager, aData, pgno, SQLITE_DECRYPT ) ) - rc = SQLITE_NOMEM; // CODEC1( pPager, aData, pgno, 3, rc = SQLITE_NOMEM ); - sqlite3BackupUpdate( pPager.pBackup, pgno, (u8[])aData ); - if ( CODEC2( pPager, aData, pgno, SQLITE_ENCRYPT_READ_CTX, ref aData ) ) - rc = SQLITE_NOMEM;//CODEC2( pPager, aData, pgno, 7, rc = SQLITE_NOMEM, aData); - } - } - else if ( 0 == isMainJrnl && pPg == null ) - { - /* If this is a rollback of a savepoint and data was not written to - ** the database and the page is not in-memory, there is a potential - ** problem. When the page is next fetched by the b-tree layer, it - ** will be read from the database file, which may or may not be - ** current. - ** - ** There are a couple of different ways this can happen. All are quite - ** obscure. When running in synchronous mode, this can only happen - ** if the page is on the free-list at the start of the transaction, then - ** populated, then moved using sqlite3PagerMovepage(). - ** - ** The solution is to add an in-memory page to the cache containing - ** the data just read from the sub-journal. Mark the page as dirty - ** and if the pager requires a journal-sync, then mark the page as - ** requiring a journal-sync before it is written. - */ - Debug.Assert( isSavepnt != 0 ); - Debug.Assert( pPager.doNotSpill == 0 ); - pPager.doNotSpill++; - rc = sqlite3PagerAcquire( pPager, pgno, ref pPg, 1 ); - Debug.Assert( pPager.doNotSpill == 1 ); - pPager.doNotSpill--; - if ( rc != SQLITE_OK ) - return rc; - pPg.flags &= ~PGHDR_NEED_READ; - sqlite3PcacheMakeDirty( pPg ); - } - if ( pPg != null ) - { - /* No page should ever be explicitly rolled back that is in use, except - ** for page 1 which is held in use in order to keep the lock on the - ** database active. However such a page may be rolled back as a result - ** of an internal error resulting in an automatic call to - ** sqlite3PagerRollback(). + /* + ** Execute a rollback if a transaction is active and unlock the + ** database file. + ** + ** If the pager has already entered the ERROR state, do not attempt + ** the rollback at this time. Instead, pager_unlock() is called. The + ** call to pager_unlock() will discard all in-memory pages, unlock + ** the database file and move the pager back to OPEN state. If this + ** means that there is a hot-journal left in the file-system, the next + ** connection to obtain a shared lock on the pager (which may be this one) + ** will roll it back. + ** + ** If the pager has not already entered the ERROR state, but an IO or + ** malloc error occurs during a rollback, then this will itself cause + ** the pager to enter the ERROR state. Which will be cleared by the + ** call to pager_unlock(), as described above. */ - byte[] pData = pPg.pData; - Buffer.BlockCopy( aData, 0, pData, 0, pPager.pageSize );// memcpy(pData, (u8[])aData, pPager.pageSize); - pPager.xReiniter( pPg ); - if ( isMainJrnl != 0 && ( 0 == isSavepnt || pOffset <= pPager.journalHdr ) ) - { - /* If the contents of this page were just restored from the main - ** journal file, then its content must be as they were when the - ** transaction was first opened. In this case we can mark the page - ** as clean, since there will be no need to write it out to the - ** database. - ** - ** There is one exception to this rule. If the page is being rolled - ** back as part of a savepoint (or statement) rollback from an - ** unsynced portion of the main journal file, then it is not safe - ** to mark the page as clean. This is because marking the page as - ** clean will clear the PGHDR_NEED_SYNC flag. Since the page is - ** already in the journal file (recorded in Pager.pInJournal) and - ** the PGHDR_NEED_SYNC flag is cleared, if the page is written to - ** again within this transaction, it will be marked as dirty but - ** the PGHDR_NEED_SYNC flag will not be set. It could then potentially - ** be written out into the database file before its journal file - ** segment is synced. If a crash occurs during or following this, - ** database corruption may ensue. - */ - Debug.Assert( !pagerUseWal( pPager ) ); - sqlite3PcacheMakeClean( pPg ); + static void pagerUnlockAndRollback(Pager pPager) { + if (pPager.eState != PAGER_ERROR && pPager.eState != PAGER_OPEN) { + Debug.Assert(assert_pager_state(pPager)); + if (pPager.eState >= PAGER_WRITER_LOCKED) { + sqlite3BeginBenignMalloc(); + sqlite3PagerRollback(pPager); + sqlite3EndBenignMalloc(); + } else if (!pPager.exclusiveMode) { + Debug.Assert(pPager.eState == PAGER_READER); + pager_end_transaction(pPager, 0); + } + } + pager_unlock(pPager); } - pager_set_pagehash( pPg ); - /* If this was page 1, then restore the value of Pager.dbFileVers. - ** Do this before any decoding. */ - if ( pgno == 1 ) - { - Buffer.BlockCopy( pData, 24, pPager.dbFileVers, 0, pPager.dbFileVers.Length ); //memcpy(pPager.dbFileVers, ((u8*)pData)[24], sizeof(pPager.dbFileVers)); + + /* + ** Parameter aData must point to a buffer of pPager.pageSize bytes + ** of data. Compute and return a checksum based ont the contents of the + ** page of data and the current value of pPager.cksumInit. + ** + ** This is not a real checksum. It is really just the sum of the + ** random initial value (pPager.cksumInit) and every 200th byte + ** of the page data, starting with byte offset (pPager.pageSize%200). + ** Each byte is interpreted as an 8-bit unsigned integer. + ** + ** Changing the formula used to compute this checksum results in an + ** incompatible journal file format. + ** + ** If journal corruption occurs due to a power failure, the most likely + ** scenario is that one end or the other of the record will be changed. + ** It is much less likely that the two ends of the journal record will be + ** correct and the middle be corrupt. Thus, this "checksum" scheme, + ** though fast and simple, catches the mostly likely kind of corruption. + */ + static u32 pager_cksum(Pager pPager, byte[] aData) { + u32 cksum = pPager.cksumInit; /* Checksum value to return */ + int i = pPager.pageSize - 200; /* Loop counter */ + while (i > 0) { + cksum += aData[i]; + i -= 200; + } + return cksum; } - /* Decode the page just read from disk */ - if ( CODEC1( pPager, pData, pPg.pgno, SQLITE_DECRYPT ) ) - rc = SQLITE_NOMEM; //CODEC1(pPager, pData, pPg.pgno, 3, rc=SQLITE_NOMEM); - sqlite3PcacheRelease( pPg ); + /* + ** Report the current page size and number of reserved bytes back + ** to the codec. + */ +#if SQLITE_HAS_CODEC + static void pagerReportSize( Pager pPager ) + { + if ( pPager.xCodecSizeChng != null ) + { + pPager.xCodecSizeChng( pPager.pCodec, pPager.pageSize, + pPager.nReserve ); } - return rc; } +#else + //# define pagerReportSize(X) /* No-op if we do not support a codec */ + static void pagerReportSize(Pager X) { } +#endif - /* - ** Parameter zMaster is the name of a master journal file. A single journal - ** file that referred to the master journal file has just been rolled back. - ** This routine checks if it is possible to delete the master journal file, - ** and does so if it is. - ** - ** Argument zMaster may point to Pager.pTmpSpace. So that buffer is not - ** available for use within this function. - ** - ** When a master journal file is created, it is populated with the names - ** of all of its child journals, one after another, formatted as utf-8 - ** encoded text. The end of each child journal file is marked with a - ** nul-terminator byte (0x00). i.e. the entire contents of a master journal - ** file for a transaction involving two databases might be: - ** - ** "/home/bill/a.db-journal\x00/home/bill/b.db-journal\x00" - ** - ** A master journal file may only be deleted once all of its child - ** journals have been rolled back. - ** - ** This function reads the contents of the master-journal file into - ** memory and loops through each of the child journal names. For - ** each child journal, it checks if: - ** - ** * if the child journal exists, and if so - ** * if the child journal contains a reference to master journal - ** file zMaster - ** - ** If a child journal can be found that matches both of the criteria - ** above, this function returns without doing anything. Otherwise, if - ** no such child journal can be found, file zMaster is deleted from - ** the file-system using sqlite3OsDelete(). + /* + ** Read a single page from either the journal file (if isMainJrnl==1) or + ** from the sub-journal (if isMainJrnl==0) and playback that page. + ** The page begins at offset *pOffset into the file. The *pOffset + ** value is increased to the start of the next page in the journal. + ** + ** The main rollback journal uses checksums - the statement journal does + ** not. + ** + ** If the page number of the page record read from the (sub-)journal file + ** is greater than the current value of Pager.dbSize, then playback is + ** skipped and SQLITE_OK is returned. + ** + ** If pDone is not NULL, then it is a record of pages that have already + ** been played back. If the page at *pOffset has already been played back + ** (if the corresponding pDone bit is set) then skip the playback. + ** Make sure the pDone bit corresponding to the *pOffset page is set + ** prior to returning. + ** + ** If the page record is successfully read from the (sub-)journal file + ** and played back, then SQLITE_OK is returned. If an IO error occurs + ** while reading the record from the (sub-)journal file or while writing + ** to the database file, then the IO error code is returned. If data + ** is successfully read from the (sub-)journal file but appears to be + ** corrupted, SQLITE_DONE is returned. Data is considered corrupted in + ** two circumstances: + ** + ** * If the record page-number is illegal (0 or PAGER_MJ_PGNO), or + ** * If the record is being rolled back from the main journal file + ** and the checksum field does not match the record content. ** - ** If an IO error within this function, an error code is returned. This - ** function allocates memory by calling sqlite3Malloc(). If an allocation - ** fails, SQLITE_NOMEM is returned. Otherwise, if no IO or malloc errors - ** occur, SQLITE_OK is returned. + ** Neither of these two scenarios are possible during a savepoint rollback. ** - ** TODO: This function allocates a single block of memory to load - ** the entire contents of the master journal file. This could be - ** a couple of kilobytes or so - potentially larger than the page - ** size. + ** If this is a savepoint rollback, then memory may have to be dynamically + ** allocated by this function. If this is the case and an allocation fails, + ** SQLITE_NOMEM is returned. */ - static int pager_delmaster( Pager pPager, string zMaster ) - { - sqlite3_vfs pVfs = pPager.pVfs; - int rc; /* Return code */ - sqlite3_file pMaster; /* Malloc'd master-journal file descriptor */ - sqlite3_file pJournal; /* Malloc'd child-journal file descriptor */ - //string zMasterJournal = null; /* Contents of master journal file */ - i64 nMasterJournal; /* Size of master journal file */ - string zJournal; /* Pointer to one journal within MJ file */ - string zMasterPtr; /* Space to hold MJ filename from a journal file */ - int nMasterPtr; /* Amount of space allocated to zMasterPtr[] */ - - /* Allocate space for both the pJournal and pMaster file descriptors. - ** If successful, open the master journal file for reading. - */ - pMaster = new sqlite3_file();// (sqlite3_file*)sqlite3MallocZero( pVfs.szOsFile * 2 ); - pJournal = new sqlite3_file();// (sqlite3_file*)( ( (u8*)pMaster ) + pVfs.szOsFile ); - //if ( null == pMaster ) - //{ - // rc = SQLITE_NOMEM; - //} - //else - { - const int flags = ( SQLITE_OPEN_READONLY | SQLITE_OPEN_MASTER_JOURNAL ); - int iDummy = 0; - rc = sqlite3OsOpen( pVfs, zMaster, pMaster, flags, ref iDummy ); - } - if ( rc != SQLITE_OK ) - goto delmaster_out; + static int pager_playback_one_page( + Pager pPager, /* The pager being played back */ + ref i64 pOffset, /* Offset of record to playback */ + Bitvec pDone, /* Bitvec of pages already played back */ + int isMainJrnl, /* True for main rollback journal. False for Stmt jrnl */ + int isSavepnt /* True for a savepoint rollback */ + ) { + int rc; + PgHdr pPg; /* An existing page in the cache */ + Pgno pgno = 0; /* The page number of a page in journal */ + u32 cksum = 0; /* Checksum used for sanity checking */ + byte[] aData; /* Temporary storage for the page */ + sqlite3_file jfd; /* The file descriptor for the journal file */ + bool isSynced; /* True if journal page is synced */ + + Debug.Assert((isMainJrnl & ~1) == 0); /* isMainJrnl is 0 or 1 */ + Debug.Assert((isSavepnt & ~1) == 0); /* isSavepnt is 0 or 1 */ + Debug.Assert(isMainJrnl != 0 || pDone != null); /* pDone always used on sub-journals */ + Debug.Assert(isSavepnt != 0 || pDone == null); /* pDone never used on non-savepoint */ + + aData = pPager.pTmpSpace; + Debug.Assert(aData != null); /* Temp storage must have already been allocated */ + Debug.Assert(pagerUseWal(pPager) == false || (0 == isMainJrnl && isSavepnt != 0)); + + /* Either the state is greater than PAGER_WRITER_CACHEMOD (a transaction + ** or savepoint rollback done at the request of the caller) or this is + ** a hot-journal rollback. If it is a hot-journal rollback, the pager + ** is in state OPEN and holds an EXCLUSIVE lock. Hot-journal rollback + ** only reads from the main journal, not the sub-journal. + */ + Debug.Assert(pPager.eState >= PAGER_WRITER_CACHEMOD + || (pPager.eState == PAGER_OPEN && pPager.eLock == EXCLUSIVE_LOCK) + ); + Debug.Assert(pPager.eState >= PAGER_WRITER_CACHEMOD || isMainJrnl != 0); - Debugger.Break(); //TODO -- + /* Read the page number and page data from the journal or sub-journal + ** file. Return an error code to the caller if an IO error occurs. + */ + jfd = isMainJrnl != 0 ? pPager.jfd : pPager.sjfd; - /* Load the entire master journal file into space obtained from - ** sqlite3_malloc() and pointed to by zMasterJournal. Also obtain - ** sufficient space (in zMasterPtr) to hold the names of master - ** journal files extracted from regular rollback-journals. - */ - //rc = sqlite3OsFileSize(pMaster, &nMasterJournal); - //if (rc != SQLITE_OK) goto delmaster_out; - //nMasterPtr = pVfs.mxPathname + 1; - // zMasterJournal = sqlite3Malloc((int)nMasterJournal + nMasterPtr + 1); - // if ( !zMasterJournal ) - // { - // rc = SQLITE_NOMEM; - // goto delmaster_out; - // } - // zMasterPtr = &zMasterJournal[nMasterJournal+1]; - // rc = sqlite3OsRead( pMaster, zMasterJournal, (int)nMasterJournal, 0 ); - // if ( rc != SQLITE_OK ) goto delmaster_out; - // zMasterJournal[nMasterJournal] = 0; - - - // zJournal = zMasterJournal; - // while ( ( zJournal - zMasterJournal ) < nMasterJournal ) - // { - // int exists; - // rc = sqlite3OsAccess( pVfs, zJournal, SQLITE_ACCESS_EXISTS, &exists ); - // if ( rc != SQLITE_OK ) - // { - // goto delmaster_out; - // } - // if ( exists ) - // { - // /* One of the journals pointed to by the master journal exists. - // ** Open it and check if it points at the master journal. If - // ** so, return without deleting the master journal file. - // */ - // int c; - // int flags = ( SQLITE_OPEN_READONLY | SQLITE_OPEN_MAIN_JOURNAL ); - // rc = sqlite3OsOpen( pVfs, zJournal, pJournal, flags, 0 ); - // if ( rc != SQLITE_OK ) - // { - // goto delmaster_out; - // } - - // rc = readMasterJournal( pJournal, zMasterPtr, nMasterPtr ); - // sqlite3OsClose( pJournal ); - // if ( rc != SQLITE_OK ) - // { - // goto delmaster_out; - // } - - // c = zMasterPtr[0] != 0 && strcmp( zMasterPtr, zMaster ) == 0; - // if ( c ) - // { - // /* We have a match. Do not delete the master journal file. */ - // goto delmaster_out; - // } - // } - // zJournal += ( sqlite3Strlen30( zJournal ) + 1 ); - // } - // - //sqlite3OsClose(pMaster); - //rc = sqlite3OsDelete( pVfs, zMaster, 0 ); - - - goto delmaster_out; -delmaster_out: - //sqlite3_free( ref zMasterJournal ); - if ( pMaster != null ) - { - sqlite3OsClose( pMaster ); - Debug.Assert( !isOpen( pJournal ) ); - //sqlite3_free( ref pMaster ); - } - return rc; - } + rc = read32bits(jfd, pOffset, ref pgno); + if (rc != SQLITE_OK) + return rc; + rc = sqlite3OsRead(jfd, aData, pPager.pageSize, (pOffset) + 4); + if (rc != SQLITE_OK) + return rc; + pOffset += pPager.pageSize + 4 + isMainJrnl * 4; + /* Sanity checking on the page. This is more important that I originally + ** thought. If a power failure occurs while the journal is being written, + ** it could cause invalid data to be written into the journal. We need to + ** detect this invalid data (with high probability) and ignore it. + */ + if (pgno == 0 || pgno == PAGER_MJ_PGNO(pPager)) { + Debug.Assert(0 == isSavepnt); + return SQLITE_DONE; + } + if (pgno > pPager.dbSize || sqlite3BitvecTest(pDone, pgno) != 0) { + return SQLITE_OK; + } + if (isMainJrnl != 0) { + rc = read32bits(jfd, (pOffset) - 4, ref cksum); + if (rc != 0) + return rc; + if (0 == isSavepnt && pager_cksum(pPager, aData) != cksum) { + return SQLITE_DONE; + } + } + /* If this page has already been played by before during the current + ** rollback, then don't bother to play it back again. + */ + if (pDone != null && (rc = sqlite3BitvecSet(pDone, pgno)) != SQLITE_OK) { + return rc; + } - /* - ** This function is used to change the actual size of the database - ** file in the file-system. This only happens when committing a transaction, - ** or rolling back a transaction (including rolling back a hot-journal). - ** - ** If the main database file is not open, or the pager is not in either - ** DBMOD or OPEN state, this function is a no-op. Otherwise, the size - ** of the file is changed to nPage pages (nPage*pPager.pageSize bytes). - ** If the file on disk is currently larger than nPage pages, then use the VFS - ** xTruncate() method to truncate it. - ** - ** Or, it might might be the case that the file on disk is smaller than - ** nPage pages. Some operating system implementations can get confused if - ** you try to truncate a file to some size that is larger than it - ** currently is, so detect this case and write a single zero byte to - ** the end of the new file instead. - ** - ** If successful, return SQLITE_OK. If an IO error occurs while modifying - ** the database file, return the error code to the caller. - */ - static int pager_truncate( Pager pPager, u32 nPage ) - { - int rc = SQLITE_OK; - Debug.Assert( pPager.eState != PAGER_ERROR ); - Debug.Assert( pPager.eState != PAGER_READER ); + /* When playing back page 1, restore the nReserve setting + */ + if (pgno == 1 && pPager.nReserve != (aData)[20]) { + pPager.nReserve = (aData)[20]; + pagerReportSize(pPager); + } - if ( isOpen( pPager.fd ) - && ( pPager.eState >= PAGER_WRITER_DBMOD || pPager.eState == PAGER_OPEN ) - ) - { - i64 currentSize = 0, newSize; - int szPage = pPager.pageSize; - Debug.Assert( pPager.eLock == EXCLUSIVE_LOCK ); - /* TODO: Is it safe to use Pager.dbFileSize here? */ - rc = sqlite3OsFileSize( pPager.fd, ref currentSize ); - newSize = szPage * nPage; - if ( rc == SQLITE_OK && currentSize != newSize ) - { - if ( currentSize > newSize ) - { - rc = sqlite3OsTruncate( pPager.fd, newSize ); - } - else - { - byte[] pTmp = pPager.pTmpSpace; - Array.Clear( pTmp, 0, szPage );//memset( pTmp, 0, szPage ); - testcase( ( newSize - szPage ) < currentSize ); - testcase( ( newSize - szPage ) == currentSize ); - testcase( ( newSize - szPage ) > currentSize ); - rc = sqlite3OsWrite( pPager.fd, pTmp, szPage, newSize - szPage ); - } - if ( rc == SQLITE_OK ) - { - pPager.dbSize = nPage; - } + /* If the pager is in CACHEMOD state, then there must be a copy of this + ** page in the pager cache. In this case just update the pager cache, + ** not the database file. The page is left marked dirty in this case. + ** + ** An exception to the above rule: If the database is in no-sync mode + ** and a page is moved during an incremental vacuum then the page may + ** not be in the pager cache. Later: if a malloc() or IO error occurs + ** during a Movepage() call, then the page may not be in the cache + ** either. So the condition described in the above paragraph is not + ** assert()able. + ** + ** If in WRITER_DBMOD, WRITER_FINISHED or OPEN state, then we update the + ** pager cache if it exists and the main file. The page is then marked + ** not dirty. Since this code is only executed in PAGER_OPEN state for + ** a hot-journal rollback, it is guaranteed that the page-cache is empty + ** if the pager is in OPEN state. + ** + ** Ticket #1171: The statement journal might contain page content that is + ** different from the page content at the start of the transaction. + ** This occurs when a page is changed prior to the start of a statement + ** then changed again within the statement. When rolling back such a + ** statement we must not write to the original database unless we know + ** for certain that original page contents are synced into the main rollback + ** journal. Otherwise, a power loss might leave modified data in the + ** database file without an entry in the rollback journal that can + ** restore the database to its original form. Two conditions must be + ** met before writing to the database files. (1) the database must be + ** locked. (2) we know that the original page content is fully synced + ** in the main journal either because the page is not in cache or else + ** the page is marked as needSync==0. + ** + ** 2008-04-14: When attempting to vacuum a corrupt database file, it + ** is possible to fail a statement on a database that does not yet exist. + ** Do not attempt to write if database file has never been opened. + */ + if (pagerUseWal(pPager)) { + pPg = null; + } else { + pPg = pager_lookup(pPager, pgno); + } + Debug.Assert(pPg != null || +#if SQLITE_OMIT_MEMORYDB +0==MEMDB +#else + pPager.memDb == 0 +#endif + ); + Debug.Assert(pPager.eState != PAGER_OPEN || pPg == null); + + PAGERTRACE("PLAYBACK %d page %d hash(%08x) %s\n", + PAGERID(pPager), pgno, pager_datahash(pPager.pageSize, aData), + (isMainJrnl != 0 ? "main-journal" : "sub-journal") + ); + if (isMainJrnl != 0) { + isSynced = pPager.noSync || (pOffset <= pPager.journalHdr); + } else { + isSynced = (pPg == null || 0 == (pPg.flags & PGHDR_NEED_SYNC)); + } + if (isOpen(pPager.fd) + && (pPager.eState >= PAGER_WRITER_DBMOD || pPager.eState == PAGER_OPEN) + && isSynced + ) { + i64 ofst = (pgno - 1) * pPager.pageSize; + testcase(0 == isSavepnt && pPg != null && (pPg.flags & PGHDR_NEED_SYNC) != 0); + Debug.Assert(!pagerUseWal(pPager)); + rc = sqlite3OsWrite(pPager.fd, aData, pPager.pageSize, ofst); + if (pgno > pPager.dbFileSize) { + pPager.dbFileSize = pgno; + } + if (pPager.pBackup != null) { + if (CODEC1(pPager, aData, pgno, SQLITE_DECRYPT)) + rc = SQLITE_NOMEM; // CODEC1( pPager, aData, pgno, 3, rc = SQLITE_NOMEM ); + sqlite3BackupUpdate(pPager.pBackup, pgno, (u8[])aData); + if (CODEC2(pPager, aData, pgno, SQLITE_ENCRYPT_READ_CTX, ref aData)) + rc = SQLITE_NOMEM;//CODEC2( pPager, aData, pgno, 7, rc = SQLITE_NOMEM, aData); + } + } else if (0 == isMainJrnl && pPg == null) { + /* If this is a rollback of a savepoint and data was not written to + ** the database and the page is not in-memory, there is a potential + ** problem. When the page is next fetched by the b-tree layer, it + ** will be read from the database file, which may or may not be + ** current. + ** + ** There are a couple of different ways this can happen. All are quite + ** obscure. When running in synchronous mode, this can only happen + ** if the page is on the free-list at the start of the transaction, then + ** populated, then moved using sqlite3PagerMovepage(). + ** + ** The solution is to add an in-memory page to the cache containing + ** the data just read from the sub-journal. Mark the page as dirty + ** and if the pager requires a journal-sync, then mark the page as + ** requiring a journal-sync before it is written. + */ + Debug.Assert(isSavepnt != 0); + Debug.Assert(pPager.doNotSpill == 0); + pPager.doNotSpill++; + rc = sqlite3PagerAcquire(pPager, pgno, ref pPg, 1); + Debug.Assert(pPager.doNotSpill == 1); + pPager.doNotSpill--; + if (rc != SQLITE_OK) + return rc; + pPg.flags &= ~PGHDR_NEED_READ; + sqlite3PcacheMakeDirty(pPg); + } + if (pPg != null) { + /* No page should ever be explicitly rolled back that is in use, except + ** for page 1 which is held in use in order to keep the lock on the + ** database active. However such a page may be rolled back as a result + ** of an internal error resulting in an automatic call to + ** sqlite3PagerRollback(). + */ + byte[] pData = pPg.pData; + Buffer.BlockCopy(aData, 0, pData, 0, pPager.pageSize);// memcpy(pData, (u8[])aData, pPager.pageSize); + pPager.xReiniter(pPg); + if (isMainJrnl != 0 && (0 == isSavepnt || pOffset <= pPager.journalHdr)) { + /* If the contents of this page were just restored from the main + ** journal file, then its content must be as they were when the + ** transaction was first opened. In this case we can mark the page + ** as clean, since there will be no need to write it out to the + ** database. + ** + ** There is one exception to this rule. If the page is being rolled + ** back as part of a savepoint (or statement) rollback from an + ** unsynced portion of the main journal file, then it is not safe + ** to mark the page as clean. This is because marking the page as + ** clean will clear the PGHDR_NEED_SYNC flag. Since the page is + ** already in the journal file (recorded in Pager.pInJournal) and + ** the PGHDR_NEED_SYNC flag is cleared, if the page is written to + ** again within this transaction, it will be marked as dirty but + ** the PGHDR_NEED_SYNC flag will not be set. It could then potentially + ** be written out into the database file before its journal file + ** segment is synced. If a crash occurs during or following this, + ** database corruption may ensue. + */ + Debug.Assert(!pagerUseWal(pPager)); + sqlite3PcacheMakeClean(pPg); + } + pager_set_pagehash(pPg); + /* If this was page 1, then restore the value of Pager.dbFileVers. + ** Do this before any decoding. */ + if (pgno == 1) { + Buffer.BlockCopy(pData, 24, pPager.dbFileVers, 0, pPager.dbFileVers.Length); //memcpy(pPager.dbFileVers, ((u8*)pData)[24], sizeof(pPager.dbFileVers)); + } + + /* Decode the page just read from disk */ + if (CODEC1(pPager, pData, pPg.pgno, SQLITE_DECRYPT)) + rc = SQLITE_NOMEM; //CODEC1(pPager, pData, pPg.pgno, 3, rc=SQLITE_NOMEM); + sqlite3PcacheRelease(pPg); + } + return rc; } - } - return rc; - } - /* - ** Set the value of the Pager.sectorSize variable for the given - ** pager based on the value returned by the xSectorSize method - ** of the open database file. The sector size will be used used - ** to determine the size and alignment of journal header and - ** master journal pointers within created journal files. - ** - ** For temporary files the effective sector size is always 512 bytes. - ** - ** Otherwise, for non-temporary files, the effective sector size is - ** the value returned by the xSectorSize() method rounded up to 512 if - ** it is less than 32, or rounded down to MAX_SECTOR_SIZE if it - ** is greater than MAX_SECTOR_SIZE. - */ - static void setSectorSize( Pager pPager ) - { - Debug.Assert( isOpen( pPager.fd ) || pPager.tempFile ); - if ( !pPager.tempFile ) - { - /* Sector size doesn't matter for temporary files. Also, the file - ** may not have been opened yet, in which case the OsSectorSize() - ** call will segfault. + /* + ** Parameter zMaster is the name of a master journal file. A single journal + ** file that referred to the master journal file has just been rolled back. + ** This routine checks if it is possible to delete the master journal file, + ** and does so if it is. + ** + ** Argument zMaster may point to Pager.pTmpSpace. So that buffer is not + ** available for use within this function. + ** + ** When a master journal file is created, it is populated with the names + ** of all of its child journals, one after another, formatted as utf-8 + ** encoded text. The end of each child journal file is marked with a + ** nul-terminator byte (0x00). i.e. the entire contents of a master journal + ** file for a transaction involving two databases might be: + ** + ** "/home/bill/a.db-journal\x00/home/bill/b.db-journal\x00" + ** + ** A master journal file may only be deleted once all of its child + ** journals have been rolled back. + ** + ** This function reads the contents of the master-journal file into + ** memory and loops through each of the child journal names. For + ** each child journal, it checks if: + ** + ** * if the child journal exists, and if so + ** * if the child journal contains a reference to master journal + ** file zMaster + ** + ** If a child journal can be found that matches both of the criteria + ** above, this function returns without doing anything. Otherwise, if + ** no such child journal can be found, file zMaster is deleted from + ** the file-system using sqlite3OsDelete(). + ** + ** If an IO error within this function, an error code is returned. This + ** function allocates memory by calling sqlite3Malloc(). If an allocation + ** fails, SQLITE_NOMEM is returned. Otherwise, if no IO or malloc errors + ** occur, SQLITE_OK is returned. + ** + ** TODO: This function allocates a single block of memory to load + ** the entire contents of the master journal file. This could be + ** a couple of kilobytes or so - potentially larger than the page + ** size. */ - pPager.sectorSize = (u32)sqlite3OsSectorSize( pPager.fd ); - } - if ( pPager.sectorSize < 32 ) - { - Debug.Assert( MAX_SECTOR_SIZE >= 512 ); - pPager.sectorSize = 512; - } - if ( pPager.sectorSize > MAX_SECTOR_SIZE ) - { - pPager.sectorSize = MAX_SECTOR_SIZE; - } - } + static int pager_delmaster(Pager pPager, string zMaster) { + sqlite3_vfs pVfs = pPager.pVfs; + int rc; /* Return code */ + sqlite3_file pMaster; /* Malloc'd master-journal file descriptor */ + sqlite3_file pJournal; /* Malloc'd child-journal file descriptor */ + //string zMasterJournal = null; /* Contents of master journal file */ + i64 nMasterJournal; /* Size of master journal file */ + string zJournal; /* Pointer to one journal within MJ file */ + string zMasterPtr; /* Space to hold MJ filename from a journal file */ + int nMasterPtr; /* Amount of space allocated to zMasterPtr[] */ + + /* Allocate space for both the pJournal and pMaster file descriptors. + ** If successful, open the master journal file for reading. + */ + pMaster = new sqlite3_file();// (sqlite3_file*)sqlite3MallocZero( pVfs.szOsFile * 2 ); + pJournal = new sqlite3_file();// (sqlite3_file*)( ( (u8*)pMaster ) + pVfs.szOsFile ); + //if ( null == pMaster ) + //{ + // rc = SQLITE_NOMEM; + //} + //else + { + const int flags = (SQLITE_OPEN_READONLY | SQLITE_OPEN_MASTER_JOURNAL); + int iDummy = 0; + rc = sqlite3OsOpen(pVfs, zMaster, pMaster, flags, ref iDummy); + } + if (rc != SQLITE_OK) + goto delmaster_out; + Debugger.Break(); //TODO -- - /* - ** Playback the journal and thus restore the database file to - ** the state it was in before we started making changes. - ** - ** The journal file format is as follows: - ** - ** (1) 8 byte prefix. A copy of aJournalMagic[]. - ** (2) 4 byte big-endian integer which is the number of valid page records - ** in the journal. If this value is 0xffffffff, then compute the - ** number of page records from the journal size. - ** (3) 4 byte big-endian integer which is the initial value for the - ** sanity checksum. - ** (4) 4 byte integer which is the number of pages to truncate the - ** database to during a rollback. - ** (5) 4 byte big-endian integer which is the sector size. The header - ** is this many bytes in size. - ** (6) 4 byte big-endian integer which is the page size. - ** (7) zero padding out to the next sector size. - ** (8) Zero or more pages instances, each as follows: - ** - ** When we speak of the journal header, we mean the first 7 items above. - ** Each entry in the journal is an instance of the 8th item. - ** - ** Call the value from the second bullet "nRec". nRec is the number of - ** valid page entries in the journal. In most cases, you can compute the - ** value of nRec from the size of the journal file. But if a power - ** failure occurred while the journal was being written, it could be the - ** case that the size of the journal file had already been increased but - ** the extra entries had not yet made it safely to disk. In such a case, - ** the value of nRec computed from the file size would be too large. For - ** that reason, we always use the nRec value in the header. - ** - ** If the nRec value is 0xffffffff it means that nRec should be computed - ** from the file size. This value is used when the user selects the - ** no-sync option for the journal. A power failure could lead to corruption - ** in this case. But for things like temporary table (which will be - ** deleted when the power is restored) we don't care. - ** - ** If the file opened as the journal file is not a well-formed - ** journal file then all pages up to the first corrupted page are rolled - ** back (or no pages if the journal header is corrupted). The journal file - ** is then deleted and SQLITE_OK returned, just as if no corruption had - ** been encountered. - ** - ** If an I/O or malloc() error occurs, the journal-file is not deleted - ** and an error code is returned. - ** - ** The isHot parameter indicates that we are trying to rollback a journal - ** that might be a hot journal. Or, it could be that the journal is - ** preserved because of JOURNALMODE_PERSIST or JOURNALMODE_TRUNCATE. - ** If the journal really is hot, reset the pager cache prior rolling - ** back any content. If the journal is merely persistent, no reset is - ** needed. - */ - static int pager_playback( Pager pPager, int isHot ) - { - sqlite3_vfs pVfs = pPager.pVfs; - i64 szJ = 0; /* Size of the journal file in bytes */ - u32 nRec = 0; /* Number of Records in the journal */ - u32 u; /* Unsigned loop counter */ - u32 mxPg = 0; /* Size of the original file in pages */ - int rc; /* Result code of a subroutine */ - int res = 1; /* Value returned by sqlite3OsAccess() */ - byte[] zMaster = null; /* Name of master journal file if any */ - int needPagerReset; /* True to reset page prior to first page rollback */ - - /* Figure out how many records are in the journal. Abort early if - ** the journal is empty. - */ - Debug.Assert( isOpen( pPager.jfd ) ); - rc = sqlite3OsFileSize( pPager.jfd, ref szJ ); - if ( rc != SQLITE_OK ) - { - goto end_playback; - } + /* Load the entire master journal file into space obtained from + ** sqlite3_malloc() and pointed to by zMasterJournal. Also obtain + ** sufficient space (in zMasterPtr) to hold the names of master + ** journal files extracted from regular rollback-journals. + */ + //rc = sqlite3OsFileSize(pMaster, &nMasterJournal); + //if (rc != SQLITE_OK) goto delmaster_out; + //nMasterPtr = pVfs.mxPathname + 1; + // zMasterJournal = sqlite3Malloc((int)nMasterJournal + nMasterPtr + 1); + // if ( !zMasterJournal ) + // { + // rc = SQLITE_NOMEM; + // goto delmaster_out; + // } + // zMasterPtr = &zMasterJournal[nMasterJournal+1]; + // rc = sqlite3OsRead( pMaster, zMasterJournal, (int)nMasterJournal, 0 ); + // if ( rc != SQLITE_OK ) goto delmaster_out; + // zMasterJournal[nMasterJournal] = 0; + + + // zJournal = zMasterJournal; + // while ( ( zJournal - zMasterJournal ) < nMasterJournal ) + // { + // int exists; + // rc = sqlite3OsAccess( pVfs, zJournal, SQLITE_ACCESS_EXISTS, &exists ); + // if ( rc != SQLITE_OK ) + // { + // goto delmaster_out; + // } + // if ( exists ) + // { + // /* One of the journals pointed to by the master journal exists. + // ** Open it and check if it points at the master journal. If + // ** so, return without deleting the master journal file. + // */ + // int c; + // int flags = ( SQLITE_OPEN_READONLY | SQLITE_OPEN_MAIN_JOURNAL ); + // rc = sqlite3OsOpen( pVfs, zJournal, pJournal, flags, 0 ); + // if ( rc != SQLITE_OK ) + // { + // goto delmaster_out; + // } + + // rc = readMasterJournal( pJournal, zMasterPtr, nMasterPtr ); + // sqlite3OsClose( pJournal ); + // if ( rc != SQLITE_OK ) + // { + // goto delmaster_out; + // } + + // c = zMasterPtr[0] != 0 && strcmp( zMasterPtr, zMaster ) == 0; + // if ( c ) + // { + // /* We have a match. Do not delete the master journal file. */ + // goto delmaster_out; + // } + // } + // zJournal += ( sqlite3Strlen30( zJournal ) + 1 ); + // } + // + //sqlite3OsClose(pMaster); + //rc = sqlite3OsDelete( pVfs, zMaster, 0 ); + + + goto delmaster_out; + delmaster_out: + //sqlite3_free( ref zMasterJournal ); + if (pMaster != null) { + sqlite3OsClose(pMaster); + Debug.Assert(!isOpen(pJournal)); + //sqlite3_free( ref pMaster ); + } + return rc; + } - /* Read the master journal name from the journal, if it is present. - ** If a master journal file name is specified, but the file is not - ** present on disk, then the journal is not hot and does not need to be - ** played back. - ** - ** TODO: Technically the following is an error because it assumes that - ** buffer Pager.pTmpSpace is (mxPathname+1) bytes or larger. i.e. that - ** (pPager.pageSize >= pPager.pVfs.mxPathname+1). Using os_unix.c, - ** mxPathname is 512, which is the same as the minimum allowable value - ** for pageSize. - */ - zMaster = new byte[pPager.pVfs.mxPathname + 1];// pPager.pTmpSpace ); - rc = readMasterJournal( pPager.jfd, zMaster, (u32)pPager.pVfs.mxPathname + 1 ); - if ( rc == SQLITE_OK && zMaster[0] != 0 ) - { - rc = sqlite3OsAccess( pVfs, Encoding.UTF8.GetString( zMaster, 0, zMaster.Length ), SQLITE_ACCESS_EXISTS, ref res ); - } - zMaster = null; - if ( rc != SQLITE_OK || res == 0 ) - { - goto end_playback; - } - pPager.journalOff = 0; - needPagerReset = isHot; - /* This loop terminates either when a readJournalHdr() or - ** pager_playback_one_page() call returns SQLITE_DONE or an IO error - ** occurs. - */ - while ( true ) - { - /* Read the next journal header from the journal file. If there are - ** not enough bytes left in the journal file for a complete header, or - ** it is corrupted, then a process must have failed while writing it. - ** This indicates nothing more needs to be rolled back. + /* + ** This function is used to change the actual size of the database + ** file in the file-system. This only happens when committing a transaction, + ** or rolling back a transaction (including rolling back a hot-journal). + ** + ** If the main database file is not open, or the pager is not in either + ** DBMOD or OPEN state, this function is a no-op. Otherwise, the size + ** of the file is changed to nPage pages (nPage*pPager.pageSize bytes). + ** If the file on disk is currently larger than nPage pages, then use the VFS + ** xTruncate() method to truncate it. + ** + ** Or, it might might be the case that the file on disk is smaller than + ** nPage pages. Some operating system implementations can get confused if + ** you try to truncate a file to some size that is larger than it + ** currently is, so detect this case and write a single zero byte to + ** the end of the new file instead. + ** + ** If successful, return SQLITE_OK. If an IO error occurs while modifying + ** the database file, return the error code to the caller. */ - rc = readJournalHdr( pPager, isHot, szJ, out nRec, out mxPg ); - if ( rc != SQLITE_OK ) - { - if ( rc == SQLITE_DONE ) - { - rc = SQLITE_OK; - } - goto end_playback; + static int pager_truncate(Pager pPager, u32 nPage) { + int rc = SQLITE_OK; + Debug.Assert(pPager.eState != PAGER_ERROR); + Debug.Assert(pPager.eState != PAGER_READER); + + if (isOpen(pPager.fd) + && (pPager.eState >= PAGER_WRITER_DBMOD || pPager.eState == PAGER_OPEN) + ) { + i64 currentSize = 0, newSize; + int szPage = pPager.pageSize; + Debug.Assert(pPager.eLock == EXCLUSIVE_LOCK); + /* TODO: Is it safe to use Pager.dbFileSize here? */ + rc = sqlite3OsFileSize(pPager.fd, ref currentSize); + newSize = szPage * nPage; + if (rc == SQLITE_OK && currentSize != newSize) { + if (currentSize > newSize) { + rc = sqlite3OsTruncate(pPager.fd, newSize); + } else { + byte[] pTmp = pPager.pTmpSpace; + Array.Clear(pTmp, 0, szPage);//memset( pTmp, 0, szPage ); + testcase((newSize - szPage) < currentSize); + testcase((newSize - szPage) == currentSize); + testcase((newSize - szPage) > currentSize); + rc = sqlite3OsWrite(pPager.fd, pTmp, szPage, newSize - szPage); + } + if (rc == SQLITE_OK) { + pPager.dbSize = nPage; + } + } + } + return rc; } - /* If nRec is 0xffffffff, then this journal was created by a process - ** working in no-sync mode. This means that the rest of the journal - ** file consists of pages, there are no more journal headers. Compute - ** the value of nRec based on this assumption. + /* + ** Set the value of the Pager.sectorSize variable for the given + ** pager based on the value returned by the xSectorSize method + ** of the open database file. The sector size will be used used + ** to determine the size and alignment of journal header and + ** master journal pointers within created journal files. + ** + ** For temporary files the effective sector size is always 512 bytes. + ** + ** Otherwise, for non-temporary files, the effective sector size is + ** the value returned by the xSectorSize() method rounded up to 512 if + ** it is less than 32, or rounded down to MAX_SECTOR_SIZE if it + ** is greater than MAX_SECTOR_SIZE. */ - if ( nRec == 0xffffffff ) - { - Debug.Assert( pPager.journalOff == JOURNAL_HDR_SZ( pPager ) ); - nRec = (u32)( ( szJ - JOURNAL_HDR_SZ( pPager ) ) / JOURNAL_PG_SZ( pPager ) ); + static void setSectorSize(Pager pPager) { + Debug.Assert(isOpen(pPager.fd) || pPager.tempFile); + if (!pPager.tempFile) { + /* Sector size doesn't matter for temporary files. Also, the file + ** may not have been opened yet, in which case the OsSectorSize() + ** call will segfault. + */ + pPager.sectorSize = (u32)sqlite3OsSectorSize(pPager.fd); + } + if (pPager.sectorSize < 32) { + Debug.Assert(MAX_SECTOR_SIZE >= 512); + pPager.sectorSize = 512; + } + if (pPager.sectorSize > MAX_SECTOR_SIZE) { + pPager.sectorSize = MAX_SECTOR_SIZE; + } } - /* If nRec is 0 and this rollback is of a transaction created by this - ** process and if this is the final header in the journal, then it means - ** that this part of the journal was being filled but has not yet been - ** synced to disk. Compute the number of pages based on the remaining - ** size of the file. - ** - ** The third term of the test was added to fix ticket #2565. - ** When rolling back a hot journal, nRec==0 always means that the next - ** chunk of the journal contains zero pages to be rolled back. But - ** when doing a ROLLBACK and the nRec==0 chunk is the last chunk in - ** the journal, it means that the journal might contain additional - ** pages that need to be rolled back and that the number of pages - ** should be computed based on the journal file size. - */ - if ( nRec == 0 && 0 == isHot && - pPager.journalHdr + JOURNAL_HDR_SZ( pPager ) == pPager.journalOff ) - { - nRec = (u32)( ( szJ - pPager.journalOff ) / JOURNAL_PG_SZ( pPager ) ); - } - /* If this is the first header read from the journal, truncate the - ** database file back to its original size. + /* + ** Playback the journal and thus restore the database file to + ** the state it was in before we started making changes. + ** + ** The journal file format is as follows: + ** + ** (1) 8 byte prefix. A copy of aJournalMagic[]. + ** (2) 4 byte big-endian integer which is the number of valid page records + ** in the journal. If this value is 0xffffffff, then compute the + ** number of page records from the journal size. + ** (3) 4 byte big-endian integer which is the initial value for the + ** sanity checksum. + ** (4) 4 byte integer which is the number of pages to truncate the + ** database to during a rollback. + ** (5) 4 byte big-endian integer which is the sector size. The header + ** is this many bytes in size. + ** (6) 4 byte big-endian integer which is the page size. + ** (7) zero padding out to the next sector size. + ** (8) Zero or more pages instances, each as follows: + ** + ** When we speak of the journal header, we mean the first 7 items above. + ** Each entry in the journal is an instance of the 8th item. + ** + ** Call the value from the second bullet "nRec". nRec is the number of + ** valid page entries in the journal. In most cases, you can compute the + ** value of nRec from the size of the journal file. But if a power + ** failure occurred while the journal was being written, it could be the + ** case that the size of the journal file had already been increased but + ** the extra entries had not yet made it safely to disk. In such a case, + ** the value of nRec computed from the file size would be too large. For + ** that reason, we always use the nRec value in the header. + ** + ** If the nRec value is 0xffffffff it means that nRec should be computed + ** from the file size. This value is used when the user selects the + ** no-sync option for the journal. A power failure could lead to corruption + ** in this case. But for things like temporary table (which will be + ** deleted when the power is restored) we don't care. + ** + ** If the file opened as the journal file is not a well-formed + ** journal file then all pages up to the first corrupted page are rolled + ** back (or no pages if the journal header is corrupted). The journal file + ** is then deleted and SQLITE_OK returned, just as if no corruption had + ** been encountered. + ** + ** If an I/O or malloc() error occurs, the journal-file is not deleted + ** and an error code is returned. + ** + ** The isHot parameter indicates that we are trying to rollback a journal + ** that might be a hot journal. Or, it could be that the journal is + ** preserved because of JOURNALMODE_PERSIST or JOURNALMODE_TRUNCATE. + ** If the journal really is hot, reset the pager cache prior rolling + ** back any content. If the journal is merely persistent, no reset is + ** needed. */ - if ( pPager.journalOff == JOURNAL_HDR_SZ( pPager ) ) - { - rc = pager_truncate( pPager, mxPg ); - if ( rc != SQLITE_OK ) - { - goto end_playback; - } - pPager.dbSize = mxPg; - } + static int pager_playback(Pager pPager, int isHot) { + sqlite3_vfs pVfs = pPager.pVfs; + i64 szJ = 0; /* Size of the journal file in bytes */ + u32 nRec = 0; /* Number of Records in the journal */ + u32 u; /* Unsigned loop counter */ + u32 mxPg = 0; /* Size of the original file in pages */ + int rc; /* Result code of a subroutine */ + int res = 1; /* Value returned by sqlite3OsAccess() */ + byte[] zMaster = null; /* Name of master journal file if any */ + int needPagerReset; /* True to reset page prior to first page rollback */ + + /* Figure out how many records are in the journal. Abort early if + ** the journal is empty. + */ + Debug.Assert(isOpen(pPager.jfd)); + rc = sqlite3OsFileSize(pPager.jfd, ref szJ); + if (rc != SQLITE_OK) { + goto end_playback; + } - /* Copy original pages out of the journal and back into the - ** database file and/or page cache. - */ - for ( u = 0; u < nRec; u++ ) - { - if ( needPagerReset != 0 ) - { - pager_reset( pPager ); - needPagerReset = 0; - } - rc = pager_playback_one_page( pPager, ref pPager.journalOff, null, 1, 0 ); - if ( rc != SQLITE_OK ) - { - if ( rc == SQLITE_DONE ) - { - rc = SQLITE_OK; - pPager.journalOff = szJ; - break; + /* Read the master journal name from the journal, if it is present. + ** If a master journal file name is specified, but the file is not + ** present on disk, then the journal is not hot and does not need to be + ** played back. + ** + ** TODO: Technically the following is an error because it assumes that + ** buffer Pager.pTmpSpace is (mxPathname+1) bytes or larger. i.e. that + ** (pPager.pageSize >= pPager.pVfs.mxPathname+1). Using os_unix.c, + ** mxPathname is 512, which is the same as the minimum allowable value + ** for pageSize. + */ + zMaster = new byte[pPager.pVfs.mxPathname + 1];// pPager.pTmpSpace ); + rc = readMasterJournal(pPager.jfd, zMaster, (u32)pPager.pVfs.mxPathname + 1); + if (rc == SQLITE_OK && zMaster[0] != 0) { + rc = sqlite3OsAccess(pVfs, Encoding.UTF8.GetString(zMaster, 0, zMaster.Length), SQLITE_ACCESS_EXISTS, ref res); } - else if ( rc == SQLITE_IOERR_SHORT_READ ) - { - /* If the journal has been truncated, simply stop reading and - ** processing the journal. This might happen if the journal was - ** not completely written and synced prior to a crash. In that - ** case, the database should have never been written in the - ** first place so it is OK to simply abandon the rollback. */ - rc = SQLITE_OK; - goto end_playback; - } - else - { - /* If we are unable to rollback, quit and return the error - ** code. This will cause the pager to enter the error state - ** so that no further harm will be done. Perhaps the next - ** process to come along will be able to rollback the database. - */ - goto end_playback; + zMaster = null; + if (rc != SQLITE_OK || res == 0) { + goto end_playback; } - } - } - } -/*NOTREACHED*/ + pPager.journalOff = 0; + needPagerReset = isHot; - end_playback: - /* Following a rollback, the database file should be back in its original - ** state prior to the start of the transaction, so invoke the - ** SQLITE_FCNTL_DB_UNCHANGED file-control method to disable the - ** assertion that the transaction counter was modified. - */ - sqlite3_int64 iDummy = 0; - Debug.Assert( - pPager.fd.pMethods == null || - sqlite3OsFileControl( pPager.fd, SQLITE_FCNTL_DB_UNCHANGED, ref iDummy ) >= SQLITE_OK - ); + /* This loop terminates either when a readJournalHdr() or + ** pager_playback_one_page() call returns SQLITE_DONE or an IO error + ** occurs. + */ + while (true) { - /* If this playback is happening automatically as a result of an IO or - ** malloc error that occurred after the change-counter was updated but - ** before the transaction was committed, then the change-counter - ** modification may just have been reverted. If this happens in exclusive - ** mode, then subsequent transactions performed by the connection will not - ** update the change-counter at all. This may lead to cache inconsistency - ** problems for other processes at some point in the future. So, just - ** in case this has happened, clear the changeCountDone flag now. - */ - pPager.changeCountDone = pPager.tempFile; + /* Read the next journal header from the journal file. If there are + ** not enough bytes left in the journal file for a complete header, or + ** it is corrupted, then a process must have failed while writing it. + ** This indicates nothing more needs to be rolled back. + */ + rc = readJournalHdr(pPager, isHot, szJ, out nRec, out mxPg); + if (rc != SQLITE_OK) { + if (rc == SQLITE_DONE) { + rc = SQLITE_OK; + } + goto end_playback; + } - if ( rc == SQLITE_OK ) - { - zMaster = new byte[pPager.pVfs.mxPathname + 1];//pPager.pTmpSpace ); - rc = readMasterJournal( pPager.jfd, zMaster, (u32)pPager.pVfs.mxPathname + 1 ); - testcase( rc != SQLITE_OK ); - } - if ( rc == SQLITE_OK - && ( pPager.eState >= PAGER_WRITER_DBMOD || pPager.eState == PAGER_OPEN ) - ) - { - rc = sqlite3PagerSync( pPager ); - } - if ( rc == SQLITE_OK ) - { - rc = pager_end_transaction( pPager, zMaster[0] != '\0' ? 1 : 0 ); - testcase( rc != SQLITE_OK ); - } - if ( rc == SQLITE_OK && zMaster[0] != '\0' && res != 0 ) - { - /* If there was a master journal and this routine will return success, - ** see if it is possible to delete the master journal. - */ - rc = pager_delmaster( pPager, Encoding.UTF8.GetString( zMaster, 0, zMaster.Length ) ); - testcase( rc != SQLITE_OK ); - } + /* If nRec is 0xffffffff, then this journal was created by a process + ** working in no-sync mode. This means that the rest of the journal + ** file consists of pages, there are no more journal headers. Compute + ** the value of nRec based on this assumption. + */ + if (nRec == 0xffffffff) { + Debug.Assert(pPager.journalOff == JOURNAL_HDR_SZ(pPager)); + nRec = (u32)((szJ - JOURNAL_HDR_SZ(pPager)) / JOURNAL_PG_SZ(pPager)); + } - /* The Pager.sectorSize variable may have been updated while rolling - ** back a journal created by a process with a different sector size - ** value. Reset it to the correct value for this process. - */ - setSectorSize( pPager ); - return rc; - } + /* If nRec is 0 and this rollback is of a transaction created by this + ** process and if this is the final header in the journal, then it means + ** that this part of the journal was being filled but has not yet been + ** synced to disk. Compute the number of pages based on the remaining + ** size of the file. + ** + ** The third term of the test was added to fix ticket #2565. + ** When rolling back a hot journal, nRec==0 always means that the next + ** chunk of the journal contains zero pages to be rolled back. But + ** when doing a ROLLBACK and the nRec==0 chunk is the last chunk in + ** the journal, it means that the journal might contain additional + ** pages that need to be rolled back and that the number of pages + ** should be computed based on the journal file size. + */ + if (nRec == 0 && 0 == isHot && + pPager.journalHdr + JOURNAL_HDR_SZ(pPager) == pPager.journalOff) { + nRec = (u32)((szJ - pPager.journalOff) / JOURNAL_PG_SZ(pPager)); + } + /* If this is the first header read from the journal, truncate the + ** database file back to its original size. + */ + if (pPager.journalOff == JOURNAL_HDR_SZ(pPager)) { + rc = pager_truncate(pPager, mxPg); + if (rc != SQLITE_OK) { + goto end_playback; + } + pPager.dbSize = mxPg; + } - /* - ** Read the content for page pPg out of the database file and into - ** pPg.pData. A shared lock or greater must be held on the database - ** file before this function is called. - ** - ** If page 1 is read, then the value of Pager.dbFileVers[] is set to - ** the value read from the database file. - ** - ** If an IO error occurs, then the IO error is returned to the caller. - ** Otherwise, SQLITE_OK is returned. - */ - static int readDbPage( PgHdr pPg ) - { - Pager pPager = pPg.pPager; /* Pager object associated with page pPg */ - Pgno pgno = pPg.pgno; /* Page number to read */ - int rc = SQLITE_OK; /* Return code */ - int isInWal = 0; /* True if page is in log file */ - int pgsz = pPager.pageSize; /* Number of bytes to read */ + /* Copy original pages out of the journal and back into the + ** database file and/or page cache. + */ + for (u = 0; u < nRec; u++) { + if (needPagerReset != 0) { + pager_reset(pPager); + needPagerReset = 0; + } + rc = pager_playback_one_page(pPager, ref pPager.journalOff, null, 1, 0); + if (rc != SQLITE_OK) { + if (rc == SQLITE_DONE) { + rc = SQLITE_OK; + pPager.journalOff = szJ; + break; + } else if (rc == SQLITE_IOERR_SHORT_READ) { + /* If the journal has been truncated, simply stop reading and + ** processing the journal. This might happen if the journal was + ** not completely written and synced prior to a crash. In that + ** case, the database should have never been written in the + ** first place so it is OK to simply abandon the rollback. */ + rc = SQLITE_OK; + goto end_playback; + } else { + /* If we are unable to rollback, quit and return the error + ** code. This will cause the pager to enter the error state + ** so that no further harm will be done. Perhaps the next + ** process to come along will be able to rollback the database. + */ + goto end_playback; + } + } + } + } + /*NOTREACHED*/ + + end_playback: + /* Following a rollback, the database file should be back in its original + ** state prior to the start of the transaction, so invoke the + ** SQLITE_FCNTL_DB_UNCHANGED file-control method to disable the + ** assertion that the transaction counter was modified. + */ + sqlite3_int64 iDummy = 0; + Debug.Assert( + pPager.fd.pMethods == null || + sqlite3OsFileControl(pPager.fd, SQLITE_FCNTL_DB_UNCHANGED, ref iDummy) >= SQLITE_OK + ); + + /* If this playback is happening automatically as a result of an IO or + ** malloc error that occurred after the change-counter was updated but + ** before the transaction was committed, then the change-counter + ** modification may just have been reverted. If this happens in exclusive + ** mode, then subsequent transactions performed by the connection will not + ** update the change-counter at all. This may lead to cache inconsistency + ** problems for other processes at some point in the future. So, just + ** in case this has happened, clear the changeCountDone flag now. + */ + pPager.changeCountDone = pPager.tempFile; + + if (rc == SQLITE_OK) { + zMaster = new byte[pPager.pVfs.mxPathname + 1];//pPager.pTmpSpace ); + rc = readMasterJournal(pPager.jfd, zMaster, (u32)pPager.pVfs.mxPathname + 1); + testcase(rc != SQLITE_OK); + } + if (rc == SQLITE_OK + && (pPager.eState >= PAGER_WRITER_DBMOD || pPager.eState == PAGER_OPEN) + ) { + rc = sqlite3PagerSync(pPager); + } + if (rc == SQLITE_OK) { + rc = pager_end_transaction(pPager, zMaster[0] != '\0' ? 1 : 0); + testcase(rc != SQLITE_OK); + } + if (rc == SQLITE_OK && zMaster[0] != '\0' && res != 0) { + /* If there was a master journal and this routine will return success, + ** see if it is possible to delete the master journal. + */ + rc = pager_delmaster(pPager, Encoding.UTF8.GetString(zMaster, 0, zMaster.Length)); + testcase(rc != SQLITE_OK); + } + + /* The Pager.sectorSize variable may have been updated while rolling + ** back a journal created by a process with a different sector size + ** value. Reset it to the correct value for this process. + */ + setSectorSize(pPager); + return rc; + } - Debug.Assert( pPager.eState >= PAGER_READER && + + /* + ** Read the content for page pPg out of the database file and into + ** pPg.pData. A shared lock or greater must be held on the database + ** file before this function is called. + ** + ** If page 1 is read, then the value of Pager.dbFileVers[] is set to + ** the value read from the database file. + ** + ** If an IO error occurs, then the IO error is returned to the caller. + ** Otherwise, SQLITE_OK is returned. + */ + static int readDbPage(PgHdr pPg) { + Pager pPager = pPg.pPager; /* Pager object associated with page pPg */ + Pgno pgno = pPg.pgno; /* Page number to read */ + int rc = SQLITE_OK; /* Return code */ + int isInWal = 0; /* True if page is in log file */ + int pgsz = pPager.pageSize; /* Number of bytes to read */ + + Debug.Assert(pPager.eState >= PAGER_READER && #if SQLITE_OMIT_MEMORYDB 0 == MEMDB #else - 0 == pPager.memDb + 0 == pPager.memDb #endif - ); - Debug.Assert( isOpen( pPager.fd ) ); - - if ( NEVER( !isOpen( pPager.fd ) ) ) - { - Debug.Assert( pPager.tempFile ); - Array.Clear( pPg.pData, 0, pPager.pageSize );// memset(pPg.pData, 0, pPager.pageSize); - return SQLITE_OK; - } + ); + Debug.Assert(isOpen(pPager.fd)); - if ( pagerUseWal( pPager ) ) - { - /* Try to pull the page from the write-ahead log. */ - rc = sqlite3WalRead( pPager.pWal, pgno, ref isInWal, pgsz, pPg.pData ); - } - if ( rc == SQLITE_OK && 0 == isInWal ) - { - i64 iOffset = ( pgno - 1 ) * (i64)pPager.pageSize; - rc = sqlite3OsRead( pPager.fd, pPg.pData, pgsz, iOffset ); - if ( rc == SQLITE_IOERR_SHORT_READ ) - { - rc = SQLITE_OK; - } - } + if (NEVER(!isOpen(pPager.fd))) { + Debug.Assert(pPager.tempFile); + Array.Clear(pPg.pData, 0, pPager.pageSize);// memset(pPg.pData, 0, pPager.pageSize); + return SQLITE_OK; + } - if ( pgno == 1 ) - { - if ( rc != 0 ) - { - /* If the read is unsuccessful, set the dbFileVers[] to something - ** that will never be a valid file version. dbFileVers[] is a copy - ** of bytes 24..39 of the database. Bytes 28..31 should always be - ** zero or the size of the database in page. Bytes 32..35 and 35..39 - ** should be page numbers which are never 0xffffffff. So filling - ** pPager.dbFileVers[] with all 0xff bytes should suffice. - ** - ** For an encrypted database, the situation is more complex: bytes - ** 24..39 of the database are white noise. But the probability of - ** white noising equaling 16 bytes of 0xff is vanishingly small so - ** we should still be ok. - */ - for ( int i = 0; i < pPager.dbFileVers.Length; pPager.dbFileVers[i++] = 0xff ) - ; // memset(pPager.dbFileVers, 0xff, sizeof(pPager.dbFileVers)); - } - else - { - //u8[] dbFileVers = pPg.pData[24]; - Buffer.BlockCopy( pPg.pData, 24, pPager.dbFileVers, 0, pPager.dbFileVers.Length ); //memcpy(&pPager.dbFileVers, dbFileVers, sizeof(pPager.dbFileVers)); - } - } - if ( CODEC1( pPager, pPg.pData, pgno, SQLITE_DECRYPT ) ) - rc = SQLITE_NOMEM;//CODEC1(pPager, pPg.pData, pgno, 3, rc = SQLITE_NOMEM); + if (pagerUseWal(pPager)) { + /* Try to pull the page from the write-ahead log. */ + rc = sqlite3WalRead(pPager.pWal, pgno, ref isInWal, pgsz, pPg.pData); + } + if (rc == SQLITE_OK && 0 == isInWal) { + i64 iOffset = (pgno - 1) * (i64)pPager.pageSize; + rc = sqlite3OsRead(pPager.fd, pPg.pData, pgsz, iOffset); + if (rc == SQLITE_IOERR_SHORT_READ) { + rc = SQLITE_OK; + } + } + + if (pgno == 1) { + if (rc != 0) { + /* If the read is unsuccessful, set the dbFileVers[] to something + ** that will never be a valid file version. dbFileVers[] is a copy + ** of bytes 24..39 of the database. Bytes 28..31 should always be + ** zero or the size of the database in page. Bytes 32..35 and 35..39 + ** should be page numbers which are never 0xffffffff. So filling + ** pPager.dbFileVers[] with all 0xff bytes should suffice. + ** + ** For an encrypted database, the situation is more complex: bytes + ** 24..39 of the database are white noise. But the probability of + ** white noising equaling 16 bytes of 0xff is vanishingly small so + ** we should still be ok. + */ + for (int i = 0; i < pPager.dbFileVers.Length; pPager.dbFileVers[i++] = 0xff) + ; // memset(pPager.dbFileVers, 0xff, sizeof(pPager.dbFileVers)); + } else { + //u8[] dbFileVers = pPg.pData[24]; + Buffer.BlockCopy(pPg.pData, 24, pPager.dbFileVers, 0, pPager.dbFileVers.Length); //memcpy(&pPager.dbFileVers, dbFileVers, sizeof(pPager.dbFileVers)); + } + } + if (CODEC1(pPager, pPg.pData, pgno, SQLITE_DECRYPT)) + rc = SQLITE_NOMEM;//CODEC1(pPager, pPg.pData, pgno, 3, rc = SQLITE_NOMEM); #if SQLITE_TEST // PAGER_INCR(ref sqlite3_pager_readdb_count); @@ -3277,35 +3090,34 @@ static int readDbPage( PgHdr pPg ) PAGER_INCR( ref pPager.nRead ); #endif - IOTRACE( "PGIN %p %d\n", pPager, pgno ); - PAGERTRACE( "FETCH %d page %d hash(%08x)\n", - PAGERID( pPager ), pgno, pager_pagehash( pPg ) ); - - return rc; - } - - /* - ** Update the value of the change-counter at offsets 24 and 92 in - ** the header and the sqlite version number at offset 96. - ** - ** This is an unconditional update. See also the pager_incr_changecounter() - ** routine which only updates the change-counter if the update is actually - ** needed, as determined by the pPager.changeCountDone state variable. - */ - static void pager_write_changecounter( PgHdr pPg ) - { - u32 change_counter; + IOTRACE("PGIN %p %d\n", pPager, pgno); + PAGERTRACE("FETCH %d page %d hash(%08x)\n", + PAGERID(pPager), pgno, pager_pagehash(pPg)); - /* Increment the value just read and write it back to byte 24. */ - change_counter = sqlite3Get4byte( pPg.pPager.dbFileVers, 0 ) + 1; - put32bits( pPg.pData, 24, change_counter ); + return rc; + } - /* Also store the SQLite version number in bytes 96..99 and in - ** bytes 92..95 store the change counter for which the version number - ** is valid. */ - put32bits( pPg.pData, 92, change_counter ); - put32bits( pPg.pData, 96, SQLITE_VERSION_NUMBER ); - } + /* + ** Update the value of the change-counter at offsets 24 and 92 in + ** the header and the sqlite version number at offset 96. + ** + ** This is an unconditional update. See also the pager_incr_changecounter() + ** routine which only updates the change-counter if the update is actually + ** needed, as determined by the pPager.changeCountDone state variable. + */ + static void pager_write_changecounter(PgHdr pPg) { + u32 change_counter; + + /* Increment the value just read and write it back to byte 24. */ + change_counter = sqlite3Get4byte(pPg.pPager.dbFileVers, 0) + 1; + put32bits(pPg.pData, 24, change_counter); + + /* Also store the SQLite version number in bytes 96..99 and in + ** bytes 92..95 store the change counter for which the version number + ** is valid. */ + put32bits(pPg.pData, 92, change_counter); + put32bits(pPg.pData, 96, SQLITE_VERSION_NUMBER); + } #if !SQLITE_OMIT_WAL /* @@ -3473,66 +3285,60 @@ static int pagerBeginReadTransaction(Pager *pPager){ } #endif - /* - ** This function is called as part of the transition from PAGER_OPEN - ** to PAGER_READER state to determine the size of the database file - ** in pages (assuming the page size currently stored in Pager.pageSize). - ** - ** If no error occurs, SQLITE_OK is returned and the size of the database - ** in pages is stored in *pnPage. Otherwise, an error code (perhaps - ** SQLITE_IOERR_FSTAT) is returned and *pnPage is left unmodified. - */ - static int pagerPagecount( Pager pPager, ref Pgno pnPage ) - { - Pgno nPage; /* Value to return via *pnPage */ - - /* Query the WAL sub-system for the database size. The WalDbsize() - ** function returns zero if the WAL is not open (i.e. Pager.pWal==0), or - ** if the database size is not available. The database size is not - ** available from the WAL sub-system if the log file is empty or - ** contains no valid committed transactions. - */ - Debug.Assert( pPager.eState == PAGER_OPEN ); - Debug.Assert( pPager.eLock >= SHARED_LOCK || pPager.noReadlock != 0 ); - nPage = sqlite3WalDbsize( pPager.pWal ); - - /* If the database size was not available from the WAL sub-system, - ** determine it based on the size of the database file. If the size - ** of the database file is not an integer multiple of the page-size, - ** round down to the nearest page. Except, any file larger than 0 - ** bytes in size is considered to contain at least one page. - */ - if ( nPage == 0 ) - { - i64 n = 0; /* Size of db file in bytes */ - Debug.Assert( isOpen( pPager.fd ) || pPager.tempFile ); - if ( isOpen( pPager.fd ) ) - { - int rc = sqlite3OsFileSize( pPager.fd, ref n ); - if ( rc != SQLITE_OK ) - { - return rc; - } - } - nPage = (Pgno)( n / pPager.pageSize ); - if ( nPage == 0 && n > 0 ) - { - nPage = 1; - } - } + /* + ** This function is called as part of the transition from PAGER_OPEN + ** to PAGER_READER state to determine the size of the database file + ** in pages (assuming the page size currently stored in Pager.pageSize). + ** + ** If no error occurs, SQLITE_OK is returned and the size of the database + ** in pages is stored in *pnPage. Otherwise, an error code (perhaps + ** SQLITE_IOERR_FSTAT) is returned and *pnPage is left unmodified. + */ + static int pagerPagecount(Pager pPager, ref Pgno pnPage) { + Pgno nPage; /* Value to return via *pnPage */ + + /* Query the WAL sub-system for the database size. The WalDbsize() + ** function returns zero if the WAL is not open (i.e. Pager.pWal==0), or + ** if the database size is not available. The database size is not + ** available from the WAL sub-system if the log file is empty or + ** contains no valid committed transactions. + */ + Debug.Assert(pPager.eState == PAGER_OPEN); + Debug.Assert(pPager.eLock >= SHARED_LOCK || pPager.noReadlock != 0); + nPage = sqlite3WalDbsize(pPager.pWal); + + /* If the database size was not available from the WAL sub-system, + ** determine it based on the size of the database file. If the size + ** of the database file is not an integer multiple of the page-size, + ** round down to the nearest page. Except, any file larger than 0 + ** bytes in size is considered to contain at least one page. + */ + if (nPage == 0) { + i64 n = 0; /* Size of db file in bytes */ + Debug.Assert(isOpen(pPager.fd) || pPager.tempFile); + if (isOpen(pPager.fd)) { + int rc = sqlite3OsFileSize(pPager.fd, ref n); + if (rc != SQLITE_OK) { + return rc; + } + } + nPage = (Pgno)(n / pPager.pageSize); + if (nPage == 0 && n > 0) { + nPage = 1; + } + } - /* If the current number of pages in the file is greater than the - ** configured maximum pager number, increase the allowed limit so - ** that the file can be read. - */ - if ( nPage > pPager.mxPgno ) - { - pPager.mxPgno = (Pgno)nPage; - } + /* If the current number of pages in the file is greater than the + ** configured maximum pager number, increase the allowed limit so + ** that the file can be read. + */ + if (nPage > pPager.mxPgno) { + pPager.mxPgno = (Pgno)nPage; + } - pnPage = nPage; - return SQLITE_OK; - } + pnPage = nPage; + return SQLITE_OK; + } #if !SQLITE_OMIT_WAL @@ -3586,255 +3392,232 @@ static int pagerOpenWalIfPresent(Pager *pPager){ } #endif - /* -** Playback savepoint pSavepoint. Or, if pSavepoint==NULL, then playback -** the entire master journal file. The case pSavepoint==NULL occurs when -** a ROLLBACK TO command is invoked on a SAVEPOINT that is a transaction -** savepoint. -** -** When pSavepoint is not NULL (meaning a non-transaction savepoint is -** being rolled back), then the rollback consists of up to three stages, -** performed in the order specified: -** -** * Pages are played back from the main journal starting at byte -** offset PagerSavepoint.iOffset and continuing to -** PagerSavepoint.iHdrOffset, or to the end of the main journal -** file if PagerSavepoint.iHdrOffset is zero. -** -** * If PagerSavepoint.iHdrOffset is not zero, then pages are played -** back starting from the journal header immediately following -** PagerSavepoint.iHdrOffset to the end of the main journal file. -** -** * Pages are then played back from the sub-journal file, starting -** with the PagerSavepoint.iSubRec and continuing to the end of -** the journal file. -** -** Throughout the rollback process, each time a page is rolled back, the -** corresponding bit is set in a bitvec structure (variable pDone in the -** implementation below). This is used to ensure that a page is only -** rolled back the first time it is encountered in either journal. -** -** If pSavepoint is NULL, then pages are only played back from the main -** journal file. There is no need for a bitvec in this case. -** -** In either case, before playback commences the Pager.dbSize variable -** is reset to the value that it held at the start of the savepoint -** (or transaction). No page with a page-number greater than this value -** is played back. If one is encountered it is simply skipped. -*/ - static int pagerPlaybackSavepoint( Pager pPager, PagerSavepoint pSavepoint ) - { - i64 szJ; /* Effective size of the main journal */ - i64 iHdrOff; /* End of first segment of main-journal records */ - int rc = SQLITE_OK; /* Return code */ - Bitvec pDone = null; /* Bitvec to ensure pages played back only once */ + /* + ** Playback savepoint pSavepoint. Or, if pSavepoint==NULL, then playback + ** the entire master journal file. The case pSavepoint==NULL occurs when + ** a ROLLBACK TO command is invoked on a SAVEPOINT that is a transaction + ** savepoint. + ** + ** When pSavepoint is not NULL (meaning a non-transaction savepoint is + ** being rolled back), then the rollback consists of up to three stages, + ** performed in the order specified: + ** + ** * Pages are played back from the main journal starting at byte + ** offset PagerSavepoint.iOffset and continuing to + ** PagerSavepoint.iHdrOffset, or to the end of the main journal + ** file if PagerSavepoint.iHdrOffset is zero. + ** + ** * If PagerSavepoint.iHdrOffset is not zero, then pages are played + ** back starting from the journal header immediately following + ** PagerSavepoint.iHdrOffset to the end of the main journal file. + ** + ** * Pages are then played back from the sub-journal file, starting + ** with the PagerSavepoint.iSubRec and continuing to the end of + ** the journal file. + ** + ** Throughout the rollback process, each time a page is rolled back, the + ** corresponding bit is set in a bitvec structure (variable pDone in the + ** implementation below). This is used to ensure that a page is only + ** rolled back the first time it is encountered in either journal. + ** + ** If pSavepoint is NULL, then pages are only played back from the main + ** journal file. There is no need for a bitvec in this case. + ** + ** In either case, before playback commences the Pager.dbSize variable + ** is reset to the value that it held at the start of the savepoint + ** (or transaction). No page with a page-number greater than this value + ** is played back. If one is encountered it is simply skipped. + */ + static int pagerPlaybackSavepoint(Pager pPager, PagerSavepoint pSavepoint) { + i64 szJ; /* Effective size of the main journal */ + i64 iHdrOff; /* End of first segment of main-journal records */ + int rc = SQLITE_OK; /* Return code */ + Bitvec pDone = null; /* Bitvec to ensure pages played back only once */ + + Debug.Assert(pPager.eState != PAGER_ERROR); + Debug.Assert(pPager.eState >= PAGER_WRITER_LOCKED); + + + /* Allocate a bitvec to use to store the set of pages rolled back */ + if (pSavepoint != null) { + pDone = sqlite3BitvecCreate(pSavepoint.nOrig); + //if ( null == pDone ) + //{ + // return SQLITE_NOMEM; + //} + } - Debug.Assert( pPager.eState != PAGER_ERROR ); - Debug.Assert( pPager.eState >= PAGER_WRITER_LOCKED ); + /* Set the database size back to the value it was before the savepoint + ** being reverted was opened. + */ + pPager.dbSize = pSavepoint != null ? pSavepoint.nOrig : pPager.dbOrigSize; + pPager.changeCountDone = pPager.tempFile; + if (!pSavepoint && pagerUseWal(pPager)) { + return pagerRollbackWal(pPager); + } - /* Allocate a bitvec to use to store the set of pages rolled back */ - if ( pSavepoint != null ) - { - pDone = sqlite3BitvecCreate( pSavepoint.nOrig ); - //if ( null == pDone ) - //{ - // return SQLITE_NOMEM; - //} - } + /* Use pPager.journalOff as the effective size of the main rollback + ** journal. The actual file might be larger than this in + ** PAGER_JOURNALMODE_TRUNCATE or PAGER_JOURNALMODE_PERSIST. But anything + ** past pPager.journalOff is off-limits to us. + */ + szJ = pPager.journalOff; + Debug.Assert(pagerUseWal(pPager) == false || szJ == 0); + + /* Begin by rolling back records from the main journal starting at + ** PagerSavepoint.iOffset and continuing to the next journal header. + ** There might be records in the main journal that have a page number + ** greater than the current database size (pPager.dbSize) but those + ** will be skipped automatically. Pages are added to pDone as they + ** are played back. + */ + if (pSavepoint != null && !pagerUseWal(pPager)) { + iHdrOff = pSavepoint.iHdrOffset != 0 ? pSavepoint.iHdrOffset : szJ; + pPager.journalOff = pSavepoint.iOffset; + while (rc == SQLITE_OK && pPager.journalOff < iHdrOff) { + rc = pager_playback_one_page(pPager, ref pPager.journalOff, pDone, 1, 1); + } + Debug.Assert(rc != SQLITE_DONE); + } else { + pPager.journalOff = 0; + } - /* Set the database size back to the value it was before the savepoint - ** being reverted was opened. - */ - pPager.dbSize = pSavepoint != null ? pSavepoint.nOrig : pPager.dbOrigSize; - pPager.changeCountDone = pPager.tempFile; + /* Continue rolling back records out of the main journal starting at + ** the first journal header seen and continuing until the effective end + ** of the main journal file. Continue to skip out-of-range pages and + ** continue adding pages rolled back to pDone. + */ + while (rc == SQLITE_OK && pPager.journalOff < szJ) { + u32 ii; /* Loop counter */ + u32 nJRec; /* Number of Journal Records */ + u32 dummy; + rc = readJournalHdr(pPager, 0, (int)szJ, out nJRec, out dummy); + Debug.Assert(rc != SQLITE_DONE); + + /* + ** The "pPager.journalHdr+JOURNAL_HDR_SZ(pPager)==pPager.journalOff" + ** test is related to ticket #2565. See the discussion in the + ** pager_playback() function for additional information. + */ + if (nJRec == 0 + && pPager.journalHdr + JOURNAL_HDR_SZ(pPager) >= pPager.journalOff + ) { + nJRec = (u32)((szJ - pPager.journalOff) / JOURNAL_PG_SZ(pPager)); + } + for (ii = 0; rc == SQLITE_OK && ii < nJRec && pPager.journalOff < szJ; ii++) { + rc = pager_playback_one_page(pPager, ref pPager.journalOff, pDone, 1, 1); + } + Debug.Assert(rc != SQLITE_DONE); + } + Debug.Assert(rc != SQLITE_OK || pPager.journalOff >= szJ); - if ( !pSavepoint && pagerUseWal( pPager ) ) - { - return pagerRollbackWal( pPager ); - } + /* Finally, rollback pages from the sub-journal. Page that were + ** previously rolled back out of the main journal (and are hence in pDone) + ** will be skipped. Out-of-range pages are also skipped. + */ + if (pSavepoint != null) { + u32 ii; /* Loop counter */ + i64 offset = pSavepoint.iSubRec * (4 + pPager.pageSize); + if (pagerUseWal(pPager)) { + rc = sqlite3WalSavepointUndo(pPager.pWal, pSavepoint.aWalData); + } + for (ii = pSavepoint.iSubRec; rc == SQLITE_OK && ii < pPager.nSubRec; ii++) { + Debug.Assert(offset == ii * (4 + pPager.pageSize)); + rc = pager_playback_one_page(pPager, ref offset, pDone, 0, 1); + } + Debug.Assert(rc != SQLITE_DONE); + } - /* Use pPager.journalOff as the effective size of the main rollback - ** journal. The actual file might be larger than this in - ** PAGER_JOURNALMODE_TRUNCATE or PAGER_JOURNALMODE_PERSIST. But anything - ** past pPager.journalOff is off-limits to us. - */ - szJ = pPager.journalOff; - Debug.Assert( pagerUseWal( pPager ) == false || szJ == 0 ); - - /* Begin by rolling back records from the main journal starting at - ** PagerSavepoint.iOffset and continuing to the next journal header. - ** There might be records in the main journal that have a page number - ** greater than the current database size (pPager.dbSize) but those - ** will be skipped automatically. Pages are added to pDone as they - ** are played back. - */ - if ( pSavepoint != null && !pagerUseWal( pPager ) ) - { - iHdrOff = pSavepoint.iHdrOffset != 0 ? pSavepoint.iHdrOffset : szJ; - pPager.journalOff = pSavepoint.iOffset; - while ( rc == SQLITE_OK && pPager.journalOff < iHdrOff ) - { - rc = pager_playback_one_page( pPager, ref pPager.journalOff, pDone, 1, 1 ); + sqlite3BitvecDestroy(ref pDone); + if (rc == SQLITE_OK) { + pPager.journalOff = (int)szJ; + } + return rc; } - Debug.Assert( rc != SQLITE_DONE ); - } - else - { - pPager.journalOff = 0; - } - - /* Continue rolling back records out of the main journal starting at - ** the first journal header seen and continuing until the effective end - ** of the main journal file. Continue to skip out-of-range pages and - ** continue adding pages rolled back to pDone. - */ - while ( rc == SQLITE_OK && pPager.journalOff < szJ ) - { - u32 ii; /* Loop counter */ - u32 nJRec; /* Number of Journal Records */ - u32 dummy; - rc = readJournalHdr( pPager, 0, (int)szJ, out nJRec, out dummy ); - Debug.Assert( rc != SQLITE_DONE ); /* - ** The "pPager.journalHdr+JOURNAL_HDR_SZ(pPager)==pPager.journalOff" - ** test is related to ticket #2565. See the discussion in the - ** pager_playback() function for additional information. + ** Change the maximum number of in-memory pages that are allowed. */ - if ( nJRec == 0 - && pPager.journalHdr + JOURNAL_HDR_SZ( pPager ) >= pPager.journalOff - ) - { - nJRec = (u32)( ( szJ - pPager.journalOff ) / JOURNAL_PG_SZ( pPager ) ); - } - for ( ii = 0; rc == SQLITE_OK && ii < nJRec && pPager.journalOff < szJ; ii++ ) - { - rc = pager_playback_one_page( pPager, ref pPager.journalOff, pDone, 1, 1 ); - } - Debug.Assert( rc != SQLITE_DONE ); - } - Debug.Assert( rc != SQLITE_OK || pPager.journalOff >= szJ ); - - /* Finally, rollback pages from the sub-journal. Page that were - ** previously rolled back out of the main journal (and are hence in pDone) - ** will be skipped. Out-of-range pages are also skipped. - */ - if ( pSavepoint != null ) - { - u32 ii; /* Loop counter */ - i64 offset = pSavepoint.iSubRec * ( 4 + pPager.pageSize ); - if ( pagerUseWal( pPager ) ) - { - rc = sqlite3WalSavepointUndo( pPager.pWal, pSavepoint.aWalData ); - } - for ( ii = pSavepoint.iSubRec; rc == SQLITE_OK && ii < pPager.nSubRec; ii++ ) - { - Debug.Assert( offset == ii * ( 4 + pPager.pageSize ) ); - rc = pager_playback_one_page( pPager, ref offset, pDone, 0, 1 ); + static void sqlite3PagerSetCachesize(Pager pPager, int mxPage) { + sqlite3PcacheSetCachesize(pPager.pPCache, mxPage); } - Debug.Assert( rc != SQLITE_DONE ); - } - - sqlite3BitvecDestroy( ref pDone ); - if ( rc == SQLITE_OK ) - { - pPager.journalOff = (int)szJ; - } - return rc; - } - - /* - ** Change the maximum number of in-memory pages that are allowed. - */ - static void sqlite3PagerSetCachesize( Pager pPager, int mxPage ) - { - sqlite3PcacheSetCachesize( pPager.pPCache, mxPage ); - } - /* - ** Adjust the robustness of the database to damage due to OS crashes - ** or power failures by changing the number of syncs()s when writing - ** the rollback journal. There are three levels: - ** - ** OFF sqlite3OsSync() is never called. This is the default - ** for temporary and transient files. - ** - ** NORMAL The journal is synced once before writes begin on the - ** database. This is normally adequate protection, but - ** it is theoretically possible, though very unlikely, - ** that an inopertune power failure could leave the journal - ** in a state which would cause damage to the database - ** when it is rolled back. - ** - ** FULL The journal is synced twice before writes begin on the - ** database (with some additional information - the nRec field - ** of the journal header - being written in between the two - ** syncs). If we assume that writing a - ** single disk sector is atomic, then this mode provides - ** assurance that the journal will not be corrupted to the - ** point of causing damage to the database during rollback. - ** - ** The above is for a rollback-journal mode. For WAL mode, OFF continues - ** to mean that no syncs ever occur. NORMAL means that the WAL is synced - ** prior to the start of checkpoint and that the database file is synced - ** at the conclusion of the checkpoint if the entire content of the WAL - ** was written back into the database. But no sync operations occur for - ** an ordinary commit in NORMAL mode with WAL. FULL means that the WAL - ** file is synced following each commit operation, in addition to the - ** syncs associated with NORMAL. - ** - ** Do not confuse synchronous=FULL with SQLITE_SYNC_FULL. The - ** SQLITE_SYNC_FULL macro means to use the MacOSX-style full-fsync - ** using fcntl(F_FULLFSYNC). SQLITE_SYNC_NORMAL means to do an - ** ordinary fsync() call. There is no difference between SQLITE_SYNC_FULL - ** and SQLITE_SYNC_NORMAL on platforms other than MacOSX. But the - ** synchronous=FULL versus synchronous=NORMAL setting determines when - ** the xSync primitive is called and is relevant to all platforms. - ** - ** Numeric values associated with these states are OFF==1, NORMAL=2, - ** and FULL=3. - */ + /* + ** Adjust the robustness of the database to damage due to OS crashes + ** or power failures by changing the number of syncs()s when writing + ** the rollback journal. There are three levels: + ** + ** OFF sqlite3OsSync() is never called. This is the default + ** for temporary and transient files. + ** + ** NORMAL The journal is synced once before writes begin on the + ** database. This is normally adequate protection, but + ** it is theoretically possible, though very unlikely, + ** that an inopertune power failure could leave the journal + ** in a state which would cause damage to the database + ** when it is rolled back. + ** + ** FULL The journal is synced twice before writes begin on the + ** database (with some additional information - the nRec field + ** of the journal header - being written in between the two + ** syncs). If we assume that writing a + ** single disk sector is atomic, then this mode provides + ** assurance that the journal will not be corrupted to the + ** point of causing damage to the database during rollback. + ** + ** The above is for a rollback-journal mode. For WAL mode, OFF continues + ** to mean that no syncs ever occur. NORMAL means that the WAL is synced + ** prior to the start of checkpoint and that the database file is synced + ** at the conclusion of the checkpoint if the entire content of the WAL + ** was written back into the database. But no sync operations occur for + ** an ordinary commit in NORMAL mode with WAL. FULL means that the WAL + ** file is synced following each commit operation, in addition to the + ** syncs associated with NORMAL. + ** + ** Do not confuse synchronous=FULL with SQLITE_SYNC_FULL. The + ** SQLITE_SYNC_FULL macro means to use the MacOSX-style full-fsync + ** using fcntl(F_FULLFSYNC). SQLITE_SYNC_NORMAL means to do an + ** ordinary fsync() call. There is no difference between SQLITE_SYNC_FULL + ** and SQLITE_SYNC_NORMAL on platforms other than MacOSX. But the + ** synchronous=FULL versus synchronous=NORMAL setting determines when + ** the xSync primitive is called and is relevant to all platforms. + ** + ** Numeric values associated with these states are OFF==1, NORMAL=2, + ** and FULL=3. + */ #if !SQLITE_OMIT_PAGER_PRAGMAS - static void sqlite3PagerSetSafetyLevel( - Pager pPager, /* The pager to set safety level for */ - int level, /* PRAGMA synchronous. 1=OFF, 2=NORMAL, 3=FULL */ - int bFullFsync, /* PRAGMA fullfsync */ - int bCkptFullFsync /* PRAGMA checkpoint_fullfsync */ - ) - { - Debug.Assert( level >= 1 && level <= 3 ); - - pPager.noSync = ( level == 1 || pPager.tempFile ); - pPager.fullSync = ( level == 3 && !pPager.tempFile ); - if ( pPager.noSync ) - { - pPager.syncFlags = 0; - pPager.ckptSyncFlags = 0; - } - else if ( bFullFsync != 0 ) - { - pPager.syncFlags = SQLITE_SYNC_FULL; - pPager.ckptSyncFlags = SQLITE_SYNC_FULL; - } - else if ( bCkptFullFsync != 0 ) - { - pPager.syncFlags = SQLITE_SYNC_NORMAL; - pPager.ckptSyncFlags = SQLITE_SYNC_FULL; - } - else - { - pPager.syncFlags = SQLITE_SYNC_NORMAL; - pPager.ckptSyncFlags = SQLITE_SYNC_NORMAL; - } - } + static void sqlite3PagerSetSafetyLevel( + Pager pPager, /* The pager to set safety level for */ + int level, /* PRAGMA synchronous. 1=OFF, 2=NORMAL, 3=FULL */ + int bFullFsync, /* PRAGMA fullfsync */ + int bCkptFullFsync /* PRAGMA checkpoint_fullfsync */ + ) { + Debug.Assert(level >= 1 && level <= 3); + + pPager.noSync = (level == 1 || pPager.tempFile); + pPager.fullSync = (level == 3 && !pPager.tempFile); + if (pPager.noSync) { + pPager.syncFlags = 0; + pPager.ckptSyncFlags = 0; + } else if (bFullFsync != 0) { + pPager.syncFlags = SQLITE_SYNC_FULL; + pPager.ckptSyncFlags = SQLITE_SYNC_FULL; + } else if (bCkptFullFsync != 0) { + pPager.syncFlags = SQLITE_SYNC_NORMAL; + pPager.ckptSyncFlags = SQLITE_SYNC_FULL; + } else { + pPager.syncFlags = SQLITE_SYNC_NORMAL; + pPager.ckptSyncFlags = SQLITE_SYNC_NORMAL; + } + } #endif -/* -** The following global variable is incremented whenever the library -** attempts to open a temporary file. This information is used for -** testing and analysis only. -*/ + /* + ** The following global variable is incremented whenever the library + ** attempts to open a temporary file. This information is used for + ** testing and analysis only. + */ #if SQLITE_TEST #if !TCLSH static int sqlite3_opentemp_count = 0; @@ -3843,28 +3626,27 @@ int bCkptFullFsync /* PRAGMA checkpoint_fullfsync */ #endif #endif - /* -** Open a temporary file. -** -** Write the file descriptor into *pFile. Return SQLITE_OK on success -** or some other error code if we fail. The OS will automatically -** delete the temporary file when it is closed. -** -** The flags passed to the VFS layer xOpen() call are those specified -** by parameter vfsFlags ORed with the following: -** -** SQLITE_OPEN_READWRITE -** SQLITE_OPEN_CREATE -** SQLITE_OPEN_EXCLUSIVE -** SQLITE_OPEN_DELETEONCLOSE -*/ - static int pagerOpentemp( - Pager pPager, /* The pager object */ - ref sqlite3_file pFile, /* Write the file descriptor here */ - int vfsFlags /* Flags passed through to the VFS */ - ) - { - int rc; /* Return code */ + /* + ** Open a temporary file. + ** + ** Write the file descriptor into *pFile. Return SQLITE_OK on success + ** or some other error code if we fail. The OS will automatically + ** delete the temporary file when it is closed. + ** + ** The flags passed to the VFS layer xOpen() call are those specified + ** by parameter vfsFlags ORed with the following: + ** + ** SQLITE_OPEN_READWRITE + ** SQLITE_OPEN_CREATE + ** SQLITE_OPEN_EXCLUSIVE + ** SQLITE_OPEN_DELETEONCLOSE + */ + static int pagerOpentemp( + Pager pPager, /* The pager object */ + ref sqlite3_file pFile, /* Write the file descriptor here */ + int vfsFlags /* Flags passed through to the VFS */ + ) { + int rc; /* Return code */ #if SQLITE_TEST #if !TCLSH @@ -3874,172 +3656,163 @@ int vfsFlags /* Flags passed through to the VFS */ #endif #endif - vfsFlags |= SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | - SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE; - int dummy = 0; - rc = sqlite3OsOpen( pPager.pVfs, null, pFile, vfsFlags, ref dummy ); - Debug.Assert( rc != SQLITE_OK || isOpen( pFile ) ); - return rc; - } - - /* - ** Set the busy handler function. - ** - ** The pager invokes the busy-handler if sqlite3OsLock() returns - ** SQLITE_BUSY when trying to upgrade from no-lock to a SHARED lock, - ** or when trying to upgrade from a RESERVED lock to an EXCLUSIVE - ** lock. It does *not* invoke the busy handler when upgrading from - ** SHARED to RESERVED, or when upgrading from SHARED to EXCLUSIVE - ** (which occurs during hot-journal rollback). Summary: - ** - ** Transition | Invokes xBusyHandler - ** -------------------------------------------------------- - ** NO_LOCK . SHARED_LOCK | Yes - ** SHARED_LOCK . RESERVED_LOCK | No - ** SHARED_LOCK . EXCLUSIVE_LOCK | No - ** RESERVED_LOCK . EXCLUSIVE_LOCK | Yes - ** - ** If the busy-handler callback returns non-zero, the lock is - ** retried. If it returns zero, then the SQLITE_BUSY error is - ** returned to the caller of the pager API function. - */ + vfsFlags |= SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | + SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE; + int dummy = 0; + rc = sqlite3OsOpen(pPager.pVfs, null, pFile, vfsFlags, ref dummy); + Debug.Assert(rc != SQLITE_OK || isOpen(pFile)); + return rc; + } - static void sqlite3PagerSetBusyhandler( - Pager pPager, /* Pager object */ - dxBusyHandler xBusyHandler, /* Pointer to busy-handler function */ - //int (*xBusyHandler)(void *), - object pBusyHandlerArg /* Argument to pass to xBusyHandler */ - ) - { - pPager.xBusyHandler = xBusyHandler; - pPager.pBusyHandlerArg = pBusyHandlerArg; - } + /* + ** Set the busy handler function. + ** + ** The pager invokes the busy-handler if sqlite3OsLock() returns + ** SQLITE_BUSY when trying to upgrade from no-lock to a SHARED lock, + ** or when trying to upgrade from a RESERVED lock to an EXCLUSIVE + ** lock. It does *not* invoke the busy handler when upgrading from + ** SHARED to RESERVED, or when upgrading from SHARED to EXCLUSIVE + ** (which occurs during hot-journal rollback). Summary: + ** + ** Transition | Invokes xBusyHandler + ** -------------------------------------------------------- + ** NO_LOCK . SHARED_LOCK | Yes + ** SHARED_LOCK . RESERVED_LOCK | No + ** SHARED_LOCK . EXCLUSIVE_LOCK | No + ** RESERVED_LOCK . EXCLUSIVE_LOCK | Yes + ** + ** If the busy-handler callback returns non-zero, the lock is + ** retried. If it returns zero, then the SQLITE_BUSY error is + ** returned to the caller of the pager API function. + */ + static void sqlite3PagerSetBusyhandler( + Pager pPager, /* Pager object */ + dxBusyHandler xBusyHandler, /* Pointer to busy-handler function */ + //int (*xBusyHandler)(void *), + object pBusyHandlerArg /* Argument to pass to xBusyHandler */ + ) { + pPager.xBusyHandler = xBusyHandler; + pPager.pBusyHandlerArg = pBusyHandlerArg; + } - /* - ** Change the page size used by the Pager object. The new page size - ** is passed in *pPageSize. - ** - ** If the pager is in the error state when this function is called, it - ** is a no-op. The value returned is the error state error code (i.e. - ** one of SQLITE_IOERR, an SQLITE_IOERR_xxx sub-code or SQLITE_FULL). - ** - ** Otherwise, if all of the following are true: - ** - ** * the new page size (value of *pPageSize) is valid (a power - ** of two between 512 and SQLITE_MAX_PAGE_SIZE, inclusive), and - ** - ** * there are no outstanding page references, and - ** - ** * the database is either not an in-memory database or it is - ** an in-memory database that currently consists of zero pages. - ** - ** then the pager object page size is set to *pPageSize. - ** - ** If the page size is changed, then this function uses sqlite3PagerMalloc() - ** to obtain a new Pager.pTmpSpace buffer. If this allocation attempt - ** fails, SQLITE_NOMEM is returned and the page size remains unchanged. - ** In all other cases, SQLITE_OK is returned. - ** - ** If the page size is not changed, either because one of the enumerated - ** conditions above is not true, the pager was in error state when this - ** function was called, or because the memory allocation attempt failed, - ** then *pPageSize is set to the old, retained page size before returning. - */ - static int sqlite3PagerSetPagesize( Pager pPager, ref u32 pPageSize, int nReserve ) - { - int rc = SQLITE_OK; - /* It is not possible to do a full assert_pager_state() here, as this - ** function may be called from within PagerOpen(), before the state - ** of the Pager object is internally consistent. - ** - ** At one point this function returned an error if the pager was in - ** PAGER_ERROR state. But since PAGER_ERROR state guarantees that - ** there is at least one outstanding page reference, this function - ** is a no-op for that case anyhow. - */ - u32 pageSize = pPageSize; - Debug.Assert( pageSize == 0 || ( pageSize >= 512 && pageSize <= SQLITE_MAX_PAGE_SIZE ) ); - if ( ( pPager.memDb == 0 || pPager.dbSize == 0 ) - && sqlite3PcacheRefCount( pPager.pPCache ) == 0 - && pageSize != 0 && pageSize != (u32)pPager.pageSize - ) - { - //char *pNew = NULL; /* New temp space */ - i64 nByte = 0; + /* + ** Change the page size used by the Pager object. The new page size + ** is passed in *pPageSize. + ** + ** If the pager is in the error state when this function is called, it + ** is a no-op. The value returned is the error state error code (i.e. + ** one of SQLITE_IOERR, an SQLITE_IOERR_xxx sub-code or SQLITE_FULL). + ** + ** Otherwise, if all of the following are true: + ** + ** * the new page size (value of *pPageSize) is valid (a power + ** of two between 512 and SQLITE_MAX_PAGE_SIZE, inclusive), and + ** + ** * there are no outstanding page references, and + ** + ** * the database is either not an in-memory database or it is + ** an in-memory database that currently consists of zero pages. + ** + ** then the pager object page size is set to *pPageSize. + ** + ** If the page size is changed, then this function uses sqlite3PagerMalloc() + ** to obtain a new Pager.pTmpSpace buffer. If this allocation attempt + ** fails, SQLITE_NOMEM is returned and the page size remains unchanged. + ** In all other cases, SQLITE_OK is returned. + ** + ** If the page size is not changed, either because one of the enumerated + ** conditions above is not true, the pager was in error state when this + ** function was called, or because the memory allocation attempt failed, + ** then *pPageSize is set to the old, retained page size before returning. + */ + static int sqlite3PagerSetPagesize(Pager pPager, ref u32 pPageSize, int nReserve) { + int rc = SQLITE_OK; + /* It is not possible to do a full assert_pager_state() here, as this + ** function may be called from within PagerOpen(), before the state + ** of the Pager object is internally consistent. + ** + ** At one point this function returned an error if the pager was in + ** PAGER_ERROR state. But since PAGER_ERROR state guarantees that + ** there is at least one outstanding page reference, this function + ** is a no-op for that case anyhow. + */ - if ( pPager.eState > PAGER_OPEN && isOpen( pPager.fd ) ) - { - rc = sqlite3OsFileSize( pPager.fd, ref nByte ); - } - //if ( rc == SQLITE_OK ) - //{ - //pNew = (char *)sqlite3PageMalloc(pageSize); - //if( !pNew ) rc = SQLITE_NOMEM; - //} - if ( rc == SQLITE_OK ) - { - pager_reset( pPager ); - pPager.dbSize = (Pgno)( nByte / pageSize ); - pPager.pageSize = (int)pageSize; - sqlite3PageFree( ref pPager.pTmpSpace ); - - pPager.pTmpSpace = sqlite3Malloc( pageSize );// pNew; - sqlite3PcacheSetPageSize( pPager.pPCache, (int)pageSize ); + u32 pageSize = pPageSize; + Debug.Assert(pageSize == 0 || (pageSize >= 512 && pageSize <= SQLITE_MAX_PAGE_SIZE)); + if ((pPager.memDb == 0 || pPager.dbSize == 0) + && sqlite3PcacheRefCount(pPager.pPCache) == 0 + && pageSize != 0 && pageSize != (u32)pPager.pageSize + ) { + //char *pNew = NULL; /* New temp space */ + i64 nByte = 0; + + if (pPager.eState > PAGER_OPEN && isOpen(pPager.fd)) { + rc = sqlite3OsFileSize(pPager.fd, ref nByte); + } + //if ( rc == SQLITE_OK ) + //{ + //pNew = (char *)sqlite3PageMalloc(pageSize); + //if( !pNew ) rc = SQLITE_NOMEM; + //} + if (rc == SQLITE_OK) { + pager_reset(pPager); + pPager.dbSize = (Pgno)(nByte / pageSize); + pPager.pageSize = (int)pageSize; + sqlite3PageFree(ref pPager.pTmpSpace); + + pPager.pTmpSpace = sqlite3Malloc(pageSize);// pNew; + sqlite3PcacheSetPageSize(pPager.pPCache, (int)pageSize); + } + } + pPageSize = (u32)pPager.pageSize; + if (rc == SQLITE_OK) { + if (nReserve < 0) + nReserve = pPager.nReserve; + Debug.Assert(nReserve >= 0 && nReserve < 1000); + pPager.nReserve = (i16)nReserve; + pagerReportSize(pPager); + } + return rc; } - } - pPageSize = (u32)pPager.pageSize; - if ( rc == SQLITE_OK ) - { - if ( nReserve < 0 ) - nReserve = pPager.nReserve; - Debug.Assert( nReserve >= 0 && nReserve < 1000 ); - pPager.nReserve = (i16)nReserve; - pagerReportSize( pPager ); - } - return rc; - } - /* - ** Return a pointer to the "temporary page" buffer held internally - ** by the pager. This is a buffer that is big enough to hold the - ** entire content of a database page. This buffer is used internally - ** during rollback and will be overwritten whenever a rollback - ** occurs. But other modules are free to use it too, as long as - ** no rollbacks are happening. - */ - static byte[] sqlite3PagerTempSpace( Pager pPager ) - { - return pPager.pTmpSpace; - } + /* + ** Return a pointer to the "temporary page" buffer held internally + ** by the pager. This is a buffer that is big enough to hold the + ** entire content of a database page. This buffer is used internally + ** during rollback and will be overwritten whenever a rollback + ** occurs. But other modules are free to use it too, as long as + ** no rollbacks are happening. + */ + static byte[] sqlite3PagerTempSpace(Pager pPager) { + return pPager.pTmpSpace; + } - /* - ** Attempt to set the maximum database page count if mxPage is positive. - ** Make no changes if mxPage is zero or negative. And never reduce the - ** maximum page count below the current size of the database. - ** - ** Regardless of mxPage, return the current maximum page count. - */ - static Pgno sqlite3PagerMaxPageCount( Pager pPager, int mxPage ) - { - if ( mxPage > 0 ) - { - pPager.mxPgno = (Pgno)mxPage; - } - Debug.Assert( pPager.eState != PAGER_OPEN ); /* Called only by OP_MaxPgcnt */ - Debug.Assert( pPager.mxPgno >= pPager.dbSize ); /* OP_MaxPgcnt enforces this */ - return pPager.mxPgno; - } + /* + ** Attempt to set the maximum database page count if mxPage is positive. + ** Make no changes if mxPage is zero or negative. And never reduce the + ** maximum page count below the current size of the database. + ** + ** Regardless of mxPage, return the current maximum page count. + */ + static Pgno sqlite3PagerMaxPageCount(Pager pPager, int mxPage) { + if (mxPage > 0) { + pPager.mxPgno = (Pgno)mxPage; + } + Debug.Assert(pPager.eState != PAGER_OPEN); /* Called only by OP_MaxPgcnt */ + Debug.Assert(pPager.mxPgno >= pPager.dbSize); /* OP_MaxPgcnt enforces this */ + return pPager.mxPgno; + } - /* - ** The following set of routines are used to disable the simulated - ** I/O error mechanism. These routines are used to avoid simulated - ** errors in places where we do not care about errors. - ** - ** Unless -DSQLITE_TEST=1 is used, these routines are all no-ops - ** and generate no code. - */ + /* + ** The following set of routines are used to disable the simulated + ** I/O error mechanism. These routines are used to avoid simulated + ** errors in places where we do not care about errors. + ** + ** Unless -DSQLITE_TEST=1 is used, these routines are all no-ops + ** and generate no code. + */ #if SQLITE_TEST //extern int sqlite3_io_error_pending; //extern int sqlite3_io_error_hit; @@ -4064,542 +3837,506 @@ static void enable_simulated_io_errors() #endif } #else -//# define disable_simulated_io_errors() -//# define enable_simulated_io_errors() + //# define disable_simulated_io_errors() + //# define enable_simulated_io_errors() #endif - /* -** Read the first N bytes from the beginning of the file into memory -** that pDest points to. -** -** If the pager was opened on a transient file (zFilename==""), or -** opened on a file less than N bytes in size, the output buffer is -** zeroed and SQLITE_OK returned. The rationale for this is that this -** function is used to read database headers, and a new transient or -** zero sized database has a header than consists entirely of zeroes. -** -** If any IO error apart from SQLITE_IOERR_SHORT_READ is encountered, -** the error code is returned to the caller and the contents of the -** output buffer undefined. -*/ - static int sqlite3PagerReadFileheader( Pager pPager, int N, byte[] pDest ) - { - int rc = SQLITE_OK; - Array.Clear( pDest, 0, N ); //memset(pDest, 0, N); - Debug.Assert( isOpen( pPager.fd ) || pPager.tempFile ); + /* + ** Read the first N bytes from the beginning of the file into memory + ** that pDest points to. + ** + ** If the pager was opened on a transient file (zFilename==""), or + ** opened on a file less than N bytes in size, the output buffer is + ** zeroed and SQLITE_OK returned. The rationale for this is that this + ** function is used to read database headers, and a new transient or + ** zero sized database has a header than consists entirely of zeroes. + ** + ** If any IO error apart from SQLITE_IOERR_SHORT_READ is encountered, + ** the error code is returned to the caller and the contents of the + ** output buffer undefined. + */ + static int sqlite3PagerReadFileheader(Pager pPager, int N, byte[] pDest) { + int rc = SQLITE_OK; + Array.Clear(pDest, 0, N); //memset(pDest, 0, N); + Debug.Assert(isOpen(pPager.fd) || pPager.tempFile); - /* This routine is only called by btree immediately after creating - ** the Pager object. There has not been an opportunity to transition - ** to WAL mode yet. - */ - Debug.Assert( !pagerUseWal( pPager ) ); + /* This routine is only called by btree immediately after creating + ** the Pager object. There has not been an opportunity to transition + ** to WAL mode yet. + */ + Debug.Assert(!pagerUseWal(pPager)); - if ( isOpen( pPager.fd ) ) - { - IOTRACE( "DBHDR %p 0 %d\n", pPager, N ); - rc = sqlite3OsRead( pPager.fd, pDest, N, 0 ); - if ( rc == SQLITE_IOERR_SHORT_READ ) - { - rc = SQLITE_OK; + if (isOpen(pPager.fd)) { + IOTRACE("DBHDR %p 0 %d\n", pPager, N); + rc = sqlite3OsRead(pPager.fd, pDest, N, 0); + if (rc == SQLITE_IOERR_SHORT_READ) { + rc = SQLITE_OK; + } + } + return rc; } - } - return rc; - } - /* - ** This function may only be called when a read-transaction is open on - ** the pager. It returns the total number of pages in the database. - ** - ** However, if the file is between 1 and bytes in size, then - ** this is considered a 1 page file. - */ - static void sqlite3PagerPagecount( Pager pPager, out Pgno pnPage ) - { - Debug.Assert( pPager.eState >= PAGER_READER ); - Debug.Assert( pPager.eState != PAGER_WRITER_FINISHED ); - pnPage = pPager.dbSize; - } + /* + ** This function may only be called when a read-transaction is open on + ** the pager. It returns the total number of pages in the database. + ** + ** However, if the file is between 1 and bytes in size, then + ** this is considered a 1 page file. + */ + static void sqlite3PagerPagecount(Pager pPager, out Pgno pnPage) { + Debug.Assert(pPager.eState >= PAGER_READER); + Debug.Assert(pPager.eState != PAGER_WRITER_FINISHED); + pnPage = pPager.dbSize; + } - /* - ** Try to obtain a lock of type locktype on the database file. If - ** a similar or greater lock is already held, this function is a no-op - ** (returning SQLITE_OK immediately). - ** - ** Otherwise, attempt to obtain the lock using sqlite3OsLock(). Invoke - ** the busy callback if the lock is currently not available. Repeat - ** until the busy callback returns false or until the attempt to - ** obtain the lock succeeds. - ** - ** Return SQLITE_OK on success and an error code if we cannot obtain - ** the lock. If the lock is obtained successfully, set the Pager.state - ** variable to locktype before returning. - */ - static int pager_wait_on_lock( Pager pPager, int locktype ) - { - int rc; /* Return code */ + /* + ** Try to obtain a lock of type locktype on the database file. If + ** a similar or greater lock is already held, this function is a no-op + ** (returning SQLITE_OK immediately). + ** + ** Otherwise, attempt to obtain the lock using sqlite3OsLock(). Invoke + ** the busy callback if the lock is currently not available. Repeat + ** until the busy callback returns false or until the attempt to + ** obtain the lock succeeds. + ** + ** Return SQLITE_OK on success and an error code if we cannot obtain + ** the lock. If the lock is obtained successfully, set the Pager.state + ** variable to locktype before returning. + */ + static int pager_wait_on_lock(Pager pPager, int locktype) { + int rc; /* Return code */ - /* Check that this is either a no-op (because the requested lock is - ** already held, or one of the transistions that the busy-handler - ** may be invoked during, according to the comment above - ** sqlite3PagerSetBusyhandler(). - */ - Debug.Assert( ( pPager.eLock >= locktype ) - || ( pPager.eLock == NO_LOCK && locktype == SHARED_LOCK ) - || ( pPager.eLock == RESERVED_LOCK && locktype == EXCLUSIVE_LOCK ) - ); + /* Check that this is either a no-op (because the requested lock is + ** already held, or one of the transistions that the busy-handler + ** may be invoked during, according to the comment above + ** sqlite3PagerSetBusyhandler(). + */ + Debug.Assert((pPager.eLock >= locktype) + || (pPager.eLock == NO_LOCK && locktype == SHARED_LOCK) + || (pPager.eLock == RESERVED_LOCK && locktype == EXCLUSIVE_LOCK) + ); - do - { - rc = pagerLockDb( pPager, locktype ); - } while ( rc == SQLITE_BUSY && pPager.xBusyHandler( pPager.pBusyHandlerArg ) != 0 ); - return rc; - } + do { + rc = pagerLockDb(pPager, locktype); + } while (rc == SQLITE_BUSY && pPager.xBusyHandler(pPager.pBusyHandlerArg) != 0); + return rc; + } - /* - ** Function assertTruncateConstraint(pPager) checks that one of the - ** following is true for all dirty pages currently in the page-cache: - ** - ** a) The page number is less than or equal to the size of the - ** current database image, in pages, OR - ** - ** b) if the page content were written at this time, it would not - ** be necessary to write the current content out to the sub-journal - ** (as determined by function subjRequiresPage()). - ** - ** If the condition asserted by this function were not true, and the - ** dirty page were to be discarded from the cache via the pagerStress() - ** routine, pagerStress() would not write the current page content to - ** the database file. If a savepoint transaction were rolled back after - ** this happened, the correct behaviour would be to restore the current - ** content of the page. However, since this content is not present in either - ** the database file or the portion of the rollback journal and - ** sub-journal rolled back the content could not be restored and the - ** database image would become corrupt. It is therefore fortunate that - ** this circumstance cannot arise. - */ + /* + ** Function assertTruncateConstraint(pPager) checks that one of the + ** following is true for all dirty pages currently in the page-cache: + ** + ** a) The page number is less than or equal to the size of the + ** current database image, in pages, OR + ** + ** b) if the page content were written at this time, it would not + ** be necessary to write the current content out to the sub-journal + ** (as determined by function subjRequiresPage()). + ** + ** If the condition asserted by this function were not true, and the + ** dirty page were to be discarded from the cache via the pagerStress() + ** routine, pagerStress() would not write the current page content to + ** the database file. If a savepoint transaction were rolled back after + ** this happened, the correct behaviour would be to restore the current + ** content of the page. However, since this content is not present in either + ** the database file or the portion of the rollback journal and + ** sub-journal rolled back the content could not be restored and the + ** database image would become corrupt. It is therefore fortunate that + ** this circumstance cannot arise. + */ #if SQLITE_DEBUG - static void assertTruncateConstraintCb( PgHdr pPg ) - { - Debug.Assert( ( pPg.flags & PGHDR_DIRTY ) != 0 ); - Debug.Assert( !subjRequiresPage( pPg ) || pPg.pgno <= pPg.pPager.dbSize ); - } - static void assertTruncateConstraint( Pager pPager ) - { - sqlite3PcacheIterateDirty( pPager.pPCache, assertTruncateConstraintCb ); - } + static void assertTruncateConstraintCb(PgHdr pPg) { + Debug.Assert((pPg.flags & PGHDR_DIRTY) != 0); + Debug.Assert(!subjRequiresPage(pPg) || pPg.pgno <= pPg.pPager.dbSize); + } + static void assertTruncateConstraint(Pager pPager) { + sqlite3PcacheIterateDirty(pPager.pPCache, assertTruncateConstraintCb); + } #else //# define assertTruncateConstraint(pPager) static void assertTruncateConstraintCb(PgHdr pPg) { } static void assertTruncateConstraint(Pager pPager) { } #endif - /* -** Truncate the in-memory database file image to nPage pages. This -** function does not actually modify the database file on disk. It -** just sets the internal state of the pager object so that the -** truncation will be done when the current transaction is committed. -*/ - static void sqlite3PagerTruncateImage( Pager pPager, u32 nPage ) - { - Debug.Assert( pPager.dbSize >= nPage ); - Debug.Assert( pPager.eState >= PAGER_WRITER_CACHEMOD ); - pPager.dbSize = nPage; - assertTruncateConstraint( pPager ); - } + /* + ** Truncate the in-memory database file image to nPage pages. This + ** function does not actually modify the database file on disk. It + ** just sets the internal state of the pager object so that the + ** truncation will be done when the current transaction is committed. + */ + static void sqlite3PagerTruncateImage(Pager pPager, u32 nPage) { + Debug.Assert(pPager.dbSize >= nPage); + Debug.Assert(pPager.eState >= PAGER_WRITER_CACHEMOD); + pPager.dbSize = nPage; + assertTruncateConstraint(pPager); + } - /* - ** This function is called before attempting a hot-journal rollback. It - ** syncs the journal file to disk, then sets pPager.journalHdr to the - ** size of the journal file so that the pager_playback() routine knows - ** that the entire journal file has been synced. - ** - ** Syncing a hot-journal to disk before attempting to roll it back ensures - ** that if a power-failure occurs during the rollback, the process that - ** attempts rollback following system recovery sees the same journal - ** content as this process. - ** - ** If everything goes as planned, SQLITE_OK is returned. Otherwise, - ** an SQLite error code. - */ - static int pagerSyncHotJournal( Pager pPager ) - { - int rc = SQLITE_OK; - if ( !pPager.noSync ) - { - rc = sqlite3OsSync( pPager.jfd, SQLITE_SYNC_NORMAL ); - } - if ( rc == SQLITE_OK ) - { - rc = sqlite3OsFileSize( pPager.jfd, ref pPager.journalHdr ); - } - return rc; - } + /* + ** This function is called before attempting a hot-journal rollback. It + ** syncs the journal file to disk, then sets pPager.journalHdr to the + ** size of the journal file so that the pager_playback() routine knows + ** that the entire journal file has been synced. + ** + ** Syncing a hot-journal to disk before attempting to roll it back ensures + ** that if a power-failure occurs during the rollback, the process that + ** attempts rollback following system recovery sees the same journal + ** content as this process. + ** + ** If everything goes as planned, SQLITE_OK is returned. Otherwise, + ** an SQLite error code. + */ + static int pagerSyncHotJournal(Pager pPager) { + int rc = SQLITE_OK; + if (!pPager.noSync) { + rc = sqlite3OsSync(pPager.jfd, SQLITE_SYNC_NORMAL); + } + if (rc == SQLITE_OK) { + rc = sqlite3OsFileSize(pPager.jfd, ref pPager.journalHdr); + } + return rc; + } - /* - ** Shutdown the page cache. Free all memory and close all files. - ** - ** If a transaction was in progress when this routine is called, that - ** transaction is rolled back. All outstanding pages are invalidated - ** and their memory is freed. Any attempt to use a page associated - ** with this page cache after this function returns will likely - ** result in a coredump. - ** - ** This function always succeeds. If a transaction is active an attempt - ** is made to roll it back. If an error occurs during the rollback - ** a hot journal may be left in the filesystem but no error is returned - ** to the caller. - */ - static int sqlite3PagerClose( Pager pPager ) - { + /* + ** Shutdown the page cache. Free all memory and close all files. + ** + ** If a transaction was in progress when this routine is called, that + ** transaction is rolled back. All outstanding pages are invalidated + ** and their memory is freed. Any attempt to use a page associated + ** with this page cache after this function returns will likely + ** result in a coredump. + ** + ** This function always succeeds. If a transaction is active an attempt + ** is made to roll it back. If an error occurs during the rollback + ** a hot journal may be left in the filesystem but no error is returned + ** to the caller. + */ + static int sqlite3PagerClose(Pager pPager) { #if SQLITE_TEST disable_simulated_io_errors(); #endif - sqlite3BeginBenignMalloc(); - /* pPager.errCode = 0; */ - pPager.exclusiveMode = false; + sqlite3BeginBenignMalloc(); + /* pPager.errCode = 0; */ + pPager.exclusiveMode = false; #if !SQLITE_OMIT_WAL u8[] pTmp = pPager.pTmpSpace; sqlite3WalClose(pPager->pWal, pPager->ckptSyncFlags, pPager->pageSize, pTmp); pPager.pWal = 0; #endif - pager_reset( pPager ); + pager_reset(pPager); #if SQLITE_OMIT_MEMORYDB if ( 1 == MEMDB ) #else - if ( 1 == pPager.memDb ) + if (1 == pPager.memDb) #endif - { - pager_unlock( pPager ); - } - else - { - /* If it is open, sync the journal file before calling UnlockAndRollback. - ** If this is not done, then an unsynced portion of the open journal - ** file may be played back into the database. If a power failure occurs - ** while this is happening, the database could become corrupt. - ** - ** If an error occurs while trying to sync the journal, shift the pager - ** into the ERROR state. This causes UnlockAndRollback to unlock the - ** database and close the journal file without attempting to roll it - ** back or finalize it. The next database user will have to do hot-journal - ** rollback before accessing the database file. - */ - if ( isOpen( pPager.jfd ) ) - { - pager_error( pPager, pagerSyncHotJournal( pPager ) ); - } - pagerUnlockAndRollback( pPager ); - } - sqlite3EndBenignMalloc(); + { + pager_unlock(pPager); + } else { + /* If it is open, sync the journal file before calling UnlockAndRollback. + ** If this is not done, then an unsynced portion of the open journal + ** file may be played back into the database. If a power failure occurs + ** while this is happening, the database could become corrupt. + ** + ** If an error occurs while trying to sync the journal, shift the pager + ** into the ERROR state. This causes UnlockAndRollback to unlock the + ** database and close the journal file without attempting to roll it + ** back or finalize it. The next database user will have to do hot-journal + ** rollback before accessing the database file. + */ + if (isOpen(pPager.jfd)) { + pager_error(pPager, pagerSyncHotJournal(pPager)); + } + pagerUnlockAndRollback(pPager); + } + sqlite3EndBenignMalloc(); #if SQLITE_TEST enable_simulated_io_errors(); #endif - PAGERTRACE( "CLOSE %d\n", PAGERID( pPager ) ); - IOTRACE( "CLOSE %p\n", pPager ); - sqlite3OsClose( pPager.jfd ); - sqlite3OsClose( pPager.fd ); - //sqlite3_free( ref pTmp ); - sqlite3PcacheClose( pPager.pPCache ); + PAGERTRACE("CLOSE %d\n", PAGERID(pPager)); + IOTRACE("CLOSE %p\n", pPager); + sqlite3OsClose(pPager.jfd); + sqlite3OsClose(pPager.fd); + //sqlite3_free( ref pTmp ); + sqlite3PcacheClose(pPager.pPCache); #if SQLITE_HAS_CODEC if ( pPager.xCodecFree != null ) pPager.xCodecFree( ref pPager.pCodec ); #endif - Debug.Assert( null == pPager.aSavepoint && !pPager.pInJournal ); - Debug.Assert( !isOpen( pPager.jfd ) && !isOpen( pPager.sjfd ) ); + Debug.Assert(null == pPager.aSavepoint && !pPager.pInJournal); + Debug.Assert(!isOpen(pPager.jfd) && !isOpen(pPager.sjfd)); - //sqlite3_free( ref pPager ); - return SQLITE_OK; - } + //sqlite3_free( ref pPager ); + return SQLITE_OK; + } #if !NDEBUG || SQLITE_TEST - /* -** Return the page number for page pPg. -*/ - static Pgno sqlite3PagerPagenumber( DbPage pPg ) - { - return pPg.pgno; - } + /* + ** Return the page number for page pPg. + */ + static Pgno sqlite3PagerPagenumber(DbPage pPg) { + return pPg.pgno; + } #else static Pgno sqlite3PagerPagenumber( DbPage pPg ) { return pPg.pgno; } #endif - /* -** Increment the reference count for page pPg. -*/ - static void sqlite3PagerRef( DbPage pPg ) - { - sqlite3PcacheRef( pPg ); - } - - /* - ** Sync the journal. In other words, make sure all the pages that have - ** been written to the journal have actually reached the surface of the - ** disk and can be restored in the event of a hot-journal rollback. - ** - ** If the Pager.noSync flag is set, then this function is a no-op. - ** Otherwise, the actions required depend on the journal-mode and the - ** device characteristics of the the file-system, as follows: - ** - ** * If the journal file is an in-memory journal file, no action need - ** be taken. - ** - ** * Otherwise, if the device does not support the SAFE_APPEND property, - ** then the nRec field of the most recently written journal header - ** is updated to contain the number of journal records that have - ** been written following it. If the pager is operating in full-sync - ** mode, then the journal file is synced before this field is updated. - ** - ** * If the device does not support the SEQUENTIAL property, then - ** journal file is synced. - ** - ** Or, in pseudo-code: - ** - ** if( NOT ){ - ** if( NOT SAFE_APPEND ){ - ** if( ) xSync(); - ** - ** } - ** if( NOT SEQUENTIAL ) xSync(); - ** } - ** - ** If successful, this routine clears the PGHDR_NEED_SYNC flag of every - ** page currently held in memory before returning SQLITE_OK. If an IO - ** error is encountered, then the IO error code is returned to the caller. + /* + ** Increment the reference count for page pPg. */ - static int syncJournal( Pager pPager, int newHdr ) - { - int rc = SQLITE_OK; - Debug.Assert( pPager.eState == PAGER_WRITER_CACHEMOD - || pPager.eState == PAGER_WRITER_DBMOD - ); - Debug.Assert( assert_pager_state( pPager ) ); - Debug.Assert( !pagerUseWal( pPager ) ); + static void sqlite3PagerRef(DbPage pPg) { + sqlite3PcacheRef(pPg); + } - rc = sqlite3PagerExclusiveLock( pPager ); - if ( rc != SQLITE_OK ) - return rc; + /* + ** Sync the journal. In other words, make sure all the pages that have + ** been written to the journal have actually reached the surface of the + ** disk and can be restored in the event of a hot-journal rollback. + ** + ** If the Pager.noSync flag is set, then this function is a no-op. + ** Otherwise, the actions required depend on the journal-mode and the + ** device characteristics of the the file-system, as follows: + ** + ** * If the journal file is an in-memory journal file, no action need + ** be taken. + ** + ** * Otherwise, if the device does not support the SAFE_APPEND property, + ** then the nRec field of the most recently written journal header + ** is updated to contain the number of journal records that have + ** been written following it. If the pager is operating in full-sync + ** mode, then the journal file is synced before this field is updated. + ** + ** * If the device does not support the SEQUENTIAL property, then + ** journal file is synced. + ** + ** Or, in pseudo-code: + ** + ** if( NOT ){ + ** if( NOT SAFE_APPEND ){ + ** if( ) xSync(); + ** + ** } + ** if( NOT SEQUENTIAL ) xSync(); + ** } + ** + ** If successful, this routine clears the PGHDR_NEED_SYNC flag of every + ** page currently held in memory before returning SQLITE_OK. If an IO + ** error is encountered, then the IO error code is returned to the caller. + */ + static int syncJournal(Pager pPager, int newHdr) { + int rc = SQLITE_OK; + Debug.Assert(pPager.eState == PAGER_WRITER_CACHEMOD + || pPager.eState == PAGER_WRITER_DBMOD + ); + Debug.Assert(assert_pager_state(pPager)); + Debug.Assert(!pagerUseWal(pPager)); - if ( !pPager.noSync ) - { - Debug.Assert( !pPager.tempFile ); - if ( isOpen( pPager.jfd ) && pPager.journalMode != PAGER_JOURNALMODE_MEMORY ) - { - int iDc = sqlite3OsDeviceCharacteristics( pPager.fd ); - Debug.Assert( isOpen( pPager.jfd ) ); + rc = sqlite3PagerExclusiveLock(pPager); + if (rc != SQLITE_OK) + return rc; - if ( 0 == ( iDc & SQLITE_IOCAP_SAFE_APPEND ) ) - { - /* This block deals with an obscure problem. If the last connection - ** that wrote to this database was operating in persistent-journal - ** mode, then the journal file may at this point actually be larger - ** than Pager.journalOff bytes. If the next thing in the journal - ** file happens to be a journal-header (written as part of the - ** previous connection's transaction), and a crash or power-failure - ** occurs after nRec is updated but before this connection writes - ** anything else to the journal file (or commits/rolls back its - ** transaction), then SQLite may become confused when doing the - ** hot-journal rollback following recovery. It may roll back all - ** of this connections data, then proceed to rolling back the old, - ** out-of-date data that follows it. Database corruption. - ** - ** To work around this, if the journal file does appear to contain - ** a valid header following Pager.journalOff, then write a 0x00 - ** byte to the start of it to prevent it from being recognized. - ** - ** Variable iNextHdrOffset is set to the offset at which this - ** problematic header will occur, if it exists. aMagic is used - ** as a temporary buffer to inspect the first couple of bytes of - ** the potential journal header. - */ - i64 iNextHdrOffset; - u8[] aMagic = new u8[8]; - u8[] zHeader = new u8[aJournalMagic.Length + 4]; - aJournalMagic.CopyTo( zHeader, 0 );// memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic)); - put32bits( zHeader, aJournalMagic.Length, pPager.nRec ); - iNextHdrOffset = journalHdrOffset( pPager ); - rc = sqlite3OsRead( pPager.jfd, aMagic, 8, iNextHdrOffset ); - if ( rc == SQLITE_OK && 0 == memcmp( aMagic, aJournalMagic, 8 ) ) - { - u8[] zerobyte = new u8[1]; - rc = sqlite3OsWrite( pPager.jfd, zerobyte, 1, iNextHdrOffset ); - } - if ( rc != SQLITE_OK && rc != SQLITE_IOERR_SHORT_READ ) - { - return rc; + if (!pPager.noSync) { + Debug.Assert(!pPager.tempFile); + if (isOpen(pPager.jfd) && pPager.journalMode != PAGER_JOURNALMODE_MEMORY) { + int iDc = sqlite3OsDeviceCharacteristics(pPager.fd); + Debug.Assert(isOpen(pPager.jfd)); + + if (0 == (iDc & SQLITE_IOCAP_SAFE_APPEND)) { + /* This block deals with an obscure problem. If the last connection + ** that wrote to this database was operating in persistent-journal + ** mode, then the journal file may at this point actually be larger + ** than Pager.journalOff bytes. If the next thing in the journal + ** file happens to be a journal-header (written as part of the + ** previous connection's transaction), and a crash or power-failure + ** occurs after nRec is updated but before this connection writes + ** anything else to the journal file (or commits/rolls back its + ** transaction), then SQLite may become confused when doing the + ** hot-journal rollback following recovery. It may roll back all + ** of this connections data, then proceed to rolling back the old, + ** out-of-date data that follows it. Database corruption. + ** + ** To work around this, if the journal file does appear to contain + ** a valid header following Pager.journalOff, then write a 0x00 + ** byte to the start of it to prevent it from being recognized. + ** + ** Variable iNextHdrOffset is set to the offset at which this + ** problematic header will occur, if it exists. aMagic is used + ** as a temporary buffer to inspect the first couple of bytes of + ** the potential journal header. + */ + i64 iNextHdrOffset; + u8[] aMagic = new u8[8]; + u8[] zHeader = new u8[aJournalMagic.Length + 4]; + aJournalMagic.CopyTo(zHeader, 0);// memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic)); + put32bits(zHeader, aJournalMagic.Length, pPager.nRec); + iNextHdrOffset = journalHdrOffset(pPager); + rc = sqlite3OsRead(pPager.jfd, aMagic, 8, iNextHdrOffset); + if (rc == SQLITE_OK && 0 == memcmp(aMagic, aJournalMagic, 8)) { + u8[] zerobyte = new u8[1]; + rc = sqlite3OsWrite(pPager.jfd, zerobyte, 1, iNextHdrOffset); + } + if (rc != SQLITE_OK && rc != SQLITE_IOERR_SHORT_READ) { + return rc; + } + + /* Write the nRec value into the journal file header. If in + ** full-synchronous mode, sync the journal first. This ensures that + ** all data has really hit the disk before nRec is updated to mark + ** it as a candidate for rollback. + ** + ** This is not required if the persistent media supports the + ** SAFE_APPEND property. Because in this case it is not possible + ** for garbage data to be appended to the file, the nRec field + ** is populated with 0xFFFFFFFF when the journal header is written + ** and never needs to be updated. + */ + if (pPager.fullSync && 0 == (iDc & SQLITE_IOCAP_SEQUENTIAL)) { + + PAGERTRACE("SYNC journal of %d\n", PAGERID(pPager)); + IOTRACE("JSYNC %p\n", pPager); + rc = sqlite3OsSync(pPager.jfd, pPager.syncFlags); + if (rc != SQLITE_OK) + return rc; + } + IOTRACE("JHDR %p %lld\n", pPager, pPager.journalHdr); + rc = sqlite3OsWrite( + pPager.jfd, zHeader, zHeader.Length, pPager.journalHdr + ); + if (rc != SQLITE_OK) + return rc; + } + if (0 == (iDc & SQLITE_IOCAP_SEQUENTIAL)) { + + PAGERTRACE("SYNC journal of %d\n", PAGERID(pPager)); + IOTRACE("JSYNC %p\n", pPager); + rc = sqlite3OsSync(pPager.jfd, pPager.syncFlags | + (pPager.syncFlags == SQLITE_SYNC_FULL ? SQLITE_SYNC_DATAONLY : 0) + ); + if (rc != SQLITE_OK) + return rc; + } + pPager.journalHdr = pPager.journalOff; + if (newHdr != 0 && 0 == (iDc & SQLITE_IOCAP_SAFE_APPEND)) { + pPager.nRec = 0; + rc = writeJournalHdr(pPager); + if (rc != SQLITE_OK) + return rc; + } + } else { + pPager.journalHdr = pPager.journalOff; + } } - - /* Write the nRec value into the journal file header. If in - ** full-synchronous mode, sync the journal first. This ensures that - ** all data has really hit the disk before nRec is updated to mark - ** it as a candidate for rollback. - ** - ** This is not required if the persistent media supports the - ** SAFE_APPEND property. Because in this case it is not possible - ** for garbage data to be appended to the file, the nRec field - ** is populated with 0xFFFFFFFF when the journal header is written - ** and never needs to be updated. + /* Unless the pager is in noSync mode, the journal file was just + ** successfully synced. Either way, clear the PGHDR_NEED_SYNC flag on + ** all pages. */ - if ( pPager.fullSync && 0 == ( iDc & SQLITE_IOCAP_SEQUENTIAL ) ) - { - - PAGERTRACE( "SYNC journal of %d\n", PAGERID( pPager ) ); - IOTRACE( "JSYNC %p\n", pPager ); - rc = sqlite3OsSync( pPager.jfd, pPager.syncFlags ); - if ( rc != SQLITE_OK ) - return rc; - } - IOTRACE( "JHDR %p %lld\n", pPager, pPager.journalHdr ); - rc = sqlite3OsWrite( - pPager.jfd, zHeader, zHeader.Length, pPager.journalHdr - ); - if ( rc != SQLITE_OK ) - return rc; - } - if ( 0 == ( iDc & SQLITE_IOCAP_SEQUENTIAL ) ) - { - - PAGERTRACE( "SYNC journal of %d\n", PAGERID( pPager ) ); - IOTRACE( "JSYNC %p\n", pPager ); - rc = sqlite3OsSync( pPager.jfd, pPager.syncFlags | - ( pPager.syncFlags == SQLITE_SYNC_FULL ? SQLITE_SYNC_DATAONLY : 0 ) - ); - if ( rc != SQLITE_OK ) - return rc; - } - pPager.journalHdr = pPager.journalOff; - if ( newHdr != 0 && 0 == ( iDc & SQLITE_IOCAP_SAFE_APPEND ) ) - { - pPager.nRec = 0; - rc = writeJournalHdr( pPager ); - if ( rc != SQLITE_OK ) - return rc; - } + sqlite3PcacheClearSyncFlags(pPager.pPCache); + pPager.eState = PAGER_WRITER_DBMOD; + Debug.Assert(assert_pager_state(pPager)); + return SQLITE_OK; } - else - { - pPager.journalHdr = pPager.journalOff; - } - } - /* Unless the pager is in noSync mode, the journal file was just - ** successfully synced. Either way, clear the PGHDR_NEED_SYNC flag on - ** all pages. - */ - sqlite3PcacheClearSyncFlags( pPager.pPCache ); - pPager.eState = PAGER_WRITER_DBMOD; - Debug.Assert( assert_pager_state( pPager ) ); - return SQLITE_OK; - } - /* - ** The argument is the first in a linked list of dirty pages connected - ** by the PgHdr.pDirty pointer. This function writes each one of the - ** in-memory pages in the list to the database file. The argument may - ** be NULL, representing an empty list. In this case this function is - ** a no-op. - ** - ** The pager must hold at least a RESERVED lock when this function - ** is called. Before writing anything to the database file, this lock - ** is upgraded to an EXCLUSIVE lock. If the lock cannot be obtained, - ** SQLITE_BUSY is returned and no data is written to the database file. - ** - ** If the pager is a temp-file pager and the actual file-system file - ** is not yet open, it is created and opened before any data is - ** written out. - ** - ** Once the lock has been upgraded and, if necessary, the file opened, - ** the pages are written out to the database file in list order. Writing - ** a page is skipped if it meets either of the following criteria: - ** - ** * The page number is greater than Pager.dbSize, or - ** * The PGHDR_DONT_WRITE flag is set on the page. - ** - ** If writing out a page causes the database file to grow, Pager.dbFileSize - ** is updated accordingly. If page 1 is written out, then the value cached - ** in Pager.dbFileVers[] is updated to match the new value stored in - ** the database file. - ** - ** If everything is successful, SQLITE_OK is returned. If an IO error - ** occurs, an IO error code is returned. Or, if the EXCLUSIVE lock cannot - ** be obtained, SQLITE_BUSY is returned. - */ - static int pager_write_pagelist( Pager pPager, PgHdr pList ) - { - int rc = SQLITE_OK; /* Return code */ - - /* This function is only called for rollback pagers in WRITER_DBMOD state. */ - Debug.Assert( !pagerUseWal( pPager ) ); - Debug.Assert( pPager.eState == PAGER_WRITER_DBMOD ); - Debug.Assert( pPager.eLock == EXCLUSIVE_LOCK ); - /* If the file is a temp-file has not yet been opened, open it now. It - ** is not possible for rc to be other than SQLITE_OK if this branch - ** is taken, as pager_wait_on_lock() is a no-op for temp-files. - */ - if ( !isOpen( pPager.fd ) ) - { - Debug.Assert( pPager.tempFile && rc == SQLITE_OK ); - rc = pagerOpentemp( pPager, ref pPager.fd, (int)pPager.vfsFlags ); - } - - /* Before the first write, give the VFS a hint of what the final - ** file size will be. - */ - Debug.Assert( rc != SQLITE_OK || isOpen( pPager.fd ) ); - if ( rc == SQLITE_OK && pPager.dbSize > pPager.dbHintSize ) - { - sqlite3_int64 szFile = pPager.pageSize * (sqlite3_int64)pPager.dbSize; - sqlite3OsFileControl( pPager.fd, SQLITE_FCNTL_SIZE_HINT, ref szFile ); - pPager.dbHintSize = pPager.dbSize; - } - while ( rc == SQLITE_OK && pList ) - { - Pgno pgno = pList.pgno; - - /* If there are dirty pages in the page cache with page numbers greater - ** than Pager.dbSize, this means sqlite3PagerTruncateImage() was called to - ** make the file smaller (presumably by auto-vacuum code). Do not write - ** any such pages to the file. + /* + ** The argument is the first in a linked list of dirty pages connected + ** by the PgHdr.pDirty pointer. This function writes each one of the + ** in-memory pages in the list to the database file. The argument may + ** be NULL, representing an empty list. In this case this function is + ** a no-op. + ** + ** The pager must hold at least a RESERVED lock when this function + ** is called. Before writing anything to the database file, this lock + ** is upgraded to an EXCLUSIVE lock. If the lock cannot be obtained, + ** SQLITE_BUSY is returned and no data is written to the database file. + ** + ** If the pager is a temp-file pager and the actual file-system file + ** is not yet open, it is created and opened before any data is + ** written out. + ** + ** Once the lock has been upgraded and, if necessary, the file opened, + ** the pages are written out to the database file in list order. Writing + ** a page is skipped if it meets either of the following criteria: + ** + ** * The page number is greater than Pager.dbSize, or + ** * The PGHDR_DONT_WRITE flag is set on the page. + ** + ** If writing out a page causes the database file to grow, Pager.dbFileSize + ** is updated accordingly. If page 1 is written out, then the value cached + ** in Pager.dbFileVers[] is updated to match the new value stored in + ** the database file. ** - ** Also, do not write out any page that has the PGHDR_DONT_WRITE flag - ** set (set by sqlite3PagerDontWrite()). + ** If everything is successful, SQLITE_OK is returned. If an IO error + ** occurs, an IO error code is returned. Or, if the EXCLUSIVE lock cannot + ** be obtained, SQLITE_BUSY is returned. */ - if ( pList.pgno <= pPager.dbSize && 0 == ( pList.flags & PGHDR_DONT_WRITE ) ) - { - i64 offset = ( pList.pgno - 1 ) * (i64)pPager.pageSize; /* Offset to write */ - byte[] pData = null; /* Data to write */ - - Debug.Assert( ( pList.flags & PGHDR_NEED_SYNC ) == 0 ); - if ( pList.pgno == 1 ) - pager_write_changecounter( pList ); - - /* Encode the database */ - if ( CODEC2( pPager, pList.pData, pgno, SQLITE_ENCRYPT_WRITE_CTX, ref pData ) ) - return SQLITE_NOMEM;// CODEC2(pPager, pList.pData, pgno, 6, return SQLITE_NOMEM, pData); - - /* Write out the page data. */ - rc = sqlite3OsWrite( pPager.fd, pData, pPager.pageSize, offset ); - /* If page 1 was just written, update Pager.dbFileVers to match - ** the value now stored in the database file. If writing this - ** page caused the database file to grow, update dbFileSize. - */ - if ( pgno == 1 ) - { - Buffer.BlockCopy( pData, 24, pPager.dbFileVers, 0, pPager.dbFileVers.Length );// memcpy(pPager.dbFileVers, pData[24], pPager.dbFileVers).Length; - } - if ( pgno > pPager.dbFileSize ) - { - pPager.dbFileSize = pgno; - } - /* Update any backup objects copying the contents of this pager. */ - sqlite3BackupUpdate( pPager.pBackup, pgno, pList.pData ); - + static int pager_write_pagelist(Pager pPager, PgHdr pList) { + int rc = SQLITE_OK; /* Return code */ + + /* This function is only called for rollback pagers in WRITER_DBMOD state. */ + Debug.Assert(!pagerUseWal(pPager)); + Debug.Assert(pPager.eState == PAGER_WRITER_DBMOD); + Debug.Assert(pPager.eLock == EXCLUSIVE_LOCK); + /* If the file is a temp-file has not yet been opened, open it now. It + ** is not possible for rc to be other than SQLITE_OK if this branch + ** is taken, as pager_wait_on_lock() is a no-op for temp-files. + */ + if (!isOpen(pPager.fd)) { + Debug.Assert(pPager.tempFile && rc == SQLITE_OK); + rc = pagerOpentemp(pPager, ref pPager.fd, (int)pPager.vfsFlags); + } - PAGERTRACE( "STORE %d page %d hash(%08x)\n", - PAGERID( pPager ), pgno, pager_pagehash( pList ) ); - IOTRACE( "PGOUT %p %d\n", pPager, pgno ); + /* Before the first write, give the VFS a hint of what the final + ** file size will be. + */ + Debug.Assert(rc != SQLITE_OK || isOpen(pPager.fd)); + if (rc == SQLITE_OK && pPager.dbSize > pPager.dbHintSize) { + sqlite3_int64 szFile = pPager.pageSize * (sqlite3_int64)pPager.dbSize; + sqlite3OsFileControl(pPager.fd, SQLITE_FCNTL_SIZE_HINT, ref szFile); + pPager.dbHintSize = pPager.dbSize; + } + while (rc == SQLITE_OK && pList) { + Pgno pgno = pList.pgno; + + /* If there are dirty pages in the page cache with page numbers greater + ** than Pager.dbSize, this means sqlite3PagerTruncateImage() was called to + ** make the file smaller (presumably by auto-vacuum code). Do not write + ** any such pages to the file. + ** + ** Also, do not write out any page that has the PGHDR_DONT_WRITE flag + ** set (set by sqlite3PagerDontWrite()). + */ + if (pList.pgno <= pPager.dbSize && 0 == (pList.flags & PGHDR_DONT_WRITE)) { + i64 offset = (pList.pgno - 1) * (i64)pPager.pageSize; /* Offset to write */ + byte[] pData = null; /* Data to write */ + + Debug.Assert((pList.flags & PGHDR_NEED_SYNC) == 0); + if (pList.pgno == 1) + pager_write_changecounter(pList); + + /* Encode the database */ + if (CODEC2(pPager, pList.pData, pgno, SQLITE_ENCRYPT_WRITE_CTX, ref pData)) + return SQLITE_NOMEM;// CODEC2(pPager, pList.pData, pgno, 6, return SQLITE_NOMEM, pData); + + /* Write out the page data. */ + rc = sqlite3OsWrite(pPager.fd, pData, pPager.pageSize, offset); + /* If page 1 was just written, update Pager.dbFileVers to match + ** the value now stored in the database file. If writing this + ** page caused the database file to grow, update dbFileSize. + */ + if (pgno == 1) { + Buffer.BlockCopy(pData, 24, pPager.dbFileVers, 0, pPager.dbFileVers.Length);// memcpy(pPager.dbFileVers, pData[24], pPager.dbFileVers).Length; + } + if (pgno > pPager.dbFileSize) { + pPager.dbFileSize = pgno; + } + /* Update any backup objects copying the contents of this pager. */ + sqlite3BackupUpdate(pPager.pBackup, pgno, pList.pData); + + + PAGERTRACE("STORE %d page %d hash(%08x)\n", + PAGERID(pPager), pgno, pager_pagehash(pList)); + IOTRACE("PGOUT %p %d\n", pPager, pgno); #if SQLITE_TEST #if !TCLSH PAGER_INCR( ref sqlite3_pager_writedb_count ); @@ -4612,399 +4349,367 @@ static int pager_write_pagelist( Pager pPager, PgHdr pList ) PAGER_INCR( ref pPager.nWrite ); #endif - } - else - { + } else { - PAGERTRACE( "NOSTORE %d page %d\n", PAGERID( pPager ), pgno ); + PAGERTRACE("NOSTORE %d page %d\n", PAGERID(pPager), pgno); + } + pager_set_pagehash(pList); + pList = pList.pDirty; + } + return rc; } - pager_set_pagehash( pList ); - pList = pList.pDirty; - } - return rc; - } - /* - ** Ensure that the sub-journal file is open. If it is already open, this - ** function is a no-op. - ** - ** SQLITE_OK is returned if everything goes according to plan. An - ** SQLITE_IOERR_XXX error code is returned if a call to sqlite3OsOpen() - ** fails. - */ - static int openSubJournal( Pager pPager ) - { - int rc = SQLITE_OK; - if ( !isOpen( pPager.sjfd ) ) - { - if ( pPager.journalMode == PAGER_JOURNALMODE_MEMORY || pPager.subjInMemory != 0 ) - { - sqlite3MemJournalOpen( pPager.sjfd ); - } - else - { - rc = pagerOpentemp( pPager, ref pPager.sjfd, SQLITE_OPEN_SUBJOURNAL ); + /* + ** Ensure that the sub-journal file is open. If it is already open, this + ** function is a no-op. + ** + ** SQLITE_OK is returned if everything goes according to plan. An + ** SQLITE_IOERR_XXX error code is returned if a call to sqlite3OsOpen() + ** fails. + */ + static int openSubJournal(Pager pPager) { + int rc = SQLITE_OK; + if (!isOpen(pPager.sjfd)) { + if (pPager.journalMode == PAGER_JOURNALMODE_MEMORY || pPager.subjInMemory != 0) { + sqlite3MemJournalOpen(pPager.sjfd); + } else { + rc = pagerOpentemp(pPager, ref pPager.sjfd, SQLITE_OPEN_SUBJOURNAL); + } + } + return rc; } - } - return rc; - } - /* - ** Append a record of the current state of page pPg to the sub-journal. - ** It is the callers responsibility to use subjRequiresPage() to check - ** that it is really required before calling this function. - ** - ** If successful, set the bit corresponding to pPg.pgno in the bitvecs - ** for all open savepoints before returning. - ** - ** This function returns SQLITE_OK if everything is successful, an IO - ** error code if the attempt to write to the sub-journal fails, or - ** SQLITE_NOMEM if a malloc fails while setting a bit in a savepoint - ** bitvec. - */ - static int subjournalPage( PgHdr pPg ) - { - int rc = SQLITE_OK; - Pager pPager = pPg.pPager; - if ( pPager.journalMode != PAGER_JOURNALMODE_OFF ) - { - - /* Open the sub-journal, if it has not already been opened */ - Debug.Assert( pPager.useJournal != 0 ); - Debug.Assert( isOpen( pPager.jfd ) || pagerUseWal( pPager ) ); - Debug.Assert( isOpen( pPager.sjfd ) || pPager.nSubRec == 0 ); - Debug.Assert( pagerUseWal( pPager ) - || pageInJournal( pPg ) - || pPg.pgno > pPager.dbOrigSize - ); - rc = openSubJournal( pPager ); - - /* If the sub-journal was opened successfully (or was already open), - ** write the journal record into the file. */ - if ( rc == SQLITE_OK ) - { - byte[] pData = pPg.pData; - i64 offset = pPager.nSubRec * ( 4 + pPager.pageSize ); - byte[] pData2 = null; - - if ( CODEC2( pPager, pData, pPg.pgno, SQLITE_ENCRYPT_READ_CTX, ref pData2 ) ) - return SQLITE_NOMEM;//CODEC2(pPager, pData, pPg.pgno, 7, return SQLITE_NOMEM, pData2); - PAGERTRACE( "STMT-JOURNAL %d page %d\n", PAGERID( pPager ), pPg.pgno ); - rc = write32bits( pPager.sjfd, offset, pPg.pgno ); - if ( rc == SQLITE_OK ) - { - rc = sqlite3OsWrite( pPager.sjfd, pData2, pPager.pageSize, offset + 4 ); - } + /* + ** Append a record of the current state of page pPg to the sub-journal. + ** It is the callers responsibility to use subjRequiresPage() to check + ** that it is really required before calling this function. + ** + ** If successful, set the bit corresponding to pPg.pgno in the bitvecs + ** for all open savepoints before returning. + ** + ** This function returns SQLITE_OK if everything is successful, an IO + ** error code if the attempt to write to the sub-journal fails, or + ** SQLITE_NOMEM if a malloc fails while setting a bit in a savepoint + ** bitvec. + */ + static int subjournalPage(PgHdr pPg) { + int rc = SQLITE_OK; + Pager pPager = pPg.pPager; + if (pPager.journalMode != PAGER_JOURNALMODE_OFF) { + + /* Open the sub-journal, if it has not already been opened */ + Debug.Assert(pPager.useJournal != 0); + Debug.Assert(isOpen(pPager.jfd) || pagerUseWal(pPager)); + Debug.Assert(isOpen(pPager.sjfd) || pPager.nSubRec == 0); + Debug.Assert(pagerUseWal(pPager) + || pageInJournal(pPg) + || pPg.pgno > pPager.dbOrigSize + ); + rc = openSubJournal(pPager); + + /* If the sub-journal was opened successfully (or was already open), + ** write the journal record into the file. */ + if (rc == SQLITE_OK) { + byte[] pData = pPg.pData; + i64 offset = pPager.nSubRec * (4 + pPager.pageSize); + byte[] pData2 = null; + + if (CODEC2(pPager, pData, pPg.pgno, SQLITE_ENCRYPT_READ_CTX, ref pData2)) + return SQLITE_NOMEM;//CODEC2(pPager, pData, pPg.pgno, 7, return SQLITE_NOMEM, pData2); + PAGERTRACE("STMT-JOURNAL %d page %d\n", PAGERID(pPager), pPg.pgno); + rc = write32bits(pPager.sjfd, offset, pPg.pgno); + if (rc == SQLITE_OK) { + rc = sqlite3OsWrite(pPager.sjfd, pData2, pPager.pageSize, offset + 4); + } + } + } + if (rc == SQLITE_OK) { + pPager.nSubRec++; + Debug.Assert(pPager.nSavepoint > 0); + rc = addToSavepointBitvecs(pPager, pPg.pgno); + } + return rc; } - } - if ( rc == SQLITE_OK ) - { - pPager.nSubRec++; - Debug.Assert( pPager.nSavepoint > 0 ); - rc = addToSavepointBitvecs( pPager, pPg.pgno ); - } - return rc; - } - /* - ** This function is called by the pcache layer when it has reached some - ** soft memory limit. The first argument is a pointer to a Pager object - ** (cast as a void*). The pager is always 'purgeable' (not an in-memory - ** database). The second argument is a reference to a page that is - ** currently dirty but has no outstanding references. The page - ** is always associated with the Pager object passed as the first - ** argument. - ** - ** The job of this function is to make pPg clean by writing its contents - ** out to the database file, if possible. This may involve syncing the - ** journal file. - ** - ** If successful, sqlite3PcacheMakeClean() is called on the page and - ** SQLITE_OK returned. If an IO error occurs while trying to make the - ** page clean, the IO error code is returned. If the page cannot be - ** made clean for some other reason, but no error occurs, then SQLITE_OK - ** is returned by sqlite3PcacheMakeClean() is not called. - */ - static int pagerStress( object p, PgHdr pPg ) - { - Pager pPager = (Pager)p; - int rc = SQLITE_OK; + /* + ** This function is called by the pcache layer when it has reached some + ** soft memory limit. The first argument is a pointer to a Pager object + ** (cast as a void*). The pager is always 'purgeable' (not an in-memory + ** database). The second argument is a reference to a page that is + ** currently dirty but has no outstanding references. The page + ** is always associated with the Pager object passed as the first + ** argument. + ** + ** The job of this function is to make pPg clean by writing its contents + ** out to the database file, if possible. This may involve syncing the + ** journal file. + ** + ** If successful, sqlite3PcacheMakeClean() is called on the page and + ** SQLITE_OK returned. If an IO error occurs while trying to make the + ** page clean, the IO error code is returned. If the page cannot be + ** made clean for some other reason, but no error occurs, then SQLITE_OK + ** is returned by sqlite3PcacheMakeClean() is not called. + */ + static int pagerStress(object p, PgHdr pPg) { + Pager pPager = (Pager)p; + int rc = SQLITE_OK; + + Debug.Assert(pPg.pPager == pPager); + Debug.Assert((pPg.flags & PGHDR_DIRTY) != 0); - Debug.Assert( pPg.pPager == pPager ); - Debug.Assert( ( pPg.flags & PGHDR_DIRTY ) != 0 ); + /* The doNotSyncSpill flag is set during times when doing a sync of + ** journal (and adding a new header) is not allowed. This occurs + ** during calls to sqlite3PagerWrite() while trying to journal multiple + ** pages belonging to the same sector. + ** + ** The doNotSpill flag inhibits all cache spilling regardless of whether + ** or not a sync is required. This is set during a rollback. + ** + ** Spilling is also prohibited when in an error state since that could + ** lead to database corruption. In the current implementaton it + ** is impossible for sqlite3PCacheFetch() to be called with createFlag==1 + ** while in the error state, hence it is impossible for this routine to + ** be called in the error state. Nevertheless, we include a NEVER() + ** test for the error state as a safeguard against future changes. + */ + if (NEVER(pPager.errCode != 0)) + return SQLITE_OK; + if (pPager.doNotSpill != 0) + return SQLITE_OK; + if (pPager.doNotSyncSpill != 0 && (pPg.flags & PGHDR_NEED_SYNC) != 0) { + return SQLITE_OK; + } + pPg.pDirty = null; + if (pagerUseWal(pPager)) { + /* Write a single frame for this page to the log. */ + if (subjRequiresPage(pPg)) { + rc = subjournalPage(pPg); + } + if (rc == SQLITE_OK) { + rc = pagerWalFrames(pPager, pPg, 0, 0, 0); + } + } else { - /* The doNotSyncSpill flag is set during times when doing a sync of - ** journal (and adding a new header) is not allowed. This occurs - ** during calls to sqlite3PagerWrite() while trying to journal multiple - ** pages belonging to the same sector. - ** - ** The doNotSpill flag inhibits all cache spilling regardless of whether - ** or not a sync is required. This is set during a rollback. - ** - ** Spilling is also prohibited when in an error state since that could - ** lead to database corruption. In the current implementaton it - ** is impossible for sqlite3PCacheFetch() to be called with createFlag==1 - ** while in the error state, hence it is impossible for this routine to - ** be called in the error state. Nevertheless, we include a NEVER() - ** test for the error state as a safeguard against future changes. - */ - if ( NEVER( pPager.errCode != 0 ) ) - return SQLITE_OK; - if ( pPager.doNotSpill != 0 ) - return SQLITE_OK; - if ( pPager.doNotSyncSpill != 0 && ( pPg.flags & PGHDR_NEED_SYNC ) != 0 ) - { - return SQLITE_OK; - } - pPg.pDirty = null; - if ( pagerUseWal( pPager ) ) - { - /* Write a single frame for this page to the log. */ - if ( subjRequiresPage( pPg ) ) - { - rc = subjournalPage( pPg ); - } - if ( rc == SQLITE_OK ) - { - rc = pagerWalFrames( pPager, pPg, 0, 0, 0 ); - } - } - else - { + /* Sync the journal file if required. */ + if ((pPg.flags & PGHDR_NEED_SYNC) != 0 + || pPager.eState == PAGER_WRITER_CACHEMOD + ) { + rc = syncJournal(pPager, 1); + } - /* Sync the journal file if required. */ - if ( ( pPg.flags & PGHDR_NEED_SYNC ) != 0 - || pPager.eState == PAGER_WRITER_CACHEMOD - ) - { - rc = syncJournal( pPager, 1 ); - } + /* If the page number of this page is larger than the current size of + ** the database image, it may need to be written to the sub-journal. + ** This is because the call to pager_write_pagelist() below will not + ** actually write data to the file in this case. + ** + ** Consider the following sequence of events: + ** + ** BEGIN; + ** + ** + ** SAVEPOINT sp; + ** + ** pagerStress(page X) + ** ROLLBACK TO sp; + ** + ** If (X>Y), then when pagerStress is called page X will not be written + ** out to the database file, but will be dropped from the cache. Then, + ** following the "ROLLBACK TO sp" statement, reading page X will read + ** data from the database file. This will be the copy of page X as it + ** was when the transaction started, not as it was when "SAVEPOINT sp" + ** was executed. + ** + ** The solution is to write the current data for page X into the + ** sub-journal file now (if it is not already there), so that it will + ** be restored to its current value when the "ROLLBACK TO sp" is + ** executed. + */ + if (NEVER( + rc == SQLITE_OK && pPg.pgno > pPager.dbSize && subjRequiresPage(pPg) + )) { + rc = subjournalPage(pPg); + } - /* If the page number of this page is larger than the current size of - ** the database image, it may need to be written to the sub-journal. - ** This is because the call to pager_write_pagelist() below will not - ** actually write data to the file in this case. - ** - ** Consider the following sequence of events: - ** - ** BEGIN; - ** - ** - ** SAVEPOINT sp; - ** - ** pagerStress(page X) - ** ROLLBACK TO sp; - ** - ** If (X>Y), then when pagerStress is called page X will not be written - ** out to the database file, but will be dropped from the cache. Then, - ** following the "ROLLBACK TO sp" statement, reading page X will read - ** data from the database file. This will be the copy of page X as it - ** was when the transaction started, not as it was when "SAVEPOINT sp" - ** was executed. - ** - ** The solution is to write the current data for page X into the - ** sub-journal file now (if it is not already there), so that it will - ** be restored to its current value when the "ROLLBACK TO sp" is - ** executed. - */ - if ( NEVER( - rc == SQLITE_OK && pPg.pgno > pPager.dbSize && subjRequiresPage( pPg ) - ) ) - { - rc = subjournalPage( pPg ); - } + /* Write the contents of the page out to the database file. */ + if (rc == SQLITE_OK) { + Debug.Assert((pPg.flags & PGHDR_NEED_SYNC) == 0); + rc = pager_write_pagelist(pPager, pPg); + } + } + /* Mark the page as clean. */ + if (rc == SQLITE_OK) { + PAGERTRACE("STRESS %d page %d\n", PAGERID(pPager), pPg.pgno); + sqlite3PcacheMakeClean(pPg); + } - /* Write the contents of the page out to the database file. */ - if ( rc == SQLITE_OK ) - { - Debug.Assert( ( pPg.flags & PGHDR_NEED_SYNC ) == 0 ); - rc = pager_write_pagelist( pPager, pPg ); + return pager_error(pPager, rc); } - } - /* Mark the page as clean. */ - if ( rc == SQLITE_OK ) - { - PAGERTRACE( "STRESS %d page %d\n", PAGERID( pPager ), pPg.pgno ); - sqlite3PcacheMakeClean( pPg ); - } - - return pager_error( pPager, rc ); - } - /* - ** Allocate and initialize a new Pager object and put a pointer to it - ** in *ppPager. The pager should eventually be freed by passing it - ** to sqlite3PagerClose(). - ** - ** The zFilename argument is the path to the database file to open. - ** If zFilename is NULL then a randomly-named temporary file is created - ** and used as the file to be cached. Temporary files are be deleted - ** automatically when they are closed. If zFilename is ":memory:" then - ** all information is held in cache. It is never written to disk. - ** This can be used to implement an in-memory database. - ** - ** The nExtra parameter specifies the number of bytes of space allocated - ** along with each page reference. This space is available to the user - ** via the sqlite3PagerGetExtra() API. - ** - ** The flags argument is used to specify properties that affect the - ** operation of the pager. It should be passed some bitwise combination - ** of the PAGER_OMIT_JOURNAL and PAGER_NO_READLOCK flags. - ** - ** The vfsFlags parameter is a bitmask to pass to the flags parameter - ** of the xOpen() method of the supplied VFS when opening files. - ** - ** If the pager object is allocated and the specified file opened - ** successfully, SQLITE_OK is returned and *ppPager set to point to - ** the new pager object. If an error occurs, *ppPager is set to NULL - ** and error code returned. This function may return SQLITE_NOMEM - ** (sqlite3Malloc() is used to allocate memory), SQLITE_CANTOPEN or - ** various SQLITE_IO_XXX errors. - */ - static int sqlite3PagerOpen( - sqlite3_vfs pVfs, /* The virtual file system to use */ - out Pager ppPager, /* OUT: Return the Pager structure here */ - string zFilename, /* Name of the database file to open */ - int nExtra, /* Extra bytes append to each in-memory page */ - int flags, /* flags controlling this file */ - int vfsFlags, /* flags passed through to sqlite3_vfs.xOpen() */ - dxReiniter xReinit /* Function to reinitialize pages */ - ) - { - u8 pPtr; - Pager pPager = null; /* Pager object to allocate and return */ - int rc = SQLITE_OK; /* Return code */ - u8 tempFile = 0; /* True for temp files (incl. in-memory files) */ // Needs to be u8 for later tests - u8 memDb = 0; /* True if this is an in-memory file */ - bool readOnly = false; /* True if this is a read-only file */ - int journalFileSize; /* Bytes to allocate for each journal fd */ - StringBuilder zPathname = null; /* Full path to database file */ - int nPathname = 0; /* Number of bytes in zPathname */ - bool useJournal = ( flags & PAGER_OMIT_JOURNAL ) == 0; /* False to omit journal */ - bool noReadlock = ( flags & PAGER_NO_READLOCK ) != 0; /* True to omit read-lock */ - int pcacheSize = sqlite3PcacheSize(); /* Bytes to allocate for PCache */ - u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE; /* Default page size */ - string zUri = null; /* URI args to copy */ - int nUri = 0; /* Number of bytes of URI args at *zUri */ - - /* Figure out how much space is required for each journal file-handle - ** (there are two of them, the main journal and the sub-journal). This - ** is the maximum space required for an in-memory journal file handle - ** and a regular journal file-handle. Note that a "regular journal-handle" - ** may be a wrapper capable of caching the first portion of the journal - ** file in memory to implement the atomic-write optimization (see - ** source file journal.c). - */ - if ( sqlite3JournalSize( pVfs ) > sqlite3MemJournalSize() ) - { - journalFileSize = ROUND8( sqlite3JournalSize( pVfs ) ); - } - else - { - journalFileSize = ROUND8( sqlite3MemJournalSize() ); - } + /* + ** Allocate and initialize a new Pager object and put a pointer to it + ** in *ppPager. The pager should eventually be freed by passing it + ** to sqlite3PagerClose(). + ** + ** The zFilename argument is the path to the database file to open. + ** If zFilename is NULL then a randomly-named temporary file is created + ** and used as the file to be cached. Temporary files are be deleted + ** automatically when they are closed. If zFilename is ":memory:" then + ** all information is held in cache. It is never written to disk. + ** This can be used to implement an in-memory database. + ** + ** The nExtra parameter specifies the number of bytes of space allocated + ** along with each page reference. This space is available to the user + ** via the sqlite3PagerGetExtra() API. + ** + ** The flags argument is used to specify properties that affect the + ** operation of the pager. It should be passed some bitwise combination + ** of the PAGER_OMIT_JOURNAL and PAGER_NO_READLOCK flags. + ** + ** The vfsFlags parameter is a bitmask to pass to the flags parameter + ** of the xOpen() method of the supplied VFS when opening files. + ** + ** If the pager object is allocated and the specified file opened + ** successfully, SQLITE_OK is returned and *ppPager set to point to + ** the new pager object. If an error occurs, *ppPager is set to NULL + ** and error code returned. This function may return SQLITE_NOMEM + ** (sqlite3Malloc() is used to allocate memory), SQLITE_CANTOPEN or + ** various SQLITE_IO_XXX errors. + */ + static int sqlite3PagerOpen( + sqlite3_vfs pVfs, /* The virtual file system to use */ + out Pager ppPager, /* OUT: Return the Pager structure here */ + string zFilename, /* Name of the database file to open */ + int nExtra, /* Extra bytes append to each in-memory page */ + int flags, /* flags controlling this file */ + int vfsFlags, /* flags passed through to sqlite3_vfs.xOpen() */ + dxReiniter xReinit /* Function to reinitialize pages */ + ) { + u8 pPtr; + Pager pPager = null; /* Pager object to allocate and return */ + int rc = SQLITE_OK; /* Return code */ + u8 tempFile = 0; /* True for temp files (incl. in-memory files) */ // Needs to be u8 for later tests + u8 memDb = 0; /* True if this is an in-memory file */ + bool readOnly = false; /* True if this is a read-only file */ + int journalFileSize; /* Bytes to allocate for each journal fd */ + StringBuilder zPathname = null; /* Full path to database file */ + int nPathname = 0; /* Number of bytes in zPathname */ + bool useJournal = (flags & PAGER_OMIT_JOURNAL) == 0; /* False to omit journal */ + bool noReadlock = (flags & PAGER_NO_READLOCK) != 0; /* True to omit read-lock */ + int pcacheSize = sqlite3PcacheSize(); /* Bytes to allocate for PCache */ + u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE; /* Default page size */ + string zUri = null; /* URI args to copy */ + int nUri = 0; /* Number of bytes of URI args at *zUri */ + + /* Figure out how much space is required for each journal file-handle + ** (there are two of them, the main journal and the sub-journal). This + ** is the maximum space required for an in-memory journal file handle + ** and a regular journal file-handle. Note that a "regular journal-handle" + ** may be a wrapper capable of caching the first portion of the journal + ** file in memory to implement the atomic-write optimization (see + ** source file journal.c). + */ + if (sqlite3JournalSize(pVfs) > sqlite3MemJournalSize()) { + journalFileSize = ROUND8(sqlite3JournalSize(pVfs)); + } else { + journalFileSize = ROUND8(sqlite3MemJournalSize()); + } - /* Set the output variable to NULL in case an error occurs. */ - ppPager = null; + /* Set the output variable to NULL in case an error occurs. */ + ppPager = null; #if !SQLITE_OMIT_MEMORYDB - if ( ( flags & PAGER_MEMORY ) != 0 ) - { - memDb = 1; - zFilename = null; - } + if ((flags & PAGER_MEMORY) != 0) { + memDb = 1; + zFilename = null; + } #endif - /* Compute and store the full pathname in an allocated buffer pointed - ** to by zPathname, length nPathname. Or, if this is a temporary file, - ** leave both nPathname and zPathname set to 0. - */ - if ( !String.IsNullOrEmpty( zFilename ) ) - { - nPathname = pVfs.mxPathname + 1; - zPathname = new StringBuilder( nPathname * 2 );// sqlite3Malloc( nPathname * 2 ); - //if ( zPathname == null ) - //{ - // return SQLITE_NOMEM; - //} - //zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */ - rc = sqlite3OsFullPathname( pVfs, zFilename, nPathname, zPathname ); - - nPathname = sqlite3Strlen30( zPathname ); - zUri = zFilename; - //string z = zUri = zFilename;//.Substring(sqlite3Strlen30( zFilename ) ); - //while ( *z ) - //{ - // z += sqlite3Strlen30( z ) + 1; - // z += sqlite3Strlen30( z ) + 1; - //} - //nUri = zUri.Length;// &z[1] - zUri; - if ( rc == SQLITE_OK && nPathname + 8 > pVfs.mxPathname ) - { - /* This branch is taken when the journal path required by - ** the database being opened will be more than pVfs.mxPathname - ** bytes in length. This means the database cannot be opened, - ** as it will not be possible to open the journal file or even - ** check for a hot-journal before reading. - */ - rc = SQLITE_CANTOPEN_BKPT(); - } - if ( rc != SQLITE_OK ) - { - //sqlite3_free( ref zPathname ); - return rc; - } - } + /* Compute and store the full pathname in an allocated buffer pointed + ** to by zPathname, length nPathname. Or, if this is a temporary file, + ** leave both nPathname and zPathname set to 0. + */ + if (!String.IsNullOrEmpty(zFilename)) { + nPathname = pVfs.mxPathname + 1; + zPathname = new StringBuilder(nPathname * 2);// sqlite3Malloc( nPathname * 2 ); + //if ( zPathname == null ) + //{ + // return SQLITE_NOMEM; + //} + //zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */ + rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname); + + nPathname = sqlite3Strlen30(zPathname); + zUri = zFilename; + //string z = zUri = zFilename;//.Substring(sqlite3Strlen30( zFilename ) ); + //while ( *z ) + //{ + // z += sqlite3Strlen30( z ) + 1; + // z += sqlite3Strlen30( z ) + 1; + //} + //nUri = zUri.Length;// &z[1] - zUri; + if (rc == SQLITE_OK && nPathname + 8 > pVfs.mxPathname) { + /* This branch is taken when the journal path required by + ** the database being opened will be more than pVfs.mxPathname + ** bytes in length. This means the database cannot be opened, + ** as it will not be possible to open the journal file or even + ** check for a hot-journal before reading. + */ + rc = SQLITE_CANTOPEN_BKPT(); + } + if (rc != SQLITE_OK) { + //sqlite3_free( ref zPathname ); + return rc; + } + } - /* Allocate memory for the Pager structure, PCache object, the - ** three file descriptors, the database file name and the journal - ** file name. The layout in memory is as follows: - ** - ** Pager object (sizeof(Pager) bytes) - ** PCache object (sqlite3PcacheSize() bytes) - ** Database file handle (pVfs.szOsFile bytes) - ** Sub-journal file handle (journalFileSize bytes) - ** Main journal file handle (journalFileSize bytes) - ** Database file name (nPathname+1 bytes) - ** Journal file name (nPathname+8+1 bytes) - */ - //pPtr = (u8 *)sqlite3MallocZero( - // ROUND8(sizeof(*pPager)) + /* Pager structure */ - // ROUND8(pcacheSize) + /* PCache object */ - // ROUND8(pVfs.szOsFile) + /* The main db file */ - // journalFileSize * 2 + /* The two journal files */ - // nPathname + 1 + nUri + /* zFilename */ - // nPathname + 8 + 1 /* zJournal */ - //#if !SQLITE_OMIT_WAL - // + nPathname + 4 + 1 /* zWal */ - //#endif - //); - // Debug.Assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize))); - //if( !pPtr ){ - // //sqlite3_free(zPathname); - // return SQLITE_NOMEM; - //} - pPager = new Pager();//(Pager*)(pPtr); - pPager.pPCache = new PCache();//(PCache*)(pPtr += ROUND8(sizeof(*pPager))); - pPager.fd = new sqlite3_file();//(sqlite3_file*)(pPtr += ROUND8(pcacheSize)); - pPager.sjfd = new sqlite3_file();//(sqlite3_file*)(pPtr += ROUND8(pVfs.szOsFile)); - pPager.jfd = new sqlite3_file();//(sqlite3_file*)(pPtr += journalFileSize); - //pPager.zFilename = (char*)(pPtr += journalFileSize); - //Debug.Assert( EIGHT_BYTE_ALIGNMENT(pPager.jfd) ); - - /* Fill in the Pager.zFilename and Pager.zJournal buffers, if required. */ - if ( zPathname != null ) - { - Debug.Assert( nPathname > 0 ); - //pPager.zJournal = (char*)(pPtr += nPathname + 1 + nUri); - //memcpy(pPager.zFilename, zPathname, nPathname); - pPager.zFilename = zPathname.ToString(); - zUri = pPager.zFilename;//.Substring( nPathname + 1 );//memcpy( &pPager.zFilename[nPathname + 1], zUri, nUri ); - //memcpy(pPager.zJournal, zPathname, nPathname); - //memcpy(&pPager.zJournal[nPathname], "-journal", 8); - pPager.zJournal = pPager.zFilename + "-journal"; - sqlite3FileSuffix3( pPager.zFilename, pPager.zJournal ); + /* Allocate memory for the Pager structure, PCache object, the + ** three file descriptors, the database file name and the journal + ** file name. The layout in memory is as follows: + ** + ** Pager object (sizeof(Pager) bytes) + ** PCache object (sqlite3PcacheSize() bytes) + ** Database file handle (pVfs.szOsFile bytes) + ** Sub-journal file handle (journalFileSize bytes) + ** Main journal file handle (journalFileSize bytes) + ** Database file name (nPathname+1 bytes) + ** Journal file name (nPathname+8+1 bytes) + */ + //pPtr = (u8 *)sqlite3MallocZero( + // ROUND8(sizeof(*pPager)) + /* Pager structure */ + // ROUND8(pcacheSize) + /* PCache object */ + // ROUND8(pVfs.szOsFile) + /* The main db file */ + // journalFileSize * 2 + /* The two journal files */ + // nPathname + 1 + nUri + /* zFilename */ + // nPathname + 8 + 1 /* zJournal */ + //#if !SQLITE_OMIT_WAL + // + nPathname + 4 + 1 /* zWal */ + //#endif + //); + // Debug.Assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize))); + //if( !pPtr ){ + // //sqlite3_free(zPathname); + // return SQLITE_NOMEM; + //} + pPager = new Pager();//(Pager*)(pPtr); + pPager.pPCache = new PCache();//(PCache*)(pPtr += ROUND8(sizeof(*pPager))); + pPager.fd = new sqlite3_file();//(sqlite3_file*)(pPtr += ROUND8(pcacheSize)); + pPager.sjfd = new sqlite3_file();//(sqlite3_file*)(pPtr += ROUND8(pVfs.szOsFile)); + pPager.jfd = new sqlite3_file();//(sqlite3_file*)(pPtr += journalFileSize); + //pPager.zFilename = (char*)(pPtr += journalFileSize); + //Debug.Assert( EIGHT_BYTE_ALIGNMENT(pPager.jfd) ); + + /* Fill in the Pager.zFilename and Pager.zJournal buffers, if required. */ + if (zPathname != null) { + Debug.Assert(nPathname > 0); + //pPager.zJournal = (char*)(pPtr += nPathname + 1 + nUri); + //memcpy(pPager.zFilename, zPathname, nPathname); + pPager.zFilename = zPathname.ToString(); + zUri = pPager.zFilename;//.Substring( nPathname + 1 );//memcpy( &pPager.zFilename[nPathname + 1], zUri, nUri ); + //memcpy(pPager.zJournal, zPathname, nPathname); + //memcpy(&pPager.zJournal[nPathname], "-journal", 8); + pPager.zJournal = pPager.zFilename + "-journal"; + sqlite3FileSuffix3(pPager.zFilename, pPager.zJournal); #if !SQLITE_OMIT_WAL pPager.zWal = &pPager.zJournal[nPathname+8+1]; memcpy(pPager.zWal, zPathname, nPathname); @@ -5012,47 +4717,39 @@ dxReiniter xReinit /* Function to reinitialize pages */ sqlite3FileSuffix3(pPager.zFilename, pPager.zWal); #endif - //sqlite3_free( ref zPathname ); - } - else - { - pPager.zFilename = ""; - } - pPager.pVfs = pVfs; - pPager.vfsFlags = (u32)vfsFlags; - - /* Open the pager file. - */ - if ( !String.IsNullOrEmpty( pPager.zFilename ) ) - { - int fout = 0; /* VFS flags returned by xOpen() */ - rc = sqlite3OsOpen( pVfs, pPager.zFilename, pPager.fd, vfsFlags, ref fout ); - Debug.Assert( 0 == memDb ); - readOnly = ( fout & SQLITE_OPEN_READONLY ) != 0; - - /* If the file was successfully opened for read/write access, - ** choose a default page size in case we have to create the - ** database file. The default page size is the maximum of: - ** - ** + SQLITE_DEFAULT_PAGE_SIZE, - ** + The value returned by sqlite3OsSectorSize() - ** + The largest page size that can be written atomically. - */ - if ( rc == SQLITE_OK && !readOnly ) - { - setSectorSize( pPager ); - Debug.Assert( SQLITE_DEFAULT_PAGE_SIZE <= SQLITE_MAX_DEFAULT_PAGE_SIZE ); - if ( szPageDflt < pPager.sectorSize ) - { - if ( pPager.sectorSize > SQLITE_MAX_DEFAULT_PAGE_SIZE ) - { - szPageDflt = SQLITE_MAX_DEFAULT_PAGE_SIZE; - } - else - { - szPageDflt = (u32)pPager.sectorSize; + //sqlite3_free( ref zPathname ); + } else { + pPager.zFilename = ""; } - } + pPager.pVfs = pVfs; + pPager.vfsFlags = (u32)vfsFlags; + + /* Open the pager file. + */ + if (!String.IsNullOrEmpty(pPager.zFilename)) { + int fout = 0; /* VFS flags returned by xOpen() */ + rc = sqlite3OsOpen(pVfs, pPager.zFilename, pPager.fd, vfsFlags, ref fout); + Debug.Assert(0 == memDb); + readOnly = (fout & SQLITE_OPEN_READONLY) != 0; + + /* If the file was successfully opened for read/write access, + ** choose a default page size in case we have to create the + ** database file. The default page size is the maximum of: + ** + ** + SQLITE_DEFAULT_PAGE_SIZE, + ** + The value returned by sqlite3OsSectorSize() + ** + The largest page size that can be written atomically. + */ + if (rc == SQLITE_OK && !readOnly) { + setSectorSize(pPager); + Debug.Assert(SQLITE_DEFAULT_PAGE_SIZE <= SQLITE_MAX_DEFAULT_PAGE_SIZE); + if (szPageDflt < pPager.sectorSize) { + if (pPager.sectorSize > SQLITE_MAX_DEFAULT_PAGE_SIZE) { + szPageDflt = SQLITE_MAX_DEFAULT_PAGE_SIZE; + } else { + szPageDflt = (u32)pPager.sectorSize; + } + } #if SQLITE_ENABLE_ATOMIC_WRITE { int iDc = sqlite3OsDeviceCharacteristics(pPager.fd); @@ -5067,1078 +4764,978 @@ dxReiniter xReinit /* Function to reinitialize pages */ } } #endif - } - } - else - { - /* If a temporary file is requested, it is not opened immediately. - ** In this case we accept the default page size and delay actually - ** opening the file until the first call to OsWrite(). - ** - ** This branch is also run for an in-memory database. An in-memory - ** database is the same as a temp-file that is never written out to - ** disk and uses an in-memory rollback journal. - */ - tempFile = 1; - pPager.eState = PAGER_READER; - pPager.eLock = EXCLUSIVE_LOCK; - readOnly = ( vfsFlags & SQLITE_OPEN_READONLY ) != 0; - } + } + } else { + /* If a temporary file is requested, it is not opened immediately. + ** In this case we accept the default page size and delay actually + ** opening the file until the first call to OsWrite(). + ** + ** This branch is also run for an in-memory database. An in-memory + ** database is the same as a temp-file that is never written out to + ** disk and uses an in-memory rollback journal. + */ + tempFile = 1; + pPager.eState = PAGER_READER; + pPager.eLock = EXCLUSIVE_LOCK; + readOnly = (vfsFlags & SQLITE_OPEN_READONLY) != 0; + } - /* The following call to PagerSetPagesize() serves to set the value of - ** Pager.pageSize and to allocate the Pager.pTmpSpace buffer. - */ - if ( rc == SQLITE_OK ) - { - Debug.Assert( pPager.memDb == 0 ); - rc = sqlite3PagerSetPagesize( pPager, ref szPageDflt, -1 ); - testcase( rc != SQLITE_OK ); - } + /* The following call to PagerSetPagesize() serves to set the value of + ** Pager.pageSize and to allocate the Pager.pTmpSpace buffer. + */ + if (rc == SQLITE_OK) { + Debug.Assert(pPager.memDb == 0); + rc = sqlite3PagerSetPagesize(pPager, ref szPageDflt, -1); + testcase(rc != SQLITE_OK); + } - /* If an error occurred in either of the blocks above, free the - ** Pager structure and close the file. - */ - if ( rc != SQLITE_OK ) - { - Debug.Assert( null == pPager.pTmpSpace ); - sqlite3OsClose( pPager.fd ); - //sqlite3_free( ref pPager ); - return rc; - } + /* If an error occurred in either of the blocks above, free the + ** Pager structure and close the file. + */ + if (rc != SQLITE_OK) { + Debug.Assert(null == pPager.pTmpSpace); + sqlite3OsClose(pPager.fd); + //sqlite3_free( ref pPager ); + return rc; + } - /* Initialize the PCache object. */ - Debug.Assert( nExtra < 1000 ); - nExtra = ROUND8( nExtra ); - sqlite3PcacheOpen( (int)szPageDflt, nExtra, 0 == memDb, - 0 == memDb ? (dxStress)pagerStress : null, pPager, pPager.pPCache ); - - PAGERTRACE( "OPEN %d %s\n", FILEHANDLEID( pPager.fd ), pPager.zFilename ); - IOTRACE( "OPEN %p %s\n", pPager, pPager.zFilename ); - pPager.useJournal = (u8)( useJournal ? 1 : 0 ); - pPager.noReadlock = (u8)( noReadlock && readOnly ? 1 : 0 ); - /* pPager.stmtOpen = 0; */ - /* pPager.stmtInUse = 0; */ - /* pPager.nRef = 0; */ - /* pPager.stmtSize = 0; */ - /* pPager.stmtJSize = 0; */ - /* pPager.nPage = 0; */ - pPager.mxPgno = SQLITE_MAX_PAGE_COUNT; - /* pPager.state = PAGER_UNLOCK; */ + /* Initialize the PCache object. */ + Debug.Assert(nExtra < 1000); + nExtra = ROUND8(nExtra); + sqlite3PcacheOpen((int)szPageDflt, nExtra, 0 == memDb, + 0 == memDb ? (dxStress)pagerStress : null, pPager, pPager.pPCache); + + PAGERTRACE("OPEN %d %s\n", FILEHANDLEID(pPager.fd), pPager.zFilename); + IOTRACE("OPEN %p %s\n", pPager, pPager.zFilename); + pPager.useJournal = (u8)(useJournal ? 1 : 0); + pPager.noReadlock = (u8)(noReadlock && readOnly ? 1 : 0); + /* pPager.stmtOpen = 0; */ + /* pPager.stmtInUse = 0; */ + /* pPager.nRef = 0; */ + /* pPager.stmtSize = 0; */ + /* pPager.stmtJSize = 0; */ + /* pPager.nPage = 0; */ + pPager.mxPgno = SQLITE_MAX_PAGE_COUNT; + /* pPager.state = PAGER_UNLOCK; */ #if FALSE Debug.Assert(pPager.state == (tempFile != 0 ? PAGER_EXCLUSIVE : PAGER_UNLOCK)); #endif - /* pPager.errMask = 0; */ - pPager.tempFile = tempFile != 0; - Debug.Assert( tempFile == PAGER_LOCKINGMODE_NORMAL - || tempFile == PAGER_LOCKINGMODE_EXCLUSIVE ); - Debug.Assert( PAGER_LOCKINGMODE_EXCLUSIVE == 1 ); - pPager.exclusiveMode = tempFile != 0; - pPager.changeCountDone = pPager.tempFile; - pPager.memDb = memDb; - pPager.readOnly = readOnly; - Debug.Assert( useJournal || pPager.tempFile ); - pPager.noSync = pPager.tempFile; - pPager.fullSync = pPager.noSync; - pPager.syncFlags = (byte)( pPager.noSync ? 0 : SQLITE_SYNC_NORMAL ); - pPager.ckptSyncFlags = pPager.syncFlags; - /* pPager.pFirst = 0; */ - /* pPager.pFirstSynced = 0; */ - /* pPager.pLast = 0; */ - pPager.nExtra = (u16)nExtra; - pPager.journalSizeLimit = SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT; - Debug.Assert( isOpen( pPager.fd ) || tempFile != 0 ); - setSectorSize( pPager ); - if ( !useJournal ) - { - pPager.journalMode = PAGER_JOURNALMODE_OFF; - } - else if ( memDb != 0 ) - { - pPager.journalMode = PAGER_JOURNALMODE_MEMORY; - } - /* pPager.xBusyHandler = 0; */ - /* pPager.pBusyHandlerArg = 0; */ - pPager.xReiniter = xReinit; - /* memset(pPager.aHash, 0, sizeof(pPager.aHash)); */ - ppPager = pPager; - return SQLITE_OK; - } + /* pPager.errMask = 0; */ + pPager.tempFile = tempFile != 0; + Debug.Assert(tempFile == PAGER_LOCKINGMODE_NORMAL + || tempFile == PAGER_LOCKINGMODE_EXCLUSIVE); + Debug.Assert(PAGER_LOCKINGMODE_EXCLUSIVE == 1); + pPager.exclusiveMode = tempFile != 0; + pPager.changeCountDone = pPager.tempFile; + pPager.memDb = memDb; + pPager.readOnly = readOnly; + Debug.Assert(useJournal || pPager.tempFile); + pPager.noSync = pPager.tempFile; + pPager.fullSync = pPager.noSync; + pPager.syncFlags = (byte)(pPager.noSync ? 0 : SQLITE_SYNC_NORMAL); + pPager.ckptSyncFlags = pPager.syncFlags; + /* pPager.pFirst = 0; */ + /* pPager.pFirstSynced = 0; */ + /* pPager.pLast = 0; */ + pPager.nExtra = (u16)nExtra; + pPager.journalSizeLimit = SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT; + Debug.Assert(isOpen(pPager.fd) || tempFile != 0); + setSectorSize(pPager); + if (!useJournal) { + pPager.journalMode = PAGER_JOURNALMODE_OFF; + } else if (memDb != 0) { + pPager.journalMode = PAGER_JOURNALMODE_MEMORY; + } + /* pPager.xBusyHandler = 0; */ + /* pPager.pBusyHandlerArg = 0; */ + pPager.xReiniter = xReinit; + /* memset(pPager.aHash, 0, sizeof(pPager.aHash)); */ + ppPager = pPager; + return SQLITE_OK; + } - /* - ** This function is called after transitioning from PAGER_UNLOCK to - ** PAGER_SHARED state. It tests if there is a hot journal present in - ** the file-system for the given pager. A hot journal is one that - ** needs to be played back. According to this function, a hot-journal - ** file exists if the following criteria are met: - ** - ** * The journal file exists in the file system, and - ** * No process holds a RESERVED or greater lock on the database file, and - ** * The database file itself is greater than 0 bytes in size, and - ** * The first byte of the journal file exists and is not 0x00. - ** - ** If the current size of the database file is 0 but a journal file - ** exists, that is probably an old journal left over from a prior - ** database with the same name. In this case the journal file is - ** just deleted using OsDelete, *pExists is set to 0 and SQLITE_OK - ** is returned. - ** - ** This routine does not check if there is a master journal filename - ** at the end of the file. If there is, and that master journal file - ** does not exist, then the journal file is not really hot. In this - ** case this routine will return a false-positive. The pager_playback() - ** routine will discover that the journal file is not really hot and - ** will not roll it back. - ** - ** If a hot-journal file is found to exist, *pExists is set to 1 and - ** SQLITE_OK returned. If no hot-journal file is present, *pExists is - ** set to 0 and SQLITE_OK returned. If an IO error occurs while trying - ** to determine whether or not a hot-journal file exists, the IO error - ** code is returned and the value of *pExists is undefined. - */ - static int hasHotJournal( Pager pPager, ref int pExists ) - { - sqlite3_vfs pVfs = pPager.pVfs; - int rc = SQLITE_OK; /* Return code */ - int exists = 1; /* True if a journal file is present */ - int jrnlOpen = isOpen( pPager.jfd ) ? 1 : 0; - Debug.Assert( pPager.useJournal != 0 ); - Debug.Assert( isOpen( pPager.fd ) ); - Debug.Assert( pPager.eState == PAGER_OPEN ); + /* + ** This function is called after transitioning from PAGER_UNLOCK to + ** PAGER_SHARED state. It tests if there is a hot journal present in + ** the file-system for the given pager. A hot journal is one that + ** needs to be played back. According to this function, a hot-journal + ** file exists if the following criteria are met: + ** + ** * The journal file exists in the file system, and + ** * No process holds a RESERVED or greater lock on the database file, and + ** * The database file itself is greater than 0 bytes in size, and + ** * The first byte of the journal file exists and is not 0x00. + ** + ** If the current size of the database file is 0 but a journal file + ** exists, that is probably an old journal left over from a prior + ** database with the same name. In this case the journal file is + ** just deleted using OsDelete, *pExists is set to 0 and SQLITE_OK + ** is returned. + ** + ** This routine does not check if there is a master journal filename + ** at the end of the file. If there is, and that master journal file + ** does not exist, then the journal file is not really hot. In this + ** case this routine will return a false-positive. The pager_playback() + ** routine will discover that the journal file is not really hot and + ** will not roll it back. + ** + ** If a hot-journal file is found to exist, *pExists is set to 1 and + ** SQLITE_OK returned. If no hot-journal file is present, *pExists is + ** set to 0 and SQLITE_OK returned. If an IO error occurs while trying + ** to determine whether or not a hot-journal file exists, the IO error + ** code is returned and the value of *pExists is undefined. + */ + static int hasHotJournal(Pager pPager, ref int pExists) { + sqlite3_vfs pVfs = pPager.pVfs; + int rc = SQLITE_OK; /* Return code */ + int exists = 1; /* True if a journal file is present */ + int jrnlOpen = isOpen(pPager.jfd) ? 1 : 0; + Debug.Assert(pPager.useJournal != 0); + Debug.Assert(isOpen(pPager.fd)); + Debug.Assert(pPager.eState == PAGER_OPEN); - Debug.Assert( jrnlOpen == 0 || ( sqlite3OsDeviceCharacteristics( pPager.jfd ) & - SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN - ) != 0 ); + Debug.Assert(jrnlOpen == 0 || (sqlite3OsDeviceCharacteristics(pPager.jfd) & + SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN + ) != 0); - pExists = 0; + pExists = 0; - if ( 0 == jrnlOpen ) - { - rc = sqlite3OsAccess( pVfs, pPager.zJournal, SQLITE_ACCESS_EXISTS, ref exists ); - } - if ( rc == SQLITE_OK && exists != 0 ) - { - int locked = 0; /* True if some process holds a RESERVED lock */ - - /* Race condition here: Another process might have been holding the - ** the RESERVED lock and have a journal open at the sqlite3OsAccess() - ** call above, but then delete the journal and drop the lock before - ** we get to the following sqlite3OsCheckReservedLock() call. If that - ** is the case, this routine might think there is a hot journal when - ** in fact there is none. This results in a false-positive which will - ** be dealt with by the playback routine. Ticket #3883. - */ - rc = sqlite3OsCheckReservedLock( pPager.fd, ref locked ); - if ( rc == SQLITE_OK && locked == 0 ) - { - Pgno nPage = 0; /* Number of pages in database file */ - - /* Check the size of the database file. If it consists of 0 pages, - ** then delete the journal file. See the header comment above for - ** the reasoning here. Delete the obsolete journal file under - ** a RESERVED lock to avoid race conditions and to avoid violating - ** [H33020]. - */ - rc = pagerPagecount( pPager, ref nPage ); - if ( rc == SQLITE_OK ) - { - if ( nPage == 0 ) - { - sqlite3BeginBenignMalloc(); - if ( pagerLockDb( pPager, RESERVED_LOCK ) == SQLITE_OK ) - { - sqlite3OsDelete( pVfs, pPager.zJournal, 0 ); - if ( !pPager.exclusiveMode ) - pagerUnlockDb( pPager, SHARED_LOCK ); - } - sqlite3EndBenignMalloc(); - } - else - { - /* The journal file exists and no other connection has a reserved - ** or greater lock on the database file. Now check that there is - ** at least one non-zero bytes at the start of the journal file. - ** If there is, then we consider this journal to be hot. If not, - ** it can be ignored. - */ - if ( 0 == jrnlOpen ) - { - int f = SQLITE_OPEN_READONLY | SQLITE_OPEN_MAIN_JOURNAL; - rc = sqlite3OsOpen( pVfs, pPager.zJournal, pPager.jfd, f, ref f ); - } - if ( rc == SQLITE_OK ) - { - u8[] first = new u8[1]; - rc = sqlite3OsRead( pPager.jfd, first, 1, 0 ); - if ( rc == SQLITE_IOERR_SHORT_READ ) - { - rc = SQLITE_OK; - } - if ( 0 == jrnlOpen ) - { - sqlite3OsClose( pPager.jfd ); - } - pExists = ( first[0] != 0 ) ? 1 : 0; - } - else if ( rc == SQLITE_CANTOPEN ) - { - /* If we cannot open the rollback journal file in order to see if - ** its has a zero header, that might be due to an I/O error, or - ** it might be due to the race condition described above and in - ** ticket #3883. Either way, assume that the journal is hot. - ** This might be a false positive. But if it is, then the - ** automatic journal playback and recovery mechanism will deal - ** with it under an EXCLUSIVE lock where we do not need to - ** worry so much with race conditions. + if (0 == jrnlOpen) { + rc = sqlite3OsAccess(pVfs, pPager.zJournal, SQLITE_ACCESS_EXISTS, ref exists); + } + if (rc == SQLITE_OK && exists != 0) { + int locked = 0; /* True if some process holds a RESERVED lock */ + + /* Race condition here: Another process might have been holding the + ** the RESERVED lock and have a journal open at the sqlite3OsAccess() + ** call above, but then delete the journal and drop the lock before + ** we get to the following sqlite3OsCheckReservedLock() call. If that + ** is the case, this routine might think there is a hot journal when + ** in fact there is none. This results in a false-positive which will + ** be dealt with by the playback routine. Ticket #3883. */ - pExists = 1; - rc = SQLITE_OK; - } + rc = sqlite3OsCheckReservedLock(pPager.fd, ref locked); + if (rc == SQLITE_OK && locked == 0) { + Pgno nPage = 0; /* Number of pages in database file */ + + /* Check the size of the database file. If it consists of 0 pages, + ** then delete the journal file. See the header comment above for + ** the reasoning here. Delete the obsolete journal file under + ** a RESERVED lock to avoid race conditions and to avoid violating + ** [H33020]. + */ + rc = pagerPagecount(pPager, ref nPage); + if (rc == SQLITE_OK) { + if (nPage == 0) { + sqlite3BeginBenignMalloc(); + if (pagerLockDb(pPager, RESERVED_LOCK) == SQLITE_OK) { + sqlite3OsDelete(pVfs, pPager.zJournal, 0); + if (!pPager.exclusiveMode) + pagerUnlockDb(pPager, SHARED_LOCK); + } + sqlite3EndBenignMalloc(); + } else { + /* The journal file exists and no other connection has a reserved + ** or greater lock on the database file. Now check that there is + ** at least one non-zero bytes at the start of the journal file. + ** If there is, then we consider this journal to be hot. If not, + ** it can be ignored. + */ + if (0 == jrnlOpen) { + int f = SQLITE_OPEN_READONLY | SQLITE_OPEN_MAIN_JOURNAL; + rc = sqlite3OsOpen(pVfs, pPager.zJournal, pPager.jfd, f, ref f); + } + if (rc == SQLITE_OK) { + u8[] first = new u8[1]; + rc = sqlite3OsRead(pPager.jfd, first, 1, 0); + if (rc == SQLITE_IOERR_SHORT_READ) { + rc = SQLITE_OK; + } + if (0 == jrnlOpen) { + sqlite3OsClose(pPager.jfd); + } + pExists = (first[0] != 0) ? 1 : 0; + } else if (rc == SQLITE_CANTOPEN) { + /* If we cannot open the rollback journal file in order to see if + ** its has a zero header, that might be due to an I/O error, or + ** it might be due to the race condition described above and in + ** ticket #3883. Either way, assume that the journal is hot. + ** This might be a false positive. But if it is, then the + ** automatic journal playback and recovery mechanism will deal + ** with it under an EXCLUSIVE lock where we do not need to + ** worry so much with race conditions. + */ + pExists = 1; + rc = SQLITE_OK; + } + } + } + } } - } + return rc; } - } - return rc; - } - /* - ** This function is called to obtain a shared lock on the database file. - ** It is illegal to call sqlite3PagerAcquire() until after this function - ** has been successfully called. If a shared-lock is already held when - ** this function is called, it is a no-op. - ** - ** The following operations are also performed by this function. - ** - ** 1) If the pager is currently in PAGER_OPEN state (no lock held - ** on the database file), then an attempt is made to obtain a - ** SHARED lock on the database file. Immediately after obtaining - ** the SHARED lock, the file-system is checked for a hot-journal, - ** which is played back if present. Following any hot-journal - ** rollback, the contents of the cache are validated by checking - ** the 'change-counter' field of the database file header and - ** discarded if they are found to be invalid. - ** - ** 2) If the pager is running in exclusive-mode, and there are currently - ** no outstanding references to any pages, and is in the error state, - ** then an attempt is made to clear the error state by discarding - ** the contents of the page cache and rolling back any open journal - ** file. - ** - ** If everything is successful, SQLITE_OK is returned. If an IO error - ** occurs while locking the database, checking for a hot-journal file or - ** rolling back a journal file, the IO error code is returned. - */ - static int sqlite3PagerSharedLock( Pager pPager ) - { - int rc = SQLITE_OK; /* Return code */ + /* + ** This function is called to obtain a shared lock on the database file. + ** It is illegal to call sqlite3PagerAcquire() until after this function + ** has been successfully called. If a shared-lock is already held when + ** this function is called, it is a no-op. + ** + ** The following operations are also performed by this function. + ** + ** 1) If the pager is currently in PAGER_OPEN state (no lock held + ** on the database file), then an attempt is made to obtain a + ** SHARED lock on the database file. Immediately after obtaining + ** the SHARED lock, the file-system is checked for a hot-journal, + ** which is played back if present. Following any hot-journal + ** rollback, the contents of the cache are validated by checking + ** the 'change-counter' field of the database file header and + ** discarded if they are found to be invalid. + ** + ** 2) If the pager is running in exclusive-mode, and there are currently + ** no outstanding references to any pages, and is in the error state, + ** then an attempt is made to clear the error state by discarding + ** the contents of the page cache and rolling back any open journal + ** file. + ** + ** If everything is successful, SQLITE_OK is returned. If an IO error + ** occurs while locking the database, checking for a hot-journal file or + ** rolling back a journal file, the IO error code is returned. + */ + static int sqlite3PagerSharedLock(Pager pPager) { + int rc = SQLITE_OK; /* Return code */ - /* This routine is only called from b-tree and only when there are no - ** outstanding pages. This implies that the pager state should either - ** be OPEN or READER. READER is only possible if the pager is or was in - ** exclusive access mode. - */ - Debug.Assert( sqlite3PcacheRefCount( pPager.pPCache ) == 0 ); - Debug.Assert( assert_pager_state( pPager ) ); - Debug.Assert( pPager.eState == PAGER_OPEN || pPager.eState == PAGER_READER ); - if ( NEVER( + /* This routine is only called from b-tree and only when there are no + ** outstanding pages. This implies that the pager state should either + ** be OPEN or READER. READER is only possible if the pager is or was in + ** exclusive access mode. + */ + Debug.Assert(sqlite3PcacheRefCount(pPager.pPCache) == 0); + Debug.Assert(assert_pager_state(pPager)); + Debug.Assert(pPager.eState == PAGER_OPEN || pPager.eState == PAGER_READER); + if (NEVER( #if SQLITE_OMIT_MEMORYDB 0!=MEMDB #else - 0 != pPager.memDb + 0 != pPager.memDb #endif - && pPager.errCode != 0 ) ) - { - return pPager.errCode; - } + && pPager.errCode != 0)) { + return pPager.errCode; + } - if ( !pagerUseWal( pPager ) && pPager.eState == PAGER_OPEN ) - { - int bHotJournal = 1; /* True if there exists a hot journal-file */ + if (!pagerUseWal(pPager) && pPager.eState == PAGER_OPEN) { + int bHotJournal = 1; /* True if there exists a hot journal-file */ - Debug.Assert( + Debug.Assert( #if SQLITE_OMIT_MEMORYDB 0==MEMDB #else - 0 == pPager.memDb + 0 == pPager.memDb #endif - ); - Debug.Assert( pPager.noReadlock == 0 || pPager.readOnly ); - - if ( pPager.noReadlock == 0 ) - { - rc = pager_wait_on_lock( pPager, SHARED_LOCK ); - if ( rc != SQLITE_OK ) - { - Debug.Assert( pPager.eLock == NO_LOCK || pPager.eLock == UNKNOWN_LOCK ); - goto failed; - } - } - - /* If a journal file exists, and there is no RESERVED lock on the - ** database file, then it either needs to be played back or deleted. - */ - if ( pPager.eLock <= SHARED_LOCK ) - { - rc = hasHotJournal( pPager, ref bHotJournal ); - } - if ( rc != SQLITE_OK ) - { - goto failed; - } - if ( bHotJournal != 0 ) - { - /* Get an EXCLUSIVE lock on the database file. At this point it is - ** important that a RESERVED lock is not obtained on the way to the - ** EXCLUSIVE lock. If it were, another process might open the - ** database file, detect the RESERVED lock, and conclude that the - ** database is safe to read while this process is still rolling the - ** hot-journal back. - ** - ** Because the intermediate RESERVED lock is not requested, any - ** other process attempting to access the database file will get to - ** this point in the code and fail to obtain its own EXCLUSIVE lock - ** on the database file. - ** - ** Unless the pager is in locking_mode=exclusive mode, the lock is - ** downgraded to SHARED_LOCK before this function returns. - */ - rc = pagerLockDb( pPager, EXCLUSIVE_LOCK ); - if ( rc != SQLITE_OK ) - { - goto failed; - } - - /* If it is not already open and the file exists on disk, open the - ** journal for read/write access. Write access is required because - ** in exclusive-access mode the file descriptor will be kept open - ** and possibly used for a transaction later on. Also, write-access - ** is usually required to finalize the journal in journal_mode=persist - ** mode (and also for journal_mode=truncate on some systems). - ** - ** If the journal does not exist, it usually means that some - ** other connection managed to get in and roll it back before - ** this connection obtained the exclusive lock above. Or, it - ** may mean that the pager was in the error-state when this - ** function was called and the journal file does not exist. - */ - if ( !isOpen( pPager.jfd ) ) - { - sqlite3_vfs pVfs = pPager.pVfs; - int bExists = 0; /* True if journal file exists */ - rc = sqlite3OsAccess( - pVfs, pPager.zJournal, SQLITE_ACCESS_EXISTS, ref bExists ); - if ( rc == SQLITE_OK && bExists != 0 ) - { - int fout = 0; - int f = SQLITE_OPEN_READWRITE | SQLITE_OPEN_MAIN_JOURNAL; - Debug.Assert( !pPager.tempFile ); - rc = sqlite3OsOpen( pVfs, pPager.zJournal, pPager.jfd, f, ref fout ); - Debug.Assert( rc != SQLITE_OK || isOpen( pPager.jfd ) ); - if ( rc == SQLITE_OK && ( fout & SQLITE_OPEN_READONLY ) != 0 ) - { - rc = SQLITE_CANTOPEN_BKPT(); - sqlite3OsClose( pPager.jfd ); - } - } - } - - /* Playback and delete the journal. Drop the database write - ** lock and reacquire the read lock. Purge the cache before - ** playing back the hot-journal so that we don't end up with - ** an inconsistent cache. Sync the hot journal before playing - ** it back since the process that crashed and left the hot journal - ** probably did not sync it and we are required to always sync - ** the journal before playing it back. - */ - if ( isOpen( pPager.jfd ) ) - { - Debug.Assert( rc == SQLITE_OK ); - rc = pagerSyncHotJournal( pPager ); - if ( rc == SQLITE_OK ) - { - rc = pager_playback( pPager, 1 ); - pPager.eState = PAGER_OPEN; - } - } - else if ( !pPager.exclusiveMode ) - { - pagerUnlockDb( pPager, SHARED_LOCK ); - } - - if ( rc != SQLITE_OK ) - { - /* This branch is taken if an error occurs while trying to open - ** or roll back a hot-journal while holding an EXCLUSIVE lock. The - ** pager_unlock() routine will be called before returning to unlock - ** the file. If the unlock attempt fails, then Pager.eLock must be - ** set to UNKNOWN_LOCK (see the comment above the #define for - ** UNKNOWN_LOCK above for an explanation). - ** - ** In order to get pager_unlock() to do this, set Pager.eState to - ** PAGER_ERROR now. This is not actually counted as a transition - ** to ERROR state in the state diagram at the top of this file, - ** since we know that the same call to pager_unlock() will very - ** shortly transition the pager object to the OPEN state. Calling - ** assert_pager_state() would fail now, as it should not be possible - ** to be in ERROR state when there are zero outstanding page - ** references. - */ - pager_error( pPager, rc ); - goto failed; - } - - Debug.Assert( pPager.eState == PAGER_OPEN ); - Debug.Assert( ( pPager.eLock == SHARED_LOCK ) - || ( pPager.exclusiveMode && pPager.eLock > SHARED_LOCK ) - ); - } - - if ( !pPager.tempFile - && ( pPager.pBackup != null || sqlite3PcachePagecount( pPager.pPCache ) > 0 ) - ) - { - /* The shared-lock has just been acquired on the database file - ** and there are already pages in the cache (from a previous - ** read or write transaction). Check to see if the database - ** has been modified. If the database has changed, flush the - ** cache. - ** - ** Database changes is detected by looking at 15 bytes beginning - ** at offset 24 into the file. The first 4 of these 16 bytes are - ** a 32-bit counter that is incremented with each change. The - ** other bytes change randomly with each file change when - ** a codec is in use. - ** - ** There is a vanishingly small chance that a change will not be - ** detected. The chance of an undetected change is so small that - ** it can be neglected. - */ - Pgno nPage = 0; - byte[] dbFileVers = new byte[pPager.dbFileVers.Length]; - - rc = pagerPagecount( pPager, ref nPage ); - if ( rc != 0 ) - goto failed; + ); + Debug.Assert(pPager.noReadlock == 0 || pPager.readOnly); + + if (pPager.noReadlock == 0) { + rc = pager_wait_on_lock(pPager, SHARED_LOCK); + if (rc != SQLITE_OK) { + Debug.Assert(pPager.eLock == NO_LOCK || pPager.eLock == UNKNOWN_LOCK); + goto failed; + } + } - if ( nPage > 0 ) - { - IOTRACE( "CKVERS %p %d\n", pPager, dbFileVers.Length ); - rc = sqlite3OsRead( pPager.fd, dbFileVers, dbFileVers.Length, 24 ); - if ( rc != SQLITE_OK ) - { - goto failed; - } - } - else - { - Array.Clear( dbFileVers, 0, dbFileVers.Length );// memset( dbFileVers, 0, sizeof( dbFileVers ) ); - } + /* If a journal file exists, and there is no RESERVED lock on the + ** database file, then it either needs to be played back or deleted. + */ + if (pPager.eLock <= SHARED_LOCK) { + rc = hasHotJournal(pPager, ref bHotJournal); + } + if (rc != SQLITE_OK) { + goto failed; + } + if (bHotJournal != 0) { + /* Get an EXCLUSIVE lock on the database file. At this point it is + ** important that a RESERVED lock is not obtained on the way to the + ** EXCLUSIVE lock. If it were, another process might open the + ** database file, detect the RESERVED lock, and conclude that the + ** database is safe to read while this process is still rolling the + ** hot-journal back. + ** + ** Because the intermediate RESERVED lock is not requested, any + ** other process attempting to access the database file will get to + ** this point in the code and fail to obtain its own EXCLUSIVE lock + ** on the database file. + ** + ** Unless the pager is in locking_mode=exclusive mode, the lock is + ** downgraded to SHARED_LOCK before this function returns. + */ + rc = pagerLockDb(pPager, EXCLUSIVE_LOCK); + if (rc != SQLITE_OK) { + goto failed; + } + + /* If it is not already open and the file exists on disk, open the + ** journal for read/write access. Write access is required because + ** in exclusive-access mode the file descriptor will be kept open + ** and possibly used for a transaction later on. Also, write-access + ** is usually required to finalize the journal in journal_mode=persist + ** mode (and also for journal_mode=truncate on some systems). + ** + ** If the journal does not exist, it usually means that some + ** other connection managed to get in and roll it back before + ** this connection obtained the exclusive lock above. Or, it + ** may mean that the pager was in the error-state when this + ** function was called and the journal file does not exist. + */ + if (!isOpen(pPager.jfd)) { + sqlite3_vfs pVfs = pPager.pVfs; + int bExists = 0; /* True if journal file exists */ + rc = sqlite3OsAccess( + pVfs, pPager.zJournal, SQLITE_ACCESS_EXISTS, ref bExists); + if (rc == SQLITE_OK && bExists != 0) { + int fout = 0; + int f = SQLITE_OPEN_READWRITE | SQLITE_OPEN_MAIN_JOURNAL; + Debug.Assert(!pPager.tempFile); + rc = sqlite3OsOpen(pVfs, pPager.zJournal, pPager.jfd, f, ref fout); + Debug.Assert(rc != SQLITE_OK || isOpen(pPager.jfd)); + if (rc == SQLITE_OK && (fout & SQLITE_OPEN_READONLY) != 0) { + rc = SQLITE_CANTOPEN_BKPT(); + sqlite3OsClose(pPager.jfd); + } + } + } + + /* Playback and delete the journal. Drop the database write + ** lock and reacquire the read lock. Purge the cache before + ** playing back the hot-journal so that we don't end up with + ** an inconsistent cache. Sync the hot journal before playing + ** it back since the process that crashed and left the hot journal + ** probably did not sync it and we are required to always sync + ** the journal before playing it back. + */ + if (isOpen(pPager.jfd)) { + Debug.Assert(rc == SQLITE_OK); + rc = pagerSyncHotJournal(pPager); + if (rc == SQLITE_OK) { + rc = pager_playback(pPager, 1); + pPager.eState = PAGER_OPEN; + } + } else if (!pPager.exclusiveMode) { + pagerUnlockDb(pPager, SHARED_LOCK); + } + + if (rc != SQLITE_OK) { + /* This branch is taken if an error occurs while trying to open + ** or roll back a hot-journal while holding an EXCLUSIVE lock. The + ** pager_unlock() routine will be called before returning to unlock + ** the file. If the unlock attempt fails, then Pager.eLock must be + ** set to UNKNOWN_LOCK (see the comment above the #define for + ** UNKNOWN_LOCK above for an explanation). + ** + ** In order to get pager_unlock() to do this, set Pager.eState to + ** PAGER_ERROR now. This is not actually counted as a transition + ** to ERROR state in the state diagram at the top of this file, + ** since we know that the same call to pager_unlock() will very + ** shortly transition the pager object to the OPEN state. Calling + ** assert_pager_state() would fail now, as it should not be possible + ** to be in ERROR state when there are zero outstanding page + ** references. + */ + pager_error(pPager, rc); + goto failed; + } + + Debug.Assert(pPager.eState == PAGER_OPEN); + Debug.Assert((pPager.eLock == SHARED_LOCK) + || (pPager.exclusiveMode && pPager.eLock > SHARED_LOCK) + ); + } - if ( memcmp( pPager.dbFileVers, dbFileVers, dbFileVers.Length ) != 0 ) - { - pager_reset( pPager ); - } - } + if (!pPager.tempFile + && (pPager.pBackup != null || sqlite3PcachePagecount(pPager.pPCache) > 0) + ) { + /* The shared-lock has just been acquired on the database file + ** and there are already pages in the cache (from a previous + ** read or write transaction). Check to see if the database + ** has been modified. If the database has changed, flush the + ** cache. + ** + ** Database changes is detected by looking at 15 bytes beginning + ** at offset 24 into the file. The first 4 of these 16 bytes are + ** a 32-bit counter that is incremented with each change. The + ** other bytes change randomly with each file change when + ** a codec is in use. + ** + ** There is a vanishingly small chance that a change will not be + ** detected. The chance of an undetected change is so small that + ** it can be neglected. + */ + Pgno nPage = 0; + byte[] dbFileVers = new byte[pPager.dbFileVers.Length]; + + rc = pagerPagecount(pPager, ref nPage); + if (rc != 0) + goto failed; + + if (nPage > 0) { + IOTRACE("CKVERS %p %d\n", pPager, dbFileVers.Length); + rc = sqlite3OsRead(pPager.fd, dbFileVers, dbFileVers.Length, 24); + if (rc != SQLITE_OK) { + goto failed; + } + } else { + Array.Clear(dbFileVers, 0, dbFileVers.Length);// memset( dbFileVers, 0, sizeof( dbFileVers ) ); + } + + if (memcmp(pPager.dbFileVers, dbFileVers, dbFileVers.Length) != 0) { + pager_reset(pPager); + } + } - /* If there is a WAL file in the file-system, open this database in WAL - ** mode. Otherwise, the following function call is a no-op. - */ - rc = pagerOpenWalIfPresent( pPager ); + /* If there is a WAL file in the file-system, open this database in WAL + ** mode. Otherwise, the following function call is a no-op. + */ + rc = pagerOpenWalIfPresent(pPager); #if !SQLITE_OMIT_WAL Debug.Assert( pPager.pWal == null || rc == SQLITE_OK ); #endif - } + } - if ( pagerUseWal( pPager ) ) - { - Debug.Assert( rc == SQLITE_OK ); - rc = pagerBeginReadTransaction( pPager ); - } + if (pagerUseWal(pPager)) { + Debug.Assert(rc == SQLITE_OK); + rc = pagerBeginReadTransaction(pPager); + } - if ( pPager.eState == PAGER_OPEN && rc == SQLITE_OK ) - { - rc = pagerPagecount( pPager, ref pPager.dbSize ); - } + if (pPager.eState == PAGER_OPEN && rc == SQLITE_OK) { + rc = pagerPagecount(pPager, ref pPager.dbSize); + } -failed: - if ( rc != SQLITE_OK ) - { - Debug.Assert( + failed: + if (rc != SQLITE_OK) { + Debug.Assert( #if SQLITE_OMIT_MEMORYDB 0==MEMDB -#else - 0 == pPager.memDb -#endif - ); - pager_unlock( pPager ); - Debug.Assert( pPager.eState == PAGER_OPEN ); - } - else - { - pPager.eState = PAGER_READER; - } - return rc; - } - - /* - ** If the reference count has reached zero, rollback any active - ** transaction and unlock the pager. - ** - ** Except, in locking_mode=EXCLUSIVE when there is nothing to in - ** the rollback journal, the unlock is not performed and there is - ** nothing to rollback, so this routine is a no-op. - */ - static void pagerUnlockIfUnused( Pager pPager ) - { - if ( sqlite3PcacheRefCount( pPager.pPCache ) == 0 ) - { - pagerUnlockAndRollback( pPager ); - } - } - - /* - ** Acquire a reference to page number pgno in pager pPager (a page - ** reference has type DbPage*). If the requested reference is - ** successfully obtained, it is copied to *ppPage and SQLITE_OK returned. - ** - ** If the requested page is already in the cache, it is returned. - ** Otherwise, a new page object is allocated and populated with data - ** read from the database file. In some cases, the pcache module may - ** choose not to allocate a new page object and may reuse an existing - ** object with no outstanding references. - ** - ** The extra data appended to a page is always initialized to zeros the - ** first time a page is loaded into memory. If the page requested is - ** already in the cache when this function is called, then the extra - ** data is left as it was when the page object was last used. - ** - ** If the database image is smaller than the requested page or if a - ** non-zero value is passed as the noContent parameter and the - ** requested page is not already stored in the cache, then no - ** actual disk read occurs. In this case the memory image of the - ** page is initialized to all zeros. - ** - ** If noContent is true, it means that we do not care about the contents - ** of the page. This occurs in two seperate scenarios: - ** - ** a) When reading a free-list leaf page from the database, and - ** - ** b) When a savepoint is being rolled back and we need to load - ** a new page into the cache to be filled with the data read - ** from the savepoint journal. - ** - ** If noContent is true, then the data returned is zeroed instead of - ** being read from the database. Additionally, the bits corresponding - ** to pgno in Pager.pInJournal (bitvec of pages already written to the - ** journal file) and the PagerSavepoint.pInSavepoint bitvecs of any open - ** savepoints are set. This means if the page is made writable at any - ** point in the future, using a call to sqlite3PagerWrite(), its contents - ** will not be journaled. This saves IO. - ** - ** The acquisition might fail for several reasons. In all cases, - ** an appropriate error code is returned and *ppPage is set to NULL. - ** - ** See also sqlite3PagerLookup(). Both this routine and Lookup() attempt - ** to find a page in the in-memory cache first. If the page is not already - ** in memory, this routine goes to disk to read it in whereas Lookup() - ** just returns 0. This routine acquires a read-lock the first time it - ** has to go to disk, and could also playback an old journal if necessary. - ** Since Lookup() never goes to disk, it never has to deal with locks - ** or journal files. - */ - - // Under C# from the header file - //#define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0) +#else + 0 == pPager.memDb +#endif + ); + pager_unlock(pPager); + Debug.Assert(pPager.eState == PAGER_OPEN); + } else { + pPager.eState = PAGER_READER; + } + return rc; + } - static int sqlite3PagerGet( - Pager pPager, /* The pager open on the database file */ - u32 pgno, /* Page number to fetch */ - ref DbPage ppPage /* Write a pointer to the page here */ - ) - { - return sqlite3PagerAcquire( pPager, pgno, ref ppPage, 0 ); - } + /* + ** If the reference count has reached zero, rollback any active + ** transaction and unlock the pager. + ** + ** Except, in locking_mode=EXCLUSIVE when there is nothing to in + ** the rollback journal, the unlock is not performed and there is + ** nothing to rollback, so this routine is a no-op. + */ + static void pagerUnlockIfUnused(Pager pPager) { + if (sqlite3PcacheRefCount(pPager.pPCache) == 0) { + pagerUnlockAndRollback(pPager); + } + } - static int sqlite3PagerAcquire( - Pager pPager, /* The pager open on the database file */ - u32 pgno, /* Page number to fetch */ - ref DbPage ppPage, /* Write a pointer to the page here */ - u8 noContent /* Do not bother reading content from disk if true */ - ) - { - int rc; - PgHdr pPg = null; + /* + ** Acquire a reference to page number pgno in pager pPager (a page + ** reference has type DbPage*). If the requested reference is + ** successfully obtained, it is copied to *ppPage and SQLITE_OK returned. + ** + ** If the requested page is already in the cache, it is returned. + ** Otherwise, a new page object is allocated and populated with data + ** read from the database file. In some cases, the pcache module may + ** choose not to allocate a new page object and may reuse an existing + ** object with no outstanding references. + ** + ** The extra data appended to a page is always initialized to zeros the + ** first time a page is loaded into memory. If the page requested is + ** already in the cache when this function is called, then the extra + ** data is left as it was when the page object was last used. + ** + ** If the database image is smaller than the requested page or if a + ** non-zero value is passed as the noContent parameter and the + ** requested page is not already stored in the cache, then no + ** actual disk read occurs. In this case the memory image of the + ** page is initialized to all zeros. + ** + ** If noContent is true, it means that we do not care about the contents + ** of the page. This occurs in two seperate scenarios: + ** + ** a) When reading a free-list leaf page from the database, and + ** + ** b) When a savepoint is being rolled back and we need to load + ** a new page into the cache to be filled with the data read + ** from the savepoint journal. + ** + ** If noContent is true, then the data returned is zeroed instead of + ** being read from the database. Additionally, the bits corresponding + ** to pgno in Pager.pInJournal (bitvec of pages already written to the + ** journal file) and the PagerSavepoint.pInSavepoint bitvecs of any open + ** savepoints are set. This means if the page is made writable at any + ** point in the future, using a call to sqlite3PagerWrite(), its contents + ** will not be journaled. This saves IO. + ** + ** The acquisition might fail for several reasons. In all cases, + ** an appropriate error code is returned and *ppPage is set to NULL. + ** + ** See also sqlite3PagerLookup(). Both this routine and Lookup() attempt + ** to find a page in the in-memory cache first. If the page is not already + ** in memory, this routine goes to disk to read it in whereas Lookup() + ** just returns 0. This routine acquires a read-lock the first time it + ** has to go to disk, and could also playback an old journal if necessary. + ** Since Lookup() never goes to disk, it never has to deal with locks + ** or journal files. + */ - Debug.Assert( pPager.eState >= PAGER_READER ); - Debug.Assert( assert_pager_state( pPager ) ); - if ( pgno == 0 ) - { - return SQLITE_CORRUPT_BKPT(); - } + // Under C# from the header file + //#define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0) - /* If the pager is in the error state, return an error immediately. - ** Otherwise, request the page from the PCache layer. */ - if ( pPager.errCode != SQLITE_OK ) - { - rc = pPager.errCode; - } - else - { - rc = sqlite3PcacheFetch( pPager.pPCache, pgno, 1, ref ppPage ); - } + static int sqlite3PagerGet( + Pager pPager, /* The pager open on the database file */ + u32 pgno, /* Page number to fetch */ + ref DbPage ppPage /* Write a pointer to the page here */ + ) { + return sqlite3PagerAcquire(pPager, pgno, ref ppPage, 0); + } - if ( rc != SQLITE_OK ) - { - /* Either the call to sqlite3PcacheFetch() returned an error or the - ** pager was already in the error-state when this function was called. - ** Set pPg to 0 and jump to the exception handler. */ - pPg = null; - goto pager_acquire_err; - } - Debug.Assert( ( ppPage ).pgno == pgno ); - Debug.Assert( ( ppPage ).pPager == pPager || ( ppPage ).pPager == null ); + static int sqlite3PagerAcquire( + Pager pPager, /* The pager open on the database file */ + u32 pgno, /* Page number to fetch */ + ref DbPage ppPage, /* Write a pointer to the page here */ + u8 noContent /* Do not bother reading content from disk if true */ + ) { + int rc; + PgHdr pPg = null; + + Debug.Assert(pPager.eState >= PAGER_READER); + Debug.Assert(assert_pager_state(pPager)); + if (pgno == 0) { + return SQLITE_CORRUPT_BKPT(); + } - if ( ( ppPage ).pPager != null && 0 == noContent ) - { - /* In this case the pcache already contains an initialized copy of - ** the page. Return without further ado. */ - Debug.Assert( pgno <= PAGER_MAX_PGNO && pgno != PAGER_MJ_PGNO( pPager ) ); - PAGER_INCR( ref pPager.nHit ); - return SQLITE_OK; + /* If the pager is in the error state, return an error immediately. + ** Otherwise, request the page from the PCache layer. */ + if (pPager.errCode != SQLITE_OK) { + rc = pPager.errCode; + } else { + rc = sqlite3PcacheFetch(pPager.pPCache, pgno, 1, ref ppPage); + } - } - else - { - /* The pager cache has created a new page. Its content needs to - ** be initialized. */ + if (rc != SQLITE_OK) { + /* Either the call to sqlite3PcacheFetch() returned an error or the + ** pager was already in the error-state when this function was called. + ** Set pPg to 0 and jump to the exception handler. */ + pPg = null; + goto pager_acquire_err; + } + Debug.Assert((ppPage).pgno == pgno); + Debug.Assert((ppPage).pPager == pPager || (ppPage).pPager == null); + + if ((ppPage).pPager != null && 0 == noContent) { + /* In this case the pcache already contains an initialized copy of + ** the page. Return without further ado. */ + Debug.Assert(pgno <= PAGER_MAX_PGNO && pgno != PAGER_MJ_PGNO(pPager)); + PAGER_INCR(ref pPager.nHit); + return SQLITE_OK; + + } else { + /* The pager cache has created a new page. Its content needs to + ** be initialized. */ #if SQLITE_TEST PAGER_INCR( ref pPager.nMiss ); #endif - pPg = ppPage; - pPg.pPager = pPager; - pPg.pExtra = new MemPage();//memset(pPg.pExtra, 0, pPager.nExtra); - - /* The maximum page number is 2^31. Return SQLITE_CORRUPT if a page - ** number greater than this, or the unused locking-page, is requested. */ - if ( pgno > PAGER_MAX_PGNO || pgno == PAGER_MJ_PGNO( pPager ) ) - { - rc = SQLITE_CORRUPT_BKPT(); - goto pager_acquire_err; - } - if ( + pPg = ppPage; + pPg.pPager = pPager; + pPg.pExtra = new MemPage();//memset(pPg.pExtra, 0, pPager.nExtra); + + /* The maximum page number is 2^31. Return SQLITE_CORRUPT if a page + ** number greater than this, or the unused locking-page, is requested. */ + if (pgno > PAGER_MAX_PGNO || pgno == PAGER_MJ_PGNO(pPager)) { + rc = SQLITE_CORRUPT_BKPT(); + goto pager_acquire_err; + } + if ( #if SQLITE_OMIT_MEMORYDB 1==MEMDB #else - pPager.memDb != 0 + pPager.memDb != 0 #endif - || pPager.dbSize < pgno || noContent != 0 || !isOpen( pPager.fd ) ) - { - if ( pgno > pPager.mxPgno ) - { - rc = SQLITE_FULL; - goto pager_acquire_err; - } - if ( noContent != 0 ) - { - /* Failure to set the bits in the InJournal bit-vectors is benign. - ** It merely means that we might do some extra work to journal a - ** page that does not need to be journaled. Nevertheless, be sure - ** to test the case where a malloc error occurs while trying to set - ** a bit in a bit vector. - */ - sqlite3BeginBenignMalloc(); - if ( pgno <= pPager.dbOrigSize ) - { + || pPager.dbSize < pgno || noContent != 0 || !isOpen(pPager.fd)) { + if (pgno > pPager.mxPgno) { + rc = SQLITE_FULL; + goto pager_acquire_err; + } + if (noContent != 0) { + /* Failure to set the bits in the InJournal bit-vectors is benign. + ** It merely means that we might do some extra work to journal a + ** page that does not need to be journaled. Nevertheless, be sure + ** to test the case where a malloc error occurs while trying to set + ** a bit in a bit vector. + */ + sqlite3BeginBenignMalloc(); + if (pgno <= pPager.dbOrigSize) { #if !NDEBUG || SQLITE_COVERAGE_TEST - rc = sqlite3BitvecSet( pPager.pInJournal, pgno ); //TESTONLY( rc = ) sqlite3BitvecSet(pPager.pInJournal, pgno); + rc = sqlite3BitvecSet(pPager.pInJournal, pgno); //TESTONLY( rc = ) sqlite3BitvecSet(pPager.pInJournal, pgno); #else sqlite3BitvecSet(pPager.pInJournal, pgno); #endif - testcase( rc == SQLITE_NOMEM ); - } + testcase(rc == SQLITE_NOMEM); + } #if !NDEBUG || SQLITE_COVERAGE_TEST - rc = addToSavepointBitvecs( pPager, pgno ); //TESTONLY( rc = ) addToSavepointBitvecs(pPager, pgno); + rc = addToSavepointBitvecs(pPager, pgno); //TESTONLY( rc = ) addToSavepointBitvecs(pPager, pgno); #else addToSavepointBitvecs(pPager, pgno); #endif - testcase( rc == SQLITE_NOMEM ); - sqlite3EndBenignMalloc(); - } - //memset(pPg.pData, 0, pPager.pageSize); - Array.Clear( pPg.pData, 0, pPager.pageSize ); - IOTRACE( "ZERO %p %d\n", pPager, pgno ); - } - else - { - Debug.Assert( pPg.pPager == pPager ); - rc = readDbPage( pPg ); - if ( rc != SQLITE_OK ) - { - goto pager_acquire_err; - } - } - - pager_set_pagehash( pPg ); - } - return SQLITE_OK; - -pager_acquire_err: - Debug.Assert( rc != SQLITE_OK ); - if ( pPg != null ) - { - sqlite3PcacheDrop( pPg ); - } - pagerUnlockIfUnused( pPager ); - - ppPage = null; - return rc; - } + testcase(rc == SQLITE_NOMEM); + sqlite3EndBenignMalloc(); + } + //memset(pPg.pData, 0, pPager.pageSize); + Array.Clear(pPg.pData, 0, pPager.pageSize); + IOTRACE("ZERO %p %d\n", pPager, pgno); + } else { + Debug.Assert(pPg.pPager == pPager); + rc = readDbPage(pPg); + if (rc != SQLITE_OK) { + goto pager_acquire_err; + } + } - /* - ** Acquire a page if it is already in the in-memory cache. Do - ** not read the page from disk. Return a pointer to the page, - ** or 0 if the page is not in cache. - ** - ** See also sqlite3PagerGet(). The difference between this routine - ** and sqlite3PagerGet() is that _get() will go to the disk and read - ** in the page if the page is not already in cache. This routine - ** returns NULL if the page is not in cache or if a disk I/O error - ** has ever happened. - */ - static DbPage sqlite3PagerLookup( Pager pPager, u32 pgno ) - { - PgHdr pPg = null; + pager_set_pagehash(pPg); + } + return SQLITE_OK; - Debug.Assert( pPager != null ); - Debug.Assert( pgno != 0 ); - Debug.Assert( pPager.pPCache != null ); - Debug.Assert( pPager.eState >= PAGER_READER && pPager.eState != PAGER_ERROR ); - sqlite3PcacheFetch( pPager.pPCache, pgno, 0, ref pPg ); + pager_acquire_err: + Debug.Assert(rc != SQLITE_OK); + if (pPg != null) { + sqlite3PcacheDrop(pPg); + } + pagerUnlockIfUnused(pPager); - return pPg; - } + ppPage = null; + return rc; + } - /* - ** Release a page reference. - ** - ** If the number of references to the page drop to zero, then the - ** page is added to the LRU list. When all references to all pages - ** are released, a rollback occurs and the lock on the database is - ** removed. - */ - static void sqlite3PagerUnref( DbPage pPg ) - { - if ( pPg != null ) - { - Pager pPager = pPg.pPager; - sqlite3PcacheRelease( pPg ); - pagerUnlockIfUnused( pPager ); - } - } + /* + ** Acquire a page if it is already in the in-memory cache. Do + ** not read the page from disk. Return a pointer to the page, + ** or 0 if the page is not in cache. + ** + ** See also sqlite3PagerGet(). The difference between this routine + ** and sqlite3PagerGet() is that _get() will go to the disk and read + ** in the page if the page is not already in cache. This routine + ** returns NULL if the page is not in cache or if a disk I/O error + ** has ever happened. + */ + static DbPage sqlite3PagerLookup(Pager pPager, u32 pgno) { + PgHdr pPg = null; - /* - ** This function is called at the start of every write transaction. - ** There must already be a RESERVED or EXCLUSIVE lock on the database - ** file when this routine is called. - ** - ** Open the journal file for pager pPager and write a journal header - ** to the start of it. If there are active savepoints, open the sub-journal - ** as well. This function is only used when the journal file is being - ** opened to write a rollback log for a transaction. It is not used - ** when opening a hot journal file to roll it back. - ** - ** If the journal file is already open (as it may be in exclusive mode), - ** then this function just writes a journal header to the start of the - ** already open file. - ** - ** Whether or not the journal file is opened by this function, the - ** Pager.pInJournal bitvec structure is allocated. - ** - ** Return SQLITE_OK if everything is successful. Otherwise, return - ** SQLITE_NOMEM if the attempt to allocate Pager.pInJournal fails, or - ** an IO error code if opening or writing the journal file fails. - */ - static int pager_open_journal( Pager pPager ) - { - int rc = SQLITE_OK; /* Return code */ - sqlite3_vfs pVfs = pPager.pVfs; /* Local cache of vfs pointer */ + Debug.Assert(pPager != null); + Debug.Assert(pgno != 0); + Debug.Assert(pPager.pPCache != null); + Debug.Assert(pPager.eState >= PAGER_READER && pPager.eState != PAGER_ERROR); + sqlite3PcacheFetch(pPager.pPCache, pgno, 0, ref pPg); - Debug.Assert( pPager.eState == PAGER_WRITER_LOCKED ); - Debug.Assert( assert_pager_state( pPager ) ); - Debug.Assert( pPager.pInJournal == null ); + return pPg; + } - /* If already in the error state, this function is a no-op. But on - ** the other hand, this routine is never called if we are already in - ** an error state. */ - if ( NEVER( pPager.errCode ) != 0 ) - return pPager.errCode; + /* + ** Release a page reference. + ** + ** If the number of references to the page drop to zero, then the + ** page is added to the LRU list. When all references to all pages + ** are released, a rollback occurs and the lock on the database is + ** removed. + */ + static void sqlite3PagerUnref(DbPage pPg) { + if (pPg != null) { + Pager pPager = pPg.pPager; + sqlite3PcacheRelease(pPg); + pagerUnlockIfUnused(pPager); + } + } - if ( !pagerUseWal( pPager ) && pPager.journalMode != PAGER_JOURNALMODE_OFF ) - { - pPager.pInJournal = sqlite3BitvecCreate( pPager.dbSize ); - //if (pPager.pInJournal == null) - //{ - // return SQLITE_NOMEM; - //} - - /* Open the journal file if it is not already open. */ - if ( !isOpen( pPager.jfd ) ) - { - if ( pPager.journalMode == PAGER_JOURNALMODE_MEMORY ) - { - sqlite3MemJournalOpen( pPager.jfd ); - } - else - { - int flags = /* VFS flags to open journal file */ - SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | - ( pPager.tempFile ? - ( SQLITE_OPEN_DELETEONCLOSE | SQLITE_OPEN_TEMP_JOURNAL ) : - ( SQLITE_OPEN_MAIN_JOURNAL ) - ); + /* + ** This function is called at the start of every write transaction. + ** There must already be a RESERVED or EXCLUSIVE lock on the database + ** file when this routine is called. + ** + ** Open the journal file for pager pPager and write a journal header + ** to the start of it. If there are active savepoints, open the sub-journal + ** as well. This function is only used when the journal file is being + ** opened to write a rollback log for a transaction. It is not used + ** when opening a hot journal file to roll it back. + ** + ** If the journal file is already open (as it may be in exclusive mode), + ** then this function just writes a journal header to the start of the + ** already open file. + ** + ** Whether or not the journal file is opened by this function, the + ** Pager.pInJournal bitvec structure is allocated. + ** + ** Return SQLITE_OK if everything is successful. Otherwise, return + ** SQLITE_NOMEM if the attempt to allocate Pager.pInJournal fails, or + ** an IO error code if opening or writing the journal file fails. + */ + static int pager_open_journal(Pager pPager) { + int rc = SQLITE_OK; /* Return code */ + sqlite3_vfs pVfs = pPager.pVfs; /* Local cache of vfs pointer */ + + Debug.Assert(pPager.eState == PAGER_WRITER_LOCKED); + Debug.Assert(assert_pager_state(pPager)); + Debug.Assert(pPager.pInJournal == null); + + /* If already in the error state, this function is a no-op. But on + ** the other hand, this routine is never called if we are already in + ** an error state. */ + if (NEVER(pPager.errCode) != 0) + return pPager.errCode; + + if (!pagerUseWal(pPager) && pPager.journalMode != PAGER_JOURNALMODE_OFF) { + pPager.pInJournal = sqlite3BitvecCreate(pPager.dbSize); + //if (pPager.pInJournal == null) + //{ + // return SQLITE_NOMEM; + //} + + /* Open the journal file if it is not already open. */ + if (!isOpen(pPager.jfd)) { + if (pPager.journalMode == PAGER_JOURNALMODE_MEMORY) { + sqlite3MemJournalOpen(pPager.jfd); + } else { + int flags = /* VFS flags to open journal file */ + SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | + (pPager.tempFile ? + (SQLITE_OPEN_DELETEONCLOSE | SQLITE_OPEN_TEMP_JOURNAL) : + (SQLITE_OPEN_MAIN_JOURNAL) + ); #if SQLITE_ENABLE_ATOMIC_WRITE rc = sqlite3JournalOpen( pVfs, pPager.zJournal, pPager.jfd, flags, jrnlBufferSize(pPager) ); #else - int int0 = 0; - rc = sqlite3OsOpen( pVfs, pPager.zJournal, pPager.jfd, flags, ref int0 ); + int int0 = 0; + rc = sqlite3OsOpen(pVfs, pPager.zJournal, pPager.jfd, flags, ref int0); #endif - } - Debug.Assert( rc != SQLITE_OK || isOpen( pPager.jfd ) ); + } + Debug.Assert(rc != SQLITE_OK || isOpen(pPager.jfd)); + } + + /* Write the first journal header to the journal file and open + ** the sub-journal if necessary. + */ + if (rc == SQLITE_OK) { + /* TODO: Check if all of these are really required. */ + pPager.nRec = 0; + pPager.journalOff = 0; + pPager.setMaster = 0; + pPager.journalHdr = 0; + rc = writeJournalHdr(pPager); + } + } + if (rc != SQLITE_OK) { + sqlite3BitvecDestroy(ref pPager.pInJournal); + pPager.pInJournal = null; + } else { + Debug.Assert(pPager.eState == PAGER_WRITER_LOCKED); + pPager.eState = PAGER_WRITER_CACHEMOD; + } + return rc; } - /* Write the first journal header to the journal file and open - ** the sub-journal if necessary. + /* + ** Begin a write-transaction on the specified pager object. If a + ** write-transaction has already been opened, this function is a no-op. + ** + ** If the exFlag argument is false, then acquire at least a RESERVED + ** lock on the database file. If exFlag is true, then acquire at least + ** an EXCLUSIVE lock. If such a lock is already held, no locking + ** functions need be called. + ** + ** If the subjInMemory argument is non-zero, then any sub-journal opened + ** within this transaction will be opened as an in-memory file. This + ** has no effect if the sub-journal is already opened (as it may be when + ** running in exclusive mode) or if the transaction does not require a + ** sub-journal. If the subjInMemory argument is zero, then any required + ** sub-journal is implemented in-memory if pPager is an in-memory database, + ** or using a temporary file otherwise. */ - if ( rc == SQLITE_OK ) - { - /* TODO: Check if all of these are really required. */ - pPager.nRec = 0; - pPager.journalOff = 0; - pPager.setMaster = 0; - pPager.journalHdr = 0; - rc = writeJournalHdr( pPager ); - } - } - if ( rc != SQLITE_OK ) - { - sqlite3BitvecDestroy( ref pPager.pInJournal ); - pPager.pInJournal = null; - } - else - { - Debug.Assert( pPager.eState == PAGER_WRITER_LOCKED ); - pPager.eState = PAGER_WRITER_CACHEMOD; - } - return rc; - } + static int sqlite3PagerBegin(Pager pPager, bool exFlag, int subjInMemory) { + int rc = SQLITE_OK; + if (pPager.errCode != 0) + return pPager.errCode; + Debug.Assert(pPager.eState >= PAGER_READER && pPager.eState < PAGER_ERROR); + pPager.subjInMemory = (u8)subjInMemory; + if (ALWAYS(pPager.eState == PAGER_READER)) { + Debug.Assert(pPager.pInJournal == null); + if (pagerUseWal(pPager)) { + /* If the pager is configured to use locking_mode=exclusive, and an + ** exclusive lock on the database is not already held, obtain it now. + */ + if (pPager.exclusiveMode && sqlite3WalExclusiveMode(pPager.pWal, -1)) { + rc = pagerLockDb(pPager, EXCLUSIVE_LOCK); + if (rc != SQLITE_OK) { + return rc; + } + sqlite3WalExclusiveMode(pPager.pWal, 1); + } + + /* Grab the write lock on the log file. If successful, upgrade to + ** PAGER_RESERVED state. Otherwise, return an error code to the caller. + ** The busy-handler is not invoked if another connection already + ** holds the write-lock. If possible, the upper layer will call it. + */ + rc = sqlite3WalBeginWriteTransaction(pPager.pWal); + } else { + /* Obtain a RESERVED lock on the database file. If the exFlag parameter + ** is true, then immediately upgrade this to an EXCLUSIVE lock. The + ** busy-handler callback can be used when upgrading to the EXCLUSIVE + ** lock, but not when obtaining the RESERVED lock. + */ + rc = pagerLockDb(pPager, RESERVED_LOCK); + if (rc == SQLITE_OK && exFlag) { + rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK); + } + } - /* - ** Begin a write-transaction on the specified pager object. If a - ** write-transaction has already been opened, this function is a no-op. - ** - ** If the exFlag argument is false, then acquire at least a RESERVED - ** lock on the database file. If exFlag is true, then acquire at least - ** an EXCLUSIVE lock. If such a lock is already held, no locking - ** functions need be called. - ** - ** If the subjInMemory argument is non-zero, then any sub-journal opened - ** within this transaction will be opened as an in-memory file. This - ** has no effect if the sub-journal is already opened (as it may be when - ** running in exclusive mode) or if the transaction does not require a - ** sub-journal. If the subjInMemory argument is zero, then any required - ** sub-journal is implemented in-memory if pPager is an in-memory database, - ** or using a temporary file otherwise. - */ - static int sqlite3PagerBegin( Pager pPager, bool exFlag, int subjInMemory ) - { - int rc = SQLITE_OK; - if ( pPager.errCode != 0 ) - return pPager.errCode; - Debug.Assert( pPager.eState >= PAGER_READER && pPager.eState < PAGER_ERROR ); - pPager.subjInMemory = (u8)subjInMemory; - if ( ALWAYS( pPager.eState == PAGER_READER ) ) - { - Debug.Assert( pPager.pInJournal == null ); - if ( pagerUseWal( pPager ) ) - { - /* If the pager is configured to use locking_mode=exclusive, and an - ** exclusive lock on the database is not already held, obtain it now. - */ - if ( pPager.exclusiveMode && sqlite3WalExclusiveMode( pPager.pWal, -1 ) ) - { - rc = pagerLockDb( pPager, EXCLUSIVE_LOCK ); - if ( rc != SQLITE_OK ) - { - return rc; - } - sqlite3WalExclusiveMode( pPager.pWal, 1 ); - } + if (rc == SQLITE_OK) { + /* Change to WRITER_LOCKED state. + ** + ** WAL mode sets Pager.eState to PAGER_WRITER_LOCKED or CACHEMOD + ** when it has an open transaction, but never to DBMOD or FINISHED. + ** This is because in those states the code to roll back savepoint + ** transactions may copy data from the sub-journal into the database + ** file as well as into the page cache. Which would be incorrect in + ** WAL mode. + */ + pPager.eState = PAGER_WRITER_LOCKED; + pPager.dbHintSize = pPager.dbSize; + pPager.dbFileSize = pPager.dbSize; + pPager.dbOrigSize = pPager.dbSize; + pPager.journalOff = 0; + } - /* Grab the write lock on the log file. If successful, upgrade to - ** PAGER_RESERVED state. Otherwise, return an error code to the caller. - ** The busy-handler is not invoked if another connection already - ** holds the write-lock. If possible, the upper layer will call it. - */ - rc = sqlite3WalBeginWriteTransaction( pPager.pWal ); - } - else - { - /* Obtain a RESERVED lock on the database file. If the exFlag parameter - ** is true, then immediately upgrade this to an EXCLUSIVE lock. The - ** busy-handler callback can be used when upgrading to the EXCLUSIVE - ** lock, but not when obtaining the RESERVED lock. - */ - rc = pagerLockDb( pPager, RESERVED_LOCK ); - if ( rc == SQLITE_OK && exFlag ) - { - rc = pager_wait_on_lock( pPager, EXCLUSIVE_LOCK ); - } - } + Debug.Assert(rc == SQLITE_OK || pPager.eState == PAGER_READER); + Debug.Assert(rc != SQLITE_OK || pPager.eState == PAGER_WRITER_LOCKED); + Debug.Assert(assert_pager_state(pPager)); + } - if ( rc == SQLITE_OK ) - { - /* Change to WRITER_LOCKED state. - ** - ** WAL mode sets Pager.eState to PAGER_WRITER_LOCKED or CACHEMOD - ** when it has an open transaction, but never to DBMOD or FINISHED. - ** This is because in those states the code to roll back savepoint - ** transactions may copy data from the sub-journal into the database - ** file as well as into the page cache. Which would be incorrect in - ** WAL mode. - */ - pPager.eState = PAGER_WRITER_LOCKED; - pPager.dbHintSize = pPager.dbSize; - pPager.dbFileSize = pPager.dbSize; - pPager.dbOrigSize = pPager.dbSize; - pPager.journalOff = 0; + PAGERTRACE("TRANSACTION %d\n", PAGERID(pPager)); + return rc; } - Debug.Assert( rc == SQLITE_OK || pPager.eState == PAGER_READER ); - Debug.Assert( rc != SQLITE_OK || pPager.eState == PAGER_WRITER_LOCKED ); - Debug.Assert( assert_pager_state( pPager ) ); - } - - PAGERTRACE( "TRANSACTION %d\n", PAGERID( pPager ) ); - return rc; - } - - /* - ** Mark a single data page as writeable. The page is written into the - ** main journal or sub-journal as required. If the page is written into - ** one of the journals, the corresponding bit is set in the - ** Pager.pInJournal bitvec and the PagerSavepoint.pInSavepoint bitvecs - ** of any open savepoints as appropriate. - */ - static int pager_write( PgHdr pPg ) - { - byte[] pData = pPg.pData; - Pager pPager = pPg.pPager; - int rc = SQLITE_OK; + /* + ** Mark a single data page as writeable. The page is written into the + ** main journal or sub-journal as required. If the page is written into + ** one of the journals, the corresponding bit is set in the + ** Pager.pInJournal bitvec and the PagerSavepoint.pInSavepoint bitvecs + ** of any open savepoints as appropriate. + */ + static int pager_write(PgHdr pPg) { + byte[] pData = pPg.pData; + Pager pPager = pPg.pPager; + int rc = SQLITE_OK; - /* This routine is not called unless a write-transaction has already - ** been started. The journal file may or may not be open at this point. - ** It is never called in the ERROR state. - */ - Debug.Assert( pPager.eState == PAGER_WRITER_LOCKED - || pPager.eState == PAGER_WRITER_CACHEMOD - || pPager.eState == PAGER_WRITER_DBMOD - ); - Debug.Assert( assert_pager_state( pPager ) ); + /* This routine is not called unless a write-transaction has already + ** been started. The journal file may or may not be open at this point. + ** It is never called in the ERROR state. + */ + Debug.Assert(pPager.eState == PAGER_WRITER_LOCKED + || pPager.eState == PAGER_WRITER_CACHEMOD + || pPager.eState == PAGER_WRITER_DBMOD + ); + Debug.Assert(assert_pager_state(pPager)); - /* If an error has been previously detected, report the same error - ** again. This should not happen, but the check provides robustness. */ - if ( NEVER( pPager.errCode ) != 0 ) - return pPager.errCode; + /* If an error has been previously detected, report the same error + ** again. This should not happen, but the check provides robustness. */ + if (NEVER(pPager.errCode) != 0) + return pPager.errCode; - /* Higher-level routines never call this function if database is not - ** writable. But check anyway, just for robustness. */ - if ( NEVER( pPager.readOnly ) ) - return SQLITE_PERM; + /* Higher-level routines never call this function if database is not + ** writable. But check anyway, just for robustness. */ + if (NEVER(pPager.readOnly)) + return SQLITE_PERM; #if SQLITE_CHECK_PAGES CHECK_PAGE(pPg); #endif - /* The journal file needs to be opened. Higher level routines have already -** obtained the necessary locks to begin the write-transaction, but the -** rollback journal might not yet be open. Open it now if this is the case. -** -** This is done before calling sqlite3PcacheMakeDirty() on the page. -** Otherwise, if it were done after calling sqlite3PcacheMakeDirty(), then -** an error might occur and the pager would end up in WRITER_LOCKED state -** with pages marked as dirty in the cache. -*/ - if ( pPager.eState == PAGER_WRITER_LOCKED ) - { - rc = pager_open_journal( pPager ); - if ( rc != SQLITE_OK ) - return rc; - } - Debug.Assert( pPager.eState >= PAGER_WRITER_CACHEMOD ); - Debug.Assert( assert_pager_state( pPager ) ); - - /* Mark the page as dirty. If the page has already been written - ** to the journal then we can return right away. + /* The journal file needs to be opened. Higher level routines have already + ** obtained the necessary locks to begin the write-transaction, but the + ** rollback journal might not yet be open. Open it now if this is the case. + ** + ** This is done before calling sqlite3PcacheMakeDirty() on the page. + ** Otherwise, if it were done after calling sqlite3PcacheMakeDirty(), then + ** an error might occur and the pager would end up in WRITER_LOCKED state + ** with pages marked as dirty in the cache. */ - sqlite3PcacheMakeDirty( pPg ); - if ( pageInJournal( pPg ) && !subjRequiresPage( pPg ) ) - { - Debug.Assert( !pagerUseWal( pPager ) ); - } - else - { - /* The transaction journal now exists and we have a RESERVED or an - ** EXCLUSIVE lock on the main database file. Write the current page to - ** the transaction journal if it is not there already. - */ - if ( !pageInJournal( pPg ) && !pagerUseWal( pPager ) ) - { - Debug.Assert( pagerUseWal( pPager ) == false ); - if ( pPg.pgno <= pPager.dbOrigSize && isOpen( pPager.jfd ) ) - { - u32 cksum; - byte[] pData2 = null; - i64 iOff = pPager.journalOff; - - /* We should never write to the journal file the page that - ** contains the database locks. The following Debug.Assert verifies - ** that we do not. */ - Debug.Assert( pPg.pgno != ( ( PENDING_BYTE / ( pPager.pageSize ) ) + 1 ) );//PAGER_MJ_PGNO(pPager) ); - - Debug.Assert( pPager.journalHdr <= pPager.journalOff ); - if ( CODEC2( pPager, pData, pPg.pgno, SQLITE_ENCRYPT_READ_CTX, ref pData2 ) ) - return SQLITE_NOMEM; // CODEC2(pPager, pData, pPg.pgno, 7, return SQLITE_NOMEM, pData2); - cksum = pager_cksum( pPager, pData2 ); - - /* Even if an IO or diskfull error occurred while journalling the - ** page in the block above, set the need-sync flag for the page. - ** Otherwise, when the transaction is rolled back, the logic in - ** playback_one_page() will think that the page needs to be restored - ** in the database file. And if an IO error occurs while doing so, - ** then corruption may follow. - */ - - pPg.flags |= PGHDR_NEED_SYNC; - - rc = write32bits( pPager.jfd, iOff, pPg.pgno ); - if ( rc != SQLITE_OK ) - return rc; - rc = sqlite3OsWrite( pPager.jfd, pData2, pPager.pageSize, iOff + 4 ); - if ( rc != SQLITE_OK ) - return rc; - rc = write32bits( pPager.jfd, iOff + pPager.pageSize + 4, cksum ); - if ( rc != SQLITE_OK ) - return rc; + if (pPager.eState == PAGER_WRITER_LOCKED) { + rc = pager_open_journal(pPager); + if (rc != SQLITE_OK) + return rc; + } + Debug.Assert(pPager.eState >= PAGER_WRITER_CACHEMOD); + Debug.Assert(assert_pager_state(pPager)); - IOTRACE( "JOUT %p %d %lld %d\n", pPager, pPg.pgno, - pPager.journalOff, pPager.pageSize ); + /* Mark the page as dirty. If the page has already been written + ** to the journal then we can return right away. + */ + sqlite3PcacheMakeDirty(pPg); + if (pageInJournal(pPg) && !subjRequiresPage(pPg)) { + Debug.Assert(!pagerUseWal(pPager)); + } else { + /* The transaction journal now exists and we have a RESERVED or an + ** EXCLUSIVE lock on the main database file. Write the current page to + ** the transaction journal if it is not there already. + */ + if (!pageInJournal(pPg) && !pagerUseWal(pPager)) { + Debug.Assert(pagerUseWal(pPager) == false); + if (pPg.pgno <= pPager.dbOrigSize && isOpen(pPager.jfd)) { + u32 cksum; + byte[] pData2 = null; + i64 iOff = pPager.journalOff; + + /* We should never write to the journal file the page that + ** contains the database locks. The following Debug.Assert verifies + ** that we do not. */ + Debug.Assert(pPg.pgno != ((PENDING_BYTE / (pPager.pageSize)) + 1));//PAGER_MJ_PGNO(pPager) ); + + Debug.Assert(pPager.journalHdr <= pPager.journalOff); + if (CODEC2(pPager, pData, pPg.pgno, SQLITE_ENCRYPT_READ_CTX, ref pData2)) + return SQLITE_NOMEM; // CODEC2(pPager, pData, pPg.pgno, 7, return SQLITE_NOMEM, pData2); + cksum = pager_cksum(pPager, pData2); + + /* Even if an IO or diskfull error occurred while journalling the + ** page in the block above, set the need-sync flag for the page. + ** Otherwise, when the transaction is rolled back, the logic in + ** playback_one_page() will think that the page needs to be restored + ** in the database file. And if an IO error occurs while doing so, + ** then corruption may follow. + */ + + pPg.flags |= PGHDR_NEED_SYNC; + + rc = write32bits(pPager.jfd, iOff, pPg.pgno); + if (rc != SQLITE_OK) + return rc; + rc = sqlite3OsWrite(pPager.jfd, pData2, pPager.pageSize, iOff + 4); + if (rc != SQLITE_OK) + return rc; + rc = write32bits(pPager.jfd, iOff + pPager.pageSize + 4, cksum); + if (rc != SQLITE_OK) + return rc; + + IOTRACE("JOUT %p %d %lld %d\n", pPager, pPg.pgno, + pPager.journalOff, pPager.pageSize); #if SQLITE_TEST #if !TCLSH PAGER_INCR( ref sqlite3_pager_writej_count ); @@ -6148,519 +5745,466 @@ static int pager_write( PgHdr pPg ) sqlite3_pager_writej_count.iValue = iValue; #endif #endif - PAGERTRACE( "JOURNAL %d page %d needSync=%d hash(%08x)\n", - PAGERID( pPager ), pPg.pgno, - ( ( pPg.flags & PGHDR_NEED_SYNC ) != 0 ? 1 : 0 ), pager_pagehash( pPg ) ); - - pPager.journalOff += 8 + pPager.pageSize; - pPager.nRec++; - Debug.Assert( pPager.pInJournal != null ); - rc = sqlite3BitvecSet( pPager.pInJournal, pPg.pgno ); - testcase( rc == SQLITE_NOMEM ); - Debug.Assert( rc == SQLITE_OK || rc == SQLITE_NOMEM ); - rc |= addToSavepointBitvecs( pPager, pPg.pgno ); - if ( rc != SQLITE_OK ) - { - Debug.Assert( rc == SQLITE_NOMEM ); - return rc; + PAGERTRACE("JOURNAL %d page %d needSync=%d hash(%08x)\n", + PAGERID(pPager), pPg.pgno, + ((pPg.flags & PGHDR_NEED_SYNC) != 0 ? 1 : 0), pager_pagehash(pPg)); + + pPager.journalOff += 8 + pPager.pageSize; + pPager.nRec++; + Debug.Assert(pPager.pInJournal != null); + rc = sqlite3BitvecSet(pPager.pInJournal, pPg.pgno); + testcase(rc == SQLITE_NOMEM); + Debug.Assert(rc == SQLITE_OK || rc == SQLITE_NOMEM); + rc |= addToSavepointBitvecs(pPager, pPg.pgno); + if (rc != SQLITE_OK) { + Debug.Assert(rc == SQLITE_NOMEM); + return rc; + } + } else { + if (pPager.eState != PAGER_WRITER_DBMOD) { + pPg.flags |= PGHDR_NEED_SYNC; + } + PAGERTRACE("APPEND %d page %d needSync=%d\n", + PAGERID(pPager), pPg.pgno, + ((pPg.flags & PGHDR_NEED_SYNC) != 0 ? 1 : 0)); + } + } + + /* If the statement journal is open and the page is not in it, + ** then write the current page to the statement journal. Note that + ** the statement journal format differs from the standard journal format + ** in that it omits the checksums and the header. + */ + if (subjRequiresPage(pPg)) { + rc = subjournalPage(pPg); + } } - } - else - { - if ( pPager.eState != PAGER_WRITER_DBMOD ) - { - pPg.flags |= PGHDR_NEED_SYNC; + + /* Update the database size and return. + */ + if (pPager.dbSize < pPg.pgno) { + pPager.dbSize = pPg.pgno; } - PAGERTRACE( "APPEND %d page %d needSync=%d\n", - PAGERID( pPager ), pPg.pgno, - ( ( pPg.flags & PGHDR_NEED_SYNC ) != 0 ? 1 : 0 ) ); - } + return rc; } - /* If the statement journal is open and the page is not in it, - ** then write the current page to the statement journal. Note that - ** the statement journal format differs from the standard journal format - ** in that it omits the checksums and the header. + /* + ** Mark a data page as writeable. This routine must be called before + ** making changes to a page. The caller must check the return value + ** of this function and be careful not to change any page data unless + ** this routine returns SQLITE_OK. + ** + ** The difference between this function and pager_write() is that this + ** function also deals with the special case where 2 or more pages + ** fit on a single disk sector. In this case all co-resident pages + ** must have been written to the journal file before returning. + ** + ** If an error occurs, SQLITE_NOMEM or an IO error code is returned + ** as appropriate. Otherwise, SQLITE_OK. */ - if ( subjRequiresPage( pPg ) ) - { - rc = subjournalPage( pPg ); - } - } - - /* Update the database size and return. - */ - if ( pPager.dbSize < pPg.pgno ) - { - pPager.dbSize = pPg.pgno; - } - return rc; - } + static int sqlite3PagerWrite(DbPage pDbPage) { + int rc = SQLITE_OK; - /* - ** Mark a data page as writeable. This routine must be called before - ** making changes to a page. The caller must check the return value - ** of this function and be careful not to change any page data unless - ** this routine returns SQLITE_OK. - ** - ** The difference between this function and pager_write() is that this - ** function also deals with the special case where 2 or more pages - ** fit on a single disk sector. In this case all co-resident pages - ** must have been written to the journal file before returning. - ** - ** If an error occurs, SQLITE_NOMEM or an IO error code is returned - ** as appropriate. Otherwise, SQLITE_OK. - */ - static int sqlite3PagerWrite( DbPage pDbPage ) - { - int rc = SQLITE_OK; + PgHdr pPg = pDbPage; + Pager pPager = pPg.pPager; + u32 nPagePerSector = (u32)(pPager.sectorSize / pPager.pageSize); - PgHdr pPg = pDbPage; - Pager pPager = pPg.pPager; - u32 nPagePerSector = (u32)( pPager.sectorSize / pPager.pageSize ); + Debug.Assert(pPager.eState >= PAGER_WRITER_LOCKED); + Debug.Assert(pPager.eState != PAGER_ERROR); + Debug.Assert(assert_pager_state(pPager)); - Debug.Assert( pPager.eState >= PAGER_WRITER_LOCKED ); - Debug.Assert( pPager.eState != PAGER_ERROR ); - Debug.Assert( assert_pager_state( pPager ) ); + if (nPagePerSector > 1) { + Pgno nPageCount = 0; /* Total number of pages in database file */ + Pgno pg1; /* First page of the sector pPg is located on. */ + Pgno nPage = 0; /* Number of pages starting at pg1 to journal */ + int ii; /* Loop counter */ + bool needSync = false; /* True if any page has PGHDR_NEED_SYNC */ - if ( nPagePerSector > 1 ) - { - Pgno nPageCount = 0; /* Total number of pages in database file */ - Pgno pg1; /* First page of the sector pPg is located on. */ - Pgno nPage = 0; /* Number of pages starting at pg1 to journal */ - int ii; /* Loop counter */ - bool needSync = false; /* True if any page has PGHDR_NEED_SYNC */ - - /* Set the doNotSyncSpill flag to 1. This is because we cannot allow - ** a journal header to be written between the pages journaled by - ** this function. - */ - Debug.Assert( + /* Set the doNotSyncSpill flag to 1. This is because we cannot allow + ** a journal header to be written between the pages journaled by + ** this function. + */ + Debug.Assert( #if SQLITE_OMIT_MEMORYDB 0==MEMDB #else - 0 == pPager.memDb + 0 == pPager.memDb #endif - ); - Debug.Assert( pPager.doNotSyncSpill == 0 ); - pPager.doNotSyncSpill++; + ); + Debug.Assert(pPager.doNotSyncSpill == 0); + pPager.doNotSyncSpill++; - /* This trick assumes that both the page-size and sector-size are - ** an integer power of 2. It sets variable pg1 to the identifier - ** of the first page of the sector pPg is located on. - */ - pg1 = (u32)( ( pPg.pgno - 1 ) & ~( nPagePerSector - 1 ) ) + 1; - - nPageCount = pPager.dbSize; - if ( pPg.pgno > nPageCount ) - { - nPage = ( pPg.pgno - pg1 ) + 1; - } - else if ( ( pg1 + nPagePerSector - 1 ) > nPageCount ) - { - nPage = nPageCount + 1 - pg1; - } - else - { - nPage = nPagePerSector; - } - Debug.Assert( nPage > 0 ); - Debug.Assert( pg1 <= pPg.pgno ); - Debug.Assert( ( pg1 + nPage ) > pPg.pgno ); - - for ( ii = 0; ii < nPage && rc == SQLITE_OK; ii++ ) - { - u32 pg = (u32)( pg1 + ii ); - PgHdr pPage = new PgHdr(); - if ( pg == pPg.pgno || sqlite3BitvecTest( pPager.pInJournal, pg ) == 0 ) - { - if ( pg != ( ( PENDING_BYTE / ( pPager.pageSize ) ) + 1 ) ) //PAGER_MJ_PGNO(pPager)) - { - rc = sqlite3PagerGet( pPager, pg, ref pPage ); - if ( rc == SQLITE_OK ) - { - rc = pager_write( pPage ); - if ( ( pPage.flags & PGHDR_NEED_SYNC ) != 0 ) - { - needSync = true; + /* This trick assumes that both the page-size and sector-size are + ** an integer power of 2. It sets variable pg1 to the identifier + ** of the first page of the sector pPg is located on. + */ + pg1 = (u32)((pPg.pgno - 1) & ~(nPagePerSector - 1)) + 1; + + nPageCount = pPager.dbSize; + if (pPg.pgno > nPageCount) { + nPage = (pPg.pgno - pg1) + 1; + } else if ((pg1 + nPagePerSector - 1) > nPageCount) { + nPage = nPageCount + 1 - pg1; + } else { + nPage = nPagePerSector; + } + Debug.Assert(nPage > 0); + Debug.Assert(pg1 <= pPg.pgno); + Debug.Assert((pg1 + nPage) > pPg.pgno); + + for (ii = 0; ii < nPage && rc == SQLITE_OK; ii++) { + u32 pg = (u32)(pg1 + ii); + PgHdr pPage = new PgHdr(); + if (pg == pPg.pgno || sqlite3BitvecTest(pPager.pInJournal, pg) == 0) { + if (pg != ((PENDING_BYTE / (pPager.pageSize)) + 1)) //PAGER_MJ_PGNO(pPager)) + { + rc = sqlite3PagerGet(pPager, pg, ref pPage); + if (rc == SQLITE_OK) { + rc = pager_write(pPage); + if ((pPage.flags & PGHDR_NEED_SYNC) != 0) { + needSync = true; + } + sqlite3PagerUnref(pPage); + } + } + } else if ((pPage = pager_lookup(pPager, pg)) != null) { + if ((pPage.flags & PGHDR_NEED_SYNC) != 0) { + needSync = true; + } + sqlite3PagerUnref(pPage); + } } - sqlite3PagerUnref( pPage ); - } - } - } - else if ( ( pPage = pager_lookup( pPager, pg ) ) != null ) - { - if ( ( pPage.flags & PGHDR_NEED_SYNC ) != 0 ) - { - needSync = true; - } - sqlite3PagerUnref( pPage ); - } - } - /* If the PGHDR_NEED_SYNC flag is set for any of the nPage pages - ** starting at pg1, then it needs to be set for all of them. Because - ** writing to any of these nPage pages may damage the others, the - ** journal file must contain sync()ed copies of all of them - ** before any of them can be written out to the database file. - */ - if ( rc == SQLITE_OK && needSync ) - { - Debug.Assert( + /* If the PGHDR_NEED_SYNC flag is set for any of the nPage pages + ** starting at pg1, then it needs to be set for all of them. Because + ** writing to any of these nPage pages may damage the others, the + ** journal file must contain sync()ed copies of all of them + ** before any of them can be written out to the database file. + */ + if (rc == SQLITE_OK && needSync) { + Debug.Assert( #if SQLITE_OMIT_MEMORYDB 0==MEMDB #else - 0 == pPager.memDb + 0 == pPager.memDb #endif - ); - for ( ii = 0; ii < nPage; ii++ ) - { - PgHdr pPage = pager_lookup( pPager, (u32)( pg1 + ii ) ); - if ( pPage != null ) - { - pPage.flags |= PGHDR_NEED_SYNC; - sqlite3PagerUnref( pPage ); + ); + for (ii = 0; ii < nPage; ii++) { + PgHdr pPage = pager_lookup(pPager, (u32)(pg1 + ii)); + if (pPage != null) { + pPage.flags |= PGHDR_NEED_SYNC; + sqlite3PagerUnref(pPage); + } + } + } + + Debug.Assert(pPager.doNotSyncSpill == 1); + pPager.doNotSyncSpill--; + } else { + rc = pager_write(pDbPage); } - } + return rc; } - Debug.Assert( pPager.doNotSyncSpill == 1 ); - pPager.doNotSyncSpill--; - } - else - { - rc = pager_write( pDbPage ); - } - return rc; - } - - /* - ** Return TRUE if the page given in the argument was previously passed - ** to sqlite3PagerWrite(). In other words, return TRUE if it is ok - ** to change the content of the page. - */ -#if !NDEBUG - static bool sqlite3PagerIswriteable( DbPage pPg ) - { - return ( pPg.flags & PGHDR_DIRTY ) != 0; - } + /* + ** Return TRUE if the page given in the argument was previously passed + ** to sqlite3PagerWrite(). In other words, return TRUE if it is ok + ** to change the content of the page. + */ +#if !NDEBUG + static bool sqlite3PagerIswriteable(DbPage pPg) { + return (pPg.flags & PGHDR_DIRTY) != 0; + } #else static bool sqlite3PagerIswriteable( DbPage pPg ) { return true; } #endif - /* -** A call to this routine tells the pager that it is not necessary to -** write the information on page pPg back to the disk, even though -** that page might be marked as dirty. This happens, for example, when -** the page has been added as a leaf of the freelist and so its -** content no longer matters. -** -** The overlying software layer calls this routine when all of the data -** on the given page is unused. The pager marks the page as clean so -** that it does not get written to disk. -** -** Tests show that this optimization can quadruple the speed of large -** DELETE operations. -*/ - static void sqlite3PagerDontWrite( PgHdr pPg ) - { - Pager pPager = pPg.pPager; - - if ( ( pPg.flags & PGHDR_DIRTY ) != 0 && pPager.nSavepoint == 0 ) - { - PAGERTRACE( "DONT_WRITE page %d of %d\n", pPg.pgno, PAGERID( pPager ) ); - IOTRACE( "CLEAN %p %d\n", pPager, pPg.pgno ); - pPg.flags |= PGHDR_DONT_WRITE; - pager_set_pagehash( pPg ); - } - } - - /* - ** This routine is called to increment the value of the database file - ** change-counter, stored as a 4-byte big-endian integer starting at - ** byte offset 24 of the pager file. The secondary change counter at - ** 92 is also updated, as is the SQLite version number at offset 96. - ** - ** But this only happens if the pPager.changeCountDone flag is false. - ** To avoid excess churning of page 1, the update only happens once. - ** See also the pager_write_changecounter() routine that does an - ** unconditional update of the change counters. - ** - ** If the isDirectMode flag is zero, then this is done by calling - ** sqlite3PagerWrite() on page 1, then modifying the contents of the - ** page data. In this case the file will be updated when the current - ** transaction is committed. - ** - ** The isDirectMode flag may only be non-zero if the library was compiled - ** with the SQLITE_ENABLE_ATOMIC_WRITE macro defined. In this case, - ** if isDirect is non-zero, then the database file is updated directly - ** by writing an updated version of page 1 using a call to the - ** sqlite3OsWrite() function. + /* + ** A call to this routine tells the pager that it is not necessary to + ** write the information on page pPg back to the disk, even though + ** that page might be marked as dirty. This happens, for example, when + ** the page has been added as a leaf of the freelist and so its + ** content no longer matters. + ** + ** The overlying software layer calls this routine when all of the data + ** on the given page is unused. The pager marks the page as clean so + ** that it does not get written to disk. + ** + ** Tests show that this optimization can quadruple the speed of large + ** DELETE operations. */ - static int pager_incr_changecounter( Pager pPager, bool isDirectMode ) - { - int rc = SQLITE_OK; + static void sqlite3PagerDontWrite(PgHdr pPg) { + Pager pPager = pPg.pPager; + + if ((pPg.flags & PGHDR_DIRTY) != 0 && pPager.nSavepoint == 0) { + PAGERTRACE("DONT_WRITE page %d of %d\n", pPg.pgno, PAGERID(pPager)); + IOTRACE("CLEAN %p %d\n", pPager, pPg.pgno); + pPg.flags |= PGHDR_DONT_WRITE; + pager_set_pagehash(pPg); + } + } - Debug.Assert( pPager.eState == PAGER_WRITER_CACHEMOD - || pPager.eState == PAGER_WRITER_DBMOD - ); - Debug.Assert( assert_pager_state( pPager ) ); + /* + ** This routine is called to increment the value of the database file + ** change-counter, stored as a 4-byte big-endian integer starting at + ** byte offset 24 of the pager file. The secondary change counter at + ** 92 is also updated, as is the SQLite version number at offset 96. + ** + ** But this only happens if the pPager.changeCountDone flag is false. + ** To avoid excess churning of page 1, the update only happens once. + ** See also the pager_write_changecounter() routine that does an + ** unconditional update of the change counters. + ** + ** If the isDirectMode flag is zero, then this is done by calling + ** sqlite3PagerWrite() on page 1, then modifying the contents of the + ** page data. In this case the file will be updated when the current + ** transaction is committed. + ** + ** The isDirectMode flag may only be non-zero if the library was compiled + ** with the SQLITE_ENABLE_ATOMIC_WRITE macro defined. In this case, + ** if isDirect is non-zero, then the database file is updated directly + ** by writing an updated version of page 1 using a call to the + ** sqlite3OsWrite() function. + */ + static int pager_incr_changecounter(Pager pPager, bool isDirectMode) { + int rc = SQLITE_OK; - /* Declare and initialize constant integer 'isDirect'. If the - ** atomic-write optimization is enabled in this build, then isDirect - ** is initialized to the value passed as the isDirectMode parameter - ** to this function. Otherwise, it is always set to zero. - ** - ** The idea is that if the atomic-write optimization is not - ** enabled at compile time, the compiler can omit the tests of - ** 'isDirect' below, as well as the block enclosed in the - ** "if( isDirect )" condition. - */ + Debug.Assert(pPager.eState == PAGER_WRITER_CACHEMOD + || pPager.eState == PAGER_WRITER_DBMOD + ); + Debug.Assert(assert_pager_state(pPager)); + + /* Declare and initialize constant integer 'isDirect'. If the + ** atomic-write optimization is enabled in this build, then isDirect + ** is initialized to the value passed as the isDirectMode parameter + ** to this function. Otherwise, it is always set to zero. + ** + ** The idea is that if the atomic-write optimization is not + ** enabled at compile time, the compiler can omit the tests of + ** 'isDirect' below, as well as the block enclosed in the + ** "if( isDirect )" condition. + */ #if !SQLITE_ENABLE_ATOMIC_WRITE - //# define DIRECT_MODE 0 - bool DIRECT_MODE = false; - Debug.Assert( isDirectMode == false ); - UNUSED_PARAMETER( isDirectMode ); + //# define DIRECT_MODE 0 + bool DIRECT_MODE = false; + Debug.Assert(isDirectMode == false); + UNUSED_PARAMETER(isDirectMode); #else //# define DIRECT_MODE isDirectMode int DIRECT_MODE = isDirectMode; #endif - if ( !pPager.changeCountDone && pPager.dbSize > 0 ) - { - PgHdr pPgHdr = null; /* Reference to page 1 */ - - Debug.Assert( !pPager.tempFile && isOpen( pPager.fd ) ); + if (!pPager.changeCountDone && pPager.dbSize > 0) { + PgHdr pPgHdr = null; /* Reference to page 1 */ - /* Open page 1 of the file for writing. */ - rc = sqlite3PagerGet( pPager, 1, ref pPgHdr ); - Debug.Assert( pPgHdr == null || rc == SQLITE_OK ); + Debug.Assert(!pPager.tempFile && isOpen(pPager.fd)); - /* If page one was fetched successfully, and this function is not - ** operating in direct-mode, make page 1 writable. When not in - ** direct mode, page 1 is always held in cache and hence the PagerGet() - ** above is always successful - hence the ALWAYS on rc==SQLITE_OK. - */ - if ( !DIRECT_MODE && ALWAYS( rc == SQLITE_OK ) ) - { - rc = sqlite3PagerWrite( pPgHdr ); - } + /* Open page 1 of the file for writing. */ + rc = sqlite3PagerGet(pPager, 1, ref pPgHdr); + Debug.Assert(pPgHdr == null || rc == SQLITE_OK); - if ( rc == SQLITE_OK ) - { - /* Actually do the update of the change counter */ - pager_write_changecounter( pPgHdr ); + /* If page one was fetched successfully, and this function is not + ** operating in direct-mode, make page 1 writable. When not in + ** direct mode, page 1 is always held in cache and hence the PagerGet() + ** above is always successful - hence the ALWAYS on rc==SQLITE_OK. + */ + if (!DIRECT_MODE && ALWAYS(rc == SQLITE_OK)) { + rc = sqlite3PagerWrite(pPgHdr); + } - /* If running in direct mode, write the contents of page 1 to the file. */ - if ( DIRECT_MODE ) - { - u8[] zBuf = null; - Debug.Assert( pPager.dbFileSize > 0 ); - if ( CODEC2( pPager, pPgHdr.pData, 1, SQLITE_ENCRYPT_WRITE_CTX, ref zBuf ) ) - return rc = SQLITE_NOMEM;//CODEC2(pPager, pPgHdr.pData, 1, 6, rc=SQLITE_NOMEM, zBuf); - if ( rc == SQLITE_OK ) - { - rc = sqlite3OsWrite( pPager.fd, zBuf, pPager.pageSize, 0 ); - } + if (rc == SQLITE_OK) { + /* Actually do the update of the change counter */ + pager_write_changecounter(pPgHdr); + + /* If running in direct mode, write the contents of page 1 to the file. */ + if (DIRECT_MODE) { + u8[] zBuf = null; + Debug.Assert(pPager.dbFileSize > 0); + if (CODEC2(pPager, pPgHdr.pData, 1, SQLITE_ENCRYPT_WRITE_CTX, ref zBuf)) + return rc = SQLITE_NOMEM;//CODEC2(pPager, pPgHdr.pData, 1, 6, rc=SQLITE_NOMEM, zBuf); + if (rc == SQLITE_OK) { + rc = sqlite3OsWrite(pPager.fd, zBuf, pPager.pageSize, 0); + } + + if (rc == SQLITE_OK) { + pPager.changeCountDone = true; + } + } else { + pPager.changeCountDone = true; + } + } - if ( rc == SQLITE_OK ) - { - pPager.changeCountDone = true; + /* Release the page reference. */ + sqlite3PagerUnref(pPgHdr); } - } - else - { - pPager.changeCountDone = true; - } + return rc; } - /* Release the page reference. */ - sqlite3PagerUnref( pPgHdr ); - } - return rc; - } - - /* - ** Sync the database file to disk. This is a no-op for in-memory databases - ** or pages with the Pager.noSync flag set. - ** - ** If successful, or if called on a pager for which it is a no-op, this - ** function returns SQLITE_OK. Otherwise, an IO error code is returned. - */ - static int sqlite3PagerSync( Pager pPager ) - { - long rc = SQLITE_OK; - if ( !pPager.noSync ) - { - Debug.Assert( + /* + ** Sync the database file to disk. This is a no-op for in-memory databases + ** or pages with the Pager.noSync flag set. + ** + ** If successful, or if called on a pager for which it is a no-op, this + ** function returns SQLITE_OK. Otherwise, an IO error code is returned. + */ + static int sqlite3PagerSync(Pager pPager) { + long rc = SQLITE_OK; + if (!pPager.noSync) { + Debug.Assert( #if SQLITE_OMIT_MEMORYDB 0 == MEMDB #else - 0 == pPager.memDb + 0 == pPager.memDb #endif - ); - rc = sqlite3OsSync( pPager.fd, pPager.syncFlags ); - } - else if ( isOpen( pPager.fd ) ) - { - Debug.Assert( + ); + rc = sqlite3OsSync(pPager.fd, pPager.syncFlags); + } else if (isOpen(pPager.fd)) { + Debug.Assert( #if SQLITE_OMIT_MEMORYDB 0 == MEMDB #else - 0 == pPager.memDb + 0 == pPager.memDb #endif - ); - sqlite3OsFileControl( pPager.fd, SQLITE_FCNTL_SYNC_OMITTED, ref rc ); - } - return (int)rc; - } - - /* - ** This function may only be called while a write-transaction is active in - ** rollback. If the connection is in WAL mode, this call is a no-op. - ** Otherwise, if the connection does not already have an EXCLUSIVE lock on - ** the database file, an attempt is made to obtain one. - ** - ** If the EXCLUSIVE lock is already held or the attempt to obtain it is - ** successful, or the connection is in WAL mode, SQLITE_OK is returned. - ** Otherwise, either SQLITE_BUSY or an SQLITE_IOERR_XXX error code is - ** returned. - */ - static int sqlite3PagerExclusiveLock( Pager pPager ) - { - int rc = SQLITE_OK; - Debug.Assert( pPager.eState == PAGER_WRITER_CACHEMOD - || pPager.eState == PAGER_WRITER_DBMOD - || pPager.eState == PAGER_WRITER_LOCKED - ); - Debug.Assert( assert_pager_state( pPager ) ); - if ( false == pagerUseWal( pPager ) ) - { - rc = pager_wait_on_lock( pPager, EXCLUSIVE_LOCK ); - } - return rc; - } + ); + sqlite3OsFileControl(pPager.fd, SQLITE_FCNTL_SYNC_OMITTED, ref rc); + } + return (int)rc; + } - /* - ** Sync the database file for the pager pPager. zMaster points to the name - ** of a master journal file that should be written into the individual - ** journal file. zMaster may be NULL, which is interpreted as no master - ** journal (a single database transaction). - ** - ** This routine ensures that: - ** - ** * The database file change-counter is updated, - ** * the journal is synced (unless the atomic-write optimization is used), - ** * all dirty pages are written to the database file, - ** * the database file is truncated (if required), and - ** * the database file synced. - ** - ** The only thing that remains to commit the transaction is to finalize - ** (delete, truncate or zero the first part of) the journal file (or - ** delete the master journal file if specified). - ** - ** Note that if zMaster==NULL, this does not overwrite a previous value - ** passed to an sqlite3PagerCommitPhaseOne() call. - ** - ** If the final parameter - noSync - is true, then the database file itself - ** is not synced. The caller must call sqlite3PagerSync() directly to - ** sync the database file before calling CommitPhaseTwo() to delete the - ** journal file in this case. - */ - static int sqlite3PagerCommitPhaseOne( - Pager pPager, /* Pager object */ - string zMaster, /* If not NULL, the master journal name */ - bool noSync /* True to omit the xSync on the db file */ - ) - { - int rc = SQLITE_OK; /* Return code */ + /* + ** This function may only be called while a write-transaction is active in + ** rollback. If the connection is in WAL mode, this call is a no-op. + ** Otherwise, if the connection does not already have an EXCLUSIVE lock on + ** the database file, an attempt is made to obtain one. + ** + ** If the EXCLUSIVE lock is already held or the attempt to obtain it is + ** successful, or the connection is in WAL mode, SQLITE_OK is returned. + ** Otherwise, either SQLITE_BUSY or an SQLITE_IOERR_XXX error code is + ** returned. + */ + static int sqlite3PagerExclusiveLock(Pager pPager) { + int rc = SQLITE_OK; + Debug.Assert(pPager.eState == PAGER_WRITER_CACHEMOD + || pPager.eState == PAGER_WRITER_DBMOD + || pPager.eState == PAGER_WRITER_LOCKED + ); + Debug.Assert(assert_pager_state(pPager)); + if (false == pagerUseWal(pPager)) { + rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK); + } + return rc; + } - Debug.Assert( pPager.eState == PAGER_WRITER_LOCKED - || pPager.eState == PAGER_WRITER_CACHEMOD - || pPager.eState == PAGER_WRITER_DBMOD - || pPager.eState == PAGER_ERROR - ); - Debug.Assert( assert_pager_state( pPager ) ); + /* + ** Sync the database file for the pager pPager. zMaster points to the name + ** of a master journal file that should be written into the individual + ** journal file. zMaster may be NULL, which is interpreted as no master + ** journal (a single database transaction). + ** + ** This routine ensures that: + ** + ** * The database file change-counter is updated, + ** * the journal is synced (unless the atomic-write optimization is used), + ** * all dirty pages are written to the database file, + ** * the database file is truncated (if required), and + ** * the database file synced. + ** + ** The only thing that remains to commit the transaction is to finalize + ** (delete, truncate or zero the first part of) the journal file (or + ** delete the master journal file if specified). + ** + ** Note that if zMaster==NULL, this does not overwrite a previous value + ** passed to an sqlite3PagerCommitPhaseOne() call. + ** + ** If the final parameter - noSync - is true, then the database file itself + ** is not synced. The caller must call sqlite3PagerSync() directly to + ** sync the database file before calling CommitPhaseTwo() to delete the + ** journal file in this case. + */ + static int sqlite3PagerCommitPhaseOne( + Pager pPager, /* Pager object */ + string zMaster, /* If not NULL, the master journal name */ + bool noSync /* True to omit the xSync on the db file */ + ) { + int rc = SQLITE_OK; /* Return code */ + + Debug.Assert(pPager.eState == PAGER_WRITER_LOCKED + || pPager.eState == PAGER_WRITER_CACHEMOD + || pPager.eState == PAGER_WRITER_DBMOD + || pPager.eState == PAGER_ERROR + ); + Debug.Assert(assert_pager_state(pPager)); - /* If a prior error occurred, report that error again. */ - if ( NEVER( pPager.errCode != 0 ) ) - return pPager.errCode; + /* If a prior error occurred, report that error again. */ + if (NEVER(pPager.errCode != 0)) + return pPager.errCode; - PAGERTRACE( "DATABASE SYNC: File=%s zMaster=%s nSize=%d\n", - pPager.zFilename, zMaster, pPager.dbSize ); + PAGERTRACE("DATABASE SYNC: File=%s zMaster=%s nSize=%d\n", + pPager.zFilename, zMaster, pPager.dbSize); - /* If no database changes have been made, return early. */ - if ( pPager.eState < PAGER_WRITER_CACHEMOD ) - return SQLITE_OK; + /* If no database changes have been made, return early. */ + if (pPager.eState < PAGER_WRITER_CACHEMOD) + return SQLITE_OK; - if ( + if ( #if SQLITE_OMIT_MEMORYDB 0 != MEMDB #else - 0 != pPager.memDb + 0 != pPager.memDb #endif - ) - { - /* If this is an in-memory db, or no pages have been written to, or this - ** function has already been called, it is mostly a no-op. However, any - ** backup in progress needs to be restarted. - */ - sqlite3BackupRestart( pPager.pBackup ); - } - else - { - if ( pagerUseWal( pPager ) ) - { - PgHdr pList = sqlite3PcacheDirtyList( pPager.pPCache ); - PgHdr pPageOne = null; - if ( pList == null ) - { - /* Must have at least one page for the WAL commit flag. - ** Ticket [2d1a5c67dfc2363e44f29d9bbd57f] 2null11-null5-18 */ - rc = sqlite3PagerGet( pPager, 1, ref pPageOne ); - pList = pPageOne; - pList.pDirty = null; - } - Debug.Assert( rc == SQLITE_OK ); - if ( ALWAYS( pList ) ) - { - - rc = pagerWalFrames( pPager, pList, pPager.dbSize, 1, - ( pPager.fullSync ? pPager.syncFlags : (byte)0 ) - ); - } - sqlite3PagerUnref( pPageOne ); - if ( rc == SQLITE_OK ) - { - sqlite3PcacheCleanAll( pPager.pPCache ); - } - } - else - { - - /* The following block updates the change-counter. Exactly how it - ** does this depends on whether or not the atomic-update optimization - ** was enabled at compile time, and if this transaction meets the - ** runtime criteria to use the operation: - ** - ** * The file-system supports the atomic-write property for - ** blocks of size page-size, and - ** * This commit is not part of a multi-file transaction, and - ** * Exactly one page has been modified and store in the journal file. - ** - ** If the optimization was not enabled at compile time, then the - ** pager_incr_changecounter() function is called to update the change - ** counter in 'indirect-mode'. If the optimization is compiled in but - ** is not applicable to this transaction, call sqlite3JournalCreate() - ** to make sure the journal file has actually been created, then call - ** pager_incr_changecounter() to update the change-counter in indirect - ** mode. - ** - ** Otherwise, if the optimization is both enabled and applicable, - ** then call pager_incr_changecounter() to update the change-counter - ** in 'direct' mode. In this case the journal file will never be - ** created for this transaction. - */ + ) { + /* If this is an in-memory db, or no pages have been written to, or this + ** function has already been called, it is mostly a no-op. However, any + ** backup in progress needs to be restarted. + */ + sqlite3BackupRestart(pPager.pBackup); + } else { + if (pagerUseWal(pPager)) { + PgHdr pList = sqlite3PcacheDirtyList(pPager.pPCache); + PgHdr pPageOne = null; + if (pList == null) { + /* Must have at least one page for the WAL commit flag. + ** Ticket [2d1a5c67dfc2363e44f29d9bbd57f] 2null11-null5-18 */ + rc = sqlite3PagerGet(pPager, 1, ref pPageOne); + pList = pPageOne; + pList.pDirty = null; + } + Debug.Assert(rc == SQLITE_OK); + if (ALWAYS(pList)) { + + rc = pagerWalFrames(pPager, pList, pPager.dbSize, 1, + (pPager.fullSync ? pPager.syncFlags : (byte)0) + ); + } + sqlite3PagerUnref(pPageOne); + if (rc == SQLITE_OK) { + sqlite3PcacheCleanAll(pPager.pPCache); + } + } else { + + /* The following block updates the change-counter. Exactly how it + ** does this depends on whether or not the atomic-update optimization + ** was enabled at compile time, and if this transaction meets the + ** runtime criteria to use the operation: + ** + ** * The file-system supports the atomic-write property for + ** blocks of size page-size, and + ** * This commit is not part of a multi-file transaction, and + ** * Exactly one page has been modified and store in the journal file. + ** + ** If the optimization was not enabled at compile time, then the + ** pager_incr_changecounter() function is called to update the change + ** counter in 'indirect-mode'. If the optimization is compiled in but + ** is not applicable to this transaction, call sqlite3JournalCreate() + ** to make sure the journal file has actually been created, then call + ** pager_incr_changecounter() to update the change-counter in indirect + ** mode. + ** + ** Otherwise, if the optimization is both enabled and applicable, + ** then call pager_incr_changecounter() to update the change-counter + ** in 'direct' mode. In this case the journal file will never be + ** created for this transaction. + */ #if SQLITE_ENABLE_ATOMIC_WRITE PgHdr *pPg; Debug.Assert( isOpen(pPager.jfd) @@ -6686,289 +6230,269 @@ bool noSync /* True to omit the xSync on the db file */ } } #else - rc = pager_incr_changecounter( pPager, false ); + rc = pager_incr_changecounter(pPager, false); #endif - if ( rc != SQLITE_OK ) - goto commit_phase_one_exit; - - /* If this transaction has made the database smaller, then all pages - ** being discarded by the truncation must be written to the journal - ** file. This can only happen in auto-vacuum mode. - ** - ** Before reading the pages with page numbers larger than the - ** current value of Pager.dbSize, set dbSize back to the value - ** that it took at the start of the transaction. Otherwise, the - ** calls to sqlite3PagerGet() return zeroed pages instead of - ** reading data from the database file. - */ + if (rc != SQLITE_OK) + goto commit_phase_one_exit; + + /* If this transaction has made the database smaller, then all pages + ** being discarded by the truncation must be written to the journal + ** file. This can only happen in auto-vacuum mode. + ** + ** Before reading the pages with page numbers larger than the + ** current value of Pager.dbSize, set dbSize back to the value + ** that it took at the start of the transaction. Otherwise, the + ** calls to sqlite3PagerGet() return zeroed pages instead of + ** reading data from the database file. + */ #if !SQLITE_OMIT_AUTOVACUUM - if ( pPager.dbSize < pPager.dbOrigSize - && pPager.journalMode != PAGER_JOURNALMODE_OFF - ) - { - Pgno i; /* Iterator variable */ - Pgno iSkip = PAGER_MJ_PGNO( pPager ); /* Pending lock page */ - Pgno dbSize = pPager.dbSize; /* Database image size */ - pPager.dbSize = pPager.dbOrigSize; - for ( i = dbSize + 1; i <= pPager.dbOrigSize; i++ ) - { - if ( 0 == sqlite3BitvecTest( pPager.pInJournal, i ) && i != iSkip ) - { - PgHdr pPage = null; /* Page to journal */ - rc = sqlite3PagerGet( pPager, i, ref pPage ); - if ( rc != SQLITE_OK ) - goto commit_phase_one_exit; - rc = sqlite3PagerWrite( pPage ); - sqlite3PagerUnref( pPage ); - if ( rc != SQLITE_OK ) - goto commit_phase_one_exit; - } - } - pPager.dbSize = dbSize; - } + if (pPager.dbSize < pPager.dbOrigSize + && pPager.journalMode != PAGER_JOURNALMODE_OFF + ) { + Pgno i; /* Iterator variable */ + Pgno iSkip = PAGER_MJ_PGNO(pPager); /* Pending lock page */ + Pgno dbSize = pPager.dbSize; /* Database image size */ + pPager.dbSize = pPager.dbOrigSize; + for (i = dbSize + 1; i <= pPager.dbOrigSize; i++) { + if (0 == sqlite3BitvecTest(pPager.pInJournal, i) && i != iSkip) { + PgHdr pPage = null; /* Page to journal */ + rc = sqlite3PagerGet(pPager, i, ref pPage); + if (rc != SQLITE_OK) + goto commit_phase_one_exit; + rc = sqlite3PagerWrite(pPage); + sqlite3PagerUnref(pPage); + if (rc != SQLITE_OK) + goto commit_phase_one_exit; + } + } + pPager.dbSize = dbSize; + } #endif - /* Write the master journal name into the journal file. If a master -** journal file name has already been written to the journal file, -** or if zMaster is NULL (no master journal), then this call is a no-op. -*/ - rc = writeMasterJournal( pPager, zMaster ); - if ( rc != SQLITE_OK ) - goto commit_phase_one_exit; - - /* Sync the journal file and write all dirty pages to the database. - ** If the atomic-update optimization is being used, this sync will not - ** create the journal file or perform any real IO. - ** - ** Because the change-counter page was just modified, unless the - ** atomic-update optimization is used it is almost certain that the - ** journal requires a sync here. However, in locking_mode=exclusive - ** on a system under memory pressure it is just possible that this is - ** not the case. In this case it is likely enough that the redundant - ** xSync() call will be changed to a no-op by the OS anyhow. - */ - rc = syncJournal( pPager, 0 ); - if ( rc != SQLITE_OK ) - goto commit_phase_one_exit; - - rc = pager_write_pagelist( pPager, sqlite3PcacheDirtyList( pPager.pPCache ) ); - if ( rc != SQLITE_OK ) - { - Debug.Assert( rc != SQLITE_IOERR_BLOCKED ); - goto commit_phase_one_exit; - } - sqlite3PcacheCleanAll( pPager.pPCache ); - - /* If the file on disk is not the same size as the database image, - ** then use pager_truncate to grow or shrink the file here. + /* Write the master journal name into the journal file. If a master + ** journal file name has already been written to the journal file, + ** or if zMaster is NULL (no master journal), then this call is a no-op. */ - if ( pPager.dbSize != pPager.dbFileSize ) - { - Pgno nNew = (Pgno)( pPager.dbSize - ( pPager.dbSize == PAGER_MJ_PGNO( pPager ) ? 1 : 0 ) ); - Debug.Assert( pPager.eState >= PAGER_WRITER_DBMOD ); - rc = pager_truncate( pPager, nNew ); - if ( rc != SQLITE_OK ) - goto commit_phase_one_exit; - } + rc = writeMasterJournal(pPager, zMaster); + if (rc != SQLITE_OK) + goto commit_phase_one_exit; + + /* Sync the journal file and write all dirty pages to the database. + ** If the atomic-update optimization is being used, this sync will not + ** create the journal file or perform any real IO. + ** + ** Because the change-counter page was just modified, unless the + ** atomic-update optimization is used it is almost certain that the + ** journal requires a sync here. However, in locking_mode=exclusive + ** on a system under memory pressure it is just possible that this is + ** not the case. In this case it is likely enough that the redundant + ** xSync() call will be changed to a no-op by the OS anyhow. + */ + rc = syncJournal(pPager, 0); + if (rc != SQLITE_OK) + goto commit_phase_one_exit; + + rc = pager_write_pagelist(pPager, sqlite3PcacheDirtyList(pPager.pPCache)); + if (rc != SQLITE_OK) { + Debug.Assert(rc != SQLITE_IOERR_BLOCKED); + goto commit_phase_one_exit; + } + sqlite3PcacheCleanAll(pPager.pPCache); + + /* If the file on disk is not the same size as the database image, + ** then use pager_truncate to grow or shrink the file here. + */ + if (pPager.dbSize != pPager.dbFileSize) { + Pgno nNew = (Pgno)(pPager.dbSize - (pPager.dbSize == PAGER_MJ_PGNO(pPager) ? 1 : 0)); + Debug.Assert(pPager.eState >= PAGER_WRITER_DBMOD); + rc = pager_truncate(pPager, nNew); + if (rc != SQLITE_OK) + goto commit_phase_one_exit; + } + + /* Finally, sync the database file. */ + if (!noSync) { + rc = sqlite3PagerSync(pPager); + } + IOTRACE("DBSYNC %p\n", pPager); + } + } - /* Finally, sync the database file. */ - if ( !noSync ) - { - rc = sqlite3PagerSync( pPager ); - } - IOTRACE( "DBSYNC %p\n", pPager ); + commit_phase_one_exit: + if (rc == SQLITE_OK && !pagerUseWal(pPager)) { + pPager.eState = PAGER_WRITER_FINISHED; + } + return rc; } - } - -commit_phase_one_exit: - if ( rc == SQLITE_OK && !pagerUseWal( pPager ) ) - { - pPager.eState = PAGER_WRITER_FINISHED; - } - return rc; - } - - - /* - ** When this function is called, the database file has been completely - ** updated to reflect the changes made by the current transaction and - ** synced to disk. The journal file still exists in the file-system - ** though, and if a failure occurs at this point it will eventually - ** be used as a hot-journal and the current transaction rolled back. - ** - ** This function finalizes the journal file, either by deleting, - ** truncating or partially zeroing it, so that it cannot be used - ** for hot-journal rollback. Once this is done the transaction is - ** irrevocably committed. - ** - ** If an error occurs, an IO error code is returned and the pager - ** moves into the error state. Otherwise, SQLITE_OK is returned. - */ - static int sqlite3PagerCommitPhaseTwo( Pager pPager ) - { - int rc = SQLITE_OK; /* Return code */ - - /* This routine should not be called if a prior error has occurred. - ** But if (due to a coding error elsewhere in the system) it does get - ** called, just return the same error code without doing anything. */ - if ( NEVER( pPager.errCode ) != 0 ) - return pPager.errCode; - - Debug.Assert( pPager.eState == PAGER_WRITER_LOCKED - || pPager.eState == PAGER_WRITER_FINISHED - || ( pagerUseWal( pPager ) && pPager.eState == PAGER_WRITER_CACHEMOD ) - ); - Debug.Assert( assert_pager_state( pPager ) ); - /* An optimization. If the database was not actually modified during - ** this transaction, the pager is running in exclusive-mode and is - ** using persistent journals, then this function is a no-op. - ** - ** The start of the journal file currently contains a single journal - ** header with the nRec field set to 0. If such a journal is used as - ** a hot-journal during hot-journal rollback, 0 changes will be made - ** to the database file. So there is no need to zero the journal - ** header. Since the pager is in exclusive mode, there is no need - ** to drop any locks either. - */ - if ( pPager.eState == PAGER_WRITER_LOCKED - && pPager.exclusiveMode - && pPager.journalMode == PAGER_JOURNALMODE_PERSIST - ) - { - Debug.Assert( pPager.journalOff == JOURNAL_HDR_SZ( pPager ) || 0 == pPager.journalOff ); - pPager.eState = PAGER_READER; - return SQLITE_OK; - } - PAGERTRACE( "COMMIT %d\n", PAGERID( pPager ) ); - rc = pager_end_transaction( pPager, pPager.setMaster ); - return pager_error( pPager, rc ); - } + /* + ** When this function is called, the database file has been completely + ** updated to reflect the changes made by the current transaction and + ** synced to disk. The journal file still exists in the file-system + ** though, and if a failure occurs at this point it will eventually + ** be used as a hot-journal and the current transaction rolled back. + ** + ** This function finalizes the journal file, either by deleting, + ** truncating or partially zeroing it, so that it cannot be used + ** for hot-journal rollback. Once this is done the transaction is + ** irrevocably committed. + ** + ** If an error occurs, an IO error code is returned and the pager + ** moves into the error state. Otherwise, SQLITE_OK is returned. + */ + static int sqlite3PagerCommitPhaseTwo(Pager pPager) { + int rc = SQLITE_OK; /* Return code */ + + /* This routine should not be called if a prior error has occurred. + ** But if (due to a coding error elsewhere in the system) it does get + ** called, just return the same error code without doing anything. */ + if (NEVER(pPager.errCode) != 0) + return pPager.errCode; + + Debug.Assert(pPager.eState == PAGER_WRITER_LOCKED + || pPager.eState == PAGER_WRITER_FINISHED + || (pagerUseWal(pPager) && pPager.eState == PAGER_WRITER_CACHEMOD) + ); + Debug.Assert(assert_pager_state(pPager)); - /* - ** If a write transaction is open, then all changes made within the - ** transaction are reverted and the current write-transaction is closed. - ** The pager falls back to PAGER_READER state if successful, or PAGER_ERROR - ** state if an error occurs. - ** - ** If the pager is already in PAGER_ERROR state when this function is called, - ** it returns Pager.errCode immediately. No work is performed in this case. - ** - ** Otherwise, in rollback mode, this function performs two functions: - ** - ** 1) It rolls back the journal file, restoring all database file and - ** in-memory cache pages to the state they were in when the transaction - ** was opened, and - ** - ** 2) It finalizes the journal file, so that it is not used for hot - ** rollback at any point in the future. - ** - ** Finalization of the journal file (task 2) is only performed if the - ** rollback is successful. - ** - ** In WAL mode, all cache-entries containing data modified within the - ** current transaction are either expelled from the cache or reverted to - ** their pre-transaction state by re-reading data from the database or - ** WAL files. The WAL transaction is then closed. - */ - static int sqlite3PagerRollback( Pager pPager ) - { - int rc = SQLITE_OK; /* Return code */ - PAGERTRACE( "ROLLBACK %d\n", PAGERID( pPager ) ); + /* An optimization. If the database was not actually modified during + ** this transaction, the pager is running in exclusive-mode and is + ** using persistent journals, then this function is a no-op. + ** + ** The start of the journal file currently contains a single journal + ** header with the nRec field set to 0. If such a journal is used as + ** a hot-journal during hot-journal rollback, 0 changes will be made + ** to the database file. So there is no need to zero the journal + ** header. Since the pager is in exclusive mode, there is no need + ** to drop any locks either. + */ + if (pPager.eState == PAGER_WRITER_LOCKED + && pPager.exclusiveMode + && pPager.journalMode == PAGER_JOURNALMODE_PERSIST + ) { + Debug.Assert(pPager.journalOff == JOURNAL_HDR_SZ(pPager) || 0 == pPager.journalOff); + pPager.eState = PAGER_READER; + return SQLITE_OK; + } - /* PagerRollback() is a no-op if called in READER or OPEN state. If - ** the pager is already in the ERROR state, the rollback is not - ** attempted here. Instead, the error code is returned to the caller. - */ - Debug.Assert( assert_pager_state( pPager ) ); - if ( pPager.eState == PAGER_ERROR ) - return pPager.errCode; - if ( pPager.eState <= PAGER_READER ) - return SQLITE_OK; + PAGERTRACE("COMMIT %d\n", PAGERID(pPager)); + rc = pager_end_transaction(pPager, pPager.setMaster); + return pager_error(pPager, rc); + } - if ( pagerUseWal( pPager ) ) - { - int rc2; + /* + ** If a write transaction is open, then all changes made within the + ** transaction are reverted and the current write-transaction is closed. + ** The pager falls back to PAGER_READER state if successful, or PAGER_ERROR + ** state if an error occurs. + ** + ** If the pager is already in PAGER_ERROR state when this function is called, + ** it returns Pager.errCode immediately. No work is performed in this case. + ** + ** Otherwise, in rollback mode, this function performs two functions: + ** + ** 1) It rolls back the journal file, restoring all database file and + ** in-memory cache pages to the state they were in when the transaction + ** was opened, and + ** + ** 2) It finalizes the journal file, so that it is not used for hot + ** rollback at any point in the future. + ** + ** Finalization of the journal file (task 2) is only performed if the + ** rollback is successful. + ** + ** In WAL mode, all cache-entries containing data modified within the + ** current transaction are either expelled from the cache or reverted to + ** their pre-transaction state by re-reading data from the database or + ** WAL files. The WAL transaction is then closed. + */ + static int sqlite3PagerRollback(Pager pPager) { + int rc = SQLITE_OK; /* Return code */ + PAGERTRACE("ROLLBACK %d\n", PAGERID(pPager)); - rc = sqlite3PagerSavepoint( pPager, SAVEPOINT_ROLLBACK, -1 ); - rc2 = pager_end_transaction( pPager, pPager.setMaster ); - if ( rc == SQLITE_OK ) - rc = rc2; - rc = pager_error( pPager, rc ); - } - else if ( !isOpen( pPager.jfd ) || pPager.eState == PAGER_WRITER_LOCKED ) - { - int eState = pPager.eState; - rc = pager_end_transaction( pPager, 0 ); - if ( + /* PagerRollback() is a no-op if called in READER or OPEN state. If + ** the pager is already in the ERROR state, the rollback is not + ** attempted here. Instead, the error code is returned to the caller. + */ + Debug.Assert(assert_pager_state(pPager)); + if (pPager.eState == PAGER_ERROR) + return pPager.errCode; + if (pPager.eState <= PAGER_READER) + return SQLITE_OK; + + if (pagerUseWal(pPager)) { + int rc2; + + rc = sqlite3PagerSavepoint(pPager, SAVEPOINT_ROLLBACK, -1); + rc2 = pager_end_transaction(pPager, pPager.setMaster); + if (rc == SQLITE_OK) + rc = rc2; + rc = pager_error(pPager, rc); + } else if (!isOpen(pPager.jfd) || pPager.eState == PAGER_WRITER_LOCKED) { + int eState = pPager.eState; + rc = pager_end_transaction(pPager, 0); + if ( #if SQLITE_OMIT_MEMORYDB 0==MEMDB #else - 0 == pPager.memDb + 0 == pPager.memDb #endif - && eState > PAGER_WRITER_LOCKED ) - { - /* This can happen using journal_mode=off. Move the pager to the error - ** state to indicate that the contents of the cache may not be trusted. - ** Any active readers will get SQLITE_ABORT. - */ - pPager.errCode = SQLITE_ABORT; - pPager.eState = PAGER_ERROR; - return rc; - } - } - else - { - rc = pager_playback( pPager, 0 ); - } + && eState > PAGER_WRITER_LOCKED) { + /* This can happen using journal_mode=off. Move the pager to the error + ** state to indicate that the contents of the cache may not be trusted. + ** Any active readers will get SQLITE_ABORT. + */ + pPager.errCode = SQLITE_ABORT; + pPager.eState = PAGER_ERROR; + return rc; + } + } else { + rc = pager_playback(pPager, 0); + } - Debug.Assert( pPager.eState == PAGER_READER || rc != SQLITE_OK ); - Debug.Assert( rc == SQLITE_OK || rc == SQLITE_FULL || ( rc & 0xFF ) == SQLITE_IOERR ); + Debug.Assert(pPager.eState == PAGER_READER || rc != SQLITE_OK); + Debug.Assert(rc == SQLITE_OK || rc == SQLITE_FULL || (rc & 0xFF) == SQLITE_IOERR); - /* If an error occurs during a ROLLBACK, we can no longer trust the pager - ** cache. So call pager_error() on the way out to make any error persistent. - */ - return pager_error( pPager, rc ); - } + /* If an error occurs during a ROLLBACK, we can no longer trust the pager + ** cache. So call pager_error() on the way out to make any error persistent. + */ + return pager_error(pPager, rc); + } - /* - ** Return TRUE if the database file is opened read-only. Return FALSE - ** if the database is (in theory) writable. - */ - static bool sqlite3PagerIsreadonly( Pager pPager ) - { - return pPager.readOnly; - } + /* + ** Return TRUE if the database file is opened read-only. Return FALSE + ** if the database is (in theory) writable. + */ + static bool sqlite3PagerIsreadonly(Pager pPager) { + return pPager.readOnly; + } - /* - ** Return the number of references to the pager. - */ - static int sqlite3PagerRefcount( Pager pPager ) - { - return sqlite3PcacheRefCount( pPager.pPCache ); - } + /* + ** Return the number of references to the pager. + */ + static int sqlite3PagerRefcount(Pager pPager) { + return sqlite3PcacheRefCount(pPager.pPCache); + } - /* - ** Return the approximate number of bytes of memory currently - ** used by the pager and its associated cache. - */ - static int sqlite3PagerMemUsed( Pager pPager ) - { - int perPageSize = pPager.pageSize + pPager.nExtra + 20; //+ sizeof(PgHdr) + 5*sizeof(void*); - return perPageSize * sqlite3PcachePagecount( pPager.pPCache ) - + 0// Not readily available under C#// sqlite3MallocSize(pPager); - + pPager.pageSize; - } + /* + ** Return the approximate number of bytes of memory currently + ** used by the pager and its associated cache. + */ + static int sqlite3PagerMemUsed(Pager pPager) { + int perPageSize = pPager.pageSize + pPager.nExtra + 20; //+ sizeof(PgHdr) + 5*sizeof(void*); + return perPageSize * sqlite3PcachePagecount(pPager.pPCache) + + 0// Not readily available under C#// sqlite3MallocSize(pPager); + + pPager.pageSize; + } - /* - ** Return the number of references to the specified page. - */ - static int sqlite3PagerPageRefcount( DbPage pPage ) - { - return sqlite3PcachePageRefcount( pPage ); - } + /* + ** Return the number of references to the specified page. + */ + static int sqlite3PagerPageRefcount(DbPage pPage) { + return sqlite3PcachePageRefcount(pPage); + } #if SQLITE_TEST @@ -6993,213 +6517,193 @@ static int[] sqlite3PagerStats( Pager pPager ) } #endif - /* -** Return true if this is an in-memory pager. -*/ - static bool sqlite3PagerIsMemdb( Pager pPager ) - { + /* + ** Return true if this is an in-memory pager. + */ + static bool sqlite3PagerIsMemdb(Pager pPager) { #if SQLITE_OMIT_MEMORYDB return MEMDB != 0; #else - return pPager.memDb != 0; -#endif - } - - /* - ** Check that there are at least nSavepoint savepoints open. If there are - ** currently less than nSavepoints open, then open one or more savepoints - ** to make up the difference. If the number of savepoints is already - ** equal to nSavepoint, then this function is a no-op. - ** - ** If a memory allocation fails, SQLITE_NOMEM is returned. If an error - ** occurs while opening the sub-journal file, then an IO error code is - ** returned. Otherwise, SQLITE_OK. - */ - static int sqlite3PagerOpenSavepoint( Pager pPager, int nSavepoint ) - { - int rc = SQLITE_OK; /* Return code */ - int nCurrent = pPager.nSavepoint; /* Current number of savepoints */ - - Debug.Assert( pPager.eState >= PAGER_WRITER_LOCKED ); - Debug.Assert( assert_pager_state( pPager ) ); - - if ( nSavepoint > nCurrent && pPager.useJournal != 0 ) - { - int ii; /* Iterator variable */ - PagerSavepoint[] aNew; /* New Pager.aSavepoint array */ - - /* Grow the Pager.aSavepoint array using realloc(). Return SQLITE_NOMEM - ** if the allocation fails. Otherwise, zero the new portion in case a - ** malloc failure occurs while populating it in the for(...) loop below. - */ - //aNew = (PagerSavepoint *)sqlite3Realloc( - // pPager.aSavepoint, sizeof(PagerSavepoint)*nSavepoint - //); - Array.Resize( ref pPager.aSavepoint, nSavepoint ); - aNew = pPager.aSavepoint; - //if( null==aNew ){ - // return SQLITE_NOMEM; - //} - // memset(&aNew[nCurrent], 0, (nSavepoint-nCurrent) * sizeof(PagerSavepoint)); - // pPager.aSavepoint = aNew; - - /* Populate the PagerSavepoint structures just allocated. */ - for ( ii = nCurrent; ii < nSavepoint; ii++ ) - { - aNew[ii] = new PagerSavepoint(); - aNew[ii].nOrig = pPager.dbSize; - if ( isOpen( pPager.jfd ) && pPager.journalOff > 0 ) - { - aNew[ii].iOffset = pPager.journalOff; - } - else - { - aNew[ii].iOffset = (int)JOURNAL_HDR_SZ( pPager ); - } - aNew[ii].iSubRec = pPager.nSubRec; - aNew[ii].pInSavepoint = sqlite3BitvecCreate( pPager.dbSize ); - //if ( null == aNew[ii].pInSavepoint ) - //{ - // return SQLITE_NOMEM; - //} - if ( pagerUseWal( pPager ) ) - { - sqlite3WalSavepoint( pPager.pWal, aNew[ii].aWalData ); - } - pPager.nSavepoint = ii + 1; + return pPager.memDb != 0; +#endif } - Debug.Assert( pPager.nSavepoint == nSavepoint ); - assertTruncateConstraint( pPager ); - } - return rc; - } + /* + ** Check that there are at least nSavepoint savepoints open. If there are + ** currently less than nSavepoints open, then open one or more savepoints + ** to make up the difference. If the number of savepoints is already + ** equal to nSavepoint, then this function is a no-op. + ** + ** If a memory allocation fails, SQLITE_NOMEM is returned. If an error + ** occurs while opening the sub-journal file, then an IO error code is + ** returned. Otherwise, SQLITE_OK. + */ + static int sqlite3PagerOpenSavepoint(Pager pPager, int nSavepoint) { + int rc = SQLITE_OK; /* Return code */ + int nCurrent = pPager.nSavepoint; /* Current number of savepoints */ - /* - ** This function is called to rollback or release (commit) a savepoint. - ** The savepoint to release or rollback need not be the most recently - ** created savepoint. - ** - ** Parameter op is always either SAVEPOINT_ROLLBACK or SAVEPOINT_RELEASE. - ** If it is SAVEPOINT_RELEASE, then release and destroy the savepoint with - ** index iSavepoint. If it is SAVEPOINT_ROLLBACK, then rollback all changes - ** that have occurred since the specified savepoint was created. - ** - ** The savepoint to rollback or release is identified by parameter - ** iSavepoint. A value of 0 means to operate on the outermost savepoint - ** (the first created). A value of (Pager.nSavepoint-1) means operate - ** on the most recently created savepoint. If iSavepoint is greater than - ** (Pager.nSavepoint-1), then this function is a no-op. - ** - ** If a negative value is passed to this function, then the current - ** transaction is rolled back. This is different to calling - ** sqlite3PagerRollback() because this function does not terminate - ** the transaction or unlock the database, it just restores the - ** contents of the database to its original state. - ** - ** In any case, all savepoints with an index greater than iSavepoint - ** are destroyed. If this is a release operation (op==SAVEPOINT_RELEASE), - ** then savepoint iSavepoint is also destroyed. - ** - ** This function may return SQLITE_NOMEM if a memory allocation fails, - ** or an IO error code if an IO error occurs while rolling back a - ** savepoint. If no errors occur, SQLITE_OK is returned. - */ - static int sqlite3PagerSavepoint( Pager pPager, int op, int iSavepoint ) - { - int rc = pPager.errCode; /* Return code */ + Debug.Assert(pPager.eState >= PAGER_WRITER_LOCKED); + Debug.Assert(assert_pager_state(pPager)); - Debug.Assert( op == SAVEPOINT_RELEASE || op == SAVEPOINT_ROLLBACK ); - Debug.Assert( iSavepoint >= 0 || op == SAVEPOINT_ROLLBACK ); + if (nSavepoint > nCurrent && pPager.useJournal != 0) { + int ii; /* Iterator variable */ + PagerSavepoint[] aNew; /* New Pager.aSavepoint array */ - if ( rc == SQLITE_OK && iSavepoint < pPager.nSavepoint ) - { - int ii; /* Iterator variable */ - int nNew; /* Number of remaining savepoints after this op. */ + /* Grow the Pager.aSavepoint array using realloc(). Return SQLITE_NOMEM + ** if the allocation fails. Otherwise, zero the new portion in case a + ** malloc failure occurs while populating it in the for(...) loop below. + */ + //aNew = (PagerSavepoint *)sqlite3Realloc( + // pPager.aSavepoint, sizeof(PagerSavepoint)*nSavepoint + //); + Array.Resize(ref pPager.aSavepoint, nSavepoint); + aNew = pPager.aSavepoint; + //if( null==aNew ){ + // return SQLITE_NOMEM; + //} + // memset(&aNew[nCurrent], 0, (nSavepoint-nCurrent) * sizeof(PagerSavepoint)); + // pPager.aSavepoint = aNew; + + /* Populate the PagerSavepoint structures just allocated. */ + for (ii = nCurrent; ii < nSavepoint; ii++) { + aNew[ii] = new PagerSavepoint(); + aNew[ii].nOrig = pPager.dbSize; + if (isOpen(pPager.jfd) && pPager.journalOff > 0) { + aNew[ii].iOffset = pPager.journalOff; + } else { + aNew[ii].iOffset = (int)JOURNAL_HDR_SZ(pPager); + } + aNew[ii].iSubRec = pPager.nSubRec; + aNew[ii].pInSavepoint = sqlite3BitvecCreate(pPager.dbSize); + //if ( null == aNew[ii].pInSavepoint ) + //{ + // return SQLITE_NOMEM; + //} + if (pagerUseWal(pPager)) { + sqlite3WalSavepoint(pPager.pWal, aNew[ii].aWalData); + } + pPager.nSavepoint = ii + 1; + } + Debug.Assert(pPager.nSavepoint == nSavepoint); + assertTruncateConstraint(pPager); + } - /* Figure out how many savepoints will still be active after this - ** operation. Store this value in nNew. Then free resources associated - ** with any savepoints that are destroyed by this operation. - */ - nNew = iSavepoint + ( ( op == SAVEPOINT_RELEASE ) ? 0 : 1 ); - for ( ii = nNew; ii < pPager.nSavepoint; ii++ ) - { - sqlite3BitvecDestroy( ref pPager.aSavepoint[ii].pInSavepoint ); + return rc; } - pPager.nSavepoint = nNew; - /* If this is a release of the outermost savepoint, truncate - ** the sub-journal to zero bytes in size. */ - if ( op == SAVEPOINT_RELEASE ) - { - if ( nNew == 0 && isOpen( pPager.sjfd ) ) - { - /* Only truncate if it is an in-memory sub-journal. */ - if ( sqlite3IsMemJournal( pPager.sjfd ) ) - { - rc = sqlite3OsTruncate( pPager.sjfd, 0 ); - Debug.Assert( rc == SQLITE_OK ); + /* + ** This function is called to rollback or release (commit) a savepoint. + ** The savepoint to release or rollback need not be the most recently + ** created savepoint. + ** + ** Parameter op is always either SAVEPOINT_ROLLBACK or SAVEPOINT_RELEASE. + ** If it is SAVEPOINT_RELEASE, then release and destroy the savepoint with + ** index iSavepoint. If it is SAVEPOINT_ROLLBACK, then rollback all changes + ** that have occurred since the specified savepoint was created. + ** + ** The savepoint to rollback or release is identified by parameter + ** iSavepoint. A value of 0 means to operate on the outermost savepoint + ** (the first created). A value of (Pager.nSavepoint-1) means operate + ** on the most recently created savepoint. If iSavepoint is greater than + ** (Pager.nSavepoint-1), then this function is a no-op. + ** + ** If a negative value is passed to this function, then the current + ** transaction is rolled back. This is different to calling + ** sqlite3PagerRollback() because this function does not terminate + ** the transaction or unlock the database, it just restores the + ** contents of the database to its original state. + ** + ** In any case, all savepoints with an index greater than iSavepoint + ** are destroyed. If this is a release operation (op==SAVEPOINT_RELEASE), + ** then savepoint iSavepoint is also destroyed. + ** + ** This function may return SQLITE_NOMEM if a memory allocation fails, + ** or an IO error code if an IO error occurs while rolling back a + ** savepoint. If no errors occur, SQLITE_OK is returned. + */ + static int sqlite3PagerSavepoint(Pager pPager, int op, int iSavepoint) { + int rc = pPager.errCode; /* Return code */ + + Debug.Assert(op == SAVEPOINT_RELEASE || op == SAVEPOINT_ROLLBACK); + Debug.Assert(iSavepoint >= 0 || op == SAVEPOINT_ROLLBACK); + + if (rc == SQLITE_OK && iSavepoint < pPager.nSavepoint) { + int ii; /* Iterator variable */ + int nNew; /* Number of remaining savepoints after this op. */ + + /* Figure out how many savepoints will still be active after this + ** operation. Store this value in nNew. Then free resources associated + ** with any savepoints that are destroyed by this operation. + */ + nNew = iSavepoint + ((op == SAVEPOINT_RELEASE) ? 0 : 1); + for (ii = nNew; ii < pPager.nSavepoint; ii++) { + sqlite3BitvecDestroy(ref pPager.aSavepoint[ii].pInSavepoint); + } + pPager.nSavepoint = nNew; + + /* If this is a release of the outermost savepoint, truncate + ** the sub-journal to zero bytes in size. */ + if (op == SAVEPOINT_RELEASE) { + if (nNew == 0 && isOpen(pPager.sjfd)) { + /* Only truncate if it is an in-memory sub-journal. */ + if (sqlite3IsMemJournal(pPager.sjfd)) { + rc = sqlite3OsTruncate(pPager.sjfd, 0); + Debug.Assert(rc == SQLITE_OK); + } + pPager.nSubRec = 0; + } + } + /* Else this is a rollback operation, playback the specified savepoint. + ** If this is a temp-file, it is possible that the journal file has + ** not yet been opened. In this case there have been no changes to + ** the database file, so the playback operation can be skipped. + */ + else if (pagerUseWal(pPager) || isOpen(pPager.jfd)) { + PagerSavepoint pSavepoint = (nNew == 0) ? null : pPager.aSavepoint[nNew - 1]; + rc = pagerPlaybackSavepoint(pPager, pSavepoint); + Debug.Assert(rc != SQLITE_DONE); + } } - pPager.nSubRec = 0; - } + return rc; } - /* Else this is a rollback operation, playback the specified savepoint. - ** If this is a temp-file, it is possible that the journal file has - ** not yet been opened. In this case there have been no changes to - ** the database file, so the playback operation can be skipped. + + /* + ** Return the full pathname of the database file. */ - else if ( pagerUseWal( pPager ) || isOpen( pPager.jfd ) ) - { - PagerSavepoint pSavepoint = ( nNew == 0 ) ? null : pPager.aSavepoint[nNew - 1]; - rc = pagerPlaybackSavepoint( pPager, pSavepoint ); - Debug.Assert( rc != SQLITE_DONE ); + static string sqlite3PagerFilename(Pager pPager) { + return pPager.zFilename; } - } - return rc; - } - - /* - ** Return the full pathname of the database file. - */ - static string sqlite3PagerFilename( Pager pPager ) - { - return pPager.zFilename; - } - /* - ** Return the VFS structure for the pager. - */ - static sqlite3_vfs sqlite3PagerVfs( Pager pPager ) - { - return pPager.pVfs; - } + /* + ** Return the VFS structure for the pager. + */ + static sqlite3_vfs sqlite3PagerVfs(Pager pPager) { + return pPager.pVfs; + } - /* - ** Return the file handle for the database file associated - ** with the pager. This might return NULL if the file has - ** not yet been opened. - */ - static sqlite3_file sqlite3PagerFile( Pager pPager ) - { - return pPager.fd; - } + /* + ** Return the file handle for the database file associated + ** with the pager. This might return NULL if the file has + ** not yet been opened. + */ + static sqlite3_file sqlite3PagerFile(Pager pPager) { + return pPager.fd; + } - /* - ** Return the full pathname of the journal file. - */ - static string sqlite3PagerJournalname( Pager pPager ) - { - return pPager.zJournal; - } + /* + ** Return the full pathname of the journal file. + */ + static string sqlite3PagerJournalname(Pager pPager) { + return pPager.zJournal; + } - /* - ** Return true if fsync() calls are disabled for this pager. Return FALSE - ** if fsync()s are executed normally. - */ - static bool sqlite3PagerNosync( Pager pPager ) - { - return pPager.noSync; - } + /* + ** Return true if fsync() calls are disabled for this pager. Return FALSE + ** if fsync()s are executed normally. + */ + static bool sqlite3PagerNosync(Pager pPager) { + return pPager.noSync; + } #if SQLITE_HAS_CODEC /* @@ -7229,413 +6733,378 @@ static object sqlite3PagerGetCodec( Pager pPager ) #endif #if !SQLITE_OMIT_AUTOVACUUM - /* -** Move the page pPg to location pgno in the file. -** -** There must be no references to the page previously located at -** pgno (which we call pPgOld) though that page is allowed to be -** in cache. If the page previously located at pgno is not already -** in the rollback journal, it is not put there by by this routine. -** -** References to the page pPg remain valid. Updating any -** meta-data associated with pPg (i.e. data stored in the nExtra bytes -** allocated along with the page) is the responsibility of the caller. -** -** A transaction must be active when this routine is called. It used to be -** required that a statement transaction was not active, but this restriction -** has been removed (CREATE INDEX needs to move a page when a statement -** transaction is active). -** -** If the fourth argument, isCommit, is non-zero, then this page is being -** moved as part of a database reorganization just before the transaction -** is being committed. In this case, it is guaranteed that the database page -** pPg refers to will not be written to again within this transaction. -** -** This function may return SQLITE_NOMEM or an IO error code if an error -** occurs. Otherwise, it returns SQLITE_OK. -*/ - static int sqlite3PagerMovepage( Pager pPager, DbPage pPg, u32 pgno, int isCommit ) - { - PgHdr pPgOld; /* The page being overwritten. */ - u32 needSyncPgno = 0; /* Old value of pPg.pgno, if sync is required */ - int rc; /* Return code */ - Pgno origPgno; /* The original page number */ - - Debug.Assert( pPg.nRef > 0 ); - Debug.Assert( pPager.eState == PAGER_WRITER_CACHEMOD - || pPager.eState == PAGER_WRITER_DBMOD - ); - Debug.Assert( assert_pager_state( pPager ) ); + /* + ** Move the page pPg to location pgno in the file. + ** + ** There must be no references to the page previously located at + ** pgno (which we call pPgOld) though that page is allowed to be + ** in cache. If the page previously located at pgno is not already + ** in the rollback journal, it is not put there by by this routine. + ** + ** References to the page pPg remain valid. Updating any + ** meta-data associated with pPg (i.e. data stored in the nExtra bytes + ** allocated along with the page) is the responsibility of the caller. + ** + ** A transaction must be active when this routine is called. It used to be + ** required that a statement transaction was not active, but this restriction + ** has been removed (CREATE INDEX needs to move a page when a statement + ** transaction is active). + ** + ** If the fourth argument, isCommit, is non-zero, then this page is being + ** moved as part of a database reorganization just before the transaction + ** is being committed. In this case, it is guaranteed that the database page + ** pPg refers to will not be written to again within this transaction. + ** + ** This function may return SQLITE_NOMEM or an IO error code if an error + ** occurs. Otherwise, it returns SQLITE_OK. + */ + static int sqlite3PagerMovepage(Pager pPager, DbPage pPg, u32 pgno, int isCommit) { + PgHdr pPgOld; /* The page being overwritten. */ + u32 needSyncPgno = 0; /* Old value of pPg.pgno, if sync is required */ + int rc; /* Return code */ + Pgno origPgno; /* The original page number */ + + Debug.Assert(pPg.nRef > 0); + Debug.Assert(pPager.eState == PAGER_WRITER_CACHEMOD + || pPager.eState == PAGER_WRITER_DBMOD + ); + Debug.Assert(assert_pager_state(pPager)); - /* In order to be able to rollback, an in-memory database must journal - ** the page we are moving from. - */ - if ( + /* In order to be able to rollback, an in-memory database must journal + ** the page we are moving from. + */ + if ( #if SQLITE_OMIT_MEMORYDB 1==MEMDB #else - pPager.memDb != 0 + pPager.memDb != 0 #endif - ) - { - rc = sqlite3PagerWrite( pPg ); - if ( rc != 0 ) - return rc; - } + ) { + rc = sqlite3PagerWrite(pPg); + if (rc != 0) + return rc; + } - /* If the page being moved is dirty and has not been saved by the latest - ** savepoint, then save the current contents of the page into the - ** sub-journal now. This is required to handle the following scenario: - ** - ** BEGIN; - ** - ** SAVEPOINT one; - ** - ** ROLLBACK TO one; - ** - ** If page X were not written to the sub-journal here, it would not - ** be possible to restore its contents when the "ROLLBACK TO one" - ** statement were is processed. - ** - ** subjournalPage() may need to allocate space to store pPg.pgno into - ** one or more savepoint bitvecs. This is the reason this function - ** may return SQLITE_NOMEM. - */ - if ( ( pPg.flags & PGHDR_DIRTY ) != 0 - && subjRequiresPage( pPg ) - && SQLITE_OK != ( rc = subjournalPage( pPg ) ) - ) - { - return rc; - } + /* If the page being moved is dirty and has not been saved by the latest + ** savepoint, then save the current contents of the page into the + ** sub-journal now. This is required to handle the following scenario: + ** + ** BEGIN; + ** + ** SAVEPOINT one; + ** + ** ROLLBACK TO one; + ** + ** If page X were not written to the sub-journal here, it would not + ** be possible to restore its contents when the "ROLLBACK TO one" + ** statement were is processed. + ** + ** subjournalPage() may need to allocate space to store pPg.pgno into + ** one or more savepoint bitvecs. This is the reason this function + ** may return SQLITE_NOMEM. + */ + if ((pPg.flags & PGHDR_DIRTY) != 0 + && subjRequiresPage(pPg) + && SQLITE_OK != (rc = subjournalPage(pPg)) + ) { + return rc; + } - PAGERTRACE( "MOVE %d page %d (needSync=%d) moves to %d\n", - PAGERID( pPager ), pPg.pgno, ( pPg.flags & PGHDR_NEED_SYNC ) != 0 ? 1 : 0, pgno ); - IOTRACE( "MOVE %p %d %d\n", pPager, pPg.pgno, pgno ); + PAGERTRACE("MOVE %d page %d (needSync=%d) moves to %d\n", + PAGERID(pPager), pPg.pgno, (pPg.flags & PGHDR_NEED_SYNC) != 0 ? 1 : 0, pgno); + IOTRACE("MOVE %p %d %d\n", pPager, pPg.pgno, pgno); - /* If the journal needs to be sync()ed before page pPg.pgno can - ** be written to, store pPg.pgno in local variable needSyncPgno. - ** - ** If the isCommit flag is set, there is no need to remember that - ** the journal needs to be sync()ed before database page pPg.pgno - ** can be written to. The caller has already promised not to write to it. - */ - if ( ( ( pPg.flags & PGHDR_NEED_SYNC ) != 0 ) && 0 == isCommit ) - { - needSyncPgno = pPg.pgno; - Debug.Assert( pageInJournal( pPg ) || pPg.pgno > pPager.dbOrigSize ); - Debug.Assert( ( pPg.flags & PGHDR_DIRTY ) != 0 ); - } + /* If the journal needs to be sync()ed before page pPg.pgno can + ** be written to, store pPg.pgno in local variable needSyncPgno. + ** + ** If the isCommit flag is set, there is no need to remember that + ** the journal needs to be sync()ed before database page pPg.pgno + ** can be written to. The caller has already promised not to write to it. + */ + if (((pPg.flags & PGHDR_NEED_SYNC) != 0) && 0 == isCommit) { + needSyncPgno = pPg.pgno; + Debug.Assert(pageInJournal(pPg) || pPg.pgno > pPager.dbOrigSize); + Debug.Assert((pPg.flags & PGHDR_DIRTY) != 0); + } - /* If the cache contains a page with page-number pgno, remove it - ** from its hash chain. Also, if the PGHDR_NEED_SYNC was set for - ** page pgno before the 'move' operation, it needs to be retained - ** for the page moved there. - */ - pPg.flags &= ~PGHDR_NEED_SYNC; - pPgOld = pager_lookup( pPager, pgno ); - Debug.Assert( null == pPgOld || pPgOld.nRef == 1 ); - if ( pPgOld != null ) - { - pPg.flags |= ( pPgOld.flags & PGHDR_NEED_SYNC ); - if ( + /* If the cache contains a page with page-number pgno, remove it + ** from its hash chain. Also, if the PGHDR_NEED_SYNC was set for + ** page pgno before the 'move' operation, it needs to be retained + ** for the page moved there. + */ + pPg.flags &= ~PGHDR_NEED_SYNC; + pPgOld = pager_lookup(pPager, pgno); + Debug.Assert(null == pPgOld || pPgOld.nRef == 1); + if (pPgOld != null) { + pPg.flags |= (pPgOld.flags & PGHDR_NEED_SYNC); + if ( #if SQLITE_OMIT_MEMORYDB 1==MEMDB #else - pPager.memDb != 0 + pPager.memDb != 0 #endif - ) - { - /* Do not discard pages from an in-memory database since we might - ** need to rollback later. Just move the page out of the way. */ - sqlite3PcacheMove( pPgOld, pPager.dbSize + 1 ); - } - else - { - sqlite3PcacheDrop( pPgOld ); - } - } - origPgno = pPg.pgno; - sqlite3PcacheMove( pPg, pgno ); - sqlite3PcacheMakeDirty( pPg ); + ) { + /* Do not discard pages from an in-memory database since we might + ** need to rollback later. Just move the page out of the way. */ + sqlite3PcacheMove(pPgOld, pPager.dbSize + 1); + } else { + sqlite3PcacheDrop(pPgOld); + } + } + origPgno = pPg.pgno; + sqlite3PcacheMove(pPg, pgno); + sqlite3PcacheMakeDirty(pPg); - /* For an in-memory database, make sure the original page continues - ** to exist, in case the transaction needs to roll back. Use pPgOld - ** as the original page since it has already been allocated. - */ - if ( + /* For an in-memory database, make sure the original page continues + ** to exist, in case the transaction needs to roll back. Use pPgOld + ** as the original page since it has already been allocated. + */ + if ( #if SQLITE_OMIT_MEMORYDB 0!=MEMDB #else - 0 != pPager.memDb + 0 != pPager.memDb #endif - ) - { - Debug.Assert( pPgOld ); - sqlite3PcacheMove( pPgOld, origPgno ); - sqlite3PagerUnref( pPgOld ); - } + ) { + Debug.Assert(pPgOld); + sqlite3PcacheMove(pPgOld, origPgno); + sqlite3PagerUnref(pPgOld); + } - if ( needSyncPgno != 0 ) - { - /* If needSyncPgno is non-zero, then the journal file needs to be - ** sync()ed before any data is written to database file page needSyncPgno. - ** Currently, no such page exists in the page-cache and the - ** "is journaled" bitvec flag has been set. This needs to be remedied by - ** loading the page into the pager-cache and setting the PGHDR_NEED_SYNC - ** flag. - ** - ** If the attempt to load the page into the page-cache fails, (due - ** to a malloc() or IO failure), clear the bit in the pInJournal[] - ** array. Otherwise, if the page is loaded and written again in - ** this transaction, it may be written to the database file before - ** it is synced into the journal file. This way, it may end up in - ** the journal file twice, but that is not a problem. - */ - PgHdr pPgHdr = null; - rc = sqlite3PagerGet( pPager, needSyncPgno, ref pPgHdr ); - if ( rc != SQLITE_OK ) - { - if ( needSyncPgno <= pPager.dbOrigSize ) - { - Debug.Assert( pPager.pTmpSpace != null ); - u32[] pTemp = new u32[pPager.pTmpSpace.Length]; - sqlite3BitvecClear( pPager.pInJournal, needSyncPgno, pTemp );//pPager.pTmpSpace ); - } - return rc; + if (needSyncPgno != 0) { + /* If needSyncPgno is non-zero, then the journal file needs to be + ** sync()ed before any data is written to database file page needSyncPgno. + ** Currently, no such page exists in the page-cache and the + ** "is journaled" bitvec flag has been set. This needs to be remedied by + ** loading the page into the pager-cache and setting the PGHDR_NEED_SYNC + ** flag. + ** + ** If the attempt to load the page into the page-cache fails, (due + ** to a malloc() or IO failure), clear the bit in the pInJournal[] + ** array. Otherwise, if the page is loaded and written again in + ** this transaction, it may be written to the database file before + ** it is synced into the journal file. This way, it may end up in + ** the journal file twice, but that is not a problem. + */ + PgHdr pPgHdr = null; + rc = sqlite3PagerGet(pPager, needSyncPgno, ref pPgHdr); + if (rc != SQLITE_OK) { + if (needSyncPgno <= pPager.dbOrigSize) { + Debug.Assert(pPager.pTmpSpace != null); + u32[] pTemp = new u32[pPager.pTmpSpace.Length]; + sqlite3BitvecClear(pPager.pInJournal, needSyncPgno, pTemp);//pPager.pTmpSpace ); + } + return rc; + } + pPgHdr.flags |= PGHDR_NEED_SYNC; + sqlite3PcacheMakeDirty(pPgHdr); + sqlite3PagerUnref(pPgHdr); + } + return SQLITE_OK; } - pPgHdr.flags |= PGHDR_NEED_SYNC; - sqlite3PcacheMakeDirty( pPgHdr ); - sqlite3PagerUnref( pPgHdr ); - } - return SQLITE_OK; - } #endif - /* -** Return a pointer to the data for the specified page. -*/ - static byte[] sqlite3PagerGetData( DbPage pPg ) - { - Debug.Assert( pPg.nRef > 0 || pPg.pPager.memDb != 0 ); - return pPg.pData; - } - - /* - ** Return a pointer to the Pager.nExtra bytes of "extra" space - ** allocated along with the specified page. + /* + ** Return a pointer to the data for the specified page. */ - static MemPage sqlite3PagerGetExtra( DbPage pPg ) - { - return pPg.pExtra; - } + static byte[] sqlite3PagerGetData(DbPage pPg) { + Debug.Assert(pPg.nRef > 0 || pPg.pPager.memDb != 0); + return pPg.pData; + } - /* - ** Get/set the locking-mode for this pager. Parameter eMode must be one - ** of PAGER_LOCKINGMODE_QUERY, PAGER_LOCKINGMODE_NORMAL or - ** PAGER_LOCKINGMODE_EXCLUSIVE. If the parameter is not _QUERY, then - ** the locking-mode is set to the value specified. - ** - ** The returned value is either PAGER_LOCKINGMODE_NORMAL or - ** PAGER_LOCKINGMODE_EXCLUSIVE, indicating the current (possibly updated) - ** locking-mode. - */ - static bool sqlite3PagerLockingMode( Pager pPager, int eMode ) - { - Debug.Assert( eMode == PAGER_LOCKINGMODE_QUERY - || eMode == PAGER_LOCKINGMODE_NORMAL - || eMode == PAGER_LOCKINGMODE_EXCLUSIVE ); - Debug.Assert( PAGER_LOCKINGMODE_QUERY < 0 ); - Debug.Assert( PAGER_LOCKINGMODE_NORMAL >= 0 && PAGER_LOCKINGMODE_EXCLUSIVE >= 0 ); - Debug.Assert( pPager.exclusiveMode || false == sqlite3WalHeapMemory( pPager.pWal ) ); - if ( eMode >= 0 && !pPager.tempFile && !sqlite3WalHeapMemory( pPager.pWal ) ) - { - pPager.exclusiveMode = eMode != 0; - } - return pPager.exclusiveMode; - } + /* + ** Return a pointer to the Pager.nExtra bytes of "extra" space + ** allocated along with the specified page. + */ + static MemPage sqlite3PagerGetExtra(DbPage pPg) { + return pPg.pExtra; + } - /* - ** Set the journal-mode for this pager. Parameter eMode must be one of: - ** - ** PAGER_JOURNALMODE_DELETE - ** PAGER_JOURNALMODE_TRUNCATE - ** PAGER_JOURNALMODE_PERSIST - ** PAGER_JOURNALMODE_OFF - ** PAGER_JOURNALMODE_MEMORY - ** PAGER_JOURNALMODE_WAL - ** - ** The journalmode is set to the value specified if the change is allowed. - ** The change may be disallowed for the following reasons: - ** - ** * An in-memory database can only have its journal_mode set to _OFF - ** or _MEMORY. - ** - ** * Temporary databases cannot have _WAL journalmode. - ** - ** The returned indicate the current (possibly updated) journal-mode. - */ - static int sqlite3PagerSetJournalMode( Pager pPager, int eMode ) - { - u8 eOld = pPager.journalMode; /* Prior journalmode */ + /* + ** Get/set the locking-mode for this pager. Parameter eMode must be one + ** of PAGER_LOCKINGMODE_QUERY, PAGER_LOCKINGMODE_NORMAL or + ** PAGER_LOCKINGMODE_EXCLUSIVE. If the parameter is not _QUERY, then + ** the locking-mode is set to the value specified. + ** + ** The returned value is either PAGER_LOCKINGMODE_NORMAL or + ** PAGER_LOCKINGMODE_EXCLUSIVE, indicating the current (possibly updated) + ** locking-mode. + */ + static bool sqlite3PagerLockingMode(Pager pPager, int eMode) { + Debug.Assert(eMode == PAGER_LOCKINGMODE_QUERY + || eMode == PAGER_LOCKINGMODE_NORMAL + || eMode == PAGER_LOCKINGMODE_EXCLUSIVE); + Debug.Assert(PAGER_LOCKINGMODE_QUERY < 0); + Debug.Assert(PAGER_LOCKINGMODE_NORMAL >= 0 && PAGER_LOCKINGMODE_EXCLUSIVE >= 0); + Debug.Assert(pPager.exclusiveMode || false == sqlite3WalHeapMemory(pPager.pWal)); + if (eMode >= 0 && !pPager.tempFile && !sqlite3WalHeapMemory(pPager.pWal)) { + pPager.exclusiveMode = eMode != 0; + } + return pPager.exclusiveMode; + } + + /* + ** Set the journal-mode for this pager. Parameter eMode must be one of: + ** + ** PAGER_JOURNALMODE_DELETE + ** PAGER_JOURNALMODE_TRUNCATE + ** PAGER_JOURNALMODE_PERSIST + ** PAGER_JOURNALMODE_OFF + ** PAGER_JOURNALMODE_MEMORY + ** PAGER_JOURNALMODE_WAL + ** + ** The journalmode is set to the value specified if the change is allowed. + ** The change may be disallowed for the following reasons: + ** + ** * An in-memory database can only have its journal_mode set to _OFF + ** or _MEMORY. + ** + ** * Temporary databases cannot have _WAL journalmode. + ** + ** The returned indicate the current (possibly updated) journal-mode. + */ + static int sqlite3PagerSetJournalMode(Pager pPager, int eMode) { + u8 eOld = pPager.journalMode; /* Prior journalmode */ #if SQLITE_DEBUG - /* The print_pager_state() routine is intended to be used by the debugger -** only. We invoke it once here to suppress a compiler warning. */ - print_pager_state( pPager ); + /* The print_pager_state() routine is intended to be used by the debugger + ** only. We invoke it once here to suppress a compiler warning. */ + print_pager_state(pPager); #endif - /* The eMode parameter is always valid */ - Debug.Assert( eMode == PAGER_JOURNALMODE_DELETE - || eMode == PAGER_JOURNALMODE_TRUNCATE - || eMode == PAGER_JOURNALMODE_PERSIST - || eMode == PAGER_JOURNALMODE_OFF - || eMode == PAGER_JOURNALMODE_WAL - || eMode == PAGER_JOURNALMODE_MEMORY ); - - /* This routine is only called from the OP_JournalMode opcode, and - ** the logic there will never allow a temporary file to be changed - ** to WAL mode. - */ - Debug.Assert( pPager.tempFile == false || eMode != PAGER_JOURNALMODE_WAL ); + /* The eMode parameter is always valid */ + Debug.Assert(eMode == PAGER_JOURNALMODE_DELETE + || eMode == PAGER_JOURNALMODE_TRUNCATE + || eMode == PAGER_JOURNALMODE_PERSIST + || eMode == PAGER_JOURNALMODE_OFF + || eMode == PAGER_JOURNALMODE_WAL + || eMode == PAGER_JOURNALMODE_MEMORY); + + /* This routine is only called from the OP_JournalMode opcode, and + ** the logic there will never allow a temporary file to be changed + ** to WAL mode. + */ + Debug.Assert(pPager.tempFile == false || eMode != PAGER_JOURNALMODE_WAL); - /* Do allow the journalmode of an in-memory database to be set to - ** anything other than MEMORY or OFF - */ - if ( + /* Do allow the journalmode of an in-memory database to be set to + ** anything other than MEMORY or OFF + */ + if ( #if SQLITE_OMIT_MEMORYDB 1==MEMDB #else - 1 == pPager.memDb + 1 == pPager.memDb #endif - ) - { - Debug.Assert( eOld == PAGER_JOURNALMODE_MEMORY || eOld == PAGER_JOURNALMODE_OFF ); - if ( eMode != PAGER_JOURNALMODE_MEMORY && eMode != PAGER_JOURNALMODE_OFF ) - { - eMode = eOld; - } - } + ) { + Debug.Assert(eOld == PAGER_JOURNALMODE_MEMORY || eOld == PAGER_JOURNALMODE_OFF); + if (eMode != PAGER_JOURNALMODE_MEMORY && eMode != PAGER_JOURNALMODE_OFF) { + eMode = eOld; + } + } - if ( eMode != eOld ) - { - /* Change the journal mode. */ - Debug.Assert( pPager.eState != PAGER_ERROR ); - pPager.journalMode = (u8)eMode; + if (eMode != eOld) { + /* Change the journal mode. */ + Debug.Assert(pPager.eState != PAGER_ERROR); + pPager.journalMode = (u8)eMode; - /* When transistioning from TRUNCATE or PERSIST to any other journal - ** mode except WAL, unless the pager is in locking_mode=exclusive mode, - ** delete the journal file. - */ - Debug.Assert( ( PAGER_JOURNALMODE_TRUNCATE & 5 ) == 1 ); - Debug.Assert( ( PAGER_JOURNALMODE_PERSIST & 5 ) == 1 ); - Debug.Assert( ( PAGER_JOURNALMODE_DELETE & 5 ) == 0 ); - Debug.Assert( ( PAGER_JOURNALMODE_MEMORY & 5 ) == 4 ); - Debug.Assert( ( PAGER_JOURNALMODE_OFF & 5 ) == 0 ); - Debug.Assert( ( PAGER_JOURNALMODE_WAL & 5 ) == 5 ); - - Debug.Assert( isOpen( pPager.fd ) || pPager.exclusiveMode ); - if ( !pPager.exclusiveMode && ( eOld & 5 ) == 1 && ( eMode & 1 ) == 0 ) - { - - /* In this case we would like to delete the journal file. If it is - ** not possible, then that is not a problem. Deleting the journal file - ** here is an optimization only. - ** - ** Before deleting the journal file, obtain a RESERVED lock on the - ** database file. This ensures that the journal file is not deleted - ** while it is in use by some other client. - */ - sqlite3OsClose( pPager.jfd ); - if ( pPager.eLock >= RESERVED_LOCK ) - { - sqlite3OsDelete( pPager.pVfs, pPager.zJournal, 0 ); - } - else - { - int rc = SQLITE_OK; - int state = pPager.eState; - Debug.Assert( state == PAGER_OPEN || state == PAGER_READER ); - if ( state == PAGER_OPEN ) - { - rc = sqlite3PagerSharedLock( pPager ); - } - if ( pPager.eState == PAGER_READER ) - { - Debug.Assert( rc == SQLITE_OK ); - rc = pagerLockDb( pPager, RESERVED_LOCK ); - } - if ( rc == SQLITE_OK ) - { - sqlite3OsDelete( pPager.pVfs, pPager.zJournal, 0 ); - } - if ( rc == SQLITE_OK && state == PAGER_READER ) - { - pagerUnlockDb( pPager, SHARED_LOCK ); - } - else if ( state == PAGER_OPEN ) - { - pager_unlock( pPager ); + /* When transistioning from TRUNCATE or PERSIST to any other journal + ** mode except WAL, unless the pager is in locking_mode=exclusive mode, + ** delete the journal file. + */ + Debug.Assert((PAGER_JOURNALMODE_TRUNCATE & 5) == 1); + Debug.Assert((PAGER_JOURNALMODE_PERSIST & 5) == 1); + Debug.Assert((PAGER_JOURNALMODE_DELETE & 5) == 0); + Debug.Assert((PAGER_JOURNALMODE_MEMORY & 5) == 4); + Debug.Assert((PAGER_JOURNALMODE_OFF & 5) == 0); + Debug.Assert((PAGER_JOURNALMODE_WAL & 5) == 5); + + Debug.Assert(isOpen(pPager.fd) || pPager.exclusiveMode); + if (!pPager.exclusiveMode && (eOld & 5) == 1 && (eMode & 1) == 0) { + + /* In this case we would like to delete the journal file. If it is + ** not possible, then that is not a problem. Deleting the journal file + ** here is an optimization only. + ** + ** Before deleting the journal file, obtain a RESERVED lock on the + ** database file. This ensures that the journal file is not deleted + ** while it is in use by some other client. + */ + sqlite3OsClose(pPager.jfd); + if (pPager.eLock >= RESERVED_LOCK) { + sqlite3OsDelete(pPager.pVfs, pPager.zJournal, 0); + } else { + int rc = SQLITE_OK; + int state = pPager.eState; + Debug.Assert(state == PAGER_OPEN || state == PAGER_READER); + if (state == PAGER_OPEN) { + rc = sqlite3PagerSharedLock(pPager); + } + if (pPager.eState == PAGER_READER) { + Debug.Assert(rc == SQLITE_OK); + rc = pagerLockDb(pPager, RESERVED_LOCK); + } + if (rc == SQLITE_OK) { + sqlite3OsDelete(pPager.pVfs, pPager.zJournal, 0); + } + if (rc == SQLITE_OK && state == PAGER_READER) { + pagerUnlockDb(pPager, SHARED_LOCK); + } else if (state == PAGER_OPEN) { + pager_unlock(pPager); + } + Debug.Assert(state == pPager.eState); + } + } } - Debug.Assert( state == pPager.eState ); - } - } - } - /* Return the new journal mode */ - return (int)pPager.journalMode; - } + /* Return the new journal mode */ + return (int)pPager.journalMode; + } - /* - ** Return the current journal mode. - */ - static int sqlite3PagerGetJournalMode( Pager pPager ) - { - return (int)pPager.journalMode; - } + /* + ** Return the current journal mode. + */ + static int sqlite3PagerGetJournalMode(Pager pPager) { + return (int)pPager.journalMode; + } - /* - ** Return TRUE if the pager is in a state where it is OK to change the - ** journalmode. Journalmode changes can only happen when the database - ** is unmodified. - */ - static int sqlite3PagerOkToChangeJournalMode( Pager pPager ) - { - Debug.Assert( assert_pager_state( pPager ) ); - if ( pPager.eState >= PAGER_WRITER_CACHEMOD ) - return 0; - if ( NEVER( isOpen( pPager.jfd ) && pPager.journalOff > 0 ) ) - return 0; - return 1; - } + /* + ** Return TRUE if the pager is in a state where it is OK to change the + ** journalmode. Journalmode changes can only happen when the database + ** is unmodified. + */ + static int sqlite3PagerOkToChangeJournalMode(Pager pPager) { + Debug.Assert(assert_pager_state(pPager)); + if (pPager.eState >= PAGER_WRITER_CACHEMOD) + return 0; + if (NEVER(isOpen(pPager.jfd) && pPager.journalOff > 0)) + return 0; + return 1; + } - /* - ** Get/set the size-limit used for persistent journal files. - ** - ** Setting the size limit to -1 means no limit is enforced. - ** An attempt to set a limit smaller than -1 is a no-op. - */ - static i64 sqlite3PagerJournalSizeLimit( Pager pPager, i64 iLimit ) - { - if ( iLimit >= -1 ) - { - pPager.journalSizeLimit = iLimit; - sqlite3WalLimit( pPager.pWal, iLimit ); - } - return pPager.journalSizeLimit; - } + /* + ** Get/set the size-limit used for persistent journal files. + ** + ** Setting the size limit to -1 means no limit is enforced. + ** An attempt to set a limit smaller than -1 is a no-op. + */ + static i64 sqlite3PagerJournalSizeLimit(Pager pPager, i64 iLimit) { + if (iLimit >= -1) { + pPager.journalSizeLimit = iLimit; + sqlite3WalLimit(pPager.pWal, iLimit); + } + return pPager.journalSizeLimit; + } - /* - ** Return a pointer to the pPager.pBackup variable. The backup module - ** in backup.c maintains the content of this variable. This module - ** uses it opaquely as an argument to sqlite3BackupRestart() and - ** sqlite3BackupUpdate() only. - */ - static sqlite3_backup sqlite3PagerBackupPtr( Pager pPager ) - { - return pPager.pBackup; - } + /* + ** Return a pointer to the pPager.pBackup variable. The backup module + ** in backup.c maintains the content of this variable. This module + ** uses it opaquely as an argument to sqlite3BackupRestart() and + ** sqlite3BackupUpdate() only. + */ + static sqlite3_backup sqlite3PagerBackupPtr(Pager pPager) { + return pPager.pBackup; + } #if !SQLITE_OMIT_WAL /* @@ -7831,5 +7300,5 @@ void sqlite3PagerCodec(PgHdr *pPg){ #endif //* !SQLITE_OMIT_WAL */ #endif // * SQLITE_OMIT_DISKIO */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/pager_h.cs b/Src/IronPython.SQLite/c#sqlite/pager_h.cs index be85989a9..a488d730b 100644 --- a/Src/IronPython.SQLite/c#sqlite/pager_h.cs +++ b/Src/IronPython.SQLite/c#sqlite/pager_h.cs @@ -1,208 +1,205 @@ using Pgno = System.UInt32; -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 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. - ** - ************************************************************************* - ** This header file defines the interface that the sqlite page cache - ** subsystem. The page cache subsystem reads and writes a file a page - ** at a time and provides a journal for rollback. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ - //#if !_PAGER_H_ - //#define _PAGER_H_ - - /* - ** Default maximum size for persistent journal files. A negative - ** value means no limit. This value may be overridden using the - ** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit". - */ +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** This header file defines the interface that the sqlite page cache + ** subsystem. The page cache subsystem reads and writes a file a page + ** at a time and provides a journal for rollback. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ + //#if !_PAGER_H_ + //#define _PAGER_H_ + + /* + ** Default maximum size for persistent journal files. A negative + ** value means no limit. This value may be overridden using the + ** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit". + */ #if !SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT - const int SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT = -1;//#define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT -1 + const int SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT = -1;//#define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT -1 #endif - /* -** The type used to represent a page number. The first page in a file -** is called page 1. 0 is used to represent "not a page". -*/ - //typedef u32 Pgno; - - /* - ** Each open file is managed by a separate instance of the "Pager" structure. - */ - //typedef struct Pager Pager; - - /* - ** Handle type for pages. + /* + ** The type used to represent a page number. The first page in a file + ** is called page 1. 0 is used to represent "not a page". */ - //typedef struct PgHdr DbPage; - - /* - ** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is - ** reserved for working around a windows/posix incompatibility). It is - ** used in the journal to signify that the remainder of the journal file - ** is devoted to storing a master journal name - there are no more pages to - ** roll back. See comments for function writeMasterJournal() in pager.c - ** for details. - */ - //#define PAGER_MJ_PGNO(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1)) - static Pgno PAGER_MJ_PGNO( Pager x ) - { - return ( (Pgno)( ( PENDING_BYTE / ( ( x ).pageSize ) ) + 1 ) ); + //typedef u32 Pgno; + + /* + ** Each open file is managed by a separate instance of the "Pager" structure. + */ + //typedef struct Pager Pager; + + /* + ** Handle type for pages. + */ + //typedef struct PgHdr DbPage; + + /* + ** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is + ** reserved for working around a windows/posix incompatibility). It is + ** used in the journal to signify that the remainder of the journal file + ** is devoted to storing a master journal name - there are no more pages to + ** roll back. See comments for function writeMasterJournal() in pager.c + ** for details. + */ + //#define PAGER_MJ_PGNO(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1)) + static Pgno PAGER_MJ_PGNO(Pager x) { + return ((Pgno)((PENDING_BYTE / ((x).pageSize)) + 1)); + } + /* + ** Allowed values for the flags parameter to sqlite3PagerOpen(). + ** + ** NOTE: These values must match the corresponding BTREE_ values in btree.h. + */ + //#define PAGER_OMIT_JOURNAL 0x0001 /* Do not use a rollback journal */ + //#define PAGER_NO_READLOCK 0x0002 /* Omit readlocks on readonly files */ + //#define PAGER_MEMORY 0x0004 /* In-memory database */ + const int PAGER_OMIT_JOURNAL = 0x0001; + const int PAGER_NO_READLOCK = 0x0002; + const int PAGER_MEMORY = 0x0004; + + /* + ** Valid values for the second argument to sqlite3PagerLockingMode(). + */ + //#define PAGER_LOCKINGMODE_QUERY -1 + //#define PAGER_LOCKINGMODE_NORMAL 0 + //#define PAGER_LOCKINGMODE_EXCLUSIVE 1 + static int PAGER_LOCKINGMODE_QUERY = -1; + static int PAGER_LOCKINGMODE_NORMAL = 0; + static int PAGER_LOCKINGMODE_EXCLUSIVE = 1; + + /* + ** Numeric constants that encode the journalmode. + */ + //#define PAGER_JOURNALMODE_QUERY (-1) /* Query the value of journalmode */ + //#define PAGER_JOURNALMODE_DELETE 0 /* Commit by deleting journal file */ + //#define PAGER_JOURNALMODE_PERSIST 1 /* Commit by zeroing journal header */ + //#define PAGER_JOURNALMODE_OFF 2 /* Journal omitted. */ + //#define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */ + //#define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */ + //#define PAGER_JOURNALMODE_WAL 5 /* Use write-ahead logging */ + const int PAGER_JOURNALMODE_QUERY = -1; + const int PAGER_JOURNALMODE_DELETE = 0; + const int PAGER_JOURNALMODE_PERSIST = 1; + const int PAGER_JOURNALMODE_OFF = 2; + const int PAGER_JOURNALMODE_TRUNCATE = 3; + const int PAGER_JOURNALMODE_MEMORY = 4; + const int PAGER_JOURNALMODE_WAL = 5; + + /* + ** The remainder of this file contains the declarations of the functions + ** that make up the Pager sub-system API. See source code comments for + ** a detailed description of each routine. + */ + /* Open and close a Pager connection. */ + //int sqlite3PagerOpen( + // sqlite3_vfs*, + // Pager **ppPager, + // const char*, + // int, + // int, + // int, + //// void()(DbPage) + //); + //int sqlite3PagerClose(Pager *pPager); + //int sqlite3PagerReadFileheader(Pager*, int, unsigned char); + + /* Functions used to configure a Pager object. */ + //void sqlite3PagerSetBusyhandler(Pager*, int()(void ), object ); + //int sqlite3PagerSetPagesize(Pager*, u32*, int); + //int sqlite3PagerMaxPageCount(Pager*, int); + //void sqlite3PagerSetCachesize(Pager*, int); + //void sqlite3PagerSetSafetyLevel(Pager*,int,int,int); + //int sqlite3PagerLockingMode(Pager *, int); + //int sqlite3PagerSetJournalMode(Pager *, int); + //int sqlite3PagerGetJournalMode(Pager); + //int sqlite3PagerOkToChangeJournalMode(Pager); + //i64 sqlite3PagerJournalSizeLimit(Pager *, i64); + //sqlite3_backup **sqlite3PagerBackupPtr(Pager); + + /* Functions used to obtain and release page references. */ + //int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag); + //#define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0) + //DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno); + //void sqlite3PagerRef(DbPage); + //void sqlite3PagerUnref(DbPage); + + /* Operations on page references. */ + //int sqlite3PagerWrite(DbPage); + //void sqlite3PagerDontWrite(DbPage); + //int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int); + //int sqlite3PagerPageRefcount(DbPage); + //void *sqlite3PagerGetData(DbPage ); + //void *sqlite3PagerGetExtra(DbPage ); + + /* Functions used to manage pager transactions and savepoints. */ + //void sqlite3PagerPagecount(Pager*, int); + //int sqlite3PagerBegin(Pager*, int exFlag, int); + //int sqlite3PagerCommitPhaseOne(Pager*,string zMaster, int); + //int sqlite3PagerExclusiveLock(Pager); + //int sqlite3PagerSync(Pager *pPager); + //int sqlite3PagerCommitPhaseTwo(Pager); + //int sqlite3PagerRollback(Pager); + //int sqlite3PagerOpenSavepoint(Pager *pPager, int n); + //int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint); + //int sqlite3PagerSharedLock(Pager *pPager); + + //int sqlite3PagerCheckpoint(Pager *pPager, int, int*, int); + //int sqlite3PagerWalSupported(Pager* pPager); + //int sqlite3PagerWalCallback(Pager* pPager); + //int sqlite3PagerOpenWal(Pager* pPager, int* pisOpen); + //int sqlite3PagerCloseWal(Pager* pPager); + + /* Functions used to query pager state and configuration. */ + //u8 sqlite3PagerIsreadonly(Pager); + //int sqlite3PagerRefcount(Pager); + //int sqlite3PagerMemUsed(Pager); + //string sqlite3PagerFilename(Pager); + //const sqlite3_vfs *sqlite3PagerVfs(Pager); + //sqlite3_file *sqlite3PagerFile(Pager); + //string sqlite3PagerJournalname(Pager); + //int sqlite3PagerNosync(Pager); + //void *sqlite3PagerTempSpace(Pager); + //int sqlite3PagerIsMemdb(Pager); + + /* Functions used to truncate the database file. */ + //void sqlite3PagerTruncateImage(Pager*,Pgno); + + //#if (SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL) + //void *sqlite3PagerCodec(DbPage ); + //#endif + + /* Functions to support testing and debugging. */ + //#if !NDEBUG || SQLITE_TEST + // Pgno sqlite3PagerPagenumber(DbPage); + // int sqlite3PagerIswriteable(DbPage); + //#endif + //#if SQLITE_TEST + // int *sqlite3PagerStats(Pager); + // void sqlite3PagerRefdump(Pager); + // void disable_simulated_io_errors(void); + // void enable_simulated_io_errors(void); + //#else + //# define disable_simulated_io_errors() + //# define enable_simulated_io_errors() + //#endif } - /* - ** Allowed values for the flags parameter to sqlite3PagerOpen(). - ** - ** NOTE: These values must match the corresponding BTREE_ values in btree.h. - */ - //#define PAGER_OMIT_JOURNAL 0x0001 /* Do not use a rollback journal */ - //#define PAGER_NO_READLOCK 0x0002 /* Omit readlocks on readonly files */ - //#define PAGER_MEMORY 0x0004 /* In-memory database */ - const int PAGER_OMIT_JOURNAL = 0x0001; - const int PAGER_NO_READLOCK = 0x0002; - const int PAGER_MEMORY = 0x0004; - - /* - ** Valid values for the second argument to sqlite3PagerLockingMode(). - */ - //#define PAGER_LOCKINGMODE_QUERY -1 - //#define PAGER_LOCKINGMODE_NORMAL 0 - //#define PAGER_LOCKINGMODE_EXCLUSIVE 1 - static int PAGER_LOCKINGMODE_QUERY = -1; - static int PAGER_LOCKINGMODE_NORMAL = 0; - static int PAGER_LOCKINGMODE_EXCLUSIVE = 1; - - /* - ** Numeric constants that encode the journalmode. - */ - //#define PAGER_JOURNALMODE_QUERY (-1) /* Query the value of journalmode */ - //#define PAGER_JOURNALMODE_DELETE 0 /* Commit by deleting journal file */ - //#define PAGER_JOURNALMODE_PERSIST 1 /* Commit by zeroing journal header */ - //#define PAGER_JOURNALMODE_OFF 2 /* Journal omitted. */ - //#define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */ - //#define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */ - //#define PAGER_JOURNALMODE_WAL 5 /* Use write-ahead logging */ - const int PAGER_JOURNALMODE_QUERY = -1; - const int PAGER_JOURNALMODE_DELETE = 0; - const int PAGER_JOURNALMODE_PERSIST = 1; - const int PAGER_JOURNALMODE_OFF = 2; - const int PAGER_JOURNALMODE_TRUNCATE = 3; - const int PAGER_JOURNALMODE_MEMORY = 4; - const int PAGER_JOURNALMODE_WAL = 5; - - /* - ** The remainder of this file contains the declarations of the functions - ** that make up the Pager sub-system API. See source code comments for - ** a detailed description of each routine. - */ - /* Open and close a Pager connection. */ - //int sqlite3PagerOpen( - // sqlite3_vfs*, - // Pager **ppPager, - // const char*, - // int, - // int, - // int, - //// void()(DbPage) - //); - //int sqlite3PagerClose(Pager *pPager); - //int sqlite3PagerReadFileheader(Pager*, int, unsigned char); - - /* Functions used to configure a Pager object. */ - //void sqlite3PagerSetBusyhandler(Pager*, int()(void ), object ); - //int sqlite3PagerSetPagesize(Pager*, u32*, int); - //int sqlite3PagerMaxPageCount(Pager*, int); - //void sqlite3PagerSetCachesize(Pager*, int); - //void sqlite3PagerSetSafetyLevel(Pager*,int,int,int); - //int sqlite3PagerLockingMode(Pager *, int); - //int sqlite3PagerSetJournalMode(Pager *, int); - //int sqlite3PagerGetJournalMode(Pager); - //int sqlite3PagerOkToChangeJournalMode(Pager); - //i64 sqlite3PagerJournalSizeLimit(Pager *, i64); - //sqlite3_backup **sqlite3PagerBackupPtr(Pager); - - /* Functions used to obtain and release page references. */ - //int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag); - //#define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0) - //DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno); - //void sqlite3PagerRef(DbPage); - //void sqlite3PagerUnref(DbPage); - - /* Operations on page references. */ - //int sqlite3PagerWrite(DbPage); - //void sqlite3PagerDontWrite(DbPage); - //int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int); - //int sqlite3PagerPageRefcount(DbPage); - //void *sqlite3PagerGetData(DbPage ); - //void *sqlite3PagerGetExtra(DbPage ); - - /* Functions used to manage pager transactions and savepoints. */ - //void sqlite3PagerPagecount(Pager*, int); - //int sqlite3PagerBegin(Pager*, int exFlag, int); - //int sqlite3PagerCommitPhaseOne(Pager*,string zMaster, int); - //int sqlite3PagerExclusiveLock(Pager); - //int sqlite3PagerSync(Pager *pPager); - //int sqlite3PagerCommitPhaseTwo(Pager); - //int sqlite3PagerRollback(Pager); - //int sqlite3PagerOpenSavepoint(Pager *pPager, int n); - //int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint); - //int sqlite3PagerSharedLock(Pager *pPager); - - //int sqlite3PagerCheckpoint(Pager *pPager, int, int*, int); - //int sqlite3PagerWalSupported(Pager* pPager); - //int sqlite3PagerWalCallback(Pager* pPager); - //int sqlite3PagerOpenWal(Pager* pPager, int* pisOpen); - //int sqlite3PagerCloseWal(Pager* pPager); - - /* Functions used to query pager state and configuration. */ - //u8 sqlite3PagerIsreadonly(Pager); - //int sqlite3PagerRefcount(Pager); - //int sqlite3PagerMemUsed(Pager); - //string sqlite3PagerFilename(Pager); - //const sqlite3_vfs *sqlite3PagerVfs(Pager); - //sqlite3_file *sqlite3PagerFile(Pager); - //string sqlite3PagerJournalname(Pager); - //int sqlite3PagerNosync(Pager); - //void *sqlite3PagerTempSpace(Pager); - //int sqlite3PagerIsMemdb(Pager); - - /* Functions used to truncate the database file. */ - //void sqlite3PagerTruncateImage(Pager*,Pgno); - - //#if (SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL) - //void *sqlite3PagerCodec(DbPage ); - //#endif - - /* Functions to support testing and debugging. */ - //#if !NDEBUG || SQLITE_TEST - // Pgno sqlite3PagerPagenumber(DbPage); - // int sqlite3PagerIswriteable(DbPage); - //#endif - //#if SQLITE_TEST - // int *sqlite3PagerStats(Pager); - // void sqlite3PagerRefdump(Pager); - // void disable_simulated_io_errors(void); - // void enable_simulated_io_errors(void); - //#else - //# define disable_simulated_io_errors() - //# define enable_simulated_io_errors() - //#endif - } } diff --git a/Src/IronPython.SQLite/c#sqlite/parse_c.cs b/Src/IronPython.SQLite/c#sqlite/parse_c.cs index 6875b2568..7addf10fa 100644 --- a/Src/IronPython.SQLite/c#sqlite/parse_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/parse_c.cs @@ -1,349 +1,329 @@ -using System; using System.Diagnostics; using System.IO; -using System.Text; using u8 = System.Byte; - - -using YYCODETYPE = System.Int32; using YYACTIONTYPE = System.Int32; +using YYCODETYPE = System.Int32; -namespace Community.CsharpSqlite -{ - using sqlite3ParserTOKENTYPE = Sqlite3.Token; +namespace Community.CsharpSqlite { + using sqlite3ParserTOKENTYPE = Sqlite3.Token; - public partial class Sqlite3 - { - /* - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ + public partial class Sqlite3 { + /* + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ - /* Driver template for the LEMON parser generator. - ** The author disclaims copyright to this source code. - ** - ** This version of "lempar.c" is modified, slightly, for use by SQLite. - ** The only modifications are the addition of a couple of NEVER() - ** macros to disable tests that are needed in the case of a general - ** LALR(1) grammar but which are always false in the - ** specific grammar used by SQLite. - */ - /* First off, code is included that follows the "include" declaration - ** in the input grammar file. */ - //#include - //#line 51 "parse.y" + /* Driver template for the LEMON parser generator. + ** The author disclaims copyright to this source code. + ** + ** This version of "lempar.c" is modified, slightly, for use by SQLite. + ** The only modifications are the addition of a couple of NEVER() + ** macros to disable tests that are needed in the case of a general + ** LALR(1) grammar but which are always false in the + ** specific grammar used by SQLite. + */ + /* First off, code is included that follows the "include" declaration + ** in the input grammar file. */ + //#include + //#line 51 "parse.y" - //#include "sqliteInt.h" - /* - ** Disable all error recovery processing in the parser push-down - ** automaton. - */ - //#define YYNOERRORRECOVERY 1 - const int YYNOERRORRECOVERY = 1; + //#include "sqliteInt.h" + /* + ** Disable all error recovery processing in the parser push-down + ** automaton. + */ + //#define YYNOERRORRECOVERY 1 + const int YYNOERRORRECOVERY = 1; - /* - ** Make yytestcase() the same as testcase() - */ - //#define yytestcase(X) testcase(X) - static void yytestcase( T X ) - { - testcase( X ); - } + /* + ** Make yytestcase() the same as testcase() + */ + //#define yytestcase(X) testcase(X) + static void yytestcase(T X) { + testcase(X); + } - /* - ** An instance of this structure holds information about the - ** LIMIT clause of a SELECT statement. - */ - public struct LimitVal - { - public Expr pLimit; /* The LIMIT expression. NULL if there is no limit */ - public Expr pOffset; /* The OFFSET expression. NULL if there is none */ - }; + /* + ** An instance of this structure holds information about the + ** LIMIT clause of a SELECT statement. + */ + public struct LimitVal { + public Expr pLimit; /* The LIMIT expression. NULL if there is no limit */ + public Expr pOffset; /* The OFFSET expression. NULL if there is none */ + }; - /* - ** An instance of this structure is used to store the LIKE, - ** GLOB, NOT LIKE, and NOT GLOB operators. - */ - public struct LikeOp - { - public Token eOperator; /* "like" or "glob" or "regexp" */ - public bool not; /* True if the NOT keyword is present */ - }; + /* + ** An instance of this structure is used to store the LIKE, + ** GLOB, NOT LIKE, and NOT GLOB operators. + */ + public struct LikeOp { + public Token eOperator; /* "like" or "glob" or "regexp" */ + public bool not; /* True if the NOT keyword is present */ + }; - /* - ** An instance of the following structure describes the event of a - ** TRIGGER. "a" is the event type, one of TK_UPDATE, TK_INSERT, - ** TK_DELETE, or TK_INSTEAD. If the event is of the form - ** - ** UPDATE ON (a,b,c) - ** - ** Then the "b" IdList records the list "a,b,c". - */ - public struct TrigEvent - { - public int a; - public IdList b; - }; - /* - ** An instance of this structure holds the ATTACH key and the key type. - */ - public struct AttachKey - { - public int type; - public Token key; - }; + /* + ** An instance of the following structure describes the event of a + ** TRIGGER. "a" is the event type, one of TK_UPDATE, TK_INSERT, + ** TK_DELETE, or TK_INSTEAD. If the event is of the form + ** + ** UPDATE ON (a,b,c) + ** + ** Then the "b" IdList records the list "a,b,c". + */ + public struct TrigEvent { + public int a; + public IdList b; + }; + /* + ** An instance of this structure holds the ATTACH key and the key type. + */ + public struct AttachKey { + public int type; + public Token key; + }; - //#line 722 "parse.y" + //#line 722 "parse.y" - /* This is a utility routine used to set the ExprSpan.zStart and - ** ExprSpan.zEnd values of pOut so that the span covers the complete - ** range of text beginning with pStart and going to the end of pEnd. - */ - static void spanSet( ExprSpan pOut, Token pStart, Token pEnd ) - { - pOut.zStart = pStart.z; - pOut.zEnd = pEnd.z.Substring( pEnd.n ); - } + /* This is a utility routine used to set the ExprSpan.zStart and + ** ExprSpan.zEnd values of pOut so that the span covers the complete + ** range of text beginning with pStart and going to the end of pEnd. + */ + static void spanSet(ExprSpan pOut, Token pStart, Token pEnd) { + pOut.zStart = pStart.z; + pOut.zEnd = pEnd.z.Substring(pEnd.n); + } - /* Construct a new Expr object from a single identifier. Use the - ** new Expr to populate pOut. Set the span of pOut to be the identifier - ** that created the expression. - */ - static void spanExpr( ExprSpan pOut, Parse pParse, int op, Token pValue ) - { - pOut.pExpr = sqlite3PExpr( pParse, op, 0, 0, pValue ); - pOut.zStart = pValue.z; - pOut.zEnd = pValue.z.Substring( pValue.n ); - } - //#line 817 "parse.y" + /* Construct a new Expr object from a single identifier. Use the + ** new Expr to populate pOut. Set the span of pOut to be the identifier + ** that created the expression. + */ + static void spanExpr(ExprSpan pOut, Parse pParse, int op, Token pValue) { + pOut.pExpr = sqlite3PExpr(pParse, op, 0, 0, pValue); + pOut.zStart = pValue.z; + pOut.zEnd = pValue.z.Substring(pValue.n); + } + //#line 817 "parse.y" - /* This routine constructs a binary expression node out of two ExprSpan - ** objects and uses the result to populate a new ExprSpan object. - */ - static void spanBinaryExpr( - ExprSpan pOut, /* Write the result here */ - Parse pParse, /* The parsing context. Errors accumulate here */ - int op, /* The binary operation */ - ExprSpan pLeft, /* The left operand */ - ExprSpan pRight /* The right operand */ - ) - { - pOut.pExpr = sqlite3PExpr( pParse, op, pLeft.pExpr, pRight.pExpr, 0 ); - pOut.zStart = pLeft.zStart; - pOut.zEnd = pRight.zEnd; - } - //#line 873 "parse.y" + /* This routine constructs a binary expression node out of two ExprSpan + ** objects and uses the result to populate a new ExprSpan object. + */ + static void spanBinaryExpr( + ExprSpan pOut, /* Write the result here */ + Parse pParse, /* The parsing context. Errors accumulate here */ + int op, /* The binary operation */ + ExprSpan pLeft, /* The left operand */ + ExprSpan pRight /* The right operand */ + ) { + pOut.pExpr = sqlite3PExpr(pParse, op, pLeft.pExpr, pRight.pExpr, 0); + pOut.zStart = pLeft.zStart; + pOut.zEnd = pRight.zEnd; + } + //#line 873 "parse.y" - /* Construct an expression node for a unary postfix operator - */ - static void spanUnaryPostfix( - ExprSpan pOut, /* Write the new expression node here */ - Parse pParse, /* Parsing context to record errors */ - int op, /* The operator */ - ExprSpan pOperand, /* The operand */ - Token pPostOp /* The operand token for setting the span */ - ) - { - pOut.pExpr = sqlite3PExpr( pParse, op, pOperand.pExpr, 0, 0 ); - pOut.zStart = pOperand.zStart; - pOut.zEnd = pPostOp.z.Substring( pPostOp.n ); - } - //#line 892 "parse.y" + /* Construct an expression node for a unary postfix operator + */ + static void spanUnaryPostfix( + ExprSpan pOut, /* Write the new expression node here */ + Parse pParse, /* Parsing context to record errors */ + int op, /* The operator */ + ExprSpan pOperand, /* The operand */ + Token pPostOp /* The operand token for setting the span */ + ) { + pOut.pExpr = sqlite3PExpr(pParse, op, pOperand.pExpr, 0, 0); + pOut.zStart = pOperand.zStart; + pOut.zEnd = pPostOp.z.Substring(pPostOp.n); + } + //#line 892 "parse.y" - /* A routine to convert a binary TK_IS or TK_ISNOT expression into a - ** unary TK_ISNULL or TK_NOTNULL expression. */ - static void binaryToUnaryIfNull( Parse pParse, Expr pY, Expr pA, int op ) - { - sqlite3 db = pParse.db; - if ( /*db.mallocFailed == null && */pY.op == TK_NULL ) - { - pA.op = (u8)op; - sqlite3ExprDelete( db, ref pA.pRight ); - pA.pRight = null; - } - } - //#line 920 "parse.y" + /* A routine to convert a binary TK_IS or TK_ISNOT expression into a + ** unary TK_ISNULL or TK_NOTNULL expression. */ + static void binaryToUnaryIfNull(Parse pParse, Expr pY, Expr pA, int op) { + sqlite3 db = pParse.db; + if ( /*db.mallocFailed == null && */pY.op == TK_NULL) { + pA.op = (u8)op; + sqlite3ExprDelete(db, ref pA.pRight); + pA.pRight = null; + } + } + //#line 920 "parse.y" - /* Construct an expression node for a unary prefix operator - */ - static void spanUnaryPrefix( - ExprSpan pOut, /* Write the new expression node here */ - Parse pParse, /* Parsing context to record errors */ - int op, /* The operator */ - ExprSpan pOperand, /* The operand */ - Token pPreOp /* The operand token for setting the span */ - ) - { - pOut.pExpr = sqlite3PExpr( pParse, op, pOperand.pExpr, 0, 0 ); - pOut.zStart = pPreOp.z; - pOut.zEnd = pOperand.zEnd; - } - //#line 141 "parse.c" - /* Next is all token values, in a form suitable for use by makeheaders. - ** This section will be null unless lemon is run with the -m switch. - */ - /* - ** These constants (all generated automatically by the parser generator) - ** specify the various kinds of tokens (terminals) that the parser - ** understands. - ** - ** Each symbol here is a terminal symbol in the grammar. - */ - /* Make sure the INTERFACE macro is defined. - */ + /* Construct an expression node for a unary prefix operator + */ + static void spanUnaryPrefix( + ExprSpan pOut, /* Write the new expression node here */ + Parse pParse, /* Parsing context to record errors */ + int op, /* The operator */ + ExprSpan pOperand, /* The operand */ + Token pPreOp /* The operand token for setting the span */ + ) { + pOut.pExpr = sqlite3PExpr(pParse, op, pOperand.pExpr, 0, 0); + pOut.zStart = pPreOp.z; + pOut.zEnd = pOperand.zEnd; + } + //#line 141 "parse.c" + /* Next is all token values, in a form suitable for use by makeheaders. + ** This section will be null unless lemon is run with the -m switch. + */ + /* + ** These constants (all generated automatically by the parser generator) + ** specify the various kinds of tokens (terminals) that the parser + ** understands. + ** + ** Each symbol here is a terminal symbol in the grammar. + */ + /* Make sure the INTERFACE macro is defined. + */ #if !INTERFACE - //# define INTERFACE 1 + //# define INTERFACE 1 #endif - /* The next thing included is series of defines which control -** various aspects of the generated parser. -** YYCODETYPE is the data type used for storing terminal -** and nonterminal numbers. "unsigned char" is -** used if there are fewer than 250 terminals -** and nonterminals. "int" is used otherwise. -** YYNOCODE is a number of type YYCODETYPE which corresponds -** to no legal terminal or nonterminal number. This -** number is used to fill in empty slots of the hash -** table. -** YYFALLBACK If defined, this indicates that one or more tokens -** have fall-back values which should be used if the -** original value of the token will not parse. -** YYACTIONTYPE is the data type used for storing terminal -** and nonterminal numbers. "unsigned char" is -** used if there are fewer than 250 rules and -** states combined. "int" is used otherwise. -** sqlite3ParserTOKENTYPE is the data type used for minor tokens given -** directly to the parser from the tokenizer. -** YYMINORTYPE is the data type used for all minor tokens. -** This is typically a union of many types, one of -** which is sqlite3ParserTOKENTYPE. The entry in the union -** for base tokens is called "yy0". -** YYSTACKDEPTH is the maximum depth of the parser's stack. If -** zero the stack is dynamically sized using realloc() -** sqlite3ParserARG_SDECL A static variable declaration for the %extra_argument -** sqlite3ParserARG_PDECL A parameter declaration for the %extra_argument -** sqlite3ParserARG_STORE Code to store %extra_argument into yypParser -** sqlite3ParserARG_FETCH Code to extract %extra_argument from yypParser -** YYNSTATE the combined number of states. -** YYNRULE the number of rules in the grammar -** YYERRORSYMBOL is the code number of the error symbol. If not -** defined, then do no error processing. -*/ - //#define YYCODETYPE unsigned short char - const int YYNOCODE = 253; - //#define YYACTIONTYPE unsigned short int - const int YYWILDCARD = 67; - //#define sqlite3ParserTOKENTYPE Token - public class YYMINORTYPE - { - public int yyinit; - public sqlite3ParserTOKENTYPE yy0 = new sqlite3ParserTOKENTYPE(); - public int yy4; - public TrigEvent yy90; - public ExprSpan yy118 = new ExprSpan(); - public TriggerStep yy203; - public u8 yy210; - public struct _yy215 - { - public int value; - public int mask; - } - public _yy215 yy215; - public SrcList yy259; - public LimitVal yy292; - public Expr yy314; - public ExprList yy322; - public LikeOp yy342; - public IdList yy384; - public Select yy387; - } + /* The next thing included is series of defines which control + ** various aspects of the generated parser. + ** YYCODETYPE is the data type used for storing terminal + ** and nonterminal numbers. "unsigned char" is + ** used if there are fewer than 250 terminals + ** and nonterminals. "int" is used otherwise. + ** YYNOCODE is a number of type YYCODETYPE which corresponds + ** to no legal terminal or nonterminal number. This + ** number is used to fill in empty slots of the hash + ** table. + ** YYFALLBACK If defined, this indicates that one or more tokens + ** have fall-back values which should be used if the + ** original value of the token will not parse. + ** YYACTIONTYPE is the data type used for storing terminal + ** and nonterminal numbers. "unsigned char" is + ** used if there are fewer than 250 rules and + ** states combined. "int" is used otherwise. + ** sqlite3ParserTOKENTYPE is the data type used for minor tokens given + ** directly to the parser from the tokenizer. + ** YYMINORTYPE is the data type used for all minor tokens. + ** This is typically a union of many types, one of + ** which is sqlite3ParserTOKENTYPE. The entry in the union + ** for base tokens is called "yy0". + ** YYSTACKDEPTH is the maximum depth of the parser's stack. If + ** zero the stack is dynamically sized using realloc() + ** sqlite3ParserARG_SDECL A static variable declaration for the %extra_argument + ** sqlite3ParserARG_PDECL A parameter declaration for the %extra_argument + ** sqlite3ParserARG_STORE Code to store %extra_argument into yypParser + ** sqlite3ParserARG_FETCH Code to extract %extra_argument from yypParser + ** YYNSTATE the combined number of states. + ** YYNRULE the number of rules in the grammar + ** YYERRORSYMBOL is the code number of the error symbol. If not + ** defined, then do no error processing. + */ + //#define YYCODETYPE unsigned short char + const int YYNOCODE = 253; + //#define YYACTIONTYPE unsigned short int + const int YYWILDCARD = 67; + //#define sqlite3ParserTOKENTYPE Token + public class YYMINORTYPE { + public int yyinit; + public sqlite3ParserTOKENTYPE yy0 = new sqlite3ParserTOKENTYPE(); + public int yy4; + public TrigEvent yy90; + public ExprSpan yy118 = new ExprSpan(); + public TriggerStep yy203; + public u8 yy210; + public struct _yy215 { + public int value; + public int mask; + } + public _yy215 yy215; + public SrcList yy259; + public LimitVal yy292; + public Expr yy314; + public ExprList yy322; + public LikeOp yy342; + public IdList yy384; + public Select yy387; + } #if !YYSTACKDEPTH - const int YYSTACKDEPTH = 100; + const int YYSTACKDEPTH = 100; #endif - //#define sqlite3ParserARG_SDECL Parse pParse; - //#define sqlite3ParserARG_PDECL ,Parse pParse - //#define sqlite3ParserARG_FETCH Parse pParse = yypParser.pParse - //#define sqlite3ParserARG_STORE yypParser.pParse = pParse - const int YYNSTATE = 630; - const int YYNRULE = 329; - //#define YYFALLBACK 1 - const int YYFALLBACK = 1; - const int YY_NO_ACTION = ( YYNSTATE + YYNRULE + 2 ); - const int YY_ACCEPT_ACTION = ( YYNSTATE + YYNRULE + 1 ); - const int YY_ERROR_ACTION = ( YYNSTATE + YYNRULE ); + //#define sqlite3ParserARG_SDECL Parse pParse; + //#define sqlite3ParserARG_PDECL ,Parse pParse + //#define sqlite3ParserARG_FETCH Parse pParse = yypParser.pParse + //#define sqlite3ParserARG_STORE yypParser.pParse = pParse + const int YYNSTATE = 630; + const int YYNRULE = 329; + //#define YYFALLBACK 1 + const int YYFALLBACK = 1; + const int YY_NO_ACTION = (YYNSTATE + YYNRULE + 2); + const int YY_ACCEPT_ACTION = (YYNSTATE + YYNRULE + 1); + const int YY_ERROR_ACTION = (YYNSTATE + YYNRULE); - /* The yyzerominor constant is used to initialize instances of - ** YYMINORTYPE objects to zero. */ - YYMINORTYPE yyzerominor = new YYMINORTYPE();//static const YYMINORTYPE yyzerominor = { 0 }; + /* The yyzerominor constant is used to initialize instances of + ** YYMINORTYPE objects to zero. */ + YYMINORTYPE yyzerominor = new YYMINORTYPE();//static const YYMINORTYPE yyzerominor = { 0 }; - /* Define the yytestcase() macro to be a no-op if is not already defined - ** otherwise. - ** - ** Applications can choose to define yytestcase() in the %include section - ** to a macro that can assist in verifying code coverage. For production - ** code the yytestcase() macro should be turned off. But it is useful - ** for testing. - */ - //#if !yytestcase - //# define yytestcase(X) - //#endif + /* Define the yytestcase() macro to be a no-op if is not already defined + ** otherwise. + ** + ** Applications can choose to define yytestcase() in the %include section + ** to a macro that can assist in verifying code coverage. For production + ** code the yytestcase() macro should be turned off. But it is useful + ** for testing. + */ + //#if !yytestcase + //# define yytestcase(X) + //#endif - /* Next are the tables used to determine what action to take based on the - ** current state and lookahead token. These tables are used to implement - ** functions that take a state number and lookahead value and return an - ** action integer. - ** - ** Suppose the action integer is N. Then the action is determined as - ** follows - ** - ** 0 <= N < YYNSTATE Shift N. That is, push the lookahead - ** token onto the stack and goto state N. - ** - ** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE. - ** - ** N == YYNSTATE+YYNRULE A syntax error has occurred. - ** - ** N == YYNSTATE+YYNRULE+1 The parser accepts its input. - ** - ** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused - ** slots in the yy_action[] table. - ** - ** The action table is constructed as a single large table named yy_action[]. - ** Given state S and lookahead X, the action is computed as - ** - ** yy_action[ yy_shift_ofst[S] + X ] - ** - ** If the index value yy_shift_ofst[S]+X is out of range or if the value - ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] - ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table - ** and that yy_default[S] should be used instead. - ** - ** The formula above is for computing the action when the lookahead is - ** a terminal symbol. If the lookahead is a non-terminal (as occurs after - ** a reduce action) then the yy_reduce_ofst[] array is used in place of - ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of - ** YY_SHIFT_USE_DFLT. - ** - ** The following are the tables generated in this section: - ** - ** yy_action[] A single table containing all actions. - ** yy_lookahead[] A table containing the lookahead for each entry in - ** yy_action. Used to detect hash collisions. - ** yy_shift_ofst[] For each state, the offset into yy_action for - ** shifting terminals. - ** yy_reduce_ofst[] For each state, the offset into yy_action for - ** shifting non-terminals after a reduce. - ** yy_default[] Default action for each state. - */ - //#define YY_ACTTAB_COUNT (1557) - const int YY_ACTTAB_COUNT = 1557; - static YYACTIONTYPE[] yy_action = new YYACTIONTYPE[]{ + /* Next are the tables used to determine what action to take based on the + ** current state and lookahead token. These tables are used to implement + ** functions that take a state number and lookahead value and return an + ** action integer. + ** + ** Suppose the action integer is N. Then the action is determined as + ** follows + ** + ** 0 <= N < YYNSTATE Shift N. That is, push the lookahead + ** token onto the stack and goto state N. + ** + ** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE. + ** + ** N == YYNSTATE+YYNRULE A syntax error has occurred. + ** + ** N == YYNSTATE+YYNRULE+1 The parser accepts its input. + ** + ** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused + ** slots in the yy_action[] table. + ** + ** The action table is constructed as a single large table named yy_action[]. + ** Given state S and lookahead X, the action is computed as + ** + ** yy_action[ yy_shift_ofst[S] + X ] + ** + ** If the index value yy_shift_ofst[S]+X is out of range or if the value + ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] + ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table + ** and that yy_default[S] should be used instead. + ** + ** The formula above is for computing the action when the lookahead is + ** a terminal symbol. If the lookahead is a non-terminal (as occurs after + ** a reduce action) then the yy_reduce_ofst[] array is used in place of + ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of + ** YY_SHIFT_USE_DFLT. + ** + ** The following are the tables generated in this section: + ** + ** yy_action[] A single table containing all actions. + ** yy_lookahead[] A table containing the lookahead for each entry in + ** yy_action. Used to detect hash collisions. + ** yy_shift_ofst[] For each state, the offset into yy_action for + ** shifting terminals. + ** yy_reduce_ofst[] For each state, the offset into yy_action for + ** shifting non-terminals after a reduce. + ** yy_default[] Default action for each state. + */ + //#define YY_ACTTAB_COUNT (1557) + const int YY_ACTTAB_COUNT = 1557; + static YYACTIONTYPE[] yy_action = new YYACTIONTYPE[]{ /* 0 */ 313, 960, 186, 419, 2, 172, 627, 597, 55, 55, /* 10 */ 55, 55, 48, 53, 53, 53, 53, 52, 52, 51, /* 20 */ 51, 51, 50, 238, 302, 283, 623, 622, 516, 515, @@ -501,7 +481,7 @@ public struct _yy215 /* 1540 */ 490, 356, 256, 961, 483, 961, 961, 961, 961, 961, /* 1550 */ 961, 961, 961, 961, 961, 961, 370, }; - static YYCODETYPE[] yy_lookahead = new YYCODETYPE[]{ + static YYCODETYPE[] yy_lookahead = new YYCODETYPE[]{ /* 0 */ 19, 142, 143, 144, 145, 24, 1, 26, 77, 78, /* 10 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, /* 20 */ 89, 90, 91, 92, 15, 98, 26, 27, 7, 8, @@ -660,12 +640,12 @@ public struct _yy215 /* 1550 */ 252, 252, 252, 252, 252, 252, 236, }; - const int YY_SHIFT_USE_DFLT = -74;//#define YY_SHIFT_USE_DFLT (-74) - const int YY_SHIFT_COUNT = 418; //#define YY_SHIFT_COUNT (418) - const int YY_SHIFT_MIN = -73; //#define YY_SHIFT_MIN (-73) - const int YY_SHIFT_MAX = 1468; //#define YY_SHIFT_MAX (1468) + const int YY_SHIFT_USE_DFLT = -74;//#define YY_SHIFT_USE_DFLT (-74) + const int YY_SHIFT_COUNT = 418; //#define YY_SHIFT_COUNT (418) + const int YY_SHIFT_MIN = -73; //#define YY_SHIFT_MIN (-73) + const int YY_SHIFT_MAX = 1468; //#define YY_SHIFT_MAX (1468) - static short[] yy_shift_ofst = new short[]{ + static short[] yy_shift_ofst = new short[]{ /* 0 */ 975, 1114, 1343, 1114, 1213, 1213, 90, 90, 0, -19, /* 10 */ 1213, 1213, 1213, 1213, 1213, 345, 445, 721, 1091, 1213, /* 20 */ 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, @@ -710,12 +690,12 @@ public struct _yy215 /* 410 */ 240, 224, 143, 62, 18, 71, 39, 9, 5, }; - const int YY_REDUCE_USE_DFLT = -142; //#define YY_REDUCE_USE_DFLT (-142) - const int YY_REDUCE_COUNT = 312; //#define YY_REDUCE_COUNT (312) - const int YY_REDUCE_MIN = -141; //#define YY_REDUCE_MIN (-141) - const int YY_REDUCE_MAX = 1369; //#define YY_REDUCE_MAX (1369) + const int YY_REDUCE_USE_DFLT = -142; //#define YY_REDUCE_USE_DFLT (-142) + const int YY_REDUCE_COUNT = 312; //#define YY_REDUCE_COUNT (312) + const int YY_REDUCE_MIN = -141; //#define YY_REDUCE_MIN (-141) + const int YY_REDUCE_MAX = 1369; //#define YY_REDUCE_MAX (1369) - static short[] yy_reduce_ofst = new short[]{ + static short[] yy_reduce_ofst = new short[]{ /* 0 */ -141, 994, 1118, 223, 157, -53, 93, 89, 83, 375, /* 10 */ 386, 381, 379, 308, 295, 325, -47, 27, 1240, 1234, /* 20 */ 1228, 1221, 1208, 1187, 1151, 1111, 1109, 1077, 1054, 1022, @@ -749,7 +729,7 @@ public struct _yy215 /* 300 */ 1112, 1115, 1086, 1105, 1092, 1087, 1068, 962, 955, 957, /* 310 */ 1031, 1023, 1030, }; - static YYACTIONTYPE[] yy_default = new YYACTIONTYPE[] { + static YYACTIONTYPE[] yy_default = new YYACTIONTYPE[] { /* 0 */ 635, 870, 959, 959, 959, 870, 899, 899, 959, 759, /* 10 */ 959, 959, 959, 959, 868, 959, 959, 933, 959, 959, /* 20 */ 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, @@ -815,18 +795,18 @@ public struct _yy215 /* 620 */ 672, 671, 669, 668, 642, 639, 638, 634, 633, 631, }; - /* The next table maps tokens into fallback tokens. If a construct - ** like the following: - ** - ** %fallback ID X Y Z. - ** - ** appears in the grammar, then ID becomes a fallback token for X, Y, - ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser - ** but it does not parse, the type of the token is changed to ID and - ** the parse is retried before an error is thrown. - */ + /* The next table maps tokens into fallback tokens. If a construct + ** like the following: + ** + ** %fallback ID X Y Z. + ** + ** appears in the grammar, then ID becomes a fallback token for X, Y, + ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser + ** but it does not parse, the type of the token is changed to ID and + ** the parse is retried before an error is thrown. + */ #if YYFALLBACK || TRUE - static YYCODETYPE[] yyFallback = new YYCODETYPE[]{ + static YYCODETYPE[] yyFallback = new YYCODETYPE[]{ 0, /* $ => nothing */ 0, /* SEMI => nothing */ 26, /* EXPLAIN => ID */ @@ -897,156 +877,153 @@ public struct _yy215 }; #endif // * YYFALLBACK */ - /* The following structure represents a single element of the -** parser's stack. Information stored includes: -** -** + The state number for the parser at this level of the stack. -** -** + The value of the token stored at this level of the stack. -** (In other words, the "major" token.) -** -** + The semantic value stored at this level of the stack. This is -** the information used by the action routines in the grammar. -** It is sometimes called the "minor" token. -*/ - public class yyStackEntry - { - public YYACTIONTYPE stateno; /* The state-number */ - public YYCODETYPE major; /* The major token value. This is the code + /* The following structure represents a single element of the + ** parser's stack. Information stored includes: + ** + ** + The state number for the parser at this level of the stack. + ** + ** + The value of the token stored at this level of the stack. + ** (In other words, the "major" token.) + ** + ** + The semantic value stored at this level of the stack. This is + ** the information used by the action routines in the grammar. + ** It is sometimes called the "minor" token. + */ + public class yyStackEntry { + public YYACTIONTYPE stateno; /* The state-number */ + public YYCODETYPE major; /* The major token value. This is the code ** number for the token at this stack level */ - public YYMINORTYPE minor; /* The user-supplied minor token value. This + public YYMINORTYPE minor; /* The user-supplied minor token value. This ** is the value of the token */ - }; - //typedef struct yyStackEntry yyStackEntry; + }; + //typedef struct yyStackEntry yyStackEntry; - /* The state of the parser is completely contained in an instance of - ** the following structure */ - public class yyParser - { - public int yyidx; /* Index of top element in stack */ + /* The state of the parser is completely contained in an instance of + ** the following structure */ + public class yyParser { + public int yyidx; /* Index of top element in stack */ #if YYTRACKMAXSTACKDEPTH int yyidxMax; /* Maximum value of yyidx */ #endif - public int yyerrcnt; /* Shifts left before out of the error */ - public Parse pParse; // sqlite3ParserARG_SDECL /* A place to hold %extra_argument */ + public int yyerrcnt; /* Shifts left before out of the error */ + public Parse pParse; // sqlite3ParserARG_SDECL /* A place to hold %extra_argument */ #if YYSTACKDEPTH//<=0 public int yystksz; /* Current side of the stack */ public yyStackEntry *yystack; /* The parser's stack */ #else - public yyStackEntry[] yystack = new yyStackEntry[YYSTACKDEPTH]; /* The parser's stack */ + public yyStackEntry[] yystack = new yyStackEntry[YYSTACKDEPTH]; /* The parser's stack */ #endif - }; - //typedef struct yyParser yyParser; + }; + //typedef struct yyParser yyParser; #if !NDEBUG - //#include - static TextWriter yyTraceFILE = null; - static string yyTracePrompt = ""; + //#include + static TextWriter yyTraceFILE = null; + static string yyTracePrompt = ""; #endif // * NDEBUG */ #if !NDEBUG - /* -** Turn parser tracing on by giving a stream to which to write the trace -** and a prompt to preface each trace message. Tracing is turned off -** by making either argument NULL -** -** Inputs: -**
    -**
  • A FILE* to which trace output should be written. -** If NULL, then tracing is turned off. -**
  • A prefix string written at the beginning of every -** line of trace output. If NULL, then tracing is -** turned off. -**
-** -** Outputs: -** None. -*/ - static void sqlite3ParserTrace( TextWriter TraceFILE, string zTracePrompt ) - { - yyTraceFILE = TraceFILE; - yyTracePrompt = zTracePrompt; - if ( yyTraceFILE == null ) - yyTracePrompt = ""; - else if ( yyTracePrompt == "" ) - yyTraceFILE = null; - } + /* + ** Turn parser tracing on by giving a stream to which to write the trace + ** and a prompt to preface each trace message. Tracing is turned off + ** by making either argument NULL + ** + ** Inputs: + **
    + **
  • A FILE* to which trace output should be written. + ** If NULL, then tracing is turned off. + **
  • A prefix string written at the beginning of every + ** line of trace output. If NULL, then tracing is + ** turned off. + **
+ ** + ** Outputs: + ** None. + */ + static void sqlite3ParserTrace(TextWriter TraceFILE, string zTracePrompt) { + yyTraceFILE = TraceFILE; + yyTracePrompt = zTracePrompt; + if (yyTraceFILE == null) + yyTracePrompt = ""; + else if (yyTracePrompt == "") + yyTraceFILE = null; + } #endif // * NDEBUG */ #if !NDEBUG - /* For tracing shifts, the names of all terminals and nonterminals -** are required. The following table supplies these names */ - static string[] yyTokenName = { -"$", "SEMI", "EXPLAIN", "QUERY", -"PLAN", "BEGIN", "TRANSACTION", "DEFERRED", -"IMMEDIATE", "EXCLUSIVE", "COMMIT", "END", -"ROLLBACK", "SAVEPOINT", "RELEASE", "TO", -"TABLE", "CREATE", "IF", "NOT", -"EXISTS", "TEMP", "LP", "RP", -"AS", "COMMA", "ID", "INDEXED", -"ABORT", "ACTION", "AFTER", "ANALYZE", -"ASC", "ATTACH", "BEFORE", "BY", -"CASCADE", "CAST", "COLUMNKW", "CONFLICT", -"DATABASE", "DESC", "DETACH", "EACH", -"FAIL", "FOR", "IGNORE", "INITIALLY", -"INSTEAD", "LIKE_KW", "MATCH", "NO", -"KEY", "OF", "OFFSET", "PRAGMA", -"RAISE", "REPLACE", "RESTRICT", "ROW", -"TRIGGER", "VACUUM", "VIEW", "VIRTUAL", -"REINDEX", "RENAME", "CTIME_KW", "ANY", -"OR", "AND", "IS", "BETWEEN", -"IN", "ISNULL", "NOTNULL", "NE", -"EQ", "GT", "LE", "LT", -"GE", "ESCAPE", "BITAND", "BITOR", -"LSHIFT", "RSHIFT", "PLUS", "MINUS", -"STAR", "SLASH", "REM", "CONCAT", -"COLLATE", "BITNOT", "STRING", "JOIN_KW", -"CONSTRAINT", "DEFAULT", "NULL", "PRIMARY", -"UNIQUE", "CHECK", "REFERENCES", "AUTOINCR", -"ON", "INSERT", "DELETE", "UPDATE", -"SET", "DEFERRABLE", "FOREIGN", "DROP", -"UNION", "ALL", "EXCEPT", "INTERSECT", -"SELECT", "DISTINCT", "DOT", "FROM", -"JOIN", "USING", "ORDER", "GROUP", -"HAVING", "LIMIT", "WHERE", "INTO", -"VALUES", "INTEGER", "FLOAT", "BLOB", -"REGISTER", "VARIABLE", "CASE", "WHEN", -"THEN", "ELSE", "INDEX", "ALTER", -"ADD", "error", "input", "cmdlist", -"ecmd", "explain", "cmdx", "cmd", + /* For tracing shifts, the names of all terminals and nonterminals + ** are required. The following table supplies these names */ + static string[] yyTokenName = { +"$", "SEMI", "EXPLAIN", "QUERY", +"PLAN", "BEGIN", "TRANSACTION", "DEFERRED", +"IMMEDIATE", "EXCLUSIVE", "COMMIT", "END", +"ROLLBACK", "SAVEPOINT", "RELEASE", "TO", +"TABLE", "CREATE", "IF", "NOT", +"EXISTS", "TEMP", "LP", "RP", +"AS", "COMMA", "ID", "INDEXED", +"ABORT", "ACTION", "AFTER", "ANALYZE", +"ASC", "ATTACH", "BEFORE", "BY", +"CASCADE", "CAST", "COLUMNKW", "CONFLICT", +"DATABASE", "DESC", "DETACH", "EACH", +"FAIL", "FOR", "IGNORE", "INITIALLY", +"INSTEAD", "LIKE_KW", "MATCH", "NO", +"KEY", "OF", "OFFSET", "PRAGMA", +"RAISE", "REPLACE", "RESTRICT", "ROW", +"TRIGGER", "VACUUM", "VIEW", "VIRTUAL", +"REINDEX", "RENAME", "CTIME_KW", "ANY", +"OR", "AND", "IS", "BETWEEN", +"IN", "ISNULL", "NOTNULL", "NE", +"EQ", "GT", "LE", "LT", +"GE", "ESCAPE", "BITAND", "BITOR", +"LSHIFT", "RSHIFT", "PLUS", "MINUS", +"STAR", "SLASH", "REM", "CONCAT", +"COLLATE", "BITNOT", "STRING", "JOIN_KW", +"CONSTRAINT", "DEFAULT", "NULL", "PRIMARY", +"UNIQUE", "CHECK", "REFERENCES", "AUTOINCR", +"ON", "INSERT", "DELETE", "UPDATE", +"SET", "DEFERRABLE", "FOREIGN", "DROP", +"UNION", "ALL", "EXCEPT", "INTERSECT", +"SELECT", "DISTINCT", "DOT", "FROM", +"JOIN", "USING", "ORDER", "GROUP", +"HAVING", "LIMIT", "WHERE", "INTO", +"VALUES", "INTEGER", "FLOAT", "BLOB", +"REGISTER", "VARIABLE", "CASE", "WHEN", +"THEN", "ELSE", "INDEX", "ALTER", +"ADD", "error", "input", "cmdlist", +"ecmd", "explain", "cmdx", "cmd", "transtype", "trans_opt", "nm", "savepoint_opt", -"create_table", "create_table_args", "createkw", "temp", +"create_table", "create_table_args", "createkw", "temp", "ifnotexists", "dbnm", "columnlist", "conslist_opt", -"select", "column", "columnid", "type", -"carglist", "id", "ids", "typetoken", -"typename", "signed", "plus_num", "minus_num", -"carg", "ccons", "term", "expr", -"onconf", "sortorder", "autoinc", "idxlist_opt", -"refargs", "defer_subclause", "refarg", "refact", -"init_deferred_pred_opt", "conslist", "tcons", "idxlist", -"defer_subclause_opt", "orconf", "resolvetype", "raisetype", +"select", "column", "columnid", "type", +"carglist", "id", "ids", "typetoken", +"typename", "signed", "plus_num", "minus_num", +"carg", "ccons", "term", "expr", +"onconf", "sortorder", "autoinc", "idxlist_opt", +"refargs", "defer_subclause", "refarg", "refact", +"init_deferred_pred_opt", "conslist", "tcons", "idxlist", +"defer_subclause_opt", "orconf", "resolvetype", "raisetype", "ifexists", "fullname", "oneselect", "multiselect_op", -"distinct", "selcollist", "from", "where_opt", -"groupby_opt", "having_opt", "orderby_opt", "limit_opt", -"sclp", "as", "seltablist", "stl_prefix", -"joinop", "indexed_opt", "on_opt", "using_opt", -"joinop2", "inscollist", "sortlist", "sortitem", +"distinct", "selcollist", "from", "where_opt", +"groupby_opt", "having_opt", "orderby_opt", "limit_opt", +"sclp", "as", "seltablist", "stl_prefix", +"joinop", "indexed_opt", "on_opt", "using_opt", +"joinop2", "inscollist", "sortlist", "sortitem", "nexprlist", "setlist", "insert_cmd", "inscollist_opt", -"itemlist", "exprlist", "likeop", "between_op", -"in_op", "case_operand", "case_exprlist", "case_else", -"uniqueflag", "collate", "nmnum", "plus_opt", +"itemlist", "exprlist", "likeop", "between_op", +"in_op", "case_operand", "case_exprlist", "case_else", +"uniqueflag", "collate", "nmnum", "plus_opt", "number", "trigger_decl", "trigger_cmd_list", "trigger_time", -"trigger_event", "foreach_clause", "when_clause", "trigger_cmd", -"trnm", "tridxby", "database_kw_opt", "key_opt", -"add_column_fullname", "kwcolumn_opt", "create_vtab", "vtabarglist", -"vtabarg", "vtabargtoken", "lp", "anylist", +"trigger_event", "foreach_clause", "when_clause", "trigger_cmd", +"trnm", "tridxby", "database_kw_opt", "key_opt", +"add_column_fullname", "kwcolumn_opt", "create_vtab", "vtabarglist", +"vtabarg", "vtabargtoken", "lp", "anylist", }; #endif // * NDEBUG */ #if !NDEBUG - /* For tracing reduce actions, the names of all rules are required. -*/ - static string[] yyRuleName = { + /* For tracing reduce actions, the names of all rules are required. + */ + static string[] yyRuleName = { /* 0 */ "input ::= cmdlist", /* 1 */ "cmdlist ::= cmdlist ecmd", /* 2 */ "cmdlist ::= ecmd", @@ -1403,25 +1380,23 @@ static void yyGrowStack(yyParser p){ } #endif - /* -** This function allocates a new parser. -** The only argument is a pointer to a function which works like -** malloc. -** -** Inputs: -** A pointer to the function used to allocate memory. -** -** Outputs: -** A pointer to a parser. This pointer is used in subsequent calls -** to sqlite3Parser and sqlite3ParserFree. -*/ - static yyParser sqlite3ParserAlloc() - {//void *(*mallocProc)(size_t)){ - yyParser pParser = new yyParser(); - //pParser = (yyParser*)(*mallocProc)( (size_t)yyParser.Length ); - if ( pParser != null ) - { - pParser.yyidx = -1; + /* + ** This function allocates a new parser. + ** The only argument is a pointer to a function which works like + ** malloc. + ** + ** Inputs: + ** A pointer to the function used to allocate memory. + ** + ** Outputs: + ** A pointer to a parser. This pointer is used in subsequent calls + ** to sqlite3Parser and sqlite3ParserFree. + */ + static yyParser sqlite3ParserAlloc() {//void *(*mallocProc)(size_t)){ + yyParser pParser = new yyParser(); + //pParser = (yyParser*)(*mallocProc)( (size_t)yyParser.Length ); + if (pParser != null) { + pParser.yyidx = -1; #if YYTRACKMAXSTACKDEPTH pParser.yyidxMax=0; #endif @@ -1431,185 +1406,180 @@ static yyParser sqlite3ParserAlloc() pParser.yystksz = null; yyGrowStack(pParser); #endif - } - return pParser; - } + } + return pParser; + } - /* The following function deletes the value associated with a - ** symbol. The symbol can be either a terminal or nonterminal. - ** "yymajor" is the symbol code, and "yypminor" is a pointer to - ** the value. - */ - static void yy_destructor( - yyParser yypParser, /* The parser */ - YYCODETYPE yymajor, /* Type code for object to destroy */ - YYMINORTYPE yypminor /* The object to be destroyed */ - ) - { - Parse pParse = yypParser.pParse; // sqlite3ParserARG_FETCH; - switch ( yymajor ) - { - /* Here is inserted the actions which take place when a - ** terminal or non-terminal is destroyed. This can happen - ** when the symbol is popped from the stack during a - ** reduce or during error processing or when a parser is - ** being destroyed before it is finished parsing. - ** - ** Note: during a reduce, the only symbols destroyed are those - ** which appear on the RHS of the rule, but which are not used - ** inside the C code. + /* The following function deletes the value associated with a + ** symbol. The symbol can be either a terminal or nonterminal. + ** "yymajor" is the symbol code, and "yypminor" is a pointer to + ** the value. */ - case 160: /* select */ - case 194: /* oneselect */ - { - //#line 403 "parse.y" - sqlite3SelectDelete( pParse.db, ref ( yypminor.yy387 ) ); - //#line 1399 "parse.c" - } - break; - case 174: /* term */ - case 175: /* Expr */ - { - //#line 720 "parse.y" - sqlite3ExprDelete( pParse.db, ref ( yypminor.yy118 ).pExpr ); - //#line 1407 "parse.c" - } - break; - case 179: /* idxlist_opt */ - case 187: /* idxlist */ - case 197: /* selcollist */ - case 200: /* groupby_opt */ - case 202: /* orderby_opt */ - case 204: /* sclp */ - case 214: /* sortlist */ - case 216: /* nexprlist */ - case 217: /* setlist */ - case 220: /* itemlist */ - case 221: /* exprlist */ - case 226: /* case_exprlist */ - { - //#line 1103 "parse.y" - sqlite3ExprListDelete( pParse.db, ref ( yypminor.yy322 ) ); - //#line 1425 "parse.c" - } - break; - case 193: /* fullname */ - case 198: /* from */ - case 206: /* seltablist */ - case 207: /* stl_prefix */ - { - //#line 534 "parse.y" - sqlite3SrcListDelete( pParse.db, ref ( yypminor.yy259 ) ); - //#line 1435 "parse.c" - } - break; - case 199: /* where_opt */ - case 201: /* having_opt */ - case 210: /* on_opt */ - case 215: /* sortitem */ - case 225: /* case_operand */ - case 227: /* case_else */ - case 238: /* when_clause */ - case 243: /* key_opt */ - { - //#line 644 "parse.y" - sqlite3ExprDelete( pParse.db, ref ( yypminor.yy314 ) ); - //#line 1449 "parse.c" - } - break; - case 211: /* using_opt */ - case 213: /* inscollist */ - case 219: /* inscollist_opt */ - { - //#line 566 "parse.y" - sqlite3IdListDelete( pParse.db, ref ( yypminor.yy384 ) ); - //#line 1458 "parse.c" - } - break; - case 234: /* trigger_cmd_list */ - case 239: /* trigger_cmd */ - { - //#line 1210"parse.y" - sqlite3DeleteTriggerStep( pParse.db, ref ( yypminor.yy203 ) ); - //#line 1466 "parse.c" - } - break; - case 236: /* trigger_event */ - { - //#line 1196 "parse.y" - sqlite3IdListDelete( pParse.db, ref ( yypminor.yy90 ).b ); - //#line 1473 "parse.c" - } - break; - default: - break; /* If no destructor action specified: do nothing */ - } - } + static void yy_destructor( + yyParser yypParser, /* The parser */ + YYCODETYPE yymajor, /* Type code for object to destroy */ + YYMINORTYPE yypminor /* The object to be destroyed */ + ) { + Parse pParse = yypParser.pParse; // sqlite3ParserARG_FETCH; + switch (yymajor) { + /* Here is inserted the actions which take place when a + ** terminal or non-terminal is destroyed. This can happen + ** when the symbol is popped from the stack during a + ** reduce or during error processing or when a parser is + ** being destroyed before it is finished parsing. + ** + ** Note: during a reduce, the only symbols destroyed are those + ** which appear on the RHS of the rule, but which are not used + ** inside the C code. + */ + case 160: /* select */ + case 194: /* oneselect */ + { + //#line 403 "parse.y" + sqlite3SelectDelete(pParse.db, ref (yypminor.yy387)); + //#line 1399 "parse.c" + } + break; + case 174: /* term */ + case 175: /* Expr */ + { + //#line 720 "parse.y" + sqlite3ExprDelete(pParse.db, ref (yypminor.yy118).pExpr); + //#line 1407 "parse.c" + } + break; + case 179: /* idxlist_opt */ + case 187: /* idxlist */ + case 197: /* selcollist */ + case 200: /* groupby_opt */ + case 202: /* orderby_opt */ + case 204: /* sclp */ + case 214: /* sortlist */ + case 216: /* nexprlist */ + case 217: /* setlist */ + case 220: /* itemlist */ + case 221: /* exprlist */ + case 226: /* case_exprlist */ + { + //#line 1103 "parse.y" + sqlite3ExprListDelete(pParse.db, ref (yypminor.yy322)); + //#line 1425 "parse.c" + } + break; + case 193: /* fullname */ + case 198: /* from */ + case 206: /* seltablist */ + case 207: /* stl_prefix */ + { + //#line 534 "parse.y" + sqlite3SrcListDelete(pParse.db, ref (yypminor.yy259)); + //#line 1435 "parse.c" + } + break; + case 199: /* where_opt */ + case 201: /* having_opt */ + case 210: /* on_opt */ + case 215: /* sortitem */ + case 225: /* case_operand */ + case 227: /* case_else */ + case 238: /* when_clause */ + case 243: /* key_opt */ + { + //#line 644 "parse.y" + sqlite3ExprDelete(pParse.db, ref (yypminor.yy314)); + //#line 1449 "parse.c" + } + break; + case 211: /* using_opt */ + case 213: /* inscollist */ + case 219: /* inscollist_opt */ + { + //#line 566 "parse.y" + sqlite3IdListDelete(pParse.db, ref (yypminor.yy384)); + //#line 1458 "parse.c" + } + break; + case 234: /* trigger_cmd_list */ + case 239: /* trigger_cmd */ + { + //#line 1210"parse.y" + sqlite3DeleteTriggerStep(pParse.db, ref (yypminor.yy203)); + //#line 1466 "parse.c" + } + break; + case 236: /* trigger_event */ + { + //#line 1196 "parse.y" + sqlite3IdListDelete(pParse.db, ref (yypminor.yy90).b); + //#line 1473 "parse.c" + } + break; + default: + break; /* If no destructor action specified: do nothing */ + } + } - /* - ** Pop the parser's stack once. - ** - ** If there is a destructor routine associated with the token which - ** is popped from the stack, then call it. - ** - ** Return the major token number for the symbol popped. - */ - static int yy_pop_parser_stack( yyParser pParser ) - { - YYCODETYPE yymajor; - yyStackEntry yytos = pParser.yystack[pParser.yyidx]; + /* + ** Pop the parser's stack once. + ** + ** If there is a destructor routine associated with the token which + ** is popped from the stack, then call it. + ** + ** Return the major token number for the symbol popped. + */ + static int yy_pop_parser_stack(yyParser pParser) { + YYCODETYPE yymajor; + yyStackEntry yytos = pParser.yystack[pParser.yyidx]; - /* There is no mechanism by which the parser stack can be popped below - ** empty in SQLite. */ - if ( NEVER( pParser.yyidx < 0 ) ) - return 0; + /* There is no mechanism by which the parser stack can be popped below + ** empty in SQLite. */ + if (NEVER(pParser.yyidx < 0)) + return 0; #if !NDEBUG - if ( yyTraceFILE != null && pParser.yyidx >= 0 ) - { - fprintf( yyTraceFILE, "%sPopping %s\n", - yyTracePrompt, - yyTokenName[yytos.major] ); - } + if (yyTraceFILE != null && pParser.yyidx >= 0) { + fprintf(yyTraceFILE, "%sPopping %s\n", + yyTracePrompt, + yyTokenName[yytos.major]); + } #endif - yymajor = yytos.major; - yy_destructor( pParser, yymajor, yytos.minor ); - pParser.yyidx--; - return yymajor; - } + yymajor = yytos.major; + yy_destructor(pParser, yymajor, yytos.minor); + pParser.yyidx--; + return yymajor; + } - /* - ** Deallocate and destroy a parser. Destructors are all called for - ** all stack elements before shutting the parser down. - ** - ** Inputs: - **
    - **
  • A pointer to the parser. This should be a pointer - ** obtained from sqlite3ParserAlloc. - **
  • A pointer to a function used to reclaim memory obtained - ** from malloc. - **
- */ - static void sqlite3ParserFree( - yyParser p, /* The parser to be deleted */ - dxDel freeProc//)(void*) /* Function used to reclaim memory */ - ) - { - yyParser pParser = p; - /* In SQLite, we never try to destroy a parser that was not successfully - ** created in the first place. */ - if ( NEVER( pParser == null ) ) - return; - while ( pParser.yyidx >= 0 ) - yy_pop_parser_stack( pParser ); + /* + ** Deallocate and destroy a parser. Destructors are all called for + ** all stack elements before shutting the parser down. + ** + ** Inputs: + **
    + **
  • A pointer to the parser. This should be a pointer + ** obtained from sqlite3ParserAlloc. + **
  • A pointer to a function used to reclaim memory obtained + ** from malloc. + **
+ */ + static void sqlite3ParserFree( + yyParser p, /* The parser to be deleted */ + dxDel freeProc//)(void*) /* Function used to reclaim memory */ + ) { + yyParser pParser = p; + /* In SQLite, we never try to destroy a parser that was not successfully + ** created in the first place. */ + if (NEVER(pParser == null)) + return; + while (pParser.yyidx >= 0) + yy_pop_parser_stack(pParser); #if YYSTACKDEPTH//<=0 pParser.yystack = null;//free(pParser.yystack); #endif - pParser = null;// freeProc(ref pParser); - } + pParser = null;// freeProc(ref pParser); + } - /* - ** Return the peak depth of the stack for a parser. - */ + /* + ** Return the peak depth of the stack for a parser. + */ #if YYTRACKMAXSTACKDEPTH int sqlite3ParserStackPeak(void p){ yyParser pParser = (yyParser*)p; @@ -1617,168 +1587,153 @@ int sqlite3ParserStackPeak(void p){ } #endif - /* -** Find the appropriate action for a parser given the terminal -** look-ahead token iLookAhead. -** -** If the look-ahead token is YYNOCODE, then check to see if the action is -** independent of the look-ahead. If it is, return the action, otherwise -** return YY_NO_ACTION. -*/ - static int yy_find_shift_action( - yyParser pParser, /* The parser */ - YYCODETYPE iLookAhead /* The look-ahead token */ - ) - { - int i; - int stateno = pParser.yystack[pParser.yyidx].stateno; + /* + ** Find the appropriate action for a parser given the terminal + ** look-ahead token iLookAhead. + ** + ** If the look-ahead token is YYNOCODE, then check to see if the action is + ** independent of the look-ahead. If it is, return the action, otherwise + ** return YY_NO_ACTION. + */ + static int yy_find_shift_action( + yyParser pParser, /* The parser */ + YYCODETYPE iLookAhead /* The look-ahead token */ + ) { + int i; + int stateno = pParser.yystack[pParser.yyidx].stateno; - if ( stateno > YY_SHIFT_COUNT - || ( i = yy_shift_ofst[stateno] ) == YY_SHIFT_USE_DFLT ) - { - return yy_default[stateno]; - } - Debug.Assert( iLookAhead != YYNOCODE ); - i += iLookAhead; - if ( i < 0 || i >= YY_ACTTAB_COUNT || yy_lookahead[i] != iLookAhead ) - { - if ( iLookAhead > 0 ) - { - //#if YYFALLBACK - YYCODETYPE iFallback; /* Fallback token */ - if ( iLookAhead < yyFallback.Length //yyFallback.Length/sizeof(yyFallback[0]) - && ( iFallback = yyFallback[iLookAhead] ) != 0 ) - { -#if !NDEBUG - if ( yyTraceFILE != null ) - { - fprintf( yyTraceFILE, "%sFALLBACK %s => %s\n", - yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback] ); + if (stateno > YY_SHIFT_COUNT + || (i = yy_shift_ofst[stateno]) == YY_SHIFT_USE_DFLT) { + return yy_default[stateno]; } + Debug.Assert(iLookAhead != YYNOCODE); + i += iLookAhead; + if (i < 0 || i >= YY_ACTTAB_COUNT || yy_lookahead[i] != iLookAhead) { + if (iLookAhead > 0) { + //#if YYFALLBACK + YYCODETYPE iFallback; /* Fallback token */ + if (iLookAhead < yyFallback.Length //yyFallback.Length/sizeof(yyFallback[0]) + && (iFallback = yyFallback[iLookAhead]) != 0) { +#if !NDEBUG + if (yyTraceFILE != null) { + fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n", + yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); + } #endif - return yy_find_shift_action( pParser, iFallback ); - } - //#endif - //#if YYWILDCARD - { - int j = i - iLookAhead + YYWILDCARD; - if ( - //#if YY_SHIFT_MIN+YYWILDCARD<0 - j >= 0 && - //#endif - //#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT - j < YY_ACTTAB_COUNT && - //#endif - yy_lookahead[j] == YYWILDCARD - ) - { + return yy_find_shift_action(pParser, iFallback); + } + //#endif + //#if YYWILDCARD + { + int j = i - iLookAhead + YYWILDCARD; + if ( + //#if YY_SHIFT_MIN+YYWILDCARD<0 + j >= 0 && + //#endif + //#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT + j < YY_ACTTAB_COUNT && + //#endif + yy_lookahead[j] == YYWILDCARD + ) { #if !NDEBUG - if ( yyTraceFILE != null ) - { - Debugger.Break(); // TODO -- - //fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", - // yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); - } + if (yyTraceFILE != null) { + Debugger.Break(); // TODO -- + //fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", + // yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); + } #endif // * NDEBUG */ - return yy_action[j]; + return yy_action[j]; + } + } + //#endif // * YYWILDCARD */ + } + return yy_default[stateno]; + } else { + return yy_action[i]; } - } - //#endif // * YYWILDCARD */ } - return yy_default[stateno]; - } - else - { - return yy_action[i]; - } - } - /* - ** Find the appropriate action for a parser given the non-terminal - ** look-ahead token iLookAhead. - ** - ** If the look-ahead token is YYNOCODE, then check to see if the action is - ** independent of the look-ahead. If it is, return the action, otherwise - ** return YY_NO_ACTION. - */ - static int yy_find_reduce_action( - int stateno, /* Current state number */ - YYCODETYPE iLookAhead /* The look-ahead token */ - ) - { - int i; + /* + ** Find the appropriate action for a parser given the non-terminal + ** look-ahead token iLookAhead. + ** + ** If the look-ahead token is YYNOCODE, then check to see if the action is + ** independent of the look-ahead. If it is, return the action, otherwise + ** return YY_NO_ACTION. + */ + static int yy_find_reduce_action( + int stateno, /* Current state number */ + YYCODETYPE iLookAhead /* The look-ahead token */ + ) { + int i; #if YYERRORSYMBOL if( stateno>YY_REDUCE_COUNT ){ return yy_default[stateno]; } #else - Debug.Assert( stateno <= YY_REDUCE_COUNT ); + Debug.Assert(stateno <= YY_REDUCE_COUNT); #endif - i = yy_reduce_ofst[stateno]; - Debug.Assert( i != YY_REDUCE_USE_DFLT ); - Debug.Assert( iLookAhead != YYNOCODE ); - i += iLookAhead; + i = yy_reduce_ofst[stateno]; + Debug.Assert(i != YY_REDUCE_USE_DFLT); + Debug.Assert(iLookAhead != YYNOCODE); + i += iLookAhead; #if YYERRORSYMBOL if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ return yy_default[stateno]; } #else - Debug.Assert( i >= 0 && i < YY_ACTTAB_COUNT ); - Debug.Assert( yy_lookahead[i] == iLookAhead ); + Debug.Assert(i >= 0 && i < YY_ACTTAB_COUNT); + Debug.Assert(yy_lookahead[i] == iLookAhead); #endif - return yy_action[i]; - } + return yy_action[i]; + } - /* - ** The following routine is called if the stack overflows. - */ - static void yyStackOverflow( yyParser yypParser, YYMINORTYPE yypMinor ) - { - Parse pParse = yypParser.pParse; // sqlite3ParserARG_FETCH; - yypParser.yyidx--; + /* + ** The following routine is called if the stack overflows. + */ + static void yyStackOverflow(yyParser yypParser, YYMINORTYPE yypMinor) { + Parse pParse = yypParser.pParse; // sqlite3ParserARG_FETCH; + yypParser.yyidx--; #if !NDEBUG - if ( yyTraceFILE != null ) - { - Debugger.Break(); // TODO -- - //fprintf(yyTraceFILE, "%sStack Overflow!\n", yyTracePrompt); - } + if (yyTraceFILE != null) { + Debugger.Break(); // TODO -- + //fprintf(yyTraceFILE, "%sStack Overflow!\n", yyTracePrompt); + } #endif - while ( yypParser.yyidx >= 0 ) - yy_pop_parser_stack( yypParser ); - /* Here code is inserted which will execute if the parser - ** stack every overflows */ - //#line 38 "parse.y" + while (yypParser.yyidx >= 0) + yy_pop_parser_stack(yypParser); + /* Here code is inserted which will execute if the parser + ** stack every overflows */ + //#line 38 "parse.y" - UNUSED_PARAMETER( yypMinor ); /* Silence some compiler warnings */ - sqlite3ErrorMsg( pParse, "parser stack overflow" ); - pParse.parseError = 1; - //#line 1664 "parse.c" - yypParser.pParse = pParse;// sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument var */ - } + UNUSED_PARAMETER(yypMinor); /* Silence some compiler warnings */ + sqlite3ErrorMsg(pParse, "parser stack overflow"); + pParse.parseError = 1; + //#line 1664 "parse.c" + yypParser.pParse = pParse;// sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument var */ + } - /* - ** Perform a shift action. - */ - static void yy_shift( - yyParser yypParser, /* The parser to be shifted */ - int yyNewState, /* The new state to shift in */ - int yyMajor, /* The major token to shift in */ - YYMINORTYPE yypMinor /* Pointer to the minor token to shift in */ - ) - { - yyStackEntry yytos = new yyStackEntry(); - yypParser.yyidx++; + /* + ** Perform a shift action. + */ + static void yy_shift( + yyParser yypParser, /* The parser to be shifted */ + int yyNewState, /* The new state to shift in */ + int yyMajor, /* The major token to shift in */ + YYMINORTYPE yypMinor /* Pointer to the minor token to shift in */ + ) { + yyStackEntry yytos = new yyStackEntry(); + yypParser.yyidx++; #if YYTRACKMAXSTACKDEPTH if( yypParser.yyidx>yypParser.yyidxMax ){ yypParser.yyidxMax = yypParser.yyidx; } #endif #if !YYSTACKDEPTH//was YYSTACKDEPTH>0 - if ( yypParser.yyidx >= YYSTACKDEPTH ) - { - yyStackOverflow( yypParser, yypMinor ); - return; - } + if (yypParser.yyidx >= YYSTACKDEPTH) { + yyStackOverflow(yypParser, yypMinor); + return; + } #else if( yypParser.yyidx>=yypParser.yystksz ){ yyGrowStack(yypParser); @@ -1788,37 +1743,34 @@ YYMINORTYPE yypMinor /* Pointer to the minor token to shift in */ } } #endif - yypParser.yystack[yypParser.yyidx] = yytos;//yytos = yypParser.yystack[yypParser.yyidx]; - yytos.stateno = (YYACTIONTYPE)yyNewState; - yytos.major = (YYCODETYPE)yyMajor; - yytos.minor = yypMinor; + yypParser.yystack[yypParser.yyidx] = yytos;//yytos = yypParser.yystack[yypParser.yyidx]; + yytos.stateno = (YYACTIONTYPE)yyNewState; + yytos.major = (YYCODETYPE)yyMajor; + yytos.minor = yypMinor; #if !NDEBUG - if ( yyTraceFILE != null && yypParser.yyidx > 0 ) - { - int i; - fprintf( yyTraceFILE, "%sShift %d\n", yyTracePrompt, yyNewState ); - fprintf( yyTraceFILE, "%sStack:", yyTracePrompt ); - for ( i = 1; i <= yypParser.yyidx; i++ ) - fprintf( yyTraceFILE, " %s", yyTokenName[yypParser.yystack[i].major] ); - fprintf( yyTraceFILE, "\n" ); - } + if (yyTraceFILE != null && yypParser.yyidx > 0) { + int i; + fprintf(yyTraceFILE, "%sShift %d\n", yyTracePrompt, yyNewState); + fprintf(yyTraceFILE, "%sStack:", yyTracePrompt); + for (i = 1; i <= yypParser.yyidx; i++) + fprintf(yyTraceFILE, " %s", yyTokenName[yypParser.yystack[i].major]); + fprintf(yyTraceFILE, "\n"); + } #endif - } - /* The following table contains information about every rule that - ** is used during the reduce. - */ - public struct _yyRuleInfo - { - public YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ - public byte nrhs; /* Number of right-hand side symbols in the rule */ - public _yyRuleInfo( YYCODETYPE lhs, byte nrhs ) - { - this.lhs = lhs; - this.nrhs = nrhs; - } + } + /* The following table contains information about every rule that + ** is used during the reduce. + */ + public struct _yyRuleInfo { + public YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ + public byte nrhs; /* Number of right-hand side symbols in the rule */ + public _yyRuleInfo(YYCODETYPE lhs, byte nrhs) { + this.lhs = lhs; + this.nrhs = nrhs; + } - } - static _yyRuleInfo[] yyRuleInfo = new _yyRuleInfo[]{ + } + static _yyRuleInfo[] yyRuleInfo = new _yyRuleInfo[]{ new _yyRuleInfo( 142, 1 ), new _yyRuleInfo( 143, 2 ), new _yyRuleInfo( 143, 1 ), @@ -2150,1924 +2102,1880 @@ public _yyRuleInfo( YYCODETYPE lhs, byte nrhs ) new _yyRuleInfo( 251, 2 ), }; - //static void yy_accept(yyParser*); /* Forward Declaration */ + //static void yy_accept(yyParser*); /* Forward Declaration */ - /* - ** Perform a reduce action and the shift that must immediately - ** follow the reduce. - */ - static void yy_reduce( - yyParser yypParser, /* The parser */ - int yyruleno /* Number of the rule by which to reduce */ - ) - { - int yygoto; /* The next state */ - int yyact; /* The next action */ - YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ - yymsp yymsp; // yyStackEntry[] yymsp = new yyStackEntry[0]; /* The top of the parser's stack */ - int yysize; /* Amount to pop the stack */ - Parse pParse = yypParser.pParse; //sqlite3ParserARG_FETCH; + /* + ** Perform a reduce action and the shift that must immediately + ** follow the reduce. + */ + static void yy_reduce( + yyParser yypParser, /* The parser */ + int yyruleno /* Number of the rule by which to reduce */ + ) { + int yygoto; /* The next state */ + int yyact; /* The next action */ + YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ + yymsp yymsp; // yyStackEntry[] yymsp = new yyStackEntry[0]; /* The top of the parser's stack */ + int yysize; /* Amount to pop the stack */ + Parse pParse = yypParser.pParse; //sqlite3ParserARG_FETCH; - yymsp = new yymsp( ref yypParser, yypParser.yyidx ); // yymsp[0] = yypParser.yystack[yypParser.yyidx]; + yymsp = new yymsp(ref yypParser, yypParser.yyidx); // yymsp[0] = yypParser.yystack[yypParser.yyidx]; #if !NDEBUG - if ( yyTraceFILE != null && yyruleno >= 0 - && yyruleno < yyRuleName.Length ) - { //(int)(yyRuleName.Length/sizeof(yyRuleName[0])) ){ - fprintf( yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, - yyRuleName[yyruleno] ); - } + if (yyTraceFILE != null && yyruleno >= 0 + && yyruleno < yyRuleName.Length) { //(int)(yyRuleName.Length/sizeof(yyRuleName[0])) ){ + fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, + yyRuleName[yyruleno]); + } #endif // * NDEBUG */ - /* Silence complaints from purify about yygotominor being uninitialized -** in some cases when it is copied into the stack after the following -** switch. yygotominor is uninitialized when a rule reduces that does -** not set the value of its left-hand side nonterminal. Leaving the -** value of the nonterminal uninitialized is utterly harmless as long -** as the value is never used. So really the only thing this code -** accomplishes is to quieten purify. -** -** 2007-01-16: The wireshark project (www.wireshark.org) reports that -** without this code, their parser segfaults. I'm not sure what there -** parser is doing to make this happen. This is the second bug report -** from wireshark this week. Clearly they are stressing Lemon in ways -** that it has not been previously stressed... (SQLite ticket #2172) -*/ - yygotominor = new YYMINORTYPE(); //memset(yygotominor, 0, yygotominor).Length; - switch ( yyruleno ) - { - /* Beginning here are the reduction cases. A typical example - ** follows: - ** case 0: - ** //#line - ** { ... } // User supplied code - ** //#line - ** break; - */ - case 5: /* explain ::= */ - //#line 107 "parse.y" - { - sqlite3BeginParse( pParse, 0 ); - } - //#line 2107 "parse.c" - break; - case 6: /* explain ::= EXPLAIN */ - //#line 109 "parse.y" - { - sqlite3BeginParse( pParse, 1 ); - } - //#line 2112 "parse.c" - break; - case 7: /* explain ::= EXPLAIN QUERY PLAN */ - //#line 110 "parse.y" - { - sqlite3BeginParse( pParse, 2 ); - } - //#line 2117 "parse.c" - break; - case 8: /* cmdx ::= cmd */ - //#line 112 "parse.y" - { - sqlite3FinishCoding( pParse ); - } - //#line 2122 "parse.c" - break; - case 9: /* cmd ::= BEGIN transtype trans_opt */ - //#line 117 "parse.y" - { - sqlite3BeginTransaction( pParse, yymsp[-1].minor.yy4 ); - } - //#line 2127 "parse.c" - break; - case 13: /* transtype ::= */ - //#line 122 "parse.y" - { - yygotominor.yy4 = TK_DEFERRED; - } - //#line 2132 "parse.c" - break; - case 14: /* transtype ::= DEFERRED */ - case 15: /* transtype ::= IMMEDIATE */ //yytestcase(yyruleno==15); - case 16: /* transtype ::= EXCLUSIVE */ //yytestcase(yyruleno==16); - case 115: /* multiselect_op ::= UNION */ //yytestcase(yyruleno==114); - case 117: /* multiselect_op ::= EXCEPT|INTERSECT */ //yytestcase(yyruleno==116); - //#line 123 "parse.y" - { - yygotominor.yy4 = yymsp[0].major; - } - //#line 2141 "parse.c" - break; - case 17: /* cmd ::= COMMIT trans_opt */ - case 18: /* cmd ::= END trans_opt */ //yytestcase(yyruleno==18); - //#line 126 "parse.y" - { - sqlite3CommitTransaction( pParse ); - } - //#line 2147 "parse.c" - break; - case 19: /* cmd ::= ROLLBACK trans_opt */ - //#line 128 "parse.y" - { - sqlite3RollbackTransaction( pParse ); - } - //#line 2152 "parse.c" - break; - case 22: /* cmd ::= SAVEPOINT nm */ - //#line 132 "parse.y" - { - sqlite3Savepoint( pParse, SAVEPOINT_BEGIN, yymsp[0].minor.yy0 ); - } - //#line 2159 "parse.c" - break; - case 23: /* cmd ::= RELEASE savepoint_opt nm */ - //#line 135 "parse.y" - { - sqlite3Savepoint( pParse, SAVEPOINT_RELEASE, yymsp[0].minor.yy0 ); - } - //#line 2166 "parse.c" - break; - case 24: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ - //#line 138 "parse.y" - { - sqlite3Savepoint( pParse, SAVEPOINT_ROLLBACK, yymsp[0].minor.yy0 ); - } - //#line 2173 "parse.c" - break; - case 26: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ - //#line 145 "parse.y" - { - sqlite3StartTable( pParse, yymsp[-1].minor.yy0, yymsp[0].minor.yy0, yymsp[-4].minor.yy4, 0, 0, yymsp[-2].minor.yy4 ); - } - //#line 2180 "parse.c" - break; - case 27: /* createkw ::= CREATE */ - //#line 148 "parse.y" - { - pParse.db.lookaside.bEnabled = 0; - yygotominor.yy0 = yymsp[0].minor.yy0; - } - //#line 2188 "parse.c" - break; - case 28: /* ifnotexists ::= */ - case 31: /* temp ::= */ //yytestcase(yyruleno == 31); - case 70: /* autoinc ::= */ //yytestcase(yyruleno == 70); - case 83: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ //yytestcase(yyruleno == 83); - case 85: /* init_deferred_pred_opt ::= */ //yytestcase(yyruleno == 85); - case 87: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ //yytestcase(yyruleno == 87); - case 98: /* defer_subclause_opt ::= */ //yytestcase(yyruleno == 98); - case 109: /* ifexists ::= */ //yytestcase(yyruleno == 109); - case 120: /* distinct ::= ALL */ //yytestcase(yyruleno == 120); - case 121: /* distinct ::= */ //yytestcase(yyruleno == 121); - case 222: /* between_op ::= BETWEEN */ //yytestcase(yyruleno == 223); - case 225: /* in_op ::= IN */ //yytestcase(yyruleno == 226); - //#line 153 "parse.y" - { - yygotominor.yy4 = 0; - } - //#line 2204 "parse.c" - break; - case 29: /* ifnotexists ::= IF NOT EXISTS */ - case 30: /* temp ::= TEMP */ //yytestcase(yyruleno == 30); - case 71: /* autoinc ::= AUTOINCR */ //yytestcase(yyruleno == 71); - case 86: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ //yytestcase(yyruleno == 86); - case 108: /* ifexists ::= IF EXISTS */ //yytestcase(yyruleno == 108); - case 119: /* distinct ::= DISTINCT */ //yytestcase(yyruleno == 119); - case 223: /* between_op ::= NOT BETWEEN */ //yytestcase(yyruleno == 224); - case 226: /* in_op ::= NOT IN */ //yytestcase(yyruleno == 227); - //#line 154 "parse.y" - { - yygotominor.yy4 = 1; - } - //#line 2216 "parse.c" - break; - case 32: /* create_table_args ::= LP columnlist conslist_opt RP */ - //#line 160 "parse.y" - { - sqlite3EndTable( pParse, yymsp[-1].minor.yy0, yymsp[0].minor.yy0, 0 ); - } - //#line 2223 "parse.c" - break; - case 33: /* create_table_args ::= AS select */ - //#line 163 "parse.y" - { - sqlite3EndTable( pParse, 0, 0, yymsp[0].minor.yy387 ); - sqlite3SelectDelete( pParse.db, ref yymsp[0].minor.yy387 ); - } - //#line 2231 "parse.c" - break; - case 36: /* column ::= columnid type carglist */ - //#line 175 "parse.y" - { - //yygotominor.yy0.z = yymsp[-2].minor.yy0.z; - //yygotominor.yy0.n = (int)( pParse.sLastToken.z - yymsp[-2].minor.yy0.z ) + pParse.sLastToken.n; - yygotominor.yy0.n = (int)( yymsp[-2].minor.yy0.z.Length - pParse.sLastToken.z.Length ) + pParse.sLastToken.n; - yygotominor.yy0.z = yymsp[-2].minor.yy0.z.Substring( 0, yygotominor.yy0.n ); - } - //#line 2239 "parse.c" - break; - case 37: /* columnid ::= nm */ - //#line 179 "parse.y" - { - sqlite3AddColumn( pParse, yymsp[0].minor.yy0 ); - yygotominor.yy0 = yymsp[0].minor.yy0; - } - //#line 2247 "parse.c" - break; - case 38: /* id ::= ID */ - case 39: /* id ::= INDEXED */ //yytestcase(yyruleno==39); - case 40: /* ids ::= ID|STRING */ //yytestcase(yyruleno==40); - case 41: /* nm ::= id */ //yytestcase(yyruleno==41); - case 42: /* nm ::= STRING */ //yytestcase(yyruleno==42); - case 43: /* nm ::= JOIN_KW */ //yytestcase(yyruleno==43); - case 46: /* typetoken ::= typename */ //yytestcase(yyruleno==46); - case 49: /* typename ::= ids */ //yytestcase(yyruleno==49); - case 127: /* as ::= AS nm */ ////yytestcase(yyruleno == 127); - case 128: /* as ::= ids */ ////yytestcase(yyruleno == 128); - case 138: /* dbnm ::= DOT nm */ ////yytestcase(yyruleno == 138); - case 147: /* indexed_opt ::= INDEXED BY nm */ ////yytestcase(yyruleno == 147); - case 251: /* collate ::= COLLATE ids */ //testcase(yyruleno == 251); - case 260: /* nmnum ::= plus_num */ //testcase(yyruleno == 260); - case 261: /* nmnum ::= nm */ //testcase(yyruleno == 261); - case 262: /* nmnum ::= ON */ //testcase(yyruleno == 262); - case 263: /* nmnum ::= DELETE */ //testcase(yyruleno == 263); - case 264: /* nmnum ::= DEFAULT */ //testcase(yyruleno == 264); - case 265: /* plus_num ::= plus_opt number */ //testcase(yyruleno == 265); - case 266: /* minus_num ::= MINUS number */ //testcase(yyruleno == 266); - case 267: /* number ::= INTEGER|FLOAT */ //testcase(yyruleno == 267); - case 285: /* trnm ::= nm */ //testcase(yyruleno == 285); - //#line 189 "parse.y" - { - yygotominor.yy0 = yymsp[0].minor.yy0; - } - //#line 2273 "parse.c" - break; - case 45: /* type ::= typetoken */ - //#line 251 "parse.y" - { - sqlite3AddColumnType( pParse, yymsp[0].minor.yy0 ); - } - //#line 2278 "parse.c" - break; - case 47: /* typetoken ::= typename LP signed RP */ - //#line 253 "parse.y" - { - //yygotominor.yy0.z = yymsp[-3].minor.yy0.z; - //yygotominor.yy0.n = (int)( &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z ); - yygotominor.yy0.n = yymsp[-3].minor.yy0.z.Length - yymsp[0].minor.yy0.z.Length + yymsp[0].minor.yy0.n; - yygotominor.yy0.z = yymsp[-3].minor.yy0.z.Substring( 0, yygotominor.yy0.n ); - } - //#line 2286 "parse.c" - break; - case 48: /* typetoken ::= typename LP signed COMMA signed RP */ - //#line 257 "parse.y" - { - //yygotominor.yy0.z = yymsp[-5].minor.yy0.z; - //yygotominor.yy0.n = (int)( &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z ); - yygotominor.yy0.n = yymsp[-5].minor.yy0.z.Length - yymsp[0].minor.yy0.z.Length + 1; - yygotominor.yy0.z = yymsp[-5].minor.yy0.z.Substring( 0, yygotominor.yy0.n ); - } - //#line 2294 "parse.c" - break; - case 50: /* typename ::= typename ids */ - //#line 263 "parse.y" - { - //yygotominor.yy0.z=yymsp[-1].minor.yy0.z; yygotominor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z); - yygotominor.yy0.z = yymsp[-1].minor.yy0.z; - yygotominor.yy0.n = yymsp[0].minor.yy0.n + (int)( yymsp[-1].minor.yy0.z.Length - yymsp[0].minor.yy0.z.Length ); - } - //#line 2299 "parse.c" - break; - case 57: /* ccons ::= DEFAULT term */ - case 59: /* ccons ::= DEFAULT PLUS term */ //yytestcase(yyruleno==59); - //#line 274 "parse.y" - { - sqlite3AddDefaultValue( pParse, yymsp[0].minor.yy118 ); - } - //#line 2308 "parse.c" - break; - case 58: /* ccons ::= DEFAULT LP expr RP */ - //#line 275 "parse.y" - { - sqlite3AddDefaultValue( pParse, yymsp[-1].minor.yy118 ); - } - //#line 2310 "parse.c" - break; - case 60: /* ccons ::= DEFAULT MINUS term */ - //#line 277 "parse.y" - { - ExprSpan v = new ExprSpan(); - v.pExpr = sqlite3PExpr( pParse, TK_UMINUS, yymsp[0].minor.yy118.pExpr, 0, 0 ); - v.zStart = yymsp[-1].minor.yy0.z; - v.zEnd = yymsp[0].minor.yy118.zEnd; - sqlite3AddDefaultValue( pParse, v ); - } - //#line 2321 "parse.c" - break; - case 61: /* ccons ::= DEFAULT id */ - //#line 284 "parse.y" - { - ExprSpan v = new ExprSpan(); - spanExpr( v, pParse, TK_STRING, yymsp[0].minor.yy0 ); - sqlite3AddDefaultValue( pParse, v ); - } - //#line 2330 "parse.c" - break; - case 63: /* ccons ::= NOT NULL onconf */ - //#line 294 "parse.y" - { - sqlite3AddNotNull( pParse, yymsp[0].minor.yy4 ); - } - //#line 2335 "parse.c" - break; - case 64: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ - //#line 296 "parse.y" - { - sqlite3AddPrimaryKey( pParse, 0, yymsp[-1].minor.yy4, yymsp[0].minor.yy4, yymsp[-2].minor.yy4 ); - } - //#line 2340 "parse.c" - break; - case 65: /* ccons ::= UNIQUE onconf */ - //#line 297 "parse.y" - { - sqlite3CreateIndex( pParse, 0, 0, 0, 0, yymsp[0].minor.yy4, 0, 0, 0, 0 ); - } - //#line 2345 "parse.c" - break; - case 66: /* ccons ::= CHECK LP expr RP */ - //#line 298 "parse.y" - { - sqlite3AddCheckConstraint( pParse, yymsp[-1].minor.yy118.pExpr ); - } - //#line 2350 "parse.c" - break; - case 67: /* ccons ::= REFERENCES nm idxlist_opt refargs */ - //#line 300 "parse.y" - { - sqlite3CreateForeignKey( pParse, 0, yymsp[-2].minor.yy0, yymsp[-1].minor.yy322, yymsp[0].minor.yy4 ); - } - //#line 2355 "parse.c" - break; - case 68: /* ccons ::= defer_subclause */ - //#line 301 "parse.y" - { - sqlite3DeferForeignKey( pParse, yymsp[0].minor.yy4 ); - } - //#line 2360 "parse.c" - break; - case 69: /* ccons ::= COLLATE ids */ - //#line 302 "parse.y" - { - sqlite3AddCollateType( pParse, yymsp[0].minor.yy0 ); - } - //#line 2365 "parse.c" - break; - case 72: /* refargs ::= */ - //#line 315 "parse.y" - { - yygotominor.yy4 = OE_None * 0x0101; /* EV: R-19803-45884 */ - } - //#line 2370 "parse.c" - break; - case 73: /* refargs ::= refargs refarg */ - //#line 316 "parse.y" - { - yygotominor.yy4 = ( yymsp[-1].minor.yy4 & ~yymsp[0].minor.yy215.mask ) | yymsp[0].minor.yy215.value; - } - //#line 2375 "parse.c" - break; - case 74: /* refarg ::= MATCH nm */ - case 75: /* refarg ::= ON INSERT refact */ //yytestcase(yyruleno==75); - //#line 318 "parse.y" - { - yygotominor.yy215.value = 0; - yygotominor.yy215.mask = 0x000000; - } - //#line 2381 "parse.c" - break; - case 76: /* refarg ::= ON DELETE refact */ - //#line 320 "parse.y" - { - yygotominor.yy215.value = yymsp[0].minor.yy4; - yygotominor.yy215.mask = 0x0000ff; - } - //#line 2386 "parse.c" - break; - case 77: /* refarg ::= ON UPDATE refact */ - //#line 321 "parse.y" - { - yygotominor.yy215.value = yymsp[0].minor.yy4 << 8; - yygotominor.yy215.mask = 0x00ff00; - } - //#line 2391 "parse.c" - break; - case 78: /* refact ::= SET NULL */ - //#line 323 "parse.y" - { - yygotominor.yy4 = OE_SetNull; /* EV: R-33326-45252 */ - } - //#line 2396 "parse.c" - break; - case 79: /* refact ::= SET DEFAULT */ - //#line 324 "parse.y" - { - yygotominor.yy4 = OE_SetDflt; /* EV: R-33326-45252 */ - } - //#line 2401 "parse.c" - break; - case 80: /* refact ::= CASCADE */ - //#line 325 "parse.y" - { - yygotominor.yy4 = OE_Cascade; /* EV: R-33326-45252 */ - } - //#line 2406 "parse.c" - break; - case 81: /* refact ::= RESTRICT */ - //#line 326 "parse.y" - { - yygotominor.yy4 = OE_Restrict; /* EV: R-33326-45252 */ - } - //#line 2411 "parse.c" - break; - case 82: /* refact ::= NO ACTION */ - //#line 327 "parse.y" - { - yygotominor.yy4 = OE_None; /* EV: R-33326-45252 */ - } - //#line 2416 "parse.c" - break; - case 84: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ - case 99: /* defer_subclause_opt ::= defer_subclause */ //yytestcase(yyruleno==99); - case 101: /* onconf ::= ON CONFLICT resolvetype */ //yytestcase(yyruleno==101); - case 104: /* resolvetype ::= raisetype */ //yytestcase(yyruleno==104); - //#line 330 "parse.y" - { - yygotominor.yy4 = yymsp[0].minor.yy4; - } - //#line 2424 "parse.c" - break; - case 88: /* conslist_opt ::= */ - //#line 339 "parse.y" - { - yygotominor.yy0.n = 0; - yygotominor.yy0.z = null; - } - //#line 2429 "parse.c" - break; - case 89: /* conslist_opt ::= COMMA conslist */ - //#line 340 "parse.y" - { - yygotominor.yy0 = yymsp[-1].minor.yy0; - } - //#line 2434 "parse.c" - break; - case 94: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */ - //#line 346 "parse.y" - { - sqlite3AddPrimaryKey( pParse, yymsp[-3].minor.yy322, yymsp[0].minor.yy4, yymsp[-2].minor.yy4, 0 ); - } - //#line 2439 "parse.c" - break; - case 95: /* tcons ::= UNIQUE LP idxlist RP onconf */ - //#line 348 "parse.y" - { - sqlite3CreateIndex( pParse, 0, 0, 0, yymsp[-2].minor.yy322, yymsp[0].minor.yy4, 0, 0, 0, 0 ); - } - //#line 2444 "parse.c" - break; - case 96: /* tcons ::= CHECK LP expr RP onconf */ - //#line 350 "parse.y" - { - sqlite3AddCheckConstraint( pParse, yymsp[-2].minor.yy118.pExpr ); - } - //#line 2449 "parse.c" - break; - case 97: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */ - //#line 352 "parse.y" - { - sqlite3CreateForeignKey( pParse, yymsp[-6].minor.yy322, yymsp[-3].minor.yy0, yymsp[-2].minor.yy322, yymsp[-1].minor.yy4 ); - sqlite3DeferForeignKey( pParse, yymsp[0].minor.yy4 ); - } - //#line 2457 "parse.c" - break; - case 100: /* onconf ::= */ - //#line 366 "parse.y" - { - yygotominor.yy4 = OE_Default; - } - //#line 2462 "parse.c" - break; - case 102: /* orconf ::= */ - //#line 368 "parse.y" - { - yygotominor.yy210 = OE_Default; - } - //#line 2467 "parse.c" - break; - case 103: /* orconf ::= OR resolvetype */ - //#line 369 "parse.y" - { - yygotominor.yy210 = (u8)yymsp[0].minor.yy4; - } - //#line 2472 "parse.c" - break; - case 105: /* resolvetype ::= IGNORE */ - //#line 371 "parse.y" - { - yygotominor.yy4 = OE_Ignore; - } - //#line 2477 "parse.c" - break; - case 106: /* resolvetype ::= REPLACE */ - //#line 372 "parse.y" - { - yygotominor.yy4 = OE_Replace; - } - //#line 2482 "parse.c" - break; - case 107: /* cmd ::= DROP TABLE ifexists fullname */ - //#line 376 "parse.y" - { - sqlite3DropTable( pParse, yymsp[0].minor.yy259, 0, yymsp[-1].minor.yy4 ); - } - //#line 2489 "parse.c" - break; - case 110: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */ - //#line 386 "parse.y" - { - sqlite3CreateView( pParse, yymsp[-7].minor.yy0, yymsp[-3].minor.yy0, yymsp[-2].minor.yy0, yymsp[0].minor.yy387, yymsp[-6].minor.yy4, yymsp[-4].minor.yy4 ); - } - //#line 2496 "parse.c" - break; - case 111: /* cmd ::= DROP VIEW ifexists fullname */ - //#line 389 "parse.y" - { - sqlite3DropTable( pParse, yymsp[0].minor.yy259, 1, yymsp[-1].minor.yy4 ); - } - //#line 2503 "parse.c" - break; - case 112: /* cmd ::= select */ - //#line 396 "parse.y" - { - SelectDest dest = new SelectDest( SRT_Output, '\0', 0, 0, 0 ); - sqlite3Select( pParse, yymsp[0].minor.yy387, ref dest ); - sqlite3SelectDelete( pParse.db, ref yymsp[0].minor.yy387 ); - } - //#line 2512 "parse.c" - break; - case 113: /* select ::= oneselect */ - //#line 407 "parse.y" - { - yygotominor.yy387 = yymsp[0].minor.yy387; - } - //#line 2517 "parse.c" - break; - case 114: /* select ::= select multiselect_op oneselect */ - //#line 409 "parse.y" - { - if ( yymsp[0].minor.yy387 != null ) - { - yymsp[0].minor.yy387.op = (u8)yymsp[-1].minor.yy4; - yymsp[0].minor.yy387.pPrior = yymsp[-2].minor.yy387; - } - else - { - sqlite3SelectDelete( pParse.db, ref yymsp[-2].minor.yy387 ); - } - yygotominor.yy387 = yymsp[0].minor.yy387; - } - //#line 2530 "parse.c" - break; - case 116: /* multiselect_op ::= UNION ALL */ - //#line 420 "parse.y" - { - yygotominor.yy4 = TK_ALL; - } - //#line 2535 "parse.c" - break; - case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ - //#line 424 "parse.y" - { - yygotominor.yy387 = sqlite3SelectNew( pParse, yymsp[-6].minor.yy322, yymsp[-5].minor.yy259, yymsp[-4].minor.yy314, yymsp[-3].minor.yy322, yymsp[-2].minor.yy314, yymsp[-1].minor.yy322, yymsp[-7].minor.yy4, yymsp[0].minor.yy292.pLimit, yymsp[0].minor.yy292.pOffset ); - } - //#line 2542 "parse.c" - break; - case 122: /* sclp ::= selcollist COMMA */ - case 247: /* idxlist_opt ::= LP idxlist RP */ //yytestcase(yyruleno==247); - //#line 445 "parse.y" - { - yygotominor.yy322 = yymsp[-1].minor.yy322; - } - //#line 2548 "parse.c" - break; - case 123: /* sclp ::= */ - case 151: /* orderby_opt ::= */ //yytestcase(yyruleno==151); - case 159: /* groupby_opt ::= */ //yytestcase(yyruleno==159); - case 240: /* exprlist ::= */ //yytestcase(yyruleno==240); - case 246: /* idxlist_opt ::= */ //yytestcase(yyruleno==246); - //#line 446 "parse.y" - { - yygotominor.yy322 = null; - } - //#line 2557 "parse.c" - break; - case 124: /* selcollist ::= sclp expr as */ - //#line 447 "parse.y" - { - yygotominor.yy322 = sqlite3ExprListAppend( pParse, yymsp[-2].minor.yy322, yymsp[-1].minor.yy118.pExpr ); - if ( yymsp[0].minor.yy0.n > 0 ) - sqlite3ExprListSetName( pParse, yygotominor.yy322, yymsp[0].minor.yy0, 1 ); - sqlite3ExprListSetSpan( pParse, yygotominor.yy322, yymsp[-1].minor.yy118 ); - } - //#line 2566 "parse.c" - break; - case 125: /* selcollist ::= sclp STAR */ - //#line 452 "parse.y" - { - Expr p = sqlite3Expr( pParse.db, TK_ALL, null ); - yygotominor.yy322 = sqlite3ExprListAppend( pParse, yymsp[-1].minor.yy322, p ); - } - //#line 2574 "parse.c" - break; - case 126: /* selcollist ::= sclp nm DOT STAR */ - //#line 456 "parse.y" - { - Expr pRight = sqlite3PExpr( pParse, TK_ALL, 0, 0, yymsp[0].minor.yy0 ); - Expr pLeft = sqlite3PExpr( pParse, TK_ID, 0, 0, yymsp[-2].minor.yy0 ); - Expr pDot = sqlite3PExpr( pParse, TK_DOT, pLeft, pRight, 0 ); - yygotominor.yy322 = sqlite3ExprListAppend( pParse, yymsp[-3].minor.yy322, pDot ); - } - //#line 2584 "parse.c" - break; - case 129: /* as ::= */ - //#line 469 "parse.y" - { - yygotominor.yy0.n = 0; - } - //#line 2589 "parse.c" - break; - case 130: /* from ::= */ - //#line 481 "parse.y" - { - yygotominor.yy259 = new SrcList(); - }//sqlite3DbMallocZero(pParse.db, sizeof(*yygotominor.yy259));} - //#line 2594 "parse.c" - break; - case 131: /* from ::= FROM seltablist */ - //#line 482 "parse.y" - { - yygotominor.yy259 = yymsp[0].minor.yy259; - sqlite3SrcListShiftJoinType( yygotominor.yy259 ); - } - //#line 2602 "parse.c" - break; - case 132: /* stl_prefix ::= seltablist joinop */ - //#line 490 "parse.y" - { - yygotominor.yy259 = yymsp[-1].minor.yy259; - if ( ALWAYS( yygotominor.yy259 != null && yygotominor.yy259.nSrc > 0 ) ) - yygotominor.yy259.a[yygotominor.yy259.nSrc - 1].jointype = (u8)yymsp[0].minor.yy4; - } - //#line 2610 "parse.c" - break; - case 133: /* stl_prefix ::= */ - //#line 494 "parse.y" - { - yygotominor.yy259 = null; - } - //#line 2615 "parse.c" - break; - case 134: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ - //#line 495 "parse.y" - { - yygotominor.yy259 = sqlite3SrcListAppendFromTerm( pParse, yymsp[-6].minor.yy259, yymsp[-5].minor.yy0, yymsp[-4].minor.yy0, yymsp[-3].minor.yy0, 0, yymsp[-1].minor.yy314, yymsp[0].minor.yy384 ); - sqlite3SrcListIndexedBy( pParse, yygotominor.yy259, yymsp[-2].minor.yy0 ); - } - //#line 2623 "parse.c" - break; - case 135: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ - //#line 501 "parse.y" - { - yygotominor.yy259 = sqlite3SrcListAppendFromTerm( pParse, yymsp[-6].minor.yy259, 0, 0, yymsp[-2].minor.yy0, yymsp[-4].minor.yy387, yymsp[-1].minor.yy314, yymsp[0].minor.yy384 ); - } - //#line 2630 "parse.c" - break; - case 136: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ - //#line 505 "parse.y" - { - if ( yymsp[-6].minor.yy259 == null && yymsp[-2].minor.yy0.n == 0 && yymsp[-1].minor.yy314 == null && yymsp[0].minor.yy384 == null ) - { - yygotominor.yy259 = yymsp[-4].minor.yy259; - } - else - { - Select pSubquery; - sqlite3SrcListShiftJoinType( yymsp[-4].minor.yy259 ); - pSubquery = sqlite3SelectNew( pParse, 0, yymsp[-4].minor.yy259, 0, 0, 0, 0, 0, 0, 0 ); - yygotominor.yy259 = sqlite3SrcListAppendFromTerm( pParse, yymsp[-6].minor.yy259, 0, 0, yymsp[-2].minor.yy0, pSubquery, yymsp[-1].minor.yy314, yymsp[0].minor.yy384 ); - } - } - //#line 2644 "parse.c" - break; - case 137: /* dbnm ::= */ - case 146: /* indexed_opt ::= */ //yytestcase(yyruleno==146); - //#line 530 "parse.y" - { - yygotominor.yy0.z = null; - yygotominor.yy0.n = 0; - } - //#line 2650 "parse.c" - break; - case 139: /* fullname ::= nm dbnm */ - //#line 535 "parse.y" - { - yygotominor.yy259 = sqlite3SrcListAppend( pParse.db, 0, yymsp[-1].minor.yy0, yymsp[0].minor.yy0 ); - } - //#line 2655 "parse.c" - break; - case 140: /* joinop ::= COMMA|JOIN */ - //#line 539 "parse.y" - { - yygotominor.yy4 = JT_INNER; - } - //#line 2660 "parse.c" - break; - case 141: /* joinop ::= JOIN_KW JOIN */ - //#line 540 "parse.y" - { - yygotominor.yy4 = sqlite3JoinType( pParse, yymsp[-1].minor.yy0, 0, 0 ); - } - //#line 2665 "parse.c" - break; - case 142: /* joinop ::= JOIN_KW nm JOIN */ - //#line 541 "parse.y" - { - yygotominor.yy4 = sqlite3JoinType( pParse, yymsp[-2].minor.yy0, yymsp[-1].minor.yy0, 0 ); - } - //#line 2670 "parse.c" - break; - case 143: /* joinop ::= JOIN_KW nm nm JOIN */ - //#line 543 "parse.y" - { - yygotominor.yy4 = sqlite3JoinType( pParse, yymsp[-3].minor.yy0, yymsp[-2].minor.yy0, yymsp[-1].minor.yy0 ); - } - //#line 2675 "parse.c" - break; - case 144: /* on_opt ::= ON expr */ - case 155: /* sortitem ::= expr */ //yytestcase(yyruleno==155); - case 162: /* having_opt ::= HAVING expr */ //yytestcase(yyruleno==162); - case 169: /* where_opt ::= WHERE expr */ //yytestcase(yyruleno==169); - case 235: /* case_else ::= ELSE expr */ //yytestcase(yyruleno==235); - case 237: /* case_operand ::= expr */ //yytestcase(yyruleno==237); - //#line 547 "parse.y" - { - yygotominor.yy314 = yymsp[0].minor.yy118.pExpr; - } - //#line 2685 "parse.c" - break; - case 145: /* on_opt ::= */ - case 161: /* having_opt ::= */ //yytestcase(yyruleno==161); - case 168: /* where_opt ::= */ //yytestcase(yyruleno==168); - case 236: /* case_else ::= */ //yytestcase(yyruleno==236); - case 238: /* case_operand ::= */ //yytestcase(yyruleno==238); - //#line 548 "parse.y" - { - yygotominor.yy314 = null; - } - //#line 2694 "parse.c" - break; - case 148: /* indexed_opt ::= NOT INDEXED */ - //#line 563 "parse.y" - { - yygotominor.yy0.z = null; - yygotominor.yy0.n = 1; - } - //#line 2699 "parse.c" - break; - case 149: /* using_opt ::= USING LP inscollist RP */ - case 181: /* inscollist_opt ::= LP inscollist RP */ //yytestcase(yyruleno==181); - //#line 567 "parse.y" - { - yygotominor.yy384 = yymsp[-1].minor.yy384; - } - //#line 2705 "parse.c" - break; - case 150: /* using_opt ::= */ - case 180: /* inscollist_opt ::= */ //yytestcase(yyruleno==180); - //#line 568 "parse.y" - { - yygotominor.yy384 = null; - } - //#line 2711 "parse.c" - break; - case 152: /* orderby_opt ::= ORDER BY sortlist */ - case 160: /* groupby_opt ::= GROUP BY nexprlist */ //yytestcase(yyruleno==160); - case 239: /* exprlist ::= nexprlist */ //yytestcase(yyruleno==239); - //#line 579 "parse.y" - { - yygotominor.yy322 = yymsp[0].minor.yy322; - } - //#line 2718 "parse.c" - break; - case 153: /* sortlist ::= sortlist COMMA sortitem sortorder */ - //#line 580 "parse.y" - { - yygotominor.yy322 = sqlite3ExprListAppend( pParse, yymsp[-3].minor.yy322, yymsp[-1].minor.yy314 ); - if ( yygotominor.yy322 != null ) - yygotominor.yy322.a[yygotominor.yy322.nExpr - 1].sortOrder = (u8)yymsp[0].minor.yy4; - } - //#line 2726 "parse.c" - break; - case 154: /* sortlist ::= sortitem sortorder */ - //#line 584 "parse.y" - { - yygotominor.yy322 = sqlite3ExprListAppend( pParse, 0, yymsp[-1].minor.yy314 ); - if ( yygotominor.yy322 != null && ALWAYS( yygotominor.yy322.a != null ) ) - yygotominor.yy322.a[0].sortOrder = (u8)yymsp[0].minor.yy4; - } - //#line 2734 "parse.c" - break; - case 156: /* sortorder ::= ASC */ - case 158: /* sortorder ::= */ //yytestcase(yyruleno==158); - //#line 592 "parse.y" - { - yygotominor.yy4 = SQLITE_SO_ASC; - } - //#line 2740 "parse.c" - break; - case 157: /* sortorder ::= DESC */ - //#line 593 "parse.y" - { - yygotominor.yy4 = SQLITE_SO_DESC; - } - //#line 2745 "parse.c" - break; - case 163: /* limit_opt ::= */ - //#line 619 "parse.y" - { - yygotominor.yy292.pLimit = null; - yygotominor.yy292.pOffset = null; - } - //#line 2750 "parse.c" - break; - case 164: /* limit_opt ::= LIMIT expr */ - //#line 620 "parse.y" - { - yygotominor.yy292.pLimit = yymsp[0].minor.yy118.pExpr; - yygotominor.yy292.pOffset = null; - } - //#line 2755 "parse.c" - break; - case 165: /* limit_opt ::= LIMIT expr OFFSET expr */ - //#line 622 "parse.y" - { - yygotominor.yy292.pLimit = yymsp[-2].minor.yy118.pExpr; - yygotominor.yy292.pOffset = yymsp[0].minor.yy118.pExpr; - } - //#line 2760 "parse.c" - break; - case 166: /* limit_opt ::= LIMIT expr COMMA expr */ - //#line 624 "parse.y" - { - yygotominor.yy292.pOffset = yymsp[-2].minor.yy118.pExpr; - yygotominor.yy292.pLimit = yymsp[0].minor.yy118.pExpr; - } - //#line 2765 "parse.c" - break; - case 167: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */ - //#line 637 "parse.y" - { - sqlite3SrcListIndexedBy( pParse, yymsp[-2].minor.yy259, yymsp[-1].minor.yy0 ); - sqlite3DeleteFrom( pParse, yymsp[-2].minor.yy259, yymsp[0].minor.yy314 ); - } - //#line 2773 "parse.c" - break; - case 170: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */ - //#line 660 "parse.y" - { - sqlite3SrcListIndexedBy( pParse, yymsp[-4].minor.yy259, yymsp[-3].minor.yy0 ); - sqlite3ExprListCheckLength( pParse, yymsp[-1].minor.yy322, "set list" ); - sqlite3Update( pParse, yymsp[-4].minor.yy259, yymsp[-1].minor.yy322, yymsp[0].minor.yy314, yymsp[-5].minor.yy210 ); - } - //#line 2782 "parse.c" - break; - case 171: /* setlist ::= setlist COMMA nm EQ expr */ - //#line 670 "parse.y" - { - yygotominor.yy322 = sqlite3ExprListAppend( pParse, yymsp[-4].minor.yy322, yymsp[0].minor.yy118.pExpr ); - sqlite3ExprListSetName( pParse, yygotominor.yy322, yymsp[-2].minor.yy0, 1 ); - } - //#line 2790 "parse.c" - break; - case 172: /* setlist ::= nm EQ expr */ - //#line 674 "parse.y" - { - yygotominor.yy322 = sqlite3ExprListAppend( pParse, 0, yymsp[0].minor.yy118.pExpr ); - sqlite3ExprListSetName( pParse, yygotominor.yy322, yymsp[-2].minor.yy0, 1 ); - } - //#line 2798 "parse.c" - break; - case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP */ - //#line 683 "parse.y" - { - sqlite3Insert( pParse, yymsp[-5].minor.yy259, yymsp[-1].minor.yy322, 0, yymsp[-4].minor.yy384, yymsp[-7].minor.yy210 ); - } - //#line 2803 "parse.c" - break; - case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */ - //#line 685 "parse.y" - { - sqlite3Insert( pParse, yymsp[-2].minor.yy259, 0, yymsp[0].minor.yy387, yymsp[-1].minor.yy384, yymsp[-4].minor.yy210 ); - } - //#line 2808 "parse.c" - break; - case 175: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */ - //#line 687 "parse.y" - { - sqlite3Insert( pParse, yymsp[-3].minor.yy259, 0, 0, yymsp[-2].minor.yy384, yymsp[-5].minor.yy210 ); - } - //#line 2813 "parse.c" - break; - case 176: /* insert_cmd ::= INSERT orconf */ - //#line 690 "parse.y" - { - yygotominor.yy210 = yymsp[0].minor.yy210; - } - //#line 2818 "parse.c" - break; - case 177: /* insert_cmd ::= REPLACE */ - //#line 691 "parse.y" - { - yygotominor.yy210 = OE_Replace; - } - //#line 2823 "parse.c" - break; - case 178: /* itemlist ::= itemlist COMMA expr */ - case 241: /* nexprlist ::= nexprlist COMMA expr */ //yytestcase(yyruleno==241); - //#line 698 "parse.y" - { - yygotominor.yy322 = sqlite3ExprListAppend( pParse, yymsp[-2].minor.yy322, yymsp[0].minor.yy118.pExpr ); - } - //#line 2829 "parse.c" - break; - case 179: /* itemlist ::= expr */ - case 242: /* nexprlist ::= expr */ //yytestcase(yyruleno==242); - //#line 700 "parse.y" - { - yygotominor.yy322 = sqlite3ExprListAppend( pParse, 0, yymsp[0].minor.yy118.pExpr ); - } - //#line 2835 "parse.c" - break; - case 182: /* inscollist ::= inscollist COMMA nm */ - //#line 710 "parse.y" - { - yygotominor.yy384 = sqlite3IdListAppend( pParse.db, yymsp[-2].minor.yy384, yymsp[0].minor.yy0 ); - } - //#line 2840 "parse.c" - break; - case 183: /* inscollist ::= nm */ - //#line 712 "parse.y" - { - yygotominor.yy384 = sqlite3IdListAppend( pParse.db, 0, yymsp[0].minor.yy0 ); - } - //#line 2845 "parse.c" - break; - case 184: /* expr ::= term */ - //#line 743 "parse.y" - { - yygotominor.yy118 = yymsp[0].minor.yy118; - } - //#line 2850 "parse.c" - break; - case 185: /* expr ::= LP expr RP */ - //#line 744 "parse.y" - { - yygotominor.yy118.pExpr = yymsp[-1].minor.yy118.pExpr; - spanSet( yygotominor.yy118, yymsp[-2].minor.yy0, yymsp[0].minor.yy0 ); - } - //#line 2855 "parse.c" - break; - case 186: /* term ::= NULL */ - case 191: /* term ::= INTEGER|FLOAT|BLOB */ //yytestcase(yyruleno==191); - case 192: /* term ::= STRING */ //yytestcase(yyruleno==192); - //#line 745 "parse.y" - { - spanExpr( yygotominor.yy118, pParse, yymsp[0].major, yymsp[0].minor.yy0 ); - } - //#line 2862 "parse.c" - break; - case 187: /* expr ::= id */ - case 188: /* expr ::= JOIN_KW */ //yytestcase(yyruleno==188); - //#line 746 "parse.y" - { - spanExpr( yygotominor.yy118, pParse, TK_ID, yymsp[0].minor.yy0 ); - } - //#line 2868 "parse.c" - break; - case 189: /* expr ::= nm DOT nm */ - //#line 748 "parse.y" - { - Expr temp1 = sqlite3PExpr( pParse, TK_ID, 0, 0, yymsp[-2].minor.yy0 ); - Expr temp2 = sqlite3PExpr( pParse, TK_ID, 0, 0, yymsp[0].minor.yy0 ); - yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_DOT, temp1, temp2, 0 ); - spanSet( yygotominor.yy118, yymsp[-2].minor.yy0, yymsp[0].minor.yy0 ); - } - //#line 2878 "parse.c" - break; - case 190: /* expr ::= nm DOT nm DOT nm */ - //#line 754 "parse.y" - { - Expr temp1 = sqlite3PExpr( pParse, TK_ID, 0, 0, yymsp[-4].minor.yy0 ); - Expr temp2 = sqlite3PExpr( pParse, TK_ID, 0, 0, yymsp[-2].minor.yy0 ); - Expr temp3 = sqlite3PExpr( pParse, TK_ID, 0, 0, yymsp[0].minor.yy0 ); - Expr temp4 = sqlite3PExpr( pParse, TK_DOT, temp2, temp3, 0 ); - yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_DOT, temp1, temp4, 0 ); - spanSet( yygotominor.yy118, yymsp[-4].minor.yy0, yymsp[0].minor.yy0 ); - } - //#line 2890 "parse.c" - break; - case 193: /* expr ::= REGISTER */ - //#line 764 "parse.y" - { - /* When doing a nested parse, one can include terms in an expression - ** that look like this: #1 #2 ... These terms refer to registers - ** in the virtual machine. #N is the N-th register. */ - if ( pParse.nested == 0 ) - { - sqlite3ErrorMsg( pParse, "near \"%T\": syntax error", yymsp[0].minor.yy0 ); - yygotominor.yy118.pExpr = null; - } - else - { - yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_REGISTER, 0, 0, yymsp[0].minor.yy0 ); - if ( yygotominor.yy118.pExpr != null ) - sqlite3GetInt32( yymsp[0].minor.yy0.z, 1, ref yygotominor.yy118.pExpr.iTable ); - } - spanSet( yygotominor.yy118, yymsp[0].minor.yy0, yymsp[0].minor.yy0 ); - } - //#line 2907 "parse.c" - break; - case 194: /* expr ::= VARIABLE */ - //#line 777 "parse.y" - { - spanExpr( yygotominor.yy118, pParse, TK_VARIABLE, yymsp[0].minor.yy0 ); - sqlite3ExprAssignVarNumber( pParse, yygotominor.yy118.pExpr ); - spanSet( yygotominor.yy118, yymsp[0].minor.yy0, yymsp[0].minor.yy0 ); - } - //#line 2916 "parse.c" - break; - case 195: /* expr ::= expr COLLATE ids */ - //#line 782 "parse.y" - { - yygotominor.yy118.pExpr = sqlite3ExprSetCollByToken( pParse, yymsp[-2].minor.yy118.pExpr, yymsp[0].minor.yy0 ); - yygotominor.yy118.zStart = yymsp[-2].minor.yy118.zStart; - yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring( yymsp[0].minor.yy0.n );//z[yymsp[0].minor.yy0.n]; - } - //#line 2925 "parse.c" - break; - case 196: /* expr ::= CAST LP expr AS typetoken RP */ - //#line 788 "parse.y" - { - yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_CAST, yymsp[-3].minor.yy118.pExpr, 0, yymsp[-1].minor.yy0 ); - spanSet( yygotominor.yy118, yymsp[-5].minor.yy0, yymsp[0].minor.yy0 ); - } - //#line 2933 "parse.c" - break; - case 197: /* expr ::= ID LP distinct exprlist RP */ - //#line 793 "parse.y" - { - if ( yymsp[-1].minor.yy322 != null && yymsp[-1].minor.yy322.nExpr > pParse.db.aLimit[SQLITE_LIMIT_FUNCTION_ARG] ) - { - sqlite3ErrorMsg( pParse, "too many arguments on function %T", yymsp[-4].minor.yy0 ); - } - yygotominor.yy118.pExpr = sqlite3ExprFunction( pParse, yymsp[-1].minor.yy322, yymsp[-4].minor.yy0 ); - spanSet( yygotominor.yy118, yymsp[-4].minor.yy0, yymsp[0].minor.yy0 ); - if ( yymsp[-2].minor.yy4 != 0 && yygotominor.yy118.pExpr != null ) - { - yygotominor.yy118.pExpr.flags |= EP_Distinct; - } - } - //#line 2947 "parse.c" - break; - case 198: /* expr ::= ID LP STAR RP */ - //#line 803 "parse.y" - { - yygotominor.yy118.pExpr = sqlite3ExprFunction( pParse, 0, yymsp[-3].minor.yy0 ); - spanSet( yygotominor.yy118, yymsp[-3].minor.yy0, yymsp[0].minor.yy0 ); - } - //#line 2955 "parse.c" - break; - case 199: /* term ::= CTIME_KW */ - //#line 807 "parse.y" - { - /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are - ** treated as functions that return constants */ - yygotominor.yy118.pExpr = sqlite3ExprFunction( pParse, 0, yymsp[0].minor.yy0 ); - if ( yygotominor.yy118.pExpr != null ) - { - yygotominor.yy118.pExpr.op = TK_CONST_FUNC; - } - spanSet( yygotominor.yy118, yymsp[0].minor.yy0, yymsp[0].minor.yy0 ); - } - //#line 2968 "parse.c" - break; - case 200: /* expr ::= expr AND expr */ - case 201: /* expr ::= expr OR expr */ //yytestcase(yyruleno==201); - case 202: /* expr ::= expr LT|GT|GE|LE expr */ //yytestcase(yyruleno==202); - case 203: /* expr ::= expr EQ|NE expr */ //yytestcase(yyruleno==203); - case 204: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ //yytestcase(yyruleno==204); - case 205: /* expr ::= expr PLUS|MINUS expr */ //yytestcase(yyruleno==205); - case 206: /* expr ::= expr STAR|SLASH|REM expr */ //yytestcase(yyruleno==206); - case 207: /* expr ::= expr CONCAT expr */ //yytestcase(yyruleno==207); - //#line 834 "parse.y" - { - spanBinaryExpr( yygotominor.yy118, pParse, yymsp[-1].major, yymsp[-2].minor.yy118, yymsp[0].minor.yy118 ); - } - //#line 2980 "parse.c" - break; - case 208: /* likeop ::= LIKE_KW */ - case 210: /* likeop ::= MATCH */ //yytestcase(yyruleno==210); - //#line 847 "parse.y" - { - yygotominor.yy342.eOperator = yymsp[0].minor.yy0; - yygotominor.yy342.not = false; - } - //#line 2986 "parse.c" - break; - case 209: /* likeop ::= NOT LIKE_KW */ - case 211: /* likeop ::= NOT MATCH */ //yytestcase(yyruleno==211); - //#line 848 "parse.y" - { - yygotominor.yy342.eOperator = yymsp[0].minor.yy0; - yygotominor.yy342.not = true; - } - //#line 2992 "parse.c" - break; - case 212: /* expr ::= expr likeop expr */ - //#line 851 "parse.y" - { - ExprList pList; - pList = sqlite3ExprListAppend( pParse, 0, yymsp[0].minor.yy118.pExpr ); - pList = sqlite3ExprListAppend( pParse, pList, yymsp[-2].minor.yy118.pExpr ); - yygotominor.yy118.pExpr = sqlite3ExprFunction( pParse, pList, yymsp[-1].minor.yy342.eOperator ); - if ( yymsp[-1].minor.yy342.not ) - yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0 ); - yygotominor.yy118.zStart = yymsp[-2].minor.yy118.zStart; - yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; - if ( yygotominor.yy118.pExpr != null ) - yygotominor.yy118.pExpr.flags |= EP_InfixFunc; - } - //#line 3006 "parse.c" - break; - case 213: /* expr ::= expr likeop expr ESCAPE expr */ - //#line 861 "parse.y" - { - ExprList pList; - pList = sqlite3ExprListAppend( pParse, 0, yymsp[-2].minor.yy118.pExpr ); - pList = sqlite3ExprListAppend( pParse, pList, yymsp[-4].minor.yy118.pExpr ); - pList = sqlite3ExprListAppend( pParse, pList, yymsp[0].minor.yy118.pExpr ); - yygotominor.yy118.pExpr = sqlite3ExprFunction( pParse, pList, yymsp[-3].minor.yy342.eOperator ); - if ( yymsp[-3].minor.yy342.not ) - yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0 ); - yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; - yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; - if ( yygotominor.yy118.pExpr != null ) - yygotominor.yy118.pExpr.flags |= EP_InfixFunc; - } - //#line 3021 "parse.c" - break; - case 214: /* expr ::= expr ISNULL|NOTNULL */ - //#line 889 "parse.y" - { - spanUnaryPostfix( yygotominor.yy118, pParse, yymsp[0].major, yymsp[-1].minor.yy118, yymsp[0].minor.yy0 ); - } - //#line 3026 "parse.c" - break; - case 215: /* expr ::= expr NOT NULL */ - //#line 890 "parse.y" - { - spanUnaryPostfix( yygotominor.yy118, pParse, TK_NOTNULL, yymsp[-2].minor.yy118, yymsp[0].minor.yy0 ); - } - //#line 3031 "parse.c" - break; - case 216: /* expr ::= expr IS expr */ - //#line 911 "parse.y" - { - spanBinaryExpr( yygotominor.yy118, pParse, TK_IS, yymsp[-2].minor.yy118, yymsp[0].minor.yy118 ); - binaryToUnaryIfNull( pParse, yymsp[0].minor.yy118.pExpr, yygotominor.yy118.pExpr, TK_ISNULL ); - } - //#line 3039 "parse.c" - break; - case 217: /* expr ::= expr IS NOT expr */ - //#line 915 "parse.y" - { - spanBinaryExpr( yygotominor.yy118, pParse, TK_ISNOT, yymsp[-3].minor.yy118, yymsp[0].minor.yy118 ); - binaryToUnaryIfNull( pParse, yymsp[0].minor.yy118.pExpr, yygotominor.yy118.pExpr, TK_NOTNULL ); - } - //#line 3047 "parse.c" - break; - case 218: /* expr ::= NOT expr */ - case 219: /* expr ::= BITNOT expr */ //yytestcase(yyruleno==219); - //#line 938 "parse.y" - { - spanUnaryPrefix( yygotominor.yy118, pParse, yymsp[-1].major, yymsp[0].minor.yy118, yymsp[-1].minor.yy0 ); - } - //#line 3053 "parse.c" - break; - case 220: /* expr ::= MINUS expr */ - //#line 941 "parse.y" - { - spanUnaryPrefix( yygotominor.yy118, pParse, TK_UMINUS, yymsp[0].minor.yy118, yymsp[-1].minor.yy0 ); - } - //#line 3058 "parse.c" - break; - case 221: /* expr ::= PLUS expr */ - //#line 943 "parse.y" - { - spanUnaryPrefix( yygotominor.yy118, pParse, TK_UPLUS, yymsp[0].minor.yy118, yymsp[-1].minor.yy0 ); - } - //#line 3063 "parse.c" - break; - case 224: /* expr ::= expr between_op expr AND expr */ - //#line 948 "parse.y" - { - ExprList pList = sqlite3ExprListAppend( pParse, 0, yymsp[-2].minor.yy118.pExpr ); - pList = sqlite3ExprListAppend( pParse, pList, yymsp[0].minor.yy118.pExpr ); - yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_BETWEEN, yymsp[-4].minor.yy118.pExpr, 0, 0 ); - if ( yygotominor.yy118.pExpr != null ) - { - yygotominor.yy118.pExpr.x.pList = pList; - } - else - { - sqlite3ExprListDelete( pParse.db, ref pList ); - } - if ( yymsp[-3].minor.yy4 != 0 ) - yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0 ); - yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; - yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; - } - //#line 3080 "parse.c" - break; - case 227: /* expr ::= expr in_op LP exprlist RP */ - //#line 965 "parse.y" - { - if ( yymsp[-1].minor.yy322 == null ) - { - /* Expressions of the form - ** - ** expr1 IN () - ** expr1 NOT IN () - ** - ** simplify to constants 0 (false) and 1 (true), respectively, - ** regardless of the value of expr1. - */ - yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_INTEGER, 0, 0, sqlite3IntTokens[yymsp[-3].minor.yy4] ); - sqlite3ExprDelete( pParse.db, ref yymsp[-4].minor.yy118.pExpr ); - } - else - { - yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_IN, yymsp[-4].minor.yy118.pExpr, 0, 0 ); - if ( yygotominor.yy118.pExpr != null ) - { - yygotominor.yy118.pExpr.x.pList = yymsp[-1].minor.yy322; - sqlite3ExprSetHeight( pParse, yygotominor.yy118.pExpr ); - } - else - { - sqlite3ExprListDelete( pParse.db, ref yymsp[-1].minor.yy322 ); - } - if ( yymsp[-3].minor.yy4 != 0 ) - yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0 ); - } - yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; - yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring( yymsp[0].minor.yy0.n );//[yymsp[0].minor.yy0.n]; - } - //#line 3109 "parse.c" - break; - case 228: /* expr ::= LP select RP */ - //#line 990 "parse.y" - { - yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_SELECT, 0, 0, 0 ); - if ( yygotominor.yy118.pExpr != null ) - { - yygotominor.yy118.pExpr.x.pSelect = yymsp[-1].minor.yy387; - ExprSetProperty( yygotominor.yy118.pExpr, EP_xIsSelect ); - sqlite3ExprSetHeight( pParse, yygotominor.yy118.pExpr ); - } - else - { - sqlite3SelectDelete( pParse.db, ref yymsp[-1].minor.yy387 ); - } - yygotominor.yy118.zStart = yymsp[-2].minor.yy0.z; - yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring( yymsp[0].minor.yy0.n );//z[yymsp[0].minor.yy0.n]; - } - //#line 3125 "parse.c" - break; - case 229: /* expr ::= expr in_op LP select RP */ - //#line 1002 "parse.y" - { - yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_IN, yymsp[-4].minor.yy118.pExpr, 0, 0 ); - if ( yygotominor.yy118.pExpr != null ) - { - yygotominor.yy118.pExpr.x.pSelect = yymsp[-1].minor.yy387; - ExprSetProperty( yygotominor.yy118.pExpr, EP_xIsSelect ); - sqlite3ExprSetHeight( pParse, yygotominor.yy118.pExpr ); - } - else - { - sqlite3SelectDelete( pParse.db, ref yymsp[-1].minor.yy387 ); - } - if ( yymsp[-3].minor.yy4 != 0 ) - yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0 ); - yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; - yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring( yymsp[0].minor.yy0.n );//z[yymsp[0].minor.yy0.n]; - } - //#line 3142 "parse.c" - break; - case 230: /* expr ::= expr in_op nm dbnm */ - //#line 1015 "parse.y" - { - SrcList pSrc = sqlite3SrcListAppend( pParse.db, 0, yymsp[-1].minor.yy0, yymsp[0].minor.yy0 ); - yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_IN, yymsp[-3].minor.yy118.pExpr, 0, 0 ); - if ( yygotominor.yy118.pExpr != null ) - { - yygotominor.yy118.pExpr.x.pSelect = sqlite3SelectNew( pParse, 0, pSrc, 0, 0, 0, 0, 0, 0, 0 ); - ExprSetProperty( yygotominor.yy118.pExpr, EP_xIsSelect ); - sqlite3ExprSetHeight( pParse, yygotominor.yy118.pExpr ); - } - else - { - sqlite3SrcListDelete( pParse.db, ref pSrc ); - } - if ( yymsp[-2].minor.yy4 != 0 ) - yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0 ); - yygotominor.yy118.zStart = yymsp[-3].minor.yy118.zStart; - yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z != null ? yymsp[0].minor.yy0.z.Substring( yymsp[0].minor.yy0.n ) : yymsp[-1].minor.yy0.z.Substring( yymsp[-1].minor.yy0.n ); - } - //#line 3160 "parse.c" - break; - case 231: /* expr ::= EXISTS LP select RP */ - //#line 1029 "parse.y" - { - Expr p = yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_EXISTS, 0, 0, 0 ); - if ( p != null ) - { - p.x.pSelect = yymsp[-1].minor.yy387; - ExprSetProperty( p, EP_xIsSelect ); - sqlite3ExprSetHeight( pParse, p ); - } - else - { - sqlite3SelectDelete( pParse.db, ref yymsp[-1].minor.yy387 ); - } - yygotominor.yy118.zStart = yymsp[-3].minor.yy0.z; - yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring( yymsp[0].minor.yy0.n ); //z[yymsp[0].minor.yy0.n]; - } - //#line 3176 "parse.c" - break; - case 232: /* expr ::= CASE case_operand case_exprlist case_else END */ - //#line 1044 "parse.y" - { - yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_CASE, yymsp[-3].minor.yy314, yymsp[-1].minor.yy314, 0 ); - if ( yygotominor.yy118.pExpr != null ) - { - yygotominor.yy118.pExpr.x.pList = yymsp[-2].minor.yy322; - sqlite3ExprSetHeight( pParse, yygotominor.yy118.pExpr ); - } - else - { - sqlite3ExprListDelete( pParse.db, ref yymsp[-2].minor.yy322 ); - } - yygotominor.yy118.zStart = yymsp[-4].minor.yy0.z; - yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring( yymsp[0].minor.yy0.n );//z[yymsp[0].minor.yy0.n]; - } - //#line 3191 "parse.c" - break; - case 233: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ - //#line 1057 "parse.y" - { - yygotominor.yy322 = sqlite3ExprListAppend( pParse, yymsp[-4].minor.yy322, yymsp[-2].minor.yy118.pExpr ); - yygotominor.yy322 = sqlite3ExprListAppend( pParse, yygotominor.yy322, yymsp[0].minor.yy118.pExpr ); - } - //#line 3199 "parse.c" - break; - case 234: /* case_exprlist ::= WHEN expr THEN expr */ - //#line 1061 "parse.y" - { - yygotominor.yy322 = sqlite3ExprListAppend( pParse, 0, yymsp[-2].minor.yy118.pExpr ); - yygotominor.yy322 = sqlite3ExprListAppend( pParse, yygotominor.yy322, yymsp[0].minor.yy118.pExpr ); - } - //#line 3207 "parse.c" - break; - case 243: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */ - //#line 1090 "parse.y" - { - sqlite3CreateIndex( pParse, yymsp[-6].minor.yy0, yymsp[-5].minor.yy0, - sqlite3SrcListAppend( pParse.db, 0, yymsp[-3].minor.yy0, 0 ), yymsp[-1].minor.yy322, yymsp[-9].minor.yy4, - yymsp[-10].minor.yy0, yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy4 ); - } - //#line 3216 "parse.c" - break; - case 244: /* uniqueflag ::= UNIQUE */ - case 298: /* raisetype ::= ABORT */ //yytestcase(yyruleno==298); - //#line 1097 "parse.y" - { - yygotominor.yy4 = OE_Abort; - } - //#line 3222 "parse.c" - break; - case 245: /* uniqueflag ::= */ - //#line 1098 "parse.y" - { - yygotominor.yy4 = OE_None; - } - //#line 3227 "parse.c" - break; - case 248: /* idxlist ::= idxlist COMMA nm collate sortorder */ - //#line 1107 "parse.y" - { - Expr p = null; - if ( yymsp[-1].minor.yy0.n > 0 ) - { - p = sqlite3Expr( pParse.db, TK_COLUMN, null ); - sqlite3ExprSetCollByToken( pParse, p, yymsp[-1].minor.yy0 ); - } - yygotominor.yy322 = sqlite3ExprListAppend( pParse, yymsp[-4].minor.yy322, p ); - sqlite3ExprListSetName( pParse, yygotominor.yy322, yymsp[-2].minor.yy0, 1 ); - sqlite3ExprListCheckLength( pParse, yygotominor.yy322, "index" ); - if ( yygotominor.yy322 != null ) - yygotominor.yy322.a[yygotominor.yy322.nExpr - 1].sortOrder = (u8)yymsp[0].minor.yy4; - } - //#line 3242 "parse.c" - break; - case 249: /* idxlist ::= nm collate sortorder */ - //#line 1118 "parse.y" - { - Expr p = null; - if ( yymsp[-1].minor.yy0.n > 0 ) - { - p = sqlite3PExpr( pParse, TK_COLUMN, 0, 0, 0 ); - sqlite3ExprSetCollByToken( pParse, p, yymsp[-1].minor.yy0 ); - } - yygotominor.yy322 = sqlite3ExprListAppend( pParse, 0, p ); - sqlite3ExprListSetName( pParse, yygotominor.yy322, yymsp[-2].minor.yy0, 1 ); - sqlite3ExprListCheckLength( pParse, yygotominor.yy322, "index" ); - if ( yygotominor.yy322 != null ) - yygotominor.yy322.a[yygotominor.yy322.nExpr - 1].sortOrder = (u8)yymsp[0].minor.yy4; - } - //#line 3257 "parse.c" - break; - case 250: /* collate ::= */ - //#line 1131 "parse.y" - { - yygotominor.yy0.z = null; - yygotominor.yy0.n = 0; - } - //#line 3262 "parse.c" - break; - case 252: /* cmd ::= DROP INDEX ifexists fullname */ - //#line 1137 "parse.y" - { - sqlite3DropIndex( pParse, yymsp[0].minor.yy259, yymsp[-1].minor.yy4 ); - } - //#line 3267 "parse.c" - break; - case 253: /* cmd ::= VACUUM */ - case 254: /* cmd ::= VACUUM nm */ //yytestcase(yyruleno==254); - //#line 1143 "parse.y" - { - sqlite3Vacuum( pParse ); - } - //#line 3273 "parse.c" - break; - case 255: /* cmd ::= PRAGMA nm dbnm */ - //#line 1151 "parse.y" - { - sqlite3Pragma( pParse, yymsp[-1].minor.yy0, yymsp[0].minor.yy0, 0, 0 ); - } - //#line 3278 "parse.c" - break; - case 256: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ - //#line 1152 "parse.y" - { - sqlite3Pragma( pParse, yymsp[-3].minor.yy0, yymsp[-2].minor.yy0, yymsp[0].minor.yy0, 0 ); - } - //#line 3283 "parse.c" - break; - case 257: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ - //#line 1153 "parse.y" - { - sqlite3Pragma( pParse, yymsp[-4].minor.yy0, yymsp[-3].minor.yy0, yymsp[-1].minor.yy0, 0 ); - } - //#line 3288 "parse.c" - break; - case 258: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ - //#line 1155 "parse.y" - { - sqlite3Pragma( pParse, yymsp[-3].minor.yy0, yymsp[-2].minor.yy0, yymsp[0].minor.yy0, 1 ); - } - //#line 3293 "parse.c" - break; - case 259: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ - //#line 1157 "parse.y" - { - sqlite3Pragma( pParse, yymsp[-4].minor.yy0, yymsp[-3].minor.yy0, yymsp[-1].minor.yy0, 1 ); - } - //#line 3298 "parse.c" - break; - case 270: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ - //#line 1175 "parse.y" - { - Token all = new Token(); - //all.z = yymsp[-3].minor.yy0.z; - //all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; - all.n = (int)( yymsp[-3].minor.yy0.z.Length - yymsp[0].minor.yy0.z.Length ) + yymsp[0].minor.yy0.n; - all.z = yymsp[-3].minor.yy0.z.Substring( 0, all.n ); - sqlite3FinishTrigger( pParse, yymsp[-1].minor.yy203, all ); - } - //#line 3308 "parse.c" - break; - case 271: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ - //#line 1184 "parse.y" - { - sqlite3BeginTrigger( pParse, yymsp[-7].minor.yy0, yymsp[-6].minor.yy0, yymsp[-5].minor.yy4, yymsp[-4].minor.yy90.a, yymsp[-4].minor.yy90.b, yymsp[-2].minor.yy259, yymsp[0].minor.yy314, yymsp[-10].minor.yy4, yymsp[-8].minor.yy4 ); - yygotominor.yy0 = ( yymsp[-6].minor.yy0.n == 0 ? yymsp[-7].minor.yy0 : yymsp[-6].minor.yy0 ); - } - //#line 3316 "parse.c" - break; - case 272: /* trigger_time ::= BEFORE */ - case 275: /* trigger_time ::= */ //yytestcase(yyruleno==275); - //#line 1190 "parse.y" - { - yygotominor.yy4 = TK_BEFORE; - } - //#line 3322 "parse.c" - break; - case 273: /* trigger_time ::= AFTER */ - //#line 1191 "parse.y" - { - yygotominor.yy4 = TK_AFTER; - } - //#line 3327 "parse.c" - break; - case 274: /* trigger_time ::= INSTEAD OF */ - //#line 1192 "parse.y" - { - yygotominor.yy4 = TK_INSTEAD; - } - //#line 3332 "parse.c" - break; - case 276: /* trigger_event ::= DELETE|INSERT */ - case 277: /* trigger_event ::= UPDATE */ //yytestcase(yyruleno==277); - //#line 1197 "parse.y" - { - yygotominor.yy90.a = yymsp[0].major; - yygotominor.yy90.b = null; - } - //#line 3338 "parse.c" - break; - case 278: /* trigger_event ::= UPDATE OF inscollist */ - //#line 1199 "parse.y" - { - yygotominor.yy90.a = TK_UPDATE; - yygotominor.yy90.b = yymsp[0].minor.yy384; - } - //#line 3343 "parse.c" - break; - case 281: /* when_clause ::= */ - case 303: /* key_opt ::= */ //yytestcase(yyruleno==303); - //#line 1206 "parse.y" - { - yygotominor.yy314 = null; - } - //#line 3349 "parse.c" - break; - case 282: /* when_clause ::= WHEN expr */ - case 304: /* key_opt ::= KEY expr */ //yytestcase(yyruleno==304); - //#line 1207 "parse.y" - { - yygotominor.yy314 = yymsp[0].minor.yy118.pExpr; - } - //#line 3355 "parse.c" - break; - case 283: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ - //#line 1211 "parse.y" - { - Debug.Assert( yymsp[-2].minor.yy203 != null ); - yymsp[-2].minor.yy203.pLast.pNext = yymsp[-1].minor.yy203; - yymsp[-2].minor.yy203.pLast = yymsp[-1].minor.yy203; - yygotominor.yy203 = yymsp[-2].minor.yy203; - } - //#line 3365 "parse.c" - break; - case 284: /* trigger_cmd_list ::= trigger_cmd SEMI */ - //#line 1217 "parse.y" - { - Debug.Assert( yymsp[-1].minor.yy203 != null ); - yymsp[-1].minor.yy203.pLast = yymsp[-1].minor.yy203; - yygotominor.yy203 = yymsp[-1].minor.yy203; - } - //#line 3374 "parse.c" - break; - case 286: /* trnm ::= nm DOT nm */ - //#line 1229 "parse.y" - { - yygotominor.yy0 = yymsp[0].minor.yy0; - sqlite3ErrorMsg( pParse, - "qualified table names are not allowed on INSERT, UPDATE, and DELETE " + - "statements within triggers" ); - } - //#line 3384 "parse.c" - break; - case 288: /* tridxby ::= INDEXED BY nm */ - //#line 1241 "parse.y" - { - sqlite3ErrorMsg( pParse, - "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " + - "within triggers" ); - } - //#line 3393 "parse.c" - break; - case 289: /* tridxby ::= NOT INDEXED */ - //#line 1246 "parse.y" - { - sqlite3ErrorMsg( pParse, - "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " + - "within triggers" ); - } - //#line 3402 "parse.c" - break; - case 290: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */ - //#line 1259 "parse.y" - { - yygotominor.yy203 = sqlite3TriggerUpdateStep( pParse.db, yymsp[-4].minor.yy0, yymsp[-1].minor.yy322, yymsp[0].minor.yy314, yymsp[-5].minor.yy210 ); - } - //#line 3407 "parse.c" - break; - case 291: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt VALUES LP itemlist RP */ - //#line 1264 "parse.y" - { - yygotominor.yy203 = sqlite3TriggerInsertStep( pParse.db, yymsp[-5].minor.yy0, yymsp[-4].minor.yy384, yymsp[-1].minor.yy322, 0, yymsp[-7].minor.yy210 ); - } - //#line 3412 "parse.c" - break; - case 292: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */ - //#line 1267 "parse.y" - { - yygotominor.yy203 = sqlite3TriggerInsertStep( pParse.db, yymsp[-2].minor.yy0, yymsp[-1].minor.yy384, 0, yymsp[0].minor.yy387, yymsp[-4].minor.yy210 ); - } - //#line 3417 "parse.c" - break; - case 293: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */ - //#line 1271 "parse.y" - { - yygotominor.yy203 = sqlite3TriggerDeleteStep( pParse.db, yymsp[-2].minor.yy0, yymsp[0].minor.yy314 ); - } - //#line 3422 "parse.c" - break; - case 294: /* trigger_cmd ::= select */ - //#line 1274 "parse.y" - { - yygotominor.yy203 = sqlite3TriggerSelectStep( pParse.db, yymsp[0].minor.yy387 ); - } - //#line 3427 "parse.c" - break; - case 295: /* expr ::= RAISE LP IGNORE RP */ - //#line 1277 "parse.y" - { - yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_RAISE, 0, 0, 0 ); - if ( yygotominor.yy118.pExpr != null ) - { - yygotominor.yy118.pExpr.affinity = (char)OE_Ignore; - } - yygotominor.yy118.zStart = yymsp[-3].minor.yy0.z; - yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring( yymsp[0].minor.yy0.n );//z[yymsp[0].minor.yy0.n]; - } - //#line 3439 "parse.c" - break; - case 296: /* expr ::= RAISE LP raisetype COMMA nm RP */ - //#line 1285 "parse.y" - { - yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_RAISE, 0, 0, yymsp[-1].minor.yy0 ); - if ( yygotominor.yy118.pExpr != null ) - { - yygotominor.yy118.pExpr.affinity = (char)yymsp[-3].minor.yy4; - } - yygotominor.yy118.zStart = yymsp[-5].minor.yy0.z; - yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring( yymsp[0].minor.yy0.n );//z[yymsp[0].minor.yy0.n]; - } - //#line 3451 "parse.c" - break; - case 297: /* raisetype ::= ROLLBACK */ - //#line 1296 "parse.y" - { - yygotominor.yy4 = OE_Rollback; - } - //#line 3456 "parse.c" - break; - case 299: /* raisetype ::= FAIL */ - //#line 1298 "parse.y" - { - yygotominor.yy4 = OE_Fail; - } - //#line 3461 "parse.c" - break; - case 300: /* cmd ::= DROP TRIGGER ifexists fullname */ - //#line 1303 "parse.y" - { - sqlite3DropTrigger( pParse, yymsp[0].minor.yy259, yymsp[-1].minor.yy4 ); - } - //#line 3468 "parse.c" - break; - case 301: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ - //#line 1310 "parse.y" - { - sqlite3Attach( pParse, yymsp[-3].minor.yy118.pExpr, yymsp[-1].minor.yy118.pExpr, yymsp[0].minor.yy314 ); - } - //#line 3475 "parse.c" - break; - case 302: /* cmd ::= DETACH database_kw_opt expr */ - //#line 1313 "parse.y" - { - sqlite3Detach( pParse, yymsp[0].minor.yy118.pExpr ); - } - //#line 3482 "parse.c" - break; - case 307: /* cmd ::= REINDEX */ - //#line 1328 "parse.y" - { - sqlite3Reindex( pParse, 0, 0 ); - } - //#line 3487 "parse.c" - break; - case 308: /* cmd ::= REINDEX nm dbnm */ - //#line 1329 "parse.y" - { - sqlite3Reindex( pParse, yymsp[-1].minor.yy0, yymsp[0].minor.yy0 ); - } - //#line 3492 "parse.c" - break; - case 309: /* cmd ::= ANALYZE */ - //#line 1334 "parse.y" - { - sqlite3Analyze( pParse, 0, 0 ); - } - //#line 3497 "parse.c" - break; - case 310: /* cmd ::= ANALYZE nm dbnm */ - //#line 1335 "parse.y" - { - sqlite3Analyze( pParse, yymsp[-1].minor.yy0, yymsp[0].minor.yy0 ); - } - //#line 3502 "parse.c" - break; - case 311: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ - //#line 1340 "parse.y" - { - sqlite3AlterRenameTable( pParse, yymsp[-3].minor.yy259, yymsp[0].minor.yy0 ); - } - //#line 3509 "parse.c" - break; - case 312: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */ - //#line 1343 "parse.y" - { - sqlite3AlterFinishAddColumn( pParse, yymsp[0].minor.yy0 ); - } - //#line 3516 "parse.c" - break; - case 313: /* add_column_fullname ::= fullname */ - //#line 1346 "parse.y" - { - pParse.db.lookaside.bEnabled = 0; - sqlite3AlterBeginAddColumn( pParse, yymsp[0].minor.yy259 ); - } - //#line 3524 "parse.c" - break; - case 316: /* cmd ::= create_vtab */ - //#line 1356 "parse.y" - { - sqlite3VtabFinishParse( pParse, (Token)null ); - } - //#line 3529 "parse.c" - break; - case 317: /* cmd ::= create_vtab LP vtabarglist RP */ - //#line 1357 "parse.y" - { - sqlite3VtabFinishParse( pParse, yymsp[0].minor.yy0 ); - } - //#line 3534 "parse.c" - break; - case 318: /* create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm */ - //#line 1358 "parse.y" - { - sqlite3VtabBeginParse( pParse, yymsp[-3].minor.yy0, yymsp[-2].minor.yy0, yymsp[0].minor.yy0 ); - } - //#line 3541 "parse.c" - break; - case 321: /* vtabarg ::= */ - //#line 1363 "parse.y" - { - sqlite3VtabArgInit( pParse ); - } - //#line 3546 "parse.c" - break; - case 323: /* vtabargtoken ::= ANY */ - case 324: /* vtabargtoken ::= lp anylist RP */ //yytestcase(yyruleno==324); - case 325: /* lp ::= LP */ //yytestcase(yyruleno==325); - //#line 1365 "parse.y" - { - sqlite3VtabArgExtend( pParse, yymsp[0].minor.yy0 ); - } - //#line 3553 "parse.c" - break; - default: - /* (0) input ::= cmdlist */ - //yytestcase(yyruleno==0); - /* (1) cmdlist ::= cmdlist ecmd */ - //yytestcase(yyruleno==1); - /* (2) cmdlist ::= ecmd */ - //yytestcase(yyruleno==2); - /* (3) ecmd ::= SEMI */ - //yytestcase(yyruleno==3); - /* (4) ecmd ::= explain cmdx SEMI */ - //yytestcase(yyruleno==4); - /* (10) trans_opt ::= */ - //yytestcase(yyruleno==10); - /* (11) trans_opt ::= TRANSACTION */ - //yytestcase(yyruleno==11); - /* (12) trans_opt ::= TRANSACTION nm */ - //yytestcase(yyruleno==12); - /* (20) savepoint_opt ::= SAVEPOINT */ - //yytestcase(yyruleno==20); - /* (21) savepoint_opt ::= */ - //yytestcase(yyruleno==21); - /* (25) cmd ::= create_table create_table_args */ - //yytestcase(yyruleno==25); - /* (34) columnlist ::= columnlist COMMA column */ - //yytestcase(yyruleno==34); - /* (35) columnlist ::= column */ - //yytestcase(yyruleno==35); - /* (44) type ::= */ - //yytestcase(yyruleno==44); - /* (51) signed ::= plus_num */ - //yytestcase(yyruleno==51); - /* (52) signed ::= minus_num */ - //yytestcase(yyruleno==52); - /* (53) carglist ::= carglist carg */ - //yytestcase(yyruleno==53); - /* (54) carglist ::= */ - //yytestcase(yyruleno==54); - /* (55) carg ::= CONSTRAINT nm ccons */ - //yytestcase(yyruleno==55); - /* (56) carg ::= ccons */ - //yytestcase(yyruleno==56); - /* (62) ccons ::= NULL onconf */ - //yytestcase(yyruleno==62); - /* (90) conslist ::= conslist COMMA tcons */ - //yytestcase(yyruleno==90); - /* (91) conslist ::= conslist tcons */ - //yytestcase(yyruleno==91); - /* (92) conslist ::= tcons */ - //yytestcase(yyruleno==92); - /* (93) tcons ::= CONSTRAINT nm */ - //yytestcase(yyruleno==93); - /* (268) plus_opt ::= PLUS */ - //yytestcase(yyruleno==268); - /* (269) plus_opt ::= */ - //yytestcase(yyruleno==269); - /* (279) foreach_clause ::= */ - //yytestcase(yyruleno==279); - /* (280) foreach_clause ::= FOR EACH ROW */ - //yytestcase(yyruleno==280); - /* (287) tridxby ::= */ - //yytestcase(yyruleno==287); - /* (305) database_kw_opt ::= DATABASE */ - //yytestcase(yyruleno==305); - /* (306) database_kw_opt ::= */ - //yytestcase(yyruleno==306); - /* (314) kwcolumn_opt ::= */ - //yytestcase(yyruleno==314); - /* (315) kwcolumn_opt ::= COLUMNKW */ - //yytestcase(yyruleno==315); - /* (319) vtabarglist ::= vtabarg */ - //yytestcase(yyruleno==319); - /* (320) vtabarglist ::= vtabarglist COMMA vtabarg */ - //yytestcase(yyruleno==320); - /* (322) vtabarg ::= vtabarg vtabargtoken */ - //yytestcase(yyruleno==322); - /* (326) anylist ::= */ - //yytestcase(yyruleno==326); - /* (327) anylist ::= anylist LP anylist RP */ - //yytestcase(yyruleno==327); - /* (328) anylist ::= anylist ANY */ - //yytestcase(yyruleno==328); - break; - }; - yygoto = yyRuleInfo[yyruleno].lhs; - yysize = yyRuleInfo[yyruleno].nrhs; - yypParser.yyidx -= yysize; - yyact = yy_find_reduce_action( yymsp[-yysize].stateno, (YYCODETYPE)yygoto ); - if ( yyact < YYNSTATE ) - { + /* Silence complaints from purify about yygotominor being uninitialized + ** in some cases when it is copied into the stack after the following + ** switch. yygotominor is uninitialized when a rule reduces that does + ** not set the value of its left-hand side nonterminal. Leaving the + ** value of the nonterminal uninitialized is utterly harmless as long + ** as the value is never used. So really the only thing this code + ** accomplishes is to quieten purify. + ** + ** 2007-01-16: The wireshark project (www.wireshark.org) reports that + ** without this code, their parser segfaults. I'm not sure what there + ** parser is doing to make this happen. This is the second bug report + ** from wireshark this week. Clearly they are stressing Lemon in ways + ** that it has not been previously stressed... (SQLite ticket #2172) + */ + yygotominor = new YYMINORTYPE(); //memset(yygotominor, 0, yygotominor).Length; + switch (yyruleno) { + /* Beginning here are the reduction cases. A typical example + ** follows: + ** case 0: + ** //#line + ** { ... } // User supplied code + ** //#line + ** break; + */ + case 5: /* explain ::= */ + //#line 107 "parse.y" + { + sqlite3BeginParse(pParse, 0); + } + //#line 2107 "parse.c" + break; + case 6: /* explain ::= EXPLAIN */ + //#line 109 "parse.y" + { + sqlite3BeginParse(pParse, 1); + } + //#line 2112 "parse.c" + break; + case 7: /* explain ::= EXPLAIN QUERY PLAN */ + //#line 110 "parse.y" + { + sqlite3BeginParse(pParse, 2); + } + //#line 2117 "parse.c" + break; + case 8: /* cmdx ::= cmd */ + //#line 112 "parse.y" + { + sqlite3FinishCoding(pParse); + } + //#line 2122 "parse.c" + break; + case 9: /* cmd ::= BEGIN transtype trans_opt */ + //#line 117 "parse.y" + { + sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy4); + } + //#line 2127 "parse.c" + break; + case 13: /* transtype ::= */ + //#line 122 "parse.y" + { + yygotominor.yy4 = TK_DEFERRED; + } + //#line 2132 "parse.c" + break; + case 14: /* transtype ::= DEFERRED */ + case 15: /* transtype ::= IMMEDIATE */ //yytestcase(yyruleno==15); + case 16: /* transtype ::= EXCLUSIVE */ //yytestcase(yyruleno==16); + case 115: /* multiselect_op ::= UNION */ //yytestcase(yyruleno==114); + case 117: /* multiselect_op ::= EXCEPT|INTERSECT */ //yytestcase(yyruleno==116); + //#line 123 "parse.y" + { + yygotominor.yy4 = yymsp[0].major; + } + //#line 2141 "parse.c" + break; + case 17: /* cmd ::= COMMIT trans_opt */ + case 18: /* cmd ::= END trans_opt */ //yytestcase(yyruleno==18); + //#line 126 "parse.y" + { + sqlite3CommitTransaction(pParse); + } + //#line 2147 "parse.c" + break; + case 19: /* cmd ::= ROLLBACK trans_opt */ + //#line 128 "parse.y" + { + sqlite3RollbackTransaction(pParse); + } + //#line 2152 "parse.c" + break; + case 22: /* cmd ::= SAVEPOINT nm */ + //#line 132 "parse.y" + { + sqlite3Savepoint(pParse, SAVEPOINT_BEGIN, yymsp[0].minor.yy0); + } + //#line 2159 "parse.c" + break; + case 23: /* cmd ::= RELEASE savepoint_opt nm */ + //#line 135 "parse.y" + { + sqlite3Savepoint(pParse, SAVEPOINT_RELEASE, yymsp[0].minor.yy0); + } + //#line 2166 "parse.c" + break; + case 24: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ + //#line 138 "parse.y" + { + sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, yymsp[0].minor.yy0); + } + //#line 2173 "parse.c" + break; + case 26: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ + //#line 145 "parse.y" + { + sqlite3StartTable(pParse, yymsp[-1].minor.yy0, yymsp[0].minor.yy0, yymsp[-4].minor.yy4, 0, 0, yymsp[-2].minor.yy4); + } + //#line 2180 "parse.c" + break; + case 27: /* createkw ::= CREATE */ + //#line 148 "parse.y" + { + pParse.db.lookaside.bEnabled = 0; + yygotominor.yy0 = yymsp[0].minor.yy0; + } + //#line 2188 "parse.c" + break; + case 28: /* ifnotexists ::= */ + case 31: /* temp ::= */ //yytestcase(yyruleno == 31); + case 70: /* autoinc ::= */ //yytestcase(yyruleno == 70); + case 83: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ //yytestcase(yyruleno == 83); + case 85: /* init_deferred_pred_opt ::= */ //yytestcase(yyruleno == 85); + case 87: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ //yytestcase(yyruleno == 87); + case 98: /* defer_subclause_opt ::= */ //yytestcase(yyruleno == 98); + case 109: /* ifexists ::= */ //yytestcase(yyruleno == 109); + case 120: /* distinct ::= ALL */ //yytestcase(yyruleno == 120); + case 121: /* distinct ::= */ //yytestcase(yyruleno == 121); + case 222: /* between_op ::= BETWEEN */ //yytestcase(yyruleno == 223); + case 225: /* in_op ::= IN */ //yytestcase(yyruleno == 226); + //#line 153 "parse.y" + { + yygotominor.yy4 = 0; + } + //#line 2204 "parse.c" + break; + case 29: /* ifnotexists ::= IF NOT EXISTS */ + case 30: /* temp ::= TEMP */ //yytestcase(yyruleno == 30); + case 71: /* autoinc ::= AUTOINCR */ //yytestcase(yyruleno == 71); + case 86: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ //yytestcase(yyruleno == 86); + case 108: /* ifexists ::= IF EXISTS */ //yytestcase(yyruleno == 108); + case 119: /* distinct ::= DISTINCT */ //yytestcase(yyruleno == 119); + case 223: /* between_op ::= NOT BETWEEN */ //yytestcase(yyruleno == 224); + case 226: /* in_op ::= NOT IN */ //yytestcase(yyruleno == 227); + //#line 154 "parse.y" + { + yygotominor.yy4 = 1; + } + //#line 2216 "parse.c" + break; + case 32: /* create_table_args ::= LP columnlist conslist_opt RP */ + //#line 160 "parse.y" + { + sqlite3EndTable(pParse, yymsp[-1].minor.yy0, yymsp[0].minor.yy0, 0); + } + //#line 2223 "parse.c" + break; + case 33: /* create_table_args ::= AS select */ + //#line 163 "parse.y" + { + sqlite3EndTable(pParse, 0, 0, yymsp[0].minor.yy387); + sqlite3SelectDelete(pParse.db, ref yymsp[0].minor.yy387); + } + //#line 2231 "parse.c" + break; + case 36: /* column ::= columnid type carglist */ + //#line 175 "parse.y" + { + //yygotominor.yy0.z = yymsp[-2].minor.yy0.z; + //yygotominor.yy0.n = (int)( pParse.sLastToken.z - yymsp[-2].minor.yy0.z ) + pParse.sLastToken.n; + yygotominor.yy0.n = (int)(yymsp[-2].minor.yy0.z.Length - pParse.sLastToken.z.Length) + pParse.sLastToken.n; + yygotominor.yy0.z = yymsp[-2].minor.yy0.z.Substring(0, yygotominor.yy0.n); + } + //#line 2239 "parse.c" + break; + case 37: /* columnid ::= nm */ + //#line 179 "parse.y" + { + sqlite3AddColumn(pParse, yymsp[0].minor.yy0); + yygotominor.yy0 = yymsp[0].minor.yy0; + } + //#line 2247 "parse.c" + break; + case 38: /* id ::= ID */ + case 39: /* id ::= INDEXED */ //yytestcase(yyruleno==39); + case 40: /* ids ::= ID|STRING */ //yytestcase(yyruleno==40); + case 41: /* nm ::= id */ //yytestcase(yyruleno==41); + case 42: /* nm ::= STRING */ //yytestcase(yyruleno==42); + case 43: /* nm ::= JOIN_KW */ //yytestcase(yyruleno==43); + case 46: /* typetoken ::= typename */ //yytestcase(yyruleno==46); + case 49: /* typename ::= ids */ //yytestcase(yyruleno==49); + case 127: /* as ::= AS nm */ ////yytestcase(yyruleno == 127); + case 128: /* as ::= ids */ ////yytestcase(yyruleno == 128); + case 138: /* dbnm ::= DOT nm */ ////yytestcase(yyruleno == 138); + case 147: /* indexed_opt ::= INDEXED BY nm */ ////yytestcase(yyruleno == 147); + case 251: /* collate ::= COLLATE ids */ //testcase(yyruleno == 251); + case 260: /* nmnum ::= plus_num */ //testcase(yyruleno == 260); + case 261: /* nmnum ::= nm */ //testcase(yyruleno == 261); + case 262: /* nmnum ::= ON */ //testcase(yyruleno == 262); + case 263: /* nmnum ::= DELETE */ //testcase(yyruleno == 263); + case 264: /* nmnum ::= DEFAULT */ //testcase(yyruleno == 264); + case 265: /* plus_num ::= plus_opt number */ //testcase(yyruleno == 265); + case 266: /* minus_num ::= MINUS number */ //testcase(yyruleno == 266); + case 267: /* number ::= INTEGER|FLOAT */ //testcase(yyruleno == 267); + case 285: /* trnm ::= nm */ //testcase(yyruleno == 285); + //#line 189 "parse.y" + { + yygotominor.yy0 = yymsp[0].minor.yy0; + } + //#line 2273 "parse.c" + break; + case 45: /* type ::= typetoken */ + //#line 251 "parse.y" + { + sqlite3AddColumnType(pParse, yymsp[0].minor.yy0); + } + //#line 2278 "parse.c" + break; + case 47: /* typetoken ::= typename LP signed RP */ + //#line 253 "parse.y" + { + //yygotominor.yy0.z = yymsp[-3].minor.yy0.z; + //yygotominor.yy0.n = (int)( &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z ); + yygotominor.yy0.n = yymsp[-3].minor.yy0.z.Length - yymsp[0].minor.yy0.z.Length + yymsp[0].minor.yy0.n; + yygotominor.yy0.z = yymsp[-3].minor.yy0.z.Substring(0, yygotominor.yy0.n); + } + //#line 2286 "parse.c" + break; + case 48: /* typetoken ::= typename LP signed COMMA signed RP */ + //#line 257 "parse.y" + { + //yygotominor.yy0.z = yymsp[-5].minor.yy0.z; + //yygotominor.yy0.n = (int)( &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z ); + yygotominor.yy0.n = yymsp[-5].minor.yy0.z.Length - yymsp[0].minor.yy0.z.Length + 1; + yygotominor.yy0.z = yymsp[-5].minor.yy0.z.Substring(0, yygotominor.yy0.n); + } + //#line 2294 "parse.c" + break; + case 50: /* typename ::= typename ids */ + //#line 263 "parse.y" + { + //yygotominor.yy0.z=yymsp[-1].minor.yy0.z; yygotominor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z); + yygotominor.yy0.z = yymsp[-1].minor.yy0.z; + yygotominor.yy0.n = yymsp[0].minor.yy0.n + (int)(yymsp[-1].minor.yy0.z.Length - yymsp[0].minor.yy0.z.Length); + } + //#line 2299 "parse.c" + break; + case 57: /* ccons ::= DEFAULT term */ + case 59: /* ccons ::= DEFAULT PLUS term */ //yytestcase(yyruleno==59); + //#line 274 "parse.y" + { + sqlite3AddDefaultValue(pParse, yymsp[0].minor.yy118); + } + //#line 2308 "parse.c" + break; + case 58: /* ccons ::= DEFAULT LP expr RP */ + //#line 275 "parse.y" + { + sqlite3AddDefaultValue(pParse, yymsp[-1].minor.yy118); + } + //#line 2310 "parse.c" + break; + case 60: /* ccons ::= DEFAULT MINUS term */ + //#line 277 "parse.y" + { + ExprSpan v = new ExprSpan(); + v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy118.pExpr, 0, 0); + v.zStart = yymsp[-1].minor.yy0.z; + v.zEnd = yymsp[0].minor.yy118.zEnd; + sqlite3AddDefaultValue(pParse, v); + } + //#line 2321 "parse.c" + break; + case 61: /* ccons ::= DEFAULT id */ + //#line 284 "parse.y" + { + ExprSpan v = new ExprSpan(); + spanExpr(v, pParse, TK_STRING, yymsp[0].minor.yy0); + sqlite3AddDefaultValue(pParse, v); + } + //#line 2330 "parse.c" + break; + case 63: /* ccons ::= NOT NULL onconf */ + //#line 294 "parse.y" + { + sqlite3AddNotNull(pParse, yymsp[0].minor.yy4); + } + //#line 2335 "parse.c" + break; + case 64: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ + //#line 296 "parse.y" + { + sqlite3AddPrimaryKey(pParse, 0, yymsp[-1].minor.yy4, yymsp[0].minor.yy4, yymsp[-2].minor.yy4); + } + //#line 2340 "parse.c" + break; + case 65: /* ccons ::= UNIQUE onconf */ + //#line 297 "parse.y" + { + sqlite3CreateIndex(pParse, 0, 0, 0, 0, yymsp[0].minor.yy4, 0, 0, 0, 0); + } + //#line 2345 "parse.c" + break; + case 66: /* ccons ::= CHECK LP expr RP */ + //#line 298 "parse.y" + { + sqlite3AddCheckConstraint(pParse, yymsp[-1].minor.yy118.pExpr); + } + //#line 2350 "parse.c" + break; + case 67: /* ccons ::= REFERENCES nm idxlist_opt refargs */ + //#line 300 "parse.y" + { + sqlite3CreateForeignKey(pParse, 0, yymsp[-2].minor.yy0, yymsp[-1].minor.yy322, yymsp[0].minor.yy4); + } + //#line 2355 "parse.c" + break; + case 68: /* ccons ::= defer_subclause */ + //#line 301 "parse.y" + { + sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy4); + } + //#line 2360 "parse.c" + break; + case 69: /* ccons ::= COLLATE ids */ + //#line 302 "parse.y" + { + sqlite3AddCollateType(pParse, yymsp[0].minor.yy0); + } + //#line 2365 "parse.c" + break; + case 72: /* refargs ::= */ + //#line 315 "parse.y" + { + yygotominor.yy4 = OE_None * 0x0101; /* EV: R-19803-45884 */ + } + //#line 2370 "parse.c" + break; + case 73: /* refargs ::= refargs refarg */ + //#line 316 "parse.y" + { + yygotominor.yy4 = (yymsp[-1].minor.yy4 & ~yymsp[0].minor.yy215.mask) | yymsp[0].minor.yy215.value; + } + //#line 2375 "parse.c" + break; + case 74: /* refarg ::= MATCH nm */ + case 75: /* refarg ::= ON INSERT refact */ //yytestcase(yyruleno==75); + //#line 318 "parse.y" + { + yygotominor.yy215.value = 0; + yygotominor.yy215.mask = 0x000000; + } + //#line 2381 "parse.c" + break; + case 76: /* refarg ::= ON DELETE refact */ + //#line 320 "parse.y" + { + yygotominor.yy215.value = yymsp[0].minor.yy4; + yygotominor.yy215.mask = 0x0000ff; + } + //#line 2386 "parse.c" + break; + case 77: /* refarg ::= ON UPDATE refact */ + //#line 321 "parse.y" + { + yygotominor.yy215.value = yymsp[0].minor.yy4 << 8; + yygotominor.yy215.mask = 0x00ff00; + } + //#line 2391 "parse.c" + break; + case 78: /* refact ::= SET NULL */ + //#line 323 "parse.y" + { + yygotominor.yy4 = OE_SetNull; /* EV: R-33326-45252 */ + } + //#line 2396 "parse.c" + break; + case 79: /* refact ::= SET DEFAULT */ + //#line 324 "parse.y" + { + yygotominor.yy4 = OE_SetDflt; /* EV: R-33326-45252 */ + } + //#line 2401 "parse.c" + break; + case 80: /* refact ::= CASCADE */ + //#line 325 "parse.y" + { + yygotominor.yy4 = OE_Cascade; /* EV: R-33326-45252 */ + } + //#line 2406 "parse.c" + break; + case 81: /* refact ::= RESTRICT */ + //#line 326 "parse.y" + { + yygotominor.yy4 = OE_Restrict; /* EV: R-33326-45252 */ + } + //#line 2411 "parse.c" + break; + case 82: /* refact ::= NO ACTION */ + //#line 327 "parse.y" + { + yygotominor.yy4 = OE_None; /* EV: R-33326-45252 */ + } + //#line 2416 "parse.c" + break; + case 84: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ + case 99: /* defer_subclause_opt ::= defer_subclause */ //yytestcase(yyruleno==99); + case 101: /* onconf ::= ON CONFLICT resolvetype */ //yytestcase(yyruleno==101); + case 104: /* resolvetype ::= raisetype */ //yytestcase(yyruleno==104); + //#line 330 "parse.y" + { + yygotominor.yy4 = yymsp[0].minor.yy4; + } + //#line 2424 "parse.c" + break; + case 88: /* conslist_opt ::= */ + //#line 339 "parse.y" + { + yygotominor.yy0.n = 0; + yygotominor.yy0.z = null; + } + //#line 2429 "parse.c" + break; + case 89: /* conslist_opt ::= COMMA conslist */ + //#line 340 "parse.y" + { + yygotominor.yy0 = yymsp[-1].minor.yy0; + } + //#line 2434 "parse.c" + break; + case 94: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */ + //#line 346 "parse.y" + { + sqlite3AddPrimaryKey(pParse, yymsp[-3].minor.yy322, yymsp[0].minor.yy4, yymsp[-2].minor.yy4, 0); + } + //#line 2439 "parse.c" + break; + case 95: /* tcons ::= UNIQUE LP idxlist RP onconf */ + //#line 348 "parse.y" + { + sqlite3CreateIndex(pParse, 0, 0, 0, yymsp[-2].minor.yy322, yymsp[0].minor.yy4, 0, 0, 0, 0); + } + //#line 2444 "parse.c" + break; + case 96: /* tcons ::= CHECK LP expr RP onconf */ + //#line 350 "parse.y" + { + sqlite3AddCheckConstraint(pParse, yymsp[-2].minor.yy118.pExpr); + } + //#line 2449 "parse.c" + break; + case 97: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */ + //#line 352 "parse.y" + { + sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy322, yymsp[-3].minor.yy0, yymsp[-2].minor.yy322, yymsp[-1].minor.yy4); + sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy4); + } + //#line 2457 "parse.c" + break; + case 100: /* onconf ::= */ + //#line 366 "parse.y" + { + yygotominor.yy4 = OE_Default; + } + //#line 2462 "parse.c" + break; + case 102: /* orconf ::= */ + //#line 368 "parse.y" + { + yygotominor.yy210 = OE_Default; + } + //#line 2467 "parse.c" + break; + case 103: /* orconf ::= OR resolvetype */ + //#line 369 "parse.y" + { + yygotominor.yy210 = (u8)yymsp[0].minor.yy4; + } + //#line 2472 "parse.c" + break; + case 105: /* resolvetype ::= IGNORE */ + //#line 371 "parse.y" + { + yygotominor.yy4 = OE_Ignore; + } + //#line 2477 "parse.c" + break; + case 106: /* resolvetype ::= REPLACE */ + //#line 372 "parse.y" + { + yygotominor.yy4 = OE_Replace; + } + //#line 2482 "parse.c" + break; + case 107: /* cmd ::= DROP TABLE ifexists fullname */ + //#line 376 "parse.y" + { + sqlite3DropTable(pParse, yymsp[0].minor.yy259, 0, yymsp[-1].minor.yy4); + } + //#line 2489 "parse.c" + break; + case 110: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */ + //#line 386 "parse.y" + { + sqlite3CreateView(pParse, yymsp[-7].minor.yy0, yymsp[-3].minor.yy0, yymsp[-2].minor.yy0, yymsp[0].minor.yy387, yymsp[-6].minor.yy4, yymsp[-4].minor.yy4); + } + //#line 2496 "parse.c" + break; + case 111: /* cmd ::= DROP VIEW ifexists fullname */ + //#line 389 "parse.y" + { + sqlite3DropTable(pParse, yymsp[0].minor.yy259, 1, yymsp[-1].minor.yy4); + } + //#line 2503 "parse.c" + break; + case 112: /* cmd ::= select */ + //#line 396 "parse.y" + { + SelectDest dest = new SelectDest(SRT_Output, '\0', 0, 0, 0); + sqlite3Select(pParse, yymsp[0].minor.yy387, ref dest); + sqlite3SelectDelete(pParse.db, ref yymsp[0].minor.yy387); + } + //#line 2512 "parse.c" + break; + case 113: /* select ::= oneselect */ + //#line 407 "parse.y" + { + yygotominor.yy387 = yymsp[0].minor.yy387; + } + //#line 2517 "parse.c" + break; + case 114: /* select ::= select multiselect_op oneselect */ + //#line 409 "parse.y" + { + if (yymsp[0].minor.yy387 != null) { + yymsp[0].minor.yy387.op = (u8)yymsp[-1].minor.yy4; + yymsp[0].minor.yy387.pPrior = yymsp[-2].minor.yy387; + } else { + sqlite3SelectDelete(pParse.db, ref yymsp[-2].minor.yy387); + } + yygotominor.yy387 = yymsp[0].minor.yy387; + } + //#line 2530 "parse.c" + break; + case 116: /* multiselect_op ::= UNION ALL */ + //#line 420 "parse.y" + { + yygotominor.yy4 = TK_ALL; + } + //#line 2535 "parse.c" + break; + case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ + //#line 424 "parse.y" + { + yygotominor.yy387 = sqlite3SelectNew(pParse, yymsp[-6].minor.yy322, yymsp[-5].minor.yy259, yymsp[-4].minor.yy314, yymsp[-3].minor.yy322, yymsp[-2].minor.yy314, yymsp[-1].minor.yy322, yymsp[-7].minor.yy4, yymsp[0].minor.yy292.pLimit, yymsp[0].minor.yy292.pOffset); + } + //#line 2542 "parse.c" + break; + case 122: /* sclp ::= selcollist COMMA */ + case 247: /* idxlist_opt ::= LP idxlist RP */ //yytestcase(yyruleno==247); + //#line 445 "parse.y" + { + yygotominor.yy322 = yymsp[-1].minor.yy322; + } + //#line 2548 "parse.c" + break; + case 123: /* sclp ::= */ + case 151: /* orderby_opt ::= */ //yytestcase(yyruleno==151); + case 159: /* groupby_opt ::= */ //yytestcase(yyruleno==159); + case 240: /* exprlist ::= */ //yytestcase(yyruleno==240); + case 246: /* idxlist_opt ::= */ //yytestcase(yyruleno==246); + //#line 446 "parse.y" + { + yygotominor.yy322 = null; + } + //#line 2557 "parse.c" + break; + case 124: /* selcollist ::= sclp expr as */ + //#line 447 "parse.y" + { + yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy322, yymsp[-1].minor.yy118.pExpr); + if (yymsp[0].minor.yy0.n > 0) + sqlite3ExprListSetName(pParse, yygotominor.yy322, yymsp[0].minor.yy0, 1); + sqlite3ExprListSetSpan(pParse, yygotominor.yy322, yymsp[-1].minor.yy118); + } + //#line 2566 "parse.c" + break; + case 125: /* selcollist ::= sclp STAR */ + //#line 452 "parse.y" + { + Expr p = sqlite3Expr(pParse.db, TK_ALL, null); + yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy322, p); + } + //#line 2574 "parse.c" + break; + case 126: /* selcollist ::= sclp nm DOT STAR */ + //#line 456 "parse.y" + { + Expr pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, yymsp[0].minor.yy0); + Expr pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, yymsp[-2].minor.yy0); + Expr pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0); + yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy322, pDot); + } + //#line 2584 "parse.c" + break; + case 129: /* as ::= */ + //#line 469 "parse.y" + { + yygotominor.yy0.n = 0; + } + //#line 2589 "parse.c" + break; + case 130: /* from ::= */ + //#line 481 "parse.y" + { + yygotominor.yy259 = new SrcList(); + }//sqlite3DbMallocZero(pParse.db, sizeof(*yygotominor.yy259));} + //#line 2594 "parse.c" + break; + case 131: /* from ::= FROM seltablist */ + //#line 482 "parse.y" + { + yygotominor.yy259 = yymsp[0].minor.yy259; + sqlite3SrcListShiftJoinType(yygotominor.yy259); + } + //#line 2602 "parse.c" + break; + case 132: /* stl_prefix ::= seltablist joinop */ + //#line 490 "parse.y" + { + yygotominor.yy259 = yymsp[-1].minor.yy259; + if (ALWAYS(yygotominor.yy259 != null && yygotominor.yy259.nSrc > 0)) + yygotominor.yy259.a[yygotominor.yy259.nSrc - 1].jointype = (u8)yymsp[0].minor.yy4; + } + //#line 2610 "parse.c" + break; + case 133: /* stl_prefix ::= */ + //#line 494 "parse.y" + { + yygotominor.yy259 = null; + } + //#line 2615 "parse.c" + break; + case 134: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ + //#line 495 "parse.y" + { + yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse, yymsp[-6].minor.yy259, yymsp[-5].minor.yy0, yymsp[-4].minor.yy0, yymsp[-3].minor.yy0, 0, yymsp[-1].minor.yy314, yymsp[0].minor.yy384); + sqlite3SrcListIndexedBy(pParse, yygotominor.yy259, yymsp[-2].minor.yy0); + } + //#line 2623 "parse.c" + break; + case 135: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ + //#line 501 "parse.y" + { + yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse, yymsp[-6].minor.yy259, 0, 0, yymsp[-2].minor.yy0, yymsp[-4].minor.yy387, yymsp[-1].minor.yy314, yymsp[0].minor.yy384); + } + //#line 2630 "parse.c" + break; + case 136: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ + //#line 505 "parse.y" + { + if (yymsp[-6].minor.yy259 == null && yymsp[-2].minor.yy0.n == 0 && yymsp[-1].minor.yy314 == null && yymsp[0].minor.yy384 == null) { + yygotominor.yy259 = yymsp[-4].minor.yy259; + } else { + Select pSubquery; + sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy259); + pSubquery = sqlite3SelectNew(pParse, 0, yymsp[-4].minor.yy259, 0, 0, 0, 0, 0, 0, 0); + yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse, yymsp[-6].minor.yy259, 0, 0, yymsp[-2].minor.yy0, pSubquery, yymsp[-1].minor.yy314, yymsp[0].minor.yy384); + } + } + //#line 2644 "parse.c" + break; + case 137: /* dbnm ::= */ + case 146: /* indexed_opt ::= */ //yytestcase(yyruleno==146); + //#line 530 "parse.y" + { + yygotominor.yy0.z = null; + yygotominor.yy0.n = 0; + } + //#line 2650 "parse.c" + break; + case 139: /* fullname ::= nm dbnm */ + //#line 535 "parse.y" + { + yygotominor.yy259 = sqlite3SrcListAppend(pParse.db, 0, yymsp[-1].minor.yy0, yymsp[0].minor.yy0); + } + //#line 2655 "parse.c" + break; + case 140: /* joinop ::= COMMA|JOIN */ + //#line 539 "parse.y" + { + yygotominor.yy4 = JT_INNER; + } + //#line 2660 "parse.c" + break; + case 141: /* joinop ::= JOIN_KW JOIN */ + //#line 540 "parse.y" + { + yygotominor.yy4 = sqlite3JoinType(pParse, yymsp[-1].minor.yy0, 0, 0); + } + //#line 2665 "parse.c" + break; + case 142: /* joinop ::= JOIN_KW nm JOIN */ + //#line 541 "parse.y" + { + yygotominor.yy4 = sqlite3JoinType(pParse, yymsp[-2].minor.yy0, yymsp[-1].minor.yy0, 0); + } + //#line 2670 "parse.c" + break; + case 143: /* joinop ::= JOIN_KW nm nm JOIN */ + //#line 543 "parse.y" + { + yygotominor.yy4 = sqlite3JoinType(pParse, yymsp[-3].minor.yy0, yymsp[-2].minor.yy0, yymsp[-1].minor.yy0); + } + //#line 2675 "parse.c" + break; + case 144: /* on_opt ::= ON expr */ + case 155: /* sortitem ::= expr */ //yytestcase(yyruleno==155); + case 162: /* having_opt ::= HAVING expr */ //yytestcase(yyruleno==162); + case 169: /* where_opt ::= WHERE expr */ //yytestcase(yyruleno==169); + case 235: /* case_else ::= ELSE expr */ //yytestcase(yyruleno==235); + case 237: /* case_operand ::= expr */ //yytestcase(yyruleno==237); + //#line 547 "parse.y" + { + yygotominor.yy314 = yymsp[0].minor.yy118.pExpr; + } + //#line 2685 "parse.c" + break; + case 145: /* on_opt ::= */ + case 161: /* having_opt ::= */ //yytestcase(yyruleno==161); + case 168: /* where_opt ::= */ //yytestcase(yyruleno==168); + case 236: /* case_else ::= */ //yytestcase(yyruleno==236); + case 238: /* case_operand ::= */ //yytestcase(yyruleno==238); + //#line 548 "parse.y" + { + yygotominor.yy314 = null; + } + //#line 2694 "parse.c" + break; + case 148: /* indexed_opt ::= NOT INDEXED */ + //#line 563 "parse.y" + { + yygotominor.yy0.z = null; + yygotominor.yy0.n = 1; + } + //#line 2699 "parse.c" + break; + case 149: /* using_opt ::= USING LP inscollist RP */ + case 181: /* inscollist_opt ::= LP inscollist RP */ //yytestcase(yyruleno==181); + //#line 567 "parse.y" + { + yygotominor.yy384 = yymsp[-1].minor.yy384; + } + //#line 2705 "parse.c" + break; + case 150: /* using_opt ::= */ + case 180: /* inscollist_opt ::= */ //yytestcase(yyruleno==180); + //#line 568 "parse.y" + { + yygotominor.yy384 = null; + } + //#line 2711 "parse.c" + break; + case 152: /* orderby_opt ::= ORDER BY sortlist */ + case 160: /* groupby_opt ::= GROUP BY nexprlist */ //yytestcase(yyruleno==160); + case 239: /* exprlist ::= nexprlist */ //yytestcase(yyruleno==239); + //#line 579 "parse.y" + { + yygotominor.yy322 = yymsp[0].minor.yy322; + } + //#line 2718 "parse.c" + break; + case 153: /* sortlist ::= sortlist COMMA sortitem sortorder */ + //#line 580 "parse.y" + { + yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy322, yymsp[-1].minor.yy314); + if (yygotominor.yy322 != null) + yygotominor.yy322.a[yygotominor.yy322.nExpr - 1].sortOrder = (u8)yymsp[0].minor.yy4; + } + //#line 2726 "parse.c" + break; + case 154: /* sortlist ::= sortitem sortorder */ + //#line 584 "parse.y" + { + yygotominor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[-1].minor.yy314); + if (yygotominor.yy322 != null && ALWAYS(yygotominor.yy322.a != null)) + yygotominor.yy322.a[0].sortOrder = (u8)yymsp[0].minor.yy4; + } + //#line 2734 "parse.c" + break; + case 156: /* sortorder ::= ASC */ + case 158: /* sortorder ::= */ //yytestcase(yyruleno==158); + //#line 592 "parse.y" + { + yygotominor.yy4 = SQLITE_SO_ASC; + } + //#line 2740 "parse.c" + break; + case 157: /* sortorder ::= DESC */ + //#line 593 "parse.y" + { + yygotominor.yy4 = SQLITE_SO_DESC; + } + //#line 2745 "parse.c" + break; + case 163: /* limit_opt ::= */ + //#line 619 "parse.y" + { + yygotominor.yy292.pLimit = null; + yygotominor.yy292.pOffset = null; + } + //#line 2750 "parse.c" + break; + case 164: /* limit_opt ::= LIMIT expr */ + //#line 620 "parse.y" + { + yygotominor.yy292.pLimit = yymsp[0].minor.yy118.pExpr; + yygotominor.yy292.pOffset = null; + } + //#line 2755 "parse.c" + break; + case 165: /* limit_opt ::= LIMIT expr OFFSET expr */ + //#line 622 "parse.y" + { + yygotominor.yy292.pLimit = yymsp[-2].minor.yy118.pExpr; + yygotominor.yy292.pOffset = yymsp[0].minor.yy118.pExpr; + } + //#line 2760 "parse.c" + break; + case 166: /* limit_opt ::= LIMIT expr COMMA expr */ + //#line 624 "parse.y" + { + yygotominor.yy292.pOffset = yymsp[-2].minor.yy118.pExpr; + yygotominor.yy292.pLimit = yymsp[0].minor.yy118.pExpr; + } + //#line 2765 "parse.c" + break; + case 167: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */ + //#line 637 "parse.y" + { + sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy259, yymsp[-1].minor.yy0); + sqlite3DeleteFrom(pParse, yymsp[-2].minor.yy259, yymsp[0].minor.yy314); + } + //#line 2773 "parse.c" + break; + case 170: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */ + //#line 660 "parse.y" + { + sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy259, yymsp[-3].minor.yy0); + sqlite3ExprListCheckLength(pParse, yymsp[-1].minor.yy322, "set list"); + sqlite3Update(pParse, yymsp[-4].minor.yy259, yymsp[-1].minor.yy322, yymsp[0].minor.yy314, yymsp[-5].minor.yy210); + } + //#line 2782 "parse.c" + break; + case 171: /* setlist ::= setlist COMMA nm EQ expr */ + //#line 670 "parse.y" + { + yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[0].minor.yy118.pExpr); + sqlite3ExprListSetName(pParse, yygotominor.yy322, yymsp[-2].minor.yy0, 1); + } + //#line 2790 "parse.c" + break; + case 172: /* setlist ::= nm EQ expr */ + //#line 674 "parse.y" + { + yygotominor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy118.pExpr); + sqlite3ExprListSetName(pParse, yygotominor.yy322, yymsp[-2].minor.yy0, 1); + } + //#line 2798 "parse.c" + break; + case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP */ + //#line 683 "parse.y" + { + sqlite3Insert(pParse, yymsp[-5].minor.yy259, yymsp[-1].minor.yy322, 0, yymsp[-4].minor.yy384, yymsp[-7].minor.yy210); + } + //#line 2803 "parse.c" + break; + case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */ + //#line 685 "parse.y" + { + sqlite3Insert(pParse, yymsp[-2].minor.yy259, 0, yymsp[0].minor.yy387, yymsp[-1].minor.yy384, yymsp[-4].minor.yy210); + } + //#line 2808 "parse.c" + break; + case 175: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */ + //#line 687 "parse.y" + { + sqlite3Insert(pParse, yymsp[-3].minor.yy259, 0, 0, yymsp[-2].minor.yy384, yymsp[-5].minor.yy210); + } + //#line 2813 "parse.c" + break; + case 176: /* insert_cmd ::= INSERT orconf */ + //#line 690 "parse.y" + { + yygotominor.yy210 = yymsp[0].minor.yy210; + } + //#line 2818 "parse.c" + break; + case 177: /* insert_cmd ::= REPLACE */ + //#line 691 "parse.y" + { + yygotominor.yy210 = OE_Replace; + } + //#line 2823 "parse.c" + break; + case 178: /* itemlist ::= itemlist COMMA expr */ + case 241: /* nexprlist ::= nexprlist COMMA expr */ //yytestcase(yyruleno==241); + //#line 698 "parse.y" + { + yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy322, yymsp[0].minor.yy118.pExpr); + } + //#line 2829 "parse.c" + break; + case 179: /* itemlist ::= expr */ + case 242: /* nexprlist ::= expr */ //yytestcase(yyruleno==242); + //#line 700 "parse.y" + { + yygotominor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy118.pExpr); + } + //#line 2835 "parse.c" + break; + case 182: /* inscollist ::= inscollist COMMA nm */ + //#line 710 "parse.y" + { + yygotominor.yy384 = sqlite3IdListAppend(pParse.db, yymsp[-2].minor.yy384, yymsp[0].minor.yy0); + } + //#line 2840 "parse.c" + break; + case 183: /* inscollist ::= nm */ + //#line 712 "parse.y" + { + yygotominor.yy384 = sqlite3IdListAppend(pParse.db, 0, yymsp[0].minor.yy0); + } + //#line 2845 "parse.c" + break; + case 184: /* expr ::= term */ + //#line 743 "parse.y" + { + yygotominor.yy118 = yymsp[0].minor.yy118; + } + //#line 2850 "parse.c" + break; + case 185: /* expr ::= LP expr RP */ + //#line 744 "parse.y" + { + yygotominor.yy118.pExpr = yymsp[-1].minor.yy118.pExpr; + spanSet(yygotominor.yy118, yymsp[-2].minor.yy0, yymsp[0].minor.yy0); + } + //#line 2855 "parse.c" + break; + case 186: /* term ::= NULL */ + case 191: /* term ::= INTEGER|FLOAT|BLOB */ //yytestcase(yyruleno==191); + case 192: /* term ::= STRING */ //yytestcase(yyruleno==192); + //#line 745 "parse.y" + { + spanExpr(yygotominor.yy118, pParse, yymsp[0].major, yymsp[0].minor.yy0); + } + //#line 2862 "parse.c" + break; + case 187: /* expr ::= id */ + case 188: /* expr ::= JOIN_KW */ //yytestcase(yyruleno==188); + //#line 746 "parse.y" + { + spanExpr(yygotominor.yy118, pParse, TK_ID, yymsp[0].minor.yy0); + } + //#line 2868 "parse.c" + break; + case 189: /* expr ::= nm DOT nm */ + //#line 748 "parse.y" + { + Expr temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, yymsp[-2].minor.yy0); + Expr temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, yymsp[0].minor.yy0); + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0); + spanSet(yygotominor.yy118, yymsp[-2].minor.yy0, yymsp[0].minor.yy0); + } + //#line 2878 "parse.c" + break; + case 190: /* expr ::= nm DOT nm DOT nm */ + //#line 754 "parse.y" + { + Expr temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, yymsp[-4].minor.yy0); + Expr temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, yymsp[-2].minor.yy0); + Expr temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, yymsp[0].minor.yy0); + Expr temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0); + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0); + spanSet(yygotominor.yy118, yymsp[-4].minor.yy0, yymsp[0].minor.yy0); + } + //#line 2890 "parse.c" + break; + case 193: /* expr ::= REGISTER */ + //#line 764 "parse.y" + { + /* When doing a nested parse, one can include terms in an expression + ** that look like this: #1 #2 ... These terms refer to registers + ** in the virtual machine. #N is the N-th register. */ + if (pParse.nested == 0) { + sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", yymsp[0].minor.yy0); + yygotominor.yy118.pExpr = null; + } else { + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, yymsp[0].minor.yy0); + if (yygotominor.yy118.pExpr != null) + sqlite3GetInt32(yymsp[0].minor.yy0.z, 1, ref yygotominor.yy118.pExpr.iTable); + } + spanSet(yygotominor.yy118, yymsp[0].minor.yy0, yymsp[0].minor.yy0); + } + //#line 2907 "parse.c" + break; + case 194: /* expr ::= VARIABLE */ + //#line 777 "parse.y" + { + spanExpr(yygotominor.yy118, pParse, TK_VARIABLE, yymsp[0].minor.yy0); + sqlite3ExprAssignVarNumber(pParse, yygotominor.yy118.pExpr); + spanSet(yygotominor.yy118, yymsp[0].minor.yy0, yymsp[0].minor.yy0); + } + //#line 2916 "parse.c" + break; + case 195: /* expr ::= expr COLLATE ids */ + //#line 782 "parse.y" + { + yygotominor.yy118.pExpr = sqlite3ExprSetCollByToken(pParse, yymsp[-2].minor.yy118.pExpr, yymsp[0].minor.yy0); + yygotominor.yy118.zStart = yymsp[-2].minor.yy118.zStart; + yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring(yymsp[0].minor.yy0.n);//z[yymsp[0].minor.yy0.n]; + } + //#line 2925 "parse.c" + break; + case 196: /* expr ::= CAST LP expr AS typetoken RP */ + //#line 788 "parse.y" + { + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy118.pExpr, 0, yymsp[-1].minor.yy0); + spanSet(yygotominor.yy118, yymsp[-5].minor.yy0, yymsp[0].minor.yy0); + } + //#line 2933 "parse.c" + break; + case 197: /* expr ::= ID LP distinct exprlist RP */ + //#line 793 "parse.y" + { + if (yymsp[-1].minor.yy322 != null && yymsp[-1].minor.yy322.nExpr > pParse.db.aLimit[SQLITE_LIMIT_FUNCTION_ARG]) { + sqlite3ErrorMsg(pParse, "too many arguments on function %T", yymsp[-4].minor.yy0); + } + yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy322, yymsp[-4].minor.yy0); + spanSet(yygotominor.yy118, yymsp[-4].minor.yy0, yymsp[0].minor.yy0); + if (yymsp[-2].minor.yy4 != 0 && yygotominor.yy118.pExpr != null) { + yygotominor.yy118.pExpr.flags |= EP_Distinct; + } + } + //#line 2947 "parse.c" + break; + case 198: /* expr ::= ID LP STAR RP */ + //#line 803 "parse.y" + { + yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, 0, yymsp[-3].minor.yy0); + spanSet(yygotominor.yy118, yymsp[-3].minor.yy0, yymsp[0].minor.yy0); + } + //#line 2955 "parse.c" + break; + case 199: /* term ::= CTIME_KW */ + //#line 807 "parse.y" + { + /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are + ** treated as functions that return constants */ + yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, 0, yymsp[0].minor.yy0); + if (yygotominor.yy118.pExpr != null) { + yygotominor.yy118.pExpr.op = TK_CONST_FUNC; + } + spanSet(yygotominor.yy118, yymsp[0].minor.yy0, yymsp[0].minor.yy0); + } + //#line 2968 "parse.c" + break; + case 200: /* expr ::= expr AND expr */ + case 201: /* expr ::= expr OR expr */ //yytestcase(yyruleno==201); + case 202: /* expr ::= expr LT|GT|GE|LE expr */ //yytestcase(yyruleno==202); + case 203: /* expr ::= expr EQ|NE expr */ //yytestcase(yyruleno==203); + case 204: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ //yytestcase(yyruleno==204); + case 205: /* expr ::= expr PLUS|MINUS expr */ //yytestcase(yyruleno==205); + case 206: /* expr ::= expr STAR|SLASH|REM expr */ //yytestcase(yyruleno==206); + case 207: /* expr ::= expr CONCAT expr */ //yytestcase(yyruleno==207); + //#line 834 "parse.y" + { + spanBinaryExpr(yygotominor.yy118, pParse, yymsp[-1].major, yymsp[-2].minor.yy118, yymsp[0].minor.yy118); + } + //#line 2980 "parse.c" + break; + case 208: /* likeop ::= LIKE_KW */ + case 210: /* likeop ::= MATCH */ //yytestcase(yyruleno==210); + //#line 847 "parse.y" + { + yygotominor.yy342.eOperator = yymsp[0].minor.yy0; + yygotominor.yy342.not = false; + } + //#line 2986 "parse.c" + break; + case 209: /* likeop ::= NOT LIKE_KW */ + case 211: /* likeop ::= NOT MATCH */ //yytestcase(yyruleno==211); + //#line 848 "parse.y" + { + yygotominor.yy342.eOperator = yymsp[0].minor.yy0; + yygotominor.yy342.not = true; + } + //#line 2992 "parse.c" + break; + case 212: /* expr ::= expr likeop expr */ + //#line 851 "parse.y" + { + ExprList pList; + pList = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy118.pExpr); + pList = sqlite3ExprListAppend(pParse, pList, yymsp[-2].minor.yy118.pExpr); + yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, pList, yymsp[-1].minor.yy342.eOperator); + if (yymsp[-1].minor.yy342.not) + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); + yygotominor.yy118.zStart = yymsp[-2].minor.yy118.zStart; + yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; + if (yygotominor.yy118.pExpr != null) + yygotominor.yy118.pExpr.flags |= EP_InfixFunc; + } + //#line 3006 "parse.c" + break; + case 213: /* expr ::= expr likeop expr ESCAPE expr */ + //#line 861 "parse.y" + { + ExprList pList; + pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy118.pExpr); + pList = sqlite3ExprListAppend(pParse, pList, yymsp[-4].minor.yy118.pExpr); + pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy118.pExpr); + yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, pList, yymsp[-3].minor.yy342.eOperator); + if (yymsp[-3].minor.yy342.not) + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); + yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; + yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; + if (yygotominor.yy118.pExpr != null) + yygotominor.yy118.pExpr.flags |= EP_InfixFunc; + } + //#line 3021 "parse.c" + break; + case 214: /* expr ::= expr ISNULL|NOTNULL */ + //#line 889 "parse.y" + { + spanUnaryPostfix(yygotominor.yy118, pParse, yymsp[0].major, yymsp[-1].minor.yy118, yymsp[0].minor.yy0); + } + //#line 3026 "parse.c" + break; + case 215: /* expr ::= expr NOT NULL */ + //#line 890 "parse.y" + { + spanUnaryPostfix(yygotominor.yy118, pParse, TK_NOTNULL, yymsp[-2].minor.yy118, yymsp[0].minor.yy0); + } + //#line 3031 "parse.c" + break; + case 216: /* expr ::= expr IS expr */ + //#line 911 "parse.y" + { + spanBinaryExpr(yygotominor.yy118, pParse, TK_IS, yymsp[-2].minor.yy118, yymsp[0].minor.yy118); + binaryToUnaryIfNull(pParse, yymsp[0].minor.yy118.pExpr, yygotominor.yy118.pExpr, TK_ISNULL); + } + //#line 3039 "parse.c" + break; + case 217: /* expr ::= expr IS NOT expr */ + //#line 915 "parse.y" + { + spanBinaryExpr(yygotominor.yy118, pParse, TK_ISNOT, yymsp[-3].minor.yy118, yymsp[0].minor.yy118); + binaryToUnaryIfNull(pParse, yymsp[0].minor.yy118.pExpr, yygotominor.yy118.pExpr, TK_NOTNULL); + } + //#line 3047 "parse.c" + break; + case 218: /* expr ::= NOT expr */ + case 219: /* expr ::= BITNOT expr */ //yytestcase(yyruleno==219); + //#line 938 "parse.y" + { + spanUnaryPrefix(yygotominor.yy118, pParse, yymsp[-1].major, yymsp[0].minor.yy118, yymsp[-1].minor.yy0); + } + //#line 3053 "parse.c" + break; + case 220: /* expr ::= MINUS expr */ + //#line 941 "parse.y" + { + spanUnaryPrefix(yygotominor.yy118, pParse, TK_UMINUS, yymsp[0].minor.yy118, yymsp[-1].minor.yy0); + } + //#line 3058 "parse.c" + break; + case 221: /* expr ::= PLUS expr */ + //#line 943 "parse.y" + { + spanUnaryPrefix(yygotominor.yy118, pParse, TK_UPLUS, yymsp[0].minor.yy118, yymsp[-1].minor.yy0); + } + //#line 3063 "parse.c" + break; + case 224: /* expr ::= expr between_op expr AND expr */ + //#line 948 "parse.y" + { + ExprList pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy118.pExpr); + pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy118.pExpr); + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy118.pExpr, 0, 0); + if (yygotominor.yy118.pExpr != null) { + yygotominor.yy118.pExpr.x.pList = pList; + } else { + sqlite3ExprListDelete(pParse.db, ref pList); + } + if (yymsp[-3].minor.yy4 != 0) + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); + yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; + yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; + } + //#line 3080 "parse.c" + break; + case 227: /* expr ::= expr in_op LP exprlist RP */ + //#line 965 "parse.y" + { + if (yymsp[-1].minor.yy322 == null) { + /* Expressions of the form + ** + ** expr1 IN () + ** expr1 NOT IN () + ** + ** simplify to constants 0 (false) and 1 (true), respectively, + ** regardless of the value of expr1. + */ + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, sqlite3IntTokens[yymsp[-3].minor.yy4]); + sqlite3ExprDelete(pParse.db, ref yymsp[-4].minor.yy118.pExpr); + } else { + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy118.pExpr, 0, 0); + if (yygotominor.yy118.pExpr != null) { + yygotominor.yy118.pExpr.x.pList = yymsp[-1].minor.yy322; + sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr); + } else { + sqlite3ExprListDelete(pParse.db, ref yymsp[-1].minor.yy322); + } + if (yymsp[-3].minor.yy4 != 0) + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); + } + yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; + yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring(yymsp[0].minor.yy0.n);//[yymsp[0].minor.yy0.n]; + } + //#line 3109 "parse.c" + break; + case 228: /* expr ::= LP select RP */ + //#line 990 "parse.y" + { + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0); + if (yygotominor.yy118.pExpr != null) { + yygotominor.yy118.pExpr.x.pSelect = yymsp[-1].minor.yy387; + ExprSetProperty(yygotominor.yy118.pExpr, EP_xIsSelect); + sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr); + } else { + sqlite3SelectDelete(pParse.db, ref yymsp[-1].minor.yy387); + } + yygotominor.yy118.zStart = yymsp[-2].minor.yy0.z; + yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring(yymsp[0].minor.yy0.n);//z[yymsp[0].minor.yy0.n]; + } + //#line 3125 "parse.c" + break; + case 229: /* expr ::= expr in_op LP select RP */ + //#line 1002 "parse.y" + { + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy118.pExpr, 0, 0); + if (yygotominor.yy118.pExpr != null) { + yygotominor.yy118.pExpr.x.pSelect = yymsp[-1].minor.yy387; + ExprSetProperty(yygotominor.yy118.pExpr, EP_xIsSelect); + sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr); + } else { + sqlite3SelectDelete(pParse.db, ref yymsp[-1].minor.yy387); + } + if (yymsp[-3].minor.yy4 != 0) + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); + yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; + yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring(yymsp[0].minor.yy0.n);//z[yymsp[0].minor.yy0.n]; + } + //#line 3142 "parse.c" + break; + case 230: /* expr ::= expr in_op nm dbnm */ + //#line 1015 "parse.y" + { + SrcList pSrc = sqlite3SrcListAppend(pParse.db, 0, yymsp[-1].minor.yy0, yymsp[0].minor.yy0); + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy118.pExpr, 0, 0); + if (yygotominor.yy118.pExpr != null) { + yygotominor.yy118.pExpr.x.pSelect = sqlite3SelectNew(pParse, 0, pSrc, 0, 0, 0, 0, 0, 0, 0); + ExprSetProperty(yygotominor.yy118.pExpr, EP_xIsSelect); + sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr); + } else { + sqlite3SrcListDelete(pParse.db, ref pSrc); + } + if (yymsp[-2].minor.yy4 != 0) + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); + yygotominor.yy118.zStart = yymsp[-3].minor.yy118.zStart; + yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z != null ? yymsp[0].minor.yy0.z.Substring(yymsp[0].minor.yy0.n) : yymsp[-1].minor.yy0.z.Substring(yymsp[-1].minor.yy0.n); + } + //#line 3160 "parse.c" + break; + case 231: /* expr ::= EXISTS LP select RP */ + //#line 1029 "parse.y" + { + Expr p = yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0); + if (p != null) { + p.x.pSelect = yymsp[-1].minor.yy387; + ExprSetProperty(p, EP_xIsSelect); + sqlite3ExprSetHeight(pParse, p); + } else { + sqlite3SelectDelete(pParse.db, ref yymsp[-1].minor.yy387); + } + yygotominor.yy118.zStart = yymsp[-3].minor.yy0.z; + yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring(yymsp[0].minor.yy0.n); //z[yymsp[0].minor.yy0.n]; + } + //#line 3176 "parse.c" + break; + case 232: /* expr ::= CASE case_operand case_exprlist case_else END */ + //#line 1044 "parse.y" + { + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy314, yymsp[-1].minor.yy314, 0); + if (yygotominor.yy118.pExpr != null) { + yygotominor.yy118.pExpr.x.pList = yymsp[-2].minor.yy322; + sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr); + } else { + sqlite3ExprListDelete(pParse.db, ref yymsp[-2].minor.yy322); + } + yygotominor.yy118.zStart = yymsp[-4].minor.yy0.z; + yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring(yymsp[0].minor.yy0.n);//z[yymsp[0].minor.yy0.n]; + } + //#line 3191 "parse.c" + break; + case 233: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ + //#line 1057 "parse.y" + { + yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[-2].minor.yy118.pExpr); + yygotominor.yy322 = sqlite3ExprListAppend(pParse, yygotominor.yy322, yymsp[0].minor.yy118.pExpr); + } + //#line 3199 "parse.c" + break; + case 234: /* case_exprlist ::= WHEN expr THEN expr */ + //#line 1061 "parse.y" + { + yygotominor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy118.pExpr); + yygotominor.yy322 = sqlite3ExprListAppend(pParse, yygotominor.yy322, yymsp[0].minor.yy118.pExpr); + } + //#line 3207 "parse.c" + break; + case 243: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */ + //#line 1090 "parse.y" + { + sqlite3CreateIndex(pParse, yymsp[-6].minor.yy0, yymsp[-5].minor.yy0, + sqlite3SrcListAppend(pParse.db, 0, yymsp[-3].minor.yy0, 0), yymsp[-1].minor.yy322, yymsp[-9].minor.yy4, + yymsp[-10].minor.yy0, yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy4); + } + //#line 3216 "parse.c" + break; + case 244: /* uniqueflag ::= UNIQUE */ + case 298: /* raisetype ::= ABORT */ //yytestcase(yyruleno==298); + //#line 1097 "parse.y" + { + yygotominor.yy4 = OE_Abort; + } + //#line 3222 "parse.c" + break; + case 245: /* uniqueflag ::= */ + //#line 1098 "parse.y" + { + yygotominor.yy4 = OE_None; + } + //#line 3227 "parse.c" + break; + case 248: /* idxlist ::= idxlist COMMA nm collate sortorder */ + //#line 1107 "parse.y" + { + Expr p = null; + if (yymsp[-1].minor.yy0.n > 0) { + p = sqlite3Expr(pParse.db, TK_COLUMN, null); + sqlite3ExprSetCollByToken(pParse, p, yymsp[-1].minor.yy0); + } + yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, p); + sqlite3ExprListSetName(pParse, yygotominor.yy322, yymsp[-2].minor.yy0, 1); + sqlite3ExprListCheckLength(pParse, yygotominor.yy322, "index"); + if (yygotominor.yy322 != null) + yygotominor.yy322.a[yygotominor.yy322.nExpr - 1].sortOrder = (u8)yymsp[0].minor.yy4; + } + //#line 3242 "parse.c" + break; + case 249: /* idxlist ::= nm collate sortorder */ + //#line 1118 "parse.y" + { + Expr p = null; + if (yymsp[-1].minor.yy0.n > 0) { + p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0); + sqlite3ExprSetCollByToken(pParse, p, yymsp[-1].minor.yy0); + } + yygotominor.yy322 = sqlite3ExprListAppend(pParse, 0, p); + sqlite3ExprListSetName(pParse, yygotominor.yy322, yymsp[-2].minor.yy0, 1); + sqlite3ExprListCheckLength(pParse, yygotominor.yy322, "index"); + if (yygotominor.yy322 != null) + yygotominor.yy322.a[yygotominor.yy322.nExpr - 1].sortOrder = (u8)yymsp[0].minor.yy4; + } + //#line 3257 "parse.c" + break; + case 250: /* collate ::= */ + //#line 1131 "parse.y" + { + yygotominor.yy0.z = null; + yygotominor.yy0.n = 0; + } + //#line 3262 "parse.c" + break; + case 252: /* cmd ::= DROP INDEX ifexists fullname */ + //#line 1137 "parse.y" + { + sqlite3DropIndex(pParse, yymsp[0].minor.yy259, yymsp[-1].minor.yy4); + } + //#line 3267 "parse.c" + break; + case 253: /* cmd ::= VACUUM */ + case 254: /* cmd ::= VACUUM nm */ //yytestcase(yyruleno==254); + //#line 1143 "parse.y" + { + sqlite3Vacuum(pParse); + } + //#line 3273 "parse.c" + break; + case 255: /* cmd ::= PRAGMA nm dbnm */ + //#line 1151 "parse.y" + { + sqlite3Pragma(pParse, yymsp[-1].minor.yy0, yymsp[0].minor.yy0, 0, 0); + } + //#line 3278 "parse.c" + break; + case 256: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ + //#line 1152 "parse.y" + { + sqlite3Pragma(pParse, yymsp[-3].minor.yy0, yymsp[-2].minor.yy0, yymsp[0].minor.yy0, 0); + } + //#line 3283 "parse.c" + break; + case 257: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ + //#line 1153 "parse.y" + { + sqlite3Pragma(pParse, yymsp[-4].minor.yy0, yymsp[-3].minor.yy0, yymsp[-1].minor.yy0, 0); + } + //#line 3288 "parse.c" + break; + case 258: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ + //#line 1155 "parse.y" + { + sqlite3Pragma(pParse, yymsp[-3].minor.yy0, yymsp[-2].minor.yy0, yymsp[0].minor.yy0, 1); + } + //#line 3293 "parse.c" + break; + case 259: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ + //#line 1157 "parse.y" + { + sqlite3Pragma(pParse, yymsp[-4].minor.yy0, yymsp[-3].minor.yy0, yymsp[-1].minor.yy0, 1); + } + //#line 3298 "parse.c" + break; + case 270: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ + //#line 1175 "parse.y" + { + Token all = new Token(); + //all.z = yymsp[-3].minor.yy0.z; + //all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; + all.n = (int)(yymsp[-3].minor.yy0.z.Length - yymsp[0].minor.yy0.z.Length) + yymsp[0].minor.yy0.n; + all.z = yymsp[-3].minor.yy0.z.Substring(0, all.n); + sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy203, all); + } + //#line 3308 "parse.c" + break; + case 271: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ + //#line 1184 "parse.y" + { + sqlite3BeginTrigger(pParse, yymsp[-7].minor.yy0, yymsp[-6].minor.yy0, yymsp[-5].minor.yy4, yymsp[-4].minor.yy90.a, yymsp[-4].minor.yy90.b, yymsp[-2].minor.yy259, yymsp[0].minor.yy314, yymsp[-10].minor.yy4, yymsp[-8].minor.yy4); + yygotominor.yy0 = (yymsp[-6].minor.yy0.n == 0 ? yymsp[-7].minor.yy0 : yymsp[-6].minor.yy0); + } + //#line 3316 "parse.c" + break; + case 272: /* trigger_time ::= BEFORE */ + case 275: /* trigger_time ::= */ //yytestcase(yyruleno==275); + //#line 1190 "parse.y" + { + yygotominor.yy4 = TK_BEFORE; + } + //#line 3322 "parse.c" + break; + case 273: /* trigger_time ::= AFTER */ + //#line 1191 "parse.y" + { + yygotominor.yy4 = TK_AFTER; + } + //#line 3327 "parse.c" + break; + case 274: /* trigger_time ::= INSTEAD OF */ + //#line 1192 "parse.y" + { + yygotominor.yy4 = TK_INSTEAD; + } + //#line 3332 "parse.c" + break; + case 276: /* trigger_event ::= DELETE|INSERT */ + case 277: /* trigger_event ::= UPDATE */ //yytestcase(yyruleno==277); + //#line 1197 "parse.y" + { + yygotominor.yy90.a = yymsp[0].major; + yygotominor.yy90.b = null; + } + //#line 3338 "parse.c" + break; + case 278: /* trigger_event ::= UPDATE OF inscollist */ + //#line 1199 "parse.y" + { + yygotominor.yy90.a = TK_UPDATE; + yygotominor.yy90.b = yymsp[0].minor.yy384; + } + //#line 3343 "parse.c" + break; + case 281: /* when_clause ::= */ + case 303: /* key_opt ::= */ //yytestcase(yyruleno==303); + //#line 1206 "parse.y" + { + yygotominor.yy314 = null; + } + //#line 3349 "parse.c" + break; + case 282: /* when_clause ::= WHEN expr */ + case 304: /* key_opt ::= KEY expr */ //yytestcase(yyruleno==304); + //#line 1207 "parse.y" + { + yygotominor.yy314 = yymsp[0].minor.yy118.pExpr; + } + //#line 3355 "parse.c" + break; + case 283: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ + //#line 1211 "parse.y" + { + Debug.Assert(yymsp[-2].minor.yy203 != null); + yymsp[-2].minor.yy203.pLast.pNext = yymsp[-1].minor.yy203; + yymsp[-2].minor.yy203.pLast = yymsp[-1].minor.yy203; + yygotominor.yy203 = yymsp[-2].minor.yy203; + } + //#line 3365 "parse.c" + break; + case 284: /* trigger_cmd_list ::= trigger_cmd SEMI */ + //#line 1217 "parse.y" + { + Debug.Assert(yymsp[-1].minor.yy203 != null); + yymsp[-1].minor.yy203.pLast = yymsp[-1].minor.yy203; + yygotominor.yy203 = yymsp[-1].minor.yy203; + } + //#line 3374 "parse.c" + break; + case 286: /* trnm ::= nm DOT nm */ + //#line 1229 "parse.y" + { + yygotominor.yy0 = yymsp[0].minor.yy0; + sqlite3ErrorMsg(pParse, + "qualified table names are not allowed on INSERT, UPDATE, and DELETE " + + "statements within triggers"); + } + //#line 3384 "parse.c" + break; + case 288: /* tridxby ::= INDEXED BY nm */ + //#line 1241 "parse.y" + { + sqlite3ErrorMsg(pParse, + "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " + + "within triggers"); + } + //#line 3393 "parse.c" + break; + case 289: /* tridxby ::= NOT INDEXED */ + //#line 1246 "parse.y" + { + sqlite3ErrorMsg(pParse, + "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " + + "within triggers"); + } + //#line 3402 "parse.c" + break; + case 290: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */ + //#line 1259 "parse.y" + { + yygotominor.yy203 = sqlite3TriggerUpdateStep(pParse.db, yymsp[-4].minor.yy0, yymsp[-1].minor.yy322, yymsp[0].minor.yy314, yymsp[-5].minor.yy210); + } + //#line 3407 "parse.c" + break; + case 291: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt VALUES LP itemlist RP */ + //#line 1264 "parse.y" + { + yygotominor.yy203 = sqlite3TriggerInsertStep(pParse.db, yymsp[-5].minor.yy0, yymsp[-4].minor.yy384, yymsp[-1].minor.yy322, 0, yymsp[-7].minor.yy210); + } + //#line 3412 "parse.c" + break; + case 292: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */ + //#line 1267 "parse.y" + { + yygotominor.yy203 = sqlite3TriggerInsertStep(pParse.db, yymsp[-2].minor.yy0, yymsp[-1].minor.yy384, 0, yymsp[0].minor.yy387, yymsp[-4].minor.yy210); + } + //#line 3417 "parse.c" + break; + case 293: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */ + //#line 1271 "parse.y" + { + yygotominor.yy203 = sqlite3TriggerDeleteStep(pParse.db, yymsp[-2].minor.yy0, yymsp[0].minor.yy314); + } + //#line 3422 "parse.c" + break; + case 294: /* trigger_cmd ::= select */ + //#line 1274 "parse.y" + { + yygotominor.yy203 = sqlite3TriggerSelectStep(pParse.db, yymsp[0].minor.yy387); + } + //#line 3427 "parse.c" + break; + case 295: /* expr ::= RAISE LP IGNORE RP */ + //#line 1277 "parse.y" + { + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0); + if (yygotominor.yy118.pExpr != null) { + yygotominor.yy118.pExpr.affinity = (char)OE_Ignore; + } + yygotominor.yy118.zStart = yymsp[-3].minor.yy0.z; + yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring(yymsp[0].minor.yy0.n);//z[yymsp[0].minor.yy0.n]; + } + //#line 3439 "parse.c" + break; + case 296: /* expr ::= RAISE LP raisetype COMMA nm RP */ + //#line 1285 "parse.y" + { + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, yymsp[-1].minor.yy0); + if (yygotominor.yy118.pExpr != null) { + yygotominor.yy118.pExpr.affinity = (char)yymsp[-3].minor.yy4; + } + yygotominor.yy118.zStart = yymsp[-5].minor.yy0.z; + yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring(yymsp[0].minor.yy0.n);//z[yymsp[0].minor.yy0.n]; + } + //#line 3451 "parse.c" + break; + case 297: /* raisetype ::= ROLLBACK */ + //#line 1296 "parse.y" + { + yygotominor.yy4 = OE_Rollback; + } + //#line 3456 "parse.c" + break; + case 299: /* raisetype ::= FAIL */ + //#line 1298 "parse.y" + { + yygotominor.yy4 = OE_Fail; + } + //#line 3461 "parse.c" + break; + case 300: /* cmd ::= DROP TRIGGER ifexists fullname */ + //#line 1303 "parse.y" + { + sqlite3DropTrigger(pParse, yymsp[0].minor.yy259, yymsp[-1].minor.yy4); + } + //#line 3468 "parse.c" + break; + case 301: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ + //#line 1310 "parse.y" + { + sqlite3Attach(pParse, yymsp[-3].minor.yy118.pExpr, yymsp[-1].minor.yy118.pExpr, yymsp[0].minor.yy314); + } + //#line 3475 "parse.c" + break; + case 302: /* cmd ::= DETACH database_kw_opt expr */ + //#line 1313 "parse.y" + { + sqlite3Detach(pParse, yymsp[0].minor.yy118.pExpr); + } + //#line 3482 "parse.c" + break; + case 307: /* cmd ::= REINDEX */ + //#line 1328 "parse.y" + { + sqlite3Reindex(pParse, 0, 0); + } + //#line 3487 "parse.c" + break; + case 308: /* cmd ::= REINDEX nm dbnm */ + //#line 1329 "parse.y" + { + sqlite3Reindex(pParse, yymsp[-1].minor.yy0, yymsp[0].minor.yy0); + } + //#line 3492 "parse.c" + break; + case 309: /* cmd ::= ANALYZE */ + //#line 1334 "parse.y" + { + sqlite3Analyze(pParse, 0, 0); + } + //#line 3497 "parse.c" + break; + case 310: /* cmd ::= ANALYZE nm dbnm */ + //#line 1335 "parse.y" + { + sqlite3Analyze(pParse, yymsp[-1].minor.yy0, yymsp[0].minor.yy0); + } + //#line 3502 "parse.c" + break; + case 311: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ + //#line 1340 "parse.y" + { + sqlite3AlterRenameTable(pParse, yymsp[-3].minor.yy259, yymsp[0].minor.yy0); + } + //#line 3509 "parse.c" + break; + case 312: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */ + //#line 1343 "parse.y" + { + sqlite3AlterFinishAddColumn(pParse, yymsp[0].minor.yy0); + } + //#line 3516 "parse.c" + break; + case 313: /* add_column_fullname ::= fullname */ + //#line 1346 "parse.y" + { + pParse.db.lookaside.bEnabled = 0; + sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy259); + } + //#line 3524 "parse.c" + break; + case 316: /* cmd ::= create_vtab */ + //#line 1356 "parse.y" + { + sqlite3VtabFinishParse(pParse, (Token)null); + } + //#line 3529 "parse.c" + break; + case 317: /* cmd ::= create_vtab LP vtabarglist RP */ + //#line 1357 "parse.y" + { + sqlite3VtabFinishParse(pParse, yymsp[0].minor.yy0); + } + //#line 3534 "parse.c" + break; + case 318: /* create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm */ + //#line 1358 "parse.y" + { + sqlite3VtabBeginParse(pParse, yymsp[-3].minor.yy0, yymsp[-2].minor.yy0, yymsp[0].minor.yy0); + } + //#line 3541 "parse.c" + break; + case 321: /* vtabarg ::= */ + //#line 1363 "parse.y" + { + sqlite3VtabArgInit(pParse); + } + //#line 3546 "parse.c" + break; + case 323: /* vtabargtoken ::= ANY */ + case 324: /* vtabargtoken ::= lp anylist RP */ //yytestcase(yyruleno==324); + case 325: /* lp ::= LP */ //yytestcase(yyruleno==325); + //#line 1365 "parse.y" + { + sqlite3VtabArgExtend(pParse, yymsp[0].minor.yy0); + } + //#line 3553 "parse.c" + break; + default: + /* (0) input ::= cmdlist */ + //yytestcase(yyruleno==0); + /* (1) cmdlist ::= cmdlist ecmd */ + //yytestcase(yyruleno==1); + /* (2) cmdlist ::= ecmd */ + //yytestcase(yyruleno==2); + /* (3) ecmd ::= SEMI */ + //yytestcase(yyruleno==3); + /* (4) ecmd ::= explain cmdx SEMI */ + //yytestcase(yyruleno==4); + /* (10) trans_opt ::= */ + //yytestcase(yyruleno==10); + /* (11) trans_opt ::= TRANSACTION */ + //yytestcase(yyruleno==11); + /* (12) trans_opt ::= TRANSACTION nm */ + //yytestcase(yyruleno==12); + /* (20) savepoint_opt ::= SAVEPOINT */ + //yytestcase(yyruleno==20); + /* (21) savepoint_opt ::= */ + //yytestcase(yyruleno==21); + /* (25) cmd ::= create_table create_table_args */ + //yytestcase(yyruleno==25); + /* (34) columnlist ::= columnlist COMMA column */ + //yytestcase(yyruleno==34); + /* (35) columnlist ::= column */ + //yytestcase(yyruleno==35); + /* (44) type ::= */ + //yytestcase(yyruleno==44); + /* (51) signed ::= plus_num */ + //yytestcase(yyruleno==51); + /* (52) signed ::= minus_num */ + //yytestcase(yyruleno==52); + /* (53) carglist ::= carglist carg */ + //yytestcase(yyruleno==53); + /* (54) carglist ::= */ + //yytestcase(yyruleno==54); + /* (55) carg ::= CONSTRAINT nm ccons */ + //yytestcase(yyruleno==55); + /* (56) carg ::= ccons */ + //yytestcase(yyruleno==56); + /* (62) ccons ::= NULL onconf */ + //yytestcase(yyruleno==62); + /* (90) conslist ::= conslist COMMA tcons */ + //yytestcase(yyruleno==90); + /* (91) conslist ::= conslist tcons */ + //yytestcase(yyruleno==91); + /* (92) conslist ::= tcons */ + //yytestcase(yyruleno==92); + /* (93) tcons ::= CONSTRAINT nm */ + //yytestcase(yyruleno==93); + /* (268) plus_opt ::= PLUS */ + //yytestcase(yyruleno==268); + /* (269) plus_opt ::= */ + //yytestcase(yyruleno==269); + /* (279) foreach_clause ::= */ + //yytestcase(yyruleno==279); + /* (280) foreach_clause ::= FOR EACH ROW */ + //yytestcase(yyruleno==280); + /* (287) tridxby ::= */ + //yytestcase(yyruleno==287); + /* (305) database_kw_opt ::= DATABASE */ + //yytestcase(yyruleno==305); + /* (306) database_kw_opt ::= */ + //yytestcase(yyruleno==306); + /* (314) kwcolumn_opt ::= */ + //yytestcase(yyruleno==314); + /* (315) kwcolumn_opt ::= COLUMNKW */ + //yytestcase(yyruleno==315); + /* (319) vtabarglist ::= vtabarg */ + //yytestcase(yyruleno==319); + /* (320) vtabarglist ::= vtabarglist COMMA vtabarg */ + //yytestcase(yyruleno==320); + /* (322) vtabarg ::= vtabarg vtabargtoken */ + //yytestcase(yyruleno==322); + /* (326) anylist ::= */ + //yytestcase(yyruleno==326); + /* (327) anylist ::= anylist LP anylist RP */ + //yytestcase(yyruleno==327); + /* (328) anylist ::= anylist ANY */ + //yytestcase(yyruleno==328); + break; + }; + yygoto = yyRuleInfo[yyruleno].lhs; + yysize = yyRuleInfo[yyruleno].nrhs; + yypParser.yyidx -= yysize; + yyact = yy_find_reduce_action(yymsp[-yysize].stateno, (YYCODETYPE)yygoto); + if (yyact < YYNSTATE) { #if NDEBUG /* If we are not debugging and the reduce action popped at least ** one element off the stack, then we can push the new element back @@ -4081,120 +3989,111 @@ int yyruleno /* Number of the rule by which to reduce */ yymsp[0].minor = yygotominor; }else #endif - { - yy_shift( yypParser, yyact, yygoto, yygotominor ); + { + yy_shift(yypParser, yyact, yygoto, yygotominor); + } + } else { + Debug.Assert(yyact == YYNSTATE + YYNRULE + 1); + yy_accept(yypParser); + } } - } - else - { - Debug.Assert( yyact == YYNSTATE + YYNRULE + 1 ); - yy_accept( yypParser ); - } - } - /* - ** The following code executes when the parse fails - */ + /* + ** The following code executes when the parse fails + */ #if !YYNOERRORRECOVERY - static void yy_parse_failed( - yyParser yypParser /* The parser */ - ) - { - Parse pParse = yypParser.pParse; // sqlite3ParserARG_FETCH; + static void yy_parse_failed( + yyParser yypParser /* The parser */ + ) { + Parse pParse = yypParser.pParse; // sqlite3ParserARG_FETCH; #if !NDEBUG - if ( yyTraceFILE != null ) - { - Debugger.Break(); // TODO -- fprintf(yyTraceFILE, "%sFail!\n", yyTracePrompt); - } + if (yyTraceFILE != null) { + Debugger.Break(); // TODO -- fprintf(yyTraceFILE, "%sFail!\n", yyTracePrompt); + } #endif - while ( yypParser.yyidx >= 0 ) - yy_pop_parser_stack( yypParser ); - /* Here code is inserted which will be executed whenever the - ** parser fails */ - yypParser.pParse = pParse;// sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ - } + while (yypParser.yyidx >= 0) + yy_pop_parser_stack(yypParser); + /* Here code is inserted which will be executed whenever the + ** parser fails */ + yypParser.pParse = pParse;// sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ + } #endif //* YYNOERRORRECOVERY */ - /* -** The following code executes when a syntax error first occurs. -*/ - static void yy_syntax_error( - yyParser yypParser, /* The parser */ - int yymajor, /* The major type of the error token */ - YYMINORTYPE yyminor /* The minor type of the error token */ - ) - { - Parse pParse = yypParser.pParse; // sqlite3ParserARG_FETCH; - //#define TOKEN (yyminor.yy0) - //#line 32 "parse.y" + /* + ** The following code executes when a syntax error first occurs. + */ + static void yy_syntax_error( + yyParser yypParser, /* The parser */ + int yymajor, /* The major type of the error token */ + YYMINORTYPE yyminor /* The minor type of the error token */ + ) { + Parse pParse = yypParser.pParse; // sqlite3ParserARG_FETCH; + //#define TOKEN (yyminor.yy0) + //#line 32 "parse.y" - UNUSED_PARAMETER( yymajor ); /* Silence some compiler warnings */ - Debug.Assert( yyminor.yy0.z.Length > 0 ); //TOKEN.z[0]); /* The tokenizer always gives us a token */ - sqlite3ErrorMsg( pParse, "near \"%T\": syntax error", yyminor.yy0 );//&TOKEN); - pParse.parseError = 1; - //#line 3661 "parse.c" - yypParser.pParse = pParse; // sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ - } + UNUSED_PARAMETER(yymajor); /* Silence some compiler warnings */ + Debug.Assert(yyminor.yy0.z.Length > 0); //TOKEN.z[0]); /* The tokenizer always gives us a token */ + sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", yyminor.yy0);//&TOKEN); + pParse.parseError = 1; + //#line 3661 "parse.c" + yypParser.pParse = pParse; // sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ + } - /* - ** The following is executed when the parser accepts - */ - static void yy_accept( - yyParser yypParser /* The parser */ - ) - { - Parse pParse = yypParser.pParse; // sqlite3ParserARG_FETCH; + /* + ** The following is executed when the parser accepts + */ + static void yy_accept( + yyParser yypParser /* The parser */ + ) { + Parse pParse = yypParser.pParse; // sqlite3ParserARG_FETCH; #if !NDEBUG - if ( yyTraceFILE != null ) - { - fprintf( yyTraceFILE, "%sAccept!\n", yyTracePrompt ); - } + if (yyTraceFILE != null) { + fprintf(yyTraceFILE, "%sAccept!\n", yyTracePrompt); + } #endif - while ( yypParser.yyidx >= 0 ) - yy_pop_parser_stack( yypParser ); - /* Here code is inserted which will be executed whenever the - ** parser accepts */ - yypParser.pParse = pParse;// sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ - } + while (yypParser.yyidx >= 0) + yy_pop_parser_stack(yypParser); + /* Here code is inserted which will be executed whenever the + ** parser accepts */ + yypParser.pParse = pParse;// sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ + } - /* The main parser program. - ** The first argument is a pointer to a structure obtained from - ** "sqlite3ParserAlloc" which describes the current state of the parser. - ** The second argument is the major token number. The third is - ** the minor token. The fourth optional argument is whatever the - ** user wants (and specified in the grammar) and is available for - ** use by the action routines. - ** - ** Inputs: - **
    - **
  • A pointer to the parser (an opaque structure.) - **
  • The major token number. - **
  • The minor token number. - **
  • An option argument of a grammar-specified type. - **
- ** - ** Outputs: - ** None. - */ - static void sqlite3Parser( - yyParser yyp, /* The parser */ - int yymajor, /* The major token code number */ - sqlite3ParserTOKENTYPE yyminor /* The value for the token */ - , Parse pParse //sqlite3ParserARG_PDECL /* Optional %extra_argument parameter */ - ) - { - YYMINORTYPE yyminorunion = new YYMINORTYPE(); - int yyact; /* The parser action. */ - bool yyendofinput; /* True if we are at the end of input */ + /* The main parser program. + ** The first argument is a pointer to a structure obtained from + ** "sqlite3ParserAlloc" which describes the current state of the parser. + ** The second argument is the major token number. The third is + ** the minor token. The fourth optional argument is whatever the + ** user wants (and specified in the grammar) and is available for + ** use by the action routines. + ** + ** Inputs: + **
    + **
  • A pointer to the parser (an opaque structure.) + **
  • The major token number. + **
  • The minor token number. + **
  • An option argument of a grammar-specified type. + **
+ ** + ** Outputs: + ** None. + */ + static void sqlite3Parser( + yyParser yyp, /* The parser */ + int yymajor, /* The major token code number */ + sqlite3ParserTOKENTYPE yyminor /* The value for the token */ + , Parse pParse //sqlite3ParserARG_PDECL /* Optional %extra_argument parameter */ + ) { + YYMINORTYPE yyminorunion = new YYMINORTYPE(); + int yyact; /* The parser action. */ + bool yyendofinput; /* True if we are at the end of input */ #if YYERRORSYMBOL int yyerrorhit = null; /* True if yymajor has invoked an error */ #endif - yyParser yypParser; /* The parser */ + yyParser yypParser; /* The parser */ - /* (re)initialize the parser, if necessary */ - yypParser = yyp; - if ( yypParser.yyidx < 0 ) - { + /* (re)initialize the parser, if necessary */ + yypParser = yyp; + if (yypParser.yyidx < 0) { #if YYSTACKDEPTH//<=0 if( yypParser.yystksz <=0 ){ memset(yyminorunion, 0, yyminorunion).Length; @@ -4202,48 +4101,40 @@ static void sqlite3Parser( return; } #endif - yypParser.yyidx = 0; - yypParser.yyerrcnt = -1; - yypParser.yystack[0] = new yyStackEntry(); - yypParser.yystack[0].stateno = 0; - yypParser.yystack[0].major = 0; - } - yyminorunion.yy0 = yyminor.Copy(); - yyendofinput = ( yymajor == 0 ); - yypParser.pParse = pParse;// sqlite3ParserARG_STORE; + yypParser.yyidx = 0; + yypParser.yyerrcnt = -1; + yypParser.yystack[0] = new yyStackEntry(); + yypParser.yystack[0].stateno = 0; + yypParser.yystack[0].major = 0; + } + yyminorunion.yy0 = yyminor.Copy(); + yyendofinput = (yymajor == 0); + yypParser.pParse = pParse;// sqlite3ParserARG_STORE; #if !NDEBUG - if ( yyTraceFILE != null ) - { - fprintf( yyTraceFILE, "%sInput %s\n", yyTracePrompt, yyTokenName[yymajor] ); - } + if (yyTraceFILE != null) { + fprintf(yyTraceFILE, "%sInput %s\n", yyTracePrompt, yyTokenName[yymajor]); + } #endif - do - { - yyact = yy_find_shift_action( yypParser, (YYCODETYPE)yymajor ); - if ( yyact < YYNSTATE ) - { - Debug.Assert( !yyendofinput ); /* Impossible to shift the $ token */ - yy_shift( yypParser, yyact, yymajor, yyminorunion ); - yypParser.yyerrcnt--; - yymajor = YYNOCODE; - } - else if ( yyact < YYNSTATE + YYNRULE ) - { - yy_reduce( yypParser, yyact - YYNSTATE ); - } - else - { - Debug.Assert( yyact == YY_ERROR_ACTION ); + do { + yyact = yy_find_shift_action(yypParser, (YYCODETYPE)yymajor); + if (yyact < YYNSTATE) { + Debug.Assert(!yyendofinput); /* Impossible to shift the $ token */ + yy_shift(yypParser, yyact, yymajor, yyminorunion); + yypParser.yyerrcnt--; + yymajor = YYNOCODE; + } else if (yyact < YYNSTATE + YYNRULE) { + yy_reduce(yypParser, yyact - YYNSTATE); + } else { + Debug.Assert(yyact == YY_ERROR_ACTION); #if YYERRORSYMBOL int yymx; #endif #if !NDEBUG - if ( yyTraceFILE != null ) - { - Debugger.Break(); // TODO -- fprintf(yyTraceFILE, "%sSyntax Error!\n", yyTracePrompt); - } + if (yyTraceFILE != null) { + Debugger.Break(); // TODO -- fprintf(yyTraceFILE, "%sSyntax Error!\n", yyTracePrompt); + } #endif #if YYERRORSYMBOL /* A syntax error has occurred. @@ -4312,49 +4203,44 @@ static void sqlite3Parser( yy_destructor(yypParser,(YYCODETYPE)yymajor,yyminorunion); yymajor = YYNOCODE; #else // * YYERRORSYMBOL is not defined */ - /* This is what we do if the grammar does not define ERROR: -** -** * Report an error message, and throw away the input token. -** -** * If the input token is $, then fail the parse. -** -** As before, subsequent error messages are suppressed until -** three input tokens have been successfully shifted. -*/ - if ( yypParser.yyerrcnt <= 0 ) - { - yy_syntax_error( yypParser, yymajor, yyminorunion ); - } - yypParser.yyerrcnt = 3; - yy_destructor( yypParser, (YYCODETYPE)yymajor, yyminorunion ); - if ( yyendofinput ) - { - yy_parse_failed( yypParser ); - } - yymajor = YYNOCODE; + /* This is what we do if the grammar does not define ERROR: + ** + ** * Report an error message, and throw away the input token. + ** + ** * If the input token is $, then fail the parse. + ** + ** As before, subsequent error messages are suppressed until + ** three input tokens have been successfully shifted. + */ + if (yypParser.yyerrcnt <= 0) { + yy_syntax_error(yypParser, yymajor, yyminorunion); + } + yypParser.yyerrcnt = 3; + yy_destructor(yypParser, (YYCODETYPE)yymajor, yyminorunion); + if (yyendofinput) { + yy_parse_failed(yypParser); + } + yymajor = YYNOCODE; #endif + } + } while (yymajor != YYNOCODE && yypParser.yyidx >= 0); + return; } - } while ( yymajor != YYNOCODE && yypParser.yyidx >= 0 ); - return; - } - public class yymsp - { - public yyParser _yyParser; - public int _yyidx; - // CONSTRUCTOR - public yymsp( ref yyParser pointer_to_yyParser, int yyidx ) //' Parser and Stack Index - { - this._yyParser = pointer_to_yyParser; - this._yyidx = yyidx; - } - // Default Value - public yyStackEntry this[int offset] - { - get - { - return _yyParser.yystack[_yyidx + offset]; + public class yymsp { + public yyParser _yyParser; + public int _yyidx; + // CONSTRUCTOR + public yymsp(ref yyParser pointer_to_yyParser, int yyidx) //' Parser and Stack Index + { + this._yyParser = pointer_to_yyParser; + this._yyidx = yyidx; + } + // Default Value + public yyStackEntry this[int offset] { + get { + return _yyParser.yystack[_yyidx + offset]; + } + } } - } } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/parse_h.cs b/Src/IronPython.SQLite/c#sqlite/parse_h.cs index 8e08e31aa..383cfab7e 100644 --- a/Src/IronPython.SQLite/c#sqlite/parse_h.cs +++ b/Src/IronPython.SQLite/c#sqlite/parse_h.cs @@ -8,323 +8,321 @@ ************************************************************************* */ -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - //#define TK_SEMI 1 - //#define TK_EXPLAIN 2 - //#define TK_QUERY 3 - //#define TK_PLAN 4 - //#define TK_BEGIN 5 - //#define TK_TRANSACTION 6 - //#define TK_DEFERRED 7 - //#define TK_IMMEDIATE 8 - //#define TK_EXCLUSIVE 9 - //#define TK_COMMIT 10 - //#define TK_END 11 - //#define TK_ROLLBACK 12 - //#define TK_SAVEPOINT 13 - //#define TK_RELEASE 14 - //#define TK_TO 15 - //#define TK_TABLE 16 - //#define TK_CREATE 17 - //#define TK_IF 18 - //#define TK_NOT 19 - //#define TK_EXISTS 20 - //#define TK_TEMP 21 - //#define TK_LP 22 - //#define TK_RP 23 - //#define TK_AS 24 - //#define TK_COMMA 25 - //#define TK_ID 26 - //#define TK_INDEXED 27 - //#define TK_ABORT 28 - //#define TK_ACTION 29 - //#define TK_AFTER 30 - //#define TK_ANALYZE 31 - //#define TK_ASC 32 - //#define TK_ATTACH 33 - //#define TK_BEFORE 34 - //#define TK_BY 35 - //#define TK_CASCADE 36 - //#define TK_CAST 37 - //#define TK_COLUMNKW 38 - //#define TK_CONFLICT 39 - //#define TK_DATABASE 40 - //#define TK_DESC 41 - //#define TK_DETACH 42 - //#define TK_EACH 43 - //#define TK_FAIL 44 - //#define TK_FOR 45 - //#define TK_IGNORE 46 - //#define TK_INITIALLY 47 - //#define TK_INSTEAD 48 - //#define TK_LIKE_KW 49 - //#define TK_MATCH 50 - //#define TK_NO 51 - //#define TK_KEY 52 - //#define TK_OF 53 - //#define TK_OFFSET 54 - //#define TK_PRAGMA 55 - //#define TK_RAISE 56 - //#define TK_REPLACE 57 - //#define TK_RESTRICT 58 - //#define TK_ROW 59 - //#define TK_TRIGGER 60 - //#define TK_VACUUM 61 - //#define TK_VIEW 62 - //#define TK_VIRTUAL 63 - //#define TK_REINDEX 64 - //#define TK_RENAME 65 - //#define TK_CTIME_KW 66 - //#define TK_ANY 67 - //#define TK_OR 68 - //#define TK_AND 69 - //#define TK_IS 70 - //#define TK_BETWEEN 71 - //#define TK_IN 72 - //#define TK_ISNULL 73 - //#define TK_NOTNULL 74 - //#define TK_NE 75 - //#define TK_EQ 76 - //#define TK_GT 77 - //#define TK_LE 78 - //#define TK_LT 79 - //#define TK_GE 80 - //#define TK_ESCAPE 81 - //#define TK_BITAND 82 - //#define TK_BITOR 83 - //#define TK_LSHIFT 84 - //#define TK_RSHIFT 85 - //#define TK_PLUS 86 - //#define TK_MINUS 87 - //#define TK_STAR 88 - //#define TK_SLASH 89 - //#define TK_REM 90 - //#define TK_CONCAT 91 - //#define TK_COLLATE 92 - //#define TK_BITNOT 93 - //#define TK_STRING 94 - //#define TK_JOIN_KW 95 - //#define TK_CONSTRAINT 96 - //#define TK_DEFAULT 97 - //#define TK_NULL 98 - //#define TK_PRIMARY 99 - //#define TK_UNIQUE 100 - //#define TK_CHECK 101 - //#define TK_REFERENCES 102 - //#define TK_AUTOINCR 103 - //#define TK_ON 104 - //#define TK_INSERT 105 - //#define TK_DELETE 106 - //#define TK_UPDATE 107 - //#define TK_SET 108 - //#define TK_DEFERRABLE 109 - //#define TK_FOREIGN 110 - //#define TK_DROP 111 - //#define TK_UNION 112 - //#define TK_ALL 113 - //#define TK_EXCEPT 114 - //#define TK_INTERSECT 115 - //#define TK_SELECT 116 - //#define TK_DISTINCT 117 - //#define TK_DOT 118 - //#define TK_FROM 119 - //#define TK_JOIN 120 - //#define TK_USING 121 - //#define TK_ORDER 122 - //#define TK_GROUP 123 - //#define TK_HAVING 124 - //#define TK_LIMIT 125 - //#define TK_WHERE 126 - //#define TK_INTO 127 - //#define TK_VALUES 128 - //#define TK_INTEGER 129 - //#define TK_FLOAT 130 - //#define TK_BLOB 131 - //#define TK_REGISTER 132 - //#define TK_VARIABLE 133 - //#define TK_CASE 134 - //#define TK_WHEN 135 - //#define TK_THEN 136 - //#define TK_ELSE 137 - //#define TK_INDEX 138 - //#define TK_ALTER 139 - //#define TK_ADD 140 - //#define TK_TO_TEXT 141 - //#define TK_TO_BLOB 142 - //#define TK_TO_NUMERIC 143 - //#define TK_TO_INT 144 - //#define TK_TO_REAL 145 - //#define TK_ISNOT 146 - //#define TK_END_OF_FILE 147 - //#define TK_ILLEGAL 148 - //#define TK_SPACE 149 - //#define TK_UNCLOSED_STRING 150 - //#define TK_FUNCTION 151 - //#define TK_COLUMN 152 - //#define TK_AGG_FUNCTION 153 - //#define TK_AGG_COLUMN 154 - //#define TK_CONST_FUNC 155 - //#define TK_UMINUS 156 - //#define TK_UPLUS 157 - public const int TK_SEMI = 1; - public const int TK_EXPLAIN = 2; - public const int TK_QUERY = 3; - public const int TK_PLAN = 4; - public const int TK_BEGIN = 5; - public const int TK_TRANSACTION = 6; - public const int TK_DEFERRED = 7; - public const int TK_IMMEDIATE = 8; - public const int TK_EXCLUSIVE = 9; - public const int TK_COMMIT = 10; - public const int TK_END = 11; - public const int TK_ROLLBACK = 12; - public const int TK_SAVEPOINT = 13; - public const int TK_RELEASE = 14; - public const int TK_TO = 15; - public const int TK_TABLE = 16; - public const int TK_CREATE = 17; - public const int TK_IF = 18; - public const int TK_NOT = 19; - public const int TK_EXISTS = 20; - public const int TK_TEMP = 21; - public const int TK_LP = 22; - public const int TK_RP = 23; - public const int TK_AS = 24; - public const int TK_COMMA = 25; - public const int TK_ID = 26; - public const int TK_INDEXED = 27; - public const int TK_ABORT = 28; - public const int TK_ACTION = 29; - public const int TK_AFTER = 30; - public const int TK_ANALYZE = 31; - public const int TK_ASC = 32; - public const int TK_ATTACH = 33; - public const int TK_BEFORE = 34; - public const int TK_BY = 35; - public const int TK_CASCADE = 36; - public const int TK_CAST = 37; - public const int TK_COLUMNKW = 38; - public const int TK_CONFLICT = 39; - public const int TK_DATABASE = 40; - public const int TK_DESC = 41; - public const int TK_DETACH = 42; - public const int TK_EACH = 43; - public const int TK_FAIL = 44; - public const int TK_FOR = 45; - public const int TK_IGNORE = 46; - public const int TK_INITIALLY = 47; - public const int TK_INSTEAD = 48; - public const int TK_LIKE_KW = 49; - public const int TK_MATCH = 50; - public const int TK_NO = 51; - public const int TK_KEY = 52; - public const int TK_OF = 53; - public const int TK_OFFSET = 54; - public const int TK_PRAGMA = 55; - public const int TK_RAISE = 56; - public const int TK_REPLACE = 57; - public const int TK_RESTRICT = 58; - public const int TK_ROW = 59; - public const int TK_TRIGGER = 60; - public const int TK_VACUUM = 61; - public const int TK_VIEW = 62; - public const int TK_VIRTUAL = 63; - public const int TK_REINDEX = 64; - public const int TK_RENAME = 65; - public const int TK_CTIME_KW = 66; - public const int TK_ANY = 67; - public const int TK_OR = 68; - public const int TK_AND = 69; - public const int TK_IS = 70; - public const int TK_BETWEEN = 71; - public const int TK_IN = 72; - public const int TK_ISNULL = 73; - public const int TK_NOTNULL = 74; - public const int TK_NE = 75; - public const int TK_EQ = 76; - public const int TK_GT = 77; - public const int TK_LE = 78; - public const int TK_LT = 79; - public const int TK_GE = 80; - public const int TK_ESCAPE = 81; - public const int TK_BITAND = 82; - public const int TK_BITOR = 83; - public const int TK_LSHIFT = 84; - public const int TK_RSHIFT = 85; - public const int TK_PLUS = 86; - public const int TK_MINUS = 87; - public const int TK_STAR = 88; - public const int TK_SLASH = 89; - public const int TK_REM = 90; - public const int TK_CONCAT = 91; - public const int TK_COLLATE = 92; - public const int TK_BITNOT = 93; - public const int TK_STRING = 94; - public const int TK_JOIN_KW = 95; - public const int TK_CONSTRAINT = 96; - public const int TK_DEFAULT = 97; - public const int TK_NULL = 98; - public const int TK_PRIMARY = 99; - public const int TK_UNIQUE = 100; - public const int TK_CHECK = 101; - public const int TK_REFERENCES = 102; - public const int TK_AUTOINCR = 103; - public const int TK_ON = 104; - public const int TK_INSERT = 105; - public const int TK_DELETE = 106; - public const int TK_UPDATE = 107; - public const int TK_SET = 108; - public const int TK_DEFERRABLE = 109; - public const int TK_FOREIGN = 110; - public const int TK_DROP = 111; - public const int TK_UNION = 112; - public const int TK_ALL = 113; - public const int TK_EXCEPT = 114; - public const int TK_INTERSECT = 115; - public const int TK_SELECT = 116; - public const int TK_DISTINCT = 117; - public const int TK_DOT = 118; - public const int TK_FROM = 119; - public const int TK_JOIN = 120; - public const int TK_USING = 121; - public const int TK_ORDER = 122; - public const int TK_GROUP = 123; - public const int TK_HAVING = 124; - public const int TK_LIMIT = 125; - public const int TK_WHERE = 126; - public const int TK_INTO = 127; - public const int TK_VALUES = 128; - public const int TK_INTEGER = 129; - public const int TK_FLOAT = 130; - public const int TK_BLOB = 131; - public const int TK_REGISTER = 132; - public const int TK_VARIABLE = 133; - public const int TK_CASE = 134; - public const int TK_WHEN = 135; - public const int TK_THEN = 136; - public const int TK_ELSE = 137; - public const int TK_INDEX = 138; - public const int TK_ALTER = 139; - public const int TK_ADD = 140; - public const int TK_TO_TEXT = 141; - public const int TK_TO_BLOB = 142; - public const int TK_TO_NUMERIC = 143; - public const int TK_TO_INT = 144; - public const int TK_TO_REAL = 145; - public const int TK_ISNOT = 146; - public const int TK_END_OF_FILE = 147; - public const int TK_ILLEGAL = 148; - public const int TK_SPACE = 149; - public const int TK_UNCLOSED_STRING = 150; - public const int TK_FUNCTION = 151; - public const int TK_COLUMN = 152; - public const int TK_AGG_FUNCTION = 153; - public const int TK_AGG_COLUMN = 154; - public const int TK_CONST_FUNC = 155; - public const int TK_UMINUS = 156; - public const int TK_UPLUS = 157; - } +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + //#define TK_SEMI 1 + //#define TK_EXPLAIN 2 + //#define TK_QUERY 3 + //#define TK_PLAN 4 + //#define TK_BEGIN 5 + //#define TK_TRANSACTION 6 + //#define TK_DEFERRED 7 + //#define TK_IMMEDIATE 8 + //#define TK_EXCLUSIVE 9 + //#define TK_COMMIT 10 + //#define TK_END 11 + //#define TK_ROLLBACK 12 + //#define TK_SAVEPOINT 13 + //#define TK_RELEASE 14 + //#define TK_TO 15 + //#define TK_TABLE 16 + //#define TK_CREATE 17 + //#define TK_IF 18 + //#define TK_NOT 19 + //#define TK_EXISTS 20 + //#define TK_TEMP 21 + //#define TK_LP 22 + //#define TK_RP 23 + //#define TK_AS 24 + //#define TK_COMMA 25 + //#define TK_ID 26 + //#define TK_INDEXED 27 + //#define TK_ABORT 28 + //#define TK_ACTION 29 + //#define TK_AFTER 30 + //#define TK_ANALYZE 31 + //#define TK_ASC 32 + //#define TK_ATTACH 33 + //#define TK_BEFORE 34 + //#define TK_BY 35 + //#define TK_CASCADE 36 + //#define TK_CAST 37 + //#define TK_COLUMNKW 38 + //#define TK_CONFLICT 39 + //#define TK_DATABASE 40 + //#define TK_DESC 41 + //#define TK_DETACH 42 + //#define TK_EACH 43 + //#define TK_FAIL 44 + //#define TK_FOR 45 + //#define TK_IGNORE 46 + //#define TK_INITIALLY 47 + //#define TK_INSTEAD 48 + //#define TK_LIKE_KW 49 + //#define TK_MATCH 50 + //#define TK_NO 51 + //#define TK_KEY 52 + //#define TK_OF 53 + //#define TK_OFFSET 54 + //#define TK_PRAGMA 55 + //#define TK_RAISE 56 + //#define TK_REPLACE 57 + //#define TK_RESTRICT 58 + //#define TK_ROW 59 + //#define TK_TRIGGER 60 + //#define TK_VACUUM 61 + //#define TK_VIEW 62 + //#define TK_VIRTUAL 63 + //#define TK_REINDEX 64 + //#define TK_RENAME 65 + //#define TK_CTIME_KW 66 + //#define TK_ANY 67 + //#define TK_OR 68 + //#define TK_AND 69 + //#define TK_IS 70 + //#define TK_BETWEEN 71 + //#define TK_IN 72 + //#define TK_ISNULL 73 + //#define TK_NOTNULL 74 + //#define TK_NE 75 + //#define TK_EQ 76 + //#define TK_GT 77 + //#define TK_LE 78 + //#define TK_LT 79 + //#define TK_GE 80 + //#define TK_ESCAPE 81 + //#define TK_BITAND 82 + //#define TK_BITOR 83 + //#define TK_LSHIFT 84 + //#define TK_RSHIFT 85 + //#define TK_PLUS 86 + //#define TK_MINUS 87 + //#define TK_STAR 88 + //#define TK_SLASH 89 + //#define TK_REM 90 + //#define TK_CONCAT 91 + //#define TK_COLLATE 92 + //#define TK_BITNOT 93 + //#define TK_STRING 94 + //#define TK_JOIN_KW 95 + //#define TK_CONSTRAINT 96 + //#define TK_DEFAULT 97 + //#define TK_NULL 98 + //#define TK_PRIMARY 99 + //#define TK_UNIQUE 100 + //#define TK_CHECK 101 + //#define TK_REFERENCES 102 + //#define TK_AUTOINCR 103 + //#define TK_ON 104 + //#define TK_INSERT 105 + //#define TK_DELETE 106 + //#define TK_UPDATE 107 + //#define TK_SET 108 + //#define TK_DEFERRABLE 109 + //#define TK_FOREIGN 110 + //#define TK_DROP 111 + //#define TK_UNION 112 + //#define TK_ALL 113 + //#define TK_EXCEPT 114 + //#define TK_INTERSECT 115 + //#define TK_SELECT 116 + //#define TK_DISTINCT 117 + //#define TK_DOT 118 + //#define TK_FROM 119 + //#define TK_JOIN 120 + //#define TK_USING 121 + //#define TK_ORDER 122 + //#define TK_GROUP 123 + //#define TK_HAVING 124 + //#define TK_LIMIT 125 + //#define TK_WHERE 126 + //#define TK_INTO 127 + //#define TK_VALUES 128 + //#define TK_INTEGER 129 + //#define TK_FLOAT 130 + //#define TK_BLOB 131 + //#define TK_REGISTER 132 + //#define TK_VARIABLE 133 + //#define TK_CASE 134 + //#define TK_WHEN 135 + //#define TK_THEN 136 + //#define TK_ELSE 137 + //#define TK_INDEX 138 + //#define TK_ALTER 139 + //#define TK_ADD 140 + //#define TK_TO_TEXT 141 + //#define TK_TO_BLOB 142 + //#define TK_TO_NUMERIC 143 + //#define TK_TO_INT 144 + //#define TK_TO_REAL 145 + //#define TK_ISNOT 146 + //#define TK_END_OF_FILE 147 + //#define TK_ILLEGAL 148 + //#define TK_SPACE 149 + //#define TK_UNCLOSED_STRING 150 + //#define TK_FUNCTION 151 + //#define TK_COLUMN 152 + //#define TK_AGG_FUNCTION 153 + //#define TK_AGG_COLUMN 154 + //#define TK_CONST_FUNC 155 + //#define TK_UMINUS 156 + //#define TK_UPLUS 157 + public const int TK_SEMI = 1; + public const int TK_EXPLAIN = 2; + public const int TK_QUERY = 3; + public const int TK_PLAN = 4; + public const int TK_BEGIN = 5; + public const int TK_TRANSACTION = 6; + public const int TK_DEFERRED = 7; + public const int TK_IMMEDIATE = 8; + public const int TK_EXCLUSIVE = 9; + public const int TK_COMMIT = 10; + public const int TK_END = 11; + public const int TK_ROLLBACK = 12; + public const int TK_SAVEPOINT = 13; + public const int TK_RELEASE = 14; + public const int TK_TO = 15; + public const int TK_TABLE = 16; + public const int TK_CREATE = 17; + public const int TK_IF = 18; + public const int TK_NOT = 19; + public const int TK_EXISTS = 20; + public const int TK_TEMP = 21; + public const int TK_LP = 22; + public const int TK_RP = 23; + public const int TK_AS = 24; + public const int TK_COMMA = 25; + public const int TK_ID = 26; + public const int TK_INDEXED = 27; + public const int TK_ABORT = 28; + public const int TK_ACTION = 29; + public const int TK_AFTER = 30; + public const int TK_ANALYZE = 31; + public const int TK_ASC = 32; + public const int TK_ATTACH = 33; + public const int TK_BEFORE = 34; + public const int TK_BY = 35; + public const int TK_CASCADE = 36; + public const int TK_CAST = 37; + public const int TK_COLUMNKW = 38; + public const int TK_CONFLICT = 39; + public const int TK_DATABASE = 40; + public const int TK_DESC = 41; + public const int TK_DETACH = 42; + public const int TK_EACH = 43; + public const int TK_FAIL = 44; + public const int TK_FOR = 45; + public const int TK_IGNORE = 46; + public const int TK_INITIALLY = 47; + public const int TK_INSTEAD = 48; + public const int TK_LIKE_KW = 49; + public const int TK_MATCH = 50; + public const int TK_NO = 51; + public const int TK_KEY = 52; + public const int TK_OF = 53; + public const int TK_OFFSET = 54; + public const int TK_PRAGMA = 55; + public const int TK_RAISE = 56; + public const int TK_REPLACE = 57; + public const int TK_RESTRICT = 58; + public const int TK_ROW = 59; + public const int TK_TRIGGER = 60; + public const int TK_VACUUM = 61; + public const int TK_VIEW = 62; + public const int TK_VIRTUAL = 63; + public const int TK_REINDEX = 64; + public const int TK_RENAME = 65; + public const int TK_CTIME_KW = 66; + public const int TK_ANY = 67; + public const int TK_OR = 68; + public const int TK_AND = 69; + public const int TK_IS = 70; + public const int TK_BETWEEN = 71; + public const int TK_IN = 72; + public const int TK_ISNULL = 73; + public const int TK_NOTNULL = 74; + public const int TK_NE = 75; + public const int TK_EQ = 76; + public const int TK_GT = 77; + public const int TK_LE = 78; + public const int TK_LT = 79; + public const int TK_GE = 80; + public const int TK_ESCAPE = 81; + public const int TK_BITAND = 82; + public const int TK_BITOR = 83; + public const int TK_LSHIFT = 84; + public const int TK_RSHIFT = 85; + public const int TK_PLUS = 86; + public const int TK_MINUS = 87; + public const int TK_STAR = 88; + public const int TK_SLASH = 89; + public const int TK_REM = 90; + public const int TK_CONCAT = 91; + public const int TK_COLLATE = 92; + public const int TK_BITNOT = 93; + public const int TK_STRING = 94; + public const int TK_JOIN_KW = 95; + public const int TK_CONSTRAINT = 96; + public const int TK_DEFAULT = 97; + public const int TK_NULL = 98; + public const int TK_PRIMARY = 99; + public const int TK_UNIQUE = 100; + public const int TK_CHECK = 101; + public const int TK_REFERENCES = 102; + public const int TK_AUTOINCR = 103; + public const int TK_ON = 104; + public const int TK_INSERT = 105; + public const int TK_DELETE = 106; + public const int TK_UPDATE = 107; + public const int TK_SET = 108; + public const int TK_DEFERRABLE = 109; + public const int TK_FOREIGN = 110; + public const int TK_DROP = 111; + public const int TK_UNION = 112; + public const int TK_ALL = 113; + public const int TK_EXCEPT = 114; + public const int TK_INTERSECT = 115; + public const int TK_SELECT = 116; + public const int TK_DISTINCT = 117; + public const int TK_DOT = 118; + public const int TK_FROM = 119; + public const int TK_JOIN = 120; + public const int TK_USING = 121; + public const int TK_ORDER = 122; + public const int TK_GROUP = 123; + public const int TK_HAVING = 124; + public const int TK_LIMIT = 125; + public const int TK_WHERE = 126; + public const int TK_INTO = 127; + public const int TK_VALUES = 128; + public const int TK_INTEGER = 129; + public const int TK_FLOAT = 130; + public const int TK_BLOB = 131; + public const int TK_REGISTER = 132; + public const int TK_VARIABLE = 133; + public const int TK_CASE = 134; + public const int TK_WHEN = 135; + public const int TK_THEN = 136; + public const int TK_ELSE = 137; + public const int TK_INDEX = 138; + public const int TK_ALTER = 139; + public const int TK_ADD = 140; + public const int TK_TO_TEXT = 141; + public const int TK_TO_BLOB = 142; + public const int TK_TO_NUMERIC = 143; + public const int TK_TO_INT = 144; + public const int TK_TO_REAL = 145; + public const int TK_ISNOT = 146; + public const int TK_END_OF_FILE = 147; + public const int TK_ILLEGAL = 148; + public const int TK_SPACE = 149; + public const int TK_UNCLOSED_STRING = 150; + public const int TK_FUNCTION = 151; + public const int TK_COLUMN = 152; + public const int TK_AGG_FUNCTION = 153; + public const int TK_AGG_COLUMN = 154; + public const int TK_CONST_FUNC = 155; + public const int TK_UMINUS = 156; + public const int TK_UPLUS = 157; + } } diff --git a/Src/IronPython.SQLite/c#sqlite/pcache1_c.cs b/Src/IronPython.SQLite/c#sqlite/pcache1_c.cs index 34e4ab00b..9d834aa74 100644 --- a/Src/IronPython.SQLite/c#sqlite/pcache1_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/pcache1_c.cs @@ -1,358 +1,332 @@ using System.Diagnostics; -using u32 = System.UInt32; using Pgno = System.UInt32; -namespace Community.CsharpSqlite -{ - using sqlite3_pcache = Sqlite3.PCache1; - public partial class Sqlite3 - { - /* - ** 2008 November 05 - ** - ** 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 implements the default page cache implementation (the - ** sqlite3_pcache interface). It also contains part of the implementation - ** of the SQLITE_CONFIG_PAGECACHE and sqlite3_release_memory() features. - ** If the default page cache implementation is overriden, then neither of - ** these two features are available. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - - //#include "sqliteInt.h" - - //typedef struct PCache1 PCache1; - //typedef struct PgHdr1 PgHdr1; - //typedef struct PgFreeslot PgFreeslot; - //typedef struct PGroup PGroup; - - /* Each page cache (or PCache) belongs to a PGroup. A PGroup is a set - ** of one or more PCaches that are able to recycle each others unpinned - ** pages when they are under memory pressure. A PGroup is an instance of - ** the following object. - ** - ** This page cache implementation works in one of two modes: - ** - ** (1) Every PCache is the sole member of its own PGroup. There is - ** one PGroup per PCache. - ** - ** (2) There is a single global PGroup that all PCaches are a member - ** of. - ** - ** Mode 1 uses more memory (since PCache instances are not able to rob - ** unused pages from other PCaches) but it also operates without a mutex, - ** and is therefore often faster. Mode 2 requires a mutex in order to be - ** threadsafe, but is able recycle pages more efficient. - ** - ** For mode (1), PGroup.mutex is NULL. For mode (2) there is only a single - ** PGroup which is the pcache1.grp global variable and its mutex is - ** SQLITE_MUTEX_STATIC_LRU. - */ - public class PGroup - { - public sqlite3_mutex mutex; /* MUTEX_STATIC_LRU or NULL */ - public int nMaxPage; /* Sum of nMax for purgeable caches */ - public int nMinPage; /* Sum of nMin for purgeable caches */ - public int mxPinned; /* nMaxpage + 10 - nMinPage */ - public int nCurrentPage; /* Number of purgeable pages allocated */ - public PgHdr1 pLruHead, pLruTail; /* LRU list of unpinned pages */ - // C# - public PGroup() - { - mutex = new sqlite3_mutex(); - } - }; - - /* Each page cache is an instance of the following object. Every - ** open database file (including each in-memory database and each - ** temporary or transient database) has a single page cache which - ** is an instance of this object. - ** - ** Pointers to structures of this type are cast and returned as - ** opaque sqlite3_pcache* handles. - */ - public class PCache1 - { - /* Cache configuration parameters. Page size (szPage) and the purgeable - ** flag (bPurgeable) are set when the cache is created. nMax may be - ** modified at any time by a call to the pcache1CacheSize() method. - ** The PGroup mutex must be held when accessing nMax. - */ - public PGroup pGroup; /* PGroup this cache belongs to */ - public int szPage; /* Size of allocated pages in bytes */ - public bool bPurgeable; /* True if cache is purgeable */ - public int nMin; /* Minimum number of pages reserved */ - public int nMax; /* Configured "cache_size" value */ - public int n90pct; /* nMax*9/10 */ - - /* Hash table of all pages. The following variables may only be accessed - ** when the accessor is holding the PGroup mutex. - */ - public int nRecyclable; /* Number of pages in the LRU list */ - public int nPage; /* Total number of pages in apHash */ - public int nHash; /* Number of slots in apHash[] */ - public PgHdr1[] apHash; /* Hash table for fast lookup by key */ - - public Pgno iMaxKey; /* Largest key seen since xTruncate() */ - - public void Clear() - { - nRecyclable = 0; - nPage = 0; - nHash = 0; - apHash = null; - iMaxKey = 0; - } - }; - - /* - ** Each cache entry is represented by an instance of the following - ** structure. A buffer of PgHdr1.pCache.szPage bytes is allocated - ** directly before this structure in memory (see the PGHDR1_TO_PAGE() - ** macro below). - */ - public class PgHdr1 - { - public Pgno iKey; /* Key value (page number) */ - public PgHdr1 pNext; /* Next in hash table chain */ - public PCache1 pCache; /* Cache that currently owns this page */ - public PgHdr1 pLruNext; /* Next in LRU list of unpinned pages */ - public PgHdr1 pLruPrev; /* Previous in LRU list of unpinned pages */ - - // For C# - public PgHdr pPgHdr = new PgHdr(); /* Pointer to Actual Page Header */ - - public void Clear() - { - this.iKey = 0; - this.pNext = null; - this.pCache = null; - this.pPgHdr.Clear(); - } - - }; - - /* - ** Free slots in the allocator used to divide up the buffer provided using - ** the SQLITE_CONFIG_PAGECACHE mechanism. - */ - public class PgFreeslot - { - public PgFreeslot pNext; /* Next free slot */ - public PgHdr _PgHdr; /* Next Free Header */ - }; - - /* - ** Global data used by this cache. - */ - public class PCacheGlobal - { - public PGroup grp; /* The global PGroup for mode (2) */ - - /* Variables related to SQLITE_CONFIG_PAGECACHE settings. The - ** szSlot, nSlot, pStart, pEnd, nReserve, and isInit values are all - ** fixed at sqlite3_initialize() time and do not require mutex protection. - ** The nFreeSlot and pFree values do require mutex protection. - */ - public bool isInit; /* True if initialized */ - public int szSlot; /* Size of each free slot */ - public int nSlot; /* The number of pcache slots */ - public int nReserve; /* Try to keep nFreeSlot above this */ - public object pStart, pEnd; /* Bounds of pagecache malloc range */ - /* Above requires no mutex. Use mutex below for variable that follow. */ - public sqlite3_mutex mutex; /* Mutex for accessing the following: */ - public int nFreeSlot; /* Number of unused pcache slots */ - public PgFreeslot pFree; /* Free page blocks */ - /* The following value requires a mutex to change. We skip the mutex on - ** reading because (1) most platforms read a 32-bit integer atomically and - ** (2) even if an incorrect value is read, no great harm is done since this - ** is really just an optimization. */ - public bool bUnderPressure; /* True if low on PAGECACHE memory */ - - // C# - public PCacheGlobal() - { - grp = new PGroup(); - } - } - static PCacheGlobal pcache = new PCacheGlobal(); - - /* - ** All code in this file should access the global structure above via the - ** alias "pcache1". This ensures that the WSD emulation is used when - ** compiling for systems that do not support real WSD. - */ - //#define pcache1 (GLOBAL(struct PCacheGlobal, pcache1_g)) - static PCacheGlobal pcache1 = pcache; +namespace Community.CsharpSqlite { + using sqlite3_pcache = Sqlite3.PCache1; + public partial class Sqlite3 { + /* + ** 2008 November 05 + ** + ** 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 implements the default page cache implementation (the + ** sqlite3_pcache interface). It also contains part of the implementation + ** of the SQLITE_CONFIG_PAGECACHE and sqlite3_release_memory() features. + ** If the default page cache implementation is overriden, then neither of + ** these two features are available. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ - /* - ** When a PgHdr1 structure is allocated, the associated PCache1.szPage - ** bytes of data are located directly before it in memory (i.e. the total - ** size of the allocation is sizeof(PgHdr1)+PCache1.szPage byte). The - ** PGHDR1_TO_PAGE() macro takes a pointer to a PgHdr1 structure as - ** an argument and returns a pointer to the associated block of szPage - ** bytes. The PAGE_TO_PGHDR1() macro does the opposite: its argument is - ** a pointer to a block of szPage bytes of data and the return value is - ** a pointer to the associated PgHdr1 structure. - ** - ** Debug.Assert( PGHDR1_TO_PAGE(PAGE_TO_PGHDR1(pCache, X))==X ); - */ - //#define PGHDR1_TO_PAGE(p) (void)(((char)p) - p.pCache.szPage) - static PgHdr PGHDR1_TO_PAGE( PgHdr1 p ) - { - return p.pPgHdr; - } + //#include "sqliteInt.h" + + //typedef struct PCache1 PCache1; + //typedef struct PgHdr1 PgHdr1; + //typedef struct PgFreeslot PgFreeslot; + //typedef struct PGroup PGroup; + + /* Each page cache (or PCache) belongs to a PGroup. A PGroup is a set + ** of one or more PCaches that are able to recycle each others unpinned + ** pages when they are under memory pressure. A PGroup is an instance of + ** the following object. + ** + ** This page cache implementation works in one of two modes: + ** + ** (1) Every PCache is the sole member of its own PGroup. There is + ** one PGroup per PCache. + ** + ** (2) There is a single global PGroup that all PCaches are a member + ** of. + ** + ** Mode 1 uses more memory (since PCache instances are not able to rob + ** unused pages from other PCaches) but it also operates without a mutex, + ** and is therefore often faster. Mode 2 requires a mutex in order to be + ** threadsafe, but is able recycle pages more efficient. + ** + ** For mode (1), PGroup.mutex is NULL. For mode (2) there is only a single + ** PGroup which is the pcache1.grp global variable and its mutex is + ** SQLITE_MUTEX_STATIC_LRU. + */ + public class PGroup { + public sqlite3_mutex mutex; /* MUTEX_STATIC_LRU or NULL */ + public int nMaxPage; /* Sum of nMax for purgeable caches */ + public int nMinPage; /* Sum of nMin for purgeable caches */ + public int mxPinned; /* nMaxpage + 10 - nMinPage */ + public int nCurrentPage; /* Number of purgeable pages allocated */ + public PgHdr1 pLruHead, pLruTail; /* LRU list of unpinned pages */ + // C# + public PGroup() { + mutex = new sqlite3_mutex(); + } + }; + + /* Each page cache is an instance of the following object. Every + ** open database file (including each in-memory database and each + ** temporary or transient database) has a single page cache which + ** is an instance of this object. + ** + ** Pointers to structures of this type are cast and returned as + ** opaque sqlite3_pcache* handles. + */ + public class PCache1 { + /* Cache configuration parameters. Page size (szPage) and the purgeable + ** flag (bPurgeable) are set when the cache is created. nMax may be + ** modified at any time by a call to the pcache1CacheSize() method. + ** The PGroup mutex must be held when accessing nMax. + */ + public PGroup pGroup; /* PGroup this cache belongs to */ + public int szPage; /* Size of allocated pages in bytes */ + public bool bPurgeable; /* True if cache is purgeable */ + public int nMin; /* Minimum number of pages reserved */ + public int nMax; /* Configured "cache_size" value */ + public int n90pct; /* nMax*9/10 */ + + /* Hash table of all pages. The following variables may only be accessed + ** when the accessor is holding the PGroup mutex. + */ + public int nRecyclable; /* Number of pages in the LRU list */ + public int nPage; /* Total number of pages in apHash */ + public int nHash; /* Number of slots in apHash[] */ + public PgHdr1[] apHash; /* Hash table for fast lookup by key */ + + public Pgno iMaxKey; /* Largest key seen since xTruncate() */ + + public void Clear() { + nRecyclable = 0; + nPage = 0; + nHash = 0; + apHash = null; + iMaxKey = 0; + } + }; + + /* + ** Each cache entry is represented by an instance of the following + ** structure. A buffer of PgHdr1.pCache.szPage bytes is allocated + ** directly before this structure in memory (see the PGHDR1_TO_PAGE() + ** macro below). + */ + public class PgHdr1 { + public Pgno iKey; /* Key value (page number) */ + public PgHdr1 pNext; /* Next in hash table chain */ + public PCache1 pCache; /* Cache that currently owns this page */ + public PgHdr1 pLruNext; /* Next in LRU list of unpinned pages */ + public PgHdr1 pLruPrev; /* Previous in LRU list of unpinned pages */ + + // For C# + public PgHdr pPgHdr = new PgHdr(); /* Pointer to Actual Page Header */ + + public void Clear() { + this.iKey = 0; + this.pNext = null; + this.pCache = null; + this.pPgHdr.Clear(); + } + + }; + + /* + ** Free slots in the allocator used to divide up the buffer provided using + ** the SQLITE_CONFIG_PAGECACHE mechanism. + */ + public class PgFreeslot { + public PgFreeslot pNext; /* Next free slot */ + public PgHdr _PgHdr; /* Next Free Header */ + }; - //#define PAGE_TO_PGHDR1(c, p) (PgHdr1)(((char)p) + c.szPage) - static PgHdr1 PAGE_TO_PGHDR1( PCache1 c, PgHdr p ) - { - return p.pPgHdr1; - } + /* + ** Global data used by this cache. + */ + public class PCacheGlobal { + public PGroup grp; /* The global PGroup for mode (2) */ + + /* Variables related to SQLITE_CONFIG_PAGECACHE settings. The + ** szSlot, nSlot, pStart, pEnd, nReserve, and isInit values are all + ** fixed at sqlite3_initialize() time and do not require mutex protection. + ** The nFreeSlot and pFree values do require mutex protection. + */ + public bool isInit; /* True if initialized */ + public int szSlot; /* Size of each free slot */ + public int nSlot; /* The number of pcache slots */ + public int nReserve; /* Try to keep nFreeSlot above this */ + public object pStart, pEnd; /* Bounds of pagecache malloc range */ + /* Above requires no mutex. Use mutex below for variable that follow. */ + public sqlite3_mutex mutex; /* Mutex for accessing the following: */ + public int nFreeSlot; /* Number of unused pcache slots */ + public PgFreeslot pFree; /* Free page blocks */ + /* The following value requires a mutex to change. We skip the mutex on + ** reading because (1) most platforms read a 32-bit integer atomically and + ** (2) even if an incorrect value is read, no great harm is done since this + ** is really just an optimization. */ + public bool bUnderPressure; /* True if low on PAGECACHE memory */ + + // C# + public PCacheGlobal() { + grp = new PGroup(); + } + } + static PCacheGlobal pcache = new PCacheGlobal(); - /* - ** Macros to enter and leave the PCache LRU mutex. - */ - //#define pcache1EnterMutex(X) sqlite3_mutex_enter((X).mutex) - static void pcache1EnterMutex( PGroup X ) - { - sqlite3_mutex_enter( X.mutex ); - } - //#define pcache1LeaveMutex(X) sqlite3_mutex_leave((X).mutex) - static void pcache1LeaveMutex( PGroup X ) - { - sqlite3_mutex_leave( X.mutex ); - } + /* + ** All code in this file should access the global structure above via the + ** alias "pcache1". This ensures that the WSD emulation is used when + ** compiling for systems that do not support real WSD. + */ + //#define pcache1 (GLOBAL(struct PCacheGlobal, pcache1_g)) + static PCacheGlobal pcache1 = pcache; + + /* + ** When a PgHdr1 structure is allocated, the associated PCache1.szPage + ** bytes of data are located directly before it in memory (i.e. the total + ** size of the allocation is sizeof(PgHdr1)+PCache1.szPage byte). The + ** PGHDR1_TO_PAGE() macro takes a pointer to a PgHdr1 structure as + ** an argument and returns a pointer to the associated block of szPage + ** bytes. The PAGE_TO_PGHDR1() macro does the opposite: its argument is + ** a pointer to a block of szPage bytes of data and the return value is + ** a pointer to the associated PgHdr1 structure. + ** + ** Debug.Assert( PGHDR1_TO_PAGE(PAGE_TO_PGHDR1(pCache, X))==X ); + */ + //#define PGHDR1_TO_PAGE(p) (void)(((char)p) - p.pCache.szPage) + static PgHdr PGHDR1_TO_PAGE(PgHdr1 p) { + return p.pPgHdr; + } - /******************************************************************************/ - /******** Page Allocation/SQLITE_CONFIG_PCACHE Related Functions **************/ + //#define PAGE_TO_PGHDR1(c, p) (PgHdr1)(((char)p) + c.szPage) + static PgHdr1 PAGE_TO_PGHDR1(PCache1 c, PgHdr p) { + return p.pPgHdr1; + } - /* - ** This function is called during initialization if a static buffer is - ** supplied to use for the page-cache by passing the SQLITE_CONFIG_PAGECACHE - ** verb to sqlite3_config(). Parameter pBuf points to an allocation large - ** enough to contain 'n' buffers of 'sz' bytes each. - ** - ** This routine is called from sqlite3_initialize() and so it is guaranteed - ** to be serialized already. There is no need for further mutexing. - */ - static void sqlite3PCacheBufferSetup( object pBuf, int sz, int n ) - { - if ( pcache1.isInit ) - { - PgFreeslot p; - sz = ROUNDDOWN8( sz ); - pcache1.szSlot = sz; - pcache1.nSlot = pcache1.nFreeSlot = n; - pcache1.nReserve = n > 90 ? 10 : ( n / 10 + 1 ); - pcache1.pStart = null; - pcache1.pEnd = null; - pcache1.pFree = null; - pcache1.bUnderPressure = false; - while ( n-- > 0 ) - { - p = new PgFreeslot();// (PgFreeslot)pBuf; - p._PgHdr = new PgHdr(); - p.pNext = pcache1.pFree; - pcache1.pFree = p; - //pBuf = (void)&((char)pBuf)[sz]; + /* + ** Macros to enter and leave the PCache LRU mutex. + */ + //#define pcache1EnterMutex(X) sqlite3_mutex_enter((X).mutex) + static void pcache1EnterMutex(PGroup X) { + sqlite3_mutex_enter(X.mutex); + } + //#define pcache1LeaveMutex(X) sqlite3_mutex_leave((X).mutex) + static void pcache1LeaveMutex(PGroup X) { + sqlite3_mutex_leave(X.mutex); } - pcache1.pEnd = pBuf; - } - } - /* - ** Malloc function used within this file to allocate space from the buffer - ** configured using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no - ** such buffer exists or there is no space left in it, this function falls - ** back to sqlite3Malloc(). - ** - ** Multiple threads can run this routine at the same time. Global variables - ** in pcache1 need to be protected via mutex. - */ - static PgHdr pcache1Alloc( int nByte ) - { - PgHdr p = null; - Debug.Assert( sqlite3_mutex_notheld( pcache1.grp.mutex ) ); - sqlite3StatusSet( SQLITE_STATUS_PAGECACHE_SIZE, nByte ); - if ( nByte <= pcache1.szSlot ) - { - sqlite3_mutex_enter( pcache1.mutex ); - p = pcache1.pFree._PgHdr; - if ( p != null ) - { - pcache1.pFree = pcache1.pFree.pNext; - pcache1.nFreeSlot--; - pcache1.bUnderPressure = pcache1.nFreeSlot < pcache1.nReserve; - Debug.Assert( pcache1.nFreeSlot >= 0 ); - sqlite3StatusAdd( SQLITE_STATUS_PAGECACHE_USED, 1 ); + /******************************************************************************/ + /******** Page Allocation/SQLITE_CONFIG_PCACHE Related Functions **************/ + + /* + ** This function is called during initialization if a static buffer is + ** supplied to use for the page-cache by passing the SQLITE_CONFIG_PAGECACHE + ** verb to sqlite3_config(). Parameter pBuf points to an allocation large + ** enough to contain 'n' buffers of 'sz' bytes each. + ** + ** This routine is called from sqlite3_initialize() and so it is guaranteed + ** to be serialized already. There is no need for further mutexing. + */ + static void sqlite3PCacheBufferSetup(object pBuf, int sz, int n) { + if (pcache1.isInit) { + PgFreeslot p; + sz = ROUNDDOWN8(sz); + pcache1.szSlot = sz; + pcache1.nSlot = pcache1.nFreeSlot = n; + pcache1.nReserve = n > 90 ? 10 : (n / 10 + 1); + pcache1.pStart = null; + pcache1.pEnd = null; + pcache1.pFree = null; + pcache1.bUnderPressure = false; + while (n-- > 0) { + p = new PgFreeslot();// (PgFreeslot)pBuf; + p._PgHdr = new PgHdr(); + p.pNext = pcache1.pFree; + pcache1.pFree = p; + //pBuf = (void)&((char)pBuf)[sz]; + } + pcache1.pEnd = pBuf; + } } - sqlite3_mutex_leave( pcache1.mutex ); - } - if ( p == null ) - { - /* Memory is not available in the SQLITE_CONFIG_PAGECACHE pool. Get - ** it from sqlite3Malloc instead. + + /* + ** Malloc function used within this file to allocate space from the buffer + ** configured using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no + ** such buffer exists or there is no space left in it, this function falls + ** back to sqlite3Malloc(). + ** + ** Multiple threads can run this routine at the same time. Global variables + ** in pcache1 need to be protected via mutex. */ - p = new PgHdr();// sqlite3Malloc( nByte ); - //if ( p != null ) - { - int sz = nByte;//sqlite3MallocSize( p ); - sqlite3_mutex_enter( pcache1.mutex ); - sqlite3StatusAdd( SQLITE_STATUS_PAGECACHE_OVERFLOW, sz ); - sqlite3_mutex_leave( pcache1.mutex ); + static PgHdr pcache1Alloc(int nByte) { + PgHdr p = null; + Debug.Assert(sqlite3_mutex_notheld(pcache1.grp.mutex)); + sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte); + if (nByte <= pcache1.szSlot) { + sqlite3_mutex_enter(pcache1.mutex); + p = pcache1.pFree._PgHdr; + if (p != null) { + pcache1.pFree = pcache1.pFree.pNext; + pcache1.nFreeSlot--; + pcache1.bUnderPressure = pcache1.nFreeSlot < pcache1.nReserve; + Debug.Assert(pcache1.nFreeSlot >= 0); + sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, 1); + } + sqlite3_mutex_leave(pcache1.mutex); + } + if (p == null) { + /* Memory is not available in the SQLITE_CONFIG_PAGECACHE pool. Get + ** it from sqlite3Malloc instead. + */ + p = new PgHdr();// sqlite3Malloc( nByte ); + //if ( p != null ) + { + int sz = nByte;//sqlite3MallocSize( p ); + sqlite3_mutex_enter(pcache1.mutex); + sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz); + sqlite3_mutex_leave(pcache1.mutex); + } + sqlite3MemdebugSetType(p, MEMTYPE_PCACHE); + } + return p; } - sqlite3MemdebugSetType( p, MEMTYPE_PCACHE ); - } - return p; - } - /* - ** Free an allocated buffer obtained from pcache1Alloc(). - */ - static void pcache1Free( ref PgHdr p ) - { - if ( p == null ) - return; - if ( p.CacheAllocated )//if ( p >= pcache1.pStart && p < pcache1.pEnd ) - { - PgFreeslot pSlot = new PgFreeslot(); - sqlite3_mutex_enter( pcache1.mutex ); - sqlite3StatusAdd( SQLITE_STATUS_PAGECACHE_USED, -1 ); - pSlot._PgHdr = p;// pSlot = (PgFreeslot)p; - pSlot.pNext = pcache1.pFree; - pcache1.pFree = pSlot; - pcache1.nFreeSlot++; - pcache1.bUnderPressure = pcache1.nFreeSlot < pcache1.nReserve; - Debug.Assert( pcache1.nFreeSlot <= pcache1.nSlot ); - sqlite3_mutex_leave( pcache1.mutex ); - } - else - { - int iSize; - Debug.Assert( sqlite3MemdebugHasType( p, MEMTYPE_PCACHE ) ); - sqlite3MemdebugSetType( p, MEMTYPE_HEAP ); - iSize = sqlite3MallocSize( p.pData ); - sqlite3_mutex_enter( pcache1.mutex ); - sqlite3StatusAdd( SQLITE_STATUS_PAGECACHE_OVERFLOW, -iSize ); - sqlite3_mutex_leave( pcache1.mutex ); - sqlite3_free( ref p.pData ); - } - } + /* + ** Free an allocated buffer obtained from pcache1Alloc(). + */ + static void pcache1Free(ref PgHdr p) { + if (p == null) + return; + if (p.CacheAllocated)//if ( p >= pcache1.pStart && p < pcache1.pEnd ) + { + PgFreeslot pSlot = new PgFreeslot(); + sqlite3_mutex_enter(pcache1.mutex); + sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, -1); + pSlot._PgHdr = p;// pSlot = (PgFreeslot)p; + pSlot.pNext = pcache1.pFree; + pcache1.pFree = pSlot; + pcache1.nFreeSlot++; + pcache1.bUnderPressure = pcache1.nFreeSlot < pcache1.nReserve; + Debug.Assert(pcache1.nFreeSlot <= pcache1.nSlot); + sqlite3_mutex_leave(pcache1.mutex); + } else { + int iSize; + Debug.Assert(sqlite3MemdebugHasType(p, MEMTYPE_PCACHE)); + sqlite3MemdebugSetType(p, MEMTYPE_HEAP); + iSize = sqlite3MallocSize(p.pData); + sqlite3_mutex_enter(pcache1.mutex); + sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, -iSize); + sqlite3_mutex_leave(pcache1.mutex); + sqlite3_free(ref p.pData); + } + } #if SQLITE_ENABLE_MEMORY_MANAGEMENT /* @@ -372,748 +346,678 @@ static int pcache1MemSize(object p){ } #endif //* SQLITE_ENABLE_MEMORY_MANAGEMENT */ - /* -** Allocate a new page object initially associated with cache pCache. -*/ - static PgHdr1 pcache1AllocPage( PCache1 pCache ) - { - //int nByte = sizeof( PgHdr1 ) + pCache.szPage; - PgHdr pPg = pcache1Alloc( pCache.szPage );//nByte ); - PgHdr1 p = null; - //if ( pPg !=null) - { - //PAGE_TO_PGHDR1( pCache, pPg ); - p = new PgHdr1(); - p.pCache = pCache; - p.pPgHdr = pPg; - if ( pCache.bPurgeable ) - { - pCache.pGroup.nCurrentPage++; - } - } - //else - //{ - // p = 0; - //} - return p; - } - - /* - ** Free a page object allocated by pcache1AllocPage(). - ** - ** The pointer is allowed to be NULL, which is prudent. But it turns out - ** that the current implementation happens to never call this routine - ** with a NULL pointer, so we mark the NULL test with ALWAYS(). + /* + ** Allocate a new page object initially associated with cache pCache. */ - static void pcache1FreePage( ref PgHdr1 p ) - { - if ( ALWAYS( p ) ) - { - PCache1 pCache = p.pCache; - if ( pCache.bPurgeable ) - { - pCache.pGroup.nCurrentPage--; + static PgHdr1 pcache1AllocPage(PCache1 pCache) { + //int nByte = sizeof( PgHdr1 ) + pCache.szPage; + PgHdr pPg = pcache1Alloc(pCache.szPage);//nByte ); + PgHdr1 p = null; + //if ( pPg !=null) + { + //PAGE_TO_PGHDR1( pCache, pPg ); + p = new PgHdr1(); + p.pCache = pCache; + p.pPgHdr = pPg; + if (pCache.bPurgeable) { + pCache.pGroup.nCurrentPage++; + } + } + //else + //{ + // p = 0; + //} + return p; } - pcache1Free( ref p.pPgHdr );//PGHDR1_TO_PAGE( p ); - } - } - - /* - ** Malloc function used by SQLite to obtain space from the buffer configured - ** using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no such buffer - ** exists, this function falls back to sqlite3Malloc(). - */ - static PgHdr sqlite3PageMalloc( int sz ) - { - return pcache1Alloc( sz ); - } - /* - ** Free an allocated buffer obtained from sqlite3PageMalloc(). - */ - static void sqlite3PageFree( ref byte[] p ) - { - if ( p != null ) - { - sqlite3_free( ref p ); - p = null; - } - } - static void sqlite3PageFree( ref PgHdr p ) - { - pcache1Free( ref p ); - } - - /* - ** Return true if it desirable to avoid allocating a new page cache - ** entry. - ** - ** If memory was allocated specifically to the page cache using - ** SQLITE_CONFIG_PAGECACHE but that memory has all been used, then - ** it is desirable to avoid allocating a new page cache entry because - ** presumably SQLITE_CONFIG_PAGECACHE was suppose to be sufficient - ** for all page cache needs and we should not need to spill the - ** allocation onto the heap. - ** - ** Or, the heap is used for all page cache memory put the heap is - ** under memory pressure, then again it is desirable to avoid - ** allocating a new page cache entry in order to avoid stressing - ** the heap even further. - */ - static bool pcache1UnderMemoryPressure( PCache1 pCache ) - { - if ( pcache1.nSlot != 0 && pCache.szPage <= pcache1.szSlot ) - { - return pcache1.bUnderPressure; - } - else - { - return sqlite3HeapNearlyFull(); - } - } - - /******************************************************************************/ - /******** General Implementation Functions ************************************/ - - /* - ** This function is used to resize the hash table used by the cache passed - ** as the first argument. - ** - ** The PCache mutex must be held when this function is called. - */ - static int pcache1ResizeHash( PCache1 p ) - { - PgHdr1[] apNew; - int nNew; - int i; - - Debug.Assert( sqlite3_mutex_held( p.pGroup.mutex ) ); + /* + ** Free a page object allocated by pcache1AllocPage(). + ** + ** The pointer is allowed to be NULL, which is prudent. But it turns out + ** that the current implementation happens to never call this routine + ** with a NULL pointer, so we mark the NULL test with ALWAYS(). + */ + static void pcache1FreePage(ref PgHdr1 p) { + if (ALWAYS(p)) { + PCache1 pCache = p.pCache; + if (pCache.bPurgeable) { + pCache.pGroup.nCurrentPage--; + } + pcache1Free(ref p.pPgHdr);//PGHDR1_TO_PAGE( p ); + } + } - nNew = p.nHash * 2; - if ( nNew < 256 ) - { - nNew = 256; - } + /* + ** Malloc function used by SQLite to obtain space from the buffer configured + ** using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no such buffer + ** exists, this function falls back to sqlite3Malloc(). + */ + static PgHdr sqlite3PageMalloc(int sz) { + return pcache1Alloc(sz); + } - pcache1LeaveMutex( p.pGroup ); - if ( p.nHash != 0 ) - { - sqlite3BeginBenignMalloc(); - } - apNew = new PgHdr1[nNew];//(PgHdr1 *)sqlite3_malloc(sizeof(PgHdr1 )*nNew); - if ( p.nHash != 0 ) - { - sqlite3EndBenignMalloc(); - } - pcache1EnterMutex( p.pGroup ); - if ( apNew != null ) - { - //memset(apNew, 0, sizeof(PgHdr1 )*nNew); - for ( i = 0; i < p.nHash; i++ ) - { - PgHdr1 pPage; - PgHdr1 pNext = p.apHash[i]; - while ( ( pPage = pNext ) != null ) - { - Pgno h = (Pgno)( pPage.iKey % nNew ); - pNext = pPage.pNext; - pPage.pNext = apNew[h]; - apNew[h] = pPage; - } + /* + ** Free an allocated buffer obtained from sqlite3PageMalloc(). + */ + static void sqlite3PageFree(ref byte[] p) { + if (p != null) { + sqlite3_free(ref p); + p = null; + } + } + static void sqlite3PageFree(ref PgHdr p) { + pcache1Free(ref p); } - //sqlite3_free( p.apHash ); - p.apHash = apNew; - p.nHash = nNew; - } - return ( p.apHash != null ? SQLITE_OK : SQLITE_NOMEM ); - } + /* + ** Return true if it desirable to avoid allocating a new page cache + ** entry. + ** + ** If memory was allocated specifically to the page cache using + ** SQLITE_CONFIG_PAGECACHE but that memory has all been used, then + ** it is desirable to avoid allocating a new page cache entry because + ** presumably SQLITE_CONFIG_PAGECACHE was suppose to be sufficient + ** for all page cache needs and we should not need to spill the + ** allocation onto the heap. + ** + ** Or, the heap is used for all page cache memory put the heap is + ** under memory pressure, then again it is desirable to avoid + ** allocating a new page cache entry in order to avoid stressing + ** the heap even further. + */ + static bool pcache1UnderMemoryPressure(PCache1 pCache) { + if (pcache1.nSlot != 0 && pCache.szPage <= pcache1.szSlot) { + return pcache1.bUnderPressure; + } else { + return sqlite3HeapNearlyFull(); + } + } - /* - ** This function is used internally to remove the page pPage from the - ** PGroup LRU list, if is part of it. If pPage is not part of the PGroup - ** LRU list, then this function is a no-op. - ** - ** The PGroup mutex must be held when this function is called. - ** - ** If pPage is NULL then this routine is a no-op. - */ - static void pcache1PinPage( PgHdr1 pPage ) - { - PCache1 pCache; - PGroup pGroup; + /******************************************************************************/ + /******** General Implementation Functions ************************************/ - if ( pPage == null ) - return; - pCache = pPage.pCache; - pGroup = pCache.pGroup; - Debug.Assert( sqlite3_mutex_held( pGroup.mutex ) ); - if ( pPage.pLruNext != null || pPage == pGroup.pLruTail ) - { - if ( pPage.pLruPrev != null ) - { - pPage.pLruPrev.pLruNext = pPage.pLruNext; - } - if ( pPage.pLruNext != null ) - { - pPage.pLruNext.pLruPrev = pPage.pLruPrev; - } - if ( pGroup.pLruHead == pPage ) - { - pGroup.pLruHead = pPage.pLruNext; + /* + ** This function is used to resize the hash table used by the cache passed + ** as the first argument. + ** + ** The PCache mutex must be held when this function is called. + */ + static int pcache1ResizeHash(PCache1 p) { + PgHdr1[] apNew; + int nNew; + int i; + + Debug.Assert(sqlite3_mutex_held(p.pGroup.mutex)); + + nNew = p.nHash * 2; + if (nNew < 256) { + nNew = 256; + } + + pcache1LeaveMutex(p.pGroup); + if (p.nHash != 0) { + sqlite3BeginBenignMalloc(); + } + apNew = new PgHdr1[nNew];//(PgHdr1 *)sqlite3_malloc(sizeof(PgHdr1 )*nNew); + if (p.nHash != 0) { + sqlite3EndBenignMalloc(); + } + pcache1EnterMutex(p.pGroup); + if (apNew != null) { + //memset(apNew, 0, sizeof(PgHdr1 )*nNew); + for (i = 0; i < p.nHash; i++) { + PgHdr1 pPage; + PgHdr1 pNext = p.apHash[i]; + while ((pPage = pNext) != null) { + Pgno h = (Pgno)(pPage.iKey % nNew); + pNext = pPage.pNext; + pPage.pNext = apNew[h]; + apNew[h] = pPage; + } + } + //sqlite3_free( p.apHash ); + p.apHash = apNew; + p.nHash = nNew; + } + + return (p.apHash != null ? SQLITE_OK : SQLITE_NOMEM); } - if ( pGroup.pLruTail == pPage ) - { - pGroup.pLruTail = pPage.pLruPrev; + + /* + ** This function is used internally to remove the page pPage from the + ** PGroup LRU list, if is part of it. If pPage is not part of the PGroup + ** LRU list, then this function is a no-op. + ** + ** The PGroup mutex must be held when this function is called. + ** + ** If pPage is NULL then this routine is a no-op. + */ + static void pcache1PinPage(PgHdr1 pPage) { + PCache1 pCache; + PGroup pGroup; + + if (pPage == null) + return; + pCache = pPage.pCache; + pGroup = pCache.pGroup; + Debug.Assert(sqlite3_mutex_held(pGroup.mutex)); + if (pPage.pLruNext != null || pPage == pGroup.pLruTail) { + if (pPage.pLruPrev != null) { + pPage.pLruPrev.pLruNext = pPage.pLruNext; + } + if (pPage.pLruNext != null) { + pPage.pLruNext.pLruPrev = pPage.pLruPrev; + } + if (pGroup.pLruHead == pPage) { + pGroup.pLruHead = pPage.pLruNext; + } + if (pGroup.pLruTail == pPage) { + pGroup.pLruTail = pPage.pLruPrev; + } + pPage.pLruNext = null; + pPage.pLruPrev = null; + pPage.pCache.nRecyclable--; + } } - pPage.pLruNext = null; - pPage.pLruPrev = null; - pPage.pCache.nRecyclable--; - } - } - /* - ** Remove the page supplied as an argument from the hash table - ** (PCache1.apHash structure) that it is currently stored in. - ** - ** The PGroup mutex must be held when this function is called. - */ - static void pcache1RemoveFromHash( PgHdr1 pPage ) - { - int h; - PCache1 pCache = pPage.pCache; - PgHdr1 pp; - PgHdr1 pPrev = null; - - Debug.Assert( sqlite3_mutex_held( pCache.pGroup.mutex ) ); - h = (int)( pPage.iKey % pCache.nHash ); - for ( pp = pCache.apHash[h]; pp != pPage; pPrev = pp, pp = pp.pNext ) - ; - if ( pPrev == null ) - pCache.apHash[h] = pp.pNext; - else - pPrev.pNext = pp.pNext; // pCache.apHash[h] = pp.pNext; - pCache.nPage--; - } + /* + ** Remove the page supplied as an argument from the hash table + ** (PCache1.apHash structure) that it is currently stored in. + ** + ** The PGroup mutex must be held when this function is called. + */ + static void pcache1RemoveFromHash(PgHdr1 pPage) { + int h; + PCache1 pCache = pPage.pCache; + PgHdr1 pp; + PgHdr1 pPrev = null; + + Debug.Assert(sqlite3_mutex_held(pCache.pGroup.mutex)); + h = (int)(pPage.iKey % pCache.nHash); + for (pp = pCache.apHash[h]; pp != pPage; pPrev = pp, pp = pp.pNext) + ; + if (pPrev == null) + pCache.apHash[h] = pp.pNext; + else + pPrev.pNext = pp.pNext; // pCache.apHash[h] = pp.pNext; + pCache.nPage--; + } - /* - ** If there are currently more than nMaxPage pages allocated, try - ** to recycle pages to reduce the number allocated to nMaxPage. - */ - static void pcache1EnforceMaxPage( PGroup pGroup ) - { - Debug.Assert( sqlite3_mutex_held( pGroup.mutex ) ); - while ( pGroup.nCurrentPage > pGroup.nMaxPage && pGroup.pLruTail != null ) - { - PgHdr1 p = pGroup.pLruTail; - Debug.Assert( p.pCache.pGroup == pGroup ); - pcache1PinPage( p ); - pcache1RemoveFromHash( p ); - pcache1FreePage( ref p ); - } - } + /* + ** If there are currently more than nMaxPage pages allocated, try + ** to recycle pages to reduce the number allocated to nMaxPage. + */ + static void pcache1EnforceMaxPage(PGroup pGroup) { + Debug.Assert(sqlite3_mutex_held(pGroup.mutex)); + while (pGroup.nCurrentPage > pGroup.nMaxPage && pGroup.pLruTail != null) { + PgHdr1 p = pGroup.pLruTail; + Debug.Assert(p.pCache.pGroup == pGroup); + pcache1PinPage(p); + pcache1RemoveFromHash(p); + pcache1FreePage(ref p); + } + } - /* - ** Discard all pages from cache pCache with a page number (key value) - ** greater than or equal to iLimit. Any pinned pages that meet this - ** criteria are unpinned before they are discarded. - ** - ** The PCache mutex must be held when this function is called. - */ - static void pcache1TruncateUnsafe( - PCache1 pCache, /* The cache to truncate */ - uint iLimit /* Drop pages with this pgno or larger */ - ) - { + /* + ** Discard all pages from cache pCache with a page number (key value) + ** greater than or equal to iLimit. Any pinned pages that meet this + ** criteria are unpinned before they are discarded. + ** + ** The PCache mutex must be held when this function is called. + */ + static void pcache1TruncateUnsafe( + PCache1 pCache, /* The cache to truncate */ + uint iLimit /* Drop pages with this pgno or larger */ + ) { #if !NDEBUG || SQLITE_COVERAGE_TEST //TESTONLY( uint nPage = 0; ) /* To assert pCache.nPage is correct */ - uint nPage = 0; + uint nPage = 0; #endif - uint h; - Debug.Assert( sqlite3_mutex_held( pCache.pGroup.mutex ) ); - for ( h = 0; h < pCache.nHash; h++ ) - { - PgHdr1 pPrev = null; - PgHdr1 pp = pCache.apHash[h]; - PgHdr1 pPage; - while ( ( pPage = pp ) != null ) - { - if ( pPage.iKey >= iLimit ) - { - pCache.nPage--; - pp = pPage.pNext; - pcache1PinPage( pPage ); - if ( pCache.apHash[h] == pPage ) - pCache.apHash[h] = pPage.pNext; - else - pPrev.pNext = pp; - pcache1FreePage( ref pPage ); - } - else - { - pp = pPage.pNext; + uint h; + Debug.Assert(sqlite3_mutex_held(pCache.pGroup.mutex)); + for (h = 0; h < pCache.nHash; h++) { + PgHdr1 pPrev = null; + PgHdr1 pp = pCache.apHash[h]; + PgHdr1 pPage; + while ((pPage = pp) != null) { + if (pPage.iKey >= iLimit) { + pCache.nPage--; + pp = pPage.pNext; + pcache1PinPage(pPage); + if (pCache.apHash[h] == pPage) + pCache.apHash[h] = pPage.pNext; + else + pPrev.pNext = pp; + pcache1FreePage(ref pPage); + } else { + pp = pPage.pNext; #if !NDEBUG || SQLITE_COVERAGE_TEST //TESTONLY( nPage++; ) - nPage++; + nPage++; #endif - } - pPrev = pPage; - } - } + } + pPrev = pPage; + } + } #if !NDEBUG || SQLITE_COVERAGE_TEST - Debug.Assert( pCache.nPage == nPage ); + Debug.Assert(pCache.nPage == nPage); #endif - } + } - /******************************************************************************/ - /******** sqlite3_pcache Methods **********************************************/ + /******************************************************************************/ + /******** sqlite3_pcache Methods **********************************************/ - /* - ** Implementation of the sqlite3_pcache.xInit method. - */ - static int pcache1Init( T NotUsed ) - { - UNUSED_PARAMETER( NotUsed ); - Debug.Assert( pcache1.isInit == false ); - pcache1 = new PCacheGlobal();//memset(&pcache1, 0, sizeof(pcache1)); - if ( sqlite3GlobalConfig.bCoreMutex ) - { - pcache1.grp.mutex = sqlite3_mutex_alloc( SQLITE_MUTEX_STATIC_LRU ); - pcache1.mutex = sqlite3_mutex_alloc( SQLITE_MUTEX_STATIC_PMEM ); - } - pcache1.grp.mxPinned = 10; - pcache1.isInit = true; - return SQLITE_OK; - } + /* + ** Implementation of the sqlite3_pcache.xInit method. + */ + static int pcache1Init(T NotUsed) { + UNUSED_PARAMETER(NotUsed); + Debug.Assert(pcache1.isInit == false); + pcache1 = new PCacheGlobal();//memset(&pcache1, 0, sizeof(pcache1)); + if (sqlite3GlobalConfig.bCoreMutex) { + pcache1.grp.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU); + pcache1.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_PMEM); + } + pcache1.grp.mxPinned = 10; + pcache1.isInit = true; + return SQLITE_OK; + } - /* - ** Implementation of the sqlite3_pcache.xShutdown method. - ** Note that the static mutex allocated in xInit does - ** not need to be freed. - */ - static void pcache1Shutdown( T NotUsed ) - { - UNUSED_PARAMETER( NotUsed ); - Debug.Assert( pcache1.isInit ); - pcache1 = new PCacheGlobal();//;memset( &pcache1, 0, sizeof( pcache1 ) ); - } + /* + ** Implementation of the sqlite3_pcache.xShutdown method. + ** Note that the static mutex allocated in xInit does + ** not need to be freed. + */ + static void pcache1Shutdown(T NotUsed) { + UNUSED_PARAMETER(NotUsed); + Debug.Assert(pcache1.isInit); + pcache1 = new PCacheGlobal();//;memset( &pcache1, 0, sizeof( pcache1 ) ); + } - /* - ** Implementation of the sqlite3_pcache.xCreate method. - ** - ** Allocate a new cache. - */ - static sqlite3_pcache pcache1Create( int szPage, bool bPurgeable ) - { - PCache1 pCache; /* The newly created page cache */ - PGroup pGroup; /* The group the new page cache will belong to */ - int sz; /* Bytes of memory required to allocate the new cache */ - - /* - ** The seperateCache variable is true if each PCache has its own private - ** PGroup. In other words, separateCache is true for mode (1) where no - ** mutexing is required. - ** - ** * Always use a unified cache (mode-2) if ENABLE_MEMORY_MANAGEMENT - ** - ** * Always use a unified cache in single-threaded applications - ** - ** * Otherwise (if multi-threaded and ENABLE_MEMORY_MANAGEMENT is off) - ** use separate caches (mode-1) - */ + /* + ** Implementation of the sqlite3_pcache.xCreate method. + ** + ** Allocate a new cache. + */ + static sqlite3_pcache pcache1Create(int szPage, bool bPurgeable) { + PCache1 pCache; /* The newly created page cache */ + PGroup pGroup; /* The group the new page cache will belong to */ + int sz; /* Bytes of memory required to allocate the new cache */ + + /* + ** The seperateCache variable is true if each PCache has its own private + ** PGroup. In other words, separateCache is true for mode (1) where no + ** mutexing is required. + ** + ** * Always use a unified cache (mode-2) if ENABLE_MEMORY_MANAGEMENT + ** + ** * Always use a unified cache in single-threaded applications + ** + ** * Otherwise (if multi-threaded and ENABLE_MEMORY_MANAGEMENT is off) + ** use separate caches (mode-1) + */ #if (SQLITE_ENABLE_MEMORY_MANAGEMENT) || !SQLITE_THREADSAF - const int separateCache = 0; + const int separateCache = 0; #else int separateCache = sqlite3GlobalConfig.bCoreMutex>0; #endif - //sz = sizeof( PCache1 ) + sizeof( PGroup ) * separateCache; - pCache = new PCache1();//(PCache1)sqlite3_malloc( sz ); - //if ( pCache != null ) - //{ - //memset( pCache, 0, sz ); - if ( separateCache == 0 ) - { - pGroup = pcache1.grp; - } - ////else - ////{ - ////pGroup = new PGroup();//(PGroup)pCache[1]; - ////pGroup.mxPinned = 10; - ////} - - pCache.pGroup = pGroup; - pCache.szPage = szPage; - pCache.bPurgeable = bPurgeable;//( bPurgeable ? 1 : 0 ); - if ( bPurgeable ) - { - pCache.nMin = 10; - pcache1EnterMutex( pGroup ); - pGroup.nMinPage += (int)pCache.nMin; - pGroup.mxPinned = pGroup.nMaxPage + 10 - pGroup.nMinPage; - pcache1LeaveMutex( pGroup ); + //sz = sizeof( PCache1 ) + sizeof( PGroup ) * separateCache; + pCache = new PCache1();//(PCache1)sqlite3_malloc( sz ); + //if ( pCache != null ) + //{ + //memset( pCache, 0, sz ); + if (separateCache == 0) { + pGroup = pcache1.grp; + } + ////else + ////{ + ////pGroup = new PGroup();//(PGroup)pCache[1]; + ////pGroup.mxPinned = 10; + ////} + + pCache.pGroup = pGroup; + pCache.szPage = szPage; + pCache.bPurgeable = bPurgeable;//( bPurgeable ? 1 : 0 ); + if (bPurgeable) { + pCache.nMin = 10; + pcache1EnterMutex(pGroup); + pGroup.nMinPage += (int)pCache.nMin; + pGroup.mxPinned = pGroup.nMaxPage + 10 - pGroup.nMinPage; + pcache1LeaveMutex(pGroup); + } + //} + return (sqlite3_pcache)pCache; } - //} - return (sqlite3_pcache)pCache; - } - - /* - ** Implementation of the sqlite3_pcache.xCachesize method. - ** - ** Configure the cache_size limit for a cache. - */ - static void pcache1Cachesize( sqlite3_pcache p, int nMax ) - { - PCache1 pCache = (PCache1)p; - if ( pCache.bPurgeable ) - { - PGroup pGroup = pCache.pGroup; - pcache1EnterMutex( pGroup ); - pGroup.nMaxPage += nMax - pCache.nMax; - pGroup.mxPinned = pGroup.nMaxPage + 10 - pGroup.nMinPage; - pCache.nMax = nMax; - pCache.n90pct = pCache.nMax * 9 / 10; - pcache1EnforceMaxPage( pGroup ); - pcache1LeaveMutex( pGroup ); - } - } - - /* - ** Implementation of the sqlite3_pcache.xPagecount method. - */ - static int pcache1Pagecount( sqlite3_pcache p ) - { - int n; - PCache1 pCache = (PCache1)p; - pcache1EnterMutex( pCache.pGroup ); - n = (int)pCache.nPage; - pcache1LeaveMutex( pCache.pGroup ); - return n; - } - /* - ** Implementation of the sqlite3_pcache.xFetch method. - ** - ** Fetch a page by key value. - ** - ** Whether or not a new page may be allocated by this function depends on - ** the value of the createFlag argument. 0 means do not allocate a new - ** page. 1 means allocate a new page if space is easily available. 2 - ** means to try really hard to allocate a new page. - ** - ** For a non-purgeable cache (a cache used as the storage for an in-memory - ** database) there is really no difference between createFlag 1 and 2. So - ** the calling function (pcache.c) will never have a createFlag of 1 on - ** a non-purgable cache. - ** - ** There are three different approaches to obtaining space for a page, - ** depending on the value of parameter createFlag (which may be 0, 1 or 2). - ** - ** 1. Regardless of the value of createFlag, the cache is searched for a - ** copy of the requested page. If one is found, it is returned. - ** - ** 2. If createFlag==0 and the page is not already in the cache, NULL is - ** returned. - ** - ** 3. If createFlag is 1, and the page is not already in the cache, then - ** return NULL (do not allocate a new page) if any of the following - ** conditions are true: - ** - ** (a) the number of pages pinned by the cache is greater than - ** PCache1.nMax, or - ** - ** (b) the number of pages pinned by the cache is greater than - ** the sum of nMax for all purgeable caches, less the sum of - ** nMin for all other purgeable caches, or - ** - ** 4. If none of the first three conditions apply and the cache is marked - ** as purgeable, and if one of the following is true: - ** - ** (a) The number of pages allocated for the cache is already - ** PCache1.nMax, or - ** - ** (b) The number of pages allocated for all purgeable caches is - ** already equal to or greater than the sum of nMax for all - ** purgeable caches, - ** - ** (c) The system is under memory pressure and wants to avoid - ** unnecessary pages cache entry allocations - ** - ** then attempt to recycle a page from the LRU list. If it is the right - ** size, return the recycled buffer. Otherwise, free the buffer and - ** proceed to step 5. - ** - ** 5. Otherwise, allocate and return a new page buffer. - */ - static PgHdr pcache1Fetch( sqlite3_pcache p, Pgno iKey, int createFlag ) - { - int nPinned; - PCache1 pCache = (PCache1)p; - PGroup pGroup; - PgHdr1 pPage = null; - - Debug.Assert( pCache.bPurgeable || createFlag != 1 ); - Debug.Assert( pCache.bPurgeable || pCache.nMin == 0 ); - Debug.Assert( pCache.bPurgeable == false || pCache.nMin == 10 ); - Debug.Assert( pCache.nMin == 0 || pCache.bPurgeable ); - pcache1EnterMutex( pGroup = pCache.pGroup ); - - /* Step 1: Search the hash table for an existing entry. */ - if ( pCache.nHash > 0 ) - { - int h = (int)( iKey % pCache.nHash ); - for ( pPage = pCache.apHash[h]; pPage != null && pPage.iKey != iKey; pPage = pPage.pNext ) - ; - } + /* + ** Implementation of the sqlite3_pcache.xCachesize method. + ** + ** Configure the cache_size limit for a cache. + */ + static void pcache1Cachesize(sqlite3_pcache p, int nMax) { + PCache1 pCache = (PCache1)p; + if (pCache.bPurgeable) { + PGroup pGroup = pCache.pGroup; + pcache1EnterMutex(pGroup); + pGroup.nMaxPage += nMax - pCache.nMax; + pGroup.mxPinned = pGroup.nMaxPage + 10 - pGroup.nMinPage; + pCache.nMax = nMax; + pCache.n90pct = pCache.nMax * 9 / 10; + pcache1EnforceMaxPage(pGroup); + pcache1LeaveMutex(pGroup); + } + } - /* Step 2: Abort if no existing page is found and createFlag is 0 */ - if ( pPage != null || createFlag == 0 ) - { - pcache1PinPage( pPage ); - goto fetch_out; - } + /* + ** Implementation of the sqlite3_pcache.xPagecount method. + */ + static int pcache1Pagecount(sqlite3_pcache p) { + int n; + PCache1 pCache = (PCache1)p; + pcache1EnterMutex(pCache.pGroup); + n = (int)pCache.nPage; + pcache1LeaveMutex(pCache.pGroup); + return n; + } - /* The pGroup local variable will normally be initialized by the - ** pcache1EnterMutex() macro above. But if SQLITE_MUTEX_OMIT is defined, - ** then pcache1EnterMutex() is a no-op, so we have to initialize the - ** local variable here. Delaying the initialization of pGroup is an - ** optimization: The common case is to exit the module before reaching - ** this point. - */ -#if SQLITE_MUTEX_OMIT + /* + ** Implementation of the sqlite3_pcache.xFetch method. + ** + ** Fetch a page by key value. + ** + ** Whether or not a new page may be allocated by this function depends on + ** the value of the createFlag argument. 0 means do not allocate a new + ** page. 1 means allocate a new page if space is easily available. 2 + ** means to try really hard to allocate a new page. + ** + ** For a non-purgeable cache (a cache used as the storage for an in-memory + ** database) there is really no difference between createFlag 1 and 2. So + ** the calling function (pcache.c) will never have a createFlag of 1 on + ** a non-purgable cache. + ** + ** There are three different approaches to obtaining space for a page, + ** depending on the value of parameter createFlag (which may be 0, 1 or 2). + ** + ** 1. Regardless of the value of createFlag, the cache is searched for a + ** copy of the requested page. If one is found, it is returned. + ** + ** 2. If createFlag==0 and the page is not already in the cache, NULL is + ** returned. + ** + ** 3. If createFlag is 1, and the page is not already in the cache, then + ** return NULL (do not allocate a new page) if any of the following + ** conditions are true: + ** + ** (a) the number of pages pinned by the cache is greater than + ** PCache1.nMax, or + ** + ** (b) the number of pages pinned by the cache is greater than + ** the sum of nMax for all purgeable caches, less the sum of + ** nMin for all other purgeable caches, or + ** + ** 4. If none of the first three conditions apply and the cache is marked + ** as purgeable, and if one of the following is true: + ** + ** (a) The number of pages allocated for the cache is already + ** PCache1.nMax, or + ** + ** (b) The number of pages allocated for all purgeable caches is + ** already equal to or greater than the sum of nMax for all + ** purgeable caches, + ** + ** (c) The system is under memory pressure and wants to avoid + ** unnecessary pages cache entry allocations + ** + ** then attempt to recycle a page from the LRU list. If it is the right + ** size, return the recycled buffer. Otherwise, free the buffer and + ** proceed to step 5. + ** + ** 5. Otherwise, allocate and return a new page buffer. + */ + static PgHdr pcache1Fetch(sqlite3_pcache p, Pgno iKey, int createFlag) { + int nPinned; + PCache1 pCache = (PCache1)p; + PGroup pGroup; + PgHdr1 pPage = null; + + Debug.Assert(pCache.bPurgeable || createFlag != 1); + Debug.Assert(pCache.bPurgeable || pCache.nMin == 0); + Debug.Assert(pCache.bPurgeable == false || pCache.nMin == 10); + Debug.Assert(pCache.nMin == 0 || pCache.bPurgeable); + pcache1EnterMutex(pGroup = pCache.pGroup); + + /* Step 1: Search the hash table for an existing entry. */ + if (pCache.nHash > 0) { + int h = (int)(iKey % pCache.nHash); + for (pPage = pCache.apHash[h]; pPage != null && pPage.iKey != iKey; pPage = pPage.pNext) + ; + } + + /* Step 2: Abort if no existing page is found and createFlag is 0 */ + if (pPage != null || createFlag == 0) { + pcache1PinPage(pPage); + goto fetch_out; + } + + /* The pGroup local variable will normally be initialized by the + ** pcache1EnterMutex() macro above. But if SQLITE_MUTEX_OMIT is defined, + ** then pcache1EnterMutex() is a no-op, so we have to initialize the + ** local variable here. Delaying the initialization of pGroup is an + ** optimization: The common case is to exit the module before reaching + ** this point. + */ +#if SQLITE_MUTEX_OMIT pGroup = pCache.pGroup; #endif - /* Step 3: Abort if createFlag is 1 but the cache is nearly full */ - nPinned = pCache.nPage - pCache.nRecyclable; - Debug.Assert( nPinned >= 0 ); - Debug.Assert( pGroup.mxPinned == pGroup.nMaxPage + 10 - pGroup.nMinPage ); - Debug.Assert( pCache.n90pct == pCache.nMax * 9 / 10 ); - if ( createFlag == 1 && ( - nPinned >= pGroup.mxPinned - || nPinned >= (int)pCache.n90pct - || pcache1UnderMemoryPressure( pCache ) - ) ) - { - goto fetch_out; - } - - if ( pCache.nPage >= pCache.nHash && pcache1ResizeHash( pCache ) != 0 ) - { - goto fetch_out; - } - - /* Step 4. Try to recycle a page. */ - if ( pCache.bPurgeable && pGroup.pLruTail != null && ( - ( pCache.nPage + 1 >= pCache.nMax ) - || pGroup.nCurrentPage >= pGroup.nMaxPage - || pcache1UnderMemoryPressure( pCache ) - ) ) - { - PCache1 pOtherCache; - pPage = pGroup.pLruTail; - pcache1RemoveFromHash( pPage ); - pcache1PinPage( pPage ); - if ( ( pOtherCache = pPage.pCache ).szPage != pCache.szPage ) - { - pcache1FreePage( ref pPage ); - pPage = null; - } - else - { - pGroup.nCurrentPage -= - ( pOtherCache.bPurgeable ? 1 : 0 ) - ( pCache.bPurgeable ? 1 : 0 ); + /* Step 3: Abort if createFlag is 1 but the cache is nearly full */ + nPinned = pCache.nPage - pCache.nRecyclable; + Debug.Assert(nPinned >= 0); + Debug.Assert(pGroup.mxPinned == pGroup.nMaxPage + 10 - pGroup.nMinPage); + Debug.Assert(pCache.n90pct == pCache.nMax * 9 / 10); + if (createFlag == 1 && ( + nPinned >= pGroup.mxPinned + || nPinned >= (int)pCache.n90pct + || pcache1UnderMemoryPressure(pCache) + )) { + goto fetch_out; + } + + if (pCache.nPage >= pCache.nHash && pcache1ResizeHash(pCache) != 0) { + goto fetch_out; + } + + /* Step 4. Try to recycle a page. */ + if (pCache.bPurgeable && pGroup.pLruTail != null && ( + (pCache.nPage + 1 >= pCache.nMax) + || pGroup.nCurrentPage >= pGroup.nMaxPage + || pcache1UnderMemoryPressure(pCache) + )) { + PCache1 pOtherCache; + pPage = pGroup.pLruTail; + pcache1RemoveFromHash(pPage); + pcache1PinPage(pPage); + if ((pOtherCache = pPage.pCache).szPage != pCache.szPage) { + pcache1FreePage(ref pPage); + pPage = null; + } else { + pGroup.nCurrentPage -= + (pOtherCache.bPurgeable ? 1 : 0) - (pCache.bPurgeable ? 1 : 0); + } + } + + /* Step 5. If a usable page buffer has still not been found, + ** attempt to allocate a new one. + */ + if (null == pPage) { + if (createFlag == 1) + sqlite3BeginBenignMalloc(); + pcache1LeaveMutex(pGroup); + pPage = pcache1AllocPage(pCache); + pcache1EnterMutex(pGroup); + if (createFlag == 1) + sqlite3EndBenignMalloc(); + } + + if (pPage != null) { + int h = (int)(iKey % pCache.nHash); + pCache.nPage++; + pPage.iKey = iKey; + pPage.pNext = pCache.apHash[h]; + pPage.pCache = pCache; + pPage.pLruPrev = null; + pPage.pLruNext = null; + PGHDR1_TO_PAGE(pPage).Clear();// *(void **)(PGHDR1_TO_PAGE(pPage)) = 0; + pPage.pPgHdr.pPgHdr1 = pPage; + pCache.apHash[h] = pPage; + } + + fetch_out: + if (pPage != null && iKey > pCache.iMaxKey) { + pCache.iMaxKey = iKey; + } + pcache1LeaveMutex(pGroup); + return (pPage != null ? PGHDR1_TO_PAGE(pPage) : null); } - } - /* Step 5. If a usable page buffer has still not been found, - ** attempt to allocate a new one. - */ - if ( null == pPage ) - { - if ( createFlag == 1 ) - sqlite3BeginBenignMalloc(); - pcache1LeaveMutex( pGroup ); - pPage = pcache1AllocPage( pCache ); - pcache1EnterMutex( pGroup ); - if ( createFlag == 1 ) - sqlite3EndBenignMalloc(); - } - if ( pPage != null ) - { - int h = (int)( iKey % pCache.nHash ); - pCache.nPage++; - pPage.iKey = iKey; - pPage.pNext = pCache.apHash[h]; - pPage.pCache = pCache; - pPage.pLruPrev = null; - pPage.pLruNext = null; - PGHDR1_TO_PAGE( pPage ).Clear();// *(void **)(PGHDR1_TO_PAGE(pPage)) = 0; - pPage.pPgHdr.pPgHdr1 = pPage; - pCache.apHash[h] = pPage; - } - -fetch_out: - if ( pPage != null && iKey > pCache.iMaxKey ) - { - pCache.iMaxKey = iKey; - } - pcache1LeaveMutex( pGroup ); - return ( pPage != null ? PGHDR1_TO_PAGE( pPage ) : null ); - } - - - /* - ** Implementation of the sqlite3_pcache.xUnpin method. - ** - ** Mark a page as unpinned (eligible for asynchronous recycling). - */ - static void pcache1Unpin( sqlite3_pcache p, PgHdr pPg, bool reuseUnlikely ) - { - PCache1 pCache = (PCache1)p; - PgHdr1 pPage = PAGE_TO_PGHDR1( pCache, pPg ); - PGroup pGroup = pCache.pGroup; - - Debug.Assert( pPage.pCache == pCache ); - pcache1EnterMutex( pGroup ); - - /* It is an error to call this function if the page is already - ** part of the PGroup LRU list. - */ - Debug.Assert( pPage.pLruPrev == null && pPage.pLruNext == null ); - Debug.Assert( pGroup.pLruHead != pPage && pGroup.pLruTail != pPage ); - - if ( reuseUnlikely || pGroup.nCurrentPage > pGroup.nMaxPage ) - { - pcache1RemoveFromHash( pPage ); - pcache1FreePage( ref pPage ); - } - else - { - /* Add the page to the PGroup LRU list. */ - if ( pGroup.pLruHead != null ) - { - pGroup.pLruHead.pLruPrev = pPage; - pPage.pLruNext = pGroup.pLruHead; - pGroup.pLruHead = pPage; - } - else - { - pGroup.pLruTail = pPage; - pGroup.pLruHead = pPage; + /* + ** Implementation of the sqlite3_pcache.xUnpin method. + ** + ** Mark a page as unpinned (eligible for asynchronous recycling). + */ + static void pcache1Unpin(sqlite3_pcache p, PgHdr pPg, bool reuseUnlikely) { + PCache1 pCache = (PCache1)p; + PgHdr1 pPage = PAGE_TO_PGHDR1(pCache, pPg); + PGroup pGroup = pCache.pGroup; + + Debug.Assert(pPage.pCache == pCache); + pcache1EnterMutex(pGroup); + + /* It is an error to call this function if the page is already + ** part of the PGroup LRU list. + */ + Debug.Assert(pPage.pLruPrev == null && pPage.pLruNext == null); + Debug.Assert(pGroup.pLruHead != pPage && pGroup.pLruTail != pPage); + + if (reuseUnlikely || pGroup.nCurrentPage > pGroup.nMaxPage) { + pcache1RemoveFromHash(pPage); + pcache1FreePage(ref pPage); + } else { + /* Add the page to the PGroup LRU list. */ + if (pGroup.pLruHead != null) { + pGroup.pLruHead.pLruPrev = pPage; + pPage.pLruNext = pGroup.pLruHead; + pGroup.pLruHead = pPage; + } else { + pGroup.pLruTail = pPage; + pGroup.pLruHead = pPage; + } + pCache.nRecyclable++; + } + + pcache1LeaveMutex(pCache.pGroup); } - pCache.nRecyclable++; - } - pcache1LeaveMutex( pCache.pGroup ); - } + /* + ** Implementation of the sqlite3_pcache.xRekey method. + */ + static void pcache1Rekey( + sqlite3_pcache p, + PgHdr pPg, + Pgno iOld, + Pgno iNew + ) { + PCache1 pCache = (PCache1)p; + PgHdr1 pPage = PAGE_TO_PGHDR1(pCache, pPg); + PgHdr1 pp; + int h; + Debug.Assert(pPage.iKey == iOld); + Debug.Assert(pPage.pCache == pCache); + + pcache1EnterMutex(pCache.pGroup); + + h = (int)(iOld % pCache.nHash); + pp = pCache.apHash[h]; + while ((pp) != pPage) { + pp = (pp).pNext; + } + if (pp == pCache.apHash[h]) + pCache.apHash[h] = pp.pNext; + else + pp.pNext = pPage.pNext; - /* - ** Implementation of the sqlite3_pcache.xRekey method. - */ - static void pcache1Rekey( - sqlite3_pcache p, - PgHdr pPg, - Pgno iOld, - Pgno iNew - ) - { - PCache1 pCache = (PCache1)p; - PgHdr1 pPage = PAGE_TO_PGHDR1( pCache, pPg ); - PgHdr1 pp; - int h; - Debug.Assert( pPage.iKey == iOld ); - Debug.Assert( pPage.pCache == pCache ); - - pcache1EnterMutex( pCache.pGroup ); - - h = (int)( iOld % pCache.nHash ); - pp = pCache.apHash[h]; - while ( ( pp ) != pPage ) - { - pp = ( pp ).pNext; - } - if ( pp == pCache.apHash[h] ) - pCache.apHash[h] = pp.pNext; - else - pp.pNext = pPage.pNext; - - h = (int)( iNew % pCache.nHash ); - pPage.iKey = iNew; - pPage.pNext = pCache.apHash[h]; - pCache.apHash[h] = pPage; - if ( iNew > pCache.iMaxKey ) - { - pCache.iMaxKey = iNew; - } + h = (int)(iNew % pCache.nHash); + pPage.iKey = iNew; + pPage.pNext = pCache.apHash[h]; + pCache.apHash[h] = pPage; + if (iNew > pCache.iMaxKey) { + pCache.iMaxKey = iNew; + } - pcache1LeaveMutex( pCache.pGroup ); - } + pcache1LeaveMutex(pCache.pGroup); + } - /* - ** Implementation of the sqlite3_pcache.xTruncate method. - ** - ** Discard all unpinned pages in the cache with a page number equal to - ** or greater than parameter iLimit. Any pinned pages with a page number - ** equal to or greater than iLimit are implicitly unpinned. - */ - static void pcache1Truncate( sqlite3_pcache p, Pgno iLimit ) - { - PCache1 pCache = (PCache1)p; - pcache1EnterMutex( pCache.pGroup ); - if ( iLimit <= pCache.iMaxKey ) - { - pcache1TruncateUnsafe( pCache, iLimit ); - pCache.iMaxKey = iLimit - 1; - } - pcache1LeaveMutex( pCache.pGroup ); - } + /* + ** Implementation of the sqlite3_pcache.xTruncate method. + ** + ** Discard all unpinned pages in the cache with a page number equal to + ** or greater than parameter iLimit. Any pinned pages with a page number + ** equal to or greater than iLimit are implicitly unpinned. + */ + static void pcache1Truncate(sqlite3_pcache p, Pgno iLimit) { + PCache1 pCache = (PCache1)p; + pcache1EnterMutex(pCache.pGroup); + if (iLimit <= pCache.iMaxKey) { + pcache1TruncateUnsafe(pCache, iLimit); + pCache.iMaxKey = iLimit - 1; + } + pcache1LeaveMutex(pCache.pGroup); + } - /* - ** Implementation of the sqlite3_pcache.xDestroy method. - ** - ** Destroy a cache allocated using pcache1Create(). - */ - static void pcache1Destroy( ref sqlite3_pcache p ) - { - PCache1 pCache = (PCache1)p; - PGroup pGroup = pCache.pGroup; - Debug.Assert( pCache.bPurgeable || ( pCache.nMax == 0 && pCache.nMin == 0 ) ); - pcache1EnterMutex( pGroup ); - pcache1TruncateUnsafe( pCache, 0 ); - pGroup.nMaxPage -= pCache.nMax; - pGroup.nMinPage -= pCache.nMin; - pGroup.mxPinned = pGroup.nMaxPage + 10 - pGroup.nMinPage; - pcache1EnforceMaxPage( pGroup ); - pcache1LeaveMutex( pGroup ); - //sqlite3_free( pCache.apHash ); - //sqlite3_free( pCache ); - p = null; - } + /* + ** Implementation of the sqlite3_pcache.xDestroy method. + ** + ** Destroy a cache allocated using pcache1Create(). + */ + static void pcache1Destroy(ref sqlite3_pcache p) { + PCache1 pCache = (PCache1)p; + PGroup pGroup = pCache.pGroup; + Debug.Assert(pCache.bPurgeable || (pCache.nMax == 0 && pCache.nMin == 0)); + pcache1EnterMutex(pGroup); + pcache1TruncateUnsafe(pCache, 0); + pGroup.nMaxPage -= pCache.nMax; + pGroup.nMinPage -= pCache.nMin; + pGroup.mxPinned = pGroup.nMaxPage + 10 - pGroup.nMinPage; + pcache1EnforceMaxPage(pGroup); + pcache1LeaveMutex(pGroup); + //sqlite3_free( pCache.apHash ); + //sqlite3_free( pCache ); + p = null; + } - /* - ** This function is called during initialization (sqlite3_initialize()) to - ** install the default pluggable cache module, assuming the user has not - ** already provided an alternative. - */ - static void sqlite3PCacheSetDefault() - { - sqlite3_pcache_methods defaultMethods = new sqlite3_pcache_methods( - 0, /* pArg */ - (dxPC_Init)pcache1Init, /* xInit */ - (dxPC_Shutdown)pcache1Shutdown, /* xShutdown */ - (dxPC_Create)pcache1Create, /* xCreate */ - (dxPC_Cachesize)pcache1Cachesize, /* xCachesize */ - (dxPC_Pagecount)pcache1Pagecount, /* xPagecount */ - (dxPC_Fetch)pcache1Fetch, /* xFetch */ - (dxPC_Unpin)pcache1Unpin, /* xUnpin */ - (dxPC_Rekey)pcache1Rekey, /* xRekey */ - (dxPC_Truncate)pcache1Truncate, /* xTruncate */ - (dxPC_Destroy)pcache1Destroy /* xDestroy */ - ); - sqlite3_config( SQLITE_CONFIG_PCACHE, defaultMethods ); - } + /* + ** This function is called during initialization (sqlite3_initialize()) to + ** install the default pluggable cache module, assuming the user has not + ** already provided an alternative. + */ + static void sqlite3PCacheSetDefault() { + sqlite3_pcache_methods defaultMethods = new sqlite3_pcache_methods( + 0, /* pArg */ + (dxPC_Init)pcache1Init, /* xInit */ + (dxPC_Shutdown)pcache1Shutdown, /* xShutdown */ + (dxPC_Create)pcache1Create, /* xCreate */ + (dxPC_Cachesize)pcache1Cachesize, /* xCachesize */ + (dxPC_Pagecount)pcache1Pagecount, /* xPagecount */ + (dxPC_Fetch)pcache1Fetch, /* xFetch */ + (dxPC_Unpin)pcache1Unpin, /* xUnpin */ + (dxPC_Rekey)pcache1Rekey, /* xRekey */ + (dxPC_Truncate)pcache1Truncate, /* xTruncate */ + (dxPC_Destroy)pcache1Destroy /* xDestroy */ + ); + sqlite3_config(SQLITE_CONFIG_PCACHE, defaultMethods); + } #if SQLITE_ENABLE_MEMORY_MANAGEMENT /* @@ -1168,5 +1072,5 @@ static void sqlite3PcacheStats( pnRecyclable = nRecyclable; } #endif - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/pcache_c.cs b/Src/IronPython.SQLite/c#sqlite/pcache_c.cs index 34f171c3c..b008e9088 100644 --- a/Src/IronPython.SQLite/c#sqlite/pcache_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/pcache_c.cs @@ -1,93 +1,84 @@ -using System; using System.Diagnostics; -using System.Text; -using u32 = System.UInt32; using Pgno = System.UInt32; +using u32 = System.UInt32; -namespace Community.CsharpSqlite -{ - using sqlite3_value = Sqlite3.Mem; - using sqlite3_pcache = Sqlite3.PCache1; - - public partial class Sqlite3 - { - /* - ** 2008 August 05 - ** - ** 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 implements that page cache. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - - /* - ** A complete page cache is an instance of this structure. - */ - public class PCache - { - public PgHdr pDirty, pDirtyTail; /* List of dirty pages in LRU order */ - public PgHdr pSynced; /* Last synced page in dirty page list */ - public int _nRef; /* Number of referenced pages */ - public int nMax; /* Configured cache size */ - public int szPage; /* Size of every page in this cache */ - public int szExtra; /* Size of extra space for each page */ - public bool bPurgeable; /* True if pages are on backing store */ - public dxStress xStress; //int (*xStress)(void*,PgHdr*); /* Call to try make a page clean */ - public object pStress; /* Argument to xStress */ - public sqlite3_pcache pCache; /* Pluggable cache module */ - public PgHdr pPage1; /* Reference to page 1 */ - - public int nRef /* Number of referenced pages */ - { - get - { - return _nRef; - } - set - { - _nRef = value; - } - } - - public void Clear() - { - pDirty = null; - pDirtyTail = null; - pSynced = null; - nRef = 0; - } - }; +namespace Community.CsharpSqlite { + using sqlite3_pcache = Sqlite3.PCache1; + + public partial class Sqlite3 { + /* + ** 2008 August 05 + ** + ** 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 implements that page cache. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" - /* - ** Some of the Debug.Assert() macros in this code are too expensive to run - ** even during normal debugging. Use them only rarely on long-running - ** tests. Enable the expensive asserts using the - ** -DSQLITE_ENABLE_EXPENSIVE_ASSERT=1 compile-time option. - */ + /* + ** A complete page cache is an instance of this structure. + */ + public class PCache { + public PgHdr pDirty, pDirtyTail; /* List of dirty pages in LRU order */ + public PgHdr pSynced; /* Last synced page in dirty page list */ + public int _nRef; /* Number of referenced pages */ + public int nMax; /* Configured cache size */ + public int szPage; /* Size of every page in this cache */ + public int szExtra; /* Size of extra space for each page */ + public bool bPurgeable; /* True if pages are on backing store */ + public dxStress xStress; //int (*xStress)(void*,PgHdr*); /* Call to try make a page clean */ + public object pStress; /* Argument to xStress */ + public sqlite3_pcache pCache; /* Pluggable cache module */ + public PgHdr pPage1; /* Reference to page 1 */ + + public int nRef /* Number of referenced pages */ + { + get { + return _nRef; + } + set { + _nRef = value; + } + } + + public void Clear() { + pDirty = null; + pDirtyTail = null; + pSynced = null; + nRef = 0; + } + }; + + /* + ** Some of the Debug.Assert() macros in this code are too expensive to run + ** even during normal debugging. Use them only rarely on long-running + ** tests. Enable the expensive asserts using the + ** -DSQLITE_ENABLE_EXPENSIVE_ASSERT=1 compile-time option. + */ #if SQLITE_ENABLE_EXPENSIVE_ASSERT //# define expensive_assert(X) Debug.Assert(X) static void expensive_assert( bool x ) { Debug.Assert( x ); } #else - //# define expensive_assert(X) + //# define expensive_assert(X) #endif - /********************************** Linked List Management ********************/ + /********************************** Linked List Management ********************/ -#if !NDEBUG && SQLITE_ENABLE_EXPENSIVE_ASSERT +#if !NDEBUG && SQLITE_ENABLE_EXPENSIVE_ASSERT /* ** Check that the pCache.pSynced variable is set correctly. If it ** is not, either fail an Debug.Assert or return zero. Otherwise, return @@ -104,239 +95,209 @@ static int pcacheCheckSynced(PCache pCache){ } #endif //* !NDEBUG && SQLITE_ENABLE_EXPENSIVE_ASSERT */ - /* -** Remove page pPage from the list of dirty pages. -*/ - static void pcacheRemoveFromDirtyList( PgHdr pPage ) - { - PCache p = pPage.pCache; - - Debug.Assert( pPage.pDirtyNext != null || pPage == p.pDirtyTail ); - Debug.Assert( pPage.pDirtyPrev != null || pPage == p.pDirty ); - - /* Update the PCache1.pSynced variable if necessary. */ - if ( p.pSynced == pPage ) - { - PgHdr pSynced = pPage.pDirtyPrev; - while ( pSynced != null && ( pSynced.flags & PGHDR_NEED_SYNC ) != 0 ) - { - pSynced = pSynced.pDirtyPrev; - } - p.pSynced = pSynced; - } - - if ( pPage.pDirtyNext != null ) - { - pPage.pDirtyNext.pDirtyPrev = pPage.pDirtyPrev; - } - else - { - Debug.Assert( pPage == p.pDirtyTail ); - p.pDirtyTail = pPage.pDirtyPrev; - } - if ( pPage.pDirtyPrev != null ) - { - pPage.pDirtyPrev.pDirtyNext = pPage.pDirtyNext; - } - else - { - Debug.Assert( pPage == p.pDirty ); - p.pDirty = pPage.pDirtyNext; - } - pPage.pDirtyNext = null; - pPage.pDirtyPrev = null; + /* + ** Remove page pPage from the list of dirty pages. + */ + static void pcacheRemoveFromDirtyList(PgHdr pPage) { + PCache p = pPage.pCache; + + Debug.Assert(pPage.pDirtyNext != null || pPage == p.pDirtyTail); + Debug.Assert(pPage.pDirtyPrev != null || pPage == p.pDirty); + + /* Update the PCache1.pSynced variable if necessary. */ + if (p.pSynced == pPage) { + PgHdr pSynced = pPage.pDirtyPrev; + while (pSynced != null && (pSynced.flags & PGHDR_NEED_SYNC) != 0) { + pSynced = pSynced.pDirtyPrev; + } + p.pSynced = pSynced; + } + + if (pPage.pDirtyNext != null) { + pPage.pDirtyNext.pDirtyPrev = pPage.pDirtyPrev; + } else { + Debug.Assert(pPage == p.pDirtyTail); + p.pDirtyTail = pPage.pDirtyPrev; + } + if (pPage.pDirtyPrev != null) { + pPage.pDirtyPrev.pDirtyNext = pPage.pDirtyNext; + } else { + Debug.Assert(pPage == p.pDirty); + p.pDirty = pPage.pDirtyNext; + } + pPage.pDirtyNext = null; + pPage.pDirtyPrev = null; #if SQLITE_ENABLE_EXPENSIVE_ASSERT expensive_assert( pcacheCheckSynced(p) ); #endif - } + } - /* - ** Add page pPage to the head of the dirty list (PCache1.pDirty is set to - ** pPage). - */ - static void pcacheAddToDirtyList( PgHdr pPage ) - { - PCache p = pPage.pCache; - - Debug.Assert( pPage.pDirtyNext == null && pPage.pDirtyPrev == null && p.pDirty != pPage ); - - pPage.pDirtyNext = p.pDirty; - if ( pPage.pDirtyNext != null ) - { - Debug.Assert( pPage.pDirtyNext.pDirtyPrev == null ); - pPage.pDirtyNext.pDirtyPrev = pPage; - } - p.pDirty = pPage; - if ( null == p.pDirtyTail ) - { - p.pDirtyTail = pPage; - } - if ( null == p.pSynced && 0 == ( pPage.flags & PGHDR_NEED_SYNC ) ) - { - p.pSynced = pPage; - } + /* + ** Add page pPage to the head of the dirty list (PCache1.pDirty is set to + ** pPage). + */ + static void pcacheAddToDirtyList(PgHdr pPage) { + PCache p = pPage.pCache; + + Debug.Assert(pPage.pDirtyNext == null && pPage.pDirtyPrev == null && p.pDirty != pPage); + + pPage.pDirtyNext = p.pDirty; + if (pPage.pDirtyNext != null) { + Debug.Assert(pPage.pDirtyNext.pDirtyPrev == null); + pPage.pDirtyNext.pDirtyPrev = pPage; + } + p.pDirty = pPage; + if (null == p.pDirtyTail) { + p.pDirtyTail = pPage; + } + if (null == p.pSynced && 0 == (pPage.flags & PGHDR_NEED_SYNC)) { + p.pSynced = pPage; + } #if SQLITE_ENABLE_EXPENSIVE_ASSERT expensive_assert( pcacheCheckSynced(p) ); #endif - } - - /* - ** Wrapper around the pluggable caches xUnpin method. If the cache is - ** being used for an in-memory database, this function is a no-op. - */ - static void pcacheUnpin( PgHdr p ) - { - PCache pCache = p.pCache; - if ( pCache.bPurgeable ) - { - if ( p.pgno == 1 ) - { - pCache.pPage1 = null; } - sqlite3GlobalConfig.pcache.xUnpin( pCache.pCache, p, false ); - } - } - /*************************************************** General Interfaces ****** - ** - ** Initialize and shutdown the page cache subsystem. Neither of these - ** functions are threadsafe. - */ - static int sqlite3PcacheInitialize() - { - if ( sqlite3GlobalConfig.pcache.xInit == null ) - { - /* IMPLEMENTATION-OF: R-26801-64137 If the xInit() method is NULL, then the - ** built-in default page cache is used instead of the application defined - ** page cache. */ - sqlite3PCacheSetDefault(); - } - return sqlite3GlobalConfig.pcache.xInit( sqlite3GlobalConfig.pcache.pArg ); - } - static void sqlite3PcacheShutdown() - { - if ( sqlite3GlobalConfig.pcache.xShutdown != null ) - { - /* IMPLEMENTATION-OF: R-26000-56589 The xShutdown() method may be NULL. */ - sqlite3GlobalConfig.pcache.xShutdown( sqlite3GlobalConfig.pcache.pArg ); - } - } + /* + ** Wrapper around the pluggable caches xUnpin method. If the cache is + ** being used for an in-memory database, this function is a no-op. + */ + static void pcacheUnpin(PgHdr p) { + PCache pCache = p.pCache; + if (pCache.bPurgeable) { + if (p.pgno == 1) { + pCache.pPage1 = null; + } + sqlite3GlobalConfig.pcache.xUnpin(pCache.pCache, p, false); + } + } - /* - ** Return the size in bytes of a PCache object. - */ - static int sqlite3PcacheSize() - { - return 4; - }// sizeof( PCache ); } + /*************************************************** General Interfaces ****** + ** + ** Initialize and shutdown the page cache subsystem. Neither of these + ** functions are threadsafe. + */ + static int sqlite3PcacheInitialize() { + if (sqlite3GlobalConfig.pcache.xInit == null) { + /* IMPLEMENTATION-OF: R-26801-64137 If the xInit() method is NULL, then the + ** built-in default page cache is used instead of the application defined + ** page cache. */ + sqlite3PCacheSetDefault(); + } + return sqlite3GlobalConfig.pcache.xInit(sqlite3GlobalConfig.pcache.pArg); + } + static void sqlite3PcacheShutdown() { + if (sqlite3GlobalConfig.pcache.xShutdown != null) { + /* IMPLEMENTATION-OF: R-26000-56589 The xShutdown() method may be NULL. */ + sqlite3GlobalConfig.pcache.xShutdown(sqlite3GlobalConfig.pcache.pArg); + } + } - /* - ** Create a new PCache object. Storage space to hold the object - ** has already been allocated and is passed in as the p pointer. - ** The caller discovers how much space needs to be allocated by - ** calling sqlite3PcacheSize(). - */ - static void sqlite3PcacheOpen( - int szPage, /* Size of every page */ - int szExtra, /* Extra space associated with each page */ - bool bPurgeable, /* True if pages are on backing store */ - dxStress xStress,//int (*xStress)(void*,PgHdr*),/* Call to try to make pages clean */ - object pStress, /* Argument to xStress */ - PCache p /* Preallocated space for the PCache */ - ) - { - p.Clear();//memset(p, 0, sizeof(PCache)); - p.szPage = szPage; - p.szExtra = szExtra; - p.bPurgeable = bPurgeable; - p.xStress = xStress; - p.pStress = pStress; - p.nMax = 100; - } + /* + ** Return the size in bytes of a PCache object. + */ + static int sqlite3PcacheSize() { + return 4; + }// sizeof( PCache ); } + + /* + ** Create a new PCache object. Storage space to hold the object + ** has already been allocated and is passed in as the p pointer. + ** The caller discovers how much space needs to be allocated by + ** calling sqlite3PcacheSize(). + */ + static void sqlite3PcacheOpen( + int szPage, /* Size of every page */ + int szExtra, /* Extra space associated with each page */ + bool bPurgeable, /* True if pages are on backing store */ + dxStress xStress,//int (*xStress)(void*,PgHdr*),/* Call to try to make pages clean */ + object pStress, /* Argument to xStress */ + PCache p /* Preallocated space for the PCache */ + ) { + p.Clear();//memset(p, 0, sizeof(PCache)); + p.szPage = szPage; + p.szExtra = szExtra; + p.bPurgeable = bPurgeable; + p.xStress = xStress; + p.pStress = pStress; + p.nMax = 100; + } - /* - ** Change the page size for PCache object. The caller must ensure that there - ** are no outstanding page references when this function is called. - */ - static void sqlite3PcacheSetPageSize( PCache pCache, int szPage ) - { - Debug.Assert( pCache.nRef == 0 && pCache.pDirty == null ); - if ( pCache.pCache != null ) - { - sqlite3GlobalConfig.pcache.xDestroy( ref pCache.pCache ); - pCache.pCache = null; - } - pCache.szPage = szPage; - } + /* + ** Change the page size for PCache object. The caller must ensure that there + ** are no outstanding page references when this function is called. + */ + static void sqlite3PcacheSetPageSize(PCache pCache, int szPage) { + Debug.Assert(pCache.nRef == 0 && pCache.pDirty == null); + if (pCache.pCache != null) { + sqlite3GlobalConfig.pcache.xDestroy(ref pCache.pCache); + pCache.pCache = null; + } + pCache.szPage = szPage; + } - /* - ** Try to obtain a page from the cache. - */ - static int sqlite3PcacheFetch( - PCache pCache, /* Obtain the page from this cache */ - u32 pgno, /* Page number to obtain */ - int createFlag, /* If true, create page if it does not exist already */ - ref PgHdr ppPage /* Write the page here */ - ) - { - PgHdr pPage = null; - int eCreate; - - Debug.Assert( pCache != null ); - Debug.Assert( createFlag == 1 || createFlag == 0 ); - Debug.Assert( pgno > 0 ); - - /* If the pluggable cache (sqlite3_pcache*) has not been allocated, - ** allocate it now. - */ - if ( null == pCache.pCache && createFlag != 0 ) - { - sqlite3_pcache p; - int nByte; - nByte = pCache.szPage + pCache.szExtra + 0;// sizeof( PgHdr ); - p = sqlite3GlobalConfig.pcache.xCreate( nByte, pCache.bPurgeable ); - //if ( null == p ) - //{ - // return SQLITE_NOMEM; - //} - sqlite3GlobalConfig.pcache.xCachesize( p, pCache.nMax ); - pCache.pCache = p; - } - - eCreate = createFlag * ( 1 + ( ( !pCache.bPurgeable || null == pCache.pDirty ) ? 1 : 0 ) ); - - if ( pCache.pCache != null ) - { - pPage = sqlite3GlobalConfig.pcache.xFetch( pCache.pCache, pgno, eCreate ); - } - - if ( null == pPage && eCreate == 1 ) - { - PgHdr pPg; - - /* Find a dirty page to write-out and recycle. First try to find a - ** page that does not require a journal-sync (one with PGHDR_NEED_SYNC - ** cleared), but if that is not possible settle for any other - ** unreferenced dirty page. + /* + ** Try to obtain a page from the cache. */ + static int sqlite3PcacheFetch( + PCache pCache, /* Obtain the page from this cache */ + u32 pgno, /* Page number to obtain */ + int createFlag, /* If true, create page if it does not exist already */ + ref PgHdr ppPage /* Write the page here */ + ) { + PgHdr pPage = null; + int eCreate; + + Debug.Assert(pCache != null); + Debug.Assert(createFlag == 1 || createFlag == 0); + Debug.Assert(pgno > 0); + + /* If the pluggable cache (sqlite3_pcache*) has not been allocated, + ** allocate it now. + */ + if (null == pCache.pCache && createFlag != 0) { + sqlite3_pcache p; + int nByte; + nByte = pCache.szPage + pCache.szExtra + 0;// sizeof( PgHdr ); + p = sqlite3GlobalConfig.pcache.xCreate(nByte, pCache.bPurgeable); + //if ( null == p ) + //{ + // return SQLITE_NOMEM; + //} + sqlite3GlobalConfig.pcache.xCachesize(p, pCache.nMax); + pCache.pCache = p; + } + + eCreate = createFlag * (1 + ((!pCache.bPurgeable || null == pCache.pDirty) ? 1 : 0)); + + if (pCache.pCache != null) { + pPage = sqlite3GlobalConfig.pcache.xFetch(pCache.pCache, pgno, eCreate); + } + + if (null == pPage && eCreate == 1) { + PgHdr pPg; + + /* Find a dirty page to write-out and recycle. First try to find a + ** page that does not require a journal-sync (one with PGHDR_NEED_SYNC + ** cleared), but if that is not possible settle for any other + ** unreferenced dirty page. + */ #if SQLITE_ENABLE_EXPENSIVE_ASSERT expensive_assert( pcacheCheckSynced(pCache) ); #endif - for ( pPg = pCache.pSynced; - pPg != null && ( pPg.nRef != 0 || ( pPg.flags & PGHDR_NEED_SYNC ) != 0 ); - pPg = pPg.pDirtyPrev - ) - ; - pCache.pSynced = pPg; - if ( null == pPg ) - { - for ( pPg = pCache.pDirtyTail; pPg != null && pPg.nRef != 0; pPg = pPg.pDirtyPrev ) - ; - } - if ( pPg != null ) - { - int rc; + for (pPg = pCache.pSynced; + pPg != null && (pPg.nRef != 0 || (pPg.flags & PGHDR_NEED_SYNC) != 0); + pPg = pPg.pDirtyPrev + ) + ; + pCache.pSynced = pPg; + if (null == pPg) { + for (pPg = pCache.pDirtyTail; pPg != null && pPg.nRef != 0; pPg = pPg.pDirtyPrev) + ; + } + if (pPg != null) { + int rc; #if SQLITE_LOG_CACHE_SPILL sqlite3_log(SQLITE_FULL, "spill page %d making room for %d - cache used: %d/%d", @@ -344,366 +305,309 @@ ref PgHdr ppPage /* Write the page here */ sqlite3GlobalConfig.pcache.xPagecount(pCache->pCache), pCache->nMax); #endif - rc = pCache.xStress( pCache.pStress, pPg ); - if ( rc != SQLITE_OK && rc != SQLITE_BUSY ) - { - return rc; - } + rc = pCache.xStress(pCache.pStress, pPg); + if (rc != SQLITE_OK && rc != SQLITE_BUSY) { + return rc; + } + } + + pPage = sqlite3GlobalConfig.pcache.xFetch(pCache.pCache, pgno, 2); + } + + if (pPage != null) { + if (null == pPage.pData) { + // memset(pPage, 0, sizeof(PgHdr)); + pPage.pData = sqlite3Malloc(pCache.szPage);// pPage->pData = (void*)&pPage[1]; + //pPage->pExtra = (void*)&((char*)pPage->pData)[pCache->szPage]; + //memset(pPage->pExtra, 0, pCache->szExtra); + pPage.pCache = pCache; + pPage.pgno = pgno; + } + Debug.Assert(pPage.pCache == pCache); + Debug.Assert(pPage.pgno == pgno); + //assert(pPage->pData == (void*)&pPage[1]); + //assert(pPage->pExtra == (void*)&((char*)&pPage[1])[pCache->szPage]); + if (0 == pPage.nRef) { + pCache.nRef++; + } + pPage.nRef++; + if (pgno == 1) { + pCache.pPage1 = pPage; + } + } + ppPage = pPage; + return (pPage == null && eCreate != 0) ? SQLITE_NOMEM : SQLITE_OK; } - pPage = sqlite3GlobalConfig.pcache.xFetch( pCache.pCache, pgno, 2 ); - } - - if ( pPage != null ) - { - if ( null == pPage.pData ) - { - // memset(pPage, 0, sizeof(PgHdr)); - pPage.pData = sqlite3Malloc( pCache.szPage );// pPage->pData = (void*)&pPage[1]; - //pPage->pExtra = (void*)&((char*)pPage->pData)[pCache->szPage]; - //memset(pPage->pExtra, 0, pCache->szExtra); - pPage.pCache = pCache; - pPage.pgno = pgno; - } - Debug.Assert( pPage.pCache == pCache ); - Debug.Assert( pPage.pgno == pgno ); - //assert(pPage->pData == (void*)&pPage[1]); - //assert(pPage->pExtra == (void*)&((char*)&pPage[1])[pCache->szPage]); - if ( 0 == pPage.nRef ) - { - pCache.nRef++; - } - pPage.nRef++; - if ( pgno == 1 ) - { - pCache.pPage1 = pPage; + /* + ** Decrement the reference count on a page. If the page is clean and the + ** reference count drops to 0, then it is made elible for recycling. + */ + static void sqlite3PcacheRelease(PgHdr p) { + Debug.Assert(p.nRef > 0); + p.nRef--; + if (p.nRef == 0) { + PCache pCache = p.pCache; + pCache.nRef--; + if ((p.flags & PGHDR_DIRTY) == 0) { + pcacheUnpin(p); + } else { + /* Move the page to the head of the dirty list. */ + pcacheRemoveFromDirtyList(p); + pcacheAddToDirtyList(p); + } + } } - } - ppPage = pPage; - return ( pPage == null && eCreate != 0 ) ? SQLITE_NOMEM : SQLITE_OK; - } - /* - ** Decrement the reference count on a page. If the page is clean and the - ** reference count drops to 0, then it is made elible for recycling. - */ - static void sqlite3PcacheRelease( PgHdr p ) - { - Debug.Assert( p.nRef > 0 ); - p.nRef--; - if ( p.nRef == 0 ) - { - PCache pCache = p.pCache; - pCache.nRef--; - if ( ( p.flags & PGHDR_DIRTY ) == 0 ) - { - pcacheUnpin( p ); - } - else - { - /* Move the page to the head of the dirty list. */ - pcacheRemoveFromDirtyList( p ); - pcacheAddToDirtyList( p ); + /* + ** Increase the reference count of a supplied page by 1. + */ + static void sqlite3PcacheRef(PgHdr p) { + Debug.Assert(p.nRef > 0); + p.nRef++; } - } - } - - /* - ** Increase the reference count of a supplied page by 1. - */ - static void sqlite3PcacheRef( PgHdr p ) - { - Debug.Assert( p.nRef > 0 ); - p.nRef++; - } - - /* - ** Drop a page from the cache. There must be exactly one reference to the - ** page. This function deletes that reference, so after it returns the - ** page pointed to by p is invalid. - */ - static void sqlite3PcacheDrop( PgHdr p ) - { - PCache pCache; - Debug.Assert( p.nRef == 1 ); - if ( ( p.flags & PGHDR_DIRTY ) != 0 ) - { - pcacheRemoveFromDirtyList( p ); - } - pCache = p.pCache; - pCache.nRef--; - if ( p.pgno == 1 ) - { - pCache.pPage1 = null; - } - sqlite3GlobalConfig.pcache.xUnpin( pCache.pCache, p, true ); - } - /* - ** Make sure the page is marked as dirty. If it isn't dirty already, - ** make it so. - */ - static void sqlite3PcacheMakeDirty( PgHdr p ) - { - p.flags &= ~PGHDR_DONT_WRITE; - Debug.Assert( p.nRef > 0 ); - if ( 0 == ( p.flags & PGHDR_DIRTY ) ) - { - p.flags |= PGHDR_DIRTY; - pcacheAddToDirtyList( p ); - } - } - - /* - ** Make sure the page is marked as clean. If it isn't clean already, - ** make it so. - */ - static void sqlite3PcacheMakeClean( PgHdr p ) - { - if ( ( p.flags & PGHDR_DIRTY ) != 0 ) - { - pcacheRemoveFromDirtyList( p ); - p.flags &= ~( PGHDR_DIRTY | PGHDR_NEED_SYNC ); - if ( p.nRef == 0 ) - { - pcacheUnpin( p ); + /* + ** Drop a page from the cache. There must be exactly one reference to the + ** page. This function deletes that reference, so after it returns the + ** page pointed to by p is invalid. + */ + static void sqlite3PcacheDrop(PgHdr p) { + PCache pCache; + Debug.Assert(p.nRef == 1); + if ((p.flags & PGHDR_DIRTY) != 0) { + pcacheRemoveFromDirtyList(p); + } + pCache = p.pCache; + pCache.nRef--; + if (p.pgno == 1) { + pCache.pPage1 = null; + } + sqlite3GlobalConfig.pcache.xUnpin(pCache.pCache, p, true); } - } - } - - /* - ** Make every page in the cache clean. - */ - static void sqlite3PcacheCleanAll( PCache pCache ) - { - PgHdr p; - while ( ( p = pCache.pDirty ) != null ) - { - sqlite3PcacheMakeClean( p ); - } - } - /* - ** Clear the PGHDR_NEED_SYNC flag from all dirty pages. - */ - static void sqlite3PcacheClearSyncFlags( PCache pCache ) - { - PgHdr p; - for ( p = pCache.pDirty; p != null; p = p.pDirtyNext ) - { - p.flags &= ~PGHDR_NEED_SYNC; - } - pCache.pSynced = pCache.pDirtyTail; - } - - /* - ** Change the page number of page p to newPgno. - */ - static void sqlite3PcacheMove( PgHdr p, Pgno newPgno ) - { - PCache pCache = p.pCache; - Debug.Assert( p.nRef > 0 ); - Debug.Assert( newPgno > 0 ); - sqlite3GlobalConfig.pcache.xRekey( pCache.pCache, p, p.pgno, newPgno ); - p.pgno = newPgno; - if ( ( p.flags & PGHDR_DIRTY ) != 0 && ( p.flags & PGHDR_NEED_SYNC ) != 0 ) - { - pcacheRemoveFromDirtyList( p ); - pcacheAddToDirtyList( p ); - } - } + /* + ** Make sure the page is marked as dirty. If it isn't dirty already, + ** make it so. + */ + static void sqlite3PcacheMakeDirty(PgHdr p) { + p.flags &= ~PGHDR_DONT_WRITE; + Debug.Assert(p.nRef > 0); + if (0 == (p.flags & PGHDR_DIRTY)) { + p.flags |= PGHDR_DIRTY; + pcacheAddToDirtyList(p); + } + } - /* - ** Drop every cache entry whose page number is greater than "pgno". The - ** caller must ensure that there are no outstanding references to any pages - ** other than page 1 with a page number greater than pgno. - ** - ** If there is a reference to page 1 and the pgno parameter passed to this - ** function is 0, then the data area associated with page 1 is zeroed, but - ** the page object is not dropped. - */ - static void sqlite3PcacheTruncate( PCache pCache, u32 pgno ) - { - if ( pCache.pCache != null ) - { - PgHdr p; - PgHdr pNext; - for ( p = pCache.pDirty; p != null; p = pNext ) - { - pNext = p.pDirtyNext; - /* This routine never gets call with a positive pgno except right - ** after sqlite3PcacheCleanAll(). So if there are dirty pages, - ** it must be that pgno==0. - */ - Debug.Assert( p.pgno > 0 ); - if ( ALWAYS( p.pgno > pgno ) ) - { - Debug.Assert( ( p.flags & PGHDR_DIRTY ) != 0 ); - sqlite3PcacheMakeClean( p ); - } + /* + ** Make sure the page is marked as clean. If it isn't clean already, + ** make it so. + */ + static void sqlite3PcacheMakeClean(PgHdr p) { + if ((p.flags & PGHDR_DIRTY) != 0) { + pcacheRemoveFromDirtyList(p); + p.flags &= ~(PGHDR_DIRTY | PGHDR_NEED_SYNC); + if (p.nRef == 0) { + pcacheUnpin(p); + } + } } - if ( pgno == 0 && pCache.pPage1 != null ) - { - // memset( pCache.pPage1.pData, 0, pCache.szPage ); - pCache.pPage1.pData = sqlite3Malloc( pCache.szPage ); - pgno = 1; + + /* + ** Make every page in the cache clean. + */ + static void sqlite3PcacheCleanAll(PCache pCache) { + PgHdr p; + while ((p = pCache.pDirty) != null) { + sqlite3PcacheMakeClean(p); + } } - sqlite3GlobalConfig.pcache.xTruncate( pCache.pCache, pgno + 1 ); - } - } - /* - ** Close a cache. - */ - static void sqlite3PcacheClose( PCache pCache ) - { - if ( pCache.pCache != null ) - { - sqlite3GlobalConfig.pcache.xDestroy( ref pCache.pCache ); - } - } + /* + ** Clear the PGHDR_NEED_SYNC flag from all dirty pages. + */ + static void sqlite3PcacheClearSyncFlags(PCache pCache) { + PgHdr p; + for (p = pCache.pDirty; p != null; p = p.pDirtyNext) { + p.flags &= ~PGHDR_NEED_SYNC; + } + pCache.pSynced = pCache.pDirtyTail; + } - /* - ** Discard the contents of the cache. - */ - static void sqlite3PcacheClear( PCache pCache ) - { - sqlite3PcacheTruncate( pCache, 0 ); - } + /* + ** Change the page number of page p to newPgno. + */ + static void sqlite3PcacheMove(PgHdr p, Pgno newPgno) { + PCache pCache = p.pCache; + Debug.Assert(p.nRef > 0); + Debug.Assert(newPgno > 0); + sqlite3GlobalConfig.pcache.xRekey(pCache.pCache, p, p.pgno, newPgno); + p.pgno = newPgno; + if ((p.flags & PGHDR_DIRTY) != 0 && (p.flags & PGHDR_NEED_SYNC) != 0) { + pcacheRemoveFromDirtyList(p); + pcacheAddToDirtyList(p); + } + } + /* + ** Drop every cache entry whose page number is greater than "pgno". The + ** caller must ensure that there are no outstanding references to any pages + ** other than page 1 with a page number greater than pgno. + ** + ** If there is a reference to page 1 and the pgno parameter passed to this + ** function is 0, then the data area associated with page 1 is zeroed, but + ** the page object is not dropped. + */ + static void sqlite3PcacheTruncate(PCache pCache, u32 pgno) { + if (pCache.pCache != null) { + PgHdr p; + PgHdr pNext; + for (p = pCache.pDirty; p != null; p = pNext) { + pNext = p.pDirtyNext; + /* This routine never gets call with a positive pgno except right + ** after sqlite3PcacheCleanAll(). So if there are dirty pages, + ** it must be that pgno==0. + */ + Debug.Assert(p.pgno > 0); + if (ALWAYS(p.pgno > pgno)) { + Debug.Assert((p.flags & PGHDR_DIRTY) != 0); + sqlite3PcacheMakeClean(p); + } + } + if (pgno == 0 && pCache.pPage1 != null) { + // memset( pCache.pPage1.pData, 0, pCache.szPage ); + pCache.pPage1.pData = sqlite3Malloc(pCache.szPage); + pgno = 1; + } + sqlite3GlobalConfig.pcache.xTruncate(pCache.pCache, pgno + 1); + } + } - /* - ** Merge two lists of pages connected by pDirty and in pgno order. - ** Do not both fixing the pDirtyPrev pointers. - */ - static PgHdr pcacheMergeDirtyList( PgHdr pA, PgHdr pB ) - { - PgHdr result = new PgHdr(); - PgHdr pTail = result; - while ( pA != null && pB != null ) - { - if ( pA.pgno < pB.pgno ) - { - pTail.pDirty = pA; - pTail = pA; - pA = pA.pDirty; + /* + ** Close a cache. + */ + static void sqlite3PcacheClose(PCache pCache) { + if (pCache.pCache != null) { + sqlite3GlobalConfig.pcache.xDestroy(ref pCache.pCache); + } } - else - { - pTail.pDirty = pB; - pTail = pB; - pB = pB.pDirty; + + /* + ** Discard the contents of the cache. + */ + static void sqlite3PcacheClear(PCache pCache) { + sqlite3PcacheTruncate(pCache, 0); } - } - if ( pA != null ) - { - pTail.pDirty = pA; - } - else if ( pB != null ) - { - pTail.pDirty = pB; - } - else - { - pTail.pDirty = null; - } - return result.pDirty; - } - /* - ** Sort the list of pages in accending order by pgno. Pages are - ** connected by pDirty pointers. The pDirtyPrev pointers are - ** corrupted by this sort. - ** - ** Since there cannot be more than 2^31 distinct pages in a database, - ** there cannot be more than 31 buckets required by the merge sorter. - ** One extra bucket is added to catch overflow in case something - ** ever changes to make the previous sentence incorrect. - */ - //#define N_SORT_BUCKET 32 - const int N_SORT_BUCKET = 32; - static PgHdr pcacheSortDirtyList( PgHdr pIn ) - { - PgHdr[] a; - PgHdr p;//a[N_SORT_BUCKET], p; - int i; - a = new PgHdr[N_SORT_BUCKET];//memset(a, 0, sizeof(a)); - while ( pIn != null ) - { - p = pIn; - pIn = p.pDirty; - p.pDirty = null; - for ( i = 0; ALWAYS( i < N_SORT_BUCKET - 1 ); i++ ) - { - if ( a[i] == null ) - { - a[i] = p; - break; - } - else - { - p = pcacheMergeDirtyList( a[i], p ); - a[i] = null; - } + /* + ** Merge two lists of pages connected by pDirty and in pgno order. + ** Do not both fixing the pDirtyPrev pointers. + */ + static PgHdr pcacheMergeDirtyList(PgHdr pA, PgHdr pB) { + PgHdr result = new PgHdr(); + PgHdr pTail = result; + while (pA != null && pB != null) { + if (pA.pgno < pB.pgno) { + pTail.pDirty = pA; + pTail = pA; + pA = pA.pDirty; + } else { + pTail.pDirty = pB; + pTail = pB; + pB = pB.pDirty; + } + } + if (pA != null) { + pTail.pDirty = pA; + } else if (pB != null) { + pTail.pDirty = pB; + } else { + pTail.pDirty = null; + } + return result.pDirty; } - if ( NEVER( i == N_SORT_BUCKET - 1 ) ) - { - /* To get here, there need to be 2^(N_SORT_BUCKET) elements in - ** the input list. But that is impossible. - */ - a[i] = pcacheMergeDirtyList( a[i], p ); + + /* + ** Sort the list of pages in accending order by pgno. Pages are + ** connected by pDirty pointers. The pDirtyPrev pointers are + ** corrupted by this sort. + ** + ** Since there cannot be more than 2^31 distinct pages in a database, + ** there cannot be more than 31 buckets required by the merge sorter. + ** One extra bucket is added to catch overflow in case something + ** ever changes to make the previous sentence incorrect. + */ + //#define N_SORT_BUCKET 32 + const int N_SORT_BUCKET = 32; + + static PgHdr pcacheSortDirtyList(PgHdr pIn) { + PgHdr[] a; + PgHdr p;//a[N_SORT_BUCKET], p; + int i; + a = new PgHdr[N_SORT_BUCKET];//memset(a, 0, sizeof(a)); + while (pIn != null) { + p = pIn; + pIn = p.pDirty; + p.pDirty = null; + for (i = 0; ALWAYS(i < N_SORT_BUCKET - 1); i++) { + if (a[i] == null) { + a[i] = p; + break; + } else { + p = pcacheMergeDirtyList(a[i], p); + a[i] = null; + } + } + if (NEVER(i == N_SORT_BUCKET - 1)) { + /* To get here, there need to be 2^(N_SORT_BUCKET) elements in + ** the input list. But that is impossible. + */ + a[i] = pcacheMergeDirtyList(a[i], p); + } + } + p = a[0]; + for (i = 1; i < N_SORT_BUCKET; i++) { + p = pcacheMergeDirtyList(p, a[i]); + } + return p; } - } - p = a[0]; - for ( i = 1; i < N_SORT_BUCKET; i++ ) - { - p = pcacheMergeDirtyList( p, a[i] ); - } - return p; - } - /* - ** Return a list of all dirty pages in the cache, sorted by page number. - */ - static PgHdr sqlite3PcacheDirtyList( PCache pCache ) - { - PgHdr p; - for ( p = pCache.pDirty; p != null; p = p.pDirtyNext ) - { - p.pDirty = p.pDirtyNext; - } - return pcacheSortDirtyList( pCache.pDirty ); - } + /* + ** Return a list of all dirty pages in the cache, sorted by page number. + */ + static PgHdr sqlite3PcacheDirtyList(PCache pCache) { + PgHdr p; + for (p = pCache.pDirty; p != null; p = p.pDirtyNext) { + p.pDirty = p.pDirtyNext; + } + return pcacheSortDirtyList(pCache.pDirty); + } - /* - ** Return the total number of referenced pages held by the cache. - */ - static int sqlite3PcacheRefCount( PCache pCache ) - { - return pCache.nRef; - } + /* + ** Return the total number of referenced pages held by the cache. + */ + static int sqlite3PcacheRefCount(PCache pCache) { + return pCache.nRef; + } - /* - ** Return the number of references to the page supplied as an argument. - */ - static int sqlite3PcachePageRefcount( PgHdr p ) - { - return p.nRef; - } + /* + ** Return the number of references to the page supplied as an argument. + */ + static int sqlite3PcachePageRefcount(PgHdr p) { + return p.nRef; + } - /* - ** Return the total number of pages in the cache. - */ - static int sqlite3PcachePagecount( PCache pCache ) - { - int nPage = 0; - if ( pCache.pCache != null ) - { - nPage = sqlite3GlobalConfig.pcache.xPagecount( pCache.pCache ); - } - return nPage; - } + /* + ** Return the total number of pages in the cache. + */ + static int sqlite3PcachePagecount(PCache pCache) { + int nPage = 0; + if (pCache.pCache != null) { + nPage = sqlite3GlobalConfig.pcache.xPagecount(pCache.pCache); + } + return nPage; + } #if SQLITE_TEST /* @@ -715,32 +619,28 @@ static int sqlite3PcacheGetCachesize( PCache pCache ) } #endif - /* -** Set the suggested cache-size value. -*/ - static void sqlite3PcacheSetCachesize( PCache pCache, int mxPage ) - { - pCache.nMax = mxPage; - if ( pCache.pCache != null ) - { - sqlite3GlobalConfig.pcache.xCachesize( pCache.pCache, mxPage ); - } - } + /* + ** Set the suggested cache-size value. + */ + static void sqlite3PcacheSetCachesize(PCache pCache, int mxPage) { + pCache.nMax = mxPage; + if (pCache.pCache != null) { + sqlite3GlobalConfig.pcache.xCachesize(pCache.pCache, mxPage); + } + } -#if SQLITE_CHECK_PAGES || (SQLITE_DEBUG) - /* -** For all dirty pages currently in the cache, invoke the specified -** callback. This is only used if the SQLITE_CHECK_PAGES macro is -** defined. -*/ - static void sqlite3PcacheIterateDirty( PCache pCache, dxIter xIter ) - { - PgHdr pDirty; - for ( pDirty = pCache.pDirty; pDirty != null; pDirty = pDirty.pDirtyNext ) - { - xIter( pDirty ); - } - } +#if SQLITE_CHECK_PAGES || (SQLITE_DEBUG) + /* + ** For all dirty pages currently in the cache, invoke the specified + ** callback. This is only used if the SQLITE_CHECK_PAGES macro is + ** defined. + */ + static void sqlite3PcacheIterateDirty(PCache pCache, dxIter xIter) { + PgHdr pDirty; + for (pDirty = pCache.pDirty; pDirty != null; pDirty = pDirty.pDirtyNext) { + xIter(pDirty); + } + } #endif - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/pcache_h.cs b/Src/IronPython.SQLite/c#sqlite/pcache_h.cs index e51a4004d..8f34c21f5 100644 --- a/Src/IronPython.SQLite/c#sqlite/pcache_h.cs +++ b/Src/IronPython.SQLite/c#sqlite/pcache_h.cs @@ -1,181 +1,170 @@ -using System; -using System.Diagnostics; -using System.IO; - -using i16 = System.Int16; -using u32 = System.UInt32; using Pgno = System.UInt32; -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 2008 August 05 - ** - ** 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 header file defines the interface that the sqlite page cache - ** subsystem. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2008 August 05 + ** + ** 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 header file defines the interface that the sqlite page cache + ** subsystem. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ #if !_PCACHE_H_ - //typedef struct PgHdr PgHdr; - //typedef struct PCache PCache; - - /* - ** Every page in the cache is controlled by an instance of the following - ** structure. - */ - public class PgHdr - { - public byte[] pData; /* Content of this page */ - public MemPage pExtra; /* Extra content */ - public PgHdr pDirty; /* Transient list of dirty pages */ - public Pgno pgno; /* The page number for this page */ - public Pager pPager; /* The pager to which this page belongs */ + //typedef struct PgHdr PgHdr; + //typedef struct PCache PCache; + + /* + ** Every page in the cache is controlled by an instance of the following + ** structure. + */ + public class PgHdr { + public byte[] pData; /* Content of this page */ + public MemPage pExtra; /* Extra content */ + public PgHdr pDirty; /* Transient list of dirty pages */ + public Pgno pgno; /* The page number for this page */ + public Pager pPager; /* The pager to which this page belongs */ #if SQLITE_CHECK_PAGES || (SQLITE_DEBUG) - public int pageHash; /* Hash of page content */ + public int pageHash; /* Hash of page content */ #endif - public int flags; /* PGHDR flags defined below */ - /********************************************************************** - ** Elements above are public. All that follows is private to pcache.c - ** and should not be accessed by other modules. - */ - public int nRef; /* Number of users of this page */ - public PCache pCache; /* Cache that owns this page */ - public bool CacheAllocated; /* True, if allocated from cache */ - - public PgHdr pDirtyNext; /* Next element in list of dirty pages */ - public PgHdr pDirtyPrev; /* Previous element in list of dirty pages */ - public PgHdr1 pPgHdr1; /* Cache page header this this page */ - - public static implicit operator bool( PgHdr b ) - { - return ( b != null ); - } - - - public void Clear() - { - sqlite3_free( ref this.pData ); - this.pData = null; - this.pExtra = null; - this.pDirty = null; - this.pgno = 0; - this.pPager = null; + public int flags; /* PGHDR flags defined below */ + /********************************************************************** + ** Elements above are public. All that follows is private to pcache.c + ** and should not be accessed by other modules. + */ + public int nRef; /* Number of users of this page */ + public PCache pCache; /* Cache that owns this page */ + public bool CacheAllocated; /* True, if allocated from cache */ + + public PgHdr pDirtyNext; /* Next element in list of dirty pages */ + public PgHdr pDirtyPrev; /* Previous element in list of dirty pages */ + public PgHdr1 pPgHdr1; /* Cache page header this this page */ + + public static implicit operator bool(PgHdr b) { + return (b != null); + } + + + public void Clear() { + sqlite3_free(ref this.pData); + this.pData = null; + this.pExtra = null; + this.pDirty = null; + this.pgno = 0; + this.pPager = null; #if SQLITE_CHECK_PAGES this.pageHash=0; #endif - this.flags = 0; - this.nRef = 0; - this.CacheAllocated = false; - this.pCache = null; - this.pDirtyNext = null; - this.pDirtyPrev = null; - this.pPgHdr1 = null; - } - }; - - /* Bit values for PgHdr.flags */ - //#define PGHDR_DIRTY 0x002 /* Page has changed */ - //#define PGHDR_NEED_SYNC 0x004 /* Fsync the rollback journal before - // ** writing this page to the database */ - //#define PGHDR_NEED_READ 0x008 /* Content is unread */ - //#define PGHDR_REUSE_UNLIKELY 0x010 /* A hint that reuse is unlikely */ - //#define PGHDR_DONT_WRITE 0x020 /* Do not write content to disk */ - - const int PGHDR_DIRTY = 0x002; /* Page has changed */ - const int PGHDR_NEED_SYNC = 0x004;/* Fsync the rollback journal before + this.flags = 0; + this.nRef = 0; + this.CacheAllocated = false; + this.pCache = null; + this.pDirtyNext = null; + this.pDirtyPrev = null; + this.pPgHdr1 = null; + } + }; + + /* Bit values for PgHdr.flags */ + //#define PGHDR_DIRTY 0x002 /* Page has changed */ + //#define PGHDR_NEED_SYNC 0x004 /* Fsync the rollback journal before + // ** writing this page to the database */ + //#define PGHDR_NEED_READ 0x008 /* Content is unread */ + //#define PGHDR_REUSE_UNLIKELY 0x010 /* A hint that reuse is unlikely */ + //#define PGHDR_DONT_WRITE 0x020 /* Do not write content to disk */ + + const int PGHDR_DIRTY = 0x002; /* Page has changed */ + const int PGHDR_NEED_SYNC = 0x004;/* Fsync the rollback journal before ** writing this page to the database */ - const int PGHDR_NEED_READ = 0x008;/* Content is unread */ - const int PGHDR_REUSE_UNLIKELY = 0x010;/* A hint that reuse is unlikely */ - const int PGHDR_DONT_WRITE = 0x020;/* Do not write content to disk */ + const int PGHDR_NEED_READ = 0x008;/* Content is unread */ + const int PGHDR_REUSE_UNLIKELY = 0x010;/* A hint that reuse is unlikely */ + const int PGHDR_DONT_WRITE = 0x020;/* Do not write content to disk */ - /* Initialize and shutdown the page cache subsystem */ - //int sqlite3PcacheInitialize(void); - //void sqlite3PcacheShutdown(void); + /* Initialize and shutdown the page cache subsystem */ + //int sqlite3PcacheInitialize(void); + //void sqlite3PcacheShutdown(void); - /* Page cache buffer management: - ** These routines implement SQLITE_CONFIG_PAGECACHE. - */ - //void sqlite3PCacheBufferSetup(void *, int sz, int n); + /* Page cache buffer management: + ** These routines implement SQLITE_CONFIG_PAGECACHE. + */ + //void sqlite3PCacheBufferSetup(void *, int sz, int n); - /* Create a new pager cache. - ** Under memory stress, invoke xStress to try to make pages clean. - ** Only clean and unpinned pages can be reclaimed. - */ - //void sqlite3PcacheOpen( - // int szPage, /* Size of every page */ - // int szExtra, /* Extra space associated with each page */ - // int bPurgeable, /* True if pages are on backing store */ - // int (*xStress)(void*, PgHdr*), /* Call to try to make pages clean */ - // void pStress, /* Argument to xStress */ - // PCache pToInit /* Preallocated space for the PCache */ - //); - - /* Modify the page-size after the cache has been created. */ - //void sqlite3PcacheSetPageSize(PCache *, int); - - /* Return the size in bytes of a PCache object. Used to preallocate - ** storage space. - */ - //int sqlite3PcacheSize(void); + /* Create a new pager cache. + ** Under memory stress, invoke xStress to try to make pages clean. + ** Only clean and unpinned pages can be reclaimed. + */ + //void sqlite3PcacheOpen( + // int szPage, /* Size of every page */ + // int szExtra, /* Extra space associated with each page */ + // int bPurgeable, /* True if pages are on backing store */ + // int (*xStress)(void*, PgHdr*), /* Call to try to make pages clean */ + // void pStress, /* Argument to xStress */ + // PCache pToInit /* Preallocated space for the PCache */ + //); - /* One release per successful fetch. Page is pinned until released. - ** Reference counted. - */ - //int sqlite3PcacheFetch(PCache*, Pgno, int createFlag, PgHdr**); - //void sqlite3PcacheRelease(PgHdr*); + /* Modify the page-size after the cache has been created. */ + //void sqlite3PcacheSetPageSize(PCache *, int); + + /* Return the size in bytes of a PCache object. Used to preallocate + ** storage space. + */ + //int sqlite3PcacheSize(void); - //void sqlite3PcacheDrop(PgHdr*); /* Remove page from cache */ - //void sqlite3PcacheMakeDirty(PgHdr*); /* Make sure page is marked dirty */ - //void sqlite3PcacheMakeClean(PgHdr*); /* Mark a single page as clean */ - //void sqlite3PcacheCleanAll(PCache*); /* Mark all dirty list pages as clean */ + /* One release per successful fetch. Page is pinned until released. + ** Reference counted. + */ + //int sqlite3PcacheFetch(PCache*, Pgno, int createFlag, PgHdr**); + //void sqlite3PcacheRelease(PgHdr*); - /* Change a page number. Used by incr-vacuum. */ - //void sqlite3PcacheMove(PgHdr*, Pgno); + //void sqlite3PcacheDrop(PgHdr*); /* Remove page from cache */ + //void sqlite3PcacheMakeDirty(PgHdr*); /* Make sure page is marked dirty */ + //void sqlite3PcacheMakeClean(PgHdr*); /* Mark a single page as clean */ + //void sqlite3PcacheCleanAll(PCache*); /* Mark all dirty list pages as clean */ - /* Remove all pages with pgno>x. Reset the cache if x==0 */ - //void sqlite3PcacheTruncate(PCache*, Pgno x); + /* Change a page number. Used by incr-vacuum. */ + //void sqlite3PcacheMove(PgHdr*, Pgno); - /* Get a list of all dirty pages in the cache, sorted by page number */ - //PgHdr *sqlite3PcacheDirtyList(PCache*); + /* Remove all pages with pgno>x. Reset the cache if x==0 */ + //void sqlite3PcacheTruncate(PCache*, Pgno x); - /* Reset and close the cache object */ - //void sqlite3PcacheClose(PCache*); + /* Get a list of all dirty pages in the cache, sorted by page number */ + //PgHdr *sqlite3PcacheDirtyList(PCache*); - /* Clear flags from pages of the page cache */ - //void sqlite3PcacheClearSyncFlags(PCache *); + /* Reset and close the cache object */ + //void sqlite3PcacheClose(PCache*); - /* Discard the contents of the cache */ - //void sqlite3PcacheClear(PCache*); + /* Clear flags from pages of the page cache */ + //void sqlite3PcacheClearSyncFlags(PCache *); - /* Return the total number of outstanding page references */ - //int sqlite3PcacheRefCount(PCache*); + /* Discard the contents of the cache */ + //void sqlite3PcacheClear(PCache*); - /* Increment the reference count of an existing page */ - //void sqlite3PcacheRef(PgHdr*); + /* Return the total number of outstanding page references */ + //int sqlite3PcacheRefCount(PCache*); - //int sqlite3PcachePageRefcount(PgHdr*); + /* Increment the reference count of an existing page */ + //void sqlite3PcacheRef(PgHdr*); + //int sqlite3PcachePageRefcount(PgHdr*); - /* Return the total number of pages stored in the cache */ - //int sqlite3PcachePagecount(PCache*); + + /* Return the total number of pages stored in the cache */ + //int sqlite3PcachePagecount(PCache*); #if SQLITE_CHECK_PAGES /* Iterate through all dirty pages currently stored in the cache. This @@ -186,13 +175,13 @@ public void Clear() //void sqlite3PcacheIterateDirty(PCache pCache, void (*xIter)(PgHdr *)); #endif - /* Set and get the suggested cache-size for the specified pager-cache. -** -** If no global maximum is configured, then the system attempts to limit -** the total number of pages cached by purgeable pager-caches to the sum -** of the suggested cache-sizes. -*/ - //void sqlite3PcacheSetCachesize(PCache *, int); + /* Set and get the suggested cache-size for the specified pager-cache. + ** + ** If no global maximum is configured, then the system attempts to limit + ** the total number of pages cached by purgeable pager-caches to the sum + ** of the suggested cache-sizes. + */ + //void sqlite3PcacheSetCachesize(PCache *, int); #if SQLITE_TEST //int sqlite3PcacheGetCachesize(PCache *); #endif @@ -206,8 +195,8 @@ public void Clear() //void sqlite3PcacheStats(int*,int*,int*,int*); #endif - //void sqlite3PCacheSetDefault(void); + //void sqlite3PCacheSetDefault(void); #endif //* _PCACHE_H_ */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/pragma_c.cs b/Src/IronPython.SQLite/c#sqlite/pragma_c.cs index 5c551c945..15fbe5acb 100644 --- a/Src/IronPython.SQLite/c#sqlite/pragma_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/pragma_c.cs @@ -1,232 +1,202 @@ using System; using System.Diagnostics; -using System.Text; using i64 = System.Int64; +using sqlite3_int64 = System.Int64; using u8 = System.Byte; -using Pgno = System.UInt32; -using sqlite3_int64 = System.Int64; -using System.Globalization; +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2003 April 6 + ** + ** 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 contains code used to implement the PRAGMA command. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 2003 April 6 - ** - ** 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 contains code used to implement the PRAGMA command. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + /* + ** 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. ** - ************************************************************************* + ** Note that the values returned are one less that the values that + ** should be passed into sqlite3BtreeSetSafetyLevel(). The is done + ** to support legacy SQL code. The safety level used to be boolean + ** and older scripts may have used numbers 0 for OFF and 1 for ON. */ - //#include "sqliteInt.h" - - /* -** 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. -** -** Note that the values returned are one less that the values that -** should be passed into sqlite3BtreeSetSafetyLevel(). The is done -** to support legacy SQL code. The safety level used to be boolean -** and older scripts may have used numbers 0 for OFF and 1 for ON. -*/ - static u8 getSafetyLevel( string z ) - { - // /* 123456789 123456789 */ - string zText = "onoffalseyestruefull"; - int[] iOffset = new int[] { 0, 1, 2, 4, 9, 12, 16 }; - int[] iLength = new int[] { 2, 2, 3, 5, 3, 4, 4 }; - u8[] iValue = new u8[] { 1, 0, 0, 0, 1, 1, 2 }; - int i, n; - if ( sqlite3Isdigit( z[0] ) ) - { - return (u8)sqlite3Atoi( z ); - } - n = sqlite3Strlen30( z ); - for ( i = 0; i < ArraySize( iLength ); i++ ) - { - if ( iLength[i] == n && sqlite3StrNICmp( zText.Substring( iOffset[i] ), z, n ) == 0 ) - { - return iValue[i]; + static u8 getSafetyLevel(string z) { + // /* 123456789 123456789 */ + string zText = "onoffalseyestruefull"; + int[] iOffset = new int[] { 0, 1, 2, 4, 9, 12, 16 }; + int[] iLength = new int[] { 2, 2, 3, 5, 3, 4, 4 }; + u8[] iValue = new u8[] { 1, 0, 0, 0, 1, 1, 2 }; + int i, n; + if (sqlite3Isdigit(z[0])) { + return (u8)sqlite3Atoi(z); + } + n = sqlite3Strlen30(z); + for (i = 0; i < ArraySize(iLength); i++) { + if (iLength[i] == n && sqlite3StrNICmp(zText.Substring(iOffset[i]), z, n) == 0) { + return iValue[i]; + } + } + return 1; } - } - return 1; - } - /* - ** Interpret the given string as a boolean value. - */ - static u8 sqlite3GetBoolean(string z){ - return (u8)( getSafetyLevel( z ) & 1 );//return getSafetyLevel(z)&1; -} + /* + ** Interpret the given string as a boolean value. + */ + static u8 sqlite3GetBoolean(string z) { + return (u8)(getSafetyLevel(z) & 1);//return getSafetyLevel(z)&1; + } -/* The sqlite3GetBoolean() function is used by other modules but the -** remainder of this file is specific to PRAGMA processing. So omit -** the rest of the file if PRAGMAs are omitted from the build. -*/ + /* The sqlite3GetBoolean() function is used by other modules but the + ** remainder of this file is specific to PRAGMA processing. So omit + ** the rest of the file if PRAGMAs are omitted from the build. + */ #if !(SQLITE_OMIT_PRAGMA) - /* - ** Interpret the given string as a locking mode value. - */ - static int getLockingMode( string z ) - { - if ( z != null ) - { - if ( z.Equals( "exclusive", StringComparison.OrdinalIgnoreCase ) ) - return PAGER_LOCKINGMODE_EXCLUSIVE; - if ( z.Equals( "normal", StringComparison.OrdinalIgnoreCase ) ) - return PAGER_LOCKINGMODE_NORMAL; - } - return PAGER_LOCKINGMODE_QUERY; - } + /* + ** Interpret the given string as a locking mode value. + */ + static int getLockingMode(string z) { + if (z != null) { + if (z.Equals("exclusive", StringComparison.OrdinalIgnoreCase)) + return PAGER_LOCKINGMODE_EXCLUSIVE; + if (z.Equals("normal", StringComparison.OrdinalIgnoreCase)) + return PAGER_LOCKINGMODE_NORMAL; + } + return PAGER_LOCKINGMODE_QUERY; + } #if !SQLITE_OMIT_AUTOVACUUM - /* -** Interpret the given string as an auto-vacuum mode value. -** -** The following strings, "none", "full" and "incremental" are -** acceptable, as are their numeric equivalents: 0, 1 and 2 respectively. -*/ - static u8 getAutoVacuum( string z ) - { - int i; - if ( z.Equals( "none", StringComparison.OrdinalIgnoreCase ) ) - return BTREE_AUTOVACUUM_NONE; - if ( z.Equals( "full", StringComparison.OrdinalIgnoreCase ) ) - return BTREE_AUTOVACUUM_FULL; - if ( z.Equals( "incremental", StringComparison.OrdinalIgnoreCase ) ) - return BTREE_AUTOVACUUM_INCR; - i = atoi( z ); - return (u8)( ( i >= 0 && i <= 2 ) ? i : 0 ); - } + /* + ** Interpret the given string as an auto-vacuum mode value. + ** + ** The following strings, "none", "full" and "incremental" are + ** acceptable, as are their numeric equivalents: 0, 1 and 2 respectively. + */ + static u8 getAutoVacuum(string z) { + int i; + if (z.Equals("none", StringComparison.OrdinalIgnoreCase)) + return BTREE_AUTOVACUUM_NONE; + if (z.Equals("full", StringComparison.OrdinalIgnoreCase)) + return BTREE_AUTOVACUUM_FULL; + if (z.Equals("incremental", StringComparison.OrdinalIgnoreCase)) + return BTREE_AUTOVACUUM_INCR; + i = atoi(z); + return (u8)((i >= 0 && i <= 2) ? i : 0); + } #endif // * if !SQLITE_OMIT_AUTOVACUUM */ #if !SQLITE_OMIT_PAGER_PRAGMAS - /* -** Interpret the given string as a temp db location. Return 1 for file -** backed temporary databases, 2 for the Red-Black tree in memory database -** and 0 to use the compile-time default. -*/ - static int getTempStore( string z ) - { - if ( z[0] >= '0' && z[0] <= '2' ) - { - return z[0] - '0'; - } - else if ( z.Equals( "file", StringComparison.OrdinalIgnoreCase ) ) - { - return 1; - } - else if ( z.Equals( "memory", StringComparison.OrdinalIgnoreCase ) ) - { - return 2; - } - else - { - return 0; - } - } + /* + ** Interpret the given string as a temp db location. Return 1 for file + ** backed temporary databases, 2 for the Red-Black tree in memory database + ** and 0 to use the compile-time default. + */ + static int getTempStore(string z) { + if (z[0] >= '0' && z[0] <= '2') { + return z[0] - '0'; + } else if (z.Equals("file", StringComparison.OrdinalIgnoreCase)) { + return 1; + } else if (z.Equals("memory", StringComparison.OrdinalIgnoreCase)) { + return 2; + } else { + return 0; + } + } #endif // * SQLITE_PAGER_PRAGMAS */ #if !SQLITE_OMIT_PAGER_PRAGMAS - /* -** Invalidate temp storage, either when the temp storage is changed -** from default, or when 'file' and the temp_store_directory has changed -*/ - static int invalidateTempStorage( Parse pParse ) - { - sqlite3 db = pParse.db; - if ( db.aDb[1].pBt != null ) - { - if ( 0 == db.autoCommit || sqlite3BtreeIsInReadTrans( db.aDb[1].pBt ) ) - { - sqlite3ErrorMsg( pParse, "temporary storage cannot be changed " + - "from within a transaction" ); - return SQLITE_ERROR; + /* + ** Invalidate temp storage, either when the temp storage is changed + ** from default, or when 'file' and the temp_store_directory has changed + */ + static int invalidateTempStorage(Parse pParse) { + sqlite3 db = pParse.db; + if (db.aDb[1].pBt != null) { + if (0 == db.autoCommit || sqlite3BtreeIsInReadTrans(db.aDb[1].pBt)) { + sqlite3ErrorMsg(pParse, "temporary storage cannot be changed " + + "from within a transaction"); + return SQLITE_ERROR; + } + sqlite3BtreeClose(ref db.aDb[1].pBt); + db.aDb[1].pBt = null; + sqlite3ResetInternalSchema(db, -1); + } + return SQLITE_OK; } - sqlite3BtreeClose( ref db.aDb[1].pBt ); - db.aDb[1].pBt = null; - sqlite3ResetInternalSchema( db, -1 ); - } - return SQLITE_OK; - } #endif // * SQLITE_PAGER_PRAGMAS */ #if !SQLITE_OMIT_PAGER_PRAGMAS - /* -** If the TEMP database is open, close it and mark the database schema -** as needing reloading. This must be done when using the SQLITE_TEMP_STORE -** or DEFAULT_TEMP_STORE pragmas. -*/ - static int changeTempStorage( Parse pParse, string zStorageType ) - { - int ts = getTempStore( zStorageType ); - sqlite3 db = pParse.db; - if ( db.temp_store == ts ) - return SQLITE_OK; - if ( invalidateTempStorage( pParse ) != SQLITE_OK ) - { - return SQLITE_ERROR; - } - db.temp_store = (u8)ts; - return SQLITE_OK; - } + /* + ** If the TEMP database is open, close it and mark the database schema + ** as needing reloading. This must be done when using the SQLITE_TEMP_STORE + ** or DEFAULT_TEMP_STORE pragmas. + */ + static int changeTempStorage(Parse pParse, string zStorageType) { + int ts = getTempStore(zStorageType); + sqlite3 db = pParse.db; + if (db.temp_store == ts) + return SQLITE_OK; + if (invalidateTempStorage(pParse) != SQLITE_OK) { + return SQLITE_ERROR; + } + db.temp_store = (u8)ts; + return SQLITE_OK; + } #endif // * SQLITE_PAGER_PRAGMAS */ - /* -** Generate code to return a single integer value. -*/ - static void returnSingleInt( Parse pParse, string zLabel, i64 value ) - { - Vdbe v = sqlite3GetVdbe( pParse ); - int mem = ++pParse.nMem; - //i64* pI64 = sqlite3DbMallocRaw( pParse->db, sizeof( value ) ); - //if ( pI64 ) - //{ - // memcpy( pI64, &value, sizeof( value ) ); - //} - //sqlite3VdbeAddOp4( v, OP_Int64, 0, mem, 0, (char*)pI64, P4_INT64 ); - sqlite3VdbeAddOp4( v, OP_Int64, 0, mem, 0, value, P4_INT64 ); - sqlite3VdbeSetNumCols( v, 1 ); - sqlite3VdbeSetColName( v, 0, COLNAME_NAME, zLabel, SQLITE_STATIC ); - sqlite3VdbeAddOp2( v, OP_ResultRow, mem, 1 ); - } + /* + ** Generate code to return a single integer value. + */ + static void returnSingleInt(Parse pParse, string zLabel, i64 value) { + Vdbe v = sqlite3GetVdbe(pParse); + int mem = ++pParse.nMem; + //i64* pI64 = sqlite3DbMallocRaw( pParse->db, sizeof( value ) ); + //if ( pI64 ) + //{ + // memcpy( pI64, &value, sizeof( value ) ); + //} + //sqlite3VdbeAddOp4( v, OP_Int64, 0, mem, 0, (char*)pI64, P4_INT64 ); + sqlite3VdbeAddOp4(v, OP_Int64, 0, mem, 0, value, P4_INT64); + sqlite3VdbeSetNumCols(v, 1); + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLabel, SQLITE_STATIC); + sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1); + } #if !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. -*/ - struct sPragmaType - { - public string zName; /* Name of the pragma */ - public int mask; /* Mask for the db.flags value */ - public sPragmaType( string zName, int mask ) - { - this.zName = zName; - this.mask = mask; - } - } - static int flagPragma( Parse pParse, string zLeft, string zRight ) - { - sPragmaType[] aPragma = new sPragmaType[]{ + /* + ** 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. + */ + struct sPragmaType { + public string zName; /* Name of the pragma */ + public int mask; /* Mask for the db.flags value */ + public sPragmaType(string zName, int mask) { + this.zName = zName; + this.mask = mask; + } + } + static int flagPragma(Parse pParse, string zLeft, string zRight) { + sPragmaType[] aPragma = new sPragmaType[]{ new sPragmaType( "full_column_names", SQLITE_FullColNames ), new sPragmaType( "short_column_names", SQLITE_ShortColNames ), new sPragmaType( "count_changes", SQLITE_CountRows ), @@ -261,140 +231,126 @@ static int flagPragma( Parse pParse, string zLeft, string zRight ) new sPragmaType( "foreign_keys", SQLITE_ForeignKeys ), #endif }; - int i; - sPragmaType p; - for ( i = 0; i < ArraySize( aPragma ); i++ )//, p++) - { - p = aPragma[i]; - if ( zLeft.Equals( p.zName ,StringComparison.OrdinalIgnoreCase ) ) - { - sqlite3 db = pParse.db; - Vdbe v; - v = sqlite3GetVdbe( pParse ); - Debug.Assert( v != null ); /* Already allocated by sqlite3Pragma() */ - if ( ALWAYS( v ) ) - { - if ( null == zRight ) + int i; + sPragmaType p; + for (i = 0; i < ArraySize(aPragma); i++)//, p++) { - returnSingleInt( pParse, p.zName, ( ( db.flags & p.mask ) != 0 ) ? 1 : 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; - } - - /* 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 ); - } - } + p = aPragma[i]; + if (zLeft.Equals(p.zName, StringComparison.OrdinalIgnoreCase)) { + sqlite3 db = pParse.db; + Vdbe v; + v = sqlite3GetVdbe(pParse); + Debug.Assert(v != null); /* Already allocated by sqlite3Pragma() */ + if (ALWAYS(v)) { + if (null == zRight) { + returnSingleInt(pParse, p.zName, ((db.flags & p.mask) != 0) ? 1 : 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; + } + + /* 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 1; + } + } + return 0; } - } - return 0; - } #endif // * SQLITE_OMIT_FLAG_PRAGMAS */ - /* -** Return a human-readable name for a constraint resolution action. -*/ + /* + ** Return a human-readable name for a constraint resolution action. + */ #if !SQLITE_OMIT_FOREIGN_KEY - static string actionName( int action ) - { - string zName; - switch ( action ) - { - case OE_SetNull: - zName = "SET NULL"; - break; - case OE_SetDflt: - zName = "SET DEFAULT"; - break; - case OE_Cascade: - zName = "CASCADE"; - break; - case OE_Restrict: - zName = "RESTRICT"; - break; - default: - zName = "NO ACTION"; - Debug.Assert( action == OE_None ); - break; - } - return zName; - } + static string actionName(int action) { + string zName; + switch (action) { + case OE_SetNull: + zName = "SET NULL"; + break; + case OE_SetDflt: + zName = "SET DEFAULT"; + break; + case OE_Cascade: + zName = "CASCADE"; + break; + case OE_Restrict: + zName = "RESTRICT"; + break; + default: + zName = "NO ACTION"; + Debug.Assert(action == OE_None); + break; + } + return zName; + } #endif - /* -** Parameter eMode must be one of the PAGER_JOURNALMODE_XXX constants -** defined in pager.h. This function returns the associated lowercase -** journal-mode name. -*/ - static string sqlite3JournalModename( int eMode ) - { - string[] azModeName = { + /* + ** Parameter eMode must be one of the PAGER_JOURNALMODE_XXX constants + ** defined in pager.h. This function returns the associated lowercase + ** journal-mode name. + */ + static string sqlite3JournalModename(int eMode) { + string[] azModeName = { "delete", "persist", "off", "truncate", "memory" #if !SQLITE_OMIT_WAL , "wal" #endif }; - Debug.Assert( PAGER_JOURNALMODE_DELETE == 0 ); - Debug.Assert( PAGER_JOURNALMODE_PERSIST == 1 ); - Debug.Assert( PAGER_JOURNALMODE_OFF == 2 ); - Debug.Assert( PAGER_JOURNALMODE_TRUNCATE == 3 ); - Debug.Assert( PAGER_JOURNALMODE_MEMORY == 4 ); - Debug.Assert( PAGER_JOURNALMODE_WAL == 5 ); - Debug.Assert( eMode >= 0 && eMode <= ArraySize( azModeName ) ); - - if ( eMode == ArraySize( azModeName ) ) - return null; - return azModeName[eMode]; - } + Debug.Assert(PAGER_JOURNALMODE_DELETE == 0); + Debug.Assert(PAGER_JOURNALMODE_PERSIST == 1); + Debug.Assert(PAGER_JOURNALMODE_OFF == 2); + Debug.Assert(PAGER_JOURNALMODE_TRUNCATE == 3); + Debug.Assert(PAGER_JOURNALMODE_MEMORY == 4); + Debug.Assert(PAGER_JOURNALMODE_WAL == 5); + Debug.Assert(eMode >= 0 && eMode <= ArraySize(azModeName)); + + if (eMode == ArraySize(azModeName)) + return null; + return azModeName[eMode]; + } - /* - ** Process a pragma statement. - ** - ** Pragmas are of this form: - ** - ** PRAGMA [database.]id [= value] - ** - ** The identifier might also be a string. The value is a string, and - ** identifier, or a number. If minusFlag is true, then the value is - ** a number that was preceded by a minus sign. - ** - ** If the left side is "database.id" then pId1 is the database name - ** and pId2 is the id. If the left side is just "id" then pId1 is the - ** id and pId2 is any empty string. - */ - class EncName - { - public string zName; - public u8 enc; - - public EncName( string zName, u8 enc ) - { - this.zName = zName; - this.enc = enc; - } - }; + /* + ** Process a pragma statement. + ** + ** Pragmas are of this form: + ** + ** PRAGMA [database.]id [= value] + ** + ** The identifier might also be a string. The value is a string, and + ** identifier, or a number. If minusFlag is true, then the value is + ** a number that was preceded by a minus sign. + ** + ** If the left side is "database.id" then pId1 is the database name + ** and pId2 is the id. If the left side is just "id" then pId1 is the + ** id and pId2 is any empty string. + */ + class EncName { + public string zName; + public u8 enc; - static EncName[] encnames = new EncName[] { + public EncName(string zName, u8 enc) { + this.zName = zName; + this.enc = enc; + } + }; + + static EncName[] encnames = new EncName[] { new EncName( "UTF8", SQLITE_UTF8 ), new EncName( "UTF-8", SQLITE_UTF8 ),/* Must be element [1] */ new EncName( "UTF-16le (not supported)", SQLITE_UTF16LE ),/* Must be element [2] */ @@ -405,62 +361,56 @@ public EncName( string zName, u8 enc ) new EncName( "UTF16", 0 ), /* SQLITE_UTF16NATIVE */ new EncName( null, 0 ) }; - - // OVERLOADS, so I don't need to rewrite parse.c - static void sqlite3Pragma( Parse pParse, Token pId1, Token pId2, int null_4, int minusFlag ) - { - sqlite3Pragma( pParse, pId1, pId2, null, minusFlag ); - } - static void sqlite3Pragma( - Parse pParse, - Token pId1, /* First part of [database.]id field */ - Token pId2, /* Second part of [database.]id field, or NULL */ - Token pValue, /* Token for , or NULL */ - int minusFlag /* True if a '-' sign preceded */ - ) - { - string zLeft = null; /* Nul-terminated UTF-8 string */ - string zRight = null; /* Nul-terminated UTF-8 string , or NULL */ - string zDb = null; /* The database name */ - Token pId = new Token();/* Pointer to token */ - int iDb; /* Database index for */ - sqlite3 db = pParse.db; - Db pDb; - Vdbe v = pParse.pVdbe = sqlite3VdbeCreate( db ); - if ( v == null ) - return; - sqlite3VdbeRunOnlyOnce( v ); - pParse.nMem = 2; - - /* Interpret the [database.] part of the pragma statement. iDb is the - ** index of the database this pragma is being applied to in db.aDb[]. */ - iDb = sqlite3TwoPartName( pParse, pId1, pId2, ref pId ); - if ( iDb < 0 ) - return; - pDb = db.aDb[iDb]; - - /* If the temp database has been explicitly named as part of the - ** pragma, make sure it is open. - */ - if ( iDb == 1 && sqlite3OpenTempDatabase( pParse ) != 0 ) - { - return; - } - zLeft = sqlite3NameFromToken( db, pId ); - if ( String.IsNullOrEmpty(zLeft)) - return; - if ( minusFlag != 0 ) - { - zRight = ( pValue == null ) ? "" : sqlite3MPrintf( db, "-%T", pValue ); - } - else - { - zRight = sqlite3NameFromToken( db, pValue ); - } + // OVERLOADS, so I don't need to rewrite parse.c + static void sqlite3Pragma(Parse pParse, Token pId1, Token pId2, int null_4, int minusFlag) { + sqlite3Pragma(pParse, pId1, pId2, null, minusFlag); + } + static void sqlite3Pragma( + Parse pParse, + Token pId1, /* First part of [database.]id field */ + Token pId2, /* Second part of [database.]id field, or NULL */ + Token pValue, /* Token for , or NULL */ + int minusFlag /* True if a '-' sign preceded */ + ) { + string zLeft = null; /* Nul-terminated UTF-8 string */ + string zRight = null; /* Nul-terminated UTF-8 string , or NULL */ + string zDb = null; /* The database name */ + Token pId = new Token();/* Pointer to token */ + int iDb; /* Database index for */ + sqlite3 db = pParse.db; + Db pDb; + Vdbe v = pParse.pVdbe = sqlite3VdbeCreate(db); + if (v == null) + return; + sqlite3VdbeRunOnlyOnce(v); + pParse.nMem = 2; + + /* Interpret the [database.] part of the pragma statement. iDb is the + ** index of the database this pragma is being applied to in db.aDb[]. */ + iDb = sqlite3TwoPartName(pParse, pId1, pId2, ref pId); + if (iDb < 0) + return; + pDb = db.aDb[iDb]; + + /* If the temp database has been explicitly named as part of the + ** pragma, make sure it is open. + */ + if (iDb == 1 && sqlite3OpenTempDatabase(pParse) != 0) { + return; + } - Debug.Assert( pId2 != null ); - zDb = pId2.n > 0 ? pDb.zName : null; + zLeft = sqlite3NameFromToken(db, pId); + if (String.IsNullOrEmpty(zLeft)) + return; + if (minusFlag != 0) { + zRight = (pValue == null) ? "" : sqlite3MPrintf(db, "-%T", pValue); + } else { + zRight = sqlite3NameFromToken(db, pValue); + } + + Debug.Assert(pId2 != null); + zDb = pId2.n > 0 ? pDb.zName : null; #if !SQLITE_OMIT_AUTHORIZATION if ( sqlite3AuthCheck( pParse, SQLITE_PRAGMA, zLeft, zRight, zDb ) ) { @@ -468,25 +418,24 @@ static void sqlite3Pragma( } #endif #if !SQLITE_OMIT_PAGER_PRAGMAS - /* -** PRAGMA [database.]default_cache_size -** PRAGMA [database.]default_cache_size=N -** -** The first form reports the current persistent setting for the -** page cache size. The value returned is the maximum number of -** pages in the page cache. The second form sets both the current -** page cache size value and the persistent page cache size value -** stored in the database file. -** -** Older versions of SQLite would set the default cache size to a -** 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. -*/ - if ( zLeft.Equals( "default_cache_size", StringComparison.OrdinalIgnoreCase ) ) - { - VdbeOpList[] getCacheSize = new VdbeOpList[]{ + /* + ** PRAGMA [database.]default_cache_size + ** PRAGMA [database.]default_cache_size=N + ** + ** The first form reports the current persistent setting for the + ** page cache size. The value returned is the maximum number of + ** pages in the page cache. The second form sets both the current + ** page cache size value and the persistent page cache size value + ** stored in the database file. + ** + ** Older versions of SQLite would set the default cache size to a + ** 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. + */ + if (zLeft.Equals("default_cache_size", StringComparison.OrdinalIgnoreCase)) { + VdbeOpList[] getCacheSize = new VdbeOpList[]{ new VdbeOpList( OP_Transaction, 0, 0, 0), /* 0 */ new VdbeOpList( OP_ReadCookie, 0, 1, BTREE_DEFAULT_CACHE_SIZE), /* 1 */ new VdbeOpList( OP_IfPos, 1, 7, 0), @@ -496,337 +445,283 @@ static void sqlite3Pragma( new VdbeOpList( OP_Integer, 0, 1, 0), /* 6 */ new VdbeOpList( OP_ResultRow, 1, 1, 0), }; - int addr; - if ( sqlite3ReadSchema( pParse ) != 0 ) - goto pragma_out; - sqlite3VdbeUsesBtree( v, iDb ); - if ( null == zRight ) - { - sqlite3VdbeSetNumCols( v, 1 ); - sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "cache_size", SQLITE_STATIC ); - pParse.nMem += 2; - addr = sqlite3VdbeAddOpList( v, getCacheSize.Length, getCacheSize ); - sqlite3VdbeChangeP1( v, addr, iDb ); - sqlite3VdbeChangeP1( v, addr + 1, iDb ); - sqlite3VdbeChangeP1( v, addr + 6, SQLITE_DEFAULT_CACHE_SIZE ); - } - else - { - int size = sqlite3AbsInt32(sqlite3Atoi( zRight )); - sqlite3BeginWriteOperation( pParse, 0, iDb ); - sqlite3VdbeAddOp2( v, OP_Integer, size, 1 ); - sqlite3VdbeAddOp3( v, OP_SetCookie, iDb, BTREE_DEFAULT_CACHE_SIZE, 1 ); - Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); - pDb.pSchema.cache_size = size; - sqlite3BtreeSetCacheSize( pDb.pBt, pDb.pSchema.cache_size ); - } - } - else - - /* - ** PRAGMA [database.]page_size - ** PRAGMA [database.]page_size=N - ** - ** 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. - */ - if ( zLeft.Equals( "page_size", StringComparison.OrdinalIgnoreCase ) ) - { - Btree pBt = pDb.pBt; - Debug.Assert( pBt != null ); - if ( null == zRight ) - { - int size = ALWAYS( pBt ) ? sqlite3BtreeGetPageSize( pBt ) : 0; - returnSingleInt( pParse, "page_size", size ); - } - else - { - /* Malloc may fail when setting the page-size, as there is an internal - ** buffer that the pager module resizes using sqlite3_realloc(). - */ - db.nextPagesize = sqlite3Atoi( zRight ); - if ( SQLITE_NOMEM == sqlite3BtreeSetPageSize( pBt, db.nextPagesize, -1, 0 ) ) - { - //// db.mallocFailed = 1; - } - } - } - 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. - */ - if ( zLeft.Equals( "secure_delete", StringComparison.OrdinalIgnoreCase ) ) - { - Btree pBt = pDb.pBt; - int b = -1; - Debug.Assert( pBt != null ); - if ( zRight != null ) - { - b = sqlite3GetBoolean( zRight ); - } - if ( pId2.n == 0 && b >= 0 ) - { - int ii; - for ( ii = 0; ii < db.nDb; ii++ ) - { - sqlite3BtreeSecureDelete( db.aDb[ii].pBt, b ); - } - } - b = sqlite3BtreeSecureDelete( pBt, b ); - returnSingleInt( pParse, "secure_delete", b ); - } - else - /* - ** PRAGMA [database.]max_page_count - ** PRAGMA [database.]max_page_count=N - ** - ** The first form reports the current setting for the - ** maximum number of pages in the database file. The - ** second form attempts to change this setting. Both - ** forms return the current setting. - ** - ** PRAGMA [database.]page_count - ** - ** Return the number of pages in the specified database. - */ - if ( zLeft.Equals( "page_count", StringComparison.OrdinalIgnoreCase ) - || zLeft.Equals( "max_page_count", StringComparison.OrdinalIgnoreCase ) - ) - { - int iReg; - if ( sqlite3ReadSchema( pParse ) != 0 ) - goto pragma_out; - sqlite3CodeVerifySchema( pParse, iDb ); - iReg = ++pParse.nMem; - if ( zLeft[0] == 'p' ) - { - sqlite3VdbeAddOp2( v, OP_Pagecount, iDb, iReg ); - } - else - { - sqlite3VdbeAddOp3( v, OP_MaxPgcnt, iDb, iReg, sqlite3Atoi( zRight ) ); - } - sqlite3VdbeAddOp2( v, OP_ResultRow, iReg, 1 ); - sqlite3VdbeSetNumCols( v, 1 ); - sqlite3VdbeSetColName( v, 0, COLNAME_NAME, zLeft, SQLITE_TRANSIENT ); - } - else + int addr; + if (sqlite3ReadSchema(pParse) != 0) + goto pragma_out; + sqlite3VdbeUsesBtree(v, iDb); + if (null == zRight) { + sqlite3VdbeSetNumCols(v, 1); + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "cache_size", SQLITE_STATIC); + pParse.nMem += 2; + addr = sqlite3VdbeAddOpList(v, getCacheSize.Length, getCacheSize); + sqlite3VdbeChangeP1(v, addr, iDb); + sqlite3VdbeChangeP1(v, addr + 1, iDb); + sqlite3VdbeChangeP1(v, addr + 6, SQLITE_DEFAULT_CACHE_SIZE); + } else { + int size = sqlite3AbsInt32(sqlite3Atoi(zRight)); + sqlite3BeginWriteOperation(pParse, 0, iDb); + sqlite3VdbeAddOp2(v, OP_Integer, size, 1); + sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_DEFAULT_CACHE_SIZE, 1); + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + pDb.pSchema.cache_size = size; + sqlite3BtreeSetCacheSize(pDb.pBt, pDb.pSchema.cache_size); + } + } else /* - ** PRAGMA [database.]page_count + ** PRAGMA [database.]page_size + ** PRAGMA [database.]page_size=N ** - ** Return the number of pages in the specified database. + ** 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. */ - if ( zLeft.Equals( "page_count", StringComparison.OrdinalIgnoreCase ) ) - { + if (zLeft.Equals("page_size", StringComparison.OrdinalIgnoreCase)) { + Btree pBt = pDb.pBt; + Debug.Assert(pBt != null); + if (null == zRight) { + int size = ALWAYS(pBt) ? sqlite3BtreeGetPageSize(pBt) : 0; + returnSingleInt(pParse, "page_size", size); + } else { + /* Malloc may fail when setting the page-size, as there is an internal + ** buffer that the pager module resizes using sqlite3_realloc(). + */ + db.nextPagesize = sqlite3Atoi(zRight); + if (SQLITE_NOMEM == sqlite3BtreeSetPageSize(pBt, db.nextPagesize, -1, 0)) { + //// db.mallocFailed = 1; + } + } + } 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. + */ + if (zLeft.Equals("secure_delete", StringComparison.OrdinalIgnoreCase)) { + Btree pBt = pDb.pBt; + int b = -1; + Debug.Assert(pBt != null); + if (zRight != null) { + b = sqlite3GetBoolean(zRight); + } + if (pId2.n == 0 && b >= 0) { + int ii; + for (ii = 0; ii < db.nDb; ii++) { + sqlite3BtreeSecureDelete(db.aDb[ii].pBt, b); + } + } + b = sqlite3BtreeSecureDelete(pBt, b); + returnSingleInt(pParse, "secure_delete", b); + } else + /* + ** PRAGMA [database.]max_page_count + ** PRAGMA [database.]max_page_count=N + ** + ** The first form reports the current setting for the + ** maximum number of pages in the database file. The + ** second form attempts to change this setting. Both + ** forms return the current setting. + ** + ** PRAGMA [database.]page_count + ** + ** Return the number of pages in the specified database. + */ + if (zLeft.Equals("page_count", StringComparison.OrdinalIgnoreCase) + || zLeft.Equals("max_page_count", StringComparison.OrdinalIgnoreCase) + ) { + int iReg; + if (sqlite3ReadSchema(pParse) != 0) + goto pragma_out; + sqlite3CodeVerifySchema(pParse, iDb); + iReg = ++pParse.nMem; + if (zLeft[0] == 'p') { + sqlite3VdbeAddOp2(v, OP_Pagecount, iDb, iReg); + } else { + sqlite3VdbeAddOp3(v, OP_MaxPgcnt, iDb, iReg, sqlite3Atoi(zRight)); + } + sqlite3VdbeAddOp2(v, OP_ResultRow, iReg, 1); + sqlite3VdbeSetNumCols(v, 1); + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLeft, SQLITE_TRANSIENT); + } else + + /* + ** PRAGMA [database.]page_count + ** + ** Return the number of pages in the specified database. + */ + if (zLeft.Equals("page_count", StringComparison.OrdinalIgnoreCase)) { Vdbe _v; int iReg; - _v = sqlite3GetVdbe( pParse ); - if ( _v == null || sqlite3ReadSchema( pParse ) != 0 ) - goto pragma_out; - sqlite3CodeVerifySchema( pParse, iDb ); + _v = sqlite3GetVdbe(pParse); + if (_v == null || sqlite3ReadSchema(pParse) != 0) + goto pragma_out; + sqlite3CodeVerifySchema(pParse, iDb); iReg = ++pParse.nMem; - sqlite3VdbeAddOp2( _v, OP_Pagecount, iDb, iReg ); - sqlite3VdbeAddOp2( _v, OP_ResultRow, iReg, 1 ); - sqlite3VdbeSetNumCols( _v, 1 ); - sqlite3VdbeSetColName( _v, 0, COLNAME_NAME, "page_count", SQLITE_STATIC ); - } - else + sqlite3VdbeAddOp2(_v, OP_Pagecount, iDb, iReg); + sqlite3VdbeAddOp2(_v, OP_ResultRow, iReg, 1); + sqlite3VdbeSetNumCols(_v, 1); + sqlite3VdbeSetColName(_v, 0, COLNAME_NAME, "page_count", SQLITE_STATIC); + } else - /* - ** PRAGMA [database.]locking_mode - ** PRAGMA [database.]locking_mode = (normal|exclusive) - */ - if ( zLeft.Equals( "locking_mode", StringComparison.OrdinalIgnoreCase ) ) - { - string zRet = "normal"; - int eMode = getLockingMode( zRight ); + /* + ** PRAGMA [database.]locking_mode + ** PRAGMA [database.]locking_mode = (normal|exclusive) + */ + if (zLeft.Equals("locking_mode", StringComparison.OrdinalIgnoreCase)) { + string zRet = "normal"; + int eMode = getLockingMode(zRight); - if ( pId2.n == 0 && eMode == PAGER_LOCKINGMODE_QUERY ) - { + if (pId2.n == 0 && eMode == PAGER_LOCKINGMODE_QUERY) { /* Simple "PRAGMA locking_mode;" statement. This is a query for ** the current default locking mode (which may be different to ** the locking-mode of the main database). */ eMode = db.dfltLockMode; - } - else - { + } else { Pager pPager; - if ( pId2.n == 0 ) - { - /* This indicates that no database name was specified as part - ** of the PRAGMA command. In this case the locking-mode must be - ** set on all attached databases, as well as the main db file. - ** - ** Also, the sqlite3.dfltLockMode variable is set so that - ** any subsequently attached databases also use the specified - ** locking mode. - */ - int ii; - Debug.Assert( pDb == db.aDb[0] ); - for ( ii = 2; ii < db.nDb; ii++ ) - { - pPager = sqlite3BtreePager( db.aDb[ii].pBt ); - sqlite3PagerLockingMode( pPager, eMode ); - } - db.dfltLockMode = (u8)eMode; + if (pId2.n == 0) { + /* This indicates that no database name was specified as part + ** of the PRAGMA command. In this case the locking-mode must be + ** set on all attached databases, as well as the main db file. + ** + ** Also, the sqlite3.dfltLockMode variable is set so that + ** any subsequently attached databases also use the specified + ** locking mode. + */ + int ii; + Debug.Assert(pDb == db.aDb[0]); + for (ii = 2; ii < db.nDb; ii++) { + pPager = sqlite3BtreePager(db.aDb[ii].pBt); + sqlite3PagerLockingMode(pPager, eMode); + } + db.dfltLockMode = (u8)eMode; } - pPager = sqlite3BtreePager( pDb.pBt ); - eMode = sqlite3PagerLockingMode( pPager, eMode ) ? 1 : 0; - } + pPager = sqlite3BtreePager(pDb.pBt); + eMode = sqlite3PagerLockingMode(pPager, eMode) ? 1 : 0; + } - Debug.Assert( eMode == PAGER_LOCKINGMODE_NORMAL || eMode == PAGER_LOCKINGMODE_EXCLUSIVE ); - if ( eMode == PAGER_LOCKINGMODE_EXCLUSIVE ) - { + Debug.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 ); } - else - /* - ** PRAGMA [database.]journal_mode - ** PRAGMA [database.]journal_mode = - ** (delete|persist|off|truncate|memory|wal|off) - */ - if ( zLeft.Equals("journal_mode", StringComparison.OrdinalIgnoreCase ) ) - { - int eMode; /* One of the PAGER_JOURNALMODE_XXX symbols */ - int ii; /* Loop counter */ - - /* Force the schema to be loaded on all databases. This cases all - ** database files to be opened and the journal_modes set. */ - if ( sqlite3ReadSchema( pParse ) != 0 ) - { - goto pragma_out; - } + 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); + } else + /* + ** PRAGMA [database.]journal_mode + ** PRAGMA [database.]journal_mode = + ** (delete|persist|off|truncate|memory|wal|off) + */ + if (zLeft.Equals("journal_mode", StringComparison.OrdinalIgnoreCase)) { + int eMode; /* One of the PAGER_JOURNALMODE_XXX symbols */ + int ii; /* Loop counter */ + + /* Force the schema to be loaded on all databases. This cases all + ** database files to be opened and the journal_modes set. */ + if (sqlite3ReadSchema(pParse) != 0) { + goto pragma_out; + } - sqlite3VdbeSetNumCols( v, 1 ); - sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "journal_mode", SQLITE_STATIC ); - if ( null == zRight ) - { - /* If there is no "=MODE" part of the pragma, do a query for the - ** current mode */ - eMode = PAGER_JOURNALMODE_QUERY; + sqlite3VdbeSetNumCols(v, 1); + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "journal_mode", SQLITE_STATIC); + if (null == zRight) { + /* If there is no "=MODE" part of the pragma, do a query for the + ** current mode */ + eMode = PAGER_JOURNALMODE_QUERY; + } else { + string zMode; + int n = sqlite3Strlen30(zRight); + for (eMode = 0; (zMode = sqlite3JournalModename(eMode)) != null; eMode++) { + if (sqlite3StrNICmp(zRight, zMode, n) == 0) + break; } - else - { - string zMode; - int n = sqlite3Strlen30( zRight ); - for ( eMode = 0; ( zMode = sqlite3JournalModename( eMode ) ) != null; eMode++ ) - { - if ( sqlite3StrNICmp( zRight, zMode, n ) == 0 ) - break; - } - if ( null == zMode ) - { + if (null == zMode) { /* If the "=MODE" part does not match any known journal mode, ** then do a query */ eMode = PAGER_JOURNALMODE_QUERY; - } } - if ( eMode == PAGER_JOURNALMODE_QUERY && pId2.n == 0 ) - { - /* Convert "PRAGMA journal_mode" into "PRAGMA main.journal_mode" */ - iDb = 0; - pId2.n = 1; - } - for ( ii = db.nDb - 1; ii >= 0; ii-- ) - { - if ( db.aDb[ii].pBt != null && ( ii == iDb || pId2.n == 0 ) ) - { - sqlite3VdbeUsesBtree( v, ii ); - sqlite3VdbeAddOp3( v, OP_JournalMode, ii, 1, eMode ); - } + } + if (eMode == PAGER_JOURNALMODE_QUERY && pId2.n == 0) { + /* Convert "PRAGMA journal_mode" into "PRAGMA main.journal_mode" */ + iDb = 0; + pId2.n = 1; + } + for (ii = db.nDb - 1; ii >= 0; ii--) { + if (db.aDb[ii].pBt != null && (ii == iDb || pId2.n == 0)) { + sqlite3VdbeUsesBtree(v, ii); + sqlite3VdbeAddOp3(v, OP_JournalMode, ii, 1, eMode); } - sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 1 ); - } - else + } + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); + } else - /* - ** PRAGMA [database.]journal_size_limit - ** PRAGMA [database.]journal_size_limit=N - ** - ** Get or set the size limit on rollback journal files. - */ - if ( zLeft.Equals( "journal_size_limit", StringComparison.OrdinalIgnoreCase ) ) - { - Pager pPager = sqlite3BtreePager( pDb.pBt ); - i64 iLimit = -2; - if ( !String.IsNullOrEmpty( zRight ) ) - { - sqlite3Atoi64( zRight, ref iLimit, 1000000, SQLITE_UTF8 ); - if ( iLimit < -1 ) - iLimit = -1; - } - iLimit = sqlite3PagerJournalSizeLimit( pPager, iLimit ); - returnSingleInt( pParse, "journal_size_limit", iLimit ); - } - else + /* + ** PRAGMA [database.]journal_size_limit + ** PRAGMA [database.]journal_size_limit=N + ** + ** Get or set the size limit on rollback journal files. + */ + if (zLeft.Equals("journal_size_limit", StringComparison.OrdinalIgnoreCase)) { + Pager pPager = sqlite3BtreePager(pDb.pBt); + i64 iLimit = -2; + if (!String.IsNullOrEmpty(zRight)) { + sqlite3Atoi64(zRight, ref iLimit, 1000000, SQLITE_UTF8); + if (iLimit < -1) + iLimit = -1; + } + iLimit = sqlite3PagerJournalSizeLimit(pPager, iLimit); + returnSingleInt(pParse, "journal_size_limit", iLimit); + } else #endif // * SQLITE_OMIT_PAGER_PRAGMAS */ - /* -** PRAGMA [database.]auto_vacuum -** PRAGMA [database.]auto_vacuum=N -** -** Get or set the value of the database 'auto-vacuum' parameter. -** The value is one of: 0 NONE 1 FULL 2 INCREMENTAL -*/ + /* + ** PRAGMA [database.]auto_vacuum + ** PRAGMA [database.]auto_vacuum=N + ** + ** Get or set the value of the database 'auto-vacuum' parameter. + ** The value is one of: 0 NONE 1 FULL 2 INCREMENTAL + */ #if !SQLITE_OMIT_AUTOVACUUM - if ( zLeft.Equals( "auto_vacuum", StringComparison.OrdinalIgnoreCase ) ) - { - Btree pBt = pDb.pBt; - Debug.Assert( pBt != null ); - if ( sqlite3ReadSchema( pParse ) != 0 ) - { - goto pragma_out; - } - if ( null == zRight ) - { - 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 ); - Debug.Assert( eAuto >= 0 && eAuto <= 2 ); - db.nextAutovac = (u8)eAuto; - 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. + if (zLeft.Equals("auto_vacuum", StringComparison.OrdinalIgnoreCase)) { + Btree pBt = pDb.pBt; + Debug.Assert(pBt != null); + if (sqlite3ReadSchema(pParse) != 0) { + goto pragma_out; + } + if (null == zRight) { + 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); + Debug.Assert(eAuto >= 0 && eAuto <= 2); + db.nextAutovac = (u8)eAuto; + 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. + */ + int 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. */ - int 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. - */ - VdbeOpList[] setMeta6 = new VdbeOpList[] { + VdbeOpList[] setMeta6 = new VdbeOpList[] { new VdbeOpList( OP_Transaction, 0, 1, 0), /* 0 */ new VdbeOpList( OP_ReadCookie, 0, 1, BTREE_LARGEST_ROOT_PAGE), /* 1 */ new VdbeOpList( OP_If, 1, 0, 0), /* 2 */ @@ -834,170 +729,143 @@ static void sqlite3Pragma( new VdbeOpList( OP_Integer, 0, 1, 0), /* 4 */ new VdbeOpList( 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 ); - } - } + 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 + } + } + } else #endif - /* -** PRAGMA [database.]incremental_vacuum(N) -** -** Do N steps of incremental vacuuming on a database. -*/ + /* + ** PRAGMA [database.]incremental_vacuum(N) + ** + ** Do N steps of incremental vacuuming on a database. + */ #if !SQLITE_OMIT_AUTOVACUUM - if ( zLeft.Equals( "incremental_vacuum", StringComparison.OrdinalIgnoreCase ) ) - { - int iLimit = 0, addr; - if ( sqlite3ReadSchema( pParse ) != 0 ) - { - goto pragma_out; - } - if ( zRight == null || !sqlite3GetInt32( zRight, ref iLimit ) || iLimit <= 0 ) - { - iLimit = 0x7fffffff; - } - sqlite3BeginWriteOperation( pParse, 0, iDb ); - sqlite3VdbeAddOp2( v, OP_Integer, iLimit, 1 ); - 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 ); - } - else + if (zLeft.Equals("incremental_vacuum", StringComparison.OrdinalIgnoreCase)) { + int iLimit = 0, addr; + if (sqlite3ReadSchema(pParse) != 0) { + goto pragma_out; + } + if (zRight == null || !sqlite3GetInt32(zRight, ref iLimit) || iLimit <= 0) { + iLimit = 0x7fffffff; + } + sqlite3BeginWriteOperation(pParse, 0, iDb); + sqlite3VdbeAddOp2(v, OP_Integer, iLimit, 1); + 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); + } else #endif #if !SQLITE_OMIT_PAGER_PRAGMAS - /* -** PRAGMA [database.]cache_size -** PRAGMA [database.]cache_size=N -** -** The first form reports the current local setting for the -** page cache size. The local setting can be different from -** the persistent cache size value that is stored in the database -** file itself. The value returned is the maximum number of -** pages in the page cache. The second form sets the local -** page cache size value. It does not change the persistent -** cache size stored on the disk so the cache size will revert -** to its default value when the database is closed and reopened. -** N should be a positive integer. -*/ - if ( zLeft.Equals( "cache_size", StringComparison.OrdinalIgnoreCase ) ) - { - if ( sqlite3ReadSchema( pParse ) != 0 ) - goto pragma_out; - Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); - if ( null == zRight ) - { - returnSingleInt( pParse, "cache_size", pDb.pSchema.cache_size ); - } - else - { - int size = sqlite3AbsInt32(sqlite3Atoi( zRight )); - pDb.pSchema.cache_size = size; - sqlite3BtreeSetCacheSize( pDb.pBt, pDb.pSchema.cache_size ); - } - } - else - - /* - ** PRAGMA temp_store - ** PRAGMA temp_store = "default"|"memory"|"file" - ** - ** Return or set the local value of the temp_store 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. - ** - ** Note that it is possible for the library compile-time options to - ** override this setting - */ - if ( zLeft.Equals( "temp_store", StringComparison.OrdinalIgnoreCase ) ) - { - if ( zRight == null ) - { - returnSingleInt( pParse, "temp_store", db.temp_store ); - } - else - { - changeTempStorage( pParse, zRight ); - } - } - else + /* + ** PRAGMA [database.]cache_size + ** PRAGMA [database.]cache_size=N + ** + ** The first form reports the current local setting for the + ** page cache size. The local setting can be different from + ** the persistent cache size value that is stored in the database + ** file itself. The value returned is the maximum number of + ** pages in the page cache. The second form sets the local + ** page cache size value. It does not change the persistent + ** cache size stored on the disk so the cache size will revert + ** to its default value when the database is closed and reopened. + ** N should be a positive integer. + */ + if (zLeft.Equals("cache_size", StringComparison.OrdinalIgnoreCase)) { + if (sqlite3ReadSchema(pParse) != 0) + goto pragma_out; + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + if (null == zRight) { + returnSingleInt(pParse, "cache_size", pDb.pSchema.cache_size); + } else { + int size = sqlite3AbsInt32(sqlite3Atoi(zRight)); + pDb.pSchema.cache_size = size; + sqlite3BtreeSetCacheSize(pDb.pBt, pDb.pSchema.cache_size); + } + } else + + /* + ** PRAGMA temp_store + ** PRAGMA temp_store = "default"|"memory"|"file" + ** + ** Return or set the local value of the temp_store 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. + ** + ** Note that it is possible for the library compile-time options to + ** override this setting + */ + if (zLeft.Equals("temp_store", StringComparison.OrdinalIgnoreCase)) { + if (zRight == null) { + returnSingleInt(pParse, "temp_store", db.temp_store); + } else { + changeTempStorage(pParse, zRight); + } + } else - /* - ** PRAGMA temp_store_directory - ** PRAGMA temp_store_directory = ""|"directory_name" - ** - ** Return or set the local value of the temp_store_directory flag. Changing - ** 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. - ** - */ - if ( zLeft.Equals( "temp_store_directory", StringComparison.OrdinalIgnoreCase ) ) - { - if ( null == zRight ) - { - if ( sqlite3_temp_directory != "" ) - { - sqlite3VdbeSetNumCols( v, 1 ); - sqlite3VdbeSetColName( v, 0, COLNAME_NAME, - "temp_store_directory", SQLITE_STATIC ); - sqlite3VdbeAddOp4( v, OP_String8, 0, 1, 0, sqlite3_temp_directory, 0 ); - sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 1 ); - } - } - else - { + /* + ** PRAGMA temp_store_directory + ** PRAGMA temp_store_directory = ""|"directory_name" + ** + ** Return or set the local value of the temp_store_directory flag. Changing + ** 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. + ** + */ + if (zLeft.Equals("temp_store_directory", StringComparison.OrdinalIgnoreCase)) { + if (null == zRight) { + if (sqlite3_temp_directory != "") { + sqlite3VdbeSetNumCols(v, 1); + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, + "temp_store_directory", SQLITE_STATIC); + sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, sqlite3_temp_directory, 0); + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); + } + } else { #if !SQLITE_OMIT_WSD - if ( zRight.Length > 0 ) - { - int rc; - int res = 0; - rc = sqlite3OsAccess( db.pVfs, zRight, SQLITE_ACCESS_READWRITE, ref res ); - if ( rc != SQLITE_OK || res == 0 ) - { - sqlite3ErrorMsg( pParse, "not a writable directory" ); - goto pragma_out; - } - } - if ( SQLITE_TEMP_STORE == 0 - || ( SQLITE_TEMP_STORE == 1 && db.temp_store <= 1 ) - || ( SQLITE_TEMP_STORE == 2 && db.temp_store == 1 ) - ) - { - invalidateTempStorage( pParse ); - } - //sqlite3_free( ref sqlite3_temp_directory ); - if ( zRight.Length > 0 ) - { - sqlite3_temp_directory = zRight;//sqlite3_mprintf("%s", zRight); - } - else - { - sqlite3_temp_directory = ""; - } + if (zRight.Length > 0) { + int rc; + int res = 0; + rc = sqlite3OsAccess(db.pVfs, zRight, SQLITE_ACCESS_READWRITE, ref res); + if (rc != SQLITE_OK || res == 0) { + sqlite3ErrorMsg(pParse, "not a writable directory"); + goto pragma_out; + } + } + if (SQLITE_TEMP_STORE == 0 + || (SQLITE_TEMP_STORE == 1 && db.temp_store <= 1) + || (SQLITE_TEMP_STORE == 2 && db.temp_store == 1) + ) { + invalidateTempStorage(pParse); + } + //sqlite3_free( ref sqlite3_temp_directory ); + if (zRight.Length > 0) { + sqlite3_temp_directory = zRight;//sqlite3_mprintf("%s", zRight); + } else { + sqlite3_temp_directory = ""; + } #endif //* SQLITE_OMIT_WSD */ - } - } - else + } + } else #if !(SQLITE_ENABLE_LOCKING_STYLE) -# if (__APPLE__) +#if (__APPLE__) //# define SQLITE_ENABLE_LOCKING_STYLE 1 -# else - //# define SQLITE_ENABLE_LOCKING_STYLE 0 -# endif +#else + //# define SQLITE_ENABLE_LOCKING_STYLE 0 +#endif #endif #if SQLITE_ENABLE_LOCKING_STYLE /* @@ -1054,421 +922,366 @@ static void sqlite3Pragma( else #endif //* SQLITE_ENABLE_LOCKING_STYLE */ - /* -** PRAGMA [database.]synchronous -** PRAGMA [database.]synchronous=OFF|ON|NORMAL|FULL -** -** 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. -*/ - if ( zLeft.Equals( "synchronous", StringComparison.OrdinalIgnoreCase ) ) - { - if ( sqlite3ReadSchema( pParse ) != 0 ) - goto pragma_out; - if ( null == zRight ) - { - returnSingleInt( pParse, "synchronous", pDb.safety_level - 1 ); - } - else - { - if ( 0 == db.autoCommit ) - { - sqlite3ErrorMsg( pParse, - "Safety level may not be changed inside a transaction" ); - } - else - { - pDb.safety_level = (byte)( getSafetyLevel( zRight ) + 1 ); - } - } - } - else + /* + ** PRAGMA [database.]synchronous + ** PRAGMA [database.]synchronous=OFF|ON|NORMAL|FULL + ** + ** 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. + */ + if (zLeft.Equals("synchronous", StringComparison.OrdinalIgnoreCase)) { + if (sqlite3ReadSchema(pParse) != 0) + goto pragma_out; + if (null == zRight) { + returnSingleInt(pParse, "synchronous", pDb.safety_level - 1); + } else { + if (0 == db.autoCommit) { + sqlite3ErrorMsg(pParse, + "Safety level may not be changed inside a transaction"); + } else { + pDb.safety_level = (byte)(getSafetyLevel(zRight) + 1); + } + } + } else #endif // * SQLITE_OMIT_PAGER_PRAGMAS */ #if !SQLITE_OMIT_FLAG_PRAGMAS - if ( flagPragma( pParse, zLeft, zRight ) != 0 ) - { - /* The flagPragma() subroutine also generates any necessary code - ** there is nothing more to do here */ - } - else + if (flagPragma(pParse, zLeft, zRight) != 0) { + /* The flagPragma() subroutine also generates any necessary code + ** there is nothing more to do here */ + } else #endif // * SQLITE_OMIT_FLAG_PRAGMAS */ #if !SQLITE_OMIT_SCHEMA_PRAGMAS - /* -** PRAGMA table_info(
) -** -** Return a single row for each column of the named table. The columns of -** the returned data set are: -** -** cid: Column id (numbered from left to right, starting at 0) -** 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. -*/ - if ( zLeft.Equals( "table_info", StringComparison.OrdinalIgnoreCase ) && zRight != null ) - { - Table pTab; - if ( sqlite3ReadSchema( pParse ) != 0 ) - goto pragma_out; - pTab = sqlite3FindTable( db, zRight, zDb ); - if ( pTab != null ) - { - int i; - int nHidden = 0; - Column pCol; - sqlite3VdbeSetNumCols( v, 6 ); - pParse.nMem = 6; - sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "cid", SQLITE_STATIC ); - sqlite3VdbeSetColName( v, 1, COLNAME_NAME, "name", SQLITE_STATIC ); - sqlite3VdbeSetColName( v, 2, COLNAME_NAME, "type", SQLITE_STATIC ); - sqlite3VdbeSetColName( v, 3, COLNAME_NAME, "notnull", SQLITE_STATIC ); - sqlite3VdbeSetColName( v, 4, COLNAME_NAME, "dflt_value", SQLITE_STATIC ); - sqlite3VdbeSetColName( v, 5, COLNAME_NAME, "pk", SQLITE_STATIC ); - sqlite3ViewGetColumnNames( pParse, pTab ); - for ( i = 0; i < pTab.nCol; i++ )//, pCol++) - { - pCol = pTab.aCol[i]; - if ( IsHiddenColumn( pCol ) ) - { - nHidden++; - continue; - } - sqlite3VdbeAddOp2( v, OP_Integer, i - nHidden, 1 ); - sqlite3VdbeAddOp4( v, OP_String8, 0, 2, 0, pCol.zName, 0 ); - sqlite3VdbeAddOp4( v, OP_String8, 0, 3, 0, - pCol.zType != null ? pCol.zType : "", 0 ); - sqlite3VdbeAddOp2( v, OP_Integer, ( pCol.notNull != 0 ? 1 : 0 ), 4 ); - if ( pCol.zDflt != null ) - { - sqlite3VdbeAddOp4( v, OP_String8, 0, 5, 0, pCol.zDflt, 0 ); - } - else - { - sqlite3VdbeAddOp2( v, OP_Null, 0, 5 ); - } - sqlite3VdbeAddOp2( v, OP_Integer, pCol.isPrimKey != 0 ? 1 : 0, 6 ); - sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 6 ); - } - } - } - else - - if ( zLeft.Equals( "index_info", StringComparison.OrdinalIgnoreCase ) && zRight != null ) - { - Index pIdx; - Table pTab; - if ( sqlite3ReadSchema( pParse ) != 0 ) - goto pragma_out; - pIdx = sqlite3FindIndex( db, zRight, zDb ); - if ( pIdx != null ) - { - int i; - pTab = pIdx.pTable; - sqlite3VdbeSetNumCols( v, 3 ); - pParse.nMem = 3; - sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "seqno", SQLITE_STATIC ); - sqlite3VdbeSetColName( v, 1, COLNAME_NAME, "cid", SQLITE_STATIC ); - sqlite3VdbeSetColName( v, 2, COLNAME_NAME, "name", SQLITE_STATIC ); - for ( i = 0; i < pIdx.nColumn; i++ ) - { - int cnum = pIdx.aiColumn[i]; - sqlite3VdbeAddOp2( v, OP_Integer, i, 1 ); - sqlite3VdbeAddOp2( v, OP_Integer, cnum, 2 ); - Debug.Assert( pTab.nCol > cnum ); - sqlite3VdbeAddOp4( v, OP_String8, 0, 3, 0, pTab.aCol[cnum].zName, 0 ); - sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 3 ); - } - } - } - else - - if ( zLeft.Equals( "index_list", StringComparison.OrdinalIgnoreCase ) && zRight != null ) - { - Index pIdx; - Table pTab; - if ( sqlite3ReadSchema( pParse ) != 0 ) - goto pragma_out; - pTab = sqlite3FindTable( db, zRight, zDb ); - if ( pTab != null ) - { - v = sqlite3GetVdbe( pParse ); - pIdx = pTab.pIndex; - if ( pIdx != null ) - { - int i = 0; - 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, "unique", SQLITE_STATIC ); - while ( pIdx != null ) - { - sqlite3VdbeAddOp2( v, OP_Integer, i, 1 ); - sqlite3VdbeAddOp4( v, OP_String8, 0, 2, 0, pIdx.zName, 0 ); - sqlite3VdbeAddOp2( v, OP_Integer, ( pIdx.onError != OE_None ) ? 1 : 0, 3 ); - sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 3 ); - ++i; - pIdx = pIdx.pNext; - } - } - } - } - else - - if ( zLeft.Equals( "database_list", StringComparison.OrdinalIgnoreCase ) ) - { - int i; - if ( sqlite3ReadSchema( pParse ) != 0 ) - 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 ); - for ( i = 0; i < db.nDb; i++ ) - { - if ( db.aDb[i].pBt == null ) - continue; - Debug.Assert( db.aDb[i].zName != null ); - sqlite3VdbeAddOp2( v, OP_Integer, i, 1 ); - 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 ); - } - } - else - - if ( zLeft.Equals( "collation_list", StringComparison.OrdinalIgnoreCase ) ) - { - int i = 0; - HashElem p; - sqlite3VdbeSetNumCols( v, 2 ); - pParse.nMem = 2; - sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "seq", SQLITE_STATIC ); - sqlite3VdbeSetColName( v, 1, COLNAME_NAME, "name", SQLITE_STATIC ); - for ( p = db.aCollSeq.first; p != null; p = p.next )//( p = sqliteHashFirst( db.aCollSeq ) ; p; p = sqliteHashNext( p ) ) - { - CollSeq pColl = ( (CollSeq[])p.data )[0];// sqliteHashData( p ); - sqlite3VdbeAddOp2( v, OP_Integer, i++, 1 ); - sqlite3VdbeAddOp4( v, OP_String8, 0, 2, 0, pColl.zName, 0 ); - sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 2 ); - } - } - else + /* + ** PRAGMA table_info(
) + ** + ** Return a single row for each column of the named table. The columns of + ** the returned data set are: + ** + ** cid: Column id (numbered from left to right, starting at 0) + ** 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. + */ + if (zLeft.Equals("table_info", StringComparison.OrdinalIgnoreCase) && zRight != null) { + Table pTab; + if (sqlite3ReadSchema(pParse) != 0) + goto pragma_out; + pTab = sqlite3FindTable(db, zRight, zDb); + if (pTab != null) { + int i; + int nHidden = 0; + Column pCol; + sqlite3VdbeSetNumCols(v, 6); + pParse.nMem = 6; + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "cid", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "type", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "notnull", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "dflt_value", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "pk", SQLITE_STATIC); + sqlite3ViewGetColumnNames(pParse, pTab); + for (i = 0; i < pTab.nCol; i++)//, pCol++) + { + pCol = pTab.aCol[i]; + if (IsHiddenColumn(pCol)) { + nHidden++; + continue; + } + sqlite3VdbeAddOp2(v, OP_Integer, i - nHidden, 1); + sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pCol.zName, 0); + sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, + pCol.zType != null ? pCol.zType : "", 0); + sqlite3VdbeAddOp2(v, OP_Integer, (pCol.notNull != 0 ? 1 : 0), 4); + if (pCol.zDflt != null) { + sqlite3VdbeAddOp4(v, OP_String8, 0, 5, 0, pCol.zDflt, 0); + } else { + sqlite3VdbeAddOp2(v, OP_Null, 0, 5); + } + sqlite3VdbeAddOp2(v, OP_Integer, pCol.isPrimKey != 0 ? 1 : 0, 6); + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6); + } + } + } else + + if (zLeft.Equals("index_info", StringComparison.OrdinalIgnoreCase) && zRight != null) { + Index pIdx; + Table pTab; + if (sqlite3ReadSchema(pParse) != 0) + goto pragma_out; + pIdx = sqlite3FindIndex(db, zRight, zDb); + if (pIdx != null) { + int i; + pTab = pIdx.pTable; + sqlite3VdbeSetNumCols(v, 3); + pParse.nMem = 3; + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seqno", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "cid", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "name", SQLITE_STATIC); + for (i = 0; i < pIdx.nColumn; i++) { + int cnum = pIdx.aiColumn[i]; + sqlite3VdbeAddOp2(v, OP_Integer, i, 1); + sqlite3VdbeAddOp2(v, OP_Integer, cnum, 2); + Debug.Assert(pTab.nCol > cnum); + sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pTab.aCol[cnum].zName, 0); + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3); + } + } + } else + + if (zLeft.Equals("index_list", StringComparison.OrdinalIgnoreCase) && zRight != null) { + Index pIdx; + Table pTab; + if (sqlite3ReadSchema(pParse) != 0) + goto pragma_out; + pTab = sqlite3FindTable(db, zRight, zDb); + if (pTab != null) { + v = sqlite3GetVdbe(pParse); + pIdx = pTab.pIndex; + if (pIdx != null) { + int i = 0; + 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, "unique", SQLITE_STATIC); + while (pIdx != null) { + sqlite3VdbeAddOp2(v, OP_Integer, i, 1); + sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx.zName, 0); + sqlite3VdbeAddOp2(v, OP_Integer, (pIdx.onError != OE_None) ? 1 : 0, 3); + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3); + ++i; + pIdx = pIdx.pNext; + } + } + } + } else + + if (zLeft.Equals("database_list", StringComparison.OrdinalIgnoreCase)) { + int i; + if (sqlite3ReadSchema(pParse) != 0) + 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); + for (i = 0; i < db.nDb; i++) { + if (db.aDb[i].pBt == null) + continue; + Debug.Assert(db.aDb[i].zName != null); + sqlite3VdbeAddOp2(v, OP_Integer, i, 1); + 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); + } + } else + + if (zLeft.Equals("collation_list", StringComparison.OrdinalIgnoreCase)) { + int i = 0; + HashElem p; + sqlite3VdbeSetNumCols(v, 2); + pParse.nMem = 2; + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC); + for (p = db.aCollSeq.first; p != null; p = p.next)//( p = sqliteHashFirst( db.aCollSeq ) ; p; p = sqliteHashNext( p ) ) + { + CollSeq pColl = ((CollSeq[])p.data)[0];// sqliteHashData( p ); + sqlite3VdbeAddOp2(v, OP_Integer, i++, 1); + sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pColl.zName, 0); + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2); + } + } else #endif // * SQLITE_OMIT_SCHEMA_PRAGMAS */ #if !SQLITE_OMIT_FOREIGN_KEY - if ( zLeft.Equals( "foreign_key_list", StringComparison.OrdinalIgnoreCase ) && zRight != null ) - { - FKey pFK; - Table pTab; - if ( sqlite3ReadSchema( pParse ) != 0 ) - goto pragma_out; - pTab = sqlite3FindTable( db, zRight, zDb ); - if ( pTab != null ) - { - v = sqlite3GetVdbe( pParse ); - pFK = pTab.pFKey; - if ( pFK != null ) - { - int i = 0; - sqlite3VdbeSetNumCols( v, 8 ); - pParse.nMem = 8; - sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "id", SQLITE_STATIC ); - sqlite3VdbeSetColName( v, 1, COLNAME_NAME, "seq", SQLITE_STATIC ); - sqlite3VdbeSetColName( v, 2, COLNAME_NAME, "table", SQLITE_STATIC ); - sqlite3VdbeSetColName( v, 3, COLNAME_NAME, "from", SQLITE_STATIC ); - sqlite3VdbeSetColName( v, 4, COLNAME_NAME, "to", SQLITE_STATIC ); - sqlite3VdbeSetColName( v, 5, COLNAME_NAME, "on_update", SQLITE_STATIC ); - sqlite3VdbeSetColName( v, 6, COLNAME_NAME, "on_delete", SQLITE_STATIC ); - sqlite3VdbeSetColName( v, 7, COLNAME_NAME, "match", SQLITE_STATIC ); - while ( pFK != null ) - { - int j; - for ( j = 0; j < pFK.nCol; j++ ) - { - string zCol = pFK.aCol[j].zCol; - string zOnDelete = actionName( pFK.aAction[0] ); - string zOnUpdate = actionName( pFK.aAction[1] ); - sqlite3VdbeAddOp2( v, OP_Integer, i, 1 ); - sqlite3VdbeAddOp2( v, OP_Integer, j, 2 ); - sqlite3VdbeAddOp4( v, OP_String8, 0, 3, 0, pFK.zTo, 0 ); - sqlite3VdbeAddOp4( v, OP_String8, 0, 4, 0, - pTab.aCol[pFK.aCol[j].iFrom].zName, 0 ); - sqlite3VdbeAddOp4( v, zCol != null ? OP_String8 : OP_Null, 0, 5, 0, zCol, 0 ); - sqlite3VdbeAddOp4( v, OP_String8, 0, 6, 0, zOnUpdate, 0 ); - sqlite3VdbeAddOp4( v, OP_String8, 0, 7, 0, zOnDelete, 0 ); - sqlite3VdbeAddOp4( v, OP_String8, 0, 8, 0, "NONE", 0 ); - sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 8 ); - } - ++i; - pFK = pFK.pNextFrom; - } - } - } - } - else + if (zLeft.Equals("foreign_key_list", StringComparison.OrdinalIgnoreCase) && zRight != null) { + FKey pFK; + Table pTab; + if (sqlite3ReadSchema(pParse) != 0) + goto pragma_out; + pTab = sqlite3FindTable(db, zRight, zDb); + if (pTab != null) { + v = sqlite3GetVdbe(pParse); + pFK = pTab.pFKey; + if (pFK != null) { + int i = 0; + sqlite3VdbeSetNumCols(v, 8); + pParse.nMem = 8; + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "id", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "seq", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "table", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "from", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "to", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "on_update", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 6, COLNAME_NAME, "on_delete", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 7, COLNAME_NAME, "match", SQLITE_STATIC); + while (pFK != null) { + int j; + for (j = 0; j < pFK.nCol; j++) { + string zCol = pFK.aCol[j].zCol; + string zOnDelete = actionName(pFK.aAction[0]); + string zOnUpdate = actionName(pFK.aAction[1]); + sqlite3VdbeAddOp2(v, OP_Integer, i, 1); + sqlite3VdbeAddOp2(v, OP_Integer, j, 2); + sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pFK.zTo, 0); + sqlite3VdbeAddOp4(v, OP_String8, 0, 4, 0, + pTab.aCol[pFK.aCol[j].iFrom].zName, 0); + sqlite3VdbeAddOp4(v, zCol != null ? OP_String8 : OP_Null, 0, 5, 0, zCol, 0); + sqlite3VdbeAddOp4(v, OP_String8, 0, 6, 0, zOnUpdate, 0); + sqlite3VdbeAddOp4(v, OP_String8, 0, 7, 0, zOnDelete, 0); + sqlite3VdbeAddOp4(v, OP_String8, 0, 8, 0, "NONE", 0); + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 8); + } + ++i; + pFK = pFK.pNextFrom; + } + } + } + } else #endif // * !SQLITE_OMIT_FOREIGN_KEY) */ #if !NDEBUG - if ( zLeft.Equals( "parser_trace", StringComparison.OrdinalIgnoreCase ) ) - { - if ( zRight != null ) - { - if ( sqlite3GetBoolean( zRight ) != 0 ) - { - sqlite3ParserTrace( Console.Out, "parser: " ); - } - else - { - sqlite3ParserTrace( null, "" ); - } - } - } - else + if (zLeft.Equals("parser_trace", StringComparison.OrdinalIgnoreCase)) { + if (zRight != null) { + if (sqlite3GetBoolean(zRight) != 0) { + sqlite3ParserTrace(Console.Out, "parser: "); + } else { + sqlite3ParserTrace(null, ""); + } + } + } else #endif - /* Reinstall the LIKE and GLOB functions. The variant of LIKE -** used will be case sensitive or not depending on the RHS. -*/ - if ( zLeft.Equals( "case_sensitive_like", StringComparison.OrdinalIgnoreCase ) ) - { - if ( zRight != null ) - { - sqlite3RegisterLikeFunctions( db, sqlite3GetBoolean( zRight ) ); - } - } - else + /* Reinstall the LIKE and GLOB functions. The variant of LIKE + ** used will be case sensitive or not depending on the RHS. + */ + if (zLeft.Equals("case_sensitive_like", StringComparison.OrdinalIgnoreCase)) { + if (zRight != null) { + sqlite3RegisterLikeFunctions(db, sqlite3GetBoolean(zRight)); + } + } else #if !SQLITE_INTEGRITY_CHECK_ERROR_MAX - //const int SQLITE_INTEGRITY_CHECK_ERROR_MAX = 100; + //const int SQLITE_INTEGRITY_CHECK_ERROR_MAX = 100; #endif #if !SQLITE_OMIT_INTEGRITY_CHECK - /* Pragma "quick_check" is an experimental reduced version of -** integrity_check designed to detect most database corruption -** without most of the overhead of a full integrity-check. -*/ - if ( zLeft.Equals( "integrity_check", StringComparison.OrdinalIgnoreCase ) - || zLeft.Equals( "quick_check", StringComparison.OrdinalIgnoreCase ) - ) - { - const int SQLITE_INTEGRITY_CHECK_ERROR_MAX = 100; - int i, j, addr, mxErr; - - /* Code that appears at the end of the integrity check. If no error - ** messages have been generated, refput OK. Otherwise output the - ** error message - */ - VdbeOpList[] endCode = new VdbeOpList[] { + /* Pragma "quick_check" is an experimental reduced version of + ** integrity_check designed to detect most database corruption + ** without most of the overhead of a full integrity-check. + */ + if (zLeft.Equals("integrity_check", StringComparison.OrdinalIgnoreCase) + || zLeft.Equals("quick_check", StringComparison.OrdinalIgnoreCase) + ) { + const int SQLITE_INTEGRITY_CHECK_ERROR_MAX = 100; + int i, j, addr, mxErr; + + /* Code that appears at the end of the integrity check. If no error + ** messages have been generated, refput OK. Otherwise output the + ** error message + */ + VdbeOpList[] endCode = new VdbeOpList[] { new VdbeOpList( OP_AddImm, 1, 0, 0), /* 0 */ new VdbeOpList( OP_IfNeg, 1, 0, 0), /* 1 */ new VdbeOpList( OP_String8, 0, 3, 0), /* 2 */ new VdbeOpList( OP_ResultRow, 3, 1, 0), }; - bool isQuick = ( zLeft[0] == 'q' ); - - /* Initialize the VDBE program */ - if ( sqlite3ReadSchema( pParse ) != 0 ) - goto pragma_out; - pParse.nMem = 6; - sqlite3VdbeSetNumCols( v, 1 ); - sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "integrity_check", SQLITE_STATIC ); - - /* Set the maximum error count */ - mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX; - if ( zRight != null ) - { - sqlite3GetInt32( zRight, ref mxErr ); - if ( mxErr <= 0 ) - { - mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX; - } - } - sqlite3VdbeAddOp2( v, OP_Integer, mxErr, 1 ); /* reg[1] holds errors left */ - - /* Do an integrity check on each database file */ - for ( i = 0; i < db.nDb; i++ ) - { - HashElem x; - Hash pTbls; - int cnt = 0; - - if ( OMIT_TEMPDB != 0 && i == 1 ) - continue; - - sqlite3CodeVerifySchema( pParse, i ); - addr = sqlite3VdbeAddOp1( v, OP_IfPos, 1 ); /* Halt if out of errors */ - sqlite3VdbeAddOp2( v, OP_Halt, 0, 0 ); - sqlite3VdbeJumpHere( v, addr ); - - /* Do an integrity check of the B-Tree - ** - ** Begin by filling registers 2, 3, ... with the root pages numbers - ** for all tables and indices in the database. - */ - Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); - pTbls = db.aDb[i].pSchema.tblHash; - for ( x = pTbls.first; x != null; x = x.next ) - {// for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){ - Table pTab = (Table)x.data;// sqliteHashData( x ); - Index pIdx; - sqlite3VdbeAddOp2( v, OP_Integer, pTab.tnum, 2 + cnt ); - cnt++; - for ( pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext ) - { - sqlite3VdbeAddOp2( v, OP_Integer, pIdx.tnum, 2 + cnt ); - cnt++; - } - } - - /* Make sure sufficient number of registers have been allocated */ - if ( pParse.nMem < cnt + 4 ) - { - pParse.nMem = cnt + 4; - } - - /* Do the b-tree integrity checks */ - sqlite3VdbeAddOp3( v, OP_IntegrityCk, 2, cnt, 1 ); - sqlite3VdbeChangeP5( v, (u8)i ); - addr = sqlite3VdbeAddOp1( v, OP_IsNull, 2 ); - sqlite3VdbeAddOp4( v, OP_String8, 0, 3, 0, - sqlite3MPrintf( db, "*** in database %s ***\n", db.aDb[i].zName ), - P4_DYNAMIC ); - sqlite3VdbeAddOp3( v, OP_Move, 2, 4, 1 ); - sqlite3VdbeAddOp3( v, OP_Concat, 4, 3, 2 ); - sqlite3VdbeAddOp2( v, OP_ResultRow, 2, 1 ); - sqlite3VdbeJumpHere( v, addr ); - - /* Make sure all the indices are constructed correctly. - */ - for ( x = pTbls.first; x != null && !isQuick; x = x.next ) - { - ;// for(x=sqliteHashFirst(pTbls); x && !isQuick; x=sqliteHashNext(x)){ - Table pTab = (Table)x.data;// sqliteHashData( x ); - Index pIdx; - int loopTop; - - if ( pTab.pIndex == null ) - continue; - addr = sqlite3VdbeAddOp1( v, OP_IfPos, 1 ); /* Stop if out of errors */ - sqlite3VdbeAddOp2( v, OP_Halt, 0, 0 ); - sqlite3VdbeJumpHere( v, addr ); - sqlite3OpenTableAndIndices( pParse, pTab, 1, OP_OpenRead ); - sqlite3VdbeAddOp2( v, OP_Integer, 0, 2 ); /* reg(2) will count entries */ - loopTop = sqlite3VdbeAddOp2( v, OP_Rewind, 1, 0 ); - sqlite3VdbeAddOp2( v, OP_AddImm, 2, 1 ); /* increment entry count */ - for ( j = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, j++ ) - { - int jmp2; - int r1; - VdbeOpList[] idxErr = new VdbeOpList[] { + bool isQuick = (zLeft[0] == 'q'); + + /* Initialize the VDBE program */ + if (sqlite3ReadSchema(pParse) != 0) + goto pragma_out; + pParse.nMem = 6; + sqlite3VdbeSetNumCols(v, 1); + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "integrity_check", SQLITE_STATIC); + + /* Set the maximum error count */ + mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX; + if (zRight != null) { + sqlite3GetInt32(zRight, ref mxErr); + if (mxErr <= 0) { + mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX; + } + } + sqlite3VdbeAddOp2(v, OP_Integer, mxErr, 1); /* reg[1] holds errors left */ + + /* Do an integrity check on each database file */ + for (i = 0; i < db.nDb; i++) { + HashElem x; + Hash pTbls; + int cnt = 0; + + if (OMIT_TEMPDB != 0 && i == 1) + continue; + + sqlite3CodeVerifySchema(pParse, i); + addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Halt if out of errors */ + sqlite3VdbeAddOp2(v, OP_Halt, 0, 0); + sqlite3VdbeJumpHere(v, addr); + + /* Do an integrity check of the B-Tree + ** + ** Begin by filling registers 2, 3, ... with the root pages numbers + ** for all tables and indices in the database. + */ + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + pTbls = db.aDb[i].pSchema.tblHash; + for (x = pTbls.first; x != null; x = x.next) {// for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){ + Table pTab = (Table)x.data;// sqliteHashData( x ); + Index pIdx; + sqlite3VdbeAddOp2(v, OP_Integer, pTab.tnum, 2 + cnt); + cnt++; + for (pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext) { + sqlite3VdbeAddOp2(v, OP_Integer, pIdx.tnum, 2 + cnt); + cnt++; + } + } + + /* Make sure sufficient number of registers have been allocated */ + if (pParse.nMem < cnt + 4) { + pParse.nMem = cnt + 4; + } + + /* Do the b-tree integrity checks */ + sqlite3VdbeAddOp3(v, OP_IntegrityCk, 2, cnt, 1); + sqlite3VdbeChangeP5(v, (u8)i); + addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); + sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, + sqlite3MPrintf(db, "*** in database %s ***\n", db.aDb[i].zName), + P4_DYNAMIC); + sqlite3VdbeAddOp3(v, OP_Move, 2, 4, 1); + sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 2); + sqlite3VdbeAddOp2(v, OP_ResultRow, 2, 1); + sqlite3VdbeJumpHere(v, addr); + + /* Make sure all the indices are constructed correctly. + */ + for (x = pTbls.first; x != null && !isQuick; x = x.next) { + ;// for(x=sqliteHashFirst(pTbls); x && !isQuick; x=sqliteHashNext(x)){ + Table pTab = (Table)x.data;// sqliteHashData( x ); + Index pIdx; + int loopTop; + + if (pTab.pIndex == null) + continue; + addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Stop if out of errors */ + sqlite3VdbeAddOp2(v, OP_Halt, 0, 0); + sqlite3VdbeJumpHere(v, addr); + sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead); + sqlite3VdbeAddOp2(v, OP_Integer, 0, 2); /* reg(2) will count entries */ + loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0); + sqlite3VdbeAddOp2(v, OP_AddImm, 2, 1); /* increment entry count */ + for (j = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, j++) { + int jmp2; + int r1; + VdbeOpList[] idxErr = new VdbeOpList[] { new VdbeOpList( OP_AddImm, 1, -1, 0), new VdbeOpList( OP_String8, 0, 3, 0), /* 1 */ new VdbeOpList( OP_Rowid, 1, 4, 0), @@ -1481,20 +1294,19 @@ static void sqlite3Pragma( new VdbeOpList( OP_IfPos, 1, 0, 0), /* 9 */ new VdbeOpList( OP_Halt, 0, 0, 0), }; - r1 = sqlite3GenerateIndexKey( pParse, pIdx, 1, 3, false ); - jmp2 = sqlite3VdbeAddOp4Int( v, OP_Found, j + 2, 0, r1, pIdx.nColumn + 1 ); - addr = sqlite3VdbeAddOpList( v, ArraySize( idxErr ), idxErr ); - sqlite3VdbeChangeP4( v, addr + 1, "rowid ", SQLITE_STATIC ); - sqlite3VdbeChangeP4( v, addr + 3, " missing from index ", SQLITE_STATIC ); - sqlite3VdbeChangeP4( v, addr + 4, pIdx.zName, P4_TRANSIENT ); - sqlite3VdbeJumpHere( v, addr + 9 ); - sqlite3VdbeJumpHere( v, jmp2 ); - } - sqlite3VdbeAddOp2( v, OP_Next, 1, loopTop + 1 ); - sqlite3VdbeJumpHere( v, loopTop ); - for ( j = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, j++ ) - { - VdbeOpList[] cntIdx = new VdbeOpList[] { + r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, false); + jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, j + 2, 0, r1, pIdx.nColumn + 1); + addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr); + sqlite3VdbeChangeP4(v, addr + 1, "rowid ", SQLITE_STATIC); + sqlite3VdbeChangeP4(v, addr + 3, " missing from index ", SQLITE_STATIC); + sqlite3VdbeChangeP4(v, addr + 4, pIdx.zName, P4_TRANSIENT); + sqlite3VdbeJumpHere(v, addr + 9); + sqlite3VdbeJumpHere(v, jmp2); + } + sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop + 1); + sqlite3VdbeJumpHere(v, loopTop); + for (j = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, j++) { + VdbeOpList[] cntIdx = new VdbeOpList[] { new VdbeOpList( OP_Integer, 0, 3, 0), new VdbeOpList( OP_Rewind, 0, 0, 0), /* 1 */ new VdbeOpList( OP_AddImm, 3, 1, 0), @@ -1506,71 +1318,67 @@ static void sqlite3Pragma( new VdbeOpList( OP_Concat, 3, 2, 2), new VdbeOpList( OP_ResultRow, 2, 1, 0), }; - addr = sqlite3VdbeAddOp1( v, OP_IfPos, 1 ); - sqlite3VdbeAddOp2( v, OP_Halt, 0, 0 ); - sqlite3VdbeJumpHere( v, addr ); - addr = sqlite3VdbeAddOpList( v, ArraySize( cntIdx ), cntIdx ); - sqlite3VdbeChangeP1( v, addr + 1, j + 2 ); - sqlite3VdbeChangeP2( v, addr + 1, addr + 4 ); - sqlite3VdbeChangeP1( v, addr + 3, j + 2 ); - sqlite3VdbeChangeP2( v, addr + 3, addr + 2 ); - sqlite3VdbeJumpHere( v, addr + 4 ); - sqlite3VdbeChangeP4( v, addr + 6, - "wrong # of entries in index ", P4_STATIC ); - sqlite3VdbeChangeP4( v, addr + 7, pIdx.zName, P4_TRANSIENT ); - } - } - } - addr = sqlite3VdbeAddOpList( v, ArraySize( endCode ), endCode ); - sqlite3VdbeChangeP2( v, addr, -mxErr ); - sqlite3VdbeJumpHere( v, addr + 1 ); - sqlite3VdbeChangeP4( v, addr + 2, "ok", P4_STATIC ); - } - else + addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); + sqlite3VdbeAddOp2(v, OP_Halt, 0, 0); + sqlite3VdbeJumpHere(v, addr); + addr = sqlite3VdbeAddOpList(v, ArraySize(cntIdx), cntIdx); + sqlite3VdbeChangeP1(v, addr + 1, j + 2); + sqlite3VdbeChangeP2(v, addr + 1, addr + 4); + sqlite3VdbeChangeP1(v, addr + 3, j + 2); + sqlite3VdbeChangeP2(v, addr + 3, addr + 2); + sqlite3VdbeJumpHere(v, addr + 4); + sqlite3VdbeChangeP4(v, addr + 6, + "wrong # of entries in index ", P4_STATIC); + sqlite3VdbeChangeP4(v, addr + 7, pIdx.zName, P4_TRANSIENT); + } + } + } + addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode); + sqlite3VdbeChangeP2(v, addr, -mxErr); + sqlite3VdbeJumpHere(v, addr + 1); + sqlite3VdbeChangeP4(v, addr + 2, "ok", P4_STATIC); + } else #endif // * SQLITE_OMIT_INTEGRITY_CHECK */ - /* -** PRAGMA encoding -** PRAGMA encoding = "utf-8"|"utf-16"|"utf-16le"|"utf-16be" -** -** In its first form, this pragma returns the encoding of the main -** database. If the database is not initialized, it is initialized now. -** -** The second form of this pragma is a no-op if the main database file -** has not already been initialized. In this case it sets the default -** encoding that will be used for the main database file if a new file -** is created. If an existing main database file is opened, then the -** default text encoding for the existing database is used. -** -** In all cases new databases created using the ATTACH command are -** created to use the same default text encoding as the main database. If -** the main database has not been initialized and/or created when ATTACH -** is executed, this is done before the ATTACH operation. -** -** 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 -*/ - if ( zLeft.Equals( "encoding", StringComparison.OrdinalIgnoreCase ) ) - { - int iEnc; - if ( null == zRight ) - { /* "PRAGMA encoding" */ - if ( sqlite3ReadSchema( pParse ) != 0 ) - { - pParse.nErr = 0; - pParse.zErrMsg = null; - pParse.rc = 0;// reset errors goto pragma_out; - } - sqlite3VdbeSetNumCols( v, 1 ); - sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "encoding", SQLITE_STATIC ); - sqlite3VdbeAddOp2( v, OP_String8, 0, 1 ); - Debug.Assert( encnames[SQLITE_UTF8].enc == SQLITE_UTF8 ); - Debug.Assert( encnames[SQLITE_UTF16LE].enc == SQLITE_UTF16LE ); - Debug.Assert( encnames[SQLITE_UTF16BE].enc == SQLITE_UTF16BE ); - sqlite3VdbeChangeP4( v, -1, encnames[ENC( pParse.db )].zName, P4_STATIC ); - sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 1 ); - } + /* + ** PRAGMA encoding + ** PRAGMA encoding = "utf-8"|"utf-16"|"utf-16le"|"utf-16be" + ** + ** In its first form, this pragma returns the encoding of the main + ** database. If the database is not initialized, it is initialized now. + ** + ** The second form of this pragma is a no-op if the main database file + ** has not already been initialized. In this case it sets the default + ** encoding that will be used for the main database file if a new file + ** is created. If an existing main database file is opened, then the + ** default text encoding for the existing database is used. + ** + ** In all cases new databases created using the ATTACH command are + ** created to use the same default text encoding as the main database. If + ** the main database has not been initialized and/or created when ATTACH + ** is executed, this is done before the ATTACH operation. + ** + ** 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 + */ + if (zLeft.Equals("encoding", StringComparison.OrdinalIgnoreCase)) { + int iEnc; + if (null == zRight) { /* "PRAGMA encoding" */ + if (sqlite3ReadSchema(pParse) != 0) { + pParse.nErr = 0; + pParse.zErrMsg = null; + pParse.rc = 0;// reset errors goto pragma_out; + } + sqlite3VdbeSetNumCols(v, 1); + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "encoding", SQLITE_STATIC); + sqlite3VdbeAddOp2(v, OP_String8, 0, 1); + Debug.Assert(encnames[SQLITE_UTF8].enc == SQLITE_UTF8); + Debug.Assert(encnames[SQLITE_UTF16LE].enc == SQLITE_UTF16LE); + Debug.Assert(encnames[SQLITE_UTF16BE].enc == SQLITE_UTF16BE); + sqlite3VdbeChangeP4(v, -1, encnames[ENC(pParse.db)].zName, P4_STATIC); + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); + } #if !SQLITE_OMIT_UTF16 else { /* "PRAGMA encoding = XXX" */ @@ -1600,121 +1408,107 @@ static void sqlite3Pragma( } } #endif - } - else + } else #if !SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS - /* -** PRAGMA [database.]schema_version -** PRAGMA [database.]schema_version = -** -** PRAGMA [database.]user_version -** PRAGMA [database.]user_version = -** -** The pragma's schema_version and user_version are used to set or get -** the value of the schema-version and user-version, respectively. Both -** the schema-version and the user-version are 32-bit signed integers -** stored in the database header. -** -** The schema-cookie is usually only manipulated internally by SQLite. It -** is incremented by SQLite whenever the database schema is modified (by -** creating or dropping a table or index). The schema version is used by -** SQLite each time a query is executed to ensure that the internal cache -** of the schema used when compiling the SQL query matches the schema of -** the database against which the compiled query is actually executed. -** Subverting this mechanism by using "PRAGMA schema_version" to modify -** the schema-version is potentially dangerous and may lead to program -** 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. -*/ - if ( zLeft.Equals( "schema_version", StringComparison.OrdinalIgnoreCase ) - || zLeft.Equals( "user_version", StringComparison.OrdinalIgnoreCase ) - || zLeft.Equals( "freelist_count", StringComparison.OrdinalIgnoreCase ) - ) - { - int iCookie; /* Cookie index. 1 for schema-cookie, 6 for user-cookie. */ - sqlite3VdbeUsesBtree( v, iDb ); - switch ( zLeft[0] ) - { - case 'f': - case 'F': - iCookie = BTREE_FREE_PAGE_COUNT; - break; - case 's': - case 'S': - iCookie = BTREE_SCHEMA_VERSION; - break; - default: - iCookie = BTREE_USER_VERSION; - break; - } - - if ( zRight != null && iCookie != BTREE_FREE_PAGE_COUNT ) - { - /* Write the specified cookie value */ - VdbeOpList[] setCookie = new VdbeOpList[] { + /* + ** PRAGMA [database.]schema_version + ** PRAGMA [database.]schema_version = + ** + ** PRAGMA [database.]user_version + ** PRAGMA [database.]user_version = + ** + ** The pragma's schema_version and user_version are used to set or get + ** the value of the schema-version and user-version, respectively. Both + ** the schema-version and the user-version are 32-bit signed integers + ** stored in the database header. + ** + ** The schema-cookie is usually only manipulated internally by SQLite. It + ** is incremented by SQLite whenever the database schema is modified (by + ** creating or dropping a table or index). The schema version is used by + ** SQLite each time a query is executed to ensure that the internal cache + ** of the schema used when compiling the SQL query matches the schema of + ** the database against which the compiled query is actually executed. + ** Subverting this mechanism by using "PRAGMA schema_version" to modify + ** the schema-version is potentially dangerous and may lead to program + ** 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. + */ + if (zLeft.Equals("schema_version", StringComparison.OrdinalIgnoreCase) + || zLeft.Equals("user_version", StringComparison.OrdinalIgnoreCase) + || zLeft.Equals("freelist_count", StringComparison.OrdinalIgnoreCase) + ) { + int iCookie; /* Cookie index. 1 for schema-cookie, 6 for user-cookie. */ + sqlite3VdbeUsesBtree(v, iDb); + switch (zLeft[0]) { + case 'f': + case 'F': + iCookie = BTREE_FREE_PAGE_COUNT; + break; + case 's': + case 'S': + iCookie = BTREE_SCHEMA_VERSION; + break; + default: + iCookie = BTREE_USER_VERSION; + break; + } + + if (zRight != null && iCookie != BTREE_FREE_PAGE_COUNT) { + /* Write the specified cookie value */ + VdbeOpList[] setCookie = new VdbeOpList[] { new VdbeOpList( OP_Transaction, 0, 1, 0), /* 0 */ new VdbeOpList( OP_Integer, 0, 1, 0), /* 1 */ new VdbeOpList( OP_SetCookie, 0, 0, 1), /* 2 */ }; - int addr = sqlite3VdbeAddOpList( v, ArraySize( setCookie ), setCookie ); - sqlite3VdbeChangeP1( v, addr, iDb ); - sqlite3VdbeChangeP1( v, addr + 1, sqlite3Atoi( zRight ) ); - sqlite3VdbeChangeP1( v, addr + 2, iDb ); - sqlite3VdbeChangeP2( v, addr + 2, iCookie ); - } - else - { - /* Read the specified cookie value */ - VdbeOpList[] readCookie = new VdbeOpList[] { + int addr = sqlite3VdbeAddOpList(v, ArraySize(setCookie), setCookie); + sqlite3VdbeChangeP1(v, addr, iDb); + sqlite3VdbeChangeP1(v, addr + 1, sqlite3Atoi(zRight)); + sqlite3VdbeChangeP1(v, addr + 2, iDb); + sqlite3VdbeChangeP2(v, addr + 2, iCookie); + } else { + /* Read the specified cookie value */ + VdbeOpList[] readCookie = new VdbeOpList[] { new VdbeOpList( OP_Transaction, 0, 0, 0), /* 0 */ new VdbeOpList( OP_ReadCookie, 0, 1, 0), /* 1 */ new VdbeOpList( OP_ResultRow, 1, 1, 0) }; - int addr = sqlite3VdbeAddOpList( v, readCookie.Length, readCookie );// ArraySize(readCookie), readCookie); - sqlite3VdbeChangeP1( v, addr, iDb ); - sqlite3VdbeChangeP1( v, addr + 1, iDb ); - sqlite3VdbeChangeP3( v, addr + 1, iCookie ); - sqlite3VdbeSetNumCols( v, 1 ); - sqlite3VdbeSetColName( v, 0, COLNAME_NAME, zLeft, SQLITE_TRANSIENT ); - } - } - else if ( zLeft.Equals( "reload_schema", StringComparison.OrdinalIgnoreCase ) ) - { - /* force schema reloading*/ - sqlite3ResetInternalSchema( db, -1 ); - } - else if ( zLeft.Equals( "file_format", StringComparison.OrdinalIgnoreCase ) ) - { - pDb.pSchema.file_format = (u8)atoi( zRight ); - sqlite3ResetInternalSchema( db, -1 ); - } - else + int addr = sqlite3VdbeAddOpList(v, readCookie.Length, readCookie);// ArraySize(readCookie), readCookie); + sqlite3VdbeChangeP1(v, addr, iDb); + sqlite3VdbeChangeP1(v, addr + 1, iDb); + sqlite3VdbeChangeP3(v, addr + 1, iCookie); + sqlite3VdbeSetNumCols(v, 1); + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLeft, SQLITE_TRANSIENT); + } + } else if (zLeft.Equals("reload_schema", StringComparison.OrdinalIgnoreCase)) { + /* force schema reloading*/ + sqlite3ResetInternalSchema(db, -1); + } else if (zLeft.Equals("file_format", StringComparison.OrdinalIgnoreCase)) { + pDb.pSchema.file_format = (u8)atoi(zRight); + sqlite3ResetInternalSchema(db, -1); + } else #endif // * SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS */ #if !SQLITE_OMIT_COMPILEOPTION_DIAGS - /* + /* ** PRAGMA compile_options ** ** Return the names of all compile-time options used in this build, ** one option per row. */ - if ( zLeft.Equals( "compile_options", StringComparison.OrdinalIgnoreCase ) ) - { - int i = 0; - string zOpt; - sqlite3VdbeSetNumCols( v, 1 ); - pParse.nMem = 1; - sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "compile_option", SQLITE_STATIC ); - while ( ( zOpt = sqlite3_compileoption_get( i++ ) ) != null ) - { - sqlite3VdbeAddOp4( v, OP_String8, 0, 1, 0, zOpt, 0 ); - sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 1 ); - } - } - else + if (zLeft.Equals("compile_options", StringComparison.OrdinalIgnoreCase)) { + int i = 0; + string zOpt; + sqlite3VdbeSetNumCols(v, 1); + pParse.nMem = 1; + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "compile_option", SQLITE_STATIC); + while ((zOpt = sqlite3_compileoption_get(i++)) != null) { + sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, zOpt, 0); + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); + } + } else #endif //* SQLITE_OMIT_COMPILEOPTION_DIAGS */ @@ -1764,43 +1558,37 @@ static void sqlite3Pragma( #endif #if SQLITE_DEBUG || SQLITE_TEST - /* + /* ** Report the current state of file logs for all databases */ - if ( zLeft.Equals( "lock_status", StringComparison.OrdinalIgnoreCase ) ) - { - string[] azLockName = { + if (zLeft.Equals("lock_status", StringComparison.OrdinalIgnoreCase)) { + string[] azLockName = { "unlocked", "shared", "reserved", "pending", "exclusive" }; - int i; - sqlite3VdbeSetNumCols( v, 2 ); - pParse.nMem = 2; - sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "database", SQLITE_STATIC ); - sqlite3VdbeSetColName( v, 1, COLNAME_NAME, "status", SQLITE_STATIC ); - for ( i = 0; i < db.nDb; i++ ) - { - Btree pBt; - Pager pPager; - string zState = "unknown"; - sqlite3_int64 j = 0; - if ( db.aDb[i].zName == null ) - continue; - sqlite3VdbeAddOp4( v, OP_String8, 0, 1, 0, db.aDb[i].zName, P4_STATIC ); - pBt = db.aDb[i].pBt; - if ( pBt == null || ( pPager = sqlite3BtreePager( pBt ) ) == null ) - { - zState = "closed"; - } - else if ( sqlite3_file_control( db, i != 0 ? db.aDb[i].zName : null, - SQLITE_FCNTL_LOCKSTATE, ref j ) == SQLITE_OK ) - { - zState = azLockName[j]; - } - sqlite3VdbeAddOp4( v, OP_String8, 0, 2, 0, zState, P4_STATIC ); - sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 2 ); - } - } - else + int i; + sqlite3VdbeSetNumCols(v, 2); + pParse.nMem = 2; + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "database", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "status", SQLITE_STATIC); + for (i = 0; i < db.nDb; i++) { + Btree pBt; + Pager pPager; + string zState = "unknown"; + sqlite3_int64 j = 0; + if (db.aDb[i].zName == null) + continue; + sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, db.aDb[i].zName, P4_STATIC); + pBt = db.aDb[i].pBt; + if (pBt == null || (pPager = sqlite3BtreePager(pBt)) == null) { + zState = "closed"; + } else if (sqlite3_file_control(db, i != 0 ? db.aDb[i].zName : null, + SQLITE_FCNTL_LOCKSTATE, ref j) == SQLITE_OK) { + zState = azLockName[j]; + } + sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, zState, P4_STATIC); + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2); + } + } else #endif #if SQLITE_HAS_CODEC @@ -1861,27 +1649,26 @@ static void sqlite3Pragma( } else #endif - { /* Empty ELSE clause */ - } + { /* Empty ELSE clause */ + } - /* - ** Reset the safety level, in case the fullfsync flag or synchronous - ** setting changed. - */ + /* + ** Reset the safety level, in case the fullfsync flag or synchronous + ** setting changed. + */ #if !SQLITE_OMIT_PAGER_PRAGMAS - if ( db.autoCommit != 0 ) - { - sqlite3BtreeSetSafetyLevel( pDb.pBt, pDb.safety_level, - ( ( db.flags & SQLITE_FullFSync ) != 0 ) ? 1 : 0, - ( ( db.flags & SQLITE_CkptFullFSync ) != 0 ) ? 1 : 0 ); - } + if (db.autoCommit != 0) { + sqlite3BtreeSetSafetyLevel(pDb.pBt, pDb.safety_level, + ((db.flags & SQLITE_FullFSync) != 0) ? 1 : 0, + ((db.flags & SQLITE_CkptFullFSync) != 0) ? 1 : 0); + } #endif -pragma_out: - sqlite3DbFree( db, ref zLeft ); - sqlite3DbFree( db, ref zRight ); - ; - } + pragma_out: + sqlite3DbFree(db, ref zLeft); + sqlite3DbFree(db, ref zRight); + ; + } #endif // * SQLITE_OMIT_PRAGMA - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/prepare_c.cs b/Src/IronPython.SQLite/c#sqlite/prepare_c.cs index d36fd8ffd..68e80a38e 100644 --- a/Src/IronPython.SQLite/c#sqlite/prepare_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/prepare_c.cs @@ -2,1006 +2,899 @@ using System.Diagnostics; using System.Text; -using u8 = System.Byte; -using u16 = System.UInt16; -using u32 = System.UInt32; using sqlite3_int64 = System.Int64; +using u32 = System.UInt32; +using u8 = System.Byte; -namespace Community.CsharpSqlite -{ - using sqlite3_stmt = Sqlite3.Vdbe; - - public partial class Sqlite3 - { - /* - ** 2005 May 25 - ** - ** 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 contains the implementation of the sqlite3_prepare() - ** interface, and routines that contribute to loading the database schema - ** from disk. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +namespace Community.CsharpSqlite { + using sqlite3_stmt = Sqlite3.Vdbe; + + public partial class Sqlite3 { + /* + ** 2005 May 25 + ** + ** 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 contains the implementation of the sqlite3_prepare() + ** interface, and routines that contribute to loading the database schema + ** from disk. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ + //#include "sqliteInt.h" - /* - ** Fill the InitData structure with an error message that indicates - ** that the database is corrupt. - */ - static void corruptSchema( - InitData pData, /* Initialization context */ - string zObj, /* Object being parsed at the point of error */ - string zExtra /* Error information */ - ) - { - sqlite3 db = pData.db; - if ( /* 0 == db.mallocFailed && */ ( db.flags & SQLITE_RecoveryMode ) == 0 ) - { - { - if ( zObj == null ) - { - zObj = "?"; + /* + ** Fill the InitData structure with an error message that indicates + ** that the database is corrupt. + */ + static void corruptSchema( + InitData pData, /* Initialization context */ + string zObj, /* Object being parsed at the point of error */ + string zExtra /* Error information */ + ) { + sqlite3 db = pData.db; + if ( /* 0 == db.mallocFailed && */ (db.flags & SQLITE_RecoveryMode) == 0) { + { + if (zObj == null) { + zObj = "?"; #if SQLITE_OMIT_UTF16 - if (ENC(db) != SQLITE_UTF8) - zObj =encnames[(ENC(db))].zName; + if (ENC(db) != SQLITE_UTF8) + zObj = encnames[(ENC(db))].zName; #endif - } - sqlite3SetString( ref pData.pzErrMsg, db, - "malformed database schema (%s)", zObj ); - if ( !String.IsNullOrEmpty( zExtra ) ) - { - pData.pzErrMsg = sqlite3MAppendf( db, pData.pzErrMsg - , "%s - %s", pData.pzErrMsg, zExtra ); - } + } + sqlite3SetString(ref pData.pzErrMsg, db, + "malformed database schema (%s)", zObj); + if (!String.IsNullOrEmpty(zExtra)) { + pData.pzErrMsg = sqlite3MAppendf(db, pData.pzErrMsg + , "%s - %s", pData.pzErrMsg, zExtra); + } + } + pData.rc = //db.mallocFailed != 0 ? SQLITE_NOMEM : + SQLITE_CORRUPT_BKPT(); + } } - pData.rc = //db.mallocFailed != 0 ? SQLITE_NOMEM : - SQLITE_CORRUPT_BKPT(); - } - } - - /* - ** This is the callback routine for the code that initializes the - ** database. See sqlite3Init() below for additional information. - ** This routine is also called from the OP_ParseSchema opcode of the VDBE. - ** - ** Each callback contains the following information: - ** - ** argv[0] = name of thing being created - ** argv[1] = root page number for table or index. 0 for trigger or view. - ** argv[2] = SQL text for the CREATE statement. - ** - */ - static int sqlite3InitCallback( object pInit, sqlite3_int64 argc, object p2, object NotUsed ) - { - string[] argv = (string[])p2; - InitData pData = (InitData)pInit; - sqlite3 db = pData.db; - int iDb = pData.iDb; - Debug.Assert( argc == 3 ); - UNUSED_PARAMETER2( NotUsed, argc ); - Debug.Assert( sqlite3_mutex_held( db.mutex ) ); - DbClearProperty( db, iDb, DB_Empty ); - //if ( db.mallocFailed != 0 ) - //{ - // corruptSchema( pData, argv[0], "" ); - // return 1; - //} - - Debug.Assert( iDb >= 0 && iDb < db.nDb ); - if ( argv == null ) - return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */ - if ( argv[1] == null ) - { - corruptSchema( pData, argv[0], "" ); - } - else if ( !String.IsNullOrEmpty( argv[2] ) ) - { - /* Call the parser to process a CREATE TABLE, INDEX or VIEW. - ** But because db.init.busy is set to 1, no VDBE code is generated - ** or executed. All the parser does is build the internal data - ** structures that describe the table, index, or view. + /* + ** This is the callback routine for the code that initializes the + ** database. See sqlite3Init() below for additional information. + ** This routine is also called from the OP_ParseSchema opcode of the VDBE. + ** + ** Each callback contains the following information: + ** + ** argv[0] = name of thing being created + ** argv[1] = root page number for table or index. 0 for trigger or view. + ** argv[2] = SQL text for the CREATE statement. + ** */ - int rc; - sqlite3_stmt pStmt = null; + static int sqlite3InitCallback(object pInit, sqlite3_int64 argc, object p2, object NotUsed) { + string[] argv = (string[])p2; + InitData pData = (InitData)pInit; + sqlite3 db = pData.db; + int iDb = pData.iDb; + + Debug.Assert(argc == 3); + UNUSED_PARAMETER2(NotUsed, argc); + Debug.Assert(sqlite3_mutex_held(db.mutex)); + DbClearProperty(db, iDb, DB_Empty); + //if ( db.mallocFailed != 0 ) + //{ + // corruptSchema( pData, argv[0], "" ); + // return 1; + //} + + Debug.Assert(iDb >= 0 && iDb < db.nDb); + if (argv == null) + return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */ + if (argv[1] == null) { + corruptSchema(pData, argv[0], ""); + } else if (!String.IsNullOrEmpty(argv[2])) { + /* Call the parser to process a CREATE TABLE, INDEX or VIEW. + ** But because db.init.busy is set to 1, no VDBE code is generated + ** or executed. All the parser does is build the internal data + ** structures that describe the table, index, or view. + */ + int rc; + sqlite3_stmt pStmt = null; #if !NDEBUG || SQLITE_COVERAGE_TEST - //TESTONLY(int rcp); /* Return code from sqlite3_prepare() */ - int rcp; + //TESTONLY(int rcp); /* Return code from sqlite3_prepare() */ + int rcp; #endif - Debug.Assert( db.init.busy != 0 ); - db.init.iDb = iDb; - db.init.newTnum = sqlite3Atoi( argv[1] ); - db.init.orphanTrigger = 0; - //TESTONLY(rcp = ) sqlite3_prepare(db, argv[2], -1, &pStmt, 0); + Debug.Assert(db.init.busy != 0); + db.init.iDb = iDb; + db.init.newTnum = sqlite3Atoi(argv[1]); + db.init.orphanTrigger = 0; + //TESTONLY(rcp = ) sqlite3_prepare(db, argv[2], -1, &pStmt, 0); #if !NDEBUG || SQLITE_COVERAGE_TEST - rcp = sqlite3_prepare( db, argv[2], -1, ref pStmt, 0 ); + rcp = sqlite3_prepare(db, argv[2], -1, ref pStmt, 0); #else sqlite3_prepare(db, argv[2], -1, ref pStmt, 0); #endif - rc = db.errCode; + rc = db.errCode; #if !NDEBUG || SQLITE_COVERAGE_TEST - Debug.Assert( ( rc & 0xFF ) == ( rcp & 0xFF ) ); + Debug.Assert((rc & 0xFF) == (rcp & 0xFF)); #endif - db.init.iDb = 0; - if ( SQLITE_OK != rc ) - { - if ( db.init.orphanTrigger != 0 ) - { - Debug.Assert( iDb == 1 ); - } - else - { - pData.rc = rc; - //if ( rc == SQLITE_NOMEM ) - //{ - // // db.mallocFailed = 1; - //} - //else - if ( rc != SQLITE_INTERRUPT && ( rc & 0xFF ) != SQLITE_LOCKED ) - { - corruptSchema( pData, argv[0], sqlite3_errmsg( db ) ); + db.init.iDb = 0; + if (SQLITE_OK != rc) { + if (db.init.orphanTrigger != 0) { + Debug.Assert(iDb == 1); + } else { + pData.rc = rc; + //if ( rc == SQLITE_NOMEM ) + //{ + // // db.mallocFailed = 1; + //} + //else + if (rc != SQLITE_INTERRUPT && (rc & 0xFF) != SQLITE_LOCKED) { + corruptSchema(pData, argv[0], sqlite3_errmsg(db)); + } + } + } + sqlite3_finalize(pStmt); + } else if (argv[0] == null || argv[0] == "") { + corruptSchema(pData, null, null); + } else { + /* If the SQL column is blank it means this is an index that + ** was created to be the PRIMARY KEY or to fulfill a UNIQUE + ** constraint for a CREATE TABLE. The index should have already + ** been created when we processed the CREATE TABLE. All we have + ** to do here is record the root page number for that index. + */ + Index pIndex; + pIndex = sqlite3FindIndex(db, argv[0], db.aDb[iDb].zName); + if (pIndex == null) { + /* This can occur if there exists an index on a TEMP table which + ** has the same name as another index on a permanent index. Since + ** the permanent table is hidden by the TEMP table, we can also + ** safely ignore the index on the permanent table. + */ + /* Do Nothing */ + ; + } else if (sqlite3GetInt32(argv[1], ref pIndex.tnum) == false) { + corruptSchema(pData, argv[0], "invalid rootpage"); + } } - } - } - sqlite3_finalize( pStmt ); - } - else if ( argv[0] == null || argv[0] == "" ) - { - corruptSchema( pData, null, null ); - } - else - { - /* If the SQL column is blank it means this is an index that - ** was created to be the PRIMARY KEY or to fulfill a UNIQUE - ** constraint for a CREATE TABLE. The index should have already - ** been created when we processed the CREATE TABLE. All we have - ** to do here is record the root page number for that index. - */ - Index pIndex; - pIndex = sqlite3FindIndex( db, argv[0], db.aDb[iDb].zName ); - if ( pIndex == null ) - { - /* This can occur if there exists an index on a TEMP table which - ** has the same name as another index on a permanent index. Since - ** the permanent table is hidden by the TEMP table, we can also - ** safely ignore the index on the permanent table. - */ - /* Do Nothing */ - ; - } - else if ( sqlite3GetInt32( argv[1], ref pIndex.tnum ) == false ) - { - corruptSchema( pData, argv[0], "invalid rootpage" ); + return 0; } - } - return 0; - } - - /* - ** Attempt to read the database schema and initialize internal - ** data structures for a single database file. The index of the - ** database file is given by iDb. iDb==0 is used for the main - ** database. iDb==1 should never be used. iDb>=2 is used for - ** auxiliary databases. Return one of the SQLITE_ error codes to - ** indicate success or failure. - */ - static int sqlite3InitOne( sqlite3 db, int iDb, ref string pzErrMsg ) - { - int rc; - int i; - int size; - Table pTab; - Db pDb; - string[] azArg = new string[4]; - u32[] meta = new u32[5]; - InitData initData = new InitData(); - string zMasterSchema; - string zMasterName; - int openedTransaction = 0; - /* - ** The master database table has a structure like this - */ - string master_schema = - "CREATE TABLE sqlite_master(\n" + - " type text,\n" + - " name text,\n" + - " tbl_name text,\n" + - " rootpage integer,\n" + - " sql text\n" + - ")" - ; + /* + ** Attempt to read the database schema and initialize internal + ** data structures for a single database file. The index of the + ** database file is given by iDb. iDb==0 is used for the main + ** database. iDb==1 should never be used. iDb>=2 is used for + ** auxiliary databases. Return one of the SQLITE_ error codes to + ** indicate success or failure. + */ + static int sqlite3InitOne(sqlite3 db, int iDb, ref string pzErrMsg) { + int rc; + int i; + int size; + Table pTab; + Db pDb; + string[] azArg = new string[4]; + u32[] meta = new u32[5]; + InitData initData = new InitData(); + string zMasterSchema; + string zMasterName; + int openedTransaction = 0; + + /* + ** The master database table has a structure like this + */ + string master_schema = + "CREATE TABLE sqlite_master(\n" + + " type text,\n" + + " name text,\n" + + " tbl_name text,\n" + + " rootpage integer,\n" + + " sql text\n" + + ")" + ; #if !SQLITE_OMIT_TEMPDB - string temp_master_schema = - "CREATE TEMP TABLE sqlite_temp_master(\n" + - " type text,\n" + - " name text,\n" + - " tbl_name text,\n" + - " rootpage integer,\n" + - " sql text\n" + - ")" - ; + string temp_master_schema = + "CREATE TEMP TABLE sqlite_temp_master(\n" + + " type text,\n" + + " name text,\n" + + " tbl_name text,\n" + + " rootpage integer,\n" + + " sql text\n" + + ")" + ; #else //#define temp_master_schema 0 #endif - Debug.Assert( iDb >= 0 && iDb < db.nDb ); - Debug.Assert( db.aDb[iDb].pSchema != null ); - Debug.Assert( sqlite3_mutex_held( db.mutex ) ); - Debug.Assert( iDb == 1 || sqlite3BtreeHoldsMutex( db.aDb[iDb].pBt ) ); - - /* zMasterSchema and zInitScript are set to point at the master schema - ** and initialisation script appropriate for the database being - ** initialised. zMasterName is the name of the master table. - */ - if ( OMIT_TEMPDB == 0 && iDb == 1 ) - { - zMasterSchema = temp_master_schema; - } - else - { - zMasterSchema = master_schema; - } - zMasterName = SCHEMA_TABLE( iDb ); - - /* Construct the schema tables. */ - azArg[0] = zMasterName; - azArg[1] = "1"; - azArg[2] = zMasterSchema; - azArg[3] = ""; - initData.db = db; - initData.iDb = iDb; - initData.rc = SQLITE_OK; - initData.pzErrMsg = pzErrMsg; - sqlite3InitCallback( initData, 3, azArg, null ); - if ( initData.rc != 0 ) - { - rc = initData.rc; - goto error_out; - } - pTab = sqlite3FindTable( db, zMasterName, db.aDb[iDb].zName ); - if ( ALWAYS( pTab ) ) - { - pTab.tabFlags |= TF_Readonly; - } + Debug.Assert(iDb >= 0 && iDb < db.nDb); + Debug.Assert(db.aDb[iDb].pSchema != null); + Debug.Assert(sqlite3_mutex_held(db.mutex)); + Debug.Assert(iDb == 1 || sqlite3BtreeHoldsMutex(db.aDb[iDb].pBt)); + + /* zMasterSchema and zInitScript are set to point at the master schema + ** and initialisation script appropriate for the database being + ** initialised. zMasterName is the name of the master table. + */ + if (OMIT_TEMPDB == 0 && iDb == 1) { + zMasterSchema = temp_master_schema; + } else { + zMasterSchema = master_schema; + } + zMasterName = SCHEMA_TABLE(iDb); + + /* Construct the schema tables. */ + azArg[0] = zMasterName; + azArg[1] = "1"; + azArg[2] = zMasterSchema; + azArg[3] = ""; + initData.db = db; + initData.iDb = iDb; + initData.rc = SQLITE_OK; + initData.pzErrMsg = pzErrMsg; + sqlite3InitCallback(initData, 3, azArg, null); + if (initData.rc != 0) { + rc = initData.rc; + goto error_out; + } + pTab = sqlite3FindTable(db, zMasterName, db.aDb[iDb].zName); + if (ALWAYS(pTab)) { + pTab.tabFlags |= TF_Readonly; + } - /* Create a cursor to hold the database open - */ - pDb = db.aDb[iDb]; - if ( pDb.pBt == null ) - { - if ( OMIT_TEMPDB == 0 && ALWAYS( iDb == 1 ) ) - { - DbSetProperty( db, 1, DB_SchemaLoaded ); - } - return SQLITE_OK; - } + /* Create a cursor to hold the database open + */ + pDb = db.aDb[iDb]; + if (pDb.pBt == null) { + if (OMIT_TEMPDB == 0 && ALWAYS(iDb == 1)) { + DbSetProperty(db, 1, DB_SchemaLoaded); + } + return SQLITE_OK; + } - /* If there is not already a read-only (or read-write) transaction opened - ** on the b-tree database, open one now. If a transaction is opened, it - ** will be closed before this function returns. */ - sqlite3BtreeEnter( pDb.pBt ); - if ( !sqlite3BtreeIsInReadTrans( pDb.pBt ) ) - { - rc = sqlite3BtreeBeginTrans( pDb.pBt, 0 ); - if ( rc != SQLITE_OK ) - { + /* If there is not already a read-only (or read-write) transaction opened + ** on the b-tree database, open one now. If a transaction is opened, it + ** will be closed before this function returns. */ + sqlite3BtreeEnter(pDb.pBt); + if (!sqlite3BtreeIsInReadTrans(pDb.pBt)) { + rc = sqlite3BtreeBeginTrans(pDb.pBt, 0); + if (rc != SQLITE_OK) { #if SQLITE_OMIT_WAL - if (pDb.pBt.pBt.pSchema.file_format == 2) - sqlite3SetString( ref pzErrMsg, db, "%s (wal format detected)", sqlite3ErrStr( rc ) ); - else - sqlite3SetString( ref pzErrMsg, db, "%s", sqlite3ErrStr( rc ) ); + if (pDb.pBt.pBt.pSchema.file_format == 2) + sqlite3SetString(ref pzErrMsg, db, "%s (wal format detected)", sqlite3ErrStr(rc)); + else + sqlite3SetString(ref pzErrMsg, db, "%s", sqlite3ErrStr(rc)); #else sqlite3SetString( ref pzErrMsg, db, "%s", sqlite3ErrStr( rc ) ); #endif - goto initone_error_out; - } - openedTransaction = 1; - } - - /* Get the database meta information. - ** - ** Meta values are as follows: - ** meta[0] Schema cookie. Changes with each schema change. - ** meta[1] File format of schema layer. - ** meta[2] Size of the page cache. - ** meta[3] Largest rootpage (auto/incr_vacuum mode) - ** meta[4] Db text encoding. 1:UTF-8 2:UTF-16LE 3:UTF-16BE - ** meta[5] User version - ** meta[6] Incremental vacuum mode - ** meta[7] unused - ** meta[8] unused - ** meta[9] unused - ** - ** Note: The #defined SQLITE_UTF* symbols in sqliteInt.h correspond to - ** the possible values of meta[BTREE_TEXT_ENCODING-1]. - */ - for ( i = 0; i < ArraySize( meta ); i++ ) - { - sqlite3BtreeGetMeta( pDb.pBt, i + 1, ref meta[i] ); - } - pDb.pSchema.schema_cookie = (int)meta[BTREE_SCHEMA_VERSION - 1]; - - /* If opening a non-empty database, check the text encoding. For the - ** main database, set sqlite3.enc to the encoding of the main database. - ** For an attached db, it is an error if the encoding is not the same - ** as sqlite3.enc. - */ - if ( meta[BTREE_TEXT_ENCODING - 1] != 0 ) - { /* text encoding */ - if ( iDb == 0 ) - { - u8 encoding; - /* If opening the main database, set ENC(db). */ - encoding = (u8)( meta[BTREE_TEXT_ENCODING - 1] & 3 ); - if ( encoding == 0 ) - encoding = SQLITE_UTF8; - db.aDb[0].pSchema.enc = encoding; //ENC( db ) = encoding; - db.pDfltColl = sqlite3FindCollSeq( db, SQLITE_UTF8, "BINARY", 0 ); - } - else - { - /* If opening an attached database, the encoding much match ENC(db) */ - if ( meta[BTREE_TEXT_ENCODING - 1] != ENC( db ) ) - { - sqlite3SetString( ref pzErrMsg, db, "attached databases must use the same" + - " text encoding as main database" ); - rc = SQLITE_ERROR; - goto initone_error_out; - } - } - } - else - { - DbSetProperty( db, iDb, DB_Empty ); - } - pDb.pSchema.enc = ENC( db ); + goto initone_error_out; + } + openedTransaction = 1; + } - if ( pDb.pSchema.cache_size == 0 ) - { - size = sqlite3AbsInt32((int)meta[BTREE_DEFAULT_CACHE_SIZE - 1]); - if ( size == 0 ) - { - size = SQLITE_DEFAULT_CACHE_SIZE; - } - pDb.pSchema.cache_size = size; - sqlite3BtreeSetCacheSize( pDb.pBt, pDb.pSchema.cache_size ); - } + /* Get the database meta information. + ** + ** Meta values are as follows: + ** meta[0] Schema cookie. Changes with each schema change. + ** meta[1] File format of schema layer. + ** meta[2] Size of the page cache. + ** meta[3] Largest rootpage (auto/incr_vacuum mode) + ** meta[4] Db text encoding. 1:UTF-8 2:UTF-16LE 3:UTF-16BE + ** meta[5] User version + ** meta[6] Incremental vacuum mode + ** meta[7] unused + ** meta[8] unused + ** meta[9] unused + ** + ** Note: The #defined SQLITE_UTF* symbols in sqliteInt.h correspond to + ** the possible values of meta[BTREE_TEXT_ENCODING-1]. + */ + for (i = 0; i < ArraySize(meta); i++) { + sqlite3BtreeGetMeta(pDb.pBt, i + 1, ref meta[i]); + } + pDb.pSchema.schema_cookie = (int)meta[BTREE_SCHEMA_VERSION - 1]; + + /* If opening a non-empty database, check the text encoding. For the + ** main database, set sqlite3.enc to the encoding of the main database. + ** For an attached db, it is an error if the encoding is not the same + ** as sqlite3.enc. + */ + if (meta[BTREE_TEXT_ENCODING - 1] != 0) { /* text encoding */ + if (iDb == 0) { + u8 encoding; + /* If opening the main database, set ENC(db). */ + encoding = (u8)(meta[BTREE_TEXT_ENCODING - 1] & 3); + if (encoding == 0) + encoding = SQLITE_UTF8; + db.aDb[0].pSchema.enc = encoding; //ENC( db ) = encoding; + db.pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 0); + } else { + /* If opening an attached database, the encoding much match ENC(db) */ + if (meta[BTREE_TEXT_ENCODING - 1] != ENC(db)) { + sqlite3SetString(ref pzErrMsg, db, "attached databases must use the same" + + " text encoding as main database"); + rc = SQLITE_ERROR; + goto initone_error_out; + } + } + } else { + DbSetProperty(db, iDb, DB_Empty); + } + pDb.pSchema.enc = ENC(db); + + if (pDb.pSchema.cache_size == 0) { + size = sqlite3AbsInt32((int)meta[BTREE_DEFAULT_CACHE_SIZE - 1]); + if (size == 0) { + size = SQLITE_DEFAULT_CACHE_SIZE; + } + pDb.pSchema.cache_size = size; + sqlite3BtreeSetCacheSize(pDb.pBt, pDb.pSchema.cache_size); + } - /* - ** file_format==1 Version 3.0.0. - ** file_format==2 Version 3.1.3. // ALTER TABLE ADD COLUMN - ** file_format==3 Version 3.1.4. // ditto but with non-NULL defaults - ** file_format==4 Version 3.3.0. // DESC indices. Boolean constants - */ - pDb.pSchema.file_format = (u8)meta[BTREE_FILE_FORMAT - 1]; - if ( pDb.pSchema.file_format == 0 ) - { - pDb.pSchema.file_format = 1; - } - if ( pDb.pSchema.file_format > SQLITE_MAX_FILE_FORMAT ) - { - sqlite3SetString( ref pzErrMsg, db, "unsupported file format" ); - rc = SQLITE_ERROR; - goto initone_error_out; - } + /* + ** file_format==1 Version 3.0.0. + ** file_format==2 Version 3.1.3. // ALTER TABLE ADD COLUMN + ** file_format==3 Version 3.1.4. // ditto but with non-NULL defaults + ** file_format==4 Version 3.3.0. // DESC indices. Boolean constants + */ + pDb.pSchema.file_format = (u8)meta[BTREE_FILE_FORMAT - 1]; + if (pDb.pSchema.file_format == 0) { + pDb.pSchema.file_format = 1; + } + if (pDb.pSchema.file_format > SQLITE_MAX_FILE_FORMAT) { + sqlite3SetString(ref pzErrMsg, db, "unsupported file format"); + rc = SQLITE_ERROR; + goto initone_error_out; + } - /* Ticket #2804: When we open a database in the newer file format, - ** clear the legacy_file_format pragma flag so that a VACUUM will - ** not downgrade the database and thus invalidate any descending - ** indices that the user might have created. - */ - if ( iDb == 0 && meta[BTREE_FILE_FORMAT - 1] >= 4 ) - { - db.flags &= ~SQLITE_LegacyFileFmt; - } + /* Ticket #2804: When we open a database in the newer file format, + ** clear the legacy_file_format pragma flag so that a VACUUM will + ** not downgrade the database and thus invalidate any descending + ** indices that the user might have created. + */ + if (iDb == 0 && meta[BTREE_FILE_FORMAT - 1] >= 4) { + db.flags &= ~SQLITE_LegacyFileFmt; + } - /* Read the schema information out of the schema tables - */ - Debug.Assert( db.init.busy != 0 ); - { - string zSql; - zSql = sqlite3MPrintf( db, - "SELECT name, rootpage, sql FROM '%q'.%s ORDER BY rowid", - db.aDb[iDb].zName, zMasterName ); + /* Read the schema information out of the schema tables + */ + Debug.Assert(db.init.busy != 0); + { + string zSql; + zSql = sqlite3MPrintf(db, + "SELECT name, rootpage, sql FROM '%q'.%s ORDER BY rowid", + db.aDb[iDb].zName, zMasterName); #if !SQLITE_OMIT_AUTHORIZATION { int (*xAuth)(void*,int,const char*,const char*,const char*,const char*); xAuth = db.xAuth; db.xAuth = 0; #endif - rc = sqlite3_exec( db, zSql, (dxCallback)sqlite3InitCallback, initData, 0 ); - pzErrMsg = initData.pzErrMsg; + rc = sqlite3_exec(db, zSql, (dxCallback)sqlite3InitCallback, initData, 0); + pzErrMsg = initData.pzErrMsg; #if !SQLITE_OMIT_AUTHORIZATION db.xAuth = xAuth; } #endif - if ( rc == SQLITE_OK ) - rc = initData.rc; - sqlite3DbFree( db, ref zSql ); + if (rc == SQLITE_OK) + rc = initData.rc; + sqlite3DbFree(db, ref zSql); #if !SQLITE_OMIT_ANALYZE - if ( rc == SQLITE_OK ) - { - sqlite3AnalysisLoad( db, iDb ); - } + if (rc == SQLITE_OK) { + sqlite3AnalysisLoad(db, iDb); + } #endif - } - //if ( db.mallocFailed != 0 ) - //{ - // rc = SQLITE_NOMEM; - // sqlite3ResetInternalSchema( db, -1 ); - //} - if ( rc == SQLITE_OK || ( db.flags & SQLITE_RecoveryMode ) != 0 ) - { - /* Black magic: If the SQLITE_RecoveryMode flag is set, then consider - ** the schema loaded, even if errors occurred. In this situation the - ** current sqlite3_prepare() operation will fail, but the following one - ** will attempt to compile the supplied statement against whatever subset - ** of the schema was loaded before the error occurred. The primary - ** purpose of this is to allow access to the sqlite_master table - ** even when its contents have been corrupted. + } + //if ( db.mallocFailed != 0 ) + //{ + // rc = SQLITE_NOMEM; + // sqlite3ResetInternalSchema( db, -1 ); + //} + if (rc == SQLITE_OK || (db.flags & SQLITE_RecoveryMode) != 0) { + /* Black magic: If the SQLITE_RecoveryMode flag is set, then consider + ** the schema loaded, even if errors occurred. In this situation the + ** current sqlite3_prepare() operation will fail, but the following one + ** will attempt to compile the supplied statement against whatever subset + ** of the schema was loaded before the error occurred. The primary + ** purpose of this is to allow access to the sqlite_master table + ** even when its contents have been corrupted. + */ + DbSetProperty(db, iDb, DB_SchemaLoaded); + rc = SQLITE_OK; + } + /* Jump here for an error that occurs after successfully allocating + ** curMain and calling sqlite3BtreeEnter(). For an error that occurs + ** before that point, jump to error_out. */ - DbSetProperty( db, iDb, DB_SchemaLoaded ); - rc = SQLITE_OK; - } -/* Jump here for an error that occurs after successfully allocating -** curMain and calling sqlite3BtreeEnter(). For an error that occurs -** before that point, jump to error_out. -*/ -initone_error_out: - if ( openedTransaction != 0 ) - { - sqlite3BtreeCommit( pDb.pBt ); - } - sqlite3BtreeLeave( pDb.pBt ); - -error_out: - if ( rc == SQLITE_NOMEM || rc == SQLITE_IOERR_NOMEM ) - { - // db.mallocFailed = 1; - } - return rc; - } - - /* - ** Initialize all database files - the main database file, the file - ** used to store temporary tables, and any additional database files - ** created using ATTACH statements. Return a success code. If an - ** error occurs, write an error message into pzErrMsg. - ** - ** After a database is initialized, the DB_SchemaLoaded bit is set - ** bit is set in the flags field of the Db structure. If the database - ** file was of zero-length, then the DB_Empty flag is also set. - */ - static int sqlite3Init( sqlite3 db, ref string pzErrMsg ) - { - int i, rc; - bool commit_internal = !( ( db.flags & SQLITE_InternChanges ) != 0 ); + initone_error_out: + if (openedTransaction != 0) { + sqlite3BtreeCommit(pDb.pBt); + } + sqlite3BtreeLeave(pDb.pBt); - Debug.Assert( sqlite3_mutex_held( db.mutex ) ); - rc = SQLITE_OK; - db.init.busy = 1; - for ( i = 0; rc == SQLITE_OK && i < db.nDb; i++ ) - { - if ( DbHasProperty( db, i, DB_SchemaLoaded ) || i == 1 ) - continue; - rc = sqlite3InitOne( db, i, ref pzErrMsg ); - if ( rc != 0 ) - { - sqlite3ResetInternalSchema( db, i ); + error_out: + if (rc == SQLITE_NOMEM || rc == SQLITE_IOERR_NOMEM) { + // db.mallocFailed = 1; + } + return rc; } - } - /* Once all the other databases have been initialised, load the schema - ** for the TEMP database. This is loaded last, as the TEMP database - ** schema may contain references to objects in other databases. - */ + /* + ** Initialize all database files - the main database file, the file + ** used to store temporary tables, and any additional database files + ** created using ATTACH statements. Return a success code. If an + ** error occurs, write an error message into pzErrMsg. + ** + ** After a database is initialized, the DB_SchemaLoaded bit is set + ** bit is set in the flags field of the Db structure. If the database + ** file was of zero-length, then the DB_Empty flag is also set. + */ + static int sqlite3Init(sqlite3 db, ref string pzErrMsg) { + int i, rc; + bool commit_internal = !((db.flags & SQLITE_InternChanges) != 0); + + Debug.Assert(sqlite3_mutex_held(db.mutex)); + rc = SQLITE_OK; + db.init.busy = 1; + for (i = 0; rc == SQLITE_OK && i < db.nDb; i++) { + if (DbHasProperty(db, i, DB_SchemaLoaded) || i == 1) + continue; + rc = sqlite3InitOne(db, i, ref pzErrMsg); + if (rc != 0) { + sqlite3ResetInternalSchema(db, i); + } + } + + /* Once all the other databases have been initialised, load the schema + ** for the TEMP database. This is loaded last, as the TEMP database + ** schema may contain references to objects in other databases. + */ #if !SQLITE_OMIT_TEMPDB - if ( rc == SQLITE_OK && ALWAYS( db.nDb > 1 ) - && !DbHasProperty( db, 1, DB_SchemaLoaded ) ) - { - rc = sqlite3InitOne( db, 1, ref pzErrMsg ); - if ( rc != 0 ) - { - sqlite3ResetInternalSchema( db, 1 ); - } - } + if (rc == SQLITE_OK && ALWAYS(db.nDb > 1) + && !DbHasProperty(db, 1, DB_SchemaLoaded)) { + rc = sqlite3InitOne(db, 1, ref pzErrMsg); + if (rc != 0) { + sqlite3ResetInternalSchema(db, 1); + } + } #endif - db.init.busy = 0; - if ( rc == SQLITE_OK && commit_internal ) - { - sqlite3CommitInternalChanges( db ); - } - - return rc; - } - - /* - ** This routine is a no-op if the database schema is already initialised. - ** Otherwise, the schema is loaded. An error code is returned. - */ - static int sqlite3ReadSchema( Parse pParse ) - { - int rc = SQLITE_OK; - sqlite3 db = pParse.db; - Debug.Assert( sqlite3_mutex_held( db.mutex ) ); - if ( 0 == db.init.busy ) - { - rc = sqlite3Init( db, ref pParse.zErrMsg ); - } - if ( rc != SQLITE_OK ) - { - pParse.rc = rc; - pParse.nErr++; - } - return rc; - } - - - /* - ** Check schema cookies in all databases. If any cookie is out - ** of date set pParse->rc to SQLITE_SCHEMA. If all schema cookies - ** make no changes to pParse->rc. - */ - static void schemaIsValid( Parse pParse ) - { - sqlite3 db = pParse.db; - int iDb; - int rc; - u32 cookie = 0; - - Debug.Assert( pParse.checkSchema != 0 ); - Debug.Assert( sqlite3_mutex_held( db.mutex ) ); - for ( iDb = 0; iDb < db.nDb; iDb++ ) - { - int openedTransaction = 0; /* True if a transaction is opened */ - Btree pBt = db.aDb[iDb].pBt; /* Btree database to read cookie from */ - if ( pBt == null ) - continue; - - /* If there is not already a read-only (or read-write) transaction opened - ** on the b-tree database, open one now. If a transaction is opened, it - ** will be closed immediately after reading the meta-value. */ - if ( !sqlite3BtreeIsInReadTrans( pBt ) ) - { - rc = sqlite3BtreeBeginTrans( pBt, 0 ); - //if ( rc == SQLITE_NOMEM || rc == SQLITE_IOERR_NOMEM ) - //{ - // db.mallocFailed = 1; - //} - if ( rc != SQLITE_OK ) - return; - openedTransaction = 1; - } + db.init.busy = 0; + if (rc == SQLITE_OK && commit_internal) { + sqlite3CommitInternalChanges(db); + } - /* Read the schema cookie from the database. If it does not match the - ** value stored as part of the in-memory schema representation, - ** set Parse.rc to SQLITE_SCHEMA. */ - sqlite3BtreeGetMeta( pBt, BTREE_SCHEMA_VERSION, ref cookie ); - Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); - if ( cookie != db.aDb[iDb].pSchema.schema_cookie ) - { - sqlite3ResetInternalSchema( db, iDb ); - pParse.rc = SQLITE_SCHEMA; + return rc; } - /* Close the transaction, if one was opened. */ - if ( openedTransaction != 0 ) - { - sqlite3BtreeCommit( pBt ); + /* + ** This routine is a no-op if the database schema is already initialised. + ** Otherwise, the schema is loaded. An error code is returned. + */ + static int sqlite3ReadSchema(Parse pParse) { + int rc = SQLITE_OK; + sqlite3 db = pParse.db; + Debug.Assert(sqlite3_mutex_held(db.mutex)); + if (0 == db.init.busy) { + rc = sqlite3Init(db, ref pParse.zErrMsg); + } + if (rc != SQLITE_OK) { + pParse.rc = rc; + pParse.nErr++; + } + return rc; } - } - } - /* - ** Convert a schema pointer into the iDb index that indicates - ** which database file in db.aDb[] the schema refers to. - ** - ** If the same database is attached more than once, the first - ** attached database is returned. - */ - static int sqlite3SchemaToIndex( sqlite3 db, Schema pSchema ) - { - int i = -1000000; - /* If pSchema is NULL, then return -1000000. This happens when code in - ** expr.c is trying to resolve a reference to a transient table (i.e. one - ** created by a sub-select). In this case the return value of this - ** function should never be used. - ** - ** We return -1000000 instead of the more usual -1 simply because using - ** -1000000 as the incorrect index into db->aDb[] is much - ** more likely to cause a segfault than -1 (of course there are assert() - ** statements too, but it never hurts to play the odds). - */ - Debug.Assert( sqlite3_mutex_held( db.mutex ) ); - if ( pSchema != null ) - { - for ( i = 0; ALWAYS( i < db.nDb ); i++ ) - { - if ( db.aDb[i].pSchema == pSchema ) - { - break; - } + /* + ** Check schema cookies in all databases. If any cookie is out + ** of date set pParse->rc to SQLITE_SCHEMA. If all schema cookies + ** make no changes to pParse->rc. + */ + static void schemaIsValid(Parse pParse) { + sqlite3 db = pParse.db; + int iDb; + int rc; + u32 cookie = 0; + + Debug.Assert(pParse.checkSchema != 0); + Debug.Assert(sqlite3_mutex_held(db.mutex)); + for (iDb = 0; iDb < db.nDb; iDb++) { + int openedTransaction = 0; /* True if a transaction is opened */ + Btree pBt = db.aDb[iDb].pBt; /* Btree database to read cookie from */ + if (pBt == null) + continue; + + /* If there is not already a read-only (or read-write) transaction opened + ** on the b-tree database, open one now. If a transaction is opened, it + ** will be closed immediately after reading the meta-value. */ + if (!sqlite3BtreeIsInReadTrans(pBt)) { + rc = sqlite3BtreeBeginTrans(pBt, 0); + //if ( rc == SQLITE_NOMEM || rc == SQLITE_IOERR_NOMEM ) + //{ + // db.mallocFailed = 1; + //} + if (rc != SQLITE_OK) + return; + openedTransaction = 1; + } + + /* Read the schema cookie from the database. If it does not match the + ** value stored as part of the in-memory schema representation, + ** set Parse.rc to SQLITE_SCHEMA. */ + sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, ref cookie); + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + if (cookie != db.aDb[iDb].pSchema.schema_cookie) { + sqlite3ResetInternalSchema(db, iDb); + pParse.rc = SQLITE_SCHEMA; + } + + /* Close the transaction, if one was opened. */ + if (openedTransaction != 0) { + sqlite3BtreeCommit(pBt); + } + } } - Debug.Assert( i >= 0 && i < db.nDb ); - } - return i; - } - - /* - ** Compile the UTF-8 encoded SQL statement zSql into a statement handle. - */ - static int sqlite3Prepare( - sqlite3 db, /* Database handle. */ - string zSql, /* UTF-8 encoded SQL statement. */ - int nBytes, /* Length of zSql in bytes. */ - int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */ - Vdbe pReprepare, /* VM being reprepared */ - ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ - ref string pzTail /* OUT: End of parsed string */ - ) - { - Parse pParse; /* Parsing context */ - string zErrMsg = ""; /* Error message */ - int rc = SQLITE_OK; /* Result code */ - int i; /* Loop counter */ - - ppStmt = null; - pzTail = null; - - /* Allocate the parsing context */ - pParse = new Parse();//sqlite3StackAllocZero(db, sizeof(*pParse)); - //if ( pParse == null ) - //{ - // rc = SQLITE_NOMEM; - // goto end_prepare; - //} - pParse.pReprepare = pReprepare; - pParse.sLastToken.z = ""; - // assert( ppStmt && *ppStmt==0 ); - //Debug.Assert( 0 == db.mallocFailed ); - Debug.Assert( sqlite3_mutex_held( db.mutex ) ); - - /* Check to verify that it is possible to get a read lock on all - ** database schemas. The inability to get a read lock indicates that - ** some other database connection is holding a write-lock, which in - ** turn means that the other connection has made uncommitted changes - ** to the schema. - ** - ** Were we to proceed and prepare the statement against the uncommitted - ** schema changes and if those schema changes are subsequently rolled - ** back and different changes are made in their place, then when this - ** prepared statement goes to run the schema cookie would fail to detect - ** the schema change. Disaster would follow. - ** - ** This thread is currently holding mutexes on all Btrees (because - ** of the sqlite3BtreeEnterAll() in sqlite3LockAndPrepare()) so it - ** is not possible for another thread to start a new schema change - ** while this routine is running. Hence, we do not need to hold - ** locks on the schema, we just need to make sure nobody else is - ** holding them. - ** - ** Note that setting READ_UNCOMMITTED overrides most lock detection, - ** but it does *not* override schema lock detection, so this all still - ** works even if READ_UNCOMMITTED is set. - */ - for ( i = 0; i < db.nDb; i++ ) - { - Btree pBt = db.aDb[i].pBt; - if ( pBt != null ) - { - Debug.Assert( sqlite3BtreeHoldsMutex( pBt ) ); - rc = sqlite3BtreeSchemaLocked( pBt ); - if ( rc != 0 ) - { - string zDb = db.aDb[i].zName; - sqlite3Error( db, rc, "database schema is locked: %s", zDb ); - testcase( db.flags & SQLITE_ReadUncommitted ); - goto end_prepare; - } + /* + ** Convert a schema pointer into the iDb index that indicates + ** which database file in db.aDb[] the schema refers to. + ** + ** If the same database is attached more than once, the first + ** attached database is returned. + */ + static int sqlite3SchemaToIndex(sqlite3 db, Schema pSchema) { + int i = -1000000; + + /* If pSchema is NULL, then return -1000000. This happens when code in + ** expr.c is trying to resolve a reference to a transient table (i.e. one + ** created by a sub-select). In this case the return value of this + ** function should never be used. + ** + ** We return -1000000 instead of the more usual -1 simply because using + ** -1000000 as the incorrect index into db->aDb[] is much + ** more likely to cause a segfault than -1 (of course there are assert() + ** statements too, but it never hurts to play the odds). + */ + Debug.Assert(sqlite3_mutex_held(db.mutex)); + if (pSchema != null) { + for (i = 0; ALWAYS(i < db.nDb); i++) { + if (db.aDb[i].pSchema == pSchema) { + break; + } + } + Debug.Assert(i >= 0 && i < db.nDb); + } + return i; } - } - sqlite3VtabUnlockList( db ); + /* + ** Compile the UTF-8 encoded SQL statement zSql into a statement handle. + */ + static int sqlite3Prepare( + sqlite3 db, /* Database handle. */ + string zSql, /* UTF-8 encoded SQL statement. */ + int nBytes, /* Length of zSql in bytes. */ + int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */ + Vdbe pReprepare, /* VM being reprepared */ + ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ + ref string pzTail /* OUT: End of parsed string */ + ) { + Parse pParse; /* Parsing context */ + string zErrMsg = ""; /* Error message */ + int rc = SQLITE_OK; /* Result code */ + int i; /* Loop counter */ + + ppStmt = null; + pzTail = null; + + /* Allocate the parsing context */ + pParse = new Parse();//sqlite3StackAllocZero(db, sizeof(*pParse)); + //if ( pParse == null ) + //{ + // rc = SQLITE_NOMEM; + // goto end_prepare; + //} + pParse.pReprepare = pReprepare; + pParse.sLastToken.z = ""; + + // assert( ppStmt && *ppStmt==0 ); + //Debug.Assert( 0 == db.mallocFailed ); + Debug.Assert(sqlite3_mutex_held(db.mutex)); + + /* Check to verify that it is possible to get a read lock on all + ** database schemas. The inability to get a read lock indicates that + ** some other database connection is holding a write-lock, which in + ** turn means that the other connection has made uncommitted changes + ** to the schema. + ** + ** Were we to proceed and prepare the statement against the uncommitted + ** schema changes and if those schema changes are subsequently rolled + ** back and different changes are made in their place, then when this + ** prepared statement goes to run the schema cookie would fail to detect + ** the schema change. Disaster would follow. + ** + ** This thread is currently holding mutexes on all Btrees (because + ** of the sqlite3BtreeEnterAll() in sqlite3LockAndPrepare()) so it + ** is not possible for another thread to start a new schema change + ** while this routine is running. Hence, we do not need to hold + ** locks on the schema, we just need to make sure nobody else is + ** holding them. + ** + ** Note that setting READ_UNCOMMITTED overrides most lock detection, + ** but it does *not* override schema lock detection, so this all still + ** works even if READ_UNCOMMITTED is set. + */ + for (i = 0; i < db.nDb; i++) { + Btree pBt = db.aDb[i].pBt; + if (pBt != null) { + Debug.Assert(sqlite3BtreeHoldsMutex(pBt)); + rc = sqlite3BtreeSchemaLocked(pBt); + if (rc != 0) { + string zDb = db.aDb[i].zName; + sqlite3Error(db, rc, "database schema is locked: %s", zDb); + testcase(db.flags & SQLITE_ReadUncommitted); + goto end_prepare; + } + } + } - pParse.db = db; - pParse.nQueryLoop = (double)1; - if ( nBytes >= 0 && ( nBytes == 0 || zSql[nBytes - 1] != 0 ) ) - { - string zSqlCopy; - int mxLen = db.aLimit[SQLITE_LIMIT_SQL_LENGTH]; - testcase( nBytes == mxLen ); - testcase( nBytes == mxLen + 1 ); - if ( nBytes > mxLen ) - { - sqlite3Error( db, SQLITE_TOOBIG, "statement too long" ); - rc = sqlite3ApiExit( db, SQLITE_TOOBIG ); - goto end_prepare; - } - zSqlCopy = zSql.Substring( 0, nBytes );// sqlite3DbStrNDup(db, zSql, nBytes); - if ( zSqlCopy != null ) - { - sqlite3RunParser( pParse, zSqlCopy, ref zErrMsg ); - sqlite3DbFree( db, ref zSqlCopy ); - //pParse->zTail = &zSql[pParse->zTail-zSqlCopy]; - } - else - { - //pParse->zTail = &zSql[nBytes]; - } - } - else - { - sqlite3RunParser( pParse, zSql, ref zErrMsg ); - } - Debug.Assert( 1 == (int)pParse.nQueryLoop ); + sqlite3VtabUnlockList(db); + + pParse.db = db; + pParse.nQueryLoop = (double)1; + if (nBytes >= 0 && (nBytes == 0 || zSql[nBytes - 1] != 0)) { + string zSqlCopy; + int mxLen = db.aLimit[SQLITE_LIMIT_SQL_LENGTH]; + testcase(nBytes == mxLen); + testcase(nBytes == mxLen + 1); + if (nBytes > mxLen) { + sqlite3Error(db, SQLITE_TOOBIG, "statement too long"); + rc = sqlite3ApiExit(db, SQLITE_TOOBIG); + goto end_prepare; + } + zSqlCopy = zSql.Substring(0, nBytes);// sqlite3DbStrNDup(db, zSql, nBytes); + if (zSqlCopy != null) { + sqlite3RunParser(pParse, zSqlCopy, ref zErrMsg); + sqlite3DbFree(db, ref zSqlCopy); + //pParse->zTail = &zSql[pParse->zTail-zSqlCopy]; + } else { + //pParse->zTail = &zSql[nBytes]; + } + } else { + sqlite3RunParser(pParse, zSql, ref zErrMsg); + } + Debug.Assert(1 == (int)pParse.nQueryLoop); - //if ( db.mallocFailed != 0 ) - //{ - // pParse.rc = SQLITE_NOMEM; - //} - if ( pParse.rc == SQLITE_DONE ) - pParse.rc = SQLITE_OK; - if ( pParse.checkSchema != 0 ) - { - schemaIsValid( pParse ); - } - //if ( db.mallocFailed != 0 ) - //{ - // pParse.rc = SQLITE_NOMEM; - //} - //if (pzTail != null) - { - pzTail = pParse.zTail == null ? "" : pParse.zTail.ToString(); - } - rc = pParse.rc; + //if ( db.mallocFailed != 0 ) + //{ + // pParse.rc = SQLITE_NOMEM; + //} + if (pParse.rc == SQLITE_DONE) + pParse.rc = SQLITE_OK; + if (pParse.checkSchema != 0) { + schemaIsValid(pParse); + } + //if ( db.mallocFailed != 0 ) + //{ + // pParse.rc = SQLITE_NOMEM; + //} + //if (pzTail != null) + { + pzTail = pParse.zTail == null ? "" : pParse.zTail.ToString(); + } + rc = pParse.rc; #if !SQLITE_OMIT_EXPLAIN - if ( rc == SQLITE_OK && pParse.pVdbe != null && pParse.explain != 0 ) - { - string[] azColName = new string[] { + if (rc == SQLITE_OK && pParse.pVdbe != null && pParse.explain != 0) { + string[] azColName = new string[] { "addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment", "selectid", "order", "from", "detail" }; - int iFirst, mx; - if ( pParse.explain == 2 ) - { - sqlite3VdbeSetNumCols( pParse.pVdbe, 4 ); - iFirst = 8; - mx = 12; - } - else - { - sqlite3VdbeSetNumCols( pParse.pVdbe, 8 ); - iFirst = 0; - mx = 8; - } - for ( i = iFirst; i < mx; i++ ) - { - sqlite3VdbeSetColName( pParse.pVdbe, i - iFirst, COLNAME_NAME, - azColName[i], SQLITE_STATIC ); - } - } + int iFirst, mx; + if (pParse.explain == 2) { + sqlite3VdbeSetNumCols(pParse.pVdbe, 4); + iFirst = 8; + mx = 12; + } else { + sqlite3VdbeSetNumCols(pParse.pVdbe, 8); + iFirst = 0; + mx = 8; + } + for (i = iFirst; i < mx; i++) { + sqlite3VdbeSetColName(pParse.pVdbe, i - iFirst, COLNAME_NAME, + azColName[i], SQLITE_STATIC); + } + } #endif - Debug.Assert( db.init.busy == 0 || saveSqlFlag == 0 ); - if ( db.init.busy == 0 ) - { - Vdbe pVdbe = pParse.pVdbe; - sqlite3VdbeSetSql( pVdbe, zSql, (int)( zSql.Length - ( pParse.zTail == null ? 0 : pParse.zTail.Length ) ), saveSqlFlag ); - } - if ( pParse.pVdbe != null && ( rc != SQLITE_OK /*|| db.mallocFailed != 0 */ ) ) - { - sqlite3VdbeFinalize( ref pParse.pVdbe ); - //Debug.Assert( ppStmt == null ); - } - else - { - ppStmt = pParse.pVdbe; - } - - if ( zErrMsg != "" ) - { - sqlite3Error( db, rc, "%s", zErrMsg ); - sqlite3DbFree( db, ref zErrMsg ); - } - else - { - sqlite3Error( db, rc, 0 ); - } + Debug.Assert(db.init.busy == 0 || saveSqlFlag == 0); + if (db.init.busy == 0) { + Vdbe pVdbe = pParse.pVdbe; + sqlite3VdbeSetSql(pVdbe, zSql, (int)(zSql.Length - (pParse.zTail == null ? 0 : pParse.zTail.Length)), saveSqlFlag); + } + if (pParse.pVdbe != null && (rc != SQLITE_OK /*|| db.mallocFailed != 0 */ )) { + sqlite3VdbeFinalize(ref pParse.pVdbe); + //Debug.Assert( ppStmt == null ); + } else { + ppStmt = pParse.pVdbe; + } - /* Delete any TriggerPrg structures allocated while parsing this statement. */ - while ( pParse.pTriggerPrg != null ) - { - TriggerPrg pT = pParse.pTriggerPrg; - pParse.pTriggerPrg = pT.pNext; - sqlite3DbFree( db, ref pT ); - } + if (zErrMsg != "") { + sqlite3Error(db, rc, "%s", zErrMsg); + sqlite3DbFree(db, ref zErrMsg); + } else { + sqlite3Error(db, rc, 0); + } -end_prepare: + /* Delete any TriggerPrg structures allocated while parsing this statement. */ + while (pParse.pTriggerPrg != null) { + TriggerPrg pT = pParse.pTriggerPrg; + pParse.pTriggerPrg = pT.pNext; + sqlite3DbFree(db, ref pT); + } - //sqlite3StackFree( db, pParse ); - rc = sqlite3ApiExit( db, rc ); - Debug.Assert( ( rc & db.errMask ) == rc ); - return rc; - } + end_prepare: - //C# Version w/o End of Parsed String - static int sqlite3LockAndPrepare( - sqlite3 db, /* Database handle. */ - string zSql, /* UTF-8 encoded SQL statement. */ - int nBytes, /* Length of zSql in bytes. */ - int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */ - Vdbe pOld, /* VM being reprepared */ - ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ - int dummy /* OUT: End of parsed string */ - ) - { - string sOut = null; - return sqlite3LockAndPrepare( db, zSql, nBytes, saveSqlFlag, pOld, ref ppStmt, ref sOut ); - } + //sqlite3StackFree( db, pParse ); + rc = sqlite3ApiExit(db, rc); + Debug.Assert((rc & db.errMask) == rc); + return rc; + } - static int sqlite3LockAndPrepare( - sqlite3 db, /* Database handle. */ - string zSql, /* UTF-8 encoded SQL statement. */ - int nBytes, /* Length of zSql in bytes. */ - int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */ - Vdbe pOld, /* VM being reprepared */ - ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ - ref string pzTail /* OUT: End of parsed string */ - ) - { - int rc; - // assert( ppStmt!=0 ); - if ( !sqlite3SafetyCheckOk( db ) ) - { - ppStmt = null; - pzTail = null; - return SQLITE_MISUSE_BKPT(); - } - sqlite3_mutex_enter( db.mutex ); - sqlite3BtreeEnterAll( db ); - rc = sqlite3Prepare( db, zSql, nBytes, saveSqlFlag, pOld, ref ppStmt, ref pzTail ); - if ( rc == SQLITE_SCHEMA ) - { - sqlite3_finalize( ppStmt ); - rc = sqlite3Prepare( db, zSql, nBytes, saveSqlFlag, pOld, ref ppStmt, ref pzTail ); - } - sqlite3BtreeLeaveAll( db ); - sqlite3_mutex_leave( db.mutex ); - return rc; - } + //C# Version w/o End of Parsed String + static int sqlite3LockAndPrepare( + sqlite3 db, /* Database handle. */ + string zSql, /* UTF-8 encoded SQL statement. */ + int nBytes, /* Length of zSql in bytes. */ + int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */ + Vdbe pOld, /* VM being reprepared */ + ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ + int dummy /* OUT: End of parsed string */ + ) { + string sOut = null; + return sqlite3LockAndPrepare(db, zSql, nBytes, saveSqlFlag, pOld, ref ppStmt, ref sOut); + } - /* - ** Rerun the compilation of a statement after a schema change. - ** - ** If the statement is successfully recompiled, return SQLITE_OK. Otherwise, - ** if the statement cannot be recompiled because another connection has - ** locked the sqlite3_master table, return SQLITE_LOCKED. If any other error - ** occurs, return SQLITE_SCHEMA. - */ - static int sqlite3Reprepare( Vdbe p ) - { - int rc; - sqlite3_stmt pNew = new sqlite3_stmt(); - string zSql; - sqlite3 db; + static int sqlite3LockAndPrepare( + sqlite3 db, /* Database handle. */ + string zSql, /* UTF-8 encoded SQL statement. */ + int nBytes, /* Length of zSql in bytes. */ + int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */ + Vdbe pOld, /* VM being reprepared */ + ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ + ref string pzTail /* OUT: End of parsed string */ + ) { + int rc; + // assert( ppStmt!=0 ); + if (!sqlite3SafetyCheckOk(db)) { + ppStmt = null; + pzTail = null; + return SQLITE_MISUSE_BKPT(); + } + sqlite3_mutex_enter(db.mutex); + sqlite3BtreeEnterAll(db); + rc = sqlite3Prepare(db, zSql, nBytes, saveSqlFlag, pOld, ref ppStmt, ref pzTail); + if (rc == SQLITE_SCHEMA) { + sqlite3_finalize(ppStmt); + rc = sqlite3Prepare(db, zSql, nBytes, saveSqlFlag, pOld, ref ppStmt, ref pzTail); + } + sqlite3BtreeLeaveAll(db); + sqlite3_mutex_leave(db.mutex); + return rc; + } - Debug.Assert( sqlite3_mutex_held( sqlite3VdbeDb( p ).mutex ) ); - zSql = sqlite3_sql( (sqlite3_stmt)p ); - Debug.Assert( zSql != null ); /* Reprepare only called for prepare_v2() statements */ - db = sqlite3VdbeDb( p ); - Debug.Assert( sqlite3_mutex_held( db.mutex ) ); - rc = sqlite3LockAndPrepare( db, zSql, -1, 0, p, ref pNew, 0 ); - if ( rc != 0 ) - { - if ( rc == SQLITE_NOMEM ) - { - // db.mallocFailed = 1; + /* + ** Rerun the compilation of a statement after a schema change. + ** + ** If the statement is successfully recompiled, return SQLITE_OK. Otherwise, + ** if the statement cannot be recompiled because another connection has + ** locked the sqlite3_master table, return SQLITE_LOCKED. If any other error + ** occurs, return SQLITE_SCHEMA. + */ + static int sqlite3Reprepare(Vdbe p) { + int rc; + sqlite3_stmt pNew = new sqlite3_stmt(); + string zSql; + sqlite3 db; + + Debug.Assert(sqlite3_mutex_held(sqlite3VdbeDb(p).mutex)); + zSql = sqlite3_sql((sqlite3_stmt)p); + Debug.Assert(zSql != null); /* Reprepare only called for prepare_v2() statements */ + db = sqlite3VdbeDb(p); + Debug.Assert(sqlite3_mutex_held(db.mutex)); + rc = sqlite3LockAndPrepare(db, zSql, -1, 0, p, ref pNew, 0); + if (rc != 0) { + if (rc == SQLITE_NOMEM) { + // db.mallocFailed = 1; + } + Debug.Assert(pNew == null); + return rc; + } else { + Debug.Assert(pNew != null); + } + sqlite3VdbeSwap((Vdbe)pNew, p); + sqlite3TransferBindings(pNew, (sqlite3_stmt)p); + sqlite3VdbeResetStepResult((Vdbe)pNew); + sqlite3VdbeFinalize(ref pNew); + return SQLITE_OK; } - Debug.Assert( pNew == null ); - return rc; - } - else - { - Debug.Assert( pNew != null ); - } - sqlite3VdbeSwap( (Vdbe)pNew, p ); - sqlite3TransferBindings( pNew, (sqlite3_stmt)p ); - sqlite3VdbeResetStepResult( (Vdbe)pNew ); - sqlite3VdbeFinalize( ref pNew ); - return SQLITE_OK; - } - //C# Overload for ignore error out - static public int sqlite3_prepare( - sqlite3 db, /* Database handle. */ - string zSql, /* UTF-8 encoded SQL statement. */ - int nBytes, /* Length of zSql in bytes. */ - ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ - int dummy /* OUT: End of parsed string */ - ) - { - string sOut = null; - return sqlite3_prepare( db, zSql, nBytes, ref ppStmt, ref sOut ); - } - static public int sqlite3_prepare( - sqlite3 db, /* Database handle. */ - StringBuilder zSql, /* UTF-8 encoded SQL statement. */ - int nBytes, /* Length of zSql in bytes. */ - ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ - int dummy /* OUT: End of parsed string */ - ) - { - string sOut = null; - return sqlite3_prepare(db, zSql.ToString(), nBytes, ref ppStmt, ref sOut); - } - /* - ** Two versions of the official API. Legacy and new use. In the legacy - ** version, the original SQL text is not saved in the prepared statement - ** and so if a schema change occurs, SQLITE_SCHEMA is returned by - ** sqlite3_step(). In the new version, the original SQL text is retained - ** and the statement is automatically recompiled if an schema change - ** occurs. - */ - static public int sqlite3_prepare( - sqlite3 db, /* Database handle. */ - string zSql, /* UTF-8 encoded SQL statement. */ - int nBytes, /* Length of zSql in bytes. */ - ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ - ref string pzTail /* OUT: End of parsed string */ - ) - { - int rc; - rc = sqlite3LockAndPrepare( db, zSql, nBytes, 0, null, ref ppStmt, ref pzTail ); - Debug.Assert( rc == SQLITE_OK || ppStmt == null ); /* VERIFY: F13021 */ - return rc; - } + //C# Overload for ignore error out + static public int sqlite3_prepare( + sqlite3 db, /* Database handle. */ + string zSql, /* UTF-8 encoded SQL statement. */ + int nBytes, /* Length of zSql in bytes. */ + ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ + int dummy /* OUT: End of parsed string */ + ) { + string sOut = null; + return sqlite3_prepare(db, zSql, nBytes, ref ppStmt, ref sOut); + } + static public int sqlite3_prepare( + sqlite3 db, /* Database handle. */ + StringBuilder zSql, /* UTF-8 encoded SQL statement. */ + int nBytes, /* Length of zSql in bytes. */ + ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ + int dummy /* OUT: End of parsed string */ + ) { + string sOut = null; + return sqlite3_prepare(db, zSql.ToString(), nBytes, ref ppStmt, ref sOut); + } + /* + ** Two versions of the official API. Legacy and new use. In the legacy + ** version, the original SQL text is not saved in the prepared statement + ** and so if a schema change occurs, SQLITE_SCHEMA is returned by + ** sqlite3_step(). In the new version, the original SQL text is retained + ** and the statement is automatically recompiled if an schema change + ** occurs. + */ + static public int sqlite3_prepare( + sqlite3 db, /* Database handle. */ + string zSql, /* UTF-8 encoded SQL statement. */ + int nBytes, /* Length of zSql in bytes. */ + ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ + ref string pzTail /* OUT: End of parsed string */ + ) { + int rc; + rc = sqlite3LockAndPrepare(db, zSql, nBytes, 0, null, ref ppStmt, ref pzTail); + Debug.Assert(rc == SQLITE_OK || ppStmt == null); /* VERIFY: F13021 */ + return rc; + } - public static int sqlite3_prepare_v2( - sqlite3 db, /* Database handle. */ - string zSql, /* UTF-8 encoded SQL statement. */ - int nBytes, /* Length of zSql in bytes. */ - ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ - int dummy /* ( No string passed) */ - ) - { - string pzTail = null; - int rc; - rc = sqlite3LockAndPrepare( db, zSql, nBytes, 1, null, ref ppStmt, ref pzTail ); - Debug.Assert( rc == SQLITE_OK || ppStmt == null ); /* VERIFY: F13021 */ - return rc; - } + public static int sqlite3_prepare_v2( + sqlite3 db, /* Database handle. */ + string zSql, /* UTF-8 encoded SQL statement. */ + int nBytes, /* Length of zSql in bytes. */ + ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ + int dummy /* ( No string passed) */ + ) { + string pzTail = null; + int rc; + rc = sqlite3LockAndPrepare(db, zSql, nBytes, 1, null, ref ppStmt, ref pzTail); + Debug.Assert(rc == SQLITE_OK || ppStmt == null); /* VERIFY: F13021 */ + return rc; + } - public static int sqlite3_prepare_v2( - sqlite3 db, /* Database handle. */ - string zSql, /* UTF-8 encoded SQL statement. */ - int nBytes, /* Length of zSql in bytes. */ - ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ - ref string pzTail /* OUT: End of parsed string */ - ) - { - int rc; - rc = sqlite3LockAndPrepare( db, zSql, nBytes, 1, null, ref ppStmt, ref pzTail ); - Debug.Assert( rc == SQLITE_OK || ppStmt == null ); /* VERIFY: F13021 */ - return rc; - } + public static int sqlite3_prepare_v2( + sqlite3 db, /* Database handle. */ + string zSql, /* UTF-8 encoded SQL statement. */ + int nBytes, /* Length of zSql in bytes. */ + ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ + ref string pzTail /* OUT: End of parsed string */ + ) { + int rc; + rc = sqlite3LockAndPrepare(db, zSql, nBytes, 1, null, ref ppStmt, ref pzTail); + Debug.Assert(rc == SQLITE_OK || ppStmt == null); /* VERIFY: F13021 */ + return rc; + } #if !SQLITE_OMIT_UTF16 @@ -1087,5 +980,5 @@ public static int sqlite3_prepare16_v2( } #endif // * SQLITE_OMIT_UTF16 */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/printf_c.cs b/Src/IronPython.SQLite/c#sqlite/printf_c.cs index 6d4ea59eb..7600f5202 100644 --- a/Src/IronPython.SQLite/c#sqlite/printf_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/printf_c.cs @@ -1,178 +1,172 @@ using System; using System.Diagnostics; -using System.Runtime.InteropServices; using System.Text; -namespace Community.CsharpSqlite -{ - using etByte = System.Boolean; - using i64 = System.Int64; - using u64 = System.UInt64; - using LONGDOUBLE_TYPE = System.Double; - using sqlite_u3264 = System.UInt64; - using va_list = System.Object; +namespace Community.CsharpSqlite { + using etByte = System.Boolean; + using i64 = System.Int64; + using LONGDOUBLE_TYPE = System.Double; + using u64 = System.UInt64; + using va_list = System.Object; - public partial class Sqlite3 - { - /* - ** The "printf" code that follows dates from the 1980's. It is in - ** the public domain. The original comments are included here for - ** completeness. They are very out-of-date but might be useful as - ** an historical reference. Most of the "enhancements" have been backed - ** out so that the functionality is now the same as standard printf(). - ** - ************************************************************************** - ** - ** The following modules is an enhanced replacement for the "printf" subroutines - ** found in the standard C library. The following enhancements are - ** supported: - ** - ** + Additional functions. The standard set of "printf" functions - ** includes printf, fprintf, sprintf, vprintf, vfprintf, and - ** vsprintf. This module adds the following: - ** - ** * snprintf -- Works like sprintf, but has an extra argument - ** which is the size of the buffer written to. - ** - ** * mprintf -- Similar to sprintf. Writes output to memory - ** obtained from malloc. - ** - ** * xprintf -- Calls a function to dispose of output. - ** - ** * nprintf -- No output, but returns the number of characters - ** that would have been output by printf. - ** - ** * A v- version (ex: vsnprintf) of every function is also - ** supplied. - ** - ** + A few extensions to the formatting notation are supported: - ** - ** * The "=" flag (similar to "-") causes the output to be - ** be centered in the appropriately sized field. - ** - ** * The %b field outputs an integer in binary notation. - ** - ** * The %c field now accepts a precision. The character output - ** is repeated by the number of times the precision specifies. - ** - ** * The %' field works like %c, but takes as its character the - ** next character of the format string, instead of the next - ** argument. For example, printf("%.78'-") prints 78 minus - ** signs, the same as printf("%.78c",'-'). - ** - ** + When compiled using GCC on a SPARC, this version of printf is - ** faster than the library printf for SUN OS 4.1. - ** - ** + All functions are fully reentrant. - ** - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ - //#include "sqliteInt.h" + public partial class Sqlite3 { + /* + ** The "printf" code that follows dates from the 1980's. It is in + ** the public domain. The original comments are included here for + ** completeness. They are very out-of-date but might be useful as + ** an historical reference. Most of the "enhancements" have been backed + ** out so that the functionality is now the same as standard printf(). + ** + ************************************************************************** + ** + ** The following modules is an enhanced replacement for the "printf" subroutines + ** found in the standard C library. The following enhancements are + ** supported: + ** + ** + Additional functions. The standard set of "printf" functions + ** includes printf, fprintf, sprintf, vprintf, vfprintf, and + ** vsprintf. This module adds the following: + ** + ** * snprintf -- Works like sprintf, but has an extra argument + ** which is the size of the buffer written to. + ** + ** * mprintf -- Similar to sprintf. Writes output to memory + ** obtained from malloc. + ** + ** * xprintf -- Calls a function to dispose of output. + ** + ** * nprintf -- No output, but returns the number of characters + ** that would have been output by printf. + ** + ** * A v- version (ex: vsnprintf) of every function is also + ** supplied. + ** + ** + A few extensions to the formatting notation are supported: + ** + ** * The "=" flag (similar to "-") causes the output to be + ** be centered in the appropriately sized field. + ** + ** * The %b field outputs an integer in binary notation. + ** + ** * The %c field now accepts a precision. The character output + ** is repeated by the number of times the precision specifies. + ** + ** * The %' field works like %c, but takes as its character the + ** next character of the format string, instead of the next + ** argument. For example, printf("%.78'-") prints 78 minus + ** signs, the same as printf("%.78c",'-'). + ** + ** + When compiled using GCC on a SPARC, this version of printf is + ** faster than the library printf for SUN OS 4.1. + ** + ** + All functions are fully reentrant. + ** + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ + //#include "sqliteInt.h" - /* - ** Conversion types fall into various categories as defined by the - ** following enumeration. - */ - //#define etRADIX 1 /* Integer types. %d, %x, %o, and so forth */ - //#define etFLOAT 2 /* Floating point. %f */ - //#define etEXP 3 /* Exponentional notation. %e and %E */ - //#define etGENERIC 4 /* Floating or exponential, depending on exponent. %g */ - //#define etSIZE 5 /* Return number of characters processed so far. %n */ - //#define etSTRING 6 /* Strings. %s */ - //#define etDYNSTRING 7 /* Dynamically allocated strings. %z */ - //#define etPERCENT 8 /* Percent symbol. %% */ - //#define etCHARX 9 /* Characters. %c */ - ///* The rest are extensions, not normally found in printf() */ - //#define etSQLESCAPE 10 /* Strings with '\'' doubled. %q */ - //#define etSQLESCAPE2 11 /* Strings with '\'' doubled and enclosed in '', - // NULL pointers replaced by SQL NULL. %Q */ - //#define etTOKEN 12 /* a pointer to a Token structure */ - //#define etSRCLIST 13 /* a pointer to a SrcList */ - //#define etPOINTER 14 /* The %p conversion */ - //#define etSQLESCAPE3 15 /* %w -> Strings with '\"' doubled */ - //#define etORDINAL 16 /* %r -> 1st, 2nd, 3rd, 4th, etc. English only */ + /* + ** Conversion types fall into various categories as defined by the + ** following enumeration. + */ + //#define etRADIX 1 /* Integer types. %d, %x, %o, and so forth */ + //#define etFLOAT 2 /* Floating point. %f */ + //#define etEXP 3 /* Exponentional notation. %e and %E */ + //#define etGENERIC 4 /* Floating or exponential, depending on exponent. %g */ + //#define etSIZE 5 /* Return number of characters processed so far. %n */ + //#define etSTRING 6 /* Strings. %s */ + //#define etDYNSTRING 7 /* Dynamically allocated strings. %z */ + //#define etPERCENT 8 /* Percent symbol. %% */ + //#define etCHARX 9 /* Characters. %c */ + ///* The rest are extensions, not normally found in printf() */ + //#define etSQLESCAPE 10 /* Strings with '\'' doubled. %q */ + //#define etSQLESCAPE2 11 /* Strings with '\'' doubled and enclosed in '', + // NULL pointers replaced by SQL NULL. %Q */ + //#define etTOKEN 12 /* a pointer to a Token structure */ + //#define etSRCLIST 13 /* a pointer to a SrcList */ + //#define etPOINTER 14 /* The %p conversion */ + //#define etSQLESCAPE3 15 /* %w -> Strings with '\"' doubled */ + //#define etORDINAL 16 /* %r -> 1st, 2nd, 3rd, 4th, etc. English only */ - //#define etINVALID 0 /* Any unrecognized conversion type */ + //#define etINVALID 0 /* Any unrecognized conversion type */ - const int etRADIX = 1; /* Integer types. %d, %x, %o, and so forth */ - const int etFLOAT = 2; /* Floating point. %f */ - const int etEXP = 3; /* Exponentional notation. %e and %E */ - const int etGENERIC = 4; /* Floating or exponential, depending on exponent. %g */ - const int etSIZE = 5; /* Return number of characters processed so far. %n */ - const int etSTRING = 6; /* Strings. %s */ - const int etDYNSTRING = 7; /* Dynamically allocated strings. %z */ - const int etPERCENT = 8; /* Percent symbol. %% */ - const int etCHARX = 9; /* Characters. %c */ - /* The rest are extensions, not normally found in printf() */ - const int etSQLESCAPE = 10; /* Strings with '\'' doubled. %q */ - const int etSQLESCAPE2 = 11; /* Strings with '\'' doubled and enclosed in '', + const int etRADIX = 1; /* Integer types. %d, %x, %o, and so forth */ + const int etFLOAT = 2; /* Floating point. %f */ + const int etEXP = 3; /* Exponentional notation. %e and %E */ + const int etGENERIC = 4; /* Floating or exponential, depending on exponent. %g */ + const int etSIZE = 5; /* Return number of characters processed so far. %n */ + const int etSTRING = 6; /* Strings. %s */ + const int etDYNSTRING = 7; /* Dynamically allocated strings. %z */ + const int etPERCENT = 8; /* Percent symbol. %% */ + const int etCHARX = 9; /* Characters. %c */ + /* The rest are extensions, not normally found in printf() */ + const int etSQLESCAPE = 10; /* Strings with '\'' doubled. %q */ + const int etSQLESCAPE2 = 11; /* Strings with '\'' doubled and enclosed in '', NULL pointers replaced by SQL NULL. %Q */ - const int etTOKEN = 12; /* a pointer to a Token structure */ - const int etSRCLIST = 13; /* a pointer to a SrcList */ - const int etPOINTER = 14; /* The %p conversion */ - const int etSQLESCAPE3 = 15; /* %w . Strings with '\"' doubled */ - const int etORDINAL = 16; /* %r . 1st, 2nd, 3rd, 4th, etc. English only */ - const int etINVALID = 0; /* Any unrecognized conversion type */ + const int etTOKEN = 12; /* a pointer to a Token structure */ + const int etSRCLIST = 13; /* a pointer to a SrcList */ + const int etPOINTER = 14; /* The %p conversion */ + const int etSQLESCAPE3 = 15; /* %w . Strings with '\"' doubled */ + const int etORDINAL = 16; /* %r . 1st, 2nd, 3rd, 4th, etc. English only */ + const int etINVALID = 0; /* Any unrecognized conversion type */ - /* - ** An "etByte" is an 8-bit unsigned value. - */ - //typedef unsigned char etByte; + /* + ** An "etByte" is an 8-bit unsigned value. + */ + //typedef unsigned char etByte; - /* - ** Each builtin conversion character (ex: the 'd' in "%d") is described - ** by an instance of the following structure - */ - public class et_info - { /* Information about each format field */ - public char fmttype; /* The format field code letter */ - public byte _base; /* The _base for radix conversion */ - public byte flags; /* One or more of FLAG_ constants below */ - public byte type; /* Conversion paradigm */ - public byte charset; /* Offset into aDigits[] of the digits string */ - public byte prefix; /* Offset into aPrefix[] of the prefix string */ - /* - * Constructor - */ - public et_info( char fmttype, - byte _base, - byte flags, - byte type, - byte charset, - byte prefix - ) - { - this.fmttype = fmttype; - this._base = _base; - this.flags = flags; - this.type = type; - this.charset = charset; - this.prefix = prefix; - } + /* + ** Each builtin conversion character (ex: the 'd' in "%d") is described + ** by an instance of the following structure + */ + public class et_info { /* Information about each format field */ + public char fmttype; /* The format field code letter */ + public byte _base; /* The _base for radix conversion */ + public byte flags; /* One or more of FLAG_ constants below */ + public byte type; /* Conversion paradigm */ + public byte charset; /* Offset into aDigits[] of the digits string */ + public byte prefix; /* Offset into aPrefix[] of the prefix string */ + /* + * Constructor + */ + public et_info(char fmttype, + byte _base, + byte flags, + byte type, + byte charset, + byte prefix + ) { + this.fmttype = fmttype; + this._base = _base; + this.flags = flags; + this.type = type; + this.charset = charset; + this.prefix = prefix; + } - } + } - /* - ** Allowed values for et_info.flags - */ - const byte FLAG_SIGNED = 1; /* True if the value to convert is signed */ - const byte FLAG_INTERN = 2; /* True if for internal use only */ - const byte FLAG_STRING = 4; /* Allow infinity precision */ + /* + ** Allowed values for et_info.flags + */ + const byte FLAG_SIGNED = 1; /* True if the value to convert is signed */ + const byte FLAG_INTERN = 2; /* True if for internal use only */ + const byte FLAG_STRING = 4; /* Allow infinity precision */ - /* - ** The following table is searched linearly, so it is good to put the - ** most frequently used conversion types first. - */ - static string aDigits = "0123456789ABCDEF0123456789abcdef"; - static string aPrefix = "-x0\000X0"; - static et_info[] fmtinfo = new et_info[] { + /* + ** The following table is searched linearly, so it is good to put the + ** most frequently used conversion types first. + */ + static string aDigits = "0123456789ABCDEF0123456789abcdef"; + static string aPrefix = "-x0\000X0"; + static et_info[] fmtinfo = new et_info[] { new et_info( 'd', 10, 1, etRADIX, 0, 0 ), new et_info( 's', 0, 4, etSTRING, 0, 0 ), new et_info( 'g', 0, 1, etGENERIC, 30, 0 ), @@ -202,1247 +196,1085 @@ byte prefix new et_info( 'S', 0, 2, etSRCLIST, 0, 0 ), new et_info( 'r', 10, 3, etORDINAL, 0, 0 ), }; - /* - ** If SQLITE_OMIT_FLOATING_POINT is defined, then none of the floating point - ** conversions will work. + /* + ** If SQLITE_OMIT_FLOATING_POINT is defined, then none of the floating point + ** conversions will work. + */ +#if !SQLITE_OMIT_FLOATING_POINT + /* + ** "*val" is a double such that 0.1 <= *val < 10.0 + ** Return the ascii code for the leading digit of *val, then + ** multiply "*val" by 10.0 to renormalize. + ** + ** Example: + ** input: *val = 3.14159 + ** output: *val = 1.4159 function return = '3' + ** + ** The counter *cnt is incremented each time. After counter exceeds + ** 16 (the number of significant digits in a 64-bit float) '0' is + ** always returned. */ -#if !SQLITE_OMIT_FLOATING_POINT - /* -** "*val" is a double such that 0.1 <= *val < 10.0 -** Return the ascii code for the leading digit of *val, then -** multiply "*val" by 10.0 to renormalize. -** -** Example: -** input: *val = 3.14159 -** output: *val = 1.4159 function return = '3' -** -** The counter *cnt is incremented each time. After counter exceeds -** 16 (the number of significant digits in a 64-bit float) '0' is -** always returned. -*/ - static char et_getdigit( ref LONGDOUBLE_TYPE val, ref int cnt ) - { - int digit; - LONGDOUBLE_TYPE d; - if ( cnt++ >= 16 ) - return '\0'; - digit = (int)val; - d = digit; - //digit += '0'; - val = ( val - d ) * 10.0; - return (char)digit; - } + static char et_getdigit(ref LONGDOUBLE_TYPE val, ref int cnt) { + int digit; + LONGDOUBLE_TYPE d; + if (cnt++ >= 16) + return '\0'; + digit = (int)val; + d = digit; + //digit += '0'; + val = (val - d) * 10.0; + return (char)digit; + } #endif // * SQLITE_OMIT_FLOATING_POINT */ - /* -** Append N space characters to the given string buffer. -*/ - static void appendSpace( StrAccum pAccum, int N ) - { - //static const char zSpaces[] = " "; - //while( N>=zSpaces.Length-1 ){ - // sqlite3StrAccumAppend(pAccum, zSpaces, zSpaces.Length-1); - // N -= zSpaces.Length-1; - //} - //if( N>0 ){ - // sqlite3StrAccumAppend(pAccum, zSpaces, N); - //} - pAccum.zText.AppendFormat( "{0," + N + "}", "" ); - } - - /* - ** On machines with a small stack size, you can redefine the - ** SQLITE_PRINT_BUF_SIZE to be less than 350. + /* + ** Append N space characters to the given string buffer. */ + static void appendSpace(StrAccum pAccum, int N) { + //static const char zSpaces[] = " "; + //while( N>=zSpaces.Length-1 ){ + // sqlite3StrAccumAppend(pAccum, zSpaces, zSpaces.Length-1); + // N -= zSpaces.Length-1; + //} + //if( N>0 ){ + // sqlite3StrAccumAppend(pAccum, zSpaces, N); + //} + pAccum.zText.AppendFormat("{0," + N + "}", ""); + } + + /* + ** On machines with a small stack size, you can redefine the + ** SQLITE_PRINT_BUF_SIZE to be less than 350. + */ #if !SQLITE_PRINT_BUF_SIZE -# if (SQLITE_SMALL_STACK) +#if (SQLITE_SMALL_STACK) const int SQLITE_PRINT_BUF_SIZE = 50; -# else - const int SQLITE_PRINT_BUF_SIZE = 350; -#endif +#else + const int SQLITE_PRINT_BUF_SIZE = 350; #endif - const int etBUFSIZE = SQLITE_PRINT_BUF_SIZE; /* Size of the output buffer */ - - /* - ** The root program. All variations call this core. - ** - ** INPUTS: - ** func This is a pointer to a function taking three arguments - ** 1. A pointer to anything. Same as the "arg" parameter. - ** 2. A pointer to the list of characters to be output - ** (Note, this list is NOT null terminated.) - ** 3. An integer number of characters to be output. - ** (Note: This number might be zero.) - ** - ** arg This is the pointer to anything which will be passed as the - ** first argument to "func". Use it for whatever you like. - ** - ** fmt This is the format string, as in the usual print. - ** - ** ap This is a pointer to a list of arguments. Same as in - ** vfprint. - ** - ** OUTPUTS: - ** The return value is the total number of characters sent to - ** the function "func". Returns -1 on a error. - ** - ** Note that the order in which automatic variables are declared below - ** seems to make a big difference in determining how fast this beast - ** will run. - */ - static char[] buf = new char[etBUFSIZE]; /* Conversion buffer */ - static void sqlite3VXPrintf( - StrAccum pAccum, /* Accumulate results here */ - int useExtended, /* Allow extended %-conversions */ - string fmt, /* Format string */ - va_list[] ap /* arguments */ - ) - { - int c; /* Next character in the format string */ - int bufpt; /* Pointer to the conversion buffer */ - int precision; /* Precision of the current field */ - int length; /* Length of the field */ - int idx; /* A general purpose loop counter */ - int width; /* Width of the current field */ - etByte flag_leftjustify; /* True if "-" flag is present */ - etByte flag_plussign; /* True if "+" flag is present */ - etByte flag_blanksign; /* True if " " flag is present */ - etByte flag_alternateform; /* True if "#" flag is present */ - etByte flag_altform2; /* True if "!" flag is present */ - etByte flag_zeropad; /* True if field width constant starts with zero */ - etByte flag_long; /* True if "l" flag is present */ - etByte flag_longlong; /* True if the "ll" flag is present */ - etByte done; /* Loop termination flag */ - i64 longvalue; - LONGDOUBLE_TYPE realvalue; /* Value for real types */ - et_info infop; /* Pointer to the appropriate info structure */ - char[] buf = new char[etBUFSIZE]; /* Conversion buffer */ - char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */ - byte xtype = 0; /* Conversion paradigm */ - // Not used in C# -- string zExtra; /* Extra memory used for etTCLESCAPE conversions */ -#if !SQLITE_OMIT_FLOATING_POINT - int exp, e2; /* exponent of real numbers */ - double rounder; /* Used for rounding floating point values */ - etByte flag_dp; /* True if decimal point should be shown */ - etByte flag_rtz; /* True if trailing zeros should be removed */ - etByte flag_exp; /* True to force display of the exponent */ - int nsd; /* Number of significant digits returned */ #endif - length = 0; - bufpt = 0; - int _fmt = 0; // Work around string pointer - fmt += '\0'; - - for ( ; _fmt <= fmt.Length && ( c = fmt[_fmt] ) != 0; ++_fmt ) - { - if ( c != '%' ) - { - int amt; - bufpt = _fmt; - amt = 1; - while ( _fmt < fmt.Length && ( c = ( fmt[++_fmt] ) ) != '%' && c != 0 ) - amt++; - sqlite3StrAccumAppend( pAccum, fmt.Substring( bufpt, amt ), amt ); - if ( c == 0 ) - break; - } - if ( _fmt < fmt.Length && ( c = ( fmt[++_fmt] ) ) == 0 ) - { - sqlite3StrAccumAppend( pAccum, "%", 1 ); - break; - } - /* Find out what flags are present */ - flag_leftjustify = flag_plussign = flag_blanksign = - flag_alternateform = flag_altform2 = flag_zeropad = false; - done = false; - do - { - switch ( c ) - { - case '-': - flag_leftjustify = true; - break; - case '+': - flag_plussign = true; - break; - case ' ': - flag_blanksign = true; - break; - case '#': - flag_alternateform = true; - break; - case '!': - flag_altform2 = true; - break; - case '0': - flag_zeropad = true; - break; - default: - done = true; - break; - } - } while ( !done && _fmt < fmt.Length - 1 && ( c = ( fmt[++_fmt] ) ) != 0 ); - /* Get the field width */ - width = 0; - if ( c == '*' ) - { - width = va_arg( ap, (Int32)0 ); - if ( width < 0 ) - { - flag_leftjustify = true; - width = -width; - } - c = fmt[++_fmt]; - } - else - { - while ( c >= '0' && c <= '9' ) - { - width = width * 10 + c - '0'; - c = fmt[++_fmt]; - } - } - if ( width > etBUFSIZE - 10 ) - { - width = etBUFSIZE - 12; - } - /* Get the precision */ - if ( c == '.' ) - { - precision = 0; - c = fmt[++_fmt]; - if ( c == '*' ) - { - precision = va_arg( ap, (Int32)0 ); - if ( precision < 0 ) - precision = -precision; - c = fmt[++_fmt]; - } - else - { - while ( c >= '0' && c <= '9' ) - { - precision = precision * 10 + c - '0'; - c = fmt[++_fmt]; - } - } - } - else - { - precision = -1; - } - /* Get the conversion type modifier */ - if ( c == 'l' ) - { - flag_long = true; - c = fmt[++_fmt]; - if ( c == 'l' ) - { - flag_longlong = true; - c = fmt[++_fmt]; - } - else - { - flag_longlong = false; - } - } - else - { - flag_long = flag_longlong = false; - } - /* Fetch the info entry for the field */ - infop = fmtinfo[0]; - xtype = etINVALID; - for ( idx = 0; idx < ArraySize( fmtinfo ); idx++ ) - { - if ( c == fmtinfo[idx].fmttype ) - { - infop = fmtinfo[idx]; - if ( useExtended != 0 || ( infop.flags & FLAG_INTERN ) == 0 ) - { - xtype = infop.type; - } - else - { - return; - } - break; - } - } - //zExtra = null; - - /* Limit the precision to prevent overflowing buf[] during conversion */ - if ( precision > etBUFSIZE - 40 && ( infop.flags & FLAG_STRING ) == 0 ) - { - precision = etBUFSIZE - 40; - } + const int etBUFSIZE = SQLITE_PRINT_BUF_SIZE; /* Size of the output buffer */ /* - ** At this point, variables are initialized as follows: + ** The root program. All variations call this core. + ** + ** INPUTS: + ** func This is a pointer to a function taking three arguments + ** 1. A pointer to anything. Same as the "arg" parameter. + ** 2. A pointer to the list of characters to be output + ** (Note, this list is NOT null terminated.) + ** 3. An integer number of characters to be output. + ** (Note: This number might be zero.) + ** + ** arg This is the pointer to anything which will be passed as the + ** first argument to "func". Use it for whatever you like. + ** + ** fmt This is the format string, as in the usual print. + ** + ** ap This is a pointer to a list of arguments. Same as in + ** vfprint. ** - ** flag_alternateform TRUE if a '#' is present. - ** flag_altform2 TRUE if a '!' is present. - ** flag_plussign TRUE if a '+' is present. - ** flag_leftjustify TRUE if a '-' is present or if the - ** field width was negative. - ** flag_zeropad TRUE if the width began with 0. - ** flag_long TRUE if the letter 'l' (ell) prefixed - ** the conversion character. - ** flag_longlong TRUE if the letter 'll' (ell ell) prefixed - ** the conversion character. - ** flag_blanksign TRUE if a ' ' is present. - ** width The specified field width. This is - ** always non-negative. Zero is the default. - ** precision The specified precision. The default - ** is -1. - ** xtype The class of the conversion. - ** infop Pointer to the appropriate info struct. + ** OUTPUTS: + ** The return value is the total number of characters sent to + ** the function "func". Returns -1 on a error. + ** + ** Note that the order in which automatic variables are declared below + ** seems to make a big difference in determining how fast this beast + ** will run. */ - switch ( xtype ) - { - case etPOINTER: - flag_longlong = true;// char*.Length == sizeof(i64); - flag_long = false;// char*.Length == sizeof(long); - /* Fall through into the next case */ - goto case etRADIX; - case etORDINAL: - case etRADIX: - if ( ( infop.flags & FLAG_SIGNED ) != 0 ) - { - i64 v; - if ( flag_longlong ) - { - v = (Int64)va_arg( ap, (Int64)0 ); - } - else if ( flag_long ) - { - v = (Int64)va_arg( ap, (Int64)0 ); - } - else - { - v = (Int32)va_arg( ap, (Int32)0 ); - } - if ( v < 0 ) - { - if ( v == SMALLEST_INT64 ) - { - longvalue = ( (long)( (u64)1 ) << 63 ); + static char[] buf = new char[etBUFSIZE]; /* Conversion buffer */ + static void sqlite3VXPrintf( + StrAccum pAccum, /* Accumulate results here */ + int useExtended, /* Allow extended %-conversions */ + string fmt, /* Format string */ + va_list[] ap /* arguments */ + ) { + int c; /* Next character in the format string */ + int bufpt; /* Pointer to the conversion buffer */ + int precision; /* Precision of the current field */ + int length; /* Length of the field */ + int idx; /* A general purpose loop counter */ + int width; /* Width of the current field */ + etByte flag_leftjustify; /* True if "-" flag is present */ + etByte flag_plussign; /* True if "+" flag is present */ + etByte flag_blanksign; /* True if " " flag is present */ + etByte flag_alternateform; /* True if "#" flag is present */ + etByte flag_altform2; /* True if "!" flag is present */ + etByte flag_zeropad; /* True if field width constant starts with zero */ + etByte flag_long; /* True if "l" flag is present */ + etByte flag_longlong; /* True if the "ll" flag is present */ + etByte done; /* Loop termination flag */ + i64 longvalue; + LONGDOUBLE_TYPE realvalue; /* Value for real types */ + et_info infop; /* Pointer to the appropriate info structure */ + char[] buf = new char[etBUFSIZE]; /* Conversion buffer */ + char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */ + byte xtype = 0; /* Conversion paradigm */ + // Not used in C# -- string zExtra; /* Extra memory used for etTCLESCAPE conversions */ +#if !SQLITE_OMIT_FLOATING_POINT + int exp, e2; /* exponent of real numbers */ + double rounder; /* Used for rounding floating point values */ + etByte flag_dp; /* True if decimal point should be shown */ + etByte flag_rtz; /* True if trailing zeros should be removed */ + etByte flag_exp; /* True to force display of the exponent */ + int nsd; /* Number of significant digits returned */ +#endif + length = 0; + bufpt = 0; + int _fmt = 0; // Work around string pointer + fmt += '\0'; + + for (; _fmt <= fmt.Length && (c = fmt[_fmt]) != 0; ++_fmt) { + if (c != '%') { + int amt; + bufpt = _fmt; + amt = 1; + while (_fmt < fmt.Length && (c = (fmt[++_fmt])) != '%' && c != 0) + amt++; + sqlite3StrAccumAppend(pAccum, fmt.Substring(bufpt, amt), amt); + if (c == 0) + break; } - else - { - longvalue = -v; + if (_fmt < fmt.Length && (c = (fmt[++_fmt])) == 0) { + sqlite3StrAccumAppend(pAccum, "%", 1); + break; } - prefix = '-'; - } - else - { - longvalue = v; - if ( flag_plussign ) - prefix = '+'; - else if ( flag_blanksign ) - prefix = ' '; - else - prefix = '\0'; - } - } - else - { - if ( flag_longlong ) - { - longvalue = va_arg( ap, (Int64)0 ); - } - else if ( flag_long ) - { - longvalue = va_arg( ap, (Int64)0 ); - } - else - { - longvalue = va_arg( ap, (Int64)0 ); - } - prefix = '\0'; - } - if ( longvalue == 0 ) - flag_alternateform = false; - if ( flag_zeropad && precision < width - ( ( prefix != '\0' ) ? 1 : 0 ) ) - { - precision = width - ( ( prefix != '\0' ) ? 1 : 0 ); - } - bufpt = buf.Length;//[etBUFSIZE-1]; - char[] _bufOrd = null; - if ( xtype == etORDINAL ) - { - char[] zOrd = "thstndrd".ToCharArray(); - int x = (int)( longvalue % 10 ); - if ( x >= 4 || ( longvalue / 10 ) % 10 == 1 ) - { - x = 0; - } - _bufOrd = new char[2]; - _bufOrd[0] = zOrd[x * 2]; - _bufOrd[1] = zOrd[x * 2 + 1]; - //bufpt -= 2; - } - { + /* Find out what flags are present */ + flag_leftjustify = flag_plussign = flag_blanksign = + flag_alternateform = flag_altform2 = flag_zeropad = false; + done = false; + do { + switch (c) { + case '-': + flag_leftjustify = true; + break; + case '+': + flag_plussign = true; + break; + case ' ': + flag_blanksign = true; + break; + case '#': + flag_alternateform = true; + break; + case '!': + flag_altform2 = true; + break; + case '0': + flag_zeropad = true; + break; + default: + done = true; + break; + } + } while (!done && _fmt < fmt.Length - 1 && (c = (fmt[++_fmt])) != 0); + /* Get the field width */ + width = 0; + if (c == '*') { + width = va_arg(ap, (Int32)0); + if (width < 0) { + flag_leftjustify = true; + width = -width; + } + c = fmt[++_fmt]; + } else { + while (c >= '0' && c <= '9') { + width = width * 10 + c - '0'; + c = fmt[++_fmt]; + } + } + if (width > etBUFSIZE - 10) { + width = etBUFSIZE - 12; + } + /* Get the precision */ + if (c == '.') { + precision = 0; + c = fmt[++_fmt]; + if (c == '*') { + precision = va_arg(ap, (Int32)0); + if (precision < 0) + precision = -precision; + c = fmt[++_fmt]; + } else { + while (c >= '0' && c <= '9') { + precision = precision * 10 + c - '0'; + c = fmt[++_fmt]; + } + } + } else { + precision = -1; + } + /* Get the conversion type modifier */ + if (c == 'l') { + flag_long = true; + c = fmt[++_fmt]; + if (c == 'l') { + flag_longlong = true; + c = fmt[++_fmt]; + } else { + flag_longlong = false; + } + } else { + flag_long = flag_longlong = false; + } + /* Fetch the info entry for the field */ + infop = fmtinfo[0]; + xtype = etINVALID; + for (idx = 0; idx < ArraySize(fmtinfo); idx++) { + if (c == fmtinfo[idx].fmttype) { + infop = fmtinfo[idx]; + if (useExtended != 0 || (infop.flags & FLAG_INTERN) == 0) { + xtype = infop.type; + } else { + return; + } + break; + } + } + //zExtra = null; - char[] _buf; - switch ( infop._base ) - { - case 16: - _buf = longvalue.ToString( "x" ).ToCharArray(); - break; - case 8: - _buf = Convert.ToString( (long)longvalue, 8 ).ToCharArray(); - break; - default: - { - if ( flag_zeropad ) - _buf = longvalue.ToString( new string( '0', width - ( ( prefix != '\0' ) ? 1 : 0 ) ) ).ToCharArray(); - else - _buf = longvalue.ToString().ToCharArray(); - } - break; - } - bufpt = buf.Length - _buf.Length - ( _bufOrd == null ? 0 : 2 ); - Array.Copy( _buf, 0, buf, bufpt, _buf.Length ); - if ( _bufOrd != null ) - { - buf[buf.Length - 1] = _bufOrd[1]; - buf[buf.Length - 2] = _bufOrd[0]; - } - //char* cset; /* Use registers for speed */ - //int _base; - //cset = aDigits[infop.charset]; - //_base = infop._base; - //do - //{ /* Convert to ascii */ - // *(--bufpt) = cset[longvalue % (ulong)_base]; - // longvalue = longvalue / (ulong)_base; - //} while (longvalue > 0); - } - length = buf.Length - bufpt;//length = (int)(&buf[etBUFSIZE-1]-bufpt); - for ( idx = precision - length; idx > 0; idx-- ) - { - buf[( --bufpt )] = '0'; /* Zero pad */ - } - if ( prefix != '\0' ) - buf[--bufpt] = prefix; /* Add sign */ - if ( flag_alternateform && infop.prefix != 0 ) - { /* Add "0" or "0x" */ - int pre; - char x; - pre = infop.prefix; - for ( ; ( x = aPrefix[pre] ) != 0; pre++ ) - buf[--bufpt] = x; - } - length = buf.Length - bufpt;//length = (int)(&buf[etBUFSIZE-1]-bufpt); - break; - case etFLOAT: - case etEXP: - case etGENERIC: - realvalue = va_arg( ap, (Double)0 ); + /* Limit the precision to prevent overflowing buf[] during conversion */ + if (precision > etBUFSIZE - 40 && (infop.flags & FLAG_STRING) == 0) { + precision = etBUFSIZE - 40; + } + + /* + ** At this point, variables are initialized as follows: + ** + ** flag_alternateform TRUE if a '#' is present. + ** flag_altform2 TRUE if a '!' is present. + ** flag_plussign TRUE if a '+' is present. + ** flag_leftjustify TRUE if a '-' is present or if the + ** field width was negative. + ** flag_zeropad TRUE if the width began with 0. + ** flag_long TRUE if the letter 'l' (ell) prefixed + ** the conversion character. + ** flag_longlong TRUE if the letter 'll' (ell ell) prefixed + ** the conversion character. + ** flag_blanksign TRUE if a ' ' is present. + ** width The specified field width. This is + ** always non-negative. Zero is the default. + ** precision The specified precision. The default + ** is -1. + ** xtype The class of the conversion. + ** infop Pointer to the appropriate info struct. + */ + switch (xtype) { + case etPOINTER: + flag_longlong = true;// char*.Length == sizeof(i64); + flag_long = false;// char*.Length == sizeof(long); + /* Fall through into the next case */ + goto case etRADIX; + case etORDINAL: + case etRADIX: + if ((infop.flags & FLAG_SIGNED) != 0) { + i64 v; + if (flag_longlong) { + v = (Int64)va_arg(ap, (Int64)0); + } else if (flag_long) { + v = (Int64)va_arg(ap, (Int64)0); + } else { + v = (Int32)va_arg(ap, (Int32)0); + } + if (v < 0) { + if (v == SMALLEST_INT64) { + longvalue = ((long)((u64)1) << 63); + } else { + longvalue = -v; + } + prefix = '-'; + } else { + longvalue = v; + if (flag_plussign) + prefix = '+'; + else if (flag_blanksign) + prefix = ' '; + else + prefix = '\0'; + } + } else { + if (flag_longlong) { + longvalue = va_arg(ap, (Int64)0); + } else if (flag_long) { + longvalue = va_arg(ap, (Int64)0); + } else { + longvalue = va_arg(ap, (Int64)0); + } + prefix = '\0'; + } + if (longvalue == 0) + flag_alternateform = false; + if (flag_zeropad && precision < width - ((prefix != '\0') ? 1 : 0)) { + precision = width - ((prefix != '\0') ? 1 : 0); + } + bufpt = buf.Length;//[etBUFSIZE-1]; + char[] _bufOrd = null; + if (xtype == etORDINAL) { + char[] zOrd = "thstndrd".ToCharArray(); + int x = (int)(longvalue % 10); + if (x >= 4 || (longvalue / 10) % 10 == 1) { + x = 0; + } + _bufOrd = new char[2]; + _bufOrd[0] = zOrd[x * 2]; + _bufOrd[1] = zOrd[x * 2 + 1]; + //bufpt -= 2; + } { + + char[] _buf; + switch (infop._base) { + case 16: + _buf = longvalue.ToString("x").ToCharArray(); + break; + case 8: + _buf = Convert.ToString((long)longvalue, 8).ToCharArray(); + break; + default: { + if (flag_zeropad) + _buf = longvalue.ToString(new string('0', width - ((prefix != '\0') ? 1 : 0))).ToCharArray(); + else + _buf = longvalue.ToString().ToCharArray(); + } + break; + } + bufpt = buf.Length - _buf.Length - (_bufOrd == null ? 0 : 2); + Array.Copy(_buf, 0, buf, bufpt, _buf.Length); + if (_bufOrd != null) { + buf[buf.Length - 1] = _bufOrd[1]; + buf[buf.Length - 2] = _bufOrd[0]; + } + //char* cset; /* Use registers for speed */ + //int _base; + //cset = aDigits[infop.charset]; + //_base = infop._base; + //do + //{ /* Convert to ascii */ + // *(--bufpt) = cset[longvalue % (ulong)_base]; + // longvalue = longvalue / (ulong)_base; + //} while (longvalue > 0); + } + length = buf.Length - bufpt;//length = (int)(&buf[etBUFSIZE-1]-bufpt); + for (idx = precision - length; idx > 0; idx--) { + buf[(--bufpt)] = '0'; /* Zero pad */ + } + if (prefix != '\0') + buf[--bufpt] = prefix; /* Add sign */ + if (flag_alternateform && infop.prefix != 0) { /* Add "0" or "0x" */ + int pre; + char x; + pre = infop.prefix; + for (; (x = aPrefix[pre]) != 0; pre++) + buf[--bufpt] = x; + } + length = buf.Length - bufpt;//length = (int)(&buf[etBUFSIZE-1]-bufpt); + break; + case etFLOAT: + case etEXP: + case etGENERIC: + realvalue = va_arg(ap, (Double)0); #if SQLITE_OMIT_FLOATING_POINT length = 0; #else - if ( precision < 0 ) - precision = 6; /* Set default precision */ - if ( precision > etBUFSIZE / 2 - 10 ) - precision = etBUFSIZE / 2 - 10; - if ( realvalue < 0.0 ) - { - realvalue = -realvalue; - prefix = '-'; - } - else - { - if ( flag_plussign ) - prefix = '+'; - else if ( flag_blanksign ) - prefix = ' '; - else - prefix = '\0'; - } - if ( xtype == etGENERIC && precision > 0 ) - precision--; + if (precision < 0) + precision = 6; /* Set default precision */ + if (precision > etBUFSIZE / 2 - 10) + precision = etBUFSIZE / 2 - 10; + if (realvalue < 0.0) { + realvalue = -realvalue; + prefix = '-'; + } else { + if (flag_plussign) + prefix = '+'; + else if (flag_blanksign) + prefix = ' '; + else + prefix = '\0'; + } + if (xtype == etGENERIC && precision > 0) + precision--; #if FALSE /* Rounding works like BSD when the constant 0.4999 is used. Wierd! */ for(idx=precision, rounder=0.4999; idx>0; idx--, rounder*=0.1); #else - /* It makes more sense to use 0.5 */ - for ( idx = precision, rounder = 0.5; idx > 0; idx--, rounder *= 0.1 ) - { - } + /* It makes more sense to use 0.5 */ + for (idx = precision, rounder = 0.5; idx > 0; idx--, rounder *= 0.1) { + } #endif - if ( xtype == etFLOAT ) - realvalue += rounder; - /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */ - exp = 0; - double d = 0; + if (xtype == etFLOAT) + realvalue += rounder; + /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */ + exp = 0; + double d = 0; #if WINDOWS_MOBILE //alxwest: Tryparse doesn't exist on Windows Moble and what will Tryparsing a double do? if ( Double.IsNaN( realvalue )) #else - if ( Double.IsNaN( realvalue ) || !( Double.TryParse( Convert.ToString( realvalue ), out d ) ) )//if( sqlite3IsNaN((double)realvalue) ) + if (Double.IsNaN(realvalue) || !(Double.TryParse(Convert.ToString(realvalue), out d)))//if( sqlite3IsNaN((double)realvalue) ) #endif - { - buf[0] = 'N'; - buf[1] = 'a'; - buf[2] = 'N';// "NaN" - length = 3; - break; - } - if ( realvalue > 0.0 ) - { - while ( realvalue >= 1e32 && exp <= 350 ) - { - realvalue *= 1e-32; - exp += 32; - } - while ( realvalue >= 1e8 && exp <= 350 ) - { - realvalue *= 1e-8; - exp += 8; - } - while ( realvalue >= 10.0 && exp <= 350 ) - { - realvalue *= 0.1; - exp++; - } - while ( realvalue < 1e-8 ) - { - realvalue *= 1e8; - exp -= 8; - } - while ( realvalue < 1.0 ) - { - realvalue *= 10.0; - exp--; - } - if ( exp > 350 ) - { - if ( prefix == '-' ) - { - buf[0] = '-'; - buf[1] = 'I'; - buf[2] = 'n'; - buf[3] = 'f';// "-Inf" - bufpt = 4; + { + buf[0] = 'N'; + buf[1] = 'a'; + buf[2] = 'N';// "NaN" + length = 3; + break; + } + if (realvalue > 0.0) { + while (realvalue >= 1e32 && exp <= 350) { + realvalue *= 1e-32; + exp += 32; + } + while (realvalue >= 1e8 && exp <= 350) { + realvalue *= 1e-8; + exp += 8; + } + while (realvalue >= 10.0 && exp <= 350) { + realvalue *= 0.1; + exp++; + } + while (realvalue < 1e-8) { + realvalue *= 1e8; + exp -= 8; + } + while (realvalue < 1.0) { + realvalue *= 10.0; + exp--; + } + if (exp > 350) { + if (prefix == '-') { + buf[0] = '-'; + buf[1] = 'I'; + buf[2] = 'n'; + buf[3] = 'f';// "-Inf" + bufpt = 4; + } else if (prefix == '+') { + buf[0] = '+'; + buf[1] = 'I'; + buf[2] = 'n'; + buf[3] = 'f';// "+Inf" + bufpt = 4; + } else { + buf[0] = 'I'; + buf[1] = 'n'; + buf[2] = 'f';// "Inf" + bufpt = 3; + } + length = sqlite3Strlen30(bufpt);// sqlite3Strlen30(bufpt); + bufpt = 0; + break; + } + } + bufpt = 0; + /* + ** If the field type is etGENERIC, then convert to either etEXP + ** or etFLOAT, as appropriate. + */ + flag_exp = xtype == etEXP; + if (xtype != etFLOAT) { + realvalue += rounder; + if (realvalue >= 10.0) { + realvalue *= 0.1; + exp++; + } + } + if (xtype == etGENERIC) { + flag_rtz = !flag_alternateform; + if (exp < -4 || exp > precision) { + xtype = etEXP; + } else { + precision = precision - exp; + xtype = etFLOAT; + } + } else { + flag_rtz = false; + } + if (xtype == etEXP) { + e2 = 0; + } else { + e2 = exp; + } + nsd = 0; + flag_dp = (precision > 0 ? true : false) | flag_alternateform | flag_altform2; + /* The sign in front of the number */ + if (prefix != '\0') { + buf[bufpt++] = prefix; + } + /* Digits prior to the decimal point */ + if (e2 < 0) { + buf[bufpt++] = '0'; + } else { + for (; e2 >= 0; e2--) { + buf[bufpt++] = (char)(et_getdigit(ref realvalue, ref nsd) + '0'); // *(bufpt++) = et_getdigit(ref realvalue, ref nsd); + } + + } + /* The decimal point */ + if (flag_dp) { + buf[bufpt++] = '.'; + } + /* "0" digits after the decimal point but before the first + ** significant digit of the number */ + for (e2++; e2 < 0; precision--, e2++) { + Debug.Assert(precision > 0); + buf[bufpt++] = '0'; + } + /* Significant digits after the decimal point */ + while ((precision--) > 0) { + buf[bufpt++] = (char)(et_getdigit(ref realvalue, ref nsd) + '0'); // *(bufpt++) = et_getdigit(&realvalue, nsd); + } + /* Remove trailing zeros and the "." if no digits follow the "." */ + if (flag_rtz && flag_dp) { + while (buf[bufpt - 1] == '0') + buf[--bufpt] = '\0'; + Debug.Assert(bufpt > 0); + if (buf[bufpt - 1] == '.') { + if (flag_altform2) { + buf[(bufpt++)] = '0'; + } else { + buf[(--bufpt)] = '0'; + } + } + } + /* Add the "eNNN" suffix */ + if (flag_exp || xtype == etEXP) { + buf[bufpt++] = aDigits[infop.charset]; + if (exp < 0) { + buf[bufpt++] = '-'; + exp = -exp; + } else { + buf[bufpt++] = '+'; + } + if (exp >= 100) { + buf[bufpt++] = (char)(exp / 100 + '0'); /* 100's digit */ + exp %= 100; + } + buf[bufpt++] = (char)(exp / 10 + '0'); /* 10's digit */ + buf[bufpt++] = (char)(exp % 10 + '0'); /* 1's digit */ + } + //bufpt = 0; + + /* The converted number is in buf[] and zero terminated. Output it. + ** Note that the number is in the usual order, not reversed as with + ** integer conversions. */ + length = bufpt;//length = (int)(bufpt-buf); + bufpt = 0; + + /* Special case: Add leading zeros if the flag_zeropad flag is + ** set and we are not left justified */ + if (flag_zeropad && !flag_leftjustify && length < width) { + int i; + int nPad = width - length; + for (i = width; i >= nPad; i--) { + buf[bufpt + i] = buf[bufpt + i - nPad]; + } + i = (prefix != '\0' ? 1 : 0); + while (nPad-- != 0) + buf[(bufpt++) + i] = '0'; + length = width; + bufpt = 0; + } +#endif //* !defined(SQLITE_OMIT_FLOATING_POINT) */ + break; + case etSIZE: + ap[0] = pAccum.nChar; // *(va_arg(ap,int)) = pAccum.nChar; + length = width = 0; + break; + case etPERCENT: + buf[0] = '%'; + bufpt = 0; + length = 1; + break; + case etCHARX: + c = va_arg(ap, (Char)0); + buf[0] = (char)c; + if (precision >= 0) { + for (idx = 1; idx < precision; idx++) + buf[idx] = (char)c; + length = precision; + } else { + length = 1; + } + bufpt = 0; + break; + case etSTRING: + case etDYNSTRING: + bufpt = 0;// + string bufStr = (string)va_arg(ap, "string"); + if (bufStr.Length > buf.Length) + buf = new char[bufStr.Length]; + bufStr.ToCharArray().CopyTo(buf, 0); + bufpt = bufStr.Length; + if (bufpt == 0) { + buf[0] = '\0'; + } else if (xtype == etDYNSTRING) { + // zExtra = bufpt; + } + if (precision >= 0) { + for (length = 0; length < precision && length < bufStr.Length && buf[length] != 0; length++) { + } + //length += precision; + } else { + length = sqlite3Strlen30(bufpt); + } + bufpt = 0; + break; + case etSQLESCAPE: + case etSQLESCAPE2: + case etSQLESCAPE3: { + int i; + int j; + int k; + int n; + bool isnull; + bool needQuote; + char ch; + char q = ((xtype == etSQLESCAPE3) ? '"' : '\''); /* Quote character */ + string escarg = (string)va_arg(ap, "char*") + '\0'; + isnull = (escarg == "" || escarg == "NULL\0"); + if (isnull) + escarg = (xtype == etSQLESCAPE2) ? "NULL\0" : "(NULL)\0"; + k = precision; + for (i = n = 0; k != 0 && (ch = escarg[i]) != 0; i++, k--) { + if (ch == q) + n++; + } + needQuote = !isnull && (xtype == etSQLESCAPE2); + n += i + 1 + (needQuote ? 2 : 0); + if (n > etBUFSIZE) { + buf = new char[n];//bufpt = zExtra = sqlite3Malloc(n); + //if ( bufpt == 0 ) + //{ + // pAccum->mallocFailed = 1; + // return; + //} + bufpt = 0; //Start of Buffer + } else { + //bufpt = buf; + bufpt = 0; //Start of Buffer + } + j = 0; + if (needQuote) + buf[bufpt + j++] = q; + k = i; + for (i = 0; i < k; i++) { + buf[bufpt + j++] = ch = escarg[i]; + if (ch == q) + buf[bufpt + j++] = ch; + } + if (needQuote) + buf[bufpt + j++] = q; + buf[bufpt + j] = '\0'; + length = j; + /* The precision in %q and %Q means how many input characters to + ** consume, not the length of the output... + ** if( precision>=0 && precision= 0 && k < pSrc.nSrc); + if (pItem.zDatabase != null) { + sqlite3StrAccumAppend(pAccum, pItem.zDatabase, -1); + sqlite3StrAccumAppend(pAccum, ".", 1); + } + sqlite3StrAccumAppend(pAccum, pItem.zName, -1); + length = width = 0; + break; + } + default: { + Debug.Assert(xtype == etINVALID); + return; + } + }/* End switch over the format type */ + /* + ** The text of the conversion is pointed to by "bufpt" and is + ** "length" characters long. The field width is "width". Do + ** the output. + */ + if (!flag_leftjustify) { + int nspace; + nspace = width - length;// -2; + if (nspace > 0) { + appendSpace(pAccum, nspace); + } } - else if ( prefix == '+' ) - { - buf[0] = '+'; - buf[1] = 'I'; - buf[2] = 'n'; - buf[3] = 'f';// "+Inf" - bufpt = 4; + if (length > 0) { + sqlite3StrAccumAppend(pAccum, new string(buf, bufpt, length), length); } - else - { - buf[0] = 'I'; - buf[1] = 'n'; - buf[2] = 'f';// "Inf" - bufpt = 3; + if (flag_leftjustify) { + int nspace; + nspace = width - length; + if (nspace > 0) { + appendSpace(pAccum, nspace); + } } - length = sqlite3Strlen30( bufpt );// sqlite3Strlen30(bufpt); - bufpt = 0; - break; - } - } - bufpt = 0; - /* - ** If the field type is etGENERIC, then convert to either etEXP - ** or etFLOAT, as appropriate. - */ - flag_exp = xtype == etEXP; - if ( xtype != etFLOAT ) - { - realvalue += rounder; - if ( realvalue >= 10.0 ) - { - realvalue *= 0.1; - exp++; - } - } - if ( xtype == etGENERIC ) - { - flag_rtz = !flag_alternateform; - if ( exp < -4 || exp > precision ) - { - xtype = etEXP; - } - else - { - precision = precision - exp; - xtype = etFLOAT; - } - } - else - { - flag_rtz = false; - } - if ( xtype == etEXP ) - { - e2 = 0; - } - else - { - e2 = exp; - } - nsd = 0; - flag_dp = ( precision > 0 ? true : false ) | flag_alternateform | flag_altform2; - /* The sign in front of the number */ - if ( prefix != '\0' ) - { - buf[bufpt++] = prefix; - } - /* Digits prior to the decimal point */ - if ( e2 < 0 ) - { - buf[bufpt++] = '0'; - } - else - { - for ( ; e2 >= 0; e2-- ) - { - buf[bufpt++] = (char)( et_getdigit( ref realvalue, ref nsd ) + '0' ); // *(bufpt++) = et_getdigit(ref realvalue, ref nsd); - } + //if( zExtra ){ + // sqlite3DbFree(db,ref zExtra); + //} + }/* End for loop over the format string */ + } /* End of function */ - } - /* The decimal point */ - if ( flag_dp ) - { - buf[bufpt++] = '.'; - } - /* "0" digits after the decimal point but before the first - ** significant digit of the number */ - for ( e2++; e2 < 0; precision--, e2++ ) - { - Debug.Assert( precision > 0 ); - buf[bufpt++] = '0'; - } - /* Significant digits after the decimal point */ - while ( ( precision-- ) > 0 ) + /* + ** Append N bytes of text from z to the StrAccum object. + */ + + static void sqlite3StrAccumAppend(StrAccum p, string z, int N) { + Debug.Assert(z != null || N == 0); + if (p.tooBig)//|| p.mallocFailed != 0 ) { - buf[bufpt++] = (char)( et_getdigit( ref realvalue, ref nsd ) + '0' ); // *(bufpt++) = et_getdigit(&realvalue, nsd); + testcase(p.tooBig); + //testcase( p.mallocFailed ); + return; } - /* Remove trailing zeros and the "." if no digits follow the "." */ - if ( flag_rtz && flag_dp ) - { - while ( buf[bufpt - 1] == '0' ) - buf[--bufpt] = '\0'; - Debug.Assert( bufpt > 0 ); - if ( buf[bufpt - 1] == '.' ) - { - if ( flag_altform2 ) - { - buf[( bufpt++ )] = '0'; - } - else - { - buf[( --bufpt )] = '0'; - } - } + if (N < 0) { + N = sqlite3Strlen30(z); } - /* Add the "eNNN" suffix */ - if ( flag_exp || xtype == etEXP ) - { - buf[bufpt++] = aDigits[infop.charset]; - if ( exp < 0 ) - { - buf[bufpt++] = '-'; - exp = -exp; - } - else - { - buf[bufpt++] = '+'; - } - if ( exp >= 100 ) - { - buf[bufpt++] = (char)( exp / 100 + '0' ); /* 100's digit */ - exp %= 100; - } - buf[bufpt++] = (char)( exp / 10 + '0' ); /* 10's digit */ - buf[bufpt++] = (char)( exp % 10 + '0' ); /* 1's digit */ + if (N == 0 || NEVER(z == null)) { + return; } - //bufpt = 0; + //if( p->nChar+N >= p->nAlloc ){ + // string zNew; + // if( null==p->useMalloc ){ + // p->tooBig = 1; + // N = p->nAlloc - p->nChar - 1; + // if( N<=0 ){ + // return; + // } + // }else{ + // string zOld = (p->zText==p->zBase ? 0 : p->zText); + // i64 szNew = p->nChar; + // szNew += N + 1; + // if( szNew > p->mxAlloc ){ + // sqlite3StrAccumReset(p); + // p->tooBig = 1; + // return; + // }else{ + // p->nAlloc = (int)szNew; + // } + // if( p->useMalloc==1 ){ + // zNew = sqlite3DbRealloc(p->db, zOld, p->nAlloc); + // }else{ + // zNew = sqlite3_realloc(zOld, p->nAlloc); + // } + // if( zNew ){ + // if( zOld==0 ) memcpy(zNew, p->zText, p->nChar); + // p->zText = zNew; + // }else{ + // p->mallocFailed = 1; + // sqlite3StrAccumReset(p); + // return; + // } + // } + //} + //memcpy(&p->zText[p->nChar], z, N); + p.zText.Append(z.Substring(0, N <= z.Length ? N : z.Length)); + //p.nChar += N; + } - /* The converted number is in buf[] and zero terminated. Output it. - ** Note that the number is in the usual order, not reversed as with - ** integer conversions. */ - length = bufpt;//length = (int)(bufpt-buf); - bufpt = 0; + /* + ** Finish off a string by making sure it is zero-terminated. + ** Return a pointer to the resulting string. Return a NULL + ** pointer if any kind of error was encountered. + */ + static string sqlite3StrAccumFinish(StrAccum p) { + //if ( p->zText ) + //{ + // p->zText[p->nChar] = 0; + // if ( p->useMalloc && p->zText == p->zBase ) + // { + // if ( p->useMalloc == 1 ) + // { + // p->zText = sqlite3DbMallocRaw( p->db, p->nChar + 1 ); + // } + // else + // { + // p->zText = sqlite3_malloc( p->nChar + 1 ); + // } + // if ( p->zText ) + // { + // memcpy( p->zText, p->zBase, p->nChar + 1 ); + // } + // else + // { + // p->mallocFailed = 1; + // } + // } + //} + return p.zText.ToString(); + } - /* Special case: Add leading zeros if the flag_zeropad flag is - ** set and we are not left justified */ - if ( flag_zeropad && !flag_leftjustify && length < width ) - { - int i; - int nPad = width - length; - for ( i = width; i >= nPad; i-- ) - { - buf[bufpt + i] = buf[bufpt + i - nPad]; - } - i = ( prefix != '\0' ? 1 : 0 ); - while ( nPad-- != 0 ) - buf[( bufpt++ ) + i] = '0'; - length = width; - bufpt = 0; - } -#endif //* !defined(SQLITE_OMIT_FLOATING_POINT) */ - break; - case etSIZE: - ap[0] = pAccum.nChar; // *(va_arg(ap,int)) = pAccum.nChar; - length = width = 0; - break; - case etPERCENT: - buf[0] = '%'; - bufpt = 0; - length = 1; - break; - case etCHARX: - c = va_arg( ap, (Char) 0); - buf[0] = (char)c; - if ( precision >= 0 ) - { - for ( idx = 1; idx < precision; idx++ ) - buf[idx] = (char)c; - length = precision; - } - else - { - length = 1; - } - bufpt = 0; - break; - case etSTRING: - case etDYNSTRING: - bufpt = 0;// - string bufStr = (string)va_arg( ap, "string" ); - if ( bufStr.Length > buf.Length ) - buf = new char[bufStr.Length]; - bufStr.ToCharArray().CopyTo( buf, 0 ); - bufpt = bufStr.Length; - if ( bufpt == 0 ) - { - buf[0] = '\0'; - } - else if ( xtype == etDYNSTRING ) - { - // zExtra = bufpt; - } - if ( precision >= 0 ) - { - for ( length = 0; length < precision && length < bufStr.Length && buf[length] != 0; length++ ) - { - } - //length += precision; - } - else - { - length = sqlite3Strlen30( bufpt ); - } - bufpt = 0; - break; - case etSQLESCAPE: - case etSQLESCAPE2: - case etSQLESCAPE3: - { - int i; - int j; - int k; - int n; - bool isnull; - bool needQuote; - char ch; - char q = ( ( xtype == etSQLESCAPE3 ) ? '"' : '\'' ); /* Quote character */ - string escarg = (string)va_arg( ap, "char*" ) + '\0'; - isnull = ( escarg == "" || escarg == "NULL\0" ); - if ( isnull ) - escarg = ( xtype == etSQLESCAPE2 ) ? "NULL\0" : "(NULL)\0"; - k = precision; - for ( i = n = 0; k != 0 && ( ch = escarg[i] ) != 0; i++, k-- ) - { - if ( ch == q ) - n++; - } - needQuote = !isnull && ( xtype == etSQLESCAPE2 ); - n += i + 1 + ( needQuote ? 2 : 0 ); - if ( n > etBUFSIZE ) - { - buf = new char[n];//bufpt = zExtra = sqlite3Malloc(n); - //if ( bufpt == 0 ) - //{ - // pAccum->mallocFailed = 1; - // return; - //} - bufpt = 0; //Start of Buffer - } - else - { - //bufpt = buf; - bufpt = 0; //Start of Buffer - } - j = 0; - if ( needQuote ) - buf[bufpt + j++] = q; - k = i; - for ( i = 0; i < k; i++ ) - { - buf[bufpt + j++] = ch = escarg[i]; - if ( ch == q ) - buf[bufpt + j++] = ch; - } - if ( needQuote ) - buf[bufpt + j++] = q; - buf[bufpt + j] = '\0'; - length = j; - /* The precision in %q and %Q means how many input characters to - ** consume, not the length of the output... - ** if( precision>=0 && precision= 0 && k < pSrc.nSrc ); - if ( pItem.zDatabase != null ) - { - sqlite3StrAccumAppend( pAccum, pItem.zDatabase, -1 ); - sqlite3StrAccumAppend( pAccum, ".", 1 ); - } - sqlite3StrAccumAppend( pAccum, pItem.zName, -1 ); - length = width = 0; - break; - } - default: - { - Debug.Assert( xtype == etINVALID ); - return; - } - }/* End switch over the format type */ /* - ** The text of the conversion is pointed to by "bufpt" and is - ** "length" characters long. The field width is "width". Do - ** the output. + ** Reset an StrAccum string. Reclaim all malloced memory. */ - if ( !flag_leftjustify ) - { - int nspace; - nspace = width - length;// -2; - if ( nspace > 0 ) - { - appendSpace( pAccum, nspace ); - } + static void sqlite3StrAccumReset(StrAccum p) { + //if ( p.zText.ToString() != p.zBase.ToString() ) + //{ + // if ( p.useMalloc == 1 ) + // { + // sqlite3DbFree( p.db, ref p.zText ); + // } + // else + // { + // sqlite3_free( ref p.zText ); + // } + //} + p.zText.Length = 0; } - if ( length > 0 ) - { - sqlite3StrAccumAppend( pAccum, new string( buf, bufpt, length ), length ); + + /* + ** Initialize a string accumulator + */ + static void sqlite3StrAccumInit(StrAccum p, StringBuilder zBase, int n, int mx) { + //p.zBase.Length = 0; + //if ( p.zBase.Capacity < n ) + // p.zBase.Capacity = n; + p.zText.Length = 0; + if (p.zText.Capacity < n) + p.zText.Capacity = n; + p.db = null; + //p.nChar = 0; + //p.nAlloc = n; + p.mxAlloc = mx; + //p.useMalloc = 1; + //p.tooBig = 0; + //p.mallocFailed = 0; } - if ( flag_leftjustify ) - { - int nspace; - nspace = width - length; - if ( nspace > 0 ) - { - appendSpace( pAccum, nspace ); - } + /* + ** Print into memory obtained from sqliteMalloc(). Use the internal + ** %-conversion extensions. + */ + static StrAccum acc = new StrAccum(SQLITE_PRINT_BUF_SIZE); + static string sqlite3VMPrintf(sqlite3 db, string zFormat, params va_list[] ap) { + if (zFormat == null) + return null; + if (ap.Length == 0) + return zFormat; + //string z; + Debug.Assert(db != null); + sqlite3StrAccumInit(acc, null, SQLITE_PRINT_BUF_SIZE, + db.aLimit[SQLITE_LIMIT_LENGTH]); + acc.db = db; + acc.zText.Length = 0; + sqlite3VXPrintf(acc, 1, zFormat, ap); + // if ( acc.mallocFailed != 0 ) + // { + ////// db.mallocFailed = 1; + // } + return sqlite3StrAccumFinish(acc); } - //if( zExtra ){ - // sqlite3DbFree(db,ref zExtra); - //} - }/* End for loop over the format string */ - } /* End of function */ - - /* - ** Append N bytes of text from z to the StrAccum object. - */ - - static void sqlite3StrAccumAppend( StrAccum p, string z, int N ) - { - Debug.Assert( z != null || N == 0 ); - if ( p.tooBig )//|| p.mallocFailed != 0 ) - { - testcase( p.tooBig ); - //testcase( p.mallocFailed ); - return; - } - if ( N < 0 ) - { - N = sqlite3Strlen30( z ); - } - if ( N == 0 || NEVER( z == null ) ) - { - return; - } - //if( p->nChar+N >= p->nAlloc ){ - // string zNew; - // if( null==p->useMalloc ){ - // p->tooBig = 1; - // N = p->nAlloc - p->nChar - 1; - // if( N<=0 ){ - // return; - // } - // }else{ - // string zOld = (p->zText==p->zBase ? 0 : p->zText); - // i64 szNew = p->nChar; - // szNew += N + 1; - // if( szNew > p->mxAlloc ){ - // sqlite3StrAccumReset(p); - // p->tooBig = 1; - // return; - // }else{ - // p->nAlloc = (int)szNew; - // } - // if( p->useMalloc==1 ){ - // zNew = sqlite3DbRealloc(p->db, zOld, p->nAlloc); - // }else{ - // zNew = sqlite3_realloc(zOld, p->nAlloc); - // } - // if( zNew ){ - // if( zOld==0 ) memcpy(zNew, p->zText, p->nChar); - // p->zText = zNew; - // }else{ - // p->mallocFailed = 1; - // sqlite3StrAccumReset(p); - // return; - // } - // } - //} - //memcpy(&p->zText[p->nChar], z, N); - p.zText.Append( z.Substring( 0, N <= z.Length ? N : z.Length ) ); - //p.nChar += N; - } - - /* - ** Finish off a string by making sure it is zero-terminated. - ** Return a pointer to the resulting string. Return a NULL - ** pointer if any kind of error was encountered. - */ - static string sqlite3StrAccumFinish( StrAccum p ) - { - //if ( p->zText ) - //{ - // p->zText[p->nChar] = 0; - // if ( p->useMalloc && p->zText == p->zBase ) - // { - // if ( p->useMalloc == 1 ) - // { - // p->zText = sqlite3DbMallocRaw( p->db, p->nChar + 1 ); - // } - // else - // { - // p->zText = sqlite3_malloc( p->nChar + 1 ); - // } - // if ( p->zText ) - // { - // memcpy( p->zText, p->zBase, p->nChar + 1 ); - // } - // else - // { - // p->mallocFailed = 1; - // } - // } - //} - return p.zText.ToString(); - } - - /* - ** Reset an StrAccum string. Reclaim all malloced memory. - */ - static void sqlite3StrAccumReset( StrAccum p ) - { - //if ( p.zText.ToString() != p.zBase.ToString() ) - //{ - // if ( p.useMalloc == 1 ) - // { - // sqlite3DbFree( p.db, ref p.zText ); - // } - // else - // { - // sqlite3_free( ref p.zText ); - // } - //} - p.zText.Length = 0; - } - - /* - ** Initialize a string accumulator - */ - static void sqlite3StrAccumInit( StrAccum p, StringBuilder zBase, int n, int mx ) - { - //p.zBase.Length = 0; - //if ( p.zBase.Capacity < n ) - // p.zBase.Capacity = n; - p.zText.Length = 0; - if ( p.zText.Capacity < n ) - p.zText.Capacity = n; - p.db = null; - //p.nChar = 0; - //p.nAlloc = n; - p.mxAlloc = mx; - //p.useMalloc = 1; - //p.tooBig = 0; - //p.mallocFailed = 0; - } - /* - ** Print into memory obtained from sqliteMalloc(). Use the internal - ** %-conversion extensions. - */ - static StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); - static string sqlite3VMPrintf( sqlite3 db, string zFormat, params va_list[] ap ) - { - if ( zFormat == null ) - return null; - if ( ap.Length == 0 ) - return zFormat; - //string z; - Debug.Assert( db != null ); - sqlite3StrAccumInit( acc, null, SQLITE_PRINT_BUF_SIZE, - db.aLimit[SQLITE_LIMIT_LENGTH] ); - acc.db = db; - acc.zText.Length = 0; - sqlite3VXPrintf( acc, 1, zFormat, ap ); - // if ( acc.mallocFailed != 0 ) - // { - ////// db.mallocFailed = 1; - // } - return sqlite3StrAccumFinish( acc ); - } - /* - ** Print into memory obtained from sqliteMalloc(). Use the internal - ** %-conversion extensions. - */ - static string sqlite3MPrintf( sqlite3 db, string zFormat, params va_list[] ap ) - { - string z; - //va_list ap; - lock ( lock_va_list ) - { - va_start( ap, zFormat ); - z = sqlite3VMPrintf( db, zFormat, ap ); - va_end( ref ap ); - } - return z; - } + /* + ** Print into memory obtained from sqliteMalloc(). Use the internal + ** %-conversion extensions. + */ + static string sqlite3MPrintf(sqlite3 db, string zFormat, params va_list[] ap) { + string z; + //va_list ap; + lock (lock_va_list) { + va_start(ap, zFormat); + z = sqlite3VMPrintf(db, zFormat, ap); + va_end(ref ap); + } + return z; + } - /* - ** Like sqlite3MPrintf(), but call sqlite3DbFree() on zStr after formatting - ** the string and before returnning. This routine is intended to be used - ** to modify an existing string. For example: - ** - ** x = sqlite3MPrintf(db, x, "prefix %s suffix", x); - ** - */ - static string sqlite3MAppendf( sqlite3 db, string zStr, string zFormat, params va_list[] ap ) - { - string z; - //va_list ap; - lock ( lock_va_list ) - { - va_start( ap, zFormat ); - z = sqlite3VMPrintf( db, zFormat, ap ); - va_end( ref ap ); - sqlite3DbFree( db, ref zStr ); - } - return z; - } + /* + ** Like sqlite3MPrintf(), but call sqlite3DbFree() on zStr after formatting + ** the string and before returnning. This routine is intended to be used + ** to modify an existing string. For example: + ** + ** x = sqlite3MPrintf(db, x, "prefix %s suffix", x); + ** + */ + static string sqlite3MAppendf(sqlite3 db, string zStr, string zFormat, params va_list[] ap) { + string z; + //va_list ap; + lock (lock_va_list) { + va_start(ap, zFormat); + z = sqlite3VMPrintf(db, zFormat, ap); + va_end(ref ap); + sqlite3DbFree(db, ref zStr); + } + return z; + } - /* - ** Print into memory obtained from sqlite3Malloc(). Omit the internal - ** %-conversion extensions. - */ - static string sqlite3_vmprintf( string zFormat, params va_list[] ap ) - { - //StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); + /* + ** Print into memory obtained from sqlite3Malloc(). Omit the internal + ** %-conversion extensions. + */ + static string sqlite3_vmprintf(string zFormat, params va_list[] ap) { + //StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); #if !SQLITE_OMIT_AUTOINIT - if ( sqlite3_initialize() != 0 ) - return ""; + if (sqlite3_initialize() != 0) + return ""; #endif - sqlite3StrAccumInit( acc, null, SQLITE_PRINT_BUF_SIZE, SQLITE_PRINT_BUF_SIZE );//zBase).Length; - //acc.useMalloc = 2; - sqlite3VXPrintf( acc, 0, zFormat, ap ); - return sqlite3StrAccumFinish( acc ); - } + sqlite3StrAccumInit(acc, null, SQLITE_PRINT_BUF_SIZE, SQLITE_PRINT_BUF_SIZE);//zBase).Length; + //acc.useMalloc = 2; + sqlite3VXPrintf(acc, 0, zFormat, ap); + return sqlite3StrAccumFinish(acc); + } - /* - ** Print into memory obtained from sqlite3Malloc()(). Omit the internal - ** %-conversion extensions. - */ - static public string sqlite3_mprintf( string zFormat, params va_list[] ap ) - { //, ...){ - string z; -#if !SQLITE_OMIT_AUTOINIT - if ( sqlite3_initialize() != 0 ) - return ""; + /* + ** Print into memory obtained from sqlite3Malloc()(). Omit the internal + ** %-conversion extensions. + */ + static public string sqlite3_mprintf(string zFormat, params va_list[] ap) { //, ...){ + string z; +#if !SQLITE_OMIT_AUTOINIT + if (sqlite3_initialize() != 0) + return ""; #endif - //va_list ap; - lock ( lock_va_list ) - { - va_start( ap, zFormat ); - z = sqlite3_vmprintf( zFormat, ap ); - va_end( ref ap ); - } - return z; - } + //va_list ap; + lock (lock_va_list) { + va_start(ap, zFormat); + z = sqlite3_vmprintf(zFormat, ap); + va_end(ref ap); + } + return z; + } - /* - ** sqlite3_snprintf() works like snprintf() except that it ignores the - ** current locale settings. This is important for SQLite because we - ** are not able to use a "," as the decimal point in place of "." as - ** specified by some locales. - ** - ** Oops: The first two arguments of sqlite3_snprintf() are backwards - ** from the snprintf() standard. Unfortunately, it is too late to change - ** this without breaking compatibility, so we just have to live with the - ** mistake. - ** - ** sqlite3_vsnprintf() is the varargs version. - */ - static public void sqlite3_vsnprintf( int n, StringBuilder zBuf, string zFormat, params va_list[] ap ) - { - //StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); - if ( n <= 0 ) - return; - sqlite3StrAccumInit( acc, null, n, 0 ); - //acc.useMalloc = 0; - sqlite3VXPrintf( acc, 0, zFormat, ap ); - zBuf.Length = 0; - if ( n > 1 && n <= acc.zText.Length ) - acc.zText.Length = n - 1; - zBuf.Append( sqlite3StrAccumFinish( acc ) ); - return; - } + /* + ** sqlite3_snprintf() works like snprintf() except that it ignores the + ** current locale settings. This is important for SQLite because we + ** are not able to use a "," as the decimal point in place of "." as + ** specified by some locales. + ** + ** Oops: The first two arguments of sqlite3_snprintf() are backwards + ** from the snprintf() standard. Unfortunately, it is too late to change + ** this without breaking compatibility, so we just have to live with the + ** mistake. + ** + ** sqlite3_vsnprintf() is the varargs version. + */ + static public void sqlite3_vsnprintf(int n, StringBuilder zBuf, string zFormat, params va_list[] ap) { + //StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); + if (n <= 0) + return; + sqlite3StrAccumInit(acc, null, n, 0); + //acc.useMalloc = 0; + sqlite3VXPrintf(acc, 0, zFormat, ap); + zBuf.Length = 0; + if (n > 1 && n <= acc.zText.Length) + acc.zText.Length = n - 1; + zBuf.Append(sqlite3StrAccumFinish(acc)); + return; + } - static public void sqlite3_snprintf( int n, StringBuilder zBuf, string zFormat, params va_list[] ap ) - { - //string z; - //va_list ap; - lock ( lock_va_list ) - {//StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); - zBuf.EnsureCapacity( SQLITE_PRINT_BUF_SIZE ); - va_start( ap, zFormat ); - sqlite3_vsnprintf( n, zBuf, zFormat, ap ); - va_end( ref ap ); - } - return; - } + static public void sqlite3_snprintf(int n, StringBuilder zBuf, string zFormat, params va_list[] ap) { + //string z; + //va_list ap; + lock (lock_va_list) {//StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); + zBuf.EnsureCapacity(SQLITE_PRINT_BUF_SIZE); + va_start(ap, zFormat); + sqlite3_vsnprintf(n, zBuf, zFormat, ap); + va_end(ref ap); + } + return; + } - //static public string sqlite3_snprintf( int n, ref string zBuf, string zFormat, params va_list[] ap ) - //{ - // string z; - // //va_list ap; - // StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); + //static public string sqlite3_snprintf( int n, ref string zBuf, string zFormat, params va_list[] ap ) + //{ + // string z; + // //va_list ap; + // StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); - // if ( n <= 0 ) - // { - // return zBuf; - // } - // sqlite3StrAccumInit( acc, null, n, 0 ); - // //acc.useMalloc = 0; - // va_start( ap, zFormat ); - // sqlite3VXPrintf( acc, 0, zFormat, ap ); - // va_end( ap ); - // z = sqlite3StrAccumFinish( acc ); - // return ( zBuf = z ); - //} + // if ( n <= 0 ) + // { + // return zBuf; + // } + // sqlite3StrAccumInit( acc, null, n, 0 ); + // //acc.useMalloc = 0; + // va_start( ap, zFormat ); + // sqlite3VXPrintf( acc, 0, zFormat, ap ); + // va_end( ap ); + // z = sqlite3StrAccumFinish( acc ); + // return ( zBuf = z ); + //} - /* - ** This is the routine that actually formats the sqlite3_log() message. - ** We house it in a separate routine from sqlite3_log() to avoid using - ** stack space on small-stack systems when logging is disabled. - ** - ** sqlite3_log() must render into a static buffer. It cannot dynamically - ** allocate memory because it might be called while the memory allocator - ** mutex is held. - */ - static void renderLogMsg( int iErrCode, string zFormat, params object[] ap ) - { - //StrAccum acc; /* String accumulator */ - //char zMsg[SQLITE_PRINT_BUF_SIZE*3]; /* Complete log message */ + /* + ** This is the routine that actually formats the sqlite3_log() message. + ** We house it in a separate routine from sqlite3_log() to avoid using + ** stack space on small-stack systems when logging is disabled. + ** + ** sqlite3_log() must render into a static buffer. It cannot dynamically + ** allocate memory because it might be called while the memory allocator + ** mutex is held. + */ + static void renderLogMsg(int iErrCode, string zFormat, params object[] ap) { + //StrAccum acc; /* String accumulator */ + //char zMsg[SQLITE_PRINT_BUF_SIZE*3]; /* Complete log message */ - sqlite3StrAccumInit( acc, null, SQLITE_PRINT_BUF_SIZE * 3, 0 ); - //acc.useMalloc = 0; - sqlite3VXPrintf( acc, 0, zFormat, ap ); - sqlite3GlobalConfig.xLog( sqlite3GlobalConfig.pLogArg, iErrCode, - sqlite3StrAccumFinish( acc ) ); - } + sqlite3StrAccumInit(acc, null, SQLITE_PRINT_BUF_SIZE * 3, 0); + //acc.useMalloc = 0; + sqlite3VXPrintf(acc, 0, zFormat, ap); + sqlite3GlobalConfig.xLog(sqlite3GlobalConfig.pLogArg, iErrCode, + sqlite3StrAccumFinish(acc)); + } - /* - ** Format and write a message to the log if logging is enabled. - */ - static void sqlite3_log( int iErrCode, string zFormat, params va_list[] ap ) - { - if (sqlite3GlobalConfig != null && sqlite3GlobalConfig.xLog != null) - { - //va_list ap; /* Vararg list */ - lock ( lock_va_list ) - { - va_start( ap, zFormat ); - renderLogMsg( iErrCode, zFormat, ap ); - va_end( ref ap ); + /* + ** Format and write a message to the log if logging is enabled. + */ + static void sqlite3_log(int iErrCode, string zFormat, params va_list[] ap) { + if (sqlite3GlobalConfig != null && sqlite3GlobalConfig.xLog != null) { + //va_list ap; /* Vararg list */ + lock (lock_va_list) { + va_start(ap, zFormat); + renderLogMsg(iErrCode, zFormat, ap); + va_end(ref ap); + } + } } - } - } #if SQLITE_DEBUG || DEBUG || TRACE - /* -** A version of printf() that understands %lld. Used for debugging. -** The printf() built into some versions of windows does not understand %lld -** and segfaults if you give it a long long int. -*/ - static void sqlite3DebugPrintf( string zFormat, params va_list[] ap ) - { - //va_list ap; - lock ( lock_va_list ) - { - //StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); - sqlite3StrAccumInit( acc, null, SQLITE_PRINT_BUF_SIZE, 0 ); - //acc.useMalloc = 0; - va_start( ap, zFormat ); - sqlite3VXPrintf( acc, 0, zFormat, ap ); - va_end( ref ap ); - } + /* + ** A version of printf() that understands %lld. Used for debugging. + ** The printf() built into some versions of windows does not understand %lld + ** and segfaults if you give it a long long int. + */ + static void sqlite3DebugPrintf(string zFormat, params va_list[] ap) { + //va_list ap; + lock (lock_va_list) { + //StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); + sqlite3StrAccumInit(acc, null, SQLITE_PRINT_BUF_SIZE, 0); + //acc.useMalloc = 0; + va_start(ap, zFormat); + sqlite3VXPrintf(acc, 0, zFormat, ap); + va_end(ref ap); + } #if !SQLITE_WINRT - Console.Write( sqlite3StrAccumFinish( acc ) ); + Console.Write(sqlite3StrAccumFinish(acc)); #endif - //fflush(stdout); - } + //fflush(stdout); + } #endif #if !SQLITE_OMIT_TRACE - /* -** variable-argument wrapper around sqlite3VXPrintf(). -*/ - static void sqlite3XPrintf( StrAccum p, string zFormat, params object[] ap ) - { - //va_list ap; - lock ( lock_va_list ) - { - va_start( ap, zFormat ); - sqlite3VXPrintf( p, 1, zFormat, ap ); - va_end( ref ap ); - } - } + /* + ** variable-argument wrapper around sqlite3VXPrintf(). + */ + static void sqlite3XPrintf(StrAccum p, string zFormat, params object[] ap) { + //va_list ap; + lock (lock_va_list) { + va_start(ap, zFormat); + sqlite3VXPrintf(p, 1, zFormat, ap); + va_end(ref ap); + } + } #endif - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/random_c.cs b/Src/IronPython.SQLite/c#sqlite/random_c.cs index 254076e35..1aab77f64 100644 --- a/Src/IronPython.SQLite/c#sqlite/random_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/random_c.cs @@ -1,203 +1,186 @@ using System; -using System.Diagnostics; using i64 = System.Int64; -using u8 = System.Byte; using u32 = System.UInt32; -using u64 = System.UInt64; +using u8 = System.Byte; -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 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. - ** - ************************************************************************* - ** This file contains code to implement a pseudo-random number - ** generator (PRNG) for SQLite. - ** - ** Random numbers are used by some of the database backends in order - ** to generate random integer keys for tables or random filenames. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** This file contains code to implement a pseudo-random number + ** generator (PRNG) for SQLite. + ** + ** Random numbers are used by some of the database backends in order + ** to generate random integer keys for tables or random filenames. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" - /* All threads share a single random number generator. - ** This structure is the current state of the generator. - */ - public class sqlite3PrngType - { - public bool isInit; /* True if initialized */ - public int i; - public int j; /* State variables */ - public u8[] s = new u8[256]; /* State variables */ + /* All threads share a single random number generator. + ** This structure is the current state of the generator. + */ + public class sqlite3PrngType { + public bool isInit; /* True if initialized */ + public int i; + public int j; /* State variables */ + public u8[] s = new u8[256]; /* State variables */ - public sqlite3PrngType Copy() - { - sqlite3PrngType cp = (sqlite3PrngType)MemberwiseClone(); - cp.s = new u8[s.Length]; - Array.Copy( s, cp.s, s.Length ); - return cp; - } - } - public static sqlite3PrngType sqlite3Prng = new sqlite3PrngType(); - /* - ** Get a single 8-bit random value from the RC4 PRNG. The Mutex - ** must be held while executing this routine. - ** - ** Why not just use a library random generator like lrand48() for this? - ** Because the OP_NewRowid opcode in the VDBE depends on having a very - ** good source of random numbers. The lrand48() library function may - ** well be good enough. But maybe not. Or maybe lrand48() has some - ** subtle problems on some systems that could cause problems. It is hard - ** to know. To minimize the risk of problems due to bad lrand48() - ** implementations, SQLite uses this random number generator based - ** on RC4, which we know works very well. - ** - ** (Later): Actually, OP_NewRowid does not depend on a good source of - ** randomness any more. But we will leave this code in all the same. - */ - static u8 randomu8() - { - u8 t; + public sqlite3PrngType Copy() { + sqlite3PrngType cp = (sqlite3PrngType)MemberwiseClone(); + cp.s = new u8[s.Length]; + Array.Copy(s, cp.s, s.Length); + return cp; + } + } + public static sqlite3PrngType sqlite3Prng = new sqlite3PrngType(); + /* + ** Get a single 8-bit random value from the RC4 PRNG. The Mutex + ** must be held while executing this routine. + ** + ** Why not just use a library random generator like lrand48() for this? + ** Because the OP_NewRowid opcode in the VDBE depends on having a very + ** good source of random numbers. The lrand48() library function may + ** well be good enough. But maybe not. Or maybe lrand48() has some + ** subtle problems on some systems that could cause problems. It is hard + ** to know. To minimize the risk of problems due to bad lrand48() + ** implementations, SQLite uses this random number generator based + ** on RC4, which we know works very well. + ** + ** (Later): Actually, OP_NewRowid does not depend on a good source of + ** randomness any more. But we will leave this code in all the same. + */ + static u8 randomu8() { + u8 t; - /* The "wsdPrng" macro will resolve to the pseudo-random number generator - ** state vector. If writable static data is unsupported on the target, - ** we have to locate the state vector at run-time. In the more common - ** case where writable static data is supported, wsdPrng can refer directly - ** to the "sqlite3Prng" state vector declared above. - */ + /* The "wsdPrng" macro will resolve to the pseudo-random number generator + ** state vector. If writable static data is unsupported on the target, + ** we have to locate the state vector at run-time. In the more common + ** case where writable static data is supported, wsdPrng can refer directly + ** to the "sqlite3Prng" state vector declared above. + */ #if SQLITE_OMIT_WSD struct sqlite3PrngType *p = &GLOBAL(struct sqlite3PrngType, sqlite3Prng); //# define wsdPrng p[0] #else - //# define wsdPrng sqlite3Prng - sqlite3PrngType wsdPrng = sqlite3Prng; + //# define wsdPrng sqlite3Prng + sqlite3PrngType wsdPrng = sqlite3Prng; #endif - /* Initialize the state of the random number generator once, -** the first time this routine is called. The seed value does -** not need to contain a lot of randomness since we are not -** trying to do secure encryption or anything like that... -** -** Nothing in this file or anywhere else in SQLite does any kind of -** encryption. The RC4 algorithm is being used as a PRNG (pseudo-random -** number generator) not as an encryption device. -*/ - if ( !wsdPrng.isInit ) - { - int i; - u8[] k = new u8[256]; - wsdPrng.j = 0; - wsdPrng.i = 0; - sqlite3OsRandomness( sqlite3_vfs_find( "" ), 256, k ); - for ( i = 0; i < 255; i++ ) - { - wsdPrng.s[i] = (u8)i; - } - for ( i = 0; i < 255; i++ ) - { - wsdPrng.j = (u8)( wsdPrng.j + wsdPrng.s[i] + k[i] ); - t = wsdPrng.s[wsdPrng.j]; - wsdPrng.s[wsdPrng.j] = wsdPrng.s[i]; - wsdPrng.s[i] = t; - } - wsdPrng.isInit = true; - } - - /* Generate and return single random u8 + /* Initialize the state of the random number generator once, + ** the first time this routine is called. The seed value does + ** not need to contain a lot of randomness since we are not + ** trying to do secure encryption or anything like that... + ** + ** Nothing in this file or anywhere else in SQLite does any kind of + ** encryption. The RC4 algorithm is being used as a PRNG (pseudo-random + ** number generator) not as an encryption device. */ - wsdPrng.i++; - t = wsdPrng.s[(u8)wsdPrng.i]; - wsdPrng.j = (u8)( wsdPrng.j + t ); - wsdPrng.s[(u8)wsdPrng.i] = wsdPrng.s[wsdPrng.j]; - wsdPrng.s[wsdPrng.j] = t; - t += wsdPrng.s[(u8)wsdPrng.i]; - return wsdPrng.s[t]; - } + if (!wsdPrng.isInit) { + int i; + u8[] k = new u8[256]; + wsdPrng.j = 0; + wsdPrng.i = 0; + sqlite3OsRandomness(sqlite3_vfs_find(""), 256, k); + for (i = 0; i < 255; i++) { + wsdPrng.s[i] = (u8)i; + } + for (i = 0; i < 255; i++) { + wsdPrng.j = (u8)(wsdPrng.j + wsdPrng.s[i] + k[i]); + t = wsdPrng.s[wsdPrng.j]; + wsdPrng.s[wsdPrng.j] = wsdPrng.s[i]; + wsdPrng.s[i] = t; + } + wsdPrng.isInit = true; + } - /* - ** Return N random u8s. - */ - static void sqlite3_randomness( int N, ref i64 pBuf ) - { - //u8[] zBuf = new u8[N]; - pBuf = 0; + /* Generate and return single random u8 + */ + wsdPrng.i++; + t = wsdPrng.s[(u8)wsdPrng.i]; + wsdPrng.j = (u8)(wsdPrng.j + t); + wsdPrng.s[(u8)wsdPrng.i] = wsdPrng.s[wsdPrng.j]; + wsdPrng.s[wsdPrng.j] = t; + t += wsdPrng.s[(u8)wsdPrng.i]; + return wsdPrng.s[t]; + } + + /* + ** Return N random u8s. + */ + static void sqlite3_randomness(int N, ref i64 pBuf) { + //u8[] zBuf = new u8[N]; + pBuf = 0; #if SQLITE_THREADSAFE - sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_PRNG ); + sqlite3_mutex mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PRNG); #endif - sqlite3_mutex_enter( mutex ); - while ( N-- > 0 ) - { - pBuf = (u32)( ( pBuf << 8 ) + randomu8() );// zBuf[N] = randomu8(); - } - sqlite3_mutex_leave( mutex ); - } + sqlite3_mutex_enter(mutex); + while (N-- > 0) { + pBuf = (u32)((pBuf << 8) + randomu8());// zBuf[N] = randomu8(); + } + sqlite3_mutex_leave(mutex); + } - static void sqlite3_randomness( byte[] pBuf, int Offset, int N ) - { - i64 iBuf = System.DateTime.Now.Ticks; + static void sqlite3_randomness(byte[] pBuf, int Offset, int N) { + i64 iBuf = System.DateTime.Now.Ticks; #if SQLITE_THREADSAFE - sqlite3_mutex mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PRNG); + sqlite3_mutex mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PRNG); #endif - sqlite3_mutex_enter( mutex ); - while ( N-- > 0 ) - { - iBuf = (u32)( ( iBuf << 8 ) + randomu8() );// zBuf[N] = randomu8(); - pBuf[Offset++] = (byte)iBuf; - } - sqlite3_mutex_leave( mutex ); - } + sqlite3_mutex_enter(mutex); + while (N-- > 0) { + iBuf = (u32)((iBuf << 8) + randomu8());// zBuf[N] = randomu8(); + pBuf[Offset++] = (byte)iBuf; + } + sqlite3_mutex_leave(mutex); + } #if !SQLITE_OMIT_BUILTIN_TEST - /* -** For testing purposes, we sometimes want to preserve the state of -** PRNG and restore the PRNG to its saved state at a later time, or -** to reset the PRNG to its initial state. These routines accomplish -** those tasks. -** -** The sqlite3_test_control() interface calls these routines to -** control the PRNG. -*/ - static sqlite3PrngType sqlite3SavedPrng = null; - static void sqlite3PrngSaveState() - { - sqlite3SavedPrng = sqlite3Prng.Copy(); - // memcpy( - // &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng), - // &GLOBAL(struct sqlite3PrngType, sqlite3Prng), - // sizeof(sqlite3Prng) - //); - } - static void sqlite3PrngRestoreState() - { - sqlite3Prng = sqlite3SavedPrng.Copy(); - //memcpy( - // &GLOBAL(struct sqlite3PrngType, sqlite3Prng), - // &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng), - // sizeof(sqlite3Prng) - //); - } - static void sqlite3PrngResetState() - { - sqlite3Prng.isInit = false;// GLOBAL(struct sqlite3PrngType, sqlite3Prng).isInit = 0; - } + /* + ** For testing purposes, we sometimes want to preserve the state of + ** PRNG and restore the PRNG to its saved state at a later time, or + ** to reset the PRNG to its initial state. These routines accomplish + ** those tasks. + ** + ** The sqlite3_test_control() interface calls these routines to + ** control the PRNG. + */ + static sqlite3PrngType sqlite3SavedPrng = null; + static void sqlite3PrngSaveState() { + sqlite3SavedPrng = sqlite3Prng.Copy(); + // memcpy( + // &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng), + // &GLOBAL(struct sqlite3PrngType, sqlite3Prng), + // sizeof(sqlite3Prng) + //); + } + static void sqlite3PrngRestoreState() { + sqlite3Prng = sqlite3SavedPrng.Copy(); + //memcpy( + // &GLOBAL(struct sqlite3PrngType, sqlite3Prng), + // &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng), + // sizeof(sqlite3Prng) + //); + } + static void sqlite3PrngResetState() { + sqlite3Prng.isInit = false;// GLOBAL(struct sqlite3PrngType, sqlite3Prng).isInit = 0; + } #endif //* SQLITE_OMIT_BUILTIN_TEST */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/resolve_c.cs b/Src/IronPython.SQLite/c#sqlite/resolve_c.cs index a8bc5e437..ee2c6f246 100644 --- a/Src/IronPython.SQLite/c#sqlite/resolve_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/resolve_c.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics; -using System.Text; using Bitmask = System.UInt64; using i16 = System.Int16; @@ -14,556 +13,487 @@ using ynVar = System.Int32; #endif -namespace Community.CsharpSqlite -{ - using sqlite3_value = Sqlite3.Mem; - - public partial class Sqlite3 - { - /* - ** 2008 August 18 - ** - ** 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 contains routines used for walking the parser tree and - ** resolve all identifiers by associating them with a particular - ** table and column. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include - //#include - - /* - ** Turn the pExpr expression into an alias for the iCol-th column of the - ** result set in pEList. - ** - ** If the result set column is a simple column reference, then this routine - ** makes an exact copy. But for any other kind of expression, this - ** routine make a copy of the result set column as the argument to the - ** TK_AS operator. The TK_AS operator causes the expression to be - ** evaluated just once and then reused for each alias. - ** - ** The reason for suppressing the TK_AS term when the expression is a simple - ** column reference is so that the column reference will be recognized as - ** usable by indices within the WHERE clause processing logic. - ** - ** Hack: The TK_AS operator is inhibited if zType[0]=='G'. This means - ** that in a GROUP BY clause, the expression is evaluated twice. Hence: - ** - ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY x - ** - ** Is equivalent to: - ** - ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY random()%5 - ** - ** The result of random()%5 in the GROUP BY clause is probably different - ** from the result in the result-set. We might fix this someday. Or - ** then again, we might not... - */ - static void resolveAlias( - Parse pParse, /* Parsing context */ - ExprList pEList, /* A result set */ - int iCol, /* A column in the result set. 0..pEList.nExpr-1 */ - Expr pExpr, /* Transform this into an alias to the result set */ - string zType /* "GROUP" or "ORDER" or "" */ - ) - { - Expr pOrig; /* The iCol-th column of the result set */ - Expr pDup; /* Copy of pOrig */ - sqlite3 db; /* The database connection */ - - Debug.Assert( iCol >= 0 && iCol < pEList.nExpr ); - pOrig = pEList.a[iCol].pExpr; - Debug.Assert( pOrig != null ); - Debug.Assert( ( pOrig.flags & EP_Resolved ) != 0 ); - db = pParse.db; - if ( pOrig.op != TK_COLUMN && ( zType.Length == 0 || zType[0] != 'G' ) ) - { - pDup = sqlite3ExprDup( db, pOrig, 0 ); - pDup = sqlite3PExpr( pParse, TK_AS, pDup, null, null ); - if ( pDup == null ) - return; - if ( pEList.a[iCol].iAlias == 0 ) - { - pEList.a[iCol].iAlias = (u16)( ++pParse.nAlias ); - } - pDup.iTable = pEList.a[iCol].iAlias; - } - else if ( ExprHasProperty( pOrig, EP_IntValue ) || pOrig.u.zToken == null ) - { - pDup = sqlite3ExprDup( db, pOrig, 0 ); - if ( pDup == null ) - return; - } - else - { - string zToken = pOrig.u.zToken; - Debug.Assert( zToken != null ); - pOrig.u.zToken = null; - pDup = sqlite3ExprDup( db, pOrig, 0 ); - pOrig.u.zToken = zToken; - if ( pDup == null ) - return; - Debug.Assert( ( pDup.flags & ( EP_Reduced | EP_TokenOnly ) ) == 0 ); - pDup.flags2 |= EP2_MallocedToken; - pDup.u.zToken = zToken;// sqlite3DbStrDup( db, zToken ); - } - if ( ( pExpr.flags & EP_ExpCollate ) != 0 ) - { - pDup.pColl = pExpr.pColl; - pDup.flags |= EP_ExpCollate; - } - - /* Before calling sqlite3ExprDelete(), set the EP_Static flag. This - ** prevents ExprDelete() from deleting the Expr structure itself, - ** allowing it to be repopulated by the memcpy() on the following line. - */ - ExprSetProperty( pExpr, EP_Static ); - sqlite3ExprDelete( db, ref pExpr ); - pExpr.CopyFrom( pDup ); //memcpy(pExpr, pDup, sizeof(*pExpr)); - sqlite3DbFree( db, ref pDup ); - } +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2008 August 18 + ** + ** 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 contains routines used for walking the parser tree and + ** resolve all identifiers by associating them with a particular + ** table and column. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include + //#include - /* - ** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up - ** that name in the set of source tables in pSrcList and make the pExpr - ** expression node refer back to that source column. The following changes - ** are made to pExpr: - ** - ** pExpr->iDb Set the index in db->aDb[] of the database X - ** (even if X is implied). - ** pExpr->iTable Set to the cursor number for the table obtained - ** from pSrcList. - ** pExpr->pTab Points to the Table structure of X.Y (even if - ** X and/or Y are implied.) - ** pExpr->iColumn Set to the column number within the table. - ** pExpr->op Set to TK_COLUMN. - ** pExpr->pLeft Any expression this points to is deleted - ** pExpr->pRight Any expression this points to is deleted. - ** - ** The zDb variable is the name of the database (the "X"). This value may be - ** NULL meaning that name is of the form Y.Z or Z. Any available database - ** can be used. The zTable variable is the name of the table (the "Y"). This - ** value can be NULL if zDb is also NULL. If zTable is NULL it - ** means that the form of the name is Z and that columns from any table - ** can be used. - ** - ** If the name cannot be resolved unambiguously, leave an error message - ** in pParse and return WRC_Abort. Return WRC_Prune on success. - */ - static int lookupName( - Parse pParse, /* The parsing context */ - string zDb, /* Name of the database containing table, or NULL */ - string zTab, /* Name of table containing column, or NULL */ - string zCol, /* Name of the column. */ - NameContext pNC, /* The name context used to resolve the name */ - Expr pExpr /* Make this EXPR node point to the selected column */ - ) - { - int i, j; /* Loop counters */ - int cnt = 0; /* Number of matching column names */ - int cntTab = 0; /* Number of matching table names */ - sqlite3 db = pParse.db; /* The database connection */ - SrcList_item pItem; /* Use for looping over pSrcList items */ - SrcList_item pMatch = null; /* The matching pSrcList item */ - NameContext pTopNC = pNC; /* First namecontext in the list */ - Schema pSchema = null; /* Schema of the expression */ - int isTrigger = 0; - - Debug.Assert( pNC != null ); /* the name context cannot be NULL. */ - Debug.Assert( zCol != null ); /* The Z in X.Y.Z cannot be NULL */ - Debug.Assert( !ExprHasAnyProperty( pExpr, EP_TokenOnly | EP_Reduced ) ); - - /* Initialize the node to no-match */ - pExpr.iTable = -1; - pExpr.pTab = null; - ExprSetIrreducible( pExpr ); - - /* Start at the inner-most context and move outward until a match is found */ - while ( pNC != null && cnt == 0 ) - { - ExprList pEList; - SrcList pSrcList = pNC.pSrcList; - - if ( pSrcList != null ) - { - for ( i = 0; i < pSrcList.nSrc; i++ )//, pItem++ ) - { - pItem = pSrcList.a[i]; - Table pTab; - int iDb; - Column pCol; - - pTab = pItem.pTab; - Debug.Assert( pTab != null && pTab.zName != null ); - iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); - Debug.Assert( pTab.nCol > 0 ); - if ( zTab != null ) - { - if ( pItem.zAlias != null ) - { - string zTabName = pItem.zAlias; - if ( !zTabName.Equals( zTab, StringComparison.OrdinalIgnoreCase ) ) - continue; - } - else - { - string zTabName = pTab.zName; - if ( NEVER( zTabName == null ) || !zTabName.Equals( zTab ,StringComparison.OrdinalIgnoreCase ) ) - { - continue; - } - if ( zDb != null && !db.aDb[iDb].zName.Equals( zDb ,StringComparison.OrdinalIgnoreCase ) ) - { - continue; + /* + ** Turn the pExpr expression into an alias for the iCol-th column of the + ** result set in pEList. + ** + ** If the result set column is a simple column reference, then this routine + ** makes an exact copy. But for any other kind of expression, this + ** routine make a copy of the result set column as the argument to the + ** TK_AS operator. The TK_AS operator causes the expression to be + ** evaluated just once and then reused for each alias. + ** + ** The reason for suppressing the TK_AS term when the expression is a simple + ** column reference is so that the column reference will be recognized as + ** usable by indices within the WHERE clause processing logic. + ** + ** Hack: The TK_AS operator is inhibited if zType[0]=='G'. This means + ** that in a GROUP BY clause, the expression is evaluated twice. Hence: + ** + ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY x + ** + ** Is equivalent to: + ** + ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY random()%5 + ** + ** The result of random()%5 in the GROUP BY clause is probably different + ** from the result in the result-set. We might fix this someday. Or + ** then again, we might not... + */ + static void resolveAlias( + Parse pParse, /* Parsing context */ + ExprList pEList, /* A result set */ + int iCol, /* A column in the result set. 0..pEList.nExpr-1 */ + Expr pExpr, /* Transform this into an alias to the result set */ + string zType /* "GROUP" or "ORDER" or "" */ + ) { + Expr pOrig; /* The iCol-th column of the result set */ + Expr pDup; /* Copy of pOrig */ + sqlite3 db; /* The database connection */ + + Debug.Assert(iCol >= 0 && iCol < pEList.nExpr); + pOrig = pEList.a[iCol].pExpr; + Debug.Assert(pOrig != null); + Debug.Assert((pOrig.flags & EP_Resolved) != 0); + db = pParse.db; + if (pOrig.op != TK_COLUMN && (zType.Length == 0 || zType[0] != 'G')) { + pDup = sqlite3ExprDup(db, pOrig, 0); + pDup = sqlite3PExpr(pParse, TK_AS, pDup, null, null); + if (pDup == null) + return; + if (pEList.a[iCol].iAlias == 0) { + pEList.a[iCol].iAlias = (u16)(++pParse.nAlias); } - } + pDup.iTable = pEList.a[iCol].iAlias; + } else if (ExprHasProperty(pOrig, EP_IntValue) || pOrig.u.zToken == null) { + pDup = sqlite3ExprDup(db, pOrig, 0); + if (pDup == null) + return; + } else { + string zToken = pOrig.u.zToken; + Debug.Assert(zToken != null); + pOrig.u.zToken = null; + pDup = sqlite3ExprDup(db, pOrig, 0); + pOrig.u.zToken = zToken; + if (pDup == null) + return; + Debug.Assert((pDup.flags & (EP_Reduced | EP_TokenOnly)) == 0); + pDup.flags2 |= EP2_MallocedToken; + pDup.u.zToken = zToken;// sqlite3DbStrDup( db, zToken ); } - if ( 0 == ( cntTab++ ) ) - { - pExpr.iTable = pItem.iCursor; - pExpr.pTab = pTab; - pSchema = pTab.pSchema; - pMatch = pItem; + if ((pExpr.flags & EP_ExpCollate) != 0) { + pDup.pColl = pExpr.pColl; + pDup.flags |= EP_ExpCollate; } - for ( j = 0; j < pTab.nCol; j++ )//, pCol++ ) - { - pCol = pTab.aCol[j]; - if ( pCol.zName.Equals( zCol, StringComparison.OrdinalIgnoreCase ) ) - { - IdList pUsing; - cnt++; - pExpr.iTable = pItem.iCursor; - pExpr.pTab = pTab; - pMatch = pItem; - pSchema = pTab.pSchema; - /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */ - pExpr.iColumn = (short)( j == pTab.iPKey ? -1 : j ); - if ( i < pSrcList.nSrc - 1 ) - { - if ( ( pSrcList.a[i + 1].jointype & JT_NATURAL ) != 0 )// pItem[1].jointype - { - /* If this match occurred in the left table of a natural join, - ** then skip the right table to avoid a duplicate match */ - //pItem++; - i++; - } - else if ( ( pUsing = pSrcList.a[i + 1].pUsing ) != null )//pItem[1].pUsing - { - /* If this match occurs on a column that is in the USING clause - ** of a join, skip the search of the right table of the join - ** to avoid a duplicate match there. */ - int k; - for ( k = 0; k < pUsing.nId; k++ ) + + /* Before calling sqlite3ExprDelete(), set the EP_Static flag. This + ** prevents ExprDelete() from deleting the Expr structure itself, + ** allowing it to be repopulated by the memcpy() on the following line. + */ + ExprSetProperty(pExpr, EP_Static); + sqlite3ExprDelete(db, ref pExpr); + pExpr.CopyFrom(pDup); //memcpy(pExpr, pDup, sizeof(*pExpr)); + sqlite3DbFree(db, ref pDup); + } + + /* + ** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up + ** that name in the set of source tables in pSrcList and make the pExpr + ** expression node refer back to that source column. The following changes + ** are made to pExpr: + ** + ** pExpr->iDb Set the index in db->aDb[] of the database X + ** (even if X is implied). + ** pExpr->iTable Set to the cursor number for the table obtained + ** from pSrcList. + ** pExpr->pTab Points to the Table structure of X.Y (even if + ** X and/or Y are implied.) + ** pExpr->iColumn Set to the column number within the table. + ** pExpr->op Set to TK_COLUMN. + ** pExpr->pLeft Any expression this points to is deleted + ** pExpr->pRight Any expression this points to is deleted. + ** + ** The zDb variable is the name of the database (the "X"). This value may be + ** NULL meaning that name is of the form Y.Z or Z. Any available database + ** can be used. The zTable variable is the name of the table (the "Y"). This + ** value can be NULL if zDb is also NULL. If zTable is NULL it + ** means that the form of the name is Z and that columns from any table + ** can be used. + ** + ** If the name cannot be resolved unambiguously, leave an error message + ** in pParse and return WRC_Abort. Return WRC_Prune on success. + */ + static int lookupName( + Parse pParse, /* The parsing context */ + string zDb, /* Name of the database containing table, or NULL */ + string zTab, /* Name of table containing column, or NULL */ + string zCol, /* Name of the column. */ + NameContext pNC, /* The name context used to resolve the name */ + Expr pExpr /* Make this EXPR node point to the selected column */ + ) { + int i, j; /* Loop counters */ + int cnt = 0; /* Number of matching column names */ + int cntTab = 0; /* Number of matching table names */ + sqlite3 db = pParse.db; /* The database connection */ + SrcList_item pItem; /* Use for looping over pSrcList items */ + SrcList_item pMatch = null; /* The matching pSrcList item */ + NameContext pTopNC = pNC; /* First namecontext in the list */ + Schema pSchema = null; /* Schema of the expression */ + int isTrigger = 0; + + Debug.Assert(pNC != null); /* the name context cannot be NULL. */ + Debug.Assert(zCol != null); /* The Z in X.Y.Z cannot be NULL */ + Debug.Assert(!ExprHasAnyProperty(pExpr, EP_TokenOnly | EP_Reduced)); + + /* Initialize the node to no-match */ + pExpr.iTable = -1; + pExpr.pTab = null; + ExprSetIrreducible(pExpr); + + /* Start at the inner-most context and move outward until a match is found */ + while (pNC != null && cnt == 0) { + ExprList pEList; + SrcList pSrcList = pNC.pSrcList; + + if (pSrcList != null) { + for (i = 0; i < pSrcList.nSrc; i++)//, pItem++ ) { - if ( pUsing.a[k].zName.Equals( zCol ,StringComparison.OrdinalIgnoreCase ) ) - { - //pItem++; - i++; - break; - } + pItem = pSrcList.a[i]; + Table pTab; + int iDb; + Column pCol; + + pTab = pItem.pTab; + Debug.Assert(pTab != null && pTab.zName != null); + iDb = sqlite3SchemaToIndex(db, pTab.pSchema); + Debug.Assert(pTab.nCol > 0); + if (zTab != null) { + if (pItem.zAlias != null) { + string zTabName = pItem.zAlias; + if (!zTabName.Equals(zTab, StringComparison.OrdinalIgnoreCase)) + continue; + } else { + string zTabName = pTab.zName; + if (NEVER(zTabName == null) || !zTabName.Equals(zTab, StringComparison.OrdinalIgnoreCase)) { + continue; + } + if (zDb != null && !db.aDb[iDb].zName.Equals(zDb, StringComparison.OrdinalIgnoreCase)) { + continue; + } + } + } + if (0 == (cntTab++)) { + pExpr.iTable = pItem.iCursor; + pExpr.pTab = pTab; + pSchema = pTab.pSchema; + pMatch = pItem; + } + for (j = 0; j < pTab.nCol; j++)//, pCol++ ) + { + pCol = pTab.aCol[j]; + if (pCol.zName.Equals(zCol, StringComparison.OrdinalIgnoreCase)) { + IdList pUsing; + cnt++; + pExpr.iTable = pItem.iCursor; + pExpr.pTab = pTab; + pMatch = pItem; + pSchema = pTab.pSchema; + /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */ + pExpr.iColumn = (short)(j == pTab.iPKey ? -1 : j); + if (i < pSrcList.nSrc - 1) { + if ((pSrcList.a[i + 1].jointype & JT_NATURAL) != 0)// pItem[1].jointype + { + /* If this match occurred in the left table of a natural join, + ** then skip the right table to avoid a duplicate match */ + //pItem++; + i++; + } else if ((pUsing = pSrcList.a[i + 1].pUsing) != null)//pItem[1].pUsing + { + /* If this match occurs on a column that is in the USING clause + ** of a join, skip the search of the right table of the join + ** to avoid a duplicate match there. */ + int k; + for (k = 0; k < pUsing.nId; k++) { + if (pUsing.a[k].zName.Equals(zCol, StringComparison.OrdinalIgnoreCase)) { + //pItem++; + i++; + break; + } + } + } + } + break; + } + } } - } } - break; - } - } - } - } #if !SQLITE_OMIT_TRIGGER - /* If we have not already resolved the name, then maybe - ** it is a new.* or old.* trigger argument reference - */ - if ( zDb == null && zTab != null && cnt == 0 && pParse.pTriggerTab != null ) - { - int op = pParse.eTriggerOp; - Table pTab = null; - Debug.Assert( op == TK_DELETE || op == TK_UPDATE || op == TK_INSERT ); - if ( op != TK_DELETE && "new".Equals( zTab ,StringComparison.OrdinalIgnoreCase ) ) - { - pExpr.iTable = 1; - pTab = pParse.pTriggerTab; - } - else if ( op != TK_INSERT && "old".Equals( zTab ,StringComparison.OrdinalIgnoreCase ) ) - { - pExpr.iTable = 0; - pTab = pParse.pTriggerTab; - } - - if ( pTab != null ) - { - int iCol; - pSchema = pTab.pSchema; - cntTab++; - for ( iCol = 0; iCol < pTab.nCol; iCol++ ) - { - Column pCol = pTab.aCol[iCol]; - if ( pCol.zName.Equals( zCol ,StringComparison.OrdinalIgnoreCase ) ) - { - if ( iCol == pTab.iPKey ) - { - iCol = -1; + /* If we have not already resolved the name, then maybe + ** it is a new.* or old.* trigger argument reference + */ + if (zDb == null && zTab != null && cnt == 0 && pParse.pTriggerTab != null) { + int op = pParse.eTriggerOp; + Table pTab = null; + Debug.Assert(op == TK_DELETE || op == TK_UPDATE || op == TK_INSERT); + if (op != TK_DELETE && "new".Equals(zTab, StringComparison.OrdinalIgnoreCase)) { + pExpr.iTable = 1; + pTab = pParse.pTriggerTab; + } else if (op != TK_INSERT && "old".Equals(zTab, StringComparison.OrdinalIgnoreCase)) { + pExpr.iTable = 0; + pTab = pParse.pTriggerTab; + } + + if (pTab != null) { + int iCol; + pSchema = pTab.pSchema; + cntTab++; + for (iCol = 0; iCol < pTab.nCol; iCol++) { + Column pCol = pTab.aCol[iCol]; + if (pCol.zName.Equals(zCol, StringComparison.OrdinalIgnoreCase)) { + if (iCol == pTab.iPKey) { + iCol = -1; + } + break; + } + } + if (iCol >= pTab.nCol && sqlite3IsRowid(zCol)) { + iCol = -1; /* IMP: R-44911-55124 */ + } + if (iCol < pTab.nCol) { + cnt++; + if (iCol < 0) { + pExpr.affinity = SQLITE_AFF_INTEGER; + } else if (pExpr.iTable == 0) { + testcase(iCol == 31); + testcase(iCol == 32); + pParse.oldmask |= (iCol >= 32 ? 0xffffffff : (((u32)1) << iCol)); + } else { + testcase(iCol == 31); + testcase(iCol == 32); + pParse.newmask |= (iCol >= 32 ? 0xffffffff : (((u32)1) << iCol)); + } + pExpr.iColumn = (i16)iCol; + pExpr.pTab = pTab; + isTrigger = 1; + } + } + } +#endif //* !SQLITE_OMIT_TRIGGER) */ + + /* + ** Perhaps the name is a reference to the ROWID + */ + if (cnt == 0 && cntTab == 1 && sqlite3IsRowid(zCol)) { + cnt = 1; + pExpr.iColumn = -1; /* IMP: R-44911-55124 */ + pExpr.affinity = SQLITE_AFF_INTEGER; + } + + /* + ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z + ** might refer to an result-set alias. This happens, for example, when + ** we are resolving names in the WHERE clause of the following command: + ** + ** SELECT a+b AS x FROM table WHERE x<10; + ** + ** In cases like this, replace pExpr with a copy of the expression that + ** forms the result set entry ("a+b" in the example) and return immediately. + ** Note that the expression in the result set should have already been + ** resolved by the time the WHERE clause is resolved. + */ + if (cnt == 0 && (pEList = pNC.pEList) != null && zTab == null) { + for (j = 0; j < pEList.nExpr; j++) { + string zAs = pEList.a[j].zName; + if (zAs != null && zAs.Equals(zCol, StringComparison.OrdinalIgnoreCase)) { + Expr pOrig; + Debug.Assert(pExpr.pLeft == null && pExpr.pRight == null); + Debug.Assert(pExpr.x.pList == null); + Debug.Assert(pExpr.x.pSelect == null); + pOrig = pEList.a[j].pExpr; + if (0 == pNC.allowAgg && ExprHasProperty(pOrig, EP_Agg)) { + sqlite3ErrorMsg(pParse, "misuse of aliased aggregate %s", zAs); + return WRC_Abort; + } + resolveAlias(pParse, pEList, j, pExpr, ""); + cnt = 1; + pMatch = null; + Debug.Assert(zTab == null && zDb == null); + goto lookupname_end; + } + } + } + + /* Advance to the next name context. The loop will exit when either + ** we have a match (cnt>0) or when we run out of name contexts. + */ + if (cnt == 0) { + pNC = pNC.pNext; } - break; - } } - if ( iCol >= pTab.nCol && sqlite3IsRowid( zCol ) ) - { - iCol = -1; /* IMP: R-44911-55124 */ + + /* + ** If X and Y are NULL (in other words if only the column name Z is + ** supplied) and the value of Z is enclosed in double-quotes, then + ** Z is a string literal if it doesn't match any column names. In that + ** case, we need to return right away and not make any changes to + ** pExpr. + ** + ** Because no reference was made to outer contexts, the pNC.nRef + ** fields are not changed in any context. + */ + if (cnt == 0 && zTab == null && ExprHasProperty(pExpr, EP_DblQuoted)) { + pExpr.op = TK_STRING; + pExpr.pTab = null; + return WRC_Prune; } - if ( iCol < pTab.nCol ) - { - cnt++; - if ( iCol < 0 ) - { - pExpr.affinity = SQLITE_AFF_INTEGER; - } - else if ( pExpr.iTable == 0 ) - { - testcase( iCol == 31 ); - testcase( iCol == 32 ); - pParse.oldmask |= ( iCol >= 32 ? 0xffffffff : ( ( (u32)1 ) << iCol ) ); - } - else - { - testcase( iCol == 31 ); - testcase( iCol == 32 ); - pParse.newmask |= ( iCol >= 32 ? 0xffffffff : ( ( (u32)1 ) << iCol ) ); - } - pExpr.iColumn = (i16)iCol; - pExpr.pTab = pTab; - isTrigger = 1; + + /* + ** cnt==0 means there was not match. cnt>1 means there were two or + ** more matches. Either way, we have an error. + */ + if (cnt != 1) { + string zErr; + zErr = cnt == 0 ? "no such column" : "ambiguous column name"; + if (zDb != null) { + sqlite3ErrorMsg(pParse, "%s: %s.%s.%s", zErr, zDb, zTab, zCol); + } else if (zTab != null) { + sqlite3ErrorMsg(pParse, "%s: %s.%s", zErr, zTab, zCol); + } else { + sqlite3ErrorMsg(pParse, "%s: %s", zErr, zCol); + } + pParse.checkSchema = 1; + pTopNC.nErr++; + } + + /* If a column from a table in pSrcList is referenced, then record + ** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes + ** bit 0 to be set. Column 1 sets bit 1. And so forth. If the + ** column number is greater than the number of bits in the bitmask + ** then set the high-order bit of the bitmask. + */ + if (pExpr.iColumn >= 0 && pMatch != null) { + int n = pExpr.iColumn; + testcase(n == BMS - 1); + if (n >= BMS) { + n = BMS - 1; + } + Debug.Assert(pMatch.iCursor == pExpr.iTable); + pMatch.colUsed |= ((Bitmask)1) << n; + } + + /* Clean up and return + */ + sqlite3ExprDelete(db, ref pExpr.pLeft); + pExpr.pLeft = null; + sqlite3ExprDelete(db, ref pExpr.pRight); + pExpr.pRight = null; + pExpr.op = (u8)(isTrigger != 0 ? TK_TRIGGER : TK_COLUMN); + lookupname_end: + if (cnt == 1) { + Debug.Assert(pNC != null); + sqlite3AuthRead(pParse, pExpr, pSchema, pNC.pSrcList); + /* Increment the nRef value on all name contexts from TopNC up to + ** the point where the name matched. */ + for (; ; ) + { + Debug.Assert(pTopNC != null); + pTopNC.nRef++; + if (pTopNC == pNC) + break; + pTopNC = pTopNC.pNext; + } + return WRC_Prune; + } else { + return WRC_Abort; } - } } -#endif //* !SQLITE_OMIT_TRIGGER) */ /* - ** Perhaps the name is a reference to the ROWID + ** Allocate and return a pointer to an expression to load the column iCol + ** from datasource iSrc in SrcList pSrc. */ - if ( cnt == 0 && cntTab == 1 && sqlite3IsRowid( zCol ) ) - { - cnt = 1; - pExpr.iColumn = -1; /* IMP: R-44911-55124 */ - pExpr.affinity = SQLITE_AFF_INTEGER; + static Expr sqlite3CreateColumnExpr(sqlite3 db, SrcList pSrc, int iSrc, int iCol) { + Expr p = sqlite3ExprAlloc(db, TK_COLUMN, null, 0); + if (p != null) { + SrcList_item pItem = pSrc.a[iSrc]; + p.pTab = pItem.pTab; + p.iTable = pItem.iCursor; + if (p.pTab.iPKey == iCol) { + p.iColumn = -1; + } else { + p.iColumn = (ynVar)iCol; + testcase(iCol == BMS); + testcase(iCol == BMS - 1); + pItem.colUsed |= ((Bitmask)1) << (iCol >= BMS ? BMS - 1 : iCol); + } + ExprSetProperty(p, EP_Resolved); + } + return p; } /* - ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z - ** might refer to an result-set alias. This happens, for example, when - ** we are resolving names in the WHERE clause of the following command: + ** This routine is callback for sqlite3WalkExpr(). ** - ** SELECT a+b AS x FROM table WHERE x<10; + ** Resolve symbolic names into TK_COLUMN operators for the current + ** node in the expression tree. Return 0 to continue the search down + ** the tree or 2 to abort the tree walk. ** - ** In cases like this, replace pExpr with a copy of the expression that - ** forms the result set entry ("a+b" in the example) and return immediately. - ** Note that the expression in the result set should have already been - ** resolved by the time the WHERE clause is resolved. - */ - if ( cnt == 0 && ( pEList = pNC.pEList ) != null && zTab == null ) - { - for ( j = 0; j < pEList.nExpr; j++ ) - { - string zAs = pEList.a[j].zName; - if ( zAs != null && zAs.Equals( zCol ,StringComparison.OrdinalIgnoreCase ) ) - { - Expr pOrig; - Debug.Assert( pExpr.pLeft == null && pExpr.pRight == null ); - Debug.Assert( pExpr.x.pList == null ); - Debug.Assert( pExpr.x.pSelect == null ); - pOrig = pEList.a[j].pExpr; - if ( 0 == pNC.allowAgg && ExprHasProperty( pOrig, EP_Agg ) ) - { - sqlite3ErrorMsg( pParse, "misuse of aliased aggregate %s", zAs ); - return WRC_Abort; - } - resolveAlias( pParse, pEList, j, pExpr, "" ); - cnt = 1; - pMatch = null; - Debug.Assert( zTab == null && zDb == null ); - goto lookupname_end; - } - } - } - - /* Advance to the next name context. The loop will exit when either - ** we have a match (cnt>0) or when we run out of name contexts. + ** This routine also does error checking and name resolution for + ** function names. The operator for aggregate functions is changed + ** to TK_AGG_FUNCTION. */ - if ( cnt == 0 ) - { - pNC = pNC.pNext; - } - } - - /* - ** If X and Y are NULL (in other words if only the column name Z is - ** supplied) and the value of Z is enclosed in double-quotes, then - ** Z is a string literal if it doesn't match any column names. In that - ** case, we need to return right away and not make any changes to - ** pExpr. - ** - ** Because no reference was made to outer contexts, the pNC.nRef - ** fields are not changed in any context. - */ - if ( cnt == 0 && zTab == null && ExprHasProperty( pExpr, EP_DblQuoted ) ) - { - pExpr.op = TK_STRING; - pExpr.pTab = null; - return WRC_Prune; - } - - /* - ** cnt==0 means there was not match. cnt>1 means there were two or - ** more matches. Either way, we have an error. - */ - if ( cnt != 1 ) - { - string zErr; - zErr = cnt == 0 ? "no such column" : "ambiguous column name"; - if ( zDb != null ) - { - sqlite3ErrorMsg( pParse, "%s: %s.%s.%s", zErr, zDb, zTab, zCol ); - } - else if ( zTab != null ) - { - sqlite3ErrorMsg( pParse, "%s: %s.%s", zErr, zTab, zCol ); - } - else - { - sqlite3ErrorMsg( pParse, "%s: %s", zErr, zCol ); - } - pParse.checkSchema = 1; - pTopNC.nErr++; - } - - /* If a column from a table in pSrcList is referenced, then record - ** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes - ** bit 0 to be set. Column 1 sets bit 1. And so forth. If the - ** column number is greater than the number of bits in the bitmask - ** then set the high-order bit of the bitmask. - */ - if ( pExpr.iColumn >= 0 && pMatch != null ) - { - int n = pExpr.iColumn; - testcase( n == BMS - 1 ); - if ( n >= BMS ) - { - n = BMS - 1; - } - Debug.Assert( pMatch.iCursor == pExpr.iTable ); - pMatch.colUsed |= ( (Bitmask)1 ) << n; - } - - /* Clean up and return - */ - sqlite3ExprDelete( db, ref pExpr.pLeft ); - pExpr.pLeft = null; - sqlite3ExprDelete( db, ref pExpr.pRight ); - pExpr.pRight = null; - pExpr.op = (u8)( isTrigger != 0 ? TK_TRIGGER : TK_COLUMN ); -lookupname_end: - if ( cnt == 1 ) - { - Debug.Assert( pNC != null ); - sqlite3AuthRead( pParse, pExpr, pSchema, pNC.pSrcList ); - /* Increment the nRef value on all name contexts from TopNC up to - ** the point where the name matched. */ - for ( ; ; ) - { - Debug.Assert( pTopNC != null ); - pTopNC.nRef++; - if ( pTopNC == pNC ) - break; - pTopNC = pTopNC.pNext; - } - return WRC_Prune; - } - else - { - return WRC_Abort; - } - } - - /* - ** Allocate and return a pointer to an expression to load the column iCol - ** from datasource iSrc in SrcList pSrc. - */ - static Expr sqlite3CreateColumnExpr( sqlite3 db, SrcList pSrc, int iSrc, int iCol ) - { - Expr p = sqlite3ExprAlloc( db, TK_COLUMN, null, 0 ); - if ( p != null ) - { - SrcList_item pItem = pSrc.a[iSrc]; - p.pTab = pItem.pTab; - p.iTable = pItem.iCursor; - if ( p.pTab.iPKey == iCol ) - { - p.iColumn = -1; - } - else - { - p.iColumn = (ynVar)iCol; - testcase( iCol == BMS ); - testcase( iCol == BMS - 1 ); - pItem.colUsed |= ( (Bitmask)1 ) << ( iCol >= BMS ? BMS - 1 : iCol ); - } - ExprSetProperty( p, EP_Resolved ); - } - return p; - } - - /* - ** This routine is callback for sqlite3WalkExpr(). - ** - ** Resolve symbolic names into TK_COLUMN operators for the current - ** node in the expression tree. Return 0 to continue the search down - ** the tree or 2 to abort the tree walk. - ** - ** This routine also does error checking and name resolution for - ** function names. The operator for aggregate functions is changed - ** to TK_AGG_FUNCTION. - */ - static int resolveExprStep( Walker pWalker, ref Expr pExpr ) - { - NameContext pNC; - Parse pParse; - - pNC = pWalker.u.pNC; - Debug.Assert( pNC != null ); - pParse = pNC.pParse; - Debug.Assert( pParse == pWalker.pParse ); - - if ( ExprHasAnyProperty( pExpr, EP_Resolved ) ) - return WRC_Prune; - ExprSetProperty( pExpr, EP_Resolved ); + static int resolveExprStep(Walker pWalker, ref Expr pExpr) { + NameContext pNC; + Parse pParse; + + pNC = pWalker.u.pNC; + Debug.Assert(pNC != null); + pParse = pNC.pParse; + Debug.Assert(pParse == pWalker.pParse); + + if (ExprHasAnyProperty(pExpr, EP_Resolved)) + return WRC_Prune; + ExprSetProperty(pExpr, EP_Resolved); #if !NDEBUG - if ( pNC.pSrcList != null && pNC.pSrcList.nAlloc > 0 ) - { - SrcList pSrcList = pNC.pSrcList; - int i; - for ( i = 0; i < pNC.pSrcList.nSrc; i++ ) - { - Debug.Assert( pSrcList.a[i].iCursor >= 0 && pSrcList.a[i].iCursor < pParse.nTab ); - } - } + if (pNC.pSrcList != null && pNC.pSrcList.nAlloc > 0) { + SrcList pSrcList = pNC.pSrcList; + int i; + for (i = 0; i < pNC.pSrcList.nSrc; i++) { + Debug.Assert(pSrcList.a[i].iCursor >= 0 && pSrcList.a[i].iCursor < pParse.nTab); + } + } #endif - switch ( pExpr.op ) - { + switch (pExpr.op) { #if (SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !(SQLITE_OMIT_SUBQUERY) /* The special operator TK_ROW means use the rowid for the first @@ -584,78 +514,66 @@ static int resolveExprStep( Walker pWalker, ref Expr pExpr ) } #endif //* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) / - /* A lone identifier is the name of a column. -*/ - case TK_ID: - { - return lookupName( pParse, null, null, pExpr.u.zToken, pNC, pExpr ); - } - - /* A table name and column name: ID.ID - ** Or a database, table and column: ID.ID.ID + /* A lone identifier is the name of a column. */ - case TK_DOT: - { - string zColumn; - string zTable; - string zDb; - Expr pRight; - - /* if( pSrcList==0 ) break; */ - pRight = pExpr.pRight; - if ( pRight.op == TK_ID ) - { - zDb = null; - zTable = pExpr.pLeft.u.zToken; - zColumn = pRight.u.zToken; - } - else - { - Debug.Assert( pRight.op == TK_DOT ); - zDb = pExpr.pLeft.u.zToken; - zTable = pRight.pLeft.u.zToken; - zColumn = pRight.pRight.u.zToken; - } - return lookupName( pParse, zDb, zTable, zColumn, pNC, pExpr ); - } + case TK_ID: { + return lookupName(pParse, null, null, pExpr.u.zToken, pNC, pExpr); + } - /* Resolve function names - */ - case TK_CONST_FUNC: - case TK_FUNCTION: - { - ExprList pList = pExpr.x.pList; /* The argument list */ - int n = pList != null ? pList.nExpr : 0; /* Number of arguments */ - bool no_such_func = false; /* True if no such function exists */ - bool wrong_num_args = false; /* True if wrong number of arguments */ - bool is_agg = false; /* True if is an aggregate function */ - int auth; /* Authorization to use the function */ - int nId; /* Number of characters in function name */ - string zId; /* The function name. */ - FuncDef pDef; /* Information about the function */ - u8 enc = (u8)pParse.db.aDbStatic[0].pSchema.enc;// ENC( pParse.db ); /* The database encoding */ - - testcase( pExpr.op == TK_CONST_FUNC ); - Debug.Assert( !ExprHasProperty( pExpr, EP_xIsSelect ) ); - zId = pExpr.u.zToken; - nId = sqlite3Strlen30( zId ); - pDef = sqlite3FindFunction( pParse.db, zId, nId, n, enc, 0 ); - if ( pDef == null ) - { - pDef = sqlite3FindFunction( pParse.db, zId, nId, -1, enc, 0 ); - if ( pDef == null ) - { - no_such_func = true; - } - else - { - wrong_num_args = true; - } - } - else - { - is_agg = pDef.xFunc == null; - } + /* A table name and column name: ID.ID + ** Or a database, table and column: ID.ID.ID + */ + case TK_DOT: { + string zColumn; + string zTable; + string zDb; + Expr pRight; + + /* if( pSrcList==0 ) break; */ + pRight = pExpr.pRight; + if (pRight.op == TK_ID) { + zDb = null; + zTable = pExpr.pLeft.u.zToken; + zColumn = pRight.u.zToken; + } else { + Debug.Assert(pRight.op == TK_DOT); + zDb = pExpr.pLeft.u.zToken; + zTable = pRight.pLeft.u.zToken; + zColumn = pRight.pRight.u.zToken; + } + return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr); + } + + /* Resolve function names + */ + case TK_CONST_FUNC: + case TK_FUNCTION: { + ExprList pList = pExpr.x.pList; /* The argument list */ + int n = pList != null ? pList.nExpr : 0; /* Number of arguments */ + bool no_such_func = false; /* True if no such function exists */ + bool wrong_num_args = false; /* True if wrong number of arguments */ + bool is_agg = false; /* True if is an aggregate function */ + int auth; /* Authorization to use the function */ + int nId; /* Number of characters in function name */ + string zId; /* The function name. */ + FuncDef pDef; /* Information about the function */ + u8 enc = (u8)pParse.db.aDbStatic[0].pSchema.enc;// ENC( pParse.db ); /* The database encoding */ + + testcase(pExpr.op == TK_CONST_FUNC); + Debug.Assert(!ExprHasProperty(pExpr, EP_xIsSelect)); + zId = pExpr.u.zToken; + nId = sqlite3Strlen30(zId); + pDef = sqlite3FindFunction(pParse.db, zId, nId, n, enc, 0); + if (pDef == null) { + pDef = sqlite3FindFunction(pParse.db, zId, nId, -1, enc, 0); + if (pDef == null) { + no_such_func = true; + } else { + wrong_num_args = true; + } + } else { + is_agg = pDef.xFunc == null; + } #if !SQLITE_OMIT_AUTHORIZATION if( pDef ){ auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0, pDef.zName, 0); @@ -670,688 +588,624 @@ static int resolveExprStep( Walker pWalker, ref Expr pExpr ) } } #endif - if ( is_agg && 0 == pNC.allowAgg ) - { - sqlite3ErrorMsg( pParse, "misuse of aggregate function %.*s()", nId, zId ); - pNC.nErr++; - is_agg = false; - } - else if ( no_such_func ) - { - sqlite3ErrorMsg( pParse, "no such function: %.*s", nId, zId ); - pNC.nErr++; - } - else if ( wrong_num_args ) - { - sqlite3ErrorMsg( pParse, "wrong number of arguments to function %.*s()", - nId, zId ); - pNC.nErr++; - } - if ( is_agg ) - { - pExpr.op = TK_AGG_FUNCTION; - pNC.hasAgg = 1; - } - if ( is_agg ) - pNC.allowAgg = 0; - sqlite3WalkExprList( pWalker, pList ); - if ( is_agg ) - pNC.allowAgg = 1; - /* FIX ME: Compute pExpr.affinity based on the expected return - ** type of the function - */ - return WRC_Prune; - } + if (is_agg && 0 == pNC.allowAgg) { + sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId, zId); + pNC.nErr++; + is_agg = false; + } else if (no_such_func) { + sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId); + pNC.nErr++; + } else if (wrong_num_args) { + sqlite3ErrorMsg(pParse, "wrong number of arguments to function %.*s()", + nId, zId); + pNC.nErr++; + } + if (is_agg) { + pExpr.op = TK_AGG_FUNCTION; + pNC.hasAgg = 1; + } + if (is_agg) + pNC.allowAgg = 0; + sqlite3WalkExprList(pWalker, pList); + if (is_agg) + pNC.allowAgg = 1; + /* FIX ME: Compute pExpr.affinity based on the expected return + ** type of the function + */ + return WRC_Prune; + } #if !SQLITE_OMIT_SUBQUERY - case TK_SELECT: - case TK_EXISTS: - { - testcase( pExpr.op == TK_EXISTS ); - goto case TK_IN; - } + case TK_SELECT: + case TK_EXISTS: { + testcase(pExpr.op == TK_EXISTS); + goto case TK_IN; + } #endif - case TK_IN: - { - testcase( pExpr.op == TK_IN ); - if ( ExprHasProperty( pExpr, EP_xIsSelect ) ) - { - int nRef = pNC.nRef; + case TK_IN: { + testcase(pExpr.op == TK_IN); + if (ExprHasProperty(pExpr, EP_xIsSelect)) { + int nRef = pNC.nRef; #if !SQLITE_OMIT_CHECK - if ( pNC.isCheck != 0 ) - { - sqlite3ErrorMsg( pParse, "subqueries prohibited in CHECK constraints" ); - } + if (pNC.isCheck != 0) { + sqlite3ErrorMsg(pParse, "subqueries prohibited in CHECK constraints"); + } #endif - sqlite3WalkSelect( pWalker, pExpr.x.pSelect ); - Debug.Assert( pNC.nRef >= nRef ); - if ( nRef != pNC.nRef ) - { - ExprSetProperty( pExpr, EP_VarSelect ); - } - } - break; - } + sqlite3WalkSelect(pWalker, pExpr.x.pSelect); + Debug.Assert(pNC.nRef >= nRef); + if (nRef != pNC.nRef) { + ExprSetProperty(pExpr, EP_VarSelect); + } + } + break; + } #if !SQLITE_OMIT_CHECK - case TK_VARIABLE: - { - if ( pNC.isCheck != 0 ) - { - sqlite3ErrorMsg( pParse, "parameters prohibited in CHECK constraints" ); - } - break; - } + case TK_VARIABLE: { + if (pNC.isCheck != 0) { + sqlite3ErrorMsg(pParse, "parameters prohibited in CHECK constraints"); + } + break; + } #endif - } - return ( pParse.nErr != 0 /* || pParse.db.mallocFailed != 0 */ ) ? WRC_Abort : WRC_Continue; - } - - /* - ** pEList is a list of expressions which are really the result set of the - ** a SELECT statement. pE is a term in an ORDER BY or GROUP BY clause. - ** This routine checks to see if pE is a simple identifier which corresponds - ** to the AS-name of one of the terms of the expression list. If it is, - ** this routine return an integer between 1 and N where N is the number of - ** elements in pEList, corresponding to the matching entry. If there is - ** no match, or if pE is not a simple identifier, then this routine - ** return 0. - ** - ** pEList has been resolved. pE has not. - */ - static int resolveAsName( - Parse pParse, /* Parsing context for error messages */ - ExprList pEList, /* List of expressions to scan */ - Expr pE /* Expression we are trying to match */ - ) - { - int i; /* Loop counter */ - - UNUSED_PARAMETER( pParse ); - - if ( pE.op == TK_ID ) - { - string zCol = pE.u.zToken; - - for ( i = 0; i < pEList.nExpr; i++ ) - { - string zAs = pEList.a[i].zName; - if ( zAs != null && zAs.Equals( zCol ,StringComparison.OrdinalIgnoreCase ) ) - { - return i + 1; - } - } - } - return 0; - } - - /* - ** pE is a pointer to an expression which is a single term in the - ** ORDER BY of a compound SELECT. The expression has not been - ** name resolved. - ** - ** At the point this routine is called, we already know that the - ** ORDER BY term is not an integer index into the result set. That - ** case is handled by the calling routine. - ** - ** Attempt to match pE against result set columns in the left-most - ** SELECT statement. Return the index i of the matching column, - ** as an indication to the caller that it should sort by the i-th column. - ** The left-most column is 1. In other words, the value returned is the - ** same integer value that would be used in the SQL statement to indicate - ** the column. - ** - ** If there is no match, return 0. Return -1 if an error occurs. - */ - static int resolveOrderByTermToExprList( - Parse pParse, /* Parsing context for error messages */ - Select pSelect, /* The SELECT statement with the ORDER BY clause */ - Expr pE /* The specific ORDER BY term */ - ) - { - int i = 0; /* Loop counter */ - ExprList pEList; /* The columns of the result set */ - NameContext nc; /* Name context for resolving pE */ - sqlite3 db; /* Database connection */ - int rc; /* Return code from subprocedures */ - u8 savedSuppErr; /* Saved value of db->suppressErr */ - - Debug.Assert( sqlite3ExprIsInteger( pE, ref i ) == 0 ); - pEList = pSelect.pEList; - - /* Resolve all names in the ORDER BY term expression - */ - nc = new NameContext();// memset( &nc, 0, sizeof( nc ) ); - nc.pParse = pParse; - nc.pSrcList = pSelect.pSrc; - nc.pEList = pEList; - nc.allowAgg = 1; - nc.nErr = 0; - db = pParse.db; - savedSuppErr = db.suppressErr; - db.suppressErr = 1; - rc = sqlite3ResolveExprNames( nc, ref pE ); - db.suppressErr = savedSuppErr; - if ( rc != 0 ) - return 0; - - /* Try to match the ORDER BY expression against an expression - ** in the result set. Return an 1-based index of the matching - ** result-set entry. - */ - for ( i = 0; i < pEList.nExpr; i++ ) - { - if ( sqlite3ExprCompare( pEList.a[i].pExpr, pE ) < 2 ) - { - return i + 1; - } - } - - /* If no match, return 0. */ - return 0; - } - - /* - ** Generate an ORDER BY or GROUP BY term out-of-range error. - */ - static void resolveOutOfRangeError( - Parse pParse, /* The error context into which to write the error */ - string zType, /* "ORDER" or "GROUP" */ - int i, /* The index (1-based) of the term out of range */ - int mx /* Largest permissible value of i */ - ) - { - sqlite3ErrorMsg( pParse, - "%r %s BY term out of range - should be " + - "between 1 and %d", i, zType, mx ); - } - - /* - ** Analyze the ORDER BY clause in a compound SELECT statement. Modify - ** each term of the ORDER BY clause is a constant integer between 1 - ** and N where N is the number of columns in the compound SELECT. - ** - ** ORDER BY terms that are already an integer between 1 and N are - ** unmodified. ORDER BY terms that are integers outside the range of - ** 1 through N generate an error. ORDER BY terms that are expressions - ** are matched against result set expressions of compound SELECT - ** beginning with the left-most SELECT and working toward the right. - ** At the first match, the ORDER BY expression is transformed into - ** the integer column number. - ** - ** Return the number of errors seen. - */ - static int resolveCompoundOrderBy( - Parse pParse, /* Parsing context. Leave error messages here */ - Select pSelect /* The SELECT statement containing the ORDER BY */ - ) - { - int i; - ExprList pOrderBy; - ExprList pEList; - sqlite3 db; - int moreToDo = 1; - - pOrderBy = pSelect.pOrderBy; - if ( pOrderBy == null ) - return 0; - db = pParse.db; -//#if SQLITE_MAX_COLUMN - if ( pOrderBy.nExpr > db.aLimit[SQLITE_LIMIT_COLUMN] ) - { - sqlite3ErrorMsg( pParse, "too many terms in ORDER BY clause" ); - return 1; - } -//#endif - for ( i = 0; i < pOrderBy.nExpr; i++ ) - { - pOrderBy.a[i].done = 0; - } - pSelect.pNext = null; - while ( pSelect.pPrior != null ) - { - pSelect.pPrior.pNext = pSelect; - pSelect = pSelect.pPrior; - } - while ( pSelect != null && moreToDo != 0 ) - { - ExprList_item pItem; - moreToDo = 0; - pEList = pSelect.pEList; - Debug.Assert( pEList != null ); - for ( i = 0; i < pOrderBy.nExpr; i++ )//, pItem++) - { - pItem = pOrderBy.a[i]; - int iCol = -1; - Expr pE, pDup; - if ( pItem.done != 0 ) - continue; - pE = pItem.pExpr; - if ( sqlite3ExprIsInteger( pE, ref iCol ) != 0 ) - { - if ( iCol <= 0 || iCol > pEList.nExpr ) - { - resolveOutOfRangeError( pParse, "ORDER", i + 1, pEList.nExpr ); - return 1; } - } - else - { - iCol = resolveAsName( pParse, pEList, pE ); - if ( iCol == 0 ) - { - pDup = sqlite3ExprDup( db, pE, 0 ); - ////if ( 0 == db.mallocFailed ) - { - Debug.Assert( pDup != null ); - iCol = resolveOrderByTermToExprList( pParse, pSelect, pDup ); - } - sqlite3ExprDelete( db, ref pDup ); - } - } - if ( iCol > 0 ) - { - CollSeq pColl = pE.pColl; - int flags = pE.flags & EP_ExpCollate; - sqlite3ExprDelete( db, ref pE ); - pItem.pExpr = pE = sqlite3Expr( db, TK_INTEGER, null ); - if ( pE == null ) - return 1; - pE.pColl = pColl; - pE.flags = (u16)( pE.flags | EP_IntValue | flags ); - pE.u.iValue = iCol; - pItem.iCol = (u16)iCol; - pItem.done = 1; - } - else - { - moreToDo = 1; - } - } - pSelect = pSelect.pNext; - } - for ( i = 0; i < pOrderBy.nExpr; i++ ) - { - if ( pOrderBy.a[i].done == 0 ) - { - sqlite3ErrorMsg( pParse, "%r ORDER BY term does not match any " + - "column in the result set", i + 1 ); - return 1; - } - } - return 0; - } - - /* - ** Check every term in the ORDER BY or GROUP BY clause pOrderBy of - ** the SELECT statement pSelect. If any term is reference to a - ** result set expression (as determined by the ExprList.a.iCol field) - ** then convert that term into a copy of the corresponding result set - ** column. - ** - ** If any errors are detected, add an error message to pParse and - ** return non-zero. Return zero if no errors are seen. - */ - static int sqlite3ResolveOrderGroupBy( - Parse pParse, /* Parsing context. Leave error messages here */ - Select pSelect, /* The SELECT statement containing the clause */ - ExprList pOrderBy, /* The ORDER BY or GROUP BY clause to be processed */ - string zType /* "ORDER" or "GROUP" */ - ) - { - int i; - sqlite3 db = pParse.db; - ExprList pEList; - ExprList_item pItem; - - if ( pOrderBy == null /* || pParse.db.mallocFailed != 0 */ ) - return 0; -//#if SQLITE_MAX_COLUMN - if ( pOrderBy.nExpr > db.aLimit[SQLITE_LIMIT_COLUMN] ) - { - sqlite3ErrorMsg( pParse, "too many terms in %s BY clause", zType ); - return 1; - } -//#endif - pEList = pSelect.pEList; - Debug.Assert( pEList != null ); /* sqlite3SelectNew() guarantees this */ - for ( i = 0; i < pOrderBy.nExpr; i++ )//, pItem++) - { - pItem = pOrderBy.a[i]; - if ( pItem.iCol != 0 ) - { - if ( pItem.iCol > pEList.nExpr ) - { - resolveOutOfRangeError( pParse, zType, i + 1, pEList.nExpr ); - return 1; - } - resolveAlias( pParse, pEList, pItem.iCol - 1, pItem.pExpr, zType ); - } - } - return 0; - } - - /* - ** pOrderBy is an ORDER BY or GROUP BY clause in SELECT statement pSelect. - ** The Name context of the SELECT statement is pNC. zType is either - ** "ORDER" or "GROUP" depending on which type of clause pOrderBy is. - ** - ** This routine resolves each term of the clause into an expression. - ** If the order-by term is an integer I between 1 and N (where N is the - ** number of columns in the result set of the SELECT) then the expression - ** in the resolution is a copy of the I-th result-set expression. If - ** the order-by term is an identify that corresponds to the AS-name of - ** a result-set expression, then the term resolves to a copy of the - ** result-set expression. Otherwise, the expression is resolved in - ** the usual way - using sqlite3ResolveExprNames(). - ** - ** This routine returns the number of errors. If errors occur, then - ** an appropriate error message might be left in pParse. (OOM errors - ** excepted.) - */ - static int resolveOrderGroupBy( - NameContext pNC, /* The name context of the SELECT statement */ - Select pSelect, /* The SELECT statement holding pOrderBy */ - ExprList pOrderBy, /* An ORDER BY or GROUP BY clause to resolve */ - string zType /* Either "ORDER" or "GROUP", as appropriate */ - ) - { - int i; /* Loop counter */ - int iCol; /* Column number */ - ExprList_item pItem; /* A term of the ORDER BY clause */ - Parse pParse; /* Parsing context */ - int nResult; /* Number of terms in the result set */ - - if ( pOrderBy == null ) - return 0; - nResult = pSelect.pEList.nExpr; - pParse = pNC.pParse; - for ( i = 0; i < pOrderBy.nExpr; i++ )//, pItem++ ) - { - pItem = pOrderBy.a[i]; - Expr pE = pItem.pExpr; - iCol = resolveAsName( pParse, pSelect.pEList, pE ); - if ( iCol > 0 ) - { - /* If an AS-name match is found, mark this ORDER BY column as being - ** a copy of the iCol-th result-set column. The subsequent call to - ** sqlite3ResolveOrderGroupBy() will convert the expression to a - ** copy of the iCol-th result-set expression. */ - pItem.iCol = (u16)iCol; - continue; - } - if ( sqlite3ExprIsInteger( pE, ref iCol ) != 0 ) - { - /* The ORDER BY term is an integer constant. Again, set the column - ** number so that sqlite3ResolveOrderGroupBy() will convert the - ** order-by term to a copy of the result-set expression */ - if ( iCol < 1 ) - { - resolveOutOfRangeError( pParse, zType, i + 1, nResult ); - return 1; - } - pItem.iCol = (u16)iCol; - continue; - } - - /* Otherwise, treat the ORDER BY term as an ordinary expression */ - pItem.iCol = 0; - if ( sqlite3ResolveExprNames( pNC, ref pE ) != 0 ) - { - return 1; + return (pParse.nErr != 0 /* || pParse.db.mallocFailed != 0 */ ) ? WRC_Abort : WRC_Continue; } - } - return sqlite3ResolveOrderGroupBy( pParse, pSelect, pOrderBy, zType ); - } - /* - ** Resolve names in the SELECT statement p and all of its descendents. - */ - static int resolveSelectStep( Walker pWalker, Select p ) - { - NameContext pOuterNC; /* Context that contains this SELECT */ - NameContext sNC; /* Name context of this SELECT */ - bool isCompound; /* True if p is a compound select */ - int nCompound; /* Number of compound terms processed so far */ - Parse pParse; /* Parsing context */ - ExprList pEList; /* Result set expression list */ - int i; /* Loop counter */ - ExprList pGroupBy; /* The GROUP BY clause */ - Select pLeftmost; /* Left-most of SELECT of a compound */ - - Debug.Assert( p != null ); - if ( ( p.selFlags & SF_Resolved ) != 0 ) - { - return WRC_Prune; - } - pOuterNC = pWalker.u.pNC; - pParse = pWalker.pParse; - //sqlite3 db = pParse.db; - - /* Normally sqlite3SelectExpand() will be called first and will have - ** already expanded this SELECT. However, if this is a subquery within - ** an expression, sqlite3ResolveExprNames() will be called without a - ** prior call to sqlite3SelectExpand(). When that happens, let - ** sqlite3SelectPrep() do all of the processing for this SELECT. - ** sqlite3SelectPrep() will invoke both sqlite3SelectExpand() and - ** this routine in the correct order. - */ - if ( ( p.selFlags & SF_Expanded ) == 0 ) - { - sqlite3SelectPrep( pParse, p, pOuterNC ); - return ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) ? WRC_Abort : WRC_Prune; - } - - isCompound = p.pPrior != null; - nCompound = 0; - pLeftmost = p; - while ( p != null ) - { - Debug.Assert( ( p.selFlags & SF_Expanded ) != 0 ); - Debug.Assert( ( p.selFlags & SF_Resolved ) == 0 ); - p.selFlags |= SF_Resolved; - - /* Resolve the expressions in the LIMIT and OFFSET clauses. These - ** are not allowed to refer to any names, so pass an empty NameContext. + /* + ** pEList is a list of expressions which are really the result set of the + ** a SELECT statement. pE is a term in an ORDER BY or GROUP BY clause. + ** This routine checks to see if pE is a simple identifier which corresponds + ** to the AS-name of one of the terms of the expression list. If it is, + ** this routine return an integer between 1 and N where N is the number of + ** elements in pEList, corresponding to the matching entry. If there is + ** no match, or if pE is not a simple identifier, then this routine + ** return 0. + ** + ** pEList has been resolved. pE has not. */ - sNC = new NameContext();// memset( &sNC, 0, sizeof( sNC ) ); - sNC.pParse = pParse; - if ( sqlite3ResolveExprNames( sNC, ref p.pLimit ) != 0 || - sqlite3ResolveExprNames( sNC, ref p.pOffset ) != 0 ) - { - return WRC_Abort; + static int resolveAsName( + Parse pParse, /* Parsing context for error messages */ + ExprList pEList, /* List of expressions to scan */ + Expr pE /* Expression we are trying to match */ + ) { + int i; /* Loop counter */ + + UNUSED_PARAMETER(pParse); + + if (pE.op == TK_ID) { + string zCol = pE.u.zToken; + + for (i = 0; i < pEList.nExpr; i++) { + string zAs = pEList.a[i].zName; + if (zAs != null && zAs.Equals(zCol, StringComparison.OrdinalIgnoreCase)) { + return i + 1; + } + } + } + return 0; } - /* Set up the local name-context to pass to sqlite3ResolveExprNames() to - ** resolve the result-set expression list. + /* + ** pE is a pointer to an expression which is a single term in the + ** ORDER BY of a compound SELECT. The expression has not been + ** name resolved. + ** + ** At the point this routine is called, we already know that the + ** ORDER BY term is not an integer index into the result set. That + ** case is handled by the calling routine. + ** + ** Attempt to match pE against result set columns in the left-most + ** SELECT statement. Return the index i of the matching column, + ** as an indication to the caller that it should sort by the i-th column. + ** The left-most column is 1. In other words, the value returned is the + ** same integer value that would be used in the SQL statement to indicate + ** the column. + ** + ** If there is no match, return 0. Return -1 if an error occurs. */ - sNC.allowAgg = 1; - sNC.pSrcList = p.pSrc; - sNC.pNext = pOuterNC; - - /* Resolve names in the result set. */ - pEList = p.pEList; - Debug.Assert( pEList != null ); - for ( i = 0; i < pEList.nExpr; i++ ) - { - Expr pX = pEList.a[i].pExpr; - if ( sqlite3ResolveExprNames( sNC, ref pX ) != 0 ) - { - return WRC_Abort; - } - } + static int resolveOrderByTermToExprList( + Parse pParse, /* Parsing context for error messages */ + Select pSelect, /* The SELECT statement with the ORDER BY clause */ + Expr pE /* The specific ORDER BY term */ + ) { + int i = 0; /* Loop counter */ + ExprList pEList; /* The columns of the result set */ + NameContext nc; /* Name context for resolving pE */ + sqlite3 db; /* Database connection */ + int rc; /* Return code from subprocedures */ + u8 savedSuppErr; /* Saved value of db->suppressErr */ + + Debug.Assert(sqlite3ExprIsInteger(pE, ref i) == 0); + pEList = pSelect.pEList; + + /* Resolve all names in the ORDER BY term expression + */ + nc = new NameContext();// memset( &nc, 0, sizeof( nc ) ); + nc.pParse = pParse; + nc.pSrcList = pSelect.pSrc; + nc.pEList = pEList; + nc.allowAgg = 1; + nc.nErr = 0; + db = pParse.db; + savedSuppErr = db.suppressErr; + db.suppressErr = 1; + rc = sqlite3ResolveExprNames(nc, ref pE); + db.suppressErr = savedSuppErr; + if (rc != 0) + return 0; + + /* Try to match the ORDER BY expression against an expression + ** in the result set. Return an 1-based index of the matching + ** result-set entry. + */ + for (i = 0; i < pEList.nExpr; i++) { + if (sqlite3ExprCompare(pEList.a[i].pExpr, pE) < 2) { + return i + 1; + } + } - /* Recursively resolve names in all subqueries - */ - for ( i = 0; i < p.pSrc.nSrc; i++ ) - { - SrcList_item pItem = p.pSrc.a[i]; - if ( pItem.pSelect != null ) - { - string zSavedContext = pParse.zAuthContext; - if ( pItem.zName != null ) - pParse.zAuthContext = pItem.zName; - sqlite3ResolveSelectNames( pParse, pItem.pSelect, pOuterNC ); - pParse.zAuthContext = zSavedContext; - if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) - return WRC_Abort; - } + /* If no match, return 0. */ + return 0; } - /* If there are no aggregate functions in the result-set, and no GROUP BY - ** expression, do not allow aggregates in any of the other expressions. + /* + ** Generate an ORDER BY or GROUP BY term out-of-range error. */ - Debug.Assert( ( p.selFlags & SF_Aggregate ) == 0 ); - pGroupBy = p.pGroupBy; - if ( pGroupBy != null || sNC.hasAgg != 0 ) - { - p.selFlags |= SF_Aggregate; - } - else - { - sNC.allowAgg = 0; + static void resolveOutOfRangeError( + Parse pParse, /* The error context into which to write the error */ + string zType, /* "ORDER" or "GROUP" */ + int i, /* The index (1-based) of the term out of range */ + int mx /* Largest permissible value of i */ + ) { + sqlite3ErrorMsg(pParse, + "%r %s BY term out of range - should be " + + "between 1 and %d", i, zType, mx); } - /* If a HAVING clause is present, then there must be a GROUP BY clause. + /* + ** Analyze the ORDER BY clause in a compound SELECT statement. Modify + ** each term of the ORDER BY clause is a constant integer between 1 + ** and N where N is the number of columns in the compound SELECT. + ** + ** ORDER BY terms that are already an integer between 1 and N are + ** unmodified. ORDER BY terms that are integers outside the range of + ** 1 through N generate an error. ORDER BY terms that are expressions + ** are matched against result set expressions of compound SELECT + ** beginning with the left-most SELECT and working toward the right. + ** At the first match, the ORDER BY expression is transformed into + ** the integer column number. + ** + ** Return the number of errors seen. */ - if ( p.pHaving != null && pGroupBy == null ) - { - sqlite3ErrorMsg( pParse, "a GROUP BY clause is required before HAVING" ); - return WRC_Abort; + static int resolveCompoundOrderBy( + Parse pParse, /* Parsing context. Leave error messages here */ + Select pSelect /* The SELECT statement containing the ORDER BY */ + ) { + int i; + ExprList pOrderBy; + ExprList pEList; + sqlite3 db; + int moreToDo = 1; + + pOrderBy = pSelect.pOrderBy; + if (pOrderBy == null) + return 0; + db = pParse.db; + //#if SQLITE_MAX_COLUMN + if (pOrderBy.nExpr > db.aLimit[SQLITE_LIMIT_COLUMN]) { + sqlite3ErrorMsg(pParse, "too many terms in ORDER BY clause"); + return 1; + } + //#endif + for (i = 0; i < pOrderBy.nExpr; i++) { + pOrderBy.a[i].done = 0; + } + pSelect.pNext = null; + while (pSelect.pPrior != null) { + pSelect.pPrior.pNext = pSelect; + pSelect = pSelect.pPrior; + } + while (pSelect != null && moreToDo != 0) { + ExprList_item pItem; + moreToDo = 0; + pEList = pSelect.pEList; + Debug.Assert(pEList != null); + for (i = 0; i < pOrderBy.nExpr; i++)//, pItem++) + { + pItem = pOrderBy.a[i]; + int iCol = -1; + Expr pE, pDup; + if (pItem.done != 0) + continue; + pE = pItem.pExpr; + if (sqlite3ExprIsInteger(pE, ref iCol) != 0) { + if (iCol <= 0 || iCol > pEList.nExpr) { + resolveOutOfRangeError(pParse, "ORDER", i + 1, pEList.nExpr); + return 1; + } + } else { + iCol = resolveAsName(pParse, pEList, pE); + if (iCol == 0) { + pDup = sqlite3ExprDup(db, pE, 0); + ////if ( 0 == db.mallocFailed ) + { + Debug.Assert(pDup != null); + iCol = resolveOrderByTermToExprList(pParse, pSelect, pDup); + } + sqlite3ExprDelete(db, ref pDup); + } + } + if (iCol > 0) { + CollSeq pColl = pE.pColl; + int flags = pE.flags & EP_ExpCollate; + sqlite3ExprDelete(db, ref pE); + pItem.pExpr = pE = sqlite3Expr(db, TK_INTEGER, null); + if (pE == null) + return 1; + pE.pColl = pColl; + pE.flags = (u16)(pE.flags | EP_IntValue | flags); + pE.u.iValue = iCol; + pItem.iCol = (u16)iCol; + pItem.done = 1; + } else { + moreToDo = 1; + } + } + pSelect = pSelect.pNext; + } + for (i = 0; i < pOrderBy.nExpr; i++) { + if (pOrderBy.a[i].done == 0) { + sqlite3ErrorMsg(pParse, "%r ORDER BY term does not match any " + + "column in the result set", i + 1); + return 1; + } + } + return 0; } - /* Add the expression list to the name-context before parsing the - ** other expressions in the SELECT statement. This is so that - ** expressions in the WHERE clause (etc.) can refer to expressions by - ** aliases in the result set. + /* + ** Check every term in the ORDER BY or GROUP BY clause pOrderBy of + ** the SELECT statement pSelect. If any term is reference to a + ** result set expression (as determined by the ExprList.a.iCol field) + ** then convert that term into a copy of the corresponding result set + ** column. ** - ** Minor point: If this is the case, then the expression will be - ** re-evaluated for each reference to it. + ** If any errors are detected, add an error message to pParse and + ** return non-zero. Return zero if no errors are seen. */ - sNC.pEList = p.pEList; - if ( sqlite3ResolveExprNames( sNC, ref p.pWhere ) != 0 || - sqlite3ResolveExprNames( sNC, ref p.pHaving ) != 0 - ) - { - return WRC_Abort; + static int sqlite3ResolveOrderGroupBy( + Parse pParse, /* Parsing context. Leave error messages here */ + Select pSelect, /* The SELECT statement containing the clause */ + ExprList pOrderBy, /* The ORDER BY or GROUP BY clause to be processed */ + string zType /* "ORDER" or "GROUP" */ + ) { + int i; + sqlite3 db = pParse.db; + ExprList pEList; + ExprList_item pItem; + + if (pOrderBy == null /* || pParse.db.mallocFailed != 0 */ ) + return 0; + //#if SQLITE_MAX_COLUMN + if (pOrderBy.nExpr > db.aLimit[SQLITE_LIMIT_COLUMN]) { + sqlite3ErrorMsg(pParse, "too many terms in %s BY clause", zType); + return 1; + } + //#endif + pEList = pSelect.pEList; + Debug.Assert(pEList != null); /* sqlite3SelectNew() guarantees this */ + for (i = 0; i < pOrderBy.nExpr; i++)//, pItem++) + { + pItem = pOrderBy.a[i]; + if (pItem.iCol != 0) { + if (pItem.iCol > pEList.nExpr) { + resolveOutOfRangeError(pParse, zType, i + 1, pEList.nExpr); + return 1; + } + resolveAlias(pParse, pEList, pItem.iCol - 1, pItem.pExpr, zType); + } + } + return 0; } - /* The ORDER BY and GROUP BY clauses may not refer to terms in - ** outer queries + /* + ** pOrderBy is an ORDER BY or GROUP BY clause in SELECT statement pSelect. + ** The Name context of the SELECT statement is pNC. zType is either + ** "ORDER" or "GROUP" depending on which type of clause pOrderBy is. + ** + ** This routine resolves each term of the clause into an expression. + ** If the order-by term is an integer I between 1 and N (where N is the + ** number of columns in the result set of the SELECT) then the expression + ** in the resolution is a copy of the I-th result-set expression. If + ** the order-by term is an identify that corresponds to the AS-name of + ** a result-set expression, then the term resolves to a copy of the + ** result-set expression. Otherwise, the expression is resolved in + ** the usual way - using sqlite3ResolveExprNames(). + ** + ** This routine returns the number of errors. If errors occur, then + ** an appropriate error message might be left in pParse. (OOM errors + ** excepted.) */ - sNC.pNext = null; - sNC.allowAgg = 1; + static int resolveOrderGroupBy( + NameContext pNC, /* The name context of the SELECT statement */ + Select pSelect, /* The SELECT statement holding pOrderBy */ + ExprList pOrderBy, /* An ORDER BY or GROUP BY clause to resolve */ + string zType /* Either "ORDER" or "GROUP", as appropriate */ + ) { + int i; /* Loop counter */ + int iCol; /* Column number */ + ExprList_item pItem; /* A term of the ORDER BY clause */ + Parse pParse; /* Parsing context */ + int nResult; /* Number of terms in the result set */ + + if (pOrderBy == null) + return 0; + nResult = pSelect.pEList.nExpr; + pParse = pNC.pParse; + for (i = 0; i < pOrderBy.nExpr; i++)//, pItem++ ) + { + pItem = pOrderBy.a[i]; + Expr pE = pItem.pExpr; + iCol = resolveAsName(pParse, pSelect.pEList, pE); + if (iCol > 0) { + /* If an AS-name match is found, mark this ORDER BY column as being + ** a copy of the iCol-th result-set column. The subsequent call to + ** sqlite3ResolveOrderGroupBy() will convert the expression to a + ** copy of the iCol-th result-set expression. */ + pItem.iCol = (u16)iCol; + continue; + } + if (sqlite3ExprIsInteger(pE, ref iCol) != 0) { + /* The ORDER BY term is an integer constant. Again, set the column + ** number so that sqlite3ResolveOrderGroupBy() will convert the + ** order-by term to a copy of the result-set expression */ + if (iCol < 1) { + resolveOutOfRangeError(pParse, zType, i + 1, nResult); + return 1; + } + pItem.iCol = (u16)iCol; + continue; + } - /* Process the ORDER BY clause for singleton SELECT statements. - ** The ORDER BY clause for compounds SELECT statements is handled - ** below, after all of the result-sets for all of the elements of - ** the compound have been resolved. - */ - if ( !isCompound && resolveOrderGroupBy( sNC, p, p.pOrderBy, "ORDER" ) != 0 ) - { - return WRC_Abort; + /* Otherwise, treat the ORDER BY term as an ordinary expression */ + pItem.iCol = 0; + if (sqlite3ResolveExprNames(pNC, ref pE) != 0) { + return 1; + } + } + return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType); } - //if ( db.mallocFailed != 0 ) - //{ - // return WRC_Abort; - //} - /* Resolve the GROUP BY clause. At the same time, make sure - ** the GROUP BY clause does not contain aggregate functions. + /* + ** Resolve names in the SELECT statement p and all of its descendents. */ - if ( pGroupBy != null ) - { - ExprList_item pItem; - - if ( resolveOrderGroupBy( sNC, p, pGroupBy, "GROUP" ) != 0 /*|| db.mallocFailed != 0 */ ) - { - return WRC_Abort; - } - for ( i = 0; i < pGroupBy.nExpr; i++ )//, pItem++) - { - pItem = pGroupBy.a[i]; - if ( ( pItem.pExpr.flags & EP_Agg ) != 0 )//HasProperty(pItem.pExpr, EP_Agg) ) - { - sqlite3ErrorMsg( pParse, "aggregate functions are not allowed in " + - "the GROUP BY clause" ); - return WRC_Abort; + static int resolveSelectStep(Walker pWalker, Select p) { + NameContext pOuterNC; /* Context that contains this SELECT */ + NameContext sNC; /* Name context of this SELECT */ + bool isCompound; /* True if p is a compound select */ + int nCompound; /* Number of compound terms processed so far */ + Parse pParse; /* Parsing context */ + ExprList pEList; /* Result set expression list */ + int i; /* Loop counter */ + ExprList pGroupBy; /* The GROUP BY clause */ + Select pLeftmost; /* Left-most of SELECT of a compound */ + + Debug.Assert(p != null); + if ((p.selFlags & SF_Resolved) != 0) { + return WRC_Prune; + } + pOuterNC = pWalker.u.pNC; + pParse = pWalker.pParse; + //sqlite3 db = pParse.db; + + /* Normally sqlite3SelectExpand() will be called first and will have + ** already expanded this SELECT. However, if this is a subquery within + ** an expression, sqlite3ResolveExprNames() will be called without a + ** prior call to sqlite3SelectExpand(). When that happens, let + ** sqlite3SelectPrep() do all of the processing for this SELECT. + ** sqlite3SelectPrep() will invoke both sqlite3SelectExpand() and + ** this routine in the correct order. + */ + if ((p.selFlags & SF_Expanded) == 0) { + sqlite3SelectPrep(pParse, p, pOuterNC); + return (pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) ? WRC_Abort : WRC_Prune; + } + + isCompound = p.pPrior != null; + nCompound = 0; + pLeftmost = p; + while (p != null) { + Debug.Assert((p.selFlags & SF_Expanded) != 0); + Debug.Assert((p.selFlags & SF_Resolved) == 0); + p.selFlags |= SF_Resolved; + + /* Resolve the expressions in the LIMIT and OFFSET clauses. These + ** are not allowed to refer to any names, so pass an empty NameContext. + */ + sNC = new NameContext();// memset( &sNC, 0, sizeof( sNC ) ); + sNC.pParse = pParse; + if (sqlite3ResolveExprNames(sNC, ref p.pLimit) != 0 || + sqlite3ResolveExprNames(sNC, ref p.pOffset) != 0) { + return WRC_Abort; + } + + /* Set up the local name-context to pass to sqlite3ResolveExprNames() to + ** resolve the result-set expression list. + */ + sNC.allowAgg = 1; + sNC.pSrcList = p.pSrc; + sNC.pNext = pOuterNC; + + /* Resolve names in the result set. */ + pEList = p.pEList; + Debug.Assert(pEList != null); + for (i = 0; i < pEList.nExpr; i++) { + Expr pX = pEList.a[i].pExpr; + if (sqlite3ResolveExprNames(sNC, ref pX) != 0) { + return WRC_Abort; + } + } + + /* Recursively resolve names in all subqueries + */ + for (i = 0; i < p.pSrc.nSrc; i++) { + SrcList_item pItem = p.pSrc.a[i]; + if (pItem.pSelect != null) { + string zSavedContext = pParse.zAuthContext; + if (pItem.zName != null) + pParse.zAuthContext = pItem.zName; + sqlite3ResolveSelectNames(pParse, pItem.pSelect, pOuterNC); + pParse.zAuthContext = zSavedContext; + if (pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) + return WRC_Abort; + } + } + + /* If there are no aggregate functions in the result-set, and no GROUP BY + ** expression, do not allow aggregates in any of the other expressions. + */ + Debug.Assert((p.selFlags & SF_Aggregate) == 0); + pGroupBy = p.pGroupBy; + if (pGroupBy != null || sNC.hasAgg != 0) { + p.selFlags |= SF_Aggregate; + } else { + sNC.allowAgg = 0; + } + + /* If a HAVING clause is present, then there must be a GROUP BY clause. + */ + if (p.pHaving != null && pGroupBy == null) { + sqlite3ErrorMsg(pParse, "a GROUP BY clause is required before HAVING"); + return WRC_Abort; + } + + /* Add the expression list to the name-context before parsing the + ** other expressions in the SELECT statement. This is so that + ** expressions in the WHERE clause (etc.) can refer to expressions by + ** aliases in the result set. + ** + ** Minor point: If this is the case, then the expression will be + ** re-evaluated for each reference to it. + */ + sNC.pEList = p.pEList; + if (sqlite3ResolveExprNames(sNC, ref p.pWhere) != 0 || + sqlite3ResolveExprNames(sNC, ref p.pHaving) != 0 + ) { + return WRC_Abort; + } + + /* The ORDER BY and GROUP BY clauses may not refer to terms in + ** outer queries + */ + sNC.pNext = null; + sNC.allowAgg = 1; + + /* Process the ORDER BY clause for singleton SELECT statements. + ** The ORDER BY clause for compounds SELECT statements is handled + ** below, after all of the result-sets for all of the elements of + ** the compound have been resolved. + */ + if (!isCompound && resolveOrderGroupBy(sNC, p, p.pOrderBy, "ORDER") != 0) { + return WRC_Abort; + } + //if ( db.mallocFailed != 0 ) + //{ + // return WRC_Abort; + //} + + /* Resolve the GROUP BY clause. At the same time, make sure + ** the GROUP BY clause does not contain aggregate functions. + */ + if (pGroupBy != null) { + ExprList_item pItem; + + if (resolveOrderGroupBy(sNC, p, pGroupBy, "GROUP") != 0 /*|| db.mallocFailed != 0 */ ) { + return WRC_Abort; + } + for (i = 0; i < pGroupBy.nExpr; i++)//, pItem++) + { + pItem = pGroupBy.a[i]; + if ((pItem.pExpr.flags & EP_Agg) != 0)//HasProperty(pItem.pExpr, EP_Agg) ) + { + sqlite3ErrorMsg(pParse, "aggregate functions are not allowed in " + + "the GROUP BY clause"); + return WRC_Abort; + } + } + } + + /* Advance to the next term of the compound + */ + p = p.pPrior; + nCompound++; + } + + /* Resolve the ORDER BY on a compound SELECT after all terms of + ** the compound have been resolved. + */ + if (isCompound && resolveCompoundOrderBy(pParse, pLeftmost) != 0) { + return WRC_Abort; } - } + + return WRC_Prune; } - /* Advance to the next term of the compound + /* + ** This routine walks an expression tree and resolves references to + ** table columns and result-set columns. At the same time, do error + ** checking on function usage and set a flag if any aggregate functions + ** are seen. + ** + ** To resolve table columns references we look for nodes (or subtrees) of the + ** form X.Y.Z or Y.Z or just Z where + ** + ** X: The name of a database. Ex: "main" or "temp" or + ** the symbolic name assigned to an ATTACH-ed database. + ** + ** Y: The name of a table in a FROM clause. Or in a trigger + ** one of the special names "old" or "new". + ** + ** Z: The name of a column in table Y. + ** + ** The node at the root of the subtree is modified as follows: + ** + ** Expr.op Changed to TK_COLUMN + ** Expr.pTab Points to the Table object for X.Y + ** Expr.iColumn The column index in X.Y. -1 for the rowid. + ** Expr.iTable The VDBE cursor number for X.Y + ** + ** + ** To resolve result-set references, look for expression nodes of the + ** form Z (with no X and Y prefix) where the Z matches the right-hand + ** size of an AS clause in the result-set of a SELECT. The Z expression + ** is replaced by a copy of the left-hand side of the result-set expression. + ** Table-name and function resolution occurs on the substituted expression + ** tree. For example, in: + ** + ** SELECT a+b AS x, c+d AS y FROM t1 ORDER BY x; + ** + ** The "x" term of the order by is replaced by "a+b" to render: + ** + ** SELECT a+b AS x, c+d AS y FROM t1 ORDER BY a+b; + ** + ** Function calls are checked to make sure that the function is + ** defined and that the correct number of arguments are specified. + ** If the function is an aggregate function, then the pNC.hasAgg is + ** set and the opcode is changed from TK_FUNCTION to TK_AGG_FUNCTION. + ** If an expression contains aggregate functions then the EP_Agg + ** property on the expression is set. + ** + ** An error message is left in pParse if anything is amiss. The number + ** if errors is returned. */ - p = p.pPrior; - nCompound++; - } - - /* Resolve the ORDER BY on a compound SELECT after all terms of - ** the compound have been resolved. - */ - if ( isCompound && resolveCompoundOrderBy( pParse, pLeftmost ) != 0 ) - { - return WRC_Abort; - } - - return WRC_Prune; - } - - /* - ** This routine walks an expression tree and resolves references to - ** table columns and result-set columns. At the same time, do error - ** checking on function usage and set a flag if any aggregate functions - ** are seen. - ** - ** To resolve table columns references we look for nodes (or subtrees) of the - ** form X.Y.Z or Y.Z or just Z where - ** - ** X: The name of a database. Ex: "main" or "temp" or - ** the symbolic name assigned to an ATTACH-ed database. - ** - ** Y: The name of a table in a FROM clause. Or in a trigger - ** one of the special names "old" or "new". - ** - ** Z: The name of a column in table Y. - ** - ** The node at the root of the subtree is modified as follows: - ** - ** Expr.op Changed to TK_COLUMN - ** Expr.pTab Points to the Table object for X.Y - ** Expr.iColumn The column index in X.Y. -1 for the rowid. - ** Expr.iTable The VDBE cursor number for X.Y - ** - ** - ** To resolve result-set references, look for expression nodes of the - ** form Z (with no X and Y prefix) where the Z matches the right-hand - ** size of an AS clause in the result-set of a SELECT. The Z expression - ** is replaced by a copy of the left-hand side of the result-set expression. - ** Table-name and function resolution occurs on the substituted expression - ** tree. For example, in: - ** - ** SELECT a+b AS x, c+d AS y FROM t1 ORDER BY x; - ** - ** The "x" term of the order by is replaced by "a+b" to render: - ** - ** SELECT a+b AS x, c+d AS y FROM t1 ORDER BY a+b; - ** - ** Function calls are checked to make sure that the function is - ** defined and that the correct number of arguments are specified. - ** If the function is an aggregate function, then the pNC.hasAgg is - ** set and the opcode is changed from TK_FUNCTION to TK_AGG_FUNCTION. - ** If an expression contains aggregate functions then the EP_Agg - ** property on the expression is set. - ** - ** An error message is left in pParse if anything is amiss. The number - ** if errors is returned. - */ - static int sqlite3ResolveExprNames( - NameContext pNC, /* Namespace to resolve expressions in. */ - ref Expr pExpr /* The expression to be analyzed. */ - ) - { - u8 savedHasAgg; - Walker w = new Walker(); - - if ( pExpr == null ) - return 0; + static int sqlite3ResolveExprNames( + NameContext pNC, /* Namespace to resolve expressions in. */ + ref Expr pExpr /* The expression to be analyzed. */ + ) { + u8 savedHasAgg; + Walker w = new Walker(); + + if (pExpr == null) + return 0; #if SQLITE_MAX_EXPR_DEPTH//>0 { Parse pParse = pNC.pParse; @@ -1361,58 +1215,53 @@ ref Expr pExpr /* The expression to be analyzed. */ pParse.nHeight += pExpr.nHeight; } #endif - savedHasAgg = pNC.hasAgg; - pNC.hasAgg = 0; - w.xExprCallback = resolveExprStep; - w.xSelectCallback = resolveSelectStep; - w.pParse = pNC.pParse; - w.u.pNC = pNC; - sqlite3WalkExpr( w, ref pExpr ); + savedHasAgg = pNC.hasAgg; + pNC.hasAgg = 0; + w.xExprCallback = resolveExprStep; + w.xSelectCallback = resolveSelectStep; + w.pParse = pNC.pParse; + w.u.pNC = pNC; + sqlite3WalkExpr(w, ref pExpr); #if SQLITE_MAX_EXPR_DEPTH//>0 pNC.pParse.nHeight -= pExpr.nHeight; #endif - if ( pNC.nErr > 0 || w.pParse.nErr > 0 ) - { - ExprSetProperty( pExpr, EP_Error ); - } - if ( pNC.hasAgg != 0 ) - { - ExprSetProperty( pExpr, EP_Agg ); - } - else if ( savedHasAgg != 0 ) - { - pNC.hasAgg = 1; - } - return ExprHasProperty( pExpr, EP_Error ) ? 1 : 0; - } + if (pNC.nErr > 0 || w.pParse.nErr > 0) { + ExprSetProperty(pExpr, EP_Error); + } + if (pNC.hasAgg != 0) { + ExprSetProperty(pExpr, EP_Agg); + } else if (savedHasAgg != 0) { + pNC.hasAgg = 1; + } + return ExprHasProperty(pExpr, EP_Error) ? 1 : 0; + } - /* - ** Resolve all names in all expressions of a SELECT and in all - ** decendents of the SELECT, including compounds off of p.pPrior, - ** subqueries in expressions, and subqueries used as FROM clause - ** terms. - ** - ** See sqlite3ResolveExprNames() for a description of the kinds of - ** transformations that occur. - ** - ** All SELECT statements should have been expanded using - ** sqlite3SelectExpand() prior to invoking this routine. - */ - static void sqlite3ResolveSelectNames( - Parse pParse, /* The parser context */ - Select p, /* The SELECT statement being coded. */ - NameContext pOuterNC /* Name context for parent SELECT statement */ - ) - { - Walker w = new Walker(); - - Debug.Assert( p != null ); - w.xExprCallback = resolveExprStep; - w.xSelectCallback = resolveSelectStep; - w.pParse = pParse; - w.u.pNC = pOuterNC; - sqlite3WalkSelect( w, p ); + /* + ** Resolve all names in all expressions of a SELECT and in all + ** decendents of the SELECT, including compounds off of p.pPrior, + ** subqueries in expressions, and subqueries used as FROM clause + ** terms. + ** + ** See sqlite3ResolveExprNames() for a description of the kinds of + ** transformations that occur. + ** + ** All SELECT statements should have been expanded using + ** sqlite3SelectExpand() prior to invoking this routine. + */ + static void sqlite3ResolveSelectNames( + Parse pParse, /* The parser context */ + Select p, /* The SELECT statement being coded. */ + NameContext pOuterNC /* Name context for parent SELECT statement */ + ) { + Walker w = new Walker(); + + Debug.Assert(p != null); + w.xExprCallback = resolveExprStep; + w.xSelectCallback = resolveSelectStep; + w.pParse = pParse; + w.u.pNC = pOuterNC; + sqlite3WalkSelect(w, p); + } } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/rowset_c.cs b/Src/IronPython.SQLite/c#sqlite/rowset_c.cs index d28509751..6da122537 100644 --- a/Src/IronPython.SQLite/c#sqlite/rowset_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/rowset_c.cs @@ -1,519 +1,456 @@ -using System; using System.Diagnostics; -using System.Text; using i64 = System.Int64; -using u8 = System.Byte; using u32 = System.UInt32; +using u8 = System.Byte; -using Pgno = System.UInt32; - -namespace Community.CsharpSqlite -{ - using sqlite3_int64 = System.Int64; - - public partial class Sqlite3 - { - /* - ** 2008 December 3 - ** - ** 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 module implements an object we call a "RowSet". - ** - ** The RowSet object is a collection of rowids. Rowids - ** are inserted into the RowSet in an arbitrary order. Inserts - ** can be intermixed with tests to see if a given rowid has been - ** previously inserted into the RowSet. - ** - ** After all inserts are finished, it is possible to extract the - ** elements of the RowSet in sorted order. Once this extraction - ** process has started, no new elements may be inserted. - ** - ** Hence, the primitive operations for a RowSet are: - ** - ** CREATE - ** INSERT - ** TEST - ** SMALLEST - ** DESTROY - ** - ** The CREATE and DESTROY primitives are the constructor and destructor, - ** obviously. The INSERT primitive adds a new element to the RowSet. - ** TEST checks to see if an element is already in the RowSet. SMALLEST - ** extracts the least value from the RowSet. - ** - ** The INSERT primitive might allocate additional memory. Memory is - ** allocated in chunks so most INSERTs do no allocation. There is an - ** upper bound on the size of allocated memory. No memory is freed - ** until DESTROY. - ** - ** The TEST primitive includes a "batch" number. The TEST primitive - ** will only see elements that were inserted before the last change - ** in the batch number. In other words, if an INSERT occurs between - ** two TESTs where the TESTs have the same batch nubmer, then the - ** value added by the INSERT will not be visible to the second TEST. - ** The initial batch number is zero, so if the very first TEST contains - ** a non-zero batch number, it will see all prior INSERTs. - ** - ** No INSERTs may occurs after a SMALLEST. An assertion will fail if - ** that is attempted. - ** - ** The cost of an INSERT is roughly constant. (Sometime new memory - ** has to be allocated on an INSERT.) The cost of a TEST with a new - ** batch number is O(NlogN) where N is the number of elements in the RowSet. - ** The cost of a TEST using the same batch number is O(logN). The cost - ** of the first SMALLEST is O(NlogN). Second and subsequent SMALLEST - ** primitives are constant time. The cost of DESTROY is O(N). - ** - ** There is an added cost of O(N) when switching between TEST and - ** SMALLEST primitives. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - - /* - ** Target size for allocation chunks. - */ - //#define ROWSET_ALLOCATION_SIZE 1024 - const int ROWSET_ALLOCATION_SIZE = 1024; - /* - ** The number of rowset entries per allocation chunk. - */ - //#define ROWSET_ENTRY_PER_CHUNK \ - // ((ROWSET_ALLOCATION_SIZE-8)/sizeof(struct RowSetEntry)) - const int ROWSET_ENTRY_PER_CHUNK = 63; +namespace Community.CsharpSqlite { + using sqlite3_int64 = System.Int64; - /* - ** Each entry in a RowSet is an instance of the following object. - */ - public class RowSetEntry - { - public i64 v; /* ROWID value for this entry */ - public RowSetEntry pRight; /* Right subtree (larger entries) or list */ - public RowSetEntry pLeft; /* Left subtree (smaller entries) */ - }; + public partial class Sqlite3 { + /* + ** 2008 December 3 + ** + ** 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 module implements an object we call a "RowSet". + ** + ** The RowSet object is a collection of rowids. Rowids + ** are inserted into the RowSet in an arbitrary order. Inserts + ** can be intermixed with tests to see if a given rowid has been + ** previously inserted into the RowSet. + ** + ** After all inserts are finished, it is possible to extract the + ** elements of the RowSet in sorted order. Once this extraction + ** process has started, no new elements may be inserted. + ** + ** Hence, the primitive operations for a RowSet are: + ** + ** CREATE + ** INSERT + ** TEST + ** SMALLEST + ** DESTROY + ** + ** The CREATE and DESTROY primitives are the constructor and destructor, + ** obviously. The INSERT primitive adds a new element to the RowSet. + ** TEST checks to see if an element is already in the RowSet. SMALLEST + ** extracts the least value from the RowSet. + ** + ** The INSERT primitive might allocate additional memory. Memory is + ** allocated in chunks so most INSERTs do no allocation. There is an + ** upper bound on the size of allocated memory. No memory is freed + ** until DESTROY. + ** + ** The TEST primitive includes a "batch" number. The TEST primitive + ** will only see elements that were inserted before the last change + ** in the batch number. In other words, if an INSERT occurs between + ** two TESTs where the TESTs have the same batch nubmer, then the + ** value added by the INSERT will not be visible to the second TEST. + ** The initial batch number is zero, so if the very first TEST contains + ** a non-zero batch number, it will see all prior INSERTs. + ** + ** No INSERTs may occurs after a SMALLEST. An assertion will fail if + ** that is attempted. + ** + ** The cost of an INSERT is roughly constant. (Sometime new memory + ** has to be allocated on an INSERT.) The cost of a TEST with a new + ** batch number is O(NlogN) where N is the number of elements in the RowSet. + ** The cost of a TEST using the same batch number is O(logN). The cost + ** of the first SMALLEST is O(NlogN). Second and subsequent SMALLEST + ** primitives are constant time. The cost of DESTROY is O(N). + ** + ** There is an added cost of O(N) when switching between TEST and + ** SMALLEST primitives. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" - /* - ** Index entries are allocated in large chunks (instances of the - ** following structure) to reduce memory allocation overhead. The - ** chunks are kept on a linked list so that they can be deallocated - ** when the RowSet is destroyed. - */ - public class RowSetChunk - { - public RowSetChunk pNextChunk; /* Next chunk on list of them all */ - public RowSetEntry[] aEntry = new RowSetEntry[ROWSET_ENTRY_PER_CHUNK]; /* Allocated entries */ - }; + /* + ** Target size for allocation chunks. + */ + //#define ROWSET_ALLOCATION_SIZE 1024 + const int ROWSET_ALLOCATION_SIZE = 1024; + /* + ** The number of rowset entries per allocation chunk. + */ + //#define ROWSET_ENTRY_PER_CHUNK \ + // ((ROWSET_ALLOCATION_SIZE-8)/sizeof(struct RowSetEntry)) + const int ROWSET_ENTRY_PER_CHUNK = 63; - /* - ** A RowSet in an instance of the following structure. - ** - ** A typedef of this structure if found in sqliteInt.h. - */ - public class RowSet - { - public RowSetChunk pChunk; /* List of all chunk allocations */ - public sqlite3 db; /* The database connection */ - public RowSetEntry pEntry; /* /* List of entries using pRight */ - public RowSetEntry pLast; /* Last entry on the pEntry list */ - public RowSetEntry[] pFresh; /* Source of new entry objects */ - public RowSetEntry pTree; /* Binary tree of entries */ - public int nFresh; /* Number of objects on pFresh */ - public bool isSorted; /* True if pEntry is sorted */ - public u8 iBatch; /* Current insert batch */ + /* + ** Each entry in a RowSet is an instance of the following object. + */ + public class RowSetEntry { + public i64 v; /* ROWID value for this entry */ + public RowSetEntry pRight; /* Right subtree (larger entries) or list */ + public RowSetEntry pLeft; /* Left subtree (smaller entries) */ + }; - public RowSet( sqlite3 db, int N ) - { - this.pChunk = null; - this.db = db; - this.pEntry = null; - this.pLast = null; - this.pFresh = new RowSetEntry[N]; - this.pTree = null; - this.nFresh = N; - this.isSorted = true; - this.iBatch = 0; - } - }; + /* + ** Index entries are allocated in large chunks (instances of the + ** following structure) to reduce memory allocation overhead. The + ** chunks are kept on a linked list so that they can be deallocated + ** when the RowSet is destroyed. + */ + public class RowSetChunk { + public RowSetChunk pNextChunk; /* Next chunk on list of them all */ + public RowSetEntry[] aEntry = new RowSetEntry[ROWSET_ENTRY_PER_CHUNK]; /* Allocated entries */ + }; - /* - ** Turn bulk memory into a RowSet object. N bytes of memory - ** are available at pSpace. The db pointer is used as a memory context - ** for any subsequent allocations that need to occur. - ** Return a pointer to the new RowSet object. - ** - ** It must be the case that N is sufficient to make a Rowset. If not - ** an assertion fault occurs. - ** - ** If N is larger than the minimum, use the surplus as an initial - ** allocation of entries available to be filled. - */ - static RowSet sqlite3RowSetInit( sqlite3 db, object pSpace, u32 N ) - { - RowSet p = new RowSet( db, (int)N ); - //Debug.Assert(N >= ROUND8(sizeof(*p)) ); - // p = pSpace; - // p.pChunk = 0; - // p.db = db; - // p.pEntry = 0; - // p.pLast = 0; - // p.pTree = 0; - // p.pFresh =(struct RowSetEntry*)(ROUND8(sizeof(*p)) + (char*)p); - // p.nFresh = (u16)((N - ROUND8(sizeof(*p)))/sizeof(struct RowSetEntry)); - // p.isSorted = 1; - // p.iBatch = 0; - return p; - } + /* + ** A RowSet in an instance of the following structure. + ** + ** A typedef of this structure if found in sqliteInt.h. + */ + public class RowSet { + public RowSetChunk pChunk; /* List of all chunk allocations */ + public sqlite3 db; /* The database connection */ + public RowSetEntry pEntry; /* /* List of entries using pRight */ + public RowSetEntry pLast; /* Last entry on the pEntry list */ + public RowSetEntry[] pFresh; /* Source of new entry objects */ + public RowSetEntry pTree; /* Binary tree of entries */ + public int nFresh; /* Number of objects on pFresh */ + public bool isSorted; /* True if pEntry is sorted */ + public u8 iBatch; /* Current insert batch */ - /* - ** Deallocate all chunks from a RowSet. This frees all memory that - ** the RowSet has allocated over its lifetime. This routine is - ** the destructor for the RowSet. - */ - static void sqlite3RowSetClear( RowSet p ) - { - RowSetChunk pChunk, pNextChunk; - for ( pChunk = p.pChunk; pChunk != null; pChunk = pNextChunk ) - { - pNextChunk = pChunk.pNextChunk; - sqlite3DbFree( p.db, ref pChunk ); - } - p.pChunk = null; - p.nFresh = 0; - p.pEntry = null; - p.pLast = null; - p.pTree = null; - p.isSorted = true; - } + public RowSet(sqlite3 db, int N) { + this.pChunk = null; + this.db = db; + this.pEntry = null; + this.pLast = null; + this.pFresh = new RowSetEntry[N]; + this.pTree = null; + this.nFresh = N; + this.isSorted = true; + this.iBatch = 0; + } + }; - /* - ** Insert a new value into a RowSet. - ** - ** The mallocFailed flag of the database connection is set if a - ** memory allocation fails. - */ - static void sqlite3RowSetInsert( RowSet p, i64 rowid ) - { - RowSetEntry pEntry; /* The new entry */ - RowSetEntry pLast; /* The last prior entry */ - Debug.Assert( p != null ); - if ( p.nFresh == 0 ) - { - RowSetChunk pNew; - pNew = new RowSetChunk();//sqlite3DbMallocRaw(p.db, sizeof(*pNew)); - if ( pNew == null ) - { - return; + /* + ** Turn bulk memory into a RowSet object. N bytes of memory + ** are available at pSpace. The db pointer is used as a memory context + ** for any subsequent allocations that need to occur. + ** Return a pointer to the new RowSet object. + ** + ** It must be the case that N is sufficient to make a Rowset. If not + ** an assertion fault occurs. + ** + ** If N is larger than the minimum, use the surplus as an initial + ** allocation of entries available to be filled. + */ + static RowSet sqlite3RowSetInit(sqlite3 db, object pSpace, u32 N) { + RowSet p = new RowSet(db, (int)N); + //Debug.Assert(N >= ROUND8(sizeof(*p)) ); + // p = pSpace; + // p.pChunk = 0; + // p.db = db; + // p.pEntry = 0; + // p.pLast = 0; + // p.pTree = 0; + // p.pFresh =(struct RowSetEntry*)(ROUND8(sizeof(*p)) + (char*)p); + // p.nFresh = (u16)((N - ROUND8(sizeof(*p)))/sizeof(struct RowSetEntry)); + // p.isSorted = 1; + // p.iBatch = 0; + return p; } - pNew.pNextChunk = p.pChunk; - p.pChunk = pNew; - p.pFresh = pNew.aEntry; - p.nFresh = ROWSET_ENTRY_PER_CHUNK; - } - p.pFresh[p.pFresh.Length - p.nFresh] = new RowSetEntry(); - pEntry = p.pFresh[p.pFresh.Length - p.nFresh]; - p.nFresh--; - pEntry.v = rowid; - pEntry.pRight = null; - pLast = p.pLast; - if ( pLast != null ) - { - if ( p.isSorted && rowid <= pLast.v ) - { - p.isSorted = false; - } - pLast.pRight = pEntry; - } - else - { - Debug.Assert( p.pEntry == null );/* Fires if INSERT after SMALLEST */ - p.pEntry = pEntry; - } - p.pLast = pEntry; - } - /* - ** Merge two lists of RowSetEntry objects. Remove duplicates. - ** - ** The input lists are connected via pRight pointers and are - ** assumed to each already be in sorted order. - */ - static RowSetEntry rowSetMerge( - RowSetEntry pA, /* First sorted list to be merged */ - RowSetEntry pB /* Second sorted list to be merged */ - ) - { - RowSetEntry head = new RowSetEntry(); - RowSetEntry pTail; - - pTail = head; - while ( pA != null && pB != null ) - { - Debug.Assert( pA.pRight == null || pA.v <= pA.pRight.v ); - Debug.Assert( pB.pRight == null || pB.v <= pB.pRight.v ); - if ( pA.v < pB.v ) - { - pTail.pRight = pA; - pA = pA.pRight; - pTail = pTail.pRight; - } - else if ( pB.v < pA.v ) - { - pTail.pRight = pB; - pB = pB.pRight; - pTail = pTail.pRight; + /* + ** Deallocate all chunks from a RowSet. This frees all memory that + ** the RowSet has allocated over its lifetime. This routine is + ** the destructor for the RowSet. + */ + static void sqlite3RowSetClear(RowSet p) { + RowSetChunk pChunk, pNextChunk; + for (pChunk = p.pChunk; pChunk != null; pChunk = pNextChunk) { + pNextChunk = pChunk.pNextChunk; + sqlite3DbFree(p.db, ref pChunk); + } + p.pChunk = null; + p.nFresh = 0; + p.pEntry = null; + p.pLast = null; + p.pTree = null; + p.isSorted = true; } - else - { - pA = pA.pRight; + + /* + ** Insert a new value into a RowSet. + ** + ** The mallocFailed flag of the database connection is set if a + ** memory allocation fails. + */ + static void sqlite3RowSetInsert(RowSet p, i64 rowid) { + RowSetEntry pEntry; /* The new entry */ + RowSetEntry pLast; /* The last prior entry */ + Debug.Assert(p != null); + if (p.nFresh == 0) { + RowSetChunk pNew; + pNew = new RowSetChunk();//sqlite3DbMallocRaw(p.db, sizeof(*pNew)); + if (pNew == null) { + return; + } + pNew.pNextChunk = p.pChunk; + p.pChunk = pNew; + p.pFresh = pNew.aEntry; + p.nFresh = ROWSET_ENTRY_PER_CHUNK; + } + p.pFresh[p.pFresh.Length - p.nFresh] = new RowSetEntry(); + pEntry = p.pFresh[p.pFresh.Length - p.nFresh]; + p.nFresh--; + pEntry.v = rowid; + pEntry.pRight = null; + pLast = p.pLast; + if (pLast != null) { + if (p.isSorted && rowid <= pLast.v) { + p.isSorted = false; + } + pLast.pRight = pEntry; + } else { + Debug.Assert(p.pEntry == null);/* Fires if INSERT after SMALLEST */ + p.pEntry = pEntry; + } + p.pLast = pEntry; } - } - if ( pA != null ) - { - Debug.Assert( pA.pRight == null || pA.v <= pA.pRight.v ); - pTail.pRight = pA; - } - else - { - Debug.Assert( pB == null || pB.pRight == null || pB.v <= pB.pRight.v ); - pTail.pRight = pB; - } - return head.pRight; - } - /* - ** Sort all elements on the pEntry list of the RowSet into ascending order. - */ - static void rowSetSort( RowSet p ) - { - u32 i; - RowSetEntry pEntry; - RowSetEntry[] aBucket = new RowSetEntry[40]; + /* + ** Merge two lists of RowSetEntry objects. Remove duplicates. + ** + ** The input lists are connected via pRight pointers and are + ** assumed to each already be in sorted order. + */ + static RowSetEntry rowSetMerge( + RowSetEntry pA, /* First sorted list to be merged */ + RowSetEntry pB /* Second sorted list to be merged */ + ) { + RowSetEntry head = new RowSetEntry(); + RowSetEntry pTail; - Debug.Assert( p.isSorted == false ); - //memset(aBucket, 0, sizeof(aBucket)); - while ( p.pEntry != null ) - { - pEntry = p.pEntry; - p.pEntry = pEntry.pRight; - pEntry.pRight = null; - for ( i = 0; aBucket[i] != null; i++ ) - { - pEntry = rowSetMerge( aBucket[i], pEntry ); - aBucket[i] = null; + pTail = head; + while (pA != null && pB != null) { + Debug.Assert(pA.pRight == null || pA.v <= pA.pRight.v); + Debug.Assert(pB.pRight == null || pB.v <= pB.pRight.v); + if (pA.v < pB.v) { + pTail.pRight = pA; + pA = pA.pRight; + pTail = pTail.pRight; + } else if (pB.v < pA.v) { + pTail.pRight = pB; + pB = pB.pRight; + pTail = pTail.pRight; + } else { + pA = pA.pRight; + } + } + if (pA != null) { + Debug.Assert(pA.pRight == null || pA.v <= pA.pRight.v); + pTail.pRight = pA; + } else { + Debug.Assert(pB == null || pB.pRight == null || pB.v <= pB.pRight.v); + pTail.pRight = pB; + } + return head.pRight; } - aBucket[i] = pEntry; - } - pEntry = null; - for ( i = 0; i < aBucket.Length; i++ )//sizeof(aBucket)/sizeof(aBucket[0]) - { - pEntry = rowSetMerge( pEntry, aBucket[i] ); - } - p.pEntry = pEntry; - p.pLast = null; - p.isSorted = true; - } - /* - ** The input, pIn, is a binary tree (or subtree) of RowSetEntry objects. - ** Convert this tree into a linked list connected by the pRight pointers - ** and return pointers to the first and last elements of the new list. - */ - static void rowSetTreeToList( - RowSetEntry pIn, /* Root of the input tree */ - ref RowSetEntry ppFirst, /* Write head of the output list here */ - ref RowSetEntry ppLast /* Write tail of the output list here */ - ) - { - Debug.Assert( pIn != null ); - if ( pIn.pLeft != null ) - { - RowSetEntry p = new RowSetEntry(); - rowSetTreeToList( pIn.pLeft, ref ppFirst, ref p ); - p.pRight = pIn; - } - else - { - ppFirst = pIn; - } - if ( pIn.pRight != null ) - { - rowSetTreeToList( pIn.pRight, ref pIn.pRight, ref ppLast ); - } - else - { - ppLast = pIn; - } - Debug.Assert( ( ppLast ).pRight == null ); - } + /* + ** Sort all elements on the pEntry list of the RowSet into ascending order. + */ + static void rowSetSort(RowSet p) { + u32 i; + RowSetEntry pEntry; + RowSetEntry[] aBucket = new RowSetEntry[40]; + Debug.Assert(p.isSorted == false); + //memset(aBucket, 0, sizeof(aBucket)); + while (p.pEntry != null) { + pEntry = p.pEntry; + p.pEntry = pEntry.pRight; + pEntry.pRight = null; + for (i = 0; aBucket[i] != null; i++) { + pEntry = rowSetMerge(aBucket[i], pEntry); + aBucket[i] = null; + } + aBucket[i] = pEntry; + } + pEntry = null; + for (i = 0; i < aBucket.Length; i++)//sizeof(aBucket)/sizeof(aBucket[0]) + { + pEntry = rowSetMerge(pEntry, aBucket[i]); + } + p.pEntry = pEntry; + p.pLast = null; + p.isSorted = true; + } - /* - ** Convert a sorted list of elements (connected by pRight) into a binary - ** tree with depth of iDepth. A depth of 1 means the tree contains a single - ** node taken from the head of *ppList. A depth of 2 means a tree with - ** three nodes. And so forth. - ** - ** Use as many entries from the input list as required and update the - ** *ppList to point to the unused elements of the list. If the input - ** list contains too few elements, then construct an incomplete tree - ** and leave *ppList set to NULL. - ** - ** Return a pointer to the root of the constructed binary tree. - */ - static RowSetEntry rowSetNDeepTree( - ref RowSetEntry ppList, - int iDepth - ) - { - RowSetEntry p; /* Root of the new tree */ - RowSetEntry pLeft; /* Left subtree */ - if ( ppList == null ) - { - return null; - } - if ( iDepth == 1 ) - { - p = ppList; - ppList = p.pRight; - p.pLeft = p.pRight = null; - return p; - } - pLeft = rowSetNDeepTree( ref ppList, iDepth - 1 ); - p = ppList; - if ( p == null ) - { - return pLeft; - } - p.pLeft = pLeft; - ppList = p.pRight; - p.pRight = rowSetNDeepTree( ref ppList, iDepth - 1 ); - return p; - } + /* + ** The input, pIn, is a binary tree (or subtree) of RowSetEntry objects. + ** Convert this tree into a linked list connected by the pRight pointers + ** and return pointers to the first and last elements of the new list. + */ + static void rowSetTreeToList( + RowSetEntry pIn, /* Root of the input tree */ + ref RowSetEntry ppFirst, /* Write head of the output list here */ + ref RowSetEntry ppLast /* Write tail of the output list here */ + ) { + Debug.Assert(pIn != null); + if (pIn.pLeft != null) { + RowSetEntry p = new RowSetEntry(); + rowSetTreeToList(pIn.pLeft, ref ppFirst, ref p); + p.pRight = pIn; + } else { + ppFirst = pIn; + } + if (pIn.pRight != null) { + rowSetTreeToList(pIn.pRight, ref pIn.pRight, ref ppLast); + } else { + ppLast = pIn; + } + Debug.Assert((ppLast).pRight == null); + } - /* - ** Convert a sorted list of elements into a binary tree. Make the tree - ** as deep as it needs to be in order to contain the entire list. - */ - static RowSetEntry rowSetListToTree( RowSetEntry pList ) - { - int iDepth; /* Depth of the tree so far */ - RowSetEntry p; /* Current tree root */ - RowSetEntry pLeft; /* Left subtree */ - Debug.Assert( pList != null ); - p = pList; - pList = p.pRight; - p.pLeft = p.pRight = null; - for ( iDepth = 1; pList != null; iDepth++ ) - { - pLeft = p; - p = pList; - pList = p.pRight; - p.pLeft = pLeft; - p.pRight = rowSetNDeepTree( ref pList, iDepth ); - } - return p; - } + /* + ** Convert a sorted list of elements (connected by pRight) into a binary + ** tree with depth of iDepth. A depth of 1 means the tree contains a single + ** node taken from the head of *ppList. A depth of 2 means a tree with + ** three nodes. And so forth. + ** + ** Use as many entries from the input list as required and update the + ** *ppList to point to the unused elements of the list. If the input + ** list contains too few elements, then construct an incomplete tree + ** and leave *ppList set to NULL. + ** + ** Return a pointer to the root of the constructed binary tree. + */ + static RowSetEntry rowSetNDeepTree( + ref RowSetEntry ppList, + int iDepth + ) { + RowSetEntry p; /* Root of the new tree */ + RowSetEntry pLeft; /* Left subtree */ + if (ppList == null) { + return null; + } + if (iDepth == 1) { + p = ppList; + ppList = p.pRight; + p.pLeft = p.pRight = null; + return p; + } + pLeft = rowSetNDeepTree(ref ppList, iDepth - 1); + p = ppList; + if (p == null) { + return pLeft; + } + p.pLeft = pLeft; + ppList = p.pRight; + p.pRight = rowSetNDeepTree(ref ppList, iDepth - 1); + return p; + } - /* - ** Convert the list in p.pEntry into a sorted list if it is not - ** sorted already. If there is a binary tree on p.pTree, then - ** convert it into a list too and merge it into the p.pEntry list. - */ - static void rowSetToList( RowSet p ) - { - if ( !p.isSorted ) - { - rowSetSort( p ); - } - if ( p.pTree != null ) - { - RowSetEntry pHead = new RowSetEntry(); - RowSetEntry pTail = new RowSetEntry(); - rowSetTreeToList( p.pTree, ref pHead, ref pTail ); - p.pTree = null; - p.pEntry = rowSetMerge( p.pEntry, pHead ); - } - } + /* + ** Convert a sorted list of elements into a binary tree. Make the tree + ** as deep as it needs to be in order to contain the entire list. + */ + static RowSetEntry rowSetListToTree(RowSetEntry pList) { + int iDepth; /* Depth of the tree so far */ + RowSetEntry p; /* Current tree root */ + RowSetEntry pLeft; /* Left subtree */ - /* - ** Extract the smallest element from the RowSet. - ** Write the element into *pRowid. Return 1 on success. Return - ** 0 if the RowSet is already empty. - ** - ** After this routine has been called, the sqlite3RowSetInsert() - ** routine may not be called again. - */ - static int sqlite3RowSetNext( RowSet p, ref i64 pRowid ) - { - rowSetToList( p ); - if ( p.pEntry != null ) - { - pRowid = p.pEntry.v; - p.pEntry = p.pEntry.pRight; - if ( p.pEntry == null ) - { - sqlite3RowSetClear( p ); + Debug.Assert(pList != null); + p = pList; + pList = p.pRight; + p.pLeft = p.pRight = null; + for (iDepth = 1; pList != null; iDepth++) { + pLeft = p; + p = pList; + pList = p.pRight; + p.pLeft = pLeft; + p.pRight = rowSetNDeepTree(ref pList, iDepth); + } + return p; } - return 1; - } - else - { - return 0; - } - } - /* - ** Check to see if element iRowid was inserted into the the rowset as - ** part of any insert batch prior to iBatch. Return 1 or 0. - */ - static int sqlite3RowSetTest( RowSet pRowSet, u8 iBatch, sqlite3_int64 iRowid ) - { - RowSetEntry p; - if ( iBatch != pRowSet.iBatch ) - { - if ( pRowSet.pEntry != null ) - { - rowSetToList( pRowSet ); - pRowSet.pTree = rowSetListToTree( pRowSet.pEntry ); - pRowSet.pEntry = null; - pRowSet.pLast = null; - } - pRowSet.iBatch = iBatch; - } - p = pRowSet.pTree; - while ( p != null ) - { - if ( p.v < iRowid ) - { - p = p.pRight; + /* + ** Convert the list in p.pEntry into a sorted list if it is not + ** sorted already. If there is a binary tree on p.pTree, then + ** convert it into a list too and merge it into the p.pEntry list. + */ + static void rowSetToList(RowSet p) { + if (!p.isSorted) { + rowSetSort(p); + } + if (p.pTree != null) { + RowSetEntry pHead = new RowSetEntry(); + RowSetEntry pTail = new RowSetEntry(); + rowSetTreeToList(p.pTree, ref pHead, ref pTail); + p.pTree = null; + p.pEntry = rowSetMerge(p.pEntry, pHead); + } } - else if ( p.v > iRowid ) - { - p = p.pLeft; + + /* + ** Extract the smallest element from the RowSet. + ** Write the element into *pRowid. Return 1 on success. Return + ** 0 if the RowSet is already empty. + ** + ** After this routine has been called, the sqlite3RowSetInsert() + ** routine may not be called again. + */ + static int sqlite3RowSetNext(RowSet p, ref i64 pRowid) { + rowSetToList(p); + if (p.pEntry != null) { + pRowid = p.pEntry.v; + p.pEntry = p.pEntry.pRight; + if (p.pEntry == null) { + sqlite3RowSetClear(p); + } + return 1; + } else { + return 0; + } } - else - { - return 1; + + /* + ** Check to see if element iRowid was inserted into the the rowset as + ** part of any insert batch prior to iBatch. Return 1 or 0. + */ + static int sqlite3RowSetTest(RowSet pRowSet, u8 iBatch, sqlite3_int64 iRowid) { + RowSetEntry p; + if (iBatch != pRowSet.iBatch) { + if (pRowSet.pEntry != null) { + rowSetToList(pRowSet); + pRowSet.pTree = rowSetListToTree(pRowSet.pEntry); + pRowSet.pEntry = null; + pRowSet.pLast = null; + } + pRowSet.iBatch = iBatch; + } + p = pRowSet.pTree; + while (p != null) { + if (p.v < iRowid) { + p = p.pRight; + } else if (p.v > iRowid) { + p = p.pLeft; + } else { + return 1; + } + } + return 0; } - } - return 0; - } - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/select_c.cs b/Src/IronPython.SQLite/c#sqlite/select_c.cs index 99f2975ae..c759fc952 100644 --- a/Src/IronPython.SQLite/c#sqlite/select_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/select_c.cs @@ -1,194 +1,176 @@ #define SQLITE_MAX_EXPR_DEPTH using System; using System.Diagnostics; -using System.Text; using i16 = System.Int16; -using u8 = System.Byte; using u16 = System.UInt16; -using u32 = System.UInt32; - -using Pgno = System.UInt32; +using u8 = System.Byte; -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 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. - ** - ************************************************************************* - ** This file contains C code routines that are called by the parser - ** to handle SELECT statements in SQLite. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** This file contains C code routines that are called by the parser + ** to handle SELECT statements in SQLite. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" - /* - ** Delete all the content of a Select structure but do not deallocate - ** the select structure itself. - */ - static void clearSelect( sqlite3 db, Select p ) - { - sqlite3ExprListDelete( db, ref p.pEList ); - sqlite3SrcListDelete( db, ref p.pSrc ); - sqlite3ExprDelete( db, ref p.pWhere ); - sqlite3ExprListDelete( db, ref p.pGroupBy ); - sqlite3ExprDelete( db, ref p.pHaving ); - sqlite3ExprListDelete( db, ref p.pOrderBy ); - sqlite3SelectDelete( db, ref p.pPrior ); - sqlite3ExprDelete( db, ref p.pLimit ); - sqlite3ExprDelete( db, ref p.pOffset ); - } + /* + ** Delete all the content of a Select structure but do not deallocate + ** the select structure itself. + */ + static void clearSelect(sqlite3 db, Select p) { + sqlite3ExprListDelete(db, ref p.pEList); + sqlite3SrcListDelete(db, ref p.pSrc); + sqlite3ExprDelete(db, ref p.pWhere); + sqlite3ExprListDelete(db, ref p.pGroupBy); + sqlite3ExprDelete(db, ref p.pHaving); + sqlite3ExprListDelete(db, ref p.pOrderBy); + sqlite3SelectDelete(db, ref p.pPrior); + sqlite3ExprDelete(db, ref p.pLimit); + sqlite3ExprDelete(db, ref p.pOffset); + } - /* - ** Initialize a SelectDest structure. - */ - static void sqlite3SelectDestInit( SelectDest pDest, int eDest, int iParm ) - { - pDest.eDest = (u8)eDest; - pDest.iParm = iParm; - pDest.affinity = '\0'; - pDest.iMem = 0; - pDest.nMem = 0; - } + /* + ** Initialize a SelectDest structure. + */ + static void sqlite3SelectDestInit(SelectDest pDest, int eDest, int iParm) { + pDest.eDest = (u8)eDest; + pDest.iParm = iParm; + pDest.affinity = '\0'; + pDest.iMem = 0; + pDest.nMem = 0; + } - /* - ** Allocate a new Select structure and return a pointer to that - ** structure. - */ - // OVERLOADS, so I don't need to rewrite parse.c - static Select sqlite3SelectNew( Parse pParse, int null_2, SrcList pSrc, int null_4, int null_5, int null_6, int null_7, int isDistinct, int null_9, int null_10 ) - { - return sqlite3SelectNew( pParse, null, pSrc, null, null, null, null, isDistinct, null, null ); - } - static Select sqlite3SelectNew( - Parse pParse, /* Parsing context */ - ExprList pEList, /* which columns to include in the result */ - SrcList pSrc, /* the FROM clause -- which tables to scan */ - Expr pWhere, /* the WHERE clause */ - ExprList pGroupBy, /* the GROUP BY clause */ - Expr pHaving, /* the HAVING clause */ - ExprList pOrderBy, /* the ORDER BY clause */ - int isDistinct, /* true if the DISTINCT keyword is present */ - Expr pLimit, /* LIMIT value. NULL means not used */ - Expr pOffset /* OFFSET value. NULL means no offset */ - ) - { - Select pNew; - // Select standin; - sqlite3 db = pParse.db; - pNew = new Select();//sqlite3DbMallocZero(db, sizeof(*pNew) ); - Debug.Assert( //db.mallocFailed != 0 || - null == pOffset || pLimit != null ); /* OFFSET implies LIMIT */ - //if( pNew==null ){ - // pNew = standin; - // memset(pNew, 0, sizeof(*pNew)); - //} - if ( pEList == null ) - { - pEList = sqlite3ExprListAppend( pParse, null, sqlite3Expr( db, TK_ALL, null ) ); - } - pNew.pEList = pEList; - pNew.pSrc = pSrc; - pNew.pWhere = pWhere; - pNew.pGroupBy = pGroupBy; - pNew.pHaving = pHaving; - pNew.pOrderBy = pOrderBy; - pNew.selFlags = (u16)( isDistinct != 0 ? SF_Distinct : 0 ); - pNew.op = TK_SELECT; - pNew.pLimit = pLimit; - pNew.pOffset = pOffset; - Debug.Assert( pOffset == null || pLimit != null ); - pNew.addrOpenEphm[0] = -1; - pNew.addrOpenEphm[1] = -1; - pNew.addrOpenEphm[2] = -1; - //if ( db.mallocFailed != 0 ) - //{ - // clearSelect( db, pNew ); - // //if ( pNew != standin ) sqlite3DbFree( db, ref pNew ); - // pNew = null; - //} - return pNew; - } + /* + ** Allocate a new Select structure and return a pointer to that + ** structure. + */ + // OVERLOADS, so I don't need to rewrite parse.c + static Select sqlite3SelectNew(Parse pParse, int null_2, SrcList pSrc, int null_4, int null_5, int null_6, int null_7, int isDistinct, int null_9, int null_10) { + return sqlite3SelectNew(pParse, null, pSrc, null, null, null, null, isDistinct, null, null); + } + static Select sqlite3SelectNew( + Parse pParse, /* Parsing context */ + ExprList pEList, /* which columns to include in the result */ + SrcList pSrc, /* the FROM clause -- which tables to scan */ + Expr pWhere, /* the WHERE clause */ + ExprList pGroupBy, /* the GROUP BY clause */ + Expr pHaving, /* the HAVING clause */ + ExprList pOrderBy, /* the ORDER BY clause */ + int isDistinct, /* true if the DISTINCT keyword is present */ + Expr pLimit, /* LIMIT value. NULL means not used */ + Expr pOffset /* OFFSET value. NULL means no offset */ + ) { + Select pNew; + // Select standin; + sqlite3 db = pParse.db; + pNew = new Select();//sqlite3DbMallocZero(db, sizeof(*pNew) ); + Debug.Assert( //db.mallocFailed != 0 || + null == pOffset || pLimit != null); /* OFFSET implies LIMIT */ + //if( pNew==null ){ + // pNew = standin; + // memset(pNew, 0, sizeof(*pNew)); + //} + if (pEList == null) { + pEList = sqlite3ExprListAppend(pParse, null, sqlite3Expr(db, TK_ALL, null)); + } + pNew.pEList = pEList; + pNew.pSrc = pSrc; + pNew.pWhere = pWhere; + pNew.pGroupBy = pGroupBy; + pNew.pHaving = pHaving; + pNew.pOrderBy = pOrderBy; + pNew.selFlags = (u16)(isDistinct != 0 ? SF_Distinct : 0); + pNew.op = TK_SELECT; + pNew.pLimit = pLimit; + pNew.pOffset = pOffset; + Debug.Assert(pOffset == null || pLimit != null); + pNew.addrOpenEphm[0] = -1; + pNew.addrOpenEphm[1] = -1; + pNew.addrOpenEphm[2] = -1; + //if ( db.mallocFailed != 0 ) + //{ + // clearSelect( db, pNew ); + // //if ( pNew != standin ) sqlite3DbFree( db, ref pNew ); + // pNew = null; + //} + return pNew; + } - /* - ** Delete the given Select structure and all of its substructures. - */ - static void sqlite3SelectDelete( sqlite3 db, ref Select p ) - { - if ( p != null ) - { - clearSelect( db, p ); - sqlite3DbFree( db, ref p ); - } - } + /* + ** Delete the given Select structure and all of its substructures. + */ + static void sqlite3SelectDelete(sqlite3 db, ref Select p) { + if (p != null) { + clearSelect(db, p); + sqlite3DbFree(db, ref p); + } + } - /* - ** Given 1 to 3 identifiers preceeding the JOIN keyword, determine the - ** type of join. Return an integer constant that expresses that type - ** in terms of the following bit values: - ** - ** JT_INNER - ** JT_CROSS - ** JT_OUTER - ** JT_NATURAL - ** JT_LEFT - ** JT_RIGHT - ** - ** A full outer join is the combination of JT_LEFT and JT_RIGHT. - ** - ** If an illegal or unsupported join type is seen, then still return - ** a join type, but put an error in the pParse structure. - */ + /* + ** Given 1 to 3 identifiers preceeding the JOIN keyword, determine the + ** type of join. Return an integer constant that expresses that type + ** in terms of the following bit values: + ** + ** JT_INNER + ** JT_CROSS + ** JT_OUTER + ** JT_NATURAL + ** JT_LEFT + ** JT_RIGHT + ** + ** A full outer join is the combination of JT_LEFT and JT_RIGHT. + ** + ** If an illegal or unsupported join type is seen, then still return + ** a join type, but put an error in the pParse structure. + */ - class Keyword - { - public u8 i; /* Beginning of keyword text in zKeyText[] */ - public u8 nChar; /* Length of the keyword in characters */ - public u8 code; /* Join type mask */ - public Keyword( u8 i, u8 nChar, u8 code ) - { - this.i = i; - this.nChar = nChar; - this.code = code; - } - } + class Keyword { + public u8 i; /* Beginning of keyword text in zKeyText[] */ + public u8 nChar; /* Length of the keyword in characters */ + public u8 code; /* Join type mask */ + public Keyword(u8 i, u8 nChar, u8 code) { + this.i = i; + this.nChar = nChar; + this.code = code; + } + } - // OVERLOADS, so I don't need to rewrite parse.c - static int sqlite3JoinType( Parse pParse, Token pA, int null_3, int null_4 ) - { - return sqlite3JoinType( pParse, pA, null, null ); - } - static int sqlite3JoinType( Parse pParse, Token pA, Token pB, int null_4 ) - { - return sqlite3JoinType( pParse, pA, pB, null ); - } - static int sqlite3JoinType( Parse pParse, Token pA, Token pB, Token pC ) - { - int jointype = 0; - Token[] apAll = new Token[3]; - Token p; + // OVERLOADS, so I don't need to rewrite parse.c + static int sqlite3JoinType(Parse pParse, Token pA, int null_3, int null_4) { + return sqlite3JoinType(pParse, pA, null, null); + } + static int sqlite3JoinType(Parse pParse, Token pA, Token pB, int null_4) { + return sqlite3JoinType(pParse, pA, pB, null); + } + static int sqlite3JoinType(Parse pParse, Token pA, Token pB, Token pC) { + int jointype = 0; + Token[] apAll = new Token[3]; + Token p; - /* 0123456789 123456789 123456789 123 */ - string zKeyText = "naturaleftouterightfullinnercross"; + /* 0123456789 123456789 123456789 123 */ + string zKeyText = "naturaleftouterightfullinnercross"; - Keyword[] aKeyword = new Keyword[]{ + Keyword[] aKeyword = new Keyword[]{ /* natural */ new Keyword( 0, 7, JT_NATURAL ), /* left */ new Keyword( 6, 4, JT_LEFT|JT_OUTER ), /* outer */ new Keyword( 10, 5, JT_OUTER ), @@ -197,799 +179,711 @@ static int sqlite3JoinType( Parse pParse, Token pA, Token pB, Token pC ) /* inner */ new Keyword( 23, 5, JT_INNER ), /* cross */ new Keyword( 28, 5, JT_INNER|JT_CROSS ), }; - int i, j; - apAll[0] = pA; - apAll[1] = pB; - apAll[2] = pC; - for ( i = 0; i < 3 && apAll[i] != null; i++ ) - { - p = apAll[i]; - for ( j = 0; j < ArraySize( aKeyword ); j++ ) - { - if ( p.n == aKeyword[j].nChar - && p.z.StartsWith( zKeyText.Substring( aKeyword[j].i, aKeyword[j].nChar ), StringComparison.OrdinalIgnoreCase ) ) - { - jointype |= aKeyword[j].code; - break; - } - } - testcase( j == 0 || j == 1 || j == 2 || j == 3 || j == 4 || j == 5 || j == 6 ); - if ( j >= ArraySize( aKeyword ) ) - { - jointype |= JT_ERROR; - break; - } - } - if ( - ( jointype & ( JT_INNER | JT_OUTER ) ) == ( JT_INNER | JT_OUTER ) || - ( jointype & JT_ERROR ) != 0 - ) - { - string zSp = " "; - Debug.Assert( pB != null ); - if ( pC == null ) - { - zSp = ""; + int i, j; + apAll[0] = pA; + apAll[1] = pB; + apAll[2] = pC; + for (i = 0; i < 3 && apAll[i] != null; i++) { + p = apAll[i]; + for (j = 0; j < ArraySize(aKeyword); j++) { + if (p.n == aKeyword[j].nChar + && p.z.StartsWith(zKeyText.Substring(aKeyword[j].i, aKeyword[j].nChar), StringComparison.OrdinalIgnoreCase)) { + jointype |= aKeyword[j].code; + break; + } + } + testcase(j == 0 || j == 1 || j == 2 || j == 3 || j == 4 || j == 5 || j == 6); + if (j >= ArraySize(aKeyword)) { + jointype |= JT_ERROR; + break; + } + } + if ( + (jointype & (JT_INNER | JT_OUTER)) == (JT_INNER | JT_OUTER) || + (jointype & JT_ERROR) != 0 + ) { + string zSp = " "; + Debug.Assert(pB != null); + if (pC == null) { + zSp = ""; + } + sqlite3ErrorMsg(pParse, "unknown or unsupported join type: " + + "%T %T%s%T", pA, pB, zSp, pC); + jointype = JT_INNER; + } else if ((jointype & JT_OUTER) != 0 + && (jointype & (JT_LEFT | JT_RIGHT)) != JT_LEFT) { + sqlite3ErrorMsg(pParse, + "RIGHT and FULL OUTER JOINs are not currently supported"); + jointype = JT_INNER; + } + return jointype; } - sqlite3ErrorMsg( pParse, "unknown or unsupported join type: " + - "%T %T%s%T", pA, pB, zSp, pC ); - jointype = JT_INNER; - } - else if ( ( jointype & JT_OUTER ) != 0 - && ( jointype & ( JT_LEFT | JT_RIGHT ) ) != JT_LEFT ) - { - sqlite3ErrorMsg( pParse, - "RIGHT and FULL OUTER JOINs are not currently supported" ); - jointype = JT_INNER; - } - return jointype; - } - /* - ** Return the index of a column in a table. Return -1 if the column - ** is not contained in the table. - */ - static int columnIndex( Table pTab, string zCol ) - { - int i; - for ( i = 0; i < pTab.nCol; i++ ) - { - if ( pTab.aCol[i].zName.Equals( zCol, StringComparison.OrdinalIgnoreCase ) ) - return i; - } - return -1; - } - - - /* - ** Search the first N tables in pSrc, from left to right, looking for a - ** table that has a column named zCol. - ** - ** When found, set *piTab and *piCol to the table index and column index - ** of the matching column and return TRUE. - ** - ** If not found, return FALSE. - */ - static int tableAndColumnIndex( - SrcList pSrc, /* Array of tables to search */ - int N, /* Number of tables in pSrc.a[] to search */ - string zCol, /* Name of the column we are looking for */ - ref int piTab, /* Write index of pSrc.a[] here */ - ref int piCol /* Write index of pSrc.a[*piTab].pTab.aCol[] here */ - ) - { - int i; /* For looping over tables in pSrc */ - int iCol; /* Index of column matching zCol */ - - Debug.Assert( ( piTab == 0 ) == ( piCol == 0 ) ); /* Both or neither are NULL */ - for ( i = 0; i < N; i++ ) - { - iCol = columnIndex( pSrc.a[i].pTab, zCol ); - if ( iCol >= 0 ) - { - //if( piTab ) - { - piTab = i; - piCol = iCol; - } - return 1; + /* + ** Return the index of a column in a table. Return -1 if the column + ** is not contained in the table. + */ + static int columnIndex(Table pTab, string zCol) { + int i; + for (i = 0; i < pTab.nCol; i++) { + if (pTab.aCol[i].zName.Equals(zCol, StringComparison.OrdinalIgnoreCase)) + return i; + } + return -1; } - } - return 0; - } - /* - ** This function is used to add terms implied by JOIN syntax to the - ** WHERE clause expression of a SELECT statement. The new term, which - ** is ANDed with the existing WHERE clause, is of the form: - ** - ** (vtab1.col1 = tab2.col2) - ** - ** where tab1 is the iSrc'th table in SrcList pSrc and tab2 is the - ** (iSrc+1)'th. Column col1 is column iColLeft of tab1, and col2 is - ** column iColRight of tab2. - */ - static void addWhereTerm( - Parse pParse, /* Parsing context */ - SrcList pSrc, /* List of tables in FROM clause */ - int iLeft, /* Index of first table to join in pSrc */ - int iColLeft, /* Index of column in first table */ - int iRight, /* Index of second table in pSrc */ - int iColRight, /* Index of column in second table */ - int isOuterJoin, /* True if this is an OUTER join */ - ref Expr ppWhere /* IN/OUT: The WHERE clause to add to */ - ) - { - sqlite3 db = pParse.db; - Expr pE1; - Expr pE2; - Expr pEq; - - Debug.Assert( iLeft < iRight ); - Debug.Assert( pSrc.nSrc > iRight ); - Debug.Assert( pSrc.a[iLeft].pTab != null ); - Debug.Assert( pSrc.a[iRight].pTab != null ); - - pE1 = sqlite3CreateColumnExpr( db, pSrc, iLeft, iColLeft ); - pE2 = sqlite3CreateColumnExpr( db, pSrc, iRight, iColRight ); - - pEq = sqlite3PExpr( pParse, TK_EQ, pE1, pE2, 0 ); - if ( pEq != null && isOuterJoin != 0 ) - { - ExprSetProperty( pEq, EP_FromJoin ); - Debug.Assert( !ExprHasAnyProperty( pEq, EP_TokenOnly | EP_Reduced ) ); - ExprSetIrreducible( pEq ); - pEq.iRightJoinTable = (i16)pE2.iTable; - } - ppWhere = sqlite3ExprAnd( db, ppWhere, pEq ); - } - /* - ** Set the EP_FromJoin property on all terms of the given expression. - ** And set the Expr.iRightJoinTable to iTable for every term in the - ** expression. - ** - ** The EP_FromJoin property is used on terms of an expression to tell - ** the LEFT OUTER JOIN processing logic that this term is part of the - ** join restriction specified in the ON or USING clause and not a part - ** of the more general WHERE clause. These terms are moved over to the - ** WHERE clause during join processing but we need to remember that they - ** originated in the ON or USING clause. - ** - ** The Expr.iRightJoinTable tells the WHERE clause processing that the - ** expression depends on table iRightJoinTable even if that table is not - ** explicitly mentioned in the expression. That information is needed - ** for cases like this: - ** - ** SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.b AND t1.x=5 - ** - ** The where clause needs to defer the handling of the t1.x=5 - ** term until after the t2 loop of the join. In that way, a - ** NULL t2 row will be inserted whenever t1.x!=5. If we do not - ** defer the handling of t1.x=5, it will be processed immediately - ** after the t1 loop and rows with t1.x!=5 will never appear in - ** the output, which is incorrect. - */ - static void setJoinExpr( Expr p, int iTable ) - { - while ( p != null ) - { - ExprSetProperty( p, EP_FromJoin ); - Debug.Assert( !ExprHasAnyProperty( p, EP_TokenOnly | EP_Reduced ) ); - ExprSetIrreducible( p ); - p.iRightJoinTable = (i16)iTable; - setJoinExpr( p.pLeft, iTable ); - p = p.pRight; - } - } + /* + ** Search the first N tables in pSrc, from left to right, looking for a + ** table that has a column named zCol. + ** + ** When found, set *piTab and *piCol to the table index and column index + ** of the matching column and return TRUE. + ** + ** If not found, return FALSE. + */ + static int tableAndColumnIndex( + SrcList pSrc, /* Array of tables to search */ + int N, /* Number of tables in pSrc.a[] to search */ + string zCol, /* Name of the column we are looking for */ + ref int piTab, /* Write index of pSrc.a[] here */ + ref int piCol /* Write index of pSrc.a[*piTab].pTab.aCol[] here */ + ) { + int i; /* For looping over tables in pSrc */ + int iCol; /* Index of column matching zCol */ + + Debug.Assert((piTab == 0) == (piCol == 0)); /* Both or neither are NULL */ + for (i = 0; i < N; i++) { + iCol = columnIndex(pSrc.a[i].pTab, zCol); + if (iCol >= 0) { + //if( piTab ) + { + piTab = i; + piCol = iCol; + } + return 1; + } + } + return 0; + } - /* - ** This routine processes the join information for a SELECT statement. - ** ON and USING clauses are converted into extra terms of the WHERE clause. - ** NATURAL joins also create extra WHERE clause terms. - ** - ** The terms of a FROM clause are contained in the Select.pSrc structure. - ** The left most table is the first entry in Select.pSrc. The right-most - ** table is the last entry. The join operator is held in the entry to - ** the left. Thus entry 0 contains the join operator for the join between - ** entries 0 and 1. Any ON or USING clauses associated with the join are - ** also attached to the left entry. - ** - ** This routine returns the number of errors encountered. - */ - static int sqliteProcessJoin( Parse pParse, Select p ) - { - SrcList pSrc; /* All tables in the FROM clause */ - int i; - int j; /* Loop counters */ - SrcList_item pLeft; /* Left table being joined */ - SrcList_item pRight; /* Right table being joined */ - - pSrc = p.pSrc; - //pLeft = pSrc.a[0]; - //pRight = pLeft[1]; - for ( i = 0; i < pSrc.nSrc - 1; i++ ) - { - pLeft = pSrc.a[i]; // pLeft ++ - pRight = pSrc.a[i + 1];//Right++, - Table pLeftTab = pLeft.pTab; - Table pRightTab = pRight.pTab; - bool isOuter; - - if ( NEVER( pLeftTab == null || pRightTab == null ) ) - continue; - isOuter = ( pRight.jointype & JT_OUTER ) != 0; - - /* When the NATURAL keyword is present, add WHERE clause terms for - ** every column that the two tables have in common. + /* + ** This function is used to add terms implied by JOIN syntax to the + ** WHERE clause expression of a SELECT statement. The new term, which + ** is ANDed with the existing WHERE clause, is of the form: + ** + ** (vtab1.col1 = tab2.col2) + ** + ** where tab1 is the iSrc'th table in SrcList pSrc and tab2 is the + ** (iSrc+1)'th. Column col1 is column iColLeft of tab1, and col2 is + ** column iColRight of tab2. */ - if ( ( pRight.jointype & JT_NATURAL ) != 0 ) - { - if ( pRight.pOn != null || pRight.pUsing != null ) - { - sqlite3ErrorMsg( pParse, "a NATURAL join may not have " + - "an ON or USING clause", "" ); - return 1; - } - for ( j = 0; j < pRightTab.nCol; j++ ) - { - string zName; /* Name of column in the right table */ - int iLeft = 0; /* Matching left table */ - int iLeftCol = 0; /* Matching column in the left table */ - - zName = pRightTab.aCol[j].zName; - int iRightCol = columnIndex( pRightTab, zName ); - if ( tableAndColumnIndex( pSrc, i + 1, zName, ref iLeft, ref iLeftCol ) != 0 ) - { - addWhereTerm( pParse, pSrc, iLeft, iLeftCol, i + 1, j, - isOuter ? 1 : 0, ref p.pWhere ); + static void addWhereTerm( + Parse pParse, /* Parsing context */ + SrcList pSrc, /* List of tables in FROM clause */ + int iLeft, /* Index of first table to join in pSrc */ + int iColLeft, /* Index of column in first table */ + int iRight, /* Index of second table in pSrc */ + int iColRight, /* Index of column in second table */ + int isOuterJoin, /* True if this is an OUTER join */ + ref Expr ppWhere /* IN/OUT: The WHERE clause to add to */ + ) { + sqlite3 db = pParse.db; + Expr pE1; + Expr pE2; + Expr pEq; + + Debug.Assert(iLeft < iRight); + Debug.Assert(pSrc.nSrc > iRight); + Debug.Assert(pSrc.a[iLeft].pTab != null); + Debug.Assert(pSrc.a[iRight].pTab != null); + + pE1 = sqlite3CreateColumnExpr(db, pSrc, iLeft, iColLeft); + pE2 = sqlite3CreateColumnExpr(db, pSrc, iRight, iColRight); + + pEq = sqlite3PExpr(pParse, TK_EQ, pE1, pE2, 0); + if (pEq != null && isOuterJoin != 0) { + ExprSetProperty(pEq, EP_FromJoin); + Debug.Assert(!ExprHasAnyProperty(pEq, EP_TokenOnly | EP_Reduced)); + ExprSetIrreducible(pEq); + pEq.iRightJoinTable = (i16)pE2.iTable; } - } + ppWhere = sqlite3ExprAnd(db, ppWhere, pEq); } - /* Disallow both ON and USING clauses in the same join + /* + ** Set the EP_FromJoin property on all terms of the given expression. + ** And set the Expr.iRightJoinTable to iTable for every term in the + ** expression. + ** + ** The EP_FromJoin property is used on terms of an expression to tell + ** the LEFT OUTER JOIN processing logic that this term is part of the + ** join restriction specified in the ON or USING clause and not a part + ** of the more general WHERE clause. These terms are moved over to the + ** WHERE clause during join processing but we need to remember that they + ** originated in the ON or USING clause. + ** + ** The Expr.iRightJoinTable tells the WHERE clause processing that the + ** expression depends on table iRightJoinTable even if that table is not + ** explicitly mentioned in the expression. That information is needed + ** for cases like this: + ** + ** SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.b AND t1.x=5 + ** + ** The where clause needs to defer the handling of the t1.x=5 + ** term until after the t2 loop of the join. In that way, a + ** NULL t2 row will be inserted whenever t1.x!=5. If we do not + ** defer the handling of t1.x=5, it will be processed immediately + ** after the t1 loop and rows with t1.x!=5 will never appear in + ** the output, which is incorrect. */ - if ( pRight.pOn != null && pRight.pUsing != null ) - { - sqlite3ErrorMsg( pParse, "cannot have both ON and USING " + - "clauses in the same join" ); - return 1; + static void setJoinExpr(Expr p, int iTable) { + while (p != null) { + ExprSetProperty(p, EP_FromJoin); + Debug.Assert(!ExprHasAnyProperty(p, EP_TokenOnly | EP_Reduced)); + ExprSetIrreducible(p); + p.iRightJoinTable = (i16)iTable; + setJoinExpr(p.pLeft, iTable); + p = p.pRight; + } } - /* Add the ON clause to the end of the WHERE clause, connected by - ** an AND operator. + /* + ** This routine processes the join information for a SELECT statement. + ** ON and USING clauses are converted into extra terms of the WHERE clause. + ** NATURAL joins also create extra WHERE clause terms. + ** + ** The terms of a FROM clause are contained in the Select.pSrc structure. + ** The left most table is the first entry in Select.pSrc. The right-most + ** table is the last entry. The join operator is held in the entry to + ** the left. Thus entry 0 contains the join operator for the join between + ** entries 0 and 1. Any ON or USING clauses associated with the join are + ** also attached to the left entry. + ** + ** This routine returns the number of errors encountered. */ - if ( pRight.pOn != null ) - { - if ( isOuter ) - setJoinExpr( pRight.pOn, pRight.iCursor ); - p.pWhere = sqlite3ExprAnd( pParse.db, p.pWhere, pRight.pOn ); - pRight.pOn = null; + static int sqliteProcessJoin(Parse pParse, Select p) { + SrcList pSrc; /* All tables in the FROM clause */ + int i; + int j; /* Loop counters */ + SrcList_item pLeft; /* Left table being joined */ + SrcList_item pRight; /* Right table being joined */ + + pSrc = p.pSrc; + //pLeft = pSrc.a[0]; + //pRight = pLeft[1]; + for (i = 0; i < pSrc.nSrc - 1; i++) { + pLeft = pSrc.a[i]; // pLeft ++ + pRight = pSrc.a[i + 1];//Right++, + Table pLeftTab = pLeft.pTab; + Table pRightTab = pRight.pTab; + bool isOuter; + + if (NEVER(pLeftTab == null || pRightTab == null)) + continue; + isOuter = (pRight.jointype & JT_OUTER) != 0; + + /* When the NATURAL keyword is present, add WHERE clause terms for + ** every column that the two tables have in common. + */ + if ((pRight.jointype & JT_NATURAL) != 0) { + if (pRight.pOn != null || pRight.pUsing != null) { + sqlite3ErrorMsg(pParse, "a NATURAL join may not have " + + "an ON or USING clause", ""); + return 1; + } + for (j = 0; j < pRightTab.nCol; j++) { + string zName; /* Name of column in the right table */ + int iLeft = 0; /* Matching left table */ + int iLeftCol = 0; /* Matching column in the left table */ + + zName = pRightTab.aCol[j].zName; + int iRightCol = columnIndex(pRightTab, zName); + if (tableAndColumnIndex(pSrc, i + 1, zName, ref iLeft, ref iLeftCol) != 0) { + addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i + 1, j, + isOuter ? 1 : 0, ref p.pWhere); + } + } + } + + /* Disallow both ON and USING clauses in the same join + */ + if (pRight.pOn != null && pRight.pUsing != null) { + sqlite3ErrorMsg(pParse, "cannot have both ON and USING " + + "clauses in the same join"); + return 1; + } + + /* Add the ON clause to the end of the WHERE clause, connected by + ** an AND operator. + */ + if (pRight.pOn != null) { + if (isOuter) + setJoinExpr(pRight.pOn, pRight.iCursor); + p.pWhere = sqlite3ExprAnd(pParse.db, p.pWhere, pRight.pOn); + pRight.pOn = null; + } + + /* Create extra terms on the WHERE clause for each column named + ** in the USING clause. Example: If the two tables to be joined are + ** A and B and the USING clause names X, Y, and Z, then add this + ** to the WHERE clause: A.X=B.X AND A.Y=B.Y AND A.Z=B.Z + ** Report an error if any column mentioned in the USING clause is + ** not contained in both tables to be joined. + */ + if (pRight.pUsing != null) { + IdList pList = pRight.pUsing; + for (j = 0; j < pList.nId; j++) { + string zName; /* Name of the term in the USING clause */ + int iLeft = 0; /* Table on the left with matching column name */ + int iLeftCol = 0; /* Column number of matching column on the left */ + int iRightCol; /* Column number of matching column on the right */ + + zName = pList.a[j].zName; + iRightCol = columnIndex(pRightTab, zName); + if (iRightCol < 0 + || 0 == tableAndColumnIndex(pSrc, i + 1, zName, ref iLeft, ref iLeftCol) + ) { + sqlite3ErrorMsg(pParse, "cannot join using column %s - column " + + "not present in both tables", zName); + return 1; + } + addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i + 1, iRightCol, + isOuter ? 1 : 0, ref p.pWhere); + } + } + } + return 0; } - /* Create extra terms on the WHERE clause for each column named - ** in the USING clause. Example: If the two tables to be joined are - ** A and B and the USING clause names X, Y, and Z, then add this - ** to the WHERE clause: A.X=B.X AND A.Y=B.Y AND A.Z=B.Z - ** Report an error if any column mentioned in the USING clause is - ** not contained in both tables to be joined. + /* + ** Insert code into "v" that will push the record on the top of the + ** stack into the sorter. */ - if ( pRight.pUsing != null ) - { - IdList pList = pRight.pUsing; - for ( j = 0; j < pList.nId; j++ ) - { - string zName; /* Name of the term in the USING clause */ - int iLeft = 0; /* Table on the left with matching column name */ - int iLeftCol = 0; /* Column number of matching column on the left */ - int iRightCol; /* Column number of matching column on the right */ - - zName = pList.a[j].zName; - iRightCol = columnIndex( pRightTab, zName ); - if ( iRightCol < 0 - || 0 == tableAndColumnIndex( pSrc, i + 1, zName, ref iLeft, ref iLeftCol ) - ) - { - sqlite3ErrorMsg( pParse, "cannot join using column %s - column " + - "not present in both tables", zName ); - return 1; + static void pushOntoSorter( + Parse pParse, /* Parser context */ + ExprList pOrderBy, /* The ORDER BY clause */ + Select pSelect, /* The whole SELECT statement */ + int regData /* Register holding data to be sorted */ + ) { + Vdbe v = pParse.pVdbe; + int nExpr = pOrderBy.nExpr; + int regBase = sqlite3GetTempRange(pParse, nExpr + 2); + int regRecord = sqlite3GetTempReg(pParse); + sqlite3ExprCacheClear(pParse); + sqlite3ExprCodeExprList(pParse, pOrderBy, regBase, false); + sqlite3VdbeAddOp2(v, OP_Sequence, pOrderBy.iECursor, regBase + nExpr); + sqlite3ExprCodeMove(pParse, regData, regBase + nExpr + 1, 1); + sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nExpr + 2, regRecord); + sqlite3VdbeAddOp2(v, OP_IdxInsert, pOrderBy.iECursor, regRecord); + sqlite3ReleaseTempReg(pParse, regRecord); + sqlite3ReleaseTempRange(pParse, regBase, nExpr + 2); + if (pSelect.iLimit != 0) { + int addr1, addr2; + int iLimit; + if (pSelect.iOffset != 0) { + iLimit = pSelect.iOffset + 1; + } else { + iLimit = pSelect.iLimit; + } + addr1 = sqlite3VdbeAddOp1(v, OP_IfZero, iLimit); + sqlite3VdbeAddOp2(v, OP_AddImm, iLimit, -1); + addr2 = sqlite3VdbeAddOp0(v, OP_Goto); + sqlite3VdbeJumpHere(v, addr1); + sqlite3VdbeAddOp1(v, OP_Last, pOrderBy.iECursor); + sqlite3VdbeAddOp1(v, OP_Delete, pOrderBy.iECursor); + sqlite3VdbeJumpHere(v, addr2); } - addWhereTerm( pParse, pSrc, iLeft, iLeftCol, i + 1, iRightCol, - isOuter ? 1 : 0, ref p.pWhere ); - } } - } - return 0; - } - /* - ** Insert code into "v" that will push the record on the top of the - ** stack into the sorter. - */ - static void pushOntoSorter( - Parse pParse, /* Parser context */ - ExprList pOrderBy, /* The ORDER BY clause */ - Select pSelect, /* The whole SELECT statement */ - int regData /* Register holding data to be sorted */ - ) - { - Vdbe v = pParse.pVdbe; - int nExpr = pOrderBy.nExpr; - int regBase = sqlite3GetTempRange( pParse, nExpr + 2 ); - int regRecord = sqlite3GetTempReg( pParse ); - sqlite3ExprCacheClear( pParse ); - sqlite3ExprCodeExprList( pParse, pOrderBy, regBase, false ); - sqlite3VdbeAddOp2( v, OP_Sequence, pOrderBy.iECursor, regBase + nExpr ); - sqlite3ExprCodeMove( pParse, regData, regBase + nExpr + 1, 1 ); - sqlite3VdbeAddOp3( v, OP_MakeRecord, regBase, nExpr + 2, regRecord ); - sqlite3VdbeAddOp2( v, OP_IdxInsert, pOrderBy.iECursor, regRecord ); - sqlite3ReleaseTempReg( pParse, regRecord ); - sqlite3ReleaseTempRange( pParse, regBase, nExpr + 2 ); - if ( pSelect.iLimit != 0 ) - { - int addr1, addr2; - int iLimit; - if ( pSelect.iOffset != 0 ) - { - iLimit = pSelect.iOffset + 1; + /* + ** Add code to implement the OFFSET + */ + static void codeOffset( + Vdbe v, /* Generate code into this VM */ + Select p, /* The SELECT statement being coded */ + int iContinue /* Jump here to skip the current record */ + ) { + if (p.iOffset != 0 && iContinue != 0) { + int addr; + sqlite3VdbeAddOp2(v, OP_AddImm, p.iOffset, -1); + addr = sqlite3VdbeAddOp1(v, OP_IfNeg, p.iOffset); + sqlite3VdbeAddOp2(v, OP_Goto, 0, iContinue); +#if SQLITE_DEBUG + VdbeComment(v, "skip OFFSET records"); +#endif + sqlite3VdbeJumpHere(v, addr); + } } - else - { - iLimit = pSelect.iLimit; + + /* + ** Add code that will check to make sure the N registers starting at iMem + ** form a distinct entry. iTab is a sorting index that holds previously + ** seen combinations of the N values. A new entry is made in iTab + ** if the current N values are new. + ** + ** A jump to addrRepeat is made and the N+1 values are popped from the + ** stack if the top N elements are not distinct. + */ + static void codeDistinct( + Parse pParse, /* Parsing and code generating context */ + int iTab, /* A sorting index used to test for distinctness */ + int addrRepeat, /* Jump to here if not distinct */ + int N, /* Number of elements */ + int iMem /* First element */ + ) { + Vdbe v; + int r1; + + v = pParse.pVdbe; + r1 = sqlite3GetTempReg(pParse); + sqlite3VdbeAddOp4Int(v, OP_Found, iTab, addrRepeat, iMem, N); + sqlite3VdbeAddOp3(v, OP_MakeRecord, iMem, N, r1); + sqlite3VdbeAddOp2(v, OP_IdxInsert, iTab, r1); + sqlite3ReleaseTempReg(pParse, r1); } - addr1 = sqlite3VdbeAddOp1( v, OP_IfZero, iLimit ); - sqlite3VdbeAddOp2( v, OP_AddImm, iLimit, -1 ); - addr2 = sqlite3VdbeAddOp0( v, OP_Goto ); - sqlite3VdbeJumpHere( v, addr1 ); - sqlite3VdbeAddOp1( v, OP_Last, pOrderBy.iECursor ); - sqlite3VdbeAddOp1( v, OP_Delete, pOrderBy.iECursor ); - sqlite3VdbeJumpHere( v, addr2 ); - } - } - /* - ** Add code to implement the OFFSET +#if !SQLITE_OMIT_SUBQUERY + /* + ** Generate an error message when a SELECT is used within a subexpression + ** (example: "a IN (SELECT * FROM table)") but it has more than 1 result + ** column. We do this in a subroutine because the error used to occur + ** in multiple places. (The error only occurs in one place now, but we + ** retain the subroutine to minimize code disruption.) */ - static void codeOffset( - Vdbe v, /* Generate code into this VM */ - Select p, /* The SELECT statement being coded */ - int iContinue /* Jump here to skip the current record */ - ) - { - if ( p.iOffset != 0 && iContinue != 0 ) - { - int addr; - sqlite3VdbeAddOp2( v, OP_AddImm, p.iOffset, -1 ); - addr = sqlite3VdbeAddOp1( v, OP_IfNeg, p.iOffset ); - sqlite3VdbeAddOp2( v, OP_Goto, 0, iContinue ); -#if SQLITE_DEBUG - VdbeComment( v, "skip OFFSET records" ); + static bool checkForMultiColumnSelectError( + Parse pParse, /* Parse context. */ + SelectDest pDest, /* Destination of SELECT results */ + int nExpr /* Number of result columns returned by SELECT */ + ) { + int eDest = pDest.eDest; + if (nExpr > 1 && (eDest == SRT_Mem || eDest == SRT_Set)) { + sqlite3ErrorMsg(pParse, "only a single result allowed for " + + "a SELECT that is part of an expression"); + return true; + } else { + return false; + } + } #endif - sqlite3VdbeJumpHere( v, addr ); - } - } - /* - ** Add code that will check to make sure the N registers starting at iMem - ** form a distinct entry. iTab is a sorting index that holds previously - ** seen combinations of the N values. A new entry is made in iTab - ** if the current N values are new. + /* + ** This routine generates the code for the inside of the inner loop + ** of a SELECT. ** - ** A jump to addrRepeat is made and the N+1 values are popped from the - ** stack if the top N elements are not distinct. + ** If srcTab and nColumn are both zero, then the pEList expressions + ** are evaluated in order to get the data for this row. If nColumn>0 + ** then data is pulled from srcTab and pEList is used only to get the + ** datatypes for each column. */ - static void codeDistinct( - Parse pParse, /* Parsing and code generating context */ - int iTab, /* A sorting index used to test for distinctness */ - int addrRepeat, /* Jump to here if not distinct */ - int N, /* Number of elements */ - int iMem /* First element */ - ) - { - Vdbe v; - int r1; - - v = pParse.pVdbe; - r1 = sqlite3GetTempReg( pParse ); - sqlite3VdbeAddOp4Int( v, OP_Found, iTab, addrRepeat, iMem, N ); - sqlite3VdbeAddOp3( v, OP_MakeRecord, iMem, N, r1 ); - sqlite3VdbeAddOp2( v, OP_IdxInsert, iTab, r1 ); - sqlite3ReleaseTempReg( pParse, r1 ); - } + static void selectInnerLoop( + Parse pParse, /* The parser context */ + Select p, /* The complete select statement being coded */ + ExprList pEList, /* List of values being extracted */ + int srcTab, /* Pull data from this table */ + int nColumn, /* Number of columns in the source table */ + ExprList pOrderBy, /* If not NULL, sort results using this key */ + int distinct, /* If >=0, make sure results are distinct */ + SelectDest pDest, /* How to dispose of the results */ + int iContinue, /* Jump here to continue with next row */ + int iBreak /* Jump here to break out of the inner loop */ + ) { + Vdbe v = pParse.pVdbe; + int i; + bool hasDistinct; /* True if the DISTINCT keyword is present */ + int regResult; /* Start of memory holding result set */ + int eDest = pDest.eDest; /* How to dispose of results */ + int iParm = pDest.iParm; /* First argument to disposal method */ + int nResultCol; /* Number of result columns */ + + Debug.Assert(v != null); + if (NEVER(v == null)) + return; + Debug.Assert(pEList != null); + hasDistinct = distinct >= 0; + if (pOrderBy == null && !hasDistinct) { + codeOffset(v, p, iContinue); + } -#if !SQLITE_OMIT_SUBQUERY - /* -** Generate an error message when a SELECT is used within a subexpression -** (example: "a IN (SELECT * FROM table)") but it has more than 1 result -** column. We do this in a subroutine because the error used to occur -** in multiple places. (The error only occurs in one place now, but we -** retain the subroutine to minimize code disruption.) -*/ - static bool checkForMultiColumnSelectError( - Parse pParse, /* Parse context. */ - SelectDest pDest, /* Destination of SELECT results */ - int nExpr /* Number of result columns returned by SELECT */ - ) - { - int eDest = pDest.eDest; - if ( nExpr > 1 && ( eDest == SRT_Mem || eDest == SRT_Set ) ) - { - sqlite3ErrorMsg( pParse, "only a single result allowed for " + - "a SELECT that is part of an expression" ); - return true; - } - else - { - return false; - } - } -#endif + /* Pull the requested columns. + */ + if (nColumn > 0) { + nResultCol = nColumn; + } else { + nResultCol = pEList.nExpr; + } + if (pDest.iMem == 0) { + pDest.iMem = pParse.nMem + 1; + pDest.nMem = nResultCol; + pParse.nMem += nResultCol; + } else { + Debug.Assert(pDest.nMem == nResultCol); + } + regResult = pDest.iMem; + if (nColumn > 0) { + for (i = 0; i < nColumn; i++) { + sqlite3VdbeAddOp3(v, OP_Column, srcTab, i, regResult + i); + } + } else if (eDest != SRT_Exists) { + /* If the destination is an EXISTS(...) expression, the actual + ** values returned by the SELECT are not required. + */ + sqlite3ExprCacheClear(pParse); + sqlite3ExprCodeExprList(pParse, pEList, regResult, eDest == SRT_Output); + } + nColumn = nResultCol; - /* -** This routine generates the code for the inside of the inner loop -** of a SELECT. -** -** If srcTab and nColumn are both zero, then the pEList expressions -** are evaluated in order to get the data for this row. If nColumn>0 -** then data is pulled from srcTab and pEList is used only to get the -** datatypes for each column. -*/ - static void selectInnerLoop( - Parse pParse, /* The parser context */ - Select p, /* The complete select statement being coded */ - ExprList pEList, /* List of values being extracted */ - int srcTab, /* Pull data from this table */ - int nColumn, /* Number of columns in the source table */ - ExprList pOrderBy, /* If not NULL, sort results using this key */ - int distinct, /* If >=0, make sure results are distinct */ - SelectDest pDest, /* How to dispose of the results */ - int iContinue, /* Jump here to continue with next row */ - int iBreak /* Jump here to break out of the inner loop */ - ) - { - Vdbe v = pParse.pVdbe; - int i; - bool hasDistinct; /* True if the DISTINCT keyword is present */ - int regResult; /* Start of memory holding result set */ - int eDest = pDest.eDest; /* How to dispose of results */ - int iParm = pDest.iParm; /* First argument to disposal method */ - int nResultCol; /* Number of result columns */ - - Debug.Assert( v != null ); - if ( NEVER( v == null ) ) - return; - Debug.Assert( pEList != null ); - hasDistinct = distinct >= 0; - if ( pOrderBy == null && !hasDistinct ) - { - codeOffset( v, p, iContinue ); - } - - /* Pull the requested columns. - */ - if ( nColumn > 0 ) - { - nResultCol = nColumn; - } - else - { - nResultCol = pEList.nExpr; - } - if ( pDest.iMem == 0 ) - { - pDest.iMem = pParse.nMem + 1; - pDest.nMem = nResultCol; - pParse.nMem += nResultCol; - } - else - { - Debug.Assert( pDest.nMem == nResultCol ); - } - regResult = pDest.iMem; - if ( nColumn > 0 ) - { - for ( i = 0; i < nColumn; i++ ) - { - sqlite3VdbeAddOp3( v, OP_Column, srcTab, i, regResult + i ); - } - } - else if ( eDest != SRT_Exists ) - { - /* If the destination is an EXISTS(...) expression, the actual - ** values returned by the SELECT are not required. - */ - sqlite3ExprCacheClear( pParse ); - sqlite3ExprCodeExprList( pParse, pEList, regResult, eDest == SRT_Output ); - } - nColumn = nResultCol; - - /* If the DISTINCT keyword was present on the SELECT statement - ** and this row has been seen before, then do not make this row - ** part of the result. - */ - if ( hasDistinct ) - { - Debug.Assert( pEList != null ); - Debug.Assert( pEList.nExpr == nColumn ); - codeDistinct( pParse, distinct, iContinue, nColumn, regResult ); - if ( pOrderBy == null ) - { - codeOffset( v, p, iContinue ); - } - } + /* If the DISTINCT keyword was present on the SELECT statement + ** and this row has been seen before, then do not make this row + ** part of the result. + */ + if (hasDistinct) { + Debug.Assert(pEList != null); + Debug.Assert(pEList.nExpr == nColumn); + codeDistinct(pParse, distinct, iContinue, nColumn, regResult); + if (pOrderBy == null) { + codeOffset(v, p, iContinue); + } + } - switch ( eDest ) - { - /* In this mode, write each query result to the key of the temporary - ** table iParm. - */ + switch (eDest) { + /* In this mode, write each query result to the key of the temporary + ** table iParm. + */ #if !SQLITE_OMIT_COMPOUND_SELECT - case SRT_Union: - { - int r1; - r1 = sqlite3GetTempReg( pParse ); - sqlite3VdbeAddOp3( v, OP_MakeRecord, regResult, nColumn, r1 ); - sqlite3VdbeAddOp2( v, OP_IdxInsert, iParm, r1 ); - sqlite3ReleaseTempReg( pParse, r1 ); - break; - } - - /* Construct a record from the query result, but instead of - ** saving that record, use it as a key to delete elements from - ** the temporary table iParm. - */ - case SRT_Except: - { - sqlite3VdbeAddOp3( v, OP_IdxDelete, iParm, regResult, nColumn ); - break; - } + case SRT_Union: { + int r1; + r1 = sqlite3GetTempReg(pParse); + sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nColumn, r1); + sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm, r1); + sqlite3ReleaseTempReg(pParse, r1); + break; + } + + /* Construct a record from the query result, but instead of + ** saving that record, use it as a key to delete elements from + ** the temporary table iParm. + */ + case SRT_Except: { + sqlite3VdbeAddOp3(v, OP_IdxDelete, iParm, regResult, nColumn); + break; + } #endif - /* Store the result as data using a unique key. -*/ - case SRT_Table: - case SRT_EphemTab: - { - int r1 = sqlite3GetTempReg( pParse ); - testcase( eDest == SRT_Table ); - testcase( eDest == SRT_EphemTab ); - sqlite3VdbeAddOp3( v, OP_MakeRecord, regResult, nColumn, r1 ); - if ( pOrderBy != null ) - { - pushOntoSorter( pParse, pOrderBy, p, r1 ); - } - else - { - int r2 = sqlite3GetTempReg( pParse ); - sqlite3VdbeAddOp2( v, OP_NewRowid, iParm, r2 ); - sqlite3VdbeAddOp3( v, OP_Insert, iParm, r1, r2 ); - sqlite3VdbeChangeP5( v, OPFLAG_APPEND ); - sqlite3ReleaseTempReg( pParse, r2 ); - } - sqlite3ReleaseTempReg( pParse, r1 ); - break; - } + /* Store the result as data using a unique key. + */ + case SRT_Table: + case SRT_EphemTab: { + int r1 = sqlite3GetTempReg(pParse); + testcase(eDest == SRT_Table); + testcase(eDest == SRT_EphemTab); + sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nColumn, r1); + if (pOrderBy != null) { + pushOntoSorter(pParse, pOrderBy, p, r1); + } else { + int r2 = sqlite3GetTempReg(pParse); + sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, r2); + sqlite3VdbeAddOp3(v, OP_Insert, iParm, r1, r2); + sqlite3VdbeChangeP5(v, OPFLAG_APPEND); + sqlite3ReleaseTempReg(pParse, r2); + } + sqlite3ReleaseTempReg(pParse, r1); + break; + } #if !SQLITE_OMIT_SUBQUERY - /* If we are creating a set for an "expr IN (SELECT ...)" construct, -** then there should be a single item on the stack. Write this -** item into the set table with bogus data. -*/ - case SRT_Set: - { - Debug.Assert( nColumn == 1 ); - p.affinity = sqlite3CompareAffinity( pEList.a[0].pExpr, pDest.affinity ); - if ( pOrderBy != null ) - { - /* At first glance you would think we could optimize out the - ** ORDER BY in this case since the order of entries in the set - ** does not matter. But there might be a LIMIT clause, in which - ** case the order does matter */ - pushOntoSorter( pParse, pOrderBy, p, regResult ); - } - else - { - int r1 = sqlite3GetTempReg( pParse ); - sqlite3VdbeAddOp4( v, OP_MakeRecord, regResult, 1, r1, p.affinity, 1 ); - sqlite3ExprCacheAffinityChange( pParse, regResult, 1 ); - sqlite3VdbeAddOp2( v, OP_IdxInsert, iParm, r1 ); - sqlite3ReleaseTempReg( pParse, r1 ); - } - break; - } - - /* If any row exist in the result set, record that fact and abort. - */ - case SRT_Exists: - { - sqlite3VdbeAddOp2( v, OP_Integer, 1, iParm ); - /* The LIMIT clause will terminate the loop for us */ - break; - } - - /* If this is a scalar select that is part of an expression, then - ** store the results in the appropriate memory cell and break out - ** of the scan loop. + /* If we are creating a set for an "expr IN (SELECT ...)" construct, + ** then there should be a single item on the stack. Write this + ** item into the set table with bogus data. */ - case SRT_Mem: - { - Debug.Assert( nColumn == 1 ); - if ( pOrderBy != null ) - { - pushOntoSorter( pParse, pOrderBy, p, regResult ); - } - else - { - sqlite3ExprCodeMove( pParse, regResult, iParm, 1 ); - /* The LIMIT clause will jump out of the loop for us */ - } - break; - } + case SRT_Set: { + Debug.Assert(nColumn == 1); + p.affinity = sqlite3CompareAffinity(pEList.a[0].pExpr, pDest.affinity); + if (pOrderBy != null) { + /* At first glance you would think we could optimize out the + ** ORDER BY in this case since the order of entries in the set + ** does not matter. But there might be a LIMIT clause, in which + ** case the order does matter */ + pushOntoSorter(pParse, pOrderBy, p, regResult); + } else { + int r1 = sqlite3GetTempReg(pParse); + sqlite3VdbeAddOp4(v, OP_MakeRecord, regResult, 1, r1, p.affinity, 1); + sqlite3ExprCacheAffinityChange(pParse, regResult, 1); + sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm, r1); + sqlite3ReleaseTempReg(pParse, r1); + } + break; + } + + /* If any row exist in the result set, record that fact and abort. + */ + case SRT_Exists: { + sqlite3VdbeAddOp2(v, OP_Integer, 1, iParm); + /* The LIMIT clause will terminate the loop for us */ + break; + } + + /* If this is a scalar select that is part of an expression, then + ** store the results in the appropriate memory cell and break out + ** of the scan loop. + */ + case SRT_Mem: { + Debug.Assert(nColumn == 1); + if (pOrderBy != null) { + pushOntoSorter(pParse, pOrderBy, p, regResult); + } else { + sqlite3ExprCodeMove(pParse, regResult, iParm, 1); + /* The LIMIT clause will jump out of the loop for us */ + } + break; + } #endif // * #if !SQLITE_OMIT_SUBQUERY */ - /* Send the data to the callback function or to a subroutine. In the -** case of a subroutine, the subroutine itself is responsible for -** popping the data from the stack. -*/ - case SRT_Coroutine: - case SRT_Output: - { - testcase( eDest == SRT_Coroutine ); - testcase( eDest == SRT_Output ); - if ( pOrderBy != null ) - { - int r1 = sqlite3GetTempReg( pParse ); - sqlite3VdbeAddOp3( v, OP_MakeRecord, regResult, nColumn, r1 ); - pushOntoSorter( pParse, pOrderBy, p, r1 ); - sqlite3ReleaseTempReg( pParse, r1 ); - } - else if ( eDest == SRT_Coroutine ) - { - sqlite3VdbeAddOp1( v, OP_Yield, pDest.iParm ); - } - else - { - sqlite3VdbeAddOp2( v, OP_ResultRow, regResult, nColumn ); - sqlite3ExprCacheAffinityChange( pParse, regResult, nColumn ); - } - break; - } + /* Send the data to the callback function or to a subroutine. In the + ** case of a subroutine, the subroutine itself is responsible for + ** popping the data from the stack. + */ + case SRT_Coroutine: + case SRT_Output: { + testcase(eDest == SRT_Coroutine); + testcase(eDest == SRT_Output); + if (pOrderBy != null) { + int r1 = sqlite3GetTempReg(pParse); + sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nColumn, r1); + pushOntoSorter(pParse, pOrderBy, p, r1); + sqlite3ReleaseTempReg(pParse, r1); + } else if (eDest == SRT_Coroutine) { + sqlite3VdbeAddOp1(v, OP_Yield, pDest.iParm); + } else { + sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, nColumn); + sqlite3ExprCacheAffinityChange(pParse, regResult, nColumn); + } + break; + } #if !SQLITE_OMIT_TRIGGER - /* Discard the results. This is used for SELECT statements inside -** the body of a TRIGGER. The purpose of such selects is to call -** user-defined functions that have side effects. We do not care -** about the actual results of the select. -*/ - default: - { - Debug.Assert( eDest == SRT_Discard ); - break; - } + /* Discard the results. This is used for SELECT statements inside + ** the body of a TRIGGER. The purpose of such selects is to call + ** user-defined functions that have side effects. We do not care + ** about the actual results of the select. + */ + default: { + Debug.Assert(eDest == SRT_Discard); + break; + } #endif - } + } - /* Jump to the end of the loop if the LIMIT is reached. Except, if - ** there is a sorter, in which case the sorter has already limited - ** the output for us. - */ - if ( pOrderBy == null && p.iLimit != 0 ) - { - sqlite3VdbeAddOp3( v, OP_IfZero, p.iLimit, iBreak, -1 ); - } - } + /* Jump to the end of the loop if the LIMIT is reached. Except, if + ** there is a sorter, in which case the sorter has already limited + ** the output for us. + */ + if (pOrderBy == null && p.iLimit != 0) { + sqlite3VdbeAddOp3(v, OP_IfZero, p.iLimit, iBreak, -1); + } + } - /* - ** Given an expression list, generate a KeyInfo structure that records - ** the collating sequence for each expression in that expression list. - ** - ** If the ExprList is an ORDER BY or GROUP BY clause then the resulting - ** KeyInfo structure is appropriate for initializing a virtual index to - ** implement that clause. If the ExprList is the result set of a SELECT - ** then the KeyInfo structure is appropriate for initializing a virtual - ** index to implement a DISTINCT test. - ** - ** Space to hold the KeyInfo structure is obtain from malloc. The calling - ** function is responsible for seeing that this structure is eventually - ** freed. Add the KeyInfo structure to the P4 field of an opcode using - ** P4_KEYINFO_HANDOFF is the usual way of dealing with this. - */ - static KeyInfo keyInfoFromExprList( Parse pParse, ExprList pList ) - { - sqlite3 db = pParse.db; - int nExpr; - KeyInfo pInfo; - ExprList_item pItem; - int i; - - nExpr = pList.nExpr; - pInfo = new KeyInfo();//sqlite3DbMallocZero(db, sizeof(*pInfo) + nExpr*(CollSeq*.Length+1) ); - if ( pInfo != null ) - { - pInfo.aSortOrder = new byte[nExpr];// pInfo.aColl[nExpr]; - pInfo.aColl = new CollSeq[nExpr]; - pInfo.nField = (u16)nExpr; - pInfo.enc = db.aDbStatic[0].pSchema.enc;// ENC(db); - pInfo.db = db; - for ( i = 0; i < nExpr; i++ ) - {//, pItem++){ - pItem = pList.a[i]; - CollSeq pColl; - pColl = sqlite3ExprCollSeq( pParse, pItem.pExpr ); - if ( pColl == null ) - { - pColl = db.pDfltColl; - } - pInfo.aColl[i] = pColl; - pInfo.aSortOrder[i] = (byte)pItem.sortOrder; + /* + ** Given an expression list, generate a KeyInfo structure that records + ** the collating sequence for each expression in that expression list. + ** + ** If the ExprList is an ORDER BY or GROUP BY clause then the resulting + ** KeyInfo structure is appropriate for initializing a virtual index to + ** implement that clause. If the ExprList is the result set of a SELECT + ** then the KeyInfo structure is appropriate for initializing a virtual + ** index to implement a DISTINCT test. + ** + ** Space to hold the KeyInfo structure is obtain from malloc. The calling + ** function is responsible for seeing that this structure is eventually + ** freed. Add the KeyInfo structure to the P4 field of an opcode using + ** P4_KEYINFO_HANDOFF is the usual way of dealing with this. + */ + static KeyInfo keyInfoFromExprList(Parse pParse, ExprList pList) { + sqlite3 db = pParse.db; + int nExpr; + KeyInfo pInfo; + ExprList_item pItem; + int i; + + nExpr = pList.nExpr; + pInfo = new KeyInfo();//sqlite3DbMallocZero(db, sizeof(*pInfo) + nExpr*(CollSeq*.Length+1) ); + if (pInfo != null) { + pInfo.aSortOrder = new byte[nExpr];// pInfo.aColl[nExpr]; + pInfo.aColl = new CollSeq[nExpr]; + pInfo.nField = (u16)nExpr; + pInfo.enc = db.aDbStatic[0].pSchema.enc;// ENC(db); + pInfo.db = db; + for (i = 0; i < nExpr; i++) {//, pItem++){ + pItem = pList.a[i]; + CollSeq pColl; + pColl = sqlite3ExprCollSeq(pParse, pItem.pExpr); + if (pColl == null) { + pColl = db.pDfltColl; + } + pInfo.aColl[i] = pColl; + pInfo.aSortOrder[i] = (byte)pItem.sortOrder; + } + } + return pInfo; } - } - return pInfo; - } #if !SQLITE_OMIT_COMPOUND_SELECT - /* -** Name of the connection operator, used for error messages. -*/ - static string selectOpName( int id ) - { - string z; - switch ( id ) - { - case TK_ALL: - z = "UNION ALL"; - break; - case TK_INTERSECT: - z = "INTERSECT"; - break; - case TK_EXCEPT: - z = "EXCEPT"; - break; - default: - z = "UNION"; - break; - } - return z; - } + /* + ** Name of the connection operator, used for error messages. + */ + static string selectOpName(int id) { + string z; + switch (id) { + case TK_ALL: + z = "UNION ALL"; + break; + case TK_INTERSECT: + z = "INTERSECT"; + break; + case TK_EXCEPT: + z = "EXCEPT"; + break; + default: + z = "UNION"; + break; + } + return z; + } #endif //* SQLITE_OMIT_COMPOUND_SELECT */ #if !SQLITE_OMIT_EXPLAIN - /* -** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function -** is a no-op. Otherwise, it adds a single row of output to the EQP result, -** where the caption is of the form: -** -** "USE TEMP B-TREE FOR xxx" -** -** where xxx is one of "DISTINCT", "ORDER BY" or "GROUP BY". Exactly which -** is determined by the zUsage argument. -*/ - static void explainTempTable( Parse pParse, string zUsage ) - { - if ( pParse.explain == 2 ) - { - Vdbe v = pParse.pVdbe; - string zMsg = sqlite3MPrintf( pParse.db, "USE TEMP B-TREE FOR %s", zUsage ); - sqlite3VdbeAddOp4( v, OP_Explain, pParse.iSelectId, 0, 0, zMsg, P4_DYNAMIC ); - } - } + /* + ** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function + ** is a no-op. Otherwise, it adds a single row of output to the EQP result, + ** where the caption is of the form: + ** + ** "USE TEMP B-TREE FOR xxx" + ** + ** where xxx is one of "DISTINCT", "ORDER BY" or "GROUP BY". Exactly which + ** is determined by the zUsage argument. + */ + static void explainTempTable(Parse pParse, string zUsage) { + if (pParse.explain == 2) { + Vdbe v = pParse.pVdbe; + string zMsg = sqlite3MPrintf(pParse.db, "USE TEMP B-TREE FOR %s", zUsage); + sqlite3VdbeAddOp4(v, OP_Explain, pParse.iSelectId, 0, 0, zMsg, P4_DYNAMIC); + } + } -/* -** Assign expression b to lvalue a. A second, no-op, version of this macro -** is provided when SQLITE_OMIT_EXPLAIN is defined. This allows the code -** in sqlite3Select() to assign values to structure member variables that -** only exist if SQLITE_OMIT_EXPLAIN is not defined without polluting the -** code with #if !directives. -*/ -//# define explainSetInteger(a, b) a = b - static void explainSetInteger( ref int a, int b ) - { - a = b; - } - static void explainSetInteger( ref byte a, int b ) -{ - a = (byte)b; -} + /* + ** Assign expression b to lvalue a. A second, no-op, version of this macro + ** is provided when SQLITE_OMIT_EXPLAIN is defined. This allows the code + ** in sqlite3Select() to assign values to structure member variables that + ** only exist if SQLITE_OMIT_EXPLAIN is not defined without polluting the + ** code with #if !directives. + */ + //# define explainSetInteger(a, b) a = b + static void explainSetInteger(ref int a, int b) { + a = b; + } + static void explainSetInteger(ref byte a, int b) { + a = (byte)b; + } #else /* No-op versions of the explainXXX() functions and macros. */ //# define explainTempTable(y,z) @@ -1000,39 +894,37 @@ static void explainSetInteger( ref byte a, int b ) #endif #if !(SQLITE_OMIT_EXPLAIN) && !(SQLITE_OMIT_COMPOUND_SELECT) -/* - ** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function - ** is a no-op. Otherwise, it adds a single row of output to the EQP result, - ** where the caption is of one of the two forms: - ** - ** "COMPOSITE SUBQUERIES iSub1 and iSub2 (op)" - ** "COMPOSITE SUBQUERIES iSub1 and iSub2 USING TEMP B-TREE (op)" - ** - ** where iSub1 and iSub2 are the integers passed as the corresponding - ** function parameters, and op is the text representation of the parameter - ** of the same name. The parameter "op" must be one of TK_UNION, TK_EXCEPT, - ** TK_INTERSECT or TK_ALL. The first form is used if argument bUseTmp is - ** false, or the second form if it is true. - */ - static void explainComposite( - Parse pParse, /* Parse context */ - int op, /* One of TK_UNION, TK_EXCEPT etc. */ - int iSub1, /* Subquery id 1 */ - int iSub2, /* Subquery id 2 */ - bool bUseTmp /* True if a temp table was used */ - ) - { - Debug.Assert( op == TK_UNION || op == TK_EXCEPT || op == TK_INTERSECT || op == TK_ALL ); - if ( pParse.explain == 2 ) - { - Vdbe v = pParse.pVdbe; - string zMsg = sqlite3MPrintf( - pParse.db, "COMPOUND SUBQUERIES %d AND %d %s(%s)", iSub1, iSub2, - bUseTmp ? "USING TEMP B-TREE " : "", selectOpName( op ) - ); - sqlite3VdbeAddOp4( v, OP_Explain, pParse.iSelectId, 0, 0, zMsg, P4_DYNAMIC ); - } - } + /* + ** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function + ** is a no-op. Otherwise, it adds a single row of output to the EQP result, + ** where the caption is of one of the two forms: + ** + ** "COMPOSITE SUBQUERIES iSub1 and iSub2 (op)" + ** "COMPOSITE SUBQUERIES iSub1 and iSub2 USING TEMP B-TREE (op)" + ** + ** where iSub1 and iSub2 are the integers passed as the corresponding + ** function parameters, and op is the text representation of the parameter + ** of the same name. The parameter "op" must be one of TK_UNION, TK_EXCEPT, + ** TK_INTERSECT or TK_ALL. The first form is used if argument bUseTmp is + ** false, or the second form if it is true. + */ + static void explainComposite( + Parse pParse, /* Parse context */ + int op, /* One of TK_UNION, TK_EXCEPT etc. */ + int iSub1, /* Subquery id 1 */ + int iSub2, /* Subquery id 2 */ + bool bUseTmp /* True if a temp table was used */ + ) { + Debug.Assert(op == TK_UNION || op == TK_EXCEPT || op == TK_INTERSECT || op == TK_ALL); + if (pParse.explain == 2) { + Vdbe v = pParse.pVdbe; + string zMsg = sqlite3MPrintf( + pParse.db, "COMPOUND SUBQUERIES %d AND %d %s(%s)", iSub1, iSub2, + bUseTmp ? "USING TEMP B-TREE " : "", selectOpName(op) + ); + sqlite3VdbeAddOp4(v, OP_Explain, pParse.iSelectId, 0, 0, zMsg, P4_DYNAMIC); + } + } #else /* No-op versions of the explainXXX() functions and macros. */ @@ -1041,1282 +933,1163 @@ static void explainComposite(Parse v, int w,int x,int y,bool z) {} #endif - /* -** If the inner loop was generated using a non-null pOrderBy argument, -** then the results were placed in a sorter. After the loop is terminated -** we need to run the sorter and output the results. The following -** routine generates the code needed to do that. -*/ - static void generateSortTail( - Parse pParse, /* Parsing context */ - Select p, /* The SELECT statement */ - Vdbe v, /* Generate code into this VDBE */ - int nColumn, /* Number of columns of data */ - SelectDest pDest /* Write the sorted results here */ - ) - { - int addrBreak = sqlite3VdbeMakeLabel( v ); /* Jump here to exit loop */ - int addrContinue = sqlite3VdbeMakeLabel( v ); /* Jump here for next cycle */ - int addr; - int iTab; - int pseudoTab = 0; - ExprList pOrderBy = p.pOrderBy; - - int eDest = pDest.eDest; - int iParm = pDest.iParm; - - int regRow; - int regRowid; - - iTab = pOrderBy.iECursor; - regRow = sqlite3GetTempReg( pParse ); - if ( eDest == SRT_Output || eDest == SRT_Coroutine ) - { - pseudoTab = pParse.nTab++; - sqlite3VdbeAddOp3( v, OP_OpenPseudo, pseudoTab, regRow, nColumn ); - regRowid = 0; - } - else - { - regRowid = sqlite3GetTempReg( pParse ); - } - addr = 1 + sqlite3VdbeAddOp2( v, OP_Sort, iTab, addrBreak ); - codeOffset( v, p, addrContinue ); - sqlite3VdbeAddOp3( v, OP_Column, iTab, pOrderBy.nExpr + 1, regRow ); - switch ( eDest ) - { - case SRT_Table: - case SRT_EphemTab: - { - testcase( eDest == SRT_Table ); - testcase( eDest == SRT_EphemTab ); - sqlite3VdbeAddOp2( v, OP_NewRowid, iParm, regRowid ); - sqlite3VdbeAddOp3( v, OP_Insert, iParm, regRow, regRowid ); - sqlite3VdbeChangeP5( v, OPFLAG_APPEND ); - break; - } + /* + ** If the inner loop was generated using a non-null pOrderBy argument, + ** then the results were placed in a sorter. After the loop is terminated + ** we need to run the sorter and output the results. The following + ** routine generates the code needed to do that. + */ + static void generateSortTail( + Parse pParse, /* Parsing context */ + Select p, /* The SELECT statement */ + Vdbe v, /* Generate code into this VDBE */ + int nColumn, /* Number of columns of data */ + SelectDest pDest /* Write the sorted results here */ + ) { + int addrBreak = sqlite3VdbeMakeLabel(v); /* Jump here to exit loop */ + int addrContinue = sqlite3VdbeMakeLabel(v); /* Jump here for next cycle */ + int addr; + int iTab; + int pseudoTab = 0; + ExprList pOrderBy = p.pOrderBy; + + int eDest = pDest.eDest; + int iParm = pDest.iParm; + + int regRow; + int regRowid; + + iTab = pOrderBy.iECursor; + regRow = sqlite3GetTempReg(pParse); + if (eDest == SRT_Output || eDest == SRT_Coroutine) { + pseudoTab = pParse.nTab++; + sqlite3VdbeAddOp3(v, OP_OpenPseudo, pseudoTab, regRow, nColumn); + regRowid = 0; + } else { + regRowid = sqlite3GetTempReg(pParse); + } + addr = 1 + sqlite3VdbeAddOp2(v, OP_Sort, iTab, addrBreak); + codeOffset(v, p, addrContinue); + sqlite3VdbeAddOp3(v, OP_Column, iTab, pOrderBy.nExpr + 1, regRow); + switch (eDest) { + case SRT_Table: + case SRT_EphemTab: { + testcase(eDest == SRT_Table); + testcase(eDest == SRT_EphemTab); + sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, regRowid); + sqlite3VdbeAddOp3(v, OP_Insert, iParm, regRow, regRowid); + sqlite3VdbeChangeP5(v, OPFLAG_APPEND); + break; + } #if !SQLITE_OMIT_SUBQUERY - case SRT_Set: - { - Debug.Assert( nColumn == 1 ); - sqlite3VdbeAddOp4( v, OP_MakeRecord, regRow, 1, regRowid, p.affinity, 1 ); - sqlite3ExprCacheAffinityChange( pParse, regRow, 1 ); - sqlite3VdbeAddOp2( v, OP_IdxInsert, iParm, regRowid ); - break; - } - case SRT_Mem: - { - Debug.Assert( nColumn == 1 ); - sqlite3ExprCodeMove( pParse, regRow, iParm, 1 ); - /* The LIMIT clause will terminate the loop for us */ - break; - } + case SRT_Set: { + Debug.Assert(nColumn == 1); + sqlite3VdbeAddOp4(v, OP_MakeRecord, regRow, 1, regRowid, p.affinity, 1); + sqlite3ExprCacheAffinityChange(pParse, regRow, 1); + sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm, regRowid); + break; + } + case SRT_Mem: { + Debug.Assert(nColumn == 1); + sqlite3ExprCodeMove(pParse, regRow, iParm, 1); + /* The LIMIT clause will terminate the loop for us */ + break; + } #endif - default: - { - int i; - Debug.Assert( eDest == SRT_Output || eDest == SRT_Coroutine ); - testcase( eDest == SRT_Output ); - testcase( eDest == SRT_Coroutine ); - for ( i = 0; i < nColumn; i++ ) - { - Debug.Assert( regRow != pDest.iMem + i ); - sqlite3VdbeAddOp3( v, OP_Column, pseudoTab, i, pDest.iMem + i ); - if ( i == 0 ) - { - sqlite3VdbeChangeP5( v, OPFLAG_CLEARCACHE ); - } - } - if ( eDest == SRT_Output ) - { - sqlite3VdbeAddOp2( v, OP_ResultRow, pDest.iMem, nColumn ); - sqlite3ExprCacheAffinityChange( pParse, pDest.iMem, nColumn ); - } - else - { - sqlite3VdbeAddOp1( v, OP_Yield, pDest.iParm ); + default: { + int i; + Debug.Assert(eDest == SRT_Output || eDest == SRT_Coroutine); + testcase(eDest == SRT_Output); + testcase(eDest == SRT_Coroutine); + for (i = 0; i < nColumn; i++) { + Debug.Assert(regRow != pDest.iMem + i); + sqlite3VdbeAddOp3(v, OP_Column, pseudoTab, i, pDest.iMem + i); + if (i == 0) { + sqlite3VdbeChangeP5(v, OPFLAG_CLEARCACHE); + } + } + if (eDest == SRT_Output) { + sqlite3VdbeAddOp2(v, OP_ResultRow, pDest.iMem, nColumn); + sqlite3ExprCacheAffinityChange(pParse, pDest.iMem, nColumn); + } else { + sqlite3VdbeAddOp1(v, OP_Yield, pDest.iParm); + } + break; + } } - break; - } - } - sqlite3ReleaseTempReg( pParse, regRow ); - sqlite3ReleaseTempReg( pParse, regRowid ); - - /* The bottom of the loop - */ - sqlite3VdbeResolveLabel( v, addrContinue ); - sqlite3VdbeAddOp2( v, OP_Next, iTab, addr ); - sqlite3VdbeResolveLabel( v, addrBreak ); - if ( eDest == SRT_Output || eDest == SRT_Coroutine ) - { - sqlite3VdbeAddOp2( v, OP_Close, pseudoTab, 0 ); - } - - } + sqlite3ReleaseTempReg(pParse, regRow); + sqlite3ReleaseTempReg(pParse, regRowid); - /* - ** Return a pointer to a string containing the 'declaration type' of the - ** expression pExpr. The string may be treated as static by the caller. - ** - ** 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 - ** considered a column by this function. - ** - ** SELECT col FROM tbl; - ** 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. - */ - static string columnType( - NameContext pNC, - Expr pExpr, - ref string pzOriginDb, - ref string pzOriginTab, - ref string pzOriginCol - ) - { - string zType = null; - string zOriginDb = null; - string zOriginTab = null; - string zOriginCol = null; - int j; - if ( NEVER( pExpr == null ) || pNC.pSrcList == null ) - return null; - - 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 - ** database table or a subquery. + /* The bottom of the loop */ - Table pTab = null; /* Table structure column is extracted from */ - Select pS = null; /* Select the column is extracted from */ - int iCol = pExpr.iColumn; /* Index of column in pTab */ - testcase( pExpr.op == TK_AGG_COLUMN ); - testcase( pExpr.op == TK_COLUMN ); - while ( pNC != null && pTab == null ) - { - SrcList pTabList = pNC.pSrcList; - for ( j = 0; j < pTabList.nSrc && pTabList.a[j].iCursor != pExpr.iTable; j++ ) - ; - if ( j < pTabList.nSrc ) - { - pTab = pTabList.a[j].pTab; - pS = pTabList.a[j].pSelect; - } - else - { - pNC = pNC.pNext; - } + sqlite3VdbeResolveLabel(v, addrContinue); + sqlite3VdbeAddOp2(v, OP_Next, iTab, addr); + sqlite3VdbeResolveLabel(v, addrBreak); + if (eDest == SRT_Output || eDest == SRT_Coroutine) { + sqlite3VdbeAddOp2(v, OP_Close, pseudoTab, 0); } - if ( pTab == null ) - { - /* At one time, code such as "SELECT new.x" within a trigger would - ** cause this condition to run. Since then, we have restructured how - ** trigger code is generated and so this condition is no longer - ** possible. However, it can still be true for statements like - ** the following: - ** - ** CREATE TABLE t1(col INTEGER); - ** SELECT (SELECT t1.col) FROM FROM t1; - ** - ** when columnType() is called on the expression "t1.col" in the - ** sub-select. In this case, set the column type to NULL, even - ** though it should really be "INTEGER". - ** - ** This is not a problem, as the column type of "t1.col" is never - ** used. When columnType() is called on the expression - ** "(SELECT t1.col)", the correct type is returned (see the TK_SELECT - ** branch below. */ - break; - } + } - //Debug.Assert( pTab != null && pExpr.pTab == pTab ); - if ( pS != null ) - { - /* The "table" is actually a sub-select or a view in the FROM clause - ** of the SELECT statement. Return the declaration type and origin - ** data for the result-set column of the sub-select. - */ - if ( iCol >= 0 && ALWAYS( iCol < pS.pEList.nExpr ) ) - { - /* If iCol is less than zero, then the expression requests the - ** rowid of the sub-select or view. This expression is legal (see - ** test case misc2.2.2) - it always evaluates to NULL. - */ - NameContext sNC = new NameContext(); - Expr p = pS.pEList.a[iCol].pExpr; - sNC.pSrcList = pS.pSrc; - sNC.pNext = pNC; - sNC.pParse = pNC.pParse; - zType = columnType( sNC, p, ref zOriginDb, ref zOriginTab, ref zOriginCol ); - } + /* + ** Return a pointer to a string containing the 'declaration type' of the + ** expression pExpr. The string may be treated as static by the caller. + ** + ** 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 + ** considered a column by this function. + ** + ** SELECT col FROM tbl; + ** 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. + */ + static string columnType( + NameContext pNC, + Expr pExpr, + ref string pzOriginDb, + ref string pzOriginTab, + ref string pzOriginCol + ) { + string zType = null; + string zOriginDb = null; + string zOriginTab = null; + string zOriginCol = null; + int j; + if (NEVER(pExpr == null) || pNC.pSrcList == null) + return null; + + 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 + ** database table or a subquery. + */ + Table pTab = null; /* Table structure column is extracted from */ + Select pS = null; /* Select the column is extracted from */ + int iCol = pExpr.iColumn; /* Index of column in pTab */ + testcase(pExpr.op == TK_AGG_COLUMN); + testcase(pExpr.op == TK_COLUMN); + while (pNC != null && pTab == null) { + SrcList pTabList = pNC.pSrcList; + for (j = 0; j < pTabList.nSrc && pTabList.a[j].iCursor != pExpr.iTable; j++) + ; + if (j < pTabList.nSrc) { + pTab = pTabList.a[j].pTab; + pS = pTabList.a[j].pSelect; + } else { + pNC = pNC.pNext; + } + } + + if (pTab == null) { + /* At one time, code such as "SELECT new.x" within a trigger would + ** cause this condition to run. Since then, we have restructured how + ** trigger code is generated and so this condition is no longer + ** possible. However, it can still be true for statements like + ** the following: + ** + ** CREATE TABLE t1(col INTEGER); + ** SELECT (SELECT t1.col) FROM FROM t1; + ** + ** when columnType() is called on the expression "t1.col" in the + ** sub-select. In this case, set the column type to NULL, even + ** though it should really be "INTEGER". + ** + ** This is not a problem, as the column type of "t1.col" is never + ** used. When columnType() is called on the expression + ** "(SELECT t1.col)", the correct type is returned (see the TK_SELECT + ** branch below. */ + break; + } + + //Debug.Assert( pTab != null && pExpr.pTab == pTab ); + if (pS != null) { + /* The "table" is actually a sub-select or a view in the FROM clause + ** of the SELECT statement. Return the declaration type and origin + ** data for the result-set column of the sub-select. + */ + if (iCol >= 0 && ALWAYS(iCol < pS.pEList.nExpr)) { + /* If iCol is less than zero, then the expression requests the + ** rowid of the sub-select or view. This expression is legal (see + ** test case misc2.2.2) - it always evaluates to NULL. + */ + NameContext sNC = new NameContext(); + Expr p = pS.pEList.a[iCol].pExpr; + sNC.pSrcList = pS.pSrc; + sNC.pNext = pNC; + sNC.pParse = pNC.pParse; + zType = columnType(sNC, p, ref zOriginDb, ref zOriginTab, ref zOriginCol); + } + } else if (ALWAYS(pTab.pSchema)) { + /* A real table */ + Debug.Assert(pS == null); + if (iCol < 0) + iCol = pTab.iPKey; + Debug.Assert(iCol == -1 || (iCol >= 0 && iCol < pTab.nCol)); + if (iCol < 0) { + zType = "INTEGER"; + zOriginCol = "rowid"; + } else { + zType = pTab.aCol[iCol].zType; + zOriginCol = pTab.aCol[iCol].zName; + } + zOriginTab = pTab.zName; + if (pNC.pParse != null) { + int iDb = sqlite3SchemaToIndex(pNC.pParse.db, pTab.pSchema); + zOriginDb = pNC.pParse.db.aDb[iDb].zName; + } + } + break; + } +#if !SQLITE_OMIT_SUBQUERY + case TK_SELECT: { + /* The expression is a sub-select. Return the declaration type and + ** origin info for the single column in the result set of the SELECT + ** statement. + */ + NameContext sNC = new NameContext(); + Select pS = pExpr.x.pSelect; + Expr p = pS.pEList.a[0].pExpr; + Debug.Assert(ExprHasProperty(pExpr, EP_xIsSelect)); + sNC.pSrcList = pS.pSrc; + sNC.pNext = pNC; + sNC.pParse = pNC.pParse; + zType = columnType(sNC, p, ref zOriginDb, ref zOriginTab, ref zOriginCol); + break; + } +#endif } - else if ( ALWAYS( pTab.pSchema ) ) + + //if ( pzOriginDb != null ) { - /* A real table */ - Debug.Assert( pS == null ); - if ( iCol < 0 ) - iCol = pTab.iPKey; - Debug.Assert( iCol == -1 || ( iCol >= 0 && iCol < pTab.nCol ) ); - if ( iCol < 0 ) - { - zType = "INTEGER"; - zOriginCol = "rowid"; - } - else - { - zType = pTab.aCol[iCol].zType; - zOriginCol = pTab.aCol[iCol].zName; - } - zOriginTab = pTab.zName; - if ( pNC.pParse != null ) - { - int iDb = sqlite3SchemaToIndex( pNC.pParse.db, pTab.pSchema ); - zOriginDb = pNC.pParse.db.aDb[iDb].zName; - } + //Debug.Assert( pzOriginTab != null && pzOriginCol != null ); + pzOriginDb = zOriginDb; + pzOriginTab = zOriginTab; + pzOriginCol = zOriginCol; } - break; - } -#if !SQLITE_OMIT_SUBQUERY - case TK_SELECT: - { - /* The expression is a sub-select. Return the declaration type and - ** origin info for the single column in the result set of the SELECT - ** statement. - */ - NameContext sNC = new NameContext(); - Select pS = pExpr.x.pSelect; - Expr p = pS.pEList.a[0].pExpr; - Debug.Assert( ExprHasProperty( pExpr, EP_xIsSelect ) ); - sNC.pSrcList = pS.pSrc; - sNC.pNext = pNC; - sNC.pParse = pNC.pParse; - zType = columnType( sNC, p, ref zOriginDb, ref zOriginTab, ref zOriginCol ); - break; - } -#endif - } - - //if ( pzOriginDb != null ) - { - //Debug.Assert( pzOriginTab != null && pzOriginCol != null ); - pzOriginDb = zOriginDb; - pzOriginTab = zOriginTab; - pzOriginCol = zOriginCol; - } - return zType; - } + return zType; + } - /* - ** Generate code that will tell the VDBE the declaration types of columns - ** in the result set. - */ - static void generateColumnTypes( - Parse pParse, /* Parser context */ - SrcList pTabList, /* List of tables */ - ExprList pEList /* Expressions defining the result set */ - ) - { + /* + ** Generate code that will tell the VDBE the declaration types of columns + ** in the result set. + */ + static void generateColumnTypes( + Parse pParse, /* Parser context */ + SrcList pTabList, /* List of tables */ + ExprList pEList /* Expressions defining the result set */ + ) { #if !SQLITE_OMIT_DECLTYPE - Vdbe v = pParse.pVdbe; - int i; - NameContext sNC = new NameContext(); - sNC.pSrcList = pTabList; - sNC.pParse = pParse; - for ( i = 0; i < pEList.nExpr; i++ ) - { - Expr p = pEList.a[i].pExpr; - string zType; + Vdbe v = pParse.pVdbe; + int i; + NameContext sNC = new NameContext(); + sNC.pSrcList = pTabList; + sNC.pParse = pParse; + for (i = 0; i < pEList.nExpr; i++) { + Expr p = pEList.a[i].pExpr; + string zType; #if SQLITE_ENABLE_COLUMN_METADATA - string zOrigDb = null; - string zOrigTab = null; - string zOrigCol = null; - zType = columnType( sNC, p, ref zOrigDb, ref zOrigTab, ref 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 ); + string zOrigDb = null; + string zOrigTab = null; + string zOrigCol = null; + zType = columnType(sNC, p, ref zOrigDb, ref zOrigTab, ref 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 string sDummy = null; zType = columnType( sNC, p, ref sDummy, ref sDummy, ref sDummy ); #endif - sqlite3VdbeSetColName( v, i, COLNAME_DECLTYPE, zType, SQLITE_TRANSIENT ); - } + sqlite3VdbeSetColName(v, i, COLNAME_DECLTYPE, zType, SQLITE_TRANSIENT); + } #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 - ** azCol[] values in the callback. - */ - static void generateColumnNames( - Parse pParse, /* Parser context */ - SrcList pTabList, /* List of tables */ - ExprList pEList /* Expressions defining the result set */ - ) - { - Vdbe v = pParse.pVdbe; - int i, j; - sqlite3 db = pParse.db; - bool fullNames; - bool shortNames; + /* + ** Generate code that will tell the VDBE the names of columns + ** in the result set. This information is used to provide the + ** azCol[] values in the callback. + */ + static void generateColumnNames( + Parse pParse, /* Parser context */ + SrcList pTabList, /* List of tables */ + ExprList pEList /* Expressions defining the result set */ + ) { + Vdbe v = pParse.pVdbe; + int i, j; + sqlite3 db = pParse.db; + bool fullNames; + bool shortNames; #if !SQLITE_OMIT_EXPLAIN - /* If this is an EXPLAIN, skip this step */ - if ( pParse.explain != 0 ) - { - return; - } + /* If this is an EXPLAIN, skip this step */ + if (pParse.explain != 0) { + return; + } #endif - if ( pParse.colNamesSet != 0 || NEVER( v == null ) /*|| db.mallocFailed != 0 */ ) - return; - pParse.colNamesSet = 1; - fullNames = ( db.flags & SQLITE_FullColNames ) != 0; - shortNames = ( db.flags & SQLITE_ShortColNames ) != 0; - sqlite3VdbeSetNumCols( v, pEList.nExpr ); - for ( i = 0; i < pEList.nExpr; i++ ) - { - Expr p; - p = pEList.a[i].pExpr; - if ( NEVER( p == null ) ) - continue; - if ( pEList.a[i].zName != null ) - { - string zName = pEList.a[i].zName; - sqlite3VdbeSetColName( v, i, COLNAME_NAME, zName, SQLITE_TRANSIENT ); - } - else if ( ( p.op == TK_COLUMN || p.op == TK_AGG_COLUMN ) && pTabList != null ) - { - Table pTab; - string zCol; - int iCol = p.iColumn; - for ( j = 0; ALWAYS( j < pTabList.nSrc ); j++ ) - { - if ( pTabList.a[j].iCursor == p.iTable ) - break; - } - Debug.Assert( j < pTabList.nSrc ); - pTab = pTabList.a[j].pTab; - if ( iCol < 0 ) - iCol = pTab.iPKey; - Debug.Assert( iCol == -1 || ( iCol >= 0 && iCol < pTab.nCol ) ); - if ( iCol < 0 ) - { - zCol = "rowid"; - } - else - { - zCol = pTab.aCol[iCol].zName; - } - if ( !shortNames && !fullNames ) - { - sqlite3VdbeSetColName( v, i, COLNAME_NAME, - pEList.a[i].zSpan, SQLITE_DYNAMIC );//sqlite3DbStrDup(db, pEList->a[i].zSpan), SQLITE_DYNAMIC); - } - else if ( fullNames ) - { - string zName; - zName = sqlite3MPrintf( db, "%s.%s", pTab.zName, zCol ); - sqlite3VdbeSetColName( v, i, COLNAME_NAME, zName, SQLITE_DYNAMIC ); - } - else - { - sqlite3VdbeSetColName( v, i, COLNAME_NAME, zCol, SQLITE_TRANSIENT ); - } - } - else - { - sqlite3VdbeSetColName( v, i, COLNAME_NAME, - pEList.a[i].zSpan, SQLITE_DYNAMIC );//sqlite3DbStrDup(db, pEList->a[i].zSpan), SQLITE_DYNAMIC); + if (pParse.colNamesSet != 0 || NEVER(v == null) /*|| db.mallocFailed != 0 */ ) + return; + pParse.colNamesSet = 1; + fullNames = (db.flags & SQLITE_FullColNames) != 0; + shortNames = (db.flags & SQLITE_ShortColNames) != 0; + sqlite3VdbeSetNumCols(v, pEList.nExpr); + for (i = 0; i < pEList.nExpr; i++) { + Expr p; + p = pEList.a[i].pExpr; + if (NEVER(p == null)) + continue; + if (pEList.a[i].zName != null) { + string zName = pEList.a[i].zName; + sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_TRANSIENT); + } else if ((p.op == TK_COLUMN || p.op == TK_AGG_COLUMN) && pTabList != null) { + Table pTab; + string zCol; + int iCol = p.iColumn; + for (j = 0; ALWAYS(j < pTabList.nSrc); j++) { + if (pTabList.a[j].iCursor == p.iTable) + break; + } + Debug.Assert(j < pTabList.nSrc); + pTab = pTabList.a[j].pTab; + if (iCol < 0) + iCol = pTab.iPKey; + Debug.Assert(iCol == -1 || (iCol >= 0 && iCol < pTab.nCol)); + if (iCol < 0) { + zCol = "rowid"; + } else { + zCol = pTab.aCol[iCol].zName; + } + if (!shortNames && !fullNames) { + sqlite3VdbeSetColName(v, i, COLNAME_NAME, + pEList.a[i].zSpan, SQLITE_DYNAMIC);//sqlite3DbStrDup(db, pEList->a[i].zSpan), SQLITE_DYNAMIC); + } else if (fullNames) { + string zName; + zName = sqlite3MPrintf(db, "%s.%s", pTab.zName, zCol); + sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_DYNAMIC); + } else { + sqlite3VdbeSetColName(v, i, COLNAME_NAME, zCol, SQLITE_TRANSIENT); + } + } else { + sqlite3VdbeSetColName(v, i, COLNAME_NAME, + pEList.a[i].zSpan, SQLITE_DYNAMIC);//sqlite3DbStrDup(db, pEList->a[i].zSpan), SQLITE_DYNAMIC); + } + } + generateColumnTypes(pParse, pTabList, pEList); } - } - generateColumnTypes( pParse, pTabList, pEList ); - } - /* - ** Given a an expression list (which is really the list of expressions - ** that form the result set of a SELECT statement) compute appropriate - ** column names for a table that would hold the expression list. - ** - ** All column names will be unique. - ** - ** Only the column names are computed. Column.zType, Column.zColl, - ** and other fields of Column are zeroed. - ** - ** Return SQLITE_OK on success. If a memory allocation error occurs, - ** store NULL in paCol and 0 in pnCol and return SQLITE_NOMEM. - */ - static int selectColumnsFromExprList( - Parse pParse, /* Parsing context */ - ExprList pEList, /* Expr list from which to derive column names */ - ref int pnCol, /* Write the number of columns here */ - ref Column[] paCol /* Write the new column list here */ - ) - { - sqlite3 db = pParse.db; /* Database connection */ - int i, j; /* Loop counters */ - int cnt; /* Index added to make the name unique */ - Column[] aCol; - Column pCol; /* For looping over result columns */ - int nCol; /* Number of columns in the result set */ - Expr p; /* Expression for a single result column */ - string zName; /* Column name */ - int nName; /* Size of name in zName[] */ - - - pnCol = nCol = pEList.nExpr; - aCol = paCol = new Column[nCol];//sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol); - //if ( aCol == null ) - // return SQLITE_NOMEM; - for ( i = 0; i < nCol; i++ )//, pCol++) - { - if ( aCol[i] == null ) - aCol[i] = new Column(); - pCol = aCol[i]; - /* Get an appropriate name for the column + /* + ** Given a an expression list (which is really the list of expressions + ** that form the result set of a SELECT statement) compute appropriate + ** column names for a table that would hold the expression list. + ** + ** All column names will be unique. + ** + ** Only the column names are computed. Column.zType, Column.zColl, + ** and other fields of Column are zeroed. + ** + ** Return SQLITE_OK on success. If a memory allocation error occurs, + ** store NULL in paCol and 0 in pnCol and return SQLITE_NOMEM. */ - p = pEList.a[i].pExpr; - Debug.Assert( p.pRight == null || ExprHasProperty( p.pRight, EP_IntValue ) - || p.pRight.u.zToken == null || p.pRight.u.zToken.Length > 0 ); - if ( pEList.a[i].zName != null && ( zName = pEList.a[i].zName ) != "" ) - { - /* If the column contains an "AS " phrase, use as the name */ - //zName = sqlite3DbStrDup(db, zName); - } - else - { - Expr pColExpr = p; /* The expression that is the result column name */ - Table pTab; /* Table associated with this expression */ - while ( pColExpr.op == TK_DOT ) - pColExpr = pColExpr.pRight; - if ( pColExpr.op == TK_COLUMN && ALWAYS( pColExpr.pTab != null ) ) - { - /* For columns use the column name name */ - int iCol = pColExpr.iColumn; - pTab = pColExpr.pTab; - if ( iCol < 0 ) - iCol = pTab.iPKey; - zName = sqlite3MPrintf( db, "%s", - iCol >= 0 ? pTab.aCol[iCol].zName : "rowid" ); - } - else if ( pColExpr.op == TK_ID ) - { - Debug.Assert( !ExprHasProperty( pColExpr, EP_IntValue ) ); - zName = sqlite3MPrintf( db, "%s", pColExpr.u.zToken ); - } - else - { - /* Use the original text of the column expression as its name */ - zName = sqlite3MPrintf( db, "%s", pEList.a[i].zSpan ); - } + static int selectColumnsFromExprList( + Parse pParse, /* Parsing context */ + ExprList pEList, /* Expr list from which to derive column names */ + ref int pnCol, /* Write the number of columns here */ + ref Column[] paCol /* Write the new column list here */ + ) { + sqlite3 db = pParse.db; /* Database connection */ + int i, j; /* Loop counters */ + int cnt; /* Index added to make the name unique */ + Column[] aCol; + Column pCol; /* For looping over result columns */ + int nCol; /* Number of columns in the result set */ + Expr p; /* Expression for a single result column */ + string zName; /* Column name */ + int nName; /* Size of name in zName[] */ + + + pnCol = nCol = pEList.nExpr; + aCol = paCol = new Column[nCol];//sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol); + //if ( aCol == null ) + // return SQLITE_NOMEM; + for (i = 0; i < nCol; i++)//, pCol++) + { + if (aCol[i] == null) + aCol[i] = new Column(); + pCol = aCol[i]; + /* Get an appropriate name for the column + */ + p = pEList.a[i].pExpr; + Debug.Assert(p.pRight == null || ExprHasProperty(p.pRight, EP_IntValue) + || p.pRight.u.zToken == null || p.pRight.u.zToken.Length > 0); + if (pEList.a[i].zName != null && (zName = pEList.a[i].zName) != "") { + /* If the column contains an "AS " phrase, use as the name */ + //zName = sqlite3DbStrDup(db, zName); + } else { + Expr pColExpr = p; /* The expression that is the result column name */ + Table pTab; /* Table associated with this expression */ + while (pColExpr.op == TK_DOT) + pColExpr = pColExpr.pRight; + if (pColExpr.op == TK_COLUMN && ALWAYS(pColExpr.pTab != null)) { + /* For columns use the column name name */ + int iCol = pColExpr.iColumn; + pTab = pColExpr.pTab; + if (iCol < 0) + iCol = pTab.iPKey; + zName = sqlite3MPrintf(db, "%s", + iCol >= 0 ? pTab.aCol[iCol].zName : "rowid"); + } else if (pColExpr.op == TK_ID) { + Debug.Assert(!ExprHasProperty(pColExpr, EP_IntValue)); + zName = sqlite3MPrintf(db, "%s", pColExpr.u.zToken); + } else { + /* Use the original text of the column expression as its name */ + zName = sqlite3MPrintf(db, "%s", pEList.a[i].zSpan); + } + } + //if ( db.mallocFailed != 0 ) + //{ + // sqlite3DbFree( db, ref zName ); + // break; + //} + + /* Make sure the column name is unique. If the name is not unique, + ** append a integer to the name so that it becomes unique. + */ + nName = sqlite3Strlen30(zName); + for (j = cnt = 0; j < i; j++) { + if (aCol[j].zName.Equals(zName, StringComparison.OrdinalIgnoreCase)) { + string zNewName; + //zName[nName] = 0; + zNewName = sqlite3MPrintf(db, "%s:%d", zName.Substring(0, nName), ++cnt); + sqlite3DbFree(db, ref zName); + zName = zNewName; + j = -1; + if (zName == "") + break; + } + } + pCol.zName = zName; + } + //if ( db.mallocFailed != 0 ) + //{ + // for ( j = 0 ; j < i ; j++ ) + // { + // sqlite3DbFree( db, aCol[j].zName ); + // } + // sqlite3DbFree( db, aCol ); + // paCol = null; + // pnCol = 0; + // return SQLITE_NOMEM; + //} + return SQLITE_OK; } - //if ( db.mallocFailed != 0 ) - //{ - // sqlite3DbFree( db, ref zName ); - // break; - //} - - /* Make sure the column name is unique. If the name is not unique, - ** append a integer to the name so that it becomes unique. + + /* + ** Add type and collation information to a column list based on + ** a SELECT statement. + ** + ** The column list presumably came from selectColumnNamesFromExprList(). + ** The column list has only names, not types or collations. This + ** routine goes through and adds the types and collations. + ** + ** This routine requires that all identifiers in the SELECT + ** statement be resolved. */ - nName = sqlite3Strlen30( zName ); - for ( j = cnt = 0; j < i; j++ ) - { - if ( aCol[j].zName.Equals( zName, StringComparison.OrdinalIgnoreCase ) ) - { - string zNewName; - //zName[nName] = 0; - zNewName = sqlite3MPrintf( db, "%s:%d", zName.Substring( 0, nName ), ++cnt ); - sqlite3DbFree( db, ref zName ); - zName = zNewName; - j = -1; - if ( zName == "" ) - break; - } + static void selectAddColumnTypeAndCollation( + Parse pParse, /* Parsing contexts */ + 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; + ExprList_item[] a; + + Debug.Assert(pSelect != null); + Debug.Assert((pSelect.selFlags & SF_Resolved) != 0); + Debug.Assert(nCol == pSelect.pEList.nExpr /*|| db.mallocFailed != 0 */ ); + // if ( db.mallocFailed != 0 ) return; + sNC = new NameContext();// memset( &sNC, 0, sizeof( sNC ) ); + sNC.pSrcList = pSelect.pSrc; + a = pSelect.pEList.a; + for (i = 0; i < nCol; i++)//, pCol++ ) + { + pCol = aCol[i]; + p = a[i].pExpr; + string bDummy = null; + pCol.zType = columnType(sNC, p, ref bDummy, ref bDummy, ref bDummy);// 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 != null) { + pCol.zColl = pColl.zName;// sqlite3DbStrDup( db, pColl.zName ); + } + } } - pCol.zName = zName; - } - //if ( db.mallocFailed != 0 ) - //{ - // for ( j = 0 ; j < i ; j++ ) - // { - // sqlite3DbFree( db, aCol[j].zName ); - // } - // sqlite3DbFree( db, aCol ); - // paCol = null; - // pnCol = 0; - // return SQLITE_NOMEM; - //} - return SQLITE_OK; - } - /* - ** Add type and collation information to a column list based on - ** a SELECT statement. - ** - ** The column list presumably came from selectColumnNamesFromExprList(). - ** The column list has only names, not types or collations. This - ** routine goes through and adds the types and collations. - ** - ** This routine requires that all identifiers in the SELECT - ** statement be resolved. - */ - static void selectAddColumnTypeAndCollation( - Parse pParse, /* Parsing contexts */ - 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; - ExprList_item[] a; - - Debug.Assert( pSelect != null ); - Debug.Assert( ( pSelect.selFlags & SF_Resolved ) != 0 ); - Debug.Assert( nCol == pSelect.pEList.nExpr /*|| db.mallocFailed != 0 */ ); - // if ( db.mallocFailed != 0 ) return; - sNC = new NameContext();// memset( &sNC, 0, sizeof( sNC ) ); - sNC.pSrcList = pSelect.pSrc; - a = pSelect.pEList.a; - for ( i = 0; i < nCol; i++ )//, pCol++ ) - { - pCol = aCol[i]; - p = a[i].pExpr; - string bDummy = null; - pCol.zType = columnType( sNC, p, ref bDummy, ref bDummy, ref bDummy );// 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 != null ) - { - pCol.zColl = pColl.zName;// sqlite3DbStrDup( db, pColl.zName ); + /* + ** Given a SELECT statement, generate a Table structure that describes + ** the result set of that SELECT. + */ + static Table sqlite3ResultSetOfSelect(Parse pParse, Select pSelect) { + Table pTab; + sqlite3 db = pParse.db; + int savedFlags; + + savedFlags = db.flags; + db.flags &= ~SQLITE_FullColNames; + db.flags |= SQLITE_ShortColNames; + sqlite3SelectPrep(pParse, pSelect, null); + if (pParse.nErr != 0) + return null; + while (pSelect.pPrior != null) + pSelect = pSelect.pPrior; + db.flags = savedFlags; + pTab = new Table();// sqlite3DbMallocZero( db, sizeof( Table ) ); + if (pTab == null) { + return null; + } + /* The sqlite3ResultSetOfSelect() is only used n contexts where lookaside + ** is disabled */ + Debug.Assert(db.lookaside.bEnabled == 0); + pTab.nRef = 1; + pTab.zName = null; + pTab.nRowEst = 1000000; + selectColumnsFromExprList(pParse, pSelect.pEList, ref pTab.nCol, ref pTab.aCol); + selectAddColumnTypeAndCollation(pParse, pTab.nCol, pTab.aCol, pSelect); + pTab.iPKey = -1; + //if ( db.mallocFailed != 0 ) + //{ + // sqlite3DeleteTable(db, ref pTab ); + // return null; + //} + return pTab; } - } - } - - /* - ** Given a SELECT statement, generate a Table structure that describes - ** the result set of that SELECT. - */ - static Table sqlite3ResultSetOfSelect( Parse pParse, Select pSelect ) - { - Table pTab; - sqlite3 db = pParse.db; - int savedFlags; - - savedFlags = db.flags; - db.flags &= ~SQLITE_FullColNames; - db.flags |= SQLITE_ShortColNames; - sqlite3SelectPrep( pParse, pSelect, null ); - if ( pParse.nErr != 0 ) - return null; - while ( pSelect.pPrior != null ) - pSelect = pSelect.pPrior; - db.flags = savedFlags; - pTab = new Table();// sqlite3DbMallocZero( db, sizeof( Table ) ); - if ( pTab == null ) - { - return null; - } - /* The sqlite3ResultSetOfSelect() is only used n contexts where lookaside - ** is disabled */ - Debug.Assert( db.lookaside.bEnabled == 0 ); - pTab.nRef = 1; - pTab.zName = null; - pTab.nRowEst = 1000000; - selectColumnsFromExprList( pParse, pSelect.pEList, ref pTab.nCol, ref pTab.aCol ); - selectAddColumnTypeAndCollation( pParse, pTab.nCol, pTab.aCol, pSelect ); - pTab.iPKey = -1; - //if ( db.mallocFailed != 0 ) - //{ - // sqlite3DeleteTable(db, ref pTab ); - // return null; - //} - return pTab; - } - /* - ** Get a VDBE for the given parser context. Create a new one if necessary. - ** If an error occurs, return NULL and leave a message in pParse. - */ - static Vdbe sqlite3GetVdbe( Parse pParse ) - { - Vdbe v = pParse.pVdbe; - if ( v == null ) - { - v = pParse.pVdbe = sqlite3VdbeCreate( pParse.db ); + /* + ** Get a VDBE for the given parser context. Create a new one if necessary. + ** If an error occurs, return NULL and leave a message in pParse. + */ + static Vdbe sqlite3GetVdbe(Parse pParse) { + Vdbe v = pParse.pVdbe; + if (v == null) { + v = pParse.pVdbe = sqlite3VdbeCreate(pParse.db); #if !SQLITE_OMIT_TRACE - if ( v != null ) - { - sqlite3VdbeAddOp0( v, OP_Trace ); - } + if (v != null) { + sqlite3VdbeAddOp0(v, OP_Trace); + } #endif - } - return v; - } + } + return v; + } - /* - ** Compute the iLimit and iOffset fields of the SELECT based on the - ** pLimit and pOffset expressions. pLimit and pOffset hold the expressions - ** that appear in the original SQL statement after the LIMIT and OFFSET - ** keywords. Or NULL if those keywords are omitted. iLimit and iOffset - ** are the integer memory register numbers for counters used to compute - ** the limit and offset. If there is no limit and/or offset, then - ** iLimit and iOffset are negative. - ** - ** This routine changes the values of iLimit and iOffset only if - ** a limit or offset is defined by pLimit and pOffset. iLimit and - ** iOffset should have been preset to appropriate default values - ** (usually but not always -1) prior to calling this routine. - ** Only if pLimit!=0 or pOffset!=0 do the limit registers get - ** redefined. The UNION ALL operator uses this property to force - ** the reuse of the same limit and offset registers across multiple - ** SELECT statements. - */ - static void computeLimitRegisters( Parse pParse, Select p, int iBreak ) - { - Vdbe v = null; - int iLimit = 0; - int iOffset; - int addr1, n = 0; - if ( p.iLimit != 0 ) - return; - - /* - ** "LIMIT -1" always shows all rows. There is some - ** contraversy about what the correct behavior should be. - ** The current implementation interprets "LIMIT 0" to mean - ** no rows. - */ - sqlite3ExprCacheClear( pParse ); - Debug.Assert( p.pOffset == null || p.pLimit != null ); - if ( p.pLimit != null ) - { - p.iLimit = iLimit = ++pParse.nMem; - v = sqlite3GetVdbe( pParse ); - if ( NEVER( v == null ) ) - return; /* VDBE should have already been allocated */ - if ( sqlite3ExprIsInteger( p.pLimit, ref n ) != 0 ) - { - sqlite3VdbeAddOp2( v, OP_Integer, n, iLimit ); - VdbeComment( v, "LIMIT counter" ); - if ( n == 0 ) - { - sqlite3VdbeAddOp2( v, OP_Goto, 0, iBreak ); - } - else - { - if ( p.nSelectRow > (double)n ) - p.nSelectRow = (double)n; - } - } - else - { - sqlite3ExprCode( pParse, p.pLimit, iLimit ); - sqlite3VdbeAddOp1( v, OP_MustBeInt, iLimit ); + /* + ** Compute the iLimit and iOffset fields of the SELECT based on the + ** pLimit and pOffset expressions. pLimit and pOffset hold the expressions + ** that appear in the original SQL statement after the LIMIT and OFFSET + ** keywords. Or NULL if those keywords are omitted. iLimit and iOffset + ** are the integer memory register numbers for counters used to compute + ** the limit and offset. If there is no limit and/or offset, then + ** iLimit and iOffset are negative. + ** + ** This routine changes the values of iLimit and iOffset only if + ** a limit or offset is defined by pLimit and pOffset. iLimit and + ** iOffset should have been preset to appropriate default values + ** (usually but not always -1) prior to calling this routine. + ** Only if pLimit!=0 or pOffset!=0 do the limit registers get + ** redefined. The UNION ALL operator uses this property to force + ** the reuse of the same limit and offset registers across multiple + ** SELECT statements. + */ + static void computeLimitRegisters(Parse pParse, Select p, int iBreak) { + Vdbe v = null; + int iLimit = 0; + int iOffset; + int addr1, n = 0; + if (p.iLimit != 0) + return; + + /* + ** "LIMIT -1" always shows all rows. There is some + ** contraversy about what the correct behavior should be. + ** The current implementation interprets "LIMIT 0" to mean + ** no rows. + */ + sqlite3ExprCacheClear(pParse); + Debug.Assert(p.pOffset == null || p.pLimit != null); + if (p.pLimit != null) { + p.iLimit = iLimit = ++pParse.nMem; + v = sqlite3GetVdbe(pParse); + if (NEVER(v == null)) + return; /* VDBE should have already been allocated */ + if (sqlite3ExprIsInteger(p.pLimit, ref n) != 0) { + sqlite3VdbeAddOp2(v, OP_Integer, n, iLimit); + VdbeComment(v, "LIMIT counter"); + if (n == 0) { + sqlite3VdbeAddOp2(v, OP_Goto, 0, iBreak); + } else { + if (p.nSelectRow > (double)n) + p.nSelectRow = (double)n; + } + } else { + sqlite3ExprCode(pParse, p.pLimit, iLimit); + sqlite3VdbeAddOp1(v, OP_MustBeInt, iLimit); #if SQLITE_DEBUG - VdbeComment( v, "LIMIT counter" ); + VdbeComment(v, "LIMIT counter"); #endif - sqlite3VdbeAddOp2( v, OP_IfZero, iLimit, iBreak ); - } - if ( p.pOffset != null ) - { - p.iOffset = iOffset = ++pParse.nMem; - pParse.nMem++; /* Allocate an extra register for limit+offset */ - sqlite3ExprCode( pParse, p.pOffset, iOffset ); - sqlite3VdbeAddOp1( v, OP_MustBeInt, iOffset ); + sqlite3VdbeAddOp2(v, OP_IfZero, iLimit, iBreak); + } + if (p.pOffset != null) { + p.iOffset = iOffset = ++pParse.nMem; + pParse.nMem++; /* Allocate an extra register for limit+offset */ + sqlite3ExprCode(pParse, p.pOffset, iOffset); + sqlite3VdbeAddOp1(v, OP_MustBeInt, iOffset); #if SQLITE_DEBUG - VdbeComment( v, "OFFSET counter" ); + VdbeComment(v, "OFFSET counter"); #endif - addr1 = sqlite3VdbeAddOp1( v, OP_IfPos, iOffset ); - sqlite3VdbeAddOp2( v, OP_Integer, 0, iOffset ); - sqlite3VdbeJumpHere( v, addr1 ); - sqlite3VdbeAddOp3( v, OP_Add, iLimit, iOffset, iOffset + 1 ); + addr1 = sqlite3VdbeAddOp1(v, OP_IfPos, iOffset); + sqlite3VdbeAddOp2(v, OP_Integer, 0, iOffset); + sqlite3VdbeJumpHere(v, addr1); + sqlite3VdbeAddOp3(v, OP_Add, iLimit, iOffset, iOffset + 1); #if SQLITE_DEBUG - VdbeComment( v, "LIMIT+OFFSET" ); + VdbeComment(v, "LIMIT+OFFSET"); #endif - addr1 = sqlite3VdbeAddOp1( v, OP_IfPos, iLimit ); - sqlite3VdbeAddOp2( v, OP_Integer, -1, iOffset + 1 ); - sqlite3VdbeJumpHere( v, addr1 ); + addr1 = sqlite3VdbeAddOp1(v, OP_IfPos, iLimit); + sqlite3VdbeAddOp2(v, OP_Integer, -1, iOffset + 1); + sqlite3VdbeJumpHere(v, addr1); + } + } } - } - } #if !SQLITE_OMIT_COMPOUND_SELECT - /* -** Return the appropriate collating sequence for the iCol-th column of -** the result set for the compound-select statement "p". Return NULL if -** the column has no default collating sequence. -** -** The collating sequence for the compound select is taken from the -** left-most term of the select that has a collating sequence. -*/ - static CollSeq multiSelectCollSeq( Parse pParse, Select p, int iCol ) - { - CollSeq pRet; - if ( p.pPrior != null ) - { - pRet = multiSelectCollSeq( pParse, p.pPrior, iCol ); - } - else - { - pRet = null; - } - Debug.Assert( iCol >= 0 ); - if ( pRet == null && iCol < p.pEList.nExpr ) - { - pRet = sqlite3ExprCollSeq( pParse, p.pEList.a[iCol].pExpr ); - } - return pRet; - } + /* + ** Return the appropriate collating sequence for the iCol-th column of + ** the result set for the compound-select statement "p". Return NULL if + ** the column has no default collating sequence. + ** + ** The collating sequence for the compound select is taken from the + ** left-most term of the select that has a collating sequence. + */ + static CollSeq multiSelectCollSeq(Parse pParse, Select p, int iCol) { + CollSeq pRet; + if (p.pPrior != null) { + pRet = multiSelectCollSeq(pParse, p.pPrior, iCol); + } else { + pRet = null; + } + Debug.Assert(iCol >= 0); + if (pRet == null && iCol < p.pEList.nExpr) { + pRet = sqlite3ExprCollSeq(pParse, p.pEList.a[iCol].pExpr); + } + return pRet; + } #endif // * SQLITE_OMIT_COMPOUND_SELECT */ - /* Forward reference */ - //static int multiSelectOrderBy( - // Parse* pParse, /* Parsing context */ - // Select* p, /* The right-most of SELECTs to be coded */ - // SelectDest* pDest /* What to do with query results */ - //); + /* Forward reference */ + //static int multiSelectOrderBy( + // Parse* pParse, /* Parsing context */ + // Select* p, /* The right-most of SELECTs to be coded */ + // SelectDest* pDest /* What to do with query results */ + //); #if !SQLITE_OMIT_COMPOUND_SELECT - /* -** This routine is called to process a compound query form from -** two or more separate queries using UNION, UNION ALL, EXCEPT, or -** INTERSECT -** -** "p" points to the right-most of the two queries. the query on the -** left is p.pPrior. The left query could also be a compound query -** in which case this routine will be called recursively. -** -** The results of the total query are to be written into a destination -** of type eDest with parameter iParm. -** -** Example 1: Consider a three-way compound SQL statement. -** -** SELECT a FROM t1 UNION SELECT b FROM t2 UNION SELECT c FROM t3 -** -** This statement is parsed up as follows: -** -** SELECT c FROM t3 -** | -** `----. SELECT b FROM t2 -** | -** `-----. SELECT a FROM t1 -** -** The arrows in the diagram above represent the Select.pPrior pointer. -** So if this routine is called with p equal to the t3 query, then -** pPrior will be the t2 query. p.op will be TK_UNION in this case. -** -** Notice that because of the way SQLite parses compound SELECTs, the -** individual selects always group from left to right. -*/ - static int multiSelect( - Parse pParse, /* Parsing context */ - Select p, /* The right-most of SELECTs to be coded */ - SelectDest pDest /* What to do with query results */ - ) - { - int rc = SQLITE_OK; /* Success code from a subroutine */ - Select pPrior; /* Another SELECT immediately to our left */ - Vdbe v; /* Generate code to this VDBE */ - SelectDest dest = new SelectDest(); /* Alternative data destination */ - Select pDelete = null; /* Chain of simple selects to delete */ - sqlite3 db; /* Database connection */ + /* + ** This routine is called to process a compound query form from + ** two or more separate queries using UNION, UNION ALL, EXCEPT, or + ** INTERSECT + ** + ** "p" points to the right-most of the two queries. the query on the + ** left is p.pPrior. The left query could also be a compound query + ** in which case this routine will be called recursively. + ** + ** The results of the total query are to be written into a destination + ** of type eDest with parameter iParm. + ** + ** Example 1: Consider a three-way compound SQL statement. + ** + ** SELECT a FROM t1 UNION SELECT b FROM t2 UNION SELECT c FROM t3 + ** + ** This statement is parsed up as follows: + ** + ** SELECT c FROM t3 + ** | + ** `----. SELECT b FROM t2 + ** | + ** `-----. SELECT a FROM t1 + ** + ** The arrows in the diagram above represent the Select.pPrior pointer. + ** So if this routine is called with p equal to the t3 query, then + ** pPrior will be the t2 query. p.op will be TK_UNION in this case. + ** + ** Notice that because of the way SQLite parses compound SELECTs, the + ** individual selects always group from left to right. + */ + static int multiSelect( + Parse pParse, /* Parsing context */ + Select p, /* The right-most of SELECTs to be coded */ + SelectDest pDest /* What to do with query results */ + ) { + int rc = SQLITE_OK; /* Success code from a subroutine */ + Select pPrior; /* Another SELECT immediately to our left */ + Vdbe v; /* Generate code to this VDBE */ + SelectDest dest = new SelectDest(); /* Alternative data destination */ + Select pDelete = null; /* Chain of simple selects to delete */ + sqlite3 db; /* Database connection */ #if !SQLITE_OMIT_EXPLAIN - int iSub1 = 0; /* EQP id of left-hand query */ - int iSub2 = 0; /* EQP id of right-hand query */ + int iSub1 = 0; /* EQP id of left-hand query */ + int iSub2 = 0; /* EQP id of right-hand query */ #endif - /* Make sure there is no ORDER BY or LIMIT clause on prior SELECTs. Only -** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT. -*/ - Debug.Assert( p != null && p.pPrior != null ); /* Calling function guarantees this much */ - db = pParse.db; - pPrior = p.pPrior; - Debug.Assert( pPrior.pRightmost != pPrior ); - Debug.Assert( pPrior.pRightmost == p.pRightmost ); - dest = pDest; - if ( pPrior.pOrderBy != null ) - { - sqlite3ErrorMsg( pParse, "ORDER BY clause should come after %s not before", - selectOpName( p.op ) ); - rc = 1; - goto multi_select_end; - } - if ( pPrior.pLimit != null ) - { - sqlite3ErrorMsg( pParse, "LIMIT clause should come after %s not before", - selectOpName( p.op ) ); - rc = 1; - goto multi_select_end; - } - - v = sqlite3GetVdbe( pParse ); - Debug.Assert( v != null ); /* The VDBE already created by calling function */ - - /* Create the destination temporary table if necessary - */ - if ( dest.eDest == SRT_EphemTab ) - { - Debug.Assert( p.pEList != null ); - sqlite3VdbeAddOp2( v, OP_OpenEphemeral, dest.iParm, p.pEList.nExpr ); - sqlite3VdbeChangeP5( v, BTREE_UNORDERED ); - dest.eDest = SRT_Table; - } - - /* Make sure all SELECTs in the statement have the same number of elements - ** in their result sets. - */ - Debug.Assert( p.pEList != null && pPrior.pEList != null ); - if ( p.pEList.nExpr != pPrior.pEList.nExpr ) - { - sqlite3ErrorMsg( pParse, "SELECTs to the left and right of %s" + - " do not have the same number of result columns", selectOpName( p.op ) ); - rc = 1; - goto multi_select_end; - } - - /* Compound SELECTs that have an ORDER BY clause are handled separately. - */ - if ( p.pOrderBy != null ) - { - return multiSelectOrderBy( pParse, p, pDest ); - } - - /* Generate code for the left and right SELECT statements. + /* Make sure there is no ORDER BY or LIMIT clause on prior SELECTs. Only + ** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT. */ - switch ( p.op ) - { - case TK_ALL: - { - int addr = 0; - int nLimit = 0; - Debug.Assert( pPrior.pLimit == null ); - pPrior.pLimit = p.pLimit; - pPrior.pOffset = p.pOffset; - explainSetInteger( ref iSub1, pParse.iNextSelectId ); - rc = sqlite3Select( pParse, pPrior, ref dest ); - p.pLimit = null; - p.pOffset = null; - if ( rc != 0 ) - { - goto multi_select_end; - } - p.pPrior = null; - p.iLimit = pPrior.iLimit; - p.iOffset = pPrior.iOffset; - if ( p.iLimit != 0 ) - { - addr = sqlite3VdbeAddOp1( v, OP_IfZero, p.iLimit ); -#if SQLITE_DEBUG - VdbeComment( v, "Jump ahead if LIMIT reached" ); -#endif - } - explainSetInteger( ref iSub2, pParse.iNextSelectId ); - rc = sqlite3Select( pParse, p, ref dest ); - testcase( rc != SQLITE_OK ); - pDelete = p.pPrior; - p.pPrior = pPrior; - p.nSelectRow += pPrior.nSelectRow; - if ( pPrior.pLimit != null - && sqlite3ExprIsInteger( pPrior.pLimit, ref nLimit ) != 0 - && p.nSelectRow > (double)nLimit - ) - { - p.nSelectRow = (double)nLimit; + Debug.Assert(p != null && p.pPrior != null); /* Calling function guarantees this much */ + db = pParse.db; + pPrior = p.pPrior; + Debug.Assert(pPrior.pRightmost != pPrior); + Debug.Assert(pPrior.pRightmost == p.pRightmost); + dest = pDest; + if (pPrior.pOrderBy != null) { + sqlite3ErrorMsg(pParse, "ORDER BY clause should come after %s not before", + selectOpName(p.op)); + rc = 1; + goto multi_select_end; } - if ( addr != 0 ) - { - sqlite3VdbeJumpHere( v, addr ); + if (pPrior.pLimit != null) { + sqlite3ErrorMsg(pParse, "LIMIT clause should come after %s not before", + selectOpName(p.op)); + rc = 1; + goto multi_select_end; } - break; - } - case TK_EXCEPT: - case TK_UNION: - { - int unionTab; /* VdbeCursor number of the temporary table holding result */ - u8 op = 0; /* One of the SRT_ operations to apply to self */ - int priorOp; /* The SRT_ operation to apply to prior selects */ - Expr pLimit, pOffset; /* Saved values of p.nLimit and p.nOffset */ - int addr; - SelectDest uniondest = new SelectDest(); - testcase( p.op == TK_EXCEPT ); - testcase( p.op == TK_UNION ); - priorOp = SRT_Union; - if ( dest.eDest == priorOp && ALWAYS( null == p.pLimit && null == p.pOffset ) ) - { - /* We can reuse a temporary table generated by a SELECT to our - ** right. - */ - Debug.Assert( p.pRightmost != p ); /* Can only happen for leftward elements -** of a 3-way or more compound */ - Debug.Assert( p.pLimit == null ); /* Not allowed on leftward elements */ - Debug.Assert( p.pOffset == null ); /* Not allowed on leftward elements */ - unionTab = dest.iParm; - } - else - { - /* We will need to create our own temporary table to hold the - ** intermediate results. - */ - unionTab = pParse.nTab++; - Debug.Assert( p.pOrderBy == null ); - addr = sqlite3VdbeAddOp2( v, OP_OpenEphemeral, unionTab, 0 ); - Debug.Assert( p.addrOpenEphm[0] == -1 ); - p.addrOpenEphm[0] = addr; - p.pRightmost.selFlags |= SF_UsesEphemeral; - Debug.Assert( p.pEList != null ); - } + v = sqlite3GetVdbe(pParse); + Debug.Assert(v != null); /* The VDBE already created by calling function */ - /* Code the SELECT statements to our left + /* Create the destination temporary table if necessary */ - Debug.Assert( pPrior.pOrderBy == null ); - sqlite3SelectDestInit( uniondest, priorOp, unionTab ); - explainSetInteger( ref iSub1, pParse.iNextSelectId ); - rc = sqlite3Select( pParse, pPrior, ref uniondest ); - if ( rc != 0 ) - { - goto multi_select_end; + if (dest.eDest == SRT_EphemTab) { + Debug.Assert(p.pEList != null); + sqlite3VdbeAddOp2(v, OP_OpenEphemeral, dest.iParm, p.pEList.nExpr); + sqlite3VdbeChangeP5(v, BTREE_UNORDERED); + dest.eDest = SRT_Table; } - /* Code the current SELECT statement + /* Make sure all SELECTs in the statement have the same number of elements + ** in their result sets. */ - if ( p.op == TK_EXCEPT ) - { - op = SRT_Except; - } - else - { - Debug.Assert( p.op == TK_UNION ); - op = SRT_Union; + Debug.Assert(p.pEList != null && pPrior.pEList != null); + if (p.pEList.nExpr != pPrior.pEList.nExpr) { + sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s" + + " do not have the same number of result columns", selectOpName(p.op)); + rc = 1; + goto multi_select_end; } - p.pPrior = null; - pLimit = p.pLimit; - p.pLimit = null; - pOffset = p.pOffset; - p.pOffset = null; - uniondest.eDest = op; - explainSetInteger( ref iSub2, pParse.iNextSelectId ); - rc = sqlite3Select( pParse, p, ref uniondest ); - testcase( rc != SQLITE_OK ); - /* Query flattening in sqlite3Select() might refill p.pOrderBy. - ** Be sure to delete p.pOrderBy, therefore, to avoid a memory leak. */ - sqlite3ExprListDelete( db, ref p.pOrderBy ); - pDelete = p.pPrior; - p.pPrior = pPrior; - p.pOrderBy = null; - if ( p.op == TK_UNION ) - p.nSelectRow += pPrior.nSelectRow; - sqlite3ExprDelete( db, ref p.pLimit ); - p.pLimit = pLimit; - p.pOffset = pOffset; - p.iLimit = 0; - p.iOffset = 0; - /* Convert the data in the temporary table into whatever form - ** it is that we currently need. + /* Compound SELECTs that have an ORDER BY clause are handled separately. */ - Debug.Assert( unionTab == dest.iParm || dest.eDest != priorOp ); - if ( dest.eDest != priorOp ) - { - int iCont, iBreak, iStart; - Debug.Assert( p.pEList != null ); - if ( dest.eDest == SRT_Output ) - { - Select pFirst = p; - while ( pFirst.pPrior != null ) - pFirst = pFirst.pPrior; - generateColumnNames( pParse, null, pFirst.pEList ); - } - iBreak = sqlite3VdbeMakeLabel( v ); - iCont = sqlite3VdbeMakeLabel( v ); - computeLimitRegisters( pParse, p, iBreak ); - sqlite3VdbeAddOp2( v, OP_Rewind, unionTab, iBreak ); - iStart = sqlite3VdbeCurrentAddr( v ); - selectInnerLoop( pParse, p, p.pEList, unionTab, p.pEList.nExpr, - null, -1, dest, iCont, iBreak ); - sqlite3VdbeResolveLabel( v, iCont ); - sqlite3VdbeAddOp2( v, OP_Next, unionTab, iStart ); - sqlite3VdbeResolveLabel( v, iBreak ); - sqlite3VdbeAddOp2( v, OP_Close, unionTab, 0 ); + if (p.pOrderBy != null) { + return multiSelectOrderBy(pParse, p, pDest); } - break; - } - default: - Debug.Assert( p.op == TK_INTERSECT ); - { - int tab1, tab2; - int iCont, iBreak, iStart; - Expr pLimit, pOffset; - int addr; - SelectDest intersectdest = new SelectDest(); - int r1; - /* INTERSECT is different from the others since it requires - ** two temporary tables. Hence it has its own case. Begin - ** by allocating the tables we will need. + /* Generate code for the left and right SELECT statements. */ - tab1 = pParse.nTab++; - tab2 = pParse.nTab++; - Debug.Assert( p.pOrderBy == null ); + switch (p.op) { + case TK_ALL: { + int addr = 0; + int nLimit = 0; + Debug.Assert(pPrior.pLimit == null); + pPrior.pLimit = p.pLimit; + pPrior.pOffset = p.pOffset; + explainSetInteger(ref iSub1, pParse.iNextSelectId); + rc = sqlite3Select(pParse, pPrior, ref dest); + p.pLimit = null; + p.pOffset = null; + if (rc != 0) { + goto multi_select_end; + } + p.pPrior = null; + p.iLimit = pPrior.iLimit; + p.iOffset = pPrior.iOffset; + if (p.iLimit != 0) { + addr = sqlite3VdbeAddOp1(v, OP_IfZero, p.iLimit); +#if SQLITE_DEBUG + VdbeComment(v, "Jump ahead if LIMIT reached"); +#endif + } + explainSetInteger(ref iSub2, pParse.iNextSelectId); + rc = sqlite3Select(pParse, p, ref dest); + testcase(rc != SQLITE_OK); + pDelete = p.pPrior; + p.pPrior = pPrior; + p.nSelectRow += pPrior.nSelectRow; + if (pPrior.pLimit != null + && sqlite3ExprIsInteger(pPrior.pLimit, ref nLimit) != 0 + && p.nSelectRow > (double)nLimit + ) { + p.nSelectRow = (double)nLimit; + } + if (addr != 0) { + sqlite3VdbeJumpHere(v, addr); + } + break; + } + case TK_EXCEPT: + case TK_UNION: { + int unionTab; /* VdbeCursor number of the temporary table holding result */ + u8 op = 0; /* One of the SRT_ operations to apply to self */ + int priorOp; /* The SRT_ operation to apply to prior selects */ + Expr pLimit, pOffset; /* Saved values of p.nLimit and p.nOffset */ + int addr; + SelectDest uniondest = new SelectDest(); + + testcase(p.op == TK_EXCEPT); + testcase(p.op == TK_UNION); + priorOp = SRT_Union; + if (dest.eDest == priorOp && ALWAYS(null == p.pLimit && null == p.pOffset)) { + /* We can reuse a temporary table generated by a SELECT to our + ** right. + */ + Debug.Assert(p.pRightmost != p); /* Can only happen for leftward elements +** of a 3-way or more compound */ + Debug.Assert(p.pLimit == null); /* Not allowed on leftward elements */ + Debug.Assert(p.pOffset == null); /* Not allowed on leftward elements */ + unionTab = dest.iParm; + } else { + /* We will need to create our own temporary table to hold the + ** intermediate results. + */ + unionTab = pParse.nTab++; + Debug.Assert(p.pOrderBy == null); + addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, unionTab, 0); + Debug.Assert(p.addrOpenEphm[0] == -1); + p.addrOpenEphm[0] = addr; + p.pRightmost.selFlags |= SF_UsesEphemeral; + Debug.Assert(p.pEList != null); + } + + /* Code the SELECT statements to our left + */ + Debug.Assert(pPrior.pOrderBy == null); + sqlite3SelectDestInit(uniondest, priorOp, unionTab); + explainSetInteger(ref iSub1, pParse.iNextSelectId); + rc = sqlite3Select(pParse, pPrior, ref uniondest); + if (rc != 0) { + goto multi_select_end; + } + + /* Code the current SELECT statement + */ + if (p.op == TK_EXCEPT) { + op = SRT_Except; + } else { + Debug.Assert(p.op == TK_UNION); + op = SRT_Union; + } + p.pPrior = null; + pLimit = p.pLimit; + p.pLimit = null; + pOffset = p.pOffset; + p.pOffset = null; + uniondest.eDest = op; + explainSetInteger(ref iSub2, pParse.iNextSelectId); + rc = sqlite3Select(pParse, p, ref uniondest); + testcase(rc != SQLITE_OK); + /* Query flattening in sqlite3Select() might refill p.pOrderBy. + ** Be sure to delete p.pOrderBy, therefore, to avoid a memory leak. */ + sqlite3ExprListDelete(db, ref p.pOrderBy); + pDelete = p.pPrior; + p.pPrior = pPrior; + p.pOrderBy = null; + if (p.op == TK_UNION) + p.nSelectRow += pPrior.nSelectRow; + sqlite3ExprDelete(db, ref p.pLimit); + p.pLimit = pLimit; + p.pOffset = pOffset; + p.iLimit = 0; + p.iOffset = 0; + + /* Convert the data in the temporary table into whatever form + ** it is that we currently need. + */ + Debug.Assert(unionTab == dest.iParm || dest.eDest != priorOp); + if (dest.eDest != priorOp) { + int iCont, iBreak, iStart; + Debug.Assert(p.pEList != null); + if (dest.eDest == SRT_Output) { + Select pFirst = p; + while (pFirst.pPrior != null) + pFirst = pFirst.pPrior; + generateColumnNames(pParse, null, pFirst.pEList); + } + iBreak = sqlite3VdbeMakeLabel(v); + iCont = sqlite3VdbeMakeLabel(v); + computeLimitRegisters(pParse, p, iBreak); + sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak); + iStart = sqlite3VdbeCurrentAddr(v); + selectInnerLoop(pParse, p, p.pEList, unionTab, p.pEList.nExpr, + null, -1, dest, iCont, iBreak); + sqlite3VdbeResolveLabel(v, iCont); + sqlite3VdbeAddOp2(v, OP_Next, unionTab, iStart); + sqlite3VdbeResolveLabel(v, iBreak); + sqlite3VdbeAddOp2(v, OP_Close, unionTab, 0); + } + break; + } + default: + Debug.Assert(p.op == TK_INTERSECT); { + int tab1, tab2; + int iCont, iBreak, iStart; + Expr pLimit, pOffset; + int addr; + SelectDest intersectdest = new SelectDest(); + int r1; + + /* INTERSECT is different from the others since it requires + ** two temporary tables. Hence it has its own case. Begin + ** by allocating the tables we will need. + */ + tab1 = pParse.nTab++; + tab2 = pParse.nTab++; + Debug.Assert(p.pOrderBy == null); + + addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab1, 0); + Debug.Assert(p.addrOpenEphm[0] == -1); + p.addrOpenEphm[0] = addr; + p.pRightmost.selFlags |= SF_UsesEphemeral; + Debug.Assert(p.pEList != null); + + /* Code the SELECTs to our left into temporary table "tab1". + */ + sqlite3SelectDestInit(intersectdest, SRT_Union, tab1); + explainSetInteger(ref iSub1, pParse.iNextSelectId); + rc = sqlite3Select(pParse, pPrior, ref intersectdest); + if (rc != 0) { + goto multi_select_end; + } + + /* Code the current SELECT into temporary table "tab2" + */ + addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab2, 0); + Debug.Assert(p.addrOpenEphm[1] == -1); + p.addrOpenEphm[1] = addr; + p.pPrior = null; + pLimit = p.pLimit; + p.pLimit = null; + pOffset = p.pOffset; + p.pOffset = null; + intersectdest.iParm = tab2; + explainSetInteger(ref iSub2, pParse.iNextSelectId); + rc = sqlite3Select(pParse, p, ref intersectdest); + testcase(rc != SQLITE_OK); + p.pPrior = pPrior; + if (p.nSelectRow > pPrior.nSelectRow) + p.nSelectRow = pPrior.nSelectRow; + sqlite3ExprDelete(db, ref p.pLimit); + p.pLimit = pLimit; + p.pOffset = pOffset; + + /* Generate code to take the intersection of the two temporary + ** tables. + */ + Debug.Assert(p.pEList != null); + if (dest.eDest == SRT_Output) { + Select pFirst = p; + while (pFirst.pPrior != null) + pFirst = pFirst.pPrior; + generateColumnNames(pParse, null, pFirst.pEList); + } + iBreak = sqlite3VdbeMakeLabel(v); + iCont = sqlite3VdbeMakeLabel(v); + computeLimitRegisters(pParse, p, iBreak); + sqlite3VdbeAddOp2(v, OP_Rewind, tab1, iBreak); + r1 = sqlite3GetTempReg(pParse); + iStart = sqlite3VdbeAddOp2(v, OP_RowKey, tab1, r1); + sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0); + sqlite3ReleaseTempReg(pParse, r1); + selectInnerLoop(pParse, p, p.pEList, tab1, p.pEList.nExpr, + null, -1, dest, iCont, iBreak); + sqlite3VdbeResolveLabel(v, iCont); + sqlite3VdbeAddOp2(v, OP_Next, tab1, iStart); + sqlite3VdbeResolveLabel(v, iBreak); + sqlite3VdbeAddOp2(v, OP_Close, tab2, 0); + sqlite3VdbeAddOp2(v, OP_Close, tab1, 0); + break; + } + } - addr = sqlite3VdbeAddOp2( v, OP_OpenEphemeral, tab1, 0 ); - Debug.Assert( p.addrOpenEphm[0] == -1 ); - p.addrOpenEphm[0] = addr; - p.pRightmost.selFlags |= SF_UsesEphemeral; - Debug.Assert( p.pEList != null ); + explainComposite(pParse, p.op, iSub1, iSub2, p.op != TK_ALL); - /* Code the SELECTs to our left into temporary table "tab1". + /* Compute collating sequences used by + ** temporary tables needed to implement the compound select. + ** Attach the KeyInfo structure to all temporary tables. + ** + ** This section is run by the right-most SELECT statement only. + ** SELECT statements to the left always skip this part. The right-most + ** SELECT might also skip this part if it has no ORDER BY clause and + ** no temp tables are required. */ - sqlite3SelectDestInit( intersectdest, SRT_Union, tab1 ); - explainSetInteger( ref iSub1, pParse.iNextSelectId ); - rc = sqlite3Select( pParse, pPrior, ref intersectdest ); - if ( rc != 0 ) - { - goto multi_select_end; - } + if ((p.selFlags & SF_UsesEphemeral) != 0) { + int i; /* Loop counter */ + KeyInfo pKeyInfo; /* Collating sequence for the result set */ + Select pLoop; /* For looping through SELECT statements */ + CollSeq apColl; /* For looping through pKeyInfo.aColl[] */ + int nCol; /* Number of columns in result set */ + + Debug.Assert(p.pRightmost == p); + nCol = p.pEList.nExpr; + pKeyInfo = new KeyInfo(); //sqlite3DbMallocZero(db, + pKeyInfo.aColl = new CollSeq[nCol]; //sizeof(*pKeyInfo)+nCol*(CollSeq*.Length + 1)); + //if ( pKeyInfo == null ) + //{ + // rc = SQLITE_NOMEM; + // goto multi_select_end; + //} + + pKeyInfo.enc = db.aDbStatic[0].pSchema.enc;// ENC( pParse.db ); + pKeyInfo.nField = (u16)nCol; + + for (i = 0; i < nCol; i++) {//, apColl++){ + apColl = multiSelectCollSeq(pParse, p, i); + if (null == apColl) { + apColl = db.pDfltColl; + } + pKeyInfo.aColl[i] = apColl; + } - /* Code the current SELECT into temporary table "tab2" - */ - addr = sqlite3VdbeAddOp2( v, OP_OpenEphemeral, tab2, 0 ); - Debug.Assert( p.addrOpenEphm[1] == -1 ); - p.addrOpenEphm[1] = addr; - p.pPrior = null; - pLimit = p.pLimit; - p.pLimit = null; - pOffset = p.pOffset; - p.pOffset = null; - intersectdest.iParm = tab2; - explainSetInteger( ref iSub2, pParse.iNextSelectId ); - rc = sqlite3Select( pParse, p, ref intersectdest ); - testcase( rc != SQLITE_OK ); - p.pPrior = pPrior; - if ( p.nSelectRow > pPrior.nSelectRow ) - p.nSelectRow = pPrior.nSelectRow; - sqlite3ExprDelete( db, ref p.pLimit ); - p.pLimit = pLimit; - p.pOffset = pOffset; - - /* Generate code to take the intersection of the two temporary - ** tables. - */ - Debug.Assert( p.pEList != null ); - if ( dest.eDest == SRT_Output ) - { - Select pFirst = p; - while ( pFirst.pPrior != null ) - pFirst = pFirst.pPrior; - generateColumnNames( pParse, null, pFirst.pEList ); + for (pLoop = p; pLoop != null; pLoop = pLoop.pPrior) { + for (i = 0; i < 2; i++) { + int addr = pLoop.addrOpenEphm[i]; + if (addr < 0) { + /* If [0] is unused then [1] is also unused. So we can + ** always safely abort as soon as the first unused slot is found */ + Debug.Assert(pLoop.addrOpenEphm[1] < 0); + break; + } + sqlite3VdbeChangeP2(v, addr, nCol); + sqlite3VdbeChangeP4(v, addr, pKeyInfo, P4_KEYINFO); + pLoop.addrOpenEphm[i] = -1; + } + } + sqlite3DbFree(db, ref pKeyInfo); } - iBreak = sqlite3VdbeMakeLabel( v ); - iCont = sqlite3VdbeMakeLabel( v ); - computeLimitRegisters( pParse, p, iBreak ); - sqlite3VdbeAddOp2( v, OP_Rewind, tab1, iBreak ); - r1 = sqlite3GetTempReg( pParse ); - iStart = sqlite3VdbeAddOp2( v, OP_RowKey, tab1, r1 ); - sqlite3VdbeAddOp4Int( v, OP_NotFound, tab2, iCont, r1, 0 ); - sqlite3ReleaseTempReg( pParse, r1 ); - selectInnerLoop( pParse, p, p.pEList, tab1, p.pEList.nExpr, - null, -1, dest, iCont, iBreak ); - sqlite3VdbeResolveLabel( v, iCont ); - sqlite3VdbeAddOp2( v, OP_Next, tab1, iStart ); - sqlite3VdbeResolveLabel( v, iBreak ); - sqlite3VdbeAddOp2( v, OP_Close, tab2, 0 ); - sqlite3VdbeAddOp2( v, OP_Close, tab1, 0 ); - break; - } - } - - explainComposite( pParse, p.op, iSub1, iSub2, p.op != TK_ALL ); - - /* Compute collating sequences used by - ** temporary tables needed to implement the compound select. - ** Attach the KeyInfo structure to all temporary tables. - ** - ** This section is run by the right-most SELECT statement only. - ** SELECT statements to the left always skip this part. The right-most - ** SELECT might also skip this part if it has no ORDER BY clause and - ** no temp tables are required. - */ - if ( ( p.selFlags & SF_UsesEphemeral ) != 0 ) - { - int i; /* Loop counter */ - KeyInfo pKeyInfo; /* Collating sequence for the result set */ - Select pLoop; /* For looping through SELECT statements */ - CollSeq apColl; /* For looping through pKeyInfo.aColl[] */ - int nCol; /* Number of columns in result set */ - - Debug.Assert( p.pRightmost == p ); - nCol = p.pEList.nExpr; - pKeyInfo = new KeyInfo(); //sqlite3DbMallocZero(db, - pKeyInfo.aColl = new CollSeq[nCol]; //sizeof(*pKeyInfo)+nCol*(CollSeq*.Length + 1)); - //if ( pKeyInfo == null ) - //{ - // rc = SQLITE_NOMEM; - // goto multi_select_end; - //} - - pKeyInfo.enc = db.aDbStatic[0].pSchema.enc;// ENC( pParse.db ); - pKeyInfo.nField = (u16)nCol; - - for ( i = 0; i < nCol; i++ ) - {//, apColl++){ - apColl = multiSelectCollSeq( pParse, p, i ); - if ( null == apColl ) - { - apColl = db.pDfltColl; - } - pKeyInfo.aColl[i] = apColl; - } - for ( pLoop = p; pLoop != null; pLoop = pLoop.pPrior ) - { - for ( i = 0; i < 2; i++ ) - { - int addr = pLoop.addrOpenEphm[i]; - if ( addr < 0 ) - { - /* If [0] is unused then [1] is also unused. So we can - ** always safely abort as soon as the first unused slot is found */ - Debug.Assert( pLoop.addrOpenEphm[1] < 0 ); - break; - } - sqlite3VdbeChangeP2( v, addr, nCol ); - sqlite3VdbeChangeP4( v, addr, pKeyInfo, P4_KEYINFO ); - pLoop.addrOpenEphm[i] = -1; - } + multi_select_end: + pDest.iMem = dest.iMem; + pDest.nMem = dest.nMem; + sqlite3SelectDelete(db, ref pDelete); + return rc; } - sqlite3DbFree( db, ref pKeyInfo ); - } - -multi_select_end: - pDest.iMem = dest.iMem; - pDest.nMem = dest.nMem; - sqlite3SelectDelete( db, ref pDelete ); - return rc; - } #endif // * SQLITE_OMIT_COMPOUND_SELECT */ - /* -** Code an output subroutine for a coroutine implementation of a -** SELECT statment. -** -** The data to be output is contained in pIn.iMem. There are -** pIn.nMem columns to be output. pDest is where the output should -** be sent. -** -** regReturn is the number of the register holding the subroutine -** return address. -** -** If regPrev>0 then it is the first register in a vector that -** records the previous output. mem[regPrev] is a flag that is false -** if there has been no previous output. If regPrev>0 then code is -** generated to suppress duplicates. pKeyInfo is used for comparing -** keys. -** -** If the LIMIT found in p.iLimit is reached, jump immediately to -** iBreak. -*/ - static int generateOutputSubroutine( - Parse pParse, /* Parsing context */ - Select p, /* The SELECT statement */ - SelectDest pIn, /* Coroutine supplying data */ - SelectDest pDest, /* Where to send the data */ - int regReturn, /* The return address register */ - int regPrev, /* Previous result register. No uniqueness if 0 */ - KeyInfo pKeyInfo, /* For comparing with previous entry */ - int p4type, /* The p4 type for pKeyInfo */ - int iBreak /* Jump here if we hit the LIMIT */ - ) - { - Vdbe v = pParse.pVdbe; - int iContinue; - int addr; - - addr = sqlite3VdbeCurrentAddr( v ); - iContinue = sqlite3VdbeMakeLabel( v ); - - /* Suppress duplicates for UNION, EXCEPT, and INTERSECT - */ - if ( regPrev != 0 ) - { - int j1, j2; - j1 = sqlite3VdbeAddOp1( v, OP_IfNot, regPrev ); - j2 = sqlite3VdbeAddOp4( v, OP_Compare, pIn.iMem, regPrev + 1, pIn.nMem, - pKeyInfo, p4type ); - sqlite3VdbeAddOp3( v, OP_Jump, j2 + 2, iContinue, j2 + 2 ); - sqlite3VdbeJumpHere( v, j1 ); - sqlite3ExprCodeCopy( pParse, pIn.iMem, regPrev + 1, pIn.nMem ); - sqlite3VdbeAddOp2( v, OP_Integer, 1, regPrev ); - } - //if ( pParse.db.mallocFailed != 0 ) return 0; - - /* Suppress the the first OFFSET entries if there is an OFFSET clause - */ - codeOffset( v, p, iContinue ); + /* + ** Code an output subroutine for a coroutine implementation of a + ** SELECT statment. + ** + ** The data to be output is contained in pIn.iMem. There are + ** pIn.nMem columns to be output. pDest is where the output should + ** be sent. + ** + ** regReturn is the number of the register holding the subroutine + ** return address. + ** + ** If regPrev>0 then it is the first register in a vector that + ** records the previous output. mem[regPrev] is a flag that is false + ** if there has been no previous output. If regPrev>0 then code is + ** generated to suppress duplicates. pKeyInfo is used for comparing + ** keys. + ** + ** If the LIMIT found in p.iLimit is reached, jump immediately to + ** iBreak. + */ + static int generateOutputSubroutine( + Parse pParse, /* Parsing context */ + Select p, /* The SELECT statement */ + SelectDest pIn, /* Coroutine supplying data */ + SelectDest pDest, /* Where to send the data */ + int regReturn, /* The return address register */ + int regPrev, /* Previous result register. No uniqueness if 0 */ + KeyInfo pKeyInfo, /* For comparing with previous entry */ + int p4type, /* The p4 type for pKeyInfo */ + int iBreak /* Jump here if we hit the LIMIT */ + ) { + Vdbe v = pParse.pVdbe; + int iContinue; + int addr; - switch ( pDest.eDest ) - { - /* Store the result as data using a unique key. - */ - case SRT_Table: - case SRT_EphemTab: - { - int r1 = sqlite3GetTempReg( pParse ); - int r2 = sqlite3GetTempReg( pParse ); - testcase( pDest.eDest == SRT_Table ); - testcase( pDest.eDest == SRT_EphemTab ); - sqlite3VdbeAddOp3( v, OP_MakeRecord, pIn.iMem, pIn.nMem, r1 ); - sqlite3VdbeAddOp2( v, OP_NewRowid, pDest.iParm, r2 ); - sqlite3VdbeAddOp3( v, OP_Insert, pDest.iParm, r1, r2 ); - sqlite3VdbeChangeP5( v, OPFLAG_APPEND ); - sqlite3ReleaseTempReg( pParse, r2 ); - sqlite3ReleaseTempReg( pParse, r1 ); - break; - } + addr = sqlite3VdbeCurrentAddr(v); + iContinue = sqlite3VdbeMakeLabel(v); + + /* Suppress duplicates for UNION, EXCEPT, and INTERSECT + */ + if (regPrev != 0) { + int j1, j2; + j1 = sqlite3VdbeAddOp1(v, OP_IfNot, regPrev); + j2 = sqlite3VdbeAddOp4(v, OP_Compare, pIn.iMem, regPrev + 1, pIn.nMem, + pKeyInfo, p4type); + sqlite3VdbeAddOp3(v, OP_Jump, j2 + 2, iContinue, j2 + 2); + sqlite3VdbeJumpHere(v, j1); + sqlite3ExprCodeCopy(pParse, pIn.iMem, regPrev + 1, pIn.nMem); + sqlite3VdbeAddOp2(v, OP_Integer, 1, regPrev); + } + //if ( pParse.db.mallocFailed != 0 ) return 0; + + /* Suppress the the first OFFSET entries if there is an OFFSET clause + */ + codeOffset(v, p, iContinue); + + switch (pDest.eDest) { + /* Store the result as data using a unique key. + */ + case SRT_Table: + case SRT_EphemTab: { + int r1 = sqlite3GetTempReg(pParse); + int r2 = sqlite3GetTempReg(pParse); + testcase(pDest.eDest == SRT_Table); + testcase(pDest.eDest == SRT_EphemTab); + sqlite3VdbeAddOp3(v, OP_MakeRecord, pIn.iMem, pIn.nMem, r1); + sqlite3VdbeAddOp2(v, OP_NewRowid, pDest.iParm, r2); + sqlite3VdbeAddOp3(v, OP_Insert, pDest.iParm, r1, r2); + sqlite3VdbeChangeP5(v, OPFLAG_APPEND); + sqlite3ReleaseTempReg(pParse, r2); + sqlite3ReleaseTempReg(pParse, r1); + break; + } #if !SQLITE_OMIT_SUBQUERY - /* If we are creating a set for an "expr IN (SELECT ...)" construct, -** then there should be a single item on the stack. Write this -** item into the set table with bogus data. -*/ - case SRT_Set: - { - int r1; - Debug.Assert( pIn.nMem == 1 ); - p.affinity = - sqlite3CompareAffinity( p.pEList.a[0].pExpr, pDest.affinity ); - r1 = sqlite3GetTempReg( pParse ); - sqlite3VdbeAddOp4( v, OP_MakeRecord, pIn.iMem, 1, r1, p.affinity, 1 ); - sqlite3ExprCacheAffinityChange( pParse, pIn.iMem, 1 ); - sqlite3VdbeAddOp2( v, OP_IdxInsert, pDest.iParm, r1 ); - sqlite3ReleaseTempReg( pParse, r1 ); - break; - } + /* If we are creating a set for an "expr IN (SELECT ...)" construct, + ** then there should be a single item on the stack. Write this + ** item into the set table with bogus data. + */ + case SRT_Set: { + int r1; + Debug.Assert(pIn.nMem == 1); + p.affinity = + sqlite3CompareAffinity(p.pEList.a[0].pExpr, pDest.affinity); + r1 = sqlite3GetTempReg(pParse); + sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn.iMem, 1, r1, p.affinity, 1); + sqlite3ExprCacheAffinityChange(pParse, pIn.iMem, 1); + sqlite3VdbeAddOp2(v, OP_IdxInsert, pDest.iParm, r1); + sqlite3ReleaseTempReg(pParse, r1); + break; + } #if FALSE //* Never occurs on an ORDER BY query */ /* If any row exist in the result set, record that fact and abort. @@ -2328,2846 +2101,2591 @@ static int generateOutputSubroutine( } #endif - /* If this is a scalar select that is part of an expression, then -** store the results in the appropriate memory cell and break out -** of the scan loop. -*/ - case SRT_Mem: - { - Debug.Assert( pIn.nMem == 1 ); - sqlite3ExprCodeMove( pParse, pIn.iMem, pDest.iParm, 1 ); - /* The LIMIT clause will jump out of the loop for us */ - break; - } + /* If this is a scalar select that is part of an expression, then + ** store the results in the appropriate memory cell and break out + ** of the scan loop. + */ + case SRT_Mem: { + Debug.Assert(pIn.nMem == 1); + sqlite3ExprCodeMove(pParse, pIn.iMem, pDest.iParm, 1); + /* The LIMIT clause will jump out of the loop for us */ + break; + } #endif //* #if !SQLITE_OMIT_SUBQUERY */ - /* The results are stored in a sequence of registers -** starting at pDest.iMem. Then the co-routine yields. -*/ - case SRT_Coroutine: - { - if ( pDest.iMem == 0 ) - { - pDest.iMem = sqlite3GetTempRange( pParse, pIn.nMem ); - pDest.nMem = pIn.nMem; - } - sqlite3ExprCodeMove( pParse, pIn.iMem, pDest.iMem, pDest.nMem ); - sqlite3VdbeAddOp1( v, OP_Yield, pDest.iParm ); - break; - } - - /* If none of the above, then the result destination must be - ** SRT_Output. This routine is never called with any other - ** destination other than the ones handled above or SRT_Output. - ** - ** For SRT_Output, results are stored in a sequence of registers. - ** Then the OP_ResultRow opcode is used to cause sqlite3_step() to - ** return the next row of result. + /* The results are stored in a sequence of registers + ** starting at pDest.iMem. Then the co-routine yields. */ - default: - { - Debug.Assert( pDest.eDest == SRT_Output ); - sqlite3VdbeAddOp2( v, OP_ResultRow, pIn.iMem, pIn.nMem ); - sqlite3ExprCacheAffinityChange( pParse, pIn.iMem, pIn.nMem ); - break; - } - } - - /* Jump to the end of the loop if the LIMIT is reached. - */ - if ( p.iLimit != 0 ) - { - sqlite3VdbeAddOp3( v, OP_IfZero, p.iLimit, iBreak, -1 ); - } + case SRT_Coroutine: { + if (pDest.iMem == 0) { + pDest.iMem = sqlite3GetTempRange(pParse, pIn.nMem); + pDest.nMem = pIn.nMem; + } + sqlite3ExprCodeMove(pParse, pIn.iMem, pDest.iMem, pDest.nMem); + sqlite3VdbeAddOp1(v, OP_Yield, pDest.iParm); + break; + } + + /* If none of the above, then the result destination must be + ** SRT_Output. This routine is never called with any other + ** destination other than the ones handled above or SRT_Output. + ** + ** For SRT_Output, results are stored in a sequence of registers. + ** Then the OP_ResultRow opcode is used to cause sqlite3_step() to + ** return the next row of result. + */ + default: { + Debug.Assert(pDest.eDest == SRT_Output); + sqlite3VdbeAddOp2(v, OP_ResultRow, pIn.iMem, pIn.nMem); + sqlite3ExprCacheAffinityChange(pParse, pIn.iMem, pIn.nMem); + break; + } + } - /* Generate the subroutine return - */ - sqlite3VdbeResolveLabel( v, iContinue ); - sqlite3VdbeAddOp1( v, OP_Return, regReturn ); + /* Jump to the end of the loop if the LIMIT is reached. + */ + if (p.iLimit != 0) { + sqlite3VdbeAddOp3(v, OP_IfZero, p.iLimit, iBreak, -1); + } - return addr; - } + /* Generate the subroutine return + */ + sqlite3VdbeResolveLabel(v, iContinue); + sqlite3VdbeAddOp1(v, OP_Return, regReturn); - /* - ** Alternative compound select code generator for cases when there - ** is an ORDER BY clause. - ** - ** We assume a query of the following form: - ** - ** ORDER BY - ** - ** is one of UNION ALL, UNION, EXCEPT, or INTERSECT. The idea - ** is to code both and with the ORDER BY clause as - ** co-routines. Then run the co-routines in parallel and merge the results - ** into the output. In addition to the two coroutines (called selectA and - ** selectB) there are 7 subroutines: - ** - ** outA: Move the output of the selectA coroutine into the output - ** of the compound query. - ** - ** outB: Move the output of the selectB coroutine into the output - ** of the compound query. (Only generated for UNION and - ** UNION ALL. EXCEPT and INSERTSECT never output a row that - ** appears only in B.) - ** - ** AltB: Called when there is data from both coroutines and AB. - ** - ** EofA: Called when data is exhausted from selectA. - ** - ** EofB: Called when data is exhausted from selectB. - ** - ** The implementation of the latter five subroutines depend on which - ** is used: - ** - ** - ** UNION ALL UNION EXCEPT INTERSECT - ** ------------- ----------------- -------------- ----------------- - ** AltB: outA, nextA outA, nextA outA, nextA nextA - ** - ** AeqB: outA, nextA nextA nextA outA, nextA - ** - ** AgtB: outB, nextB outB, nextB nextB nextB - ** - ** EofA: outB, nextB outB, nextB halt halt - ** - ** EofB: outA, nextA outA, nextA outA, nextA halt - ** - ** In the AltB, AeqB, and AgtB subroutines, an EOF on A following nextA - ** causes an immediate jump to EofA and an EOF on B following nextB causes - ** an immediate jump to EofB. Within EofA and EofB, and EOF on entry or - ** following nextX causes a jump to the end of the select processing. - ** - ** Duplicate removal in the UNION, EXCEPT, and INTERSECT cases is handled - ** within the output subroutine. The regPrev register set holds the previously - ** output value. A comparison is made against this value and the output - ** is skipped if the next results would be the same as the previous. - ** - ** The implementation plan is to implement the two coroutines and seven - ** subroutines first, then put the control logic at the bottom. Like this: - ** - ** goto Init - ** coA: coroutine for left query (A) - ** coB: coroutine for right query (B) - ** outA: output one row of A - ** outB: output one row of B (UNION and UNION ALL only) - ** EofA: ... - ** EofB: ... - ** AltB: ... - ** AeqB: ... - ** AgtB: ... - ** Init: initialize coroutine registers - ** yield coA - ** if eof(A) goto EofA - ** yield coB - ** if eof(B) goto EofB - ** Cmpr: Compare A, B - ** Jump AltB, AeqB, AgtB - ** End: ... - ** - ** We call AltB, AeqB, AgtB, EofA, and EofB "subroutines" but they are not - ** actually called using Gosub and they do not Return. EofA and EofB loop - ** until all data is exhausted then jump to the "end" labe. AltB, AeqB, - ** and AgtB jump to either L2 or to one of EofA or EofB. - */ + return addr; + } + + /* + ** Alternative compound select code generator for cases when there + ** is an ORDER BY clause. + ** + ** We assume a query of the following form: + ** + ** ORDER BY + ** + ** is one of UNION ALL, UNION, EXCEPT, or INTERSECT. The idea + ** is to code both and with the ORDER BY clause as + ** co-routines. Then run the co-routines in parallel and merge the results + ** into the output. In addition to the two coroutines (called selectA and + ** selectB) there are 7 subroutines: + ** + ** outA: Move the output of the selectA coroutine into the output + ** of the compound query. + ** + ** outB: Move the output of the selectB coroutine into the output + ** of the compound query. (Only generated for UNION and + ** UNION ALL. EXCEPT and INSERTSECT never output a row that + ** appears only in B.) + ** + ** AltB: Called when there is data from both coroutines and AB. + ** + ** EofA: Called when data is exhausted from selectA. + ** + ** EofB: Called when data is exhausted from selectB. + ** + ** The implementation of the latter five subroutines depend on which + ** is used: + ** + ** + ** UNION ALL UNION EXCEPT INTERSECT + ** ------------- ----------------- -------------- ----------------- + ** AltB: outA, nextA outA, nextA outA, nextA nextA + ** + ** AeqB: outA, nextA nextA nextA outA, nextA + ** + ** AgtB: outB, nextB outB, nextB nextB nextB + ** + ** EofA: outB, nextB outB, nextB halt halt + ** + ** EofB: outA, nextA outA, nextA outA, nextA halt + ** + ** In the AltB, AeqB, and AgtB subroutines, an EOF on A following nextA + ** causes an immediate jump to EofA and an EOF on B following nextB causes + ** an immediate jump to EofB. Within EofA and EofB, and EOF on entry or + ** following nextX causes a jump to the end of the select processing. + ** + ** Duplicate removal in the UNION, EXCEPT, and INTERSECT cases is handled + ** within the output subroutine. The regPrev register set holds the previously + ** output value. A comparison is made against this value and the output + ** is skipped if the next results would be the same as the previous. + ** + ** The implementation plan is to implement the two coroutines and seven + ** subroutines first, then put the control logic at the bottom. Like this: + ** + ** goto Init + ** coA: coroutine for left query (A) + ** coB: coroutine for right query (B) + ** outA: output one row of A + ** outB: output one row of B (UNION and UNION ALL only) + ** EofA: ... + ** EofB: ... + ** AltB: ... + ** AeqB: ... + ** AgtB: ... + ** Init: initialize coroutine registers + ** yield coA + ** if eof(A) goto EofA + ** yield coB + ** if eof(B) goto EofB + ** Cmpr: Compare A, B + ** Jump AltB, AeqB, AgtB + ** End: ... + ** + ** We call AltB, AeqB, AgtB, EofA, and EofB "subroutines" but they are not + ** actually called using Gosub and they do not Return. EofA and EofB loop + ** until all data is exhausted then jump to the "end" labe. AltB, AeqB, + ** and AgtB jump to either L2 or to one of EofA or EofB. + */ #if !SQLITE_OMIT_COMPOUND_SELECT - static int multiSelectOrderBy( - Parse pParse, /* Parsing context */ - Select p, /* The right-most of SELECTs to be coded */ - SelectDest pDest /* What to do with query results */ - ) - { - int i, j; /* Loop counters */ - Select pPrior; /* Another SELECT immediately to our left */ - Vdbe v; /* Generate code to this VDBE */ - SelectDest destA = new SelectDest(); /* Destination for coroutine A */ - SelectDest destB = new SelectDest(); /* Destination for coroutine B */ - int regAddrA; /* Address register for select-A coroutine */ - int regEofA; /* Flag to indicate when select-A is complete */ - int regAddrB; /* Address register for select-B coroutine */ - int regEofB; /* Flag to indicate when select-B is complete */ - int addrSelectA; /* Address of the select-A coroutine */ - int addrSelectB; /* Address of the select-B coroutine */ - int regOutA; /* Address register for the output-A subroutine */ - int regOutB; /* Address register for the output-B subroutine */ - int addrOutA; /* Address of the output-A subroutine */ - int addrOutB = 0; /* Address of the output-B subroutine */ - int addrEofA; /* Address of the select-A-exhausted subroutine */ - int addrEofB; /* Address of the select-B-exhausted subroutine */ - int addrAltB; /* Address of the AB subroutine */ - int regLimitA; /* Limit register for select-A */ - int regLimitB; /* Limit register for select-A */ - int regPrev; /* A range of registers to hold previous output */ - int savedLimit; /* Saved value of p.iLimit */ - int savedOffset; /* Saved value of p.iOffset */ - int labelCmpr; /* Label for the start of the merge algorithm */ - int labelEnd; /* Label for the end of the overall SELECT stmt */ - int j1; /* Jump instructions that get retargetted */ - int op; /* One of TK_ALL, TK_UNION, TK_EXCEPT, TK_INTERSECT */ - KeyInfo pKeyDup = null; /* Comparison information for duplicate removal */ - KeyInfo pKeyMerge; /* Comparison information for merging rows */ - sqlite3 db; /* Database connection */ - ExprList pOrderBy; /* The ORDER BY clause */ - int nOrderBy; /* Number of terms in the ORDER BY clause */ - int[] aPermute; /* Mapping from ORDER BY terms to result set columns */ + static int multiSelectOrderBy( + Parse pParse, /* Parsing context */ + Select p, /* The right-most of SELECTs to be coded */ + SelectDest pDest /* What to do with query results */ + ) { + int i, j; /* Loop counters */ + Select pPrior; /* Another SELECT immediately to our left */ + Vdbe v; /* Generate code to this VDBE */ + SelectDest destA = new SelectDest(); /* Destination for coroutine A */ + SelectDest destB = new SelectDest(); /* Destination for coroutine B */ + int regAddrA; /* Address register for select-A coroutine */ + int regEofA; /* Flag to indicate when select-A is complete */ + int regAddrB; /* Address register for select-B coroutine */ + int regEofB; /* Flag to indicate when select-B is complete */ + int addrSelectA; /* Address of the select-A coroutine */ + int addrSelectB; /* Address of the select-B coroutine */ + int regOutA; /* Address register for the output-A subroutine */ + int regOutB; /* Address register for the output-B subroutine */ + int addrOutA; /* Address of the output-A subroutine */ + int addrOutB = 0; /* Address of the output-B subroutine */ + int addrEofA; /* Address of the select-A-exhausted subroutine */ + int addrEofB; /* Address of the select-B-exhausted subroutine */ + int addrAltB; /* Address of the AB subroutine */ + int regLimitA; /* Limit register for select-A */ + int regLimitB; /* Limit register for select-A */ + int regPrev; /* A range of registers to hold previous output */ + int savedLimit; /* Saved value of p.iLimit */ + int savedOffset; /* Saved value of p.iOffset */ + int labelCmpr; /* Label for the start of the merge algorithm */ + int labelEnd; /* Label for the end of the overall SELECT stmt */ + int j1; /* Jump instructions that get retargetted */ + int op; /* One of TK_ALL, TK_UNION, TK_EXCEPT, TK_INTERSECT */ + KeyInfo pKeyDup = null; /* Comparison information for duplicate removal */ + KeyInfo pKeyMerge; /* Comparison information for merging rows */ + sqlite3 db; /* Database connection */ + ExprList pOrderBy; /* The ORDER BY clause */ + int nOrderBy; /* Number of terms in the ORDER BY clause */ + int[] aPermute; /* Mapping from ORDER BY terms to result set columns */ #if !SQLITE_OMIT_EXPLAIN - int iSub1 = 0; /* EQP id of left-hand query */ - int iSub2 = 0; /* EQP id of right-hand query */ + int iSub1 = 0; /* EQP id of left-hand query */ + int iSub2 = 0; /* EQP id of right-hand query */ #endif - Debug.Assert( p.pOrderBy != null ); - Debug.Assert( pKeyDup == null ); /* "Managed" code needs this. Ticket #3382. */ - db = pParse.db; - v = pParse.pVdbe; - Debug.Assert( v != null ); /* Already thrown the error if VDBE alloc failed */ - labelEnd = sqlite3VdbeMakeLabel( v ); - labelCmpr = sqlite3VdbeMakeLabel( v ); + Debug.Assert(p.pOrderBy != null); + Debug.Assert(pKeyDup == null); /* "Managed" code needs this. Ticket #3382. */ + db = pParse.db; + v = pParse.pVdbe; + Debug.Assert(v != null); /* Already thrown the error if VDBE alloc failed */ + labelEnd = sqlite3VdbeMakeLabel(v); + labelCmpr = sqlite3VdbeMakeLabel(v); - /* Patch up the ORDER BY clause - */ - op = p.op; - pPrior = p.pPrior; - Debug.Assert( pPrior.pOrderBy == null ); - pOrderBy = p.pOrderBy; - Debug.Assert( pOrderBy != null ); - nOrderBy = pOrderBy.nExpr; - - /* For operators other than UNION ALL we have to make sure that - ** the ORDER BY clause covers every term of the result set. Add - ** terms to the ORDER BY clause as necessary. - */ - if ( op != TK_ALL ) - { - for ( i = 1; /* db.mallocFailed == 0 && */ i <= p.pEList.nExpr; i++ ) - { - ExprList_item pItem; - for ( j = 0; j < nOrderBy; j++ )//, pItem++) - { - pItem = pOrderBy.a[j]; - Debug.Assert( pItem.iCol > 0 ); - if ( pItem.iCol == i ) - break; - } - if ( j == nOrderBy ) - { - Expr pNew = sqlite3Expr( db, TK_INTEGER, null ); - //if ( pNew == null ) - // return SQLITE_NOMEM; - pNew.flags |= EP_IntValue; - pNew.u.iValue = i; - pOrderBy = sqlite3ExprListAppend( pParse, pOrderBy, pNew ); - pOrderBy.a[nOrderBy++].iCol = (u16)i; - } - } - } - - /* Compute the comparison permutation and keyinfo that is used with - ** the permutation used to determine if the next - ** row of results comes from selectA or selectB. Also add explicit - ** collations to the ORDER BY clause terms so that when the subqueries - ** to the right and the left are evaluated, they use the correct - ** collation. - */ - aPermute = new int[nOrderBy];// sqlite3DbMallocRaw( db, sizeof( int ) * nOrderBy ); - if ( aPermute != null ) - { - ExprList_item pItem; - for ( i = 0; i < nOrderBy; i++ )//, pItem++) - { - pItem = pOrderBy.a[i]; - Debug.Assert( pItem.iCol > 0 && pItem.iCol <= p.pEList.nExpr ); - aPermute[i] = pItem.iCol - 1; - } - pKeyMerge = new KeyInfo();// sqlite3DbMallocRaw(db, sizeof(*pKeyMerge)+nOrderBy*(sizeof(CollSeq)+1)); - if ( pKeyMerge != null ) - { - pKeyMerge.aColl = new CollSeq[nOrderBy]; - pKeyMerge.aSortOrder = new byte[nOrderBy];//(u8)&pKeyMerge.aColl[nOrderBy]; - pKeyMerge.nField = (u16)nOrderBy; - pKeyMerge.enc = ENC( db ); - for ( i = 0; i < nOrderBy; i++ ) - { - CollSeq pColl; - Expr pTerm = pOrderBy.a[i].pExpr; - if ( ( pTerm.flags & EP_ExpCollate ) != 0 ) - { - pColl = pTerm.pColl; + /* Patch up the ORDER BY clause + */ + op = p.op; + pPrior = p.pPrior; + Debug.Assert(pPrior.pOrderBy == null); + pOrderBy = p.pOrderBy; + Debug.Assert(pOrderBy != null); + nOrderBy = pOrderBy.nExpr; + + /* For operators other than UNION ALL we have to make sure that + ** the ORDER BY clause covers every term of the result set. Add + ** terms to the ORDER BY clause as necessary. + */ + if (op != TK_ALL) { + for (i = 1; /* db.mallocFailed == 0 && */ i <= p.pEList.nExpr; i++) { + ExprList_item pItem; + for (j = 0; j < nOrderBy; j++)//, pItem++) + { + pItem = pOrderBy.a[j]; + Debug.Assert(pItem.iCol > 0); + if (pItem.iCol == i) + break; + } + if (j == nOrderBy) { + Expr pNew = sqlite3Expr(db, TK_INTEGER, null); + //if ( pNew == null ) + // return SQLITE_NOMEM; + pNew.flags |= EP_IntValue; + pNew.u.iValue = i; + pOrderBy = sqlite3ExprListAppend(pParse, pOrderBy, pNew); + pOrderBy.a[nOrderBy++].iCol = (u16)i; + } + } } - else - { - pColl = multiSelectCollSeq( pParse, p, aPermute[i] ); - pTerm.flags |= EP_ExpCollate; - pTerm.pColl = pColl; + + /* Compute the comparison permutation and keyinfo that is used with + ** the permutation used to determine if the next + ** row of results comes from selectA or selectB. Also add explicit + ** collations to the ORDER BY clause terms so that when the subqueries + ** to the right and the left are evaluated, they use the correct + ** collation. + */ + aPermute = new int[nOrderBy];// sqlite3DbMallocRaw( db, sizeof( int ) * nOrderBy ); + if (aPermute != null) { + ExprList_item pItem; + for (i = 0; i < nOrderBy; i++)//, pItem++) + { + pItem = pOrderBy.a[i]; + Debug.Assert(pItem.iCol > 0 && pItem.iCol <= p.pEList.nExpr); + aPermute[i] = pItem.iCol - 1; + } + pKeyMerge = new KeyInfo();// sqlite3DbMallocRaw(db, sizeof(*pKeyMerge)+nOrderBy*(sizeof(CollSeq)+1)); + if (pKeyMerge != null) { + pKeyMerge.aColl = new CollSeq[nOrderBy]; + pKeyMerge.aSortOrder = new byte[nOrderBy];//(u8)&pKeyMerge.aColl[nOrderBy]; + pKeyMerge.nField = (u16)nOrderBy; + pKeyMerge.enc = ENC(db); + for (i = 0; i < nOrderBy; i++) { + CollSeq pColl; + Expr pTerm = pOrderBy.a[i].pExpr; + if ((pTerm.flags & EP_ExpCollate) != 0) { + pColl = pTerm.pColl; + } else { + pColl = multiSelectCollSeq(pParse, p, aPermute[i]); + pTerm.flags |= EP_ExpCollate; + pTerm.pColl = pColl; + } + pKeyMerge.aColl[i] = pColl; + pKeyMerge.aSortOrder[i] = (byte)pOrderBy.a[i].sortOrder; + } + } + } else { + pKeyMerge = null; } - pKeyMerge.aColl[i] = pColl; - pKeyMerge.aSortOrder[i] = (byte)pOrderBy.a[i].sortOrder; - } - } - } - else - { - pKeyMerge = null; - } - /* Reattach the ORDER BY clause to the query. - */ - p.pOrderBy = pOrderBy; - pPrior.pOrderBy = sqlite3ExprListDup( pParse.db, pOrderBy, 0 ); + /* Reattach the ORDER BY clause to the query. + */ + p.pOrderBy = pOrderBy; + pPrior.pOrderBy = sqlite3ExprListDup(pParse.db, pOrderBy, 0); - /* Allocate a range of temporary registers and the KeyInfo needed - ** for the logic that removes duplicate result rows when the - ** operator is UNION, EXCEPT, or INTERSECT (but not UNION ALL). - */ - if ( op == TK_ALL ) - { - regPrev = 0; - } - else - { - int nExpr = p.pEList.nExpr; - Debug.Assert( nOrderBy >= nExpr /*|| db.mallocFailed != 0 */ ); - regPrev = sqlite3GetTempRange( pParse, nExpr + 1 ); - sqlite3VdbeAddOp2( v, OP_Integer, 0, regPrev ); - pKeyDup = new KeyInfo();//sqlite3DbMallocZero(db, - //sizeof(*pKeyDup) + nExpr*(sizeof(CollSeq)+1) ); - if ( pKeyDup != null ) - { - pKeyDup.aColl = new CollSeq[nExpr]; - pKeyDup.aSortOrder = new byte[nExpr];//(u8)&pKeyDup.aColl[nExpr]; - pKeyDup.nField = (u16)nExpr; - pKeyDup.enc = ENC( db ); - for ( i = 0; i < nExpr; i++ ) - { - pKeyDup.aColl[i] = multiSelectCollSeq( pParse, p, i ); - pKeyDup.aSortOrder[i] = 0; - } - } - } + /* Allocate a range of temporary registers and the KeyInfo needed + ** for the logic that removes duplicate result rows when the + ** operator is UNION, EXCEPT, or INTERSECT (but not UNION ALL). + */ + if (op == TK_ALL) { + regPrev = 0; + } else { + int nExpr = p.pEList.nExpr; + Debug.Assert(nOrderBy >= nExpr /*|| db.mallocFailed != 0 */ ); + regPrev = sqlite3GetTempRange(pParse, nExpr + 1); + sqlite3VdbeAddOp2(v, OP_Integer, 0, regPrev); + pKeyDup = new KeyInfo();//sqlite3DbMallocZero(db, + //sizeof(*pKeyDup) + nExpr*(sizeof(CollSeq)+1) ); + if (pKeyDup != null) { + pKeyDup.aColl = new CollSeq[nExpr]; + pKeyDup.aSortOrder = new byte[nExpr];//(u8)&pKeyDup.aColl[nExpr]; + pKeyDup.nField = (u16)nExpr; + pKeyDup.enc = ENC(db); + for (i = 0; i < nExpr; i++) { + pKeyDup.aColl[i] = multiSelectCollSeq(pParse, p, i); + pKeyDup.aSortOrder[i] = 0; + } + } + } - /* Separate the left and the right query from one another - */ - p.pPrior = null; - sqlite3ResolveOrderGroupBy( pParse, p, p.pOrderBy, "ORDER" ); - if ( pPrior.pPrior == null ) - { - sqlite3ResolveOrderGroupBy( pParse, pPrior, pPrior.pOrderBy, "ORDER" ); - } - - /* Compute the limit registers */ - computeLimitRegisters( pParse, p, labelEnd ); - if ( p.iLimit != 0 && op == TK_ALL ) - { - regLimitA = ++pParse.nMem; - regLimitB = ++pParse.nMem; - sqlite3VdbeAddOp2( v, OP_Copy, ( p.iOffset != 0 ) ? p.iOffset + 1 : p.iLimit, - regLimitA ); - sqlite3VdbeAddOp2( v, OP_Copy, regLimitA, regLimitB ); - } - else - { - regLimitA = regLimitB = 0; - } - sqlite3ExprDelete( db, ref p.pLimit ); - p.pLimit = null; - sqlite3ExprDelete( db, ref p.pOffset ); - p.pOffset = null; - - regAddrA = ++pParse.nMem; - regEofA = ++pParse.nMem; - regAddrB = ++pParse.nMem; - regEofB = ++pParse.nMem; - regOutA = ++pParse.nMem; - regOutB = ++pParse.nMem; - sqlite3SelectDestInit( destA, SRT_Coroutine, regAddrA ); - sqlite3SelectDestInit( destB, SRT_Coroutine, regAddrB ); - - /* Jump past the various subroutines and coroutines to the main - ** merge loop - */ - j1 = sqlite3VdbeAddOp0( v, OP_Goto ); - addrSelectA = sqlite3VdbeCurrentAddr( v ); + /* Separate the left and the right query from one another + */ + p.pPrior = null; + sqlite3ResolveOrderGroupBy(pParse, p, p.pOrderBy, "ORDER"); + if (pPrior.pPrior == null) { + sqlite3ResolveOrderGroupBy(pParse, pPrior, pPrior.pOrderBy, "ORDER"); + } + /* Compute the limit registers */ + computeLimitRegisters(pParse, p, labelEnd); + if (p.iLimit != 0 && op == TK_ALL) { + regLimitA = ++pParse.nMem; + regLimitB = ++pParse.nMem; + sqlite3VdbeAddOp2(v, OP_Copy, (p.iOffset != 0) ? p.iOffset + 1 : p.iLimit, + regLimitA); + sqlite3VdbeAddOp2(v, OP_Copy, regLimitA, regLimitB); + } else { + regLimitA = regLimitB = 0; + } + sqlite3ExprDelete(db, ref p.pLimit); + p.pLimit = null; + sqlite3ExprDelete(db, ref p.pOffset); + p.pOffset = null; - /* Generate a coroutine to evaluate the SELECT statement to the - ** left of the compound operator - the "A" select. - */ - VdbeNoopComment( v, "Begin coroutine for left SELECT" ); - pPrior.iLimit = regLimitA; - explainSetInteger( ref iSub1, pParse.iNextSelectId ); - sqlite3Select( pParse, pPrior, ref destA ); - sqlite3VdbeAddOp2( v, OP_Integer, 1, regEofA ); - sqlite3VdbeAddOp1( v, OP_Yield, regAddrA ); - VdbeNoopComment( v, "End coroutine for left SELECT" ); - - /* Generate a coroutine to evaluate the SELECT statement on - ** the right - the "B" select - */ - addrSelectB = sqlite3VdbeCurrentAddr( v ); - VdbeNoopComment( v, "Begin coroutine for right SELECT" ); - savedLimit = p.iLimit; - savedOffset = p.iOffset; - p.iLimit = regLimitB; - p.iOffset = 0; - explainSetInteger( ref iSub2, pParse.iNextSelectId ); - sqlite3Select( pParse, p, ref destB ); - p.iLimit = savedLimit; - p.iOffset = savedOffset; - sqlite3VdbeAddOp2( v, OP_Integer, 1, regEofB ); - sqlite3VdbeAddOp1( v, OP_Yield, regAddrB ); - VdbeNoopComment( v, "End coroutine for right SELECT" ); - - /* Generate a subroutine that outputs the current row of the A - ** select as the next output row of the compound select. - */ - VdbeNoopComment( v, "Output routine for A" ); - addrOutA = generateOutputSubroutine( pParse, - p, destA, pDest, regOutA, - regPrev, pKeyDup, P4_KEYINFO_HANDOFF, labelEnd ); + regAddrA = ++pParse.nMem; + regEofA = ++pParse.nMem; + regAddrB = ++pParse.nMem; + regEofB = ++pParse.nMem; + regOutA = ++pParse.nMem; + regOutB = ++pParse.nMem; + sqlite3SelectDestInit(destA, SRT_Coroutine, regAddrA); + sqlite3SelectDestInit(destB, SRT_Coroutine, regAddrB); + + /* Jump past the various subroutines and coroutines to the main + ** merge loop + */ + j1 = sqlite3VdbeAddOp0(v, OP_Goto); + addrSelectA = sqlite3VdbeCurrentAddr(v); - /* Generate a subroutine that outputs the current row of the B - ** select as the next output row of the compound select. - */ - if ( op == TK_ALL || op == TK_UNION ) - { - VdbeNoopComment( v, "Output routine for B" ); - addrOutB = generateOutputSubroutine( pParse, - p, destB, pDest, regOutB, - regPrev, pKeyDup, P4_KEYINFO_STATIC, labelEnd ); - } - - /* Generate a subroutine to run when the results from select A - ** are exhausted and only data in select B remains. - */ - VdbeNoopComment( v, "eof-A subroutine" ); - if ( op == TK_EXCEPT || op == TK_INTERSECT ) - { - addrEofA = sqlite3VdbeAddOp2( v, OP_Goto, 0, labelEnd ); - } - else - { - addrEofA = sqlite3VdbeAddOp2( v, OP_If, regEofB, labelEnd ); - sqlite3VdbeAddOp2( v, OP_Gosub, regOutB, addrOutB ); - sqlite3VdbeAddOp1( v, OP_Yield, regAddrB ); - sqlite3VdbeAddOp2( v, OP_Goto, 0, addrEofA ); - p.nSelectRow += pPrior.nSelectRow; - } - - /* Generate a subroutine to run when the results from select B - ** are exhausted and only data in select A remains. - */ - if ( op == TK_INTERSECT ) - { - addrEofB = addrEofA; - if ( p.nSelectRow > pPrior.nSelectRow ) - p.nSelectRow = pPrior.nSelectRow; - } - else - { - VdbeNoopComment( v, "eof-B subroutine" ); - addrEofB = sqlite3VdbeAddOp2( v, OP_If, regEofA, labelEnd ); - sqlite3VdbeAddOp2( v, OP_Gosub, regOutA, addrOutA ); - sqlite3VdbeAddOp1( v, OP_Yield, regAddrA ); - sqlite3VdbeAddOp2( v, OP_Goto, 0, addrEofB ); - } - - /* Generate code to handle the case of AB - */ - VdbeNoopComment( v, "A-gt-B subroutine" ); - addrAgtB = sqlite3VdbeCurrentAddr( v ); - if ( op == TK_ALL || op == TK_UNION ) - { - sqlite3VdbeAddOp2( v, OP_Gosub, regOutB, addrOutB ); - } - sqlite3VdbeAddOp1( v, OP_Yield, regAddrB ); - sqlite3VdbeAddOp2( v, OP_If, regEofB, addrEofB ); - sqlite3VdbeAddOp2( v, OP_Goto, 0, labelCmpr ); - - /* This code runs once to initialize everything. - */ - sqlite3VdbeJumpHere( v, j1 ); - sqlite3VdbeAddOp2( v, OP_Integer, 0, regEofA ); - sqlite3VdbeAddOp2( v, OP_Integer, 0, regEofB ); - sqlite3VdbeAddOp2( v, OP_Gosub, regAddrA, addrSelectA ); - sqlite3VdbeAddOp2( v, OP_Gosub, regAddrB, addrSelectB ); - sqlite3VdbeAddOp2( v, OP_If, regEofA, addrEofA ); - sqlite3VdbeAddOp2( v, OP_If, regEofB, addrEofB ); - - /* Implement the main merge loop - */ - sqlite3VdbeResolveLabel( v, labelCmpr ); - sqlite3VdbeAddOp4( v, OP_Permutation, 0, 0, 0, aPermute, P4_INTARRAY ); - sqlite3VdbeAddOp4( v, OP_Compare, destA.iMem, destB.iMem, nOrderBy, - pKeyMerge, P4_KEYINFO_HANDOFF ); - sqlite3VdbeAddOp3( v, OP_Jump, addrAltB, addrAeqB, addrAgtB ); + /* Generate a coroutine to evaluate the SELECT statement to the + ** left of the compound operator - the "A" select. + */ + VdbeNoopComment(v, "Begin coroutine for left SELECT"); + pPrior.iLimit = regLimitA; + explainSetInteger(ref iSub1, pParse.iNextSelectId); + sqlite3Select(pParse, pPrior, ref destA); + sqlite3VdbeAddOp2(v, OP_Integer, 1, regEofA); + sqlite3VdbeAddOp1(v, OP_Yield, regAddrA); + VdbeNoopComment(v, "End coroutine for left SELECT"); + + /* Generate a coroutine to evaluate the SELECT statement on + ** the right - the "B" select + */ + addrSelectB = sqlite3VdbeCurrentAddr(v); + VdbeNoopComment(v, "Begin coroutine for right SELECT"); + savedLimit = p.iLimit; + savedOffset = p.iOffset; + p.iLimit = regLimitB; + p.iOffset = 0; + explainSetInteger(ref iSub2, pParse.iNextSelectId); + sqlite3Select(pParse, p, ref destB); + p.iLimit = savedLimit; + p.iOffset = savedOffset; + sqlite3VdbeAddOp2(v, OP_Integer, 1, regEofB); + sqlite3VdbeAddOp1(v, OP_Yield, regAddrB); + VdbeNoopComment(v, "End coroutine for right SELECT"); + + /* Generate a subroutine that outputs the current row of the A + ** select as the next output row of the compound select. + */ + VdbeNoopComment(v, "Output routine for A"); + addrOutA = generateOutputSubroutine(pParse, + p, destA, pDest, regOutA, + regPrev, pKeyDup, P4_KEYINFO_HANDOFF, labelEnd); - /* Release temporary registers - */ - if ( regPrev != 0 ) - { - sqlite3ReleaseTempRange( pParse, regPrev, nOrderBy + 1 ); - } + /* Generate a subroutine that outputs the current row of the B + ** select as the next output row of the compound select. + */ + if (op == TK_ALL || op == TK_UNION) { + VdbeNoopComment(v, "Output routine for B"); + addrOutB = generateOutputSubroutine(pParse, + p, destB, pDest, regOutB, + regPrev, pKeyDup, P4_KEYINFO_STATIC, labelEnd); + } - /* Jump to the this point in order to terminate the query. - */ - sqlite3VdbeResolveLabel( v, labelEnd ); + /* Generate a subroutine to run when the results from select A + ** are exhausted and only data in select B remains. + */ + VdbeNoopComment(v, "eof-A subroutine"); + if (op == TK_EXCEPT || op == TK_INTERSECT) { + addrEofA = sqlite3VdbeAddOp2(v, OP_Goto, 0, labelEnd); + } else { + addrEofA = sqlite3VdbeAddOp2(v, OP_If, regEofB, labelEnd); + sqlite3VdbeAddOp2(v, OP_Gosub, regOutB, addrOutB); + sqlite3VdbeAddOp1(v, OP_Yield, regAddrB); + sqlite3VdbeAddOp2(v, OP_Goto, 0, addrEofA); + p.nSelectRow += pPrior.nSelectRow; + } - /* Set the number of output columns - */ - if ( pDest.eDest == SRT_Output ) - { - Select pFirst = pPrior; - while ( pFirst.pPrior != null ) - pFirst = pFirst.pPrior; - generateColumnNames( pParse, null, pFirst.pEList ); - } - - /* Reassembly the compound query so that it will be freed correctly - ** by the calling function */ - if ( p.pPrior != null ) - { - sqlite3SelectDelete( db, ref p.pPrior ); - } - p.pPrior = pPrior; - - /*** TBD: Insert subroutine calls to close cursors on incomplete - **** subqueries ****/ - explainComposite( pParse, p.op, iSub1, iSub2, false ); - return SQLITE_OK; - } -#endif -#if !(SQLITE_OMIT_SUBQUERY) || !(SQLITE_OMIT_VIEW) - /* Forward Declarations */ - //static void substExprList(sqlite3*, ExprList*, int, ExprList); - //static void substSelect(sqlite3*, Select *, int, ExprList ); - - /* - ** Scan through the expression pExpr. Replace every reference to - ** a column in table number iTable with a copy of the iColumn-th - ** entry in pEList. (But leave references to the ROWID column - ** unchanged.) - ** - ** This routine is part of the flattening procedure. A subquery - ** whose result set is defined by pEList appears as entry in the - ** FROM clause of a SELECT such that the VDBE cursor assigned to that - ** FORM clause entry is iTable. This routine make the necessary - ** changes to pExpr so that it refers directly to the source table - ** of the subquery rather the result set of the subquery. - */ - static Expr substExpr( - sqlite3 db, /* Report malloc errors to this connection */ - Expr pExpr, /* Expr in which substitution occurs */ - int iTable, /* Table to be substituted */ - ExprList pEList /* Substitute expressions */ - ) - { - if ( pExpr == null ) - return null; - if ( pExpr.op == TK_COLUMN && pExpr.iTable == iTable ) - { - if ( pExpr.iColumn < 0 ) - { - pExpr.op = TK_NULL; - } - else - { - Expr pNew; - Debug.Assert( pEList != null && pExpr.iColumn < pEList.nExpr ); - Debug.Assert( pExpr.pLeft == null && pExpr.pRight == null ); - pNew = sqlite3ExprDup( db, pEList.a[pExpr.iColumn].pExpr, 0 ); - if ( pExpr.pColl != null ) - { - pNew.pColl = pExpr.pColl; - } - sqlite3ExprDelete( db, ref pExpr ); - pExpr = pNew; - } - } - else - { - pExpr.pLeft = substExpr( db, pExpr.pLeft, iTable, pEList ); - pExpr.pRight = substExpr( db, pExpr.pRight, iTable, pEList ); - if ( ExprHasProperty( pExpr, EP_xIsSelect ) ) - { - substSelect( db, pExpr.x.pSelect, iTable, pEList ); - } - else - { - substExprList( db, pExpr.x.pList, iTable, pEList ); - } - } - return pExpr; - } + /* Generate a subroutine to run when the results from select B + ** are exhausted and only data in select A remains. + */ + if (op == TK_INTERSECT) { + addrEofB = addrEofA; + if (p.nSelectRow > pPrior.nSelectRow) + p.nSelectRow = pPrior.nSelectRow; + } else { + VdbeNoopComment(v, "eof-B subroutine"); + addrEofB = sqlite3VdbeAddOp2(v, OP_If, regEofA, labelEnd); + sqlite3VdbeAddOp2(v, OP_Gosub, regOutA, addrOutA); + sqlite3VdbeAddOp1(v, OP_Yield, regAddrA); + sqlite3VdbeAddOp2(v, OP_Goto, 0, addrEofB); + } - static void substExprList( - sqlite3 db, /* Report malloc errors here */ - ExprList pList, /* List to scan and in which to make substitutes */ - int iTable, /* Table to be substituted */ - ExprList pEList /* Substitute values */ - ) - { - int i; - if ( pList == null ) - return; - for ( i = 0; i < pList.nExpr; i++ ) - { - pList.a[i].pExpr = substExpr( db, pList.a[i].pExpr, iTable, pEList ); - } - } + /* Generate code to handle the case of AnSrc==0 */ - if ( ALWAYS( pSrc ) ) - { - for ( i = pSrc.nSrc; i > 0; i-- )//, pItem++ ) - { - pItem = pSrc.a[pSrc.nSrc - i]; - substSelect( db, pItem.pSelect, iTable, pEList ); - } - } - } -#endif //* !SQLITE_OMIT_SUBQUERY) || !SQLITE_OMIT_VIEW) */ + /* Generate code to handle the case of A==B + */ + if (op == TK_ALL) { + addrAeqB = addrAltB; + } else if (op == TK_INTERSECT) { + addrAeqB = addrAltB; + addrAltB++; + } else { + VdbeNoopComment(v, "A-eq-B subroutine"); + addrAeqB = + sqlite3VdbeAddOp1(v, OP_Yield, regAddrA); + sqlite3VdbeAddOp2(v, OP_If, regEofA, addrEofA); + sqlite3VdbeAddOp2(v, OP_Goto, 0, labelCmpr); + } -#if !(SQLITE_OMIT_SUBQUERY) || !(SQLITE_OMIT_VIEW) - /* -** This routine attempts to flatten subqueries in order to speed -** execution. It returns 1 if it makes changes and 0 if no flattening -** occurs. -** -** To understand the concept of flattening, consider the following -** query: -** -** SELECT a FROM (SELECT x+y AS a FROM t1 WHERE z<100) WHERE a>5 -** -** The default way of implementing this query is to execute the -** subquery first and store the results in a temporary table, then -** run the outer query on that temporary table. This requires two -** passes over the data. Furthermore, because the temporary table -** has no indices, the WHERE clause on the outer query cannot be -** optimized. -** -** This routine attempts to rewrite queries such as the above into -** a single flat select, like this: -** -** SELECT x+y AS a FROM t1 WHERE z<100 AND a>5 -** -** The code generated for this simpification gives the same result -** but only has to scan the data once. And because indices might -** exist on the table t1, a complete scan of the data might be -** avoided. -** -** Flattening is only attempted if all of the following are true: -** -** (1) The subquery and the outer query do not both use aggregates. -** -** (2) The subquery is not an aggregate or the outer query is not a join. -** -** (3) The subquery is not the right operand of a left outer join -** (Originally ticket #306. Strengthened by ticket #3300) -** -** (4) The subquery is not DISTINCT. -** -** (*) At one point restrictions (4) and (5) defined a subset of DISTINCT -** sub-queries that were excluded from this optimization. Restriction -** (4) has since been expanded to exclude all DISTINCT subqueries. -** -** (6) The subquery does not use aggregates or the outer query is not -** DISTINCT. -** -** (7) The subquery has a FROM clause. -** -** (8) The subquery does not use LIMIT or the outer query is not a join. -** -** (9) The subquery does not use LIMIT or the outer query does not use -** aggregates. -** -** (10) The subquery does not use aggregates or the outer query does not -** use LIMIT. -** -** (11) The subquery and the outer query do not both have ORDER BY clauses. -** -** (*) Not implemented. Subsumed into restriction (3). Was previously -** a separate restriction deriving from ticket #350. -** -** (13) The subquery and outer query do not both use LIMIT. -** -** (14) The subquery does not use OFFSET. -** -** (15) The outer query is not part of a compound select or the -** subquery does not have a LIMIT clause. -** (See ticket #2339 and ticket [02a8e81d44]). -** -** (16) The outer query is not an aggregate or the subquery does -** not contain ORDER BY. (Ticket #2942) This used to not matter -** until we introduced the group_concat() function. -** -** (17) The sub-query is not a compound select, or it is a UNION ALL -** compound clause made up entirely of non-aggregate queries, and -** the parent query: -** -** * is not itself part of a compound select, -** * is not an aggregate or DISTINCT query, and -** * has no other tables or sub-selects in the FROM clause. -** -** The parent and sub-query may contain WHERE clauses. Subject to -** rules (11), (13) and (14), they may also contain ORDER BY, -** LIMIT and OFFSET clauses. -** -** (18) If the sub-query is a compound select, then all terms of the -** ORDER by clause of the parent must be simple references to -** columns of the sub-query. -** -** (19) The subquery does not use LIMIT or the outer query does not -** have a WHERE clause. -** -** (20) If the sub-query is a compound select, then it must not use -** an ORDER BY clause. Ticket #3773. We could relax this constraint -** somewhat by saying that the terms of the ORDER BY clause must -** appear as unmodified result columns in the outer query. But -** have other optimizations in mind to deal with that case. -** -** (21) The subquery does not use LIMIT or the outer query is not -** DISTINCT. (See ticket [752e1646fc]). -** -** In this routine, the "p" parameter is a pointer to the outer query. -** The subquery is p.pSrc.a[iFrom]. isAgg is true if the outer query -** uses aggregates and subqueryIsAgg is true if the subquery uses aggregates. -** -** If flattening is not attempted, this routine is a no-op and returns 0. -** If flattening is attempted this routine returns 1. -** -** All of the expression analysis must occur on both the outer query and -** the subquery before this routine runs. -*/ - static int flattenSubquery( - Parse pParse, /* Parsing context */ - Select p, /* The parent or outer SELECT statement */ - int iFrom, /* Index in p.pSrc.a[] of the inner subquery */ - bool isAgg, /* True if outer SELECT uses aggregate functions */ - bool subqueryIsAgg /* True if the subquery uses aggregate functions */ - ) - { - string zSavedAuthContext = pParse.zAuthContext; - Select pParent; - Select pSub; /* The inner query or "subquery" */ - Select pSub1; /* Pointer to the rightmost select in sub-query */ - SrcList pSrc; /* The FROM clause of the outer query */ - SrcList pSubSrc; /* The FROM clause of the subquery */ - ExprList pList; /* The result set of the outer query */ - int iParent; /* VDBE cursor number of the pSub result set temp table */ - int i; /* Loop counter */ - Expr pWhere; /* The WHERE clause */ - SrcList_item pSubitem;/* The subquery */ - sqlite3 db = pParse.db; - - /* Check to see if flattening is permitted. Return 0 if not. - */ - Debug.Assert( p != null ); - Debug.Assert( p.pPrior == null ); /* Unable to flatten compound queries */ - if ( ( db.flags & SQLITE_QueryFlattener ) != 0 ) - return 0; - pSrc = p.pSrc; - Debug.Assert( pSrc != null && iFrom >= 0 && iFrom < pSrc.nSrc ); - pSubitem = pSrc.a[iFrom]; - iParent = pSubitem.iCursor; - pSub = pSubitem.pSelect; - Debug.Assert( pSub != null ); - if ( isAgg && subqueryIsAgg ) - return 0; /* Restriction (1) */ - if ( subqueryIsAgg && pSrc.nSrc > 1 ) - return 0; /* Restriction (2) */ - pSubSrc = pSub.pSrc; - Debug.Assert( pSubSrc != null ); - /* Prior to version 3.1.2, when LIMIT and OFFSET had to be simple constants, - ** not arbitrary expresssions, we allowed some combining of LIMIT and OFFSET - ** because they could be computed at compile-time. But when LIMIT and OFFSET - ** became arbitrary expressions, we were forced to add restrictions (13) - ** and (14). */ - if ( pSub.pLimit != null && p.pLimit != null ) - return 0; /* Restriction (13) */ - if ( pSub.pOffset != null ) - return 0; /* Restriction (14) */ - if ( p.pRightmost != null && pSub.pLimit != null ) - { - return 0; /* Restriction (15) */ - } - if ( pSubSrc.nSrc == 0 ) - return 0; /* Restriction (7) */ - if ( ( pSub.selFlags & SF_Distinct ) != 0 ) - return 0; /* Restriction (5) */ - if ( pSub.pLimit != null && ( pSrc.nSrc > 1 || isAgg ) ) - { - return 0; /* Restrictions (8)(9) */ - } - if ( ( p.selFlags & SF_Distinct ) != 0 && subqueryIsAgg ) - { - return 0; /* Restriction (6) */ - } - if ( p.pOrderBy != null && pSub.pOrderBy != null ) - { - return 0; /* Restriction (11) */ - } - if ( isAgg && pSub.pOrderBy != null ) - return 0; /* Restriction (16) */ - if ( pSub.pLimit != null && p.pWhere != null ) - return 0; /* Restriction (19) */ - if ( pSub.pLimit != null && ( p.selFlags & SF_Distinct ) != 0 ) - { - return 0; /* Restriction (21) */ - } - - /* OBSOLETE COMMENT 1: - ** Restriction 3: If the subquery is a join, make sure the subquery is - ** not used as the right operand of an outer join. Examples of why this - ** is not allowed: - ** - ** t1 LEFT OUTER JOIN (t2 JOIN t3) - ** - ** If we flatten the above, we would get - ** - ** (t1 LEFT OUTER JOIN t2) JOIN t3 - ** - ** which is not at all the same thing. - ** - ** OBSOLETE COMMENT 2: - ** Restriction 12: If the subquery is the right operand of a left outer - - /* Restriction 12: If the subquery is the right operand of a left outer - ** join, make sure the subquery has no WHERE clause. - ** An examples of why this is not allowed: - ** - ** t1 LEFT OUTER JOIN (SELECT * FROM t2 WHERE t2.x>0) - ** - ** If we flatten the above, we would get - ** - ** (t1 LEFT OUTER JOIN t2) WHERE t2.x>0 - ** - ** But the t2.x>0 test will always fail on a NULL row of t2, which - ** effectively converts the OUTER JOIN into an INNER JOIN. - ** - ** THIS OVERRIDES OBSOLETE COMMENTS 1 AND 2 ABOVE: - ** Ticket #3300 shows that flattening the right term of a LEFT JOIN - ** is fraught with danger. Best to avoid the whole thing. If the - ** subquery is the right term of a LEFT JOIN, then do not flatten. - */ - if ( ( pSubitem.jointype & JT_OUTER ) != 0 ) - { - return 0; - } - - /* Restriction 17: If the sub-query is a compound SELECT, then it must - ** use only the UNION ALL operator. And none of the simple select queries - ** that make up the compound SELECT are allowed to be aggregate or distinct - ** queries. - */ - if ( pSub.pPrior != null ) - { - if ( pSub.pOrderBy != null ) - { - return 0; /* Restriction 20 */ - } - if ( isAgg || ( p.selFlags & SF_Distinct ) != 0 || pSrc.nSrc != 1 ) - { - return 0; - } - for ( pSub1 = pSub; pSub1 != null; pSub1 = pSub1.pPrior ) - { - testcase( ( pSub1.selFlags & ( SF_Distinct | SF_Aggregate ) ) == SF_Distinct ); - testcase( ( pSub1.selFlags & ( SF_Distinct | SF_Aggregate ) ) == SF_Aggregate ); - if ( ( pSub1.selFlags & ( SF_Distinct | SF_Aggregate ) ) != 0 - || ( pSub1.pPrior != null && pSub1.op != TK_ALL ) - || NEVER( pSub1.pSrc == null ) || pSub1.pSrc.nSrc != 1 - ) - { - return 0; - } - } + /* Generate code to handle the case of A>B + */ + VdbeNoopComment(v, "A-gt-B subroutine"); + addrAgtB = sqlite3VdbeCurrentAddr(v); + if (op == TK_ALL || op == TK_UNION) { + sqlite3VdbeAddOp2(v, OP_Gosub, regOutB, addrOutB); + } + sqlite3VdbeAddOp1(v, OP_Yield, regAddrB); + sqlite3VdbeAddOp2(v, OP_If, regEofB, addrEofB); + sqlite3VdbeAddOp2(v, OP_Goto, 0, labelCmpr); - /* Restriction 18. */ - if ( p.pOrderBy != null ) - { - int ii; - for ( ii = 0; ii < p.pOrderBy.nExpr; ii++ ) - { - if ( p.pOrderBy.a[ii].iCol == 0 ) - return 0; - } - } - } - - /***** If we reach this point, flattening is permitted. *****/ - - /* Authorize the subquery */ - pParse.zAuthContext = pSubitem.zName; - sqlite3AuthCheck( pParse, SQLITE_SELECT, null, null, null ); - pParse.zAuthContext = zSavedAuthContext; - - /* If the sub-query is a compound SELECT statement, then (by restrictions - ** 17 and 18 above) it must be a UNION ALL and the parent query must - ** be of the form: - ** - ** SELECT FROM () - ** - ** followed by any ORDER BY, LIMIT and/or OFFSET clauses. This block - ** creates N-1 copies of the parent query without any ORDER BY, LIMIT or - ** OFFSET clauses and joins them to the left-hand-side of the original - ** using UNION ALL operators. In this case N is the number of simple - ** select statements in the compound sub-query. - ** - ** Example: - ** - ** SELECT a+1 FROM ( - ** SELECT x FROM tab - ** UNION ALL - ** SELECT y FROM tab - ** UNION ALL - ** SELECT abs(z*2) FROM tab2 - ** ) WHERE a!=5 ORDER BY 1 - ** - ** Transformed into: - ** - ** SELECT x+1 FROM tab WHERE x+1!=5 - ** UNION ALL - ** SELECT y+1 FROM tab WHERE y+1!=5 - ** UNION ALL - ** SELECT abs(z*2)+1 FROM tab2 WHERE abs(z*2)+1!=5 - ** ORDER BY 1 - ** - ** We call this the "compound-subquery flattening". - */ - for ( pSub = pSub.pPrior; pSub != null; pSub = pSub.pPrior ) - { - Select pNew; - ExprList pOrderBy = p.pOrderBy; - Expr pLimit = p.pLimit; - Select pPrior = p.pPrior; - p.pOrderBy = null; - p.pSrc = null; - p.pPrior = null; - p.pLimit = null; - pNew = sqlite3SelectDup( db, p, 0 ); - p.pLimit = pLimit; - p.pOrderBy = pOrderBy; - p.pSrc = pSrc; - p.op = TK_ALL; - p.pRightmost = null; - if ( pNew == null ) - { - pNew = pPrior; - } - else - { - pNew.pPrior = pPrior; - pNew.pRightmost = null; - } - p.pPrior = pNew; - // if ( db.mallocFailed != 0 ) return 1; - } + /* This code runs once to initialize everything. + */ + sqlite3VdbeJumpHere(v, j1); + sqlite3VdbeAddOp2(v, OP_Integer, 0, regEofA); + sqlite3VdbeAddOp2(v, OP_Integer, 0, regEofB); + sqlite3VdbeAddOp2(v, OP_Gosub, regAddrA, addrSelectA); + sqlite3VdbeAddOp2(v, OP_Gosub, regAddrB, addrSelectB); + sqlite3VdbeAddOp2(v, OP_If, regEofA, addrEofA); + sqlite3VdbeAddOp2(v, OP_If, regEofB, addrEofB); + + /* Implement the main merge loop + */ + sqlite3VdbeResolveLabel(v, labelCmpr); + sqlite3VdbeAddOp4(v, OP_Permutation, 0, 0, 0, aPermute, P4_INTARRAY); + sqlite3VdbeAddOp4(v, OP_Compare, destA.iMem, destB.iMem, nOrderBy, + pKeyMerge, P4_KEYINFO_HANDOFF); + sqlite3VdbeAddOp3(v, OP_Jump, addrAltB, addrAeqB, addrAgtB); - /* Begin flattening the iFrom-th entry of the FROM clause - ** in the outer query. - */ - pSub = pSub1 = pSubitem.pSelect; - /* Delete the transient table structure associated with the - ** subquery - */ + /* Release temporary registers + */ + if (regPrev != 0) { + sqlite3ReleaseTempRange(pParse, regPrev, nOrderBy + 1); + } - sqlite3DbFree( db, ref pSubitem.zDatabase ); - sqlite3DbFree( db, ref pSubitem.zName ); - sqlite3DbFree( db, ref pSubitem.zAlias ); - pSubitem.zDatabase = null; - pSubitem.zName = null; - pSubitem.zAlias = null; - pSubitem.pSelect = null; - /* Defer deleting the Table object associated with the - ** subquery until code generation is - ** complete, since there may still exist Expr.pTab entries that - ** refer to the subquery even after flattening. Ticket #3346. - ** - ** pSubitem->pTab is always non-NULL by test restrictions and tests above. - */ - if ( ALWAYS( pSubitem.pTab != null ) ) - { - Table pTabToDel = pSubitem.pTab; - if ( pTabToDel.nRef == 1 ) - { - Parse pToplevel = sqlite3ParseToplevel( pParse ); - pTabToDel.pNextZombie = pToplevel.pZombieTab; - pToplevel.pZombieTab = pTabToDel; - } - else - { - pTabToDel.nRef--; - } - pSubitem.pTab = null; - } - - /* The following loop runs once for each term in a compound-subquery - ** flattening (as described above). If we are doing a different kind - ** of flattening - a flattening other than a compound-subquery flattening - - ** then this loop only runs once. - ** - ** This loop moves all of the FROM elements of the subquery into the - ** the FROM clause of the outer query. Before doing this, remember - ** the cursor number for the original outer query FROM element in - ** iParent. The iParent cursor will never be used. Subsequent code - ** will scan expressions looking for iParent references and replace - ** those references with expressions that resolve to the subquery FROM - ** elements we are now copying in. - */ - for ( pParent = p; pParent != null; pParent = pParent.pPrior, pSub = pSub.pPrior ) - { - int nSubSrc; - u8 jointype = 0; - pSubSrc = pSub.pSrc; /* FROM clause of subquery */ - nSubSrc = pSubSrc.nSrc; /* Number of terms in subquery FROM clause */ - pSrc = pParent.pSrc; /* FROM clause of the outer query */ - - if ( pSrc != null ) - { - Debug.Assert( pParent == p ); /* First time through the loop */ - jointype = pSubitem.jointype; - } - else - { - Debug.Assert( pParent != p ); /* 2nd and subsequent times through the loop */ - pSrc = pParent.pSrc = sqlite3SrcListAppend( db, null, null, null ); - //if ( pSrc == null ) - //{ - // //Debug.Assert( db.mallocFailed != 0 ); - // break; - //} - } + /* Jump to the this point in order to terminate the query. + */ + sqlite3VdbeResolveLabel(v, labelEnd); - /* The subquery uses a single slot of the FROM clause of the outer - ** query. If the subquery has more than one element in its FROM clause, - ** then expand the outer query to make space for it to hold all elements - ** of the subquery. - ** - ** Example: - ** - ** SELECT * FROM tabA, (SELECT * FROM sub1, sub2), tabB; - ** - ** The outer query has 3 slots in its FROM clause. One slot of the - ** outer query (the middle slot) is used by the subquery. The next - ** block of code will expand the out query to 4 slots. The middle - ** slot is expanded to two slots in order to make space for the - ** two elements in the FROM clause of the subquery. - */ - if ( nSubSrc > 1 ) - { - pParent.pSrc = pSrc = sqlite3SrcListEnlarge( db, pSrc, nSubSrc - 1, iFrom + 1 ); - //if ( db.mallocFailed != 0 ) - //{ - // break; - //} - } + /* Set the number of output columns + */ + if (pDest.eDest == SRT_Output) { + Select pFirst = pPrior; + while (pFirst.pPrior != null) + pFirst = pFirst.pPrior; + generateColumnNames(pParse, null, pFirst.pEList); + } - /* Transfer the FROM clause terms from the subquery into the - ** outer query. - */ - for ( i = 0; i < nSubSrc; i++ ) - { - sqlite3IdListDelete( db, ref pSrc.a[i + iFrom].pUsing ); - pSrc.a[i + iFrom] = pSubSrc.a[i]; - pSubSrc.a[i] = new SrcList_item();//memset(pSubSrc.a[i], 0, sizeof(pSubSrc.a[i])); + /* Reassembly the compound query so that it will be freed correctly + ** by the calling function */ + if (p.pPrior != null) { + sqlite3SelectDelete(db, ref p.pPrior); + } + p.pPrior = pPrior; + + /*** TBD: Insert subroutine calls to close cursors on incomplete + **** subqueries ****/ + explainComposite(pParse, p.op, iSub1, iSub2, false); + return SQLITE_OK; } - pSubitem = pSrc.a[iFrom]; // Reset for C# - pSrc.a[iFrom].jointype = jointype; +#endif +#if !(SQLITE_OMIT_SUBQUERY) || !(SQLITE_OMIT_VIEW) + /* Forward Declarations */ + //static void substExprList(sqlite3*, ExprList*, int, ExprList); + //static void substSelect(sqlite3*, Select *, int, ExprList ); - /* Now begin substituting subquery result set expressions for - ** references to the iParent in the outer query. - ** - ** Example: - ** - ** SELECT a+5, b*10 FROM (SELECT x*3 AS a, y+10 AS b FROM t1) WHERE a>b; - ** \ \_____________ subquery __________/ / - ** \_____________________ outer query ______________________________/ + /* + ** Scan through the expression pExpr. Replace every reference to + ** a column in table number iTable with a copy of the iColumn-th + ** entry in pEList. (But leave references to the ROWID column + ** unchanged.) ** - ** We look at every expression in the outer query and every place we see - ** "a" we substitute "x*3" and every place we see "b" we substitute "y+10". + ** This routine is part of the flattening procedure. A subquery + ** whose result set is defined by pEList appears as entry in the + ** FROM clause of a SELECT such that the VDBE cursor assigned to that + ** FORM clause entry is iTable. This routine make the necessary + ** changes to pExpr so that it refers directly to the source table + ** of the subquery rather the result set of the subquery. */ - pList = pParent.pEList; - for ( i = 0; i < pList.nExpr; i++ ) - { - if ( pList.a[i].zName == null ) - { - string zSpan = pList.a[i].zSpan; - if ( ALWAYS( zSpan ) ) - { - pList.a[i].zName = zSpan;// sqlite3DbStrDup( db, zSpan ); + static Expr substExpr( + sqlite3 db, /* Report malloc errors to this connection */ + Expr pExpr, /* Expr in which substitution occurs */ + int iTable, /* Table to be substituted */ + ExprList pEList /* Substitute expressions */ + ) { + if (pExpr == null) + return null; + if (pExpr.op == TK_COLUMN && pExpr.iTable == iTable) { + if (pExpr.iColumn < 0) { + pExpr.op = TK_NULL; + } else { + Expr pNew; + Debug.Assert(pEList != null && pExpr.iColumn < pEList.nExpr); + Debug.Assert(pExpr.pLeft == null && pExpr.pRight == null); + pNew = sqlite3ExprDup(db, pEList.a[pExpr.iColumn].pExpr, 0); + if (pExpr.pColl != null) { + pNew.pColl = pExpr.pColl; + } + sqlite3ExprDelete(db, ref pExpr); + pExpr = pNew; + } + } else { + pExpr.pLeft = substExpr(db, pExpr.pLeft, iTable, pEList); + pExpr.pRight = substExpr(db, pExpr.pRight, iTable, pEList); + if (ExprHasProperty(pExpr, EP_xIsSelect)) { + substSelect(db, pExpr.x.pSelect, iTable, pEList); + } else { + substExprList(db, pExpr.x.pList, iTable, pEList); + } } - } + return pExpr; } - substExprList( db, pParent.pEList, iParent, pSub.pEList ); - if ( isAgg ) - { - substExprList( db, pParent.pGroupBy, iParent, pSub.pEList ); - pParent.pHaving = substExpr( db, pParent.pHaving, iParent, pSub.pEList ); - } - if ( pSub.pOrderBy != null ) - { - Debug.Assert( pParent.pOrderBy == null ); - pParent.pOrderBy = pSub.pOrderBy; - pSub.pOrderBy = null; - } - else if ( pParent.pOrderBy != null ) - { - substExprList( db, pParent.pOrderBy, iParent, pSub.pEList ); - } - if ( pSub.pWhere != null ) - { - pWhere = sqlite3ExprDup( db, pSub.pWhere, 0 ); - } - else - { - pWhere = null; - } - if ( subqueryIsAgg ) - { - Debug.Assert( pParent.pHaving == null ); - pParent.pHaving = pParent.pWhere; - pParent.pWhere = pWhere; - pParent.pHaving = substExpr( db, pParent.pHaving, iParent, pSub.pEList ); - pParent.pHaving = sqlite3ExprAnd( db, pParent.pHaving, - sqlite3ExprDup( db, pSub.pHaving, 0 ) ); - Debug.Assert( pParent.pGroupBy == null ); - pParent.pGroupBy = sqlite3ExprListDup( db, pSub.pGroupBy, 0 ); - } - else - { - pParent.pWhere = substExpr( db, pParent.pWhere, iParent, pSub.pEList ); - pParent.pWhere = sqlite3ExprAnd( db, pParent.pWhere, pWhere ); - } - - /* The flattened query is distinct if either the inner or the - ** outer query is distinct. - */ - pParent.selFlags = (u16)( pParent.selFlags | pSub.selFlags & SF_Distinct ); - /* - ** SELECT ... FROM (SELECT ... LIMIT a OFFSET b) LIMIT x OFFSET y; - ** - ** One is tempted to try to add a and b to combine the limits. But this - ** does not work if either limit is negative. - */ - if ( pSub.pLimit != null ) - { - pParent.pLimit = pSub.pLimit; - pSub.pLimit = null; + static void substExprList( + sqlite3 db, /* Report malloc errors here */ + ExprList pList, /* List to scan and in which to make substitutes */ + int iTable, /* Table to be substituted */ + ExprList pEList /* Substitute values */ + ) { + int i; + if (pList == null) + return; + for (i = 0; i < pList.nExpr; i++) { + pList.a[i].pExpr = substExpr(db, pList.a[i].pExpr, iTable, pEList); + } } - } - /* Finially, delete what is left of the subquery and return - ** success. - */ - sqlite3SelectDelete( db, ref pSub ); - sqlite3SelectDelete( db, ref pSub1 ); - return 1; - } + static void substSelect( + sqlite3 db, /* Report malloc errors here */ + Select p, /* SELECT statement in which to make substitutions */ + int iTable, /* Table to be replaced */ + ExprList pEList /* Substitute values */ + ) { + SrcList pSrc; + SrcList_item pItem; + int i; + if (p == null) + return; + substExprList(db, p.pEList, iTable, pEList); + substExprList(db, p.pGroupBy, iTable, pEList); + substExprList(db, p.pOrderBy, iTable, pEList); + p.pHaving = substExpr(db, p.pHaving, iTable, pEList); + p.pWhere = substExpr(db, p.pWhere, iTable, pEList); + substSelect(db, p.pPrior, iTable, pEList); + pSrc = p.pSrc; + Debug.Assert(pSrc != null); /* Even for (SELECT 1) we have: pSrc!=0 but pSrc->nSrc==0 */ + if (ALWAYS(pSrc)) { + for (i = pSrc.nSrc; i > 0; i--)//, pItem++ ) + { + pItem = pSrc.a[pSrc.nSrc - i]; + substSelect(db, pItem.pSelect, iTable, pEList); + } + } + } #endif //* !SQLITE_OMIT_SUBQUERY) || !SQLITE_OMIT_VIEW) */ - /* -** Analyze the SELECT statement passed as an argument to see if it -** is a min() or max() query. Return WHERE_ORDERBY_MIN or WHERE_ORDERBY_MAX if -** it is, or 0 otherwise. At present, a query is considered to be -** a min()/max() query if: -** -** 1. There is a single object in the FROM clause. -** -** 2. There is a single expression in the result set, and it is -** either min(x) or max(x), where x is a column reference. -*/ - static u8 minMaxQuery( Select p ) - { - Expr pExpr; - ExprList pEList = p.pEList; - - if ( pEList.nExpr != 1 ) - return WHERE_ORDERBY_NORMAL; - pExpr = pEList.a[0].pExpr; - if ( pExpr.op != TK_AGG_FUNCTION ) - return 0; - if ( NEVER( ExprHasProperty( pExpr, EP_xIsSelect ) ) ) - return 0; - pEList = pExpr.x.pList; - if ( pEList == null || pEList.nExpr != 1 ) - return 0; - if ( pEList.a[0].pExpr.op != TK_AGG_COLUMN ) - return WHERE_ORDERBY_NORMAL; - Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); - if ( pExpr.u.zToken.Equals( "min", StringComparison.OrdinalIgnoreCase ) ) - { - return WHERE_ORDERBY_MIN; - } - else if ( pExpr.u.zToken.Equals( "max", StringComparison.OrdinalIgnoreCase ) ) - { - return WHERE_ORDERBY_MAX; - } - return WHERE_ORDERBY_NORMAL; - } - - /* - ** The select statement passed as the first argument is an aggregate query. - ** The second argment is the associated aggregate-info object. This - ** function tests if the SELECT is of the form: +#if !(SQLITE_OMIT_SUBQUERY) || !(SQLITE_OMIT_VIEW) + /* + ** This routine attempts to flatten subqueries in order to speed + ** execution. It returns 1 if it makes changes and 0 if no flattening + ** occurs. ** - ** SELECT count() FROM + ** To understand the concept of flattening, consider the following + ** query: ** - ** where table is a database table, not a sub-select or view. If the query - ** does match this pattern, then a pointer to the Table object representing - ** is returned. Otherwise, 0 is returned. - */ - static Table isSimpleCount( Select p, AggInfo pAggInfo ) - { - Table pTab; - Expr pExpr; - - Debug.Assert( null == p.pGroupBy ); - - if ( p.pWhere != null || p.pEList.nExpr != 1 - || p.pSrc.nSrc != 1 || p.pSrc.a[0].pSelect != null - ) - { - return null; - } - pTab = p.pSrc.a[0].pTab; - pExpr = p.pEList.a[0].pExpr; - Debug.Assert( pTab != null && null == pTab.pSelect && pExpr != null ); - - if ( IsVirtual( pTab ) ) - return null; - if ( pExpr.op != TK_AGG_FUNCTION ) - return null; - if ( ( pAggInfo.aFunc[0].pFunc.flags & SQLITE_FUNC_COUNT ) == 0 ) - return null; - if ( ( pExpr.flags & EP_Distinct ) != 0 ) - return null; - - return pTab; - } - - /* - ** If the source-list item passed as an argument was augmented with an - ** INDEXED BY clause, then try to locate the specified index. If there - ** was such a clause and the named index cannot be found, return - ** SQLITE_ERROR and leave an error in pParse. Otherwise, populate - ** pFrom.pIndex and return SQLITE_OK. - */ - static int sqlite3IndexedByLookup( Parse pParse, SrcList_item pFrom ) - { - if ( pFrom.pTab != null && pFrom.zIndex != null && pFrom.zIndex.Length != 0 ) - { - Table pTab = pFrom.pTab; - string zIndex = pFrom.zIndex; - Index pIdx; - for ( pIdx = pTab.pIndex; - pIdx != null && !pIdx.zName.Equals( zIndex, StringComparison.OrdinalIgnoreCase ); - pIdx = pIdx.pNext - ) - ; - if ( null == pIdx ) - { - sqlite3ErrorMsg( pParse, "no such index: %s", zIndex ); - pParse.checkSchema = 1; - return SQLITE_ERROR; - } - pFrom.pIndex = pIdx; - } - return SQLITE_OK; - } - - /* - ** This routine is a Walker callback for "expanding" a SELECT statement. - ** "Expanding" means to do the following: + ** SELECT a FROM (SELECT x+y AS a FROM t1 WHERE z<100) WHERE a>5 ** - ** (1) Make sure VDBE cursor numbers have been assigned to every - ** element of the FROM clause. + ** The default way of implementing this query is to execute the + ** subquery first and store the results in a temporary table, then + ** run the outer query on that temporary table. This requires two + ** passes over the data. Furthermore, because the temporary table + ** has no indices, the WHERE clause on the outer query cannot be + ** optimized. ** - ** (2) Fill in the pTabList.a[].pTab fields in the SrcList that - ** defines FROM clause. When views appear in the FROM clause, - ** fill pTabList.a[].x.pSelect with a copy of the SELECT statement - ** that implements the view. A copy is made of the view's SELECT - ** statement so that we can freely modify or delete that statement - ** without worrying about messing up the presistent representation - ** of the view. + ** This routine attempts to rewrite queries such as the above into + ** a single flat select, like this: ** - ** (3) Add terms to the WHERE clause to accomodate the NATURAL keyword - ** on joins and the ON and USING clause of joins. + ** SELECT x+y AS a FROM t1 WHERE z<100 AND a>5 ** - ** (4) Scan the list of columns in the result set (pEList) looking - ** for instances of the "*" operator or the TABLE.* operator. - ** If found, expand each "*" to be every column in every table - ** and TABLE.* to be every column in TABLE. + ** The code generated for this simpification gives the same result + ** but only has to scan the data once. And because indices might + ** exist on the table t1, a complete scan of the data might be + ** avoided. ** + ** Flattening is only attempted if all of the following are true: + ** + ** (1) The subquery and the outer query do not both use aggregates. + ** + ** (2) The subquery is not an aggregate or the outer query is not a join. + ** + ** (3) The subquery is not the right operand of a left outer join + ** (Originally ticket #306. Strengthened by ticket #3300) + ** + ** (4) The subquery is not DISTINCT. + ** + ** (*) At one point restrictions (4) and (5) defined a subset of DISTINCT + ** sub-queries that were excluded from this optimization. Restriction + ** (4) has since been expanded to exclude all DISTINCT subqueries. + ** + ** (6) The subquery does not use aggregates or the outer query is not + ** DISTINCT. + ** + ** (7) The subquery has a FROM clause. + ** + ** (8) The subquery does not use LIMIT or the outer query is not a join. + ** + ** (9) The subquery does not use LIMIT or the outer query does not use + ** aggregates. + ** + ** (10) The subquery does not use aggregates or the outer query does not + ** use LIMIT. + ** + ** (11) The subquery and the outer query do not both have ORDER BY clauses. + ** + ** (*) Not implemented. Subsumed into restriction (3). Was previously + ** a separate restriction deriving from ticket #350. + ** + ** (13) The subquery and outer query do not both use LIMIT. + ** + ** (14) The subquery does not use OFFSET. + ** + ** (15) The outer query is not part of a compound select or the + ** subquery does not have a LIMIT clause. + ** (See ticket #2339 and ticket [02a8e81d44]). + ** + ** (16) The outer query is not an aggregate or the subquery does + ** not contain ORDER BY. (Ticket #2942) This used to not matter + ** until we introduced the group_concat() function. + ** + ** (17) The sub-query is not a compound select, or it is a UNION ALL + ** compound clause made up entirely of non-aggregate queries, and + ** the parent query: + ** + ** * is not itself part of a compound select, + ** * is not an aggregate or DISTINCT query, and + ** * has no other tables or sub-selects in the FROM clause. + ** + ** The parent and sub-query may contain WHERE clauses. Subject to + ** rules (11), (13) and (14), they may also contain ORDER BY, + ** LIMIT and OFFSET clauses. + ** + ** (18) If the sub-query is a compound select, then all terms of the + ** ORDER by clause of the parent must be simple references to + ** columns of the sub-query. + ** + ** (19) The subquery does not use LIMIT or the outer query does not + ** have a WHERE clause. + ** + ** (20) If the sub-query is a compound select, then it must not use + ** an ORDER BY clause. Ticket #3773. We could relax this constraint + ** somewhat by saying that the terms of the ORDER BY clause must + ** appear as unmodified result columns in the outer query. But + ** have other optimizations in mind to deal with that case. + ** + ** (21) The subquery does not use LIMIT or the outer query is not + ** DISTINCT. (See ticket [752e1646fc]). + ** + ** In this routine, the "p" parameter is a pointer to the outer query. + ** The subquery is p.pSrc.a[iFrom]. isAgg is true if the outer query + ** uses aggregates and subqueryIsAgg is true if the subquery uses aggregates. + ** + ** If flattening is not attempted, this routine is a no-op and returns 0. + ** If flattening is attempted this routine returns 1. + ** + ** All of the expression analysis must occur on both the outer query and + ** the subquery before this routine runs. */ - static int selectExpander( Walker pWalker, Select p ) - { - Parse pParse = pWalker.pParse; - int i, j, k; - SrcList pTabList; - ExprList pEList; - SrcList_item pFrom; - sqlite3 db = pParse.db; - - //if ( db.mallocFailed != 0 ) - //{ - // return WRC_Abort; - //} - if ( NEVER( p.pSrc == null ) || ( p.selFlags & SF_Expanded ) != 0 ) - { - return WRC_Prune; - } - p.selFlags |= SF_Expanded; - pTabList = p.pSrc; - pEList = p.pEList; - - /* Make sure cursor numbers have been assigned to all entries in - ** the FROM clause of the SELECT statement. - */ - sqlite3SrcListAssignCursors( pParse, pTabList ); + static int flattenSubquery( + Parse pParse, /* Parsing context */ + Select p, /* The parent or outer SELECT statement */ + int iFrom, /* Index in p.pSrc.a[] of the inner subquery */ + bool isAgg, /* True if outer SELECT uses aggregate functions */ + bool subqueryIsAgg /* True if the subquery uses aggregate functions */ + ) { + string zSavedAuthContext = pParse.zAuthContext; + Select pParent; + Select pSub; /* The inner query or "subquery" */ + Select pSub1; /* Pointer to the rightmost select in sub-query */ + SrcList pSrc; /* The FROM clause of the outer query */ + SrcList pSubSrc; /* The FROM clause of the subquery */ + ExprList pList; /* The result set of the outer query */ + int iParent; /* VDBE cursor number of the pSub result set temp table */ + int i; /* Loop counter */ + Expr pWhere; /* The WHERE clause */ + SrcList_item pSubitem;/* The subquery */ + sqlite3 db = pParse.db; + + /* Check to see if flattening is permitted. Return 0 if not. + */ + Debug.Assert(p != null); + Debug.Assert(p.pPrior == null); /* Unable to flatten compound queries */ + if ((db.flags & SQLITE_QueryFlattener) != 0) + return 0; + pSrc = p.pSrc; + Debug.Assert(pSrc != null && iFrom >= 0 && iFrom < pSrc.nSrc); + pSubitem = pSrc.a[iFrom]; + iParent = pSubitem.iCursor; + pSub = pSubitem.pSelect; + Debug.Assert(pSub != null); + if (isAgg && subqueryIsAgg) + return 0; /* Restriction (1) */ + if (subqueryIsAgg && pSrc.nSrc > 1) + return 0; /* Restriction (2) */ + pSubSrc = pSub.pSrc; + Debug.Assert(pSubSrc != null); + /* Prior to version 3.1.2, when LIMIT and OFFSET had to be simple constants, + ** not arbitrary expresssions, we allowed some combining of LIMIT and OFFSET + ** because they could be computed at compile-time. But when LIMIT and OFFSET + ** became arbitrary expressions, we were forced to add restrictions (13) + ** and (14). */ + if (pSub.pLimit != null && p.pLimit != null) + return 0; /* Restriction (13) */ + if (pSub.pOffset != null) + return 0; /* Restriction (14) */ + if (p.pRightmost != null && pSub.pLimit != null) { + return 0; /* Restriction (15) */ + } + if (pSubSrc.nSrc == 0) + return 0; /* Restriction (7) */ + if ((pSub.selFlags & SF_Distinct) != 0) + return 0; /* Restriction (5) */ + if (pSub.pLimit != null && (pSrc.nSrc > 1 || isAgg)) { + return 0; /* Restrictions (8)(9) */ + } + if ((p.selFlags & SF_Distinct) != 0 && subqueryIsAgg) { + return 0; /* Restriction (6) */ + } + if (p.pOrderBy != null && pSub.pOrderBy != null) { + return 0; /* Restriction (11) */ + } + if (isAgg && pSub.pOrderBy != null) + return 0; /* Restriction (16) */ + if (pSub.pLimit != null && p.pWhere != null) + return 0; /* Restriction (19) */ + if (pSub.pLimit != null && (p.selFlags & SF_Distinct) != 0) { + return 0; /* Restriction (21) */ + } - /* Look up every table named in the FROM clause of the select. If - ** an entry of the FROM clause is a subquery instead of a table or view, - ** then create a transient table ure to describe the subquery. - */ - for ( i = 0; i < pTabList.nSrc; i++ )// pFrom++ ) - { - pFrom = pTabList.a[i]; - Table pTab; - if ( pFrom.pTab != null ) - { - /* This statement has already been prepared. There is no need - ** to go further. */ - Debug.Assert( i == 0 ); - return WRC_Prune; - } - if ( pFrom.zName == null ) - { -#if !SQLITE_OMIT_SUBQUERY - Select pSel = pFrom.pSelect; - /* A sub-query in the FROM clause of a SELECT */ - Debug.Assert( pSel != null ); - Debug.Assert( pFrom.pTab == null ); - sqlite3WalkSelect( pWalker, pSel ); - pFrom.pTab = pTab = new Table();// sqlite3DbMallocZero( db, sizeof( Table ) ); - if ( pTab == null ) - return WRC_Abort; - pTab.nRef = 1; - pTab.zName = sqlite3MPrintf( db, "sqlite_subquery_%p_", pTab ); - while ( pSel.pPrior != null ) - { - pSel = pSel.pPrior; - } - selectColumnsFromExprList( pParse, pSel.pEList, ref pTab.nCol, ref pTab.aCol ); - pTab.iPKey = -1; - pTab.nRowEst = 1000000; - pTab.tabFlags |= TF_Ephemeral; -#endif - } - else - { - /* An ordinary table or view name in the FROM clause */ - Debug.Assert( pFrom.pTab == null ); - pFrom.pTab = pTab = - sqlite3LocateTable( pParse, 0, pFrom.zName, pFrom.zDatabase ); - if ( pTab == null ) - return WRC_Abort; - pTab.nRef++; -#if !(SQLITE_OMIT_VIEW) || !(SQLITE_OMIT_VIRTUALTABLE) - if ( pTab.pSelect != null || IsVirtual( pTab ) ) - { - /* We reach here if the named table is a really a view */ - if ( sqlite3ViewGetColumnNames( pParse, pTab ) != 0 ) - return WRC_Abort; - - pFrom.pSelect = sqlite3SelectDup( db, pTab.pSelect, 0 ); - sqlite3WalkSelect( pWalker, pFrom.pSelect ); - } -#endif - } - /* Locate the index named by the INDEXED BY clause, if any. */ - if ( sqlite3IndexedByLookup( pParse, pFrom ) != 0 ) - { - return WRC_Abort; - } - } + /* OBSOLETE COMMENT 1: + ** Restriction 3: If the subquery is a join, make sure the subquery is + ** not used as the right operand of an outer join. Examples of why this + ** is not allowed: + ** + ** t1 LEFT OUTER JOIN (t2 JOIN t3) + ** + ** If we flatten the above, we would get + ** + ** (t1 LEFT OUTER JOIN t2) JOIN t3 + ** + ** which is not at all the same thing. + ** + ** OBSOLETE COMMENT 2: + ** Restriction 12: If the subquery is the right operand of a left outer - /* Process NATURAL keywords, and ON and USING clauses of joins. - */ - if ( /* db.mallocFailed != 0 || */ sqliteProcessJoin( pParse, p ) != 0 ) - { - return WRC_Abort; - } - - /* For every "*" that occurs in the column list, insert the names of - ** all columns in all tables. And for every TABLE.* insert the names - ** of all columns in TABLE. The parser inserted a special expression - ** with the TK_ALL operator for each "*" that it found in the column list. - ** The following code just has to locate the TK_ALL expressions and expand - ** each one to the list of all columns in all tables. - ** - ** The first loop just checks to see if there are any "*" operators - ** that need expanding. - */ - for ( k = 0; k < pEList.nExpr; k++ ) - { - Expr pE = pEList.a[k].pExpr; - if ( pE.op == TK_ALL ) - break; - Debug.Assert( pE.op != TK_DOT || pE.pRight != null ); - Debug.Assert( pE.op != TK_DOT || ( pE.pLeft != null && pE.pLeft.op == TK_ID ) ); - if ( pE.op == TK_DOT && pE.pRight.op == TK_ALL ) - break; - } - if ( k < pEList.nExpr ) - { - /* - ** If we get here it means the result set contains one or more "*" - ** operators that need to be expanded. Loop through each expression - ** in the result set and expand them one by one. - */ - ExprList_item[] a = pEList.a; - ExprList pNew = null; - int flags = pParse.db.flags; - bool longNames = ( flags & SQLITE_FullColNames ) != 0 - && ( flags & SQLITE_ShortColNames ) == 0; - - for ( k = 0; k < pEList.nExpr; k++ ) - { - Expr pE = a[k].pExpr; - Debug.Assert( pE.op != TK_DOT || pE.pRight != null ); - if ( pE.op != TK_ALL && ( pE.op != TK_DOT || pE.pRight.op != TK_ALL ) ) - { - /* This particular expression does not need to be expanded. + /* Restriction 12: If the subquery is the right operand of a left outer + ** join, make sure the subquery has no WHERE clause. + ** An examples of why this is not allowed: + ** + ** t1 LEFT OUTER JOIN (SELECT * FROM t2 WHERE t2.x>0) + ** + ** If we flatten the above, we would get + ** + ** (t1 LEFT OUTER JOIN t2) WHERE t2.x>0 + ** + ** But the t2.x>0 test will always fail on a NULL row of t2, which + ** effectively converts the OUTER JOIN into an INNER JOIN. + ** + ** THIS OVERRIDES OBSOLETE COMMENTS 1 AND 2 ABOVE: + ** Ticket #3300 shows that flattening the right term of a LEFT JOIN + ** is fraught with danger. Best to avoid the whole thing. If the + ** subquery is the right term of a LEFT JOIN, then do not flatten. */ - pNew = sqlite3ExprListAppend( pParse, pNew, a[k].pExpr ); - if ( pNew != null ) - { - pNew.a[pNew.nExpr - 1].zName = a[k].zName; - pNew.a[pNew.nExpr - 1].zSpan = a[k].zSpan; - a[k].zName = null; - a[k].zSpan = null; + if ((pSubitem.jointype & JT_OUTER) != 0) { + return 0; } - a[k].pExpr = null; - } - else - { - /* This expression is a "*" or a "TABLE.*" and needs to be - ** expanded. */ - int tableSeen = 0; /* Set to 1 when TABLE matches */ - string zTName; /* text of name of TABLE */ - if ( pE.op == TK_DOT ) - { - Debug.Assert( pE.pLeft != null ); - Debug.Assert( !ExprHasProperty( pE.pLeft, EP_IntValue ) ); - zTName = pE.pLeft.u.zToken; + + /* Restriction 17: If the sub-query is a compound SELECT, then it must + ** use only the UNION ALL operator. And none of the simple select queries + ** that make up the compound SELECT are allowed to be aggregate or distinct + ** queries. + */ + if (pSub.pPrior != null) { + if (pSub.pOrderBy != null) { + return 0; /* Restriction 20 */ + } + if (isAgg || (p.selFlags & SF_Distinct) != 0 || pSrc.nSrc != 1) { + return 0; + } + for (pSub1 = pSub; pSub1 != null; pSub1 = pSub1.pPrior) { + testcase((pSub1.selFlags & (SF_Distinct | SF_Aggregate)) == SF_Distinct); + testcase((pSub1.selFlags & (SF_Distinct | SF_Aggregate)) == SF_Aggregate); + if ((pSub1.selFlags & (SF_Distinct | SF_Aggregate)) != 0 + || (pSub1.pPrior != null && pSub1.op != TK_ALL) + || NEVER(pSub1.pSrc == null) || pSub1.pSrc.nSrc != 1 + ) { + return 0; + } + } + + /* Restriction 18. */ + if (p.pOrderBy != null) { + int ii; + for (ii = 0; ii < p.pOrderBy.nExpr; ii++) { + if (p.pOrderBy.a[ii].iCol == 0) + return 0; + } + } } - else - { - zTName = null; + + /***** If we reach this point, flattening is permitted. *****/ + + /* Authorize the subquery */ + pParse.zAuthContext = pSubitem.zName; + sqlite3AuthCheck(pParse, SQLITE_SELECT, null, null, null); + pParse.zAuthContext = zSavedAuthContext; + + /* If the sub-query is a compound SELECT statement, then (by restrictions + ** 17 and 18 above) it must be a UNION ALL and the parent query must + ** be of the form: + ** + ** SELECT FROM () + ** + ** followed by any ORDER BY, LIMIT and/or OFFSET clauses. This block + ** creates N-1 copies of the parent query without any ORDER BY, LIMIT or + ** OFFSET clauses and joins them to the left-hand-side of the original + ** using UNION ALL operators. In this case N is the number of simple + ** select statements in the compound sub-query. + ** + ** Example: + ** + ** SELECT a+1 FROM ( + ** SELECT x FROM tab + ** UNION ALL + ** SELECT y FROM tab + ** UNION ALL + ** SELECT abs(z*2) FROM tab2 + ** ) WHERE a!=5 ORDER BY 1 + ** + ** Transformed into: + ** + ** SELECT x+1 FROM tab WHERE x+1!=5 + ** UNION ALL + ** SELECT y+1 FROM tab WHERE y+1!=5 + ** UNION ALL + ** SELECT abs(z*2)+1 FROM tab2 WHERE abs(z*2)+1!=5 + ** ORDER BY 1 + ** + ** We call this the "compound-subquery flattening". + */ + for (pSub = pSub.pPrior; pSub != null; pSub = pSub.pPrior) { + Select pNew; + ExprList pOrderBy = p.pOrderBy; + Expr pLimit = p.pLimit; + Select pPrior = p.pPrior; + p.pOrderBy = null; + p.pSrc = null; + p.pPrior = null; + p.pLimit = null; + pNew = sqlite3SelectDup(db, p, 0); + p.pLimit = pLimit; + p.pOrderBy = pOrderBy; + p.pSrc = pSrc; + p.op = TK_ALL; + p.pRightmost = null; + if (pNew == null) { + pNew = pPrior; + } else { + pNew.pPrior = pPrior; + pNew.pRightmost = null; + } + p.pPrior = pNew; + // if ( db.mallocFailed != 0 ) return 1; } - for ( i = 0; i < pTabList.nSrc; i++ )//, pFrom++ ) - { - pFrom = pTabList.a[i]; - Table pTab = pFrom.pTab; - string zTabName = pFrom.zAlias; - if ( zTabName == null ) - { - zTabName = pTab.zName; - } - ///if ( db.mallocFailed != 0 ) break; - if ( zTName != null && !zTName.Equals( zTabName, StringComparison.OrdinalIgnoreCase ) ) - { - continue; - } - tableSeen = 1; - for ( j = 0; j < pTab.nCol; j++ ) - { - Expr pExpr, pRight; - string zName = pTab.aCol[j].zName; - string zColname; /* The computed column name */ - string zToFree; /* Malloced string that needs to be freed */ - Token sColname = new Token(); /* Computed column name as a token */ - - /* If a column is marked as 'hidden' (currently only possible - ** for virtual tables), do not include it in the expanded - ** result-set list. + + /* Begin flattening the iFrom-th entry of the FROM clause + ** in the outer query. + */ + pSub = pSub1 = pSubitem.pSelect; + /* Delete the transient table structure associated with the + ** subquery + */ + + sqlite3DbFree(db, ref pSubitem.zDatabase); + sqlite3DbFree(db, ref pSubitem.zName); + sqlite3DbFree(db, ref pSubitem.zAlias); + pSubitem.zDatabase = null; + pSubitem.zName = null; + pSubitem.zAlias = null; + pSubitem.pSelect = null; + /* Defer deleting the Table object associated with the + ** subquery until code generation is + ** complete, since there may still exist Expr.pTab entries that + ** refer to the subquery even after flattening. Ticket #3346. + ** + ** pSubitem->pTab is always non-NULL by test restrictions and tests above. + */ + if (ALWAYS(pSubitem.pTab != null)) { + Table pTabToDel = pSubitem.pTab; + if (pTabToDel.nRef == 1) { + Parse pToplevel = sqlite3ParseToplevel(pParse); + pTabToDel.pNextZombie = pToplevel.pZombieTab; + pToplevel.pZombieTab = pTabToDel; + } else { + pTabToDel.nRef--; + } + pSubitem.pTab = null; + } + + /* The following loop runs once for each term in a compound-subquery + ** flattening (as described above). If we are doing a different kind + ** of flattening - a flattening other than a compound-subquery flattening - + ** then this loop only runs once. + ** + ** This loop moves all of the FROM elements of the subquery into the + ** the FROM clause of the outer query. Before doing this, remember + ** the cursor number for the original outer query FROM element in + ** iParent. The iParent cursor will never be used. Subsequent code + ** will scan expressions looking for iParent references and replace + ** those references with expressions that resolve to the subquery FROM + ** elements we are now copying in. + */ + for (pParent = p; pParent != null; pParent = pParent.pPrior, pSub = pSub.pPrior) { + int nSubSrc; + u8 jointype = 0; + pSubSrc = pSub.pSrc; /* FROM clause of subquery */ + nSubSrc = pSubSrc.nSrc; /* Number of terms in subquery FROM clause */ + pSrc = pParent.pSrc; /* FROM clause of the outer query */ + + if (pSrc != null) { + Debug.Assert(pParent == p); /* First time through the loop */ + jointype = pSubitem.jointype; + } else { + Debug.Assert(pParent != p); /* 2nd and subsequent times through the loop */ + pSrc = pParent.pSrc = sqlite3SrcListAppend(db, null, null, null); + //if ( pSrc == null ) + //{ + // //Debug.Assert( db.mallocFailed != 0 ); + // break; + //} + } + + /* The subquery uses a single slot of the FROM clause of the outer + ** query. If the subquery has more than one element in its FROM clause, + ** then expand the outer query to make space for it to hold all elements + ** of the subquery. + ** + ** Example: + ** + ** SELECT * FROM tabA, (SELECT * FROM sub1, sub2), tabB; + ** + ** The outer query has 3 slots in its FROM clause. One slot of the + ** outer query (the middle slot) is used by the subquery. The next + ** block of code will expand the out query to 4 slots. The middle + ** slot is expanded to two slots in order to make space for the + ** two elements in the FROM clause of the subquery. */ - if ( IsHiddenColumn( pTab.aCol[j] ) ) - { - Debug.Assert( IsVirtual( pTab ) ); - continue; + if (nSubSrc > 1) { + pParent.pSrc = pSrc = sqlite3SrcListEnlarge(db, pSrc, nSubSrc - 1, iFrom + 1); + //if ( db.mallocFailed != 0 ) + //{ + // break; + //} } - if ( i > 0 && ( zTName == null || zTName.Length == 0 ) ) - { - int iDummy = 0; - if ( ( pFrom.jointype & JT_NATURAL ) != 0 - && tableAndColumnIndex( pTabList, i, zName, ref iDummy, ref iDummy ) != 0 - ) - { - /* In a NATURAL join, omit the join columns from the - ** table to the right of the join */ - continue; - } - if ( sqlite3IdListIndex( pFrom.pUsing, zName ) >= 0 ) - { - /* In a join with a USING clause, omit columns in the - ** using clause from the table on the right. */ - continue; - } + /* Transfer the FROM clause terms from the subquery into the + ** outer query. + */ + for (i = 0; i < nSubSrc; i++) { + sqlite3IdListDelete(db, ref pSrc.a[i + iFrom].pUsing); + pSrc.a[i + iFrom] = pSubSrc.a[i]; + pSubSrc.a[i] = new SrcList_item();//memset(pSubSrc.a[i], 0, sizeof(pSubSrc.a[i])); } - pRight = sqlite3Expr( db, TK_ID, zName ); - zColname = zName; - zToFree = ""; - if ( longNames || pTabList.nSrc > 1 ) - { - Expr pLeft; - pLeft = sqlite3Expr( db, TK_ID, zTabName ); - pExpr = sqlite3PExpr( pParse, TK_DOT, pLeft, pRight, 0 ); - if ( longNames ) - { - zColname = sqlite3MPrintf( db, "%s.%s", zTabName, zName ); - zToFree = zColname; - } + pSubitem = pSrc.a[iFrom]; // Reset for C# + pSrc.a[iFrom].jointype = jointype; + + /* Now begin substituting subquery result set expressions for + ** references to the iParent in the outer query. + ** + ** Example: + ** + ** SELECT a+5, b*10 FROM (SELECT x*3 AS a, y+10 AS b FROM t1) WHERE a>b; + ** \ \_____________ subquery __________/ / + ** \_____________________ outer query ______________________________/ + ** + ** We look at every expression in the outer query and every place we see + ** "a" we substitute "x*3" and every place we see "b" we substitute "y+10". + */ + pList = pParent.pEList; + for (i = 0; i < pList.nExpr; i++) { + if (pList.a[i].zName == null) { + string zSpan = pList.a[i].zSpan; + if (ALWAYS(zSpan)) { + pList.a[i].zName = zSpan;// sqlite3DbStrDup( db, zSpan ); + } + } } - else - { - pExpr = pRight; + substExprList(db, pParent.pEList, iParent, pSub.pEList); + if (isAgg) { + substExprList(db, pParent.pGroupBy, iParent, pSub.pEList); + pParent.pHaving = substExpr(db, pParent.pHaving, iParent, pSub.pEList); + } + if (pSub.pOrderBy != null) { + Debug.Assert(pParent.pOrderBy == null); + pParent.pOrderBy = pSub.pOrderBy; + pSub.pOrderBy = null; + } else if (pParent.pOrderBy != null) { + substExprList(db, pParent.pOrderBy, iParent, pSub.pEList); + } + if (pSub.pWhere != null) { + pWhere = sqlite3ExprDup(db, pSub.pWhere, 0); + } else { + pWhere = null; + } + if (subqueryIsAgg) { + Debug.Assert(pParent.pHaving == null); + pParent.pHaving = pParent.pWhere; + pParent.pWhere = pWhere; + pParent.pHaving = substExpr(db, pParent.pHaving, iParent, pSub.pEList); + pParent.pHaving = sqlite3ExprAnd(db, pParent.pHaving, + sqlite3ExprDup(db, pSub.pHaving, 0)); + Debug.Assert(pParent.pGroupBy == null); + pParent.pGroupBy = sqlite3ExprListDup(db, pSub.pGroupBy, 0); + } else { + pParent.pWhere = substExpr(db, pParent.pWhere, iParent, pSub.pEList); + pParent.pWhere = sqlite3ExprAnd(db, pParent.pWhere, pWhere); + } + + /* The flattened query is distinct if either the inner or the + ** outer query is distinct. + */ + pParent.selFlags = (u16)(pParent.selFlags | pSub.selFlags & SF_Distinct); + + /* + ** SELECT ... FROM (SELECT ... LIMIT a OFFSET b) LIMIT x OFFSET y; + ** + ** One is tempted to try to add a and b to combine the limits. But this + ** does not work if either limit is negative. + */ + if (pSub.pLimit != null) { + pParent.pLimit = pSub.pLimit; + pSub.pLimit = null; } - pNew = sqlite3ExprListAppend( pParse, pNew, pExpr ); - sColname.z = zColname; - sColname.n = sqlite3Strlen30( zColname ); - sqlite3ExprListSetName( pParse, pNew, sColname, 0 ); - sqlite3DbFree( db, ref zToFree ); - } - } - if ( tableSeen == 0 ) - { - if ( zTName != null ) - { - sqlite3ErrorMsg( pParse, "no such table: %s", zTName ); - } - else - { - sqlite3ErrorMsg( pParse, "no tables specified" ); - } } - } - } - sqlite3ExprListDelete( db, ref pEList ); - p.pEList = pNew; - } -//#if SQLITE_MAX_COLUMN - if ( p.pEList != null && p.pEList.nExpr > db.aLimit[SQLITE_LIMIT_COLUMN] ) - { - sqlite3ErrorMsg( pParse, "too many columns in result set" ); - } -//#endif - return WRC_Continue; - } - /* - ** No-op routine for the parse-tree walker. - ** - ** When this routine is the Walker.xExprCallback then expression trees - ** are walked without any actions being taken at each node. Presumably, - ** when this routine is used for Walker.xExprCallback then - ** Walker.xSelectCallback is set to do something useful for every - ** subquery in the parser tree. - */ - static int exprWalkNoop( Walker NotUsed, ref Expr NotUsed2 ) - { - UNUSED_PARAMETER2( NotUsed, NotUsed2 ); - return WRC_Continue; - } + /* Finially, delete what is left of the subquery and return + ** success. + */ + sqlite3SelectDelete(db, ref pSub); + sqlite3SelectDelete(db, ref pSub1); + return 1; + } +#endif //* !SQLITE_OMIT_SUBQUERY) || !SQLITE_OMIT_VIEW) */ - /* - ** This routine "expands" a SELECT statement and all of its subqueries. - ** For additional information on what it means to "expand" a SELECT - ** statement, see the comment on the selectExpand worker callback above. + /* + ** Analyze the SELECT statement passed as an argument to see if it + ** is a min() or max() query. Return WHERE_ORDERBY_MIN or WHERE_ORDERBY_MAX if + ** it is, or 0 otherwise. At present, a query is considered to be + ** a min()/max() query if: ** - ** Expanding a SELECT statement is the first step in processing a - ** SELECT statement. The SELECT statement must be expanded before - ** name resolution is performed. + ** 1. There is a single object in the FROM clause. ** - ** If anything goes wrong, an error message is written into pParse. - ** The calling function can detect the problem by looking at pParse.nErr - ** and/or pParse.db.mallocFailed. + ** 2. There is a single expression in the result set, and it is + ** either min(x) or max(x), where x is a column reference. */ - static void sqlite3SelectExpand( Parse pParse, Select pSelect ) - { - Walker w = new Walker(); - w.xSelectCallback = selectExpander; - w.xExprCallback = exprWalkNoop; - w.pParse = pParse; - sqlite3WalkSelect( w, pSelect ); - } + static u8 minMaxQuery(Select p) { + Expr pExpr; + ExprList pEList = p.pEList; + + if (pEList.nExpr != 1) + return WHERE_ORDERBY_NORMAL; + pExpr = pEList.a[0].pExpr; + if (pExpr.op != TK_AGG_FUNCTION) + return 0; + if (NEVER(ExprHasProperty(pExpr, EP_xIsSelect))) + return 0; + pEList = pExpr.x.pList; + if (pEList == null || pEList.nExpr != 1) + return 0; + if (pEList.a[0].pExpr.op != TK_AGG_COLUMN) + return WHERE_ORDERBY_NORMAL; + Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); + if (pExpr.u.zToken.Equals("min", StringComparison.OrdinalIgnoreCase)) { + return WHERE_ORDERBY_MIN; + } else if (pExpr.u.zToken.Equals("max", StringComparison.OrdinalIgnoreCase)) { + return WHERE_ORDERBY_MAX; + } + return WHERE_ORDERBY_NORMAL; + } + + /* + ** The select statement passed as the first argument is an aggregate query. + ** The second argment is the associated aggregate-info object. This + ** function tests if the SELECT is of the form: + ** + ** SELECT count() FROM + ** + ** where table is a database table, not a sub-select or view. If the query + ** does match this pattern, then a pointer to the Table object representing + ** is returned. Otherwise, 0 is returned. + */ + static Table isSimpleCount(Select p, AggInfo pAggInfo) { + Table pTab; + Expr pExpr; + Debug.Assert(null == p.pGroupBy); -#if !SQLITE_OMIT_SUBQUERY - /* -** This is a Walker.xSelectCallback callback for the sqlite3SelectTypeInfo() -** interface. -** -** For each FROM-clause subquery, add Column.zType and Column.zColl -** information to the Table ure that represents the result set -** of that subquery. -** -** The Table ure that represents the result set was coned -** by selectExpander() but the type and collation information was omitted -** at that point because identifiers had not yet been resolved. This -** routine is called after identifier resolution. -*/ - static int selectAddSubqueryTypeInfo( Walker pWalker, Select p ) - { - Parse pParse; - int i; - SrcList pTabList; - SrcList_item pFrom; - - Debug.Assert( ( p.selFlags & SF_Resolved ) != 0 ); - if ( ( p.selFlags & SF_HasTypeInfo ) == 0 ) - { - p.selFlags |= SF_HasTypeInfo; - pParse = pWalker.pParse; - pTabList = p.pSrc; - for ( i = 0; i < pTabList.nSrc; i++ )//, pFrom++ ) - { - pFrom = pTabList.a[i]; - Table pTab = pFrom.pTab; - if ( ALWAYS( pTab != null ) && ( pTab.tabFlags & TF_Ephemeral ) != 0 ) - { - /* A sub-query in the FROM clause of a SELECT */ - Select pSel = pFrom.pSelect; - Debug.Assert( pSel != null ); - while ( pSel.pPrior != null ) - pSel = pSel.pPrior; - selectAddColumnTypeAndCollation( pParse, pTab.nCol, pTab.aCol, pSel ); - } + if (p.pWhere != null || p.pEList.nExpr != 1 + || p.pSrc.nSrc != 1 || p.pSrc.a[0].pSelect != null + ) { + return null; + } + pTab = p.pSrc.a[0].pTab; + pExpr = p.pEList.a[0].pExpr; + Debug.Assert(pTab != null && null == pTab.pSelect && pExpr != null); + + if (IsVirtual(pTab)) + return null; + if (pExpr.op != TK_AGG_FUNCTION) + return null; + if ((pAggInfo.aFunc[0].pFunc.flags & SQLITE_FUNC_COUNT) == 0) + return null; + if ((pExpr.flags & EP_Distinct) != 0) + return null; + + return pTab; + } + + /* + ** If the source-list item passed as an argument was augmented with an + ** INDEXED BY clause, then try to locate the specified index. If there + ** was such a clause and the named index cannot be found, return + ** SQLITE_ERROR and leave an error in pParse. Otherwise, populate + ** pFrom.pIndex and return SQLITE_OK. + */ + static int sqlite3IndexedByLookup(Parse pParse, SrcList_item pFrom) { + if (pFrom.pTab != null && pFrom.zIndex != null && pFrom.zIndex.Length != 0) { + Table pTab = pFrom.pTab; + string zIndex = pFrom.zIndex; + Index pIdx; + for (pIdx = pTab.pIndex; + pIdx != null && !pIdx.zName.Equals(zIndex, StringComparison.OrdinalIgnoreCase); + pIdx = pIdx.pNext + ) + ; + if (null == pIdx) { + sqlite3ErrorMsg(pParse, "no such index: %s", zIndex); + pParse.checkSchema = 1; + return SQLITE_ERROR; + } + pFrom.pIndex = pIdx; + } + return SQLITE_OK; } - } - return WRC_Continue; - } -#endif + /* + ** This routine is a Walker callback for "expanding" a SELECT statement. + ** "Expanding" means to do the following: + ** + ** (1) Make sure VDBE cursor numbers have been assigned to every + ** element of the FROM clause. + ** + ** (2) Fill in the pTabList.a[].pTab fields in the SrcList that + ** defines FROM clause. When views appear in the FROM clause, + ** fill pTabList.a[].x.pSelect with a copy of the SELECT statement + ** that implements the view. A copy is made of the view's SELECT + ** statement so that we can freely modify or delete that statement + ** without worrying about messing up the presistent representation + ** of the view. + ** + ** (3) Add terms to the WHERE clause to accomodate the NATURAL keyword + ** on joins and the ON and USING clause of joins. + ** + ** (4) Scan the list of columns in the result set (pEList) looking + ** for instances of the "*" operator or the TABLE.* operator. + ** If found, expand each "*" to be every column in every table + ** and TABLE.* to be every column in TABLE. + ** + */ + static int selectExpander(Walker pWalker, Select p) { + Parse pParse = pWalker.pParse; + int i, j, k; + SrcList pTabList; + ExprList pEList; + SrcList_item pFrom; + sqlite3 db = pParse.db; + + //if ( db.mallocFailed != 0 ) + //{ + // return WRC_Abort; + //} + if (NEVER(p.pSrc == null) || (p.selFlags & SF_Expanded) != 0) { + return WRC_Prune; + } + p.selFlags |= SF_Expanded; + pTabList = p.pSrc; + pEList = p.pEList; - /* -** This routine adds datatype and collating sequence information to -** the Table ures of all FROM-clause subqueries in a -** SELECT statement. -** -** Use this routine after name resolution. -*/ - static void sqlite3SelectAddTypeInfo( Parse pParse, Select pSelect ) - { + /* Make sure cursor numbers have been assigned to all entries in + ** the FROM clause of the SELECT statement. + */ + sqlite3SrcListAssignCursors(pParse, pTabList); + + /* Look up every table named in the FROM clause of the select. If + ** an entry of the FROM clause is a subquery instead of a table or view, + ** then create a transient table ure to describe the subquery. + */ + for (i = 0; i < pTabList.nSrc; i++)// pFrom++ ) + { + pFrom = pTabList.a[i]; + Table pTab; + if (pFrom.pTab != null) { + /* This statement has already been prepared. There is no need + ** to go further. */ + Debug.Assert(i == 0); + return WRC_Prune; + } + if (pFrom.zName == null) { #if !SQLITE_OMIT_SUBQUERY - Walker w = new Walker(); - w.xSelectCallback = selectAddSubqueryTypeInfo; - w.xExprCallback = exprWalkNoop; - w.pParse = pParse; - sqlite3WalkSelect( w, pSelect ); + Select pSel = pFrom.pSelect; + /* A sub-query in the FROM clause of a SELECT */ + Debug.Assert(pSel != null); + Debug.Assert(pFrom.pTab == null); + sqlite3WalkSelect(pWalker, pSel); + pFrom.pTab = pTab = new Table();// sqlite3DbMallocZero( db, sizeof( Table ) ); + if (pTab == null) + return WRC_Abort; + pTab.nRef = 1; + pTab.zName = sqlite3MPrintf(db, "sqlite_subquery_%p_", pTab); + while (pSel.pPrior != null) { + pSel = pSel.pPrior; + } + selectColumnsFromExprList(pParse, pSel.pEList, ref pTab.nCol, ref pTab.aCol); + pTab.iPKey = -1; + pTab.nRowEst = 1000000; + pTab.tabFlags |= TF_Ephemeral; #endif - } + } else { + /* An ordinary table or view name in the FROM clause */ + Debug.Assert(pFrom.pTab == null); + pFrom.pTab = pTab = + sqlite3LocateTable(pParse, 0, pFrom.zName, pFrom.zDatabase); + if (pTab == null) + return WRC_Abort; + pTab.nRef++; +#if !(SQLITE_OMIT_VIEW) || !(SQLITE_OMIT_VIRTUALTABLE) + if (pTab.pSelect != null || IsVirtual(pTab)) { + /* We reach here if the named table is a really a view */ + if (sqlite3ViewGetColumnNames(pParse, pTab) != 0) + return WRC_Abort; + + pFrom.pSelect = sqlite3SelectDup(db, pTab.pSelect, 0); + sqlite3WalkSelect(pWalker, pFrom.pSelect); + } +#endif + } + /* Locate the index named by the INDEXED BY clause, if any. */ + if (sqlite3IndexedByLookup(pParse, pFrom) != 0) { + return WRC_Abort; + } + } + + /* Process NATURAL keywords, and ON and USING clauses of joins. + */ + if ( /* db.mallocFailed != 0 || */ sqliteProcessJoin(pParse, p) != 0) { + return WRC_Abort; + } + + /* For every "*" that occurs in the column list, insert the names of + ** all columns in all tables. And for every TABLE.* insert the names + ** of all columns in TABLE. The parser inserted a special expression + ** with the TK_ALL operator for each "*" that it found in the column list. + ** The following code just has to locate the TK_ALL expressions and expand + ** each one to the list of all columns in all tables. + ** + ** The first loop just checks to see if there are any "*" operators + ** that need expanding. + */ + for (k = 0; k < pEList.nExpr; k++) { + Expr pE = pEList.a[k].pExpr; + if (pE.op == TK_ALL) + break; + Debug.Assert(pE.op != TK_DOT || pE.pRight != null); + Debug.Assert(pE.op != TK_DOT || (pE.pLeft != null && pE.pLeft.op == TK_ID)); + if (pE.op == TK_DOT && pE.pRight.op == TK_ALL) + break; + } + if (k < pEList.nExpr) { + /* + ** If we get here it means the result set contains one or more "*" + ** operators that need to be expanded. Loop through each expression + ** in the result set and expand them one by one. + */ + ExprList_item[] a = pEList.a; + ExprList pNew = null; + int flags = pParse.db.flags; + bool longNames = (flags & SQLITE_FullColNames) != 0 + && (flags & SQLITE_ShortColNames) == 0; + + for (k = 0; k < pEList.nExpr; k++) { + Expr pE = a[k].pExpr; + Debug.Assert(pE.op != TK_DOT || pE.pRight != null); + if (pE.op != TK_ALL && (pE.op != TK_DOT || pE.pRight.op != TK_ALL)) { + /* This particular expression does not need to be expanded. + */ + pNew = sqlite3ExprListAppend(pParse, pNew, a[k].pExpr); + if (pNew != null) { + pNew.a[pNew.nExpr - 1].zName = a[k].zName; + pNew.a[pNew.nExpr - 1].zSpan = a[k].zSpan; + a[k].zName = null; + a[k].zSpan = null; + } + a[k].pExpr = null; + } else { + /* This expression is a "*" or a "TABLE.*" and needs to be + ** expanded. */ + int tableSeen = 0; /* Set to 1 when TABLE matches */ + string zTName; /* text of name of TABLE */ + if (pE.op == TK_DOT) { + Debug.Assert(pE.pLeft != null); + Debug.Assert(!ExprHasProperty(pE.pLeft, EP_IntValue)); + zTName = pE.pLeft.u.zToken; + } else { + zTName = null; + } + for (i = 0; i < pTabList.nSrc; i++)//, pFrom++ ) + { + pFrom = pTabList.a[i]; + Table pTab = pFrom.pTab; + string zTabName = pFrom.zAlias; + if (zTabName == null) { + zTabName = pTab.zName; + } + ///if ( db.mallocFailed != 0 ) break; + if (zTName != null && !zTName.Equals(zTabName, StringComparison.OrdinalIgnoreCase)) { + continue; + } + tableSeen = 1; + for (j = 0; j < pTab.nCol; j++) { + Expr pExpr, pRight; + string zName = pTab.aCol[j].zName; + string zColname; /* The computed column name */ + string zToFree; /* Malloced string that needs to be freed */ + Token sColname = new Token(); /* Computed column name as a token */ + + /* If a column is marked as 'hidden' (currently only possible + ** for virtual tables), do not include it in the expanded + ** result-set list. + */ + if (IsHiddenColumn(pTab.aCol[j])) { + Debug.Assert(IsVirtual(pTab)); + continue; + } + + if (i > 0 && (zTName == null || zTName.Length == 0)) { + int iDummy = 0; + if ((pFrom.jointype & JT_NATURAL) != 0 + && tableAndColumnIndex(pTabList, i, zName, ref iDummy, ref iDummy) != 0 + ) { + /* In a NATURAL join, omit the join columns from the + ** table to the right of the join */ + continue; + } + if (sqlite3IdListIndex(pFrom.pUsing, zName) >= 0) { + /* In a join with a USING clause, omit columns in the + ** using clause from the table on the right. */ + continue; + } + } + pRight = sqlite3Expr(db, TK_ID, zName); + zColname = zName; + zToFree = ""; + if (longNames || pTabList.nSrc > 1) { + Expr pLeft; + pLeft = sqlite3Expr(db, TK_ID, zTabName); + pExpr = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0); + if (longNames) { + zColname = sqlite3MPrintf(db, "%s.%s", zTabName, zName); + zToFree = zColname; + } + } else { + pExpr = pRight; + } + pNew = sqlite3ExprListAppend(pParse, pNew, pExpr); + sColname.z = zColname; + sColname.n = sqlite3Strlen30(zColname); + sqlite3ExprListSetName(pParse, pNew, sColname, 0); + sqlite3DbFree(db, ref zToFree); + } + } + if (tableSeen == 0) { + if (zTName != null) { + sqlite3ErrorMsg(pParse, "no such table: %s", zTName); + } else { + sqlite3ErrorMsg(pParse, "no tables specified"); + } + } + } + } + sqlite3ExprListDelete(db, ref pEList); + p.pEList = pNew; + } + //#if SQLITE_MAX_COLUMN + if (p.pEList != null && p.pEList.nExpr > db.aLimit[SQLITE_LIMIT_COLUMN]) { + sqlite3ErrorMsg(pParse, "too many columns in result set"); + } + //#endif + return WRC_Continue; + } + + /* + ** No-op routine for the parse-tree walker. + ** + ** When this routine is the Walker.xExprCallback then expression trees + ** are walked without any actions being taken at each node. Presumably, + ** when this routine is used for Walker.xExprCallback then + ** Walker.xSelectCallback is set to do something useful for every + ** subquery in the parser tree. + */ + static int exprWalkNoop(Walker NotUsed, ref Expr NotUsed2) { + UNUSED_PARAMETER2(NotUsed, NotUsed2); + return WRC_Continue; + } + + /* + ** This routine "expands" a SELECT statement and all of its subqueries. + ** For additional information on what it means to "expand" a SELECT + ** statement, see the comment on the selectExpand worker callback above. + ** + ** Expanding a SELECT statement is the first step in processing a + ** SELECT statement. The SELECT statement must be expanded before + ** name resolution is performed. + ** + ** If anything goes wrong, an error message is written into pParse. + ** The calling function can detect the problem by looking at pParse.nErr + ** and/or pParse.db.mallocFailed. + */ + static void sqlite3SelectExpand(Parse pParse, Select pSelect) { + Walker w = new Walker(); + w.xSelectCallback = selectExpander; + w.xExprCallback = exprWalkNoop; + w.pParse = pParse; + sqlite3WalkSelect(w, pSelect); + } - /* - ** This routine sets of a SELECT statement for processing. The - ** following is accomplished: +#if !SQLITE_OMIT_SUBQUERY + /* + ** This is a Walker.xSelectCallback callback for the sqlite3SelectTypeInfo() + ** interface. ** - ** * VDBE VdbeCursor numbers are assigned to all FROM-clause terms. - ** * Ephemeral Table objects are created for all FROM-clause subqueries. - ** * ON and USING clauses are shifted into WHERE statements - ** * Wildcards "*" and "TABLE.*" in result sets are expanded. - ** * Identifiers in expression are matched to tables. + ** For each FROM-clause subquery, add Column.zType and Column.zColl + ** information to the Table ure that represents the result set + ** of that subquery. ** - ** This routine acts recursively on all subqueries within the SELECT. + ** The Table ure that represents the result set was coned + ** by selectExpander() but the type and collation information was omitted + ** at that point because identifiers had not yet been resolved. This + ** routine is called after identifier resolution. */ - static void sqlite3SelectPrep( - Parse pParse, /* The parser context */ - Select p, /* The SELECT statement being coded. */ - NameContext pOuterNC /* Name context for container */ - ) - { - if ( NEVER( p == null ) ) - return; - //sqlite3 db = pParse.db; - if ( ( p.selFlags & SF_HasTypeInfo ) != 0 ) - return; - sqlite3SelectExpand( pParse, p ); - if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) - return; - sqlite3ResolveSelectNames( pParse, p, pOuterNC ); - if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) - return; - sqlite3SelectAddTypeInfo( pParse, p ); - } + static int selectAddSubqueryTypeInfo(Walker pWalker, Select p) { + Parse pParse; + int i; + SrcList pTabList; + SrcList_item pFrom; + + Debug.Assert((p.selFlags & SF_Resolved) != 0); + if ((p.selFlags & SF_HasTypeInfo) == 0) { + p.selFlags |= SF_HasTypeInfo; + pParse = pWalker.pParse; + pTabList = p.pSrc; + for (i = 0; i < pTabList.nSrc; i++)//, pFrom++ ) + { + pFrom = pTabList.a[i]; + Table pTab = pFrom.pTab; + if (ALWAYS(pTab != null) && (pTab.tabFlags & TF_Ephemeral) != 0) { + /* A sub-query in the FROM clause of a SELECT */ + Select pSel = pFrom.pSelect; + Debug.Assert(pSel != null); + while (pSel.pPrior != null) + pSel = pSel.pPrior; + selectAddColumnTypeAndCollation(pParse, pTab.nCol, pTab.aCol, pSel); + } + } + } + return WRC_Continue; + } +#endif - /* - ** Reset the aggregate accumulator. + + /* + ** This routine adds datatype and collating sequence information to + ** the Table ures of all FROM-clause subqueries in a + ** SELECT statement. ** - ** The aggregate accumulator is a set of memory cells that hold - ** intermediate results while calculating an aggregate. This - ** routine simply stores NULLs in all of those memory cells. + ** Use this routine after name resolution. */ - static void resetAccumulator( Parse pParse, AggInfo pAggInfo ) - { - Vdbe v = pParse.pVdbe; - int i; - AggInfo_func pFunc; - if ( pAggInfo.nFunc + pAggInfo.nColumn == 0 ) - { - return; - } - for ( i = 0; i < pAggInfo.nColumn; i++ ) - { - sqlite3VdbeAddOp2( v, OP_Null, 0, pAggInfo.aCol[i].iMem ); - } - for ( i = 0; i < pAggInfo.nFunc; i++ ) - {//, pFunc++){ - pFunc = pAggInfo.aFunc[i]; - sqlite3VdbeAddOp2( v, OP_Null, 0, pFunc.iMem ); - if ( pFunc.iDistinct >= 0 ) - { - Expr pE = pFunc.pExpr; - Debug.Assert( !ExprHasProperty( pE, EP_xIsSelect ) ); - if ( pE.x.pList == null || pE.x.pList.nExpr != 1 ) - { - sqlite3ErrorMsg( pParse, "DISTINCT aggregates must have exactly one " + - "argument" ); - pFunc.iDistinct = -1; - } - else - { - KeyInfo pKeyInfo = keyInfoFromExprList( pParse, pE.x.pList ); - sqlite3VdbeAddOp4( v, OP_OpenEphemeral, pFunc.iDistinct, 0, 0, - pKeyInfo, P4_KEYINFO_HANDOFF ); - } + static void sqlite3SelectAddTypeInfo(Parse pParse, Select pSelect) { +#if !SQLITE_OMIT_SUBQUERY + Walker w = new Walker(); + w.xSelectCallback = selectAddSubqueryTypeInfo; + w.xExprCallback = exprWalkNoop; + w.pParse = pParse; + sqlite3WalkSelect(w, pSelect); +#endif } - } - } - /* - ** Invoke the OP_AggFinalize opcode for every aggregate function - ** in the AggInfo structure. - */ - static void finalizeAggFunctions( Parse pParse, AggInfo pAggInfo ) - { - Vdbe v = pParse.pVdbe; - int i; - AggInfo_func pF; - for ( i = 0; i < pAggInfo.nFunc; i++ ) - {//, pF++){ - pF = pAggInfo.aFunc[i]; - ExprList pList = pF.pExpr.x.pList; - Debug.Assert( !ExprHasProperty( pF.pExpr, EP_xIsSelect ) ); - sqlite3VdbeAddOp4( v, OP_AggFinal, pF.iMem, pList != null ? pList.nExpr : 0, 0, - pF.pFunc, P4_FUNCDEF ); - } - } - /* - ** Update the accumulator memory cells for an aggregate based on - ** the current cursor position. - */ - static void updateAccumulator( Parse pParse, AggInfo pAggInfo ) - { - Vdbe v = pParse.pVdbe; - int i; - AggInfo_func pF; - AggInfo_col pC; - - pAggInfo.directMode = 1; - sqlite3ExprCacheClear( pParse ); - for ( i = 0; i < pAggInfo.nFunc; i++ ) - {//, pF++){ - pF = pAggInfo.aFunc[i]; - int nArg; - int addrNext = 0; - int regAgg; - Debug.Assert( !ExprHasProperty( pF.pExpr, EP_xIsSelect ) ); - ExprList pList = pF.pExpr.x.pList; - if ( pList != null ) - { - nArg = pList.nExpr; - regAgg = sqlite3GetTempRange( pParse, nArg ); - sqlite3ExprCodeExprList( pParse, pList, regAgg, true ); - } - else - { - nArg = 0; - regAgg = 0; + /* + ** This routine sets of a SELECT statement for processing. The + ** following is accomplished: + ** + ** * VDBE VdbeCursor numbers are assigned to all FROM-clause terms. + ** * Ephemeral Table objects are created for all FROM-clause subqueries. + ** * ON and USING clauses are shifted into WHERE statements + ** * Wildcards "*" and "TABLE.*" in result sets are expanded. + ** * Identifiers in expression are matched to tables. + ** + ** This routine acts recursively on all subqueries within the SELECT. + */ + static void sqlite3SelectPrep( + Parse pParse, /* The parser context */ + Select p, /* The SELECT statement being coded. */ + NameContext pOuterNC /* Name context for container */ + ) { + if (NEVER(p == null)) + return; + //sqlite3 db = pParse.db; + if ((p.selFlags & SF_HasTypeInfo) != 0) + return; + sqlite3SelectExpand(pParse, p); + if (pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) + return; + sqlite3ResolveSelectNames(pParse, p, pOuterNC); + if (pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) + return; + sqlite3SelectAddTypeInfo(pParse, p); } - if ( pF.iDistinct >= 0 ) - { - addrNext = sqlite3VdbeMakeLabel( v ); - Debug.Assert( nArg == 1 ); - codeDistinct( pParse, pF.iDistinct, addrNext, 1, regAgg ); + + /* + ** Reset the aggregate accumulator. + ** + ** The aggregate accumulator is a set of memory cells that hold + ** intermediate results while calculating an aggregate. This + ** routine simply stores NULLs in all of those memory cells. + */ + static void resetAccumulator(Parse pParse, AggInfo pAggInfo) { + Vdbe v = pParse.pVdbe; + int i; + AggInfo_func pFunc; + if (pAggInfo.nFunc + pAggInfo.nColumn == 0) { + return; + } + for (i = 0; i < pAggInfo.nColumn; i++) { + sqlite3VdbeAddOp2(v, OP_Null, 0, pAggInfo.aCol[i].iMem); + } + for (i = 0; i < pAggInfo.nFunc; i++) {//, pFunc++){ + pFunc = pAggInfo.aFunc[i]; + sqlite3VdbeAddOp2(v, OP_Null, 0, pFunc.iMem); + if (pFunc.iDistinct >= 0) { + Expr pE = pFunc.pExpr; + Debug.Assert(!ExprHasProperty(pE, EP_xIsSelect)); + if (pE.x.pList == null || pE.x.pList.nExpr != 1) { + sqlite3ErrorMsg(pParse, "DISTINCT aggregates must have exactly one " + + "argument"); + pFunc.iDistinct = -1; + } else { + KeyInfo pKeyInfo = keyInfoFromExprList(pParse, pE.x.pList); + sqlite3VdbeAddOp4(v, OP_OpenEphemeral, pFunc.iDistinct, 0, 0, + pKeyInfo, P4_KEYINFO_HANDOFF); + } + } + } } - if ( ( pF.pFunc.flags & SQLITE_FUNC_NEEDCOLL ) != 0 ) - { - CollSeq pColl = null; - ExprList_item pItem; - int j; - Debug.Assert( pList != null ); /* pList!=0 if pF->pFunc has NEEDCOLL */ - for ( j = 0; pColl == null && j < nArg; j++ ) - {//, pItem++){ - pItem = pList.a[j]; - pColl = sqlite3ExprCollSeq( pParse, pItem.pExpr ); - } - if ( pColl == null ) - { - pColl = pParse.db.pDfltColl; - } - sqlite3VdbeAddOp4( v, OP_CollSeq, 0, 0, 0, pColl, P4_COLLSEQ ); + + /* + ** Invoke the OP_AggFinalize opcode for every aggregate function + ** in the AggInfo structure. + */ + static void finalizeAggFunctions(Parse pParse, AggInfo pAggInfo) { + Vdbe v = pParse.pVdbe; + int i; + AggInfo_func pF; + for (i = 0; i < pAggInfo.nFunc; i++) {//, pF++){ + pF = pAggInfo.aFunc[i]; + ExprList pList = pF.pExpr.x.pList; + Debug.Assert(!ExprHasProperty(pF.pExpr, EP_xIsSelect)); + sqlite3VdbeAddOp4(v, OP_AggFinal, pF.iMem, pList != null ? pList.nExpr : 0, 0, + pF.pFunc, P4_FUNCDEF); + } } - sqlite3VdbeAddOp4( v, OP_AggStep, 0, regAgg, pF.iMem, - pF.pFunc, P4_FUNCDEF ); - sqlite3VdbeChangeP5( v, (u8)nArg ); - sqlite3ExprCacheAffinityChange( pParse, regAgg, nArg ); - sqlite3ReleaseTempRange( pParse, regAgg, nArg ); - if ( addrNext != 0 ) - { - sqlite3VdbeResolveLabel( v, addrNext ); - sqlite3ExprCacheClear( pParse ); + + /* + ** Update the accumulator memory cells for an aggregate based on + ** the current cursor position. + */ + static void updateAccumulator(Parse pParse, AggInfo pAggInfo) { + Vdbe v = pParse.pVdbe; + int i; + AggInfo_func pF; + AggInfo_col pC; + + pAggInfo.directMode = 1; + sqlite3ExprCacheClear(pParse); + for (i = 0; i < pAggInfo.nFunc; i++) {//, pF++){ + pF = pAggInfo.aFunc[i]; + int nArg; + int addrNext = 0; + int regAgg; + Debug.Assert(!ExprHasProperty(pF.pExpr, EP_xIsSelect)); + ExprList pList = pF.pExpr.x.pList; + if (pList != null) { + nArg = pList.nExpr; + regAgg = sqlite3GetTempRange(pParse, nArg); + sqlite3ExprCodeExprList(pParse, pList, regAgg, true); + } else { + nArg = 0; + regAgg = 0; + } + if (pF.iDistinct >= 0) { + addrNext = sqlite3VdbeMakeLabel(v); + Debug.Assert(nArg == 1); + codeDistinct(pParse, pF.iDistinct, addrNext, 1, regAgg); + } + if ((pF.pFunc.flags & SQLITE_FUNC_NEEDCOLL) != 0) { + CollSeq pColl = null; + ExprList_item pItem; + int j; + Debug.Assert(pList != null); /* pList!=0 if pF->pFunc has NEEDCOLL */ + for (j = 0; pColl == null && j < nArg; j++) {//, pItem++){ + pItem = pList.a[j]; + pColl = sqlite3ExprCollSeq(pParse, pItem.pExpr); + } + if (pColl == null) { + pColl = pParse.db.pDfltColl; + } + sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, pColl, P4_COLLSEQ); + } + sqlite3VdbeAddOp4(v, OP_AggStep, 0, regAgg, pF.iMem, + pF.pFunc, P4_FUNCDEF); + sqlite3VdbeChangeP5(v, (u8)nArg); + sqlite3ExprCacheAffinityChange(pParse, regAgg, nArg); + sqlite3ReleaseTempRange(pParse, regAgg, nArg); + if (addrNext != 0) { + sqlite3VdbeResolveLabel(v, addrNext); + sqlite3ExprCacheClear(pParse); + } + } + + /* Before populating the accumulator registers, clear the column cache. + ** Otherwise, if any of the required column values are already present + ** in registers, sqlite3ExprCode() may use OP_SCopy to copy the value + ** to pC->iMem. But by the time the value is used, the original register + ** may have been used, invalidating the underlying buffer holding the + ** text or blob value. See ticket [883034dcb5]. + ** + ** Another solution would be to change the OP_SCopy used to copy cached + ** values to an OP_Copy. + */ + sqlite3ExprCacheClear(pParse); + for (i = 0; i < pAggInfo.nAccumulator; i++)//, pC++) + { + pC = pAggInfo.aCol[i]; + sqlite3ExprCode(pParse, pC.pExpr, pC.iMem); + } + pAggInfo.directMode = 0; + sqlite3ExprCacheClear(pParse); } - } - - /* Before populating the accumulator registers, clear the column cache. - ** Otherwise, if any of the required column values are already present - ** in registers, sqlite3ExprCode() may use OP_SCopy to copy the value - ** to pC->iMem. But by the time the value is used, the original register - ** may have been used, invalidating the underlying buffer holding the - ** text or blob value. See ticket [883034dcb5]. - ** - ** Another solution would be to change the OP_SCopy used to copy cached - ** values to an OP_Copy. - */ - sqlite3ExprCacheClear( pParse ); - for ( i = 0; i < pAggInfo.nAccumulator; i++ )//, pC++) - { - pC = pAggInfo.aCol[i]; - sqlite3ExprCode( pParse, pC.pExpr, pC.iMem ); - } - pAggInfo.directMode = 0; - sqlite3ExprCacheClear( pParse ); - } - /* - ** Add a single OP_Explain instruction to the VDBE to explain a simple - ** count() query ("SELECT count() FROM pTab"). - */ + /* + ** Add a single OP_Explain instruction to the VDBE to explain a simple + ** count() query ("SELECT count() FROM pTab"). + */ #if !SQLITE_OMIT_EXPLAIN - static void explainSimpleCount( - Parse pParse, /* Parse context */ - Table pTab, /* Table being queried */ - Index pIdx /* Index used to optimize scan, or NULL */ - ) - { - if ( pParse.explain == 2 ) - { - string zEqp = sqlite3MPrintf( pParse.db, "SCAN TABLE %s %s%s(~%d rows)", - pTab.zName, - pIdx != null ? "USING COVERING INDEX " : "", - pIdx != null ? pIdx.zName : "", - pTab.nRowEst - ); - sqlite3VdbeAddOp4( - pParse.pVdbe, OP_Explain, pParse.iSelectId, 0, 0, zEqp, P4_DYNAMIC - ); - } - } + static void explainSimpleCount( + Parse pParse, /* Parse context */ + Table pTab, /* Table being queried */ + Index pIdx /* Index used to optimize scan, or NULL */ + ) { + if (pParse.explain == 2) { + string zEqp = sqlite3MPrintf(pParse.db, "SCAN TABLE %s %s%s(~%d rows)", + pTab.zName, + pIdx != null ? "USING COVERING INDEX " : "", + pIdx != null ? pIdx.zName : "", + pTab.nRowEst + ); + sqlite3VdbeAddOp4( + pParse.pVdbe, OP_Explain, pParse.iSelectId, 0, 0, zEqp, P4_DYNAMIC + ); + } + } #else //# define explainSimpleCount(a,b,c) static void explainSimpleCount(Parse a, Table b, Index c){} #endif - /* - ** Generate code for the SELECT statement given in the p argument. - ** - ** The results are distributed in various ways depending on the - ** contents of the SelectDest structure pointed to by argument pDest - ** as follows: - ** - ** pDest.eDest Result - ** ------------ ------------------------------------------- - ** SRT_Output Generate a row of output (using the OP_ResultRow - ** opcode) for each row in the result set. - ** - ** SRT_Mem Only valid if the result is a single column. - ** Store the first column of the first result row - ** in register pDest.iParm then abandon the rest - ** of the query. This destination implies "LIMIT 1". - ** - ** SRT_Set The result must be a single column. Store each - ** row of result as the key in table pDest.iParm. - ** Apply the affinity pDest.affinity before storing - ** results. Used to implement "IN (SELECT ...)". - ** - ** SRT_Union Store results as a key in a temporary table pDest.iParm. - ** - ** SRT_Except Remove results from the temporary table pDest.iParm. - ** - ** SRT_Table Store results in temporary table pDest.iParm. - ** This is like SRT_EphemTab except that the table - ** is assumed to already be open. - ** - ** SRT_EphemTab Create an temporary table pDest.iParm and store - ** the result there. The cursor is left open after - ** returning. This is like SRT_Table except that - ** this destination uses OP_OpenEphemeral to create - ** the table first. - ** - ** SRT_Coroutine Generate a co-routine that returns a new row of - ** results each time it is invoked. The entry point - ** of the co-routine is stored in register pDest.iParm. - ** - ** SRT_Exists Store a 1 in memory cell pDest.iParm if the result - ** set is not empty. - ** - ** SRT_Discard Throw the results away. This is used by SELECT - ** statements within triggers whose only purpose is - ** the side-effects of functions. - ** - ** This routine returns the number of errors. If any errors are - ** encountered, then an appropriate error message is left in - ** pParse.zErrMsg. - ** - ** This routine does NOT free the Select structure passed in. The - ** calling function needs to do that. - */ - static SelectDest sdDummy = null; - static bool bDummy = false; - - static int sqlite3Select( - Parse pParse, /* The parser context */ - Select p, /* The SELECT statement being coded. */ - ref SelectDest pDest /* What to do with the query results */ - ) - { - int i, j; /* Loop counters */ - WhereInfo pWInfo; /* Return from sqlite3WhereBegin() */ - Vdbe v; /* The virtual machine under construction */ - bool isAgg; /* True for select lists like "count()" */ - ExprList pEList = new ExprList(); /* List of columns to extract. */ - SrcList pTabList = new SrcList(); /* List of tables to select from */ - Expr pWhere; /* The WHERE clause. May be NULL */ - ExprList pOrderBy; /* The ORDER BY clause. May be NULL */ - ExprList pGroupBy; /* The GROUP BY clause. May be NULL */ - Expr pHaving; /* The HAVING clause. May be NULL */ - bool isDistinct; /* True if the DISTINCT keyword is present */ - int distinct; /* Table to use for the distinct set */ - int rc = 1; /* Value to return from this function */ - int addrSortIndex; /* Address of an OP_OpenEphemeral instruction */ - AggInfo sAggInfo; /* Information used by aggregate queries */ - int iEnd; /* Address of the end of the query */ - sqlite3 db; /* The database connection */ + /* + ** Generate code for the SELECT statement given in the p argument. + ** + ** The results are distributed in various ways depending on the + ** contents of the SelectDest structure pointed to by argument pDest + ** as follows: + ** + ** pDest.eDest Result + ** ------------ ------------------------------------------- + ** SRT_Output Generate a row of output (using the OP_ResultRow + ** opcode) for each row in the result set. + ** + ** SRT_Mem Only valid if the result is a single column. + ** Store the first column of the first result row + ** in register pDest.iParm then abandon the rest + ** of the query. This destination implies "LIMIT 1". + ** + ** SRT_Set The result must be a single column. Store each + ** row of result as the key in table pDest.iParm. + ** Apply the affinity pDest.affinity before storing + ** results. Used to implement "IN (SELECT ...)". + ** + ** SRT_Union Store results as a key in a temporary table pDest.iParm. + ** + ** SRT_Except Remove results from the temporary table pDest.iParm. + ** + ** SRT_Table Store results in temporary table pDest.iParm. + ** This is like SRT_EphemTab except that the table + ** is assumed to already be open. + ** + ** SRT_EphemTab Create an temporary table pDest.iParm and store + ** the result there. The cursor is left open after + ** returning. This is like SRT_Table except that + ** this destination uses OP_OpenEphemeral to create + ** the table first. + ** + ** SRT_Coroutine Generate a co-routine that returns a new row of + ** results each time it is invoked. The entry point + ** of the co-routine is stored in register pDest.iParm. + ** + ** SRT_Exists Store a 1 in memory cell pDest.iParm if the result + ** set is not empty. + ** + ** SRT_Discard Throw the results away. This is used by SELECT + ** statements within triggers whose only purpose is + ** the side-effects of functions. + ** + ** This routine returns the number of errors. If any errors are + ** encountered, then an appropriate error message is left in + ** pParse.zErrMsg. + ** + ** This routine does NOT free the Select structure passed in. The + ** calling function needs to do that. + */ + static SelectDest sdDummy = null; + static bool bDummy = false; + + static int sqlite3Select( + Parse pParse, /* The parser context */ + Select p, /* The SELECT statement being coded. */ + ref SelectDest pDest /* What to do with the query results */ + ) { + int i, j; /* Loop counters */ + WhereInfo pWInfo; /* Return from sqlite3WhereBegin() */ + Vdbe v; /* The virtual machine under construction */ + bool isAgg; /* True for select lists like "count()" */ + ExprList pEList = new ExprList(); /* List of columns to extract. */ + SrcList pTabList = new SrcList(); /* List of tables to select from */ + Expr pWhere; /* The WHERE clause. May be NULL */ + ExprList pOrderBy; /* The ORDER BY clause. May be NULL */ + ExprList pGroupBy; /* The GROUP BY clause. May be NULL */ + Expr pHaving; /* The HAVING clause. May be NULL */ + bool isDistinct; /* True if the DISTINCT keyword is present */ + int distinct; /* Table to use for the distinct set */ + int rc = 1; /* Value to return from this function */ + int addrSortIndex; /* Address of an OP_OpenEphemeral instruction */ + AggInfo sAggInfo; /* Information used by aggregate queries */ + int iEnd; /* Address of the end of the query */ + sqlite3 db; /* The database connection */ #if !SQLITE_OMIT_EXPLAIN - int iRestoreSelectId = pParse.iSelectId; - pParse.iSelectId = pParse.iNextSelectId++; + int iRestoreSelectId = pParse.iSelectId; + pParse.iSelectId = pParse.iNextSelectId++; #endif - db = pParse.db; - if ( p == null /*|| db.mallocFailed != 0 */ || pParse.nErr != 0 ) - { - return 1; - } + db = pParse.db; + if (p == null /*|| db.mallocFailed != 0 */ || pParse.nErr != 0) { + return 1; + } #if !SQLITE_OMIT_AUTHORIZATION if (sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0)) return 1; #endif - sAggInfo = new AggInfo();// memset(sAggInfo, 0, sAggInfo).Length; - - if ( pDest.eDest <= SRT_Discard ) //IgnorableOrderby(pDest)) - { - Debug.Assert( pDest.eDest == SRT_Exists || pDest.eDest == SRT_Union || - pDest.eDest == SRT_Except || pDest.eDest == SRT_Discard ); - /* If ORDER BY makes no difference in the output then neither does - ** DISTINCT so it can be removed too. */ - sqlite3ExprListDelete( db, ref p.pOrderBy ); - p.pOrderBy = null; - p.selFlags = (u16)( p.selFlags & ~SF_Distinct ); - } - sqlite3SelectPrep( pParse, p, null ); - pOrderBy = p.pOrderBy; - pTabList = p.pSrc; - pEList = p.pEList; - if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) - { - goto select_end; - } - isAgg = ( p.selFlags & SF_Aggregate ) != 0; - Debug.Assert( pEList != null ); - - /* Begin generating code. - */ - v = sqlite3GetVdbe( pParse ); - if ( v == null ) - goto select_end; + sAggInfo = new AggInfo();// memset(sAggInfo, 0, sAggInfo).Length; - /* If writing to memory or generating a set - ** only a single column may be output. - */ + if (pDest.eDest <= SRT_Discard) //IgnorableOrderby(pDest)) + { + Debug.Assert(pDest.eDest == SRT_Exists || pDest.eDest == SRT_Union || + pDest.eDest == SRT_Except || pDest.eDest == SRT_Discard); + /* If ORDER BY makes no difference in the output then neither does + ** DISTINCT so it can be removed too. */ + sqlite3ExprListDelete(db, ref p.pOrderBy); + p.pOrderBy = null; + p.selFlags = (u16)(p.selFlags & ~SF_Distinct); + } + sqlite3SelectPrep(pParse, p, null); + pOrderBy = p.pOrderBy; + pTabList = p.pSrc; + pEList = p.pEList; + if (pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) { + goto select_end; + } + isAgg = (p.selFlags & SF_Aggregate) != 0; + Debug.Assert(pEList != null); + + /* Begin generating code. + */ + v = sqlite3GetVdbe(pParse); + if (v == null) + goto select_end; + + /* If writing to memory or generating a set + ** only a single column may be output. + */ #if !SQLITE_OMIT_SUBQUERY - if ( checkForMultiColumnSelectError( pParse, pDest, pEList.nExpr ) ) - { - goto select_end; - } + if (checkForMultiColumnSelectError(pParse, pDest, pEList.nExpr)) { + goto select_end; + } #endif - /* Generate code for all sub-queries in the FROM clause -*/ + /* Generate code for all sub-queries in the FROM clause + */ #if !SQLITE_OMIT_SUBQUERY || !SQLITE_OMIT_VIEW - for ( i = 0; p.pPrior == null && i < pTabList.nSrc; i++ ) - { - SrcList_item pItem = pTabList.a[i]; - SelectDest dest = new SelectDest(); - Select pSub = pItem.pSelect; - bool isAggSub; - - if ( pSub == null || pItem.isPopulated != 0 ) - continue; - - /* Increment Parse.nHeight by the height of the largest expression - ** tree refered to by this, the parent select. The child select - ** may contain expression trees of at most - ** (SQLITE_MAX_EXPR_DEPTH-Parse.nHeight) height. This is a bit - ** more conservative than necessary, but much easier than enforcing - ** an exact limit. - */ - pParse.nHeight += sqlite3SelectExprHeight( p ); - - /* Check to see if the subquery can be absorbed into the parent. */ - isAggSub = ( pSub.selFlags & SF_Aggregate ) != 0; - if ( flattenSubquery( pParse, p, i, isAgg, isAggSub ) != 0 ) - { - if ( isAggSub ) - { - isAgg = true; - p.selFlags |= SF_Aggregate; - } - i = -1; - } - else - { - sqlite3SelectDestInit( dest, SRT_EphemTab, pItem.iCursor ); - Debug.Assert( 0 == pItem.isPopulated ); - explainSetInteger( ref pItem.iSelectId, (int)pParse.iNextSelectId ); - sqlite3Select( pParse, pSub, ref dest ); - pItem.isPopulated = 1; - pItem.pTab.nRowEst = (uint)pSub.nSelectRow; - } - //if ( /* pParse.nErr != 0 || */ db.mallocFailed != 0 ) - //{ - // goto select_end; - //} - pParse.nHeight -= sqlite3SelectExprHeight( p ); - pTabList = p.pSrc; - if ( !( pDest.eDest <= SRT_Discard ) )// if( null==IgnorableOrderby(pDest) ) - { - pOrderBy = p.pOrderBy; - } - } - pEList = p.pEList; -#endif - pWhere = p.pWhere; - pGroupBy = p.pGroupBy; - pHaving = p.pHaving; - isDistinct = ( p.selFlags & SF_Distinct ) != 0; + for (i = 0; p.pPrior == null && i < pTabList.nSrc; i++) { + SrcList_item pItem = pTabList.a[i]; + SelectDest dest = new SelectDest(); + Select pSub = pItem.pSelect; + bool isAggSub; -#if !SQLITE_OMIT_COMPOUND_SELECT - /* If there is are a sequence of queries, do the earlier ones first. -*/ - if ( p.pPrior != null ) - { - if ( p.pRightmost == null ) - { - Select pLoop, pRight = null; - int cnt = 0; - int mxSelect; - for ( pLoop = p; pLoop != null; pLoop = pLoop.pPrior, cnt++ ) - { - pLoop.pRightmost = p; - pLoop.pNext = pRight; - pRight = pLoop; - } - mxSelect = db.aLimit[SQLITE_LIMIT_COMPOUND_SELECT]; - if ( mxSelect != 0 && cnt > mxSelect ) - { - sqlite3ErrorMsg( pParse, "too many terms in compound SELECT" ); - goto select_end; - } - } - rc = multiSelect( pParse, p, pDest ); - explainSetInteger( ref pParse.iSelectId, iRestoreSelectId ); - return rc; - } + if (pSub == null || pItem.isPopulated != 0) + continue; + + /* Increment Parse.nHeight by the height of the largest expression + ** tree refered to by this, the parent select. The child select + ** may contain expression trees of at most + ** (SQLITE_MAX_EXPR_DEPTH-Parse.nHeight) height. This is a bit + ** more conservative than necessary, but much easier than enforcing + ** an exact limit. + */ + pParse.nHeight += sqlite3SelectExprHeight(p); + + /* Check to see if the subquery can be absorbed into the parent. */ + isAggSub = (pSub.selFlags & SF_Aggregate) != 0; + if (flattenSubquery(pParse, p, i, isAgg, isAggSub) != 0) { + if (isAggSub) { + isAgg = true; + p.selFlags |= SF_Aggregate; + } + i = -1; + } else { + sqlite3SelectDestInit(dest, SRT_EphemTab, pItem.iCursor); + Debug.Assert(0 == pItem.isPopulated); + explainSetInteger(ref pItem.iSelectId, (int)pParse.iNextSelectId); + sqlite3Select(pParse, pSub, ref dest); + pItem.isPopulated = 1; + pItem.pTab.nRowEst = (uint)pSub.nSelectRow; + } + //if ( /* pParse.nErr != 0 || */ db.mallocFailed != 0 ) + //{ + // goto select_end; + //} + pParse.nHeight -= sqlite3SelectExprHeight(p); + pTabList = p.pSrc; + if (!(pDest.eDest <= SRT_Discard))// if( null==IgnorableOrderby(pDest) ) + { + pOrderBy = p.pOrderBy; + } + } + pEList = p.pEList; #endif + pWhere = p.pWhere; + pGroupBy = p.pGroupBy; + pHaving = p.pHaving; + isDistinct = (p.selFlags & SF_Distinct) != 0; - /* If possible, rewrite the query to use GROUP BY instead of DISTINCT. -** GROUP BY might use an index, DISTINCT never does. -*/ - Debug.Assert( p.pGroupBy == null || ( p.selFlags & SF_Aggregate ) != 0 ); - if ( ( p.selFlags & ( SF_Distinct | SF_Aggregate ) ) == SF_Distinct ) - { - p.pGroupBy = sqlite3ExprListDup( db, p.pEList, 0 ); - pGroupBy = p.pGroupBy; - p.selFlags = (u16)( p.selFlags & ~SF_Distinct ); - } - - /* If there is both a GROUP BY and an ORDER BY clause and they are - ** identical, then disable the ORDER BY clause since the GROUP BY - ** will cause elements to come out in the correct order. This is - ** an optimization - the correct answer should result regardless. - ** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER - ** to disable this optimization for testing purposes. - */ - if ( sqlite3ExprListCompare( p.pGroupBy, pOrderBy ) == 0 - && ( db.flags & SQLITE_GroupByOrder ) == 0 ) - { - pOrderBy = null; - } - - /* If there is an ORDER BY clause, then this sorting - ** index might end up being unused if the data can be - ** extracted in pre-sorted order. If that is the case, then the - ** OP_OpenEphemeral instruction will be changed to an OP_Noop once - ** we figure out that the sorting index is not needed. The addrSortIndex - ** variable is used to facilitate that change. - */ - if ( pOrderBy != null ) - { - KeyInfo pKeyInfo; - pKeyInfo = keyInfoFromExprList( pParse, pOrderBy ); - pOrderBy.iECursor = pParse.nTab++; - p.addrOpenEphm[2] = addrSortIndex = - sqlite3VdbeAddOp4( v, OP_OpenEphemeral, - pOrderBy.iECursor, pOrderBy.nExpr + 2, 0, - pKeyInfo, P4_KEYINFO_HANDOFF ); - } - else - { - addrSortIndex = -1; - } - - /* If the output is destined for a temporary table, open that table. +#if !SQLITE_OMIT_COMPOUND_SELECT + /* If there is are a sequence of queries, do the earlier ones first. */ - if ( pDest.eDest == SRT_EphemTab ) - { - sqlite3VdbeAddOp2( v, OP_OpenEphemeral, pDest.iParm, pEList.nExpr ); - } + if (p.pPrior != null) { + if (p.pRightmost == null) { + Select pLoop, pRight = null; + int cnt = 0; + int mxSelect; + for (pLoop = p; pLoop != null; pLoop = pLoop.pPrior, cnt++) { + pLoop.pRightmost = p; + pLoop.pNext = pRight; + pRight = pLoop; + } + mxSelect = db.aLimit[SQLITE_LIMIT_COMPOUND_SELECT]; + if (mxSelect != 0 && cnt > mxSelect) { + sqlite3ErrorMsg(pParse, "too many terms in compound SELECT"); + goto select_end; + } + } + rc = multiSelect(pParse, p, pDest); + explainSetInteger(ref pParse.iSelectId, iRestoreSelectId); + return rc; + } +#endif - /* Set the limiter. + /* If possible, rewrite the query to use GROUP BY instead of DISTINCT. + ** GROUP BY might use an index, DISTINCT never does. */ - iEnd = sqlite3VdbeMakeLabel( v ); - p.nSelectRow = (double)LARGEST_INT64; - computeLimitRegisters( pParse, p, iEnd ); + Debug.Assert(p.pGroupBy == null || (p.selFlags & SF_Aggregate) != 0); + if ((p.selFlags & (SF_Distinct | SF_Aggregate)) == SF_Distinct) { + p.pGroupBy = sqlite3ExprListDup(db, p.pEList, 0); + pGroupBy = p.pGroupBy; + p.selFlags = (u16)(p.selFlags & ~SF_Distinct); + } - /* Open a virtual index to use for the distinct set. - */ - if ( ( p.selFlags & SF_Distinct ) != 0 ) - { - KeyInfo pKeyInfo; - Debug.Assert( isAgg || pGroupBy != null ); - distinct = pParse.nTab++; - pKeyInfo = keyInfoFromExprList( pParse, p.pEList ); - sqlite3VdbeAddOp4( v, OP_OpenEphemeral, distinct, 0, 0, - pKeyInfo, P4_KEYINFO_HANDOFF ); - sqlite3VdbeChangeP5( v, BTREE_UNORDERED ); - } - else - { - distinct = -1; - } - - /* Aggregate and non-aggregate queries are handled differently */ - if ( !isAgg && pGroupBy == null ) - { - /* This case is for non-aggregate queries - ** Begin the database scan - */ - pWInfo = sqlite3WhereBegin( pParse, pTabList, pWhere, ref pOrderBy, 0 ); - if ( pWInfo == null ) - goto select_end; - if ( pWInfo.nRowOut < p.nSelectRow ) - p.nSelectRow = pWInfo.nRowOut; - - /* If sorting index that was created by a prior OP_OpenEphemeral - ** instruction ended up not being needed, then change the OP_OpenEphemeral - ** into an OP_Noop. - */ - if ( addrSortIndex >= 0 && pOrderBy == null ) - { - sqlite3VdbeChangeToNoop( v, addrSortIndex, 1 ); - p.addrOpenEphm[2] = -1; - } + /* If there is both a GROUP BY and an ORDER BY clause and they are + ** identical, then disable the ORDER BY clause since the GROUP BY + ** will cause elements to come out in the correct order. This is + ** an optimization - the correct answer should result regardless. + ** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER + ** to disable this optimization for testing purposes. + */ + if (sqlite3ExprListCompare(p.pGroupBy, pOrderBy) == 0 + && (db.flags & SQLITE_GroupByOrder) == 0) { + pOrderBy = null; + } - /* Use the standard inner loop - */ - Debug.Assert( !isDistinct ); - selectInnerLoop( pParse, p, pEList, 0, 0, pOrderBy, -1, pDest, - pWInfo.iContinue, pWInfo.iBreak ); + /* If there is an ORDER BY clause, then this sorting + ** index might end up being unused if the data can be + ** extracted in pre-sorted order. If that is the case, then the + ** OP_OpenEphemeral instruction will be changed to an OP_Noop once + ** we figure out that the sorting index is not needed. The addrSortIndex + ** variable is used to facilitate that change. + */ + if (pOrderBy != null) { + KeyInfo pKeyInfo; + pKeyInfo = keyInfoFromExprList(pParse, pOrderBy); + pOrderBy.iECursor = pParse.nTab++; + p.addrOpenEphm[2] = addrSortIndex = + sqlite3VdbeAddOp4(v, OP_OpenEphemeral, + pOrderBy.iECursor, pOrderBy.nExpr + 2, 0, + pKeyInfo, P4_KEYINFO_HANDOFF); + } else { + addrSortIndex = -1; + } - /* End the database scan loop. - */ - sqlite3WhereEnd( pWInfo ); - } - else - { - /* This is the processing for aggregate queries */ - NameContext sNC; /* Name context for processing aggregate information */ - int iAMem; /* First Mem address for storing current GROUP BY */ - int iBMem; /* First Mem address for previous GROUP BY */ - int iUseFlag; /* Mem address holding flag indicating that at least + /* If the output is destined for a temporary table, open that table. + */ + if (pDest.eDest == SRT_EphemTab) { + sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pDest.iParm, pEList.nExpr); + } + + /* Set the limiter. + */ + iEnd = sqlite3VdbeMakeLabel(v); + p.nSelectRow = (double)LARGEST_INT64; + computeLimitRegisters(pParse, p, iEnd); + + /* Open a virtual index to use for the distinct set. + */ + if ((p.selFlags & SF_Distinct) != 0) { + KeyInfo pKeyInfo; + Debug.Assert(isAgg || pGroupBy != null); + distinct = pParse.nTab++; + pKeyInfo = keyInfoFromExprList(pParse, p.pEList); + sqlite3VdbeAddOp4(v, OP_OpenEphemeral, distinct, 0, 0, + pKeyInfo, P4_KEYINFO_HANDOFF); + sqlite3VdbeChangeP5(v, BTREE_UNORDERED); + } else { + distinct = -1; + } + + /* Aggregate and non-aggregate queries are handled differently */ + if (!isAgg && pGroupBy == null) { + /* This case is for non-aggregate queries + ** Begin the database scan + */ + pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, ref pOrderBy, 0); + if (pWInfo == null) + goto select_end; + if (pWInfo.nRowOut < p.nSelectRow) + p.nSelectRow = pWInfo.nRowOut; + + /* If sorting index that was created by a prior OP_OpenEphemeral + ** instruction ended up not being needed, then change the OP_OpenEphemeral + ** into an OP_Noop. + */ + if (addrSortIndex >= 0 && pOrderBy == null) { + sqlite3VdbeChangeToNoop(v, addrSortIndex, 1); + p.addrOpenEphm[2] = -1; + } + + /* Use the standard inner loop + */ + Debug.Assert(!isDistinct); + selectInnerLoop(pParse, p, pEList, 0, 0, pOrderBy, -1, pDest, + pWInfo.iContinue, pWInfo.iBreak); + + /* End the database scan loop. + */ + sqlite3WhereEnd(pWInfo); + } else { + /* This is the processing for aggregate queries */ + NameContext sNC; /* Name context for processing aggregate information */ + int iAMem; /* First Mem address for storing current GROUP BY */ + int iBMem; /* First Mem address for previous GROUP BY */ + int iUseFlag; /* Mem address holding flag indicating that at least ** one row of the input to the aggregator has been ** processed */ - int iAbortFlag; /* Mem address which causes query abort if positive */ - int groupBySort; /* Rows come from source in GR BY' clause thanROUP BY order */ - - int addrEnd; /* End of processing for this SELECT */ + int iAbortFlag; /* Mem address which causes query abort if positive */ + int groupBySort; /* Rows come from source in GR BY' clause thanROUP BY order */ - /* Remove any and all aliases between the result set and the - ** GROUP BY clause. - */ - if ( pGroupBy != null ) - { - int k; /* Loop counter */ - ExprList_item pItem; /* For looping over expression in a list */ - - for ( k = p.pEList.nExpr; k > 0; k-- )//, pItem++) - { - pItem = p.pEList.a[p.pEList.nExpr - k]; - pItem.iAlias = 0; - } - for ( k = pGroupBy.nExpr; k > 0; k-- )//, pItem++ ) - { - pItem = pGroupBy.a[pGroupBy.nExpr - k]; - pItem.iAlias = 0; - } - if ( p.nSelectRow > (double)100 ) - p.nSelectRow = (double)100; - } - else - { - p.nSelectRow = (double)1; - } + int addrEnd; /* End of processing for this SELECT */ - /* Create a label to jump to when we want to abort the query */ - addrEnd = sqlite3VdbeMakeLabel( v ); + /* Remove any and all aliases between the result set and the + ** GROUP BY clause. + */ + if (pGroupBy != null) { + int k; /* Loop counter */ + ExprList_item pItem; /* For looping over expression in a list */ + + for (k = p.pEList.nExpr; k > 0; k--)//, pItem++) + { + pItem = p.pEList.a[p.pEList.nExpr - k]; + pItem.iAlias = 0; + } + for (k = pGroupBy.nExpr; k > 0; k--)//, pItem++ ) + { + pItem = pGroupBy.a[pGroupBy.nExpr - k]; + pItem.iAlias = 0; + } + if (p.nSelectRow > (double)100) + p.nSelectRow = (double)100; + } else { + p.nSelectRow = (double)1; + } - /* Convert TK_COLUMN nodes into TK_AGG_COLUMN and make entries in - ** sAggInfo for all TK_AGG_FUNCTION nodes in expressions of the - ** SELECT statement. - */ - sNC = new NameContext(); // memset(sNC, 0, sNC).Length; - sNC.pParse = pParse; - sNC.pSrcList = pTabList; - sNC.pAggInfo = sAggInfo; - sAggInfo.nSortingColumn = pGroupBy != null ? pGroupBy.nExpr + 1 : 0; - sAggInfo.pGroupBy = pGroupBy; - sqlite3ExprAnalyzeAggList( sNC, pEList ); - sqlite3ExprAnalyzeAggList( sNC, pOrderBy ); - if ( pHaving != null ) - { - sqlite3ExprAnalyzeAggregates( sNC, ref pHaving ); - } - sAggInfo.nAccumulator = sAggInfo.nColumn; - for ( i = 0; i < sAggInfo.nFunc; i++ ) - { - Debug.Assert( !ExprHasProperty( sAggInfo.aFunc[i].pExpr, EP_xIsSelect ) ); - sqlite3ExprAnalyzeAggList( sNC, sAggInfo.aFunc[i].pExpr.x.pList ); - } - // if ( db.mallocFailed != 0 ) goto select_end; + /* Create a label to jump to when we want to abort the query */ + addrEnd = sqlite3VdbeMakeLabel(v); - /* Processing for aggregates with GROUP BY is very different and - ** much more complex than aggregates without a GROUP BY. - */ - if ( pGroupBy != null ) - { - KeyInfo pKeyInfo; /* Keying information for the group by clause */ - int j1; /* A-vs-B comparision jump */ - int addrOutputRow; /* Start of subroutine that outputs a result row */ - int regOutputRow; /* Return address register for output subroutine */ - int addrSetAbort; /* Set the abort flag and return */ - int addrTopOfLoop; /* Top of the input loop */ - int addrSortingIdx; /* The OP_OpenEphemeral for the sorting index */ - int addrReset; /* Subroutine for resetting the accumulator */ - int regReset; /* Return address register for reset subroutine */ - - /* If there is a GROUP BY clause we might need a sorting index to - ** implement it. Allocate that sorting index now. If it turns out - ** that we do not need it after all, the OpenEphemeral instruction - ** will be converted into a Noop. - */ - sAggInfo.sortingIdx = pParse.nTab++; - pKeyInfo = keyInfoFromExprList( pParse, pGroupBy ); - addrSortingIdx = sqlite3VdbeAddOp4( v, OP_OpenEphemeral, - sAggInfo.sortingIdx, sAggInfo.nSortingColumn, - 0, pKeyInfo, P4_KEYINFO_HANDOFF ); + /* Convert TK_COLUMN nodes into TK_AGG_COLUMN and make entries in + ** sAggInfo for all TK_AGG_FUNCTION nodes in expressions of the + ** SELECT statement. + */ + sNC = new NameContext(); // memset(sNC, 0, sNC).Length; + sNC.pParse = pParse; + sNC.pSrcList = pTabList; + sNC.pAggInfo = sAggInfo; + sAggInfo.nSortingColumn = pGroupBy != null ? pGroupBy.nExpr + 1 : 0; + sAggInfo.pGroupBy = pGroupBy; + sqlite3ExprAnalyzeAggList(sNC, pEList); + sqlite3ExprAnalyzeAggList(sNC, pOrderBy); + if (pHaving != null) { + sqlite3ExprAnalyzeAggregates(sNC, ref pHaving); + } + sAggInfo.nAccumulator = sAggInfo.nColumn; + for (i = 0; i < sAggInfo.nFunc; i++) { + Debug.Assert(!ExprHasProperty(sAggInfo.aFunc[i].pExpr, EP_xIsSelect)); + sqlite3ExprAnalyzeAggList(sNC, sAggInfo.aFunc[i].pExpr.x.pList); + } + // if ( db.mallocFailed != 0 ) goto select_end; - /* Initialize memory locations used by GROUP BY aggregate processing - */ - iUseFlag = ++pParse.nMem; - iAbortFlag = ++pParse.nMem; - regOutputRow = ++pParse.nMem; - addrOutputRow = sqlite3VdbeMakeLabel( v ); - regReset = ++pParse.nMem; - addrReset = sqlite3VdbeMakeLabel( v ); - iAMem = pParse.nMem + 1; - pParse.nMem += pGroupBy.nExpr; - iBMem = pParse.nMem + 1; - pParse.nMem += pGroupBy.nExpr; - sqlite3VdbeAddOp2( v, OP_Integer, 0, iAbortFlag ); + /* Processing for aggregates with GROUP BY is very different and + ** much more complex than aggregates without a GROUP BY. + */ + if (pGroupBy != null) { + KeyInfo pKeyInfo; /* Keying information for the group by clause */ + int j1; /* A-vs-B comparision jump */ + int addrOutputRow; /* Start of subroutine that outputs a result row */ + int regOutputRow; /* Return address register for output subroutine */ + int addrSetAbort; /* Set the abort flag and return */ + int addrTopOfLoop; /* Top of the input loop */ + int addrSortingIdx; /* The OP_OpenEphemeral for the sorting index */ + int addrReset; /* Subroutine for resetting the accumulator */ + int regReset; /* Return address register for reset subroutine */ + + /* If there is a GROUP BY clause we might need a sorting index to + ** implement it. Allocate that sorting index now. If it turns out + ** that we do not need it after all, the OpenEphemeral instruction + ** will be converted into a Noop. + */ + sAggInfo.sortingIdx = pParse.nTab++; + pKeyInfo = keyInfoFromExprList(pParse, pGroupBy); + addrSortingIdx = sqlite3VdbeAddOp4(v, OP_OpenEphemeral, + sAggInfo.sortingIdx, sAggInfo.nSortingColumn, + 0, pKeyInfo, P4_KEYINFO_HANDOFF); + + /* Initialize memory locations used by GROUP BY aggregate processing + */ + iUseFlag = ++pParse.nMem; + iAbortFlag = ++pParse.nMem; + regOutputRow = ++pParse.nMem; + addrOutputRow = sqlite3VdbeMakeLabel(v); + regReset = ++pParse.nMem; + addrReset = sqlite3VdbeMakeLabel(v); + iAMem = pParse.nMem + 1; + pParse.nMem += pGroupBy.nExpr; + iBMem = pParse.nMem + 1; + pParse.nMem += pGroupBy.nExpr; + sqlite3VdbeAddOp2(v, OP_Integer, 0, iAbortFlag); #if SQLITE_DEBUG - VdbeComment( v, "clear abort flag" ); + VdbeComment(v, "clear abort flag"); #endif - sqlite3VdbeAddOp2( v, OP_Integer, 0, iUseFlag ); + sqlite3VdbeAddOp2(v, OP_Integer, 0, iUseFlag); #if SQLITE_DEBUG - VdbeComment( v, "indicate accumulator empty" ); + VdbeComment(v, "indicate accumulator empty"); #endif - /* Begin a loop that will extract all source rows in GROUP BY order. -** This might involve two separate loops with an OP_Sort in between, or -** it might be a single loop that uses an index to extract information -** in the right order to begin with. -*/ - sqlite3VdbeAddOp2( v, OP_Gosub, regReset, addrReset ); - pWInfo = sqlite3WhereBegin( pParse, pTabList, pWhere, ref pGroupBy, 0 ); - if ( pWInfo == null ) - goto select_end; - if ( pGroupBy == null ) - { - /* The optimizer is able to deliver rows in group by order so - ** we do not have to sort. The OP_OpenEphemeral table will be - ** cancelled later because we still need to use the pKeyInfo - */ - pGroupBy = p.pGroupBy; - groupBySort = 0; - } - else - { - /* Rows are coming out in undetermined order. We have to push - ** each row into a sorting index, terminate the first loop, - ** then loop over the sorting index in order to get the output - ** in sorted order - */ - int regBase; - int regRecord; - int nCol; - int nGroupBy; - - explainTempTable( pParse, - isDistinct && 0 == ( p.selFlags & SF_Distinct ) ? "DISTINCT" : "GROUP BY" ); - - groupBySort = 1; - nGroupBy = pGroupBy.nExpr; - nCol = nGroupBy + 1; - j = nGroupBy + 1; - for ( i = 0; i < sAggInfo.nColumn; i++ ) - { - if ( sAggInfo.aCol[i].iSorterColumn >= j ) - { - nCol++; - j++; - } - } - regBase = sqlite3GetTempRange( pParse, nCol ); - sqlite3ExprCacheClear( pParse ); - sqlite3ExprCodeExprList( pParse, pGroupBy, regBase, false ); - sqlite3VdbeAddOp2( v, OP_Sequence, sAggInfo.sortingIdx, regBase + nGroupBy ); - j = nGroupBy + 1; - for ( i = 0; i < sAggInfo.nColumn; i++ ) - { - AggInfo_col pCol = sAggInfo.aCol[i]; - if ( pCol.iSorterColumn >= j ) - { - int r1 = j + regBase; - int r2; - r2 = sqlite3ExprCodeGetColumn( pParse, - pCol.pTab, pCol.iColumn, pCol.iTable, r1 ); - if ( r1 != r2 ) - { - sqlite3VdbeAddOp2( v, OP_SCopy, r2, r1 ); - } - j++; - } - } - regRecord = sqlite3GetTempReg( pParse ); - sqlite3VdbeAddOp3( v, OP_MakeRecord, regBase, nCol, regRecord ); - sqlite3VdbeAddOp2( v, OP_IdxInsert, sAggInfo.sortingIdx, regRecord ); - sqlite3ReleaseTempReg( pParse, regRecord ); - sqlite3ReleaseTempRange( pParse, regBase, nCol ); - sqlite3WhereEnd( pWInfo ); - sqlite3VdbeAddOp2( v, OP_Sort, sAggInfo.sortingIdx, addrEnd ); + /* Begin a loop that will extract all source rows in GROUP BY order. + ** This might involve two separate loops with an OP_Sort in between, or + ** it might be a single loop that uses an index to extract information + ** in the right order to begin with. + */ + sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset); + pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, ref pGroupBy, 0); + if (pWInfo == null) + goto select_end; + if (pGroupBy == null) { + /* The optimizer is able to deliver rows in group by order so + ** we do not have to sort. The OP_OpenEphemeral table will be + ** cancelled later because we still need to use the pKeyInfo + */ + pGroupBy = p.pGroupBy; + groupBySort = 0; + } else { + /* Rows are coming out in undetermined order. We have to push + ** each row into a sorting index, terminate the first loop, + ** then loop over the sorting index in order to get the output + ** in sorted order + */ + int regBase; + int regRecord; + int nCol; + int nGroupBy; + + explainTempTable(pParse, + isDistinct && 0 == (p.selFlags & SF_Distinct) ? "DISTINCT" : "GROUP BY"); + + groupBySort = 1; + nGroupBy = pGroupBy.nExpr; + nCol = nGroupBy + 1; + j = nGroupBy + 1; + for (i = 0; i < sAggInfo.nColumn; i++) { + if (sAggInfo.aCol[i].iSorterColumn >= j) { + nCol++; + j++; + } + } + regBase = sqlite3GetTempRange(pParse, nCol); + sqlite3ExprCacheClear(pParse); + sqlite3ExprCodeExprList(pParse, pGroupBy, regBase, false); + sqlite3VdbeAddOp2(v, OP_Sequence, sAggInfo.sortingIdx, regBase + nGroupBy); + j = nGroupBy + 1; + for (i = 0; i < sAggInfo.nColumn; i++) { + AggInfo_col pCol = sAggInfo.aCol[i]; + if (pCol.iSorterColumn >= j) { + int r1 = j + regBase; + int r2; + r2 = sqlite3ExprCodeGetColumn(pParse, + pCol.pTab, pCol.iColumn, pCol.iTable, r1); + if (r1 != r2) { + sqlite3VdbeAddOp2(v, OP_SCopy, r2, r1); + } + j++; + } + } + regRecord = sqlite3GetTempReg(pParse); + sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regRecord); + sqlite3VdbeAddOp2(v, OP_IdxInsert, sAggInfo.sortingIdx, regRecord); + sqlite3ReleaseTempReg(pParse, regRecord); + sqlite3ReleaseTempRange(pParse, regBase, nCol); + sqlite3WhereEnd(pWInfo); + sqlite3VdbeAddOp2(v, OP_Sort, sAggInfo.sortingIdx, addrEnd); #if SQLITE_DEBUG - VdbeComment( v, "GROUP BY sort" ); + VdbeComment(v, "GROUP BY sort"); #endif - sAggInfo.useSortingIdx = 1; - sqlite3ExprCacheClear( pParse ); - } - - /* Evaluate the current GROUP BY terms and store in b0, b1, b2... - ** (b0 is memory location iBMem+0, b1 is iBMem+1, and so forth) - ** Then compare the current GROUP BY terms against the GROUP BY terms - ** from the previous row currently stored in a0, a1, a2... - */ - addrTopOfLoop = sqlite3VdbeCurrentAddr( v ); - sqlite3ExprCacheClear( pParse ); - for ( j = 0; j < pGroupBy.nExpr; j++ ) - { - if ( groupBySort != 0 ) - { - sqlite3VdbeAddOp3( v, OP_Column, sAggInfo.sortingIdx, j, iBMem + j ); - } - else - { - sAggInfo.directMode = 1; - sqlite3ExprCode( pParse, pGroupBy.a[j].pExpr, iBMem + j ); - } - } - sqlite3VdbeAddOp4( v, OP_Compare, iAMem, iBMem, pGroupBy.nExpr, - pKeyInfo, P4_KEYINFO ); - j1 = sqlite3VdbeCurrentAddr( v ); - sqlite3VdbeAddOp3( v, OP_Jump, j1 + 1, 0, j1 + 1 ); - - /* Generate code that runs whenever the GROUP BY changes. - ** Changes in the GROUP BY are detected by the previous code - ** block. If there were no changes, this block is skipped. - ** - ** This code copies current group by terms in b0,b1,b2,... - ** over to a0,a1,a2. It then calls the output subroutine - ** and resets the aggregate accumulator registers in preparation - ** for the next GROUP BY batch. - */ - sqlite3ExprCodeMove( pParse, iBMem, iAMem, pGroupBy.nExpr ); - sqlite3VdbeAddOp2( v, OP_Gosub, regOutputRow, addrOutputRow ); + sAggInfo.useSortingIdx = 1; + sqlite3ExprCacheClear(pParse); + } + + /* Evaluate the current GROUP BY terms and store in b0, b1, b2... + ** (b0 is memory location iBMem+0, b1 is iBMem+1, and so forth) + ** Then compare the current GROUP BY terms against the GROUP BY terms + ** from the previous row currently stored in a0, a1, a2... + */ + addrTopOfLoop = sqlite3VdbeCurrentAddr(v); + sqlite3ExprCacheClear(pParse); + for (j = 0; j < pGroupBy.nExpr; j++) { + if (groupBySort != 0) { + sqlite3VdbeAddOp3(v, OP_Column, sAggInfo.sortingIdx, j, iBMem + j); + } else { + sAggInfo.directMode = 1; + sqlite3ExprCode(pParse, pGroupBy.a[j].pExpr, iBMem + j); + } + } + sqlite3VdbeAddOp4(v, OP_Compare, iAMem, iBMem, pGroupBy.nExpr, + pKeyInfo, P4_KEYINFO); + j1 = sqlite3VdbeCurrentAddr(v); + sqlite3VdbeAddOp3(v, OP_Jump, j1 + 1, 0, j1 + 1); + + /* Generate code that runs whenever the GROUP BY changes. + ** Changes in the GROUP BY are detected by the previous code + ** block. If there were no changes, this block is skipped. + ** + ** This code copies current group by terms in b0,b1,b2,... + ** over to a0,a1,a2. It then calls the output subroutine + ** and resets the aggregate accumulator registers in preparation + ** for the next GROUP BY batch. + */ + sqlite3ExprCodeMove(pParse, iBMem, iAMem, pGroupBy.nExpr); + sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow); #if SQLITE_DEBUG - VdbeComment( v, "output one row" ); + VdbeComment(v, "output one row"); #endif - sqlite3VdbeAddOp2( v, OP_IfPos, iAbortFlag, addrEnd ); + sqlite3VdbeAddOp2(v, OP_IfPos, iAbortFlag, addrEnd); #if SQLITE_DEBUG - VdbeComment( v, "check abort flag" ); + VdbeComment(v, "check abort flag"); #endif - sqlite3VdbeAddOp2( v, OP_Gosub, regReset, addrReset ); + sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset); #if SQLITE_DEBUG - VdbeComment( v, "reset accumulator" ); + VdbeComment(v, "reset accumulator"); #endif - /* Update the aggregate accumulators based on the content of -** the current row -*/ - sqlite3VdbeJumpHere( v, j1 ); - updateAccumulator( pParse, sAggInfo ); - sqlite3VdbeAddOp2( v, OP_Integer, 1, iUseFlag ); + /* Update the aggregate accumulators based on the content of + ** the current row + */ + sqlite3VdbeJumpHere(v, j1); + updateAccumulator(pParse, sAggInfo); + sqlite3VdbeAddOp2(v, OP_Integer, 1, iUseFlag); #if SQLITE_DEBUG - VdbeComment( v, "indicate data in accumulator" ); + VdbeComment(v, "indicate data in accumulator"); #endif - /* End of the loop -*/ - if ( groupBySort != 0 ) - { - sqlite3VdbeAddOp2( v, OP_Next, sAggInfo.sortingIdx, addrTopOfLoop ); - } - else - { - sqlite3WhereEnd( pWInfo ); - sqlite3VdbeChangeToNoop( v, addrSortingIdx, 1 ); - } - - /* Output the final row of result + /* End of the loop */ - sqlite3VdbeAddOp2( v, OP_Gosub, regOutputRow, addrOutputRow ); + if (groupBySort != 0) { + sqlite3VdbeAddOp2(v, OP_Next, sAggInfo.sortingIdx, addrTopOfLoop); + } else { + sqlite3WhereEnd(pWInfo); + sqlite3VdbeChangeToNoop(v, addrSortingIdx, 1); + } + + /* Output the final row of result + */ + sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow); #if SQLITE_DEBUG - VdbeComment( v, "output final row" ); + VdbeComment(v, "output final row"); #endif - /* Jump over the subroutines -*/ - sqlite3VdbeAddOp2( v, OP_Goto, 0, addrEnd ); - - /* Generate a subroutine that outputs a single row of the result - ** set. This subroutine first looks at the iUseFlag. If iUseFlag - ** is less than or equal to zero, the subroutine is a no-op. If - ** the processing calls for the query to abort, this subroutine - ** increments the iAbortFlag memory location before returning in - ** order to signal the caller to abort. + /* Jump over the subroutines */ - addrSetAbort = sqlite3VdbeCurrentAddr( v ); - sqlite3VdbeAddOp2( v, OP_Integer, 1, iAbortFlag ); - VdbeComment( v, "set abort flag" ); - sqlite3VdbeAddOp1( v, OP_Return, regOutputRow ); - sqlite3VdbeResolveLabel( v, addrOutputRow ); - addrOutputRow = sqlite3VdbeCurrentAddr( v ); - sqlite3VdbeAddOp2( v, OP_IfPos, iUseFlag, addrOutputRow + 2 ); - VdbeComment( v, "Groupby result generator entry point" ); - sqlite3VdbeAddOp1( v, OP_Return, regOutputRow ); - finalizeAggFunctions( pParse, sAggInfo ); - sqlite3ExprIfFalse( pParse, pHaving, addrOutputRow + 1, SQLITE_JUMPIFNULL ); - selectInnerLoop( pParse, p, p.pEList, 0, 0, pOrderBy, - distinct, pDest, - addrOutputRow + 1, addrSetAbort ); - sqlite3VdbeAddOp1( v, OP_Return, regOutputRow ); - VdbeComment( v, "end groupby result generator" ); - - /* Generate a subroutine that will reset the group-by accumulator - */ - sqlite3VdbeResolveLabel( v, addrReset ); - resetAccumulator( pParse, sAggInfo ); - sqlite3VdbeAddOp1( v, OP_Return, regReset ); - - } /* endif pGroupBy. Begin aggregate queries without GROUP BY: */ - else - { - ExprList pDel = null; + sqlite3VdbeAddOp2(v, OP_Goto, 0, addrEnd); + + /* Generate a subroutine that outputs a single row of the result + ** set. This subroutine first looks at the iUseFlag. If iUseFlag + ** is less than or equal to zero, the subroutine is a no-op. If + ** the processing calls for the query to abort, this subroutine + ** increments the iAbortFlag memory location before returning in + ** order to signal the caller to abort. + */ + addrSetAbort = sqlite3VdbeCurrentAddr(v); + sqlite3VdbeAddOp2(v, OP_Integer, 1, iAbortFlag); + VdbeComment(v, "set abort flag"); + sqlite3VdbeAddOp1(v, OP_Return, regOutputRow); + sqlite3VdbeResolveLabel(v, addrOutputRow); + addrOutputRow = sqlite3VdbeCurrentAddr(v); + sqlite3VdbeAddOp2(v, OP_IfPos, iUseFlag, addrOutputRow + 2); + VdbeComment(v, "Groupby result generator entry point"); + sqlite3VdbeAddOp1(v, OP_Return, regOutputRow); + finalizeAggFunctions(pParse, sAggInfo); + sqlite3ExprIfFalse(pParse, pHaving, addrOutputRow + 1, SQLITE_JUMPIFNULL); + selectInnerLoop(pParse, p, p.pEList, 0, 0, pOrderBy, + distinct, pDest, + addrOutputRow + 1, addrSetAbort); + sqlite3VdbeAddOp1(v, OP_Return, regOutputRow); + VdbeComment(v, "end groupby result generator"); + + /* Generate a subroutine that will reset the group-by accumulator + */ + sqlite3VdbeResolveLabel(v, addrReset); + resetAccumulator(pParse, sAggInfo); + sqlite3VdbeAddOp1(v, OP_Return, regReset); + + } /* endif pGroupBy. Begin aggregate queries without GROUP BY: */ + else { + ExprList pDel = null; #if !SQLITE_OMIT_BTREECOUNT - Table pTab; - if ( ( pTab = isSimpleCount( p, sAggInfo ) ) != null ) - { - /* If isSimpleCount() returns a pointer to a Table structure, then - ** the SQL statement is of the form: - ** - ** SELECT count() FROM - ** - ** where the Table structure returned represents table . - ** - ** This statement is so common that it is optimized specially. The - ** OP_Count instruction is executed either on the intkey table that - ** contains the data for table or on one of its indexes. It - ** is better to execute the op on an index, as indexes are almost - ** always spread across less pages than their corresponding tables. - */ - int iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema ); - int iCsr = pParse.nTab++; /* Cursor to scan b-tree */ - Index pIdx; /* Iterator variable */ - KeyInfo pKeyInfo = null; /* Keyinfo for scanned index */ - Index pBest = null; /* Best index found so far */ - 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 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. - ** - ** In practice the KeyInfo structure will not be used. It is only - ** passed to keep OP_OpenRead happy. - */ - for ( pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext ) - { - if ( pIdx.bUnordered == 0 && ( null == pBest || pIdx.nColumn < pBest.nColumn ) ) - { - pBest = pIdx; - } - } - if ( pBest != null && pBest.nColumn < pTab.nCol ) - { - iRoot = pBest.tnum; - pKeyInfo = sqlite3IndexKeyinfo( pParse, pBest ); - } - - /* Open a read-only cursor, execute the OP_Count, close the cursor. */ - sqlite3VdbeAddOp3( v, OP_OpenRead, iCsr, iRoot, iDb ); - if ( pKeyInfo != null ) - { - sqlite3VdbeChangeP4( v, -1, pKeyInfo, P4_KEYINFO_HANDOFF ); - } - sqlite3VdbeAddOp2( v, OP_Count, iCsr, sAggInfo.aFunc[0].iMem ); - sqlite3VdbeAddOp1( v, OP_Close, iCsr ); - explainSimpleCount( pParse, pTab, pBest ); - } - else + Table pTab; + if ((pTab = isSimpleCount(p, sAggInfo)) != null) { + /* If isSimpleCount() returns a pointer to a Table structure, then + ** the SQL statement is of the form: + ** + ** SELECT count() FROM + ** + ** where the Table structure returned represents table . + ** + ** This statement is so common that it is optimized specially. The + ** OP_Count instruction is executed either on the intkey table that + ** contains the data for table or on one of its indexes. It + ** is better to execute the op on an index, as indexes are almost + ** always spread across less pages than their corresponding tables. + */ + int iDb = sqlite3SchemaToIndex(pParse.db, pTab.pSchema); + int iCsr = pParse.nTab++; /* Cursor to scan b-tree */ + Index pIdx; /* Iterator variable */ + KeyInfo pKeyInfo = null; /* Keyinfo for scanned index */ + Index pBest = null; /* Best index found so far */ + 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 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. + ** + ** In practice the KeyInfo structure will not be used. It is only + ** passed to keep OP_OpenRead happy. + */ + for (pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext) { + if (pIdx.bUnordered == 0 && (null == pBest || pIdx.nColumn < pBest.nColumn)) { + pBest = pIdx; + } + } + if (pBest != null && pBest.nColumn < pTab.nCol) { + iRoot = pBest.tnum; + pKeyInfo = sqlite3IndexKeyinfo(pParse, pBest); + } + + /* Open a read-only cursor, execute the OP_Count, close the cursor. */ + sqlite3VdbeAddOp3(v, OP_OpenRead, iCsr, iRoot, iDb); + if (pKeyInfo != null) { + sqlite3VdbeChangeP4(v, -1, pKeyInfo, P4_KEYINFO_HANDOFF); + } + sqlite3VdbeAddOp2(v, OP_Count, iCsr, sAggInfo.aFunc[0].iMem); + sqlite3VdbeAddOp1(v, OP_Close, iCsr); + explainSimpleCount(pParse, pTab, pBest); + } else #endif //* SQLITE_OMIT_BTREECOUNT */ - { - - /* Check if the query is of one of the following forms: - ** - ** SELECT min(x) FROM ... - ** SELECT max(x) FROM ... - ** - ** If it is, then ask the code in where.c to attempt to sort results - ** as if there was an "ORDER ON x" or "ORDER ON x DESC" clause. - ** If where.c is able to produce results sorted in this order, then - ** add vdbe code to break out of the processing loop after the - ** first iteration (since the first iteration of the loop is - ** guaranteed to operate on the row with the minimum or maximum - ** value of x, the only row required). - ** - ** A special flag must be passed to sqlite3WhereBegin() to slightly - ** modify behavior as follows: - ** - ** + If the query is a "SELECT min(x)", then the loop coded by - ** where.c should not iterate over any values with a NULL value - ** for x. - ** - ** + The optimizer code in where.c (the thing that decides which - ** index or indices to use) should place a different priority on - ** satisfying the 'ORDER BY' clause than it does in other cases. - ** Refer to code and comments in where.c for details. - */ - ExprList pMinMax = null; - int flag = minMaxQuery( p ); - if ( flag != 0 ) - { - Debug.Assert( !ExprHasProperty( p.pEList.a[0].pExpr, EP_xIsSelect ) ); - pMinMax = sqlite3ExprListDup( db, p.pEList.a[0].pExpr.x.pList, 0 ); - pDel = pMinMax; - if ( pMinMax != null )///* && 0 == db.mallocFailed */ ) - { - pMinMax.a[0].sortOrder = (u8)( flag != WHERE_ORDERBY_MIN ? 1 : 0 ); - pMinMax.a[0].pExpr.op = TK_COLUMN; - } - } - - /* This case runs if the aggregate has no GROUP BY clause. The - ** processing is much simpler since there is only a single row - ** of output. - */ - resetAccumulator( pParse, sAggInfo ); - pWInfo = sqlite3WhereBegin( pParse, pTabList, pWhere, ref pMinMax, (byte)flag ); - if ( pWInfo == null ) - { - sqlite3ExprListDelete( db, ref pDel ); - goto select_end; - } - updateAccumulator( pParse, sAggInfo ); - if ( pMinMax == null && flag != 0 ) - { - sqlite3VdbeAddOp2( v, OP_Goto, 0, pWInfo.iBreak ); + { + + /* Check if the query is of one of the following forms: + ** + ** SELECT min(x) FROM ... + ** SELECT max(x) FROM ... + ** + ** If it is, then ask the code in where.c to attempt to sort results + ** as if there was an "ORDER ON x" or "ORDER ON x DESC" clause. + ** If where.c is able to produce results sorted in this order, then + ** add vdbe code to break out of the processing loop after the + ** first iteration (since the first iteration of the loop is + ** guaranteed to operate on the row with the minimum or maximum + ** value of x, the only row required). + ** + ** A special flag must be passed to sqlite3WhereBegin() to slightly + ** modify behavior as follows: + ** + ** + If the query is a "SELECT min(x)", then the loop coded by + ** where.c should not iterate over any values with a NULL value + ** for x. + ** + ** + The optimizer code in where.c (the thing that decides which + ** index or indices to use) should place a different priority on + ** satisfying the 'ORDER BY' clause than it does in other cases. + ** Refer to code and comments in where.c for details. + */ + ExprList pMinMax = null; + int flag = minMaxQuery(p); + if (flag != 0) { + Debug.Assert(!ExprHasProperty(p.pEList.a[0].pExpr, EP_xIsSelect)); + pMinMax = sqlite3ExprListDup(db, p.pEList.a[0].pExpr.x.pList, 0); + pDel = pMinMax; + if (pMinMax != null)///* && 0 == db.mallocFailed */ ) + { + pMinMax.a[0].sortOrder = (u8)(flag != WHERE_ORDERBY_MIN ? 1 : 0); + pMinMax.a[0].pExpr.op = TK_COLUMN; + } + } + + /* This case runs if the aggregate has no GROUP BY clause. The + ** processing is much simpler since there is only a single row + ** of output. + */ + resetAccumulator(pParse, sAggInfo); + pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, ref pMinMax, (byte)flag); + if (pWInfo == null) { + sqlite3ExprListDelete(db, ref pDel); + goto select_end; + } + updateAccumulator(pParse, sAggInfo); + if (pMinMax == null && flag != 0) { + sqlite3VdbeAddOp2(v, OP_Goto, 0, pWInfo.iBreak); #if SQLITE_DEBUG - VdbeComment( v, "%s() by index", - ( flag == WHERE_ORDERBY_MIN ? "min" : "max" ) ); + VdbeComment(v, "%s() by index", + (flag == WHERE_ORDERBY_MIN ? "min" : "max")); #endif - } - sqlite3WhereEnd( pWInfo ); - finalizeAggFunctions( pParse, sAggInfo ); - } + } + sqlite3WhereEnd(pWInfo); + finalizeAggFunctions(pParse, sAggInfo); + } - pOrderBy = null; - sqlite3ExprIfFalse( pParse, pHaving, addrEnd, SQLITE_JUMPIFNULL ); - selectInnerLoop( pParse, p, p.pEList, 0, 0, null, -1, - pDest, addrEnd, addrEnd ); + pOrderBy = null; + sqlite3ExprIfFalse(pParse, pHaving, addrEnd, SQLITE_JUMPIFNULL); + selectInnerLoop(pParse, p, p.pEList, 0, 0, null, -1, + pDest, addrEnd, addrEnd); - sqlite3ExprListDelete( db, ref pDel ); - } - sqlite3VdbeResolveLabel( v, addrEnd ); + sqlite3ExprListDelete(db, ref pDel); + } + sqlite3VdbeResolveLabel(v, addrEnd); - } /* endif aggregate query */ + } /* endif aggregate query */ - if ( distinct >= 0 ) - { - explainTempTable( pParse, "DISTINCT" ); - } + if (distinct >= 0) { + explainTempTable(pParse, "DISTINCT"); + } - /* If there is an ORDER BY clause, then we need to sort the results - ** and send them to the callback one by one. - */ - if ( pOrderBy != null ) - { - explainTempTable( pParse, "ORDER BY" ); - generateSortTail( pParse, p, v, pEList.nExpr, pDest ); - } + /* If there is an ORDER BY clause, then we need to sort the results + ** and send them to the callback one by one. + */ + if (pOrderBy != null) { + explainTempTable(pParse, "ORDER BY"); + generateSortTail(pParse, p, v, pEList.nExpr, pDest); + } - /* Jump here to skip this query - */ - sqlite3VdbeResolveLabel( v, iEnd ); + /* Jump here to skip this query + */ + sqlite3VdbeResolveLabel(v, iEnd); - /* The SELECT was successfully coded. Set the return code to 0 - ** to indicate no errors. - */ - rc = 0; + /* The SELECT was successfully coded. Set the return code to 0 + ** to indicate no errors. + */ + rc = 0; - /* Control jumps to here if an error is encountered above, or upon - ** successful coding of the SELECT. - */ -select_end: - explainSetInteger( ref pParse.iSelectId, iRestoreSelectId ); + /* Control jumps to here if an error is encountered above, or upon + ** successful coding of the SELECT. + */ + select_end: + explainSetInteger(ref pParse.iSelectId, iRestoreSelectId); - /* Identify column names if results of the SELECT are to be output. - */ - if ( rc == SQLITE_OK && pDest.eDest == SRT_Output ) - { - generateColumnNames( pParse, pTabList, pEList ); - } - - sqlite3DbFree( db, ref sAggInfo.aCol ); - sqlite3DbFree( db, ref sAggInfo.aFunc ); - return rc; - } + /* Identify column names if results of the SELECT are to be output. + */ + if (rc == SQLITE_OK && pDest.eDest == SRT_Output) { + generateColumnNames(pParse, pTabList, pEList); + } + + sqlite3DbFree(db, ref sAggInfo.aCol); + sqlite3DbFree(db, ref sAggInfo.aFunc); + return rc; + } #if SQLITE_DEBUG - /* -******************************************************************************* -** The following code is used for testing and debugging only. The code -** that follows does not appear in normal builds. -** -** These routines are used to print out the content of all or part of a -** parse structures such as Select or Expr. Such printouts are useful -** for helping to understand what is happening inside the code generator -** during the execution of complex SELECT statements. -** -** These routine are not called anywhere from within the normal -** code base. Then are intended to be called from within the debugger -** or from temporary "printf" statements inserted for debugging. -*/ - void sqlite3PrintExpr( Expr p ) - { - if ( !ExprHasProperty( p, EP_IntValue ) && p.u.zToken != null ) - { - sqlite3DebugPrintf( "(%s", p.u.zToken ); - } - else - { - sqlite3DebugPrintf( "(%d", p.op ); - } - if ( p.pLeft != null ) - { - sqlite3DebugPrintf( " " ); - sqlite3PrintExpr( p.pLeft ); - } - if ( p.pRight != null ) - { - sqlite3DebugPrintf( " " ); - sqlite3PrintExpr( p.pRight ); - } - sqlite3DebugPrintf( ")" ); - } - void sqlite3PrintExprList( ExprList pList ) - { - int i; - for ( i = 0; i < pList.nExpr; i++ ) - { - sqlite3PrintExpr( pList.a[i].pExpr ); - if ( i < pList.nExpr - 1 ) - { - sqlite3DebugPrintf( ", " ); + /* + ******************************************************************************* + ** The following code is used for testing and debugging only. The code + ** that follows does not appear in normal builds. + ** + ** These routines are used to print out the content of all or part of a + ** parse structures such as Select or Expr. Such printouts are useful + ** for helping to understand what is happening inside the code generator + ** during the execution of complex SELECT statements. + ** + ** These routine are not called anywhere from within the normal + ** code base. Then are intended to be called from within the debugger + ** or from temporary "printf" statements inserted for debugging. + */ + void sqlite3PrintExpr(Expr p) { + if (!ExprHasProperty(p, EP_IntValue) && p.u.zToken != null) { + sqlite3DebugPrintf("(%s", p.u.zToken); + } else { + sqlite3DebugPrintf("(%d", p.op); + } + if (p.pLeft != null) { + sqlite3DebugPrintf(" "); + sqlite3PrintExpr(p.pLeft); + } + if (p.pRight != null) { + sqlite3DebugPrintf(" "); + sqlite3PrintExpr(p.pRight); + } + sqlite3DebugPrintf(")"); } - } - } - void sqlite3PrintSelect( Select p, int indent ) - { - sqlite3DebugPrintf( "%*sSELECT(%p) ", indent, "", p ); - sqlite3PrintExprList( p.pEList ); - sqlite3DebugPrintf( "\n" ); - if ( p.pSrc != null ) - { - string zPrefix; - int i; - zPrefix = "FROM"; - for ( i = 0; i < p.pSrc.nSrc; i++ ) - { - SrcList_item pItem = p.pSrc.a[i]; - sqlite3DebugPrintf( "%*s ", indent + 6, zPrefix ); - zPrefix = ""; - if ( pItem.pSelect != null ) - { - sqlite3DebugPrintf( "(\n" ); - sqlite3PrintSelect( pItem.pSelect, indent + 10 ); - sqlite3DebugPrintf( "%*s)", indent + 8, "" ); - } - else if ( pItem.zName != null ) - { - sqlite3DebugPrintf( "%s", pItem.zName ); - } - if ( pItem.pTab != null ) - { - sqlite3DebugPrintf( "(vtable: %s)", pItem.pTab.zName ); - } - if ( pItem.zAlias != null ) - { - sqlite3DebugPrintf( " AS %s", pItem.zAlias ); - } - if ( i < p.pSrc.nSrc - 1 ) - { - sqlite3DebugPrintf( "," ); - } - sqlite3DebugPrintf( "\n" ); + void sqlite3PrintExprList(ExprList pList) { + int i; + for (i = 0; i < pList.nExpr; i++) { + sqlite3PrintExpr(pList.a[i].pExpr); + if (i < pList.nExpr - 1) { + sqlite3DebugPrintf(", "); + } + } } - } - if ( p.pWhere != null ) - { - sqlite3DebugPrintf( "%*s WHERE ", indent, "" ); - sqlite3PrintExpr( p.pWhere ); - sqlite3DebugPrintf( "\n" ); - } - if ( p.pGroupBy != null ) - { - sqlite3DebugPrintf( "%*s GROUP BY ", indent, "" ); - sqlite3PrintExprList( p.pGroupBy ); - sqlite3DebugPrintf( "\n" ); - } - if ( p.pHaving != null ) - { - sqlite3DebugPrintf( "%*s HAVING ", indent, "" ); - sqlite3PrintExpr( p.pHaving ); - sqlite3DebugPrintf( "\n" ); - } - if ( p.pOrderBy != null ) - { - sqlite3DebugPrintf( "%*s ORDER BY ", indent, "" ); - sqlite3PrintExprList( p.pOrderBy ); - sqlite3DebugPrintf( "\n" ); - } - } - /* End of the structure debug printing code - *****************************************************************************/ + void sqlite3PrintSelect(Select p, int indent) { + sqlite3DebugPrintf("%*sSELECT(%p) ", indent, "", p); + sqlite3PrintExprList(p.pEList); + sqlite3DebugPrintf("\n"); + if (p.pSrc != null) { + string zPrefix; + int i; + zPrefix = "FROM"; + for (i = 0; i < p.pSrc.nSrc; i++) { + SrcList_item pItem = p.pSrc.a[i]; + sqlite3DebugPrintf("%*s ", indent + 6, zPrefix); + zPrefix = ""; + if (pItem.pSelect != null) { + sqlite3DebugPrintf("(\n"); + sqlite3PrintSelect(pItem.pSelect, indent + 10); + sqlite3DebugPrintf("%*s)", indent + 8, ""); + } else if (pItem.zName != null) { + sqlite3DebugPrintf("%s", pItem.zName); + } + if (pItem.pTab != null) { + sqlite3DebugPrintf("(vtable: %s)", pItem.pTab.zName); + } + if (pItem.zAlias != null) { + sqlite3DebugPrintf(" AS %s", pItem.zAlias); + } + if (i < p.pSrc.nSrc - 1) { + sqlite3DebugPrintf(","); + } + sqlite3DebugPrintf("\n"); + } + } + if (p.pWhere != null) { + sqlite3DebugPrintf("%*s WHERE ", indent, ""); + sqlite3PrintExpr(p.pWhere); + sqlite3DebugPrintf("\n"); + } + if (p.pGroupBy != null) { + sqlite3DebugPrintf("%*s GROUP BY ", indent, ""); + sqlite3PrintExprList(p.pGroupBy); + sqlite3DebugPrintf("\n"); + } + if (p.pHaving != null) { + sqlite3DebugPrintf("%*s HAVING ", indent, ""); + sqlite3PrintExpr(p.pHaving); + sqlite3DebugPrintf("\n"); + } + if (p.pOrderBy != null) { + sqlite3DebugPrintf("%*s ORDER BY ", indent, ""); + sqlite3PrintExprList(p.pOrderBy); + sqlite3DebugPrintf("\n"); + } + } + /* End of the structure debug printing code + *****************************************************************************/ #endif // * defined(SQLITE_TEST) || defined(SQLITE_DEBUG) */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/sqlite3_h.cs b/Src/IronPython.SQLite/c#sqlite/sqlite3_h.cs index c3a2b1e69..5b84c4e85 100644 --- a/Src/IronPython.SQLite/c#sqlite/sqlite3_h.cs +++ b/Src/IronPython.SQLite/c#sqlite/sqlite3_h.cs @@ -1,705 +1,703 @@ -using u8 = System.Byte; using System.Diagnostics; -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 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. - ** - ************************************************************************* - ** This header file defines the interface that the SQLite library - ** presents to client programs. If a C-function, structure, datatype, - ** or constant definition does not appear in this file, then it is - ** not a published API of SQLite, is subject to change without - ** notice, and should not be referenced by programs that use SQLite. - ** - ** Some of the definitions that are in this file are marked as - ** "experimental". Experimental interfaces are normally new - ** features recently added to SQLite. We do not anticipate changes - ** to experimental interfaces but reserve the right to make minor changes - ** if experience from use "in the wild" suggest such changes are prudent. - ** - ** The official C-language API documentation for SQLite is derived - ** from comments in this file. This file is the authoritative source - ** on how SQLite interfaces are suppose to operate. - ** - ** The name of this file under configuration management is "sqlite.h.in". - ** The makefile makes some minor changes to this file (such as inserting - ** the version number) and changes its name to "sqlite3.h" as - ** part of the build process. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#if !_SQLITE3_H_ - //#define _SQLITE3_H_ - //#include /* Needed for the definition of va_list */ - - /* - ** Make sure we can call this stuff from C++. - */ - //#if __cplusplus - //extern "C" { - //#endif - - - /* - ** Add the ability to override 'extern' - */ - //#if !SQLITE_EXTERN - //# define SQLITE_EXTERN extern - //#endif - - //#if !SQLITE_API - //# define SQLITE_API - //#endif - - - /* - ** These no-op macros are used in front of interfaces to mark those - ** interfaces as either deprecated or experimental. New applications - ** should not use deprecated interfaces - they are support for backwards - ** compatibility only. Application writers should be aware that - ** experimental interfaces are subject to change in point releases. - ** - ** These macros used to resolve to various kinds of compiler magic that - ** would generate warning messages when they were used. But that - ** compiler magic ended up generating such a flurry of bug reports - ** that we have taken it all out and gone back to using simple - ** noop macros. - */ - //#define SQLITE_DEPRECATED - //#define SQLITE_EXPERIMENTAL - - /* - ** Ensure these symbols were not defined by some previous header file. - */ - //#if SQLITE_VERSION - //# undef SQLITE_VERSION - //#endif - //#if SQLITE_VERSION_NUMBER - //# undef SQLITE_VERSION_NUMBER - //#endif - - /* - ** CAPI3REF: Compile-Time Library Version Numbers - ** - ** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header - ** evaluates to a string literal that is the SQLite version in the - ** format "X.Y.Z" where X is the major version number (always 3 for - ** SQLite3) and Y is the minor version number and Z is the release number.)^ - ** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer - ** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same - ** numbers used in [SQLITE_VERSION].)^ - ** The SQLITE_VERSION_NUMBER for any given release of SQLite will also - ** be larger than the release from which it is derived. Either Y will - ** be held constant and Z will be incremented or else Y will be incremented - ** and Z will be reset to zero. - ** - ** Since version 3.6.18, SQLite source code has been stored in the - ** Fossil configuration management - ** system. ^The SQLITE_SOURCE_ID macro evaluates to - ** a string which identifies a particular check-in of SQLite - ** within its configuration management system. ^The SQLITE_SOURCE_ID - ** string contains the date and time of the check-in (UTC) and an SHA1 - ** hash of the entire source tree. - ** - ** See also: [sqlite3_libversion()], - ** [sqlite3_libversion_number()], [sqlite3_sourceid()], - ** [sqlite_version()] and [sqlite_source_id()]. - */ - //#define SQLITE_VERSION "3.7.7" - //#define SQLITE_VERSION_NUMBER 3007007 - //#define SQLITE_SOURCE_ID "2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2" - public const string SQLITE_VERSION = "3.7.7(C#)"; - public const int SQLITE_VERSION_NUMBER = 300700701; - public const string SQLITE_SOURCE_ID = "2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2"; - - /* - ** CAPI3REF: Run-Time Library Version Numbers - ** KEYWORDS: sqlite3_version, sqlite3_sourceid - ** - ** These interfaces provide the same information as the [SQLITE_VERSION], - ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros - ** but are associated with the library instead of the header file. ^(Cautious - ** programmers might include Debug.Assert() statements in their application to - ** verify that values returned by these interfaces match the macros in - ** the header, and thus insure that the application is - ** compiled with matching library and header files. - ** - **
-    ** Debug.Assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
-    ** Debug.Assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
-    ** Debug.Assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
-    ** 
)^ - ** - ** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION] - ** macro. ^The sqlite3_libversion() function returns a pointer to the - ** to the sqlite3_version[] string constant. The sqlite3_libversion() - ** function is provided for use in DLLs since DLL users usually do not have - ** direct access to string constants within the DLL. ^The - ** sqlite3_libversion_number() function returns an integer equal to - ** [SQLITE_VERSION_NUMBER]. ^The sqlite3_sourceid() function returns - ** a pointer to a string constant whose value is the same as the - ** [SQLITE_SOURCE_ID] C preprocessor macro. - ** - ** See also: [sqlite_version()] and [sqlite_source_id()]. - */ - //SQLITE_API SQLITE_EXTERN const char sqlite3_version[]; - //SQLITE_API string sqlite3_libversion(void); - //SQLITE_API string sqlite3_sourceid(void); - //SQLITE_API int sqlite3_libversion_number(void); - - /* - ** CAPI3REF: Run-Time Library Compilation Options Diagnostics - ** - ** ^The sqlite3_compileoption_used() function returns 0 or 1 - ** indicating whether the specified option was defined at - ** compile time. ^The SQLITE_ prefix may be omitted from the - ** option name passed to sqlite3_compileoption_used(). - ** - ** ^The sqlite3_compileoption_get() function allows iterating - ** over the list of options that were defined at compile time by - ** returning the N-th compile time option string. ^If N is out of range, - ** sqlite3_compileoption_get() returns a NULL pointer. ^The SQLITE_ - ** prefix is omitted from any strings returned by - ** sqlite3_compileoption_get(). - ** - ** ^Support for the diagnostic functions sqlite3_compileoption_used() - ** and sqlite3_compileoption_get() may be omitted by specifying the - ** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time. - ** - ** See also: SQL functions [sqlite_compileoption_used()] and - ** [sqlite_compileoption_get()] and the [compile_options pragma]. - */ - //#if !SQLITE_OMIT_COMPILEOPTION_DIAGS - //SQLITE_API int sqlite3_compileoption_used(string zOptName); - //SQLITE_API string sqlite3_compileoption_get(int N); - //#endif - - /* - ** CAPI3REF: Test To See If The Library Is Threadsafe - ** - ** ^The sqlite3_threadsafe() function returns zero if and only if - ** SQLite was compiled mutexing code omitted due to the - ** [SQLITE_THREADSAFE] compile-time option being set to 0. - ** - ** SQLite can be compiled with or without mutexes. When - ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes - ** are enabled and SQLite is threadsafe. When the - ** [SQLITE_THREADSAFE] macro is 0, - ** the mutexes are omitted. Without the mutexes, it is not safe - ** to use SQLite concurrently from more than one thread. - ** - ** Enabling mutexes incurs a measurable performance penalty. - ** So if speed is of utmost importance, it makes sense to disable - ** the mutexes. But for maximum safety, mutexes should be enabled. - ** ^The default behavior is for mutexes to be enabled. - ** - ** This interface can be used by an application to make sure that the - ** version of SQLite that it is linking against was compiled with - ** the desired setting of the [SQLITE_THREADSAFE] macro. - ** - ** This interface only reports on the compile-time mutex setting - ** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with - ** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but - ** can be fully or partially disabled using a call to [sqlite3_config()] - ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD], - ** or [SQLITE_CONFIG_MUTEX]. ^(The return value of the - ** sqlite3_threadsafe() function shows only the compile-time setting of - ** thread safety, not any run-time changes to that setting made by - ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe() - ** is unchanged by calls to sqlite3_config().)^ - ** - ** See the [threading mode] documentation for additional information. - */ - //SQLITE_API int sqlite3_threadsafe(void); - - /* - ** CAPI3REF: Database Connection Handle - ** KEYWORDS: {database connection} {database connections} - ** - ** Each open SQLite database is represented by a pointer to an instance of - ** the opaque structure named "sqlite3". It is useful to think of an sqlite3 - ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and - ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()] - ** is its destructor. There are many other interfaces (such as - ** [sqlite3_prepare_v2()], [sqlite3_create_function()], and - ** [sqlite3_busy_timeout()] to name but three) that are methods on an - ** sqlite3 object. - */ - //typedef struct sqlite3 sqlite3; - - /* - ** CAPI3REF: 64-Bit Integer Types - ** KEYWORDS: sqlite_int64 sqlite_uint64 - ** - ** Because there is no cross-platform way to specify 64-bit integer types - ** SQLite includes typedefs for 64-bit signed and unsigned integers. - ** - ** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions. - ** The sqlite_int64 and sqlite_uint64 types are supported for backwards - ** compatibility only. - ** - ** ^The sqlite3_int64 and sqlite_int64 types can store integer values - ** between -9223372036854775808 and +9223372036854775807 inclusive. ^The - ** sqlite3_uint64 and sqlite_uint64 types can store integer values - ** between 0 and +18446744073709551615 inclusive. - */ - //#if SQLITE_INT64_TYPE - // typedef SQLITE_INT64_TYPE sqlite_int64; - // typedef unsigned SQLITE_INT64_TYPE sqlite_uint64; - //#elif defined(_MSC_VER) || defined(__BORLANDC__) - // typedef __int64 sqlite_int64; - // typedef unsigned __int64 sqlite_uint64; - //#else - // typedef long long int sqlite_int64; - // typedef unsigned long long int sqlite_uint64; - //#endif - //typedef sqlite_int64 sqlite3_int64; - //typedef sqlite_uint64 sqlite3_uint64; - - /* - ** If compiling for a processor that lacks floating point support, - ** substitute integer for floating-point. - */ - //#if SQLITE_OMIT_FLOATING_POINT - //# define double sqlite3_int64 - //#endif - - /* - ** CAPI3REF: Closing A Database Connection - ** - ** ^The sqlite3_close() routine is the destructor for the [sqlite3] object. - ** ^Calls to sqlite3_close() return SQLITE_OK if the [sqlite3] object is - ** successfully destroyed and all associated resources are deallocated. - ** - ** Applications must [sqlite3_finalize | finalize] all [prepared statements] - ** and [sqlite3_blob_close | close] all [BLOB handles] associated with - ** the [sqlite3] object prior to attempting to close the object. ^If - ** sqlite3_close() is called on a [database connection] that still has - ** outstanding [prepared statements] or [BLOB handles], then it returns - ** SQLITE_BUSY. - ** - ** ^If [sqlite3_close()] is invoked while a transaction is open, - ** the transaction is automatically rolled back. - ** - ** The C parameter to [sqlite3_close(C)] must be either a NULL - ** pointer or an [sqlite3] object pointer obtained - ** from [sqlite3_open()], [sqlite3_open16()], or - ** [sqlite3_open_v2()], and not previously closed. - ** ^Calling sqlite3_close() with a NULL pointer argument is a - ** harmless no-op. - */ - //SQLITE_API int sqlite3_close(sqlite3 ); - - /* - ** The type for a callback function. - ** This is legacy and deprecated. It is included for historical - ** compatibility and is not documented. - */ - //typedef int (*sqlite3_callback)(void*,int,char**, char*); - - /* - ** CAPI3REF: One-Step Query Execution Interface - ** - ** The sqlite3_exec() interface is a convenience wrapper around - ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()], - ** that allows an application to run multiple statements of SQL - ** without having to use a lot of C code. - ** - ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded, - ** semicolon-separate SQL statements passed into its 2nd argument, - ** in the context of the [database connection] passed in as its 1st - ** argument. ^If the callback function of the 3rd argument to - ** sqlite3_exec() is not NULL, then it is invoked for each result row - ** coming out of the evaluated SQL statements. ^The 4th argument to - ** sqlite3_exec() is relayed through to the 1st argument of each - ** callback invocation. ^If the callback pointer to sqlite3_exec() - ** is NULL, then no callback is ever invoked and result rows are - ** ignored. - ** - ** ^If an error occurs while evaluating the SQL statements passed into - ** sqlite3_exec(), then execution of the current statement stops and - ** subsequent statements are skipped. ^If the 5th parameter to sqlite3_exec() - ** is not NULL then any error message is written into memory obtained - ** from [sqlite3_malloc()] and passed back through the 5th parameter. - ** To avoid memory leaks, the application should invoke [sqlite3_free()] - ** on error message strings returned through the 5th parameter of - ** of sqlite3_exec() after the error message string is no longer needed. - ** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors - ** occur, then sqlite3_exec() sets the pointer in its 5th parameter to - ** NULL before returning. - ** - ** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec() - ** routine returns SQLITE_ABORT without invoking the callback again and - ** without running any subsequent SQL statements. - ** - ** ^The 2nd argument to the sqlite3_exec() callback function is the - ** number of columns in the result. ^The 3rd argument to the sqlite3_exec() - ** callback is an array of pointers to strings obtained as if from - ** [sqlite3_column_text()], one for each column. ^If an element of a - ** result row is NULL then the corresponding string pointer for the - ** sqlite3_exec() callback is a NULL pointer. ^The 4th argument to the - ** sqlite3_exec() callback is an array of pointers to strings where each - ** entry represents the name of corresponding result column as obtained - ** from [sqlite3_column_name()]. - ** - ** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer - ** to an empty string, or a pointer that contains only whitespace and/or - ** SQL comments, then no SQL statements are evaluated and the database - ** is not changed. - ** - ** Restrictions: - ** - **
    - **
  • The application must insure that the 1st parameter to sqlite3_exec() - ** is a valid and open [database connection]. - **
  • The application must not close [database connection] specified by - ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running. - **
  • The application must not modify the SQL statement text passed into - ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running. - **
- */ - //SQLITE_API int sqlite3_exec( - // sqlite3*, /* An open database */ - // string sql, /* SQL to be evaluated */ - // int (*callback)(void*,int,char**,char*), /* Callback function */ - // void *, /* 1st argument to callback */ - // char **errmsg /* Error msg written here */ - //); - - /* - ** CAPI3REF: Result Codes - ** KEYWORDS: SQLITE_OK {error code} {error codes} - ** KEYWORDS: {result code} {result codes} - ** - ** Many SQLite functions return an integer result code from the set shown - ** here in order to indicates success or failure. - ** - ** New error codes may be added in future versions of SQLite. - ** - ** See also: [SQLITE_IOERR_READ | extended result codes], - ** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes]. - */ - //#define SQLITE_OK 0 /* Successful result */ - ///* beginning-of-error-codes */ - //#define SQLITE_ERROR 1 /* SQL error or missing database */ - //#define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */ - //#define SQLITE_PERM 3 /* Access permission denied */ - //#define SQLITE_ABORT 4 /* Callback routine requested an abort */ - //#define SQLITE_BUSY 5 /* The database file is locked */ - //#define SQLITE_LOCKED 6 /* A table in the database is locked */ - //#define SQLITE_NOMEM 7 /* A malloc() failed */ - //#define SQLITE_READONLY 8 /* Attempt to write a readonly database */ - //#define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/ - //#define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */ - //#define SQLITE_CORRUPT 11 /* The database disk image is malformed */ - //#define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */ - //#define SQLITE_FULL 13 /* Insertion failed because database is full */ - //#define SQLITE_CANTOPEN 14 /* Unable to open the database file */ - //#define SQLITE_PROTOCOL 15 /* Database lock protocol error */ - //#define SQLITE_EMPTY 16 /* Database is empty */ - //#define SQLITE_SCHEMA 17 /* The database schema changed */ - //#define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */ - //#define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */ - //#define SQLITE_MISMATCH 20 /* Data type mismatch */ - //#define SQLITE_MISUSE 21 /* Library used incorrectly */ - //#define SQLITE_NOLFS 22 /* Uses OS features not supported on host */ - //#define SQLITE_AUTH 23 /* Authorization denied */ - //#define SQLITE_FORMAT 24 /* Auxiliary database format error */ - //#define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */ - //#define SQLITE_NOTADB 26 /* File opened that is not a database file */ - //#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */ - //#define SQLITE_DONE 101 /* sqlite3_step() has finished executing */ - /* end-of-error-codes */ - public const int SQLITE_OK = 0; - public const int SQLITE_ERROR = 1; - public const int SQLITE_INTERNAL = 2; - public const int SQLITE_PERM = 3; - public const int SQLITE_ABORT = 4; - public const int SQLITE_BUSY = 5; - public const int SQLITE_LOCKED = 6; - public const int SQLITE_NOMEM = 7; - public const int SQLITE_READONLY = 8; - public const int SQLITE_INTERRUPT = 9; - public const int SQLITE_IOERR = 10; - public const int SQLITE_CORRUPT = 11; - public const int SQLITE_NOTFOUND = 12; - public const int SQLITE_FULL = 13; - public const int SQLITE_CANTOPEN = 14; - public const int SQLITE_PROTOCOL = 15; - public const int SQLITE_EMPTY = 16; - public const int SQLITE_SCHEMA = 17; - public const int SQLITE_TOOBIG = 18; - public const int SQLITE_CONSTRAINT = 19; - public const int SQLITE_MISMATCH = 20; - public const int SQLITE_MISUSE = 21; - public const int SQLITE_NOLFS = 22; - public const int SQLITE_AUTH = 23; - public const int SQLITE_FORMAT = 24; - public const int SQLITE_RANGE = 25; - public const int SQLITE_NOTADB = 26; - public const int SQLITE_ROW = 100; - public const int SQLITE_DONE = 101; - - /* - ** CAPI3REF: Extended Result Codes - ** KEYWORDS: {extended error code} {extended error codes} - ** KEYWORDS: {extended result code} {extended result codes} - ** - ** In its default configuration, SQLite API routines return one of 26 integer - ** [SQLITE_OK | result codes]. However, experience has shown that many of - ** these result codes are too coarse-grained. They do not provide as - ** much information about problems as programmers might like. In an effort to - ** address this, newer versions of SQLite (version 3.3.8 and later) include - ** support for additional result codes that provide more detailed information - ** about errors. The extended result codes are enabled or disabled - ** on a per database connection basis using the - ** [sqlite3_extended_result_codes()] API. - ** - ** Some of the available extended result codes are listed here. - ** One may expect the number of extended result codes will be expand - ** over time. Software that uses extended result codes should expect - ** to see new result codes in future releases of SQLite. - ** - ** The SQLITE_OK result code will never be extended. It will always - ** be exactly zero. - */ - //#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8)) - //#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8)) - //#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8)) - //#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8)) - //#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8)) - //#define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8)) - //#define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8)) - //#define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8)) - //#define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8)) - //#define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8)) - //#define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8)) - //#define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8)) - //#define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8)) - //#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8)) - //#define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8)) - //#define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8)) - //#define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8)) - //#define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8)) - //#define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8)) - //#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8)) - //#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8)) - //#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8)) - //#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) - //#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) - //#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) - //#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8)) - //#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8)) - //#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8)) - const int SQLITE_IOERR_READ = ( SQLITE_IOERR | ( 1 << 8 ) ); - const int SQLITE_IOERR_SHORT_READ = ( SQLITE_IOERR | ( 2 << 8 ) ); - const int SQLITE_IOERR_WRITE = ( SQLITE_IOERR | ( 3 << 8 ) ); - const int SQLITE_IOERR_FSYNC = ( SQLITE_IOERR | ( 4 << 8 ) ); - const int SQLITE_IOERR_DIR_FSYNC = ( SQLITE_IOERR | ( 5 << 8 ) ); - const int SQLITE_IOERR_TRUNCATE = ( SQLITE_IOERR | ( 6 << 8 ) ); - const int SQLITE_IOERR_FSTAT = ( SQLITE_IOERR | ( 7 << 8 ) ); - const int SQLITE_IOERR_UNLOCK = ( SQLITE_IOERR | ( 8 << 8 ) ); - const int SQLITE_IOERR_RDLOCK = ( SQLITE_IOERR | ( 9 << 8 ) ); - const int SQLITE_IOERR_DELETE = ( SQLITE_IOERR | ( 10 << 8 ) ); - const int SQLITE_IOERR_BLOCKED = ( SQLITE_IOERR | ( 11 << 8 ) ); - const int SQLITE_IOERR_NOMEM = ( SQLITE_IOERR | ( 12 << 8 ) ); - const int SQLITE_IOERR_ACCESS = ( SQLITE_IOERR | ( 13 << 8 ) ); - const int SQLITE_IOERR_CHECKRESERVEDLOCK = ( SQLITE_IOERR | ( 14 << 8 ) ); - const int SQLITE_IOERR_LOCK = ( SQLITE_IOERR | ( 15 << 8 ) ); - const int SQLITE_IOERR_CLOSE = ( SQLITE_IOERR | ( 16 << 8 ) ); - const int SQLITE_IOERR_DIR_CLOSE = ( SQLITE_IOERR | ( 17 << 8 ) ); - const int SQLITE_IOERR_SHMOPEN = ( SQLITE_IOERR | ( 18 << 8 ) ); - const int SQLITE_IOERR_SHMSIZE = ( SQLITE_IOERR | ( 19 << 8 ) ); - const int SQLITE_IOERR_SHMLOCK = ( SQLITE_IOERR | ( 20 << 8 ) ); - const int SQLITE_IOERR_SHMMAP = ( SQLITE_IOERR | ( 21 << 8 ) ); - const int SQLITE_IOERR_SEEK = ( SQLITE_IOERR | ( 22 << 8 ) ); - const int SQLITE_LOCKED_SHAREDCACHE = ( SQLITE_LOCKED | ( 1 << 8 ) ); - const int SQLITE_BUSY_RECOVERY = ( SQLITE_BUSY | ( 1 << 8 ) ); - const int SQLITE_CANTOPEN_NOTEMPDIR = ( SQLITE_CANTOPEN | ( 1 << 8 ) ); - const int SQLITE_CORRUPT_VTAB = ( SQLITE_CORRUPT | ( 1 << 8 ) ); - const int SQLITE_READONLY_RECOVERY = ( SQLITE_READONLY | ( 1 << 8 ) ); - const int SQLITE_READONLY_CANTLOCK = ( SQLITE_READONLY | ( 2 << 8 ) ); - - /* - ** CAPI3REF: Flags For File Open Operations - ** - ** These bit values are intended for use in the - ** 3rd parameter to the [sqlite3_open_v2()] interface and - ** in the 4th parameter to the [sqlite3_vfs.xOpen] method. - */ - //#define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */ - //#define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */ - //#define SQLITE_OPEN_CREATE 0x00000004 /* Ok for sqlite3_open_v2() */ - //#define SQLITE_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */ - //#define SQLITE_OPEN_EXCLUSIVE 0x00000010 /* VFS only */ - //#define SQLITE_OPEN_AUTOPROXY 0x00000020 /* VFS only */ - //#define SQLITE_OPEN_URI 0x00000040 /* Ok for sqlite3_open_v2() */ - //#define SQLITE_OPEN_MAIN_DB 0x00000100 /* VFS only */ - //#define SQLITE_OPEN_TEMP_DB 0x00000200 /* VFS only */ - //#define SQLITE_OPEN_TRANSIENT_DB 0x00000400 /* VFS only */ - //#define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 /* VFS only */ - //#define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 /* VFS only */ - //#define SQLITE_OPEN_SUBJOURNAL 0x00002000 /* VFS only */ - //#define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */ - //#define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */ - //#define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */ - //#define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ - //#define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ - //#define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ - - /* Reserved: 0x00F00000 */ - - public const int SQLITE_OPEN_READONLY = 0x00000001; - public const int SQLITE_OPEN_READWRITE = 0x00000002; - public const int SQLITE_OPEN_CREATE = 0x00000004; - public const int SQLITE_OPEN_DELETEONCLOSE = 0x00000008; - public const int SQLITE_OPEN_EXCLUSIVE = 0x00000010; - public const int SQLITE_OPEN_AUTOPROXY = 0x00000020; - public const int SQLITE_OPEN_URI = 0x00000040; - public const int SQLITE_OPEN_MAIN_DB = 0x00000100; - public const int SQLITE_OPEN_TEMP_DB = 0x00000200; - public const int SQLITE_OPEN_TRANSIENT_DB = 0x00000400; - public const int SQLITE_OPEN_MAIN_JOURNAL = 0x00000800; - public const int SQLITE_OPEN_TEMP_JOURNAL = 0x00001000; - public const int SQLITE_OPEN_SUBJOURNAL = 0x00002000; - public const int SQLITE_OPEN_MASTER_JOURNAL = 0x00004000; - public const int SQLITE_OPEN_NOMUTEX = 0x00008000; - public const int SQLITE_OPEN_FULLMUTEX = 0x00010000; - public const int SQLITE_OPEN_SHAREDCACHE = 0x00020000; - public const int SQLITE_OPEN_PRIVATECACHE = 0x00040000; - public const int SQLITE_OPEN_WAL = 0x00080000; - - /* - ** CAPI3REF: Device Characteristics - ** - ** The xDeviceCharacteristics method of the [sqlite3_io_methods] - ** object returns an integer which is a vector of the these - ** bit values expressing I/O characteristics of the mass storage - ** device that holds the file that the [sqlite3_io_methods] - ** refers to. - ** - ** The SQLITE_IOCAP_ATOMIC property means that all writes of - ** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values - ** mean that writes of blocks that are nnn bytes in size and - ** are aligned to an address which is an integer multiple of - ** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means - ** that when data is appended to a file, the data is appended - ** first then the size of the file is extended, never the other - ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that - ** information is written to disk in the same order as calls - ** to xWrite(). - */ - //#define SQLITE_IOCAP_ATOMIC 0x00000001 - //#define SQLITE_IOCAP_ATOMIC512 0x00000002 - //#define SQLITE_IOCAP_ATOMIC1K 0x00000004 - //#define SQLITE_IOCAP_ATOMIC2K 0x00000008 - //#define SQLITE_IOCAP_ATOMIC4K 0x00000010 - //#define SQLITE_IOCAP_ATOMIC8K 0x00000020 - //#define SQLITE_IOCAP_ATOMIC16K 0x00000040 - //#define SQLITE_IOCAP_ATOMIC32K 0x00000080 - //#define SQLITE_IOCAP_ATOMIC64K 0x00000100 - //#define SQLITE_IOCAP_SAFE_APPEND 0x00000200 - //#define SQLITE_IOCAP_SEQUENTIAL 0x00000400 - //#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800 - const int SQLITE_IOCAP_ATOMIC = 0x00000001; - const int SQLITE_IOCAP_ATOMIC512 = 0x00000002; - const int SQLITE_IOCAP_ATOMIC1K = 0x00000004; - const int SQLITE_IOCAP_ATOMIC2K = 0x00000008; - const int SQLITE_IOCAP_ATOMIC4K = 0x00000010; - const int SQLITE_IOCAP_ATOMIC8K = 0x00000020; - const int SQLITE_IOCAP_ATOMIC16K = 0x00000040; - const int SQLITE_IOCAP_ATOMIC32K = 0x00000080; - const int SQLITE_IOCAP_ATOMIC64K = 0x00000100; - const int SQLITE_IOCAP_SAFE_APPEND = 0x00000200; - const int SQLITE_IOCAP_SEQUENTIAL = 0x00000400; - const int SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN = 0x00000800; - - /* - ** CAPI3REF: File Locking Levels - ** - ** SQLite uses one of these integer values as the second - ** argument to calls it makes to the xLock() and xUnlock() methods - ** of an [sqlite3_io_methods] object. - */ - //#define SQLITE_LOCK_NONE 0 - //#define SQLITE_LOCK_SHARED 1 - //#define SQLITE_LOCK_RESERVED 2 - //#define SQLITE_LOCK_PENDING 3 - //#define SQLITE_LOCK_EXCLUSIVE 4 - const int SQLITE_LOCK_NONE = 0; - const int SQLITE_LOCK_SHARED = 1; - const int SQLITE_LOCK_RESERVED = 2; - const int SQLITE_LOCK_PENDING = 3; - const int SQLITE_LOCK_EXCLUSIVE = 4; - - /* - ** CAPI3REF: Synchronization Type Flags - ** - ** When SQLite invokes the xSync() method of an - ** [sqlite3_io_methods] object it uses a combination of - ** these integer values as the second argument. - ** - ** When the SQLITE_SYNC_DATAONLY flag is used, it means that the - ** sync operation only needs to flush data to mass storage. Inode - ** information need not be flushed. If the lower four bits of the flag - ** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics. - ** If the lower four bits equal SQLITE_SYNC_FULL, that means - ** to use Mac OS X style fullsync instead of fsync(). - ** - ** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags - ** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL - ** settings. The [synchronous pragma] determines when calls to the - ** xSync VFS method occur and applies uniformly across all platforms. - ** The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how - ** energetic or rigorous or forceful the sync operations are and - ** only make a difference on Mac OSX for the default SQLite code. - ** (Third-party VFS implementations might also make the distinction - ** between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the - ** operating systems natively supported by SQLite, only Mac OSX - ** cares about the difference.) - */ - //#define SQLITE_SYNC_NORMAL 0x00002 - //#define SQLITE_SYNC_FULL 0x00003 - //#define SQLITE_SYNC_DATAONLY 0x00010 - const int SQLITE_SYNC_NORMAL = 0x00002; - const int SQLITE_SYNC_FULL = 0x00003; - const int SQLITE_SYNC_DATAONLY = 0x00010; - - /* - ** CAPI3REF: OS Interface Open File Handle - ** - ** An [sqlite3_file] object represents an open file in the - ** [sqlite3_vfs | OS interface layer]. Individual OS interface - ** implementations will - ** want to subclass this object by appending additional fields - ** for their own use. The pMethods entry is a pointer to an - ** [sqlite3_io_methods] object that defines methods for performing - ** I/O operations on the open file. - */ - //typedef struct sqlite3_file sqlite3_file; - //struct sqlite3_file { - // const struct sqlite3_io_methods *pMethods; /* Methods for an open file */ - //}; - public partial class sqlite3_file - { - public sqlite3_io_methods pMethods;/* Must be first */ - } +using u8 = System.Byte; + +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** This header file defines the interface that the SQLite library + ** presents to client programs. If a C-function, structure, datatype, + ** or constant definition does not appear in this file, then it is + ** not a published API of SQLite, is subject to change without + ** notice, and should not be referenced by programs that use SQLite. + ** + ** Some of the definitions that are in this file are marked as + ** "experimental". Experimental interfaces are normally new + ** features recently added to SQLite. We do not anticipate changes + ** to experimental interfaces but reserve the right to make minor changes + ** if experience from use "in the wild" suggest such changes are prudent. + ** + ** The official C-language API documentation for SQLite is derived + ** from comments in this file. This file is the authoritative source + ** on how SQLite interfaces are suppose to operate. + ** + ** The name of this file under configuration management is "sqlite.h.in". + ** The makefile makes some minor changes to this file (such as inserting + ** the version number) and changes its name to "sqlite3.h" as + ** part of the build process. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#if !_SQLITE3_H_ + //#define _SQLITE3_H_ + //#include /* Needed for the definition of va_list */ + + /* + ** Make sure we can call this stuff from C++. + */ + //#if __cplusplus + //extern "C" { + //#endif + + + /* + ** Add the ability to override 'extern' + */ + //#if !SQLITE_EXTERN + //# define SQLITE_EXTERN extern + //#endif + + //#if !SQLITE_API + //# define SQLITE_API + //#endif + + + /* + ** These no-op macros are used in front of interfaces to mark those + ** interfaces as either deprecated or experimental. New applications + ** should not use deprecated interfaces - they are support for backwards + ** compatibility only. Application writers should be aware that + ** experimental interfaces are subject to change in point releases. + ** + ** These macros used to resolve to various kinds of compiler magic that + ** would generate warning messages when they were used. But that + ** compiler magic ended up generating such a flurry of bug reports + ** that we have taken it all out and gone back to using simple + ** noop macros. + */ + //#define SQLITE_DEPRECATED + //#define SQLITE_EXPERIMENTAL + + /* + ** Ensure these symbols were not defined by some previous header file. + */ + //#if SQLITE_VERSION + //# undef SQLITE_VERSION + //#endif + //#if SQLITE_VERSION_NUMBER + //# undef SQLITE_VERSION_NUMBER + //#endif + + /* + ** CAPI3REF: Compile-Time Library Version Numbers + ** + ** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header + ** evaluates to a string literal that is the SQLite version in the + ** format "X.Y.Z" where X is the major version number (always 3 for + ** SQLite3) and Y is the minor version number and Z is the release number.)^ + ** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer + ** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same + ** numbers used in [SQLITE_VERSION].)^ + ** The SQLITE_VERSION_NUMBER for any given release of SQLite will also + ** be larger than the release from which it is derived. Either Y will + ** be held constant and Z will be incremented or else Y will be incremented + ** and Z will be reset to zero. + ** + ** Since version 3.6.18, SQLite source code has been stored in the + ** Fossil configuration management + ** system. ^The SQLITE_SOURCE_ID macro evaluates to + ** a string which identifies a particular check-in of SQLite + ** within its configuration management system. ^The SQLITE_SOURCE_ID + ** string contains the date and time of the check-in (UTC) and an SHA1 + ** hash of the entire source tree. + ** + ** See also: [sqlite3_libversion()], + ** [sqlite3_libversion_number()], [sqlite3_sourceid()], + ** [sqlite_version()] and [sqlite_source_id()]. + */ + //#define SQLITE_VERSION "3.7.7" + //#define SQLITE_VERSION_NUMBER 3007007 + //#define SQLITE_SOURCE_ID "2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2" + public const string SQLITE_VERSION = "3.7.7(C#)"; + public const int SQLITE_VERSION_NUMBER = 300700701; + public const string SQLITE_SOURCE_ID = "2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2"; + + /* + ** CAPI3REF: Run-Time Library Version Numbers + ** KEYWORDS: sqlite3_version, sqlite3_sourceid + ** + ** These interfaces provide the same information as the [SQLITE_VERSION], + ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros + ** but are associated with the library instead of the header file. ^(Cautious + ** programmers might include Debug.Assert() statements in their application to + ** verify that values returned by these interfaces match the macros in + ** the header, and thus insure that the application is + ** compiled with matching library and header files. + ** + **
+        ** Debug.Assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
+        ** Debug.Assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
+        ** Debug.Assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
+        ** 
)^ + ** + ** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION] + ** macro. ^The sqlite3_libversion() function returns a pointer to the + ** to the sqlite3_version[] string constant. The sqlite3_libversion() + ** function is provided for use in DLLs since DLL users usually do not have + ** direct access to string constants within the DLL. ^The + ** sqlite3_libversion_number() function returns an integer equal to + ** [SQLITE_VERSION_NUMBER]. ^The sqlite3_sourceid() function returns + ** a pointer to a string constant whose value is the same as the + ** [SQLITE_SOURCE_ID] C preprocessor macro. + ** + ** See also: [sqlite_version()] and [sqlite_source_id()]. + */ + //SQLITE_API SQLITE_EXTERN const char sqlite3_version[]; + //SQLITE_API string sqlite3_libversion(void); + //SQLITE_API string sqlite3_sourceid(void); + //SQLITE_API int sqlite3_libversion_number(void); + + /* + ** CAPI3REF: Run-Time Library Compilation Options Diagnostics + ** + ** ^The sqlite3_compileoption_used() function returns 0 or 1 + ** indicating whether the specified option was defined at + ** compile time. ^The SQLITE_ prefix may be omitted from the + ** option name passed to sqlite3_compileoption_used(). + ** + ** ^The sqlite3_compileoption_get() function allows iterating + ** over the list of options that were defined at compile time by + ** returning the N-th compile time option string. ^If N is out of range, + ** sqlite3_compileoption_get() returns a NULL pointer. ^The SQLITE_ + ** prefix is omitted from any strings returned by + ** sqlite3_compileoption_get(). + ** + ** ^Support for the diagnostic functions sqlite3_compileoption_used() + ** and sqlite3_compileoption_get() may be omitted by specifying the + ** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time. + ** + ** See also: SQL functions [sqlite_compileoption_used()] and + ** [sqlite_compileoption_get()] and the [compile_options pragma]. + */ + //#if !SQLITE_OMIT_COMPILEOPTION_DIAGS + //SQLITE_API int sqlite3_compileoption_used(string zOptName); + //SQLITE_API string sqlite3_compileoption_get(int N); + //#endif + + /* + ** CAPI3REF: Test To See If The Library Is Threadsafe + ** + ** ^The sqlite3_threadsafe() function returns zero if and only if + ** SQLite was compiled mutexing code omitted due to the + ** [SQLITE_THREADSAFE] compile-time option being set to 0. + ** + ** SQLite can be compiled with or without mutexes. When + ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes + ** are enabled and SQLite is threadsafe. When the + ** [SQLITE_THREADSAFE] macro is 0, + ** the mutexes are omitted. Without the mutexes, it is not safe + ** to use SQLite concurrently from more than one thread. + ** + ** Enabling mutexes incurs a measurable performance penalty. + ** So if speed is of utmost importance, it makes sense to disable + ** the mutexes. But for maximum safety, mutexes should be enabled. + ** ^The default behavior is for mutexes to be enabled. + ** + ** This interface can be used by an application to make sure that the + ** version of SQLite that it is linking against was compiled with + ** the desired setting of the [SQLITE_THREADSAFE] macro. + ** + ** This interface only reports on the compile-time mutex setting + ** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with + ** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but + ** can be fully or partially disabled using a call to [sqlite3_config()] + ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD], + ** or [SQLITE_CONFIG_MUTEX]. ^(The return value of the + ** sqlite3_threadsafe() function shows only the compile-time setting of + ** thread safety, not any run-time changes to that setting made by + ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe() + ** is unchanged by calls to sqlite3_config().)^ + ** + ** See the [threading mode] documentation for additional information. + */ + //SQLITE_API int sqlite3_threadsafe(void); + + /* + ** CAPI3REF: Database Connection Handle + ** KEYWORDS: {database connection} {database connections} + ** + ** Each open SQLite database is represented by a pointer to an instance of + ** the opaque structure named "sqlite3". It is useful to think of an sqlite3 + ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and + ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()] + ** is its destructor. There are many other interfaces (such as + ** [sqlite3_prepare_v2()], [sqlite3_create_function()], and + ** [sqlite3_busy_timeout()] to name but three) that are methods on an + ** sqlite3 object. + */ + //typedef struct sqlite3 sqlite3; + + /* + ** CAPI3REF: 64-Bit Integer Types + ** KEYWORDS: sqlite_int64 sqlite_uint64 + ** + ** Because there is no cross-platform way to specify 64-bit integer types + ** SQLite includes typedefs for 64-bit signed and unsigned integers. + ** + ** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions. + ** The sqlite_int64 and sqlite_uint64 types are supported for backwards + ** compatibility only. + ** + ** ^The sqlite3_int64 and sqlite_int64 types can store integer values + ** between -9223372036854775808 and +9223372036854775807 inclusive. ^The + ** sqlite3_uint64 and sqlite_uint64 types can store integer values + ** between 0 and +18446744073709551615 inclusive. + */ + //#if SQLITE_INT64_TYPE + // typedef SQLITE_INT64_TYPE sqlite_int64; + // typedef unsigned SQLITE_INT64_TYPE sqlite_uint64; + //#elif defined(_MSC_VER) || defined(__BORLANDC__) + // typedef __int64 sqlite_int64; + // typedef unsigned __int64 sqlite_uint64; + //#else + // typedef long long int sqlite_int64; + // typedef unsigned long long int sqlite_uint64; + //#endif + //typedef sqlite_int64 sqlite3_int64; + //typedef sqlite_uint64 sqlite3_uint64; + + /* + ** If compiling for a processor that lacks floating point support, + ** substitute integer for floating-point. + */ + //#if SQLITE_OMIT_FLOATING_POINT + //# define double sqlite3_int64 + //#endif + + /* + ** CAPI3REF: Closing A Database Connection + ** + ** ^The sqlite3_close() routine is the destructor for the [sqlite3] object. + ** ^Calls to sqlite3_close() return SQLITE_OK if the [sqlite3] object is + ** successfully destroyed and all associated resources are deallocated. + ** + ** Applications must [sqlite3_finalize | finalize] all [prepared statements] + ** and [sqlite3_blob_close | close] all [BLOB handles] associated with + ** the [sqlite3] object prior to attempting to close the object. ^If + ** sqlite3_close() is called on a [database connection] that still has + ** outstanding [prepared statements] or [BLOB handles], then it returns + ** SQLITE_BUSY. + ** + ** ^If [sqlite3_close()] is invoked while a transaction is open, + ** the transaction is automatically rolled back. + ** + ** The C parameter to [sqlite3_close(C)] must be either a NULL + ** pointer or an [sqlite3] object pointer obtained + ** from [sqlite3_open()], [sqlite3_open16()], or + ** [sqlite3_open_v2()], and not previously closed. + ** ^Calling sqlite3_close() with a NULL pointer argument is a + ** harmless no-op. + */ + //SQLITE_API int sqlite3_close(sqlite3 ); + + /* + ** The type for a callback function. + ** This is legacy and deprecated. It is included for historical + ** compatibility and is not documented. + */ + //typedef int (*sqlite3_callback)(void*,int,char**, char*); + + /* + ** CAPI3REF: One-Step Query Execution Interface + ** + ** The sqlite3_exec() interface is a convenience wrapper around + ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()], + ** that allows an application to run multiple statements of SQL + ** without having to use a lot of C code. + ** + ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded, + ** semicolon-separate SQL statements passed into its 2nd argument, + ** in the context of the [database connection] passed in as its 1st + ** argument. ^If the callback function of the 3rd argument to + ** sqlite3_exec() is not NULL, then it is invoked for each result row + ** coming out of the evaluated SQL statements. ^The 4th argument to + ** sqlite3_exec() is relayed through to the 1st argument of each + ** callback invocation. ^If the callback pointer to sqlite3_exec() + ** is NULL, then no callback is ever invoked and result rows are + ** ignored. + ** + ** ^If an error occurs while evaluating the SQL statements passed into + ** sqlite3_exec(), then execution of the current statement stops and + ** subsequent statements are skipped. ^If the 5th parameter to sqlite3_exec() + ** is not NULL then any error message is written into memory obtained + ** from [sqlite3_malloc()] and passed back through the 5th parameter. + ** To avoid memory leaks, the application should invoke [sqlite3_free()] + ** on error message strings returned through the 5th parameter of + ** of sqlite3_exec() after the error message string is no longer needed. + ** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors + ** occur, then sqlite3_exec() sets the pointer in its 5th parameter to + ** NULL before returning. + ** + ** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec() + ** routine returns SQLITE_ABORT without invoking the callback again and + ** without running any subsequent SQL statements. + ** + ** ^The 2nd argument to the sqlite3_exec() callback function is the + ** number of columns in the result. ^The 3rd argument to the sqlite3_exec() + ** callback is an array of pointers to strings obtained as if from + ** [sqlite3_column_text()], one for each column. ^If an element of a + ** result row is NULL then the corresponding string pointer for the + ** sqlite3_exec() callback is a NULL pointer. ^The 4th argument to the + ** sqlite3_exec() callback is an array of pointers to strings where each + ** entry represents the name of corresponding result column as obtained + ** from [sqlite3_column_name()]. + ** + ** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer + ** to an empty string, or a pointer that contains only whitespace and/or + ** SQL comments, then no SQL statements are evaluated and the database + ** is not changed. + ** + ** Restrictions: + ** + **
    + **
  • The application must insure that the 1st parameter to sqlite3_exec() + ** is a valid and open [database connection]. + **
  • The application must not close [database connection] specified by + ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running. + **
  • The application must not modify the SQL statement text passed into + ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running. + **
+ */ + //SQLITE_API int sqlite3_exec( + // sqlite3*, /* An open database */ + // string sql, /* SQL to be evaluated */ + // int (*callback)(void*,int,char**,char*), /* Callback function */ + // void *, /* 1st argument to callback */ + // char **errmsg /* Error msg written here */ + //); + + /* + ** CAPI3REF: Result Codes + ** KEYWORDS: SQLITE_OK {error code} {error codes} + ** KEYWORDS: {result code} {result codes} + ** + ** Many SQLite functions return an integer result code from the set shown + ** here in order to indicates success or failure. + ** + ** New error codes may be added in future versions of SQLite. + ** + ** See also: [SQLITE_IOERR_READ | extended result codes], + ** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes]. + */ + //#define SQLITE_OK 0 /* Successful result */ + ///* beginning-of-error-codes */ + //#define SQLITE_ERROR 1 /* SQL error or missing database */ + //#define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */ + //#define SQLITE_PERM 3 /* Access permission denied */ + //#define SQLITE_ABORT 4 /* Callback routine requested an abort */ + //#define SQLITE_BUSY 5 /* The database file is locked */ + //#define SQLITE_LOCKED 6 /* A table in the database is locked */ + //#define SQLITE_NOMEM 7 /* A malloc() failed */ + //#define SQLITE_READONLY 8 /* Attempt to write a readonly database */ + //#define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/ + //#define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */ + //#define SQLITE_CORRUPT 11 /* The database disk image is malformed */ + //#define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */ + //#define SQLITE_FULL 13 /* Insertion failed because database is full */ + //#define SQLITE_CANTOPEN 14 /* Unable to open the database file */ + //#define SQLITE_PROTOCOL 15 /* Database lock protocol error */ + //#define SQLITE_EMPTY 16 /* Database is empty */ + //#define SQLITE_SCHEMA 17 /* The database schema changed */ + //#define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */ + //#define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */ + //#define SQLITE_MISMATCH 20 /* Data type mismatch */ + //#define SQLITE_MISUSE 21 /* Library used incorrectly */ + //#define SQLITE_NOLFS 22 /* Uses OS features not supported on host */ + //#define SQLITE_AUTH 23 /* Authorization denied */ + //#define SQLITE_FORMAT 24 /* Auxiliary database format error */ + //#define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */ + //#define SQLITE_NOTADB 26 /* File opened that is not a database file */ + //#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */ + //#define SQLITE_DONE 101 /* sqlite3_step() has finished executing */ + /* end-of-error-codes */ + public const int SQLITE_OK = 0; + public const int SQLITE_ERROR = 1; + public const int SQLITE_INTERNAL = 2; + public const int SQLITE_PERM = 3; + public const int SQLITE_ABORT = 4; + public const int SQLITE_BUSY = 5; + public const int SQLITE_LOCKED = 6; + public const int SQLITE_NOMEM = 7; + public const int SQLITE_READONLY = 8; + public const int SQLITE_INTERRUPT = 9; + public const int SQLITE_IOERR = 10; + public const int SQLITE_CORRUPT = 11; + public const int SQLITE_NOTFOUND = 12; + public const int SQLITE_FULL = 13; + public const int SQLITE_CANTOPEN = 14; + public const int SQLITE_PROTOCOL = 15; + public const int SQLITE_EMPTY = 16; + public const int SQLITE_SCHEMA = 17; + public const int SQLITE_TOOBIG = 18; + public const int SQLITE_CONSTRAINT = 19; + public const int SQLITE_MISMATCH = 20; + public const int SQLITE_MISUSE = 21; + public const int SQLITE_NOLFS = 22; + public const int SQLITE_AUTH = 23; + public const int SQLITE_FORMAT = 24; + public const int SQLITE_RANGE = 25; + public const int SQLITE_NOTADB = 26; + public const int SQLITE_ROW = 100; + public const int SQLITE_DONE = 101; + + /* + ** CAPI3REF: Extended Result Codes + ** KEYWORDS: {extended error code} {extended error codes} + ** KEYWORDS: {extended result code} {extended result codes} + ** + ** In its default configuration, SQLite API routines return one of 26 integer + ** [SQLITE_OK | result codes]. However, experience has shown that many of + ** these result codes are too coarse-grained. They do not provide as + ** much information about problems as programmers might like. In an effort to + ** address this, newer versions of SQLite (version 3.3.8 and later) include + ** support for additional result codes that provide more detailed information + ** about errors. The extended result codes are enabled or disabled + ** on a per database connection basis using the + ** [sqlite3_extended_result_codes()] API. + ** + ** Some of the available extended result codes are listed here. + ** One may expect the number of extended result codes will be expand + ** over time. Software that uses extended result codes should expect + ** to see new result codes in future releases of SQLite. + ** + ** The SQLITE_OK result code will never be extended. It will always + ** be exactly zero. + */ + //#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8)) + //#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8)) + //#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8)) + //#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8)) + //#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8)) + //#define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8)) + //#define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8)) + //#define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8)) + //#define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8)) + //#define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8)) + //#define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8)) + //#define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8)) + //#define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8)) + //#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8)) + //#define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8)) + //#define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8)) + //#define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8)) + //#define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8)) + //#define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8)) + //#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8)) + //#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8)) + //#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8)) + //#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) + //#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) + //#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) + //#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8)) + //#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8)) + //#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8)) + const int SQLITE_IOERR_READ = (SQLITE_IOERR | (1 << 8)); + const int SQLITE_IOERR_SHORT_READ = (SQLITE_IOERR | (2 << 8)); + const int SQLITE_IOERR_WRITE = (SQLITE_IOERR | (3 << 8)); + const int SQLITE_IOERR_FSYNC = (SQLITE_IOERR | (4 << 8)); + const int SQLITE_IOERR_DIR_FSYNC = (SQLITE_IOERR | (5 << 8)); + const int SQLITE_IOERR_TRUNCATE = (SQLITE_IOERR | (6 << 8)); + const int SQLITE_IOERR_FSTAT = (SQLITE_IOERR | (7 << 8)); + const int SQLITE_IOERR_UNLOCK = (SQLITE_IOERR | (8 << 8)); + const int SQLITE_IOERR_RDLOCK = (SQLITE_IOERR | (9 << 8)); + const int SQLITE_IOERR_DELETE = (SQLITE_IOERR | (10 << 8)); + const int SQLITE_IOERR_BLOCKED = (SQLITE_IOERR | (11 << 8)); + const int SQLITE_IOERR_NOMEM = (SQLITE_IOERR | (12 << 8)); + const int SQLITE_IOERR_ACCESS = (SQLITE_IOERR | (13 << 8)); + const int SQLITE_IOERR_CHECKRESERVEDLOCK = (SQLITE_IOERR | (14 << 8)); + const int SQLITE_IOERR_LOCK = (SQLITE_IOERR | (15 << 8)); + const int SQLITE_IOERR_CLOSE = (SQLITE_IOERR | (16 << 8)); + const int SQLITE_IOERR_DIR_CLOSE = (SQLITE_IOERR | (17 << 8)); + const int SQLITE_IOERR_SHMOPEN = (SQLITE_IOERR | (18 << 8)); + const int SQLITE_IOERR_SHMSIZE = (SQLITE_IOERR | (19 << 8)); + const int SQLITE_IOERR_SHMLOCK = (SQLITE_IOERR | (20 << 8)); + const int SQLITE_IOERR_SHMMAP = (SQLITE_IOERR | (21 << 8)); + const int SQLITE_IOERR_SEEK = (SQLITE_IOERR | (22 << 8)); + const int SQLITE_LOCKED_SHAREDCACHE = (SQLITE_LOCKED | (1 << 8)); + const int SQLITE_BUSY_RECOVERY = (SQLITE_BUSY | (1 << 8)); + const int SQLITE_CANTOPEN_NOTEMPDIR = (SQLITE_CANTOPEN | (1 << 8)); + const int SQLITE_CORRUPT_VTAB = (SQLITE_CORRUPT | (1 << 8)); + const int SQLITE_READONLY_RECOVERY = (SQLITE_READONLY | (1 << 8)); + const int SQLITE_READONLY_CANTLOCK = (SQLITE_READONLY | (2 << 8)); + + /* + ** CAPI3REF: Flags For File Open Operations + ** + ** These bit values are intended for use in the + ** 3rd parameter to the [sqlite3_open_v2()] interface and + ** in the 4th parameter to the [sqlite3_vfs.xOpen] method. + */ + //#define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */ + //#define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */ + //#define SQLITE_OPEN_CREATE 0x00000004 /* Ok for sqlite3_open_v2() */ + //#define SQLITE_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */ + //#define SQLITE_OPEN_EXCLUSIVE 0x00000010 /* VFS only */ + //#define SQLITE_OPEN_AUTOPROXY 0x00000020 /* VFS only */ + //#define SQLITE_OPEN_URI 0x00000040 /* Ok for sqlite3_open_v2() */ + //#define SQLITE_OPEN_MAIN_DB 0x00000100 /* VFS only */ + //#define SQLITE_OPEN_TEMP_DB 0x00000200 /* VFS only */ + //#define SQLITE_OPEN_TRANSIENT_DB 0x00000400 /* VFS only */ + //#define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 /* VFS only */ + //#define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 /* VFS only */ + //#define SQLITE_OPEN_SUBJOURNAL 0x00002000 /* VFS only */ + //#define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */ + //#define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */ + //#define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */ + //#define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ + //#define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ + //#define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ + + /* Reserved: 0x00F00000 */ + + public const int SQLITE_OPEN_READONLY = 0x00000001; + public const int SQLITE_OPEN_READWRITE = 0x00000002; + public const int SQLITE_OPEN_CREATE = 0x00000004; + public const int SQLITE_OPEN_DELETEONCLOSE = 0x00000008; + public const int SQLITE_OPEN_EXCLUSIVE = 0x00000010; + public const int SQLITE_OPEN_AUTOPROXY = 0x00000020; + public const int SQLITE_OPEN_URI = 0x00000040; + public const int SQLITE_OPEN_MAIN_DB = 0x00000100; + public const int SQLITE_OPEN_TEMP_DB = 0x00000200; + public const int SQLITE_OPEN_TRANSIENT_DB = 0x00000400; + public const int SQLITE_OPEN_MAIN_JOURNAL = 0x00000800; + public const int SQLITE_OPEN_TEMP_JOURNAL = 0x00001000; + public const int SQLITE_OPEN_SUBJOURNAL = 0x00002000; + public const int SQLITE_OPEN_MASTER_JOURNAL = 0x00004000; + public const int SQLITE_OPEN_NOMUTEX = 0x00008000; + public const int SQLITE_OPEN_FULLMUTEX = 0x00010000; + public const int SQLITE_OPEN_SHAREDCACHE = 0x00020000; + public const int SQLITE_OPEN_PRIVATECACHE = 0x00040000; + public const int SQLITE_OPEN_WAL = 0x00080000; + + /* + ** CAPI3REF: Device Characteristics + ** + ** The xDeviceCharacteristics method of the [sqlite3_io_methods] + ** object returns an integer which is a vector of the these + ** bit values expressing I/O characteristics of the mass storage + ** device that holds the file that the [sqlite3_io_methods] + ** refers to. + ** + ** The SQLITE_IOCAP_ATOMIC property means that all writes of + ** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values + ** mean that writes of blocks that are nnn bytes in size and + ** are aligned to an address which is an integer multiple of + ** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means + ** that when data is appended to a file, the data is appended + ** first then the size of the file is extended, never the other + ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that + ** information is written to disk in the same order as calls + ** to xWrite(). + */ + //#define SQLITE_IOCAP_ATOMIC 0x00000001 + //#define SQLITE_IOCAP_ATOMIC512 0x00000002 + //#define SQLITE_IOCAP_ATOMIC1K 0x00000004 + //#define SQLITE_IOCAP_ATOMIC2K 0x00000008 + //#define SQLITE_IOCAP_ATOMIC4K 0x00000010 + //#define SQLITE_IOCAP_ATOMIC8K 0x00000020 + //#define SQLITE_IOCAP_ATOMIC16K 0x00000040 + //#define SQLITE_IOCAP_ATOMIC32K 0x00000080 + //#define SQLITE_IOCAP_ATOMIC64K 0x00000100 + //#define SQLITE_IOCAP_SAFE_APPEND 0x00000200 + //#define SQLITE_IOCAP_SEQUENTIAL 0x00000400 + //#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800 + const int SQLITE_IOCAP_ATOMIC = 0x00000001; + const int SQLITE_IOCAP_ATOMIC512 = 0x00000002; + const int SQLITE_IOCAP_ATOMIC1K = 0x00000004; + const int SQLITE_IOCAP_ATOMIC2K = 0x00000008; + const int SQLITE_IOCAP_ATOMIC4K = 0x00000010; + const int SQLITE_IOCAP_ATOMIC8K = 0x00000020; + const int SQLITE_IOCAP_ATOMIC16K = 0x00000040; + const int SQLITE_IOCAP_ATOMIC32K = 0x00000080; + const int SQLITE_IOCAP_ATOMIC64K = 0x00000100; + const int SQLITE_IOCAP_SAFE_APPEND = 0x00000200; + const int SQLITE_IOCAP_SEQUENTIAL = 0x00000400; + const int SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN = 0x00000800; + + /* + ** CAPI3REF: File Locking Levels + ** + ** SQLite uses one of these integer values as the second + ** argument to calls it makes to the xLock() and xUnlock() methods + ** of an [sqlite3_io_methods] object. + */ + //#define SQLITE_LOCK_NONE 0 + //#define SQLITE_LOCK_SHARED 1 + //#define SQLITE_LOCK_RESERVED 2 + //#define SQLITE_LOCK_PENDING 3 + //#define SQLITE_LOCK_EXCLUSIVE 4 + const int SQLITE_LOCK_NONE = 0; + const int SQLITE_LOCK_SHARED = 1; + const int SQLITE_LOCK_RESERVED = 2; + const int SQLITE_LOCK_PENDING = 3; + const int SQLITE_LOCK_EXCLUSIVE = 4; + + /* + ** CAPI3REF: Synchronization Type Flags + ** + ** When SQLite invokes the xSync() method of an + ** [sqlite3_io_methods] object it uses a combination of + ** these integer values as the second argument. + ** + ** When the SQLITE_SYNC_DATAONLY flag is used, it means that the + ** sync operation only needs to flush data to mass storage. Inode + ** information need not be flushed. If the lower four bits of the flag + ** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics. + ** If the lower four bits equal SQLITE_SYNC_FULL, that means + ** to use Mac OS X style fullsync instead of fsync(). + ** + ** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags + ** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL + ** settings. The [synchronous pragma] determines when calls to the + ** xSync VFS method occur and applies uniformly across all platforms. + ** The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how + ** energetic or rigorous or forceful the sync operations are and + ** only make a difference on Mac OSX for the default SQLite code. + ** (Third-party VFS implementations might also make the distinction + ** between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the + ** operating systems natively supported by SQLite, only Mac OSX + ** cares about the difference.) + */ + //#define SQLITE_SYNC_NORMAL 0x00002 + //#define SQLITE_SYNC_FULL 0x00003 + //#define SQLITE_SYNC_DATAONLY 0x00010 + const int SQLITE_SYNC_NORMAL = 0x00002; + const int SQLITE_SYNC_FULL = 0x00003; + const int SQLITE_SYNC_DATAONLY = 0x00010; + + /* + ** CAPI3REF: OS Interface Open File Handle + ** + ** An [sqlite3_file] object represents an open file in the + ** [sqlite3_vfs | OS interface layer]. Individual OS interface + ** implementations will + ** want to subclass this object by appending additional fields + ** for their own use. The pMethods entry is a pointer to an + ** [sqlite3_io_methods] object that defines methods for performing + ** I/O operations on the open file. + */ + //typedef struct sqlite3_file sqlite3_file; + //struct sqlite3_file { + // const struct sqlite3_io_methods *pMethods; /* Methods for an open file */ + //}; + public partial class sqlite3_file { + public sqlite3_io_methods pMethods;/* Must be first */ + } /* ** CAPI3REF: OS Interface File Virtual Methods Object @@ -791,6695 +789,6670 @@ public partial class sqlite3_file ** failure to zero-fill short reads will eventually lead to ** database corruption. */ - //typedef struct sqlite3_io_methods sqlite3_io_methods; - //struct sqlite3_io_methods { - // int iVersion; - // int (*xClose)(sqlite3_file); - // int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst); - // int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst); - // int (*xTruncate)(sqlite3_file*, sqlite3_int64 size); - // int (*xSync)(sqlite3_file*, int flags); - // int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize); - // int (*xLock)(sqlite3_file*, int); - // int (*xUnlock)(sqlite3_file*, int); - // int (*xCheckReservedLock)(sqlite3_file*, int *pResOut); - // int (*xFileControl)(sqlite3_file*, int op, object *pArg); - // int (*xSectorSize)(sqlite3_file); - // int (*xDeviceCharacteristics)(sqlite3_file); - // /* Methods above are valid for version 1 */ - // int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, object volatile*); - // int (*xShmLock)(sqlite3_file*, int offset, int n, int flags); - // void (*xShmBarrier)(sqlite3_file); - // int (*xShmUnmap)(sqlite3_file*, int deleteFlag); - // /* Methods above are valid for version 2 */ - // /* Additional methods may be added in future releases */ - //}; - public class sqlite3_io_methods - { - public int iVersion; - public dxClose xClose; - public dxRead xRead; - public dxWrite xWrite; - public dxTruncate xTruncate; - public dxSync xSync; - public dxFileSize xFileSize; - public dxLock xLock; - public dxUnlock xUnlock; - public dxCheckReservedLock xCheckReservedLock; - public dxFileControl xFileControl; - public dxSectorSize xSectorSize; - public dxDeviceCharacteristics xDeviceCharacteristics; - public dxShmMap xShmMap;//int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, object volatile*); - public dxShmLock xShmLock;//int (*xShmLock)(sqlite3_file*, int offset, int n, int flags); - public dxShmBarrier xShmBarrier;//void (*xShmBarrier)(sqlite3_file); - public dxShmUnmap xShmUnmap;//int (*xShmUnmap)(sqlite3_file*, int deleteFlag); - /* Additional methods may be added in future releases */ - - public sqlite3_io_methods( int iVersion, - dxClose xClose, - dxRead xRead, - dxWrite xWrite, - dxTruncate xTruncate, - dxSync xSync, - dxFileSize xFileSize, - dxLock xLock, - dxUnlock xUnlock, - dxCheckReservedLock xCheckReservedLock, - dxFileControl xFileControl, - dxSectorSize xSectorSize, - dxDeviceCharacteristics xDeviceCharacteristics, - dxShmMap xShmMap, - dxShmLock xShmLock, - dxShmBarrier xShmBarrier, - dxShmUnmap xShmUnmap - ) - { - this.iVersion = iVersion; - this.xClose = xClose; - this.xRead = xRead; - this.xWrite = xWrite; - this.xTruncate = xTruncate; - this.xSync = xSync; - this.xFileSize = xFileSize; - this.xLock = xLock; - this.xUnlock = xUnlock; - this.xCheckReservedLock = xCheckReservedLock; - this.xFileControl = xFileControl; - this.xSectorSize = xSectorSize; - this.xDeviceCharacteristics = xDeviceCharacteristics; - this.xShmMap = xShmMap; - this.xShmLock = xShmLock; - this.xShmBarrier = xShmBarrier; - this.xShmUnmap = xShmUnmap; - } - } + //typedef struct sqlite3_io_methods sqlite3_io_methods; + //struct sqlite3_io_methods { + // int iVersion; + // int (*xClose)(sqlite3_file); + // int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst); + // int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst); + // int (*xTruncate)(sqlite3_file*, sqlite3_int64 size); + // int (*xSync)(sqlite3_file*, int flags); + // int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize); + // int (*xLock)(sqlite3_file*, int); + // int (*xUnlock)(sqlite3_file*, int); + // int (*xCheckReservedLock)(sqlite3_file*, int *pResOut); + // int (*xFileControl)(sqlite3_file*, int op, object *pArg); + // int (*xSectorSize)(sqlite3_file); + // int (*xDeviceCharacteristics)(sqlite3_file); + // /* Methods above are valid for version 1 */ + // int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, object volatile*); + // int (*xShmLock)(sqlite3_file*, int offset, int n, int flags); + // void (*xShmBarrier)(sqlite3_file); + // int (*xShmUnmap)(sqlite3_file*, int deleteFlag); + // /* Methods above are valid for version 2 */ + // /* Additional methods may be added in future releases */ + //}; + public class sqlite3_io_methods { + public int iVersion; + public dxClose xClose; + public dxRead xRead; + public dxWrite xWrite; + public dxTruncate xTruncate; + public dxSync xSync; + public dxFileSize xFileSize; + public dxLock xLock; + public dxUnlock xUnlock; + public dxCheckReservedLock xCheckReservedLock; + public dxFileControl xFileControl; + public dxSectorSize xSectorSize; + public dxDeviceCharacteristics xDeviceCharacteristics; + public dxShmMap xShmMap;//int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, object volatile*); + public dxShmLock xShmLock;//int (*xShmLock)(sqlite3_file*, int offset, int n, int flags); + public dxShmBarrier xShmBarrier;//void (*xShmBarrier)(sqlite3_file); + public dxShmUnmap xShmUnmap;//int (*xShmUnmap)(sqlite3_file*, int deleteFlag); + /* Additional methods may be added in future releases */ + + public sqlite3_io_methods(int iVersion, + dxClose xClose, + dxRead xRead, + dxWrite xWrite, + dxTruncate xTruncate, + dxSync xSync, + dxFileSize xFileSize, + dxLock xLock, + dxUnlock xUnlock, + dxCheckReservedLock xCheckReservedLock, + dxFileControl xFileControl, + dxSectorSize xSectorSize, + dxDeviceCharacteristics xDeviceCharacteristics, + dxShmMap xShmMap, + dxShmLock xShmLock, + dxShmBarrier xShmBarrier, + dxShmUnmap xShmUnmap + ) { + this.iVersion = iVersion; + this.xClose = xClose; + this.xRead = xRead; + this.xWrite = xWrite; + this.xTruncate = xTruncate; + this.xSync = xSync; + this.xFileSize = xFileSize; + this.xLock = xLock; + this.xUnlock = xUnlock; + this.xCheckReservedLock = xCheckReservedLock; + this.xFileControl = xFileControl; + this.xSectorSize = xSectorSize; + this.xDeviceCharacteristics = xDeviceCharacteristics; + this.xShmMap = xShmMap; + this.xShmLock = xShmLock; + this.xShmBarrier = xShmBarrier; + this.xShmUnmap = xShmUnmap; + } + } - /* - ** CAPI3REF: Standard File Control Opcodes - ** - ** These integer constants are opcodes for the xFileControl method - ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()] - ** interface. - ** - ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This - ** opcode causes the xFileControl method to write the current state of - ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED], - ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE]) - ** into an integer that the pArg argument points to. This capability - ** is used during testing and only needs to be supported when SQLITE_TEST - ** is defined. - ** - ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS - ** layer a hint of how large the database file will grow to be during the - ** current transaction. This hint is not guaranteed to be accurate but it - ** is often close. The underlying VFS might choose to preallocate database - ** file space based on this hint in order to help writes to the database - ** file run faster. - ** - ** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS - ** extends and truncates the database file in chunks of a size specified - ** by the user. The fourth argument to [sqlite3_file_control()] should - ** point to an integer (type int) containing the new chunk-size to use - ** for the nominated database. Allocating database file space in large - ** chunks (say 1MB at a time), may reduce file-system fragmentation and - ** improve performance on some systems. - ** - ** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer - ** to the [sqlite3_file] object associated with a particular database - ** connection. See the [sqlite3_file_control()] documentation for - ** additional information. - ** - ** ^(The [SQLITE_FCNTL_SYNC_OMITTED] opcode is generated internally by - ** SQLite and sent to all VFSes in place of a call to the xSync method - ** when the database connection has [PRAGMA synchronous] set to OFF.)^ - ** Some specialized VFSes need this signal in order to operate correctly - ** when [PRAGMA synchronous | PRAGMA synchronous=OFF] is set, but most - ** VFSes do not need this signal and should silently ignore this opcode. - ** Applications should not call [sqlite3_file_control()] with this - ** opcode as doing so may disrupt the operation of the specialized VFSes - ** that do require it. - */ - //#define SQLITE_FCNTL_LOCKSTATE 1 - //#define SQLITE_GET_LOCKPROXYFILE 2 - //#define SQLITE_SET_LOCKPROXYFILE 3 - //#define SQLITE_LAST_ERRNO 4 - //#define SQLITE_FCNTL_SIZE_HINT 5 - //#define SQLITE_FCNTL_CHUNK_SIZE 6 - //#define SQLITE_FCNTL_FILE_POINTER 7 - //#define SQLITE_FCNTL_SYNC_OMITTED 8 - - const int SQLITE_FCNTL_LOCKSTATE = 1; - const int SQLITE_GET_LOCKPROXYFILE = 2; - const int SQLITE_SET_LOCKPROXYFILE = 3; - const int SQLITE_LAST_ERRNO = 4; - const int SQLITE_FCNTL_SIZE_HINT = 5; - const int SQLITE_FCNTL_CHUNK_SIZE = 6; - const int SQLITE_FCNTL_FILE_POINTER = 7; - const int SQLITE_FCNTL_SYNC_OMITTED = 8; - - /* - ** CAPI3REF: Mutex Handle - ** - ** The mutex module within SQLite defines [sqlite3_mutex] to be an - ** abstract type for a mutex object. The SQLite core never looks - ** at the internal representation of an [sqlite3_mutex]. It only - ** deals with pointers to the [sqlite3_mutex] object. - ** - ** Mutexes are created using [sqlite3_mutex_alloc()]. - */ - //typedef struct sqlite3_mutex sqlite3_mutex; - - /* - ** CAPI3REF: OS Interface Object - ** - ** An instance of the sqlite3_vfs object defines the interface between - ** the SQLite core and the underlying operating system. The "vfs" - ** in the name of the object stands for "virtual file system". See - ** the [VFS | VFS documentation] for further information. - ** - ** The value of the iVersion field is initially 1 but may be larger in - ** future versions of SQLite. Additional fields may be appended to this - ** object when the iVersion value is increased. Note that the structure - ** of the sqlite3_vfs object changes in the transaction between - ** SQLite version 3.5.9 and 3.6.0 and yet the iVersion field was not - ** modified. - ** - ** The szOsFile field is the size of the subclassed [sqlite3_file] - ** structure used by this VFS. mxPathname is the maximum length of - ** a pathname in this VFS. - ** - ** Registered sqlite3_vfs objects are kept on a linked list formed by - ** the pNext pointer. The [sqlite3_vfs_register()] - ** and [sqlite3_vfs_unregister()] interfaces manage this list - ** in a thread-safe way. The [sqlite3_vfs_find()] interface - ** searches the list. Neither the application code nor the VFS - ** implementation should use the pNext pointer. - ** - ** The pNext field is the only field in the sqlite3_vfs - ** structure that SQLite will ever modify. SQLite will only access - ** or modify this field while holding a particular static mutex. - ** The application should never modify anything within the sqlite3_vfs - ** object once the object has been registered. - ** - ** The zName field holds the name of the VFS module. The name must - ** be unique across all VFS modules. - ** - ** [[sqlite3_vfs.xOpen] - ** ^SQLite guarantees that the zFilename parameter to xOpen - ** is either a NULL pointer or string obtained - ** from xFullPathname() with an optional suffix added. - ** ^If a suffix is added to the zFilename parameter, it will - ** consist of a single "-" character followed by no more than - ** 10 alphanumeric and/or "-" characters. - ** ^SQLite further guarantees that - ** the string will be valid and unchanged until xClose() is - ** called. Because of the previous sentence, - ** the [sqlite3_file] can safely store a pointer to the - ** filename if it needs to remember the filename for some reason. - ** If the zFilename parameter to xOpen is a NULL pointer then xOpen - ** must invent its own temporary name for the file. ^Whenever the - ** xFilename parameter is NULL it will also be the case that the - ** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE]. - ** - ** The flags argument to xOpen() includes all bits set in - ** the flags argument to [sqlite3_open_v2()]. Or if [sqlite3_open()] - ** or [sqlite3_open16()] is used, then flags includes at least - ** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. - ** If xOpen() opens a file read-only then it sets *pOutFlags to - ** include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be set. - ** - ** ^(SQLite will also add one of the following flags to the xOpen() - ** call, depending on the object being opened: - ** - **
    - **
  • [SQLITE_OPEN_MAIN_DB] - **
  • [SQLITE_OPEN_MAIN_JOURNAL] - **
  • [SQLITE_OPEN_TEMP_DB] - **
  • [SQLITE_OPEN_TEMP_JOURNAL] - **
  • [SQLITE_OPEN_TRANSIENT_DB] - **
  • [SQLITE_OPEN_SUBJOURNAL] - **
  • [SQLITE_OPEN_MASTER_JOURNAL] - **
  • [SQLITE_OPEN_WAL] - **
)^ - ** - ** The file I/O implementation can use the object type flags to - ** change the way it deals with files. For example, an application - ** that does not care about crash recovery or rollback might make - ** the open of a journal file a no-op. Writes to this journal would - ** also be no-ops, and any attempt to read the journal would return - ** SQLITE_IOERR. Or the implementation might recognize that a database - ** file will be doing page-aligned sector reads and writes in a random - ** order and set up its I/O subsystem accordingly. - ** - ** SQLite might also add one of the following flags to the xOpen method: - ** - **
    - **
  • [SQLITE_OPEN_DELETEONCLOSE] - **
  • [SQLITE_OPEN_EXCLUSIVE] - **
- ** - ** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be - ** deleted when it is closed. ^The [SQLITE_OPEN_DELETEONCLOSE] - ** will be set for TEMP databases and their journals, transient - ** databases, and subjournals. - ** - ** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction - ** with the [SQLITE_OPEN_CREATE] flag, which are both directly - ** analogous to the O_EXCL and O_CREAT flags of the POSIX open() - ** API. The SQLITE_OPEN_EXCLUSIVE flag, when paired with the - ** SQLITE_OPEN_CREATE, is used to indicate that file should always - ** be created, and that it is an error if it already exists. - ** It is not used to indicate the file should be opened - ** for exclusive access. - ** - ** ^At least szOsFile bytes of memory are allocated by SQLite - ** to hold the [sqlite3_file] structure passed as the third - ** argument to xOpen. The xOpen method does not have to - ** allocate the structure; it should just fill it in. Note that - ** the xOpen method must set the sqlite3_file.pMethods to either - ** a valid [sqlite3_io_methods] object or to NULL. xOpen must do - ** this even if the open fails. SQLite expects that the sqlite3_file.pMethods - ** element will be valid after xOpen returns regardless of the success - ** or failure of the xOpen call. - ** - ** [[sqlite3_vfs.xAccess] - ** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS] - ** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to - ** test whether a file is readable and writable, or [SQLITE_ACCESS_READ] - ** to test whether a file is at least readable. The file can be a - ** directory. - ** - ** ^SQLite will always allocate at least mxPathname+1 bytes for the - ** output buffer xFullPathname. The exact size of the output buffer - ** is also passed as a parameter to both methods. If the output buffer - ** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is - ** handled as a fatal error by SQLite, vfs implementations should endeavor - ** to prevent this by setting mxPathname to a sufficiently large value. - ** - ** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64() - ** interfaces are not strictly a part of the filesystem, but they are - ** included in the VFS structure for completeness. - ** The xRandomness() function attempts to return nBytes bytes - ** of good-quality randomness into zOut. The return value is - ** the actual number of bytes of randomness obtained. - ** The xSleep() method causes the calling thread to sleep for at - ** least the number of microseconds given. ^The xCurrentTime() - ** method returns a Julian Day Number for the current date and time as - ** a floating point value. - ** ^The xCurrentTimeInt64() method returns, as an integer, the Julian - ** Day Number multiplied by 86400000 (the number of milliseconds in - ** a 24-hour day). - ** ^SQLite will use the xCurrentTimeInt64() method to get the current - ** date and time if that method is available (if iVersion is 2 or - ** greater and the function pointer is not NULL) and will fall back - ** to xCurrentTime() if xCurrentTimeInt64() is unavailable. - ** - ** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces - ** are not used by the SQLite core. These optional interfaces are provided - ** by some VFSes to facilitate testing of the VFS code. By overriding - ** system calls with functions under its control, a test program can - ** simulate faults and error conditions that would otherwise be difficult - ** or impossible to induce. The set of system calls that can be overridden - ** varies from one VFS to another, and from one version of the same VFS to the - ** next. Applications that use these interfaces must be prepared for any - ** or all of these interfaces to be NULL or for their behavior to change - ** from one release to the next. Applications must not attempt to access - ** any of these methods if the iVersion of the VFS is less than 3. - */ - //typedef struct sqlite3_vfs sqlite3_vfs; - //typedef void (*sqlite3_syscall_ptr)(void); - //struct sqlite3_vfs { - // int iVersion; /* Structure version number (currently 3) */ - // int szOsFile; /* Size of subclassed sqlite3_file */ - // int mxPathname; /* Maximum file pathname length */ - // sqlite3_vfs *pNext; /* Next registered VFS */ - // string zName; /* Name of this virtual file system */ - // void *pAppData; /* Pointer to application-specific data */ - // int (*xOpen)(sqlite3_vfs*, string zName, sqlite3_file*, - // int flags, int *pOutFlags); - // int (*xDelete)(sqlite3_vfs*, string zName, int syncDir); - // int (*xAccess)(sqlite3_vfs*, string zName, int flags, int *pResOut); - // int (*xFullPathname)(sqlite3_vfs*, string zName, int nOut, string zOut); - // void *(*xDlOpen)(sqlite3_vfs*, string zFilename); - // void (*xDlError)(sqlite3_vfs*, int nByte, string zErrMsg); - // void (*(*xDlSym)(sqlite3_vfs*,void*, string zSymbol))(void); - // void (*xDlClose)(sqlite3_vfs*, void); - // int (*xRandomness)(sqlite3_vfs*, int nByte, string zOut); - // int (*xSleep)(sqlite3_vfs*, int microseconds); - // int (*xCurrentTime)(sqlite3_vfs*, double); - // int (*xGetLastError)(sqlite3_vfs*, int, char ); - // /* - // ** The methods above are in version 1 of the sqlite_vfs object - // ** definition. Those that follow are added in version 2 or later - // */ - // int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64); - // /* - // ** The methods above are in versions 1 and 2 of the sqlite_vfs object. - // ** New fields may be appended in figure versions. The iVersion - // ** value will increment whenever this happens. - // */ - //}; - public class sqlite3_vfs - { - public int iVersion; /* Structure version number (currently 3) */ - public int szOsFile; /* Size of subclassed sqlite3_file */ - public int mxPathname; /* Maximum file pathname length */ - public sqlite3_vfs pNext; /* Next registered VFS */ - public string zName; /* Name of this virtual file system */ - public object pAppData; /* Pointer to application-specific data */ - public dxOpen xOpen; - public dxDelete xDelete; - public dxAccess xAccess; - public dxFullPathname xFullPathname; - public dxDlOpen xDlOpen; - public dxDlError xDlError; - public dxDlSym xDlSym; - public dxDlClose xDlClose; - public dxRandomness xRandomness; - public dxSleep xSleep; - public dxCurrentTime xCurrentTime; - public dxGetLastError xGetLastError; - /* - ** The methods above are in version 1 of the sqlite_vfs object - ** definition. Those that follow are added in version 2 or later - */ - public dxCurrentTimeInt64 xCurrentTimeInt64; - /* - ** The methods above are in versions 1 and 2 of the sqlite_vfs object. - ** Those below are for version 3 and greater. - */ - //int (*xSetSystemCall)(sqlite3_vfs*, string zName, sqlite3_syscall_ptr); - public dxSetSystemCall xSetSystemCall; - //sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, string zName); - public dxGetSystemCall xGetSystemCall; - //string (*xNextSystemCall)(sqlite3_vfs*, string zName); - public dxNextSystemCall xNextSystemCall; - /* - ** The methods above are in versions 1 through 3 of the sqlite_vfs object. - ** New fields may be appended in figure versions. The iVersion - ** value will increment whenever this happens. - */ - /* New fields may be appended in figure versions. The iVersion - ** value will increment whenever this happens. */ - - public sqlite3_vfs() - { - } - - public sqlite3_vfs( int iVersion, - int szOsFile, - int mxPathname, - sqlite3_vfs pNext, - string zName, - object pAppData, - dxOpen xOpen, - dxDelete xDelete, - dxAccess xAccess, - dxFullPathname xFullPathname, - dxDlOpen xDlOpen, - dxDlError xDlError, - dxDlSym xDlSym, - dxDlClose xDlClose, - dxRandomness xRandomness, - dxSleep xSleep, - dxCurrentTime xCurrentTime, - dxGetLastError xGetLastError, - dxCurrentTimeInt64 xCurrentTimeInt64, - dxSetSystemCall xSetSystemCall, - dxGetSystemCall xGetSystemCall, - dxNextSystemCall xNextSystemCall) - { - this.iVersion = iVersion; - this.szOsFile = szOsFile; - this.mxPathname = mxPathname; - this.pNext = pNext; - this.zName = zName; - this.pAppData = pAppData; - this.xOpen = xOpen; - this.xDelete = xDelete; - this.xAccess = xAccess; - this.xFullPathname = xFullPathname; - this.xDlOpen = xDlOpen; - this.xDlError = xDlError; - this.xDlSym = xDlSym; - this.xDlClose = xDlClose; - this.xRandomness = xRandomness; - this.xSleep = xSleep; - this.xCurrentTime = xCurrentTime; - this.xGetLastError = xGetLastError; - this.xCurrentTimeInt64 = xCurrentTimeInt64; - } - public void CopyTo(sqlite3_vfs ct) - { - ct.iVersion = this.iVersion; - ct.szOsFile = this.szOsFile; - ct.mxPathname = this.mxPathname; - ct.pNext = this.pNext; - ct.zName = this.zName; - ct.pAppData = this.pAppData; - ct.xOpen = this.xOpen; - ct.xDelete = this.xDelete; - ct.xAccess = this.xAccess; - ct.xFullPathname = this.xFullPathname; - ct.xDlOpen = this.xDlOpen; - ct.xDlError = this.xDlError; - ct.xDlSym = this.xDlSym; - ct.xDlClose = this.xDlClose; - ct.xRandomness = this.xRandomness; - ct.xSleep = this.xSleep; - ct.xCurrentTime = this.xCurrentTime; - ct.xGetLastError = this.xGetLastError; - ct.xCurrentTimeInt64 = this.xCurrentTimeInt64; - } - } + /* + ** CAPI3REF: Standard File Control Opcodes + ** + ** These integer constants are opcodes for the xFileControl method + ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()] + ** interface. + ** + ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This + ** opcode causes the xFileControl method to write the current state of + ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED], + ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE]) + ** into an integer that the pArg argument points to. This capability + ** is used during testing and only needs to be supported when SQLITE_TEST + ** is defined. + ** + ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS + ** layer a hint of how large the database file will grow to be during the + ** current transaction. This hint is not guaranteed to be accurate but it + ** is often close. The underlying VFS might choose to preallocate database + ** file space based on this hint in order to help writes to the database + ** file run faster. + ** + ** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS + ** extends and truncates the database file in chunks of a size specified + ** by the user. The fourth argument to [sqlite3_file_control()] should + ** point to an integer (type int) containing the new chunk-size to use + ** for the nominated database. Allocating database file space in large + ** chunks (say 1MB at a time), may reduce file-system fragmentation and + ** improve performance on some systems. + ** + ** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer + ** to the [sqlite3_file] object associated with a particular database + ** connection. See the [sqlite3_file_control()] documentation for + ** additional information. + ** + ** ^(The [SQLITE_FCNTL_SYNC_OMITTED] opcode is generated internally by + ** SQLite and sent to all VFSes in place of a call to the xSync method + ** when the database connection has [PRAGMA synchronous] set to OFF.)^ + ** Some specialized VFSes need this signal in order to operate correctly + ** when [PRAGMA synchronous | PRAGMA synchronous=OFF] is set, but most + ** VFSes do not need this signal and should silently ignore this opcode. + ** Applications should not call [sqlite3_file_control()] with this + ** opcode as doing so may disrupt the operation of the specialized VFSes + ** that do require it. + */ + //#define SQLITE_FCNTL_LOCKSTATE 1 + //#define SQLITE_GET_LOCKPROXYFILE 2 + //#define SQLITE_SET_LOCKPROXYFILE 3 + //#define SQLITE_LAST_ERRNO 4 + //#define SQLITE_FCNTL_SIZE_HINT 5 + //#define SQLITE_FCNTL_CHUNK_SIZE 6 + //#define SQLITE_FCNTL_FILE_POINTER 7 + //#define SQLITE_FCNTL_SYNC_OMITTED 8 + + const int SQLITE_FCNTL_LOCKSTATE = 1; + const int SQLITE_GET_LOCKPROXYFILE = 2; + const int SQLITE_SET_LOCKPROXYFILE = 3; + const int SQLITE_LAST_ERRNO = 4; + const int SQLITE_FCNTL_SIZE_HINT = 5; + const int SQLITE_FCNTL_CHUNK_SIZE = 6; + const int SQLITE_FCNTL_FILE_POINTER = 7; + const int SQLITE_FCNTL_SYNC_OMITTED = 8; + /* + ** CAPI3REF: Mutex Handle + ** + ** The mutex module within SQLite defines [sqlite3_mutex] to be an + ** abstract type for a mutex object. The SQLite core never looks + ** at the internal representation of an [sqlite3_mutex]. It only + ** deals with pointers to the [sqlite3_mutex] object. + ** + ** Mutexes are created using [sqlite3_mutex_alloc()]. + */ + //typedef struct sqlite3_mutex sqlite3_mutex; - /* - ** CAPI3REF: Flags for the xAccess VFS method - ** - ** These integer constants can be used as the third parameter to - ** the xAccess method of an [sqlite3_vfs] object. They determine - ** what kind of permissions the xAccess method is looking for. - ** With SQLITE_ACCESS_EXISTS, the xAccess method - ** simply checks whether the file exists. - ** With SQLITE_ACCESS_READWRITE, the xAccess method - ** checks whether the named directory is both readable and writable - ** (in other words, if files can be added, removed, and renamed within - ** the directory). - ** The SQLITE_ACCESS_READWRITE constant is currently used only by the - ** [temp_store_directory pragma], though this could change in a future - ** release of SQLite. - ** With SQLITE_ACCESS_READ, the xAccess method - ** checks whether the file is readable. The SQLITE_ACCESS_READ constant is - ** currently unused, though it might be used in a future release of - ** SQLite. - */ - //#define SQLITE_ACCESS_EXISTS 0 - //#define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */ - //#define SQLITE_ACCESS_READ 2 /* Unused */ - const int SQLITE_ACCESS_EXISTS = 0; - const int SQLITE_ACCESS_READWRITE = 1; - const int SQLITE_ACCESS_READ = 2; - - - /* - ** CAPI3REF: Flags for the xShmLock VFS method - ** - ** These integer constants define the various locking operations - ** allowed by the xShmLock method of [sqlite3_io_methods]. The - ** following are the only legal combinations of flags to the - ** xShmLock method: - ** - **
    - **
  • SQLITE_SHM_LOCK | SQLITE_SHM_SHARED - **
  • SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE - **
  • SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED - **
  • SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE - **
- ** - ** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as - ** was given no the corresponding lock. - ** - ** The xShmLock method can transition between unlocked and SHARED or - ** between unlocked and EXCLUSIVE. It cannot transition between SHARED - ** and EXCLUSIVE. - */ - //#define SQLITE_SHM_UNLOCK 1 - //#define SQLITE_SHM_LOCK 2 - //#define SQLITE_SHM_SHARED 4 - //#define SQLITE_SHM_EXCLUSIVE 8 - const int SQLITE_SHM_UNLOCK = 1; - const int SQLITE_SHM_LOCK = 2; - const int SQLITE_SHM_SHARED = 4; - const int SQLITE_SHM_EXCLUSIVE = 8; - - - /* - ** CAPI3REF: Maximum xShmLock index - ** - ** The xShmLock method on [sqlite3_io_methods] may use values - ** between 0 and this upper bound as its "offset" argument. - ** The SQLite core will never attempt to acquire or release a - ** lock outside of this range - */ - //#define SQLITE_SHM_NLOCK 8 - const int SQLITE_SHM_NLOCK = 8; - - /* - ** CAPI3REF: Initialize The SQLite Library - ** - ** ^The sqlite3_initialize() routine initializes the - ** SQLite library. ^The sqlite3_shutdown() routine - ** deallocates any resources that were allocated by sqlite3_initialize(). - ** These routines are designed to aid in process initialization and - ** shutdown on embedded systems. Workstation applications using - ** SQLite normally do not need to invoke either of these routines. - ** - ** A call to sqlite3_initialize() is an "effective" call if it is - ** the first time sqlite3_initialize() is invoked during the lifetime of - ** the process, or if it is the first time sqlite3_initialize() is invoked - ** following a call to sqlite3_shutdown(). ^(Only an effective call - ** of sqlite3_initialize() does any initialization. All other calls - ** are harmless no-ops.)^ - ** - ** A call to sqlite3_shutdown() is an "effective" call if it is the first - ** call to sqlite3_shutdown() since the last sqlite3_initialize(). ^(Only - ** an effective call to sqlite3_shutdown() does any deinitialization. - ** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^ - ** - ** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown() - ** is not. The sqlite3_shutdown() interface must only be called from a - ** single thread. All open [database connections] must be closed and all - ** other SQLite resources must be deallocated prior to invoking - ** sqlite3_shutdown(). - ** - ** Among other things, ^sqlite3_initialize() will invoke - ** sqlite3_os_init(). Similarly, ^sqlite3_shutdown() - ** will invoke sqlite3_os_end(). - ** - ** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success. - ** ^If for some reason, sqlite3_initialize() is unable to initialize - ** the library (perhaps it is unable to allocate a needed resource such - ** as a mutex) it returns an [error code] other than [SQLITE_OK]. - ** - ** ^The sqlite3_initialize() routine is called internally by many other - ** SQLite interfaces so that an application usually does not need to - ** invoke sqlite3_initialize() directly. For example, [sqlite3_open()] - ** calls sqlite3_initialize() so the SQLite library will be automatically - ** initialized when [sqlite3_open()] is called if it has not be initialized - ** already. ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT] - ** compile-time option, then the automatic calls to sqlite3_initialize() - ** are omitted and the application must call sqlite3_initialize() directly - ** prior to using any other SQLite interface. For maximum portability, - ** it is recommended that applications always invoke sqlite3_initialize() - ** directly prior to using any other SQLite interface. Future releases - ** of SQLite may require this. In other words, the behavior exhibited - ** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the - ** default behavior in some future release of SQLite. - ** - ** The sqlite3_os_init() routine does operating-system specific - ** initialization of the SQLite library. The sqlite3_os_end() - ** routine undoes the effect of sqlite3_os_init(). Typical tasks - ** performed by these routines include allocation or deallocation - ** of static resources, initialization of global variables, - ** setting up a default [sqlite3_vfs] module, or setting up - ** a default configuration using [sqlite3_config()]. - ** - ** The application should never invoke either sqlite3_os_init() - ** or sqlite3_os_end() directly. The application should only invoke - ** sqlite3_initialize() and sqlite3_shutdown(). The sqlite3_os_init() - ** interface is called automatically by sqlite3_initialize() and - ** sqlite3_os_end() is called by sqlite3_shutdown(). Appropriate - ** implementations for sqlite3_os_init() and sqlite3_os_end() - ** are built into SQLite when it is compiled for Unix, Windows, or OS/2. - ** When [custom builds | built for other platforms] - ** (using the [SQLITE_OS_OTHER=1] compile-time - ** option) the application must supply a suitable implementation for - ** sqlite3_os_init() and sqlite3_os_end(). An application-supplied - ** implementation of sqlite3_os_init() or sqlite3_os_end() - ** must return [SQLITE_OK] on success and some other [error code] upon - ** failure. - */ - //SQLITE_API int sqlite3_initialize(void); - //SQLITE_API int sqlite3_shutdown(void); - //SQLITE_API int sqlite3_os_init(void); - //SQLITE_API int sqlite3_os_end(void); - - /* - ** CAPI3REF: Configuring The SQLite Library - ** - ** The sqlite3_config() interface is used to make global configuration - ** changes to SQLite in order to tune SQLite to the specific needs of - ** the application. The default configuration is recommended for most - ** applications and so this routine is usually not necessary. It is - ** provided to support rare applications with unusual needs. - ** - ** The sqlite3_config() interface is not threadsafe. The application - ** must insure that no other SQLite interfaces are invoked by other - ** threads while sqlite3_config() is running. Furthermore, sqlite3_config() - ** may only be invoked prior to library initialization using - ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()]. - ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before - ** [sqlite3_shutdown()] then it will return SQLITE_MISUSE. - ** Note, however, that ^sqlite3_config() can be called as part of the - ** implementation of an application-defined [sqlite3_os_init()]. - ** - ** The first argument to sqlite3_config() is an integer - ** [configuration option] that determines - ** what property of SQLite is to be configured. Subsequent arguments - ** vary depending on the [configuration option] - ** in the first argument. - ** - ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK]. - ** ^If the option is unknown or SQLite is unable to set the option - ** then this routine returns a non-zero [error code]. - */ - //SQLITE_API int sqlite3_config(int, ...); - - /* - ** CAPI3REF: Configure database connections - ** - ** The sqlite3_db_config() interface is used to make configuration - ** changes to a [database connection]. The interface is similar to - ** [sqlite3_config()] except that the changes apply to a single - ** [database connection] (specified in the first argument). - ** - ** The second argument to sqlite3_db_config(D,V,...) is the - ** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code - ** that indicates what aspect of the [database connection] is being configured. - ** Subsequent arguments vary depending on the configuration verb. - ** - ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if - ** the call is considered successful. - */ - //SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...); - - /* - ** CAPI3REF: Memory Allocation Routines - ** - ** An instance of this object defines the interface between SQLite - ** and low-level memory allocation routines. - ** - ** This object is used in only one place in the SQLite interface. - ** A pointer to an instance of this object is the argument to - ** [sqlite3_config()] when the configuration option is - ** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC]. - ** By creating an instance of this object - ** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC]) - ** during configuration, an application can specify an alternative - ** memory allocation subsystem for SQLite to use for all of its - ** dynamic memory needs. - ** - ** Note that SQLite comes with several [built-in memory allocators] - ** that are perfectly adequate for the overwhelming majority of applications - ** and that this object is only useful to a tiny minority of applications - ** with specialized memory allocation requirements. This object is - ** also used during testing of SQLite in order to specify an alternative - ** memory allocator that simulates memory out-of-memory conditions in - ** order to verify that SQLite recovers gracefully from such - ** conditions. - ** - ** The xMalloc and xFree methods must work like the - ** malloc() and free() functions from the standard C library. - ** The xRealloc method must work like realloc() from the standard C library - ** with the exception that if the second argument to xRealloc is zero, - ** xRealloc must be a no-op - it must not perform any allocation or - ** deallocation. ^SQLite guarantees that the second argument to - ** xRealloc is always a value returned by a prior call to xRoundup. - ** And so in cases where xRoundup always returns a positive number, - ** xRealloc can perform exactly as the standard library realloc() and - ** still be in compliance with this specification. - ** - ** xSize should return the allocated size of a memory allocation - ** previously obtained from xMalloc or xRealloc. The allocated size - ** is always at least as big as the requested size but may be larger. - ** - ** The xRoundup method returns what would be the allocated size of - ** a memory allocation given a particular requested size. Most memory - ** allocators round up memory allocations at least to the next multiple - ** of 8. Some allocators round up to a larger multiple or to a power of 2. - ** Every memory allocation request coming in through [sqlite3_malloc()] - ** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0, - ** that causes the corresponding memory allocation to fail. - ** - ** The xInit method initializes the memory allocator. (For example, - ** it might allocate any require mutexes or initialize internal data - ** structures. The xShutdown method is invoked (indirectly) by - ** [sqlite3_shutdown()] and should deallocate any resources acquired - ** by xInit. The pAppData pointer is used as the only parameter to - ** xInit and xShutdown. - ** - ** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes - ** the xInit method, so the xInit method need not be threadsafe. The - ** xShutdown method is only called from [sqlite3_shutdown()] so it does - ** not need to be threadsafe either. For all other methods, SQLite - ** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the - ** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which - ** it is by default) and so the methods are automatically serialized. - ** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other - ** methods must be threadsafe or else make their own arrangements for - ** serialization. - ** - ** SQLite will never invoke xInit() more than once without an intervening - ** call to xShutdown(). - */ - //typedef struct sqlite3_mem_methods sqlite3_mem_methods; - //struct sqlite3_mem_methods { - // void *(*xMalloc)(int); /* Memory allocation function */ - // void (*xFree)(void); /* Free a prior allocation */ - // void *(*xRealloc)(void*,int); /* Resize an allocation */ - // int (*xSize)(void); /* Return the size of an allocation */ - // int (*xRoundup)(int); /* Round up request size to allocation size */ - // int (*xInit)(void); /* Initialize the memory allocator */ - // void (*xShutdown)(void); /* Deinitialize the memory allocator */ - // void *pAppData; /* Argument to xInit() and xShutdown() */ - //}; - public class sqlite3_mem_methods - { - public dxMalloc xMalloc; //void *(*xMalloc)(int); /* Memory allocation function */ - public dxMallocInt xMallocInt; //void *(*xMalloc)(int); /* Memory allocation function */ - public dxMallocMem xMallocMem; //void *(*xMalloc)(int); /* Memory allocation function */ - public dxFree xFree; //void (*xFree)(void); /* Free a prior allocation */ - public dxFreeInt xFreeInt; //void (*xFree)(void); /* Free a prior allocation */ - public dxFreeMem xFreeMem; //void (*xFree)(void); /* Free a prior allocation */ - public dxRealloc xRealloc; //void *(*xRealloc)(void*,int); /* Resize an allocation */ - public dxSize xSize; //int (*xSize)(void); /* Return the size of an allocation */ - public dxRoundup xRoundup; //int (*xRoundup)(int); /* Round up request size to allocation size */ - public dxMemInit xInit; //int (*xInit)(void); /* Initialize the memory allocator */ - public dxMemShutdown xShutdown; //void (*xShutdown)(void); /* Deinitialize the memory allocator */ - public object pAppData; /* Argument to xInit() and xShutdown() */ - - public sqlite3_mem_methods() - { - } - - public sqlite3_mem_methods( - dxMalloc xMalloc, - dxMallocInt xMallocInt, - dxMallocMem xMallocMem, - dxFree xFree, - dxFreeInt xFreeInt, - dxFreeMem xFreeMem, - dxRealloc xRealloc, - dxSize xSize, - dxRoundup xRoundup, - dxMemInit xInit, - dxMemShutdown xShutdown, - object pAppData - ) - { - this.xMalloc = xMalloc; - this.xMallocInt = xMallocInt; - this.xMallocMem = xMallocMem; - this.xFree = xFree; - this.xFreeInt = xFreeInt; - this.xFreeMem = xFreeMem; - this.xRealloc = xRealloc; - this.xSize = xSize; - this.xRoundup = xRoundup; - this.xInit = xInit; - this.xShutdown = xShutdown; - this.pAppData = pAppData; - } - } + /* + ** CAPI3REF: OS Interface Object + ** + ** An instance of the sqlite3_vfs object defines the interface between + ** the SQLite core and the underlying operating system. The "vfs" + ** in the name of the object stands for "virtual file system". See + ** the [VFS | VFS documentation] for further information. + ** + ** The value of the iVersion field is initially 1 but may be larger in + ** future versions of SQLite. Additional fields may be appended to this + ** object when the iVersion value is increased. Note that the structure + ** of the sqlite3_vfs object changes in the transaction between + ** SQLite version 3.5.9 and 3.6.0 and yet the iVersion field was not + ** modified. + ** + ** The szOsFile field is the size of the subclassed [sqlite3_file] + ** structure used by this VFS. mxPathname is the maximum length of + ** a pathname in this VFS. + ** + ** Registered sqlite3_vfs objects are kept on a linked list formed by + ** the pNext pointer. The [sqlite3_vfs_register()] + ** and [sqlite3_vfs_unregister()] interfaces manage this list + ** in a thread-safe way. The [sqlite3_vfs_find()] interface + ** searches the list. Neither the application code nor the VFS + ** implementation should use the pNext pointer. + ** + ** The pNext field is the only field in the sqlite3_vfs + ** structure that SQLite will ever modify. SQLite will only access + ** or modify this field while holding a particular static mutex. + ** The application should never modify anything within the sqlite3_vfs + ** object once the object has been registered. + ** + ** The zName field holds the name of the VFS module. The name must + ** be unique across all VFS modules. + ** + ** [[sqlite3_vfs.xOpen] + ** ^SQLite guarantees that the zFilename parameter to xOpen + ** is either a NULL pointer or string obtained + ** from xFullPathname() with an optional suffix added. + ** ^If a suffix is added to the zFilename parameter, it will + ** consist of a single "-" character followed by no more than + ** 10 alphanumeric and/or "-" characters. + ** ^SQLite further guarantees that + ** the string will be valid and unchanged until xClose() is + ** called. Because of the previous sentence, + ** the [sqlite3_file] can safely store a pointer to the + ** filename if it needs to remember the filename for some reason. + ** If the zFilename parameter to xOpen is a NULL pointer then xOpen + ** must invent its own temporary name for the file. ^Whenever the + ** xFilename parameter is NULL it will also be the case that the + ** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE]. + ** + ** The flags argument to xOpen() includes all bits set in + ** the flags argument to [sqlite3_open_v2()]. Or if [sqlite3_open()] + ** or [sqlite3_open16()] is used, then flags includes at least + ** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. + ** If xOpen() opens a file read-only then it sets *pOutFlags to + ** include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be set. + ** + ** ^(SQLite will also add one of the following flags to the xOpen() + ** call, depending on the object being opened: + ** + **
    + **
  • [SQLITE_OPEN_MAIN_DB] + **
  • [SQLITE_OPEN_MAIN_JOURNAL] + **
  • [SQLITE_OPEN_TEMP_DB] + **
  • [SQLITE_OPEN_TEMP_JOURNAL] + **
  • [SQLITE_OPEN_TRANSIENT_DB] + **
  • [SQLITE_OPEN_SUBJOURNAL] + **
  • [SQLITE_OPEN_MASTER_JOURNAL] + **
  • [SQLITE_OPEN_WAL] + **
)^ + ** + ** The file I/O implementation can use the object type flags to + ** change the way it deals with files. For example, an application + ** that does not care about crash recovery or rollback might make + ** the open of a journal file a no-op. Writes to this journal would + ** also be no-ops, and any attempt to read the journal would return + ** SQLITE_IOERR. Or the implementation might recognize that a database + ** file will be doing page-aligned sector reads and writes in a random + ** order and set up its I/O subsystem accordingly. + ** + ** SQLite might also add one of the following flags to the xOpen method: + ** + **
    + **
  • [SQLITE_OPEN_DELETEONCLOSE] + **
  • [SQLITE_OPEN_EXCLUSIVE] + **
+ ** + ** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be + ** deleted when it is closed. ^The [SQLITE_OPEN_DELETEONCLOSE] + ** will be set for TEMP databases and their journals, transient + ** databases, and subjournals. + ** + ** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction + ** with the [SQLITE_OPEN_CREATE] flag, which are both directly + ** analogous to the O_EXCL and O_CREAT flags of the POSIX open() + ** API. The SQLITE_OPEN_EXCLUSIVE flag, when paired with the + ** SQLITE_OPEN_CREATE, is used to indicate that file should always + ** be created, and that it is an error if it already exists. + ** It is not used to indicate the file should be opened + ** for exclusive access. + ** + ** ^At least szOsFile bytes of memory are allocated by SQLite + ** to hold the [sqlite3_file] structure passed as the third + ** argument to xOpen. The xOpen method does not have to + ** allocate the structure; it should just fill it in. Note that + ** the xOpen method must set the sqlite3_file.pMethods to either + ** a valid [sqlite3_io_methods] object or to NULL. xOpen must do + ** this even if the open fails. SQLite expects that the sqlite3_file.pMethods + ** element will be valid after xOpen returns regardless of the success + ** or failure of the xOpen call. + ** + ** [[sqlite3_vfs.xAccess] + ** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS] + ** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to + ** test whether a file is readable and writable, or [SQLITE_ACCESS_READ] + ** to test whether a file is at least readable. The file can be a + ** directory. + ** + ** ^SQLite will always allocate at least mxPathname+1 bytes for the + ** output buffer xFullPathname. The exact size of the output buffer + ** is also passed as a parameter to both methods. If the output buffer + ** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is + ** handled as a fatal error by SQLite, vfs implementations should endeavor + ** to prevent this by setting mxPathname to a sufficiently large value. + ** + ** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64() + ** interfaces are not strictly a part of the filesystem, but they are + ** included in the VFS structure for completeness. + ** The xRandomness() function attempts to return nBytes bytes + ** of good-quality randomness into zOut. The return value is + ** the actual number of bytes of randomness obtained. + ** The xSleep() method causes the calling thread to sleep for at + ** least the number of microseconds given. ^The xCurrentTime() + ** method returns a Julian Day Number for the current date and time as + ** a floating point value. + ** ^The xCurrentTimeInt64() method returns, as an integer, the Julian + ** Day Number multiplied by 86400000 (the number of milliseconds in + ** a 24-hour day). + ** ^SQLite will use the xCurrentTimeInt64() method to get the current + ** date and time if that method is available (if iVersion is 2 or + ** greater and the function pointer is not NULL) and will fall back + ** to xCurrentTime() if xCurrentTimeInt64() is unavailable. + ** + ** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces + ** are not used by the SQLite core. These optional interfaces are provided + ** by some VFSes to facilitate testing of the VFS code. By overriding + ** system calls with functions under its control, a test program can + ** simulate faults and error conditions that would otherwise be difficult + ** or impossible to induce. The set of system calls that can be overridden + ** varies from one VFS to another, and from one version of the same VFS to the + ** next. Applications that use these interfaces must be prepared for any + ** or all of these interfaces to be NULL or for their behavior to change + ** from one release to the next. Applications must not attempt to access + ** any of these methods if the iVersion of the VFS is less than 3. + */ + //typedef struct sqlite3_vfs sqlite3_vfs; + //typedef void (*sqlite3_syscall_ptr)(void); + //struct sqlite3_vfs { + // int iVersion; /* Structure version number (currently 3) */ + // int szOsFile; /* Size of subclassed sqlite3_file */ + // int mxPathname; /* Maximum file pathname length */ + // sqlite3_vfs *pNext; /* Next registered VFS */ + // string zName; /* Name of this virtual file system */ + // void *pAppData; /* Pointer to application-specific data */ + // int (*xOpen)(sqlite3_vfs*, string zName, sqlite3_file*, + // int flags, int *pOutFlags); + // int (*xDelete)(sqlite3_vfs*, string zName, int syncDir); + // int (*xAccess)(sqlite3_vfs*, string zName, int flags, int *pResOut); + // int (*xFullPathname)(sqlite3_vfs*, string zName, int nOut, string zOut); + // void *(*xDlOpen)(sqlite3_vfs*, string zFilename); + // void (*xDlError)(sqlite3_vfs*, int nByte, string zErrMsg); + // void (*(*xDlSym)(sqlite3_vfs*,void*, string zSymbol))(void); + // void (*xDlClose)(sqlite3_vfs*, void); + // int (*xRandomness)(sqlite3_vfs*, int nByte, string zOut); + // int (*xSleep)(sqlite3_vfs*, int microseconds); + // int (*xCurrentTime)(sqlite3_vfs*, double); + // int (*xGetLastError)(sqlite3_vfs*, int, char ); + // /* + // ** The methods above are in version 1 of the sqlite_vfs object + // ** definition. Those that follow are added in version 2 or later + // */ + // int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64); + // /* + // ** The methods above are in versions 1 and 2 of the sqlite_vfs object. + // ** New fields may be appended in figure versions. The iVersion + // ** value will increment whenever this happens. + // */ + //}; + public class sqlite3_vfs { + public int iVersion; /* Structure version number (currently 3) */ + public int szOsFile; /* Size of subclassed sqlite3_file */ + public int mxPathname; /* Maximum file pathname length */ + public sqlite3_vfs pNext; /* Next registered VFS */ + public string zName; /* Name of this virtual file system */ + public object pAppData; /* Pointer to application-specific data */ + public dxOpen xOpen; + public dxDelete xDelete; + public dxAccess xAccess; + public dxFullPathname xFullPathname; + public dxDlOpen xDlOpen; + public dxDlError xDlError; + public dxDlSym xDlSym; + public dxDlClose xDlClose; + public dxRandomness xRandomness; + public dxSleep xSleep; + public dxCurrentTime xCurrentTime; + public dxGetLastError xGetLastError; + /* + ** The methods above are in version 1 of the sqlite_vfs object + ** definition. Those that follow are added in version 2 or later + */ + public dxCurrentTimeInt64 xCurrentTimeInt64; + /* + ** The methods above are in versions 1 and 2 of the sqlite_vfs object. + ** Those below are for version 3 and greater. + */ + //int (*xSetSystemCall)(sqlite3_vfs*, string zName, sqlite3_syscall_ptr); + public dxSetSystemCall xSetSystemCall; + //sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, string zName); + public dxGetSystemCall xGetSystemCall; + //string (*xNextSystemCall)(sqlite3_vfs*, string zName); + public dxNextSystemCall xNextSystemCall; + /* + ** The methods above are in versions 1 through 3 of the sqlite_vfs object. + ** New fields may be appended in figure versions. The iVersion + ** value will increment whenever this happens. + */ + /* New fields may be appended in figure versions. The iVersion + ** value will increment whenever this happens. */ + + public sqlite3_vfs() { + } + + public sqlite3_vfs(int iVersion, + int szOsFile, + int mxPathname, + sqlite3_vfs pNext, + string zName, + object pAppData, + dxOpen xOpen, + dxDelete xDelete, + dxAccess xAccess, + dxFullPathname xFullPathname, + dxDlOpen xDlOpen, + dxDlError xDlError, + dxDlSym xDlSym, + dxDlClose xDlClose, + dxRandomness xRandomness, + dxSleep xSleep, + dxCurrentTime xCurrentTime, + dxGetLastError xGetLastError, + dxCurrentTimeInt64 xCurrentTimeInt64, + dxSetSystemCall xSetSystemCall, + dxGetSystemCall xGetSystemCall, + dxNextSystemCall xNextSystemCall) { + this.iVersion = iVersion; + this.szOsFile = szOsFile; + this.mxPathname = mxPathname; + this.pNext = pNext; + this.zName = zName; + this.pAppData = pAppData; + this.xOpen = xOpen; + this.xDelete = xDelete; + this.xAccess = xAccess; + this.xFullPathname = xFullPathname; + this.xDlOpen = xDlOpen; + this.xDlError = xDlError; + this.xDlSym = xDlSym; + this.xDlClose = xDlClose; + this.xRandomness = xRandomness; + this.xSleep = xSleep; + this.xCurrentTime = xCurrentTime; + this.xGetLastError = xGetLastError; + this.xCurrentTimeInt64 = xCurrentTimeInt64; + } + public void CopyTo(sqlite3_vfs ct) { + ct.iVersion = this.iVersion; + ct.szOsFile = this.szOsFile; + ct.mxPathname = this.mxPathname; + ct.pNext = this.pNext; + ct.zName = this.zName; + ct.pAppData = this.pAppData; + ct.xOpen = this.xOpen; + ct.xDelete = this.xDelete; + ct.xAccess = this.xAccess; + ct.xFullPathname = this.xFullPathname; + ct.xDlOpen = this.xDlOpen; + ct.xDlError = this.xDlError; + ct.xDlSym = this.xDlSym; + ct.xDlClose = this.xDlClose; + ct.xRandomness = this.xRandomness; + ct.xSleep = this.xSleep; + ct.xCurrentTime = this.xCurrentTime; + ct.xGetLastError = this.xGetLastError; + ct.xCurrentTimeInt64 = this.xCurrentTimeInt64; + } + } - /* - ** CAPI3REF: Configuration Options - ** KEYWORDS: {configuration option} - ** - ** These constants are the available integer configuration options that - ** can be passed as the first argument to the [sqlite3_config()] interface. - ** - ** New configuration options may be added in future releases of SQLite. - ** Existing configuration options might be discontinued. Applications - ** should check the return code from [sqlite3_config()] to make sure that - ** the call worked. The [sqlite3_config()] interface will return a - ** non-zero [error code] if a discontinued or unsupported configuration option - ** is invoked. - ** - **
- ** [[SQLITE_CONFIG_SINGLETHREAD]]
SQLITE_CONFIG_SINGLETHREAD
- **
There are no arguments to this option. ^This option sets the - ** [threading mode] to Single-thread. In other words, it disables - ** all mutexing and puts SQLite into a mode where it can only be used - ** by a single thread. ^If SQLite is compiled with - ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then - ** it is not possible to change the [threading mode] from its default - ** value of Single-thread and so [sqlite3_config()] will return - ** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD - ** configuration option.
- ** - ** [[SQLITE_CONFIG_MULTITHREAD]]
SQLITE_CONFIG_MULTITHREAD
- **
There are no arguments to this option. ^This option sets the - ** [threading mode] to Multi-thread. In other words, it disables - ** mutexing on [database connection] and [prepared statement] objects. - ** The application is responsible for serializing access to - ** [database connections] and [prepared statements]. But other mutexes - ** are enabled so that SQLite will be safe to use in a multi-threaded - ** environment as long as no two threads attempt to use the same - ** [database connection] at the same time. ^If SQLite is compiled with - ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then - ** it is not possible to set the Multi-thread [threading mode] and - ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the - ** SQLITE_CONFIG_MULTITHREAD configuration option.
- ** - ** [[SQLITE_CONFIG_SERIALIZED]]
SQLITE_CONFIG_SERIALIZED
- **
There are no arguments to this option. ^This option sets the - ** [threading mode] to Serialized. In other words, this option enables - ** all mutexes including the recursive - ** mutexes on [database connection] and [prepared statement] objects. - ** In this mode (which is the default when SQLite is compiled with - ** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access - ** to [database connections] and [prepared statements] so that the - ** application is free to use the same [database connection] or the - ** same [prepared statement] in different threads at the same time. - ** ^If SQLite is compiled with - ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then - ** it is not possible to set the Serialized [threading mode] and - ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the - ** SQLITE_CONFIG_SERIALIZED configuration option.
- ** - ** [[SQLITE_CONFIG_MALLOC]]
SQLITE_CONFIG_MALLOC
- **
^(This option takes a single argument which is a pointer to an - ** instance of the [sqlite3_mem_methods] structure. The argument specifies - ** alternative low-level memory allocation routines to be used in place of - ** the memory allocation routines built into SQLite.)^ ^SQLite makes - ** its own private copy of the content of the [sqlite3_mem_methods] structure - ** before the [sqlite3_config()] call returns.
- ** - ** [[SQLITE_CONFIG_GETMALLOC]]
SQLITE_CONFIG_GETMALLOC
- **
^(This option takes a single argument which is a pointer to an - ** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods] - ** structure is filled with the currently defined memory allocation routines.)^ - ** This option can be used to overload the default memory allocation - ** routines with a wrapper that simulations memory allocation failure or - ** tracks memory usage, for example.
- ** - ** [[SQLITE_CONFIG_MEMSTATUS]]
SQLITE_CONFIG_MEMSTATUS
- **
^This option takes single argument of type int, interpreted as a - ** boolean, which enables or disables the collection of memory allocation - ** statistics. ^(When memory allocation statistics are disabled, the - ** following SQLite interfaces become non-operational: - **
    - **
  • [sqlite3_memory_used()] - **
  • [sqlite3_memory_highwater()] - **
  • [sqlite3_soft_heap_limit64()] - **
  • [sqlite3_status()] - **
)^ - ** ^Memory allocation statistics are enabled by default unless SQLite is - ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory - ** allocation statistics are disabled by default. - **
- ** - ** [[SQLITE_CONFIG_SCRATCH]]
SQLITE_CONFIG_SCRATCH
- **
^This option specifies a static memory buffer that SQLite can use for - ** scratch memory. There are three arguments: A pointer an 8-byte - ** aligned memory buffer from which the scratch allocations will be - ** drawn, the size of each scratch allocation (sz), - ** and the maximum number of scratch allocations (N). The sz - ** argument must be a multiple of 16. - ** The first argument must be a pointer to an 8-byte aligned buffer - ** of at least sz*N bytes of memory. - ** ^SQLite will use no more than two scratch buffers per thread. So - ** N should be set to twice the expected maximum number of threads. - ** ^SQLite will never require a scratch buffer that is more than 6 - ** times the database page size. ^If SQLite needs needs additional - ** scratch memory beyond what is provided by this configuration option, then - ** [sqlite3_malloc()] will be used to obtain the memory needed.
- ** - ** [[SQLITE_CONFIG_PAGECACHE]]
SQLITE_CONFIG_PAGECACHE
- **
^This option specifies a static memory buffer that SQLite can use for - ** the database page cache with the default page cache implementation. - ** This configuration should not be used if an application-define page - ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option. - ** There are three arguments to this option: A pointer to 8-byte aligned - ** memory, the size of each page buffer (sz), and the number of pages (N). - ** The sz argument should be the size of the largest database page - ** (a power of two between 512 and 32768) plus a little extra for each - ** page header. ^The page header size is 20 to 40 bytes depending on - ** the host architecture. ^It is harmless, apart from the wasted memory, - ** to make sz a little too large. The first - ** argument should point to an allocation of at least sz*N bytes of memory. - ** ^SQLite will use the memory provided by the first argument to satisfy its - ** memory needs for the first N pages that it adds to cache. ^If additional - ** page cache memory is needed beyond what is provided by this option, then - ** SQLite goes to [sqlite3_malloc()] for the additional storage space. - ** The pointer in the first argument must - ** be aligned to an 8-byte boundary or subsequent behavior of SQLite - ** will be undefined.
- ** - ** [[SQLITE_CONFIG_HEAP]]
SQLITE_CONFIG_HEAP
- **
^This option specifies a static memory buffer that SQLite will use - ** for all of its dynamic memory allocation needs beyond those provided - ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE]. - ** There are three arguments: An 8-byte aligned pointer to the memory, - ** the number of bytes in the memory buffer, and the minimum allocation size. - ** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts - ** to using its default memory allocator (the system malloc() implementation), - ** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. ^If the - ** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or - ** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory - ** allocator is engaged to handle all of SQLites memory allocation needs. - ** The first pointer (the memory pointer) must be aligned to an 8-byte - ** boundary or subsequent behavior of SQLite will be undefined. - ** The minimum allocation size is capped at 2^12. Reasonable values - ** for the minimum allocation size are 2^5 through 2^8.
- ** - ** [[SQLITE_CONFIG_MUTEX]]
SQLITE_CONFIG_MUTEX
- **
^(This option takes a single argument which is a pointer to an - ** instance of the [sqlite3_mutex_methods] structure. The argument specifies - ** alternative low-level mutex routines to be used in place - ** the mutex routines built into SQLite.)^ ^SQLite makes a copy of the - ** content of the [sqlite3_mutex_methods] structure before the call to - ** [sqlite3_config()] returns. ^If SQLite is compiled with - ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then - ** the entire mutexing subsystem is omitted from the build and hence calls to - ** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will - ** return [SQLITE_ERROR].
- ** - ** [[SQLITE_CONFIG_GETMUTEX]]
SQLITE_CONFIG_GETMUTEX
- **
^(This option takes a single argument which is a pointer to an - ** instance of the [sqlite3_mutex_methods] structure. The - ** [sqlite3_mutex_methods] - ** structure is filled with the currently defined mutex routines.)^ - ** This option can be used to overload the default mutex allocation - ** routines with a wrapper used to track mutex usage for performance - ** profiling or testing, for example. ^If SQLite is compiled with - ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then - ** the entire mutexing subsystem is omitted from the build and hence calls to - ** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will - ** return [SQLITE_ERROR].
- ** - ** [[SQLITE_CONFIG_LOOKASIDE]]
SQLITE_CONFIG_LOOKASIDE
- **
^(This option takes two arguments that determine the default - ** memory allocation for the lookaside memory allocator on each - ** [database connection]. The first argument is the - ** size of each lookaside buffer slot and the second is the number of - ** slots allocated to each database connection.)^ ^(This option sets the - ** default lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE] - ** verb to [sqlite3_db_config()] can be used to change the lookaside - ** configuration on individual connections.)^
- ** - ** [[SQLITE_CONFIG_PCACHE]]
SQLITE_CONFIG_PCACHE
- **
^(This option takes a single argument which is a pointer to - ** an [sqlite3_pcache_methods] object. This object specifies the interface - ** to a custom page cache implementation.)^ ^SQLite makes a copy of the - ** object and uses it for page cache memory allocations.
- ** - ** [[SQLITE_CONFIG_GETPCACHE]]
SQLITE_CONFIG_GETPCACHE
- **
^(This option takes a single argument which is a pointer to an - ** [sqlite3_pcache_methods] object. SQLite copies of the current - ** page cache implementation into that object.)^
- ** - ** [[SQLITE_CONFIG_LOG]]
SQLITE_CONFIG_LOG
- **
^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a - ** function with a call signature of void()(void*,int,const char), - ** and a pointer to void. ^If the function pointer is not NULL, it is - ** invoked by [sqlite3_log()] to process each logging event. ^If the - ** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op. - ** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is - ** passed through as the first parameter to the application-defined logger - ** function whenever that function is invoked. ^The second parameter to - ** the logger function is a copy of the first parameter to the corresponding - ** [sqlite3_log()] call and is intended to be a [result code] or an - ** [extended result code]. ^The third parameter passed to the logger is - ** log message after formatting via [sqlite3_snprintf()]. - ** The SQLite logging interface is not reentrant; the logger function - ** 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 - ** URI handling is globally enabled. If the parameter is zero, then URI handling - ** 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 - ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the - ** 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. - **
- */ - //#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ - //#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ - //#define SQLITE_CONFIG_SERIALIZED 3 /* nil */ - //#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ - //#define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ - //#define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */ - //#define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */ - //#define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */ - //#define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */ - //#define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */ - //#define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */ - ///* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ - //#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ - //#define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */ - //#define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */ - //#define SQLITE_CONFIG_LOG 16 /* xFunc, void* */ - //#define SQLITE_CONFIG_URI 17 /* int */ - public const int SQLITE_CONFIG_SINGLETHREAD = 1; - public const int SQLITE_CONFIG_MULTITHREAD = 2; - public const int SQLITE_CONFIG_SERIALIZED = 3; - public const int SQLITE_CONFIG_MALLOC = 4; - public const int SQLITE_CONFIG_GETMALLOC = 5; - public const int SQLITE_CONFIG_SCRATCH = 6; - public const int SQLITE_CONFIG_PAGECACHE = 7; - public const int SQLITE_CONFIG_HEAP = 8; - public const int SQLITE_CONFIG_MEMSTATUS = 9; - public const int SQLITE_CONFIG_MUTEX = 10; - public const int SQLITE_CONFIG_GETMUTEX = 11; - public const int SQLITE_CONFIG_LOOKASIDE = 13; - public const int SQLITE_CONFIG_PCACHE = 14; - public const int SQLITE_CONFIG_GETPCACHE = 15; - public const int SQLITE_CONFIG_LOG = 16; - public const int SQLITE_CONFIG_URI = 17; - - /* - ** CAPI3REF: Database Connection Configuration Options - ** - ** These constants are the available integer configuration options that - ** can be passed as the second argument to the [sqlite3_db_config()] interface. - ** - ** New configuration options may be added in future releases of SQLite. - ** Existing configuration options might be discontinued. Applications - ** should check the return code from [sqlite3_db_config()] to make sure that - ** the call worked. ^The [sqlite3_db_config()] interface will return a - ** non-zero [error code] if a discontinued or unsupported configuration option - ** is invoked. - ** - **
- **
SQLITE_DBCONFIG_LOOKASIDE
- **
^This option takes three additional arguments that determine the - ** [lookaside memory allocator] configuration for the [database connection]. - ** ^The first argument (the third parameter to [sqlite3_db_config()] is a - ** pointer to a memory buffer to use for lookaside memory. - ** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb - ** may be NULL in which case SQLite will allocate the - ** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the - ** size of each lookaside buffer slot. ^The third argument is the number of - ** slots. The size of the buffer in the first argument must be greater than - ** or equal to the product of the second and third arguments. The buffer - ** must be aligned to an 8-byte boundary. ^If the second argument to - ** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally - ** rounded down to the next smaller multiple of 8. ^(The lookaside memory - ** configuration for a database connection can only be changed when that - ** connection is not currently using lookaside memory, or in other words - ** when the "current value" returned by - ** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero. - ** Any attempt to change the lookaside memory configuration when lookaside - ** memory is in use leaves the configuration unchanged and returns - ** [SQLITE_BUSY].)^
- ** - **
SQLITE_DBCONFIG_ENABLE_FKEY
- **
^This option is used to enable or disable the enforcement of - ** [foreign key constraints]. There should be two additional arguments. - ** The first argument is an integer which is 0 to disable FK enforcement, - ** positive to enable FK enforcement or negative to leave FK enforcement - ** unchanged. The second parameter is a pointer to an integer into which - ** is written 0 or 1 to indicate whether FK enforcement is off or on - ** following this call. The second parameter may be a NULL pointer, in - ** which case the FK enforcement setting is not reported back.
- ** - **
SQLITE_DBCONFIG_ENABLE_TRIGGER
- **
^This option is used to enable or disable [CREATE TRIGGER | triggers]. - ** There should be two additional arguments. - ** The first argument is an integer which is 0 to disable triggers, - ** positive to enable triggers or negative to leave the setting unchanged. - ** The second parameter is a pointer to an integer into which - ** is written 0 or 1 to indicate whether triggers are disabled or enabled - ** following this call. The second parameter may be a NULL pointer, in - ** which case the trigger setting is not reported back.
- ** - **
- */ - //#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ - //#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */ - //#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */ - const int SQLITE_DBCONFIG_LOOKASIDE = 1001; - const int SQLITE_DBCONFIG_ENABLE_FKEY = 1002; - const int SQLITE_DBCONFIG_ENABLE_TRIGGER = 1003; - - /* - ** CAPI3REF: Enable Or Disable Extended Result Codes - ** - ** ^The sqlite3_extended_result_codes() routine enables or disables the - ** [extended result codes] feature of SQLite. ^The extended result - ** codes are disabled by default for historical compatibility. - */ - //SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff); - - /* - ** CAPI3REF: Last Insert Rowid - ** - ** ^Each entry in an SQLite table has a unique 64-bit signed - ** integer key called the [ROWID | "rowid"]. ^The rowid is always available - ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those - ** names are not also used by explicitly declared columns. ^If - ** the table has a column of type [INTEGER PRIMARY KEY] then that column - ** is another alias for the rowid. - ** - ** ^This routine returns the [rowid] of the most recent - ** successful [INSERT] into the database from the [database connection] - ** in the first argument. ^As of SQLite version 3.7.7, this routines - ** records the last insert rowid of both ordinary tables and [virtual tables]. - ** ^If no successful [INSERT]s - ** have ever occurred on that database connection, zero is returned. - ** - ** ^(If an [INSERT] occurs within a trigger or within a [virtual table] - ** method, then this routine will return the [rowid] of the inserted - ** row as long as the trigger or virtual table method is running. - ** But once the trigger or virtual table method ends, the value returned - ** by this routine reverts to what it was before the trigger or virtual - ** table method began.)^ - ** - ** ^An [INSERT] that fails due to a constraint violation is not a - ** successful [INSERT] and does not change the value returned by this - ** routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK, - ** and INSERT OR ABORT make no changes to the return value of this - ** routine when their insertion fails. ^(When INSERT OR REPLACE - ** encounters a constraint violation, it does not fail. The - ** INSERT continues to completion after deleting rows that caused - ** the constraint problem so INSERT OR REPLACE will always change - ** the return value of this interface.)^ - ** - ** ^For the purposes of this routine, an [INSERT] is considered to - ** be successful even if it is subsequently rolled back. - ** - ** This function is accessible to SQL statements via the - ** [last_insert_rowid() SQL function]. - ** - ** If a separate thread performs a new [INSERT] on the same - ** database connection while the [sqlite3_last_insert_rowid()] - ** function is running and thus changes the last insert [rowid], - ** then the value returned by [sqlite3_last_insert_rowid()] is - ** unpredictable and might not equal either the old or the new - ** last insert [rowid]. - */ - //SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3); - - /* - ** CAPI3REF: Count The Number Of Rows Modified - ** - ** ^This function returns the number of database rows that were changed - ** or inserted or deleted by the most recently completed SQL statement - ** on the [database connection] specified by the first parameter. - ** ^(Only changes that are directly specified by the [INSERT], [UPDATE], - ** or [DELETE] statement are counted. Auxiliary changes caused by - ** triggers or [foreign key actions] are not counted.)^ Use the - ** [sqlite3_total_changes()] function to find the total number of changes - ** including changes caused by triggers and foreign key actions. - ** - ** ^Changes to a view that are simulated by an [INSTEAD OF trigger] - ** are not counted. Only real table changes are counted. - ** - ** ^(A "row change" is a change to a single row of a single table - ** caused by an INSERT, DELETE, or UPDATE statement. Rows that - ** are changed as side effects of [REPLACE] constraint resolution, - ** rollback, ABORT processing, [DROP TABLE], or by any other - ** mechanisms do not count as direct row changes.)^ - ** - ** A "trigger context" is a scope of execution that begins and - ** ends with the script of a [CREATE TRIGGER | trigger]. - ** Most SQL statements are - ** evaluated outside of any trigger. This is the "top level" - ** trigger context. If a trigger fires from the top level, a - ** new trigger context is entered for the duration of that one - ** trigger. Subtriggers create subcontexts for their duration. - ** - ** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does - ** not create a new trigger context. - ** - ** ^This function returns the number of direct row changes in the - ** most recent INSERT, UPDATE, or DELETE statement within the same - ** trigger context. - ** - ** ^Thus, when called from the top level, this function returns the - ** number of changes in the most recent INSERT, UPDATE, or DELETE - ** that also occurred at the top level. ^(Within the body of a trigger, - ** the sqlite3_changes() interface can be called to find the number of - ** changes in the most recently completed INSERT, UPDATE, or DELETE - ** statement within the body of the same trigger. - ** However, the number returned does not include changes - ** caused by subtriggers since those have their own context.)^ - ** - ** See also the [sqlite3_total_changes()] interface, the - ** [count_changes pragma], and the [changes() SQL function]. - ** - ** If a separate thread makes changes on the same database connection - ** while [sqlite3_changes()] is running then the value returned - ** is unpredictable and not meaningful. - */ - //SQLITE_API int sqlite3_changes(sqlite3); - - /* - ** CAPI3REF: Total Number Of Rows Modified - ** - ** ^This function returns the number of row changes caused by [INSERT], - ** [UPDATE] or [DELETE] statements since the [database connection] was opened. - ** ^(The count returned by sqlite3_total_changes() includes all changes - ** from all [CREATE TRIGGER | trigger] contexts and changes made by - ** [foreign key actions]. However, - ** the count does not include changes used to implement [REPLACE] constraints, - ** do rollbacks or ABORT processing, or [DROP TABLE] processing. The - ** count does not include rows of views that fire an [INSTEAD OF trigger], - ** though if the INSTEAD OF trigger makes changes of its own, those changes - ** are counted.)^ - ** ^The sqlite3_total_changes() function counts the changes as soon as - ** the statement that makes them is completed (when the statement handle - ** is passed to [sqlite3_reset()] or [sqlite3_finalize()]). - ** - ** See also the [sqlite3_changes()] interface, the - ** [count_changes pragma], and the [total_changes() SQL function]. - ** - ** If a separate thread makes changes on the same database connection - ** while [sqlite3_total_changes()] is running then the value - ** returned is unpredictable and not meaningful. - */ - //SQLITE_API int sqlite3_total_changes(sqlite3); - - /* - ** CAPI3REF: Interrupt A Long-Running Query - ** - ** ^This function causes any pending database operation to abort and - ** return at its earliest opportunity. This routine is typically - ** called in response to a user action such as pressing "Cancel" - ** or Ctrl-C where the user wants a long query operation to halt - ** immediately. - ** - ** ^It is safe to call this routine from a thread different from the - ** thread that is currently running the database operation. But it - ** is not safe to call this routine with a [database connection] that - ** is closed or might close before sqlite3_interrupt() returns. - ** - ** ^If an SQL operation is very nearly finished at the time when - ** sqlite3_interrupt() is called, then it might not have an opportunity - ** to be interrupted and might continue to completion. - ** - ** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT]. - ** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE - ** that is inside an explicit transaction, then the entire transaction - ** will be rolled back automatically. - ** - ** ^The sqlite3_interrupt(D) call is in effect until all currently running - ** SQL statements on [database connection] D complete. ^Any new SQL statements - ** that are started after the sqlite3_interrupt() call and before the - ** running statements reaches zero are interrupted as if they had been - ** running prior to the sqlite3_interrupt() call. ^New SQL statements - ** that are started after the running statement count reaches zero are - ** not effected by the sqlite3_interrupt(). - ** ^A call to sqlite3_interrupt(D) that occurs when there are no running - ** SQL statements is a no-op and has no effect on SQL statements - ** that are started after the sqlite3_interrupt() call returns. - ** - ** If the database connection closes while [sqlite3_interrupt()] - ** is running then bad things will likely happen. - */ - //SQLITE_API void sqlite3_interrupt(sqlite3); - - /* - ** CAPI3REF: Determine If An SQL Statement Is Complete - ** - ** These routines are useful during command-line input to determine if the - ** currently entered text seems to form a complete SQL statement or - ** if additional input is needed before sending the text into - ** SQLite for parsing. ^These routines return 1 if the input string - ** appears to be a complete SQL statement. ^A statement is judged to be - ** complete if it ends with a semicolon token and is not a prefix of a - ** well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within - ** string literals or quoted identifier names or comments are not - ** independent tokens (they are part of the token in which they are - ** embedded) and thus do not count as a statement terminator. ^Whitespace - ** and comments that follow the final semicolon are ignored. - ** - ** ^These routines return 0 if the statement is incomplete. ^If a - ** memory allocation fails, then SQLITE_NOMEM is returned. - ** - ** ^These routines do not parse the SQL statements thus - ** will not detect syntactically incorrect SQL. - ** - ** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior - ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked - ** automatically by sqlite3_complete16(). If that initialization fails, - ** then the return value from sqlite3_complete16() will be non-zero - ** regardless of whether or not the input SQL is complete.)^ - ** - ** The input to [sqlite3_complete()] must be a zero-terminated - ** UTF-8 string. - ** - ** The input to [sqlite3_complete16()] must be a zero-terminated - ** UTF-16 string in native byte order. - */ - //SQLITE_API int sqlite3_complete(string sql); - //SQLITE_API int sqlite3_complete16(const void *sql); - - /* - ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors - ** - ** ^This routine sets a callback function that might be invoked whenever - ** an attempt is made to open a database table that another thread - ** or process has locked. - ** - ** ^If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] - ** is returned immediately upon encountering the lock. ^If the busy callback - ** is not NULL, then the callback might be invoked with two arguments. - ** - ** ^The first argument to the busy handler is a copy of the void* pointer which - ** is the third argument to sqlite3_busy_handler(). ^The second argument to - ** the busy handler callback is the number of times that the busy handler has - ** been invoked for this locking event. ^If the - ** busy callback returns 0, then no additional attempts are made to - ** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned. - ** ^If the callback returns non-zero, then another attempt - ** is made to open the database for reading and the cycle repeats. - ** - ** The presence of a busy handler does not guarantee that it will be invoked - ** when there is lock contention. ^If SQLite determines that invoking the busy - ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY] - ** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler. - ** Consider a scenario where one process is holding a read lock that - ** it is trying to promote to a reserved lock and - ** a second process is holding a reserved lock that it is trying - ** to promote to an exclusive lock. The first process cannot proceed - ** because it is blocked by the second and the second process cannot - ** proceed because it is blocked by the first. If both processes - ** invoke the busy handlers, neither will make any progress. Therefore, - ** SQLite returns [SQLITE_BUSY] for the first process, hoping that this - ** will induce the first process to release its read lock and allow - ** the second process to proceed. - ** - ** ^The default busy callback is NULL. - ** - ** ^The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED] - ** when SQLite is in the middle of a large transaction where all the - ** changes will not fit into the in-memory cache. SQLite will - ** already hold a RESERVED lock on the database file, but it needs - ** to promote this lock to EXCLUSIVE so that it can spill cache - ** pages into the database file without harm to concurrent - ** readers. ^If it is unable to promote the lock, then the in-memory - ** cache will be left in an inconsistent state and so the error - ** code is promoted from the relatively benign [SQLITE_BUSY] to - ** the more severe [SQLITE_IOERR_BLOCKED]. ^This error code promotion - ** forces an automatic rollback of the changes. See the - ** - ** CorruptionFollowingBusyError wiki page for a discussion of why - ** this is important. - ** - ** ^(There can only be a single busy handler defined for each - ** [database connection]. Setting a new busy handler clears any - ** previously set handler.)^ ^Note that calling [sqlite3_busy_timeout()] - ** will also set or clear the busy handler. - ** - ** The busy callback should not take any actions which modify the - ** database connection that invoked the busy handler. Any such actions - ** result in undefined behavior. - ** - ** A busy handler must not close the database connection - ** or [prepared statement] that invoked the busy handler. - */ - //SQLITE_API int sqlite3_busy_handler(sqlite3*, int()(void*,int), void); - - /* - ** CAPI3REF: Set A Busy Timeout - ** - ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps - ** for a specified amount of time when a table is locked. ^The handler - ** will sleep multiple times until at least "ms" milliseconds of sleeping - ** have accumulated. ^After at least "ms" milliseconds of sleeping, - ** the handler returns 0 which causes [sqlite3_step()] to return - ** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]. - ** - ** ^Calling this routine with an argument less than or equal to zero - ** turns off all busy handlers. - ** - ** ^(There can only be a single busy handler for a particular - ** [database connection] any any given moment. If another busy handler - ** was defined (using [sqlite3_busy_handler()]) prior to calling - ** this routine, that other busy handler is cleared.)^ - */ - //SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms); - - /* - ** CAPI3REF: Convenience Routines For Running Queries - ** - ** This is a legacy interface that is preserved for backwards compatibility. - ** Use of this interface is not recommended. - ** - ** Definition: A result table is memory data structure created by the - ** [sqlite3_get_table()] interface. A result table records the - ** complete query results from one or more queries. - ** - ** The table conceptually has a number of rows and columns. But - ** these numbers are not part of the result table itself. These - ** numbers are obtained separately. Let N be the number of rows - ** and M be the number of columns. - ** - ** A result table is an array of pointers to zero-terminated UTF-8 strings. - ** There are (N+1)*M elements in the array. The first M pointers point - ** to zero-terminated strings that contain the names of the columns. - ** The remaining entries all point to query results. NULL values result - ** in NULL pointers. All other values are in their UTF-8 zero-terminated - ** string representation as returned by [sqlite3_column_text()]. - ** - ** A result table might consist of one or more memory allocations. - ** It is not safe to pass a result table directly to [sqlite3_free()]. - ** A result table should be deallocated using [sqlite3_free_table()]. - ** - ** ^(As an example of the result table format, suppose a query result - ** is as follows: - ** - **
-    **        Name        | Age
-    **        -----------------------
-    **        Alice       | 43
-    **        Bob         | 28
-    **        Cindy       | 21
-    ** 
- ** - ** There are two column (M==2) and three rows (N==3). Thus the - ** result table has 8 entries. Suppose the result table is stored - ** in an array names azResult. Then azResult holds this content: - ** - **
-    **        azResult[0] = "Name";
-    **        azResult[1] = "Age";
-    **        azResult[2] = "Alice";
-    **        azResult[3] = "43";
-    **        azResult[4] = "Bob";
-    **        azResult[5] = "28";
-    **        azResult[6] = "Cindy";
-    **        azResult[7] = "21";
-    ** 
)^ - ** - ** ^The sqlite3_get_table() function evaluates one or more - ** semicolon-separated SQL statements in the zero-terminated UTF-8 - ** string of its 2nd parameter and returns a result table to the - ** pointer given in its 3rd parameter. - ** - ** After the application has finished with the result from sqlite3_get_table(), - ** it must pass the result table pointer to sqlite3_free_table() in order to - ** release the memory that was malloced. Because of the way the - ** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling - ** function must not try to call [sqlite3_free()] directly. Only - ** [sqlite3_free_table()] is able to release the memory properly and safely. - ** - ** The sqlite3_get_table() interface is implemented as a wrapper around - ** [sqlite3_exec()]. The sqlite3_get_table() routine does not have access - ** to any internal data structures of SQLite. It uses only the public - ** interface defined here. As a consequence, errors that occur in the - ** wrapper layer outside of the internal [sqlite3_exec()] call are not - ** reflected in subsequent calls to [sqlite3_errcode()] or - ** [sqlite3_errmsg()]. - */ - //SQLITE_API int sqlite3_get_table( - // sqlite3 db, /* An open database */ - // string zSql, /* SQL to be evaluated */ - // char ***pazResult, /* Results of the query */ - // int *pnRow, /* Number of result rows written here */ - // int *pnColumn, /* Number of result columns written here */ - // char **pzErrmsg /* Error msg written here */ - //); - //SQLITE_API void sqlite3_free_table(char **result); - - /* - ** CAPI3REF: Formatted String Printing Functions - ** - ** These routines are work-alikes of the "printf()" family of functions - ** from the standard C library. - ** - ** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their - ** results into memory obtained from [sqlite3_malloc()]. - ** The strings returned by these two routines should be - ** released by [sqlite3_free()]. ^Both routines return a - ** NULL pointer if [sqlite3_malloc()] is unable to allocate enough - ** memory to hold the resulting string. - ** - ** ^(The sqlite3_snprintf() routine is similar to "snprintf()" from - ** the standard C library. The result is written into the - ** buffer supplied as the second parameter whose size is given by - ** the first parameter. Note that the order of the - ** first two parameters is reversed from snprintf().)^ This is an - ** historical accident that cannot be fixed without breaking - ** backwards compatibility. ^(Note also that sqlite3_snprintf() - ** returns a pointer to its buffer instead of the number of - ** characters actually written into the buffer.)^ We admit that - ** the number of characters written would be a more useful return - ** value but we cannot change the implementation of sqlite3_snprintf() - ** now without breaking compatibility. - ** - ** ^As long as the buffer size is greater than zero, sqlite3_snprintf() - ** guarantees that the buffer is always zero-terminated. ^The first - ** parameter "n" is the total size of the buffer, including space for - ** the zero terminator. So the longest string that can be completely - ** written will be n-1 characters. - ** - ** ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf(). - ** - ** These routines all implement some additional formatting - ** options that are useful for constructing SQL statements. - ** All of the usual printf() formatting options apply. In addition, there - ** is are "%q", "%Q", and "%z" options. - ** - ** ^(The %q option works like %s in that it substitutes a null-terminated - ** string from the argument list. But %q also doubles every '\'' character. - ** %q is designed for use inside a string literal.)^ By doubling each '\'' - ** character it escapes that character and allows it to be inserted into - ** the string. - ** - ** For example, assume the string variable zText contains text as follows: - ** - **
-    **  string zText = "It's a happy day!";
-    ** 
- ** - ** One can use this text in an SQL statement as follows: - ** - **
-    **  string zSQL = sqlite3_mprintf("INSERT INTO table VALUES('%q')", zText);
-    **  sqlite3_exec(db, zSQL, 0, 0, 0);
-    **  sqlite3_free(zSQL);
-    ** 
- ** - ** Because the %q format string is used, the '\'' character in zText - ** is escaped and the SQL generated is as follows: - ** - **
-    **  INSERT INTO table1 VALUES('It''s a happy day!')
-    ** 
- ** - ** This is correct. Had we used %s instead of %q, the generated SQL - ** would have looked like this: - ** - **
-    **  INSERT INTO table1 VALUES('It's a happy day!');
-    ** 
- ** - ** This second example is an SQL syntax error. As a general rule you should - ** always use %q instead of %s when inserting text into a string literal. - ** - ** ^(The %Q option works like %q except it also adds single quotes around - ** the outside of the total string. Additionally, if the parameter in the - ** argument list is a NULL pointer, %Q substitutes the text "NULL" (without - ** single quotes).)^ So, for example, one could say: - ** - **
-    **  string zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
-    **  sqlite3_exec(db, zSQL, 0, 0, 0);
-    **  sqlite3_free(zSQL);
-    ** 
- ** - ** The code above will render a correct SQL statement in the zSQL - ** variable even if the zText variable is a NULL pointer. - ** - ** ^(The "%z" formatting option works like "%s" but with the - ** addition that after the string has been read and copied into - ** the result, [sqlite3_free()] is called on the input string.)^ - */ - //SQLITE_API char *sqlite3_mprintf(const char*,...); - //SQLITE_API char *sqlite3_vmprintf(const char*, va_list); - //SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...); - //SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list); - - - /* - ** CAPI3REF: Memory Allocation Subsystem - ** - ** The SQLite core uses these three routines for all of its own - ** internal memory allocation needs. "Core" in the previous sentence - ** does not include operating-system specific VFS implementation. The - ** Windows VFS uses native malloc() and free() for some operations. - ** - ** ^The sqlite3_malloc() routine returns a pointer to a block - ** of memory at least N bytes in length, where N is the parameter. - ** ^If sqlite3_malloc() is unable to obtain sufficient free - ** memory, it returns a NULL pointer. ^If the parameter N to - ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns - ** a NULL pointer. - ** - ** ^Calling sqlite3_free() with a pointer previously returned - ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so - ** that it might be reused. ^The sqlite3_free() routine is - ** a no-op if is called with a NULL pointer. Passing a NULL pointer - ** to sqlite3_free() is harmless. After being freed, memory - ** should neither be read nor written. Even reading previously freed - ** memory might result in a segmentation fault or other severe error. - ** Memory corruption, a segmentation fault, or other severe error - ** might result if sqlite3_free() is called with a non-NULL pointer that - ** was not obtained from sqlite3_malloc() or sqlite3_realloc(). - ** - ** ^(The sqlite3_realloc() interface attempts to resize a - ** prior memory allocation to be at least N bytes, where N is the - ** second parameter. The memory allocation to be resized is the first - ** parameter.)^ ^ If the first parameter to sqlite3_realloc() - ** is a NULL pointer then its behavior is identical to calling - ** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc(). - ** ^If the second parameter to sqlite3_realloc() is zero or - ** negative then the behavior is exactly the same as calling - ** sqlite3_free(P) where P is the first parameter to sqlite3_realloc(). - ** ^sqlite3_realloc() returns a pointer to a memory allocation - ** of at least N bytes in size or NULL if sufficient memory is unavailable. - ** ^If M is the size of the prior allocation, then min(N,M) bytes - ** of the prior allocation are copied into the beginning of buffer returned - ** by sqlite3_realloc() and the prior allocation is freed. - ** ^If sqlite3_realloc() returns NULL, then the prior allocation - ** is not freed. - ** - ** ^The memory returned by sqlite3_malloc() and sqlite3_realloc() - ** is always aligned to at least an 8 byte boundary, or to a - ** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time - ** option is used. - ** - ** In SQLite version 3.5.0 and 3.5.1, it was possible to define - ** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in - ** implementation of these routines to be omitted. That capability - ** is no longer provided. Only built-in memory allocators can be used. - ** - ** The Windows OS interface layer calls - ** the system malloc() and free() directly when converting - ** filenames between the UTF-8 encoding used by SQLite - ** and whatever filename encoding is used by the particular Windows - ** installation. Memory allocation errors are detected, but - ** they are reported back as [SQLITE_CANTOPEN] or - ** [SQLITE_IOERR] rather than [SQLITE_NOMEM]. - ** - ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()] - ** must be either NULL or else pointers obtained from a prior - ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have - ** not yet been released. - ** - ** The application must not read or write any part of - ** a block of memory after it has been released using - ** [sqlite3_free()] or [sqlite3_realloc()]. - */ - //SQLITE_API void *sqlite3_malloc(int); - //SQLITE_API void *sqlite3_realloc(void*, int); - //SQLITE_API void sqlite3_free(void); - - /* - ** CAPI3REF: Memory Allocator Statistics - ** - ** SQLite provides these two interfaces for reporting on the status - ** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()] - ** routines, which form the built-in memory allocation subsystem. - ** - ** ^The [sqlite3_memory_used()] routine returns the number of bytes - ** of memory currently outstanding (malloced but not freed). - ** ^The [sqlite3_memory_highwater()] routine returns the maximum - ** value of [sqlite3_memory_used()] since the high-water mark - ** was last reset. ^The values returned by [sqlite3_memory_used()] and - ** [sqlite3_memory_highwater()] include any overhead - ** added by SQLite in its implementation of [sqlite3_malloc()], - ** but not overhead added by the any underlying system library - ** routines that [sqlite3_malloc()] may call. - ** - ** ^The memory high-water mark is reset to the current value of - ** [sqlite3_memory_used()] if and only if the parameter to - ** [sqlite3_memory_highwater()] is true. ^The value returned - ** by [sqlite3_memory_highwater(1)] is the high-water mark - ** prior to the reset. - */ - //SQLITE_API sqlite3_int64 sqlite3_memory_used(void); - //SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag); - - /* - ** CAPI3REF: Pseudo-Random Number Generator - ** - ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to - ** select random [ROWID | ROWIDs] when inserting new records into a table that - ** already uses the largest possible [ROWID]. The PRNG is also used for - ** the build-in random() and randomblob() SQL functions. This interface allows - ** applications to access the same PRNG for other purposes. - ** - ** ^A call to this routine stores N bytes of randomness into buffer P. - ** - ** ^The first time this routine is invoked (either internally or by - ** the application) the PRNG is seeded using randomness obtained - ** from the xRandomness method of the default [sqlite3_vfs] object. - ** ^On all subsequent invocations, the pseudo-randomness is generated - ** internally and without recourse to the [sqlite3_vfs] xRandomness - ** method. - */ - //SQLITE_API void sqlite3_randomness(int N, object *P); - - /* - ** CAPI3REF: Compile-Time Authorization Callbacks - ** - ** ^This routine registers an authorizer callback with a particular - ** [database connection], supplied in the first argument. - ** ^The authorizer callback is invoked as SQL statements are being compiled - ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()], - ** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various - ** points during the compilation process, as logic is being created - ** to perform various actions, the authorizer callback is invoked to - ** see if those actions are allowed. ^The authorizer callback should - ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the - ** specific action but allow the SQL statement to continue to be - ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be - ** rejected with an error. ^If the authorizer callback returns - ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY] - ** then the [sqlite3_prepare_v2()] or equivalent call that triggered - ** the authorizer will fail with an error message. - ** - ** When the callback returns [SQLITE_OK], that means the operation - ** requested is ok. ^When the callback returns [SQLITE_DENY], the - ** [sqlite3_prepare_v2()] or equivalent call that triggered the - ** authorizer will fail with an error message explaining that - ** access is denied. - ** - ** ^The first parameter to the authorizer callback is a copy of the third - ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter - ** to the callback is an integer [SQLITE_COPY | action code] that specifies - ** the particular action to be authorized. ^The third through sixth parameters - ** to the callback are zero-terminated strings that contain additional - ** details about the action to be authorized. - ** - ** ^If the action code is [SQLITE_READ] - ** and the callback returns [SQLITE_IGNORE] then the - ** [prepared statement] statement is constructed to substitute - ** a NULL value in place of the table column that would have - ** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE] - ** return can be used to deny an untrusted user access to individual - ** columns of a table. - ** ^If the action code is [SQLITE_DELETE] and the callback returns - ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the - ** [truncate optimization] is disabled and all rows are deleted individually. - ** - ** An authorizer is used when [sqlite3_prepare | preparing] - ** SQL statements from an untrusted source, to ensure that the SQL statements - ** do not try to access data they are not allowed to see, or that they do not - ** try to execute malicious statements that damage the database. For - ** example, an application may allow a user to enter arbitrary - ** SQL queries for evaluation by a database. But the application does - ** not want the user to be able to make arbitrary changes to the - ** database. An authorizer could then be put in place while the - ** user-entered SQL is being [sqlite3_prepare | prepared] that - ** disallows everything except [SELECT] statements. - ** - ** Applications that need to process SQL from untrusted sources - ** might also consider lowering resource limits using [sqlite3_limit()] - ** and limiting database size using the [max_page_count] [PRAGMA] - ** in addition to using an authorizer. - ** - ** ^(Only a single authorizer can be in place on a database connection - ** at a time. Each call to sqlite3_set_authorizer overrides the - ** previous call.)^ ^Disable the authorizer by installing a NULL callback. - ** The authorizer is disabled by default. - ** - ** The authorizer callback must not do anything that will modify - ** the database connection that invoked the authorizer callback. - ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their - ** database connections for the meaning of "modify" in this paragraph. - ** - ** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the - ** statement might be re-prepared during [sqlite3_step()] due to a - ** schema change. Hence, the application should ensure that the - ** correct authorizer callback remains in place during the [sqlite3_step()]. - ** - ** ^Note that the authorizer callback is invoked only during - ** [sqlite3_prepare()] or its variants. Authorization is not - ** performed during statement evaluation in [sqlite3_step()], unless - ** as stated in the previous paragraph, sqlite3_step() invokes - ** sqlite3_prepare_v2() to reprepare a statement after a schema change. - */ - //SQLITE_API int sqlite3_set_authorizer( - // sqlite3*, - // int (*xAuth)(void*,int,const char*,const char*,const char*,const char), - // void *pUserData - //); - - /* - ** CAPI3REF: Authorizer Return Codes - ** - ** The [sqlite3_set_authorizer | authorizer callback function] must - ** return either [SQLITE_OK] or one of these two constants in order - ** to signal SQLite whether or not the action is permitted. See the - ** [sqlite3_set_authorizer | authorizer documentation] for additional - ** information. - ** - ** Note that SQLITE_IGNORE is also used as a [SQLITE_ROLLBACK | return code] - ** from the [sqlite3_vtab_on_conflict()] interface. - */ - //#define SQLITE_DENY 1 /* Abort the SQL statement with an error */ - //#define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */ - const int SQLITE_DENY = 1; - const int SQLITE_IGNORE = 2; - - /* - ** CAPI3REF: Authorizer Action Codes - ** - ** The [sqlite3_set_authorizer()] interface registers a callback function - ** that is invoked to authorize certain SQL statement actions. The - ** second parameter to the callback is an integer code that specifies - ** what action is being authorized. These are the integer action codes that - ** the authorizer callback may be passed. - ** - ** These action code values signify what kind of operation is to be - ** authorized. The 3rd and 4th parameters to the authorization - ** callback function will be parameters or NULL depending on which of these - ** codes is used as the second parameter. ^(The 5th parameter to the - ** authorizer callback is the name of the database ("main", "temp", - ** etc.) if applicable.)^ ^The 6th parameter to the authorizer callback - ** is the name of the inner-most trigger or view that is responsible for - ** the access attempt or NULL if this access attempt is directly from - ** top-level SQL code. - */ - /******************************************* 3rd ************ 4th ***********/ - //#define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */ - //#define SQLITE_CREATE_TABLE 2 /* Table Name NULL */ - //#define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */ - //#define SQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */ - //#define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */ - //#define SQLITE_CREATE_TEMP_VIEW 6 /* View Name NULL */ - //#define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */ - //#define SQLITE_CREATE_VIEW 8 /* View Name NULL */ - //#define SQLITE_DELETE 9 /* Table Name NULL */ - //#define SQLITE_DROP_INDEX 10 /* Index Name Table Name */ - //#define SQLITE_DROP_TABLE 11 /* Table Name NULL */ - //#define SQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */ - //#define SQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */ - //#define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */ - //#define SQLITE_DROP_TEMP_VIEW 15 /* View Name NULL */ - //#define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */ - //#define SQLITE_DROP_VIEW 17 /* View Name NULL */ - //#define SQLITE_INSERT 18 /* Table Name NULL */ - //#define SQLITE_PRAGMA 19 /* Pragma Name 1st arg or NULL */ - //#define SQLITE_READ 20 /* Table Name Column Name */ - //#define SQLITE_SELECT 21 /* NULL NULL */ - //#define SQLITE_TRANSACTION 22 /* Operation NULL */ - //#define SQLITE_UPDATE 23 /* Table Name Column Name */ - //#define SQLITE_ATTACH 24 /* Filename NULL */ - //#define SQLITE_DETACH 25 /* Database Name NULL */ - //#define SQLITE_ALTER_TABLE 26 /* Database Name Table Name */ - //#define SQLITE_REINDEX 27 /* Index Name NULL */ - //#define SQLITE_ANALYZE 28 /* Table Name NULL */ - //#define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */ - //#define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */ - //#define SQLITE_FUNCTION 31 /* NULL Function Name */ - //#define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */ - //#define SQLITE_COPY 0 /* No longer used */ - const int SQLITE_CREATE_INDEX = 1; - const int SQLITE_CREATE_TABLE = 2; - const int SQLITE_CREATE_TEMP_INDEX = 3; - const int SQLITE_CREATE_TEMP_TABLE = 4; - const int SQLITE_CREATE_TEMP_TRIGGER = 5; - const int SQLITE_CREATE_TEMP_VIEW = 6; - const int SQLITE_CREATE_TRIGGER = 7; - const int SQLITE_CREATE_VIEW = 8; - const int SQLITE_DELETE = 9; - const int SQLITE_DROP_INDEX = 10; - const int SQLITE_DROP_TABLE = 11; - const int SQLITE_DROP_TEMP_INDEX = 12; - const int SQLITE_DROP_TEMP_TABLE = 13; - const int SQLITE_DROP_TEMP_TRIGGER = 14; - const int SQLITE_DROP_TEMP_VIEW = 15; - const int SQLITE_DROP_TRIGGER = 16; - const int SQLITE_DROP_VIEW = 17; - const int SQLITE_INSERT = 18; - const int SQLITE_PRAGMA = 19; - const int SQLITE_READ = 20; - const int SQLITE_SELECT = 21; - const int SQLITE_TRANSACTION = 22; - const int SQLITE_UPDATE = 23; - const int SQLITE_ATTACH = 24; - const int SQLITE_DETACH = 25; - const int SQLITE_ALTER_TABLE = 26; - const int SQLITE_REINDEX = 27; - const int SQLITE_ANALYZE = 28; - const int SQLITE_CREATE_VTABLE = 29; - const int SQLITE_DROP_VTABLE = 30; - const int SQLITE_FUNCTION = 31; - const int SQLITE_SAVEPOINT = 32; - const int SQLITE_COPY = 0; - - /* - ** CAPI3REF: Tracing And Profiling Functions - ** - ** These routines register callback functions that can be used for - ** tracing and profiling the execution of SQL statements. - ** - ** ^The callback function registered by sqlite3_trace() is invoked at - ** various times when an SQL statement is being run by [sqlite3_step()]. - ** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the - ** SQL statement text as the statement first begins executing. - ** ^(Additional sqlite3_trace() callbacks might occur - ** as each triggered subprogram is entered. The callbacks for triggers - ** contain a UTF-8 SQL comment that identifies the trigger.)^ - ** - ** ^The callback function registered by sqlite3_profile() is invoked - ** as each SQL statement finishes. ^The profile callback contains - ** the original statement text and an estimate of wall-clock time - ** of how long that statement took to run. ^The profile callback - ** time is in units of nanoseconds, however the current implementation - ** is only capable of millisecond resolution so the six least significant - ** digits in the time are meaningless. Future versions of SQLite - ** might provide greater resolution on the profiler callback. The - ** sqlite3_profile() function is considered experimental and is - ** subject to change in future versions of SQLite. - */ - //SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char), void); - //SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*, - // void(*xProfile)(void*,const char*,sqlite3_uint64), void); - - /* - ** CAPI3REF: Query Progress Callbacks - ** - ** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback - ** function X to be invoked periodically during long running calls to - ** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for - ** database connection D. An example use for this - ** interface is to keep a GUI updated during a large query. - ** - ** ^The parameter P is passed through as the only parameter to the - ** callback function X. ^The parameter N is the number of - ** [virtual machine instructions] that are evaluated between successive - ** invocations of the callback X. - ** - ** ^Only a single progress handler may be defined at one time per - ** [database connection]; setting a new progress handler cancels the - ** old one. ^Setting parameter X to NULL disables the progress handler. - ** ^The progress handler is also disabled by setting N to a value less - ** than 1. - ** - ** ^If the progress callback returns non-zero, the operation is - ** interrupted. This feature can be used to implement a - ** "Cancel" button on a GUI progress dialog box. - ** - ** The progress handler callback must not do anything that will modify - ** the database connection that invoked the progress handler. - ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their - ** database connections for the meaning of "modify" in this paragraph. - ** - */ - //SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int()(void), void); - - /* - ** CAPI3REF: Opening A New Database Connection - ** - ** ^These routines open an SQLite database file as specified by the - ** filename argument. ^The filename argument is interpreted as UTF-8 for - ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte - ** order for sqlite3_open16(). ^(A [database connection] handle is usually - ** returned in *ppDb, even if an error occurs. The only exception is that - ** if SQLite is unable to allocate memory to hold the [sqlite3] object, - ** a NULL will be written into *ppDb instead of a pointer to the [sqlite3] - ** object.)^ ^(If the database is opened (and/or created) successfully, then - ** [SQLITE_OK] is returned. Otherwise an [error code] is returned.)^ ^The - ** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain - ** an English language description of the error following a failure of any - ** of the sqlite3_open() routines. - ** - ** ^The default encoding for the database will be UTF-8 if - ** sqlite3_open() or sqlite3_open_v2() is called and - ** UTF-16 in the native byte order if sqlite3_open16() is used. - ** - ** Whether or not an error occurs when it is opened, resources - ** associated with the [database connection] handle should be released by - ** passing it to [sqlite3_close()] when it is no longer required. - ** - ** The sqlite3_open_v2() interface works like sqlite3_open() - ** except that it accepts two additional parameters for additional control - ** over the new database connection. ^(The flags parameter to - ** sqlite3_open_v2() can take one of - ** the following three values, optionally combined with the - ** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE], - ** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^ - ** - **
- ** ^(
[SQLITE_OPEN_READONLY]
- **
The database is opened in read-only mode. If the database does not - ** already exist, an error is returned.
)^ - ** - ** ^(
[SQLITE_OPEN_READWRITE]
- **
The database is opened for reading and writing if possible, or reading - ** only if the file is write protected by the operating system. In either - ** case the database must already exist, otherwise an error is returned.
)^ - ** - ** ^(
[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]
- **
The database is opened for reading and writing, and is created if - ** it does not already exist. This is the behavior that is always used for - ** sqlite3_open() and sqlite3_open16().
)^ - **
- ** - ** If the 3rd parameter to sqlite3_open_v2() is not one of the - ** combinations shown above optionally combined with other - ** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits] - ** then the behavior is undefined. - ** - ** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection - ** opens in the multi-thread [threading mode] as long as the single-thread - ** mode has not been set at compile-time or start-time. ^If the - ** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens - ** in the serialized [threading mode] unless single-thread was - ** previously selected at compile-time or start-time. - ** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be - ** eligible to use [shared cache mode], regardless of whether or not shared - ** cache is enabled using [sqlite3_enable_shared_cache()]. ^The - ** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not - ** participate in [shared cache mode] even if it is enabled. - ** - ** ^The fourth parameter to sqlite3_open_v2() is the name of the - ** [sqlite3_vfs] object that defines the operating system interface that - ** the new database connection should use. ^If the fourth parameter is - ** a NULL pointer then the default [sqlite3_vfs] object is used. - ** - ** ^If the filename is ":memory:", then a private, temporary in-memory database - ** is created for the connection. ^This in-memory database will vanish when - ** the database connection is closed. Future versions of SQLite might - ** make use of additional special filenames that begin with the ":" character. - ** It is recommended that when a database filename actually does begin with - ** a ":" character you should prefix the filename with a pathname such as - ** "./" to avoid ambiguity. - ** - ** ^If the filename is an empty string, then a private, temporary - ** on-disk database will be created. ^This private database will be - ** automatically deleted as soon as the database connection is closed. - ** - ** [[URI filenames in sqlite3_open()]]

URI Filenames

- ** - ** ^If [URI filename] interpretation is enabled, and the filename argument - ** begins with "file:", then the filename is interpreted as a URI. ^URI - ** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is - ** set in the fourth argument to sqlite3_open_v2(), or if it has - ** been enabled globally using the [SQLITE_CONFIG_URI] option with the - ** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option. - ** As of SQLite version 3.7.7, URI filename interpretation is turned off - ** by default, but future releases of SQLite might enable URI filename - ** interpretation by default. See "[URI filenames]" for additional - ** information. - ** - ** URI filenames are parsed according to RFC 3986. ^If the URI contains an - ** authority, then it must be either an empty string or the string - ** "localhost". ^If the authority is not an empty string or "localhost", an - ** error is returned to the caller. ^The fragment component of a URI, if - ** present, is ignored. - ** - ** ^SQLite uses the path component of the URI as the name of the disk file - ** which contains the database. ^If the path begins with a '/' character, - ** then it is interpreted as an absolute path. ^If the path does not begin - ** with a '/' (meaning that the authority section is omitted from the URI) - ** then the path is interpreted as a relative path. - ** ^On windows, the first component of an absolute path - ** is a drive specification (e.g. "C:"). - ** - ** [[core URI query parameters]] - ** The query component of a URI may contain parameters that are interpreted - ** either by SQLite itself, or by a [VFS | custom VFS implementation]. - ** SQLite interprets the following three query parameters: - ** - **
    - **
  • vfs: ^The "vfs" parameter may be used to specify the name of - ** a VFS object that provides the operating system interface that should - ** be used to access the database file on disk. ^If this option is set to - ** an empty string the default VFS object is used. ^Specifying an unknown - ** VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is - ** present, then the VFS specified by the option takes precedence over - ** the value passed as the fourth parameter to sqlite3_open_v2(). - ** - **
  • mode: ^(The mode parameter may be set to either "ro", "rw" or - ** "rwc". Attempting to set it to any other value is an error)^. - ** ^If "ro" is specified, then the database is opened for read-only - ** access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the - ** third argument to sqlite3_prepare_v2(). ^If the mode option is set to - ** "rw", then the database is opened for read-write (but not create) - ** access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had - ** been set. ^Value "rwc" is equivalent to setting both - ** SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE. ^If sqlite3_open_v2() is - ** used, it is an error to specify a value for the mode parameter that is - ** less restrictive than that specified by the flags passed as the third - ** parameter. - ** - **
  • cache: ^The cache parameter may be set to either "shared" or - ** "private". ^Setting it to "shared" is equivalent to setting the - ** SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to - ** sqlite3_open_v2(). ^Setting the cache parameter to "private" is - ** equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit. - ** ^If sqlite3_open_v2() is used and the "cache" parameter is present in - ** a URI filename, its value overrides any behaviour requested by setting - ** SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag. - **
- ** - ** ^Specifying an unknown parameter in the query component of a URI is not an - ** error. Future versions of SQLite might understand additional query - ** parameters. See "[query parameters with special meaning to SQLite]" for - ** additional information. - ** - ** [[URI filename examples]]

URI filename examples

- ** - **
- **
URI filenames Results - **
file:data.db - ** Open the file "data.db" in the current directory. - **
file:/home/fred/data.db
- ** file:///home/fred/data.db
- ** file://localhost/home/fred/data.db
- ** Open the database file "/home/fred/data.db". - **
file://darkstar/home/fred/data.db - ** An error. "darkstar" is not a recognized authority. - **
- ** file:///C:/Documents%20and%20Settings/fred/Desktop/data.db - ** Windows only: Open the file "data.db" on fred's desktop on drive - ** C:. Note that the %20 escaping in this example is not strictly - ** necessary - space characters can be used literally - ** in URI filenames. - **
file:data.db?mode=ro&cache=private - ** Open file "data.db" in the current directory for read-only access. - ** Regardless of whether or not shared-cache mode is enabled by - ** default, use a private cache. - **
file:/home/fred/data.db?vfs=unix-nolock - ** Open file "/home/fred/data.db". Use the special VFS "unix-nolock". - **
file:data.db?mode=readonly - ** An error. "readonly" is not a valid option for the "mode" parameter. - **
- ** - ** ^URI hexadecimal escape sequences (%HH) are supported within the path and - ** query components of a URI. A hexadecimal escape sequence consists of a - ** percent sign - "%" - followed by exactly two hexadecimal digits - ** specifying an octet value. ^Before the path or query components of a - ** URI filename are interpreted, they are encoded using UTF-8 and all - ** hexadecimal escape sequences replaced by a single byte containing the - ** corresponding octet. If this process generates an invalid UTF-8 encoding, - ** the results are undefined. - ** - ** Note to Windows users: The encoding used for the filename argument - ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever - ** codepage is currently defined. Filenames containing international - ** characters must be converted to UTF-8 prior to passing them into - ** sqlite3_open() or sqlite3_open_v2(). - */ - //SQLITE_API int sqlite3_open( - // string filename, /* Database filename (UTF-8) */ - // sqlite3 **ppDb /* OUT: SQLite db handle */ - //); - //SQLITE_API int sqlite3_open16( - // const void *filename, /* Database filename (UTF-16) */ - // sqlite3 **ppDb /* OUT: SQLite db handle */ - //); - //SQLITE_API int sqlite3_open_v2( - // string filename, /* Database filename (UTF-8) */ - // sqlite3 **ppDb, /* OUT: SQLite db handle */ - // int flags, /* Flags */ - // string zVfs /* Name of VFS module to use */ - //); - - /* - ** CAPI3REF: Obtain Values For URI Parameters - ** - ** This is a utility routine, useful to VFS implementations, that checks - ** to see if a database file was a URI that contained a specific query - ** parameter, and if so obtains the value of the query parameter. - ** - ** The zFilename argument is the filename pointer passed into the xOpen() - ** method of a VFS implementation. The zParam argument is the name of the - ** query parameter we seek. This routine returns the value of the zParam - ** parameter if it exists. If the parameter does not exist, this routine - ** returns a NULL pointer. - ** - ** If the zFilename argument to this function is not a pointer that SQLite - ** passed into the xOpen VFS method, then the behavior of this routine - ** is undefined and probably undesirable. - */ - //SQLITE_API string sqlite3_uri_parameter(string zFilename, string zParam); - - - /* - ** CAPI3REF: Error Codes And Messages - ** - ** ^The sqlite3_errcode() interface returns the numeric [result code] or - ** [extended result code] for the most recent failed sqlite3_* API call - ** associated with a [database connection]. If a prior API call failed - ** but the most recent API call succeeded, the return value from - ** sqlite3_errcode() is undefined. ^The sqlite3_extended_errcode() - ** interface is the same except that it always returns the - ** [extended result code] even when extended result codes are - ** disabled. - ** - ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language - ** text that describes the error, as either UTF-8 or UTF-16 respectively. - ** ^(Memory to hold the error message string is managed internally. - ** The application does not need to worry about freeing the result. - ** However, the error string might be overwritten or deallocated by - ** subsequent calls to other SQLite interface functions.)^ - ** - ** When the serialized [threading mode] is in use, it might be the - ** case that a second error occurs on a separate thread in between - ** the time of the first error and the call to these interfaces. - ** When that happens, the second error will be reported since these - ** interfaces always report the most recent result. To avoid - ** this, each thread can obtain exclusive use of the [database connection] D - ** by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning - ** to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after - ** all calls to the interfaces listed here are completed. - ** - ** If an interface fails with SQLITE_MISUSE, that means the interface - ** was invoked incorrectly by the application. In that case, the - ** error code and message may or may not be set. - */ - //SQLITE_API int sqlite3_errcode(sqlite3 db); - //SQLITE_API int sqlite3_extended_errcode(sqlite3 db); - //SQLITE_API string sqlite3_errmsg(sqlite3); - //SQLITE_API const void *sqlite3_errmsg16(sqlite3); - - /* - ** CAPI3REF: SQL Statement Object - ** KEYWORDS: {prepared statement} {prepared statements} - ** - ** An instance of this object represents a single SQL statement. - ** This object is variously known as a "prepared statement" or a - ** "compiled SQL statement" or simply as a "statement". - ** - ** The life of a statement object goes something like this: - ** - **
    - **
  1. Create the object using [sqlite3_prepare_v2()] or a related - ** function. - **
  2. Bind values to [host parameters] using the sqlite3_bind_*() - ** interfaces. - **
  3. Run the SQL by calling [sqlite3_step()] one or more times. - **
  4. Reset the statement using [sqlite3_reset()] then go back - ** to step 2. Do this zero or more times. - **
  5. Destroy the object using [sqlite3_finalize()]. - **
- ** - ** Refer to documentation on individual methods above for additional - ** information. - */ - //typedef struct sqlite3_stmt sqlite3_stmt; - - /* - ** CAPI3REF: Run-time Limits - ** - ** ^(This interface allows the size of various constructs to be limited - ** on a connection by connection basis. The first parameter is the - ** [database connection] whose limit is to be set or queried. The - ** second parameter is one of the [limit categories] that define a - ** class of constructs to be size limited. The third parameter is the - ** new limit for that construct.)^ - ** - ** ^If the new limit is a negative number, the limit is unchanged. - ** ^(For each limit category SQLITE_LIMIT_NAME there is a - ** [limits | hard upper bound] - ** set at compile-time by a C preprocessor macro called - ** [limits | SQLITE_MAX_NAME]. - ** (The "_LIMIT_" in the name is changed to "_MAX_".))^ - ** ^Attempts to increase a limit above its hard upper bound are - ** silently truncated to the hard upper bound. - ** - ** ^Regardless of whether or not the limit was changed, the - ** [sqlite3_limit()] interface returns the prior value of the limit. - ** ^Hence, to find the current value of a limit without changing it, - ** simply invoke this interface with the third parameter set to -1. - ** - ** Run-time limits are intended for use in applications that manage - ** both their own internal database and also databases that are controlled - ** by untrusted external sources. An example application might be a - ** web browser that has its own databases for storing history and - ** separate databases controlled by JavaScript applications downloaded - ** off the Internet. The internal databases can be given the - ** large, default limits. Databases managed by external sources can - ** be given much smaller limits designed to prevent a denial of service - ** attack. Developers might also want to use the [sqlite3_set_authorizer()] - ** interface to further control untrusted SQL. The size of the database - ** created by an untrusted script can be contained using the - ** [max_page_count] [PRAGMA]. - ** - ** New run-time limit categories may be added in future releases. - */ - //SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); - - /* - ** CAPI3REF: Run-Time Limit Categories - ** KEYWORDS: {limit category} {*limit categories} - ** - ** These constants define various performance limits - ** that can be lowered at run-time using [sqlite3_limit()]. - ** The synopsis of the meanings of the various limits is shown below. - ** Additional information is available at [limits | Limits in SQLite]. - ** - **
- ** [[SQLITE_LIMIT_LENGTH]] ^(
SQLITE_LIMIT_LENGTH
- **
The maximum size of any string or BLOB or table row, in bytes.
)^ - ** - ** [[SQLITE_LIMIT_SQL_LENGTH]] ^(
SQLITE_LIMIT_SQL_LENGTH
- **
The maximum length of an SQL statement, in bytes.
)^ - ** - ** [[SQLITE_LIMIT_COLUMN]] ^(
SQLITE_LIMIT_COLUMN
- **
The maximum number of columns in a table definition or in the - ** result set of a [SELECT] or the maximum number of columns in an index - ** or in an ORDER BY or GROUP BY clause.
)^ - ** - ** [[SQLITE_LIMIT_EXPR_DEPTH]] ^(
SQLITE_LIMIT_EXPR_DEPTH
- **
The maximum depth of the parse tree on any expression.
)^ - ** - ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(
SQLITE_LIMIT_COMPOUND_SELECT
- **
The maximum number of terms in a compound SELECT statement.
)^ - ** - ** [[SQLITE_LIMIT_VDBE_OP]] ^(
SQLITE_LIMIT_VDBE_OP
- **
The maximum number of instructions in a virtual machine program - ** used to implement an SQL statement. This limit is not currently - ** enforced, though that might be added in some future release of - ** SQLite.
)^ - ** - ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(
SQLITE_LIMIT_FUNCTION_ARG
- **
The maximum number of arguments on a function.
)^ - ** - ** [[SQLITE_LIMIT_ATTACHED]] ^(
SQLITE_LIMIT_ATTACHED
- **
The maximum number of [ATTACH | attached databases].)^
- ** - ** [[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]] - ** ^(
SQLITE_LIMIT_LIKE_PATTERN_LENGTH
- **
The maximum length of the pattern argument to the [LIKE] or - ** [GLOB] operators.
)^ - ** - ** [[SQLITE_LIMIT_VARIABLE_NUMBER]] - ** ^(
SQLITE_LIMIT_VARIABLE_NUMBER
- **
The maximum index number of any [parameter] in an SQL statement.)^ - ** - ** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(
SQLITE_LIMIT_TRIGGER_DEPTH
- **
The maximum depth of recursion for triggers.
)^ - **
- */ - //#define SQLITE_LIMIT_LENGTH 0 - //#define SQLITE_LIMIT_SQL_LENGTH 1 - //#define SQLITE_LIMIT_COLUMN 2 - //#define SQLITE_LIMIT_EXPR_DEPTH 3 - //#define SQLITE_LIMIT_COMPOUND_SELECT 4 - //#define SQLITE_LIMIT_VDBE_OP 5 - //#define SQLITE_LIMIT_FUNCTION_ARG 6 - //#define SQLITE_LIMIT_ATTACHED 7 - //#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8 - //#define SQLITE_LIMIT_VARIABLE_NUMBER 9 - //#define SQLITE_LIMIT_TRIGGER_DEPTH 10 - const int SQLITE_LIMIT_LENGTH = 0; - const int SQLITE_LIMIT_SQL_LENGTH = 1; - const int SQLITE_LIMIT_COLUMN = 2; - const int SQLITE_LIMIT_EXPR_DEPTH = 3; - const int SQLITE_LIMIT_COMPOUND_SELECT = 4; - const int SQLITE_LIMIT_VDBE_OP = 5; - const int SQLITE_LIMIT_FUNCTION_ARG = 6; - const int SQLITE_LIMIT_ATTACHED = 7; - const int SQLITE_LIMIT_LIKE_PATTERN_LENGTH = 8; - const int SQLITE_LIMIT_VARIABLE_NUMBER = 9; - const int SQLITE_LIMIT_TRIGGER_DEPTH = 10; - - /* - ** CAPI3REF: Compiling An SQL Statement - ** KEYWORDS: {SQL statement compiler} - ** - ** To execute an SQL query, it must first be compiled into a byte-code - ** program using one of these routines. - ** - ** The first argument, "db", is a [database connection] obtained from a - ** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or - ** [sqlite3_open16()]. The database connection must not have been closed. - ** - ** The second argument, "zSql", is the statement to be compiled, encoded - ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() - ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2() - ** use UTF-16. - ** - ** ^If the nByte argument is less than zero, then zSql is read up to the - ** first zero terminator. ^If nByte is non-negative, then it is the maximum - ** number of bytes read from zSql. ^When nByte is non-negative, the - ** zSql string ends at either the first '\000' or '\u0000' character or - ** the nByte-th byte, whichever comes first. If the caller knows - ** that the supplied string is nul-terminated, then there is a small - ** performance advantage to be gained by passing an nByte parameter that - ** is equal to the number of bytes in the input string including - ** the nul-terminator bytes. - ** - ** ^If pzTail is not NULL then *pzTail is made to point to the first byte - ** past the end of the first SQL statement in zSql. These routines only - ** compile the first statement in zSql, so *pzTail is left pointing to - ** what remains uncompiled. - ** - ** ^*ppStmt is left pointing to a compiled [prepared statement] that can be - ** executed using [sqlite3_step()]. ^If there is an error, *ppStmt is set - ** to NULL. ^If the input text contains no SQL (if the input is an empty - ** string or a comment) then *ppStmt is set to NULL. - ** The calling procedure is responsible for deleting the compiled - ** SQL statement using [sqlite3_finalize()] after it has finished with it. - ** ppStmt may not be NULL. - ** - ** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK]; - ** otherwise an [error code] is returned. - ** - ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are - ** recommended for all new programs. The two older interfaces are retained - ** for backwards compatibility, but their use is discouraged. - ** ^In the "v2" interfaces, the prepared statement - ** that is returned (the [sqlite3_stmt] object) contains a copy of the - ** original SQL text. This causes the [sqlite3_step()] interface to - ** behave differently in three ways: - ** - **
    - **
  1. - ** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it - ** always used to do, [sqlite3_step()] will automatically recompile the SQL - ** statement and try to run it again. - **
  2. - ** - **
  3. - ** ^When an error occurs, [sqlite3_step()] will return one of the detailed - ** [error codes] or [extended error codes]. ^The legacy behavior was that - ** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code - ** and the application would have to make a second call to [sqlite3_reset()] - ** in order to find the underlying cause of the problem. With the "v2" prepare - ** interfaces, the underlying reason for the error is returned immediately. - **
  4. - ** - **
  5. - ** ^If the specific value bound to [parameter | host parameter] in the - ** WHERE clause might influence the choice of query plan for a statement, - ** then the statement will be automatically recompiled, as if there had been - ** a schema change, on the first [sqlite3_step()] call following any change - ** to the [sqlite3_bind_text | bindings] of that [parameter]. - ** ^The specific value of WHERE-clause [parameter] might influence the - ** choice of query plan if the parameter is the left-hand side of a [LIKE] - ** or [GLOB] operator or if the parameter is compared to an indexed column - ** and the [SQLITE_ENABLE_STAT2] compile-time option is enabled. - ** the - **
  6. - **
- */ - //SQLITE_API int sqlite3_prepare( - // sqlite3 db, /* Database handle */ - // string zSql, /* SQL statement, UTF-8 encoded */ - // int nByte, /* Maximum length of zSql in bytes. */ - // sqlite3_stmt **ppStmt, /* OUT: Statement handle */ - // string *pzTail /* OUT: Pointer to unused portion of zSql */ - //); - //SQLITE_API int sqlite3_prepare_v2( - // sqlite3 db, /* Database handle */ - // string zSql, /* SQL statement, UTF-8 encoded */ - // int nByte, /* Maximum length of zSql in bytes. */ - // sqlite3_stmt **ppStmt, /* OUT: Statement handle */ - // string *pzTail /* OUT: Pointer to unused portion of zSql */ - //); - //SQLITE_API int sqlite3_prepare16( - // sqlite3 db, /* Database handle */ - // string zSql, /* SQL statement, UTF-16 encoded */ - // int nByte, /* Maximum length of zSql in bytes. */ - // sqlite3_stmt **ppStmt, /* OUT: Statement handle */ - // const void **pzTail /* OUT: Pointer to unused portion of zSql */ - //); - //SQLITE_API int sqlite3_prepare16_v2( - // sqlite3 db, /* Database handle */ - // string zSql, /* SQL statement, UTF-16 encoded */ - // int nByte, /* Maximum length of zSql in bytes. */ - // sqlite3_stmt **ppStmt, /* OUT: Statement handle */ - // const void **pzTail /* OUT: Pointer to unused portion of zSql */ - //); - - /* - ** CAPI3REF: Retrieving Statement SQL - ** - ** ^This interface can be used to retrieve a saved copy of the original - ** SQL text used to create a [prepared statement] if that statement was - ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()]. - */ - //SQLITE_API string sqlite3_sql(sqlite3_stmt *pStmt); - - /* - ** CAPI3REF: Determine If An SQL Statement Writes The Database - ** - ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if - ** and only if the [prepared statement] X makes no direct changes to - ** the content of the database file. - ** - ** Note that [application-defined SQL functions] or - ** [virtual tables] might change the database indirectly as a side effect. - ** ^(For example, if an application defines a function "eval()" that - ** calls [sqlite3_exec()], then the following SQL statement would - ** change the database file through side-effects: - ** - **
-    **    SELECT eval('DELETE FROM t1') FROM t2;
-    ** 
- ** - ** But because the [SELECT] statement does not change the database file - ** directly, sqlite3_stmt_readonly() would still return true.)^ - ** - ** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK], - ** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true, - ** since the statements themselves do not actually modify the database but - ** rather they control the timing of when other statements modify the - ** database. ^The [ATTACH] and [DETACH] statements also cause - ** sqlite3_stmt_readonly() to return true since, while those statements - ** change the configuration of a database connection, they do not make - ** changes to the content of the database files on disk. - */ - //SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); - - /* - ** CAPI3REF: Dynamically Typed Value Object - ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value} - ** - ** SQLite uses the sqlite3_value object to represent all values - ** that can be stored in a database table. SQLite uses dynamic typing - ** for the values it stores. ^Values stored in sqlite3_value objects - ** can be integers, floating point values, strings, BLOBs, or NULL. - ** - ** An sqlite3_value object may be either "protected" or "unprotected". - ** Some interfaces require a protected sqlite3_value. Other interfaces - ** will accept either a protected or an unprotected sqlite3_value. - ** Every interface that accepts sqlite3_value arguments specifies - ** whether or not it requires a protected sqlite3_value. - ** - ** The terms "protected" and "unprotected" refer to whether or not - ** a mutex is held. An internal mutex is held for a protected - ** sqlite3_value object but no mutex is held for an unprotected - ** sqlite3_value object. If SQLite is compiled to be single-threaded - ** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0) - ** or if SQLite is run in one of reduced mutex modes - ** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD] - ** then there is no distinction between protected and unprotected - ** sqlite3_value objects and they can be used interchangeably. However, - ** for maximum code portability it is recommended that applications - ** still make the distinction between protected and unprotected - ** sqlite3_value objects even when not strictly required. - ** - ** ^The sqlite3_value objects that are passed as parameters into the - ** implementation of [application-defined SQL functions] are protected. - ** ^The sqlite3_value object returned by - ** [sqlite3_column_value()] is unprotected. - ** Unprotected sqlite3_value objects may only be used with - ** [sqlite3_result_value()] and [sqlite3_bind_value()]. - ** The [sqlite3_value_blob | sqlite3_value_type()] family of - ** interfaces require protected sqlite3_value objects. - */ - //typedef struct Mem sqlite3_value; - - /* - ** CAPI3REF: SQL Function Context Object - ** - ** The context in which an SQL function executes is stored in an - ** sqlite3_context object. ^A pointer to an sqlite3_context object - ** is always first parameter to [application-defined SQL functions]. - ** The application-defined SQL function implementation will pass this - ** pointer through into calls to [sqlite3_result_int | sqlite3_result()], - ** [sqlite3_aggregate_context()], [sqlite3_user_data()], - ** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()], - ** and/or [sqlite3_set_auxdata()]. - */ - //typedef struct sqlite3_context sqlite3_context; - - /* - ** CAPI3REF: Binding Values To Prepared Statements - ** KEYWORDS: {host parameter} {host parameters} {host parameter name} - ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding} - ** - ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants, - ** literals may be replaced by a [parameter] that matches one of following - ** templates: - ** - **
    - **
  • ? - **
  • ?NNN - **
  • :VVV - **
  • @VVV - **
  • $VVV - **
- ** - ** In the templates above, NNN represents an integer literal, - ** and VVV represents an alphanumeric identifier.)^ ^The values of these - ** parameters (also called "host parameter names" or "SQL parameters") - ** can be set using the sqlite3_bind_*() routines defined here. - ** - ** ^The first argument to the sqlite3_bind_*() routines is always - ** a pointer to the [sqlite3_stmt] object returned from - ** [sqlite3_prepare_v2()] or its variants. - ** - ** ^The second argument is the index of the SQL parameter to be set. - ** ^The leftmost SQL parameter has an index of 1. ^When the same named - ** SQL parameter is used more than once, second and subsequent - ** occurrences have the same index as the first occurrence. - ** ^The index for named parameters can be looked up using the - ** [sqlite3_bind_parameter_index()] API if desired. ^The index - ** for "?NNN" parameters is the value of NNN. - ** ^The NNN value must be between 1 and the [sqlite3_limit()] - ** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999). - ** - ** ^The third argument is the value to bind to the parameter. - ** - ** ^(In those routines that have a fourth argument, its value is the - ** number of bytes in the parameter. To be clear: the value is the - ** number of bytes in the value, not the number of characters.)^ - ** ^If the fourth parameter is negative, the length of the string is - ** the number of bytes up to the first zero terminator. - ** - ** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and - ** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or - ** string after SQLite has finished with it. ^The destructor is called - ** to dispose of the BLOB or string even if the call to sqlite3_bind_blob(), - ** sqlite3_bind_text(), or sqlite3_bind_text16() fails. - ** ^If the fifth argument is - ** the special value [SQLITE_STATIC], then SQLite assumes that the - ** information is in static, unmanaged space and does not need to be freed. - ** ^If the fifth argument has the value [SQLITE_TRANSIENT], then - ** SQLite makes its own private copy of the data immediately, before - ** the sqlite3_bind_*() routine returns. - ** - ** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that - ** is filled with zeroes. ^A zeroblob uses a fixed amount of memory - ** (just an integer to hold its size) while it is being processed. - ** Zeroblobs are intended to serve as placeholders for BLOBs whose - ** content is later written using - ** [sqlite3_blob_open | incremental BLOB I/O] routines. - ** ^A negative value for the zeroblob results in a zero-length BLOB. - ** - ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer - ** for the [prepared statement] or with a prepared statement for which - ** [sqlite3_step()] has been called more recently than [sqlite3_reset()], - ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() - ** routine is passed a [prepared statement] that has been finalized, the - ** result is undefined and probably harmful. - ** - ** ^Bindings are not cleared by the [sqlite3_reset()] routine. - ** ^Unbound parameters are interpreted as NULL. - ** - ** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an - ** [error code] if anything goes wrong. - ** ^[SQLITE_RANGE] is returned if the parameter - ** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails. - ** - ** See also: [sqlite3_bind_parameter_count()], - ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()]. - */ - //SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void()(void)); - //SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double); - //SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int); - //SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); - //SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int); - //SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void()(void)); - //SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void()(void)); - //SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value); - //SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); - - /* - ** CAPI3REF: Number Of SQL Parameters - ** - ** ^This routine can be used to find the number of [SQL parameters] - ** in a [prepared statement]. SQL parameters are tokens of the - ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as - ** placeholders for values that are [sqlite3_bind_blob | bound] - ** to the parameters at a later time. - ** - ** ^(This routine actually returns the index of the largest (rightmost) - ** parameter. For all forms except ?NNN, this will correspond to the - ** number of unique parameters. If parameters of the ?NNN form are used, - ** there may be gaps in the list.)^ - ** - ** See also: [sqlite3_bind_blob|sqlite3_bind()], - ** [sqlite3_bind_parameter_name()], and - ** [sqlite3_bind_parameter_index()]. - */ - //SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt); - - /* - ** CAPI3REF: Name Of A Host Parameter - ** - ** ^The sqlite3_bind_parameter_name(P,N) interface returns - ** the name of the N-th [SQL parameter] in the [prepared statement] P. - ** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA" - ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA" - ** respectively. - ** In other words, the initial ":" or "$" or "@" or "?" - ** is included as part of the name.)^ - ** ^Parameters of the form "?" without a following integer have no name - ** and are referred to as "nameless" or "anonymous parameters". - ** - ** ^The first host parameter has an index of 1, not 0. - ** - ** ^If the value N is out of range or if the N-th parameter is - ** nameless, then NULL is returned. ^The returned string is - ** always in UTF-8 encoding even if the named parameter was - ** originally specified as UTF-16 in [sqlite3_prepare16()] or - ** [sqlite3_prepare16_v2()]. - ** - ** See also: [sqlite3_bind_blob|sqlite3_bind()], - ** [sqlite3_bind_parameter_count()], and - ** [sqlite3_bind_parameter_index()]. - */ - //SQLITE_API string sqlite3_bind_parameter_name(sqlite3_stmt*, int); - - /* - ** CAPI3REF: Index Of A Parameter With A Given Name - ** - ** ^Return the index of an SQL parameter given its name. ^The - ** index value returned is suitable for use as the second - ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero - ** is returned if no matching parameter is found. ^The parameter - ** name must be given in UTF-8 even if the original statement - ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()]. - ** - ** See also: [sqlite3_bind_blob|sqlite3_bind()], - ** [sqlite3_bind_parameter_count()], and - ** [sqlite3_bind_parameter_index()]. - */ - //SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, string zName); - - /* - ** CAPI3REF: Reset All Bindings On A Prepared Statement - ** - ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset - ** the [sqlite3_bind_blob | bindings] on a [prepared statement]. - ** ^Use this routine to reset all host parameters to NULL. - */ - //SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt); - - /* - ** CAPI3REF: Number Of Columns In A Result Set - ** - ** ^Return the number of columns in the result set returned by the - ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL - ** statement that does not return data (for example an [UPDATE]). - ** - ** See also: [sqlite3_data_count()] - */ - //SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt); - - /* - ** CAPI3REF: Column Names In A Result Set - ** - ** ^These routines return the name assigned to a particular column - ** in the result set of a [SELECT] statement. ^The sqlite3_column_name() - ** interface returns a pointer to a zero-terminated UTF-8 string - ** and sqlite3_column_name16() returns a pointer to a zero-terminated - ** UTF-16 string. ^The first parameter is the [prepared statement] - ** that implements the [SELECT] statement. ^The second parameter is the - ** column number. ^The leftmost column is number 0. - ** - ** ^The returned string pointer is valid until either the [prepared statement] - ** is destroyed by [sqlite3_finalize()] or until the statement is automatically - ** reprepared by the first call to [sqlite3_step()] for a particular run - ** or until the next call to - ** sqlite3_column_name() or sqlite3_column_name16() on the same column. - ** - ** ^If sqlite3_malloc() fails during the processing of either routine - ** (for example during a conversion from UTF-8 to UTF-16) then a - ** NULL pointer is returned. - ** - ** ^The name of a result column is the value of the "AS" clause for - ** that column, if there is an AS clause. If there is no AS clause - ** then the name of the column is unspecified and may change from - ** one release of SQLite to the next. - */ - //SQLITE_API string sqlite3_column_name(sqlite3_stmt*, int N); - //SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N); - - /* - ** CAPI3REF: Source Of Data In A Query Result - ** - ** ^These routines provide a means to determine the database, table, and - ** table column that is the origin of a particular result column in - ** [SELECT] statement. - ** ^The name of the database or table or column can be returned as - ** either a UTF-8 or UTF-16 string. ^The _database_ routines return - ** the database name, the _table_ routines return the table name, and - ** the origin_ routines return the column name. - ** ^The returned string is valid until the [prepared statement] is destroyed - ** using [sqlite3_finalize()] or until the statement is automatically - ** reprepared by the first call to [sqlite3_step()] for a particular run - ** or until the same information is requested - ** again in a different encoding. - ** - ** ^The names returned are the original un-aliased names of the - ** database, table, and column. - ** - ** ^The first argument to these interfaces is a [prepared statement]. - ** ^These functions return information about the Nth result column returned by - ** the statement, where N is the second function argument. - ** ^The left-most column is column 0 for these routines. - ** - ** ^If the Nth column returned by the statement is an expression or - ** subquery and is not a column value, then all of these functions return - ** NULL. ^These routine might also return NULL if a memory allocation error - ** occurs. ^Otherwise, they return the name of the attached database, table, - ** or column that query result column was extracted from. - ** - ** ^As with all other SQLite APIs, those whose names end with "16" return - ** UTF-16 encoded strings and the other functions return UTF-8. - ** - ** ^These APIs are only available if the library was compiled with the - ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol. - ** - ** If two or more threads call one or more of these routines against the same - ** prepared statement and column at the same time then the results are - ** undefined. - ** - ** If two or more threads call one or more - ** [sqlite3_column_database_name | column metadata interfaces] - ** for the same [prepared statement] and result column - ** at the same time then the results are undefined. - */ - //SQLITE_API string sqlite3_column_database_name(sqlite3_stmt*,int); - //SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int); - //SQLITE_API string sqlite3_column_table_name(sqlite3_stmt*,int); - //SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int); - //SQLITE_API string sqlite3_column_origin_name(sqlite3_stmt*,int); - //SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int); - - /* - ** CAPI3REF: Declared Datatype Of A Query Result - ** - ** ^(The first parameter is a [prepared statement]. - ** If this statement is a [SELECT] statement and the Nth column of the - ** returned result set of that [SELECT] is a table column (not an - ** expression or subquery) then the declared type of the table - ** column is returned.)^ ^If the Nth column of the result set is an - ** expression or subquery, then a NULL pointer is returned. - ** ^The returned string is always UTF-8 encoded. - ** - ** ^(For example, given the database schema: - ** - ** CREATE TABLE t1(c1 VARIANT); - ** - ** and the following statement to be compiled: - ** - ** SELECT c1 + 1, c1 FROM t1; - ** - ** this routine would return the string "VARIANT" for the second result - ** column (i==1), and a NULL pointer for the first result column (i==0).)^ - ** - ** ^SQLite uses dynamic run-time typing. ^So just because a column - ** is declared to contain a particular type does not mean that the - ** data stored in that column is of the declared type. SQLite is - ** strongly typed, but the typing is dynamic not static. ^Type - ** is associated with individual values, not with the containers - ** used to hold those values. - */ - //SQLITE_API string sqlite3_column_decltype(sqlite3_stmt*,int); - //SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int); - - /* - ** CAPI3REF: Evaluate An SQL Statement - ** - ** After a [prepared statement] has been prepared using either - ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy - ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function - ** must be called one or more times to evaluate the statement. - ** - ** The details of the behavior of the sqlite3_step() interface depend - ** on whether the statement was prepared using the newer "v2" interface - ** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy - ** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the - ** new "v2" interface is recommended for new applications but the legacy - ** interface will continue to be supported. - ** - ** ^In the legacy interface, the return value will be either [SQLITE_BUSY], - ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE]. - ** ^With the "v2" interface, any of the other [result codes] or - ** [extended result codes] might be returned as well. - ** - ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the - ** database locks it needs to do its job. ^If the statement is a [COMMIT] - ** or occurs outside of an explicit transaction, then you can retry the - ** statement. If the statement is not a [COMMIT] and occurs within an - ** explicit transaction then you should rollback the transaction before - ** continuing. - ** - ** ^[SQLITE_DONE] means that the statement has finished executing - ** successfully. sqlite3_step() should not be called again on this virtual - ** machine without first calling [sqlite3_reset()] to reset the virtual - ** machine back to its initial state. - ** - ** ^If the SQL statement being executed returns any data, then [SQLITE_ROW] - ** is returned each time a new row of data is ready for processing by the - ** caller. The values may be accessed using the [column access functions]. - ** sqlite3_step() is called again to retrieve the next row of data. - ** - ** ^[SQLITE_ERROR] means that a run-time error (such as a constraint - ** violation) has occurred. sqlite3_step() should not be called again on - ** the VM. More information may be found by calling [sqlite3_errmsg()]. - ** ^With the legacy interface, a more specific error code (for example, - ** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth) - ** can be obtained by calling [sqlite3_reset()] on the - ** [prepared statement]. ^In the "v2" interface, - ** the more specific error code is returned directly by sqlite3_step(). - ** - ** [SQLITE_MISUSE] means that the this routine was called inappropriately. - ** Perhaps it was called on a [prepared statement] that has - ** already been [sqlite3_finalize | finalized] or on one that had - ** previously returned [SQLITE_ERROR] or [SQLITE_DONE]. Or it could - ** be the case that the same database connection is being used by two or - ** more threads at the same moment in time. - ** - ** For all versions of SQLite up to and including 3.6.23.1, a call to - ** [sqlite3_reset()] was required after sqlite3_step() returned anything - ** other than [SQLITE_ROW] before any subsequent invocation of - ** sqlite3_step(). Failure to reset the prepared statement using - ** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from - ** sqlite3_step(). But after version 3.6.23.1, sqlite3_step() began - ** calling [sqlite3_reset()] automatically in this circumstance rather - ** than returning [SQLITE_MISUSE]. This is not considered a compatibility - ** break because any application that ever receives an SQLITE_MISUSE error - ** is broken by definition. The [SQLITE_OMIT_AUTORESET] compile-time option - ** can be used to restore the legacy behavior. - ** - ** Goofy Interface Alert: In the legacy interface, the sqlite3_step() - ** API always returns a generic error code, [SQLITE_ERROR], following any - ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call - ** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the - ** specific [error codes] that better describes the error. - ** We admit that this is a goofy design. The problem has been fixed - ** with the "v2" interface. If you prepare all of your SQL statements - ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead - ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces, - ** then the more specific [error codes] are returned directly - ** by sqlite3_step(). The use of the "v2" interface is recommended. - */ - //SQLITE_API int sqlite3_step(sqlite3_stmt); - - /* - ** CAPI3REF: Number of columns in a result set - ** - ** ^The sqlite3_data_count(P) interface returns the number of columns in the - ** current row of the result set of [prepared statement] P. - ** ^If prepared statement P does not have results ready to return - ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of - ** interfaces) then sqlite3_data_count(P) returns 0. - ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer. - ** - ** See also: [sqlite3_column_count()] - */ - //SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); - - /* - ** CAPI3REF: Fundamental Datatypes - ** KEYWORDS: SQLITE_TEXT - ** - ** ^(Every value in SQLite has one of five fundamental datatypes: - ** - **
    - **
  • 64-bit signed integer - **
  • 64-bit IEEE floating point number - **
  • string - **
  • BLOB - **
  • NULL - **
)^ - ** - ** These constants are codes for each of those types. - ** - ** Note that the SQLITE_TEXT constant was also used in SQLite version 2 - ** for a completely different meaning. Software that links against both - ** SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, not - ** SQLITE_TEXT. - */ - //#define SQLITE_INTEGER 1 - //#define SQLITE_FLOAT 2 - //#define SQLITE_BLOB 4 - //#define SQLITE_NULL 5 - //#if SQLITE_TEXT - //# undef SQLITE_TEXT - //#else - //# define SQLITE_TEXT 3 - //#endif - //#define SQLITE3_TEXT 3 - public const u8 SQLITE_INTEGER = 1; - public const u8 SQLITE_FLOAT = 2; - public const u8 SQLITE_BLOB = 4; - public const u8 SQLITE_NULL = 5; - public const u8 SQLITE_TEXT = 3; - public const u8 SQLITE3_TEXT = 3; - - /* - ** CAPI3REF: Result Values From A Query - ** KEYWORDS: {column access functions} - ** - ** These routines form the "result set" interface. - ** - ** ^These routines return information about a single column of the current - ** result row of a query. ^In every case the first argument is a pointer - ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*] - ** that was returned from [sqlite3_prepare_v2()] or one of its variants) - ** and the second argument is the index of the column for which information - ** should be returned. ^The leftmost column of the result set has the index 0. - ** ^The number of columns in the result can be determined using - ** [sqlite3_column_count()]. - ** - ** If the SQL statement does not currently point to a valid row, or if the - ** column index is out of range, the result is undefined. - ** These routines may only be called when the most recent call to - ** [sqlite3_step()] has returned [SQLITE_ROW] and neither - ** [sqlite3_reset()] nor [sqlite3_finalize()] have been called subsequently. - ** If any of these routines are called after [sqlite3_reset()] or - ** [sqlite3_finalize()] or after [sqlite3_step()] has returned - ** something other than [SQLITE_ROW], the results are undefined. - ** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()] - ** are called from a different thread while any of these routines - ** are pending, then the results are undefined. - ** - ** ^The sqlite3_column_type() routine returns the - ** [SQLITE_INTEGER | datatype code] for the initial data type - ** of the result column. ^The returned value is one of [SQLITE_INTEGER], - ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value - ** returned by sqlite3_column_type() is only meaningful if no type - ** conversions have occurred as described below. After a type conversion, - ** the value returned by sqlite3_column_type() is undefined. Future - ** versions of SQLite may change the behavior of sqlite3_column_type() - ** following a type conversion. - ** - ** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes() - ** routine returns the number of bytes in that BLOB or string. - ** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts - ** the string to UTF-8 and then returns the number of bytes. - ** ^If the result is a numeric value then sqlite3_column_bytes() uses - ** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns - ** the number of bytes in that string. - ** ^If the result is NULL, then sqlite3_column_bytes() returns zero. - ** - ** ^If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16() - ** routine returns the number of bytes in that BLOB or string. - ** ^If the result is a UTF-8 string, then sqlite3_column_bytes16() converts - ** the string to UTF-16 and then returns the number of bytes. - ** ^If the result is a numeric value then sqlite3_column_bytes16() uses - ** [sqlite3_snprintf()] to convert that value to a UTF-16 string and returns - ** the number of bytes in that string. - ** ^If the result is NULL, then sqlite3_column_bytes16() returns zero. - ** - ** ^The values returned by [sqlite3_column_bytes()] and - ** [sqlite3_column_bytes16()] do not include the zero terminators at the end - ** of the string. ^For clarity: the values returned by - ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of - ** bytes in the string, not the number of characters. - ** - ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(), - ** even empty strings, are always zero terminated. ^The return - ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer. - ** - ** ^The object returned by [sqlite3_column_value()] is an - ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object - ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()]. - ** If the [unprotected sqlite3_value] object returned by - ** [sqlite3_column_value()] is used in any other way, including calls - ** to routines like [sqlite3_value_int()], [sqlite3_value_text()], - ** or [sqlite3_value_bytes()], then the behavior is undefined. - ** - ** These routines attempt to convert the value where appropriate. ^For - ** example, if the internal representation is FLOAT and a text result - ** is requested, [sqlite3_snprintf()] is used internally to perform the - ** conversion automatically. ^(The following table details the conversions - ** that are applied: - ** - **
- ** - **
Internal
Type
Requested
Type
Conversion - ** - **
NULL INTEGER Result is 0 - **
NULL FLOAT Result is 0.0 - **
NULL TEXT Result is NULL pointer - **
NULL BLOB Result is NULL pointer - **
INTEGER FLOAT Convert from integer to float - **
INTEGER TEXT ASCII rendering of the integer - **
INTEGER BLOB Same as INTEGER->TEXT - **
FLOAT INTEGER Convert from float to integer - **
FLOAT TEXT ASCII rendering of the float - **
FLOAT BLOB Same as FLOAT->TEXT - **
TEXT INTEGER Use atoi() - **
TEXT FLOAT Use atof() - **
TEXT BLOB No change - **
BLOB INTEGER Convert to TEXT then use atoi() - **
BLOB FLOAT Convert to TEXT then use atof() - **
BLOB TEXT Add a zero terminator if needed - **
- **
)^ - ** - ** The table above makes reference to standard C library functions atoi() - ** and atof(). SQLite does not really use these functions. It has its - ** own equivalent internal routines. The atoi() and atof() names are - ** used in the table for brevity and because they are familiar to most - ** C programmers. - ** - ** Note that when type conversions occur, pointers returned by prior - ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or - ** sqlite3_column_text16() may be invalidated. - ** Type conversions and pointer invalidations might occur - ** in the following cases: - ** - **
    - **
  • The initial content is a BLOB and sqlite3_column_text() or - ** sqlite3_column_text16() is called. A zero-terminator might - ** need to be added to the string.
  • - **
  • The initial content is UTF-8 text and sqlite3_column_bytes16() or - ** sqlite3_column_text16() is called. The content must be converted - ** to UTF-16.
  • - **
  • The initial content is UTF-16 text and sqlite3_column_bytes() or - ** sqlite3_column_text() is called. The content must be converted - ** to UTF-8.
  • - **
- ** - ** ^Conversions between UTF-16be and UTF-16le are always done in place and do - ** not invalidate a prior pointer, though of course the content of the buffer - ** that the prior pointer references will have been modified. Other kinds - ** of conversion are done in place when it is possible, but sometimes they - ** are not possible and in those cases prior pointers are invalidated. - ** - ** The safest and easiest to remember policy is to invoke these routines - ** in one of the following ways: - ** - **
    - **
  • sqlite3_column_text() followed by sqlite3_column_bytes()
  • - **
  • sqlite3_column_blob() followed by sqlite3_column_bytes()
  • - **
  • sqlite3_column_text16() followed by sqlite3_column_bytes16()
  • - **
- ** - ** In other words, you should call sqlite3_column_text(), - ** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result - ** into the desired format, then invoke sqlite3_column_bytes() or - ** sqlite3_column_bytes16() to find the size of the result. Do not mix calls - ** to sqlite3_column_text() or sqlite3_column_blob() with calls to - ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16() - ** with calls to sqlite3_column_bytes(). - ** - ** ^The pointers returned are valid until a type conversion occurs as - ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or - ** [sqlite3_finalize()] is called. ^The memory space used to hold strings - ** and BLOBs is freed automatically. Do not pass the pointers returned - ** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into - ** [sqlite3_free()]. - ** - ** ^(If a memory allocation error occurs during the evaluation of any - ** of these routines, a default value is returned. The default value - ** is either the integer 0, the floating point number 0.0, or a NULL - ** pointer. Subsequent calls to [sqlite3_errcode()] will return - ** [SQLITE_NOMEM].)^ - */ - //SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); - //SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol); - //SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol); - //SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol); - //SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol); - //SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol); - //SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol); - //SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol); - //SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol); - //SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol); - - /* - ** CAPI3REF: Destroy A Prepared Statement Object - ** - ** ^The sqlite3_finalize() function is called to delete a [prepared statement]. - ** ^If the most recent evaluation of the statement encountered no errors - ** or if the statement is never been evaluated, then sqlite3_finalize() returns - ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then - ** sqlite3_finalize(S) returns the appropriate [error code] or - ** [extended error code]. - ** - ** ^The sqlite3_finalize(S) routine can be called at any point during - ** the life cycle of [prepared statement] S: - ** before statement S is ever evaluated, after - ** one or more calls to [sqlite3_reset()], or after any call - ** to [sqlite3_step()] regardless of whether or not the statement has - ** completed execution. - ** - ** ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op. - ** - ** The application must finalize every [prepared statement] in order to avoid - ** resource leaks. It is a grievous error for the application to try to use - ** a prepared statement after it has been finalized. Any use of a prepared - ** statement after it has been finalized can result in undefined and - ** undesirable behavior such as segfaults and heap corruption. - */ - //SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt); - - /* - ** CAPI3REF: Reset A Prepared Statement Object - ** - ** The sqlite3_reset() function is called to reset a [prepared statement] - ** object back to its initial state, ready to be re-executed. - ** ^Any SQL statement variables that had values bound to them using - ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values. - ** Use [sqlite3_clear_bindings()] to reset the bindings. - ** - ** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S - ** back to the beginning of its program. - ** - ** ^If the most recent call to [sqlite3_step(S)] for the - ** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE], - ** or if [sqlite3_step(S)] has never before been called on S, - ** then [sqlite3_reset(S)] returns [SQLITE_OK]. - ** - ** ^If the most recent call to [sqlite3_step(S)] for the - ** [prepared statement] S indicated an error, then - ** [sqlite3_reset(S)] returns an appropriate [error code]. - ** - ** ^The [sqlite3_reset(S)] interface does not change the values - ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. - */ - //SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); - - /* - ** CAPI3REF: Create Or Redefine SQL Functions - ** KEYWORDS: {function creation routines} - ** KEYWORDS: {application-defined SQL function} - ** KEYWORDS: {application-defined SQL functions} - ** - ** ^These functions (collectively known as "function creation routines") - ** are used to add SQL functions or aggregates or to redefine the behavior - ** of existing SQL functions or aggregates. The only differences between - ** these routines are the text encoding expected for - ** the second parameter (the name of the function being created) - ** and the presence or absence of a destructor callback for - ** the application data pointer. - ** - ** ^The first parameter is the [database connection] to which the SQL - ** function is to be added. ^If an application uses more than one database - ** connection then application-defined SQL functions must be added - ** to each database connection separately. - ** - ** ^The second parameter is the name of the SQL function to be created or - ** redefined. ^The length of the name is limited to 255 bytes in a UTF-8 - ** representation, exclusive of the zero-terminator. ^Note that the name - ** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes. - ** ^Any attempt to create a function with a longer name - ** will result in [SQLITE_MISUSE] being returned. - ** - ** ^The third parameter (nArg) - ** is the number of arguments that the SQL function or - ** aggregate takes. ^If this parameter is -1, then the SQL function or - ** aggregate may take any number of arguments between 0 and the limit - ** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]). If the third - ** parameter is less than -1 or greater than 127 then the behavior is - ** undefined. - ** - ** ^The fourth parameter, eTextRep, specifies what - ** [SQLITE_UTF8 | text encoding] this SQL function prefers for - ** its parameters. Every SQL function implementation must be able to work - ** with UTF-8, UTF-16le, or UTF-16be. But some implementations may be - ** more efficient with one encoding than another. ^An application may - ** invoke sqlite3_create_function() or sqlite3_create_function16() multiple - ** times with the same function but with different values of eTextRep. - ** ^When multiple implementations of the same function are available, SQLite - ** will pick the one that involves the least amount of data conversion. - ** If there is only a single implementation which does not care what text - ** encoding is used, then the fourth argument should be [SQLITE_ANY]. - ** - ** ^(The fifth parameter is an arbitrary pointer. The implementation of the - ** function can gain access to this pointer using [sqlite3_user_data()].)^ - ** - ** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are - ** pointers to C-language functions that implement the SQL function or - ** aggregate. ^A scalar SQL function requires an implementation of the xFunc - ** callback only; NULL pointers must be passed as the xStep and xFinal - ** parameters. ^An aggregate SQL function requires an implementation of xStep - ** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing - ** SQL function or aggregate, pass NULL pointers for all three function - ** callbacks. - ** - ** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL, - ** then it is destructor for the application data pointer. - ** The destructor is invoked when the function is deleted, either by being - ** overloaded or when the database connection closes.)^ - ** ^The destructor is also invoked if the call to - ** sqlite3_create_function_v2() fails. - ** ^When the destructor callback of the tenth parameter is invoked, it - ** is passed a single argument which is a copy of the application data - ** pointer which was the fifth parameter to sqlite3_create_function_v2(). - ** - ** ^It is permitted to register multiple implementations of the same - ** functions with the same name but with either differing numbers of - ** arguments or differing preferred text encodings. ^SQLite will use - ** the implementation that most closely matches the way in which the - ** SQL function is used. ^A function implementation with a non-negative - ** nArg parameter is a better match than a function implementation with - ** a negative nArg. ^A function where the preferred text encoding - ** matches the database encoding is a better - ** match than a function where the encoding is different. - ** ^A function where the encoding difference is between UTF16le and UTF16be - ** is a closer match than a function where the encoding difference is - ** between UTF8 and UTF16. - ** - ** ^Built-in functions may be overloaded by new application-defined functions. - ** - ** ^An application-defined function is permitted to call other - ** SQLite interfaces. However, such calls must not - ** close the database connection nor finalize or reset the prepared - ** statement in which the function is running. - */ - //SQLITE_API int sqlite3_create_function( - // sqlite3 db, - // string zFunctionName, - // int nArg, - // int eTextRep, - // void *pApp, - // void (*xFunc)(sqlite3_context*,int,sqlite3_value*), - // void (*xStep)(sqlite3_context*,int,sqlite3_value*), - // void (*xFinal)(sqlite3_context) - //); - //SQLITE_API int sqlite3_create_function16( - // sqlite3 db, - // string zFunctionName, - // int nArg, - // int eTextRep, - // void *pApp, - // void (*xFunc)(sqlite3_context*,int,sqlite3_value*), - // void (*xStep)(sqlite3_context*,int,sqlite3_value*), - // void (*xFinal)(sqlite3_context) - //); - //SQLITE_API int sqlite3_create_function_v2( - // sqlite3 db, - // string zFunctionName, - // int nArg, - // int eTextRep, - // void *pApp, - // void (*xFunc)(sqlite3_context*,int,sqlite3_value*), - // void (*xStep)(sqlite3_context*,int,sqlite3_value*), - // void (*xFinal)(sqlite3_context), - // void(*xDestroy)(void) - //); - - /* - ** CAPI3REF: Text Encodings - ** - ** These constant define integer codes that represent the various - ** text encodings supported by SQLite. - */ - //#define SQLITE_UTF8 1 - //#define SQLITE_UTF16LE 2 - //#define SQLITE_UTF16BE 3 - //#define SQLITE_UTF16 4 /* Use native byte order */ - //#define SQLITE_ANY 5 /* sqlite3_create_function only */ - //#define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */ - public const u8 SQLITE_UTF8 = 1; - public const u8 SQLITE_UTF16LE = 2; - public const u8 SQLITE_UTF16BE = 3; - public const u8 SQLITE_UTF16 = 4; - public const u8 SQLITE_ANY = 5; - public const u8 SQLITE_UTF16_ALIGNED = 8; - - - /* - ** CAPI3REF: Deprecated Functions - ** DEPRECATED - ** - ** These functions are [deprecated]. In order to maintain - ** backwards compatibility with older code, these functions continue - ** to be supported. However, new applications should avoid - ** the use of these functions. To help encourage people to avoid - ** using these functions, we are not going to tell you what they do. - */ - //#if !SQLITE_OMIT_DEPRECATED - //SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context); - //SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt); - //SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt); - //SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void); - //SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); - //SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void()(void*,sqlite3_int64,int),void*,sqlite3_int64); - //#endif - - /* - ** CAPI3REF: Obtaining SQL Function Parameter Values - ** - ** The C-language implementation of SQL functions and aggregates uses - ** this set of interface routines to access the parameter values on - ** the function or aggregate. - ** - ** The xFunc (for scalar functions) or xStep (for aggregates) parameters - ** to [sqlite3_create_function()] and [sqlite3_create_function16()] - ** define callbacks that implement the SQL functions and aggregates. - ** The 3rd parameter to these callbacks is an array of pointers to - ** [protected sqlite3_value] objects. There is one [sqlite3_value] object for - ** each parameter to the SQL function. These routines are used to - ** extract values from the [sqlite3_value] objects. - ** - ** These routines work only with [protected sqlite3_value] objects. - ** Any attempt to use these routines on an [unprotected sqlite3_value] - ** object results in undefined behavior. - ** - ** ^These routines work just like the corresponding [column access functions] - ** except that these routines take a single [protected sqlite3_value] object - ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number. - ** - ** ^The sqlite3_value_text16() interface extracts a UTF-16 string - ** in the native byte-order of the host machine. ^The - ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces - ** extract UTF-16 strings as big-endian and little-endian respectively. - ** - ** ^(The sqlite3_value_numeric_type() interface attempts to apply - ** numeric affinity to the value. This means that an attempt is - ** made to convert the value to an integer or floating point. If - ** such a conversion is possible without loss of information (in other - ** words, if the value is a string that looks like a number) - ** then the conversion is performed. Otherwise no conversion occurs. - ** The [SQLITE_INTEGER | datatype] after conversion is returned.)^ - ** - ** Please pay particular attention to the fact that the pointer returned - ** from [sqlite3_value_blob()], [sqlite3_value_text()], or - ** [sqlite3_value_text16()] can be invalidated by a subsequent call to - ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()], - ** or [sqlite3_value_text16()]. - ** - ** These routines must be called from the same thread as - ** the SQL function that supplied the [sqlite3_value*] parameters. - */ - //SQLITE_API const void *sqlite3_value_blob(sqlite3_value); - //SQLITE_API int sqlite3_value_bytes(sqlite3_value); - //SQLITE_API int sqlite3_value_bytes16(sqlite3_value); - //SQLITE_API double sqlite3_value_double(sqlite3_value); - //SQLITE_API int sqlite3_value_int(sqlite3_value); - //SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value); - //SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value); - //SQLITE_API const void *sqlite3_value_text16(sqlite3_value); - //SQLITE_API const void *sqlite3_value_text16le(sqlite3_value); - //SQLITE_API const void *sqlite3_value_text16be(sqlite3_value); - //SQLITE_API int sqlite3_value_type(sqlite3_value); - //SQLITE_API int sqlite3_value_numeric_type(sqlite3_value); - - /* - ** CAPI3REF: Obtain Aggregate Function Context - ** - ** Implementations of aggregate SQL functions use this - ** routine to allocate memory for storing their state. - ** - ** ^The first time the sqlite3_aggregate_context(C,N) routine is called - ** for a particular aggregate function, SQLite - ** allocates N of memory, zeroes out that memory, and returns a pointer - ** to the new memory. ^On second and subsequent calls to - ** sqlite3_aggregate_context() for the same aggregate function instance, - ** the same buffer is returned. Sqlite3_aggregate_context() is normally - ** called once for each invocation of the xStep callback and then one - ** last time when the xFinal callback is invoked. ^(When no rows match - ** an aggregate query, the xStep() callback of the aggregate function - ** implementation is never called and xFinal() is called exactly once. - ** In those cases, sqlite3_aggregate_context() might be called for the - ** first time from within xFinal().)^ - ** - ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is - ** less than or equal to zero or if a memory allocate error occurs. - ** - ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is - ** determined by the N parameter on first successful call. Changing the - ** value of N in subsequent call to sqlite3_aggregate_context() within - ** the same aggregate function instance will not resize the memory - ** allocation.)^ - ** - ** ^SQLite automatically frees the memory allocated by - ** sqlite3_aggregate_context() when the aggregate query concludes. - ** - ** The first parameter must be a copy of the - ** [sqlite3_context | SQL function context] that is the first parameter - ** to the xStep or xFinal callback routine that implements the aggregate - ** function. - ** - ** This routine must be called from the same thread in which - ** the aggregate SQL function is running. - */ - //SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes); - - /* - ** CAPI3REF: User Data For Functions - ** - ** ^The sqlite3_user_data() interface returns a copy of - ** the pointer that was the pUserData parameter (the 5th parameter) - ** of the [sqlite3_create_function()] - ** and [sqlite3_create_function16()] routines that originally - ** registered the application defined function. - ** - ** This routine must be called from the same thread in which - ** the application-defined function is running. - */ - //SQLITE_API void *sqlite3_user_data(sqlite3_context); - - /* - ** CAPI3REF: Database Connection For Functions - ** - ** ^The sqlite3_context_db_handle() interface returns a copy of - ** the pointer to the [database connection] (the 1st parameter) - ** of the [sqlite3_create_function()] - ** and [sqlite3_create_function16()] routines that originally - ** registered the application defined function. - */ - //SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context); - - /* - ** CAPI3REF: Function Auxiliary Data - ** - ** The following two functions may be used by scalar SQL functions to - ** associate metadata with argument values. If the same value is passed to - ** multiple invocations of the same SQL function during query execution, under - ** some circumstances the associated metadata may be preserved. This may - ** be used, for example, to add a regular-expression matching scalar - ** function. The compiled version of the regular expression is stored as - ** metadata associated with the SQL value passed as the regular expression - ** pattern. The compiled regular expression can be reused on multiple - ** invocations of the same function so that the original pattern string - ** does not need to be recompiled on each invocation. - ** - ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata - ** associated by the sqlite3_set_auxdata() function with the Nth argument - ** value to the application-defined function. ^If no metadata has been ever - ** been set for the Nth argument of the function, or if the corresponding - ** function parameter has changed since the meta-data was set, - ** then sqlite3_get_auxdata() returns a NULL pointer. - ** - ** ^The sqlite3_set_auxdata() interface saves the metadata - ** pointed to by its 3rd parameter as the metadata for the N-th - ** argument of the application-defined function. Subsequent - ** calls to sqlite3_get_auxdata() might return this data, if it has - ** not been destroyed. - ** ^If it is not NULL, SQLite will invoke the destructor - ** function given by the 4th parameter to sqlite3_set_auxdata() on - ** the metadata when the corresponding function parameter changes - ** or when the SQL statement completes, whichever comes first. - ** - ** SQLite is free to call the destructor and drop metadata on any - ** parameter of any function at any time. ^The only guarantee is that - ** the destructor will be called before the metadata is dropped. - ** - ** ^(In practice, metadata is preserved between function calls for - ** expressions that are constant at compile time. This includes literal - ** values and [parameters].)^ - ** - ** These routines must be called from the same thread in which - ** the SQL function is running. - */ - //SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); - //SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, object ()(void)); - - - /* - ** CAPI3REF: Constants Defining Special Destructor Behavior - ** - ** These are special values for the destructor that is passed in as the - ** final argument to routines like [sqlite3_result_blob()]. ^If the destructor - ** argument is SQLITE_STATIC, it means that the content pointer is constant - ** and will never change. It does not need to be destroyed. ^The - ** SQLITE_TRANSIENT value means that the content will likely change in - ** the near future and that SQLite should make its own private copy of - ** the content before returning. - ** - ** The typedef is necessary to work around problems in certain - ** C++ compilers. See ticket #2191. - */ - //typedef void (*sqlite3_destructor_type)(void); - //#define SQLITE_STATIC ((sqlite3_destructor_type)0) - //#define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1) - static public dxDel SQLITE_STATIC; - static public dxDel SQLITE_TRANSIENT; - /* - ** CAPI3REF: Setting The Result Of An SQL Function - ** - ** These routines are used by the xFunc or xFinal callbacks that - ** implement SQL functions and aggregates. See - ** [sqlite3_create_function()] and [sqlite3_create_function16()] - ** for additional information. - ** - ** These functions work very much like the [parameter binding] family of - ** functions used to bind values to host parameters in prepared statements. - ** Refer to the [SQL parameter] documentation for additional information. - ** - ** ^The sqlite3_result_blob() interface sets the result from - ** an application-defined function to be the BLOB whose content is pointed - ** to by the second parameter and which is N bytes long where N is the - ** third parameter. - ** - ** ^The sqlite3_result_zeroblob() interfaces set the result of - ** the application-defined function to be a BLOB containing all zero - ** bytes and N bytes in size, where N is the value of the 2nd parameter. - ** - ** ^The sqlite3_result_double() interface sets the result from - ** an application-defined function to be a floating point value specified - ** by its 2nd argument. - ** - ** ^The sqlite3_result_error() and sqlite3_result_error16() functions - ** cause the implemented SQL function to throw an exception. - ** ^SQLite uses the string pointed to by the - ** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16() - ** as the text of an error message. ^SQLite interprets the error - ** message string from sqlite3_result_error() as UTF-8. ^SQLite - ** interprets the string from sqlite3_result_error16() as UTF-16 in native - ** byte order. ^If the third parameter to sqlite3_result_error() - ** or sqlite3_result_error16() is negative then SQLite takes as the error - ** message all text up through the first zero character. - ** ^If the third parameter to sqlite3_result_error() or - ** sqlite3_result_error16() is non-negative then SQLite takes that many - ** bytes (not characters) from the 2nd parameter as the error message. - ** ^The sqlite3_result_error() and sqlite3_result_error16() - ** routines make a private copy of the error message text before - ** they return. Hence, the calling function can deallocate or - ** modify the text after they return without harm. - ** ^The sqlite3_result_error_code() function changes the error code - ** returned by SQLite as a result of an error in a function. ^By default, - ** the error code is SQLITE_ERROR. ^A subsequent call to sqlite3_result_error() - ** or sqlite3_result_error16() resets the error code to SQLITE_ERROR. - ** - ** ^The sqlite3_result_toobig() interface causes SQLite to throw an error - ** indicating that a string or BLOB is too long to represent. - ** - ** ^The sqlite3_result_nomem() interface causes SQLite to throw an error - ** indicating that a memory allocation failed. - ** - ** ^The sqlite3_result_int() interface sets the return value - ** of the application-defined function to be the 32-bit signed integer - ** value given in the 2nd argument. - ** ^The sqlite3_result_int64() interface sets the return value - ** of the application-defined function to be the 64-bit signed integer - ** value given in the 2nd argument. - ** - ** ^The sqlite3_result_null() interface sets the return value - ** of the application-defined function to be NULL. - ** - ** ^The sqlite3_result_text(), sqlite3_result_text16(), - ** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces - ** set the return value of the application-defined function to be - ** a text string which is represented as UTF-8, UTF-16 native byte order, - ** UTF-16 little endian, or UTF-16 big endian, respectively. - ** ^SQLite takes the text result from the application from - ** the 2nd parameter of the sqlite3_result_text* interfaces. - ** ^If the 3rd parameter to the sqlite3_result_text* interfaces - ** is negative, then SQLite takes result text from the 2nd parameter - ** through the first zero character. - ** ^If the 3rd parameter to the sqlite3_result_text* interfaces - ** is non-negative, then as many bytes (not characters) of the text - ** pointed to by the 2nd parameter are taken as the application-defined - ** function result. - ** ^If the 4th parameter to the sqlite3_result_text* interfaces - ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that - ** function as the destructor on the text or BLOB result when it has - ** finished using that result. - ** ^If the 4th parameter to the sqlite3_result_text* interfaces or to - ** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite - ** assumes that the text or BLOB result is in constant space and does not - ** copy the content of the parameter nor call a destructor on the content - ** when it has finished using that result. - ** ^If the 4th parameter to the sqlite3_result_text* interfaces - ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT - ** then SQLite makes a copy of the result into space obtained from - ** from [sqlite3_malloc()] before it returns. - ** - ** ^The sqlite3_result_value() interface sets the result of - ** the application-defined function to be a copy the - ** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The - ** sqlite3_result_value() interface makes a copy of the [sqlite3_value] - ** so that the [sqlite3_value] specified in the parameter may change or - ** be deallocated after sqlite3_result_value() returns without harm. - ** ^A [protected sqlite3_value] object may always be used where an - ** [unprotected sqlite3_value] object is required, so either - ** kind of [sqlite3_value] object can be used with this interface. - ** - ** If these routines are called from within the different thread - ** than the one containing the application-defined function that received - ** the [sqlite3_context] pointer, the results are undefined. - */ - //SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void()(void)); - //SQLITE_API void sqlite3_result_double(sqlite3_context*, double); - //SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int); - //SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int); - //SQLITE_API void sqlite3_result_error_toobig(sqlite3_context); - //SQLITE_API void sqlite3_result_error_nomem(sqlite3_context); - //SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int); - //SQLITE_API void sqlite3_result_int(sqlite3_context*, int); - //SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64); - //SQLITE_API void sqlite3_result_null(sqlite3_context); - //SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void()(void)); - //SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void()(void)); - //SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void()(void)); - //SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void()(void)); - //SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value); - //SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); - - /* - ** CAPI3REF: Define New Collating Sequences - ** - ** ^These functions add, remove, or modify a [collation] associated - ** with the [database connection] specified as the first argument. - ** - ** ^The name of the collation is a UTF-8 string - ** for sqlite3_create_collation() and sqlite3_create_collation_v2() - ** and a UTF-16 string in native byte order for sqlite3_create_collation16(). - ** ^Collation names that compare equal according to [sqlite3_strnicmp()] are - ** considered to be the same name. - ** - ** ^(The third argument (eTextRep) must be one of the constants: - **
    - **
  • [SQLITE_UTF8], - **
  • [SQLITE_UTF16LE], - **
  • [SQLITE_UTF16BE], - **
  • [SQLITE_UTF16], or - **
  • [SQLITE_UTF16_ALIGNED]. - **
)^ - ** ^The eTextRep argument determines the encoding of strings passed - ** to the collating function callback, xCallback. - ** ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep - ** force strings to be UTF16 with native byte order. - ** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin - ** on an even byte address. - ** - ** ^The fourth argument, pArg, is an application data pointer that is passed - ** through as the first argument to the collating function callback. - ** - ** ^The fifth argument, xCallback, is a pointer to the collating function. - ** ^Multiple collating functions can be registered using the same name but - ** with different eTextRep parameters and SQLite will use whichever - ** function requires the least amount of data transformation. - ** ^If the xCallback argument is NULL then the collating function is - ** deleted. ^When all collating functions having the same name are deleted, - ** that collation is no longer usable. - ** - ** ^The collating function callback is invoked with a copy of the pArg - ** application data pointer and with two strings in the encoding specified - ** by the eTextRep argument. The collating function must return an - ** integer that is negative, zero, or positive - ** if the first string is less than, equal to, or greater than the second, - ** respectively. A collating function must always return the same answer - ** given the same inputs. If two or more collating functions are registered - ** to the same collation name (using different eTextRep values) then all - ** must give an equivalent answer when invoked with equivalent strings. - ** The collating function must obey the following properties for all - ** strings A, B, and C: - ** - **
    - **
  1. If A==B then B==A. - **
  2. If A==B and B==C then A==C. - **
  3. If A<B THEN B>A. - **
  4. If A<B and B<C then A<C. - **
- ** - ** If a collating function fails any of the above constraints and that - ** collating function is registered and used, then the behavior of SQLite - ** is undefined. - ** - ** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation() - ** with the addition that the xDestroy callback is invoked on pArg when - ** the collating function is deleted. - ** ^Collating functions are deleted when they are overridden by later - ** calls to the collation creation functions or when the - ** [database connection] is closed using [sqlite3_close()]. - ** - ** ^The xDestroy callback is not called if the - ** sqlite3_create_collation_v2() function fails. Applications that invoke - ** sqlite3_create_collation_v2() with a non-NULL xDestroy argument should - ** check the return code and dispose of the application data pointer - ** themselves rather than expecting SQLite to deal with it for them. - ** This is different from every other SQLite interface. The inconsistency - ** is unfortunate but cannot be changed without breaking backwards - ** compatibility. - ** - ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()]. - */ - //SQLITE_API int sqlite3_create_collation( - // sqlite3*, - // string zName, - // int eTextRep, - // void *pArg, - // int(*xCompare)(void*,int,const void*,int,const void) - //); - //SQLITE_API int sqlite3_create_collation_v2( - // sqlite3*, - // string zName, - // int eTextRep, - // void *pArg, - // int(*xCompare)(void*,int,const void*,int,const void), - // void(*xDestroy)(void) - //); - //SQLITE_API int sqlite3_create_collation16( - // sqlite3*, - // string zName, - // int eTextRep, - // void *pArg, - // int(*xCompare)(void*,int,const void*,int,const void) - //); - - /* - ** CAPI3REF: Collation Needed Callbacks - ** - ** ^To avoid having to register all collation sequences before a database - ** can be used, a single callback function may be registered with the - ** [database connection] to be invoked whenever an undefined collation - ** sequence is required. - ** - ** ^If the function is registered using the sqlite3_collation_needed() API, - ** then it is passed the names of undefined collation sequences as strings - ** encoded in UTF-8. ^If sqlite3_collation_needed16() is used, - ** the names are passed as UTF-16 in machine native byte order. - ** ^A call to either function replaces the existing collation-needed callback. - ** - ** ^(When the callback is invoked, the first argument passed is a copy - ** of the second argument to sqlite3_collation_needed() or - ** sqlite3_collation_needed16(). The second argument is the database - ** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE], - ** or [SQLITE_UTF16LE], indicating the most desirable form of the collation - ** sequence function required. The fourth parameter is the name of the - ** required collation sequence.)^ - ** - ** The callback function should register the desired collation using - ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or - ** [sqlite3_create_collation_v2()]. - */ - //SQLITE_API int sqlite3_collation_needed( - // sqlite3*, - // void*, - // void()(void*,sqlite3*,int eTextRep,const char) - //); - //SQLITE_API int sqlite3_collation_needed16( - // sqlite3*, - // void*, - // void()(void*,sqlite3*,int eTextRep,const void) - //); - - //#if SQLITE_HAS_CODEC - /* - ** Specify the key for an encrypted database. This routine should be - ** called right after sqlite3_open(). - ** - ** The code to implement this API is not available in the public release - ** of SQLite. - */ - //SQLITE_API int sqlite3_key( - // sqlite3 db, /* Database to be rekeyed */ - // const void *pKey, int nKey /* The key */ - //); - - /* - ** Change the key on an open database. If the current database is not - ** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the - ** database is decrypted. - ** - ** The code to implement this API is not available in the public release - ** of SQLite. - */ - //SQLITE_API int sqlite3_rekey( - // sqlite3 db, /* Database to be rekeyed */ - // const void *pKey, int nKey /* The new key */ - //); - - /* - ** Specify the activation key for a SEE database. Unless - ** activated, none of the SEE routines will work. - */ - //SQLITE_API void sqlite3_activate_see( - // string zPassPhrase /* Activation phrase */ - //); - //#endif - - //#if SQLITE_ENABLE_CEROD - /* - ** Specify the activation key for a CEROD database. Unless - ** activated, none of the CEROD routines will work. - */ - //SQLITE_API void sqlite3_activate_cerod( - // string zPassPhrase /* Activation phrase */ - //); - //#endif - - /* - ** CAPI3REF: Suspend Execution For A Short Time - ** - ** The sqlite3_sleep() function causes the current thread to suspend execution - ** for at least a number of milliseconds specified in its parameter. - ** - ** If the operating system does not support sleep requests with - ** millisecond time resolution, then the time will be rounded up to - ** the nearest second. The number of milliseconds of sleep actually - ** requested from the operating system is returned. - ** - ** ^SQLite implements this interface by calling the xSleep() - ** method of the default [sqlite3_vfs] object. If the xSleep() method - ** of the default VFS is not implemented correctly, or not implemented at - ** all, then the behavior of sqlite3_sleep() may deviate from the description - ** in the previous paragraphs. - */ - //SQLITE_API int sqlite3_sleep(int); - - /* - ** CAPI3REF: Name Of The Folder Holding Temporary Files - ** - ** ^(If this global variable is made to point to a string which is - ** the name of a folder (a.k.a. directory), then all temporary files - ** created by SQLite when using a built-in [sqlite3_vfs | VFS] - ** will be placed in that directory.)^ ^If this variable - ** is a NULL pointer, then SQLite performs a search for an appropriate - ** temporary file directory. - ** - ** It is not safe to read or modify this variable in more than one - ** thread at a time. It is not safe to read or modify this variable - ** if a [database connection] is being used at the same time in a separate - ** thread. - ** It is intended that this variable be set once - ** as part of process initialization and before any SQLite interface - ** routines have been called and that this variable remain unchanged - ** thereafter. - ** - ** ^The [temp_store_directory pragma] may modify this variable and cause - ** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, - ** the [temp_store_directory pragma] always assumes that any string - ** that this variable points to is held in memory obtained from - ** [sqlite3_malloc] and the pragma may attempt to free that memory - ** using [sqlite3_free]. - ** Hence, if this variable is modified directly, either it should be - ** made NULL or made to point to memory obtained from [sqlite3_malloc] - ** or else the use of the [temp_store_directory pragma] should be avoided. - */ - //SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory; - - /* - ** CAPI3REF: Test For Auto-Commit Mode - ** KEYWORDS: {autocommit mode} - ** - ** ^The sqlite3_get_autocommit() interface returns non-zero or - ** zero if the given database connection is or is not in autocommit mode, - ** respectively. ^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 certain kinds of errors occur on a statement within a multi-statement - ** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR], - ** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the - ** transaction might be rolled back automatically. The only way to - ** find out whether SQLite automatically rolled back the transaction after - ** an error is to use this function. - ** - ** If another thread changes the autocommit status of the database - ** connection while this routine is running, then the return value - ** is undefined. - */ - //SQLITE_API int sqlite3_get_autocommit(sqlite3); - - /* - ** CAPI3REF: Find The Database Handle Of A Prepared Statement - ** - ** ^The sqlite3_db_handle interface returns the [database connection] handle - ** to which a [prepared statement] belongs. ^The [database connection] - ** returned by sqlite3_db_handle is the same [database connection] - ** that was the first argument - ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to - ** create the statement in the first place. - */ - //SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt); - - /* - ** CAPI3REF: Find the next prepared statement - ** - ** ^This interface returns a pointer to the next [prepared statement] after - ** pStmt associated with the [database connection] pDb. ^If pStmt is NULL - ** then this interface returns a pointer to the first prepared statement - ** associated with the database connection pDb. ^If no prepared statement - ** satisfies the conditions of this routine, it returns NULL. - ** - ** The [database connection] pointer D in a call to - ** [sqlite3_next_stmt(D,S)] must refer to an open database - ** connection and in particular must not be a NULL pointer. - */ - //SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); - - /* - ** CAPI3REF: Commit And Rollback Notification Callbacks - ** - ** ^The sqlite3_commit_hook() interface registers a callback - ** function to be invoked whenever a transaction is [COMMIT | committed]. - ** ^Any callback set by a previous call to sqlite3_commit_hook() - ** for the same database connection is overridden. - ** ^The sqlite3_rollback_hook() interface registers a callback - ** function to be invoked whenever a transaction is [ROLLBACK | rolled back]. - ** ^Any callback set by a previous call to sqlite3_rollback_hook() - ** for the same database connection is overridden. - ** ^The pArg argument is passed through to the callback. - ** ^If the callback on a commit hook function returns non-zero, - ** then the commit is converted into a rollback. - ** - ** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions - ** return the P argument from the previous call of the same function - ** on the same [database connection] D, or NULL for - ** the first call for each function on D. - ** - ** The callback implementation must not do anything that will modify - ** the database connection that invoked the callback. Any actions - ** to modify the database connection must be deferred until after the - ** completion of the [sqlite3_step()] call that triggered the commit - ** or rollback hook in the first place. - ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their - ** database connections for the meaning of "modify" in this paragraph. - ** - ** ^Registering a NULL function disables the callback. - ** - ** ^When the commit hook callback routine returns zero, the [COMMIT] - ** operation is allowed to continue normally. ^If the commit hook - ** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK]. - ** ^The rollback hook is invoked on a rollback that results from a commit - ** hook returning non-zero, just as it would be with any other rollback. - ** - ** ^For the purposes of this API, a transaction is said to have been - ** rolled back if an explicit "ROLLBACK" statement is executed, or - ** an error or constraint causes an implicit rollback to occur. - ** ^The rollback callback is not invoked if a transaction is - ** automatically rolled back because the database connection is closed. - ** - ** See also the [sqlite3_update_hook()] interface. - */ - //SQLITE_API void *sqlite3_commit_hook(sqlite3*, int()(void), void); - //SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void()(void ), void); - - /* - ** CAPI3REF: Data Change Notification Callbacks - ** - ** ^The sqlite3_update_hook() interface registers a callback function - ** with the [database connection] identified by the first argument - ** to be invoked whenever a row is updated, inserted or deleted. - ** ^Any callback set by a previous call to this function - ** for the same database connection is overridden. - ** - ** ^The second argument is a pointer to the function to invoke when a - ** row is updated, inserted or deleted. - ** ^The first argument to the callback is a copy of the third argument - ** to sqlite3_update_hook(). - ** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE], - ** or [SQLITE_UPDATE], depending on the operation that caused the callback - ** to be invoked. - ** ^The third and fourth arguments to the callback contain pointers to the - ** database and table name containing the affected row. - ** ^The final callback parameter is the [rowid] of the row. - ** ^In the case of an update, this is the [rowid] after the update takes place. - ** - ** ^(The update hook is not invoked when internal system tables are - ** modified (i.e. sqlite_master and sqlite_sequence).)^ - ** - ** ^In the current implementation, the update hook - ** is not invoked when duplication rows are deleted because of an - ** [ON CONFLICT | ON CONFLICT REPLACE] clause. ^Nor is the update hook - ** invoked when rows are deleted using the [truncate optimization]. - ** The exceptions defined in this paragraph might change in a future - ** release of SQLite. - ** - ** The update hook implementation must not do anything that will modify - ** the database connection that invoked the update hook. Any actions - ** to modify the database connection must be deferred until after the - ** completion of the [sqlite3_step()] call that triggered the update hook. - ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their - ** database connections for the meaning of "modify" in this paragraph. - ** - ** ^The sqlite3_update_hook(D,C,P) function - ** returns the P argument from the previous call - ** on the same [database connection] D, or NULL for - ** the first call on D. - ** - ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()] - ** interfaces. - */ - //SQLITE_API void *sqlite3_update_hook( - // sqlite3*, - // void()(void *,int ,char const *,char const *,sqlite3_int64), - // void* - //); - - /* - ** CAPI3REF: Enable Or Disable Shared Pager Cache - ** KEYWORDS: {shared cache} - ** - ** ^(This routine enables or disables the sharing of the database cache - ** and schema data structures between [database connection | connections] - ** to the same database. Sharing is enabled if the argument is true - ** and disabled if the argument is false.)^ - ** - ** ^Cache sharing is enabled and disabled for an entire process. - ** This is a change as of SQLite version 3.5.0. In prior versions of SQLite, - ** sharing was enabled or disabled for each thread separately. - ** - ** ^(The cache sharing mode set by this interface effects all subsequent - ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()]. - ** Existing database connections continue use the sharing mode - ** that was in effect at the time they were opened.)^ - ** - ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled - ** successfully. An [error code] is returned otherwise.)^ - ** - ** ^Shared cache is disabled by default. But this might change in - ** future releases of SQLite. Applications that care about shared - ** cache setting should set it explicitly. - ** - ** See Also: [SQLite Shared-Cache Mode] - */ - //SQLITE_API int sqlite3_enable_shared_cache(int); - - /* - ** CAPI3REF: Attempt To Free Heap Memory - ** - ** ^The sqlite3_release_memory() interface attempts to free N bytes - ** of heap memory by deallocating non-essential memory allocations - ** held by the database library. Memory used to cache database - ** pages to improve performance is an example of non-essential memory. - ** ^sqlite3_release_memory() returns the number of bytes actually freed, - ** which might be more or less than the amount requested. - ** ^The sqlite3_release_memory() routine is a no-op returning zero - ** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT]. - */ - //SQLITE_API int sqlite3_release_memory(int); - - /* - ** CAPI3REF: Impose A Limit On Heap Size - ** - ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the - ** soft limit on the amount of heap memory that may be allocated by SQLite. - ** ^SQLite strives to keep heap memory utilization below the soft heap - ** limit by reducing the number of pages held in the page cache - ** as heap memory usages approaches the limit. - ** ^The soft heap limit is "soft" because even though SQLite strives to stay - ** below the limit, it will exceed the limit rather than generate - ** an [SQLITE_NOMEM] error. In other words, the soft heap limit - ** is advisory only. - ** - ** ^The return value from sqlite3_soft_heap_limit64() is the size of - ** the soft heap limit prior to the call. ^If the argument N is negative - ** then no change is made to the soft heap limit. Hence, the current - ** size of the soft heap limit can be determined by invoking - ** sqlite3_soft_heap_limit64() with a negative argument. - ** - ** ^If the argument N is zero then the soft heap limit is disabled. - ** - ** ^(The soft heap limit is not enforced in the current implementation - ** if one or more of following conditions are true: - ** - **
    - **
  • The soft heap limit is set to zero. - **
  • Memory accounting is disabled using a combination of the - ** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and - ** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option. - **
  • An alternative page cache implementation is specified using - ** [sqlite3_config]([SQLITE_CONFIG_PCACHE],...). - **
  • The page cache allocates from its own memory pool supplied - ** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than - ** from the heap. - **
)^ - ** - ** Beginning with SQLite version 3.7.3, the soft heap limit is enforced - ** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT] - ** compile-time option is invoked. With [SQLITE_ENABLE_MEMORY_MANAGEMENT], - ** the soft heap limit is enforced on every memory allocation. Without - ** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced - ** when memory is allocated by the page cache. Testing suggests that because - ** the page cache is the predominate memory user in SQLite, most - ** applications will achieve adequate soft heap limit enforcement without - ** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT]. - ** - ** The circumstances under which SQLite will enforce the soft heap limit may - ** changes in future releases of SQLite. - */ - //SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N); - - /* - ** CAPI3REF: Deprecated Soft Heap Limit Interface - ** DEPRECATED - ** - ** This is a deprecated version of the [sqlite3_soft_heap_limit64()] - ** interface. This routine is provided for historical compatibility - ** only. All new applications should use the - ** [sqlite3_soft_heap_limit64()] interface rather than this one. - */ - //SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N); - - - /* - ** CAPI3REF: Extract Metadata About A Column Of A Table - ** - ** ^This routine returns metadata about a specific column of a specific - ** database table accessible using the [database connection] handle - ** passed as the first function argument. - ** - ** ^The column is identified by the second, third and fourth parameters to - ** this function. ^The second parameter is either the name of the database - ** (i.e. "main", "temp", or an attached database) containing the specified - ** table or NULL. ^If it is NULL, then all attached databases are searched - ** for the table using the same algorithm used by the database engine to - ** resolve unqualified table references. - ** - ** ^The third and fourth parameters to this function are the table and column - ** name of the desired column, respectively. Neither of these parameters - ** may be NULL. - ** - ** ^Metadata is returned by writing to the memory locations passed as the 5th - ** and subsequent parameters to this function. ^Any of these arguments may be - ** NULL, in which case the corresponding element of metadata is omitted. - ** - ** ^(
- ** - **
Parameter Output
Type
Description - ** - **
5th const char* Data type - **
6th const char* Name of default collation sequence - **
7th int True if column has a NOT NULL constraint - **
8th int True if column is part of the PRIMARY KEY - **
9th int True if column is [AUTOINCREMENT] - **
- **
)^ - ** - ** ^The memory pointed to by the character pointers returned for the - ** declaration type and collation sequence is valid only until the next - ** call to any SQLite API function. - ** - ** ^If the specified table is actually a view, an [error code] is returned. - ** - ** ^If the specified column is "rowid", "oid" or "_rowid_" and an - ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output - ** parameters are set for the explicitly declared column. ^(If there is no - ** explicitly declared [INTEGER PRIMARY KEY] column, then the output - ** parameters are set as follows: - ** - **
-    **     data type: "INTEGER"
-    **     collation sequence: "BINARY"
-    **     not null: 0
-    **     primary key: 1
-    **     auto increment: 0
-    ** 
)^ - ** - ** ^(This function may load one or more schemas from database files. If an - ** error occurs during this process, or if the requested table or column - ** cannot be found, an [error code] is returned and an error message left - ** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^ - ** - ** ^This API is only available if the library was compiled with the - ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined. - */ - //SQLITE_API int sqlite3_table_column_metadata( - // sqlite3 db, /* Connection handle */ - // string zDbName, /* Database name or NULL */ - // string zTableName, /* Table name */ - // string zColumnName, /* Column name */ - // char const **pzDataType, /* OUTPUT: Declared data type */ - // char const **pzCollSeq, /* OUTPUT: Collation sequence name */ - // int *pNotNull, /* OUTPUT: True if NOT NULL constraint exists */ - // int *pPrimaryKey, /* OUTPUT: True if column part of PK */ - // int *pAutoinc /* OUTPUT: True if column is auto-increment */ - //); - - /* - ** CAPI3REF: Load An Extension - ** - ** ^This interface loads an SQLite extension library from the named file. - ** - ** ^The sqlite3_load_extension() interface attempts to load an - ** SQLite extension library contained in the file zFile. - ** - ** ^The entry point is zProc. - ** ^zProc may be 0, in which case the name of the entry point - ** defaults to "sqlite3_extension_init". - ** ^The sqlite3_load_extension() interface returns - ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong. - ** ^If an error occurs and pzErrMsg is not 0, then the - ** [sqlite3_load_extension()] interface shall attempt to - ** fill *pzErrMsg with error message text stored in memory - ** obtained from [sqlite3_malloc()]. The calling function - ** should free this memory by calling [sqlite3_free()]. - ** - ** ^Extension loading must be enabled using - ** [sqlite3_enable_load_extension()] prior to calling this API, - ** otherwise an error will be returned. - ** - ** See also the [load_extension() SQL function]. - */ - //SQLITE_API int sqlite3_load_extension( - // sqlite3 db, /* Load the extension into this database connection */ - // string zFile, /* Name of the shared library containing extension */ - // string zProc, /* Entry point. Derived from zFile if 0 */ - // char **pzErrMsg /* Put error message here if not 0 */ - //); - - /* - ** CAPI3REF: Enable Or Disable Extension Loading - ** - ** ^So as not to open security holes in older applications that are - ** unprepared to deal with extension loading, and as a means of disabling - ** extension loading while evaluating user-entered SQL, the following API - ** is provided to turn the [sqlite3_load_extension()] mechanism on and off. - ** - ** ^Extension loading is off by default. See ticket #1863. - ** ^Call the sqlite3_enable_load_extension() routine with onoff==1 - ** to turn extension loading on and call it with onoff==0 to turn - ** it back off again. - */ - //SQLITE_API int sqlite3_enable_load_extension(sqlite3 db, int onoff); - - /* - ** CAPI3REF: Automatically Load Statically Linked Extensions - ** - ** ^This interface causes the xEntryPoint() function to be invoked for - ** each new [database connection] that is created. The idea here is that - ** xEntryPoint() is the entry point for a statically linked SQLite extension - ** that is to be automatically loaded into all new database connections. - ** - ** ^(Even though the function prototype shows that xEntryPoint() takes - ** no arguments and returns void, SQLite invokes xEntryPoint() with three - ** arguments and expects and integer result as if the signature of the - ** entry point where as follows: - ** - **
-    **    int xEntryPoint(
-    **      sqlite3 db,
-    **      string *pzErrMsg,
-    **      const struct sqlite3_api_routines *pThunk
-    **    );
-    ** 
)^ - ** - ** If the xEntryPoint routine encounters an error, it should make *pzErrMsg - ** point to an appropriate error message (obtained from [sqlite3_mprintf()]) - ** and return an appropriate [error code]. ^SQLite ensures that *pzErrMsg - ** is NULL before calling the xEntryPoint(). ^SQLite will invoke - ** [sqlite3_free()] on *pzErrMsg after xEntryPoint() returns. ^If any - ** xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()], - ** or [sqlite3_open_v2()] call that provoked the xEntryPoint() will fail. - ** - ** ^Calling sqlite3_auto_extension(X) with an entry point X that is already - ** on the list of automatic extensions is a harmless no-op. ^No entry point - ** will be called more than once for each database connection that is opened. - ** - ** See also: [sqlite3_reset_auto_extension()]. - */ - //SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void)); - - /* - ** CAPI3REF: Reset Automatic Extension Loading - ** - ** ^This interface disables all automatic extensions previously - ** registered using [sqlite3_auto_extension()]. - */ - //SQLITE_API void sqlite3_reset_auto_extension(void); - - /* - ** The interface to the virtual-table mechanism is currently considered - ** to be experimental. The interface might change in incompatible ways. - ** If this is a problem for you, do not use the interface at this time. - ** - ** When the virtual-table mechanism stabilizes, we will declare the - ** interface fixed, support it indefinitely, and remove this comment. - */ - - /* - ** Structures used by the virtual table interface - */ - //typedef struct sqlite3_vtab sqlite3_vtab; - //typedef struct sqlite3_index_info sqlite3_index_info; - //typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor; - //typedef struct sqlite3_module sqlite3_module; - - /* - ** CAPI3REF: Virtual Table Object - ** KEYWORDS: sqlite3_module {virtual table module} - ** - ** This structure, sometimes called a "virtual table module", - ** defines the implementation of a [virtual tables]. - ** This structure consists mostly of methods for the module. - ** - ** ^A virtual table module is created by filling in a persistent - ** instance of this structure and passing a pointer to that instance - ** to [sqlite3_create_module()] or [sqlite3_create_module_v2()]. - ** ^The registration remains valid until it is replaced by a different - ** module or until the [database connection] closes. The content - ** of this structure must not change while it is registered with - ** any database connection. - */ - //struct sqlite3_module { - // int iVersion; - // int (*xCreate)(sqlite3*, object *pAux, - // int argc, string[] argv, - // sqlite3_vtab **ppVTab, char*); - // int (*xConnect)(sqlite3*, object *pAux, - // int argc, string[] argv, - // sqlite3_vtab **ppVTab, char*); - // int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info); - // int (*xDisconnect)(sqlite3_vtab *pVTab); - // int (*xDestroy)(sqlite3_vtab *pVTab); - // int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor); - // int (*xClose)(sqlite3_vtab_cursor); - // int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, string idxStr, - // int argc, sqlite3_value **argv); - // int (*xNext)(sqlite3_vtab_cursor); - // int (*xEof)(sqlite3_vtab_cursor); - // int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int); - // int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid); - // int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 ); - // int (*xBegin)(sqlite3_vtab *pVTab); - // int (*xSync)(sqlite3_vtab *pVTab); - // int (*xCommit)(sqlite3_vtab *pVTab); - // int (*xRollback)(sqlite3_vtab *pVTab); - // int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, string zName, - // void (**pxFunc)(sqlite3_context*,int,sqlite3_value*), - // void **ppArg); - // int (*xRename)(sqlite3_vtab *pVtab, string zNew); - ///* The methods above are in version 1 of the sqlite_module object. Those - //** below are for version 2 and greater. */ - //int (*xSavepoint)(sqlite3_vtab *pVTab, int); - //int (*xRelease)(sqlite3_vtab *pVTab, int); - //int (*xRollbackTo)(sqlite3_vtab *pVTab, int); - //}; - // MINIMAL STRUCTURE - public class sqlite3_module - { - public int iVersion; - public smdxCreateConnect xCreate; - public smdxCreateConnect xConnect; - public smdxBestIndex xBestIndex; - public smdxDisconnect xDisconnect; - public smdxDestroy xDestroy; - public smdxOpen xOpen; - public smdxClose xClose; - public smdxFilter xFilter; - public smdxNext xNext; - public smdxEof xEof; - public smdxColumn xColumn; - public smdxRowid xRowid; - public smdxUpdate xUpdate; - public smdxFunction xBegin; - public smdxFunction xSync; - public smdxFunction xCommit; - public smdxFunction xRollback; - public smdxFindFunction xFindFunction; - public smdxRename xRename; - /* The methods above are in version 1 of the sqlite_module object. Those - ** below are for version 2 and greater. */ - public smdxFunctionArg xSavepoint; - public smdxFunctionArg xRelease; - public smdxFunctionArg xRollbackTo; - - //Version 1 - public sqlite3_module( - int iVersion, - smdxCreateConnect xCreate, - smdxCreateConnect xConnect, - smdxBestIndex xBestIndex, - smdxDisconnect xDisconnect, - smdxDestroy xDestroy, - smdxOpen xOpen, - smdxClose xClose, - smdxFilter xFilter, - smdxNext xNext, - smdxEof xEof, - smdxColumn xColumn, - smdxRowid xRowid, - smdxUpdate xUpdate, - smdxFunction xBegin, - smdxFunction xSync, - smdxFunction xCommit, - smdxFunction xRollback, - smdxFindFunction xFindFunction, - smdxRename xRename ) - { - this.iVersion = iVersion; - this.xCreate = xCreate; - this.xConnect = xConnect; - this.xBestIndex = xBestIndex; - this.xDisconnect = xDisconnect; - this.xDestroy = xDestroy; - this.xOpen = xOpen; - this.xClose = xClose; - this.xFilter = xFilter; - this.xNext = xNext; - this.xEof = xEof; - this.xColumn = xColumn; - this.xRowid = xRowid; - this.xUpdate = xUpdate; - this.xBegin = xBegin; - this.xSync = xSync; - this.xCommit = xCommit; - this.xRollback = xRollback; - this.xFindFunction = xFindFunction; - this.xRename = xRename; - } - - //Version 2 - public sqlite3_module( - int iVersion, - smdxCreateConnect xCreate, - smdxCreateConnect xConnect, - smdxBestIndex xBestIndex, - smdxDisconnect xDisconnect, - smdxDestroy xDestroy, - smdxOpen xOpen, - smdxClose xClose, - smdxFilter xFilter, - smdxNext xNext, - smdxEof xEof, - smdxColumn xColumn, - smdxRowid xRowid, - smdxUpdate xUpdate, - smdxFunction xBegin, - smdxFunction xSync, - smdxFunction xCommit, - smdxFunction xRollback, - smdxFindFunction xFindFunction, - smdxRename xRename, - /* The methods above are in version 1 of the sqlite_module object. Those - ** below are for version 2 and greater. */ - smdxFunctionArg xSavepoint, - smdxFunctionArg xRelease, - smdxFunctionArg xRollbackTo - ) - { - this.iVersion = iVersion; - this.xCreate = xCreate; - this.xConnect = xConnect; - this.xBestIndex = xBestIndex; - this.xDisconnect = xDisconnect; - this.xDestroy = xDestroy; - this.xOpen = xOpen; - this.xClose = xClose; - this.xFilter = xFilter; - this.xNext = xNext; - this.xEof = xEof; - this.xColumn = xColumn; - this.xRowid = xRowid; - this.xUpdate = xUpdate; - this.xBegin = xBegin; - this.xSync = xSync; - this.xCommit = xCommit; - this.xRollback = xRollback; - this.xFindFunction = xFindFunction; - this.xRename = xRename; - this.xSavepoint = xSavepoint; - this.xRelease = xRelease; - this.xRollbackTo = xRollbackTo; - } - } + /* + ** CAPI3REF: Flags for the xAccess VFS method + ** + ** These integer constants can be used as the third parameter to + ** the xAccess method of an [sqlite3_vfs] object. They determine + ** what kind of permissions the xAccess method is looking for. + ** With SQLITE_ACCESS_EXISTS, the xAccess method + ** simply checks whether the file exists. + ** With SQLITE_ACCESS_READWRITE, the xAccess method + ** checks whether the named directory is both readable and writable + ** (in other words, if files can be added, removed, and renamed within + ** the directory). + ** The SQLITE_ACCESS_READWRITE constant is currently used only by the + ** [temp_store_directory pragma], though this could change in a future + ** release of SQLite. + ** With SQLITE_ACCESS_READ, the xAccess method + ** checks whether the file is readable. The SQLITE_ACCESS_READ constant is + ** currently unused, though it might be used in a future release of + ** SQLite. + */ + //#define SQLITE_ACCESS_EXISTS 0 + //#define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */ + //#define SQLITE_ACCESS_READ 2 /* Unused */ + const int SQLITE_ACCESS_EXISTS = 0; + const int SQLITE_ACCESS_READWRITE = 1; + const int SQLITE_ACCESS_READ = 2; - /* - ** CAPI3REF: Virtual Table Indexing Information - ** KEYWORDS: sqlite3_index_info - ** - ** The sqlite3_index_info structure and its substructures is used as part - ** of the [virtual table] interface to - ** pass information into and receive the reply from the [xBestIndex] - ** method of a [virtual table module]. The fields under **Inputs** are the - ** inputs to xBestIndex and are read-only. xBestIndex inserts its - ** results into the **Outputs** fields. - ** - ** ^(The aConstraint[] array records WHERE clause constraints of the form: - ** - **
column OP expr
- ** - ** where OP is =, <, <=, >, or >=.)^ ^(The particular operator is - ** stored in aConstraint[].op using one of the - ** [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^ - ** ^(The index of the column is stored in - ** aConstraint[].iColumn.)^ ^(aConstraint[].usable is TRUE if the - ** expr on the right-hand side can be evaluated (and thus the constraint - ** is usable) and false if it cannot.)^ - ** - ** ^The optimizer automatically inverts terms of the form "expr OP column" - ** and makes other simplifications to the WHERE clause in an attempt to - ** get as many WHERE clause terms into the form shown above as possible. - ** ^The aConstraint[] array only reports WHERE clause terms that are - ** relevant to the particular virtual table being queried. - ** - ** ^Information about the ORDER BY clause is stored in aOrderBy[]. - ** ^Each term of aOrderBy records a column of the ORDER BY clause. - ** - ** The [xBestIndex] method must fill aConstraintUsage[] with information - ** about what parameters to pass to xFilter. ^If argvIndex>0 then - ** the right-hand side of the corresponding aConstraint[] is evaluated - ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit - ** is true, then the constraint is assumed to be fully handled by the - ** virtual table and is not checked again by SQLite.)^ - ** - ** ^The idxNum and idxPtr values are recorded and passed into the - ** [xFilter] method. - ** ^[sqlite3_free()] is used to free idxPtr if and only if - ** needToFreeIdxPtr is true. - ** - ** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in - ** the correct order to satisfy the ORDER BY clause so that no separate - ** sorting step is required. - ** - ** ^The estimatedCost value is an estimate of the cost of doing the - ** particular lookup. A full scan of a table with N entries should have - ** a cost of N. A binary search of a table of N entries should have a - ** cost of approximately log(N). - */ - //struct sqlite3_index_info { - // /* Inputs */ - // int nConstraint; /* Number of entries in aConstraint */ - // struct sqlite3_index_constraint { - // int iColumn; /* Column on left-hand side of constraint */ - // unsigned char op; /* Constraint operator */ - // unsigned char usable; /* True if this constraint is usable */ - // int iTermOffset; /* Used internally - xBestIndex should ignore */ - // } *aConstraint; /* Table of WHERE clause constraints */ - // int nOrderBy; /* Number of terms in the ORDER BY clause */ - // struct sqlite3_index_orderby { - // int iColumn; /* Column number */ - // unsigned char desc; /* True for DESC. False for ASC. */ - // } *aOrderBy; /* The ORDER BY clause */ - // /* Outputs */ - // struct sqlite3_index_constraint_usage { - // int argvIndex; /* if >0, constraint is part of argv to xFilter */ - // unsigned char omit; /* Do not code a test for this constraint */ - // } *aConstraintUsage; - // int idxNum; /* Number used to identify the index */ - // char *idxStr; /* String, possibly obtained from sqlite3_malloc */ - // int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */ - // int orderByConsumed; /* True if output is already ordered */ - // double estimatedCost; /* Estimated cost of using this index */ - //}; - public class sqlite3_index_constraint - { - public int iColumn; /* Column on left-hand side of constraint */ - public int op; /* Constraint operator */ - public bool usable; /* True if this constraint is usable */ - public int iTermOffset; /* Used internally - xBestIndex should ignore */ - } - public class sqlite3_index_orderby - { - public int iColumn; /* Column number */ - public bool desc; /* True for DESC. False for ASC. */ - } - public class sqlite3_index_constraint_usage - { - public int argvIndex; /* if >0, constraint is part of argv to xFilter */ - public bool omit; /* Do not code a test for this constraint */ - } + /* + ** CAPI3REF: Flags for the xShmLock VFS method + ** + ** These integer constants define the various locking operations + ** allowed by the xShmLock method of [sqlite3_io_methods]. The + ** following are the only legal combinations of flags to the + ** xShmLock method: + ** + **
    + **
  • SQLITE_SHM_LOCK | SQLITE_SHM_SHARED + **
  • SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE + **
  • SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED + **
  • SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE + **
+ ** + ** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as + ** was given no the corresponding lock. + ** + ** The xShmLock method can transition between unlocked and SHARED or + ** between unlocked and EXCLUSIVE. It cannot transition between SHARED + ** and EXCLUSIVE. + */ + //#define SQLITE_SHM_UNLOCK 1 + //#define SQLITE_SHM_LOCK 2 + //#define SQLITE_SHM_SHARED 4 + //#define SQLITE_SHM_EXCLUSIVE 8 + const int SQLITE_SHM_UNLOCK = 1; + const int SQLITE_SHM_LOCK = 2; + const int SQLITE_SHM_SHARED = 4; + const int SQLITE_SHM_EXCLUSIVE = 8; - public class sqlite3_index_info - { - /* Inputs */ - public int nConstraint; /* Number of entries in aConstraint */ - public sqlite3_index_constraint[] aConstraint; /* Table of WHERE clause constraints */ - public int nOrderBy; /* Number of terms in the ORDER BY clause */ - public sqlite3_index_orderby[] aOrderBy;/* The ORDER BY clause */ - - /* Outputs */ - - public sqlite3_index_constraint_usage[] aConstraintUsage; - public int idxNum; /* Number used to identify the index */ - public string idxStr; /* String, possibly obtained from sqlite3Malloc */ - public int needToFreeIdxStr; /* Free idxStr using sqlite3DbFree(db,) if true */ - public bool orderByConsumed; /* True if output is already ordered */ - public double estimatedCost; /* Estimated cost of using this index */ - } - /* - ** CAPI3REF: Virtual Table Constraint Operator Codes - ** - ** These macros defined the allowed values for the - ** [sqlite3_index_info].aConstraint[].op field. Each value represents - ** an operator that is part of a constraint term in the wHERE clause of - ** a query that uses a [virtual table]. - */ - //#define SQLITE_INDEX_CONSTRAINT_EQ 2 - //#define SQLITE_INDEX_CONSTRAINT_GT 4 - //#define SQLITE_INDEX_CONSTRAINT_LE 8 - //#define SQLITE_INDEX_CONSTRAINT_LT 16 - //#define SQLITE_INDEX_CONSTRAINT_GE 32 - //#define SQLITE_INDEX_CONSTRAINT_MATCH 64 - const int SQLITE_INDEX_CONSTRAINT_EQ = 2; - const int SQLITE_INDEX_CONSTRAINT_GT = 4; - const int SQLITE_INDEX_CONSTRAINT_LE = 8; - const int SQLITE_INDEX_CONSTRAINT_LT = 16; - const int SQLITE_INDEX_CONSTRAINT_GE = 32; - const int SQLITE_INDEX_CONSTRAINT_MATCH = 64; - - /* - ** CAPI3REF: Register A Virtual Table Implementation - ** - ** ^These routines are used to register a new [virtual table module] name. - ** ^Module names must be registered before - ** creating a new [virtual table] using the module and before using a - ** preexisting [virtual table] for the module. - ** - ** ^The module name is registered on the [database connection] specified - ** by the first parameter. ^The name of the module is given by the - ** second parameter. ^The third parameter is a pointer to - ** the implementation of the [virtual table module]. ^The fourth - ** parameter is an arbitrary client data pointer that is passed through - ** into the [xCreate] and [xConnect] methods of the virtual table module - ** when a new virtual table is be being created or reinitialized. - ** - ** ^The sqlite3_create_module_v2() interface has a fifth parameter which - ** is a pointer to a destructor for the pClientData. ^SQLite will - ** invoke the destructor function (if it is not NULL) when SQLite - ** no longer needs the pClientData pointer. ^The destructor will also - ** be invoked if the call to sqlite3_create_module_v2() fails. - ** ^The sqlite3_create_module() - ** interface is equivalent to sqlite3_create_module_v2() with a NULL - ** destructor. - */ - //SQLITE_API int sqlite3_create_module( - // sqlite3 db, /* SQLite connection to register module with */ - // string zName, /* Name of the module */ - // const sqlite3_module *p, /* Methods for the module */ - // void *pClientData /* Client data for xCreate/xConnect */ - //); - //SQLITE_API int sqlite3_create_module_v2( - // sqlite3 db, /* SQLite connection to register module with */ - // string zName, /* Name of the module */ - // const sqlite3_module *p, /* Methods for the module */ - // void *pClientData, /* Client data for xCreate/xConnect */ - // void(*xDestroy)(void) /* Module destructor function */ - //); - - /* - ** CAPI3REF: Virtual Table Instance Object - ** KEYWORDS: sqlite3_vtab - ** - ** Every [virtual table module] implementation uses a subclass - ** of this object to describe a particular instance - ** of the [virtual table]. Each subclass will - ** be tailored to the specific needs of the module implementation. - ** The purpose of this superclass is to define certain fields that are - ** common to all module implementations. - ** - ** ^Virtual tables methods can set an error message by assigning a - ** string obtained from [sqlite3_mprintf()] to zErrMsg. The method should - ** take care that any prior string is freed by a call to [sqlite3_free()] - ** prior to assigning a new string to zErrMsg. ^After the error message - ** is delivered up to the client application, the string will be automatically - ** freed by sqlite3_free() and the zErrMsg field will be zeroed. - */ - //struct sqlite3_vtab { - // const sqlite3_module *pModule; /* The module for this virtual table */ - // int nRef; /* NO LONGER USED */ - // string zErrMsg; /* Error message from sqlite3_mprintf() */ - // /* Virtual table implementations will typically add additional fields */ - //}; - public class sqlite3_vtab - { - public sqlite3_module pModule; /* The module for this virtual table */ - public int nRef; /* Used internally */ - public string zErrMsg; /* Error message from sqlite3_mprintf() */ - /* Virtual table implementations will typically add additional fields */ - }; - - /* - ** CAPI3REF: Virtual Table Cursor Object - ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor} - ** - ** Every [virtual table module] implementation uses a subclass of the - ** following structure to describe cursors that point into the - ** [virtual table] and are used - ** to loop through the virtual table. Cursors are created using the - ** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed - ** by the [sqlite3_module.xClose | xClose] method. Cursors are used - ** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods - ** of the module. Each module implementation will define - ** the content of a cursor structure to suit its own needs. - ** - ** This superclass exists in order to define fields of the cursor that - ** are common to all implementations. - */ - //struct sqlite3_vtab_cursor { - // sqlite3_vtab *pVtab; /* Virtual table of this cursor */ - // /* Virtual table implementations will typically add additional fields */ - //}; - public class sqlite3_vtab_cursor - { - public sqlite3_vtab pVtab; /* Virtual table of this cursor */ - /* Virtual table implementations will typically add additional fields */ - }; - - /* - ** CAPI3REF: Declare The Schema Of A Virtual Table - ** - ** ^The [xCreate] and [xConnect] methods of a - ** [virtual table module] call this interface - ** to declare the format (the names and datatypes of the columns) of - ** the virtual tables they implement. - */ - //SQLITE_API int sqlite3_declare_vtab(sqlite3*, string zSQL); - - /* - ** CAPI3REF: Overload A Function For A Virtual Table - ** - ** ^(Virtual tables can provide alternative implementations of functions - ** using the [xFindFunction] method of the [virtual table module]. - ** But global versions of those functions - ** must exist in order to be overloaded.)^ - ** - ** ^(This API makes sure a global version of a function with a particular - ** name and number of parameters exists. If no such function exists - ** before this API is called, a new function is created.)^ ^The implementation - ** of the new function always causes an exception to be thrown. So - ** the new function is not good for anything by itself. Its only - ** purpose is to be a placeholder function that can be overloaded - ** by a [virtual table]. - */ - //SQLITE_API int sqlite3_overload_function(sqlite3*, string zFuncName, int nArg); - - /* - ** The interface to the virtual-table mechanism defined above (back up - ** to a comment remarkably similar to this one) is currently considered - ** to be experimental. The interface might change in incompatible ways. - ** If this is a problem for you, do not use the interface at this time. - ** - ** When the virtual-table mechanism stabilizes, we will declare the - ** interface fixed, support it indefinitely, and remove this comment. - */ - - /* - ** CAPI3REF: A Handle To An Open BLOB - ** KEYWORDS: {BLOB handle} {BLOB handles} - ** - ** An instance of this object represents an open BLOB on which - ** [sqlite3_blob_open | incremental BLOB I/O] can be performed. - ** ^Objects of this type are created by [sqlite3_blob_open()] - ** and destroyed by [sqlite3_blob_close()]. - ** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces - ** can be used to read or write small subsections of the BLOB. - ** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes. - */ - //typedef struct sqlite3_blob sqlite3_blob; - - /* - ** CAPI3REF: Open A BLOB For Incremental I/O - ** - ** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located - ** in row iRow, column zColumn, table zTable in database zDb; - ** in other words, the same BLOB that would be selected by: - ** - **
-    **     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
-    ** 
)^ - ** - ** ^If the flags parameter is non-zero, then the BLOB is opened for read - ** and write access. ^If it is zero, the BLOB is opened for read access. - ** ^It is not possible to open a column that is part of an index or primary - ** key for writing. ^If [foreign key constraints] are enabled, it is - ** not possible to open a column that is part of a [child key] for writing. - ** - ** ^Note that the database name is not the filename that contains - ** the database but rather the symbolic name of the database that - ** appears after the AS keyword when the database is connected using [ATTACH]. - ** ^For the main database file, the database name is "main". - ** ^For TEMP tables, the database name is "temp". - ** - ** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written - ** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set - ** to be a null pointer.)^ - ** ^This function sets the [database connection] error code and message - ** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related - ** functions. ^Note that the *ppBlob variable is always initialized in a - ** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob - ** regardless of the success or failure of this routine. - ** - ** ^(If the row that a BLOB handle points to is modified by an - ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects - ** then the BLOB handle is marked as "expired". - ** This is true if any column of the row is changed, even a column - ** other than the one the BLOB handle is open on.)^ - ** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for - ** a expired BLOB handle fail with a return code of [SQLITE_ABORT]. - ** ^(Changes written into a BLOB prior to the BLOB expiring are not - ** rolled back by the expiration of the BLOB. Such changes will eventually - ** commit if the transaction continues to completion.)^ - ** - ** ^Use the [sqlite3_blob_bytes()] interface to determine the size of - ** the opened blob. ^The size of a blob may not be changed by this - ** interface. Use the [UPDATE] SQL command to change the size of a - ** blob. - ** - ** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces - ** and the built-in [zeroblob] SQL function can be used, if desired, - ** to create an empty, zero-filled blob in which to read or write using - ** this interface. - ** - ** To avoid a resource leak, every open [BLOB handle] should eventually - ** be released by a call to [sqlite3_blob_close()]. - */ - //SQLITE_API int sqlite3_blob_open( - // sqlite3*, - // string zDb, - // string zTable, - // string zColumn, - // sqlite3_int64 iRow, - // int flags, - // sqlite3_blob **ppBlob - //); - - /* - ** CAPI3REF: Move a BLOB Handle to a New Row - ** - ** ^This function is used to move an existing blob handle so that it points - ** to a different row of the same database table. ^The new row is identified - ** by the rowid value passed as the second argument. Only the row can be - ** changed. ^The database, table and column on which the blob handle is open - ** remain the same. Moving an existing blob handle to a new row can be - ** faster than closing the existing handle and opening a new one. - ** - ** ^(The new row must meet the same criteria as for [sqlite3_blob_open()] - - ** it must exist and there must be either a blob or text value stored in - ** the nominated column.)^ ^If the new row is not present in the table, or if - ** it does not contain a blob or text value, or if another error occurs, an - ** SQLite error code is returned and the blob handle is considered aborted. - ** ^All subsequent calls to [sqlite3_blob_read()], [sqlite3_blob_write()] or - ** [sqlite3_blob_reopen()] on an aborted blob handle immediately return - ** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle - ** always returns zero. - ** - ** ^This function sets the database handle error code and message. - */ - //SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64); - - /* - ** CAPI3REF: Close A BLOB Handle - ** - ** ^Closes an open [BLOB handle]. - ** - ** ^Closing a BLOB shall cause the current transaction to commit - ** if there are no other BLOBs, no pending prepared statements, and the - ** database connection is in [autocommit mode]. - ** ^If any writes were made to the BLOB, they might be held in cache - ** until the close operation if they will fit. - ** - ** ^(Closing the BLOB often forces the changes - ** out to disk and so if any I/O errors occur, they will likely occur - ** at the time when the BLOB is closed. Any errors that occur during - ** closing are reported as a non-zero return value.)^ - ** - ** ^(The BLOB is closed unconditionally. Even if this routine returns - ** an error code, the BLOB is still closed.)^ - ** - ** ^Calling this routine with a null pointer (such as would be returned - ** by a failed call to [sqlite3_blob_open()]) is a harmless no-op. - */ - //SQLITE_API int sqlite3_blob_close(sqlite3_blob ); - - /* - ** CAPI3REF: Return The Size Of An Open BLOB - ** - ** ^Returns the size in bytes of the BLOB accessible via the - ** successfully opened [BLOB handle] in its only argument. ^The - ** incremental blob I/O routines can only read or overwriting existing - ** blob content; they cannot change the size of a blob. - ** - ** This routine only works on a [BLOB handle] which has been created - ** by a prior successful call to [sqlite3_blob_open()] and which has not - ** been closed by [sqlite3_blob_close()]. Passing any other pointer in - ** to this routine results in undefined and probably undesirable behavior. - */ - //SQLITE_API int sqlite3_blob_bytes(sqlite3_blob ); - - /* - ** CAPI3REF: Read Data From A BLOB Incrementally - ** - ** ^(This function is used to read data from an open [BLOB handle] into a - ** caller-supplied buffer. N bytes of data are copied into buffer Z - ** from the open BLOB, starting at offset iOffset.)^ - ** - ** ^If offset iOffset is less than N bytes from the end of the BLOB, - ** [SQLITE_ERROR] is returned and no data is read. ^If N or iOffset is - ** less than zero, [SQLITE_ERROR] is returned and no data is read. - ** ^The size of the blob (and hence the maximum value of N+iOffset) - ** can be determined using the [sqlite3_blob_bytes()] interface. - ** - ** ^An attempt to read from an expired [BLOB handle] fails with an - ** error code of [SQLITE_ABORT]. - ** - ** ^(On success, sqlite3_blob_read() returns SQLITE_OK. - ** Otherwise, an [error code] or an [extended error code] is returned.)^ - ** - ** This routine only works on a [BLOB handle] which has been created - ** by a prior successful call to [sqlite3_blob_open()] and which has not - ** been closed by [sqlite3_blob_close()]. Passing any other pointer in - ** to this routine results in undefined and probably undesirable behavior. - ** - ** See also: [sqlite3_blob_write()]. - */ - //SQLITE_API int sqlite3_blob_read(sqlite3_blob *, object *Z, int N, int iOffset); - - /* - ** CAPI3REF: Write Data Into A BLOB Incrementally - ** - ** ^This function is used to write data into an open [BLOB handle] from a - ** caller-supplied buffer. ^N bytes of data are copied from the buffer Z - ** into the open BLOB, starting at offset iOffset. - ** - ** ^If the [BLOB handle] passed as the first argument was not opened for - ** writing (the flags parameter to [sqlite3_blob_open()] was zero), - ** this function returns [SQLITE_READONLY]. - ** - ** ^This function may only modify the contents of the BLOB; it is - ** not possible to increase the size of a BLOB using this API. - ** ^If offset iOffset is less than N bytes from the end of the BLOB, - ** [SQLITE_ERROR] is returned and no data is written. ^If N is - ** less than zero [SQLITE_ERROR] is returned and no data is written. - ** The size of the BLOB (and hence the maximum value of N+iOffset) - ** can be determined using the [sqlite3_blob_bytes()] interface. - ** - ** ^An attempt to write to an expired [BLOB handle] fails with an - ** error code of [SQLITE_ABORT]. ^Writes to the BLOB that occurred - ** before the [BLOB handle] expired are not rolled back by the - ** expiration of the handle, though of course those changes might - ** have been overwritten by the statement that expired the BLOB handle - ** or by other independent statements. - ** - ** ^(On success, sqlite3_blob_write() returns SQLITE_OK. - ** Otherwise, an [error code] or an [extended error code] is returned.)^ - ** - ** This routine only works on a [BLOB handle] which has been created - ** by a prior successful call to [sqlite3_blob_open()] and which has not - ** been closed by [sqlite3_blob_close()]. Passing any other pointer in - ** to this routine results in undefined and probably undesirable behavior. - ** - ** See also: [sqlite3_blob_read()]. - */ - //SQLITE_API int sqlite3_blob_write(sqlite3_blob *, string z, int n, int iOffset); - - /* - ** CAPI3REF: Virtual File System Objects - ** - ** A virtual filesystem (VFS) is an [sqlite3_vfs] object - ** that SQLite uses to interact - ** with the underlying operating system. Most SQLite builds come with a - ** single default VFS that is appropriate for the host computer. - ** New VFSes can be registered and existing VFSes can be unregistered. - ** The following interfaces are provided. - ** - ** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name. - ** ^Names are case sensitive. - ** ^Names are zero-terminated UTF-8 strings. - ** ^If there is no match, a NULL pointer is returned. - ** ^If zVfsName is NULL then the default VFS is returned. - ** - ** ^New VFSes are registered with sqlite3_vfs_register(). - ** ^Each new VFS becomes the default VFS if the makeDflt flag is set. - ** ^The same VFS can be registered multiple times without injury. - ** ^To make an existing VFS into the default VFS, register it again - ** with the makeDflt flag set. If two different VFSes with the - ** same name are registered, the behavior is undefined. If a - ** VFS is registered with a name that is NULL or an empty string, - ** then the behavior is undefined. - ** - ** ^Unregister a VFS with the sqlite3_vfs_unregister() interface. - ** ^(If the default VFS is unregistered, another VFS is chosen as - ** the default. The choice for the new VFS is arbitrary.)^ - */ - //SQLITE_API sqlite3_vfs *sqlite3_vfs_find(string zVfsName); - //SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt); - //SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs); - - /* - ** CAPI3REF: Mutexes - ** - ** The SQLite core uses these routines for thread - ** synchronization. Though they are intended for internal - ** use by SQLite, code that links against SQLite is - ** permitted to use any of these routines. - ** - ** The SQLite source code contains multiple implementations - ** of these mutex routines. An appropriate implementation - ** is selected automatically at compile-time. ^(The following - ** implementations are available in the SQLite core: - ** - **
    - **
  • SQLITE_MUTEX_OS2 - **
  • SQLITE_MUTEX_PTHREAD - **
  • SQLITE_MUTEX_W32 - **
  • SQLITE_MUTEX_NOOP - **
)^ - ** - ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines - ** that does no real locking and is appropriate for use in - ** a single-threaded application. ^The SQLITE_MUTEX_OS2, - ** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations - ** are appropriate for use on OS/2, Unix, and Windows. - ** - ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor - ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex - ** implementation is included with the library. In this case the - ** application must supply a custom mutex implementation using the - ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function - ** before calling sqlite3_initialize() or any other public sqlite3_ - ** function that calls sqlite3_initialize().)^ - ** - ** ^The sqlite3_mutex_alloc() routine allocates a new - ** mutex and returns a pointer to it. ^If it returns NULL - ** that means that a mutex could not be allocated. ^SQLite - ** will unwind its stack and return an error. ^(The argument - ** to sqlite3_mutex_alloc() is one of these integer constants: - ** - **
    - **
  • SQLITE_MUTEX_FAST - **
  • SQLITE_MUTEX_RECURSIVE - **
  • SQLITE_MUTEX_STATIC_MASTER - **
  • SQLITE_MUTEX_STATIC_MEM - **
  • SQLITE_MUTEX_STATIC_MEM2 - **
  • SQLITE_MUTEX_STATIC_PRNG - **
  • SQLITE_MUTEX_STATIC_LRU - **
  • SQLITE_MUTEX_STATIC_LRU2 - **
)^ - ** - ** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) - ** cause sqlite3_mutex_alloc() to create - ** a new mutex. ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE - ** is used but not necessarily so when SQLITE_MUTEX_FAST is used. - ** The mutex implementation does not need to make a distinction - ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does - ** not want to. ^SQLite will only request a recursive mutex in - ** cases where it really needs one. ^If a faster non-recursive mutex - ** implementation is available on the host platform, the mutex subsystem - ** might return such a mutex in response to SQLITE_MUTEX_FAST. - ** - ** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other - ** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return - ** a pointer to a static preexisting mutex. ^Six static mutexes are - ** used by the current version of SQLite. Future versions of SQLite - ** may add additional static mutexes. Static mutexes are for internal - ** use by SQLite only. Applications that use SQLite mutexes should - ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or - ** SQLITE_MUTEX_RECURSIVE. - ** - ** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST - ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() - ** returns a different mutex on every call. ^But for the static - ** mutex types, the same mutex is returned on every call that has - ** the same type number. - ** - ** ^The sqlite3_mutex_free() routine deallocates a previously - ** allocated dynamic mutex. ^SQLite is careful to deallocate every - ** dynamic mutex that it allocates. The dynamic mutexes must not be in - ** use when they are deallocated. Attempting to deallocate a static - ** mutex results in undefined behavior. ^SQLite never deallocates - ** a static mutex. - ** - ** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt - ** to enter a mutex. ^If another thread is already within the mutex, - ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return - ** SQLITE_BUSY. ^The sqlite3_mutex_try() interface returns [SQLITE_OK] - ** upon successful entry. ^(Mutexes created using - ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread. - ** In such cases the, - ** mutex must be exited an equal number of times before another thread - ** can enter.)^ ^(If the same thread tries to enter any other - ** kind of mutex more than once, the behavior is undefined. - ** SQLite will never exhibit - ** such behavior in its own use of mutexes.)^ - ** - ** ^(Some systems (for example, Windows 95) do not support the operation - ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() - ** will always return SQLITE_BUSY. The SQLite core only ever uses - ** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^ - ** - ** ^The sqlite3_mutex_leave() routine exits a mutex that was - ** previously entered by the same thread. ^(The behavior - ** is undefined if the mutex is not currently entered by the - ** calling thread or is not currently allocated. SQLite will - ** never do either.)^ - ** - ** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or - ** sqlite3_mutex_leave() is a NULL pointer, then all three routines - ** behave as no-ops. - ** - ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()]. - */ - //SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int); - //SQLITE_API void sqlite3_mutex_free(sqlite3_mutex); - //SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex); - //SQLITE_API int sqlite3_mutex_try(sqlite3_mutex); - //SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex); - - /* - ** CAPI3REF: Mutex Methods Object - ** - ** An instance of this structure defines the low-level routines - ** used to allocate and use mutexes. - ** - ** Usually, the default mutex implementations provided by SQLite are - ** sufficient, however the user has the option of substituting a custom - ** implementation for specialized deployments or systems for which SQLite - ** does not provide a suitable implementation. In this case, the user - ** creates and populates an instance of this structure to pass - ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option. - ** Additionally, an instance of this structure can be used as an - ** output variable when querying the system for the current mutex - ** implementation, using the [SQLITE_CONFIG_GETMUTEX] option. - ** - ** ^The xMutexInit method defined by this structure is invoked as - ** part of system initialization by the sqlite3_initialize() function. - ** ^The xMutexInit routine is called by SQLite exactly once for each - ** effective call to [sqlite3_initialize()]. - ** - ** ^The xMutexEnd method defined by this structure is invoked as - ** part of system shutdown by the sqlite3_shutdown() function. The - ** implementation of this method is expected to release all outstanding - ** resources obtained by the mutex methods implementation, especially - ** those obtained by the xMutexInit method. ^The xMutexEnd() - ** interface is invoked exactly once for each call to [sqlite3_shutdown()]. - ** - ** ^(The remaining seven methods defined by this structure (xMutexAlloc, - ** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and - ** xMutexNotheld) implement the following interfaces (respectively): - ** - **
    - **
  • [sqlite3_mutex_alloc()]
  • - **
  • [sqlite3_mutex_free()]
  • - **
  • [sqlite3_mutex_enter()]
  • - **
  • [sqlite3_mutex_try()]
  • - **
  • [sqlite3_mutex_leave()]
  • - **
  • [sqlite3_mutex_held()]
  • - **
  • [sqlite3_mutex_notheld()]
  • - **
)^ - ** - ** The only difference is that the public sqlite3_XXX functions enumerated - ** above silently ignore any invocations that pass a NULL pointer instead - ** of a valid mutex handle. The implementations of the methods defined - ** by this structure are not required to handle this case, the results - ** of passing a NULL pointer instead of a valid mutex handle are undefined - ** (i.e. it is acceptable to provide an implementation that segfaults if - ** it is passed a NULL pointer). - ** - ** The xMutexInit() method must be threadsafe. ^It must be harmless to - ** invoke xMutexInit() multiple times within the same process and without - ** intervening calls to xMutexEnd(). Second and subsequent calls to - ** xMutexInit() must be no-ops. - ** - ** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()] - ** and its associates). ^Similarly, xMutexAlloc() must not use SQLite memory - ** allocation for a static mutex. ^However xMutexAlloc() may use SQLite - ** memory allocation for a fast or recursive mutex. - ** - ** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is - ** called, but only if the prior call to xMutexInit returned SQLITE_OK. - ** If xMutexInit fails in any way, it is expected to clean up after itself - ** prior to returning. - */ - //typedef struct sqlite3_mutex_methods sqlite3_mutex_methods; - //struct sqlite3_mutex_methods { - // int (*xMutexInit)(void); - // int (*xMutexEnd)(void); - // sqlite3_mutex *(*xMutexAlloc)(int); - // void (*xMutexFree)(sqlite3_mutex ); - // void (*xMutexEnter)(sqlite3_mutex ); - // int (*xMutexTry)(sqlite3_mutex ); - // void (*xMutexLeave)(sqlite3_mutex ); - // int (*xMutexHeld)(sqlite3_mutex ); - // int (*xMutexNotheld)(sqlite3_mutex ); - //}; - public class sqlite3_mutex_methods - { - public dxMutexInit xMutexInit; - public dxMutexEnd xMutexEnd; - public dxMutexAlloc xMutexAlloc; - public dxMutexFree xMutexFree; - public dxMutexEnter xMutexEnter; - public dxMutexTry xMutexTry; - public dxMutexLeave xMutexLeave; - public dxMutexHeld xMutexHeld; - public dxMutexNotheld xMutexNotheld; - - public sqlite3_mutex_methods() - { - } - - public sqlite3_mutex_methods( - dxMutexInit xMutexInit, - dxMutexEnd xMutexEnd, - dxMutexAlloc xMutexAlloc, - dxMutexFree xMutexFree, - dxMutexEnter xMutexEnter, - dxMutexTry xMutexTry, - dxMutexLeave xMutexLeave, - dxMutexHeld xMutexHeld, - dxMutexNotheld xMutexNotheld - ) - { - this.xMutexInit = xMutexInit; - this.xMutexEnd = xMutexEnd; - this.xMutexAlloc = xMutexAlloc; - this.xMutexFree = xMutexFree; - this.xMutexEnter = xMutexEnter; - this.xMutexTry = xMutexTry; - this.xMutexLeave = xMutexLeave; - this.xMutexHeld = xMutexHeld; - this.xMutexNotheld = xMutexNotheld; - } - -//Copy sqlite3_mutex_methods from existing - public void Copy( sqlite3_mutex_methods cp ) - { - Debug.Assert( cp != null ); - this.xMutexInit = cp.xMutexInit; - this.xMutexEnd = cp.xMutexEnd; - this.xMutexAlloc = cp.xMutexAlloc; - this.xMutexFree = cp.xMutexFree; - this.xMutexEnter = cp.xMutexEnter; - this.xMutexTry = cp.xMutexTry; - this.xMutexLeave = cp.xMutexLeave; - this.xMutexHeld = cp.xMutexHeld; - this.xMutexNotheld = cp.xMutexNotheld; - } + /* + ** CAPI3REF: Maximum xShmLock index + ** + ** The xShmLock method on [sqlite3_io_methods] may use values + ** between 0 and this upper bound as its "offset" argument. + ** The SQLite core will never attempt to acquire or release a + ** lock outside of this range + */ + //#define SQLITE_SHM_NLOCK 8 + const int SQLITE_SHM_NLOCK = 8; + + /* + ** CAPI3REF: Initialize The SQLite Library + ** + ** ^The sqlite3_initialize() routine initializes the + ** SQLite library. ^The sqlite3_shutdown() routine + ** deallocates any resources that were allocated by sqlite3_initialize(). + ** These routines are designed to aid in process initialization and + ** shutdown on embedded systems. Workstation applications using + ** SQLite normally do not need to invoke either of these routines. + ** + ** A call to sqlite3_initialize() is an "effective" call if it is + ** the first time sqlite3_initialize() is invoked during the lifetime of + ** the process, or if it is the first time sqlite3_initialize() is invoked + ** following a call to sqlite3_shutdown(). ^(Only an effective call + ** of sqlite3_initialize() does any initialization. All other calls + ** are harmless no-ops.)^ + ** + ** A call to sqlite3_shutdown() is an "effective" call if it is the first + ** call to sqlite3_shutdown() since the last sqlite3_initialize(). ^(Only + ** an effective call to sqlite3_shutdown() does any deinitialization. + ** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^ + ** + ** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown() + ** is not. The sqlite3_shutdown() interface must only be called from a + ** single thread. All open [database connections] must be closed and all + ** other SQLite resources must be deallocated prior to invoking + ** sqlite3_shutdown(). + ** + ** Among other things, ^sqlite3_initialize() will invoke + ** sqlite3_os_init(). Similarly, ^sqlite3_shutdown() + ** will invoke sqlite3_os_end(). + ** + ** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success. + ** ^If for some reason, sqlite3_initialize() is unable to initialize + ** the library (perhaps it is unable to allocate a needed resource such + ** as a mutex) it returns an [error code] other than [SQLITE_OK]. + ** + ** ^The sqlite3_initialize() routine is called internally by many other + ** SQLite interfaces so that an application usually does not need to + ** invoke sqlite3_initialize() directly. For example, [sqlite3_open()] + ** calls sqlite3_initialize() so the SQLite library will be automatically + ** initialized when [sqlite3_open()] is called if it has not be initialized + ** already. ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT] + ** compile-time option, then the automatic calls to sqlite3_initialize() + ** are omitted and the application must call sqlite3_initialize() directly + ** prior to using any other SQLite interface. For maximum portability, + ** it is recommended that applications always invoke sqlite3_initialize() + ** directly prior to using any other SQLite interface. Future releases + ** of SQLite may require this. In other words, the behavior exhibited + ** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the + ** default behavior in some future release of SQLite. + ** + ** The sqlite3_os_init() routine does operating-system specific + ** initialization of the SQLite library. The sqlite3_os_end() + ** routine undoes the effect of sqlite3_os_init(). Typical tasks + ** performed by these routines include allocation or deallocation + ** of static resources, initialization of global variables, + ** setting up a default [sqlite3_vfs] module, or setting up + ** a default configuration using [sqlite3_config()]. + ** + ** The application should never invoke either sqlite3_os_init() + ** or sqlite3_os_end() directly. The application should only invoke + ** sqlite3_initialize() and sqlite3_shutdown(). The sqlite3_os_init() + ** interface is called automatically by sqlite3_initialize() and + ** sqlite3_os_end() is called by sqlite3_shutdown(). Appropriate + ** implementations for sqlite3_os_init() and sqlite3_os_end() + ** are built into SQLite when it is compiled for Unix, Windows, or OS/2. + ** When [custom builds | built for other platforms] + ** (using the [SQLITE_OS_OTHER=1] compile-time + ** option) the application must supply a suitable implementation for + ** sqlite3_os_init() and sqlite3_os_end(). An application-supplied + ** implementation of sqlite3_os_init() or sqlite3_os_end() + ** must return [SQLITE_OK] on success and some other [error code] upon + ** failure. + */ + //SQLITE_API int sqlite3_initialize(void); + //SQLITE_API int sqlite3_shutdown(void); + //SQLITE_API int sqlite3_os_init(void); + //SQLITE_API int sqlite3_os_end(void); + + /* + ** CAPI3REF: Configuring The SQLite Library + ** + ** The sqlite3_config() interface is used to make global configuration + ** changes to SQLite in order to tune SQLite to the specific needs of + ** the application. The default configuration is recommended for most + ** applications and so this routine is usually not necessary. It is + ** provided to support rare applications with unusual needs. + ** + ** The sqlite3_config() interface is not threadsafe. The application + ** must insure that no other SQLite interfaces are invoked by other + ** threads while sqlite3_config() is running. Furthermore, sqlite3_config() + ** may only be invoked prior to library initialization using + ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()]. + ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before + ** [sqlite3_shutdown()] then it will return SQLITE_MISUSE. + ** Note, however, that ^sqlite3_config() can be called as part of the + ** implementation of an application-defined [sqlite3_os_init()]. + ** + ** The first argument to sqlite3_config() is an integer + ** [configuration option] that determines + ** what property of SQLite is to be configured. Subsequent arguments + ** vary depending on the [configuration option] + ** in the first argument. + ** + ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK]. + ** ^If the option is unknown or SQLite is unable to set the option + ** then this routine returns a non-zero [error code]. + */ + //SQLITE_API int sqlite3_config(int, ...); + + /* + ** CAPI3REF: Configure database connections + ** + ** The sqlite3_db_config() interface is used to make configuration + ** changes to a [database connection]. The interface is similar to + ** [sqlite3_config()] except that the changes apply to a single + ** [database connection] (specified in the first argument). + ** + ** The second argument to sqlite3_db_config(D,V,...) is the + ** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code + ** that indicates what aspect of the [database connection] is being configured. + ** Subsequent arguments vary depending on the configuration verb. + ** + ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if + ** the call is considered successful. + */ + //SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...); + + /* + ** CAPI3REF: Memory Allocation Routines + ** + ** An instance of this object defines the interface between SQLite + ** and low-level memory allocation routines. + ** + ** This object is used in only one place in the SQLite interface. + ** A pointer to an instance of this object is the argument to + ** [sqlite3_config()] when the configuration option is + ** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC]. + ** By creating an instance of this object + ** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC]) + ** during configuration, an application can specify an alternative + ** memory allocation subsystem for SQLite to use for all of its + ** dynamic memory needs. + ** + ** Note that SQLite comes with several [built-in memory allocators] + ** that are perfectly adequate for the overwhelming majority of applications + ** and that this object is only useful to a tiny minority of applications + ** with specialized memory allocation requirements. This object is + ** also used during testing of SQLite in order to specify an alternative + ** memory allocator that simulates memory out-of-memory conditions in + ** order to verify that SQLite recovers gracefully from such + ** conditions. + ** + ** The xMalloc and xFree methods must work like the + ** malloc() and free() functions from the standard C library. + ** The xRealloc method must work like realloc() from the standard C library + ** with the exception that if the second argument to xRealloc is zero, + ** xRealloc must be a no-op - it must not perform any allocation or + ** deallocation. ^SQLite guarantees that the second argument to + ** xRealloc is always a value returned by a prior call to xRoundup. + ** And so in cases where xRoundup always returns a positive number, + ** xRealloc can perform exactly as the standard library realloc() and + ** still be in compliance with this specification. + ** + ** xSize should return the allocated size of a memory allocation + ** previously obtained from xMalloc or xRealloc. The allocated size + ** is always at least as big as the requested size but may be larger. + ** + ** The xRoundup method returns what would be the allocated size of + ** a memory allocation given a particular requested size. Most memory + ** allocators round up memory allocations at least to the next multiple + ** of 8. Some allocators round up to a larger multiple or to a power of 2. + ** Every memory allocation request coming in through [sqlite3_malloc()] + ** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0, + ** that causes the corresponding memory allocation to fail. + ** + ** The xInit method initializes the memory allocator. (For example, + ** it might allocate any require mutexes or initialize internal data + ** structures. The xShutdown method is invoked (indirectly) by + ** [sqlite3_shutdown()] and should deallocate any resources acquired + ** by xInit. The pAppData pointer is used as the only parameter to + ** xInit and xShutdown. + ** + ** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes + ** the xInit method, so the xInit method need not be threadsafe. The + ** xShutdown method is only called from [sqlite3_shutdown()] so it does + ** not need to be threadsafe either. For all other methods, SQLite + ** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the + ** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which + ** it is by default) and so the methods are automatically serialized. + ** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other + ** methods must be threadsafe or else make their own arrangements for + ** serialization. + ** + ** SQLite will never invoke xInit() more than once without an intervening + ** call to xShutdown(). + */ + //typedef struct sqlite3_mem_methods sqlite3_mem_methods; + //struct sqlite3_mem_methods { + // void *(*xMalloc)(int); /* Memory allocation function */ + // void (*xFree)(void); /* Free a prior allocation */ + // void *(*xRealloc)(void*,int); /* Resize an allocation */ + // int (*xSize)(void); /* Return the size of an allocation */ + // int (*xRoundup)(int); /* Round up request size to allocation size */ + // int (*xInit)(void); /* Initialize the memory allocator */ + // void (*xShutdown)(void); /* Deinitialize the memory allocator */ + // void *pAppData; /* Argument to xInit() and xShutdown() */ + //}; + public class sqlite3_mem_methods { + public dxMalloc xMalloc; //void *(*xMalloc)(int); /* Memory allocation function */ + public dxMallocInt xMallocInt; //void *(*xMalloc)(int); /* Memory allocation function */ + public dxMallocMem xMallocMem; //void *(*xMalloc)(int); /* Memory allocation function */ + public dxFree xFree; //void (*xFree)(void); /* Free a prior allocation */ + public dxFreeInt xFreeInt; //void (*xFree)(void); /* Free a prior allocation */ + public dxFreeMem xFreeMem; //void (*xFree)(void); /* Free a prior allocation */ + public dxRealloc xRealloc; //void *(*xRealloc)(void*,int); /* Resize an allocation */ + public dxSize xSize; //int (*xSize)(void); /* Return the size of an allocation */ + public dxRoundup xRoundup; //int (*xRoundup)(int); /* Round up request size to allocation size */ + public dxMemInit xInit; //int (*xInit)(void); /* Initialize the memory allocator */ + public dxMemShutdown xShutdown; //void (*xShutdown)(void); /* Deinitialize the memory allocator */ + public object pAppData; /* Argument to xInit() and xShutdown() */ + + public sqlite3_mem_methods() { + } + + public sqlite3_mem_methods( + dxMalloc xMalloc, + dxMallocInt xMallocInt, + dxMallocMem xMallocMem, + dxFree xFree, + dxFreeInt xFreeInt, + dxFreeMem xFreeMem, + dxRealloc xRealloc, + dxSize xSize, + dxRoundup xRoundup, + dxMemInit xInit, + dxMemShutdown xShutdown, + object pAppData + ) { + this.xMalloc = xMalloc; + this.xMallocInt = xMallocInt; + this.xMallocMem = xMallocMem; + this.xFree = xFree; + this.xFreeInt = xFreeInt; + this.xFreeMem = xFreeMem; + this.xRealloc = xRealloc; + this.xSize = xSize; + this.xRoundup = xRoundup; + this.xInit = xInit; + this.xShutdown = xShutdown; + this.pAppData = pAppData; + } + } + + + /* + ** CAPI3REF: Configuration Options + ** KEYWORDS: {configuration option} + ** + ** These constants are the available integer configuration options that + ** can be passed as the first argument to the [sqlite3_config()] interface. + ** + ** New configuration options may be added in future releases of SQLite. + ** Existing configuration options might be discontinued. Applications + ** should check the return code from [sqlite3_config()] to make sure that + ** the call worked. The [sqlite3_config()] interface will return a + ** non-zero [error code] if a discontinued or unsupported configuration option + ** is invoked. + ** + **
+ ** [[SQLITE_CONFIG_SINGLETHREAD]]
SQLITE_CONFIG_SINGLETHREAD
+ **
There are no arguments to this option. ^This option sets the + ** [threading mode] to Single-thread. In other words, it disables + ** all mutexing and puts SQLite into a mode where it can only be used + ** by a single thread. ^If SQLite is compiled with + ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then + ** it is not possible to change the [threading mode] from its default + ** value of Single-thread and so [sqlite3_config()] will return + ** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD + ** configuration option.
+ ** + ** [[SQLITE_CONFIG_MULTITHREAD]]
SQLITE_CONFIG_MULTITHREAD
+ **
There are no arguments to this option. ^This option sets the + ** [threading mode] to Multi-thread. In other words, it disables + ** mutexing on [database connection] and [prepared statement] objects. + ** The application is responsible for serializing access to + ** [database connections] and [prepared statements]. But other mutexes + ** are enabled so that SQLite will be safe to use in a multi-threaded + ** environment as long as no two threads attempt to use the same + ** [database connection] at the same time. ^If SQLite is compiled with + ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then + ** it is not possible to set the Multi-thread [threading mode] and + ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the + ** SQLITE_CONFIG_MULTITHREAD configuration option.
+ ** + ** [[SQLITE_CONFIG_SERIALIZED]]
SQLITE_CONFIG_SERIALIZED
+ **
There are no arguments to this option. ^This option sets the + ** [threading mode] to Serialized. In other words, this option enables + ** all mutexes including the recursive + ** mutexes on [database connection] and [prepared statement] objects. + ** In this mode (which is the default when SQLite is compiled with + ** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access + ** to [database connections] and [prepared statements] so that the + ** application is free to use the same [database connection] or the + ** same [prepared statement] in different threads at the same time. + ** ^If SQLite is compiled with + ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then + ** it is not possible to set the Serialized [threading mode] and + ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the + ** SQLITE_CONFIG_SERIALIZED configuration option.
+ ** + ** [[SQLITE_CONFIG_MALLOC]]
SQLITE_CONFIG_MALLOC
+ **
^(This option takes a single argument which is a pointer to an + ** instance of the [sqlite3_mem_methods] structure. The argument specifies + ** alternative low-level memory allocation routines to be used in place of + ** the memory allocation routines built into SQLite.)^ ^SQLite makes + ** its own private copy of the content of the [sqlite3_mem_methods] structure + ** before the [sqlite3_config()] call returns.
+ ** + ** [[SQLITE_CONFIG_GETMALLOC]]
SQLITE_CONFIG_GETMALLOC
+ **
^(This option takes a single argument which is a pointer to an + ** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods] + ** structure is filled with the currently defined memory allocation routines.)^ + ** This option can be used to overload the default memory allocation + ** routines with a wrapper that simulations memory allocation failure or + ** tracks memory usage, for example.
+ ** + ** [[SQLITE_CONFIG_MEMSTATUS]]
SQLITE_CONFIG_MEMSTATUS
+ **
^This option takes single argument of type int, interpreted as a + ** boolean, which enables or disables the collection of memory allocation + ** statistics. ^(When memory allocation statistics are disabled, the + ** following SQLite interfaces become non-operational: + **
    + **
  • [sqlite3_memory_used()] + **
  • [sqlite3_memory_highwater()] + **
  • [sqlite3_soft_heap_limit64()] + **
  • [sqlite3_status()] + **
)^ + ** ^Memory allocation statistics are enabled by default unless SQLite is + ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory + ** allocation statistics are disabled by default. + **
+ ** + ** [[SQLITE_CONFIG_SCRATCH]]
SQLITE_CONFIG_SCRATCH
+ **
^This option specifies a static memory buffer that SQLite can use for + ** scratch memory. There are three arguments: A pointer an 8-byte + ** aligned memory buffer from which the scratch allocations will be + ** drawn, the size of each scratch allocation (sz), + ** and the maximum number of scratch allocations (N). The sz + ** argument must be a multiple of 16. + ** The first argument must be a pointer to an 8-byte aligned buffer + ** of at least sz*N bytes of memory. + ** ^SQLite will use no more than two scratch buffers per thread. So + ** N should be set to twice the expected maximum number of threads. + ** ^SQLite will never require a scratch buffer that is more than 6 + ** times the database page size. ^If SQLite needs needs additional + ** scratch memory beyond what is provided by this configuration option, then + ** [sqlite3_malloc()] will be used to obtain the memory needed.
+ ** + ** [[SQLITE_CONFIG_PAGECACHE]]
SQLITE_CONFIG_PAGECACHE
+ **
^This option specifies a static memory buffer that SQLite can use for + ** the database page cache with the default page cache implementation. + ** This configuration should not be used if an application-define page + ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option. + ** There are three arguments to this option: A pointer to 8-byte aligned + ** memory, the size of each page buffer (sz), and the number of pages (N). + ** The sz argument should be the size of the largest database page + ** (a power of two between 512 and 32768) plus a little extra for each + ** page header. ^The page header size is 20 to 40 bytes depending on + ** the host architecture. ^It is harmless, apart from the wasted memory, + ** to make sz a little too large. The first + ** argument should point to an allocation of at least sz*N bytes of memory. + ** ^SQLite will use the memory provided by the first argument to satisfy its + ** memory needs for the first N pages that it adds to cache. ^If additional + ** page cache memory is needed beyond what is provided by this option, then + ** SQLite goes to [sqlite3_malloc()] for the additional storage space. + ** The pointer in the first argument must + ** be aligned to an 8-byte boundary or subsequent behavior of SQLite + ** will be undefined.
+ ** + ** [[SQLITE_CONFIG_HEAP]]
SQLITE_CONFIG_HEAP
+ **
^This option specifies a static memory buffer that SQLite will use + ** for all of its dynamic memory allocation needs beyond those provided + ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE]. + ** There are three arguments: An 8-byte aligned pointer to the memory, + ** the number of bytes in the memory buffer, and the minimum allocation size. + ** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts + ** to using its default memory allocator (the system malloc() implementation), + ** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. ^If the + ** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or + ** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory + ** allocator is engaged to handle all of SQLites memory allocation needs. + ** The first pointer (the memory pointer) must be aligned to an 8-byte + ** boundary or subsequent behavior of SQLite will be undefined. + ** The minimum allocation size is capped at 2^12. Reasonable values + ** for the minimum allocation size are 2^5 through 2^8.
+ ** + ** [[SQLITE_CONFIG_MUTEX]]
SQLITE_CONFIG_MUTEX
+ **
^(This option takes a single argument which is a pointer to an + ** instance of the [sqlite3_mutex_methods] structure. The argument specifies + ** alternative low-level mutex routines to be used in place + ** the mutex routines built into SQLite.)^ ^SQLite makes a copy of the + ** content of the [sqlite3_mutex_methods] structure before the call to + ** [sqlite3_config()] returns. ^If SQLite is compiled with + ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then + ** the entire mutexing subsystem is omitted from the build and hence calls to + ** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will + ** return [SQLITE_ERROR].
+ ** + ** [[SQLITE_CONFIG_GETMUTEX]]
SQLITE_CONFIG_GETMUTEX
+ **
^(This option takes a single argument which is a pointer to an + ** instance of the [sqlite3_mutex_methods] structure. The + ** [sqlite3_mutex_methods] + ** structure is filled with the currently defined mutex routines.)^ + ** This option can be used to overload the default mutex allocation + ** routines with a wrapper used to track mutex usage for performance + ** profiling or testing, for example. ^If SQLite is compiled with + ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then + ** the entire mutexing subsystem is omitted from the build and hence calls to + ** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will + ** return [SQLITE_ERROR].
+ ** + ** [[SQLITE_CONFIG_LOOKASIDE]]
SQLITE_CONFIG_LOOKASIDE
+ **
^(This option takes two arguments that determine the default + ** memory allocation for the lookaside memory allocator on each + ** [database connection]. The first argument is the + ** size of each lookaside buffer slot and the second is the number of + ** slots allocated to each database connection.)^ ^(This option sets the + ** default lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE] + ** verb to [sqlite3_db_config()] can be used to change the lookaside + ** configuration on individual connections.)^
+ ** + ** [[SQLITE_CONFIG_PCACHE]]
SQLITE_CONFIG_PCACHE
+ **
^(This option takes a single argument which is a pointer to + ** an [sqlite3_pcache_methods] object. This object specifies the interface + ** to a custom page cache implementation.)^ ^SQLite makes a copy of the + ** object and uses it for page cache memory allocations.
+ ** + ** [[SQLITE_CONFIG_GETPCACHE]]
SQLITE_CONFIG_GETPCACHE
+ **
^(This option takes a single argument which is a pointer to an + ** [sqlite3_pcache_methods] object. SQLite copies of the current + ** page cache implementation into that object.)^
+ ** + ** [[SQLITE_CONFIG_LOG]]
SQLITE_CONFIG_LOG
+ **
^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a + ** function with a call signature of void()(void*,int,const char), + ** and a pointer to void. ^If the function pointer is not NULL, it is + ** invoked by [sqlite3_log()] to process each logging event. ^If the + ** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op. + ** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is + ** passed through as the first parameter to the application-defined logger + ** function whenever that function is invoked. ^The second parameter to + ** the logger function is a copy of the first parameter to the corresponding + ** [sqlite3_log()] call and is intended to be a [result code] or an + ** [extended result code]. ^The third parameter passed to the logger is + ** log message after formatting via [sqlite3_snprintf()]. + ** The SQLite logging interface is not reentrant; the logger function + ** 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 + ** URI handling is globally enabled. If the parameter is zero, then URI handling + ** 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 + ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the + ** 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. + **
+ */ + //#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ + //#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ + //#define SQLITE_CONFIG_SERIALIZED 3 /* nil */ + //#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ + //#define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ + //#define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */ + //#define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */ + //#define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */ + //#define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */ + //#define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */ + //#define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */ + ///* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ + //#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ + //#define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */ + //#define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */ + //#define SQLITE_CONFIG_LOG 16 /* xFunc, void* */ + //#define SQLITE_CONFIG_URI 17 /* int */ + public const int SQLITE_CONFIG_SINGLETHREAD = 1; + public const int SQLITE_CONFIG_MULTITHREAD = 2; + public const int SQLITE_CONFIG_SERIALIZED = 3; + public const int SQLITE_CONFIG_MALLOC = 4; + public const int SQLITE_CONFIG_GETMALLOC = 5; + public const int SQLITE_CONFIG_SCRATCH = 6; + public const int SQLITE_CONFIG_PAGECACHE = 7; + public const int SQLITE_CONFIG_HEAP = 8; + public const int SQLITE_CONFIG_MEMSTATUS = 9; + public const int SQLITE_CONFIG_MUTEX = 10; + public const int SQLITE_CONFIG_GETMUTEX = 11; + public const int SQLITE_CONFIG_LOOKASIDE = 13; + public const int SQLITE_CONFIG_PCACHE = 14; + public const int SQLITE_CONFIG_GETPCACHE = 15; + public const int SQLITE_CONFIG_LOG = 16; + public const int SQLITE_CONFIG_URI = 17; + + /* + ** CAPI3REF: Database Connection Configuration Options + ** + ** These constants are the available integer configuration options that + ** can be passed as the second argument to the [sqlite3_db_config()] interface. + ** + ** New configuration options may be added in future releases of SQLite. + ** Existing configuration options might be discontinued. Applications + ** should check the return code from [sqlite3_db_config()] to make sure that + ** the call worked. ^The [sqlite3_db_config()] interface will return a + ** non-zero [error code] if a discontinued or unsupported configuration option + ** is invoked. + ** + **
+ **
SQLITE_DBCONFIG_LOOKASIDE
+ **
^This option takes three additional arguments that determine the + ** [lookaside memory allocator] configuration for the [database connection]. + ** ^The first argument (the third parameter to [sqlite3_db_config()] is a + ** pointer to a memory buffer to use for lookaside memory. + ** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb + ** may be NULL in which case SQLite will allocate the + ** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the + ** size of each lookaside buffer slot. ^The third argument is the number of + ** slots. The size of the buffer in the first argument must be greater than + ** or equal to the product of the second and third arguments. The buffer + ** must be aligned to an 8-byte boundary. ^If the second argument to + ** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally + ** rounded down to the next smaller multiple of 8. ^(The lookaside memory + ** configuration for a database connection can only be changed when that + ** connection is not currently using lookaside memory, or in other words + ** when the "current value" returned by + ** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero. + ** Any attempt to change the lookaside memory configuration when lookaside + ** memory is in use leaves the configuration unchanged and returns + ** [SQLITE_BUSY].)^
+ ** + **
SQLITE_DBCONFIG_ENABLE_FKEY
+ **
^This option is used to enable or disable the enforcement of + ** [foreign key constraints]. There should be two additional arguments. + ** The first argument is an integer which is 0 to disable FK enforcement, + ** positive to enable FK enforcement or negative to leave FK enforcement + ** unchanged. The second parameter is a pointer to an integer into which + ** is written 0 or 1 to indicate whether FK enforcement is off or on + ** following this call. The second parameter may be a NULL pointer, in + ** which case the FK enforcement setting is not reported back.
+ ** + **
SQLITE_DBCONFIG_ENABLE_TRIGGER
+ **
^This option is used to enable or disable [CREATE TRIGGER | triggers]. + ** There should be two additional arguments. + ** The first argument is an integer which is 0 to disable triggers, + ** positive to enable triggers or negative to leave the setting unchanged. + ** The second parameter is a pointer to an integer into which + ** is written 0 or 1 to indicate whether triggers are disabled or enabled + ** following this call. The second parameter may be a NULL pointer, in + ** which case the trigger setting is not reported back.
+ ** + **
+ */ + //#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ + //#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */ + //#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */ + const int SQLITE_DBCONFIG_LOOKASIDE = 1001; + const int SQLITE_DBCONFIG_ENABLE_FKEY = 1002; + const int SQLITE_DBCONFIG_ENABLE_TRIGGER = 1003; + + /* + ** CAPI3REF: Enable Or Disable Extended Result Codes + ** + ** ^The sqlite3_extended_result_codes() routine enables or disables the + ** [extended result codes] feature of SQLite. ^The extended result + ** codes are disabled by default for historical compatibility. + */ + //SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff); + + /* + ** CAPI3REF: Last Insert Rowid + ** + ** ^Each entry in an SQLite table has a unique 64-bit signed + ** integer key called the [ROWID | "rowid"]. ^The rowid is always available + ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those + ** names are not also used by explicitly declared columns. ^If + ** the table has a column of type [INTEGER PRIMARY KEY] then that column + ** is another alias for the rowid. + ** + ** ^This routine returns the [rowid] of the most recent + ** successful [INSERT] into the database from the [database connection] + ** in the first argument. ^As of SQLite version 3.7.7, this routines + ** records the last insert rowid of both ordinary tables and [virtual tables]. + ** ^If no successful [INSERT]s + ** have ever occurred on that database connection, zero is returned. + ** + ** ^(If an [INSERT] occurs within a trigger or within a [virtual table] + ** method, then this routine will return the [rowid] of the inserted + ** row as long as the trigger or virtual table method is running. + ** But once the trigger or virtual table method ends, the value returned + ** by this routine reverts to what it was before the trigger or virtual + ** table method began.)^ + ** + ** ^An [INSERT] that fails due to a constraint violation is not a + ** successful [INSERT] and does not change the value returned by this + ** routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK, + ** and INSERT OR ABORT make no changes to the return value of this + ** routine when their insertion fails. ^(When INSERT OR REPLACE + ** encounters a constraint violation, it does not fail. The + ** INSERT continues to completion after deleting rows that caused + ** the constraint problem so INSERT OR REPLACE will always change + ** the return value of this interface.)^ + ** + ** ^For the purposes of this routine, an [INSERT] is considered to + ** be successful even if it is subsequently rolled back. + ** + ** This function is accessible to SQL statements via the + ** [last_insert_rowid() SQL function]. + ** + ** If a separate thread performs a new [INSERT] on the same + ** database connection while the [sqlite3_last_insert_rowid()] + ** function is running and thus changes the last insert [rowid], + ** then the value returned by [sqlite3_last_insert_rowid()] is + ** unpredictable and might not equal either the old or the new + ** last insert [rowid]. + */ + //SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3); + + /* + ** CAPI3REF: Count The Number Of Rows Modified + ** + ** ^This function returns the number of database rows that were changed + ** or inserted or deleted by the most recently completed SQL statement + ** on the [database connection] specified by the first parameter. + ** ^(Only changes that are directly specified by the [INSERT], [UPDATE], + ** or [DELETE] statement are counted. Auxiliary changes caused by + ** triggers or [foreign key actions] are not counted.)^ Use the + ** [sqlite3_total_changes()] function to find the total number of changes + ** including changes caused by triggers and foreign key actions. + ** + ** ^Changes to a view that are simulated by an [INSTEAD OF trigger] + ** are not counted. Only real table changes are counted. + ** + ** ^(A "row change" is a change to a single row of a single table + ** caused by an INSERT, DELETE, or UPDATE statement. Rows that + ** are changed as side effects of [REPLACE] constraint resolution, + ** rollback, ABORT processing, [DROP TABLE], or by any other + ** mechanisms do not count as direct row changes.)^ + ** + ** A "trigger context" is a scope of execution that begins and + ** ends with the script of a [CREATE TRIGGER | trigger]. + ** Most SQL statements are + ** evaluated outside of any trigger. This is the "top level" + ** trigger context. If a trigger fires from the top level, a + ** new trigger context is entered for the duration of that one + ** trigger. Subtriggers create subcontexts for their duration. + ** + ** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does + ** not create a new trigger context. + ** + ** ^This function returns the number of direct row changes in the + ** most recent INSERT, UPDATE, or DELETE statement within the same + ** trigger context. + ** + ** ^Thus, when called from the top level, this function returns the + ** number of changes in the most recent INSERT, UPDATE, or DELETE + ** that also occurred at the top level. ^(Within the body of a trigger, + ** the sqlite3_changes() interface can be called to find the number of + ** changes in the most recently completed INSERT, UPDATE, or DELETE + ** statement within the body of the same trigger. + ** However, the number returned does not include changes + ** caused by subtriggers since those have their own context.)^ + ** + ** See also the [sqlite3_total_changes()] interface, the + ** [count_changes pragma], and the [changes() SQL function]. + ** + ** If a separate thread makes changes on the same database connection + ** while [sqlite3_changes()] is running then the value returned + ** is unpredictable and not meaningful. + */ + //SQLITE_API int sqlite3_changes(sqlite3); + + /* + ** CAPI3REF: Total Number Of Rows Modified + ** + ** ^This function returns the number of row changes caused by [INSERT], + ** [UPDATE] or [DELETE] statements since the [database connection] was opened. + ** ^(The count returned by sqlite3_total_changes() includes all changes + ** from all [CREATE TRIGGER | trigger] contexts and changes made by + ** [foreign key actions]. However, + ** the count does not include changes used to implement [REPLACE] constraints, + ** do rollbacks or ABORT processing, or [DROP TABLE] processing. The + ** count does not include rows of views that fire an [INSTEAD OF trigger], + ** though if the INSTEAD OF trigger makes changes of its own, those changes + ** are counted.)^ + ** ^The sqlite3_total_changes() function counts the changes as soon as + ** the statement that makes them is completed (when the statement handle + ** is passed to [sqlite3_reset()] or [sqlite3_finalize()]). + ** + ** See also the [sqlite3_changes()] interface, the + ** [count_changes pragma], and the [total_changes() SQL function]. + ** + ** If a separate thread makes changes on the same database connection + ** while [sqlite3_total_changes()] is running then the value + ** returned is unpredictable and not meaningful. + */ + //SQLITE_API int sqlite3_total_changes(sqlite3); + + /* + ** CAPI3REF: Interrupt A Long-Running Query + ** + ** ^This function causes any pending database operation to abort and + ** return at its earliest opportunity. This routine is typically + ** called in response to a user action such as pressing "Cancel" + ** or Ctrl-C where the user wants a long query operation to halt + ** immediately. + ** + ** ^It is safe to call this routine from a thread different from the + ** thread that is currently running the database operation. But it + ** is not safe to call this routine with a [database connection] that + ** is closed or might close before sqlite3_interrupt() returns. + ** + ** ^If an SQL operation is very nearly finished at the time when + ** sqlite3_interrupt() is called, then it might not have an opportunity + ** to be interrupted and might continue to completion. + ** + ** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT]. + ** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE + ** that is inside an explicit transaction, then the entire transaction + ** will be rolled back automatically. + ** + ** ^The sqlite3_interrupt(D) call is in effect until all currently running + ** SQL statements on [database connection] D complete. ^Any new SQL statements + ** that are started after the sqlite3_interrupt() call and before the + ** running statements reaches zero are interrupted as if they had been + ** running prior to the sqlite3_interrupt() call. ^New SQL statements + ** that are started after the running statement count reaches zero are + ** not effected by the sqlite3_interrupt(). + ** ^A call to sqlite3_interrupt(D) that occurs when there are no running + ** SQL statements is a no-op and has no effect on SQL statements + ** that are started after the sqlite3_interrupt() call returns. + ** + ** If the database connection closes while [sqlite3_interrupt()] + ** is running then bad things will likely happen. + */ + //SQLITE_API void sqlite3_interrupt(sqlite3); + + /* + ** CAPI3REF: Determine If An SQL Statement Is Complete + ** + ** These routines are useful during command-line input to determine if the + ** currently entered text seems to form a complete SQL statement or + ** if additional input is needed before sending the text into + ** SQLite for parsing. ^These routines return 1 if the input string + ** appears to be a complete SQL statement. ^A statement is judged to be + ** complete if it ends with a semicolon token and is not a prefix of a + ** well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within + ** string literals or quoted identifier names or comments are not + ** independent tokens (they are part of the token in which they are + ** embedded) and thus do not count as a statement terminator. ^Whitespace + ** and comments that follow the final semicolon are ignored. + ** + ** ^These routines return 0 if the statement is incomplete. ^If a + ** memory allocation fails, then SQLITE_NOMEM is returned. + ** + ** ^These routines do not parse the SQL statements thus + ** will not detect syntactically incorrect SQL. + ** + ** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior + ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked + ** automatically by sqlite3_complete16(). If that initialization fails, + ** then the return value from sqlite3_complete16() will be non-zero + ** regardless of whether or not the input SQL is complete.)^ + ** + ** The input to [sqlite3_complete()] must be a zero-terminated + ** UTF-8 string. + ** + ** The input to [sqlite3_complete16()] must be a zero-terminated + ** UTF-16 string in native byte order. + */ + //SQLITE_API int sqlite3_complete(string sql); + //SQLITE_API int sqlite3_complete16(const void *sql); + + /* + ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors + ** + ** ^This routine sets a callback function that might be invoked whenever + ** an attempt is made to open a database table that another thread + ** or process has locked. + ** + ** ^If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] + ** is returned immediately upon encountering the lock. ^If the busy callback + ** is not NULL, then the callback might be invoked with two arguments. + ** + ** ^The first argument to the busy handler is a copy of the void* pointer which + ** is the third argument to sqlite3_busy_handler(). ^The second argument to + ** the busy handler callback is the number of times that the busy handler has + ** been invoked for this locking event. ^If the + ** busy callback returns 0, then no additional attempts are made to + ** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned. + ** ^If the callback returns non-zero, then another attempt + ** is made to open the database for reading and the cycle repeats. + ** + ** The presence of a busy handler does not guarantee that it will be invoked + ** when there is lock contention. ^If SQLite determines that invoking the busy + ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY] + ** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler. + ** Consider a scenario where one process is holding a read lock that + ** it is trying to promote to a reserved lock and + ** a second process is holding a reserved lock that it is trying + ** to promote to an exclusive lock. The first process cannot proceed + ** because it is blocked by the second and the second process cannot + ** proceed because it is blocked by the first. If both processes + ** invoke the busy handlers, neither will make any progress. Therefore, + ** SQLite returns [SQLITE_BUSY] for the first process, hoping that this + ** will induce the first process to release its read lock and allow + ** the second process to proceed. + ** + ** ^The default busy callback is NULL. + ** + ** ^The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED] + ** when SQLite is in the middle of a large transaction where all the + ** changes will not fit into the in-memory cache. SQLite will + ** already hold a RESERVED lock on the database file, but it needs + ** to promote this lock to EXCLUSIVE so that it can spill cache + ** pages into the database file without harm to concurrent + ** readers. ^If it is unable to promote the lock, then the in-memory + ** cache will be left in an inconsistent state and so the error + ** code is promoted from the relatively benign [SQLITE_BUSY] to + ** the more severe [SQLITE_IOERR_BLOCKED]. ^This error code promotion + ** forces an automatic rollback of the changes. See the + ** + ** CorruptionFollowingBusyError wiki page for a discussion of why + ** this is important. + ** + ** ^(There can only be a single busy handler defined for each + ** [database connection]. Setting a new busy handler clears any + ** previously set handler.)^ ^Note that calling [sqlite3_busy_timeout()] + ** will also set or clear the busy handler. + ** + ** The busy callback should not take any actions which modify the + ** database connection that invoked the busy handler. Any such actions + ** result in undefined behavior. + ** + ** A busy handler must not close the database connection + ** or [prepared statement] that invoked the busy handler. + */ + //SQLITE_API int sqlite3_busy_handler(sqlite3*, int()(void*,int), void); + + /* + ** CAPI3REF: Set A Busy Timeout + ** + ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps + ** for a specified amount of time when a table is locked. ^The handler + ** will sleep multiple times until at least "ms" milliseconds of sleeping + ** have accumulated. ^After at least "ms" milliseconds of sleeping, + ** the handler returns 0 which causes [sqlite3_step()] to return + ** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]. + ** + ** ^Calling this routine with an argument less than or equal to zero + ** turns off all busy handlers. + ** + ** ^(There can only be a single busy handler for a particular + ** [database connection] any any given moment. If another busy handler + ** was defined (using [sqlite3_busy_handler()]) prior to calling + ** this routine, that other busy handler is cleared.)^ + */ + //SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms); + + /* + ** CAPI3REF: Convenience Routines For Running Queries + ** + ** This is a legacy interface that is preserved for backwards compatibility. + ** Use of this interface is not recommended. + ** + ** Definition: A result table is memory data structure created by the + ** [sqlite3_get_table()] interface. A result table records the + ** complete query results from one or more queries. + ** + ** The table conceptually has a number of rows and columns. But + ** these numbers are not part of the result table itself. These + ** numbers are obtained separately. Let N be the number of rows + ** and M be the number of columns. + ** + ** A result table is an array of pointers to zero-terminated UTF-8 strings. + ** There are (N+1)*M elements in the array. The first M pointers point + ** to zero-terminated strings that contain the names of the columns. + ** The remaining entries all point to query results. NULL values result + ** in NULL pointers. All other values are in their UTF-8 zero-terminated + ** string representation as returned by [sqlite3_column_text()]. + ** + ** A result table might consist of one or more memory allocations. + ** It is not safe to pass a result table directly to [sqlite3_free()]. + ** A result table should be deallocated using [sqlite3_free_table()]. + ** + ** ^(As an example of the result table format, suppose a query result + ** is as follows: + ** + **
+        **        Name        | Age
+        **        -----------------------
+        **        Alice       | 43
+        **        Bob         | 28
+        **        Cindy       | 21
+        ** 
+ ** + ** There are two column (M==2) and three rows (N==3). Thus the + ** result table has 8 entries. Suppose the result table is stored + ** in an array names azResult. Then azResult holds this content: + ** + **
+        **        azResult[0] = "Name";
+        **        azResult[1] = "Age";
+        **        azResult[2] = "Alice";
+        **        azResult[3] = "43";
+        **        azResult[4] = "Bob";
+        **        azResult[5] = "28";
+        **        azResult[6] = "Cindy";
+        **        azResult[7] = "21";
+        ** 
)^ + ** + ** ^The sqlite3_get_table() function evaluates one or more + ** semicolon-separated SQL statements in the zero-terminated UTF-8 + ** string of its 2nd parameter and returns a result table to the + ** pointer given in its 3rd parameter. + ** + ** After the application has finished with the result from sqlite3_get_table(), + ** it must pass the result table pointer to sqlite3_free_table() in order to + ** release the memory that was malloced. Because of the way the + ** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling + ** function must not try to call [sqlite3_free()] directly. Only + ** [sqlite3_free_table()] is able to release the memory properly and safely. + ** + ** The sqlite3_get_table() interface is implemented as a wrapper around + ** [sqlite3_exec()]. The sqlite3_get_table() routine does not have access + ** to any internal data structures of SQLite. It uses only the public + ** interface defined here. As a consequence, errors that occur in the + ** wrapper layer outside of the internal [sqlite3_exec()] call are not + ** reflected in subsequent calls to [sqlite3_errcode()] or + ** [sqlite3_errmsg()]. + */ + //SQLITE_API int sqlite3_get_table( + // sqlite3 db, /* An open database */ + // string zSql, /* SQL to be evaluated */ + // char ***pazResult, /* Results of the query */ + // int *pnRow, /* Number of result rows written here */ + // int *pnColumn, /* Number of result columns written here */ + // char **pzErrmsg /* Error msg written here */ + //); + //SQLITE_API void sqlite3_free_table(char **result); + + /* + ** CAPI3REF: Formatted String Printing Functions + ** + ** These routines are work-alikes of the "printf()" family of functions + ** from the standard C library. + ** + ** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their + ** results into memory obtained from [sqlite3_malloc()]. + ** The strings returned by these two routines should be + ** released by [sqlite3_free()]. ^Both routines return a + ** NULL pointer if [sqlite3_malloc()] is unable to allocate enough + ** memory to hold the resulting string. + ** + ** ^(The sqlite3_snprintf() routine is similar to "snprintf()" from + ** the standard C library. The result is written into the + ** buffer supplied as the second parameter whose size is given by + ** the first parameter. Note that the order of the + ** first two parameters is reversed from snprintf().)^ This is an + ** historical accident that cannot be fixed without breaking + ** backwards compatibility. ^(Note also that sqlite3_snprintf() + ** returns a pointer to its buffer instead of the number of + ** characters actually written into the buffer.)^ We admit that + ** the number of characters written would be a more useful return + ** value but we cannot change the implementation of sqlite3_snprintf() + ** now without breaking compatibility. + ** + ** ^As long as the buffer size is greater than zero, sqlite3_snprintf() + ** guarantees that the buffer is always zero-terminated. ^The first + ** parameter "n" is the total size of the buffer, including space for + ** the zero terminator. So the longest string that can be completely + ** written will be n-1 characters. + ** + ** ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf(). + ** + ** These routines all implement some additional formatting + ** options that are useful for constructing SQL statements. + ** All of the usual printf() formatting options apply. In addition, there + ** is are "%q", "%Q", and "%z" options. + ** + ** ^(The %q option works like %s in that it substitutes a null-terminated + ** string from the argument list. But %q also doubles every '\'' character. + ** %q is designed for use inside a string literal.)^ By doubling each '\'' + ** character it escapes that character and allows it to be inserted into + ** the string. + ** + ** For example, assume the string variable zText contains text as follows: + ** + **
+        **  string zText = "It's a happy day!";
+        ** 
+ ** + ** One can use this text in an SQL statement as follows: + ** + **
+        **  string zSQL = sqlite3_mprintf("INSERT INTO table VALUES('%q')", zText);
+        **  sqlite3_exec(db, zSQL, 0, 0, 0);
+        **  sqlite3_free(zSQL);
+        ** 
+ ** + ** Because the %q format string is used, the '\'' character in zText + ** is escaped and the SQL generated is as follows: + ** + **
+        **  INSERT INTO table1 VALUES('It''s a happy day!')
+        ** 
+ ** + ** This is correct. Had we used %s instead of %q, the generated SQL + ** would have looked like this: + ** + **
+        **  INSERT INTO table1 VALUES('It's a happy day!');
+        ** 
+ ** + ** This second example is an SQL syntax error. As a general rule you should + ** always use %q instead of %s when inserting text into a string literal. + ** + ** ^(The %Q option works like %q except it also adds single quotes around + ** the outside of the total string. Additionally, if the parameter in the + ** argument list is a NULL pointer, %Q substitutes the text "NULL" (without + ** single quotes).)^ So, for example, one could say: + ** + **
+        **  string zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
+        **  sqlite3_exec(db, zSQL, 0, 0, 0);
+        **  sqlite3_free(zSQL);
+        ** 
+ ** + ** The code above will render a correct SQL statement in the zSQL + ** variable even if the zText variable is a NULL pointer. + ** + ** ^(The "%z" formatting option works like "%s" but with the + ** addition that after the string has been read and copied into + ** the result, [sqlite3_free()] is called on the input string.)^ + */ + //SQLITE_API char *sqlite3_mprintf(const char*,...); + //SQLITE_API char *sqlite3_vmprintf(const char*, va_list); + //SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...); + //SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list); + + + /* + ** CAPI3REF: Memory Allocation Subsystem + ** + ** The SQLite core uses these three routines for all of its own + ** internal memory allocation needs. "Core" in the previous sentence + ** does not include operating-system specific VFS implementation. The + ** Windows VFS uses native malloc() and free() for some operations. + ** + ** ^The sqlite3_malloc() routine returns a pointer to a block + ** of memory at least N bytes in length, where N is the parameter. + ** ^If sqlite3_malloc() is unable to obtain sufficient free + ** memory, it returns a NULL pointer. ^If the parameter N to + ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns + ** a NULL pointer. + ** + ** ^Calling sqlite3_free() with a pointer previously returned + ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so + ** that it might be reused. ^The sqlite3_free() routine is + ** a no-op if is called with a NULL pointer. Passing a NULL pointer + ** to sqlite3_free() is harmless. After being freed, memory + ** should neither be read nor written. Even reading previously freed + ** memory might result in a segmentation fault or other severe error. + ** Memory corruption, a segmentation fault, or other severe error + ** might result if sqlite3_free() is called with a non-NULL pointer that + ** was not obtained from sqlite3_malloc() or sqlite3_realloc(). + ** + ** ^(The sqlite3_realloc() interface attempts to resize a + ** prior memory allocation to be at least N bytes, where N is the + ** second parameter. The memory allocation to be resized is the first + ** parameter.)^ ^ If the first parameter to sqlite3_realloc() + ** is a NULL pointer then its behavior is identical to calling + ** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc(). + ** ^If the second parameter to sqlite3_realloc() is zero or + ** negative then the behavior is exactly the same as calling + ** sqlite3_free(P) where P is the first parameter to sqlite3_realloc(). + ** ^sqlite3_realloc() returns a pointer to a memory allocation + ** of at least N bytes in size or NULL if sufficient memory is unavailable. + ** ^If M is the size of the prior allocation, then min(N,M) bytes + ** of the prior allocation are copied into the beginning of buffer returned + ** by sqlite3_realloc() and the prior allocation is freed. + ** ^If sqlite3_realloc() returns NULL, then the prior allocation + ** is not freed. + ** + ** ^The memory returned by sqlite3_malloc() and sqlite3_realloc() + ** is always aligned to at least an 8 byte boundary, or to a + ** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time + ** option is used. + ** + ** In SQLite version 3.5.0 and 3.5.1, it was possible to define + ** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in + ** implementation of these routines to be omitted. That capability + ** is no longer provided. Only built-in memory allocators can be used. + ** + ** The Windows OS interface layer calls + ** the system malloc() and free() directly when converting + ** filenames between the UTF-8 encoding used by SQLite + ** and whatever filename encoding is used by the particular Windows + ** installation. Memory allocation errors are detected, but + ** they are reported back as [SQLITE_CANTOPEN] or + ** [SQLITE_IOERR] rather than [SQLITE_NOMEM]. + ** + ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()] + ** must be either NULL or else pointers obtained from a prior + ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have + ** not yet been released. + ** + ** The application must not read or write any part of + ** a block of memory after it has been released using + ** [sqlite3_free()] or [sqlite3_realloc()]. + */ + //SQLITE_API void *sqlite3_malloc(int); + //SQLITE_API void *sqlite3_realloc(void*, int); + //SQLITE_API void sqlite3_free(void); + + /* + ** CAPI3REF: Memory Allocator Statistics + ** + ** SQLite provides these two interfaces for reporting on the status + ** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()] + ** routines, which form the built-in memory allocation subsystem. + ** + ** ^The [sqlite3_memory_used()] routine returns the number of bytes + ** of memory currently outstanding (malloced but not freed). + ** ^The [sqlite3_memory_highwater()] routine returns the maximum + ** value of [sqlite3_memory_used()] since the high-water mark + ** was last reset. ^The values returned by [sqlite3_memory_used()] and + ** [sqlite3_memory_highwater()] include any overhead + ** added by SQLite in its implementation of [sqlite3_malloc()], + ** but not overhead added by the any underlying system library + ** routines that [sqlite3_malloc()] may call. + ** + ** ^The memory high-water mark is reset to the current value of + ** [sqlite3_memory_used()] if and only if the parameter to + ** [sqlite3_memory_highwater()] is true. ^The value returned + ** by [sqlite3_memory_highwater(1)] is the high-water mark + ** prior to the reset. + */ + //SQLITE_API sqlite3_int64 sqlite3_memory_used(void); + //SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag); + + /* + ** CAPI3REF: Pseudo-Random Number Generator + ** + ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to + ** select random [ROWID | ROWIDs] when inserting new records into a table that + ** already uses the largest possible [ROWID]. The PRNG is also used for + ** the build-in random() and randomblob() SQL functions. This interface allows + ** applications to access the same PRNG for other purposes. + ** + ** ^A call to this routine stores N bytes of randomness into buffer P. + ** + ** ^The first time this routine is invoked (either internally or by + ** the application) the PRNG is seeded using randomness obtained + ** from the xRandomness method of the default [sqlite3_vfs] object. + ** ^On all subsequent invocations, the pseudo-randomness is generated + ** internally and without recourse to the [sqlite3_vfs] xRandomness + ** method. + */ + //SQLITE_API void sqlite3_randomness(int N, object *P); + + /* + ** CAPI3REF: Compile-Time Authorization Callbacks + ** + ** ^This routine registers an authorizer callback with a particular + ** [database connection], supplied in the first argument. + ** ^The authorizer callback is invoked as SQL statements are being compiled + ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()], + ** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various + ** points during the compilation process, as logic is being created + ** to perform various actions, the authorizer callback is invoked to + ** see if those actions are allowed. ^The authorizer callback should + ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the + ** specific action but allow the SQL statement to continue to be + ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be + ** rejected with an error. ^If the authorizer callback returns + ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY] + ** then the [sqlite3_prepare_v2()] or equivalent call that triggered + ** the authorizer will fail with an error message. + ** + ** When the callback returns [SQLITE_OK], that means the operation + ** requested is ok. ^When the callback returns [SQLITE_DENY], the + ** [sqlite3_prepare_v2()] or equivalent call that triggered the + ** authorizer will fail with an error message explaining that + ** access is denied. + ** + ** ^The first parameter to the authorizer callback is a copy of the third + ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter + ** to the callback is an integer [SQLITE_COPY | action code] that specifies + ** the particular action to be authorized. ^The third through sixth parameters + ** to the callback are zero-terminated strings that contain additional + ** details about the action to be authorized. + ** + ** ^If the action code is [SQLITE_READ] + ** and the callback returns [SQLITE_IGNORE] then the + ** [prepared statement] statement is constructed to substitute + ** a NULL value in place of the table column that would have + ** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE] + ** return can be used to deny an untrusted user access to individual + ** columns of a table. + ** ^If the action code is [SQLITE_DELETE] and the callback returns + ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the + ** [truncate optimization] is disabled and all rows are deleted individually. + ** + ** An authorizer is used when [sqlite3_prepare | preparing] + ** SQL statements from an untrusted source, to ensure that the SQL statements + ** do not try to access data they are not allowed to see, or that they do not + ** try to execute malicious statements that damage the database. For + ** example, an application may allow a user to enter arbitrary + ** SQL queries for evaluation by a database. But the application does + ** not want the user to be able to make arbitrary changes to the + ** database. An authorizer could then be put in place while the + ** user-entered SQL is being [sqlite3_prepare | prepared] that + ** disallows everything except [SELECT] statements. + ** + ** Applications that need to process SQL from untrusted sources + ** might also consider lowering resource limits using [sqlite3_limit()] + ** and limiting database size using the [max_page_count] [PRAGMA] + ** in addition to using an authorizer. + ** + ** ^(Only a single authorizer can be in place on a database connection + ** at a time. Each call to sqlite3_set_authorizer overrides the + ** previous call.)^ ^Disable the authorizer by installing a NULL callback. + ** The authorizer is disabled by default. + ** + ** The authorizer callback must not do anything that will modify + ** the database connection that invoked the authorizer callback. + ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their + ** database connections for the meaning of "modify" in this paragraph. + ** + ** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the + ** statement might be re-prepared during [sqlite3_step()] due to a + ** schema change. Hence, the application should ensure that the + ** correct authorizer callback remains in place during the [sqlite3_step()]. + ** + ** ^Note that the authorizer callback is invoked only during + ** [sqlite3_prepare()] or its variants. Authorization is not + ** performed during statement evaluation in [sqlite3_step()], unless + ** as stated in the previous paragraph, sqlite3_step() invokes + ** sqlite3_prepare_v2() to reprepare a statement after a schema change. + */ + //SQLITE_API int sqlite3_set_authorizer( + // sqlite3*, + // int (*xAuth)(void*,int,const char*,const char*,const char*,const char), + // void *pUserData + //); + + /* + ** CAPI3REF: Authorizer Return Codes + ** + ** The [sqlite3_set_authorizer | authorizer callback function] must + ** return either [SQLITE_OK] or one of these two constants in order + ** to signal SQLite whether or not the action is permitted. See the + ** [sqlite3_set_authorizer | authorizer documentation] for additional + ** information. + ** + ** Note that SQLITE_IGNORE is also used as a [SQLITE_ROLLBACK | return code] + ** from the [sqlite3_vtab_on_conflict()] interface. + */ + //#define SQLITE_DENY 1 /* Abort the SQL statement with an error */ + //#define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */ + const int SQLITE_DENY = 1; + const int SQLITE_IGNORE = 2; + + /* + ** CAPI3REF: Authorizer Action Codes + ** + ** The [sqlite3_set_authorizer()] interface registers a callback function + ** that is invoked to authorize certain SQL statement actions. The + ** second parameter to the callback is an integer code that specifies + ** what action is being authorized. These are the integer action codes that + ** the authorizer callback may be passed. + ** + ** These action code values signify what kind of operation is to be + ** authorized. The 3rd and 4th parameters to the authorization + ** callback function will be parameters or NULL depending on which of these + ** codes is used as the second parameter. ^(The 5th parameter to the + ** authorizer callback is the name of the database ("main", "temp", + ** etc.) if applicable.)^ ^The 6th parameter to the authorizer callback + ** is the name of the inner-most trigger or view that is responsible for + ** the access attempt or NULL if this access attempt is directly from + ** top-level SQL code. + */ + /******************************************* 3rd ************ 4th ***********/ + //#define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */ + //#define SQLITE_CREATE_TABLE 2 /* Table Name NULL */ + //#define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */ + //#define SQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */ + //#define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */ + //#define SQLITE_CREATE_TEMP_VIEW 6 /* View Name NULL */ + //#define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */ + //#define SQLITE_CREATE_VIEW 8 /* View Name NULL */ + //#define SQLITE_DELETE 9 /* Table Name NULL */ + //#define SQLITE_DROP_INDEX 10 /* Index Name Table Name */ + //#define SQLITE_DROP_TABLE 11 /* Table Name NULL */ + //#define SQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */ + //#define SQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */ + //#define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */ + //#define SQLITE_DROP_TEMP_VIEW 15 /* View Name NULL */ + //#define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */ + //#define SQLITE_DROP_VIEW 17 /* View Name NULL */ + //#define SQLITE_INSERT 18 /* Table Name NULL */ + //#define SQLITE_PRAGMA 19 /* Pragma Name 1st arg or NULL */ + //#define SQLITE_READ 20 /* Table Name Column Name */ + //#define SQLITE_SELECT 21 /* NULL NULL */ + //#define SQLITE_TRANSACTION 22 /* Operation NULL */ + //#define SQLITE_UPDATE 23 /* Table Name Column Name */ + //#define SQLITE_ATTACH 24 /* Filename NULL */ + //#define SQLITE_DETACH 25 /* Database Name NULL */ + //#define SQLITE_ALTER_TABLE 26 /* Database Name Table Name */ + //#define SQLITE_REINDEX 27 /* Index Name NULL */ + //#define SQLITE_ANALYZE 28 /* Table Name NULL */ + //#define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */ + //#define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */ + //#define SQLITE_FUNCTION 31 /* NULL Function Name */ + //#define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */ + //#define SQLITE_COPY 0 /* No longer used */ + const int SQLITE_CREATE_INDEX = 1; + const int SQLITE_CREATE_TABLE = 2; + const int SQLITE_CREATE_TEMP_INDEX = 3; + const int SQLITE_CREATE_TEMP_TABLE = 4; + const int SQLITE_CREATE_TEMP_TRIGGER = 5; + const int SQLITE_CREATE_TEMP_VIEW = 6; + const int SQLITE_CREATE_TRIGGER = 7; + const int SQLITE_CREATE_VIEW = 8; + const int SQLITE_DELETE = 9; + const int SQLITE_DROP_INDEX = 10; + const int SQLITE_DROP_TABLE = 11; + const int SQLITE_DROP_TEMP_INDEX = 12; + const int SQLITE_DROP_TEMP_TABLE = 13; + const int SQLITE_DROP_TEMP_TRIGGER = 14; + const int SQLITE_DROP_TEMP_VIEW = 15; + const int SQLITE_DROP_TRIGGER = 16; + const int SQLITE_DROP_VIEW = 17; + const int SQLITE_INSERT = 18; + const int SQLITE_PRAGMA = 19; + const int SQLITE_READ = 20; + const int SQLITE_SELECT = 21; + const int SQLITE_TRANSACTION = 22; + const int SQLITE_UPDATE = 23; + const int SQLITE_ATTACH = 24; + const int SQLITE_DETACH = 25; + const int SQLITE_ALTER_TABLE = 26; + const int SQLITE_REINDEX = 27; + const int SQLITE_ANALYZE = 28; + const int SQLITE_CREATE_VTABLE = 29; + const int SQLITE_DROP_VTABLE = 30; + const int SQLITE_FUNCTION = 31; + const int SQLITE_SAVEPOINT = 32; + const int SQLITE_COPY = 0; + + /* + ** CAPI3REF: Tracing And Profiling Functions + ** + ** These routines register callback functions that can be used for + ** tracing and profiling the execution of SQL statements. + ** + ** ^The callback function registered by sqlite3_trace() is invoked at + ** various times when an SQL statement is being run by [sqlite3_step()]. + ** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the + ** SQL statement text as the statement first begins executing. + ** ^(Additional sqlite3_trace() callbacks might occur + ** as each triggered subprogram is entered. The callbacks for triggers + ** contain a UTF-8 SQL comment that identifies the trigger.)^ + ** + ** ^The callback function registered by sqlite3_profile() is invoked + ** as each SQL statement finishes. ^The profile callback contains + ** the original statement text and an estimate of wall-clock time + ** of how long that statement took to run. ^The profile callback + ** time is in units of nanoseconds, however the current implementation + ** is only capable of millisecond resolution so the six least significant + ** digits in the time are meaningless. Future versions of SQLite + ** might provide greater resolution on the profiler callback. The + ** sqlite3_profile() function is considered experimental and is + ** subject to change in future versions of SQLite. + */ + //SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char), void); + //SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*, + // void(*xProfile)(void*,const char*,sqlite3_uint64), void); + + /* + ** CAPI3REF: Query Progress Callbacks + ** + ** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback + ** function X to be invoked periodically during long running calls to + ** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for + ** database connection D. An example use for this + ** interface is to keep a GUI updated during a large query. + ** + ** ^The parameter P is passed through as the only parameter to the + ** callback function X. ^The parameter N is the number of + ** [virtual machine instructions] that are evaluated between successive + ** invocations of the callback X. + ** + ** ^Only a single progress handler may be defined at one time per + ** [database connection]; setting a new progress handler cancels the + ** old one. ^Setting parameter X to NULL disables the progress handler. + ** ^The progress handler is also disabled by setting N to a value less + ** than 1. + ** + ** ^If the progress callback returns non-zero, the operation is + ** interrupted. This feature can be used to implement a + ** "Cancel" button on a GUI progress dialog box. + ** + ** The progress handler callback must not do anything that will modify + ** the database connection that invoked the progress handler. + ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their + ** database connections for the meaning of "modify" in this paragraph. + ** + */ + //SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int()(void), void); + + /* + ** CAPI3REF: Opening A New Database Connection + ** + ** ^These routines open an SQLite database file as specified by the + ** filename argument. ^The filename argument is interpreted as UTF-8 for + ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte + ** order for sqlite3_open16(). ^(A [database connection] handle is usually + ** returned in *ppDb, even if an error occurs. The only exception is that + ** if SQLite is unable to allocate memory to hold the [sqlite3] object, + ** a NULL will be written into *ppDb instead of a pointer to the [sqlite3] + ** object.)^ ^(If the database is opened (and/or created) successfully, then + ** [SQLITE_OK] is returned. Otherwise an [error code] is returned.)^ ^The + ** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain + ** an English language description of the error following a failure of any + ** of the sqlite3_open() routines. + ** + ** ^The default encoding for the database will be UTF-8 if + ** sqlite3_open() or sqlite3_open_v2() is called and + ** UTF-16 in the native byte order if sqlite3_open16() is used. + ** + ** Whether or not an error occurs when it is opened, resources + ** associated with the [database connection] handle should be released by + ** passing it to [sqlite3_close()] when it is no longer required. + ** + ** The sqlite3_open_v2() interface works like sqlite3_open() + ** except that it accepts two additional parameters for additional control + ** over the new database connection. ^(The flags parameter to + ** sqlite3_open_v2() can take one of + ** the following three values, optionally combined with the + ** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE], + ** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^ + ** + **
+ ** ^(
[SQLITE_OPEN_READONLY]
+ **
The database is opened in read-only mode. If the database does not + ** already exist, an error is returned.
)^ + ** + ** ^(
[SQLITE_OPEN_READWRITE]
+ **
The database is opened for reading and writing if possible, or reading + ** only if the file is write protected by the operating system. In either + ** case the database must already exist, otherwise an error is returned.
)^ + ** + ** ^(
[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]
+ **
The database is opened for reading and writing, and is created if + ** it does not already exist. This is the behavior that is always used for + ** sqlite3_open() and sqlite3_open16().
)^ + **
+ ** + ** If the 3rd parameter to sqlite3_open_v2() is not one of the + ** combinations shown above optionally combined with other + ** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits] + ** then the behavior is undefined. + ** + ** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection + ** opens in the multi-thread [threading mode] as long as the single-thread + ** mode has not been set at compile-time or start-time. ^If the + ** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens + ** in the serialized [threading mode] unless single-thread was + ** previously selected at compile-time or start-time. + ** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be + ** eligible to use [shared cache mode], regardless of whether or not shared + ** cache is enabled using [sqlite3_enable_shared_cache()]. ^The + ** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not + ** participate in [shared cache mode] even if it is enabled. + ** + ** ^The fourth parameter to sqlite3_open_v2() is the name of the + ** [sqlite3_vfs] object that defines the operating system interface that + ** the new database connection should use. ^If the fourth parameter is + ** a NULL pointer then the default [sqlite3_vfs] object is used. + ** + ** ^If the filename is ":memory:", then a private, temporary in-memory database + ** is created for the connection. ^This in-memory database will vanish when + ** the database connection is closed. Future versions of SQLite might + ** make use of additional special filenames that begin with the ":" character. + ** It is recommended that when a database filename actually does begin with + ** a ":" character you should prefix the filename with a pathname such as + ** "./" to avoid ambiguity. + ** + ** ^If the filename is an empty string, then a private, temporary + ** on-disk database will be created. ^This private database will be + ** automatically deleted as soon as the database connection is closed. + ** + ** [[URI filenames in sqlite3_open()]]

URI Filenames

+ ** + ** ^If [URI filename] interpretation is enabled, and the filename argument + ** begins with "file:", then the filename is interpreted as a URI. ^URI + ** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is + ** set in the fourth argument to sqlite3_open_v2(), or if it has + ** been enabled globally using the [SQLITE_CONFIG_URI] option with the + ** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option. + ** As of SQLite version 3.7.7, URI filename interpretation is turned off + ** by default, but future releases of SQLite might enable URI filename + ** interpretation by default. See "[URI filenames]" for additional + ** information. + ** + ** URI filenames are parsed according to RFC 3986. ^If the URI contains an + ** authority, then it must be either an empty string or the string + ** "localhost". ^If the authority is not an empty string or "localhost", an + ** error is returned to the caller. ^The fragment component of a URI, if + ** present, is ignored. + ** + ** ^SQLite uses the path component of the URI as the name of the disk file + ** which contains the database. ^If the path begins with a '/' character, + ** then it is interpreted as an absolute path. ^If the path does not begin + ** with a '/' (meaning that the authority section is omitted from the URI) + ** then the path is interpreted as a relative path. + ** ^On windows, the first component of an absolute path + ** is a drive specification (e.g. "C:"). + ** + ** [[core URI query parameters]] + ** The query component of a URI may contain parameters that are interpreted + ** either by SQLite itself, or by a [VFS | custom VFS implementation]. + ** SQLite interprets the following three query parameters: + ** + **
    + **
  • vfs: ^The "vfs" parameter may be used to specify the name of + ** a VFS object that provides the operating system interface that should + ** be used to access the database file on disk. ^If this option is set to + ** an empty string the default VFS object is used. ^Specifying an unknown + ** VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is + ** present, then the VFS specified by the option takes precedence over + ** the value passed as the fourth parameter to sqlite3_open_v2(). + ** + **
  • mode: ^(The mode parameter may be set to either "ro", "rw" or + ** "rwc". Attempting to set it to any other value is an error)^. + ** ^If "ro" is specified, then the database is opened for read-only + ** access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the + ** third argument to sqlite3_prepare_v2(). ^If the mode option is set to + ** "rw", then the database is opened for read-write (but not create) + ** access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had + ** been set. ^Value "rwc" is equivalent to setting both + ** SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE. ^If sqlite3_open_v2() is + ** used, it is an error to specify a value for the mode parameter that is + ** less restrictive than that specified by the flags passed as the third + ** parameter. + ** + **
  • cache: ^The cache parameter may be set to either "shared" or + ** "private". ^Setting it to "shared" is equivalent to setting the + ** SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to + ** sqlite3_open_v2(). ^Setting the cache parameter to "private" is + ** equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit. + ** ^If sqlite3_open_v2() is used and the "cache" parameter is present in + ** a URI filename, its value overrides any behaviour requested by setting + ** SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag. + **
+ ** + ** ^Specifying an unknown parameter in the query component of a URI is not an + ** error. Future versions of SQLite might understand additional query + ** parameters. See "[query parameters with special meaning to SQLite]" for + ** additional information. + ** + ** [[URI filename examples]]

URI filename examples

+ ** + ** + **
URI filenames Results + **
file:data.db + ** Open the file "data.db" in the current directory. + **
file:/home/fred/data.db
+ ** file:///home/fred/data.db
+ ** file://localhost/home/fred/data.db
+ ** Open the database file "/home/fred/data.db". + **
file://darkstar/home/fred/data.db + ** An error. "darkstar" is not a recognized authority. + **
+ ** file:///C:/Documents%20and%20Settings/fred/Desktop/data.db + ** Windows only: Open the file "data.db" on fred's desktop on drive + ** C:. Note that the %20 escaping in this example is not strictly + ** necessary - space characters can be used literally + ** in URI filenames. + **
file:data.db?mode=ro&cache=private + ** Open file "data.db" in the current directory for read-only access. + ** Regardless of whether or not shared-cache mode is enabled by + ** default, use a private cache. + **
file:/home/fred/data.db?vfs=unix-nolock + ** Open file "/home/fred/data.db". Use the special VFS "unix-nolock". + **
file:data.db?mode=readonly + ** An error. "readonly" is not a valid option for the "mode" parameter. + **
+ ** + ** ^URI hexadecimal escape sequences (%HH) are supported within the path and + ** query components of a URI. A hexadecimal escape sequence consists of a + ** percent sign - "%" - followed by exactly two hexadecimal digits + ** specifying an octet value. ^Before the path or query components of a + ** URI filename are interpreted, they are encoded using UTF-8 and all + ** hexadecimal escape sequences replaced by a single byte containing the + ** corresponding octet. If this process generates an invalid UTF-8 encoding, + ** the results are undefined. + ** + ** Note to Windows users: The encoding used for the filename argument + ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever + ** codepage is currently defined. Filenames containing international + ** characters must be converted to UTF-8 prior to passing them into + ** sqlite3_open() or sqlite3_open_v2(). + */ + //SQLITE_API int sqlite3_open( + // string filename, /* Database filename (UTF-8) */ + // sqlite3 **ppDb /* OUT: SQLite db handle */ + //); + //SQLITE_API int sqlite3_open16( + // const void *filename, /* Database filename (UTF-16) */ + // sqlite3 **ppDb /* OUT: SQLite db handle */ + //); + //SQLITE_API int sqlite3_open_v2( + // string filename, /* Database filename (UTF-8) */ + // sqlite3 **ppDb, /* OUT: SQLite db handle */ + // int flags, /* Flags */ + // string zVfs /* Name of VFS module to use */ + //); + + /* + ** CAPI3REF: Obtain Values For URI Parameters + ** + ** This is a utility routine, useful to VFS implementations, that checks + ** to see if a database file was a URI that contained a specific query + ** parameter, and if so obtains the value of the query parameter. + ** + ** The zFilename argument is the filename pointer passed into the xOpen() + ** method of a VFS implementation. The zParam argument is the name of the + ** query parameter we seek. This routine returns the value of the zParam + ** parameter if it exists. If the parameter does not exist, this routine + ** returns a NULL pointer. + ** + ** If the zFilename argument to this function is not a pointer that SQLite + ** passed into the xOpen VFS method, then the behavior of this routine + ** is undefined and probably undesirable. + */ + //SQLITE_API string sqlite3_uri_parameter(string zFilename, string zParam); + + + /* + ** CAPI3REF: Error Codes And Messages + ** + ** ^The sqlite3_errcode() interface returns the numeric [result code] or + ** [extended result code] for the most recent failed sqlite3_* API call + ** associated with a [database connection]. If a prior API call failed + ** but the most recent API call succeeded, the return value from + ** sqlite3_errcode() is undefined. ^The sqlite3_extended_errcode() + ** interface is the same except that it always returns the + ** [extended result code] even when extended result codes are + ** disabled. + ** + ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language + ** text that describes the error, as either UTF-8 or UTF-16 respectively. + ** ^(Memory to hold the error message string is managed internally. + ** The application does not need to worry about freeing the result. + ** However, the error string might be overwritten or deallocated by + ** subsequent calls to other SQLite interface functions.)^ + ** + ** When the serialized [threading mode] is in use, it might be the + ** case that a second error occurs on a separate thread in between + ** the time of the first error and the call to these interfaces. + ** When that happens, the second error will be reported since these + ** interfaces always report the most recent result. To avoid + ** this, each thread can obtain exclusive use of the [database connection] D + ** by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning + ** to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after + ** all calls to the interfaces listed here are completed. + ** + ** If an interface fails with SQLITE_MISUSE, that means the interface + ** was invoked incorrectly by the application. In that case, the + ** error code and message may or may not be set. + */ + //SQLITE_API int sqlite3_errcode(sqlite3 db); + //SQLITE_API int sqlite3_extended_errcode(sqlite3 db); + //SQLITE_API string sqlite3_errmsg(sqlite3); + //SQLITE_API const void *sqlite3_errmsg16(sqlite3); + + /* + ** CAPI3REF: SQL Statement Object + ** KEYWORDS: {prepared statement} {prepared statements} + ** + ** An instance of this object represents a single SQL statement. + ** This object is variously known as a "prepared statement" or a + ** "compiled SQL statement" or simply as a "statement". + ** + ** The life of a statement object goes something like this: + ** + **
    + **
  1. Create the object using [sqlite3_prepare_v2()] or a related + ** function. + **
  2. Bind values to [host parameters] using the sqlite3_bind_*() + ** interfaces. + **
  3. Run the SQL by calling [sqlite3_step()] one or more times. + **
  4. Reset the statement using [sqlite3_reset()] then go back + ** to step 2. Do this zero or more times. + **
  5. Destroy the object using [sqlite3_finalize()]. + **
+ ** + ** Refer to documentation on individual methods above for additional + ** information. + */ + //typedef struct sqlite3_stmt sqlite3_stmt; + + /* + ** CAPI3REF: Run-time Limits + ** + ** ^(This interface allows the size of various constructs to be limited + ** on a connection by connection basis. The first parameter is the + ** [database connection] whose limit is to be set or queried. The + ** second parameter is one of the [limit categories] that define a + ** class of constructs to be size limited. The third parameter is the + ** new limit for that construct.)^ + ** + ** ^If the new limit is a negative number, the limit is unchanged. + ** ^(For each limit category SQLITE_LIMIT_NAME there is a + ** [limits | hard upper bound] + ** set at compile-time by a C preprocessor macro called + ** [limits | SQLITE_MAX_NAME]. + ** (The "_LIMIT_" in the name is changed to "_MAX_".))^ + ** ^Attempts to increase a limit above its hard upper bound are + ** silently truncated to the hard upper bound. + ** + ** ^Regardless of whether or not the limit was changed, the + ** [sqlite3_limit()] interface returns the prior value of the limit. + ** ^Hence, to find the current value of a limit without changing it, + ** simply invoke this interface with the third parameter set to -1. + ** + ** Run-time limits are intended for use in applications that manage + ** both their own internal database and also databases that are controlled + ** by untrusted external sources. An example application might be a + ** web browser that has its own databases for storing history and + ** separate databases controlled by JavaScript applications downloaded + ** off the Internet. The internal databases can be given the + ** large, default limits. Databases managed by external sources can + ** be given much smaller limits designed to prevent a denial of service + ** attack. Developers might also want to use the [sqlite3_set_authorizer()] + ** interface to further control untrusted SQL. The size of the database + ** created by an untrusted script can be contained using the + ** [max_page_count] [PRAGMA]. + ** + ** New run-time limit categories may be added in future releases. + */ + //SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); + + /* + ** CAPI3REF: Run-Time Limit Categories + ** KEYWORDS: {limit category} {*limit categories} + ** + ** These constants define various performance limits + ** that can be lowered at run-time using [sqlite3_limit()]. + ** The synopsis of the meanings of the various limits is shown below. + ** Additional information is available at [limits | Limits in SQLite]. + ** + **
+ ** [[SQLITE_LIMIT_LENGTH]] ^(
SQLITE_LIMIT_LENGTH
+ **
The maximum size of any string or BLOB or table row, in bytes.
)^ + ** + ** [[SQLITE_LIMIT_SQL_LENGTH]] ^(
SQLITE_LIMIT_SQL_LENGTH
+ **
The maximum length of an SQL statement, in bytes.
)^ + ** + ** [[SQLITE_LIMIT_COLUMN]] ^(
SQLITE_LIMIT_COLUMN
+ **
The maximum number of columns in a table definition or in the + ** result set of a [SELECT] or the maximum number of columns in an index + ** or in an ORDER BY or GROUP BY clause.
)^ + ** + ** [[SQLITE_LIMIT_EXPR_DEPTH]] ^(
SQLITE_LIMIT_EXPR_DEPTH
+ **
The maximum depth of the parse tree on any expression.
)^ + ** + ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(
SQLITE_LIMIT_COMPOUND_SELECT
+ **
The maximum number of terms in a compound SELECT statement.
)^ + ** + ** [[SQLITE_LIMIT_VDBE_OP]] ^(
SQLITE_LIMIT_VDBE_OP
+ **
The maximum number of instructions in a virtual machine program + ** used to implement an SQL statement. This limit is not currently + ** enforced, though that might be added in some future release of + ** SQLite.
)^ + ** + ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(
SQLITE_LIMIT_FUNCTION_ARG
+ **
The maximum number of arguments on a function.
)^ + ** + ** [[SQLITE_LIMIT_ATTACHED]] ^(
SQLITE_LIMIT_ATTACHED
+ **
The maximum number of [ATTACH | attached databases].)^
+ ** + ** [[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]] + ** ^(
SQLITE_LIMIT_LIKE_PATTERN_LENGTH
+ **
The maximum length of the pattern argument to the [LIKE] or + ** [GLOB] operators.
)^ + ** + ** [[SQLITE_LIMIT_VARIABLE_NUMBER]] + ** ^(
SQLITE_LIMIT_VARIABLE_NUMBER
+ **
The maximum index number of any [parameter] in an SQL statement.)^ + ** + ** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(
SQLITE_LIMIT_TRIGGER_DEPTH
+ **
The maximum depth of recursion for triggers.
)^ + **
+ */ + //#define SQLITE_LIMIT_LENGTH 0 + //#define SQLITE_LIMIT_SQL_LENGTH 1 + //#define SQLITE_LIMIT_COLUMN 2 + //#define SQLITE_LIMIT_EXPR_DEPTH 3 + //#define SQLITE_LIMIT_COMPOUND_SELECT 4 + //#define SQLITE_LIMIT_VDBE_OP 5 + //#define SQLITE_LIMIT_FUNCTION_ARG 6 + //#define SQLITE_LIMIT_ATTACHED 7 + //#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8 + //#define SQLITE_LIMIT_VARIABLE_NUMBER 9 + //#define SQLITE_LIMIT_TRIGGER_DEPTH 10 + const int SQLITE_LIMIT_LENGTH = 0; + const int SQLITE_LIMIT_SQL_LENGTH = 1; + const int SQLITE_LIMIT_COLUMN = 2; + const int SQLITE_LIMIT_EXPR_DEPTH = 3; + const int SQLITE_LIMIT_COMPOUND_SELECT = 4; + const int SQLITE_LIMIT_VDBE_OP = 5; + const int SQLITE_LIMIT_FUNCTION_ARG = 6; + const int SQLITE_LIMIT_ATTACHED = 7; + const int SQLITE_LIMIT_LIKE_PATTERN_LENGTH = 8; + const int SQLITE_LIMIT_VARIABLE_NUMBER = 9; + const int SQLITE_LIMIT_TRIGGER_DEPTH = 10; + + /* + ** CAPI3REF: Compiling An SQL Statement + ** KEYWORDS: {SQL statement compiler} + ** + ** To execute an SQL query, it must first be compiled into a byte-code + ** program using one of these routines. + ** + ** The first argument, "db", is a [database connection] obtained from a + ** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or + ** [sqlite3_open16()]. The database connection must not have been closed. + ** + ** The second argument, "zSql", is the statement to be compiled, encoded + ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() + ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2() + ** use UTF-16. + ** + ** ^If the nByte argument is less than zero, then zSql is read up to the + ** first zero terminator. ^If nByte is non-negative, then it is the maximum + ** number of bytes read from zSql. ^When nByte is non-negative, the + ** zSql string ends at either the first '\000' or '\u0000' character or + ** the nByte-th byte, whichever comes first. If the caller knows + ** that the supplied string is nul-terminated, then there is a small + ** performance advantage to be gained by passing an nByte parameter that + ** is equal to the number of bytes in the input string including + ** the nul-terminator bytes. + ** + ** ^If pzTail is not NULL then *pzTail is made to point to the first byte + ** past the end of the first SQL statement in zSql. These routines only + ** compile the first statement in zSql, so *pzTail is left pointing to + ** what remains uncompiled. + ** + ** ^*ppStmt is left pointing to a compiled [prepared statement] that can be + ** executed using [sqlite3_step()]. ^If there is an error, *ppStmt is set + ** to NULL. ^If the input text contains no SQL (if the input is an empty + ** string or a comment) then *ppStmt is set to NULL. + ** The calling procedure is responsible for deleting the compiled + ** SQL statement using [sqlite3_finalize()] after it has finished with it. + ** ppStmt may not be NULL. + ** + ** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK]; + ** otherwise an [error code] is returned. + ** + ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are + ** recommended for all new programs. The two older interfaces are retained + ** for backwards compatibility, but their use is discouraged. + ** ^In the "v2" interfaces, the prepared statement + ** that is returned (the [sqlite3_stmt] object) contains a copy of the + ** original SQL text. This causes the [sqlite3_step()] interface to + ** behave differently in three ways: + ** + **
    + **
  1. + ** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it + ** always used to do, [sqlite3_step()] will automatically recompile the SQL + ** statement and try to run it again. + **
  2. + ** + **
  3. + ** ^When an error occurs, [sqlite3_step()] will return one of the detailed + ** [error codes] or [extended error codes]. ^The legacy behavior was that + ** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code + ** and the application would have to make a second call to [sqlite3_reset()] + ** in order to find the underlying cause of the problem. With the "v2" prepare + ** interfaces, the underlying reason for the error is returned immediately. + **
  4. + ** + **
  5. + ** ^If the specific value bound to [parameter | host parameter] in the + ** WHERE clause might influence the choice of query plan for a statement, + ** then the statement will be automatically recompiled, as if there had been + ** a schema change, on the first [sqlite3_step()] call following any change + ** to the [sqlite3_bind_text | bindings] of that [parameter]. + ** ^The specific value of WHERE-clause [parameter] might influence the + ** choice of query plan if the parameter is the left-hand side of a [LIKE] + ** or [GLOB] operator or if the parameter is compared to an indexed column + ** and the [SQLITE_ENABLE_STAT2] compile-time option is enabled. + ** the + **
  6. + **
+ */ + //SQLITE_API int sqlite3_prepare( + // sqlite3 db, /* Database handle */ + // string zSql, /* SQL statement, UTF-8 encoded */ + // int nByte, /* Maximum length of zSql in bytes. */ + // sqlite3_stmt **ppStmt, /* OUT: Statement handle */ + // string *pzTail /* OUT: Pointer to unused portion of zSql */ + //); + //SQLITE_API int sqlite3_prepare_v2( + // sqlite3 db, /* Database handle */ + // string zSql, /* SQL statement, UTF-8 encoded */ + // int nByte, /* Maximum length of zSql in bytes. */ + // sqlite3_stmt **ppStmt, /* OUT: Statement handle */ + // string *pzTail /* OUT: Pointer to unused portion of zSql */ + //); + //SQLITE_API int sqlite3_prepare16( + // sqlite3 db, /* Database handle */ + // string zSql, /* SQL statement, UTF-16 encoded */ + // int nByte, /* Maximum length of zSql in bytes. */ + // sqlite3_stmt **ppStmt, /* OUT: Statement handle */ + // const void **pzTail /* OUT: Pointer to unused portion of zSql */ + //); + //SQLITE_API int sqlite3_prepare16_v2( + // sqlite3 db, /* Database handle */ + // string zSql, /* SQL statement, UTF-16 encoded */ + // int nByte, /* Maximum length of zSql in bytes. */ + // sqlite3_stmt **ppStmt, /* OUT: Statement handle */ + // const void **pzTail /* OUT: Pointer to unused portion of zSql */ + //); + + /* + ** CAPI3REF: Retrieving Statement SQL + ** + ** ^This interface can be used to retrieve a saved copy of the original + ** SQL text used to create a [prepared statement] if that statement was + ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()]. + */ + //SQLITE_API string sqlite3_sql(sqlite3_stmt *pStmt); + + /* + ** CAPI3REF: Determine If An SQL Statement Writes The Database + ** + ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if + ** and only if the [prepared statement] X makes no direct changes to + ** the content of the database file. + ** + ** Note that [application-defined SQL functions] or + ** [virtual tables] might change the database indirectly as a side effect. + ** ^(For example, if an application defines a function "eval()" that + ** calls [sqlite3_exec()], then the following SQL statement would + ** change the database file through side-effects: + ** + **
+        **    SELECT eval('DELETE FROM t1') FROM t2;
+        ** 
+ ** + ** But because the [SELECT] statement does not change the database file + ** directly, sqlite3_stmt_readonly() would still return true.)^ + ** + ** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK], + ** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true, + ** since the statements themselves do not actually modify the database but + ** rather they control the timing of when other statements modify the + ** database. ^The [ATTACH] and [DETACH] statements also cause + ** sqlite3_stmt_readonly() to return true since, while those statements + ** change the configuration of a database connection, they do not make + ** changes to the content of the database files on disk. + */ + //SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); + + /* + ** CAPI3REF: Dynamically Typed Value Object + ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value} + ** + ** SQLite uses the sqlite3_value object to represent all values + ** that can be stored in a database table. SQLite uses dynamic typing + ** for the values it stores. ^Values stored in sqlite3_value objects + ** can be integers, floating point values, strings, BLOBs, or NULL. + ** + ** An sqlite3_value object may be either "protected" or "unprotected". + ** Some interfaces require a protected sqlite3_value. Other interfaces + ** will accept either a protected or an unprotected sqlite3_value. + ** Every interface that accepts sqlite3_value arguments specifies + ** whether or not it requires a protected sqlite3_value. + ** + ** The terms "protected" and "unprotected" refer to whether or not + ** a mutex is held. An internal mutex is held for a protected + ** sqlite3_value object but no mutex is held for an unprotected + ** sqlite3_value object. If SQLite is compiled to be single-threaded + ** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0) + ** or if SQLite is run in one of reduced mutex modes + ** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD] + ** then there is no distinction between protected and unprotected + ** sqlite3_value objects and they can be used interchangeably. However, + ** for maximum code portability it is recommended that applications + ** still make the distinction between protected and unprotected + ** sqlite3_value objects even when not strictly required. + ** + ** ^The sqlite3_value objects that are passed as parameters into the + ** implementation of [application-defined SQL functions] are protected. + ** ^The sqlite3_value object returned by + ** [sqlite3_column_value()] is unprotected. + ** Unprotected sqlite3_value objects may only be used with + ** [sqlite3_result_value()] and [sqlite3_bind_value()]. + ** The [sqlite3_value_blob | sqlite3_value_type()] family of + ** interfaces require protected sqlite3_value objects. + */ + //typedef struct Mem sqlite3_value; + + /* + ** CAPI3REF: SQL Function Context Object + ** + ** The context in which an SQL function executes is stored in an + ** sqlite3_context object. ^A pointer to an sqlite3_context object + ** is always first parameter to [application-defined SQL functions]. + ** The application-defined SQL function implementation will pass this + ** pointer through into calls to [sqlite3_result_int | sqlite3_result()], + ** [sqlite3_aggregate_context()], [sqlite3_user_data()], + ** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()], + ** and/or [sqlite3_set_auxdata()]. + */ + //typedef struct sqlite3_context sqlite3_context; + + /* + ** CAPI3REF: Binding Values To Prepared Statements + ** KEYWORDS: {host parameter} {host parameters} {host parameter name} + ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding} + ** + ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants, + ** literals may be replaced by a [parameter] that matches one of following + ** templates: + ** + **
    + **
  • ? + **
  • ?NNN + **
  • :VVV + **
  • @VVV + **
  • $VVV + **
+ ** + ** In the templates above, NNN represents an integer literal, + ** and VVV represents an alphanumeric identifier.)^ ^The values of these + ** parameters (also called "host parameter names" or "SQL parameters") + ** can be set using the sqlite3_bind_*() routines defined here. + ** + ** ^The first argument to the sqlite3_bind_*() routines is always + ** a pointer to the [sqlite3_stmt] object returned from + ** [sqlite3_prepare_v2()] or its variants. + ** + ** ^The second argument is the index of the SQL parameter to be set. + ** ^The leftmost SQL parameter has an index of 1. ^When the same named + ** SQL parameter is used more than once, second and subsequent + ** occurrences have the same index as the first occurrence. + ** ^The index for named parameters can be looked up using the + ** [sqlite3_bind_parameter_index()] API if desired. ^The index + ** for "?NNN" parameters is the value of NNN. + ** ^The NNN value must be between 1 and the [sqlite3_limit()] + ** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999). + ** + ** ^The third argument is the value to bind to the parameter. + ** + ** ^(In those routines that have a fourth argument, its value is the + ** number of bytes in the parameter. To be clear: the value is the + ** number of bytes in the value, not the number of characters.)^ + ** ^If the fourth parameter is negative, the length of the string is + ** the number of bytes up to the first zero terminator. + ** + ** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and + ** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or + ** string after SQLite has finished with it. ^The destructor is called + ** to dispose of the BLOB or string even if the call to sqlite3_bind_blob(), + ** sqlite3_bind_text(), or sqlite3_bind_text16() fails. + ** ^If the fifth argument is + ** the special value [SQLITE_STATIC], then SQLite assumes that the + ** information is in static, unmanaged space and does not need to be freed. + ** ^If the fifth argument has the value [SQLITE_TRANSIENT], then + ** SQLite makes its own private copy of the data immediately, before + ** the sqlite3_bind_*() routine returns. + ** + ** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that + ** is filled with zeroes. ^A zeroblob uses a fixed amount of memory + ** (just an integer to hold its size) while it is being processed. + ** Zeroblobs are intended to serve as placeholders for BLOBs whose + ** content is later written using + ** [sqlite3_blob_open | incremental BLOB I/O] routines. + ** ^A negative value for the zeroblob results in a zero-length BLOB. + ** + ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer + ** for the [prepared statement] or with a prepared statement for which + ** [sqlite3_step()] has been called more recently than [sqlite3_reset()], + ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() + ** routine is passed a [prepared statement] that has been finalized, the + ** result is undefined and probably harmful. + ** + ** ^Bindings are not cleared by the [sqlite3_reset()] routine. + ** ^Unbound parameters are interpreted as NULL. + ** + ** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an + ** [error code] if anything goes wrong. + ** ^[SQLITE_RANGE] is returned if the parameter + ** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails. + ** + ** See also: [sqlite3_bind_parameter_count()], + ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()]. + */ + //SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void()(void)); + //SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double); + //SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int); + //SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); + //SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int); + //SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void()(void)); + //SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void()(void)); + //SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value); + //SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); + + /* + ** CAPI3REF: Number Of SQL Parameters + ** + ** ^This routine can be used to find the number of [SQL parameters] + ** in a [prepared statement]. SQL parameters are tokens of the + ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as + ** placeholders for values that are [sqlite3_bind_blob | bound] + ** to the parameters at a later time. + ** + ** ^(This routine actually returns the index of the largest (rightmost) + ** parameter. For all forms except ?NNN, this will correspond to the + ** number of unique parameters. If parameters of the ?NNN form are used, + ** there may be gaps in the list.)^ + ** + ** See also: [sqlite3_bind_blob|sqlite3_bind()], + ** [sqlite3_bind_parameter_name()], and + ** [sqlite3_bind_parameter_index()]. + */ + //SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt); + + /* + ** CAPI3REF: Name Of A Host Parameter + ** + ** ^The sqlite3_bind_parameter_name(P,N) interface returns + ** the name of the N-th [SQL parameter] in the [prepared statement] P. + ** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA" + ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA" + ** respectively. + ** In other words, the initial ":" or "$" or "@" or "?" + ** is included as part of the name.)^ + ** ^Parameters of the form "?" without a following integer have no name + ** and are referred to as "nameless" or "anonymous parameters". + ** + ** ^The first host parameter has an index of 1, not 0. + ** + ** ^If the value N is out of range or if the N-th parameter is + ** nameless, then NULL is returned. ^The returned string is + ** always in UTF-8 encoding even if the named parameter was + ** originally specified as UTF-16 in [sqlite3_prepare16()] or + ** [sqlite3_prepare16_v2()]. + ** + ** See also: [sqlite3_bind_blob|sqlite3_bind()], + ** [sqlite3_bind_parameter_count()], and + ** [sqlite3_bind_parameter_index()]. + */ + //SQLITE_API string sqlite3_bind_parameter_name(sqlite3_stmt*, int); + + /* + ** CAPI3REF: Index Of A Parameter With A Given Name + ** + ** ^Return the index of an SQL parameter given its name. ^The + ** index value returned is suitable for use as the second + ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero + ** is returned if no matching parameter is found. ^The parameter + ** name must be given in UTF-8 even if the original statement + ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()]. + ** + ** See also: [sqlite3_bind_blob|sqlite3_bind()], + ** [sqlite3_bind_parameter_count()], and + ** [sqlite3_bind_parameter_index()]. + */ + //SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, string zName); + + /* + ** CAPI3REF: Reset All Bindings On A Prepared Statement + ** + ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset + ** the [sqlite3_bind_blob | bindings] on a [prepared statement]. + ** ^Use this routine to reset all host parameters to NULL. + */ + //SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt); + + /* + ** CAPI3REF: Number Of Columns In A Result Set + ** + ** ^Return the number of columns in the result set returned by the + ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL + ** statement that does not return data (for example an [UPDATE]). + ** + ** See also: [sqlite3_data_count()] + */ + //SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt); + + /* + ** CAPI3REF: Column Names In A Result Set + ** + ** ^These routines return the name assigned to a particular column + ** in the result set of a [SELECT] statement. ^The sqlite3_column_name() + ** interface returns a pointer to a zero-terminated UTF-8 string + ** and sqlite3_column_name16() returns a pointer to a zero-terminated + ** UTF-16 string. ^The first parameter is the [prepared statement] + ** that implements the [SELECT] statement. ^The second parameter is the + ** column number. ^The leftmost column is number 0. + ** + ** ^The returned string pointer is valid until either the [prepared statement] + ** is destroyed by [sqlite3_finalize()] or until the statement is automatically + ** reprepared by the first call to [sqlite3_step()] for a particular run + ** or until the next call to + ** sqlite3_column_name() or sqlite3_column_name16() on the same column. + ** + ** ^If sqlite3_malloc() fails during the processing of either routine + ** (for example during a conversion from UTF-8 to UTF-16) then a + ** NULL pointer is returned. + ** + ** ^The name of a result column is the value of the "AS" clause for + ** that column, if there is an AS clause. If there is no AS clause + ** then the name of the column is unspecified and may change from + ** one release of SQLite to the next. + */ + //SQLITE_API string sqlite3_column_name(sqlite3_stmt*, int N); + //SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N); + + /* + ** CAPI3REF: Source Of Data In A Query Result + ** + ** ^These routines provide a means to determine the database, table, and + ** table column that is the origin of a particular result column in + ** [SELECT] statement. + ** ^The name of the database or table or column can be returned as + ** either a UTF-8 or UTF-16 string. ^The _database_ routines return + ** the database name, the _table_ routines return the table name, and + ** the origin_ routines return the column name. + ** ^The returned string is valid until the [prepared statement] is destroyed + ** using [sqlite3_finalize()] or until the statement is automatically + ** reprepared by the first call to [sqlite3_step()] for a particular run + ** or until the same information is requested + ** again in a different encoding. + ** + ** ^The names returned are the original un-aliased names of the + ** database, table, and column. + ** + ** ^The first argument to these interfaces is a [prepared statement]. + ** ^These functions return information about the Nth result column returned by + ** the statement, where N is the second function argument. + ** ^The left-most column is column 0 for these routines. + ** + ** ^If the Nth column returned by the statement is an expression or + ** subquery and is not a column value, then all of these functions return + ** NULL. ^These routine might also return NULL if a memory allocation error + ** occurs. ^Otherwise, they return the name of the attached database, table, + ** or column that query result column was extracted from. + ** + ** ^As with all other SQLite APIs, those whose names end with "16" return + ** UTF-16 encoded strings and the other functions return UTF-8. + ** + ** ^These APIs are only available if the library was compiled with the + ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol. + ** + ** If two or more threads call one or more of these routines against the same + ** prepared statement and column at the same time then the results are + ** undefined. + ** + ** If two or more threads call one or more + ** [sqlite3_column_database_name | column metadata interfaces] + ** for the same [prepared statement] and result column + ** at the same time then the results are undefined. + */ + //SQLITE_API string sqlite3_column_database_name(sqlite3_stmt*,int); + //SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int); + //SQLITE_API string sqlite3_column_table_name(sqlite3_stmt*,int); + //SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int); + //SQLITE_API string sqlite3_column_origin_name(sqlite3_stmt*,int); + //SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int); + + /* + ** CAPI3REF: Declared Datatype Of A Query Result + ** + ** ^(The first parameter is a [prepared statement]. + ** If this statement is a [SELECT] statement and the Nth column of the + ** returned result set of that [SELECT] is a table column (not an + ** expression or subquery) then the declared type of the table + ** column is returned.)^ ^If the Nth column of the result set is an + ** expression or subquery, then a NULL pointer is returned. + ** ^The returned string is always UTF-8 encoded. + ** + ** ^(For example, given the database schema: + ** + ** CREATE TABLE t1(c1 VARIANT); + ** + ** and the following statement to be compiled: + ** + ** SELECT c1 + 1, c1 FROM t1; + ** + ** this routine would return the string "VARIANT" for the second result + ** column (i==1), and a NULL pointer for the first result column (i==0).)^ + ** + ** ^SQLite uses dynamic run-time typing. ^So just because a column + ** is declared to contain a particular type does not mean that the + ** data stored in that column is of the declared type. SQLite is + ** strongly typed, but the typing is dynamic not static. ^Type + ** is associated with individual values, not with the containers + ** used to hold those values. + */ + //SQLITE_API string sqlite3_column_decltype(sqlite3_stmt*,int); + //SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int); + + /* + ** CAPI3REF: Evaluate An SQL Statement + ** + ** After a [prepared statement] has been prepared using either + ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy + ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function + ** must be called one or more times to evaluate the statement. + ** + ** The details of the behavior of the sqlite3_step() interface depend + ** on whether the statement was prepared using the newer "v2" interface + ** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy + ** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the + ** new "v2" interface is recommended for new applications but the legacy + ** interface will continue to be supported. + ** + ** ^In the legacy interface, the return value will be either [SQLITE_BUSY], + ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE]. + ** ^With the "v2" interface, any of the other [result codes] or + ** [extended result codes] might be returned as well. + ** + ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the + ** database locks it needs to do its job. ^If the statement is a [COMMIT] + ** or occurs outside of an explicit transaction, then you can retry the + ** statement. If the statement is not a [COMMIT] and occurs within an + ** explicit transaction then you should rollback the transaction before + ** continuing. + ** + ** ^[SQLITE_DONE] means that the statement has finished executing + ** successfully. sqlite3_step() should not be called again on this virtual + ** machine without first calling [sqlite3_reset()] to reset the virtual + ** machine back to its initial state. + ** + ** ^If the SQL statement being executed returns any data, then [SQLITE_ROW] + ** is returned each time a new row of data is ready for processing by the + ** caller. The values may be accessed using the [column access functions]. + ** sqlite3_step() is called again to retrieve the next row of data. + ** + ** ^[SQLITE_ERROR] means that a run-time error (such as a constraint + ** violation) has occurred. sqlite3_step() should not be called again on + ** the VM. More information may be found by calling [sqlite3_errmsg()]. + ** ^With the legacy interface, a more specific error code (for example, + ** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth) + ** can be obtained by calling [sqlite3_reset()] on the + ** [prepared statement]. ^In the "v2" interface, + ** the more specific error code is returned directly by sqlite3_step(). + ** + ** [SQLITE_MISUSE] means that the this routine was called inappropriately. + ** Perhaps it was called on a [prepared statement] that has + ** already been [sqlite3_finalize | finalized] or on one that had + ** previously returned [SQLITE_ERROR] or [SQLITE_DONE]. Or it could + ** be the case that the same database connection is being used by two or + ** more threads at the same moment in time. + ** + ** For all versions of SQLite up to and including 3.6.23.1, a call to + ** [sqlite3_reset()] was required after sqlite3_step() returned anything + ** other than [SQLITE_ROW] before any subsequent invocation of + ** sqlite3_step(). Failure to reset the prepared statement using + ** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from + ** sqlite3_step(). But after version 3.6.23.1, sqlite3_step() began + ** calling [sqlite3_reset()] automatically in this circumstance rather + ** than returning [SQLITE_MISUSE]. This is not considered a compatibility + ** break because any application that ever receives an SQLITE_MISUSE error + ** is broken by definition. The [SQLITE_OMIT_AUTORESET] compile-time option + ** can be used to restore the legacy behavior. + ** + ** Goofy Interface Alert: In the legacy interface, the sqlite3_step() + ** API always returns a generic error code, [SQLITE_ERROR], following any + ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call + ** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the + ** specific [error codes] that better describes the error. + ** We admit that this is a goofy design. The problem has been fixed + ** with the "v2" interface. If you prepare all of your SQL statements + ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead + ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces, + ** then the more specific [error codes] are returned directly + ** by sqlite3_step(). The use of the "v2" interface is recommended. + */ + //SQLITE_API int sqlite3_step(sqlite3_stmt); + + /* + ** CAPI3REF: Number of columns in a result set + ** + ** ^The sqlite3_data_count(P) interface returns the number of columns in the + ** current row of the result set of [prepared statement] P. + ** ^If prepared statement P does not have results ready to return + ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of + ** interfaces) then sqlite3_data_count(P) returns 0. + ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer. + ** + ** See also: [sqlite3_column_count()] + */ + //SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); + + /* + ** CAPI3REF: Fundamental Datatypes + ** KEYWORDS: SQLITE_TEXT + ** + ** ^(Every value in SQLite has one of five fundamental datatypes: + ** + **
    + **
  • 64-bit signed integer + **
  • 64-bit IEEE floating point number + **
  • string + **
  • BLOB + **
  • NULL + **
)^ + ** + ** These constants are codes for each of those types. + ** + ** Note that the SQLITE_TEXT constant was also used in SQLite version 2 + ** for a completely different meaning. Software that links against both + ** SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, not + ** SQLITE_TEXT. + */ + //#define SQLITE_INTEGER 1 + //#define SQLITE_FLOAT 2 + //#define SQLITE_BLOB 4 + //#define SQLITE_NULL 5 + //#if SQLITE_TEXT + //# undef SQLITE_TEXT + //#else + //# define SQLITE_TEXT 3 + //#endif + //#define SQLITE3_TEXT 3 + public const u8 SQLITE_INTEGER = 1; + public const u8 SQLITE_FLOAT = 2; + public const u8 SQLITE_BLOB = 4; + public const u8 SQLITE_NULL = 5; + public const u8 SQLITE_TEXT = 3; + public const u8 SQLITE3_TEXT = 3; + + /* + ** CAPI3REF: Result Values From A Query + ** KEYWORDS: {column access functions} + ** + ** These routines form the "result set" interface. + ** + ** ^These routines return information about a single column of the current + ** result row of a query. ^In every case the first argument is a pointer + ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*] + ** that was returned from [sqlite3_prepare_v2()] or one of its variants) + ** and the second argument is the index of the column for which information + ** should be returned. ^The leftmost column of the result set has the index 0. + ** ^The number of columns in the result can be determined using + ** [sqlite3_column_count()]. + ** + ** If the SQL statement does not currently point to a valid row, or if the + ** column index is out of range, the result is undefined. + ** These routines may only be called when the most recent call to + ** [sqlite3_step()] has returned [SQLITE_ROW] and neither + ** [sqlite3_reset()] nor [sqlite3_finalize()] have been called subsequently. + ** If any of these routines are called after [sqlite3_reset()] or + ** [sqlite3_finalize()] or after [sqlite3_step()] has returned + ** something other than [SQLITE_ROW], the results are undefined. + ** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()] + ** are called from a different thread while any of these routines + ** are pending, then the results are undefined. + ** + ** ^The sqlite3_column_type() routine returns the + ** [SQLITE_INTEGER | datatype code] for the initial data type + ** of the result column. ^The returned value is one of [SQLITE_INTEGER], + ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value + ** returned by sqlite3_column_type() is only meaningful if no type + ** conversions have occurred as described below. After a type conversion, + ** the value returned by sqlite3_column_type() is undefined. Future + ** versions of SQLite may change the behavior of sqlite3_column_type() + ** following a type conversion. + ** + ** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes() + ** routine returns the number of bytes in that BLOB or string. + ** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts + ** the string to UTF-8 and then returns the number of bytes. + ** ^If the result is a numeric value then sqlite3_column_bytes() uses + ** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns + ** the number of bytes in that string. + ** ^If the result is NULL, then sqlite3_column_bytes() returns zero. + ** + ** ^If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16() + ** routine returns the number of bytes in that BLOB or string. + ** ^If the result is a UTF-8 string, then sqlite3_column_bytes16() converts + ** the string to UTF-16 and then returns the number of bytes. + ** ^If the result is a numeric value then sqlite3_column_bytes16() uses + ** [sqlite3_snprintf()] to convert that value to a UTF-16 string and returns + ** the number of bytes in that string. + ** ^If the result is NULL, then sqlite3_column_bytes16() returns zero. + ** + ** ^The values returned by [sqlite3_column_bytes()] and + ** [sqlite3_column_bytes16()] do not include the zero terminators at the end + ** of the string. ^For clarity: the values returned by + ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of + ** bytes in the string, not the number of characters. + ** + ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(), + ** even empty strings, are always zero terminated. ^The return + ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer. + ** + ** ^The object returned by [sqlite3_column_value()] is an + ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object + ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()]. + ** If the [unprotected sqlite3_value] object returned by + ** [sqlite3_column_value()] is used in any other way, including calls + ** to routines like [sqlite3_value_int()], [sqlite3_value_text()], + ** or [sqlite3_value_bytes()], then the behavior is undefined. + ** + ** These routines attempt to convert the value where appropriate. ^For + ** example, if the internal representation is FLOAT and a text result + ** is requested, [sqlite3_snprintf()] is used internally to perform the + ** conversion automatically. ^(The following table details the conversions + ** that are applied: + ** + **
+ ** + **
Internal
Type
Requested
Type
Conversion + ** + **
NULL INTEGER Result is 0 + **
NULL FLOAT Result is 0.0 + **
NULL TEXT Result is NULL pointer + **
NULL BLOB Result is NULL pointer + **
INTEGER FLOAT Convert from integer to float + **
INTEGER TEXT ASCII rendering of the integer + **
INTEGER BLOB Same as INTEGER->TEXT + **
FLOAT INTEGER Convert from float to integer + **
FLOAT TEXT ASCII rendering of the float + **
FLOAT BLOB Same as FLOAT->TEXT + **
TEXT INTEGER Use atoi() + **
TEXT FLOAT Use atof() + **
TEXT BLOB No change + **
BLOB INTEGER Convert to TEXT then use atoi() + **
BLOB FLOAT Convert to TEXT then use atof() + **
BLOB TEXT Add a zero terminator if needed + **
+ **
)^ + ** + ** The table above makes reference to standard C library functions atoi() + ** and atof(). SQLite does not really use these functions. It has its + ** own equivalent internal routines. The atoi() and atof() names are + ** used in the table for brevity and because they are familiar to most + ** C programmers. + ** + ** Note that when type conversions occur, pointers returned by prior + ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or + ** sqlite3_column_text16() may be invalidated. + ** Type conversions and pointer invalidations might occur + ** in the following cases: + ** + **
    + **
  • The initial content is a BLOB and sqlite3_column_text() or + ** sqlite3_column_text16() is called. A zero-terminator might + ** need to be added to the string.
  • + **
  • The initial content is UTF-8 text and sqlite3_column_bytes16() or + ** sqlite3_column_text16() is called. The content must be converted + ** to UTF-16.
  • + **
  • The initial content is UTF-16 text and sqlite3_column_bytes() or + ** sqlite3_column_text() is called. The content must be converted + ** to UTF-8.
  • + **
+ ** + ** ^Conversions between UTF-16be and UTF-16le are always done in place and do + ** not invalidate a prior pointer, though of course the content of the buffer + ** that the prior pointer references will have been modified. Other kinds + ** of conversion are done in place when it is possible, but sometimes they + ** are not possible and in those cases prior pointers are invalidated. + ** + ** The safest and easiest to remember policy is to invoke these routines + ** in one of the following ways: + ** + **
    + **
  • sqlite3_column_text() followed by sqlite3_column_bytes()
  • + **
  • sqlite3_column_blob() followed by sqlite3_column_bytes()
  • + **
  • sqlite3_column_text16() followed by sqlite3_column_bytes16()
  • + **
+ ** + ** In other words, you should call sqlite3_column_text(), + ** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result + ** into the desired format, then invoke sqlite3_column_bytes() or + ** sqlite3_column_bytes16() to find the size of the result. Do not mix calls + ** to sqlite3_column_text() or sqlite3_column_blob() with calls to + ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16() + ** with calls to sqlite3_column_bytes(). + ** + ** ^The pointers returned are valid until a type conversion occurs as + ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or + ** [sqlite3_finalize()] is called. ^The memory space used to hold strings + ** and BLOBs is freed automatically. Do not pass the pointers returned + ** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into + ** [sqlite3_free()]. + ** + ** ^(If a memory allocation error occurs during the evaluation of any + ** of these routines, a default value is returned. The default value + ** is either the integer 0, the floating point number 0.0, or a NULL + ** pointer. Subsequent calls to [sqlite3_errcode()] will return + ** [SQLITE_NOMEM].)^ + */ + //SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); + //SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol); + //SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol); + //SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol); + //SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol); + //SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol); + //SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol); + //SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol); + //SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol); + //SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol); + + /* + ** CAPI3REF: Destroy A Prepared Statement Object + ** + ** ^The sqlite3_finalize() function is called to delete a [prepared statement]. + ** ^If the most recent evaluation of the statement encountered no errors + ** or if the statement is never been evaluated, then sqlite3_finalize() returns + ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then + ** sqlite3_finalize(S) returns the appropriate [error code] or + ** [extended error code]. + ** + ** ^The sqlite3_finalize(S) routine can be called at any point during + ** the life cycle of [prepared statement] S: + ** before statement S is ever evaluated, after + ** one or more calls to [sqlite3_reset()], or after any call + ** to [sqlite3_step()] regardless of whether or not the statement has + ** completed execution. + ** + ** ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op. + ** + ** The application must finalize every [prepared statement] in order to avoid + ** resource leaks. It is a grievous error for the application to try to use + ** a prepared statement after it has been finalized. Any use of a prepared + ** statement after it has been finalized can result in undefined and + ** undesirable behavior such as segfaults and heap corruption. + */ + //SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt); + + /* + ** CAPI3REF: Reset A Prepared Statement Object + ** + ** The sqlite3_reset() function is called to reset a [prepared statement] + ** object back to its initial state, ready to be re-executed. + ** ^Any SQL statement variables that had values bound to them using + ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values. + ** Use [sqlite3_clear_bindings()] to reset the bindings. + ** + ** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S + ** back to the beginning of its program. + ** + ** ^If the most recent call to [sqlite3_step(S)] for the + ** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE], + ** or if [sqlite3_step(S)] has never before been called on S, + ** then [sqlite3_reset(S)] returns [SQLITE_OK]. + ** + ** ^If the most recent call to [sqlite3_step(S)] for the + ** [prepared statement] S indicated an error, then + ** [sqlite3_reset(S)] returns an appropriate [error code]. + ** + ** ^The [sqlite3_reset(S)] interface does not change the values + ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. + */ + //SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); + + /* + ** CAPI3REF: Create Or Redefine SQL Functions + ** KEYWORDS: {function creation routines} + ** KEYWORDS: {application-defined SQL function} + ** KEYWORDS: {application-defined SQL functions} + ** + ** ^These functions (collectively known as "function creation routines") + ** are used to add SQL functions or aggregates or to redefine the behavior + ** of existing SQL functions or aggregates. The only differences between + ** these routines are the text encoding expected for + ** the second parameter (the name of the function being created) + ** and the presence or absence of a destructor callback for + ** the application data pointer. + ** + ** ^The first parameter is the [database connection] to which the SQL + ** function is to be added. ^If an application uses more than one database + ** connection then application-defined SQL functions must be added + ** to each database connection separately. + ** + ** ^The second parameter is the name of the SQL function to be created or + ** redefined. ^The length of the name is limited to 255 bytes in a UTF-8 + ** representation, exclusive of the zero-terminator. ^Note that the name + ** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes. + ** ^Any attempt to create a function with a longer name + ** will result in [SQLITE_MISUSE] being returned. + ** + ** ^The third parameter (nArg) + ** is the number of arguments that the SQL function or + ** aggregate takes. ^If this parameter is -1, then the SQL function or + ** aggregate may take any number of arguments between 0 and the limit + ** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]). If the third + ** parameter is less than -1 or greater than 127 then the behavior is + ** undefined. + ** + ** ^The fourth parameter, eTextRep, specifies what + ** [SQLITE_UTF8 | text encoding] this SQL function prefers for + ** its parameters. Every SQL function implementation must be able to work + ** with UTF-8, UTF-16le, or UTF-16be. But some implementations may be + ** more efficient with one encoding than another. ^An application may + ** invoke sqlite3_create_function() or sqlite3_create_function16() multiple + ** times with the same function but with different values of eTextRep. + ** ^When multiple implementations of the same function are available, SQLite + ** will pick the one that involves the least amount of data conversion. + ** If there is only a single implementation which does not care what text + ** encoding is used, then the fourth argument should be [SQLITE_ANY]. + ** + ** ^(The fifth parameter is an arbitrary pointer. The implementation of the + ** function can gain access to this pointer using [sqlite3_user_data()].)^ + ** + ** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are + ** pointers to C-language functions that implement the SQL function or + ** aggregate. ^A scalar SQL function requires an implementation of the xFunc + ** callback only; NULL pointers must be passed as the xStep and xFinal + ** parameters. ^An aggregate SQL function requires an implementation of xStep + ** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing + ** SQL function or aggregate, pass NULL pointers for all three function + ** callbacks. + ** + ** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL, + ** then it is destructor for the application data pointer. + ** The destructor is invoked when the function is deleted, either by being + ** overloaded or when the database connection closes.)^ + ** ^The destructor is also invoked if the call to + ** sqlite3_create_function_v2() fails. + ** ^When the destructor callback of the tenth parameter is invoked, it + ** is passed a single argument which is a copy of the application data + ** pointer which was the fifth parameter to sqlite3_create_function_v2(). + ** + ** ^It is permitted to register multiple implementations of the same + ** functions with the same name but with either differing numbers of + ** arguments or differing preferred text encodings. ^SQLite will use + ** the implementation that most closely matches the way in which the + ** SQL function is used. ^A function implementation with a non-negative + ** nArg parameter is a better match than a function implementation with + ** a negative nArg. ^A function where the preferred text encoding + ** matches the database encoding is a better + ** match than a function where the encoding is different. + ** ^A function where the encoding difference is between UTF16le and UTF16be + ** is a closer match than a function where the encoding difference is + ** between UTF8 and UTF16. + ** + ** ^Built-in functions may be overloaded by new application-defined functions. + ** + ** ^An application-defined function is permitted to call other + ** SQLite interfaces. However, such calls must not + ** close the database connection nor finalize or reset the prepared + ** statement in which the function is running. + */ + //SQLITE_API int sqlite3_create_function( + // sqlite3 db, + // string zFunctionName, + // int nArg, + // int eTextRep, + // void *pApp, + // void (*xFunc)(sqlite3_context*,int,sqlite3_value*), + // void (*xStep)(sqlite3_context*,int,sqlite3_value*), + // void (*xFinal)(sqlite3_context) + //); + //SQLITE_API int sqlite3_create_function16( + // sqlite3 db, + // string zFunctionName, + // int nArg, + // int eTextRep, + // void *pApp, + // void (*xFunc)(sqlite3_context*,int,sqlite3_value*), + // void (*xStep)(sqlite3_context*,int,sqlite3_value*), + // void (*xFinal)(sqlite3_context) + //); + //SQLITE_API int sqlite3_create_function_v2( + // sqlite3 db, + // string zFunctionName, + // int nArg, + // int eTextRep, + // void *pApp, + // void (*xFunc)(sqlite3_context*,int,sqlite3_value*), + // void (*xStep)(sqlite3_context*,int,sqlite3_value*), + // void (*xFinal)(sqlite3_context), + // void(*xDestroy)(void) + //); + + /* + ** CAPI3REF: Text Encodings + ** + ** These constant define integer codes that represent the various + ** text encodings supported by SQLite. + */ + //#define SQLITE_UTF8 1 + //#define SQLITE_UTF16LE 2 + //#define SQLITE_UTF16BE 3 + //#define SQLITE_UTF16 4 /* Use native byte order */ + //#define SQLITE_ANY 5 /* sqlite3_create_function only */ + //#define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */ + public const u8 SQLITE_UTF8 = 1; + public const u8 SQLITE_UTF16LE = 2; + public const u8 SQLITE_UTF16BE = 3; + public const u8 SQLITE_UTF16 = 4; + public const u8 SQLITE_ANY = 5; + public const u8 SQLITE_UTF16_ALIGNED = 8; + + + /* + ** CAPI3REF: Deprecated Functions + ** DEPRECATED + ** + ** These functions are [deprecated]. In order to maintain + ** backwards compatibility with older code, these functions continue + ** to be supported. However, new applications should avoid + ** the use of these functions. To help encourage people to avoid + ** using these functions, we are not going to tell you what they do. + */ + //#if !SQLITE_OMIT_DEPRECATED + //SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context); + //SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt); + //SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt); + //SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void); + //SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); + //SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void()(void*,sqlite3_int64,int),void*,sqlite3_int64); + //#endif + + /* + ** CAPI3REF: Obtaining SQL Function Parameter Values + ** + ** The C-language implementation of SQL functions and aggregates uses + ** this set of interface routines to access the parameter values on + ** the function or aggregate. + ** + ** The xFunc (for scalar functions) or xStep (for aggregates) parameters + ** to [sqlite3_create_function()] and [sqlite3_create_function16()] + ** define callbacks that implement the SQL functions and aggregates. + ** The 3rd parameter to these callbacks is an array of pointers to + ** [protected sqlite3_value] objects. There is one [sqlite3_value] object for + ** each parameter to the SQL function. These routines are used to + ** extract values from the [sqlite3_value] objects. + ** + ** These routines work only with [protected sqlite3_value] objects. + ** Any attempt to use these routines on an [unprotected sqlite3_value] + ** object results in undefined behavior. + ** + ** ^These routines work just like the corresponding [column access functions] + ** except that these routines take a single [protected sqlite3_value] object + ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number. + ** + ** ^The sqlite3_value_text16() interface extracts a UTF-16 string + ** in the native byte-order of the host machine. ^The + ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces + ** extract UTF-16 strings as big-endian and little-endian respectively. + ** + ** ^(The sqlite3_value_numeric_type() interface attempts to apply + ** numeric affinity to the value. This means that an attempt is + ** made to convert the value to an integer or floating point. If + ** such a conversion is possible without loss of information (in other + ** words, if the value is a string that looks like a number) + ** then the conversion is performed. Otherwise no conversion occurs. + ** The [SQLITE_INTEGER | datatype] after conversion is returned.)^ + ** + ** Please pay particular attention to the fact that the pointer returned + ** from [sqlite3_value_blob()], [sqlite3_value_text()], or + ** [sqlite3_value_text16()] can be invalidated by a subsequent call to + ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()], + ** or [sqlite3_value_text16()]. + ** + ** These routines must be called from the same thread as + ** the SQL function that supplied the [sqlite3_value*] parameters. + */ + //SQLITE_API const void *sqlite3_value_blob(sqlite3_value); + //SQLITE_API int sqlite3_value_bytes(sqlite3_value); + //SQLITE_API int sqlite3_value_bytes16(sqlite3_value); + //SQLITE_API double sqlite3_value_double(sqlite3_value); + //SQLITE_API int sqlite3_value_int(sqlite3_value); + //SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value); + //SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value); + //SQLITE_API const void *sqlite3_value_text16(sqlite3_value); + //SQLITE_API const void *sqlite3_value_text16le(sqlite3_value); + //SQLITE_API const void *sqlite3_value_text16be(sqlite3_value); + //SQLITE_API int sqlite3_value_type(sqlite3_value); + //SQLITE_API int sqlite3_value_numeric_type(sqlite3_value); + + /* + ** CAPI3REF: Obtain Aggregate Function Context + ** + ** Implementations of aggregate SQL functions use this + ** routine to allocate memory for storing their state. + ** + ** ^The first time the sqlite3_aggregate_context(C,N) routine is called + ** for a particular aggregate function, SQLite + ** allocates N of memory, zeroes out that memory, and returns a pointer + ** to the new memory. ^On second and subsequent calls to + ** sqlite3_aggregate_context() for the same aggregate function instance, + ** the same buffer is returned. Sqlite3_aggregate_context() is normally + ** called once for each invocation of the xStep callback and then one + ** last time when the xFinal callback is invoked. ^(When no rows match + ** an aggregate query, the xStep() callback of the aggregate function + ** implementation is never called and xFinal() is called exactly once. + ** In those cases, sqlite3_aggregate_context() might be called for the + ** first time from within xFinal().)^ + ** + ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is + ** less than or equal to zero or if a memory allocate error occurs. + ** + ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is + ** determined by the N parameter on first successful call. Changing the + ** value of N in subsequent call to sqlite3_aggregate_context() within + ** the same aggregate function instance will not resize the memory + ** allocation.)^ + ** + ** ^SQLite automatically frees the memory allocated by + ** sqlite3_aggregate_context() when the aggregate query concludes. + ** + ** The first parameter must be a copy of the + ** [sqlite3_context | SQL function context] that is the first parameter + ** to the xStep or xFinal callback routine that implements the aggregate + ** function. + ** + ** This routine must be called from the same thread in which + ** the aggregate SQL function is running. + */ + //SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes); + + /* + ** CAPI3REF: User Data For Functions + ** + ** ^The sqlite3_user_data() interface returns a copy of + ** the pointer that was the pUserData parameter (the 5th parameter) + ** of the [sqlite3_create_function()] + ** and [sqlite3_create_function16()] routines that originally + ** registered the application defined function. + ** + ** This routine must be called from the same thread in which + ** the application-defined function is running. + */ + //SQLITE_API void *sqlite3_user_data(sqlite3_context); + + /* + ** CAPI3REF: Database Connection For Functions + ** + ** ^The sqlite3_context_db_handle() interface returns a copy of + ** the pointer to the [database connection] (the 1st parameter) + ** of the [sqlite3_create_function()] + ** and [sqlite3_create_function16()] routines that originally + ** registered the application defined function. + */ + //SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context); + + /* + ** CAPI3REF: Function Auxiliary Data + ** + ** The following two functions may be used by scalar SQL functions to + ** associate metadata with argument values. If the same value is passed to + ** multiple invocations of the same SQL function during query execution, under + ** some circumstances the associated metadata may be preserved. This may + ** be used, for example, to add a regular-expression matching scalar + ** function. The compiled version of the regular expression is stored as + ** metadata associated with the SQL value passed as the regular expression + ** pattern. The compiled regular expression can be reused on multiple + ** invocations of the same function so that the original pattern string + ** does not need to be recompiled on each invocation. + ** + ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata + ** associated by the sqlite3_set_auxdata() function with the Nth argument + ** value to the application-defined function. ^If no metadata has been ever + ** been set for the Nth argument of the function, or if the corresponding + ** function parameter has changed since the meta-data was set, + ** then sqlite3_get_auxdata() returns a NULL pointer. + ** + ** ^The sqlite3_set_auxdata() interface saves the metadata + ** pointed to by its 3rd parameter as the metadata for the N-th + ** argument of the application-defined function. Subsequent + ** calls to sqlite3_get_auxdata() might return this data, if it has + ** not been destroyed. + ** ^If it is not NULL, SQLite will invoke the destructor + ** function given by the 4th parameter to sqlite3_set_auxdata() on + ** the metadata when the corresponding function parameter changes + ** or when the SQL statement completes, whichever comes first. + ** + ** SQLite is free to call the destructor and drop metadata on any + ** parameter of any function at any time. ^The only guarantee is that + ** the destructor will be called before the metadata is dropped. + ** + ** ^(In practice, metadata is preserved between function calls for + ** expressions that are constant at compile time. This includes literal + ** values and [parameters].)^ + ** + ** These routines must be called from the same thread in which + ** the SQL function is running. + */ + //SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); + //SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, object ()(void)); + + + /* + ** CAPI3REF: Constants Defining Special Destructor Behavior + ** + ** These are special values for the destructor that is passed in as the + ** final argument to routines like [sqlite3_result_blob()]. ^If the destructor + ** argument is SQLITE_STATIC, it means that the content pointer is constant + ** and will never change. It does not need to be destroyed. ^The + ** SQLITE_TRANSIENT value means that the content will likely change in + ** the near future and that SQLite should make its own private copy of + ** the content before returning. + ** + ** The typedef is necessary to work around problems in certain + ** C++ compilers. See ticket #2191. + */ + //typedef void (*sqlite3_destructor_type)(void); + //#define SQLITE_STATIC ((sqlite3_destructor_type)0) + //#define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1) + static public dxDel SQLITE_STATIC; + static public dxDel SQLITE_TRANSIENT; + /* + ** CAPI3REF: Setting The Result Of An SQL Function + ** + ** These routines are used by the xFunc or xFinal callbacks that + ** implement SQL functions and aggregates. See + ** [sqlite3_create_function()] and [sqlite3_create_function16()] + ** for additional information. + ** + ** These functions work very much like the [parameter binding] family of + ** functions used to bind values to host parameters in prepared statements. + ** Refer to the [SQL parameter] documentation for additional information. + ** + ** ^The sqlite3_result_blob() interface sets the result from + ** an application-defined function to be the BLOB whose content is pointed + ** to by the second parameter and which is N bytes long where N is the + ** third parameter. + ** + ** ^The sqlite3_result_zeroblob() interfaces set the result of + ** the application-defined function to be a BLOB containing all zero + ** bytes and N bytes in size, where N is the value of the 2nd parameter. + ** + ** ^The sqlite3_result_double() interface sets the result from + ** an application-defined function to be a floating point value specified + ** by its 2nd argument. + ** + ** ^The sqlite3_result_error() and sqlite3_result_error16() functions + ** cause the implemented SQL function to throw an exception. + ** ^SQLite uses the string pointed to by the + ** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16() + ** as the text of an error message. ^SQLite interprets the error + ** message string from sqlite3_result_error() as UTF-8. ^SQLite + ** interprets the string from sqlite3_result_error16() as UTF-16 in native + ** byte order. ^If the third parameter to sqlite3_result_error() + ** or sqlite3_result_error16() is negative then SQLite takes as the error + ** message all text up through the first zero character. + ** ^If the third parameter to sqlite3_result_error() or + ** sqlite3_result_error16() is non-negative then SQLite takes that many + ** bytes (not characters) from the 2nd parameter as the error message. + ** ^The sqlite3_result_error() and sqlite3_result_error16() + ** routines make a private copy of the error message text before + ** they return. Hence, the calling function can deallocate or + ** modify the text after they return without harm. + ** ^The sqlite3_result_error_code() function changes the error code + ** returned by SQLite as a result of an error in a function. ^By default, + ** the error code is SQLITE_ERROR. ^A subsequent call to sqlite3_result_error() + ** or sqlite3_result_error16() resets the error code to SQLITE_ERROR. + ** + ** ^The sqlite3_result_toobig() interface causes SQLite to throw an error + ** indicating that a string or BLOB is too long to represent. + ** + ** ^The sqlite3_result_nomem() interface causes SQLite to throw an error + ** indicating that a memory allocation failed. + ** + ** ^The sqlite3_result_int() interface sets the return value + ** of the application-defined function to be the 32-bit signed integer + ** value given in the 2nd argument. + ** ^The sqlite3_result_int64() interface sets the return value + ** of the application-defined function to be the 64-bit signed integer + ** value given in the 2nd argument. + ** + ** ^The sqlite3_result_null() interface sets the return value + ** of the application-defined function to be NULL. + ** + ** ^The sqlite3_result_text(), sqlite3_result_text16(), + ** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces + ** set the return value of the application-defined function to be + ** a text string which is represented as UTF-8, UTF-16 native byte order, + ** UTF-16 little endian, or UTF-16 big endian, respectively. + ** ^SQLite takes the text result from the application from + ** the 2nd parameter of the sqlite3_result_text* interfaces. + ** ^If the 3rd parameter to the sqlite3_result_text* interfaces + ** is negative, then SQLite takes result text from the 2nd parameter + ** through the first zero character. + ** ^If the 3rd parameter to the sqlite3_result_text* interfaces + ** is non-negative, then as many bytes (not characters) of the text + ** pointed to by the 2nd parameter are taken as the application-defined + ** function result. + ** ^If the 4th parameter to the sqlite3_result_text* interfaces + ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that + ** function as the destructor on the text or BLOB result when it has + ** finished using that result. + ** ^If the 4th parameter to the sqlite3_result_text* interfaces or to + ** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite + ** assumes that the text or BLOB result is in constant space and does not + ** copy the content of the parameter nor call a destructor on the content + ** when it has finished using that result. + ** ^If the 4th parameter to the sqlite3_result_text* interfaces + ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT + ** then SQLite makes a copy of the result into space obtained from + ** from [sqlite3_malloc()] before it returns. + ** + ** ^The sqlite3_result_value() interface sets the result of + ** the application-defined function to be a copy the + ** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The + ** sqlite3_result_value() interface makes a copy of the [sqlite3_value] + ** so that the [sqlite3_value] specified in the parameter may change or + ** be deallocated after sqlite3_result_value() returns without harm. + ** ^A [protected sqlite3_value] object may always be used where an + ** [unprotected sqlite3_value] object is required, so either + ** kind of [sqlite3_value] object can be used with this interface. + ** + ** If these routines are called from within the different thread + ** than the one containing the application-defined function that received + ** the [sqlite3_context] pointer, the results are undefined. + */ + //SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void()(void)); + //SQLITE_API void sqlite3_result_double(sqlite3_context*, double); + //SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int); + //SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int); + //SQLITE_API void sqlite3_result_error_toobig(sqlite3_context); + //SQLITE_API void sqlite3_result_error_nomem(sqlite3_context); + //SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int); + //SQLITE_API void sqlite3_result_int(sqlite3_context*, int); + //SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64); + //SQLITE_API void sqlite3_result_null(sqlite3_context); + //SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void()(void)); + //SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void()(void)); + //SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void()(void)); + //SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void()(void)); + //SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value); + //SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); + + /* + ** CAPI3REF: Define New Collating Sequences + ** + ** ^These functions add, remove, or modify a [collation] associated + ** with the [database connection] specified as the first argument. + ** + ** ^The name of the collation is a UTF-8 string + ** for sqlite3_create_collation() and sqlite3_create_collation_v2() + ** and a UTF-16 string in native byte order for sqlite3_create_collation16(). + ** ^Collation names that compare equal according to [sqlite3_strnicmp()] are + ** considered to be the same name. + ** + ** ^(The third argument (eTextRep) must be one of the constants: + **
    + **
  • [SQLITE_UTF8], + **
  • [SQLITE_UTF16LE], + **
  • [SQLITE_UTF16BE], + **
  • [SQLITE_UTF16], or + **
  • [SQLITE_UTF16_ALIGNED]. + **
)^ + ** ^The eTextRep argument determines the encoding of strings passed + ** to the collating function callback, xCallback. + ** ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep + ** force strings to be UTF16 with native byte order. + ** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin + ** on an even byte address. + ** + ** ^The fourth argument, pArg, is an application data pointer that is passed + ** through as the first argument to the collating function callback. + ** + ** ^The fifth argument, xCallback, is a pointer to the collating function. + ** ^Multiple collating functions can be registered using the same name but + ** with different eTextRep parameters and SQLite will use whichever + ** function requires the least amount of data transformation. + ** ^If the xCallback argument is NULL then the collating function is + ** deleted. ^When all collating functions having the same name are deleted, + ** that collation is no longer usable. + ** + ** ^The collating function callback is invoked with a copy of the pArg + ** application data pointer and with two strings in the encoding specified + ** by the eTextRep argument. The collating function must return an + ** integer that is negative, zero, or positive + ** if the first string is less than, equal to, or greater than the second, + ** respectively. A collating function must always return the same answer + ** given the same inputs. If two or more collating functions are registered + ** to the same collation name (using different eTextRep values) then all + ** must give an equivalent answer when invoked with equivalent strings. + ** The collating function must obey the following properties for all + ** strings A, B, and C: + ** + **
    + **
  1. If A==B then B==A. + **
  2. If A==B and B==C then A==C. + **
  3. If A<B THEN B>A. + **
  4. If A<B and B<C then A<C. + **
+ ** + ** If a collating function fails any of the above constraints and that + ** collating function is registered and used, then the behavior of SQLite + ** is undefined. + ** + ** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation() + ** with the addition that the xDestroy callback is invoked on pArg when + ** the collating function is deleted. + ** ^Collating functions are deleted when they are overridden by later + ** calls to the collation creation functions or when the + ** [database connection] is closed using [sqlite3_close()]. + ** + ** ^The xDestroy callback is not called if the + ** sqlite3_create_collation_v2() function fails. Applications that invoke + ** sqlite3_create_collation_v2() with a non-NULL xDestroy argument should + ** check the return code and dispose of the application data pointer + ** themselves rather than expecting SQLite to deal with it for them. + ** This is different from every other SQLite interface. The inconsistency + ** is unfortunate but cannot be changed without breaking backwards + ** compatibility. + ** + ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()]. + */ + //SQLITE_API int sqlite3_create_collation( + // sqlite3*, + // string zName, + // int eTextRep, + // void *pArg, + // int(*xCompare)(void*,int,const void*,int,const void) + //); + //SQLITE_API int sqlite3_create_collation_v2( + // sqlite3*, + // string zName, + // int eTextRep, + // void *pArg, + // int(*xCompare)(void*,int,const void*,int,const void), + // void(*xDestroy)(void) + //); + //SQLITE_API int sqlite3_create_collation16( + // sqlite3*, + // string zName, + // int eTextRep, + // void *pArg, + // int(*xCompare)(void*,int,const void*,int,const void) + //); + + /* + ** CAPI3REF: Collation Needed Callbacks + ** + ** ^To avoid having to register all collation sequences before a database + ** can be used, a single callback function may be registered with the + ** [database connection] to be invoked whenever an undefined collation + ** sequence is required. + ** + ** ^If the function is registered using the sqlite3_collation_needed() API, + ** then it is passed the names of undefined collation sequences as strings + ** encoded in UTF-8. ^If sqlite3_collation_needed16() is used, + ** the names are passed as UTF-16 in machine native byte order. + ** ^A call to either function replaces the existing collation-needed callback. + ** + ** ^(When the callback is invoked, the first argument passed is a copy + ** of the second argument to sqlite3_collation_needed() or + ** sqlite3_collation_needed16(). The second argument is the database + ** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE], + ** or [SQLITE_UTF16LE], indicating the most desirable form of the collation + ** sequence function required. The fourth parameter is the name of the + ** required collation sequence.)^ + ** + ** The callback function should register the desired collation using + ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or + ** [sqlite3_create_collation_v2()]. + */ + //SQLITE_API int sqlite3_collation_needed( + // sqlite3*, + // void*, + // void()(void*,sqlite3*,int eTextRep,const char) + //); + //SQLITE_API int sqlite3_collation_needed16( + // sqlite3*, + // void*, + // void()(void*,sqlite3*,int eTextRep,const void) + //); + + //#if SQLITE_HAS_CODEC + /* + ** Specify the key for an encrypted database. This routine should be + ** called right after sqlite3_open(). + ** + ** The code to implement this API is not available in the public release + ** of SQLite. + */ + //SQLITE_API int sqlite3_key( + // sqlite3 db, /* Database to be rekeyed */ + // const void *pKey, int nKey /* The key */ + //); + + /* + ** Change the key on an open database. If the current database is not + ** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the + ** database is decrypted. + ** + ** The code to implement this API is not available in the public release + ** of SQLite. + */ + //SQLITE_API int sqlite3_rekey( + // sqlite3 db, /* Database to be rekeyed */ + // const void *pKey, int nKey /* The new key */ + //); + + /* + ** Specify the activation key for a SEE database. Unless + ** activated, none of the SEE routines will work. + */ + //SQLITE_API void sqlite3_activate_see( + // string zPassPhrase /* Activation phrase */ + //); + //#endif + + //#if SQLITE_ENABLE_CEROD + /* + ** Specify the activation key for a CEROD database. Unless + ** activated, none of the CEROD routines will work. + */ + //SQLITE_API void sqlite3_activate_cerod( + // string zPassPhrase /* Activation phrase */ + //); + //#endif + + /* + ** CAPI3REF: Suspend Execution For A Short Time + ** + ** The sqlite3_sleep() function causes the current thread to suspend execution + ** for at least a number of milliseconds specified in its parameter. + ** + ** If the operating system does not support sleep requests with + ** millisecond time resolution, then the time will be rounded up to + ** the nearest second. The number of milliseconds of sleep actually + ** requested from the operating system is returned. + ** + ** ^SQLite implements this interface by calling the xSleep() + ** method of the default [sqlite3_vfs] object. If the xSleep() method + ** of the default VFS is not implemented correctly, or not implemented at + ** all, then the behavior of sqlite3_sleep() may deviate from the description + ** in the previous paragraphs. + */ + //SQLITE_API int sqlite3_sleep(int); + + /* + ** CAPI3REF: Name Of The Folder Holding Temporary Files + ** + ** ^(If this global variable is made to point to a string which is + ** the name of a folder (a.k.a. directory), then all temporary files + ** created by SQLite when using a built-in [sqlite3_vfs | VFS] + ** will be placed in that directory.)^ ^If this variable + ** is a NULL pointer, then SQLite performs a search for an appropriate + ** temporary file directory. + ** + ** It is not safe to read or modify this variable in more than one + ** thread at a time. It is not safe to read or modify this variable + ** if a [database connection] is being used at the same time in a separate + ** thread. + ** It is intended that this variable be set once + ** as part of process initialization and before any SQLite interface + ** routines have been called and that this variable remain unchanged + ** thereafter. + ** + ** ^The [temp_store_directory pragma] may modify this variable and cause + ** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, + ** the [temp_store_directory pragma] always assumes that any string + ** that this variable points to is held in memory obtained from + ** [sqlite3_malloc] and the pragma may attempt to free that memory + ** using [sqlite3_free]. + ** Hence, if this variable is modified directly, either it should be + ** made NULL or made to point to memory obtained from [sqlite3_malloc] + ** or else the use of the [temp_store_directory pragma] should be avoided. + */ + //SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory; + + /* + ** CAPI3REF: Test For Auto-Commit Mode + ** KEYWORDS: {autocommit mode} + ** + ** ^The sqlite3_get_autocommit() interface returns non-zero or + ** zero if the given database connection is or is not in autocommit mode, + ** respectively. ^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 certain kinds of errors occur on a statement within a multi-statement + ** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR], + ** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the + ** transaction might be rolled back automatically. The only way to + ** find out whether SQLite automatically rolled back the transaction after + ** an error is to use this function. + ** + ** If another thread changes the autocommit status of the database + ** connection while this routine is running, then the return value + ** is undefined. + */ + //SQLITE_API int sqlite3_get_autocommit(sqlite3); + + /* + ** CAPI3REF: Find The Database Handle Of A Prepared Statement + ** + ** ^The sqlite3_db_handle interface returns the [database connection] handle + ** to which a [prepared statement] belongs. ^The [database connection] + ** returned by sqlite3_db_handle is the same [database connection] + ** that was the first argument + ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to + ** create the statement in the first place. + */ + //SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt); + + /* + ** CAPI3REF: Find the next prepared statement + ** + ** ^This interface returns a pointer to the next [prepared statement] after + ** pStmt associated with the [database connection] pDb. ^If pStmt is NULL + ** then this interface returns a pointer to the first prepared statement + ** associated with the database connection pDb. ^If no prepared statement + ** satisfies the conditions of this routine, it returns NULL. + ** + ** The [database connection] pointer D in a call to + ** [sqlite3_next_stmt(D,S)] must refer to an open database + ** connection and in particular must not be a NULL pointer. + */ + //SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); + + /* + ** CAPI3REF: Commit And Rollback Notification Callbacks + ** + ** ^The sqlite3_commit_hook() interface registers a callback + ** function to be invoked whenever a transaction is [COMMIT | committed]. + ** ^Any callback set by a previous call to sqlite3_commit_hook() + ** for the same database connection is overridden. + ** ^The sqlite3_rollback_hook() interface registers a callback + ** function to be invoked whenever a transaction is [ROLLBACK | rolled back]. + ** ^Any callback set by a previous call to sqlite3_rollback_hook() + ** for the same database connection is overridden. + ** ^The pArg argument is passed through to the callback. + ** ^If the callback on a commit hook function returns non-zero, + ** then the commit is converted into a rollback. + ** + ** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions + ** return the P argument from the previous call of the same function + ** on the same [database connection] D, or NULL for + ** the first call for each function on D. + ** + ** The callback implementation must not do anything that will modify + ** the database connection that invoked the callback. Any actions + ** to modify the database connection must be deferred until after the + ** completion of the [sqlite3_step()] call that triggered the commit + ** or rollback hook in the first place. + ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their + ** database connections for the meaning of "modify" in this paragraph. + ** + ** ^Registering a NULL function disables the callback. + ** + ** ^When the commit hook callback routine returns zero, the [COMMIT] + ** operation is allowed to continue normally. ^If the commit hook + ** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK]. + ** ^The rollback hook is invoked on a rollback that results from a commit + ** hook returning non-zero, just as it would be with any other rollback. + ** + ** ^For the purposes of this API, a transaction is said to have been + ** rolled back if an explicit "ROLLBACK" statement is executed, or + ** an error or constraint causes an implicit rollback to occur. + ** ^The rollback callback is not invoked if a transaction is + ** automatically rolled back because the database connection is closed. + ** + ** See also the [sqlite3_update_hook()] interface. + */ + //SQLITE_API void *sqlite3_commit_hook(sqlite3*, int()(void), void); + //SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void()(void ), void); + + /* + ** CAPI3REF: Data Change Notification Callbacks + ** + ** ^The sqlite3_update_hook() interface registers a callback function + ** with the [database connection] identified by the first argument + ** to be invoked whenever a row is updated, inserted or deleted. + ** ^Any callback set by a previous call to this function + ** for the same database connection is overridden. + ** + ** ^The second argument is a pointer to the function to invoke when a + ** row is updated, inserted or deleted. + ** ^The first argument to the callback is a copy of the third argument + ** to sqlite3_update_hook(). + ** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE], + ** or [SQLITE_UPDATE], depending on the operation that caused the callback + ** to be invoked. + ** ^The third and fourth arguments to the callback contain pointers to the + ** database and table name containing the affected row. + ** ^The final callback parameter is the [rowid] of the row. + ** ^In the case of an update, this is the [rowid] after the update takes place. + ** + ** ^(The update hook is not invoked when internal system tables are + ** modified (i.e. sqlite_master and sqlite_sequence).)^ + ** + ** ^In the current implementation, the update hook + ** is not invoked when duplication rows are deleted because of an + ** [ON CONFLICT | ON CONFLICT REPLACE] clause. ^Nor is the update hook + ** invoked when rows are deleted using the [truncate optimization]. + ** The exceptions defined in this paragraph might change in a future + ** release of SQLite. + ** + ** The update hook implementation must not do anything that will modify + ** the database connection that invoked the update hook. Any actions + ** to modify the database connection must be deferred until after the + ** completion of the [sqlite3_step()] call that triggered the update hook. + ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their + ** database connections for the meaning of "modify" in this paragraph. + ** + ** ^The sqlite3_update_hook(D,C,P) function + ** returns the P argument from the previous call + ** on the same [database connection] D, or NULL for + ** the first call on D. + ** + ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()] + ** interfaces. + */ + //SQLITE_API void *sqlite3_update_hook( + // sqlite3*, + // void()(void *,int ,char const *,char const *,sqlite3_int64), + // void* + //); + + /* + ** CAPI3REF: Enable Or Disable Shared Pager Cache + ** KEYWORDS: {shared cache} + ** + ** ^(This routine enables or disables the sharing of the database cache + ** and schema data structures between [database connection | connections] + ** to the same database. Sharing is enabled if the argument is true + ** and disabled if the argument is false.)^ + ** + ** ^Cache sharing is enabled and disabled for an entire process. + ** This is a change as of SQLite version 3.5.0. In prior versions of SQLite, + ** sharing was enabled or disabled for each thread separately. + ** + ** ^(The cache sharing mode set by this interface effects all subsequent + ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()]. + ** Existing database connections continue use the sharing mode + ** that was in effect at the time they were opened.)^ + ** + ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled + ** successfully. An [error code] is returned otherwise.)^ + ** + ** ^Shared cache is disabled by default. But this might change in + ** future releases of SQLite. Applications that care about shared + ** cache setting should set it explicitly. + ** + ** See Also: [SQLite Shared-Cache Mode] + */ + //SQLITE_API int sqlite3_enable_shared_cache(int); + + /* + ** CAPI3REF: Attempt To Free Heap Memory + ** + ** ^The sqlite3_release_memory() interface attempts to free N bytes + ** of heap memory by deallocating non-essential memory allocations + ** held by the database library. Memory used to cache database + ** pages to improve performance is an example of non-essential memory. + ** ^sqlite3_release_memory() returns the number of bytes actually freed, + ** which might be more or less than the amount requested. + ** ^The sqlite3_release_memory() routine is a no-op returning zero + ** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT]. + */ + //SQLITE_API int sqlite3_release_memory(int); + + /* + ** CAPI3REF: Impose A Limit On Heap Size + ** + ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the + ** soft limit on the amount of heap memory that may be allocated by SQLite. + ** ^SQLite strives to keep heap memory utilization below the soft heap + ** limit by reducing the number of pages held in the page cache + ** as heap memory usages approaches the limit. + ** ^The soft heap limit is "soft" because even though SQLite strives to stay + ** below the limit, it will exceed the limit rather than generate + ** an [SQLITE_NOMEM] error. In other words, the soft heap limit + ** is advisory only. + ** + ** ^The return value from sqlite3_soft_heap_limit64() is the size of + ** the soft heap limit prior to the call. ^If the argument N is negative + ** then no change is made to the soft heap limit. Hence, the current + ** size of the soft heap limit can be determined by invoking + ** sqlite3_soft_heap_limit64() with a negative argument. + ** + ** ^If the argument N is zero then the soft heap limit is disabled. + ** + ** ^(The soft heap limit is not enforced in the current implementation + ** if one or more of following conditions are true: + ** + **
    + **
  • The soft heap limit is set to zero. + **
  • Memory accounting is disabled using a combination of the + ** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and + ** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option. + **
  • An alternative page cache implementation is specified using + ** [sqlite3_config]([SQLITE_CONFIG_PCACHE],...). + **
  • The page cache allocates from its own memory pool supplied + ** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than + ** from the heap. + **
)^ + ** + ** Beginning with SQLite version 3.7.3, the soft heap limit is enforced + ** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT] + ** compile-time option is invoked. With [SQLITE_ENABLE_MEMORY_MANAGEMENT], + ** the soft heap limit is enforced on every memory allocation. Without + ** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced + ** when memory is allocated by the page cache. Testing suggests that because + ** the page cache is the predominate memory user in SQLite, most + ** applications will achieve adequate soft heap limit enforcement without + ** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT]. + ** + ** The circumstances under which SQLite will enforce the soft heap limit may + ** changes in future releases of SQLite. + */ + //SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N); + + /* + ** CAPI3REF: Deprecated Soft Heap Limit Interface + ** DEPRECATED + ** + ** This is a deprecated version of the [sqlite3_soft_heap_limit64()] + ** interface. This routine is provided for historical compatibility + ** only. All new applications should use the + ** [sqlite3_soft_heap_limit64()] interface rather than this one. + */ + //SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N); + + + /* + ** CAPI3REF: Extract Metadata About A Column Of A Table + ** + ** ^This routine returns metadata about a specific column of a specific + ** database table accessible using the [database connection] handle + ** passed as the first function argument. + ** + ** ^The column is identified by the second, third and fourth parameters to + ** this function. ^The second parameter is either the name of the database + ** (i.e. "main", "temp", or an attached database) containing the specified + ** table or NULL. ^If it is NULL, then all attached databases are searched + ** for the table using the same algorithm used by the database engine to + ** resolve unqualified table references. + ** + ** ^The third and fourth parameters to this function are the table and column + ** name of the desired column, respectively. Neither of these parameters + ** may be NULL. + ** + ** ^Metadata is returned by writing to the memory locations passed as the 5th + ** and subsequent parameters to this function. ^Any of these arguments may be + ** NULL, in which case the corresponding element of metadata is omitted. + ** + ** ^(
+ ** + **
Parameter Output
Type
Description + ** + **
5th const char* Data type + **
6th const char* Name of default collation sequence + **
7th int True if column has a NOT NULL constraint + **
8th int True if column is part of the PRIMARY KEY + **
9th int True if column is [AUTOINCREMENT] + **
+ **
)^ + ** + ** ^The memory pointed to by the character pointers returned for the + ** declaration type and collation sequence is valid only until the next + ** call to any SQLite API function. + ** + ** ^If the specified table is actually a view, an [error code] is returned. + ** + ** ^If the specified column is "rowid", "oid" or "_rowid_" and an + ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output + ** parameters are set for the explicitly declared column. ^(If there is no + ** explicitly declared [INTEGER PRIMARY KEY] column, then the output + ** parameters are set as follows: + ** + **
+        **     data type: "INTEGER"
+        **     collation sequence: "BINARY"
+        **     not null: 0
+        **     primary key: 1
+        **     auto increment: 0
+        ** 
)^ + ** + ** ^(This function may load one or more schemas from database files. If an + ** error occurs during this process, or if the requested table or column + ** cannot be found, an [error code] is returned and an error message left + ** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^ + ** + ** ^This API is only available if the library was compiled with the + ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined. + */ + //SQLITE_API int sqlite3_table_column_metadata( + // sqlite3 db, /* Connection handle */ + // string zDbName, /* Database name or NULL */ + // string zTableName, /* Table name */ + // string zColumnName, /* Column name */ + // char const **pzDataType, /* OUTPUT: Declared data type */ + // char const **pzCollSeq, /* OUTPUT: Collation sequence name */ + // int *pNotNull, /* OUTPUT: True if NOT NULL constraint exists */ + // int *pPrimaryKey, /* OUTPUT: True if column part of PK */ + // int *pAutoinc /* OUTPUT: True if column is auto-increment */ + //); + + /* + ** CAPI3REF: Load An Extension + ** + ** ^This interface loads an SQLite extension library from the named file. + ** + ** ^The sqlite3_load_extension() interface attempts to load an + ** SQLite extension library contained in the file zFile. + ** + ** ^The entry point is zProc. + ** ^zProc may be 0, in which case the name of the entry point + ** defaults to "sqlite3_extension_init". + ** ^The sqlite3_load_extension() interface returns + ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong. + ** ^If an error occurs and pzErrMsg is not 0, then the + ** [sqlite3_load_extension()] interface shall attempt to + ** fill *pzErrMsg with error message text stored in memory + ** obtained from [sqlite3_malloc()]. The calling function + ** should free this memory by calling [sqlite3_free()]. + ** + ** ^Extension loading must be enabled using + ** [sqlite3_enable_load_extension()] prior to calling this API, + ** otherwise an error will be returned. + ** + ** See also the [load_extension() SQL function]. + */ + //SQLITE_API int sqlite3_load_extension( + // sqlite3 db, /* Load the extension into this database connection */ + // string zFile, /* Name of the shared library containing extension */ + // string zProc, /* Entry point. Derived from zFile if 0 */ + // char **pzErrMsg /* Put error message here if not 0 */ + //); + + /* + ** CAPI3REF: Enable Or Disable Extension Loading + ** + ** ^So as not to open security holes in older applications that are + ** unprepared to deal with extension loading, and as a means of disabling + ** extension loading while evaluating user-entered SQL, the following API + ** is provided to turn the [sqlite3_load_extension()] mechanism on and off. + ** + ** ^Extension loading is off by default. See ticket #1863. + ** ^Call the sqlite3_enable_load_extension() routine with onoff==1 + ** to turn extension loading on and call it with onoff==0 to turn + ** it back off again. + */ + //SQLITE_API int sqlite3_enable_load_extension(sqlite3 db, int onoff); + + /* + ** CAPI3REF: Automatically Load Statically Linked Extensions + ** + ** ^This interface causes the xEntryPoint() function to be invoked for + ** each new [database connection] that is created. The idea here is that + ** xEntryPoint() is the entry point for a statically linked SQLite extension + ** that is to be automatically loaded into all new database connections. + ** + ** ^(Even though the function prototype shows that xEntryPoint() takes + ** no arguments and returns void, SQLite invokes xEntryPoint() with three + ** arguments and expects and integer result as if the signature of the + ** entry point where as follows: + ** + **
+        **    int xEntryPoint(
+        **      sqlite3 db,
+        **      string *pzErrMsg,
+        **      const struct sqlite3_api_routines *pThunk
+        **    );
+        ** 
)^ + ** + ** If the xEntryPoint routine encounters an error, it should make *pzErrMsg + ** point to an appropriate error message (obtained from [sqlite3_mprintf()]) + ** and return an appropriate [error code]. ^SQLite ensures that *pzErrMsg + ** is NULL before calling the xEntryPoint(). ^SQLite will invoke + ** [sqlite3_free()] on *pzErrMsg after xEntryPoint() returns. ^If any + ** xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()], + ** or [sqlite3_open_v2()] call that provoked the xEntryPoint() will fail. + ** + ** ^Calling sqlite3_auto_extension(X) with an entry point X that is already + ** on the list of automatic extensions is a harmless no-op. ^No entry point + ** will be called more than once for each database connection that is opened. + ** + ** See also: [sqlite3_reset_auto_extension()]. + */ + //SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void)); + + /* + ** CAPI3REF: Reset Automatic Extension Loading + ** + ** ^This interface disables all automatic extensions previously + ** registered using [sqlite3_auto_extension()]. + */ + //SQLITE_API void sqlite3_reset_auto_extension(void); + + /* + ** The interface to the virtual-table mechanism is currently considered + ** to be experimental. The interface might change in incompatible ways. + ** If this is a problem for you, do not use the interface at this time. + ** + ** When the virtual-table mechanism stabilizes, we will declare the + ** interface fixed, support it indefinitely, and remove this comment. + */ + + /* + ** Structures used by the virtual table interface + */ + //typedef struct sqlite3_vtab sqlite3_vtab; + //typedef struct sqlite3_index_info sqlite3_index_info; + //typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor; + //typedef struct sqlite3_module sqlite3_module; + + /* + ** CAPI3REF: Virtual Table Object + ** KEYWORDS: sqlite3_module {virtual table module} + ** + ** This structure, sometimes called a "virtual table module", + ** defines the implementation of a [virtual tables]. + ** This structure consists mostly of methods for the module. + ** + ** ^A virtual table module is created by filling in a persistent + ** instance of this structure and passing a pointer to that instance + ** to [sqlite3_create_module()] or [sqlite3_create_module_v2()]. + ** ^The registration remains valid until it is replaced by a different + ** module or until the [database connection] closes. The content + ** of this structure must not change while it is registered with + ** any database connection. + */ + //struct sqlite3_module { + // int iVersion; + // int (*xCreate)(sqlite3*, object *pAux, + // int argc, string[] argv, + // sqlite3_vtab **ppVTab, char*); + // int (*xConnect)(sqlite3*, object *pAux, + // int argc, string[] argv, + // sqlite3_vtab **ppVTab, char*); + // int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info); + // int (*xDisconnect)(sqlite3_vtab *pVTab); + // int (*xDestroy)(sqlite3_vtab *pVTab); + // int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor); + // int (*xClose)(sqlite3_vtab_cursor); + // int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, string idxStr, + // int argc, sqlite3_value **argv); + // int (*xNext)(sqlite3_vtab_cursor); + // int (*xEof)(sqlite3_vtab_cursor); + // int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int); + // int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid); + // int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 ); + // int (*xBegin)(sqlite3_vtab *pVTab); + // int (*xSync)(sqlite3_vtab *pVTab); + // int (*xCommit)(sqlite3_vtab *pVTab); + // int (*xRollback)(sqlite3_vtab *pVTab); + // int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, string zName, + // void (**pxFunc)(sqlite3_context*,int,sqlite3_value*), + // void **ppArg); + // int (*xRename)(sqlite3_vtab *pVtab, string zNew); + ///* The methods above are in version 1 of the sqlite_module object. Those + //** below are for version 2 and greater. */ + //int (*xSavepoint)(sqlite3_vtab *pVTab, int); + //int (*xRelease)(sqlite3_vtab *pVTab, int); + //int (*xRollbackTo)(sqlite3_vtab *pVTab, int); + //}; + // MINIMAL STRUCTURE + public class sqlite3_module { + public int iVersion; + public smdxCreateConnect xCreate; + public smdxCreateConnect xConnect; + public smdxBestIndex xBestIndex; + public smdxDisconnect xDisconnect; + public smdxDestroy xDestroy; + public smdxOpen xOpen; + public smdxClose xClose; + public smdxFilter xFilter; + public smdxNext xNext; + public smdxEof xEof; + public smdxColumn xColumn; + public smdxRowid xRowid; + public smdxUpdate xUpdate; + public smdxFunction xBegin; + public smdxFunction xSync; + public smdxFunction xCommit; + public smdxFunction xRollback; + public smdxFindFunction xFindFunction; + public smdxRename xRename; + /* The methods above are in version 1 of the sqlite_module object. Those + ** below are for version 2 and greater. */ + public smdxFunctionArg xSavepoint; + public smdxFunctionArg xRelease; + public smdxFunctionArg xRollbackTo; + + //Version 1 + public sqlite3_module( + int iVersion, + smdxCreateConnect xCreate, + smdxCreateConnect xConnect, + smdxBestIndex xBestIndex, + smdxDisconnect xDisconnect, + smdxDestroy xDestroy, + smdxOpen xOpen, + smdxClose xClose, + smdxFilter xFilter, + smdxNext xNext, + smdxEof xEof, + smdxColumn xColumn, + smdxRowid xRowid, + smdxUpdate xUpdate, + smdxFunction xBegin, + smdxFunction xSync, + smdxFunction xCommit, + smdxFunction xRollback, + smdxFindFunction xFindFunction, + smdxRename xRename) { + this.iVersion = iVersion; + this.xCreate = xCreate; + this.xConnect = xConnect; + this.xBestIndex = xBestIndex; + this.xDisconnect = xDisconnect; + this.xDestroy = xDestroy; + this.xOpen = xOpen; + this.xClose = xClose; + this.xFilter = xFilter; + this.xNext = xNext; + this.xEof = xEof; + this.xColumn = xColumn; + this.xRowid = xRowid; + this.xUpdate = xUpdate; + this.xBegin = xBegin; + this.xSync = xSync; + this.xCommit = xCommit; + this.xRollback = xRollback; + this.xFindFunction = xFindFunction; + this.xRename = xRename; + } + + //Version 2 + public sqlite3_module( + int iVersion, + smdxCreateConnect xCreate, + smdxCreateConnect xConnect, + smdxBestIndex xBestIndex, + smdxDisconnect xDisconnect, + smdxDestroy xDestroy, + smdxOpen xOpen, + smdxClose xClose, + smdxFilter xFilter, + smdxNext xNext, + smdxEof xEof, + smdxColumn xColumn, + smdxRowid xRowid, + smdxUpdate xUpdate, + smdxFunction xBegin, + smdxFunction xSync, + smdxFunction xCommit, + smdxFunction xRollback, + smdxFindFunction xFindFunction, + smdxRename xRename, + /* The methods above are in version 1 of the sqlite_module object. Those + ** below are for version 2 and greater. */ + smdxFunctionArg xSavepoint, + smdxFunctionArg xRelease, + smdxFunctionArg xRollbackTo + ) { + this.iVersion = iVersion; + this.xCreate = xCreate; + this.xConnect = xConnect; + this.xBestIndex = xBestIndex; + this.xDisconnect = xDisconnect; + this.xDestroy = xDestroy; + this.xOpen = xOpen; + this.xClose = xClose; + this.xFilter = xFilter; + this.xNext = xNext; + this.xEof = xEof; + this.xColumn = xColumn; + this.xRowid = xRowid; + this.xUpdate = xUpdate; + this.xBegin = xBegin; + this.xSync = xSync; + this.xCommit = xCommit; + this.xRollback = xRollback; + this.xFindFunction = xFindFunction; + this.xRename = xRename; + this.xSavepoint = xSavepoint; + this.xRelease = xRelease; + this.xRollbackTo = xRollbackTo; + } + } + + + /* + ** CAPI3REF: Virtual Table Indexing Information + ** KEYWORDS: sqlite3_index_info + ** + ** The sqlite3_index_info structure and its substructures is used as part + ** of the [virtual table] interface to + ** pass information into and receive the reply from the [xBestIndex] + ** method of a [virtual table module]. The fields under **Inputs** are the + ** inputs to xBestIndex and are read-only. xBestIndex inserts its + ** results into the **Outputs** fields. + ** + ** ^(The aConstraint[] array records WHERE clause constraints of the form: + ** + **
column OP expr
+ ** + ** where OP is =, <, <=, >, or >=.)^ ^(The particular operator is + ** stored in aConstraint[].op using one of the + ** [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^ + ** ^(The index of the column is stored in + ** aConstraint[].iColumn.)^ ^(aConstraint[].usable is TRUE if the + ** expr on the right-hand side can be evaluated (and thus the constraint + ** is usable) and false if it cannot.)^ + ** + ** ^The optimizer automatically inverts terms of the form "expr OP column" + ** and makes other simplifications to the WHERE clause in an attempt to + ** get as many WHERE clause terms into the form shown above as possible. + ** ^The aConstraint[] array only reports WHERE clause terms that are + ** relevant to the particular virtual table being queried. + ** + ** ^Information about the ORDER BY clause is stored in aOrderBy[]. + ** ^Each term of aOrderBy records a column of the ORDER BY clause. + ** + ** The [xBestIndex] method must fill aConstraintUsage[] with information + ** about what parameters to pass to xFilter. ^If argvIndex>0 then + ** the right-hand side of the corresponding aConstraint[] is evaluated + ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit + ** is true, then the constraint is assumed to be fully handled by the + ** virtual table and is not checked again by SQLite.)^ + ** + ** ^The idxNum and idxPtr values are recorded and passed into the + ** [xFilter] method. + ** ^[sqlite3_free()] is used to free idxPtr if and only if + ** needToFreeIdxPtr is true. + ** + ** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in + ** the correct order to satisfy the ORDER BY clause so that no separate + ** sorting step is required. + ** + ** ^The estimatedCost value is an estimate of the cost of doing the + ** particular lookup. A full scan of a table with N entries should have + ** a cost of N. A binary search of a table of N entries should have a + ** cost of approximately log(N). + */ + //struct sqlite3_index_info { + // /* Inputs */ + // int nConstraint; /* Number of entries in aConstraint */ + // struct sqlite3_index_constraint { + // int iColumn; /* Column on left-hand side of constraint */ + // unsigned char op; /* Constraint operator */ + // unsigned char usable; /* True if this constraint is usable */ + // int iTermOffset; /* Used internally - xBestIndex should ignore */ + // } *aConstraint; /* Table of WHERE clause constraints */ + // int nOrderBy; /* Number of terms in the ORDER BY clause */ + // struct sqlite3_index_orderby { + // int iColumn; /* Column number */ + // unsigned char desc; /* True for DESC. False for ASC. */ + // } *aOrderBy; /* The ORDER BY clause */ + // /* Outputs */ + // struct sqlite3_index_constraint_usage { + // int argvIndex; /* if >0, constraint is part of argv to xFilter */ + // unsigned char omit; /* Do not code a test for this constraint */ + // } *aConstraintUsage; + // int idxNum; /* Number used to identify the index */ + // char *idxStr; /* String, possibly obtained from sqlite3_malloc */ + // int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */ + // int orderByConsumed; /* True if output is already ordered */ + // double estimatedCost; /* Estimated cost of using this index */ + //}; + public class sqlite3_index_constraint { + public int iColumn; /* Column on left-hand side of constraint */ + public int op; /* Constraint operator */ + public bool usable; /* True if this constraint is usable */ + public int iTermOffset; /* Used internally - xBestIndex should ignore */ + } + public class sqlite3_index_orderby { + public int iColumn; /* Column number */ + public bool desc; /* True for DESC. False for ASC. */ + } + public class sqlite3_index_constraint_usage { + public int argvIndex; /* if >0, constraint is part of argv to xFilter */ + public bool omit; /* Do not code a test for this constraint */ + } + + public class sqlite3_index_info { + /* Inputs */ + public int nConstraint; /* Number of entries in aConstraint */ + public sqlite3_index_constraint[] aConstraint; /* Table of WHERE clause constraints */ + public int nOrderBy; /* Number of terms in the ORDER BY clause */ + public sqlite3_index_orderby[] aOrderBy;/* The ORDER BY clause */ + + /* Outputs */ + + public sqlite3_index_constraint_usage[] aConstraintUsage; + public int idxNum; /* Number used to identify the index */ + public string idxStr; /* String, possibly obtained from sqlite3Malloc */ + public int needToFreeIdxStr; /* Free idxStr using sqlite3DbFree(db,) if true */ + public bool orderByConsumed; /* True if output is already ordered */ + public double estimatedCost; /* Estimated cost of using this index */ + } + + /* + ** CAPI3REF: Virtual Table Constraint Operator Codes + ** + ** These macros defined the allowed values for the + ** [sqlite3_index_info].aConstraint[].op field. Each value represents + ** an operator that is part of a constraint term in the wHERE clause of + ** a query that uses a [virtual table]. + */ + //#define SQLITE_INDEX_CONSTRAINT_EQ 2 + //#define SQLITE_INDEX_CONSTRAINT_GT 4 + //#define SQLITE_INDEX_CONSTRAINT_LE 8 + //#define SQLITE_INDEX_CONSTRAINT_LT 16 + //#define SQLITE_INDEX_CONSTRAINT_GE 32 + //#define SQLITE_INDEX_CONSTRAINT_MATCH 64 + const int SQLITE_INDEX_CONSTRAINT_EQ = 2; + const int SQLITE_INDEX_CONSTRAINT_GT = 4; + const int SQLITE_INDEX_CONSTRAINT_LE = 8; + const int SQLITE_INDEX_CONSTRAINT_LT = 16; + const int SQLITE_INDEX_CONSTRAINT_GE = 32; + const int SQLITE_INDEX_CONSTRAINT_MATCH = 64; + + /* + ** CAPI3REF: Register A Virtual Table Implementation + ** + ** ^These routines are used to register a new [virtual table module] name. + ** ^Module names must be registered before + ** creating a new [virtual table] using the module and before using a + ** preexisting [virtual table] for the module. + ** + ** ^The module name is registered on the [database connection] specified + ** by the first parameter. ^The name of the module is given by the + ** second parameter. ^The third parameter is a pointer to + ** the implementation of the [virtual table module]. ^The fourth + ** parameter is an arbitrary client data pointer that is passed through + ** into the [xCreate] and [xConnect] methods of the virtual table module + ** when a new virtual table is be being created or reinitialized. + ** + ** ^The sqlite3_create_module_v2() interface has a fifth parameter which + ** is a pointer to a destructor for the pClientData. ^SQLite will + ** invoke the destructor function (if it is not NULL) when SQLite + ** no longer needs the pClientData pointer. ^The destructor will also + ** be invoked if the call to sqlite3_create_module_v2() fails. + ** ^The sqlite3_create_module() + ** interface is equivalent to sqlite3_create_module_v2() with a NULL + ** destructor. + */ + //SQLITE_API int sqlite3_create_module( + // sqlite3 db, /* SQLite connection to register module with */ + // string zName, /* Name of the module */ + // const sqlite3_module *p, /* Methods for the module */ + // void *pClientData /* Client data for xCreate/xConnect */ + //); + //SQLITE_API int sqlite3_create_module_v2( + // sqlite3 db, /* SQLite connection to register module with */ + // string zName, /* Name of the module */ + // const sqlite3_module *p, /* Methods for the module */ + // void *pClientData, /* Client data for xCreate/xConnect */ + // void(*xDestroy)(void) /* Module destructor function */ + //); + + /* + ** CAPI3REF: Virtual Table Instance Object + ** KEYWORDS: sqlite3_vtab + ** + ** Every [virtual table module] implementation uses a subclass + ** of this object to describe a particular instance + ** of the [virtual table]. Each subclass will + ** be tailored to the specific needs of the module implementation. + ** The purpose of this superclass is to define certain fields that are + ** common to all module implementations. + ** + ** ^Virtual tables methods can set an error message by assigning a + ** string obtained from [sqlite3_mprintf()] to zErrMsg. The method should + ** take care that any prior string is freed by a call to [sqlite3_free()] + ** prior to assigning a new string to zErrMsg. ^After the error message + ** is delivered up to the client application, the string will be automatically + ** freed by sqlite3_free() and the zErrMsg field will be zeroed. + */ + //struct sqlite3_vtab { + // const sqlite3_module *pModule; /* The module for this virtual table */ + // int nRef; /* NO LONGER USED */ + // string zErrMsg; /* Error message from sqlite3_mprintf() */ + // /* Virtual table implementations will typically add additional fields */ + //}; + public class sqlite3_vtab { + public sqlite3_module pModule; /* The module for this virtual table */ + public int nRef; /* Used internally */ + public string zErrMsg; /* Error message from sqlite3_mprintf() */ + /* Virtual table implementations will typically add additional fields */ + }; + + /* + ** CAPI3REF: Virtual Table Cursor Object + ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor} + ** + ** Every [virtual table module] implementation uses a subclass of the + ** following structure to describe cursors that point into the + ** [virtual table] and are used + ** to loop through the virtual table. Cursors are created using the + ** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed + ** by the [sqlite3_module.xClose | xClose] method. Cursors are used + ** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods + ** of the module. Each module implementation will define + ** the content of a cursor structure to suit its own needs. + ** + ** This superclass exists in order to define fields of the cursor that + ** are common to all implementations. + */ + //struct sqlite3_vtab_cursor { + // sqlite3_vtab *pVtab; /* Virtual table of this cursor */ + // /* Virtual table implementations will typically add additional fields */ + //}; + public class sqlite3_vtab_cursor { + public sqlite3_vtab pVtab; /* Virtual table of this cursor */ + /* Virtual table implementations will typically add additional fields */ + }; + + /* + ** CAPI3REF: Declare The Schema Of A Virtual Table + ** + ** ^The [xCreate] and [xConnect] methods of a + ** [virtual table module] call this interface + ** to declare the format (the names and datatypes of the columns) of + ** the virtual tables they implement. + */ + //SQLITE_API int sqlite3_declare_vtab(sqlite3*, string zSQL); + + /* + ** CAPI3REF: Overload A Function For A Virtual Table + ** + ** ^(Virtual tables can provide alternative implementations of functions + ** using the [xFindFunction] method of the [virtual table module]. + ** But global versions of those functions + ** must exist in order to be overloaded.)^ + ** + ** ^(This API makes sure a global version of a function with a particular + ** name and number of parameters exists. If no such function exists + ** before this API is called, a new function is created.)^ ^The implementation + ** of the new function always causes an exception to be thrown. So + ** the new function is not good for anything by itself. Its only + ** purpose is to be a placeholder function that can be overloaded + ** by a [virtual table]. + */ + //SQLITE_API int sqlite3_overload_function(sqlite3*, string zFuncName, int nArg); + + /* + ** The interface to the virtual-table mechanism defined above (back up + ** to a comment remarkably similar to this one) is currently considered + ** to be experimental. The interface might change in incompatible ways. + ** If this is a problem for you, do not use the interface at this time. + ** + ** When the virtual-table mechanism stabilizes, we will declare the + ** interface fixed, support it indefinitely, and remove this comment. + */ + + /* + ** CAPI3REF: A Handle To An Open BLOB + ** KEYWORDS: {BLOB handle} {BLOB handles} + ** + ** An instance of this object represents an open BLOB on which + ** [sqlite3_blob_open | incremental BLOB I/O] can be performed. + ** ^Objects of this type are created by [sqlite3_blob_open()] + ** and destroyed by [sqlite3_blob_close()]. + ** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces + ** can be used to read or write small subsections of the BLOB. + ** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes. + */ + //typedef struct sqlite3_blob sqlite3_blob; + + /* + ** CAPI3REF: Open A BLOB For Incremental I/O + ** + ** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located + ** in row iRow, column zColumn, table zTable in database zDb; + ** in other words, the same BLOB that would be selected by: + ** + **
+        **     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
+        ** 
)^ + ** + ** ^If the flags parameter is non-zero, then the BLOB is opened for read + ** and write access. ^If it is zero, the BLOB is opened for read access. + ** ^It is not possible to open a column that is part of an index or primary + ** key for writing. ^If [foreign key constraints] are enabled, it is + ** not possible to open a column that is part of a [child key] for writing. + ** + ** ^Note that the database name is not the filename that contains + ** the database but rather the symbolic name of the database that + ** appears after the AS keyword when the database is connected using [ATTACH]. + ** ^For the main database file, the database name is "main". + ** ^For TEMP tables, the database name is "temp". + ** + ** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written + ** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set + ** to be a null pointer.)^ + ** ^This function sets the [database connection] error code and message + ** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related + ** functions. ^Note that the *ppBlob variable is always initialized in a + ** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob + ** regardless of the success or failure of this routine. + ** + ** ^(If the row that a BLOB handle points to is modified by an + ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects + ** then the BLOB handle is marked as "expired". + ** This is true if any column of the row is changed, even a column + ** other than the one the BLOB handle is open on.)^ + ** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for + ** a expired BLOB handle fail with a return code of [SQLITE_ABORT]. + ** ^(Changes written into a BLOB prior to the BLOB expiring are not + ** rolled back by the expiration of the BLOB. Such changes will eventually + ** commit if the transaction continues to completion.)^ + ** + ** ^Use the [sqlite3_blob_bytes()] interface to determine the size of + ** the opened blob. ^The size of a blob may not be changed by this + ** interface. Use the [UPDATE] SQL command to change the size of a + ** blob. + ** + ** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces + ** and the built-in [zeroblob] SQL function can be used, if desired, + ** to create an empty, zero-filled blob in which to read or write using + ** this interface. + ** + ** To avoid a resource leak, every open [BLOB handle] should eventually + ** be released by a call to [sqlite3_blob_close()]. + */ + //SQLITE_API int sqlite3_blob_open( + // sqlite3*, + // string zDb, + // string zTable, + // string zColumn, + // sqlite3_int64 iRow, + // int flags, + // sqlite3_blob **ppBlob + //); + + /* + ** CAPI3REF: Move a BLOB Handle to a New Row + ** + ** ^This function is used to move an existing blob handle so that it points + ** to a different row of the same database table. ^The new row is identified + ** by the rowid value passed as the second argument. Only the row can be + ** changed. ^The database, table and column on which the blob handle is open + ** remain the same. Moving an existing blob handle to a new row can be + ** faster than closing the existing handle and opening a new one. + ** + ** ^(The new row must meet the same criteria as for [sqlite3_blob_open()] - + ** it must exist and there must be either a blob or text value stored in + ** the nominated column.)^ ^If the new row is not present in the table, or if + ** it does not contain a blob or text value, or if another error occurs, an + ** SQLite error code is returned and the blob handle is considered aborted. + ** ^All subsequent calls to [sqlite3_blob_read()], [sqlite3_blob_write()] or + ** [sqlite3_blob_reopen()] on an aborted blob handle immediately return + ** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle + ** always returns zero. + ** + ** ^This function sets the database handle error code and message. + */ + //SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64); + + /* + ** CAPI3REF: Close A BLOB Handle + ** + ** ^Closes an open [BLOB handle]. + ** + ** ^Closing a BLOB shall cause the current transaction to commit + ** if there are no other BLOBs, no pending prepared statements, and the + ** database connection is in [autocommit mode]. + ** ^If any writes were made to the BLOB, they might be held in cache + ** until the close operation if they will fit. + ** + ** ^(Closing the BLOB often forces the changes + ** out to disk and so if any I/O errors occur, they will likely occur + ** at the time when the BLOB is closed. Any errors that occur during + ** closing are reported as a non-zero return value.)^ + ** + ** ^(The BLOB is closed unconditionally. Even if this routine returns + ** an error code, the BLOB is still closed.)^ + ** + ** ^Calling this routine with a null pointer (such as would be returned + ** by a failed call to [sqlite3_blob_open()]) is a harmless no-op. + */ + //SQLITE_API int sqlite3_blob_close(sqlite3_blob ); + + /* + ** CAPI3REF: Return The Size Of An Open BLOB + ** + ** ^Returns the size in bytes of the BLOB accessible via the + ** successfully opened [BLOB handle] in its only argument. ^The + ** incremental blob I/O routines can only read or overwriting existing + ** blob content; they cannot change the size of a blob. + ** + ** This routine only works on a [BLOB handle] which has been created + ** by a prior successful call to [sqlite3_blob_open()] and which has not + ** been closed by [sqlite3_blob_close()]. Passing any other pointer in + ** to this routine results in undefined and probably undesirable behavior. + */ + //SQLITE_API int sqlite3_blob_bytes(sqlite3_blob ); + + /* + ** CAPI3REF: Read Data From A BLOB Incrementally + ** + ** ^(This function is used to read data from an open [BLOB handle] into a + ** caller-supplied buffer. N bytes of data are copied into buffer Z + ** from the open BLOB, starting at offset iOffset.)^ + ** + ** ^If offset iOffset is less than N bytes from the end of the BLOB, + ** [SQLITE_ERROR] is returned and no data is read. ^If N or iOffset is + ** less than zero, [SQLITE_ERROR] is returned and no data is read. + ** ^The size of the blob (and hence the maximum value of N+iOffset) + ** can be determined using the [sqlite3_blob_bytes()] interface. + ** + ** ^An attempt to read from an expired [BLOB handle] fails with an + ** error code of [SQLITE_ABORT]. + ** + ** ^(On success, sqlite3_blob_read() returns SQLITE_OK. + ** Otherwise, an [error code] or an [extended error code] is returned.)^ + ** + ** This routine only works on a [BLOB handle] which has been created + ** by a prior successful call to [sqlite3_blob_open()] and which has not + ** been closed by [sqlite3_blob_close()]. Passing any other pointer in + ** to this routine results in undefined and probably undesirable behavior. + ** + ** See also: [sqlite3_blob_write()]. + */ + //SQLITE_API int sqlite3_blob_read(sqlite3_blob *, object *Z, int N, int iOffset); + + /* + ** CAPI3REF: Write Data Into A BLOB Incrementally + ** + ** ^This function is used to write data into an open [BLOB handle] from a + ** caller-supplied buffer. ^N bytes of data are copied from the buffer Z + ** into the open BLOB, starting at offset iOffset. + ** + ** ^If the [BLOB handle] passed as the first argument was not opened for + ** writing (the flags parameter to [sqlite3_blob_open()] was zero), + ** this function returns [SQLITE_READONLY]. + ** + ** ^This function may only modify the contents of the BLOB; it is + ** not possible to increase the size of a BLOB using this API. + ** ^If offset iOffset is less than N bytes from the end of the BLOB, + ** [SQLITE_ERROR] is returned and no data is written. ^If N is + ** less than zero [SQLITE_ERROR] is returned and no data is written. + ** The size of the BLOB (and hence the maximum value of N+iOffset) + ** can be determined using the [sqlite3_blob_bytes()] interface. + ** + ** ^An attempt to write to an expired [BLOB handle] fails with an + ** error code of [SQLITE_ABORT]. ^Writes to the BLOB that occurred + ** before the [BLOB handle] expired are not rolled back by the + ** expiration of the handle, though of course those changes might + ** have been overwritten by the statement that expired the BLOB handle + ** or by other independent statements. + ** + ** ^(On success, sqlite3_blob_write() returns SQLITE_OK. + ** Otherwise, an [error code] or an [extended error code] is returned.)^ + ** + ** This routine only works on a [BLOB handle] which has been created + ** by a prior successful call to [sqlite3_blob_open()] and which has not + ** been closed by [sqlite3_blob_close()]. Passing any other pointer in + ** to this routine results in undefined and probably undesirable behavior. + ** + ** See also: [sqlite3_blob_read()]. + */ + //SQLITE_API int sqlite3_blob_write(sqlite3_blob *, string z, int n, int iOffset); + + /* + ** CAPI3REF: Virtual File System Objects + ** + ** A virtual filesystem (VFS) is an [sqlite3_vfs] object + ** that SQLite uses to interact + ** with the underlying operating system. Most SQLite builds come with a + ** single default VFS that is appropriate for the host computer. + ** New VFSes can be registered and existing VFSes can be unregistered. + ** The following interfaces are provided. + ** + ** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name. + ** ^Names are case sensitive. + ** ^Names are zero-terminated UTF-8 strings. + ** ^If there is no match, a NULL pointer is returned. + ** ^If zVfsName is NULL then the default VFS is returned. + ** + ** ^New VFSes are registered with sqlite3_vfs_register(). + ** ^Each new VFS becomes the default VFS if the makeDflt flag is set. + ** ^The same VFS can be registered multiple times without injury. + ** ^To make an existing VFS into the default VFS, register it again + ** with the makeDflt flag set. If two different VFSes with the + ** same name are registered, the behavior is undefined. If a + ** VFS is registered with a name that is NULL or an empty string, + ** then the behavior is undefined. + ** + ** ^Unregister a VFS with the sqlite3_vfs_unregister() interface. + ** ^(If the default VFS is unregistered, another VFS is chosen as + ** the default. The choice for the new VFS is arbitrary.)^ + */ + //SQLITE_API sqlite3_vfs *sqlite3_vfs_find(string zVfsName); + //SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt); + //SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs); + + /* + ** CAPI3REF: Mutexes + ** + ** The SQLite core uses these routines for thread + ** synchronization. Though they are intended for internal + ** use by SQLite, code that links against SQLite is + ** permitted to use any of these routines. + ** + ** The SQLite source code contains multiple implementations + ** of these mutex routines. An appropriate implementation + ** is selected automatically at compile-time. ^(The following + ** implementations are available in the SQLite core: + ** + **
    + **
  • SQLITE_MUTEX_OS2 + **
  • SQLITE_MUTEX_PTHREAD + **
  • SQLITE_MUTEX_W32 + **
  • SQLITE_MUTEX_NOOP + **
)^ + ** + ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines + ** that does no real locking and is appropriate for use in + ** a single-threaded application. ^The SQLITE_MUTEX_OS2, + ** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations + ** are appropriate for use on OS/2, Unix, and Windows. + ** + ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor + ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex + ** implementation is included with the library. In this case the + ** application must supply a custom mutex implementation using the + ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function + ** before calling sqlite3_initialize() or any other public sqlite3_ + ** function that calls sqlite3_initialize().)^ + ** + ** ^The sqlite3_mutex_alloc() routine allocates a new + ** mutex and returns a pointer to it. ^If it returns NULL + ** that means that a mutex could not be allocated. ^SQLite + ** will unwind its stack and return an error. ^(The argument + ** to sqlite3_mutex_alloc() is one of these integer constants: + ** + **
    + **
  • SQLITE_MUTEX_FAST + **
  • SQLITE_MUTEX_RECURSIVE + **
  • SQLITE_MUTEX_STATIC_MASTER + **
  • SQLITE_MUTEX_STATIC_MEM + **
  • SQLITE_MUTEX_STATIC_MEM2 + **
  • SQLITE_MUTEX_STATIC_PRNG + **
  • SQLITE_MUTEX_STATIC_LRU + **
  • SQLITE_MUTEX_STATIC_LRU2 + **
)^ + ** + ** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) + ** cause sqlite3_mutex_alloc() to create + ** a new mutex. ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE + ** is used but not necessarily so when SQLITE_MUTEX_FAST is used. + ** The mutex implementation does not need to make a distinction + ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does + ** not want to. ^SQLite will only request a recursive mutex in + ** cases where it really needs one. ^If a faster non-recursive mutex + ** implementation is available on the host platform, the mutex subsystem + ** might return such a mutex in response to SQLITE_MUTEX_FAST. + ** + ** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other + ** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return + ** a pointer to a static preexisting mutex. ^Six static mutexes are + ** used by the current version of SQLite. Future versions of SQLite + ** may add additional static mutexes. Static mutexes are for internal + ** use by SQLite only. Applications that use SQLite mutexes should + ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or + ** SQLITE_MUTEX_RECURSIVE. + ** + ** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST + ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() + ** returns a different mutex on every call. ^But for the static + ** mutex types, the same mutex is returned on every call that has + ** the same type number. + ** + ** ^The sqlite3_mutex_free() routine deallocates a previously + ** allocated dynamic mutex. ^SQLite is careful to deallocate every + ** dynamic mutex that it allocates. The dynamic mutexes must not be in + ** use when they are deallocated. Attempting to deallocate a static + ** mutex results in undefined behavior. ^SQLite never deallocates + ** a static mutex. + ** + ** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt + ** to enter a mutex. ^If another thread is already within the mutex, + ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return + ** SQLITE_BUSY. ^The sqlite3_mutex_try() interface returns [SQLITE_OK] + ** upon successful entry. ^(Mutexes created using + ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread. + ** In such cases the, + ** mutex must be exited an equal number of times before another thread + ** can enter.)^ ^(If the same thread tries to enter any other + ** kind of mutex more than once, the behavior is undefined. + ** SQLite will never exhibit + ** such behavior in its own use of mutexes.)^ + ** + ** ^(Some systems (for example, Windows 95) do not support the operation + ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() + ** will always return SQLITE_BUSY. The SQLite core only ever uses + ** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^ + ** + ** ^The sqlite3_mutex_leave() routine exits a mutex that was + ** previously entered by the same thread. ^(The behavior + ** is undefined if the mutex is not currently entered by the + ** calling thread or is not currently allocated. SQLite will + ** never do either.)^ + ** + ** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or + ** sqlite3_mutex_leave() is a NULL pointer, then all three routines + ** behave as no-ops. + ** + ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()]. + */ + //SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int); + //SQLITE_API void sqlite3_mutex_free(sqlite3_mutex); + //SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex); + //SQLITE_API int sqlite3_mutex_try(sqlite3_mutex); + //SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex); + + /* + ** CAPI3REF: Mutex Methods Object + ** + ** An instance of this structure defines the low-level routines + ** used to allocate and use mutexes. + ** + ** Usually, the default mutex implementations provided by SQLite are + ** sufficient, however the user has the option of substituting a custom + ** implementation for specialized deployments or systems for which SQLite + ** does not provide a suitable implementation. In this case, the user + ** creates and populates an instance of this structure to pass + ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option. + ** Additionally, an instance of this structure can be used as an + ** output variable when querying the system for the current mutex + ** implementation, using the [SQLITE_CONFIG_GETMUTEX] option. + ** + ** ^The xMutexInit method defined by this structure is invoked as + ** part of system initialization by the sqlite3_initialize() function. + ** ^The xMutexInit routine is called by SQLite exactly once for each + ** effective call to [sqlite3_initialize()]. + ** + ** ^The xMutexEnd method defined by this structure is invoked as + ** part of system shutdown by the sqlite3_shutdown() function. The + ** implementation of this method is expected to release all outstanding + ** resources obtained by the mutex methods implementation, especially + ** those obtained by the xMutexInit method. ^The xMutexEnd() + ** interface is invoked exactly once for each call to [sqlite3_shutdown()]. + ** + ** ^(The remaining seven methods defined by this structure (xMutexAlloc, + ** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and + ** xMutexNotheld) implement the following interfaces (respectively): + ** + **
    + **
  • [sqlite3_mutex_alloc()]
  • + **
  • [sqlite3_mutex_free()]
  • + **
  • [sqlite3_mutex_enter()]
  • + **
  • [sqlite3_mutex_try()]
  • + **
  • [sqlite3_mutex_leave()]
  • + **
  • [sqlite3_mutex_held()]
  • + **
  • [sqlite3_mutex_notheld()]
  • + **
)^ + ** + ** The only difference is that the public sqlite3_XXX functions enumerated + ** above silently ignore any invocations that pass a NULL pointer instead + ** of a valid mutex handle. The implementations of the methods defined + ** by this structure are not required to handle this case, the results + ** of passing a NULL pointer instead of a valid mutex handle are undefined + ** (i.e. it is acceptable to provide an implementation that segfaults if + ** it is passed a NULL pointer). + ** + ** The xMutexInit() method must be threadsafe. ^It must be harmless to + ** invoke xMutexInit() multiple times within the same process and without + ** intervening calls to xMutexEnd(). Second and subsequent calls to + ** xMutexInit() must be no-ops. + ** + ** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()] + ** and its associates). ^Similarly, xMutexAlloc() must not use SQLite memory + ** allocation for a static mutex. ^However xMutexAlloc() may use SQLite + ** memory allocation for a fast or recursive mutex. + ** + ** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is + ** called, but only if the prior call to xMutexInit returned SQLITE_OK. + ** If xMutexInit fails in any way, it is expected to clean up after itself + ** prior to returning. + */ + //typedef struct sqlite3_mutex_methods sqlite3_mutex_methods; + //struct sqlite3_mutex_methods { + // int (*xMutexInit)(void); + // int (*xMutexEnd)(void); + // sqlite3_mutex *(*xMutexAlloc)(int); + // void (*xMutexFree)(sqlite3_mutex ); + // void (*xMutexEnter)(sqlite3_mutex ); + // int (*xMutexTry)(sqlite3_mutex ); + // void (*xMutexLeave)(sqlite3_mutex ); + // int (*xMutexHeld)(sqlite3_mutex ); + // int (*xMutexNotheld)(sqlite3_mutex ); + //}; + public class sqlite3_mutex_methods { + public dxMutexInit xMutexInit; + public dxMutexEnd xMutexEnd; + public dxMutexAlloc xMutexAlloc; + public dxMutexFree xMutexFree; + public dxMutexEnter xMutexEnter; + public dxMutexTry xMutexTry; + public dxMutexLeave xMutexLeave; + public dxMutexHeld xMutexHeld; + public dxMutexNotheld xMutexNotheld; + + public sqlite3_mutex_methods() { + } + + public sqlite3_mutex_methods( + dxMutexInit xMutexInit, + dxMutexEnd xMutexEnd, + dxMutexAlloc xMutexAlloc, + dxMutexFree xMutexFree, + dxMutexEnter xMutexEnter, + dxMutexTry xMutexTry, + dxMutexLeave xMutexLeave, + dxMutexHeld xMutexHeld, + dxMutexNotheld xMutexNotheld + ) { + this.xMutexInit = xMutexInit; + this.xMutexEnd = xMutexEnd; + this.xMutexAlloc = xMutexAlloc; + this.xMutexFree = xMutexFree; + this.xMutexEnter = xMutexEnter; + this.xMutexTry = xMutexTry; + this.xMutexLeave = xMutexLeave; + this.xMutexHeld = xMutexHeld; + this.xMutexNotheld = xMutexNotheld; + } + + //Copy sqlite3_mutex_methods from existing + public void Copy(sqlite3_mutex_methods cp) { + Debug.Assert(cp != null); + this.xMutexInit = cp.xMutexInit; + this.xMutexEnd = cp.xMutexEnd; + this.xMutexAlloc = cp.xMutexAlloc; + this.xMutexFree = cp.xMutexFree; + this.xMutexEnter = cp.xMutexEnter; + this.xMutexTry = cp.xMutexTry; + this.xMutexLeave = cp.xMutexLeave; + this.xMutexHeld = cp.xMutexHeld; + this.xMutexNotheld = cp.xMutexNotheld; + } + } + /* + ** CAPI3REF: Mutex Verification Routines + ** + ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines + ** are intended for use inside Debug.Assert() statements. ^The SQLite core + ** never uses these routines except inside an Debug.Assert() and applications + ** are advised to follow the lead of the core. ^The SQLite core only + ** provides implementations for these routines when it is compiled + ** with the SQLITE_DEBUG flag. ^External mutex implementations + ** are only required to provide these routines if SQLITE_DEBUG is + ** defined and if NDEBUG is not defined. + ** + ** ^These routines should return true if the mutex in their argument + ** is held or not held, respectively, by the calling thread. + ** + ** ^The implementation is not required to provided versions of these + ** routines that actually work. If the implementation does not provide working + ** versions of these routines, it should at least provide stubs that always + ** return true so that one does not get spurious assertion failures. + ** + ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then + ** the routine should return 1. This seems counter-intuitive since + ** clearly the mutex cannot be held if it does not exist. But + ** the reason the mutex does not exist is because the build is not + ** using mutexes. And we do not want the Debug.Assert() containing the + ** call to sqlite3_mutex_held() to fail, so a non-zero return is + ** the appropriate thing to do. ^The sqlite3_mutex_notheld() + ** interface should also return 1 when given a NULL pointer. + */ + //#if !NDEBUG + //SQLITE_API int sqlite3_mutex_held(sqlite3_mutex); + //SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex); + //#endif + + /* + ** CAPI3REF: Mutex Types + ** + ** The [sqlite3_mutex_alloc()] interface takes a single argument + ** which is one of these integer constants. + ** + ** The set of static mutexes may change from one SQLite release to the + ** next. Applications that override the built-in mutex logic must be + ** prepared to accommodate additional static mutexes. + */ + //#define SQLITE_MUTEX_FAST 0 + //#define SQLITE_MUTEX_RECURSIVE 1 + //#define SQLITE_MUTEX_STATIC_MASTER 2 + //#define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite3_malloc() */ + //#define SQLITE_MUTEX_STATIC_MEM2 4 /* NOT USED */ + //#define SQLITE_MUTEX_STATIC_OPEN 4 /* sqlite3BtreeOpen() */ + //#define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */ + //#define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */ + //#define SQLITE_MUTEX_STATIC_LRU2 7 /* NOT USED */ + //#define SQLITE_MUTEX_STATIC_PMEM 7 /* sqlite3PageMalloc() */ + const int SQLITE_MUTEX_FAST = 0; + const int SQLITE_MUTEX_RECURSIVE = 1; + const int SQLITE_MUTEX_STATIC_MASTER = 2; + const int SQLITE_MUTEX_STATIC_MEM = 3; + const int SQLITE_MUTEX_STATIC_MEM2 = 4; + const int SQLITE_MUTEX_STATIC_OPEN = 4; + const int SQLITE_MUTEX_STATIC_PRNG = 5; + const int SQLITE_MUTEX_STATIC_LRU = 6; + const int SQLITE_MUTEX_STATIC_LRU2 = 7; + const int SQLITE_MUTEX_STATIC_PMEM = 7; + + /* + ** CAPI3REF: Retrieve the mutex for a database connection + ** + ** ^This interface returns a pointer the [sqlite3_mutex] object that + ** serializes access to the [database connection] given in the argument + ** when the [threading mode] is Serialized. + ** ^If the [threading mode] is Single-thread or Multi-thread then this + ** routine returns a NULL pointer. + */ + //SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3); + + /* + ** CAPI3REF: Low-Level Control Of Database Files + ** + ** ^The [sqlite3_file_control()] interface makes a direct call to the + ** xFileControl method for the [sqlite3_io_methods] object associated + ** with a particular database identified by the second argument. ^The + ** name of the database is "main" for the main database or "temp" for the + ** TEMP database, or the name that appears after the AS keyword for + ** databases that are added using the [ATTACH] SQL command. + ** ^A NULL pointer can be used in place of "main" to refer to the + ** main database file. + ** ^The third and fourth parameters to this routine + ** are passed directly through to the second and third parameters of + ** the xFileControl method. ^The return value of the xFileControl + ** method becomes the return value of this routine. + ** + ** ^The SQLITE_FCNTL_FILE_POINTER value for the op parameter causes + ** a pointer to the underlying [sqlite3_file] object to be written into + ** the space pointed to by the 4th parameter. ^The SQLITE_FCNTL_FILE_POINTER + ** case is a short-circuit path which does not actually invoke the + ** underlying sqlite3_io_methods.xFileControl method. + ** + ** ^If the second parameter (zDbName) does not match the name of any + ** open database file, then SQLITE_ERROR is returned. ^This error + ** code is not remembered and will not be recalled by [sqlite3_errcode()] + ** or [sqlite3_errmsg()]. The underlying xFileControl method might + ** also return SQLITE_ERROR. There is no way to distinguish between + ** an incorrect zDbName and an SQLITE_ERROR return from the underlying + ** xFileControl method. + ** + ** See also: [SQLITE_FCNTL_LOCKSTATE] + */ + //SQLITE_API int sqlite3_file_control(sqlite3*, string zDbName, int op, void); + + /* + ** CAPI3REF: Testing Interface + ** + ** ^The sqlite3_test_control() interface is used to read out internal + ** state of SQLite and to inject faults into SQLite for testing + ** purposes. ^The first parameter is an operation code that determines + ** the number, meaning, and operation of all subsequent parameters. + ** + ** This interface is not for use by applications. It exists solely + ** for verifying the correct operation of the SQLite library. Depending + ** on how the SQLite library is compiled, this interface might not exist. + ** + ** The details of the operation codes, their meanings, the parameters + ** they take, and what they do are all subject to change without notice. + ** Unlike most of the SQLite API, this function is not guaranteed to + ** operate consistently from one release to the next. + */ + //SQLITE_API int sqlite3_test_control(int op, ...); + + /* + ** CAPI3REF: Testing Interface Operation Codes + ** + ** These constants are the valid operation code parameters used + ** as the first argument to [sqlite3_test_control()]. + ** + ** These parameters and their meanings are subject to change + ** without notice. These values are for testing purposes only. + ** Applications should not use any of these parameters or the + ** [sqlite3_test_control()] interface. + */ + //#define SQLITE_TESTCTRL_FIRST 5 + //#define SQLITE_TESTCTRL_PRNG_SAVE 5 + //#define SQLITE_TESTCTRL_PRNG_RESTORE 6 + //#define SQLITE_TESTCTRL_PRNG_RESET 7 + //#define SQLITE_TESTCTRL_BITVEC_TEST 8 + //#define SQLITE_TESTCTRL_FAULT_INSTALL 9 + //#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 + //#define SQLITE_TESTCTRL_PENDING_BYTE 11 + //#define SQLITE_TESTCTRL_ASSERT 12 + //#define SQLITE_TESTCTRL_ALWAYS 13 + //#define SQLITE_TESTCTRL_RESERVE 14 + //#define SQLITE_TESTCTRL_OPTIMIZATIONS 15 + //#define SQLITE_TESTCTRL_ISKEYWORD 16 + //#define SQLITE_TESTCTRL_PGHDRSZ 17 + //#define SQLITE_TESTCTRL_SCRATCHMALLOC 18 + //#define SQLITE_TESTCTRL_LOCALTIME_FAULT 19 + //#define SQLITE_TESTCTRL_LAST 19 + public const int SQLITE_TESTCTRL_FIRST = 5; + public const int SQLITE_TESTCTRL_PRNG_SAVE = 5; + public const int SQLITE_TESTCTRL_PRNG_RESTORE = 6; + public const int SQLITE_TESTCTRL_PRNG_RESET = 7; + public const int SQLITE_TESTCTRL_BITVEC_TEST = 8; + public const int SQLITE_TESTCTRL_FAULT_INSTALL = 9; + public const int SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS = 10; + public const int SQLITE_TESTCTRL_PENDING_BYTE = 11; + public const int SQLITE_TESTCTRL_ASSERT = 12; + public const int SQLITE_TESTCTRL_ALWAYS = 13; + public const int SQLITE_TESTCTRL_RESERVE = 14; + public const int SQLITE_TESTCTRL_OPTIMIZATIONS = 15; + public const int SQLITE_TESTCTRL_ISKEYWORD = 16; + public const int SQLITE_TESTCTRL_PGHDRSZ = 17; + public const int SQLITE_TESTCTRL_SCRATCHMALLOC = 18; + public const int SQLITE_TESTCTRL_LOCALTIME_FAULT = 19; + public const int SQLITE_TESTCTRL_LAST = 19; + + /* + ** CAPI3REF: SQLite Runtime Status + ** + ** ^This interface is used to retrieve runtime status information + ** about the performance of SQLite, and optionally to reset various + ** highwater marks. ^The first argument is an integer code for + ** the specific parameter to measure. ^(Recognized integer codes + ** are of the form [status parameters | SQLITE_STATUS_...].)^ + ** ^The current value of the parameter is returned into *pCurrent. + ** ^The highest recorded value is returned in *pHighwater. ^If the + ** resetFlag is true, then the highest record value is reset after + ** *pHighwater is written. ^(Some parameters do not record the highest + ** value. For those parameters + ** nothing is written into *pHighwater and the resetFlag is ignored.)^ + ** ^(Other parameters record only the highwater mark and not the current + ** value. For these latter parameters nothing is written into *pCurrent.)^ + ** + ** ^The sqlite3_status() routine returns SQLITE_OK on success and a + ** non-zero [error code] on failure. + ** + ** This routine is threadsafe but is not atomic. This routine can be + ** called while other threads are running the same or different SQLite + ** interfaces. However the values returned in *pCurrent and + ** *pHighwater reflect the status of SQLite at different points in time + ** and it is possible that another thread might change the parameter + ** in between the times when *pCurrent and *pHighwater are written. + ** + ** See also: [sqlite3_db_status()] + */ + //SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); + + + /* + ** CAPI3REF: Status Parameters + ** KEYWORDS: {status parameters} + ** + ** These integer constants designate various run-time status parameters + ** that can be returned by [sqlite3_status()]. + ** + **
+ ** [[SQLITE_STATUS_MEMORY_USED]] ^(
SQLITE_STATUS_MEMORY_USED
+ **
This parameter is the current amount of memory checked out + ** using [sqlite3_malloc()], either directly or indirectly. The + ** figure includes calls made to [sqlite3_malloc()] by the application + ** and internal memory usage by the SQLite library. Scratch memory + ** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache + ** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in + ** this parameter. The amount returned is the sum of the allocation + ** sizes as reported by the xSize method in [sqlite3_mem_methods].
)^ + ** + ** [[SQLITE_STATUS_MALLOC_SIZE]] ^(
SQLITE_STATUS_MALLOC_SIZE
+ **
This parameter records the largest memory allocation request + ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their + ** internal equivalents). Only the value returned in the + ** *pHighwater parameter to [sqlite3_status()] is of interest. + ** The value written into the *pCurrent parameter is undefined.
)^ + ** + ** [[SQLITE_STATUS_MALLOC_COUNT]] ^(
SQLITE_STATUS_MALLOC_COUNT
+ **
This parameter records the number of separate memory allocations + ** currently checked out.
)^ + ** + ** [[SQLITE_STATUS_PAGECACHE_USED]] ^(
SQLITE_STATUS_PAGECACHE_USED
+ **
This parameter returns the number of pages used out of the + ** [pagecache memory allocator] that was configured using + ** [SQLITE_CONFIG_PAGECACHE]. The + ** value returned is in pages, not in bytes.
)^ + ** + ** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]] + ** ^(
SQLITE_STATUS_PAGECACHE_OVERFLOW
+ **
This parameter returns the number of bytes of page cache + ** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE] + ** buffer and where forced to overflow to [sqlite3_malloc()]. The + ** returned value includes allocations that overflowed because they + ** where too large (they were larger than the "sz" parameter to + ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because + ** no space was left in the page cache.
)^ + ** + ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(
SQLITE_STATUS_PAGECACHE_SIZE
+ **
This parameter records the largest memory allocation request + ** handed to [pagecache memory allocator]. Only the value returned in the + ** *pHighwater parameter to [sqlite3_status()] is of interest. + ** The value written into the *pCurrent parameter is undefined.
)^ + ** + ** [[SQLITE_STATUS_SCRATCH_USED]] ^(
SQLITE_STATUS_SCRATCH_USED
+ **
This parameter returns the number of allocations used out of the + ** [scratch memory allocator] configured using + ** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not + ** in bytes. Since a single thread may only have one scratch allocation + ** outstanding at time, this parameter also reports the number of threads + ** using scratch memory at the same time.
)^ + ** + ** [[SQLITE_STATUS_SCRATCH_OVERFLOW]] ^(
SQLITE_STATUS_SCRATCH_OVERFLOW
+ **
This parameter returns the number of bytes of scratch memory + ** allocation which could not be satisfied by the [SQLITE_CONFIG_SCRATCH] + ** buffer and where forced to overflow to [sqlite3_malloc()]. The values + ** returned include overflows because the requested allocation was too + ** larger (that is, because the requested allocation was larger than the + ** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer + ** slots were available. + **
)^ + ** + ** [[SQLITE_STATUS_SCRATCH_SIZE]] ^(
SQLITE_STATUS_SCRATCH_SIZE
+ **
This parameter records the largest memory allocation request + ** handed to [scratch memory allocator]. Only the value returned in the + ** *pHighwater parameter to [sqlite3_status()] is of interest. + ** The value written into the *pCurrent parameter is undefined.
)^ + ** + ** [[SQLITE_STATUS_PARSER_STACK]] ^(
SQLITE_STATUS_PARSER_STACK
+ **
This parameter records the deepest parser stack. It is only + ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].
)^ + **
+ ** + ** New status parameters may be added from time to time. + */ + //#define SQLITE_STATUS_MEMORY_USED 0 + //#define SQLITE_STATUS_PAGECACHE_USED 1 + //#define SQLITE_STATUS_PAGECACHE_OVERFLOW 2 + //#define SQLITE_STATUS_SCRATCH_USED 3 + //#define SQLITE_STATUS_SCRATCH_OVERFLOW 4 + //#define SQLITE_STATUS_MALLOC_SIZE 5 + //#define SQLITE_STATUS_PARSER_STACK 6 + //#define SQLITE_STATUS_PAGECACHE_SIZE 7 + //#define SQLITE_STATUS_SCRATCH_SIZE 8 + //#define SQLITE_STATUS_MALLOC_COUNT 9 + public const int SQLITE_STATUS_MEMORY_USED = 0; + public const int SQLITE_STATUS_PAGECACHE_USED = 1; + public const int SQLITE_STATUS_PAGECACHE_OVERFLOW = 2; + public const int SQLITE_STATUS_SCRATCH_USED = 3; + public const int SQLITE_STATUS_SCRATCH_OVERFLOW = 4; + public const int SQLITE_STATUS_MALLOC_SIZE = 5; + public const int SQLITE_STATUS_PARSER_STACK = 6; + public const int SQLITE_STATUS_PAGECACHE_SIZE = 7; + public const int SQLITE_STATUS_SCRATCH_SIZE = 8; + public const int SQLITE_STATUS_MALLOC_COUNT = 9; + + /* + ** CAPI3REF: Database Connection Status + ** + ** ^This interface is used to retrieve runtime status information + ** about a single [database connection]. ^The first argument is the + ** database connection object to be interrogated. ^The second argument + ** is an integer constant, taken from the set of + ** [SQLITE_DBSTATUS options], that + ** determines the parameter to interrogate. The set of + ** [SQLITE_DBSTATUS options] is likely + ** to grow in future releases of SQLite. + ** + ** ^The current value of the requested parameter is written into *pCur + ** and the highest instantaneous value is written into *pHiwtr. ^If + ** the resetFlg is true, then the highest instantaneous value is + ** reset back down to the current value. + ** + ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a + ** non-zero [error code] on failure. + ** + ** See also: [sqlite3_status()] and [sqlite3_stmt_status()]. + */ + //SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); + + /* + ** CAPI3REF: Status Parameters for database connections + ** KEYWORDS: {SQLITE_DBSTATUS options} + ** + ** These constants are the available integer "verbs" that can be passed as + ** the second argument to the [sqlite3_db_status()] interface. + ** + ** New verbs may be added in future releases of SQLite. Existing verbs + ** might be discontinued. Applications should check the return code from + ** [sqlite3_db_status()] to make sure that the call worked. + ** The [sqlite3_db_status()] interface will return a non-zero error code + ** if a discontinued or unsupported verb is invoked. + ** + **
+ ** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(
SQLITE_DBSTATUS_LOOKASIDE_USED
+ **
This parameter returns the number of lookaside memory slots currently + ** checked out.
)^ + ** + ** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(
SQLITE_DBSTATUS_LOOKASIDE_HIT
+ **
This parameter returns the number malloc attempts that were + ** satisfied using lookaside memory. Only the high-water value is meaningful; + ** the current value is always zero.)^ + ** + ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]] + ** ^(
SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE
+ **
This parameter returns the number malloc attempts that might have + ** been satisfied using lookaside memory but failed due to the amount of + ** memory requested being larger than the lookaside slot size. + ** Only the high-water value is meaningful; + ** the current value is always zero.)^ + ** + ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]] + ** ^(
SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL
+ **
This parameter returns the number malloc attempts that might have + ** been satisfied using lookaside memory but failed due to all lookaside + ** memory already being in use. + ** Only the high-water value is meaningful; + ** the current value is always zero.)^ + ** + ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(
SQLITE_DBSTATUS_CACHE_USED
+ **
This parameter returns the approximate number of of bytes of heap + ** memory used by all pager caches associated with the database connection.)^ + ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. + ** + ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(
SQLITE_DBSTATUS_SCHEMA_USED
+ **
This parameter returns the approximate number of of bytes of heap + ** memory used to store the schema for all databases associated + ** with the connection - main, temp, and any [ATTACH]-ed databases.)^ + ** ^The full amount of memory used by the schemas is reported, even if the + ** schema memory is shared with other database connections due to + ** [shared cache mode] being enabled. + ** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0. + ** + ** [[SQLITE_DBSTATUS_STMT_USED]] ^(
SQLITE_DBSTATUS_STMT_USED
+ **
This parameter returns the approximate number of of bytes of heap + ** and lookaside memory used by all prepared statements associated with + ** the database connection.)^ + ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. + **
+ **
+ */ + //#define SQLITE_DBSTATUS_LOOKASIDE_USED 0 + //#define SQLITE_DBSTATUS_CACHE_USED 1 + //#define SQLITE_DBSTATUS_SCHEMA_USED 2 + //#define SQLITE_DBSTATUS_STMT_USED 3 + //#define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 + //#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 + //#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 + //#define SQLITE_DBSTATUS_MAX 6 /* Largest defined DBSTATUS */ + public const int SQLITE_DBSTATUS_LOOKASIDE_USED = 0; + public const int SQLITE_DBSTATUS_CACHE_USED = 1; + public const int SQLITE_DBSTATUS_SCHEMA_USED = 2; + public const int SQLITE_DBSTATUS_STMT_USED = 3; + public const int SQLITE_DBSTATUS_LOOKASIDE_HIT = 4; + public const int SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE = 5; + public const int SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL = 6; + public const int SQLITE_DBSTATUS_MAX = 6; + + + /* + ** CAPI3REF: Prepared Statement Status + ** + ** ^(Each prepared statement maintains various + ** [SQLITE_STMTSTATUS counters] that measure the number + ** of times it has performed specific operations.)^ These counters can + ** be used to monitor the performance characteristics of the prepared + ** statements. For example, if the number of table steps greatly exceeds + ** the number of table searches or result rows, that would tend to indicate + ** that the prepared statement is using a full table scan rather than + ** an index. + ** + ** ^(This interface is used to retrieve and reset counter values from + ** a [prepared statement]. The first argument is the prepared statement + ** object to be interrogated. The second argument + ** is an integer code for a specific [SQLITE_STMTSTATUS counte + ** to be interrogated.)^ + ** ^The current value of the requested counter is returned. + ** ^If the resetFlg is true, then the counter is reset to zero after this + ** interface call returns. + ** + ** See also: [sqlite3_status()] and [sqlite3_db_status()]. + */ + //SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); + + /* + ** CAPI3REF: Status Parameters for prepared statements + ** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters} + ** + ** These preprocessor macros define integer codes that name counter + ** values associated with the [sqlite3_stmt_status()] interface. + ** The meanings of the various counters are as follows: + ** + **
+ ** [[SQLITE_STMTSTATUS_FULLSCAN_STEP]]
SQLITE_STMTSTATUS_FULLSCAN_STEP
+ **
^This is the number of times that SQLite has stepped forward in + ** a table as part of a full table scan. Large numbers for this counter + ** may indicate opportunities for performance improvement through + ** careful use of indices.
+ ** + ** [[SQLITE_STMTSTATUS_SORT]]
SQLITE_STMTSTATUS_SORT
+ **
^This is the number of sort operations that have occurred. + ** A non-zero value in this counter may indicate an opportunity to + ** improvement performance through careful use of indices.
+ ** + ** [[SQLITE_STMTSTATUS_AUTOINDEX]]
SQLITE_STMTSTATUS_AUTOINDEX
+ **
^This is the number of rows inserted into transient indices that + ** were created automatically in order to help joins run faster. + ** A non-zero value in this counter may indicate an opportunity to + ** improvement performance by adding permanent indices that do not + ** need to be reinitialized each time the statement is run.
+ ** + **
+ */ + //#define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 + //#define SQLITE_STMTSTATUS_SORT 2 + //#define SQLITE_STMTSTATUS_AUTOINDEX 3 + public const int SQLITE_STMTSTATUS_FULLSCAN_STEP = 1; + public const int SQLITE_STMTSTATUS_SORT = 2; + public const int SQLITE_STMTSTATUS_AUTOINDEX = 3; + + /* + ** CAPI3REF: Custom Page Cache Object + ** + ** The sqlite3_pcache type is opaque. It is implemented by + ** the pluggable module. The SQLite core has no knowledge of + ** its size or internal structure and never deals with the + ** sqlite3_pcache object except by holding and passing pointers + ** to the object. + ** + ** See [sqlite3_pcache_methods] for additional information. + */ + //typedef struct sqlite3_pcache sqlite3_pcache; + + /* + ** CAPI3REF: Application Defined Page Cache. + ** KEYWORDS: {page cache} + ** + ** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can + ** register an alternative page cache implementation by passing in an + ** instance of the sqlite3_pcache_methods structure.)^ + ** In many applications, most of the heap memory allocated by + ** SQLite is used for the page cache. + ** By implementing a + ** custom page cache using this API, an application can better control + ** the amount of memory consumed by SQLite, the way in which + ** that memory is allocated and released, and the policies used to + ** determine exactly which parts of a database file are cached and for + ** how long. + ** + ** The alternative page cache mechanism is an + ** extreme measure that is only needed by the most demanding applications. + ** The built-in page cache is recommended for most uses. + ** + ** ^(The contents of the sqlite3_pcache_methods structure are copied to an + ** internal buffer by SQLite within the call to [sqlite3_config]. Hence + ** the application may discard the parameter after the call to + ** [sqlite3_config()] returns.)^ + ** + ** [[the xInit() page cache method]] + ** ^(The xInit() method is called once for each effective + ** call to [sqlite3_initialize()])^ + ** (usually only once during the lifetime of the process). ^(The xInit() + ** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^ + ** The intent of the xInit() method is to set up global data structures + ** required by the custom page cache implementation. + ** ^(If the xInit() method is NULL, then the + ** built-in default page cache is used instead of the application defined + ** page cache.)^ + ** + ** [[the xShutdown() page cache method]] + ** ^The xShutdown() method is called by [sqlite3_shutdown()]. + ** It can be used to clean up + ** any outstanding resources before process shutdown, if required. + ** ^The xShutdown() method may be NULL. + ** + ** ^SQLite automatically serializes calls to the xInit method, + ** so the xInit method need not be threadsafe. ^The + ** xShutdown method is only called from [sqlite3_shutdown()] so it does + ** not need to be threadsafe either. All other methods must be threadsafe + ** in multithreaded applications. + ** + ** ^SQLite will never invoke xInit() more than once without an intervening + ** call to xShutdown(). + ** + ** [[the xCreate() page cache methods]] + ** ^SQLite invokes the xCreate() method to construct a new cache instance. + ** SQLite will typically create one cache instance for each open database file, + ** though this is not guaranteed. ^The + ** first parameter, szPage, is the size in bytes of the pages that must + ** be allocated by the cache. ^szPage will not be a power of two. ^szPage + ** will the page size of the database file that is to be cached plus an + ** increment (here called "R") of less than 250. SQLite will use the + ** extra R bytes on each page to store metadata about the underlying + ** database page on disk. The value of R depends + ** on the SQLite version, the target platform, and how SQLite was compiled. + ** ^(R is constant for a particular build of SQLite. Except, there are two + ** distinct values of R when SQLite is compiled with the proprietary + ** ZIPVFS extension.)^ ^The second argument to + ** xCreate(), bPurgeable, is true if the cache being created will + ** be used to cache database pages of a file stored on disk, or + ** false if it is used for an in-memory database. The cache implementation + ** does not have to do anything special based with the value of bPurgeable; + ** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will + ** never invoke xUnpin() except to deliberately delete a page. + ** ^In other words, calls to xUnpin() on a cache with bPurgeable set to + ** false will always have the "discard" flag set to true. + ** ^Hence, a cache created with bPurgeable false will + ** never contain any unpinned pages. + ** + ** [[the xCachesize() page cache method]] + ** ^(The xCachesize() method may be called at any time by SQLite to set the + ** suggested maximum cache-size (number of pages stored by) the cache + ** instance passed as the first argument. This is the value configured using + ** the SQLite "[PRAGMA cache_size]" command.)^ As with the bPurgeable + ** parameter, the implementation is not required to do anything with this + ** value; it is advisory only. + ** + ** [[the xPagecount() page cache methods]] + ** The xPagecount() method must return the number of pages currently + ** stored in the cache, both pinned and unpinned. + ** + ** [[the xFetch() page cache methods]] + ** The xFetch() method locates a page in the cache and returns a pointer to + ** the page, or a NULL pointer. + ** A "page", in this context, means a buffer of szPage bytes aligned at an + ** 8-byte boundary. The page to be fetched is determined by the key. ^The + ** minimum key value is 1. After it has been retrieved using xFetch, the page + ** is considered to be "pinned". + ** + ** If the requested page is already in the page cache, then the page cache + ** implementation must return a pointer to the page buffer with its content + ** intact. If the requested page is not already in the cache, then the + ** cache implementation should use the value of the createFlag + ** parameter to help it determined what action to take: + ** + ** + **
createFlag Behaviour when page is not already in cache + **
0 Do not allocate a new page. Return NULL. + **
1 Allocate a new page if it easy and convenient to do so. + ** Otherwise return NULL. + **
2 Make every effort to allocate a new page. Only return + ** NULL if allocating a new page is effectively impossible. + **
+ ** + ** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite + ** will only use a createFlag of 2 after a prior call with a createFlag of 1 + ** failed.)^ In between the to xFetch() calls, SQLite may + ** attempt to unpin one or more cache pages by spilling the content of + ** pinned pages to disk and synching the operating system disk cache. + ** + ** [[the xUnpin() page cache method]] + ** ^xUnpin() is called by SQLite with a pointer to a currently pinned page + ** as its second argument. If the third parameter, discard, is non-zero, + ** then the page must be evicted from the cache. + ** ^If the discard parameter is + ** zero, then the page may be discarded or retained at the discretion of + ** page cache implementation. ^The page cache implementation + ** may choose to evict unpinned pages at any time. + ** + ** The cache must not perform any reference counting. A single + ** call to xUnpin() unpins the page regardless of the number of prior calls + ** to xFetch(). + ** + ** [[the xRekey() page cache methods]] + ** The xRekey() method is used to change the key value associated with the + ** page passed as the second argument. If the cache + ** previously contains an entry associated with newKey, it must be + ** discarded. ^Any prior cache entry associated with newKey is guaranteed not + ** to be pinned. + ** + ** When SQLite calls the xTruncate() method, the cache must discard all + ** existing cache entries with page numbers (keys) greater than or equal + ** to the value of the iLimit parameter passed to xTruncate(). If any + ** of these pages are pinned, they are implicitly unpinned, meaning that + ** they can be safely discarded. + ** + ** [[the xDestroy() page cache method]] + ** ^The xDestroy() method is used to delete a cache allocated by xCreate(). + ** All resources associated with the specified cache should be freed. ^After + ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] + ** handle invalid, and will not use it with any other sqlite3_pcache_methods + ** functions. + */ + //typedef struct sqlite3_pcache_methods sqlite3_pcache_methods; + //struct sqlite3_pcache_methods { + // void *pArg; + // int (*xInit)(void); + // void (*xShutdown)(void); + // sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable); + // void (*xCachesize)(sqlite3_pcache*, int nCachesize); + // int (*xPagecount)(sqlite3_pcache); + // void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); + // void (*xUnpin)(sqlite3_pcache*, void*, int discard); + // void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey); + // void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); + // void (*xDestroy)(sqlite3_pcache); + //}; + public class sqlite3_pcache_methods { + public object pArg; + public dxPC_Init xInit;//int (*xInit)(void); + public dxPC_Shutdown xShutdown;//public void (*xShutdown)(void); + public dxPC_Create xCreate;//public sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable); + public dxPC_Cachesize xCachesize;//public void (*xCachesize)(sqlite3_pcache*, int nCachesize); + public dxPC_Pagecount xPagecount;//public int (*xPagecount)(sqlite3_pcache); + public dxPC_Fetch xFetch;//public void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); + public dxPC_Unpin xUnpin;//public void (*xUnpin)(sqlite3_pcache*, void*, int discard); + public dxPC_Rekey xRekey;//public void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey); + public dxPC_Truncate xTruncate;//public void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); + public dxPC_Destroy xDestroy;//public void (*xDestroy)(sqlite3_pcache); + + public sqlite3_pcache_methods() { + } + + public sqlite3_pcache_methods(object pArg, dxPC_Init xInit, dxPC_Shutdown xShutdown, dxPC_Create xCreate, dxPC_Cachesize xCachesize, dxPC_Pagecount xPagecount, dxPC_Fetch xFetch, dxPC_Unpin xUnpin, dxPC_Rekey xRekey, dxPC_Truncate xTruncate, dxPC_Destroy xDestroy) { + this.pArg = pArg; + this.xInit = xInit; + this.xShutdown = xShutdown; + this.xCreate = xCreate; + this.xCachesize = xCachesize; + this.xPagecount = xPagecount; + this.xFetch = xFetch; + this.xUnpin = xUnpin; + this.xRekey = xRekey; + this.xTruncate = xTruncate; + this.xDestroy = xDestroy; + } + }; + + + /* + ** CAPI3REF: Online Backup Object + ** + ** The sqlite3_backup object records state information about an ongoing + ** online backup operation. ^The sqlite3_backup object is created by + ** a call to [sqlite3_backup_init()] and is destroyed by a call to + ** [sqlite3_backup_finish()]. + ** + ** See Also: [Using the SQLite Online Backup API] + */ + //typedef struct sqlite3_backup sqlite3_backup; + + /* + ** CAPI3REF: Online Backup API. + ** + ** The backup API copies the content of one database into another. + ** It is useful either for creating backups of databases or + ** for copying in-memory databases to or from persistent files. + ** + ** See Also: [Using the SQLite Online Backup API] + ** + ** ^SQLite holds a write transaction open on the destination database file + ** for the duration of the backup operation. + ** ^The source database is read-locked only while it is being read; + ** it is not locked continuously for the entire backup operation. + ** ^Thus, the backup may be performed on a live source database without + ** preventing other database connections from + ** reading or writing to the source database while the backup is underway. + ** + ** ^(To perform a backup operation: + **
    + **
  1. sqlite3_backup_init() is called once to initialize the + ** backup, + **
  2. sqlite3_backup_step() is called one or more times to transfer + ** the data between the two databases, and finally + **
  3. sqlite3_backup_finish() is called to release all resources + ** associated with the backup operation. + **
)^ + ** There should be exactly one call to sqlite3_backup_finish() for each + ** successful call to sqlite3_backup_init(). + ** + ** [[sqlite3_backup_init()]] sqlite3_backup_init() + ** + ** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the + ** [database connection] associated with the destination database + ** and the database name, respectively. + ** ^The database name is "main" for the main database, "temp" for the + ** temporary database, or the name specified after the AS keyword in + ** an [ATTACH] statement for an attached database. + ** ^The S and M arguments passed to + ** sqlite3_backup_init(D,N,S,M) identify the [database connection] + ** and database name of the source database, respectively. + ** ^The source and destination [database connections] (parameters S and D) + ** must be different or else sqlite3_backup_init(D,N,S,M) will fail with + ** an error. + ** + ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is + ** returned and an error code and error message are stored in the + ** destination [database connection] D. + ** ^The error code and message for the failed call to sqlite3_backup_init() + ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or + ** [sqlite3_errmsg16()] functions. + ** ^A successful call to sqlite3_backup_init() returns a pointer to an + ** [sqlite3_backup] object. + ** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and + ** sqlite3_backup_finish() functions to perform the specified backup + ** operation. + ** + ** [[sqlite3_backup_step()]] sqlite3_backup_step() + ** + ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between + ** the source and destination databases specified by [sqlite3_backup] object B. + ** ^If N is negative, all remaining source pages are copied. + ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there + ** are still more pages to be copied, then the function returns [SQLITE_OK]. + ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages + ** from source to destination, then it returns [SQLITE_DONE]. + ** ^If an error occurs while running sqlite3_backup_step(B,N), + ** then an [error code] is returned. ^As well as [SQLITE_OK] and + ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], + ** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an + ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code. + ** + ** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if + **
    + **
  1. the destination database was opened read-only, or + **
  2. the destination database is using write-ahead-log journaling + ** and the destination and source page sizes differ, or + **
  3. the destination database is an in-memory database and the + ** destination and source page sizes differ. + **
)^ + ** + ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then + ** the [sqlite3_busy_handler | busy-handler function] + ** is invoked (if one is specified). ^If the + ** busy-handler returns non-zero before the lock is available, then + ** [SQLITE_BUSY] is returned to the caller. ^In this case the call to + ** sqlite3_backup_step() can be retried later. ^If the source + ** [database connection] + ** is being used to write to the source database when sqlite3_backup_step() + ** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this + ** case the call to sqlite3_backup_step() can be retried later on. ^(If + ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or + ** [SQLITE_READONLY] is returned, then + ** there is no point in retrying the call to sqlite3_backup_step(). These + ** errors are considered fatal.)^ The application must accept + ** that the backup operation has failed and pass the backup operation handle + ** to the sqlite3_backup_finish() to release associated resources. + ** + ** ^The first call to sqlite3_backup_step() obtains an exclusive lock + ** on the destination file. ^The exclusive lock is not released until either + ** sqlite3_backup_finish() is called or the backup operation is complete + ** and sqlite3_backup_step() returns [SQLITE_DONE]. ^Every call to + ** sqlite3_backup_step() obtains a [shared lock] on the source database that + ** lasts for the duration of the sqlite3_backup_step() call. + ** ^Because the source database is not locked between calls to + ** sqlite3_backup_step(), the source database may be modified mid-way + ** through the backup process. ^If the source database is modified by an + ** external process or via a database connection other than the one being + ** used by the backup operation, then the backup will be automatically + ** restarted by the next call to sqlite3_backup_step(). ^If the source + ** database is modified by the using the same database connection as is used + ** by the backup operation, then the backup database is automatically + ** updated at the same time. + ** + ** [[sqlite3_backup_finish()]] sqlite3_backup_finish() + ** + ** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the + ** application wishes to abandon the backup operation, the application + ** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish(). + ** ^The sqlite3_backup_finish() interfaces releases all + ** resources associated with the [sqlite3_backup] object. + ** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any + ** active write-transaction on the destination database is rolled back. + ** The [sqlite3_backup] object is invalid + ** and may not be used following a call to sqlite3_backup_finish(). + ** + ** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no + ** sqlite3_backup_step() errors occurred, regardless or whether or not + ** sqlite3_backup_step() completed. + ** ^If an out-of-memory condition or IO error occurred during any prior + ** sqlite3_backup_step() call on the same [sqlite3_backup] object, then + ** sqlite3_backup_finish() returns the corresponding [error code]. + ** + ** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step() + ** is not a permanent error and does not affect the return value of + ** sqlite3_backup_finish(). + ** + ** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]] + ** sqlite3_backup_remaining() and sqlite3_backup_pagecount() + ** + ** ^Each call to sqlite3_backup_step() sets two values inside + ** the [sqlite3_backup] object: the number of pages still to be backed + ** up and the total number of pages in the source database file. + ** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces + ** retrieve these two values, respectively. + ** + ** ^The values returned by these functions are only updated by + ** sqlite3_backup_step(). ^If the source database is modified during a backup + ** operation, then the values are not updated to account for any extra + ** pages that need to be updated or the size of the source database file + ** changing. + ** + ** Concurrent Usage of Database Handles + ** + ** ^The source [database connection] may be used by the application for other + ** purposes while a backup operation is underway or being initialized. + ** ^If SQLite is compiled and configured to support threadsafe database + ** connections, then the source database connection may be used concurrently + ** from within other threads. + ** + ** However, the application must guarantee that the destination + ** [database connection] is not passed to any other API (by any thread) after + ** sqlite3_backup_init() is called and before the corresponding call to + ** sqlite3_backup_finish(). SQLite does not currently check to see + ** if the application incorrectly accesses the destination [database connection] + ** and so no error code is reported, but the operations may malfunction + ** nevertheless. Use of the destination database connection while a + ** backup is in progress might also also cause a mutex deadlock. + ** + ** If running in [shared cache mode], the application must + ** guarantee that the shared cache used by the destination database + ** is not accessed while the backup is running. In practice this means + ** that the application must guarantee that the disk file being + ** backed up to is not accessed by any connection within the process, + ** not just the specific connection that was passed to sqlite3_backup_init(). + ** + ** The [sqlite3_backup] object itself is partially threadsafe. Multiple + ** threads may safely make multiple concurrent calls to sqlite3_backup_step(). + ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount() + ** APIs are not strictly speaking threadsafe. If they are invoked at the + ** same time as another thread is invoking sqlite3_backup_step() it is + ** possible that they return invalid values. + */ + //SQLITE_API sqlite3_backup *sqlite3_backup_init( + // sqlite3 *pDest, /* Destination database handle */ + // string zDestName, /* Destination database name */ + // sqlite3 *pSource, /* Source database handle */ + // string zSourceName /* Source database name */ + //); + //SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage); + //SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p); + //SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p); + //SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p); + + /* + ** CAPI3REF: Unlock Notification + ** + ** ^When running in shared-cache mode, a database operation may fail with + ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or + ** individual tables within the shared-cache cannot be obtained. See + ** [SQLite Shared-Cache Mode] for a description of shared-cache locking. + ** ^This API may be used to register a callback that SQLite will invoke + ** when the connection currently holding the required lock relinquishes it. + ** ^This API is only available if the library was compiled with the + ** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined. + ** + ** See Also: [Using the SQLite Unlock Notification Feature]. + ** + ** ^Shared-cache locks are released when a database connection concludes + ** its current transaction, either by committing it or rolling it back. + ** + ** ^When a connection (known as the blocked connection) fails to obtain a + ** shared-cache lock and SQLITE_LOCKED is returned to the caller, the + ** identity of the database connection (the blocking connection) that + ** has locked the required resource is stored internally. ^After an + ** application receives an SQLITE_LOCKED error, it may call the + ** sqlite3_unlock_notify() method with the blocked connection handle as + ** the first argument to register for a callback that will be invoked + ** when the blocking connections current transaction is concluded. ^The + ** callback is invoked from within the [sqlite3_step] or [sqlite3_close] + ** call that concludes the blocking connections transaction. + ** + ** ^(If sqlite3_unlock_notify() is called in a multi-threaded application, + ** there is a chance that the blocking connection will have already + ** concluded its transaction by the time sqlite3_unlock_notify() is invoked. + ** If this happens, then the specified callback is invoked immediately, + ** from within the call to sqlite3_unlock_notify().)^ + ** + ** ^If the blocked connection is attempting to obtain a write-lock on a + ** shared-cache table, and more than one other connection currently holds + ** a read-lock on the same table, then SQLite arbitrarily selects one of + ** the other connections to use as the blocking connection. + ** + ** ^(There may be at most one unlock-notify callback registered by a + ** blocked connection. If sqlite3_unlock_notify() is called when the + ** blocked connection already has a registered unlock-notify callback, + ** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is + ** called with a NULL pointer as its second argument, then any existing + ** unlock-notify callback is canceled. ^The blocked connections + ** unlock-notify callback may also be canceled by closing the blocked + ** connection using [sqlite3_close()]. + ** + ** The unlock-notify callback is not reentrant. If an application invokes + ** any sqlite3_xxx API functions from within an unlock-notify callback, a + ** crash or deadlock may be the result. + ** + ** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always + ** returns SQLITE_OK. + ** + ** Callback Invocation Details + ** + ** When an unlock-notify callback is registered, the application provides a + ** single void* pointer that is passed to the callback when it is invoked. + ** However, the signature of the callback function allows SQLite to pass + ** it an array of void* context pointers. The first argument passed to + ** an unlock-notify callback is a pointer to an array of void* pointers, + ** and the second is the number of entries in the array. + ** + ** When a blocking connections transaction is concluded, there may be + ** more than one blocked connection that has registered for an unlock-notify + ** callback. ^If two or more such blocked connections have specified the + ** same callback function, then instead of invoking the callback function + ** multiple times, it is invoked once with the set of void* context pointers + ** specified by the blocked connections bundled together into an array. + ** This gives the application an opportunity to prioritize any actions + ** related to the set of unblocked database connections. + ** + ** Deadlock Detection + ** + ** Assuming that after registering for an unlock-notify callback a + ** database waits for the callback to be issued before taking any further + ** action (a reasonable assumption), then using this API may cause the + ** application to deadlock. For example, if connection X is waiting for + ** connection Y's transaction to be concluded, and similarly connection + ** Y is waiting on connection X's transaction, then neither connection + ** will proceed and the system may remain deadlocked indefinitely. + ** + ** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock + ** detection. ^If a given call to sqlite3_unlock_notify() would put the + ** system in a deadlocked state, then SQLITE_LOCKED is returned and no + ** unlock-notify callback is registered. The system is said to be in + ** a deadlocked state if connection A has registered for an unlock-notify + ** callback on the conclusion of connection B's transaction, and connection + ** B has itself registered for an unlock-notify callback when connection + ** A's transaction is concluded. ^Indirect deadlock is also detected, so + ** the system is also considered to be deadlocked if connection B has + ** registered for an unlock-notify callback on the conclusion of connection + ** C's transaction, where connection C is waiting on connection A. ^Any + ** number of levels of indirection are allowed. + ** + ** The "DROP TABLE" Exception + ** + ** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost + ** always appropriate to call sqlite3_unlock_notify(). There is however, + ** one exception. When executing a "DROP TABLE" or "DROP INDEX" statement, + ** SQLite checks if there are any currently executing SELECT statements + ** that belong to the same connection. If there are, SQLITE_LOCKED is + ** returned. In this case there is no "blocking connection", so invoking + ** sqlite3_unlock_notify() results in the unlock-notify callback being + ** invoked immediately. If the application then re-attempts the "DROP TABLE" + ** or "DROP INDEX" query, an infinite loop might be the result. + ** + ** One way around this problem is to check the extended error code returned + ** by an sqlite3_step() call. ^(If there is a blocking connection, then the + ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in + ** the special "DROP TABLE/INDEX" case, the extended error code is just + ** SQLITE_LOCKED.)^ + */ + //SQLITE_API int sqlite3_unlock_notify( + // sqlite3 *pBlocked, /* Waiting connection */ + // void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */ + // void *pNotifyArg /* Argument to pass to xNotify */ + //); + + + /* + ** CAPI3REF: String Comparison + ** + ** ^The [sqlite3_strnicmp()] API allows applications and extensions to + ** compare the contents of two buffers containing UTF-8 strings in a + ** case-independent fashion, using the same definition of case independence + ** that SQLite uses internally when comparing identifiers. + */ + //SQLITE_API int sqlite3_strnicmp(string , string , int); + + /* + ** CAPI3REF: Error Logging Interface + ** + ** ^The [sqlite3_log()] interface writes a message into the error log + ** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()]. + ** ^If logging is enabled, the zFormat string and subsequent arguments are + ** used with [sqlite3_snprintf()] to generate the final output string. + ** + ** The sqlite3_log() interface is intended for use by extensions such as + ** virtual tables, collating functions, and SQL functions. While there is + ** nothing to prevent an application from calling sqlite3_log(), doing so + ** is considered bad form. + ** + ** The zFormat string must not be NULL. + ** + ** To avoid deadlocks and other threading problems, the sqlite3_log() routine + ** will not use dynamically allocated memory. The log message is stored in + ** a fixed-length buffer on the stack. If the log message is longer than + ** a few hundred characters, it will be truncated to the length of the + ** buffer. + */ + //SQLITE_API void sqlite3_log(int iErrCode, string zFormat, ...); + + /* + ** CAPI3REF: Write-Ahead Log Commit Hook + ** + ** ^The [sqlite3_wal_hook()] function is used to register a callback that + ** will be invoked each time a database connection commits data to a + ** [write-ahead log] (i.e. whenever a transaction is committed in + ** [journal_mode | journal_mode=WAL mode]). + ** + ** ^The callback is invoked by SQLite after the commit has taken place and + ** the associated write-lock on the database released, so the implementation + ** may read, write or [checkpoint] the database as required. + ** + ** ^The first parameter passed to the callback function when it is invoked + ** is a copy of the third parameter passed to sqlite3_wal_hook() when + ** registering the callback. ^The second is a copy of the database handle. + ** ^The third parameter is the name of the database that was written to - + ** either "main" or the name of an [ATTACH]-ed database. ^The fourth parameter + ** is the number of pages currently in the write-ahead log file, + ** including those that were just committed. + ** + ** The callback function should normally return [SQLITE_OK]. ^If an error + ** code is returned, that error will propagate back up through the + ** SQLite code base to cause the statement that provoked the callback + ** to report an error, though the commit will have still occurred. If the + ** callback returns [SQLITE_ROW] or [SQLITE_DONE], or if it returns a value + ** that does not correspond to any valid SQLite error code, the results + ** are undefined. + ** + ** A single database handle may have at most a single write-ahead log callback + ** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any + ** previously registered write-ahead log callback. ^Note that the + ** [sqlite3_wal_autocheckpoint()] interface and the + ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will + ** those overwrite any prior [sqlite3_wal_hook()] settings. + */ + //SQLITE_API void *sqlite3_wal_hook( + // sqlite3*, + // int()(void *,sqlite3*,const char*,int), + // void* + //); + + /* + ** CAPI3REF: Configure an auto-checkpoint + ** + ** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around + ** [sqlite3_wal_hook()] that causes any database on [database connection] D + ** to automatically [checkpoint] + ** after committing a transaction if there are N or + ** more frames in the [write-ahead log] file. ^Passing zero or + ** a negative value as the nFrame parameter disables automatic + ** checkpoints entirely. + ** + ** ^The callback registered by this function replaces any existing callback + ** registered using [sqlite3_wal_hook()]. ^Likewise, registering a callback + ** using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism + ** configured by this function. + ** + ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface + ** from SQL. + ** + ** ^Every new [database connection] defaults to having the auto-checkpoint + ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] + ** pages. The use of this interface + ** for a particular application. + */ + //SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 db, int N); + + /* + ** CAPI3REF: Checkpoint a database + ** + ** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X + ** on [database connection] D to be [checkpointed]. ^If X is NULL or an + ** empty string, then a checkpoint is run on all databases of + ** connection D. ^If the database connection D is not in + ** [WAL | write-ahead log mode] then this interface is a harmless no-op. + ** + ** ^The [wal_checkpoint pragma] can be used to invoke this interface + ** from SQL. ^The [sqlite3_wal_autocheckpoint()] interface and the + ** [wal_autocheckpoint pragma] can be used to cause this interface to be + ** run whenever the WAL reaches a certain size threshold. + ** + ** See also: [sqlite3_wal_checkpoint_v2()] + */ + //SQLITE_API int sqlite3_wal_checkpoint(sqlite3 db, string zDb); + + /* + ** CAPI3REF: Checkpoint a database + ** + ** Run a checkpoint operation on WAL database zDb attached to database + ** handle db. The specific operation is determined by the value of the + ** eMode parameter: + ** + **
+ **
SQLITE_CHECKPOINT_PASSIVE
+ ** Checkpoint as many frames as possible without waiting for any database + ** readers or writers to finish. Sync the db file if all frames in the log + ** are checkpointed. This mode is the same as calling + ** sqlite3_wal_checkpoint(). The busy-handler callback is never invoked. + ** + **
SQLITE_CHECKPOINT_FULL
+ ** This mode blocks (calls the busy-handler callback) until there is no + ** database writer and all readers are reading from the most recent database + ** snapshot. It then checkpoints all frames in the log file and syncs the + ** database file. This call blocks database writers while it is running, + ** but not database readers. + ** + **
SQLITE_CHECKPOINT_RESTART
+ ** This mode works the same way as SQLITE_CHECKPOINT_FULL, except after + ** checkpointing the log file it blocks (calls the busy-handler callback) + ** until all readers are reading from the database file only. This ensures + ** that the next client to write to the database file restarts the log file + ** from the beginning. This call blocks database writers while it is running, + ** but not database readers. + **
+ ** + ** If pnLog is not NULL, then *pnLog is set to the total number of frames in + ** the log file before returning. If pnCkpt is not NULL, then *pnCkpt is set to + ** the total number of checkpointed frames (including any that were already + ** checkpointed when this function is called). *pnLog and *pnCkpt may be + ** populated even if sqlite3_wal_checkpoint_v2() returns other than SQLITE_OK. + ** If no values are available because of an error, they are both set to -1 + ** before returning to communicate this to the caller. + ** + ** All calls obtain an exclusive "checkpoint" lock on the database file. If + ** any other process is running a checkpoint operation at the same time, the + ** lock cannot be obtained and SQLITE_BUSY is returned. Even if there is a + ** busy-handler configured, it will not be invoked in this case. + ** + ** The SQLITE_CHECKPOINT_FULL and RESTART modes also obtain the exclusive + ** "writer" lock on the database file. If the writer lock cannot be obtained + ** immediately, and a busy-handler is configured, it is invoked and the writer + ** lock retried until either the busy-handler returns 0 or the lock is + ** successfully obtained. The busy-handler is also invoked while waiting for + ** database readers as described above. If the busy-handler returns 0 before + ** the writer lock is obtained or while waiting for database readers, the + ** checkpoint operation proceeds from that point in the same way as + ** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible + ** without blocking any further. SQLITE_BUSY is returned in this case. + ** + ** If parameter zDb is NULL or points to a zero length string, then the + ** specified operation is attempted on all WAL databases. In this case the + ** values written to output parameters *pnLog and *pnCkpt are undefined. If + ** an SQLITE_BUSY error is encountered when processing one or more of the + ** attached WAL databases, the operation is still attempted on any remaining + ** attached databases and SQLITE_BUSY is returned to the caller. If any other + ** error occurs while processing an attached database, processing is abandoned + ** and the error code returned to the caller immediately. If no error + ** (SQLITE_BUSY or otherwise) is encountered while processing the attached + ** databases, SQLITE_OK is returned. + ** + ** If database zDb is the name of an attached database that is not in WAL + ** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. If + ** zDb is not NULL (or a zero length string) and is not the name of any + ** attached database, SQLITE_ERROR is returned to the caller. + */ + //SQLITE_API int sqlite3_wal_checkpoint_v2( + // sqlite3 db, /* Database handle */ + // string zDb, /* Name of attached database (or NULL) */ + // int eMode, /* SQLITE_CHECKPOINT_* value */ + // int *pnLog, /* OUT: Size of WAL log in frames */ + // int *pnCkpt /* OUT: Total number of frames checkpointed */ + //); + + /* + ** CAPI3REF: Checkpoint operation parameters + ** + ** These constants can be used as the 3rd parameter to + ** [sqlite3_wal_checkpoint_v2()]. See the [sqlite3_wal_checkpoint_v2()] + ** documentation for additional information about the meaning and use of + ** each of these values. + */ + //#define SQLITE_CHECKPOINT_PASSIVE 0 + //#define SQLITE_CHECKPOINT_FULL 1 + //#define SQLITE_CHECKPOINT_RESTART 2 + static public int SQLITE_CHECKPOINT_PASSIVE = 0; + static public int SQLITE_CHECKPOINT_FULL = 1; + static public int SQLITE_CHECKPOINT_RESTART = 2; + + + /* + ** CAPI3REF: Virtual Table Interface Configuration + ** + ** This function may be called by either the [xConnect] or [xCreate] method + ** of a [virtual table] implementation to configure + ** various facets of the virtual table interface. + ** + ** If this interface is invoked outside the context of an xConnect or + ** xCreate virtual table method then the behavior is undefined. + ** + ** At present, there is only one option that may be configured using + ** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options + ** may be added in the future. + */ + //SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...); + + /* + ** CAPI3REF: Virtual Table Configuration Options + ** + ** These macros define the various options to the + ** [sqlite3_vtab_config()] interface that [virtual table] implementations + ** can use to customize and optimize their behavior. + ** + **
+ **
SQLITE_VTAB_CONSTRAINT_SUPPORT + **
Calls of the form + ** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported, + ** where X is an integer. If X is zero, then the [virtual table] whose + ** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not + ** support constraints. In this configuration (which is the default) if + ** a call to the [xUpdate] method returns [SQLITE_CONSTRAINT], then the entire + ** statement is rolled back as if [ON CONFLICT | OR ABORT] had been + ** specified as part of the users SQL statement, regardless of the actual + ** ON CONFLICT mode specified. + ** + ** If X is non-zero, then the virtual table implementation guarantees + ** that if [xUpdate] returns [SQLITE_CONSTRAINT], it will do so before + ** any modifications to internal or persistent data structures have been made. + ** If the [ON CONFLICT] mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite + ** is able to roll back a statement or database transaction, and abandon + ** or continue processing the current SQL statement as appropriate. + ** If the ON CONFLICT mode is REPLACE and the [xUpdate] method returns + ** [SQLITE_CONSTRAINT], SQLite handles this as if the ON CONFLICT mode + ** had been ABORT. + ** + ** Virtual table implementations that are required to handle OR REPLACE + ** must do so within the [xUpdate] method. If a call to the + ** [sqlite3_vtab_on_conflict()] function indicates that the current ON + ** CONFLICT policy is REPLACE, the virtual table implementation should + ** silently replace the appropriate rows within the xUpdate callback and + ** return SQLITE_OK. Or, if this is not possible, it may return + ** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT + ** constraint handling. + **
+ */ + //#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1 + public const int SQLITE_VTAB_CONSTRAINT_SUPPORT = 1; + + /* + ** CAPI3REF: Determine The Virtual Table Conflict Policy + ** + ** This function may only be called from within a call to the [xUpdate] method + ** of a [virtual table] implementation for an INSERT or UPDATE operation. ^The + ** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL], + ** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode + ** of the SQL statement that triggered the call to the [xUpdate] method of the + ** [virtual table]. + */ + //SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 ); + + /* + ** CAPI3REF: Conflict resolution modes + ** + ** These constants are returned by [sqlite3_vtab_on_conflict()] to + ** inform a [virtual table] implementation what the [ON CONFLICT] mode + ** is for the SQL statement being evaluated. + ** + ** Note that the [SQLITE_IGNORE] constant is also used as a potential + ** return value from the [sqlite3_set_authorizer()] callback and that + ** [SQLITE_ABORT] is also a [result code]. + */ + //#define SQLITE_ROLLBACK 1 + public const int SQLITE_ROLLBACK = 1; + /* #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback */ + //#define SQLITE_FAIL 3 + public const int SQLITE_FAIL = 3; + /* #define SQLITE_ABORT 4 // Also an error code */ + //#define SQLITE_REPLACE 5 + public const int SQLITE_REPLACE = 5; + + + /* + ** Undo the hack that converts floating point types to integer for + ** builds on processors without floating point support. + */ + //#if SQLITE_OMIT_FLOATING_POINT + //# undef double + //#endif + + //#if __cplusplus + //} /* End of the 'extern "C"' block */ + //#endif + //#endif + + /* + ** 2010 August 30 + ** + ** 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. + ** + ************************************************************************* + */ + + //#if !_SQLITE3RTREE_H_ + //#define _SQLITE3RTREE_H_ + + + //#if __cplusplus + //extern "C" { + //#endif + + //typedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry; + + /* + ** Register a geometry callback named zGeom that can be used as part of an + ** R-Tree geometry query as follows: + ** + ** SELECT ... FROM WHERE MATCH $zGeom(... params ...) + */ + //SQLITE_API int sqlite3_rtree_geometry_callback( + // sqlite3 db, + // string zGeom, + // int (*xGeom)(sqlite3_rtree_geometry *, int nCoord, double *aCoord, int *pRes), + // void *pContext + //); + + + /* + ** A pointer to a structure of the following type is passed as the first + ** argument to callbacks registered using rtree_geometry_callback(). + */ + //struct sqlite3_rtree_geometry { + // void *pContext; /* Copy of pContext passed to s_r_g_c() */ + // int nParam; /* Size of array aParam[] */ + // double *aParam; /* Parameters passed to SQL geom function */ + // void *pUser; /* Callback implementation user data */ + // void (*xDelUser)(void ); /* Called by SQLite to clean up pUser */ + //}; + + + //#if __cplusplus + //} /* end of the 'extern "C"' block */ + //#endif + + //#endif /* ifndef _SQLITE3RTREE_H_ */ + } - /* - ** CAPI3REF: Mutex Verification Routines - ** - ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines - ** are intended for use inside Debug.Assert() statements. ^The SQLite core - ** never uses these routines except inside an Debug.Assert() and applications - ** are advised to follow the lead of the core. ^The SQLite core only - ** provides implementations for these routines when it is compiled - ** with the SQLITE_DEBUG flag. ^External mutex implementations - ** are only required to provide these routines if SQLITE_DEBUG is - ** defined and if NDEBUG is not defined. - ** - ** ^These routines should return true if the mutex in their argument - ** is held or not held, respectively, by the calling thread. - ** - ** ^The implementation is not required to provided versions of these - ** routines that actually work. If the implementation does not provide working - ** versions of these routines, it should at least provide stubs that always - ** return true so that one does not get spurious assertion failures. - ** - ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then - ** the routine should return 1. This seems counter-intuitive since - ** clearly the mutex cannot be held if it does not exist. But - ** the reason the mutex does not exist is because the build is not - ** using mutexes. And we do not want the Debug.Assert() containing the - ** call to sqlite3_mutex_held() to fail, so a non-zero return is - ** the appropriate thing to do. ^The sqlite3_mutex_notheld() - ** interface should also return 1 when given a NULL pointer. - */ - //#if !NDEBUG - //SQLITE_API int sqlite3_mutex_held(sqlite3_mutex); - //SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex); - //#endif - - /* - ** CAPI3REF: Mutex Types - ** - ** The [sqlite3_mutex_alloc()] interface takes a single argument - ** which is one of these integer constants. - ** - ** The set of static mutexes may change from one SQLite release to the - ** next. Applications that override the built-in mutex logic must be - ** prepared to accommodate additional static mutexes. - */ - //#define SQLITE_MUTEX_FAST 0 - //#define SQLITE_MUTEX_RECURSIVE 1 - //#define SQLITE_MUTEX_STATIC_MASTER 2 - //#define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite3_malloc() */ - //#define SQLITE_MUTEX_STATIC_MEM2 4 /* NOT USED */ - //#define SQLITE_MUTEX_STATIC_OPEN 4 /* sqlite3BtreeOpen() */ - //#define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */ - //#define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */ - //#define SQLITE_MUTEX_STATIC_LRU2 7 /* NOT USED */ - //#define SQLITE_MUTEX_STATIC_PMEM 7 /* sqlite3PageMalloc() */ - const int SQLITE_MUTEX_FAST = 0; - const int SQLITE_MUTEX_RECURSIVE = 1; - const int SQLITE_MUTEX_STATIC_MASTER = 2; - const int SQLITE_MUTEX_STATIC_MEM = 3; - const int SQLITE_MUTEX_STATIC_MEM2 = 4; - const int SQLITE_MUTEX_STATIC_OPEN = 4; - const int SQLITE_MUTEX_STATIC_PRNG = 5; - const int SQLITE_MUTEX_STATIC_LRU = 6; - const int SQLITE_MUTEX_STATIC_LRU2 = 7; - const int SQLITE_MUTEX_STATIC_PMEM = 7; - - /* - ** CAPI3REF: Retrieve the mutex for a database connection - ** - ** ^This interface returns a pointer the [sqlite3_mutex] object that - ** serializes access to the [database connection] given in the argument - ** when the [threading mode] is Serialized. - ** ^If the [threading mode] is Single-thread or Multi-thread then this - ** routine returns a NULL pointer. - */ - //SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3); - - /* - ** CAPI3REF: Low-Level Control Of Database Files - ** - ** ^The [sqlite3_file_control()] interface makes a direct call to the - ** xFileControl method for the [sqlite3_io_methods] object associated - ** with a particular database identified by the second argument. ^The - ** name of the database is "main" for the main database or "temp" for the - ** TEMP database, or the name that appears after the AS keyword for - ** databases that are added using the [ATTACH] SQL command. - ** ^A NULL pointer can be used in place of "main" to refer to the - ** main database file. - ** ^The third and fourth parameters to this routine - ** are passed directly through to the second and third parameters of - ** the xFileControl method. ^The return value of the xFileControl - ** method becomes the return value of this routine. - ** - ** ^The SQLITE_FCNTL_FILE_POINTER value for the op parameter causes - ** a pointer to the underlying [sqlite3_file] object to be written into - ** the space pointed to by the 4th parameter. ^The SQLITE_FCNTL_FILE_POINTER - ** case is a short-circuit path which does not actually invoke the - ** underlying sqlite3_io_methods.xFileControl method. - ** - ** ^If the second parameter (zDbName) does not match the name of any - ** open database file, then SQLITE_ERROR is returned. ^This error - ** code is not remembered and will not be recalled by [sqlite3_errcode()] - ** or [sqlite3_errmsg()]. The underlying xFileControl method might - ** also return SQLITE_ERROR. There is no way to distinguish between - ** an incorrect zDbName and an SQLITE_ERROR return from the underlying - ** xFileControl method. - ** - ** See also: [SQLITE_FCNTL_LOCKSTATE] - */ - //SQLITE_API int sqlite3_file_control(sqlite3*, string zDbName, int op, void); - - /* - ** CAPI3REF: Testing Interface - ** - ** ^The sqlite3_test_control() interface is used to read out internal - ** state of SQLite and to inject faults into SQLite for testing - ** purposes. ^The first parameter is an operation code that determines - ** the number, meaning, and operation of all subsequent parameters. - ** - ** This interface is not for use by applications. It exists solely - ** for verifying the correct operation of the SQLite library. Depending - ** on how the SQLite library is compiled, this interface might not exist. - ** - ** The details of the operation codes, their meanings, the parameters - ** they take, and what they do are all subject to change without notice. - ** Unlike most of the SQLite API, this function is not guaranteed to - ** operate consistently from one release to the next. - */ - //SQLITE_API int sqlite3_test_control(int op, ...); - - /* - ** CAPI3REF: Testing Interface Operation Codes - ** - ** These constants are the valid operation code parameters used - ** as the first argument to [sqlite3_test_control()]. - ** - ** These parameters and their meanings are subject to change - ** without notice. These values are for testing purposes only. - ** Applications should not use any of these parameters or the - ** [sqlite3_test_control()] interface. - */ - //#define SQLITE_TESTCTRL_FIRST 5 - //#define SQLITE_TESTCTRL_PRNG_SAVE 5 - //#define SQLITE_TESTCTRL_PRNG_RESTORE 6 - //#define SQLITE_TESTCTRL_PRNG_RESET 7 - //#define SQLITE_TESTCTRL_BITVEC_TEST 8 - //#define SQLITE_TESTCTRL_FAULT_INSTALL 9 - //#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 - //#define SQLITE_TESTCTRL_PENDING_BYTE 11 - //#define SQLITE_TESTCTRL_ASSERT 12 - //#define SQLITE_TESTCTRL_ALWAYS 13 - //#define SQLITE_TESTCTRL_RESERVE 14 - //#define SQLITE_TESTCTRL_OPTIMIZATIONS 15 - //#define SQLITE_TESTCTRL_ISKEYWORD 16 - //#define SQLITE_TESTCTRL_PGHDRSZ 17 - //#define SQLITE_TESTCTRL_SCRATCHMALLOC 18 - //#define SQLITE_TESTCTRL_LOCALTIME_FAULT 19 - //#define SQLITE_TESTCTRL_LAST 19 - public const int SQLITE_TESTCTRL_FIRST = 5; - public const int SQLITE_TESTCTRL_PRNG_SAVE = 5; - public const int SQLITE_TESTCTRL_PRNG_RESTORE = 6; - public const int SQLITE_TESTCTRL_PRNG_RESET = 7; - public const int SQLITE_TESTCTRL_BITVEC_TEST = 8; - public const int SQLITE_TESTCTRL_FAULT_INSTALL = 9; - public const int SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS = 10; - public const int SQLITE_TESTCTRL_PENDING_BYTE = 11; - public const int SQLITE_TESTCTRL_ASSERT = 12; - public const int SQLITE_TESTCTRL_ALWAYS = 13; - public const int SQLITE_TESTCTRL_RESERVE = 14; - public const int SQLITE_TESTCTRL_OPTIMIZATIONS = 15; - public const int SQLITE_TESTCTRL_ISKEYWORD = 16; - public const int SQLITE_TESTCTRL_PGHDRSZ = 17; - public const int SQLITE_TESTCTRL_SCRATCHMALLOC = 18; - public const int SQLITE_TESTCTRL_LOCALTIME_FAULT = 19; - public const int SQLITE_TESTCTRL_LAST = 19; - - /* - ** CAPI3REF: SQLite Runtime Status - ** - ** ^This interface is used to retrieve runtime status information - ** about the performance of SQLite, and optionally to reset various - ** highwater marks. ^The first argument is an integer code for - ** the specific parameter to measure. ^(Recognized integer codes - ** are of the form [status parameters | SQLITE_STATUS_...].)^ - ** ^The current value of the parameter is returned into *pCurrent. - ** ^The highest recorded value is returned in *pHighwater. ^If the - ** resetFlag is true, then the highest record value is reset after - ** *pHighwater is written. ^(Some parameters do not record the highest - ** value. For those parameters - ** nothing is written into *pHighwater and the resetFlag is ignored.)^ - ** ^(Other parameters record only the highwater mark and not the current - ** value. For these latter parameters nothing is written into *pCurrent.)^ - ** - ** ^The sqlite3_status() routine returns SQLITE_OK on success and a - ** non-zero [error code] on failure. - ** - ** This routine is threadsafe but is not atomic. This routine can be - ** called while other threads are running the same or different SQLite - ** interfaces. However the values returned in *pCurrent and - ** *pHighwater reflect the status of SQLite at different points in time - ** and it is possible that another thread might change the parameter - ** in between the times when *pCurrent and *pHighwater are written. - ** - ** See also: [sqlite3_db_status()] - */ - //SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); - - - /* - ** CAPI3REF: Status Parameters - ** KEYWORDS: {status parameters} - ** - ** These integer constants designate various run-time status parameters - ** that can be returned by [sqlite3_status()]. - ** - **
- ** [[SQLITE_STATUS_MEMORY_USED]] ^(
SQLITE_STATUS_MEMORY_USED
- **
This parameter is the current amount of memory checked out - ** using [sqlite3_malloc()], either directly or indirectly. The - ** figure includes calls made to [sqlite3_malloc()] by the application - ** and internal memory usage by the SQLite library. Scratch memory - ** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache - ** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in - ** this parameter. The amount returned is the sum of the allocation - ** sizes as reported by the xSize method in [sqlite3_mem_methods].
)^ - ** - ** [[SQLITE_STATUS_MALLOC_SIZE]] ^(
SQLITE_STATUS_MALLOC_SIZE
- **
This parameter records the largest memory allocation request - ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their - ** internal equivalents). Only the value returned in the - ** *pHighwater parameter to [sqlite3_status()] is of interest. - ** The value written into the *pCurrent parameter is undefined.
)^ - ** - ** [[SQLITE_STATUS_MALLOC_COUNT]] ^(
SQLITE_STATUS_MALLOC_COUNT
- **
This parameter records the number of separate memory allocations - ** currently checked out.
)^ - ** - ** [[SQLITE_STATUS_PAGECACHE_USED]] ^(
SQLITE_STATUS_PAGECACHE_USED
- **
This parameter returns the number of pages used out of the - ** [pagecache memory allocator] that was configured using - ** [SQLITE_CONFIG_PAGECACHE]. The - ** value returned is in pages, not in bytes.
)^ - ** - ** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]] - ** ^(
SQLITE_STATUS_PAGECACHE_OVERFLOW
- **
This parameter returns the number of bytes of page cache - ** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE] - ** buffer and where forced to overflow to [sqlite3_malloc()]. The - ** returned value includes allocations that overflowed because they - ** where too large (they were larger than the "sz" parameter to - ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because - ** no space was left in the page cache.
)^ - ** - ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(
SQLITE_STATUS_PAGECACHE_SIZE
- **
This parameter records the largest memory allocation request - ** handed to [pagecache memory allocator]. Only the value returned in the - ** *pHighwater parameter to [sqlite3_status()] is of interest. - ** The value written into the *pCurrent parameter is undefined.
)^ - ** - ** [[SQLITE_STATUS_SCRATCH_USED]] ^(
SQLITE_STATUS_SCRATCH_USED
- **
This parameter returns the number of allocations used out of the - ** [scratch memory allocator] configured using - ** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not - ** in bytes. Since a single thread may only have one scratch allocation - ** outstanding at time, this parameter also reports the number of threads - ** using scratch memory at the same time.
)^ - ** - ** [[SQLITE_STATUS_SCRATCH_OVERFLOW]] ^(
SQLITE_STATUS_SCRATCH_OVERFLOW
- **
This parameter returns the number of bytes of scratch memory - ** allocation which could not be satisfied by the [SQLITE_CONFIG_SCRATCH] - ** buffer and where forced to overflow to [sqlite3_malloc()]. The values - ** returned include overflows because the requested allocation was too - ** larger (that is, because the requested allocation was larger than the - ** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer - ** slots were available. - **
)^ - ** - ** [[SQLITE_STATUS_SCRATCH_SIZE]] ^(
SQLITE_STATUS_SCRATCH_SIZE
- **
This parameter records the largest memory allocation request - ** handed to [scratch memory allocator]. Only the value returned in the - ** *pHighwater parameter to [sqlite3_status()] is of interest. - ** The value written into the *pCurrent parameter is undefined.
)^ - ** - ** [[SQLITE_STATUS_PARSER_STACK]] ^(
SQLITE_STATUS_PARSER_STACK
- **
This parameter records the deepest parser stack. It is only - ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].
)^ - **
- ** - ** New status parameters may be added from time to time. - */ - //#define SQLITE_STATUS_MEMORY_USED 0 - //#define SQLITE_STATUS_PAGECACHE_USED 1 - //#define SQLITE_STATUS_PAGECACHE_OVERFLOW 2 - //#define SQLITE_STATUS_SCRATCH_USED 3 - //#define SQLITE_STATUS_SCRATCH_OVERFLOW 4 - //#define SQLITE_STATUS_MALLOC_SIZE 5 - //#define SQLITE_STATUS_PARSER_STACK 6 - //#define SQLITE_STATUS_PAGECACHE_SIZE 7 - //#define SQLITE_STATUS_SCRATCH_SIZE 8 - //#define SQLITE_STATUS_MALLOC_COUNT 9 - public const int SQLITE_STATUS_MEMORY_USED = 0; - public const int SQLITE_STATUS_PAGECACHE_USED = 1; - public const int SQLITE_STATUS_PAGECACHE_OVERFLOW = 2; - public const int SQLITE_STATUS_SCRATCH_USED = 3; - public const int SQLITE_STATUS_SCRATCH_OVERFLOW = 4; - public const int SQLITE_STATUS_MALLOC_SIZE = 5; - public const int SQLITE_STATUS_PARSER_STACK = 6; - public const int SQLITE_STATUS_PAGECACHE_SIZE = 7; - public const int SQLITE_STATUS_SCRATCH_SIZE = 8; - public const int SQLITE_STATUS_MALLOC_COUNT = 9; - - /* - ** CAPI3REF: Database Connection Status - ** - ** ^This interface is used to retrieve runtime status information - ** about a single [database connection]. ^The first argument is the - ** database connection object to be interrogated. ^The second argument - ** is an integer constant, taken from the set of - ** [SQLITE_DBSTATUS options], that - ** determines the parameter to interrogate. The set of - ** [SQLITE_DBSTATUS options] is likely - ** to grow in future releases of SQLite. - ** - ** ^The current value of the requested parameter is written into *pCur - ** and the highest instantaneous value is written into *pHiwtr. ^If - ** the resetFlg is true, then the highest instantaneous value is - ** reset back down to the current value. - ** - ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a - ** non-zero [error code] on failure. - ** - ** See also: [sqlite3_status()] and [sqlite3_stmt_status()]. - */ - //SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); - - /* - ** CAPI3REF: Status Parameters for database connections - ** KEYWORDS: {SQLITE_DBSTATUS options} - ** - ** These constants are the available integer "verbs" that can be passed as - ** the second argument to the [sqlite3_db_status()] interface. - ** - ** New verbs may be added in future releases of SQLite. Existing verbs - ** might be discontinued. Applications should check the return code from - ** [sqlite3_db_status()] to make sure that the call worked. - ** The [sqlite3_db_status()] interface will return a non-zero error code - ** if a discontinued or unsupported verb is invoked. - ** - **
- ** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(
SQLITE_DBSTATUS_LOOKASIDE_USED
- **
This parameter returns the number of lookaside memory slots currently - ** checked out.
)^ - ** - ** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(
SQLITE_DBSTATUS_LOOKASIDE_HIT
- **
This parameter returns the number malloc attempts that were - ** satisfied using lookaside memory. Only the high-water value is meaningful; - ** the current value is always zero.)^ - ** - ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]] - ** ^(
SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE
- **
This parameter returns the number malloc attempts that might have - ** been satisfied using lookaside memory but failed due to the amount of - ** memory requested being larger than the lookaside slot size. - ** Only the high-water value is meaningful; - ** the current value is always zero.)^ - ** - ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]] - ** ^(
SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL
- **
This parameter returns the number malloc attempts that might have - ** been satisfied using lookaside memory but failed due to all lookaside - ** memory already being in use. - ** Only the high-water value is meaningful; - ** the current value is always zero.)^ - ** - ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(
SQLITE_DBSTATUS_CACHE_USED
- **
This parameter returns the approximate number of of bytes of heap - ** memory used by all pager caches associated with the database connection.)^ - ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. - ** - ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(
SQLITE_DBSTATUS_SCHEMA_USED
- **
This parameter returns the approximate number of of bytes of heap - ** memory used to store the schema for all databases associated - ** with the connection - main, temp, and any [ATTACH]-ed databases.)^ - ** ^The full amount of memory used by the schemas is reported, even if the - ** schema memory is shared with other database connections due to - ** [shared cache mode] being enabled. - ** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0. - ** - ** [[SQLITE_DBSTATUS_STMT_USED]] ^(
SQLITE_DBSTATUS_STMT_USED
- **
This parameter returns the approximate number of of bytes of heap - ** and lookaside memory used by all prepared statements associated with - ** the database connection.)^ - ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. - **
- **
- */ - //#define SQLITE_DBSTATUS_LOOKASIDE_USED 0 - //#define SQLITE_DBSTATUS_CACHE_USED 1 - //#define SQLITE_DBSTATUS_SCHEMA_USED 2 - //#define SQLITE_DBSTATUS_STMT_USED 3 - //#define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 - //#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 - //#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 - //#define SQLITE_DBSTATUS_MAX 6 /* Largest defined DBSTATUS */ - public const int SQLITE_DBSTATUS_LOOKASIDE_USED = 0; - public const int SQLITE_DBSTATUS_CACHE_USED = 1; - public const int SQLITE_DBSTATUS_SCHEMA_USED = 2; - public const int SQLITE_DBSTATUS_STMT_USED = 3; - public const int SQLITE_DBSTATUS_LOOKASIDE_HIT = 4; - public const int SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE = 5; - public const int SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL = 6; - public const int SQLITE_DBSTATUS_MAX = 6; - - - /* - ** CAPI3REF: Prepared Statement Status - ** - ** ^(Each prepared statement maintains various - ** [SQLITE_STMTSTATUS counters] that measure the number - ** of times it has performed specific operations.)^ These counters can - ** be used to monitor the performance characteristics of the prepared - ** statements. For example, if the number of table steps greatly exceeds - ** the number of table searches or result rows, that would tend to indicate - ** that the prepared statement is using a full table scan rather than - ** an index. - ** - ** ^(This interface is used to retrieve and reset counter values from - ** a [prepared statement]. The first argument is the prepared statement - ** object to be interrogated. The second argument - ** is an integer code for a specific [SQLITE_STMTSTATUS counte - ** to be interrogated.)^ - ** ^The current value of the requested counter is returned. - ** ^If the resetFlg is true, then the counter is reset to zero after this - ** interface call returns. - ** - ** See also: [sqlite3_status()] and [sqlite3_db_status()]. - */ - //SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); - - /* - ** CAPI3REF: Status Parameters for prepared statements - ** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters} - ** - ** These preprocessor macros define integer codes that name counter - ** values associated with the [sqlite3_stmt_status()] interface. - ** The meanings of the various counters are as follows: - ** - **
- ** [[SQLITE_STMTSTATUS_FULLSCAN_STEP]]
SQLITE_STMTSTATUS_FULLSCAN_STEP
- **
^This is the number of times that SQLite has stepped forward in - ** a table as part of a full table scan. Large numbers for this counter - ** may indicate opportunities for performance improvement through - ** careful use of indices.
- ** - ** [[SQLITE_STMTSTATUS_SORT]]
SQLITE_STMTSTATUS_SORT
- **
^This is the number of sort operations that have occurred. - ** A non-zero value in this counter may indicate an opportunity to - ** improvement performance through careful use of indices.
- ** - ** [[SQLITE_STMTSTATUS_AUTOINDEX]]
SQLITE_STMTSTATUS_AUTOINDEX
- **
^This is the number of rows inserted into transient indices that - ** were created automatically in order to help joins run faster. - ** A non-zero value in this counter may indicate an opportunity to - ** improvement performance by adding permanent indices that do not - ** need to be reinitialized each time the statement is run.
- ** - **
- */ - //#define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 - //#define SQLITE_STMTSTATUS_SORT 2 - //#define SQLITE_STMTSTATUS_AUTOINDEX 3 - public const int SQLITE_STMTSTATUS_FULLSCAN_STEP = 1; - public const int SQLITE_STMTSTATUS_SORT = 2; - public const int SQLITE_STMTSTATUS_AUTOINDEX = 3; - - /* - ** CAPI3REF: Custom Page Cache Object - ** - ** The sqlite3_pcache type is opaque. It is implemented by - ** the pluggable module. The SQLite core has no knowledge of - ** its size or internal structure and never deals with the - ** sqlite3_pcache object except by holding and passing pointers - ** to the object. - ** - ** See [sqlite3_pcache_methods] for additional information. - */ - //typedef struct sqlite3_pcache sqlite3_pcache; - - /* - ** CAPI3REF: Application Defined Page Cache. - ** KEYWORDS: {page cache} - ** - ** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can - ** register an alternative page cache implementation by passing in an - ** instance of the sqlite3_pcache_methods structure.)^ - ** In many applications, most of the heap memory allocated by - ** SQLite is used for the page cache. - ** By implementing a - ** custom page cache using this API, an application can better control - ** the amount of memory consumed by SQLite, the way in which - ** that memory is allocated and released, and the policies used to - ** determine exactly which parts of a database file are cached and for - ** how long. - ** - ** The alternative page cache mechanism is an - ** extreme measure that is only needed by the most demanding applications. - ** The built-in page cache is recommended for most uses. - ** - ** ^(The contents of the sqlite3_pcache_methods structure are copied to an - ** internal buffer by SQLite within the call to [sqlite3_config]. Hence - ** the application may discard the parameter after the call to - ** [sqlite3_config()] returns.)^ - ** - ** [[the xInit() page cache method]] - ** ^(The xInit() method is called once for each effective - ** call to [sqlite3_initialize()])^ - ** (usually only once during the lifetime of the process). ^(The xInit() - ** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^ - ** The intent of the xInit() method is to set up global data structures - ** required by the custom page cache implementation. - ** ^(If the xInit() method is NULL, then the - ** built-in default page cache is used instead of the application defined - ** page cache.)^ - ** - ** [[the xShutdown() page cache method]] - ** ^The xShutdown() method is called by [sqlite3_shutdown()]. - ** It can be used to clean up - ** any outstanding resources before process shutdown, if required. - ** ^The xShutdown() method may be NULL. - ** - ** ^SQLite automatically serializes calls to the xInit method, - ** so the xInit method need not be threadsafe. ^The - ** xShutdown method is only called from [sqlite3_shutdown()] so it does - ** not need to be threadsafe either. All other methods must be threadsafe - ** in multithreaded applications. - ** - ** ^SQLite will never invoke xInit() more than once without an intervening - ** call to xShutdown(). - ** - ** [[the xCreate() page cache methods]] - ** ^SQLite invokes the xCreate() method to construct a new cache instance. - ** SQLite will typically create one cache instance for each open database file, - ** though this is not guaranteed. ^The - ** first parameter, szPage, is the size in bytes of the pages that must - ** be allocated by the cache. ^szPage will not be a power of two. ^szPage - ** will the page size of the database file that is to be cached plus an - ** increment (here called "R") of less than 250. SQLite will use the - ** extra R bytes on each page to store metadata about the underlying - ** database page on disk. The value of R depends - ** on the SQLite version, the target platform, and how SQLite was compiled. - ** ^(R is constant for a particular build of SQLite. Except, there are two - ** distinct values of R when SQLite is compiled with the proprietary - ** ZIPVFS extension.)^ ^The second argument to - ** xCreate(), bPurgeable, is true if the cache being created will - ** be used to cache database pages of a file stored on disk, or - ** false if it is used for an in-memory database. The cache implementation - ** does not have to do anything special based with the value of bPurgeable; - ** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will - ** never invoke xUnpin() except to deliberately delete a page. - ** ^In other words, calls to xUnpin() on a cache with bPurgeable set to - ** false will always have the "discard" flag set to true. - ** ^Hence, a cache created with bPurgeable false will - ** never contain any unpinned pages. - ** - ** [[the xCachesize() page cache method]] - ** ^(The xCachesize() method may be called at any time by SQLite to set the - ** suggested maximum cache-size (number of pages stored by) the cache - ** instance passed as the first argument. This is the value configured using - ** the SQLite "[PRAGMA cache_size]" command.)^ As with the bPurgeable - ** parameter, the implementation is not required to do anything with this - ** value; it is advisory only. - ** - ** [[the xPagecount() page cache methods]] - ** The xPagecount() method must return the number of pages currently - ** stored in the cache, both pinned and unpinned. - ** - ** [[the xFetch() page cache methods]] - ** The xFetch() method locates a page in the cache and returns a pointer to - ** the page, or a NULL pointer. - ** A "page", in this context, means a buffer of szPage bytes aligned at an - ** 8-byte boundary. The page to be fetched is determined by the key. ^The - ** minimum key value is 1. After it has been retrieved using xFetch, the page - ** is considered to be "pinned". - ** - ** If the requested page is already in the page cache, then the page cache - ** implementation must return a pointer to the page buffer with its content - ** intact. If the requested page is not already in the cache, then the - ** cache implementation should use the value of the createFlag - ** parameter to help it determined what action to take: - ** - ** - **
createFlag Behaviour when page is not already in cache - **
0 Do not allocate a new page. Return NULL. - **
1 Allocate a new page if it easy and convenient to do so. - ** Otherwise return NULL. - **
2 Make every effort to allocate a new page. Only return - ** NULL if allocating a new page is effectively impossible. - **
- ** - ** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite - ** will only use a createFlag of 2 after a prior call with a createFlag of 1 - ** failed.)^ In between the to xFetch() calls, SQLite may - ** attempt to unpin one or more cache pages by spilling the content of - ** pinned pages to disk and synching the operating system disk cache. - ** - ** [[the xUnpin() page cache method]] - ** ^xUnpin() is called by SQLite with a pointer to a currently pinned page - ** as its second argument. If the third parameter, discard, is non-zero, - ** then the page must be evicted from the cache. - ** ^If the discard parameter is - ** zero, then the page may be discarded or retained at the discretion of - ** page cache implementation. ^The page cache implementation - ** may choose to evict unpinned pages at any time. - ** - ** The cache must not perform any reference counting. A single - ** call to xUnpin() unpins the page regardless of the number of prior calls - ** to xFetch(). - ** - ** [[the xRekey() page cache methods]] - ** The xRekey() method is used to change the key value associated with the - ** page passed as the second argument. If the cache - ** previously contains an entry associated with newKey, it must be - ** discarded. ^Any prior cache entry associated with newKey is guaranteed not - ** to be pinned. - ** - ** When SQLite calls the xTruncate() method, the cache must discard all - ** existing cache entries with page numbers (keys) greater than or equal - ** to the value of the iLimit parameter passed to xTruncate(). If any - ** of these pages are pinned, they are implicitly unpinned, meaning that - ** they can be safely discarded. - ** - ** [[the xDestroy() page cache method]] - ** ^The xDestroy() method is used to delete a cache allocated by xCreate(). - ** All resources associated with the specified cache should be freed. ^After - ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] - ** handle invalid, and will not use it with any other sqlite3_pcache_methods - ** functions. - */ - //typedef struct sqlite3_pcache_methods sqlite3_pcache_methods; - //struct sqlite3_pcache_methods { - // void *pArg; - // int (*xInit)(void); - // void (*xShutdown)(void); - // sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable); - // void (*xCachesize)(sqlite3_pcache*, int nCachesize); - // int (*xPagecount)(sqlite3_pcache); - // void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); - // void (*xUnpin)(sqlite3_pcache*, void*, int discard); - // void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey); - // void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); - // void (*xDestroy)(sqlite3_pcache); - //}; - public class sqlite3_pcache_methods - { - public object pArg; - public dxPC_Init xInit;//int (*xInit)(void); - public dxPC_Shutdown xShutdown;//public void (*xShutdown)(void); - public dxPC_Create xCreate;//public sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable); - public dxPC_Cachesize xCachesize;//public void (*xCachesize)(sqlite3_pcache*, int nCachesize); - public dxPC_Pagecount xPagecount;//public int (*xPagecount)(sqlite3_pcache); - public dxPC_Fetch xFetch;//public void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); - public dxPC_Unpin xUnpin;//public void (*xUnpin)(sqlite3_pcache*, void*, int discard); - public dxPC_Rekey xRekey;//public void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey); - public dxPC_Truncate xTruncate;//public void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); - public dxPC_Destroy xDestroy;//public void (*xDestroy)(sqlite3_pcache); - - public sqlite3_pcache_methods() - { - } - - public sqlite3_pcache_methods( object pArg, dxPC_Init xInit, dxPC_Shutdown xShutdown, dxPC_Create xCreate, dxPC_Cachesize xCachesize, dxPC_Pagecount xPagecount, dxPC_Fetch xFetch, dxPC_Unpin xUnpin, dxPC_Rekey xRekey, dxPC_Truncate xTruncate, dxPC_Destroy xDestroy ) - { - this.pArg = pArg; - this.xInit = xInit; - this.xShutdown = xShutdown; - this.xCreate = xCreate; - this.xCachesize = xCachesize; - this.xPagecount = xPagecount; - this.xFetch = xFetch; - this.xUnpin = xUnpin; - this.xRekey = xRekey; - this.xTruncate = xTruncate; - this.xDestroy = xDestroy; - } - }; - - - /* - ** CAPI3REF: Online Backup Object - ** - ** The sqlite3_backup object records state information about an ongoing - ** online backup operation. ^The sqlite3_backup object is created by - ** a call to [sqlite3_backup_init()] and is destroyed by a call to - ** [sqlite3_backup_finish()]. - ** - ** See Also: [Using the SQLite Online Backup API] - */ - //typedef struct sqlite3_backup sqlite3_backup; - - /* - ** CAPI3REF: Online Backup API. - ** - ** The backup API copies the content of one database into another. - ** It is useful either for creating backups of databases or - ** for copying in-memory databases to or from persistent files. - ** - ** See Also: [Using the SQLite Online Backup API] - ** - ** ^SQLite holds a write transaction open on the destination database file - ** for the duration of the backup operation. - ** ^The source database is read-locked only while it is being read; - ** it is not locked continuously for the entire backup operation. - ** ^Thus, the backup may be performed on a live source database without - ** preventing other database connections from - ** reading or writing to the source database while the backup is underway. - ** - ** ^(To perform a backup operation: - **
    - **
  1. sqlite3_backup_init() is called once to initialize the - ** backup, - **
  2. sqlite3_backup_step() is called one or more times to transfer - ** the data between the two databases, and finally - **
  3. sqlite3_backup_finish() is called to release all resources - ** associated with the backup operation. - **
)^ - ** There should be exactly one call to sqlite3_backup_finish() for each - ** successful call to sqlite3_backup_init(). - ** - ** [[sqlite3_backup_init()]] sqlite3_backup_init() - ** - ** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the - ** [database connection] associated with the destination database - ** and the database name, respectively. - ** ^The database name is "main" for the main database, "temp" for the - ** temporary database, or the name specified after the AS keyword in - ** an [ATTACH] statement for an attached database. - ** ^The S and M arguments passed to - ** sqlite3_backup_init(D,N,S,M) identify the [database connection] - ** and database name of the source database, respectively. - ** ^The source and destination [database connections] (parameters S and D) - ** must be different or else sqlite3_backup_init(D,N,S,M) will fail with - ** an error. - ** - ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is - ** returned and an error code and error message are stored in the - ** destination [database connection] D. - ** ^The error code and message for the failed call to sqlite3_backup_init() - ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or - ** [sqlite3_errmsg16()] functions. - ** ^A successful call to sqlite3_backup_init() returns a pointer to an - ** [sqlite3_backup] object. - ** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and - ** sqlite3_backup_finish() functions to perform the specified backup - ** operation. - ** - ** [[sqlite3_backup_step()]] sqlite3_backup_step() - ** - ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between - ** the source and destination databases specified by [sqlite3_backup] object B. - ** ^If N is negative, all remaining source pages are copied. - ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there - ** are still more pages to be copied, then the function returns [SQLITE_OK]. - ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages - ** from source to destination, then it returns [SQLITE_DONE]. - ** ^If an error occurs while running sqlite3_backup_step(B,N), - ** then an [error code] is returned. ^As well as [SQLITE_OK] and - ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], - ** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an - ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code. - ** - ** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if - **
    - **
  1. the destination database was opened read-only, or - **
  2. the destination database is using write-ahead-log journaling - ** and the destination and source page sizes differ, or - **
  3. the destination database is an in-memory database and the - ** destination and source page sizes differ. - **
)^ - ** - ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then - ** the [sqlite3_busy_handler | busy-handler function] - ** is invoked (if one is specified). ^If the - ** busy-handler returns non-zero before the lock is available, then - ** [SQLITE_BUSY] is returned to the caller. ^In this case the call to - ** sqlite3_backup_step() can be retried later. ^If the source - ** [database connection] - ** is being used to write to the source database when sqlite3_backup_step() - ** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this - ** case the call to sqlite3_backup_step() can be retried later on. ^(If - ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or - ** [SQLITE_READONLY] is returned, then - ** there is no point in retrying the call to sqlite3_backup_step(). These - ** errors are considered fatal.)^ The application must accept - ** that the backup operation has failed and pass the backup operation handle - ** to the sqlite3_backup_finish() to release associated resources. - ** - ** ^The first call to sqlite3_backup_step() obtains an exclusive lock - ** on the destination file. ^The exclusive lock is not released until either - ** sqlite3_backup_finish() is called or the backup operation is complete - ** and sqlite3_backup_step() returns [SQLITE_DONE]. ^Every call to - ** sqlite3_backup_step() obtains a [shared lock] on the source database that - ** lasts for the duration of the sqlite3_backup_step() call. - ** ^Because the source database is not locked between calls to - ** sqlite3_backup_step(), the source database may be modified mid-way - ** through the backup process. ^If the source database is modified by an - ** external process or via a database connection other than the one being - ** used by the backup operation, then the backup will be automatically - ** restarted by the next call to sqlite3_backup_step(). ^If the source - ** database is modified by the using the same database connection as is used - ** by the backup operation, then the backup database is automatically - ** updated at the same time. - ** - ** [[sqlite3_backup_finish()]] sqlite3_backup_finish() - ** - ** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the - ** application wishes to abandon the backup operation, the application - ** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish(). - ** ^The sqlite3_backup_finish() interfaces releases all - ** resources associated with the [sqlite3_backup] object. - ** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any - ** active write-transaction on the destination database is rolled back. - ** The [sqlite3_backup] object is invalid - ** and may not be used following a call to sqlite3_backup_finish(). - ** - ** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no - ** sqlite3_backup_step() errors occurred, regardless or whether or not - ** sqlite3_backup_step() completed. - ** ^If an out-of-memory condition or IO error occurred during any prior - ** sqlite3_backup_step() call on the same [sqlite3_backup] object, then - ** sqlite3_backup_finish() returns the corresponding [error code]. - ** - ** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step() - ** is not a permanent error and does not affect the return value of - ** sqlite3_backup_finish(). - ** - ** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]] - ** sqlite3_backup_remaining() and sqlite3_backup_pagecount() - ** - ** ^Each call to sqlite3_backup_step() sets two values inside - ** the [sqlite3_backup] object: the number of pages still to be backed - ** up and the total number of pages in the source database file. - ** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces - ** retrieve these two values, respectively. - ** - ** ^The values returned by these functions are only updated by - ** sqlite3_backup_step(). ^If the source database is modified during a backup - ** operation, then the values are not updated to account for any extra - ** pages that need to be updated or the size of the source database file - ** changing. - ** - ** Concurrent Usage of Database Handles - ** - ** ^The source [database connection] may be used by the application for other - ** purposes while a backup operation is underway or being initialized. - ** ^If SQLite is compiled and configured to support threadsafe database - ** connections, then the source database connection may be used concurrently - ** from within other threads. - ** - ** However, the application must guarantee that the destination - ** [database connection] is not passed to any other API (by any thread) after - ** sqlite3_backup_init() is called and before the corresponding call to - ** sqlite3_backup_finish(). SQLite does not currently check to see - ** if the application incorrectly accesses the destination [database connection] - ** and so no error code is reported, but the operations may malfunction - ** nevertheless. Use of the destination database connection while a - ** backup is in progress might also also cause a mutex deadlock. - ** - ** If running in [shared cache mode], the application must - ** guarantee that the shared cache used by the destination database - ** is not accessed while the backup is running. In practice this means - ** that the application must guarantee that the disk file being - ** backed up to is not accessed by any connection within the process, - ** not just the specific connection that was passed to sqlite3_backup_init(). - ** - ** The [sqlite3_backup] object itself is partially threadsafe. Multiple - ** threads may safely make multiple concurrent calls to sqlite3_backup_step(). - ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount() - ** APIs are not strictly speaking threadsafe. If they are invoked at the - ** same time as another thread is invoking sqlite3_backup_step() it is - ** possible that they return invalid values. - */ - //SQLITE_API sqlite3_backup *sqlite3_backup_init( - // sqlite3 *pDest, /* Destination database handle */ - // string zDestName, /* Destination database name */ - // sqlite3 *pSource, /* Source database handle */ - // string zSourceName /* Source database name */ - //); - //SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage); - //SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p); - //SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p); - //SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p); - - /* - ** CAPI3REF: Unlock Notification - ** - ** ^When running in shared-cache mode, a database operation may fail with - ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or - ** individual tables within the shared-cache cannot be obtained. See - ** [SQLite Shared-Cache Mode] for a description of shared-cache locking. - ** ^This API may be used to register a callback that SQLite will invoke - ** when the connection currently holding the required lock relinquishes it. - ** ^This API is only available if the library was compiled with the - ** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined. - ** - ** See Also: [Using the SQLite Unlock Notification Feature]. - ** - ** ^Shared-cache locks are released when a database connection concludes - ** its current transaction, either by committing it or rolling it back. - ** - ** ^When a connection (known as the blocked connection) fails to obtain a - ** shared-cache lock and SQLITE_LOCKED is returned to the caller, the - ** identity of the database connection (the blocking connection) that - ** has locked the required resource is stored internally. ^After an - ** application receives an SQLITE_LOCKED error, it may call the - ** sqlite3_unlock_notify() method with the blocked connection handle as - ** the first argument to register for a callback that will be invoked - ** when the blocking connections current transaction is concluded. ^The - ** callback is invoked from within the [sqlite3_step] or [sqlite3_close] - ** call that concludes the blocking connections transaction. - ** - ** ^(If sqlite3_unlock_notify() is called in a multi-threaded application, - ** there is a chance that the blocking connection will have already - ** concluded its transaction by the time sqlite3_unlock_notify() is invoked. - ** If this happens, then the specified callback is invoked immediately, - ** from within the call to sqlite3_unlock_notify().)^ - ** - ** ^If the blocked connection is attempting to obtain a write-lock on a - ** shared-cache table, and more than one other connection currently holds - ** a read-lock on the same table, then SQLite arbitrarily selects one of - ** the other connections to use as the blocking connection. - ** - ** ^(There may be at most one unlock-notify callback registered by a - ** blocked connection. If sqlite3_unlock_notify() is called when the - ** blocked connection already has a registered unlock-notify callback, - ** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is - ** called with a NULL pointer as its second argument, then any existing - ** unlock-notify callback is canceled. ^The blocked connections - ** unlock-notify callback may also be canceled by closing the blocked - ** connection using [sqlite3_close()]. - ** - ** The unlock-notify callback is not reentrant. If an application invokes - ** any sqlite3_xxx API functions from within an unlock-notify callback, a - ** crash or deadlock may be the result. - ** - ** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always - ** returns SQLITE_OK. - ** - ** Callback Invocation Details - ** - ** When an unlock-notify callback is registered, the application provides a - ** single void* pointer that is passed to the callback when it is invoked. - ** However, the signature of the callback function allows SQLite to pass - ** it an array of void* context pointers. The first argument passed to - ** an unlock-notify callback is a pointer to an array of void* pointers, - ** and the second is the number of entries in the array. - ** - ** When a blocking connections transaction is concluded, there may be - ** more than one blocked connection that has registered for an unlock-notify - ** callback. ^If two or more such blocked connections have specified the - ** same callback function, then instead of invoking the callback function - ** multiple times, it is invoked once with the set of void* context pointers - ** specified by the blocked connections bundled together into an array. - ** This gives the application an opportunity to prioritize any actions - ** related to the set of unblocked database connections. - ** - ** Deadlock Detection - ** - ** Assuming that after registering for an unlock-notify callback a - ** database waits for the callback to be issued before taking any further - ** action (a reasonable assumption), then using this API may cause the - ** application to deadlock. For example, if connection X is waiting for - ** connection Y's transaction to be concluded, and similarly connection - ** Y is waiting on connection X's transaction, then neither connection - ** will proceed and the system may remain deadlocked indefinitely. - ** - ** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock - ** detection. ^If a given call to sqlite3_unlock_notify() would put the - ** system in a deadlocked state, then SQLITE_LOCKED is returned and no - ** unlock-notify callback is registered. The system is said to be in - ** a deadlocked state if connection A has registered for an unlock-notify - ** callback on the conclusion of connection B's transaction, and connection - ** B has itself registered for an unlock-notify callback when connection - ** A's transaction is concluded. ^Indirect deadlock is also detected, so - ** the system is also considered to be deadlocked if connection B has - ** registered for an unlock-notify callback on the conclusion of connection - ** C's transaction, where connection C is waiting on connection A. ^Any - ** number of levels of indirection are allowed. - ** - ** The "DROP TABLE" Exception - ** - ** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost - ** always appropriate to call sqlite3_unlock_notify(). There is however, - ** one exception. When executing a "DROP TABLE" or "DROP INDEX" statement, - ** SQLite checks if there are any currently executing SELECT statements - ** that belong to the same connection. If there are, SQLITE_LOCKED is - ** returned. In this case there is no "blocking connection", so invoking - ** sqlite3_unlock_notify() results in the unlock-notify callback being - ** invoked immediately. If the application then re-attempts the "DROP TABLE" - ** or "DROP INDEX" query, an infinite loop might be the result. - ** - ** One way around this problem is to check the extended error code returned - ** by an sqlite3_step() call. ^(If there is a blocking connection, then the - ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in - ** the special "DROP TABLE/INDEX" case, the extended error code is just - ** SQLITE_LOCKED.)^ - */ - //SQLITE_API int sqlite3_unlock_notify( - // sqlite3 *pBlocked, /* Waiting connection */ - // void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */ - // void *pNotifyArg /* Argument to pass to xNotify */ - //); - - - /* - ** CAPI3REF: String Comparison - ** - ** ^The [sqlite3_strnicmp()] API allows applications and extensions to - ** compare the contents of two buffers containing UTF-8 strings in a - ** case-independent fashion, using the same definition of case independence - ** that SQLite uses internally when comparing identifiers. - */ - //SQLITE_API int sqlite3_strnicmp(string , string , int); - - /* - ** CAPI3REF: Error Logging Interface - ** - ** ^The [sqlite3_log()] interface writes a message into the error log - ** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()]. - ** ^If logging is enabled, the zFormat string and subsequent arguments are - ** used with [sqlite3_snprintf()] to generate the final output string. - ** - ** The sqlite3_log() interface is intended for use by extensions such as - ** virtual tables, collating functions, and SQL functions. While there is - ** nothing to prevent an application from calling sqlite3_log(), doing so - ** is considered bad form. - ** - ** The zFormat string must not be NULL. - ** - ** To avoid deadlocks and other threading problems, the sqlite3_log() routine - ** will not use dynamically allocated memory. The log message is stored in - ** a fixed-length buffer on the stack. If the log message is longer than - ** a few hundred characters, it will be truncated to the length of the - ** buffer. - */ - //SQLITE_API void sqlite3_log(int iErrCode, string zFormat, ...); - - /* - ** CAPI3REF: Write-Ahead Log Commit Hook - ** - ** ^The [sqlite3_wal_hook()] function is used to register a callback that - ** will be invoked each time a database connection commits data to a - ** [write-ahead log] (i.e. whenever a transaction is committed in - ** [journal_mode | journal_mode=WAL mode]). - ** - ** ^The callback is invoked by SQLite after the commit has taken place and - ** the associated write-lock on the database released, so the implementation - ** may read, write or [checkpoint] the database as required. - ** - ** ^The first parameter passed to the callback function when it is invoked - ** is a copy of the third parameter passed to sqlite3_wal_hook() when - ** registering the callback. ^The second is a copy of the database handle. - ** ^The third parameter is the name of the database that was written to - - ** either "main" or the name of an [ATTACH]-ed database. ^The fourth parameter - ** is the number of pages currently in the write-ahead log file, - ** including those that were just committed. - ** - ** The callback function should normally return [SQLITE_OK]. ^If an error - ** code is returned, that error will propagate back up through the - ** SQLite code base to cause the statement that provoked the callback - ** to report an error, though the commit will have still occurred. If the - ** callback returns [SQLITE_ROW] or [SQLITE_DONE], or if it returns a value - ** that does not correspond to any valid SQLite error code, the results - ** are undefined. - ** - ** A single database handle may have at most a single write-ahead log callback - ** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any - ** previously registered write-ahead log callback. ^Note that the - ** [sqlite3_wal_autocheckpoint()] interface and the - ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will - ** those overwrite any prior [sqlite3_wal_hook()] settings. - */ - //SQLITE_API void *sqlite3_wal_hook( - // sqlite3*, - // int()(void *,sqlite3*,const char*,int), - // void* - //); - - /* - ** CAPI3REF: Configure an auto-checkpoint - ** - ** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around - ** [sqlite3_wal_hook()] that causes any database on [database connection] D - ** to automatically [checkpoint] - ** after committing a transaction if there are N or - ** more frames in the [write-ahead log] file. ^Passing zero or - ** a negative value as the nFrame parameter disables automatic - ** checkpoints entirely. - ** - ** ^The callback registered by this function replaces any existing callback - ** registered using [sqlite3_wal_hook()]. ^Likewise, registering a callback - ** using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism - ** configured by this function. - ** - ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface - ** from SQL. - ** - ** ^Every new [database connection] defaults to having the auto-checkpoint - ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] - ** pages. The use of this interface - ** for a particular application. - */ - //SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 db, int N); - - /* - ** CAPI3REF: Checkpoint a database - ** - ** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X - ** on [database connection] D to be [checkpointed]. ^If X is NULL or an - ** empty string, then a checkpoint is run on all databases of - ** connection D. ^If the database connection D is not in - ** [WAL | write-ahead log mode] then this interface is a harmless no-op. - ** - ** ^The [wal_checkpoint pragma] can be used to invoke this interface - ** from SQL. ^The [sqlite3_wal_autocheckpoint()] interface and the - ** [wal_autocheckpoint pragma] can be used to cause this interface to be - ** run whenever the WAL reaches a certain size threshold. - ** - ** See also: [sqlite3_wal_checkpoint_v2()] - */ - //SQLITE_API int sqlite3_wal_checkpoint(sqlite3 db, string zDb); - - /* - ** CAPI3REF: Checkpoint a database - ** - ** Run a checkpoint operation on WAL database zDb attached to database - ** handle db. The specific operation is determined by the value of the - ** eMode parameter: - ** - **
- **
SQLITE_CHECKPOINT_PASSIVE
- ** Checkpoint as many frames as possible without waiting for any database - ** readers or writers to finish. Sync the db file if all frames in the log - ** are checkpointed. This mode is the same as calling - ** sqlite3_wal_checkpoint(). The busy-handler callback is never invoked. - ** - **
SQLITE_CHECKPOINT_FULL
- ** This mode blocks (calls the busy-handler callback) until there is no - ** database writer and all readers are reading from the most recent database - ** snapshot. It then checkpoints all frames in the log file and syncs the - ** database file. This call blocks database writers while it is running, - ** but not database readers. - ** - **
SQLITE_CHECKPOINT_RESTART
- ** This mode works the same way as SQLITE_CHECKPOINT_FULL, except after - ** checkpointing the log file it blocks (calls the busy-handler callback) - ** until all readers are reading from the database file only. This ensures - ** that the next client to write to the database file restarts the log file - ** from the beginning. This call blocks database writers while it is running, - ** but not database readers. - **
- ** - ** If pnLog is not NULL, then *pnLog is set to the total number of frames in - ** the log file before returning. If pnCkpt is not NULL, then *pnCkpt is set to - ** the total number of checkpointed frames (including any that were already - ** checkpointed when this function is called). *pnLog and *pnCkpt may be - ** populated even if sqlite3_wal_checkpoint_v2() returns other than SQLITE_OK. - ** If no values are available because of an error, they are both set to -1 - ** before returning to communicate this to the caller. - ** - ** All calls obtain an exclusive "checkpoint" lock on the database file. If - ** any other process is running a checkpoint operation at the same time, the - ** lock cannot be obtained and SQLITE_BUSY is returned. Even if there is a - ** busy-handler configured, it will not be invoked in this case. - ** - ** The SQLITE_CHECKPOINT_FULL and RESTART modes also obtain the exclusive - ** "writer" lock on the database file. If the writer lock cannot be obtained - ** immediately, and a busy-handler is configured, it is invoked and the writer - ** lock retried until either the busy-handler returns 0 or the lock is - ** successfully obtained. The busy-handler is also invoked while waiting for - ** database readers as described above. If the busy-handler returns 0 before - ** the writer lock is obtained or while waiting for database readers, the - ** checkpoint operation proceeds from that point in the same way as - ** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible - ** without blocking any further. SQLITE_BUSY is returned in this case. - ** - ** If parameter zDb is NULL or points to a zero length string, then the - ** specified operation is attempted on all WAL databases. In this case the - ** values written to output parameters *pnLog and *pnCkpt are undefined. If - ** an SQLITE_BUSY error is encountered when processing one or more of the - ** attached WAL databases, the operation is still attempted on any remaining - ** attached databases and SQLITE_BUSY is returned to the caller. If any other - ** error occurs while processing an attached database, processing is abandoned - ** and the error code returned to the caller immediately. If no error - ** (SQLITE_BUSY or otherwise) is encountered while processing the attached - ** databases, SQLITE_OK is returned. - ** - ** If database zDb is the name of an attached database that is not in WAL - ** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. If - ** zDb is not NULL (or a zero length string) and is not the name of any - ** attached database, SQLITE_ERROR is returned to the caller. - */ - //SQLITE_API int sqlite3_wal_checkpoint_v2( - // sqlite3 db, /* Database handle */ - // string zDb, /* Name of attached database (or NULL) */ - // int eMode, /* SQLITE_CHECKPOINT_* value */ - // int *pnLog, /* OUT: Size of WAL log in frames */ - // int *pnCkpt /* OUT: Total number of frames checkpointed */ - //); - - /* - ** CAPI3REF: Checkpoint operation parameters - ** - ** These constants can be used as the 3rd parameter to - ** [sqlite3_wal_checkpoint_v2()]. See the [sqlite3_wal_checkpoint_v2()] - ** documentation for additional information about the meaning and use of - ** each of these values. - */ - //#define SQLITE_CHECKPOINT_PASSIVE 0 - //#define SQLITE_CHECKPOINT_FULL 1 - //#define SQLITE_CHECKPOINT_RESTART 2 - static public int SQLITE_CHECKPOINT_PASSIVE = 0; - static public int SQLITE_CHECKPOINT_FULL = 1; - static public int SQLITE_CHECKPOINT_RESTART = 2; - - - /* - ** CAPI3REF: Virtual Table Interface Configuration - ** - ** This function may be called by either the [xConnect] or [xCreate] method - ** of a [virtual table] implementation to configure - ** various facets of the virtual table interface. - ** - ** If this interface is invoked outside the context of an xConnect or - ** xCreate virtual table method then the behavior is undefined. - ** - ** At present, there is only one option that may be configured using - ** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options - ** may be added in the future. - */ - //SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...); - - /* - ** CAPI3REF: Virtual Table Configuration Options - ** - ** These macros define the various options to the - ** [sqlite3_vtab_config()] interface that [virtual table] implementations - ** can use to customize and optimize their behavior. - ** - **
- **
SQLITE_VTAB_CONSTRAINT_SUPPORT - **
Calls of the form - ** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported, - ** where X is an integer. If X is zero, then the [virtual table] whose - ** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not - ** support constraints. In this configuration (which is the default) if - ** a call to the [xUpdate] method returns [SQLITE_CONSTRAINT], then the entire - ** statement is rolled back as if [ON CONFLICT | OR ABORT] had been - ** specified as part of the users SQL statement, regardless of the actual - ** ON CONFLICT mode specified. - ** - ** If X is non-zero, then the virtual table implementation guarantees - ** that if [xUpdate] returns [SQLITE_CONSTRAINT], it will do so before - ** any modifications to internal or persistent data structures have been made. - ** If the [ON CONFLICT] mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite - ** is able to roll back a statement or database transaction, and abandon - ** or continue processing the current SQL statement as appropriate. - ** If the ON CONFLICT mode is REPLACE and the [xUpdate] method returns - ** [SQLITE_CONSTRAINT], SQLite handles this as if the ON CONFLICT mode - ** had been ABORT. - ** - ** Virtual table implementations that are required to handle OR REPLACE - ** must do so within the [xUpdate] method. If a call to the - ** [sqlite3_vtab_on_conflict()] function indicates that the current ON - ** CONFLICT policy is REPLACE, the virtual table implementation should - ** silently replace the appropriate rows within the xUpdate callback and - ** return SQLITE_OK. Or, if this is not possible, it may return - ** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT - ** constraint handling. - **
- */ - //#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1 - public const int SQLITE_VTAB_CONSTRAINT_SUPPORT = 1; - - /* - ** CAPI3REF: Determine The Virtual Table Conflict Policy - ** - ** This function may only be called from within a call to the [xUpdate] method - ** of a [virtual table] implementation for an INSERT or UPDATE operation. ^The - ** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL], - ** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode - ** of the SQL statement that triggered the call to the [xUpdate] method of the - ** [virtual table]. - */ - //SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 ); - - /* - ** CAPI3REF: Conflict resolution modes - ** - ** These constants are returned by [sqlite3_vtab_on_conflict()] to - ** inform a [virtual table] implementation what the [ON CONFLICT] mode - ** is for the SQL statement being evaluated. - ** - ** Note that the [SQLITE_IGNORE] constant is also used as a potential - ** return value from the [sqlite3_set_authorizer()] callback and that - ** [SQLITE_ABORT] is also a [result code]. - */ - //#define SQLITE_ROLLBACK 1 - public const int SQLITE_ROLLBACK = 1; - /* #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback */ - //#define SQLITE_FAIL 3 - public const int SQLITE_FAIL = 3; - /* #define SQLITE_ABORT 4 // Also an error code */ - //#define SQLITE_REPLACE 5 - public const int SQLITE_REPLACE = 5; - - - /* - ** Undo the hack that converts floating point types to integer for - ** builds on processors without floating point support. - */ - //#if SQLITE_OMIT_FLOATING_POINT - //# undef double - //#endif - - //#if __cplusplus - //} /* End of the 'extern "C"' block */ - //#endif - //#endif - - /* - ** 2010 August 30 - ** - ** 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. - ** - ************************************************************************* - */ - - //#if !_SQLITE3RTREE_H_ - //#define _SQLITE3RTREE_H_ - - - //#if __cplusplus - //extern "C" { - //#endif - - //typedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry; - - /* - ** Register a geometry callback named zGeom that can be used as part of an - ** R-Tree geometry query as follows: - ** - ** SELECT ... FROM WHERE MATCH $zGeom(... params ...) - */ - //SQLITE_API int sqlite3_rtree_geometry_callback( - // sqlite3 db, - // string zGeom, - // int (*xGeom)(sqlite3_rtree_geometry *, int nCoord, double *aCoord, int *pRes), - // void *pContext - //); - - - /* - ** A pointer to a structure of the following type is passed as the first - ** argument to callbacks registered using rtree_geometry_callback(). - */ - //struct sqlite3_rtree_geometry { - // void *pContext; /* Copy of pContext passed to s_r_g_c() */ - // int nParam; /* Size of array aParam[] */ - // double *aParam; /* Parameters passed to SQL geom function */ - // void *pUser; /* Callback implementation user data */ - // void (*xDelUser)(void ); /* Called by SQLite to clean up pUser */ - //}; - - - //#if __cplusplus - //} /* end of the 'extern "C"' block */ - //#endif - - //#endif /* ifndef _SQLITE3RTREE_H_ */ - - } } diff --git a/Src/IronPython.SQLite/c#sqlite/sqliteInt_h.cs b/Src/IronPython.SQLite/c#sqlite/sqliteInt_h.cs index a7f7ac6fe..728553bdd 100644 --- a/Src/IronPython.SQLite/c#sqlite/sqliteInt_h.cs +++ b/Src/IronPython.SQLite/c#sqlite/sqliteInt_h.cs @@ -2,7 +2,6 @@ using System; using System.Diagnostics; -using System.Runtime.InteropServices; using System.Text; using Bitmask = System.UInt64; @@ -14,9 +13,6 @@ using u16 = System.UInt16; using u32 = System.UInt32; using u64 = System.UInt64; -using unsigned = System.UInt64; - -using Pgno = System.UInt32; #if !SQLITE_MAX_VARIABLE_NUMBER using ynVar = System.Int16; @@ -35,88 +31,86 @@ using yDbMask = System.Int32; #endif -namespace Community.CsharpSqlite -{ - using sqlite3_value = Sqlite3.Mem; - - public partial class Sqlite3 - { - /* - ** 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. - ** - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#if !_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. - */ - //#if !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 - */ +namespace Community.CsharpSqlite { + using sqlite3_value = Sqlite3.Mem; + + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#if !_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. + */ + //#if !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 + */ #if _HAVE_SQLITE_CONFIG_H //#include "config.h" #endif - //#include "sqliteLimit.h" - - /* Disable nuisance warnings on Borland compilers */ - //#if (__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... */ - //#if !_GNU_SOURCE - //#define _GNU_SOURCE - //#endif - /* - ** Include standard header files as necessary - */ + //#include "sqliteLimit.h" + + /* Disable nuisance warnings on Borland compilers */ + //#if (__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... */ + //#if !_GNU_SOURCE + //#define _GNU_SOURCE + //#endif + /* + ** Include standard header files as necessary + */ #if HAVE_STDINT_H //#include #endif @@ -124,254 +118,246 @@ public partial class Sqlite3 //#include #endif - /* -** The number of samples of an index that SQLite takes in order to -** construct a histogram of the table content when running ANALYZE -** and with SQLITE_ENABLE_STAT2 -*/ - //#define SQLITE_INDEX_SAMPLES 10 - public const int SQLITE_INDEX_SAMPLES = 10; - - /* - ** 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 (__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 libary 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. + /* + ** The number of samples of an index that SQLite takes in order to + ** construct a histogram of the table content when running ANALYZE + ** and with SQLITE_ENABLE_STAT2 */ + //#define SQLITE_INDEX_SAMPLES 10 + public const int SQLITE_INDEX_SAMPLES = 10; + + /* + ** 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 (__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 libary 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 !SQLITE_THREADSAFE //# define SQLITE_THREADSAFE 2 const int SQLITE_THREADSAFE = 2; #else - const int SQLITE_THREADSAFE = 2; /* IMP: R-07272-22309 */ + const int SQLITE_THREADSAFE = 2; /* IMP: R-07272-22309 */ #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. -*/ + /* + ** 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 !(SQLITE_DEFAULT_MEMSTATUS) - //# define SQLITE_DEFAULT_MEMSTATUS 1 - const int SQLITE_DEFAULT_MEMSTATUS = 0; + //# define SQLITE_DEFAULT_MEMSTATUS 1 + const int SQLITE_DEFAULT_MEMSTATUS = 0; #else const int 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_MEMDEBUG // Debugging version of system malloc() -** -** (Historical note: There used to be several other options, but we've -** pared it down to just these two.) -** -** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as -** the default. -*/ - //#if (SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)+\ - //# error "At most one of the following compile-time configuration options\ - // is allows: SQLITE_SYSTEM_MALLOC, SQLITE_MEMDEBUG" - //#endif - //#if (SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)+\ - //# 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. + /* + ** 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_MEMDEBUG // Debugging version of system malloc() + ** + ** (Historical note: There used to be several other options, but we've + ** pared it down to just these two.) + ** + ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as + ** the default. */ + //#if (SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)+\ + //# error "At most one of the following compile-time configuration options\ + // is allows: SQLITE_SYSTEM_MALLOC, SQLITE_MEMDEBUG" + //#endif + //#if (SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)+\ + //# 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 !(SQLITE_MALLOC_SOFT_LIMIT) - const int SQLITE_MALLOC_SOFT_LIMIT = 1024; + const int SQLITE_MALLOC_SOFT_LIMIT = 1024; #endif - /* -** We need to define _XOPEN_SOURCE as follows in order to enable -** recursive mutexes on most Unix systems. But Mac OS X is different. -** The _XOPEN_SOURCE define causes problems for Mac OS X we are told, -** so it is omitted there. See ticket #2673. -** -** Later we learn that _XOPEN_SOURCE is poorly or incorrectly -** implemented on some systems. So we avoid defining it at all -** if it is already defined or if it is unneeded because we are -** not doing a threadsafe build. Ticket #2681. -** -** See also ticket #2741. -*/ + /* + ** We need to define _XOPEN_SOURCE as follows in order to enable + ** recursive mutexes on most Unix systems. But Mac OS X is different. + ** The _XOPEN_SOURCE define causes problems for Mac OS X we are told, + ** so it is omitted there. See ticket #2673. + ** + ** Later we learn that _XOPEN_SOURCE is poorly or incorrectly + ** implemented on some systems. So we avoid defining it at all + ** if it is already defined or if it is unneeded because we are + ** not doing a threadsafe build. Ticket #2681. + ** + ** See also ticket #2741. + */ #if !_XOPEN_SOURCE && !__DARWIN__ && !__APPLE__ && SQLITE_THREADSAFE - const int _XOPEN_SOURCE = 500;//#define _XOPEN_SOURCE 500 /* Needed to enable pthread recursive mutexes */ + const int _XOPEN_SOURCE = 500;//#define _XOPEN_SOURCE 500 /* Needed to enable pthread recursive mutexes */ #endif - /* -** The TCL headers are only needed when compiling the TCL bindings. -*/ + /* + ** The TCL headers are only needed when compiling the TCL bindings. + */ #if SQLITE_TCL || TCLSH //# include #endif - /* -** Many people are failing to set -DNDEBUG=1 when compiling SQLite. -** Setting NDEBUG makes the code smaller and run faster. So the following -** lines are added to automatically set NDEBUG unless the -DSQLITE_DEBUG=1 -** option is set. Thus NDEBUG becomes an opt-in rather than an opt-out -** feature. -*/ + /* + ** Many people are failing to set -DNDEBUG=1 when compiling SQLite. + ** Setting NDEBUG makes the code smaller and run faster. So the following + ** lines are added to automatically set NDEBUG unless the -DSQLITE_DEBUG=1 + ** option is set. Thus NDEBUG becomes an opt-in rather than an opt-out + ** feature. + */ #if !NDEBUG && !SQLITE_DEBUG const int NDEBUG = 1;//# define NDEBUG 1 #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. -** -*/ + /* + ** 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. + ** + */ #if SQLITE_COVERAGE_TEST void sqlite3Coverage(int); //# define testcase(X) if( X ){ sqlite3Coverage(__LINE__); } #else - //# define testcase(X) - static void testcase( T X ) - { - } + //# define testcase(X) + static void testcase(T 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 Debug.Assert() macros. -*/ + /* + ** The TESTONLY macro is used to enclose variable declarations or + ** other bits of code that are needed to support the arguments + ** within testcase() and Debug.Assert() macros. + */ #if !NDEBUG || SQLITE_COVERAGE_TEST - //# define TESTONLY(X) X - // -- Need workaround for C#, since inline macros don't exist + //# define TESTONLY(X) X + // -- Need workaround for C#, since inline macros don't exist #else //# define TESTONLY(X) #endif - /* -** Sometimes we need a small amount of code such as a variable initialization -** to setup for a later Debug.Assert() statement. We do not want this code to -** appear when Debug.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. -*/ + /* + ** Sometimes we need a small amount of code such as a variable initialization + ** to setup for a later Debug.Assert() statement. We do not want this code to + ** appear when Debug.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. + */ #if !NDEBUG - //# define VVA_ONLY(X) X + //# 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 then specify will -** not be counted as untested code. -*/ + /* + ** 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 then specify will + ** not be counted as untested code. + */ #if SQLITE_COVERAGE_TEST //# define ALWAYS(X) (1) //# define NEVER(X) (0) #elif !NDEBUG - //# define ALWAYS(X) ((X)?1:(Debug.Assert(0),0)) - static bool ALWAYS( bool X ) - { - if ( X != true ) - Debug.Assert( false ); - return true; - } - static int ALWAYS( int X ) - { - if ( X == 0 ) - Debug.Assert( false ); - return 1; - } - static bool ALWAYS( T X ) - { - if ( X == null ) - Debug.Assert( false ); - return true; - } + //# define ALWAYS(X) ((X)?1:(Debug.Assert(0),0)) + static bool ALWAYS(bool X) { + if (X != true) + Debug.Assert(false); + return true; + } + static int ALWAYS(int X) { + if (X == 0) + Debug.Assert(false); + return 1; + } + static bool ALWAYS(T X) { + if (X == null) + Debug.Assert(false); + return true; + } - //# define NEVER(X) ((X)?(Debug.Assert(0),1):0) - static bool NEVER( bool X ) - { - if ( X == true ) - Debug.Assert( false ); - return false; - } - static byte NEVER( byte X ) - { - if ( X != 0 ) - Debug.Assert( false ); - return 0; - } - static int NEVER( int X ) - { - if ( X != 0 ) - Debug.Assert( false ); - return 0; - } - static bool NEVER( T X ) - { - if ( X != null ) - Debug.Assert( false ); - return false; - } + //# define NEVER(X) ((X)?(Debug.Assert(0),1):0) + static bool NEVER(bool X) { + if (X == true) + Debug.Assert(false); + return false; + } + static byte NEVER(byte X) { + if (X != 0) + Debug.Assert(false); + return 0; + } + static int NEVER(int X) { + if (X != 0) + Debug.Assert(false); + return 0; + } + static bool NEVER(T X) { + if (X != null) + Debug.Assert(false); + return false; + } #else //# define ALWAYS(X) (X) static bool ALWAYS(bool X) { return X; } @@ -386,51 +372,48 @@ static bool NEVER( T X ) static bool NEVER(T X) { return false; } #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. -*/ - static bool IS_BIG_INT( i64 X ) - { - return ( ( ( X ) & ~(i64)0xffffffff ) != 0 ); - }//#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. GCC is able to - ** use these hints to generate better code, sometimes. + /* + ** 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. */ + static bool IS_BIG_INT(i64 X) { + return (((X) & ~(i64)0xffffffff) != 0); + }//#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. GCC is able to + ** use these hints to generate better code, sometimes. + */ #if (__GNUC__) && FALSE //# define likely(X) __builtin_expect((X),1) //# define unlikely(X) __builtin_expect((X),0) #else - //# define likely(X) !!(X) - static bool likely( bool X ) - { - return !!X; - } - //# define unlikely(X) !!(X) - static bool unlikely( bool X ) - { - return !!X; - } + //# define likely(X) !!(X) + static bool likely(bool X) { + return !!X; + } + //# define unlikely(X) !!(X) + static bool unlikely(bool X) { + return !!X; + } #endif - //#include "sqlite3.h" - //#include "hash.h" - //#include "parse.h" - //#include - //#include - //#include - //#include - //#include - - /* - ** If compiling for a processor that lacks floating point support, - ** substitute integer for floating-point - */ + //#include "sqlite3.h" + //#include "hash.h" + //#include "parse.h" + //#include + //#include + //#include + //#include + //#include + + /* + ** If compiling for a processor that lacks floating point support, + ** substitute integer for floating-point + */ #if SQLITE_OMIT_FLOATING_POINT //# define double sqlite_int64 //# define float sqlite_int64 @@ -444,265 +427,261 @@ static bool unlikely( bool X ) //# undef SQLITE_HAVE_ISNAN #endif #if !SQLITE_BIG_DBL - const double SQLITE_BIG_DBL = ( ( (sqlite3_int64)1 ) << 60 );//# define SQLITE_BIG_DBL (1e99) + const double SQLITE_BIG_DBL = (((sqlite3_int64)1) << 60);//# define SQLITE_BIG_DBL (1e99) #endif - /* -** OMIT_TEMPDB is set to 1 if SQLITE_OMIT_TEMPDB is defined, or 0 -** afterward. Having this macro allows us to cause the C compiler -** to omit code used by TEMP tables without messy #if !statements. -*/ + /* + ** OMIT_TEMPDB is set to 1 if SQLITE_OMIT_TEMPDB is defined, or 0 + ** afterward. Having this macro allows us to cause the C compiler + ** to omit code used by TEMP tables without messy #if !statements. + */ #if SQLITE_OMIT_TEMPDB //#define OMIT_TEMPDB 1 #else - static int OMIT_TEMPDB = 0; + static int OMIT_TEMPDB = 0; #endif - /* -** The "file format" number is an integer that is incremented whenever -** the VDBE-level file format changes. The following macros define the -** the default file format for new databases and the maximum file format -** that the library can read. -*/ - static public int SQLITE_MAX_FILE_FORMAT = 4;//#define SQLITE_MAX_FILE_FORMAT 4 - //#if !SQLITE_DEFAULT_FILE_FORMAT - static int SQLITE_DEFAULT_FILE_FORMAT = 1;//# define SQLITE_DEFAULT_FILE_FORMAT 1 - //#endif - - /* - ** Determine whether triggers are recursive by default. This can be - ** changed at run-time using a pragma. + /* + ** The "file format" number is an integer that is incremented whenever + ** the VDBE-level file format changes. The following macros define the + ** the default file format for new databases and the maximum file format + ** that the library can read. */ + static public int SQLITE_MAX_FILE_FORMAT = 4;//#define SQLITE_MAX_FILE_FORMAT 4 + //#if !SQLITE_DEFAULT_FILE_FORMAT + static int SQLITE_DEFAULT_FILE_FORMAT = 1;//# define SQLITE_DEFAULT_FILE_FORMAT 1 + //#endif + + /* + ** Determine whether triggers are recursive by default. This can be + ** changed at run-time using a pragma. + */ #if !SQLITE_DEFAULT_RECURSIVE_TRIGGERS - //# define SQLITE_DEFAULT_RECURSIVE_TRIGGERS 0 - static public bool SQLITE_DEFAULT_RECURSIVE_TRIGGERS = false; + //# define SQLITE_DEFAULT_RECURSIVE_TRIGGERS 0 + static public bool SQLITE_DEFAULT_RECURSIVE_TRIGGERS = false; #else static public bool SQLITE_DEFAULT_RECURSIVE_TRIGGERS = true; #endif - /* -** Provide a default value for SQLITE_TEMP_STORE in case it is not specified -** on the command-line -*/ - //#if !SQLITE_TEMP_STORE - static int SQLITE_TEMP_STORE = 1;//#define SQLITE_TEMP_STORE 1 - //#endif + /* + ** Provide a default value for SQLITE_TEMP_STORE in case it is not specified + ** on the command-line + */ + //#if !SQLITE_TEMP_STORE + static int SQLITE_TEMP_STORE = 1;//#define SQLITE_TEMP_STORE 1 + //#endif - /* -** GCC does not define the offsetof() macro so we'll have to do it -** ourselves. -*/ + /* + ** GCC does not define the offsetof() macro so we'll have to do it + ** ourselves. + */ #if !offsetof - //#define offsetof(STRUCTURE,FIELD) ((int)((char)&((STRUCTURE)0)->FIELD)) + //#define offsetof(STRUCTURE,FIELD) ((int)((char)&((STRUCTURE)0)->FIELD)) #endif - /* -** Check to see if this machine uses EBCDIC. (Yes, believe it or -** not, there are still machines out there that use EBCDIC.) -*/ + /* + ** Check to see if this machine uses EBCDIC. (Yes, believe it or + ** not, there are still machines out there that use EBCDIC.) + */ #if FALSE //'A' == '\301' //# define SQLITE_EBCDIC 1 #else - const int SQLITE_ASCII = 1;//#define SQLITE_ASCII 1 + const int SQLITE_ASCII = 1;//#define SQLITE_ASCII 1 #endif - /* -** Integers of known sizes. These typedefs might change for architectures -** where the sizes very. Preprocessor macros are available so that the -** types can be conveniently redefined at compile-type. Like this: -** -** cc '-Du32PTR_TYPE=long long int' ... -*/ - //#if !u32_TYPE - //# ifdef HAVE_u32_T - //# define u32_TYPE u32_t - //# else - //# define u32_TYPE unsigned int - //# endif - //#endif - //#if !u3216_TYPE - //# ifdef HAVE_u3216_T - //# define u3216_TYPE u3216_t - //# else - //# define u3216_TYPE unsigned short int - //# endif - //#endif - //#if !INT16_TYPE - //# ifdef HAVE_INT16_T - //# define INT16_TYPE int16_t - //# else - //# define INT16_TYPE short int - //# endif - //#endif - //#if !u328_TYPE - //# ifdef HAVE_u328_T - //# define u328_TYPE u328_t - //# else - //# define u328_TYPE unsigned char - //# endif - //#endif - //#if !INT8_TYPE - //# ifdef HAVE_INT8_T - //# define INT8_TYPE int8_t - //# else - //# define INT8_TYPE signed char - //# endif - //#endif - //#if !LONGDOUBLE_TYPE - //# define LONGDOUBLE_TYPE long double - //#endif - //typedef sqlite_int64 i64; /* 8-byte signed integer */ - //typedef sqlite_u3264 u64; /* 8-byte unsigned integer */ - //typedef u32_TYPE u32; /* 4-byte unsigned integer */ - //typedef u3216_TYPE u16; /* 2-byte unsigned integer */ - //typedef INT16_TYPE i16; /* 2-byte signed integer */ - //typedef u328_TYPE u8; /* 1-byte unsigned integer */ - //typedef INT8_TYPE i8; /* 1-byte signed integer */ - - /* - ** SQLITE_MAX_U32 is a u64 constant that is the maximum u64 value - ** that can be stored in a u32 without loss of data. The value - ** is 0x00000000ffffffff. But because of quirks of some compilers, we - ** have to specify the value in the less intuitive manner shown: - */ - //#define SQLITE_MAX_U32 ((((u64)1)<<32)-1) - const u32 SQLITE_MAX_U32 = (u32)( ( ( (u64)1 ) << 32 ) - 1 ); - - - /* - ** Macros to determine whether the machine is big or little endian, - ** evaluated at runtime. + /* + ** Integers of known sizes. These typedefs might change for architectures + ** where the sizes very. Preprocessor macros are available so that the + ** types can be conveniently redefined at compile-type. Like this: + ** + ** cc '-Du32PTR_TYPE=long long int' ... */ + //#if !u32_TYPE + //# ifdef HAVE_u32_T + //# define u32_TYPE u32_t + //# else + //# define u32_TYPE unsigned int + //# endif + //#endif + //#if !u3216_TYPE + //# ifdef HAVE_u3216_T + //# define u3216_TYPE u3216_t + //# else + //# define u3216_TYPE unsigned short int + //# endif + //#endif + //#if !INT16_TYPE + //# ifdef HAVE_INT16_T + //# define INT16_TYPE int16_t + //# else + //# define INT16_TYPE short int + //# endif + //#endif + //#if !u328_TYPE + //# ifdef HAVE_u328_T + //# define u328_TYPE u328_t + //# else + //# define u328_TYPE unsigned char + //# endif + //#endif + //#if !INT8_TYPE + //# ifdef HAVE_INT8_T + //# define INT8_TYPE int8_t + //# else + //# define INT8_TYPE signed char + //# endif + //#endif + //#if !LONGDOUBLE_TYPE + //# define LONGDOUBLE_TYPE long double + //#endif + //typedef sqlite_int64 i64; /* 8-byte signed integer */ + //typedef sqlite_u3264 u64; /* 8-byte unsigned integer */ + //typedef u32_TYPE u32; /* 4-byte unsigned integer */ + //typedef u3216_TYPE u16; /* 2-byte unsigned integer */ + //typedef INT16_TYPE i16; /* 2-byte signed integer */ + //typedef u328_TYPE u8; /* 1-byte unsigned integer */ + //typedef INT8_TYPE i8; /* 1-byte signed integer */ + + /* + ** SQLITE_MAX_U32 is a u64 constant that is the maximum u64 value + ** that can be stored in a u32 without loss of data. The value + ** is 0x00000000ffffffff. But because of quirks of some compilers, we + ** have to specify the value in the less intuitive manner shown: + */ + //#define SQLITE_MAX_U32 ((((u64)1)<<32)-1) + const u32 SQLITE_MAX_U32 = (u32)((((u64)1) << 32) - 1); + + + /* + ** Macros to determine whether the machine is big or little endian, + ** evaluated at runtime. + */ #if SQLITE_AMALGAMATION //const int sqlite3one = 1; #else - const bool sqlite3one = true; + const bool sqlite3one = true; #endif #if i386 || __i386__ || _M_IX86 const int ;//#define SQLITE_BIGENDIAN 0 const int ;//#define SQLITE_LITTLEENDIAN 1 const int ;//#define SQLITE_UTF16NATIVE SQLITE_UTF16LE #else - static u8 SQLITE_BIGENDIAN = 0;//#define SQLITE_BIGENDIAN (*(char )(&sqlite3one)==0) - static u8 SQLITE_LITTLEENDIAN = 1;//#define SQLITE_LITTLEENDIAN (*(char )(&sqlite3one)==1) - static u8 SQLITE_UTF16NATIVE = ( SQLITE_BIGENDIAN != 0 ? SQLITE_UTF16BE : SQLITE_UTF16LE );//#define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE) + static u8 SQLITE_BIGENDIAN = 0;//#define SQLITE_BIGENDIAN (*(char )(&sqlite3one)==0) + static u8 SQLITE_LITTLEENDIAN = 1;//#define SQLITE_LITTLEENDIAN (*(char )(&sqlite3one)==1) + static u8 SQLITE_UTF16NATIVE = (SQLITE_BIGENDIAN != 0 ? SQLITE_UTF16BE : SQLITE_UTF16LE);//#define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE) #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. -*/ - //#define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32)) - //#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64) - const i64 LARGEST_INT64 = i64.MaxValue;//( 0xffffffff | ( ( (i64)0x7fffffff ) << 32 ) ); - const i64 SMALLEST_INT64 = i64.MinValue;//( ( ( i64 ) - 1 ) - LARGEST_INT64 ); - - /* - ** Round up a number to the next larger multiple of 8. This is used - ** to force 8-byte alignment on 64-bit architectures. - */ - //#define ROUND8(x) (((x)+7)&~7) - static int ROUND8( int x ) - { - return ( x + 7 ) & ~7; - } - - /* - ** Round down to the nearest multiple of 8 - */ - //#define ROUNDDOWN8(x) ((x)&~7) - static int ROUNDDOWN8( int x ) - { - return x & ~7; - } - - /* - ** Assert that the pointer X is aligned to an 8-byte boundary. This - ** macro is used only within Debug.Assert() to verify that the code gets - ** all alignment restrictions correct. - ** - ** Except, if SQLITE_4_BYTE_ALIGNED_MALLOC is defined, then the - ** underlying malloc() implemention might return us 4-byte aligned - ** pointers. In that case, only verify 4-byte alignment. - */ - //#if SQLITE_4_BYTE_ALIGNED_MALLOC - //# define EIGHT_BYTE_ALIGNMENT(X) ((((char)(X) - (char)0)&3)==0) - //#else - //# define EIGHT_BYTE_ALIGNMENT(X) ((((char)(X) - (char)0)&7)==0) - //#endif - - /* - ** An instance of the following structure is used to store the busy-handler - ** callback for a given sqlite handle. - ** - ** The sqlite.busyHandler member of the sqlite struct contains the busy - ** callback for the database handle. Each pager opened via the sqlite - ** handle is passed a pointer to sqlite.busyHandler. The busy-handler - ** callback is currently invoked only from within pager.c. - */ - //typedef struct BusyHandler BusyHandler; - public class BusyHandler - { - public dxBusy xFunc;//)(void *,int); /* The busy callback */ - public object pArg; /* First arg to busy callback */ - public int nBusy; /* Incremented with each busy call */ - }; - - /* - ** Name of the master database table. The master database table - ** is a special table that holds the names and attributes of all - ** user tables and indices. + /* + ** 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. */ - const string MASTER_NAME = "sqlite_master";//#define MASTER_NAME "sqlite_master" - const string TEMP_MASTER_NAME = "sqlite_temp_master";//#define TEMP_MASTER_NAME "sqlite_temp_master" + //#define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32)) + //#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64) + const i64 LARGEST_INT64 = i64.MaxValue;//( 0xffffffff | ( ( (i64)0x7fffffff ) << 32 ) ); + const i64 SMALLEST_INT64 = i64.MinValue;//( ( ( i64 ) - 1 ) - LARGEST_INT64 ); + + /* + ** Round up a number to the next larger multiple of 8. This is used + ** to force 8-byte alignment on 64-bit architectures. + */ + //#define ROUND8(x) (((x)+7)&~7) + static int ROUND8(int x) { + return (x + 7) & ~7; + } - /* - ** The root-page of the master database table. - */ - const int MASTER_ROOT = 1;//#define MASTER_ROOT 1 + /* + ** Round down to the nearest multiple of 8 + */ + //#define ROUNDDOWN8(x) ((x)&~7) + static int ROUNDDOWN8(int x) { + return x & ~7; + } - /* - ** The name of the schema table. - */ - static string SCHEMA_TABLE( int x ) //#define SCHEMA_TABLE(x) ((!OMIT_TEMPDB)&&(x==1)?TEMP_MASTER_NAME:MASTER_NAME) - { - return ( ( OMIT_TEMPDB == 0 ) && ( x == 1 ) ? TEMP_MASTER_NAME : MASTER_NAME ); - } + /* + ** Assert that the pointer X is aligned to an 8-byte boundary. This + ** macro is used only within Debug.Assert() to verify that the code gets + ** all alignment restrictions correct. + ** + ** Except, if SQLITE_4_BYTE_ALIGNED_MALLOC is defined, then the + ** underlying malloc() implemention might return us 4-byte aligned + ** pointers. In that case, only verify 4-byte alignment. + */ + //#if SQLITE_4_BYTE_ALIGNED_MALLOC + //# define EIGHT_BYTE_ALIGNMENT(X) ((((char)(X) - (char)0)&3)==0) + //#else + //# define EIGHT_BYTE_ALIGNMENT(X) ((((char)(X) - (char)0)&7)==0) + //#endif + + /* + ** An instance of the following structure is used to store the busy-handler + ** callback for a given sqlite handle. + ** + ** The sqlite.busyHandler member of the sqlite struct contains the busy + ** callback for the database handle. Each pager opened via the sqlite + ** handle is passed a pointer to sqlite.busyHandler. The busy-handler + ** callback is currently invoked only from within pager.c. + */ + //typedef struct BusyHandler BusyHandler; + public class BusyHandler { + public dxBusy xFunc;//)(void *,int); /* The busy callback */ + public object pArg; /* First arg to busy callback */ + public int nBusy; /* Incremented with each busy call */ + }; + + /* + ** Name of the master database table. The master database table + ** is a special table that holds the names and attributes of all + ** user tables and indices. + */ + const string MASTER_NAME = "sqlite_master";//#define MASTER_NAME "sqlite_master" + const string TEMP_MASTER_NAME = "sqlite_temp_master";//#define TEMP_MASTER_NAME "sqlite_temp_master" + + /* + ** The root-page of the master database table. + */ + const int MASTER_ROOT = 1;//#define MASTER_ROOT 1 + + /* + ** The name of the schema table. + */ + static string SCHEMA_TABLE(int x) //#define SCHEMA_TABLE(x) ((!OMIT_TEMPDB)&&(x==1)?TEMP_MASTER_NAME:MASTER_NAME) + { + return ((OMIT_TEMPDB == 0) && (x == 1) ? TEMP_MASTER_NAME : MASTER_NAME); + } - /* - ** A convenience macro that returns the number of elements in - ** an array. - */ - //#define ArraySize(X) ((int)(sizeof(X)/sizeof(X[0]))) - static int ArraySize( T[] x ) - { - return x.Length; - } + /* + ** A convenience macro that returns the number of elements in + ** an array. + */ + //#define ArraySize(X) ((int)(sizeof(X)/sizeof(X[0]))) + static int ArraySize(T[] x) { + return x.Length; + } - /* - ** The following value as a destructor means to use sqlite3DbFree(). - ** This is an internal extension to SQLITE_STATIC and SQLITE_TRANSIENT. - */ - //#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3DbFree) - static dxDel SQLITE_DYNAMIC; - - /* - ** When SQLITE_OMIT_WSD is defined, it means that the target platform does - ** not support Writable Static Data (WSD) such as global and static variables. - ** All variables must either be on the stack or dynamically allocated from - ** the heap. When WSD is unsupported, the variable declarations scattered - ** throughout the SQLite code must become constants instead. The SQLITE_WSD - ** macro is used for this purpose. And instead of referencing the variable - ** directly, we use its constant as a key to lookup the run-time allocated - ** buffer that holds real variable. The constant is also the initializer - ** for the run-time allocated buffer. - ** - ** In the usual case where WSD is supported, the SQLITE_WSD and GLOBAL - ** macros become no-ops and have zero performance impact. - */ + /* + ** The following value as a destructor means to use sqlite3DbFree(). + ** This is an internal extension to SQLITE_STATIC and SQLITE_TRANSIENT. + */ + //#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3DbFree) + static dxDel SQLITE_DYNAMIC; + + /* + ** When SQLITE_OMIT_WSD is defined, it means that the target platform does + ** not support Writable Static Data (WSD) such as global and static variables. + ** All variables must either be on the stack or dynamically allocated from + ** the heap. When WSD is unsupported, the variable declarations scattered + ** throughout the SQLite code must become constants instead. The SQLITE_WSD + ** macro is used for this purpose. And instead of referencing the variable + ** directly, we use its constant as a key to lookup the run-time allocated + ** buffer that holds real variable. The constant is also the initializer + ** for the run-time allocated buffer. + ** + ** In the usual case where WSD is supported, the SQLITE_WSD and GLOBAL + ** macros become no-ops and have zero performance impact. + */ #if SQLITE_OMIT_WSD //#define SQLITE_WSD const //#define GLOBAL(t,v) (*(t)sqlite3_wsd_find((void)&(v), sizeof(v))) @@ -710,383 +689,366 @@ static int ArraySize( T[] x ) int sqlite3_wsd_init(int N, int J); void *sqlite3_wsd_find(void *K, int L); #else - //#define SQLITE_WSD - //#define GLOBAL(t,v) v - //#define sqlite3GlobalConfig sqlite3Config - static Sqlite3Config sqlite3GlobalConfig; + //#define SQLITE_WSD + //#define GLOBAL(t,v) v + //#define sqlite3GlobalConfig sqlite3Config + static Sqlite3Config sqlite3GlobalConfig; #endif - /* -** The following macros are used to suppress compiler warnings and to -** make it clear to human readers when a function parameter is deliberately -** left unused within the body of a function. This usually happens when -** a function is called via a function pointer. For example the -** implementation of an SQL aggregate step callback may not use the -** parameter indicating the number of arguments passed to the aggregate, -** if it knows that this is enforced elsewhere. -** -** When a function parameter is not used at all within the body of a function, -** it is generally named "NotUsed" or "NotUsed2" to make things even clearer. -** However, these macros may also be used to suppress warnings related to -** parameters that may or may not be used depending on compilation options. -** For example those parameters only used in Debug.Assert() statements. In these -** cases the parameters are named as per the usual conventions. -*/ - //#define UNUSED_PARAMETER(x) (void)(x) - static void UNUSED_PARAMETER( T x ) - { - } - - //#define UNUSED_PARAMETER2(x,y) UNUSED_PARAMETER(x),UNUSED_PARAMETER(y) - static void UNUSED_PARAMETER2( T1 x, T2 y ) - { - UNUSED_PARAMETER( x ); - UNUSED_PARAMETER( y ); - } - - /* - ** Forward references to structures - */ - //typedef struct AggInfo AggInfo; - //typedef struct AuthContext AuthContext; - //typedef struct AutoincInfo AutoincInfo; - //typedef struct Bitvec Bitvec; - //typedef struct CollSeq CollSeq; - //typedef struct Column Column; - //typedef struct Db Db; - //typedef struct Schema Schema; - //typedef struct Expr Expr; - //typedef struct ExprList ExprList; - //typedef struct ExprSpan ExprSpan; - //typedef struct FKey FKey; - //typedef struct FuncDestructor FuncDestructor; - //typedef struct FuncDef FuncDef; - //typedef struct IdList IdList; - //typedef struct Index Index; - //typedef struct IndexSample IndexSample; - //typedef struct KeyClass KeyClass; - //typedef struct KeyInfo KeyInfo; - //typedef struct Lookaside Lookaside; - //typedef struct LookasideSlot LookasideSlot; - //typedef struct Module Module; - //typedef struct NameContext NameContext; - //typedef struct Parse Parse; - //typedef struct RowSet RowSet; - //typedef struct Savepoint Savepoint; - //typedef struct Select Select; - //typedef struct SrcList SrcList; - //typedef struct StrAccum StrAccum; - //typedef struct Table Table; - //typedef struct TableLock TableLock; - //typedef struct Token Token; - //typedef struct Trigger Trigger; - //typedef struct TriggerPrg TriggerPrg; - //typedef struct TriggerStep TriggerStep; - //typedef struct UnpackedRecord UnpackedRecord; - //typedef struct VTable VTable; - //typedef struct VtabCtx VtabCtx; - //typedef struct Walker Walker; - //typedef struct WherePlan WherePlan; - //typedef struct WhereInfo WhereInfo; - //typedef struct WhereLevel WhereLevel; - - /* - ** Defer sourcing vdbe.h and btree.h until after the "u8" and - ** "BusyHandler" typedefs. vdbe.h also requires a few of the opaque - ** pointer types (i.e. FuncDef) defined above. - */ - //#include "btree.h" - //#include "vdbe.h" - //#include "pager.h" - //#include "pcache_g.h" - - //#include "os.h" - //#include "mutex.h" - - /* - ** Each database file to be accessed by the system is an instance - ** of the following structure. There are normally two of these structures - ** in the sqlite.aDb[] array. aDb[0] is the main database file and - ** aDb[1] is the database file used to hold temporary tables. Additional - ** databases may be attached. - */ - public class Db - { - public string zName; /* Name of this database */ - public Btree pBt; /* The B Tree structure for this database file */ - public u8 inTrans; /* 0: not writable. 1: Transaction. 2: Checkpoint */ - public u8 safety_level; /* How aggressive at syncing data to disk */ - public Schema pSchema; /* Pointer to database schema (possibly shared) */ - }; - - /* - ** An instance of the following structure stores a database schema. + /* + ** The following macros are used to suppress compiler warnings and to + ** make it clear to human readers when a function parameter is deliberately + ** left unused within the body of a function. This usually happens when + ** a function is called via a function pointer. For example the + ** implementation of an SQL aggregate step callback may not use the + ** parameter indicating the number of arguments passed to the aggregate, + ** if it knows that this is enforced elsewhere. ** - ** Most Schema objects are associated with a Btree. The exception is - ** the Schema for the TEMP databaes (sqlite3.aDb[1]) which is free-standing. - ** In shared cache mode, a single Schema object can be shared by multiple - ** Btrees that refer to the same underlying BtShared object. - ** - ** Schema objects are automatically deallocated when the last Btree that - ** references them is destroyed. The TEMP Schema is manually freed by - ** sqlite3_close(). - * - ** A thread must be holding a mutex on the corresponding Btree in order - ** to access Schema content. This implies that the thread must also be - ** holding a mutex on the sqlite3 connection pointer that owns the Btree. - ** For a TEMP Schema, only the connection mutex is required. + ** When a function parameter is not used at all within the body of a function, + ** it is generally named "NotUsed" or "NotUsed2" to make things even clearer. + ** However, these macros may also be used to suppress warnings related to + ** parameters that may or may not be used depending on compilation options. + ** For example those parameters only used in Debug.Assert() statements. In these + ** cases the parameters are named as per the usual conventions. */ - public class Schema - { - public int schema_cookie; /* Database schema version number for this file */ - public u32 iGeneration; /* Generation counter. Incremented with each change */ - public Hash tblHash = new Hash(); /* All tables indexed by name */ - public Hash idxHash = new Hash(); /* All (named) indices indexed by name */ - public Hash trigHash = new Hash();/* All triggers indexed by name */ - public Hash fkeyHash = new Hash();/* All foreign keys by referenced table name */ - public Table pSeqTab; /* The sqlite_sequence table used by AUTOINCREMENT */ - public u8 file_format; /* Schema format version for this file */ - public u8 enc; /* Text encoding used by this database */ - public u16 flags; /* Flags associated with this schema */ - public int cache_size; /* Number of pages to use in the cache */ - public Schema Copy() - { - if ( this == null ) - return null; - else - { - Schema cp = (Schema)MemberwiseClone(); - return cp; + //#define UNUSED_PARAMETER(x) (void)(x) + static void UNUSED_PARAMETER(T x) { } - } - public void Clear() - { - if ( this != null ) - { - schema_cookie = 0; - tblHash = new Hash(); - idxHash = new Hash(); - trigHash = new Hash(); - fkeyHash = new Hash(); - pSeqTab = null; + //#define UNUSED_PARAMETER2(x,y) UNUSED_PARAMETER(x),UNUSED_PARAMETER(y) + static void UNUSED_PARAMETER2(T1 x, T2 y) { + UNUSED_PARAMETER(x); + UNUSED_PARAMETER(y); } - } - }; - /* - ** These macros can be used to test, set, or clear bits in the - ** Db.pSchema->flags field. - */ - //#define DbHasProperty(D,I,P) (((D)->aDb[I].pSchema->flags&(P))==(P)) - static bool DbHasProperty( sqlite3 D, int I, ushort P ) - { - return ( D.aDb[I].pSchema.flags & P ) == P; - } - //#define DbHasAnyProperty(D,I,P) (((D)->aDb[I].pSchema->flags&(P))!=0) - //#define DbSetProperty(D,I,P) (D)->aDb[I].pSchema->flags|=(P) - static void DbSetProperty( sqlite3 D, int I, ushort P ) - { - D.aDb[I].pSchema.flags = (u16)( D.aDb[I].pSchema.flags | P ); - } - //#define DbClearProperty(D,I,P) (D)->aDb[I].pSchema->flags&=~(P) - static void DbClearProperty( sqlite3 D, int I, ushort P ) - { - D.aDb[I].pSchema.flags = (u16)( D.aDb[I].pSchema.flags & ~P ); - } - /* - ** Allowed values for the DB.pSchema->flags field. - ** - ** The DB_SchemaLoaded flag is set after the database schema has been - ** read into internal hash tables. - ** - ** DB_UnresetViews means that one or more views have column names that - ** have been filled out. If the schema changes, these column names might - ** changes and so the view will need to be reset. - */ - //#define DB_SchemaLoaded 0x0001 /* The schema has been loaded */ - //#define DB_UnresetViews 0x0002 /* Some views have defined column names */ - //#define DB_Empty 0x0004 /* The file is empty (length 0 bytes) */ - const u16 DB_SchemaLoaded = 0x0001; - const u16 DB_UnresetViews = 0x0002; - const u16 DB_Empty = 0x0004; - - /* - ** The number of different kinds of things that can be limited - ** using the sqlite3_limit() interface. - */ - //#define SQLITE_N_LIMIT (SQLITE_LIMIT_TRIGGER_DEPTH+1) - const int SQLITE_N_LIMIT = SQLITE_LIMIT_TRIGGER_DEPTH + 1; - - /* - ** Lookaside malloc is a set of fixed-size buffers that can be used - ** to satisfy small transient memory allocation requests for objects - ** associated with a particular database connection. The use of - ** lookaside malloc provides a significant performance enhancement - ** (approx 10%) by avoiding numerous malloc/free requests while parsing - ** SQL statements. - ** - ** The Lookaside structure holds configuration information about the - ** lookaside malloc subsystem. Each available memory allocation in - ** the lookaside subsystem is stored on a linked list of LookasideSlot - ** objects. - ** - ** Lookaside allocations are only allowed for objects that are associated - ** with a particular database connection. Hence, schema information cannot - ** be stored in lookaside because in shared cache mode the schema information - ** is shared by multiple database connections. Therefore, while parsing - ** schema information, the Lookaside.bEnabled flag is cleared so that - ** lookaside allocations are not used to construct the schema objects. - */ - public class Lookaside - { - public int sz; /* Size of each buffer in bytes */ - public u8 bEnabled; /* False to disable new lookaside allocations */ - public bool bMalloced; /* True if pStart obtained from sqlite3_malloc() */ - public int nOut; /* Number of buffers currently checked out */ - public int mxOut; /* Highwater mark for nOut */ - public int[] anStat = new int[3]; /* 0: hits. 1: size misses. 2: full misses */ - public LookasideSlot pFree; /* List of available buffers */ - public int pStart; /* First byte of available memory space */ - public int pEnd; /* First byte past end of available space */ - }; - public class LookasideSlot - { - public LookasideSlot pNext; /* Next buffer in the list of free buffers */ - }; - - /* - ** A hash table for function definitions. - ** - ** Hash each FuncDef structure into one of the FuncDefHash.a[] slots. - ** Collisions are on the FuncDef.pHash chain. - */ - public class FuncDefHash - { - public FuncDef[] a = new FuncDef[23]; /* Hash table for functions */ - }; - - /* - ** Each database connection is an instance of the following structure. - ** - ** The sqlite.lastRowid records the last insert rowid generated by an - ** insert statement. Inserts on views do not affect its value. Each - ** trigger has its own context, so that lastRowid can be updated inside - ** triggers as usual. The previous value will be restored once the trigger - ** exits. Upon entering a before or instead of trigger, lastRowid is no - ** longer (since after version 2.8.12) reset to -1. - ** - ** The sqlite.nChange does not count changes within triggers and keeps no - ** context. It is reset at start of sqlite3_exec. - ** The sqlite.lsChange represents the number of changes made by the last - ** insert, update, or delete statement. It remains constant throughout the - ** length of a statement and is then updated by OP_SetCounts. It keeps a - ** context stack just like lastRowid so that the count of changes - ** within a trigger is not seen outside the trigger. Changes to views do not - ** affect the value of lsChange. - ** The sqlite.csChange keeps track of the number of current changes (since - ** the last statement) and is used to update sqlite_lsChange. - ** - ** The member variables sqlite.errCode, sqlite.zErrMsg and sqlite.zErrMsg16 - ** store the most recent error code and, if applicable, string. The - ** internal function sqlite3Error() is used to set these variables - ** consistently. - */ - public class sqlite3 - { - public sqlite3_vfs pVfs; /* OS Interface */ - public int nDb; /* Number of backends currently in use */ - public Db[] aDb = new Db[SQLITE_MAX_ATTACHED]; /* All backends */ - public int flags; /* Miscellaneous flags. See below */ - public int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */ - public int errCode; /* Most recent error code (SQLITE_) */ - public int errMask; /* & result codes with this before returning */ - public u8 autoCommit; /* The auto-commit flag. */ - public u8 temp_store; /* 1: file 2: memory 0: default */ - // Cannot happen under C# - // public u8 mallocFailed; /* True if we have seen a malloc failure */ - public u8 dfltLockMode; /* Default locking-mode for attached dbs */ - public int nextAutovac; /* Autovac setting after VACUUM if >=0 */ - public u8 suppressErr; /* Do not issue error messages if true */ - public u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */ - public int nextPagesize; /* Pagesize after VACUUM if >0 */ - public int nTable; /* Number of tables in the database */ - public CollSeq pDfltColl; /* The default collating sequence (BINARY) */ - public i64 lastRowid; /* ROWID of most recent insert (see above) */ - public u32 magic; /* Magic number for detect library misuse */ - public int nChange; /* Value returned by sqlite3_changes() */ - public int nTotalChange; /* Value returned by sqlite3_total_changes() */ - public sqlite3_mutex mutex; /* Connection mutex */ - public int[] aLimit = new int[SQLITE_N_LIMIT]; /* Limits */ - public class sqlite3InitInfo - { /* Information used during initialization */ - public int iDb; /* When back is being initialized */ - public int newTnum; /* Rootpage of table being initialized */ - public u8 busy; /* TRUE if currently initializing */ - public u8 orphanTrigger; /* Last statement is orphaned TEMP trigger */ - }; - public sqlite3InitInfo init = new sqlite3InitInfo(); - public int nExtension; /* Number of loaded extensions */ - public object[] aExtension; /* Array of shared library handles */ - public Vdbe pVdbe; /* List of active virtual machines */ - public int activeVdbeCnt; /* Number of VDBEs currently executing */ - public int writeVdbeCnt; /* Number of active VDBEs that are writing */ - public int vdbeExecCnt; /* Number of nested calls to VdbeExec() */ - public dxTrace xTrace;//)(void*,const char); /* Trace function */ - public object pTraceArg; /* Argument to the trace function */ - public dxProfile xProfile;//)(void*,const char*,u64); /* Profiling function */ - public object pProfileArg; /* Argument to profile function */ - public object pCommitArg; /* Argument to xCommitCallback() */ - public dxCommitCallback xCommitCallback;//)(void); /* Invoked at every commit. */ - public object pRollbackArg; /* Argument to xRollbackCallback() */ - public dxRollbackCallback xRollbackCallback;//)(void); /* Invoked at every commit. */ - public object pUpdateArg; - public dxUpdateCallback xUpdateCallback;//)(void*,int, const char*,const char*,sqlite_int64); + /* + ** Forward references to structures + */ + //typedef struct AggInfo AggInfo; + //typedef struct AuthContext AuthContext; + //typedef struct AutoincInfo AutoincInfo; + //typedef struct Bitvec Bitvec; + //typedef struct CollSeq CollSeq; + //typedef struct Column Column; + //typedef struct Db Db; + //typedef struct Schema Schema; + //typedef struct Expr Expr; + //typedef struct ExprList ExprList; + //typedef struct ExprSpan ExprSpan; + //typedef struct FKey FKey; + //typedef struct FuncDestructor FuncDestructor; + //typedef struct FuncDef FuncDef; + //typedef struct IdList IdList; + //typedef struct Index Index; + //typedef struct IndexSample IndexSample; + //typedef struct KeyClass KeyClass; + //typedef struct KeyInfo KeyInfo; + //typedef struct Lookaside Lookaside; + //typedef struct LookasideSlot LookasideSlot; + //typedef struct Module Module; + //typedef struct NameContext NameContext; + //typedef struct Parse Parse; + //typedef struct RowSet RowSet; + //typedef struct Savepoint Savepoint; + //typedef struct Select Select; + //typedef struct SrcList SrcList; + //typedef struct StrAccum StrAccum; + //typedef struct Table Table; + //typedef struct TableLock TableLock; + //typedef struct Token Token; + //typedef struct Trigger Trigger; + //typedef struct TriggerPrg TriggerPrg; + //typedef struct TriggerStep TriggerStep; + //typedef struct UnpackedRecord UnpackedRecord; + //typedef struct VTable VTable; + //typedef struct VtabCtx VtabCtx; + //typedef struct Walker Walker; + //typedef struct WherePlan WherePlan; + //typedef struct WhereInfo WhereInfo; + //typedef struct WhereLevel WhereLevel; + + /* + ** Defer sourcing vdbe.h and btree.h until after the "u8" and + ** "BusyHandler" typedefs. vdbe.h also requires a few of the opaque + ** pointer types (i.e. FuncDef) defined above. + */ + //#include "btree.h" + //#include "vdbe.h" + //#include "pager.h" + //#include "pcache_g.h" + + //#include "os.h" + //#include "mutex.h" + + /* + ** Each database file to be accessed by the system is an instance + ** of the following structure. There are normally two of these structures + ** in the sqlite.aDb[] array. aDb[0] is the main database file and + ** aDb[1] is the database file used to hold temporary tables. Additional + ** databases may be attached. + */ + public class Db { + public string zName; /* Name of this database */ + public Btree pBt; /* The B Tree structure for this database file */ + public u8 inTrans; /* 0: not writable. 1: Transaction. 2: Checkpoint */ + public u8 safety_level; /* How aggressive at syncing data to disk */ + public Schema pSchema; /* Pointer to database schema (possibly shared) */ + }; + + /* + ** An instance of the following structure stores a database schema. + ** + ** Most Schema objects are associated with a Btree. The exception is + ** the Schema for the TEMP databaes (sqlite3.aDb[1]) which is free-standing. + ** In shared cache mode, a single Schema object can be shared by multiple + ** Btrees that refer to the same underlying BtShared object. + ** + ** Schema objects are automatically deallocated when the last Btree that + ** references them is destroyed. The TEMP Schema is manually freed by + ** sqlite3_close(). + * + ** A thread must be holding a mutex on the corresponding Btree in order + ** to access Schema content. This implies that the thread must also be + ** holding a mutex on the sqlite3 connection pointer that owns the Btree. + ** For a TEMP Schema, only the connection mutex is required. + */ + public class Schema { + public int schema_cookie; /* Database schema version number for this file */ + public u32 iGeneration; /* Generation counter. Incremented with each change */ + public Hash tblHash = new Hash(); /* All tables indexed by name */ + public Hash idxHash = new Hash(); /* All (named) indices indexed by name */ + public Hash trigHash = new Hash();/* All triggers indexed by name */ + public Hash fkeyHash = new Hash();/* All foreign keys by referenced table name */ + public Table pSeqTab; /* The sqlite_sequence table used by AUTOINCREMENT */ + public u8 file_format; /* Schema format version for this file */ + public u8 enc; /* Text encoding used by this database */ + public u16 flags; /* Flags associated with this schema */ + public int cache_size; /* Number of pages to use in the cache */ + public Schema Copy() { + if (this == null) + return null; + else { + Schema cp = (Schema)MemberwiseClone(); + return cp; + } + } + + public void Clear() { + if (this != null) { + schema_cookie = 0; + tblHash = new Hash(); + idxHash = new Hash(); + trigHash = new Hash(); + fkeyHash = new Hash(); + pSeqTab = null; + } + } + }; + + /* + ** These macros can be used to test, set, or clear bits in the + ** Db.pSchema->flags field. + */ + //#define DbHasProperty(D,I,P) (((D)->aDb[I].pSchema->flags&(P))==(P)) + static bool DbHasProperty(sqlite3 D, int I, ushort P) { + return (D.aDb[I].pSchema.flags & P) == P; + } + //#define DbHasAnyProperty(D,I,P) (((D)->aDb[I].pSchema->flags&(P))!=0) + //#define DbSetProperty(D,I,P) (D)->aDb[I].pSchema->flags|=(P) + static void DbSetProperty(sqlite3 D, int I, ushort P) { + D.aDb[I].pSchema.flags = (u16)(D.aDb[I].pSchema.flags | P); + } + //#define DbClearProperty(D,I,P) (D)->aDb[I].pSchema->flags&=~(P) + static void DbClearProperty(sqlite3 D, int I, ushort P) { + D.aDb[I].pSchema.flags = (u16)(D.aDb[I].pSchema.flags & ~P); + } + /* + ** Allowed values for the DB.pSchema->flags field. + ** + ** The DB_SchemaLoaded flag is set after the database schema has been + ** read into internal hash tables. + ** + ** DB_UnresetViews means that one or more views have column names that + ** have been filled out. If the schema changes, these column names might + ** changes and so the view will need to be reset. + */ + //#define DB_SchemaLoaded 0x0001 /* The schema has been loaded */ + //#define DB_UnresetViews 0x0002 /* Some views have defined column names */ + //#define DB_Empty 0x0004 /* The file is empty (length 0 bytes) */ + const u16 DB_SchemaLoaded = 0x0001; + const u16 DB_UnresetViews = 0x0002; + const u16 DB_Empty = 0x0004; + + /* + ** The number of different kinds of things that can be limited + ** using the sqlite3_limit() interface. + */ + //#define SQLITE_N_LIMIT (SQLITE_LIMIT_TRIGGER_DEPTH+1) + const int SQLITE_N_LIMIT = SQLITE_LIMIT_TRIGGER_DEPTH + 1; + + /* + ** Lookaside malloc is a set of fixed-size buffers that can be used + ** to satisfy small transient memory allocation requests for objects + ** associated with a particular database connection. The use of + ** lookaside malloc provides a significant performance enhancement + ** (approx 10%) by avoiding numerous malloc/free requests while parsing + ** SQL statements. + ** + ** The Lookaside structure holds configuration information about the + ** lookaside malloc subsystem. Each available memory allocation in + ** the lookaside subsystem is stored on a linked list of LookasideSlot + ** objects. + ** + ** Lookaside allocations are only allowed for objects that are associated + ** with a particular database connection. Hence, schema information cannot + ** be stored in lookaside because in shared cache mode the schema information + ** is shared by multiple database connections. Therefore, while parsing + ** schema information, the Lookaside.bEnabled flag is cleared so that + ** lookaside allocations are not used to construct the schema objects. + */ + public class Lookaside { + public int sz; /* Size of each buffer in bytes */ + public u8 bEnabled; /* False to disable new lookaside allocations */ + public bool bMalloced; /* True if pStart obtained from sqlite3_malloc() */ + public int nOut; /* Number of buffers currently checked out */ + public int mxOut; /* Highwater mark for nOut */ + public int[] anStat = new int[3]; /* 0: hits. 1: size misses. 2: full misses */ + public LookasideSlot pFree; /* List of available buffers */ + public int pStart; /* First byte of available memory space */ + public int pEnd; /* First byte past end of available space */ + }; + public class LookasideSlot { + public LookasideSlot pNext; /* Next buffer in the list of free buffers */ + }; + + /* + ** A hash table for function definitions. + ** + ** Hash each FuncDef structure into one of the FuncDefHash.a[] slots. + ** Collisions are on the FuncDef.pHash chain. + */ + public class FuncDefHash { + public FuncDef[] a = new FuncDef[23]; /* Hash table for functions */ + }; + + /* + ** Each database connection is an instance of the following structure. + ** + ** The sqlite.lastRowid records the last insert rowid generated by an + ** insert statement. Inserts on views do not affect its value. Each + ** trigger has its own context, so that lastRowid can be updated inside + ** triggers as usual. The previous value will be restored once the trigger + ** exits. Upon entering a before or instead of trigger, lastRowid is no + ** longer (since after version 2.8.12) reset to -1. + ** + ** The sqlite.nChange does not count changes within triggers and keeps no + ** context. It is reset at start of sqlite3_exec. + ** The sqlite.lsChange represents the number of changes made by the last + ** insert, update, or delete statement. It remains constant throughout the + ** length of a statement and is then updated by OP_SetCounts. It keeps a + ** context stack just like lastRowid so that the count of changes + ** within a trigger is not seen outside the trigger. Changes to views do not + ** affect the value of lsChange. + ** The sqlite.csChange keeps track of the number of current changes (since + ** the last statement) and is used to update sqlite_lsChange. + ** + ** The member variables sqlite.errCode, sqlite.zErrMsg and sqlite.zErrMsg16 + ** store the most recent error code and, if applicable, string. The + ** internal function sqlite3Error() is used to set these variables + ** consistently. + */ + public class sqlite3 { + public sqlite3_vfs pVfs; /* OS Interface */ + public int nDb; /* Number of backends currently in use */ + public Db[] aDb = new Db[SQLITE_MAX_ATTACHED]; /* All backends */ + public int flags; /* Miscellaneous flags. See below */ + public int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */ + public int errCode; /* Most recent error code (SQLITE_) */ + public int errMask; /* & result codes with this before returning */ + public u8 autoCommit; /* The auto-commit flag. */ + public u8 temp_store; /* 1: file 2: memory 0: default */ + // Cannot happen under C# + // public u8 mallocFailed; /* True if we have seen a malloc failure */ + public u8 dfltLockMode; /* Default locking-mode for attached dbs */ + public int nextAutovac; /* Autovac setting after VACUUM if >=0 */ + public u8 suppressErr; /* Do not issue error messages if true */ + public u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */ + public int nextPagesize; /* Pagesize after VACUUM if >0 */ + public int nTable; /* Number of tables in the database */ + public CollSeq pDfltColl; /* The default collating sequence (BINARY) */ + public i64 lastRowid; /* ROWID of most recent insert (see above) */ + public u32 magic; /* Magic number for detect library misuse */ + public int nChange; /* Value returned by sqlite3_changes() */ + public int nTotalChange; /* Value returned by sqlite3_total_changes() */ + public sqlite3_mutex mutex; /* Connection mutex */ + public int[] aLimit = new int[SQLITE_N_LIMIT]; /* Limits */ + public class sqlite3InitInfo { /* Information used during initialization */ + public int iDb; /* When back is being initialized */ + public int newTnum; /* Rootpage of table being initialized */ + public u8 busy; /* TRUE if currently initializing */ + public u8 orphanTrigger; /* Last statement is orphaned TEMP trigger */ + }; + public sqlite3InitInfo init = new sqlite3InitInfo(); + public int nExtension; /* Number of loaded extensions */ + public object[] aExtension; /* Array of shared library handles */ + public Vdbe pVdbe; /* List of active virtual machines */ + public int activeVdbeCnt; /* Number of VDBEs currently executing */ + public int writeVdbeCnt; /* Number of active VDBEs that are writing */ + public int vdbeExecCnt; /* Number of nested calls to VdbeExec() */ + public dxTrace xTrace;//)(void*,const char); /* Trace function */ + public object pTraceArg; /* Argument to the trace function */ + public dxProfile xProfile;//)(void*,const char*,u64); /* Profiling function */ + public object pProfileArg; /* Argument to profile function */ + public object pCommitArg; /* Argument to xCommitCallback() */ + public dxCommitCallback xCommitCallback;//)(void); /* Invoked at every commit. */ + public object pRollbackArg; /* Argument to xRollbackCallback() */ + public dxRollbackCallback xRollbackCallback;//)(void); /* Invoked at every commit. */ + public object pUpdateArg; + public dxUpdateCallback xUpdateCallback;//)(void*,int, const char*,const char*,sqlite_int64); #if !SQLITE_OMIT_WAL //int (*xWalCallback)(void *, sqlite3 *, string , int); //void *pWalArg; #endif - public dxCollNeeded xCollNeeded;//)(void*,sqlite3*,int eTextRep,const char); - public dxCollNeeded xCollNeeded16;//)(void*,sqlite3*,int eTextRep,const void); - public object pCollNeededArg; - public sqlite3_value pErr; /* Most recent error message */ - public string zErrMsg; /* Most recent error message (UTF-8 encoded) */ - public string zErrMsg16; /* Most recent error message (UTF-16 encoded) */ - public struct _u1 - { - public bool isInterrupted; /* True if sqlite3_interrupt has been called */ - public double notUsed1; /* Spacer */ - } - public _u1 u1; - public Lookaside lookaside = new Lookaside(); /* Lookaside malloc configuration */ + public dxCollNeeded xCollNeeded;//)(void*,sqlite3*,int eTextRep,const char); + public dxCollNeeded xCollNeeded16;//)(void*,sqlite3*,int eTextRep,const void); + public object pCollNeededArg; + public sqlite3_value pErr; /* Most recent error message */ + public string zErrMsg; /* Most recent error message (UTF-8 encoded) */ + public string zErrMsg16; /* Most recent error message (UTF-16 encoded) */ + public struct _u1 { + public bool isInterrupted; /* True if sqlite3_interrupt has been called */ + public double notUsed1; /* Spacer */ + } + public _u1 u1; + public Lookaside lookaside = new Lookaside(); /* Lookaside malloc configuration */ #if !SQLITE_OMIT_AUTHORIZATION public dxAuth xAuth;//)(void*,int,const char*,const char*,const char*,const char); /* Access authorization function */ public object pAuthArg; /* 1st argument to the access auth function */ #endif #if !SQLITE_OMIT_PROGRESS_CALLBACK - public dxProgress xProgress;//)(void ); /* The progress callback */ - public object pProgressArg; /* Argument to the progress callback */ - public int nProgressOps; /* Number of opcodes for progress callback */ + public dxProgress xProgress;//)(void ); /* The progress callback */ + public object pProgressArg; /* Argument to the progress callback */ + public int nProgressOps; /* Number of opcodes for progress callback */ #endif #if !SQLITE_OMIT_VIRTUALTABLE - public Hash aModule; /* populated by sqlite3_create_module() */ - public VtabCtx pVtabCtx; /* Context for active vtab connect/create */ - public VTable[] aVTrans; /* Virtual tables with open transactions */ - public int nVTrans; /* Allocated size of aVTrans */ - public VTable pDisconnect; /* Disconnect these in next sqlite3_prepare() */ + public Hash aModule; /* populated by sqlite3_create_module() */ + public VtabCtx pVtabCtx; /* Context for active vtab connect/create */ + public VTable[] aVTrans; /* Virtual tables with open transactions */ + public int nVTrans; /* Allocated size of aVTrans */ + public VTable pDisconnect; /* Disconnect these in next sqlite3_prepare() */ #endif - public FuncDefHash aFunc = new FuncDefHash(); /* Hash table of connection functions */ - public Hash aCollSeq = new Hash(); /* All collating sequences */ - public BusyHandler busyHandler = new BusyHandler(); /* Busy callback */ - public int busyTimeout; /* Busy handler timeout, in msec */ - public Db[] aDbStatic = new Db[] { new Db(), new Db() }; /* Static space for the 2 default backends */ - public Savepoint pSavepoint; /* List of active savepoints */ - public int nSavepoint; /* Number of non-transaction savepoints */ - public int nStatement; /* Number of nested statement-transactions */ - public u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */ - public i64 nDeferredCons; /* Net deferred constraints this transaction. */ - public int pnBytesFreed; /* If not NULL, increment this in DbFree() */ + public FuncDefHash aFunc = new FuncDefHash(); /* Hash table of connection functions */ + public Hash aCollSeq = new Hash(); /* All collating sequences */ + public BusyHandler busyHandler = new BusyHandler(); /* Busy callback */ + public int busyTimeout; /* Busy handler timeout, in msec */ + public Db[] aDbStatic = new Db[] { new Db(), new Db() }; /* Static space for the 2 default backends */ + public Savepoint pSavepoint; /* List of active savepoints */ + public int nSavepoint; /* Number of non-transaction savepoints */ + public int nStatement; /* Number of nested statement-transactions */ + public u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */ + public i64 nDeferredCons; /* Net deferred constraints this transaction. */ + public int pnBytesFreed; /* If not NULL, increment this in DbFree() */ #if SQLITE_ENABLE_UNLOCK_NOTIFY /* The following variables are all protected by the STATIC_MASTER ** mutex, not by sqlite3.mutex. They are used by code in notify.c. @@ -1104,633 +1066,608 @@ public struct _u1 void (*xUnlockNotify)(void **, int); /* Unlock notify callback */ sqlite3 *pNextBlocked; /* Next in list of all blocked connections */ #endif - }; - - /* - ** A macro to discover the encoding of a database. - */ - //#define ENC(db) ((db)->aDb[0].pSchema->enc) - static u8 ENC( sqlite3 db ) - { - return db.aDb[0].pSchema.enc; - } - - /* - ** Possible values for the sqlite3.flags. - */ - //#define SQLITE_VdbeTrace 0x00000100 /* True to trace VDBE execution */ - //#define SQLITE_InternChanges 0x00000200 /* Uncommitted Hash table changes */ - //#define SQLITE_FullColNames 0x00000400 /* Show full column names on SELECT */ - //#define SQLITE_ShortColNames 0x00000800 /* Show short columns names */ - //#define SQLITE_CountRows 0x00001000 /* Count rows changed by INSERT, */ - // /* DELETE, or UPDATE and return */ - // /* the count using a callback. */ - //#define SQLITE_NullCallback 0x00002000 /* Invoke the callback once if the */ - // /* result set is empty */ - //#define SQLITE_SqlTrace 0x00004000 /* Debug print SQL as it executes */ - //#define SQLITE_VdbeListing 0x00008000 /* Debug listings of VDBE programs */ - //#define SQLITE_WriteSchema 0x00010000 /* OK to update SQLITE_MASTER */ - //#define SQLITE_NoReadlock 0x00020000 /* Readlocks are omitted when - // ** accessing read-only databases */ - //#define SQLITE_IgnoreChecks 0x00040000 /* Do not enforce check constraints */ - //#define SQLITE_ReadUncommitted 0x0080000 /* For shared-cache mode */ - //#define SQLITE_LegacyFileFmt 0x00100000 /* Create new databases in format 1 */ - //#define SQLITE_FullFSync 0x00200000 /* Use full fsync on the backend */ - //#define SQLITE_CkptFullFSync 0x00400000 /* Use full fsync for checkpoint */ - //#define SQLITE_RecoveryMode 0x00800000 /* Ignore schema errors */ - //#define SQLITE_ReverseOrder 0x01000000 /* Reverse unordered SELECTs */ - //#define SQLITE_RecTriggers 0x02000000 /* Enable recursive triggers */ - //#define SQLITE_ForeignKeys 0x04000000 /* Enforce foreign key constraints */ - //#define SQLITE_AutoIndex 0x08000000 /* Enable automatic indexes */ - //#define SQLITE_PreferBuiltin 0x10000000 /* Preference to built-in funcs */ - //#define SQLITE_LoadExtension 0x20000000 /* Enable load_extension */ - //define SQLITE_EnableTrigger 0x40000000 /* True to enable triggers */ - const int SQLITE_VdbeTrace = 0x00000100; - const int SQLITE_InternChanges = 0x00000200; - const int SQLITE_FullColNames = 0x00000400; - const int SQLITE_ShortColNames = 0x00000800; - const int SQLITE_CountRows = 0x00001000; - const int SQLITE_NullCallback = 0x00002000; - const int SQLITE_SqlTrace = 0x00004000; - const int SQLITE_VdbeListing = 0x00008000; - const int SQLITE_WriteSchema = 0x00010000; - const int SQLITE_NoReadlock = 0x00020000; - const int SQLITE_IgnoreChecks = 0x00040000; - const int SQLITE_ReadUncommitted = 0x0080000; - const int SQLITE_LegacyFileFmt = 0x00100000; - const int SQLITE_FullFSync = 0x00200000; - const int SQLITE_CkptFullFSync = 0x00400000; - const int SQLITE_RecoveryMode = 0x00800000; - const int SQLITE_ReverseOrder = 0x01000000; - const int SQLITE_RecTriggers = 0x02000000; - const int SQLITE_ForeignKeys = 0x04000000; - const int SQLITE_AutoIndex = 0x08000000; - const int SQLITE_PreferBuiltin = 0x10000000; - const int SQLITE_LoadExtension = 0x20000000; - const int SQLITE_EnableTrigger = 0x40000000; - - /* - ** Bits of the sqlite3.flags field that are used by the - ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface. - ** These must be the low-order bits of the flags field. - */ - //#define SQLITE_QueryFlattener 0x01 /* Disable query flattening */ - //#define SQLITE_ColumnCache 0x02 /* Disable the column cache */ - //#define SQLITE_IndexSort 0x04 /* Disable indexes for sorting */ - //#define SQLITE_IndexSearch 0x08 /* Disable indexes for searching */ - //#define SQLITE_IndexCover 0x10 /* Disable index covering table */ - //#define SQLITE_GroupByOrder 0x20 /* Disable GROUPBY cover of ORDERBY */ - //#define SQLITE_FactorOutConst 0x40 /* Disable factoring out constants */ - //#define SQLITE_IdxRealAsInt 0x80 /* Store REAL as INT in indices */ - //#define SQLITE_OptMask 0xff /* Mask of all disablable opts */ - const int SQLITE_QueryFlattener = 0x01; - const int SQLITE_ColumnCache = 0x02; - const int SQLITE_IndexSort = 0x04; - const int SQLITE_IndexSearch = 0x08; - const int SQLITE_IndexCover = 0x10; - const int SQLITE_GroupByOrder = 0x20; - const int SQLITE_FactorOutConst = 0x40; - const int SQLITE_IdxRealAsInt = 0x80; - const int SQLITE_OptMask = 0xff; - - /* - ** Possible values for the sqlite.magic field. - ** The numbers are obtained at random and have no special meaning, other - ** than being distinct from one another. - */ - const int SQLITE_MAGIC_OPEN = 0x1029a697; //#define SQLITE_MAGIC_OPEN 0xa029a697 /* Database is open */ - const int SQLITE_MAGIC_CLOSED = 0x2f3c2d33; //#define SQLITE_MAGIC_CLOSED 0x9f3c2d33 /* Database is closed */ - const int SQLITE_MAGIC_SICK = 0x3b771290; //#define SQLITE_MAGIC_SICK 0x4b771290 /* Error and awaiting close */ - const int SQLITE_MAGIC_BUSY = 0x403b7906; //#define SQLITE_MAGIC_BUSY 0xf03b7906 /* Database currently in use */ - const int SQLITE_MAGIC_ERROR = 0x55357930; //#define SQLITE_MAGIC_ERROR 0xb5357930 /* An SQLITE_MISUSE error occurred */ - - /* - ** Each SQL function is defined by an instance of the following - ** structure. A pointer to this structure is stored in the sqlite.aFunc - ** hash table. When multiple functions have the same name, the hash table - ** points to a linked list of these structures. - */ - public class FuncDef - { - public i16 nArg; /* Number of arguments. -1 means unlimited */ - public u8 iPrefEnc; /* Preferred text encoding (SQLITE_UTF8, 16LE, 16BE) */ - public u8 flags; /* Some combination of SQLITE_FUNC_* */ - public object pUserData; /* User data parameter */ - public FuncDef pNext; /* Next function with same name */ - public dxFunc xFunc;//)(sqlite3_context*,int,sqlite3_value*); /* Regular function */ - public dxStep xStep;//)(sqlite3_context*,int,sqlite3_value*); /* Aggregate step */ - public dxFinal xFinalize;//)(sqlite3_context); /* Aggregate finalizer */ - public string zName; /* SQL name of the function. */ - public FuncDef pHash; /* Next with a different name but the same hash */ - public FuncDestructor pDestructor; /* Reference counted destructor function */ - - public FuncDef() - { - } - - public FuncDef( i16 nArg, u8 iPrefEnc, u8 iflags, object pUserData, FuncDef pNext, dxFunc xFunc, dxStep xStep, dxFinal xFinalize, string zName, FuncDef pHash, FuncDestructor pDestructor ) - { - this.nArg = nArg; - this.iPrefEnc = iPrefEnc; - this.flags = iflags; - this.pUserData = pUserData; - this.pNext = pNext; - this.xFunc = xFunc; - this.xStep = xStep; - this.xFinalize = xFinalize; - this.zName = zName; - this.pHash = pHash; - this.pDestructor = pDestructor; - } - public FuncDef( string zName, u8 iPrefEnc, i16 nArg, int iArg, u8 iflags, dxFunc xFunc ) - { - this.nArg = nArg; - this.iPrefEnc = iPrefEnc; - this.flags = iflags; - this.pUserData = iArg; - this.pNext = null; - this.xFunc = xFunc; - this.xStep = null; - this.xFinalize = null; - this.zName = zName; - } - - public FuncDef( string zName, u8 iPrefEnc, i16 nArg, int iArg, u8 iflags, dxStep xStep, dxFinal xFinal ) - { - this.nArg = nArg; - this.iPrefEnc = iPrefEnc; - this.flags = iflags; - this.pUserData = iArg; - this.pNext = null; - this.xFunc = null; - this.xStep = xStep; - this.xFinalize = xFinal; - this.zName = zName; - } - - public FuncDef( string zName, u8 iPrefEnc, i16 nArg, object arg, dxFunc xFunc, u8 flags ) - { - this.nArg = nArg; - this.iPrefEnc = iPrefEnc; - this.flags = flags; - this.pUserData = arg; - this.pNext = null; - this.xFunc = xFunc; - this.xStep = null; - this.xFinalize = null; - this.zName = zName; - } - - public FuncDef Copy() - { - FuncDef c = new FuncDef(); - c.nArg = nArg; - c.iPrefEnc = iPrefEnc; - c.flags = flags; - c.pUserData = pUserData; - c.pNext = pNext; - c.xFunc = xFunc; - c.xStep = xStep; - c.xFinalize = xFinalize; - c.zName = zName; - c.pHash = pHash; - c.pDestructor = pDestructor; - return c; - } - }; - - /* - ** This structure encapsulates a user-function destructor callback (as - ** configured using create_function_v2()) and a reference counter. When - ** create_function_v2() is called to create a function with a destructor, - ** a single object of this type is allocated. FuncDestructor.nRef is set to - ** the number of FuncDef objects created (either 1 or 3, depending on whether - ** or not the specified encoding is SQLITE_ANY). The FuncDef.pDestructor - ** member of each of the new FuncDef objects is set to point to the allocated - ** FuncDestructor. - ** - ** Thereafter, when one of the FuncDef objects is deleted, the reference - ** count on this object is decremented. When it reaches 0, the destructor - ** is invoked and the FuncDestructor structure freed. - */ - //struct FuncDestructor { - // int nRef; - // void (*xDestroy)(void ); - // void *pUserData; - //}; - public class FuncDestructor - { - public int nRef; - public dxFDestroy xDestroy;// (*xDestroy)(void ); - public object pUserData; - }; - - - /* - ** Possible values for FuncDef.flags - */ - //#define SQLITE_FUNC_LIKE 0x01 /* Candidate for the LIKE optimization */ - //#define SQLITE_FUNC_CASE 0x02 /* Case-sensitive LIKE-type function */ - //#define SQLITE_FUNC_EPHEM 0x04 /* Ephemeral. Delete with VDBE */ - //#define SQLITE_FUNC_NEEDCOLL 0x08 /* sqlite3GetFuncCollSeq() might be called */ - //#define SQLITE_FUNC_PRIVATE 0x10 /* Allowed for internal use only */ - //#define SQLITE_FUNC_COUNT 0x20 /* Built-in count() aggregate */ - //#define SQLITE_FUNC_COALESCE 0x40 /* Built-in coalesce() or ifnull() function */ - const int SQLITE_FUNC_LIKE = 0x01; /* Candidate for the LIKE optimization */ - const int SQLITE_FUNC_CASE = 0x02; /* Case-sensitive LIKE-type function */ - const int SQLITE_FUNC_EPHEM = 0x04; /* Ephermeral. Delete with VDBE */ - const int SQLITE_FUNC_NEEDCOLL = 0x08;/* sqlite3GetFuncCollSeq() might be called */ - const int SQLITE_FUNC_PRIVATE = 0x10; /* Allowed for internal use only */ - const int SQLITE_FUNC_COUNT = 0x20; /* Built-in count() aggregate */ - const int SQLITE_FUNC_COALESCE = 0x40;/* Built-in coalesce() or ifnull() function */ - - - /* - ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are - ** used to create the initializers for the FuncDef structures. - ** - ** FUNCTION(zName, nArg, iArg, bNC, xFunc) - ** Used to create a scalar function definition of a function zName - ** implemented by C function xFunc that accepts nArg arguments. The - ** value passed as iArg is cast to a (void) and made available - ** as the user-data (sqlite3_user_data()) for the function. If - ** argument bNC is true, then the SQLITE_FUNC_NEEDCOLL flag is set. - ** - ** AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal) - ** Used to create an aggregate function definition implemented by - ** the C functions xStep and xFinal. The first four parameters - ** are interpreted in the same way as the first 4 parameters to - ** FUNCTION(). - ** - ** LIKEFUNC(zName, nArg, pArg, flags) - ** Used to create a scalar function definition of a function zName - ** that accepts nArg arguments and is implemented by a call to C - ** function likeFunc. Argument pArg is cast to a (void ) and made - ** available as the function user-data (sqlite3_user_data()). The - ** FuncDef.flags variable is set to the value passed as the flags - ** parameter. - */ - //#define FUNCTION(zName, nArg, iArg, bNC, xFunc) \ - // {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \ - //SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} + }; + + /* + ** A macro to discover the encoding of a database. + */ + //#define ENC(db) ((db)->aDb[0].pSchema->enc) + static u8 ENC(sqlite3 db) { + return db.aDb[0].pSchema.enc; + } - static FuncDef FUNCTION( string zName, i16 nArg, int iArg, u8 bNC, dxFunc xFunc ) - { - return new FuncDef( zName, SQLITE_UTF8, nArg, iArg, (u8)( bNC * SQLITE_FUNC_NEEDCOLL ), xFunc ); - } + /* + ** Possible values for the sqlite3.flags. + */ + //#define SQLITE_VdbeTrace 0x00000100 /* True to trace VDBE execution */ + //#define SQLITE_InternChanges 0x00000200 /* Uncommitted Hash table changes */ + //#define SQLITE_FullColNames 0x00000400 /* Show full column names on SELECT */ + //#define SQLITE_ShortColNames 0x00000800 /* Show short columns names */ + //#define SQLITE_CountRows 0x00001000 /* Count rows changed by INSERT, */ + // /* DELETE, or UPDATE and return */ + // /* the count using a callback. */ + //#define SQLITE_NullCallback 0x00002000 /* Invoke the callback once if the */ + // /* result set is empty */ + //#define SQLITE_SqlTrace 0x00004000 /* Debug print SQL as it executes */ + //#define SQLITE_VdbeListing 0x00008000 /* Debug listings of VDBE programs */ + //#define SQLITE_WriteSchema 0x00010000 /* OK to update SQLITE_MASTER */ + //#define SQLITE_NoReadlock 0x00020000 /* Readlocks are omitted when + // ** accessing read-only databases */ + //#define SQLITE_IgnoreChecks 0x00040000 /* Do not enforce check constraints */ + //#define SQLITE_ReadUncommitted 0x0080000 /* For shared-cache mode */ + //#define SQLITE_LegacyFileFmt 0x00100000 /* Create new databases in format 1 */ + //#define SQLITE_FullFSync 0x00200000 /* Use full fsync on the backend */ + //#define SQLITE_CkptFullFSync 0x00400000 /* Use full fsync for checkpoint */ + //#define SQLITE_RecoveryMode 0x00800000 /* Ignore schema errors */ + //#define SQLITE_ReverseOrder 0x01000000 /* Reverse unordered SELECTs */ + //#define SQLITE_RecTriggers 0x02000000 /* Enable recursive triggers */ + //#define SQLITE_ForeignKeys 0x04000000 /* Enforce foreign key constraints */ + //#define SQLITE_AutoIndex 0x08000000 /* Enable automatic indexes */ + //#define SQLITE_PreferBuiltin 0x10000000 /* Preference to built-in funcs */ + //#define SQLITE_LoadExtension 0x20000000 /* Enable load_extension */ + //define SQLITE_EnableTrigger 0x40000000 /* True to enable triggers */ + const int SQLITE_VdbeTrace = 0x00000100; + const int SQLITE_InternChanges = 0x00000200; + const int SQLITE_FullColNames = 0x00000400; + const int SQLITE_ShortColNames = 0x00000800; + const int SQLITE_CountRows = 0x00001000; + const int SQLITE_NullCallback = 0x00002000; + const int SQLITE_SqlTrace = 0x00004000; + const int SQLITE_VdbeListing = 0x00008000; + const int SQLITE_WriteSchema = 0x00010000; + const int SQLITE_NoReadlock = 0x00020000; + const int SQLITE_IgnoreChecks = 0x00040000; + const int SQLITE_ReadUncommitted = 0x0080000; + const int SQLITE_LegacyFileFmt = 0x00100000; + const int SQLITE_FullFSync = 0x00200000; + const int SQLITE_CkptFullFSync = 0x00400000; + const int SQLITE_RecoveryMode = 0x00800000; + const int SQLITE_ReverseOrder = 0x01000000; + const int SQLITE_RecTriggers = 0x02000000; + const int SQLITE_ForeignKeys = 0x04000000; + const int SQLITE_AutoIndex = 0x08000000; + const int SQLITE_PreferBuiltin = 0x10000000; + const int SQLITE_LoadExtension = 0x20000000; + const int SQLITE_EnableTrigger = 0x40000000; + + /* + ** Bits of the sqlite3.flags field that are used by the + ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface. + ** These must be the low-order bits of the flags field. + */ + //#define SQLITE_QueryFlattener 0x01 /* Disable query flattening */ + //#define SQLITE_ColumnCache 0x02 /* Disable the column cache */ + //#define SQLITE_IndexSort 0x04 /* Disable indexes for sorting */ + //#define SQLITE_IndexSearch 0x08 /* Disable indexes for searching */ + //#define SQLITE_IndexCover 0x10 /* Disable index covering table */ + //#define SQLITE_GroupByOrder 0x20 /* Disable GROUPBY cover of ORDERBY */ + //#define SQLITE_FactorOutConst 0x40 /* Disable factoring out constants */ + //#define SQLITE_IdxRealAsInt 0x80 /* Store REAL as INT in indices */ + //#define SQLITE_OptMask 0xff /* Mask of all disablable opts */ + const int SQLITE_QueryFlattener = 0x01; + const int SQLITE_ColumnCache = 0x02; + const int SQLITE_IndexSort = 0x04; + const int SQLITE_IndexSearch = 0x08; + const int SQLITE_IndexCover = 0x10; + const int SQLITE_GroupByOrder = 0x20; + const int SQLITE_FactorOutConst = 0x40; + const int SQLITE_IdxRealAsInt = 0x80; + const int SQLITE_OptMask = 0xff; + + /* + ** Possible values for the sqlite.magic field. + ** The numbers are obtained at random and have no special meaning, other + ** than being distinct from one another. + */ + const int SQLITE_MAGIC_OPEN = 0x1029a697; //#define SQLITE_MAGIC_OPEN 0xa029a697 /* Database is open */ + const int SQLITE_MAGIC_CLOSED = 0x2f3c2d33; //#define SQLITE_MAGIC_CLOSED 0x9f3c2d33 /* Database is closed */ + const int SQLITE_MAGIC_SICK = 0x3b771290; //#define SQLITE_MAGIC_SICK 0x4b771290 /* Error and awaiting close */ + const int SQLITE_MAGIC_BUSY = 0x403b7906; //#define SQLITE_MAGIC_BUSY 0xf03b7906 /* Database currently in use */ + const int SQLITE_MAGIC_ERROR = 0x55357930; //#define SQLITE_MAGIC_ERROR 0xb5357930 /* An SQLITE_MISUSE error occurred */ + + /* + ** Each SQL function is defined by an instance of the following + ** structure. A pointer to this structure is stored in the sqlite.aFunc + ** hash table. When multiple functions have the same name, the hash table + ** points to a linked list of these structures. + */ + public class FuncDef { + public i16 nArg; /* Number of arguments. -1 means unlimited */ + public u8 iPrefEnc; /* Preferred text encoding (SQLITE_UTF8, 16LE, 16BE) */ + public u8 flags; /* Some combination of SQLITE_FUNC_* */ + public object pUserData; /* User data parameter */ + public FuncDef pNext; /* Next function with same name */ + public dxFunc xFunc;//)(sqlite3_context*,int,sqlite3_value*); /* Regular function */ + public dxStep xStep;//)(sqlite3_context*,int,sqlite3_value*); /* Aggregate step */ + public dxFinal xFinalize;//)(sqlite3_context); /* Aggregate finalizer */ + public string zName; /* SQL name of the function. */ + public FuncDef pHash; /* Next with a different name but the same hash */ + public FuncDestructor pDestructor; /* Reference counted destructor function */ + + public FuncDef() { + } + + public FuncDef(i16 nArg, u8 iPrefEnc, u8 iflags, object pUserData, FuncDef pNext, dxFunc xFunc, dxStep xStep, dxFinal xFinalize, string zName, FuncDef pHash, FuncDestructor pDestructor) { + this.nArg = nArg; + this.iPrefEnc = iPrefEnc; + this.flags = iflags; + this.pUserData = pUserData; + this.pNext = pNext; + this.xFunc = xFunc; + this.xStep = xStep; + this.xFinalize = xFinalize; + this.zName = zName; + this.pHash = pHash; + this.pDestructor = pDestructor; + } + public FuncDef(string zName, u8 iPrefEnc, i16 nArg, int iArg, u8 iflags, dxFunc xFunc) { + this.nArg = nArg; + this.iPrefEnc = iPrefEnc; + this.flags = iflags; + this.pUserData = iArg; + this.pNext = null; + this.xFunc = xFunc; + this.xStep = null; + this.xFinalize = null; + this.zName = zName; + } + + public FuncDef(string zName, u8 iPrefEnc, i16 nArg, int iArg, u8 iflags, dxStep xStep, dxFinal xFinal) { + this.nArg = nArg; + this.iPrefEnc = iPrefEnc; + this.flags = iflags; + this.pUserData = iArg; + this.pNext = null; + this.xFunc = null; + this.xStep = xStep; + this.xFinalize = xFinal; + this.zName = zName; + } + + public FuncDef(string zName, u8 iPrefEnc, i16 nArg, object arg, dxFunc xFunc, u8 flags) { + this.nArg = nArg; + this.iPrefEnc = iPrefEnc; + this.flags = flags; + this.pUserData = arg; + this.pNext = null; + this.xFunc = xFunc; + this.xStep = null; + this.xFinalize = null; + this.zName = zName; + } + + public FuncDef Copy() { + FuncDef c = new FuncDef(); + c.nArg = nArg; + c.iPrefEnc = iPrefEnc; + c.flags = flags; + c.pUserData = pUserData; + c.pNext = pNext; + c.xFunc = xFunc; + c.xStep = xStep; + c.xFinalize = xFinalize; + c.zName = zName; + c.pHash = pHash; + c.pDestructor = pDestructor; + return c; + } + }; + + /* + ** This structure encapsulates a user-function destructor callback (as + ** configured using create_function_v2()) and a reference counter. When + ** create_function_v2() is called to create a function with a destructor, + ** a single object of this type is allocated. FuncDestructor.nRef is set to + ** the number of FuncDef objects created (either 1 or 3, depending on whether + ** or not the specified encoding is SQLITE_ANY). The FuncDef.pDestructor + ** member of each of the new FuncDef objects is set to point to the allocated + ** FuncDestructor. + ** + ** Thereafter, when one of the FuncDef objects is deleted, the reference + ** count on this object is decremented. When it reaches 0, the destructor + ** is invoked and the FuncDestructor structure freed. + */ + //struct FuncDestructor { + // int nRef; + // void (*xDestroy)(void ); + // void *pUserData; + //}; + public class FuncDestructor { + public int nRef; + public dxFDestroy xDestroy;// (*xDestroy)(void ); + public object pUserData; + }; + + + /* + ** Possible values for FuncDef.flags + */ + //#define SQLITE_FUNC_LIKE 0x01 /* Candidate for the LIKE optimization */ + //#define SQLITE_FUNC_CASE 0x02 /* Case-sensitive LIKE-type function */ + //#define SQLITE_FUNC_EPHEM 0x04 /* Ephemeral. Delete with VDBE */ + //#define SQLITE_FUNC_NEEDCOLL 0x08 /* sqlite3GetFuncCollSeq() might be called */ + //#define SQLITE_FUNC_PRIVATE 0x10 /* Allowed for internal use only */ + //#define SQLITE_FUNC_COUNT 0x20 /* Built-in count() aggregate */ + //#define SQLITE_FUNC_COALESCE 0x40 /* Built-in coalesce() or ifnull() function */ + const int SQLITE_FUNC_LIKE = 0x01; /* Candidate for the LIKE optimization */ + const int SQLITE_FUNC_CASE = 0x02; /* Case-sensitive LIKE-type function */ + const int SQLITE_FUNC_EPHEM = 0x04; /* Ephermeral. Delete with VDBE */ + const int SQLITE_FUNC_NEEDCOLL = 0x08;/* sqlite3GetFuncCollSeq() might be called */ + const int SQLITE_FUNC_PRIVATE = 0x10; /* Allowed for internal use only */ + const int SQLITE_FUNC_COUNT = 0x20; /* Built-in count() aggregate */ + const int SQLITE_FUNC_COALESCE = 0x40;/* Built-in coalesce() or ifnull() function */ + + + /* + ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are + ** used to create the initializers for the FuncDef structures. + ** + ** FUNCTION(zName, nArg, iArg, bNC, xFunc) + ** Used to create a scalar function definition of a function zName + ** implemented by C function xFunc that accepts nArg arguments. The + ** value passed as iArg is cast to a (void) and made available + ** as the user-data (sqlite3_user_data()) for the function. If + ** argument bNC is true, then the SQLITE_FUNC_NEEDCOLL flag is set. + ** + ** AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal) + ** Used to create an aggregate function definition implemented by + ** the C functions xStep and xFinal. The first four parameters + ** are interpreted in the same way as the first 4 parameters to + ** FUNCTION(). + ** + ** LIKEFUNC(zName, nArg, pArg, flags) + ** Used to create a scalar function definition of a function zName + ** that accepts nArg arguments and is implemented by a call to C + ** function likeFunc. Argument pArg is cast to a (void ) and made + ** available as the function user-data (sqlite3_user_data()). The + ** FuncDef.flags variable is set to the value passed as the flags + ** parameter. + */ + //#define FUNCTION(zName, nArg, iArg, bNC, xFunc) \ + // {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \ + //SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} + + static FuncDef FUNCTION(string zName, i16 nArg, int iArg, u8 bNC, dxFunc xFunc) { + return new FuncDef(zName, SQLITE_UTF8, nArg, iArg, (u8)(bNC * SQLITE_FUNC_NEEDCOLL), xFunc); + } - //#define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \ - // {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \ - //pArg, 0, xFunc, 0, 0, #zName, 0, 0} + //#define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \ + // {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \ + //pArg, 0, xFunc, 0, 0, #zName, 0, 0} - //#define LIKEFUNC(zName, nArg, arg, flags) \ - // {nArg, SQLITE_UTF8, flags, (void )arg, 0, likeFunc, 0, 0, #zName, 0, 0} - static FuncDef LIKEFUNC( string zName, i16 nArg, object arg, u8 flags ) - { - return new FuncDef( zName, SQLITE_UTF8, nArg, arg, likeFunc, flags ); - } + //#define LIKEFUNC(zName, nArg, arg, flags) \ + // {nArg, SQLITE_UTF8, flags, (void )arg, 0, likeFunc, 0, 0, #zName, 0, 0} + static FuncDef LIKEFUNC(string zName, i16 nArg, object arg, u8 flags) { + return new FuncDef(zName, SQLITE_UTF8, nArg, arg, likeFunc, flags); + } - //#define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \ - // {nArg, SQLITE_UTF8, nc*SQLITE_FUNC_NEEDCOLL, \ - //SQLITE_INT_TO_PTR(arg), 0, 0, xStep,xFinal,#zName,0,0} + //#define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \ + // {nArg, SQLITE_UTF8, nc*SQLITE_FUNC_NEEDCOLL, \ + //SQLITE_INT_TO_PTR(arg), 0, 0, xStep,xFinal,#zName,0,0} - static FuncDef AGGREGATE( string zName, i16 nArg, int arg, u8 nc, dxStep xStep, dxFinal xFinal ) - { - return new FuncDef( zName, SQLITE_UTF8, nArg, arg, (u8)( nc * SQLITE_FUNC_NEEDCOLL ), xStep, xFinal ); - } + static FuncDef AGGREGATE(string zName, i16 nArg, int arg, u8 nc, dxStep xStep, dxFinal xFinal) { + return new FuncDef(zName, SQLITE_UTF8, nArg, arg, (u8)(nc * SQLITE_FUNC_NEEDCOLL), xStep, xFinal); + } - /* - ** All current savepoints are stored in a linked list starting at - ** sqlite3.pSavepoint. The first element in the list is the most recently - ** opened savepoint. Savepoints are added to the list by the vdbe - ** OP_Savepoint instruction. - */ - //struct Savepoint { - // string zName; /* Savepoint name (nul-terminated) */ - // i64 nDeferredCons; /* Number of deferred fk violations */ - // Savepoint *pNext; /* Parent savepoint (if any) */ - //}; - public class Savepoint - { - public string zName; /* Savepoint name (nul-terminated) */ - public i64 nDeferredCons; /* Number of deferred fk violations */ - public Savepoint pNext; /* Parent savepoint (if any) */ - }; - /* - ** The following are used as the second parameter to sqlite3Savepoint(), - ** and as the P1 argument to the OP_Savepoint instruction. - */ - const int SAVEPOINT_BEGIN = 0; //#define SAVEPOINT_BEGIN 0 - const int SAVEPOINT_RELEASE = 1; //#define SAVEPOINT_RELEASE 1 - const int SAVEPOINT_ROLLBACK = 2; //#define SAVEPOINT_ROLLBACK 2 - - /* - ** Each SQLite module (virtual table definition) is defined by an - ** instance of the following structure, stored in the sqlite3.aModule - ** hash table. - */ - public class Module - { - public sqlite3_module pModule; /* Callback pointers */ - public string zName; /* Name passed to create_module() */ - public object pAux; /* pAux passed to create_module() */ - public smdxDestroy xDestroy;//)(void );/* Module destructor function */ - }; - - /* - ** information about each column of an SQL table is held in an instance - ** of this structure. - */ - public class Column - { - public string zName; /* Name of this column */ - public Expr pDflt; /* Default value of this column */ - public string zDflt; /* Original text of the default value */ - public string zType; /* Data type for this column */ - public string zColl; /* Collating sequence. If NULL, use the default */ - public u8 notNull; /* True if there is a NOT NULL constraint */ - public u8 isPrimKey; /* True if this column is part of the PRIMARY KEY */ - public char affinity; /* One of the SQLITE_AFF_... values */ + /* + ** All current savepoints are stored in a linked list starting at + ** sqlite3.pSavepoint. The first element in the list is the most recently + ** opened savepoint. Savepoints are added to the list by the vdbe + ** OP_Savepoint instruction. + */ + //struct Savepoint { + // string zName; /* Savepoint name (nul-terminated) */ + // i64 nDeferredCons; /* Number of deferred fk violations */ + // Savepoint *pNext; /* Parent savepoint (if any) */ + //}; + public class Savepoint { + public string zName; /* Savepoint name (nul-terminated) */ + public i64 nDeferredCons; /* Number of deferred fk violations */ + public Savepoint pNext; /* Parent savepoint (if any) */ + }; + /* + ** The following are used as the second parameter to sqlite3Savepoint(), + ** and as the P1 argument to the OP_Savepoint instruction. + */ + const int SAVEPOINT_BEGIN = 0; //#define SAVEPOINT_BEGIN 0 + const int SAVEPOINT_RELEASE = 1; //#define SAVEPOINT_RELEASE 1 + const int SAVEPOINT_ROLLBACK = 2; //#define SAVEPOINT_ROLLBACK 2 + + /* + ** Each SQLite module (virtual table definition) is defined by an + ** instance of the following structure, stored in the sqlite3.aModule + ** hash table. + */ + public class Module { + public sqlite3_module pModule; /* Callback pointers */ + public string zName; /* Name passed to create_module() */ + public object pAux; /* pAux passed to create_module() */ + public smdxDestroy xDestroy;//)(void );/* Module destructor function */ + }; + + /* + ** information about each column of an SQL table is held in an instance + ** of this structure. + */ + public class Column { + public string zName; /* Name of this column */ + public Expr pDflt; /* Default value of this column */ + public string zDflt; /* Original text of the default value */ + public string zType; /* Data type for this column */ + public string zColl; /* Collating sequence. If NULL, use the default */ + public u8 notNull; /* True if there is a NOT NULL constraint */ + public u8 isPrimKey; /* True if this column is part of the PRIMARY KEY */ + public char affinity; /* One of the SQLITE_AFF_... values */ #if !SQLITE_OMIT_VIRTUALTABLE -public u8 isHidden; /* True if this column is 'hidden' */ + public u8 isHidden; /* True if this column is 'hidden' */ #endif - public Column Copy() - { - Column cp = (Column)MemberwiseClone(); - if ( cp.pDflt != null ) - cp.pDflt = pDflt.Copy(); - return cp; - } - }; - - /* - ** A "Collating Sequence" is defined by an instance of the following - ** structure. Conceptually, a collating sequence consists of a name and - ** a comparison routine that defines the order of that sequence. - ** - ** There may two separate implementations of the collation function, one - ** that processes text in UTF-8 encoding (CollSeq.xCmp) and another that - ** processes text encoded in UTF-16 (CollSeq.xCmp16), using the machine - ** native byte order. When a collation sequence is invoked, SQLite selects - ** the version that will require the least expensive encoding - ** translations, if any. - ** - ** The CollSeq.pUser member variable is an extra parameter that passed in - ** as the first argument to the UTF-8 comparison function, xCmp. - ** CollSeq.pUser16 is the equivalent for the UTF-16 comparison function, - ** xCmp16. - ** - ** If both CollSeq.xCmp and CollSeq.xCmp16 are NULL, it means that the - ** collating sequence is undefined. Indices built on an undefined - ** collating sequence may not be read or written. - */ - public class CollSeq - { - public string zName; /* Name of the collating sequence, UTF-8 encoded */ - public u8 enc; /* Text encoding handled by xCmp() */ - public u8 type; /* One of the SQLITE_COLL_... values below */ - public object pUser; /* First argument to xCmp() */ - public dxCompare xCmp;//)(void*,int, const void*, int, const void); - public dxDelCollSeq xDel;//)(void); /* Destructor for pUser */ - - public CollSeq Copy() - { - if ( this == null ) - return null; - else - { - CollSeq cp = (CollSeq)MemberwiseClone(); - return cp; - } - } - }; - - /* - ** Allowed values of CollSeq.type: - */ - const int SQLITE_COLL_BINARY = 1;//#define SQLITE_COLL_BINARY 1 /* The default memcmp() collating sequence */ - const int SQLITE_COLL_NOCASE = 2;//#define SQLITE_COLL_NOCASE 2 /* The built-in NOCASE collating sequence */ - const int SQLITE_COLL_REVERSE = 3;//#define SQLITE_COLL_REVERSE 3 /* The built-in REVERSE collating sequence */ - const int SQLITE_COLL_USER = 0;//#define SQLITE_COLL_USER 0 /* Any other user-defined collating sequence */ - - /* - ** A sort order can be either ASC or DESC. - */ - const int SQLITE_SO_ASC = 0;//#define SQLITE_SO_ASC 0 /* Sort in ascending order */ - const int SQLITE_SO_DESC = 1;//#define SQLITE_SO_DESC 1 /* Sort in ascending order */ - - /* - ** Column affinity types. - ** - ** These used to have mnemonic name like 'i' for SQLITE_AFF_INTEGER and - ** 't' for SQLITE_AFF_TEXT. But we can save a little space and improve - ** the speed a little by numbering the values consecutively. - ** - ** But rather than start with 0 or 1, we begin with 'a'. That way, - ** when multiple affinity types are concatenated into a string and - ** used as the P4 operand, they will be more readable. - ** - ** Note also that the numeric types are grouped together so that testing - ** for a numeric type is a single comparison. - */ - const char SQLITE_AFF_TEXT = 'a';//#define SQLITE_AFF_TEXT 'a' - const char SQLITE_AFF_NONE = 'b';//#define SQLITE_AFF_NONE 'b' - const char SQLITE_AFF_NUMERIC = 'c';//#define SQLITE_AFF_NUMERIC 'c' - const char SQLITE_AFF_INTEGER = 'd';//#define SQLITE_AFF_INTEGER 'd' - const char SQLITE_AFF_REAL = 'e';//#define SQLITE_AFF_REAL 'e' - - //#define sqlite3IsNumericAffinity(X) ((X)>=SQLITE_AFF_NUMERIC) - - /* - ** The SQLITE_AFF_MASK values masks off the significant bits of an - ** affinity value. - */ - const int SQLITE_AFF_MASK = 0x67;//#define SQLITE_AFF_MASK 0x67 - - /* - ** Additional bit values that can be ORed with an affinity without - ** changing the affinity. - */ - const int SQLITE_JUMPIFNULL = 0x08; //#define SQLITE_JUMPIFNULL 0x08 /* jumps if either operand is NULL */ - const int SQLITE_STOREP2 = 0x10; //#define SQLITE_STOREP2 0x10 /* Store result in reg[P2] rather than jump */ - const int SQLITE_NULLEQ = 0x80; //#define SQLITE_NULLEQ 0x80 /* NULL=NULL */ - - /* - ** An object of this type is created for each virtual table present in - ** the database schema. - ** - ** If the database schema is shared, then there is one instance of this - ** structure for each database connection (sqlite3) that uses the shared - ** schema. This is because each database connection requires its own unique - ** instance of the sqlite3_vtab* handle used to access the virtual table - ** implementation. sqlite3_vtab* handles can not be shared between - ** database connections, even when the rest of the in-memory database - ** schema is shared, as the implementation often stores the database - ** connection handle passed to it via the xConnect() or xCreate() method - ** during initialization internally. This database connection handle may - ** then be used by the virtual table implementation to access real tables - ** within the database. So that they appear as part of the callers - ** transaction, these accesses need to be made via the same database - ** connection as that used to execute SQL operations on the virtual table. - ** - ** All VTable objects that correspond to a single table in a shared - ** database schema are initially stored in a linked-list pointed to by - ** the Table.pVTable member variable of the corresponding Table object. - ** When an sqlite3_prepare() operation is required to access the virtual - ** table, it searches the list for the VTable that corresponds to the - ** database connection doing the preparing so as to use the correct - ** sqlite3_vtab* handle in the compiled query. - ** - ** When an in-memory Table object is deleted (for example when the - ** schema is being reloaded for some reason), the VTable objects are not - ** deleted and the sqlite3_vtab* handles are not xDisconnect()ed - ** immediately. Instead, they are moved from the Table.pVTable list to - ** another linked list headed by the sqlite3.pDisconnect member of the - ** corresponding sqlite3 structure. They are then deleted/xDisconnected - ** next time a statement is prepared using said sqlite3*. This is done - ** to avoid deadlock issues involving multiple sqlite3.mutex mutexes. - ** Refer to comments above function sqlite3VtabUnlockList() for an - ** explanation as to why it is safe to add an entry to an sqlite3.pDisconnect - ** list without holding the corresponding sqlite3.mutex mutex. - ** - ** The memory for objects of this type is always allocated by - ** sqlite3DbMalloc(), using the connection handle stored in VTable.db as - ** the first argument. - */ - public class VTable - { - public sqlite3 db; /* Database connection associated with this table */ - public Module pMod; /* Pointer to module implementation */ - public sqlite3_vtab pVtab; /* Pointer to vtab instance */ - public int nRef; /* Number of pointers to this structure */ - public u8 bConstraint; /* True if constraints are supported */ - public int iSavepoint; /* Depth of the SAVEPOINT stack */ - public VTable pNext; /* Next in linked list (see above) */ - }; - - /* - ** Each SQL table is represented in memory by an instance of the - ** following structure. - ** - ** Table.zName is the name of the table. The case of the original - ** CREATE TABLE statement is stored, but case is not significant for - ** comparisons. - ** - ** Table.nCol is the number of columns in this table. Table.aCol is a - ** pointer to an array of Column structures, one for each column. - ** - ** If the table has an INTEGER PRIMARY KEY, then Table.iPKey is the index of - ** the column that is that key. Otherwise Table.iPKey is negative. Note - ** that the datatype of the PRIMARY KEY must be INTEGER for this field to - ** be set. An INTEGER PRIMARY KEY is used as the rowid for each row of - ** the table. If a table has no INTEGER PRIMARY KEY, then a random rowid - ** is generated for each row of the table. TF_HasPrimaryKey is set if - ** the table has any PRIMARY KEY, INTEGER or otherwise. - ** - ** Table.tnum is the page number for the root BTree page of the table in the - ** database file. If Table.iDb is the index of the database table backend - ** in sqlite.aDb[]. 0 is for the main database and 1 is for the file that - ** holds temporary tables and indices. If TF_Ephemeral is set - ** then the table is stored in a file that is automatically deleted - ** when the VDBE cursor to the table is closed. In this case Table.tnum - ** refers VDBE cursor number that holds the table open, not to the root - ** page number. Transient tables are used to hold the results of a - ** sub-query that appears instead of a real table name in the FROM clause - ** of a SELECT statement. - */ - public class Table - { - public string zName; /* Name of the table or view */ - public int iPKey; /* If not negative, use aCol[iPKey] as the primary key */ - public int nCol; /* Number of columns in this table */ - public Column[] aCol; /* Information about each column */ - public Index pIndex; /* List of SQL indexes on this table. */ - public int tnum; /* Root BTree node for this table (see note above) */ - public u32 nRowEst; /* Estimated rows in table - from sqlite_stat1 table */ - public Select pSelect; /* NULL for tables. Points to definition if a view. */ - public u16 nRef; /* Number of pointers to this Table */ - public u8 tabFlags; /* Mask of TF_* values */ - public u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */ - public FKey pFKey; /* Linked list of all foreign keys in this table */ - public string zColAff; /* String defining the affinity of each column */ + public Column Copy() { + Column cp = (Column)MemberwiseClone(); + if (cp.pDflt != null) + cp.pDflt = pDflt.Copy(); + return cp; + } + }; + + /* + ** A "Collating Sequence" is defined by an instance of the following + ** structure. Conceptually, a collating sequence consists of a name and + ** a comparison routine that defines the order of that sequence. + ** + ** There may two separate implementations of the collation function, one + ** that processes text in UTF-8 encoding (CollSeq.xCmp) and another that + ** processes text encoded in UTF-16 (CollSeq.xCmp16), using the machine + ** native byte order. When a collation sequence is invoked, SQLite selects + ** the version that will require the least expensive encoding + ** translations, if any. + ** + ** The CollSeq.pUser member variable is an extra parameter that passed in + ** as the first argument to the UTF-8 comparison function, xCmp. + ** CollSeq.pUser16 is the equivalent for the UTF-16 comparison function, + ** xCmp16. + ** + ** If both CollSeq.xCmp and CollSeq.xCmp16 are NULL, it means that the + ** collating sequence is undefined. Indices built on an undefined + ** collating sequence may not be read or written. + */ + public class CollSeq { + public string zName; /* Name of the collating sequence, UTF-8 encoded */ + public u8 enc; /* Text encoding handled by xCmp() */ + public u8 type; /* One of the SQLITE_COLL_... values below */ + public object pUser; /* First argument to xCmp() */ + public dxCompare xCmp;//)(void*,int, const void*, int, const void); + public dxDelCollSeq xDel;//)(void); /* Destructor for pUser */ + + public CollSeq Copy() { + if (this == null) + return null; + else { + CollSeq cp = (CollSeq)MemberwiseClone(); + return cp; + } + } + }; + + /* + ** Allowed values of CollSeq.type: + */ + const int SQLITE_COLL_BINARY = 1;//#define SQLITE_COLL_BINARY 1 /* The default memcmp() collating sequence */ + const int SQLITE_COLL_NOCASE = 2;//#define SQLITE_COLL_NOCASE 2 /* The built-in NOCASE collating sequence */ + const int SQLITE_COLL_REVERSE = 3;//#define SQLITE_COLL_REVERSE 3 /* The built-in REVERSE collating sequence */ + const int SQLITE_COLL_USER = 0;//#define SQLITE_COLL_USER 0 /* Any other user-defined collating sequence */ + + /* + ** A sort order can be either ASC or DESC. + */ + const int SQLITE_SO_ASC = 0;//#define SQLITE_SO_ASC 0 /* Sort in ascending order */ + const int SQLITE_SO_DESC = 1;//#define SQLITE_SO_DESC 1 /* Sort in ascending order */ + + /* + ** Column affinity types. + ** + ** These used to have mnemonic name like 'i' for SQLITE_AFF_INTEGER and + ** 't' for SQLITE_AFF_TEXT. But we can save a little space and improve + ** the speed a little by numbering the values consecutively. + ** + ** But rather than start with 0 or 1, we begin with 'a'. That way, + ** when multiple affinity types are concatenated into a string and + ** used as the P4 operand, they will be more readable. + ** + ** Note also that the numeric types are grouped together so that testing + ** for a numeric type is a single comparison. + */ + const char SQLITE_AFF_TEXT = 'a';//#define SQLITE_AFF_TEXT 'a' + const char SQLITE_AFF_NONE = 'b';//#define SQLITE_AFF_NONE 'b' + const char SQLITE_AFF_NUMERIC = 'c';//#define SQLITE_AFF_NUMERIC 'c' + const char SQLITE_AFF_INTEGER = 'd';//#define SQLITE_AFF_INTEGER 'd' + const char SQLITE_AFF_REAL = 'e';//#define SQLITE_AFF_REAL 'e' + + //#define sqlite3IsNumericAffinity(X) ((X)>=SQLITE_AFF_NUMERIC) + + /* + ** The SQLITE_AFF_MASK values masks off the significant bits of an + ** affinity value. + */ + const int SQLITE_AFF_MASK = 0x67;//#define SQLITE_AFF_MASK 0x67 + + /* + ** Additional bit values that can be ORed with an affinity without + ** changing the affinity. + */ + const int SQLITE_JUMPIFNULL = 0x08; //#define SQLITE_JUMPIFNULL 0x08 /* jumps if either operand is NULL */ + const int SQLITE_STOREP2 = 0x10; //#define SQLITE_STOREP2 0x10 /* Store result in reg[P2] rather than jump */ + const int SQLITE_NULLEQ = 0x80; //#define SQLITE_NULLEQ 0x80 /* NULL=NULL */ + + /* + ** An object of this type is created for each virtual table present in + ** the database schema. + ** + ** If the database schema is shared, then there is one instance of this + ** structure for each database connection (sqlite3) that uses the shared + ** schema. This is because each database connection requires its own unique + ** instance of the sqlite3_vtab* handle used to access the virtual table + ** implementation. sqlite3_vtab* handles can not be shared between + ** database connections, even when the rest of the in-memory database + ** schema is shared, as the implementation often stores the database + ** connection handle passed to it via the xConnect() or xCreate() method + ** during initialization internally. This database connection handle may + ** then be used by the virtual table implementation to access real tables + ** within the database. So that they appear as part of the callers + ** transaction, these accesses need to be made via the same database + ** connection as that used to execute SQL operations on the virtual table. + ** + ** All VTable objects that correspond to a single table in a shared + ** database schema are initially stored in a linked-list pointed to by + ** the Table.pVTable member variable of the corresponding Table object. + ** When an sqlite3_prepare() operation is required to access the virtual + ** table, it searches the list for the VTable that corresponds to the + ** database connection doing the preparing so as to use the correct + ** sqlite3_vtab* handle in the compiled query. + ** + ** When an in-memory Table object is deleted (for example when the + ** schema is being reloaded for some reason), the VTable objects are not + ** deleted and the sqlite3_vtab* handles are not xDisconnect()ed + ** immediately. Instead, they are moved from the Table.pVTable list to + ** another linked list headed by the sqlite3.pDisconnect member of the + ** corresponding sqlite3 structure. They are then deleted/xDisconnected + ** next time a statement is prepared using said sqlite3*. This is done + ** to avoid deadlock issues involving multiple sqlite3.mutex mutexes. + ** Refer to comments above function sqlite3VtabUnlockList() for an + ** explanation as to why it is safe to add an entry to an sqlite3.pDisconnect + ** list without holding the corresponding sqlite3.mutex mutex. + ** + ** The memory for objects of this type is always allocated by + ** sqlite3DbMalloc(), using the connection handle stored in VTable.db as + ** the first argument. + */ + public class VTable { + public sqlite3 db; /* Database connection associated with this table */ + public Module pMod; /* Pointer to module implementation */ + public sqlite3_vtab pVtab; /* Pointer to vtab instance */ + public int nRef; /* Number of pointers to this structure */ + public u8 bConstraint; /* True if constraints are supported */ + public int iSavepoint; /* Depth of the SAVEPOINT stack */ + public VTable pNext; /* Next in linked list (see above) */ + }; + + /* + ** Each SQL table is represented in memory by an instance of the + ** following structure. + ** + ** Table.zName is the name of the table. The case of the original + ** CREATE TABLE statement is stored, but case is not significant for + ** comparisons. + ** + ** Table.nCol is the number of columns in this table. Table.aCol is a + ** pointer to an array of Column structures, one for each column. + ** + ** If the table has an INTEGER PRIMARY KEY, then Table.iPKey is the index of + ** the column that is that key. Otherwise Table.iPKey is negative. Note + ** that the datatype of the PRIMARY KEY must be INTEGER for this field to + ** be set. An INTEGER PRIMARY KEY is used as the rowid for each row of + ** the table. If a table has no INTEGER PRIMARY KEY, then a random rowid + ** is generated for each row of the table. TF_HasPrimaryKey is set if + ** the table has any PRIMARY KEY, INTEGER or otherwise. + ** + ** Table.tnum is the page number for the root BTree page of the table in the + ** database file. If Table.iDb is the index of the database table backend + ** in sqlite.aDb[]. 0 is for the main database and 1 is for the file that + ** holds temporary tables and indices. If TF_Ephemeral is set + ** then the table is stored in a file that is automatically deleted + ** when the VDBE cursor to the table is closed. In this case Table.tnum + ** refers VDBE cursor number that holds the table open, not to the root + ** page number. Transient tables are used to hold the results of a + ** sub-query that appears instead of a real table name in the FROM clause + ** of a SELECT statement. + */ + public class Table { + public string zName; /* Name of the table or view */ + public int iPKey; /* If not negative, use aCol[iPKey] as the primary key */ + public int nCol; /* Number of columns in this table */ + public Column[] aCol; /* Information about each column */ + public Index pIndex; /* List of SQL indexes on this table. */ + public int tnum; /* Root BTree node for this table (see note above) */ + public u32 nRowEst; /* Estimated rows in table - from sqlite_stat1 table */ + public Select pSelect; /* NULL for tables. Points to definition if a view. */ + public u16 nRef; /* Number of pointers to this Table */ + public u8 tabFlags; /* Mask of TF_* values */ + public u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */ + public FKey pFKey; /* Linked list of all foreign keys in this table */ + public string zColAff; /* String defining the affinity of each column */ #if !SQLITE_OMIT_CHECK - public Expr pCheck; /* The AND of all CHECK constraints */ + public Expr pCheck; /* The AND of all CHECK constraints */ #endif #if !SQLITE_OMIT_ALTERTABLE - public int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */ + public int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */ #endif #if !SQLITE_OMIT_VIRTUALTABLE - public VTable pVTable; /* List of VTable objects. */ - public int nModuleArg; /* Number of arguments to the module */ - public string[] azModuleArg;/* Text of all module args. [0] is module name */ + public VTable pVTable; /* List of VTable objects. */ + public int nModuleArg; /* Number of arguments to the module */ + public string[] azModuleArg;/* Text of all module args. [0] is module name */ #endif - public Trigger pTrigger; /* List of SQL triggers on this table */ - public Schema pSchema; /* Schema that contains this table */ - public Table pNextZombie; /* Next on the Parse.pZombieTab list */ - - public Table Copy() - { - if ( this == null ) - return null; - else - { - Table cp = (Table)MemberwiseClone(); - if ( pIndex != null ) - cp.pIndex = pIndex.Copy(); - if ( pSelect != null ) - cp.pSelect = pSelect.Copy(); - if ( pTrigger != null ) - cp.pTrigger = pTrigger.Copy(); - if ( pFKey != null ) - cp.pFKey = pFKey.Copy(); + public Trigger pTrigger; /* List of SQL triggers on this table */ + public Schema pSchema; /* Schema that contains this table */ + public Table pNextZombie; /* Next on the Parse.pZombieTab list */ + + public Table Copy() { + if (this == null) + return null; + else { + Table cp = (Table)MemberwiseClone(); + if (pIndex != null) + cp.pIndex = pIndex.Copy(); + if (pSelect != null) + cp.pSelect = pSelect.Copy(); + if (pTrigger != null) + cp.pTrigger = pTrigger.Copy(); + if (pFKey != null) + cp.pFKey = pFKey.Copy(); #if !SQLITE_OMIT_CHECK - // Don't Clone Checks, only copy reference via Memberwise Clone above -- - //if ( pCheck != null ) cp.pCheck = pCheck.Copy(); + // Don't Clone Checks, only copy reference via Memberwise Clone above -- + //if ( pCheck != null ) cp.pCheck = pCheck.Copy(); #endif - // Don't Clone Schema, only copy reference via Memberwise Clone above -- - // if ( pSchema != null ) cp.pSchema=pSchema.Copy(); - // Don't Clone pNextZombie, only copy reference via Memberwise Clone above -- - // if ( pNextZombie != null ) cp.pNextZombie=pNextZombie.Copy(); - return cp; - } - } - }; - - /* - ** Allowed values for Tabe.tabFlags. - */ - //#define TF_Readonly 0x01 /* Read-only system table */ - //#define TF_Ephemeral 0x02 /* An ephemeral table */ - //#define TF_HasPrimaryKey 0x04 /* Table has a primary key */ - //#define TF_Autoincrement 0x08 /* Integer primary key is autoincrement */ - //#define TF_Virtual 0x10 /* Is a virtual table */ - //#define TF_NeedMetadata 0x20 /* aCol[].zType and aCol[].pColl missing */ - /* - ** Allowed values for Tabe.tabFlags. - */ - const int TF_Readonly = 0x01; /* Read-only system table */ - const int TF_Ephemeral = 0x02; /* An ephemeral table */ - const int TF_HasPrimaryKey = 0x04; /* Table has a primary key */ - const int TF_Autoincrement = 0x08; /* Integer primary key is autoincrement */ - const int TF_Virtual = 0x10; /* Is a virtual table */ - const int TF_NeedMetadata = 0x20; /* aCol[].zType and aCol[].pColl missing */ - - /* - ** Test to see whether or not a table is a virtual table. This is - ** done as a macro so that it will be optimized out when virtual - ** table support is omitted from the build. - */ + // Don't Clone Schema, only copy reference via Memberwise Clone above -- + // if ( pSchema != null ) cp.pSchema=pSchema.Copy(); + // Don't Clone pNextZombie, only copy reference via Memberwise Clone above -- + // if ( pNextZombie != null ) cp.pNextZombie=pNextZombie.Copy(); + return cp; + } + } + }; + + /* + ** Allowed values for Tabe.tabFlags. + */ + //#define TF_Readonly 0x01 /* Read-only system table */ + //#define TF_Ephemeral 0x02 /* An ephemeral table */ + //#define TF_HasPrimaryKey 0x04 /* Table has a primary key */ + //#define TF_Autoincrement 0x08 /* Integer primary key is autoincrement */ + //#define TF_Virtual 0x10 /* Is a virtual table */ + //#define TF_NeedMetadata 0x20 /* aCol[].zType and aCol[].pColl missing */ + /* + ** Allowed values for Tabe.tabFlags. + */ + const int TF_Readonly = 0x01; /* Read-only system table */ + const int TF_Ephemeral = 0x02; /* An ephemeral table */ + const int TF_HasPrimaryKey = 0x04; /* Table has a primary key */ + const int TF_Autoincrement = 0x08; /* Integer primary key is autoincrement */ + const int TF_Virtual = 0x10; /* Is a virtual table */ + const int TF_NeedMetadata = 0x20; /* aCol[].zType and aCol[].pColl missing */ + + /* + ** Test to see whether or not a table is a virtual table. This is + ** done as a macro so that it will be optimized out when virtual + ** table support is omitted from the build. + */ #if !SQLITE_OMIT_VIRTUALTABLE -//# define IsVirtual(X) (((X)->tabFlags & TF_Virtual)!=0) - static bool IsVirtual( Table X ) - { - return ( X.tabFlags & TF_Virtual ) != 0; - } - //# define IsHiddenColumn(X) ((X)->isHidden) -static bool IsHiddenColumn( Column X ) -{ - return X.isHidden != 0; -} + //# define IsVirtual(X) (((X)->tabFlags & TF_Virtual)!=0) + static bool IsVirtual(Table X) { + return (X.tabFlags & TF_Virtual) != 0; + } + //# define IsHiddenColumn(X) ((X)->isHidden) + static bool IsHiddenColumn(Column X) { + return X.isHidden != 0; + } #else //# define IsVirtual(X) 0 static bool IsVirtual( Table T ) @@ -1744,237 +1681,224 @@ static bool IsHiddenColumn( Column C ) } #endif - /* -** Each foreign key constraint is an instance of the following structure. -** -** A foreign key is associated with two tables. The "from" table is -** the table that contains the REFERENCES clause that creates the foreign -** key. The "to" table is the table that is named in the REFERENCES clause. -** Consider this example: -** -** CREATE TABLE ex1( -** a INTEGER PRIMARY KEY, -** b INTEGER CONSTRAINT fk1 REFERENCES ex2(x) -** ); -** -** For foreign key "fk1", the from-table is "ex1" and the to-table is "ex2". -** -** Each REFERENCES clause generates an instance of the following structure -** which is attached to the from-table. The to-table need not exist when -** the from-table is created. The existence of the to-table is not checked. -*/ - public class FKey - { - public Table pFrom; /* Table containing the REFERENCES clause (aka: Child) */ - public FKey pNextFrom; /* Next foreign key in pFrom */ - public string zTo; /* Name of table that the key points to (aka: Parent) */ - public FKey pNextTo; /* Next foreign key on table named zTo */ - public FKey pPrevTo; /* Previous foreign key on table named zTo */ - public int nCol; /* Number of columns in this key */ - /* EV: R-30323-21917 */ - public u8 isDeferred; /* True if constraint checking is deferred till COMMIT */ - public u8[] aAction = new u8[2]; /* ON DELETE and ON UPDATE actions, respectively */ - public Trigger[] apTrigger = new Trigger[2];/* Triggers for aAction[] actions */ - - public class sColMap - { /* Mapping of columns in pFrom to columns in zTo */ - public int iFrom; /* Index of column in pFrom */ - public string zCol; /* Name of column in zTo. If 0 use PRIMARY KEY */ - }; - public sColMap[] aCol; /* One entry for each of nCol column s */ - - public FKey Copy() - { - if ( this == null ) - return null; - else - { - FKey cp = (FKey)MemberwiseClone(); - return cp; - } - } - - }; - - /* - ** SQLite supports many different ways to resolve a constraint - ** error. ROLLBACK processing means that a constraint violation - ** causes the operation in process to fail and for the current transaction - ** to be rolled back. ABORT processing means the operation in process - ** fails and any prior changes from that one operation are backed out, - ** but the transaction is not rolled back. FAIL processing means that - ** the operation in progress stops and returns an error code. But prior - ** changes due to the same operation are not backed out and no rollback - ** occurs. IGNORE means that the particular row that caused the constraint - ** error is not inserted or updated. Processing continues and no error - ** is returned. REPLACE means that preexisting database rows that caused - ** a UNIQUE constraint violation are removed so that the new insert or - ** update can proceed. Processing continues and no error is reported. + /* + ** Each foreign key constraint is an instance of the following structure. ** - ** RESTRICT, SETNULL, and CASCADE actions apply only to foreign keys. - ** RESTRICT is the same as ABORT for IMMEDIATE foreign keys and the - ** same as ROLLBACK for DEFERRED keys. SETNULL means that the foreign - ** key is set to NULL. CASCADE means that a DELETE or UPDATE of the - ** referenced table row is propagated into the row that holds the - ** foreign key. + ** A foreign key is associated with two tables. The "from" table is + ** the table that contains the REFERENCES clause that creates the foreign + ** key. The "to" table is the table that is named in the REFERENCES clause. + ** Consider this example: ** - ** The following symbolic values are used to record which type - ** of action to take. - */ - const int OE_None = 0;//#define OE_None 0 /* There is no constraint to check */ - const int OE_Rollback = 1;//#define OE_Rollback 1 /* Fail the operation and rollback the transaction */ - const int OE_Abort = 2;//#define OE_Abort 2 /* Back out changes but do no rollback transaction */ - const int OE_Fail = 3;//#define OE_Fail 3 /* Stop the operation but leave all prior changes */ - const int OE_Ignore = 4;//#define OE_Ignore 4 /* Ignore the error. Do not do the INSERT or UPDATE */ - const int OE_Replace = 5;//#define OE_Replace 5 /* Delete existing record, then do INSERT or UPDATE */ - - const int OE_Restrict = 6;//#define OE_Restrict 6 /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */ - const int OE_SetNull = 7;//#define OE_SetNull 7 /* Set the foreign key value to NULL */ - const int OE_SetDflt = 8;//#define OE_SetDflt 8 /* Set the foreign key value to its default */ - const int OE_Cascade = 9;//#define OE_Cascade 9 /* Cascade the changes */ - - const int OE_Default = 99;//#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 - ** comparison of the two index keys. - */ - public class KeyInfo - { - public sqlite3 db; /* The database connection */ - public u8 enc; /* Text encoding - one of the SQLITE_UTF* values */ - public u16 nField; /* Number of entries in aColl[] */ - public u8[] aSortOrder; /* Sort order for each column. May be NULL */ - public CollSeq[] aColl = new CollSeq[1]; /* Collating sequence for each term of the key */ - public KeyInfo Copy() - { - return (KeyInfo)MemberwiseClone(); - } - }; - - /* - ** An instance of the following structure holds information about a - ** single index record that has already been parsed out into individual - ** values. + ** CREATE TABLE ex1( + ** a INTEGER PRIMARY KEY, + ** b INTEGER CONSTRAINT fk1 REFERENCES ex2(x) + ** ); ** - ** A record is an object that contains one or more fields of data. - ** Records are used to store the content of a table row and to store - ** the key of an index. A blob encoding of a record is created by - ** the OP_MakeRecord opcode of the VDBE and is disassembled by the - ** OP_Column opcode. + ** For foreign key "fk1", the from-table is "ex1" and the to-table is "ex2". ** - ** This structure holds a record that has already been disassembled - ** into its constituent fields. - */ - public class UnpackedRecord - { - public KeyInfo pKeyInfo; /* Collation and sort-order information */ - public u16 nField; /* Number of entries in apMem[] */ - public u16 flags; /* Boolean settings. UNPACKED_... below */ - public i64 rowid; /* Used by UNPACKED_PREFIX_SEARCH */ - public Mem[] aMem; /* Values */ - }; - - /* - ** Allowed values of UnpackedRecord.flags + ** Each REFERENCES clause generates an instance of the following structure + ** which is attached to the from-table. The to-table need not exist when + ** the from-table is created. The existence of the to-table is not checked. */ - //#define UNPACKED_NEED_FREE 0x0001 /* Memory is from sqlite3Malloc() */ - //#define UNPACKED_NEED_DESTROY 0x0002 /* apMem[]s should all be destroyed */ - //#define UNPACKED_IGNORE_ROWID 0x0004 /* Ignore trailing rowid on key1 */ - //#define UNPACKED_INCRKEY 0x0008 /* Make this key an epsilon larger */ - //#define UNPACKED_PREFIX_MATCH 0x0010 /* A prefix match is considered OK */ - //#define UNPACKED_PREFIX_SEARCH 0x0020 /* A prefix match is considered OK */ - const int UNPACKED_NEED_FREE = 0x0001; /* Memory is from sqlite3Malloc() */ - const int UNPACKED_NEED_DESTROY = 0x0002; /* apMem[]s should all be destroyed */ - const int UNPACKED_IGNORE_ROWID = 0x0004; /* Ignore trailing rowid on key1 */ - const int UNPACKED_INCRKEY = 0x0008; /* Make this key an epsilon larger */ - const int UNPACKED_PREFIX_MATCH = 0x0010; /* A prefix match is considered OK */ - const int UNPACKED_PREFIX_SEARCH = 0x0020; /* A prefix match is considered OK */ - - /* - ** Each SQL index is represented in memory by an - ** instance of the following structure. - ** - ** The columns of the table that are to be indexed are described - ** by the aiColumn[] field of this structure. For example, suppose - ** we have the following table and index: - ** - ** CREATE TABLE Ex1(c1 int, c2 int, c3 text); - ** CREATE INDEX Ex2 ON Ex1(c3,c1); - ** - ** In the Table structure describing Ex1, nCol==3 because there are - ** three columns in the table. In the Index structure describing - ** Ex2, nColumn==2 since 2 of the 3 columns of Ex1 are indexed. - ** The value of aiColumn is {2, 0}. aiColumn[0]==2 because the - ** first column to be indexed (c3) has an index of 2 in Ex1.aCol[]. - ** The second column to be indexed (c1) has an index of 0 in - ** Ex1.aCol[], hence Ex2.aiColumn[1]==0. - ** - ** The Index.onError field determines whether or not the indexed columns - ** must be unique and what to do if they are not. When Index.onError=OE_None, - ** it means this is not a unique index. Otherwise it is a unique index - ** and the value of Index.onError indicate the which conflict resolution - ** algorithm to employ whenever an attempt is made to insert a non-unique - ** element. - */ - public class Index - { - public string zName; /* Name of this index */ - public int nColumn; /* Number of columns in the table used by this index */ - public int[] aiColumn; /* Which columns are used by this index. 1st is 0 */ - public int[] aiRowEst; /* Result of ANALYZE: Est. rows selected by each column */ - public Table pTable; /* The SQL table being indexed */ - public int tnum; /* Page containing root of this index in database file */ - public u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ - public u8 autoIndex; /* True if is automatically created (ex: by UNIQUE) */ - public u8 bUnordered; /* Use this index for == or IN queries only */ - public string zColAff; /* String defining the affinity of each column */ - public Index pNext; /* The next index associated with the same table */ - public Schema pSchema; /* Schema containing this index */ - public u8[] aSortOrder; /* Array of size Index.nColumn. True==DESC, False==ASC */ - public string[] azColl; /* Array of collation sequence names for index */ - public IndexSample[] aSample; /* Array of SQLITE_INDEX_SAMPLES samples */ - - public Index Copy() - { - if ( this == null ) - return null; - else - { - Index cp = (Index)MemberwiseClone(); - return cp; - } - } - }; - /* - ** Each sample stored in the sqlite_stat2 table is represented in memory - ** using a structure of this type. - */ - public class IndexSample - { - public struct _u - { //union { - public string z; /* Value if eType is SQLITE_TEXT */ - public byte[] zBLOB; /* Value if eType is SQLITE_BLOB */ - public double r; /* Value if eType is SQLITE_FLOAT or SQLITE_INTEGER */ - } - public _u u; - public u8 eType; /* SQLITE_NULL, SQLITE_INTEGER ... etc. */ - public u8 nByte; /* Size in byte of text or blob. */ - }; - - /* - ** Each token coming out of the lexer is an instance of - ** this structure. Tokens are also used as part of an expression. - ** - ** Note if Token.z==0 then Token.dyn and Token.n are undefined and - ** may contain random values. Do not make any assumptions about Token.dyn - ** and Token.n when Token.z==0. - */ - public class Token - { + public class FKey { + public Table pFrom; /* Table containing the REFERENCES clause (aka: Child) */ + public FKey pNextFrom; /* Next foreign key in pFrom */ + public string zTo; /* Name of table that the key points to (aka: Parent) */ + public FKey pNextTo; /* Next foreign key on table named zTo */ + public FKey pPrevTo; /* Previous foreign key on table named zTo */ + public int nCol; /* Number of columns in this key */ + /* EV: R-30323-21917 */ + public u8 isDeferred; /* True if constraint checking is deferred till COMMIT */ + public u8[] aAction = new u8[2]; /* ON DELETE and ON UPDATE actions, respectively */ + public Trigger[] apTrigger = new Trigger[2];/* Triggers for aAction[] actions */ + + public class sColMap { /* Mapping of columns in pFrom to columns in zTo */ + public int iFrom; /* Index of column in pFrom */ + public string zCol; /* Name of column in zTo. If 0 use PRIMARY KEY */ + }; + public sColMap[] aCol; /* One entry for each of nCol column s */ + + public FKey Copy() { + if (this == null) + return null; + else { + FKey cp = (FKey)MemberwiseClone(); + return cp; + } + } + + }; + + /* + ** SQLite supports many different ways to resolve a constraint + ** error. ROLLBACK processing means that a constraint violation + ** causes the operation in process to fail and for the current transaction + ** to be rolled back. ABORT processing means the operation in process + ** fails and any prior changes from that one operation are backed out, + ** but the transaction is not rolled back. FAIL processing means that + ** the operation in progress stops and returns an error code. But prior + ** changes due to the same operation are not backed out and no rollback + ** occurs. IGNORE means that the particular row that caused the constraint + ** error is not inserted or updated. Processing continues and no error + ** is returned. REPLACE means that preexisting database rows that caused + ** a UNIQUE constraint violation are removed so that the new insert or + ** update can proceed. Processing continues and no error is reported. + ** + ** RESTRICT, SETNULL, and CASCADE actions apply only to foreign keys. + ** RESTRICT is the same as ABORT for IMMEDIATE foreign keys and the + ** same as ROLLBACK for DEFERRED keys. SETNULL means that the foreign + ** key is set to NULL. CASCADE means that a DELETE or UPDATE of the + ** referenced table row is propagated into the row that holds the + ** foreign key. + ** + ** The following symbolic values are used to record which type + ** of action to take. + */ + const int OE_None = 0;//#define OE_None 0 /* There is no constraint to check */ + const int OE_Rollback = 1;//#define OE_Rollback 1 /* Fail the operation and rollback the transaction */ + const int OE_Abort = 2;//#define OE_Abort 2 /* Back out changes but do no rollback transaction */ + const int OE_Fail = 3;//#define OE_Fail 3 /* Stop the operation but leave all prior changes */ + const int OE_Ignore = 4;//#define OE_Ignore 4 /* Ignore the error. Do not do the INSERT or UPDATE */ + const int OE_Replace = 5;//#define OE_Replace 5 /* Delete existing record, then do INSERT or UPDATE */ + + const int OE_Restrict = 6;//#define OE_Restrict 6 /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */ + const int OE_SetNull = 7;//#define OE_SetNull 7 /* Set the foreign key value to NULL */ + const int OE_SetDflt = 8;//#define OE_SetDflt 8 /* Set the foreign key value to its default */ + const int OE_Cascade = 9;//#define OE_Cascade 9 /* Cascade the changes */ + + const int OE_Default = 99;//#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 + ** comparison of the two index keys. + */ + public class KeyInfo { + public sqlite3 db; /* The database connection */ + public u8 enc; /* Text encoding - one of the SQLITE_UTF* values */ + public u16 nField; /* Number of entries in aColl[] */ + public u8[] aSortOrder; /* Sort order for each column. May be NULL */ + public CollSeq[] aColl = new CollSeq[1]; /* Collating sequence for each term of the key */ + public KeyInfo Copy() { + return (KeyInfo)MemberwiseClone(); + } + }; + + /* + ** An instance of the following structure holds information about a + ** single index record that has already been parsed out into individual + ** values. + ** + ** A record is an object that contains one or more fields of data. + ** Records are used to store the content of a table row and to store + ** the key of an index. A blob encoding of a record is created by + ** the OP_MakeRecord opcode of the VDBE and is disassembled by the + ** OP_Column opcode. + ** + ** This structure holds a record that has already been disassembled + ** into its constituent fields. + */ + public class UnpackedRecord { + public KeyInfo pKeyInfo; /* Collation and sort-order information */ + public u16 nField; /* Number of entries in apMem[] */ + public u16 flags; /* Boolean settings. UNPACKED_... below */ + public i64 rowid; /* Used by UNPACKED_PREFIX_SEARCH */ + public Mem[] aMem; /* Values */ + }; + + /* + ** Allowed values of UnpackedRecord.flags + */ + //#define UNPACKED_NEED_FREE 0x0001 /* Memory is from sqlite3Malloc() */ + //#define UNPACKED_NEED_DESTROY 0x0002 /* apMem[]s should all be destroyed */ + //#define UNPACKED_IGNORE_ROWID 0x0004 /* Ignore trailing rowid on key1 */ + //#define UNPACKED_INCRKEY 0x0008 /* Make this key an epsilon larger */ + //#define UNPACKED_PREFIX_MATCH 0x0010 /* A prefix match is considered OK */ + //#define UNPACKED_PREFIX_SEARCH 0x0020 /* A prefix match is considered OK */ + const int UNPACKED_NEED_FREE = 0x0001; /* Memory is from sqlite3Malloc() */ + const int UNPACKED_NEED_DESTROY = 0x0002; /* apMem[]s should all be destroyed */ + const int UNPACKED_IGNORE_ROWID = 0x0004; /* Ignore trailing rowid on key1 */ + const int UNPACKED_INCRKEY = 0x0008; /* Make this key an epsilon larger */ + const int UNPACKED_PREFIX_MATCH = 0x0010; /* A prefix match is considered OK */ + const int UNPACKED_PREFIX_SEARCH = 0x0020; /* A prefix match is considered OK */ + + /* + ** Each SQL index is represented in memory by an + ** instance of the following structure. + ** + ** The columns of the table that are to be indexed are described + ** by the aiColumn[] field of this structure. For example, suppose + ** we have the following table and index: + ** + ** CREATE TABLE Ex1(c1 int, c2 int, c3 text); + ** CREATE INDEX Ex2 ON Ex1(c3,c1); + ** + ** In the Table structure describing Ex1, nCol==3 because there are + ** three columns in the table. In the Index structure describing + ** Ex2, nColumn==2 since 2 of the 3 columns of Ex1 are indexed. + ** The value of aiColumn is {2, 0}. aiColumn[0]==2 because the + ** first column to be indexed (c3) has an index of 2 in Ex1.aCol[]. + ** The second column to be indexed (c1) has an index of 0 in + ** Ex1.aCol[], hence Ex2.aiColumn[1]==0. + ** + ** The Index.onError field determines whether or not the indexed columns + ** must be unique and what to do if they are not. When Index.onError=OE_None, + ** it means this is not a unique index. Otherwise it is a unique index + ** and the value of Index.onError indicate the which conflict resolution + ** algorithm to employ whenever an attempt is made to insert a non-unique + ** element. + */ + public class Index { + public string zName; /* Name of this index */ + public int nColumn; /* Number of columns in the table used by this index */ + public int[] aiColumn; /* Which columns are used by this index. 1st is 0 */ + public int[] aiRowEst; /* Result of ANALYZE: Est. rows selected by each column */ + public Table pTable; /* The SQL table being indexed */ + public int tnum; /* Page containing root of this index in database file */ + public u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ + public u8 autoIndex; /* True if is automatically created (ex: by UNIQUE) */ + public u8 bUnordered; /* Use this index for == or IN queries only */ + public string zColAff; /* String defining the affinity of each column */ + public Index pNext; /* The next index associated with the same table */ + public Schema pSchema; /* Schema containing this index */ + public u8[] aSortOrder; /* Array of size Index.nColumn. True==DESC, False==ASC */ + public string[] azColl; /* Array of collation sequence names for index */ + public IndexSample[] aSample; /* Array of SQLITE_INDEX_SAMPLES samples */ + + public Index Copy() { + if (this == null) + return null; + else { + Index cp = (Index)MemberwiseClone(); + return cp; + } + } + }; + /* + ** Each sample stored in the sqlite_stat2 table is represented in memory + ** using a structure of this type. + */ + public class IndexSample { + public struct _u { //union { + public string z; /* Value if eType is SQLITE_TEXT */ + public byte[] zBLOB; /* Value if eType is SQLITE_BLOB */ + public double r; /* Value if eType is SQLITE_FLOAT or SQLITE_INTEGER */ + } + public _u u; + public u8 eType; /* SQLITE_NULL, SQLITE_INTEGER ... etc. */ + public u8 nByte; /* Size in byte of text or blob. */ + }; + + /* + ** Each token coming out of the lexer is an instance of + ** this structure. Tokens are also used as part of an expression. + ** + ** Note if Token.z==0 then Token.dyn and Token.n are undefined and + ** may contain random values. Do not make any assumptions about Token.dyn + ** and Token.n when Token.z==0. + */ + public class Token { #if DEBUG_CLASS_TOKEN || DEBUG_CLASS_ALL public string _z; /* Text of the token. Not NULL-terminated! */ public bool dyn;// : 1; /* True for malloced memory, false for static */ @@ -1992,179 +1916,169 @@ public Int32 n set { _n = value; } } #else - public string z; /* Text of the token. Not NULL-terminated! */ - public Int32 n; /* Number of characters in this token */ + public string z; /* Text of the token. Not NULL-terminated! */ + public Int32 n; /* Number of characters in this token */ #endif - public Token() - { - this.z = null; - this.n = 0; - } - public Token( string z, Int32 n ) - { - this.z = z; - this.n = n; - } - public Token Copy() - { - if ( this == null ) - return null; - else - { - Token cp = (Token)MemberwiseClone(); - if ( z == null || z.Length == 0 ) - cp.n = 0; - else - if ( n > z.Length ) - cp.n = z.Length; - return cp; + public Token() { + this.z = null; + this.n = 0; + } + public Token(string z, Int32 n) { + this.z = z; + this.n = n; + } + public Token Copy() { + if (this == null) + return null; + else { + Token cp = (Token)MemberwiseClone(); + if (z == null || z.Length == 0) + cp.n = 0; + else + if (n > z.Length) + cp.n = z.Length; + return cp; + } + } } - } - } - /* - ** An instance of this structure contains information needed to generate - ** code for a SELECT that contains aggregate functions. - ** - ** If Expr.op==TK_AGG_COLUMN or TK_AGG_FUNCTION then Expr.pAggInfo is a - ** pointer to this structure. The Expr.iColumn field is the index in - ** AggInfo.aCol[] or AggInfo.aFunc[] of information needed to generate - ** code for that node. - ** - ** AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the - ** original Select structure that describes the SELECT statement. These - ** fields do not need to be freed when deallocating the AggInfo structure. - */ - public class AggInfo_col - { /* For each column used in source tables */ - public Table pTab; /* Source table */ - public int iTable; /* VdbeCursor number of the source table */ - public int iColumn; /* Column number within the source table */ - public int iSorterColumn; /* Column number in the sorting index */ - public int iMem; /* Memory location that acts as accumulator */ - public Expr pExpr; /* The original expression */ - }; - public class AggInfo_func - { /* For each aggregate function */ - public Expr pExpr; /* Expression encoding the function */ - public FuncDef pFunc; /* The aggregate function implementation */ - public int iMem; /* Memory location that acts as accumulator */ - public int iDistinct; /* Ephemeral table used to enforce DISTINCT */ - } - public class AggInfo - { - public u8 directMode; /* Direct rendering mode means take data directly + /* + ** An instance of this structure contains information needed to generate + ** code for a SELECT that contains aggregate functions. + ** + ** If Expr.op==TK_AGG_COLUMN or TK_AGG_FUNCTION then Expr.pAggInfo is a + ** pointer to this structure. The Expr.iColumn field is the index in + ** AggInfo.aCol[] or AggInfo.aFunc[] of information needed to generate + ** code for that node. + ** + ** AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the + ** original Select structure that describes the SELECT statement. These + ** fields do not need to be freed when deallocating the AggInfo structure. + */ + public class AggInfo_col { /* For each column used in source tables */ + public Table pTab; /* Source table */ + public int iTable; /* VdbeCursor number of the source table */ + public int iColumn; /* Column number within the source table */ + public int iSorterColumn; /* Column number in the sorting index */ + public int iMem; /* Memory location that acts as accumulator */ + public Expr pExpr; /* The original expression */ + }; + public class AggInfo_func { /* For each aggregate function */ + public Expr pExpr; /* Expression encoding the function */ + public FuncDef pFunc; /* The aggregate function implementation */ + public int iMem; /* Memory location that acts as accumulator */ + public int iDistinct; /* Ephemeral table used to enforce DISTINCT */ + } + public class AggInfo { + public u8 directMode; /* Direct rendering mode means take data directly ** from source tables rather than from accumulators */ - public u8 useSortingIdx; /* In direct mode, reference the sorting index rather + public u8 useSortingIdx; /* In direct mode, reference the sorting index rather ** than the source table */ - public int sortingIdx; /* VdbeCursor number of the sorting index */ - public ExprList pGroupBy; /* The group by clause */ - public int nSortingColumn; /* Number of columns in the sorting index */ - public AggInfo_col[] aCol; - public int nColumn; /* Number of used entries in aCol[] */ - public int nColumnAlloc; /* Number of slots allocated for aCol[] */ - public int nAccumulator; /* Number of columns that show through to the output. + public int sortingIdx; /* VdbeCursor number of the sorting index */ + public ExprList pGroupBy; /* The group by clause */ + public int nSortingColumn; /* Number of columns in the sorting index */ + public AggInfo_col[] aCol; + public int nColumn; /* Number of used entries in aCol[] */ + public int nColumnAlloc; /* Number of slots allocated for aCol[] */ + public int nAccumulator; /* Number of columns that show through to the output. ** Additional columns are used only as parameters to ** aggregate functions */ - public AggInfo_func[] aFunc; - public int nFunc; /* Number of entries in aFunc[] */ - public int nFuncAlloc; /* Number of slots allocated for aFunc[] */ - - public AggInfo Copy() - { - if ( this == null ) - return null; - else - { - AggInfo cp = (AggInfo)MemberwiseClone(); - if ( pGroupBy != null ) - cp.pGroupBy = pGroupBy.Copy(); - return cp; - } - } - }; - - /* - ** The datatype ynVar is a signed integer, either 16-bit or 32-bit. - ** Usually it is 16-bits. But if SQLITE_MAX_VARIABLE_NUMBER is greater - ** than 32767 we have to make it 32-bit. 16-bit is preferred because - ** it uses less memory in the Expr object, which is a big memory user - ** in systems with lots of prepared statements. And few applications - ** need more than about 10 or 20 variables. But some extreme users want - ** to have prepared statements with over 32767 variables, and for them - ** the option is available (at compile-time). - */ - //#if SQLITE_MAX_VARIABLE_NUMBER<=32767 - //typedef i16 ynVar; - //#else - //typedef int ynVar; - //#endif - - /* - ** Each node of an expression in the parse tree is an instance - ** of this structure. - ** - ** Expr.op is the opcode. The integer parser token codes are reused - ** as opcodes here. For example, the parser defines TK_GE to be an integer - ** code representing the ">=" operator. This same integer code is reused - ** to represent the greater-than-or-equal-to operator in the expression - ** tree. - ** - ** If the expression is an SQL literal (TK_INTEGER, TK_FLOAT, TK_BLOB, - ** or TK_STRING), then Expr.token contains the text of the SQL literal. If - ** the expression is a variable (TK_VARIABLE), then Expr.token contains the - ** variable name. Finally, if the expression is an SQL function (TK_FUNCTION), - ** then Expr.token contains the name of the function. - ** - ** Expr.pRight and Expr.pLeft are the left and right subexpressions of a - ** binary operator. Either or both may be NULL. - ** - ** Expr.x.pList is a list of arguments if the expression is an SQL function, - ** a CASE expression or an IN expression of the form " IN (, ...)". - ** Expr.x.pSelect is used if the expression is a sub-select or an expression of - ** the form " IN (SELECT ...)". If the EP_xIsSelect bit is set in the - ** Expr.flags mask, then Expr.x.pSelect is valid. Otherwise, Expr.x.pList is - ** valid. - ** - ** An expression of the form ID or ID.ID refers to a column in a table. - ** For such expressions, Expr.op is set to TK_COLUMN and Expr.iTable is - ** the integer cursor number of a VDBE cursor pointing to that table and - ** Expr.iColumn is the column number for the specific column. If the - ** expression is used as a result in an aggregate SELECT, then the - ** value is also stored in the Expr.iAgg column in the aggregate so that - ** it can be accessed after all aggregates are computed. - ** - ** If the expression is an unbound variable marker (a question mark - ** character '?' in the original SQL) then the Expr.iTable holds the index - ** number for that variable. - ** - ** If the expression is a subquery then Expr.iColumn holds an integer - ** register number containing the result of the subquery. If the - ** subquery gives a constant result, then iTable is -1. If the subquery - ** gives a different answer at different times during statement processing - ** then iTable is the address of a subroutine that computes the subquery. - ** - ** If the Expr is of type OP_Column, and the table it is selecting from - ** is a disk table or the "old.*" pseudo-table, then pTab points to the - ** corresponding table definition. - ** - ** ALLOCATION NOTES: - ** - ** Expr objects can use a lot of memory space in database schema. To - ** help reduce memory requirements, sometimes an Expr object will be - ** truncated. And to reduce the number of memory allocations, sometimes - ** two or more Expr objects will be stored in a single memory allocation, - ** together with Expr.zToken strings. - ** - ** If the EP_Reduced and EP_TokenOnly flags are set when - ** an Expr object is truncated. When EP_Reduced is set, then all - ** the child Expr objects in the Expr.pLeft and Expr.pRight subtrees - ** are contained within the same memory allocation. Note, however, that - ** the subtrees in Expr.x.pList or Expr.x.pSelect are always separately - ** allocated, regardless of whether or not EP_Reduced is set. - */ - public class Expr - { + public AggInfo_func[] aFunc; + public int nFunc; /* Number of entries in aFunc[] */ + public int nFuncAlloc; /* Number of slots allocated for aFunc[] */ + + public AggInfo Copy() { + if (this == null) + return null; + else { + AggInfo cp = (AggInfo)MemberwiseClone(); + if (pGroupBy != null) + cp.pGroupBy = pGroupBy.Copy(); + return cp; + } + } + }; + + /* + ** The datatype ynVar is a signed integer, either 16-bit or 32-bit. + ** Usually it is 16-bits. But if SQLITE_MAX_VARIABLE_NUMBER is greater + ** than 32767 we have to make it 32-bit. 16-bit is preferred because + ** it uses less memory in the Expr object, which is a big memory user + ** in systems with lots of prepared statements. And few applications + ** need more than about 10 or 20 variables. But some extreme users want + ** to have prepared statements with over 32767 variables, and for them + ** the option is available (at compile-time). + */ + //#if SQLITE_MAX_VARIABLE_NUMBER<=32767 + //typedef i16 ynVar; + //#else + //typedef int ynVar; + //#endif + + /* + ** Each node of an expression in the parse tree is an instance + ** of this structure. + ** + ** Expr.op is the opcode. The integer parser token codes are reused + ** as opcodes here. For example, the parser defines TK_GE to be an integer + ** code representing the ">=" operator. This same integer code is reused + ** to represent the greater-than-or-equal-to operator in the expression + ** tree. + ** + ** If the expression is an SQL literal (TK_INTEGER, TK_FLOAT, TK_BLOB, + ** or TK_STRING), then Expr.token contains the text of the SQL literal. If + ** the expression is a variable (TK_VARIABLE), then Expr.token contains the + ** variable name. Finally, if the expression is an SQL function (TK_FUNCTION), + ** then Expr.token contains the name of the function. + ** + ** Expr.pRight and Expr.pLeft are the left and right subexpressions of a + ** binary operator. Either or both may be NULL. + ** + ** Expr.x.pList is a list of arguments if the expression is an SQL function, + ** a CASE expression or an IN expression of the form " IN (, ...)". + ** Expr.x.pSelect is used if the expression is a sub-select or an expression of + ** the form " IN (SELECT ...)". If the EP_xIsSelect bit is set in the + ** Expr.flags mask, then Expr.x.pSelect is valid. Otherwise, Expr.x.pList is + ** valid. + ** + ** An expression of the form ID or ID.ID refers to a column in a table. + ** For such expressions, Expr.op is set to TK_COLUMN and Expr.iTable is + ** the integer cursor number of a VDBE cursor pointing to that table and + ** Expr.iColumn is the column number for the specific column. If the + ** expression is used as a result in an aggregate SELECT, then the + ** value is also stored in the Expr.iAgg column in the aggregate so that + ** it can be accessed after all aggregates are computed. + ** + ** If the expression is an unbound variable marker (a question mark + ** character '?' in the original SQL) then the Expr.iTable holds the index + ** number for that variable. + ** + ** If the expression is a subquery then Expr.iColumn holds an integer + ** register number containing the result of the subquery. If the + ** subquery gives a constant result, then iTable is -1. If the subquery + ** gives a different answer at different times during statement processing + ** then iTable is the address of a subroutine that computes the subquery. + ** + ** If the Expr is of type OP_Column, and the table it is selecting from + ** is a disk table or the "old.*" pseudo-table, then pTab points to the + ** corresponding table definition. + ** + ** ALLOCATION NOTES: + ** + ** Expr objects can use a lot of memory space in database schema. To + ** help reduce memory requirements, sometimes an Expr object will be + ** truncated. And to reduce the number of memory allocations, sometimes + ** two or more Expr objects will be stored in a single memory allocation, + ** together with Expr.zToken strings. + ** + ** If the EP_Reduced and EP_TokenOnly flags are set when + ** an Expr object is truncated. When EP_Reduced is set, then all + ** the child Expr objects in the Expr.pLeft and Expr.pRight subtrees + ** are contained within the same memory allocation. Note, however, that + ** the subtrees in Expr.x.pList or Expr.x.pSelect are always separately + ** allocated, regardless of whether or not EP_Reduced is set. + */ + public class Expr { #if DEBUG_CLASS_EXPR || DEBUG_CLASS_ALL public u8 _op; /* Operation performed by this node */ public u8 op @@ -2173,9 +2087,9 @@ public u8 op set { _op = value; } } #else - public u8 op; /* Operation performed by this node */ + public u8 op; /* Operation performed by this node */ #endif - public char affinity; /* The affinity of the column or 0 if not a column */ + public char affinity; /* The affinity of the column or 0 if not a column */ #if DEBUG_CLASS_EXPR || DEBUG_CLASS_ALL public u16 _flags; /* Various flags. EP_* See below */ public u16 flags @@ -2195,49 +2109,47 @@ public string zToken } #else - public struct _u - { - public string zToken; /* Token value. Zero terminated and dequoted */ - public int iValue; /* Non-negative integer value if EP_IntValue */ - } - public u16 flags; /* Various flags. EP_* See below */ + public struct _u { + public string zToken; /* Token value. Zero terminated and dequoted */ + public int iValue; /* Non-negative integer value if EP_IntValue */ + } + public u16 flags; /* Various flags. EP_* See below */ #endif - public _u u; - - /* If the EP_TokenOnly 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. - *********************************************************************/ - - public Expr pLeft; /* Left subnode */ - public Expr pRight; /* Right subnode */ - public struct _x - { - public ExprList pList; /* Function arguments or in " IN ( IN ()" */ + } + public _x x; + public CollSeq pColl; /* The collation type of the column or 0 */ + + /* 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. + *********************************************************************/ + + public int iTable; /* TK_COLUMN: cursor number of table holding column ** TK_REGISTER: register number ** TK_TRIGGER: 1 -> new, 0 -> old */ - public ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid. + public ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid. ** TK_VARIABLE: variable number (always >= 1). */ - public i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */ - public i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */ - public u8 flags2; /* Second set of flags. EP2_... */ - public u8 op2; /* If a TK_REGISTER, the original value of Expr.op */ - public AggInfo pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */ - public Table pTab; /* Table for TK_COLUMN expressions. */ + public i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */ + public i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */ + public u8 flags2; /* Second set of flags. EP2_... */ + public u8 op2; /* If a TK_REGISTER, the original value of Expr.op */ + public AggInfo pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */ + public Table pTab; /* Table for TK_COLUMN expressions. */ #if SQLITE_MAX_EXPR_DEPTH //>0 - public int nHeight; /* Height of the tree headed by this node */ - public Table pZombieTab; /* List of Table objects to delete after code gen */ + public int nHeight; /* Height of the tree headed by this node */ + public Table pZombieTab; /* List of Table objects to delete after code gen */ #endif #if DEBUG_CLASS @@ -2247,948 +2159,905 @@ public int op set { _op = value; } } #endif - public void CopyFrom( Expr cf ) - { - op = cf.op; - affinity = cf.affinity; - flags = cf.flags; - u = cf.u; - pColl = cf.pColl == null ? null : cf.pColl.Copy(); - iTable = cf.iTable; - iColumn = cf.iColumn; - pAggInfo = cf.pAggInfo == null ? null : cf.pAggInfo.Copy(); - iAgg = cf.iAgg; - iRightJoinTable = cf.iRightJoinTable; - flags2 = cf.flags2; - pTab = cf.pTab == null ? null : cf.pTab; + public void CopyFrom(Expr cf) { + op = cf.op; + affinity = cf.affinity; + flags = cf.flags; + u = cf.u; + pColl = cf.pColl == null ? null : cf.pColl.Copy(); + iTable = cf.iTable; + iColumn = cf.iColumn; + pAggInfo = cf.pAggInfo == null ? null : cf.pAggInfo.Copy(); + iAgg = cf.iAgg; + iRightJoinTable = cf.iRightJoinTable; + flags2 = cf.flags2; + pTab = cf.pTab == null ? null : cf.pTab; #if SQLITE_TEST || SQLITE_MAX_EXPR_DEPTH //SQLITE_MAX_EXPR_DEPTH>0 - nHeight = cf.nHeight; - pZombieTab = cf.pZombieTab; + nHeight = cf.nHeight; + pZombieTab = cf.pZombieTab; #endif - pLeft = cf.pLeft == null ? null : cf.pLeft.Copy(); - pRight = cf.pRight == null ? null : cf.pRight.Copy(); - x.pList = cf.x.pList == null ? null : cf.x.pList.Copy(); - x.pSelect = cf.x.pSelect == null ? null : cf.x.pSelect.Copy(); - } - - public Expr Copy() - { - if ( this == null ) - return null; - else - return Copy( flags ); - } - - public Expr Copy( int flag ) - { - Expr cp = new Expr(); - cp.op = op; - cp.affinity = affinity; - cp.flags = flags; - cp.u = u; - if ( ( flag & EP_TokenOnly ) != 0 ) - return cp; - if ( pLeft != null ) - cp.pLeft = pLeft.Copy(); - if ( pRight != null ) - cp.pRight = pRight.Copy(); - cp.x = x; - cp.pColl = pColl; - if ( ( flag & EP_Reduced ) != 0 ) - return cp; - cp.iTable = iTable; - cp.iColumn = iColumn; - cp.iAgg = iAgg; - cp.iRightJoinTable = iRightJoinTable; - cp.flags2 = flags2; - cp.op2 = op2; - cp.pAggInfo = pAggInfo; - cp.pTab = pTab; + pLeft = cf.pLeft == null ? null : cf.pLeft.Copy(); + pRight = cf.pRight == null ? null : cf.pRight.Copy(); + x.pList = cf.x.pList == null ? null : cf.x.pList.Copy(); + x.pSelect = cf.x.pSelect == null ? null : cf.x.pSelect.Copy(); + } + + public Expr Copy() { + if (this == null) + return null; + else + return Copy(flags); + } + + public Expr Copy(int flag) { + Expr cp = new Expr(); + cp.op = op; + cp.affinity = affinity; + cp.flags = flags; + cp.u = u; + if ((flag & EP_TokenOnly) != 0) + return cp; + if (pLeft != null) + cp.pLeft = pLeft.Copy(); + if (pRight != null) + cp.pRight = pRight.Copy(); + cp.x = x; + cp.pColl = pColl; + if ((flag & EP_Reduced) != 0) + return cp; + cp.iTable = iTable; + cp.iColumn = iColumn; + cp.iAgg = iAgg; + cp.iRightJoinTable = iRightJoinTable; + cp.flags2 = flags2; + cp.op2 = op2; + cp.pAggInfo = pAggInfo; + cp.pTab = pTab; #if SQLITE_MAX_EXPR_DEPTH //>0 - cp.nHeight = nHeight; - cp.pZombieTab = pZombieTab; + cp.nHeight = nHeight; + cp.pZombieTab = pZombieTab; #endif - return cp; - } - }; - - /* - ** The following are the meanings of bits in the Expr.flags field. - */ - //#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_ExpCollate 0x0100 /* Collating sequence specified explicitly */ - //#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_Reduced 0x1000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */ - //#define EP_TokenOnly 0x2000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */ - //#define EP_Static 0x4000 /* Held in memory not obtained from malloc() */ - - const ushort EP_FromJoin = 0x0001; - const ushort EP_Agg = 0x0002; - const ushort EP_Resolved = 0x0004; - const ushort EP_Error = 0x0008; - const ushort EP_Distinct = 0x0010; - const ushort EP_VarSelect = 0x0020; - const ushort EP_DblQuoted = 0x0040; - const ushort EP_InfixFunc = 0x0080; - const ushort EP_ExpCollate = 0x0100; - const ushort EP_FixedDest = 0x0200; - const ushort EP_IntValue = 0x0400; - const ushort EP_xIsSelect = 0x0800; - - const ushort EP_Reduced = 0x1000; - const ushort EP_TokenOnly = 0x2000; - const ushort EP_Static = 0x4000; - - /* - ** 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 */ - const u8 EP2_MallocedToken = 0x0001; - const u8 EP2_Irreducible = 0x0002; - - /* - ** 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. - */ + return cp; + } + }; + + /* + ** The following are the meanings of bits in the Expr.flags field. + */ + //#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_ExpCollate 0x0100 /* Collating sequence specified explicitly */ + //#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_Reduced 0x1000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */ + //#define EP_TokenOnly 0x2000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */ + //#define EP_Static 0x4000 /* Held in memory not obtained from malloc() */ + + const ushort EP_FromJoin = 0x0001; + const ushort EP_Agg = 0x0002; + const ushort EP_Resolved = 0x0004; + const ushort EP_Error = 0x0008; + const ushort EP_Distinct = 0x0010; + const ushort EP_VarSelect = 0x0020; + const ushort EP_DblQuoted = 0x0040; + const ushort EP_InfixFunc = 0x0080; + const ushort EP_ExpCollate = 0x0100; + const ushort EP_FixedDest = 0x0200; + const ushort EP_IntValue = 0x0400; + const ushort EP_xIsSelect = 0x0800; + + const ushort EP_Reduced = 0x1000; + const ushort EP_TokenOnly = 0x2000; + const ushort EP_Static = 0x4000; + + /* + ** 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 */ + const u8 EP2_MallocedToken = 0x0001; + const u8 EP2_Irreducible = 0x0002; + + /* + ** 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. + */ #if SQLITE_DEBUG - //# define ExprSetIrreducible(X) (X)->flags2 |= EP2_Irreducible - static void ExprSetIrreducible( Expr X ) - { - X.flags2 |= EP2_Irreducible; - } + //# define ExprSetIrreducible(X) (X)->flags2 |= EP2_Irreducible + static void ExprSetIrreducible(Expr X) { + X.flags2 |= EP2_Irreducible; + } #else //# define ExprSetIrreducible(X) static void ExprSetIrreducible( Expr 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))==(P)) - static bool ExprHasProperty( Expr E, int P ) - { - return ( E.flags & P ) == P; - } - //#define ExprHasAnyProperty(E,P) (((E)->flags&(P))!=0) - static bool ExprHasAnyProperty( Expr E, int P ) - { - return ( E.flags & P ) != 0; - } - //#define ExprSetProperty(E,P) (E)->flags|=(P) - static void ExprSetProperty( Expr E, int P ) - { - E.flags = (ushort)( E.flags | P ); - } - //#define ExprClearProperty(E,P) (E)->flags&=~(P) - static void ExprClearProperty( Expr E, int P ) - { - E.flags = (ushort)( E.flags & ~P ); - } - - /* - ** 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. - */ - //#define EXPR_FULLSIZE sizeof(Expr) /* Full size */ - //#define EXPR_REDUCEDSIZE offsetof(Expr,iTable) /* Common features */ - //#define EXPR_TOKENONLYSIZE offsetof(Expr,pLeft) /* Fewer features */ - - // We don't use these in C#, but define them anyway, - const int EXPR_FULLSIZE = 48; - const int EXPR_REDUCEDSIZE = 24; - const int EXPR_TOKENONLYSIZE = 8; - - /* - ** Flags passed to the sqlite3ExprDup() function. See the header comment - ** above sqlite3ExprDup() for details. - */ - //#define EXPRDUP_REDUCE 0x0001 /* Used reduced-size Expr nodes */ - const int EXPRDUP_REDUCE = 0x0001; - - /* - ** A list of expressions. Each expression may optionally have a - ** name. An expr/name combination can be used in several ways, such - ** as the list of "expr AS ID" fields following a "SELECT" or in the - ** list of "ID = expr" items in an UPDATE. A list of expressions can - ** also be used as the argument to a function, in which case the a.zName - ** field is not used. + /* + ** These macros can be used to test, set, or clear bits in the + ** Expr.flags field. */ - public class ExprList_item - { - public Expr pExpr; /* The list of expressions */ - public string zName; /* Token associated with this expression */ - public string zSpan; /* Original text of the expression */ - public u8 sortOrder; /* 1 for DESC or 0 for ASC */ - public u8 done; /* A flag to indicate when processing is finished */ - public u16 iCol; /* For ORDER BY, column number in result set */ - public u16 iAlias; /* Index into Parse.aAlias[] for zName */ - } - public class ExprList - { - public int nExpr; /* Number of expressions on the list */ - public int nAlloc; /* Number of entries allocated below */ - public int iECursor; /* VDBE VdbeCursor associated with this ExprList */ - public ExprList_item[] a; /* One entry for each expression */ - - public ExprList Copy() - { - if ( this == null ) - return null; - else - { - ExprList cp = (ExprList)MemberwiseClone(); - a.CopyTo( cp.a, 0 ); - return cp; + //#define ExprHasProperty(E,P) (((E)->flags&(P))==(P)) + static bool ExprHasProperty(Expr E, int P) { + return (E.flags & P) == P; } - } - - }; - - /* - ** An instance of this structure is used by the parser to record both - ** the parse tree for an expression and the span of input text for an - ** expression. - */ - public class ExprSpan - { - public Expr pExpr; /* The expression parse tree */ - public string zStart; /* First character of input text */ - public string zEnd; /* One character past the end of input text */ - }; - - /* - ** An instance of this structure can hold a simple list of identifiers, - ** such as the list "a,b,c" in the following statements: - ** - ** INSERT INTO t(a,b,c) VALUES ...; - ** CREATE INDEX idx ON t(a,b,c); - ** CREATE TRIGGER trig BEFORE UPDATE ON t(a,b,c) ...; - ** - ** The IdList.a.idx field is used when the IdList represents the list of - ** column names after a table name in an INSERT statement. In the statement - ** - ** INSERT INTO t(a,b,c) ... - ** - ** If "a" is the k-th column of table "t", then IdList.a[0].idx==k. - */ - public class IdList_item - { - public string zName; /* Name of the identifier */ - public int idx; /* Index in some Table.aCol[] of a column named zName */ - } - public class IdList - { - public IdList_item[] a; - public int nId; /* Number of identifiers on the list */ - public int nAlloc; /* Number of entries allocated for a[] below */ - - public IdList Copy() - { - if ( this == null ) - return null; - else - { - IdList cp = (IdList)MemberwiseClone(); - a.CopyTo( cp.a, 0 ); - return cp; + //#define ExprHasAnyProperty(E,P) (((E)->flags&(P))!=0) + static bool ExprHasAnyProperty(Expr E, int P) { + return (E.flags & P) != 0; + } + //#define ExprSetProperty(E,P) (E)->flags|=(P) + static void ExprSetProperty(Expr E, int P) { + E.flags = (ushort)(E.flags | P); + } + //#define ExprClearProperty(E,P) (E)->flags&=~(P) + static void ExprClearProperty(Expr E, int P) { + E.flags = (ushort)(E.flags & ~P); } - } - }; - - /* - ** The bitmask datatype defined below is used for various optimizations. - ** - ** Changing this from a 64-bit to a 32-bit type limits the number of - ** tables in a join to 32 instead of 64. But it also reduces the size - ** of the library by 738 bytes on ix86. - */ - //typedef u64 Bitmask; - - /* - ** The number of bits in a Bitmask. "BMS" means "BitMask Size". - */ - //#define BMS ((int)(sizeof(Bitmask)*8)) - const int BMS = ( (int)( sizeof( Bitmask ) * 8 ) ); - - /* - ** The following structure describes the FROM clause of a SELECT statement. - ** Each table or subquery in the FROM clause is a separate element of - ** the SrcList.a[] array. - ** - ** With the addition of multiple database support, the following structure - ** can also be used to describe a particular table such as the table that - ** is modified by an INSERT, DELETE, or UPDATE statement. In standard SQL, - ** such a table must be a simple name: ID. But in SQLite, the table can - ** now be identified by a database name, a dot, then the table name: ID.ID. - ** - ** The jointype starts out showing the join type between the current table - ** and the next table on the list. The parser builds the list this way. - ** But sqlite3SrcListShiftJoinType() later shifts the jointypes so that each - ** jointype expresses the join between the table and the previous table. - ** - ** In the colUsed field, the high-order bit (bit 63) is set if the table - ** contains more than 63 columns and the 64-th or later column is used. - */ - public class SrcList_item - { - public string zDatabase; /* Name of database holding this table */ - public string zName; /* Name of the table */ - public string zAlias; /* The "B" part of a "A AS B" phrase. zName is the "A" */ - public Table pTab; /* An SQL table corresponding to zName */ - public Select pSelect; /* A SELECT statement used in place of a table name */ - public u8 isPopulated; /* Temporary table associated with SELECT is populated */ - public u8 jointype; /* Type of join between this able and the previous */ - public u8 notIndexed; /* True if there is a NOT INDEXED clause */ + /* + ** 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. + */ + //#define EXPR_FULLSIZE sizeof(Expr) /* Full size */ + //#define EXPR_REDUCEDSIZE offsetof(Expr,iTable) /* Common features */ + //#define EXPR_TOKENONLYSIZE offsetof(Expr,pLeft) /* Fewer features */ + + // We don't use these in C#, but define them anyway, + const int EXPR_FULLSIZE = 48; + const int EXPR_REDUCEDSIZE = 24; + const int EXPR_TOKENONLYSIZE = 8; + + /* + ** Flags passed to the sqlite3ExprDup() function. See the header comment + ** above sqlite3ExprDup() for details. + */ + //#define EXPRDUP_REDUCE 0x0001 /* Used reduced-size Expr nodes */ + const int EXPRDUP_REDUCE = 0x0001; + + /* + ** A list of expressions. Each expression may optionally have a + ** name. An expr/name combination can be used in several ways, such + ** as the list of "expr AS ID" fields following a "SELECT" or in the + ** list of "ID = expr" items in an UPDATE. A list of expressions can + ** also be used as the argument to a function, in which case the a.zName + ** field is not used. + */ + public class ExprList_item { + public Expr pExpr; /* The list of expressions */ + public string zName; /* Token associated with this expression */ + public string zSpan; /* Original text of the expression */ + public u8 sortOrder; /* 1 for DESC or 0 for ASC */ + public u8 done; /* A flag to indicate when processing is finished */ + public u16 iCol; /* For ORDER BY, column number in result set */ + public u16 iAlias; /* Index into Parse.aAlias[] for zName */ + } + public class ExprList { + public int nExpr; /* Number of expressions on the list */ + public int nAlloc; /* Number of entries allocated below */ + public int iECursor; /* VDBE VdbeCursor associated with this ExprList */ + public ExprList_item[] a; /* One entry for each expression */ + + public ExprList Copy() { + if (this == null) + return null; + else { + ExprList cp = (ExprList)MemberwiseClone(); + a.CopyTo(cp.a, 0); + return cp; + } + } + + }; + + /* + ** An instance of this structure is used by the parser to record both + ** the parse tree for an expression and the span of input text for an + ** expression. + */ + public class ExprSpan { + public Expr pExpr; /* The expression parse tree */ + public string zStart; /* First character of input text */ + public string zEnd; /* One character past the end of input text */ + }; + + /* + ** An instance of this structure can hold a simple list of identifiers, + ** such as the list "a,b,c" in the following statements: + ** + ** INSERT INTO t(a,b,c) VALUES ...; + ** CREATE INDEX idx ON t(a,b,c); + ** CREATE TRIGGER trig BEFORE UPDATE ON t(a,b,c) ...; + ** + ** The IdList.a.idx field is used when the IdList represents the list of + ** column names after a table name in an INSERT statement. In the statement + ** + ** INSERT INTO t(a,b,c) ... + ** + ** If "a" is the k-th column of table "t", then IdList.a[0].idx==k. + */ + public class IdList_item { + public string zName; /* Name of the identifier */ + public int idx; /* Index in some Table.aCol[] of a column named zName */ + } + public class IdList { + public IdList_item[] a; + public int nId; /* Number of identifiers on the list */ + public int nAlloc; /* Number of entries allocated for a[] below */ + + public IdList Copy() { + if (this == null) + return null; + else { + IdList cp = (IdList)MemberwiseClone(); + a.CopyTo(cp.a, 0); + return cp; + } + } + }; + + /* + ** The bitmask datatype defined below is used for various optimizations. + ** + ** Changing this from a 64-bit to a 32-bit type limits the number of + ** tables in a join to 32 instead of 64. But it also reduces the size + ** of the library by 738 bytes on ix86. + */ + //typedef u64 Bitmask; + + /* + ** The number of bits in a Bitmask. "BMS" means "BitMask Size". + */ + //#define BMS ((int)(sizeof(Bitmask)*8)) + const int BMS = ((int)(sizeof(Bitmask) * 8)); + + + /* + ** The following structure describes the FROM clause of a SELECT statement. + ** Each table or subquery in the FROM clause is a separate element of + ** the SrcList.a[] array. + ** + ** With the addition of multiple database support, the following structure + ** can also be used to describe a particular table such as the table that + ** is modified by an INSERT, DELETE, or UPDATE statement. In standard SQL, + ** such a table must be a simple name: ID. But in SQLite, the table can + ** now be identified by a database name, a dot, then the table name: ID.ID. + ** + ** The jointype starts out showing the join type between the current table + ** and the next table on the list. The parser builds the list this way. + ** But sqlite3SrcListShiftJoinType() later shifts the jointypes so that each + ** jointype expresses the join between the table and the previous table. + ** + ** In the colUsed field, the high-order bit (bit 63) is set if the table + ** contains more than 63 columns and the 64-th or later column is used. + */ + public class SrcList_item { + public string zDatabase; /* Name of database holding this table */ + public string zName; /* Name of the table */ + public string zAlias; /* The "B" part of a "A AS B" phrase. zName is the "A" */ + public Table pTab; /* An SQL table corresponding to zName */ + public Select pSelect; /* A SELECT statement used in place of a table name */ + public u8 isPopulated; /* Temporary table associated with SELECT is populated */ + public u8 jointype; /* Type of join between this able and the previous */ + public u8 notIndexed; /* True if there is a NOT INDEXED clause */ #if !SQLITE_OMIT_EXPLAIN - public u8 iSelectId; /* If pSelect!=0, the id of the sub-select in EQP */ + public u8 iSelectId; /* If pSelect!=0, the id of the sub-select in EQP */ #endif - public int iCursor; /* The VDBE cursor number used to access this table */ - public Expr pOn; /* The ON clause of a join */ - public IdList pUsing; /* The USING clause of a join */ - public Bitmask colUsed; /* Bit N (1<" clause */ - public Index pIndex; /* Index structure corresponding to zIndex, if any */ - } - public class SrcList - { - public i16 nSrc; /* Number of tables or subqueries in the FROM clause */ - public i16 nAlloc; /* Number of entries allocated in a[] below */ - public SrcList_item[] a;/* One entry for each identifier on the list */ - public SrcList Copy() - { - if ( this == null ) - return null; - else - { - SrcList cp = (SrcList)MemberwiseClone(); - if ( a != null ) - a.CopyTo( cp.a, 0 ); - return cp; + public int iCursor; /* The VDBE cursor number used to access this table */ + public Expr pOn; /* The ON clause of a join */ + public IdList pUsing; /* The USING clause of a join */ + public Bitmask colUsed; /* Bit N (1<" clause */ + public Index pIndex; /* Index structure corresponding to zIndex, if any */ } - } - }; - - /* - ** Permitted values of the SrcList.a.jointype field - */ - const int JT_INNER = 0x0001; //#define JT_INNER 0x0001 /* Any kind of inner or cross join */ - const int JT_CROSS = 0x0002; //#define JT_CROSS 0x0002 /* Explicit use of the CROSS keyword */ - const int JT_NATURAL = 0x0004; //#define JT_NATURAL 0x0004 /* True for a "natural" join */ - const int JT_LEFT = 0x0008; //#define JT_LEFT 0x0008 /* Left outer join */ - const int JT_RIGHT = 0x0010; //#define JT_RIGHT 0x0010 /* Right outer join */ - const int JT_OUTER = 0x0020; //#define JT_OUTER 0x0020 /* The "OUTER" keyword is present */ - const int JT_ERROR = 0x0040; //#define JT_ERROR 0x0040 /* unknown or unsupported join type */ - - - /* - ** A WherePlan object holds information that describes a lookup - ** strategy. - ** - ** This object is intended to be opaque outside of the where.c module. - ** It is included here only so that that compiler will know how big it - ** is. None of the fields in this object should be used outside of - ** the where.c module. - ** - ** Within the union, pIdx is only used when wsFlags&WHERE_INDEXED is true. - ** pTerm is only used when wsFlags&WHERE_MULTI_OR is true. And pVtabIdx - ** is only used when wsFlags&WHERE_VIRTUALTABLE is true. It is never the - ** case that more than one of these conditions is true. - */ - public class WherePlan - { - public u32 wsFlags; /* WHERE_* flags that describe the strategy */ - public u32 nEq; /* Number of == constraints */ - public double nRow; /* Estimated number of rows (for EQP) */ - public class _u - { - public Index pIdx; /* Index when WHERE_INDEXED is true */ - public WhereTerm pTerm; /* WHERE clause term for OR-search */ - public sqlite3_index_info pVtabIdx; /* Virtual table index to use */ - } - public _u u = new _u(); - public void Clear() - { - wsFlags = 0; - nEq = 0; - nRow = 0; - u.pIdx = null; - u.pTerm = null; - u.pVtabIdx = null; - } - }; - - /* - ** For each nested loop in a WHERE clause implementation, the WhereInfo - ** structure contains a single instance of this structure. This structure - ** is intended to be private the the where.c module and should not be - ** access or modified by other modules. - ** - ** The pIdxInfo field is used to help pick the best index on a - ** virtual table. The pIdxInfo pointer contains indexing - ** information for the i-th table in the FROM clause before reordering. - ** All the pIdxInfo pointers are freed by whereInfoFree() in where.c. - ** All other information in the i-th WhereLevel object for the i-th table - ** after FROM clause ordering. - */ - public class InLoop - { - public int iCur; /* The VDBE cursor used by this IN operator */ - public int addrInTop; /* Top of the IN loop */ - } - public class WhereLevel - { - public WherePlan plan = new WherePlan(); /* query plan for this element of the FROM clause */ - public int iLeftJoin; /* Memory cell used to implement LEFT OUTER JOIN */ - public int iTabCur; /* The VDBE cursor used to access the table */ - public int iIdxCur; /* The VDBE cursor used to access pIdx */ - public int addrBrk; /* Jump here to break out of the loop */ - public int addrNxt; /* Jump here to start the next IN combination */ - public int addrCont; /* Jump here to continue with the next loop cycle */ - public int addrFirst; /* First instruction of interior of the loop */ - public u8 iFrom; /* Which entry in the FROM clause */ - public u8 op, p5; /* Opcode and P5 of the opcode that ends the loop */ - public int p1, p2; /* Operands of the opcode used to ends the loop */ - public class _u - { - public class __in /* Information that depends on plan.wsFlags */ - { - public int nIn; /* Number of entries in aInLoop[] */ - public InLoop[] aInLoop; /* Information about each nested IN operator */ - } - public __in _in = new __in(); /* Used when plan.wsFlags&WHERE_IN_ABLE */ - } - public _u u = new _u(); - - - /* The following field is really not part of the current level. But - ** we need a place to cache virtual table index information for each - ** virtual table in the FROM clause and the WhereLevel structure is - ** a convenient place since there is one WhereLevel for each FROM clause - ** element. - */ - public sqlite3_index_info pIdxInfo; /* Index info for n-th source table */ - }; - - /* - ** Flags appropriate for the wctrlFlags parameter of sqlite3WhereBegin() - ** and the WhereInfo.wctrlFlags member. - */ - //#define WHERE_ORDERBY_NORMAL 0x0000 /* No-op */ - //#define WHERE_ORDERBY_MIN 0x0001 /* ORDER BY processing for min() func */ - //#define WHERE_ORDERBY_MAX 0x0002 /* ORDER BY processing for max() func */ - //#define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */ - //#define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */ - //#define WHERE_OMIT_OPEN 0x0010 /* Table cursors are already open */ - //#define WHERE_OMIT_CLOSE 0x0020 /* Omit close of table & index cursors */ - //#define WHERE_FORCE_TABLE 0x0040 /* Do not use an index-only search */ - //#define WHERE_ONETABLE_ONLY 0x0080 /* Only code the 1st table in pTabList */ - const int WHERE_ORDERBY_NORMAL = 0x0000; - const int WHERE_ORDERBY_MIN = 0x0001; - const int WHERE_ORDERBY_MAX = 0x0002; - const int WHERE_ONEPASS_DESIRED = 0x0004; - const int WHERE_DUPLICATES_OK = 0x0008; - const int WHERE_OMIT_OPEN = 0x0010; - const int WHERE_OMIT_CLOSE = 0x0020; - const int WHERE_FORCE_TABLE = 0x0040; - const int WHERE_ONETABLE_ONLY = 0x0080; - - /* - ** The WHERE clause processing routine has two halves. The - ** first part does the start of the WHERE loop and the second - ** half does the tail of the WHERE loop. An instance of - ** this structure is returned by the first half and passed - ** into the second half to give some continuity. - */ - public class WhereInfo - { - public Parse pParse; /* Parsing and code generating context */ - public u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */ - public u8 okOnePass; /* Ok to use one-pass algorithm for UPDATE or DELETE */ - public u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */ - public SrcList pTabList; /* List of tables in the join */ - public int iTop; /* The very beginning of the WHERE loop */ - public int iContinue; /* Jump here to continue with next record */ - public int iBreak; /* Jump here to break out of the loop */ - public int nLevel; /* Number of nested loop */ - public WhereClause pWC; /* Decomposition of the WHERE clause */ - public double savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */ - public double nRowOut; /* Estimated number of output rows */ - public WhereLevel[] a = new WhereLevel[] { new WhereLevel() }; /* Information about each nest loop in the WHERE */ - }; - - /* - ** A NameContext defines a context in which to resolve table and column - ** names. The context consists of a list of tables (the pSrcList) field and - ** a list of named expression (pEList). The named expression list may - ** be NULL. The pSrc corresponds to the FROM clause of a SELECT or - ** to the table being operated on by INSERT, UPDATE, or DELETE. The - ** pEList corresponds to the result set of a SELECT and is NULL for - ** other statements. - ** - ** NameContexts can be nested. When resolving names, the inner-most - ** context is searched first. If no match is found, the next outer - ** context is checked. If there is still no match, the next context - ** is checked. This process continues until either a match is found - ** or all contexts are check. When a match is found, the nRef member of - ** the context containing the match is incremented. - ** - ** Each subquery gets a new NameContext. The pNext field points to the - ** NameContext in the parent query. Thus the process of scanning the - ** NameContext list corresponds to searching through successively outer - ** subqueries looking for a match. - */ - public class NameContext - { - public Parse pParse; /* The parser */ - public SrcList pSrcList; /* One or more tables used to resolve names */ - public ExprList pEList; /* Optional list of named expressions */ - public int nRef; /* Number of names resolved by this context */ - public int nErr; /* Number of errors encountered while resolving names */ - public u8 allowAgg; /* Aggregate functions allowed here */ - public u8 hasAgg; /* True if aggregates are seen */ - public u8 isCheck; /* True if resolving names in a CHECK constraint */ - public int nDepth; /* Depth of subquery recursion. 1 for no recursion */ - public AggInfo pAggInfo; /* Information about aggregates at this level */ - public NameContext pNext; /* Next outer name context. NULL for outermost */ - }; - - /* - ** An instance of the following structure contains all information - ** needed to generate code for a single SELECT statement. - ** - ** nLimit is set to -1 if there is no LIMIT clause. nOffset is set to 0. - ** If there is a LIMIT clause, the parser sets nLimit to the value of the - ** limit and nOffset to the value of the offset (or 0 if there is not - ** offset). But later on, nLimit and nOffset become the memory locations - ** in the VDBE that record the limit and offset counters. - ** - ** addrOpenEphm[] entries contain the address of OP_OpenEphemeral opcodes. - ** These addresses must be stored so that we can go back and fill in - ** the P4_KEYINFO and P2 parameters later. Neither the KeyInfo nor - ** the number of columns in P2 can be computed at the same time - ** as the OP_OpenEphm instruction is coded because not - ** enough information about the compound query is known at that point. - ** The KeyInfo for addrOpenTran[0] and [1] contains collating sequences - ** for the result set. The KeyInfo for addrOpenTran[2] contains collating - ** sequences for the ORDER BY clause. - */ - public class Select - { - public ExprList pEList; /* The fields of the result */ - public u8 op; /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */ - public char affinity; /* MakeRecord with this affinity for SRT_Set */ - public u16 selFlags; /* Various SF_* values */ - public SrcList pSrc; /* The FROM clause */ - public Expr pWhere; /* The WHERE clause */ - public ExprList pGroupBy; /* The GROUP BY clause */ - public Expr pHaving; /* The HAVING clause */ - public ExprList pOrderBy; /* The ORDER BY clause */ - public Select pPrior; /* Prior select in a compound select statement */ - public Select pNext; /* Next select to the left in a compound */ - public Select pRightmost; /* Right-most select in a compound select statement */ - public Expr pLimit; /* LIMIT expression. NULL means not used. */ - public Expr pOffset; /* OFFSET expression. NULL means not used. */ - public int iLimit; - public int iOffset; /* Memory registers holding LIMIT & OFFSET counters */ - public int[] addrOpenEphm = new int[3]; /* OP_OpenEphem opcodes related to this select */ - public double nSelectRow; /* Estimated number of result rows */ - - public Select Copy() - { - if ( this == null ) - return null; - else - { - Select cp = (Select)MemberwiseClone(); - if ( pEList != null ) - cp.pEList = pEList.Copy(); - if ( pSrc != null ) - cp.pSrc = pSrc.Copy(); - if ( pWhere != null ) - cp.pWhere = pWhere.Copy(); - if ( pGroupBy != null ) - cp.pGroupBy = pGroupBy.Copy(); - if ( pHaving != null ) - cp.pHaving = pHaving.Copy(); - if ( pOrderBy != null ) - cp.pOrderBy = pOrderBy.Copy(); - if ( pPrior != null ) - cp.pPrior = pPrior.Copy(); - if ( pNext != null ) - cp.pNext = pNext.Copy(); - if ( pRightmost != null ) - cp.pRightmost = pRightmost.Copy(); - if ( pLimit != null ) - cp.pLimit = pLimit.Copy(); - if ( pOffset != null ) - cp.pOffset = pOffset.Copy(); - return cp; + public class SrcList { + public i16 nSrc; /* Number of tables or subqueries in the FROM clause */ + public i16 nAlloc; /* Number of entries allocated in a[] below */ + public SrcList_item[] a;/* One entry for each identifier on the list */ + public SrcList Copy() { + if (this == null) + return null; + else { + SrcList cp = (SrcList)MemberwiseClone(); + if (a != null) + a.CopyTo(cp.a, 0); + return cp; + } + } + }; + + /* + ** Permitted values of the SrcList.a.jointype field + */ + const int JT_INNER = 0x0001; //#define JT_INNER 0x0001 /* Any kind of inner or cross join */ + const int JT_CROSS = 0x0002; //#define JT_CROSS 0x0002 /* Explicit use of the CROSS keyword */ + const int JT_NATURAL = 0x0004; //#define JT_NATURAL 0x0004 /* True for a "natural" join */ + const int JT_LEFT = 0x0008; //#define JT_LEFT 0x0008 /* Left outer join */ + const int JT_RIGHT = 0x0010; //#define JT_RIGHT 0x0010 /* Right outer join */ + const int JT_OUTER = 0x0020; //#define JT_OUTER 0x0020 /* The "OUTER" keyword is present */ + const int JT_ERROR = 0x0040; //#define JT_ERROR 0x0040 /* unknown or unsupported join type */ + + + /* + ** A WherePlan object holds information that describes a lookup + ** strategy. + ** + ** This object is intended to be opaque outside of the where.c module. + ** It is included here only so that that compiler will know how big it + ** is. None of the fields in this object should be used outside of + ** the where.c module. + ** + ** Within the union, pIdx is only used when wsFlags&WHERE_INDEXED is true. + ** pTerm is only used when wsFlags&WHERE_MULTI_OR is true. And pVtabIdx + ** is only used when wsFlags&WHERE_VIRTUALTABLE is true. It is never the + ** case that more than one of these conditions is true. + */ + public class WherePlan { + public u32 wsFlags; /* WHERE_* flags that describe the strategy */ + public u32 nEq; /* Number of == constraints */ + public double nRow; /* Estimated number of rows (for EQP) */ + public class _u { + public Index pIdx; /* Index when WHERE_INDEXED is true */ + public WhereTerm pTerm; /* WHERE clause term for OR-search */ + public sqlite3_index_info pVtabIdx; /* Virtual table index to use */ + } + public _u u = new _u(); + public void Clear() { + wsFlags = 0; + nEq = 0; + nRow = 0; + u.pIdx = null; + u.pTerm = null; + u.pVtabIdx = null; + } + }; + + /* + ** For each nested loop in a WHERE clause implementation, the WhereInfo + ** structure contains a single instance of this structure. This structure + ** is intended to be private the the where.c module and should not be + ** access or modified by other modules. + ** + ** The pIdxInfo field is used to help pick the best index on a + ** virtual table. The pIdxInfo pointer contains indexing + ** information for the i-th table in the FROM clause before reordering. + ** All the pIdxInfo pointers are freed by whereInfoFree() in where.c. + ** All other information in the i-th WhereLevel object for the i-th table + ** after FROM clause ordering. + */ + public class InLoop { + public int iCur; /* The VDBE cursor used by this IN operator */ + public int addrInTop; /* Top of the IN loop */ } - } - }; - - /* - ** Allowed values for Select.selFlags. The "SF" prefix stands for - ** "Select Flag". - */ - //#define SF_Distinct 0x0001 /* Output should be DISTINCT */ - //#define SF_Resolved 0x0002 /* Identifiers have been resolved */ - //#define SF_Aggregate 0x0004 /* Contains aggregate functions */ - //#define SF_UsesEphemeral 0x0008 /* Uses the OpenEphemeral opcode */ - //#define SF_Expanded 0x0010 /* sqlite3SelectExpand() called on this */ - //#define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */ - const int SF_Distinct = 0x0001; /* Output should be DISTINCT */ - const int SF_Resolved = 0x0002; /* Identifiers have been resolved */ - const int SF_Aggregate = 0x0004; /* Contains aggregate functions */ - const int SF_UsesEphemeral = 0x0008; /* Uses the OpenEphemeral opcode */ - const int SF_Expanded = 0x0010; /* sqlite3SelectExpand() called on this */ - const int SF_HasTypeInfo = 0x0020; /* FROM subqueries have Table metadata */ - - - /* - ** The results of a select can be distributed in several ways. The - ** "SRT" prefix means "SELECT Result Type". - */ - const int SRT_Union = 1;//#define SRT_Union 1 /* Store result as keys in an index */ - const int SRT_Except = 2;//#define SRT_Except 2 /* Remove result from a UNION index */ - const int SRT_Exists = 3;//#define SRT_Exists 3 /* Store 1 if the result is not empty */ - const int SRT_Discard = 4;//#define SRT_Discard 4 /* Do not save the results anywhere */ - - /* The ORDER BY clause is ignored for all of the above */ - //#define IgnorableOrderby(X) ((X->eDest)<=SRT_Discard) - - const int SRT_Output = 5;//#define SRT_Output 5 /* Output each row of result */ - const int SRT_Mem = 6;//#define SRT_Mem 6 /* Store result in a memory cell */ - const int SRT_Set = 7;//#define SRT_Set 7 /* Store results as keys in an index */ - const int SRT_Table = 8;//#define SRT_Table 8 /* Store result as data with an automatic rowid */ - const int SRT_EphemTab = 9;//#define SRT_EphemTab 9 /* Create transient tab and store like SRT_Table / - const int SRT_Coroutine = 10;//#define SRT_Coroutine 10 /* Generate a single row of result */ - - /* - ** A structure used to customize the behavior of sqlite3Select(). See - ** comments above sqlite3Select() for details. - */ - //typedef struct SelectDest SelectDest; - public class SelectDest - { - public u8 eDest; /* How to dispose of the results */ - public char affinity; /* Affinity used when eDest==SRT_Set */ - public int iParm; /* A parameter used by the eDest disposal method */ - public int iMem; /* Base register where results are written */ - public int nMem; /* Number of registers allocated */ - public SelectDest() - { - this.eDest = 0; - this.affinity = '\0'; - this.iParm = 0; - this.iMem = 0; - this.nMem = 0; - } - public SelectDest( u8 eDest, char affinity, int iParm ) - { - this.eDest = eDest; - this.affinity = affinity; - this.iParm = iParm; - this.iMem = 0; - this.nMem = 0; - } - public SelectDest( u8 eDest, char affinity, int iParm, int iMem, int nMem ) - { - this.eDest = eDest; - this.affinity = affinity; - this.iParm = iParm; - this.iMem = iMem; - this.nMem = nMem; - } - }; - - /* - ** During code generation of statements that do inserts into AUTOINCREMENT - ** tables, the following information is attached to the Table.u.autoInc.p - ** pointer of each autoincrement table to record some side information that - ** the code generator needs. We have to keep per-table autoincrement - ** information in case inserts are down within triggers. Triggers do not - ** normally coordinate their activities, but we do need to coordinate the - ** loading and saving of autoincrement information. - */ - public class AutoincInfo - { - public AutoincInfo pNext; /* Next info block in a list of them all */ - public Table pTab; /* Table this info block refers to */ - public int iDb; /* Index in sqlite3.aDb[] of database holding pTab */ - public int regCtr; /* Memory register holding the rowid counter */ - }; - - /* - ** Size of the column cache - */ + public class WhereLevel { + public WherePlan plan = new WherePlan(); /* query plan for this element of the FROM clause */ + public int iLeftJoin; /* Memory cell used to implement LEFT OUTER JOIN */ + public int iTabCur; /* The VDBE cursor used to access the table */ + public int iIdxCur; /* The VDBE cursor used to access pIdx */ + public int addrBrk; /* Jump here to break out of the loop */ + public int addrNxt; /* Jump here to start the next IN combination */ + public int addrCont; /* Jump here to continue with the next loop cycle */ + public int addrFirst; /* First instruction of interior of the loop */ + public u8 iFrom; /* Which entry in the FROM clause */ + public u8 op, p5; /* Opcode and P5 of the opcode that ends the loop */ + public int p1, p2; /* Operands of the opcode used to ends the loop */ + public class _u { + public class __in /* Information that depends on plan.wsFlags */ + { + public int nIn; /* Number of entries in aInLoop[] */ + public InLoop[] aInLoop; /* Information about each nested IN operator */ + } + public __in _in = new __in(); /* Used when plan.wsFlags&WHERE_IN_ABLE */ + } + public _u u = new _u(); + + + /* The following field is really not part of the current level. But + ** we need a place to cache virtual table index information for each + ** virtual table in the FROM clause and the WhereLevel structure is + ** a convenient place since there is one WhereLevel for each FROM clause + ** element. + */ + public sqlite3_index_info pIdxInfo; /* Index info for n-th source table */ + }; + + /* + ** Flags appropriate for the wctrlFlags parameter of sqlite3WhereBegin() + ** and the WhereInfo.wctrlFlags member. + */ + //#define WHERE_ORDERBY_NORMAL 0x0000 /* No-op */ + //#define WHERE_ORDERBY_MIN 0x0001 /* ORDER BY processing for min() func */ + //#define WHERE_ORDERBY_MAX 0x0002 /* ORDER BY processing for max() func */ + //#define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */ + //#define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */ + //#define WHERE_OMIT_OPEN 0x0010 /* Table cursors are already open */ + //#define WHERE_OMIT_CLOSE 0x0020 /* Omit close of table & index cursors */ + //#define WHERE_FORCE_TABLE 0x0040 /* Do not use an index-only search */ + //#define WHERE_ONETABLE_ONLY 0x0080 /* Only code the 1st table in pTabList */ + const int WHERE_ORDERBY_NORMAL = 0x0000; + const int WHERE_ORDERBY_MIN = 0x0001; + const int WHERE_ORDERBY_MAX = 0x0002; + const int WHERE_ONEPASS_DESIRED = 0x0004; + const int WHERE_DUPLICATES_OK = 0x0008; + const int WHERE_OMIT_OPEN = 0x0010; + const int WHERE_OMIT_CLOSE = 0x0020; + const int WHERE_FORCE_TABLE = 0x0040; + const int WHERE_ONETABLE_ONLY = 0x0080; + + /* + ** The WHERE clause processing routine has two halves. The + ** first part does the start of the WHERE loop and the second + ** half does the tail of the WHERE loop. An instance of + ** this structure is returned by the first half and passed + ** into the second half to give some continuity. + */ + public class WhereInfo { + public Parse pParse; /* Parsing and code generating context */ + public u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */ + public u8 okOnePass; /* Ok to use one-pass algorithm for UPDATE or DELETE */ + public u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */ + public SrcList pTabList; /* List of tables in the join */ + public int iTop; /* The very beginning of the WHERE loop */ + public int iContinue; /* Jump here to continue with next record */ + public int iBreak; /* Jump here to break out of the loop */ + public int nLevel; /* Number of nested loop */ + public WhereClause pWC; /* Decomposition of the WHERE clause */ + public double savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */ + public double nRowOut; /* Estimated number of output rows */ + public WhereLevel[] a = new WhereLevel[] { new WhereLevel() }; /* Information about each nest loop in the WHERE */ + }; + + /* + ** A NameContext defines a context in which to resolve table and column + ** names. The context consists of a list of tables (the pSrcList) field and + ** a list of named expression (pEList). The named expression list may + ** be NULL. The pSrc corresponds to the FROM clause of a SELECT or + ** to the table being operated on by INSERT, UPDATE, or DELETE. The + ** pEList corresponds to the result set of a SELECT and is NULL for + ** other statements. + ** + ** NameContexts can be nested. When resolving names, the inner-most + ** context is searched first. If no match is found, the next outer + ** context is checked. If there is still no match, the next context + ** is checked. This process continues until either a match is found + ** or all contexts are check. When a match is found, the nRef member of + ** the context containing the match is incremented. + ** + ** Each subquery gets a new NameContext. The pNext field points to the + ** NameContext in the parent query. Thus the process of scanning the + ** NameContext list corresponds to searching through successively outer + ** subqueries looking for a match. + */ + public class NameContext { + public Parse pParse; /* The parser */ + public SrcList pSrcList; /* One or more tables used to resolve names */ + public ExprList pEList; /* Optional list of named expressions */ + public int nRef; /* Number of names resolved by this context */ + public int nErr; /* Number of errors encountered while resolving names */ + public u8 allowAgg; /* Aggregate functions allowed here */ + public u8 hasAgg; /* True if aggregates are seen */ + public u8 isCheck; /* True if resolving names in a CHECK constraint */ + public int nDepth; /* Depth of subquery recursion. 1 for no recursion */ + public AggInfo pAggInfo; /* Information about aggregates at this level */ + public NameContext pNext; /* Next outer name context. NULL for outermost */ + }; + + /* + ** An instance of the following structure contains all information + ** needed to generate code for a single SELECT statement. + ** + ** nLimit is set to -1 if there is no LIMIT clause. nOffset is set to 0. + ** If there is a LIMIT clause, the parser sets nLimit to the value of the + ** limit and nOffset to the value of the offset (or 0 if there is not + ** offset). But later on, nLimit and nOffset become the memory locations + ** in the VDBE that record the limit and offset counters. + ** + ** addrOpenEphm[] entries contain the address of OP_OpenEphemeral opcodes. + ** These addresses must be stored so that we can go back and fill in + ** the P4_KEYINFO and P2 parameters later. Neither the KeyInfo nor + ** the number of columns in P2 can be computed at the same time + ** as the OP_OpenEphm instruction is coded because not + ** enough information about the compound query is known at that point. + ** The KeyInfo for addrOpenTran[0] and [1] contains collating sequences + ** for the result set. The KeyInfo for addrOpenTran[2] contains collating + ** sequences for the ORDER BY clause. + */ + public class Select { + public ExprList pEList; /* The fields of the result */ + public u8 op; /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */ + public char affinity; /* MakeRecord with this affinity for SRT_Set */ + public u16 selFlags; /* Various SF_* values */ + public SrcList pSrc; /* The FROM clause */ + public Expr pWhere; /* The WHERE clause */ + public ExprList pGroupBy; /* The GROUP BY clause */ + public Expr pHaving; /* The HAVING clause */ + public ExprList pOrderBy; /* The ORDER BY clause */ + public Select pPrior; /* Prior select in a compound select statement */ + public Select pNext; /* Next select to the left in a compound */ + public Select pRightmost; /* Right-most select in a compound select statement */ + public Expr pLimit; /* LIMIT expression. NULL means not used. */ + public Expr pOffset; /* OFFSET expression. NULL means not used. */ + public int iLimit; + public int iOffset; /* Memory registers holding LIMIT & OFFSET counters */ + public int[] addrOpenEphm = new int[3]; /* OP_OpenEphem opcodes related to this select */ + public double nSelectRow; /* Estimated number of result rows */ + + public Select Copy() { + if (this == null) + return null; + else { + Select cp = (Select)MemberwiseClone(); + if (pEList != null) + cp.pEList = pEList.Copy(); + if (pSrc != null) + cp.pSrc = pSrc.Copy(); + if (pWhere != null) + cp.pWhere = pWhere.Copy(); + if (pGroupBy != null) + cp.pGroupBy = pGroupBy.Copy(); + if (pHaving != null) + cp.pHaving = pHaving.Copy(); + if (pOrderBy != null) + cp.pOrderBy = pOrderBy.Copy(); + if (pPrior != null) + cp.pPrior = pPrior.Copy(); + if (pNext != null) + cp.pNext = pNext.Copy(); + if (pRightmost != null) + cp.pRightmost = pRightmost.Copy(); + if (pLimit != null) + cp.pLimit = pLimit.Copy(); + if (pOffset != null) + cp.pOffset = pOffset.Copy(); + return cp; + } + } + }; + + /* + ** Allowed values for Select.selFlags. The "SF" prefix stands for + ** "Select Flag". + */ + //#define SF_Distinct 0x0001 /* Output should be DISTINCT */ + //#define SF_Resolved 0x0002 /* Identifiers have been resolved */ + //#define SF_Aggregate 0x0004 /* Contains aggregate functions */ + //#define SF_UsesEphemeral 0x0008 /* Uses the OpenEphemeral opcode */ + //#define SF_Expanded 0x0010 /* sqlite3SelectExpand() called on this */ + //#define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */ + const int SF_Distinct = 0x0001; /* Output should be DISTINCT */ + const int SF_Resolved = 0x0002; /* Identifiers have been resolved */ + const int SF_Aggregate = 0x0004; /* Contains aggregate functions */ + const int SF_UsesEphemeral = 0x0008; /* Uses the OpenEphemeral opcode */ + const int SF_Expanded = 0x0010; /* sqlite3SelectExpand() called on this */ + const int SF_HasTypeInfo = 0x0020; /* FROM subqueries have Table metadata */ + + + /* + ** The results of a select can be distributed in several ways. The + ** "SRT" prefix means "SELECT Result Type". + */ + const int SRT_Union = 1;//#define SRT_Union 1 /* Store result as keys in an index */ + const int SRT_Except = 2;//#define SRT_Except 2 /* Remove result from a UNION index */ + const int SRT_Exists = 3;//#define SRT_Exists 3 /* Store 1 if the result is not empty */ + const int SRT_Discard = 4;//#define SRT_Discard 4 /* Do not save the results anywhere */ + + /* The ORDER BY clause is ignored for all of the above */ + //#define IgnorableOrderby(X) ((X->eDest)<=SRT_Discard) + + const int SRT_Output = 5;//#define SRT_Output 5 /* Output each row of result */ + const int SRT_Mem = 6;//#define SRT_Mem 6 /* Store result in a memory cell */ + const int SRT_Set = 7;//#define SRT_Set 7 /* Store results as keys in an index */ + const int SRT_Table = 8;//#define SRT_Table 8 /* Store result as data with an automatic rowid */ + const int SRT_EphemTab = 9;//#define SRT_EphemTab 9 /* Create transient tab and store like SRT_Table / + const int SRT_Coroutine = 10;//#define SRT_Coroutine 10 /* Generate a single row of result */ + + /* + ** A structure used to customize the behavior of sqlite3Select(). See + ** comments above sqlite3Select() for details. + */ + //typedef struct SelectDest SelectDest; + public class SelectDest { + public u8 eDest; /* How to dispose of the results */ + public char affinity; /* Affinity used when eDest==SRT_Set */ + public int iParm; /* A parameter used by the eDest disposal method */ + public int iMem; /* Base register where results are written */ + public int nMem; /* Number of registers allocated */ + public SelectDest() { + this.eDest = 0; + this.affinity = '\0'; + this.iParm = 0; + this.iMem = 0; + this.nMem = 0; + } + public SelectDest(u8 eDest, char affinity, int iParm) { + this.eDest = eDest; + this.affinity = affinity; + this.iParm = iParm; + this.iMem = 0; + this.nMem = 0; + } + public SelectDest(u8 eDest, char affinity, int iParm, int iMem, int nMem) { + this.eDest = eDest; + this.affinity = affinity; + this.iParm = iParm; + this.iMem = iMem; + this.nMem = nMem; + } + }; + + /* + ** During code generation of statements that do inserts into AUTOINCREMENT + ** tables, the following information is attached to the Table.u.autoInc.p + ** pointer of each autoincrement table to record some side information that + ** the code generator needs. We have to keep per-table autoincrement + ** information in case inserts are down within triggers. Triggers do not + ** normally coordinate their activities, but we do need to coordinate the + ** loading and saving of autoincrement information. + */ + public class AutoincInfo { + public AutoincInfo pNext; /* Next info block in a list of them all */ + public Table pTab; /* Table this info block refers to */ + public int iDb; /* Index in sqlite3.aDb[] of database holding pTab */ + public int regCtr; /* Memory register holding the rowid counter */ + }; + + /* + ** Size of the column cache + */ #if !SQLITE_N_COLCACHE - //# define SQLITE_N_COLCACHE 10 - const int SQLITE_N_COLCACHE = 10; + //# define SQLITE_N_COLCACHE 10 + const int SQLITE_N_COLCACHE = 10; #endif - /* -** At least one instance of the following structure is created for each -** trigger that may be fired while parsing an INSERT, UPDATE or DELETE -** statement. All such objects are stored in the linked list headed at -** Parse.pTriggerPrg and deleted once statement compilation has been -** completed. -** -** A Vdbe sub-program that implements the body and WHEN clause of trigger -** TriggerPrg.pTrigger, assuming a default ON CONFLICT clause of -** TriggerPrg.orconf, is stored in the TriggerPrg.pProgram variable. -** The Parse.pTriggerPrg list never contains two entries with the same -** values for both pTrigger and orconf. -** -** The TriggerPrg.aColmask[0] variable is set to a mask of old.* columns -** accessed (or set to 0 for triggers fired as a result of INSERT -** statements). Similarly, the TriggerPrg.aColmask[1] variable is set to -** a mask of new.* columns used by the program. -*/ - public class TriggerPrg - { - public Trigger pTrigger; /* Trigger this program was coded from */ - public int orconf; /* Default ON CONFLICT policy */ - public SubProgram pProgram; /* Program implementing pTrigger/orconf */ - public u32[] aColmask = new u32[2]; /* Masks of old.*, new.* columns accessed */ - public TriggerPrg pNext; /* Next entry in Parse.pTriggerPrg list */ - }; - - /* - ** The yDbMask datatype for the bitmask of all attached databases. - */ - //#if SQLITE_MAX_ATTACHED>30 - // typedef sqlite3_uint64 yDbMask; - //#else - // typedef unsigned int yDbMask; - //#endif - - /* - ** An SQL parser context. A copy of this structure is passed through - ** the parser and down into all the parser action routine in order to - ** carry around information that is global to the entire parse. + /* + ** At least one instance of the following structure is created for each + ** trigger that may be fired while parsing an INSERT, UPDATE or DELETE + ** statement. All such objects are stored in the linked list headed at + ** Parse.pTriggerPrg and deleted once statement compilation has been + ** completed. ** - ** The structure is divided into two parts. When the parser and code - ** generate call themselves recursively, the first part of the structure - ** is constant but the second part is reset at the beginning and end of - ** each recursion. + ** A Vdbe sub-program that implements the body and WHEN clause of trigger + ** TriggerPrg.pTrigger, assuming a default ON CONFLICT clause of + ** TriggerPrg.orconf, is stored in the TriggerPrg.pProgram variable. + ** The Parse.pTriggerPrg list never contains two entries with the same + ** values for both pTrigger and orconf. ** - ** The nTableLock and aTableLock variables are only used if the shared-cache - ** feature is enabled (if sqlite3Tsd()->useSharedData is true). They are - ** used to store the set of table-locks required by the statement being - ** compiled. Function sqlite3TableLock() is used to add entries to the - ** list. + ** The TriggerPrg.aColmask[0] variable is set to a mask of old.* columns + ** accessed (or set to 0 for triggers fired as a result of INSERT + ** statements). Similarly, the TriggerPrg.aColmask[1] variable is set to + ** a mask of new.* columns used by the program. */ - public class yColCache - { - public int iTable; /* Table cursor number */ - public int iColumn; /* Table column number */ - public u8 tempReg; /* iReg is a temp register that needs to be freed */ - public int iLevel; /* Nesting level */ - public int iReg; /* Reg with value of this column. 0 means none. */ - public int lru; /* Least recently used entry has the smallest value */ - } + public class TriggerPrg { + public Trigger pTrigger; /* Trigger this program was coded from */ + public int orconf; /* Default ON CONFLICT policy */ + public SubProgram pProgram; /* Program implementing pTrigger/orconf */ + public u32[] aColmask = new u32[2]; /* Masks of old.*, new.* columns accessed */ + public TriggerPrg pNext; /* Next entry in Parse.pTriggerPrg list */ + }; + + /* + ** The yDbMask datatype for the bitmask of all attached databases. + */ + //#if SQLITE_MAX_ATTACHED>30 + // typedef sqlite3_uint64 yDbMask; + //#else + // typedef unsigned int yDbMask; + //#endif + + /* + ** An SQL parser context. A copy of this structure is passed through + ** the parser and down into all the parser action routine in order to + ** carry around information that is global to the entire parse. + ** + ** The structure is divided into two parts. When the parser and code + ** generate call themselves recursively, the first part of the structure + ** is constant but the second part is reset at the beginning and end of + ** each recursion. + ** + ** The nTableLock and aTableLock variables are only used if the shared-cache + ** feature is enabled (if sqlite3Tsd()->useSharedData is true). They are + ** used to store the set of table-locks required by the statement being + ** compiled. Function sqlite3TableLock() is used to add entries to the + ** list. + */ + public class yColCache { + public int iTable; /* Table cursor number */ + public int iColumn; /* Table column number */ + public u8 tempReg; /* iReg is a temp register that needs to be freed */ + public int iLevel; /* Nesting level */ + public int iReg; /* Reg with value of this column. 0 means none. */ + public int lru; /* Least recently used entry has the smallest value */ + } - public class Parse - { - public sqlite3 db; /* The main database structure */ - public int rc; /* Return code from execution */ - public string zErrMsg; /* An error message */ - public Vdbe pVdbe; /* An engine for executing database bytecode */ - public u8 colNamesSet; /* TRUE after OP_ColumnName has been issued to pVdbe */ - public u8 nameClash; /* A permanent table name clashes with temp table name */ - public u8 checkSchema; /* Causes schema cookie check after an error */ - public u8 nested; /* Number of nested calls to the parser/code generator */ - public u8 parseError; /* True after a parsing error. Ticket #1794 */ - public u8 nTempReg; /* Number of temporary registers in aTempReg[] */ - public u8 nTempInUse; /* Number of aTempReg[] currently checked out */ - public int[] aTempReg; /* Holding area for temporary registers */ - public int nRangeReg; /* Size of the temporary register block */ - public int iRangeReg; /* First register in temporary register block */ - public int nErr; /* Number of errors seen */ - public int nTab; /* Number of previously allocated VDBE cursors */ - public int nMem; /* Number of memory cells used so far */ - public int nSet; /* Number of sets used so far */ - public int ckBase; /* Base register of data during check constraints */ - public int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */ - public int iCacheCnt; /* Counter used to generate aColCache[].lru values */ - public u8 nColCache; /* Number of entries in the column cache */ - public u8 iColCache; /* Next entry of the cache to replace */ - public yColCache[] aColCache;/* One for each valid column cache entry */ - public yDbMask writeMask; /* Start a write transaction on these databases */ - public yDbMask cookieMask; /* Bitmask of schema verified databases */ - public u8 isMultiWrite; /* True if statement may affect/insert multiple rows */ - public u8 mayAbort; /* True if statement may throw an ABORT exception */ - public int cookieGoto; /* Address of OP_Goto to cookie verifier subroutine */ - public int[] cookieValue; /* Values of cookies to verify */ + public class Parse { + public sqlite3 db; /* The main database structure */ + public int rc; /* Return code from execution */ + public string zErrMsg; /* An error message */ + public Vdbe pVdbe; /* An engine for executing database bytecode */ + public u8 colNamesSet; /* TRUE after OP_ColumnName has been issued to pVdbe */ + public u8 nameClash; /* A permanent table name clashes with temp table name */ + public u8 checkSchema; /* Causes schema cookie check after an error */ + public u8 nested; /* Number of nested calls to the parser/code generator */ + public u8 parseError; /* True after a parsing error. Ticket #1794 */ + public u8 nTempReg; /* Number of temporary registers in aTempReg[] */ + public u8 nTempInUse; /* Number of aTempReg[] currently checked out */ + public int[] aTempReg; /* Holding area for temporary registers */ + public int nRangeReg; /* Size of the temporary register block */ + public int iRangeReg; /* First register in temporary register block */ + public int nErr; /* Number of errors seen */ + public int nTab; /* Number of previously allocated VDBE cursors */ + public int nMem; /* Number of memory cells used so far */ + public int nSet; /* Number of sets used so far */ + public int ckBase; /* Base register of data during check constraints */ + public int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */ + public int iCacheCnt; /* Counter used to generate aColCache[].lru values */ + public u8 nColCache; /* Number of entries in the column cache */ + public u8 iColCache; /* Next entry of the cache to replace */ + public yColCache[] aColCache;/* One for each valid column cache entry */ + public yDbMask writeMask; /* Start a write transaction on these databases */ + public yDbMask cookieMask; /* Bitmask of schema verified databases */ + public u8 isMultiWrite; /* True if statement may affect/insert multiple rows */ + public u8 mayAbort; /* True if statement may throw an ABORT exception */ + public int cookieGoto; /* Address of OP_Goto to cookie verifier subroutine */ + public int[] cookieValue; /* Values of cookies to verify */ #if !SQLITE_OMIT_SHARED_CACHE public int nTableLock; /* Number of locks in aTableLock */ public TableLock[] aTableLock; /* Required table locks for shared-cache mode */ #endif - public int regRowid; /* Register holding rowid of CREATE TABLE entry */ - public int regRoot; /* Register holding root page number for new objects */ - public AutoincInfo pAinc; /* Information about AUTOINCREMENT counters */ - public int nMaxArg; /* Max args passed to user function by sub-program */ - - /* Information used while coding trigger programs. */ - public Parse pToplevel; /* Parse structure for main program (or NULL) */ - public Table pTriggerTab; /* Table triggers are being coded for */ - public u32 oldmask; /* Mask of old.* columns referenced */ - public u32 newmask; /* Mask of new.* columns referenced */ - public u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */ - public u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */ - public u8 disableTriggers; /* True to disable triggers */ - public double nQueryLoop; /* Estimated number of iterations of a query */ - - /* Above is constant between recursions. Below is reset before and after - ** each recursion */ - - public int nVar; /* Number of '?' variables seen in the SQL so far */ - public int nzVar; /* Number of available slots in azVar[] */ - public string[] azVar; /* Pointers to names of parameters */ - public Vdbe pReprepare; /* VM being reprepared (sqlite3Reprepare()) */ - public int nAlias; /* Number of aliased result set columns */ - public int nAliasAlloc; /* Number of allocated slots for aAlias[] */ - public int[] aAlias; /* Register used to hold aliased result */ - public u8 explain; /* True if the EXPLAIN flag is found on the query */ - public Token sNameToken; /* Token with unqualified schema object name */ - public Token sLastToken; /* The last token parsed */ - public StringBuilder zTail; /* All SQL text past the last semicolon parsed */ - public Table pNewTable; /* A table being constructed by CREATE TABLE */ - public Trigger pNewTrigger; /* Trigger under construct by a CREATE TRIGGER */ - public string zAuthContext; /* The 6th parameter to db.xAuth callbacks */ + public int regRowid; /* Register holding rowid of CREATE TABLE entry */ + public int regRoot; /* Register holding root page number for new objects */ + public AutoincInfo pAinc; /* Information about AUTOINCREMENT counters */ + public int nMaxArg; /* Max args passed to user function by sub-program */ + + /* Information used while coding trigger programs. */ + public Parse pToplevel; /* Parse structure for main program (or NULL) */ + public Table pTriggerTab; /* Table triggers are being coded for */ + public u32 oldmask; /* Mask of old.* columns referenced */ + public u32 newmask; /* Mask of new.* columns referenced */ + public u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */ + public u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */ + public u8 disableTriggers; /* True to disable triggers */ + public double nQueryLoop; /* Estimated number of iterations of a query */ + + /* Above is constant between recursions. Below is reset before and after + ** each recursion */ + + public int nVar; /* Number of '?' variables seen in the SQL so far */ + public int nzVar; /* Number of available slots in azVar[] */ + public string[] azVar; /* Pointers to names of parameters */ + public Vdbe pReprepare; /* VM being reprepared (sqlite3Reprepare()) */ + public int nAlias; /* Number of aliased result set columns */ + public int nAliasAlloc; /* Number of allocated slots for aAlias[] */ + public int[] aAlias; /* Register used to hold aliased result */ + public u8 explain; /* True if the EXPLAIN flag is found on the query */ + public Token sNameToken; /* Token with unqualified schema object name */ + public Token sLastToken; /* The last token parsed */ + public StringBuilder zTail; /* All SQL text past the last semicolon parsed */ + public Table pNewTable; /* A table being constructed by CREATE TABLE */ + public Trigger pNewTrigger; /* Trigger under construct by a CREATE TRIGGER */ + public string zAuthContext; /* The 6th parameter to db.xAuth callbacks */ #if !SQLITE_OMIT_VIRTUALTABLE - public Token sArg; /* Complete text of a module argument */ - public u8 declareVtab; /* True if inside sqlite3_declare_vtab() */ - public int nVtabLock; /* Number of virtual tables to lock */ - public Table[] apVtabLock; /* Pointer to virtual tables needing locking */ + public Token sArg; /* Complete text of a module argument */ + public u8 declareVtab; /* True if inside sqlite3_declare_vtab() */ + public int nVtabLock; /* Number of virtual tables to lock */ + public Table[] apVtabLock; /* Pointer to virtual tables needing locking */ #endif - public int nHeight; /* Expression tree height of current sub-select */ - public Table pZombieTab; /* List of Table objects to delete after code gen */ - public TriggerPrg pTriggerPrg; /* Linked list of coded triggers */ + public int nHeight; /* Expression tree height of current sub-select */ + public Table pZombieTab; /* List of Table objects to delete after code gen */ + public TriggerPrg pTriggerPrg; /* Linked list of coded triggers */ #if !SQLITE_OMIT_EXPLAIN - public int iSelectId; - public int iNextSelectId; + public int iSelectId; + public int iNextSelectId; #endif - // We need to create instances of the col cache - public Parse() - { - aTempReg = new int[8]; /* Holding area for temporary registers */ + // We need to create instances of the col cache + public Parse() { + aTempReg = new int[8]; /* Holding area for temporary registers */ - aColCache = new yColCache[SQLITE_N_COLCACHE]; /* One for each valid column cache entry */ - for ( int i = 0; i < this.aColCache.Length; i++ ) - { - this.aColCache[i] = new yColCache(); - } + aColCache = new yColCache[SQLITE_N_COLCACHE]; /* One for each valid column cache entry */ + for (int i = 0; i < this.aColCache.Length; i++) { + this.aColCache[i] = new yColCache(); + } - cookieValue = new int[SQLITE_MAX_ATTACHED + 2]; /* Values of cookies to verify */ + cookieValue = new int[SQLITE_MAX_ATTACHED + 2]; /* Values of cookies to verify */ - sLastToken = new Token(); /* The last token parsed */ + sLastToken = new Token(); /* The last token parsed */ #if !SQLITE_OMIT_VIRTUALTABLE - sArg = new Token(); + sArg = new Token(); #endif - } - - public void ResetMembers() // Need to clear all the following variables during each recursion - { - nVar = 0; - nzVar = 0; - azVar = null; - nAlias = 0; - nAliasAlloc = 0; - aAlias = null; - explain = 0; - sNameToken = new Token(); - sLastToken = new Token(); - zTail.Length = 0; - pNewTable = null; - pNewTrigger = null; - zAuthContext = null; + } + + public void ResetMembers() // Need to clear all the following variables during each recursion + { + nVar = 0; + nzVar = 0; + azVar = null; + nAlias = 0; + nAliasAlloc = 0; + aAlias = null; + explain = 0; + sNameToken = new Token(); + sLastToken = new Token(); + zTail.Length = 0; + pNewTable = null; + pNewTrigger = null; + zAuthContext = null; #if !SQLITE_OMIT_VIRTUALTABLE - sArg = new Token(); - declareVtab = 0; - nVtabLock = 0; - apVtabLock = null; + sArg = new Token(); + declareVtab = 0; + nVtabLock = 0; + apVtabLock = null; #endif - nHeight = 0; - pZombieTab = null; - pTriggerPrg = null; - } - Parse[] SaveBuf = new Parse[10]; //For Recursion Storage - public void RestoreMembers() // Need to clear all the following variables during each recursion - { - if ( SaveBuf[nested] != null ) - { - nVar = SaveBuf[nested].nVar; - nzVar = SaveBuf[nested].nzVar; - azVar = SaveBuf[nested].azVar; - nAlias = SaveBuf[nested].nAlias; - nAliasAlloc = SaveBuf[nested].nAliasAlloc; - aAlias = SaveBuf[nested].aAlias; - explain = SaveBuf[nested].explain; - sNameToken = SaveBuf[nested].sNameToken; - sLastToken = SaveBuf[nested].sLastToken; - zTail = SaveBuf[nested].zTail; - pNewTable = SaveBuf[nested].pNewTable; - pNewTrigger = SaveBuf[nested].pNewTrigger; - zAuthContext = SaveBuf[nested].zAuthContext; + nHeight = 0; + pZombieTab = null; + pTriggerPrg = null; + } + Parse[] SaveBuf = new Parse[10]; //For Recursion Storage + public void RestoreMembers() // Need to clear all the following variables during each recursion + { + if (SaveBuf[nested] != null) { + nVar = SaveBuf[nested].nVar; + nzVar = SaveBuf[nested].nzVar; + azVar = SaveBuf[nested].azVar; + nAlias = SaveBuf[nested].nAlias; + nAliasAlloc = SaveBuf[nested].nAliasAlloc; + aAlias = SaveBuf[nested].aAlias; + explain = SaveBuf[nested].explain; + sNameToken = SaveBuf[nested].sNameToken; + sLastToken = SaveBuf[nested].sLastToken; + zTail = SaveBuf[nested].zTail; + pNewTable = SaveBuf[nested].pNewTable; + pNewTrigger = SaveBuf[nested].pNewTrigger; + zAuthContext = SaveBuf[nested].zAuthContext; #if !SQLITE_OMIT_VIRTUALTABLE - sArg = SaveBuf[nested].sArg; - declareVtab = SaveBuf[nested].declareVtab; - nVtabLock = SaveBuf[nested].nVtabLock; - apVtabLock = SaveBuf[nested].apVtabLock; + sArg = SaveBuf[nested].sArg; + declareVtab = SaveBuf[nested].declareVtab; + nVtabLock = SaveBuf[nested].nVtabLock; + apVtabLock = SaveBuf[nested].apVtabLock; #endif - nHeight = SaveBuf[nested].nHeight; - pZombieTab = SaveBuf[nested].pZombieTab; - pTriggerPrg = SaveBuf[nested].pTriggerPrg; - SaveBuf[nested] = null; - } - } - public void SaveMembers() // Need to clear all the following variables during each recursion - { - SaveBuf[nested] = new Parse(); - SaveBuf[nested].nVar = nVar; - SaveBuf[nested].nzVar = nzVar; - SaveBuf[nested].azVar = azVar; - SaveBuf[nested].nAlias = nAlias; - SaveBuf[nested].nAliasAlloc = nAliasAlloc; - SaveBuf[nested].aAlias = aAlias; - SaveBuf[nested].explain = explain; - SaveBuf[nested].sNameToken = sNameToken; - SaveBuf[nested].sLastToken = sLastToken; - SaveBuf[nested].zTail = zTail; - SaveBuf[nested].pNewTable = pNewTable; - SaveBuf[nested].pNewTrigger = pNewTrigger; - SaveBuf[nested].zAuthContext = zAuthContext; + nHeight = SaveBuf[nested].nHeight; + pZombieTab = SaveBuf[nested].pZombieTab; + pTriggerPrg = SaveBuf[nested].pTriggerPrg; + SaveBuf[nested] = null; + } + } + public void SaveMembers() // Need to clear all the following variables during each recursion + { + SaveBuf[nested] = new Parse(); + SaveBuf[nested].nVar = nVar; + SaveBuf[nested].nzVar = nzVar; + SaveBuf[nested].azVar = azVar; + SaveBuf[nested].nAlias = nAlias; + SaveBuf[nested].nAliasAlloc = nAliasAlloc; + SaveBuf[nested].aAlias = aAlias; + SaveBuf[nested].explain = explain; + SaveBuf[nested].sNameToken = sNameToken; + SaveBuf[nested].sLastToken = sLastToken; + SaveBuf[nested].zTail = zTail; + SaveBuf[nested].pNewTable = pNewTable; + SaveBuf[nested].pNewTrigger = pNewTrigger; + SaveBuf[nested].zAuthContext = zAuthContext; #if !SQLITE_OMIT_VIRTUALTABLE - SaveBuf[nested].sArg = sArg; - SaveBuf[nested].declareVtab = declareVtab; - SaveBuf[nested].nVtabLock = nVtabLock; - SaveBuf[nested].apVtabLock = apVtabLock; + SaveBuf[nested].sArg = sArg; + SaveBuf[nested].declareVtab = declareVtab; + SaveBuf[nested].nVtabLock = nVtabLock; + SaveBuf[nested].apVtabLock = apVtabLock; #endif - SaveBuf[nested].nHeight = nHeight; - SaveBuf[nested].pZombieTab = pZombieTab; - SaveBuf[nested].pTriggerPrg = pTriggerPrg; - } - }; + SaveBuf[nested].nHeight = nHeight; + SaveBuf[nested].pZombieTab = pZombieTab; + SaveBuf[nested].pTriggerPrg = pTriggerPrg; + } + }; #if SQLITE_OMIT_VIRTUALTABLE //#define IN_DECLARE_VTAB 0 @@ -3197,528 +3066,490 @@ static bool IN_DECLARE_VTAB( Parse pParse ) return false; } #else - //#define IN_DECLARE_VTAB (pParse.declareVtab) - static bool IN_DECLARE_VTAB( Parse pParse ) - { - return pParse.declareVtab != 0; - } + //#define IN_DECLARE_VTAB (pParse.declareVtab) + static bool IN_DECLARE_VTAB(Parse pParse) { + return pParse.declareVtab != 0; + } #endif - /* -** An instance of the following structure can be declared on a stack and used -** to save the Parse.zAuthContext value so that it can be restored later. -*/ - public class AuthContext - { - public string zAuthContext; /* Put saved Parse.zAuthContext here */ - public Parse pParse; /* The Parse structure */ - }; - - /* - ** Bitfield flags for P5 value in OP_Insert and OP_Delete - */ - //#define OPFLAG_NCHANGE 0x01 /* Set to update db->nChange */ - //#define OPFLAG_LASTROWID 0x02 /* Set to update db->lastRowid */ - //#define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */ - //#define OPFLAG_APPEND 0x08 /* This is likely to be an append */ - //#define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */ - //#define OPFLAG_CLEARCACHE 0x20 /* Clear pseudo-table cache in OP_Column */ - const byte OPFLAG_NCHANGE = 0x01; - const byte OPFLAG_LASTROWID = 0x02; - const byte OPFLAG_ISUPDATE = 0x04; - const byte OPFLAG_APPEND = 0x08; - const byte OPFLAG_USESEEKRESULT = 0x10; - const byte OPFLAG_CLEARCACHE = 0x20; - - /* - * Each trigger present in the database schema is stored as an instance of - * struct Trigger. - * - * Pointers to instances of struct Trigger are stored in two ways. - * 1. In the "trigHash" hash table (part of the sqlite3* that represents the - * database). This allows Trigger structures to be retrieved by name. - * 2. All triggers associated with a single table form a linked list, using the - * pNext member of struct Trigger. A pointer to the first element of the - * linked list is stored as the "pTrigger" member of the associated - * struct Table. - * - * The "step_list" member points to the first element of a linked list - * containing the SQL statements specified as the trigger program. + /* + ** An instance of the following structure can be declared on a stack and used + ** to save the Parse.zAuthContext value so that it can be restored later. */ - public class Trigger - { - public string zName; /* The name of the trigger */ - public string table; /* The table or view to which the trigger applies */ - public u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT */ - public u8 tr_tm; /* One of TRIGGER_BEFORE, TRIGGER_AFTER */ - public Expr pWhen; /* The WHEN clause of the expression (may be NULL) */ - public IdList pColumns; /* If this is an UPDATE OF trigger, + public class AuthContext { + public string zAuthContext; /* Put saved Parse.zAuthContext here */ + public Parse pParse; /* The Parse structure */ + }; + + /* + ** Bitfield flags for P5 value in OP_Insert and OP_Delete + */ + //#define OPFLAG_NCHANGE 0x01 /* Set to update db->nChange */ + //#define OPFLAG_LASTROWID 0x02 /* Set to update db->lastRowid */ + //#define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */ + //#define OPFLAG_APPEND 0x08 /* This is likely to be an append */ + //#define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */ + //#define OPFLAG_CLEARCACHE 0x20 /* Clear pseudo-table cache in OP_Column */ + const byte OPFLAG_NCHANGE = 0x01; + const byte OPFLAG_LASTROWID = 0x02; + const byte OPFLAG_ISUPDATE = 0x04; + const byte OPFLAG_APPEND = 0x08; + const byte OPFLAG_USESEEKRESULT = 0x10; + const byte OPFLAG_CLEARCACHE = 0x20; + + /* + * Each trigger present in the database schema is stored as an instance of + * struct Trigger. + * + * Pointers to instances of struct Trigger are stored in two ways. + * 1. In the "trigHash" hash table (part of the sqlite3* that represents the + * database). This allows Trigger structures to be retrieved by name. + * 2. All triggers associated with a single table form a linked list, using the + * pNext member of struct Trigger. A pointer to the first element of the + * linked list is stored as the "pTrigger" member of the associated + * struct Table. + * + * The "step_list" member points to the first element of a linked list + * containing the SQL statements specified as the trigger program. + */ + public class Trigger { + public string zName; /* The name of the trigger */ + public string table; /* The table or view to which the trigger applies */ + public u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT */ + public u8 tr_tm; /* One of TRIGGER_BEFORE, TRIGGER_AFTER */ + public Expr pWhen; /* The WHEN clause of the expression (may be NULL) */ + public IdList pColumns; /* If this is an UPDATE OF trigger, the is stored here */ - public Schema pSchema; /* Schema containing the trigger */ - public Schema pTabSchema; /* Schema containing the table */ - public TriggerStep step_list; /* Link list of trigger program steps */ - public Trigger pNext; /* Next trigger associated with the table */ - - public Trigger Copy() - { - if ( this == null ) - return null; - else - { - Trigger cp = (Trigger)MemberwiseClone(); - if ( pWhen != null ) - cp.pWhen = pWhen.Copy(); - if ( pColumns != null ) - cp.pColumns = pColumns.Copy(); - if ( pSchema != null ) - cp.pSchema = pSchema.Copy(); - if ( pTabSchema != null ) - cp.pTabSchema = pTabSchema.Copy(); - if ( step_list != null ) - cp.step_list = step_list.Copy(); - if ( pNext != null ) - cp.pNext = pNext.Copy(); - return cp; + public Schema pSchema; /* Schema containing the trigger */ + public Schema pTabSchema; /* Schema containing the table */ + public TriggerStep step_list; /* Link list of trigger program steps */ + public Trigger pNext; /* Next trigger associated with the table */ + + public Trigger Copy() { + if (this == null) + return null; + else { + Trigger cp = (Trigger)MemberwiseClone(); + if (pWhen != null) + cp.pWhen = pWhen.Copy(); + if (pColumns != null) + cp.pColumns = pColumns.Copy(); + if (pSchema != null) + cp.pSchema = pSchema.Copy(); + if (pTabSchema != null) + cp.pTabSchema = pTabSchema.Copy(); + if (step_list != null) + cp.step_list = step_list.Copy(); + if (pNext != null) + cp.pNext = pNext.Copy(); + return cp; + } + } + }; + + /* + ** A trigger is either a BEFORE or an AFTER trigger. The following constants + ** determine which. + ** + ** If there are multiple triggers, you might of some BEFORE and some AFTER. + ** In that cases, the constants below can be ORed together. + */ + const u8 TRIGGER_BEFORE = 1;//#define TRIGGER_BEFORE 1 + const u8 TRIGGER_AFTER = 2;//#define TRIGGER_AFTER 2 + + /* + * An instance of struct TriggerStep is used to store a single SQL statement + * that is a part of a trigger-program. + * + * Instances of struct TriggerStep are stored in a singly linked list (linked + * using the "pNext" member) referenced by the "step_list" member of the + * associated struct Trigger instance. The first element of the linked list is + * the first step of the trigger-program. + * + * The "op" member indicates whether this is a "DELETE", "INSERT", "UPDATE" or + * "SELECT" statement. The meanings of the other members is determined by the + * value of "op" as follows: + * + * (op == TK_INSERT) + * orconf -> stores the ON CONFLICT algorithm + * pSelect -> If this is an INSERT INTO ... SELECT ... statement, then + * this stores a pointer to the SELECT statement. Otherwise NULL. + * target -> A token holding the quoted name of the table to insert into. + * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then + * this stores values to be inserted. Otherwise NULL. + * pIdList -> If this is an INSERT INTO ... () VALUES ... + * statement, then this stores the column-names to be + * inserted into. + * + * (op == TK_DELETE) + * target -> A token holding the quoted name of the table to delete from. + * pWhere -> The WHERE clause of the DELETE statement if one is specified. + * Otherwise NULL. + * + * (op == TK_UPDATE) + * target -> A token holding the quoted name of the table to update rows of. + * pWhere -> The WHERE clause of the UPDATE statement if one is specified. + * Otherwise NULL. + * pExprList -> A list of the columns to update and the expressions to update + * them to. See sqlite3Update() documentation of "pChanges" + * argument. + * + */ + public class TriggerStep { + public u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */ + public u8 orconf; /* OE_Rollback etc. */ + public Trigger pTrig; /* The trigger that this step is a part of */ + public Select pSelect; /* SELECT statment or RHS of INSERT INTO .. SELECT ... */ + public Token target; /* Target table for DELETE, UPDATE, INSERT */ + public Expr pWhere; /* The WHERE clause for DELETE or UPDATE steps */ + public ExprList pExprList; /* SET clause for UPDATE. VALUES clause for INSERT */ + public IdList pIdList; /* Column names for INSERT */ + public TriggerStep pNext; /* Next in the link-list */ + public TriggerStep pLast; /* Last element in link-list. Valid for 1st elem only */ + + public TriggerStep() { + target = new Token(); + } + public TriggerStep Copy() { + if (this == null) + return null; + else { + TriggerStep cp = (TriggerStep)MemberwiseClone(); + return cp; + } + } + }; + + /* + ** The following structure contains information used by the sqliteFix... + ** routines as they walk the parse tree to make database references + ** explicit. + */ + //typedef struct DbFixer DbFixer; + public class DbFixer { + public Parse pParse; /* The parsing context. Error messages written here */ + public string zDb; /* Make sure all objects are contained in this database */ + public string zType; /* Type of the container - used for error messages */ + public Token pName; /* Name of the container - used for error messages */ + }; + + /* + ** An objected used to accumulate the text of a string where we + ** do not necessarily know how big the string will be in the end. + */ + public class StrAccum { + public sqlite3 db; /* Optional database for lookaside. Can be NULL */ + //public StringBuilder zBase; /* A base allocation. Not from malloc. */ + public StringBuilder zText; /* The string collected so far */ + //public int nChar; /* Length of the string so far */ + //public int nAlloc; /* Amount of space allocated in zText */ + public int mxAlloc; /* Maximum allowed string length */ + // Cannot happen under C# + //public u8 mallocFailed; /* Becomes true if any memory allocation fails */ + //public u8 useMalloc; /* 0: none, 1: sqlite3DbMalloc, 2: sqlite3_malloc */ + //public u8 tooBig; /* Becomes true if string size exceeds limits */ + public Mem Context; + + public StrAccum(int n) { + db = null; + //zBase = new StringBuilder( n ); + zText = new StringBuilder(n); + //nChar = 0; + //nAlloc = n; + mxAlloc = 0; + //useMalloc = 0; + //tooBig = 0; + Context = null; + } + + public i64 nChar { + get { + return zText.Length; + } + } + + public bool tooBig { + get { + return mxAlloc > 0 && zText.Length > mxAlloc; + } + } + }; + + /* + ** A pointer to this structure is used to communicate information + ** from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback. + */ + public class InitData { + public sqlite3 db; /* The database being initialized */ + public int iDb; /* 0 for main database. 1 for TEMP, 2.. for ATTACHed */ + public string pzErrMsg; /* Error message stored here */ + public int rc; /* Result code stored here */ } - } - }; - /* - ** A trigger is either a BEFORE or an AFTER trigger. The following constants - ** determine which. - ** - ** If there are multiple triggers, you might of some BEFORE and some AFTER. - ** In that cases, the constants below can be ORed together. - */ - const u8 TRIGGER_BEFORE = 1;//#define TRIGGER_BEFORE 1 - const u8 TRIGGER_AFTER = 2;//#define TRIGGER_AFTER 2 - - /* - * An instance of struct TriggerStep is used to store a single SQL statement - * that is a part of a trigger-program. - * - * Instances of struct TriggerStep are stored in a singly linked list (linked - * using the "pNext" member) referenced by the "step_list" member of the - * associated struct Trigger instance. The first element of the linked list is - * the first step of the trigger-program. - * - * The "op" member indicates whether this is a "DELETE", "INSERT", "UPDATE" or - * "SELECT" statement. The meanings of the other members is determined by the - * value of "op" as follows: - * - * (op == TK_INSERT) - * orconf -> stores the ON CONFLICT algorithm - * pSelect -> If this is an INSERT INTO ... SELECT ... statement, then - * this stores a pointer to the SELECT statement. Otherwise NULL. - * target -> A token holding the quoted name of the table to insert into. - * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then - * this stores values to be inserted. Otherwise NULL. - * pIdList -> If this is an INSERT INTO ... () VALUES ... - * statement, then this stores the column-names to be - * inserted into. - * - * (op == TK_DELETE) - * target -> A token holding the quoted name of the table to delete from. - * pWhere -> The WHERE clause of the DELETE statement if one is specified. - * Otherwise NULL. - * - * (op == TK_UPDATE) - * target -> A token holding the quoted name of the table to update rows of. - * pWhere -> The WHERE clause of the UPDATE statement if one is specified. - * Otherwise NULL. - * pExprList -> A list of the columns to update and the expressions to update - * them to. See sqlite3Update() documentation of "pChanges" - * argument. - * - */ - public class TriggerStep - { - public u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */ - public u8 orconf; /* OE_Rollback etc. */ - public Trigger pTrig; /* The trigger that this step is a part of */ - public Select pSelect; /* SELECT statment or RHS of INSERT INTO .. SELECT ... */ - public Token target; /* Target table for DELETE, UPDATE, INSERT */ - public Expr pWhere; /* The WHERE clause for DELETE or UPDATE steps */ - public ExprList pExprList; /* SET clause for UPDATE. VALUES clause for INSERT */ - public IdList pIdList; /* Column names for INSERT */ - public TriggerStep pNext; /* Next in the link-list */ - public TriggerStep pLast; /* Last element in link-list. Valid for 1st elem only */ - - public TriggerStep() - { - target = new Token(); - } - public TriggerStep Copy() - { - if ( this == null ) - return null; - else - { - TriggerStep cp = (TriggerStep)MemberwiseClone(); - return cp; - } - } - }; - - /* - ** The following structure contains information used by the sqliteFix... - ** routines as they walk the parse tree to make database references - ** explicit. - */ - //typedef struct DbFixer DbFixer; - public class DbFixer - { - public Parse pParse; /* The parsing context. Error messages written here */ - public string zDb; /* Make sure all objects are contained in this database */ - public string zType; /* Type of the container - used for error messages */ - public Token pName; /* Name of the container - used for error messages */ - }; - - /* - ** An objected used to accumulate the text of a string where we - ** do not necessarily know how big the string will be in the end. - */ - public class StrAccum - { - public sqlite3 db; /* Optional database for lookaside. Can be NULL */ - //public StringBuilder zBase; /* A base allocation. Not from malloc. */ - public StringBuilder zText; /* The string collected so far */ - //public int nChar; /* Length of the string so far */ - //public int nAlloc; /* Amount of space allocated in zText */ - public int mxAlloc; /* Maximum allowed string length */ - // Cannot happen under C# - //public u8 mallocFailed; /* Becomes true if any memory allocation fails */ - //public u8 useMalloc; /* 0: none, 1: sqlite3DbMalloc, 2: sqlite3_malloc */ - //public u8 tooBig; /* Becomes true if string size exceeds limits */ - public Mem Context; - - public StrAccum( int n ) - { - db = null; - //zBase = new StringBuilder( n ); - zText = new StringBuilder( n ); - //nChar = 0; - //nAlloc = n; - mxAlloc = 0; - //useMalloc = 0; - //tooBig = 0; - Context = null; - } - - public i64 nChar - { - get - { - return zText.Length; + /* + ** Structure containing global configuration data for the SQLite library. + ** + ** This structure also contains some state information. + */ + public class Sqlite3Config { + public bool bMemstat; /* True to enable memory status */ + public bool bCoreMutex; /* True to enable core mutexing */ + public bool bFullMutex; /* True to enable full mutexing */ + public bool bOpenUri; /* True to interpret filenames as URIs */ + public int mxStrlen; /* Maximum string length */ + public int szLookaside; /* Default lookaside buffer size */ + public int nLookaside; /* Default lookaside buffer count */ + public sqlite3_mem_methods m; /* Low-level memory allocation interface */ + public sqlite3_mutex_methods mutex; /* Low-level mutex interface */ + public sqlite3_pcache_methods pcache; /* Low-level page-cache interface */ + public byte[] pHeap; /* Heap storage space */ + public int nHeap; /* Size of pHeap[] */ + public int mnReq, mxReq; /* Min and max heap requests sizes */ + public byte[][] pScratch2; /* Scratch memory */ + public byte[][] pScratch; /* Scratch memory */ + public int szScratch; /* Size of each scratch buffer */ + public int nScratch; /* Number of scratch buffers */ + public MemPage pPage; /* Page cache memory */ + public int szPage; /* Size of each page in pPage[] */ + public int nPage; /* Number of pages in pPage[] */ + public int mxParserStack; /* maximum depth of the parser stack */ + public bool sharedCacheEnabled; /* true if shared-cache mode enabled */ + /* The above might be initialized to non-zero. The following need to always + ** initially be zero, however. */ + public int isInit; /* True after initialization has finished */ + public int inProgress; /* True while initialization in progress */ + public int isMutexInit; /* True after mutexes are initialized */ + public int isMallocInit; /* True after malloc is initialized */ + public int isPCacheInit; /* True after malloc is initialized */ + public sqlite3_mutex pInitMutex; /* Mutex used by sqlite3_initialize() */ + public int nRefInitMutex; /* Number of users of pInitMutex */ + public dxLog xLog; //void (*xLog)(void*,int,const char); /* Function for logging */ + public object pLogArg; /* First argument to xLog() */ + public bool bLocaltimeFault; /* True to fail localtime() calls */ + + public Sqlite3Config( + int bMemstat + , int bCoreMutex + , bool bFullMutex + , bool bOpenUri + , int mxStrlen + , int szLookaside + , int nLookaside + , sqlite3_mem_methods m + , sqlite3_mutex_methods mutex + , sqlite3_pcache_methods pcache + , byte[] pHeap + , int nHeap + , int mnReq + , int mxReq + , byte[][] pScratch + , int szScratch + , int nScratch + , MemPage pPage + , int szPage + , int nPage + , int mxParserStack + , bool sharedCacheEnabled + , int isInit + , int inProgress + , int isMutexInit + , int isMallocInit + , int isPCacheInit + , sqlite3_mutex pInitMutex + , int nRefInitMutex + , dxLog xLog + , object pLogArg + , bool bLocaltimeFault + ) { + this.bMemstat = bMemstat != 0; + this.bCoreMutex = bCoreMutex != 0; + this.bOpenUri = bOpenUri; + this.bFullMutex = bFullMutex; + this.mxStrlen = mxStrlen; + this.szLookaside = szLookaside; + this.nLookaside = nLookaside; + this.m = m; + this.mutex = mutex; + this.pcache = pcache; + this.pHeap = pHeap; + this.nHeap = nHeap; + this.mnReq = mnReq; + this.mxReq = mxReq; + this.pScratch = pScratch; + this.szScratch = szScratch; + this.nScratch = nScratch; + this.pPage = pPage; + this.szPage = szPage; + this.nPage = nPage; + this.mxParserStack = mxParserStack; + this.sharedCacheEnabled = sharedCacheEnabled; + this.isInit = isInit; + this.inProgress = inProgress; + this.isMutexInit = isMutexInit; + this.isMallocInit = isMallocInit; + this.isPCacheInit = isPCacheInit; + this.pInitMutex = pInitMutex; + this.nRefInitMutex = nRefInitMutex; + this.xLog = xLog; + this.pLogArg = pLogArg; + this.bLocaltimeFault = bLocaltimeFault; + } + }; + + /* + ** Context pointer passed down through the tree-walk. + */ + public class Walker { + public dxExprCallback xExprCallback; //)(Walker*, Expr); /* Callback for expressions */ + public dxSelectCallback xSelectCallback; //)(Walker*,Select); /* Callback for SELECTs */ + public Parse pParse; /* Parser context. */ + public struct uw { /* Extra data for callback */ + public NameContext pNC; /* Naming context */ + public int i; /* Integer value */ + } + public uw u; + }; + + /* Forward declarations */ + //int sqlite3WalkExpr(Walker*, Expr); + //int sqlite3WalkExprList(Walker*, ExprList); + //int sqlite3WalkSelect(Walker*, Select); + //int sqlite3WalkSelectExpr(Walker*, Select); + //int sqlite3WalkSelectFrom(Walker*, Select); + + /* + ** Return code from the parse-tree walking primitives and their + ** callbacks. + */ + //#define WRC_Continue 0 /* Continue down into children */ + //#define WRC_Prune 1 /* Omit children but continue walking siblings */ + //#define WRC_Abort 2 /* Abandon the tree walk */ + const int WRC_Continue = 0; + const int WRC_Prune = 1; + const int WRC_Abort = 2; + + + /* + ** Assuming zIn points to the first byte of a UTF-8 character, + ** advance zIn to point to the first byte of the next UTF-8 character. + */ + //#define SQLITE_SKIP_UTF8(zIn) { \ + // if( (*(zIn++))>=0xc0 ){ \ + // while( (*zIn & 0xc0)==0x80 ){ zIn++; } \ + // } \ + //} + static void SQLITE_SKIP_UTF8(string zIn, ref int iz) { + iz++; + if (iz < zIn.Length && zIn[iz - 1] >= 0xC0) { + while (iz < zIn.Length && (zIn[iz] & 0xC0) == 0x80) { + iz++; + } + } } - } - - public bool tooBig - { - get - { - return mxAlloc > 0 && zText.Length > mxAlloc; + static void SQLITE_SKIP_UTF8( + byte[] zIn, ref int iz) { + iz++; + if (iz < zIn.Length && zIn[iz - 1] >= 0xC0) { + while (iz < zIn.Length && (zIn[iz] & 0xC0) == 0x80) { + iz++; + } + } } - } - }; - - /* - ** A pointer to this structure is used to communicate information - ** from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback. - */ - public class InitData - { - public sqlite3 db; /* The database being initialized */ - public int iDb; /* 0 for main database. 1 for TEMP, 2.. for ATTACHed */ - public string pzErrMsg; /* Error message stored here */ - public int rc; /* Result code stored here */ - } - - /* - ** Structure containing global configuration data for the SQLite library. - ** - ** This structure also contains some state information. - */ - public class Sqlite3Config - { - public bool bMemstat; /* True to enable memory status */ - public bool bCoreMutex; /* True to enable core mutexing */ - public bool bFullMutex; /* True to enable full mutexing */ - public bool bOpenUri; /* True to interpret filenames as URIs */ - public int mxStrlen; /* Maximum string length */ - public int szLookaside; /* Default lookaside buffer size */ - public int nLookaside; /* Default lookaside buffer count */ - public sqlite3_mem_methods m; /* Low-level memory allocation interface */ - public sqlite3_mutex_methods mutex; /* Low-level mutex interface */ - public sqlite3_pcache_methods pcache; /* Low-level page-cache interface */ - public byte[] pHeap; /* Heap storage space */ - public int nHeap; /* Size of pHeap[] */ - public int mnReq, mxReq; /* Min and max heap requests sizes */ - public byte[][] pScratch2; /* Scratch memory */ - public byte[][] pScratch; /* Scratch memory */ - public int szScratch; /* Size of each scratch buffer */ - public int nScratch; /* Number of scratch buffers */ - public MemPage pPage; /* Page cache memory */ - public int szPage; /* Size of each page in pPage[] */ - public int nPage; /* Number of pages in pPage[] */ - public int mxParserStack; /* maximum depth of the parser stack */ - public bool sharedCacheEnabled; /* true if shared-cache mode enabled */ - /* The above might be initialized to non-zero. The following need to always - ** initially be zero, however. */ - public int isInit; /* True after initialization has finished */ - public int inProgress; /* True while initialization in progress */ - public int isMutexInit; /* True after mutexes are initialized */ - public int isMallocInit; /* True after malloc is initialized */ - public int isPCacheInit; /* True after malloc is initialized */ - public sqlite3_mutex pInitMutex; /* Mutex used by sqlite3_initialize() */ - public int nRefInitMutex; /* Number of users of pInitMutex */ - public dxLog xLog; //void (*xLog)(void*,int,const char); /* Function for logging */ - public object pLogArg; /* First argument to xLog() */ - public bool bLocaltimeFault; /* True to fail localtime() calls */ - - public Sqlite3Config( - int bMemstat - , int bCoreMutex - , bool bFullMutex - , bool bOpenUri - , int mxStrlen - , int szLookaside - , int nLookaside - , sqlite3_mem_methods m - , sqlite3_mutex_methods mutex - , sqlite3_pcache_methods pcache - , byte[] pHeap - , int nHeap - , int mnReq - , int mxReq - , byte[][] pScratch - , int szScratch - , int nScratch - , MemPage pPage - , int szPage - , int nPage - , int mxParserStack - , bool sharedCacheEnabled - , int isInit - , int inProgress - , int isMutexInit - , int isMallocInit - , int isPCacheInit - , sqlite3_mutex pInitMutex - , int nRefInitMutex - , dxLog xLog - , object pLogArg - , bool bLocaltimeFault - ) - { - this.bMemstat = bMemstat != 0; - this.bCoreMutex = bCoreMutex != 0; - this.bOpenUri = bOpenUri; - this.bFullMutex = bFullMutex; - this.mxStrlen = mxStrlen; - this.szLookaside = szLookaside; - this.nLookaside = nLookaside; - this.m = m; - this.mutex = mutex; - this.pcache = pcache; - this.pHeap = pHeap; - this.nHeap = nHeap; - this.mnReq = mnReq; - this.mxReq = mxReq; - this.pScratch = pScratch; - this.szScratch = szScratch; - this.nScratch = nScratch; - this.pPage = pPage; - this.szPage = szPage; - this.nPage = nPage; - this.mxParserStack = mxParserStack; - this.sharedCacheEnabled = sharedCacheEnabled; - this.isInit = isInit; - this.inProgress = inProgress; - this.isMutexInit = isMutexInit; - this.isMallocInit = isMallocInit; - this.isPCacheInit = isPCacheInit; - this.pInitMutex = pInitMutex; - this.nRefInitMutex = nRefInitMutex; - this.xLog = xLog; - this.pLogArg = pLogArg; - this.bLocaltimeFault = bLocaltimeFault; - } - }; - - /* - ** Context pointer passed down through the tree-walk. - */ - public class Walker - { - public dxExprCallback xExprCallback; //)(Walker*, Expr); /* Callback for expressions */ - public dxSelectCallback xSelectCallback; //)(Walker*,Select); /* Callback for SELECTs */ - public Parse pParse; /* Parser context. */ - public struct uw - { /* Extra data for callback */ - public NameContext pNC; /* Naming context */ - public int i; /* Integer value */ - } - public uw u; - }; - - /* Forward declarations */ - //int sqlite3WalkExpr(Walker*, Expr); - //int sqlite3WalkExprList(Walker*, ExprList); - //int sqlite3WalkSelect(Walker*, Select); - //int sqlite3WalkSelectExpr(Walker*, Select); - //int sqlite3WalkSelectFrom(Walker*, Select); - - /* - ** Return code from the parse-tree walking primitives and their - ** callbacks. - */ - //#define WRC_Continue 0 /* Continue down into children */ - //#define WRC_Prune 1 /* Omit children but continue walking siblings */ - //#define WRC_Abort 2 /* Abandon the tree walk */ - const int WRC_Continue = 0; - const int WRC_Prune = 1; - const int WRC_Abort = 2; + /* + ** The SQLITE_*_BKPT macros are substitutes for the error codes with + ** the same name but without the _BKPT suffix. These macros invoke + ** routines that report the line-number on which the error originated + ** using sqlite3_log(). The routines also provide a convenient place + ** to set a debugger breakpoint. + */ + //int sqlite3CorruptError(int); + //int sqlite3MisuseError(int); + //int sqlite3CantopenError(int); +#if DEBUG - /* - ** Assuming zIn points to the first byte of a UTF-8 character, - ** advance zIn to point to the first byte of the next UTF-8 character. - */ - //#define SQLITE_SKIP_UTF8(zIn) { \ - // if( (*(zIn++))>=0xc0 ){ \ - // while( (*zIn & 0xc0)==0x80 ){ zIn++; } \ - // } \ - //} - static void SQLITE_SKIP_UTF8( string zIn, ref int iz ) - { - iz++; - if ( iz < zIn.Length && zIn[iz - 1] >= 0xC0 ) - { - while ( iz < zIn.Length && ( zIn[iz] & 0xC0 ) == 0x80 ) - { - iz++; - } - } - } - static void SQLITE_SKIP_UTF8( - byte[] zIn, ref int iz ) - { - iz++; - if ( iz < zIn.Length && zIn[iz - 1] >= 0xC0 ) - { - while ( iz < zIn.Length && ( zIn[iz] & 0xC0 ) == 0x80 ) - { - iz++; + //#define SQLITE_CORRUPT_BKPT sqlite3CorruptError(__LINE__) + static int SQLITE_CORRUPT_BKPT() { + return sqlite3CorruptError(0); } - } - } - - /* - ** The SQLITE_*_BKPT macros are substitutes for the error codes with - ** the same name but without the _BKPT suffix. These macros invoke - ** routines that report the line-number on which the error originated - ** using sqlite3_log(). The routines also provide a convenient place - ** to set a debugger breakpoint. - */ - //int sqlite3CorruptError(int); - //int sqlite3MisuseError(int); - //int sqlite3CantopenError(int); -#if DEBUG - - //#define SQLITE_CORRUPT_BKPT sqlite3CorruptError(__LINE__) - static int SQLITE_CORRUPT_BKPT() - { - return sqlite3CorruptError( 0 ); - } - //#define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__) - static int SQLITE_MISUSE_BKPT() - { - return sqlite3MisuseError( 0 ); - } + //#define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__) + static int SQLITE_MISUSE_BKPT() { + return sqlite3MisuseError(0); + } - //#define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__) - static int SQLITE_CANTOPEN_BKPT() - { - return sqlite3CantopenError( 0 ); - } + //#define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__) + static int SQLITE_CANTOPEN_BKPT() { + return sqlite3CantopenError(0); + } #else static int SQLITE_CORRUPT_BKPT() {return SQLITE_CORRUPT;} static int SQLITE_MISUSE_BKPT() {return SQLITE_MISUSE;} static int SQLITE_CANTOPEN_BKPT() {return SQLITE_CANTOPEN;} #endif - /* -** FTS4 is really an extension for FTS3. It is enabled using the -** SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also all -** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3. -*/ - //#if (SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3) - //# define SQLITE_ENABLE_FTS3 - //#endif - - /* - ** The ctype.h header is needed for non-ASCII systems. It is also - ** needed by FTS3 when FTS3 is included in the amalgamation. - */ - //#if !defined(SQLITE_ASCII) || \ - // (defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_AMALGAMATION)) - //# include - //#endif - - - /* - ** The following macros mimic the standard library functions toupper(), - ** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The - ** sqlite versions only work for ASCII characters, regardless of locale. + /* + ** FTS4 is really an extension for FTS3. It is enabled using the + ** SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also all + ** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3. */ + //#if (SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3) + //# define SQLITE_ENABLE_FTS3 + //#endif + + /* + ** The ctype.h header is needed for non-ASCII systems. It is also + ** needed by FTS3 when FTS3 is included in the amalgamation. + */ + //#if !defined(SQLITE_ASCII) || \ + // (defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_AMALGAMATION)) + //# include + //#endif + + + /* + ** The following macros mimic the standard library functions toupper(), + ** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The + ** sqlite versions only work for ASCII characters, regardless of locale. + */ #if SQLITE_ASCII - //# define sqlite3Toupper(x) ((x)&~(sqlite3CtypeMap[(unsigned char)(x)]&0x20)) + //# define sqlite3Toupper(x) ((x)&~(sqlite3CtypeMap[(unsigned char)(x)]&0x20)) - //# define sqlite3Isspace(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x01) - static bool sqlite3Isspace( byte x ) - { - return ( sqlite3CtypeMap[(byte)( x )] & 0x01 ) != 0; - } - static bool sqlite3Isspace( char x ) - { - return x < 256 && ( sqlite3CtypeMap[(byte)( x )] & 0x01 ) != 0; - } + //# define sqlite3Isspace(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x01) + static bool sqlite3Isspace(byte x) { + return (sqlite3CtypeMap[(byte)(x)] & 0x01) != 0; + } + static bool sqlite3Isspace(char x) { + return x < 256 && (sqlite3CtypeMap[(byte)(x)] & 0x01) != 0; + } - //# define sqlite3Isalnum(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x06) - static bool sqlite3Isalnum( byte x ) - { - return ( sqlite3CtypeMap[(byte)( x )] & 0x06 ) != 0; - } - static bool sqlite3Isalnum( char x ) - { - return x < 256 && ( sqlite3CtypeMap[(byte)( x )] & 0x06 ) != 0; - } + //# define sqlite3Isalnum(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x06) + static bool sqlite3Isalnum(byte x) { + return (sqlite3CtypeMap[(byte)(x)] & 0x06) != 0; + } + static bool sqlite3Isalnum(char x) { + return x < 256 && (sqlite3CtypeMap[(byte)(x)] & 0x06) != 0; + } - //# define sqlite3Isalpha(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x02) + //# define sqlite3Isalpha(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x02) - //# define sqlite3Isdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x04) - static bool sqlite3Isdigit( byte x ) - { - return ( sqlite3CtypeMap[( (byte)x )] & 0x04 ) != 0; - } - static bool sqlite3Isdigit( char x ) - { - return x < 256 && ( sqlite3CtypeMap[( (byte)x )] & 0x04 ) != 0; - } + //# define sqlite3Isdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x04) + static bool sqlite3Isdigit(byte x) { + return (sqlite3CtypeMap[((byte)x)] & 0x04) != 0; + } + static bool sqlite3Isdigit(char x) { + return x < 256 && (sqlite3CtypeMap[((byte)x)] & 0x04) != 0; + } - //# define sqlite3Isxdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x08) - static bool sqlite3Isxdigit( byte x ) - { - return ( sqlite3CtypeMap[( (byte)x )] & 0x08 ) != 0; - } - static bool sqlite3Isxdigit( char x ) - { - return x < 256 && ( sqlite3CtypeMap[( (byte)x )] & 0x08 ) != 0; - } + //# define sqlite3Isxdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x08) + static bool sqlite3Isxdigit(byte x) { + return (sqlite3CtypeMap[((byte)x)] & 0x08) != 0; + } + static bool sqlite3Isxdigit(char x) { + return x < 256 && (sqlite3CtypeMap[((byte)x)] & 0x08) != 0; + } - //# define sqlite3Tolower(x) (sqlite3UpperToLower[(unsigned char)(x)]) + //# define sqlite3Tolower(x) (sqlite3UpperToLower[(unsigned char)(x)]) #else //# define sqlite3Toupper(x) toupper((unsigned char)(x)) //# define sqlite3Isspace(x) isspace((unsigned char)(x)) @@ -3729,43 +3560,43 @@ static bool sqlite3Isxdigit( char x ) //# define sqlite3Tolower(x) tolower((unsigned char)(x)) #endif - /* -** Internal function prototypes -*/ - //int sqlite3StrICmp(string , string ); - //int sqlite3Strlen30(const char); - //#define sqlite3StrNICmp sqlite3_strnicmp - - //int sqlite3MallocInit(void); - //void sqlite3MallocEnd(void); - //void *sqlite3Malloc(int); - //void *sqlite3MallocZero(int); - //void *sqlite3DbMallocZero(sqlite3*, int); - //void *sqlite3DbMallocRaw(sqlite3*, int); - //char *sqlite3DbStrDup(sqlite3*,const char); - //char *sqlite3DbStrNDup(sqlite3*,const char*, int); - //void *sqlite3Realloc(void*, int); - //void *sqlite3DbReallocOrFree(sqlite3 *, object *, int); - //void *sqlite3DbRealloc(sqlite3 *, object *, int); - //void sqlite3DbFree(sqlite3*, void); - //int sqlite3MallocSize(void); - //int sqlite3DbMallocSize(sqlite3*, void); - //void *sqlite3ScratchMalloc(int); - //void //sqlite3ScratchFree(void); - //void *sqlite3PageMalloc(int); - //void sqlite3PageFree(void); - //void sqlite3MemSetDefault(void); - //void sqlite3BenignMallocHooks(void ()(void), object ()(void)); - //int sqlite3HeapNearlyFull(void); - - /* - ** On systems with ample stack space and that support alloca(), make - ** use of alloca() to obtain space for large automatic objects. By default, - ** obtain space from malloc(). - ** - ** The alloca() routine never returns NULL. This will cause code paths - ** that deal with sqlite3StackAlloc() failures to be unreachable. + /* + ** Internal function prototypes */ + //int sqlite3StrICmp(string , string ); + //int sqlite3Strlen30(const char); + //#define sqlite3StrNICmp sqlite3_strnicmp + + //int sqlite3MallocInit(void); + //void sqlite3MallocEnd(void); + //void *sqlite3Malloc(int); + //void *sqlite3MallocZero(int); + //void *sqlite3DbMallocZero(sqlite3*, int); + //void *sqlite3DbMallocRaw(sqlite3*, int); + //char *sqlite3DbStrDup(sqlite3*,const char); + //char *sqlite3DbStrNDup(sqlite3*,const char*, int); + //void *sqlite3Realloc(void*, int); + //void *sqlite3DbReallocOrFree(sqlite3 *, object *, int); + //void *sqlite3DbRealloc(sqlite3 *, object *, int); + //void sqlite3DbFree(sqlite3*, void); + //int sqlite3MallocSize(void); + //int sqlite3DbMallocSize(sqlite3*, void); + //void *sqlite3ScratchMalloc(int); + //void //sqlite3ScratchFree(void); + //void *sqlite3PageMalloc(int); + //void sqlite3PageFree(void); + //void sqlite3MemSetDefault(void); + //void sqlite3BenignMallocHooks(void ()(void), object ()(void)); + //int sqlite3HeapNearlyFull(void); + + /* + ** On systems with ample stack space and that support alloca(), make + ** use of alloca() to obtain space for large automatic objects. By default, + ** obtain space from malloc(). + ** + ** The alloca() routine never returns NULL. This will cause code paths + ** that deal with sqlite3StackAlloc() failures to be unreachable. + */ #if SQLITE_USE_ALLOCA //# define sqlite3StackAllocRaw(D,N) alloca(N) //# define sqlite3StackAllocZero(D,N) memset(alloca(N), 0, N) @@ -3789,96 +3620,96 @@ static bool sqlite3Isxdigit( char x ) #endif #if !SQLITE_MUTEX_OMIT - // sqlite3_mutex_methods const *sqlite3DefaultMutex(void); - // sqlite3_mutex_methods const *sqlite3NoopMutex(void); - // sqlite3_mutex *sqlite3MutexAlloc(int); - // int sqlite3MutexInit(void); - // int sqlite3MutexEnd(void); + // sqlite3_mutex_methods const *sqlite3DefaultMutex(void); + // sqlite3_mutex_methods const *sqlite3NoopMutex(void); + // sqlite3_mutex *sqlite3MutexAlloc(int); + // int sqlite3MutexInit(void); + // int sqlite3MutexEnd(void); #endif - //int sqlite3StatusValue(int); - //void sqlite3StatusAdd(int, int); - //void sqlite3StatusSet(int, int); + //int sqlite3StatusValue(int); + //void sqlite3StatusAdd(int, int); + //void sqlite3StatusSet(int, int); - //#if !SQLITE_OMIT_FLOATING_POINT - // int sqlite3IsNaN(double); - //#else - //# define sqlite3IsNaN(X) 0 - //#endif + //#if !SQLITE_OMIT_FLOATING_POINT + // int sqlite3IsNaN(double); + //#else + //# define sqlite3IsNaN(X) 0 + //#endif - //void sqlite3VXPrintf(StrAccum*, int, const char*, va_list); -#if!SQLITE_OMIT_TRACE - //void sqlite3XPrintf(StrAccum*, const char*, ...); + //void sqlite3VXPrintf(StrAccum*, int, const char*, va_list); +#if !SQLITE_OMIT_TRACE + //void sqlite3XPrintf(StrAccum*, const char*, ...); #endif - //char *sqlite3MPrintf(sqlite3*,const char*, ...); - //char *sqlite3VMPrintf(sqlite3*,const char*, va_list); - //char *sqlite3MAppendf(sqlite3*,char*,const char*,...); + //char *sqlite3MPrintf(sqlite3*,const char*, ...); + //char *sqlite3VMPrintf(sqlite3*,const char*, va_list); + //char *sqlite3MAppendf(sqlite3*,char*,const char*,...); #if SQLITE_TEST || SQLITE_DEBUG - // void sqlite3DebugPrintf(const char*, ...); + // void sqlite3DebugPrintf(const char*, ...); #endif #if SQLITE_TEST // void *sqlite3TestTextToPtr(const char); #endif - //void sqlite3SetString(char **, sqlite3*, const char*, ...); - //void sqlite3ErrorMsg(Parse*, const char*, ...); - //int sqlite3Dequote(char); - //int sqlite3KeywordCode(const unsigned char*, int); - //int sqlite3RunParser(Parse*, const char*, char *); - //void sqlite3FinishCoding(Parse); - //int sqlite3GetTempReg(Parse); - //void sqlite3ReleaseTempReg(Parse*,int); - //int sqlite3GetTempRange(Parse*,int); - //void sqlite3ReleaseTempRange(Parse*,int,int); - //Expr *sqlite3ExprAlloc(sqlite3*,int,const Token*,int); - //Expr *sqlite3Expr(sqlite3*,int,const char); - //void sqlite3ExprAttachSubtrees(sqlite3*,Expr*,Expr*,Expr); - //Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*, const Token); - //Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr); - //Expr *sqlite3ExprFunction(Parse*,ExprList*, Token); - //void sqlite3ExprAssignVarNumber(Parse*, Expr); - //void sqlite3ExprDelete(sqlite3*, Expr); - //ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr); - //void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int); - //void sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan); - //void sqlite3ExprListDelete(sqlite3*, ExprList); - //int sqlite3Init(sqlite3*, char*); - //int sqlite3InitCallback(void*, int, char**, char*); - //void sqlite3Pragma(Parse*,Token*,Token*,Token*,int); - //void sqlite3ResetInternalSchema(sqlite3*, int); - //void sqlite3BeginParse(Parse*,int); - //void sqlite3CommitInternalChanges(sqlite3); - //Table *sqlite3ResultSetOfSelect(Parse*,Select); - //void sqlite3OpenMasterTable(Parse *, int); - //void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int); - //void sqlite3AddColumn(Parse*,Token); - //void sqlite3AddNotNull(Parse*, int); - //void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int); - //void sqlite3AddCheckConstraint(Parse*, Expr); - //void sqlite3AddColumnType(Parse*,Token); - //void sqlite3AddDefaultValue(Parse*,ExprSpan); - //void sqlite3AddCollateType(Parse*, Token); - //void sqlite3EndTable(Parse*,Token*,Token*,Select); - //int sqlite3ParseUri(const char*,const char*,unsigned int*, - // sqlite3_vfs**,char**,char *); - - //Bitvec *sqlite3BitvecCreate(u32); - //int sqlite3BitvecTest(Bitvec*, u32); - //int sqlite3BitvecSet(Bitvec*, u32); - //void sqlite3BitvecClear(Bitvec*, u32, void); - //void sqlite3BitvecDestroy(Bitvec); - //u32 sqlite3BitvecSize(Bitvec); - //int sqlite3BitvecBuiltinTest(int,int); - - //RowSet *sqlite3RowSetInit(sqlite3*, void*, unsigned int); - //void sqlite3RowSetClear(RowSet); - //void sqlite3RowSetInsert(RowSet*, i64); - //int sqlite3RowSetTest(RowSet*, u8 iBatch, i64); - //int sqlite3RowSetNext(RowSet*, i64); - - //void sqlite3CreateView(Parse*,Token*,Token*,Token*,Select*,int,int); + //void sqlite3SetString(char **, sqlite3*, const char*, ...); + //void sqlite3ErrorMsg(Parse*, const char*, ...); + //int sqlite3Dequote(char); + //int sqlite3KeywordCode(const unsigned char*, int); + //int sqlite3RunParser(Parse*, const char*, char *); + //void sqlite3FinishCoding(Parse); + //int sqlite3GetTempReg(Parse); + //void sqlite3ReleaseTempReg(Parse*,int); + //int sqlite3GetTempRange(Parse*,int); + //void sqlite3ReleaseTempRange(Parse*,int,int); + //Expr *sqlite3ExprAlloc(sqlite3*,int,const Token*,int); + //Expr *sqlite3Expr(sqlite3*,int,const char); + //void sqlite3ExprAttachSubtrees(sqlite3*,Expr*,Expr*,Expr); + //Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*, const Token); + //Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr); + //Expr *sqlite3ExprFunction(Parse*,ExprList*, Token); + //void sqlite3ExprAssignVarNumber(Parse*, Expr); + //void sqlite3ExprDelete(sqlite3*, Expr); + //ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr); + //void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int); + //void sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan); + //void sqlite3ExprListDelete(sqlite3*, ExprList); + //int sqlite3Init(sqlite3*, char*); + //int sqlite3InitCallback(void*, int, char**, char*); + //void sqlite3Pragma(Parse*,Token*,Token*,Token*,int); + //void sqlite3ResetInternalSchema(sqlite3*, int); + //void sqlite3BeginParse(Parse*,int); + //void sqlite3CommitInternalChanges(sqlite3); + //Table *sqlite3ResultSetOfSelect(Parse*,Select); + //void sqlite3OpenMasterTable(Parse *, int); + //void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int); + //void sqlite3AddColumn(Parse*,Token); + //void sqlite3AddNotNull(Parse*, int); + //void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int); + //void sqlite3AddCheckConstraint(Parse*, Expr); + //void sqlite3AddColumnType(Parse*,Token); + //void sqlite3AddDefaultValue(Parse*,ExprSpan); + //void sqlite3AddCollateType(Parse*, Token); + //void sqlite3EndTable(Parse*,Token*,Token*,Select); + //int sqlite3ParseUri(const char*,const char*,unsigned int*, + // sqlite3_vfs**,char**,char *); + + //Bitvec *sqlite3BitvecCreate(u32); + //int sqlite3BitvecTest(Bitvec*, u32); + //int sqlite3BitvecSet(Bitvec*, u32); + //void sqlite3BitvecClear(Bitvec*, u32, void); + //void sqlite3BitvecDestroy(Bitvec); + //u32 sqlite3BitvecSize(Bitvec); + //int sqlite3BitvecBuiltinTest(int,int); + + //RowSet *sqlite3RowSetInit(sqlite3*, void*, unsigned int); + //void sqlite3RowSetClear(RowSet); + //void sqlite3RowSetInsert(RowSet*, i64); + //int sqlite3RowSetTest(RowSet*, u8 iBatch, i64); + //int sqlite3RowSetNext(RowSet*, i64); + + //void sqlite3CreateView(Parse*,Token*,Token*,Token*,Select*,int,int); #if !SQLITE_OMIT_VIEW || !SQLITE_OMIT_VIRTUALTABLE - //int sqlite3ViewGetColumnNames(Parse*,Table); + //int sqlite3ViewGetColumnNames(Parse*,Table); #else //# define sqlite3ViewGetColumnNames(A,B) 0 static int sqlite3ViewGetColumnNames( Parse A, Table B ) @@ -3887,148 +3718,147 @@ static int sqlite3ViewGetColumnNames( Parse A, Table B ) } #endif - //void sqlite3DropTable(Parse*, SrcList*, int, int); - //void sqlite3DeleteTable(sqlite3*, Table); - //#if !SQLITE_OMIT_AUTOINCREMENT - // void sqlite3AutoincrementBegin(Parse *pParse); - // void sqlite3AutoincrementEnd(Parse *pParse); - //#else - //# define sqlite3AutoincrementBegin(X) - //# define sqlite3AutoincrementEnd(X) - //#endif - //void sqlite3Insert(Parse*, SrcList*, ExprList*, Select*, IdList*, int); - //void *sqlite3ArrayAllocate(sqlite3*,void*,int,int,int*,int*,int); - //IdList *sqlite3IdListAppend(sqlite3*, IdList*, Token); - //int sqlite3IdListIndex(IdList*,const char); - //SrcList *sqlite3SrcListEnlarge(sqlite3*, SrcList*, int, int); - //SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token); - //SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*, - // Token*, Select*, Expr*, IdList); - //void sqlite3SrcListIndexedBy(Parse *, SrcList *, Token ); - //int sqlite3IndexedByLookup(Parse *, struct SrcList_item ); - //void sqlite3SrcListShiftJoinType(SrcList); - //void sqlite3SrcListAssignCursors(Parse*, SrcList); - //void sqlite3IdListDelete(sqlite3*, IdList); - //void sqlite3SrcListDelete(sqlite3*, SrcList); - //Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*, - // Token*, int, int); - //void sqlite3DropIndex(Parse*, SrcList*, int); - //int sqlite3Select(Parse*, Select*, SelectDest); - //Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*, - // Expr*,ExprList*,int,Expr*,Expr); - //void sqlite3SelectDelete(sqlite3*, Select); - //Table *sqlite3SrcListLookup(Parse*, SrcList); - //int sqlite3IsReadOnly(Parse*, Table*, int); - //void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int); + //void sqlite3DropTable(Parse*, SrcList*, int, int); + //void sqlite3DeleteTable(sqlite3*, Table); + //#if !SQLITE_OMIT_AUTOINCREMENT + // void sqlite3AutoincrementBegin(Parse *pParse); + // void sqlite3AutoincrementEnd(Parse *pParse); + //#else + //# define sqlite3AutoincrementBegin(X) + //# define sqlite3AutoincrementEnd(X) + //#endif + //void sqlite3Insert(Parse*, SrcList*, ExprList*, Select*, IdList*, int); + //void *sqlite3ArrayAllocate(sqlite3*,void*,int,int,int*,int*,int); + //IdList *sqlite3IdListAppend(sqlite3*, IdList*, Token); + //int sqlite3IdListIndex(IdList*,const char); + //SrcList *sqlite3SrcListEnlarge(sqlite3*, SrcList*, int, int); + //SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token); + //SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*, + // Token*, Select*, Expr*, IdList); + //void sqlite3SrcListIndexedBy(Parse *, SrcList *, Token ); + //int sqlite3IndexedByLookup(Parse *, struct SrcList_item ); + //void sqlite3SrcListShiftJoinType(SrcList); + //void sqlite3SrcListAssignCursors(Parse*, SrcList); + //void sqlite3IdListDelete(sqlite3*, IdList); + //void sqlite3SrcListDelete(sqlite3*, SrcList); + //Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*, + // Token*, int, int); + //void sqlite3DropIndex(Parse*, SrcList*, int); + //int sqlite3Select(Parse*, Select*, SelectDest); + //Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*, + // Expr*,ExprList*,int,Expr*,Expr); + //void sqlite3SelectDelete(sqlite3*, Select); + //Table *sqlite3SrcListLookup(Parse*, SrcList); + //int sqlite3IsReadOnly(Parse*, Table*, int); + //void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int); #if (SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !(SQLITE_OMIT_SUBQUERY) //Expr *sqlite3LimitWhere(Parse *, SrcList *, Expr *, ExprList *, Expr *, Expr *, char ); #endif - //void sqlite3DeleteFrom(Parse*, SrcList*, Expr); - //void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int); - //WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**, u16); - //void sqlite3WhereEnd(WhereInfo); - //int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int); - //void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int); - //void sqlite3ExprCodeMove(Parse*, int, int, int); - //void sqlite3ExprCodeCopy(Parse*, int, int, int); - //void sqlite3ExprCacheStore(Parse*, int, int, int); - //void sqlite3ExprCachePush(Parse); - //void sqlite3ExprCachePop(Parse*, int); - //void sqlite3ExprCacheRemove(Parse*, int, int); - //void sqlite3ExprCacheClear(Parse); - //void sqlite3ExprCacheAffinityChange(Parse*, int, int); - //int sqlite3ExprCode(Parse*, Expr*, int); - //int sqlite3ExprCodeTemp(Parse*, Expr*, int); - //int sqlite3ExprCodeTarget(Parse*, Expr*, int); - //int sqlite3ExprCodeAndCache(Parse*, Expr*, int); - //void sqlite3ExprCodeConstants(Parse*, Expr); - //int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int); - //void sqlite3ExprIfTrue(Parse*, Expr*, int, int); - //void sqlite3ExprIfFalse(Parse*, Expr*, int, int); - //Table *sqlite3FindTable(sqlite3*,const char*, const char); - //Table *sqlite3LocateTable(Parse*,int isView,const char*, const char); - //Index *sqlite3FindIndex(sqlite3*,const char*, const char); - //void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char); - //void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char); - //void sqlite3Vacuum(Parse); - //int sqlite3RunVacuum(char**, sqlite3); - //char *sqlite3NameFromToken(sqlite3*, Token); - //int sqlite3ExprCompare(Expr*, Expr); - //int sqlite3ExprListCompare(ExprList*, ExprList); - //void sqlite3ExprAnalyzeAggregates(NameContext*, Expr); - //void sqlite3ExprAnalyzeAggList(NameContext*,ExprList); - //Vdbe *sqlite3GetVdbe(Parse); - //void sqlite3PrngSaveState(void); - //void sqlite3PrngRestoreState(void); - //void sqlite3PrngResetState(void); - //void sqlite3RollbackAll(sqlite3); - //void sqlite3CodeVerifySchema(Parse*, int); - //void sqlite3CodeVerifyNamedSchema(Parse*, string zDb); - //void sqlite3BeginTransaction(Parse*, int); - //void sqlite3CommitTransaction(Parse); - //void sqlite3RollbackTransaction(Parse); - //void sqlite3Savepoint(Parse*, int, Token); - //void sqlite3CloseSavepoints(sqlite3 ); - //int sqlite3ExprIsConstant(Expr); - //int sqlite3ExprIsConstantNotJoin(Expr); - //int sqlite3ExprIsConstantOrFunction(Expr); - //int sqlite3ExprIsInteger(Expr*, int); - //int sqlite3ExprCanBeNull(const Expr); - //void sqlite3ExprCodeIsNullJump(Vdbe*, const Expr*, int, int); - //int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); - //int sqlite3IsRowid(const char); - //void sqlite3GenerateRowDelete(Parse*, Table*, int, int, int, Trigger *, int); - //void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int); - //int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int); - //void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int, - // int*,int,int,int,int,int); - //void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int); - //int sqlite3OpenTableAndIndices(Parse*, Table*, int, int); - //void sqlite3BeginWriteOperation(Parse*, int, int); - //void sqlite3MultiWrite(Parse); - //void sqlite3MayAbort(Parse ); - //void sqlite3HaltConstraint(Parse*, int, char*, int); - //Expr *sqlite3ExprDup(sqlite3*,Expr*,int); - //ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int); - //SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int); - //IdList *sqlite3IdListDup(sqlite3*,IdList); - //Select *sqlite3SelectDup(sqlite3*,Select*,int); - //void sqlite3FuncDefInsert(FuncDefHash*, FuncDef); - //FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,int,u8,int); - //void sqlite3RegisterBuiltinFunctions(sqlite3); - //void sqlite3RegisterDateTimeFunctions(void); - //void sqlite3RegisterGlobalFunctions(void); - //int sqlite3SafetyCheckOk(sqlite3); - //int sqlite3SafetyCheckSickOrOk(sqlite3); - //void sqlite3ChangeCookie(Parse*, int); + //void sqlite3DeleteFrom(Parse*, SrcList*, Expr); + //void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int); + //WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**, u16); + //void sqlite3WhereEnd(WhereInfo); + //int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int); + //void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int); + //void sqlite3ExprCodeMove(Parse*, int, int, int); + //void sqlite3ExprCodeCopy(Parse*, int, int, int); + //void sqlite3ExprCacheStore(Parse*, int, int, int); + //void sqlite3ExprCachePush(Parse); + //void sqlite3ExprCachePop(Parse*, int); + //void sqlite3ExprCacheRemove(Parse*, int, int); + //void sqlite3ExprCacheClear(Parse); + //void sqlite3ExprCacheAffinityChange(Parse*, int, int); + //int sqlite3ExprCode(Parse*, Expr*, int); + //int sqlite3ExprCodeTemp(Parse*, Expr*, int); + //int sqlite3ExprCodeTarget(Parse*, Expr*, int); + //int sqlite3ExprCodeAndCache(Parse*, Expr*, int); + //void sqlite3ExprCodeConstants(Parse*, Expr); + //int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int); + //void sqlite3ExprIfTrue(Parse*, Expr*, int, int); + //void sqlite3ExprIfFalse(Parse*, Expr*, int, int); + //Table *sqlite3FindTable(sqlite3*,const char*, const char); + //Table *sqlite3LocateTable(Parse*,int isView,const char*, const char); + //Index *sqlite3FindIndex(sqlite3*,const char*, const char); + //void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char); + //void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char); + //void sqlite3Vacuum(Parse); + //int sqlite3RunVacuum(char**, sqlite3); + //char *sqlite3NameFromToken(sqlite3*, Token); + //int sqlite3ExprCompare(Expr*, Expr); + //int sqlite3ExprListCompare(ExprList*, ExprList); + //void sqlite3ExprAnalyzeAggregates(NameContext*, Expr); + //void sqlite3ExprAnalyzeAggList(NameContext*,ExprList); + //Vdbe *sqlite3GetVdbe(Parse); + //void sqlite3PrngSaveState(void); + //void sqlite3PrngRestoreState(void); + //void sqlite3PrngResetState(void); + //void sqlite3RollbackAll(sqlite3); + //void sqlite3CodeVerifySchema(Parse*, int); + //void sqlite3CodeVerifyNamedSchema(Parse*, string zDb); + //void sqlite3BeginTransaction(Parse*, int); + //void sqlite3CommitTransaction(Parse); + //void sqlite3RollbackTransaction(Parse); + //void sqlite3Savepoint(Parse*, int, Token); + //void sqlite3CloseSavepoints(sqlite3 ); + //int sqlite3ExprIsConstant(Expr); + //int sqlite3ExprIsConstantNotJoin(Expr); + //int sqlite3ExprIsConstantOrFunction(Expr); + //int sqlite3ExprIsInteger(Expr*, int); + //int sqlite3ExprCanBeNull(const Expr); + //void sqlite3ExprCodeIsNullJump(Vdbe*, const Expr*, int, int); + //int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); + //int sqlite3IsRowid(const char); + //void sqlite3GenerateRowDelete(Parse*, Table*, int, int, int, Trigger *, int); + //void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int); + //int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int); + //void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int, + // int*,int,int,int,int,int); + //void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int); + //int sqlite3OpenTableAndIndices(Parse*, Table*, int, int); + //void sqlite3BeginWriteOperation(Parse*, int, int); + //void sqlite3MultiWrite(Parse); + //void sqlite3MayAbort(Parse ); + //void sqlite3HaltConstraint(Parse*, int, char*, int); + //Expr *sqlite3ExprDup(sqlite3*,Expr*,int); + //ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int); + //SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int); + //IdList *sqlite3IdListDup(sqlite3*,IdList); + //Select *sqlite3SelectDup(sqlite3*,Select*,int); + //void sqlite3FuncDefInsert(FuncDefHash*, FuncDef); + //FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,int,u8,int); + //void sqlite3RegisterBuiltinFunctions(sqlite3); + //void sqlite3RegisterDateTimeFunctions(void); + //void sqlite3RegisterGlobalFunctions(void); + //int sqlite3SafetyCheckOk(sqlite3); + //int sqlite3SafetyCheckSickOrOk(sqlite3); + //void sqlite3ChangeCookie(Parse*, int); #if !(SQLITE_OMIT_VIEW) && !(SQLITE_OMIT_TRIGGER) - //void sqlite3MaterializeView(Parse*, Table*, Expr*, int); + //void sqlite3MaterializeView(Parse*, Table*, Expr*, int); #endif #if !SQLITE_OMIT_TRIGGER - //void sqlite3BeginTrigger(Parse*, Token*,Token*,int,int,IdList*,SrcList*, - // Expr*,int, int); - //void sqlite3FinishTrigger(Parse*, TriggerStep*, Token); - //void sqlite3DropTrigger(Parse*, SrcList*, int); - //Trigger *sqlite3TriggersExist(Parse *, Table*, int, ExprList*, int *pMask); - //Trigger *sqlite3TriggerList(Parse *, Table ); - // void sqlite3CodeRowTrigger(Parse*, Trigger *, int, ExprList*, int, Table *, - // int, int, int); - //void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList); - //void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep); - //TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select); - //TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*, - // ExprList*,Select*,u8); - //TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8); - //TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr); - //void sqlite3DeleteTrigger(sqlite3*, Trigger); - //void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char); - // u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int); - //# define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p)) - static Parse sqlite3ParseToplevel( Parse p ) - { - return p.pToplevel != null ? p.pToplevel : p; - } + //void sqlite3BeginTrigger(Parse*, Token*,Token*,int,int,IdList*,SrcList*, + // Expr*,int, int); + //void sqlite3FinishTrigger(Parse*, TriggerStep*, Token); + //void sqlite3DropTrigger(Parse*, SrcList*, int); + //Trigger *sqlite3TriggersExist(Parse *, Table*, int, ExprList*, int *pMask); + //Trigger *sqlite3TriggerList(Parse *, Table ); + // void sqlite3CodeRowTrigger(Parse*, Trigger *, int, ExprList*, int, Table *, + // int, int, int); + //void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList); + //void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep); + //TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select); + //TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*, + // ExprList*,Select*,u8); + //TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8); + //TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr); + //void sqlite3DeleteTrigger(sqlite3*, Trigger); + //void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char); + // u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int); + //# define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p)) + static Parse sqlite3ParseToplevel(Parse p) { + return p.pToplevel != null ? p.pToplevel : p; + } #else static void sqlite3BeginTrigger( Parse A, Token B, Token C, int D, int E, IdList F, SrcList G, Expr H, int I, int J ) { @@ -4116,9 +3946,9 @@ static u32 sqlite3TriggerOldmask( Parse A, Trigger B, int C, ExprList D, Table E } #endif - //int sqlite3JoinType(Parse*, Token*, Token*, Token); - //void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int); - //void sqlite3DeferForeignKey(Parse*, int); + //int sqlite3JoinType(Parse*, Token*, Token*, Token); + //void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int); + //void sqlite3DeferForeignKey(Parse*, int); #if !SQLITE_OMIT_AUTHORIZATION void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList); int sqlite3AuthCheck(Parse*,int, const char*, const char*, const char); @@ -4126,195 +3956,191 @@ static u32 sqlite3TriggerOldmask( Parse A, Trigger B, int C, ExprList D, Table E void sqlite3AuthContextPop(AuthContext); int sqlite3AuthReadCol(Parse*, string , string , int); #else - //# define sqlite3AuthRead(a,b,c,d) - static void sqlite3AuthRead( Parse a, Expr b, Schema c, SrcList d ) - { - } + //# define sqlite3AuthRead(a,b,c,d) + static void sqlite3AuthRead(Parse a, Expr b, Schema c, SrcList d) { + } - //# define sqlite3AuthCheck(a,b,c,d,e) SQLITE_OK - static int sqlite3AuthCheck( Parse a, int b, string c, byte[] d, byte[] e ) - { - return SQLITE_OK; - } + //# define sqlite3AuthCheck(a,b,c,d,e) SQLITE_OK + static int sqlite3AuthCheck(Parse a, int b, string c, byte[] d, byte[] e) { + return SQLITE_OK; + } - //# define sqlite3AuthContextPush(a,b,c) - static void sqlite3AuthContextPush( Parse a, AuthContext b, string c ) - { - } + //# define sqlite3AuthContextPush(a,b,c) + static void sqlite3AuthContextPush(Parse a, AuthContext b, string c) { + } - //# define sqlite3AuthContextPop(a) ((void)(a)) - static Parse sqlite3AuthContextPop( Parse a ) - { - return a; - } + //# define sqlite3AuthContextPop(a) ((void)(a)) + static Parse sqlite3AuthContextPop(Parse a) { + return a; + } #endif - //void sqlite3Attach(Parse*, Expr*, Expr*, Expr); - //void sqlite3Detach(Parse*, Expr); - //int sqlite3FixInit(DbFixer*, Parse*, int, const char*, const Token); - //int sqlite3FixSrcList(DbFixer*, SrcList); - //int sqlite3FixSelect(DbFixer*, Select); - //int sqlite3FixExpr(DbFixer*, Expr); - //int sqlite3FixExprList(DbFixer*, ExprList); - //int sqlite3FixTriggerStep(DbFixer*, TriggerStep); - //sqlite3AtoF(string z, double*, int, u8) - //int sqlite3GetInt32(string , int); - //int sqlite3Atoi(string ); - //int sqlite3Utf16ByteLen(const void pData, int nChar); - //int sqlite3Utf8CharLen(const char pData, int nByte); - //u32 sqlite3Utf8Read(const u8*, const u8*); - - /* - ** 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 - ** are coded to assume the single byte case is already handled (which - ** the MACRO form does). - */ - //int sqlite3PutVarint(unsigned char*, u64); - //int putVarint32(unsigned char*, u32); - //u8 sqlite3GetVarint(const unsigned char *, u64 ); - //u8 sqlite3GetVarint32(const unsigned char *, u32 ); - //int sqlite3VarintLen(u64 v); - - /* - ** The header of a record consists of a sequence variable-length integers. - ** These integers are almost always small and are encoded as a single byte. - ** The following macros take advantage this fact to provide a fast encode - ** and decode of the integers in a record header. It is faster for the common - ** case where the integer is a single byte. It is a little slower when the - ** integer is two or more bytes. But overall it is faster. - ** - ** The following expressions are equivalent: - ** - ** x = sqlite3GetVarint32( A, B ); - ** x = putVarint32( A, B ); - ** - ** x = getVarint32( A, B ); - ** x = putVarint32( A, B ); - ** - */ - //#define getVarint32(A,B) (u8)((*(A)<(u8)0x80) ? ((B) = (u32)*(A)),1 : sqlite3GetVarint32((A), (u32 )&(B))) - //#define putVarint32(A,B) (u8)(((u32)(B)<(u32)0x80) ? (*(A) = (unsigned char)(B)),1 : sqlite3PutVarint32((A), (B))) - //#define getVarint sqlite3GetVarint - //#define putVarint sqlite3PutVarint - - - //string sqlite3IndexAffinityStr(Vdbe *, Index ); - //void sqlite3TableAffinityStr(Vdbe *, Table ); - //char sqlite3CompareAffinity(Expr pExpr, char aff2); - //int sqlite3IndexAffinityOk(Expr pExpr, char idx_affinity); - //char sqlite3ExprAffinity(Expr pExpr); - //int sqlite3Atoi64(const char*, i64*, int, u8); - //void sqlite3Error(sqlite3*, int, const char*,...); - //void *sqlite3HexToBlob(sqlite3*, string z, int n); - //u8 sqlite3HexToInt(int h); - //int sqlite3TwoPartName(Parse *, Token *, Token *, Token *); - //string sqlite3ErrStr(int); - //int sqlite3ReadSchema(Parse pParse); - //CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int); - //CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName); - //CollSeq *sqlite3ExprCollSeq(Parse pParse, Expr pExpr); - //Expr *sqlite3ExprSetColl(Expr*, CollSeq); - //Expr *sqlite3ExprSetCollByToken(Parse *pParse, Expr*, Token); - //int sqlite3CheckCollSeq(Parse *, CollSeq ); - //int sqlite3CheckObjectName(Parse *, string ); - //void sqlite3VdbeSetChanges(sqlite3 *, int); - //int sqlite3AddInt64(i64*,i64); - //int sqlite3SubInt64(i64*,i64); - //int sqlite3MulInt64(i64*,i64); - //int sqlite3AbsInt32(int); - #if SQLITE_ENABLE_8_3_NAMES + //void sqlite3Attach(Parse*, Expr*, Expr*, Expr); + //void sqlite3Detach(Parse*, Expr); + //int sqlite3FixInit(DbFixer*, Parse*, int, const char*, const Token); + //int sqlite3FixSrcList(DbFixer*, SrcList); + //int sqlite3FixSelect(DbFixer*, Select); + //int sqlite3FixExpr(DbFixer*, Expr); + //int sqlite3FixExprList(DbFixer*, ExprList); + //int sqlite3FixTriggerStep(DbFixer*, TriggerStep); + //sqlite3AtoF(string z, double*, int, u8) + //int sqlite3GetInt32(string , int); + //int sqlite3Atoi(string ); + //int sqlite3Utf16ByteLen(const void pData, int nChar); + //int sqlite3Utf8CharLen(const char pData, int nByte); + //u32 sqlite3Utf8Read(const u8*, const u8*); + + /* + ** 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 + ** are coded to assume the single byte case is already handled (which + ** the MACRO form does). + */ + //int sqlite3PutVarint(unsigned char*, u64); + //int putVarint32(unsigned char*, u32); + //u8 sqlite3GetVarint(const unsigned char *, u64 ); + //u8 sqlite3GetVarint32(const unsigned char *, u32 ); + //int sqlite3VarintLen(u64 v); + + /* + ** The header of a record consists of a sequence variable-length integers. + ** These integers are almost always small and are encoded as a single byte. + ** The following macros take advantage this fact to provide a fast encode + ** and decode of the integers in a record header. It is faster for the common + ** case where the integer is a single byte. It is a little slower when the + ** integer is two or more bytes. But overall it is faster. + ** + ** The following expressions are equivalent: + ** + ** x = sqlite3GetVarint32( A, B ); + ** x = putVarint32( A, B ); + ** + ** x = getVarint32( A, B ); + ** x = putVarint32( A, B ); + ** + */ + //#define getVarint32(A,B) (u8)((*(A)<(u8)0x80) ? ((B) = (u32)*(A)),1 : sqlite3GetVarint32((A), (u32 )&(B))) + //#define putVarint32(A,B) (u8)(((u32)(B)<(u32)0x80) ? (*(A) = (unsigned char)(B)),1 : sqlite3PutVarint32((A), (B))) + //#define getVarint sqlite3GetVarint + //#define putVarint sqlite3PutVarint + + + //string sqlite3IndexAffinityStr(Vdbe *, Index ); + //void sqlite3TableAffinityStr(Vdbe *, Table ); + //char sqlite3CompareAffinity(Expr pExpr, char aff2); + //int sqlite3IndexAffinityOk(Expr pExpr, char idx_affinity); + //char sqlite3ExprAffinity(Expr pExpr); + //int sqlite3Atoi64(const char*, i64*, int, u8); + //void sqlite3Error(sqlite3*, int, const char*,...); + //void *sqlite3HexToBlob(sqlite3*, string z, int n); + //u8 sqlite3HexToInt(int h); + //int sqlite3TwoPartName(Parse *, Token *, Token *, Token *); + //string sqlite3ErrStr(int); + //int sqlite3ReadSchema(Parse pParse); + //CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int); + //CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName); + //CollSeq *sqlite3ExprCollSeq(Parse pParse, Expr pExpr); + //Expr *sqlite3ExprSetColl(Expr*, CollSeq); + //Expr *sqlite3ExprSetCollByToken(Parse *pParse, Expr*, Token); + //int sqlite3CheckCollSeq(Parse *, CollSeq ); + //int sqlite3CheckObjectName(Parse *, string ); + //void sqlite3VdbeSetChanges(sqlite3 *, int); + //int sqlite3AddInt64(i64*,i64); + //int sqlite3SubInt64(i64*,i64); + //int sqlite3MulInt64(i64*,i64); + //int sqlite3AbsInt32(int); +#if SQLITE_ENABLE_8_3_NAMES //void sqlite3FileSuffix3(const char*, char); - #else - //# define sqlite3FileSuffix3(X,Y) - static void sqlite3FileSuffix3(string X, string Y){} - #endif - //u8 sqlite3GetBoolean(string z); - - //const void *sqlite3ValueText(sqlite3_value*, u8); - //int sqlite3ValueBytes(sqlite3_value*, u8); - //void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8, - // // void()(void)); - //void sqlite3ValueFree(sqlite3_value); - //sqlite3_value *sqlite3ValueNew(sqlite3 ); - //char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8); - //#if SQLITE_ENABLE_STAT2 - //char *sqlite3Utf8to16(sqlite3 *, u8, char *, int, int ); - //#endif - //int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value *); - //void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8); - //#if !SQLITE_AMALGAMATION - //extern const unsigned char sqlite3OpcodeProperty[]; - //extern const unsigned char sqlite3UpperToLower[]; - //extern const unsigned char sqlite3CtypeMap[]; - //extern const Token sqlite3IntTokens[]; - //extern SQLITE_WSD struct Sqlite3Config sqlite3Config; - //extern SQLITE_WSD FuncDefHash sqlite3GlobalFunctions; - //#if !SQLITE_OMIT_WSD - //extern int sqlite3PendingByte; - //#endif - //#endif - //void sqlite3RootPageMoved(sqlite3*, int, int, int); - //void sqlite3Reindex(Parse*, Token*, Token); - //void sqlite3AlterFunctions(void); - //void sqlite3AlterRenameTable(Parse*, SrcList*, Token); - //int sqlite3GetToken(const unsigned char *, int ); - //void sqlite3NestedParse(Parse*, const char*, ...); - //void sqlite3ExpirePreparedStatements(sqlite3); - //int sqlite3CodeSubselect(Parse *, Expr *, int, int); - //void sqlite3SelectPrep(Parse*, Select*, NameContext); - //int sqlite3ResolveExprNames(NameContext*, Expr); - //void sqlite3ResolveSelectNames(Parse*, Select*, NameContext); - //int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char); - //void sqlite3ColumnDefault(Vdbe *, Table *, int, int); - //void sqlite3AlterFinishAddColumn(Parse *, Token ); - //void sqlite3AlterBeginAddColumn(Parse *, SrcList ); - //CollSeq *sqlite3GetCollSeq(sqlite3*, u8, CollSeq *, const char); - //char sqlite3AffinityType(const char); - //void sqlite3Analyze(Parse*, Token*, Token); - //int sqlite3InvokeBusyHandler(BusyHandler); - //int sqlite3FindDb(sqlite3*, Token); - //int sqlite3FindDbName(sqlite3 *, string ); - //int sqlite3AnalysisLoad(sqlite3*,int iDB); - //void sqlite3DeleteIndexSamples(sqlite3*,Index); - //void sqlite3DefaultRowEst(Index); - //void sqlite3RegisterLikeFunctions(sqlite3*, int); - //int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char); - //void sqlite3MinimumFileFormat(Parse*, int, int); - //void sqlite3SchemaClear(void ); - //Schema *sqlite3SchemaGet(sqlite3 *, Btree ); - //int sqlite3SchemaToIndex(sqlite3 db, Schema ); - //KeyInfo *sqlite3IndexKeyinfo(Parse *, Index ); - //int sqlite3CreateFunc(sqlite3 *, string , int, int, object *, - // void ()(sqlite3_context*,int,sqlite3_value *), - // void ()(sqlite3_context*,int,sqlite3_value *), object ()(sqlite3_context), - // FuncDestructor *pDestructor - //); - //int sqlite3ApiExit(sqlite3 db, int); - //int sqlite3OpenTempDatabase(Parse ); - - //void sqlite3StrAccumAppend(StrAccum*,const char*,int); - //char *sqlite3StrAccumFinish(StrAccum); - //void sqlite3StrAccumReset(StrAccum); - //void sqlite3SelectDestInit(SelectDest*,int,int); - //Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int); - - //void sqlite3BackupRestart(sqlite3_backup ); - //void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 ); - - /* - ** The interface to the LEMON-generated parser - */ - //void *sqlite3ParserAlloc(void*()(size_t)); - //void sqlite3ParserFree(void*, void()(void)); - //void sqlite3Parser(void*, int, Token, Parse); +#else + //# define sqlite3FileSuffix3(X,Y) + static void sqlite3FileSuffix3(string X, string Y) { } +#endif + //u8 sqlite3GetBoolean(string z); + + //const void *sqlite3ValueText(sqlite3_value*, u8); + //int sqlite3ValueBytes(sqlite3_value*, u8); + //void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8, + // // void()(void)); + //void sqlite3ValueFree(sqlite3_value); + //sqlite3_value *sqlite3ValueNew(sqlite3 ); + //char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8); + //#if SQLITE_ENABLE_STAT2 + //char *sqlite3Utf8to16(sqlite3 *, u8, char *, int, int ); + //#endif + //int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value *); + //void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8); + //#if !SQLITE_AMALGAMATION + //extern const unsigned char sqlite3OpcodeProperty[]; + //extern const unsigned char sqlite3UpperToLower[]; + //extern const unsigned char sqlite3CtypeMap[]; + //extern const Token sqlite3IntTokens[]; + //extern SQLITE_WSD struct Sqlite3Config sqlite3Config; + //extern SQLITE_WSD FuncDefHash sqlite3GlobalFunctions; + //#if !SQLITE_OMIT_WSD + //extern int sqlite3PendingByte; + //#endif + //#endif + //void sqlite3RootPageMoved(sqlite3*, int, int, int); + //void sqlite3Reindex(Parse*, Token*, Token); + //void sqlite3AlterFunctions(void); + //void sqlite3AlterRenameTable(Parse*, SrcList*, Token); + //int sqlite3GetToken(const unsigned char *, int ); + //void sqlite3NestedParse(Parse*, const char*, ...); + //void sqlite3ExpirePreparedStatements(sqlite3); + //int sqlite3CodeSubselect(Parse *, Expr *, int, int); + //void sqlite3SelectPrep(Parse*, Select*, NameContext); + //int sqlite3ResolveExprNames(NameContext*, Expr); + //void sqlite3ResolveSelectNames(Parse*, Select*, NameContext); + //int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char); + //void sqlite3ColumnDefault(Vdbe *, Table *, int, int); + //void sqlite3AlterFinishAddColumn(Parse *, Token ); + //void sqlite3AlterBeginAddColumn(Parse *, SrcList ); + //CollSeq *sqlite3GetCollSeq(sqlite3*, u8, CollSeq *, const char); + //char sqlite3AffinityType(const char); + //void sqlite3Analyze(Parse*, Token*, Token); + //int sqlite3InvokeBusyHandler(BusyHandler); + //int sqlite3FindDb(sqlite3*, Token); + //int sqlite3FindDbName(sqlite3 *, string ); + //int sqlite3AnalysisLoad(sqlite3*,int iDB); + //void sqlite3DeleteIndexSamples(sqlite3*,Index); + //void sqlite3DefaultRowEst(Index); + //void sqlite3RegisterLikeFunctions(sqlite3*, int); + //int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char); + //void sqlite3MinimumFileFormat(Parse*, int, int); + //void sqlite3SchemaClear(void ); + //Schema *sqlite3SchemaGet(sqlite3 *, Btree ); + //int sqlite3SchemaToIndex(sqlite3 db, Schema ); + //KeyInfo *sqlite3IndexKeyinfo(Parse *, Index ); + //int sqlite3CreateFunc(sqlite3 *, string , int, int, object *, + // void ()(sqlite3_context*,int,sqlite3_value *), + // void ()(sqlite3_context*,int,sqlite3_value *), object ()(sqlite3_context), + // FuncDestructor *pDestructor + //); + //int sqlite3ApiExit(sqlite3 db, int); + //int sqlite3OpenTempDatabase(Parse ); + + //void sqlite3StrAccumAppend(StrAccum*,const char*,int); + //char *sqlite3StrAccumFinish(StrAccum); + //void sqlite3StrAccumReset(StrAccum); + //void sqlite3SelectDestInit(SelectDest*,int,int); + //Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int); + + //void sqlite3BackupRestart(sqlite3_backup ); + //void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 ); + + /* + ** The interface to the LEMON-generated parser + */ + //void *sqlite3ParserAlloc(void*()(size_t)); + //void sqlite3ParserFree(void*, void()(void)); + //void sqlite3Parser(void*, int, Token, Parse); #if YYTRACKMAXSTACKDEPTH int sqlite3ParserStackPeak(void); #endif - //void sqlite3AutoLoadExtensions(sqlite3); + //void sqlite3AutoLoadExtensions(sqlite3); #if !SQLITE_OMIT_LOAD_EXTENSION - //void sqlite3CloseExtensions(sqlite3); + //void sqlite3CloseExtensions(sqlite3); #else //# define sqlite3CloseExtensions(X) #endif @@ -4322,13 +4148,11 @@ static void sqlite3FileSuffix3(string X, string Y){} #if !SQLITE_OMIT_SHARED_CACHE //void sqlite3TableLock(Parse *, int, int, u8, string ); #else - //#define sqlite3TableLock(v,w,x,y,z) - static void sqlite3TableLock( Parse p, int p1, int p2, u8 p3, byte[] p4 ) - { - } - static void sqlite3TableLock( Parse p, int p1, int p2, u8 p3, string p4 ) - { - } + //#define sqlite3TableLock(v,w,x,y,z) + static void sqlite3TableLock(Parse p, int p1, int p2, u8 p3, byte[] p4) { + } + static void sqlite3TableLock(Parse p, int p1, int p2, u8 p3, string p4) { + } #endif #if SQLITE_TEST @@ -4407,56 +4231,55 @@ static VTable sqlite3GetVTable( sqlite3 db, Table T ) return null; } #else -//void sqlite3VtabClear(sqlite3 db, Table); -//int sqlite3VtabSync(sqlite3 db, int rc); -//int sqlite3VtabRollback(sqlite3 db); -//int sqlite3VtabCommit(sqlite3 db); -//void sqlite3VtabLock(VTable ); -//void sqlite3VtabUnlock(VTable ); -//void sqlite3VtabUnlockList(sqlite3); -//int sqlite3VtabSavepoint(sqlite3 *, int, int); -//# define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0) - static bool sqlite3VtabInSync( sqlite3 db ) - { - return ( db.nVTrans > 0 && db.aVTrans == null ); - } + //void sqlite3VtabClear(sqlite3 db, Table); + //int sqlite3VtabSync(sqlite3 db, int rc); + //int sqlite3VtabRollback(sqlite3 db); + //int sqlite3VtabCommit(sqlite3 db); + //void sqlite3VtabLock(VTable ); + //void sqlite3VtabUnlock(VTable ); + //void sqlite3VtabUnlockList(sqlite3); + //int sqlite3VtabSavepoint(sqlite3 *, int, int); + //# define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0) + static bool sqlite3VtabInSync(sqlite3 db) { + return (db.nVTrans > 0 && db.aVTrans == null); + } #endif - //void sqlite3VtabMakeWritable(Parse*,Table); - //void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token); - //void sqlite3VtabFinishParse(Parse*, Token); - //void sqlite3VtabArgInit(Parse); - //void sqlite3VtabArgExtend(Parse*, Token); - //int sqlite3VtabCallCreate(sqlite3*, int, string , char *); - //int sqlite3VtabCallConnect(Parse*, Table); - //int sqlite3VtabCallDestroy(sqlite3*, int, string ); - //int sqlite3VtabBegin(sqlite3 *, VTable ); - //FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr); - //void sqlite3InvalidFunction(sqlite3_context*,int,sqlite3_value*); - //int sqlite3VdbeParameterIndex(Vdbe*, const char*, int); - //int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt ); - //int sqlite3Reprepare(Vdbe); - //void sqlite3ExprListCheckLength(Parse*, ExprList*, const char); - //CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr ); - //int sqlite3TempInMemory(const sqlite3); - //VTable *sqlite3GetVTable(sqlite3*, Table); - //string sqlite3JournalModename(int); - //int sqlite3Checkpoint(sqlite3*, int, int, int*, int); - //int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int); - - /* Declarations for functions in fkey.c. All of these are replaced by - ** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign - ** key functionality is available. If OMIT_TRIGGER is defined but - ** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In - ** this case foreign keys are parsed, but no other functionality is - ** provided (enforcement of FK constraints requires the triggers sub-system). - */ + //void sqlite3VtabMakeWritable(Parse*,Table); + //void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token); + //void sqlite3VtabFinishParse(Parse*, Token); + //void sqlite3VtabArgInit(Parse); + //void sqlite3VtabArgExtend(Parse*, Token); + //int sqlite3VtabCallCreate(sqlite3*, int, string , char *); + //int sqlite3VtabCallConnect(Parse*, Table); + //int sqlite3VtabCallDestroy(sqlite3*, int, string ); + //int sqlite3VtabBegin(sqlite3 *, VTable ); + //FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr); + //void sqlite3InvalidFunction(sqlite3_context*,int,sqlite3_value*); + //int sqlite3VdbeParameterIndex(Vdbe*, const char*, int); + //int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt ); + //int sqlite3Reprepare(Vdbe); + //void sqlite3ExprListCheckLength(Parse*, ExprList*, const char); + //CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr ); + //int sqlite3TempInMemory(const sqlite3); + //VTable *sqlite3GetVTable(sqlite3*, Table); + //string sqlite3JournalModename(int); + //int sqlite3Checkpoint(sqlite3*, int, int, int*, int); + //int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int); + + /* Declarations for functions in fkey.c. All of these are replaced by + ** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign + ** key functionality is available. If OMIT_TRIGGER is defined but + ** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In + ** this case foreign keys are parsed, but no other functionality is + ** provided (enforcement of FK constraints requires the triggers sub-system). + */ #if !(SQLITE_OMIT_FOREIGN_KEY) && !(SQLITE_OMIT_TRIGGER) - //void sqlite3FkCheck(Parse*, Table*, int, int); - //void sqlite3FkDropTable(Parse*, SrcList *, Table); - //void sqlite3FkActions(Parse*, Table*, ExprList*, int); - //int sqlite3FkRequired(Parse*, Table*, int*, int); - //u32 sqlite3FkOldmask(Parse*, Table); - //FKey *sqlite3FkReferences(vtable ); + //void sqlite3FkCheck(Parse*, Table*, int, int); + //void sqlite3FkDropTable(Parse*, SrcList *, Table); + //void sqlite3FkActions(Parse*, Table*, ExprList*, int); + //int sqlite3FkRequired(Parse*, Table*, int*, int); + //u32 sqlite3FkOldmask(Parse*, Table); + //FKey *sqlite3FkReferences(vtable ); #else //#define sqlite3FkActions(a,b,c,d) static void sqlite3FkActions( Parse a, Table b, ExprList c, int d ) { } @@ -4474,90 +4297,86 @@ static void sqlite3FkDropTable( Parse a, SrcList b, Table c ) { } static int sqlite3FkRequired( Parse a, Table b, int[] c, int d ) { return 0; } #endif #if !SQLITE_OMIT_FOREIGN_KEY - //void sqlite3FkDelete(sqlite3 *, Table); + //void sqlite3FkDelete(sqlite3 *, Table); #else //#define sqlite3FkDelete(a, b) static void sqlite3FkDelete(sqlite3 a, Table b) {} #endif - /* -** Available fault injectors. Should be numbered beginning with 0. -*/ - const int SQLITE_FAULTINJECTOR_MALLOC = 0;//#define SQLITE_FAULTINJECTOR_MALLOC 0 - const int SQLITE_FAULTINJECTOR_COUNT = 1;//#define SQLITE_FAULTINJECTOR_COUNT 1 - - /* - ** The interface to the code in fault.c used for identifying "benign" - ** malloc failures. This is only present if SQLITE_OMIT_BUILTIN_TEST - ** is not defined. + /* + ** Available fault injectors. Should be numbered beginning with 0. */ + const int SQLITE_FAULTINJECTOR_MALLOC = 0;//#define SQLITE_FAULTINJECTOR_MALLOC 0 + const int SQLITE_FAULTINJECTOR_COUNT = 1;//#define SQLITE_FAULTINJECTOR_COUNT 1 + + /* + ** The interface to the code in fault.c used for identifying "benign" + ** malloc failures. This is only present if SQLITE_OMIT_BUILTIN_TEST + ** is not defined. + */ #if !SQLITE_OMIT_BUILTIN_TEST - //void sqlite3BeginBenignMalloc(void); - //void sqlite3EndBenignMalloc(void); + //void sqlite3BeginBenignMalloc(void); + //void sqlite3EndBenignMalloc(void); #else //#define sqlite3BeginBenignMalloc() //#define sqlite3EndBenignMalloc() #endif - const int IN_INDEX_ROWID = 1;//#define IN_INDEX_ROWID 1 - const int IN_INDEX_EPH = 2;//#define IN_INDEX_EPH 2 - const int IN_INDEX_INDEX = 3;//#define IN_INDEX_INDEX 3 - //int sqlite3FindInIndex(Parse *, Expr *, int); + const int IN_INDEX_ROWID = 1;//#define IN_INDEX_ROWID 1 + const int IN_INDEX_EPH = 2;//#define IN_INDEX_EPH 2 + const int IN_INDEX_INDEX = 3;//#define IN_INDEX_INDEX 3 + //int sqlite3FindInIndex(Parse *, Expr *, int); #if SQLITE_ENABLE_ATOMIC_WRITE // int sqlite3JournalOpen(sqlite3_vfs *, string , sqlite3_file *, int, int); // int sqlite3JournalSize(sqlite3_vfs ); // int sqlite3JournalCreate(sqlite3_file ); #else - //#define sqlite3JournalSize(pVfs) ((pVfs)->szOsFile) - static int sqlite3JournalSize( sqlite3_vfs pVfs ) - { - return pVfs.szOsFile; - } + //#define sqlite3JournalSize(pVfs) ((pVfs)->szOsFile) + static int sqlite3JournalSize(sqlite3_vfs pVfs) { + return pVfs.szOsFile; + } #endif - //void sqlite3MemJournalOpen(sqlite3_file ); - //int sqlite3MemJournalSize(void); - //int sqlite3IsMemJournal(sqlite3_file ); + //void sqlite3MemJournalOpen(sqlite3_file ); + //int sqlite3MemJournalSize(void); + //int sqlite3IsMemJournal(sqlite3_file ); #if SQLITE_MAX_EXPR_DEPTH//>0 - // void sqlite3ExprSetHeight(Parse pParse, Expr p); - // int sqlite3SelectExprHeight(Select ); - //int sqlite3ExprCheckHeight(Parse*, int); + // void sqlite3ExprSetHeight(Parse pParse, Expr p); + // int sqlite3SelectExprHeight(Select ); + //int sqlite3ExprCheckHeight(Parse*, int); #else //#define sqlite3ExprSetHeight(x,y) //#define sqlite3SelectExprHeight(x) 0 //#define sqlite3ExprCheckHeight(x,y) #endif - //u32 sqlite3Get4byte(const u8); - //void sqlite3sqlite3Put4byte(u8*, u32); + //u32 sqlite3Get4byte(const u8); + //void sqlite3sqlite3Put4byte(u8*, u32); #if SQLITE_ENABLE_UNLOCK_NOTIFY void sqlite3ConnectionBlocked(sqlite3 *, sqlite3 ); void sqlite3ConnectionUnlocked(sqlite3 db); void sqlite3ConnectionClosed(sqlite3 db); #else - static void sqlite3ConnectionBlocked( sqlite3 x, sqlite3 y ) - { - } //#define sqlite3ConnectionBlocked(x,y) - static void sqlite3ConnectionUnlocked( sqlite3 x ) - { - } //#define sqlite3ConnectionUnlocked(x) - static void sqlite3ConnectionClosed( sqlite3 x ) - { - } //#define sqlite3ConnectionClosed(x) + static void sqlite3ConnectionBlocked(sqlite3 x, sqlite3 y) { + } //#define sqlite3ConnectionBlocked(x,y) + static void sqlite3ConnectionUnlocked(sqlite3 x) { + } //#define sqlite3ConnectionUnlocked(x) + static void sqlite3ConnectionClosed(sqlite3 x) { + } //#define sqlite3ConnectionClosed(x) #endif #if SQLITE_DEBUG - // void sqlite3ParserTrace(FILE*, char ); + // void sqlite3ParserTrace(FILE*, char ); #endif - /* -** If the SQLITE_ENABLE IOTRACE exists then the global variable -** sqlite3IoTrace is a pointer to a printf-like routine used to -** print I/O tracing messages. -*/ + /* + ** If the SQLITE_ENABLE IOTRACE exists then the global variable + ** sqlite3IoTrace is a pointer to a printf-like routine used to + ** print I/O tracing messages. + */ #if SQLITE_ENABLE_IOTRACE static bool SQLite3IoTrace = false; //#define IOTRACE(A) if( sqlite3IoTrace ){ sqlite3IoTrace A; } @@ -4566,76 +4385,71 @@ static void sqlite3ConnectionClosed( sqlite3 x ) // void sqlite3VdbeIOTraceSql(Vdbe); //SQLITE_EXTERN void (*sqlite3IoTrace)(const char*,...); #else - //#define IOTRACE(A) - static void IOTRACE( string F, params object[] ap ) - { - } - //#define sqlite3VdbeIOTraceSql(X) - static void sqlite3VdbeIOTraceSql( Vdbe X ) - { - } + //#define IOTRACE(A) + static void IOTRACE(string F, params object[] ap) { + } + //#define sqlite3VdbeIOTraceSql(X) + static void sqlite3VdbeIOTraceSql(Vdbe X) { + } #endif - /* -** These routines are available for the mem2.c debugging memory allocator -** only. They are used to verify that different "types" of memory -** allocations are properly tracked by the system. -** -** sqlite3MemdebugSetType() sets the "type" of an allocation to one of -** the MEMTYPE_* macros defined below. The type must be a bitmask with -** a single bit set. -** -** sqlite3MemdebugHasType() returns true if any of the bits in its second -** argument match the type set by the previous sqlite3MemdebugSetType(). -** sqlite3MemdebugHasType() is intended for use inside Debug.Assert() statements. -** -** sqlite3MemdebugNoType() returns true if none of the bits in its second -** argument match the type set by the previous sqlite3MemdebugSetType(). -** -** Perhaps the most important point is the difference between MEMTYPE_HEAP -** and MEMTYPE_LOOKASIDE. If an allocation is MEMTYPE_LOOKASIDE, that means -** it might have been allocated by lookaside, except the allocation was -** too large or lookaside was already full. It is important to verify -** that allocations that might have been satisfied by lookaside are not -** passed back to non-lookaside free() routines. Asserts such as the -** example above are placed on the non-lookaside free() routines to verify -** this constraint. -** -** All of this is no-op for a production build. It only comes into -** play when the SQLITE_MEMDEBUG compile-time option is used. -*/ + /* + ** These routines are available for the mem2.c debugging memory allocator + ** only. They are used to verify that different "types" of memory + ** allocations are properly tracked by the system. + ** + ** sqlite3MemdebugSetType() sets the "type" of an allocation to one of + ** the MEMTYPE_* macros defined below. The type must be a bitmask with + ** a single bit set. + ** + ** sqlite3MemdebugHasType() returns true if any of the bits in its second + ** argument match the type set by the previous sqlite3MemdebugSetType(). + ** sqlite3MemdebugHasType() is intended for use inside Debug.Assert() statements. + ** + ** sqlite3MemdebugNoType() returns true if none of the bits in its second + ** argument match the type set by the previous sqlite3MemdebugSetType(). + ** + ** Perhaps the most important point is the difference between MEMTYPE_HEAP + ** and MEMTYPE_LOOKASIDE. If an allocation is MEMTYPE_LOOKASIDE, that means + ** it might have been allocated by lookaside, except the allocation was + ** too large or lookaside was already full. It is important to verify + ** that allocations that might have been satisfied by lookaside are not + ** passed back to non-lookaside free() routines. Asserts such as the + ** example above are placed on the non-lookaside free() routines to verify + ** this constraint. + ** + ** All of this is no-op for a production build. It only comes into + ** play when the SQLITE_MEMDEBUG compile-time option is used. + */ #if SQLITE_MEMDEBUG // void sqlite3MemdebugSetType(void*,u8); // int sqlite3MemdebugHasType(void*,u8); // int sqlite3MemdebugNoType(void*,u8); #else - //# define sqlite3MemdebugSetType(X,Y) /* no-op */ - static void sqlite3MemdebugSetType( T X, int Y ) - { - } - //# define sqlite3MemdebugHasType(X,Y) 1 - static bool sqlite3MemdebugHasType( T X, int Y ) - { - return true; - } - //# define sqlite3MemdebugNoType(X,Y) 1 - static bool sqlite3MemdebugNoType( T X, int Y ) - { - return true; - } + //# define sqlite3MemdebugSetType(X,Y) /* no-op */ + static void sqlite3MemdebugSetType(T X, int Y) { + } + //# define sqlite3MemdebugHasType(X,Y) 1 + static bool sqlite3MemdebugHasType(T X, int Y) { + return true; + } + //# define sqlite3MemdebugNoType(X,Y) 1 + static bool sqlite3MemdebugNoType(T X, int Y) { + return true; + } #endif - //#define MEMTYPE_HEAP 0x01 /* General heap allocations */ - //#define MEMTYPE_LOOKASIDE 0x02 /* Might have been lookaside memory */ - //#define MEMTYPE_SCRATCH 0x04 /* Scratch allocations */ - //#define MEMTYPE_PCACHE 0x08 /* Page cache allocations */ - //#define MEMTYPE_DB 0x10 /* Uses sqlite3DbMalloc, not sqlite_malloc */ - public const int MEMTYPE_HEAP = 0x01; - public const int MEMTYPE_LOOKASIDE = 0x02; - public const int MEMTYPE_SCRATCH = 0x04; - public const int MEMTYPE_PCACHE = 0x08; - public const int MEMTYPE_DB = 0x10; - - //#endif //* _SQLITEINT_H_ */ - - } + //#define MEMTYPE_HEAP 0x01 /* General heap allocations */ + //#define MEMTYPE_LOOKASIDE 0x02 /* Might have been lookaside memory */ + //#define MEMTYPE_SCRATCH 0x04 /* Scratch allocations */ + //#define MEMTYPE_PCACHE 0x08 /* Page cache allocations */ + //#define MEMTYPE_DB 0x10 /* Uses sqlite3DbMalloc, not sqlite_malloc */ + public const int MEMTYPE_HEAP = 0x01; + public const int MEMTYPE_LOOKASIDE = 0x02; + public const int MEMTYPE_SCRATCH = 0x04; + public const int MEMTYPE_PCACHE = 0x08; + public const int MEMTYPE_DB = 0x10; + + //#endif //* _SQLITEINT_H_ */ + + } } diff --git a/Src/IronPython.SQLite/c#sqlite/sqliteLimit_h.cs b/Src/IronPython.SQLite/c#sqlite/sqliteLimit_h.cs index 713eb3960..fe9e26555 100644 --- a/Src/IronPython.SQLite/c#sqlite/sqliteLimit_h.cs +++ b/Src/IronPython.SQLite/c#sqlite/sqliteLimit_h.cs @@ -1,189 +1,187 @@ -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 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. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 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. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ + /* + ** 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. + */ +#if !SQLITE_MAX_LENGTH + const int SQLITE_MAX_LENGTH = 1000000000; +#endif + + /* + ** This is the maximum number of ** - ************************************************************************* - */ - /* - ** The maximum length of a TEXT or BLOB in bytes. This also - ** limits the size of a row in a table or index. + ** * 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 limit is the ability of a 32-bit signed integer - ** to count the size: 2^31-1 or 2147483647. + ** 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. */ -#if !SQLITE_MAX_LENGTH - const int 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. -*/ #if !SQLITE_MAX_COLUMN - const int SQLITE_MAX_COLUMN = 2000; + const int 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. -*/ + /* + ** 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. + */ #if !SQLITE_MAX_SQL_LENGTH - const int 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. -*/ + const int 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. + */ #if !SQLITE_MAX_EXPR_DEPTH - const int SQLITE_MAX_EXPR_DEPTH = 1000; + const int 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. -*/ + /* + ** 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. + */ #if !SQLITE_MAX_COMPOUND_SELECT - const int SQLITE_MAX_COMPOUND_SELECT = 250; + const int SQLITE_MAX_COMPOUND_SELECT = 250; #endif - /* -** The maximum number of opcodes in a VDBE program. -** Not currently enforced. -*/ + /* + ** The maximum number of opcodes in a VDBE program. + ** Not currently enforced. + */ #if !SQLITE_MAX_VDBE_OP - const int SQLITE_MAX_VDBE_OP = 25000; + const int SQLITE_MAX_VDBE_OP = 25000; #endif - /* -** The maximum number of arguments to an SQL function. -*/ + /* + ** The maximum number of arguments to an SQL function. + */ #if !SQLITE_MAX_FUNCTION_ARG - const int SQLITE_MAX_FUNCTION_ARG = 127;//# define SQLITE_MAX_FUNCTION_ARG 127 + const int SQLITE_MAX_FUNCTION_ARG = 127;//# 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 -*/ + /* + ** The maximum number of in-memory pages to use for the main database + ** table and for temporary tables. The SQLITE_DEFAULT_CACHE_SIZE + */ #if !SQLITE_DEFAULT_CACHE_SIZE - const int SQLITE_DEFAULT_CACHE_SIZE = 2000; + const int SQLITE_DEFAULT_CACHE_SIZE = 2000; #endif #if !SQLITE_DEFAULT_TEMP_CACHE_SIZE - const int SQLITE_DEFAULT_TEMP_CACHE_SIZE = 500; + const int 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. -*/ + /* + ** The default number of frames to accumulate in the log file before + ** checkpointing the database in WAL mode. + */ #if !SQLITE_DEFAULT_WAL_AUTOCHECKPOINT - const int SQLITE_DEFAULT_WAL_AUTOCHECKPOINT = 1000; - //# define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT 1000 + const int SQLITE_DEFAULT_WAL_AUTOCHECKPOINT = 1000; + //# 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. -*/ + /* + ** 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. + */ #if !SQLITE_MAX_ATTACHED - const int SQLITE_MAX_ATTACHED = 10; + const int SQLITE_MAX_ATTACHED = 10; #endif - /* -** The maximum value of a ?nnn wildcard that the parser will accept. -*/ + /* + ** The maximum value of a ?nnn wildcard that the parser will accept. + */ #if !SQLITE_MAX_VARIABLE_NUMBER - const int 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. -*/ - //#if SQLITE_MAX_PAGE_SIZE - //# undef SQLITE_MAX_PAGE_SIZE - //#endif - //#define SQLITE_MAX_PAGE_SIZE 65536 - const int SQLITE_MAX_PAGE_SIZE = 65535; - - - /* -** The default size of a database page. -*/ + const int 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. + */ + //#if SQLITE_MAX_PAGE_SIZE + //# undef SQLITE_MAX_PAGE_SIZE + //#endif + //#define SQLITE_MAX_PAGE_SIZE 65536 + const int SQLITE_MAX_PAGE_SIZE = 65535; + + + /* + ** The default size of a database page. + */ #if !SQLITE_DEFAULT_PAGE_SIZE - const int SQLITE_DEFAULT_PAGE_SIZE = 1024; + const int SQLITE_DEFAULT_PAGE_SIZE = 1024; #endif #if SQLITE_DEFAULT_PAGE_SIZE //SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE //# undef SQLITE_DEFAULT_PAGE_SIZE const int 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. -*/ + /* + ** 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. + */ #if !SQLITE_MAX_DEFAULT_PAGE_SIZE - const int SQLITE_MAX_DEFAULT_PAGE_SIZE = 8192; + const int SQLITE_MAX_DEFAULT_PAGE_SIZE = 8192; #endif #if SQLITE_MAX_DEFAULT_PAGE_SIZE //SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE //# undef SQLITE_MAX_DEFAULT_PAGE_SIZE @@ -191,36 +189,36 @@ const int 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. -*/ + /* + ** 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. + */ #if !SQLITE_MAX_PAGE_COUNT - const int SQLITE_MAX_PAGE_COUNT = 1073741823; + const int SQLITE_MAX_PAGE_COUNT = 1073741823; #endif - /* -** Maximum length (in bytes) of the pattern in a LIKE or GLOB -** operator. -*/ - //#if !SQLITE_MAX_LIKE_PATTERN_LENGTH - const int 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. + /* + ** Maximum length (in bytes) of the pattern in a LIKE or GLOB + ** operator. */ + //#if !SQLITE_MAX_LIKE_PATTERN_LENGTH + const int 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. + */ #if !SQLITE_MAX_TRIGGER_DEPTH - const int SQLITE_MAX_TRIGGER_DEPTH = 101; // # define SQLITE_MAX_TRIGGER_DEPTH 1000 + const int SQLITE_MAX_TRIGGER_DEPTH = 101; // # define SQLITE_MAX_TRIGGER_DEPTH 1000 #else const int SQLITE_MAX_TRIGGER_DEPTH=1; #endif - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/status_c.cs b/Src/IronPython.SQLite/c#sqlite/status_c.cs index 0e4b53f47..98dd93aaa 100644 --- a/Src/IronPython.SQLite/c#sqlite/status_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/status_c.cs @@ -1,277 +1,244 @@ -using System; using System.Diagnostics; -using System.Text; -namespace Community.CsharpSqlite -{ - using sqlite3_value = Sqlite3.Mem; - - public partial class Sqlite3 - { - /* - ** 2008 June 18 - ** - ** 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 module implements the sqlite3_status() interface and related - ** functionality. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include "vdbeInt.h" - - /* - ** Variables in which to record status information. - */ - //typedef struct sqlite3StatType sqlite3StatType; - public class sqlite3StatType - { - public int[] nowValue = new int[10]; /* Current value */ - public int[] mxValue = new int[10]; /* Maximum value */ - } - public static sqlite3StatType sqlite3Stat = new sqlite3StatType(); +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2008 June 18 + ** + ** 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 module implements the sqlite3_status() interface and related + ** functionality. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include "vdbeInt.h" - /* The "wsdStat" macro will resolve to the status information - ** state vector. If writable static data is unsupported on the target, - ** we have to locate the state vector at run-time. In the more common - ** case where writable static data is supported, wsdStat can refer directly - ** to the "sqlite3Stat" state vector declared above. - */ + /* + ** Variables in which to record status information. + */ + //typedef struct sqlite3StatType sqlite3StatType; + public class sqlite3StatType { + public int[] nowValue = new int[10]; /* Current value */ + public int[] mxValue = new int[10]; /* Maximum value */ + } + public static sqlite3StatType sqlite3Stat = new sqlite3StatType(); + + /* The "wsdStat" macro will resolve to the status information + ** state vector. If writable static data is unsupported on the target, + ** we have to locate the state vector at run-time. In the more common + ** case where writable static data is supported, wsdStat can refer directly + ** to the "sqlite3Stat" state vector declared above. + */ #if SQLITE_OMIT_WSD //# define wsdStatInit sqlite3StatType *x = &GLOBAL(sqlite3StatType,sqlite3Stat) //# define wsdStat x[0] #else - //# define wsdStatInit - static void wsdStatInit() - { - } - //# define wsdStat sqlite3Stat - static sqlite3StatType wsdStat = sqlite3Stat; + //# define wsdStatInit + static void wsdStatInit() { + } + //# define wsdStat sqlite3Stat + static sqlite3StatType wsdStat = sqlite3Stat; #endif - /* -** Return the current value of a status parameter. -*/ - static int sqlite3StatusValue( int op ) - { - wsdStatInit(); - Debug.Assert( op >= 0 && op < ArraySize( wsdStat.nowValue ) ); - return wsdStat.nowValue[op]; - } - - /* - ** Add N to the value of a status record. It is assumed that the - ** caller holds appropriate locks. - */ - static void sqlite3StatusAdd( int op, int N ) - { - wsdStatInit(); - Debug.Assert( op >= 0 && op < ArraySize( wsdStat.nowValue ) ); - wsdStat.nowValue[op] += N; - if ( wsdStat.nowValue[op] > wsdStat.mxValue[op] ) - { - wsdStat.mxValue[op] = wsdStat.nowValue[op]; - } - } - - /* - ** Set the value of a status to X. + /* + ** Return the current value of a status parameter. */ - static void sqlite3StatusSet( int op, int X ) - { - wsdStatInit(); - Debug.Assert( op >= 0 && op < ArraySize( wsdStat.nowValue ) ); - wsdStat.nowValue[op] = X; - if ( wsdStat.nowValue[op] > wsdStat.mxValue[op] ) - { - wsdStat.mxValue[op] = wsdStat.nowValue[op]; - } - } + static int sqlite3StatusValue(int op) { + wsdStatInit(); + Debug.Assert(op >= 0 && op < ArraySize(wsdStat.nowValue)); + return wsdStat.nowValue[op]; + } - /* - ** Query status information. - ** - ** This implementation assumes that reading or writing an aligned - ** 32-bit integer is an atomic operation. If that assumption is not true, - ** then this routine is not threadsafe. - */ - static public int sqlite3_status( int op, ref int pCurrent, ref int pHighwater, int resetFlag ) - { - wsdStatInit(); - if ( op < 0 || op >= ArraySize( wsdStat.nowValue ) ) - { - return SQLITE_MISUSE_BKPT(); - } - pCurrent = wsdStat.nowValue[op]; - pHighwater = wsdStat.mxValue[op]; - if ( resetFlag != 0 ) - { - wsdStat.mxValue[op] = wsdStat.nowValue[op]; - } - return SQLITE_OK; - } - /* - ** Query status information for a single database connection - */ - static public int sqlite3_db_status( - sqlite3 db, /* The database connection whose status is desired */ - int op, /* Status verb */ - ref int pCurrent, /* Write current value here */ - ref int pHighwater, /* Write high-water mark here */ - int resetFlag /* Reset high-water mark if true */ - ) - { - int rc = SQLITE_OK; /* Return code */ - sqlite3_mutex_enter( db.mutex ); - switch ( op ) - { - case SQLITE_DBSTATUS_LOOKASIDE_USED: - { - pCurrent = db.lookaside.nOut; - pHighwater = db.lookaside.mxOut; - if ( resetFlag != 0 ) - { - db.lookaside.mxOut = db.lookaside.nOut; - } - break; - } - case SQLITE_DBSTATUS_LOOKASIDE_HIT: - case SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE: - case SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL: - { - testcase( op == SQLITE_DBSTATUS_LOOKASIDE_HIT ); - testcase( op == SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE ); - testcase( op == SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL ); - Debug.Assert( ( op - SQLITE_DBSTATUS_LOOKASIDE_HIT ) >= 0 ); - Debug.Assert( ( op - SQLITE_DBSTATUS_LOOKASIDE_HIT ) < 3 ); - pCurrent = 0; - pHighwater = db.lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT]; - if ( resetFlag != 0 ) - { - db.lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT] = 0; + /* + ** Add N to the value of a status record. It is assumed that the + ** caller holds appropriate locks. + */ + static void sqlite3StatusAdd(int op, int N) { + wsdStatInit(); + Debug.Assert(op >= 0 && op < ArraySize(wsdStat.nowValue)); + wsdStat.nowValue[op] += N; + if (wsdStat.nowValue[op] > wsdStat.mxValue[op]) { + wsdStat.mxValue[op] = wsdStat.nowValue[op]; } - break; - } + } - /* - ** Return an approximation for the amount of memory currently used - ** by all pagers associated with the given database connection. The - ** highwater mark is meaningless and is returned as zero. + /* + ** Set the value of a status to X. */ - case SQLITE_DBSTATUS_CACHE_USED: - { - int totalUsed = 0; - int i; - sqlite3BtreeEnterAll( db ); - for ( i = 0; i < db.nDb; i++ ) - { - Btree pBt = db.aDb[i].pBt; - if ( pBt != null ) - { - Pager pPager = sqlite3BtreePager( pBt ); - totalUsed += sqlite3PagerMemUsed( pPager ); - } + static void sqlite3StatusSet(int op, int X) { + wsdStatInit(); + Debug.Assert(op >= 0 && op < ArraySize(wsdStat.nowValue)); + wsdStat.nowValue[op] = X; + if (wsdStat.nowValue[op] > wsdStat.mxValue[op]) { + wsdStat.mxValue[op] = wsdStat.nowValue[op]; } - sqlite3BtreeLeaveAll( db ); - pCurrent = totalUsed; - pHighwater = 0; - break; - } + } /* - ** *pCurrent gets an accurate estimate of the amount of memory used - ** to store the schema for all databases (main, temp, and any ATTACHed - ** databases. *pHighwater is set to zero. + ** Query status information. + ** + ** This implementation assumes that reading or writing an aligned + ** 32-bit integer is an atomic operation. If that assumption is not true, + ** then this routine is not threadsafe. */ - case SQLITE_DBSTATUS_SCHEMA_USED: - { - int i; /* Used to iterate through schemas */ - int nByte = 0; /* Used to accumulate return value */ - - sqlite3BtreeEnterAll( db ); - //db.pnBytesFreed = nByte; - for ( i = 0; i < db.nDb; i++ ) - { - Schema pSchema = db.aDb[i].pSchema; - if ( ALWAYS( pSchema != null ) ) - { - HashElem p; - - //nByte += (int)(sqlite3GlobalConfig.m.xRoundup(sizeof(HashElem)) * ( - // pSchema.tblHash.count - // + pSchema.trigHash.count - // + pSchema.idxHash.count - // + pSchema.fkeyHash.count - //)); - //nByte += (int)sqlite3MallocSize( pSchema.tblHash.ht ); - //nByte += (int)sqlite3MallocSize( pSchema.trigHash.ht ); - //nByte += (int)sqlite3MallocSize( pSchema.idxHash.ht ); - //nByte += (int)sqlite3MallocSize( pSchema.fkeyHash.ht ); - - for ( p = sqliteHashFirst( pSchema.trigHash ); p != null; p = sqliteHashNext( p ) ) - { - Trigger t = (Trigger)sqliteHashData( p ); - sqlite3DeleteTrigger( db, ref t ); - } - for ( p = sqliteHashFirst( pSchema.tblHash ); p != null; p = sqliteHashNext( p ) ) - { - Table t = (Table)sqliteHashData( p ); - sqlite3DeleteTable( db, ref t ); - } - } + static public int sqlite3_status(int op, ref int pCurrent, ref int pHighwater, int resetFlag) { + wsdStatInit(); + if (op < 0 || op >= ArraySize(wsdStat.nowValue)) { + return SQLITE_MISUSE_BKPT(); } - db.pnBytesFreed = 0; - sqlite3BtreeLeaveAll( db ); - - pHighwater = 0; - pCurrent = nByte; - break; - } - + pCurrent = wsdStat.nowValue[op]; + pHighwater = wsdStat.mxValue[op]; + if (resetFlag != 0) { + wsdStat.mxValue[op] = wsdStat.nowValue[op]; + } + return SQLITE_OK; + } /* - ** *pCurrent gets an accurate estimate of the amount of memory used - ** to store all prepared statements. - ** *pHighwater is set to zero. + ** Query status information for a single database connection */ - case SQLITE_DBSTATUS_STMT_USED: - { - Vdbe pVdbe; /* Used to iterate through VMs */ - int nByte = 0; /* Used to accumulate return value */ - - //db.pnBytesFreed = nByte; - for ( pVdbe = db.pVdbe; pVdbe != null; pVdbe = pVdbe.pNext ) - { - sqlite3VdbeDeleteObject( db, ref pVdbe ); + static public int sqlite3_db_status( + sqlite3 db, /* The database connection whose status is desired */ + int op, /* Status verb */ + ref int pCurrent, /* Write current value here */ + ref int pHighwater, /* Write high-water mark here */ + int resetFlag /* Reset high-water mark if true */ + ) { + int rc = SQLITE_OK; /* Return code */ + sqlite3_mutex_enter(db.mutex); + switch (op) { + case SQLITE_DBSTATUS_LOOKASIDE_USED: { + pCurrent = db.lookaside.nOut; + pHighwater = db.lookaside.mxOut; + if (resetFlag != 0) { + db.lookaside.mxOut = db.lookaside.nOut; + } + break; + } + case SQLITE_DBSTATUS_LOOKASIDE_HIT: + case SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE: + case SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL: { + testcase(op == SQLITE_DBSTATUS_LOOKASIDE_HIT); + testcase(op == SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE); + testcase(op == SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL); + Debug.Assert((op - SQLITE_DBSTATUS_LOOKASIDE_HIT) >= 0); + Debug.Assert((op - SQLITE_DBSTATUS_LOOKASIDE_HIT) < 3); + pCurrent = 0; + pHighwater = db.lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT]; + if (resetFlag != 0) { + db.lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT] = 0; + } + break; + } + + /* + ** Return an approximation for the amount of memory currently used + ** by all pagers associated with the given database connection. The + ** highwater mark is meaningless and is returned as zero. + */ + case SQLITE_DBSTATUS_CACHE_USED: { + int totalUsed = 0; + int i; + sqlite3BtreeEnterAll(db); + for (i = 0; i < db.nDb; i++) { + Btree pBt = db.aDb[i].pBt; + if (pBt != null) { + Pager pPager = sqlite3BtreePager(pBt); + totalUsed += sqlite3PagerMemUsed(pPager); + } + } + sqlite3BtreeLeaveAll(db); + pCurrent = totalUsed; + pHighwater = 0; + break; + } + + /* + ** *pCurrent gets an accurate estimate of the amount of memory used + ** to store the schema for all databases (main, temp, and any ATTACHed + ** databases. *pHighwater is set to zero. + */ + case SQLITE_DBSTATUS_SCHEMA_USED: { + int i; /* Used to iterate through schemas */ + int nByte = 0; /* Used to accumulate return value */ + + sqlite3BtreeEnterAll(db); + //db.pnBytesFreed = nByte; + for (i = 0; i < db.nDb; i++) { + Schema pSchema = db.aDb[i].pSchema; + if (ALWAYS(pSchema != null)) { + HashElem p; + + //nByte += (int)(sqlite3GlobalConfig.m.xRoundup(sizeof(HashElem)) * ( + // pSchema.tblHash.count + // + pSchema.trigHash.count + // + pSchema.idxHash.count + // + pSchema.fkeyHash.count + //)); + //nByte += (int)sqlite3MallocSize( pSchema.tblHash.ht ); + //nByte += (int)sqlite3MallocSize( pSchema.trigHash.ht ); + //nByte += (int)sqlite3MallocSize( pSchema.idxHash.ht ); + //nByte += (int)sqlite3MallocSize( pSchema.fkeyHash.ht ); + + for (p = sqliteHashFirst(pSchema.trigHash); p != null; p = sqliteHashNext(p)) { + Trigger t = (Trigger)sqliteHashData(p); + sqlite3DeleteTrigger(db, ref t); + } + for (p = sqliteHashFirst(pSchema.tblHash); p != null; p = sqliteHashNext(p)) { + Table t = (Table)sqliteHashData(p); + sqlite3DeleteTable(db, ref t); + } + } + } + db.pnBytesFreed = 0; + sqlite3BtreeLeaveAll(db); + + pHighwater = 0; + pCurrent = nByte; + break; + } + + /* + ** *pCurrent gets an accurate estimate of the amount of memory used + ** to store all prepared statements. + ** *pHighwater is set to zero. + */ + case SQLITE_DBSTATUS_STMT_USED: { + Vdbe pVdbe; /* Used to iterate through VMs */ + int nByte = 0; /* Used to accumulate return value */ + + //db.pnBytesFreed = nByte; + for (pVdbe = db.pVdbe; pVdbe != null; pVdbe = pVdbe.pNext) { + sqlite3VdbeDeleteObject(db, ref pVdbe); + } + db.pnBytesFreed = 0; + + pHighwater = 0; + pCurrent = nByte; + + break; + } + + default: { + rc = SQLITE_ERROR; + break; + } } - db.pnBytesFreed = 0; - - pHighwater = 0; - pCurrent = nByte; - - break; - } - - default: - { - rc = SQLITE_ERROR; - break; - } - } - sqlite3_mutex_leave( db.mutex ); - return rc; + sqlite3_mutex_leave(db.mutex); + return rc; + } } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/table_c.cs b/Src/IronPython.SQLite/c#sqlite/table_c.cs index c129d0da2..af6994916 100644 --- a/Src/IronPython.SQLite/c#sqlite/table_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/table_c.cs @@ -1,40 +1,33 @@ -using System; -using System.Diagnostics; - -using i64 = System.Int64; - -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 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. - ** - ************************************************************************* - ** This file contains the sqlite3_get_table() and //sqlite3_free_table() - ** interface routines. These are just wrappers around the main - ** interface routine of sqlite3_exec(). - ** - ** These routines are in a separate files so that they will not be linked - ** if they are not used. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include - //#include +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** This file contains the sqlite3_get_table() and //sqlite3_free_table() + ** interface routines. These are just wrappers around the main + ** interface routine of sqlite3_exec(). + ** + ** These routines are in a separate files so that they will not be linked + ** if they are not used. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include + //#include #if !SQLITE_OMIT_GET_TABLE @@ -217,5 +210,5 @@ ref string pzErrMsg /* Write error messages here */ } #endif //* SQLITE_OMIT_GET_TABLE */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/tokenize_c.cs b/Src/IronPython.SQLite/c#sqlite/tokenize_c.cs index 71b7f5aa4..542fcfb87 100644 --- a/Src/IronPython.SQLite/c#sqlite/tokenize_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/tokenize_c.cs @@ -1,669 +1,560 @@ -using System; using System.Diagnostics; using System.Text; -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 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. - ** - ************************************************************************* - ** An tokenizer for SQL - ** - ** This file contains C code that splits an SQL input string up into - ** individual tokens and sends those tokens one-by-one over to the - ** parser for analysis. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** An tokenizer for SQL + ** + ** This file contains C code that splits an SQL input string up into + ** individual tokens and sends those tokens one-by-one over to the + ** parser for analysis. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include - /* - ** The charMap() macro maps alphabetic characters into their - ** lower-case ASCII equivalent. On ASCII machines, this is just - ** an upper-to-lower case map. On EBCDIC machines we also need - ** to adjust the encoding. Only alphabetic characters and underscores - ** need to be translated. - */ + /* + ** The charMap() macro maps alphabetic characters into their + ** lower-case ASCII equivalent. On ASCII machines, this is just + ** an upper-to-lower case map. On EBCDIC machines we also need + ** to adjust the encoding. Only alphabetic characters and underscores + ** need to be translated. + */ #if SQLITE_ASCII - //# define charMap(X) sqlite3UpperToLower[(unsigned char)X] + //# define charMap(X) sqlite3UpperToLower[(unsigned char)X] #endif -//#if SQLITE_EBCDIC -//# define charMap(X) ebcdicToAscii[(unsigned char)X] -//const unsigned char ebcdicToAscii[] = { -///* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x */ -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 1x */ -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 2x */ -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 3x */ -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 4x */ -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 5x */ -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 0, 0, /* 6x */ -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 7x */ -// 0, 97, 98, 99,100,101,102,103,104,105, 0, 0, 0, 0, 0, 0, /* 8x */ -// 0,106,107,108,109,110,111,112,113,114, 0, 0, 0, 0, 0, 0, /* 9x */ -// 0, 0,115,116,117,118,119,120,121,122, 0, 0, 0, 0, 0, 0, /* Ax */ -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Bx */ -// 0, 97, 98, 99,100,101,102,103,104,105, 0, 0, 0, 0, 0, 0, /* Cx */ -// 0,106,107,108,109,110,111,112,113,114, 0, 0, 0, 0, 0, 0, /* Dx */ -// 0, 0,115,116,117,118,119,120,121,122, 0, 0, 0, 0, 0, 0, /* Ex */ -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Fx */ -//}; -//#endif + //#if SQLITE_EBCDIC + //# define charMap(X) ebcdicToAscii[(unsigned char)X] + //const unsigned char ebcdicToAscii[] = { + ///* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ + // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x */ + // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 1x */ + // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 2x */ + // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 3x */ + // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 4x */ + // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 5x */ + // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 0, 0, /* 6x */ + // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 7x */ + // 0, 97, 98, 99,100,101,102,103,104,105, 0, 0, 0, 0, 0, 0, /* 8x */ + // 0,106,107,108,109,110,111,112,113,114, 0, 0, 0, 0, 0, 0, /* 9x */ + // 0, 0,115,116,117,118,119,120,121,122, 0, 0, 0, 0, 0, 0, /* Ax */ + // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Bx */ + // 0, 97, 98, 99,100,101,102,103,104,105, 0, 0, 0, 0, 0, 0, /* Cx */ + // 0,106,107,108,109,110,111,112,113,114, 0, 0, 0, 0, 0, 0, /* Dx */ + // 0, 0,115,116,117,118,119,120,121,122, 0, 0, 0, 0, 0, 0, /* Ex */ + // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Fx */ + //}; + //#endif - /* -** The sqlite3KeywordCode function looks up an identifier to determine if -** it is a keyword. If it is a keyword, the token code of that keyword is -** returned. If the input is not a keyword, TK_ID is returned. -** -** The implementation of this routine was generated by a program, -** mkkeywordhash.h, located in the tool subdirectory of the distribution. -** The output of the mkkeywordhash.c program is written into a file -** named keywordhash.h and then included into this source file by -** the #include below. -*/ - //#include "keywordhash.h" - - - /* - ** If X is a character that can be used in an identifier then - ** IdChar(X) will be true. Otherwise it is false. - ** - ** For ASCII, any character with the high-order bit set is - ** allowed in an identifier. For 7-bit characters, - ** sqlite3IsIdChar[X] must be 1. + /* + ** The sqlite3KeywordCode function looks up an identifier to determine if + ** it is a keyword. If it is a keyword, the token code of that keyword is + ** returned. If the input is not a keyword, TK_ID is returned. ** - ** For EBCDIC, the rules are more complex but have the same - ** end result. - ** - ** Ticket #1066. the SQL standard does not allow '$' in the - ** middle of identfiers. But many SQL implementations do. - ** SQLite will allow '$' in identifiers for compatibility. - ** But the feature is undocumented. + ** The implementation of this routine was generated by a program, + ** mkkeywordhash.h, located in the tool subdirectory of the distribution. + ** The output of the mkkeywordhash.c program is written into a file + ** named keywordhash.h and then included into this source file by + ** the #include below. */ + //#include "keywordhash.h" + + + /* + ** If X is a character that can be used in an identifier then + ** IdChar(X) will be true. Otherwise it is false. + ** + ** For ASCII, any character with the high-order bit set is + ** allowed in an identifier. For 7-bit characters, + ** sqlite3IsIdChar[X] must be 1. + ** + ** For EBCDIC, the rules are more complex but have the same + ** end result. + ** + ** Ticket #1066. the SQL standard does not allow '$' in the + ** middle of identfiers. But many SQL implementations do. + ** SQLite will allow '$' in identifiers for compatibility. + ** But the feature is undocumented. + */ #if SQLITE_ASCII - //#define IdChar(C) ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0) + //#define IdChar(C) ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0) #endif -//#if SQLITE_EBCDIC -//const char sqlite3IsEbcdicIdChar[] = { -///* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */ -// 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 4x */ -// 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, /* 5x */ -// 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, /* 6x */ -// 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, /* 7x */ -// 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, /* 8x */ -// 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, /* 9x */ -// 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, /* Ax */ -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Bx */ -// 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Cx */ -// 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Dx */ -// 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Ex */ -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, /* Fx */ -//}; -//#define IdChar(C) (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40])) -//#endif + //#if SQLITE_EBCDIC + //const char sqlite3IsEbcdicIdChar[] = { + ///* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */ + // 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 4x */ + // 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, /* 5x */ + // 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, /* 6x */ + // 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, /* 7x */ + // 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, /* 8x */ + // 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, /* 9x */ + // 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, /* Ax */ + // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Bx */ + // 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Cx */ + // 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Dx */ + // 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Ex */ + // 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, /* Fx */ + //}; + //#define IdChar(C) (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40])) + //#endif - /* -** Return the length of the token that begins at z[iOffset + 0]. -** Store the token type in *tokenType before returning. -*/ - static int sqlite3GetToken( string z, int iOffset, ref int tokenType ) - { - int i; - byte c = 0; - switch ( z[iOffset + 0] ) - { - case ' ': - case '\t': - case '\n': - case '\f': - case '\r': - { - testcase( z[iOffset + 0] == ' ' ); - testcase( z[iOffset + 0] == '\t' ); - testcase( z[iOffset + 0] == '\n' ); - testcase( z[iOffset + 0] == '\f' ); - testcase( z[iOffset + 0] == '\r' ); - for ( i = 1; z.Length > iOffset + i && sqlite3Isspace( z[iOffset + i] ); i++ ) - { - } - tokenType = TK_SPACE; - return i; - } - case '-': - { - if ( z.Length > iOffset + 1 && z[iOffset + 1] == '-' ) - { - /* IMP: R-15891-05542 -- syntax diagram for comments */ - for ( i = 2; z.Length > iOffset + i && ( c = (byte)z[iOffset + i] ) != 0 && c != '\n'; i++ ) - { - } - tokenType = TK_SPACE; /* IMP: R-22934-25134 */ - return i; - } - tokenType = TK_MINUS; - return 1; - } - case '(': - { - tokenType = TK_LP; - return 1; - } - case ')': - { - tokenType = TK_RP; - return 1; - } - case ';': - { - tokenType = TK_SEMI; - return 1; - } - case '+': - { - tokenType = TK_PLUS; - return 1; - } - case '*': - { - tokenType = TK_STAR; - return 1; - } - case '/': - { - if ( iOffset + 2 >= z.Length || z[iOffset + 1] != '*' ) - { - tokenType = TK_SLASH; - return 1; - } - /* IMP: R-15891-05542 -- syntax diagram for comments */ - for ( i = 3, c = (byte)z[iOffset + 2]; iOffset + i < z.Length && ( c != '*' || ( z[iOffset + i] != '/' ) && ( c != 0 ) ); i++ ) - { - c = (byte)z[iOffset + i]; - } - if ( iOffset + i == z.Length ) - c = 0; - if ( c != 0 ) - i++; - tokenType = TK_SPACE; /* IMP: R-22934-25134 */ - return i; - } - case '%': - { - tokenType = TK_REM; - return 1; - } - case '=': - { - tokenType = TK_EQ; - return 1 + ( z[iOffset + 1] == '=' ? 1 : 0 ); - } - case '<': - { - if ( ( c = (byte)z[iOffset + 1] ) == '=' ) - { - tokenType = TK_LE; - return 2; - } - else if ( c == '>' ) - { - tokenType = TK_NE; - return 2; - } - else if ( c == '<' ) - { - tokenType = TK_LSHIFT; - return 2; - } - else - { - tokenType = TK_LT; - return 1; - } - } - case '>': - { - if ( z.Length > iOffset + 1 && ( c = (byte)z[iOffset + 1] ) == '=' ) - { - tokenType = TK_GE; - return 2; - } - else if ( c == '>' ) - { - tokenType = TK_RSHIFT; - return 2; - } - else - { - tokenType = TK_GT; - return 1; - } - } - case '!': - { - if ( z[iOffset + 1] != '=' ) - { - tokenType = TK_ILLEGAL; - return 2; - } - else - { - tokenType = TK_NE; - return 2; - } - } - case '|': - { - if ( z[iOffset + 1] != '|' ) - { - tokenType = TK_BITOR; - return 1; - } - else - { - tokenType = TK_CONCAT; - return 2; - } - } - case ',': - { - tokenType = TK_COMMA; - return 1; - } - case '&': - { - tokenType = TK_BITAND; - return 1; - } - case '~': - { - tokenType = TK_BITNOT; - return 1; - } - case '`': - case '\'': - case '"': - { - int delim = z[iOffset + 0]; - testcase( delim == '`' ); - testcase( delim == '\'' ); - testcase( delim == '"' ); - for ( i = 1; ( iOffset + i ) < z.Length && ( c = (byte)z[iOffset + i] ) != 0; i++ ) - { - if ( c == delim ) - { - if ( z.Length > iOffset + i + 1 && z[iOffset + i + 1] == delim ) - { - i++; - } - else - { - break; - } - } - } - if ( ( iOffset + i == z.Length && c != delim ) || z[iOffset + i] != delim ) - { - tokenType = TK_ILLEGAL; - return i + 1; - } - if ( c == '\'' ) - { - tokenType = TK_STRING; - return i + 1; - } - else if ( c != 0 ) - { - tokenType = TK_ID; - return i + 1; - } - else - { - tokenType = TK_ILLEGAL; - return i; - } - } - case '.': - { + /* + ** Return the length of the token that begins at z[iOffset + 0]. + ** Store the token type in *tokenType before returning. + */ + static int sqlite3GetToken(string z, int iOffset, ref int tokenType) { + int i; + byte c = 0; + switch (z[iOffset + 0]) { + case ' ': + case '\t': + case '\n': + case '\f': + case '\r': { + testcase(z[iOffset + 0] == ' '); + testcase(z[iOffset + 0] == '\t'); + testcase(z[iOffset + 0] == '\n'); + testcase(z[iOffset + 0] == '\f'); + testcase(z[iOffset + 0] == '\r'); + for (i = 1; z.Length > iOffset + i && sqlite3Isspace(z[iOffset + i]); i++) { + } + tokenType = TK_SPACE; + return i; + } + case '-': { + if (z.Length > iOffset + 1 && z[iOffset + 1] == '-') { + /* IMP: R-15891-05542 -- syntax diagram for comments */ + for (i = 2; z.Length > iOffset + i && (c = (byte)z[iOffset + i]) != 0 && c != '\n'; i++) { + } + tokenType = TK_SPACE; /* IMP: R-22934-25134 */ + return i; + } + tokenType = TK_MINUS; + return 1; + } + case '(': { + tokenType = TK_LP; + return 1; + } + case ')': { + tokenType = TK_RP; + return 1; + } + case ';': { + tokenType = TK_SEMI; + return 1; + } + case '+': { + tokenType = TK_PLUS; + return 1; + } + case '*': { + tokenType = TK_STAR; + return 1; + } + case '/': { + if (iOffset + 2 >= z.Length || z[iOffset + 1] != '*') { + tokenType = TK_SLASH; + return 1; + } + /* IMP: R-15891-05542 -- syntax diagram for comments */ + for (i = 3, c = (byte)z[iOffset + 2]; iOffset + i < z.Length && (c != '*' || (z[iOffset + i] != '/') && (c != 0)); i++) { + c = (byte)z[iOffset + i]; + } + if (iOffset + i == z.Length) + c = 0; + if (c != 0) + i++; + tokenType = TK_SPACE; /* IMP: R-22934-25134 */ + return i; + } + case '%': { + tokenType = TK_REM; + return 1; + } + case '=': { + tokenType = TK_EQ; + return 1 + (z[iOffset + 1] == '=' ? 1 : 0); + } + case '<': { + if ((c = (byte)z[iOffset + 1]) == '=') { + tokenType = TK_LE; + return 2; + } else if (c == '>') { + tokenType = TK_NE; + return 2; + } else if (c == '<') { + tokenType = TK_LSHIFT; + return 2; + } else { + tokenType = TK_LT; + return 1; + } + } + case '>': { + if (z.Length > iOffset + 1 && (c = (byte)z[iOffset + 1]) == '=') { + tokenType = TK_GE; + return 2; + } else if (c == '>') { + tokenType = TK_RSHIFT; + return 2; + } else { + tokenType = TK_GT; + return 1; + } + } + case '!': { + if (z[iOffset + 1] != '=') { + tokenType = TK_ILLEGAL; + return 2; + } else { + tokenType = TK_NE; + return 2; + } + } + case '|': { + if (z[iOffset + 1] != '|') { + tokenType = TK_BITOR; + return 1; + } else { + tokenType = TK_CONCAT; + return 2; + } + } + case ',': { + tokenType = TK_COMMA; + return 1; + } + case '&': { + tokenType = TK_BITAND; + return 1; + } + case '~': { + tokenType = TK_BITNOT; + return 1; + } + case '`': + case '\'': + case '"': { + int delim = z[iOffset + 0]; + testcase(delim == '`'); + testcase(delim == '\''); + testcase(delim == '"'); + for (i = 1; (iOffset + i) < z.Length && (c = (byte)z[iOffset + i]) != 0; i++) { + if (c == delim) { + if (z.Length > iOffset + i + 1 && z[iOffset + i + 1] == delim) { + i++; + } else { + break; + } + } + } + if ((iOffset + i == z.Length && c != delim) || z[iOffset + i] != delim) { + tokenType = TK_ILLEGAL; + return i + 1; + } + if (c == '\'') { + tokenType = TK_STRING; + return i + 1; + } else if (c != 0) { + tokenType = TK_ID; + return i + 1; + } else { + tokenType = TK_ILLEGAL; + return i; + } + } + case '.': { #if !SQLITE_OMIT_FLOATING_POINT - if ( !sqlite3Isdigit( z[iOffset + 1] ) ) + if (!sqlite3Isdigit(z[iOffset + 1])) #endif - { - tokenType = TK_DOT; - return 1; - } - /* If the next character is a digit, this is a floating point - ** number that begins with ".". Fall thru into the next case */ - goto case '0'; - } - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - testcase( z[iOffset] == '0' ); - testcase( z[iOffset] == '1' ); - testcase( z[iOffset] == '2' ); - testcase( z[iOffset] == '3' ); - testcase( z[iOffset] == '4' ); - testcase( z[iOffset] == '5' ); - testcase( z[iOffset] == '6' ); - testcase( z[iOffset] == '7' ); - testcase( z[iOffset] == '8' ); - testcase( z[iOffset] == '9' ); - tokenType = TK_INTEGER; - for ( i = 0; z.Length > iOffset + i && sqlite3Isdigit( z[iOffset + i] ); i++ ) - { - } + { + tokenType = TK_DOT; + return 1; + } + /* If the next character is a digit, this is a floating point + ** number that begins with ".". Fall thru into the next case */ + goto case '0'; + } + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': { + testcase(z[iOffset] == '0'); + testcase(z[iOffset] == '1'); + testcase(z[iOffset] == '2'); + testcase(z[iOffset] == '3'); + testcase(z[iOffset] == '4'); + testcase(z[iOffset] == '5'); + testcase(z[iOffset] == '6'); + testcase(z[iOffset] == '7'); + testcase(z[iOffset] == '8'); + testcase(z[iOffset] == '9'); + tokenType = TK_INTEGER; + for (i = 0; z.Length > iOffset + i && sqlite3Isdigit(z[iOffset + i]); i++) { + } #if !SQLITE_OMIT_FLOATING_POINT - if ( z.Length > iOffset + i && z[iOffset + i] == '.' ) - { - i++; - while ( z.Length > iOffset + i && sqlite3Isdigit( z[iOffset + i] ) ) - { - i++; - } - tokenType = TK_FLOAT; - } - if ( z.Length > iOffset + i + 1 && ( z[iOffset + i] == 'e' || z[iOffset + i] == 'E' ) && - ( sqlite3Isdigit( z[iOffset + i + 1] ) - || z.Length > iOffset + i + 2 && ( ( z[iOffset + i + 1] == '+' || z[iOffset + i + 1] == '-' ) && sqlite3Isdigit( z[iOffset + i + 2] ) ) - ) - ) - { - i += 2; - while ( z.Length > iOffset + i && sqlite3Isdigit( z[iOffset + i] ) ) - { - i++; - } - tokenType = TK_FLOAT; - } + if (z.Length > iOffset + i && z[iOffset + i] == '.') { + i++; + while (z.Length > iOffset + i && sqlite3Isdigit(z[iOffset + i])) { + i++; + } + tokenType = TK_FLOAT; + } + if (z.Length > iOffset + i + 1 && (z[iOffset + i] == 'e' || z[iOffset + i] == 'E') && + (sqlite3Isdigit(z[iOffset + i + 1]) + || z.Length > iOffset + i + 2 && ((z[iOffset + i + 1] == '+' || z[iOffset + i + 1] == '-') && sqlite3Isdigit(z[iOffset + i + 2])) + ) + ) { + i += 2; + while (z.Length > iOffset + i && sqlite3Isdigit(z[iOffset + i])) { + i++; + } + tokenType = TK_FLOAT; + } #endif - while ( iOffset + i < z.Length && IdChar( (byte)z[iOffset + i] ) ) - { - tokenType = TK_ILLEGAL; - i++; - } - return i; - } + while (iOffset + i < z.Length && IdChar((byte)z[iOffset + i])) { + tokenType = TK_ILLEGAL; + i++; + } + return i; + } - case '[': - { - for ( i = 1, c = (byte)z[iOffset + 0]; c != ']' && ( iOffset + i ) < z.Length && ( c = (byte)z[iOffset + i] ) != 0; i++ ) - { - } - tokenType = c == ']' ? TK_ID : TK_ILLEGAL; - return i; - } - case '?': - { - tokenType = TK_VARIABLE; - for ( i = 1; z.Length > iOffset + i && sqlite3Isdigit( z[iOffset + i] ); i++ ) - { - } - return i; - } - case '#': - { - for ( i = 1; z.Length > iOffset + i && sqlite3Isdigit( z[iOffset + i] ); i++ ) - { - } - if ( i > 1 ) - { - /* Parameters of the form #NNN (where NNN is a number) are used - ** internally by sqlite3NestedParse. */ - tokenType = TK_REGISTER; - return i; - } - /* Fall through into the next case if the '#' is not followed by - ** a digit. Try to match #AAAA where AAAA is a parameter name. */ - goto case ':'; - } + case '[': { + for (i = 1, c = (byte)z[iOffset + 0]; c != ']' && (iOffset + i) < z.Length && (c = (byte)z[iOffset + i]) != 0; i++) { + } + tokenType = c == ']' ? TK_ID : TK_ILLEGAL; + return i; + } + case '?': { + tokenType = TK_VARIABLE; + for (i = 1; z.Length > iOffset + i && sqlite3Isdigit(z[iOffset + i]); i++) { + } + return i; + } + case '#': { + for (i = 1; z.Length > iOffset + i && sqlite3Isdigit(z[iOffset + i]); i++) { + } + if (i > 1) { + /* Parameters of the form #NNN (where NNN is a number) are used + ** internally by sqlite3NestedParse. */ + tokenType = TK_REGISTER; + return i; + } + /* Fall through into the next case if the '#' is not followed by + ** a digit. Try to match #AAAA where AAAA is a parameter name. */ + goto case ':'; + } #if !SQLITE_OMIT_TCL_VARIABLE - case '$': + case '$': #endif - case '@': /* For compatibility with MS SQL Server */ - case ':': - { - int n = 0; - testcase( z[iOffset + 0] == '$' ); - testcase( z[iOffset + 0] == '@' ); - testcase( z[iOffset + 0] == ':' ); - tokenType = TK_VARIABLE; - for ( i = 1; z.Length > iOffset + i && ( c = (byte)z[iOffset + i] ) != 0; i++ ) - { - if ( IdChar( c ) ) - { - n++; + case '@': /* For compatibility with MS SQL Server */ + case ':': { + int n = 0; + testcase(z[iOffset + 0] == '$'); + testcase(z[iOffset + 0] == '@'); + testcase(z[iOffset + 0] == ':'); + tokenType = TK_VARIABLE; + for (i = 1; z.Length > iOffset + i && (c = (byte)z[iOffset + i]) != 0; i++) { + if (IdChar(c)) { + n++; #if !SQLITE_OMIT_TCL_VARIABLE - } - else if ( c == '(' && n > 0 ) - { - do - { - i++; - } while ( ( iOffset + i ) < z.Length && ( c = (byte)z[iOffset + i] ) != 0 && !sqlite3Isspace( c ) && c != ')' ); - if ( c == ')' ) - { - i++; - } - else - { - tokenType = TK_ILLEGAL; - } - break; - } - else if ( c == ':' && z[iOffset + i + 1] == ':' ) - { - i++; + } else if (c == '(' && n > 0) { + do { + i++; + } while ((iOffset + i) < z.Length && (c = (byte)z[iOffset + i]) != 0 && !sqlite3Isspace(c) && c != ')'); + if (c == ')') { + i++; + } else { + tokenType = TK_ILLEGAL; + } + break; + } else if (c == ':' && z[iOffset + i + 1] == ':') { + i++; #endif - } - else - { - break; - } - } - if ( n == 0 ) - tokenType = TK_ILLEGAL; - return i; - } + } else { + break; + } + } + if (n == 0) + tokenType = TK_ILLEGAL; + return i; + } #if !SQLITE_OMIT_BLOB_LITERAL - case 'x': - case 'X': - { - testcase( z[iOffset + 0] == 'x' ); - testcase( z[iOffset + 0] == 'X' ); - if ( z.Length > iOffset + 1 && z[iOffset + 1] == '\'' ) - { - tokenType = TK_BLOB; - for ( i = 2; z.Length > iOffset + i && sqlite3Isxdigit( z[iOffset + i] ); i++ ) - { - } - if ( iOffset + i == z.Length || z[iOffset + i] != '\'' || i % 2 != 0 ) - { - tokenType = TK_ILLEGAL; - while ( z.Length > iOffset + i && z[iOffset + i] != '\'' ) - { - i++; - } - } - if ( z.Length > iOffset + i ) - i++; - return i; - } - goto default; - /* Otherwise fall through to the next case */ - } + case 'x': + case 'X': { + testcase(z[iOffset + 0] == 'x'); + testcase(z[iOffset + 0] == 'X'); + if (z.Length > iOffset + 1 && z[iOffset + 1] == '\'') { + tokenType = TK_BLOB; + for (i = 2; z.Length > iOffset + i && sqlite3Isxdigit(z[iOffset + i]); i++) { + } + if (iOffset + i == z.Length || z[iOffset + i] != '\'' || i % 2 != 0) { + tokenType = TK_ILLEGAL; + while (z.Length > iOffset + i && z[iOffset + i] != '\'') { + i++; + } + } + if (z.Length > iOffset + i) + i++; + return i; + } + goto default; + /* Otherwise fall through to the next case */ + } #endif - default: - { - if ( !IdChar( (byte)z[iOffset] ) ) - { - break; - } - for ( i = 1; i < z.Length - iOffset && IdChar( (byte)z[iOffset + i] ); i++ ) - { - } - tokenType = keywordCode( z, iOffset, i ); - return i; - } - } - tokenType = TK_ILLEGAL; - return 1; - } + default: { + if (!IdChar((byte)z[iOffset])) { + break; + } + for (i = 1; i < z.Length - iOffset && IdChar((byte)z[iOffset + i]); i++) { + } + tokenType = keywordCode(z, iOffset, i); + return i; + } + } + tokenType = TK_ILLEGAL; + return 1; + } - /* - ** Run the parser on the given SQL string. The parser structure is - ** passed in. An SQLITE_ status code is returned. If an error occurs - ** then an and attempt is made to write an error message into - ** memory obtained from sqlite3_malloc() and to make pzErrMsg point to that - ** error message. - */ - static int sqlite3RunParser( Parse pParse, string zSql, ref string pzErrMsg ) - { - int nErr = 0; /* Number of errors encountered */ - int i; /* Loop counter */ - yyParser pEngine; /* The LEMON-generated LALR(1) parser */ - int tokenType = 0; /* type of the next token */ - int lastTokenParsed = -1; /* type of the previous token */ - byte enableLookaside; /* Saved value of db->lookaside.bEnabled */ - sqlite3 db = pParse.db; /* The database connection */ - int mxSqlLen; /* Max length of an SQL string */ + /* + ** Run the parser on the given SQL string. The parser structure is + ** passed in. An SQLITE_ status code is returned. If an error occurs + ** then an and attempt is made to write an error message into + ** memory obtained from sqlite3_malloc() and to make pzErrMsg point to that + ** error message. + */ + static int sqlite3RunParser(Parse pParse, string zSql, ref string pzErrMsg) { + int nErr = 0; /* Number of errors encountered */ + int i; /* Loop counter */ + yyParser pEngine; /* The LEMON-generated LALR(1) parser */ + int tokenType = 0; /* type of the next token */ + int lastTokenParsed = -1; /* type of the previous token */ + byte enableLookaside; /* Saved value of db->lookaside.bEnabled */ + sqlite3 db = pParse.db; /* The database connection */ + int mxSqlLen; /* Max length of an SQL string */ - mxSqlLen = db.aLimit[SQLITE_LIMIT_SQL_LENGTH]; - if ( db.activeVdbeCnt == 0 ) - { - db.u1.isInterrupted = false; - } - pParse.rc = SQLITE_OK; - pParse.zTail = new StringBuilder( zSql ); - i = 0; - Debug.Assert( pzErrMsg != null ); - pEngine = sqlite3ParserAlloc();//sqlite3ParserAlloc((void*(*)(size_t))sqlite3Malloc); - //if ( pEngine == null ) - //{ - // db.mallocFailed = 1; - // return SQLITE_NOMEM; - //} - Debug.Assert( pParse.pNewTable == null ); - Debug.Assert( pParse.pNewTrigger == null ); - Debug.Assert( pParse.nVar == 0 ); - Debug.Assert( pParse.nzVar == 0 ); - Debug.Assert( pParse.azVar == null ); - enableLookaside = db.lookaside.bEnabled; - if ( db.lookaside.pStart != 0 ) - db.lookaside.bEnabled = 1; - while ( /* 0 == db.mallocFailed && */ i < zSql.Length ) - { - Debug.Assert( i >= 0 ); - //pParse->sLastToken.z = &zSql[i]; - pParse.sLastToken.n = sqlite3GetToken( zSql, i, ref tokenType ); - pParse.sLastToken.z = zSql.Substring( i ); - i += pParse.sLastToken.n; - if ( i > mxSqlLen ) - { - pParse.rc = SQLITE_TOOBIG; - break; - } - switch ( tokenType ) - { - case TK_SPACE: - { - if ( db.u1.isInterrupted ) - { - sqlite3ErrorMsg( pParse, "interrupt" ); - pParse.rc = SQLITE_INTERRUPT; - goto abort_parse; - } - break; - } - case TK_ILLEGAL: - { - sqlite3DbFree( db, ref pzErrMsg ); - pzErrMsg = sqlite3MPrintf( db, "unrecognized token: \"%T\"", - (object)pParse.sLastToken ); - nErr++; - goto abort_parse; - } - case TK_SEMI: - { - //pParse.zTail = new StringBuilder(zSql.Substring( i,zSql.Length-i )); - /* Fall thru into the default case */ - goto default; + mxSqlLen = db.aLimit[SQLITE_LIMIT_SQL_LENGTH]; + if (db.activeVdbeCnt == 0) { + db.u1.isInterrupted = false; + } + pParse.rc = SQLITE_OK; + pParse.zTail = new StringBuilder(zSql); + i = 0; + Debug.Assert(pzErrMsg != null); + pEngine = sqlite3ParserAlloc();//sqlite3ParserAlloc((void*(*)(size_t))sqlite3Malloc); + //if ( pEngine == null ) + //{ + // db.mallocFailed = 1; + // return SQLITE_NOMEM; + //} + Debug.Assert(pParse.pNewTable == null); + Debug.Assert(pParse.pNewTrigger == null); + Debug.Assert(pParse.nVar == 0); + Debug.Assert(pParse.nzVar == 0); + Debug.Assert(pParse.azVar == null); + enableLookaside = db.lookaside.bEnabled; + if (db.lookaside.pStart != 0) + db.lookaside.bEnabled = 1; + while ( /* 0 == db.mallocFailed && */ i < zSql.Length) { + Debug.Assert(i >= 0); + //pParse->sLastToken.z = &zSql[i]; + pParse.sLastToken.n = sqlite3GetToken(zSql, i, ref tokenType); + pParse.sLastToken.z = zSql.Substring(i); + i += pParse.sLastToken.n; + if (i > mxSqlLen) { + pParse.rc = SQLITE_TOOBIG; + break; + } + switch (tokenType) { + case TK_SPACE: { + if (db.u1.isInterrupted) { + sqlite3ErrorMsg(pParse, "interrupt"); + pParse.rc = SQLITE_INTERRUPT; + goto abort_parse; + } + break; + } + case TK_ILLEGAL: { + sqlite3DbFree(db, ref pzErrMsg); + pzErrMsg = sqlite3MPrintf(db, "unrecognized token: \"%T\"", + (object)pParse.sLastToken); + nErr++; + goto abort_parse; + } + case TK_SEMI: { + //pParse.zTail = new StringBuilder(zSql.Substring( i,zSql.Length-i )); + /* Fall thru into the default case */ + goto default; + } + default: { + sqlite3Parser(pEngine, tokenType, pParse.sLastToken, pParse); + lastTokenParsed = tokenType; + if (pParse.rc != SQLITE_OK) { + goto abort_parse; + } + break; + } + } } - default: - { - sqlite3Parser( pEngine, tokenType, pParse.sLastToken, pParse ); - lastTokenParsed = tokenType; - if ( pParse.rc != SQLITE_OK ) - { - goto abort_parse; - } - break; + abort_parse: + pParse.zTail = new StringBuilder(zSql.Length <= i ? "" : zSql.Substring(i)); + if (zSql.Length >= i && nErr == 0 && pParse.rc == SQLITE_OK) { + if (lastTokenParsed != TK_SEMI) { + sqlite3Parser(pEngine, TK_SEMI, pParse.sLastToken, pParse); + } + sqlite3Parser(pEngine, 0, pParse.sLastToken, pParse); } - } - } -abort_parse: - pParse.zTail = new StringBuilder( zSql.Length <= i ? "" : zSql.Substring( i ) ); - if ( zSql.Length >= i && nErr == 0 && pParse.rc == SQLITE_OK ) - { - if ( lastTokenParsed != TK_SEMI ) - { - sqlite3Parser( pEngine, TK_SEMI, pParse.sLastToken, pParse ); - } - sqlite3Parser( pEngine, 0, pParse.sLastToken, pParse ); - } #if YYTRACKMAXSTACKDEPTH sqlite3StatusSet(SQLITE_STATUS_PARSER_STACK, sqlite3ParserStackPeak(pEngine) ); #endif //* YYDEBUG */ - sqlite3ParserFree( pEngine, null );//sqlite3_free ); - db.lookaside.bEnabled = enableLookaside; - //if ( db.mallocFailed != 0 ) - //{ - // pParse.rc = SQLITE_NOMEM; - //} - if ( pParse.rc != SQLITE_OK && pParse.rc != SQLITE_DONE && pParse.zErrMsg == "" ) - { - sqlite3SetString( ref pParse.zErrMsg, db, sqlite3ErrStr( pParse.rc ) ); - } - //assert( pzErrMsg!=0 ); - if ( pParse.zErrMsg != null ) - { - pzErrMsg = pParse.zErrMsg; - sqlite3_log( pParse.rc, "%s", pzErrMsg ); - pParse.zErrMsg = ""; - nErr++; - } - if ( pParse.pVdbe != null && pParse.nErr > 0 && pParse.nested == 0 ) - { - sqlite3VdbeDelete( ref pParse.pVdbe ); - pParse.pVdbe = null; - } + sqlite3ParserFree(pEngine, null);//sqlite3_free ); + db.lookaside.bEnabled = enableLookaside; + //if ( db.mallocFailed != 0 ) + //{ + // pParse.rc = SQLITE_NOMEM; + //} + if (pParse.rc != SQLITE_OK && pParse.rc != SQLITE_DONE && pParse.zErrMsg == "") { + sqlite3SetString(ref pParse.zErrMsg, db, sqlite3ErrStr(pParse.rc)); + } + //assert( pzErrMsg!=0 ); + if (pParse.zErrMsg != null) { + pzErrMsg = pParse.zErrMsg; + sqlite3_log(pParse.rc, "%s", pzErrMsg); + pParse.zErrMsg = ""; + nErr++; + } + if (pParse.pVdbe != null && pParse.nErr > 0 && pParse.nested == 0) { + sqlite3VdbeDelete(ref pParse.pVdbe); + pParse.pVdbe = null; + } #if !SQLITE_OMIT_SHARED_CACHE if ( pParse.nested == 0 ) { @@ -673,41 +564,37 @@ static int sqlite3RunParser( Parse pParse, string zSql, ref string pzErrMsg ) } #endif #if !SQLITE_OMIT_VIRTUALTABLE - pParse.apVtabLock = null;//sqlite3_free( pParse.apVtabLock ); + pParse.apVtabLock = null;//sqlite3_free( pParse.apVtabLock ); #endif - if ( !IN_DECLARE_VTAB(pParse) ) - { - /* If the pParse.declareVtab flag is set, do not delete any table - ** structure built up in pParse.pNewTable. The calling code (see vtab.c) - ** will take responsibility for freeing the Table structure. - */ - sqlite3DeleteTable( db, ref pParse.pNewTable ); - } + if (!IN_DECLARE_VTAB(pParse)) { + /* If the pParse.declareVtab flag is set, do not delete any table + ** structure built up in pParse.pNewTable. The calling code (see vtab.c) + ** will take responsibility for freeing the Table structure. + */ + sqlite3DeleteTable(db, ref pParse.pNewTable); + } #if !SQLITE_OMIT_TRIGGER - sqlite3DeleteTrigger( db, ref pParse.pNewTrigger ); + sqlite3DeleteTrigger(db, ref pParse.pNewTrigger); #endif - //for ( i = pParse.nzVar - 1; i >= 0; i-- ) - // sqlite3DbFree( db, pParse.azVar[i] ); - sqlite3DbFree( db, ref pParse.azVar ); - sqlite3DbFree( db, ref pParse.aAlias ); - while ( pParse.pAinc != null ) - { - AutoincInfo p = pParse.pAinc; - pParse.pAinc = p.pNext; - sqlite3DbFree( db, ref p ); - } - while ( pParse.pZombieTab != null ) - { - Table p = pParse.pZombieTab; - pParse.pZombieTab = p.pNextZombie; - sqlite3DeleteTable( db, ref p ); - } - if ( nErr > 0 && pParse.rc == SQLITE_OK ) - { - pParse.rc = SQLITE_ERROR; - } - return nErr; + //for ( i = pParse.nzVar - 1; i >= 0; i-- ) + // sqlite3DbFree( db, pParse.azVar[i] ); + sqlite3DbFree(db, ref pParse.azVar); + sqlite3DbFree(db, ref pParse.aAlias); + while (pParse.pAinc != null) { + AutoincInfo p = pParse.pAinc; + pParse.pAinc = p.pNext; + sqlite3DbFree(db, ref p); + } + while (pParse.pZombieTab != null) { + Table p = pParse.pZombieTab; + pParse.pZombieTab = p.pNextZombie; + sqlite3DeleteTable(db, ref p); + } + if (nErr > 0 && pParse.rc == SQLITE_OK) { + pParse.rc = SQLITE_ERROR; + } + return nErr; + } } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/trigger_c.cs b/Src/IronPython.SQLite/c#sqlite/trigger_c.cs index 6a29a4232..b27f77339 100644 --- a/Src/IronPython.SQLite/c#sqlite/trigger_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/trigger_c.cs @@ -1,266 +1,235 @@ using System; using System.Diagnostics; -using System.Text; -using u8 = System.Byte; using u32 = System.UInt32; -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** - ** 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 contains the implementation for TRIGGERs - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +using u8 = System.Byte; +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** + ** 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 contains the implementation for TRIGGERs + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" #if !SQLITE_OMIT_TRIGGER - /* -** Delete a linked list of TriggerStep structures. -*/ - static void sqlite3DeleteTriggerStep( sqlite3 db, ref TriggerStep pTriggerStep ) - { - while ( pTriggerStep != null ) - { - TriggerStep pTmp = pTriggerStep; - pTriggerStep = pTriggerStep.pNext; - - sqlite3ExprDelete( db, ref pTmp.pWhere ); - sqlite3ExprListDelete( db, ref pTmp.pExprList ); - sqlite3SelectDelete( db, ref pTmp.pSelect ); - sqlite3IdListDelete( db, ref pTmp.pIdList ); - - pTriggerStep = null; - sqlite3DbFree( db, ref pTmp ); - } - } - - /* - ** Given table pTab, return a list of all the triggers attached to - ** the table. The list is connected by Trigger.pNext pointers. - ** - ** All of the triggers on pTab that are in the same database as pTab - ** are already attached to pTab.pTrigger. But there might be additional - ** triggers on pTab in the TEMP schema. This routine prepends all - ** TEMP triggers on pTab to the beginning of the pTab.pTrigger list - ** and returns the combined list. - ** - ** To state it another way: This routine returns a list of all triggers - ** that fire off of pTab. The list will include any TEMP triggers on - ** pTab as well as the triggers lised in pTab.pTrigger. + /* + ** Delete a linked list of TriggerStep structures. */ - static Trigger sqlite3TriggerList( Parse pParse, Table pTab ) - { - Schema pTmpSchema = pParse.db.aDb[1].pSchema; - Trigger pList = null; /* List of triggers to return */ - - if ( pParse.disableTriggers != 0 ) - { - return null; - } - - if ( pTmpSchema != pTab.pSchema ) - { - HashElem p; - Debug.Assert( sqlite3SchemaMutexHeld( pParse.db, 0, pTmpSchema ) ); - for ( p = sqliteHashFirst( pTmpSchema.trigHash ); p != null; p = sqliteHashNext( p ) ) - { - Trigger pTrig = (Trigger)sqliteHashData( p ); - if ( pTrig.pTabSchema == pTab.pSchema - && pTrig.table.Equals( pTab.zName, StringComparison.OrdinalIgnoreCase ) ) - { - pTrig.pNext = ( pList != null ? pList : pTab.pTrigger ); - pList = pTrig; - } + static void sqlite3DeleteTriggerStep(sqlite3 db, ref TriggerStep pTriggerStep) { + while (pTriggerStep != null) { + TriggerStep pTmp = pTriggerStep; + pTriggerStep = pTriggerStep.pNext; + + sqlite3ExprDelete(db, ref pTmp.pWhere); + sqlite3ExprListDelete(db, ref pTmp.pExprList); + sqlite3SelectDelete(db, ref pTmp.pSelect); + sqlite3IdListDelete(db, ref pTmp.pIdList); + + pTriggerStep = null; + sqlite3DbFree(db, ref pTmp); + } } - } - return ( pList != null ? pList : pTab.pTrigger ); - } + /* + ** Given table pTab, return a list of all the triggers attached to + ** the table. The list is connected by Trigger.pNext pointers. + ** + ** All of the triggers on pTab that are in the same database as pTab + ** are already attached to pTab.pTrigger. But there might be additional + ** triggers on pTab in the TEMP schema. This routine prepends all + ** TEMP triggers on pTab to the beginning of the pTab.pTrigger list + ** and returns the combined list. + ** + ** To state it another way: This routine returns a list of all triggers + ** that fire off of pTab. The list will include any TEMP triggers on + ** pTab as well as the triggers lised in pTab.pTrigger. + */ + static Trigger sqlite3TriggerList(Parse pParse, Table pTab) { + Schema pTmpSchema = pParse.db.aDb[1].pSchema; + Trigger pList = null; /* List of triggers to return */ - /* - ** This is called by the parser when it sees a CREATE TRIGGER statement - ** up to the point of the BEGIN before the trigger actions. A Trigger - ** structure is generated based on the information available and stored - ** in pParse.pNewTrigger. After the trigger actions have been parsed, the - ** sqlite3FinishTrigger() function is called to complete the trigger - ** construction process. - */ - static void sqlite3BeginTrigger( - Parse pParse, /* The parse context of the CREATE TRIGGER statement */ - Token pName1, /* The name of the trigger */ - Token pName2, /* The name of the trigger */ - int tr_tm, /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */ - int op, /* One of TK_INSERT, TK_UPDATE, TK_DELETE */ - IdList pColumns, /* column list if this is an UPDATE OF trigger */ - SrcList pTableName,/* The name of the table/view the trigger applies to */ - Expr pWhen, /* WHEN clause */ - int isTemp, /* True if the TEMPORARY keyword is present */ - int noErr /* Suppress errors if the trigger already exists */ - ) - { - Trigger pTrigger = null; /* The new trigger */ - Table pTab; /* Table that the trigger fires off of */ - string zName = null; /* Name of the trigger */ - sqlite3 db = pParse.db; /* The database connection */ - int iDb; /* The database to store the trigger in */ - Token pName = null; /* The unqualified db name */ - DbFixer sFix = new DbFixer(); /* State vector for the DB fixer */ - int iTabDb; /* Index of the database holding pTab */ - - Debug.Assert( pName1 != null ); /* pName1.z might be NULL, but not pName1 itself */ - Debug.Assert( pName2 != null ); - Debug.Assert( op == TK_INSERT || op == TK_UPDATE || op == TK_DELETE ); - Debug.Assert( op > 0 && op < 0xff ); - if ( isTemp != 0 ) - { - /* If TEMP was specified, then the trigger name may not be qualified. */ - if ( pName2.n > 0 ) - { - sqlite3ErrorMsg( pParse, "temporary trigger may not have qualified name" ); - goto trigger_cleanup; - } - iDb = 1; - pName = pName1; - } - else - { - /* Figure out the db that the the trigger will be created in */ - iDb = sqlite3TwoPartName( pParse, pName1, pName2, ref pName ); - if ( iDb < 0 ) - { - goto trigger_cleanup; - } - } - if ( null == pTableName ) //|| db.mallocFailed - { - goto trigger_cleanup; - } - - /* A long-standing parser bug is that this syntax was allowed: - ** - ** CREATE TRIGGER attached.demo AFTER INSERT ON attached.tab .... - ** ^^^^^^^^ - ** - ** To maintain backwards compatibility, ignore the database - ** name on pTableName if we are reparsing our of SQLITE_MASTER. - */ - if ( db.init.busy != 0 && iDb != 1 ) - { - //sqlite3DbFree( db, pTableName.a[0].zDatabase ); - pTableName.a[0].zDatabase = null; - } - - /* If the trigger name was unqualified, and the table is a temp table, - ** then set iDb to 1 to create the trigger in the temporary database. - ** If sqlite3SrcListLookup() returns 0, indicating the table does not - ** exist, the error is caught by the block below. - */ - if ( pTableName == null /*|| db.mallocFailed != 0 */ ) - { - goto trigger_cleanup; - } - pTab = sqlite3SrcListLookup( pParse, pTableName ); - if ( db.init.busy == 0 && pName2.n == 0 && pTab != null - && pTab.pSchema == db.aDb[1].pSchema ) - { - iDb = 1; - } - - /* Ensure the table name matches database name and that the table exists */ - // if ( db.mallocFailed != 0 ) goto trigger_cleanup; - Debug.Assert( pTableName.nSrc == 1 ); - if ( sqlite3FixInit( sFix, pParse, iDb, "trigger", pName ) != 0 && - sqlite3FixSrcList( sFix, pTableName ) != 0 ) - { - goto trigger_cleanup; - } - pTab = sqlite3SrcListLookup( pParse, pTableName ); - if ( pTab == null ) - { - /* The table does not exist. */ - if ( db.init.iDb == 1 ) - { - /* Ticket #3810. - ** Normally, whenever a table is dropped, all associated triggers are - ** dropped too. But if a TEMP trigger is created on a non-TEMP table - ** and the table is dropped by a different database connection, the - ** trigger is not visible to the database connection that does the - ** drop so the trigger cannot be dropped. This results in an - ** "orphaned trigger" - a trigger whose associated table is missing. - */ - db.init.orphanTrigger = 1; - } - goto trigger_cleanup; - } - if ( IsVirtual( pTab ) ) - { - sqlite3ErrorMsg( pParse, "cannot create triggers on virtual tables" ); - goto trigger_cleanup; - } - - /* Check that the trigger name is not reserved and that no trigger of the - ** specified name exists */ - zName = sqlite3NameFromToken( db, pName ); - if ( zName == null || SQLITE_OK != sqlite3CheckObjectName( pParse, zName ) ) - { - goto trigger_cleanup; - } - Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); - if ( sqlite3HashFind( ( db.aDb[iDb].pSchema.trigHash ), - zName, sqlite3Strlen30( zName ), (Trigger)null ) != null ) - { - if ( noErr == 0 ) - { - sqlite3ErrorMsg( pParse, "trigger %T already exists", pName ); - } - else - { - Debug.Assert( 0==db.init.busy ); - sqlite3CodeVerifySchema( pParse, iDb ); + if (pParse.disableTriggers != 0) { + return null; + } + + if (pTmpSchema != pTab.pSchema) { + HashElem p; + Debug.Assert(sqlite3SchemaMutexHeld(pParse.db, 0, pTmpSchema)); + for (p = sqliteHashFirst(pTmpSchema.trigHash); p != null; p = sqliteHashNext(p)) { + Trigger pTrig = (Trigger)sqliteHashData(p); + if (pTrig.pTabSchema == pTab.pSchema + && pTrig.table.Equals(pTab.zName, StringComparison.OrdinalIgnoreCase)) { + pTrig.pNext = (pList != null ? pList : pTab.pTrigger); + pList = pTrig; + } + } + } + + return (pList != null ? pList : pTab.pTrigger); } - goto trigger_cleanup; - } - - /* Do not create a trigger on a system table */ - if ( pTab.zName.StartsWith( "sqlite_", System.StringComparison.OrdinalIgnoreCase ) ) - { - sqlite3ErrorMsg( pParse, "cannot create trigger on system table" ); - pParse.nErr++; - goto trigger_cleanup; - } - - /* INSTEAD of triggers are only for views and views only support INSTEAD - ** of triggers. - */ - if ( pTab.pSelect != null && tr_tm != TK_INSTEAD ) - { - sqlite3ErrorMsg( pParse, "cannot create %s trigger on view: %S", - ( tr_tm == TK_BEFORE ) ? "BEFORE" : "AFTER", pTableName, 0 ); - goto trigger_cleanup; - } - if ( pTab.pSelect == null && tr_tm == TK_INSTEAD ) - { - sqlite3ErrorMsg( pParse, "cannot create INSTEAD OF" + - " trigger on table: %S", pTableName, 0 ); - goto trigger_cleanup; - } - iTabDb = sqlite3SchemaToIndex( db, pTab.pSchema ); + + /* + ** This is called by the parser when it sees a CREATE TRIGGER statement + ** up to the point of the BEGIN before the trigger actions. A Trigger + ** structure is generated based on the information available and stored + ** in pParse.pNewTrigger. After the trigger actions have been parsed, the + ** sqlite3FinishTrigger() function is called to complete the trigger + ** construction process. + */ + static void sqlite3BeginTrigger( + Parse pParse, /* The parse context of the CREATE TRIGGER statement */ + Token pName1, /* The name of the trigger */ + Token pName2, /* The name of the trigger */ + int tr_tm, /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */ + int op, /* One of TK_INSERT, TK_UPDATE, TK_DELETE */ + IdList pColumns, /* column list if this is an UPDATE OF trigger */ + SrcList pTableName,/* The name of the table/view the trigger applies to */ + Expr pWhen, /* WHEN clause */ + int isTemp, /* True if the TEMPORARY keyword is present */ + int noErr /* Suppress errors if the trigger already exists */ + ) { + Trigger pTrigger = null; /* The new trigger */ + Table pTab; /* Table that the trigger fires off of */ + string zName = null; /* Name of the trigger */ + sqlite3 db = pParse.db; /* The database connection */ + int iDb; /* The database to store the trigger in */ + Token pName = null; /* The unqualified db name */ + DbFixer sFix = new DbFixer(); /* State vector for the DB fixer */ + int iTabDb; /* Index of the database holding pTab */ + + Debug.Assert(pName1 != null); /* pName1.z might be NULL, but not pName1 itself */ + Debug.Assert(pName2 != null); + Debug.Assert(op == TK_INSERT || op == TK_UPDATE || op == TK_DELETE); + Debug.Assert(op > 0 && op < 0xff); + if (isTemp != 0) { + /* If TEMP was specified, then the trigger name may not be qualified. */ + if (pName2.n > 0) { + sqlite3ErrorMsg(pParse, "temporary trigger may not have qualified name"); + goto trigger_cleanup; + } + iDb = 1; + pName = pName1; + } else { + /* Figure out the db that the the trigger will be created in */ + iDb = sqlite3TwoPartName(pParse, pName1, pName2, ref pName); + if (iDb < 0) { + goto trigger_cleanup; + } + } + if (null == pTableName) //|| db.mallocFailed + { + goto trigger_cleanup; + } + + /* A long-standing parser bug is that this syntax was allowed: + ** + ** CREATE TRIGGER attached.demo AFTER INSERT ON attached.tab .... + ** ^^^^^^^^ + ** + ** To maintain backwards compatibility, ignore the database + ** name on pTableName if we are reparsing our of SQLITE_MASTER. + */ + if (db.init.busy != 0 && iDb != 1) { + //sqlite3DbFree( db, pTableName.a[0].zDatabase ); + pTableName.a[0].zDatabase = null; + } + + /* If the trigger name was unqualified, and the table is a temp table, + ** then set iDb to 1 to create the trigger in the temporary database. + ** If sqlite3SrcListLookup() returns 0, indicating the table does not + ** exist, the error is caught by the block below. + */ + if (pTableName == null /*|| db.mallocFailed != 0 */ ) { + goto trigger_cleanup; + } + pTab = sqlite3SrcListLookup(pParse, pTableName); + if (db.init.busy == 0 && pName2.n == 0 && pTab != null + && pTab.pSchema == db.aDb[1].pSchema) { + iDb = 1; + } + + /* Ensure the table name matches database name and that the table exists */ + // if ( db.mallocFailed != 0 ) goto trigger_cleanup; + Debug.Assert(pTableName.nSrc == 1); + if (sqlite3FixInit(sFix, pParse, iDb, "trigger", pName) != 0 && + sqlite3FixSrcList(sFix, pTableName) != 0) { + goto trigger_cleanup; + } + pTab = sqlite3SrcListLookup(pParse, pTableName); + if (pTab == null) { + /* The table does not exist. */ + if (db.init.iDb == 1) { + /* Ticket #3810. + ** Normally, whenever a table is dropped, all associated triggers are + ** dropped too. But if a TEMP trigger is created on a non-TEMP table + ** and the table is dropped by a different database connection, the + ** trigger is not visible to the database connection that does the + ** drop so the trigger cannot be dropped. This results in an + ** "orphaned trigger" - a trigger whose associated table is missing. + */ + db.init.orphanTrigger = 1; + } + goto trigger_cleanup; + } + if (IsVirtual(pTab)) { + sqlite3ErrorMsg(pParse, "cannot create triggers on virtual tables"); + goto trigger_cleanup; + } + + /* Check that the trigger name is not reserved and that no trigger of the + ** specified name exists */ + zName = sqlite3NameFromToken(db, pName); + if (zName == null || SQLITE_OK != sqlite3CheckObjectName(pParse, zName)) { + goto trigger_cleanup; + } + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + if (sqlite3HashFind((db.aDb[iDb].pSchema.trigHash), + zName, sqlite3Strlen30(zName), (Trigger)null) != null) { + if (noErr == 0) { + sqlite3ErrorMsg(pParse, "trigger %T already exists", pName); + } else { + Debug.Assert(0 == db.init.busy); + sqlite3CodeVerifySchema(pParse, iDb); + } + goto trigger_cleanup; + } + + /* Do not create a trigger on a system table */ + if (pTab.zName.StartsWith("sqlite_", System.StringComparison.OrdinalIgnoreCase)) { + sqlite3ErrorMsg(pParse, "cannot create trigger on system table"); + pParse.nErr++; + goto trigger_cleanup; + } + + /* INSTEAD of triggers are only for views and views only support INSTEAD + ** of triggers. + */ + if (pTab.pSelect != null && tr_tm != TK_INSTEAD) { + sqlite3ErrorMsg(pParse, "cannot create %s trigger on view: %S", + (tr_tm == TK_BEFORE) ? "BEFORE" : "AFTER", pTableName, 0); + goto trigger_cleanup; + } + if (pTab.pSelect == null && tr_tm == TK_INSTEAD) { + sqlite3ErrorMsg(pParse, "cannot create INSTEAD OF" + + " trigger on table: %S", pTableName, 0); + goto trigger_cleanup; + } + iTabDb = sqlite3SchemaToIndex(db, pTab.pSchema); #if !SQLITE_OMIT_AUTHORIZATION { @@ -277,385 +246,354 @@ static void sqlite3BeginTrigger( } #endif - /* INSTEAD OF triggers can only appear on views and BEFORE triggers -** cannot appear on views. So we might as well translate every -** INSTEAD OF trigger into a BEFORE trigger. It simplifies code -** elsewhere. -*/ - if ( tr_tm == TK_INSTEAD ) - { - tr_tm = TK_BEFORE; - } - - /* Build the Trigger object */ - pTrigger = new Trigger();// (Trigger*)sqlite3DbMallocZero( db, sizeof(Trigger )) - if ( pTrigger == null ) - goto trigger_cleanup; - pTrigger.zName = zName; - pTrigger.table = pTableName.a[0].zName;// sqlite3DbStrDup( db, pTableName.a[0].zName ); - pTrigger.pSchema = db.aDb[iDb].pSchema; - pTrigger.pTabSchema = pTab.pSchema; - pTrigger.op = (u8)op; - pTrigger.tr_tm = tr_tm == TK_BEFORE ? TRIGGER_BEFORE : TRIGGER_AFTER; - pTrigger.pWhen = sqlite3ExprDup( db, pWhen, EXPRDUP_REDUCE ); - pTrigger.pColumns = sqlite3IdListDup( db, pColumns ); - Debug.Assert( pParse.pNewTrigger == null ); - pParse.pNewTrigger = pTrigger; - -trigger_cleanup: - sqlite3DbFree( db, ref zName ); - sqlite3SrcListDelete( db, ref pTableName ); - sqlite3IdListDelete( db, ref pColumns ); - sqlite3ExprDelete( db, ref pWhen ); - if ( pParse.pNewTrigger == null ) - { - sqlite3DeleteTrigger( db, ref pTrigger ); - } - else - { - Debug.Assert( pParse.pNewTrigger == pTrigger ); - } - } - - /* - ** This routine is called after all of the trigger actions have been parsed - ** in order to complete the process of building the trigger. - */ - static void sqlite3FinishTrigger( - Parse pParse, /* Parser context */ - TriggerStep pStepList, /* The triggered program */ - Token pAll /* Token that describes the complete CREATE TRIGGER */ - ) - { - Trigger pTrig = pParse.pNewTrigger; /* Trigger being finished */ - string zName; /* Name of trigger */ - - sqlite3 db = pParse.db; /* The database */ - DbFixer sFix = new DbFixer(); /* Fixer object */ - int iDb; /* Database containing the trigger */ - Token nameToken = new Token(); /* Trigger name for error reporting */ - - pParse.pNewTrigger = null; - if ( NEVER( pParse.nErr != 0 ) || pTrig == null ) - goto triggerfinish_cleanup; - zName = pTrig.zName; - iDb = sqlite3SchemaToIndex( pParse.db, pTrig.pSchema ); - pTrig.step_list = pStepList; - while ( pStepList != null ) - { - pStepList.pTrig = pTrig; - pStepList = pStepList.pNext; - } - nameToken.z = pTrig.zName; - nameToken.n = sqlite3Strlen30( nameToken.z ); - if ( sqlite3FixInit( sFix, pParse, iDb, "trigger", nameToken ) != 0 - && sqlite3FixTriggerStep( sFix, pTrig.step_list ) != 0 ) - { - goto triggerfinish_cleanup; - } - - /* if we are not initializing, - ** build the sqlite_master entry + /* INSTEAD OF triggers can only appear on views and BEFORE triggers + ** cannot appear on views. So we might as well translate every + ** INSTEAD OF trigger into a BEFORE trigger. It simplifies code + ** elsewhere. */ - if ( 0 == db.init.busy ) - { - Vdbe v; - string z; - - /* Make an entry in the sqlite_master table */ - v = sqlite3GetVdbe( pParse ); - if ( v == null ) - goto triggerfinish_cleanup; - sqlite3BeginWriteOperation( pParse, 0, iDb ); - z = pAll.z.Substring( 0, pAll.n );//sqlite3DbStrNDup( db, (char*)pAll.z, pAll.n ); - sqlite3NestedParse( pParse, - "INSERT INTO %Q.%s VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')", - db.aDb[iDb].zName, SCHEMA_TABLE( iDb ), zName, - pTrig.table, z ); - sqlite3DbFree( db, ref z ); - sqlite3ChangeCookie( pParse, iDb ); - sqlite3VdbeAddParseSchemaOp( v, iDb, - sqlite3MPrintf( db, "type='trigger' AND name='%q'", zName ) ); - } - - if ( db.init.busy != 0 ) - { - Trigger pLink = pTrig; - Hash pHash = db.aDb[iDb].pSchema.trigHash; - Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); - pTrig = sqlite3HashInsert( ref pHash, zName, sqlite3Strlen30( zName ), pTrig ); - if ( pTrig != null ) - { - //db.mallocFailed = 1; - } - else if ( pLink.pSchema == pLink.pTabSchema ) - { - Table pTab; - int n = sqlite3Strlen30( pLink.table ); - pTab = sqlite3HashFind( pLink.pTabSchema.tblHash, pLink.table, n, (Table)null ); - Debug.Assert( pTab != null ); - pLink.pNext = pTab.pTrigger; - pTab.pTrigger = pLink; + if (tr_tm == TK_INSTEAD) { + tr_tm = TK_BEFORE; + } + + /* Build the Trigger object */ + pTrigger = new Trigger();// (Trigger*)sqlite3DbMallocZero( db, sizeof(Trigger )) + if (pTrigger == null) + goto trigger_cleanup; + pTrigger.zName = zName; + pTrigger.table = pTableName.a[0].zName;// sqlite3DbStrDup( db, pTableName.a[0].zName ); + pTrigger.pSchema = db.aDb[iDb].pSchema; + pTrigger.pTabSchema = pTab.pSchema; + pTrigger.op = (u8)op; + pTrigger.tr_tm = tr_tm == TK_BEFORE ? TRIGGER_BEFORE : TRIGGER_AFTER; + pTrigger.pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE); + pTrigger.pColumns = sqlite3IdListDup(db, pColumns); + Debug.Assert(pParse.pNewTrigger == null); + pParse.pNewTrigger = pTrigger; + + trigger_cleanup: + sqlite3DbFree(db, ref zName); + sqlite3SrcListDelete(db, ref pTableName); + sqlite3IdListDelete(db, ref pColumns); + sqlite3ExprDelete(db, ref pWhen); + if (pParse.pNewTrigger == null) { + sqlite3DeleteTrigger(db, ref pTrigger); + } else { + Debug.Assert(pParse.pNewTrigger == pTrigger); + } } - } -triggerfinish_cleanup: - sqlite3DeleteTrigger( db, ref pTrig ); - Debug.Assert( pParse.pNewTrigger == null ); - sqlite3DeleteTriggerStep( db, ref pStepList ); - } + /* + ** This routine is called after all of the trigger actions have been parsed + ** in order to complete the process of building the trigger. + */ + static void sqlite3FinishTrigger( + Parse pParse, /* Parser context */ + TriggerStep pStepList, /* The triggered program */ + Token pAll /* Token that describes the complete CREATE TRIGGER */ + ) { + Trigger pTrig = pParse.pNewTrigger; /* Trigger being finished */ + string zName; /* Name of trigger */ + + sqlite3 db = pParse.db; /* The database */ + DbFixer sFix = new DbFixer(); /* Fixer object */ + int iDb; /* Database containing the trigger */ + Token nameToken = new Token(); /* Trigger name for error reporting */ + + pParse.pNewTrigger = null; + if (NEVER(pParse.nErr != 0) || pTrig == null) + goto triggerfinish_cleanup; + zName = pTrig.zName; + iDb = sqlite3SchemaToIndex(pParse.db, pTrig.pSchema); + pTrig.step_list = pStepList; + while (pStepList != null) { + pStepList.pTrig = pTrig; + pStepList = pStepList.pNext; + } + nameToken.z = pTrig.zName; + nameToken.n = sqlite3Strlen30(nameToken.z); + if (sqlite3FixInit(sFix, pParse, iDb, "trigger", nameToken) != 0 + && sqlite3FixTriggerStep(sFix, pTrig.step_list) != 0) { + goto triggerfinish_cleanup; + } - /* - ** Turn a SELECT statement (that the pSelect parameter points to) into - ** a trigger step. Return a pointer to a TriggerStep structure. - ** - ** The parser calls this routine when it finds a SELECT statement in - ** body of a TRIGGER. - */ - static TriggerStep sqlite3TriggerSelectStep( sqlite3 db, Select pSelect ) - { - TriggerStep pTriggerStep = new TriggerStep();// sqlite3DbMallocZero( db, sizeof(TriggerStep )) - if ( pTriggerStep == null ) - { - sqlite3SelectDelete( db, ref pSelect ); - return null; - } - - pTriggerStep.op = TK_SELECT; - pTriggerStep.pSelect = pSelect; - pTriggerStep.orconf = OE_Default; - return pTriggerStep; - } + /* if we are not initializing, + ** build the sqlite_master entry + */ + if (0 == db.init.busy) { + Vdbe v; + string z; + + /* Make an entry in the sqlite_master table */ + v = sqlite3GetVdbe(pParse); + if (v == null) + goto triggerfinish_cleanup; + sqlite3BeginWriteOperation(pParse, 0, iDb); + z = pAll.z.Substring(0, pAll.n);//sqlite3DbStrNDup( db, (char*)pAll.z, pAll.n ); + sqlite3NestedParse(pParse, + "INSERT INTO %Q.%s VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')", + db.aDb[iDb].zName, SCHEMA_TABLE(iDb), zName, + pTrig.table, z); + sqlite3DbFree(db, ref z); + sqlite3ChangeCookie(pParse, iDb); + sqlite3VdbeAddParseSchemaOp(v, iDb, + sqlite3MPrintf(db, "type='trigger' AND name='%q'", zName)); + } - /* - ** Allocate space to hold a new trigger step. The allocated space - ** holds both the TriggerStep object and the TriggerStep.target.z string. - ** - ** If an OOM error occurs, NULL is returned and db.mallocFailed is set. - */ - static TriggerStep triggerStepAllocate( - sqlite3 db, /* Database connection */ - u8 op, /* Trigger opcode */ - Token pName /* The target name */ - ) - { - TriggerStep pTriggerStep; - - pTriggerStep = new TriggerStep();// sqlite3DbMallocZero( db, sizeof( TriggerStep ) + pName.n ); - //if ( pTriggerStep != null ) - //{ - string z;// = (char*)&pTriggerStep[1]; - z = pName.z;// memcpy( z, pName.z, pName.n ); - pTriggerStep.target.z = z; - pTriggerStep.target.n = pName.n; - pTriggerStep.op = op; - //} - return pTriggerStep; - } + if (db.init.busy != 0) { + Trigger pLink = pTrig; + Hash pHash = db.aDb[iDb].pSchema.trigHash; + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + pTrig = sqlite3HashInsert(ref pHash, zName, sqlite3Strlen30(zName), pTrig); + if (pTrig != null) { + //db.mallocFailed = 1; + } else if (pLink.pSchema == pLink.pTabSchema) { + Table pTab; + int n = sqlite3Strlen30(pLink.table); + pTab = sqlite3HashFind(pLink.pTabSchema.tblHash, pLink.table, n, (Table)null); + Debug.Assert(pTab != null); + pLink.pNext = pTab.pTrigger; + pTab.pTrigger = pLink; + } + } - /* - ** Build a trigger step out of an INSERT statement. Return a pointer - ** to the new trigger step. - ** - ** The parser calls this routine when it sees an INSERT inside the - ** body of a trigger. - */ - // OVERLOADS, so I don't need to rewrite parse.c - static TriggerStep sqlite3TriggerInsertStep( sqlite3 db, Token pTableName, IdList pColumn, int null_4, int null_5, u8 orconf ) - { - return sqlite3TriggerInsertStep( db, pTableName, pColumn, null, null, orconf ); - } - static TriggerStep sqlite3TriggerInsertStep( sqlite3 db, Token pTableName, IdList pColumn, ExprList pEList, int null_5, u8 orconf ) - { - return sqlite3TriggerInsertStep( db, pTableName, pColumn, pEList, null, orconf ); - } - static TriggerStep sqlite3TriggerInsertStep( sqlite3 db, Token pTableName, IdList pColumn, int null_4, Select pSelect, u8 orconf ) - { - return sqlite3TriggerInsertStep( db, pTableName, pColumn, null, pSelect, orconf ); - } - static TriggerStep sqlite3TriggerInsertStep( - sqlite3 db, /* The database connection */ - Token pTableName, /* Name of the table into which we insert */ - IdList pColumn, /* List of columns in pTableName to insert into */ - ExprList pEList, /* The VALUE clause: a list of values to be inserted */ - Select pSelect, /* A SELECT statement that supplies values */ - u8 orconf /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */ - ) - { - TriggerStep pTriggerStep; - - Debug.Assert( pEList == null || pSelect == null ); - Debug.Assert( pEList != null || pSelect != null /*|| db.mallocFailed != 0 */ ); - - pTriggerStep = triggerStepAllocate( db, TK_INSERT, pTableName ); - //if ( pTriggerStep != null ) - //{ - pTriggerStep.pSelect = sqlite3SelectDup( db, pSelect, EXPRDUP_REDUCE ); - pTriggerStep.pIdList = pColumn; - pTriggerStep.pExprList = sqlite3ExprListDup( db, pEList, EXPRDUP_REDUCE ); - pTriggerStep.orconf = orconf; - //} - //else - //{ - // sqlite3IdListDelete( db, ref pColumn ); - //} - sqlite3ExprListDelete( db, ref pEList ); - sqlite3SelectDelete( db, ref pSelect ); - - return pTriggerStep; - } + triggerfinish_cleanup: + sqlite3DeleteTrigger(db, ref pTrig); + Debug.Assert(pParse.pNewTrigger == null); + sqlite3DeleteTriggerStep(db, ref pStepList); + } - /* - ** Construct a trigger step that implements an UPDATE statement and return - ** a pointer to that trigger step. The parser calls this routine when it - ** sees an UPDATE statement inside the body of a CREATE TRIGGER. - */ - static TriggerStep sqlite3TriggerUpdateStep( - sqlite3 db, /* The database connection */ - Token pTableName, /* Name of the table to be updated */ - ExprList pEList, /* The SET clause: list of column and new values */ - Expr pWhere, /* The WHERE clause */ - u8 orconf /* The conflict algorithm. (OE_Abort, OE_Ignore, etc) */ - ) - { - TriggerStep pTriggerStep; - - pTriggerStep = triggerStepAllocate( db, TK_UPDATE, pTableName ); - //if ( pTriggerStep != null ) - //{ - pTriggerStep.pExprList = sqlite3ExprListDup( db, pEList, EXPRDUP_REDUCE ); - pTriggerStep.pWhere = sqlite3ExprDup( db, pWhere, EXPRDUP_REDUCE ); - pTriggerStep.orconf = orconf; - //} - sqlite3ExprListDelete( db, ref pEList ); - sqlite3ExprDelete( db, ref pWhere ); - return pTriggerStep; - } + /* + ** Turn a SELECT statement (that the pSelect parameter points to) into + ** a trigger step. Return a pointer to a TriggerStep structure. + ** + ** The parser calls this routine when it finds a SELECT statement in + ** body of a TRIGGER. + */ + static TriggerStep sqlite3TriggerSelectStep(sqlite3 db, Select pSelect) { + TriggerStep pTriggerStep = new TriggerStep();// sqlite3DbMallocZero( db, sizeof(TriggerStep )) + if (pTriggerStep == null) { + sqlite3SelectDelete(db, ref pSelect); + return null; + } - /* - ** Construct a trigger step that implements a DELETE statement and return - ** a pointer to that trigger step. The parser calls this routine when it - ** sees a DELETE statement inside the body of a CREATE TRIGGER. - */ - static TriggerStep sqlite3TriggerDeleteStep( - sqlite3 db, /* Database connection */ - Token pTableName, /* The table from which rows are deleted */ - Expr pWhere /* The WHERE clause */ - ) - { - TriggerStep pTriggerStep; - - pTriggerStep = triggerStepAllocate( db, TK_DELETE, pTableName ); - //if ( pTriggerStep != null ) - //{ - pTriggerStep.pWhere = sqlite3ExprDup( db, pWhere, EXPRDUP_REDUCE ); - pTriggerStep.orconf = OE_Default; - //} - sqlite3ExprDelete( db, ref pWhere ); - return pTriggerStep; - } + pTriggerStep.op = TK_SELECT; + pTriggerStep.pSelect = pSelect; + pTriggerStep.orconf = OE_Default; + return pTriggerStep; + } + /* + ** Allocate space to hold a new trigger step. The allocated space + ** holds both the TriggerStep object and the TriggerStep.target.z string. + ** + ** If an OOM error occurs, NULL is returned and db.mallocFailed is set. + */ + static TriggerStep triggerStepAllocate( + sqlite3 db, /* Database connection */ + u8 op, /* Trigger opcode */ + Token pName /* The target name */ + ) { + TriggerStep pTriggerStep; + + pTriggerStep = new TriggerStep();// sqlite3DbMallocZero( db, sizeof( TriggerStep ) + pName.n ); + //if ( pTriggerStep != null ) + //{ + string z;// = (char*)&pTriggerStep[1]; + z = pName.z;// memcpy( z, pName.z, pName.n ); + pTriggerStep.target.z = z; + pTriggerStep.target.n = pName.n; + pTriggerStep.op = op; + //} + return pTriggerStep; + } + /* + ** Build a trigger step out of an INSERT statement. Return a pointer + ** to the new trigger step. + ** + ** The parser calls this routine when it sees an INSERT inside the + ** body of a trigger. + */ + // OVERLOADS, so I don't need to rewrite parse.c + static TriggerStep sqlite3TriggerInsertStep(sqlite3 db, Token pTableName, IdList pColumn, int null_4, int null_5, u8 orconf) { + return sqlite3TriggerInsertStep(db, pTableName, pColumn, null, null, orconf); + } + static TriggerStep sqlite3TriggerInsertStep(sqlite3 db, Token pTableName, IdList pColumn, ExprList pEList, int null_5, u8 orconf) { + return sqlite3TriggerInsertStep(db, pTableName, pColumn, pEList, null, orconf); + } + static TriggerStep sqlite3TriggerInsertStep(sqlite3 db, Token pTableName, IdList pColumn, int null_4, Select pSelect, u8 orconf) { + return sqlite3TriggerInsertStep(db, pTableName, pColumn, null, pSelect, orconf); + } + static TriggerStep sqlite3TriggerInsertStep( + sqlite3 db, /* The database connection */ + Token pTableName, /* Name of the table into which we insert */ + IdList pColumn, /* List of columns in pTableName to insert into */ + ExprList pEList, /* The VALUE clause: a list of values to be inserted */ + Select pSelect, /* A SELECT statement that supplies values */ + u8 orconf /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */ + ) { + TriggerStep pTriggerStep; + + Debug.Assert(pEList == null || pSelect == null); + Debug.Assert(pEList != null || pSelect != null /*|| db.mallocFailed != 0 */ ); + + pTriggerStep = triggerStepAllocate(db, TK_INSERT, pTableName); + //if ( pTriggerStep != null ) + //{ + pTriggerStep.pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE); + pTriggerStep.pIdList = pColumn; + pTriggerStep.pExprList = sqlite3ExprListDup(db, pEList, EXPRDUP_REDUCE); + pTriggerStep.orconf = orconf; + //} + //else + //{ + // sqlite3IdListDelete( db, ref pColumn ); + //} + sqlite3ExprListDelete(db, ref pEList); + sqlite3SelectDelete(db, ref pSelect); + + return pTriggerStep; + } - /* - ** Recursively delete a Trigger structure - */ - static void sqlite3DeleteTrigger( sqlite3 db, ref Trigger pTrigger ) - { - if ( pTrigger == null ) - return; - sqlite3DeleteTriggerStep( db, ref pTrigger.step_list ); - sqlite3DbFree( db, ref pTrigger.zName ); - sqlite3DbFree( db, ref pTrigger.table ); - sqlite3ExprDelete( db, ref pTrigger.pWhen ); - sqlite3IdListDelete( db, ref pTrigger.pColumns ); - pTrigger = null; - sqlite3DbFree( db, ref pTrigger ); - } + /* + ** Construct a trigger step that implements an UPDATE statement and return + ** a pointer to that trigger step. The parser calls this routine when it + ** sees an UPDATE statement inside the body of a CREATE TRIGGER. + */ + static TriggerStep sqlite3TriggerUpdateStep( + sqlite3 db, /* The database connection */ + Token pTableName, /* Name of the table to be updated */ + ExprList pEList, /* The SET clause: list of column and new values */ + Expr pWhere, /* The WHERE clause */ + u8 orconf /* The conflict algorithm. (OE_Abort, OE_Ignore, etc) */ + ) { + TriggerStep pTriggerStep; + + pTriggerStep = triggerStepAllocate(db, TK_UPDATE, pTableName); + //if ( pTriggerStep != null ) + //{ + pTriggerStep.pExprList = sqlite3ExprListDup(db, pEList, EXPRDUP_REDUCE); + pTriggerStep.pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE); + pTriggerStep.orconf = orconf; + //} + sqlite3ExprListDelete(db, ref pEList); + sqlite3ExprDelete(db, ref pWhere); + return pTriggerStep; + } - /* - ** This function is called to drop a trigger from the database schema. - ** - ** This may be called directly from the parser and therefore identifies - ** the trigger by name. The sqlite3DropTriggerPtr() routine does the - ** same job as this routine except it takes a pointer to the trigger - ** instead of the trigger name. - **/ - static void sqlite3DropTrigger( Parse pParse, SrcList pName, int noErr ) - { - Trigger pTrigger = null; - int i; - string zDb; - string zName; - int nName; - sqlite3 db = pParse.db; - - // if ( db.mallocFailed != 0 ) goto drop_trigger_cleanup; - if ( SQLITE_OK != sqlite3ReadSchema( pParse ) ) - { - goto drop_trigger_cleanup; - } - - Debug.Assert( pName.nSrc == 1 ); - zDb = pName.a[0].zDatabase; - zName = pName.a[0].zName; - nName = sqlite3Strlen30( zName ); - Debug.Assert( zDb != null || sqlite3BtreeHoldsAllMutexes( db ) ); - for ( i = OMIT_TEMPDB; i < db.nDb; i++ ) - { - int j = ( i < 2 ) ? i ^ 1 : i; /* Search TEMP before MAIN */ - if ( zDb != null && !db.aDb[j].zName.Equals( zDb ,StringComparison.OrdinalIgnoreCase ) ) - continue; - Debug.Assert( sqlite3SchemaMutexHeld( db, j, null ) ); - pTrigger = sqlite3HashFind( ( db.aDb[j].pSchema.trigHash ), zName, nName, (Trigger)null ); - if ( pTrigger != null ) - break; - } - if ( pTrigger == null ) - { - if ( noErr == 0 ) - { - sqlite3ErrorMsg( pParse, "no such trigger: %S", pName, 0 ); + /* + ** Construct a trigger step that implements a DELETE statement and return + ** a pointer to that trigger step. The parser calls this routine when it + ** sees a DELETE statement inside the body of a CREATE TRIGGER. + */ + static TriggerStep sqlite3TriggerDeleteStep( + sqlite3 db, /* Database connection */ + Token pTableName, /* The table from which rows are deleted */ + Expr pWhere /* The WHERE clause */ + ) { + TriggerStep pTriggerStep; + + pTriggerStep = triggerStepAllocate(db, TK_DELETE, pTableName); + //if ( pTriggerStep != null ) + //{ + pTriggerStep.pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE); + pTriggerStep.orconf = OE_Default; + //} + sqlite3ExprDelete(db, ref pWhere); + return pTriggerStep; } - else - { - sqlite3CodeVerifyNamedSchema( pParse, zDb ); + + + + /* + ** Recursively delete a Trigger structure + */ + static void sqlite3DeleteTrigger(sqlite3 db, ref Trigger pTrigger) { + if (pTrigger == null) + return; + sqlite3DeleteTriggerStep(db, ref pTrigger.step_list); + sqlite3DbFree(db, ref pTrigger.zName); + sqlite3DbFree(db, ref pTrigger.table); + sqlite3ExprDelete(db, ref pTrigger.pWhen); + sqlite3IdListDelete(db, ref pTrigger.pColumns); + pTrigger = null; + sqlite3DbFree(db, ref pTrigger); } - pParse.checkSchema = 1; - goto drop_trigger_cleanup; - } - sqlite3DropTriggerPtr( pParse, pTrigger ); -drop_trigger_cleanup: - sqlite3SrcListDelete( db, ref pName ); - } + /* + ** This function is called to drop a trigger from the database schema. + ** + ** This may be called directly from the parser and therefore identifies + ** the trigger by name. The sqlite3DropTriggerPtr() routine does the + ** same job as this routine except it takes a pointer to the trigger + ** instead of the trigger name. + **/ + static void sqlite3DropTrigger(Parse pParse, SrcList pName, int noErr) { + Trigger pTrigger = null; + int i; + string zDb; + string zName; + int nName; + sqlite3 db = pParse.db; + + // if ( db.mallocFailed != 0 ) goto drop_trigger_cleanup; + if (SQLITE_OK != sqlite3ReadSchema(pParse)) { + goto drop_trigger_cleanup; + } - /* - ** Return a pointer to the Table structure for the table that a trigger - ** is set on. - */ - static Table tableOfTrigger( Trigger pTrigger ) - { - int n = sqlite3Strlen30( pTrigger.table ); - return sqlite3HashFind( pTrigger.pTabSchema.tblHash, pTrigger.table, n, (Table)null ); - } + Debug.Assert(pName.nSrc == 1); + zDb = pName.a[0].zDatabase; + zName = pName.a[0].zName; + nName = sqlite3Strlen30(zName); + Debug.Assert(zDb != null || sqlite3BtreeHoldsAllMutexes(db)); + for (i = OMIT_TEMPDB; i < db.nDb; i++) { + int j = (i < 2) ? i ^ 1 : i; /* Search TEMP before MAIN */ + if (zDb != null && !db.aDb[j].zName.Equals(zDb, StringComparison.OrdinalIgnoreCase)) + continue; + Debug.Assert(sqlite3SchemaMutexHeld(db, j, null)); + pTrigger = sqlite3HashFind((db.aDb[j].pSchema.trigHash), zName, nName, (Trigger)null); + if (pTrigger != null) + break; + } + if (pTrigger == null) { + if (noErr == 0) { + sqlite3ErrorMsg(pParse, "no such trigger: %S", pName, 0); + } else { + sqlite3CodeVerifyNamedSchema(pParse, zDb); + } + pParse.checkSchema = 1; + goto drop_trigger_cleanup; + } + sqlite3DropTriggerPtr(pParse, pTrigger); + drop_trigger_cleanup: + sqlite3SrcListDelete(db, ref pName); + } - /* - ** Drop a trigger given a pointer to that trigger. - */ - static void sqlite3DropTriggerPtr( Parse pParse, Trigger pTrigger ) - { - Table pTable; - Vdbe v; - sqlite3 db = pParse.db; - int iDb; - - iDb = sqlite3SchemaToIndex( pParse.db, pTrigger.pSchema ); - Debug.Assert( iDb >= 0 && iDb < db.nDb ); - pTable = tableOfTrigger( pTrigger ); - Debug.Assert( pTable != null ); - Debug.Assert( pTable.pSchema == pTrigger.pSchema || iDb == 1 ); + /* + ** Return a pointer to the Table structure for the table that a trigger + ** is set on. + */ + static Table tableOfTrigger(Trigger pTrigger) { + int n = sqlite3Strlen30(pTrigger.table); + return sqlite3HashFind(pTrigger.pTabSchema.tblHash, pTrigger.table, n, (Table)null); + } + + + /* + ** Drop a trigger given a pointer to that trigger. + */ + static void sqlite3DropTriggerPtr(Parse pParse, Trigger pTrigger) { + Table pTable; + Vdbe v; + sqlite3 db = pParse.db; + int iDb; + + iDb = sqlite3SchemaToIndex(pParse.db, pTrigger.pSchema); + Debug.Assert(iDb >= 0 && iDb < db.nDb); + pTable = tableOfTrigger(pTrigger); + Debug.Assert(pTable != null); + Debug.Assert(pTable.pSchema == pTrigger.pSchema || iDb == 1); #if !SQLITE_OMIT_AUTHORIZATION { int code = SQLITE_DROP_TRIGGER; @@ -669,13 +607,12 @@ static void sqlite3DropTriggerPtr( Parse pParse, Trigger pTrigger ) } #endif - /* Generate code to destroy the database record of the trigger. -*/ - Debug.Assert( pTable != null ); - if ( ( v = sqlite3GetVdbe( pParse ) ) != null ) - { - int _base; - VdbeOpList[] dropTrigger = new VdbeOpList[] { + /* Generate code to destroy the database record of the trigger. + */ + Debug.Assert(pTable != null); + if ((v = sqlite3GetVdbe(pParse)) != null) { + int _base; + VdbeOpList[] dropTrigger = new VdbeOpList[] { new VdbeOpList( OP_Rewind, 0, ADDR(9), 0), new VdbeOpList( OP_String8, 0, 1, 0), /* 1 */ new VdbeOpList( OP_Column, 0, 1, 2), @@ -687,624 +624,577 @@ static void sqlite3DropTriggerPtr( Parse pParse, Trigger pTrigger ) new VdbeOpList( OP_Next, 0, ADDR(1), 0), /* 8 */ }; - sqlite3BeginWriteOperation( pParse, 0, iDb ); - sqlite3OpenMasterTable( pParse, iDb ); - _base = sqlite3VdbeAddOpList( v, dropTrigger.Length, dropTrigger ); - sqlite3VdbeChangeP4( v, _base + 1, pTrigger.zName, P4_TRANSIENT ); - sqlite3VdbeChangeP4( v, _base + 4, "trigger", P4_STATIC ); - sqlite3ChangeCookie( pParse, iDb ); - sqlite3VdbeAddOp2( v, OP_Close, 0, 0 ); - sqlite3VdbeAddOp4( v, OP_DropTrigger, iDb, 0, 0, pTrigger.zName, 0 ); - if ( pParse.nMem < 3 ) - { - pParse.nMem = 3; + sqlite3BeginWriteOperation(pParse, 0, iDb); + sqlite3OpenMasterTable(pParse, iDb); + _base = sqlite3VdbeAddOpList(v, dropTrigger.Length, dropTrigger); + sqlite3VdbeChangeP4(v, _base + 1, pTrigger.zName, P4_TRANSIENT); + sqlite3VdbeChangeP4(v, _base + 4, "trigger", P4_STATIC); + sqlite3ChangeCookie(pParse, iDb); + sqlite3VdbeAddOp2(v, OP_Close, 0, 0); + sqlite3VdbeAddOp4(v, OP_DropTrigger, iDb, 0, 0, pTrigger.zName, 0); + if (pParse.nMem < 3) { + pParse.nMem = 3; + } + } } - } - } - /* - ** Remove a trigger from the hash tables of the sqlite* pointer. - */ - static void sqlite3UnlinkAndDeleteTrigger( sqlite3 db, int iDb, string zName ) - { - Trigger pTrigger; - Hash pHash; - - Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); - pHash = ( db.aDb[iDb].pSchema.trigHash ); - pTrigger = sqlite3HashInsert( ref pHash, zName, sqlite3Strlen30( zName ), (Trigger)null ); - if ( ALWAYS( pTrigger != null ) ) - { - if ( pTrigger.pSchema == pTrigger.pTabSchema ) - { - Table pTab = tableOfTrigger( pTrigger ); - //Trigger** pp; - //for ( pp = &pTab.pTrigger ; *pp != pTrigger ; pp = &( (*pp).pNext ) ) ; - //*pp = (*pp).pNext; - if ( pTab.pTrigger == pTrigger ) - { - pTab.pTrigger = pTrigger.pNext; - } - else - { - Trigger cc = pTab.pTrigger; - while ( cc != null ) - { - if ( cc.pNext == pTrigger ) - { - cc.pNext = cc.pNext.pNext; - break; - } - cc = cc.pNext; + /* + ** Remove a trigger from the hash tables of the sqlite* pointer. + */ + static void sqlite3UnlinkAndDeleteTrigger(sqlite3 db, int iDb, string zName) { + Trigger pTrigger; + Hash pHash; + + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + pHash = (db.aDb[iDb].pSchema.trigHash); + pTrigger = sqlite3HashInsert(ref pHash, zName, sqlite3Strlen30(zName), (Trigger)null); + if (ALWAYS(pTrigger != null)) { + if (pTrigger.pSchema == pTrigger.pTabSchema) { + Table pTab = tableOfTrigger(pTrigger); + //Trigger** pp; + //for ( pp = &pTab.pTrigger ; *pp != pTrigger ; pp = &( (*pp).pNext ) ) ; + //*pp = (*pp).pNext; + if (pTab.pTrigger == pTrigger) { + pTab.pTrigger = pTrigger.pNext; + } else { + Trigger cc = pTab.pTrigger; + while (cc != null) { + if (cc.pNext == pTrigger) { + cc.pNext = cc.pNext.pNext; + break; + } + cc = cc.pNext; + } + Debug.Assert(cc != null); + } + } + sqlite3DeleteTrigger(db, ref pTrigger); + db.flags |= SQLITE_InternChanges; } - Debug.Assert( cc != null ); - } } - sqlite3DeleteTrigger( db, ref pTrigger ); - db.flags |= SQLITE_InternChanges; - } - } - - /* - ** pEList is the SET clause of an UPDATE statement. Each entry - ** in pEList is of the format =. If any of the entries - ** in pEList have an which matches an identifier in pIdList, - ** then return TRUE. If pIdList==NULL, then it is considered a - ** wildcard that matches anything. Likewise if pEList==NULL then - ** it matches anything so always return true. Return false only - ** if there is no match. - */ - static int checkColumnOverlap( IdList pIdList, ExprList pEList ) - { - int e; - if ( pIdList == null || NEVER( pEList == null ) ) - return 1; - for ( e = 0; e < pEList.nExpr; e++ ) - { - if ( sqlite3IdListIndex( pIdList, pEList.a[e].zName ) >= 0 ) - return 1; - } - return 0; - } - /* - ** Return a list of all triggers on table pTab if there exists at least - ** one trigger that must be fired when an operation of type 'op' is - ** performed on the table, and, if that operation is an UPDATE, if at - ** least one of the columns in pChanges is being modified. - */ - static Trigger sqlite3TriggersExist( - Parse pParse, /* Parse context */ - Table pTab, /* The table the contains the triggers */ - int op, /* one of TK_DELETE, TK_INSERT, TK_UPDATE */ - ExprList pChanges, /* Columns that change in an UPDATE statement */ - out int pMask /* OUT: Mask of TRIGGER_BEFORE|TRIGGER_AFTER */ - ) - { - int mask = 0; - Trigger pList = null; - Trigger p; - - if ( ( pParse.db.flags & SQLITE_EnableTrigger ) != 0 ) - { - pList = sqlite3TriggerList( pParse, pTab ); - } - Debug.Assert( pList == null || IsVirtual( pTab ) == false ); - for ( p = pList; p != null; p = p.pNext ) - { - if ( p.op == op && checkColumnOverlap( p.pColumns, pChanges ) != 0 ) - { - mask |= p.tr_tm; + /* + ** pEList is the SET clause of an UPDATE statement. Each entry + ** in pEList is of the format =. If any of the entries + ** in pEList have an which matches an identifier in pIdList, + ** then return TRUE. If pIdList==NULL, then it is considered a + ** wildcard that matches anything. Likewise if pEList==NULL then + ** it matches anything so always return true. Return false only + ** if there is no match. + */ + static int checkColumnOverlap(IdList pIdList, ExprList pEList) { + int e; + if (pIdList == null || NEVER(pEList == null)) + return 1; + for (e = 0; e < pEList.nExpr; e++) { + if (sqlite3IdListIndex(pIdList, pEList.a[e].zName) >= 0) + return 1; + } + return 0; } - } - //if ( pMask != 0 ) - { - pMask = mask; - } - return ( mask != 0 ? pList : null ); - } - - /* - ** Convert the pStep.target token into a SrcList and return a pointer - ** to that SrcList. - ** - ** This routine adds a specific database name, if needed, to the target when - ** forming the SrcList. This prevents a trigger in one database from - ** referring to a target in another database. An exception is when the - ** trigger is in TEMP in which case it can refer to any other database it - ** wants. - */ - static SrcList targetSrcList( - Parse pParse, /* The parsing context */ - TriggerStep pStep /* The trigger containing the target token */ - ) - { - int iDb; /* Index of the database to use */ - SrcList pSrc; /* SrcList to be returned */ - - pSrc = sqlite3SrcListAppend( pParse.db, 0, pStep.target, 0 ); - //if ( pSrc != null ) - //{ - Debug.Assert( pSrc.nSrc > 0 ); - Debug.Assert( pSrc.a != null ); - iDb = sqlite3SchemaToIndex( pParse.db, pStep.pTrig.pSchema ); - if ( iDb == 0 || iDb >= 2 ) - { - sqlite3 db = pParse.db; - Debug.Assert( iDb < pParse.db.nDb ); - pSrc.a[pSrc.nSrc - 1].zDatabase = db.aDb[iDb].zName;// sqlite3DbStrDup( db, db.aDb[iDb].zName ); - } - //} - return pSrc; - } - - /* - ** Generate VDBE code for the statements inside the body of a single - ** trigger. - */ - static int codeTriggerProgram( - Parse pParse, /* The parser context */ - TriggerStep pStepList, /* List of statements inside the trigger body */ - int orconf /* Conflict algorithm. (OE_Abort, etc) */ - ) - { - TriggerStep pStep; - Vdbe v = pParse.pVdbe; - sqlite3 db = pParse.db; - - Debug.Assert( pParse.pTriggerTab != null && pParse.pToplevel != null ); - Debug.Assert( pStepList != null ); - Debug.Assert( v != null ); - for ( pStep = pStepList; pStep != null; pStep = pStep.pNext ) - { - /* Figure out the ON CONFLICT policy that will be used for this step - ** of the trigger program. If the statement that caused this trigger - ** to fire had an explicit ON CONFLICT, then use it. Otherwise, use - ** the ON CONFLICT policy that was specified as part of the trigger - ** step statement. Example: - ** - ** CREATE TRIGGER AFTER INSERT ON t1 BEGIN; - ** INSERT OR REPLACE INTO t2 VALUES(new.a, new.b); - ** END; - ** - ** INSERT INTO t1 ... ; -- insert into t2 uses REPLACE policy - ** INSERT OR IGNORE INTO t1 ... ; -- insert into t2 uses IGNORE policy + /* + ** Return a list of all triggers on table pTab if there exists at least + ** one trigger that must be fired when an operation of type 'op' is + ** performed on the table, and, if that operation is an UPDATE, if at + ** least one of the columns in pChanges is being modified. */ - pParse.eOrconf = ( orconf == OE_Default ) ? pStep.orconf : (u8)orconf; - - switch ( pStep.op ) - { - case TK_UPDATE: - { - sqlite3Update( pParse, - targetSrcList( pParse, pStep ), - sqlite3ExprListDup( db, pStep.pExprList, 0 ), - sqlite3ExprDup( db, pStep.pWhere, 0 ), - pParse.eOrconf - ); - break; + static Trigger sqlite3TriggersExist( + Parse pParse, /* Parse context */ + Table pTab, /* The table the contains the triggers */ + int op, /* one of TK_DELETE, TK_INSERT, TK_UPDATE */ + ExprList pChanges, /* Columns that change in an UPDATE statement */ + out int pMask /* OUT: Mask of TRIGGER_BEFORE|TRIGGER_AFTER */ + ) { + int mask = 0; + Trigger pList = null; + Trigger p; + + if ((pParse.db.flags & SQLITE_EnableTrigger) != 0) { + pList = sqlite3TriggerList(pParse, pTab); } - case TK_INSERT: - { - sqlite3Insert( pParse, - targetSrcList( pParse, pStep ), - sqlite3ExprListDup( db, pStep.pExprList, 0 ), - sqlite3SelectDup( db, pStep.pSelect, 0 ), - sqlite3IdListDup( db, pStep.pIdList ), - pParse.eOrconf - ); - break; - } - case TK_DELETE: - { - sqlite3DeleteFrom( pParse, - targetSrcList( pParse, pStep ), - sqlite3ExprDup( db, pStep.pWhere, 0 ) - ); - break; + Debug.Assert(pList == null || IsVirtual(pTab) == false); + for (p = pList; p != null; p = p.pNext) { + if (p.op == op && checkColumnOverlap(p.pColumns, pChanges) != 0) { + mask |= p.tr_tm; + } } - default: - Debug.Assert( pStep.op == TK_SELECT ); + //if ( pMask != 0 ) { - SelectDest sDest = new SelectDest(); - Select pSelect = sqlite3SelectDup( db, pStep.pSelect, 0 ); - sqlite3SelectDestInit( sDest, SRT_Discard, 0 ); - sqlite3Select( pParse, pSelect, ref sDest ); - sqlite3SelectDelete( db, ref pSelect ); - break; + pMask = mask; } + return (mask != 0 ? pList : null); } - if ( pStep.op != TK_SELECT ) - { - sqlite3VdbeAddOp0( v, OP_ResetCount ); + + + /* + ** Convert the pStep.target token into a SrcList and return a pointer + ** to that SrcList. + ** + ** This routine adds a specific database name, if needed, to the target when + ** forming the SrcList. This prevents a trigger in one database from + ** referring to a target in another database. An exception is when the + ** trigger is in TEMP in which case it can refer to any other database it + ** wants. + */ + static SrcList targetSrcList( + Parse pParse, /* The parsing context */ + TriggerStep pStep /* The trigger containing the target token */ + ) { + int iDb; /* Index of the database to use */ + SrcList pSrc; /* SrcList to be returned */ + + pSrc = sqlite3SrcListAppend(pParse.db, 0, pStep.target, 0); + //if ( pSrc != null ) + //{ + Debug.Assert(pSrc.nSrc > 0); + Debug.Assert(pSrc.a != null); + iDb = sqlite3SchemaToIndex(pParse.db, pStep.pTrig.pSchema); + if (iDb == 0 || iDb >= 2) { + sqlite3 db = pParse.db; + Debug.Assert(iDb < pParse.db.nDb); + pSrc.a[pSrc.nSrc - 1].zDatabase = db.aDb[iDb].zName;// sqlite3DbStrDup( db, db.aDb[iDb].zName ); + } + //} + return pSrc; } - } - return 0; - } + /* + ** Generate VDBE code for the statements inside the body of a single + ** trigger. + */ + static int codeTriggerProgram( + Parse pParse, /* The parser context */ + TriggerStep pStepList, /* List of statements inside the trigger body */ + int orconf /* Conflict algorithm. (OE_Abort, etc) */ + ) { + TriggerStep pStep; + Vdbe v = pParse.pVdbe; + sqlite3 db = pParse.db; + + Debug.Assert(pParse.pTriggerTab != null && pParse.pToplevel != null); + Debug.Assert(pStepList != null); + Debug.Assert(v != null); + for (pStep = pStepList; pStep != null; pStep = pStep.pNext) { + /* Figure out the ON CONFLICT policy that will be used for this step + ** of the trigger program. If the statement that caused this trigger + ** to fire had an explicit ON CONFLICT, then use it. Otherwise, use + ** the ON CONFLICT policy that was specified as part of the trigger + ** step statement. Example: + ** + ** CREATE TRIGGER AFTER INSERT ON t1 BEGIN; + ** INSERT OR REPLACE INTO t2 VALUES(new.a, new.b); + ** END; + ** + ** INSERT INTO t1 ... ; -- insert into t2 uses REPLACE policy + ** INSERT OR IGNORE INTO t1 ... ; -- insert into t2 uses IGNORE policy + */ + pParse.eOrconf = (orconf == OE_Default) ? pStep.orconf : (u8)orconf; + + switch (pStep.op) { + case TK_UPDATE: { + sqlite3Update(pParse, + targetSrcList(pParse, pStep), + sqlite3ExprListDup(db, pStep.pExprList, 0), + sqlite3ExprDup(db, pStep.pWhere, 0), + pParse.eOrconf + ); + break; + } + case TK_INSERT: { + sqlite3Insert(pParse, + targetSrcList(pParse, pStep), + sqlite3ExprListDup(db, pStep.pExprList, 0), + sqlite3SelectDup(db, pStep.pSelect, 0), + sqlite3IdListDup(db, pStep.pIdList), + pParse.eOrconf + ); + break; + } + case TK_DELETE: { + sqlite3DeleteFrom(pParse, + targetSrcList(pParse, pStep), + sqlite3ExprDup(db, pStep.pWhere, 0) + ); + break; + } + default: + Debug.Assert(pStep.op == TK_SELECT); { + SelectDest sDest = new SelectDest(); + Select pSelect = sqlite3SelectDup(db, pStep.pSelect, 0); + sqlite3SelectDestInit(sDest, SRT_Discard, 0); + sqlite3Select(pParse, pSelect, ref sDest); + sqlite3SelectDelete(db, ref pSelect); + break; + } + } + if (pStep.op != TK_SELECT) { + sqlite3VdbeAddOp0(v, OP_ResetCount); + } + } + + return 0; + } #if SQLITE_DEBUG - /* -** This function is used to add VdbeComment() annotations to a VDBE -** program. It is not used in production code, only for debugging. -*/ - static string onErrorText( int onError ) - { - switch ( onError ) - { - case OE_Abort: - return "abort"; - case OE_Rollback: - return "rollback"; - case OE_Fail: - return "fail"; - case OE_Replace: - return "replace"; - case OE_Ignore: - return "ignore"; - case OE_Default: - return "default"; - } - return "n/a"; - } + /* + ** This function is used to add VdbeComment() annotations to a VDBE + ** program. It is not used in production code, only for debugging. + */ + static string onErrorText(int onError) { + switch (onError) { + case OE_Abort: + return "abort"; + case OE_Rollback: + return "rollback"; + case OE_Fail: + return "fail"; + case OE_Replace: + return "replace"; + case OE_Ignore: + return "ignore"; + case OE_Default: + return "default"; + } + return "n/a"; + } #endif - /* -** Parse context structure pFrom has just been used to create a sub-vdbe -** (trigger program). If an error has occurred, transfer error information -** from pFrom to pTo. -*/ - static void transferParseError( Parse pTo, Parse pFrom ) - { - Debug.Assert( String.IsNullOrEmpty( pFrom.zErrMsg ) || pFrom.nErr != 0 ); - Debug.Assert( String.IsNullOrEmpty( pTo.zErrMsg ) || pTo.nErr != 0 ); - if ( pTo.nErr == 0 ) - { - pTo.zErrMsg = pFrom.zErrMsg; - pTo.nErr = pFrom.nErr; - } - else - { - sqlite3DbFree( pFrom.db, ref pFrom.zErrMsg ); - } - } - - /* - ** Create and populate a new TriggerPrg object with a sub-program - ** implementing trigger pTrigger with ON CONFLICT policy orconf. + /* + ** Parse context structure pFrom has just been used to create a sub-vdbe + ** (trigger program). If an error has occurred, transfer error information + ** from pFrom to pTo. */ - static TriggerPrg codeRowTrigger( - Parse pParse, /* Current parse context */ - Trigger pTrigger, /* Trigger to code */ - Table pTab, /* The table pTrigger is attached to */ - int orconf /* ON CONFLICT policy to code trigger program with */ - ) - { - Parse pTop = sqlite3ParseToplevel( pParse ); - sqlite3 db = pParse.db; /* Database handle */ - TriggerPrg pPrg; /* Value to return */ - Expr pWhen = null; /* Duplicate of trigger WHEN expression */ - Vdbe v; /* Temporary VM */ - NameContext sNC; /* Name context for sub-vdbe */ - SubProgram pProgram = null; /* Sub-vdbe for trigger program */ - Parse pSubParse; /* Parse context for sub-vdbe */ - int iEndTrigger = 0; /* Label to jump to if WHEN is false */ - - Debug.Assert( pTrigger.zName == null || pTab == tableOfTrigger( pTrigger ) ); - Debug.Assert( pTop.pVdbe != null ); - - /* Allocate the TriggerPrg and SubProgram objects. To ensure that they - ** are freed if an error occurs, link them into the Parse.pTriggerPrg - ** list of the top-level Parse object sooner rather than later. */ - pPrg = new TriggerPrg();// sqlite3DbMallocZero( db, sizeof( TriggerPrg ) ); - //if ( null == pPrg ) return 0; - pPrg.pNext = pTop.pTriggerPrg; - pTop.pTriggerPrg = pPrg; - pPrg.pProgram = pProgram = new SubProgram();// sqlite3DbMallocZero( db, sizeof( SubProgram ) ); - //if( null==pProgram ) return 0; - sqlite3VdbeLinkSubProgram( pTop.pVdbe, pProgram ); - pPrg.pTrigger = pTrigger; - pPrg.orconf = orconf; - pPrg.aColmask[0] = 0xffffffff; - pPrg.aColmask[1] = 0xffffffff; - - - /* Allocate and populate a new Parse context to use for coding the - ** trigger sub-program. */ - pSubParse = new Parse();// sqlite3StackAllocZero( db, sizeof( Parse ) ); - //if ( null == pSubParse ) return null; - sNC = new NameContext();// memset( &sNC, 0, sizeof( sNC ) ); - sNC.pParse = pSubParse; - pSubParse.db = db; - pSubParse.pTriggerTab = pTab; - pSubParse.pToplevel = pTop; - pSubParse.zAuthContext = pTrigger.zName; - pSubParse.eTriggerOp = pTrigger.op; - pSubParse.nQueryLoop = pParse.nQueryLoop; - - v = sqlite3GetVdbe( pSubParse ); - if ( v != null ) - { + static void transferParseError(Parse pTo, Parse pFrom) { + Debug.Assert(String.IsNullOrEmpty(pFrom.zErrMsg) || pFrom.nErr != 0); + Debug.Assert(String.IsNullOrEmpty(pTo.zErrMsg) || pTo.nErr != 0); + if (pTo.nErr == 0) { + pTo.zErrMsg = pFrom.zErrMsg; + pTo.nErr = pFrom.nErr; + } else { + sqlite3DbFree(pFrom.db, ref pFrom.zErrMsg); + } + } + + /* + ** Create and populate a new TriggerPrg object with a sub-program + ** implementing trigger pTrigger with ON CONFLICT policy orconf. + */ + static TriggerPrg codeRowTrigger( + Parse pParse, /* Current parse context */ + Trigger pTrigger, /* Trigger to code */ + Table pTab, /* The table pTrigger is attached to */ + int orconf /* ON CONFLICT policy to code trigger program with */ + ) { + Parse pTop = sqlite3ParseToplevel(pParse); + sqlite3 db = pParse.db; /* Database handle */ + TriggerPrg pPrg; /* Value to return */ + Expr pWhen = null; /* Duplicate of trigger WHEN expression */ + Vdbe v; /* Temporary VM */ + NameContext sNC; /* Name context for sub-vdbe */ + SubProgram pProgram = null; /* Sub-vdbe for trigger program */ + Parse pSubParse; /* Parse context for sub-vdbe */ + int iEndTrigger = 0; /* Label to jump to if WHEN is false */ + + Debug.Assert(pTrigger.zName == null || pTab == tableOfTrigger(pTrigger)); + Debug.Assert(pTop.pVdbe != null); + + /* Allocate the TriggerPrg and SubProgram objects. To ensure that they + ** are freed if an error occurs, link them into the Parse.pTriggerPrg + ** list of the top-level Parse object sooner rather than later. */ + pPrg = new TriggerPrg();// sqlite3DbMallocZero( db, sizeof( TriggerPrg ) ); + //if ( null == pPrg ) return 0; + pPrg.pNext = pTop.pTriggerPrg; + pTop.pTriggerPrg = pPrg; + pPrg.pProgram = pProgram = new SubProgram();// sqlite3DbMallocZero( db, sizeof( SubProgram ) ); + //if( null==pProgram ) return 0; + sqlite3VdbeLinkSubProgram(pTop.pVdbe, pProgram); + pPrg.pTrigger = pTrigger; + pPrg.orconf = orconf; + pPrg.aColmask[0] = 0xffffffff; + pPrg.aColmask[1] = 0xffffffff; + + + /* Allocate and populate a new Parse context to use for coding the + ** trigger sub-program. */ + pSubParse = new Parse();// sqlite3StackAllocZero( db, sizeof( Parse ) ); + //if ( null == pSubParse ) return null; + sNC = new NameContext();// memset( &sNC, 0, sizeof( sNC ) ); + sNC.pParse = pSubParse; + pSubParse.db = db; + pSubParse.pTriggerTab = pTab; + pSubParse.pToplevel = pTop; + pSubParse.zAuthContext = pTrigger.zName; + pSubParse.eTriggerOp = pTrigger.op; + pSubParse.nQueryLoop = pParse.nQueryLoop; + + v = sqlite3GetVdbe(pSubParse); + if (v != null) { #if SQLITE_DEBUG - VdbeComment( v, "Start: %s.%s (%s %s%s%s ON %s)", - pTrigger.zName != null ? pTrigger.zName : "", onErrorText( orconf ), - ( pTrigger.tr_tm == TRIGGER_BEFORE ? "BEFORE" : "AFTER" ), - ( pTrigger.op == TK_UPDATE ? "UPDATE" : "" ), - ( pTrigger.op == TK_INSERT ? "INSERT" : "" ), - ( pTrigger.op == TK_DELETE ? "DELETE" : "" ), - pTab.zName - ); + VdbeComment(v, "Start: %s.%s (%s %s%s%s ON %s)", + pTrigger.zName != null ? pTrigger.zName : "", onErrorText(orconf), + (pTrigger.tr_tm == TRIGGER_BEFORE ? "BEFORE" : "AFTER"), + (pTrigger.op == TK_UPDATE ? "UPDATE" : ""), + (pTrigger.op == TK_INSERT ? "INSERT" : ""), + (pTrigger.op == TK_DELETE ? "DELETE" : ""), + pTab.zName + ); #endif #if !SQLITE_OMIT_TRACE - sqlite3VdbeChangeP4( v, -1, - sqlite3MPrintf( db, "-- TRIGGER %s", pTrigger.zName ), P4_DYNAMIC - ); + sqlite3VdbeChangeP4(v, -1, + sqlite3MPrintf(db, "-- TRIGGER %s", pTrigger.zName), P4_DYNAMIC + ); #endif - /* If one was specified, code the WHEN clause. If it evaluates to false - ** (or NULL) the sub-vdbe is immediately halted by jumping to the - ** OP_Halt inserted at the end of the program. */ - if ( pTrigger.pWhen != null ) - { - pWhen = sqlite3ExprDup( db, pTrigger.pWhen, 0 ); - if ( SQLITE_OK == sqlite3ResolveExprNames( sNC, ref pWhen ) - //&& db.mallocFailed==0 - ) - { - iEndTrigger = sqlite3VdbeMakeLabel( v ); - sqlite3ExprIfFalse( pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL ); - } - sqlite3ExprDelete( db, ref pWhen ); - } + /* If one was specified, code the WHEN clause. If it evaluates to false + ** (or NULL) the sub-vdbe is immediately halted by jumping to the + ** OP_Halt inserted at the end of the program. */ + if (pTrigger.pWhen != null) { + pWhen = sqlite3ExprDup(db, pTrigger.pWhen, 0); + if (SQLITE_OK == sqlite3ResolveExprNames(sNC, ref pWhen) + //&& db.mallocFailed==0 + ) { + iEndTrigger = sqlite3VdbeMakeLabel(v); + sqlite3ExprIfFalse(pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL); + } + sqlite3ExprDelete(db, ref pWhen); + } + + /* Code the trigger program into the sub-vdbe. */ + codeTriggerProgram(pSubParse, pTrigger.step_list, orconf); + + /* Insert an OP_Halt at the end of the sub-program. */ + if (iEndTrigger != 0) { + sqlite3VdbeResolveLabel(v, iEndTrigger); + } + sqlite3VdbeAddOp0(v, OP_Halt); +#if SQLITE_DEBUG + VdbeComment(v, "End: %s.%s", pTrigger.zName, onErrorText(orconf)); +#endif + transferParseError(pParse, pSubParse); + //if( db.mallocFailed==0 ){ + pProgram.aOp = sqlite3VdbeTakeOpArray(v, ref pProgram.nOp, ref pTop.nMaxArg); + //} + pProgram.nMem = pSubParse.nMem; + pProgram.nCsr = pSubParse.nTab; + pProgram.token = pTrigger.GetHashCode(); + pPrg.aColmask[0] = pSubParse.oldmask; + pPrg.aColmask[1] = pSubParse.newmask; + sqlite3VdbeDelete(ref v); + } - /* Code the trigger program into the sub-vdbe. */ - codeTriggerProgram( pSubParse, pTrigger.step_list, orconf ); + Debug.Assert(null == pSubParse.pAinc && null == pSubParse.pZombieTab); + Debug.Assert(null == pSubParse.pTriggerPrg && 0 == pSubParse.nMaxArg); + //sqlite3StackFree(db, pSubParse); - /* Insert an OP_Halt at the end of the sub-program. */ - if ( iEndTrigger != 0 ) - { - sqlite3VdbeResolveLabel( v, iEndTrigger ); + return pPrg; } - sqlite3VdbeAddOp0( v, OP_Halt ); -#if SQLITE_DEBUG - VdbeComment( v, "End: %s.%s", pTrigger.zName, onErrorText( orconf ) ); -#endif - transferParseError( pParse, pSubParse ); - //if( db.mallocFailed==0 ){ - pProgram.aOp = sqlite3VdbeTakeOpArray( v, ref pProgram.nOp, ref pTop.nMaxArg ); - //} - pProgram.nMem = pSubParse.nMem; - pProgram.nCsr = pSubParse.nTab; - pProgram.token = pTrigger.GetHashCode(); - pPrg.aColmask[0] = pSubParse.oldmask; - pPrg.aColmask[1] = pSubParse.newmask; - sqlite3VdbeDelete( ref v ); - } - - Debug.Assert( null == pSubParse.pAinc && null == pSubParse.pZombieTab ); - Debug.Assert( null == pSubParse.pTriggerPrg && 0 == pSubParse.nMaxArg ); - //sqlite3StackFree(db, pSubParse); - - return pPrg; - } - /* - ** Return a pointer to a TriggerPrg object containing the sub-program for - ** trigger pTrigger with default ON CONFLICT algorithm orconf. If no such - ** TriggerPrg object exists, a new object is allocated and populated before - ** being returned. - */ - static TriggerPrg getRowTrigger( - Parse pParse, /* Current parse context */ - Trigger pTrigger, /* Trigger to code */ - Table pTab, /* The table trigger pTrigger is attached to */ - int orconf /* ON CONFLICT algorithm. */ - ) - { - Parse pRoot = sqlite3ParseToplevel( pParse ); - TriggerPrg pPrg; - - Debug.Assert( pTrigger.zName == null || pTab == tableOfTrigger( pTrigger ) ); - - /* It may be that this trigger has already been coded (or is in the - ** process of being coded). If this is the case, then an entry with - ** a matching TriggerPrg.pTrigger field will be present somewhere - ** in the Parse.pTriggerPrg list. Search for such an entry. */ - for ( pPrg = pRoot.pTriggerPrg; - pPrg != null && ( pPrg.pTrigger != pTrigger || pPrg.orconf != orconf ); - pPrg = pPrg.pNext - ) - ; - - /* If an existing TriggerPrg could not be located, create a new one. */ - if ( null == pPrg ) - { - pPrg = codeRowTrigger( pParse, pTrigger, pTab, orconf ); - } - - return pPrg; - } + /* + ** Return a pointer to a TriggerPrg object containing the sub-program for + ** trigger pTrigger with default ON CONFLICT algorithm orconf. If no such + ** TriggerPrg object exists, a new object is allocated and populated before + ** being returned. + */ + static TriggerPrg getRowTrigger( + Parse pParse, /* Current parse context */ + Trigger pTrigger, /* Trigger to code */ + Table pTab, /* The table trigger pTrigger is attached to */ + int orconf /* ON CONFLICT algorithm. */ + ) { + Parse pRoot = sqlite3ParseToplevel(pParse); + TriggerPrg pPrg; + + Debug.Assert(pTrigger.zName == null || pTab == tableOfTrigger(pTrigger)); + + /* It may be that this trigger has already been coded (or is in the + ** process of being coded). If this is the case, then an entry with + ** a matching TriggerPrg.pTrigger field will be present somewhere + ** in the Parse.pTriggerPrg list. Search for such an entry. */ + for (pPrg = pRoot.pTriggerPrg; + pPrg != null && (pPrg.pTrigger != pTrigger || pPrg.orconf != orconf); + pPrg = pPrg.pNext + ) + ; + + /* If an existing TriggerPrg could not be located, create a new one. */ + if (null == pPrg) { + pPrg = codeRowTrigger(pParse, pTrigger, pTab, orconf); + } - /* - ** Generate code for the trigger program associated with trigger p on - ** table pTab. The reg, orconf and ignoreJump parameters passed to this - ** function are the same as those described in the header function for - ** sqlite3CodeRowTrigger() - */ - static void sqlite3CodeRowTriggerDirect( - Parse pParse, /* Parse context */ - Trigger p, /* Trigger to code */ - Table pTab, /* The table to code triggers from */ - int reg, /* Reg array containing OLD.* and NEW.* values */ - int orconf, /* ON CONFLICT policy */ - int ignoreJump /* Instruction to jump to for RAISE(IGNORE) */ - ) - { - Vdbe v = sqlite3GetVdbe( pParse ); /* Main VM */ - TriggerPrg pPrg; - pPrg = getRowTrigger( pParse, p, pTab, orconf ); - Debug.Assert( pPrg != null || pParse.nErr != 0 );//|| pParse.db.mallocFailed ); - - /* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program - ** is a pointer to the sub-vdbe containing the trigger program. */ - if ( pPrg != null ) - { - bool bRecursive = ( !String.IsNullOrEmpty( p.zName ) && 0 == ( pParse.db.flags & SQLITE_RecTriggers ) ); - sqlite3VdbeAddOp3( v, OP_Program, reg, ignoreJump, ++pParse.nMem ); - sqlite3VdbeChangeP4( v, -1, pPrg.pProgram, P4_SUBPROGRAM ); + return pPrg; + } + + /* + ** Generate code for the trigger program associated with trigger p on + ** table pTab. The reg, orconf and ignoreJump parameters passed to this + ** function are the same as those described in the header function for + ** sqlite3CodeRowTrigger() + */ + static void sqlite3CodeRowTriggerDirect( + Parse pParse, /* Parse context */ + Trigger p, /* Trigger to code */ + Table pTab, /* The table to code triggers from */ + int reg, /* Reg array containing OLD.* and NEW.* values */ + int orconf, /* ON CONFLICT policy */ + int ignoreJump /* Instruction to jump to for RAISE(IGNORE) */ + ) { + Vdbe v = sqlite3GetVdbe(pParse); /* Main VM */ + TriggerPrg pPrg; + pPrg = getRowTrigger(pParse, p, pTab, orconf); + Debug.Assert(pPrg != null || pParse.nErr != 0);//|| pParse.db.mallocFailed ); + + /* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program + ** is a pointer to the sub-vdbe containing the trigger program. */ + if (pPrg != null) { + bool bRecursive = (!String.IsNullOrEmpty(p.zName) && 0 == (pParse.db.flags & SQLITE_RecTriggers)); + sqlite3VdbeAddOp3(v, OP_Program, reg, ignoreJump, ++pParse.nMem); + sqlite3VdbeChangeP4(v, -1, pPrg.pProgram, P4_SUBPROGRAM); #if SQLITE_DEBUG - VdbeComment - ( v, "Call: %s.%s", ( !String.IsNullOrEmpty( p.zName ) ? p.zName : "fkey" ), onErrorText( orconf ) ); + VdbeComment + (v, "Call: %s.%s", (!String.IsNullOrEmpty(p.zName) ? p.zName : "fkey"), onErrorText(orconf)); #endif - /* Set the P5 operand of the OP_Program instruction to non-zero if - ** recursive invocation of this trigger program is disallowed. Recursive - ** invocation is disallowed if (a) the sub-program is really a trigger, - ** not a foreign key action, and (b) the flag to enable recursive triggers - ** is clear. */ - sqlite3VdbeChangeP5( v, (u8)( bRecursive ? 1 : 0 ) ); - } - } - - /* - ** This is called to code the required FOR EACH ROW triggers for an operation - ** on table pTab. The operation to code triggers for (INSERT, UPDATE or DELETE) - ** is given by the op paramater. The tr_tm parameter determines whether the - ** BEFORE or AFTER triggers are coded. If the operation is an UPDATE, then - ** parameter pChanges is passed the list of columns being modified. - ** - ** If there are no triggers that fire at the specified time for the specified - ** operation on pTab, this function is a no-op. - ** - ** The reg argument is the address of the first in an array of registers - ** that contain the values substituted for the new.* and old.* references - ** in the trigger program. If N is the number of columns in table pTab - ** (a copy of pTab.nCol), then registers are populated as follows: - ** - ** Register Contains - ** ------------------------------------------------------ - ** reg+0 OLD.rowid - ** reg+1 OLD.* value of left-most column of pTab - ** ... ... - ** reg+N OLD.* value of right-most column of pTab - ** reg+N+1 NEW.rowid - ** reg+N+2 OLD.* value of left-most column of pTab - ** ... ... - ** reg+N+N+1 NEW.* value of right-most column of pTab - ** - ** For ON DELETE triggers, the registers containing the NEW.* values will - ** never be accessed by the trigger program, so they are not allocated or - ** populated by the caller (there is no data to populate them with anyway). - ** Similarly, for ON INSERT triggers the values stored in the OLD.* registers - ** are never accessed, and so are not allocated by the caller. So, for an - ** ON INSERT trigger, the value passed to this function as parameter reg - ** is not a readable register, although registers (reg+N) through - ** (reg+N+N+1) are. - ** - ** Parameter orconf is the default conflict resolution algorithm for the - ** trigger program to use (REPLACE, IGNORE etc.). Parameter ignoreJump - ** is the instruction that control should jump to if a trigger program - ** raises an IGNORE exception. - */ - static void sqlite3CodeRowTrigger( - Parse pParse, /* Parse context */ - Trigger pTrigger, /* List of triggers on table pTab */ - int op, /* One of TK_UPDATE, TK_INSERT, TK_DELETE */ - ExprList pChanges, /* Changes list for any UPDATE OF triggers */ - int tr_tm, /* One of TRIGGER_BEFORE, TRIGGER_AFTER */ - Table pTab, /* The table to code triggers from */ - int reg, /* The first in an array of registers (see above) */ - int orconf, /* ON CONFLICT policy */ - int ignoreJump /* Instruction to jump to for RAISE(IGNORE) */ - ) - { - Trigger p; /* Used to iterate through pTrigger list */ - - Debug.Assert( op == TK_UPDATE || op == TK_INSERT || op == TK_DELETE ); - Debug.Assert( tr_tm == TRIGGER_BEFORE || tr_tm == TRIGGER_AFTER ); - Debug.Assert( ( op == TK_UPDATE ) == ( pChanges != null ) ); - - for ( p = pTrigger; p != null; p = p.pNext ) - { - - /* Sanity checking: The schema for the trigger and for the table are - ** always defined. The trigger must be in the same schema as the table - ** or else it must be a TEMP trigger. */ - Debug.Assert( p.pSchema != null ); - Debug.Assert( p.pTabSchema != null ); - Debug.Assert( p.pSchema == p.pTabSchema - || p.pSchema == pParse.db.aDb[1].pSchema ); - - /* Determine whether we should code this trigger */ - if ( p.op == op - && p.tr_tm == tr_tm - && checkColumnOverlap( p.pColumns, pChanges ) != 0 - ) - { - sqlite3CodeRowTriggerDirect( pParse, p, pTab, reg, orconf, ignoreJump ); + /* Set the P5 operand of the OP_Program instruction to non-zero if + ** recursive invocation of this trigger program is disallowed. Recursive + ** invocation is disallowed if (a) the sub-program is really a trigger, + ** not a foreign key action, and (b) the flag to enable recursive triggers + ** is clear. */ + sqlite3VdbeChangeP5(v, (u8)(bRecursive ? 1 : 0)); + } } - } - } - /* - ** Triggers may access values stored in the old.* or new.* pseudo-table. - ** This function returns a 32-bit bitmask indicating which columns of the - ** old.* or new.* tables actually are used by triggers. This information - ** may be used by the caller, for example, to avoid having to load the entire - ** old.* record into memory when executing an UPDATE or DELETE command. - ** - ** Bit 0 of the returned mask is set if the left-most column of the - ** table may be accessed using an [old|new]. reference. Bit 1 is set if - ** the second leftmost column value is required, and so on. If there - ** are more than 32 columns in the table, and at least one of the columns - ** with an index greater than 32 may be accessed, 0xffffffff is returned. - ** - ** It is not possible to determine if the old.rowid or new.rowid column is - ** accessed by triggers. The caller must always assume that it is. - ** - ** Parameter isNew must be either 1 or 0. If it is 0, then the mask returned - ** applies to the old.* table. If 1, the new.* table. - ** - ** Parameter tr_tm must be a mask with one or both of the TRIGGER_BEFORE - ** and TRIGGER_AFTER bits set. Values accessed by BEFORE triggers are only - ** included in the returned mask if the TRIGGER_BEFORE bit is set in the - ** tr_tm parameter. Similarly, values accessed by AFTER triggers are only - ** included in the returned mask if the TRIGGER_AFTER bit is set in tr_tm. - */ - static u32 sqlite3TriggerColmask( - Parse pParse, /* Parse context */ - Trigger pTrigger, /* List of triggers on table pTab */ - ExprList pChanges, /* Changes list for any UPDATE OF triggers */ - int isNew, /* 1 for new.* ref mask, 0 for old.* ref mask */ - int tr_tm, /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */ - Table pTab, /* The table to code triggers from */ - int orconf /* Default ON CONFLICT policy for trigger steps */ - ) - { - int op = pChanges != null ? TK_UPDATE : TK_DELETE; - u32 mask = 0; - Trigger p; - - Debug.Assert( isNew == 1 || isNew == 0 ); - for ( p = pTrigger; p != null; p = p.pNext ) - { - if ( p.op == op && ( tr_tm & p.tr_tm ) != 0 - && checkColumnOverlap( p.pColumns, pChanges ) != 0 - ) - { - TriggerPrg pPrg; - pPrg = getRowTrigger( pParse, p, pTab, orconf ); - if ( pPrg != null ) - { - mask |= pPrg.aColmask[isNew]; - } + /* + ** This is called to code the required FOR EACH ROW triggers for an operation + ** on table pTab. The operation to code triggers for (INSERT, UPDATE or DELETE) + ** is given by the op paramater. The tr_tm parameter determines whether the + ** BEFORE or AFTER triggers are coded. If the operation is an UPDATE, then + ** parameter pChanges is passed the list of columns being modified. + ** + ** If there are no triggers that fire at the specified time for the specified + ** operation on pTab, this function is a no-op. + ** + ** The reg argument is the address of the first in an array of registers + ** that contain the values substituted for the new.* and old.* references + ** in the trigger program. If N is the number of columns in table pTab + ** (a copy of pTab.nCol), then registers are populated as follows: + ** + ** Register Contains + ** ------------------------------------------------------ + ** reg+0 OLD.rowid + ** reg+1 OLD.* value of left-most column of pTab + ** ... ... + ** reg+N OLD.* value of right-most column of pTab + ** reg+N+1 NEW.rowid + ** reg+N+2 OLD.* value of left-most column of pTab + ** ... ... + ** reg+N+N+1 NEW.* value of right-most column of pTab + ** + ** For ON DELETE triggers, the registers containing the NEW.* values will + ** never be accessed by the trigger program, so they are not allocated or + ** populated by the caller (there is no data to populate them with anyway). + ** Similarly, for ON INSERT triggers the values stored in the OLD.* registers + ** are never accessed, and so are not allocated by the caller. So, for an + ** ON INSERT trigger, the value passed to this function as parameter reg + ** is not a readable register, although registers (reg+N) through + ** (reg+N+N+1) are. + ** + ** Parameter orconf is the default conflict resolution algorithm for the + ** trigger program to use (REPLACE, IGNORE etc.). Parameter ignoreJump + ** is the instruction that control should jump to if a trigger program + ** raises an IGNORE exception. + */ + static void sqlite3CodeRowTrigger( + Parse pParse, /* Parse context */ + Trigger pTrigger, /* List of triggers on table pTab */ + int op, /* One of TK_UPDATE, TK_INSERT, TK_DELETE */ + ExprList pChanges, /* Changes list for any UPDATE OF triggers */ + int tr_tm, /* One of TRIGGER_BEFORE, TRIGGER_AFTER */ + Table pTab, /* The table to code triggers from */ + int reg, /* The first in an array of registers (see above) */ + int orconf, /* ON CONFLICT policy */ + int ignoreJump /* Instruction to jump to for RAISE(IGNORE) */ + ) { + Trigger p; /* Used to iterate through pTrigger list */ + + Debug.Assert(op == TK_UPDATE || op == TK_INSERT || op == TK_DELETE); + Debug.Assert(tr_tm == TRIGGER_BEFORE || tr_tm == TRIGGER_AFTER); + Debug.Assert((op == TK_UPDATE) == (pChanges != null)); + + for (p = pTrigger; p != null; p = p.pNext) { + + /* Sanity checking: The schema for the trigger and for the table are + ** always defined. The trigger must be in the same schema as the table + ** or else it must be a TEMP trigger. */ + Debug.Assert(p.pSchema != null); + Debug.Assert(p.pTabSchema != null); + Debug.Assert(p.pSchema == p.pTabSchema + || p.pSchema == pParse.db.aDb[1].pSchema); + + /* Determine whether we should code this trigger */ + if (p.op == op + && p.tr_tm == tr_tm + && checkColumnOverlap(p.pColumns, pChanges) != 0 + ) { + sqlite3CodeRowTriggerDirect(pParse, p, pTab, reg, orconf, ignoreJump); + } + } } - } - return mask; - } + /* + ** Triggers may access values stored in the old.* or new.* pseudo-table. + ** This function returns a 32-bit bitmask indicating which columns of the + ** old.* or new.* tables actually are used by triggers. This information + ** may be used by the caller, for example, to avoid having to load the entire + ** old.* record into memory when executing an UPDATE or DELETE command. + ** + ** Bit 0 of the returned mask is set if the left-most column of the + ** table may be accessed using an [old|new]. reference. Bit 1 is set if + ** the second leftmost column value is required, and so on. If there + ** are more than 32 columns in the table, and at least one of the columns + ** with an index greater than 32 may be accessed, 0xffffffff is returned. + ** + ** It is not possible to determine if the old.rowid or new.rowid column is + ** accessed by triggers. The caller must always assume that it is. + ** + ** Parameter isNew must be either 1 or 0. If it is 0, then the mask returned + ** applies to the old.* table. If 1, the new.* table. + ** + ** Parameter tr_tm must be a mask with one or both of the TRIGGER_BEFORE + ** and TRIGGER_AFTER bits set. Values accessed by BEFORE triggers are only + ** included in the returned mask if the TRIGGER_BEFORE bit is set in the + ** tr_tm parameter. Similarly, values accessed by AFTER triggers are only + ** included in the returned mask if the TRIGGER_AFTER bit is set in tr_tm. + */ + static u32 sqlite3TriggerColmask( + Parse pParse, /* Parse context */ + Trigger pTrigger, /* List of triggers on table pTab */ + ExprList pChanges, /* Changes list for any UPDATE OF triggers */ + int isNew, /* 1 for new.* ref mask, 0 for old.* ref mask */ + int tr_tm, /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */ + Table pTab, /* The table to code triggers from */ + int orconf /* Default ON CONFLICT policy for trigger steps */ + ) { + int op = pChanges != null ? TK_UPDATE : TK_DELETE; + u32 mask = 0; + Trigger p; + + Debug.Assert(isNew == 1 || isNew == 0); + for (p = pTrigger; p != null; p = p.pNext) { + if (p.op == op && (tr_tm & p.tr_tm) != 0 + && checkColumnOverlap(p.pColumns, pChanges) != 0 + ) { + TriggerPrg pPrg; + pPrg = getRowTrigger(pParse, p, pTab, orconf); + if (pPrg != null) { + mask |= pPrg.aColmask[isNew]; + } + } + } + + return mask; + } #endif // * !SQLITE_OMIT_TRIGGER) */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/update_c.cs b/Src/IronPython.SQLite/c#sqlite/update_c.cs index bc6b81874..7570bd390 100644 --- a/Src/IronPython.SQLite/c#sqlite/update_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/update_c.cs @@ -1,183 +1,174 @@ using System; using System.Diagnostics; -using u8 = System.Byte; using u32 = System.UInt32; -namespace Community.CsharpSqlite -{ - using sqlite3_value = Sqlite3.Mem; +namespace Community.CsharpSqlite { + using sqlite3_value = Sqlite3.Mem; - public partial class Sqlite3 - { - /* - ** 2001 September 15 - ** - ** The author disclaims copyright to this source code. In place of - ** a legal notice, here is a blessing: + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** This file contains C code routines that are called by the parser + ** to handle UPDATE statements. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + +#if !SQLITE_OMIT_VIRTUALTABLE + /* Forward declaration */ + //static void updateVirtualTable( + //Parse pParse, /* The parsing context */ + //SrcList pSrc, /* The virtual table to be modified */ + //Table pTab, /* The virtual table */ + //ExprList pChanges, /* The columns to change in the UPDATE statement */ + //Expr pRowidExpr, /* Expression used to recompute the rowid */ + //int aXRef, /* Mapping from columns of pTab to entries in pChanges */ + //Expr *pWhere, /* WHERE clause of the UPDATE statement */ + //int onError /* ON CONFLICT strategy */ + //); +#endif // * SQLITE_OMIT_VIRTUALTABLE */ + + /* + ** The most recently coded instruction was an OP_Column to retrieve the + ** i-th column of table pTab. This routine sets the P4 parameter of the + ** OP_Column to the default value, if any. ** - ** 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. + ** The default value of a column is specified by a DEFAULT clause in the + ** column definition. This was either supplied by the user when the table + ** was created, or added later to the table definition by an ALTER TABLE + ** command. If the latter, then the row-records in the table btree on disk + ** may not contain a value for the column and the default value, taken + ** from the P4 parameter of the OP_Column instruction, is returned instead. + ** If the former, then all row-records are guaranteed to include a value + ** for the column and the P4 value is not required. ** - ************************************************************************* - ** This file contains C code routines that are called by the parser - ** to handle UPDATE statements. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library + ** Column definitions created by an ALTER TABLE command may only have + ** literal default values specified: a number, null or a string. (If a more + ** complicated default expression value was provided, it is evaluated + ** when the ALTER TABLE is executed and one of the literal values written + ** into the sqlite_master table.) ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** Therefore, the P4 parameter is only required if the default value for + ** the column is a literal number, string or null. The sqlite3ValueFromExpr() + ** function is capable of transforming these types of expressions into + ** sqlite3_value objects. ** - ************************************************************************* + ** If parameter iReg is not negative, code an OP_RealAffinity instruction + ** on register iReg. This is used when an equivalent integer value is + ** stored in place of an 8-byte floating point value in order to save + ** space. */ - //#include "sqliteInt.h" - -#if !SQLITE_OMIT_VIRTUALTABLE - /* Forward declaration */ - //static void updateVirtualTable( - //Parse pParse, /* The parsing context */ - //SrcList pSrc, /* The virtual table to be modified */ - //Table pTab, /* The virtual table */ - //ExprList pChanges, /* The columns to change in the UPDATE statement */ - //Expr pRowidExpr, /* Expression used to recompute the rowid */ - //int aXRef, /* Mapping from columns of pTab to entries in pChanges */ - //Expr *pWhere, /* WHERE clause of the UPDATE statement */ - //int onError /* ON CONFLICT strategy */ - //); -#endif // * SQLITE_OMIT_VIRTUALTABLE */ - - /* -** The most recently coded instruction was an OP_Column to retrieve the -** i-th column of table pTab. This routine sets the P4 parameter of the -** OP_Column to the default value, if any. -** -** The default value of a column is specified by a DEFAULT clause in the -** column definition. This was either supplied by the user when the table -** was created, or added later to the table definition by an ALTER TABLE -** command. If the latter, then the row-records in the table btree on disk -** may not contain a value for the column and the default value, taken -** from the P4 parameter of the OP_Column instruction, is returned instead. -** If the former, then all row-records are guaranteed to include a value -** for the column and the P4 value is not required. -** -** Column definitions created by an ALTER TABLE command may only have -** literal default values specified: a number, null or a string. (If a more -** complicated default expression value was provided, it is evaluated -** when the ALTER TABLE is executed and one of the literal values written -** into the sqlite_master table.) -** -** Therefore, the P4 parameter is only required if the default value for -** the column is a literal number, string or null. The sqlite3ValueFromExpr() -** function is capable of transforming these types of expressions into -** sqlite3_value objects. -** -** If parameter iReg is not negative, code an OP_RealAffinity instruction -** on register iReg. This is used when an equivalent integer value is -** stored in place of an 8-byte floating point value in order to save -** space. -*/ - static void sqlite3ColumnDefault( Vdbe v, Table pTab, int i, int iReg ) - { - Debug.Assert( pTab != null ); - if ( null == pTab.pSelect ) - { - sqlite3_value pValue = new sqlite3_value(); - int enc = ENC( sqlite3VdbeDb( v ) ); - Column pCol = pTab.aCol[i]; + static void sqlite3ColumnDefault(Vdbe v, Table pTab, int i, int iReg) { + Debug.Assert(pTab != null); + if (null == pTab.pSelect) { + sqlite3_value pValue = new sqlite3_value(); + int enc = ENC(sqlite3VdbeDb(v)); + Column pCol = pTab.aCol[i]; #if SQLITE_DEBUG - VdbeComment( v, "%s.%s", pTab.zName, pCol.zName ); + VdbeComment(v, "%s.%s", pTab.zName, pCol.zName); #endif - Debug.Assert( i < pTab.nCol ); - sqlite3ValueFromExpr( sqlite3VdbeDb( v ), pCol.pDflt, enc, - pCol.affinity, ref pValue ); - if ( pValue != null ) - { - sqlite3VdbeChangeP4( v, -1, pValue, P4_MEM ); - } + Debug.Assert(i < pTab.nCol); + sqlite3ValueFromExpr(sqlite3VdbeDb(v), pCol.pDflt, enc, + pCol.affinity, ref pValue); + if (pValue != null) { + sqlite3VdbeChangeP4(v, -1, pValue, P4_MEM); + } #if !SQLITE_OMIT_FLOATING_POINT - if ( iReg >= 0 && pTab.aCol[i].affinity == SQLITE_AFF_REAL ) - { - sqlite3VdbeAddOp1( v, OP_RealAffinity, iReg ); - } + if (iReg >= 0 && pTab.aCol[i].affinity == SQLITE_AFF_REAL) { + sqlite3VdbeAddOp1(v, OP_RealAffinity, iReg); + } #endif - } - } + } + } - /* - ** Process an UPDATE statement. - ** - ** UPDATE OR IGNORE table_wxyz SET a=b, c=d WHERE e<5 AND f NOT NULL; - ** \_______/ \________/ \______/ \________________/ - * onError pTabList pChanges pWhere - */ - static void sqlite3Update( - Parse pParse, /* The parser context */ - SrcList pTabList, /* The table in which we should change things */ - ExprList pChanges, /* Things to be changed */ - Expr pWhere, /* The WHERE clause. May be null */ - int onError /* How to handle constraint errors */ - ) - { - int i, j; /* Loop counters */ - Table pTab; /* The table to be updated */ - int addr = 0; /* VDBE instruction address of the start of the loop */ - WhereInfo pWInfo; /* Information about the WHERE clause */ - Vdbe v; /* The virtual database engine */ - Index pIdx; /* For looping over indices */ - int nIdx; /* Number of indices that need updating */ - int iCur; /* VDBE Cursor number of pTab */ - sqlite3 db; /* The database structure */ - int[] aRegIdx = null; /* One register assigned to each index to be updated */ - int[] aXRef = null; /* aXRef[i] is the index in pChanges.a[] of the + /* + ** Process an UPDATE statement. + ** + ** UPDATE OR IGNORE table_wxyz SET a=b, c=d WHERE e<5 AND f NOT NULL; + ** \_______/ \________/ \______/ \________________/ + * onError pTabList pChanges pWhere + */ + static void sqlite3Update( + Parse pParse, /* The parser context */ + SrcList pTabList, /* The table in which we should change things */ + ExprList pChanges, /* Things to be changed */ + Expr pWhere, /* The WHERE clause. May be null */ + int onError /* How to handle constraint errors */ + ) { + int i, j; /* Loop counters */ + Table pTab; /* The table to be updated */ + int addr = 0; /* VDBE instruction address of the start of the loop */ + WhereInfo pWInfo; /* Information about the WHERE clause */ + Vdbe v; /* The virtual database engine */ + Index pIdx; /* For looping over indices */ + int nIdx; /* Number of indices that need updating */ + int iCur; /* VDBE Cursor number of pTab */ + sqlite3 db; /* The database structure */ + int[] aRegIdx = null; /* One register assigned to each index to be updated */ + int[] aXRef = null; /* aXRef[i] is the index in pChanges.a[] of the ** an expression for the i-th column of the table. ** aXRef[i]==-1 if the i-th column is not changed. */ - bool chngRowid; /* True if the record number is being changed */ - Expr pRowidExpr = null; /* Expression defining the new record number */ - bool openAll = false; /* True if all indices need to be opened */ - AuthContext sContext; /* The authorization context */ - NameContext sNC; /* The name-context to resolve expressions in */ - int iDb; /* Database containing the table being updated */ - bool okOnePass; /* True for one-pass algorithm without the FIFO */ - bool hasFK; /* True if foreign key processing is required */ + bool chngRowid; /* True if the record number is being changed */ + Expr pRowidExpr = null; /* Expression defining the new record number */ + bool openAll = false; /* True if all indices need to be opened */ + AuthContext sContext; /* The authorization context */ + NameContext sNC; /* The name-context to resolve expressions in */ + int iDb; /* Database containing the table being updated */ + bool okOnePass; /* True for one-pass algorithm without the FIFO */ + bool hasFK; /* True if foreign key processing is required */ #if !SQLITE_OMIT_TRIGGER - bool isView; /* True when updating a view (INSTEAD OF trigger) */ - Trigger pTrigger; /* List of triggers on pTab, if required */ - int tmask = 0; /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */ + bool isView; /* True when updating a view (INSTEAD OF trigger) */ + Trigger pTrigger; /* List of triggers on pTab, if required */ + int tmask = 0; /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */ #endif - int newmask; /* Mask of NEW.* columns accessed by BEFORE triggers */ - - /* Register Allocations */ - int regRowCount = 0; /* A count of rows changed */ - int regOldRowid; /* The old rowid */ - int regNewRowid; /* The new rowid */ - int regNew; - int regOld = 0; - int regRowSet = 0; /* Rowset of rows to be updated */ - - sContext = new AuthContext(); //memset( &sContext, 0, sizeof( sContext ) ); - db = pParse.db; - if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) - { - goto update_cleanup; - } - Debug.Assert( pTabList.nSrc == 1 ); - - /* Locate the table which we want to update. - */ - pTab = sqlite3SrcListLookup( pParse, pTabList ); - if ( pTab == null ) - goto update_cleanup; - iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema ); + int newmask; /* Mask of NEW.* columns accessed by BEFORE triggers */ + + /* Register Allocations */ + int regRowCount = 0; /* A count of rows changed */ + int regOldRowid; /* The old rowid */ + int regNewRowid; /* The new rowid */ + int regNew; + int regOld = 0; + int regRowSet = 0; /* Rowset of rows to be updated */ + + sContext = new AuthContext(); //memset( &sContext, 0, sizeof( sContext ) ); + db = pParse.db; + if (pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) { + goto update_cleanup; + } + Debug.Assert(pTabList.nSrc == 1); - /* Figure out if we have any triggers and if the table being - ** updated is a view. - */ + /* Locate the table which we want to update. + */ + pTab = sqlite3SrcListLookup(pParse, pTabList); + if (pTab == null) + goto update_cleanup; + iDb = sqlite3SchemaToIndex(pParse.db, pTab.pSchema); + + /* Figure out if we have any triggers and if the table being + ** updated is a view. + */ #if !SQLITE_OMIT_TRIGGER - pTrigger = sqlite3TriggersExist( pParse, pTab, TK_UPDATE, pChanges, out tmask ); - isView = pTab.pSelect != null; - Debug.Assert( pTrigger != null || tmask == 0 ); + pTrigger = sqlite3TriggersExist(pParse, pTab, TK_UPDATE, pChanges, out tmask); + isView = pTab.pSelect != null; + Debug.Assert(pTrigger != null || tmask == 0); #else const Trigger pTrigger = null;//# define pTrigger 0 const int tmask = 0; //# define tmask 0 @@ -187,75 +178,63 @@ int onError /* How to handle constraint errors */ const bool isView = false; //# define isView 0 #endif - if ( sqlite3ViewGetColumnNames( pParse, pTab ) != 0 ) - { - goto update_cleanup; - } - if ( sqlite3IsReadOnly( pParse, pTab, tmask ) ) - { - goto update_cleanup; - } - aXRef = new int[pTab.nCol];// sqlite3DbMallocRaw(db, sizeof(int) * pTab.nCol); - //if ( aXRef == null ) goto update_cleanup; - for ( i = 0; i < pTab.nCol; i++ ) - aXRef[i] = -1; - - /* Allocate a cursors for the main database table and for all indices. - ** The index cursors might not be used, but if they are used they - ** need to occur right after the database cursor. So go ahead and - ** allocate enough space, just in case. - */ - pTabList.a[0].iCursor = iCur = pParse.nTab++; - for ( pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext ) - { - pParse.nTab++; - } - - /* Initialize the name-context */ - sNC = new NameContext();// memset(&sNC, 0, sNC).Length; - sNC.pParse = pParse; - sNC.pSrcList = pTabList; - - /* Resolve the column names in all the expressions of the - ** of the UPDATE statement. Also find the column index - ** for each column to be updated in the pChanges array. For each - ** column to be updated, make sure we have authorization to change - ** that column. - */ - chngRowid = false; - for ( i = 0; i < pChanges.nExpr; i++ ) - { - if ( sqlite3ResolveExprNames( sNC, ref pChanges.a[i].pExpr ) != 0 ) - { - goto update_cleanup; - } - for ( j = 0; j < pTab.nCol; j++ ) - { - if ( pTab.aCol[j].zName.Equals( pChanges.a[i].zName, StringComparison.OrdinalIgnoreCase ) ) - { - if ( j == pTab.iPKey ) - { - chngRowid = true; - pRowidExpr = pChanges.a[i].pExpr; + if (sqlite3ViewGetColumnNames(pParse, pTab) != 0) { + goto update_cleanup; } - aXRef[j] = i; - break; - } - } - if ( j >= pTab.nCol ) - { - if ( sqlite3IsRowid( pChanges.a[i].zName ) ) - { - chngRowid = true; - pRowidExpr = pChanges.a[i].pExpr; - } - else - { - sqlite3ErrorMsg( pParse, "no such column: %s", pChanges.a[i].zName ); - pParse.checkSchema = 1; - goto update_cleanup; - } - } + if (sqlite3IsReadOnly(pParse, pTab, tmask)) { + goto update_cleanup; + } + aXRef = new int[pTab.nCol];// sqlite3DbMallocRaw(db, sizeof(int) * pTab.nCol); + //if ( aXRef == null ) goto update_cleanup; + for (i = 0; i < pTab.nCol; i++) + aXRef[i] = -1; + + /* Allocate a cursors for the main database table and for all indices. + ** The index cursors might not be used, but if they are used they + ** need to occur right after the database cursor. So go ahead and + ** allocate enough space, just in case. + */ + pTabList.a[0].iCursor = iCur = pParse.nTab++; + for (pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext) { + pParse.nTab++; + } + + /* Initialize the name-context */ + sNC = new NameContext();// memset(&sNC, 0, sNC).Length; + sNC.pParse = pParse; + sNC.pSrcList = pTabList; + + /* Resolve the column names in all the expressions of the + ** of the UPDATE statement. Also find the column index + ** for each column to be updated in the pChanges array. For each + ** column to be updated, make sure we have authorization to change + ** that column. + */ + chngRowid = false; + for (i = 0; i < pChanges.nExpr; i++) { + if (sqlite3ResolveExprNames(sNC, ref pChanges.a[i].pExpr) != 0) { + goto update_cleanup; + } + for (j = 0; j < pTab.nCol; j++) { + if (pTab.aCol[j].zName.Equals(pChanges.a[i].zName, StringComparison.OrdinalIgnoreCase)) { + if (j == pTab.iPKey) { + chngRowid = true; + pRowidExpr = pChanges.a[i].pExpr; + } + aXRef[j] = i; + break; + } + } + if (j >= pTab.nCol) { + if (sqlite3IsRowid(pChanges.a[i].zName)) { + chngRowid = true; + pRowidExpr = pChanges.a[i].pExpr; + } else { + sqlite3ErrorMsg(pParse, "no such column: %s", pChanges.a[i].zName); + pParse.checkSchema = 1; + goto update_cleanup; + } + } #if !SQLITE_OMIT_AUTHORIZATION { int rc; @@ -268,514 +247,453 @@ int onError /* How to handle constraint errors */ } } #endif - } + } - hasFK = sqlite3FkRequired( pParse, pTab, aXRef, chngRowid ? 1 : 0 ) != 0; + hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngRowid ? 1 : 0) != 0; - /* Allocate memory for the array aRegIdx[]. There is one entry in the - ** array for each index associated with table being updated. Fill in - ** the value with a register number for indices that are to be used - ** and with zero for unused indices. - */ - for ( nIdx = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, nIdx++ ) - { - } - if ( nIdx > 0 ) - { - aRegIdx = new int[nIdx]; // sqlite3DbMallocRaw(db, Index*.Length * nIdx); - if ( aRegIdx == null ) - goto update_cleanup; - } - for ( j = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, j++ ) - { - int reg; - if ( hasFK || chngRowid ) - { - reg = ++pParse.nMem; - } - else - { - reg = 0; - for ( i = 0; i < pIdx.nColumn; i++ ) - { - if ( aXRef[pIdx.aiColumn[i]] >= 0 ) - { - reg = ++pParse.nMem; - break; + /* Allocate memory for the array aRegIdx[]. There is one entry in the + ** array for each index associated with table being updated. Fill in + ** the value with a register number for indices that are to be used + ** and with zero for unused indices. + */ + for (nIdx = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, nIdx++) { + } + if (nIdx > 0) { + aRegIdx = new int[nIdx]; // sqlite3DbMallocRaw(db, Index*.Length * nIdx); + if (aRegIdx == null) + goto update_cleanup; + } + for (j = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, j++) { + int reg; + if (hasFK || chngRowid) { + reg = ++pParse.nMem; + } else { + reg = 0; + for (i = 0; i < pIdx.nColumn; i++) { + if (aXRef[pIdx.aiColumn[i]] >= 0) { + reg = ++pParse.nMem; + break; + } + } + } + aRegIdx[j] = reg; } - } - } - aRegIdx[j] = reg; - } - /* Begin generating code. */ - v = sqlite3GetVdbe( pParse ); - if ( v == null ) - goto update_cleanup; - if ( pParse.nested == 0 ) - sqlite3VdbeCountChanges( v ); - sqlite3BeginWriteOperation( pParse, 1, iDb ); + /* Begin generating code. */ + v = sqlite3GetVdbe(pParse); + if (v == null) + goto update_cleanup; + if (pParse.nested == 0) + sqlite3VdbeCountChanges(v); + sqlite3BeginWriteOperation(pParse, 1, iDb); #if !SQLITE_OMIT_VIRTUALTABLE - /* Virtual tables must be handled separately */ - if ( IsVirtual( pTab ) ) - { - updateVirtualTable( pParse, pTabList, pTab, pChanges, pRowidExpr, aXRef, - pWhere, onError ); - pWhere = null; - pTabList = null; - goto update_cleanup; - } + /* Virtual tables must be handled separately */ + if (IsVirtual(pTab)) { + updateVirtualTable(pParse, pTabList, pTab, pChanges, pRowidExpr, aXRef, + pWhere, onError); + pWhere = null; + pTabList = null; + goto update_cleanup; + } #endif - /* Allocate required registers. */ - regOldRowid = regNewRowid = ++pParse.nMem; - if ( pTrigger != null || hasFK ) - { - regOld = pParse.nMem + 1; - pParse.nMem += pTab.nCol; - } - if ( chngRowid || pTrigger != null || hasFK ) - { - regNewRowid = ++pParse.nMem; - } - regNew = pParse.nMem + 1; - pParse.nMem += pTab.nCol; - - /* Start the view context. */ - if ( isView ) - { - sqlite3AuthContextPush( pParse, sContext, pTab.zName ); - } - - /* If we are trying to update a view, realize that view into - ** a ephemeral table. - */ + /* Allocate required registers. */ + regOldRowid = regNewRowid = ++pParse.nMem; + if (pTrigger != null || hasFK) { + regOld = pParse.nMem + 1; + pParse.nMem += pTab.nCol; + } + if (chngRowid || pTrigger != null || hasFK) { + regNewRowid = ++pParse.nMem; + } + regNew = pParse.nMem + 1; + pParse.nMem += pTab.nCol; + + /* Start the view context. */ + if (isView) { + sqlite3AuthContextPush(pParse, sContext, pTab.zName); + } + + /* If we are trying to update a view, realize that view into + ** a ephemeral table. + */ #if !(SQLITE_OMIT_VIEW) && !(SQLITE_OMIT_TRIGGER) - if ( isView ) - { - sqlite3MaterializeView( pParse, pTab, pWhere, iCur ); - } + if (isView) { + sqlite3MaterializeView(pParse, pTab, pWhere, iCur); + } #endif - /* Resolve the column names in all the expressions in the -** WHERE clause. -*/ - if ( sqlite3ResolveExprNames( sNC, ref pWhere ) != 0 ) - { - goto update_cleanup; - } - - /* Begin the database scan + /* Resolve the column names in all the expressions in the + ** WHERE clause. */ - sqlite3VdbeAddOp2( v, OP_Null, 0, regOldRowid ); - ExprList NullOrderby = null; - pWInfo = sqlite3WhereBegin( pParse, pTabList, pWhere, ref NullOrderby, WHERE_ONEPASS_DESIRED ); - if ( pWInfo == null ) - goto update_cleanup; - okOnePass = pWInfo.okOnePass != 0; - - /* Remember the rowid of every item to be updated. - */ - sqlite3VdbeAddOp2( v, OP_Rowid, iCur, regOldRowid ); - if ( !okOnePass ) - { - regRowSet = ++pParse.nMem; - sqlite3VdbeAddOp2( v, OP_RowSetAdd, regRowSet, regOldRowid ); - } - - /* End the database scan loop. - */ - sqlite3WhereEnd( pWInfo ); + if (sqlite3ResolveExprNames(sNC, ref pWhere) != 0) { + goto update_cleanup; + } - /* Initialize the count of updated rows - */ - if ( ( db.flags & SQLITE_CountRows ) != 0 && null == pParse.pTriggerTab ) - { - regRowCount = ++pParse.nMem; - sqlite3VdbeAddOp2( v, OP_Integer, 0, regRowCount ); - } - - if ( !isView ) - { - /* - ** Open every index that needs updating. Note that if any - ** index could potentially invoke a REPLACE conflict resolution - ** action, then we need to open all indices because we might need - ** to be deleting some records. - */ - if ( !okOnePass ) - sqlite3OpenTable( pParse, iCur, iDb, pTab, OP_OpenWrite ); - if ( onError == OE_Replace ) - { - openAll = true; - } - else - { - openAll = false; - for ( pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext ) - { - if ( pIdx.onError == OE_Replace ) - { - openAll = true; - break; + /* Begin the database scan + */ + sqlite3VdbeAddOp2(v, OP_Null, 0, regOldRowid); + ExprList NullOrderby = null; + pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, ref NullOrderby, WHERE_ONEPASS_DESIRED); + if (pWInfo == null) + goto update_cleanup; + okOnePass = pWInfo.okOnePass != 0; + + /* Remember the rowid of every item to be updated. + */ + sqlite3VdbeAddOp2(v, OP_Rowid, iCur, regOldRowid); + if (!okOnePass) { + regRowSet = ++pParse.nMem; + sqlite3VdbeAddOp2(v, OP_RowSetAdd, regRowSet, regOldRowid); } - } - } - for ( i = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, i++ ) - { - if ( openAll || aRegIdx[i] > 0 ) - { - KeyInfo pKey = sqlite3IndexKeyinfo( pParse, pIdx ); - sqlite3VdbeAddOp4( v, OP_OpenWrite, iCur + i + 1, pIdx.tnum, iDb, - pKey, P4_KEYINFO_HANDOFF ); - Debug.Assert( pParse.nTab > iCur + i + 1 ); - } - } - } - - /* Top of the update loop */ - if ( okOnePass ) - { - int a1 = sqlite3VdbeAddOp1( v, OP_NotNull, regOldRowid ); - addr = sqlite3VdbeAddOp0( v, OP_Goto ); - sqlite3VdbeJumpHere( v, a1 ); - } - else - { - addr = sqlite3VdbeAddOp3( v, OP_RowSetRead, regRowSet, 0, regOldRowid ); - } - - /* Make cursor iCur point to the record that is being updated. If - ** this record does not exist for some reason (deleted by a trigger, - ** for example, then jump to the next iteration of the RowSet loop. */ - sqlite3VdbeAddOp3( v, OP_NotExists, iCur, addr, regOldRowid ); - - /* If the record number will change, set register regNewRowid to - ** contain the new value. If the record number is not being modified, - ** then regNewRowid is the same register as regOldRowid, which is - ** already populated. */ - Debug.Assert( chngRowid || pTrigger != null || hasFK || regOldRowid == regNewRowid ); - if ( chngRowid ) - { - sqlite3ExprCode( pParse, pRowidExpr, regNewRowid ); - sqlite3VdbeAddOp1( v, OP_MustBeInt, regNewRowid ); - } - - /* If there are triggers on this table, populate an array of registers - ** with the required old.* column data. */ - if ( hasFK || pTrigger != null ) - { - u32 oldmask = ( hasFK ? sqlite3FkOldmask( pParse, pTab ) : 0 ); - oldmask |= sqlite3TriggerColmask( pParse, - pTrigger, pChanges, 0, TRIGGER_BEFORE | TRIGGER_AFTER, pTab, onError - ); - for ( i = 0; i < pTab.nCol; i++ ) - { - if ( aXRef[i] < 0 || oldmask == 0xffffffff || ( i < 32 && 0 != ( oldmask & ( 1 << i ) ) ) ) - { - sqlite3ExprCodeGetColumnOfTable( v, pTab, iCur, i, regOld + i ); - } - else - { - sqlite3VdbeAddOp2( v, OP_Null, 0, regOld + i ); - } - } - if ( chngRowid == false ) - { - sqlite3VdbeAddOp2( v, OP_Copy, regOldRowid, regNewRowid ); - } - } - - /* Populate the array of registers beginning at regNew with the new - ** row data. This array is used to check constaints, create the new - ** table and index records, and as the values for any new.* references - ** made by triggers. - ** - ** If there are one or more BEFORE triggers, then do not populate the - ** registers associated with columns that are (a) not modified by - ** this UPDATE statement and (b) not accessed by new.* references. The - ** values for registers not modified by the UPDATE must be reloaded from - ** the database after the BEFORE triggers are fired anyway (as the trigger - ** may have modified them). So not loading those that are not going to - ** be used eliminates some redundant opcodes. - */ - newmask = (int)sqlite3TriggerColmask( - pParse, pTrigger, pChanges, 1, TRIGGER_BEFORE, pTab, onError - ); - for ( i = 0; i < pTab.nCol; i++ ) - { - if ( i == pTab.iPKey ) - { - sqlite3VdbeAddOp2( v, OP_Null, 0, regNew + i ); - } - else - { - j = aXRef[i]; - if ( j >= 0 ) - { - sqlite3ExprCode( pParse, pChanges.a[j].pExpr, regNew + i ); - } - else if ( 0 == ( tmask & TRIGGER_BEFORE ) || i > 31 || ( newmask & ( 1 << i ) ) != 0 ) - { - /* This branch loads the value of a column that will not be changed - ** into a register. This is done if there are no BEFORE triggers, or - ** if there are one or more BEFORE triggers that use this value via - ** a new.* reference in a trigger program. + + /* End the database scan loop. */ - testcase( i == 31 ); - testcase( i == 32 ); - sqlite3VdbeAddOp3( v, OP_Column, iCur, i, regNew + i ); - sqlite3ColumnDefault( v, pTab, i, regNew + i ); - } - } - } + sqlite3WhereEnd(pWInfo); - /* Fire any BEFORE UPDATE triggers. This happens before constraints are - ** verified. One could argue that this is wrong. - */ - if ( ( tmask & TRIGGER_BEFORE ) != 0 ) - { - sqlite3VdbeAddOp2( v, OP_Affinity, regNew, pTab.nCol ); - sqlite3TableAffinityStr( v, pTab ); - sqlite3CodeRowTrigger( pParse, pTrigger, TK_UPDATE, pChanges, - TRIGGER_BEFORE, pTab, regOldRowid, onError, addr ); - - /* The row-trigger may have deleted the row being updated. In this - ** case, jump to the next row. No updates or AFTER triggers are - ** required. This behaviour - what happens when the row being updated - ** is deleted or renamed by a BEFORE trigger - is left undefined in the - ** documentation. - */ - sqlite3VdbeAddOp3( v, OP_NotExists, iCur, addr, regOldRowid ); + /* Initialize the count of updated rows + */ + if ((db.flags & SQLITE_CountRows) != 0 && null == pParse.pTriggerTab) { + regRowCount = ++pParse.nMem; + sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount); + } - /* If it did not delete it, the row-trigger may still have modified - ** some of the columns of the row being updated. Load the values for - ** all columns not modified by the update statement into their - ** registers in case this has happened. - */ - for ( i = 0; i < pTab.nCol; i++ ) - { - if ( aXRef[i] < 0 && i != pTab.iPKey ) - { - sqlite3VdbeAddOp3( v, OP_Column, iCur, i, regNew + i ); - sqlite3ColumnDefault( v, pTab, i, regNew + i ); - } - } - } + if (!isView) { + /* + ** Open every index that needs updating. Note that if any + ** index could potentially invoke a REPLACE conflict resolution + ** action, then we need to open all indices because we might need + ** to be deleting some records. + */ + if (!okOnePass) + sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenWrite); + if (onError == OE_Replace) { + openAll = true; + } else { + openAll = false; + for (pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext) { + if (pIdx.onError == OE_Replace) { + openAll = true; + break; + } + } + } + for (i = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, i++) { + if (openAll || aRegIdx[i] > 0) { + KeyInfo pKey = sqlite3IndexKeyinfo(pParse, pIdx); + sqlite3VdbeAddOp4(v, OP_OpenWrite, iCur + i + 1, pIdx.tnum, iDb, + pKey, P4_KEYINFO_HANDOFF); + Debug.Assert(pParse.nTab > iCur + i + 1); + } + } + } - if ( !isView ) - { - int j1; /* Address of jump instruction */ + /* Top of the update loop */ + if (okOnePass) { + int a1 = sqlite3VdbeAddOp1(v, OP_NotNull, regOldRowid); + addr = sqlite3VdbeAddOp0(v, OP_Goto); + sqlite3VdbeJumpHere(v, a1); + } else { + addr = sqlite3VdbeAddOp3(v, OP_RowSetRead, regRowSet, 0, regOldRowid); + } - /* Do constraint checks. */ - int iDummy; - sqlite3GenerateConstraintChecks( pParse, pTab, iCur, regNewRowid, - aRegIdx, ( chngRowid ? regOldRowid : 0 ), true, onError, addr, out iDummy ); + /* Make cursor iCur point to the record that is being updated. If + ** this record does not exist for some reason (deleted by a trigger, + ** for example, then jump to the next iteration of the RowSet loop. */ + sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, regOldRowid); + + /* If the record number will change, set register regNewRowid to + ** contain the new value. If the record number is not being modified, + ** then regNewRowid is the same register as regOldRowid, which is + ** already populated. */ + Debug.Assert(chngRowid || pTrigger != null || hasFK || regOldRowid == regNewRowid); + if (chngRowid) { + sqlite3ExprCode(pParse, pRowidExpr, regNewRowid); + sqlite3VdbeAddOp1(v, OP_MustBeInt, regNewRowid); + } - /* Do FK constraint checks. */ - if ( hasFK ) - { - sqlite3FkCheck( pParse, pTab, regOldRowid, 0 ); - } + /* If there are triggers on this table, populate an array of registers + ** with the required old.* column data. */ + if (hasFK || pTrigger != null) { + u32 oldmask = (hasFK ? sqlite3FkOldmask(pParse, pTab) : 0); + oldmask |= sqlite3TriggerColmask(pParse, + pTrigger, pChanges, 0, TRIGGER_BEFORE | TRIGGER_AFTER, pTab, onError + ); + for (i = 0; i < pTab.nCol; i++) { + if (aXRef[i] < 0 || oldmask == 0xffffffff || (i < 32 && 0 != (oldmask & (1 << i)))) { + sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, i, regOld + i); + } else { + sqlite3VdbeAddOp2(v, OP_Null, 0, regOld + i); + } + } + if (chngRowid == false) { + sqlite3VdbeAddOp2(v, OP_Copy, regOldRowid, regNewRowid); + } + } - /* Delete the index entries associated with the current record. */ - j1 = sqlite3VdbeAddOp3( v, OP_NotExists, iCur, 0, regOldRowid ); - sqlite3GenerateRowIndexDelete( pParse, pTab, iCur, aRegIdx ); + /* Populate the array of registers beginning at regNew with the new + ** row data. This array is used to check constaints, create the new + ** table and index records, and as the values for any new.* references + ** made by triggers. + ** + ** If there are one or more BEFORE triggers, then do not populate the + ** registers associated with columns that are (a) not modified by + ** this UPDATE statement and (b) not accessed by new.* references. The + ** values for registers not modified by the UPDATE must be reloaded from + ** the database after the BEFORE triggers are fired anyway (as the trigger + ** may have modified them). So not loading those that are not going to + ** be used eliminates some redundant opcodes. + */ + newmask = (int)sqlite3TriggerColmask( + pParse, pTrigger, pChanges, 1, TRIGGER_BEFORE, pTab, onError + ); + for (i = 0; i < pTab.nCol; i++) { + if (i == pTab.iPKey) { + sqlite3VdbeAddOp2(v, OP_Null, 0, regNew + i); + } else { + j = aXRef[i]; + if (j >= 0) { + sqlite3ExprCode(pParse, pChanges.a[j].pExpr, regNew + i); + } else if (0 == (tmask & TRIGGER_BEFORE) || i > 31 || (newmask & (1 << i)) != 0) { + /* This branch loads the value of a column that will not be changed + ** into a register. This is done if there are no BEFORE triggers, or + ** if there are one or more BEFORE triggers that use this value via + ** a new.* reference in a trigger program. + */ + testcase(i == 31); + testcase(i == 32); + sqlite3VdbeAddOp3(v, OP_Column, iCur, i, regNew + i); + sqlite3ColumnDefault(v, pTab, i, regNew + i); + } + } + } - /* If changing the record number, delete the old record. */ - if ( hasFK || chngRowid ) - { - sqlite3VdbeAddOp2( v, OP_Delete, iCur, 0 ); - } - sqlite3VdbeJumpHere( v, j1 ); + /* Fire any BEFORE UPDATE triggers. This happens before constraints are + ** verified. One could argue that this is wrong. + */ + if ((tmask & TRIGGER_BEFORE) != 0) { + sqlite3VdbeAddOp2(v, OP_Affinity, regNew, pTab.nCol); + sqlite3TableAffinityStr(v, pTab); + sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, + TRIGGER_BEFORE, pTab, regOldRowid, onError, addr); + + /* The row-trigger may have deleted the row being updated. In this + ** case, jump to the next row. No updates or AFTER triggers are + ** required. This behaviour - what happens when the row being updated + ** is deleted or renamed by a BEFORE trigger - is left undefined in the + ** documentation. + */ + sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, regOldRowid); + + /* If it did not delete it, the row-trigger may still have modified + ** some of the columns of the row being updated. Load the values for + ** all columns not modified by the update statement into their + ** registers in case this has happened. + */ + for (i = 0; i < pTab.nCol; i++) { + if (aXRef[i] < 0 && i != pTab.iPKey) { + sqlite3VdbeAddOp3(v, OP_Column, iCur, i, regNew + i); + sqlite3ColumnDefault(v, pTab, i, regNew + i); + } + } + } - if ( hasFK ) - { - sqlite3FkCheck( pParse, pTab, 0, regNewRowid ); - } + if (!isView) { + int j1; /* Address of jump instruction */ + + /* Do constraint checks. */ + int iDummy; + sqlite3GenerateConstraintChecks(pParse, pTab, iCur, regNewRowid, + aRegIdx, (chngRowid ? regOldRowid : 0), true, onError, addr, out iDummy); + + /* Do FK constraint checks. */ + if (hasFK) { + sqlite3FkCheck(pParse, pTab, regOldRowid, 0); + } + + /* Delete the index entries associated with the current record. */ + j1 = sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regOldRowid); + sqlite3GenerateRowIndexDelete(pParse, pTab, iCur, aRegIdx); + + /* If changing the record number, delete the old record. */ + if (hasFK || chngRowid) { + sqlite3VdbeAddOp2(v, OP_Delete, iCur, 0); + } + sqlite3VdbeJumpHere(v, j1); + + if (hasFK) { + sqlite3FkCheck(pParse, pTab, 0, regNewRowid); + } + + /* Insert the new index entries and the new record. */ + sqlite3CompleteInsertion(pParse, pTab, iCur, regNewRowid, aRegIdx, true, false, false); + + /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to + ** handle rows (possibly in other tables) that refer via a foreign key + ** to the row just updated. */ + if (hasFK) { + sqlite3FkActions(pParse, pTab, pChanges, regOldRowid); + } + } - /* Insert the new index entries and the new record. */ - sqlite3CompleteInsertion( pParse, pTab, iCur, regNewRowid, aRegIdx, true, false, false ); + /* Increment the row counter + */ + if ((db.flags & SQLITE_CountRows) != 0 && null == pParse.pTriggerTab) { + sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1); + } - /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to - ** handle rows (possibly in other tables) that refer via a foreign key - ** to the row just updated. */ - if ( hasFK ) - { - sqlite3FkActions( pParse, pTab, pChanges, regOldRowid ); - } - } + sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, + TRIGGER_AFTER, pTab, regOldRowid, onError, addr); - /* Increment the row counter - */ - if ( ( db.flags & SQLITE_CountRows ) != 0 && null == pParse.pTriggerTab ) - { - sqlite3VdbeAddOp2( v, OP_AddImm, regRowCount, 1 ); - } + /* Repeat the above with the next record to be updated, until + ** all record selected by the WHERE clause have been updated. + */ + sqlite3VdbeAddOp2(v, OP_Goto, 0, addr); + sqlite3VdbeJumpHere(v, addr); + + /* Close all tables */ + for (i = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, i++) { + if (openAll || aRegIdx[i] > 0) { + sqlite3VdbeAddOp2(v, OP_Close, iCur + i + 1, 0); + } + } + sqlite3VdbeAddOp2(v, OP_Close, iCur, 0); - sqlite3CodeRowTrigger( pParse, pTrigger, TK_UPDATE, pChanges, - TRIGGER_AFTER, pTab, regOldRowid, onError, addr ); + /* Update the sqlite_sequence table by storing the content of the + ** maximum rowid counter values recorded while inserting into + ** autoincrement tables. + */ + if (pParse.nested == 0 && pParse.pTriggerTab == null) { + sqlite3AutoincrementEnd(pParse); + } - /* Repeat the above with the next record to be updated, until - ** all record selected by the WHERE clause have been updated. - */ - sqlite3VdbeAddOp2( v, OP_Goto, 0, addr ); - sqlite3VdbeJumpHere( v, addr ); - - /* Close all tables */ - for ( i = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, i++ ) - { - if ( openAll || aRegIdx[i] > 0 ) - { - sqlite3VdbeAddOp2( v, OP_Close, iCur + i + 1, 0 ); - } - } - sqlite3VdbeAddOp2( v, OP_Close, iCur, 0 ); + /* + ** Return the number of rows that were changed. If this routine is + ** generating code because of a call to sqlite3NestedParse(), do not + ** invoke the callback function. + */ + if ((db.flags & SQLITE_CountRows) != 0 && null == pParse.pTriggerTab && 0 == pParse.nested) { + sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1); + sqlite3VdbeSetNumCols(v, 1); + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows updated", SQLITE_STATIC); + } - /* Update the sqlite_sequence table by storing the content of the - ** maximum rowid counter values recorded while inserting into - ** autoincrement tables. - */ - if ( pParse.nested == 0 && pParse.pTriggerTab == null ) - { - sqlite3AutoincrementEnd( pParse ); - } - - /* - ** Return the number of rows that were changed. If this routine is - ** generating code because of a call to sqlite3NestedParse(), do not - ** invoke the callback function. - */ - if ( ( db.flags & SQLITE_CountRows ) != 0 && null == pParse.pTriggerTab && 0 == pParse.nested ) - { - sqlite3VdbeAddOp2( v, OP_ResultRow, regRowCount, 1 ); - sqlite3VdbeSetNumCols( v, 1 ); - sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "rows updated", SQLITE_STATIC ); - } - -update_cleanup: + update_cleanup: #if !SQLITE_OMIT_AUTHORIZATION sqlite3AuthContextPop(sContext); #endif - sqlite3DbFree( db, ref aRegIdx ); - sqlite3DbFree( db, ref aXRef ); - sqlite3SrcListDelete( db, ref pTabList ); - sqlite3ExprListDelete( db, ref pChanges ); - sqlite3ExprDelete( db, ref pWhere ); - return; - } - /* Make sure "isView" and other macros defined above are undefined. Otherwise - ** thely may interfere with compilation of other functions in this file - ** (or in another file, if this file becomes part of the amalgamation). */ - //#if isView - // #undef isView - //#endif - //#if pTrigger - // #undef pTrigger - //#endif + sqlite3DbFree(db, ref aRegIdx); + sqlite3DbFree(db, ref aXRef); + sqlite3SrcListDelete(db, ref pTabList); + sqlite3ExprListDelete(db, ref pChanges); + sqlite3ExprDelete(db, ref pWhere); + return; + } + /* Make sure "isView" and other macros defined above are undefined. Otherwise + ** thely may interfere with compilation of other functions in this file + ** (or in another file, if this file becomes part of the amalgamation). */ + //#if isView + // #undef isView + //#endif + //#if pTrigger + // #undef pTrigger + //#endif #if !SQLITE_OMIT_VIRTUALTABLE - /* -** Generate code for an UPDATE of a virtual table. -** -** The strategy is that we create an ephemerial table that contains -** for each row to be changed: -** -** (A) The original rowid of that row. -** (B) The revised rowid for the row. (note1) -** (C) The content of every column in the row. -** -** Then we loop over this ephemeral table and for each row in -** the ephermeral table call VUpdate. -** -** When finished, drop the ephemeral table. -** -** (note1) Actually, if we know in advance that (A) is always the same -** as (B) we only store (A), then duplicate (A) when pulling -** it out of the ephemeral table before calling VUpdate. -*/ - static void updateVirtualTable( - Parse pParse, /* The parsing context */ - SrcList pSrc, /* The virtual table to be modified */ - Table pTab, /* The virtual table */ - ExprList pChanges, /* The columns to change in the UPDATE statement */ - Expr pRowid, /* Expression used to recompute the rowid */ - int[] aXRef, /* Mapping from columns of pTab to entries in pChanges */ - Expr pWhere, /* WHERE clause of the UPDATE statement */ - int onError /* ON CONFLICT strategy */ - ) - { - Vdbe v = pParse.pVdbe; /* Virtual machine under construction */ - ExprList pEList = null; /* The result set of the SELECT statement */ - Select pSelect = null; /* The SELECT statement */ - Expr pExpr; /* Temporary expression */ - int ephemTab; /* Table holding the result of the SELECT */ - int i; /* Loop counter */ - int addr; /* Address of top of loop */ - int iReg; /* First register in set passed to OP_VUpdate */ - sqlite3 db = pParse.db; /* Database connection */ - VTable pVTab = sqlite3GetVTable( db, pTab ); - SelectDest dest = new SelectDest(); - - /* Construct the SELECT statement that will find the new values for - ** all updated rows. - */ - pEList = sqlite3ExprListAppend( pParse, 0, sqlite3Expr( db, TK_ID, "_rowid_" ) ); - if ( pRowid != null) - { - pEList = sqlite3ExprListAppend( pParse, pEList, - sqlite3ExprDup( db, pRowid, 0 ) ); - } - Debug.Assert( pTab.iPKey < 0 ); - for ( i = 0; i < pTab.nCol; i++ ) - { - if ( aXRef[i] >= 0 ) - { - pExpr = sqlite3ExprDup( db, pChanges.a[aXRef[i]].pExpr, 0 ); - } - else - { - pExpr = sqlite3Expr( db, TK_ID, pTab.aCol[i].zName ); - } - pEList = sqlite3ExprListAppend( pParse, pEList, pExpr ); - } - pSelect = sqlite3SelectNew( pParse, pEList, pSrc, pWhere, null, null, null, 0, null, null ); + /* + ** Generate code for an UPDATE of a virtual table. + ** + ** The strategy is that we create an ephemerial table that contains + ** for each row to be changed: + ** + ** (A) The original rowid of that row. + ** (B) The revised rowid for the row. (note1) + ** (C) The content of every column in the row. + ** + ** Then we loop over this ephemeral table and for each row in + ** the ephermeral table call VUpdate. + ** + ** When finished, drop the ephemeral table. + ** + ** (note1) Actually, if we know in advance that (A) is always the same + ** as (B) we only store (A), then duplicate (A) when pulling + ** it out of the ephemeral table before calling VUpdate. + */ + static void updateVirtualTable( + Parse pParse, /* The parsing context */ + SrcList pSrc, /* The virtual table to be modified */ + Table pTab, /* The virtual table */ + ExprList pChanges, /* The columns to change in the UPDATE statement */ + Expr pRowid, /* Expression used to recompute the rowid */ + int[] aXRef, /* Mapping from columns of pTab to entries in pChanges */ + Expr pWhere, /* WHERE clause of the UPDATE statement */ + int onError /* ON CONFLICT strategy */ + ) { + Vdbe v = pParse.pVdbe; /* Virtual machine under construction */ + ExprList pEList = null; /* The result set of the SELECT statement */ + Select pSelect = null; /* The SELECT statement */ + Expr pExpr; /* Temporary expression */ + int ephemTab; /* Table holding the result of the SELECT */ + int i; /* Loop counter */ + int addr; /* Address of top of loop */ + int iReg; /* First register in set passed to OP_VUpdate */ + sqlite3 db = pParse.db; /* Database connection */ + VTable pVTab = sqlite3GetVTable(db, pTab); + SelectDest dest = new SelectDest(); + + /* Construct the SELECT statement that will find the new values for + ** all updated rows. + */ + pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, TK_ID, "_rowid_")); + if (pRowid != null) { + pEList = sqlite3ExprListAppend(pParse, pEList, + sqlite3ExprDup(db, pRowid, 0)); + } + Debug.Assert(pTab.iPKey < 0); + for (i = 0; i < pTab.nCol; i++) { + if (aXRef[i] >= 0) { + pExpr = sqlite3ExprDup(db, pChanges.a[aXRef[i]].pExpr, 0); + } else { + pExpr = sqlite3Expr(db, TK_ID, pTab.aCol[i].zName); + } + pEList = sqlite3ExprListAppend(pParse, pEList, pExpr); + } + pSelect = sqlite3SelectNew(pParse, pEList, pSrc, pWhere, null, null, null, 0, null, null); - /* Create the ephemeral table into which the update results will - ** be stored. - */ - Debug.Assert( v != null); - ephemTab = pParse.nTab++; - sqlite3VdbeAddOp2( v, OP_OpenEphemeral, ephemTab, pTab.nCol + 1 + ( ( pRowid != null ) ? 1 : 0 ) ); - sqlite3VdbeChangeP5( v, BTREE_UNORDERED ); + /* Create the ephemeral table into which the update results will + ** be stored. + */ + Debug.Assert(v != null); + ephemTab = pParse.nTab++; + sqlite3VdbeAddOp2(v, OP_OpenEphemeral, ephemTab, pTab.nCol + 1 + ((pRowid != null) ? 1 : 0)); + sqlite3VdbeChangeP5(v, BTREE_UNORDERED); - /* fill the ephemeral table - */ - sqlite3SelectDestInit( dest, SRT_Table, ephemTab ); - sqlite3Select( pParse, pSelect, ref dest ); - - /* Generate code to scan the ephemeral table and call VUpdate. */ - iReg = ++pParse.nMem; - pParse.nMem += pTab.nCol + 1; - addr = sqlite3VdbeAddOp2( v, OP_Rewind, ephemTab, 0 ); - sqlite3VdbeAddOp3( v, OP_Column, ephemTab, 0, iReg ); - sqlite3VdbeAddOp3( v, OP_Column, ephemTab, ( pRowid != null ? 1 : 0 ), iReg + 1 ); - for ( i = 0; i < pTab.nCol; i++ ) - { - sqlite3VdbeAddOp3( v, OP_Column, ephemTab, i + 1 + ( ( pRowid != null ) ? 1 : 0 ), iReg + 2 + i ); - } - sqlite3VtabMakeWritable( pParse, pTab ); - sqlite3VdbeAddOp4( v, OP_VUpdate, 0, pTab.nCol + 2, iReg, pVTab, P4_VTAB ); - sqlite3VdbeChangeP5( v, (byte)( onError == OE_Default ? OE_Abort : onError ) ); - sqlite3MayAbort( pParse ); - sqlite3VdbeAddOp2( v, OP_Next, ephemTab, addr + 1 ); - sqlite3VdbeJumpHere( v, addr ); - sqlite3VdbeAddOp2( v, OP_Close, ephemTab, 0 ); - - /* Cleanup */ - sqlite3SelectDelete( db, ref pSelect ); - } + /* fill the ephemeral table + */ + sqlite3SelectDestInit(dest, SRT_Table, ephemTab); + sqlite3Select(pParse, pSelect, ref dest); + + /* Generate code to scan the ephemeral table and call VUpdate. */ + iReg = ++pParse.nMem; + pParse.nMem += pTab.nCol + 1; + addr = sqlite3VdbeAddOp2(v, OP_Rewind, ephemTab, 0); + sqlite3VdbeAddOp3(v, OP_Column, ephemTab, 0, iReg); + sqlite3VdbeAddOp3(v, OP_Column, ephemTab, (pRowid != null ? 1 : 0), iReg + 1); + for (i = 0; i < pTab.nCol; i++) { + sqlite3VdbeAddOp3(v, OP_Column, ephemTab, i + 1 + ((pRowid != null) ? 1 : 0), iReg + 2 + i); + } + sqlite3VtabMakeWritable(pParse, pTab); + sqlite3VdbeAddOp4(v, OP_VUpdate, 0, pTab.nCol + 2, iReg, pVTab, P4_VTAB); + sqlite3VdbeChangeP5(v, (byte)(onError == OE_Default ? OE_Abort : onError)); + sqlite3MayAbort(pParse); + sqlite3VdbeAddOp2(v, OP_Next, ephemTab, addr + 1); + sqlite3VdbeJumpHere(v, addr); + sqlite3VdbeAddOp2(v, OP_Close, ephemTab, 0); + + /* Cleanup */ + sqlite3SelectDelete(db, ref pSelect); + } #endif // * SQLITE_OMIT_VIRTUALTABLE */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/utf_c.cs b/Src/IronPython.SQLite/c#sqlite/utf_c.cs index 0d18555a4..9d15afc5a 100644 --- a/Src/IronPython.SQLite/c#sqlite/utf_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/utf_c.cs @@ -1,71 +1,68 @@ using System; -using System.Diagnostics; -using System.Text; + using u32 = System.UInt32; -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 2004 April 13 - ** - ** 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 contains routines used to translate between UTF-8, - ** UTF-16, UTF-16BE, and UTF-16LE. - ** - ** Notes on UTF-8: - ** - ** Byte-0 Byte-1 Byte-2 Byte-3 Value - ** 0xxxxxxx 00000000 00000000 0xxxxxxx - ** 110yyyyy 10xxxxxx 00000000 00000yyy yyxxxxxx - ** 1110zzzz 10yyyyyy 10xxxxxx 00000000 zzzzyyyy yyxxxxxx - ** 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx 000uuuuu zzzzyyyy yyxxxxxx - ** - ** - ** Notes on UTF-16: (with wwww+1==uuuuu) - ** - ** Word-0 Word-1 Value - ** 110110ww wwzzzzyy 110111yy yyxxxxxx 000uuuuu zzzzyyyy yyxxxxxx - ** zzzzyyyy yyxxxxxx 00000000 zzzzyyyy yyxxxxxx - ** - ** - ** BOM or Byte Order Mark: - ** 0xff 0xfe little-endian utf-16 follows - ** 0xfe 0xff big-endian utf-16 follows - ** - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include - //#include "vdbeInt.h" +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2004 April 13 + ** + ** 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 contains routines used to translate between UTF-8, + ** UTF-16, UTF-16BE, and UTF-16LE. + ** + ** Notes on UTF-8: + ** + ** Byte-0 Byte-1 Byte-2 Byte-3 Value + ** 0xxxxxxx 00000000 00000000 0xxxxxxx + ** 110yyyyy 10xxxxxx 00000000 00000yyy yyxxxxxx + ** 1110zzzz 10yyyyyy 10xxxxxx 00000000 zzzzyyyy yyxxxxxx + ** 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx 000uuuuu zzzzyyyy yyxxxxxx + ** + ** + ** Notes on UTF-16: (with wwww+1==uuuuu) + ** + ** Word-0 Word-1 Value + ** 110110ww wwzzzzyy 110111yy yyxxxxxx 000uuuuu zzzzyyyy yyxxxxxx + ** zzzzyyyy yyxxxxxx 00000000 zzzzyyyy yyxxxxxx + ** + ** + ** BOM or Byte Order Mark: + ** 0xff 0xfe little-endian utf-16 follows + ** 0xfe 0xff big-endian utf-16 follows + ** + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include + //#include "vdbeInt.h" #if !SQLITE_AMALGAMATION - /* -** The following constant value is used by the SQLITE_BIGENDIAN and -** SQLITE_LITTLEENDIAN macros. -*/ - //const int sqlite3one = 1; + /* + ** The following constant value is used by the SQLITE_BIGENDIAN and + ** SQLITE_LITTLEENDIAN macros. + */ + //const int sqlite3one = 1; #endif //* SQLITE_AMALGAMATION */ - /* -** This lookup table is used to help decode the first byte of -** a multi-byte UTF8 character. -*/ - static byte[] sqlite3Utf8Trans1 = new byte[] { + /* + ** This lookup table is used to help decode the first byte of + ** a multi-byte UTF8 character. + */ + static byte[] sqlite3Utf8Trans1 = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, @@ -77,163 +74,159 @@ public partial class Sqlite3 }; - //#define WRITE_UTF8(zOut, c) { \ - // if( c<0x00080 ){ \ - // *zOut++ = (u8)(c&0xFF); \ - // } \ - // else if( c<0x00800 ){ \ - // *zOut++ = 0xC0 + (u8)((c>>6)&0x1F); \ - // *zOut++ = 0x80 + (u8)(c & 0x3F); \ - // } \ - // else if( c<0x10000 ){ \ - // *zOut++ = 0xE0 + (u8)((c>>12)&0x0F); \ - // *zOut++ = 0x80 + (u8)((c>>6) & 0x3F); \ - // *zOut++ = 0x80 + (u8)(c & 0x3F); \ - // }else{ \ - // *zOut++ = 0xF0 + (u8)((c>>18) & 0x07); \ - // *zOut++ = 0x80 + (u8)((c>>12) & 0x3F); \ - // *zOut++ = 0x80 + (u8)((c>>6) & 0x3F); \ - // *zOut++ = 0x80 + (u8)(c & 0x3F); \ - // } \ - //} - - //#define WRITE_UTF16LE(zOut, c) { \ - // if( c<=0xFFFF ){ \ - // *zOut++ = (u8)(c&0x00FF); \ - // *zOut++ = (u8)((c>>8)&0x00FF); \ - // }else{ \ - // *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0)); \ - // *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03)); \ - // *zOut++ = (u8)(c&0x00FF); \ - // *zOut++ = (u8)(0x00DC + ((c>>8)&0x03)); \ - // } \ - //} - - //#define WRITE_UTF16BE(zOut, c) { \ - // if( c<=0xFFFF ){ \ - // *zOut++ = (u8)((c>>8)&0x00FF); \ - // *zOut++ = (u8)(c&0x00FF); \ - // }else{ \ - // *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03)); \ - // *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0)); \ - // *zOut++ = (u8)(0x00DC + ((c>>8)&0x03)); \ - // *zOut++ = (u8)(c&0x00FF); \ - // } \ - //} - - //#define READ_UTF16LE(zIn, TERM, c){ \ - // c = (*zIn++); \ - // c += ((*zIn++)<<8); \ - // if( c>=0xD800 && c<0xE000 && TERM ){ \ - // int c2 = (*zIn++); \ - // c2 += ((*zIn++)<<8); \ - // c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \ - // } \ - //} - - //#define READ_UTF16BE(zIn, TERM, c){ \ - // c = ((*zIn++)<<8); \ - // c += (*zIn++); \ - // if( c>=0xD800 && c<0xE000 && TERM ){ \ - // int c2 = ((*zIn++)<<8); \ - // c2 += (*zIn++); \ - // c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \ - // } \ - //} - - /* - ** Translate a single UTF-8 character. Return the unicode value. - ** - ** During translation, assume that the byte that zTerm points - ** is a 0x00. - ** - ** Write a pointer to the next unread byte back into pzNext. - ** - ** Notes On Invalid UTF-8: - ** - ** * This routine never allows a 7-bit character (0x00 through 0x7f) to - ** be encoded as a multi-byte character. Any multi-byte character that - ** attempts to encode a value between 0x00 and 0x7f is rendered as 0xfffd. - ** - ** * This routine never allows a UTF16 surrogate value to be encoded. - ** If a multi-byte character attempts to encode a value between - ** 0xd800 and 0xe000 then it is rendered as 0xfffd. - ** - ** * Bytes in the range of 0x80 through 0xbf which occur as the first - ** byte of a character are interpreted as single-byte characters - ** and rendered as themselves even though they are technically - ** invalid characters. - ** - ** * This routine accepts an infinite number of different UTF8 encodings - ** for unicode values 0x80 and greater. It do not change over-length - ** encodings to 0xfffd as some systems recommend. - */ - //#define READ_UTF8(zIn, zTerm, c) \ - // c = *(zIn++); \ - // if( c>=0xc0 ){ \ - // c = sqlite3Utf8Trans1[c-0xc0]; \ - // while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){ \ - // c = (c<<6) + (0x3f & *(zIn++)); \ - // } \ - // if( c<0x80 \ - // || (c&0xFFFFF800)==0xD800 \ - // || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \ - // } - static u32 sqlite3Utf8Read( - string zIn, /* First byte of UTF-8 character */ - ref string pzNext /* Write first byte past UTF-8 char here */ - ) - { - //unsigned int c; - /* Same as READ_UTF8() above but without the zTerm parameter. - ** For this routine, we assume the UTF8 string is always zero-terminated. - */ - if ( String.IsNullOrEmpty( zIn ) ) - return 0; - //c = *( zIn++ ); - //if ( c >= 0xc0 ) - //{ - // c = sqlite3Utf8Trans1[c - 0xc0]; - // while ( ( *zIn & 0xc0 ) == 0x80 ) - // { - // c = ( c << 6 ) + ( 0x3f & *( zIn++ ) ); - // } - // if ( c < 0x80 - // || ( c & 0xFFFFF800 ) == 0xD800 - // || ( c & 0xFFFFFFFE ) == 0xFFFE ) { c = 0xFFFD; } - //} - //*pzNext = zIn; - int zIndex = 0; - u32 c = zIn[zIndex++]; - if ( c >= 0xc0 ) - { - //if ( c > 0xff ) c = 0; - //else - { - //c = sqlite3Utf8Trans1[c - 0xc0]; - while ( zIndex != zIn.Length && ( zIn[zIndex] & 0xc0 ) == 0x80 ) - { - c = (u32)( ( c << 6 ) + ( 0x3f & zIn[zIndex++] ) ); - } - if ( c < 0x80 - || ( c & 0xFFFFF800 ) == 0xD800 - || ( c & 0xFFFFFFFE ) == 0xFFFE ) - { - c = 0xFFFD; - } + //#define WRITE_UTF8(zOut, c) { \ + // if( c<0x00080 ){ \ + // *zOut++ = (u8)(c&0xFF); \ + // } \ + // else if( c<0x00800 ){ \ + // *zOut++ = 0xC0 + (u8)((c>>6)&0x1F); \ + // *zOut++ = 0x80 + (u8)(c & 0x3F); \ + // } \ + // else if( c<0x10000 ){ \ + // *zOut++ = 0xE0 + (u8)((c>>12)&0x0F); \ + // *zOut++ = 0x80 + (u8)((c>>6) & 0x3F); \ + // *zOut++ = 0x80 + (u8)(c & 0x3F); \ + // }else{ \ + // *zOut++ = 0xF0 + (u8)((c>>18) & 0x07); \ + // *zOut++ = 0x80 + (u8)((c>>12) & 0x3F); \ + // *zOut++ = 0x80 + (u8)((c>>6) & 0x3F); \ + // *zOut++ = 0x80 + (u8)(c & 0x3F); \ + // } \ + //} + + //#define WRITE_UTF16LE(zOut, c) { \ + // if( c<=0xFFFF ){ \ + // *zOut++ = (u8)(c&0x00FF); \ + // *zOut++ = (u8)((c>>8)&0x00FF); \ + // }else{ \ + // *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0)); \ + // *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03)); \ + // *zOut++ = (u8)(c&0x00FF); \ + // *zOut++ = (u8)(0x00DC + ((c>>8)&0x03)); \ + // } \ + //} + + //#define WRITE_UTF16BE(zOut, c) { \ + // if( c<=0xFFFF ){ \ + // *zOut++ = (u8)((c>>8)&0x00FF); \ + // *zOut++ = (u8)(c&0x00FF); \ + // }else{ \ + // *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03)); \ + // *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0)); \ + // *zOut++ = (u8)(0x00DC + ((c>>8)&0x03)); \ + // *zOut++ = (u8)(c&0x00FF); \ + // } \ + //} + + //#define READ_UTF16LE(zIn, TERM, c){ \ + // c = (*zIn++); \ + // c += ((*zIn++)<<8); \ + // if( c>=0xD800 && c<0xE000 && TERM ){ \ + // int c2 = (*zIn++); \ + // c2 += ((*zIn++)<<8); \ + // c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \ + // } \ + //} + + //#define READ_UTF16BE(zIn, TERM, c){ \ + // c = ((*zIn++)<<8); \ + // c += (*zIn++); \ + // if( c>=0xD800 && c<0xE000 && TERM ){ \ + // int c2 = ((*zIn++)<<8); \ + // c2 += (*zIn++); \ + // c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \ + // } \ + //} + + /* + ** Translate a single UTF-8 character. Return the unicode value. + ** + ** During translation, assume that the byte that zTerm points + ** is a 0x00. + ** + ** Write a pointer to the next unread byte back into pzNext. + ** + ** Notes On Invalid UTF-8: + ** + ** * This routine never allows a 7-bit character (0x00 through 0x7f) to + ** be encoded as a multi-byte character. Any multi-byte character that + ** attempts to encode a value between 0x00 and 0x7f is rendered as 0xfffd. + ** + ** * This routine never allows a UTF16 surrogate value to be encoded. + ** If a multi-byte character attempts to encode a value between + ** 0xd800 and 0xe000 then it is rendered as 0xfffd. + ** + ** * Bytes in the range of 0x80 through 0xbf which occur as the first + ** byte of a character are interpreted as single-byte characters + ** and rendered as themselves even though they are technically + ** invalid characters. + ** + ** * This routine accepts an infinite number of different UTF8 encodings + ** for unicode values 0x80 and greater. It do not change over-length + ** encodings to 0xfffd as some systems recommend. + */ + //#define READ_UTF8(zIn, zTerm, c) \ + // c = *(zIn++); \ + // if( c>=0xc0 ){ \ + // c = sqlite3Utf8Trans1[c-0xc0]; \ + // while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){ \ + // c = (c<<6) + (0x3f & *(zIn++)); \ + // } \ + // if( c<0x80 \ + // || (c&0xFFFFF800)==0xD800 \ + // || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \ + // } + static u32 sqlite3Utf8Read( + string zIn, /* First byte of UTF-8 character */ + ref string pzNext /* Write first byte past UTF-8 char here */ + ) { + //unsigned int c; + /* Same as READ_UTF8() above but without the zTerm parameter. + ** For this routine, we assume the UTF8 string is always zero-terminated. + */ + if (String.IsNullOrEmpty(zIn)) + return 0; + //c = *( zIn++ ); + //if ( c >= 0xc0 ) + //{ + // c = sqlite3Utf8Trans1[c - 0xc0]; + // while ( ( *zIn & 0xc0 ) == 0x80 ) + // { + // c = ( c << 6 ) + ( 0x3f & *( zIn++ ) ); + // } + // if ( c < 0x80 + // || ( c & 0xFFFFF800 ) == 0xD800 + // || ( c & 0xFFFFFFFE ) == 0xFFFE ) { c = 0xFFFD; } + //} + //*pzNext = zIn; + int zIndex = 0; + u32 c = zIn[zIndex++]; + if (c >= 0xc0) { + //if ( c > 0xff ) c = 0; + //else + { + //c = sqlite3Utf8Trans1[c - 0xc0]; + while (zIndex != zIn.Length && (zIn[zIndex] & 0xc0) == 0x80) { + c = (u32)((c << 6) + (0x3f & zIn[zIndex++])); + } + if (c < 0x80 + || (c & 0xFFFFF800) == 0xD800 + || (c & 0xFFFFFFFE) == 0xFFFE) { + c = 0xFFFD; + } + } + } + pzNext = zIn.Substring(zIndex); + return c; } - } - pzNext = zIn.Substring( zIndex ); - return c; - } - /* - ** If the TRANSLATE_TRACE macro is defined, the value of each Mem is - ** printed on stderr on the way into and out of sqlite3VdbeMemTranslate(). - */ - /* #define TRANSLATE_TRACE 1 */ + /* + ** If the TRANSLATE_TRACE macro is defined, the value of each Mem is + ** printed on stderr on the way into and out of sqlite3VdbeMemTranslate(). + */ + /* #define TRANSLATE_TRACE 1 */ #if !SQLITE_OMIT_UTF16 @@ -422,37 +415,36 @@ static int sqlite3VdbeMemHandleBom(Mem pMem){ } #endif // * SQLITE_OMIT_UTF16 */ - /* -** pZ is a UTF-8 encoded unicode string. If nByte is less than zero, -** return the number of unicode characters in pZ up to (but not including) -** the first 0x00 byte. If nByte is not less than zero, return the -** number of unicode characters in the first nByte of pZ (or up to -** the first 0x00, whichever comes first). -*/ - static int sqlite3Utf8CharLen( string zIn, int nByte ) - { - //int r = 0; - //string z = zIn; - if ( zIn.Length == 0 ) - return 0; - int zInLength = zIn.Length; - int zTerm = ( nByte >= 0 && nByte <= zInLength ) ? nByte : zInLength; - //Debug.Assert( z<=zTerm ); - //for ( int i = 0 ; i < zTerm ; i++ ) //while( *z!=0 && z= 0 && nByte <= zInLength) ? nByte : zInLength; + //Debug.Assert( z<=zTerm ); + //for ( int i = 0 ; i < zTerm ; i++ ) //while( *z!=0 && z +namespace Community.CsharpSqlite { + using sqlite_int64 = System.Int64; + + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** Utility functions used throughout sqlite. + ** + ** This file contains functions for allocating memory, comparing + ** strings, and stuff like that. + ** + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include #if SQLITE_HAVE_ISNAN //# include #endif - /* -** Routine needed to support the testcase() macro. -*/ + /* + ** Routine needed to support the testcase() macro. + */ #if SQLITE_COVERAGE_TEST void sqlite3Coverage(int x){ static uint dummy = 0; @@ -60,1264 +54,1108 @@ void sqlite3Coverage(int x){ #endif #if !SQLITE_OMIT_FLOATING_POINT - /* -** Return true if the floating point value is Not a Number (NaN). -** -** Use the math library isnan() function if compiled with SQLITE_HAVE_ISNAN. -** Otherwise, we have our own implementation that works on most systems. -*/ - static bool sqlite3IsNaN( double x ) - { - bool rc; /* The value return */ + /* + ** Return true if the floating point value is Not a Number (NaN). + ** + ** Use the math library isnan() function if compiled with SQLITE_HAVE_ISNAN. + ** Otherwise, we have our own implementation that works on most systems. + */ + static bool sqlite3IsNaN(double x) { + bool rc; /* The value return */ #if !(SQLITE_HAVE_ISNAN) - /* -** Systems that support the isnan() library function should probably -** make use of it by compiling with -DSQLITE_HAVE_ISNAN. But we have -** found that many systems do not have a working isnan() function so -** this implementation is provided as an alternative. -** -** This NaN test sometimes fails if compiled on GCC with -ffast-math. -** On the other hand, the use of -ffast-math comes with the following -** warning: -** -** This option [-ffast-math] should never be turned on by any -** -O option since it can result in incorrect output for programs -** which depend on an exact implementation of IEEE or ISO -** rules/specifications for math functions. -** -** Under MSVC, this NaN test may fail if compiled with a floating- -** point precision mode other than /fp:precise. From the MSDN -** documentation: -** -** The compiler [with /fp:precise] will properly handle comparisons -** involving NaN. For example, x != x evaluates to true if x is NaN -** ... -*/ + /* + ** Systems that support the isnan() library function should probably + ** make use of it by compiling with -DSQLITE_HAVE_ISNAN. But we have + ** found that many systems do not have a working isnan() function so + ** this implementation is provided as an alternative. + ** + ** This NaN test sometimes fails if compiled on GCC with -ffast-math. + ** On the other hand, the use of -ffast-math comes with the following + ** warning: + ** + ** This option [-ffast-math] should never be turned on by any + ** -O option since it can result in incorrect output for programs + ** which depend on an exact implementation of IEEE or ISO + ** rules/specifications for math functions. + ** + ** Under MSVC, this NaN test may fail if compiled with a floating- + ** point precision mode other than /fp:precise. From the MSDN + ** documentation: + ** + ** The compiler [with /fp:precise] will properly handle comparisons + ** involving NaN. For example, x != x evaluates to true if x is NaN + ** ... + */ #if __FAST_MATH__ -# error SQLite will not work correctly with the -ffast-math option of GCC. +#error SQLite will not work correctly with the -ffast-math option of GCC. #endif - double y = x; - double z = y; - rc = ( y != z ); + double y = x; + double z = y; + rc = (y != z); #else //* if defined(SQLITE_HAVE_ISNAN) */ rc = isnan(x); #endif //* SQLITE_HAVE_ISNAN */ - testcase( rc ); - return rc; - } + testcase(rc); + return rc; + } #endif //* SQLITE_OMIT_FLOATING_POINT */ - /* -** Compute a string length that is limited to what can be stored in -** lower 30 bits of a 32-bit signed integer. -** -** The value returned will never be negative. Nor will it ever be greater -** than the actual length of the string. For very long strings (greater -** than 1GiB) the value returned might be less than the true string length. -*/ - static int sqlite3Strlen30( int z ) - { - return 0x3fffffff & z; - } - static int sqlite3Strlen30( StringBuilder z ) - { - //string z2 = z; - if ( z == null ) - return 0; - //while( *z2 ){ z2++; } - //return 0x3fffffff & (int)(z2 - z); - int iLen = z.ToString().IndexOf( '\0' ); - return 0x3fffffff & ( iLen == -1 ? z.Length : iLen ); - } - static int sqlite3Strlen30( string z ) - { - //string z2 = z; - if ( z == null ) - return 0; - //while( *z2 ){ z2++; } - //return 0x3fffffff & (int)(z2 - z); - int iLen = z.IndexOf( '\0' ); - return 0x3fffffff & (iLen == -1 ? z.Length : iLen); - } - - - /* - ** Set the most recent error code and error string for the sqlite - ** handle "db". The error code is set to "err_code". - ** - ** If it is not NULL, string zFormat specifies the format of the - ** error string in the style of the printf functions: The following - ** format characters are allowed: - ** - ** %s Insert a string - ** %z A string that should be freed after use - ** %d Insert an integer - ** %T Insert a token - ** %S Insert the first element of a SrcList + /* + ** Compute a string length that is limited to what can be stored in + ** lower 30 bits of a 32-bit signed integer. ** - ** zFormat and any string tokens that follow it are assumed to be - ** encoded in UTF-8. - ** - ** To clear the most recent error for sqlite handle "db", sqlite3Error - ** should be called with err_code set to SQLITE_OK and zFormat set - ** to NULL. + ** The value returned will never be negative. Nor will it ever be greater + ** than the actual length of the string. For very long strings (greater + ** than 1GiB) the value returned might be less than the true string length. */ - //Overloads - static void sqlite3Error( sqlite3 db, int err_code, int noString ) - { - sqlite3Error( db, err_code, err_code == 0 ? null : "" ); - } - - static void sqlite3Error( sqlite3 db, int err_code, string zFormat, params object[] ap ) - { - if ( db != null && ( db.pErr != null || ( db.pErr = sqlite3ValueNew( db ) ) != null ) ) - { - db.errCode = err_code; - if ( zFormat != null ) - { - lock ( lock_va_list ) - { - string z; - va_start( ap, zFormat ); - z = sqlite3VMPrintf( db, zFormat, ap ); - va_end( ref ap ); - sqlite3ValueSetStr( db.pErr, -1, z, SQLITE_UTF8, (dxDel)SQLITE_DYNAMIC ); - } + static int sqlite3Strlen30(int z) { + return 0x3fffffff & z; } - else - { - sqlite3ValueSetStr( db.pErr, 0, null, SQLITE_UTF8, SQLITE_STATIC ); + static int sqlite3Strlen30(StringBuilder z) { + //string z2 = z; + if (z == null) + return 0; + //while( *z2 ){ z2++; } + //return 0x3fffffff & (int)(z2 - z); + int iLen = z.ToString().IndexOf('\0'); + return 0x3fffffff & (iLen == -1 ? z.Length : iLen); + } + static int sqlite3Strlen30(string z) { + //string z2 = z; + if (z == null) + return 0; + //while( *z2 ){ z2++; } + //return 0x3fffffff & (int)(z2 - z); + int iLen = z.IndexOf('\0'); + return 0x3fffffff & (iLen == -1 ? z.Length : iLen); } - } - } - /* - ** Add an error message to pParse.zErrMsg and increment pParse.nErr. - ** The following formatting characters are allowed: - ** - ** %s Insert a string - ** %z A string that should be freed after use - ** %d Insert an integer - ** %T Insert a token - ** %S Insert the first element of a SrcList - ** - ** This function should be used to report any error that occurs whilst - ** compiling an SQL statement (i.e. within sqlite3_prepare()). The - ** last thing the sqlite3_prepare() function does is copy the error - ** stored by this function into the database handle using sqlite3Error(). - ** Function sqlite3Error() should be used during statement execution - ** (sqlite3_step() etc.). - */ - static void sqlite3ErrorMsg( Parse pParse, string zFormat, params object[] ap ) - { - string zMsg; - sqlite3 db = pParse.db; - //va_list ap; - lock ( lock_va_list ) - { - va_start( ap, zFormat ); - zMsg = sqlite3VMPrintf( db, zFormat, ap ); - va_end( ref ap ); - } - if ( db.suppressErr != 0 ) - { - sqlite3DbFree( db, ref zMsg ); - } - else - { - pParse.nErr++; - sqlite3DbFree( db, ref pParse.zErrMsg ); - pParse.zErrMsg = zMsg; - pParse.rc = SQLITE_ERROR; - } - } - /* - ** Convert an SQL-style quoted string into a normal string by removing - ** the quote characters. The conversion is done in-place. If the - ** input does not begin with a quote character, then this routine - ** is a no-op. - ** - ** The input string must be zero-terminated. A new zero-terminator - ** is added to the dequoted string. - ** - ** The return value is -1 if no dequoting occurs or the length of the - ** dequoted string, exclusive of the zero terminator, if dequoting does - ** occur. - ** - ** 2002-Feb-14: This routine is extended to remove MS-Access style - ** brackets from around identifers. For example: "[a-b-c]" becomes - ** "a-b-c". - */ - static int sqlite3Dequote( ref string z ) - { - char quote; - int i; - if ( z == null || z == "" ) - return -1; - quote = z[0]; - switch ( quote ) - { - case '\'': - break; - case '"': - break; - case '`': - break; /* For MySQL compatibility */ - case '[': - quote = ']'; - break; /* For MS SqlServer compatibility */ - default: - return -1; - } - StringBuilder sbZ = new StringBuilder( z.Length ); - for ( i = 1; i < z.Length; i++ ) //z[i] != 0; i++) - { - if ( z[i] == quote ) - { - if ( i < z.Length - 1 && ( z[i + 1] == quote ) ) - { - sbZ.Append( quote ); - i++; - } - else - { - break; - } + /* + ** Set the most recent error code and error string for the sqlite + ** handle "db". The error code is set to "err_code". + ** + ** If it is not NULL, string zFormat specifies the format of the + ** error string in the style of the printf functions: The following + ** format characters are allowed: + ** + ** %s Insert a string + ** %z A string that should be freed after use + ** %d Insert an integer + ** %T Insert a token + ** %S Insert the first element of a SrcList + ** + ** zFormat and any string tokens that follow it are assumed to be + ** encoded in UTF-8. + ** + ** To clear the most recent error for sqlite handle "db", sqlite3Error + ** should be called with err_code set to SQLITE_OK and zFormat set + ** to NULL. + */ + //Overloads + static void sqlite3Error(sqlite3 db, int err_code, int noString) { + sqlite3Error(db, err_code, err_code == 0 ? null : ""); } - else - { - sbZ.Append( z[i] ); + + static void sqlite3Error(sqlite3 db, int err_code, string zFormat, params object[] ap) { + if (db != null && (db.pErr != null || (db.pErr = sqlite3ValueNew(db)) != null)) { + db.errCode = err_code; + if (zFormat != null) { + lock (lock_va_list) { + string z; + va_start(ap, zFormat); + z = sqlite3VMPrintf(db, zFormat, ap); + va_end(ref ap); + sqlite3ValueSetStr(db.pErr, -1, z, SQLITE_UTF8, (dxDel)SQLITE_DYNAMIC); + } + } else { + sqlite3ValueSetStr(db.pErr, 0, null, SQLITE_UTF8, SQLITE_STATIC); + } + } } - } - z = sbZ.ToString(); - return sbZ.Length; - } - /* Convenient short-hand */ - //#define UpperToLower sqlite3UpperToLower + /* + ** Add an error message to pParse.zErrMsg and increment pParse.nErr. + ** The following formatting characters are allowed: + ** + ** %s Insert a string + ** %z A string that should be freed after use + ** %d Insert an integer + ** %T Insert a token + ** %S Insert the first element of a SrcList + ** + ** This function should be used to report any error that occurs whilst + ** compiling an SQL statement (i.e. within sqlite3_prepare()). The + ** last thing the sqlite3_prepare() function does is copy the error + ** stored by this function into the database handle using sqlite3Error(). + ** Function sqlite3Error() should be used during statement execution + ** (sqlite3_step() etc.). + */ + static void sqlite3ErrorMsg(Parse pParse, string zFormat, params object[] ap) { + string zMsg; + sqlite3 db = pParse.db; + //va_list ap; + lock (lock_va_list) { + va_start(ap, zFormat); + zMsg = sqlite3VMPrintf(db, zFormat, ap); + va_end(ref ap); + } + if (db.suppressErr != 0) { + sqlite3DbFree(db, ref zMsg); + } else { + pParse.nErr++; + sqlite3DbFree(db, ref pParse.zErrMsg); + pParse.zErrMsg = zMsg; + pParse.rc = SQLITE_ERROR; + } + } - /* - ** Some systems have stricmp(). Others have strcasecmp(). Because - ** there is no consistency, we will define our own. - ** - ** IMPLEMENTATION-OF: R-20522-24639 The sqlite3_strnicmp() API allows - ** applications and extensions to compare the contents of two buffers - ** containing UTF-8 strings in a case-independent fashion, using the same - ** definition of case independence that SQLite uses internally when - ** comparing identifiers. - */ + /* + ** Convert an SQL-style quoted string into a normal string by removing + ** the quote characters. The conversion is done in-place. If the + ** input does not begin with a quote character, then this routine + ** is a no-op. + ** + ** The input string must be zero-terminated. A new zero-terminator + ** is added to the dequoted string. + ** + ** The return value is -1 if no dequoting occurs or the length of the + ** dequoted string, exclusive of the zero terminator, if dequoting does + ** occur. + ** + ** 2002-Feb-14: This routine is extended to remove MS-Access style + ** brackets from around identifers. For example: "[a-b-c]" becomes + ** "a-b-c". + */ + static int sqlite3Dequote(ref string z) { + char quote; + int i; + if (z == null || z == "") + return -1; + quote = z[0]; + switch (quote) { + case '\'': + break; + case '"': + break; + case '`': + break; /* For MySQL compatibility */ + case '[': + quote = ']'; + break; /* For MS SqlServer compatibility */ + default: + return -1; + } + StringBuilder sbZ = new StringBuilder(z.Length); + for (i = 1; i < z.Length; i++) //z[i] != 0; i++) + { + if (z[i] == quote) { + if (i < z.Length - 1 && (z[i + 1] == quote)) { + sbZ.Append(quote); + i++; + } else { + break; + } + } else { + sbZ.Append(z[i]); + } + } + z = sbZ.ToString(); + return sbZ.Length; + } - static int sqlite3StrNICmp( string zLeft, int offsetLeft, string zRight, int N ) - { - //register unsigned char *a, *b; - //a = (unsigned char )zLeft; - //b = (unsigned char )zRight; - int a = 0, b = 0; - while ( N-- > 0 && a < zLeft.Length - offsetLeft && b < zRight.Length && zLeft[a + offsetLeft] != 0 && UpperToLower[zLeft[a + offsetLeft]] == UpperToLower[zRight[b]] ) - { - a++; - b++; - } - return N < 0 ? 0 : ( ( a < zLeft.Length - offsetLeft ) ? UpperToLower[zLeft[a + offsetLeft]] : 0 ) - UpperToLower[zRight[b]]; - } + /* Convenient short-hand */ + //#define UpperToLower sqlite3UpperToLower + + /* + ** Some systems have stricmp(). Others have strcasecmp(). Because + ** there is no consistency, we will define our own. + ** + ** IMPLEMENTATION-OF: R-20522-24639 The sqlite3_strnicmp() API allows + ** applications and extensions to compare the contents of two buffers + ** containing UTF-8 strings in a case-independent fashion, using the same + ** definition of case independence that SQLite uses internally when + ** comparing identifiers. + */ + + static int sqlite3StrNICmp(string zLeft, int offsetLeft, string zRight, int N) { + //register unsigned char *a, *b; + //a = (unsigned char )zLeft; + //b = (unsigned char )zRight; + int a = 0, b = 0; + while (N-- > 0 && a < zLeft.Length - offsetLeft && b < zRight.Length && zLeft[a + offsetLeft] != 0 && UpperToLower[zLeft[a + offsetLeft]] == UpperToLower[zRight[b]]) { + a++; + b++; + } + return N < 0 ? 0 : ((a < zLeft.Length - offsetLeft) ? UpperToLower[zLeft[a + offsetLeft]] : 0) - UpperToLower[zRight[b]]; + } - static int sqlite3StrNICmp( string zLeft, string zRight, int N ) - { - //register unsigned char *a, *b; - //a = (unsigned char )zLeft; - //b = (unsigned char )zRight; - int a = 0, b = 0; - while ( N-- > 0 && a < zLeft.Length && b < zRight.Length && ( zLeft[a] == zRight[b] || ( zLeft[a] != 0 && zLeft[a] < 256 && zRight[b] < 256 && UpperToLower[zLeft[a]] == UpperToLower[zRight[b]] ) ) ) - { - a++; - b++; - } - if ( N < 0 ) - return 0; - if ( a == zLeft.Length && b == zRight.Length ) - return 0; - if ( a == zLeft.Length ) - return -UpperToLower[zRight[b]]; - if ( b == zRight.Length ) - return UpperToLower[zLeft[a]]; - return ( zLeft[a] < 256 ? UpperToLower[zLeft[a]] : zLeft[a] ) - ( zRight[b] < 256 ? UpperToLower[zRight[b]] : zRight[b] ); - } + static int sqlite3StrNICmp(string zLeft, string zRight, int N) { + //register unsigned char *a, *b; + //a = (unsigned char )zLeft; + //b = (unsigned char )zRight; + int a = 0, b = 0; + while (N-- > 0 && a < zLeft.Length && b < zRight.Length && (zLeft[a] == zRight[b] || (zLeft[a] != 0 && zLeft[a] < 256 && zRight[b] < 256 && UpperToLower[zLeft[a]] == UpperToLower[zRight[b]]))) { + a++; + b++; + } + if (N < 0) + return 0; + if (a == zLeft.Length && b == zRight.Length) + return 0; + if (a == zLeft.Length) + return -UpperToLower[zRight[b]]; + if (b == zRight.Length) + return UpperToLower[zLeft[a]]; + return (zLeft[a] < 256 ? UpperToLower[zLeft[a]] : zLeft[a]) - (zRight[b] < 256 ? UpperToLower[zRight[b]] : zRight[b]); + } - /* - ** The string z[] is an text representation of a real number. - ** Convert this string to a double and write it into *pResult. - ** - ** The string z[] is length bytes in length (bytes, not characters) and - ** uses the encoding enc. 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 bool sqlite3AtoF( string z, ref double pResult, int length, u8 enc ) - { + /* + ** The string z[] is an text representation of a real number. + ** Convert this string to a double and write it into *pResult. + ** + ** The string z[] is length bytes in length (bytes, not characters) and + ** uses the encoding enc. 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 bool sqlite3AtoF(string z, ref double pResult, int length, u8 enc) { #if !SQLITE_OMIT_FLOATING_POINT - if ( String.IsNullOrEmpty( z ) ) - { - pResult = 0; - return false; - } - int incr = ( enc == SQLITE_UTF8 ? 1 : 2 ); - //const char* zEnd = z + length; - - /* sign * significand * (10 ^ (esign * exponent)) */ - int sign = 1; /* sign of significand */ - i64 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 = 0; - int nDigits = 0; - - pResult = 0.0; /* Default return value, in case of an error */ - - int zDx = 0; - if ( enc == SQLITE_UTF16BE ) - zDx++; - - while ( zDx < length && sqlite3Isspace( z[zDx] ) ) - zDx++; - if ( zDx >= length ) - return false; - - /* get sign of significand */ - if ( z[zDx] == '-' ) - { - sign = -1; - zDx += incr; - } - else if ( z[zDx] == '+' ) - { - zDx += incr; - } - /* skip leading zeroes */ - while ( zDx < z.Length && z[zDx] == '0' ) - { - zDx += incr; - nDigits++; - } - /* copy max significant digits to significand */ - while ( zDx < length && sqlite3Isdigit( z[zDx] ) && s < ( ( LARGEST_INT64 - 9 ) / 10 ) ) - { - s = s * 10 + ( z[zDx] - '0' ); - zDx += incr; - nDigits++; - } - /* skip non-significant significand digits - ** (increase exponent by d to shift decimal left) */ - while ( zDx < length && sqlite3Isdigit( z[zDx] ) ) - { - zDx += incr; - nDigits++; - d++; - } - if ( zDx >= length ) - goto do_atof_calc; - - /* if decimal point is present */ - if ( z[zDx] == '.' ) - { - zDx += incr; - /* copy digits from after decimal to significand - ** (decrease exponent by d to shift decimal right) */ - while ( zDx < length && sqlite3Isdigit( z[zDx] ) && s < ( ( LARGEST_INT64 - 9 ) / 10 ) ) - { - s = s * 10 + ( z[zDx] - '0' ); - zDx += incr; - nDigits++; - d--; - } + if (String.IsNullOrEmpty(z)) { + pResult = 0; + return false; + } + int incr = (enc == SQLITE_UTF8 ? 1 : 2); + //const char* zEnd = z + length; + + /* sign * significand * (10 ^ (esign * exponent)) */ + int sign = 1; /* sign of significand */ + i64 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 = 0; + int nDigits = 0; + + pResult = 0.0; /* Default return value, in case of an error */ + + int zDx = 0; + if (enc == SQLITE_UTF16BE) + zDx++; + + while (zDx < length && sqlite3Isspace(z[zDx])) + zDx++; + if (zDx >= length) + return false; + + /* get sign of significand */ + if (z[zDx] == '-') { + sign = -1; + zDx += incr; + } else if (z[zDx] == '+') { + zDx += incr; + } + /* skip leading zeroes */ + while (zDx < z.Length && z[zDx] == '0') { + zDx += incr; + nDigits++; + } + /* copy max significant digits to significand */ + while (zDx < length && sqlite3Isdigit(z[zDx]) && s < ((LARGEST_INT64 - 9) / 10)) { + s = s * 10 + (z[zDx] - '0'); + zDx += incr; + nDigits++; + } + /* skip non-significant significand digits + ** (increase exponent by d to shift decimal left) */ + while (zDx < length && sqlite3Isdigit(z[zDx])) { + zDx += incr; + nDigits++; + d++; + } + if (zDx >= length) + goto do_atof_calc; + + /* if decimal point is present */ + if (z[zDx] == '.') { + zDx += incr; + /* copy digits from after decimal to significand + ** (decrease exponent by d to shift decimal right) */ + while (zDx < length && sqlite3Isdigit(z[zDx]) && s < ((LARGEST_INT64 - 9) / 10)) { + s = s * 10 + (z[zDx] - '0'); + zDx += incr; + nDigits++; + d--; + } + + /* skip non-significant digits */ + while (zDx < length && sqlite3Isdigit(z[zDx])) { + zDx += incr; + nDigits++; + } + if (zDx >= length) + goto do_atof_calc; + } - /* skip non-significant digits */ - while ( zDx < length && sqlite3Isdigit( z[zDx] ) ) - { - zDx += incr; - nDigits++; - } - if ( zDx >= length ) - goto do_atof_calc; - } - - /* if exponent is present */ - if ( z[zDx] == 'e' || z[zDx] == 'E' ) - { - zDx += incr; - eValid = 0; - if ( zDx >= length ) - goto do_atof_calc; - - /* get sign of exponent */ - if ( z[zDx] == '-' ) - { - esign = -1; - zDx += incr; - } - else if ( z[zDx] == '+' ) - { - zDx += incr; - } + /* if exponent is present */ + if (z[zDx] == 'e' || z[zDx] == 'E') { + zDx += incr; + eValid = 0; + if (zDx >= length) + goto do_atof_calc; + + /* get sign of exponent */ + if (z[zDx] == '-') { + esign = -1; + zDx += incr; + } else if (z[zDx] == '+') { + zDx += incr; + } + + /* copy digits to exponent */ + while (zDx < length && sqlite3Isdigit(z[zDx])) { + e = e * 10 + (z[zDx] - '0'); + zDx += incr; + eValid = 1; + } + } - /* copy digits to exponent */ - while ( zDx < length && sqlite3Isdigit( z[zDx] ) ) - { - e = e * 10 + ( z[zDx] - '0' ); - zDx += incr; - eValid = 1; - } - } - - /* skip trailing spaces */ - if ( nDigits > 0 && eValid > 0 ) - { - while ( zDx < length && sqlite3Isspace( z[zDx] ) ) - zDx += incr; - } - -do_atof_calc: - - /* adjust exponent by d, and update sign */ - e = ( e * esign ) + d; - if ( e < 0 ) - { - esign = -1; - e *= -1; - } - else - { - esign = 1; - } - - /* if 0 significand */ - if ( 0 == s ) - { - /* In the IEEE 754 standard, zero is signed. - ** Add the sign if we've seen at least one digit */ - result = ( sign < 0 && nDigits != 0 ) ? -(double)0 : (double)0; - } - else - { - /* attempt to reduce exponent */ - if ( esign > 0 ) - { - while ( s < ( LARGEST_INT64 / 10 ) && e > 0 ) - { - e--; - s *= 10; - } - } - else - { - while ( 0 == ( s % 10 ) && e > 0 ) - { - e--; - s /= 10; - } + /* skip trailing spaces */ + if (nDigits > 0 && eValid > 0) { + while (zDx < length && sqlite3Isspace(z[zDx])) + zDx += incr; + } + + do_atof_calc: + + /* adjust exponent by d, and update sign */ + e = (e * esign) + d; + if (e < 0) { + esign = -1; + e *= -1; + } else { + esign = 1; + } + + /* if 0 significand */ + if (0 == s) { + /* In the IEEE 754 standard, zero is signed. + ** Add the sign if we've seen at least one digit */ + result = (sign < 0 && nDigits != 0) ? -(double)0 : (double)0; + } else { + /* attempt to reduce exponent */ + if (esign > 0) { + while (s < (LARGEST_INT64 / 10) && e > 0) { + e--; + s *= 10; + } + } else { + while (0 == (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 != 0) { + double scale = 1.0; + /* attempt to handle extremely small/large numbers better */ + if (e > 307 && e < 342) { + while ((e % 308) != 0) { + 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 { + /* 1.0e+22 is the largest power of 10 than can be + ** represented exactly. */ + while ((e % 22) != 0) { + 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 zDx >= length && nDigits > 0 && eValid != 0; +#else +return !sqlite3Atoi64(z, pResult, length, enc); +#endif //* SQLITE_OMIT_FLOATING_POINT */ } - /* adjust the sign of significand */ - s = sign < 0 ? -s : s; - - /* if exponent, scale significand as appropriate - ** and store in result. */ - if ( e != 0 ) - { - double scale = 1.0; - /* attempt to handle extremely small/large numbers better */ - if ( e > 307 && e < 342 ) - { - while ( ( e % 308 ) != 0 ) - { - scale *= 1.0e+1; - e -= 1; + /* + ** 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, + ** + ** compare2pow63("9223372036854775800", 1) + ** + ** will return -8. + */ + static int compare2pow63(string zNum, int incr) { + int c = 0; + int i; + /* 012345678901234567 */ + string pow63 = "922337203685477580"; + for (i = 0; c == 0 && i < 18; i++) { + c = (zNum[i * incr] - pow63[i]) * 10; } - if ( esign < 0 ) - { - result = s / scale; - result /= 1.0e+308; + + if (c == 0) { + c = zNum[18 * incr] - '8'; + testcase(c == (-1)); + testcase(c == 0); + testcase(c == (+1)); } - else - { - result = s * scale; - result *= 1.0e+308; + 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 then return 1. + ** + ** length is the number of bytes in the string (bytes, not characters). + ** The string is not necessarily zero-terminated. The encoding is + ** given by enc. + */ + static int sqlite3Atoi64(string zNum, ref i64 pNum, int length, u8 enc) { + if (zNum == null) { + pNum = 0; + return 1; } - } - else - { - /* 1.0e+22 is the largest power of 10 than can be - ** represented exactly. */ - while ( ( e % 22 ) != 0 ) - { - scale *= 1.0e+1; - e -= 1; + int incr = (enc == SQLITE_UTF8 ? 1 : 2); + u64 u = 0; + int neg = 0; /* assume positive */ + int i; + int c = 0; + int zDx = 0;// string zStart; + //string zEnd = zNum + length; + + if (enc == SQLITE_UTF16BE) + zDx++; + while (zDx < length && sqlite3Isspace(zNum[zDx])) + zDx += incr; + if (zDx < length) { + if (zNum[zDx] == '-') { + neg = 1; + zDx += incr; + } else if (zNum[zDx] == '+') { + zDx += incr; + } } - while ( e > 0 ) - { - scale *= 1.0e+22; - e -= 22; + //zStart = zNum; + if (length > zNum.Length) + length = zNum.Length; + while (zDx < length - 1 && zNum[zDx] == '0') { + zDx += incr; + } /* Skip leading zeros. */ + for (i = zDx; i < length && (c = zNum[i]) >= '0' && c <= '9'; i += incr) { + u = u * 10 + (u64)(c - '0'); } - if ( esign < 0 ) - { - result = s / scale; + if (u > LARGEST_INT64) { + pNum = SMALLEST_INT64; + } else if (neg != 0) { + pNum = -(i64)u; + } else { + pNum = (i64)u; } - else - { - result = s * scale; + testcase(i - zDx == 18); + testcase(i - zDx == 19); + testcase(i - zDx == 20); + if ((c != 0 && i < length) || i == zDx || i - zDx > 19 * incr) { + /* 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 - zDx < 19 * incr) { + /* Less than 19 digits, so we know that it fits in 64 bits */ + Debug.Assert(u <= LARGEST_INT64); + return 0; + } else { + /* zNum is a 19-digit numbers. Compare it against 9223372036854775808. */ + c = compare2pow63(zNum.Substring(zDx), incr); + if (c < 0) { + /* zNum is less than 9223372036854775808 so it fits */ + Debug.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 */ + Debug.Assert(u - 1 == LARGEST_INT64); + Debug.Assert((pNum) == SMALLEST_INT64); + return neg != 0 ? 0 : 2; + } } - } - } - else - { - result = (double)s; } - } - /* store the result */ - pResult = result; - /* return true if number and no extra non-whitespace chracters after */ - return zDx >= length && nDigits > 0 && eValid != 0; -#else -return !sqlite3Atoi64(z, pResult, length, enc); -#endif //* SQLITE_OMIT_FLOATING_POINT */ - } + /* + ** If zNum represents an integer that will fit in 32-bits, then set + ** pValue to that integer and return true. Otherwise return false. + ** + ** Any non-numeric characters that following zNum are ignored. + ** This is different from sqlite3Atoi64() which requires the + ** input number to be zero-terminated. + */ + static bool sqlite3GetInt32(string zNum, ref int pValue) { + return sqlite3GetInt32(zNum, 0, ref pValue); + } + static bool sqlite3GetInt32(string zNum, int iZnum, ref int pValue) { + sqlite_int64 v = 0; + int i, c; + int neg = 0; + if (zNum[iZnum] == '-') { + neg = 1; + iZnum++; + } else if (zNum[iZnum] == '+') { + iZnum++; + } + while (iZnum < zNum.Length && zNum[iZnum] == '0') + iZnum++; + for (i = 0; i < 11 && i + iZnum < zNum.Length && (c = zNum[iZnum + i] - '0') >= 0 && c <= 9; i++) { + v = v * 10 + c; + } - /* - ** 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, - ** - ** compare2pow63("9223372036854775800", 1) - ** - ** will return -8. - */ - static int compare2pow63( string zNum, int incr ) - { - int c = 0; - int i; - /* 012345678901234567 */ - string pow63 = "922337203685477580"; - for ( i = 0; c == 0 && i < 18; i++ ) - { - c = ( zNum[i * incr] - pow63[i] ) * 10; - } - - if ( c == 0 ) - { - c = zNum[18 * incr] - '8'; - testcase( c == ( -1 ) ); - testcase( c == 0 ); - testcase( c == ( +1 ) ); - } - return c; - } + /* The longest decimal representation of a 32 bit integer is 10 digits: + ** + ** 1234567890 + ** 2^31 . 2147483648 + */ + testcase(i == 10); + if (i > 10) { + return false; + } + testcase(v - neg == 2147483647); + if (v - neg > 2147483647) { + return false; + } + if (neg != 0) { + v = -v; + } + pValue = (int)v; + return true; + } + /* + ** Return a 32-bit integer value extracted from a string. If the + ** string is not an integer, just return 0. + */ + static int sqlite3Atoi(string z) { + int x = 0; + if (!String.IsNullOrEmpty(z)) + sqlite3GetInt32(z, ref x); + return x; + } - /* - ** 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 then return 1. - ** - ** length is the number of bytes in the string (bytes, not characters). - ** The string is not necessarily zero-terminated. The encoding is - ** given by enc. - */ - static int sqlite3Atoi64( string zNum, ref i64 pNum, int length, u8 enc ) - { - if ( zNum == null ) - { - pNum = 0; - return 1; - } - int incr = ( enc == SQLITE_UTF8 ? 1 : 2 ); - u64 u = 0; - int neg = 0; /* assume positive */ - int i; - int c = 0; - int zDx = 0;// string zStart; - //string zEnd = zNum + length; - - if ( enc == SQLITE_UTF16BE ) - zDx++; - while ( zDx < length && sqlite3Isspace( zNum[zDx] ) ) - zDx += incr; - if ( zDx < length ) - { - if ( zNum[zDx] == '-' ) - { - neg = 1; - zDx += incr; + /* + ** The variable-length integer encoding is as follows: + ** + ** KEY: + ** A = 0xxxxxxx 7 bits of data and one flag bit + ** B = 1xxxxxxx 7 bits of data and one flag bit + ** C = xxxxxxxx 8 bits of data + ** + ** 7 bits - A + ** 14 bits - BA + ** 21 bits - BBA + ** 28 bits - BBBA + ** 35 bits - BBBBA + ** 42 bits - BBBBBA + ** 49 bits - BBBBBBA + ** 56 bits - BBBBBBBA + ** 64 bits - BBBBBBBBC + */ + + /* + ** Write a 64-bit variable-length integer to memory starting at p[0]. + ** The length of data write will be between 1 and 9 bytes. The number + ** of bytes written is returned. + ** + ** A variable-length integer consists of the lower 7 bits of each byte + ** for all bytes that have the 8th bit set and one byte with the 8th + ** bit clear. Except, if we get to the 9th byte, it stores the full + ** 8 bits and is the last byte. + */ + static int getVarint(byte[] p, out u32 v) { + v = p[0]; + if (v <= 0x7F) + return 1; + u64 u64_v = 0; + int result = sqlite3GetVarint(p, 0, out u64_v); + v = (u32)u64_v; + return result; } - else if ( zNum[zDx] == '+' ) - { - zDx += incr; + static int getVarint(byte[] p, int offset, out u32 v) { + v = p[offset + 0]; + if (v <= 0x7F) + return 1; + u64 u64_v = 0; + int result = sqlite3GetVarint(p, offset, out u64_v); + v = (u32)u64_v; + return result; } - } - //zStart = zNum; - if ( length > zNum.Length ) - length = zNum.Length; - while ( zDx < length - 1 && zNum[zDx] == '0' ) - { - zDx += incr; - } /* Skip leading zeros. */ - for ( i = zDx; i < length && ( c = zNum[i] ) >= '0' && c <= '9'; i += incr ) - { - u = u * 10 + (u64)(c - '0'); - } - if ( u > LARGEST_INT64 ) - { - pNum = SMALLEST_INT64; - } - else if ( neg != 0) - { - pNum = -(i64)u; - } - else - { - pNum = (i64)u; - } - testcase( i - zDx == 18 ); - testcase( i - zDx == 19 ); - testcase( i - zDx == 20 ); - if ( ( c != 0 && i < length ) || i == zDx || i - zDx > 19 * incr ) - { - /* 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 - zDx < 19 * incr ) - { - /* Less than 19 digits, so we know that it fits in 64 bits */ - Debug.Assert( u <= LARGEST_INT64 ); - return 0; - } - else - { - /* zNum is a 19-digit numbers. Compare it against 9223372036854775808. */ - c = compare2pow63( zNum.Substring(zDx), incr ); - if ( c < 0 ) - { - /* zNum is less than 9223372036854775808 so it fits */ - Debug.Assert( u <= LARGEST_INT64 ); - return 0; + static int getVarint(byte[] p, int offset, out int v) { + v = p[offset + 0]; + if (v <= 0x7F) + return 1; + u64 u64_v = 0; + int result = sqlite3GetVarint(p, offset, out u64_v); + v = (int)u64_v; + return result; } - else if ( c > 0 ) - { - /* zNum is greater than 9223372036854775808 so it overflows */ - return 1; + static int getVarint(byte[] p, int offset, out i64 v) { + v = offset >= p.Length ? 0 : (int)p[offset + 0]; + if (v <= 0x7F) + return 1; + if (offset + 1 >= p.Length) { + v = 65535; + return 2; + } else { + u64 u64_v = 0; + int result = sqlite3GetVarint(p, offset, out u64_v); + v = (i64)u64_v; + return result; + } } - else - { - /* zNum is exactly 9223372036854775808. Fits if negative. The - ** special case 2 overflow if positive */ - Debug.Assert( u - 1 == LARGEST_INT64 ); - Debug.Assert( ( pNum ) == SMALLEST_INT64 ); - return neg != 0 ? 0 : 2; + static int getVarint(byte[] p, int offset, out u64 v) { + v = p[offset + 0]; + if (v <= 0x7F) + return 1; + int result = sqlite3GetVarint(p, offset, out v); + return result; + } + static int getVarint32(byte[] p, out u32 v) { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) + v = p[0]; + if (v <= 0x7F) + return 1; + return sqlite3GetVarint32(p, 0, out v); + } + static byte[] pByte4 = new byte[4]; + static int getVarint32(string s, u32 offset, out int v) { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) + v = s[(int)offset]; + if (v <= 0x7F) + return 1; + pByte4[0] = (u8)s[(int)offset + 0]; + pByte4[1] = (u8)s[(int)offset + 1]; + pByte4[2] = (u8)s[(int)offset + 2]; + pByte4[3] = (u8)s[(int)offset + 3]; + u32 u32_v = 0; + int result = sqlite3GetVarint32(pByte4, 0, out u32_v); + v = (int)u32_v; + return sqlite3GetVarint32(pByte4, 0, out v); + } + static int getVarint32(string s, u32 offset, out u32 v) { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) + v = s[(int)offset]; + if (v <= 0x7F) + return 1; + pByte4[0] = (u8)s[(int)offset + 0]; + pByte4[1] = (u8)s[(int)offset + 1]; + pByte4[2] = (u8)s[(int)offset + 2]; + pByte4[3] = (u8)s[(int)offset + 3]; + return sqlite3GetVarint32(pByte4, 0, out v); + } + static int getVarint32(byte[] p, u32 offset, out u32 v) { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) + v = p[offset]; + if (v <= 0x7F) + return 1; + return sqlite3GetVarint32(p, (int)offset, out v); + } + static int getVarint32(byte[] p, int offset, out u32 v) { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) + v = offset >= p.Length ? 0 : (u32)p[offset]; + if (v <= 0x7F) + return 1; + return sqlite3GetVarint32(p, offset, out v); + } + static int getVarint32(byte[] p, int offset, out int v) { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) + v = p[offset + 0]; + if (v <= 0x7F) + return 1; + u32 u32_v = 0; + int result = sqlite3GetVarint32(p, offset, out u32_v); + v = (int)u32_v; + return result; + } + static int putVarint(byte[] p, int offset, int v) { + return putVarint(p, offset, (u64)v); + } + static int putVarint(byte[] p, int offset, u64 v) { + return sqlite3PutVarint(p, offset, v); + } + static int sqlite3PutVarint(byte[] p, int offset, int v) { + return sqlite3PutVarint(p, offset, (u64)v); + } + static u8[] bufByte10 = new u8[10]; + static int sqlite3PutVarint(byte[] p, int offset, u64 v) { + int i, j, n; + if ((v & (((u64)0xff000000) << 32)) != 0) { + p[offset + 8] = (byte)v; + v >>= 8; + for (i = 7; i >= 0; i--) { + p[offset + i] = (byte)((v & 0x7f) | 0x80); + v >>= 7; + } + return 9; + } + n = 0; + do { + bufByte10[n++] = (byte)((v & 0x7f) | 0x80); + v >>= 7; + } while (v != 0); + bufByte10[0] &= 0x7f; + Debug.Assert(n <= 9); + for (i = 0, j = n - 1; j >= 0; j--, i++) { + p[offset + i] = bufByte10[j]; + } + return n; } - } - } - /* - ** If zNum represents an integer that will fit in 32-bits, then set - ** pValue to that integer and return true. Otherwise return false. - ** - ** Any non-numeric characters that following zNum are ignored. - ** This is different from sqlite3Atoi64() which requires the - ** input number to be zero-terminated. - */ - static bool sqlite3GetInt32( string zNum, ref int pValue ) - { - return sqlite3GetInt32( zNum, 0, ref pValue ); - } - static bool sqlite3GetInt32( string zNum, int iZnum, ref int pValue ) - { - sqlite_int64 v = 0; - int i, c; - int neg = 0; - if ( zNum[iZnum] == '-' ) - { - neg = 1; - iZnum++; - } - else if ( zNum[iZnum] == '+' ) - { - iZnum++; - } - while ( iZnum < zNum.Length && zNum[iZnum] == '0' ) - iZnum++; - for ( i = 0; i < 11 && i + iZnum < zNum.Length && ( c = zNum[iZnum + i] - '0' ) >= 0 && c <= 9; i++ ) - { - v = v * 10 + c; - } - - /* The longest decimal representation of a 32 bit integer is 10 digits: - ** - ** 1234567890 - ** 2^31 . 2147483648 - */ - testcase( i == 10 ); - if ( i > 10 ) - { - return false; - } - testcase( v - neg == 2147483647 ); - if ( v - neg > 2147483647 ) - { - return false; - } - if ( neg != 0 ) - { - v = -v; - } - pValue = (int)v; - return true; - } + /* + ** This routine is a faster version of sqlite3PutVarint() that only + ** works for 32-bit positive integers and which is optimized for + ** the common case of small integers. + */ + static int putVarint32(byte[] p, int offset, int v) { +#if !putVarint32 + if ((v & ~0x7f) == 0) { + p[offset] = (byte)v; + return 1; + } +#endif + if ((v & ~0x3fff) == 0) { + p[offset] = (byte)((v >> 7) | 0x80); + p[offset + 1] = (byte)(v & 0x7f); + return 2; + } + return sqlite3PutVarint(p, offset, v); + } - /* - ** Return a 32-bit integer value extracted from a string. If the - ** string is not an integer, just return 0. - */ - static int sqlite3Atoi( string z ) - { - int x = 0; - if ( !String.IsNullOrEmpty( z ) ) - sqlite3GetInt32( z, ref x ); - return x; - } + static int putVarint32(byte[] p, int v) { + if ((v & ~0x7f) == 0) { + p[0] = (byte)v; + return 1; + } else if ((v & ~0x3fff) == 0) { + p[0] = (byte)((v >> 7) | 0x80); + p[1] = (byte)(v & 0x7f); + return 2; + } else { + return sqlite3PutVarint(p, 0, v); + } + } - /* - ** The variable-length integer encoding is as follows: - ** - ** KEY: - ** A = 0xxxxxxx 7 bits of data and one flag bit - ** B = 1xxxxxxx 7 bits of data and one flag bit - ** C = xxxxxxxx 8 bits of data - ** - ** 7 bits - A - ** 14 bits - BA - ** 21 bits - BBA - ** 28 bits - BBBA - ** 35 bits - BBBBA - ** 42 bits - BBBBBA - ** 49 bits - BBBBBBA - ** 56 bits - BBBBBBBA - ** 64 bits - BBBBBBBBC - */ + /* + ** Bitmasks used by sqlite3GetVarint(). These precomputed constants + ** are defined here rather than simply putting the constant expressions + ** inline in order to work around bugs in the RVT compiler. + ** + ** SLOT_2_0 A mask for (0x7f<<14) | 0x7f + ** + ** SLOT_4_2_0 A mask for (0x7f<<28) | SLOT_2_0 + */ + const int SLOT_2_0 = 0x001fc07f; //#define SLOT_2_0 0x001fc07f + const u32 SLOT_4_2_0 = (u32)0xf01fc07f; //#define SLOT_4_2_0 0xf01fc07f + + /* + ** Read a 64-bit variable-length integer from memory starting at p[0]. + ** Return the number of bytes read. The value is stored in *v. + */ + static u8 sqlite3GetVarint(byte[] p, int offset, out u64 v) { + u32 a, b, s; + + a = p[offset + 0]; + /* a: p0 (unmasked) */ + if (0 == (a & 0x80)) { + v = a; + return 1; + } - /* - ** Write a 64-bit variable-length integer to memory starting at p[0]. - ** The length of data write will be between 1 and 9 bytes. The number - ** of bytes written is returned. - ** - ** A variable-length integer consists of the lower 7 bits of each byte - ** for all bytes that have the 8th bit set and one byte with the 8th - ** bit clear. Except, if we get to the 9th byte, it stores the full - ** 8 bits and is the last byte. - */ - static int getVarint( byte[] p, out u32 v ) - { - v = p[0]; - if ( v <= 0x7F ) - return 1; - u64 u64_v = 0; - int result = sqlite3GetVarint( p, 0, out u64_v ); - v = (u32)u64_v; - return result; - } - static int getVarint( byte[] p, int offset, out u32 v ) - { - v = p[offset + 0]; - if ( v <= 0x7F ) - return 1; - u64 u64_v = 0; - int result = sqlite3GetVarint( p, offset, out u64_v ); - v = (u32)u64_v; - return result; - } - static int getVarint( byte[] p, int offset, out int v ) - { - v = p[offset + 0]; - if ( v <= 0x7F ) - return 1; - u64 u64_v = 0; - int result = sqlite3GetVarint( p, offset, out u64_v ); - v = (int)u64_v; - return result; - } - static int getVarint( byte[] p, int offset, out i64 v ) - { - v = offset >= p.Length ? 0 : (int)p[offset + 0]; - if ( v <= 0x7F ) - return 1; - if ( offset + 1 >= p.Length ) - { - v = 65535; - return 2; - } - else - { - u64 u64_v = 0; - int result = sqlite3GetVarint( p, offset, out u64_v ); - v = (i64)u64_v; - return result; - } - } - static int getVarint( byte[] p, int offset, out u64 v ) - { - v = p[offset + 0]; - if ( v <= 0x7F ) - return 1; - int result = sqlite3GetVarint( p, offset, out v ); - return result; - } - static int getVarint32( byte[] p, out u32 v ) - { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) - v = p[0]; - if ( v <= 0x7F ) - return 1; - return sqlite3GetVarint32( p, 0, out v ); - } - static byte[] pByte4 = new byte[4]; - static int getVarint32( string s, u32 offset, out int v ) - { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) - v = s[(int)offset]; - if ( v <= 0x7F ) - return 1; - pByte4[0] = (u8)s[(int)offset + 0]; - pByte4[1] = (u8)s[(int)offset + 1]; - pByte4[2] = (u8)s[(int)offset + 2]; - pByte4[3] = (u8)s[(int)offset + 3]; - u32 u32_v = 0; - int result = sqlite3GetVarint32( pByte4, 0, out u32_v ); - v = (int)u32_v; - return sqlite3GetVarint32( pByte4, 0, out v ); - } - static int getVarint32( string s, u32 offset, out u32 v ) - { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) - v = s[(int)offset]; - if ( v <= 0x7F ) - return 1; - pByte4[0] = (u8)s[(int)offset + 0]; - pByte4[1] = (u8)s[(int)offset + 1]; - pByte4[2] = (u8)s[(int)offset + 2]; - pByte4[3] = (u8)s[(int)offset + 3]; - return sqlite3GetVarint32( pByte4, 0, out v ); - } - static int getVarint32( byte[] p, u32 offset, out u32 v ) - { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) - v = p[offset]; - if ( v <= 0x7F ) - return 1; - return sqlite3GetVarint32( p, (int)offset, out v ); - } - static int getVarint32( byte[] p, int offset, out u32 v ) - { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) - v = offset >= p.Length ? 0 : (u32)p[offset]; - if ( v <= 0x7F ) - return 1; - return sqlite3GetVarint32( p, offset, out v ); - } - static int getVarint32( byte[] p, int offset, out int v ) - { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) - v = p[offset + 0]; - if ( v <= 0x7F ) - return 1; - u32 u32_v = 0; - int result = sqlite3GetVarint32( p, offset, out u32_v ); - v = (int)u32_v; - return result; - } - static int putVarint( byte[] p, int offset, int v ) - { - return putVarint( p, offset, (u64)v ); - } - static int putVarint( byte[] p, int offset, u64 v ) - { - return sqlite3PutVarint( p, offset, v ); - } - static int sqlite3PutVarint( byte[] p, int offset, int v ) - { - return sqlite3PutVarint( p, offset, (u64)v ); - } - static u8[] bufByte10 = new u8[10]; - static int sqlite3PutVarint( byte[] p, int offset, u64 v ) - { - int i, j, n; - if ( ( v & ( ( (u64)0xff000000 ) << 32 ) ) != 0 ) - { - p[offset + 8] = (byte)v; - v >>= 8; - for ( i = 7; i >= 0; i-- ) - { - p[offset + i] = (byte)( ( v & 0x7f ) | 0x80 ); - v >>= 7; - } - return 9; - } - n = 0; - do - { - bufByte10[n++] = (byte)( ( v & 0x7f ) | 0x80 ); - v >>= 7; - } while ( v != 0 ); - bufByte10[0] &= 0x7f; - Debug.Assert( n <= 9 ); - for ( i = 0, j = n - 1; j >= 0; j--, i++ ) - { - p[offset + i] = bufByte10[j]; - } - return n; - } + //p++; + b = p[offset + 1]; + /* b: p1 (unmasked) */ + if (0 == (b & 0x80)) { + a &= 0x7f; + a = a << 7; + a |= b; + v = a; + return 2; + } - /* - ** This routine is a faster version of sqlite3PutVarint() that only - ** works for 32-bit positive integers and which is optimized for - ** the common case of small integers. - */ - static int putVarint32( byte[] p, int offset, int v ) - { -#if !putVarint32 - if ( ( v & ~0x7f ) == 0 ) - { - p[offset] = (byte)v; - return 1; - } -#endif - if ( ( v & ~0x3fff ) == 0 ) - { - p[offset] = (byte)( ( v >> 7 ) | 0x80 ); - p[offset + 1] = (byte)( v & 0x7f ); - return 2; - } - return sqlite3PutVarint( p, offset, v ); - } + /* Verify that constants are precomputed correctly */ + Debug.Assert(SLOT_2_0 == ((0x7f << 14) | (0x7f))); + Debug.Assert(SLOT_4_2_0 == ((0xfU << 28) | (0x7f << 14) | (0x7f))); + //p++; + a = a << 14; + a |= p[offset + 2]; + /* a: p0<<14 | p2 (unmasked) */ + if (0 == (a & 0x80)) { + a &= SLOT_2_0; + b &= 0x7f; + b = b << 7; + a |= b; + v = a; + return 3; + } - static int putVarint32( byte[] p, int v ) - { - if ( ( v & ~0x7f ) == 0 ) - { - p[0] = (byte)v; - return 1; - } - else if ( ( v & ~0x3fff ) == 0 ) - { - p[0] = (byte)( ( v >> 7 ) | 0x80 ); - p[1] = (byte)( v & 0x7f ); - return 2; - } - else - { - return sqlite3PutVarint( p, 0, v ); - } - } + /* CSE1 from below */ + a &= SLOT_2_0; + //p++; + b = b << 14; + b |= p[offset + 3]; + /* b: p1<<14 | p3 (unmasked) */ + if (0 == (b & 0x80)) { + b &= SLOT_2_0; + /* moved CSE1 up */ + /* a &= (0x7f<<14)|(0x7f); */ + a = a << 7; + a |= b; + v = a; + return 4; + } - /* - ** Bitmasks used by sqlite3GetVarint(). These precomputed constants - ** are defined here rather than simply putting the constant expressions - ** inline in order to work around bugs in the RVT compiler. - ** - ** SLOT_2_0 A mask for (0x7f<<14) | 0x7f - ** - ** SLOT_4_2_0 A mask for (0x7f<<28) | SLOT_2_0 - */ - const int SLOT_2_0 = 0x001fc07f; //#define SLOT_2_0 0x001fc07f - const u32 SLOT_4_2_0 = (u32)0xf01fc07f; //#define SLOT_4_2_0 0xf01fc07f + /* a: p0<<14 | p2 (masked) */ + /* b: p1<<14 | p3 (unmasked) */ + /* 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */ + /* moved CSE1 up */ + /* a &= (0x7f<<14)|(0x7f); */ + b &= SLOT_2_0; + s = a; + /* s: p0<<14 | p2 (masked) */ + + //p++; + a = a << 14; + a |= p[offset + 4]; + /* a: p0<<28 | p2<<14 | p4 (unmasked) */ + if (0 == (a & 0x80)) { + /* we can skip these cause they were (effectively) done above in calc'ing s */ + /* a &= (0x1f<<28)|(0x7f<<14)|(0x7f); */ + /* b &= (0x7f<<14)|(0x7f); */ + b = b << 7; + a |= b; + s = s >> 18; + v = ((u64)s) << 32 | a; + return 5; + } - /* - ** Read a 64-bit variable-length integer from memory starting at p[0]. - ** Return the number of bytes read. The value is stored in *v. - */ - static u8 sqlite3GetVarint( byte[] p, int offset, out u64 v ) - { - u32 a, b, s; - - a = p[offset + 0]; - /* a: p0 (unmasked) */ - if ( 0 == ( a & 0x80 ) ) - { - v = a; - return 1; - } - - //p++; - b = p[offset + 1]; - /* b: p1 (unmasked) */ - if ( 0 == ( b & 0x80 ) ) - { - a &= 0x7f; - a = a << 7; - a |= b; - v = a; - return 2; - } - - /* Verify that constants are precomputed correctly */ - Debug.Assert( SLOT_2_0 == ( ( 0x7f << 14 ) | ( 0x7f ) ) ); - Debug.Assert( SLOT_4_2_0 == ( ( 0xfU << 28 ) | ( 0x7f << 14 ) | ( 0x7f ) ) ); - //p++; - a = a << 14; - a |= p[offset + 2]; - /* a: p0<<14 | p2 (unmasked) */ - if ( 0 == ( a & 0x80 ) ) - { - a &= SLOT_2_0; - b &= 0x7f; - b = b << 7; - a |= b; - v = a; - return 3; - } - - /* CSE1 from below */ - a &= SLOT_2_0; - //p++; - b = b << 14; - b |= p[offset + 3]; - /* b: p1<<14 | p3 (unmasked) */ - if ( 0 == ( b & 0x80 ) ) - { - b &= SLOT_2_0; - /* moved CSE1 up */ - /* a &= (0x7f<<14)|(0x7f); */ - a = a << 7; - a |= b; - v = a; - return 4; - } - - /* a: p0<<14 | p2 (masked) */ - /* b: p1<<14 | p3 (unmasked) */ - /* 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */ - /* moved CSE1 up */ - /* a &= (0x7f<<14)|(0x7f); */ - b &= SLOT_2_0; - s = a; - /* s: p0<<14 | p2 (masked) */ - - //p++; - a = a << 14; - a |= p[offset + 4]; - /* a: p0<<28 | p2<<14 | p4 (unmasked) */ - if ( 0 == ( a & 0x80 ) ) - { - /* we can skip these cause they were (effectively) done above in calc'ing s */ - /* a &= (0x1f<<28)|(0x7f<<14)|(0x7f); */ - /* b &= (0x7f<<14)|(0x7f); */ - b = b << 7; - a |= b; - s = s >> 18; - v = ( (u64)s ) << 32 | a; - return 5; - } - - /* 2:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */ - s = s << 7; - s |= b; - /* s: p0<<21 | p1<<14 | p2<<7 | p3 (masked) */ - - //p++; - b = b << 14; - b |= p[offset + 5]; - /* b: p1<<28 | p3<<14 | p5 (unmasked) */ - if ( 0 == ( b & 0x80 ) ) - { - /* we can skip this cause it was (effectively) done above in calc'ing s */ - /* b &= (0x1f<<28)|(0x7f<<14)|(0x7f); */ - a &= SLOT_2_0; - a = a << 7; - a |= b; - s = s >> 18; - v = ( (u64)s ) << 32 | a; - return 6; - } - - //p++; - a = a << 14; - a |= p[offset + 6]; - /* a: p2<<28 | p4<<14 | p6 (unmasked) */ - if ( 0 == ( a & 0x80 ) ) - { - a &= SLOT_4_2_0; - b &= SLOT_2_0; - b = b << 7; - a |= b; - s = s >> 11; - v = ( (u64)s ) << 32 | a; - return 7; - } - - /* CSE2 from below */ - a &= SLOT_2_0; - //p++; - b = b << 14; - b |= p[offset + 7]; - /* b: p3<<28 | p5<<14 | p7 (unmasked) */ - if ( 0 == ( b & 0x80 ) ) - { - b &= SLOT_4_2_0; - /* moved CSE2 up */ - /* a &= (0x7f<<14)|(0x7f); */ - a = a << 7; - a |= b; - s = s >> 4; - v = ( (u64)s ) << 32 | a; - return 8; - } - - //p++; - a = a << 15; - a |= p[offset + 8]; - /* a: p4<<29 | p6<<15 | p8 (unmasked) */ - - /* moved CSE2 up */ - /* a &= (0x7f<<29)|(0x7f<<15)|(0xff); */ - b &= SLOT_2_0; - b = b << 8; - a |= b; - - s = s << 4; - b = p[offset + 4]; - b &= 0x7f; - b = b >> 3; - s |= b; - - v = ( (u64)s ) << 32 | a; - - return 9; - } + /* 2:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */ + s = s << 7; + s |= b; + /* s: p0<<21 | p1<<14 | p2<<7 | p3 (masked) */ + + //p++; + b = b << 14; + b |= p[offset + 5]; + /* b: p1<<28 | p3<<14 | p5 (unmasked) */ + if (0 == (b & 0x80)) { + /* we can skip this cause it was (effectively) done above in calc'ing s */ + /* b &= (0x1f<<28)|(0x7f<<14)|(0x7f); */ + a &= SLOT_2_0; + a = a << 7; + a |= b; + s = s >> 18; + v = ((u64)s) << 32 | a; + return 6; + } + //p++; + a = a << 14; + a |= p[offset + 6]; + /* a: p2<<28 | p4<<14 | p6 (unmasked) */ + if (0 == (a & 0x80)) { + a &= SLOT_4_2_0; + b &= SLOT_2_0; + b = b << 7; + a |= b; + s = s >> 11; + v = ((u64)s) << 32 | a; + return 7; + } - /* - ** Read a 32-bit variable-length integer from memory starting at p[0]. - ** Return the number of bytes read. The value is stored in *v. - ** - ** If the varint stored in p[0] is larger than can fit in a 32-bit unsigned - ** integer, then set *v to 0xffffffff. - ** - ** A MACRO version, getVarint32, is provided which inlines the - ** single-byte case. All code should use the MACRO version as - ** this function assumes the single-byte case has already been handled. - */ - static u8 sqlite3GetVarint32( byte[] p, out int v ) - { - u32 u32_v = 0; - u8 result = sqlite3GetVarint32( p, 0, out u32_v ); - v = (int)u32_v; - return result; - } - static u8 sqlite3GetVarint32( byte[] p, int offset, out int v ) - { - u32 u32_v = 0; - u8 result = sqlite3GetVarint32( p, offset, out u32_v ); - v = (int)u32_v; - return result; - } - static u8 sqlite3GetVarint32( byte[] p, out u32 v ) - { - return sqlite3GetVarint32( p, 0, out v ); - } - static u8 sqlite3GetVarint32( byte[] p, int offset, out u32 v ) - { - u32 a, b; - - /* The 1-byte case. Overwhelmingly the most common. Handled inline - ** by the getVarin32() macro */ - a = p[offset + 0]; - /* a: p0 (unmasked) */ - //#if getVarint32 - // if ( 0==( a&0x80)) - // { - /* Values between 0 and 127 */ - // v = a; - // return 1; - // } - //#endif - - /* The 2-byte case */ - //p++; - b = ( offset + 1 ) < p.Length ? p[offset + 1] : (u32)0; - /* b: p1 (unmasked) */ - if ( 0 == ( b & 0x80 ) ) - { - /* Values between 128 and 16383 */ - a &= 0x7f; - a = a << 7; - v = a | b; - return 2; - } - - /* The 3-byte case */ - //p++; - a = a << 14; - a |= ( offset + 2 ) < p.Length ? p[offset + 2] : (u32)0; - /* a: p0<<14 | p2 (unmasked) */ - if ( 0 == ( a & 0x80 ) ) - { - /* Values between 16384 and 2097151 */ - a &= ( 0x7f << 14 ) | ( 0x7f ); - b &= 0x7f; - b = b << 7; - v = a | b; - return 3; - } - - /* A 32-bit varint is used to store size information in btrees. - ** Objects are rarely larger than 2MiB limit of a 3-byte varint. - ** A 3-byte varint is sufficient, for example, to record the size - ** of a 1048569-byte BLOB or string. - ** - ** We only unroll the first 1-, 2-, and 3- byte cases. The very - ** rare larger cases can be handled by the slower 64-bit varint - ** routine. - */ -#if TRUE - { - u64 v64 = 0; - u8 n; - - //p -= 2; - n = sqlite3GetVarint( p, offset, out v64 ); - Debug.Assert( n > 3 && n <= 9 ); - if ( ( v64 & SQLITE_MAX_U32 ) != v64 ) - { - v = 0xffffffff; + /* CSE2 from below */ + a &= SLOT_2_0; + //p++; + b = b << 14; + b |= p[offset + 7]; + /* b: p3<<28 | p5<<14 | p7 (unmasked) */ + if (0 == (b & 0x80)) { + b &= SLOT_4_2_0; + /* moved CSE2 up */ + /* a &= (0x7f<<14)|(0x7f); */ + a = a << 7; + a |= b; + s = s >> 4; + v = ((u64)s) << 32 | a; + return 8; + } + + //p++; + a = a << 15; + a |= p[offset + 8]; + /* a: p4<<29 | p6<<15 | p8 (unmasked) */ + + /* moved CSE2 up */ + /* a &= (0x7f<<29)|(0x7f<<15)|(0xff); */ + b &= SLOT_2_0; + b = b << 8; + a |= b; + + s = s << 4; + b = p[offset + 4]; + b &= 0x7f; + b = b >> 3; + s |= b; + + v = ((u64)s) << 32 | a; + + return 9; + } + + + /* + ** Read a 32-bit variable-length integer from memory starting at p[0]. + ** Return the number of bytes read. The value is stored in *v. + ** + ** If the varint stored in p[0] is larger than can fit in a 32-bit unsigned + ** integer, then set *v to 0xffffffff. + ** + ** A MACRO version, getVarint32, is provided which inlines the + ** single-byte case. All code should use the MACRO version as + ** this function assumes the single-byte case has already been handled. + */ + static u8 sqlite3GetVarint32(byte[] p, out int v) { + u32 u32_v = 0; + u8 result = sqlite3GetVarint32(p, 0, out u32_v); + v = (int)u32_v; + return result; } - else - { - v = (u32)v64; + static u8 sqlite3GetVarint32(byte[] p, int offset, out int v) { + u32 u32_v = 0; + u8 result = sqlite3GetVarint32(p, offset, out u32_v); + v = (int)u32_v; + return result; } - return n; - } + static u8 sqlite3GetVarint32(byte[] p, out u32 v) { + return sqlite3GetVarint32(p, 0, out v); + } + static u8 sqlite3GetVarint32(byte[] p, int offset, out u32 v) { + u32 a, b; + + /* The 1-byte case. Overwhelmingly the most common. Handled inline + ** by the getVarin32() macro */ + a = p[offset + 0]; + /* a: p0 (unmasked) */ + //#if getVarint32 + // if ( 0==( a&0x80)) + // { + /* Values between 0 and 127 */ + // v = a; + // return 1; + // } + //#endif + + /* The 2-byte case */ + //p++; + b = (offset + 1) < p.Length ? p[offset + 1] : (u32)0; + /* b: p1 (unmasked) */ + if (0 == (b & 0x80)) { + /* Values between 128 and 16383 */ + a &= 0x7f; + a = a << 7; + v = a | b; + return 2; + } + + /* The 3-byte case */ + //p++; + a = a << 14; + a |= (offset + 2) < p.Length ? p[offset + 2] : (u32)0; + /* a: p0<<14 | p2 (unmasked) */ + if (0 == (a & 0x80)) { + /* Values between 16384 and 2097151 */ + a &= (0x7f << 14) | (0x7f); + b &= 0x7f; + b = b << 7; + v = a | b; + return 3; + } + + /* A 32-bit varint is used to store size information in btrees. + ** Objects are rarely larger than 2MiB limit of a 3-byte varint. + ** A 3-byte varint is sufficient, for example, to record the size + ** of a 1048569-byte BLOB or string. + ** + ** We only unroll the first 1-, 2-, and 3- byte cases. The very + ** rare larger cases can be handled by the slower 64-bit varint + ** routine. + */ +#if TRUE + { + u64 v64 = 0; + u8 n; + + //p -= 2; + n = sqlite3GetVarint(p, offset, out v64); + Debug.Assert(n > 3 && n <= 9); + if ((v64 & SQLITE_MAX_U32) != v64) { + v = 0xffffffff; + } else { + v = (u32)v64; + } + return n; + } #else /* For following code (kept for historical record only) shows an ** unrolling for the 3- and 4-byte varint cases. This code is @@ -1366,286 +1204,250 @@ static u8 sqlite3GetVarint32( byte[] p, int offset, out u32 v ) return n; } #endif - } + } - /* - ** Return the number of bytes that will be needed to store the given - ** 64-bit integer. - */ - static int sqlite3VarintLen( u64 v ) - { - int i = 0; - do - { - i++; - v >>= 7; - } while ( v != 0 && ALWAYS( i < 9 ) ); - return i; - } + /* + ** Return the number of bytes that will be needed to store the given + ** 64-bit integer. + */ + static int sqlite3VarintLen(u64 v) { + int i = 0; + do { + i++; + v >>= 7; + } while (v != 0 && ALWAYS(i < 9)); + return i; + } - /* - ** Read or write a four-byte big-endian integer value. - */ - static u32 sqlite3Get4byte( u8[] p, int p_offset, int offset ) - { - offset += p_offset; - return ( offset + 3 > p.Length ) ? 0 : (u32)( ( p[0 + offset] << 24 ) | ( p[1 + offset] << 16 ) | ( p[2 + offset] << 8 ) | p[3 + offset] ); - } - static u32 sqlite3Get4byte( u8[] p, int offset ) - { - return ( offset + 3 > p.Length ) ? 0 : (u32)( ( p[0 + offset] << 24 ) | ( p[1 + offset] << 16 ) | ( p[2 + offset] << 8 ) | p[3 + offset] ); - } - static u32 sqlite3Get4byte( u8[] p, u32 offset ) - { - return ( offset + 3 > p.Length ) ? 0 : (u32)( ( p[0 + offset] << 24 ) | ( p[1 + offset] << 16 ) | ( p[2 + offset] << 8 ) | p[3 + offset] ); - } - static u32 sqlite3Get4byte( u8[] p ) - { - return (u32)( ( p[0] << 24 ) | ( p[1] << 16 ) | ( p[2] << 8 ) | p[3] ); - } - static void sqlite3Put4byte( byte[] p, int v ) - { - p[0] = (byte)( v >> 24 & 0xFF ); - p[1] = (byte)( v >> 16 & 0xFF ); - p[2] = (byte)( v >> 8 & 0xFF ); - p[3] = (byte)( v & 0xFF ); - } - static void sqlite3Put4byte( byte[] p, int offset, int v ) - { - p[0 + offset] = (byte)( v >> 24 & 0xFF ); - p[1 + offset] = (byte)( v >> 16 & 0xFF ); - p[2 + offset] = (byte)( v >> 8 & 0xFF ); - p[3 + offset] = (byte)( v & 0xFF ); - } - static void sqlite3Put4byte( byte[] p, u32 offset, u32 v ) - { - p[0 + offset] = (byte)( v >> 24 & 0xFF ); - p[1 + offset] = (byte)( v >> 16 & 0xFF ); - p[2 + offset] = (byte)( v >> 8 & 0xFF ); - p[3 + offset] = (byte)( v & 0xFF ); - } - static void sqlite3Put4byte( byte[] p, int offset, u64 v ) - { - p[0 + offset] = (byte)( v >> 24 & 0xFF ); - p[1 + offset] = (byte)( v >> 16 & 0xFF ); - p[2 + offset] = (byte)( v >> 8 & 0xFF ); - p[3 + offset] = (byte)( v & 0xFF ); - } - static void sqlite3Put4byte( byte[] p, u64 v ) - { - p[0] = (byte)( v >> 24 & 0xFF ); - p[1] = (byte)( v >> 16 & 0xFF ); - p[2] = (byte)( v >> 8 & 0xFF ); - p[3] = (byte)( v & 0xFF ); - } + /* + ** Read or write a four-byte big-endian integer value. + */ + static u32 sqlite3Get4byte(u8[] p, int p_offset, int offset) { + offset += p_offset; + return (offset + 3 > p.Length) ? 0 : (u32)((p[0 + offset] << 24) | (p[1 + offset] << 16) | (p[2 + offset] << 8) | p[3 + offset]); + } + static u32 sqlite3Get4byte(u8[] p, int offset) { + return (offset + 3 > p.Length) ? 0 : (u32)((p[0 + offset] << 24) | (p[1 + offset] << 16) | (p[2 + offset] << 8) | p[3 + offset]); + } + static u32 sqlite3Get4byte(u8[] p, u32 offset) { + return (offset + 3 > p.Length) ? 0 : (u32)((p[0 + offset] << 24) | (p[1 + offset] << 16) | (p[2 + offset] << 8) | p[3 + offset]); + } + static u32 sqlite3Get4byte(u8[] p) { + return (u32)((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]); + } + static void sqlite3Put4byte(byte[] p, int v) { + p[0] = (byte)(v >> 24 & 0xFF); + p[1] = (byte)(v >> 16 & 0xFF); + p[2] = (byte)(v >> 8 & 0xFF); + p[3] = (byte)(v & 0xFF); + } + static void sqlite3Put4byte(byte[] p, int offset, int v) { + p[0 + offset] = (byte)(v >> 24 & 0xFF); + p[1 + offset] = (byte)(v >> 16 & 0xFF); + p[2 + offset] = (byte)(v >> 8 & 0xFF); + p[3 + offset] = (byte)(v & 0xFF); + } + static void sqlite3Put4byte(byte[] p, u32 offset, u32 v) { + p[0 + offset] = (byte)(v >> 24 & 0xFF); + p[1 + offset] = (byte)(v >> 16 & 0xFF); + p[2 + offset] = (byte)(v >> 8 & 0xFF); + p[3 + offset] = (byte)(v & 0xFF); + } + static void sqlite3Put4byte(byte[] p, int offset, u64 v) { + p[0 + offset] = (byte)(v >> 24 & 0xFF); + p[1 + offset] = (byte)(v >> 16 & 0xFF); + p[2 + offset] = (byte)(v >> 8 & 0xFF); + p[3 + offset] = (byte)(v & 0xFF); + } + static void sqlite3Put4byte(byte[] p, u64 v) { + p[0] = (byte)(v >> 24 & 0xFF); + p[1] = (byte)(v >> 16 & 0xFF); + p[2] = (byte)(v >> 8 & 0xFF); + p[3] = (byte)(v & 0xFF); + } -/* -** Translate a single byte of Hex into an integer. -** This routine only works if h really is a valid hexadecimal -** character: 0..9a..fA..F -*/ - static int sqlite3HexToInt( int h ) - { - Debug.Assert( ( h >= '0' && h <= '9' ) || ( h >= 'a' && h <= 'f' ) || ( h >= 'A' && h <= 'F' ) ); + /* + ** Translate a single byte of Hex into an integer. + ** This routine only works if h really is a valid hexadecimal + ** character: 0..9a..fA..F + */ + static int sqlite3HexToInt(int h) { + Debug.Assert((h >= '0' && h <= '9') || (h >= 'a' && h <= 'f') || (h >= 'A' && h <= 'F')); #if SQLITE_ASCII - h += 9 * ( 1 & ( h >> 6 ) ); + h += 9 * (1 & (h >> 6)); #endif -//#if SQLITE_EBCDIC -//h += 9*(1&~(h>>4)); -//#endif - return h & 0xf; - } + //#if SQLITE_EBCDIC + //h += 9*(1&~(h>>4)); + //#endif + return h & 0xf; + } #if !SQLITE_OMIT_BLOB_LITERAL || SQLITE_HAS_CODEC - /* -** Convert a BLOB literal of the form "x'hhhhhh'" into its binary -** value. Return a pointer to its binary value. Space to hold the -** binary value has been obtained from malloc and must be freed by -** the calling routine. -*/ - static byte[] sqlite3HexToBlob( sqlite3 db, string z, int n ) - { - StringBuilder zBlob; - int i; - - zBlob = new StringBuilder( n / 2 + 1 );// (char)sqlite3DbMallocRaw(db, n / 2 + 1); - n--; - if ( zBlob != null ) - { - for ( i = 0; i < n; i += 2 ) - { - zBlob.Append( Convert.ToChar( ( sqlite3HexToInt( z[i] ) << 4 ) | sqlite3HexToInt( z[i + 1] ) ) ); + /* + ** Convert a BLOB literal of the form "x'hhhhhh'" into its binary + ** value. Return a pointer to its binary value. Space to hold the + ** binary value has been obtained from malloc and must be freed by + ** the calling routine. + */ + static byte[] sqlite3HexToBlob(sqlite3 db, string z, int n) { + StringBuilder zBlob; + int i; + + zBlob = new StringBuilder(n / 2 + 1);// (char)sqlite3DbMallocRaw(db, n / 2 + 1); + n--; + if (zBlob != null) { + for (i = 0; i < n; i += 2) { + zBlob.Append(Convert.ToChar((sqlite3HexToInt(z[i]) << 4) | sqlite3HexToInt(z[i + 1]))); + } + //zBlob[i / 2] = '\0'; ; + } + return Encoding.UTF8.GetBytes(zBlob.ToString()); } - //zBlob[i / 2] = '\0'; ; - } - return Encoding.UTF8.GetBytes( zBlob.ToString() ); - } #endif // * !SQLITE_OMIT_BLOB_LITERAL || SQLITE_HAS_CODEC */ - /* -** Log an error that is an API call on a connection pointer that should -** not have been used. The "type" of connection pointer is given as the -** argument. The zType is a word like "NULL" or "closed" or "invalid". -*/ - static void logBadConnection( string zType ) - { - sqlite3_log( SQLITE_MISUSE, - "API call with %s database connection pointer", - zType - ); - } - - /* - ** Check to make sure we have a valid db pointer. This test is not - ** foolproof but it does provide some measure of protection against - ** misuse of the interface such as passing in db pointers that are - ** NULL or which have been previously closed. If this routine returns - ** 1 it means that the db pointer is valid and 0 if it should not be - ** dereferenced for any reason. The calling function should invoke - ** SQLITE_MISUSE immediately. - ** - ** sqlite3SafetyCheckOk() requires that the db pointer be valid for - ** use. sqlite3SafetyCheckSickOrOk() allows a db pointer that failed to - ** open properly and is not fit for general use but which can be - ** used as an argument to sqlite3_errmsg() or sqlite3_close(). + /* + ** Log an error that is an API call on a connection pointer that should + ** not have been used. The "type" of connection pointer is given as the + ** argument. The zType is a word like "NULL" or "closed" or "invalid". */ - static bool sqlite3SafetyCheckOk( sqlite3 db ) - { - u32 magic; - if ( db == null ) - { - logBadConnection( "NULL" ); - return false; - } - magic = db.magic; - if ( magic != SQLITE_MAGIC_OPEN ) - { - if ( sqlite3SafetyCheckSickOrOk( db ) ) - { - testcase( sqlite3GlobalConfig.xLog != null ); - logBadConnection( "unopened" ); + static void logBadConnection(string zType) { + sqlite3_log(SQLITE_MISUSE, + "API call with %s database connection pointer", + zType + ); } - return false; - } - else - { - return true; - } - } - static bool sqlite3SafetyCheckSickOrOk( sqlite3 db ) - { - u32 magic; - magic = db.magic; - if ( magic != SQLITE_MAGIC_SICK && - magic != SQLITE_MAGIC_OPEN && - magic != SQLITE_MAGIC_BUSY ) - { - testcase( sqlite3GlobalConfig.xLog != null ); - logBadConnection( "invalid" ); - return false; - } - else - { - return true; - } - } - /* - ** Attempt to add, substract, or multiply the 64-bit signed value iB against - ** the other 64-bit signed integer at *pA and store the result in *pA. - ** Return 0 on success. Or if the operation would have resulted in an - ** overflow, leave *pA unchanged and return 1. - */ - static int sqlite3AddInt64( ref i64 pA, i64 iB ) - { - i64 iA = pA; - testcase( iA == 0 ); - testcase( iA == 1 ); - testcase( iB == -1 ); - testcase( iB == 0 ); - if ( iB >= 0 ) - { - testcase( iA > 0 && LARGEST_INT64 - iA == iB ); - testcase( iA > 0 && LARGEST_INT64 - iA == iB - 1 ); - if ( iA > 0 && LARGEST_INT64 - iA < iB ) - return 1; - pA += iB; - } - else - { - testcase( iA < 0 && -( iA + LARGEST_INT64 ) == iB + 1 ); - testcase( iA < 0 && -( iA + LARGEST_INT64 ) == iB + 2 ); - if ( iA < 0 && -( iA + LARGEST_INT64 ) > iB + 1 ) - return 1; - pA += iB; - } - return 0; - } - static int sqlite3SubInt64( ref i64 pA, i64 iB ) - { - testcase( iB == SMALLEST_INT64 + 1 ); - if ( iB == SMALLEST_INT64 ) - { - testcase( ( pA ) == ( -1 ) ); - testcase( ( pA ) == 0 ); - if ( ( pA ) >= 0 ) - return 1; - pA -= iB; - return 0; - } - else - { - return sqlite3AddInt64( ref pA, -iB ); - } - } - //#define TWOPOWER32 (((i64)1)<<32) - const i64 TWOPOWER32 = ( ( (i64)1 ) << 32 ); - //#define TWOPOWER31 (((i64)1)<<31) - const i64 TWOPOWER31 = ( ( (i64)1 ) << 31 ); - - static int sqlite3MulInt64( ref i64 pA, i64 iB ) - { - i64 iA = pA; - i64 iA1, iA0, iB1, iB0, r; - - iA1 = iA / TWOPOWER32; - iA0 = iA % TWOPOWER32; - iB1 = iB / TWOPOWER32; - iB0 = iB % TWOPOWER32; - if ( iA1 * iB1 != 0 ) - return 1; - Debug.Assert( iA1 * iB0 == 0 || iA0 * iB1 == 0 ); - r = iA1 * iB0 + iA0 * iB1; - testcase( r == ( -TWOPOWER31 ) - 1 ); - testcase( r == ( -TWOPOWER31 ) ); - testcase( r == TWOPOWER31 ); - testcase( r == TWOPOWER31 - 1 ); - if ( r < ( -TWOPOWER31 ) || r >= TWOPOWER31 ) - return 1; - r *= TWOPOWER32; - if ( sqlite3AddInt64( ref r, iA0 * iB0 ) != 0) - return 1; - pA = r; - return 0; - } + /* + ** Check to make sure we have a valid db pointer. This test is not + ** foolproof but it does provide some measure of protection against + ** misuse of the interface such as passing in db pointers that are + ** NULL or which have been previously closed. If this routine returns + ** 1 it means that the db pointer is valid and 0 if it should not be + ** dereferenced for any reason. The calling function should invoke + ** SQLITE_MISUSE immediately. + ** + ** sqlite3SafetyCheckOk() requires that the db pointer be valid for + ** use. sqlite3SafetyCheckSickOrOk() allows a db pointer that failed to + ** open properly and is not fit for general use but which can be + ** used as an argument to sqlite3_errmsg() or sqlite3_close(). + */ + static bool sqlite3SafetyCheckOk(sqlite3 db) { + u32 magic; + if (db == null) { + logBadConnection("NULL"); + return false; + } + magic = db.magic; + if (magic != SQLITE_MAGIC_OPEN) { + if (sqlite3SafetyCheckSickOrOk(db)) { + testcase(sqlite3GlobalConfig.xLog != null); + logBadConnection("unopened"); + } + return false; + } else { + return true; + } + } + static bool sqlite3SafetyCheckSickOrOk(sqlite3 db) { + u32 magic; + magic = db.magic; + if (magic != SQLITE_MAGIC_SICK && + magic != SQLITE_MAGIC_OPEN && + magic != SQLITE_MAGIC_BUSY) { + testcase(sqlite3GlobalConfig.xLog != null); + logBadConnection("invalid"); + return false; + } else { + return true; + } + } - /* - ** Compute the absolute value of a 32-bit signed integer, if possible. Or - ** if the integer has a value of -2147483648, return +2147483647 - */ - static int sqlite3AbsInt32( int x ) - { - if ( x >= 0 ) - return x; - if ( x == -2147483648) // 0x80000000 - return 0x7fffffff; - return -x; - } + /* + ** Attempt to add, substract, or multiply the 64-bit signed value iB against + ** the other 64-bit signed integer at *pA and store the result in *pA. + ** Return 0 on success. Or if the operation would have resulted in an + ** overflow, leave *pA unchanged and return 1. + */ + static int sqlite3AddInt64(ref i64 pA, i64 iB) { + i64 iA = pA; + testcase(iA == 0); + testcase(iA == 1); + testcase(iB == -1); + testcase(iB == 0); + if (iB >= 0) { + testcase(iA > 0 && LARGEST_INT64 - iA == iB); + testcase(iA > 0 && LARGEST_INT64 - iA == iB - 1); + if (iA > 0 && LARGEST_INT64 - iA < iB) + return 1; + pA += iB; + } else { + testcase(iA < 0 && -(iA + LARGEST_INT64) == iB + 1); + testcase(iA < 0 && -(iA + LARGEST_INT64) == iB + 2); + if (iA < 0 && -(iA + LARGEST_INT64) > iB + 1) + return 1; + pA += iB; + } + return 0; + } + static int sqlite3SubInt64(ref i64 pA, i64 iB) { + testcase(iB == SMALLEST_INT64 + 1); + if (iB == SMALLEST_INT64) { + testcase((pA) == (-1)); + testcase((pA) == 0); + if ((pA) >= 0) + return 1; + pA -= iB; + return 0; + } else { + return sqlite3AddInt64(ref pA, -iB); + } + } + //#define TWOPOWER32 (((i64)1)<<32) + const i64 TWOPOWER32 = (((i64)1) << 32); + //#define TWOPOWER31 (((i64)1)<<31) + const i64 TWOPOWER31 = (((i64)1) << 31); + + static int sqlite3MulInt64(ref i64 pA, i64 iB) { + i64 iA = pA; + i64 iA1, iA0, iB1, iB0, r; + + iA1 = iA / TWOPOWER32; + iA0 = iA % TWOPOWER32; + iB1 = iB / TWOPOWER32; + iB0 = iB % TWOPOWER32; + if (iA1 * iB1 != 0) + return 1; + Debug.Assert(iA1 * iB0 == 0 || iA0 * iB1 == 0); + r = iA1 * iB0 + iA0 * iB1; + testcase(r == (-TWOPOWER31) - 1); + testcase(r == (-TWOPOWER31)); + testcase(r == TWOPOWER31); + testcase(r == TWOPOWER31 - 1); + if (r < (-TWOPOWER31) || r >= TWOPOWER31) + return 1; + r *= TWOPOWER32; + if (sqlite3AddInt64(ref r, iA0 * iB0) != 0) + return 1; + pA = r; + return 0; + } + + /* + ** Compute the absolute value of a 32-bit signed integer, if possible. Or + ** if the integer has a value of -2147483648, return +2147483647 + */ + static int sqlite3AbsInt32(int x) { + if (x >= 0) + return x; + if (x == -2147483648) // 0x80000000 + return 0x7fffffff; + return -x; + } #if SQLITE_ENABLE_8_3_NAMES /* @@ -1673,5 +1475,5 @@ static void sqlite3FileSuffix3(string zBaseFilename, string z){ } #endif - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/vacuum_c.cs b/Src/IronPython.SQLite/c#sqlite/vacuum_c.cs index 5d0df238b..40aa1c8e2 100644 --- a/Src/IronPython.SQLite/c#sqlite/vacuum_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/vacuum_c.cs @@ -1,222 +1,199 @@ -using System; using System.Diagnostics; -using System.Text; - -using Pgno = System.UInt32; using u32 = System.UInt32; -namespace Community.CsharpSqlite -{ - using sqlite3_stmt = Sqlite3.Vdbe; - - public partial class Sqlite3 - { - /* - ** 2003 April 6 - ** - ** 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 contains code used to implement the VACUUM command. - ** - ** Most of the code in this file may be omitted by defining the - ** SQLITE_OMIT_VACUUM macro. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include "vdbeInt.h" +namespace Community.CsharpSqlite { + using sqlite3_stmt = Sqlite3.Vdbe; + + public partial class Sqlite3 { + /* + ** 2003 April 6 + ** + ** 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 contains code used to implement the VACUUM command. + ** + ** Most of the code in this file may be omitted by defining the + ** SQLITE_OMIT_VACUUM macro. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include "vdbeInt.h" #if !SQLITE_OMIT_VACUUM && !SQLITE_OMIT_ATTACH - /* -** Finalize a prepared statement. If there was an error, store the -** text of the error message in *pzErrMsg. Return the result code. -*/ - static int vacuumFinalize( sqlite3 db, sqlite3_stmt pStmt, string pzErrMsg ) - { - int rc; - rc = sqlite3VdbeFinalize( ref pStmt ); - if ( rc != 0 ) - { - sqlite3SetString( ref pzErrMsg, db, sqlite3_errmsg( db ) ); - } - return rc; - } + /* + ** Finalize a prepared statement. If there was an error, store the + ** text of the error message in *pzErrMsg. Return the result code. + */ + static int vacuumFinalize(sqlite3 db, sqlite3_stmt pStmt, string pzErrMsg) { + int rc; + rc = sqlite3VdbeFinalize(ref pStmt); + if (rc != 0) { + sqlite3SetString(ref pzErrMsg, db, sqlite3_errmsg(db)); + } + return rc; + } - /* -** Execute zSql on database db. Return an error code. -*/ - static int execSql( sqlite3 db, string pzErrMsg, string zSql ) - { - sqlite3_stmt pStmt = null; + /* + ** Execute zSql on database db. Return an error code. + */ + static int execSql(sqlite3 db, string pzErrMsg, string zSql) { + sqlite3_stmt pStmt = null; #if !NDEBUG - int rc; - //VVA_ONLY( int rc; ) + int rc; + //VVA_ONLY( int rc; ) #endif - if ( zSql == null ) - { - return SQLITE_NOMEM; - } - if ( SQLITE_OK != sqlite3_prepare( db, zSql, -1, ref pStmt, 0 ) ) - { - sqlite3SetString( ref pzErrMsg, db, sqlite3_errmsg( db ) ); - return sqlite3_errcode( db ); - } + if (zSql == null) { + return SQLITE_NOMEM; + } + if (SQLITE_OK != sqlite3_prepare(db, zSql, -1, ref pStmt, 0)) { + sqlite3SetString(ref pzErrMsg, db, sqlite3_errmsg(db)); + return sqlite3_errcode(db); + } #if !NDEBUG - rc = sqlite3_step( pStmt ); - //VVA_ONLY( rc = ) sqlite3_step(pStmt); - Debug.Assert( rc != SQLITE_ROW ); + rc = sqlite3_step(pStmt); + //VVA_ONLY( rc = ) sqlite3_step(pStmt); + Debug.Assert(rc != SQLITE_ROW); #else sqlite3_step(pStmt); #endif - return vacuumFinalize( db, pStmt, pzErrMsg ); - } - - /* - ** Execute zSql on database db. The statement returns exactly - ** one column. Execute this as SQL on the same database. - */ - static int execExecSql( sqlite3 db, string pzErrMsg, string zSql ) - { - sqlite3_stmt pStmt = null; - int rc; - - rc = sqlite3_prepare( db, zSql, -1, ref pStmt, 0 ); - if ( rc != SQLITE_OK ) - return rc; - - while ( SQLITE_ROW == sqlite3_step( pStmt ) ) - { - rc = execSql( db, pzErrMsg, sqlite3_column_text( pStmt, 0 ) ); - if ( rc != SQLITE_OK ) - { - vacuumFinalize( db, pStmt, pzErrMsg ); - return rc; + return vacuumFinalize(db, pStmt, pzErrMsg); } - } - - return vacuumFinalize( db, pStmt, pzErrMsg ); - } - - /* - ** 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. - ** - ** 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. - */ - static void sqlite3Vacuum( Parse pParse ) - { - Vdbe v = sqlite3GetVdbe( pParse ); - if ( v != null ) - { - sqlite3VdbeAddOp2( v, OP_Vacuum, 0, 0 ); - } - return; - } - - /* - ** This routine implements the OP_Vacuum opcode of the VDBE. - */ - static int sqlite3RunVacuum( ref string pzErrMsg, sqlite3 db ) - { - int rc = SQLITE_OK; /* Return code from service routines */ - Btree pMain; /* The database being vacuumed */ - Btree pTemp; /* The temporary database we vacuum into */ - string zSql = ""; /* SQL statements */ - int saved_flags; /* Saved value of the db.flags */ - int saved_nChange; /* Saved value of db.nChange */ - int saved_nTotalChange; /* Saved value of db.nTotalChange */ - dxTrace saved_xTrace; //void (*saved_xTrace)(void*,const char*); /* Saved db->xTrace */ - Db pDb = null; /* Database to detach at end of vacuum */ - bool isMemDb; /* True if vacuuming a :memory: database */ - int nRes; /* Bytes of reserved space at the end of each page */ - int nDb; /* Number of attached databases */ - - if ( 0 == db.autoCommit ) - { - sqlite3SetString( ref pzErrMsg, db, "cannot VACUUM from within a transaction" ); - return SQLITE_ERROR; - } - if ( db.activeVdbeCnt > 1 ) - { - sqlite3SetString( ref pzErrMsg, db, "cannot VACUUM - SQL statements in progress" ); - return SQLITE_ERROR; - } - - /* Save the current value of the database flags so that it can be - ** restored before returning. Then set the writable-schema flag, and - ** disable CHECK and foreign key constraints. */ - saved_flags = db.flags; - saved_nChange = db.nChange; - saved_nTotalChange = db.nTotalChange; - saved_xTrace = db.xTrace; - db.flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks | SQLITE_PreferBuiltin; - db.flags &= ~( SQLITE_ForeignKeys | SQLITE_ReverseOrder ); - - db.xTrace = null; - - pMain = db.aDb[0].pBt; - isMemDb = sqlite3PagerIsMemdb( sqlite3BtreePager( pMain ) ); - - /* Attach the temporary database as 'vacuum_db'. The synchronous pragma - ** can be set to 'off' for this file, as it is not recovered if a crash - ** occurs anyway. The integrity of the database is maintained by a - ** (possibly synchronous) transaction opened on the main database before - ** sqlite3BtreeCopyFile() is called. - ** - ** An optimisation would be to use a non-journaled pager. - ** (Later:) I tried setting "PRAGMA vacuum_db.journal_mode=OFF" but - ** that actually made the VACUUM run slower. Very little journalling - ** actually occurs when doing a vacuum since the vacuum_db is initially - ** empty. Only the journal header is written. Apparently it takes more - ** time to parse and run the PRAGMA to turn journalling off than it does - ** to write the journal header file. - */ - nDb = db.nDb; - if ( sqlite3TempInMemory( db ) ) - { - zSql = "ATTACH ':memory:' AS vacuum_db;"; - } - else - { - zSql = "ATTACH '' AS vacuum_db;"; - } - rc = execSql( db, pzErrMsg, zSql ); - if ( db.nDb > nDb ) - { - pDb = db.aDb[db.nDb - 1]; - Debug.Assert( pDb.zName == "vacuum_db" ); - } - if ( rc != SQLITE_OK ) - goto end_of_vacuum; - pDb = db.aDb[db.nDb - 1]; - Debug.Assert( db.aDb[db.nDb - 1].zName == "vacuum_db" ); - pTemp = db.aDb[db.nDb - 1].pBt; - /* The call to execSql() to attach the temp database has left the file - ** locked (as there was more than one active statement when the transaction - ** to read the schema was concluded. Unlock it here so that this doesn't - ** cause problems for the call to BtreeSetPageSize() below. */ - sqlite3BtreeCommit( pTemp ); + /* + ** Execute zSql on database db. The statement returns exactly + ** one column. Execute this as SQL on the same database. + */ + static int execExecSql(sqlite3 db, string pzErrMsg, string zSql) { + sqlite3_stmt pStmt = null; + int rc; + + rc = sqlite3_prepare(db, zSql, -1, ref pStmt, 0); + if (rc != SQLITE_OK) + return rc; + + while (SQLITE_ROW == sqlite3_step(pStmt)) { + rc = execSql(db, pzErrMsg, sqlite3_column_text(pStmt, 0)); + if (rc != SQLITE_OK) { + vacuumFinalize(db, pStmt, pzErrMsg); + return rc; + } + } + + return vacuumFinalize(db, pStmt, pzErrMsg); + } - nRes = sqlite3BtreeGetReserve( pMain ); + /* + ** 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. + ** + ** 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. + */ + static void sqlite3Vacuum(Parse pParse) { + Vdbe v = sqlite3GetVdbe(pParse); + if (v != null) { + sqlite3VdbeAddOp2(v, OP_Vacuum, 0, 0); + } + return; + } - /* A VACUUM cannot change the pagesize of an encrypted database. */ + /* + ** This routine implements the OP_Vacuum opcode of the VDBE. + */ + static int sqlite3RunVacuum(ref string pzErrMsg, sqlite3 db) { + int rc = SQLITE_OK; /* Return code from service routines */ + Btree pMain; /* The database being vacuumed */ + Btree pTemp; /* The temporary database we vacuum into */ + string zSql = ""; /* SQL statements */ + int saved_flags; /* Saved value of the db.flags */ + int saved_nChange; /* Saved value of db.nChange */ + int saved_nTotalChange; /* Saved value of db.nTotalChange */ + dxTrace saved_xTrace; //void (*saved_xTrace)(void*,const char*); /* Saved db->xTrace */ + Db pDb = null; /* Database to detach at end of vacuum */ + bool isMemDb; /* True if vacuuming a :memory: database */ + int nRes; /* Bytes of reserved space at the end of each page */ + int nDb; /* Number of attached databases */ + + if (0 == db.autoCommit) { + sqlite3SetString(ref pzErrMsg, db, "cannot VACUUM from within a transaction"); + return SQLITE_ERROR; + } + if (db.activeVdbeCnt > 1) { + sqlite3SetString(ref pzErrMsg, db, "cannot VACUUM - SQL statements in progress"); + return SQLITE_ERROR; + } + + /* Save the current value of the database flags so that it can be + ** restored before returning. Then set the writable-schema flag, and + ** disable CHECK and foreign key constraints. */ + saved_flags = db.flags; + saved_nChange = db.nChange; + saved_nTotalChange = db.nTotalChange; + saved_xTrace = db.xTrace; + db.flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks | SQLITE_PreferBuiltin; + db.flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder); + + db.xTrace = null; + + pMain = db.aDb[0].pBt; + isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain)); + + /* Attach the temporary database as 'vacuum_db'. The synchronous pragma + ** can be set to 'off' for this file, as it is not recovered if a crash + ** occurs anyway. The integrity of the database is maintained by a + ** (possibly synchronous) transaction opened on the main database before + ** sqlite3BtreeCopyFile() is called. + ** + ** An optimisation would be to use a non-journaled pager. + ** (Later:) I tried setting "PRAGMA vacuum_db.journal_mode=OFF" but + ** that actually made the VACUUM run slower. Very little journalling + ** actually occurs when doing a vacuum since the vacuum_db is initially + ** empty. Only the journal header is written. Apparently it takes more + ** time to parse and run the PRAGMA to turn journalling off than it does + ** to write the journal header file. + */ + nDb = db.nDb; + if (sqlite3TempInMemory(db)) { + zSql = "ATTACH ':memory:' AS vacuum_db;"; + } else { + zSql = "ATTACH '' AS vacuum_db;"; + } + rc = execSql(db, pzErrMsg, zSql); + if (db.nDb > nDb) { + pDb = db.aDb[db.nDb - 1]; + Debug.Assert(pDb.zName == "vacuum_db"); + } + if (rc != SQLITE_OK) + goto end_of_vacuum; + pDb = db.aDb[db.nDb - 1]; + Debug.Assert(db.aDb[db.nDb - 1].zName == "vacuum_db"); + pTemp = db.aDb[db.nDb - 1].pBt; + + /* The call to execSql() to attach the temp database has left the file + ** locked (as there was more than one active statement when the transaction + ** to read the schema was concluded. Unlock it here so that this doesn't + ** cause problems for the call to BtreeSetPageSize() below. */ + sqlite3BtreeCommit(pTemp); + + nRes = sqlite3BtreeGetReserve(pMain); + + /* A VACUUM cannot change the pagesize of an encrypted database. */ #if SQLITE_HAS_CODEC if ( db.nextPagesize != 0 ) { @@ -229,187 +206,182 @@ static int sqlite3RunVacuum( ref string pzErrMsg, sqlite3 db ) } #endif - /* Do not attempt to change the page size for a WAL database */ - if ( sqlite3PagerGetJournalMode( sqlite3BtreePager( pMain ) ) - == PAGER_JOURNALMODE_WAL ) - { - db.nextPagesize = 0; - } - - if ( sqlite3BtreeSetPageSize( pTemp, sqlite3BtreeGetPageSize( pMain ), nRes, 0 ) != 0 - || ( !isMemDb && sqlite3BtreeSetPageSize( pTemp, db.nextPagesize, nRes, 0 ) != 0 ) - //|| NEVER( db.mallocFailed != 0 ) - ) - { - rc = SQLITE_NOMEM; - goto end_of_vacuum; - } - rc = execSql( db, pzErrMsg, "PRAGMA vacuum_db.synchronous=OFF" ); - if ( rc != SQLITE_OK ) - { - goto end_of_vacuum; - } + /* Do not attempt to change the page size for a WAL database */ + if (sqlite3PagerGetJournalMode(sqlite3BtreePager(pMain)) + == PAGER_JOURNALMODE_WAL) { + db.nextPagesize = 0; + } + + if (sqlite3BtreeSetPageSize(pTemp, sqlite3BtreeGetPageSize(pMain), nRes, 0) != 0 + || (!isMemDb && sqlite3BtreeSetPageSize(pTemp, db.nextPagesize, nRes, 0) != 0) + //|| NEVER( db.mallocFailed != 0 ) + ) { + rc = SQLITE_NOMEM; + goto end_of_vacuum; + } + rc = execSql(db, pzErrMsg, "PRAGMA vacuum_db.synchronous=OFF"); + if (rc != SQLITE_OK) { + goto end_of_vacuum; + } #if !SQLITE_OMIT_AUTOVACUUM - sqlite3BtreeSetAutoVacuum( pTemp, db.nextAutovac >= 0 ? db.nextAutovac : - sqlite3BtreeGetAutoVacuum( pMain ) ); + sqlite3BtreeSetAutoVacuum(pTemp, db.nextAutovac >= 0 ? db.nextAutovac : + sqlite3BtreeGetAutoVacuum(pMain)); #endif - /* Begin a transaction */ - rc = execSql( db, pzErrMsg, "BEGIN EXCLUSIVE;" ); - if ( rc != SQLITE_OK ) - goto end_of_vacuum; - - /* Query the schema of the main database. Create a mirror schema - ** in the temporary database. - */ - rc = execExecSql( db, pzErrMsg, - "SELECT 'CREATE TABLE vacuum_db.' || substr(sql,14) " + - " FROM sqlite_master WHERE type='table' AND name!='sqlite_sequence'" + - " AND rootpage>0" - ); - if ( rc != SQLITE_OK ) - goto end_of_vacuum; - rc = execExecSql( db, pzErrMsg, - "SELECT 'CREATE INDEX vacuum_db.' || substr(sql,14)" + - " FROM sqlite_master WHERE sql LIKE 'CREATE INDEX %' " ); - if ( rc != SQLITE_OK ) - goto end_of_vacuum; - rc = execExecSql( db, pzErrMsg, - "SELECT 'CREATE UNIQUE INDEX vacuum_db.' || substr(sql,21) " + - " FROM sqlite_master WHERE sql LIKE 'CREATE UNIQUE INDEX %'" ); - if ( rc != SQLITE_OK ) - goto end_of_vacuum; - - /* Loop through the tables in the main database. For each, do - ** an "INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;" to copy - ** the contents to the temporary database. - */ - rc = execExecSql( db, pzErrMsg, - "SELECT 'INSERT INTO vacuum_db.' || quote(name) " + - "|| ' SELECT * FROM main.' || quote(name) || ';'" + - "FROM main.sqlite_master " + - "WHERE type = 'table' AND name!='sqlite_sequence' " + - " AND rootpage>0" - - ); - if ( rc != SQLITE_OK ) - goto end_of_vacuum; - - /* Copy over the sequence table - */ - rc = execExecSql( db, pzErrMsg, - "SELECT 'DELETE FROM vacuum_db.' || quote(name) || ';' " + - "FROM vacuum_db.sqlite_master WHERE name='sqlite_sequence' " - ); - if ( rc != SQLITE_OK ) - goto end_of_vacuum; - rc = execExecSql( db, pzErrMsg, - "SELECT 'INSERT INTO vacuum_db.' || quote(name) " + - "|| ' SELECT * FROM main.' || quote(name) || ';' " + - "FROM vacuum_db.sqlite_master WHERE name=='sqlite_sequence';" - ); - if ( rc != SQLITE_OK ) - goto end_of_vacuum; - - - /* Copy the triggers, views, and virtual tables from the main database - ** over to the temporary database. None of these objects has any - ** associated storage, so all we have to do is copy their entries - ** from the SQLITE_MASTER table. - */ - rc = execSql( db, pzErrMsg, - "INSERT INTO vacuum_db.sqlite_master " + - " SELECT type, name, tbl_name, rootpage, sql" + - " FROM main.sqlite_master" + - " WHERE type='view' OR type='trigger'" + - " OR (type='table' AND rootpage=0)" - ); - if ( rc != 0 ) - goto end_of_vacuum; - - /* At this point, unless the main db was completely empty, there is now a - ** transaction open on the vacuum database, but not on the main database. - ** Open a btree level transaction on the main database. This allows a - ** call to sqlite3BtreeCopyFile(). The main database btree level - ** transaction is then committed, so the SQL level never knows it was - ** opened for writing. This way, the SQL transaction used to create the - ** temporary database never needs to be committed. - */ - { - u32 meta = 0; - int i; - - /* This array determines which meta meta values are preserved in the - ** vacuum. Even entries are the meta value number and odd entries - ** are an increment to apply to the meta value after the vacuum. - ** The increment is used to increase the schema cookie so that other - ** connections to the same database will know to reread the schema. - */ - byte[] aCopy = new byte[] { + /* Begin a transaction */ + rc = execSql(db, pzErrMsg, "BEGIN EXCLUSIVE;"); + if (rc != SQLITE_OK) + goto end_of_vacuum; + + /* Query the schema of the main database. Create a mirror schema + ** in the temporary database. + */ + rc = execExecSql(db, pzErrMsg, + "SELECT 'CREATE TABLE vacuum_db.' || substr(sql,14) " + + " FROM sqlite_master WHERE type='table' AND name!='sqlite_sequence'" + + " AND rootpage>0" + ); + if (rc != SQLITE_OK) + goto end_of_vacuum; + rc = execExecSql(db, pzErrMsg, + "SELECT 'CREATE INDEX vacuum_db.' || substr(sql,14)" + + " FROM sqlite_master WHERE sql LIKE 'CREATE INDEX %' "); + if (rc != SQLITE_OK) + goto end_of_vacuum; + rc = execExecSql(db, pzErrMsg, + "SELECT 'CREATE UNIQUE INDEX vacuum_db.' || substr(sql,21) " + + " FROM sqlite_master WHERE sql LIKE 'CREATE UNIQUE INDEX %'"); + if (rc != SQLITE_OK) + goto end_of_vacuum; + + /* Loop through the tables in the main database. For each, do + ** an "INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;" to copy + ** the contents to the temporary database. + */ + rc = execExecSql(db, pzErrMsg, + "SELECT 'INSERT INTO vacuum_db.' || quote(name) " + + "|| ' SELECT * FROM main.' || quote(name) || ';'" + + "FROM main.sqlite_master " + + "WHERE type = 'table' AND name!='sqlite_sequence' " + + " AND rootpage>0" + + ); + if (rc != SQLITE_OK) + goto end_of_vacuum; + + /* Copy over the sequence table + */ + rc = execExecSql(db, pzErrMsg, + "SELECT 'DELETE FROM vacuum_db.' || quote(name) || ';' " + + "FROM vacuum_db.sqlite_master WHERE name='sqlite_sequence' " + ); + if (rc != SQLITE_OK) + goto end_of_vacuum; + rc = execExecSql(db, pzErrMsg, + "SELECT 'INSERT INTO vacuum_db.' || quote(name) " + + "|| ' SELECT * FROM main.' || quote(name) || ';' " + + "FROM vacuum_db.sqlite_master WHERE name=='sqlite_sequence';" + ); + if (rc != SQLITE_OK) + goto end_of_vacuum; + + + /* Copy the triggers, views, and virtual tables from the main database + ** over to the temporary database. None of these objects has any + ** associated storage, so all we have to do is copy their entries + ** from the SQLITE_MASTER table. + */ + rc = execSql(db, pzErrMsg, + "INSERT INTO vacuum_db.sqlite_master " + + " SELECT type, name, tbl_name, rootpage, sql" + + " FROM main.sqlite_master" + + " WHERE type='view' OR type='trigger'" + + " OR (type='table' AND rootpage=0)" + ); + if (rc != 0) + goto end_of_vacuum; + + /* At this point, unless the main db was completely empty, there is now a + ** transaction open on the vacuum database, but not on the main database. + ** Open a btree level transaction on the main database. This allows a + ** call to sqlite3BtreeCopyFile(). The main database btree level + ** transaction is then committed, so the SQL level never knows it was + ** opened for writing. This way, the SQL transaction used to create the + ** temporary database never needs to be committed. + */ + { + u32 meta = 0; + int i; + + /* This array determines which meta meta values are preserved in the + ** vacuum. Even entries are the meta value number and odd entries + ** are an increment to apply to the meta value after the vacuum. + ** The increment is used to increase the schema cookie so that other + ** connections to the same database will know to reread the schema. + */ + byte[] aCopy = new byte[] { BTREE_SCHEMA_VERSION, 1, /* Add one to the old schema cookie */ BTREE_DEFAULT_CACHE_SIZE, 0, /* Preserve the default page cache size */ BTREE_TEXT_ENCODING, 0, /* Preserve the text encoding */ BTREE_USER_VERSION, 0, /* Preserve the user version */ }; - Debug.Assert( sqlite3BtreeIsInTrans( pTemp ) ); - Debug.Assert( sqlite3BtreeIsInTrans( pMain ) ); - - /* Copy Btree meta values */ - for ( i = 0; i < ArraySize( aCopy ); i += 2 ) - { - /* GetMeta() and UpdateMeta() cannot fail in this context because - ** we already have page 1 loaded into cache and marked dirty. */ - sqlite3BtreeGetMeta( pMain, aCopy[i], ref meta ); - rc = sqlite3BtreeUpdateMeta( pTemp, aCopy[i], (u32)( meta + aCopy[i + 1] ) ); - if ( NEVER( rc != SQLITE_OK ) ) - goto end_of_vacuum; - } - - rc = sqlite3BtreeCopyFile( pMain, pTemp ); - if ( rc != SQLITE_OK ) - goto end_of_vacuum; - rc = sqlite3BtreeCommit( pTemp ); - if ( rc != SQLITE_OK ) - goto end_of_vacuum; + Debug.Assert(sqlite3BtreeIsInTrans(pTemp)); + Debug.Assert(sqlite3BtreeIsInTrans(pMain)); + + /* Copy Btree meta values */ + for (i = 0; i < ArraySize(aCopy); i += 2) { + /* GetMeta() and UpdateMeta() cannot fail in this context because + ** we already have page 1 loaded into cache and marked dirty. */ + sqlite3BtreeGetMeta(pMain, aCopy[i], ref meta); + rc = sqlite3BtreeUpdateMeta(pTemp, aCopy[i], (u32)(meta + aCopy[i + 1])); + if (NEVER(rc != SQLITE_OK)) + goto end_of_vacuum; + } + + rc = sqlite3BtreeCopyFile(pMain, pTemp); + if (rc != SQLITE_OK) + goto end_of_vacuum; + rc = sqlite3BtreeCommit(pTemp); + if (rc != SQLITE_OK) + goto end_of_vacuum; #if !SQLITE_OMIT_AUTOVACUUM - sqlite3BtreeSetAutoVacuum( pMain, sqlite3BtreeGetAutoVacuum( pTemp ) ); + sqlite3BtreeSetAutoVacuum(pMain, sqlite3BtreeGetAutoVacuum(pTemp)); #endif - } - Debug.Assert( rc == SQLITE_OK ); - rc = sqlite3BtreeSetPageSize( pMain, sqlite3BtreeGetPageSize( pTemp ), nRes, 1 ); - -end_of_vacuum: - /* Restore the original value of db.flags */ - db.flags = saved_flags; - db.nChange = saved_nChange; - db.nTotalChange = saved_nTotalChange; - db.xTrace = saved_xTrace; - sqlite3BtreeSetPageSize( pMain, -1, -1, 1 ); - - /* Currently there is an SQL level transaction open on the vacuum - ** database. No locks are held on any other files (since the main file - ** was committed at the btree level). So it safe to end the transaction - ** by manually setting the autoCommit flag to true and detaching the - ** vacuum database. The vacuum_db journal file is deleted when the pager - ** is closed by the DETACH. - */ - db.autoCommit = 1; - - if ( pDb != null ) - { - sqlite3BtreeClose( ref pDb.pBt ); - pDb.pBt = null; - pDb.pSchema = null; - } - - /* This both clears the schemas and reduces the size of the db->aDb[] - ** array. */ - sqlite3ResetInternalSchema( db, -1 ); - - return rc; - } + } + Debug.Assert(rc == SQLITE_OK); + rc = sqlite3BtreeSetPageSize(pMain, sqlite3BtreeGetPageSize(pTemp), nRes, 1); + + end_of_vacuum: + /* Restore the original value of db.flags */ + db.flags = saved_flags; + db.nChange = saved_nChange; + db.nTotalChange = saved_nTotalChange; + db.xTrace = saved_xTrace; + sqlite3BtreeSetPageSize(pMain, -1, -1, 1); + + /* Currently there is an SQL level transaction open on the vacuum + ** database. No locks are held on any other files (since the main file + ** was committed at the btree level). So it safe to end the transaction + ** by manually setting the autoCommit flag to true and detaching the + ** vacuum database. The vacuum_db journal file is deleted when the pager + ** is closed by the DETACH. + */ + db.autoCommit = 1; + + if (pDb != null) { + sqlite3BtreeClose(ref pDb.pBt); + pDb.pBt = null; + pDb.pSchema = null; + } + + /* This both clears the schemas and reduces the size of the db->aDb[] + ** array. */ + sqlite3ResetInternalSchema(db, -1); + + return rc; + } #endif // * SQLITE_OMIT_VACUUM && SQLITE_OMIT_ATTACH */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/vdbe_c.cs b/Src/IronPython.SQLite/c#sqlite/vdbe_c.cs index adba5fe7a..39de09c6d 100644 --- a/Src/IronPython.SQLite/c#sqlite/vdbe_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/vdbe_c.cs @@ -1,10 +1,7 @@ using System.Diagnostics; -using System.IO; using System.Text; using FILE = System.IO.TextWriter; - -using i32 = System.Int32; using i64 = System.Int64; using sqlite_int64 = System.Int64; @@ -12,10 +9,6 @@ using u16 = System.UInt16; using u32 = System.UInt32; using u64 = System.UInt64; - -using sqlite3_int64 = System.Int64; - -using Pgno = System.UInt32; /* ** The yDbMask datatype for the bitmask of all attached databases. */ @@ -27,93 +20,91 @@ using yDbMask = System.Int32; #endif -namespace Community.CsharpSqlite -{ - using sqlite3_value = Sqlite3.Mem; - using Op = Sqlite3.VdbeOp; - using System; - - public partial class Sqlite3 - { - /* - ** 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. - ** - ************************************************************************* - ** The code in this file implements execution method of the - ** Virtual Database Engine (VDBE). A separate file ("vdbeaux.c") - ** handles housekeeping details such as creating and deleting - ** VDBE instances. This file is solely interested in executing - ** the VDBE program. - ** - ** In the external interface, an "sqlite3_stmt*" is an opaque pointer - ** to a VDBE. - ** - ** The SQL parser generates a program which is then executed by - ** the VDBE to do the work of the SQL statement. VDBE programs are - ** similar in form to assembly language. The program consists of - ** a linear sequence of operations. Each operation has an opcode - ** and 5 operands. Operands P1, P2, and P3 are integers. Operand P4 - ** is a null-terminated string. Operand P5 is an unsigned character. - ** Few opcodes use all 5 operands. - ** - ** Computation results are stored on a set of registers numbered beginning - ** with 1 and going up to Vdbe.nMem. Each register can store - ** either an integer, a null-terminated string, a floating point - ** number, or the SQL "NULL" value. An implicit conversion from one - ** type to the other occurs as necessary. - ** - ** Most of the code in this file is taken up by the sqlite3VdbeExec() - ** function which does the work of interpreting a VDBE program. - ** But other routines are also provided to help in building up - ** a program instruction by instruction. - ** - ** Various scripts scan this source file in order to generate HTML - ** documentation, headers files, or other derived files. The formatting - ** of the code in this file is, therefore, important. See other comments - ** in this file for details. If in doubt, do not deviate from existing - ** commenting and indentation practices when changing or adding code. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include "vdbeInt.h" +namespace Community.CsharpSqlite { + using System; + + using Op = Sqlite3.VdbeOp; + using sqlite3_value = Sqlite3.Mem; + + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** The code in this file implements execution method of the + ** Virtual Database Engine (VDBE). A separate file ("vdbeaux.c") + ** handles housekeeping details such as creating and deleting + ** VDBE instances. This file is solely interested in executing + ** the VDBE program. + ** + ** In the external interface, an "sqlite3_stmt*" is an opaque pointer + ** to a VDBE. + ** + ** The SQL parser generates a program which is then executed by + ** the VDBE to do the work of the SQL statement. VDBE programs are + ** similar in form to assembly language. The program consists of + ** a linear sequence of operations. Each operation has an opcode + ** and 5 operands. Operands P1, P2, and P3 are integers. Operand P4 + ** is a null-terminated string. Operand P5 is an unsigned character. + ** Few opcodes use all 5 operands. + ** + ** Computation results are stored on a set of registers numbered beginning + ** with 1 and going up to Vdbe.nMem. Each register can store + ** either an integer, a null-terminated string, a floating point + ** number, or the SQL "NULL" value. An implicit conversion from one + ** type to the other occurs as necessary. + ** + ** Most of the code in this file is taken up by the sqlite3VdbeExec() + ** function which does the work of interpreting a VDBE program. + ** But other routines are also provided to help in building up + ** a program instruction by instruction. + ** + ** Various scripts scan this source file in order to generate HTML + ** documentation, headers files, or other derived files. The formatting + ** of the code in this file is, therefore, important. See other comments + ** in this file for details. If in doubt, do not deviate from existing + ** commenting and indentation practices when changing or adding code. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include "vdbeInt.h" - /* - ** Invoke this macro on memory cells just prior to changing the - ** value of the cell. This macro verifies that shallow copies are - ** not misused. - */ + /* + ** Invoke this macro on memory cells just prior to changing the + ** value of the cell. This macro verifies that shallow copies are + ** not misused. + */ #if SQLITE_DEBUG - //# define memAboutToChange(P,M) sqlite3VdbeMemPrepareToChange(P,M) - static void memAboutToChange( Vdbe P, Mem M ) - { - sqlite3VdbeMemPrepareToChange( P, M ); - } + //# define memAboutToChange(P,M) sqlite3VdbeMemPrepareToChange(P,M) + static void memAboutToChange(Vdbe P, Mem M) { + sqlite3VdbeMemPrepareToChange(P, M); + } #else //# define memAboutToChange(P,M) static void memAboutToChange(Vdbe P, Mem M) {} #endif - /* -** The following global variable is incremented every time a cursor -** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes. The test -** procedures use this information to make sure that indices are -** working correctly. This variable has no function other than to -** help verify the correct operation of the library. -*/ -#if SQLITE_TEST + /* + ** The following global variable is incremented every time a cursor + ** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes. The test + ** procedures use this information to make sure that indices are + ** working correctly. This variable has no function other than to + ** help verify the correct operation of the library. + */ +#if SQLITE_TEST #if !TCLSH static int sqlite3_search_count = 0; #else @@ -121,14 +112,14 @@ static void memAboutToChange(Vdbe P, Mem M) {} #endif #endif - /* -** When this global variable is positive, it gets decremented once before -** each instruction in the VDBE. When reaches zero, the u1.isInterrupted -** field of the sqlite3 structure is set in order to simulate and interrupt. -** -** This facility is used for testing purposes only. It does not function -** in an ordinary build. -*/ + /* + ** When this global variable is positive, it gets decremented once before + ** each instruction in the VDBE. When reaches zero, the u1.isInterrupted + ** field of the sqlite3 structure is set in order to simulate and interrupt. + ** + ** This facility is used for testing purposes only. It does not function + ** in an ordinary build. + */ #if SQLITE_TEST #if !TCLSH static int sqlite3_interrupt_count = 0; @@ -137,13 +128,13 @@ static void memAboutToChange(Vdbe P, Mem M) {} #endif #endif - /* -** The next global variable is incremented each type the OP_Sort opcode -** is executed. The test procedures use this information to make sure that -** sorting is occurring or not occurring at appropriate times. This variable -** has no function other than to help verify the correct operation of the -** library. -*/ + /* + ** The next global variable is incremented each type the OP_Sort opcode + ** is executed. The test procedures use this information to make sure that + ** sorting is occurring or not occurring at appropriate times. This variable + ** has no function other than to help verify the correct operation of the + ** library. + */ #if SQLITE_TEST #if !TCLSH static int sqlite3_sort_count = 0; @@ -152,13 +143,13 @@ static void memAboutToChange(Vdbe P, Mem M) {} #endif #endif - /* -** The next global variable records the size of the largest MEM_Blob -** or MEM_Str that has been used by a VDBE opcode. The test procedures -** use this information to make sure that the zero-blob functionality -** is working correctly. This variable has no function other than to -** help verify the correct operation of the library. -*/ + /* + ** The next global variable records the size of the largest MEM_Blob + ** or MEM_Str that has been used by a VDBE opcode. The test procedures + ** use this information to make sure that the zero-blob functionality + ** is working correctly. This variable has no function other than to + ** help verify the correct operation of the library. + */ #if SQLITE_TEST #if !TCLSH static int sqlite3_max_blobsize = 0; @@ -182,13 +173,13 @@ static void updateMaxBlobsize( Mem p ) } #endif - /* -** The next global variable is incremented each type the OP_Found opcode -** is executed. This is used to test whether or not the foreign key -** operation implemented using OP_FkIsZero is working. This variable -** has no function other than to help verify the correct operation of the -** library. -*/ + /* + ** The next global variable is incremented each type the OP_Found opcode + ** is executed. This is used to test whether or not the foreign key + ** operation implemented using OP_FkIsZero is working. This variable + ** has no function other than to help verify the correct operation of the + ** library. + */ #if SQLITE_TEST #if !TCLSH static int sqlite3_found_count = 0; @@ -197,435 +188,365 @@ static void updateMaxBlobsize( Mem p ) #endif #endif + /* /* -/* -** Test a register to see if it exceeds the current maximum blob size. -** If it does, record the new maximum blob size. -*/ + ** Test a register to see if it exceeds the current maximum blob size. + ** If it does, record the new maximum blob size. + */ #if SQLITE_TEST && !SQLITE_OMIT_BUILTIN_TEST static void UPDATE_MAX_BLOBSIZE( Mem P ) { updateMaxBlobsize( P ); } #else -//# define UPDATE_MAX_BLOBSIZE(P) -static void UPDATE_MAX_BLOBSIZE( Mem P ) { } + //# define UPDATE_MAX_BLOBSIZE(P) + static void UPDATE_MAX_BLOBSIZE(Mem P) { } #endif - /* -** Convert the given register into a string if it isn't one -** already. Return non-zero if a malloc() fails. -*/ - //#define Stringify(P, enc) \ - // if(((P).flags&(MEM_Str|MEM_Blob))==0 && sqlite3VdbeMemStringify(P,enc)) \ - // { goto no_mem; } - - /* - ** An ephemeral string value (signified by the MEM_Ephem flag) contains - ** a pointer to a dynamically allocated string where some other entity - ** is responsible for deallocating that string. Because the register - ** does not control the string, it might be deleted without the register - ** knowing it. - ** - ** This routine converts an ephemeral string into a dynamically allocated - ** string that the register itself controls. In other words, it - ** converts an MEM_Ephem string into an MEM_Dyn string. - */ - //#define Deephemeralize(P) \ - // if( ((P).flags&MEM_Ephem)!=0 \ - // && sqlite3VdbeMemMakeWriteable(P) ){ goto no_mem;} - static void Deephemeralize( Mem P ) - { - } - - /* - ** Call sqlite3VdbeMemExpandBlob() on the supplied value (type Mem) - ** P if required. - */ - //#define ExpandBlob(P) (((P).flags&MEM_Zero)?sqlite3VdbeMemExpandBlob(P):0) - static int ExpandBlob( Mem P ) - { - return ( P.flags & MEM_Zero ) != 0 ? sqlite3VdbeMemExpandBlob( P ) : 0; - } - - /* - ** Argument pMem points at a register that will be passed to a - ** user-defined function or returned to the user as the result of a query. - ** This routine sets the pMem.type variable used by the sqlite3_value_*() - ** routines. - */ - static void sqlite3VdbeMemStoreType( Mem pMem ) - { - int flags = pMem.flags; - if ( ( flags & MEM_Null ) != 0 ) - { - pMem.type = SQLITE_NULL; - pMem.z = null; - pMem.zBLOB = null; - } - else if ( ( flags & MEM_Int ) != 0 ) - { - pMem.type = SQLITE_INTEGER; - } - else if ( ( flags & MEM_Real ) != 0 ) - { - pMem.type = SQLITE_FLOAT; - } - else if ( ( flags & MEM_Str ) != 0 ) - { - pMem.type = SQLITE_TEXT; - } - else - { - pMem.type = SQLITE_BLOB; - } - } - - /* - ** Allocate VdbeCursor number iCur. Return a pointer to it. Return NULL - ** if we run out of memory. + /* + ** Convert the given register into a string if it isn't one + ** already. Return non-zero if a malloc() fails. */ - static VdbeCursor allocateCursor( - Vdbe p, /* The virtual machine */ - int iCur, /* Index of the new VdbeCursor */ - int nField, /* Number of fields in the table or index */ - int iDb, /* When database the cursor belongs to, or -1 */ - int isBtreeCursor /* True for B-Tree. False for pseudo-table or vtab */ - ) - { - /* Find the memory cell that will be used to store the blob of memory - ** required for this VdbeCursor structure. It is convenient to use a - ** vdbe memory cell to manage the memory allocation required for a - ** VdbeCursor structure for the following reasons: - ** - ** * Sometimes cursor numbers are used for a couple of different - ** purposes in a vdbe program. The different uses might require - ** different sized allocations. Memory cells provide growable - ** allocations. - ** - ** * When using ENABLE_MEMORY_MANAGEMENT, memory cell buffers can - ** be freed lazily via the sqlite3_release_memory() API. This - ** minimizes the number of malloc calls made by the system. - ** - ** Memory cells for cursors are allocated at the top of the address - ** space. Memory cell (p.nMem) corresponds to cursor 0. Space for - ** cursor 1 is managed by memory cell (p.nMem-1), etc. - */ - //Mem pMem = p.aMem[p.nMem - iCur]; - - //int nByte; - VdbeCursor pCx = null; - //ROUND8(sizeof(VdbeCursor)) + - //( isBtreeCursor ? sqlite3BtreeCursorSize() : 0 ) + - //2 * nField * sizeof( u32 ); - - Debug.Assert( iCur < p.nCursor ); - if ( p.apCsr[iCur] != null ) - { - sqlite3VdbeFreeCursor( p, p.apCsr[iCur] ); - p.apCsr[iCur] = null; - } - //if ( SQLITE_OK == sqlite3VdbeMemGrow( pMem, nByte, 0 ) ) - { - p.apCsr[iCur] = pCx = new VdbeCursor();// (VdbeCursor)pMem.z; - //memset(pCx, 0, sizeof(VdbeCursor)); - pCx.iDb = iDb; - pCx.nField = nField; - if ( nField != 0 ) - { - pCx.aType = new u32[nField];// (u32)&pMem.z[ROUND8(sizeof( VdbeCursor ))]; - } - if ( isBtreeCursor != 0 ) - { - pCx.pCursor = sqlite3MemMallocBtCursor( pCx.pCursor );// (BtCursor)&pMem.z[ROUND8(sizeof( VdbeCursor )) + 2 * nField * sizeof( u32 )]; - sqlite3BtreeCursorZero( pCx.pCursor ); + //#define Stringify(P, enc) \ + // if(((P).flags&(MEM_Str|MEM_Blob))==0 && sqlite3VdbeMemStringify(P,enc)) \ + // { goto no_mem; } + + /* + ** An ephemeral string value (signified by the MEM_Ephem flag) contains + ** a pointer to a dynamically allocated string where some other entity + ** is responsible for deallocating that string. Because the register + ** does not control the string, it might be deleted without the register + ** knowing it. + ** + ** This routine converts an ephemeral string into a dynamically allocated + ** string that the register itself controls. In other words, it + ** converts an MEM_Ephem string into an MEM_Dyn string. + */ + //#define Deephemeralize(P) \ + // if( ((P).flags&MEM_Ephem)!=0 \ + // && sqlite3VdbeMemMakeWriteable(P) ){ goto no_mem;} + static void Deephemeralize(Mem P) { } - } - return pCx; - } - /* - ** Try to convert a value into a numeric representation if we can - ** do so without loss of information. In other words, if the string - ** looks like a number, convert it into a number. If it does not - ** look like a number, leave it alone. - */ - static void applyNumericAffinity( Mem pRec ) - { - if ( ( pRec.flags & ( MEM_Real | MEM_Int ) ) == 0 ) - { - double rValue = 0.0; - i64 iValue = 0; - u8 enc = pRec.enc; - if ( ( pRec.flags & MEM_Str ) == 0 ) - return; - if ( sqlite3AtoF( pRec.z, ref rValue, pRec.n, enc ) == false ) - return; - if ( 0 == sqlite3Atoi64( pRec.z, ref iValue, pRec.n, enc ) ) - { - pRec.u.i = iValue; - pRec.flags |= MEM_Int; + /* + ** Call sqlite3VdbeMemExpandBlob() on the supplied value (type Mem) + ** P if required. + */ + //#define ExpandBlob(P) (((P).flags&MEM_Zero)?sqlite3VdbeMemExpandBlob(P):0) + static int ExpandBlob(Mem P) { + return (P.flags & MEM_Zero) != 0 ? sqlite3VdbeMemExpandBlob(P) : 0; } - else - { - pRec.r = rValue; - pRec.flags |= MEM_Real; + + /* + ** Argument pMem points at a register that will be passed to a + ** user-defined function or returned to the user as the result of a query. + ** This routine sets the pMem.type variable used by the sqlite3_value_*() + ** routines. + */ + static void sqlite3VdbeMemStoreType(Mem pMem) { + int flags = pMem.flags; + if ((flags & MEM_Null) != 0) { + pMem.type = SQLITE_NULL; + pMem.z = null; + pMem.zBLOB = null; + } else if ((flags & MEM_Int) != 0) { + pMem.type = SQLITE_INTEGER; + } else if ((flags & MEM_Real) != 0) { + pMem.type = SQLITE_FLOAT; + } else if ((flags & MEM_Str) != 0) { + pMem.type = SQLITE_TEXT; + } else { + pMem.type = SQLITE_BLOB; + } } - } - } - /* - ** Processing is determine by the affinity parameter: - ** - ** SQLITE_AFF_INTEGER: - ** SQLITE_AFF_REAL: - ** SQLITE_AFF_NUMERIC: - ** Try to convert pRec to an integer representation or a - ** floating-point representation if an integer representation - ** is not possible. Note that the integer representation is - ** always preferred, even if the affinity is REAL, because - ** an integer representation is more space efficient on disk. - ** - ** SQLITE_AFF_TEXT: - ** Convert pRec to a text representation. - ** - ** SQLITE_AFF_NONE: - ** No-op. pRec is unchanged. - */ - static void applyAffinity( - Mem pRec, /* The value to apply affinity to */ - char affinity, /* The affinity to be applied */ - int enc /* Use this text encoding */ - ) - { - if ( affinity == SQLITE_AFF_TEXT ) - { - /* Only attempt the conversion to TEXT if there is an integer or real - ** representation (blob and NULL do not get converted) but no string - ** representation. + /* + ** Allocate VdbeCursor number iCur. Return a pointer to it. Return NULL + ** if we run out of memory. */ - if ( 0 == ( pRec.flags & MEM_Str ) && ( pRec.flags & ( MEM_Real | MEM_Int ) ) != 0 ) - { - sqlite3VdbeMemStringify( pRec, enc ); + static VdbeCursor allocateCursor( + Vdbe p, /* The virtual machine */ + int iCur, /* Index of the new VdbeCursor */ + int nField, /* Number of fields in the table or index */ + int iDb, /* When database the cursor belongs to, or -1 */ + int isBtreeCursor /* True for B-Tree. False for pseudo-table or vtab */ + ) { + /* Find the memory cell that will be used to store the blob of memory + ** required for this VdbeCursor structure. It is convenient to use a + ** vdbe memory cell to manage the memory allocation required for a + ** VdbeCursor structure for the following reasons: + ** + ** * Sometimes cursor numbers are used for a couple of different + ** purposes in a vdbe program. The different uses might require + ** different sized allocations. Memory cells provide growable + ** allocations. + ** + ** * When using ENABLE_MEMORY_MANAGEMENT, memory cell buffers can + ** be freed lazily via the sqlite3_release_memory() API. This + ** minimizes the number of malloc calls made by the system. + ** + ** Memory cells for cursors are allocated at the top of the address + ** space. Memory cell (p.nMem) corresponds to cursor 0. Space for + ** cursor 1 is managed by memory cell (p.nMem-1), etc. + */ + //Mem pMem = p.aMem[p.nMem - iCur]; + + //int nByte; + VdbeCursor pCx = null; + //ROUND8(sizeof(VdbeCursor)) + + //( isBtreeCursor ? sqlite3BtreeCursorSize() : 0 ) + + //2 * nField * sizeof( u32 ); + + Debug.Assert(iCur < p.nCursor); + if (p.apCsr[iCur] != null) { + sqlite3VdbeFreeCursor(p, p.apCsr[iCur]); + p.apCsr[iCur] = null; + } + //if ( SQLITE_OK == sqlite3VdbeMemGrow( pMem, nByte, 0 ) ) + { + p.apCsr[iCur] = pCx = new VdbeCursor();// (VdbeCursor)pMem.z; + //memset(pCx, 0, sizeof(VdbeCursor)); + pCx.iDb = iDb; + pCx.nField = nField; + if (nField != 0) { + pCx.aType = new u32[nField];// (u32)&pMem.z[ROUND8(sizeof( VdbeCursor ))]; + } + if (isBtreeCursor != 0) { + pCx.pCursor = sqlite3MemMallocBtCursor(pCx.pCursor);// (BtCursor)&pMem.z[ROUND8(sizeof( VdbeCursor )) + 2 * nField * sizeof( u32 )]; + sqlite3BtreeCursorZero(pCx.pCursor); + } + } + return pCx; } - if ( ( pRec.flags & ( MEM_Blob | MEM_Str ) ) == ( MEM_Blob | MEM_Str ) ) - { - StringBuilder sb = new StringBuilder( pRec.zBLOB.Length ); - for ( int i = 0; i < pRec.zBLOB.Length; i++ ) - sb.Append( (char)pRec.zBLOB[i] ); - pRec.z = sb.ToString(); - sqlite3_free( ref pRec.zBLOB ); - pRec.flags = (u16)( pRec.flags & ~MEM_Blob ); + + /* + ** Try to convert a value into a numeric representation if we can + ** do so without loss of information. In other words, if the string + ** looks like a number, convert it into a number. If it does not + ** look like a number, leave it alone. + */ + static void applyNumericAffinity(Mem pRec) { + if ((pRec.flags & (MEM_Real | MEM_Int)) == 0) { + double rValue = 0.0; + i64 iValue = 0; + u8 enc = pRec.enc; + if ((pRec.flags & MEM_Str) == 0) + return; + if (sqlite3AtoF(pRec.z, ref rValue, pRec.n, enc) == false) + return; + if (0 == sqlite3Atoi64(pRec.z, ref iValue, pRec.n, enc)) { + pRec.u.i = iValue; + pRec.flags |= MEM_Int; + } else { + pRec.r = rValue; + pRec.flags |= MEM_Real; + } + } } - pRec.flags = (u16)( pRec.flags & ~( MEM_Real | MEM_Int ) ); - } - else if ( affinity != SQLITE_AFF_NONE ) - { - Debug.Assert( affinity == SQLITE_AFF_INTEGER || affinity == SQLITE_AFF_REAL - || affinity == SQLITE_AFF_NUMERIC ); - applyNumericAffinity( pRec ); - if ( ( pRec.flags & MEM_Real ) != 0 ) - { - sqlite3VdbeIntegerAffinity( pRec ); + + /* + ** Processing is determine by the affinity parameter: + ** + ** SQLITE_AFF_INTEGER: + ** SQLITE_AFF_REAL: + ** SQLITE_AFF_NUMERIC: + ** Try to convert pRec to an integer representation or a + ** floating-point representation if an integer representation + ** is not possible. Note that the integer representation is + ** always preferred, even if the affinity is REAL, because + ** an integer representation is more space efficient on disk. + ** + ** SQLITE_AFF_TEXT: + ** Convert pRec to a text representation. + ** + ** SQLITE_AFF_NONE: + ** No-op. pRec is unchanged. + */ + static void applyAffinity( + Mem pRec, /* The value to apply affinity to */ + char affinity, /* The affinity to be applied */ + int enc /* Use this text encoding */ + ) { + if (affinity == SQLITE_AFF_TEXT) { + /* Only attempt the conversion to TEXT if there is an integer or real + ** representation (blob and NULL do not get converted) but no string + ** representation. + */ + if (0 == (pRec.flags & MEM_Str) && (pRec.flags & (MEM_Real | MEM_Int)) != 0) { + sqlite3VdbeMemStringify(pRec, enc); + } + if ((pRec.flags & (MEM_Blob | MEM_Str)) == (MEM_Blob | MEM_Str)) { + StringBuilder sb = new StringBuilder(pRec.zBLOB.Length); + for (int i = 0; i < pRec.zBLOB.Length; i++) + sb.Append((char)pRec.zBLOB[i]); + pRec.z = sb.ToString(); + sqlite3_free(ref pRec.zBLOB); + pRec.flags = (u16)(pRec.flags & ~MEM_Blob); + } + pRec.flags = (u16)(pRec.flags & ~(MEM_Real | MEM_Int)); + } else if (affinity != SQLITE_AFF_NONE) { + Debug.Assert(affinity == SQLITE_AFF_INTEGER || affinity == SQLITE_AFF_REAL + || affinity == SQLITE_AFF_NUMERIC); + applyNumericAffinity(pRec); + if ((pRec.flags & MEM_Real) != 0) { + sqlite3VdbeIntegerAffinity(pRec); + } + } } - } - } - /* - ** Try to convert the type of a function argument or a result column - ** into a numeric representation. Use either INTEGER or REAL whichever - ** is appropriate. But only do the conversion if it is possible without - ** loss of information and return the revised type of the argument. - */ - static int sqlite3_value_numeric_type( sqlite3_value pVal ) - { - Mem pMem = (Mem)pVal; - if ( pMem.type == SQLITE_TEXT ) - { - applyNumericAffinity( pMem ); - sqlite3VdbeMemStoreType( pMem ); - } - return pMem.type; - } + /* + ** Try to convert the type of a function argument or a result column + ** into a numeric representation. Use either INTEGER or REAL whichever + ** is appropriate. But only do the conversion if it is possible without + ** loss of information and return the revised type of the argument. + */ + static int sqlite3_value_numeric_type(sqlite3_value pVal) { + Mem pMem = (Mem)pVal; + if (pMem.type == SQLITE_TEXT) { + applyNumericAffinity(pMem); + sqlite3VdbeMemStoreType(pMem); + } + return pMem.type; + } - /* - ** Exported version of applyAffinity(). This one works on sqlite3_value*, - ** not the internal Mem type. - */ - static void sqlite3ValueApplyAffinity( - sqlite3_value pVal, - char affinity, - int enc - ) - { - applyAffinity( (Mem)pVal, affinity, enc ); - } + /* + ** Exported version of applyAffinity(). This one works on sqlite3_value*, + ** not the internal Mem type. + */ + static void sqlite3ValueApplyAffinity( + sqlite3_value pVal, + char affinity, + int enc + ) { + applyAffinity((Mem)pVal, affinity, enc); + } #if SQLITE_DEBUG - /* -** Write a nice string representation of the contents of cell pMem -** into buffer zBuf, length nBuf. -*/ - static StringBuilder zCsr = new StringBuilder( 100 ); - static void sqlite3VdbeMemPrettyPrint( Mem pMem, StringBuilder zBuf ) - { - zBuf.Length = 0; - zCsr.Length = 0; - int f = pMem.flags; - - string[] encnames = new string[] { "(X)", "(8)", "(16LE)", "(16BE)" }; - - if ( ( f & MEM_Blob ) != 0 ) - { - int i; - char c; - if ( ( f & MEM_Dyn ) != 0 ) - { - c = 'z'; - Debug.Assert( ( f & ( MEM_Static | MEM_Ephem ) ) == 0 ); - } - else if ( ( f & MEM_Static ) != 0 ) - { - c = 't'; - Debug.Assert( ( f & ( MEM_Dyn | MEM_Ephem ) ) == 0 ); - } - else if ( ( f & MEM_Ephem ) != 0 ) - { - c = 'e'; - Debug.Assert( ( f & ( MEM_Static | MEM_Dyn ) ) == 0 ); - } - else - { - c = 's'; - } + /* + ** Write a nice string representation of the contents of cell pMem + ** into buffer zBuf, length nBuf. + */ + static StringBuilder zCsr = new StringBuilder(100); + static void sqlite3VdbeMemPrettyPrint(Mem pMem, StringBuilder zBuf) { + zBuf.Length = 0; + zCsr.Length = 0; + int f = pMem.flags; + + string[] encnames = new string[] { "(X)", "(8)", "(16LE)", "(16BE)" }; + + if ((f & MEM_Blob) != 0) { + int i; + char c; + if ((f & MEM_Dyn) != 0) { + c = 'z'; + Debug.Assert((f & (MEM_Static | MEM_Ephem)) == 0); + } else if ((f & MEM_Static) != 0) { + c = 't'; + Debug.Assert((f & (MEM_Dyn | MEM_Ephem)) == 0); + } else if ((f & MEM_Ephem) != 0) { + c = 'e'; + Debug.Assert((f & (MEM_Static | MEM_Dyn)) == 0); + } else { + c = 's'; + } - sqlite3_snprintf( 100, zCsr, "%c", c ); - zBuf.Append( zCsr );//zCsr += sqlite3Strlen30(zCsr); - sqlite3_snprintf( 100, zCsr, "%d[", pMem.n ); - zBuf.Append( zCsr );//zCsr += sqlite3Strlen30(zCsr); - for ( i = 0; i < 16 && i < pMem.n; i++ ) - { - sqlite3_snprintf( 100, zCsr, "%02X", ( (int)pMem.zBLOB[i] & 0xFF ) ); - zBuf.Append( zCsr );//zCsr += sqlite3Strlen30(zCsr); - } - for ( i = 0; i < 16 && i < pMem.n; i++ ) - { - char z = (char)pMem.zBLOB[i]; - if ( z < 32 || z > 126 ) - zBuf.Append( '.' );//*zCsr++ = '.'; - else - zBuf.Append( z );//*zCsr++ = z; - } + sqlite3_snprintf(100, zCsr, "%c", c); + zBuf.Append(zCsr);//zCsr += sqlite3Strlen30(zCsr); + sqlite3_snprintf(100, zCsr, "%d[", pMem.n); + zBuf.Append(zCsr);//zCsr += sqlite3Strlen30(zCsr); + for (i = 0; i < 16 && i < pMem.n; i++) { + sqlite3_snprintf(100, zCsr, "%02X", ((int)pMem.zBLOB[i] & 0xFF)); + zBuf.Append(zCsr);//zCsr += sqlite3Strlen30(zCsr); + } + for (i = 0; i < 16 && i < pMem.n; i++) { + char z = (char)pMem.zBLOB[i]; + if (z < 32 || z > 126) + zBuf.Append('.');//*zCsr++ = '.'; + else + zBuf.Append(z);//*zCsr++ = z; + } - sqlite3_snprintf( 100, zCsr, "]%s", encnames[pMem.enc] ); - zBuf.Append( zCsr );//zCsr += sqlite3Strlen30(zCsr); - if ( ( f & MEM_Zero ) != 0 ) - { - sqlite3_snprintf( 100, zCsr, "+%dz", pMem.u.nZero ); - zBuf.Append( zCsr );//zCsr += sqlite3Strlen30(zCsr); - } - //*zCsr = '\0'; - } - else if ( ( f & MEM_Str ) != 0 ) - { - int j;//, k; - zBuf.Append( ' ' ); - if ( ( f & MEM_Dyn ) != 0 ) - { - zBuf.Append( 'z' ); - Debug.Assert( ( f & ( MEM_Static | MEM_Ephem ) ) == 0 ); - } - else if ( ( f & MEM_Static ) != 0 ) - { - zBuf.Append( 't' ); - Debug.Assert( ( f & ( MEM_Dyn | MEM_Ephem ) ) == 0 ); - } - else if ( ( f & MEM_Ephem ) != 0 ) - { - zBuf.Append( 's' ); //zBuf.Append( 'e' ); - Debug.Assert( ( f & ( MEM_Static | MEM_Dyn ) ) == 0 ); - } - else - { - zBuf.Append( 's' ); - } - //k = 2; - sqlite3_snprintf( 100, zCsr, "%d", pMem.n );//zBuf[k], "%d", pMem.n ); - zBuf.Append( zCsr ); - //k += sqlite3Strlen30( &zBuf[k] ); - zBuf.Append( '[' );// zBuf[k++] = '['; - for ( j = 0; j < 15 && j < pMem.n; j++ ) - { - u8 c = pMem.z != null ? (u8)pMem.z[j] : pMem.zBLOB[j]; - if ( c >= 0x20 && c < 0x7f ) - { - zBuf.Append( (char)c );//zBuf[k++] = c; - } - else - { - zBuf.Append( '.' );//zBuf[k++] = '.'; - } + sqlite3_snprintf(100, zCsr, "]%s", encnames[pMem.enc]); + zBuf.Append(zCsr);//zCsr += sqlite3Strlen30(zCsr); + if ((f & MEM_Zero) != 0) { + sqlite3_snprintf(100, zCsr, "+%dz", pMem.u.nZero); + zBuf.Append(zCsr);//zCsr += sqlite3Strlen30(zCsr); + } + //*zCsr = '\0'; + } else if ((f & MEM_Str) != 0) { + int j;//, k; + zBuf.Append(' '); + if ((f & MEM_Dyn) != 0) { + zBuf.Append('z'); + Debug.Assert((f & (MEM_Static | MEM_Ephem)) == 0); + } else if ((f & MEM_Static) != 0) { + zBuf.Append('t'); + Debug.Assert((f & (MEM_Dyn | MEM_Ephem)) == 0); + } else if ((f & MEM_Ephem) != 0) { + zBuf.Append('s'); //zBuf.Append( 'e' ); + Debug.Assert((f & (MEM_Static | MEM_Dyn)) == 0); + } else { + zBuf.Append('s'); + } + //k = 2; + sqlite3_snprintf(100, zCsr, "%d", pMem.n);//zBuf[k], "%d", pMem.n ); + zBuf.Append(zCsr); + //k += sqlite3Strlen30( &zBuf[k] ); + zBuf.Append('[');// zBuf[k++] = '['; + for (j = 0; j < 15 && j < pMem.n; j++) { + u8 c = pMem.z != null ? (u8)pMem.z[j] : pMem.zBLOB[j]; + if (c >= 0x20 && c < 0x7f) { + zBuf.Append((char)c);//zBuf[k++] = c; + } else { + zBuf.Append('.');//zBuf[k++] = '.'; + } + } + zBuf.Append(']');//zBuf[k++] = ']'; + sqlite3_snprintf(100, zCsr, encnames[pMem.enc]);//& zBuf[k], encnames[pMem.enc] ); + zBuf.Append(zCsr); + //k += sqlite3Strlen30( &zBuf[k] ); + //zBuf[k++] = 0; + } } - zBuf.Append( ']' );//zBuf[k++] = ']'; - sqlite3_snprintf( 100, zCsr, encnames[pMem.enc] );//& zBuf[k], encnames[pMem.enc] ); - zBuf.Append( zCsr ); - //k += sqlite3Strlen30( &zBuf[k] ); - //zBuf[k++] = 0; - } - } #endif #if SQLITE_DEBUG - /* -** Print the value of a register for tracing purposes: -*/ - static void memTracePrint( FILE _out, Mem p ) - { - if ( ( p.flags & MEM_Null ) != 0 ) - { - fprintf( _out, " NULL" ); - } - else if ( ( p.flags & ( MEM_Int | MEM_Str ) ) == ( MEM_Int | MEM_Str ) ) - { - fprintf( _out, " si:%lld", p.u.i ); + /* + ** Print the value of a register for tracing purposes: + */ + static void memTracePrint(FILE _out, Mem p) { + if ((p.flags & MEM_Null) != 0) { + fprintf(_out, " NULL"); + } else if ((p.flags & (MEM_Int | MEM_Str)) == (MEM_Int | MEM_Str)) { + fprintf(_out, " si:%lld", p.u.i); #if !SQLITE_OMIT_FLOATING_POINT - } - else if ( ( p.flags & MEM_Int ) != 0 ) - { - fprintf( _out, " i:%lld", p.u.i ); + } else if ((p.flags & MEM_Int) != 0) { + fprintf(_out, " i:%lld", p.u.i); #endif - } - else if ( ( p.flags & MEM_Real ) != 0 ) - { - fprintf( _out, " r:%g", p.r ); - } - else if ( ( p.flags & MEM_RowSet ) != 0 ) - { - fprintf( _out, " (rowset)" ); - } - else - { - StringBuilder zBuf = new StringBuilder( 200 ); - sqlite3VdbeMemPrettyPrint( p, zBuf ); - fprintf( _out, " " ); - fprintf( _out, "%s", zBuf ); - } - } - static void registerTrace( FILE _out, int iReg, Mem p ) - { - fprintf( _out, "reg[%d] = ", iReg ); - memTracePrint( _out, p ); - fprintf( _out, "\n" ); - } + } else if ((p.flags & MEM_Real) != 0) { + fprintf(_out, " r:%g", p.r); + } else if ((p.flags & MEM_RowSet) != 0) { + fprintf(_out, " (rowset)"); + } else { + StringBuilder zBuf = new StringBuilder(200); + sqlite3VdbeMemPrettyPrint(p, zBuf); + fprintf(_out, " "); + fprintf(_out, "%s", zBuf); + } + } + static void registerTrace(FILE _out, int iReg, Mem p) { + fprintf(_out, "reg[%d] = ", iReg); + memTracePrint(_out, p); + fprintf(_out, "\n"); + } #endif #if SQLITE_DEBUG - //# define REGISTER_TRACE(R,M) if(p.trace)registerTrace(p.trace,R,M) - static void REGISTER_TRACE( Vdbe p, int R, Mem M ) - { - if ( p.trace != null ) - registerTrace( p.trace, R, M ); - } + //# define REGISTER_TRACE(R,M) if(p.trace)registerTrace(p.trace,R,M) + static void REGISTER_TRACE(Vdbe p, int R, Mem M) { + if (p.trace != null) + registerTrace(p.trace, R, M); + } #else //# define REGISTER_TRACE(R,M) static void REGISTER_TRACE( Vdbe p, int R, Mem M ) { } @@ -642,181 +563,172 @@ static void REGISTER_TRACE( Vdbe p, int R, Mem M ) { } #endif - /* -** The CHECK_FOR_INTERRUPT macro defined here looks to see if the -** sqlite3_interrupt() routine has been called. If it has been, then -** processing of the VDBE program is interrupted. -** -** This macro added to every instruction that does a jump in order to -** implement a loop. This test used to be on every single instruction, -** but that meant we more testing that we needed. By only testing the -** flag on jump instructions, we get a (small) speed improvement. -*/ - //#define CHECK_FOR_INTERRUPT \ - // if( db.u1.isInterrupted ) goto abort_due_to_interrupt; + /* + ** The CHECK_FOR_INTERRUPT macro defined here looks to see if the + ** sqlite3_interrupt() routine has been called. If it has been, then + ** processing of the VDBE program is interrupted. + ** + ** This macro added to every instruction that does a jump in order to + ** implement a loop. This test used to be on every single instruction, + ** but that meant we more testing that we needed. By only testing the + ** flag on jump instructions, we get a (small) speed improvement. + */ + //#define CHECK_FOR_INTERRUPT \ + // if( db.u1.isInterrupted ) goto abort_due_to_interrupt; #if !NDEBUG - /* -** This function is only called from within an Debug.Assert() expression. It -** checks that the sqlite3.nTransaction variable is correctly set to -** the number of non-transaction savepoints currently in the -** linked list starting at sqlite3.pSavepoint. -** -** Usage: -** -** Debug.Assert( checkSavepointCount(db) ); -*/ - static int checkSavepointCount( sqlite3 db ) - { - int n = 0; - Savepoint p; - for ( p = db.pSavepoint; p != null; p = p.pNext ) - n++; - Debug.Assert( n == ( db.nSavepoint + db.isTransactionSavepoint ) ); - return 1; - } + /* + ** This function is only called from within an Debug.Assert() expression. It + ** checks that the sqlite3.nTransaction variable is correctly set to + ** the number of non-transaction savepoints currently in the + ** linked list starting at sqlite3.pSavepoint. + ** + ** Usage: + ** + ** Debug.Assert( checkSavepointCount(db) ); + */ + static int checkSavepointCount(sqlite3 db) { + int n = 0; + Savepoint p; + for (p = db.pSavepoint; p != null; p = p.pNext) + n++; + Debug.Assert(n == (db.nSavepoint + db.isTransactionSavepoint)); + return 1; + } #else static int checkSavepointCount( sqlite3 db ) { return 1; } #endif - /* -** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored -** in memory obtained from sqlite3_malloc) into a Vdbe.zErrMsg (text stored -** in memory obtained from sqlite3DbMalloc). -*/ - static void importVtabErrMsg( Vdbe p, sqlite3_vtab pVtab ) - { - sqlite3 db = p.db; - sqlite3DbFree( db, ref p.zErrMsg ); - p.zErrMsg = pVtab.zErrMsg; // sqlite3DbStrDup( db, pVtab.zErrMsg ); - //sqlite3_free( pVtab.zErrMsg ); - pVtab.zErrMsg = null; - } - - /* - ** Execute as much of a VDBE program as we can then return. - ** - ** sqlite3VdbeMakeReady() must be called before this routine in order to - ** close the program with a final OP_Halt and to set up the callbacks - ** and the error message pointer. - ** - ** Whenever a row or result data is available, this routine will either - ** invoke the result callback (if there is one) or return with - ** SQLITE_ROW. - ** - ** If an attempt is made to open a locked database, then this routine - ** will either invoke the busy callback (if there is one) or it will - ** return SQLITE_BUSY. - ** - ** If an error occurs, an error message is written to memory obtained - ** from sqlite3Malloc() and p.zErrMsg is made to point to that memory. - ** The error code is stored in p.rc and this routine returns SQLITE_ERROR. - ** - ** If the callback ever returns non-zero, then the program exits - ** immediately. There will be no error message but the p.rc field is - ** set to SQLITE_ABORT and this routine will return SQLITE_ERROR. - ** - ** A memory allocation error causes p.rc to be set to SQLITE_NOMEM and this - ** routine to return SQLITE_ERROR. - ** - ** Other fatal errors return SQLITE_ERROR. - ** - ** After this routine has finished, sqlite3VdbeFinalize() should be - ** used to clean up the mess that was left behind. + /* + ** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored + ** in memory obtained from sqlite3_malloc) into a Vdbe.zErrMsg (text stored + ** in memory obtained from sqlite3DbMalloc). */ - static int sqlite3VdbeExec( - Vdbe p /* The VDBE */ - ) - { - int pc = 0; /* The program counter */ - Op[] aOp = p.aOp; /* Copy of p.aOp */ - Op pOp; /* Current operation */ - int rc = SQLITE_OK; /* Value to return */ - sqlite3 db = p.db; /* The database */ - u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */ - u8 encoding = ENC( db ); /* The database encoding */ + static void importVtabErrMsg(Vdbe p, sqlite3_vtab pVtab) { + sqlite3 db = p.db; + sqlite3DbFree(db, ref p.zErrMsg); + p.zErrMsg = pVtab.zErrMsg; // sqlite3DbStrDup( db, pVtab.zErrMsg ); + //sqlite3_free( pVtab.zErrMsg ); + pVtab.zErrMsg = null; + } + + /* + ** Execute as much of a VDBE program as we can then return. + ** + ** sqlite3VdbeMakeReady() must be called before this routine in order to + ** close the program with a final OP_Halt and to set up the callbacks + ** and the error message pointer. + ** + ** Whenever a row or result data is available, this routine will either + ** invoke the result callback (if there is one) or return with + ** SQLITE_ROW. + ** + ** If an attempt is made to open a locked database, then this routine + ** will either invoke the busy callback (if there is one) or it will + ** return SQLITE_BUSY. + ** + ** If an error occurs, an error message is written to memory obtained + ** from sqlite3Malloc() and p.zErrMsg is made to point to that memory. + ** The error code is stored in p.rc and this routine returns SQLITE_ERROR. + ** + ** If the callback ever returns non-zero, then the program exits + ** immediately. There will be no error message but the p.rc field is + ** set to SQLITE_ABORT and this routine will return SQLITE_ERROR. + ** + ** A memory allocation error causes p.rc to be set to SQLITE_NOMEM and this + ** routine to return SQLITE_ERROR. + ** + ** Other fatal errors return SQLITE_ERROR. + ** + ** After this routine has finished, sqlite3VdbeFinalize() should be + ** used to clean up the mess that was left behind. + */ + static int sqlite3VdbeExec( + Vdbe p /* The VDBE */ + ) { + int pc = 0; /* The program counter */ + Op[] aOp = p.aOp; /* Copy of p.aOp */ + Op pOp; /* Current operation */ + int rc = SQLITE_OK; /* Value to return */ + sqlite3 db = p.db; /* The database */ + u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */ + u8 encoding = ENC(db); /* The database encoding */ #if !SQLITE_OMIT_PROGRESS_CALLBACK - bool checkProgress; /* True if progress callbacks are enabled */ - int nProgressOps = 0; /* Opcodes executed since progress callback. */ + bool checkProgress; /* True if progress callbacks are enabled */ + int nProgressOps = 0; /* Opcodes executed since progress callback. */ #endif - Mem[] aMem = p.aMem; /* Copy of p.aMem */ - Mem pIn1 = null; /* 1st input operand */ - Mem pIn2 = null; /* 2nd input operand */ - Mem pIn3 = null; /* 3rd input operand */ - Mem pOut = null; /* Output operand */ - int iCompare = 0; /* Result of last OP_Compare operation */ - int[] aPermute = null; /* Permutation of columns for OP_Compare */ - i64 lastRowid = db.lastRowid; /* Saved value of the last insert ROWID */ + Mem[] aMem = p.aMem; /* Copy of p.aMem */ + Mem pIn1 = null; /* 1st input operand */ + Mem pIn2 = null; /* 2nd input operand */ + Mem pIn3 = null; /* 3rd input operand */ + Mem pOut = null; /* Output operand */ + int iCompare = 0; /* Result of last OP_Compare operation */ + int[] aPermute = null; /* Permutation of columns for OP_Compare */ + i64 lastRowid = db.lastRowid; /* Saved value of the last insert ROWID */ #if VDBE_PROFILE u64 start; /* CPU clock count at start of opcode */ int origPc; /* Program counter at start of opcode */ #endif - /*** INSERT STACK UNION HERE ***/ + /*** INSERT STACK UNION HERE ***/ - Debug.Assert( p.magic == VDBE_MAGIC_RUN ); /* sqlite3_step() verifies this */ - sqlite3VdbeEnter( p ); - if ( p.rc == SQLITE_NOMEM ) - { - /* This happens if a malloc() inside a call to sqlite3_column_text() or - ** sqlite3_column_text16() failed. */ - goto no_mem; - } - Debug.Assert( p.rc == SQLITE_OK || p.rc == SQLITE_BUSY ); - p.rc = SQLITE_OK; - Debug.Assert( p.explain == 0 ); - p.pResultSet = null; - db.busyHandler.nBusy = 0; - if ( db.u1.isInterrupted ) - goto abort_due_to_interrupt; //CHECK_FOR_INTERRUPT; + Debug.Assert(p.magic == VDBE_MAGIC_RUN); /* sqlite3_step() verifies this */ + sqlite3VdbeEnter(p); + if (p.rc == SQLITE_NOMEM) { + /* This happens if a malloc() inside a call to sqlite3_column_text() or + ** sqlite3_column_text16() failed. */ + goto no_mem; + } + Debug.Assert(p.rc == SQLITE_OK || p.rc == SQLITE_BUSY); + p.rc = SQLITE_OK; + Debug.Assert(p.explain == 0); + p.pResultSet = null; + db.busyHandler.nBusy = 0; + if (db.u1.isInterrupted) + goto abort_due_to_interrupt; //CHECK_FOR_INTERRUPT; #if TRACE -sqlite3VdbeIOTraceSql( p ); + sqlite3VdbeIOTraceSql(p); #endif #if !SQLITE_OMIT_PROGRESS_CALLBACK - checkProgress = db.xProgress != null; + checkProgress = db.xProgress != null; #endif #if SQLITE_DEBUG - sqlite3BeginBenignMalloc(); - if ( p.pc == 0 - && ( p.db.flags & SQLITE_VdbeListing ) != 0 ) - { - int i; - Console.Write( "VDBE Program Listing:\n" ); - sqlite3VdbePrintSql( p ); - for ( i = 0; i < p.nOp; i++ ) - { - sqlite3VdbePrintOp( Console.Out, i, aOp[i] ); - } - } - sqlite3EndBenignMalloc(); + sqlite3BeginBenignMalloc(); + if (p.pc == 0 + && (p.db.flags & SQLITE_VdbeListing) != 0) { + int i; + Console.Write("VDBE Program Listing:\n"); + sqlite3VdbePrintSql(p); + for (i = 0; i < p.nOp; i++) { + sqlite3VdbePrintOp(Console.Out, i, aOp[i]); + } + } + sqlite3EndBenignMalloc(); #endif - for ( pc = p.pc; rc == SQLITE_OK; pc++ ) - { - Debug.Assert( pc >= 0 && pc < p.nOp ); - // if ( db.mallocFailed != 0 ) goto no_mem; + for (pc = p.pc; rc == SQLITE_OK; pc++) { + Debug.Assert(pc >= 0 && pc < p.nOp); + // if ( db.mallocFailed != 0 ) goto no_mem; #if VDBE_PROFILE origPc = pc; start = sqlite3Hwtime(); #endif - pOp = aOp[pc]; + pOp = aOp[pc]; - /* Only allow tracing if SQLITE_DEBUG is defined. - */ + /* Only allow tracing if SQLITE_DEBUG is defined. + */ #if SQLITE_DEBUG - if ( p.trace != null ) - { - if ( pc == 0 ) - { - printf( "VDBE Execution Trace:\n" ); - sqlite3VdbePrintSql( p ); - } - sqlite3VdbePrintOp( p.trace, pc, pOp ); - } + if (p.trace != null) { + if (pc == 0) { + printf("VDBE Execution Trace:\n"); + sqlite3VdbePrintSql(p); + } + sqlite3VdbePrintOp(p.trace, pc, pOp); + } #endif - /* Check to see if we need to simulate an interrupt. This only happens -** if we have a special test build. -*/ + /* Check to see if we need to simulate an interrupt. This only happens + ** if we have a special test build. + */ #if SQLITE_TEST #if !TCLSH if ( sqlite3_interrupt_count > 0 ) @@ -836,318 +748,290 @@ Vdbe p /* The VDBE */ #endif #if !SQLITE_OMIT_PROGRESS_CALLBACK - /* Call the progress callback if it is configured and the required number -** of VDBE ops have been executed (either since this invocation of -** sqlite3VdbeExec() or since last time the progress callback was called). -** If the progress callback returns non-zero, exit the virtual machine with -** a return code SQLITE_ABORT. -*/ - if ( checkProgress ) - { - if ( db.nProgressOps == nProgressOps ) - { - int prc; - prc = db.xProgress( db.pProgressArg ); - if ( prc != 0 ) - { - rc = SQLITE_INTERRUPT; - goto vdbe_error_halt; - } - nProgressOps = 0; - } - nProgressOps++; - } + /* Call the progress callback if it is configured and the required number + ** of VDBE ops have been executed (either since this invocation of + ** sqlite3VdbeExec() or since last time the progress callback was called). + ** If the progress callback returns non-zero, exit the virtual machine with + ** a return code SQLITE_ABORT. + */ + if (checkProgress) { + if (db.nProgressOps == nProgressOps) { + int prc; + prc = db.xProgress(db.pProgressArg); + if (prc != 0) { + rc = SQLITE_INTERRUPT; + goto vdbe_error_halt; + } + nProgressOps = 0; + } + nProgressOps++; + } #endif - /* On any opcode with the "out2-prerelase" tag, free any -** external allocations out of mem[p2] and set mem[p2] to be -** an undefined integer. Opcodes will either fill in the integer -** value or convert mem[p2] to a different type. -*/ - Debug.Assert( pOp.opflags == sqlite3OpcodeProperty[pOp.opcode] ); - if ( ( pOp.opflags & OPFLG_OUT2_PRERELEASE ) != 0 ) - { - Debug.Assert( pOp.p2 > 0 ); - Debug.Assert( pOp.p2 <= p.nMem ); - pOut = aMem[pOp.p2]; - memAboutToChange( p, pOut ); - sqlite3VdbeMemReleaseExternal( pOut ); - pOut.flags = MEM_Int; - } + /* On any opcode with the "out2-prerelase" tag, free any + ** external allocations out of mem[p2] and set mem[p2] to be + ** an undefined integer. Opcodes will either fill in the integer + ** value or convert mem[p2] to a different type. + */ + Debug.Assert(pOp.opflags == sqlite3OpcodeProperty[pOp.opcode]); + if ((pOp.opflags & OPFLG_OUT2_PRERELEASE) != 0) { + Debug.Assert(pOp.p2 > 0); + Debug.Assert(pOp.p2 <= p.nMem); + pOut = aMem[pOp.p2]; + memAboutToChange(p, pOut); + sqlite3VdbeMemReleaseExternal(pOut); + pOut.flags = MEM_Int; + } - /* Sanity checking on other operands */ - /* Sanity checking on other operands */ + /* Sanity checking on other operands */ + /* Sanity checking on other operands */ #if SQLITE_DEBUG - if ( ( pOp.opflags & OPFLG_IN1 ) != 0 ) - { - Debug.Assert( pOp.p1 > 0 ); - Debug.Assert( pOp.p1 <= p.nMem ); - Debug.Assert( memIsValid( aMem[pOp.p1] ) ); - REGISTER_TRACE( p, pOp.p1, aMem[pOp.p1] ); - } - if ( ( pOp.opflags & OPFLG_IN2 ) != 0 ) - { - Debug.Assert( pOp.p2 > 0 ); - Debug.Assert( pOp.p2 <= p.nMem ); - Debug.Assert( memIsValid( aMem[pOp.p2] ) ); - REGISTER_TRACE( p, pOp.p2, aMem[pOp.p2] ); - } - if ( ( pOp.opflags & OPFLG_IN3 ) != 0 ) - { - Debug.Assert( pOp.p3 > 0 ); - Debug.Assert( pOp.p3 <= p.nMem ); - Debug.Assert( memIsValid( aMem[pOp.p3] ) ); - REGISTER_TRACE( p, pOp.p3, aMem[pOp.p3] ); - } - if ( ( pOp.opflags & OPFLG_OUT2 ) != 0 ) - { - Debug.Assert( pOp.p2 > 0 ); - Debug.Assert( pOp.p2 <= p.nMem ); - memAboutToChange( p, aMem[pOp.p2] ); - } - if ( ( pOp.opflags & OPFLG_OUT3 ) != 0 ) - { - Debug.Assert( pOp.p3 > 0 ); - Debug.Assert( pOp.p3 <= p.nMem ); - memAboutToChange( p, aMem[pOp.p3] ); - } + if ((pOp.opflags & OPFLG_IN1) != 0) { + Debug.Assert(pOp.p1 > 0); + Debug.Assert(pOp.p1 <= p.nMem); + Debug.Assert(memIsValid(aMem[pOp.p1])); + REGISTER_TRACE(p, pOp.p1, aMem[pOp.p1]); + } + if ((pOp.opflags & OPFLG_IN2) != 0) { + Debug.Assert(pOp.p2 > 0); + Debug.Assert(pOp.p2 <= p.nMem); + Debug.Assert(memIsValid(aMem[pOp.p2])); + REGISTER_TRACE(p, pOp.p2, aMem[pOp.p2]); + } + if ((pOp.opflags & OPFLG_IN3) != 0) { + Debug.Assert(pOp.p3 > 0); + Debug.Assert(pOp.p3 <= p.nMem); + Debug.Assert(memIsValid(aMem[pOp.p3])); + REGISTER_TRACE(p, pOp.p3, aMem[pOp.p3]); + } + if ((pOp.opflags & OPFLG_OUT2) != 0) { + Debug.Assert(pOp.p2 > 0); + Debug.Assert(pOp.p2 <= p.nMem); + memAboutToChange(p, aMem[pOp.p2]); + } + if ((pOp.opflags & OPFLG_OUT3) != 0) { + Debug.Assert(pOp.p3 > 0); + Debug.Assert(pOp.p3 <= p.nMem); + memAboutToChange(p, aMem[pOp.p3]); + } #endif - switch ( pOp.opcode ) - { - - /***************************************************************************** - ** What follows is a massive switch statement where each case implements a - ** separate instruction in the virtual machine. If we follow the usual - ** indentation conventions, each case should be indented by 6 spaces. But - ** that is a lot of wasted space on the left margin. So the code within - ** the switch statement will break with convention and be flush-left. Another - ** big comment (similar to this one) will mark the point in the code where - ** we transition back to normal indentation. - ** - ** The formatting of each case is important. The makefile for SQLite - ** generates two C files "opcodes.h" and "opcodes.c" by scanning this - ** file looking for lines that begin with "case OP_". The opcodes.h files - ** will be filled with #defines that give unique integer values to each - ** opcode and the opcodes.c file is filled with an array of strings where - ** each string is the symbolic name for the corresponding opcode. If the - ** case statement is followed by a comment of the form "/# same as ... #/" - ** that comment is used to determine the particular value of the opcode. - ** - ** Other keywords in the comment that follows each case are used to - ** construct the OPFLG_INITIALIZER value that initializes opcodeProperty[]. - ** Keywords include: in1, in2, in3, ref2_prerelease, ref2, ref3. See - ** the mkopcodeh.awk script for additional information. - ** - ** Documentation about VDBE opcodes is generated by scanning this file - ** for lines of that contain "Opcode:". That line and all subsequent - ** comment lines are used in the generation of the opcode.html documentation - ** file. - ** - ** SUMMARY: - ** - ** Formatting is important to scripts that scan this file. - ** Do not deviate from the formatting style currently in use. - ** - *****************************************************************************/ + switch (pOp.opcode) { + + /***************************************************************************** + ** What follows is a massive switch statement where each case implements a + ** separate instruction in the virtual machine. If we follow the usual + ** indentation conventions, each case should be indented by 6 spaces. But + ** that is a lot of wasted space on the left margin. So the code within + ** the switch statement will break with convention and be flush-left. Another + ** big comment (similar to this one) will mark the point in the code where + ** we transition back to normal indentation. + ** + ** The formatting of each case is important. The makefile for SQLite + ** generates two C files "opcodes.h" and "opcodes.c" by scanning this + ** file looking for lines that begin with "case OP_". The opcodes.h files + ** will be filled with #defines that give unique integer values to each + ** opcode and the opcodes.c file is filled with an array of strings where + ** each string is the symbolic name for the corresponding opcode. If the + ** case statement is followed by a comment of the form "/# same as ... #/" + ** that comment is used to determine the particular value of the opcode. + ** + ** Other keywords in the comment that follows each case are used to + ** construct the OPFLG_INITIALIZER value that initializes opcodeProperty[]. + ** Keywords include: in1, in2, in3, ref2_prerelease, ref2, ref3. See + ** the mkopcodeh.awk script for additional information. + ** + ** Documentation about VDBE opcodes is generated by scanning this file + ** for lines of that contain "Opcode:". That line and all subsequent + ** comment lines are used in the generation of the opcode.html documentation + ** file. + ** + ** SUMMARY: + ** + ** Formatting is important to scripts that scan this file. + ** Do not deviate from the formatting style currently in use. + ** + *****************************************************************************/ + + /* Opcode: Goto * P2 * * * + ** + ** An unconditional jump to address P2. + ** The next instruction executed will be + ** the one at index P2 from the beginning of + ** the program. + */ + case OP_Goto: { /* jump */ + if (db.u1.isInterrupted) + goto abort_due_to_interrupt; //CHECK_FOR_INTERRUPT; + pc = pOp.p2 - 1; + break; + } - /* Opcode: Goto * P2 * * * - ** - ** An unconditional jump to address P2. - ** The next instruction executed will be - ** the one at index P2 from the beginning of - ** the program. - */ - case OP_Goto: - { /* jump */ - if ( db.u1.isInterrupted ) - goto abort_due_to_interrupt; //CHECK_FOR_INTERRUPT; - pc = pOp.p2 - 1; - break; - } + /* Opcode: Gosub P1 P2 * * * + ** + ** Write the current address onto register P1 + ** and then jump to address P2. + */ + case OP_Gosub: { /* jump, in1 */ + pIn1 = aMem[pOp.p1]; + Debug.Assert((pIn1.flags & MEM_Dyn) == 0); + memAboutToChange(p, pIn1); + pIn1.flags = MEM_Int; + pIn1.u.i = pc; + REGISTER_TRACE(p, pOp.p1, pIn1); + pc = pOp.p2 - 1; + break; + } - /* Opcode: Gosub P1 P2 * * * - ** - ** Write the current address onto register P1 - ** and then jump to address P2. - */ - case OP_Gosub: - { /* jump, in1 */ - pIn1 = aMem[pOp.p1]; - Debug.Assert( ( pIn1.flags & MEM_Dyn ) == 0 ); - memAboutToChange( p, pIn1 ); - pIn1.flags = MEM_Int; - pIn1.u.i = pc; - REGISTER_TRACE( p, pOp.p1, pIn1 ); - pc = pOp.p2 - 1; - break; - } + /* Opcode: Return P1 * * * * + ** + ** Jump to the next instruction after the address in register P1. + */ + case OP_Return: { /* in1 */ + pIn1 = aMem[pOp.p1]; + Debug.Assert((pIn1.flags & MEM_Int) != 0); + pc = (int)pIn1.u.i; + break; + } - /* Opcode: Return P1 * * * * - ** - ** Jump to the next instruction after the address in register P1. - */ - case OP_Return: - { /* in1 */ - pIn1 = aMem[pOp.p1]; - Debug.Assert( ( pIn1.flags & MEM_Int ) != 0 ); - pc = (int)pIn1.u.i; - break; - } + /* Opcode: Yield P1 * * * * + ** + ** Swap the program counter with the value in register P1. + */ + case OP_Yield: { /* in1 */ + int pcDest; + pIn1 = aMem[pOp.p1]; + Debug.Assert((pIn1.flags & MEM_Dyn) == 0); + pIn1.flags = MEM_Int; + pcDest = (int)pIn1.u.i; + pIn1.u.i = pc; + REGISTER_TRACE(p, pOp.p1, pIn1); + pc = pcDest; + break; + } - /* Opcode: Yield P1 * * * * - ** - ** Swap the program counter with the value in register P1. - */ - case OP_Yield: - { /* in1 */ - int pcDest; - pIn1 = aMem[pOp.p1]; - Debug.Assert( ( pIn1.flags & MEM_Dyn ) == 0 ); - pIn1.flags = MEM_Int; - pcDest = (int)pIn1.u.i; - pIn1.u.i = pc; - REGISTER_TRACE( p, pOp.p1, pIn1 ); - pc = pcDest; - break; - } + /* Opcode: HaltIfNull P1 P2 P3 P4 * + ** + ** Check the value in register P3. If it is NULL then Halt using + ** parameter P1, P2, and P4 as if this were a Halt instruction. If the + ** value in register P3 is not NULL, then this routine is a no-op. + */ + case OP_HaltIfNull: { /* in3 */ + pIn3 = aMem[pOp.p3]; + if ((pIn3.flags & MEM_Null) == 0) + break; + /* Fall through into OP_Halt */ + goto case OP_Halt; + } - /* Opcode: HaltIfNull P1 P2 P3 P4 * - ** - ** Check the value in register P3. If it is NULL then Halt using - ** parameter P1, P2, and P4 as if this were a Halt instruction. If the - ** value in register P3 is not NULL, then this routine is a no-op. - */ - case OP_HaltIfNull: - { /* in3 */ - pIn3 = aMem[pOp.p3]; - if ( ( pIn3.flags & MEM_Null ) == 0 ) - break; - /* Fall through into OP_Halt */ - goto case OP_Halt; - } + /* Opcode: Halt P1 P2 * P4 * + ** + ** Exit immediately. All open cursors, etc are closed + ** automatically. + ** + ** P1 is the result code returned by sqlite3_exec(), sqlite3_reset(), + ** or sqlite3_finalize(). For a normal halt, this should be SQLITE_OK (0). + ** For errors, it can be some other value. If P1!=0 then P2 will determine + ** whether or not to rollback the current transaction. Do not rollback + ** if P2==OE_Fail. Do the rollback if P2==OE_Rollback. If P2==OE_Abort, + ** then back out all changes that have occurred during this execution of the + ** VDBE, but do not rollback the transaction. + ** + ** If P4 is not null then it is an error message string. + ** + ** There is an implied "Halt 0 0 0" instruction inserted at the very end of + ** every program. So a jump past the last instruction of the program + ** is the same as executing Halt. + */ + case OP_Halt: { + pIn3 = aMem[pOp.p3]; + if (pOp.p1 == SQLITE_OK && p.pFrame != null) { + /* Halt the sub-program. Return control to the parent frame. */ + VdbeFrame pFrame = p.pFrame; + p.pFrame = pFrame.pParent; + p.nFrame--; + sqlite3VdbeSetChanges(db, p.nChange); + pc = sqlite3VdbeFrameRestore(pFrame); + lastRowid = db.lastRowid; + if (pOp.p2 == OE_Ignore) { + /* Instruction pc is the OP_Program that invoked the sub-program + ** currently being halted. If the p2 instruction of this OP_Halt + ** instruction is set to OE_Ignore, then the sub-program is throwing + ** an IGNORE exception. In this case jump to the address specified + ** as the p2 of the calling OP_Program. */ + pc = p.aOp[pc].p2 - 1; + } + aOp = p.aOp; + aMem = p.aMem; + break; + } + p.rc = pOp.p1; + p.errorAction = (u8)pOp.p2; + p.pc = pc; + if (pOp.p4.z != null) { + Debug.Assert(p.rc != SQLITE_OK); + sqlite3SetString(ref p.zErrMsg, db, "%s", pOp.p4.z); + testcase(sqlite3GlobalConfig.xLog != null); + sqlite3_log(pOp.p1, "abort at %d in [%s]: %s", pc, p.zSql, pOp.p4.z); + } else if (p.rc != 0) { + testcase(sqlite3GlobalConfig.xLog != null); + sqlite3_log(pOp.p1, "constraint failed at %d in [%s]", pc, p.zSql); + } + rc = sqlite3VdbeHalt(p); + Debug.Assert(rc == SQLITE_BUSY || rc == SQLITE_OK || rc == SQLITE_ERROR); + if (rc == SQLITE_BUSY) { + p.rc = rc = SQLITE_BUSY; + } else { + Debug.Assert(rc == SQLITE_OK || p.rc == SQLITE_CONSTRAINT); + Debug.Assert(rc == SQLITE_OK || db.nDeferredCons > 0); + rc = p.rc != 0 ? SQLITE_ERROR : SQLITE_DONE; + } + goto vdbe_return; + } - /* Opcode: Halt P1 P2 * P4 * - ** - ** Exit immediately. All open cursors, etc are closed - ** automatically. - ** - ** P1 is the result code returned by sqlite3_exec(), sqlite3_reset(), - ** or sqlite3_finalize(). For a normal halt, this should be SQLITE_OK (0). - ** For errors, it can be some other value. If P1!=0 then P2 will determine - ** whether or not to rollback the current transaction. Do not rollback - ** if P2==OE_Fail. Do the rollback if P2==OE_Rollback. If P2==OE_Abort, - ** then back out all changes that have occurred during this execution of the - ** VDBE, but do not rollback the transaction. - ** - ** If P4 is not null then it is an error message string. - ** - ** There is an implied "Halt 0 0 0" instruction inserted at the very end of - ** every program. So a jump past the last instruction of the program - ** is the same as executing Halt. - */ - case OP_Halt: - { - pIn3 = aMem[pOp.p3]; - if ( pOp.p1 == SQLITE_OK && p.pFrame != null ) - { - /* Halt the sub-program. Return control to the parent frame. */ - VdbeFrame pFrame = p.pFrame; - p.pFrame = pFrame.pParent; - p.nFrame--; - sqlite3VdbeSetChanges( db, p.nChange ); - pc = sqlite3VdbeFrameRestore( pFrame ); - lastRowid = db.lastRowid; - if ( pOp.p2 == OE_Ignore ) - { - /* Instruction pc is the OP_Program that invoked the sub-program - ** currently being halted. If the p2 instruction of this OP_Halt - ** instruction is set to OE_Ignore, then the sub-program is throwing - ** an IGNORE exception. In this case jump to the address specified - ** as the p2 of the calling OP_Program. */ - pc = p.aOp[pc].p2 - 1; - } - aOp = p.aOp; - aMem = p.aMem; - break; - } - p.rc = pOp.p1; - p.errorAction = (u8)pOp.p2; - p.pc = pc; - if ( pOp.p4.z != null ) - { - Debug.Assert( p.rc != SQLITE_OK ); - sqlite3SetString( ref p.zErrMsg, db, "%s", pOp.p4.z ); - testcase( sqlite3GlobalConfig.xLog != null ); - sqlite3_log( pOp.p1, "abort at %d in [%s]: %s", pc, p.zSql, pOp.p4.z ); - } - else if ( p.rc != 0 ) - { - testcase( sqlite3GlobalConfig.xLog != null ); - sqlite3_log( pOp.p1, "constraint failed at %d in [%s]", pc, p.zSql ); - } - rc = sqlite3VdbeHalt( p ); - Debug.Assert( rc == SQLITE_BUSY || rc == SQLITE_OK || rc == SQLITE_ERROR ); - if ( rc == SQLITE_BUSY ) - { - p.rc = rc = SQLITE_BUSY; - } - else - { - Debug.Assert( rc == SQLITE_OK || p.rc == SQLITE_CONSTRAINT ); - Debug.Assert( rc == SQLITE_OK || db.nDeferredCons > 0 ); - rc = p.rc != 0 ? SQLITE_ERROR : SQLITE_DONE; - } - goto vdbe_return; - } + /* Opcode: Integer P1 P2 * * * + ** + ** The 32-bit integer value P1 is written into register P2. + */ + case OP_Integer: { /* out2-prerelease */ + pOut.u.i = pOp.p1; + break; + } - /* Opcode: Integer P1 P2 * * * - ** - ** The 32-bit integer value P1 is written into register P2. - */ - case OP_Integer: - { /* out2-prerelease */ - pOut.u.i = pOp.p1; - break; - } + /* Opcode: Int64 * P2 * P4 * + ** + ** P4 is a pointer to a 64-bit integer value. + ** Write that value into register P2. + */ + case OP_Int64: { /* out2-prerelease */ + // Integer pointer always exists Debug.Assert( pOp.p4.pI64 != 0 ); + pOut.u.i = pOp.p4.pI64; + break; + } - /* Opcode: Int64 * P2 * P4 * +#if !SQLITE_OMIT_FLOATING_POINT + /* Opcode: Real * P2 * P4 * ** - ** P4 is a pointer to a 64-bit integer value. + ** P4 is a pointer to a 64-bit floating point value. ** Write that value into register P2. */ - case OP_Int64: - { /* out2-prerelease */ - // Integer pointer always exists Debug.Assert( pOp.p4.pI64 != 0 ); - pOut.u.i = pOp.p4.pI64; - break; - } - -#if !SQLITE_OMIT_FLOATING_POINT - /* Opcode: Real * P2 * P4 * -** -** P4 is a pointer to a 64-bit floating point value. -** Write that value into register P2. -*/ - case OP_Real: - { /* same as TK_FLOAT, ref2-prerelease */ - pOut.flags = MEM_Real; - Debug.Assert( !sqlite3IsNaN( pOp.p4.pReal ) ); - pOut.r = pOp.p4.pReal; - break; - } + case OP_Real: { /* same as TK_FLOAT, ref2-prerelease */ + pOut.flags = MEM_Real; + Debug.Assert(!sqlite3IsNaN(pOp.p4.pReal)); + pOut.r = pOp.p4.pReal; + break; + } #endif - /* Opcode: String8 * P2 * P4 * -** -** P4 points to a nul terminated UTF-8 string. This opcode is transformed -** into an OP_String before it is executed for the first time. -*/ - case OP_String8: - { /* same as TK_STRING, ref2-prerelease */ - Debug.Assert( pOp.p4.z != null ); - pOp.opcode = OP_String; - pOp.p1 = sqlite3Strlen30( pOp.p4.z ); + /* Opcode: String8 * P2 * P4 * + ** + ** P4 points to a nul terminated UTF-8 string. This opcode is transformed + ** into an OP_String before it is executed for the first time. + */ + case OP_String8: { /* same as TK_STRING, ref2-prerelease */ + Debug.Assert(pOp.p4.z != null); + pOp.opcode = OP_String; + pOp.p1 = sqlite3Strlen30(pOp.p4.z); #if !SQLITE_OMIT_UTF16 if( encoding!=SQLITE_UTF8 ){ @@ -1167,635 +1051,586 @@ Vdbe p /* The VDBE */ pOp.p1 = pOut.n; } #endif - if ( pOp.p1 > db.aLimit[SQLITE_LIMIT_LENGTH] ) - { - goto too_big; - } - /* Fall through to the next case, OP_String */ - goto case OP_String; - } + if (pOp.p1 > db.aLimit[SQLITE_LIMIT_LENGTH]) { + goto too_big; + } + /* Fall through to the next case, OP_String */ + goto case OP_String; + } - /* Opcode: String P1 P2 * P4 * - ** - ** The string value P4 of length P1 (bytes) is stored in register P2. - */ - case OP_String: - { /* out2-prerelease */ - Debug.Assert( pOp.p4.z != null ); - pOut.flags = MEM_Str | MEM_Static | MEM_Term; - sqlite3_free( ref pOut.zBLOB ); - pOut.z = pOp.p4.z; - pOut.n = pOp.p1; + /* Opcode: String P1 P2 * P4 * + ** + ** The string value P4 of length P1 (bytes) is stored in register P2. + */ + case OP_String: { /* out2-prerelease */ + Debug.Assert(pOp.p4.z != null); + pOut.flags = MEM_Str | MEM_Static | MEM_Term; + sqlite3_free(ref pOut.zBLOB); + pOut.z = pOp.p4.z; + pOut.n = pOp.p1; #if SQLITE_OMIT_UTF16 - pOut.enc = SQLITE_UTF8; -#else + pOut.enc = SQLITE_UTF8; +#else pOut.enc = encoding; #endif #if SQLITE_TEST UPDATE_MAX_BLOBSIZE( pOut ); #endif - break; - } + break; + } - /* Opcode: Null * P2 * * * - ** - ** Write a NULL into register P2. - */ - case OP_Null: - { /* out2-prerelease */ - pOut.flags = MEM_Null; - break; - } + /* Opcode: Null * P2 * * * + ** + ** Write a NULL into register P2. + */ + case OP_Null: { /* out2-prerelease */ + pOut.flags = MEM_Null; + break; + } - /* Opcode: Blob P1 P2 * P4 - ** - ** P4 points to a blob of data P1 bytes long. Store this - ** blob in register P2. - */ - case OP_Blob: - { /* out2-prerelease */ - Debug.Assert( pOp.p1 <= db.aLimit[SQLITE_LIMIT_LENGTH] ); - sqlite3VdbeMemSetStr( pOut, pOp.p4.z, pOp.p1, 0, null ); - pOut.enc = encoding; + /* Opcode: Blob P1 P2 * P4 + ** + ** P4 points to a blob of data P1 bytes long. Store this + ** blob in register P2. + */ + case OP_Blob: { /* out2-prerelease */ + Debug.Assert(pOp.p1 <= db.aLimit[SQLITE_LIMIT_LENGTH]); + sqlite3VdbeMemSetStr(pOut, pOp.p4.z, pOp.p1, 0, null); + pOut.enc = encoding; #if SQLITE_TEST UPDATE_MAX_BLOBSIZE( pOut ); #endif - break; - } + break; + } - /* Opcode: Variable P1 P2 * P4 * - ** - ** Transfer the values of bound parameter P1 into register P2 - ** - ** If the parameter is named, then its name appears in P4 and P3==1. - ** The P4 value is used by sqlite3_bind_parameter_name(). - */ - case OP_Variable: - { /* out2-prerelease */ - Mem pVar; /* Value being transferred */ - - Debug.Assert( pOp.p1 >= 0 && pOp.p1 <= p.nVar ); - Debug.Assert( pOp.p4.z == null || pOp.p4.z == p.azVar[pOp.p1 - 1] ); - pVar = p.aVar[pOp.p1 - 1]; - - if ( sqlite3VdbeMemTooBig( pVar ) ) - { - goto too_big; - } - sqlite3VdbeMemShallowCopy( pOut, pVar, MEM_Static ); + /* Opcode: Variable P1 P2 * P4 * + ** + ** Transfer the values of bound parameter P1 into register P2 + ** + ** If the parameter is named, then its name appears in P4 and P3==1. + ** The P4 value is used by sqlite3_bind_parameter_name(). + */ + case OP_Variable: { /* out2-prerelease */ + Mem pVar; /* Value being transferred */ + + Debug.Assert(pOp.p1 >= 0 && pOp.p1 <= p.nVar); + Debug.Assert(pOp.p4.z == null || pOp.p4.z == p.azVar[pOp.p1 - 1]); + pVar = p.aVar[pOp.p1 - 1]; + + if (sqlite3VdbeMemTooBig(pVar)) { + goto too_big; + } + sqlite3VdbeMemShallowCopy(pOut, pVar, MEM_Static); #if SQLITE_TEST UPDATE_MAX_BLOBSIZE( pOut ); #endif - break; - } - /* Opcode: Move P1 P2 P3 * * - ** - ** Move the values in register P1..P1+P3-1 over into - ** registers P2..P2+P3-1. Registers P1..P1+P1-1 are - ** left holding a NULL. It is an error for register ranges - ** P1..P1+P3-1 and P2..P2+P3-1 to overlap. - */ - case OP_Move: - { - //char* zMalloc; /* Holding variable for allocated memory */ - int n; /* Number of registers left to copy */ - int p1; /* Register to copy from */ - int p2; /* Register to copy to */ - - n = pOp.p3; - p1 = pOp.p1; - p2 = pOp.p2; - Debug.Assert( n > 0 && p1 > 0 && p2 > 0 ); - Debug.Assert( p1 + n <= p2 || p2 + n <= p1 ); - //pIn1 = aMem[p1]; - //pOut = aMem[p2]; - while ( n-- != 0 ) - { - pIn1 = aMem[p1 + pOp.p3 - n - 1]; - pOut = aMem[p2]; - //Debug.Assert( pOut<=&aMem[p.nMem] ); - //Debug.Assert( pIn1<=&aMem[p.nMem] ); - Debug.Assert( memIsValid( pIn1 ) ); - memAboutToChange( p, pOut ); - //zMalloc = pOut.zMalloc; - //pOut.zMalloc = null; - sqlite3VdbeMemMove( pOut, pIn1 ); - //pIn1.zMalloc = zMalloc; - REGISTER_TRACE( p, p2++, pOut ); - //pIn1++; - //pOut++; - } - break; - } + break; + } + /* Opcode: Move P1 P2 P3 * * + ** + ** Move the values in register P1..P1+P3-1 over into + ** registers P2..P2+P3-1. Registers P1..P1+P1-1 are + ** left holding a NULL. It is an error for register ranges + ** P1..P1+P3-1 and P2..P2+P3-1 to overlap. + */ + case OP_Move: { + //char* zMalloc; /* Holding variable for allocated memory */ + int n; /* Number of registers left to copy */ + int p1; /* Register to copy from */ + int p2; /* Register to copy to */ + + n = pOp.p3; + p1 = pOp.p1; + p2 = pOp.p2; + Debug.Assert(n > 0 && p1 > 0 && p2 > 0); + Debug.Assert(p1 + n <= p2 || p2 + n <= p1); + //pIn1 = aMem[p1]; + //pOut = aMem[p2]; + while (n-- != 0) { + pIn1 = aMem[p1 + pOp.p3 - n - 1]; + pOut = aMem[p2]; + //Debug.Assert( pOut<=&aMem[p.nMem] ); + //Debug.Assert( pIn1<=&aMem[p.nMem] ); + Debug.Assert(memIsValid(pIn1)); + memAboutToChange(p, pOut); + //zMalloc = pOut.zMalloc; + //pOut.zMalloc = null; + sqlite3VdbeMemMove(pOut, pIn1); + //pIn1.zMalloc = zMalloc; + REGISTER_TRACE(p, p2++, pOut); + //pIn1++; + //pOut++; + } + break; + } - /* Opcode: Copy P1 P2 * * * - ** - ** Make a copy of register P1 into register P2. - ** - ** This instruction makes a deep copy of the value. A duplicate - ** is made of any string or blob constant. See also OP_SCopy. - */ - case OP_Copy: - { /* in1, ref2 */ - pIn1 = aMem[pOp.p1]; - pOut = aMem[pOp.p2]; - - Debug.Assert( pOut != pIn1 ); - sqlite3VdbeMemShallowCopy( pOut, pIn1, MEM_Ephem ); - if ( ( pOut.flags & MEM_Ephem ) != 0 && sqlite3VdbeMemMakeWriteable( pOut ) != 0 ) - { - goto no_mem; - }//Deephemeralize( pOut ); - REGISTER_TRACE( p, pOp.p2, pOut ); - break; - } + /* Opcode: Copy P1 P2 * * * + ** + ** Make a copy of register P1 into register P2. + ** + ** This instruction makes a deep copy of the value. A duplicate + ** is made of any string or blob constant. See also OP_SCopy. + */ + case OP_Copy: { /* in1, ref2 */ + pIn1 = aMem[pOp.p1]; + pOut = aMem[pOp.p2]; + + Debug.Assert(pOut != pIn1); + sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem); + if ((pOut.flags & MEM_Ephem) != 0 && sqlite3VdbeMemMakeWriteable(pOut) != 0) { + goto no_mem; + }//Deephemeralize( pOut ); + REGISTER_TRACE(p, pOp.p2, pOut); + break; + } - /* Opcode: SCopy P1 P2 * * * - ** - ** Make a shallow copy of register P1 into register P2. - ** - ** This instruction makes a shallow copy of the value. If the value - ** is a string or blob, then the copy is only a pointer to the - ** original and hence if the original changes so will the copy. - ** Worse, if the original is deallocated, the copy becomes invalid. - ** Thus the program must guarantee that the original will not change - ** during the lifetime of the copy. Use OP_Copy to make a complete - ** copy. - */ - case OP_SCopy: - { /* in1, ref2 */ - pIn1 = aMem[pOp.p1]; - pOut = aMem[pOp.p2]; - Debug.Assert( pOut != pIn1 ); - sqlite3VdbeMemShallowCopy( pOut, pIn1, MEM_Ephem ); + /* Opcode: SCopy P1 P2 * * * + ** + ** Make a shallow copy of register P1 into register P2. + ** + ** This instruction makes a shallow copy of the value. If the value + ** is a string or blob, then the copy is only a pointer to the + ** original and hence if the original changes so will the copy. + ** Worse, if the original is deallocated, the copy becomes invalid. + ** Thus the program must guarantee that the original will not change + ** during the lifetime of the copy. Use OP_Copy to make a complete + ** copy. + */ + case OP_SCopy: { /* in1, ref2 */ + pIn1 = aMem[pOp.p1]; + pOut = aMem[pOp.p2]; + Debug.Assert(pOut != pIn1); + sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem); #if SQLITE_DEBUG - if ( pOut.pScopyFrom == null ) - pOut.pScopyFrom = pIn1; + if (pOut.pScopyFrom == null) + pOut.pScopyFrom = pIn1; #endif - REGISTER_TRACE( p, pOp.p2, pOut ); - break; - } + REGISTER_TRACE(p, pOp.p2, pOut); + break; + } - /* Opcode: ResultRow P1 P2 * * * - ** - ** The registers P1 through P1+P2-1 contain a single row of - ** results. This opcode causes the sqlite3_step() call to terminate - ** with an SQLITE_ROW return code and it sets up the sqlite3_stmt - ** structure to provide access to the top P1 values as the result - ** row. - */ - case OP_ResultRow: - { - //Mem[] pMem; - int i; - Debug.Assert( p.nResColumn == pOp.p2 ); - Debug.Assert( pOp.p1 > 0 ); - Debug.Assert( pOp.p1 + pOp.p2 <= p.nMem + 1 ); - - /* If this statement has violated immediate foreign key constraints, do - ** not return the number of rows modified. And do not RELEASE the statement - ** transaction. It needs to be rolled back. */ - if ( SQLITE_OK != ( rc = sqlite3VdbeCheckFk( p, 0 ) ) ) - { - Debug.Assert( ( db.flags & SQLITE_CountRows ) != 0 ); - Debug.Assert( p.usesStmtJournal ); - break; - } - - /* If the SQLITE_CountRows flag is set in sqlite3.flags mask, then - ** DML statements invoke this opcode to return the number of rows - ** modified to the user. This is the only way that a VM that - ** opens a statement transaction may invoke this opcode. - ** - ** In case this is such a statement, close any statement transaction - ** opened by this VM before returning control to the user. This is to - ** ensure that statement-transactions are always nested, not overlapping. - ** If the open statement-transaction is not closed here, then the user - ** may step another VM that opens its own statement transaction. This - ** may lead to overlapping statement transactions. - ** - ** The statement transaction is never a top-level transaction. Hence - ** the RELEASE call below can never fail. - */ - Debug.Assert( p.iStatement == 0 || ( db.flags & SQLITE_CountRows ) != 0 ); - rc = sqlite3VdbeCloseStatement( p, SAVEPOINT_RELEASE ); - if ( NEVER( rc != SQLITE_OK ) ) - { - break; - } - - /* Invalidate all ephemeral cursor row caches */ - p.cacheCtr = ( p.cacheCtr + 2 ) | 1; - - /* Make sure the results of the current row are \000 terminated - ** and have an assigned type. The results are de-ephemeralized as - ** as side effect. - */ - //pMem = p.pResultSet = aMem[pOp.p1]; - p.pResultSet = new Mem[pOp.p2]; - for ( i = 0; i < pOp.p2; i++ ) - { - p.pResultSet[i] = aMem[pOp.p1 + i]; - Debug.Assert( memIsValid( p.pResultSet[i] ) ); - //Deephemeralize( p.pResultSet[i] ); - //Debug.Assert( ( p.pResultSet[i].flags & MEM_Ephem ) == 0 - // || ( p.pResultSet[i].flags & ( MEM_Str | MEM_Blob ) ) == 0 ); - sqlite3VdbeMemNulTerminate( p.pResultSet[i] ); //sqlite3VdbeMemNulTerminate(pMem[i]); - sqlite3VdbeMemStoreType( p.pResultSet[i] ); - REGISTER_TRACE( p, pOp.p1 + i, p.pResultSet[i] ); - } - // if ( db.mallocFailed != 0 ) goto no_mem; - - /* Return SQLITE_ROW - */ - p.pc = pc + 1; - rc = SQLITE_ROW; - goto vdbe_return; - } + /* Opcode: ResultRow P1 P2 * * * + ** + ** The registers P1 through P1+P2-1 contain a single row of + ** results. This opcode causes the sqlite3_step() call to terminate + ** with an SQLITE_ROW return code and it sets up the sqlite3_stmt + ** structure to provide access to the top P1 values as the result + ** row. + */ + case OP_ResultRow: { + //Mem[] pMem; + int i; + Debug.Assert(p.nResColumn == pOp.p2); + Debug.Assert(pOp.p1 > 0); + Debug.Assert(pOp.p1 + pOp.p2 <= p.nMem + 1); + + /* If this statement has violated immediate foreign key constraints, do + ** not return the number of rows modified. And do not RELEASE the statement + ** transaction. It needs to be rolled back. */ + if (SQLITE_OK != (rc = sqlite3VdbeCheckFk(p, 0))) { + Debug.Assert((db.flags & SQLITE_CountRows) != 0); + Debug.Assert(p.usesStmtJournal); + break; + } + + /* If the SQLITE_CountRows flag is set in sqlite3.flags mask, then + ** DML statements invoke this opcode to return the number of rows + ** modified to the user. This is the only way that a VM that + ** opens a statement transaction may invoke this opcode. + ** + ** In case this is such a statement, close any statement transaction + ** opened by this VM before returning control to the user. This is to + ** ensure that statement-transactions are always nested, not overlapping. + ** If the open statement-transaction is not closed here, then the user + ** may step another VM that opens its own statement transaction. This + ** may lead to overlapping statement transactions. + ** + ** The statement transaction is never a top-level transaction. Hence + ** the RELEASE call below can never fail. + */ + Debug.Assert(p.iStatement == 0 || (db.flags & SQLITE_CountRows) != 0); + rc = sqlite3VdbeCloseStatement(p, SAVEPOINT_RELEASE); + if (NEVER(rc != SQLITE_OK)) { + break; + } + + /* Invalidate all ephemeral cursor row caches */ + p.cacheCtr = (p.cacheCtr + 2) | 1; + + /* Make sure the results of the current row are \000 terminated + ** and have an assigned type. The results are de-ephemeralized as + ** as side effect. + */ + //pMem = p.pResultSet = aMem[pOp.p1]; + p.pResultSet = new Mem[pOp.p2]; + for (i = 0; i < pOp.p2; i++) { + p.pResultSet[i] = aMem[pOp.p1 + i]; + Debug.Assert(memIsValid(p.pResultSet[i])); + //Deephemeralize( p.pResultSet[i] ); + //Debug.Assert( ( p.pResultSet[i].flags & MEM_Ephem ) == 0 + // || ( p.pResultSet[i].flags & ( MEM_Str | MEM_Blob ) ) == 0 ); + sqlite3VdbeMemNulTerminate(p.pResultSet[i]); //sqlite3VdbeMemNulTerminate(pMem[i]); + sqlite3VdbeMemStoreType(p.pResultSet[i]); + REGISTER_TRACE(p, pOp.p1 + i, p.pResultSet[i]); + } + // if ( db.mallocFailed != 0 ) goto no_mem; + + /* Return SQLITE_ROW + */ + p.pc = pc + 1; + rc = SQLITE_ROW; + goto vdbe_return; + } - /* Opcode: Concat P1 P2 P3 * * - ** - ** Add the text in register P1 onto the end of the text in - ** register P2 and store the result in register P3. - ** If either the P1 or P2 text are NULL then store NULL in P3. - ** - ** P3 = P2 || P1 - ** - ** It is illegal for P1 and P3 to be the same register. Sometimes, - ** if P3 is the same register as P2, the implementation is able - ** to avoid a memcpy(). - */ - case OP_Concat: - { /* same as TK_CONCAT, in1, in2, ref3 */ - i64 nByte; - - pIn1 = aMem[pOp.p1]; - pIn2 = aMem[pOp.p2]; - pOut = aMem[pOp.p3]; - Debug.Assert( pIn1 != pOut ); - if ( ( ( pIn1.flags | pIn2.flags ) & MEM_Null ) != 0 ) - { - sqlite3VdbeMemSetNull( pOut ); - break; - } - if ( ExpandBlob( pIn1 ) != 0 || ExpandBlob( pIn2 ) != 0 ) - goto no_mem; - if ( ( ( pIn1.flags & ( MEM_Str | MEM_Blob ) ) == 0 ) && sqlite3VdbeMemStringify( pIn1, encoding ) != 0 ) - { - goto no_mem; - }// Stringify(pIn1, encoding); - if ( ( ( pIn2.flags & ( MEM_Str | MEM_Blob ) ) == 0 ) && sqlite3VdbeMemStringify( pIn2, encoding ) != 0 ) - { - goto no_mem; - }// Stringify(pIn2, encoding); - nByte = pIn1.n + pIn2.n; - if ( nByte > db.aLimit[SQLITE_LIMIT_LENGTH] ) - { - goto too_big; - } - MemSetTypeFlag( pOut, MEM_Str ); - //if ( sqlite3VdbeMemGrow( pOut, (int)nByte + 2, ( pOut == pIn2 ) ? 1 : 0 ) != 0 ) - //{ - // goto no_mem; - //} - //if ( pOut != pIn2 ) - //{ - // memcpy( pOut.z, pIn2.z, pIn2.n ); - //} - //memcpy( &pOut.z[pIn2.n], pIn1.z, pIn1.n ); - if ( pIn2.z != null && pIn2.z.Length >= pIn2.n ) - if ( pIn1.z != null ) - pOut.z = pIn2.z.Substring( 0, pIn2.n ) + ( pIn1.n < pIn1.z.Length ? pIn1.z.Substring( 0, pIn1.n ) : pIn1.z ); - else - { - if ( ( pIn1.flags & MEM_Blob ) == 0 ) //String as Blob - { - StringBuilder sb = new StringBuilder( pIn1.n ); - for ( int i = 0; i < pIn1.n; i++ ) - sb.Append( (byte)pIn1.zBLOB[i] ); - pOut.z = pIn2.z.Substring( 0, pIn2.n ) + sb.ToString(); - } - else // UTF-8 Blob - pOut.z = pIn2.z.Substring( 0, pIn2.n ) + Encoding.UTF8.GetString( pIn1.zBLOB, 0, pIn1.zBLOB.Length ); - } - else - { - pOut.zBLOB = sqlite3Malloc( pIn1.n + pIn2.n ); - Buffer.BlockCopy( pIn2.zBLOB, 0, pOut.zBLOB, 0, pIn2.n ); - if ( pIn1.zBLOB != null ) - Buffer.BlockCopy( pIn1.zBLOB, 0, pOut.zBLOB, pIn2.n, pIn1.n ); - else - for ( int i = 0; i < pIn1.n; i++ ) - pOut.zBLOB[pIn2.n + i] = (byte)pIn1.z[i]; - } //pOut.z[nByte] = 0; - //pOut.z[nByte + 1] = 0; - pOut.flags |= MEM_Term; - pOut.n = (int)nByte; - pOut.enc = encoding; + /* Opcode: Concat P1 P2 P3 * * + ** + ** Add the text in register P1 onto the end of the text in + ** register P2 and store the result in register P3. + ** If either the P1 or P2 text are NULL then store NULL in P3. + ** + ** P3 = P2 || P1 + ** + ** It is illegal for P1 and P3 to be the same register. Sometimes, + ** if P3 is the same register as P2, the implementation is able + ** to avoid a memcpy(). + */ + case OP_Concat: { /* same as TK_CONCAT, in1, in2, ref3 */ + i64 nByte; + + pIn1 = aMem[pOp.p1]; + pIn2 = aMem[pOp.p2]; + pOut = aMem[pOp.p3]; + Debug.Assert(pIn1 != pOut); + if (((pIn1.flags | pIn2.flags) & MEM_Null) != 0) { + sqlite3VdbeMemSetNull(pOut); + break; + } + if (ExpandBlob(pIn1) != 0 || ExpandBlob(pIn2) != 0) + goto no_mem; + if (((pIn1.flags & (MEM_Str | MEM_Blob)) == 0) && sqlite3VdbeMemStringify(pIn1, encoding) != 0) { + goto no_mem; + }// Stringify(pIn1, encoding); + if (((pIn2.flags & (MEM_Str | MEM_Blob)) == 0) && sqlite3VdbeMemStringify(pIn2, encoding) != 0) { + goto no_mem; + }// Stringify(pIn2, encoding); + nByte = pIn1.n + pIn2.n; + if (nByte > db.aLimit[SQLITE_LIMIT_LENGTH]) { + goto too_big; + } + MemSetTypeFlag(pOut, MEM_Str); + //if ( sqlite3VdbeMemGrow( pOut, (int)nByte + 2, ( pOut == pIn2 ) ? 1 : 0 ) != 0 ) + //{ + // goto no_mem; + //} + //if ( pOut != pIn2 ) + //{ + // memcpy( pOut.z, pIn2.z, pIn2.n ); + //} + //memcpy( &pOut.z[pIn2.n], pIn1.z, pIn1.n ); + if (pIn2.z != null && pIn2.z.Length >= pIn2.n) + if (pIn1.z != null) + pOut.z = pIn2.z.Substring(0, pIn2.n) + (pIn1.n < pIn1.z.Length ? pIn1.z.Substring(0, pIn1.n) : pIn1.z); + else { + if ((pIn1.flags & MEM_Blob) == 0) //String as Blob + { + StringBuilder sb = new StringBuilder(pIn1.n); + for (int i = 0; i < pIn1.n; i++) + sb.Append((byte)pIn1.zBLOB[i]); + pOut.z = pIn2.z.Substring(0, pIn2.n) + sb.ToString(); + } else // UTF-8 Blob + pOut.z = pIn2.z.Substring(0, pIn2.n) + Encoding.UTF8.GetString(pIn1.zBLOB, 0, pIn1.zBLOB.Length); + } + else { + pOut.zBLOB = sqlite3Malloc(pIn1.n + pIn2.n); + Buffer.BlockCopy(pIn2.zBLOB, 0, pOut.zBLOB, 0, pIn2.n); + if (pIn1.zBLOB != null) + Buffer.BlockCopy(pIn1.zBLOB, 0, pOut.zBLOB, pIn2.n, pIn1.n); + else + for (int i = 0; i < pIn1.n; i++) + pOut.zBLOB[pIn2.n + i] = (byte)pIn1.z[i]; + } //pOut.z[nByte] = 0; + //pOut.z[nByte + 1] = 0; + pOut.flags |= MEM_Term; + pOut.n = (int)nByte; + pOut.enc = encoding; #if SQLITE_TEST UPDATE_MAX_BLOBSIZE( pOut ); #endif - break; - } + break; + } - /* Opcode: Add P1 P2 P3 * * - ** - ** Add the value in register P1 to the value in register P2 - ** and store the result in register P3. - ** If either input is NULL, the result is NULL. - */ - /* Opcode: Multiply P1 P2 P3 * * - ** - ** - ** Multiply the value in register P1 by the value in register P2 - ** and store the result in register P3. - ** If either input is NULL, the result is NULL. - */ - /* Opcode: Subtract P1 P2 P3 * * - ** - ** Subtract the value in register P1 from the value in register P2 - ** and store the result in register P3. - ** If either input is NULL, the result is NULL. - */ - /* Opcode: Divide P1 P2 P3 * * - ** - ** Divide the value in register P1 by the value in register P2 - ** and store the result in register P3 (P3=P2/P1). If the value in - ** register P1 is zero, then the result is NULL. If either input is - ** NULL, the result is NULL. - */ - /* Opcode: Remainder P1 P2 P3 * * - ** - ** Compute the remainder after integer division of the value in - ** register P1 by the value in register P2 and store the result in P3. - ** If the value in register P2 is zero the result is NULL. - ** If either operand is NULL, the result is NULL. - */ - case OP_Add: /* same as TK_PLUS, in1, in2, ref3 */ - case OP_Subtract: /* same as TK_MINUS, in1, in2, ref3 */ - case OP_Multiply: /* same as TK_STAR, in1, in2, ref3 */ - case OP_Divide: /* same as TK_SLASH, in1, in2, ref3 */ - case OP_Remainder: - { /* same as TK_REM, in1, in2, ref3 */ - int flags; /* Combined MEM_* flags from both inputs */ - i64 iA; /* Integer value of left operand */ - i64 iB = 0; /* Integer value of right operand */ - double rA; /* Real value of left operand */ - double rB; /* Real value of right operand */ - - pIn1 = aMem[pOp.p1]; - applyNumericAffinity( pIn1 ); - pIn2 = aMem[pOp.p2]; - applyNumericAffinity( pIn2 ); - pOut = aMem[pOp.p3]; - flags = pIn1.flags | pIn2.flags; - if ( ( flags & MEM_Null ) != 0 ) - goto arithmetic_result_is_null; - bool fp_math; - if ( !( fp_math = !( ( pIn1.flags & pIn2.flags & MEM_Int ) == MEM_Int ) ) ) - { - iA = pIn1.u.i; - iB = pIn2.u.i; - switch ( pOp.opcode ) - { - case OP_Add: - { - if ( sqlite3AddInt64( ref iB, iA ) != 0 ) - fp_math = true; // goto fp_math - break; - } - case OP_Subtract: - { - if ( sqlite3SubInt64( ref iB, iA ) != 0 ) - fp_math = true; // goto fp_math - break; - } - case OP_Multiply: - { - if ( sqlite3MulInt64( ref iB, iA ) != 0 ) - fp_math = true; // goto fp_math - break; - } - case OP_Divide: - { - if ( iA == 0 ) - goto arithmetic_result_is_null; - if ( iA == -1 && iB == SMALLEST_INT64 ) - { - fp_math = true; // goto fp_math - break; - } - iB /= iA; - break; - } - default: - { - if ( iA == 0 ) - goto arithmetic_result_is_null; - if ( iA == -1 ) - iA = 1; - iB %= iA; - break; - } - } - } - if ( !fp_math ) - { - pOut.u.i = iB; - MemSetTypeFlag( pOut, MEM_Int ); - } - else - { - //fp_math: - rA = sqlite3VdbeRealValue( pIn1 ); - rB = sqlite3VdbeRealValue( pIn2 ); - switch ( pOp.opcode ) - { - case OP_Add: - rB += rA; - break; - case OP_Subtract: - rB -= rA; - break; - case OP_Multiply: - rB *= rA; - break; - case OP_Divide: - { - /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ - if ( rA == (double)0 ) - goto arithmetic_result_is_null; - rB /= rA; - break; - } - default: - { - iA = (i64)rA; - iB = (i64)rB; - if ( iA == 0 ) - goto arithmetic_result_is_null; - if ( iA == -1 ) - iA = 1; - rB = (double)( iB % iA ); - break; - } - } + /* Opcode: Add P1 P2 P3 * * + ** + ** Add the value in register P1 to the value in register P2 + ** and store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + /* Opcode: Multiply P1 P2 P3 * * + ** + ** + ** Multiply the value in register P1 by the value in register P2 + ** and store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + /* Opcode: Subtract P1 P2 P3 * * + ** + ** Subtract the value in register P1 from the value in register P2 + ** and store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + /* Opcode: Divide P1 P2 P3 * * + ** + ** Divide the value in register P1 by the value in register P2 + ** and store the result in register P3 (P3=P2/P1). If the value in + ** register P1 is zero, then the result is NULL. If either input is + ** NULL, the result is NULL. + */ + /* Opcode: Remainder P1 P2 P3 * * + ** + ** Compute the remainder after integer division of the value in + ** register P1 by the value in register P2 and store the result in P3. + ** If the value in register P2 is zero the result is NULL. + ** If either operand is NULL, the result is NULL. + */ + case OP_Add: /* same as TK_PLUS, in1, in2, ref3 */ + case OP_Subtract: /* same as TK_MINUS, in1, in2, ref3 */ + case OP_Multiply: /* same as TK_STAR, in1, in2, ref3 */ + case OP_Divide: /* same as TK_SLASH, in1, in2, ref3 */ + case OP_Remainder: { /* same as TK_REM, in1, in2, ref3 */ + int flags; /* Combined MEM_* flags from both inputs */ + i64 iA; /* Integer value of left operand */ + i64 iB = 0; /* Integer value of right operand */ + double rA; /* Real value of left operand */ + double rB; /* Real value of right operand */ + + pIn1 = aMem[pOp.p1]; + applyNumericAffinity(pIn1); + pIn2 = aMem[pOp.p2]; + applyNumericAffinity(pIn2); + pOut = aMem[pOp.p3]; + flags = pIn1.flags | pIn2.flags; + if ((flags & MEM_Null) != 0) + goto arithmetic_result_is_null; + bool fp_math; + if (!(fp_math = !((pIn1.flags & pIn2.flags & MEM_Int) == MEM_Int))) { + iA = pIn1.u.i; + iB = pIn2.u.i; + switch (pOp.opcode) { + case OP_Add: { + if (sqlite3AddInt64(ref iB, iA) != 0) + fp_math = true; // goto fp_math + break; + } + case OP_Subtract: { + if (sqlite3SubInt64(ref iB, iA) != 0) + fp_math = true; // goto fp_math + break; + } + case OP_Multiply: { + if (sqlite3MulInt64(ref iB, iA) != 0) + fp_math = true; // goto fp_math + break; + } + case OP_Divide: { + if (iA == 0) + goto arithmetic_result_is_null; + if (iA == -1 && iB == SMALLEST_INT64) { + fp_math = true; // goto fp_math + break; + } + iB /= iA; + break; + } + default: { + if (iA == 0) + goto arithmetic_result_is_null; + if (iA == -1) + iA = 1; + iB %= iA; + break; + } + } + } + if (!fp_math) { + pOut.u.i = iB; + MemSetTypeFlag(pOut, MEM_Int); + } else { + //fp_math: + rA = sqlite3VdbeRealValue(pIn1); + rB = sqlite3VdbeRealValue(pIn2); + switch (pOp.opcode) { + case OP_Add: + rB += rA; + break; + case OP_Subtract: + rB -= rA; + break; + case OP_Multiply: + rB *= rA; + break; + case OP_Divide: { + /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ + if (rA == (double)0) + goto arithmetic_result_is_null; + rB /= rA; + break; + } + default: { + iA = (i64)rA; + iB = (i64)rB; + if (iA == 0) + goto arithmetic_result_is_null; + if (iA == -1) + iA = 1; + rB = (double)(iB % iA); + break; + } + } #if SQLITE_OMIT_FLOATING_POINT pOut->u.i = rB; MemSetTypeFlag(pOut, MEM_Int); #else - if ( sqlite3IsNaN( rB ) ) - { - goto arithmetic_result_is_null; - } - pOut.r = rB; - MemSetTypeFlag( pOut, MEM_Real ); - if ( ( flags & MEM_Real ) == 0 ) - { - sqlite3VdbeIntegerAffinity( pOut ); - } + if (sqlite3IsNaN(rB)) { + goto arithmetic_result_is_null; + } + pOut.r = rB; + MemSetTypeFlag(pOut, MEM_Real); + if ((flags & MEM_Real) == 0) { + sqlite3VdbeIntegerAffinity(pOut); + } #endif - } - break; + } + break; -arithmetic_result_is_null: - sqlite3VdbeMemSetNull( pOut ); - break; - } + arithmetic_result_is_null: + sqlite3VdbeMemSetNull(pOut); + break; + } - /* Opcode: CollSeq * * P4 - ** - ** P4 is a pointer to a CollSeq struct. If the next call to a user function - ** or aggregate calls sqlite3GetFuncCollSeq(), this collation sequence will - ** be returned. This is used by the built-in min(), max() and nullif() - ** functions. - ** - ** The interface used by the implementation of the aforementioned functions - ** to retrieve the collation sequence set by this opcode is not available - ** publicly, only to user functions defined in func.c. - */ - case OP_CollSeq: - { - Debug.Assert( pOp.p4type == P4_COLLSEQ ); - break; - } + /* Opcode: CollSeq * * P4 + ** + ** P4 is a pointer to a CollSeq struct. If the next call to a user function + ** or aggregate calls sqlite3GetFuncCollSeq(), this collation sequence will + ** be returned. This is used by the built-in min(), max() and nullif() + ** functions. + ** + ** The interface used by the implementation of the aforementioned functions + ** to retrieve the collation sequence set by this opcode is not available + ** publicly, only to user functions defined in func.c. + */ + case OP_CollSeq: { + Debug.Assert(pOp.p4type == P4_COLLSEQ); + break; + } - /* Opcode: Function P1 P2 P3 P4 P5 - ** - ** Invoke a user function (P4 is a pointer to a Function structure that - ** defines the function) with P5 arguments taken from register P2 and - ** successors. The result of the function is stored in register P3. - ** Register P3 must not be one of the function inputs. - ** - ** P1 is a 32-bit bitmask indicating whether or not each argument to the - ** function was determined to be constant at compile time. If the first - ** argument was constant then bit 0 of P1 is set. This is used to determine - ** whether meta data associated with a user function argument using the - ** sqlite3_set_auxdata() API may be safely retained until the next - ** invocation of this opcode. - ** - ** See also: AggStep and AggFinal - */ - case OP_Function: - { - int i; - Mem pArg; - sqlite3_context ctx = new sqlite3_context(); - sqlite3_value[] apVal; - int n; - - n = pOp.p5; - apVal = p.apArg; - Debug.Assert( apVal != null || n == 0 ); - Debug.Assert( pOp.p3 > 0 && pOp.p3 <= p.nMem ); - pOut = aMem[pOp.p3]; - memAboutToChange( p, pOut ); - - Debug.Assert( n == 0 || ( pOp.p2 > 0 && pOp.p2 + n <= p.nMem + 1 ) ); - Debug.Assert( pOp.p3 < pOp.p2 || pOp.p3 >= pOp.p2 + n ); - //pArg = aMem[pOp.p2]; - for ( i = 0; i < n; i++ )//, pArg++) - { - pArg = aMem[pOp.p2 + i]; - Debug.Assert( memIsValid( pArg ) ); - apVal[i] = pArg; - Deephemeralize( pArg ); - sqlite3VdbeMemStoreType( pArg ); - REGISTER_TRACE( p, pOp.p2 + i, pArg ); - } - - Debug.Assert( pOp.p4type == P4_FUNCDEF || pOp.p4type == P4_VDBEFUNC ); - if ( pOp.p4type == P4_FUNCDEF ) - { - ctx.pFunc = pOp.p4.pFunc; - ctx.pVdbeFunc = null; - } - else - { - ctx.pVdbeFunc = (VdbeFunc)pOp.p4.pVdbeFunc; - ctx.pFunc = ctx.pVdbeFunc.pFunc; - } - - ctx.s.flags = MEM_Null; - ctx.s.db = db; - ctx.s.xDel = null; - //ctx.s.zMalloc = null; - - /* The output cell may already have a buffer allocated. Move - ** the pointer to ctx.s so in case the user-function can use - ** the already allocated buffer instead of allocating a new one. - */ - sqlite3VdbeMemMove( ctx.s, pOut ); - MemSetTypeFlag( ctx.s, MEM_Null ); - - ctx.isError = 0; - if ( ( ctx.pFunc.flags & SQLITE_FUNC_NEEDCOLL ) != 0 ) - { - Debug.Assert( pc > 1 );//Debug.Assert(pOp > aOp); - Debug.Assert( p.aOp[pc - 1].p4type == P4_COLLSEQ );//Debug.Assert(pOp[-1].p4type == P4_COLLSEQ); - Debug.Assert( p.aOp[pc - 1].opcode == OP_CollSeq );//Debug.Assert(pOp[-1].opcode == OP_CollSeq); - ctx.pColl = p.aOp[pc - 1].p4.pColl;//ctx.pColl = pOp[-1].p4.pColl; - } - db.lastRowid = lastRowid; - ctx.pFunc.xFunc( ctx, n, apVal );///* IMP: R-24505-23230 */ - lastRowid = db.lastRowid; - - /* If any auxillary data functions have been called by this user function, - ** immediately call the destructor for any non-static values. - */ - if ( ctx.pVdbeFunc != null ) - { - sqlite3VdbeDeleteAuxData( ctx.pVdbeFunc, pOp.p1 ); - pOp.p4.pVdbeFunc = ctx.pVdbeFunc; - pOp.p4type = P4_VDBEFUNC; - } - - //if ( db->mallocFailed ) - //{ - // /* Even though a malloc() has failed, the implementation of the - // ** user function may have called an sqlite3_result_XXX() function - // ** to return a value. The following call releases any resources - // ** associated with such a value. - // */ - // sqlite3VdbeMemRelease( &u.ag.ctx.s ); - // goto no_mem; - //} - - /* If the function returned an error, throw an exception */ - if ( ctx.isError != 0 ) - { - sqlite3SetString( ref p.zErrMsg, db, sqlite3_value_text( ctx.s ) ); - rc = ctx.isError; - } - - /* Copy the result of the function into register P3 */ - sqlite3VdbeChangeEncoding( ctx.s, encoding ); - sqlite3VdbeMemMove( pOut, ctx.s ); - if ( sqlite3VdbeMemTooBig( pOut ) ) - { - goto too_big; - } + /* Opcode: Function P1 P2 P3 P4 P5 + ** + ** Invoke a user function (P4 is a pointer to a Function structure that + ** defines the function) with P5 arguments taken from register P2 and + ** successors. The result of the function is stored in register P3. + ** Register P3 must not be one of the function inputs. + ** + ** P1 is a 32-bit bitmask indicating whether or not each argument to the + ** function was determined to be constant at compile time. If the first + ** argument was constant then bit 0 of P1 is set. This is used to determine + ** whether meta data associated with a user function argument using the + ** sqlite3_set_auxdata() API may be safely retained until the next + ** invocation of this opcode. + ** + ** See also: AggStep and AggFinal + */ + case OP_Function: { + int i; + Mem pArg; + sqlite3_context ctx = new sqlite3_context(); + sqlite3_value[] apVal; + int n; + + n = pOp.p5; + apVal = p.apArg; + Debug.Assert(apVal != null || n == 0); + Debug.Assert(pOp.p3 > 0 && pOp.p3 <= p.nMem); + pOut = aMem[pOp.p3]; + memAboutToChange(p, pOut); + + Debug.Assert(n == 0 || (pOp.p2 > 0 && pOp.p2 + n <= p.nMem + 1)); + Debug.Assert(pOp.p3 < pOp.p2 || pOp.p3 >= pOp.p2 + n); + //pArg = aMem[pOp.p2]; + for (i = 0; i < n; i++)//, pArg++) + { + pArg = aMem[pOp.p2 + i]; + Debug.Assert(memIsValid(pArg)); + apVal[i] = pArg; + Deephemeralize(pArg); + sqlite3VdbeMemStoreType(pArg); + REGISTER_TRACE(p, pOp.p2 + i, pArg); + } + + Debug.Assert(pOp.p4type == P4_FUNCDEF || pOp.p4type == P4_VDBEFUNC); + if (pOp.p4type == P4_FUNCDEF) { + ctx.pFunc = pOp.p4.pFunc; + ctx.pVdbeFunc = null; + } else { + ctx.pVdbeFunc = (VdbeFunc)pOp.p4.pVdbeFunc; + ctx.pFunc = ctx.pVdbeFunc.pFunc; + } + + ctx.s.flags = MEM_Null; + ctx.s.db = db; + ctx.s.xDel = null; + //ctx.s.zMalloc = null; + + /* The output cell may already have a buffer allocated. Move + ** the pointer to ctx.s so in case the user-function can use + ** the already allocated buffer instead of allocating a new one. + */ + sqlite3VdbeMemMove(ctx.s, pOut); + MemSetTypeFlag(ctx.s, MEM_Null); + + ctx.isError = 0; + if ((ctx.pFunc.flags & SQLITE_FUNC_NEEDCOLL) != 0) { + Debug.Assert(pc > 1);//Debug.Assert(pOp > aOp); + Debug.Assert(p.aOp[pc - 1].p4type == P4_COLLSEQ);//Debug.Assert(pOp[-1].p4type == P4_COLLSEQ); + Debug.Assert(p.aOp[pc - 1].opcode == OP_CollSeq);//Debug.Assert(pOp[-1].opcode == OP_CollSeq); + ctx.pColl = p.aOp[pc - 1].p4.pColl;//ctx.pColl = pOp[-1].p4.pColl; + } + db.lastRowid = lastRowid; + ctx.pFunc.xFunc(ctx, n, apVal);///* IMP: R-24505-23230 */ + lastRowid = db.lastRowid; + + /* If any auxillary data functions have been called by this user function, + ** immediately call the destructor for any non-static values. + */ + if (ctx.pVdbeFunc != null) { + sqlite3VdbeDeleteAuxData(ctx.pVdbeFunc, pOp.p1); + pOp.p4.pVdbeFunc = ctx.pVdbeFunc; + pOp.p4type = P4_VDBEFUNC; + } + + //if ( db->mallocFailed ) + //{ + // /* Even though a malloc() has failed, the implementation of the + // ** user function may have called an sqlite3_result_XXX() function + // ** to return a value. The following call releases any resources + // ** associated with such a value. + // */ + // sqlite3VdbeMemRelease( &u.ag.ctx.s ); + // goto no_mem; + //} + + /* If the function returned an error, throw an exception */ + if (ctx.isError != 0) { + sqlite3SetString(ref p.zErrMsg, db, sqlite3_value_text(ctx.s)); + rc = ctx.isError; + } + + /* Copy the result of the function into register P3 */ + sqlite3VdbeChangeEncoding(ctx.s, encoding); + sqlite3VdbeMemMove(pOut, ctx.s); + if (sqlite3VdbeMemTooBig(pOut)) { + goto too_big; + } #if FALSE /* The app-defined function has done something that as caused this ** statement to expire. (Perhaps the function called sqlite3_exec() @@ -1804,2297 +1639,2035 @@ Vdbe p /* The VDBE */ if( p.expired ) rc = SQLITE_ABORT; #endif - REGISTER_TRACE( p, pOp.p3, pOut ); + REGISTER_TRACE(p, pOp.p3, pOut); #if SQLITE_TEST UPDATE_MAX_BLOBSIZE( pOut ); #endif - break; - } + break; + } + + /* Opcode: BitAnd P1 P2 P3 * * + ** + ** Take the bit-wise AND of the values in register P1 and P2 and + ** store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + /* Opcode: BitOr P1 P2 P3 * * + ** + ** Take the bit-wise OR of the values in register P1 and P2 and + ** store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + /* Opcode: ShiftLeft P1 P2 P3 * * + ** + ** Shift the integer value in register P2 to the left by the + ** number of bits specified by the integer in register P1. + ** Store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + /* Opcode: ShiftRight P1 P2 P3 * * + ** + ** Shift the integer value in register P2 to the right by the + ** number of bits specified by the integer in register P1. + ** Store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + case OP_BitAnd: /* same as TK_BITAND, in1, in2, ref3 */ + case OP_BitOr: /* same as TK_BITOR, in1, in2, ref3 */ + case OP_ShiftLeft: /* same as TK_LSHIFT, in1, in2, ref3 */ + case OP_ShiftRight: { /* same as TK_RSHIFT, in1, in2, ref3 */ + i64 iA; + u64 uA; + i64 iB; + u8 op; + + pIn1 = aMem[pOp.p1]; + pIn2 = aMem[pOp.p2]; + pOut = aMem[pOp.p3]; + if (((pIn1.flags | pIn2.flags) & MEM_Null) != 0) { + sqlite3VdbeMemSetNull(pOut); + break; + } + iA = sqlite3VdbeIntValue(pIn2); + iB = sqlite3VdbeIntValue(pIn1); + op = pOp.opcode; + if (op == OP_BitAnd) { + iA &= iB; + } else if (op == OP_BitOr) { + iA |= iB; + } else if (iB != 0) { + Debug.Assert(op == OP_ShiftRight || op == OP_ShiftLeft); + + /* If shifting by a negative amount, shift in the other direction */ + if (iB < 0) { + Debug.Assert(OP_ShiftRight == OP_ShiftLeft + 1); + op = (u8)(2 * OP_ShiftLeft + 1 - op); + iB = iB > (-64) ? -iB : 64; + } + + if (iB >= 64) { + iA = (iA >= 0 || op == OP_ShiftLeft) ? 0 : -1; + } else { + //uA = (ulong)(iA << 0); // memcpy( &uA, &iA, sizeof( uA ) ); + if (op == OP_ShiftLeft) { + iA = iA << (int)iB; + } else { + iA = iA >> (int)iB; + /* Sign-extend on a right shift of a negative number */ + //if ( iA < 0 ) + // uA |= ( ( (0xffffffff ) << (u8)32 ) | 0xffffffff ) << (u8)( 64 - iB ); + } + //iA = (long)( uA << 0 ); //memcpy( &iA, &uA, sizeof( iA ) ); + } + } + pOut.u.i = iA; + MemSetTypeFlag(pOut, MEM_Int); + break; + } + + /* Opcode: AddImm P1 P2 * * * + ** + ** Add the constant P2 to the value in register P1. + ** The result is always an integer. + ** + ** To force any register to be an integer, just add 0. + */ + case OP_AddImm: { /* in1 */ + pIn1 = aMem[pOp.p1]; + memAboutToChange(p, pIn1); + sqlite3VdbeMemIntegerify(pIn1); + pIn1.u.i += pOp.p2; + break; + } + + /* Opcode: MustBeInt P1 P2 * * * + ** + ** Force the value in register P1 to be an integer. If the value + ** in P1 is not an integer and cannot be converted into an integer + ** without data loss, then jump immediately to P2, or if P2==0 + ** raise an SQLITE_MISMATCH exception. + */ + case OP_MustBeInt: { /* jump, in1 */ + pIn1 = aMem[pOp.p1]; + applyAffinity(pIn1, SQLITE_AFF_NUMERIC, encoding); + if ((pIn1.flags & MEM_Int) == 0) { + if (pOp.p2 == 0) { + rc = SQLITE_MISMATCH; + goto abort_due_to_error; + } else { + pc = pOp.p2 - 1; + } + } else { + MemSetTypeFlag(pIn1, MEM_Int); + } + break; + } - /* Opcode: BitAnd P1 P2 P3 * * +#if !SQLITE_OMIT_FLOATING_POINT + /* Opcode: RealAffinity P1 * * * * ** - ** Take the bit-wise AND of the values in register P1 and P2 and - ** store the result in register P3. - ** If either input is NULL, the result is NULL. - */ - /* Opcode: BitOr P1 P2 P3 * * + ** If register P1 holds an integer convert it to a real value. ** - ** Take the bit-wise OR of the values in register P1 and P2 and - ** store the result in register P3. - ** If either input is NULL, the result is NULL. + ** This opcode is used when extracting information from a column that + ** has REAL affinity. Such column values may still be stored as + ** integers, for space efficiency, but after extraction we want them + ** to have only a real value. */ - /* Opcode: ShiftLeft P1 P2 P3 * * + case OP_RealAffinity: { /* in1 */ + pIn1 = aMem[pOp.p1]; + if ((pIn1.flags & MEM_Int) != 0) { + sqlite3VdbeMemRealify(pIn1); + } + break; + } +#endif + +#if !SQLITE_OMIT_CAST + /* Opcode: ToText P1 * * * * ** - ** Shift the integer value in register P2 to the left by the - ** number of bits specified by the integer in register P1. - ** Store the result in register P3. - ** If either input is NULL, the result is NULL. - */ - /* Opcode: ShiftRight P1 P2 P3 * * + ** Force the value in register P1 to be text. + ** If the value is numeric, convert it to a string using the + ** equivalent of printf(). Blob values are unchanged and + ** are afterwards simply interpreted as text. ** - ** Shift the integer value in register P2 to the right by the - ** number of bits specified by the integer in register P1. - ** Store the result in register P3. - ** If either input is NULL, the result is NULL. + ** A NULL value is not changed by this routine. It remains NULL. */ - case OP_BitAnd: /* same as TK_BITAND, in1, in2, ref3 */ - case OP_BitOr: /* same as TK_BITOR, in1, in2, ref3 */ - case OP_ShiftLeft: /* same as TK_LSHIFT, in1, in2, ref3 */ - case OP_ShiftRight: - { /* same as TK_RSHIFT, in1, in2, ref3 */ - i64 iA; - u64 uA; - i64 iB; - u8 op; - - pIn1 = aMem[pOp.p1]; - pIn2 = aMem[pOp.p2]; - pOut = aMem[pOp.p3]; - if ( ( ( pIn1.flags | pIn2.flags ) & MEM_Null ) != 0 ) - { - sqlite3VdbeMemSetNull( pOut ); - break; - } - iA = sqlite3VdbeIntValue( pIn2 ); - iB = sqlite3VdbeIntValue( pIn1 ); - op = pOp.opcode; - if ( op == OP_BitAnd ) - { - iA &= iB; - } - else if ( op == OP_BitOr ) - { - iA |= iB; - } - else if ( iB != 0 ) - { - Debug.Assert( op == OP_ShiftRight || op == OP_ShiftLeft ); - - /* If shifting by a negative amount, shift in the other direction */ - if ( iB < 0 ) - { - Debug.Assert( OP_ShiftRight == OP_ShiftLeft + 1 ); - op = (u8)( 2 * OP_ShiftLeft + 1 - op ); - iB = iB > ( -64 ) ? -iB : 64; - } + case OP_ToText: { /* same as TK_TO_TEXT, in1 */ + pIn1 = aMem[pOp.p1]; + memAboutToChange(p, pIn1); + if ((pIn1.flags & MEM_Null) != 0) + break; + Debug.Assert(MEM_Str == (MEM_Blob >> 3)); + pIn1.flags |= (u16)((pIn1.flags & MEM_Blob) >> 3); + applyAffinity(pIn1, SQLITE_AFF_TEXT, encoding); + rc = ExpandBlob(pIn1); + Debug.Assert((pIn1.flags & MEM_Str) != 0 /*|| db.mallocFailed != 0 */ ); + pIn1.flags = (u16)(pIn1.flags & ~(MEM_Int | MEM_Real | MEM_Blob | MEM_Zero)); +#if SQLITE_TEST + UPDATE_MAX_BLOBSIZE( pIn1 ); +#endif + break; + } - if ( iB >= 64 ) - { - iA = ( iA >= 0 || op == OP_ShiftLeft ) ? 0 : -1; - } - else - { - //uA = (ulong)(iA << 0); // memcpy( &uA, &iA, sizeof( uA ) ); - if ( op == OP_ShiftLeft ) - { - iA = iA << (int)iB; - } - else - { - iA = iA >> (int)iB; - /* Sign-extend on a right shift of a negative number */ - //if ( iA < 0 ) - // uA |= ( ( (0xffffffff ) << (u8)32 ) | 0xffffffff ) << (u8)( 64 - iB ); - } - //iA = (long)( uA << 0 ); //memcpy( &iA, &uA, sizeof( iA ) ); - } - } - pOut.u.i = iA; - MemSetTypeFlag( pOut, MEM_Int ); - break; - } + /* Opcode: ToBlob P1 * * * * + ** + ** Force the value in register P1 to be a BLOB. + ** If the value is numeric, convert it to a string first. + ** Strings are simply reinterpreted as blobs with no change + ** to the underlying data. + ** + ** A NULL value is not changed by this routine. It remains NULL. + */ + case OP_ToBlob: { /* same as TK_TO_BLOB, in1 */ + pIn1 = aMem[pOp.p1]; + if ((pIn1.flags & MEM_Null) != 0) + break; + if ((pIn1.flags & MEM_Blob) == 0) { + applyAffinity(pIn1, SQLITE_AFF_TEXT, encoding); + Debug.Assert((pIn1.flags & MEM_Str) != 0 /*|| db.mallocFailed != 0 */ ); + MemSetTypeFlag(pIn1, MEM_Blob); + } else { + pIn1.flags = (ushort)(pIn1.flags & ~(MEM_TypeMask & ~MEM_Blob)); + } +#if SQLITE_TEST + UPDATE_MAX_BLOBSIZE( pIn1 ); +#endif + break; + } + + /* Opcode: ToNumeric P1 * * * * + ** + ** Force the value in register P1 to be numeric (either an + ** integer or a floating-point number.) + ** If the value is text or blob, try to convert it to an using the + ** equivalent of atoi() or atof() and store 0 if no such conversion + ** is possible. + ** + ** A NULL value is not changed by this routine. It remains NULL. + */ + case OP_ToNumeric: { /* same as TK_TO_NUMERIC, in1 */ + pIn1 = aMem[pOp.p1]; + sqlite3VdbeMemNumerify(pIn1); + break; + } +#endif // * SQLITE_OMIT_CAST */ - /* Opcode: AddImm P1 P2 * * * + /* Opcode: ToInt P1 * * * * ** - ** Add the constant P2 to the value in register P1. - ** The result is always an integer. + ** Force the value in register P1 to be an integer. If + ** The value is currently a real number, drop its fractional part. + ** If the value is text or blob, try to convert it to an integer using the + ** equivalent of atoi() and store 0 if no such conversion is possible. ** - ** To force any register to be an integer, just add 0. + ** A NULL value is not changed by this routine. It remains NULL. */ - case OP_AddImm: - { /* in1 */ - pIn1 = aMem[pOp.p1]; - memAboutToChange( p, pIn1 ); - sqlite3VdbeMemIntegerify( pIn1 ); - pIn1.u.i += pOp.p2; - break; - } + case OP_ToInt: { /* same as TK_TO_INT, in1 */ + pIn1 = aMem[pOp.p1]; + if ((pIn1.flags & MEM_Null) == 0) { + sqlite3VdbeMemIntegerify(pIn1); + } + break; + } - /* Opcode: MustBeInt P1 P2 * * * - ** - ** Force the value in register P1 to be an integer. If the value - ** in P1 is not an integer and cannot be converted into an integer - ** without data loss, then jump immediately to P2, or if P2==0 - ** raise an SQLITE_MISMATCH exception. - */ - case OP_MustBeInt: - { /* jump, in1 */ - pIn1 = aMem[pOp.p1]; - applyAffinity( pIn1, SQLITE_AFF_NUMERIC, encoding ); - if ( ( pIn1.flags & MEM_Int ) == 0 ) - { - if ( pOp.p2 == 0 ) - { - rc = SQLITE_MISMATCH; - goto abort_due_to_error; - } - else - { - pc = pOp.p2 - 1; - } - } - else - { - MemSetTypeFlag( pIn1, MEM_Int ); - } - break; - } - -#if !SQLITE_OMIT_FLOATING_POINT - /* Opcode: RealAffinity P1 * * * * -** -** If register P1 holds an integer convert it to a real value. -** -** This opcode is used when extracting information from a column that -** has REAL affinity. Such column values may still be stored as -** integers, for space efficiency, but after extraction we want them -** to have only a real value. -*/ - case OP_RealAffinity: - { /* in1 */ - pIn1 = aMem[pOp.p1]; - if ( ( pIn1.flags & MEM_Int ) != 0 ) - { - sqlite3VdbeMemRealify( pIn1 ); - } - break; - } -#endif - -#if !SQLITE_OMIT_CAST - /* Opcode: ToText P1 * * * * -** -** Force the value in register P1 to be text. -** If the value is numeric, convert it to a string using the -** equivalent of printf(). Blob values are unchanged and -** are afterwards simply interpreted as text. -** -** A NULL value is not changed by this routine. It remains NULL. -*/ - case OP_ToText: - { /* same as TK_TO_TEXT, in1 */ - pIn1 = aMem[pOp.p1]; - memAboutToChange( p, pIn1 ); - if ( ( pIn1.flags & MEM_Null ) != 0 ) - break; - Debug.Assert( MEM_Str == ( MEM_Blob >> 3 ) ); - pIn1.flags |= (u16)( ( pIn1.flags & MEM_Blob ) >> 3 ); - applyAffinity( pIn1, SQLITE_AFF_TEXT, encoding ); - rc = ExpandBlob( pIn1 ); - Debug.Assert( ( pIn1.flags & MEM_Str ) != 0 /*|| db.mallocFailed != 0 */ ); - pIn1.flags = (u16)( pIn1.flags & ~( MEM_Int | MEM_Real | MEM_Blob | MEM_Zero ) ); -#if SQLITE_TEST - UPDATE_MAX_BLOBSIZE( pIn1 ); -#endif - break; - } - - /* Opcode: ToBlob P1 * * * * - ** - ** Force the value in register P1 to be a BLOB. - ** If the value is numeric, convert it to a string first. - ** Strings are simply reinterpreted as blobs with no change - ** to the underlying data. - ** - ** A NULL value is not changed by this routine. It remains NULL. - */ - case OP_ToBlob: - { /* same as TK_TO_BLOB, in1 */ - pIn1 = aMem[pOp.p1]; - if ( ( pIn1.flags & MEM_Null ) != 0 ) - break; - if ( ( pIn1.flags & MEM_Blob ) == 0 ) - { - applyAffinity( pIn1, SQLITE_AFF_TEXT, encoding ); - Debug.Assert( ( pIn1.flags & MEM_Str ) != 0 /*|| db.mallocFailed != 0 */ ); - MemSetTypeFlag( pIn1, MEM_Blob ); - } - else - { - pIn1.flags = (ushort)( pIn1.flags & ~( MEM_TypeMask & ~MEM_Blob ) ); - } -#if SQLITE_TEST - UPDATE_MAX_BLOBSIZE( pIn1 ); -#endif - break; - } - - /* Opcode: ToNumeric P1 * * * * +#if !(SQLITE_OMIT_CAST) && !(SQLITE_OMIT_FLOATING_POINT) + /* Opcode: ToReal P1 * * * * ** - ** Force the value in register P1 to be numeric (either an - ** integer or a floating-point number.) - ** If the value is text or blob, try to convert it to an using the - ** equivalent of atoi() or atof() and store 0 if no such conversion - ** is possible. + ** Force the value in register P1 to be a floating point number. + ** If The value is currently an integer, convert it. + ** If the value is text or blob, try to convert it to an integer using the + ** equivalent of atoi() and store 0.0 if no such conversion is possible. ** ** A NULL value is not changed by this routine. It remains NULL. */ - case OP_ToNumeric: - { /* same as TK_TO_NUMERIC, in1 */ - pIn1 = aMem[pOp.p1]; - sqlite3VdbeMemNumerify( pIn1 ); - break; - } -#endif // * SQLITE_OMIT_CAST */ - - /* Opcode: ToInt P1 * * * * -** -** Force the value in register P1 to be an integer. If -** The value is currently a real number, drop its fractional part. -** If the value is text or blob, try to convert it to an integer using the -** equivalent of atoi() and store 0 if no such conversion is possible. -** -** A NULL value is not changed by this routine. It remains NULL. -*/ - case OP_ToInt: - { /* same as TK_TO_INT, in1 */ - pIn1 = aMem[pOp.p1]; - if ( ( pIn1.flags & MEM_Null ) == 0 ) - { - sqlite3VdbeMemIntegerify( pIn1 ); - } - break; - } - -#if !(SQLITE_OMIT_CAST) && !(SQLITE_OMIT_FLOATING_POINT) - /* Opcode: ToReal P1 * * * * -** -** Force the value in register P1 to be a floating point number. -** If The value is currently an integer, convert it. -** If the value is text or blob, try to convert it to an integer using the -** equivalent of atoi() and store 0.0 if no such conversion is possible. -** -** A NULL value is not changed by this routine. It remains NULL. -*/ - case OP_ToReal: - { /* same as TK_TO_REAL, in1 */ - pIn1 = aMem[pOp.p1]; - memAboutToChange( p, pIn1 ); - if ( ( pIn1.flags & MEM_Null ) == 0 ) - { - sqlite3VdbeMemRealify( pIn1 ); - } - break; - } + case OP_ToReal: { /* same as TK_TO_REAL, in1 */ + pIn1 = aMem[pOp.p1]; + memAboutToChange(p, pIn1); + if ((pIn1.flags & MEM_Null) == 0) { + sqlite3VdbeMemRealify(pIn1); + } + break; + } #endif //* !defined(SQLITE_OMIT_CAST) && !defined(SQLITE_OMIT_FLOATING_POINT) */ - /* Opcode: Lt P1 P2 P3 P4 P5 -** -** Compare the values in register P1 and P3. If reg(P3)flags */ - u16 flags3; /* Copy of initial value of pIn3->flags */ - pIn1 = aMem[pOp.p1]; - pIn3 = aMem[pOp.p3]; - flags1 = pIn1.flags; - flags3 = pIn3.flags; - if ( ( ( pIn1.flags | pIn3.flags ) & MEM_Null ) != 0 ) - { - /* One or both operands are NULL */ - if ( ( pOp.p5 & SQLITE_NULLEQ ) != 0 ) - { - /* If SQLITE_NULLEQ is set (which will only happen if the operator is - ** OP_Eq or OP_Ne) then take the jump or not depending on whether - ** or not both operands are null. - */ - Debug.Assert( pOp.opcode == OP_Eq || pOp.opcode == OP_Ne ); - res = ( pIn1.flags & pIn3.flags & MEM_Null ) == 0 ? 1 : 0; - } - else - { - /* SQLITE_NULLEQ is clear and at least one operand is NULL, - ** then the result is always NULL. - ** The jump is taken if the SQLITE_JUMPIFNULL bit is set. - */ - if ( ( pOp.p5 & SQLITE_STOREP2 ) != 0 ) - { - pOut = aMem[pOp.p2]; - MemSetTypeFlag( pOut, MEM_Null ); - REGISTER_TRACE( p, pOp.p2, pOut ); - } - else if ( ( pOp.p5 & SQLITE_JUMPIFNULL ) != 0 ) - { - pc = pOp.p2 - 1; - } - break; - } - - } - else - { - /* Neither operand is NULL. Do a comparison. */ - affinity = (char)( pOp.p5 & SQLITE_AFF_MASK ); - if ( affinity != '\0' ) - { - applyAffinity( pIn1, affinity, encoding ); - applyAffinity( pIn3, affinity, encoding ); - // if ( db.mallocFailed != 0 ) goto no_mem; - } - - Debug.Assert( pOp.p4type == P4_COLLSEQ || pOp.p4.pColl == null ); - ExpandBlob( pIn1 ); - ExpandBlob( pIn3 ); - res = sqlite3MemCompare( pIn3, pIn1, pOp.p4.pColl ); - } - switch ( pOp.opcode ) - { - case OP_Eq: - res = ( res == 0 ) ? 1 : 0; - break; - case OP_Ne: - res = ( res != 0 ) ? 1 : 0; - break; - case OP_Lt: - res = ( res < 0 ) ? 1 : 0; - break; - case OP_Le: - res = ( res <= 0 ) ? 1 : 0; - break; - case OP_Gt: - res = ( res > 0 ) ? 1 : 0; - break; - default: - res = ( res >= 0 ) ? 1 : 0; - break; - } - - if ( ( pOp.p5 & SQLITE_STOREP2 ) != 0 ) - { - pOut = aMem[pOp.p2]; - memAboutToChange( p, pOut ); - MemSetTypeFlag( pOut, MEM_Int ); - pOut.u.i = res; - REGISTER_TRACE( p, pOp.p2, pOut ); - } - else if ( res != 0 ) - { - pc = pOp.p2 - 1; - } - - /* Undo any changes made by applyAffinity() to the input registers. */ - pIn1.flags = (u16)( ( pIn1.flags & ~MEM_TypeMask ) | ( flags1 & MEM_TypeMask ) ); - pIn3.flags = (u16)( ( pIn3.flags & ~MEM_TypeMask ) | ( flags3 & MEM_TypeMask ) ); - break; - } + /* Opcode: Ne P1 P2 P3 P4 P5 + ** + ** This works just like the Lt opcode except that the jump is taken if + ** the operands in registers P1 and P3 are not equal. See the Lt opcode for + ** additional information. + ** + ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either + ** true or false and is never NULL. If both operands are NULL then the result + ** of comparison is false. If either operand is NULL then the result is true. + ** If neither operand is NULL the result is the same as it would be if + ** the SQLITE_NULLEQ flag were omitted from P5. + */ + /* Opcode: Eq P1 P2 P3 P4 P5 + ** + ** This works just like the Lt opcode except that the jump is taken if + ** the operands in registers P1 and P3 are equal. + ** See the Lt opcode for additional information. + ** + ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either + ** true or false and is never NULL. If both operands are NULL then the result + ** of comparison is true. If either operand is NULL then the result is false. + ** If neither operand is NULL the result is the same as it would be if + ** the SQLITE_NULLEQ flag were omitted from P5. + */ + /* Opcode: Le P1 P2 P3 P4 P5 + ** + ** This works just like the Lt opcode except that the jump is taken if + ** the content of register P3 is less than or equal to the content of + ** register P1. See the Lt opcode for additional information. + */ + /* Opcode: Gt P1 P2 P3 P4 P5 + ** + ** This works just like the Lt opcode except that the jump is taken if + ** the content of register P3 is greater than the content of + ** register P1. See the Lt opcode for additional information. + */ + /* Opcode: Ge P1 P2 P3 P4 P5 + ** + ** This works just like the Lt opcode except that the jump is taken if + ** the content of register P3 is greater than or equal to the content of + ** register P1. See the Lt opcode for additional information. + */ + case OP_Eq: /* same as TK_EQ, jump, in1, in3 */ + case OP_Ne: /* same as TK_NE, jump, in1, in3 */ + case OP_Lt: /* same as TK_LT, jump, in1, in3 */ + case OP_Le: /* same as TK_LE, jump, in1, in3 */ + case OP_Gt: /* same as TK_GT, jump, in1, in3 */ + case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ + int res = 0; /* Result of the comparison of pIn1 against pIn3 */ + char affinity; /* Affinity to use for comparison */ + u16 flags1; /* Copy of initial value of pIn1->flags */ + u16 flags3; /* Copy of initial value of pIn3->flags */ + pIn1 = aMem[pOp.p1]; + pIn3 = aMem[pOp.p3]; + flags1 = pIn1.flags; + flags3 = pIn3.flags; + if (((pIn1.flags | pIn3.flags) & MEM_Null) != 0) { + /* One or both operands are NULL */ + if ((pOp.p5 & SQLITE_NULLEQ) != 0) { + /* If SQLITE_NULLEQ is set (which will only happen if the operator is + ** OP_Eq or OP_Ne) then take the jump or not depending on whether + ** or not both operands are null. + */ + Debug.Assert(pOp.opcode == OP_Eq || pOp.opcode == OP_Ne); + res = (pIn1.flags & pIn3.flags & MEM_Null) == 0 ? 1 : 0; + } else { + /* SQLITE_NULLEQ is clear and at least one operand is NULL, + ** then the result is always NULL. + ** The jump is taken if the SQLITE_JUMPIFNULL bit is set. + */ + if ((pOp.p5 & SQLITE_STOREP2) != 0) { + pOut = aMem[pOp.p2]; + MemSetTypeFlag(pOut, MEM_Null); + REGISTER_TRACE(p, pOp.p2, pOut); + } else if ((pOp.p5 & SQLITE_JUMPIFNULL) != 0) { + pc = pOp.p2 - 1; + } + break; + } + + } else { + /* Neither operand is NULL. Do a comparison. */ + affinity = (char)(pOp.p5 & SQLITE_AFF_MASK); + if (affinity != '\0') { + applyAffinity(pIn1, affinity, encoding); + applyAffinity(pIn3, affinity, encoding); + // if ( db.mallocFailed != 0 ) goto no_mem; + } + + Debug.Assert(pOp.p4type == P4_COLLSEQ || pOp.p4.pColl == null); + ExpandBlob(pIn1); + ExpandBlob(pIn3); + res = sqlite3MemCompare(pIn3, pIn1, pOp.p4.pColl); + } + switch (pOp.opcode) { + case OP_Eq: + res = (res == 0) ? 1 : 0; + break; + case OP_Ne: + res = (res != 0) ? 1 : 0; + break; + case OP_Lt: + res = (res < 0) ? 1 : 0; + break; + case OP_Le: + res = (res <= 0) ? 1 : 0; + break; + case OP_Gt: + res = (res > 0) ? 1 : 0; + break; + default: + res = (res >= 0) ? 1 : 0; + break; + } + + if ((pOp.p5 & SQLITE_STOREP2) != 0) { + pOut = aMem[pOp.p2]; + memAboutToChange(p, pOut); + MemSetTypeFlag(pOut, MEM_Int); + pOut.u.i = res; + REGISTER_TRACE(p, pOp.p2, pOut); + } else if (res != 0) { + pc = pOp.p2 - 1; + } + + /* Undo any changes made by applyAffinity() to the input registers. */ + pIn1.flags = (u16)((pIn1.flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask)); + pIn3.flags = (u16)((pIn3.flags & ~MEM_TypeMask) | (flags3 & MEM_TypeMask)); + break; + } - /* Opcode: Permutation * * * P4 * - ** - ** Set the permutation used by the OP_Compare operator to be the array - ** of integers in P4. - ** - ** The permutation is only valid until the next OP_Permutation, OP_Compare, - ** OP_Halt, or OP_ResultRow. Typically the OP_Permutation should occur - ** immediately prior to the OP_Compare. - */ - case OP_Permutation: - { - Debug.Assert( pOp.p4type == P4_INTARRAY ); - Debug.Assert( pOp.p4.ai != null ); - aPermute = pOp.p4.ai; - break; - } + /* Opcode: Permutation * * * P4 * + ** + ** Set the permutation used by the OP_Compare operator to be the array + ** of integers in P4. + ** + ** The permutation is only valid until the next OP_Permutation, OP_Compare, + ** OP_Halt, or OP_ResultRow. Typically the OP_Permutation should occur + ** immediately prior to the OP_Compare. + */ + case OP_Permutation: { + Debug.Assert(pOp.p4type == P4_INTARRAY); + Debug.Assert(pOp.p4.ai != null); + aPermute = pOp.p4.ai; + break; + } - /* Opcode: Compare P1 P2 P3 P4 * - ** - ** Compare two vectors of registers in reg(P1)..reg(P1+P3-1) (call this - ** vector "A") and in reg(P2)..reg(P2+P3-1) ("B"). Save the result of - ** the comparison for use by the next OP_Jump instruct. - ** - ** P4 is a KeyInfo structure that defines collating sequences and sort - ** orders for the comparison. The permutation applies to registers - ** only. The KeyInfo elements are used sequentially. - ** - ** The comparison is a sort comparison, so NULLs compare equal, - ** NULLs are less than numbers, numbers are less than strings, - ** and strings are less than blobs. - */ - case OP_Compare: - { - int n; - int i; - int p1; - int p2; - KeyInfo pKeyInfo; - int idx; - CollSeq pColl; /* Collating sequence to use on this term */ - int bRev; /* True for DESCENDING sort order */ - - n = pOp.p3; - pKeyInfo = pOp.p4.pKeyInfo; - Debug.Assert( n > 0 ); - Debug.Assert( pKeyInfo != null ); - p1 = pOp.p1; - p2 = pOp.p2; + /* Opcode: Compare P1 P2 P3 P4 * + ** + ** Compare two vectors of registers in reg(P1)..reg(P1+P3-1) (call this + ** vector "A") and in reg(P2)..reg(P2+P3-1) ("B"). Save the result of + ** the comparison for use by the next OP_Jump instruct. + ** + ** P4 is a KeyInfo structure that defines collating sequences and sort + ** orders for the comparison. The permutation applies to registers + ** only. The KeyInfo elements are used sequentially. + ** + ** The comparison is a sort comparison, so NULLs compare equal, + ** NULLs are less than numbers, numbers are less than strings, + ** and strings are less than blobs. + */ + case OP_Compare: { + int n; + int i; + int p1; + int p2; + KeyInfo pKeyInfo; + int idx; + CollSeq pColl; /* Collating sequence to use on this term */ + int bRev; /* True for DESCENDING sort order */ + + n = pOp.p3; + pKeyInfo = pOp.p4.pKeyInfo; + Debug.Assert(n > 0); + Debug.Assert(pKeyInfo != null); + p1 = pOp.p1; + p2 = pOp.p2; #if SQLITE_DEBUG - if ( aPermute != null ) - { - int k, mx = 0; - for ( k = 0; k < n; k++ ) - if ( aPermute[k] > mx ) - mx = aPermute[k]; - Debug.Assert( p1 > 0 && p1 + mx <= p.nMem + 1 ); - Debug.Assert( p2 > 0 && p2 + mx <= p.nMem + 1 ); - } - else - { - Debug.Assert( p1 > 0 && p1 + n <= p.nMem + 1 ); - Debug.Assert( p2 > 0 && p2 + n <= p.nMem + 1 ); - } + if (aPermute != null) { + int k, mx = 0; + for (k = 0; k < n; k++) + if (aPermute[k] > mx) + mx = aPermute[k]; + Debug.Assert(p1 > 0 && p1 + mx <= p.nMem + 1); + Debug.Assert(p2 > 0 && p2 + mx <= p.nMem + 1); + } else { + Debug.Assert(p1 > 0 && p1 + n <= p.nMem + 1); + Debug.Assert(p2 > 0 && p2 + n <= p.nMem + 1); + } #endif //* SQLITE_DEBUG */ - for ( i = 0; i < n; i++ ) - { - idx = aPermute != null ? aPermute[i] : i; - Debug.Assert( memIsValid( aMem[p1 + idx] ) ); - Debug.Assert( memIsValid( aMem[p2 + idx] ) ); - REGISTER_TRACE( p, p1 + idx, aMem[p1 + idx] ); - REGISTER_TRACE( p, p2 + idx, aMem[p2 + idx] ); - Debug.Assert( i < pKeyInfo.nField ); - pColl = pKeyInfo.aColl[i]; - bRev = pKeyInfo.aSortOrder[i]; - iCompare = sqlite3MemCompare( aMem[p1 + idx], aMem[p2 + idx], pColl ); - if ( iCompare != 0 ) - { - if ( bRev != 0 ) - iCompare = -iCompare; - break; - } - } - aPermute = null; - break; - } + for (i = 0; i < n; i++) { + idx = aPermute != null ? aPermute[i] : i; + Debug.Assert(memIsValid(aMem[p1 + idx])); + Debug.Assert(memIsValid(aMem[p2 + idx])); + REGISTER_TRACE(p, p1 + idx, aMem[p1 + idx]); + REGISTER_TRACE(p, p2 + idx, aMem[p2 + idx]); + Debug.Assert(i < pKeyInfo.nField); + pColl = pKeyInfo.aColl[i]; + bRev = pKeyInfo.aSortOrder[i]; + iCompare = sqlite3MemCompare(aMem[p1 + idx], aMem[p2 + idx], pColl); + if (iCompare != 0) { + if (bRev != 0) + iCompare = -iCompare; + break; + } + } + aPermute = null; + break; + } - /* Opcode: Jump P1 P2 P3 * * - ** - ** Jump to the instruction at address P1, P2, or P3 depending on whether - ** in the most recent OP_Compare instruction the P1 vector was less than - ** equal to, or greater than the P2 vector, respectively. - */ - case OP_Jump: - { /* jump */ - if ( iCompare < 0 ) - { - pc = pOp.p1 - 1; - } - else if ( iCompare == 0 ) - { - pc = pOp.p2 - 1; - } - else - { - pc = pOp.p3 - 1; - } - break; - } - /* Opcode: And P1 P2 P3 * * - ** - ** Take the logical AND of the values in registers P1 and P2 and - ** write the result into register P3. - ** - ** If either P1 or P2 is 0 (false) then the result is 0 even if - ** the other input is NULL. A NULL and true or two NULLs give - ** a NULL output. - */ - /* Opcode: Or P1 P2 P3 * * - ** - ** Take the logical OR of the values in register P1 and P2 and - ** store the answer in register P3. - ** - ** If either P1 or P2 is nonzero (true) then the result is 1 (true) - ** even if the other input is NULL. A NULL and false or two NULLs - ** give a NULL output. - */ - case OP_And: /* same as TK_AND, in1, in2, ref3 */ - case OP_Or: - { /* same as TK_OR, in1, in2, ref3 */ - int v1; /* Left operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */ - int v2; /* Right operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */ - - pIn1 = aMem[pOp.p1]; - if ( ( pIn1.flags & MEM_Null ) != 0 ) - { - v1 = 2; - } - else - { - v1 = ( sqlite3VdbeIntValue( pIn1 ) != 0 ) ? 1 : 0; - } - pIn2 = aMem[pOp.p2]; - if ( ( pIn2.flags & MEM_Null ) != 0 ) - { - v2 = 2; - } - else - { - v2 = ( sqlite3VdbeIntValue( pIn2 ) != 0 ) ? 1 : 0; - } - if ( pOp.opcode == OP_And ) - { - byte[] and_logic = new byte[] { 0, 0, 0, 0, 1, 2, 0, 2, 2 }; - v1 = and_logic[v1 * 3 + v2]; - } - else - { - byte[] or_logic = new byte[] { 0, 1, 2, 1, 1, 1, 2, 1, 2 }; - v1 = or_logic[v1 * 3 + v2]; - } - pOut = aMem[pOp.p3]; - if ( v1 == 2 ) - { - MemSetTypeFlag( pOut, MEM_Null ); - } - else - { - pOut.u.i = v1; - MemSetTypeFlag( pOut, MEM_Int ); - } - break; - } + /* Opcode: Jump P1 P2 P3 * * + ** + ** Jump to the instruction at address P1, P2, or P3 depending on whether + ** in the most recent OP_Compare instruction the P1 vector was less than + ** equal to, or greater than the P2 vector, respectively. + */ + case OP_Jump: { /* jump */ + if (iCompare < 0) { + pc = pOp.p1 - 1; + } else if (iCompare == 0) { + pc = pOp.p2 - 1; + } else { + pc = pOp.p3 - 1; + } + break; + } + /* Opcode: And P1 P2 P3 * * + ** + ** Take the logical AND of the values in registers P1 and P2 and + ** write the result into register P3. + ** + ** If either P1 or P2 is 0 (false) then the result is 0 even if + ** the other input is NULL. A NULL and true or two NULLs give + ** a NULL output. + */ + /* Opcode: Or P1 P2 P3 * * + ** + ** Take the logical OR of the values in register P1 and P2 and + ** store the answer in register P3. + ** + ** If either P1 or P2 is nonzero (true) then the result is 1 (true) + ** even if the other input is NULL. A NULL and false or two NULLs + ** give a NULL output. + */ + case OP_And: /* same as TK_AND, in1, in2, ref3 */ + case OP_Or: { /* same as TK_OR, in1, in2, ref3 */ + int v1; /* Left operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */ + int v2; /* Right operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */ + + pIn1 = aMem[pOp.p1]; + if ((pIn1.flags & MEM_Null) != 0) { + v1 = 2; + } else { + v1 = (sqlite3VdbeIntValue(pIn1) != 0) ? 1 : 0; + } + pIn2 = aMem[pOp.p2]; + if ((pIn2.flags & MEM_Null) != 0) { + v2 = 2; + } else { + v2 = (sqlite3VdbeIntValue(pIn2) != 0) ? 1 : 0; + } + if (pOp.opcode == OP_And) { + byte[] and_logic = new byte[] { 0, 0, 0, 0, 1, 2, 0, 2, 2 }; + v1 = and_logic[v1 * 3 + v2]; + } else { + byte[] or_logic = new byte[] { 0, 1, 2, 1, 1, 1, 2, 1, 2 }; + v1 = or_logic[v1 * 3 + v2]; + } + pOut = aMem[pOp.p3]; + if (v1 == 2) { + MemSetTypeFlag(pOut, MEM_Null); + } else { + pOut.u.i = v1; + MemSetTypeFlag(pOut, MEM_Int); + } + break; + } - /* Opcode: Not P1 P2 * * * - ** - ** Interpret the value in register P1 as a boolean value. Store the - ** boolean complement in register P2. If the value in register P1 is - ** NULL, then a NULL is stored in P2. - */ - case OP_Not: - { /* same as TK_NOT, in1 */ - pIn1 = aMem[pOp.p1]; - pOut = aMem[pOp.p2]; - if ( ( pIn1.flags & MEM_Null ) != 0 ) - { - sqlite3VdbeMemSetNull( pOut ); - } - else - { - sqlite3VdbeMemSetInt64( pOut, sqlite3VdbeIntValue( pIn1 ) == 0 ? 1 : 0 ); - } - break; - } + /* Opcode: Not P1 P2 * * * + ** + ** Interpret the value in register P1 as a boolean value. Store the + ** boolean complement in register P2. If the value in register P1 is + ** NULL, then a NULL is stored in P2. + */ + case OP_Not: { /* same as TK_NOT, in1 */ + pIn1 = aMem[pOp.p1]; + pOut = aMem[pOp.p2]; + if ((pIn1.flags & MEM_Null) != 0) { + sqlite3VdbeMemSetNull(pOut); + } else { + sqlite3VdbeMemSetInt64(pOut, sqlite3VdbeIntValue(pIn1) == 0 ? 1 : 0); + } + break; + } - /* Opcode: BitNot P1 P2 * * * - ** - ** Interpret the content of register P1 as an integer. Store the - ** ones-complement of the P1 value into register P2. If P1 holds - ** a NULL then store a NULL in P2. - */ - case OP_BitNot: - { /* same as TK_BITNOT, in1 */ - pIn1 = aMem[pOp.p1]; - pOut = aMem[pOp.p2]; - if ( ( pIn1.flags & MEM_Null ) != 0 ) - { - sqlite3VdbeMemSetNull( pOut ); - } - else - { - sqlite3VdbeMemSetInt64( pOut, ~sqlite3VdbeIntValue( pIn1 ) ); - } - break; - } + /* Opcode: BitNot P1 P2 * * * + ** + ** Interpret the content of register P1 as an integer. Store the + ** ones-complement of the P1 value into register P2. If P1 holds + ** a NULL then store a NULL in P2. + */ + case OP_BitNot: { /* same as TK_BITNOT, in1 */ + pIn1 = aMem[pOp.p1]; + pOut = aMem[pOp.p2]; + if ((pIn1.flags & MEM_Null) != 0) { + sqlite3VdbeMemSetNull(pOut); + } else { + sqlite3VdbeMemSetInt64(pOut, ~sqlite3VdbeIntValue(pIn1)); + } + break; + } - /* Opcode: If P1 P2 P3 * * - ** - ** Jump to P2 if the value in register P1 is true. The value - ** is considered true if it is numeric and non-zero. If the value - ** in P1 is NULL then take the jump if P3 is true. - */ - /* Opcode: IfNot P1 P2 P3 * * - ** - ** Jump to P2 if the value in register P1 is False. The value - ** is considered true if it has a numeric value of zero. If the value - ** in P1 is NULL then take the jump if P3 is true. - */ - case OP_If: /* jump, in1 */ - case OP_IfNot: - { /* jump, in1 */ - int c; - pIn1 = aMem[pOp.p1]; - if ( ( pIn1.flags & MEM_Null ) != 0 ) - { - c = pOp.p3; - } - else - { + /* Opcode: If P1 P2 P3 * * + ** + ** Jump to P2 if the value in register P1 is true. The value + ** is considered true if it is numeric and non-zero. If the value + ** in P1 is NULL then take the jump if P3 is true. + */ + /* Opcode: IfNot P1 P2 P3 * * + ** + ** Jump to P2 if the value in register P1 is False. The value + ** is considered true if it has a numeric value of zero. If the value + ** in P1 is NULL then take the jump if P3 is true. + */ + case OP_If: /* jump, in1 */ + case OP_IfNot: { /* jump, in1 */ + int c; + pIn1 = aMem[pOp.p1]; + if ((pIn1.flags & MEM_Null) != 0) { + c = pOp.p3; + } else { #if SQLITE_OMIT_FLOATING_POINT c = sqlite3VdbeIntValue(pIn1)!=0; #else - c = ( sqlite3VdbeRealValue( pIn1 ) != 0.0 ) ? 1 : 0; + c = (sqlite3VdbeRealValue(pIn1) != 0.0) ? 1 : 0; #endif - if ( pOp.opcode == OP_IfNot ) - c = ( c == 0 ) ? 1 : 0; - } - if ( c != 0 ) - { - pc = pOp.p2 - 1; - } - break; - } + if (pOp.opcode == OP_IfNot) + c = (c == 0) ? 1 : 0; + } + if (c != 0) { + pc = pOp.p2 - 1; + } + break; + } - /* Opcode: IsNull P1 P2 * * * - ** - ** Jump to P2 if the value in register P1 is NULL. - */ - case OP_IsNull: - { /* same as TK_ISNULL, jump, in1 */ - pIn1 = aMem[pOp.p1]; - if ( ( pIn1.flags & MEM_Null ) != 0 ) - { - pc = pOp.p2 - 1; - } - break; - } + /* Opcode: IsNull P1 P2 * * * + ** + ** Jump to P2 if the value in register P1 is NULL. + */ + case OP_IsNull: { /* same as TK_ISNULL, jump, in1 */ + pIn1 = aMem[pOp.p1]; + if ((pIn1.flags & MEM_Null) != 0) { + pc = pOp.p2 - 1; + } + break; + } - /* Opcode: NotNull P1 P2 * * * - ** - ** Jump to P2 if the value in register P1 is not NULL. - */ - case OP_NotNull: - { /* same as TK_NOTNULL, jump, in1 */ - pIn1 = aMem[pOp.p1]; - if ( ( pIn1.flags & MEM_Null ) == 0 ) - { - pc = pOp.p2 - 1; - } - break; - } + /* Opcode: NotNull P1 P2 * * * + ** + ** Jump to P2 if the value in register P1 is not NULL. + */ + case OP_NotNull: { /* same as TK_NOTNULL, jump, in1 */ + pIn1 = aMem[pOp.p1]; + if ((pIn1.flags & MEM_Null) == 0) { + pc = pOp.p2 - 1; + } + break; + } - /* Opcode: Column P1 P2 P3 P4 * - ** - ** Interpret the data that cursor P1 points to as a structure built using - ** the MakeRecord instruction. (See the MakeRecord opcode for additional - ** information about the format of the data.) Extract the P2-th column - ** from this record. If there are less that (P2+1) - ** values in the record, extract a NULL. - ** - ** The value extracted is stored in register P3. - ** - ** If the column contains fewer than P2 fields, then extract a NULL. Or, - ** if the P4 argument is a P4_MEM use the value of the P4 argument as - ** the result. - ** - ** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor, - ** then the cache of the cursor is reset prior to extracting the column. - ** The first OP_Column against a pseudo-table after the value of the content - ** register has changed should have this bit set. - */ - case OP_Column: - { - u32 payloadSize; /* Number of bytes in the record */ - i64 payloadSize64; /* Number of bytes in the record */ - int p1; /* P1 value of the opcode */ - int p2; /* column number to retrieve */ - VdbeCursor pC; /* The VDBE cursor */ - byte[] zRec; /* Pointer to complete record-data */ - BtCursor pCrsr; /* The BTree cursor */ - u32[] aType; /* aType[i] holds the numeric type of the i-th column */ - u32[] aOffset; /* aOffset[i] is offset to start of data for i-th column */ - int nField; /* number of fields in the record */ - int len; /* The length of the serialized data for the column */ - int i; /* Loop counter */ - byte[] zData = null;/* Part of the record being decoded */ - Mem pDest; /* Where to write the extracted value */ - Mem sMem = null; /* For storing the record being decoded */ - int zIdx; /* Index into header */ - int zEndHdr; /* Pointer to first byte after the header */ - u32 offset; /* Offset into the data */ - u32 szField = 0; /* Number of bytes in the content of a field */ - int szHdr; /* Size of the header size field at start of record */ - int avail; /* Number of bytes of available data */ - Mem pReg; /* PseudoTable input register */ - - p1 = pOp.p1; - p2 = pOp.p2; - pC = null; - - payloadSize = 0; - payloadSize64 = 0; - offset = 0; - - sMem = sqlite3Malloc( sMem ); - // memset(&sMem, 0, sizeof(sMem)); - Debug.Assert( p1 < p.nCursor ); - Debug.Assert( pOp.p3 > 0 && pOp.p3 <= p.nMem ); - pDest = aMem[pOp.p3]; - memAboutToChange( p, pDest ); - MemSetTypeFlag( pDest, MEM_Null ); - zRec = null; - - /* This block sets the variable payloadSize to be the total number of - ** bytes in the record. - ** - ** zRec is set to be the complete text of the record if it is available. - ** The complete record text is always available for pseudo-tables - ** If the record is stored in a cursor, the complete record text - ** might be available in the pC.aRow cache. Or it might not be. - ** If the data is unavailable, zRec is set to NULL. - ** - ** We also compute the number of columns in the record. For cursors, - ** the number of columns is stored in the VdbeCursor.nField element. - */ - pC = p.apCsr[p1]; - Debug.Assert( pC != null ); + /* Opcode: Column P1 P2 P3 P4 * + ** + ** Interpret the data that cursor P1 points to as a structure built using + ** the MakeRecord instruction. (See the MakeRecord opcode for additional + ** information about the format of the data.) Extract the P2-th column + ** from this record. If there are less that (P2+1) + ** values in the record, extract a NULL. + ** + ** The value extracted is stored in register P3. + ** + ** If the column contains fewer than P2 fields, then extract a NULL. Or, + ** if the P4 argument is a P4_MEM use the value of the P4 argument as + ** the result. + ** + ** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor, + ** then the cache of the cursor is reset prior to extracting the column. + ** The first OP_Column against a pseudo-table after the value of the content + ** register has changed should have this bit set. + */ + case OP_Column: { + u32 payloadSize; /* Number of bytes in the record */ + i64 payloadSize64; /* Number of bytes in the record */ + int p1; /* P1 value of the opcode */ + int p2; /* column number to retrieve */ + VdbeCursor pC; /* The VDBE cursor */ + byte[] zRec; /* Pointer to complete record-data */ + BtCursor pCrsr; /* The BTree cursor */ + u32[] aType; /* aType[i] holds the numeric type of the i-th column */ + u32[] aOffset; /* aOffset[i] is offset to start of data for i-th column */ + int nField; /* number of fields in the record */ + int len; /* The length of the serialized data for the column */ + int i; /* Loop counter */ + byte[] zData = null;/* Part of the record being decoded */ + Mem pDest; /* Where to write the extracted value */ + Mem sMem = null; /* For storing the record being decoded */ + int zIdx; /* Index into header */ + int zEndHdr; /* Pointer to first byte after the header */ + u32 offset; /* Offset into the data */ + u32 szField = 0; /* Number of bytes in the content of a field */ + int szHdr; /* Size of the header size field at start of record */ + int avail; /* Number of bytes of available data */ + Mem pReg; /* PseudoTable input register */ + + p1 = pOp.p1; + p2 = pOp.p2; + pC = null; + + payloadSize = 0; + payloadSize64 = 0; + offset = 0; + + sMem = sqlite3Malloc(sMem); + // memset(&sMem, 0, sizeof(sMem)); + Debug.Assert(p1 < p.nCursor); + Debug.Assert(pOp.p3 > 0 && pOp.p3 <= p.nMem); + pDest = aMem[pOp.p3]; + memAboutToChange(p, pDest); + MemSetTypeFlag(pDest, MEM_Null); + zRec = null; + + /* This block sets the variable payloadSize to be the total number of + ** bytes in the record. + ** + ** zRec is set to be the complete text of the record if it is available. + ** The complete record text is always available for pseudo-tables + ** If the record is stored in a cursor, the complete record text + ** might be available in the pC.aRow cache. Or it might not be. + ** If the data is unavailable, zRec is set to NULL. + ** + ** We also compute the number of columns in the record. For cursors, + ** the number of columns is stored in the VdbeCursor.nField element. + */ + pC = p.apCsr[p1]; + Debug.Assert(pC != null); #if !SQLITE_OMIT_VIRTUALTABLE - Debug.Assert( pC.pVtabCursor == null ); + Debug.Assert(pC.pVtabCursor == null); #endif - pCrsr = pC.pCursor; - if ( pCrsr != null ) - { - /* The record is stored in a B-Tree */ - rc = sqlite3VdbeCursorMoveto( pC ); - if ( rc != 0 ) - goto abort_due_to_error; - if ( pC.nullRow ) - { - payloadSize = 0; - } - else if ( ( pC.cacheStatus == p.cacheCtr ) && ( pC.aRow != -1 ) ) - { - payloadSize = pC.payloadSize; - zRec = sqlite3Malloc( (int)payloadSize ); - Buffer.BlockCopy( pCrsr.info.pCell, pC.aRow, zRec, 0, (int)payloadSize ); - } - else if ( pC.isIndex ) - { - Debug.Assert( sqlite3BtreeCursorIsValid( pCrsr ) ); - rc = sqlite3BtreeKeySize( pCrsr, ref payloadSize64 ); - Debug.Assert( rc == SQLITE_OK ); /* True because of CursorMoveto() call above */ - /* sqlite3BtreeParseCellPtr() uses getVarint32() to extract the - ** payload size, so it is impossible for payloadSize64 to be - ** larger than 32 bits. */ - Debug.Assert( ( (u64)payloadSize64 & SQLITE_MAX_U32 ) == (u64)payloadSize64 ); - payloadSize = (u32)payloadSize64; - } - else - { - Debug.Assert( sqlite3BtreeCursorIsValid( pCrsr ) ); - rc = sqlite3BtreeDataSize( pCrsr, ref payloadSize ); - Debug.Assert( rc == SQLITE_OK ); /* DataSize() cannot fail */ - } - } - else if ( pC.pseudoTableReg > 0 ) - { - /* The record is the sole entry of a pseudo-table */ - pReg = aMem[pC.pseudoTableReg]; - Debug.Assert( ( pReg.flags & MEM_Blob ) != 0 ); - Debug.Assert( memIsValid( pReg ) ); - payloadSize = (u32)pReg.n; - zRec = pReg.zBLOB; - pC.cacheStatus = ( pOp.p5 & OPFLAG_CLEARCACHE ) != 0 ? CACHE_STALE : p.cacheCtr; - Debug.Assert( payloadSize == 0 || zRec != null ); - } - else - { - /* Consider the row to be NULL */ - payloadSize = 0; - } - - /* If payloadSize is 0, then just store a NULL */ - if ( payloadSize == 0 ) - { - Debug.Assert( ( pDest.flags & MEM_Null ) != 0 ); - goto op_column_out; - } - Debug.Assert( db.aLimit[SQLITE_LIMIT_LENGTH] >= 0 ); - if ( payloadSize > (u32)db.aLimit[SQLITE_LIMIT_LENGTH] ) - { - goto too_big; - } - - nField = pC.nField; - Debug.Assert( p2 < nField ); - - /* Read and parse the table header. Store the results of the parse - ** into the record header cache fields of the cursor. - */ - aType = pC.aType; - if ( pC.cacheStatus == p.cacheCtr ) - { - aOffset = pC.aOffset; - } - else - { - Debug.Assert( aType != null ); - avail = 0; - //pC.aOffset = aOffset = aType[nField]; - aOffset = new u32[nField]; - pC.aOffset = aOffset; - pC.payloadSize = payloadSize; - pC.cacheStatus = p.cacheCtr; - - /* Figure out how many bytes are in the header */ - if ( zRec != null ) - { - zData = zRec; - } - else - { - if ( pC.isIndex ) - { - zData = sqlite3BtreeKeyFetch( pCrsr, ref avail, ref pC.aRow ); - } - else - { - zData = sqlite3BtreeDataFetch( pCrsr, ref avail, ref pC.aRow ); - } - /* If KeyFetch()/DataFetch() managed to get the entire payload, - ** save the payload in the pC.aRow cache. That will save us from - ** having to make additional calls to fetch the content portion of - ** the record. - */ - Debug.Assert( avail >= 0 ); - if ( payloadSize <= (u32)avail ) - { - zRec = zData; - //pC.aRow = zData; - } - else - { - pC.aRow = -1; //pC.aRow = null; - } - } - /* The following Debug.Assert is true in all cases accept when - ** the database file has been corrupted externally. - ** Debug.Assert( zRec!=0 || avail>=payloadSize || avail>=9 ); */ - szHdr = getVarint32( zData, out offset ); - - /* Make sure a corrupt database has not given us an oversize header. - ** Do this now to avoid an oversize memory allocation. - ** - ** Type entries can be between 1 and 5 bytes each. But 4 and 5 byte - ** types use so much data space that there can only be 4096 and 32 of - ** them, respectively. So the maximum header length results from a - ** 3-byte type for each of the maximum of 32768 columns plus three - ** extra bytes for the header length itself. 32768*3 + 3 = 98307. - */ - if ( offset > 98307 ) - { - rc = SQLITE_CORRUPT_BKPT(); - goto op_column_out; - } - - /* Compute in len the number of bytes of data we need to read in order - ** to get nField type values. offset is an upper bound on this. But - ** nField might be significantly less than the true number of columns - ** in the table, and in that case, 5*nField+3 might be smaller than offset. - ** We want to minimize len in order to limit the size of the memory - ** allocation, especially if a corrupt database file has caused offset - ** to be oversized. Offset is limited to 98307 above. But 98307 might - ** still exceed Robson memory allocation limits on some configurations. - ** On systems that cannot tolerate large memory allocations, nField*5+3 - ** will likely be much smaller since nField will likely be less than - ** 20 or so. This insures that Robson memory allocation limits are - ** not exceeded even for corrupt database files. - */ - len = nField * 5 + 3; - if ( len > (int)offset ) - len = (int)offset; - - /* The KeyFetch() or DataFetch() above are fast and will get the entire - ** record header in most cases. But they will fail to get the complete - ** record header if the record header does not fit on a single page - ** in the B-Tree. When that happens, use sqlite3VdbeMemFromBtree() to - ** acquire the complete header text. - */ - if ( zRec == null && avail < len ) - { - sMem.db = null; - sMem.flags = 0; - rc = sqlite3VdbeMemFromBtree( pCrsr, 0, len, pC.isIndex, sMem ); - if ( rc != SQLITE_OK ) - { - goto op_column_out; - } - zData = sMem.zBLOB; - } - zEndHdr = len;// zData[len]; - zIdx = szHdr;// zData[szHdr]; - - /* Scan the header and use it to fill in the aType[] and aOffset[] - ** arrays. aType[i] will contain the type integer for the i-th - ** column and aOffset[i] will contain the offset from the beginning - ** of the record to the start of the data for the i-th column - */ - for ( i = 0; i < nField; i++ ) - { - if ( zIdx < zEndHdr ) - { - aOffset[i] = offset; - zIdx += getVarint32( zData, zIdx, out aType[i] );//getVarint32(zIdx, aType[i]); - szField = sqlite3VdbeSerialTypeLen( aType[i] ); - offset += szField; - if ( offset < szField ) - { /* True if offset overflows */ - zIdx = int.MaxValue; /* Forces SQLITE_CORRUPT return below */ - break; - } - } - else - { - /* If i is less that nField, then there are less fields in this - ** record than SetNumColumns indicated there are columns in the - ** table. Set the offset for any extra columns not present in - ** the record to 0. This tells code below to store a NULL - ** instead of deserializing a value from the record. - */ - aOffset[i] = 0; - } - } - sqlite3VdbeMemRelease( sMem ); - sMem.flags = MEM_Null; - - /* If we have read more header data than was contained in the header, - ** or if the end of the last field appears to be past the end of the - ** record, or if the end of the last field appears to be before the end - ** of the record (when all fields present), then we must be dealing - ** with a corrupt database. - */ - if ( ( zIdx > zEndHdr ) || ( offset > payloadSize ) - || ( zIdx == zEndHdr && offset != payloadSize ) ) - { - rc = SQLITE_CORRUPT_BKPT(); - goto op_column_out; - } - } - - /* Get the column information. If aOffset[p2] is non-zero, then - ** deserialize the value from the record. If aOffset[p2] is zero, - ** then there are not enough fields in the record to satisfy the - ** request. In this case, set the value NULL or to P4 if P4 is - ** a pointer to a Mem object. - */ - if ( aOffset[p2] != 0 ) - { - Debug.Assert( rc == SQLITE_OK ); - if ( zRec != null ) - { - sqlite3VdbeMemReleaseExternal( pDest ); - sqlite3VdbeSerialGet( zRec, (int)aOffset[p2], aType[p2], pDest ); - } - else - { - len = (int)sqlite3VdbeSerialTypeLen( aType[p2] ); - sqlite3VdbeMemMove( sMem, pDest ); - rc = sqlite3VdbeMemFromBtree( pCrsr, (int)aOffset[p2], len, pC.isIndex, sMem ); - if ( rc != SQLITE_OK ) - { - goto op_column_out; - } - zData = sMem.zBLOB; - sMem.zBLOB = null; - sqlite3VdbeSerialGet( zData, aType[p2], pDest ); - } - pDest.enc = encoding; - } - else - { - if ( pOp.p4type == P4_MEM ) - { - sqlite3VdbeMemShallowCopy( pDest, pOp.p4.pMem, MEM_Static ); - } - else - { - Debug.Assert( ( pDest.flags & MEM_Null ) != 0 ); - } - } - - /* If we dynamically allocated space to hold the data (in the - ** sqlite3VdbeMemFromBtree() call above) then transfer control of that - ** dynamically allocated space over to the pDest structure. - ** This prevents a memory copy. - */ - //if ( sMem.zMalloc != null ) - //{ - // Debug.Assert( sMem.z == sMem.zMalloc); - // Debug.Assert( sMem.xDel == null ); - // Debug.Assert( ( pDest.flags & MEM_Dyn ) == 0 ); - // Debug.Assert( ( pDest.flags & ( MEM_Blob | MEM_Str ) ) == 0 || pDest.z == sMem.z ); - // pDest.flags &= ~( MEM_Ephem | MEM_Static ); - // pDest.flags |= MEM_Term; - // pDest.z = sMem.z; - // pDest.zMalloc = sMem.zMalloc; - //} - - rc = sqlite3VdbeMemMakeWriteable( pDest ); - -op_column_out: + pCrsr = pC.pCursor; + if (pCrsr != null) { + /* The record is stored in a B-Tree */ + rc = sqlite3VdbeCursorMoveto(pC); + if (rc != 0) + goto abort_due_to_error; + if (pC.nullRow) { + payloadSize = 0; + } else if ((pC.cacheStatus == p.cacheCtr) && (pC.aRow != -1)) { + payloadSize = pC.payloadSize; + zRec = sqlite3Malloc((int)payloadSize); + Buffer.BlockCopy(pCrsr.info.pCell, pC.aRow, zRec, 0, (int)payloadSize); + } else if (pC.isIndex) { + Debug.Assert(sqlite3BtreeCursorIsValid(pCrsr)); + rc = sqlite3BtreeKeySize(pCrsr, ref payloadSize64); + Debug.Assert(rc == SQLITE_OK); /* True because of CursorMoveto() call above */ + /* sqlite3BtreeParseCellPtr() uses getVarint32() to extract the + ** payload size, so it is impossible for payloadSize64 to be + ** larger than 32 bits. */ + Debug.Assert(((u64)payloadSize64 & SQLITE_MAX_U32) == (u64)payloadSize64); + payloadSize = (u32)payloadSize64; + } else { + Debug.Assert(sqlite3BtreeCursorIsValid(pCrsr)); + rc = sqlite3BtreeDataSize(pCrsr, ref payloadSize); + Debug.Assert(rc == SQLITE_OK); /* DataSize() cannot fail */ + } + } else if (pC.pseudoTableReg > 0) { + /* The record is the sole entry of a pseudo-table */ + pReg = aMem[pC.pseudoTableReg]; + Debug.Assert((pReg.flags & MEM_Blob) != 0); + Debug.Assert(memIsValid(pReg)); + payloadSize = (u32)pReg.n; + zRec = pReg.zBLOB; + pC.cacheStatus = (pOp.p5 & OPFLAG_CLEARCACHE) != 0 ? CACHE_STALE : p.cacheCtr; + Debug.Assert(payloadSize == 0 || zRec != null); + } else { + /* Consider the row to be NULL */ + payloadSize = 0; + } + + /* If payloadSize is 0, then just store a NULL */ + if (payloadSize == 0) { + Debug.Assert((pDest.flags & MEM_Null) != 0); + goto op_column_out; + } + Debug.Assert(db.aLimit[SQLITE_LIMIT_LENGTH] >= 0); + if (payloadSize > (u32)db.aLimit[SQLITE_LIMIT_LENGTH]) { + goto too_big; + } + + nField = pC.nField; + Debug.Assert(p2 < nField); + + /* Read and parse the table header. Store the results of the parse + ** into the record header cache fields of the cursor. + */ + aType = pC.aType; + if (pC.cacheStatus == p.cacheCtr) { + aOffset = pC.aOffset; + } else { + Debug.Assert(aType != null); + avail = 0; + //pC.aOffset = aOffset = aType[nField]; + aOffset = new u32[nField]; + pC.aOffset = aOffset; + pC.payloadSize = payloadSize; + pC.cacheStatus = p.cacheCtr; + + /* Figure out how many bytes are in the header */ + if (zRec != null) { + zData = zRec; + } else { + if (pC.isIndex) { + zData = sqlite3BtreeKeyFetch(pCrsr, ref avail, ref pC.aRow); + } else { + zData = sqlite3BtreeDataFetch(pCrsr, ref avail, ref pC.aRow); + } + /* If KeyFetch()/DataFetch() managed to get the entire payload, + ** save the payload in the pC.aRow cache. That will save us from + ** having to make additional calls to fetch the content portion of + ** the record. + */ + Debug.Assert(avail >= 0); + if (payloadSize <= (u32)avail) { + zRec = zData; + //pC.aRow = zData; + } else { + pC.aRow = -1; //pC.aRow = null; + } + } + /* The following Debug.Assert is true in all cases accept when + ** the database file has been corrupted externally. + ** Debug.Assert( zRec!=0 || avail>=payloadSize || avail>=9 ); */ + szHdr = getVarint32(zData, out offset); + + /* Make sure a corrupt database has not given us an oversize header. + ** Do this now to avoid an oversize memory allocation. + ** + ** Type entries can be between 1 and 5 bytes each. But 4 and 5 byte + ** types use so much data space that there can only be 4096 and 32 of + ** them, respectively. So the maximum header length results from a + ** 3-byte type for each of the maximum of 32768 columns plus three + ** extra bytes for the header length itself. 32768*3 + 3 = 98307. + */ + if (offset > 98307) { + rc = SQLITE_CORRUPT_BKPT(); + goto op_column_out; + } + + /* Compute in len the number of bytes of data we need to read in order + ** to get nField type values. offset is an upper bound on this. But + ** nField might be significantly less than the true number of columns + ** in the table, and in that case, 5*nField+3 might be smaller than offset. + ** We want to minimize len in order to limit the size of the memory + ** allocation, especially if a corrupt database file has caused offset + ** to be oversized. Offset is limited to 98307 above. But 98307 might + ** still exceed Robson memory allocation limits on some configurations. + ** On systems that cannot tolerate large memory allocations, nField*5+3 + ** will likely be much smaller since nField will likely be less than + ** 20 or so. This insures that Robson memory allocation limits are + ** not exceeded even for corrupt database files. + */ + len = nField * 5 + 3; + if (len > (int)offset) + len = (int)offset; + + /* The KeyFetch() or DataFetch() above are fast and will get the entire + ** record header in most cases. But they will fail to get the complete + ** record header if the record header does not fit on a single page + ** in the B-Tree. When that happens, use sqlite3VdbeMemFromBtree() to + ** acquire the complete header text. + */ + if (zRec == null && avail < len) { + sMem.db = null; + sMem.flags = 0; + rc = sqlite3VdbeMemFromBtree(pCrsr, 0, len, pC.isIndex, sMem); + if (rc != SQLITE_OK) { + goto op_column_out; + } + zData = sMem.zBLOB; + } + zEndHdr = len;// zData[len]; + zIdx = szHdr;// zData[szHdr]; + + /* Scan the header and use it to fill in the aType[] and aOffset[] + ** arrays. aType[i] will contain the type integer for the i-th + ** column and aOffset[i] will contain the offset from the beginning + ** of the record to the start of the data for the i-th column + */ + for (i = 0; i < nField; i++) { + if (zIdx < zEndHdr) { + aOffset[i] = offset; + zIdx += getVarint32(zData, zIdx, out aType[i]);//getVarint32(zIdx, aType[i]); + szField = sqlite3VdbeSerialTypeLen(aType[i]); + offset += szField; + if (offset < szField) { /* True if offset overflows */ + zIdx = int.MaxValue; /* Forces SQLITE_CORRUPT return below */ + break; + } + } else { + /* If i is less that nField, then there are less fields in this + ** record than SetNumColumns indicated there are columns in the + ** table. Set the offset for any extra columns not present in + ** the record to 0. This tells code below to store a NULL + ** instead of deserializing a value from the record. + */ + aOffset[i] = 0; + } + } + sqlite3VdbeMemRelease(sMem); + sMem.flags = MEM_Null; + + /* If we have read more header data than was contained in the header, + ** or if the end of the last field appears to be past the end of the + ** record, or if the end of the last field appears to be before the end + ** of the record (when all fields present), then we must be dealing + ** with a corrupt database. + */ + if ((zIdx > zEndHdr) || (offset > payloadSize) + || (zIdx == zEndHdr && offset != payloadSize)) { + rc = SQLITE_CORRUPT_BKPT(); + goto op_column_out; + } + } + + /* Get the column information. If aOffset[p2] is non-zero, then + ** deserialize the value from the record. If aOffset[p2] is zero, + ** then there are not enough fields in the record to satisfy the + ** request. In this case, set the value NULL or to P4 if P4 is + ** a pointer to a Mem object. + */ + if (aOffset[p2] != 0) { + Debug.Assert(rc == SQLITE_OK); + if (zRec != null) { + sqlite3VdbeMemReleaseExternal(pDest); + sqlite3VdbeSerialGet(zRec, (int)aOffset[p2], aType[p2], pDest); + } else { + len = (int)sqlite3VdbeSerialTypeLen(aType[p2]); + sqlite3VdbeMemMove(sMem, pDest); + rc = sqlite3VdbeMemFromBtree(pCrsr, (int)aOffset[p2], len, pC.isIndex, sMem); + if (rc != SQLITE_OK) { + goto op_column_out; + } + zData = sMem.zBLOB; + sMem.zBLOB = null; + sqlite3VdbeSerialGet(zData, aType[p2], pDest); + } + pDest.enc = encoding; + } else { + if (pOp.p4type == P4_MEM) { + sqlite3VdbeMemShallowCopy(pDest, pOp.p4.pMem, MEM_Static); + } else { + Debug.Assert((pDest.flags & MEM_Null) != 0); + } + } + + /* If we dynamically allocated space to hold the data (in the + ** sqlite3VdbeMemFromBtree() call above) then transfer control of that + ** dynamically allocated space over to the pDest structure. + ** This prevents a memory copy. + */ + //if ( sMem.zMalloc != null ) + //{ + // Debug.Assert( sMem.z == sMem.zMalloc); + // Debug.Assert( sMem.xDel == null ); + // Debug.Assert( ( pDest.flags & MEM_Dyn ) == 0 ); + // Debug.Assert( ( pDest.flags & ( MEM_Blob | MEM_Str ) ) == 0 || pDest.z == sMem.z ); + // pDest.flags &= ~( MEM_Ephem | MEM_Static ); + // pDest.flags |= MEM_Term; + // pDest.z = sMem.z; + // pDest.zMalloc = sMem.zMalloc; + //} + + rc = sqlite3VdbeMemMakeWriteable(pDest); + + op_column_out: #if SQLITE_TEST UPDATE_MAX_BLOBSIZE( pDest ); #endif - REGISTER_TRACE( p, pOp.p3, pDest ); - if ( zData != null && zData != zRec ) - sqlite3_free( ref zData ); - //sqlite3_free( ref zRec ); - sqlite3_free( ref sMem ); - break; - } + REGISTER_TRACE(p, pOp.p3, pDest); + if (zData != null && zData != zRec) + sqlite3_free(ref zData); + //sqlite3_free( ref zRec ); + sqlite3_free(ref sMem); + break; + } - /* Opcode: Affinity P1 P2 * P4 * - ** - ** Apply affinities to a range of P2 registers starting with P1. - ** - ** P4 is a string that is P2 characters long. The nth character of the - ** string indicates the column affinity that should be used for the nth - ** memory cell in the range. - */ - case OP_Affinity: - { - string zAffinity; /* The affinity to be applied */ - char cAff; /* A single character of affinity */ - - zAffinity = pOp.p4.z; - Debug.Assert( !String.IsNullOrEmpty( zAffinity ) ); - Debug.Assert( zAffinity.Length <= pOp.p2 );//zAffinity[pOp.p2] == 0 - //pIn1 = aMem[pOp.p1]; - for ( int zI = 0; zI < zAffinity.Length; zI++ )// while( (cAff = *(zAffinity++))!=0 ){ - { - cAff = zAffinity[zI]; - pIn1 = aMem[pOp.p1 + zI]; - //Debug.Assert( pIn1 <= p->aMem[p->nMem] ); - Debug.Assert( memIsValid( pIn1 ) ); - ExpandBlob( pIn1 ); - applyAffinity( pIn1, cAff, encoding ); - //pIn1++; - } - break; - } + /* Opcode: Affinity P1 P2 * P4 * + ** + ** Apply affinities to a range of P2 registers starting with P1. + ** + ** P4 is a string that is P2 characters long. The nth character of the + ** string indicates the column affinity that should be used for the nth + ** memory cell in the range. + */ + case OP_Affinity: { + string zAffinity; /* The affinity to be applied */ + char cAff; /* A single character of affinity */ + + zAffinity = pOp.p4.z; + Debug.Assert(!String.IsNullOrEmpty(zAffinity)); + Debug.Assert(zAffinity.Length <= pOp.p2);//zAffinity[pOp.p2] == 0 + //pIn1 = aMem[pOp.p1]; + for (int zI = 0; zI < zAffinity.Length; zI++)// while( (cAff = *(zAffinity++))!=0 ){ + { + cAff = zAffinity[zI]; + pIn1 = aMem[pOp.p1 + zI]; + //Debug.Assert( pIn1 <= p->aMem[p->nMem] ); + Debug.Assert(memIsValid(pIn1)); + ExpandBlob(pIn1); + applyAffinity(pIn1, cAff, encoding); + //pIn1++; + } + break; + } - /* Opcode: MakeRecord P1 P2 P3 P4 * - ** - ** Convert P2 registers beginning with P1 into the [record format] - ** use as a data record in a database table or as a key - ** in an index. The OP_Column opcode can decode the record later. - ** - ** P4 may be a string that is P2 characters long. The nth character of the - ** string indicates the column affinity that should be used for the nth - ** field of the index key. - ** - ** The mapping from character to affinity is given by the SQLITE_AFF_ - ** macros defined in sqliteInt.h. - ** - ** If P4 is NULL then all index fields have the affinity NONE. - */ - case OP_MakeRecord: - { - byte[] zNewRecord; /* A buffer to hold the data for the new record */ - Mem pRec; /* The new record */ - u64 nData; /* Number of bytes of data space */ - int nHdr; /* Number of bytes of header space */ - i64 nByte; /* Data space required for this record */ - int nZero; /* Number of zero bytes at the end of the record */ - int nVarint; /* Number of bytes in a varint */ - u32 serial_type; /* Type field */ - //Mem pData0; /* First field to be combined into the record */ - //Mem pLast; /* Last field of the record */ - int nField; /* Number of fields in the record */ - string zAffinity; /* The affinity string for the record */ - int file_format; /* File format to use for encoding */ - int i; /* Space used in zNewRecord[] */ - int len; /* Length of a field */ - /* Assuming the record contains N fields, the record format looks - ** like this: - ** - ** ------------------------------------------------------------------------ - ** | hdr-size | type 0 | type 1 | ... | type N-1 | data0 | ... | data N-1 | - ** ------------------------------------------------------------------------ - ** - ** Data(0) is taken from register P1. Data(1) comes from register P1+1 - ** and so froth. - ** - ** Each type field is a varint representing the serial type of the - ** corresponding data element (see sqlite3VdbeSerialType()). The - ** hdr-size field is also a varint which is the offset from the beginning - ** of the record to data0. - */ - - nData = 0; /* Number of bytes of data space */ - nHdr = 0; /* Number of bytes of header space */ - nZero = 0; /* Number of zero bytes at the end of the record */ - nField = pOp.p1; - zAffinity = ( pOp.p4.z == null || pOp.p4.z.Length == 0 ) ? "" : pOp.p4.z; - Debug.Assert( nField > 0 && pOp.p2 > 0 && pOp.p2 + nField <= p.nMem + 1 ); - //pData0 = aMem[nField]; - nField = pOp.p2; - //pLast = pData0[nField - 1]; - file_format = p.minWriteFileFormat; - - /* Identify the output register */ - Debug.Assert( pOp.p3 < pOp.p1 || pOp.p3 >= pOp.p1 + pOp.p2 ); - pOut = aMem[pOp.p3]; - memAboutToChange( p, pOut ); - - /* Loop through the elements that will make up the record to figure - ** out how much space is required for the new record. - */ - //for (pRec = pData0; pRec <= pLast; pRec++) - for ( int pD0 = 0; pD0 < nField; pD0++ ) - { - pRec = p.aMem[pOp.p1 + pD0]; - Debug.Assert( memIsValid( pRec ) ); - if ( pD0 < zAffinity.Length && zAffinity[pD0] != '\0' ) - { - applyAffinity( pRec, (char)zAffinity[pD0], encoding ); - } - if ( ( pRec.flags & MEM_Zero ) != 0 && pRec.n > 0 ) - { - sqlite3VdbeMemExpandBlob( pRec ); - } - serial_type = sqlite3VdbeSerialType( pRec, file_format ); - len = (int)sqlite3VdbeSerialTypeLen( serial_type ); - nData += (u64)len; - nHdr += sqlite3VarintLen( serial_type ); - if ( ( pRec.flags & MEM_Zero ) != 0 ) - { - /* Only pure zero-filled BLOBs can be input to this Opcode. - ** We do not allow blobs with a prefix and a zero-filled tail. */ - nZero += pRec.u.nZero; - } - else if ( len != 0 ) - { - nZero = 0; - } - } - - /* Add the initial header varint and total the size */ - nHdr += nVarint = sqlite3VarintLen( (u64)nHdr ); - if ( nVarint < sqlite3VarintLen( (u64)nHdr ) ) - { - nHdr++; - } - nByte = (i64)( (u64)nHdr + nData - (u64)nZero ); - if ( nByte > db.aLimit[SQLITE_LIMIT_LENGTH] ) - { - goto too_big; - } - - /* Make sure the output register has a buffer large enough to store - ** the new record. The output register (pOp.p3) is not allowed to - ** be one of the input registers (because the following call to - ** sqlite3VdbeMemGrow() could clobber the value before it is used). - */ - //if ( sqlite3VdbeMemGrow( pOut, (int)nByte, 0 ) != 0 ) - //{ - // goto no_mem; - //} - zNewRecord = sqlite3Malloc( (int)nByte );// (u8 )pOut.z; - - /* Write the record */ - i = putVarint32( zNewRecord, nHdr ); - for ( int pD0 = 0; pD0 < nField; pD0++ )//for (pRec = pData0; pRec <= pLast; pRec++) - { - pRec = p.aMem[pOp.p1 + pD0]; - serial_type = sqlite3VdbeSerialType( pRec, file_format ); - i += putVarint32( zNewRecord, i, (int)serial_type ); /* serial type */ - } - for ( int pD0 = 0; pD0 < nField; pD0++ )//for (pRec = pData0; pRec <= pLast; pRec++) - { /* serial data */ - pRec = p.aMem[pOp.p1 + pD0]; - i += (int)sqlite3VdbeSerialPut( zNewRecord, i, (int)nByte - i, pRec, file_format ); - } - //TODO -- Remove this for testing Debug.Assert( i == nByte ); - - Debug.Assert( pOp.p3 > 0 && pOp.p3 <= p.nMem ); - pOut.zBLOB = zNewRecord; - pOut.z = null; - pOut.n = (int)nByte; - pOut.flags = MEM_Blob | MEM_Dyn; - pOut.xDel = null; - if ( nZero != 0 ) - { - pOut.u.nZero = nZero; - pOut.flags |= MEM_Zero; - } - pOut.enc = SQLITE_UTF8; /* In case the blob is ever converted to text */ - REGISTER_TRACE( p, pOp.p3, pOut ); + /* Opcode: MakeRecord P1 P2 P3 P4 * + ** + ** Convert P2 registers beginning with P1 into the [record format] + ** use as a data record in a database table or as a key + ** in an index. The OP_Column opcode can decode the record later. + ** + ** P4 may be a string that is P2 characters long. The nth character of the + ** string indicates the column affinity that should be used for the nth + ** field of the index key. + ** + ** The mapping from character to affinity is given by the SQLITE_AFF_ + ** macros defined in sqliteInt.h. + ** + ** If P4 is NULL then all index fields have the affinity NONE. + */ + case OP_MakeRecord: { + byte[] zNewRecord; /* A buffer to hold the data for the new record */ + Mem pRec; /* The new record */ + u64 nData; /* Number of bytes of data space */ + int nHdr; /* Number of bytes of header space */ + i64 nByte; /* Data space required for this record */ + int nZero; /* Number of zero bytes at the end of the record */ + int nVarint; /* Number of bytes in a varint */ + u32 serial_type; /* Type field */ + //Mem pData0; /* First field to be combined into the record */ + //Mem pLast; /* Last field of the record */ + int nField; /* Number of fields in the record */ + string zAffinity; /* The affinity string for the record */ + int file_format; /* File format to use for encoding */ + int i; /* Space used in zNewRecord[] */ + int len; /* Length of a field */ + /* Assuming the record contains N fields, the record format looks + ** like this: + ** + ** ------------------------------------------------------------------------ + ** | hdr-size | type 0 | type 1 | ... | type N-1 | data0 | ... | data N-1 | + ** ------------------------------------------------------------------------ + ** + ** Data(0) is taken from register P1. Data(1) comes from register P1+1 + ** and so froth. + ** + ** Each type field is a varint representing the serial type of the + ** corresponding data element (see sqlite3VdbeSerialType()). The + ** hdr-size field is also a varint which is the offset from the beginning + ** of the record to data0. + */ + + nData = 0; /* Number of bytes of data space */ + nHdr = 0; /* Number of bytes of header space */ + nZero = 0; /* Number of zero bytes at the end of the record */ + nField = pOp.p1; + zAffinity = (pOp.p4.z == null || pOp.p4.z.Length == 0) ? "" : pOp.p4.z; + Debug.Assert(nField > 0 && pOp.p2 > 0 && pOp.p2 + nField <= p.nMem + 1); + //pData0 = aMem[nField]; + nField = pOp.p2; + //pLast = pData0[nField - 1]; + file_format = p.minWriteFileFormat; + + /* Identify the output register */ + Debug.Assert(pOp.p3 < pOp.p1 || pOp.p3 >= pOp.p1 + pOp.p2); + pOut = aMem[pOp.p3]; + memAboutToChange(p, pOut); + + /* Loop through the elements that will make up the record to figure + ** out how much space is required for the new record. + */ + //for (pRec = pData0; pRec <= pLast; pRec++) + for (int pD0 = 0; pD0 < nField; pD0++) { + pRec = p.aMem[pOp.p1 + pD0]; + Debug.Assert(memIsValid(pRec)); + if (pD0 < zAffinity.Length && zAffinity[pD0] != '\0') { + applyAffinity(pRec, (char)zAffinity[pD0], encoding); + } + if ((pRec.flags & MEM_Zero) != 0 && pRec.n > 0) { + sqlite3VdbeMemExpandBlob(pRec); + } + serial_type = sqlite3VdbeSerialType(pRec, file_format); + len = (int)sqlite3VdbeSerialTypeLen(serial_type); + nData += (u64)len; + nHdr += sqlite3VarintLen(serial_type); + if ((pRec.flags & MEM_Zero) != 0) { + /* Only pure zero-filled BLOBs can be input to this Opcode. + ** We do not allow blobs with a prefix and a zero-filled tail. */ + nZero += pRec.u.nZero; + } else if (len != 0) { + nZero = 0; + } + } + + /* Add the initial header varint and total the size */ + nHdr += nVarint = sqlite3VarintLen((u64)nHdr); + if (nVarint < sqlite3VarintLen((u64)nHdr)) { + nHdr++; + } + nByte = (i64)((u64)nHdr + nData - (u64)nZero); + if (nByte > db.aLimit[SQLITE_LIMIT_LENGTH]) { + goto too_big; + } + + /* Make sure the output register has a buffer large enough to store + ** the new record. The output register (pOp.p3) is not allowed to + ** be one of the input registers (because the following call to + ** sqlite3VdbeMemGrow() could clobber the value before it is used). + */ + //if ( sqlite3VdbeMemGrow( pOut, (int)nByte, 0 ) != 0 ) + //{ + // goto no_mem; + //} + zNewRecord = sqlite3Malloc((int)nByte);// (u8 )pOut.z; + + /* Write the record */ + i = putVarint32(zNewRecord, nHdr); + for (int pD0 = 0; pD0 < nField; pD0++)//for (pRec = pData0; pRec <= pLast; pRec++) + { + pRec = p.aMem[pOp.p1 + pD0]; + serial_type = sqlite3VdbeSerialType(pRec, file_format); + i += putVarint32(zNewRecord, i, (int)serial_type); /* serial type */ + } + for (int pD0 = 0; pD0 < nField; pD0++)//for (pRec = pData0; pRec <= pLast; pRec++) + { /* serial data */ + pRec = p.aMem[pOp.p1 + pD0]; + i += (int)sqlite3VdbeSerialPut(zNewRecord, i, (int)nByte - i, pRec, file_format); + } + //TODO -- Remove this for testing Debug.Assert( i == nByte ); + + Debug.Assert(pOp.p3 > 0 && pOp.p3 <= p.nMem); + pOut.zBLOB = zNewRecord; + pOut.z = null; + pOut.n = (int)nByte; + pOut.flags = MEM_Blob | MEM_Dyn; + pOut.xDel = null; + if (nZero != 0) { + pOut.u.nZero = nZero; + pOut.flags |= MEM_Zero; + } + pOut.enc = SQLITE_UTF8; /* In case the blob is ever converted to text */ + REGISTER_TRACE(p, pOp.p3, pOut); #if SQLITE_TEST UPDATE_MAX_BLOBSIZE( pOut ); #endif - break; - } + break; + } - /* Opcode: Count P1 P2 * * * - ** - ** Store the number of entries (an integer value) in the table or index - ** opened by cursor P1 in register P2 - */ + /* Opcode: Count P1 P2 * * * + ** + ** Store the number of entries (an integer value) in the table or index + ** opened by cursor P1 in register P2 + */ #if !SQLITE_OMIT_BTREECOUNT - case OP_Count: - { /* out2-prerelease */ - i64 nEntry = 0; - BtCursor pCrsr; - pCrsr = p.apCsr[pOp.p1].pCursor; - if ( pCrsr != null ) - { - rc = sqlite3BtreeCount( pCrsr, ref nEntry ); - } - else - { - nEntry = 0; - } - pOut.u.i = nEntry; - break; - } -#endif - - /* Opcode: Savepoint P1 * * P4 * -** -** Open, release or rollback the savepoint named by parameter P4, depending -** on the value of P1. To open a new savepoint, P1==0. To release (commit) an -** existing savepoint, P1==1, or to rollback an existing savepoint P1==2. -*/ - case OP_Savepoint: - { - int p1; /* Value of P1 operand */ - string zName; /* Name of savepoint */ - Savepoint pNew; - Savepoint pSavepoint; - Savepoint pTmp; - int iSavepoint; - int ii; - - p1 = pOp.p1; - zName = pOp.p4.z; - - /* Assert that the p1 parameter is valid. Also that if there is no open - ** transaction, then there cannot be any savepoints. - */ - Debug.Assert( db.pSavepoint == null || db.autoCommit == 0 ); - Debug.Assert( p1 == SAVEPOINT_BEGIN || p1 == SAVEPOINT_RELEASE || p1 == SAVEPOINT_ROLLBACK ); - Debug.Assert( db.pSavepoint != null || db.isTransactionSavepoint == 0 ); - Debug.Assert( checkSavepointCount( db ) != 0 ); - - if ( p1 == SAVEPOINT_BEGIN ) - { - if ( db.writeVdbeCnt > 0 ) - { - /* A new savepoint cannot be created if there are active write - ** statements (i.e. open read/write incremental blob handles). - */ - sqlite3SetString( ref p.zErrMsg, db, "cannot open savepoint - ", - "SQL statements in progress" ); - rc = SQLITE_BUSY; - } - else - { - ////nName = sqlite3Strlen30( zName ); - -#if !SQLITE_OMIT_VIRTUALTABLE - /* This call is Ok even if this savepoint is actually a transaction - ** savepoint (and therefore should not prompt xSavepoint()) callbacks. - ** If this is a transaction savepoint being opened, it is guaranteed - ** that the db->aVTrans[] array is empty. */ - Debug.Assert( db.autoCommit == 0 || db.nVTrans == 0 ); - rc = sqlite3VtabSavepoint( db, SAVEPOINT_BEGIN, - db.nStatement + db.nSavepoint ); - if ( rc != SQLITE_OK ) - goto abort_due_to_error; + case OP_Count: { /* out2-prerelease */ + i64 nEntry = 0; + BtCursor pCrsr; + pCrsr = p.apCsr[pOp.p1].pCursor; + if (pCrsr != null) { + rc = sqlite3BtreeCount(pCrsr, ref nEntry); + } else { + nEntry = 0; + } + pOut.u.i = nEntry; + break; + } #endif - /* Create a new savepoint structure. */ - pNew = new Savepoint();// sqlite3DbMallocRaw( db, sizeof( Savepoint ) + nName + 1 ); - if ( pNew != null ) - { - //pNew.zName = (char )&pNew[1]; - //memcpy(pNew.zName, zName, nName+1); - pNew.zName = zName; - - /* If there is no open transaction, then mark this as a special - ** "transaction savepoint". */ - if ( db.autoCommit != 0 ) - { - db.autoCommit = 0; - db.isTransactionSavepoint = 1; - } - else - { - db.nSavepoint++; - } - - /* Link the new savepoint into the database handle's list. */ - pNew.pNext = db.pSavepoint; - db.pSavepoint = pNew; - pNew.nDeferredCons = db.nDeferredCons; - } - } - } - else - { - iSavepoint = 0; - - /* Find the named savepoint. If there is no such savepoint, then an - ** an error is returned to the user. */ - for ( - pSavepoint = db.pSavepoint; - pSavepoint != null && !pSavepoint.zName.Equals( zName, StringComparison.OrdinalIgnoreCase ); - pSavepoint = pSavepoint.pNext - ) - { - iSavepoint++; - } - if ( null == pSavepoint ) - { - sqlite3SetString( ref p.zErrMsg, db, "no such savepoint: %s", zName ); - rc = SQLITE_ERROR; - } - else if ( - db.writeVdbeCnt > 0 || ( p1 == SAVEPOINT_ROLLBACK && db.activeVdbeCnt > 1 ) - ) - { - /* It is not possible to release (commit) a savepoint if there are - ** active write statements. It is not possible to rollback a savepoint - ** if there are any active statements at all. - */ - sqlite3SetString( ref p.zErrMsg, db, - "cannot %s savepoint - SQL statements in progress", - ( p1 == SAVEPOINT_ROLLBACK ? "rollback" : "release" ) - ); - rc = SQLITE_BUSY; - } - else - { - - /* Determine whether or not this is a transaction savepoint. If so, - ** and this is a RELEASE command, then the current transaction - ** is committed. - */ - int isTransaction = ( pSavepoint.pNext == null && db.isTransactionSavepoint != 0 ) ? 1 : 0; - if ( isTransaction != 0 && p1 == SAVEPOINT_RELEASE ) - { - if ( ( rc = sqlite3VdbeCheckFk( p, 1 ) ) != SQLITE_OK ) - { - goto vdbe_return; - } - db.autoCommit = 1; - if ( sqlite3VdbeHalt( p ) == SQLITE_BUSY ) - { - p.pc = pc; - db.autoCommit = 0; - p.rc = rc = SQLITE_BUSY; - goto vdbe_return; - } - db.isTransactionSavepoint = 0; - rc = p.rc; - } - else - { - iSavepoint = db.nSavepoint - iSavepoint - 1; - for ( ii = 0; ii < db.nDb; ii++ ) - { - rc = sqlite3BtreeSavepoint( db.aDb[ii].pBt, p1, iSavepoint ); - if ( rc != SQLITE_OK ) - { - goto abort_due_to_error; - } - } - if ( p1 == SAVEPOINT_ROLLBACK && ( db.flags & SQLITE_InternChanges ) != 0 ) - { - sqlite3ExpirePreparedStatements( db ); - sqlite3ResetInternalSchema( db, -1 ); - db.flags = ( db.flags | SQLITE_InternChanges ); - } - } - - /* Regardless of whether this is a RELEASE or ROLLBACK, destroy all - ** savepoints nested inside of the savepoint being operated on. */ - while ( db.pSavepoint != pSavepoint ) - { - pTmp = db.pSavepoint; - db.pSavepoint = pTmp.pNext; - sqlite3DbFree( db, ref pTmp ); - db.nSavepoint--; - } - - /* If it is a RELEASE, then destroy the savepoint being operated on - ** too. If it is a ROLLBACK TO, then set the number of deferred - ** constraint violations present in the database to the value stored - ** when the savepoint was created. */ - if ( p1 == SAVEPOINT_RELEASE ) - { - Debug.Assert( pSavepoint == db.pSavepoint ); - db.pSavepoint = pSavepoint.pNext; - sqlite3DbFree( db, ref pSavepoint ); - if ( 0 == isTransaction ) - { - db.nSavepoint--; - } - } - else - { - db.nDeferredCons = pSavepoint.nDeferredCons; - } - - if ( 0 == isTransaction ) - { - rc = sqlite3VtabSavepoint( db, p1, iSavepoint ); - if ( rc != SQLITE_OK ) - goto abort_due_to_error; - } - - } - } - - break; - } - - /* Opcode: AutoCommit P1 P2 * * * + /* Opcode: Savepoint P1 * * P4 * ** - ** Set the database auto-commit flag to P1 (1 or 0). If P2 is true, roll - ** back any currently active btree transactions. If there are any active - ** VMs (apart from this one), then the COMMIT or ROLLBACK statement fails. - ** - ** This instruction causes the VM to halt. + ** Open, release or rollback the savepoint named by parameter P4, depending + ** on the value of P1. To open a new savepoint, P1==0. To release (commit) an + ** existing savepoint, P1==1, or to rollback an existing savepoint P1==2. */ - case OP_AutoCommit: - { - int desiredAutoCommit; - int iRollback; - int turnOnAC; - - desiredAutoCommit = (u8)pOp.p1; - iRollback = pOp.p2; - turnOnAC = ( desiredAutoCommit != 0 && 0 == db.autoCommit ) ? 1 : 0; - - Debug.Assert( desiredAutoCommit != 0 || 0 == desiredAutoCommit ); - Debug.Assert( desiredAutoCommit != 0 || 0 == iRollback ); - - Debug.Assert( db.activeVdbeCnt > 0 ); /* At least this one VM is active */ - - if ( turnOnAC != 0 && iRollback != 0 && db.activeVdbeCnt > 1 ) - { - /* If this instruction implements a ROLLBACK and other VMs are - ** still running, and a transaction is active, return an error indicating - ** that the other VMs must complete first. - */ - sqlite3SetString( ref p.zErrMsg, db, "cannot rollback transaction - " + - "SQL statements in progress" ); - rc = SQLITE_BUSY; - } - else if ( turnOnAC != 0 && 0 == iRollback && db.writeVdbeCnt > 0 ) - { - /* If this instruction implements a COMMIT and other VMs are writing - ** return an error indicating that the other VMs must complete first. - */ - sqlite3SetString( ref p.zErrMsg, db, "cannot commit transaction - " + - "SQL statements in progress" ); - rc = SQLITE_BUSY; - } - else if ( desiredAutoCommit != db.autoCommit ) - { - if ( iRollback != 0 ) - { - Debug.Assert( desiredAutoCommit != 0 ); - sqlite3RollbackAll( db ); - db.autoCommit = 1; - } - else if ( ( rc = sqlite3VdbeCheckFk( p, 1 ) ) != SQLITE_OK ) - { - goto vdbe_return; - } - else - { - db.autoCommit = (u8)desiredAutoCommit; - if ( sqlite3VdbeHalt( p ) == SQLITE_BUSY ) - { - p.pc = pc; - db.autoCommit = (u8)( desiredAutoCommit == 0 ? 1 : 0 ); - p.rc = rc = SQLITE_BUSY; - goto vdbe_return; - } - } - Debug.Assert( db.nStatement == 0 ); - sqlite3CloseSavepoints( db ); - if ( p.rc == SQLITE_OK ) - { - rc = SQLITE_DONE; - } - else - { - rc = SQLITE_ERROR; - } - goto vdbe_return; - } - else - { - sqlite3SetString( ref p.zErrMsg, db, - ( 0 == desiredAutoCommit ) ? "cannot start a transaction within a transaction" : ( - ( iRollback != 0 ) ? "cannot rollback - no transaction is active" : - "cannot commit - no transaction is active" ) ); - rc = SQLITE_ERROR; - } - break; - } + case OP_Savepoint: { + int p1; /* Value of P1 operand */ + string zName; /* Name of savepoint */ + Savepoint pNew; + Savepoint pSavepoint; + Savepoint pTmp; + int iSavepoint; + int ii; + + p1 = pOp.p1; + zName = pOp.p4.z; + + /* Assert that the p1 parameter is valid. Also that if there is no open + ** transaction, then there cannot be any savepoints. + */ + Debug.Assert(db.pSavepoint == null || db.autoCommit == 0); + Debug.Assert(p1 == SAVEPOINT_BEGIN || p1 == SAVEPOINT_RELEASE || p1 == SAVEPOINT_ROLLBACK); + Debug.Assert(db.pSavepoint != null || db.isTransactionSavepoint == 0); + Debug.Assert(checkSavepointCount(db) != 0); + + if (p1 == SAVEPOINT_BEGIN) { + if (db.writeVdbeCnt > 0) { + /* A new savepoint cannot be created if there are active write + ** statements (i.e. open read/write incremental blob handles). + */ + sqlite3SetString(ref p.zErrMsg, db, "cannot open savepoint - ", + "SQL statements in progress"); + rc = SQLITE_BUSY; + } else { + ////nName = sqlite3Strlen30( zName ); - /* Opcode: Transaction P1 P2 * * * - ** - ** Begin a transaction. The transaction ends when a Commit or Rollback - ** opcode is encountered. Depending on the ON CONFLICT setting, the - ** transaction might also be rolled back if an error is encountered. - ** - ** P1 is the index of the database file on which the transaction is - ** started. Index 0 is the main database file and index 1 is the - ** file used for temporary tables. Indices of 2 or more are used for - ** attached databases. - ** - ** If P2 is non-zero, then a write-transaction is started. A RESERVED lock is - ** obtained on the database file when a write-transaction is started. No - ** other process can start another write transaction while this transaction is - ** underway. Starting a write transaction also creates a rollback journal. A - ** write transaction must be started before any changes can be made to the - ** database. If P2 is 2 or greater then an EXCLUSIVE lock is also obtained - ** on the file. - ** - ** If a write-transaction is started and the Vdbe.usesStmtJournal flag is - ** true (this flag is set if the Vdbe may modify more than one row and may - ** throw an ABORT exception), a statement transaction may also be opened. - ** More specifically, a statement transaction is opened iff the database - ** connection is currently not in autocommit mode, or if there are other - ** active statements. A statement transaction allows the affects of this - ** VDBE to be rolled back after an error without having to roll back the - ** entire transaction. If no error is encountered, the statement transaction - ** will automatically commit when the VDBE halts. - ** - ** If P2 is zero, then a read-lock is obtained on the database file. - */ - case OP_Transaction: - { - Btree pBt; - - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < db.nDb ); - Debug.Assert( ( p.btreeMask & ( ( (yDbMask)1 ) << pOp.p1 ) ) != 0 ); - pBt = db.aDb[pOp.p1].pBt; - - if ( pBt != null ) - { - rc = sqlite3BtreeBeginTrans( pBt, pOp.p2 ); - if ( rc == SQLITE_BUSY ) - { - p.pc = pc; - p.rc = rc = SQLITE_BUSY; - goto vdbe_return; - } - if ( rc != SQLITE_OK ) - { - goto abort_due_to_error; - } - if ( pOp.p2 != 0 && p.usesStmtJournal - && ( db.autoCommit == 0 || db.activeVdbeCnt > 1 ) - ) - { - Debug.Assert( sqlite3BtreeIsInTrans( pBt ) ); - if ( p.iStatement == 0 ) - { - Debug.Assert( db.nStatement >= 0 && db.nSavepoint >= 0 ); - db.nStatement++; - p.iStatement = db.nSavepoint + db.nStatement; - } - rc = sqlite3VtabSavepoint( db, SAVEPOINT_BEGIN, p.iStatement - 1 ); - if ( rc == SQLITE_OK ) - { - rc = sqlite3BtreeBeginStmt( pBt, p.iStatement ); - } - /* Store the current value of the database handles deferred constraint - ** counter. If the statement transaction needs to be rolled back, - ** the value of this counter needs to be restored too. */ - p.nStmtDefCons = db.nDeferredCons; - } - } - break; - } +#if !SQLITE_OMIT_VIRTUALTABLE + /* This call is Ok even if this savepoint is actually a transaction + ** savepoint (and therefore should not prompt xSavepoint()) callbacks. + ** If this is a transaction savepoint being opened, it is guaranteed + ** that the db->aVTrans[] array is empty. */ + Debug.Assert(db.autoCommit == 0 || db.nVTrans == 0); + rc = sqlite3VtabSavepoint(db, SAVEPOINT_BEGIN, + db.nStatement + db.nSavepoint); + if (rc != SQLITE_OK) + goto abort_due_to_error; +#endif - /* Opcode: ReadCookie P1 P2 P3 * * - ** - ** Read cookie number P3 from database P1 and write it into register P2. - ** P3==1 is the schema version. P3==2 is the database format. - ** P3==3 is the recommended pager cache size, and so forth. P1==0 is - ** the main database file and P1==1 is the database file used to store - ** temporary tables. - ** - ** There must be a read-lock on the database (either a transaction - ** must be started or there must be an open cursor) before - ** executing this instruction. - */ - case OP_ReadCookie: - { /* out2-prerelease */ - u32 iMeta; - int iDb; - int iCookie; - - iMeta = 0; - iDb = pOp.p1; - iCookie = pOp.p3; - - Debug.Assert( pOp.p3 < SQLITE_N_BTREE_META ); - Debug.Assert( iDb >= 0 && iDb < db.nDb ); - Debug.Assert( db.aDb[iDb].pBt != null ); - Debug.Assert( ( p.btreeMask & ( ( (yDbMask)1 ) << iDb ) ) != 0 ); - sqlite3BtreeGetMeta( db.aDb[iDb].pBt, iCookie, ref iMeta ); - pOut.u.i = (int)iMeta; - break; - } + /* Create a new savepoint structure. */ + pNew = new Savepoint();// sqlite3DbMallocRaw( db, sizeof( Savepoint ) + nName + 1 ); + if (pNew != null) { + //pNew.zName = (char )&pNew[1]; + //memcpy(pNew.zName, zName, nName+1); + pNew.zName = zName; + + /* If there is no open transaction, then mark this as a special + ** "transaction savepoint". */ + if (db.autoCommit != 0) { + db.autoCommit = 0; + db.isTransactionSavepoint = 1; + } else { + db.nSavepoint++; + } + + /* Link the new savepoint into the database handle's list. */ + pNew.pNext = db.pSavepoint; + db.pSavepoint = pNew; + pNew.nDeferredCons = db.nDeferredCons; + } + } + } else { + iSavepoint = 0; + + /* Find the named savepoint. If there is no such savepoint, then an + ** an error is returned to the user. */ + for ( + pSavepoint = db.pSavepoint; + pSavepoint != null && !pSavepoint.zName.Equals(zName, StringComparison.OrdinalIgnoreCase); + pSavepoint = pSavepoint.pNext + ) { + iSavepoint++; + } + if (null == pSavepoint) { + sqlite3SetString(ref p.zErrMsg, db, "no such savepoint: %s", zName); + rc = SQLITE_ERROR; + } else if ( + db.writeVdbeCnt > 0 || (p1 == SAVEPOINT_ROLLBACK && db.activeVdbeCnt > 1) + ) { + /* It is not possible to release (commit) a savepoint if there are + ** active write statements. It is not possible to rollback a savepoint + ** if there are any active statements at all. + */ + sqlite3SetString(ref p.zErrMsg, db, + "cannot %s savepoint - SQL statements in progress", + (p1 == SAVEPOINT_ROLLBACK ? "rollback" : "release") + ); + rc = SQLITE_BUSY; + } else { + + /* Determine whether or not this is a transaction savepoint. If so, + ** and this is a RELEASE command, then the current transaction + ** is committed. + */ + int isTransaction = (pSavepoint.pNext == null && db.isTransactionSavepoint != 0) ? 1 : 0; + if (isTransaction != 0 && p1 == SAVEPOINT_RELEASE) { + if ((rc = sqlite3VdbeCheckFk(p, 1)) != SQLITE_OK) { + goto vdbe_return; + } + db.autoCommit = 1; + if (sqlite3VdbeHalt(p) == SQLITE_BUSY) { + p.pc = pc; + db.autoCommit = 0; + p.rc = rc = SQLITE_BUSY; + goto vdbe_return; + } + db.isTransactionSavepoint = 0; + rc = p.rc; + } else { + iSavepoint = db.nSavepoint - iSavepoint - 1; + for (ii = 0; ii < db.nDb; ii++) { + rc = sqlite3BtreeSavepoint(db.aDb[ii].pBt, p1, iSavepoint); + if (rc != SQLITE_OK) { + goto abort_due_to_error; + } + } + if (p1 == SAVEPOINT_ROLLBACK && (db.flags & SQLITE_InternChanges) != 0) { + sqlite3ExpirePreparedStatements(db); + sqlite3ResetInternalSchema(db, -1); + db.flags = (db.flags | SQLITE_InternChanges); + } + } + + /* Regardless of whether this is a RELEASE or ROLLBACK, destroy all + ** savepoints nested inside of the savepoint being operated on. */ + while (db.pSavepoint != pSavepoint) { + pTmp = db.pSavepoint; + db.pSavepoint = pTmp.pNext; + sqlite3DbFree(db, ref pTmp); + db.nSavepoint--; + } + + /* If it is a RELEASE, then destroy the savepoint being operated on + ** too. If it is a ROLLBACK TO, then set the number of deferred + ** constraint violations present in the database to the value stored + ** when the savepoint was created. */ + if (p1 == SAVEPOINT_RELEASE) { + Debug.Assert(pSavepoint == db.pSavepoint); + db.pSavepoint = pSavepoint.pNext; + sqlite3DbFree(db, ref pSavepoint); + if (0 == isTransaction) { + db.nSavepoint--; + } + } else { + db.nDeferredCons = pSavepoint.nDeferredCons; + } + + if (0 == isTransaction) { + rc = sqlite3VtabSavepoint(db, p1, iSavepoint); + if (rc != SQLITE_OK) + goto abort_due_to_error; + } + + } + } + + break; + } - /* Opcode: SetCookie P1 P2 P3 * * - ** - ** Write the content of register P3 (interpreted as an integer) - ** into cookie number P2 of database P1. P2==1 is the schema version. - ** P2==2 is the database format. P2==3 is the recommended pager cache - ** size, and so forth. P1==0 is the main database file and P1==1 is the - ** database file used to store temporary tables. - ** - ** A transaction must be started before executing this opcode. - */ - case OP_SetCookie: - { /* in3 */ - Db pDb; - Debug.Assert( pOp.p2 < SQLITE_N_BTREE_META ); - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < db.nDb ); - Debug.Assert( ( p.btreeMask & ( ( (yDbMask)1 ) << pOp.p1 ) ) != 0 ); - pDb = db.aDb[pOp.p1]; - Debug.Assert( pDb.pBt != null ); - Debug.Assert( sqlite3SchemaMutexHeld( db, pOp.p1, null ) ); - pIn3 = aMem[pOp.p3]; - sqlite3VdbeMemIntegerify( pIn3 ); - /* See note about index shifting on OP_ReadCookie */ - rc = sqlite3BtreeUpdateMeta( pDb.pBt, pOp.p2, (u32)pIn3.u.i ); - if ( pOp.p2 == BTREE_SCHEMA_VERSION ) - { - /* When the schema cookie changes, record the new cookie internally */ - pDb.pSchema.schema_cookie = (int)pIn3.u.i; - db.flags |= SQLITE_InternChanges; - } - else if ( pOp.p2 == BTREE_FILE_FORMAT ) - { - /* Record changes in the file format */ - pDb.pSchema.file_format = (u8)pIn3.u.i; - } - if ( pOp.p1 == 1 ) - { - /* Invalidate all prepared statements whenever the TEMP database - ** schema is changed. Ticket #1644 */ - sqlite3ExpirePreparedStatements( db ); - p.expired = false; - } - break; - } + /* Opcode: AutoCommit P1 P2 * * * + ** + ** Set the database auto-commit flag to P1 (1 or 0). If P2 is true, roll + ** back any currently active btree transactions. If there are any active + ** VMs (apart from this one), then the COMMIT or ROLLBACK statement fails. + ** + ** This instruction causes the VM to halt. + */ + case OP_AutoCommit: { + int desiredAutoCommit; + int iRollback; + int turnOnAC; + + desiredAutoCommit = (u8)pOp.p1; + iRollback = pOp.p2; + turnOnAC = (desiredAutoCommit != 0 && 0 == db.autoCommit) ? 1 : 0; + + Debug.Assert(desiredAutoCommit != 0 || 0 == desiredAutoCommit); + Debug.Assert(desiredAutoCommit != 0 || 0 == iRollback); + + Debug.Assert(db.activeVdbeCnt > 0); /* At least this one VM is active */ + + if (turnOnAC != 0 && iRollback != 0 && db.activeVdbeCnt > 1) { + /* If this instruction implements a ROLLBACK and other VMs are + ** still running, and a transaction is active, return an error indicating + ** that the other VMs must complete first. + */ + sqlite3SetString(ref p.zErrMsg, db, "cannot rollback transaction - " + + "SQL statements in progress"); + rc = SQLITE_BUSY; + } else if (turnOnAC != 0 && 0 == iRollback && db.writeVdbeCnt > 0) { + /* If this instruction implements a COMMIT and other VMs are writing + ** return an error indicating that the other VMs must complete first. + */ + sqlite3SetString(ref p.zErrMsg, db, "cannot commit transaction - " + + "SQL statements in progress"); + rc = SQLITE_BUSY; + } else if (desiredAutoCommit != db.autoCommit) { + if (iRollback != 0) { + Debug.Assert(desiredAutoCommit != 0); + sqlite3RollbackAll(db); + db.autoCommit = 1; + } else if ((rc = sqlite3VdbeCheckFk(p, 1)) != SQLITE_OK) { + goto vdbe_return; + } else { + db.autoCommit = (u8)desiredAutoCommit; + if (sqlite3VdbeHalt(p) == SQLITE_BUSY) { + p.pc = pc; + db.autoCommit = (u8)(desiredAutoCommit == 0 ? 1 : 0); + p.rc = rc = SQLITE_BUSY; + goto vdbe_return; + } + } + Debug.Assert(db.nStatement == 0); + sqlite3CloseSavepoints(db); + if (p.rc == SQLITE_OK) { + rc = SQLITE_DONE; + } else { + rc = SQLITE_ERROR; + } + goto vdbe_return; + } else { + sqlite3SetString(ref p.zErrMsg, db, + (0 == desiredAutoCommit) ? "cannot start a transaction within a transaction" : ( + (iRollback != 0) ? "cannot rollback - no transaction is active" : + "cannot commit - no transaction is active")); + rc = SQLITE_ERROR; + } + break; + } - /* Opcode: VerifyCookie P1 P2 P3 * * - ** - ** Check the value of global database parameter number 0 (the - ** schema version) and make sure it is equal to P2 and that the - ** generation counter on the local schema parse equals P3. - ** - ** P1 is the database number which is 0 for the main database file - ** and 1 for the file holding temporary tables and some higher number - ** for auxiliary databases. - ** - ** The cookie changes its value whenever the database schema changes. - ** This operation is used to detect when that the cookie has changed - ** and that the current process needs to reread the schema. - ** - ** Either a transaction needs to have been started or an OP_Open needs - ** to be executed (to establish a read lock) before this opcode is - ** invoked. - */ - case OP_VerifyCookie: - { - u32 iMeta = 0; - u32 iGen; - Btree pBt; - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < db.nDb ); - Debug.Assert( ( p.btreeMask & ( (yDbMask)1 << pOp.p1 ) ) != 0 ); - Debug.Assert( sqlite3SchemaMutexHeld( db, pOp.p1, null ) ); - pBt = db.aDb[pOp.p1].pBt; - if ( pBt != null ) - { - sqlite3BtreeGetMeta( pBt, BTREE_SCHEMA_VERSION, ref iMeta ); - iGen = db.aDb[pOp.p1].pSchema.iGeneration; - } - else - { - iGen = iMeta = 0; - } - if ( iMeta != pOp.p2 || iGen != pOp.p3 ) - { - sqlite3DbFree( db, ref p.zErrMsg ); - p.zErrMsg = "database schema has changed";// sqlite3DbStrDup(db, "database schema has changed"); - /* If the schema-cookie from the database file matches the cookie - ** stored with the in-memory representation of the schema, do - ** not reload the schema from the database file. - ** - ** If virtual-tables are in use, this is not just an optimization. - ** Often, v-tables store their data in other SQLite tables, which - ** are queried from within xNext() and other v-table methods using - ** prepared queries. If such a query is out-of-date, we do not want to - ** discard the database schema, as the user code implementing the - ** v-table would have to be ready for the sqlite3_vtab structure itself - ** to be invalidated whenever sqlite3_step() is called from within - ** a v-table method. - */ - if ( db.aDb[pOp.p1].pSchema.schema_cookie != iMeta ) - { - sqlite3ResetInternalSchema( db, pOp.p1 ); - } + /* Opcode: Transaction P1 P2 * * * + ** + ** Begin a transaction. The transaction ends when a Commit or Rollback + ** opcode is encountered. Depending on the ON CONFLICT setting, the + ** transaction might also be rolled back if an error is encountered. + ** + ** P1 is the index of the database file on which the transaction is + ** started. Index 0 is the main database file and index 1 is the + ** file used for temporary tables. Indices of 2 or more are used for + ** attached databases. + ** + ** If P2 is non-zero, then a write-transaction is started. A RESERVED lock is + ** obtained on the database file when a write-transaction is started. No + ** other process can start another write transaction while this transaction is + ** underway. Starting a write transaction also creates a rollback journal. A + ** write transaction must be started before any changes can be made to the + ** database. If P2 is 2 or greater then an EXCLUSIVE lock is also obtained + ** on the file. + ** + ** If a write-transaction is started and the Vdbe.usesStmtJournal flag is + ** true (this flag is set if the Vdbe may modify more than one row and may + ** throw an ABORT exception), a statement transaction may also be opened. + ** More specifically, a statement transaction is opened iff the database + ** connection is currently not in autocommit mode, or if there are other + ** active statements. A statement transaction allows the affects of this + ** VDBE to be rolled back after an error without having to roll back the + ** entire transaction. If no error is encountered, the statement transaction + ** will automatically commit when the VDBE halts. + ** + ** If P2 is zero, then a read-lock is obtained on the database file. + */ + case OP_Transaction: { + Btree pBt; + + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < db.nDb); + Debug.Assert((p.btreeMask & (((yDbMask)1) << pOp.p1)) != 0); + pBt = db.aDb[pOp.p1].pBt; + + if (pBt != null) { + rc = sqlite3BtreeBeginTrans(pBt, pOp.p2); + if (rc == SQLITE_BUSY) { + p.pc = pc; + p.rc = rc = SQLITE_BUSY; + goto vdbe_return; + } + if (rc != SQLITE_OK) { + goto abort_due_to_error; + } + if (pOp.p2 != 0 && p.usesStmtJournal + && (db.autoCommit == 0 || db.activeVdbeCnt > 1) + ) { + Debug.Assert(sqlite3BtreeIsInTrans(pBt)); + if (p.iStatement == 0) { + Debug.Assert(db.nStatement >= 0 && db.nSavepoint >= 0); + db.nStatement++; + p.iStatement = db.nSavepoint + db.nStatement; + } + rc = sqlite3VtabSavepoint(db, SAVEPOINT_BEGIN, p.iStatement - 1); + if (rc == SQLITE_OK) { + rc = sqlite3BtreeBeginStmt(pBt, p.iStatement); + } + /* Store the current value of the database handles deferred constraint + ** counter. If the statement transaction needs to be rolled back, + ** the value of this counter needs to be restored too. */ + p.nStmtDefCons = db.nDeferredCons; + } + } + break; + } - p.expired = true; - rc = SQLITE_SCHEMA; - } - break; - } + /* Opcode: ReadCookie P1 P2 P3 * * + ** + ** Read cookie number P3 from database P1 and write it into register P2. + ** P3==1 is the schema version. P3==2 is the database format. + ** P3==3 is the recommended pager cache size, and so forth. P1==0 is + ** the main database file and P1==1 is the database file used to store + ** temporary tables. + ** + ** There must be a read-lock on the database (either a transaction + ** must be started or there must be an open cursor) before + ** executing this instruction. + */ + case OP_ReadCookie: { /* out2-prerelease */ + u32 iMeta; + int iDb; + int iCookie; + + iMeta = 0; + iDb = pOp.p1; + iCookie = pOp.p3; + + Debug.Assert(pOp.p3 < SQLITE_N_BTREE_META); + Debug.Assert(iDb >= 0 && iDb < db.nDb); + Debug.Assert(db.aDb[iDb].pBt != null); + Debug.Assert((p.btreeMask & (((yDbMask)1) << iDb)) != 0); + sqlite3BtreeGetMeta(db.aDb[iDb].pBt, iCookie, ref iMeta); + pOut.u.i = (int)iMeta; + break; + } - /* Opcode: OpenRead P1 P2 P3 P4 P5 - ** - ** Open a read-only cursor for the database table whose root page is - ** P2 in a database file. The database file is determined by P3. - ** P3==0 means the main database, P3==1 means the database used for - ** temporary tables, and P3>1 means used the corresponding attached - ** database. Give the new cursor an identifier of P1. The P1 - ** values need not be contiguous but all P1 values should be small integers. - ** It is an error for P1 to be negative. - ** - ** If P5!=0 then use the content of register P2 as the root page, not - ** the value of P2 itself. - ** - ** There will be a read lock on the database whenever there is an - ** open cursor. If the database was unlocked prior to this instruction - ** then a read lock is acquired as part of this instruction. A read - ** lock allows other processes to read the database but prohibits - ** any other process from modifying the database. The read lock is - ** released when all cursors are closed. If this instruction attempts - ** to get a read lock but fails, the script terminates with an - ** SQLITE_BUSY error code. - ** - ** The P4 value may be either an integer (P4_INT32) or a pointer to - ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo - ** structure, then said structure defines the content and collating - ** sequence of the index being opened. Otherwise, if P4 is an integer - ** value, it is set to the number of columns in the table. - ** - ** See also OpenWrite. - */ - /* Opcode: OpenWrite P1 P2 P3 P4 P5 - ** - ** Open a read/write cursor named P1 on the table or index whose root - ** page is P2. Or if P5!=0 use the content of register P2 to find the - ** root page. - ** - ** The P4 value may be either an integer (P4_INT32) or a pointer to - ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo - ** structure, then said structure defines the content and collating - ** sequence of the index being opened. Otherwise, if P4 is an integer - ** value, it is set to the number of columns in the table, or to the - ** largest index of any column of the table that is actually used. - ** - ** This instruction works just like OpenRead except that it opens the cursor - ** in read/write mode. For a given table, there can be one or more read-only - ** cursors or a single read/write cursor but not both. - ** - ** See also OpenRead. - */ - case OP_OpenRead: - case OP_OpenWrite: - { - int nField; - KeyInfo pKeyInfo; - int p2; - int iDb; - int wrFlag; - Btree pX; - VdbeCursor pCur; - Db pDb; - - if ( p.expired ) - { - rc = SQLITE_ABORT; - break; - } - - nField = 0; - pKeyInfo = null; - p2 = pOp.p2; - iDb = pOp.p3; - Debug.Assert( iDb >= 0 && iDb < db.nDb ); - Debug.Assert( ( p.btreeMask & ( ( (yDbMask)1 ) << iDb ) ) != 0 ); - pDb = db.aDb[iDb]; - pX = pDb.pBt; - Debug.Assert( pX != null ); - if ( pOp.opcode == OP_OpenWrite ) - { - wrFlag = 1; - Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); - if ( pDb.pSchema.file_format < p.minWriteFileFormat ) - { - p.minWriteFileFormat = pDb.pSchema.file_format; - } - } - else - { - wrFlag = 0; - } - if ( pOp.p5 != 0 ) - { - Debug.Assert( p2 > 0 ); - Debug.Assert( p2 <= p.nMem ); - pIn2 = aMem[p2]; - Debug.Assert( memIsValid( pIn2 ) ); - Debug.Assert( ( pIn2.flags & MEM_Int ) != 0 ); - sqlite3VdbeMemIntegerify( pIn2 ); - p2 = (int)pIn2.u.i; - /* The p2 value always comes from a prior OP_CreateTable opcode and - ** that opcode will always set the p2 value to 2 or more or else fail. - ** If there were a failure, the prepared statement would have halted - ** before reaching this instruction. */ - if ( NEVER( p2 < 2 ) ) - { - rc = SQLITE_CORRUPT_BKPT(); - goto abort_due_to_error; - } - } - if ( pOp.p4type == P4_KEYINFO ) - { - pKeyInfo = pOp.p4.pKeyInfo; - pKeyInfo.enc = ENC( p.db ); - nField = pKeyInfo.nField + 1; - } - else if ( pOp.p4type == P4_INT32 ) - { - nField = pOp.p4.i; - } - Debug.Assert( pOp.p1 >= 0 ); - pCur = allocateCursor( p, pOp.p1, nField, iDb, 1 ); - if ( pCur == null ) - goto no_mem; - pCur.nullRow = true; - pCur.isOrdered = true; - rc = sqlite3BtreeCursor( pX, p2, wrFlag, pKeyInfo, pCur.pCursor ); - pCur.pKeyInfo = pKeyInfo; - /* Since it performs no memory allocation or IO, the only values that - ** sqlite3BtreeCursor() may return are SQLITE_EMPTY and SQLITE_OK. - ** SQLITE_EMPTY is only returned when attempting to open the table - ** rooted at page 1 of a zero-byte database. */ - Debug.Assert( rc == SQLITE_EMPTY || rc == SQLITE_OK ); - if ( rc == SQLITE_EMPTY ) - { - sqlite3MemFreeBtCursor( ref pCur.pCursor ); - rc = SQLITE_OK; - } - /* Set the VdbeCursor.isTable and isIndex variables. Previous versions of - ** SQLite used to check if the root-page flags were sane at this point - ** and report database corruption if they were not, but this check has - ** since moved into the btree layer. */ - pCur.isTable = pOp.p4type != P4_KEYINFO; - pCur.isIndex = !pCur.isTable; - break; - } + /* Opcode: SetCookie P1 P2 P3 * * + ** + ** Write the content of register P3 (interpreted as an integer) + ** into cookie number P2 of database P1. P2==1 is the schema version. + ** P2==2 is the database format. P2==3 is the recommended pager cache + ** size, and so forth. P1==0 is the main database file and P1==1 is the + ** database file used to store temporary tables. + ** + ** A transaction must be started before executing this opcode. + */ + case OP_SetCookie: { /* in3 */ + Db pDb; + Debug.Assert(pOp.p2 < SQLITE_N_BTREE_META); + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < db.nDb); + Debug.Assert((p.btreeMask & (((yDbMask)1) << pOp.p1)) != 0); + pDb = db.aDb[pOp.p1]; + Debug.Assert(pDb.pBt != null); + Debug.Assert(sqlite3SchemaMutexHeld(db, pOp.p1, null)); + pIn3 = aMem[pOp.p3]; + sqlite3VdbeMemIntegerify(pIn3); + /* See note about index shifting on OP_ReadCookie */ + rc = sqlite3BtreeUpdateMeta(pDb.pBt, pOp.p2, (u32)pIn3.u.i); + if (pOp.p2 == BTREE_SCHEMA_VERSION) { + /* When the schema cookie changes, record the new cookie internally */ + pDb.pSchema.schema_cookie = (int)pIn3.u.i; + db.flags |= SQLITE_InternChanges; + } else if (pOp.p2 == BTREE_FILE_FORMAT) { + /* Record changes in the file format */ + pDb.pSchema.file_format = (u8)pIn3.u.i; + } + if (pOp.p1 == 1) { + /* Invalidate all prepared statements whenever the TEMP database + ** schema is changed. Ticket #1644 */ + sqlite3ExpirePreparedStatements(db); + p.expired = false; + } + break; + } - /* Opcode: OpenEphemeral P1 P2 * P4 * - ** - ** Open a new cursor P1 to a transient table. - ** The cursor is always opened read/write even if - ** the main database is read-only. The ephemeral - ** table is deleted automatically when the cursor is closed. - ** - ** P2 is the number of columns in the ephemeral table. - ** The cursor points to a BTree table if P4==0 and to a BTree index - ** if P4 is not 0. If P4 is not NULL, it points to a KeyInfo structure - ** that defines the format of keys in the index. - ** - ** This opcode was once called OpenTemp. But that created - ** confusion because the term "temp table", might refer either - ** to a TEMP table at the SQL level, or to a table opened by - ** this opcode. Then this opcode was call OpenVirtual. But - ** that created confusion with the whole virtual-table idea. - */ - /* Opcode: OpenAutoindex P1 P2 * P4 * - ** - ** This opcode works the same as OP_OpenEphemeral. It has a - ** different name to distinguish its use. Tables created using - ** by this opcode will be used for automatically created transient - ** indices in joins. - */ - case OP_OpenAutoindex: - case OP_OpenEphemeral: - { - VdbeCursor pCx; - const int vfsFlags = - SQLITE_OPEN_READWRITE | - SQLITE_OPEN_CREATE | - SQLITE_OPEN_EXCLUSIVE | - SQLITE_OPEN_DELETEONCLOSE | - SQLITE_OPEN_TRANSIENT_DB; - - Debug.Assert( pOp.p1 >= 0 ); - pCx = allocateCursor( p, pOp.p1, pOp.p2, -1, 1 ); - if ( pCx == null ) - goto no_mem; - pCx.nullRow = true; - rc = sqlite3BtreeOpen( db.pVfs, null, db, ref pCx.pBt, - BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp.p5, vfsFlags ); - if ( rc == SQLITE_OK ) - { - rc = sqlite3BtreeBeginTrans( pCx.pBt, 1 ); - } - if ( rc == SQLITE_OK ) - { - /* If a transient index is required, create it by calling - ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before - ** opening it. If a transient table is required, just use the - ** automatically created table with root-page 1 (an BLOB_INTKEY table). - */ - if ( pOp.p4.pKeyInfo != null ) - { - int pgno = 0; - Debug.Assert( pOp.p4type == P4_KEYINFO ); - rc = sqlite3BtreeCreateTable( pCx.pBt, ref pgno, BTREE_BLOBKEY ); - if ( rc == SQLITE_OK ) - { - Debug.Assert( pgno == MASTER_ROOT + 1 ); - rc = sqlite3BtreeCursor( pCx.pBt, pgno, 1, - pOp.p4.pKeyInfo, pCx.pCursor ); - pCx.pKeyInfo = pOp.p4.pKeyInfo; - pCx.pKeyInfo.enc = ENC( p.db ); - } - pCx.isTable = false; - } - else - { - rc = sqlite3BtreeCursor( pCx.pBt, MASTER_ROOT, 1, null, pCx.pCursor ); - pCx.isTable = true; - } - } - pCx.isOrdered = ( pOp.p5 != BTREE_UNORDERED ); - pCx.isIndex = !pCx.isTable; - break; - } + /* Opcode: VerifyCookie P1 P2 P3 * * + ** + ** Check the value of global database parameter number 0 (the + ** schema version) and make sure it is equal to P2 and that the + ** generation counter on the local schema parse equals P3. + ** + ** P1 is the database number which is 0 for the main database file + ** and 1 for the file holding temporary tables and some higher number + ** for auxiliary databases. + ** + ** The cookie changes its value whenever the database schema changes. + ** This operation is used to detect when that the cookie has changed + ** and that the current process needs to reread the schema. + ** + ** Either a transaction needs to have been started or an OP_Open needs + ** to be executed (to establish a read lock) before this opcode is + ** invoked. + */ + case OP_VerifyCookie: { + u32 iMeta = 0; + u32 iGen; + Btree pBt; + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < db.nDb); + Debug.Assert((p.btreeMask & ((yDbMask)1 << pOp.p1)) != 0); + Debug.Assert(sqlite3SchemaMutexHeld(db, pOp.p1, null)); + pBt = db.aDb[pOp.p1].pBt; + if (pBt != null) { + sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, ref iMeta); + iGen = db.aDb[pOp.p1].pSchema.iGeneration; + } else { + iGen = iMeta = 0; + } + if (iMeta != pOp.p2 || iGen != pOp.p3) { + sqlite3DbFree(db, ref p.zErrMsg); + p.zErrMsg = "database schema has changed";// sqlite3DbStrDup(db, "database schema has changed"); + /* If the schema-cookie from the database file matches the cookie + ** stored with the in-memory representation of the schema, do + ** not reload the schema from the database file. + ** + ** If virtual-tables are in use, this is not just an optimization. + ** Often, v-tables store their data in other SQLite tables, which + ** are queried from within xNext() and other v-table methods using + ** prepared queries. If such a query is out-of-date, we do not want to + ** discard the database schema, as the user code implementing the + ** v-table would have to be ready for the sqlite3_vtab structure itself + ** to be invalidated whenever sqlite3_step() is called from within + ** a v-table method. + */ + if (db.aDb[pOp.p1].pSchema.schema_cookie != iMeta) { + sqlite3ResetInternalSchema(db, pOp.p1); + } + + p.expired = true; + rc = SQLITE_SCHEMA; + } + break; + } - /* Opcode: OpenPseudo P1 P2 P3 * * - ** - ** Open a new cursor that points to a fake table that contains a single - ** row of data. The content of that one row in the content of memory - ** register P2. In other words, cursor P1 becomes an alias for the - ** MEM_Blob content contained in register P2. - ** - ** A pseudo-table created by this opcode is used to hold a single - ** row output from the sorter so that the row can be decomposed into - ** individual columns using the OP_Column opcode. The OP_Column opcode - ** is the only cursor opcode that works with a pseudo-table. - ** - ** P3 is the number of fields in the records that will be stored by - ** the pseudo-table. - */ - case OP_OpenPseudo: - { - VdbeCursor pCx; - Debug.Assert( pOp.p1 >= 0 ); - pCx = allocateCursor( p, pOp.p1, pOp.p3, -1, 0 ); - if ( pCx == null ) - goto no_mem; - pCx.nullRow = true; - pCx.pseudoTableReg = pOp.p2; - pCx.isTable = true; - pCx.isIndex = false; - break; - } + /* Opcode: OpenRead P1 P2 P3 P4 P5 + ** + ** Open a read-only cursor for the database table whose root page is + ** P2 in a database file. The database file is determined by P3. + ** P3==0 means the main database, P3==1 means the database used for + ** temporary tables, and P3>1 means used the corresponding attached + ** database. Give the new cursor an identifier of P1. The P1 + ** values need not be contiguous but all P1 values should be small integers. + ** It is an error for P1 to be negative. + ** + ** If P5!=0 then use the content of register P2 as the root page, not + ** the value of P2 itself. + ** + ** There will be a read lock on the database whenever there is an + ** open cursor. If the database was unlocked prior to this instruction + ** then a read lock is acquired as part of this instruction. A read + ** lock allows other processes to read the database but prohibits + ** any other process from modifying the database. The read lock is + ** released when all cursors are closed. If this instruction attempts + ** to get a read lock but fails, the script terminates with an + ** SQLITE_BUSY error code. + ** + ** The P4 value may be either an integer (P4_INT32) or a pointer to + ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo + ** structure, then said structure defines the content and collating + ** sequence of the index being opened. Otherwise, if P4 is an integer + ** value, it is set to the number of columns in the table. + ** + ** See also OpenWrite. + */ + /* Opcode: OpenWrite P1 P2 P3 P4 P5 + ** + ** Open a read/write cursor named P1 on the table or index whose root + ** page is P2. Or if P5!=0 use the content of register P2 to find the + ** root page. + ** + ** The P4 value may be either an integer (P4_INT32) or a pointer to + ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo + ** structure, then said structure defines the content and collating + ** sequence of the index being opened. Otherwise, if P4 is an integer + ** value, it is set to the number of columns in the table, or to the + ** largest index of any column of the table that is actually used. + ** + ** This instruction works just like OpenRead except that it opens the cursor + ** in read/write mode. For a given table, there can be one or more read-only + ** cursors or a single read/write cursor but not both. + ** + ** See also OpenRead. + */ + case OP_OpenRead: + case OP_OpenWrite: { + int nField; + KeyInfo pKeyInfo; + int p2; + int iDb; + int wrFlag; + Btree pX; + VdbeCursor pCur; + Db pDb; + + if (p.expired) { + rc = SQLITE_ABORT; + break; + } + + nField = 0; + pKeyInfo = null; + p2 = pOp.p2; + iDb = pOp.p3; + Debug.Assert(iDb >= 0 && iDb < db.nDb); + Debug.Assert((p.btreeMask & (((yDbMask)1) << iDb)) != 0); + pDb = db.aDb[iDb]; + pX = pDb.pBt; + Debug.Assert(pX != null); + if (pOp.opcode == OP_OpenWrite) { + wrFlag = 1; + Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + if (pDb.pSchema.file_format < p.minWriteFileFormat) { + p.minWriteFileFormat = pDb.pSchema.file_format; + } + } else { + wrFlag = 0; + } + if (pOp.p5 != 0) { + Debug.Assert(p2 > 0); + Debug.Assert(p2 <= p.nMem); + pIn2 = aMem[p2]; + Debug.Assert(memIsValid(pIn2)); + Debug.Assert((pIn2.flags & MEM_Int) != 0); + sqlite3VdbeMemIntegerify(pIn2); + p2 = (int)pIn2.u.i; + /* The p2 value always comes from a prior OP_CreateTable opcode and + ** that opcode will always set the p2 value to 2 or more or else fail. + ** If there were a failure, the prepared statement would have halted + ** before reaching this instruction. */ + if (NEVER(p2 < 2)) { + rc = SQLITE_CORRUPT_BKPT(); + goto abort_due_to_error; + } + } + if (pOp.p4type == P4_KEYINFO) { + pKeyInfo = pOp.p4.pKeyInfo; + pKeyInfo.enc = ENC(p.db); + nField = pKeyInfo.nField + 1; + } else if (pOp.p4type == P4_INT32) { + nField = pOp.p4.i; + } + Debug.Assert(pOp.p1 >= 0); + pCur = allocateCursor(p, pOp.p1, nField, iDb, 1); + if (pCur == null) + goto no_mem; + pCur.nullRow = true; + pCur.isOrdered = true; + rc = sqlite3BtreeCursor(pX, p2, wrFlag, pKeyInfo, pCur.pCursor); + pCur.pKeyInfo = pKeyInfo; + /* Since it performs no memory allocation or IO, the only values that + ** sqlite3BtreeCursor() may return are SQLITE_EMPTY and SQLITE_OK. + ** SQLITE_EMPTY is only returned when attempting to open the table + ** rooted at page 1 of a zero-byte database. */ + Debug.Assert(rc == SQLITE_EMPTY || rc == SQLITE_OK); + if (rc == SQLITE_EMPTY) { + sqlite3MemFreeBtCursor(ref pCur.pCursor); + rc = SQLITE_OK; + } + /* Set the VdbeCursor.isTable and isIndex variables. Previous versions of + ** SQLite used to check if the root-page flags were sane at this point + ** and report database corruption if they were not, but this check has + ** since moved into the btree layer. */ + pCur.isTable = pOp.p4type != P4_KEYINFO; + pCur.isIndex = !pCur.isTable; + break; + } - /* Opcode: Close P1 * * * * - ** - ** Close a cursor previously opened as P1. If P1 is not - ** currently open, this instruction is a no-op. - */ - case OP_Close: - { - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); - sqlite3VdbeFreeCursor( p, p.apCsr[pOp.p1] ); - p.apCsr[pOp.p1] = null; - break; - } + /* Opcode: OpenEphemeral P1 P2 * P4 * + ** + ** Open a new cursor P1 to a transient table. + ** The cursor is always opened read/write even if + ** the main database is read-only. The ephemeral + ** table is deleted automatically when the cursor is closed. + ** + ** P2 is the number of columns in the ephemeral table. + ** The cursor points to a BTree table if P4==0 and to a BTree index + ** if P4 is not 0. If P4 is not NULL, it points to a KeyInfo structure + ** that defines the format of keys in the index. + ** + ** This opcode was once called OpenTemp. But that created + ** confusion because the term "temp table", might refer either + ** to a TEMP table at the SQL level, or to a table opened by + ** this opcode. Then this opcode was call OpenVirtual. But + ** that created confusion with the whole virtual-table idea. + */ + /* Opcode: OpenAutoindex P1 P2 * P4 * + ** + ** This opcode works the same as OP_OpenEphemeral. It has a + ** different name to distinguish its use. Tables created using + ** by this opcode will be used for automatically created transient + ** indices in joins. + */ + case OP_OpenAutoindex: + case OP_OpenEphemeral: { + VdbeCursor pCx; + const int vfsFlags = + SQLITE_OPEN_READWRITE | + SQLITE_OPEN_CREATE | + SQLITE_OPEN_EXCLUSIVE | + SQLITE_OPEN_DELETEONCLOSE | + SQLITE_OPEN_TRANSIENT_DB; + + Debug.Assert(pOp.p1 >= 0); + pCx = allocateCursor(p, pOp.p1, pOp.p2, -1, 1); + if (pCx == null) + goto no_mem; + pCx.nullRow = true; + rc = sqlite3BtreeOpen(db.pVfs, null, db, ref pCx.pBt, + BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp.p5, vfsFlags); + if (rc == SQLITE_OK) { + rc = sqlite3BtreeBeginTrans(pCx.pBt, 1); + } + if (rc == SQLITE_OK) { + /* If a transient index is required, create it by calling + ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before + ** opening it. If a transient table is required, just use the + ** automatically created table with root-page 1 (an BLOB_INTKEY table). + */ + if (pOp.p4.pKeyInfo != null) { + int pgno = 0; + Debug.Assert(pOp.p4type == P4_KEYINFO); + rc = sqlite3BtreeCreateTable(pCx.pBt, ref pgno, BTREE_BLOBKEY); + if (rc == SQLITE_OK) { + Debug.Assert(pgno == MASTER_ROOT + 1); + rc = sqlite3BtreeCursor(pCx.pBt, pgno, 1, + pOp.p4.pKeyInfo, pCx.pCursor); + pCx.pKeyInfo = pOp.p4.pKeyInfo; + pCx.pKeyInfo.enc = ENC(p.db); + } + pCx.isTable = false; + } else { + rc = sqlite3BtreeCursor(pCx.pBt, MASTER_ROOT, 1, null, pCx.pCursor); + pCx.isTable = true; + } + } + pCx.isOrdered = (pOp.p5 != BTREE_UNORDERED); + pCx.isIndex = !pCx.isTable; + break; + } - /* Opcode: SeekGe P1 P2 P3 P4 * - ** - ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), - ** use the value in register P3 as the key. If cursor P1 refers - ** to an SQL index, then P3 is the first in an array of P4 registers - ** that are used as an unpacked index key. - ** - ** Reposition cursor P1 so that it points to the smallest entry that - ** is greater than or equal to the key value. If there are no records - ** greater than or equal to the key and P2 is not zero, then jump to P2. - ** - ** See also: Found, NotFound, Distinct, SeekLt, SeekGt, SeekLe - */ - /* Opcode: SeekGt P1 P2 P3 P4 * - ** - ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), - ** use the value in register P3 as a key. If cursor P1 refers - ** to an SQL index, then P3 is the first in an array of P4 registers - ** that are used as an unpacked index key. - ** - ** Reposition cursor P1 so that it points to the smallest entry that - ** is greater than the key value. If there are no records greater than - ** the key and P2 is not zero, then jump to P2. - ** - ** See also: Found, NotFound, Distinct, SeekLt, SeekGe, SeekLe - */ - /* Opcode: SeekLt P1 P2 P3 P4 * - ** - ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), - ** use the value in register P3 as a key. If cursor P1 refers - ** to an SQL index, then P3 is the first in an array of P4 registers - ** that are used as an unpacked index key. - ** - ** Reposition cursor P1 so that it points to the largest entry that - ** is less than the key value. If there are no records less than - ** the key and P2 is not zero, then jump to P2. - ** - ** See also: Found, NotFound, Distinct, SeekGt, SeekGe, SeekLe - */ - /* Opcode: SeekLe P1 P2 P3 P4 * - ** - ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), - ** use the value in register P3 as a key. If cursor P1 refers - ** to an SQL index, then P3 is the first in an array of P4 registers - ** that are used as an unpacked index key. - ** - ** Reposition cursor P1 so that it points to the largest entry that - ** is less than or equal to the key value. If there are no records - ** less than or equal to the key and P2 is not zero, then jump to P2. - ** - ** See also: Found, NotFound, Distinct, SeekGt, SeekGe, SeekLt - */ - case OP_SeekLt: /* jump, in3 */ - case OP_SeekLe: /* jump, in3 */ - case OP_SeekGe: /* jump, in3 */ - case OP_SeekGt: - { /* jump, in3 */ - int res; - int oc; - VdbeCursor pC; - UnpackedRecord r; - int nField; - i64 iKey; /* The rowid we are to seek to */ - - res = 0; - r = new UnpackedRecord(); - - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); - Debug.Assert( pOp.p2 != 0 ); - pC = p.apCsr[pOp.p1]; - Debug.Assert( pC != null ); - Debug.Assert( pC.pseudoTableReg == 0 ); - Debug.Assert( OP_SeekLe == OP_SeekLt + 1 ); - Debug.Assert( OP_SeekGe == OP_SeekLt + 2 ); - Debug.Assert( OP_SeekGt == OP_SeekLt + 3 ); - Debug.Assert( pC.isOrdered ); - if ( pC.pCursor != null ) - { - oc = pOp.opcode; - pC.nullRow = false; - if ( pC.isTable ) - { - /* The input value in P3 might be of any type: integer, real, string, - ** blob, or NULL. But it needs to be an integer before we can do - ** the seek, so convert it. */ - pIn3 = aMem[pOp.p3]; - applyNumericAffinity( pIn3 ); - iKey = sqlite3VdbeIntValue( pIn3 ); - pC.rowidIsValid = false; - - /* If the P3 value could not be converted into an integer without - ** loss of information, then special processing is required... */ - if ( ( pIn3.flags & MEM_Int ) == 0 ) - { - if ( ( pIn3.flags & MEM_Real ) == 0 ) - { - /* If the P3 value cannot be converted into any kind of a number, - ** then the seek is not possible, so jump to P2 */ - pc = pOp.p2 - 1; - break; - } - /* If we reach this point, then the P3 value must be a floating - ** point number. */ - Debug.Assert( ( pIn3.flags & MEM_Real ) != 0 ); - - if ( iKey == SMALLEST_INT64 && ( pIn3.r < (double)iKey || pIn3.r > 0 ) ) - { - /* The P3 value is too large in magnitude to be expressed as an - ** integer. */ - res = 1; - if ( pIn3.r < 0 ) - { - if ( oc >= OP_SeekGe ) - { - Debug.Assert( oc == OP_SeekGe || oc == OP_SeekGt ); - rc = sqlite3BtreeFirst( pC.pCursor, ref res ); - if ( rc != SQLITE_OK ) - goto abort_due_to_error; + /* Opcode: OpenPseudo P1 P2 P3 * * + ** + ** Open a new cursor that points to a fake table that contains a single + ** row of data. The content of that one row in the content of memory + ** register P2. In other words, cursor P1 becomes an alias for the + ** MEM_Blob content contained in register P2. + ** + ** A pseudo-table created by this opcode is used to hold a single + ** row output from the sorter so that the row can be decomposed into + ** individual columns using the OP_Column opcode. The OP_Column opcode + ** is the only cursor opcode that works with a pseudo-table. + ** + ** P3 is the number of fields in the records that will be stored by + ** the pseudo-table. + */ + case OP_OpenPseudo: { + VdbeCursor pCx; + Debug.Assert(pOp.p1 >= 0); + pCx = allocateCursor(p, pOp.p1, pOp.p3, -1, 0); + if (pCx == null) + goto no_mem; + pCx.nullRow = true; + pCx.pseudoTableReg = pOp.p2; + pCx.isTable = true; + pCx.isIndex = false; + break; } - } - else - { - if ( oc <= OP_SeekLe ) - { - Debug.Assert( oc == OP_SeekLt || oc == OP_SeekLe ); - rc = sqlite3BtreeLast( pC.pCursor, ref res ); - if ( rc != SQLITE_OK ) - goto abort_due_to_error; + + /* Opcode: Close P1 * * * * + ** + ** Close a cursor previously opened as P1. If P1 is not + ** currently open, this instruction is a no-op. + */ + case OP_Close: { + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); + sqlite3VdbeFreeCursor(p, p.apCsr[pOp.p1]); + p.apCsr[pOp.p1] = null; + break; } - } - if ( res != 0 ) - { - pc = pOp.p2 - 1; - } - break; - } - else if ( oc == OP_SeekLt || oc == OP_SeekGe ) - { - /* Use the ceiling() function to convert real.int */ - if ( pIn3.r > (double)iKey ) - iKey++; - } - else - { - /* Use the floor() function to convert real.int */ - Debug.Assert( oc == OP_SeekLe || oc == OP_SeekGt ); - if ( pIn3.r < (double)iKey ) - iKey--; - } - } - rc = sqlite3BtreeMovetoUnpacked( pC.pCursor, null, iKey, 0, ref res ); - if ( rc != SQLITE_OK ) - { - goto abort_due_to_error; - } - if ( res == 0 ) - { - pC.rowidIsValid = true; - pC.lastRowid = iKey; - } - } - else - { - nField = pOp.p4.i; - Debug.Assert( pOp.p4type == P4_INT32 ); - Debug.Assert( nField > 0 ); - r.pKeyInfo = pC.pKeyInfo; - r.nField = (u16)nField; - - /* The next line of code computes as follows, only faster: - ** if( oc==OP_SeekGt || oc==OP_SeekLe ){ - ** r.flags = UNPACKED_INCRKEY; - ** }else{ - ** r.flags = 0; - ** } - */ - r.flags = (u16)( UNPACKED_INCRKEY * ( 1 & ( oc - OP_SeekLt ) ) ); - Debug.Assert( oc != OP_SeekGt || r.flags == UNPACKED_INCRKEY ); - Debug.Assert( oc != OP_SeekLe || r.flags == UNPACKED_INCRKEY ); - Debug.Assert( oc != OP_SeekGe || r.flags == 0 ); - Debug.Assert( oc != OP_SeekLt || r.flags == 0 ); - - r.aMem = new Mem[r.nField]; - for ( int rI = 0; rI < r.nField; rI++ ) - r.aMem[rI] = aMem[pOp.p3 + rI];// r.aMem = aMem[pOp.p3]; + + /* Opcode: SeekGe P1 P2 P3 P4 * + ** + ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), + ** use the value in register P3 as the key. If cursor P1 refers + ** to an SQL index, then P3 is the first in an array of P4 registers + ** that are used as an unpacked index key. + ** + ** Reposition cursor P1 so that it points to the smallest entry that + ** is greater than or equal to the key value. If there are no records + ** greater than or equal to the key and P2 is not zero, then jump to P2. + ** + ** See also: Found, NotFound, Distinct, SeekLt, SeekGt, SeekLe + */ + /* Opcode: SeekGt P1 P2 P3 P4 * + ** + ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), + ** use the value in register P3 as a key. If cursor P1 refers + ** to an SQL index, then P3 is the first in an array of P4 registers + ** that are used as an unpacked index key. + ** + ** Reposition cursor P1 so that it points to the smallest entry that + ** is greater than the key value. If there are no records greater than + ** the key and P2 is not zero, then jump to P2. + ** + ** See also: Found, NotFound, Distinct, SeekLt, SeekGe, SeekLe + */ + /* Opcode: SeekLt P1 P2 P3 P4 * + ** + ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), + ** use the value in register P3 as a key. If cursor P1 refers + ** to an SQL index, then P3 is the first in an array of P4 registers + ** that are used as an unpacked index key. + ** + ** Reposition cursor P1 so that it points to the largest entry that + ** is less than the key value. If there are no records less than + ** the key and P2 is not zero, then jump to P2. + ** + ** See also: Found, NotFound, Distinct, SeekGt, SeekGe, SeekLe + */ + /* Opcode: SeekLe P1 P2 P3 P4 * + ** + ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), + ** use the value in register P3 as a key. If cursor P1 refers + ** to an SQL index, then P3 is the first in an array of P4 registers + ** that are used as an unpacked index key. + ** + ** Reposition cursor P1 so that it points to the largest entry that + ** is less than or equal to the key value. If there are no records + ** less than or equal to the key and P2 is not zero, then jump to P2. + ** + ** See also: Found, NotFound, Distinct, SeekGt, SeekGe, SeekLt + */ + case OP_SeekLt: /* jump, in3 */ + case OP_SeekLe: /* jump, in3 */ + case OP_SeekGe: /* jump, in3 */ + case OP_SeekGt: { /* jump, in3 */ + int res; + int oc; + VdbeCursor pC; + UnpackedRecord r; + int nField; + i64 iKey; /* The rowid we are to seek to */ + + res = 0; + r = new UnpackedRecord(); + + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); + Debug.Assert(pOp.p2 != 0); + pC = p.apCsr[pOp.p1]; + Debug.Assert(pC != null); + Debug.Assert(pC.pseudoTableReg == 0); + Debug.Assert(OP_SeekLe == OP_SeekLt + 1); + Debug.Assert(OP_SeekGe == OP_SeekLt + 2); + Debug.Assert(OP_SeekGt == OP_SeekLt + 3); + Debug.Assert(pC.isOrdered); + if (pC.pCursor != null) { + oc = pOp.opcode; + pC.nullRow = false; + if (pC.isTable) { + /* The input value in P3 might be of any type: integer, real, string, + ** blob, or NULL. But it needs to be an integer before we can do + ** the seek, so convert it. */ + pIn3 = aMem[pOp.p3]; + applyNumericAffinity(pIn3); + iKey = sqlite3VdbeIntValue(pIn3); + pC.rowidIsValid = false; + + /* If the P3 value could not be converted into an integer without + ** loss of information, then special processing is required... */ + if ((pIn3.flags & MEM_Int) == 0) { + if ((pIn3.flags & MEM_Real) == 0) { + /* If the P3 value cannot be converted into any kind of a number, + ** then the seek is not possible, so jump to P2 */ + pc = pOp.p2 - 1; + break; + } + /* If we reach this point, then the P3 value must be a floating + ** point number. */ + Debug.Assert((pIn3.flags & MEM_Real) != 0); + + if (iKey == SMALLEST_INT64 && (pIn3.r < (double)iKey || pIn3.r > 0)) { + /* The P3 value is too large in magnitude to be expressed as an + ** integer. */ + res = 1; + if (pIn3.r < 0) { + if (oc >= OP_SeekGe) { + Debug.Assert(oc == OP_SeekGe || oc == OP_SeekGt); + rc = sqlite3BtreeFirst(pC.pCursor, ref res); + if (rc != SQLITE_OK) + goto abort_due_to_error; + } + } else { + if (oc <= OP_SeekLe) { + Debug.Assert(oc == OP_SeekLt || oc == OP_SeekLe); + rc = sqlite3BtreeLast(pC.pCursor, ref res); + if (rc != SQLITE_OK) + goto abort_due_to_error; + } + } + if (res != 0) { + pc = pOp.p2 - 1; + } + break; + } else if (oc == OP_SeekLt || oc == OP_SeekGe) { + /* Use the ceiling() function to convert real.int */ + if (pIn3.r > (double)iKey) + iKey++; + } else { + /* Use the floor() function to convert real.int */ + Debug.Assert(oc == OP_SeekLe || oc == OP_SeekGt); + if (pIn3.r < (double)iKey) + iKey--; + } + } + rc = sqlite3BtreeMovetoUnpacked(pC.pCursor, null, iKey, 0, ref res); + if (rc != SQLITE_OK) { + goto abort_due_to_error; + } + if (res == 0) { + pC.rowidIsValid = true; + pC.lastRowid = iKey; + } + } else { + nField = pOp.p4.i; + Debug.Assert(pOp.p4type == P4_INT32); + Debug.Assert(nField > 0); + r.pKeyInfo = pC.pKeyInfo; + r.nField = (u16)nField; + + /* The next line of code computes as follows, only faster: + ** if( oc==OP_SeekGt || oc==OP_SeekLe ){ + ** r.flags = UNPACKED_INCRKEY; + ** }else{ + ** r.flags = 0; + ** } + */ + r.flags = (u16)(UNPACKED_INCRKEY * (1 & (oc - OP_SeekLt))); + Debug.Assert(oc != OP_SeekGt || r.flags == UNPACKED_INCRKEY); + Debug.Assert(oc != OP_SeekLe || r.flags == UNPACKED_INCRKEY); + Debug.Assert(oc != OP_SeekGe || r.flags == 0); + Debug.Assert(oc != OP_SeekLt || r.flags == 0); + + r.aMem = new Mem[r.nField]; + for (int rI = 0; rI < r.nField; rI++) + r.aMem[rI] = aMem[pOp.p3 + rI];// r.aMem = aMem[pOp.p3]; #if SQLITE_DEBUG - { - int i; - for ( i = 0; i < r.nField; i++ ) - Debug.Assert( memIsValid( r.aMem[i] ) ); - } + { + int i; + for (i = 0; i < r.nField; i++) + Debug.Assert(memIsValid(r.aMem[i])); + } #endif - ExpandBlob( r.aMem[0] ); - rc = sqlite3BtreeMovetoUnpacked( pC.pCursor, r, 0, 0, ref res ); - if ( rc != SQLITE_OK ) - { - goto abort_due_to_error; - } - pC.rowidIsValid = false; - } - pC.deferredMoveto = false; - pC.cacheStatus = CACHE_STALE; + ExpandBlob(r.aMem[0]); + rc = sqlite3BtreeMovetoUnpacked(pC.pCursor, r, 0, 0, ref res); + if (rc != SQLITE_OK) { + goto abort_due_to_error; + } + pC.rowidIsValid = false; + } + pC.deferredMoveto = false; + pC.cacheStatus = CACHE_STALE; #if SQLITE_TEST #if !TCLSH sqlite3_search_count++; @@ -4102,117 +3675,102 @@ Vdbe p /* The VDBE */ sqlite3_search_count.iValue++; #endif #endif - if ( oc >= OP_SeekGe ) - { - Debug.Assert( oc == OP_SeekGe || oc == OP_SeekGt ); - if ( res < 0 || ( res == 0 && oc == OP_SeekGt ) ) - { - rc = sqlite3BtreeNext( pC.pCursor, ref res ); - if ( rc != SQLITE_OK ) - goto abort_due_to_error; - pC.rowidIsValid = false; - } - else - { - res = 0; - } - } - else - { - Debug.Assert( oc == OP_SeekLt || oc == OP_SeekLe ); - if ( res > 0 || ( res == 0 && oc == OP_SeekLt ) ) - { - rc = sqlite3BtreePrevious( pC.pCursor, ref res ); - if ( rc != SQLITE_OK ) - goto abort_due_to_error; - pC.rowidIsValid = false; - } - else - { - /* res might be negative because the table is empty. Check to - ** see if this is the case. - */ - res = sqlite3BtreeEof( pC.pCursor ) ? 1 : 0; - } - } - Debug.Assert( pOp.p2 > 0 ); - if ( res != 0 ) - { - pc = pOp.p2 - 1; - } - } - else - { - /* This happens when attempting to open the sqlite3_master table - ** for read access returns SQLITE_EMPTY. In this case always - ** take the jump (since there are no records in the table). - */ - pc = pOp.p2 - 1; - } - break; - } + if (oc >= OP_SeekGe) { + Debug.Assert(oc == OP_SeekGe || oc == OP_SeekGt); + if (res < 0 || (res == 0 && oc == OP_SeekGt)) { + rc = sqlite3BtreeNext(pC.pCursor, ref res); + if (rc != SQLITE_OK) + goto abort_due_to_error; + pC.rowidIsValid = false; + } else { + res = 0; + } + } else { + Debug.Assert(oc == OP_SeekLt || oc == OP_SeekLe); + if (res > 0 || (res == 0 && oc == OP_SeekLt)) { + rc = sqlite3BtreePrevious(pC.pCursor, ref res); + if (rc != SQLITE_OK) + goto abort_due_to_error; + pC.rowidIsValid = false; + } else { + /* res might be negative because the table is empty. Check to + ** see if this is the case. + */ + res = sqlite3BtreeEof(pC.pCursor) ? 1 : 0; + } + } + Debug.Assert(pOp.p2 > 0); + if (res != 0) { + pc = pOp.p2 - 1; + } + } else { + /* This happens when attempting to open the sqlite3_master table + ** for read access returns SQLITE_EMPTY. In this case always + ** take the jump (since there are no records in the table). + */ + pc = pOp.p2 - 1; + } + break; + } - /* Opcode: Seek P1 P2 * * * - ** - ** P1 is an open table cursor and P2 is a rowid integer. Arrange - ** for P1 to move so that it points to the rowid given by P2. - ** - ** This is actually a deferred seek. Nothing actually happens until - ** the cursor is used to read a record. That way, if no reads - ** occur, no unnecessary I/O happens. - */ - case OP_Seek: - { /* in2 */ - VdbeCursor pC; - - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); - pC = p.apCsr[pOp.p1]; - Debug.Assert( ALWAYS( pC != null ) ); - if ( pC.pCursor != null ) - { - Debug.Assert( pC.isTable ); - pC.nullRow = false; - pIn2 = aMem[pOp.p2]; - pC.movetoTarget = sqlite3VdbeIntValue( pIn2 ); - pC.rowidIsValid = false; - pC.deferredMoveto = true; - } - break; - } + /* Opcode: Seek P1 P2 * * * + ** + ** P1 is an open table cursor and P2 is a rowid integer. Arrange + ** for P1 to move so that it points to the rowid given by P2. + ** + ** This is actually a deferred seek. Nothing actually happens until + ** the cursor is used to read a record. That way, if no reads + ** occur, no unnecessary I/O happens. + */ + case OP_Seek: { /* in2 */ + VdbeCursor pC; + + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); + pC = p.apCsr[pOp.p1]; + Debug.Assert(ALWAYS(pC != null)); + if (pC.pCursor != null) { + Debug.Assert(pC.isTable); + pC.nullRow = false; + pIn2 = aMem[pOp.p2]; + pC.movetoTarget = sqlite3VdbeIntValue(pIn2); + pC.rowidIsValid = false; + pC.deferredMoveto = true; + } + break; + } - /* Opcode: Found P1 P2 P3 P4 * - ** - ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If - ** P4>0 then register P3 is the first of P4 registers that form an unpacked - ** record. - ** - ** Cursor P1 is on an index btree. If the record identified by P3 and P4 - ** is a prefix of any entry in P1 then a jump is made to P2 and - ** P1 is left pointing at the matching entry. - */ - /* Opcode: NotFound P1 P2 P3 P4 * - ** - ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If - ** P4>0 then register P3 is the first of P4 registers that form an unpacked - ** record. - ** - ** Cursor P1 is on an index btree. If the record identified by P3 and P4 - ** is not the prefix of any entry in P1 then a jump is made to P2. If P1 - ** does contain an entry whose prefix matches the P3/P4 record then control - ** falls through to the next instruction and P1 is left pointing at the - ** matching entry. - ** - ** See also: Found, NotExists, IsUnique - */ - case OP_NotFound: /* jump, in3 */ - case OP_Found: - { /* jump, in3 */ - int alreadyExists; - VdbeCursor pC; - int res = 0; - UnpackedRecord pIdxKey; - UnpackedRecord r = new UnpackedRecord(); - UnpackedRecord aTempRec = new UnpackedRecord();//char aTempRec[ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*3 + 7]; + /* Opcode: Found P1 P2 P3 P4 * + ** + ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If + ** P4>0 then register P3 is the first of P4 registers that form an unpacked + ** record. + ** + ** Cursor P1 is on an index btree. If the record identified by P3 and P4 + ** is a prefix of any entry in P1 then a jump is made to P2 and + ** P1 is left pointing at the matching entry. + */ + /* Opcode: NotFound P1 P2 P3 P4 * + ** + ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If + ** P4>0 then register P3 is the first of P4 registers that form an unpacked + ** record. + ** + ** Cursor P1 is on an index btree. If the record identified by P3 and P4 + ** is not the prefix of any entry in P1 then a jump is made to P2. If P1 + ** does contain an entry whose prefix matches the P3/P4 record then control + ** falls through to the next instruction and P1 is left pointing at the + ** matching entry. + ** + ** See also: Found, NotExists, IsUnique + */ + case OP_NotFound: /* jump, in3 */ + case OP_Found: { /* jump, in3 */ + int alreadyExists; + VdbeCursor pC; + int res = 0; + UnpackedRecord pIdxKey; + UnpackedRecord r = new UnpackedRecord(); + UnpackedRecord aTempRec = new UnpackedRecord();//char aTempRec[ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*3 + 7]; #if SQLITE_TEST #if !TCLSH @@ -4220,866 +3778,773 @@ Vdbe p /* The VDBE */ #else sqlite3_found_count.iValue++; #endif -#endif - alreadyExists = 0; - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); - Debug.Assert( pOp.p4type == P4_INT32 ); - pC = p.apCsr[pOp.p1]; - Debug.Assert( pC != null ); - pIn3 = aMem[pOp.p3]; - if ( ALWAYS( pC.pCursor != null ) ) - { - - Debug.Assert( !pC.isTable ); - if ( pOp.p4.i > 0 ) - { - r.pKeyInfo = pC.pKeyInfo; - r.nField = (u16)pOp.p4.i; - r.aMem = new Mem[r.nField]; - for ( int i = 0; i < r.aMem.Length; i++ ) - { - r.aMem[i] = aMem[pOp.p3 + i]; -#if SQLITE_DEBUG - Debug.Assert( memIsValid( r.aMem[i] ) ); -#endif - } - r.flags = UNPACKED_PREFIX_MATCH; - pIdxKey = r; - } - else - { - Debug.Assert( ( pIn3.flags & MEM_Blob ) != 0 ); - Debug.Assert( ( pIn3.flags & MEM_Zero ) == 0 ); /* zeroblobs already expanded */ - pIdxKey = sqlite3VdbeRecordUnpack( pC.pKeyInfo, pIn3.n, pIn3.zBLOB, - aTempRec, 0 );//sizeof( aTempRec ) ); - if ( pIdxKey == null ) - { - goto no_mem; - } - pIdxKey.flags |= UNPACKED_PREFIX_MATCH; - } - rc = sqlite3BtreeMovetoUnpacked( pC.pCursor, pIdxKey, 0, 0, ref res ); - if ( pOp.p4.i == 0 ) - { - sqlite3VdbeDeleteUnpackedRecord( pIdxKey ); - } - if ( rc != SQLITE_OK ) - { - break; - } - alreadyExists = ( res == 0 ) ? 1 : 0; - pC.deferredMoveto = false; - pC.cacheStatus = CACHE_STALE; - } - if ( pOp.opcode == OP_Found ) - { - if ( alreadyExists != 0 ) - pc = pOp.p2 - 1; - } - else - { - if ( 0 == alreadyExists ) - pc = pOp.p2 - 1; - } - break; - } - - /* Opcode: IsUnique P1 P2 P3 P4 * - ** - ** Cursor P1 is open on an index b-tree - that is to say, a btree which - ** no data and where the key are records generated by OP_MakeRecord with - ** the list field being the integer ROWID of the entry that the index - ** entry refers to. - ** - ** The P3 register contains an integer record number. Call this record - ** number R. Register P4 is the first in a set of N contiguous registers - ** that make up an unpacked index key that can be used with cursor P1. - ** The value of N can be inferred from the cursor. N includes the rowid - ** value appended to the end of the index record. This rowid value may - ** or may not be the same as R. - ** - ** If any of the N registers beginning with register P4 contains a NULL - ** value, jump immediately to P2. - ** - ** Otherwise, this instruction checks if cursor P1 contains an entry - ** where the first (N-1) fields match but the rowid value at the end - ** of the index entry is not R. If there is no such entry, control jumps - ** to instruction P2. Otherwise, the rowid of the conflicting index - ** entry is copied to register P3 and control falls through to the next - ** instruction. - ** - ** See also: NotFound, NotExists, Found - */ - case OP_IsUnique: - { /* jump, in3 */ - u16 ii; - VdbeCursor pCx = new VdbeCursor(); - BtCursor pCrsr; - u16 nField; - Mem[] aMx; - UnpackedRecord r; /* B-Tree index search key */ - i64 R; /* Rowid stored in register P3 */ - - r = new UnpackedRecord(); - - pIn3 = aMem[pOp.p3]; - //aMx = aMem[pOp->p4.i]; - /* Assert that the values of parameters P1 and P4 are in range. */ - Debug.Assert( pOp.p4type == P4_INT32 ); - Debug.Assert( pOp.p4.i > 0 && pOp.p4.i <= p.nMem ); - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); - - /* Find the index cursor. */ - pCx = p.apCsr[pOp.p1]; - Debug.Assert( !pCx.deferredMoveto ); - pCx.seekResult = 0; - pCx.cacheStatus = CACHE_STALE; - pCrsr = pCx.pCursor; - - /* If any of the values are NULL, take the jump. */ - nField = pCx.pKeyInfo.nField; - aMx = new Mem[nField + 1]; - for ( ii = 0; ii < nField; ii++ ) - { - aMx[ii] = aMem[pOp.p4.i + ii]; - if ( ( aMx[ii].flags & MEM_Null ) != 0 ) - { - pc = pOp.p2 - 1; - pCrsr = null; - break; - } - } - aMx[nField] = new Mem(); - //Debug.Assert( ( aMx[nField].flags & MEM_Null ) == 0 ); - - if ( pCrsr != null ) - { - /* Populate the index search key. */ - r.pKeyInfo = pCx.pKeyInfo; - r.nField = (ushort)( nField + 1 ); - r.flags = UNPACKED_PREFIX_SEARCH; - r.aMem = aMx; +#endif + alreadyExists = 0; + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); + Debug.Assert(pOp.p4type == P4_INT32); + pC = p.apCsr[pOp.p1]; + Debug.Assert(pC != null); + pIn3 = aMem[pOp.p3]; + if (ALWAYS(pC.pCursor != null)) { + + Debug.Assert(!pC.isTable); + if (pOp.p4.i > 0) { + r.pKeyInfo = pC.pKeyInfo; + r.nField = (u16)pOp.p4.i; + r.aMem = new Mem[r.nField]; + for (int i = 0; i < r.aMem.Length; i++) { + r.aMem[i] = aMem[pOp.p3 + i]; #if SQLITE_DEBUG - { - int i; - for ( i = 0; i < r.nField; i++ ) - Debug.Assert( memIsValid( r.aMem[i] ) ); - } + Debug.Assert(memIsValid(r.aMem[i])); #endif + } + r.flags = UNPACKED_PREFIX_MATCH; + pIdxKey = r; + } else { + Debug.Assert((pIn3.flags & MEM_Blob) != 0); + Debug.Assert((pIn3.flags & MEM_Zero) == 0); /* zeroblobs already expanded */ + pIdxKey = sqlite3VdbeRecordUnpack(pC.pKeyInfo, pIn3.n, pIn3.zBLOB, + aTempRec, 0);//sizeof( aTempRec ) ); + if (pIdxKey == null) { + goto no_mem; + } + pIdxKey.flags |= UNPACKED_PREFIX_MATCH; + } + rc = sqlite3BtreeMovetoUnpacked(pC.pCursor, pIdxKey, 0, 0, ref res); + if (pOp.p4.i == 0) { + sqlite3VdbeDeleteUnpackedRecord(pIdxKey); + } + if (rc != SQLITE_OK) { + break; + } + alreadyExists = (res == 0) ? 1 : 0; + pC.deferredMoveto = false; + pC.cacheStatus = CACHE_STALE; + } + if (pOp.opcode == OP_Found) { + if (alreadyExists != 0) + pc = pOp.p2 - 1; + } else { + if (0 == alreadyExists) + pc = pOp.p2 - 1; + } + break; + } - /* Extract the value of R from register P3. */ - sqlite3VdbeMemIntegerify( pIn3 ); - R = pIn3.u.i; - - /* Search the B-Tree index. If no conflicting record is found, jump - ** to P2. Otherwise, copy the rowid of the conflicting record to - ** register P3 and fall through to the next instruction. */ - rc = sqlite3BtreeMovetoUnpacked( pCrsr, r, 0, 0, ref pCx.seekResult ); - if ( ( r.flags & UNPACKED_PREFIX_SEARCH ) != 0 || r.rowid == R ) - { - pc = pOp.p2 - 1; - } - else - { - pIn3.u.i = r.rowid; - } - } - break; - } + /* Opcode: IsUnique P1 P2 P3 P4 * + ** + ** Cursor P1 is open on an index b-tree - that is to say, a btree which + ** no data and where the key are records generated by OP_MakeRecord with + ** the list field being the integer ROWID of the entry that the index + ** entry refers to. + ** + ** The P3 register contains an integer record number. Call this record + ** number R. Register P4 is the first in a set of N contiguous registers + ** that make up an unpacked index key that can be used with cursor P1. + ** The value of N can be inferred from the cursor. N includes the rowid + ** value appended to the end of the index record. This rowid value may + ** or may not be the same as R. + ** + ** If any of the N registers beginning with register P4 contains a NULL + ** value, jump immediately to P2. + ** + ** Otherwise, this instruction checks if cursor P1 contains an entry + ** where the first (N-1) fields match but the rowid value at the end + ** of the index entry is not R. If there is no such entry, control jumps + ** to instruction P2. Otherwise, the rowid of the conflicting index + ** entry is copied to register P3 and control falls through to the next + ** instruction. + ** + ** See also: NotFound, NotExists, Found + */ + case OP_IsUnique: { /* jump, in3 */ + u16 ii; + VdbeCursor pCx = new VdbeCursor(); + BtCursor pCrsr; + u16 nField; + Mem[] aMx; + UnpackedRecord r; /* B-Tree index search key */ + i64 R; /* Rowid stored in register P3 */ + + r = new UnpackedRecord(); + + pIn3 = aMem[pOp.p3]; + //aMx = aMem[pOp->p4.i]; + /* Assert that the values of parameters P1 and P4 are in range. */ + Debug.Assert(pOp.p4type == P4_INT32); + Debug.Assert(pOp.p4.i > 0 && pOp.p4.i <= p.nMem); + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); + + /* Find the index cursor. */ + pCx = p.apCsr[pOp.p1]; + Debug.Assert(!pCx.deferredMoveto); + pCx.seekResult = 0; + pCx.cacheStatus = CACHE_STALE; + pCrsr = pCx.pCursor; + + /* If any of the values are NULL, take the jump. */ + nField = pCx.pKeyInfo.nField; + aMx = new Mem[nField + 1]; + for (ii = 0; ii < nField; ii++) { + aMx[ii] = aMem[pOp.p4.i + ii]; + if ((aMx[ii].flags & MEM_Null) != 0) { + pc = pOp.p2 - 1; + pCrsr = null; + break; + } + } + aMx[nField] = new Mem(); + //Debug.Assert( ( aMx[nField].flags & MEM_Null ) == 0 ); + + if (pCrsr != null) { + /* Populate the index search key. */ + r.pKeyInfo = pCx.pKeyInfo; + r.nField = (ushort)(nField + 1); + r.flags = UNPACKED_PREFIX_SEARCH; + r.aMem = aMx; +#if SQLITE_DEBUG + { + int i; + for (i = 0; i < r.nField; i++) + Debug.Assert(memIsValid(r.aMem[i])); + } +#endif + /* Extract the value of R from register P3. */ + sqlite3VdbeMemIntegerify(pIn3); + R = pIn3.u.i; + + /* Search the B-Tree index. If no conflicting record is found, jump + ** to P2. Otherwise, copy the rowid of the conflicting record to + ** register P3 and fall through to the next instruction. */ + rc = sqlite3BtreeMovetoUnpacked(pCrsr, r, 0, 0, ref pCx.seekResult); + if ((r.flags & UNPACKED_PREFIX_SEARCH) != 0 || r.rowid == R) { + pc = pOp.p2 - 1; + } else { + pIn3.u.i = r.rowid; + } + } + break; + } - /* Opcode: NotExists P1 P2 P3 * * - ** - ** Use the content of register P3 as an integer key. If a record - ** with that key does not exist in table of P1, then jump to P2. - ** If the record does exist, then fall through. The cursor is left - ** pointing to the record if it exists. - ** - ** The difference between this operation and NotFound is that this - ** operation assumes the key is an integer and that P1 is a table whereas - ** NotFound assumes key is a blob constructed from MakeRecord and - ** P1 is an index. - ** - ** See also: Found, NotFound, IsUnique - */ - case OP_NotExists: - { /* jump, in3 */ - VdbeCursor pC; - BtCursor pCrsr; - int res; - i64 iKey; - - pIn3 = aMem[pOp.p3]; - Debug.Assert( ( pIn3.flags & MEM_Int ) != 0 ); - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); - pC = p.apCsr[pOp.p1]; - Debug.Assert( pC != null ); - Debug.Assert( pC.isTable ); - Debug.Assert( pC.pseudoTableReg == 0 ); - pCrsr = pC.pCursor; - if ( pCrsr != null ) - { - res = 0; - iKey = pIn3.u.i; - rc = sqlite3BtreeMovetoUnpacked( pCrsr, null, (long)iKey, 0, ref res ); - pC.lastRowid = pIn3.u.i; - pC.rowidIsValid = res == 0 ? true : false; - pC.nullRow = false; - pC.cacheStatus = CACHE_STALE; - pC.deferredMoveto = false; - if ( res != 0 ) - { - pc = pOp.p2 - 1; - Debug.Assert( !pC.rowidIsValid ); - } - pC.seekResult = res; - } - else - { - /* This happens when an attempt to open a read cursor on the - ** sqlite_master table returns SQLITE_EMPTY. - */ - pc = pOp.p2 - 1; - Debug.Assert( !pC.rowidIsValid ); - pC.seekResult = 0; - } - break; - } - /* Opcode: Sequence P1 P2 * * * - ** - ** Find the next available sequence number for cursor P1. - ** Write the sequence number into register P2. - ** The sequence number on the cursor is incremented after this - ** instruction. - */ - case OP_Sequence: - { /* out2-prerelease */ - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); - Debug.Assert( p.apCsr[pOp.p1] != null ); - pOut.u.i = (long)p.apCsr[pOp.p1].seqCount++; - break; - } + /* Opcode: NotExists P1 P2 P3 * * + ** + ** Use the content of register P3 as an integer key. If a record + ** with that key does not exist in table of P1, then jump to P2. + ** If the record does exist, then fall through. The cursor is left + ** pointing to the record if it exists. + ** + ** The difference between this operation and NotFound is that this + ** operation assumes the key is an integer and that P1 is a table whereas + ** NotFound assumes key is a blob constructed from MakeRecord and + ** P1 is an index. + ** + ** See also: Found, NotFound, IsUnique + */ + case OP_NotExists: { /* jump, in3 */ + VdbeCursor pC; + BtCursor pCrsr; + int res; + i64 iKey; + + pIn3 = aMem[pOp.p3]; + Debug.Assert((pIn3.flags & MEM_Int) != 0); + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); + pC = p.apCsr[pOp.p1]; + Debug.Assert(pC != null); + Debug.Assert(pC.isTable); + Debug.Assert(pC.pseudoTableReg == 0); + pCrsr = pC.pCursor; + if (pCrsr != null) { + res = 0; + iKey = pIn3.u.i; + rc = sqlite3BtreeMovetoUnpacked(pCrsr, null, (long)iKey, 0, ref res); + pC.lastRowid = pIn3.u.i; + pC.rowidIsValid = res == 0 ? true : false; + pC.nullRow = false; + pC.cacheStatus = CACHE_STALE; + pC.deferredMoveto = false; + if (res != 0) { + pc = pOp.p2 - 1; + Debug.Assert(!pC.rowidIsValid); + } + pC.seekResult = res; + } else { + /* This happens when an attempt to open a read cursor on the + ** sqlite_master table returns SQLITE_EMPTY. + */ + pc = pOp.p2 - 1; + Debug.Assert(!pC.rowidIsValid); + pC.seekResult = 0; + } + break; + } + + /* Opcode: Sequence P1 P2 * * * + ** + ** Find the next available sequence number for cursor P1. + ** Write the sequence number into register P2. + ** The sequence number on the cursor is incremented after this + ** instruction. + */ + case OP_Sequence: { /* out2-prerelease */ + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); + Debug.Assert(p.apCsr[pOp.p1] != null); + pOut.u.i = (long)p.apCsr[pOp.p1].seqCount++; + break; + } - /* Opcode: NewRowid P1 P2 P3 * * - ** - ** Get a new integer record number (a.k.a "rowid") used as the key to a table. - ** The record number is not previously used as a key in the database - ** table that cursor P1 points to. The new record number is written - ** written to register P2. - ** - ** If P3>0 then P3 is a register in the root frame of this VDBE that holds - ** the largest previously generated record number. No new record numbers are - ** allowed to be less than this value. When this value reaches its maximum, - ** an SQLITE_FULL error is generated. The P3 register is updated with the ' - ** generated record number. This P3 mechanism is used to help implement the - ** AUTOINCREMENT feature. - */ - case OP_NewRowid: - { /* out2-prerelease */ - i64 v; /* The new rowid */ - VdbeCursor pC; /* Cursor of table to get the new rowid */ - int res; /* Result of an sqlite3BtreeLast() */ - int cnt; /* Counter to limit the number of searches */ - Mem pMem; /* Register holding largest rowid for AUTOINCREMENT */ - VdbeFrame pFrame; /* Root frame of VDBE */ - - v = 0; - res = 0; - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); - pC = p.apCsr[pOp.p1]; - Debug.Assert( pC != null ); - if ( NEVER( pC.pCursor == null ) ) - { - /* The zero initialization above is all that is needed */ - } - else - { - /* The next rowid or record number (different terms for the same - ** thing) is obtained in a two-step algorithm. - ** - ** First we attempt to find the largest existing rowid and add one - ** to that. But if the largest existing rowid is already the maximum - ** positive integer, we have to fall through to the second - ** probabilistic algorithm - ** - ** The second algorithm is to select a rowid at random and see if - ** it already exists in the table. If it does not exist, we have - ** succeeded. If the random rowid does exist, we select a new one - ** and try again, up to 100 times. - */ - Debug.Assert( pC.isTable ); + /* Opcode: NewRowid P1 P2 P3 * * + ** + ** Get a new integer record number (a.k.a "rowid") used as the key to a table. + ** The record number is not previously used as a key in the database + ** table that cursor P1 points to. The new record number is written + ** written to register P2. + ** + ** If P3>0 then P3 is a register in the root frame of this VDBE that holds + ** the largest previously generated record number. No new record numbers are + ** allowed to be less than this value. When this value reaches its maximum, + ** an SQLITE_FULL error is generated. The P3 register is updated with the ' + ** generated record number. This P3 mechanism is used to help implement the + ** AUTOINCREMENT feature. + */ + case OP_NewRowid: { /* out2-prerelease */ + i64 v; /* The new rowid */ + VdbeCursor pC; /* Cursor of table to get the new rowid */ + int res; /* Result of an sqlite3BtreeLast() */ + int cnt; /* Counter to limit the number of searches */ + Mem pMem; /* Register holding largest rowid for AUTOINCREMENT */ + VdbeFrame pFrame; /* Root frame of VDBE */ + + v = 0; + res = 0; + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); + pC = p.apCsr[pOp.p1]; + Debug.Assert(pC != null); + if (NEVER(pC.pCursor == null)) { + /* The zero initialization above is all that is needed */ + } else { + /* The next rowid or record number (different terms for the same + ** thing) is obtained in a two-step algorithm. + ** + ** First we attempt to find the largest existing rowid and add one + ** to that. But if the largest existing rowid is already the maximum + ** positive integer, we have to fall through to the second + ** probabilistic algorithm + ** + ** The second algorithm is to select a rowid at random and see if + ** it already exists in the table. If it does not exist, we have + ** succeeded. If the random rowid does exist, we select a new one + ** and try again, up to 100 times. + */ + Debug.Assert(pC.isTable); #if SQLITE_32BIT_ROWID const int MAX_ROWID = i32.MaxValue;//# define MAX_ROWID 0x7fffffff #else - /* Some compilers complain about constants of the form 0x7fffffffffffffff. -** Others complain about 0x7ffffffffffffffffLL. The following macro seems -** to provide the constant while making all compilers happy. -*/ - const long MAX_ROWID = i64.MaxValue;// (i64)( (((u64)0x7fffffff)<<32) | (u64)0xffffffff ) + /* Some compilers complain about constants of the form 0x7fffffffffffffff. + ** Others complain about 0x7ffffffffffffffffLL. The following macro seems + ** to provide the constant while making all compilers happy. + */ + const long MAX_ROWID = i64.MaxValue;// (i64)( (((u64)0x7fffffff)<<32) | (u64)0xffffffff ) #endif - if ( !pC.useRandomRowid ) - { - v = sqlite3BtreeGetCachedRowid( pC.pCursor ); - if ( v == 0 ) - { - rc = sqlite3BtreeLast( pC.pCursor, ref res ); - if ( rc != SQLITE_OK ) - { - goto abort_due_to_error; - } - if ( res != 0 ) - { - v = 1;/* IMP: R-61914-48074 */ - } - else - { - Debug.Assert( sqlite3BtreeCursorIsValid( pC.pCursor ) ); - rc = sqlite3BtreeKeySize( pC.pCursor, ref v ); - Debug.Assert( rc == SQLITE_OK ); /* Cannot fail following BtreeLast() */ - if ( v == MAX_ROWID ) - { - pC.useRandomRowid = true; - } - else - { - v++; /* IMP: R-29538-34987 */ - } - } - } + if (!pC.useRandomRowid) { + v = sqlite3BtreeGetCachedRowid(pC.pCursor); + if (v == 0) { + rc = sqlite3BtreeLast(pC.pCursor, ref res); + if (rc != SQLITE_OK) { + goto abort_due_to_error; + } + if (res != 0) { + v = 1;/* IMP: R-61914-48074 */ + } else { + Debug.Assert(sqlite3BtreeCursorIsValid(pC.pCursor)); + rc = sqlite3BtreeKeySize(pC.pCursor, ref v); + Debug.Assert(rc == SQLITE_OK); /* Cannot fail following BtreeLast() */ + if (v == MAX_ROWID) { + pC.useRandomRowid = true; + } else { + v++; /* IMP: R-29538-34987 */ + } + } + } #if !SQLITE_OMIT_AUTOINCREMENT - if ( pOp.p3 != 0 ) - { - /* Assert that P3 is a valid memory cell. */ - Debug.Assert( pOp.p3 > 0 ); - if ( p.pFrame != null ) - { - for ( pFrame = p.pFrame; pFrame.pParent != null; pFrame = pFrame.pParent ) - ; - /* Assert that P3 is a valid memory cell. */ - Debug.Assert( pOp.p3 <= pFrame.nMem ); - pMem = pFrame.aMem[pOp.p3]; - } - else - { - /* Assert that P3 is a valid memory cell. */ - Debug.Assert( pOp.p3 <= p.nMem ); - pMem = aMem[pOp.p3]; - memAboutToChange( p, pMem ); - } - Debug.Assert( memIsValid( pMem ) ); - - REGISTER_TRACE( p, pOp.p3, pMem ); - sqlite3VdbeMemIntegerify( pMem ); - Debug.Assert( ( pMem.flags & MEM_Int ) != 0 ); /* mem(P3) holds an integer */ - if ( pMem.u.i == MAX_ROWID || pC.useRandomRowid ) - { - rc = SQLITE_FULL; /* IMP: R-12275-61338 */ - goto abort_due_to_error; - } - if ( v < ( pMem.u.i + 1 ) ) - { - v = (int)( pMem.u.i + 1 ); - } - pMem.u.i = (long)v; - } + if (pOp.p3 != 0) { + /* Assert that P3 is a valid memory cell. */ + Debug.Assert(pOp.p3 > 0); + if (p.pFrame != null) { + for (pFrame = p.pFrame; pFrame.pParent != null; pFrame = pFrame.pParent) + ; + /* Assert that P3 is a valid memory cell. */ + Debug.Assert(pOp.p3 <= pFrame.nMem); + pMem = pFrame.aMem[pOp.p3]; + } else { + /* Assert that P3 is a valid memory cell. */ + Debug.Assert(pOp.p3 <= p.nMem); + pMem = aMem[pOp.p3]; + memAboutToChange(p, pMem); + } + Debug.Assert(memIsValid(pMem)); + + REGISTER_TRACE(p, pOp.p3, pMem); + sqlite3VdbeMemIntegerify(pMem); + Debug.Assert((pMem.flags & MEM_Int) != 0); /* mem(P3) holds an integer */ + if (pMem.u.i == MAX_ROWID || pC.useRandomRowid) { + rc = SQLITE_FULL; /* IMP: R-12275-61338 */ + goto abort_due_to_error; + } + if (v < (pMem.u.i + 1)) { + v = (int)(pMem.u.i + 1); + } + pMem.u.i = (long)v; + } #endif - sqlite3BtreeSetCachedRowid( pC.pCursor, v < MAX_ROWID ? v + 1 : 0 ); - } - if ( pC.useRandomRowid ) - { - /* IMPLEMENTATION-OF: R-07677-41881 If the largest ROWID is equal to the - ** largest possible integer (9223372036854775807) then the database - ** engine starts picking positive candidate ROWIDs at random until - ** it finds one that is not previously used. */ - Debug.Assert( pOp.p3 == 0 ); /* We cannot be in random rowid mode if this is + sqlite3BtreeSetCachedRowid(pC.pCursor, v < MAX_ROWID ? v + 1 : 0); + } + if (pC.useRandomRowid) { + /* IMPLEMENTATION-OF: R-07677-41881 If the largest ROWID is equal to the + ** largest possible integer (9223372036854775807) then the database + ** engine starts picking positive candidate ROWIDs at random until + ** it finds one that is not previously used. */ + Debug.Assert(pOp.p3 == 0); /* We cannot be in random rowid mode if this is ** an AUTOINCREMENT table. */ - /* on the first attempt, simply do one more than previous */ - v = lastRowid; - v &= ( MAX_ROWID >> 1 ); /* ensure doesn't go negative */ - v++; /* ensure non-zero */ - cnt = 0; - while ( ( ( rc = sqlite3BtreeMovetoUnpacked( pC.pCursor, null, v, - 0, ref res ) ) == SQLITE_OK ) - && ( res == 0 ) - && ( ++cnt < 100 ) ) - { - /* collision - try another random rowid */ - sqlite3_randomness( sizeof( i64 ), ref v ); - if ( cnt < 5 ) - { - /* try "small" random rowids for the initial attempts */ - v &= 0xffffff; - } - else - { - v &= ( MAX_ROWID >> 1 ); /* ensure doesn't go negative */ - } - v++; /* ensure non-zero */ - } - if ( rc == SQLITE_OK && res == 0 ) - { - rc = SQLITE_FULL;/* IMP: R-38219-53002 */ - goto abort_due_to_error; - } - Debug.Assert( v > 0 ); /* EV: R-40812-03570 */ - } - pC.rowidIsValid = false; - pC.deferredMoveto = false; - pC.cacheStatus = CACHE_STALE; - } - pOut.u.i = (long)v; - break; - } + /* on the first attempt, simply do one more than previous */ + v = lastRowid; + v &= (MAX_ROWID >> 1); /* ensure doesn't go negative */ + v++; /* ensure non-zero */ + cnt = 0; + while (((rc = sqlite3BtreeMovetoUnpacked(pC.pCursor, null, v, + 0, ref res)) == SQLITE_OK) + && (res == 0) + && (++cnt < 100)) { + /* collision - try another random rowid */ + sqlite3_randomness(sizeof(i64), ref v); + if (cnt < 5) { + /* try "small" random rowids for the initial attempts */ + v &= 0xffffff; + } else { + v &= (MAX_ROWID >> 1); /* ensure doesn't go negative */ + } + v++; /* ensure non-zero */ + } + if (rc == SQLITE_OK && res == 0) { + rc = SQLITE_FULL;/* IMP: R-38219-53002 */ + goto abort_due_to_error; + } + Debug.Assert(v > 0); /* EV: R-40812-03570 */ + } + pC.rowidIsValid = false; + pC.deferredMoveto = false; + pC.cacheStatus = CACHE_STALE; + } + pOut.u.i = (long)v; + break; + } - /* Opcode: Insert P1 P2 P3 P4 P5 - ** - ** Write an entry into the table of cursor P1. A new entry is - ** created if it doesn't already exist or the data for an existing - ** entry is overwritten. The data is the value MEM_Blob stored in register - ** number P2. The key is stored in register P3. The key must - ** be a MEM_Int. - ** - ** If the OPFLAG_NCHANGE flag of P5 is set, then the row change count is - ** incremented (otherwise not). If the OPFLAG_LASTROWID flag of P5 is set, - ** then rowid is stored for subsequent return by the - ** sqlite3_last_insert_rowid() function (otherwise it is unmodified). - ** - ** If the OPFLAG_USESEEKRESULT flag of P5 is set and if the result of - ** the last seek operation (OP_NotExists) was a success, then this - ** operation will not attempt to find the appropriate row before doing - ** the insert but will instead overwrite the row that the cursor is - ** currently pointing to. Presumably, the prior OP_NotExists opcode - ** has already positioned the cursor correctly. This is an optimization - ** that boosts performance by avoiding redundant seeks. - ** - ** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an - ** UPDATE operation. Otherwise (if the flag is clear) then this opcode - ** is part of an INSERT operation. The difference is only important to - ** the update hook. - ** - ** Parameter P4 may point to a string containing the table-name, or - ** may be NULL. If it is not NULL, then the update-hook - ** (sqlite3.xUpdateCallback) is invoked following a successful insert. - ** - ** (WARNING/TODO: If P1 is a pseudo-cursor and P2 is dynamically - ** allocated, then ownership of P2 is transferred to the pseudo-cursor - ** and register P2 becomes ephemeral. If the cursor is changed, the - ** value of register P2 will then change. Make sure this does not - ** cause any problems.) - ** - ** This instruction only works on tables. The equivalent instruction - ** for indices is OP_IdxInsert. - */ - /* Opcode: InsertInt P1 P2 P3 P4 P5 - ** - ** This works exactly like OP_Insert except that the key is the - ** integer value P3, not the value of the integer stored in register P3. - */ - case OP_Insert: - case OP_InsertInt: - { - Mem pData; /* MEM cell holding data for the record to be inserted */ - Mem pKey; /* MEM cell holding key for the record */ - i64 iKey; /* The integer ROWID or key for the record to be inserted */ - VdbeCursor pC; /* Cursor to table into which insert is written */ - int nZero; /* Number of zero-bytes to append */ - int seekResult; /* Result of prior seek or 0 if no USESEEKRESULT flag */ - string zDb; /* database name - used by the update hook */ - string zTbl; /* Table name - used by the opdate hook */ - int op; /* Opcode for update hook: SQLITE_UPDATE or SQLITE_INSERT */ - - pData = aMem[pOp.p2]; - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); - Debug.Assert( memIsValid( pData ) ); - pC = p.apCsr[pOp.p1]; - Debug.Assert( pC != null ); - Debug.Assert( pC.pCursor != null ); - Debug.Assert( pC.pseudoTableReg == 0 ); - Debug.Assert( pC.isTable ); - REGISTER_TRACE( p, pOp.p2, pData ); - - if ( pOp.opcode == OP_Insert ) - { - pKey = aMem[pOp.p3]; - Debug.Assert( ( pKey.flags & MEM_Int ) != 0 ); - Debug.Assert( memIsValid( pKey ) ); - REGISTER_TRACE( p, pOp.p3, pKey ); - iKey = pKey.u.i; - } - else - { - Debug.Assert( pOp.opcode == OP_InsertInt ); - iKey = pOp.p3; - } - - if ( ( pOp.p5 & OPFLAG_NCHANGE ) != 0 ) - p.nChange++; - if ( ( pOp.p5 & OPFLAG_LASTROWID ) != 0 ) - db.lastRowid = lastRowid = iKey; - if ( ( pData.flags & MEM_Null ) != 0 ) - { - sqlite3_free( ref pData.zBLOB ); - pData.z = null; - pData.n = 0; - } - else - { - Debug.Assert( ( pData.flags & ( MEM_Blob | MEM_Str ) ) != 0 ); - } - seekResult = ( ( pOp.p5 & OPFLAG_USESEEKRESULT ) != 0 ? pC.seekResult : 0 ); - if ( ( pData.flags & MEM_Zero ) != 0 ) - { - nZero = pData.u.nZero; - } - else - { - nZero = 0; - } - rc = sqlite3BtreeInsert( pC.pCursor, null, iKey, - pData.zBLOB - , pData.n, nZero, - ( pOp.p5 & OPFLAG_APPEND ) != 0 ? 1 : 0, seekResult - ); - - pC.rowidIsValid = false; - pC.deferredMoveto = false; - pC.cacheStatus = CACHE_STALE; - - /* Invoke the update-hook if required. */ - if ( rc == SQLITE_OK && db.xUpdateCallback != null && pOp.p4.z != null ) - { - zDb = db.aDb[pC.iDb].zName; - zTbl = pOp.p4.z; - op = ( ( pOp.p5 & OPFLAG_ISUPDATE ) != 0 ? SQLITE_UPDATE : SQLITE_INSERT ); - Debug.Assert( pC.isTable ); - db.xUpdateCallback( db.pUpdateArg, op, zDb, zTbl, iKey ); - Debug.Assert( pC.iDb >= 0 ); - } - break; - } + /* Opcode: Insert P1 P2 P3 P4 P5 + ** + ** Write an entry into the table of cursor P1. A new entry is + ** created if it doesn't already exist or the data for an existing + ** entry is overwritten. The data is the value MEM_Blob stored in register + ** number P2. The key is stored in register P3. The key must + ** be a MEM_Int. + ** + ** If the OPFLAG_NCHANGE flag of P5 is set, then the row change count is + ** incremented (otherwise not). If the OPFLAG_LASTROWID flag of P5 is set, + ** then rowid is stored for subsequent return by the + ** sqlite3_last_insert_rowid() function (otherwise it is unmodified). + ** + ** If the OPFLAG_USESEEKRESULT flag of P5 is set and if the result of + ** the last seek operation (OP_NotExists) was a success, then this + ** operation will not attempt to find the appropriate row before doing + ** the insert but will instead overwrite the row that the cursor is + ** currently pointing to. Presumably, the prior OP_NotExists opcode + ** has already positioned the cursor correctly. This is an optimization + ** that boosts performance by avoiding redundant seeks. + ** + ** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an + ** UPDATE operation. Otherwise (if the flag is clear) then this opcode + ** is part of an INSERT operation. The difference is only important to + ** the update hook. + ** + ** Parameter P4 may point to a string containing the table-name, or + ** may be NULL. If it is not NULL, then the update-hook + ** (sqlite3.xUpdateCallback) is invoked following a successful insert. + ** + ** (WARNING/TODO: If P1 is a pseudo-cursor and P2 is dynamically + ** allocated, then ownership of P2 is transferred to the pseudo-cursor + ** and register P2 becomes ephemeral. If the cursor is changed, the + ** value of register P2 will then change. Make sure this does not + ** cause any problems.) + ** + ** This instruction only works on tables. The equivalent instruction + ** for indices is OP_IdxInsert. + */ + /* Opcode: InsertInt P1 P2 P3 P4 P5 + ** + ** This works exactly like OP_Insert except that the key is the + ** integer value P3, not the value of the integer stored in register P3. + */ + case OP_Insert: + case OP_InsertInt: { + Mem pData; /* MEM cell holding data for the record to be inserted */ + Mem pKey; /* MEM cell holding key for the record */ + i64 iKey; /* The integer ROWID or key for the record to be inserted */ + VdbeCursor pC; /* Cursor to table into which insert is written */ + int nZero; /* Number of zero-bytes to append */ + int seekResult; /* Result of prior seek or 0 if no USESEEKRESULT flag */ + string zDb; /* database name - used by the update hook */ + string zTbl; /* Table name - used by the opdate hook */ + int op; /* Opcode for update hook: SQLITE_UPDATE or SQLITE_INSERT */ + + pData = aMem[pOp.p2]; + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); + Debug.Assert(memIsValid(pData)); + pC = p.apCsr[pOp.p1]; + Debug.Assert(pC != null); + Debug.Assert(pC.pCursor != null); + Debug.Assert(pC.pseudoTableReg == 0); + Debug.Assert(pC.isTable); + REGISTER_TRACE(p, pOp.p2, pData); + + if (pOp.opcode == OP_Insert) { + pKey = aMem[pOp.p3]; + Debug.Assert((pKey.flags & MEM_Int) != 0); + Debug.Assert(memIsValid(pKey)); + REGISTER_TRACE(p, pOp.p3, pKey); + iKey = pKey.u.i; + } else { + Debug.Assert(pOp.opcode == OP_InsertInt); + iKey = pOp.p3; + } + + if ((pOp.p5 & OPFLAG_NCHANGE) != 0) + p.nChange++; + if ((pOp.p5 & OPFLAG_LASTROWID) != 0) + db.lastRowid = lastRowid = iKey; + if ((pData.flags & MEM_Null) != 0) { + sqlite3_free(ref pData.zBLOB); + pData.z = null; + pData.n = 0; + } else { + Debug.Assert((pData.flags & (MEM_Blob | MEM_Str)) != 0); + } + seekResult = ((pOp.p5 & OPFLAG_USESEEKRESULT) != 0 ? pC.seekResult : 0); + if ((pData.flags & MEM_Zero) != 0) { + nZero = pData.u.nZero; + } else { + nZero = 0; + } + rc = sqlite3BtreeInsert(pC.pCursor, null, iKey, + pData.zBLOB + , pData.n, nZero, + (pOp.p5 & OPFLAG_APPEND) != 0 ? 1 : 0, seekResult + ); + + pC.rowidIsValid = false; + pC.deferredMoveto = false; + pC.cacheStatus = CACHE_STALE; + + /* Invoke the update-hook if required. */ + if (rc == SQLITE_OK && db.xUpdateCallback != null && pOp.p4.z != null) { + zDb = db.aDb[pC.iDb].zName; + zTbl = pOp.p4.z; + op = ((pOp.p5 & OPFLAG_ISUPDATE) != 0 ? SQLITE_UPDATE : SQLITE_INSERT); + Debug.Assert(pC.isTable); + db.xUpdateCallback(db.pUpdateArg, op, zDb, zTbl, iKey); + Debug.Assert(pC.iDb >= 0); + } + break; + } - /* Opcode: Delete P1 P2 * P4 * - ** - ** Delete the record at which the P1 cursor is currently pointing. - ** - ** The cursor will be left pointing at either the next or the previous - ** record in the table. If it is left pointing at the next record, then - ** the next Next instruction will be a no-op. Hence it is OK to delete - ** a record from within an Next loop. - ** - ** If the OPFLAG_NCHANGE flag of P2 is set, then the row change count is - ** incremented (otherwise not). - ** - ** P1 must not be pseudo-table. It has to be a real table with - ** multiple rows. - ** - ** If P4 is not NULL, then it is the name of the table that P1 is - ** pointing to. The update hook will be invoked, if it exists. - ** If P4 is not NULL then the P1 cursor must have been positioned - ** using OP_NotFound prior to invoking this opcode. - */ - case OP_Delete: - { - i64 iKey; - VdbeCursor pC; - - iKey = 0; - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); - pC = p.apCsr[pOp.p1]; - Debug.Assert( pC != null ); - Debug.Assert( pC.pCursor != null ); /* Only valid for real tables, no pseudotables */ - - /* If the update-hook will be invoked, set iKey to the rowid of the - ** row being deleted. - */ - if ( db.xUpdateCallback != null && pOp.p4.z != null ) - { - Debug.Assert( pC.isTable ); - Debug.Assert( pC.rowidIsValid ); /* lastRowid set by previous OP_NotFound */ - iKey = pC.lastRowid; - } - - /* The OP_Delete opcode always follows an OP_NotExists or OP_Last or - ** OP_Column on the same table without any intervening operations that - ** might move or invalidate the cursor. Hence cursor pC is always pointing - ** to the row to be deleted and the sqlite3VdbeCursorMoveto() operation - ** below is always a no-op and cannot fail. We will run it anyhow, though, - ** to guard against future changes to the code generator. - **/ - Debug.Assert( pC.deferredMoveto == false ); - rc = sqlite3VdbeCursorMoveto( pC ); - if ( NEVER( rc != SQLITE_OK ) ) - goto abort_due_to_error; - sqlite3BtreeSetCachedRowid( pC.pCursor, 0 ); - rc = sqlite3BtreeDelete( pC.pCursor ); - pC.cacheStatus = CACHE_STALE; - - /* Invoke the update-hook if required. */ - if ( rc == SQLITE_OK && db.xUpdateCallback != null && pOp.p4.z != null ) - { - string zDb = db.aDb[pC.iDb].zName; - string zTbl = pOp.p4.z; - db.xUpdateCallback( db.pUpdateArg, SQLITE_DELETE, zDb, zTbl, iKey ); - Debug.Assert( pC.iDb >= 0 ); - } - if ( ( pOp.p2 & OPFLAG_NCHANGE ) != 0 ) - p.nChange++; - break; - } + /* Opcode: Delete P1 P2 * P4 * + ** + ** Delete the record at which the P1 cursor is currently pointing. + ** + ** The cursor will be left pointing at either the next or the previous + ** record in the table. If it is left pointing at the next record, then + ** the next Next instruction will be a no-op. Hence it is OK to delete + ** a record from within an Next loop. + ** + ** If the OPFLAG_NCHANGE flag of P2 is set, then the row change count is + ** incremented (otherwise not). + ** + ** P1 must not be pseudo-table. It has to be a real table with + ** multiple rows. + ** + ** If P4 is not NULL, then it is the name of the table that P1 is + ** pointing to. The update hook will be invoked, if it exists. + ** If P4 is not NULL then the P1 cursor must have been positioned + ** using OP_NotFound prior to invoking this opcode. + */ + case OP_Delete: { + i64 iKey; + VdbeCursor pC; + + iKey = 0; + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); + pC = p.apCsr[pOp.p1]; + Debug.Assert(pC != null); + Debug.Assert(pC.pCursor != null); /* Only valid for real tables, no pseudotables */ + + /* If the update-hook will be invoked, set iKey to the rowid of the + ** row being deleted. + */ + if (db.xUpdateCallback != null && pOp.p4.z != null) { + Debug.Assert(pC.isTable); + Debug.Assert(pC.rowidIsValid); /* lastRowid set by previous OP_NotFound */ + iKey = pC.lastRowid; + } + + /* The OP_Delete opcode always follows an OP_NotExists or OP_Last or + ** OP_Column on the same table without any intervening operations that + ** might move or invalidate the cursor. Hence cursor pC is always pointing + ** to the row to be deleted and the sqlite3VdbeCursorMoveto() operation + ** below is always a no-op and cannot fail. We will run it anyhow, though, + ** to guard against future changes to the code generator. + **/ + Debug.Assert(pC.deferredMoveto == false); + rc = sqlite3VdbeCursorMoveto(pC); + if (NEVER(rc != SQLITE_OK)) + goto abort_due_to_error; + sqlite3BtreeSetCachedRowid(pC.pCursor, 0); + rc = sqlite3BtreeDelete(pC.pCursor); + pC.cacheStatus = CACHE_STALE; + + /* Invoke the update-hook if required. */ + if (rc == SQLITE_OK && db.xUpdateCallback != null && pOp.p4.z != null) { + string zDb = db.aDb[pC.iDb].zName; + string zTbl = pOp.p4.z; + db.xUpdateCallback(db.pUpdateArg, SQLITE_DELETE, zDb, zTbl, iKey); + Debug.Assert(pC.iDb >= 0); + } + if ((pOp.p2 & OPFLAG_NCHANGE) != 0) + p.nChange++; + break; + } - /* Opcode: ResetCount P1 * * - ** - ** The value of the change counter is copied to the database handle - ** change counter (returned by subsequent calls to sqlite3_changes()). - ** Then the VMs internal change counter resets to 0. - ** This is used by trigger programs. - */ - case OP_ResetCount: - { - sqlite3VdbeSetChanges( db, p.nChange ); - p.nChange = 0; - break; - } + /* Opcode: ResetCount P1 * * + ** + ** The value of the change counter is copied to the database handle + ** change counter (returned by subsequent calls to sqlite3_changes()). + ** Then the VMs internal change counter resets to 0. + ** This is used by trigger programs. + */ + case OP_ResetCount: { + sqlite3VdbeSetChanges(db, p.nChange); + p.nChange = 0; + break; + } - /* Opcode: RowData P1 P2 * * * - ** - ** Write into register P2 the complete row data for cursor P1. - ** There is no interpretation of the data. - ** It is just copied onto the P2 register exactly as - ** it is found in the database file. - ** - ** If the P1 cursor must be pointing to a valid row (not a NULL row) - ** of a real table, not a pseudo-table. - */ - /* Opcode: RowKey P1 P2 * * * - ** - ** Write into register P2 the complete row key for cursor P1. - ** There is no interpretation of the data. - ** The key is copied onto the P3 register exactly as - ** it is found in the database file. - ** - ** If the P1 cursor must be pointing to a valid row (not a NULL row) - ** of a real table, not a pseudo-table. - */ - case OP_RowKey: - case OP_RowData: - { - VdbeCursor pC; - BtCursor pCrsr; - u32 n; - i64 n64; - - n = 0; - n64 = 0; - - pOut = aMem[pOp.p2]; - memAboutToChange( p, pOut ); - - /* Note that RowKey and RowData are really exactly the same instruction */ - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); - pC = p.apCsr[pOp.p1]; - Debug.Assert( pC.isTable || pOp.opcode == OP_RowKey ); - Debug.Assert( pC.isIndex || pOp.opcode == OP_RowData ); - Debug.Assert( pC != null ); - Debug.Assert( pC.nullRow == false ); - Debug.Assert( pC.pseudoTableReg == 0 ); - Debug.Assert( pC.pCursor != null ); - pCrsr = pC.pCursor; - Debug.Assert( sqlite3BtreeCursorIsValid( pCrsr ) ); - - /* The OP_RowKey and OP_RowData opcodes always follow OP_NotExists or - ** OP_Rewind/Op_Next with no intervening instructions that might invalidate - ** the cursor. Hence the following sqlite3VdbeCursorMoveto() call is always - ** a no-op and can never fail. But we leave it in place as a safety. - */ - Debug.Assert( pC.deferredMoveto == false ); - rc = sqlite3VdbeCursorMoveto( pC ); - if ( NEVER( rc != SQLITE_OK ) ) - goto abort_due_to_error; - if ( pC.isIndex ) - { - Debug.Assert( !pC.isTable ); - rc = sqlite3BtreeKeySize( pCrsr, ref n64 ); - Debug.Assert( rc == SQLITE_OK ); /* True because of CursorMoveto() call above */ - if ( n64 > db.aLimit[SQLITE_LIMIT_LENGTH] ) - { - goto too_big; - } - n = (u32)n64; - } - else - { - rc = sqlite3BtreeDataSize( pCrsr, ref n ); - Debug.Assert( rc == SQLITE_OK ); /* DataSize() cannot fail */ - if ( n > (u32)db.aLimit[SQLITE_LIMIT_LENGTH] ) - { - goto too_big; - } - if ( sqlite3VdbeMemGrow( pOut, (int)n, 0 ) != 0 ) - { - goto no_mem; - } - } - pOut.n = (int)n; - if ( pC.isIndex ) - { - pOut.zBLOB = sqlite3Malloc( (int)n ); - rc = sqlite3BtreeKey( pCrsr, 0, n, pOut.zBLOB ); - } - else - { - pOut.zBLOB = sqlite3Malloc( (int)pCrsr.info.nData ); - rc = sqlite3BtreeData( pCrsr, 0, (u32)n, pOut.zBLOB ); - } - MemSetTypeFlag( pOut, MEM_Blob ); - pOut.enc = SQLITE_UTF8; /* In case the blob is ever cast to text */ + /* Opcode: RowData P1 P2 * * * + ** + ** Write into register P2 the complete row data for cursor P1. + ** There is no interpretation of the data. + ** It is just copied onto the P2 register exactly as + ** it is found in the database file. + ** + ** If the P1 cursor must be pointing to a valid row (not a NULL row) + ** of a real table, not a pseudo-table. + */ + /* Opcode: RowKey P1 P2 * * * + ** + ** Write into register P2 the complete row key for cursor P1. + ** There is no interpretation of the data. + ** The key is copied onto the P3 register exactly as + ** it is found in the database file. + ** + ** If the P1 cursor must be pointing to a valid row (not a NULL row) + ** of a real table, not a pseudo-table. + */ + case OP_RowKey: + case OP_RowData: { + VdbeCursor pC; + BtCursor pCrsr; + u32 n; + i64 n64; + + n = 0; + n64 = 0; + + pOut = aMem[pOp.p2]; + memAboutToChange(p, pOut); + + /* Note that RowKey and RowData are really exactly the same instruction */ + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); + pC = p.apCsr[pOp.p1]; + Debug.Assert(pC.isTable || pOp.opcode == OP_RowKey); + Debug.Assert(pC.isIndex || pOp.opcode == OP_RowData); + Debug.Assert(pC != null); + Debug.Assert(pC.nullRow == false); + Debug.Assert(pC.pseudoTableReg == 0); + Debug.Assert(pC.pCursor != null); + pCrsr = pC.pCursor; + Debug.Assert(sqlite3BtreeCursorIsValid(pCrsr)); + + /* The OP_RowKey and OP_RowData opcodes always follow OP_NotExists or + ** OP_Rewind/Op_Next with no intervening instructions that might invalidate + ** the cursor. Hence the following sqlite3VdbeCursorMoveto() call is always + ** a no-op and can never fail. But we leave it in place as a safety. + */ + Debug.Assert(pC.deferredMoveto == false); + rc = sqlite3VdbeCursorMoveto(pC); + if (NEVER(rc != SQLITE_OK)) + goto abort_due_to_error; + if (pC.isIndex) { + Debug.Assert(!pC.isTable); + rc = sqlite3BtreeKeySize(pCrsr, ref n64); + Debug.Assert(rc == SQLITE_OK); /* True because of CursorMoveto() call above */ + if (n64 > db.aLimit[SQLITE_LIMIT_LENGTH]) { + goto too_big; + } + n = (u32)n64; + } else { + rc = sqlite3BtreeDataSize(pCrsr, ref n); + Debug.Assert(rc == SQLITE_OK); /* DataSize() cannot fail */ + if (n > (u32)db.aLimit[SQLITE_LIMIT_LENGTH]) { + goto too_big; + } + if (sqlite3VdbeMemGrow(pOut, (int)n, 0) != 0) { + goto no_mem; + } + } + pOut.n = (int)n; + if (pC.isIndex) { + pOut.zBLOB = sqlite3Malloc((int)n); + rc = sqlite3BtreeKey(pCrsr, 0, n, pOut.zBLOB); + } else { + pOut.zBLOB = sqlite3Malloc((int)pCrsr.info.nData); + rc = sqlite3BtreeData(pCrsr, 0, (u32)n, pOut.zBLOB); + } + MemSetTypeFlag(pOut, MEM_Blob); + pOut.enc = SQLITE_UTF8; /* In case the blob is ever cast to text */ #if SQLITE_TEST UPDATE_MAX_BLOBSIZE( pOut ); #endif - break; - } + break; + } - /* Opcode: Rowid P1 P2 * * * - ** - ** Store in register P2 an integer which is the key of the table entry that - ** P1 is currently point to. - ** - ** P1 can be either an ordinary table or a virtual table. There used to - ** be a separate OP_VRowid opcode for use with virtual tables, but this - ** one opcode now works for both table types. - */ - case OP_Rowid: - { /* out2-prerelease */ - VdbeCursor pC; - i64 v; - sqlite3_vtab pVtab; - sqlite3_module pModule; - - v = 0; - - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); - pC = p.apCsr[pOp.p1]; - Debug.Assert( pC != null ); - Debug.Assert( pC.pseudoTableReg == 0 ); - if ( pC.nullRow ) - { - pOut.flags = MEM_Null; - break; - } - else if ( pC.deferredMoveto ) - { - v = pC.movetoTarget; + /* Opcode: Rowid P1 P2 * * * + ** + ** Store in register P2 an integer which is the key of the table entry that + ** P1 is currently point to. + ** + ** P1 can be either an ordinary table or a virtual table. There used to + ** be a separate OP_VRowid opcode for use with virtual tables, but this + ** one opcode now works for both table types. + */ + case OP_Rowid: { /* out2-prerelease */ + VdbeCursor pC; + i64 v; + sqlite3_vtab pVtab; + sqlite3_module pModule; + + v = 0; + + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); + pC = p.apCsr[pOp.p1]; + Debug.Assert(pC != null); + Debug.Assert(pC.pseudoTableReg == 0); + if (pC.nullRow) { + pOut.flags = MEM_Null; + break; + } else if (pC.deferredMoveto) { + v = pC.movetoTarget; #if !SQLITE_OMIT_VIRTUALTABLE - } - else if ( pC.pVtabCursor!=null ) - { - pVtab = pC.pVtabCursor.pVtab; - pModule = pVtab.pModule; - Debug.Assert( pModule.xRowid != null ); - rc = pModule.xRowid( pC.pVtabCursor, out v ); - importVtabErrMsg( p, pVtab ); + } else if (pC.pVtabCursor != null) { + pVtab = pC.pVtabCursor.pVtab; + pModule = pVtab.pModule; + Debug.Assert(pModule.xRowid != null); + rc = pModule.xRowid(pC.pVtabCursor, out v); + importVtabErrMsg(p, pVtab); #endif //* SQLITE_OMIT_VIRTUALTABLE */ - } - else - { - Debug.Assert( pC.pCursor != null ); - rc = sqlite3VdbeCursorMoveto( pC ); - if ( rc != 0 ) - goto abort_due_to_error; - if ( pC.rowidIsValid ) - { - v = pC.lastRowid; - } - else - { - rc = sqlite3BtreeKeySize( pC.pCursor, ref v ); - Debug.Assert( rc == SQLITE_OK ); /* Always so because of CursorMoveto() above */ - } - } - pOut.u.i = (long)v; - break; - } + } else { + Debug.Assert(pC.pCursor != null); + rc = sqlite3VdbeCursorMoveto(pC); + if (rc != 0) + goto abort_due_to_error; + if (pC.rowidIsValid) { + v = pC.lastRowid; + } else { + rc = sqlite3BtreeKeySize(pC.pCursor, ref v); + Debug.Assert(rc == SQLITE_OK); /* Always so because of CursorMoveto() above */ + } + } + pOut.u.i = (long)v; + break; + } - /* Opcode: NullRow P1 * * * * - ** - ** Move the cursor P1 to a null row. Any OP_Column operations - ** that occur while the cursor is on the null row will always - ** write a NULL. - */ - case OP_NullRow: - { - VdbeCursor pC; - - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); - pC = p.apCsr[pOp.p1]; - Debug.Assert( pC != null ); - pC.nullRow = true; - pC.rowidIsValid = false; - if ( pC.pCursor != null ) - { - sqlite3BtreeClearCursor( pC.pCursor ); - } - break; - } + /* Opcode: NullRow P1 * * * * + ** + ** Move the cursor P1 to a null row. Any OP_Column operations + ** that occur while the cursor is on the null row will always + ** write a NULL. + */ + case OP_NullRow: { + VdbeCursor pC; + + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); + pC = p.apCsr[pOp.p1]; + Debug.Assert(pC != null); + pC.nullRow = true; + pC.rowidIsValid = false; + if (pC.pCursor != null) { + sqlite3BtreeClearCursor(pC.pCursor); + } + break; + } - /* Opcode: Last P1 P2 * * * - ** - ** The next use of the Rowid or Column or Next instruction for P1 - ** will refer to the last entry in the database table or index. - ** If the table or index is empty and P2>0, then jump immediately to P2. - ** If P2 is 0 or if the table or index is not empty, fall through - ** to the following instruction. - */ - case OP_Last: - { /* jump */ - VdbeCursor pC; - BtCursor pCrsr; - int res = 0; - - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); - pC = p.apCsr[pOp.p1]; - Debug.Assert( pC != null ); - pCrsr = pC.pCursor; - if ( pCrsr == null ) - { - res = 1; - } - else - { - rc = sqlite3BtreeLast( pCrsr, ref res ); - } - pC.nullRow = res == 1 ? true : false; - pC.deferredMoveto = false; - pC.rowidIsValid = false; - pC.cacheStatus = CACHE_STALE; - if ( pOp.p2 > 0 && res != 0 ) - { - pc = pOp.p2 - 1; - } - break; - } + /* Opcode: Last P1 P2 * * * + ** + ** The next use of the Rowid or Column or Next instruction for P1 + ** will refer to the last entry in the database table or index. + ** If the table or index is empty and P2>0, then jump immediately to P2. + ** If P2 is 0 or if the table or index is not empty, fall through + ** to the following instruction. + */ + case OP_Last: { /* jump */ + VdbeCursor pC; + BtCursor pCrsr; + int res = 0; + + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); + pC = p.apCsr[pOp.p1]; + Debug.Assert(pC != null); + pCrsr = pC.pCursor; + if (pCrsr == null) { + res = 1; + } else { + rc = sqlite3BtreeLast(pCrsr, ref res); + } + pC.nullRow = res == 1 ? true : false; + pC.deferredMoveto = false; + pC.rowidIsValid = false; + pC.cacheStatus = CACHE_STALE; + if (pOp.p2 > 0 && res != 0) { + pc = pOp.p2 - 1; + } + break; + } - /* Opcode: Sort P1 P2 * * * - ** - ** This opcode does exactly the same thing as OP_Rewind except that - ** it increments an undocumented global variable used for testing. - ** - ** Sorting is accomplished by writing records into a sorting index, - ** then rewinding that index and playing it back from beginning to - ** end. We use the OP_Sort opcode instead of OP_Rewind to do the - ** rewinding so that the global variable will be incremented and - ** regression tests can determine whether or not the optimizer is - ** correctly optimizing out sorts. - */ - case OP_Sort: - { /* jump */ + /* Opcode: Sort P1 P2 * * * + ** + ** This opcode does exactly the same thing as OP_Rewind except that + ** it increments an undocumented global variable used for testing. + ** + ** Sorting is accomplished by writing records into a sorting index, + ** then rewinding that index and playing it back from beginning to + ** end. We use the OP_Sort opcode instead of OP_Rewind to do the + ** rewinding so that the global variable will be incremented and + ** regression tests can determine whether or not the optimizer is + ** correctly optimizing out sorts. + */ + case OP_Sort: { /* jump */ #if SQLITE_TEST #if !TCLSH sqlite3_sort_count++; @@ -5089,102 +4554,95 @@ Vdbe p /* The VDBE */ sqlite3_search_count.iValue--; #endif #endif - p.aCounter[SQLITE_STMTSTATUS_SORT - 1]++; - /* Fall through into OP_Rewind */ - goto case OP_Rewind; - } - /* Opcode: Rewind P1 P2 * * * - ** - ** The next use of the Rowid or Column or Next instruction for P1 - ** will refer to the first entry in the database table or index. - ** If the table or index is empty and P2>0, then jump immediately to P2. - ** If P2 is 0 or if the table or index is not empty, fall through - ** to the following instruction. - */ - case OP_Rewind: - { /* jump */ - VdbeCursor pC; - BtCursor pCrsr; - int res = 0; - - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); - pC = p.apCsr[pOp.p1]; - Debug.Assert( pC != null ); - res = 1; - if ( ( pCrsr = pC.pCursor ) != null ) - { - rc = sqlite3BtreeFirst( pCrsr, ref res ); - pC.atFirst = res == 0 ? true : false; - pC.deferredMoveto = false; - pC.cacheStatus = CACHE_STALE; - pC.rowidIsValid = false; - } - pC.nullRow = res == 1 ? true : false; - Debug.Assert( pOp.p2 > 0 && pOp.p2 < p.nOp ); - if ( res != 0 ) - { - pc = pOp.p2 - 1; - } - break; - } + p.aCounter[SQLITE_STMTSTATUS_SORT - 1]++; + /* Fall through into OP_Rewind */ + goto case OP_Rewind; + } + /* Opcode: Rewind P1 P2 * * * + ** + ** The next use of the Rowid or Column or Next instruction for P1 + ** will refer to the first entry in the database table or index. + ** If the table or index is empty and P2>0, then jump immediately to P2. + ** If P2 is 0 or if the table or index is not empty, fall through + ** to the following instruction. + */ + case OP_Rewind: { /* jump */ + VdbeCursor pC; + BtCursor pCrsr; + int res = 0; + + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); + pC = p.apCsr[pOp.p1]; + Debug.Assert(pC != null); + res = 1; + if ((pCrsr = pC.pCursor) != null) { + rc = sqlite3BtreeFirst(pCrsr, ref res); + pC.atFirst = res == 0 ? true : false; + pC.deferredMoveto = false; + pC.cacheStatus = CACHE_STALE; + pC.rowidIsValid = false; + } + pC.nullRow = res == 1 ? true : false; + Debug.Assert(pOp.p2 > 0 && pOp.p2 < p.nOp); + if (res != 0) { + pc = pOp.p2 - 1; + } + break; + } - /* Opcode: Next P1 P2 * * P5 - ** - ** Advance cursor P1 so that it points to the next key/data pair in its - ** table or index. If there are no more key/value pairs then fall through - ** to the following instruction. But if the cursor advance was successful, - ** jump immediately to P2. - ** - ** The P1 cursor must be for a real table, not a pseudo-table. - ** - ** See also: Prev - */ - /* Opcode: Prev P1 P2 * * * - ** - ** Back up cursor P1 so that it points to the previous key/data pair in its - ** table or index. If there is no previous key/value pairs then fall through - ** to the following instruction. But if the cursor backup was successful, - ** jump immediately to P2. - ** - ** The P1 cursor must be for a real table, not a pseudo-table. - ** - ** If P5 is positive and the jump is taken, then event counter - ** number P5-1 in the prepared statement is incremented. - ** - */ - case OP_Prev: /* jump */ - case OP_Next: - { /* jump */ - VdbeCursor pC; - BtCursor pCrsr; - int res; - - if ( db.u1.isInterrupted ) - goto abort_due_to_interrupt; //CHECK_FOR_INTERRUPT; - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); - Debug.Assert( pOp.p5 <= ArraySize( p.aCounter ) ); - pC = p.apCsr[pOp.p1]; - if ( pC == null ) - { - break; /* See ticket #2273 */ - } - pCrsr = pC.pCursor; - if ( pCrsr == null ) - { - pC.nullRow = true; - break; - } - res = 1; - Debug.Assert( !pC.deferredMoveto ); - rc = pOp.opcode == OP_Next ? sqlite3BtreeNext( pCrsr, ref res ) : - sqlite3BtreePrevious( pCrsr, ref res ); - pC.nullRow = res == 1 ? true : false; - pC.cacheStatus = CACHE_STALE; - if ( res == 0 ) - { - pc = pOp.p2 - 1; - if ( pOp.p5 != 0 ) - p.aCounter[pOp.p5 - 1]++; + /* Opcode: Next P1 P2 * * P5 + ** + ** Advance cursor P1 so that it points to the next key/data pair in its + ** table or index. If there are no more key/value pairs then fall through + ** to the following instruction. But if the cursor advance was successful, + ** jump immediately to P2. + ** + ** The P1 cursor must be for a real table, not a pseudo-table. + ** + ** See also: Prev + */ + /* Opcode: Prev P1 P2 * * * + ** + ** Back up cursor P1 so that it points to the previous key/data pair in its + ** table or index. If there is no previous key/value pairs then fall through + ** to the following instruction. But if the cursor backup was successful, + ** jump immediately to P2. + ** + ** The P1 cursor must be for a real table, not a pseudo-table. + ** + ** If P5 is positive and the jump is taken, then event counter + ** number P5-1 in the prepared statement is incremented. + ** + */ + case OP_Prev: /* jump */ + case OP_Next: { /* jump */ + VdbeCursor pC; + BtCursor pCrsr; + int res; + + if (db.u1.isInterrupted) + goto abort_due_to_interrupt; //CHECK_FOR_INTERRUPT; + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); + Debug.Assert(pOp.p5 <= ArraySize(p.aCounter)); + pC = p.apCsr[pOp.p1]; + if (pC == null) { + break; /* See ticket #2273 */ + } + pCrsr = pC.pCursor; + if (pCrsr == null) { + pC.nullRow = true; + break; + } + res = 1; + Debug.Assert(!pC.deferredMoveto); + rc = pOp.opcode == OP_Next ? sqlite3BtreeNext(pCrsr, ref res) : + sqlite3BtreePrevious(pCrsr, ref res); + pC.nullRow = res == 1 ? true : false; + pC.cacheStatus = CACHE_STALE; + if (res == 0) { + pc = pOp.p2 - 1; + if (pOp.p5 != 0) + p.aCounter[pOp.p5 - 1]++; #if SQLITE_TEST #if !TCLSH sqlite3_search_count++; @@ -5192,1074 +4650,979 @@ Vdbe p /* The VDBE */ sqlite3_search_count.iValue++; #endif #endif - } - pC.rowidIsValid = false; - break; - } + } + pC.rowidIsValid = false; + break; + } - /* Opcode: IdxInsert P1 P2 P3 * P5 - ** - ** Register P2 holds an SQL index key made using the - ** MakeRecord instructions. This opcode writes that key - ** into the index P1. Data for the entry is nil. - ** - ** P3 is a flag that provides a hint to the b-tree layer that this - ** insert is likely to be an append. - ** - ** This instruction only works for indices. The equivalent instruction - ** for tables is OP_Insert. - */ - case OP_IdxInsert: - { /* in2 */ - VdbeCursor pC; - BtCursor pCrsr; - int nKey; - byte[] zKey; - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); - pC = p.apCsr[pOp.p1]; - Debug.Assert( pC != null ); - pIn2 = aMem[pOp.p2]; - Debug.Assert( ( pIn2.flags & MEM_Blob ) != 0 ); - pCrsr = pC.pCursor; - if ( ALWAYS( pCrsr != null ) ) - { - Debug.Assert( !pC.isTable ); - ExpandBlob( pIn2 ); - if ( rc == SQLITE_OK ) - { - nKey = pIn2.n; - zKey = ( pIn2.flags & MEM_Blob ) != 0 ? pIn2.zBLOB : Encoding.UTF8.GetBytes( pIn2.z ); - rc = sqlite3BtreeInsert( pCrsr, zKey, nKey, null, 0, 0, ( pOp.p3 != 0 ) ? 1 : 0, - ( ( pOp.p5 & OPFLAG_USESEEKRESULT ) != 0 ? pC.seekResult : 0 ) - ); - Debug.Assert( !pC.deferredMoveto ); - pC.cacheStatus = CACHE_STALE; - } - } - break; - } + /* Opcode: IdxInsert P1 P2 P3 * P5 + ** + ** Register P2 holds an SQL index key made using the + ** MakeRecord instructions. This opcode writes that key + ** into the index P1. Data for the entry is nil. + ** + ** P3 is a flag that provides a hint to the b-tree layer that this + ** insert is likely to be an append. + ** + ** This instruction only works for indices. The equivalent instruction + ** for tables is OP_Insert. + */ + case OP_IdxInsert: { /* in2 */ + VdbeCursor pC; + BtCursor pCrsr; + int nKey; + byte[] zKey; + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); + pC = p.apCsr[pOp.p1]; + Debug.Assert(pC != null); + pIn2 = aMem[pOp.p2]; + Debug.Assert((pIn2.flags & MEM_Blob) != 0); + pCrsr = pC.pCursor; + if (ALWAYS(pCrsr != null)) { + Debug.Assert(!pC.isTable); + ExpandBlob(pIn2); + if (rc == SQLITE_OK) { + nKey = pIn2.n; + zKey = (pIn2.flags & MEM_Blob) != 0 ? pIn2.zBLOB : Encoding.UTF8.GetBytes(pIn2.z); + rc = sqlite3BtreeInsert(pCrsr, zKey, nKey, null, 0, 0, (pOp.p3 != 0) ? 1 : 0, + ((pOp.p5 & OPFLAG_USESEEKRESULT) != 0 ? pC.seekResult : 0) + ); + Debug.Assert(!pC.deferredMoveto); + pC.cacheStatus = CACHE_STALE; + } + } + break; + } - /* Opcode: IdxDelete P1 P2 P3 * * - ** - ** The content of P3 registers starting at register P2 form - ** an unpacked index key. This opcode removes that entry from the - ** index opened by cursor P1. - */ - case OP_IdxDelete: - { - VdbeCursor pC; - BtCursor pCrsr; - int res; - UnpackedRecord r; - - res = 0; - r = new UnpackedRecord(); - - Debug.Assert( pOp.p3 > 0 ); - Debug.Assert( pOp.p2 > 0 && pOp.p2 + pOp.p3 <= p.nMem + 1 ); - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); - pC = p.apCsr[pOp.p1]; - Debug.Assert( pC != null ); - pCrsr = pC.pCursor; - if ( ALWAYS( pCrsr != null ) ) - { - r.pKeyInfo = pC.pKeyInfo; - r.nField = (u16)pOp.p3; - r.flags = 0; - r.aMem = new Mem[r.nField]; - for ( int ra = 0; ra < r.nField; ra++ ) - { - r.aMem[ra] = aMem[pOp.p2 + ra]; + /* Opcode: IdxDelete P1 P2 P3 * * + ** + ** The content of P3 registers starting at register P2 form + ** an unpacked index key. This opcode removes that entry from the + ** index opened by cursor P1. + */ + case OP_IdxDelete: { + VdbeCursor pC; + BtCursor pCrsr; + int res; + UnpackedRecord r; + + res = 0; + r = new UnpackedRecord(); + + Debug.Assert(pOp.p3 > 0); + Debug.Assert(pOp.p2 > 0 && pOp.p2 + pOp.p3 <= p.nMem + 1); + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); + pC = p.apCsr[pOp.p1]; + Debug.Assert(pC != null); + pCrsr = pC.pCursor; + if (ALWAYS(pCrsr != null)) { + r.pKeyInfo = pC.pKeyInfo; + r.nField = (u16)pOp.p3; + r.flags = 0; + r.aMem = new Mem[r.nField]; + for (int ra = 0; ra < r.nField; ra++) { + r.aMem[ra] = aMem[pOp.p2 + ra]; #if SQLITE_DEBUG - Debug.Assert( memIsValid( r.aMem[ra] ) ); + Debug.Assert(memIsValid(r.aMem[ra])); #endif - } - rc = sqlite3BtreeMovetoUnpacked( pCrsr, r, 0, 0, ref res ); - if ( rc == SQLITE_OK && res == 0 ) - { - rc = sqlite3BtreeDelete( pCrsr ); - } - Debug.Assert( !pC.deferredMoveto ); - pC.cacheStatus = CACHE_STALE; - } - break; - } + } + rc = sqlite3BtreeMovetoUnpacked(pCrsr, r, 0, 0, ref res); + if (rc == SQLITE_OK && res == 0) { + rc = sqlite3BtreeDelete(pCrsr); + } + Debug.Assert(!pC.deferredMoveto); + pC.cacheStatus = CACHE_STALE; + } + break; + } - /* Opcode: IdxRowid P1 P2 * * * - ** - ** Write into register P2 an integer which is the last entry in the record at - ** the end of the index key pointed to by cursor P1. This integer should be - ** the rowid of the table entry to which this index entry points. - ** - ** See also: Rowid, MakeRecord. - */ - case OP_IdxRowid: - { /* out2-prerelease */ - BtCursor pCrsr; - VdbeCursor pC; - i64 rowid; - - rowid = 0; - - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); - pC = p.apCsr[pOp.p1]; - Debug.Assert( pC != null ); - pCrsr = pC.pCursor; - pOut.flags = MEM_Null; - if ( ALWAYS( pCrsr != null ) ) - { - rc = sqlite3VdbeCursorMoveto( pC ); - if ( NEVER( rc != 0 ) ) - goto abort_due_to_error; - Debug.Assert( !pC.deferredMoveto ); - Debug.Assert( !pC.isTable ); - if ( !pC.nullRow ) - { - rc = sqlite3VdbeIdxRowid( db, pCrsr, ref rowid ); - if ( rc != SQLITE_OK ) - { - goto abort_due_to_error; - } - pOut.u.i = rowid; - pOut.flags = MEM_Int; - } - } - break; - } + /* Opcode: IdxRowid P1 P2 * * * + ** + ** Write into register P2 an integer which is the last entry in the record at + ** the end of the index key pointed to by cursor P1. This integer should be + ** the rowid of the table entry to which this index entry points. + ** + ** See also: Rowid, MakeRecord. + */ + case OP_IdxRowid: { /* out2-prerelease */ + BtCursor pCrsr; + VdbeCursor pC; + i64 rowid; + + rowid = 0; + + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); + pC = p.apCsr[pOp.p1]; + Debug.Assert(pC != null); + pCrsr = pC.pCursor; + pOut.flags = MEM_Null; + if (ALWAYS(pCrsr != null)) { + rc = sqlite3VdbeCursorMoveto(pC); + if (NEVER(rc != 0)) + goto abort_due_to_error; + Debug.Assert(!pC.deferredMoveto); + Debug.Assert(!pC.isTable); + if (!pC.nullRow) { + rc = sqlite3VdbeIdxRowid(db, pCrsr, ref rowid); + if (rc != SQLITE_OK) { + goto abort_due_to_error; + } + pOut.u.i = rowid; + pOut.flags = MEM_Int; + } + } + break; + } - /* Opcode: IdxGE P1 P2 P3 P4 P5 - ** - ** The P4 register values beginning with P3 form an unpacked index - ** key that omits the ROWID. Compare this key value against the index - ** that P1 is currently pointing to, ignoring the ROWID on the P1 index. - ** - ** If the P1 index entry is greater than or equal to the key value - ** then jump to P2. Otherwise fall through to the next instruction. - ** - ** If P5 is non-zero then the key value is increased by an epsilon - ** prior to the comparison. This make the opcode work like IdxGT except - ** that if the key from register P3 is a prefix of the key in the cursor, - ** the result is false whereas it would be true with IdxGT. - */ - /* Opcode: IdxLT P1 P2 P3 P4 P5 - ** - ** The P4 register values beginning with P3 form an unpacked index - ** key that omits the ROWID. Compare this key value against the index - ** that P1 is currently pointing to, ignoring the ROWID on the P1 index. - ** - ** If the P1 index entry is less than the key value then jump to P2. - ** Otherwise fall through to the next instruction. - ** - ** If P5 is non-zero then the key value is increased by an epsilon prior - ** to the comparison. This makes the opcode work like IdxLE. - */ - case OP_IdxLT: /* jump */ - case OP_IdxGE: - { /* jump */ - VdbeCursor pC; - int res; - UnpackedRecord r; - - res = 0; - r = new UnpackedRecord(); - - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); - pC = p.apCsr[pOp.p1]; - Debug.Assert( pC != null ); - Debug.Assert( pC.isOrdered ); - if ( ALWAYS( pC.pCursor != null ) ) - { - Debug.Assert( pC.deferredMoveto == false ); - Debug.Assert( pOp.p5 == 0 || pOp.p5 == 1 ); - Debug.Assert( pOp.p4type == P4_INT32 ); - r.pKeyInfo = pC.pKeyInfo; - r.nField = (u16)pOp.p4.i; - if ( pOp.p5 != 0 ) - { - r.flags = UNPACKED_INCRKEY | UNPACKED_IGNORE_ROWID; - } - else - { - r.flags = UNPACKED_IGNORE_ROWID; - } - r.aMem = new Mem[r.nField]; - for ( int rI = 0; rI < r.nField; rI++ ) - { - r.aMem[rI] = aMem[pOp.p3 + rI];// r.aMem = aMem[pOp.p3]; + /* Opcode: IdxGE P1 P2 P3 P4 P5 + ** + ** The P4 register values beginning with P3 form an unpacked index + ** key that omits the ROWID. Compare this key value against the index + ** that P1 is currently pointing to, ignoring the ROWID on the P1 index. + ** + ** If the P1 index entry is greater than or equal to the key value + ** then jump to P2. Otherwise fall through to the next instruction. + ** + ** If P5 is non-zero then the key value is increased by an epsilon + ** prior to the comparison. This make the opcode work like IdxGT except + ** that if the key from register P3 is a prefix of the key in the cursor, + ** the result is false whereas it would be true with IdxGT. + */ + /* Opcode: IdxLT P1 P2 P3 P4 P5 + ** + ** The P4 register values beginning with P3 form an unpacked index + ** key that omits the ROWID. Compare this key value against the index + ** that P1 is currently pointing to, ignoring the ROWID on the P1 index. + ** + ** If the P1 index entry is less than the key value then jump to P2. + ** Otherwise fall through to the next instruction. + ** + ** If P5 is non-zero then the key value is increased by an epsilon prior + ** to the comparison. This makes the opcode work like IdxLE. + */ + case OP_IdxLT: /* jump */ + case OP_IdxGE: { /* jump */ + VdbeCursor pC; + int res; + UnpackedRecord r; + + res = 0; + r = new UnpackedRecord(); + + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); + pC = p.apCsr[pOp.p1]; + Debug.Assert(pC != null); + Debug.Assert(pC.isOrdered); + if (ALWAYS(pC.pCursor != null)) { + Debug.Assert(pC.deferredMoveto == false); + Debug.Assert(pOp.p5 == 0 || pOp.p5 == 1); + Debug.Assert(pOp.p4type == P4_INT32); + r.pKeyInfo = pC.pKeyInfo; + r.nField = (u16)pOp.p4.i; + if (pOp.p5 != 0) { + r.flags = UNPACKED_INCRKEY | UNPACKED_IGNORE_ROWID; + } else { + r.flags = UNPACKED_IGNORE_ROWID; + } + r.aMem = new Mem[r.nField]; + for (int rI = 0; rI < r.nField; rI++) { + r.aMem[rI] = aMem[pOp.p3 + rI];// r.aMem = aMem[pOp.p3]; #if SQLITE_DEBUG - Debug.Assert( memIsValid( r.aMem[rI] ) ); + Debug.Assert(memIsValid(r.aMem[rI])); #endif - } - rc = sqlite3VdbeIdxKeyCompare( pC, r, ref res ); - if ( pOp.opcode == OP_IdxLT ) - { - res = -res; - } - else - { - Debug.Assert( pOp.opcode == OP_IdxGE ); - res++; - } - if ( res > 0 ) - { - pc = pOp.p2 - 1; - } - } - break; - } + } + rc = sqlite3VdbeIdxKeyCompare(pC, r, ref res); + if (pOp.opcode == OP_IdxLT) { + res = -res; + } else { + Debug.Assert(pOp.opcode == OP_IdxGE); + res++; + } + if (res > 0) { + pc = pOp.p2 - 1; + } + } + break; + } - /* Opcode: Destroy P1 P2 P3 * * - ** - ** Delete an entire database table or index whose root page in the database - ** file is given by P1. - ** - ** The table being destroyed is in the main database file if P3==0. If - ** P3==1 then the table to be clear is in the auxiliary database file - ** that is used to store tables create using CREATE TEMPORARY TABLE. - ** - ** If AUTOVACUUM is enabled then it is possible that another root page - ** might be moved into the newly deleted root page in order to keep all - ** root pages contiguous at the beginning of the database. The former - ** value of the root page that moved - its value before the move occurred - - ** is stored in register P2. If no page - ** movement was required (because the table being dropped was already - ** the last one in the database) then a zero is stored in register P2. - ** If AUTOVACUUM is disabled then a zero is stored in register P2. - ** - ** See also: Clear - */ - case OP_Destroy: - { /* out2-prerelease */ - int iMoved = 0; - int iCnt; - Vdbe pVdbe; - int iDb; + /* Opcode: Destroy P1 P2 P3 * * + ** + ** Delete an entire database table or index whose root page in the database + ** file is given by P1. + ** + ** The table being destroyed is in the main database file if P3==0. If + ** P3==1 then the table to be clear is in the auxiliary database file + ** that is used to store tables create using CREATE TEMPORARY TABLE. + ** + ** If AUTOVACUUM is enabled then it is possible that another root page + ** might be moved into the newly deleted root page in order to keep all + ** root pages contiguous at the beginning of the database. The former + ** value of the root page that moved - its value before the move occurred - + ** is stored in register P2. If no page + ** movement was required (because the table being dropped was already + ** the last one in the database) then a zero is stored in register P2. + ** If AUTOVACUUM is disabled then a zero is stored in register P2. + ** + ** See also: Clear + */ + case OP_Destroy: { /* out2-prerelease */ + int iMoved = 0; + int iCnt; + Vdbe pVdbe; + int iDb; #if !SQLITE_OMIT_VIRTUALTABLE - iCnt = 0; - for ( pVdbe = db.pVdbe; pVdbe != null; pVdbe = pVdbe.pNext ) - { - if ( pVdbe.magic == VDBE_MAGIC_RUN && pVdbe.inVtabMethod < 2 && pVdbe.pc >= 0 ) - { - iCnt++; - } - } + iCnt = 0; + for (pVdbe = db.pVdbe; pVdbe != null; pVdbe = pVdbe.pNext) { + if (pVdbe.magic == VDBE_MAGIC_RUN && pVdbe.inVtabMethod < 2 && pVdbe.pc >= 0) { + iCnt++; + } + } #else iCnt = db.activeVdbeCnt; #endif - pOut.flags = MEM_Null; - if ( iCnt > 1 ) - { - rc = SQLITE_LOCKED; - p.errorAction = OE_Abort; - } - else - { - iDb = pOp.p3; - Debug.Assert( iCnt == 1 ); - Debug.Assert( ( p.btreeMask & ( ( (yDbMask)1 ) << iDb ) ) != 0 ); - rc = sqlite3BtreeDropTable( db.aDb[iDb].pBt, pOp.p1, ref iMoved ); - pOut.flags = MEM_Int; - pOut.u.i = iMoved; + pOut.flags = MEM_Null; + if (iCnt > 1) { + rc = SQLITE_LOCKED; + p.errorAction = OE_Abort; + } else { + iDb = pOp.p3; + Debug.Assert(iCnt == 1); + Debug.Assert((p.btreeMask & (((yDbMask)1) << iDb)) != 0); + rc = sqlite3BtreeDropTable(db.aDb[iDb].pBt, pOp.p1, ref iMoved); + pOut.flags = MEM_Int; + pOut.u.i = iMoved; #if !SQLITE_OMIT_AUTOVACUUM - if ( rc == SQLITE_OK && iMoved != 0 ) - { - sqlite3RootPageMoved( db, iDb, iMoved, pOp.p1 ); - /* All OP_Destroy operations occur on the same btree */ - Debug.Assert( resetSchemaOnFault == 0 || resetSchemaOnFault == iDb + 1 ); - resetSchemaOnFault = (u8)( iDb + 1 ); - } + if (rc == SQLITE_OK && iMoved != 0) { + sqlite3RootPageMoved(db, iDb, iMoved, pOp.p1); + /* All OP_Destroy operations occur on the same btree */ + Debug.Assert(resetSchemaOnFault == 0 || resetSchemaOnFault == iDb + 1); + resetSchemaOnFault = (u8)(iDb + 1); + } #endif - } - break; - } + } + break; + } - /* Opcode: Clear P1 P2 P3 - ** - ** Delete all contents of the database table or index whose root page - ** in the database file is given by P1. But, unlike Destroy, do not - ** remove the table or index from the database file. - ** - ** The table being clear is in the main database file if P2==0. If - ** P2==1 then the table to be clear is in the auxiliary database file - ** that is used to store tables create using CREATE TEMPORARY TABLE. - ** - ** If the P3 value is non-zero, then the table referred to must be an - ** intkey table (an SQL table, not an index). In this case the row change - ** count is incremented by the number of rows in the table being cleared. - ** If P3 is greater than zero, then the value stored in register P3 is - ** also incremented by the number of rows in the table being cleared. - ** - ** See also: Destroy - */ - case OP_Clear: - { - int nChange; - - nChange = 0; - Debug.Assert( ( p.btreeMask & ( ( (yDbMask)1 ) << pOp.p2 ) ) != 0 ); - int iDummy0 = 0; - if ( pOp.p3 != 0 ) - rc = sqlite3BtreeClearTable( db.aDb[pOp.p2].pBt, pOp.p1, ref nChange ); - else - rc = sqlite3BtreeClearTable( db.aDb[pOp.p2].pBt, pOp.p1, ref iDummy0 ); - if ( pOp.p3 != 0 ) - { - p.nChange += nChange; - if ( pOp.p3 > 0 ) - { - Debug.Assert( memIsValid( aMem[pOp.p3] ) ); - memAboutToChange( p, aMem[pOp.p3] ); - aMem[pOp.p3].u.i += nChange; - } - } - break; - } + /* Opcode: Clear P1 P2 P3 + ** + ** Delete all contents of the database table or index whose root page + ** in the database file is given by P1. But, unlike Destroy, do not + ** remove the table or index from the database file. + ** + ** The table being clear is in the main database file if P2==0. If + ** P2==1 then the table to be clear is in the auxiliary database file + ** that is used to store tables create using CREATE TEMPORARY TABLE. + ** + ** If the P3 value is non-zero, then the table referred to must be an + ** intkey table (an SQL table, not an index). In this case the row change + ** count is incremented by the number of rows in the table being cleared. + ** If P3 is greater than zero, then the value stored in register P3 is + ** also incremented by the number of rows in the table being cleared. + ** + ** See also: Destroy + */ + case OP_Clear: { + int nChange; + + nChange = 0; + Debug.Assert((p.btreeMask & (((yDbMask)1) << pOp.p2)) != 0); + int iDummy0 = 0; + if (pOp.p3 != 0) + rc = sqlite3BtreeClearTable(db.aDb[pOp.p2].pBt, pOp.p1, ref nChange); + else + rc = sqlite3BtreeClearTable(db.aDb[pOp.p2].pBt, pOp.p1, ref iDummy0); + if (pOp.p3 != 0) { + p.nChange += nChange; + if (pOp.p3 > 0) { + Debug.Assert(memIsValid(aMem[pOp.p3])); + memAboutToChange(p, aMem[pOp.p3]); + aMem[pOp.p3].u.i += nChange; + } + } + break; + } - /* Opcode: CreateTable P1 P2 * * * - ** - ** Allocate a new table in the main database file if P1==0 or in the - ** auxiliary database file if P1==1 or in an attached database if - ** P1>1. Write the root page number of the new table into - ** register P2 - ** - ** The difference between a table and an index is this: A table must - ** have a 4-byte integer key and can have arbitrary data. An index - ** has an arbitrary key but no data. - ** - ** See also: CreateIndex - */ - /* Opcode: CreateIndex P1 P2 * * * - ** - ** Allocate a new index in the main database file if P1==0 or in the - ** auxiliary database file if P1==1 or in an attached database if - ** P1>1. Write the root page number of the new table into - ** register P2. - ** - ** See documentation on OP_CreateTable for additional information. - */ - case OP_CreateIndex: /* out2-prerelease */ - case OP_CreateTable: - { /* out2-prerelease */ - int pgno; - int flags; - Db pDb; - - pgno = 0; - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < db.nDb ); - Debug.Assert( ( p.btreeMask & ( ( (yDbMask)1 ) << pOp.p1 ) ) != 0 ); - pDb = db.aDb[pOp.p1]; - Debug.Assert( pDb.pBt != null ); - if ( pOp.opcode == OP_CreateTable ) - { - /* flags = BTREE_INTKEY; */ - flags = BTREE_INTKEY; - } - else - { - flags = BTREE_BLOBKEY; - } - rc = sqlite3BtreeCreateTable( pDb.pBt, ref pgno, flags ); - pOut.u.i = pgno; - break; - } + /* Opcode: CreateTable P1 P2 * * * + ** + ** Allocate a new table in the main database file if P1==0 or in the + ** auxiliary database file if P1==1 or in an attached database if + ** P1>1. Write the root page number of the new table into + ** register P2 + ** + ** The difference between a table and an index is this: A table must + ** have a 4-byte integer key and can have arbitrary data. An index + ** has an arbitrary key but no data. + ** + ** See also: CreateIndex + */ + /* Opcode: CreateIndex P1 P2 * * * + ** + ** Allocate a new index in the main database file if P1==0 or in the + ** auxiliary database file if P1==1 or in an attached database if + ** P1>1. Write the root page number of the new table into + ** register P2. + ** + ** See documentation on OP_CreateTable for additional information. + */ + case OP_CreateIndex: /* out2-prerelease */ + case OP_CreateTable: { /* out2-prerelease */ + int pgno; + int flags; + Db pDb; + + pgno = 0; + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < db.nDb); + Debug.Assert((p.btreeMask & (((yDbMask)1) << pOp.p1)) != 0); + pDb = db.aDb[pOp.p1]; + Debug.Assert(pDb.pBt != null); + if (pOp.opcode == OP_CreateTable) { + /* flags = BTREE_INTKEY; */ + flags = BTREE_INTKEY; + } else { + flags = BTREE_BLOBKEY; + } + rc = sqlite3BtreeCreateTable(pDb.pBt, ref pgno, flags); + pOut.u.i = pgno; + break; + } - /* Opcode: ParseSchema P1 * * P4 * - ** - ** Read and parse all entries from the SQLITE_MASTER table of database P1 - ** that match the WHERE clause P4. - ** - ** This opcode invokes the parser to create a new virtual machine, - ** then runs the new virtual machine. It is thus a re-entrant opcode. - */ - case OP_ParseSchema: - { - int iDb; - string zMaster; - string zSql; - InitData initData; - - /* Any prepared statement that invokes this opcode will hold mutexes - ** on every btree. This is a prerequisite for invoking - ** sqlite3InitCallback(). - */ + /* Opcode: ParseSchema P1 * * P4 * + ** + ** Read and parse all entries from the SQLITE_MASTER table of database P1 + ** that match the WHERE clause P4. + ** + ** This opcode invokes the parser to create a new virtual machine, + ** then runs the new virtual machine. It is thus a re-entrant opcode. + */ + case OP_ParseSchema: { + int iDb; + string zMaster; + string zSql; + InitData initData; + + /* Any prepared statement that invokes this opcode will hold mutexes + ** on every btree. This is a prerequisite for invoking + ** sqlite3InitCallback(). + */ #if SQLITE_DEBUG - for ( iDb = 0; iDb < db.nDb; iDb++ ) - { - Debug.Assert( iDb == 1 || sqlite3BtreeHoldsMutex( db.aDb[iDb].pBt ) ); - } + for (iDb = 0; iDb < db.nDb; iDb++) { + Debug.Assert(iDb == 1 || sqlite3BtreeHoldsMutex(db.aDb[iDb].pBt)); + } #endif - iDb = pOp.p1; - Debug.Assert( iDb >= 0 && iDb < db.nDb ); - Debug.Assert( DbHasProperty( db, iDb, DB_SchemaLoaded ) ); - /* Used to be a conditional */ - { - zMaster = SCHEMA_TABLE( iDb ); - initData = new InitData(); - initData.db = db; - initData.iDb = pOp.p1; - initData.pzErrMsg = p.zErrMsg; - zSql = sqlite3MPrintf( db, - "SELECT name, rootpage, sql FROM '%q'.%s WHERE %s ORDER BY rowid", - db.aDb[iDb].zName, zMaster, pOp.p4.z ); - if ( String.IsNullOrEmpty( zSql ) ) - { - rc = SQLITE_NOMEM; - } - else - { - Debug.Assert( 0 == db.init.busy ); - db.init.busy = 1; - initData.rc = SQLITE_OK; - //Debug.Assert( 0 == db.mallocFailed ); - rc = sqlite3_exec( db, zSql, (dxCallback)sqlite3InitCallback, (object)initData, 0 ); - if ( rc == SQLITE_OK ) - rc = initData.rc; - sqlite3DbFree( db, ref zSql ); - db.init.busy = 0; - } - } - if ( rc == SQLITE_NOMEM ) - { - goto no_mem; - } - break; - } - -#if !SQLITE_OMIT_ANALYZE - /* Opcode: LoadAnalysis P1 * * * * -** -** Read the sqlite_stat1 table for database P1 and load the content -** of that table into the internal index hash table. This will cause -** the analysis to be used when preparing all subsequent queries. -*/ - case OP_LoadAnalysis: - { - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < db.nDb ); - rc = sqlite3AnalysisLoad( db, pOp.p1 ); - break; - } -#endif // * !SQLITE_OMIT_ANALYZE) */ - - /* Opcode: DropTable P1 * * P4 * -** -** Remove the internal (in-memory) data structures that describe -** the table named P4 in database P1. This is called after a table -** is dropped in order to keep the internal representation of the -** schema consistent with what is on disk. -*/ - case OP_DropTable: - { - sqlite3UnlinkAndDeleteTable( db, pOp.p1, pOp.p4.z ); - break; - } + iDb = pOp.p1; + Debug.Assert(iDb >= 0 && iDb < db.nDb); + Debug.Assert(DbHasProperty(db, iDb, DB_SchemaLoaded)); + /* Used to be a conditional */ + { + zMaster = SCHEMA_TABLE(iDb); + initData = new InitData(); + initData.db = db; + initData.iDb = pOp.p1; + initData.pzErrMsg = p.zErrMsg; + zSql = sqlite3MPrintf(db, + "SELECT name, rootpage, sql FROM '%q'.%s WHERE %s ORDER BY rowid", + db.aDb[iDb].zName, zMaster, pOp.p4.z); + if (String.IsNullOrEmpty(zSql)) { + rc = SQLITE_NOMEM; + } else { + Debug.Assert(0 == db.init.busy); + db.init.busy = 1; + initData.rc = SQLITE_OK; + //Debug.Assert( 0 == db.mallocFailed ); + rc = sqlite3_exec(db, zSql, (dxCallback)sqlite3InitCallback, (object)initData, 0); + if (rc == SQLITE_OK) + rc = initData.rc; + sqlite3DbFree(db, ref zSql); + db.init.busy = 0; + } + } + if (rc == SQLITE_NOMEM) { + goto no_mem; + } + break; + } - /* Opcode: DropIndex P1 * * P4 * +#if !SQLITE_OMIT_ANALYZE + /* Opcode: LoadAnalysis P1 * * * * ** - ** Remove the internal (in-memory) data structures that describe - ** the index named P4 in database P1. This is called after an index - ** is dropped in order to keep the internal representation of the - ** schema consistent with what is on disk. + ** Read the sqlite_stat1 table for database P1 and load the content + ** of that table into the internal index hash table. This will cause + ** the analysis to be used when preparing all subsequent queries. */ - case OP_DropIndex: - { - sqlite3UnlinkAndDeleteIndex( db, pOp.p1, pOp.p4.z ); - break; - } + case OP_LoadAnalysis: { + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < db.nDb); + rc = sqlite3AnalysisLoad(db, pOp.p1); + break; + } +#endif // * !SQLITE_OMIT_ANALYZE) */ - /* Opcode: DropTrigger P1 * * P4 * + /* Opcode: DropTable P1 * * P4 * ** ** Remove the internal (in-memory) data structures that describe - ** the trigger named P4 in database P1. This is called after a trigger + ** the table named P4 in database P1. This is called after a table ** is dropped in order to keep the internal representation of the ** schema consistent with what is on disk. */ - case OP_DropTrigger: - { - sqlite3UnlinkAndDeleteTrigger( db, pOp.p1, pOp.p4.z ); - break; - } + case OP_DropTable: { + sqlite3UnlinkAndDeleteTable(db, pOp.p1, pOp.p4.z); + break; + } + /* Opcode: DropIndex P1 * * P4 * + ** + ** Remove the internal (in-memory) data structures that describe + ** the index named P4 in database P1. This is called after an index + ** is dropped in order to keep the internal representation of the + ** schema consistent with what is on disk. + */ + case OP_DropIndex: { + sqlite3UnlinkAndDeleteIndex(db, pOp.p1, pOp.p4.z); + break; + } -#if !SQLITE_OMIT_INTEGRITY_CHECK - /* Opcode: IntegrityCk P1 P2 P3 * P5 -** -** Do an analysis of the currently open database. Store in -** register P1 the text of an error message describing any problems. -** If no problems are found, store a NULL in register P1. -** -** The register P3 contains the maximum number of allowed errors. -** At most reg(P3) errors will be reported. -** In other words, the analysis stops as soon as reg(P1) errors are -** seen. Reg(P1) is updated with the number of errors remaining. -** -** The root page numbers of all tables in the database are integer -** stored in reg(P1), reg(P1+1), reg(P1+2), .... There are P2 tables -** total. -** -** If P5 is not zero, the check is done on the auxiliary database -** file, not the main database file. -** -** This opcode is used to implement the integrity_check pragma. -*/ - case OP_IntegrityCk: - { - int nRoot; /* Number of tables to check. (Number of root pages.) */ - int[] aRoot = null; /* Array of rootpage numbers for tables to be checked */ - int j; /* Loop counter */ - int nErr = 0; /* Number of errors reported */ - string z; /* Text of the error report */ - Mem pnErr; /* Register keeping track of errors remaining */ - - nRoot = pOp.p2; - Debug.Assert( nRoot > 0 ); - aRoot = sqlite3Malloc( aRoot, ( nRoot + 1 ) );// sqlite3DbMallocRaw(db, sizeof(int) * (nRoot + 1)); - if ( aRoot == null ) - goto no_mem; - Debug.Assert( pOp.p3 > 0 && pOp.p3 <= p.nMem ); - pnErr = aMem[pOp.p3]; - Debug.Assert( ( pnErr.flags & MEM_Int ) != 0 ); - Debug.Assert( ( pnErr.flags & ( MEM_Str | MEM_Blob ) ) == 0 ); - pIn1 = aMem[pOp.p1]; - for ( j = 0; j < nRoot; j++ ) - { - aRoot[j] = (int)sqlite3VdbeIntValue( p.aMem[pOp.p1 + j] ); // pIn1[j]); - } - aRoot[j] = 0; - Debug.Assert( pOp.p5 < db.nDb ); - Debug.Assert( ( p.btreeMask & ( ( (yDbMask)1 ) << pOp.p5 ) ) != 0 ); - z = sqlite3BtreeIntegrityCheck( db.aDb[pOp.p5].pBt, aRoot, nRoot, - (int)pnErr.u.i, ref nErr ); - sqlite3DbFree( db, ref aRoot ); - pnErr.u.i -= nErr; - sqlite3VdbeMemSetNull( pIn1 ); - if ( nErr == 0 ) - { - Debug.Assert( z == "" ); - } - else if ( String.IsNullOrEmpty( z ) ) - { - goto no_mem; - } - else - { - sqlite3VdbeMemSetStr( pIn1, z, -1, SQLITE_UTF8, null ); //sqlite3_free ); - } + /* Opcode: DropTrigger P1 * * P4 * + ** + ** Remove the internal (in-memory) data structures that describe + ** the trigger named P4 in database P1. This is called after a trigger + ** is dropped in order to keep the internal representation of the + ** schema consistent with what is on disk. + */ + case OP_DropTrigger: { + sqlite3UnlinkAndDeleteTrigger(db, pOp.p1, pOp.p4.z); + break; + } + + +#if !SQLITE_OMIT_INTEGRITY_CHECK + /* Opcode: IntegrityCk P1 P2 P3 * P5 + ** + ** Do an analysis of the currently open database. Store in + ** register P1 the text of an error message describing any problems. + ** If no problems are found, store a NULL in register P1. + ** + ** The register P3 contains the maximum number of allowed errors. + ** At most reg(P3) errors will be reported. + ** In other words, the analysis stops as soon as reg(P1) errors are + ** seen. Reg(P1) is updated with the number of errors remaining. + ** + ** The root page numbers of all tables in the database are integer + ** stored in reg(P1), reg(P1+1), reg(P1+2), .... There are P2 tables + ** total. + ** + ** If P5 is not zero, the check is done on the auxiliary database + ** file, not the main database file. + ** + ** This opcode is used to implement the integrity_check pragma. + */ + case OP_IntegrityCk: { + int nRoot; /* Number of tables to check. (Number of root pages.) */ + int[] aRoot = null; /* Array of rootpage numbers for tables to be checked */ + int j; /* Loop counter */ + int nErr = 0; /* Number of errors reported */ + string z; /* Text of the error report */ + Mem pnErr; /* Register keeping track of errors remaining */ + + nRoot = pOp.p2; + Debug.Assert(nRoot > 0); + aRoot = sqlite3Malloc(aRoot, (nRoot + 1));// sqlite3DbMallocRaw(db, sizeof(int) * (nRoot + 1)); + if (aRoot == null) + goto no_mem; + Debug.Assert(pOp.p3 > 0 && pOp.p3 <= p.nMem); + pnErr = aMem[pOp.p3]; + Debug.Assert((pnErr.flags & MEM_Int) != 0); + Debug.Assert((pnErr.flags & (MEM_Str | MEM_Blob)) == 0); + pIn1 = aMem[pOp.p1]; + for (j = 0; j < nRoot; j++) { + aRoot[j] = (int)sqlite3VdbeIntValue(p.aMem[pOp.p1 + j]); // pIn1[j]); + } + aRoot[j] = 0; + Debug.Assert(pOp.p5 < db.nDb); + Debug.Assert((p.btreeMask & (((yDbMask)1) << pOp.p5)) != 0); + z = sqlite3BtreeIntegrityCheck(db.aDb[pOp.p5].pBt, aRoot, nRoot, + (int)pnErr.u.i, ref nErr); + sqlite3DbFree(db, ref aRoot); + pnErr.u.i -= nErr; + sqlite3VdbeMemSetNull(pIn1); + if (nErr == 0) { + Debug.Assert(z == ""); + } else if (String.IsNullOrEmpty(z)) { + goto no_mem; + } else { + sqlite3VdbeMemSetStr(pIn1, z, -1, SQLITE_UTF8, null); //sqlite3_free ); + } #if SQLITE_TEST UPDATE_MAX_BLOBSIZE( pIn1 ); #endif - sqlite3VdbeChangeEncoding( pIn1, encoding ); - break; - } + sqlite3VdbeChangeEncoding(pIn1, encoding); + break; + } #endif // * SQLITE_OMIT_INTEGRITY_CHECK */ - /* Opcode: RowSetAdd P1 P2 * * * -** -** Insert the integer value held by register P2 into a boolean index -** held in register P1. -** -** An assertion fails if P2 is not an integer. -*/ - case OP_RowSetAdd: - { /* in1, in2 */ - pIn1 = aMem[pOp.p1]; - pIn2 = aMem[pOp.p2]; - Debug.Assert( ( pIn2.flags & MEM_Int ) != 0 ); - if ( ( pIn1.flags & MEM_RowSet ) == 0 ) - { - sqlite3VdbeMemSetRowSet( pIn1 ); - if ( ( pIn1.flags & MEM_RowSet ) == 0 ) - goto no_mem; - } - sqlite3RowSetInsert( pIn1.u.pRowSet, pIn2.u.i ); - break; - } - /* Opcode: RowSetRead P1 P2 P3 * * - ** - ** Extract the smallest value from boolean index P1 and put that value into - ** register P3. Or, if boolean index P1 is initially empty, leave P3 - ** unchanged and jump to instruction P2. - */ - case OP_RowSetRead: - { /* jump, in1, ref3 */ - i64 val = 0; - if ( db.u1.isInterrupted ) - goto abort_due_to_interrupt; //CHECK_FOR_INTERRUPT; - pIn1 = aMem[pOp.p1]; - if ( ( pIn1.flags & MEM_RowSet ) == 0 - || sqlite3RowSetNext( pIn1.u.pRowSet, ref val ) == 0 - ) - { - /* The boolean index is empty */ - sqlite3VdbeMemSetNull( pIn1 ); - pc = pOp.p2 - 1; - } - else - { - /* A value was pulled from the index */ - sqlite3VdbeMemSetInt64( aMem[pOp.p3], val ); - } - break; - } - - /* Opcode: RowSetTest P1 P2 P3 P4 + /* Opcode: RowSetAdd P1 P2 * * * ** - ** Register P3 is assumed to hold a 64-bit integer value. If register P1 - ** contains a RowSet object and that RowSet object contains - ** the value held in P3, jump to register P2. Otherwise, insert the - ** integer in P3 into the RowSet and continue on to the - ** next opcode. + ** Insert the integer value held by register P2 into a boolean index + ** held in register P1. ** - ** The RowSet object is optimized for the case where successive sets - ** of integers, where each set contains no duplicates. Each set - ** of values is identified by a unique P4 value. The first set - ** must have P4==0, the final set P4=-1. P4 must be either -1 or - ** non-negative. For non-negative values of P4 only the lower 4 - ** bits are significant. - ** - ** This allows optimizations: (a) when P4==0 there is no need to test - ** the rowset object for P3, as it is guaranteed not to contain it, - ** (b) when P4==-1 there is no need to insert the value, as it will - ** never be tested for, and (c) when a value that is part of set X is - ** inserted, there is no need to search to see if the same value was - ** previously inserted as part of set X (only if it was previously - ** inserted as part of some other set). + ** An assertion fails if P2 is not an integer. */ - case OP_RowSetTest: - { /* jump, in1, in3 */ - int iSet; - int exists; - - pIn1 = aMem[pOp.p1]; - pIn3 = aMem[pOp.p3]; - iSet = pOp.p4.i; - Debug.Assert( ( pIn3.flags & MEM_Int ) != 0 ); - - /* If there is anything other than a rowset object in memory cell P1, - ** delete it now and initialize P1 with an empty rowset - */ - if ( ( pIn1.flags & MEM_RowSet ) == 0 ) - { - sqlite3VdbeMemSetRowSet( pIn1 ); - if ( ( pIn1.flags & MEM_RowSet ) == 0 ) - goto no_mem; - } - - Debug.Assert( pOp.p4type == P4_INT32 ); - Debug.Assert( iSet == -1 || iSet >= 0 ); - if ( iSet != 0 ) - { - exists = sqlite3RowSetTest( pIn1.u.pRowSet, - (u8)( iSet >= 0 ? iSet & 0xf : 0xff ), - pIn3.u.i ); - if ( exists != 0 ) - { - pc = pOp.p2 - 1; - break; - } - } - if ( iSet >= 0 ) - { - sqlite3RowSetInsert( pIn1.u.pRowSet, pIn3.u.i ); - } - break; - } + case OP_RowSetAdd: { /* in1, in2 */ + pIn1 = aMem[pOp.p1]; + pIn2 = aMem[pOp.p2]; + Debug.Assert((pIn2.flags & MEM_Int) != 0); + if ((pIn1.flags & MEM_RowSet) == 0) { + sqlite3VdbeMemSetRowSet(pIn1); + if ((pIn1.flags & MEM_RowSet) == 0) + goto no_mem; + } + sqlite3RowSetInsert(pIn1.u.pRowSet, pIn2.u.i); + break; + } + /* Opcode: RowSetRead P1 P2 P3 * * + ** + ** Extract the smallest value from boolean index P1 and put that value into + ** register P3. Or, if boolean index P1 is initially empty, leave P3 + ** unchanged and jump to instruction P2. + */ + case OP_RowSetRead: { /* jump, in1, ref3 */ + i64 val = 0; + if (db.u1.isInterrupted) + goto abort_due_to_interrupt; //CHECK_FOR_INTERRUPT; + pIn1 = aMem[pOp.p1]; + if ((pIn1.flags & MEM_RowSet) == 0 + || sqlite3RowSetNext(pIn1.u.pRowSet, ref val) == 0 + ) { + /* The boolean index is empty */ + sqlite3VdbeMemSetNull(pIn1); + pc = pOp.p2 - 1; + } else { + /* A value was pulled from the index */ + sqlite3VdbeMemSetInt64(aMem[pOp.p3], val); + } + break; + } -#if !SQLITE_OMIT_TRIGGER + /* Opcode: RowSetTest P1 P2 P3 P4 + ** + ** Register P3 is assumed to hold a 64-bit integer value. If register P1 + ** contains a RowSet object and that RowSet object contains + ** the value held in P3, jump to register P2. Otherwise, insert the + ** integer in P3 into the RowSet and continue on to the + ** next opcode. + ** + ** The RowSet object is optimized for the case where successive sets + ** of integers, where each set contains no duplicates. Each set + ** of values is identified by a unique P4 value. The first set + ** must have P4==0, the final set P4=-1. P4 must be either -1 or + ** non-negative. For non-negative values of P4 only the lower 4 + ** bits are significant. + ** + ** This allows optimizations: (a) when P4==0 there is no need to test + ** the rowset object for P3, as it is guaranteed not to contain it, + ** (b) when P4==-1 there is no need to insert the value, as it will + ** never be tested for, and (c) when a value that is part of set X is + ** inserted, there is no need to search to see if the same value was + ** previously inserted as part of set X (only if it was previously + ** inserted as part of some other set). + */ + case OP_RowSetTest: { /* jump, in1, in3 */ + int iSet; + int exists; + + pIn1 = aMem[pOp.p1]; + pIn3 = aMem[pOp.p3]; + iSet = pOp.p4.i; + Debug.Assert((pIn3.flags & MEM_Int) != 0); + + /* If there is anything other than a rowset object in memory cell P1, + ** delete it now and initialize P1 with an empty rowset + */ + if ((pIn1.flags & MEM_RowSet) == 0) { + sqlite3VdbeMemSetRowSet(pIn1); + if ((pIn1.flags & MEM_RowSet) == 0) + goto no_mem; + } + + Debug.Assert(pOp.p4type == P4_INT32); + Debug.Assert(iSet == -1 || iSet >= 0); + if (iSet != 0) { + exists = sqlite3RowSetTest(pIn1.u.pRowSet, + (u8)(iSet >= 0 ? iSet & 0xf : 0xff), + pIn3.u.i); + if (exists != 0) { + pc = pOp.p2 - 1; + break; + } + } + if (iSet >= 0) { + sqlite3RowSetInsert(pIn1.u.pRowSet, pIn3.u.i); + } + break; + } - /* Opcode: Program P1 P2 P3 P4 * -** -** Execute the trigger program passed as P4 (type P4_SUBPROGRAM). -** -** P1 contains the address of the memory cell that contains the first memory -** cell in an array of values used as arguments to the sub-program. P2 -** contains the address to jump to if the sub-program throws an IGNORE -** exception using the RAISE() function. Register P3 contains the address -** of a memory cell in this (the parent) VM that is used to allocate the -** memory required by the sub-vdbe at runtime. -** -** P4 is a pointer to the VM containing the trigger program. -*/ - case OP_Program: - { /* jump */ - int nMem; /* Number of memory registers for sub-program */ - int nByte; /* Bytes of runtime space required for sub-program */ - Mem pRt; /* Register to allocate runtime space */ - Mem pMem = null; /* Used to iterate through memory cells */ - //Mem pEnd; /* Last memory cell in new array */ - VdbeFrame pFrame; /* New vdbe frame to execute in */ - SubProgram pProgram; /* Sub-program to execute */ - int t; /* Token identifying trigger */ - - pProgram = pOp.p4.pProgram; - pRt = aMem[pOp.p3]; - Debug.Assert( memIsValid( pRt ) ); - Debug.Assert( pProgram.nOp > 0 ); - - /* If the p5 flag is clear, then recursive invocation of triggers is - ** disabled for backwards compatibility (p5 is set if this sub-program - ** is really a trigger, not a foreign key action, and the flag set - ** and cleared by the "PRAGMA recursive_triggers" command is clear). - ** - ** It is recursive invocation of triggers, at the SQL level, that is - ** disabled. In some cases a single trigger may generate more than one - ** SubProgram (if the trigger may be executed with more than one different - ** ON CONFLICT algorithm). SubProgram structures associated with a - ** single trigger all have the same value for the SubProgram.token - ** variable. */ - if ( pOp.p5 != 0 ) - { - t = pProgram.token; - for ( pFrame = p.pFrame; pFrame != null && pFrame.token != t; pFrame = pFrame.pParent ) - ; - if ( pFrame != null ) - break; - } - - if ( p.nFrame >= db.aLimit[SQLITE_LIMIT_TRIGGER_DEPTH] ) - { - rc = SQLITE_ERROR; - sqlite3SetString( ref p.zErrMsg, db, "too many levels of trigger recursion" ); - break; - } - - /* Register pRt is used to store the memory required to save the state - ** of the current program, and the memory required at runtime to execute - ** the trigger program. If this trigger has been fired before, then pRt - ** is already allocated. Otherwise, it must be initialized. */ - if ( ( pRt.flags & MEM_Frame ) == 0 ) - { - /* SubProgram.nMem is set to the number of memory cells used by the - ** program stored in SubProgram.aOp. As well as these, one memory - ** cell is required for each cursor used by the program. Set local - ** variable nMem (and later, VdbeFrame.nChildMem) to this value. - */ - nMem = pProgram.nMem + pProgram.nCsr; - //nByte = ROUND8( sizeof( VdbeFrame ) ) - //+ nMem * sizeof( Mem ) - //+ pProgram.nCsr * sizeof( VdbeCursor* ); - pFrame = new VdbeFrame();// sqlite3DbMallocZero( db, nByte ); - //if ( !pFrame ) - //{ - // goto no_mem; - //} - sqlite3VdbeMemRelease( pRt ); - pRt.flags = MEM_Frame; - pRt.u.pFrame = pFrame; - - pFrame.v = p; - pFrame.nChildMem = nMem; - pFrame.nChildCsr = pProgram.nCsr; - pFrame.pc = pc; - pFrame.aMem = p.aMem; - pFrame.nMem = p.nMem; - pFrame.apCsr = p.apCsr; - pFrame.nCursor = p.nCursor; - pFrame.aOp = p.aOp; - pFrame.nOp = p.nOp; - pFrame.token = pProgram.token; - - // &VdbeFrameMem( pFrame )[pFrame.nChildMem]; - // aMem is 1 based, so allocate 1 extra cell under C# - pFrame.aChildMem = new Mem[pFrame.nChildMem + 1]; - for ( int i = 0; i < pFrame.aChildMem.Length; i++ )//pMem = VdbeFrameMem( pFrame ) ; pMem != pEnd ; pMem++ ) - { - //pFrame.aMem[i] = pFrame.aMem[pFrame.nMem+i]; - pMem = sqlite3Malloc( pMem ); - pMem.flags = MEM_Null; - pMem.db = db; - pFrame.aChildMem[i] = pMem; - } - pFrame.aChildCsr = new VdbeCursor[pFrame.nChildCsr]; - for ( int i = 0; i < pFrame.nChildCsr; i++ ) - pFrame.aChildCsr[i] = new VdbeCursor(); - } - else - { - pFrame = pRt.u.pFrame; - Debug.Assert( pProgram.nMem + pProgram.nCsr == pFrame.nChildMem ); - Debug.Assert( pProgram.nCsr == pFrame.nChildCsr ); - Debug.Assert( pc == pFrame.pc ); - } - - p.nFrame++; - pFrame.pParent = p.pFrame; - pFrame.lastRowid = lastRowid; - pFrame.nChange = p.nChange; - p.nChange = 0; - p.pFrame = pFrame; - p.aMem = aMem = pFrame.aChildMem; // &VdbeFrameMem( pFrame )[-1]; - p.nMem = pFrame.nChildMem; - p.nCursor = (u16)pFrame.nChildCsr; - p.apCsr = pFrame.aChildCsr;// (VdbeCursor *)&aMem[p->nMem+1]; - p.aOp = aOp = pProgram.aOp; - p.nOp = pProgram.nOp; - pc = -1; - - break; - } +#if !SQLITE_OMIT_TRIGGER - /* Opcode: Param P1 P2 * * * + /* Opcode: Program P1 P2 P3 P4 * + ** + ** Execute the trigger program passed as P4 (type P4_SUBPROGRAM). ** - ** This opcode is only ever present in sub-programs called via the - ** OP_Program instruction. Copy a value currently stored in a memory - ** cell of the calling (parent) frame to cell P2 in the current frames - ** address space. This is used by trigger programs to access the new.* - ** and old.* values. + ** P1 contains the address of the memory cell that contains the first memory + ** cell in an array of values used as arguments to the sub-program. P2 + ** contains the address to jump to if the sub-program throws an IGNORE + ** exception using the RAISE() function. Register P3 contains the address + ** of a memory cell in this (the parent) VM that is used to allocate the + ** memory required by the sub-vdbe at runtime. ** - ** The address of the cell in the parent frame is determined by adding - ** the value of the P1 argument to the value of the P1 argument to the - ** calling OP_Program instruction. + ** P4 is a pointer to the VM containing the trigger program. */ - case OP_Param: - { /* out2-prerelease */ - VdbeFrame pFrame; - Mem pIn; - pFrame = p.pFrame; - pIn = pFrame.aMem[pOp.p1 + pFrame.aOp[pFrame.pc].p1]; - sqlite3VdbeMemShallowCopy( pOut, pIn, MEM_Ephem ); - break; - } + case OP_Program: { /* jump */ + int nMem; /* Number of memory registers for sub-program */ + int nByte; /* Bytes of runtime space required for sub-program */ + Mem pRt; /* Register to allocate runtime space */ + Mem pMem = null; /* Used to iterate through memory cells */ + //Mem pEnd; /* Last memory cell in new array */ + VdbeFrame pFrame; /* New vdbe frame to execute in */ + SubProgram pProgram; /* Sub-program to execute */ + int t; /* Token identifying trigger */ + + pProgram = pOp.p4.pProgram; + pRt = aMem[pOp.p3]; + Debug.Assert(memIsValid(pRt)); + Debug.Assert(pProgram.nOp > 0); + + /* If the p5 flag is clear, then recursive invocation of triggers is + ** disabled for backwards compatibility (p5 is set if this sub-program + ** is really a trigger, not a foreign key action, and the flag set + ** and cleared by the "PRAGMA recursive_triggers" command is clear). + ** + ** It is recursive invocation of triggers, at the SQL level, that is + ** disabled. In some cases a single trigger may generate more than one + ** SubProgram (if the trigger may be executed with more than one different + ** ON CONFLICT algorithm). SubProgram structures associated with a + ** single trigger all have the same value for the SubProgram.token + ** variable. */ + if (pOp.p5 != 0) { + t = pProgram.token; + for (pFrame = p.pFrame; pFrame != null && pFrame.token != t; pFrame = pFrame.pParent) + ; + if (pFrame != null) + break; + } + + if (p.nFrame >= db.aLimit[SQLITE_LIMIT_TRIGGER_DEPTH]) { + rc = SQLITE_ERROR; + sqlite3SetString(ref p.zErrMsg, db, "too many levels of trigger recursion"); + break; + } + + /* Register pRt is used to store the memory required to save the state + ** of the current program, and the memory required at runtime to execute + ** the trigger program. If this trigger has been fired before, then pRt + ** is already allocated. Otherwise, it must be initialized. */ + if ((pRt.flags & MEM_Frame) == 0) { + /* SubProgram.nMem is set to the number of memory cells used by the + ** program stored in SubProgram.aOp. As well as these, one memory + ** cell is required for each cursor used by the program. Set local + ** variable nMem (and later, VdbeFrame.nChildMem) to this value. + */ + nMem = pProgram.nMem + pProgram.nCsr; + //nByte = ROUND8( sizeof( VdbeFrame ) ) + //+ nMem * sizeof( Mem ) + //+ pProgram.nCsr * sizeof( VdbeCursor* ); + pFrame = new VdbeFrame();// sqlite3DbMallocZero( db, nByte ); + //if ( !pFrame ) + //{ + // goto no_mem; + //} + sqlite3VdbeMemRelease(pRt); + pRt.flags = MEM_Frame; + pRt.u.pFrame = pFrame; + + pFrame.v = p; + pFrame.nChildMem = nMem; + pFrame.nChildCsr = pProgram.nCsr; + pFrame.pc = pc; + pFrame.aMem = p.aMem; + pFrame.nMem = p.nMem; + pFrame.apCsr = p.apCsr; + pFrame.nCursor = p.nCursor; + pFrame.aOp = p.aOp; + pFrame.nOp = p.nOp; + pFrame.token = pProgram.token; + + // &VdbeFrameMem( pFrame )[pFrame.nChildMem]; + // aMem is 1 based, so allocate 1 extra cell under C# + pFrame.aChildMem = new Mem[pFrame.nChildMem + 1]; + for (int i = 0; i < pFrame.aChildMem.Length; i++)//pMem = VdbeFrameMem( pFrame ) ; pMem != pEnd ; pMem++ ) + { + //pFrame.aMem[i] = pFrame.aMem[pFrame.nMem+i]; + pMem = sqlite3Malloc(pMem); + pMem.flags = MEM_Null; + pMem.db = db; + pFrame.aChildMem[i] = pMem; + } + pFrame.aChildCsr = new VdbeCursor[pFrame.nChildCsr]; + for (int i = 0; i < pFrame.nChildCsr; i++) + pFrame.aChildCsr[i] = new VdbeCursor(); + } else { + pFrame = pRt.u.pFrame; + Debug.Assert(pProgram.nMem + pProgram.nCsr == pFrame.nChildMem); + Debug.Assert(pProgram.nCsr == pFrame.nChildCsr); + Debug.Assert(pc == pFrame.pc); + } + + p.nFrame++; + pFrame.pParent = p.pFrame; + pFrame.lastRowid = lastRowid; + pFrame.nChange = p.nChange; + p.nChange = 0; + p.pFrame = pFrame; + p.aMem = aMem = pFrame.aChildMem; // &VdbeFrameMem( pFrame )[-1]; + p.nMem = pFrame.nChildMem; + p.nCursor = (u16)pFrame.nChildCsr; + p.apCsr = pFrame.aChildCsr;// (VdbeCursor *)&aMem[p->nMem+1]; + p.aOp = aOp = pProgram.aOp; + p.nOp = pProgram.nOp; + pc = -1; + + break; + } + + /* Opcode: Param P1 P2 * * * + ** + ** This opcode is only ever present in sub-programs called via the + ** OP_Program instruction. Copy a value currently stored in a memory + ** cell of the calling (parent) frame to cell P2 in the current frames + ** address space. This is used by trigger programs to access the new.* + ** and old.* values. + ** + ** The address of the cell in the parent frame is determined by adding + ** the value of the P1 argument to the value of the P1 argument to the + ** calling OP_Program instruction. + */ + case OP_Param: { /* out2-prerelease */ + VdbeFrame pFrame; + Mem pIn; + pFrame = p.pFrame; + pIn = pFrame.aMem[pOp.p1 + pFrame.aOp[pFrame.pc].p1]; + sqlite3VdbeMemShallowCopy(pOut, pIn, MEM_Ephem); + break; + } #endif // * #if !SQLITE_OMIT_TRIGGER */ #if !SQLITE_OMIT_FOREIGN_KEY - /* Opcode: FkCounter P1 P2 * * * -** -** Increment a "constraint counter" by P2 (P2 may be negative or positive). -** If P1 is non-zero, the database constraint counter is incremented -** (deferred foreign key constraints). Otherwise, if P1 is zero, the -** statement counter is incremented (immediate foreign key constraints). -*/ - case OP_FkCounter: - { - if ( pOp.p1 != 0 ) - { - db.nDeferredCons += pOp.p2; - } - else - { - p.nFkConstraint += pOp.p2; - } - break; - } - - /* Opcode: FkIfZero P1 P2 * * * + /* Opcode: FkCounter P1 P2 * * * ** - ** This opcode tests if a foreign key constraint-counter is currently zero. - ** If so, jump to instruction P2. Otherwise, fall through to the next - ** instruction. - ** - ** If P1 is non-zero, then the jump is taken if the database constraint-counter - ** is zero (the one that counts deferred constraint violations). If P1 is - ** zero, the jump is taken if the statement constraint-counter is zero - ** (immediate foreign key constraint violations). + ** Increment a "constraint counter" by P2 (P2 may be negative or positive). + ** If P1 is non-zero, the database constraint counter is incremented + ** (deferred foreign key constraints). Otherwise, if P1 is zero, the + ** statement counter is incremented (immediate foreign key constraints). */ - case OP_FkIfZero: - { /* jump */ - if ( pOp.p1 != 0 ) - { - if ( db.nDeferredCons == 0 ) - pc = pOp.p2 - 1; - } - else - { - if ( p.nFkConstraint == 0 ) - pc = pOp.p2 - 1; - } - break; - } + case OP_FkCounter: { + if (pOp.p1 != 0) { + db.nDeferredCons += pOp.p2; + } else { + p.nFkConstraint += pOp.p2; + } + break; + } + + /* Opcode: FkIfZero P1 P2 * * * + ** + ** This opcode tests if a foreign key constraint-counter is currently zero. + ** If so, jump to instruction P2. Otherwise, fall through to the next + ** instruction. + ** + ** If P1 is non-zero, then the jump is taken if the database constraint-counter + ** is zero (the one that counts deferred constraint violations). If P1 is + ** zero, the jump is taken if the statement constraint-counter is zero + ** (immediate foreign key constraint violations). + */ + case OP_FkIfZero: { /* jump */ + if (pOp.p1 != 0) { + if (db.nDeferredCons == 0) + pc = pOp.p2 - 1; + } else { + if (p.nFkConstraint == 0) + pc = pOp.p2 - 1; + } + break; + } #endif //* #if !SQLITE_OMIT_FOREIGN_KEY */ #if !SQLITE_OMIT_AUTOINCREMENT - /* Opcode: MemMax P1 P2 * * * -** -** P1 is a register in the root frame of this VM (the root frame is -** different from the current frame if this instruction is being executed -** within a sub-program). Set the value of register P1 to the maximum of -** its current value and the value in register P2. -** -** This instruction throws an error if the memory cell is not initially -** an integer. -*/ - case OP_MemMax: - { /* in2 */ - Mem _pIn1; - VdbeFrame pFrame; - if ( p.pFrame != null ) - { - for ( pFrame = p.pFrame; pFrame.pParent != null; pFrame = pFrame.pParent ) - ; - _pIn1 = pFrame.aMem[pOp.p1]; - } - else - { - _pIn1 = aMem[pOp.p1]; - } - Debug.Assert( memIsValid( _pIn1 ) ); - sqlite3VdbeMemIntegerify( _pIn1 ); - pIn2 = aMem[pOp.p2]; - sqlite3VdbeMemIntegerify( pIn2 ); - if ( _pIn1.u.i < pIn2.u.i ) - { - _pIn1.u.i = pIn2.u.i; - } - break; - } -#endif // * SQLITE_OMIT_AUTOINCREMENT */ - - /* Opcode: IfPos P1 P2 * * * -** -** If the value of register P1 is 1 or greater, jump to P2. -** -** It is illegal to use this instruction on a register that does -** not contain an integer. An Debug.Assertion fault will result if you try. -*/ - case OP_IfPos: - { /* jump, in1 */ - pIn1 = aMem[pOp.p1]; - Debug.Assert( ( pIn1.flags & MEM_Int ) != 0 ); - if ( pIn1.u.i > 0 ) - { - pc = pOp.p2 - 1; - } - break; - } - - /* Opcode: IfNeg P1 P2 * * * + /* Opcode: MemMax P1 P2 * * * ** - ** If the value of register P1 is less than zero, jump to P2. + ** P1 is a register in the root frame of this VM (the root frame is + ** different from the current frame if this instruction is being executed + ** within a sub-program). Set the value of register P1 to the maximum of + ** its current value and the value in register P2. ** - ** It is illegal to use this instruction on a register that does - ** not contain an integer. An Debug.Assertion fault will result if you try. + ** This instruction throws an error if the memory cell is not initially + ** an integer. */ - case OP_IfNeg: - { /* jump, in1 */ - pIn1 = aMem[pOp.p1]; - Debug.Assert( ( pIn1.flags & MEM_Int ) != 0 ); - if ( pIn1.u.i < 0 ) - { - pc = pOp.p2 - 1; - } - break; - } + case OP_MemMax: { /* in2 */ + Mem _pIn1; + VdbeFrame pFrame; + if (p.pFrame != null) { + for (pFrame = p.pFrame; pFrame.pParent != null; pFrame = pFrame.pParent) + ; + _pIn1 = pFrame.aMem[pOp.p1]; + } else { + _pIn1 = aMem[pOp.p1]; + } + Debug.Assert(memIsValid(_pIn1)); + sqlite3VdbeMemIntegerify(_pIn1); + pIn2 = aMem[pOp.p2]; + sqlite3VdbeMemIntegerify(pIn2); + if (_pIn1.u.i < pIn2.u.i) { + _pIn1.u.i = pIn2.u.i; + } + break; + } +#endif // * SQLITE_OMIT_AUTOINCREMENT */ - /* Opcode: IfZero P1 P2 P3 * * + /* Opcode: IfPos P1 P2 * * * ** - ** The register P1 must contain an integer. Add literal P3 to the - ** value in register P1. If the result is exactly 0, jump to P2. + ** If the value of register P1 is 1 or greater, jump to P2. ** ** It is illegal to use this instruction on a register that does - ** not contain an integer. An assertion fault will result if you try. + ** not contain an integer. An Debug.Assertion fault will result if you try. */ - case OP_IfZero: - { /* jump, in1 */ - pIn1 = aMem[pOp.p1]; - Debug.Assert( ( pIn1.flags & MEM_Int ) != 0 ); - pIn1.u.i += pOp.p3; - if ( pIn1.u.i == 0 ) - { - pc = pOp.p2 - 1; - } - break; - } + case OP_IfPos: { /* jump, in1 */ + pIn1 = aMem[pOp.p1]; + Debug.Assert((pIn1.flags & MEM_Int) != 0); + if (pIn1.u.i > 0) { + pc = pOp.p2 - 1; + } + break; + } - /* Opcode: AggStep * P2 P3 P4 P5 - ** - ** Execute the step function for an aggregate. The - ** function has P5 arguments. P4 is a pointer to the FuncDef - ** structure that specifies the function. Use register - ** P3 as the accumulator. - ** - ** The P5 arguments are taken from register P2 and its - ** successors. - */ - case OP_AggStep: - { - int n; - int i; - Mem pMem; - Mem pRec; - sqlite3_context ctx = new sqlite3_context(); - sqlite3_value[] apVal; - - n = pOp.p5; - Debug.Assert( n >= 0 ); - //pRec = aMem[pOp.p2]; - apVal = p.apArg; - Debug.Assert( apVal != null || n == 0 ); - for ( i = 0; i < n; i++ )//, pRec++) - { - pRec = aMem[pOp.p2 + i]; - Debug.Assert( memIsValid( pRec ) ); - apVal[i] = pRec; - memAboutToChange( p, pRec ); - sqlite3VdbeMemStoreType( pRec ); - } - ctx.pFunc = pOp.p4.pFunc; - Debug.Assert( pOp.p3 > 0 && pOp.p3 <= p.nMem ); - ctx.pMem = pMem = aMem[pOp.p3]; - pMem.n++; - ctx.s.flags = MEM_Null; - ctx.s.z = null; - //ctx.s.zMalloc = null; - ctx.s.xDel = null; - ctx.s.db = db; - ctx.isError = 0; - ctx.pColl = null; - if ( ( ctx.pFunc.flags & SQLITE_FUNC_NEEDCOLL ) != 0 ) - { - Debug.Assert( pc > 0 );//pOp > p.aOp ); - Debug.Assert( p.aOp[pc - 1].p4type == P4_COLLSEQ ); //pOp[-1].p4type == P4_COLLSEQ ); - Debug.Assert( p.aOp[pc - 1].opcode == OP_CollSeq ); // pOp[-1].opcode == OP_CollSeq ); - ctx.pColl = p.aOp[pc - 1].p4.pColl; - ;// pOp[-1].p4.pColl; - } - ctx.pFunc.xStep( ctx, n, apVal ); /* IMP: R-24505-23230 */ - if ( ctx.isError != 0 ) - { - sqlite3SetString( ref p.zErrMsg, db, sqlite3_value_text( ctx.s ) ); - rc = ctx.isError; - } - sqlite3VdbeMemRelease( ctx.s ); - break; - } + /* Opcode: IfNeg P1 P2 * * * + ** + ** If the value of register P1 is less than zero, jump to P2. + ** + ** It is illegal to use this instruction on a register that does + ** not contain an integer. An Debug.Assertion fault will result if you try. + */ + case OP_IfNeg: { /* jump, in1 */ + pIn1 = aMem[pOp.p1]; + Debug.Assert((pIn1.flags & MEM_Int) != 0); + if (pIn1.u.i < 0) { + pc = pOp.p2 - 1; + } + break; + } - /* Opcode: AggFinal P1 P2 * P4 * - ** - ** Execute the finalizer function for an aggregate. P1 is - ** the memory location that is the accumulator for the aggregate. - ** - ** P2 is the number of arguments that the step function takes and - ** P4 is a pointer to the FuncDef for this function. The P2 - ** argument is not used by this opcode. It is only there to disambiguate - ** functions that can take varying numbers of arguments. The - ** P4 argument is only needed for the degenerate case where - ** the step function was not previously called. - */ - case OP_AggFinal: - { - Mem pMem; - Debug.Assert( pOp.p1 > 0 && pOp.p1 <= p.nMem ); - pMem = aMem[pOp.p1]; - Debug.Assert( ( pMem.flags & ~( MEM_Null | MEM_Agg ) ) == 0 ); - rc = sqlite3VdbeMemFinalize( pMem, pOp.p4.pFunc ); - p.aMem[pOp.p1] = pMem; - if ( rc != 0 ) - { - sqlite3SetString( ref p.zErrMsg, db, sqlite3_value_text( pMem ) ); - } - sqlite3VdbeChangeEncoding( pMem, encoding ); + /* Opcode: IfZero P1 P2 P3 * * + ** + ** The register P1 must contain an integer. Add literal P3 to the + ** value in register P1. If the result is exactly 0, jump to P2. + ** + ** It is illegal to use this instruction on a register that does + ** not contain an integer. An assertion fault will result if you try. + */ + case OP_IfZero: { /* jump, in1 */ + pIn1 = aMem[pOp.p1]; + Debug.Assert((pIn1.flags & MEM_Int) != 0); + pIn1.u.i += pOp.p3; + if (pIn1.u.i == 0) { + pc = pOp.p2 - 1; + } + break; + } + + /* Opcode: AggStep * P2 P3 P4 P5 + ** + ** Execute the step function for an aggregate. The + ** function has P5 arguments. P4 is a pointer to the FuncDef + ** structure that specifies the function. Use register + ** P3 as the accumulator. + ** + ** The P5 arguments are taken from register P2 and its + ** successors. + */ + case OP_AggStep: { + int n; + int i; + Mem pMem; + Mem pRec; + sqlite3_context ctx = new sqlite3_context(); + sqlite3_value[] apVal; + + n = pOp.p5; + Debug.Assert(n >= 0); + //pRec = aMem[pOp.p2]; + apVal = p.apArg; + Debug.Assert(apVal != null || n == 0); + for (i = 0; i < n; i++)//, pRec++) + { + pRec = aMem[pOp.p2 + i]; + Debug.Assert(memIsValid(pRec)); + apVal[i] = pRec; + memAboutToChange(p, pRec); + sqlite3VdbeMemStoreType(pRec); + } + ctx.pFunc = pOp.p4.pFunc; + Debug.Assert(pOp.p3 > 0 && pOp.p3 <= p.nMem); + ctx.pMem = pMem = aMem[pOp.p3]; + pMem.n++; + ctx.s.flags = MEM_Null; + ctx.s.z = null; + //ctx.s.zMalloc = null; + ctx.s.xDel = null; + ctx.s.db = db; + ctx.isError = 0; + ctx.pColl = null; + if ((ctx.pFunc.flags & SQLITE_FUNC_NEEDCOLL) != 0) { + Debug.Assert(pc > 0);//pOp > p.aOp ); + Debug.Assert(p.aOp[pc - 1].p4type == P4_COLLSEQ); //pOp[-1].p4type == P4_COLLSEQ ); + Debug.Assert(p.aOp[pc - 1].opcode == OP_CollSeq); // pOp[-1].opcode == OP_CollSeq ); + ctx.pColl = p.aOp[pc - 1].p4.pColl; + ;// pOp[-1].p4.pColl; + } + ctx.pFunc.xStep(ctx, n, apVal); /* IMP: R-24505-23230 */ + if (ctx.isError != 0) { + sqlite3SetString(ref p.zErrMsg, db, sqlite3_value_text(ctx.s)); + rc = ctx.isError; + } + sqlite3VdbeMemRelease(ctx.s); + break; + } + + /* Opcode: AggFinal P1 P2 * P4 * + ** + ** Execute the finalizer function for an aggregate. P1 is + ** the memory location that is the accumulator for the aggregate. + ** + ** P2 is the number of arguments that the step function takes and + ** P4 is a pointer to the FuncDef for this function. The P2 + ** argument is not used by this opcode. It is only there to disambiguate + ** functions that can take varying numbers of arguments. The + ** P4 argument is only needed for the degenerate case where + ** the step function was not previously called. + */ + case OP_AggFinal: { + Mem pMem; + Debug.Assert(pOp.p1 > 0 && pOp.p1 <= p.nMem); + pMem = aMem[pOp.p1]; + Debug.Assert((pMem.flags & ~(MEM_Null | MEM_Agg)) == 0); + rc = sqlite3VdbeMemFinalize(pMem, pOp.p4.pFunc); + p.aMem[pOp.p1] = pMem; + if (rc != 0) { + sqlite3SetString(ref p.zErrMsg, db, sqlite3_value_text(pMem)); + } + sqlite3VdbeChangeEncoding(pMem, encoding); #if SQLITE_TEST UPDATE_MAX_BLOBSIZE( pMem ); #endif - if ( sqlite3VdbeMemTooBig( pMem ) ) - { - goto too_big; - } - break; - } + if (sqlite3VdbeMemTooBig(pMem)) { + goto too_big; + } + break; + } #if !SQLITE_OMIT_WAL @@ -6294,43 +5657,42 @@ Vdbe p /* The VDBE */ #endif #if !SQLITE_OMIT_PRAGMA - /* Opcode: JournalMode P1 P2 P3 * P5 -** -** Change the journal mode of database P1 to P3. P3 must be one of the -** PAGER_JOURNALMODE_XXX values. If changing between the various rollback -** modes (delete, truncate, persist, off and memory), this is a simple -** operation. No IO is required. -** -** If changing into or out of WAL mode the procedure is more complicated. -** -** Write a string containing the final journal-mode to register P2. -*/ - case OP_JournalMode: - { /* out2-prerelease */ - Btree pBt; /* Btree to change journal mode of */ - Pager pPager; /* Pager associated with pBt */ - int eNew; /* New journal mode */ - int eOld; /* The old journal mode */ - string zFilename; /* Name of database file for pPager */ - - eNew = pOp.p3; - Debug.Assert( eNew == PAGER_JOURNALMODE_DELETE - || eNew == PAGER_JOURNALMODE_TRUNCATE - || eNew == PAGER_JOURNALMODE_PERSIST - || eNew == PAGER_JOURNALMODE_OFF - || eNew == PAGER_JOURNALMODE_MEMORY - || eNew == PAGER_JOURNALMODE_WAL - || eNew == PAGER_JOURNALMODE_QUERY - ); - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < db.nDb ); - - pBt = db.aDb[pOp.p1].pBt; - pPager = sqlite3BtreePager( pBt ); - eOld = sqlite3PagerGetJournalMode( pPager ); - if ( eNew == PAGER_JOURNALMODE_QUERY ) - eNew = eOld; - if ( 0 == sqlite3PagerOkToChangeJournalMode( pPager ) ) - eNew = eOld; + /* Opcode: JournalMode P1 P2 P3 * P5 + ** + ** Change the journal mode of database P1 to P3. P3 must be one of the + ** PAGER_JOURNALMODE_XXX values. If changing between the various rollback + ** modes (delete, truncate, persist, off and memory), this is a simple + ** operation. No IO is required. + ** + ** If changing into or out of WAL mode the procedure is more complicated. + ** + ** Write a string containing the final journal-mode to register P2. + */ + case OP_JournalMode: { /* out2-prerelease */ + Btree pBt; /* Btree to change journal mode of */ + Pager pPager; /* Pager associated with pBt */ + int eNew; /* New journal mode */ + int eOld; /* The old journal mode */ + string zFilename; /* Name of database file for pPager */ + + eNew = pOp.p3; + Debug.Assert(eNew == PAGER_JOURNALMODE_DELETE + || eNew == PAGER_JOURNALMODE_TRUNCATE + || eNew == PAGER_JOURNALMODE_PERSIST + || eNew == PAGER_JOURNALMODE_OFF + || eNew == PAGER_JOURNALMODE_MEMORY + || eNew == PAGER_JOURNALMODE_WAL + || eNew == PAGER_JOURNALMODE_QUERY + ); + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < db.nDb); + + pBt = db.aDb[pOp.p1].pBt; + pPager = sqlite3BtreePager(pBt); + eOld = sqlite3PagerGetJournalMode(pPager); + if (eNew == PAGER_JOURNALMODE_QUERY) + eNew = eOld; + if (0 == sqlite3PagerOkToChangeJournalMode(pPager)) + eNew = eOld; #if !SQLITE_OMIT_WAL zFilename = sqlite3PagerFilename(pPager); @@ -6384,81 +5746,73 @@ Vdbe p /* The VDBE */ } #endif //* ifndef SQLITE_OMIT_WAL */ - if ( rc != 0 ) - { - eNew = eOld; - } - eNew = sqlite3PagerSetJournalMode( pPager, eNew ); - - pOut = aMem[pOp.p2]; - pOut.flags = MEM_Str | MEM_Static | MEM_Term; - pOut.z = sqlite3JournalModename( eNew ); - pOut.n = sqlite3Strlen30( pOut.z ); - pOut.enc = SQLITE_UTF8; - sqlite3VdbeChangeEncoding( pOut, encoding ); - break; - }; + if (rc != 0) { + eNew = eOld; + } + eNew = sqlite3PagerSetJournalMode(pPager, eNew); + + pOut = aMem[pOp.p2]; + pOut.flags = MEM_Str | MEM_Static | MEM_Term; + pOut.z = sqlite3JournalModename(eNew); + pOut.n = sqlite3Strlen30(pOut.z); + pOut.enc = SQLITE_UTF8; + sqlite3VdbeChangeEncoding(pOut, encoding); + break; + }; #endif //* SQLITE_OMIT_PRAGMA */ -#if !SQLITE_OMIT_VACUUM && !SQLITE_OMIT_ATTACH - /* Opcode: Vacuum * * * * * -** -** Vacuum the entire database. This opcode will cause other virtual -** machines to be created and run. It may not be called from within -** a transaction. -*/ - case OP_Vacuum: - { - rc = sqlite3RunVacuum( ref p.zErrMsg, db ); - break; - } +#if !SQLITE_OMIT_VACUUM && !SQLITE_OMIT_ATTACH + /* Opcode: Vacuum * * * * * + ** + ** Vacuum the entire database. This opcode will cause other virtual + ** machines to be created and run. It may not be called from within + ** a transaction. + */ + case OP_Vacuum: { + rc = sqlite3RunVacuum(ref p.zErrMsg, db); + break; + } #endif -#if !SQLITE_OMIT_AUTOVACUUM - /* Opcode: IncrVacuum P1 P2 * * * -** -** Perform a single step of the incremental vacuum procedure on -** the P1 database. If the vacuum has finished, jump to instruction -** P2. Otherwise, fall through to the next instruction. -*/ - case OP_IncrVacuum: - { /* jump */ - Btree pBt; - - Debug.Assert( pOp.p1 >= 0 && pOp.p1 < db.nDb ); - Debug.Assert( ( p.btreeMask & ( ( (yDbMask)1 ) << pOp.p1 ) ) != 0 ); - pBt = db.aDb[pOp.p1].pBt; - rc = sqlite3BtreeIncrVacuum( pBt ); - if ( rc == SQLITE_DONE ) - { - pc = pOp.p2 - 1; - rc = SQLITE_OK; - } - break; - } +#if !SQLITE_OMIT_AUTOVACUUM + /* Opcode: IncrVacuum P1 P2 * * * + ** + ** Perform a single step of the incremental vacuum procedure on + ** the P1 database. If the vacuum has finished, jump to instruction + ** P2. Otherwise, fall through to the next instruction. + */ + case OP_IncrVacuum: { /* jump */ + Btree pBt; + + Debug.Assert(pOp.p1 >= 0 && pOp.p1 < db.nDb); + Debug.Assert((p.btreeMask & (((yDbMask)1) << pOp.p1)) != 0); + pBt = db.aDb[pOp.p1].pBt; + rc = sqlite3BtreeIncrVacuum(pBt); + if (rc == SQLITE_DONE) { + pc = pOp.p2 - 1; + rc = SQLITE_OK; + } + break; + } #endif - /* Opcode: Expire P1 * * * * -** -** Cause precompiled statements to become expired. An expired statement -** fails with an error code of SQLITE_SCHEMA if it is ever executed -** (via sqlite3_step()). -** -** If P1 is 0, then all SQL statements become expired. If P1 is non-zero, -** then only the currently executing statement is affected. -*/ - case OP_Expire: - { - if ( pOp.p1 == 0 ) - { - sqlite3ExpirePreparedStatements( db ); - } - else - { - p.expired = true; - } - break; - } + /* Opcode: Expire P1 * * * * + ** + ** Cause precompiled statements to become expired. An expired statement + ** fails with an error code of SQLITE_SCHEMA if it is ever executed + ** (via sqlite3_step()). + ** + ** If P1 is 0, then all SQL statements become expired. If P1 is non-zero, + ** then only the currently executing statement is affected. + */ + case OP_Expire: { + if (pOp.p1 == 0) { + sqlite3ExpirePreparedStatements(db); + } else { + p.expired = true; + } + break; + } #if !SQLITE_OMIT_SHARED_CACHE /* Opcode: TableLock P1 P2 P3 P4 * @@ -6495,586 +5849,543 @@ Vdbe p /* The VDBE */ #endif // * SQLITE_OMIT_SHARED_CACHE */ #if !SQLITE_OMIT_VIRTUALTABLE - /* Opcode: VBegin * * * P4 * -** -** P4 may be a pointer to an sqlite3_vtab structure. If so, call the -** xBegin method for that table. -** -** Also, whether or not P4 is set, check that this is not being called from -** within a callback to a virtual table xSync() method. If it is, the error -** code will be set to SQLITE_LOCKED. -*/ - case OP_VBegin: - { - VTable pVTab; - pVTab = pOp.p4.pVtab; - rc = sqlite3VtabBegin( db, pVTab ); - if ( pVTab != null ) - importVtabErrMsg( p, pVTab.pVtab ); - break; - } + /* Opcode: VBegin * * * P4 * + ** + ** P4 may be a pointer to an sqlite3_vtab structure. If so, call the + ** xBegin method for that table. + ** + ** Also, whether or not P4 is set, check that this is not being called from + ** within a callback to a virtual table xSync() method. If it is, the error + ** code will be set to SQLITE_LOCKED. + */ + case OP_VBegin: { + VTable pVTab; + pVTab = pOp.p4.pVtab; + rc = sqlite3VtabBegin(db, pVTab); + if (pVTab != null) + importVtabErrMsg(p, pVTab.pVtab); + break; + } #endif //* SQLITE_OMIT_VIRTUALTABLE */ #if !SQLITE_OMIT_VIRTUALTABLE - /* Opcode: VCreate P1 * * P4 * -** -** P4 is the name of a virtual table in database P1. Call the xCreate method -** for that table. -*/ - case OP_VCreate: - { - rc = sqlite3VtabCallCreate( db, pOp.p1, pOp.p4.z, ref p.zErrMsg ); - break; - } + /* Opcode: VCreate P1 * * P4 * + ** + ** P4 is the name of a virtual table in database P1. Call the xCreate method + ** for that table. + */ + case OP_VCreate: { + rc = sqlite3VtabCallCreate(db, pOp.p1, pOp.p4.z, ref p.zErrMsg); + break; + } #endif //* SQLITE_OMIT_VIRTUALTABLE */ #if !SQLITE_OMIT_VIRTUALTABLE - /* Opcode: VDestroy P1 * * P4 * -** -** P4 is the name of a virtual table in database P1. Call the xDestroy method -** of that table. -*/ - case OP_VDestroy: - { - p.inVtabMethod = 2; - rc = sqlite3VtabCallDestroy( db, pOp.p1, pOp.p4.z ); - p.inVtabMethod = 0; - break; - } + /* Opcode: VDestroy P1 * * P4 * + ** + ** P4 is the name of a virtual table in database P1. Call the xDestroy method + ** of that table. + */ + case OP_VDestroy: { + p.inVtabMethod = 2; + rc = sqlite3VtabCallDestroy(db, pOp.p1, pOp.p4.z); + p.inVtabMethod = 0; + break; + } #endif //* SQLITE_OMIT_VIRTUALTABLE */ #if !SQLITE_OMIT_VIRTUALTABLE - /* Opcode: VOpen P1 * * P4 * -** -** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. -** P1 is a cursor number. This opcode opens a cursor to the virtual -** table and stores that cursor in P1. -*/ - case OP_VOpen: - { - VdbeCursor pCur; - sqlite3_vtab_cursor pVtabCursor; - sqlite3_vtab pVtab; - sqlite3_module pModule; - - pCur = null; - pVtab = pOp.p4.pVtab.pVtab; - pModule = (sqlite3_module)pVtab.pModule; - Debug.Assert( pVtab != null && pModule != null ); - rc = pModule.xOpen( pVtab, out pVtabCursor ); - importVtabErrMsg( p, pVtab ); - if ( SQLITE_OK == rc ) - { - /* Initialize sqlite3_vtab_cursor base class */ - pVtabCursor.pVtab = pVtab; - - /* Initialise vdbe cursor object */ - pCur = allocateCursor( p, pOp.p1, 0, -1, 0 ); - if ( pCur != null ) - { - pCur.pVtabCursor = pVtabCursor; - pCur.pModule = pVtabCursor.pVtab.pModule; - } - else - { - //db.mallocFailed = 1; - pModule.xClose( ref pVtabCursor ); - } - } - break; - } + /* Opcode: VOpen P1 * * P4 * + ** + ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. + ** P1 is a cursor number. This opcode opens a cursor to the virtual + ** table and stores that cursor in P1. + */ + case OP_VOpen: { + VdbeCursor pCur; + sqlite3_vtab_cursor pVtabCursor; + sqlite3_vtab pVtab; + sqlite3_module pModule; + + pCur = null; + pVtab = pOp.p4.pVtab.pVtab; + pModule = (sqlite3_module)pVtab.pModule; + Debug.Assert(pVtab != null && pModule != null); + rc = pModule.xOpen(pVtab, out pVtabCursor); + importVtabErrMsg(p, pVtab); + if (SQLITE_OK == rc) { + /* Initialize sqlite3_vtab_cursor base class */ + pVtabCursor.pVtab = pVtab; + + /* Initialise vdbe cursor object */ + pCur = allocateCursor(p, pOp.p1, 0, -1, 0); + if (pCur != null) { + pCur.pVtabCursor = pVtabCursor; + pCur.pModule = pVtabCursor.pVtab.pModule; + } else { + //db.mallocFailed = 1; + pModule.xClose(ref pVtabCursor); + } + } + break; + } #endif //* SQLITE_OMIT_VIRTUALTABLE */ #if !SQLITE_OMIT_VIRTUALTABLE - /* Opcode: VFilter P1 P2 P3 P4 * -** -** P1 is a cursor opened using VOpen. P2 is an address to jump to if -** the filtered result set is empty. -** -** P4 is either NULL or a string that was generated by the xBestIndex -** method of the module. The interpretation of the P4 string is left -** to the module implementation. -** -** This opcode invokes the xFilter method on the virtual table specified -** by P1. The integer query plan parameter to xFilter is stored in register -** P3. Register P3+1 stores the argc parameter to be passed to the -** xFilter method. Registers P3+2..P3+1+argc are the argc -** additional parameters which are passed to -** xFilter as argv. Register P3+2 becomes argv[0] when passed to xFilter. -** -** A jump is made to P2 if the result set after filtering would be empty. -*/ - case OP_VFilter: - { /* jump */ - int nArg; - int iQuery; - sqlite3_module pModule; - Mem pQuery; - Mem pArgc = null; - sqlite3_vtab_cursor pVtabCursor; - sqlite3_vtab pVtab; - VdbeCursor pCur; - int res; - int i; - Mem[] apArg; - - pQuery = aMem[pOp.p3]; - pArgc = aMem[pOp.p3 + 1];// pQuery[1]; - pCur = p.apCsr[pOp.p1]; - Debug.Assert( memIsValid( pQuery ) ); - REGISTER_TRACE( p, pOp.p3, pQuery ); - Debug.Assert( pCur.pVtabCursor != null ); - pVtabCursor = pCur.pVtabCursor; - pVtab = pVtabCursor.pVtab; - pModule = pVtab.pModule; - - /* Grab the index number and argc parameters */ - Debug.Assert( ( pQuery.flags & MEM_Int ) != 0 && pArgc.flags == MEM_Int ); - nArg = (int)pArgc.u.i; - iQuery = (int)pQuery.u.i; - - /* Invoke the xFilter method */ - { - res = 0; - apArg = p.apArg; - for ( i = 0; i < nArg; i++ ) - { - apArg[i] = aMem[(pOp.p3 + 1) + i + 1];//apArg[i] = pArgc[i + 1]; - sqlite3VdbeMemStoreType( apArg[i] ); - } - - p.inVtabMethod = 1; - rc = pModule.xFilter( pVtabCursor, iQuery, pOp.p4.z, nArg, apArg ); - p.inVtabMethod = 0; - importVtabErrMsg( p, pVtab ); - if ( rc == SQLITE_OK ) - { - res = pModule.xEof( pVtabCursor ); - } - - if ( res != 0 ) - { - pc = pOp.p2 - 1; - } - } - pCur.nullRow = false; - break; - } + /* Opcode: VFilter P1 P2 P3 P4 * + ** + ** P1 is a cursor opened using VOpen. P2 is an address to jump to if + ** the filtered result set is empty. + ** + ** P4 is either NULL or a string that was generated by the xBestIndex + ** method of the module. The interpretation of the P4 string is left + ** to the module implementation. + ** + ** This opcode invokes the xFilter method on the virtual table specified + ** by P1. The integer query plan parameter to xFilter is stored in register + ** P3. Register P3+1 stores the argc parameter to be passed to the + ** xFilter method. Registers P3+2..P3+1+argc are the argc + ** additional parameters which are passed to + ** xFilter as argv. Register P3+2 becomes argv[0] when passed to xFilter. + ** + ** A jump is made to P2 if the result set after filtering would be empty. + */ + case OP_VFilter: { /* jump */ + int nArg; + int iQuery; + sqlite3_module pModule; + Mem pQuery; + Mem pArgc = null; + sqlite3_vtab_cursor pVtabCursor; + sqlite3_vtab pVtab; + VdbeCursor pCur; + int res; + int i; + Mem[] apArg; + + pQuery = aMem[pOp.p3]; + pArgc = aMem[pOp.p3 + 1];// pQuery[1]; + pCur = p.apCsr[pOp.p1]; + Debug.Assert(memIsValid(pQuery)); + REGISTER_TRACE(p, pOp.p3, pQuery); + Debug.Assert(pCur.pVtabCursor != null); + pVtabCursor = pCur.pVtabCursor; + pVtab = pVtabCursor.pVtab; + pModule = pVtab.pModule; + + /* Grab the index number and argc parameters */ + Debug.Assert((pQuery.flags & MEM_Int) != 0 && pArgc.flags == MEM_Int); + nArg = (int)pArgc.u.i; + iQuery = (int)pQuery.u.i; + + /* Invoke the xFilter method */ + { + res = 0; + apArg = p.apArg; + for (i = 0; i < nArg; i++) { + apArg[i] = aMem[(pOp.p3 + 1) + i + 1];//apArg[i] = pArgc[i + 1]; + sqlite3VdbeMemStoreType(apArg[i]); + } + + p.inVtabMethod = 1; + rc = pModule.xFilter(pVtabCursor, iQuery, pOp.p4.z, nArg, apArg); + p.inVtabMethod = 0; + importVtabErrMsg(p, pVtab); + if (rc == SQLITE_OK) { + res = pModule.xEof(pVtabCursor); + } + + if (res != 0) { + pc = pOp.p2 - 1; + } + } + pCur.nullRow = false; + break; + } #endif //* SQLITE_OMIT_VIRTUALTABLE */ #if !SQLITE_OMIT_VIRTUALTABLE - /* Opcode: VColumn P1 P2 P3 * * -** -** Store the value of the P2-th column of -** the row of the virtual-table that the -** P1 cursor is pointing to into register P3. -*/ - case OP_VColumn: - { - sqlite3_vtab pVtab; - sqlite3_module pModule; - Mem pDest; - sqlite3_context sContext; - - VdbeCursor pCur = p.apCsr[pOp.p1]; - Debug.Assert( pCur.pVtabCursor != null ); - Debug.Assert( pOp.p3 > 0 && pOp.p3 <= p.nMem ); - pDest = aMem[pOp.p3]; - memAboutToChange( p, pDest ); - if ( pCur.nullRow ) - { - sqlite3VdbeMemSetNull( pDest ); - break; - } - pVtab = pCur.pVtabCursor.pVtab; - pModule = pVtab.pModule; - Debug.Assert( pModule.xColumn != null ); - sContext = new sqlite3_context();//memset( &sContext, 0, sizeof( sContext ) ); - - /* The output cell may already have a buffer allocated. Move - ** the current contents to sContext.s so in case the user-function - ** can use the already allocated buffer instead of allocating a - ** new one. - */ - sqlite3VdbeMemMove( sContext.s, pDest ); - MemSetTypeFlag( sContext.s, MEM_Null ); - - rc = pModule.xColumn( pCur.pVtabCursor, sContext, pOp.p2 ); - importVtabErrMsg( p, pVtab ); - - if ( sContext.isError != 0 ) - { - rc = sContext.isError; - } - - /* Copy the result of the function to the P3 register. We - ** do this regardless of whether or not an error occurred to ensure any - ** dynamic allocation in sContext.s (a Mem struct) is released. - */ - sqlite3VdbeChangeEncoding( sContext.s, encoding ); - sqlite3VdbeMemMove( pDest, sContext.s ); - REGISTER_TRACE( p, pOp.p3, pDest ); - UPDATE_MAX_BLOBSIZE( pDest ); - if ( sqlite3VdbeMemTooBig( pDest ) ) - { - goto too_big; - } - break; - } + /* Opcode: VColumn P1 P2 P3 * * + ** + ** Store the value of the P2-th column of + ** the row of the virtual-table that the + ** P1 cursor is pointing to into register P3. + */ + case OP_VColumn: { + sqlite3_vtab pVtab; + sqlite3_module pModule; + Mem pDest; + sqlite3_context sContext; + + VdbeCursor pCur = p.apCsr[pOp.p1]; + Debug.Assert(pCur.pVtabCursor != null); + Debug.Assert(pOp.p3 > 0 && pOp.p3 <= p.nMem); + pDest = aMem[pOp.p3]; + memAboutToChange(p, pDest); + if (pCur.nullRow) { + sqlite3VdbeMemSetNull(pDest); + break; + } + pVtab = pCur.pVtabCursor.pVtab; + pModule = pVtab.pModule; + Debug.Assert(pModule.xColumn != null); + sContext = new sqlite3_context();//memset( &sContext, 0, sizeof( sContext ) ); + + /* The output cell may already have a buffer allocated. Move + ** the current contents to sContext.s so in case the user-function + ** can use the already allocated buffer instead of allocating a + ** new one. + */ + sqlite3VdbeMemMove(sContext.s, pDest); + MemSetTypeFlag(sContext.s, MEM_Null); + + rc = pModule.xColumn(pCur.pVtabCursor, sContext, pOp.p2); + importVtabErrMsg(p, pVtab); + + if (sContext.isError != 0) { + rc = sContext.isError; + } + + /* Copy the result of the function to the P3 register. We + ** do this regardless of whether or not an error occurred to ensure any + ** dynamic allocation in sContext.s (a Mem struct) is released. + */ + sqlite3VdbeChangeEncoding(sContext.s, encoding); + sqlite3VdbeMemMove(pDest, sContext.s); + REGISTER_TRACE(p, pOp.p3, pDest); + UPDATE_MAX_BLOBSIZE(pDest); + if (sqlite3VdbeMemTooBig(pDest)) { + goto too_big; + } + break; + } #endif //* SQLITE_OMIT_VIRTUALTABLE */ #if !SQLITE_OMIT_VIRTUALTABLE - /* Opcode: VNext P1 P2 * * * -** -** Advance virtual table P1 to the next row in its result set and -** jump to instruction P2. Or, if the virtual table has reached -** the end of its result set, then fall through to the next instruction. -*/ - case OP_VNext: - { /* jump */ - sqlite3_vtab pVtab; - sqlite3_module pModule; - int res; - VdbeCursor pCur; - - res = 0; - pCur = p.apCsr[pOp.p1]; - Debug.Assert( pCur.pVtabCursor != null ); - if ( pCur.nullRow ) - { - break; - } - pVtab = pCur.pVtabCursor.pVtab; - pModule = pVtab.pModule; - Debug.Assert( pModule.xNext != null ); - - /* Invoke the xNext() method of the module. There is no way for the - ** underlying implementation to return an error if one occurs during - ** xNext(). Instead, if an error occurs, true is returned (indicating that - ** data is available) and the error code returned when xColumn or - ** some other method is next invoked on the save virtual table cursor. - */ - p.inVtabMethod = 1; - rc = pModule.xNext( pCur.pVtabCursor ); - p.inVtabMethod = 0; - importVtabErrMsg( p, pVtab ); - if ( rc == SQLITE_OK ) - { - res = pModule.xEof( pCur.pVtabCursor ); - } - - if ( 0 == res ) - { - /* If there is data, jump to P2 */ - pc = pOp.p2 - 1; - } - break; - } + /* Opcode: VNext P1 P2 * * * + ** + ** Advance virtual table P1 to the next row in its result set and + ** jump to instruction P2. Or, if the virtual table has reached + ** the end of its result set, then fall through to the next instruction. + */ + case OP_VNext: { /* jump */ + sqlite3_vtab pVtab; + sqlite3_module pModule; + int res; + VdbeCursor pCur; + + res = 0; + pCur = p.apCsr[pOp.p1]; + Debug.Assert(pCur.pVtabCursor != null); + if (pCur.nullRow) { + break; + } + pVtab = pCur.pVtabCursor.pVtab; + pModule = pVtab.pModule; + Debug.Assert(pModule.xNext != null); + + /* Invoke the xNext() method of the module. There is no way for the + ** underlying implementation to return an error if one occurs during + ** xNext(). Instead, if an error occurs, true is returned (indicating that + ** data is available) and the error code returned when xColumn or + ** some other method is next invoked on the save virtual table cursor. + */ + p.inVtabMethod = 1; + rc = pModule.xNext(pCur.pVtabCursor); + p.inVtabMethod = 0; + importVtabErrMsg(p, pVtab); + if (rc == SQLITE_OK) { + res = pModule.xEof(pCur.pVtabCursor); + } + + if (0 == res) { + /* If there is data, jump to P2 */ + pc = pOp.p2 - 1; + } + break; + } #endif //* SQLITE_OMIT_VIRTUALTABLE */ #if !SQLITE_OMIT_VIRTUALTABLE - /* Opcode: VRename P1 * * P4 * -** -** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. -** This opcode invokes the corresponding xRename method. The value -** in register P1 is passed as the zName argument to the xRename method. -*/ - case OP_VRename: - { - sqlite3_vtab pVtab; - Mem pName; - - pVtab = pOp.p4.pVtab.pVtab; - pName = aMem[pOp.p1]; - Debug.Assert( pVtab.pModule.xRename != null ); - Debug.Assert( memIsValid( pName ) ); - REGISTER_TRACE( p, pOp.p1, pName ); - Debug.Assert( ( pName.flags & MEM_Str ) != 0 ); - rc = pVtab.pModule.xRename( pVtab, pName.z ); - importVtabErrMsg( p, pVtab ); - p.expired = false; - break; - } + /* Opcode: VRename P1 * * P4 * + ** + ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. + ** This opcode invokes the corresponding xRename method. The value + ** in register P1 is passed as the zName argument to the xRename method. + */ + case OP_VRename: { + sqlite3_vtab pVtab; + Mem pName; + + pVtab = pOp.p4.pVtab.pVtab; + pName = aMem[pOp.p1]; + Debug.Assert(pVtab.pModule.xRename != null); + Debug.Assert(memIsValid(pName)); + REGISTER_TRACE(p, pOp.p1, pName); + Debug.Assert((pName.flags & MEM_Str) != 0); + rc = pVtab.pModule.xRename(pVtab, pName.z); + importVtabErrMsg(p, pVtab); + p.expired = false; + break; + } #endif #if !SQLITE_OMIT_VIRTUALTABLE - /* Opcode: VUpdate P1 P2 P3 P4 * -** -** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. -** This opcode invokes the corresponding xUpdate method. P2 values -** are contiguous memory cells starting at P3 to pass to the xUpdate -** invocation. The value in register (P3+P2-1) corresponds to the -** p2th element of the argv array passed to xUpdate. -** -** The xUpdate method will do a DELETE or an INSERT or both. -** The argv[0] element (which corresponds to memory cell P3) -** is the rowid of a row to delete. If argv[0] is NULL then no -** deletion occurs. The argv[1] element is the rowid of the new -** row. This can be NULL to have the virtual table select the new -** rowid for itself. The subsequent elements in the array are -** the values of columns in the new row. -** -** If P2==1 then no insert is performed. argv[0] is the rowid of -** a row to delete. -** -** P1 is a boolean flag. If it is set to true and the xUpdate call -** is successful, then the value returned by sqlite3_last_insert_rowid() -** is set to the value of the rowid for the row just inserted. -*/ - case OP_VUpdate: - { - sqlite3_vtab pVtab; - sqlite3_module pModule; - int nArg; - int i; - sqlite_int64 rowid = 0; - Mem[] apArg; - Mem pX; - - Debug.Assert( pOp.p2 == 1 || pOp.p5 == OE_Fail || pOp.p5 == OE_Rollback - || pOp.p5 == OE_Abort || pOp.p5 == OE_Ignore || pOp.p5 == OE_Replace - ); - pVtab = pOp.p4.pVtab.pVtab; - pModule = (sqlite3_module)pVtab.pModule; - nArg = pOp.p2; - Debug.Assert( pOp.p4type == P4_VTAB ); - if ( ALWAYS( pModule.xUpdate ) ) - { - u8 vtabOnConflict = db.vtabOnConflict; - apArg = p.apArg; - //pX = aMem[pOp.p3]; - for ( i = 0; i < nArg; i++ ) - { - pX = aMem[pOp.p3 + i]; - Debug.Assert( memIsValid( pX ) ); - memAboutToChange( p, pX ); - sqlite3VdbeMemStoreType( pX ); - apArg[i] = pX; - //pX++; - } - db.vtabOnConflict = pOp.p5; - rc = pModule.xUpdate( pVtab, nArg, apArg, out rowid ); - db.vtabOnConflict = vtabOnConflict; - importVtabErrMsg( p, pVtab ); - if ( rc == SQLITE_OK && pOp.p1 != 0 ) - { - Debug.Assert( nArg > 1 && apArg[0] != null && ( apArg[0].flags & MEM_Null ) != 0 ); - db.lastRowid = lastRowid = rowid; - } - if ( rc == SQLITE_CONSTRAINT && pOp.p4.pVtab.bConstraint != 0 ) - { - if ( pOp.p5 == OE_Ignore ) - { - rc = SQLITE_OK; - } - else - { - p.errorAction = pOp.p5 == (u8)OE_Replace ? (u8)OE_Abort : pOp.p5; - } - } - else - { - p.nChange++; - } - } - break; - } + /* Opcode: VUpdate P1 P2 P3 P4 * + ** + ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. + ** This opcode invokes the corresponding xUpdate method. P2 values + ** are contiguous memory cells starting at P3 to pass to the xUpdate + ** invocation. The value in register (P3+P2-1) corresponds to the + ** p2th element of the argv array passed to xUpdate. + ** + ** The xUpdate method will do a DELETE or an INSERT or both. + ** The argv[0] element (which corresponds to memory cell P3) + ** is the rowid of a row to delete. If argv[0] is NULL then no + ** deletion occurs. The argv[1] element is the rowid of the new + ** row. This can be NULL to have the virtual table select the new + ** rowid for itself. The subsequent elements in the array are + ** the values of columns in the new row. + ** + ** If P2==1 then no insert is performed. argv[0] is the rowid of + ** a row to delete. + ** + ** P1 is a boolean flag. If it is set to true and the xUpdate call + ** is successful, then the value returned by sqlite3_last_insert_rowid() + ** is set to the value of the rowid for the row just inserted. + */ + case OP_VUpdate: { + sqlite3_vtab pVtab; + sqlite3_module pModule; + int nArg; + int i; + sqlite_int64 rowid = 0; + Mem[] apArg; + Mem pX; + + Debug.Assert(pOp.p2 == 1 || pOp.p5 == OE_Fail || pOp.p5 == OE_Rollback + || pOp.p5 == OE_Abort || pOp.p5 == OE_Ignore || pOp.p5 == OE_Replace + ); + pVtab = pOp.p4.pVtab.pVtab; + pModule = (sqlite3_module)pVtab.pModule; + nArg = pOp.p2; + Debug.Assert(pOp.p4type == P4_VTAB); + if (ALWAYS(pModule.xUpdate)) { + u8 vtabOnConflict = db.vtabOnConflict; + apArg = p.apArg; + //pX = aMem[pOp.p3]; + for (i = 0; i < nArg; i++) { + pX = aMem[pOp.p3 + i]; + Debug.Assert(memIsValid(pX)); + memAboutToChange(p, pX); + sqlite3VdbeMemStoreType(pX); + apArg[i] = pX; + //pX++; + } + db.vtabOnConflict = pOp.p5; + rc = pModule.xUpdate(pVtab, nArg, apArg, out rowid); + db.vtabOnConflict = vtabOnConflict; + importVtabErrMsg(p, pVtab); + if (rc == SQLITE_OK && pOp.p1 != 0) { + Debug.Assert(nArg > 1 && apArg[0] != null && (apArg[0].flags & MEM_Null) != 0); + db.lastRowid = lastRowid = rowid; + } + if (rc == SQLITE_CONSTRAINT && pOp.p4.pVtab.bConstraint != 0) { + if (pOp.p5 == OE_Ignore) { + rc = SQLITE_OK; + } else { + p.errorAction = pOp.p5 == (u8)OE_Replace ? (u8)OE_Abort : pOp.p5; + } + } else { + p.nChange++; + } + } + break; + } #endif //* SQLITE_OMIT_VIRTUALTABLE */ #if !SQLITE_OMIT_PAGER_PRAGMAS - /* Opcode: Pagecount P1 P2 * * * -** -** Write the current number of pages in database P1 to memory cell P2. -*/ - case OP_Pagecount: - { /* out2-prerelease */ - pOut.u.i = sqlite3BtreeLastPage( db.aDb[pOp.p1].pBt ); - break; - } + /* Opcode: Pagecount P1 P2 * * * + ** + ** Write the current number of pages in database P1 to memory cell P2. + */ + case OP_Pagecount: { /* out2-prerelease */ + pOut.u.i = sqlite3BtreeLastPage(db.aDb[pOp.p1].pBt); + break; + } #endif #if !SQLITE_OMIT_PAGER_PRAGMAS - /* Opcode: MaxPgcnt P1 P2 P3 * * -** -** Try to set the maximum page count for database P1 to the value in P3. -** Do not let the maximum page count fall below the current page count and -** do not change the maximum page count value if P3==0. -** -** Store the maximum page count after the change in register P2. -*/ - case OP_MaxPgcnt: - { /* out2-prerelease */ - i64 newMax; - Btree pBt; - - pBt = db.aDb[pOp.p1].pBt; - newMax = 0; - if ( pOp.p3 != 0 ) - { - newMax = sqlite3BtreeLastPage( pBt ); - if ( newMax < pOp.p3 ) - newMax = pOp.p3; - } - pOut.u.i = (i64)sqlite3BtreeMaxPageCount( pBt, (int)newMax ); - break; - } + /* Opcode: MaxPgcnt P1 P2 P3 * * + ** + ** Try to set the maximum page count for database P1 to the value in P3. + ** Do not let the maximum page count fall below the current page count and + ** do not change the maximum page count value if P3==0. + ** + ** Store the maximum page count after the change in register P2. + */ + case OP_MaxPgcnt: { /* out2-prerelease */ + i64 newMax; + Btree pBt; + + pBt = db.aDb[pOp.p1].pBt; + newMax = 0; + if (pOp.p3 != 0) { + newMax = sqlite3BtreeLastPage(pBt); + if (newMax < pOp.p3) + newMax = pOp.p3; + } + pOut.u.i = (i64)sqlite3BtreeMaxPageCount(pBt, (int)newMax); + break; + } #endif #if !SQLITE_OMIT_TRACE - /* Opcode: Trace * * * P4 * -** -** If tracing is enabled (by the sqlite3_trace()) interface, then -** the UTF-8 string contained in P4 is emitted on the trace callback. -*/ - case OP_Trace: - { - string zTrace; - string z; - - if ( db.xTrace != null && !String.IsNullOrEmpty( zTrace = ( pOp.p4.z != null ? pOp.p4.z : p.zSql ) ) ) - { - z = sqlite3VdbeExpandSql( p, zTrace ); - db.xTrace( db.pTraceArg, z ); - //sqlite3DbFree( db, ref z ); - } + /* Opcode: Trace * * * P4 * + ** + ** If tracing is enabled (by the sqlite3_trace()) interface, then + ** the UTF-8 string contained in P4 is emitted on the trace callback. + */ + case OP_Trace: { + string zTrace; + string z; + + if (db.xTrace != null && !String.IsNullOrEmpty(zTrace = (pOp.p4.z != null ? pOp.p4.z : p.zSql))) { + z = sqlite3VdbeExpandSql(p, zTrace); + db.xTrace(db.pTraceArg, z); + //sqlite3DbFree( db, ref z ); + } #if SQLITE_DEBUG - if ( ( db.flags & SQLITE_SqlTrace ) != 0 - && ( zTrace = ( pOp.p4.z != null ? pOp.p4.z : p.zSql ) ) != "" ) - { - sqlite3DebugPrintf( "SQL-trace: %s\n", zTrace ); - } + if ((db.flags & SQLITE_SqlTrace) != 0 + && (zTrace = (pOp.p4.z != null ? pOp.p4.z : p.zSql)) != "") { + sqlite3DebugPrintf("SQL-trace: %s\n", zTrace); + } #endif // * SQLITE_DEBUG */ - break; - } + break; + } #endif - /* Opcode: Noop * * * * * -** -** Do nothing. This instruction is often useful as a jump -** destination. -*/ - /* - ** The magic Explain opcode are only inserted when explain==2 (which - ** is to say when the EXPLAIN QUERY PLAN syntax is used.) - ** This opcode records information from the optimizer. It is the - ** the same as a no-op. This opcodesnever appears in a real VM program. + /* Opcode: Noop * * * * * + ** + ** Do nothing. This instruction is often useful as a jump + ** destination. */ - default: - { /* This is really OP_Noop and OP_Explain */ - Debug.Assert( pOp.opcode == OP_Noop || pOp.opcode == OP_Explain ); - break; - } + /* + ** The magic Explain opcode are only inserted when explain==2 (which + ** is to say when the EXPLAIN QUERY PLAN syntax is used.) + ** This opcode records information from the optimizer. It is the + ** the same as a no-op. This opcodesnever appears in a real VM program. + */ + default: { /* This is really OP_Noop and OP_Explain */ + Debug.Assert(pOp.opcode == OP_Noop || pOp.opcode == OP_Explain); + break; + } - /***************************************************************************** - ** The cases of the switch statement above this line should all be indented - ** by 6 spaces. But the left-most 6 spaces have been removed to improve the - ** readability. From this point on down, the normal indentation rules are - ** restored. - *****************************************************************************/ - } + /***************************************************************************** + ** The cases of the switch statement above this line should all be indented + ** by 6 spaces. But the left-most 6 spaces have been removed to improve the + ** readability. From this point on down, the normal indentation rules are + ** restored. + *****************************************************************************/ + } #if VDBE_PROFILE { u64 elapsed = sqlite3Hwtime() - start; pOp.cycles += elapsed; pOp.cnt++; -#if FALSE +#if FALSE fprintf(stdout, "%10llu ", elapsed); sqlite3VdbePrintOp(stdout, origPc, aOp[origPc]); #endif } #endif - /* The following code adds nothing to the actual functionality -** of the program. It is only here for testing and debugging. -** On the other hand, it does burn CPU cycles every time through -** the evaluator loop. So we can leave it out when NDEBUG is defined. -*/ + /* The following code adds nothing to the actual functionality + ** of the program. It is only here for testing and debugging. + ** On the other hand, it does burn CPU cycles every time through + ** the evaluator loop. So we can leave it out when NDEBUG is defined. + */ #if !NDEBUG - Debug.Assert( pc >= -1 && pc < p.nOp ); + Debug.Assert(pc >= -1 && pc < p.nOp); #if SQLITE_DEBUG - if ( p.trace != null ) - { - if ( rc != 0 ) - fprintf( p.trace, "rc=%d\n", rc ); - if ( ( pOp.opflags & ( OPFLG_OUT2_PRERELEASE | OPFLG_OUT2 ) ) != 0 ) - { - registerTrace( p.trace, pOp.p2, aMem[pOp.p2] ); - } - if ( ( pOp.opflags & OPFLG_OUT3 ) != 0 ) - { - registerTrace( p.trace, pOp.p3, aMem[pOp.p3] ); - } - } + if (p.trace != null) { + if (rc != 0) + fprintf(p.trace, "rc=%d\n", rc); + if ((pOp.opflags & (OPFLG_OUT2_PRERELEASE | OPFLG_OUT2)) != 0) { + registerTrace(p.trace, pOp.p2, aMem[pOp.p2]); + } + if ((pOp.opflags & OPFLG_OUT3) != 0) { + registerTrace(p.trace, pOp.p3, aMem[pOp.p3]); + } + } #endif // * SQLITE_DEBUG */ #endif // * NDEBUG */ - } /* The end of the for(;;) loop the loops through opcodes */ + } /* The end of the for(;;) loop the loops through opcodes */ - /* If we reach this point, it means that execution is finished with - ** an error of some kind. - */ -vdbe_error_halt: - Debug.Assert( rc != 0 ); - p.rc = rc; - testcase( sqlite3GlobalConfig.xLog != null ); - sqlite3_log( rc, "statement aborts at %d: [%s] %s", - pc, p.zSql, p.zErrMsg ); - sqlite3VdbeHalt( p ); - //if ( rc == SQLITE_IOERR_NOMEM ) db.mallocFailed = 1; - rc = SQLITE_ERROR; - if ( resetSchemaOnFault > 0 ) - { - sqlite3ResetInternalSchema( db, resetSchemaOnFault - 1 ); - } -/* This is the only way out of this procedure. We have to -** release the mutexes on btrees that were acquired at the -** top. */ -vdbe_return: - db.lastRowid = lastRowid; - sqlite3VdbeLeave( p ); - return rc; + /* If we reach this point, it means that execution is finished with + ** an error of some kind. + */ + vdbe_error_halt: + Debug.Assert(rc != 0); + p.rc = rc; + testcase(sqlite3GlobalConfig.xLog != null); + sqlite3_log(rc, "statement aborts at %d: [%s] %s", + pc, p.zSql, p.zErrMsg); + sqlite3VdbeHalt(p); + //if ( rc == SQLITE_IOERR_NOMEM ) db.mallocFailed = 1; + rc = SQLITE_ERROR; + if (resetSchemaOnFault > 0) { + sqlite3ResetInternalSchema(db, resetSchemaOnFault - 1); + } + /* This is the only way out of this procedure. We have to + ** release the mutexes on btrees that were acquired at the + ** top. */ + vdbe_return: + db.lastRowid = lastRowid; + sqlite3VdbeLeave(p); + return rc; /* Jump to here if a string or blob larger than db.aLimit[SQLITE_LIMIT_LENGTH] ** is encountered. */ -too_big: - sqlite3SetString( ref p.zErrMsg, db, "string or blob too big" ); - rc = SQLITE_TOOBIG; - goto vdbe_error_halt; + too_big: + sqlite3SetString(ref p.zErrMsg, db, "string or blob too big"); + rc = SQLITE_TOOBIG; + goto vdbe_error_halt; /* Jump to here if a malloc() fails. */ -no_mem: - //db.mallocFailed = 1; - sqlite3SetString( ref p.zErrMsg, db, "out of memory" ); - rc = SQLITE_NOMEM; - goto vdbe_error_halt; + no_mem: + //db.mallocFailed = 1; + sqlite3SetString(ref p.zErrMsg, db, "out of memory"); + rc = SQLITE_NOMEM; + goto vdbe_error_halt; /* Jump to here for any other kind of fatal error. The "rc" variable ** should hold the error number. */ -abort_due_to_error: - //Debug.Assert( p.zErrMsg); /// Not needed in C# - //if ( db.mallocFailed != 0 ) rc = SQLITE_NOMEM; - if ( rc != SQLITE_IOERR_NOMEM ) - { - sqlite3SetString( ref p.zErrMsg, db, "%s", sqlite3ErrStr( rc ) ); - } - goto vdbe_error_halt; + abort_due_to_error: + //Debug.Assert( p.zErrMsg); /// Not needed in C# + //if ( db.mallocFailed != 0 ) rc = SQLITE_NOMEM; + if (rc != SQLITE_IOERR_NOMEM) { + sqlite3SetString(ref p.zErrMsg, db, "%s", sqlite3ErrStr(rc)); + } + goto vdbe_error_halt; /* Jump to here if the sqlite3_interrupt() API sets the interrupt ** flag. */ -abort_due_to_interrupt: - Debug.Assert( db.u1.isInterrupted ); - rc = SQLITE_INTERRUPT; - p.rc = rc; - sqlite3SetString( ref p.zErrMsg, db, sqlite3ErrStr( rc ) ); - goto vdbe_error_halt; + abort_due_to_interrupt: + Debug.Assert(db.u1.isInterrupted); + rc = SQLITE_INTERRUPT; + p.rc = rc; + sqlite3SetString(ref p.zErrMsg, db, sqlite3ErrStr(rc)); + goto vdbe_error_halt; + } } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/vdbeapi_c.cs b/Src/IronPython.SQLite/c#sqlite/vdbeapi_c.cs index eb1a225ba..f8d7607f5 100644 --- a/Src/IronPython.SQLite/c#sqlite/vdbeapi_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/vdbeapi_c.cs @@ -1,46 +1,43 @@ using System; using System.Diagnostics; using System.Text; + using i64 = System.Int64; +using sqlite3_int64 = System.Int64; using u16 = System.UInt16; using u32 = System.UInt32; -using u64 = System.UInt64; using u8 = System.Byte; -using sqlite3_int64 = System.Int64; -namespace Community.CsharpSqlite -{ - using Op = Sqlite3.VdbeOp; - using sqlite_int64 = System.Int64; - using sqlite3_stmt = Sqlite3.Vdbe; - using sqlite3_value = Sqlite3.Mem; - - public partial class Sqlite3 - { - /* - ** 2004 May 26 - ** - ** 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 contains code use to implement APIs that are part of the - ** VDBE. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include "vdbeInt.h" +namespace Community.CsharpSqlite { + using sqlite_int64 = System.Int64; + using sqlite3_stmt = Sqlite3.Vdbe; + using sqlite3_value = Sqlite3.Mem; + + public partial class Sqlite3 { + /* + ** 2004 May 26 + ** + ** 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 contains code use to implement APIs that are part of the + ** VDBE. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include "vdbeInt.h" #if !SQLITE_OMIT_DEPRECATED /* @@ -58,192 +55,161 @@ static int sqlite3_expired( sqlite3_stmt pStmt ) } #endif - /* -** Check on a Vdbe to make sure it has not been finalized. Log -** an error and return true if it has been finalized (or is otherwise -** invalid). Return false if it is ok. -*/ - static bool vdbeSafety( Vdbe p ) - { - if ( p.db == null ) - { - sqlite3_log( SQLITE_MISUSE, "API called with finalized prepared statement" ); - return true; - } - else - { - return false; - } - } - static bool vdbeSafetyNotNull( Vdbe p ) - { - if ( p == null ) - { - sqlite3_log( SQLITE_MISUSE, "API called with NULL prepared statement" ); - return true; - } - else - { - return vdbeSafety( p ); - } - } - - /* - ** The following routine destroys a virtual machine that is created by - ** the sqlite3_compile() routine. The integer returned is an SQLITE_ - ** success/failure code that describes the result of executing the virtual - ** machine. - ** - ** This routine sets the error code and string returned by - ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16(). + /* + ** Check on a Vdbe to make sure it has not been finalized. Log + ** an error and return true if it has been finalized (or is otherwise + ** invalid). Return false if it is ok. */ - public static int sqlite3_finalize( sqlite3_stmt pStmt ) - { - int rc; - if ( pStmt == null ) - { - /* IMPLEMENTATION-OF: R-57228-12904 Invoking sqlite3_finalize() on a NULL - ** pointer is a harmless no-op. */ - rc = SQLITE_OK; - } - else - { - Vdbe v = pStmt; - sqlite3 db = v.db; -#if SQLITE_THREADSAFE - sqlite3_mutex mutex; + static bool vdbeSafety(Vdbe p) { + if (p.db == null) { + sqlite3_log(SQLITE_MISUSE, "API called with finalized prepared statement"); + return true; + } else { + return false; + } + } + static bool vdbeSafetyNotNull(Vdbe p) { + if (p == null) { + sqlite3_log(SQLITE_MISUSE, "API called with NULL prepared statement"); + return true; + } else { + return vdbeSafety(p); + } + } + + /* + ** The following routine destroys a virtual machine that is created by + ** the sqlite3_compile() routine. The integer returned is an SQLITE_ + ** success/failure code that describes the result of executing the virtual + ** machine. + ** + ** This routine sets the error code and string returned by + ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16(). + */ + public static int sqlite3_finalize(sqlite3_stmt pStmt) { + int rc; + if (pStmt == null) { + /* IMPLEMENTATION-OF: R-57228-12904 Invoking sqlite3_finalize() on a NULL + ** pointer is a harmless no-op. */ + rc = SQLITE_OK; + } else { + Vdbe v = pStmt; + sqlite3 db = v.db; +#if SQLITE_THREADSAFE + sqlite3_mutex mutex; #endif - if ( vdbeSafety( v ) ) - return SQLITE_MISUSE_BKPT(); + if (vdbeSafety(v)) + return SQLITE_MISUSE_BKPT(); #if SQLITE_THREADSAFE - mutex = v.db.mutex; + mutex = v.db.mutex; #endif - sqlite3_mutex_enter( mutex ); - rc = sqlite3VdbeFinalize( ref v ); - rc = sqlite3ApiExit( db, rc ); - sqlite3_mutex_leave( mutex ); - } - return rc; - } + sqlite3_mutex_enter(mutex); + rc = sqlite3VdbeFinalize(ref v); + rc = sqlite3ApiExit(db, rc); + sqlite3_mutex_leave(mutex); + } + return rc; + } - /* - ** Terminate the current execution of an SQL statement and reset it - ** back to its starting state so that it can be reused. A success code from - ** the prior execution is returned. - ** - ** This routine sets the error code and string returned by - ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16(). - */ - public static int sqlite3_reset( sqlite3_stmt pStmt ) - { - int rc; - if ( pStmt == null ) - { - rc = SQLITE_OK; - } - else - { - Vdbe v = (Vdbe)pStmt; - sqlite3_mutex_enter( v.db.mutex ); - rc = sqlite3VdbeReset( v ); - sqlite3VdbeRewind( v ); - Debug.Assert( ( rc & ( v.db.errMask ) ) == rc ); - rc = sqlite3ApiExit( v.db, rc ); - sqlite3_mutex_leave( v.db.mutex ); - } - return rc; - } + /* + ** Terminate the current execution of an SQL statement and reset it + ** back to its starting state so that it can be reused. A success code from + ** the prior execution is returned. + ** + ** This routine sets the error code and string returned by + ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16(). + */ + public static int sqlite3_reset(sqlite3_stmt pStmt) { + int rc; + if (pStmt == null) { + rc = SQLITE_OK; + } else { + Vdbe v = (Vdbe)pStmt; + sqlite3_mutex_enter(v.db.mutex); + rc = sqlite3VdbeReset(v); + sqlite3VdbeRewind(v); + Debug.Assert((rc & (v.db.errMask)) == rc); + rc = sqlite3ApiExit(v.db, rc); + sqlite3_mutex_leave(v.db.mutex); + } + return rc; + } - /* - ** Set all the parameters in the compiled SQL statement to NULL. - */ - public static int sqlite3_clear_bindings( sqlite3_stmt pStmt ) - { - int i; - int rc = SQLITE_OK; - Vdbe p = (Vdbe)pStmt; -#if SQLITE_THREADSAFE - sqlite3_mutex mutex = ( (Vdbe)pStmt ).db.mutex; + /* + ** Set all the parameters in the compiled SQL statement to NULL. + */ + public static int sqlite3_clear_bindings(sqlite3_stmt pStmt) { + int i; + int rc = SQLITE_OK; + Vdbe p = (Vdbe)pStmt; +#if SQLITE_THREADSAFE + sqlite3_mutex mutex = ((Vdbe)pStmt).db.mutex; #endif - sqlite3_mutex_enter( mutex ); - for ( i = 0; i < p.nVar; i++ ) - { - sqlite3VdbeMemRelease( p.aVar[i] ); - p.aVar[i].flags = MEM_Null; - } - if ( p.isPrepareV2 && p.expmask != 0 ) - { - p.expired = true; - } - sqlite3_mutex_leave( mutex ); - return rc; - } + sqlite3_mutex_enter(mutex); + for (i = 0; i < p.nVar; i++) { + sqlite3VdbeMemRelease(p.aVar[i]); + p.aVar[i].flags = MEM_Null; + } + if (p.isPrepareV2 && p.expmask != 0) { + p.expired = true; + } + sqlite3_mutex_leave(mutex); + return rc; + } - /**************************** sqlite3_value_ ******************************* - ** The following routines extract information from a Mem or sqlite3_value - ** structure. - */ - public static byte[] sqlite3_value_blob( sqlite3_value pVal ) - { - Mem p = pVal; - if ( ( p.flags & ( MEM_Blob | MEM_Str ) ) != 0 ) - { - sqlite3VdbeMemExpandBlob( p ); - if ( p.zBLOB == null && p.z != null ) - { - if ( p.z.Length == 0 ) - p.zBLOB = sqlite3Malloc( 1 ); - else - { - p.zBLOB = sqlite3Malloc( p.z.Length ); - Debug.Assert( p.zBLOB.Length == p.z.Length ); - for ( int i = 0; i < p.zBLOB.Length; i++ ) - p.zBLOB[i] = (u8)p.z[i]; - } - p.z = null; - } - p.flags = (u16)( p.flags & ~MEM_Str ); - p.flags |= MEM_Blob; - return p.n > 0 ? p.zBLOB : null; - } - else - { - return sqlite3_value_text( pVal ) == null ? null : Encoding.UTF8.GetBytes( sqlite3_value_text( pVal ) ); - } - } + /**************************** sqlite3_value_ ******************************* + ** The following routines extract information from a Mem or sqlite3_value + ** structure. + */ + public static byte[] sqlite3_value_blob(sqlite3_value pVal) { + Mem p = pVal; + if ((p.flags & (MEM_Blob | MEM_Str)) != 0) { + sqlite3VdbeMemExpandBlob(p); + if (p.zBLOB == null && p.z != null) { + if (p.z.Length == 0) + p.zBLOB = sqlite3Malloc(1); + else { + p.zBLOB = sqlite3Malloc(p.z.Length); + Debug.Assert(p.zBLOB.Length == p.z.Length); + for (int i = 0; i < p.zBLOB.Length; i++) + p.zBLOB[i] = (u8)p.z[i]; + } + p.z = null; + } + p.flags = (u16)(p.flags & ~MEM_Str); + p.flags |= MEM_Blob; + return p.n > 0 ? p.zBLOB : null; + } else { + return sqlite3_value_text(pVal) == null ? null : Encoding.UTF8.GetBytes(sqlite3_value_text(pVal)); + } + } - public static int sqlite3_value_bytes( sqlite3_value pVal ) - { - return sqlite3ValueBytes( pVal, SQLITE_UTF8 ); - } + public static int sqlite3_value_bytes(sqlite3_value pVal) { + return sqlite3ValueBytes(pVal, SQLITE_UTF8); + } - public static int sqlite3_value_bytes16( sqlite3_value pVal ) - { - return sqlite3ValueBytes( pVal, SQLITE_UTF16NATIVE ); - } + public static int sqlite3_value_bytes16(sqlite3_value pVal) { + return sqlite3ValueBytes(pVal, SQLITE_UTF16NATIVE); + } - public static double sqlite3_value_double( sqlite3_value pVal ) - { - return sqlite3VdbeRealValue( pVal ); - } + public static double sqlite3_value_double(sqlite3_value pVal) { + return sqlite3VdbeRealValue(pVal); + } - public static int sqlite3_value_int( sqlite3_value pVal ) - { - return (int)sqlite3VdbeIntValue( pVal ); - } + public static int sqlite3_value_int(sqlite3_value pVal) { + return (int)sqlite3VdbeIntValue(pVal); + } - public static sqlite_int64 sqlite3_value_int64( sqlite3_value pVal ) - { - return sqlite3VdbeIntValue( pVal ); - } + public static sqlite_int64 sqlite3_value_int64(sqlite3_value pVal) { + return sqlite3VdbeIntValue(pVal); + } - public static string sqlite3_value_text( sqlite3_value pVal ) - { - return sqlite3ValueText( pVal, SQLITE_UTF8 ); - } + public static string sqlite3_value_text(sqlite3_value pVal) { + return sqlite3ValueText(pVal, SQLITE_UTF8); + } -#if !SQLITE_OMIT_UTF16 +#if !SQLITE_OMIT_UTF16 public static string sqlite3_value_text16(sqlite3_value pVal){ return sqlite3ValueText(pVal, SQLITE_UTF16NATIVE); } @@ -255,73 +221,65 @@ public static string sqlite3_value_text16le(sqlite3_value pVal){ } #endif // * SQLITE_OMIT_UTF16 */ - public static int sqlite3_value_type( sqlite3_value pval ) - { - return pval.type; - } + public static int sqlite3_value_type(sqlite3_value pval) { + return pval.type; + } - /**************************** sqlite3_result_ ******************************* - ** The following routines are used by user-defined functions to specify - ** the function result. - ** - ** The setStrOrError() funtion calls sqlite3VdbeMemSetStr() to store the - ** result as a string or blob but if the string or blob is too large, it - ** then sets the error code to SQLITE_TOOBIG - */ - static void setResultStrOrError( - sqlite3_context pCtx, /* Function context */ - string z, /* String pointer */ - int o, /* offset into string */ - int n, /* Bytes in string, or negative */ - u8 enc, /* Encoding of z. 0 for BLOBs */ - dxDel xDel //void (*xDel)(void) /* Destructor function */ - ) - { - if ( sqlite3VdbeMemSetStr( pCtx.s, z, o, n, enc, xDel ) == SQLITE_TOOBIG ) - { - sqlite3_result_error_toobig( pCtx ); - } - } - static void setResultStrOrError( - sqlite3_context pCtx, /* Function context */ - string z, /* String pointer */ - int n, /* Bytes in string, or negative */ - u8 enc, /* Encoding of z. 0 for BLOBs */ - dxDel xDel //void (*xDel)(void) /* Destructor function */ - ) - { - if ( sqlite3VdbeMemSetStr( pCtx.s, z, n, enc, xDel ) == SQLITE_TOOBIG ) - { - sqlite3_result_error_toobig( pCtx ); - } - } + /**************************** sqlite3_result_ ******************************* + ** The following routines are used by user-defined functions to specify + ** the function result. + ** + ** The setStrOrError() funtion calls sqlite3VdbeMemSetStr() to store the + ** result as a string or blob but if the string or blob is too large, it + ** then sets the error code to SQLITE_TOOBIG + */ + static void setResultStrOrError( + sqlite3_context pCtx, /* Function context */ + string z, /* String pointer */ + int o, /* offset into string */ + int n, /* Bytes in string, or negative */ + u8 enc, /* Encoding of z. 0 for BLOBs */ + dxDel xDel //void (*xDel)(void) /* Destructor function */ + ) { + if (sqlite3VdbeMemSetStr(pCtx.s, z, o, n, enc, xDel) == SQLITE_TOOBIG) { + sqlite3_result_error_toobig(pCtx); + } + } + static void setResultStrOrError( + sqlite3_context pCtx, /* Function context */ + string z, /* String pointer */ + int n, /* Bytes in string, or negative */ + u8 enc, /* Encoding of z. 0 for BLOBs */ + dxDel xDel //void (*xDel)(void) /* Destructor function */ + ) { + if (sqlite3VdbeMemSetStr(pCtx.s, z, n, enc, xDel) == SQLITE_TOOBIG) { + sqlite3_result_error_toobig(pCtx); + } + } - public static void sqlite3_result_blob( - sqlite3_context pCtx, - string z, - int n, - dxDel xDel - ) - { - Debug.Assert( n >= 0 ); - Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); - setResultStrOrError( pCtx, z, n, 0, xDel ); - } + public static void sqlite3_result_blob( + sqlite3_context pCtx, + string z, + int n, + dxDel xDel + ) { + Debug.Assert(n >= 0); + Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); + setResultStrOrError(pCtx, z, n, 0, xDel); + } - public static void sqlite3_result_double( sqlite3_context pCtx, double rVal ) - { - Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); - sqlite3VdbeMemSetDouble( pCtx.s, rVal ); - } + public static void sqlite3_result_double(sqlite3_context pCtx, double rVal) { + Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); + sqlite3VdbeMemSetDouble(pCtx.s, rVal); + } - public static void sqlite3_result_error( sqlite3_context pCtx, string z, int n ) - { - Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); - setResultStrOrError( pCtx, z, n, SQLITE_UTF8, SQLITE_TRANSIENT ); - pCtx.isError = SQLITE_ERROR; - } + public static void sqlite3_result_error(sqlite3_context pCtx, string z, int n) { + Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); + setResultStrOrError(pCtx, z, n, SQLITE_UTF8, SQLITE_TRANSIENT); + pCtx.isError = SQLITE_ERROR; + } -#if !SQLITE_OMIT_UTF16 +#if !SQLITE_OMIT_UTF16 //void sqlite3_result_error16(sqlite3_context pCtx, string z, int n){ // Debug.Assert( sqlite3_mutex_held(pCtx.s.db.mutex) ); // pCtx.isError = SQLITE_ERROR; @@ -329,59 +287,53 @@ public static void sqlite3_result_error( sqlite3_context pCtx, string z, int n ) //} #endif - public static void sqlite3_result_int( sqlite3_context pCtx, int iVal ) - { - Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); - sqlite3VdbeMemSetInt64( pCtx.s, (i64)iVal ); - } + public static void sqlite3_result_int(sqlite3_context pCtx, int iVal) { + Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); + sqlite3VdbeMemSetInt64(pCtx.s, (i64)iVal); + } - public static void sqlite3_result_int64( sqlite3_context pCtx, i64 iVal ) - { - Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); - sqlite3VdbeMemSetInt64( pCtx.s, iVal ); - } + public static void sqlite3_result_int64(sqlite3_context pCtx, i64 iVal) { + Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); + sqlite3VdbeMemSetInt64(pCtx.s, iVal); + } - public static void sqlite3_result_null( sqlite3_context pCtx ) - { - Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); - sqlite3VdbeMemSetNull( pCtx.s ); - } + public static void sqlite3_result_null(sqlite3_context pCtx) { + Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); + sqlite3VdbeMemSetNull(pCtx.s); + } - public static void sqlite3_result_text( - sqlite3_context pCtx, - string z, - int o, //Offset - int n, - dxDel xDel - ) - { - Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); - setResultStrOrError( pCtx, z, o, n, SQLITE_UTF8, xDel ); - } + public static void sqlite3_result_text( + sqlite3_context pCtx, + string z, + int o, //Offset + int n, + dxDel xDel + ) { + Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); + setResultStrOrError(pCtx, z, o, n, SQLITE_UTF8, xDel); + } - public static void sqlite3_result_text( - sqlite3_context pCtx, - StringBuilder z, - int n, - dxDel xDel - ) - { - Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); - setResultStrOrError( pCtx, z.ToString(), n, SQLITE_UTF8, xDel ); - } + public static void sqlite3_result_text( + sqlite3_context pCtx, + StringBuilder z, + int n, + dxDel xDel + ) { + Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); + setResultStrOrError(pCtx, z.ToString(), n, SQLITE_UTF8, xDel); + } - public static void sqlite3_result_text( - sqlite3_context pCtx, - string z, - int n, - dxDel xDel - ) - { - Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); - setResultStrOrError( pCtx, z, n, SQLITE_UTF8, xDel ); - } -#if !SQLITE_OMIT_UTF16 + public static void sqlite3_result_text( + sqlite3_context pCtx, + string z, + int n, + dxDel xDel + ) { + Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); + setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel); + } +#if !SQLITE_OMIT_UTF16 void sqlite3_result_text16( sqlite3_context pCtx, string z, @@ -411,54 +363,47 @@ dxDel xDel } #endif // * SQLITE_OMIT_UTF16 */ - public static void sqlite3_result_value( sqlite3_context pCtx, sqlite3_value pValue ) - { - Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); - sqlite3VdbeMemCopy( pCtx.s, pValue ); - } + public static void sqlite3_result_value(sqlite3_context pCtx, sqlite3_value pValue) { + Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); + sqlite3VdbeMemCopy(pCtx.s, pValue); + } - public static void sqlite3_result_zeroblob( sqlite3_context pCtx, int n ) - { - Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); - sqlite3VdbeMemSetZeroBlob( pCtx.s, n ); - } + public static void sqlite3_result_zeroblob(sqlite3_context pCtx, int n) { + Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); + sqlite3VdbeMemSetZeroBlob(pCtx.s, n); + } - public static void sqlite3_result_error_code( sqlite3_context pCtx, int errCode ) - { - pCtx.isError = errCode; - if ( ( pCtx.s.flags & MEM_Null ) != 0 ) - { - setResultStrOrError( pCtx, sqlite3ErrStr( errCode ), -1, - SQLITE_UTF8, SQLITE_STATIC ); - } - } + public static void sqlite3_result_error_code(sqlite3_context pCtx, int errCode) { + pCtx.isError = errCode; + if ((pCtx.s.flags & MEM_Null) != 0) { + setResultStrOrError(pCtx, sqlite3ErrStr(errCode), -1, + SQLITE_UTF8, SQLITE_STATIC); + } + } - /* Force an SQLITE_TOOBIG error. */ + /* Force an SQLITE_TOOBIG error. */ - public static void sqlite3_result_error_toobig( sqlite3_context pCtx ) - { - Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); - pCtx.isError = SQLITE_ERROR; - setResultStrOrError( pCtx, "string or blob too big", -1, - SQLITE_UTF8, SQLITE_STATIC ); - } + public static void sqlite3_result_error_toobig(sqlite3_context pCtx) { + Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); + pCtx.isError = SQLITE_ERROR; + setResultStrOrError(pCtx, "string or blob too big", -1, + SQLITE_UTF8, SQLITE_STATIC); + } - /* An SQLITE_NOMEM error. */ - public static void sqlite3_result_error_nomem( sqlite3_context pCtx ) - { - Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); - sqlite3VdbeMemSetNull( pCtx.s ); - pCtx.isError = SQLITE_NOMEM; - //pCtx.s.db.mallocFailed = 1; - } + /* An SQLITE_NOMEM error. */ + public static void sqlite3_result_error_nomem(sqlite3_context pCtx) { + Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); + sqlite3VdbeMemSetNull(pCtx.s); + pCtx.isError = SQLITE_NOMEM; + //pCtx.s.db.mallocFailed = 1; + } - /* - ** This function is called after a transaction has been committed. It - ** invokes callbacks registered with sqlite3_wal_hook() as required. - */ - static int doWalCallbacks( sqlite3 db ) - { - int rc = SQLITE_OK; + /* + ** This function is called after a transaction has been committed. It + ** invokes callbacks registered with sqlite3_wal_hook() as required. + */ + static int doWalCallbacks(sqlite3 db) { + int rc = SQLITE_OK; #if !SQLITE_OMIT_WAL int i; for(i=0; inDb; i++){ @@ -471,41 +416,39 @@ static int doWalCallbacks( sqlite3 db ) } } #endif - return rc; - } - /* - ** Execute the statement pStmt, either until a row of data is ready, the - ** statement is completely executed or an error occurs. - ** - ** This routine implements the bulk of the logic behind the sqlite_step() - ** API. The only thing omitted is the automatic recompile if a - ** schema change has occurred. That detail is handled by the - ** outer sqlite3_step() wrapper procedure. - */ - static int sqlite3Step( Vdbe p ) - { - sqlite3 db; - int rc; - - Debug.Assert( p != null ); - if ( p.magic != VDBE_MAGIC_RUN ) - { - /* We used to require that sqlite3_reset() be called before retrying - ** sqlite3_step() after any error or after SQLITE_DONE. But beginning - ** with version 3.7.0, we changed this so that sqlite3_reset() would - ** be called automatically instead of throwing the SQLITE_MISUSE error. - ** This "automatic-reset" change is not technically an incompatibility, - ** since any application that receives an SQLITE_MISUSE is broken by - ** definition. + return rc; + } + /* + ** Execute the statement pStmt, either until a row of data is ready, the + ** statement is completely executed or an error occurs. ** - ** Nevertheless, some published applications that were originally written - ** for version 3.6.23 or earlier do in fact depend on SQLITE_MISUSE - ** returns, and the so were broken by the automatic-reset change. As a - ** a work-around, the SQLITE_OMIT_AUTORESET compile-time restores the - ** legacy behavior of returning SQLITE_MISUSE for cases where the - ** previous sqlite3_step() returned something other than a SQLITE_LOCKED - ** or SQLITE_BUSY error. + ** This routine implements the bulk of the logic behind the sqlite_step() + ** API. The only thing omitted is the automatic recompile if a + ** schema change has occurred. That detail is handled by the + ** outer sqlite3_step() wrapper procedure. */ + static int sqlite3Step(Vdbe p) { + sqlite3 db; + int rc; + + Debug.Assert(p != null); + if (p.magic != VDBE_MAGIC_RUN) { + /* We used to require that sqlite3_reset() be called before retrying + ** sqlite3_step() after any error or after SQLITE_DONE. But beginning + ** with version 3.7.0, we changed this so that sqlite3_reset() would + ** be called automatically instead of throwing the SQLITE_MISUSE error. + ** This "automatic-reset" change is not technically an incompatibility, + ** since any application that receives an SQLITE_MISUSE is broken by + ** definition. + ** + ** Nevertheless, some published applications that were originally written + ** for version 3.6.23 or earlier do in fact depend on SQLITE_MISUSE + ** returns, and the so were broken by the automatic-reset change. As a + ** a work-around, the SQLITE_OMIT_AUTORESET compile-time restores the + ** legacy behavior of returning SQLITE_MISUSE for cases where the + ** previous sqlite3_step() returned something other than a SQLITE_LOCKED + ** or SQLITE_BUSY error. + */ #if SQLITE_OMIT_AUTORESET if( p.rc==SQLITE_BUSY || p.rc==SQLITE_LOCKED ){ sqlite3_reset((sqlite3_stmt)p); @@ -513,330 +456,298 @@ static int sqlite3Step( Vdbe p ) return SQLITE_MISUSE_BKPT(); } #else - sqlite3_reset( (sqlite3_stmt)p ); + sqlite3_reset((sqlite3_stmt)p); #endif - } - - /* Check that malloc() has not failed. If it has, return early. */ - db = p.db; - //if ( db.mallocFailed != 0 ) - //{ - //p->rc = SQLITE_NOMEM; - // return SQLITE_NOMEM; - //} - - if ( p.pc <= 0 && p.expired ) - { - p.rc = SQLITE_SCHEMA; - rc = SQLITE_ERROR; - goto end_of_step; - } - if ( p.pc < 0 ) - { - /* If there are no other statements currently running, then - ** reset the interrupt flag. This prevents a call to sqlite3_interrupt - ** from interrupting a statement that has not yet started. - */ - if ( db.activeVdbeCnt == 0 ) - { - db.u1.isInterrupted = false; - } + } - Debug.Assert( db.writeVdbeCnt > 0 || db.autoCommit == 0 || db.nDeferredCons == 0 ); -#if !SQLITE_OMIT_TRACE - if ( db.xProfile != null && 0 == db.init.busy ) - { - sqlite3OsCurrentTimeInt64( db.pVfs, ref p.startTime ); - } + /* Check that malloc() has not failed. If it has, return early. */ + db = p.db; + //if ( db.mallocFailed != 0 ) + //{ + //p->rc = SQLITE_NOMEM; + // return SQLITE_NOMEM; + //} + + if (p.pc <= 0 && p.expired) { + p.rc = SQLITE_SCHEMA; + rc = SQLITE_ERROR; + goto end_of_step; + } + if (p.pc < 0) { + /* If there are no other statements currently running, then + ** reset the interrupt flag. This prevents a call to sqlite3_interrupt + ** from interrupting a statement that has not yet started. + */ + if (db.activeVdbeCnt == 0) { + db.u1.isInterrupted = false; + } + + Debug.Assert(db.writeVdbeCnt > 0 || db.autoCommit == 0 || db.nDeferredCons == 0); +#if !SQLITE_OMIT_TRACE + if (db.xProfile != null && 0 == db.init.busy) { + sqlite3OsCurrentTimeInt64(db.pVfs, ref p.startTime); + } #endif - db.activeVdbeCnt++; - if ( p.readOnly == false ) - db.writeVdbeCnt++; - p.pc = 0; - } -#if !SQLITE_OMIT_EXPLAIN - if ( p.explain != 0 ) - { - rc = sqlite3VdbeList( p ); - } - else + db.activeVdbeCnt++; + if (p.readOnly == false) + db.writeVdbeCnt++; + p.pc = 0; + } +#if !SQLITE_OMIT_EXPLAIN + if (p.explain != 0) { + rc = sqlite3VdbeList(p); + } else #endif // * SQLITE_OMIT_EXPLAIN */ - { + { - db.vdbeExecCnt++; - rc = sqlite3VdbeExec( p ); - db.vdbeExecCnt--; - } + db.vdbeExecCnt++; + rc = sqlite3VdbeExec(p); + db.vdbeExecCnt--; + } -#if !SQLITE_OMIT_TRACE - /* Invoke the profile callback if there is one -*/ - if ( rc != SQLITE_ROW && db.xProfile != null && 0 == db.init.busy && p.zSql != null ) - { - sqlite3_int64 iNow = 0; - sqlite3OsCurrentTimeInt64( db.pVfs, ref iNow ); - db.xProfile( db.pProfileArg, p.zSql, ( iNow - p.startTime ) * 1000000 ); - } +#if !SQLITE_OMIT_TRACE + /* Invoke the profile callback if there is one + */ + if (rc != SQLITE_ROW && db.xProfile != null && 0 == db.init.busy && p.zSql != null) { + sqlite3_int64 iNow = 0; + sqlite3OsCurrentTimeInt64(db.pVfs, ref iNow); + db.xProfile(db.pProfileArg, p.zSql, (iNow - p.startTime) * 1000000); + } #endif - if ( rc == SQLITE_DONE ) - { - Debug.Assert( p.rc == SQLITE_OK ); - p.rc = doWalCallbacks( db ); - if ( p.rc != SQLITE_OK ) - { - rc = SQLITE_ERROR; - } - } - - db.errCode = rc; - if ( SQLITE_NOMEM == sqlite3ApiExit( p.db, p.rc ) ) - { - p.rc = SQLITE_NOMEM; - } -end_of_step: - /* At this point local variable rc holds the value that should be - ** returned if this statement was compiled using the legacy - ** sqlite3_prepare() interface. According to the docs, this can only - ** be one of the values in the first Debug.Assert() below. Variable p.rc - ** contains the value that would be returned if sqlite3_finalize() - ** were called on statement p. - */ - Debug.Assert( rc == SQLITE_ROW || rc == SQLITE_DONE || rc == SQLITE_ERROR - || rc == SQLITE_BUSY || rc == SQLITE_MISUSE - ); - Debug.Assert( p.rc != SQLITE_ROW && p.rc != SQLITE_DONE ); - if ( p.isPrepareV2 && rc != SQLITE_ROW && rc != SQLITE_DONE ) - { - /* If this statement was prepared using sqlite3_prepare_v2(), and an - ** error has occured, then return the error code in p.rc to the - ** caller. Set the error code in the database handle to the same value. - */ - rc = db.errCode = p.rc; - } - return ( rc & db.errMask ); - } + if (rc == SQLITE_DONE) { + Debug.Assert(p.rc == SQLITE_OK); + p.rc = doWalCallbacks(db); + if (p.rc != SQLITE_OK) { + rc = SQLITE_ERROR; + } + } -/* -** The maximum number of times that a statement will try to reparse -** itself before giving up and returning SQLITE_SCHEMA. -*/ + db.errCode = rc; + if (SQLITE_NOMEM == sqlite3ApiExit(p.db, p.rc)) { + p.rc = SQLITE_NOMEM; + } + end_of_step: + /* At this point local variable rc holds the value that should be + ** returned if this statement was compiled using the legacy + ** sqlite3_prepare() interface. According to the docs, this can only + ** be one of the values in the first Debug.Assert() below. Variable p.rc + ** contains the value that would be returned if sqlite3_finalize() + ** were called on statement p. + */ + Debug.Assert(rc == SQLITE_ROW || rc == SQLITE_DONE || rc == SQLITE_ERROR + || rc == SQLITE_BUSY || rc == SQLITE_MISUSE + ); + Debug.Assert(p.rc != SQLITE_ROW && p.rc != SQLITE_DONE); + if (p.isPrepareV2 && rc != SQLITE_ROW && rc != SQLITE_DONE) { + /* If this statement was prepared using sqlite3_prepare_v2(), and an + ** error has occured, then return the error code in p.rc to the + ** caller. Set the error code in the database handle to the same value. + */ + rc = db.errCode = p.rc; + } + return (rc & db.errMask); + } + + /* + ** The maximum number of times that a statement will try to reparse + ** itself before giving up and returning SQLITE_SCHEMA. + */ #if !SQLITE_MAX_SCHEMA_RETRY -//# define SQLITE_MAX_SCHEMA_RETRY 5 - public const int SQLITE_MAX_SCHEMA_RETRY = 5; + //# define SQLITE_MAX_SCHEMA_RETRY 5 + public const int SQLITE_MAX_SCHEMA_RETRY = 5; #endif - /* - ** This is the top-level implementation of sqlite3_step(). Call - ** sqlite3Step() to do most of the work. If a schema error occurs, - ** call sqlite3Reprepare() and try again. - */ - public static int sqlite3_step( sqlite3_stmt pStmt ) - { - int rc = SQLITE_OK; /* Result from sqlite3Step() */ - int rc2 = SQLITE_OK; /* Result from sqlite3Reprepare() */ - Vdbe v = (Vdbe)pStmt; /* the prepared statement */ - int cnt = 0; /* Counter to prevent infinite loop of reprepares */ - sqlite3 db; /* The database connection */ - - if ( vdbeSafetyNotNull( v ) ) - { - return SQLITE_MISUSE_BKPT(); - } - db = v.db; - sqlite3_mutex_enter( db.mutex ); - while ( ( rc = sqlite3Step( v ) ) == SQLITE_SCHEMA - && cnt++ < SQLITE_MAX_SCHEMA_RETRY - && ( rc2 = rc = sqlite3Reprepare( v ) ) == SQLITE_OK ) - { - sqlite3_reset( pStmt ); - v.expired = false; - } - if ( rc2 != SQLITE_OK && ALWAYS( v.isPrepareV2 ) && ALWAYS( db.pErr != null ) ) - { - /* This case occurs after failing to recompile an sql statement. - ** The error message from the SQL compiler has already been loaded - ** into the database handle. This block copies the error message - ** from the database handle into the statement and sets the statement - ** program counter to 0 to ensure that when the statement is - ** finalized or reset the parser error message is available via - ** sqlite3_errmsg() and sqlite3_errcode(). + /* + ** This is the top-level implementation of sqlite3_step(). Call + ** sqlite3Step() to do most of the work. If a schema error occurs, + ** call sqlite3Reprepare() and try again. */ - string zErr = sqlite3_value_text( db.pErr ); - sqlite3DbFree( db, ref v.zErrMsg ); - //if ( 0 == db.mallocFailed ) - { - v.zErrMsg = zErr;// sqlite3DbStrDup(db, zErr); - v.rc = rc2; - } - //else - //{ - // v.zErrMsg = ""; - // v->rc = rc = SQLITE_NOMEM; - //} - } - rc = sqlite3ApiExit( db, rc ); - sqlite3_mutex_leave( db.mutex ); - return rc; - } + public static int sqlite3_step(sqlite3_stmt pStmt) { + int rc = SQLITE_OK; /* Result from sqlite3Step() */ + int rc2 = SQLITE_OK; /* Result from sqlite3Reprepare() */ + Vdbe v = (Vdbe)pStmt; /* the prepared statement */ + int cnt = 0; /* Counter to prevent infinite loop of reprepares */ + sqlite3 db; /* The database connection */ + + if (vdbeSafetyNotNull(v)) { + return SQLITE_MISUSE_BKPT(); + } + db = v.db; + sqlite3_mutex_enter(db.mutex); + while ((rc = sqlite3Step(v)) == SQLITE_SCHEMA + && cnt++ < SQLITE_MAX_SCHEMA_RETRY + && (rc2 = rc = sqlite3Reprepare(v)) == SQLITE_OK) { + sqlite3_reset(pStmt); + v.expired = false; + } + if (rc2 != SQLITE_OK && ALWAYS(v.isPrepareV2) && ALWAYS(db.pErr != null)) { + /* This case occurs after failing to recompile an sql statement. + ** The error message from the SQL compiler has already been loaded + ** into the database handle. This block copies the error message + ** from the database handle into the statement and sets the statement + ** program counter to 0 to ensure that when the statement is + ** finalized or reset the parser error message is available via + ** sqlite3_errmsg() and sqlite3_errcode(). + */ + string zErr = sqlite3_value_text(db.pErr); + sqlite3DbFree(db, ref v.zErrMsg); + //if ( 0 == db.mallocFailed ) + { + v.zErrMsg = zErr;// sqlite3DbStrDup(db, zErr); + v.rc = rc2; + } + //else + //{ + // v.zErrMsg = ""; + // v->rc = rc = SQLITE_NOMEM; + //} + } + 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. - ** - ** IMPLEMENTATION-OF: R-46798-50301 The sqlite3_context_db_handle() interface - ** returns a copy of the pointer to the database connection (the 1st - ** parameter) of the sqlite3_create_function() and - ** sqlite3_create_function16() routines that originally registered the - ** application defined function. - */ - public static object sqlite3_user_data( sqlite3_context p ) - { - Debug.Assert( p != null && p.pFunc != null ); - return p.pFunc.pUserData; - } + /* + ** Extract the user data from a sqlite3_context structure and return a + ** pointer to it. + ** + ** IMPLEMENTATION-OF: R-46798-50301 The sqlite3_context_db_handle() interface + ** returns a copy of the pointer to the database connection (the 1st + ** parameter) of the sqlite3_create_function() and + ** sqlite3_create_function16() routines that originally registered the + ** application defined function. + */ + public static object sqlite3_user_data(sqlite3_context p) { + Debug.Assert(p != null && p.pFunc != null); + return p.pFunc.pUserData; + } - /* - ** Extract the user data from a sqlite3_context structure and return a - ** pointer to it. - */ - public static sqlite3 sqlite3_context_db_handle( sqlite3_context p ) - { - Debug.Assert( p != null && p.pFunc != null ); - return p.s.db; - } + /* + ** Extract the user data from a sqlite3_context structure and return a + ** pointer to it. + */ + public static sqlite3 sqlite3_context_db_handle(sqlite3_context p) { + Debug.Assert(p != null && p.pFunc != null); + return p.s.db; + } - /* - ** 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 - ** for name resolution but are actually overloaded by the xFindFunction - ** method of virtual tables. - */ - public static void sqlite3InvalidFunction( - sqlite3_context context, /* The function calling context */ - int NotUsed, /* Number of arguments to the function */ - sqlite3_value[] NotUsed2 /* Value of each argument */ - ) - { - string zName = context.pFunc.zName; - string zErr; - UNUSED_PARAMETER2( NotUsed, NotUsed2 ); - zErr = sqlite3_mprintf( - "unable to use function %s in the requested context", zName ); - sqlite3_result_error( context, zErr, -1 ); - //sqlite3_free( ref zErr ); - } + /* + ** 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 + ** for name resolution but are actually overloaded by the xFindFunction + ** method of virtual tables. + */ + public static void sqlite3InvalidFunction( + sqlite3_context context, /* The function calling context */ + int NotUsed, /* Number of arguments to the function */ + sqlite3_value[] NotUsed2 /* Value of each argument */ + ) { + string zName = context.pFunc.zName; + string zErr; + UNUSED_PARAMETER2(NotUsed, NotUsed2); + zErr = sqlite3_mprintf( + "unable to use function %s in the requested context", zName); + sqlite3_result_error(context, zErr, -1); + //sqlite3_free( ref zErr ); + } - /* - ** Allocate or return the aggregate context for a user function. A new - ** context is allocated on the first call. Subsequent calls return the - ** same context that was returned on prior calls. - */ - public static Mem sqlite3_aggregate_context( sqlite3_context p, int nByte ) - { - Mem pMem; - Debug.Assert( p != null && p.pFunc != null && p.pFunc.xStep != null ); - Debug.Assert( sqlite3_mutex_held( p.s.db.mutex ) ); - pMem = p.pMem; - testcase( nByte < 0 ); - if ( ( pMem.flags & MEM_Agg ) == 0 ) - { - if ( nByte <= 0 ) - { - sqlite3VdbeMemReleaseExternal( pMem ); - pMem.flags = 0; - pMem.z = null; - } - else - { - sqlite3VdbeMemGrow( pMem, nByte, 0 ); - pMem.flags = MEM_Agg; - pMem.u.pDef = p.pFunc; - if ( pMem.z != null ) - { - pMem.z = null; - } - pMem._Mem = sqlite3Malloc( pMem._Mem ); - pMem._Mem.flags = 0; - pMem._Mem.z = null; - } - } - return pMem._Mem; - } + /* + ** Allocate or return the aggregate context for a user function. A new + ** context is allocated on the first call. Subsequent calls return the + ** same context that was returned on prior calls. + */ + public static Mem sqlite3_aggregate_context(sqlite3_context p, int nByte) { + Mem pMem; + Debug.Assert(p != null && p.pFunc != null && p.pFunc.xStep != null); + Debug.Assert(sqlite3_mutex_held(p.s.db.mutex)); + pMem = p.pMem; + testcase(nByte < 0); + if ((pMem.flags & MEM_Agg) == 0) { + if (nByte <= 0) { + sqlite3VdbeMemReleaseExternal(pMem); + pMem.flags = 0; + pMem.z = null; + } else { + sqlite3VdbeMemGrow(pMem, nByte, 0); + pMem.flags = MEM_Agg; + pMem.u.pDef = p.pFunc; + if (pMem.z != null) { + pMem.z = null; + } + pMem._Mem = sqlite3Malloc(pMem._Mem); + pMem._Mem.flags = 0; + pMem._Mem.z = null; + } + } + return pMem._Mem; + } - /* - ** Return the auxillary data pointer, if any, for the iArg'th argument to - ** the user-function defined by pCtx. - */ - public static object sqlite3_get_auxdata( sqlite3_context pCtx, int iArg ) - { - VdbeFunc pVdbeFunc; - - Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); - pVdbeFunc = pCtx.pVdbeFunc; - if ( null == pVdbeFunc || iArg >= pVdbeFunc.nAux || iArg < 0 ) - { - return null; - } - return pVdbeFunc.apAux[iArg].pAux; - } + /* + ** Return the auxillary data pointer, if any, for the iArg'th argument to + ** the user-function defined by pCtx. + */ + public static object sqlite3_get_auxdata(sqlite3_context pCtx, int iArg) { + VdbeFunc pVdbeFunc; - /* - ** Set the auxillary data pointer and delete function, for the iArg'th - ** argument to the user-function defined by pCtx. Any previous value is - ** deleted by calling the delete function specified when it was set. - */ - public static void sqlite3_set_auxdata( - sqlite3_context pCtx, - int iArg, - object pAux - //void (*xDelete)(void) - ) - { - AuxData pAuxData; - VdbeFunc pVdbeFunc; - if ( iArg < 0 ) - goto failed; - - Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); - pVdbeFunc = pCtx.pVdbeFunc; - if ( null == pVdbeFunc || pVdbeFunc.nAux <= iArg ) - { - int nAux = ( pVdbeFunc != null ? pVdbeFunc.nAux : 0 ); - ////int nMalloc = iArg; - ////VdbeFunc+ sizeof(struct AuxData)*iArg; - if ( pVdbeFunc == null ) - { - //pVdbeFunc = (VdbeFunc)sqlite3DbRealloc( pCtx.s.db, pVdbeFunc, nMalloc ); - pVdbeFunc = new VdbeFunc(); - if ( null == pVdbeFunc ) - { - goto failed; - } - pCtx.pVdbeFunc = pVdbeFunc; - } - pVdbeFunc.apAux[nAux] = new AuxData();//memset(pVdbeFunc.apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux)); - pVdbeFunc.nAux = iArg + 1; - pVdbeFunc.pFunc = pCtx.pFunc; - } - - pAuxData = pVdbeFunc.apAux[iArg]; - if ( pAuxData.pAux != null && pAuxData.pAux is IDisposable ) - { - (pAuxData.pAux as IDisposable).Dispose(); - } - pAuxData.pAux = pAux; - return; - -failed: - if ( pAux != null && pAux is IDisposable) - { - (pAux as IDisposable).Dispose(); - } - } + Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); + pVdbeFunc = pCtx.pVdbeFunc; + if (null == pVdbeFunc || iArg >= pVdbeFunc.nAux || iArg < 0) { + return null; + } + return pVdbeFunc.apAux[iArg].pAux; + } + + /* + ** Set the auxillary data pointer and delete function, for the iArg'th + ** argument to the user-function defined by pCtx. Any previous value is + ** deleted by calling the delete function specified when it was set. + */ + public static void sqlite3_set_auxdata( + sqlite3_context pCtx, + int iArg, + object pAux + //void (*xDelete)(void) + ) { + AuxData pAuxData; + VdbeFunc pVdbeFunc; + if (iArg < 0) + goto failed; + + Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); + pVdbeFunc = pCtx.pVdbeFunc; + if (null == pVdbeFunc || pVdbeFunc.nAux <= iArg) { + int nAux = (pVdbeFunc != null ? pVdbeFunc.nAux : 0); + ////int nMalloc = iArg; + ////VdbeFunc+ sizeof(struct AuxData)*iArg; + if (pVdbeFunc == null) { + //pVdbeFunc = (VdbeFunc)sqlite3DbRealloc( pCtx.s.db, pVdbeFunc, nMalloc ); + pVdbeFunc = new VdbeFunc(); + if (null == pVdbeFunc) { + goto failed; + } + pCtx.pVdbeFunc = pVdbeFunc; + } + pVdbeFunc.apAux[nAux] = new AuxData();//memset(pVdbeFunc.apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux)); + pVdbeFunc.nAux = iArg + 1; + pVdbeFunc.pFunc = pCtx.pFunc; + } + + pAuxData = pVdbeFunc.apAux[iArg]; + if (pAuxData.pAux != null && pAuxData.pAux is IDisposable) { + (pAuxData.pAux as IDisposable).Dispose(); + } + pAuxData.pAux = pAux; + return; + + failed: + if (pAux != null && pAux is IDisposable) { + (pAux as IDisposable).Dispose(); + } + } #if !SQLITE_OMIT_DEPRECATED /* @@ -855,187 +766,169 @@ static int sqlite3_aggregate_count( sqlite3_context p ) } #endif - /* -** Return the number of columns in the result set for the statement pStmt. -*/ - public static int sqlite3_column_count( sqlite3_stmt pStmt ) - { - Vdbe pVm = pStmt; - return pVm != null ? (int)pVm.nResColumn : 0; - } - - /* - ** Return the number of values available from the current row of the - ** currently executing statement pStmt. + /* + ** Return the number of columns in the result set for the statement pStmt. */ - public static int sqlite3_data_count( sqlite3_stmt pStmt ) - { - Vdbe pVm = pStmt; - if ( pVm == null || pVm.pResultSet == null ) - return 0; - return pVm.nResColumn; - } + public static int sqlite3_column_count(sqlite3_stmt pStmt) { + Vdbe pVm = pStmt; + return pVm != null ? (int)pVm.nResColumn : 0; + } + /* + ** Return the number of values available from the current row of the + ** currently executing statement pStmt. + */ + public static int sqlite3_data_count(sqlite3_stmt pStmt) { + Vdbe pVm = pStmt; + if (pVm == null || pVm.pResultSet == null) + return 0; + return pVm.nResColumn; + } - /* - ** Check to see if column iCol of the given statement is valid. If - ** it is, return a pointer to the Mem for the value of that column. - ** If iCol is not valid, return a pointer to a Mem which has a value - ** of NULL. - */ - static Mem columnMem( sqlite3_stmt pStmt, int i ) - { - Vdbe pVm; - Mem pOut; - - pVm = (Vdbe)pStmt; - if ( pVm != null && pVm.pResultSet != null && i < pVm.nResColumn && i >= 0 ) - { - sqlite3_mutex_enter( pVm.db.mutex ); - pOut = pVm.pResultSet[i]; - } - else - { - /* If the value passed as the second argument is out of range, return - ** a pointer to the following public static Mem object which contains the - ** value SQL NULL. Even though the Mem structure contains an element - ** of type i64, on certain architecture (x86) with certain compiler - ** switches (-Os), gcc may align this Mem object on a 4-byte boundary - ** instead of an 8-byte one. This all works fine, except that when - ** running with SQLITE_DEBUG defined the SQLite code sometimes Debug.Assert()s - ** that a Mem structure is located on an 8-byte boundary. To prevent - ** this Debug.Assert() from failing, when building with SQLITE_DEBUG defined - ** using gcc, force nullMem to be 8-byte aligned using the magical - ** __attribute__((aligned(8))) macro. */ - // static const Mem nullMem - //#if defined(SQLITE_DEBUG) && defined(__GNUC__) - // __attribute__((aligned(8))) - //#endif - // = {0, "", (double)0, {0}, 0, MEM_Null, SQLITE_NULL, 0, - //#if SQLITE_DEBUG - // 0, 0, /* pScopyFrom, pFiller */ - //#endif - // 0, 0 }; - Mem nullMem = new Mem( null, "", (double)0, 0, 0, MEM_Null, SQLITE_NULL, 0 + + /* + ** Check to see if column iCol of the given statement is valid. If + ** it is, return a pointer to the Mem for the value of that column. + ** If iCol is not valid, return a pointer to a Mem which has a value + ** of NULL. + */ + static Mem columnMem(sqlite3_stmt pStmt, int i) { + Vdbe pVm; + Mem pOut; + + pVm = (Vdbe)pStmt; + if (pVm != null && pVm.pResultSet != null && i < pVm.nResColumn && i >= 0) { + sqlite3_mutex_enter(pVm.db.mutex); + pOut = pVm.pResultSet[i]; + } else { + /* If the value passed as the second argument is out of range, return + ** a pointer to the following public static Mem object which contains the + ** value SQL NULL. Even though the Mem structure contains an element + ** of type i64, on certain architecture (x86) with certain compiler + ** switches (-Os), gcc may align this Mem object on a 4-byte boundary + ** instead of an 8-byte one. This all works fine, except that when + ** running with SQLITE_DEBUG defined the SQLite code sometimes Debug.Assert()s + ** that a Mem structure is located on an 8-byte boundary. To prevent + ** this Debug.Assert() from failing, when building with SQLITE_DEBUG defined + ** using gcc, force nullMem to be 8-byte aligned using the magical + ** __attribute__((aligned(8))) macro. */ + // static const Mem nullMem + //#if defined(SQLITE_DEBUG) && defined(__GNUC__) + // __attribute__((aligned(8))) + //#endif + // = {0, "", (double)0, {0}, 0, MEM_Null, SQLITE_NULL, 0, + //#if SQLITE_DEBUG + // 0, 0, /* pScopyFrom, pFiller */ + //#endif + // 0, 0 }; + Mem nullMem = new Mem(null, "", (double)0, 0, 0, MEM_Null, SQLITE_NULL, 0 #if SQLITE_DEBUG - , null, null /* pScopyFrom, pFiller */ + , null, null /* pScopyFrom, pFiller */ #endif - ); + ); - if ( pVm != null && ALWAYS( pVm.db != null ) ) - { - sqlite3_mutex_enter( pVm.db.mutex ); - sqlite3Error( pVm.db, SQLITE_RANGE, 0 ); + if (pVm != null && ALWAYS(pVm.db != null)) { + sqlite3_mutex_enter(pVm.db.mutex); + sqlite3Error(pVm.db, SQLITE_RANGE, 0); + } + pOut = nullMem; + } + return pOut; } - pOut = nullMem; - } - return pOut; - } - /* - ** This function is called after invoking an sqlite3_value_XXX function on a - ** column value (i.e. a value returned by evaluating an SQL expression in the - ** select list of a SELECT statement) that may cause a malloc() failure. If - ** malloc() has failed, the threads mallocFailed flag is cleared and the result - ** code of statement pStmt set to SQLITE_NOMEM. - ** - ** Specifically, this is called from within: - ** - ** sqlite3_column_int() - ** sqlite3_column_int64() - ** sqlite3_column_text() - ** sqlite3_column_text16() - ** sqlite3_column_real() - ** sqlite3_column_bytes() - ** sqlite3_column_bytes16() - ** sqlite3_column_blob() - */ - static void columnMallocFailure( sqlite3_stmt pStmt ) - { - /* If malloc() failed during an encoding conversion within an - ** sqlite3_column_XXX API, then set the return code of the statement to - ** SQLITE_NOMEM. The next call to _step() (if any) will return SQLITE_ERROR - ** and _finalize() will return NOMEM. - */ - Vdbe p = pStmt; - if ( p != null ) - { - p.rc = sqlite3ApiExit( p.db, p.rc ); - sqlite3_mutex_leave( p.db.mutex ); - } - } + /* + ** This function is called after invoking an sqlite3_value_XXX function on a + ** column value (i.e. a value returned by evaluating an SQL expression in the + ** select list of a SELECT statement) that may cause a malloc() failure. If + ** malloc() has failed, the threads mallocFailed flag is cleared and the result + ** code of statement pStmt set to SQLITE_NOMEM. + ** + ** Specifically, this is called from within: + ** + ** sqlite3_column_int() + ** sqlite3_column_int64() + ** sqlite3_column_text() + ** sqlite3_column_text16() + ** sqlite3_column_real() + ** sqlite3_column_bytes() + ** sqlite3_column_bytes16() + ** sqlite3_column_blob() + */ + static void columnMallocFailure(sqlite3_stmt pStmt) { + /* If malloc() failed during an encoding conversion within an + ** sqlite3_column_XXX API, then set the return code of the statement to + ** SQLITE_NOMEM. The next call to _step() (if any) will return SQLITE_ERROR + ** and _finalize() will return NOMEM. + */ + Vdbe p = pStmt; + if (p != null) { + p.rc = sqlite3ApiExit(p.db, p.rc); + sqlite3_mutex_leave(p.db.mutex); + } + } - /**************************** sqlite3_column_ ******************************* - ** The following routines are used to access elements of the current row - ** in the result set. - */ - public static byte[] sqlite3_column_blob( sqlite3_stmt pStmt, int i ) - { - byte[] val; - val = sqlite3_value_blob( columnMem( pStmt, i ) ); - /* Even though there is no encoding conversion, value_blob() might - ** need to call malloc() to expand the result of a zeroblob() - ** expression. - */ - columnMallocFailure( pStmt ); - return val; - } + /**************************** sqlite3_column_ ******************************* + ** The following routines are used to access elements of the current row + ** in the result set. + */ + public static byte[] sqlite3_column_blob(sqlite3_stmt pStmt, int i) { + byte[] val; + val = sqlite3_value_blob(columnMem(pStmt, i)); + /* Even though there is no encoding conversion, value_blob() might + ** need to call malloc() to expand the result of a zeroblob() + ** expression. + */ + columnMallocFailure(pStmt); + return val; + } - public static int sqlite3_column_bytes( sqlite3_stmt pStmt, int i ) - { - int val = sqlite3_value_bytes( columnMem( pStmt, i ) ); - columnMallocFailure( pStmt ); - return val; - } + public static int sqlite3_column_bytes(sqlite3_stmt pStmt, int i) { + int val = sqlite3_value_bytes(columnMem(pStmt, i)); + columnMallocFailure(pStmt); + return val; + } - public static int sqlite3_column_bytes16( sqlite3_stmt pStmt, int i ) - { - int val = sqlite3_value_bytes16( columnMem( pStmt, i ) ); - columnMallocFailure( pStmt ); - return val; - } + public static int sqlite3_column_bytes16(sqlite3_stmt pStmt, int i) { + int val = sqlite3_value_bytes16(columnMem(pStmt, i)); + columnMallocFailure(pStmt); + return val; + } - public static double sqlite3_column_double( sqlite3_stmt pStmt, int i ) - { - double val = sqlite3_value_double( columnMem( pStmt, i ) ); - columnMallocFailure( pStmt ); - return val; - } + public static double sqlite3_column_double(sqlite3_stmt pStmt, int i) { + double val = sqlite3_value_double(columnMem(pStmt, i)); + columnMallocFailure(pStmt); + return val; + } - public static int sqlite3_column_int( sqlite3_stmt pStmt, int i ) - { - int val = sqlite3_value_int( columnMem( pStmt, i ) ); - columnMallocFailure( pStmt ); - return val; - } + public static int sqlite3_column_int(sqlite3_stmt pStmt, int i) { + int val = sqlite3_value_int(columnMem(pStmt, i)); + columnMallocFailure(pStmt); + return val; + } - public static sqlite_int64 sqlite3_column_int64( sqlite3_stmt pStmt, int i ) - { - sqlite_int64 val = sqlite3_value_int64( columnMem( pStmt, i ) ); - columnMallocFailure( pStmt ); - return val; - } + public static sqlite_int64 sqlite3_column_int64(sqlite3_stmt pStmt, int i) { + sqlite_int64 val = sqlite3_value_int64(columnMem(pStmt, i)); + columnMallocFailure(pStmt); + return val; + } - public static string sqlite3_column_text( sqlite3_stmt pStmt, int i ) - { - string val = sqlite3_value_text( columnMem( pStmt, i ) ); - columnMallocFailure( pStmt ); - return val; - } + public static string sqlite3_column_text(sqlite3_stmt pStmt, int i) { + string val = sqlite3_value_text(columnMem(pStmt, i)); + columnMallocFailure(pStmt); + return val; + } - public static sqlite3_value sqlite3_column_value( sqlite3_stmt pStmt, int i ) - { - Mem pOut = columnMem( pStmt, i ); - if ( ( pOut.flags & MEM_Static ) != 0 ) - { - pOut.flags = (u16)( pOut.flags & ~MEM_Static ); - pOut.flags |= MEM_Ephem; - } - columnMallocFailure( pStmt ); - return (sqlite3_value)pOut; - } -#if !SQLITE_OMIT_UTF16 + public static sqlite3_value sqlite3_column_value(sqlite3_stmt pStmt, int i) { + Mem pOut = columnMem(pStmt, i); + if ((pOut.flags & MEM_Static) != 0) { + pOut.flags = (u16)(pOut.flags & ~MEM_Static); + pOut.flags |= MEM_Ephem; + } + columnMallocFailure(pStmt); + return (sqlite3_value)pOut; + } +#if !SQLITE_OMIT_UTF16 //const void *sqlite3_column_text16(sqlite3_stmt pStmt, int i){ // const void *val = sqlite3_value_text16( columnMem(pStmt,i) ); // columnMallocFailure(pStmt); @@ -1043,106 +936,101 @@ public static sqlite3_value sqlite3_column_value( sqlite3_stmt pStmt, int i ) //} #endif // * SQLITE_OMIT_UTF16 */ - public static int sqlite3_column_type( sqlite3_stmt pStmt, int i ) - { - int iType = sqlite3_value_type( columnMem( pStmt, i ) ); - columnMallocFailure( pStmt ); - return iType; - } + public static int sqlite3_column_type(sqlite3_stmt pStmt, int i) { + int iType = sqlite3_value_type(columnMem(pStmt, i)); + columnMallocFailure(pStmt); + return iType; + } - /* The following function is experimental and subject to change or - ** removal */ - /*int sqlite3_column_numeric_type(sqlite3_stmt pStmt, int i){ - ** return sqlite3_value_numeric_type( columnMem(pStmt,i) ); - **} - */ + /* The following function is experimental and subject to change or + ** removal */ + /*int sqlite3_column_numeric_type(sqlite3_stmt pStmt, int i){ + ** return sqlite3_value_numeric_type( columnMem(pStmt,i) ); + **} + */ - /* - ** Convert the N-th element of pStmt.pColName[] into a string using - ** xFunc() then return that string. If N is out of range, return 0. - ** - ** There are up to 5 names for each column. useType determines which - ** name is returned. Here are the names: - ** - ** 0 The column name as it should be displayed for output - ** 1 The datatype name for the column - ** 2 The name of the database that the column derives from - ** 3 The name of the table that the column derives from - ** 4 The name of the table column that the result column derives from - ** - ** If the result is not a simple column reference (if it is an expression - ** or a constant) then useTypes 2, 3, and 4 return NULL. - */ - public static string columnName( - sqlite3_stmt pStmt, - int N, - dxColname xFunc, - int useType - ) - { - string ret = null; - Vdbe p = pStmt; - int n; - sqlite3 db = p.db; - - Debug.Assert( db != null ); - - n = sqlite3_column_count( pStmt ); - if ( N < n && N >= 0 ) - { - N += useType * n; - sqlite3_mutex_enter( db.mutex ); - //Debug.Assert( db.mallocFailed == 0 ); - ret = xFunc( p.aColName[N] ); - - /* A malloc may have failed inside of the xFunc() call. If this - ** is the case, clear the mallocFailed flag and return NULL. + /* + ** Convert the N-th element of pStmt.pColName[] into a string using + ** xFunc() then return that string. If N is out of range, return 0. + ** + ** There are up to 5 names for each column. useType determines which + ** name is returned. Here are the names: + ** + ** 0 The column name as it should be displayed for output + ** 1 The datatype name for the column + ** 2 The name of the database that the column derives from + ** 3 The name of the table that the column derives from + ** 4 The name of the table column that the result column derives from + ** + ** If the result is not a simple column reference (if it is an expression + ** or a constant) then useTypes 2, 3, and 4 return NULL. */ - //if ( db.mallocFailed != 0 ) - //{ - // //db.mallocFailed = 0; - // ret = null; - //} - sqlite3_mutex_leave( db.mutex ); - } - return ret; - } + public static string columnName( + sqlite3_stmt pStmt, + int N, + dxColname xFunc, + int useType + ) { + string ret = null; + Vdbe p = pStmt; + int n; + sqlite3 db = p.db; + + Debug.Assert(db != null); + + n = sqlite3_column_count(pStmt); + if (N < n && N >= 0) { + N += useType * n; + sqlite3_mutex_enter(db.mutex); + //Debug.Assert( db.mallocFailed == 0 ); + ret = xFunc(p.aColName[N]); + + /* A malloc may have failed inside of the xFunc() call. If this + ** is the case, clear the mallocFailed flag and return NULL. + */ + //if ( db.mallocFailed != 0 ) + //{ + // //db.mallocFailed = 0; + // ret = null; + //} + sqlite3_mutex_leave(db.mutex); + } + return ret; + } - /* - ** Return the name of the Nth column of the result set returned by SQL - ** statement pStmt. - */ - public static string sqlite3_column_name( sqlite3_stmt pStmt, int N ) - { - return columnName( - pStmt, N, sqlite3_value_text, COLNAME_NAME ); - } -#if !SQLITE_OMIT_UTF16 + /* + ** Return the name of the Nth column of the result set returned by SQL + ** statement pStmt. + */ + public static string sqlite3_column_name(sqlite3_stmt pStmt, int N) { + return columnName( + pStmt, N, sqlite3_value_text, COLNAME_NAME); + } +#if !SQLITE_OMIT_UTF16 public static string sqlite3_column_name16(sqlite3_stmt pStmt, int N){ return columnName( pStmt, N, sqlite3_value_text16, COLNAME_NAME); } #endif - /* -** Constraint: If you have ENABLE_COLUMN_METADATA then you must -** not define OMIT_DECLTYPE. -*/ + /* + ** Constraint: If you have ENABLE_COLUMN_METADATA then you must + ** not define OMIT_DECLTYPE. + */ #if SQLITE_OMIT_DECLTYPE && SQLITE_ENABLE_COLUMN_METADATA -# error "Must not define both SQLITE_OMIT_DECLTYPE and SQLITE_ENABLE_COLUMN_METADATA" +#error "Must not define both SQLITE_OMIT_DECLTYPE and SQLITE_ENABLE_COLUMN_METADATA" #endif #if !SQLITE_OMIT_DECLTYPE - /* -** Return the column declaration type (if applicable) of the 'i'th column -** of the result set of SQL statement pStmt. -*/ - public static string sqlite3_column_decltype( sqlite3_stmt pStmt, int N ) - { - return columnName( - pStmt, N, sqlite3_value_text, COLNAME_DECLTYPE ); - } -#if !SQLITE_OMIT_UTF16 + /* + ** Return the column declaration type (if applicable) of the 'i'th column + ** of the result set of SQL statement pStmt. + */ + public static string sqlite3_column_decltype(sqlite3_stmt pStmt, int N) { + return columnName( + pStmt, N, sqlite3_value_text, COLNAME_DECLTYPE); + } +#if !SQLITE_OMIT_UTF16 //const void *sqlite3_column_decltype16(sqlite3_stmt pStmt, int N){ // return columnName( // pStmt, N, (const void*()(Mem))sqlite3_value_text16, COLNAME_DECLTYPE); @@ -1150,18 +1038,17 @@ public static string sqlite3_column_decltype( sqlite3_stmt pStmt, int N ) #endif // * SQLITE_OMIT_UTF16 */ #endif // * SQLITE_OMIT_DECLTYPE */ -#if SQLITE_ENABLE_COLUMN_METADATA +#if SQLITE_ENABLE_COLUMN_METADATA -/* -** Return the name of the database from which a result column derives. -** NULL is returned if the result column is an expression or constant or -** anything else which is not an unabiguous reference to a database column. -*/ - public static string sqlite3_column_database_name( sqlite3_stmt pStmt, int N ) - { - return columnName( - pStmt, N, sqlite3_value_text, COLNAME_DATABASE ); - } + /* + ** Return the name of the database from which a result column derives. + ** NULL is returned if the result column is an expression or constant or + ** anything else which is not an unabiguous reference to a database column. + */ + public static string sqlite3_column_database_name(sqlite3_stmt pStmt, int N) { + return columnName( + pStmt, N, sqlite3_value_text, COLNAME_DATABASE); + } #if !SQLITE_OMIT_UTF16 const void *sqlite3_column_database_name16(sqlite3_stmt pStmt, int N){ return columnName( @@ -1169,16 +1056,15 @@ public static string sqlite3_column_database_name( sqlite3_stmt pStmt, int N ) } #endif //* SQLITE_OMIT_UTF16 */ -/* -** Return the name of the table from which a result column derives. -** NULL is returned if the result column is an expression or constant or -** anything else which is not an unabiguous reference to a database column. -*/ - public static string sqlite3_column_table_name( sqlite3_stmt pStmt, int N ) - { - return columnName( - pStmt, N, sqlite3_value_text, COLNAME_TABLE ); - } + /* + ** Return the name of the table from which a result column derives. + ** NULL is returned if the result column is an expression or constant or + ** anything else which is not an unabiguous reference to a database column. + */ + public static string sqlite3_column_table_name(sqlite3_stmt pStmt, int N) { + return columnName( + pStmt, N, sqlite3_value_text, COLNAME_TABLE); + } #if !SQLITE_OMIT_UTF16 const void *sqlite3_column_table_name16(sqlite3_stmt pStmt, int N){ return columnName( @@ -1186,16 +1072,15 @@ public static string sqlite3_column_table_name( sqlite3_stmt pStmt, int N ) } #endif //* SQLITE_OMIT_UTF16 */ -/* -** Return the name of the table column from which a result column derives. -** NULL is returned if the result column is an expression or constant or -** anything else which is not an unabiguous reference to a database column. -*/ - public static string sqlite3_column_origin_name( sqlite3_stmt pStmt, int N ) - { - return columnName( - pStmt, N, sqlite3_value_text, COLNAME_COLUMN ); - } + /* + ** Return the name of the table column from which a result column derives. + ** NULL is returned if the result column is an expression or constant or + ** anything else which is not an unabiguous reference to a database column. + */ + public static string sqlite3_column_origin_name(sqlite3_stmt pStmt, int N) { + return columnName( + pStmt, N, sqlite3_value_text, COLNAME_COLUMN); + } #if !SQLITE_OMIT_UTF16 const void *sqlite3_column_origin_name16(sqlite3_stmt pStmt, int N){ return columnName( @@ -1205,208 +1090,184 @@ public static string sqlite3_column_origin_name( sqlite3_stmt pStmt, int N ) #endif // * SQLITE_ENABLE_COLUMN_METADATA */ - /******************************* sqlite3_bind_ *************************** -** -** Routines used to attach values to wildcards in a compiled SQL statement. -*/ - /* - ** Unbind the value bound to variable i in virtual machine p. This is the - ** the same as binding a NULL value to the column. If the "i" parameter is - ** out of range, then SQLITE_RANGE is returned. Othewise SQLITE_OK. - ** - ** A successful evaluation of this routine acquires the mutex on p. - ** the mutex is released if any kind of error occurs. + /******************************* sqlite3_bind_ *************************** ** - ** The error code stored in database p.db is overwritten with the return - ** value in any case. + ** Routines used to attach values to wildcards in a compiled SQL statement. */ - public static int vdbeUnbind( Vdbe p, int i ) - { - Mem pVar; - if ( vdbeSafetyNotNull( p ) ) - { - return SQLITE_MISUSE_BKPT(); - } - sqlite3_mutex_enter( p.db.mutex ); - if ( p.magic != VDBE_MAGIC_RUN || p.pc >= 0 ) - { - sqlite3Error( p.db, SQLITE_MISUSE, 0 ); - sqlite3_mutex_leave( p.db.mutex ); - sqlite3_log( SQLITE_MISUSE, - "bind on a busy prepared statement: [%s]", p.zSql ); - return SQLITE_MISUSE_BKPT(); - } - if ( i < 1 || i > p.nVar ) - { - sqlite3Error( p.db, SQLITE_RANGE, 0 ); - sqlite3_mutex_leave( p.db.mutex ); - return SQLITE_RANGE; - } - i--; - pVar = p.aVar[i]; - sqlite3VdbeMemRelease( pVar ); - pVar.flags = MEM_Null; - sqlite3Error( p.db, SQLITE_OK, 0 ); - - /* If the bit corresponding to this variable in Vdbe.expmask is set, then - ** binding a new value to this variable invalidates the current query plan. - ** - ** IMPLEMENTATION-OF: R-48440-37595 If the specific value bound to host - ** parameter in the WHERE clause might influence the choice of query plan - ** for a statement, then the statement will be automatically recompiled, - ** as if there had been a schema change, on the first sqlite3_step() call - ** following any change to the bindings of that parameter. - */ - if ( p.isPrepareV2 && - ( ( i < 32 && p.expmask != 0 & ( (u32)1 << i ) != 0 ) || p.expmask == 0xffffffff ) - ) - { - p.expired = true; - } - - return SQLITE_OK; - } + /* + ** Unbind the value bound to variable i in virtual machine p. This is the + ** the same as binding a NULL value to the column. If the "i" parameter is + ** out of range, then SQLITE_RANGE is returned. Othewise SQLITE_OK. + ** + ** A successful evaluation of this routine acquires the mutex on p. + ** the mutex is released if any kind of error occurs. + ** + ** The error code stored in database p.db is overwritten with the return + ** value in any case. + */ + public static int vdbeUnbind(Vdbe p, int i) { + Mem pVar; + if (vdbeSafetyNotNull(p)) { + return SQLITE_MISUSE_BKPT(); + } + sqlite3_mutex_enter(p.db.mutex); + if (p.magic != VDBE_MAGIC_RUN || p.pc >= 0) { + sqlite3Error(p.db, SQLITE_MISUSE, 0); + sqlite3_mutex_leave(p.db.mutex); + sqlite3_log(SQLITE_MISUSE, + "bind on a busy prepared statement: [%s]", p.zSql); + return SQLITE_MISUSE_BKPT(); + } + if (i < 1 || i > p.nVar) { + sqlite3Error(p.db, SQLITE_RANGE, 0); + sqlite3_mutex_leave(p.db.mutex); + return SQLITE_RANGE; + } + i--; + pVar = p.aVar[i]; + sqlite3VdbeMemRelease(pVar); + pVar.flags = MEM_Null; + sqlite3Error(p.db, SQLITE_OK, 0); + + /* If the bit corresponding to this variable in Vdbe.expmask is set, then + ** binding a new value to this variable invalidates the current query plan. + ** + ** IMPLEMENTATION-OF: R-48440-37595 If the specific value bound to host + ** parameter in the WHERE clause might influence the choice of query plan + ** for a statement, then the statement will be automatically recompiled, + ** as if there had been a schema change, on the first sqlite3_step() call + ** following any change to the bindings of that parameter. + */ + if (p.isPrepareV2 && + ((i < 32 && p.expmask != 0 & ((u32)1 << i) != 0) || p.expmask == 0xffffffff) + ) { + p.expired = true; + } - /* - ** Bind a text or BLOB value. - */ - static int bindBlob( - sqlite3_stmt pStmt, /* The statement to bind against */ - int i, /* Index of the parameter to bind */ - byte[] zData, /* Pointer to the data to be bound */ - int nData, /* Number of bytes of data to be bound */ - dxDel xDel, /* Destructor for the data */ - u8 encoding /* Encoding for the data */ - ) - { - Vdbe p = pStmt; - Mem pVar; - int rc; - - rc = vdbeUnbind( p, i ); - if ( rc == SQLITE_OK ) - { - if ( zData != null ) - { - pVar = p.aVar[i - 1]; - rc = sqlite3VdbeMemSetBlob( pVar, zData, nData, encoding, xDel ); - if ( rc == SQLITE_OK && encoding != 0 ) - { - rc = sqlite3VdbeChangeEncoding( pVar, ENC( p.db ) ); - } - sqlite3Error( p.db, rc, 0 ); - rc = sqlite3ApiExit( p.db, rc ); - } - sqlite3_mutex_leave( p.db.mutex ); - } - return rc; - } + return SQLITE_OK; + } - /* - ** Bind a text value. - */ - public static int bindText( - sqlite3_stmt pStmt, /* The statement to bind against */ - int i, /* Index of the parameter to bind */ - string zData, /* Pointer to the data to be bound */ - int nData, /* Number of bytes of data to be bound */ - dxDel xDel, /* Destructor for the data */ - u8 encoding /* Encoding for the data */ - ) - { - Vdbe p = pStmt; - Mem pVar; - int rc; - - rc = vdbeUnbind( p, i ); - if ( rc == SQLITE_OK ) - { - if ( zData != null ) - { - pVar = p.aVar[i - 1]; - rc = sqlite3VdbeMemSetStr( pVar, zData, nData, encoding, xDel ); - if ( rc == SQLITE_OK && encoding != 0 ) - { - rc = sqlite3VdbeChangeEncoding( pVar, ENC( p.db ) ); - } - sqlite3Error( p.db, rc, 0 ); - rc = sqlite3ApiExit( p.db, rc ); - } - sqlite3_mutex_leave( p.db.mutex ); - } - else if ( xDel != SQLITE_STATIC && xDel != SQLITE_TRANSIENT ) - { - xDel( ref zData ); - } - return rc; - } + /* + ** Bind a text or BLOB value. + */ + static int bindBlob( + sqlite3_stmt pStmt, /* The statement to bind against */ + int i, /* Index of the parameter to bind */ + byte[] zData, /* Pointer to the data to be bound */ + int nData, /* Number of bytes of data to be bound */ + dxDel xDel, /* Destructor for the data */ + u8 encoding /* Encoding for the data */ + ) { + Vdbe p = pStmt; + Mem pVar; + int rc; + + rc = vdbeUnbind(p, i); + if (rc == SQLITE_OK) { + if (zData != null) { + pVar = p.aVar[i - 1]; + rc = sqlite3VdbeMemSetBlob(pVar, zData, nData, encoding, xDel); + if (rc == SQLITE_OK && encoding != 0) { + rc = sqlite3VdbeChangeEncoding(pVar, ENC(p.db)); + } + sqlite3Error(p.db, rc, 0); + rc = sqlite3ApiExit(p.db, rc); + } + sqlite3_mutex_leave(p.db.mutex); + } + return rc; + } - public static int sqlite3_bind_double( sqlite3_stmt pStmt, int i, double rValue ) - { - int rc; - Vdbe p = pStmt; - rc = vdbeUnbind( p, i ); - if ( rc == SQLITE_OK ) - { - sqlite3VdbeMemSetDouble( p.aVar[i - 1], rValue ); - sqlite3_mutex_leave( p.db.mutex ); - } - return rc; - } + /* + ** Bind a text value. + */ + public static int bindText( + sqlite3_stmt pStmt, /* The statement to bind against */ + int i, /* Index of the parameter to bind */ + string zData, /* Pointer to the data to be bound */ + int nData, /* Number of bytes of data to be bound */ + dxDel xDel, /* Destructor for the data */ + u8 encoding /* Encoding for the data */ + ) { + Vdbe p = pStmt; + Mem pVar; + int rc; + + rc = vdbeUnbind(p, i); + if (rc == SQLITE_OK) { + if (zData != null) { + pVar = p.aVar[i - 1]; + rc = sqlite3VdbeMemSetStr(pVar, zData, nData, encoding, xDel); + if (rc == SQLITE_OK && encoding != 0) { + rc = sqlite3VdbeChangeEncoding(pVar, ENC(p.db)); + } + sqlite3Error(p.db, rc, 0); + rc = sqlite3ApiExit(p.db, rc); + } + sqlite3_mutex_leave(p.db.mutex); + } else if (xDel != SQLITE_STATIC && xDel != SQLITE_TRANSIENT) { + xDel(ref zData); + } + return rc; + } - public static int sqlite3_bind_int( sqlite3_stmt p, int i, int iValue ) - { - return sqlite3_bind_int64( p, i, (i64)iValue ); - } + public static int sqlite3_bind_double(sqlite3_stmt pStmt, int i, double rValue) { + int rc; + Vdbe p = pStmt; + rc = vdbeUnbind(p, i); + if (rc == SQLITE_OK) { + sqlite3VdbeMemSetDouble(p.aVar[i - 1], rValue); + sqlite3_mutex_leave(p.db.mutex); + } + return rc; + } - public static int sqlite3_bind_int64( sqlite3_stmt pStmt, int i, sqlite_int64 iValue ) - { - int rc; - Vdbe p = pStmt; - rc = vdbeUnbind( p, i ); - if ( rc == SQLITE_OK ) - { - sqlite3VdbeMemSetInt64( p.aVar[i - 1], iValue ); - sqlite3_mutex_leave( p.db.mutex ); - } - return rc; - } + public static int sqlite3_bind_int(sqlite3_stmt p, int i, int iValue) { + return sqlite3_bind_int64(p, i, (i64)iValue); + } - public static int sqlite3_bind_null( sqlite3_stmt pStmt, int i ) - { - int rc; - Vdbe p = (Vdbe)pStmt; - rc = vdbeUnbind( p, i ); - if ( rc == SQLITE_OK ) - { - sqlite3_mutex_leave( p.db.mutex ); - } - return rc; - } + public static int sqlite3_bind_int64(sqlite3_stmt pStmt, int i, sqlite_int64 iValue) { + int rc; + Vdbe p = pStmt; + rc = vdbeUnbind(p, i); + if (rc == SQLITE_OK) { + sqlite3VdbeMemSetInt64(p.aVar[i - 1], iValue); + sqlite3_mutex_leave(p.db.mutex); + } + return rc; + } - public static int sqlite3_bind_text( - sqlite3_stmt pStmt, - int i, - string zData, - int nData, - dxDel xDel - ) - { - return bindText( pStmt, i, zData, nData, xDel, SQLITE_UTF8 ); - } + public static int sqlite3_bind_null(sqlite3_stmt pStmt, int i) { + int rc; + Vdbe p = (Vdbe)pStmt; + rc = vdbeUnbind(p, i); + if (rc == SQLITE_OK) { + sqlite3_mutex_leave(p.db.mutex); + } + return rc; + } - public static int sqlite3_bind_blob( - sqlite3_stmt pStmt, - int i, - byte[] zData, - int nData, - dxDel xDel - ) - { - return bindBlob( pStmt, i, zData, nData >= 0 ? nData : zData.Length, xDel, 0 ); - } + public static int sqlite3_bind_text( + sqlite3_stmt pStmt, + int i, + string zData, + int nData, + dxDel xDel + ) { + return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF8); + } + + public static int sqlite3_bind_blob( + sqlite3_stmt pStmt, + int i, + byte[] zData, + int nData, + dxDel xDel + ) { + return bindBlob(pStmt, i, zData, nData >= 0 ? nData : zData.Length, xDel, 0); + } -#if !SQLITE_OMIT_UTF16 +#if !SQLITE_OMIT_UTF16 static int sqlite3_bind_text16( sqlite3_stmt pStmt, int i, @@ -1418,136 +1279,114 @@ dxDel xDel } #endif // * SQLITE_OMIT_UTF16 */ - public static int sqlite3_bind_value( sqlite3_stmt pStmt, int i, sqlite3_value pValue ) - { - int rc; - switch ( pValue.type ) - { - case SQLITE_INTEGER: - { - rc = sqlite3_bind_int64( pStmt, i, pValue.u.i ); - break; - } - case SQLITE_FLOAT: - { - rc = sqlite3_bind_double( pStmt, i, pValue.r ); - break; - } - case SQLITE_BLOB: - { - if ( ( pValue.flags & MEM_Zero ) != 0 ) - { - rc = sqlite3_bind_zeroblob( pStmt, i, pValue.u.nZero ); - } - else - { - rc = sqlite3_bind_blob( pStmt, i, pValue.zBLOB, pValue.n, SQLITE_TRANSIENT ); + public static int sqlite3_bind_value(sqlite3_stmt pStmt, int i, sqlite3_value pValue) { + int rc; + switch (pValue.type) { + case SQLITE_INTEGER: { + rc = sqlite3_bind_int64(pStmt, i, pValue.u.i); + break; + } + case SQLITE_FLOAT: { + rc = sqlite3_bind_double(pStmt, i, pValue.r); + break; + } + case SQLITE_BLOB: { + if ((pValue.flags & MEM_Zero) != 0) { + rc = sqlite3_bind_zeroblob(pStmt, i, pValue.u.nZero); + } else { + rc = sqlite3_bind_blob(pStmt, i, pValue.zBLOB, pValue.n, SQLITE_TRANSIENT); + } + break; + } + case SQLITE_TEXT: { + rc = bindText(pStmt, i, pValue.z, pValue.n, SQLITE_TRANSIENT, + pValue.enc); + break; + } + default: { + rc = sqlite3_bind_null(pStmt, i); + break; + } } - break; - } - case SQLITE_TEXT: - { - rc = bindText( pStmt, i, pValue.z, pValue.n, SQLITE_TRANSIENT, - pValue.enc ); - break; - } - default: - { - rc = sqlite3_bind_null( pStmt, i ); - break; - } - } - return rc; - } + return rc; + } - public static int sqlite3_bind_zeroblob( sqlite3_stmt pStmt, int i, int n ) - { - int rc; - Vdbe p = pStmt; - rc = vdbeUnbind( p, i ); - if ( rc == SQLITE_OK ) - { - sqlite3VdbeMemSetZeroBlob( p.aVar[i - 1], n ); - sqlite3_mutex_leave( p.db.mutex ); - } - return rc; - } + public static int sqlite3_bind_zeroblob(sqlite3_stmt pStmt, int i, int n) { + int rc; + Vdbe p = pStmt; + rc = vdbeUnbind(p, i); + if (rc == SQLITE_OK) { + sqlite3VdbeMemSetZeroBlob(p.aVar[i - 1], n); + sqlite3_mutex_leave(p.db.mutex); + } + return rc; + } - /* - ** Return the number of wildcards that can be potentially bound to. - ** This routine is added to support DBD::SQLite. - */ - public static int sqlite3_bind_parameter_count( sqlite3_stmt pStmt ) - { - Vdbe p = (Vdbe)pStmt; - return ( p != null ) ? (int)p.nVar : 0; - } + /* + ** Return the number of wildcards that can be potentially bound to. + ** This routine is added to support DBD::SQLite. + */ + public static int sqlite3_bind_parameter_count(sqlite3_stmt pStmt) { + Vdbe p = (Vdbe)pStmt; + return (p != null) ? (int)p.nVar : 0; + } - /* - ** Return the name of a wildcard parameter. Return NULL if the index - ** is out of range or if the wildcard is unnamed. - ** - ** The result is always UTF-8. - */ - public static string sqlite3_bind_parameter_name( sqlite3_stmt pStmt, int i ) - { - Vdbe p = (Vdbe)pStmt; - if ( p == null || i < 1 || i > p.nzVar ) - { - return ""; - } - return p.azVar[i - 1]; - } + /* + ** Return the name of a wildcard parameter. Return NULL if the index + ** is out of range or if the wildcard is unnamed. + ** + ** The result is always UTF-8. + */ + public static string sqlite3_bind_parameter_name(sqlite3_stmt pStmt, int i) { + Vdbe p = (Vdbe)pStmt; + if (p == null || i < 1 || i > p.nzVar) { + return ""; + } + return p.azVar[i - 1]; + } - /* - ** Given a wildcard parameter name, return the index of the variable - ** with that name. If there is no variable with the given name, - ** return 0. - */ - public static int sqlite3VdbeParameterIndex( Vdbe p, string zName, int nName ) - { - int i; - if ( p == null ) - { - return 0; - } - if ( zName != null && zName != "" ) - { - for ( i = 0; i < p.nzVar; i++ ) - { - string z = p.azVar[i]; - if ( z != null && z == zName )//&& memcmp(z,zName,nName)==0 && z[nName]==0) - { - return i + 1; - } - } - } - return 0; - } + /* + ** Given a wildcard parameter name, return the index of the variable + ** with that name. If there is no variable with the given name, + ** return 0. + */ + public static int sqlite3VdbeParameterIndex(Vdbe p, string zName, int nName) { + int i; + if (p == null) { + return 0; + } + if (zName != null && zName != "") { + for (i = 0; i < p.nzVar; i++) { + string z = p.azVar[i]; + if (z != null && z == zName)//&& memcmp(z,zName,nName)==0 && z[nName]==0) + { + return i + 1; + } + } + } + return 0; + } - public static int sqlite3_bind_parameter_index( sqlite3_stmt pStmt, string zName ) - { - return sqlite3VdbeParameterIndex( (Vdbe)pStmt, zName, sqlite3Strlen30( zName ) ); - } + public static int sqlite3_bind_parameter_index(sqlite3_stmt pStmt, string zName) { + return sqlite3VdbeParameterIndex((Vdbe)pStmt, zName, sqlite3Strlen30(zName)); + } - /* - ** Transfer all bindings from the first statement over to the second. - */ - public static int sqlite3TransferBindings( sqlite3_stmt pFromStmt, sqlite3_stmt pToStmt ) - { - Vdbe pFrom = (Vdbe)pFromStmt; - Vdbe pTo = (Vdbe)pToStmt; - int i; - Debug.Assert( pTo.db == pFrom.db ); - Debug.Assert( pTo.nVar == pFrom.nVar ); - sqlite3_mutex_enter( pTo.db.mutex ); - for ( i = 0; i < pFrom.nVar; i++ ) - { - sqlite3VdbeMemMove( pTo.aVar[i], pFrom.aVar[i] ); - } - sqlite3_mutex_leave( pTo.db.mutex ); - return SQLITE_OK; - } + /* + ** Transfer all bindings from the first statement over to the second. + */ + public static int sqlite3TransferBindings(sqlite3_stmt pFromStmt, sqlite3_stmt pToStmt) { + Vdbe pFrom = (Vdbe)pFromStmt; + Vdbe pTo = (Vdbe)pToStmt; + int i; + Debug.Assert(pTo.db == pFrom.db); + Debug.Assert(pTo.nVar == pFrom.nVar); + sqlite3_mutex_enter(pTo.db.mutex); + for (i = 0; i < pFrom.nVar; i++) { + sqlite3VdbeMemMove(pTo.aVar[i], pFrom.aVar[i]); + } + sqlite3_mutex_leave(pTo.db.mutex); + return SQLITE_OK; + } #if !SQLITE_OMIT_DEPRECATED /* @@ -1580,59 +1419,52 @@ static int sqlite3_transfer_bindings( sqlite3_stmt pFromStmt, sqlite3_stmt pToSt } #endif - /* -** Return the sqlite3* database handle to which the prepared statement given -** in the argument belongs. This is the same database handle that was -** the first argument to the sqlite3_prepare() that was used to create -** the statement in the first place. -*/ - public static sqlite3 sqlite3_db_handle( sqlite3_stmt pStmt ) - { - return pStmt != null ? ( (Vdbe)pStmt ).db : null; - } + /* + ** Return the sqlite3* database handle to which the prepared statement given + ** in the argument belongs. This is the same database handle that was + ** the first argument to the sqlite3_prepare() that was used to create + ** the statement in the first place. + */ + public static sqlite3 sqlite3_db_handle(sqlite3_stmt pStmt) { + return pStmt != null ? ((Vdbe)pStmt).db : null; + } - /* - ** Return true if the prepared statement is guaranteed to not modify the - ** database. - */ - static bool sqlite3_stmt_readonly( sqlite3_stmt pStmt ) - { - return pStmt != null ? ( (Vdbe)pStmt ).readOnly : true; - } + /* + ** Return true if the prepared statement is guaranteed to not modify the + ** database. + */ + static bool sqlite3_stmt_readonly(sqlite3_stmt pStmt) { + return pStmt != null ? ((Vdbe)pStmt).readOnly : true; + } - /* - ** Return a pointer to the next prepared statement after pStmt associated - ** with database connection pDb. If pStmt is NULL, return the first - ** prepared statement for the database connection. Return NULL if there - ** are no more. - */ + /* + ** Return a pointer to the next prepared statement after pStmt associated + ** with database connection pDb. If pStmt is NULL, return the first + ** prepared statement for the database connection. Return NULL if there + ** are no more. + */ - public static sqlite3_stmt sqlite3_next_stmt( sqlite3 pDb, sqlite3_stmt pStmt ) - { - sqlite3_stmt pNext; - sqlite3_mutex_enter( pDb.mutex ); - if ( pStmt == null ) - { - pNext = (sqlite3_stmt)pDb.pVdbe; - } - else - { - pNext = (sqlite3_stmt)( (Vdbe)pStmt ).pNext; - } - sqlite3_mutex_leave( pDb.mutex ); - return pNext; - } - /* - ** Return the value of a status counter for a prepared statement - */ - public static int sqlite3_stmt_status( sqlite3_stmt pStmt, int op, int resetFlag ) - { - Vdbe pVdbe = (Vdbe)pStmt; - int v = pVdbe.aCounter[op - 1]; - if ( resetFlag != 0 ) - pVdbe.aCounter[op - 1] = 0; - return v; + public static sqlite3_stmt sqlite3_next_stmt(sqlite3 pDb, sqlite3_stmt pStmt) { + sqlite3_stmt pNext; + sqlite3_mutex_enter(pDb.mutex); + if (pStmt == null) { + pNext = (sqlite3_stmt)pDb.pVdbe; + } else { + pNext = (sqlite3_stmt)((Vdbe)pStmt).pNext; + } + sqlite3_mutex_leave(pDb.mutex); + return pNext; + } + /* + ** Return the value of a status counter for a prepared statement + */ + public static int sqlite3_stmt_status(sqlite3_stmt pStmt, int op, int resetFlag) { + Vdbe pVdbe = (Vdbe)pStmt; + int v = pVdbe.aCounter[op - 1]; + if (resetFlag != 0) + pVdbe.aCounter[op - 1] = 0; + return v; + } } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/vdbeaux_c.cs b/Src/IronPython.SQLite/c#sqlite/vdbeaux_c.cs index c996b9af9..a7ae335db 100644 --- a/Src/IronPython.SQLite/c#sqlite/vdbeaux_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/vdbeaux_c.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using System.IO; using System.Text; using FILE = System.IO.TextWriter; @@ -11,8 +10,6 @@ using u32 = System.UInt32; using u64 = System.UInt64; -using Pgno = System.UInt32; - #if !SQLITE_MAX_VARIABLE_NUMBER using ynVar = System.Int16; #else @@ -30,1425 +27,1248 @@ using yDbMask = System.Int32; #endif -namespace Community.CsharpSqlite -{ - using Op = Sqlite3.VdbeOp; - using sqlite3_stmt = Sqlite3.Vdbe; - using sqlite3_value = Sqlite3.Mem; - using System; - - public partial class Sqlite3 - { - /* - ** 2003 September 6 - ** - ** 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 contains code used for creating, destroying, and populating - ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.) Prior - ** to version 2.8.7, all this code was combined into the vdbe.c source file. - ** But that file was getting too big so this subroutines were split out. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include "vdbeInt.h" +namespace Community.CsharpSqlite { + using System; - /* - ** When debugging the code generator in a symbolic debugger, one can - ** set the sqlite3VdbeAddopTrace to 1 and all opcodes will be printed - ** as they are added to the instruction stream. - */ -#if SQLITE_DEBUG - static bool sqlite3VdbeAddopTrace = false; -#endif + using Op = Sqlite3.VdbeOp; + using sqlite3_stmt = Sqlite3.Vdbe; + using sqlite3_value = Sqlite3.Mem; + + public partial class Sqlite3 { + /* + ** 2003 September 6 + ** + ** 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 contains code used for creating, destroying, and populating + ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.) Prior + ** to version 2.8.7, all this code was combined into the vdbe.c source file. + ** But that file was getting too big so this subroutines were split out. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include "vdbeInt.h" + /* + ** When debugging the code generator in a symbolic debugger, one can + ** set the sqlite3VdbeAddopTrace to 1 and all opcodes will be printed + ** as they are added to the instruction stream. + */ +#if SQLITE_DEBUG + static bool sqlite3VdbeAddopTrace = false; +#endif - /* -** Create a new virtual database engine. -*/ - static Vdbe sqlite3VdbeCreate( sqlite3 db ) - { - Vdbe p; - p = new Vdbe();// sqlite3DbMallocZero(db, Vdbe).Length; - if ( p == null ) - return null; - p.db = db; - if ( db.pVdbe != null ) - { - db.pVdbe.pPrev = p; - } - p.pNext = db.pVdbe; - p.pPrev = null; - db.pVdbe = p; - p.magic = VDBE_MAGIC_INIT; - return p; - } - /* - ** Remember the SQL string for a prepared statement. + /* + ** Create a new virtual database engine. */ - static void sqlite3VdbeSetSql( Vdbe p, string z, int n, int isPrepareV2 ) - { - Debug.Assert( isPrepareV2 == 1 || isPrepareV2 == 0 ); - if ( p == null ) - return; + static Vdbe sqlite3VdbeCreate(sqlite3 db) { + Vdbe p; + p = new Vdbe();// sqlite3DbMallocZero(db, Vdbe).Length; + if (p == null) + return null; + p.db = db; + if (db.pVdbe != null) { + db.pVdbe.pPrev = p; + } + p.pNext = db.pVdbe; + p.pPrev = null; + db.pVdbe = p; + p.magic = VDBE_MAGIC_INIT; + return p; + } + + /* + ** Remember the SQL string for a prepared statement. + */ + static void sqlite3VdbeSetSql(Vdbe p, string z, int n, int isPrepareV2) { + Debug.Assert(isPrepareV2 == 1 || isPrepareV2 == 0); + if (p == null) + return; #if SQLITE_OMIT_TRACE if( 0==isPrepareV2 ) return; #endif - Debug.Assert( p.zSql == "" ); - p.zSql = z.Substring( 0, n );// sqlite3DbStrNDup(p.db, z, n); - p.isPrepareV2 = isPrepareV2 != 0; - } + Debug.Assert(p.zSql == ""); + p.zSql = z.Substring(0, n);// sqlite3DbStrNDup(p.db, z, n); + p.isPrepareV2 = isPrepareV2 != 0; + } - /* - ** Return the SQL associated with a prepared statement - */ - static public string sqlite3_sql( sqlite3_stmt pStmt ) - { - Vdbe p = (Vdbe)pStmt; - return ( p != null && p.isPrepareV2 ? p.zSql : "" ); - } + /* + ** Return the SQL associated with a prepared statement + */ + static public string sqlite3_sql(sqlite3_stmt pStmt) { + Vdbe p = (Vdbe)pStmt; + return (p != null && p.isPrepareV2 ? p.zSql : ""); + } - /* - ** Swap all content between two VDBE structures. - */ - static void sqlite3VdbeSwap( Vdbe pA, Vdbe pB ) - { - Vdbe tmp = new Vdbe(); - Vdbe pTmp = new Vdbe(); - string zTmp; - pA.CopyTo( tmp ); - pB.CopyTo( pA ); - tmp.CopyTo( pB ); - pTmp = pA.pNext; - pA.pNext = pB.pNext; - pB.pNext = pTmp; - pTmp = pA.pPrev; - pA.pPrev = pB.pPrev; - pB.pPrev = pTmp; - zTmp = pA.zSql; - pA.zSql = pB.zSql; - pB.zSql = zTmp; - pB.isPrepareV2 = pA.isPrepareV2; - } + /* + ** Swap all content between two VDBE structures. + */ + static void sqlite3VdbeSwap(Vdbe pA, Vdbe pB) { + Vdbe tmp = new Vdbe(); + Vdbe pTmp = new Vdbe(); + string zTmp; + pA.CopyTo(tmp); + pB.CopyTo(pA); + tmp.CopyTo(pB); + pTmp = pA.pNext; + pA.pNext = pB.pNext; + pB.pNext = pTmp; + pTmp = pA.pPrev; + pA.pPrev = pB.pPrev; + pB.pPrev = pTmp; + zTmp = pA.zSql; + pA.zSql = pB.zSql; + pB.zSql = zTmp; + pB.isPrepareV2 = pA.isPrepareV2; + } -#if SQLITE_DEBUG - /* -** Turn tracing on or off -*/ - static void sqlite3VdbeTrace( Vdbe p, FILE trace ) - { - p.trace = trace; - } +#if SQLITE_DEBUG + /* + ** Turn tracing on or off + */ + static void sqlite3VdbeTrace(Vdbe p, FILE trace) { + p.trace = trace; + } #endif - /* -** Resize the Vdbe.aOp array so that it is at least one op larger than -** it was. -** -** If an out-of-memory error occurs while resizing the array, return -** SQLITE_NOMEM. In this case Vdbe.aOp and Vdbe.nOpAlloc remain -** unchanged (this is so that any opcodes already allocated can be -** correctly deallocated along with the rest of the Vdbe). -*/ - static int growOpArray( Vdbe p ) - { - //VdbeOp pNew; - int nNew = ( p.nOpAlloc != 0 ? p.nOpAlloc * 2 : 1024 / 4 );//(int)(1024/sizeof(Op))); - // pNew = sqlite3DbRealloc( p.db, p.aOp, nNew * sizeof( Op ) ); - //if (pNew != null) - //{ - // p.nOpAlloc = sqlite3DbMallocSize(p.db, pNew)/sizeof(Op); - // p.aOp = pNew; - //} - p.nOpAlloc = nNew; - if ( p.aOp == null ) - p.aOp = new VdbeOp[nNew]; - else - Array.Resize( ref p.aOp, nNew ); - return ( p.aOp != null ? SQLITE_OK : SQLITE_NOMEM ); // return (pNew ? SQLITE_OK : SQLITE_NOMEM); - } - - /* - ** Add a new instruction to the list of instructions current in the - ** VDBE. Return the address of the new instruction. - ** - ** Parameters: - ** - ** p Pointer to the VDBE + /* + ** Resize the Vdbe.aOp array so that it is at least one op larger than + ** it was. ** - ** op The opcode for this instruction - ** - ** p1, p2, p3 Operands - ** - ** Use the sqlite3VdbeResolveLabel() function to fix an address and - ** the sqlite3VdbeChangeP4() function to change the value of the P4 - ** operand. - */ - static int sqlite3VdbeAddOp3( Vdbe p, int op, int p1, int p2, int p3 ) - { - int i; - VdbeOp pOp; - - i = p.nOp; - Debug.Assert( p.magic == VDBE_MAGIC_INIT ); - Debug.Assert( op > 0 && op < 0xff ); - if ( p.nOpAlloc <= i ) - { - if ( growOpArray( p ) != 0 ) - { - return 1; + ** If an out-of-memory error occurs while resizing the array, return + ** SQLITE_NOMEM. In this case Vdbe.aOp and Vdbe.nOpAlloc remain + ** unchanged (this is so that any opcodes already allocated can be + ** correctly deallocated along with the rest of the Vdbe). + */ + static int growOpArray(Vdbe p) { + //VdbeOp pNew; + int nNew = (p.nOpAlloc != 0 ? p.nOpAlloc * 2 : 1024 / 4);//(int)(1024/sizeof(Op))); + // pNew = sqlite3DbRealloc( p.db, p.aOp, nNew * sizeof( Op ) ); + //if (pNew != null) + //{ + // p.nOpAlloc = sqlite3DbMallocSize(p.db, pNew)/sizeof(Op); + // p.aOp = pNew; + //} + p.nOpAlloc = nNew; + if (p.aOp == null) + p.aOp = new VdbeOp[nNew]; + else + Array.Resize(ref p.aOp, nNew); + return (p.aOp != null ? SQLITE_OK : SQLITE_NOMEM); // return (pNew ? SQLITE_OK : SQLITE_NOMEM); } - } - p.nOp++; - if ( p.aOp[i] == null ) - p.aOp[i] = new VdbeOp(); - pOp = p.aOp[i]; - pOp.opcode = (u8)op; - pOp.p5 = 0; - pOp.p1 = p1; - pOp.p2 = p2; - pOp.p3 = p3; - pOp.p4.p = null; - pOp.p4type = P4_NOTUSED; -#if SQLITE_DEBUG - pOp.zComment = null; - if ( sqlite3VdbeAddopTrace ) - sqlite3VdbePrintOp( null, i, p.aOp[i] ); + + /* + ** Add a new instruction to the list of instructions current in the + ** VDBE. Return the address of the new instruction. + ** + ** Parameters: + ** + ** p Pointer to the VDBE + ** + ** op The opcode for this instruction + ** + ** p1, p2, p3 Operands + ** + ** Use the sqlite3VdbeResolveLabel() function to fix an address and + ** the sqlite3VdbeChangeP4() function to change the value of the P4 + ** operand. + */ + static int sqlite3VdbeAddOp3(Vdbe p, int op, int p1, int p2, int p3) { + int i; + VdbeOp pOp; + + i = p.nOp; + Debug.Assert(p.magic == VDBE_MAGIC_INIT); + Debug.Assert(op > 0 && op < 0xff); + if (p.nOpAlloc <= i) { + if (growOpArray(p) != 0) { + return 1; + } + } + p.nOp++; + if (p.aOp[i] == null) + p.aOp[i] = new VdbeOp(); + pOp = p.aOp[i]; + pOp.opcode = (u8)op; + pOp.p5 = 0; + pOp.p1 = p1; + pOp.p2 = p2; + pOp.p3 = p3; + pOp.p4.p = null; + pOp.p4type = P4_NOTUSED; +#if SQLITE_DEBUG + pOp.zComment = null; + if (sqlite3VdbeAddopTrace) + sqlite3VdbePrintOp(null, i, p.aOp[i]); #endif #if VDBE_PROFILE pOp.cycles = 0; pOp.cnt = 0; #endif - return i; - } - static int sqlite3VdbeAddOp0( Vdbe p, int op ) - { - return sqlite3VdbeAddOp3( p, op, 0, 0, 0 ); - } - static int sqlite3VdbeAddOp1( Vdbe p, int op, int p1 ) - { - return sqlite3VdbeAddOp3( p, op, p1, 0, 0 ); - } - static int sqlite3VdbeAddOp2( Vdbe p, int op, int p1, bool b2 ) - { - return sqlite3VdbeAddOp2( p, op, p1, (int)( b2 ? 1 : 0 ) ); - } - - static int sqlite3VdbeAddOp2( Vdbe p, int op, int p1, int p2 ) - { - return sqlite3VdbeAddOp3( p, op, p1, p2, 0 ); - } - - - /* - ** Add an opcode that includes the p4 value as a pointer. - */ - //P4_INT32 - static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, i32 pP4, int p4type ) - { - union_p4 _p4 = new union_p4(); - _p4.i = pP4; - int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); - sqlite3VdbeChangeP4( p, addr, _p4, p4type ); - return addr; - } + return i; + } + static int sqlite3VdbeAddOp0(Vdbe p, int op) { + return sqlite3VdbeAddOp3(p, op, 0, 0, 0); + } + static int sqlite3VdbeAddOp1(Vdbe p, int op, int p1) { + return sqlite3VdbeAddOp3(p, op, p1, 0, 0); + } + static int sqlite3VdbeAddOp2(Vdbe p, int op, int p1, bool b2) { + return sqlite3VdbeAddOp2(p, op, p1, (int)(b2 ? 1 : 0)); + } - //char - static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, char pP4, int p4type ) - { - union_p4 _p4 = new union_p4(); - _p4.z = pP4.ToString(); - int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); - sqlite3VdbeChangeP4( p, addr, _p4, p4type ); - return addr; - } + static int sqlite3VdbeAddOp2(Vdbe p, int op, int p1, int p2) { + return sqlite3VdbeAddOp3(p, op, p1, p2, 0); + } - //StringBuilder - static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, StringBuilder pP4, int p4type ) - { - // Debug.Assert( pP4 != null ); - union_p4 _p4 = new union_p4(); - _p4.z = pP4.ToString(); - int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); - sqlite3VdbeChangeP4( p, addr, _p4, p4type ); - return addr; - } - //String - static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, string pP4, int p4type ) - { - // Debug.Assert( pP4 != null ); - union_p4 _p4 = new union_p4(); - _p4.z = pP4; - int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); - sqlite3VdbeChangeP4( p, addr, _p4, p4type ); - return addr; - } + /* + ** Add an opcode that includes the p4 value as a pointer. + */ + //P4_INT32 + static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, i32 pP4, int p4type) { + union_p4 _p4 = new union_p4(); + _p4.i = pP4; + int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); + sqlite3VdbeChangeP4(p, addr, _p4, p4type); + return addr; + } + + //char + static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, char pP4, int p4type) { + union_p4 _p4 = new union_p4(); + _p4.z = pP4.ToString(); + int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); + sqlite3VdbeChangeP4(p, addr, _p4, p4type); + return addr; + } + + //StringBuilder + static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, StringBuilder pP4, int p4type) { + // Debug.Assert( pP4 != null ); + union_p4 _p4 = new union_p4(); + _p4.z = pP4.ToString(); + int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); + sqlite3VdbeChangeP4(p, addr, _p4, p4type); + return addr; + } + + //String + static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, string pP4, int p4type) { + // Debug.Assert( pP4 != null ); + union_p4 _p4 = new union_p4(); + _p4.z = pP4; + int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); + sqlite3VdbeChangeP4(p, addr, _p4, p4type); + return addr; + } + + static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, byte[] pP4, int p4type) { + Debug.Assert(op == OP_Null || pP4 != null); + union_p4 _p4 = new union_p4(); + _p4.z = Encoding.UTF8.GetString(pP4, 0, pP4.Length); + int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); + sqlite3VdbeChangeP4(p, addr, _p4, p4type); + return addr; + } + + //P4_INTARRAY + static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, int[] pP4, int p4type) { + Debug.Assert(pP4 != null); + union_p4 _p4 = new union_p4(); + _p4.ai = pP4; + int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); + sqlite3VdbeChangeP4(p, addr, _p4, p4type); + return addr; + } + //P4_INT64 + static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, i64 pP4, int p4type) { + union_p4 _p4 = new union_p4(); + _p4.pI64 = pP4; + int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); + sqlite3VdbeChangeP4(p, addr, _p4, p4type); + return addr; + } + + //DOUBLE (REAL) + static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, double pP4, int p4type) { + union_p4 _p4 = new union_p4(); + _p4.pReal = pP4; + int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); + sqlite3VdbeChangeP4(p, addr, _p4, p4type); + return addr; + } + + //FUNCDEF + static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, FuncDef pP4, int p4type) { + union_p4 _p4 = new union_p4(); + _p4.pFunc = pP4; + int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); + sqlite3VdbeChangeP4(p, addr, _p4, p4type); + return addr; + } + + //CollSeq + static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, CollSeq pP4, int p4type) { + union_p4 _p4 = new union_p4(); + _p4.pColl = pP4; + int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); + sqlite3VdbeChangeP4(p, addr, _p4, p4type); + return addr; + } + + //KeyInfo + static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, KeyInfo pP4, int p4type) { + union_p4 _p4 = new union_p4(); + _p4.pKeyInfo = pP4; + int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); + sqlite3VdbeChangeP4(p, addr, _p4, p4type); + return addr; + } - static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, byte[] pP4, int p4type ) - { - Debug.Assert( op == OP_Null || pP4 != null ); - union_p4 _p4 = new union_p4(); - _p4.z = Encoding.UTF8.GetString( pP4, 0, pP4.Length ); - int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); - sqlite3VdbeChangeP4( p, addr, _p4, p4type ); - return addr; - } +#if !SQLITE_OMIT_VIRTUALTABLE + //VTable + static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, VTable pP4, int p4type) { + Debug.Assert(pP4 != null); + union_p4 _p4 = new union_p4(); + _p4.pVtab = pP4; + int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); + sqlite3VdbeChangeP4(p, addr, _p4, p4type); + return addr; + } +#endif - //P4_INTARRAY - static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, int[] pP4, int p4type ) - { - Debug.Assert( pP4 != null ); - union_p4 _p4 = new union_p4(); - _p4.ai = pP4; - int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); - sqlite3VdbeChangeP4( p, addr, _p4, p4type ); - return addr; - } - //P4_INT64 - static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, i64 pP4, int p4type ) - { - union_p4 _p4 = new union_p4(); - _p4.pI64 = pP4; - int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); - sqlite3VdbeChangeP4( p, addr, _p4, p4type ); - return addr; - } + // static int sqlite3VdbeAddOp4( + // Vdbe p, /* Add the opcode to this VM */ + // int op, /* The new opcode */ + // int p1, /* The P1 operand */ + // int p2, /* The P2 operand */ + // int p3, /* The P3 operand */ + // union_p4 _p4, /* The P4 operand */ + // int p4type /* P4 operand type */ + //) + // { + // int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); + // sqlite3VdbeChangeP4(p, addr, _p4, p4type); + // return addr; + // } - //DOUBLE (REAL) - static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, double pP4, int p4type ) - { - union_p4 _p4 = new union_p4(); - _p4.pReal = pP4; - int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); - sqlite3VdbeChangeP4( p, addr, _p4, p4type ); - return addr; - } + /* + ** Add an OP_ParseSchema opcode. This routine is broken out from + ** sqlite3VdbeAddOp4() since it needs to also local all btrees. + ** + ** The zWhere string must have been obtained from sqlite3_malloc(). + ** This routine will take ownership of the allocated memory. + */ + static void sqlite3VdbeAddParseSchemaOp(Vdbe p, int iDb, string zWhere) { + int j; + int addr = sqlite3VdbeAddOp3(p, OP_ParseSchema, iDb, 0, 0); + sqlite3VdbeChangeP4(p, addr, zWhere, P4_DYNAMIC); + for (j = 0; j < p.db.nDb; j++) + sqlite3VdbeUsesBtree(p, j); + } - //FUNCDEF - static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, FuncDef pP4, int p4type ) - { - union_p4 _p4 = new union_p4(); - _p4.pFunc = pP4; - int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); - sqlite3VdbeChangeP4( p, addr, _p4, p4type ); - return addr; - } + /* + ** Add an opcode that includes the p4 value as an integer. + */ + static int sqlite3VdbeAddOp4Int( + Vdbe p, /* Add the opcode to this VM */ + int op, /* The new opcode */ + int p1, /* The P1 operand */ + int p2, /* The P2 operand */ + int p3, /* The P3 operand */ + int p4 /* The P4 operand as an integer */ + ) { + union_p4 _p4 = new union_p4(); + _p4.i = p4; + int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); + sqlite3VdbeChangeP4(p, addr, _p4, P4_INT32); + return addr; + } + /* + ** Create a new symbolic label for an instruction that has yet to be + ** coded. The symbolic label is really just a negative number. The + ** label can be used as the P2 value of an operation. Later, when + ** the label is resolved to a specific address, the VDBE will scan + ** through its operation list and change all values of P2 which match + ** the label into the resolved address. + ** + ** The VDBE knows that a P2 value is a label because labels are + ** always negative and P2 values are suppose to be non-negative. + ** Hence, a negative P2 value is a label that has yet to be resolved. + ** + ** Zero is returned if a malloc() fails. + */ + static int sqlite3VdbeMakeLabel(Vdbe p) { + int i; + i = p.nLabel++; + Debug.Assert(p.magic == VDBE_MAGIC_INIT); + if (i >= p.nLabelAlloc) { + int n = p.nLabelAlloc == 0 ? 15 : p.nLabelAlloc * 2 + 5; + if (p.aLabel == null) + p.aLabel = sqlite3Malloc(p.aLabel, n); + else + Array.Resize(ref p.aLabel, n); + //p.aLabel = sqlite3DbReallocOrFree(p.db, p.aLabel, + // n*sizeof(p.aLabel[0])); + p.nLabelAlloc = p.aLabel.Length;//sqlite3DbMallocSize(p.db, p.aLabel)/sizeof(p.aLabel[0]); + } + if (p.aLabel != null) { + p.aLabel[i] = -1; + } + return -1 - i; + } - //CollSeq - static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, CollSeq pP4, int p4type ) - { - union_p4 _p4 = new union_p4(); - _p4.pColl = pP4; - int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); - sqlite3VdbeChangeP4( p, addr, _p4, p4type ); - return addr; - } + /* + ** Resolve label "x" to be the address of the next instruction to + ** be inserted. The parameter "x" must have been obtained from + ** a prior call to sqlite3VdbeMakeLabel(). + */ + static void sqlite3VdbeResolveLabel(Vdbe p, int x) { + int j = -1 - x; + Debug.Assert(p.magic == VDBE_MAGIC_INIT); + Debug.Assert(j >= 0 && j < p.nLabel); + if (p.aLabel != null) { + p.aLabel[j] = p.nOp; + } + } - //KeyInfo - static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, KeyInfo pP4, int p4type ) - { - union_p4 _p4 = new union_p4(); - _p4.pKeyInfo = pP4; - int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); - sqlite3VdbeChangeP4( p, addr, _p4, p4type ); - return addr; - } + /* + ** Mark the VDBE as one that can only be run one time. + */ + static void sqlite3VdbeRunOnlyOnce(Vdbe p) { + p.runOnlyOnce = 1; + } -#if !SQLITE_OMIT_VIRTUALTABLE - //VTable - static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, VTable pP4, int p4type ) - { - Debug.Assert( pP4 != null ); - union_p4 _p4 = new union_p4(); - _p4.pVtab = pP4; - int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); - sqlite3VdbeChangeP4( p, addr, _p4, p4type ); - return addr; - } -#endif - - // static int sqlite3VdbeAddOp4( - // Vdbe p, /* Add the opcode to this VM */ - // int op, /* The new opcode */ - // int p1, /* The P1 operand */ - // int p2, /* The P2 operand */ - // int p3, /* The P3 operand */ - // union_p4 _p4, /* The P4 operand */ - // int p4type /* P4 operand type */ - //) - // { - // int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); - // sqlite3VdbeChangeP4(p, addr, _p4, p4type); - // return addr; - // } - - /* - ** Add an OP_ParseSchema opcode. This routine is broken out from - ** sqlite3VdbeAddOp4() since it needs to also local all btrees. - ** - ** The zWhere string must have been obtained from sqlite3_malloc(). - ** This routine will take ownership of the allocated memory. - */ - static void sqlite3VdbeAddParseSchemaOp( Vdbe p, int iDb, string zWhere ) - { - int j; - int addr = sqlite3VdbeAddOp3( p, OP_ParseSchema, iDb, 0, 0 ); - sqlite3VdbeChangeP4( p, addr, zWhere, P4_DYNAMIC ); - for ( j = 0; j < p.db.nDb; j++ ) - sqlite3VdbeUsesBtree( p, j ); - } +#if SQLITE_DEBUG //* sqlite3AssertMayAbort() logic */ - /* - ** Add an opcode that includes the p4 value as an integer. - */ - static int sqlite3VdbeAddOp4Int( - Vdbe p, /* Add the opcode to this VM */ - int op, /* The new opcode */ - int p1, /* The P1 operand */ - int p2, /* The P2 operand */ - int p3, /* The P3 operand */ - int p4 /* The P4 operand as an integer */ - ) - { - union_p4 _p4 = new union_p4(); - _p4.i = p4; - int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); - sqlite3VdbeChangeP4( p, addr, _p4, P4_INT32 ); - return addr; - } - /* - ** Create a new symbolic label for an instruction that has yet to be - ** coded. The symbolic label is really just a negative number. The - ** label can be used as the P2 value of an operation. Later, when - ** the label is resolved to a specific address, the VDBE will scan - ** through its operation list and change all values of P2 which match - ** the label into the resolved address. + /* + ** The following type and function are used to iterate through all opcodes + ** in a Vdbe main program and each of the sub-programs (triggers) it may + ** invoke directly or indirectly. It should be used as follows: ** - ** The VDBE knows that a P2 value is a label because labels are - ** always negative and P2 values are suppose to be non-negative. - ** Hence, a negative P2 value is a label that has yet to be resolved. + ** Op *pOp; + ** VdbeOpIter sIter; ** - ** Zero is returned if a malloc() fails. - */ - static int sqlite3VdbeMakeLabel( Vdbe p ) - { - int i; - i = p.nLabel++; - Debug.Assert( p.magic == VDBE_MAGIC_INIT ); - if ( i >= p.nLabelAlloc ) - { - int n = p.nLabelAlloc == 0 ? 15 : p.nLabelAlloc * 2 + 5; - if ( p.aLabel == null ) - p.aLabel = sqlite3Malloc( p.aLabel, n ); - else - Array.Resize( ref p.aLabel, n ); - //p.aLabel = sqlite3DbReallocOrFree(p.db, p.aLabel, - // n*sizeof(p.aLabel[0])); - p.nLabelAlloc = p.aLabel.Length;//sqlite3DbMallocSize(p.db, p.aLabel)/sizeof(p.aLabel[0]); - } - if ( p.aLabel != null ) - { - p.aLabel[i] = -1; - } - return -1 - i; - } - - /* - ** Resolve label "x" to be the address of the next instruction to - ** be inserted. The parameter "x" must have been obtained from - ** a prior call to sqlite3VdbeMakeLabel(). - */ - static void sqlite3VdbeResolveLabel( Vdbe p, int x ) - { - int j = -1 - x; - Debug.Assert( p.magic == VDBE_MAGIC_INIT ); - Debug.Assert( j >= 0 && j < p.nLabel ); - if ( p.aLabel != null ) - { - p.aLabel[j] = p.nOp; - } - } - - /* - ** Mark the VDBE as one that can only be run one time. - */ - static void sqlite3VdbeRunOnlyOnce( Vdbe p ) - { - p.runOnlyOnce = 1; - } + ** memset(&sIter, 0, sizeof(sIter)); + ** sIter.v = v; // v is of type Vdbe* + ** while( (pOp = opIterNext(&sIter)) ){ + ** // Do something with pOp + ** } + ** sqlite3DbFree(v->db, sIter.apSub); + ** + */ + //typedef struct VdbeOpIter VdbeOpIter; + public class VdbeOpIter { + public Vdbe v; /* Vdbe to iterate through the opcodes of */ + public SubProgram[] apSub; /* Array of subprograms */ + public int nSub; /* Number of entries in apSub */ + public int iAddr; /* Address of next instruction to return */ + public int iSub; /* 0 = main program, 1 = first sub-program etc. */ + }; + + static Op opIterNext(VdbeOpIter p) { + Vdbe v = p.v; + Op pRet = null; + Op[] aOp; + int nOp; + + if (p.iSub <= p.nSub) { + + if (p.iSub == 0) { + aOp = v.aOp; + nOp = v.nOp; + } else { + aOp = p.apSub[p.iSub - 1].aOp; + nOp = p.apSub[p.iSub - 1].nOp; + } + Debug.Assert(p.iAddr < nOp); -#if SQLITE_DEBUG //* sqlite3AssertMayAbort() logic */ + pRet = aOp[p.iAddr]; + p.iAddr++; + if (p.iAddr == nOp) { + p.iSub++; + p.iAddr = 0; + } - /* -** The following type and function are used to iterate through all opcodes -** in a Vdbe main program and each of the sub-programs (triggers) it may -** invoke directly or indirectly. It should be used as follows: -** -** Op *pOp; -** VdbeOpIter sIter; -** -** memset(&sIter, 0, sizeof(sIter)); -** sIter.v = v; // v is of type Vdbe* -** while( (pOp = opIterNext(&sIter)) ){ -** // Do something with pOp -** } -** sqlite3DbFree(v->db, sIter.apSub); -** -*/ - //typedef struct VdbeOpIter VdbeOpIter; - public class VdbeOpIter - { - public Vdbe v; /* Vdbe to iterate through the opcodes of */ - public SubProgram[] apSub; /* Array of subprograms */ - public int nSub; /* Number of entries in apSub */ - public int iAddr; /* Address of next instruction to return */ - public int iSub; /* 0 = main program, 1 = first sub-program etc. */ - }; - - static Op opIterNext( VdbeOpIter p ) - { - Vdbe v = p.v; - Op pRet = null; - Op[] aOp; - int nOp; - - if ( p.iSub <= p.nSub ) - { - - if ( p.iSub == 0 ) - { - aOp = v.aOp; - nOp = v.nOp; - } - else - { - aOp = p.apSub[p.iSub - 1].aOp; - nOp = p.apSub[p.iSub - 1].nOp; - } - Debug.Assert( p.iAddr < nOp ); - - pRet = aOp[p.iAddr]; - p.iAddr++; - if ( p.iAddr == nOp ) - { - p.iSub++; - p.iAddr = 0; - } + if (pRet.p4type == P4_SUBPROGRAM) { + //int nByte = p.nSub + 1 ) * sizeof( SubProgram* ); + int j; + for (j = 0; j < p.nSub; j++) { + if (p.apSub[j] == pRet.p4.pProgram) + break; + } + if (j == p.nSub) { + Array.Resize(ref p.apSub, p.nSub + 1);/// sqlite3DbReallocOrFree( v.db, p.apSub, nByte ); + //if( null==p.apSub ){ + // pRet = null; + //}else{ + p.apSub[p.nSub++] = pRet.p4.pProgram; + //} + } + } + } - if ( pRet.p4type == P4_SUBPROGRAM ) - { - //int nByte = p.nSub + 1 ) * sizeof( SubProgram* ); - int j; - for ( j = 0; j < p.nSub; j++ ) - { - if ( p.apSub[j] == pRet.p4.pProgram ) - break; - } - if ( j == p.nSub ) - { - Array.Resize( ref p.apSub, p.nSub + 1 );/// sqlite3DbReallocOrFree( v.db, p.apSub, nByte ); - //if( null==p.apSub ){ - // pRet = null; - //}else{ - p.apSub[p.nSub++] = pRet.p4.pProgram; - //} - } + return pRet; } - } - return pRet; - } - - /* - ** Check if the program stored in the VM associated with pParse may - ** throw an ABORT exception (causing the statement, but not entire transaction - ** to be rolled back). This condition is true if the main program or any - ** sub-programs contains any of the following: - ** - ** * OP_Halt with P1=SQLITE_CONSTRAINT and P2=OE_Abort. - ** * OP_HaltIfNull with P1=SQLITE_CONSTRAINT and P2=OE_Abort. - ** * OP_Destroy - ** * OP_VUpdate - ** * OP_VRename - ** * OP_FkCounter with P2==0 (immediate foreign key constraint) - ** - ** Then check that the value of Parse.mayAbort is true if an - ** ABORT may be thrown, or false otherwise. Return true if it does - ** match, or false otherwise. This function is intended to be used as - ** part of an assert statement in the compiler. Similar to: - ** - ** Debug.Assert( sqlite3VdbeAssertMayAbort(pParse->pVdbe, pParse->mayAbort) ); - */ - static int sqlite3VdbeAssertMayAbort( Vdbe v, int mayAbort ) - { - int hasAbort = 0; - Op pOp; - VdbeOpIter sIter; - sIter = new VdbeOpIter();// memset( &sIter, 0, sizeof( sIter ) ); - sIter.v = v; - - while ( ( pOp = opIterNext( sIter ) ) != null ) - { - int opcode = pOp.opcode; - if ( opcode == OP_Destroy || opcode == OP_VUpdate || opcode == OP_VRename + /* + ** Check if the program stored in the VM associated with pParse may + ** throw an ABORT exception (causing the statement, but not entire transaction + ** to be rolled back). This condition is true if the main program or any + ** sub-programs contains any of the following: + ** + ** * OP_Halt with P1=SQLITE_CONSTRAINT and P2=OE_Abort. + ** * OP_HaltIfNull with P1=SQLITE_CONSTRAINT and P2=OE_Abort. + ** * OP_Destroy + ** * OP_VUpdate + ** * OP_VRename + ** * OP_FkCounter with P2==0 (immediate foreign key constraint) + ** + ** Then check that the value of Parse.mayAbort is true if an + ** ABORT may be thrown, or false otherwise. Return true if it does + ** match, or false otherwise. This function is intended to be used as + ** part of an assert statement in the compiler. Similar to: + ** + ** Debug.Assert( sqlite3VdbeAssertMayAbort(pParse->pVdbe, pParse->mayAbort) ); + */ + static int sqlite3VdbeAssertMayAbort(Vdbe v, int mayAbort) { + int hasAbort = 0; + Op pOp; + VdbeOpIter sIter; + sIter = new VdbeOpIter();// memset( &sIter, 0, sizeof( sIter ) ); + sIter.v = v; + + while ((pOp = opIterNext(sIter)) != null) { + int opcode = pOp.opcode; + if (opcode == OP_Destroy || opcode == OP_VUpdate || opcode == OP_VRename #if !SQLITE_OMIT_FOREIGN_KEY - || ( opcode == OP_FkCounter && pOp.p1 == 0 && pOp.p2 == 1 ) + || (opcode == OP_FkCounter && pOp.p1 == 0 && pOp.p2 == 1) #endif - || ( ( opcode == OP_Halt || opcode == OP_HaltIfNull ) - && ( pOp.p1 == SQLITE_CONSTRAINT && pOp.p2 == OE_Abort ) ) - ) - { - hasAbort = 1; - break; + || ((opcode == OP_Halt || opcode == OP_HaltIfNull) + && (pOp.p1 == SQLITE_CONSTRAINT && pOp.p2 == OE_Abort)) + ) { + hasAbort = 1; + break; + } + } + sIter.apSub = null;// sqlite3DbFree( v.db, sIter.apSub ); + + /* Return true if hasAbort==mayAbort. Or if a malloc failure occured. + ** If malloc failed, then the while() loop above may not have iterated + ** through all opcodes and hasAbort may be set incorrectly. Return + ** true for this case to prevent the Debug.Assert() in the callers frame + ** from failing. */ + return (hasAbort == mayAbort) ? 1 : 0;//v.db.mallocFailed !=0|| hasAbort==mayAbort ); } - } - sIter.apSub = null;// sqlite3DbFree( v.db, sIter.apSub ); - - /* Return true if hasAbort==mayAbort. Or if a malloc failure occured. - ** If malloc failed, then the while() loop above may not have iterated - ** through all opcodes and hasAbort may be set incorrectly. Return - ** true for this case to prevent the Debug.Assert() in the callers frame - ** from failing. */ - return ( hasAbort == mayAbort ) ? 1 : 0;//v.db.mallocFailed !=0|| hasAbort==mayAbort ); - } #endif //* SQLITE_DEBUG - the sqlite3AssertMayAbort() function */ - /* -** Loop through the program looking for P2 values that are negative -** on jump instructions. Each such value is a label. Resolve the -** label by setting the P2 value to its correct non-zero value. -** -** This routine is called once after all opcodes have been inserted. -** -** Variable *pMaxFuncArgs is set to the maximum value of any P2 argument -** to an OP_Function, OP_AggStep or OP_VFilter opcode. This is used by -** sqlite3VdbeMakeReady() to size the Vdbe.apArg[] array. -** -** The Op.opflags field is set on all opcodes. -*/ - static void resolveP2Values( Vdbe p, ref int pMaxFuncArgs ) - { - int i; - int nMaxArgs = pMaxFuncArgs; - Op pOp; - int[] aLabel = p.aLabel; - p.readOnly = true; - for ( i = 0; i < p.nOp; i++ )// for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++) - { - pOp = p.aOp[i]; - u8 opcode = pOp.opcode; - - pOp.opflags = (u8)sqlite3OpcodeProperty[opcode]; - if ( opcode == OP_Function || opcode == OP_AggStep ) - { - if ( pOp.p5 > nMaxArgs ) - nMaxArgs = pOp.p5; - } - else if ( ( opcode == OP_Transaction && pOp.p2 != 0 ) || opcode == OP_Vacuum ) - { - p.readOnly = false; + /* + ** Loop through the program looking for P2 values that are negative + ** on jump instructions. Each such value is a label. Resolve the + ** label by setting the P2 value to its correct non-zero value. + ** + ** This routine is called once after all opcodes have been inserted. + ** + ** Variable *pMaxFuncArgs is set to the maximum value of any P2 argument + ** to an OP_Function, OP_AggStep or OP_VFilter opcode. This is used by + ** sqlite3VdbeMakeReady() to size the Vdbe.apArg[] array. + ** + ** The Op.opflags field is set on all opcodes. + */ + static void resolveP2Values(Vdbe p, ref int pMaxFuncArgs) { + int i; + int nMaxArgs = pMaxFuncArgs; + Op pOp; + int[] aLabel = p.aLabel; + p.readOnly = true; + for (i = 0; i < p.nOp; i++)// for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++) + { + pOp = p.aOp[i]; + u8 opcode = pOp.opcode; + + pOp.opflags = (u8)sqlite3OpcodeProperty[opcode]; + if (opcode == OP_Function || opcode == OP_AggStep) { + if (pOp.p5 > nMaxArgs) + nMaxArgs = pOp.p5; + } else if ((opcode == OP_Transaction && pOp.p2 != 0) || opcode == OP_Vacuum) { + p.readOnly = false; #if !SQLITE_OMIT_VIRTUALTABLE - } - else if ( opcode == OP_VUpdate ) - { - if ( pOp.p2 > nMaxArgs ) - nMaxArgs = pOp.p2; - } - else if ( opcode == OP_VFilter ) - { - int n; - Debug.Assert( p.nOp - i >= 3 ); - Debug.Assert( p.aOp[i - 1].opcode == OP_Integer );//pOp[-1].opcode==OP_Integer ); - n = p.aOp[i - 1].p1;//pOp[-1].p1; - if ( n > nMaxArgs ) - nMaxArgs = n; + } else if (opcode == OP_VUpdate) { + if (pOp.p2 > nMaxArgs) + nMaxArgs = pOp.p2; + } else if (opcode == OP_VFilter) { + int n; + Debug.Assert(p.nOp - i >= 3); + Debug.Assert(p.aOp[i - 1].opcode == OP_Integer);//pOp[-1].opcode==OP_Integer ); + n = p.aOp[i - 1].p1;//pOp[-1].p1; + if (n > nMaxArgs) + nMaxArgs = n; #endif + } + + if ((pOp.opflags & OPFLG_JUMP) != 0 && pOp.p2 < 0) { + Debug.Assert(-1 - pOp.p2 < p.nLabel); + pOp.p2 = aLabel[-1 - pOp.p2]; + } + } + sqlite3DbFree(p.db, ref p.aLabel); + + pMaxFuncArgs = nMaxArgs; } - if ( ( pOp.opflags & OPFLG_JUMP ) != 0 && pOp.p2 < 0 ) - { - Debug.Assert( -1 - pOp.p2 < p.nLabel ); - pOp.p2 = aLabel[-1 - pOp.p2]; + /* + ** Return the address of the next instruction to be inserted. + */ + static int sqlite3VdbeCurrentAddr(Vdbe p) { + Debug.Assert(p.magic == VDBE_MAGIC_INIT); + return p.nOp; } - } - sqlite3DbFree( p.db, ref p.aLabel ); - pMaxFuncArgs = nMaxArgs; - } + /* + ** This function returns a pointer to the array of opcodes associated with + ** the Vdbe passed as the first argument. It is the callers responsibility + ** to arrange for the returned array to be eventually freed using the + ** vdbeFreeOpArray() function. + ** + ** Before returning, *pnOp is set to the number of entries in the returned + ** array. Also, *pnMaxArg is set to the larger of its current value and + ** the number of entries in the Vdbe.apArg[] array required to execute the + ** returned program. + */ + static VdbeOp[] sqlite3VdbeTakeOpArray(Vdbe p, ref int pnOp, ref int pnMaxArg) { + VdbeOp[] aOp = p.aOp; + Debug.Assert(aOp != null);// && 0==p.db.mallocFailed ); - /* - ** Return the address of the next instruction to be inserted. - */ - static int sqlite3VdbeCurrentAddr( Vdbe p ) - { - Debug.Assert( p.magic == VDBE_MAGIC_INIT ); - return p.nOp; - } + /* Check that sqlite3VdbeUsesBtree() was not called on this VM */ + Debug.Assert(p.btreeMask == 0); - /* - ** This function returns a pointer to the array of opcodes associated with - ** the Vdbe passed as the first argument. It is the callers responsibility - ** to arrange for the returned array to be eventually freed using the - ** vdbeFreeOpArray() function. - ** - ** Before returning, *pnOp is set to the number of entries in the returned - ** array. Also, *pnMaxArg is set to the larger of its current value and - ** the number of entries in the Vdbe.apArg[] array required to execute the - ** returned program. - */ - static VdbeOp[] sqlite3VdbeTakeOpArray( Vdbe p, ref int pnOp, ref int pnMaxArg ) - { - VdbeOp[] aOp = p.aOp; - Debug.Assert( aOp != null );// && 0==p.db.mallocFailed ); - - /* Check that sqlite3VdbeUsesBtree() was not called on this VM */ - Debug.Assert( p.btreeMask == 0 ); - - resolveP2Values( p, ref pnMaxArg ); - pnOp = p.nOp; - p.aOp = null; - return aOp; - } + resolveP2Values(p, ref pnMaxArg); + pnOp = p.nOp; + p.aOp = null; + return aOp; + } - /* - ** Add a whole list of operations to the operation stack. Return the - ** address of the first operation added. - */ - static int sqlite3VdbeAddOpList( Vdbe p, int nOp, VdbeOpList[] aOp ) - { - int addr; - Debug.Assert( p.magic == VDBE_MAGIC_INIT ); - if ( p.nOp + nOp > p.nOpAlloc && growOpArray( p ) != 0 ) - { - return 0; - } - addr = p.nOp; - if ( ALWAYS( nOp > 0 ) ) - { - int i; - VdbeOpList pIn; - for ( i = 0; i < nOp; i++ ) - { - pIn = aOp[i]; - int p2 = pIn.p2; - if ( p.aOp[i + addr] == null ) - p.aOp[i + addr] = new VdbeOp(); - VdbeOp pOut = p.aOp[i + addr]; - pOut.opcode = pIn.opcode; - pOut.p1 = pIn.p1; - if ( p2 < 0 && ( sqlite3OpcodeProperty[pOut.opcode] & OPFLG_JUMP ) != 0 ) - { - pOut.p2 = addr + ( -1 - p2 );// ADDR(p2); - } - else - { - pOut.p2 = p2; - } - pOut.p3 = pIn.p3; - pOut.p4type = P4_NOTUSED; - pOut.p4.p = null; - pOut.p5 = 0; -#if SQLITE_DEBUG - pOut.zComment = null; - if ( sqlite3VdbeAddopTrace ) - { - sqlite3VdbePrintOp( null, i + addr, p.aOp[i + addr] ); - } + /* + ** Add a whole list of operations to the operation stack. Return the + ** address of the first operation added. + */ + static int sqlite3VdbeAddOpList(Vdbe p, int nOp, VdbeOpList[] aOp) { + int addr; + Debug.Assert(p.magic == VDBE_MAGIC_INIT); + if (p.nOp + nOp > p.nOpAlloc && growOpArray(p) != 0) { + return 0; + } + addr = p.nOp; + if (ALWAYS(nOp > 0)) { + int i; + VdbeOpList pIn; + for (i = 0; i < nOp; i++) { + pIn = aOp[i]; + int p2 = pIn.p2; + if (p.aOp[i + addr] == null) + p.aOp[i + addr] = new VdbeOp(); + VdbeOp pOut = p.aOp[i + addr]; + pOut.opcode = pIn.opcode; + pOut.p1 = pIn.p1; + if (p2 < 0 && (sqlite3OpcodeProperty[pOut.opcode] & OPFLG_JUMP) != 0) { + pOut.p2 = addr + (-1 - p2);// ADDR(p2); + } else { + pOut.p2 = p2; + } + pOut.p3 = pIn.p3; + pOut.p4type = P4_NOTUSED; + pOut.p4.p = null; + pOut.p5 = 0; +#if SQLITE_DEBUG + pOut.zComment = null; + if (sqlite3VdbeAddopTrace) { + sqlite3VdbePrintOp(null, i + addr, p.aOp[i + addr]); + } #endif + } + p.nOp += nOp; + } + return addr; } - p.nOp += nOp; - } - return addr; - } - /* - ** Change the value of the P1 operand for a specific instruction. - ** This routine is useful when a large program is loaded from a - ** static array using sqlite3VdbeAddOpList but we want to make a - ** few minor changes to the program. - */ - static void sqlite3VdbeChangeP1( Vdbe p, int addr, int val ) - { - Debug.Assert( p != null ); - Debug.Assert( addr >= 0 ); - if ( p.nOp > addr ) - { - p.aOp[addr].p1 = val; - } - } + /* + ** Change the value of the P1 operand for a specific instruction. + ** This routine is useful when a large program is loaded from a + ** static array using sqlite3VdbeAddOpList but we want to make a + ** few minor changes to the program. + */ + static void sqlite3VdbeChangeP1(Vdbe p, int addr, int val) { + Debug.Assert(p != null); + Debug.Assert(addr >= 0); + if (p.nOp > addr) { + p.aOp[addr].p1 = val; + } + } - /* - ** Change the value of the P2 operand for a specific instruction. - ** This routine is useful for setting a jump destination. - */ - static void sqlite3VdbeChangeP2( Vdbe p, int addr, int val ) - { - Debug.Assert( p != null ); - Debug.Assert( addr >= 0 ); - if ( p.nOp > addr ) - { - p.aOp[addr].p2 = val; - } - } + /* + ** Change the value of the P2 operand for a specific instruction. + ** This routine is useful for setting a jump destination. + */ + static void sqlite3VdbeChangeP2(Vdbe p, int addr, int val) { + Debug.Assert(p != null); + Debug.Assert(addr >= 0); + if (p.nOp > addr) { + p.aOp[addr].p2 = val; + } + } - /* - ** Change the value of the P3 operand for a specific instruction. - */ - static void sqlite3VdbeChangeP3( Vdbe p, int addr, int val ) - { - Debug.Assert( p != null ); - Debug.Assert( addr >= 0 ); - if ( p.nOp > addr ) - { - p.aOp[addr].p3 = val; - } - } + /* + ** Change the value of the P3 operand for a specific instruction. + */ + static void sqlite3VdbeChangeP3(Vdbe p, int addr, int val) { + Debug.Assert(p != null); + Debug.Assert(addr >= 0); + if (p.nOp > addr) { + p.aOp[addr].p3 = val; + } + } - /* - ** Change the value of the P5 operand for the most recently - ** added operation. - */ - static void sqlite3VdbeChangeP5( Vdbe p, u8 val ) - { - Debug.Assert( p != null ); - if ( p.aOp != null ) - { - Debug.Assert( p.nOp > 0 ); - p.aOp[p.nOp - 1].p5 = val; - } - } + /* + ** Change the value of the P5 operand for the most recently + ** added operation. + */ + static void sqlite3VdbeChangeP5(Vdbe p, u8 val) { + Debug.Assert(p != null); + if (p.aOp != null) { + Debug.Assert(p.nOp > 0); + p.aOp[p.nOp - 1].p5 = val; + } + } - /* - ** Change the P2 operand of instruction addr so that it points to - ** the address of the next instruction to be coded. - */ - static void sqlite3VdbeJumpHere( Vdbe p, int addr ) - { - Debug.Assert( addr >= 0 ); - sqlite3VdbeChangeP2( p, addr, p.nOp ); - } + /* + ** Change the P2 operand of instruction addr so that it points to + ** the address of the next instruction to be coded. + */ + static void sqlite3VdbeJumpHere(Vdbe p, int addr) { + Debug.Assert(addr >= 0); + sqlite3VdbeChangeP2(p, addr, p.nOp); + } - /* - ** If the input FuncDef structure is ephemeral, then free it. If - ** the FuncDef is not ephermal, then do nothing. - */ - static void freeEphemeralFunction( sqlite3 db, FuncDef pDef ) - { - if ( ALWAYS( pDef ) && ( pDef.flags & SQLITE_FUNC_EPHEM ) != 0 ) - { - pDef = null; - sqlite3DbFree( db, ref pDef ); - } - } + /* + ** If the input FuncDef structure is ephemeral, then free it. If + ** the FuncDef is not ephermal, then do nothing. + */ + static void freeEphemeralFunction(sqlite3 db, FuncDef pDef) { + if (ALWAYS(pDef) && (pDef.flags & SQLITE_FUNC_EPHEM) != 0) { + pDef = null; + sqlite3DbFree(db, ref pDef); + } + } - //static void vdbeFreeOpArray(sqlite3 *, Op *, int); + //static void vdbeFreeOpArray(sqlite3 *, Op *, int); - /* - ** Delete a P4 value if necessary. - */ - static void freeP4( sqlite3 db, int p4type, object p4 ) - { - if ( p4 != null ) - { - switch ( p4type ) - { - case P4_REAL: - case P4_INT64: - case P4_DYNAMIC: - case P4_KEYINFO: - case P4_INTARRAY: - case P4_KEYINFO_HANDOFF: - { - sqlite3DbFree( db, ref p4 ); - break; - } - case P4_MPRINTF: - { - if ( db.pnBytesFreed == 0 ) - p4 = null;// sqlite3_free( ref p4 ); - break; - } - case P4_VDBEFUNC: - { - VdbeFunc pVdbeFunc = (VdbeFunc)p4; - freeEphemeralFunction( db, pVdbeFunc.pFunc ); - if ( db.pnBytesFreed == 0 ) - sqlite3VdbeDeleteAuxData( pVdbeFunc, 0 ); - sqlite3DbFree( db, ref pVdbeFunc ); - break; - } - case P4_FUNCDEF: - { - freeEphemeralFunction( db, (FuncDef)p4 ); - break; - } - case P4_MEM: - { - if ( db.pnBytesFreed == 0 ) - { - p4 = null;// sqlite3ValueFree(ref (sqlite3_value)p4); - } - else - { - Mem p = (Mem)p4; - //sqlite3DbFree( db, ref p.zMalloc ); - sqlite3DbFree( db, ref p ); - } - break; - } - case P4_VTAB: - { - if ( db.pnBytesFreed == 0 ) - sqlite3VtabUnlock( (VTable)p4 ); - break; + /* + ** Delete a P4 value if necessary. + */ + static void freeP4(sqlite3 db, int p4type, object p4) { + if (p4 != null) { + switch (p4type) { + case P4_REAL: + case P4_INT64: + case P4_DYNAMIC: + case P4_KEYINFO: + case P4_INTARRAY: + case P4_KEYINFO_HANDOFF: { + sqlite3DbFree(db, ref p4); + break; + } + case P4_MPRINTF: { + if (db.pnBytesFreed == 0) + p4 = null;// sqlite3_free( ref p4 ); + break; + } + case P4_VDBEFUNC: { + VdbeFunc pVdbeFunc = (VdbeFunc)p4; + freeEphemeralFunction(db, pVdbeFunc.pFunc); + if (db.pnBytesFreed == 0) + sqlite3VdbeDeleteAuxData(pVdbeFunc, 0); + sqlite3DbFree(db, ref pVdbeFunc); + break; + } + case P4_FUNCDEF: { + freeEphemeralFunction(db, (FuncDef)p4); + break; + } + case P4_MEM: { + if (db.pnBytesFreed == 0) { + p4 = null;// sqlite3ValueFree(ref (sqlite3_value)p4); + } else { + Mem p = (Mem)p4; + //sqlite3DbFree( db, ref p.zMalloc ); + sqlite3DbFree(db, ref p); + } + break; + } + case P4_VTAB: { + if (db.pnBytesFreed == 0) + sqlite3VtabUnlock((VTable)p4); + break; + } + } } } - } - } - /* - ** Free the space allocated for aOp and any p4 values allocated for the - ** opcodes contained within. If aOp is not NULL it is assumed to contain - ** nOp entries. - */ - static void vdbeFreeOpArray( sqlite3 db, ref Op[] aOp, int nOp ) - { - if ( aOp != null ) - { - //Op pOp; - // for(pOp=aOp; pOp<&aOp[nOp]; pOp++){ - // freeP4(db, pOp.p4type, pOp.p4.p); - //#if SQLITE_DEBUG - // sqlite3DbFree(db, ref pOp.zComment); - //#endif - // } - // } - // sqlite3DbFree(db, aOp); - aOp = null; - } - } + /* + ** Free the space allocated for aOp and any p4 values allocated for the + ** opcodes contained within. If aOp is not NULL it is assumed to contain + ** nOp entries. + */ + static void vdbeFreeOpArray(sqlite3 db, ref Op[] aOp, int nOp) { + if (aOp != null) { + //Op pOp; + // for(pOp=aOp; pOp<&aOp[nOp]; pOp++){ + // freeP4(db, pOp.p4type, pOp.p4.p); + //#if SQLITE_DEBUG + // sqlite3DbFree(db, ref pOp.zComment); + //#endif + // } + // } + // sqlite3DbFree(db, aOp); + aOp = null; + } + } - /* - ** Link the SubProgram object passed as the second argument into the linked - ** list at Vdbe.pSubProgram. This list is used to delete all sub-program - ** objects when the VM is no longer required. - */ - static void sqlite3VdbeLinkSubProgram( Vdbe pVdbe, SubProgram p ) - { - p.pNext = pVdbe.pProgram; - pVdbe.pProgram = p; - } + /* + ** Link the SubProgram object passed as the second argument into the linked + ** list at Vdbe.pSubProgram. This list is used to delete all sub-program + ** objects when the VM is no longer required. + */ + static void sqlite3VdbeLinkSubProgram(Vdbe pVdbe, SubProgram p) { + p.pNext = pVdbe.pProgram; + pVdbe.pProgram = p; + } - /* - ** Change N opcodes starting at addr to No-ops. - */ - static void sqlite3VdbeChangeToNoop( Vdbe p, int addr, int N ) - { - if ( p.aOp != null ) - { - sqlite3 db = p.db; - while ( N-- > 0 ) - { - VdbeOp pOp = p.aOp[addr + N]; - freeP4( db, pOp.p4type, pOp.p4.p ); - pOp = p.aOp[addr + N] = new VdbeOp();//memset(pOp, 0, sizeof(pOp[0])); - pOp.opcode = OP_Noop; - //pOp++; + /* + ** Change N opcodes starting at addr to No-ops. + */ + static void sqlite3VdbeChangeToNoop(Vdbe p, int addr, int N) { + if (p.aOp != null) { + sqlite3 db = p.db; + while (N-- > 0) { + VdbeOp pOp = p.aOp[addr + N]; + freeP4(db, pOp.p4type, pOp.p4.p); + pOp = p.aOp[addr + N] = new VdbeOp();//memset(pOp, 0, sizeof(pOp[0])); + pOp.opcode = OP_Noop; + //pOp++; + } + } } - } - } - /* - ** Change the value of the P4 operand for a specific instruction. - ** This routine is useful when a large program is loaded from a - ** static array using sqlite3VdbeAddOpList but we want to make a - ** few minor changes to the program. - ** - ** If n>=0 then the P4 operand is dynamic, meaning that a copy of - ** the string is made into memory obtained from sqlite3Malloc(). - ** A value of n==0 means copy bytes of zP4 up to and including the - ** first null byte. If n>0 then copy n+1 bytes of zP4. - ** - ** If n==P4_KEYINFO it means that zP4 is a pointer to a KeyInfo structure. - ** A copy is made of the KeyInfo structure into memory obtained from - ** sqlite3Malloc, to be freed when the Vdbe is finalized. - ** n==P4_KEYINFO_HANDOFF indicates that zP4 points to a KeyInfo structure - ** stored in memory that the caller has obtained from sqlite3Malloc. The - ** caller should not free the allocation, it will be freed when the Vdbe is - ** finalized. - ** - ** Other values of n (P4_STATIC, P4_COLLSEQ etc.) indicate that zP4 points - ** to a string or structure that is guaranteed to exist for the lifetime of - ** the Vdbe. In these cases we can just copy the pointer. - ** - ** If addr<0 then change P4 on the most recently inserted instruction. - */ - - //P4_COLLSEQ - static void sqlite3VdbeChangeP4( Vdbe p, int addr, CollSeq pColl, int n ) - { - union_p4 _p4 = new union_p4(); - _p4.pColl = pColl; - sqlite3VdbeChangeP4( p, addr, _p4, n ); - } - //P4_FUNCDEF - static void sqlite3VdbeChangeP4( Vdbe p, int addr, FuncDef pFunc, int n ) - { - union_p4 _p4 = new union_p4(); - _p4.pFunc = pFunc; - sqlite3VdbeChangeP4( p, addr, _p4, n ); - } - //P4_INT32 - static void sqlite3VdbeChangeP4( Vdbe p, int addr, int i32n, int n ) - { - union_p4 _p4 = new union_p4(); - _p4.i = i32n; - sqlite3VdbeChangeP4( p, addr, _p4, n ); - } - - //P4_KEYINFO - static void sqlite3VdbeChangeP4( Vdbe p, int addr, KeyInfo pKeyInfo, int n ) - { - union_p4 _p4 = new union_p4(); - _p4.pKeyInfo = pKeyInfo; - sqlite3VdbeChangeP4( p, addr, _p4, n ); - } - //CHAR - static void sqlite3VdbeChangeP4( Vdbe p, int addr, char c, int n ) - { - union_p4 _p4 = new union_p4(); - _p4.z = c.ToString(); - sqlite3VdbeChangeP4( p, addr, _p4, n ); - } - - //MEM - static void sqlite3VdbeChangeP4( Vdbe p, int addr, Mem m, int n ) - { - union_p4 _p4 = new union_p4(); - _p4.pMem = m; - sqlite3VdbeChangeP4( p, addr, _p4, n ); - } + /* + ** Change the value of the P4 operand for a specific instruction. + ** This routine is useful when a large program is loaded from a + ** static array using sqlite3VdbeAddOpList but we want to make a + ** few minor changes to the program. + ** + ** If n>=0 then the P4 operand is dynamic, meaning that a copy of + ** the string is made into memory obtained from sqlite3Malloc(). + ** A value of n==0 means copy bytes of zP4 up to and including the + ** first null byte. If n>0 then copy n+1 bytes of zP4. + ** + ** If n==P4_KEYINFO it means that zP4 is a pointer to a KeyInfo structure. + ** A copy is made of the KeyInfo structure into memory obtained from + ** sqlite3Malloc, to be freed when the Vdbe is finalized. + ** n==P4_KEYINFO_HANDOFF indicates that zP4 points to a KeyInfo structure + ** stored in memory that the caller has obtained from sqlite3Malloc. The + ** caller should not free the allocation, it will be freed when the Vdbe is + ** finalized. + ** + ** Other values of n (P4_STATIC, P4_COLLSEQ etc.) indicate that zP4 points + ** to a string or structure that is guaranteed to exist for the lifetime of + ** the Vdbe. In these cases we can just copy the pointer. + ** + ** If addr<0 then change P4 on the most recently inserted instruction. + */ - //STRING + //P4_COLLSEQ + static void sqlite3VdbeChangeP4(Vdbe p, int addr, CollSeq pColl, int n) { + union_p4 _p4 = new union_p4(); + _p4.pColl = pColl; + sqlite3VdbeChangeP4(p, addr, _p4, n); + } + //P4_FUNCDEF + static void sqlite3VdbeChangeP4(Vdbe p, int addr, FuncDef pFunc, int n) { + union_p4 _p4 = new union_p4(); + _p4.pFunc = pFunc; + sqlite3VdbeChangeP4(p, addr, _p4, n); + } + //P4_INT32 + static void sqlite3VdbeChangeP4(Vdbe p, int addr, int i32n, int n) { + union_p4 _p4 = new union_p4(); + _p4.i = i32n; + sqlite3VdbeChangeP4(p, addr, _p4, n); + } - //STRING + Type - static void sqlite3VdbeChangeP4( Vdbe p, int addr, string z, dxDel P4_Type ) - { - union_p4 _p4 = new union_p4(); - _p4.z = z; - sqlite3VdbeChangeP4( p, addr, _p4, P4_DYNAMIC ); - } + //P4_KEYINFO + static void sqlite3VdbeChangeP4(Vdbe p, int addr, KeyInfo pKeyInfo, int n) { + union_p4 _p4 = new union_p4(); + _p4.pKeyInfo = pKeyInfo; + sqlite3VdbeChangeP4(p, addr, _p4, n); + } + //CHAR + static void sqlite3VdbeChangeP4(Vdbe p, int addr, char c, int n) { + union_p4 _p4 = new union_p4(); + _p4.z = c.ToString(); + sqlite3VdbeChangeP4(p, addr, _p4, n); + } - //SUBPROGRAM - static void sqlite3VdbeChangeP4( Vdbe p, int addr, SubProgram pProgram, int n ) - { - union_p4 _p4 = new union_p4(); - _p4.pProgram = pProgram; - sqlite3VdbeChangeP4( p, addr, _p4, n ); - } + //MEM + static void sqlite3VdbeChangeP4(Vdbe p, int addr, Mem m, int n) { + union_p4 _p4 = new union_p4(); + _p4.pMem = m; + sqlite3VdbeChangeP4(p, addr, _p4, n); + } - static void sqlite3VdbeChangeP4( Vdbe p, int addr, string z, int n ) - { - union_p4 _p4 = new union_p4(); - if ( n > 0 && n <= z.Length ) - _p4.z = z.Substring( 0, n ); - else - _p4.z = z; - sqlite3VdbeChangeP4( p, addr, _p4, n ); - } + //STRING - static void sqlite3VdbeChangeP4( Vdbe p, int addr, union_p4 _p4, int n ) - { - Op pOp; - sqlite3 db; - Debug.Assert( p != null ); - db = p.db; - Debug.Assert( p.magic == VDBE_MAGIC_INIT ); - if ( p.aOp == null /*|| db.mallocFailed != 0 */) - { - if ( n != P4_KEYINFO && n != P4_VTAB ) - { - freeP4( db, n, _p4 ); + //STRING + Type + static void sqlite3VdbeChangeP4(Vdbe p, int addr, string z, dxDel P4_Type) { + union_p4 _p4 = new union_p4(); + _p4.z = z; + sqlite3VdbeChangeP4(p, addr, _p4, P4_DYNAMIC); } - return; - } - Debug.Assert( p.nOp > 0 ); - Debug.Assert( addr < p.nOp ); - if ( addr < 0 ) - { - addr = p.nOp - 1; - } - pOp = p.aOp[addr]; - freeP4( db, pOp.p4type, pOp.p4.p ); - pOp.p4.p = null; - if ( n == P4_INT32 ) - { - /* Note: this cast is safe, because the origin data point was an int - ** that was cast to a (string ). */ - pOp.p4.i = _p4.i; // SQLITE_PTR_TO_INT(zP4); - pOp.p4type = P4_INT32; - } - else if ( n == P4_INT64 ) - { - pOp.p4.pI64 = _p4.pI64; - pOp.p4type = n; - } - else if ( n == P4_REAL ) - { - pOp.p4.pReal = _p4.pReal; - pOp.p4type = n; - } - else if ( _p4 == null ) - { - pOp.p4.p = null; - pOp.p4type = P4_NOTUSED; - } - else if ( n == P4_KEYINFO ) - { - KeyInfo pKeyInfo; - int nByte; - - //int nField = _p4.pKeyInfo.nField; - //nByte = sizeof(*pKeyInfo) + (nField-1)*sizeof(pKeyInfo.aColl[0]) + nField; - pKeyInfo = new KeyInfo();//sqlite3DbMallocRaw(0, nByte); - pOp.p4.pKeyInfo = pKeyInfo; - if ( pKeyInfo != null ) - { - //u8 *aSortOrder; - // memcpy((char)pKeyInfo, zP4, nByte - nField); - //aSortOrder = pKeyInfo.aSortOrder; - //if( aSortOrder ){ - // pKeyInfo.aSortOrder = (unsigned char)&pKeyInfo.aColl[nField]; - // memcpy(pKeyInfo.aSortOrder, aSortOrder, nField); - //} - pKeyInfo = _p4.pKeyInfo.Copy(); - pOp.p4type = P4_KEYINFO; + + //SUBPROGRAM + static void sqlite3VdbeChangeP4(Vdbe p, int addr, SubProgram pProgram, int n) { + union_p4 _p4 = new union_p4(); + _p4.pProgram = pProgram; + sqlite3VdbeChangeP4(p, addr, _p4, n); } - else - { - //p.db.mallocFailed = 1; - pOp.p4type = P4_NOTUSED; + + static void sqlite3VdbeChangeP4(Vdbe p, int addr, string z, int n) { + union_p4 _p4 = new union_p4(); + if (n > 0 && n <= z.Length) + _p4.z = z.Substring(0, n); + else + _p4.z = z; + sqlite3VdbeChangeP4(p, addr, _p4, n); + } + + static void sqlite3VdbeChangeP4(Vdbe p, int addr, union_p4 _p4, int n) { + Op pOp; + sqlite3 db; + Debug.Assert(p != null); + db = p.db; + Debug.Assert(p.magic == VDBE_MAGIC_INIT); + if (p.aOp == null /*|| db.mallocFailed != 0 */) { + if (n != P4_KEYINFO && n != P4_VTAB) { + freeP4(db, n, _p4); + } + return; + } + Debug.Assert(p.nOp > 0); + Debug.Assert(addr < p.nOp); + if (addr < 0) { + addr = p.nOp - 1; + } + pOp = p.aOp[addr]; + freeP4(db, pOp.p4type, pOp.p4.p); + pOp.p4.p = null; + if (n == P4_INT32) { + /* Note: this cast is safe, because the origin data point was an int + ** that was cast to a (string ). */ + pOp.p4.i = _p4.i; // SQLITE_PTR_TO_INT(zP4); + pOp.p4type = P4_INT32; + } else if (n == P4_INT64) { + pOp.p4.pI64 = _p4.pI64; + pOp.p4type = n; + } else if (n == P4_REAL) { + pOp.p4.pReal = _p4.pReal; + pOp.p4type = n; + } else if (_p4 == null) { + pOp.p4.p = null; + pOp.p4type = P4_NOTUSED; + } else if (n == P4_KEYINFO) { + KeyInfo pKeyInfo; + int nByte; + + //int nField = _p4.pKeyInfo.nField; + //nByte = sizeof(*pKeyInfo) + (nField-1)*sizeof(pKeyInfo.aColl[0]) + nField; + pKeyInfo = new KeyInfo();//sqlite3DbMallocRaw(0, nByte); + pOp.p4.pKeyInfo = pKeyInfo; + if (pKeyInfo != null) { + //u8 *aSortOrder; + // memcpy((char)pKeyInfo, zP4, nByte - nField); + //aSortOrder = pKeyInfo.aSortOrder; + //if( aSortOrder ){ + // pKeyInfo.aSortOrder = (unsigned char)&pKeyInfo.aColl[nField]; + // memcpy(pKeyInfo.aSortOrder, aSortOrder, nField); + //} + pKeyInfo = _p4.pKeyInfo.Copy(); + pOp.p4type = P4_KEYINFO; + } else { + //p.db.mallocFailed = 1; + pOp.p4type = P4_NOTUSED; + } + pOp.p4.pKeyInfo = _p4.pKeyInfo; + pOp.p4type = P4_KEYINFO; + } else if (n == P4_KEYINFO_HANDOFF || n == P4_KEYINFO_STATIC) { + pOp.p4.pKeyInfo = _p4.pKeyInfo; + pOp.p4type = P4_KEYINFO; + } else if (n == P4_FUNCDEF) { + pOp.p4.pFunc = _p4.pFunc; + pOp.p4type = P4_FUNCDEF; + } else if (n == P4_COLLSEQ) { + pOp.p4.pColl = _p4.pColl; + pOp.p4type = P4_COLLSEQ; + } else if (n == P4_DYNAMIC || n == P4_STATIC || n == P4_MPRINTF) { + pOp.p4.z = _p4.z; + pOp.p4type = P4_DYNAMIC; + } else if (n == P4_MEM) { + pOp.p4.pMem = _p4.pMem; + pOp.p4type = P4_MEM; + } else if (n == P4_INTARRAY) { + pOp.p4.ai = _p4.ai; + pOp.p4type = P4_INTARRAY; + } else if (n == P4_SUBPROGRAM) { + pOp.p4.pProgram = _p4.pProgram; + pOp.p4type = P4_SUBPROGRAM; + } else if (n == P4_VTAB) { + pOp.p4.pVtab = _p4.pVtab; + pOp.p4type = P4_VTAB; + sqlite3VtabLock(_p4.pVtab); + Debug.Assert((_p4.pVtab).db == p.db); + } else if (n < 0) { + pOp.p4.p = _p4.p; + pOp.p4type = n; + } else { + //if (n == 0) n = n = sqlite3Strlen30(zP4); + pOp.p4.z = _p4.z;// sqlite3DbStrNDup(p.db, zP4, n); + pOp.p4type = P4_DYNAMIC; + } } - pOp.p4.pKeyInfo = _p4.pKeyInfo; - pOp.p4type = P4_KEYINFO; - } - else if ( n == P4_KEYINFO_HANDOFF || n == P4_KEYINFO_STATIC ) - { - pOp.p4.pKeyInfo = _p4.pKeyInfo; - pOp.p4type = P4_KEYINFO; - } - else if ( n == P4_FUNCDEF ) - { - pOp.p4.pFunc = _p4.pFunc; - pOp.p4type = P4_FUNCDEF; - } - else if ( n == P4_COLLSEQ ) - { - pOp.p4.pColl = _p4.pColl; - pOp.p4type = P4_COLLSEQ; - } - else if ( n == P4_DYNAMIC || n == P4_STATIC || n == P4_MPRINTF ) - { - pOp.p4.z = _p4.z; - pOp.p4type = P4_DYNAMIC; - } - else if ( n == P4_MEM ) - { - pOp.p4.pMem = _p4.pMem; - pOp.p4type = P4_MEM; - } - else if ( n == P4_INTARRAY ) - { - pOp.p4.ai = _p4.ai; - pOp.p4type = P4_INTARRAY; - } - else if ( n == P4_SUBPROGRAM ) - { - pOp.p4.pProgram = _p4.pProgram; - pOp.p4type = P4_SUBPROGRAM; - } - else if ( n == P4_VTAB ) - { - pOp.p4.pVtab = _p4.pVtab; - pOp.p4type = P4_VTAB; - sqlite3VtabLock( _p4.pVtab ); - Debug.Assert( ( _p4.pVtab ).db == p.db ); - } - else if ( n < 0 ) - { - pOp.p4.p = _p4.p; - pOp.p4type = n; - } - else - { - //if (n == 0) n = n = sqlite3Strlen30(zP4); - pOp.p4.z = _p4.z;// sqlite3DbStrNDup(p.db, zP4, n); - pOp.p4type = P4_DYNAMIC; - } - } #if !NDEBUG - /* -** Change the comment on the the most recently coded instruction. Or -** insert a No-op and add the comment to that new instruction. This -** makes the code easier to read during debugging. None of this happens -** in a production build. -*/ - static void sqlite3VdbeComment( Vdbe p, string zFormat, params object[] ap ) - { - if ( null == p ) - return; - // va_list ap; - lock ( lock_va_list ) - { - Debug.Assert( p.nOp > 0 || p.aOp == null ); - Debug.Assert( p.aOp == null || p.aOp[p.nOp - 1].zComment == null /* || p.db.mallocFailed != 0 */); - if ( p.nOp != 0 ) - { - string pz;// = p.aOp[p.nOp-1].zComment; - va_start( ap, zFormat ); - //sqlite3DbFree(db, ref pz); - pz = sqlite3VMPrintf( p.db, zFormat, ap ); - p.aOp[p.nOp - 1].zComment = pz; - va_end( ref ap ); + /* + ** Change the comment on the the most recently coded instruction. Or + ** insert a No-op and add the comment to that new instruction. This + ** makes the code easier to read during debugging. None of this happens + ** in a production build. + */ + static void sqlite3VdbeComment(Vdbe p, string zFormat, params object[] ap) { + if (null == p) + return; + // va_list ap; + lock (lock_va_list) { + Debug.Assert(p.nOp > 0 || p.aOp == null); + Debug.Assert(p.aOp == null || p.aOp[p.nOp - 1].zComment == null /* || p.db.mallocFailed != 0 */); + if (p.nOp != 0) { + string pz;// = p.aOp[p.nOp-1].zComment; + va_start(ap, zFormat); + //sqlite3DbFree(db, ref pz); + pz = sqlite3VMPrintf(p.db, zFormat, ap); + p.aOp[p.nOp - 1].zComment = pz; + va_end(ref ap); + } + } } - } - } - static void sqlite3VdbeNoopComment( Vdbe p, string zFormat, params object[] ap ) - { - if ( null == p ) - return; - //va_list ap; - lock ( lock_va_list ) - { - sqlite3VdbeAddOp0( p, OP_Noop ); - Debug.Assert( p.nOp > 0 || p.aOp == null ); - Debug.Assert( p.aOp == null || p.aOp[p.nOp - 1].zComment == null /* || p.db.mallocFailed != 0 */); - if ( p.nOp != 0 ) - { - string pz; // = p.aOp[p.nOp - 1].zComment; - va_start( ap, zFormat ); - //sqlite3DbFree(db,ref pz); - pz = sqlite3VMPrintf( p.db, zFormat, ap ); - p.aOp[p.nOp - 1].zComment = pz; - va_end( ref ap ); + static void sqlite3VdbeNoopComment(Vdbe p, string zFormat, params object[] ap) { + if (null == p) + return; + //va_list ap; + lock (lock_va_list) { + sqlite3VdbeAddOp0(p, OP_Noop); + Debug.Assert(p.nOp > 0 || p.aOp == null); + Debug.Assert(p.aOp == null || p.aOp[p.nOp - 1].zComment == null /* || p.db.mallocFailed != 0 */); + if (p.nOp != 0) { + string pz; // = p.aOp[p.nOp - 1].zComment; + va_start(ap, zFormat); + //sqlite3DbFree(db,ref pz); + pz = sqlite3VMPrintf(p.db, zFormat, ap); + p.aOp[p.nOp - 1].zComment = pz; + va_end(ref ap); + } + } } - } - } #else #endif //* NDEBUG */ - /* -** Return the opcode for a given address. If the address is -1, then -** return the most recently inserted opcode. -** -** If a memory allocation error has occurred prior to the calling of this -** routine, then a pointer to a dummy VdbeOp will be returned. That opcode -** is readable but not writable, though it is cast to a writable value. -** The return of a dummy opcode allows the call to continue functioning -** after a OOM fault without having to check to see if the return from -** this routine is a valid pointer. But because the dummy.opcode is 0, -** dummy will never be written to. This is verified by code inspection and -** by running with Valgrind. -** -** About the #if SQLITE_OMIT_TRACE: Normally, this routine is never called -** unless p->nOp>0. This is because in the absense of SQLITE_OMIT_TRACE, -** an OP_Trace instruction is always inserted by sqlite3VdbeGet() as soon as -** a new VDBE is created. So we are free to set addr to p->nOp-1 without -** having to double-check to make sure that the result is non-negative. But -** if SQLITE_OMIT_TRACE is defined, the OP_Trace is omitted and we do need to -** check the value of p->nOp-1 before continuing. -*/ - const VdbeOp dummy = null; /* Ignore the MSVC warning about no initializer */ - static VdbeOp sqlite3VdbeGetOp( Vdbe p, int addr ) - { - /* C89 specifies that the constant "dummy" will be initialized to all - ** zeros, which is correct. MSVC generates a warning, nevertheless. */ - Debug.Assert( p.magic == VDBE_MAGIC_INIT ); - if ( addr < 0 ) - { + /* + ** Return the opcode for a given address. If the address is -1, then + ** return the most recently inserted opcode. + ** + ** If a memory allocation error has occurred prior to the calling of this + ** routine, then a pointer to a dummy VdbeOp will be returned. That opcode + ** is readable but not writable, though it is cast to a writable value. + ** The return of a dummy opcode allows the call to continue functioning + ** after a OOM fault without having to check to see if the return from + ** this routine is a valid pointer. But because the dummy.opcode is 0, + ** dummy will never be written to. This is verified by code inspection and + ** by running with Valgrind. + ** + ** About the #if SQLITE_OMIT_TRACE: Normally, this routine is never called + ** unless p->nOp>0. This is because in the absense of SQLITE_OMIT_TRACE, + ** an OP_Trace instruction is always inserted by sqlite3VdbeGet() as soon as + ** a new VDBE is created. So we are free to set addr to p->nOp-1 without + ** having to double-check to make sure that the result is non-negative. But + ** if SQLITE_OMIT_TRACE is defined, the OP_Trace is omitted and we do need to + ** check the value of p->nOp-1 before continuing. + */ + const VdbeOp dummy = null; /* Ignore the MSVC warning about no initializer */ + static VdbeOp sqlite3VdbeGetOp(Vdbe p, int addr) { + /* C89 specifies that the constant "dummy" will be initialized to all + ** zeros, which is correct. MSVC generates a warning, nevertheless. */ + Debug.Assert(p.magic == VDBE_MAGIC_INIT); + if (addr < 0) { #if SQLITE_OMIT_TRACE if( p.nOp==0 ) return dummy; #endif - addr = p.nOp - 1; - } - Debug.Assert( ( addr >= 0 && addr < p.nOp ) /* || p.db.mallocFailed != 0 */); - //if ( p.db.mallocFailed != 0 ) - //{ - // return dummy; - //} - //else - { - return p.aOp[addr]; - } - } - -#if !SQLITE_OMIT_EXPLAIN || !NDEBUG || VDBE_PROFILE || SQLITE_DEBUG - /* -** Compute a string that describes the P4 parameter for an opcode. -** Use zTemp for any required temporary buffer space. -*/ - static StringBuilder zTemp = new StringBuilder( 100 ); - static string displayP4( Op pOp, string zBuffer, int nTemp ) - { - zTemp.Length = 0; - Debug.Assert( nTemp >= 20 ); - switch ( pOp.p4type ) - { - case P4_KEYINFO_STATIC: - case P4_KEYINFO: - { - int i, j; - KeyInfo pKeyInfo = pOp.p4.pKeyInfo; - sqlite3_snprintf( nTemp, zTemp, "keyinfo(%d", pKeyInfo.nField ); - i = sqlite3Strlen30( zTemp ); - for ( j = 0; j < pKeyInfo.nField; j++ ) - { - CollSeq pColl = pKeyInfo.aColl[j]; - if ( pColl != null ) - { - int n = sqlite3Strlen30( pColl.zName ); - if ( i + n > nTemp ) - { - zTemp.Append( ",..." ); // memcpy( &zTemp[i], ",...", 4 ); - break; - } - zTemp.Append( "," );// zTemp[i++] = ','; - if ( pKeyInfo.aSortOrder != null && pKeyInfo.aSortOrder[j] != 0 ) - { - zTemp.Append( "-" );// zTemp[i++] = '-'; - } - zTemp.Append( pColl.zName );// memcpy( &zTemp[i], pColl.zName, n + 1 ); - i += n; - } - else if ( i + 4 < nTemp ) - { - zTemp.Append( ",nil" );// memcpy( &zTemp[i], ",nil", 4 ); - i += 4; - } - } - zTemp.Append( ")" );// zTemp[i++] = ')'; - //zTemp[i] = 0; - Debug.Assert( i < nTemp ); - break; - } - case P4_COLLSEQ: - { - CollSeq pColl = pOp.p4.pColl; - sqlite3_snprintf( nTemp, zTemp, "collseq(%.20s)", ( pColl != null ? pColl.zName : "null" ) ); - break; - } - case P4_FUNCDEF: - { - FuncDef pDef = pOp.p4.pFunc; - sqlite3_snprintf( nTemp, zTemp, "%s(%d)", pDef.zName, pDef.nArg ); - break; - } - case P4_INT64: - { - sqlite3_snprintf( nTemp, zTemp, "%lld", pOp.p4.pI64 ); - break; - } - case P4_INT32: - { - sqlite3_snprintf( nTemp, zTemp, "%d", pOp.p4.i ); - break; - } - case P4_REAL: - { - sqlite3_snprintf( nTemp, zTemp, "%.16g", pOp.p4.pReal ); - break; - } - case P4_MEM: - { - Mem pMem = pOp.p4.pMem; - Debug.Assert( ( pMem.flags & MEM_Null ) == 0 ); - if ( ( pMem.flags & MEM_Str ) != 0 ) - { - zTemp.Append( pMem.z ); + addr = p.nOp - 1; } - else if ( ( pMem.flags & MEM_Int ) != 0 ) - { - sqlite3_snprintf( nTemp, zTemp, "%lld", pMem.u.i ); - } - else if ( ( pMem.flags & MEM_Real ) != 0 ) - { - sqlite3_snprintf( nTemp, zTemp, "%.16g", pMem.r ); - } - else + Debug.Assert((addr >= 0 && addr < p.nOp) /* || p.db.mallocFailed != 0 */); + //if ( p.db.mallocFailed != 0 ) + //{ + // return dummy; + //} + //else { - Debug.Assert( ( pMem.flags & MEM_Blob ) != 0 ); - zTemp = new StringBuilder( "(blob)" ); + return p.aOp[addr]; } - break; - } + } + +#if !SQLITE_OMIT_EXPLAIN || !NDEBUG || VDBE_PROFILE || SQLITE_DEBUG + /* + ** Compute a string that describes the P4 parameter for an opcode. + ** Use zTemp for any required temporary buffer space. + */ + static StringBuilder zTemp = new StringBuilder(100); + static string displayP4(Op pOp, string zBuffer, int nTemp) { + zTemp.Length = 0; + Debug.Assert(nTemp >= 20); + switch (pOp.p4type) { + case P4_KEYINFO_STATIC: + case P4_KEYINFO: { + int i, j; + KeyInfo pKeyInfo = pOp.p4.pKeyInfo; + sqlite3_snprintf(nTemp, zTemp, "keyinfo(%d", pKeyInfo.nField); + i = sqlite3Strlen30(zTemp); + for (j = 0; j < pKeyInfo.nField; j++) { + CollSeq pColl = pKeyInfo.aColl[j]; + if (pColl != null) { + int n = sqlite3Strlen30(pColl.zName); + if (i + n > nTemp) { + zTemp.Append(",..."); // memcpy( &zTemp[i], ",...", 4 ); + break; + } + zTemp.Append(",");// zTemp[i++] = ','; + if (pKeyInfo.aSortOrder != null && pKeyInfo.aSortOrder[j] != 0) { + zTemp.Append("-");// zTemp[i++] = '-'; + } + zTemp.Append(pColl.zName);// memcpy( &zTemp[i], pColl.zName, n + 1 ); + i += n; + } else if (i + 4 < nTemp) { + zTemp.Append(",nil");// memcpy( &zTemp[i], ",nil", 4 ); + i += 4; + } + } + zTemp.Append(")");// zTemp[i++] = ')'; + //zTemp[i] = 0; + Debug.Assert(i < nTemp); + break; + } + case P4_COLLSEQ: { + CollSeq pColl = pOp.p4.pColl; + sqlite3_snprintf(nTemp, zTemp, "collseq(%.20s)", (pColl != null ? pColl.zName : "null")); + break; + } + case P4_FUNCDEF: { + FuncDef pDef = pOp.p4.pFunc; + sqlite3_snprintf(nTemp, zTemp, "%s(%d)", pDef.zName, pDef.nArg); + break; + } + case P4_INT64: { + sqlite3_snprintf(nTemp, zTemp, "%lld", pOp.p4.pI64); + break; + } + case P4_INT32: { + sqlite3_snprintf(nTemp, zTemp, "%d", pOp.p4.i); + break; + } + case P4_REAL: { + sqlite3_snprintf(nTemp, zTemp, "%.16g", pOp.p4.pReal); + break; + } + case P4_MEM: { + Mem pMem = pOp.p4.pMem; + Debug.Assert((pMem.flags & MEM_Null) == 0); + if ((pMem.flags & MEM_Str) != 0) { + zTemp.Append(pMem.z); + } else if ((pMem.flags & MEM_Int) != 0) { + sqlite3_snprintf(nTemp, zTemp, "%lld", pMem.u.i); + } else if ((pMem.flags & MEM_Real) != 0) { + sqlite3_snprintf(nTemp, zTemp, "%.16g", pMem.r); + } else { + Debug.Assert((pMem.flags & MEM_Blob) != 0); + zTemp = new StringBuilder("(blob)"); + } + break; + } #if !SQLITE_OMIT_VIRTUALTABLE - case P4_VTAB: - { - sqlite3_vtab pVtab = pOp.p4.pVtab.pVtab; - sqlite3_snprintf( nTemp, zTemp, "vtab:%p:%p", pVtab, pVtab.pModule ); - break; - } + case P4_VTAB: { + sqlite3_vtab pVtab = pOp.p4.pVtab.pVtab; + sqlite3_snprintf(nTemp, zTemp, "vtab:%p:%p", pVtab, pVtab.pModule); + break; + } #endif - case P4_INTARRAY: - { - sqlite3_snprintf( nTemp, zTemp, "intarray" ); - break; - } - case P4_SUBPROGRAM: - { - sqlite3_snprintf( nTemp, zTemp, "program" ); - break; - } - default: - { - if ( pOp.p4.z != null ) - zTemp.Append( pOp.p4.z ); - //if ( zTemp == null ) - //{ - // zTemp = ""; - //} - break; - } - } - Debug.Assert( zTemp != null ); - return zTemp.ToString(); - } + case P4_INTARRAY: { + sqlite3_snprintf(nTemp, zTemp, "intarray"); + break; + } + case P4_SUBPROGRAM: { + sqlite3_snprintf(nTemp, zTemp, "program"); + break; + } + default: { + if (pOp.p4.z != null) + zTemp.Append(pOp.p4.z); + //if ( zTemp == null ) + //{ + // zTemp = ""; + //} + break; + } + } + Debug.Assert(zTemp != null); + return zTemp.ToString(); + } #endif - /* - ** Declare to the Vdbe that the BTree object at db->aDb[i] is used. - ** - ** The prepared statements need to know in advance the complete set of - ** attached databases that they will be using. A mask of these databases - ** is maintained in p->btreeMask and is used for locking and other purposes. - */ - static void sqlite3VdbeUsesBtree( Vdbe p, int i ) - { - Debug.Assert( i >= 0 && i < p.db.nDb && i < (int)sizeof( yDbMask ) * 8 ); - Debug.Assert( i < (int)sizeof( yDbMask ) * 8 ); - p.btreeMask |= ( (yDbMask)1 ) << i; - if ( i != 1 && sqlite3BtreeSharable( p.db.aDb[i].pBt ) ) - { - p.lockMask |= ( (yDbMask)1 ) << i; - } - } + /* + ** Declare to the Vdbe that the BTree object at db->aDb[i] is used. + ** + ** The prepared statements need to know in advance the complete set of + ** attached databases that they will be using. A mask of these databases + ** is maintained in p->btreeMask and is used for locking and other purposes. + */ + static void sqlite3VdbeUsesBtree(Vdbe p, int i) { + Debug.Assert(i >= 0 && i < p.db.nDb && i < (int)sizeof(yDbMask) * 8); + Debug.Assert(i < (int)sizeof(yDbMask) * 8); + p.btreeMask |= ((yDbMask)1) << i; + if (i != 1 && sqlite3BtreeSharable(p.db.aDb[i].pBt)) { + p.lockMask |= ((yDbMask)1) << i; + } + } #if !(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE//>0 /* @@ -1514,391 +1334,350 @@ void sqlite3VdbeLeave(Vdbe *p){ #if VDBE_PROFILE || SQLITE_DEBUG - /* -** Print a single opcode. This routine is used for debugging only. -*/ - static void sqlite3VdbePrintOp( FILE pOut, int pc, Op pOp ) - { - string zP4; - string zPtr = null; - string zFormat1 = "%4d %-13s %4d %4d %4d %-4s %.2X %s\n"; - if ( pOut == null ) - pOut = System.Console.Out; - zP4 = displayP4( pOp, zPtr, 50 ); - StringBuilder zOut = new StringBuilder( 10 ); - sqlite3_snprintf( 999, zOut, zFormat1, pc, - sqlite3OpcodeName( pOp.opcode ), pOp.p1, pOp.p2, pOp.p3, zP4, pOp.p5, -#if SQLITE_DEBUG - pOp.zComment != null ? pOp.zComment : "" + /* + ** Print a single opcode. This routine is used for debugging only. + */ + static void sqlite3VdbePrintOp(FILE pOut, int pc, Op pOp) { + string zP4; + string zPtr = null; + string zFormat1 = "%4d %-13s %4d %4d %4d %-4s %.2X %s\n"; + if (pOut == null) + pOut = System.Console.Out; + zP4 = displayP4(pOp, zPtr, 50); + StringBuilder zOut = new StringBuilder(10); + sqlite3_snprintf(999, zOut, zFormat1, pc, + sqlite3OpcodeName(pOp.opcode), pOp.p1, pOp.p2, pOp.p3, zP4, pOp.p5, +#if SQLITE_DEBUG + pOp.zComment != null ? pOp.zComment : "" #else "" #endif - ); - pOut.Write( zOut ); - //fflush(pOut); - } + ); + pOut.Write(zOut); + //fflush(pOut); + } #endif - /* -** Release an array of N Mem elements -*/ - static void releaseMemArray( Mem[] p, int N ) - { - releaseMemArray( p, 0, N ); - } - static void releaseMemArray( Mem[] p, int starting, int N ) - { - if ( p != null && p.Length > starting && p[starting] != null && N != 0 ) - { - Mem pEnd; - //sqlite3 db = p[starting].db; - //u8 malloc_failed = db.mallocFailed; - //if ( db != null ) //&& db.pnBytesFreed != 0 ) - //{ - // for ( int i = starting; i < N; i++ )//pEnd = p[N] ; p < pEnd ; p++ ) - // { - // sqlite3DbFree( db, ref p[i].zMalloc ); - // } - // return; - //} - for ( int i = starting; i < N; i++ )//pEnd = p[N] ; p < pEnd ; p++ ) - { - pEnd = p[i]; - Debug.Assert( //( p[1] ) == pEnd || - N == 1 || i == p.Length - 1 || p[starting].db == p[starting + 1].db ); - - /* This block is really an inlined version of sqlite3VdbeMemRelease() - ** that takes advantage of the fact that the memory cell value is - ** being set to NULL after releasing any dynamic resources. - ** - ** The justification for duplicating code is that according to - ** callgrind, this causes a certain test case to hit the CPU 4.7 - ** percent less (x86 linux, gcc version 4.1.2, -O6) than if - ** sqlite3MemRelease() were called from here. With -O2, this jumps - ** to 6.6 percent. The test case is inserting 1000 rows into a table - ** with no indexes using a single prepared INSERT statement, bind() - ** and reset(). Inserts are grouped into a transaction. - */ - if ( pEnd != null ) - { - if ( ( pEnd.flags & ( MEM_Agg | MEM_Dyn | MEM_Frame | MEM_RowSet ) ) != 0 ) - { - sqlite3VdbeMemRelease( pEnd ); + /* + ** Release an array of N Mem elements + */ + static void releaseMemArray(Mem[] p, int N) { + releaseMemArray(p, 0, N); + } + static void releaseMemArray(Mem[] p, int starting, int N) { + if (p != null && p.Length > starting && p[starting] != null && N != 0) { + Mem pEnd; + //sqlite3 db = p[starting].db; + //u8 malloc_failed = db.mallocFailed; + //if ( db != null ) //&& db.pnBytesFreed != 0 ) + //{ + // for ( int i = starting; i < N; i++ )//pEnd = p[N] ; p < pEnd ; p++ ) + // { + // sqlite3DbFree( db, ref p[i].zMalloc ); + // } + // return; + //} + for (int i = starting; i < N; i++)//pEnd = p[N] ; p < pEnd ; p++ ) + { + pEnd = p[i]; + Debug.Assert( //( p[1] ) == pEnd || + N == 1 || i == p.Length - 1 || p[starting].db == p[starting + 1].db); + + /* This block is really an inlined version of sqlite3VdbeMemRelease() + ** that takes advantage of the fact that the memory cell value is + ** being set to NULL after releasing any dynamic resources. + ** + ** The justification for duplicating code is that according to + ** callgrind, this causes a certain test case to hit the CPU 4.7 + ** percent less (x86 linux, gcc version 4.1.2, -O6) than if + ** sqlite3MemRelease() were called from here. With -O2, this jumps + ** to 6.6 percent. The test case is inserting 1000 rows into a table + ** with no indexes using a single prepared INSERT statement, bind() + ** and reset(). Inserts are grouped into a transaction. + */ + if (pEnd != null) { + if ((pEnd.flags & (MEM_Agg | MEM_Dyn | MEM_Frame | MEM_RowSet)) != 0) { + sqlite3VdbeMemRelease(pEnd); + } + //else if ( pEnd.zMalloc != null ) + //{ + // sqlite3DbFree( db, ref pEnd.zMalloc ); + // pEnd.zMalloc = 0; + //} + pEnd.z = null; + pEnd.n = 0; + pEnd.flags = MEM_Null; + sqlite3_free(ref pEnd._Mem); + sqlite3_free(ref pEnd.zBLOB); + } + } + // db.mallocFailed = malloc_failed; } - //else if ( pEnd.zMalloc != null ) - //{ - // sqlite3DbFree( db, ref pEnd.zMalloc ); - // pEnd.zMalloc = 0; - //} - pEnd.z = null; - pEnd.n = 0; - pEnd.flags = MEM_Null; - sqlite3_free( ref pEnd._Mem ); - sqlite3_free( ref pEnd.zBLOB ); - } } - // db.mallocFailed = malloc_failed; - } - } - /* - ** Delete a VdbeFrame object and its contents. VdbeFrame objects are - ** allocated by the OP_Program opcode in sqlite3VdbeExec(). - */ - static void sqlite3VdbeFrameDelete( VdbeFrame p ) - { - int i; - //Mem[] aMem = VdbeFrameMem(p); - VdbeCursor[] apCsr = p.aChildCsr;// (VdbeCursor)aMem[p.nChildMem]; - for ( i = 0; i < p.nChildCsr; i++ ) - { - sqlite3VdbeFreeCursor( p.v, apCsr[i] ); - } - releaseMemArray( p.aChildMem, p.nChildMem ); - p = null;// sqlite3DbFree( p.v.db, p ); - } + /* + ** Delete a VdbeFrame object and its contents. VdbeFrame objects are + ** allocated by the OP_Program opcode in sqlite3VdbeExec(). + */ + static void sqlite3VdbeFrameDelete(VdbeFrame p) { + int i; + //Mem[] aMem = VdbeFrameMem(p); + VdbeCursor[] apCsr = p.aChildCsr;// (VdbeCursor)aMem[p.nChildMem]; + for (i = 0; i < p.nChildCsr; i++) { + sqlite3VdbeFreeCursor(p.v, apCsr[i]); + } + releaseMemArray(p.aChildMem, p.nChildMem); + p = null;// sqlite3DbFree( p.v.db, p ); + } #if !SQLITE_OMIT_EXPLAIN - /* -** Give a listing of the program in the virtual machine. -** -** The interface is the same as sqlite3VdbeExec(). But instead of -** running the code, it invokes the callback once for each instruction. -** This feature is used to implement "EXPLAIN". -** -** When p.explain==1, each instruction is listed. When -** p.explain==2, only OP_Explain instructions are listed and these -** are shown in a different format. p.explain==2 is used to implement -** EXPLAIN QUERY PLAN. -** -** When p->explain==1, first the main program is listed, then each of -** the trigger subprograms are listed one by one. -*/ - static int sqlite3VdbeList( - Vdbe p /* The VDBE */ - ) - { - int nRow; /* Stop when row count reaches this */ - int nSub = 0; /* Number of sub-vdbes seen so far */ - SubProgram[] apSub = null; /* Array of sub-vdbes */ - Mem pSub = null; /* Memory cell hold array of subprogs */ - sqlite3 db = p.db; /* The database connection */ - int i; /* Loop counter */ - int rc = SQLITE_OK; /* Return code */ - if ( p.pResultSet == null ) - p.pResultSet = Array.Empty();//Mem* pMem = p.pResultSet = p.aMem[1]; /* First Mem of result set */ - Mem pMem; - Debug.Assert( p.explain != 0 ); - Debug.Assert( p.magic == VDBE_MAGIC_RUN ); - Debug.Assert( p.rc == SQLITE_OK || p.rc == SQLITE_BUSY || p.rc == SQLITE_NOMEM ); - /* Even though this opcode does not use dynamic strings for - ** the result, result columns may become dynamic if the user calls - ** sqlite3_column_text16(), causing a translation to UTF-16 encoding. - */ - releaseMemArray( p.pResultSet, 8 ); - - //if ( p.rc == SQLITE_NOMEM ) - //{ - // /* This happens if a malloc() inside a call to sqlite3_column_text() or - // ** sqlite3_column_text16() failed. */ - // db.mallocFailed = 1; - // return SQLITE_ERROR; - //} - - /* When the number of output rows reaches nRow, that means the - ** listing has finished and sqlite3_step() should return SQLITE_DONE. - ** nRow is the sum of the number of rows in the main program, plus - ** the sum of the number of rows in all trigger subprograms encountered - ** so far. The nRow value will increase as new trigger subprograms are - ** encountered, but p->pc will eventually catch up to nRow. - */ - nRow = p.nOp; - int i_pMem; - if ( p.explain == 1 ) - { - /* The first 8 memory cells are used for the result set. So we will - ** commandeer the 9th cell to use as storage for an array of pointers - ** to trigger subprograms. The VDBE is guaranteed to have at least 9 - ** cells. */ - Debug.Assert( p.nMem > 9 ); - pSub = p.aMem[9]; - if ( ( pSub.flags & MEM_Blob ) != 0 ) - { - /* On the first call to sqlite3_step(), pSub will hold a NULL. It is - ** initialized to a BLOB by the P4_SUBPROGRAM processing logic below */ - apSub = p.aMem[9]._SubProgram; // apSub = (SubProgram*)pSub->z; - nSub = apSub.Length;// pSub->n / sizeof( Vdbe* ); - } - for ( i = 0; i < nSub; i++ ) - { - nRow += apSub[i].nOp; - } - } + /* + ** Give a listing of the program in the virtual machine. + ** + ** The interface is the same as sqlite3VdbeExec(). But instead of + ** running the code, it invokes the callback once for each instruction. + ** This feature is used to implement "EXPLAIN". + ** + ** When p.explain==1, each instruction is listed. When + ** p.explain==2, only OP_Explain instructions are listed and these + ** are shown in a different format. p.explain==2 is used to implement + ** EXPLAIN QUERY PLAN. + ** + ** When p->explain==1, first the main program is listed, then each of + ** the trigger subprograms are listed one by one. + */ + static int sqlite3VdbeList( + Vdbe p /* The VDBE */ + ) { + int nRow; /* Stop when row count reaches this */ + int nSub = 0; /* Number of sub-vdbes seen so far */ + SubProgram[] apSub = null; /* Array of sub-vdbes */ + Mem pSub = null; /* Memory cell hold array of subprogs */ + sqlite3 db = p.db; /* The database connection */ + int i; /* Loop counter */ + int rc = SQLITE_OK; /* Return code */ + if (p.pResultSet == null) + p.pResultSet = Array.Empty();//Mem* pMem = p.pResultSet = p.aMem[1]; /* First Mem of result set */ + Mem pMem; + Debug.Assert(p.explain != 0); + Debug.Assert(p.magic == VDBE_MAGIC_RUN); + Debug.Assert(p.rc == SQLITE_OK || p.rc == SQLITE_BUSY || p.rc == SQLITE_NOMEM); + /* Even though this opcode does not use dynamic strings for + ** the result, result columns may become dynamic if the user calls + ** sqlite3_column_text16(), causing a translation to UTF-16 encoding. + */ + releaseMemArray(p.pResultSet, 8); + + //if ( p.rc == SQLITE_NOMEM ) + //{ + // /* This happens if a malloc() inside a call to sqlite3_column_text() or + // ** sqlite3_column_text16() failed. */ + // db.mallocFailed = 1; + // return SQLITE_ERROR; + //} - i_pMem = 0; - if ( i_pMem >= p.pResultSet.Length ) - Array.Resize( ref p.pResultSet, 8 + p.pResultSet.Length ); - { - p.pResultSet[i_pMem] = sqlite3Malloc( p.pResultSet[i_pMem] ); - } - pMem = p.pResultSet[i_pMem++]; - do - { - i = p.pc++; - } while ( i < nRow && p.explain == 2 && p.aOp[i].opcode != OP_Explain ); - if ( i >= nRow ) - { - p.rc = SQLITE_OK; - rc = SQLITE_DONE; - } - else if ( db.u1.isInterrupted ) - { - p.rc = SQLITE_INTERRUPT; - rc = SQLITE_ERROR; - sqlite3SetString( ref p.zErrMsg, db, sqlite3ErrStr( p.rc ) ); - } - else - { - string z; - Op pOp; - if ( i < p.nOp ) - { - /* The output line number is small enough that we are still in the - ** main program. */ - pOp = p.aOp[i]; - } - else - { - /* We are currently listing subprograms. Figure out which one and - ** pick up the appropriate opcode. */ - int j; - i -= p.nOp; - for ( j = 0; i >= apSub[j].nOp; j++ ) - { - i -= apSub[j].nOp; - } - pOp = apSub[j].aOp[i]; - } - if ( p.explain == 1 ) - { - pMem.flags = MEM_Int; - pMem.type = SQLITE_INTEGER; - pMem.u.i = i; /* Program counter */ - if ( p.pResultSet[i_pMem] == null ) - { - p.pResultSet[i_pMem] = sqlite3Malloc( p.pResultSet[i_pMem] ); - } - pMem = p.pResultSet[i_pMem++]; //pMem++; - - /* When an OP_Program opcode is encounter (the only opcode that has - ** a P4_SUBPROGRAM argument), expand the size of the array of subprograms - ** kept in p->aMem[9].z to hold the new program - assuming this subprogram - ** has not already been seen. - */ - pMem.flags = MEM_Static | MEM_Str | MEM_Term; - pMem.z = sqlite3OpcodeName( pOp.opcode ); /* Opcode */ - Debug.Assert( pMem.z != null ); - pMem.n = sqlite3Strlen30( pMem.z ); - pMem.type = SQLITE_TEXT; - pMem.enc = SQLITE_UTF8; - if ( p.pResultSet[i_pMem] == null ) - { - p.pResultSet[i_pMem] = sqlite3Malloc( p.pResultSet[i_pMem] ); - } - pMem = p.pResultSet[i_pMem++]; //pMem++; - if ( pOp.p4type == P4_SUBPROGRAM ) - { - //Debugger.Break(); // TODO - //int nByte = 0;//(nSub+1)*sizeof(SubProgram); - int j; - for ( j = 0; j < nSub; j++ ) - { - if ( apSub[j] == pOp.p4.pProgram ) - break; + /* When the number of output rows reaches nRow, that means the + ** listing has finished and sqlite3_step() should return SQLITE_DONE. + ** nRow is the sum of the number of rows in the main program, plus + ** the sum of the number of rows in all trigger subprograms encountered + ** so far. The nRow value will increase as new trigger subprograms are + ** encountered, but p->pc will eventually catch up to nRow. + */ + nRow = p.nOp; + int i_pMem; + if (p.explain == 1) { + /* The first 8 memory cells are used for the result set. So we will + ** commandeer the 9th cell to use as storage for an array of pointers + ** to trigger subprograms. The VDBE is guaranteed to have at least 9 + ** cells. */ + Debug.Assert(p.nMem > 9); + pSub = p.aMem[9]; + if ((pSub.flags & MEM_Blob) != 0) { + /* On the first call to sqlite3_step(), pSub will hold a NULL. It is + ** initialized to a BLOB by the P4_SUBPROGRAM processing logic below */ + apSub = p.aMem[9]._SubProgram; // apSub = (SubProgram*)pSub->z; + nSub = apSub.Length;// pSub->n / sizeof( Vdbe* ); + } + for (i = 0; i < nSub; i++) { + nRow += apSub[i].nOp; + } } - if ( j == nSub ) - {// && SQLITE_OK==sqlite3VdbeMemGrow(pSub, nByte, 1) ){ - Array.Resize( ref apSub, nSub + 1 ); - pSub._SubProgram = apSub;// (SubProgram)pSub.z; - apSub[nSub++] = pOp.p4.pProgram; - pSub.flags |= MEM_Blob; - pSub.n = 0;//nSub*sizeof(SubProgram); + + i_pMem = 0; + if (i_pMem >= p.pResultSet.Length) + Array.Resize(ref p.pResultSet, 8 + p.pResultSet.Length); + { + p.pResultSet[i_pMem] = sqlite3Malloc(p.pResultSet[i_pMem]); } - } - } + pMem = p.pResultSet[i_pMem++]; + do { + i = p.pc++; + } while (i < nRow && p.explain == 2 && p.aOp[i].opcode != OP_Explain); + if (i >= nRow) { + p.rc = SQLITE_OK; + rc = SQLITE_DONE; + } else if (db.u1.isInterrupted) { + p.rc = SQLITE_INTERRUPT; + rc = SQLITE_ERROR; + sqlite3SetString(ref p.zErrMsg, db, sqlite3ErrStr(p.rc)); + } else { + string z; + Op pOp; + if (i < p.nOp) { + /* The output line number is small enough that we are still in the + ** main program. */ + pOp = p.aOp[i]; + } else { + /* We are currently listing subprograms. Figure out which one and + ** pick up the appropriate opcode. */ + int j; + i -= p.nOp; + for (j = 0; i >= apSub[j].nOp; j++) { + i -= apSub[j].nOp; + } + pOp = apSub[j].aOp[i]; + } + if (p.explain == 1) { + pMem.flags = MEM_Int; + pMem.type = SQLITE_INTEGER; + pMem.u.i = i; /* Program counter */ + if (p.pResultSet[i_pMem] == null) { + p.pResultSet[i_pMem] = sqlite3Malloc(p.pResultSet[i_pMem]); + } + pMem = p.pResultSet[i_pMem++]; //pMem++; + + /* When an OP_Program opcode is encounter (the only opcode that has + ** a P4_SUBPROGRAM argument), expand the size of the array of subprograms + ** kept in p->aMem[9].z to hold the new program - assuming this subprogram + ** has not already been seen. + */ + pMem.flags = MEM_Static | MEM_Str | MEM_Term; + pMem.z = sqlite3OpcodeName(pOp.opcode); /* Opcode */ + Debug.Assert(pMem.z != null); + pMem.n = sqlite3Strlen30(pMem.z); + pMem.type = SQLITE_TEXT; + pMem.enc = SQLITE_UTF8; + if (p.pResultSet[i_pMem] == null) { + p.pResultSet[i_pMem] = sqlite3Malloc(p.pResultSet[i_pMem]); + } + pMem = p.pResultSet[i_pMem++]; //pMem++; + if (pOp.p4type == P4_SUBPROGRAM) { + //Debugger.Break(); // TODO + //int nByte = 0;//(nSub+1)*sizeof(SubProgram); + int j; + for (j = 0; j < nSub; j++) { + if (apSub[j] == pOp.p4.pProgram) + break; + } + if (j == nSub) {// && SQLITE_OK==sqlite3VdbeMemGrow(pSub, nByte, 1) ){ + Array.Resize(ref apSub, nSub + 1); + pSub._SubProgram = apSub;// (SubProgram)pSub.z; + apSub[nSub++] = pOp.p4.pProgram; + pSub.flags |= MEM_Blob; + pSub.n = 0;//nSub*sizeof(SubProgram); + } + } + } - pMem.flags = MEM_Int; - pMem.u.i = pOp.p1; /* P1 */ - pMem.type = SQLITE_INTEGER; - if ( p.pResultSet[i_pMem] == null ) - { - p.pResultSet[i_pMem] = sqlite3Malloc( p.pResultSet[i_pMem] ); - } - pMem = p.pResultSet[i_pMem++]; //pMem++; - - pMem.flags = MEM_Int; - pMem.u.i = pOp.p2; /* P2 */ - pMem.type = SQLITE_INTEGER; - if ( p.pResultSet[i_pMem] == null ) - { - p.pResultSet[i_pMem] = sqlite3Malloc( p.pResultSet[i_pMem] ); - } - pMem = p.pResultSet[i_pMem++]; //pMem++; - - pMem.flags = MEM_Int; - pMem.u.i = pOp.p3; /* P3 */ - pMem.type = SQLITE_INTEGER; - if ( p.pResultSet[i_pMem] == null ) - { - p.pResultSet[i_pMem] = sqlite3Malloc( p.pResultSet[i_pMem] ); - } - pMem = p.pResultSet[i_pMem++]; //pMem++; + pMem.flags = MEM_Int; + pMem.u.i = pOp.p1; /* P1 */ + pMem.type = SQLITE_INTEGER; + if (p.pResultSet[i_pMem] == null) { + p.pResultSet[i_pMem] = sqlite3Malloc(p.pResultSet[i_pMem]); + } + pMem = p.pResultSet[i_pMem++]; //pMem++; - //if ( sqlite3VdbeMemGrow( pMem, 32, 0 ) != 0 ) - //{ /* P4 */ - // Debug.Assert( p.db.mallocFailed != 0 ); - // return SQLITE_ERROR; - //} - pMem.flags = MEM_Dyn | MEM_Str | MEM_Term; - z = displayP4( pOp, pMem.z, 32 ); - if ( z != pMem.z ) - { - sqlite3VdbeMemSetStr( pMem, z, -1, SQLITE_UTF8, null ); - } - else - { - Debug.Assert( pMem.z != null ); - pMem.n = sqlite3Strlen30( pMem.z ); - pMem.enc = SQLITE_UTF8; - } - pMem.type = SQLITE_TEXT; - if ( p.pResultSet[i_pMem] == null ) - { - p.pResultSet[i_pMem] = sqlite3Malloc( p.pResultSet[i_pMem] ); - } - pMem = p.pResultSet[i_pMem++]; //pMem++; - - if ( p.explain == 1 ) - { - //if ( sqlite3VdbeMemGrow( pMem, 4, 0 ) != 0 ) - //{ - // Debug.Assert( p.db.mallocFailed != 0 ); - // return SQLITE_ERROR; - //} - pMem.flags = MEM_Dyn | MEM_Str | MEM_Term; - pMem.n = 2; - pMem.z = pOp.p5.ToString( "x2" ); //sqlite3_snprintf( 3, pMem.z, "%.2x", pOp.p5 ); /* P5 */ - pMem.type = SQLITE_TEXT; - pMem.enc = SQLITE_UTF8; - if ( p.pResultSet[i_pMem] == null ) - { - p.pResultSet[i_pMem] = sqlite3Malloc( p.pResultSet[i_pMem] ); - } - pMem = p.pResultSet[i_pMem++]; // pMem++; + pMem.flags = MEM_Int; + pMem.u.i = pOp.p2; /* P2 */ + pMem.type = SQLITE_INTEGER; + if (p.pResultSet[i_pMem] == null) { + p.pResultSet[i_pMem] = sqlite3Malloc(p.pResultSet[i_pMem]); + } + pMem = p.pResultSet[i_pMem++]; //pMem++; + + pMem.flags = MEM_Int; + pMem.u.i = pOp.p3; /* P3 */ + pMem.type = SQLITE_INTEGER; + if (p.pResultSet[i_pMem] == null) { + p.pResultSet[i_pMem] = sqlite3Malloc(p.pResultSet[i_pMem]); + } + pMem = p.pResultSet[i_pMem++]; //pMem++; + + //if ( sqlite3VdbeMemGrow( pMem, 32, 0 ) != 0 ) + //{ /* P4 */ + // Debug.Assert( p.db.mallocFailed != 0 ); + // return SQLITE_ERROR; + //} + pMem.flags = MEM_Dyn | MEM_Str | MEM_Term; + z = displayP4(pOp, pMem.z, 32); + if (z != pMem.z) { + sqlite3VdbeMemSetStr(pMem, z, -1, SQLITE_UTF8, null); + } else { + Debug.Assert(pMem.z != null); + pMem.n = sqlite3Strlen30(pMem.z); + pMem.enc = SQLITE_UTF8; + } + pMem.type = SQLITE_TEXT; + if (p.pResultSet[i_pMem] == null) { + p.pResultSet[i_pMem] = sqlite3Malloc(p.pResultSet[i_pMem]); + } + pMem = p.pResultSet[i_pMem++]; //pMem++; + + if (p.explain == 1) { + //if ( sqlite3VdbeMemGrow( pMem, 4, 0 ) != 0 ) + //{ + // Debug.Assert( p.db.mallocFailed != 0 ); + // return SQLITE_ERROR; + //} + pMem.flags = MEM_Dyn | MEM_Str | MEM_Term; + pMem.n = 2; + pMem.z = pOp.p5.ToString("x2"); //sqlite3_snprintf( 3, pMem.z, "%.2x", pOp.p5 ); /* P5 */ + pMem.type = SQLITE_TEXT; + pMem.enc = SQLITE_UTF8; + if (p.pResultSet[i_pMem] == null) { + p.pResultSet[i_pMem] = sqlite3Malloc(p.pResultSet[i_pMem]); + } + pMem = p.pResultSet[i_pMem++]; // pMem++; #if SQLITE_DEBUG - if ( pOp.zComment != null ) - { - pMem.flags = MEM_Str | MEM_Term; - pMem.z = pOp.zComment; - pMem.n = pMem.z == null ? 0 : sqlite3Strlen30( pMem.z ); - pMem.enc = SQLITE_UTF8; - pMem.type = SQLITE_TEXT; - } - else + if (pOp.zComment != null) { + pMem.flags = MEM_Str | MEM_Term; + pMem.z = pOp.zComment; + pMem.n = pMem.z == null ? 0 : sqlite3Strlen30(pMem.z); + pMem.enc = SQLITE_UTF8; + pMem.type = SQLITE_TEXT; + } else #endif - { - pMem.flags = MEM_Null; /* Comment */ - pMem.type = SQLITE_NULL; - } - } + { + pMem.flags = MEM_Null; /* Comment */ + pMem.type = SQLITE_NULL; + } + } - p.nResColumn = (u16)( 8 - 4 * ( p.explain - 1 ) ); - p.rc = SQLITE_OK; - rc = SQLITE_ROW; - } - return rc; - } + p.nResColumn = (u16)(8 - 4 * (p.explain - 1)); + p.rc = SQLITE_OK; + rc = SQLITE_ROW; + } + return rc; + } #endif // * SQLITE_OMIT_EXPLAIN */ -#if SQLITE_DEBUG - /* -** Print the SQL that was used to generate a VDBE program. -*/ - static void sqlite3VdbePrintSql( Vdbe p ) - { - int nOp = p.nOp; - VdbeOp pOp; - if ( nOp < 1 ) - return; - pOp = p.aOp[0]; - if ( pOp.opcode == OP_Trace && pOp.p4.z != null ) - { - string z = pOp.p4.z; - z = z.Trim();// while ( sqlite3Isspace( *(u8)z ) ) z++; - Console.Write( "SQL: [{0}]\n", z ); - } - } +#if SQLITE_DEBUG + /* + ** Print the SQL that was used to generate a VDBE program. + */ + static void sqlite3VdbePrintSql(Vdbe p) { + int nOp = p.nOp; + VdbeOp pOp; + if (nOp < 1) + return; + pOp = p.aOp[0]; + if (pOp.opcode == OP_Trace && pOp.p4.z != null) { + string z = pOp.p4.z; + z = z.Trim();// while ( sqlite3Isspace( *(u8)z ) ) z++; + Console.Write("SQL: [{0}]\n", z); + } + } #endif #if !SQLITE_OMIT_TRACE && SQLITE_ENABLE_IOTRACE @@ -1934,456 +1713,429 @@ static void sqlite3VdbeIOTraceSql( Vdbe p ) } #endif // * !SQLITE_OMIT_TRACE && SQLITE_ENABLE_IOTRACE */ - /* -** Allocate space from a fixed size buffer and return a pointer to -** that space. If insufficient space is available, return NULL. -** -** The pBuf parameter is the initial value of a pointer which will -** receive the new memory. pBuf is normally NULL. If pBuf is not -** NULL, it means that memory space has already been allocated and that -** this routine should not allocate any new memory. When pBuf is not -** NULL simply return pBuf. Only allocate new memory space when pBuf -** is NULL. -** -** nByte is the number of bytes of space needed. -** -** *ppFrom points to available space and pEnd points to the end of the -** available space. When space is allocated, *ppFrom is advanced past -** the end of the allocated space. -** -** *pnByte is a counter of the number of bytes of space that have failed -** to allocate. If there is insufficient space in *ppFrom to satisfy the -** request, then increment *pnByte by the amount of the request. -*/ - //static void* allocSpace( - // void* pBuf, /* Where return pointer will be stored */ - // int nByte, /* Number of bytes to allocate */ - // u8** ppFrom, /* IN/OUT: Allocate from *ppFrom */ - // u8* pEnd, /* Pointer to 1 byte past the end of *ppFrom buffer */ - // int* pnByte /* If allocation cannot be made, increment *pnByte */ - //) - //{ - // Debug.Assert(EIGHT_BYTE_ALIGNMENT(*ppFrom)); - // if (pBuf) return pBuf; - // nByte = ROUND8(nByte); - // if (&(*ppFrom)[nByte] <= pEnd) - // { - // pBuf = (void)*ppFrom; - // *ppFrom += nByte; - // } - // else - // { - // *pnByte += nByte; - // } - // return pBuf; - //} - - /* - ** Rewind the VDBE back to the beginning in preparation for - ** running it. - */ - static void sqlite3VdbeRewind(Vdbe p){ - #if (SQLITE_DEBUG) || (VDBE_PROFILE) - int i; - #endif - Debug.Assert( p!=null ); - Debug.Assert( p.magic==VDBE_MAGIC_INIT ); - - /* There should be at least one opcode. - */ - Debug.Assert( p.nOp>0 ); + /* + ** Allocate space from a fixed size buffer and return a pointer to + ** that space. If insufficient space is available, return NULL. + ** + ** The pBuf parameter is the initial value of a pointer which will + ** receive the new memory. pBuf is normally NULL. If pBuf is not + ** NULL, it means that memory space has already been allocated and that + ** this routine should not allocate any new memory. When pBuf is not + ** NULL simply return pBuf. Only allocate new memory space when pBuf + ** is NULL. + ** + ** nByte is the number of bytes of space needed. + ** + ** *ppFrom points to available space and pEnd points to the end of the + ** available space. When space is allocated, *ppFrom is advanced past + ** the end of the allocated space. + ** + ** *pnByte is a counter of the number of bytes of space that have failed + ** to allocate. If there is insufficient space in *ppFrom to satisfy the + ** request, then increment *pnByte by the amount of the request. + */ + //static void* allocSpace( + // void* pBuf, /* Where return pointer will be stored */ + // int nByte, /* Number of bytes to allocate */ + // u8** ppFrom, /* IN/OUT: Allocate from *ppFrom */ + // u8* pEnd, /* Pointer to 1 byte past the end of *ppFrom buffer */ + // int* pnByte /* If allocation cannot be made, increment *pnByte */ + //) + //{ + // Debug.Assert(EIGHT_BYTE_ALIGNMENT(*ppFrom)); + // if (pBuf) return pBuf; + // nByte = ROUND8(nByte); + // if (&(*ppFrom)[nByte] <= pEnd) + // { + // pBuf = (void)*ppFrom; + // *ppFrom += nByte; + // } + // else + // { + // *pnByte += nByte; + // } + // return pBuf; + //} - /* Set the magic to VDBE_MAGIC_RUN sooner rather than later. */ - p.magic = VDBE_MAGIC_RUN; + /* + ** Rewind the VDBE back to the beginning in preparation for + ** running it. + */ + static void sqlite3VdbeRewind(Vdbe p) { +#if (SQLITE_DEBUG) || (VDBE_PROFILE) + int i; +#endif + Debug.Assert(p != null); + Debug.Assert(p.magic == VDBE_MAGIC_INIT); - #if SQLITE_DEBUG - for(i=1; i 0); + + /* Set the magic to VDBE_MAGIC_RUN sooner rather than later. */ + p.magic = VDBE_MAGIC_RUN; + +#if SQLITE_DEBUG + for (i = 1; i < p.nMem; i++) { + Debug.Assert(p.aMem[i].db == p.db); + } +#endif + p.pc = -1; + p.rc = SQLITE_OK; + p.errorAction = OE_Abort; + p.magic = VDBE_MAGIC_RUN; + p.nChange = 0; + p.cacheCtr = 1; + p.minWriteFileFormat = 255; + p.iStatement = 0; + p.nFkConstraint = 0; +#if VDBE_PROFILE for(i=0; iaOp[p->nOp]; /* Memory avaliable for allocation */ - //zEnd = (u8)&p->aOp[p->nOpAlloc]; /* First byte past end of zCsr[] */ - resolveP2Values( p, ref nArg ); - p.usesStmtJournal = (pParse.isMultiWrite !=0 && pParse.mayAbort !=0 ); - if( pParse.explain !=0 && nMem<10 ){ - nMem = 10; +#endif } - //memset(zCsr, 0, zEnd-zCsr); - //zCsr += ( zCsr - (u8)0 ) & 7; - //Debug.Assert( EIGHT_BYTE_ALIGNMENT( zCsr ) ); - p.expired = false; - - // - // C# -- Replace allocation with individual Dims - // - /* Memory for registers, parameters, cursor, etc, is allocated in two - ** passes. On the first pass, we try to reuse unused space at the - ** end of the opcode array. If we are unable to satisfy all memory - ** requirements by reusing the opcode array tail, then the second - ** pass will fill in the rest using a fresh allocation. + /* + ** Prepare a virtual machine for execution for the first time after + ** creating the virtual machine. This involves things such + ** as allocating stack space and initializing the program counter. + ** After the VDBE has be prepped, it can be executed by one or more + ** calls to sqlite3VdbeExec(). + ** + ** This function may be called exact once on a each virtual machine. + ** After this routine is called the VM has been "packaged" and is ready + ** to run. After this routine is called, futher calls to + ** sqlite3VdbeAddOp() functions are prohibited. This routine disconnects + ** the Vdbe from the Parse object that helped generate it so that the + ** the Vdbe becomes an independent entity and the Parse object can be + ** destroyed. ** - ** This two-pass approach that reuses as much memory as possible from - ** the leftover space at the end of the opcode array can significantly - ** reduce the amount of memory held by a prepared statement. + ** Use the sqlite3VdbeRewind() procedure to restore a virtual machine back + ** to its initial state after it has been run. */ - //do - //{ - // nByte = 0; - // p->aMem = allocSpace( p->aMem, nMem * sizeof( Mem ), &zCsr, zEnd, &nByte ); - // p->aVar = allocSpace( p->aVar, nVar * sizeof( Mem ), &zCsr, zEnd, &nByte ); - // p->apArg = allocSpace( p->apArg, nArg * sizeof( Mem* ), &zCsr, zEnd, &nByte ); - // p->azVar = allocSpace( p->azVar, nVar * sizeof( char* ), &zCsr, zEnd, &nByte ); - // p->apCsr = allocSpace( p->apCsr, nCursor * sizeof( VdbeCursor* ), - // &zCsr, zEnd, &nByte ); - // if ( nByte ) - // { - // p->pFree = sqlite3DbMallocZero( db, nByte ); - // } - // zCsr = p->pFree; - // zEnd = zCsr[nByte]; - //} while ( nByte && !db->mallocFailed ); - - //p->nCursor = (u16)nCursor; - //if( p->aVar ){ - // p->nVar = (ynVar)nVar; - // for(n=0; naVar[n].flags = MEM_Null; - // p->aVar[n].db = db; - // } - //} - //if( p->azVar ){ - // p->nzVar = pParse->nzVar; - // memcpy(p->azVar, pParse->azVar, p->nzVar*sizeof(p->azVar[0])); - // memset(pParse->azVar, 0, pParse->nzVar*sizeof(pParse->azVar[0])); - //} - p.nzVar = (i16)pParse.nzVar; - p.azVar = new string[(int)p.nzVar == 0 ? 1 : (int)p.nzVar]; //p.azVar = (char*)p.apArg[nArg]; - for ( n = 0; n < p.nzVar; n++ ) - { - p.azVar[n] = pParse.azVar[n]; - } - // - - // C# -- Replace allocation with individual Dims - // aMem is 1 based, so allocate 1 extra cell under C# - p.aMem = new Mem[nMem + 1]; - for ( n = 0; n <= nMem; n++ ) - { - p.aMem[n] = sqlite3Malloc( p.aMem[n] ); - p.aMem[n].db = db; - } - //p.aMem--; /* aMem[] goes from 1..nMem */ - p.nMem = nMem; /* not from 0..nMem-1 */ - // - p.aVar = new Mem[nVar == 0 ? 1 : nVar]; - for ( n = 0; n < nVar; n++ ) - { - p.aVar[n] = sqlite3Malloc( p.aVar[n] ); - } - p.nVar = (ynVar)nVar; - // - p.apArg = new Mem[nArg == 0 ? 1 : nArg];//p.apArg = (Mem*)p.aVar[nVar]; - // - - p.apCsr = new VdbeCursor[nCursor == 0 ? 1 : nCursor];//p.apCsr = (VdbeCursor*)p.azVar[nVar]; - p.apCsr[0] = new VdbeCursor(); - p.nCursor = (u16)nCursor; - if ( p.aVar != null ) - { - p.nVar = (ynVar)nVar; - // - for ( n = 0; n < nVar; n++ ) - { - p.aVar[n].flags = MEM_Null; - p.aVar[n].db = db; - } - } - if ( p.aMem != null ) - { - //p.aMem--; /* aMem[] goes from 1..nMem */ - p.nMem = nMem; /* not from 0..nMem-1 */ - for ( n = 0; n <= nMem; n++ ) - { - p.aMem[n].flags = MEM_Null; - p.aMem[n].n = 0; - p.aMem[n].z = null; - p.aMem[n].zBLOB = null; - p.aMem[n].db = db; - } + static void sqlite3VdbeMakeReady( + Vdbe p, /* The VDBE */ + Parse pParse /* Parsing context */ + ) { + sqlite3 db; /* The database connection */ + int nVar; /* Number of parameters */ + int nMem; /* Number of VM memory registers */ + int nCursor; /* Number of cursors required */ + int nArg; /* Number of arguments in subprograms */ + int n; /* Loop counter */ + //u8 zCsr; /* Memory available for allocation */ + //u8 zEnd; /* First byte past allocated memory */ + int nByte; /* How much extra memory is needed */ + + Debug.Assert(p != null); + Debug.Assert(pParse != null); + Debug.Assert(p.magic == VDBE_MAGIC_INIT); + db = p.db; + //Debug.Assert( db.mallocFailed == 0 ); + nVar = pParse.nVar; + nMem = pParse.nMem; + nCursor = pParse.nTab; + nArg = pParse.nMaxArg; + + /* For each cursor required, also allocate a memory cell. Memory + ** cells (nMem+1-nCursor)..nMem, inclusive, will never be used by + ** the vdbe program. Instead they are used to allocate space for + ** VdbeCursor/BtCursor structures. The blob of memory associated with + ** cursor 0 is stored in memory cell nMem. Memory cell (nMem-1) + ** stores the blob of memory associated with cursor 1, etc. + ** + ** See also: allocateCursor(). + */ + nMem += nCursor; + + /* Allocate space for memory registers, SQL variables, VDBE cursors and + ** an array to marshal SQL function arguments in. + */ + //zCsr = (u8)&p->aOp[p->nOp]; /* Memory avaliable for allocation */ + //zEnd = (u8)&p->aOp[p->nOpAlloc]; /* First byte past end of zCsr[] */ + resolveP2Values(p, ref nArg); + p.usesStmtJournal = (pParse.isMultiWrite != 0 && pParse.mayAbort != 0); + if (pParse.explain != 0 && nMem < 10) { + nMem = 10; + } + + //memset(zCsr, 0, zEnd-zCsr); + //zCsr += ( zCsr - (u8)0 ) & 7; + //Debug.Assert( EIGHT_BYTE_ALIGNMENT( zCsr ) ); + p.expired = false; + + // + // C# -- Replace allocation with individual Dims + // + /* Memory for registers, parameters, cursor, etc, is allocated in two + ** passes. On the first pass, we try to reuse unused space at the + ** end of the opcode array. If we are unable to satisfy all memory + ** requirements by reusing the opcode array tail, then the second + ** pass will fill in the rest using a fresh allocation. + ** + ** This two-pass approach that reuses as much memory as possible from + ** the leftover space at the end of the opcode array can significantly + ** reduce the amount of memory held by a prepared statement. + */ + //do + //{ + // nByte = 0; + // p->aMem = allocSpace( p->aMem, nMem * sizeof( Mem ), &zCsr, zEnd, &nByte ); + // p->aVar = allocSpace( p->aVar, nVar * sizeof( Mem ), &zCsr, zEnd, &nByte ); + // p->apArg = allocSpace( p->apArg, nArg * sizeof( Mem* ), &zCsr, zEnd, &nByte ); + // p->azVar = allocSpace( p->azVar, nVar * sizeof( char* ), &zCsr, zEnd, &nByte ); + // p->apCsr = allocSpace( p->apCsr, nCursor * sizeof( VdbeCursor* ), + // &zCsr, zEnd, &nByte ); + // if ( nByte ) + // { + // p->pFree = sqlite3DbMallocZero( db, nByte ); + // } + // zCsr = p->pFree; + // zEnd = zCsr[nByte]; + //} while ( nByte && !db->mallocFailed ); + + //p->nCursor = (u16)nCursor; + //if( p->aVar ){ + // p->nVar = (ynVar)nVar; + // for(n=0; naVar[n].flags = MEM_Null; + // p->aVar[n].db = db; + // } + //} + //if( p->azVar ){ + // p->nzVar = pParse->nzVar; + // memcpy(p->azVar, pParse->azVar, p->nzVar*sizeof(p->azVar[0])); + // memset(pParse->azVar, 0, pParse->nzVar*sizeof(pParse->azVar[0])); + //} + p.nzVar = (i16)pParse.nzVar; + p.azVar = new string[(int)p.nzVar == 0 ? 1 : (int)p.nzVar]; //p.azVar = (char*)p.apArg[nArg]; + for (n = 0; n < p.nzVar; n++) { + p.azVar[n] = pParse.azVar[n]; + } + // + + // C# -- Replace allocation with individual Dims + // aMem is 1 based, so allocate 1 extra cell under C# + p.aMem = new Mem[nMem + 1]; + for (n = 0; n <= nMem; n++) { + p.aMem[n] = sqlite3Malloc(p.aMem[n]); + p.aMem[n].db = db; + } + //p.aMem--; /* aMem[] goes from 1..nMem */ + p.nMem = nMem; /* not from 0..nMem-1 */ + // + p.aVar = new Mem[nVar == 0 ? 1 : nVar]; + for (n = 0; n < nVar; n++) { + p.aVar[n] = sqlite3Malloc(p.aVar[n]); + } + p.nVar = (ynVar)nVar; + // + p.apArg = new Mem[nArg == 0 ? 1 : nArg];//p.apArg = (Mem*)p.aVar[nVar]; + // + + p.apCsr = new VdbeCursor[nCursor == 0 ? 1 : nCursor];//p.apCsr = (VdbeCursor*)p.azVar[nVar]; + p.apCsr[0] = new VdbeCursor(); + p.nCursor = (u16)nCursor; + if (p.aVar != null) { + p.nVar = (ynVar)nVar; + // + for (n = 0; n < nVar; n++) { + p.aVar[n].flags = MEM_Null; + p.aVar[n].db = db; + } + } + if (p.aMem != null) { + //p.aMem--; /* aMem[] goes from 1..nMem */ + p.nMem = nMem; /* not from 0..nMem-1 */ + for (n = 0; n <= nMem; n++) { + p.aMem[n].flags = MEM_Null; + p.aMem[n].n = 0; + p.aMem[n].z = null; + p.aMem[n].zBLOB = null; + p.aMem[n].db = db; + } + } + p.explain = pParse.explain; + sqlite3VdbeRewind(p); } - p.explain = pParse.explain; - sqlite3VdbeRewind( p ); - } - /* - ** Close a VDBE cursor and release all the resources that cursor - ** happens to hold. - */ - static void sqlite3VdbeFreeCursor( Vdbe p, VdbeCursor pCx ) - { - if ( pCx == null ) - { - return; - } + /* + ** Close a VDBE cursor and release all the resources that cursor + ** happens to hold. + */ + static void sqlite3VdbeFreeCursor(Vdbe p, VdbeCursor pCx) { + if (pCx == null) { + return; + } - if ( pCx.pBt != null ) - { - sqlite3BtreeClose( ref pCx.pBt ); - /* The pCx.pCursor will be close automatically, if it exists, by - ** the call above. */ - } - else if ( pCx.pCursor != null ) - { - sqlite3BtreeCloseCursor( pCx.pCursor ); - } + if (pCx.pBt != null) { + sqlite3BtreeClose(ref pCx.pBt); + /* The pCx.pCursor will be close automatically, if it exists, by + ** the call above. */ + } else if (pCx.pCursor != null) { + sqlite3BtreeCloseCursor(pCx.pCursor); + } #if !SQLITE_OMIT_VIRTUALTABLE - if ( pCx.pVtabCursor != null ) - { - sqlite3_vtab_cursor pVtabCursor = pCx.pVtabCursor; - sqlite3_module pModule = pCx.pModule; - p.inVtabMethod = 1; - pModule.xClose( ref pVtabCursor ); - p.inVtabMethod = 0; - } + if (pCx.pVtabCursor != null) { + sqlite3_vtab_cursor pVtabCursor = pCx.pVtabCursor; + sqlite3_module pModule = pCx.pModule; + p.inVtabMethod = 1; + pModule.xClose(ref pVtabCursor); + p.inVtabMethod = 0; + } #endif - } - /* - ** Copy the values stored in the VdbeFrame structure to its Vdbe. This - ** is used, for example, when a trigger sub-program is halted to restore - ** control to the main program. - */ - static int sqlite3VdbeFrameRestore( VdbeFrame pFrame ) - { - Vdbe v = pFrame.v; - v.aOp = pFrame.aOp; - v.nOp = pFrame.nOp; - v.aMem = pFrame.aMem; - v.nMem = pFrame.nMem; - v.apCsr = pFrame.apCsr; - v.nCursor = pFrame.nCursor; - v.db.lastRowid = pFrame.lastRowid; - v.nChange = pFrame.nChange; - return pFrame.pc; - } - - /* - ** Close all cursors. - ** - ** Also release any dynamic memory held by the VM in the Vdbe.aMem memory - ** cell array. This is necessary as the memory cell array may contain - ** pointers to VdbeFrame objects, which may in turn contain pointers to - ** open cursors. - */ - static void closeAllCursors( Vdbe p ) - { - if ( p.pFrame != null ) - { - VdbeFrame pFrame; - for ( pFrame = p.pFrame; pFrame.pParent != null; pFrame = pFrame.pParent ) - ; - sqlite3VdbeFrameRestore( pFrame ); - } - p.pFrame = null; - p.nFrame = 0; - - if ( p.apCsr != null ) - { - int i; - for ( i = 0; i < p.nCursor; i++ ) - { - VdbeCursor pC = p.apCsr[i]; - if ( pC != null ) - { - sqlite3VdbeFreeCursor( p, pC ); - p.apCsr[i] = null; - } } - } - if ( p.aMem != null ) - { - releaseMemArray( p.aMem, 1, p.nMem ); - } - while ( p.pDelFrame != null ) - { - VdbeFrame pDel = p.pDelFrame; - p.pDelFrame = pDel.pParent; - sqlite3VdbeFrameDelete( pDel ); - } + /* + ** Copy the values stored in the VdbeFrame structure to its Vdbe. This + ** is used, for example, when a trigger sub-program is halted to restore + ** control to the main program. + */ + static int sqlite3VdbeFrameRestore(VdbeFrame pFrame) { + Vdbe v = pFrame.v; + v.aOp = pFrame.aOp; + v.nOp = pFrame.nOp; + v.aMem = pFrame.aMem; + v.nMem = pFrame.nMem; + v.apCsr = pFrame.apCsr; + v.nCursor = pFrame.nCursor; + v.db.lastRowid = pFrame.lastRowid; + v.nChange = pFrame.nChange; + return pFrame.pc; + } + + /* + ** Close all cursors. + ** + ** Also release any dynamic memory held by the VM in the Vdbe.aMem memory + ** cell array. This is necessary as the memory cell array may contain + ** pointers to VdbeFrame objects, which may in turn contain pointers to + ** open cursors. + */ + static void closeAllCursors(Vdbe p) { + if (p.pFrame != null) { + VdbeFrame pFrame; + for (pFrame = p.pFrame; pFrame.pParent != null; pFrame = pFrame.pParent) + ; + sqlite3VdbeFrameRestore(pFrame); + } + p.pFrame = null; + p.nFrame = 0; + + if (p.apCsr != null) { + int i; + for (i = 0; i < p.nCursor; i++) { + VdbeCursor pC = p.apCsr[i]; + if (pC != null) { + sqlite3VdbeFreeCursor(p, pC); + p.apCsr[i] = null; + } + } + } + if (p.aMem != null) { + releaseMemArray(p.aMem, 1, p.nMem); + } + while (p.pDelFrame != null) { + VdbeFrame pDel = p.pDelFrame; + p.pDelFrame = pDel.pParent; + sqlite3VdbeFrameDelete(pDel); + } - } - /* - ** Clean up the VM after execution. - ** - ** This routine will automatically close any cursors, lists, and/or - ** sorters that were left open. It also deletes the values of - ** variables in the aVar[] array. - */ - static void Cleanup( Vdbe p ) - { - sqlite3 db = p.db; + } + /* + ** Clean up the VM after execution. + ** + ** This routine will automatically close any cursors, lists, and/or + ** sorters that were left open. It also deletes the values of + ** variables in the aVar[] array. + */ + static void Cleanup(Vdbe p) { + sqlite3 db = p.db; #if SQLITE_DEBUG - /* Execute Debug.Assert() statements to ensure that the Vdbe.apCsr[] and -** Vdbe.aMem[] arrays have already been cleaned up. */ - int i; - //TODO for(i=0; i 0 ) - { - p.aColName[n] = sqlite3Malloc( p.aColName[n] ); - pColName = p.aColName[n]; - pColName.flags = MEM_Null; - pColName.db = p.db; - } - } + sqlite3DbFree(db, ref p.zErrMsg); + p.pResultSet = null; + } - /* - ** Set the name of the idx'th column to be returned by the SQL statement. - ** zName must be a pointer to a nul terminated string. - ** - ** This call must be made after a call to sqlite3VdbeSetNumCols(). - ** - ** The final parameter, xDel, must be one of SQLITE_DYNAMIC, SQLITE_STATIC - ** or SQLITE_TRANSIENT. If it is SQLITE_DYNAMIC, then the buffer pointed - ** to by zName will be freed by sqlite3DbFree() when the vdbe is destroyed. - */ + /* + ** Set the number of result columns that will be returned by this SQL + ** statement. This is now set at compile time, rather than during + ** execution of the vdbe program so that sqlite3_column_count() can + ** be called on an SQL statement before sqlite3_step(). + */ + static void sqlite3VdbeSetNumCols(Vdbe p, int nResColumn) { + Mem pColName; + int n; + sqlite3 db = p.db; + + releaseMemArray(p.aColName, p.nResColumn * COLNAME_N); + sqlite3DbFree(db, ref p.aColName); + n = nResColumn * COLNAME_N; + p.nResColumn = (u16)nResColumn; + p.aColName = new Mem[n];// (Mem)sqlite3DbMallocZero(db, Mem.Length * n); + //if (p.aColName == 0) return; + while (n-- > 0) { + p.aColName[n] = sqlite3Malloc(p.aColName[n]); + pColName = p.aColName[n]; + pColName.flags = MEM_Null; + pColName.db = p.db; + } + } + /* + ** Set the name of the idx'th column to be returned by the SQL statement. + ** zName must be a pointer to a nul terminated string. + ** + ** This call must be made after a call to sqlite3VdbeSetNumCols(). + ** + ** The final parameter, xDel, must be one of SQLITE_DYNAMIC, SQLITE_STATIC + ** or SQLITE_TRANSIENT. If it is SQLITE_DYNAMIC, then the buffer pointed + ** to by zName will be freed by sqlite3DbFree() when the vdbe is destroyed. + */ - static int sqlite3VdbeSetColName( - Vdbe p, /* Vdbe being configured */ - int idx, /* Index of column zName applies to */ - int var, /* One of the COLNAME_* constants */ - string zName, /* Pointer to buffer containing name */ - dxDel xDel /* Memory management strategy for zName */ - ) - { - int rc; - Mem pColName; - Debug.Assert( idx < p.nResColumn ); - Debug.Assert( var < COLNAME_N ); - //if ( p.db.mallocFailed != 0 ) - //{ - // Debug.Assert( null == zName || xDel != SQLITE_DYNAMIC ); - // return SQLITE_NOMEM; - //} - Debug.Assert( p.aColName != null ); - pColName = p.aColName[idx + var * p.nResColumn]; - rc = sqlite3VdbeMemSetStr( pColName, zName, -1, SQLITE_UTF8, xDel ); - Debug.Assert( rc != 0 || null == zName || ( pColName.flags & MEM_Term ) != 0 ); - return rc; - } - /* - ** A read or write transaction may or may not be active on database handle - ** db. If a transaction is active, commit it. If there is a - ** write-transaction spanning more than one database file, this routine - ** takes care of the master journal trickery. - */ - static int vdbeCommit( sqlite3 db, Vdbe p ) - { - int i; - int nTrans = 0; /* Number of databases with an active write-transaction */ - int rc = SQLITE_OK; - bool needXcommit = false; + static int sqlite3VdbeSetColName( + Vdbe p, /* Vdbe being configured */ + int idx, /* Index of column zName applies to */ + int var, /* One of the COLNAME_* constants */ + string zName, /* Pointer to buffer containing name */ + dxDel xDel /* Memory management strategy for zName */ + ) { + int rc; + Mem pColName; + Debug.Assert(idx < p.nResColumn); + Debug.Assert(var < COLNAME_N); + //if ( p.db.mallocFailed != 0 ) + //{ + // Debug.Assert( null == zName || xDel != SQLITE_DYNAMIC ); + // return SQLITE_NOMEM; + //} + Debug.Assert(p.aColName != null); + pColName = p.aColName[idx + var * p.nResColumn]; + rc = sqlite3VdbeMemSetStr(pColName, zName, -1, SQLITE_UTF8, xDel); + Debug.Assert(rc != 0 || null == zName || (pColName.flags & MEM_Term) != 0); + return rc; + } + + /* + ** A read or write transaction may or may not be active on database handle + ** db. If a transaction is active, commit it. If there is a + ** write-transaction spanning more than one database file, this routine + ** takes care of the master journal trickery. + */ + static int vdbeCommit(sqlite3 db, Vdbe p) { + int i; + int nTrans = 0; /* Number of databases with an active write-transaction */ + int rc = SQLITE_OK; + bool needXcommit = false; #if SQLITE_OMIT_VIRTUALTABLE /* With this option, sqlite3VtabSync() is defined to be simply @@ -2391,733 +2143,642 @@ static int vdbeCommit( sqlite3 db, Vdbe p ) */ UNUSED_PARAMETER( p ); #endif - /* Before doing anything else, call the xSync() callback for any -** virtual module tables written in this transaction. This has to -** be done before determining whether a master journal file is -** required, as an xSync() callback may add an attached database -** to the transaction. -*/ - rc = sqlite3VtabSync( db, ref p.zErrMsg ); - - /* This loop determines (a) if the commit hook should be invoked and - ** (b) how many database files have open write transactions, not - ** including the temp database. (b) is important because if more than - ** one database file has an open write transaction, a master journal - ** file is required for an atomic commit. + /* Before doing anything else, call the xSync() callback for any + ** virtual module tables written in this transaction. This has to + ** be done before determining whether a master journal file is + ** required, as an xSync() callback may add an attached database + ** to the transaction. */ - for ( i = 0; rc == SQLITE_OK && i < db.nDb; i++ ) - { - Btree pBt = db.aDb[i].pBt; - if ( sqlite3BtreeIsInTrans( pBt ) ) - { - needXcommit = true; - if ( i != 1 ) - nTrans++; - rc = sqlite3PagerExclusiveLock( sqlite3BtreePager( pBt ) ); - } - } - if ( rc != SQLITE_OK ) - { - return rc; - } + rc = sqlite3VtabSync(db, ref p.zErrMsg); + + /* This loop determines (a) if the commit hook should be invoked and + ** (b) how many database files have open write transactions, not + ** including the temp database. (b) is important because if more than + ** one database file has an open write transaction, a master journal + ** file is required for an atomic commit. + */ + for (i = 0; rc == SQLITE_OK && i < db.nDb; i++) { + Btree pBt = db.aDb[i].pBt; + if (sqlite3BtreeIsInTrans(pBt)) { + needXcommit = true; + if (i != 1) + nTrans++; + rc = sqlite3PagerExclusiveLock(sqlite3BtreePager(pBt)); + } + } + if (rc != SQLITE_OK) { + return rc; + } - /* If there are any write-transactions at all, invoke the commit hook */ - if ( needXcommit && db.xCommitCallback != null ) - { - rc = db.xCommitCallback( db.pCommitArg ); - if ( rc != 0 ) - { - return SQLITE_CONSTRAINT; - } - } + /* If there are any write-transactions at all, invoke the commit hook */ + if (needXcommit && db.xCommitCallback != null) { + rc = db.xCommitCallback(db.pCommitArg); + if (rc != 0) { + return SQLITE_CONSTRAINT; + } + } - /* The simple case - no more than one database file (not counting the - ** TEMP database) has a transaction active. There is no need for the - ** master-journal. - ** - ** If the return value of sqlite3BtreeGetFilename() is a zero length - ** string, it means the main database is :memory: or a temp file. In - ** that case we do not support atomic multi-file commits, so use the - ** simple case then too. - */ - if ( 0 == sqlite3Strlen30( sqlite3BtreeGetFilename( db.aDb[0].pBt ) ) - || nTrans <= 1 ) - { - for ( i = 0; rc == SQLITE_OK && i < db.nDb; i++ ) - { - Btree pBt = db.aDb[i].pBt; - if ( pBt != null ) - { - rc = sqlite3BtreeCommitPhaseOne( pBt, null ); - } - } + /* The simple case - no more than one database file (not counting the + ** TEMP database) has a transaction active. There is no need for the + ** master-journal. + ** + ** If the return value of sqlite3BtreeGetFilename() is a zero length + ** string, it means the main database is :memory: or a temp file. In + ** that case we do not support atomic multi-file commits, so use the + ** simple case then too. + */ + if (0 == sqlite3Strlen30(sqlite3BtreeGetFilename(db.aDb[0].pBt)) + || nTrans <= 1) { + for (i = 0; rc == SQLITE_OK && i < db.nDb; i++) { + Btree pBt = db.aDb[i].pBt; + if (pBt != null) { + rc = sqlite3BtreeCommitPhaseOne(pBt, null); + } + } - /* Do the commit only if all databases successfully complete phase 1. - ** If one of the BtreeCommitPhaseOne() calls fails, this indicates an - ** IO error while deleting or truncating a journal file. It is unlikely, - ** but could happen. In this case abandon processing and return the error. - */ - for ( i = 0; rc == SQLITE_OK && i < db.nDb; i++ ) - { - Btree pBt = db.aDb[i].pBt; - if ( pBt != null ) - { - rc = sqlite3BtreeCommitPhaseTwo( pBt, 0 ); - } - } - if ( rc == SQLITE_OK ) - { - sqlite3VtabCommit( db ); - } - } + /* Do the commit only if all databases successfully complete phase 1. + ** If one of the BtreeCommitPhaseOne() calls fails, this indicates an + ** IO error while deleting or truncating a journal file. It is unlikely, + ** but could happen. In this case abandon processing and return the error. + */ + for (i = 0; rc == SQLITE_OK && i < db.nDb; i++) { + Btree pBt = db.aDb[i].pBt; + if (pBt != null) { + rc = sqlite3BtreeCommitPhaseTwo(pBt, 0); + } + } + if (rc == SQLITE_OK) { + sqlite3VtabCommit(db); + } + } - /* The complex case - There is a multi-file write-transaction active. - ** This requires a master journal file to ensure the transaction is - ** committed atomicly. - */ + /* The complex case - There is a multi-file write-transaction active. + ** This requires a master journal file to ensure the transaction is + ** committed atomicly. + */ #if !SQLITE_OMIT_DISKIO - else - { - sqlite3_vfs pVfs = db.pVfs; - bool needSync = false; - string zMaster = ""; /* File-name for the master journal */ - string zMainFile = sqlite3BtreeGetFilename( db.aDb[0].pBt ); - sqlite3_file pMaster = null; - i64 offset = 0; - int res = 0; - - /* Select a master journal file name */ - do - { - i64 iRandom = 0; - sqlite3DbFree( db, ref zMaster ); - sqlite3_randomness( sizeof( u32 ), ref iRandom );//random.Length - zMaster = sqlite3MPrintf( db, "%s-mj%08X", zMainFile, iRandom & 0x7fffffff ); - //if (!zMaster) - //{ - // return SQLITE_NOMEM; - //} - sqlite3FileSuffix3( zMainFile, zMaster ); - rc = sqlite3OsAccess( pVfs, zMaster, SQLITE_ACCESS_EXISTS, ref res ); - } while ( rc == SQLITE_OK && res == 1 ); - if ( rc == SQLITE_OK ) - { - /* Open the master journal. */ - rc = sqlite3OsOpenMalloc( ref pVfs, zMaster, ref pMaster, - SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | - SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_MASTER_JOURNAL, ref rc - ); - } - if ( rc != SQLITE_OK ) - { - sqlite3DbFree( db, ref zMaster ); - return rc; - } + else { + sqlite3_vfs pVfs = db.pVfs; + bool needSync = false; + string zMaster = ""; /* File-name for the master journal */ + string zMainFile = sqlite3BtreeGetFilename(db.aDb[0].pBt); + sqlite3_file pMaster = null; + i64 offset = 0; + int res = 0; + + /* Select a master journal file name */ + do { + i64 iRandom = 0; + sqlite3DbFree(db, ref zMaster); + sqlite3_randomness(sizeof(u32), ref iRandom);//random.Length + zMaster = sqlite3MPrintf(db, "%s-mj%08X", zMainFile, iRandom & 0x7fffffff); + //if (!zMaster) + //{ + // return SQLITE_NOMEM; + //} + sqlite3FileSuffix3(zMainFile, zMaster); + rc = sqlite3OsAccess(pVfs, zMaster, SQLITE_ACCESS_EXISTS, ref res); + } while (rc == SQLITE_OK && res == 1); + if (rc == SQLITE_OK) { + /* Open the master journal. */ + rc = sqlite3OsOpenMalloc(ref pVfs, zMaster, ref pMaster, + SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | + SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_MASTER_JOURNAL, ref rc + ); + } + if (rc != SQLITE_OK) { + sqlite3DbFree(db, ref zMaster); + return rc; + } - /* Write the name of each database file in the transaction into the new - ** master journal file. If an error occurs at this point close - ** and delete the master journal file. All the individual journal files - ** still have 'null' as the master journal pointer, so they will roll - ** back independently if a failure occurs. - */ - for ( i = 0; i < db.nDb; i++ ) - { - Btree pBt = db.aDb[i].pBt; - if ( sqlite3BtreeIsInTrans( pBt ) ) - { - string zFile = sqlite3BtreeGetJournalname( pBt ); - if ( zFile == null ) - { - continue; /* Ignore TEMP and :memory: databases */ - } - Debug.Assert( zFile != "" ); - if ( !needSync && 0 == sqlite3BtreeSyncDisabled( pBt ) ) - { - needSync = true; - } - rc = sqlite3OsWrite( pMaster, Encoding.UTF8.GetBytes( zFile ), sqlite3Strlen30( zFile ), offset ); - offset += sqlite3Strlen30( zFile ); - if ( rc != SQLITE_OK ) - { - sqlite3OsCloseFree( pMaster ); - sqlite3OsDelete( pVfs, zMaster, 0 ); - sqlite3DbFree( db, ref zMaster ); - return rc; - } - } - } + /* Write the name of each database file in the transaction into the new + ** master journal file. If an error occurs at this point close + ** and delete the master journal file. All the individual journal files + ** still have 'null' as the master journal pointer, so they will roll + ** back independently if a failure occurs. + */ + for (i = 0; i < db.nDb; i++) { + Btree pBt = db.aDb[i].pBt; + if (sqlite3BtreeIsInTrans(pBt)) { + string zFile = sqlite3BtreeGetJournalname(pBt); + if (zFile == null) { + continue; /* Ignore TEMP and :memory: databases */ + } + Debug.Assert(zFile != ""); + if (!needSync && 0 == sqlite3BtreeSyncDisabled(pBt)) { + needSync = true; + } + rc = sqlite3OsWrite(pMaster, Encoding.UTF8.GetBytes(zFile), sqlite3Strlen30(zFile), offset); + offset += sqlite3Strlen30(zFile); + if (rc != SQLITE_OK) { + sqlite3OsCloseFree(pMaster); + sqlite3OsDelete(pVfs, zMaster, 0); + sqlite3DbFree(db, ref zMaster); + return rc; + } + } + } - /* Sync the master journal file. If the IOCAP_SEQUENTIAL device - ** flag is set this is not required. - */ - if ( needSync - && 0 == ( sqlite3OsDeviceCharacteristics( pMaster ) & SQLITE_IOCAP_SEQUENTIAL ) - && SQLITE_OK != ( rc = sqlite3OsSync( pMaster, SQLITE_SYNC_NORMAL ) ) - ) - { - sqlite3OsCloseFree( pMaster ); - sqlite3OsDelete( pVfs, zMaster, 0 ); - sqlite3DbFree( db, ref zMaster ); - return rc; - } + /* Sync the master journal file. If the IOCAP_SEQUENTIAL device + ** flag is set this is not required. + */ + if (needSync + && 0 == (sqlite3OsDeviceCharacteristics(pMaster) & SQLITE_IOCAP_SEQUENTIAL) + && SQLITE_OK != (rc = sqlite3OsSync(pMaster, SQLITE_SYNC_NORMAL)) + ) { + sqlite3OsCloseFree(pMaster); + sqlite3OsDelete(pVfs, zMaster, 0); + sqlite3DbFree(db, ref zMaster); + return rc; + } - /* Sync all the db files involved in the transaction. The same call - ** sets the master journal pointer in each individual journal. If - ** an error occurs here, do not delete the master journal file. - ** - ** If the error occurs during the first call to - ** sqlite3BtreeCommitPhaseOne(), then there is a chance that the - ** master journal file will be orphaned. But we cannot delete it, - ** in case the master journal file name was written into the journal - ** file before the failure occurred. - */ - for ( i = 0; rc == SQLITE_OK && i < db.nDb; i++ ) - { - Btree pBt = db.aDb[i].pBt; - if ( pBt != null ) - { - rc = sqlite3BtreeCommitPhaseOne( pBt, zMaster ); - } - } - sqlite3OsCloseFree( pMaster ); - Debug.Assert( rc != SQLITE_BUSY ); - if ( rc != SQLITE_OK ) - { - sqlite3DbFree( db, ref zMaster ); - return rc; - } + /* Sync all the db files involved in the transaction. The same call + ** sets the master journal pointer in each individual journal. If + ** an error occurs here, do not delete the master journal file. + ** + ** If the error occurs during the first call to + ** sqlite3BtreeCommitPhaseOne(), then there is a chance that the + ** master journal file will be orphaned. But we cannot delete it, + ** in case the master journal file name was written into the journal + ** file before the failure occurred. + */ + for (i = 0; rc == SQLITE_OK && i < db.nDb; i++) { + Btree pBt = db.aDb[i].pBt; + if (pBt != null) { + rc = sqlite3BtreeCommitPhaseOne(pBt, zMaster); + } + } + sqlite3OsCloseFree(pMaster); + Debug.Assert(rc != SQLITE_BUSY); + if (rc != SQLITE_OK) { + sqlite3DbFree(db, ref zMaster); + return rc; + } - /* Delete the master journal file. This commits the transaction. After - ** doing this the directory is synced again before any individual - ** transaction files are deleted. - */ - rc = sqlite3OsDelete( pVfs, zMaster, 1 ); - sqlite3DbFree( db, ref zMaster ); - if ( rc != 0 ) - { - return rc; - } + /* Delete the master journal file. This commits the transaction. After + ** doing this the directory is synced again before any individual + ** transaction files are deleted. + */ + rc = sqlite3OsDelete(pVfs, zMaster, 1); + sqlite3DbFree(db, ref zMaster); + if (rc != 0) { + return rc; + } - /* All files and directories have already been synced, so the following - ** calls to sqlite3BtreeCommitPhaseTwo() are only closing files and - ** deleting or truncating journals. If something goes wrong while - ** this is happening we don't really care. The integrity of the - ** transaction is already guaranteed, but some stray 'cold' journals - ** may be lying around. Returning an error code won't help matters. - */ + /* All files and directories have already been synced, so the following + ** calls to sqlite3BtreeCommitPhaseTwo() are only closing files and + ** deleting or truncating journals. If something goes wrong while + ** this is happening we don't really care. The integrity of the + ** transaction is already guaranteed, but some stray 'cold' journals + ** may be lying around. Returning an error code won't help matters. + */ #if SQLITE_TEST disable_simulated_io_errors(); #endif - sqlite3BeginBenignMalloc(); - for ( i = 0; i < db.nDb; i++ ) - { - Btree pBt = db.aDb[i].pBt; - if ( pBt != null ) - { - sqlite3BtreeCommitPhaseTwo( pBt, 0 ); - } - } - sqlite3EndBenignMalloc(); + sqlite3BeginBenignMalloc(); + for (i = 0; i < db.nDb; i++) { + Btree pBt = db.aDb[i].pBt; + if (pBt != null) { + sqlite3BtreeCommitPhaseTwo(pBt, 0); + } + } + sqlite3EndBenignMalloc(); #if SQLITE_TEST enable_simulated_io_errors(); #endif - sqlite3VtabCommit( db ); - } + sqlite3VtabCommit(db); + } #endif - return rc; - } + return rc; + } - /* - ** This routine checks that the sqlite3.activeVdbeCnt count variable - ** matches the number of vdbe's in the list sqlite3.pVdbe that are - ** currently active. An Debug.Assertion fails if the two counts do not match. - ** This is an internal self-check only - it is not an essential processing - ** step. - ** - ** This is a no-op if NDEBUG is defined. - */ + /* + ** This routine checks that the sqlite3.activeVdbeCnt count variable + ** matches the number of vdbe's in the list sqlite3.pVdbe that are + ** currently active. An Debug.Assertion fails if the two counts do not match. + ** This is an internal self-check only - it is not an essential processing + ** step. + ** + ** This is a no-op if NDEBUG is defined. + */ #if !NDEBUG - static void checkActiveVdbeCnt( sqlite3 db ) - { - Vdbe p; - int cnt = 0; - int nWrite = 0; - p = db.pVdbe; - while ( p != null ) - { - if ( p.magic == VDBE_MAGIC_RUN && p.pc >= 0 ) - { - cnt++; - if ( p.readOnly == false ) - nWrite++; + static void checkActiveVdbeCnt(sqlite3 db) { + Vdbe p; + int cnt = 0; + int nWrite = 0; + p = db.pVdbe; + while (p != null) { + if (p.magic == VDBE_MAGIC_RUN && p.pc >= 0) { + cnt++; + if (p.readOnly == false) + nWrite++; + } + p = p.pNext; + } + Debug.Assert(cnt == db.activeVdbeCnt); + Debug.Assert(nWrite == db.writeVdbeCnt); } - p = p.pNext; - } - Debug.Assert( cnt == db.activeVdbeCnt ); - Debug.Assert( nWrite == db.writeVdbeCnt ); - } #else //#define checkActiveVdbeCnt(x) static void checkActiveVdbeCnt( sqlite3 db ){} #endif - /* -** For every Btree that in database connection db which -** has been modified, "trip" or invalidate each cursor in -** that Btree might have been modified so that the cursor -** can never be used again. This happens when a rollback -*** occurs. We have to trip all the other cursors, even -** cursor from other VMs in different database connections, -** so that none of them try to use the data at which they -** were pointing and which now may have been changed due -** to the rollback. -** -** Remember that a rollback can delete tables complete and -** reorder rootpages. So it is not sufficient just to save -** the state of the cursor. We have to invalidate the cursor -** so that it is never used again. -*/ - static void invalidateCursorsOnModifiedBtrees( sqlite3 db ) - { - int i; - for ( i = 0; i < db.nDb; i++ ) - { - Btree p = db.aDb[i].pBt; - if ( p != null && sqlite3BtreeIsInTrans( p ) ) - { - sqlite3BtreeTripAllCursors( p, SQLITE_ABORT ); - } - } - } - - /* - ** If the Vdbe passed as the first argument opened a statement-transaction, - ** close it now. Argument eOp must be either SAVEPOINT_ROLLBACK or - ** SAVEPOINT_RELEASE. If it is SAVEPOINT_ROLLBACK, then the statement - ** transaction is rolled back. If eOp is SAVEPOINT_RELEASE, then the - ** statement transaction is commtted. + /* + ** For every Btree that in database connection db which + ** has been modified, "trip" or invalidate each cursor in + ** that Btree might have been modified so that the cursor + ** can never be used again. This happens when a rollback + *** occurs. We have to trip all the other cursors, even + ** cursor from other VMs in different database connections, + ** so that none of them try to use the data at which they + ** were pointing and which now may have been changed due + ** to the rollback. ** - ** If an IO error occurs, an SQLITE_IOERR_XXX error code is returned. - ** Otherwise SQLITE_OK. - */ - static int sqlite3VdbeCloseStatement( Vdbe p, int eOp ) - { - sqlite3 db = p.db; - int rc = SQLITE_OK; - /* If p->iStatement is greater than zero, then this Vdbe opened a - ** statement transaction that should be closed here. The only exception - ** is that an IO error may have occured, causing an emergency rollback. - ** In this case (db->nStatement==0), and there is nothing to do. - */ - if ( db.nStatement != 0 && p.iStatement != 0 ) - { - int i; - int iSavepoint = p.iStatement - 1; - - Debug.Assert( eOp == SAVEPOINT_ROLLBACK || eOp == SAVEPOINT_RELEASE ); - Debug.Assert( db.nStatement > 0 ); - Debug.Assert( p.iStatement == ( db.nStatement + db.nSavepoint ) ); - - for ( i = 0; i < db.nDb; i++ ) - { - int rc2 = SQLITE_OK; - Btree pBt = db.aDb[i].pBt; - if ( pBt != null ) - { - if ( eOp == SAVEPOINT_ROLLBACK ) - { - rc2 = sqlite3BtreeSavepoint( pBt, SAVEPOINT_ROLLBACK, iSavepoint ); - } - if ( rc2 == SQLITE_OK ) - { - rc2 = sqlite3BtreeSavepoint( pBt, SAVEPOINT_RELEASE, iSavepoint ); - } - if ( rc == SQLITE_OK ) - { - rc = rc2; + ** Remember that a rollback can delete tables complete and + ** reorder rootpages. So it is not sufficient just to save + ** the state of the cursor. We have to invalidate the cursor + ** so that it is never used again. + */ + static void invalidateCursorsOnModifiedBtrees(sqlite3 db) { + int i; + for (i = 0; i < db.nDb; i++) { + Btree p = db.aDb[i].pBt; + if (p != null && sqlite3BtreeIsInTrans(p)) { + sqlite3BtreeTripAllCursors(p, SQLITE_ABORT); + } } - } } - db.nStatement--; - p.iStatement = 0; - - if ( rc == SQLITE_OK ) - { - if ( eOp == SAVEPOINT_ROLLBACK ) - { - rc = sqlite3VtabSavepoint( db, SAVEPOINT_ROLLBACK, iSavepoint ); - } - if ( rc == SQLITE_OK ) - { - rc = sqlite3VtabSavepoint( db, SAVEPOINT_RELEASE, iSavepoint ); - } - } - - /* If the statement transaction is being rolled back, also restore the - ** database handles deferred constraint counter to the value it had when - ** the statement transaction was opened. */ - if ( eOp == SAVEPOINT_ROLLBACK ) - { - db.nDeferredCons = p.nStmtDefCons; - } - } - return rc; - } - /* - ** This function is called when a transaction opened by the database - ** handle associated with the VM passed as an argument is about to be - ** committed. If there are outstanding deferred foreign key constraint - ** violations, return SQLITE_ERROR. Otherwise, SQLITE_OK. - ** - ** If there are outstanding FK violations and this function returns - ** SQLITE_ERROR, set the result of the VM to SQLITE_CONSTRAINT and write - ** an error message to it. Then return SQLITE_ERROR. - */ -#if !SQLITE_OMIT_FOREIGN_KEY - static int sqlite3VdbeCheckFk( Vdbe p, int deferred ) - { - sqlite3 db = p.db; - if ( ( deferred != 0 && db.nDeferredCons > 0 ) || ( 0 == deferred && p.nFkConstraint > 0 ) ) - { - p.rc = SQLITE_CONSTRAINT; - p.errorAction = OE_Abort; - sqlite3SetString( ref p.zErrMsg, db, "foreign key constraint failed" ); - return SQLITE_ERROR; - } - return SQLITE_OK; - } -#endif - - /* -** This routine is called the when a VDBE tries to halt. If the VDBE -** has made changes and is in autocommit mode, then commit those -** changes. If a rollback is needed, then do the rollback. -** -** This routine is the only way to move the state of a VM from -** SQLITE_MAGIC_RUN to SQLITE_MAGIC_HALT. It is harmless to -** call this on a VM that is in the SQLITE_MAGIC_HALT state. -** -** Return an error code. If the commit could not complete because of -** lock contention, return SQLITE_BUSY. If SQLITE_BUSY is returned, it -** means the close did not happen and needs to be repeated. -*/ - static int sqlite3VdbeHalt( Vdbe p ) - { - int rc; /* Used to store transient return codes */ - sqlite3 db = p.db; - - /* This function contains the logic that determines if a statement or - ** transaction will be committed or rolled back as a result of the - ** execution of this virtual machine. - ** - ** If any of the following errors occur: - ** - ** SQLITE_NOMEM - ** SQLITE_IOERR - ** SQLITE_FULL - ** SQLITE_INTERRUPT - ** - ** Then the internal cache might have been left in an inconsistent - ** state. We need to rollback the statement transaction, if there is - ** one, or the complete transaction if there is no statement transaction. - */ + /* + ** If the Vdbe passed as the first argument opened a statement-transaction, + ** close it now. Argument eOp must be either SAVEPOINT_ROLLBACK or + ** SAVEPOINT_RELEASE. If it is SAVEPOINT_ROLLBACK, then the statement + ** transaction is rolled back. If eOp is SAVEPOINT_RELEASE, then the + ** statement transaction is commtted. + ** + ** If an IO error occurs, an SQLITE_IOERR_XXX error code is returned. + ** Otherwise SQLITE_OK. + */ + static int sqlite3VdbeCloseStatement(Vdbe p, int eOp) { + sqlite3 db = p.db; + int rc = SQLITE_OK; + /* If p->iStatement is greater than zero, then this Vdbe opened a + ** statement transaction that should be closed here. The only exception + ** is that an IO error may have occured, causing an emergency rollback. + ** In this case (db->nStatement==0), and there is nothing to do. + */ + if (db.nStatement != 0 && p.iStatement != 0) { + int i; + int iSavepoint = p.iStatement - 1; + + Debug.Assert(eOp == SAVEPOINT_ROLLBACK || eOp == SAVEPOINT_RELEASE); + Debug.Assert(db.nStatement > 0); + Debug.Assert(p.iStatement == (db.nStatement + db.nSavepoint)); + + for (i = 0; i < db.nDb; i++) { + int rc2 = SQLITE_OK; + Btree pBt = db.aDb[i].pBt; + if (pBt != null) { + if (eOp == SAVEPOINT_ROLLBACK) { + rc2 = sqlite3BtreeSavepoint(pBt, SAVEPOINT_ROLLBACK, iSavepoint); + } + if (rc2 == SQLITE_OK) { + rc2 = sqlite3BtreeSavepoint(pBt, SAVEPOINT_RELEASE, iSavepoint); + } + if (rc == SQLITE_OK) { + rc = rc2; + } + } + } + db.nStatement--; + p.iStatement = 0; + + if (rc == SQLITE_OK) { + if (eOp == SAVEPOINT_ROLLBACK) { + rc = sqlite3VtabSavepoint(db, SAVEPOINT_ROLLBACK, iSavepoint); + } + if (rc == SQLITE_OK) { + rc = sqlite3VtabSavepoint(db, SAVEPOINT_RELEASE, iSavepoint); + } + } - //if ( p.db.mallocFailed != 0 ) - //{ - // p.rc = SQLITE_NOMEM; - //} - closeAllCursors( p ); - if ( p.magic != VDBE_MAGIC_RUN ) - { - return SQLITE_OK; - } - checkActiveVdbeCnt( db ); - - /* No commit or rollback needed if the program never started */ - if ( p.pc >= 0 ) - { - int mrc; /* Primary error code from p.rc */ - int eStatementOp = 0; - bool isSpecialError = false; /* Set to true if a 'special' error */ - - /* Lock all btrees used by the statement */ - sqlite3VdbeEnter( p ); - /* Check for one of the special errors */ - mrc = p.rc & 0xff; - Debug.Assert( p.rc != SQLITE_IOERR_BLOCKED ); /* This error no longer exists */ - isSpecialError = mrc == SQLITE_NOMEM || mrc == SQLITE_IOERR - || mrc == SQLITE_INTERRUPT || mrc == SQLITE_FULL; - if ( isSpecialError ) - { - /* If the query was read-only and the error code is SQLITE_INTERRUPT, - ** no rollback is necessary. Otherwise, at least a savepoint - ** transaction must be rolled back to restore the database to a - ** consistent state. - ** - ** Even if the statement is read-only, it is important to perform - ** a statement or transaction rollback operation. If the error - ** occured while writing to the journal, sub-journal or database - ** file as part of an effort to free up cache space (see function - ** pagerStress() in pager.c), the rollback is required to restore - ** the pager to a consistent state. - */ - if ( !p.readOnly || mrc != SQLITE_INTERRUPT ) - { - if ( ( mrc == SQLITE_NOMEM || mrc == SQLITE_FULL ) && p.usesStmtJournal ) - { - eStatementOp = SAVEPOINT_ROLLBACK; - } - else - { - /* We are forced to roll back the active transaction. Before doing - ** so, abort any other statements this handle currently has active. - */ - invalidateCursorsOnModifiedBtrees( db ); - sqlite3RollbackAll( db ); - sqlite3CloseSavepoints( db ); - db.autoCommit = 1; + /* If the statement transaction is being rolled back, also restore the + ** database handles deferred constraint counter to the value it had when + ** the statement transaction was opened. */ + if (eOp == SAVEPOINT_ROLLBACK) { + db.nDeferredCons = p.nStmtDefCons; + } } - } + return rc; } - /* Check for immediate foreign key violations. */ - if ( p.rc == SQLITE_OK ) - { - sqlite3VdbeCheckFk( p, 0 ); - } - - /* If the auto-commit flag is set and this is the only active writer - ** VM, then we do either a commit or rollback of the current transaction. + /* + ** This function is called when a transaction opened by the database + ** handle associated with the VM passed as an argument is about to be + ** committed. If there are outstanding deferred foreign key constraint + ** violations, return SQLITE_ERROR. Otherwise, SQLITE_OK. ** - ** Note: This block also runs if one of the special errors handled - ** above has occurred. + ** If there are outstanding FK violations and this function returns + ** SQLITE_ERROR, set the result of the VM to SQLITE_CONSTRAINT and write + ** an error message to it. Then return SQLITE_ERROR. */ - if ( !sqlite3VtabInSync( db ) - && db.autoCommit != 0 - && db.writeVdbeCnt == ( ( p.readOnly == false ) ? 1 : 0 ) - ) - { - if ( p.rc == SQLITE_OK || ( p.errorAction == OE_Fail && !isSpecialError ) ) - { - rc = sqlite3VdbeCheckFk( p, 1 ); - if ( rc != SQLITE_OK ) - { - if ( NEVER( p.readOnly ) ) - { - sqlite3VdbeLeave( p ); +#if !SQLITE_OMIT_FOREIGN_KEY + static int sqlite3VdbeCheckFk(Vdbe p, int deferred) { + sqlite3 db = p.db; + if ((deferred != 0 && db.nDeferredCons > 0) || (0 == deferred && p.nFkConstraint > 0)) { + p.rc = SQLITE_CONSTRAINT; + p.errorAction = OE_Abort; + sqlite3SetString(ref p.zErrMsg, db, "foreign key constraint failed"); return SQLITE_ERROR; - } - rc = SQLITE_CONSTRAINT; - } - else - { - /* The auto-commit flag is true, the vdbe program was successful - ** or hit an 'OR FAIL' constraint and there are no deferred foreign - ** key constraints to hold up the transaction. This means a commit - ** is required. */ - rc = vdbeCommit( db, p ); - } - if ( rc == SQLITE_BUSY && p.readOnly ) - { - sqlite3VdbeLeave( p ); - return SQLITE_BUSY; - } - else if ( rc != SQLITE_OK ) - { - p.rc = rc; - sqlite3RollbackAll( db ); } - else - { - db.nDeferredCons = 0; - sqlite3CommitInternalChanges( db ); - } - } - else - { - sqlite3RollbackAll( db ); - } - db.nStatement = 0; - } - else if ( eStatementOp == 0 ) - { - if ( p.rc == SQLITE_OK || p.errorAction == OE_Fail ) - { - eStatementOp = SAVEPOINT_RELEASE; - } - else if ( p.errorAction == OE_Abort ) - { - eStatementOp = SAVEPOINT_ROLLBACK; - } - else - { - invalidateCursorsOnModifiedBtrees( db ); - sqlite3RollbackAll( db ); - sqlite3CloseSavepoints( db ); - db.autoCommit = 1; - } + return SQLITE_OK; } +#endif - /* If eStatementOp is non-zero, then a statement transaction needs to - ** be committed or rolled back. Call sqlite3VdbeCloseStatement() to - ** do so. If this operation returns an error, and the current statement - ** error code is SQLITE_OK or SQLITE_CONSTRAINT, then promote the - ** current statement error code. - */ - if ( eStatementOp != 0 ) - { - rc = sqlite3VdbeCloseStatement( p, eStatementOp ); - if ( rc != 0 ) - { - if ( p.rc == SQLITE_OK || p.rc == SQLITE_CONSTRAINT ) - { - p.rc = rc; - sqlite3DbFree( db, ref p.zErrMsg ); - p.zErrMsg = null; + /* + ** This routine is called the when a VDBE tries to halt. If the VDBE + ** has made changes and is in autocommit mode, then commit those + ** changes. If a rollback is needed, then do the rollback. + ** + ** This routine is the only way to move the state of a VM from + ** SQLITE_MAGIC_RUN to SQLITE_MAGIC_HALT. It is harmless to + ** call this on a VM that is in the SQLITE_MAGIC_HALT state. + ** + ** Return an error code. If the commit could not complete because of + ** lock contention, return SQLITE_BUSY. If SQLITE_BUSY is returned, it + ** means the close did not happen and needs to be repeated. + */ + static int sqlite3VdbeHalt(Vdbe p) { + int rc; /* Used to store transient return codes */ + sqlite3 db = p.db; + + /* This function contains the logic that determines if a statement or + ** transaction will be committed or rolled back as a result of the + ** execution of this virtual machine. + ** + ** If any of the following errors occur: + ** + ** SQLITE_NOMEM + ** SQLITE_IOERR + ** SQLITE_FULL + ** SQLITE_INTERRUPT + ** + ** Then the internal cache might have been left in an inconsistent + ** state. We need to rollback the statement transaction, if there is + ** one, or the complete transaction if there is no statement transaction. + */ + + //if ( p.db.mallocFailed != 0 ) + //{ + // p.rc = SQLITE_NOMEM; + //} + closeAllCursors(p); + if (p.magic != VDBE_MAGIC_RUN) { + return SQLITE_OK; } - invalidateCursorsOnModifiedBtrees( db ); - sqlite3RollbackAll( db ); - sqlite3CloseSavepoints( db ); - db.autoCommit = 1; - } - } - - /* If this was an INSERT, UPDATE or DELETE and no statement transaction - ** has been rolled back, update the database connection change-counter. - */ - if ( p.changeCntOn ) - { - if ( eStatementOp != SAVEPOINT_ROLLBACK ) - { - sqlite3VdbeSetChanges( db, p.nChange ); - } - else - { - sqlite3VdbeSetChanges( db, 0 ); - } - p.nChange = 0; - } + checkActiveVdbeCnt(db); + + /* No commit or rollback needed if the program never started */ + if (p.pc >= 0) { + int mrc; /* Primary error code from p.rc */ + int eStatementOp = 0; + bool isSpecialError = false; /* Set to true if a 'special' error */ + + /* Lock all btrees used by the statement */ + sqlite3VdbeEnter(p); + /* Check for one of the special errors */ + mrc = p.rc & 0xff; + Debug.Assert(p.rc != SQLITE_IOERR_BLOCKED); /* This error no longer exists */ + isSpecialError = mrc == SQLITE_NOMEM || mrc == SQLITE_IOERR + || mrc == SQLITE_INTERRUPT || mrc == SQLITE_FULL; + if (isSpecialError) { + /* If the query was read-only and the error code is SQLITE_INTERRUPT, + ** no rollback is necessary. Otherwise, at least a savepoint + ** transaction must be rolled back to restore the database to a + ** consistent state. + ** + ** Even if the statement is read-only, it is important to perform + ** a statement or transaction rollback operation. If the error + ** occured while writing to the journal, sub-journal or database + ** file as part of an effort to free up cache space (see function + ** pagerStress() in pager.c), the rollback is required to restore + ** the pager to a consistent state. + */ + if (!p.readOnly || mrc != SQLITE_INTERRUPT) { + if ((mrc == SQLITE_NOMEM || mrc == SQLITE_FULL) && p.usesStmtJournal) { + eStatementOp = SAVEPOINT_ROLLBACK; + } else { + /* We are forced to roll back the active transaction. Before doing + ** so, abort any other statements this handle currently has active. + */ + invalidateCursorsOnModifiedBtrees(db); + sqlite3RollbackAll(db); + sqlite3CloseSavepoints(db); + db.autoCommit = 1; + } + } + } - /* Rollback or commit any schema changes that occurred. */ - if ( p.rc != SQLITE_OK && ( db.flags & SQLITE_InternChanges ) != 0 ) - { - sqlite3ResetInternalSchema( db, -1 ); - db.flags = ( db.flags | SQLITE_InternChanges ); - } + /* Check for immediate foreign key violations. */ + if (p.rc == SQLITE_OK) { + sqlite3VdbeCheckFk(p, 0); + } - /* Release the locks */ - sqlite3VdbeLeave( p ); - } + /* If the auto-commit flag is set and this is the only active writer + ** VM, then we do either a commit or rollback of the current transaction. + ** + ** Note: This block also runs if one of the special errors handled + ** above has occurred. + */ + if (!sqlite3VtabInSync(db) + && db.autoCommit != 0 + && db.writeVdbeCnt == ((p.readOnly == false) ? 1 : 0) + ) { + if (p.rc == SQLITE_OK || (p.errorAction == OE_Fail && !isSpecialError)) { + rc = sqlite3VdbeCheckFk(p, 1); + if (rc != SQLITE_OK) { + if (NEVER(p.readOnly)) { + sqlite3VdbeLeave(p); + return SQLITE_ERROR; + } + rc = SQLITE_CONSTRAINT; + } else { + /* The auto-commit flag is true, the vdbe program was successful + ** or hit an 'OR FAIL' constraint and there are no deferred foreign + ** key constraints to hold up the transaction. This means a commit + ** is required. */ + rc = vdbeCommit(db, p); + } + if (rc == SQLITE_BUSY && p.readOnly) { + sqlite3VdbeLeave(p); + return SQLITE_BUSY; + } else if (rc != SQLITE_OK) { + p.rc = rc; + sqlite3RollbackAll(db); + } else { + db.nDeferredCons = 0; + sqlite3CommitInternalChanges(db); + } + } else { + sqlite3RollbackAll(db); + } + db.nStatement = 0; + } else if (eStatementOp == 0) { + if (p.rc == SQLITE_OK || p.errorAction == OE_Fail) { + eStatementOp = SAVEPOINT_RELEASE; + } else if (p.errorAction == OE_Abort) { + eStatementOp = SAVEPOINT_ROLLBACK; + } else { + invalidateCursorsOnModifiedBtrees(db); + sqlite3RollbackAll(db); + sqlite3CloseSavepoints(db); + db.autoCommit = 1; + } + } - /* We have successfully halted and closed the VM. Record this fact. */ - if ( p.pc >= 0 ) - { - db.activeVdbeCnt--; - if ( !p.readOnly ) - { - db.writeVdbeCnt--; - } - Debug.Assert( db.activeVdbeCnt >= db.writeVdbeCnt ); - } - p.magic = VDBE_MAGIC_HALT; - checkActiveVdbeCnt( db ); - //if ( p.db.mallocFailed != 0 ) - //{ - // p.rc = SQLITE_NOMEM; - //} - /* If the auto-commit flag is set to true, then any locks that were held - ** by connection db have now been released. Call sqlite3ConnectionUnlocked() - ** to invoke any required unlock-notify callbacks. - */ - if ( db.autoCommit != 0 ) - { - sqlite3ConnectionUnlocked( db ); - } + /* If eStatementOp is non-zero, then a statement transaction needs to + ** be committed or rolled back. Call sqlite3VdbeCloseStatement() to + ** do so. If this operation returns an error, and the current statement + ** error code is SQLITE_OK or SQLITE_CONSTRAINT, then promote the + ** current statement error code. + */ + if (eStatementOp != 0) { + rc = sqlite3VdbeCloseStatement(p, eStatementOp); + if (rc != 0) { + if (p.rc == SQLITE_OK || p.rc == SQLITE_CONSTRAINT) { + p.rc = rc; + sqlite3DbFree(db, ref p.zErrMsg); + p.zErrMsg = null; + } + invalidateCursorsOnModifiedBtrees(db); + sqlite3RollbackAll(db); + sqlite3CloseSavepoints(db); + db.autoCommit = 1; + } + } - Debug.Assert( db.activeVdbeCnt > 0 || db.autoCommit == 0 || db.nStatement == 0 ); - return ( p.rc == SQLITE_BUSY ? SQLITE_BUSY : SQLITE_OK ); - } + /* If this was an INSERT, UPDATE or DELETE and no statement transaction + ** has been rolled back, update the database connection change-counter. + */ + if (p.changeCntOn) { + if (eStatementOp != SAVEPOINT_ROLLBACK) { + sqlite3VdbeSetChanges(db, p.nChange); + } else { + sqlite3VdbeSetChanges(db, 0); + } + p.nChange = 0; + } + /* Rollback or commit any schema changes that occurred. */ + if (p.rc != SQLITE_OK && (db.flags & SQLITE_InternChanges) != 0) { + sqlite3ResetInternalSchema(db, -1); + db.flags = (db.flags | SQLITE_InternChanges); + } - /* - ** Each VDBE holds the result of the most recent sqlite3_step() call - ** in p.rc. This routine sets that result back to SQLITE_OK. - */ - static void sqlite3VdbeResetStepResult( Vdbe p ) - { - p.rc = SQLITE_OK; - } + /* Release the locks */ + sqlite3VdbeLeave(p); + } - /* - ** Clean up a VDBE after execution but do not delete the VDBE just yet. - ** Write any error messages into pzErrMsg. Return the result code. - ** - ** After this routine is run, the VDBE should be ready to be executed - ** again. - ** - ** To look at it another way, this routine resets the state of the - ** virtual machine from VDBE_MAGIC_RUN or VDBE_MAGIC_HALT back to - ** VDBE_MAGIC_INIT. - */ - static int sqlite3VdbeReset( Vdbe p ) - { - sqlite3 db; - db = p.db; - - /* If the VM did not run to completion or if it encountered an - ** error, then it might not have been halted properly. So halt - ** it now. - */ - sqlite3VdbeHalt( p ); + /* We have successfully halted and closed the VM. Record this fact. */ + if (p.pc >= 0) { + db.activeVdbeCnt--; + if (!p.readOnly) { + db.writeVdbeCnt--; + } + Debug.Assert(db.activeVdbeCnt >= db.writeVdbeCnt); + } + p.magic = VDBE_MAGIC_HALT; + checkActiveVdbeCnt(db); + //if ( p.db.mallocFailed != 0 ) + //{ + // p.rc = SQLITE_NOMEM; + //} + /* If the auto-commit flag is set to true, then any locks that were held + ** by connection db have now been released. Call sqlite3ConnectionUnlocked() + ** to invoke any required unlock-notify callbacks. + */ + if (db.autoCommit != 0) { + sqlite3ConnectionUnlocked(db); + } - /* If the VDBE has be run even partially, then transfer the error code - ** and error message from the VDBE into the main database structure. But - ** if the VDBE has just been set to run but has not actually executed any - ** instructions yet, leave the main database error information unchanged. - */ - if ( p.pc >= 0 ) - { - //if ( p.zErrMsg != 0 ) // Always exists under C# - { - sqlite3BeginBenignMalloc(); - sqlite3ValueSetStr( db.pErr, -1, p.zErrMsg == null ? "" : p.zErrMsg, SQLITE_UTF8, SQLITE_TRANSIENT ); - sqlite3EndBenignMalloc(); - db.errCode = p.rc; - sqlite3DbFree( db, ref p.zErrMsg ); - p.zErrMsg = ""; + Debug.Assert(db.activeVdbeCnt > 0 || db.autoCommit == 0 || db.nStatement == 0); + return (p.rc == SQLITE_BUSY ? SQLITE_BUSY : SQLITE_OK); } - //else if ( p.rc != 0 ) - //{ - // sqlite3Error( db, p.rc, 0 ); - //} - //else - //{ - // sqlite3Error( db, SQLITE_OK, 0 ); - //} - if ( p.runOnlyOnce != 0 ) - p.expired = true; - } - else if ( p.rc != 0 && p.expired ) - { - /* The expired flag was set on the VDBE before the first call - ** to sqlite3_step(). For consistency (since sqlite3_step() was - ** called), set the database error in this case as well. + + + /* + ** Each VDBE holds the result of the most recent sqlite3_step() call + ** in p.rc. This routine sets that result back to SQLITE_OK. + */ + static void sqlite3VdbeResetStepResult(Vdbe p) { + p.rc = SQLITE_OK; + } + + /* + ** Clean up a VDBE after execution but do not delete the VDBE just yet. + ** Write any error messages into pzErrMsg. Return the result code. + ** + ** After this routine is run, the VDBE should be ready to be executed + ** again. + ** + ** To look at it another way, this routine resets the state of the + ** virtual machine from VDBE_MAGIC_RUN or VDBE_MAGIC_HALT back to + ** VDBE_MAGIC_INIT. */ - sqlite3Error( db, p.rc, 0 ); - sqlite3ValueSetStr( db.pErr, -1, p.zErrMsg, SQLITE_UTF8, SQLITE_TRANSIENT ); - sqlite3DbFree( db, ref p.zErrMsg ); - p.zErrMsg = ""; - } + static int sqlite3VdbeReset(Vdbe p) { + sqlite3 db; + db = p.db; + + /* If the VM did not run to completion or if it encountered an + ** error, then it might not have been halted properly. So halt + ** it now. + */ + sqlite3VdbeHalt(p); + + /* If the VDBE has be run even partially, then transfer the error code + ** and error message from the VDBE into the main database structure. But + ** if the VDBE has just been set to run but has not actually executed any + ** instructions yet, leave the main database error information unchanged. + */ + if (p.pc >= 0) { + //if ( p.zErrMsg != 0 ) // Always exists under C# + { + sqlite3BeginBenignMalloc(); + sqlite3ValueSetStr(db.pErr, -1, p.zErrMsg == null ? "" : p.zErrMsg, SQLITE_UTF8, SQLITE_TRANSIENT); + sqlite3EndBenignMalloc(); + db.errCode = p.rc; + sqlite3DbFree(db, ref p.zErrMsg); + p.zErrMsg = ""; + } + //else if ( p.rc != 0 ) + //{ + // sqlite3Error( db, p.rc, 0 ); + //} + //else + //{ + // sqlite3Error( db, SQLITE_OK, 0 ); + //} + if (p.runOnlyOnce != 0) + p.expired = true; + } else if (p.rc != 0 && p.expired) { + /* The expired flag was set on the VDBE before the first call + ** to sqlite3_step(). For consistency (since sqlite3_step() was + ** called), set the database error in this case as well. + */ + sqlite3Error(db, p.rc, 0); + sqlite3ValueSetStr(db.pErr, -1, p.zErrMsg, SQLITE_UTF8, SQLITE_TRANSIENT); + sqlite3DbFree(db, ref p.zErrMsg); + p.zErrMsg = ""; + } - /* Reclaim all memory used by the VDBE - */ - Cleanup( p ); + /* Reclaim all memory used by the VDBE + */ + Cleanup(p); - /* Save profiling information from this VDBE run. - */ -#if VDBE_PROFILE && TODO + /* Save profiling information from this VDBE run. + */ +#if VDBE_PROFILE && TODO { FILE *out = fopen("vdbe_profile.out", "a"); if( out ){ @@ -3139,327 +2800,292 @@ static int sqlite3VdbeReset( Vdbe p ) } } #endif - p.magic = VDBE_MAGIC_INIT; - return p.rc & db.errMask; - } - - /* - ** Clean up and delete a VDBE after execution. Return an integer which is - ** the result code. Write any error message text into pzErrMsg. - */ - static int sqlite3VdbeFinalize( ref Vdbe p ) - { - int rc = SQLITE_OK; - if ( p.magic == VDBE_MAGIC_RUN || p.magic == VDBE_MAGIC_HALT ) - { - rc = sqlite3VdbeReset( p ); - Debug.Assert( ( rc & p.db.errMask ) == rc ); - } - sqlite3VdbeDelete( ref p ); - return rc; - } + p.magic = VDBE_MAGIC_INIT; + return p.rc & db.errMask; + } - /* - ** Call the destructor for each auxdata entry in pVdbeFunc for which - ** the corresponding bit in mask is clear. Auxdata entries beyond 31 - ** are always destroyed. To destroy all auxdata entries, call this - ** routine with mask==0. - */ - static void sqlite3VdbeDeleteAuxData( VdbeFunc pVdbeFunc, int mask ) - { - int i; - for ( i = 0; i < pVdbeFunc.nAux; i++ ) - { - AuxData pAux = pVdbeFunc.apAux[i]; - if ( ( i > 31 || ( mask & ( ( (u32)1 ) << i ) ) == 0 && pAux.pAux != null ) ) - { - if ( pAux.pAux != null && pAux.pAux is IDisposable ) - { - (pAux.pAux as IDisposable).Dispose(); - } - pAux.pAux = null; + /* + ** Clean up and delete a VDBE after execution. Return an integer which is + ** the result code. Write any error message text into pzErrMsg. + */ + static int sqlite3VdbeFinalize(ref Vdbe p) { + int rc = SQLITE_OK; + if (p.magic == VDBE_MAGIC_RUN || p.magic == VDBE_MAGIC_HALT) { + rc = sqlite3VdbeReset(p); + Debug.Assert((rc & p.db.errMask) == rc); + } + sqlite3VdbeDelete(ref p); + return rc; } - } - } - /* - ** Free all memory associated with the Vdbe passed as the second argument. - ** The difference between this function and sqlite3VdbeDelete() is that - ** VdbeDelete() also unlinks the Vdbe from the list of VMs associated with - ** the database connection. - */ - static void sqlite3VdbeDeleteObject( sqlite3 db, ref Vdbe p ) - { - SubProgram pSub, pNext; - int i; - Debug.Assert( p.db == null || p.db == db ); - releaseMemArray( p.aVar, p.nVar ); - releaseMemArray( p.aColName, p.nResColumn, COLNAME_N ); - for ( pSub = p.pProgram; pSub != null; pSub = pNext ) - { - pNext = pSub.pNext; - vdbeFreeOpArray( db, ref pSub.aOp, pSub.nOp ); - sqlite3DbFree( db, ref pSub ); - } - //for ( i = p->nzVar - 1; i >= 0; i-- ) - // sqlite3DbFree( db, p.azVar[i] ); - vdbeFreeOpArray( db, ref p.aOp, p.nOp ); - sqlite3DbFree( db, ref p.aLabel ); - sqlite3DbFree( db, ref p.aColName ); - sqlite3DbFree( db, ref p.zSql ); - sqlite3DbFree( db, ref p.pFree ); - // Free memory allocated from db within p - //sqlite3DbFree( db, p ); - } + /* + ** Call the destructor for each auxdata entry in pVdbeFunc for which + ** the corresponding bit in mask is clear. Auxdata entries beyond 31 + ** are always destroyed. To destroy all auxdata entries, call this + ** routine with mask==0. + */ + static void sqlite3VdbeDeleteAuxData(VdbeFunc pVdbeFunc, int mask) { + int i; + for (i = 0; i < pVdbeFunc.nAux; i++) { + AuxData pAux = pVdbeFunc.apAux[i]; + if ((i > 31 || (mask & (((u32)1) << i)) == 0 && pAux.pAux != null)) { + if (pAux.pAux != null && pAux.pAux is IDisposable) { + (pAux.pAux as IDisposable).Dispose(); + } + pAux.pAux = null; + } + } + } - /* - ** Delete an entire VDBE. - */ - static void sqlite3VdbeDelete( ref Vdbe p ) - { - sqlite3 db; - if ( NEVER( p == null ) ) - return; - Cleanup( p ); - db = p.db; - if ( p.pPrev != null ) - { - p.pPrev.pNext = p.pNext; - } - else - { - Debug.Assert( db.pVdbe == p ); - db.pVdbe = p.pNext; - } - if ( p.pNext != null ) - { - p.pNext.pPrev = p.pPrev; - } - p.magic = VDBE_MAGIC_DEAD; - p.db = null; - sqlite3VdbeDeleteObject( db, ref p ); - } + /* + ** Free all memory associated with the Vdbe passed as the second argument. + ** The difference between this function and sqlite3VdbeDelete() is that + ** VdbeDelete() also unlinks the Vdbe from the list of VMs associated with + ** the database connection. + */ + static void sqlite3VdbeDeleteObject(sqlite3 db, ref Vdbe p) { + SubProgram pSub, pNext; + int i; + Debug.Assert(p.db == null || p.db == db); + releaseMemArray(p.aVar, p.nVar); + releaseMemArray(p.aColName, p.nResColumn, COLNAME_N); + for (pSub = p.pProgram; pSub != null; pSub = pNext) { + pNext = pSub.pNext; + vdbeFreeOpArray(db, ref pSub.aOp, pSub.nOp); + sqlite3DbFree(db, ref pSub); + } + //for ( i = p->nzVar - 1; i >= 0; i-- ) + // sqlite3DbFree( db, p.azVar[i] ); + vdbeFreeOpArray(db, ref p.aOp, p.nOp); + sqlite3DbFree(db, ref p.aLabel); + sqlite3DbFree(db, ref p.aColName); + sqlite3DbFree(db, ref p.zSql); + sqlite3DbFree(db, ref p.pFree); + // Free memory allocated from db within p + //sqlite3DbFree( db, p ); + } + + /* + ** Delete an entire VDBE. + */ + static void sqlite3VdbeDelete(ref Vdbe p) { + sqlite3 db; + if (NEVER(p == null)) + return; + Cleanup(p); + db = p.db; + if (p.pPrev != null) { + p.pPrev.pNext = p.pNext; + } else { + Debug.Assert(db.pVdbe == p); + db.pVdbe = p.pNext; + } + if (p.pNext != null) { + p.pNext.pPrev = p.pPrev; + } + p.magic = VDBE_MAGIC_DEAD; + p.db = null; + sqlite3VdbeDeleteObject(db, ref p); + } - /* - ** Make sure the cursor p is ready to read or write the row to which it - ** was last positioned. Return an error code if an OOM fault or I/O error - ** prevents us from positioning the cursor to its correct position. - ** - ** If a MoveTo operation is pending on the given cursor, then do that - ** MoveTo now. If no move is pending, check to see if the row has been - ** deleted out from under the cursor and if it has, mark the row as - ** a NULL row. - ** - ** If the cursor is already pointing to the correct row and that row has - ** not been deleted out from under the cursor, then this routine is a no-op. - */ - static int sqlite3VdbeCursorMoveto( VdbeCursor p ) - { - if ( p.deferredMoveto ) - { - int res = 0; - int rc; -#if SQLITE_TEST + /* + ** Make sure the cursor p is ready to read or write the row to which it + ** was last positioned. Return an error code if an OOM fault or I/O error + ** prevents us from positioning the cursor to its correct position. + ** + ** If a MoveTo operation is pending on the given cursor, then do that + ** MoveTo now. If no move is pending, check to see if the row has been + ** deleted out from under the cursor and if it has, mark the row as + ** a NULL row. + ** + ** If the cursor is already pointing to the correct row and that row has + ** not been deleted out from under the cursor, then this routine is a no-op. + */ + static int sqlite3VdbeCursorMoveto(VdbeCursor p) { + if (p.deferredMoveto) { + int res = 0; + int rc; +#if SQLITE_TEST //extern int sqlite3_search_count; #endif - Debug.Assert( p.isTable ); - rc = sqlite3BtreeMovetoUnpacked( p.pCursor, null, p.movetoTarget, 0, ref res ); - if ( rc != 0 ) - return rc; - p.lastRowid = p.movetoTarget; - if ( res != 0 ) - return SQLITE_CORRUPT_BKPT(); - p.rowidIsValid = true; -#if SQLITE_TEST + Debug.Assert(p.isTable); + rc = sqlite3BtreeMovetoUnpacked(p.pCursor, null, p.movetoTarget, 0, ref res); + if (rc != 0) + return rc; + p.lastRowid = p.movetoTarget; + if (res != 0) + return SQLITE_CORRUPT_BKPT(); + p.rowidIsValid = true; +#if SQLITE_TEST #if !TCLSH sqlite3_search_count++; #else sqlite3_search_count.iValue++; #endif #endif - p.deferredMoveto = false; - p.cacheStatus = CACHE_STALE; - } - else if ( ALWAYS( p.pCursor != null ) ) - { - int hasMoved = 0; - int rc = sqlite3BtreeCursorHasMoved( p.pCursor, ref hasMoved ); - if ( rc != 0 ) - return rc; - if ( hasMoved != 0 ) - { - p.cacheStatus = CACHE_STALE; - p.nullRow = true; + p.deferredMoveto = false; + p.cacheStatus = CACHE_STALE; + } else if (ALWAYS(p.pCursor != null)) { + int hasMoved = 0; + int rc = sqlite3BtreeCursorHasMoved(p.pCursor, ref hasMoved); + if (rc != 0) + return rc; + if (hasMoved != 0) { + p.cacheStatus = CACHE_STALE; + p.nullRow = true; + } + } + return SQLITE_OK; } - } - return SQLITE_OK; - } - /* - ** The following functions: - ** - ** sqlite3VdbeSerialType() - ** sqlite3VdbeSerialTypeLen() - ** sqlite3VdbeSerialLen() - ** sqlite3VdbeSerialPut() - ** sqlite3VdbeSerialGet() - ** - ** encapsulate the code that serializes values for storage in SQLite - ** data and index records. Each serialized value consists of a - ** 'serial-type' and a blob of data. The serial type is an 8-byte unsigned - ** integer, stored as a varint. - ** - ** In an SQLite index record, the serial type is stored directly before - ** the blob of data that it corresponds to. In a table record, all serial - ** types are stored at the start of the record, and the blobs of data at - ** the end. Hence these functions allow the caller to handle the - ** serial-type and data blob seperately. - ** - ** The following table describes the various storage classes for data: - ** - ** serial type bytes of data type - ** -------------- --------------- --------------- - ** 0 0 NULL - ** 1 1 signed integer - ** 2 2 signed integer - ** 3 3 signed integer - ** 4 4 signed integer - ** 5 6 signed integer - ** 6 8 signed integer - ** 7 8 IEEE float - ** 8 0 Integer constant 0 - ** 9 0 Integer constant 1 - ** 10,11 reserved for expansion - ** N>=12 and even (N-12)/2 BLOB - ** N>=13 and odd (N-13)/2 text - ** - ** The 8 and 9 types were added in 3.3.0, file format 4. Prior versions - ** of SQLite will not understand those serial types. - */ + /* + ** The following functions: + ** + ** sqlite3VdbeSerialType() + ** sqlite3VdbeSerialTypeLen() + ** sqlite3VdbeSerialLen() + ** sqlite3VdbeSerialPut() + ** sqlite3VdbeSerialGet() + ** + ** encapsulate the code that serializes values for storage in SQLite + ** data and index records. Each serialized value consists of a + ** 'serial-type' and a blob of data. The serial type is an 8-byte unsigned + ** integer, stored as a varint. + ** + ** In an SQLite index record, the serial type is stored directly before + ** the blob of data that it corresponds to. In a table record, all serial + ** types are stored at the start of the record, and the blobs of data at + ** the end. Hence these functions allow the caller to handle the + ** serial-type and data blob seperately. + ** + ** The following table describes the various storage classes for data: + ** + ** serial type bytes of data type + ** -------------- --------------- --------------- + ** 0 0 NULL + ** 1 1 signed integer + ** 2 2 signed integer + ** 3 3 signed integer + ** 4 4 signed integer + ** 5 6 signed integer + ** 6 8 signed integer + ** 7 8 IEEE float + ** 8 0 Integer constant 0 + ** 9 0 Integer constant 1 + ** 10,11 reserved for expansion + ** N>=12 and even (N-12)/2 BLOB + ** N>=13 and odd (N-13)/2 text + ** + ** The 8 and 9 types were added in 3.3.0, file format 4. Prior versions + ** of SQLite will not understand those serial types. + */ - /* - ** Return the serial-type for the value stored in pMem. - */ - static u32 sqlite3VdbeSerialType( Mem pMem, int file_format ) - { - int flags = pMem.flags; - int n; - - if ( ( flags & MEM_Null ) != 0 ) - { - return 0; - } - if ( ( flags & MEM_Int ) != 0 ) - { - /* Figure out whether to use 1, 2, 4, 6 or 8 bytes. */ - const i64 MAX_6BYTE = ( ( ( (i64)0x00008000 ) << 32 ) - 1 ); - i64 i = pMem.u.i; - u64 u; - if ( file_format >= 4 && ( i & 1 ) == i ) - { - return 8 + (u32)i; - } - if ( i < 0 ) - { - if ( i < ( -MAX_6BYTE ) ) - return 6; - /* Previous test prevents: u = -(-9223372036854775808) */ - u = (u64)( -i ); - } - else - { - u = (u64)i; - } - if ( u <= 127 ) - return 1; - if ( u <= 32767 ) - return 2; - if ( u <= 8388607 ) - return 3; - if ( u <= 2147483647 ) - return 4; - if ( u <= MAX_6BYTE ) - return 5; - return 6; - } - if ( ( flags & MEM_Real ) != 0 ) - { - return 7; - } - Debug.Assert( /* pMem.db.mallocFailed != 0 || */ ( flags & ( MEM_Str | MEM_Blob ) ) != 0 ); - n = pMem.n; - if ( ( flags & MEM_Zero ) != 0 ) - { - n += pMem.u.nZero; - } - else if ( ( flags & MEM_Blob ) != 0 ) - { - n = pMem.zBLOB != null ? pMem.zBLOB.Length : pMem.z != null ? pMem.z.Length : 0; - } - else - { - if ( pMem.z != null ) - n = Encoding.UTF8.GetByteCount( pMem.n < pMem.z.Length ? pMem.z.Substring( 0, pMem.n ) : pMem.z ); - else - n = pMem.zBLOB.Length; - pMem.n = n; - } + /* + ** Return the serial-type for the value stored in pMem. + */ + static u32 sqlite3VdbeSerialType(Mem pMem, int file_format) { + int flags = pMem.flags; + int n; - Debug.Assert( n >= 0 ); - return (u32)( ( n * 2 ) + 12 + ( ( ( flags & MEM_Str ) != 0 ) ? 1 : 0 ) ); - } + if ((flags & MEM_Null) != 0) { + return 0; + } + if ((flags & MEM_Int) != 0) { + /* Figure out whether to use 1, 2, 4, 6 or 8 bytes. */ + const i64 MAX_6BYTE = ((((i64)0x00008000) << 32) - 1); + i64 i = pMem.u.i; + u64 u; + if (file_format >= 4 && (i & 1) == i) { + return 8 + (u32)i; + } + if (i < 0) { + if (i < (-MAX_6BYTE)) + return 6; + /* Previous test prevents: u = -(-9223372036854775808) */ + u = (u64)(-i); + } else { + u = (u64)i; + } + if (u <= 127) + return 1; + if (u <= 32767) + return 2; + if (u <= 8388607) + return 3; + if (u <= 2147483647) + return 4; + if (u <= MAX_6BYTE) + return 5; + return 6; + } + if ((flags & MEM_Real) != 0) { + return 7; + } + Debug.Assert( /* pMem.db.mallocFailed != 0 || */ (flags & (MEM_Str | MEM_Blob)) != 0); + n = pMem.n; + if ((flags & MEM_Zero) != 0) { + n += pMem.u.nZero; + } else if ((flags & MEM_Blob) != 0) { + n = pMem.zBLOB != null ? pMem.zBLOB.Length : pMem.z != null ? pMem.z.Length : 0; + } else { + if (pMem.z != null) + n = Encoding.UTF8.GetByteCount(pMem.n < pMem.z.Length ? pMem.z.Substring(0, pMem.n) : pMem.z); + else + n = pMem.zBLOB.Length; + pMem.n = n; + } - /* - ** Return the length of the data corresponding to the supplied serial-type. - */ - static u32[] aSize = new u32[] { 0, 1, 2, 3, 4, 6, 8, 8, 0, 0, 0, 0 }; - static u32 sqlite3VdbeSerialTypeLen( u32 serial_type ) - { - if ( serial_type >= 12 ) - { - return (u32)( ( serial_type - 12 ) / 2 ); - } - else - { - return aSize[serial_type]; - } - } + Debug.Assert(n >= 0); + return (u32)((n * 2) + 12 + (((flags & MEM_Str) != 0) ? 1 : 0)); + } - /* - ** If we are on an architecture with mixed-endian floating - ** points (ex: ARM7) then swap the lower 4 bytes with the - ** upper 4 bytes. Return the result. - ** - ** For most architectures, this is a no-op. - ** - ** (later): It is reported to me that the mixed-endian problem - ** on ARM7 is an issue with GCC, not with the ARM7 chip. It seems - ** that early versions of GCC stored the two words of a 64-bit - ** float in the wrong order. And that error has been propagated - ** ever since. The blame is not necessarily with GCC, though. - ** GCC might have just copying the problem from a prior compiler. - ** I am also told that newer versions of GCC that follow a different - ** ABI get the byte order right. - ** - ** Developers using SQLite on an ARM7 should compile and run their - ** application using -DSQLITE_DEBUG=1 at least once. With DEBUG - ** enabled, some Debug.Asserts below will ensure that the byte order of - ** floating point values is correct. - ** - ** (2007-08-30) Frank van Vugt has studied this problem closely - ** and has send his findings to the SQLite developers. Frank - ** writes that some Linux kernels offer floating point hardware - ** emulation that uses only 32-bit mantissas instead of a full - ** 48-bits as required by the IEEE standard. (This is the - ** CONFIG_FPE_FASTFPE option.) On such systems, floating point - ** byte swapping becomes very complicated. To avoid problems, - ** the necessary byte swapping is carried out using a 64-bit integer - ** rather than a 64-bit float. Frank assures us that the code here - ** works for him. We, the developers, have no way to independently - ** verify this, but Frank seems to know what he is talking about - ** so we trust him. - */ -#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT + /* + ** Return the length of the data corresponding to the supplied serial-type. + */ + static u32[] aSize = new u32[] { 0, 1, 2, 3, 4, 6, 8, 8, 0, 0, 0, 0 }; + static u32 sqlite3VdbeSerialTypeLen(u32 serial_type) { + if (serial_type >= 12) { + return (u32)((serial_type - 12) / 2); + } else { + return aSize[serial_type]; + } + } + + /* + ** If we are on an architecture with mixed-endian floating + ** points (ex: ARM7) then swap the lower 4 bytes with the + ** upper 4 bytes. Return the result. + ** + ** For most architectures, this is a no-op. + ** + ** (later): It is reported to me that the mixed-endian problem + ** on ARM7 is an issue with GCC, not with the ARM7 chip. It seems + ** that early versions of GCC stored the two words of a 64-bit + ** float in the wrong order. And that error has been propagated + ** ever since. The blame is not necessarily with GCC, though. + ** GCC might have just copying the problem from a prior compiler. + ** I am also told that newer versions of GCC that follow a different + ** ABI get the byte order right. + ** + ** Developers using SQLite on an ARM7 should compile and run their + ** application using -DSQLITE_DEBUG=1 at least once. With DEBUG + ** enabled, some Debug.Asserts below will ensure that the byte order of + ** floating point values is correct. + ** + ** (2007-08-30) Frank van Vugt has studied this problem closely + ** and has send his findings to the SQLite developers. Frank + ** writes that some Linux kernels offer floating point hardware + ** emulation that uses only 32-bit mantissas instead of a full + ** 48-bits as required by the IEEE standard. (This is the + ** CONFIG_FPE_FASTFPE option.) On such systems, floating point + ** byte swapping becomes very complicated. To avoid problems, + ** the necessary byte swapping is carried out using a 64-bit integer + ** rather than a 64-bit float. Frank assures us that the code here + ** works for him. We, the developers, have no way to independently + ** verify this, but Frank seems to know what he is talking about + ** so we trust him. + */ +#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT //static u64 floatSwap(u64 in){ // union { // u64 r; @@ -3475,839 +3101,751 @@ static u32 sqlite3VdbeSerialTypeLen( u32 serial_type ) //} //# define swapMixedEndianFloat(X) X = floatSwap(X) #else - //# define swapMixedEndianFloat(X) + //# define swapMixedEndianFloat(X) #endif - /* -** Write the serialized data blob for the value stored in pMem into -** buf. It is assumed that the caller has allocated sufficient space. -** Return the number of bytes written. -** -** nBuf is the amount of space left in buf[]. nBuf must always be -** large enough to hold the entire field. Except, if the field is -** a blob with a zero-filled tail, then buf[] might be just the right -** size to hold everything except for the zero-filled tail. If buf[] -** is only big enough to hold the non-zero prefix, then only write that -** prefix into buf[]. But if buf[] is large enough to hold both the -** prefix and the tail then write the prefix and set the tail to all -** zeros. -** -** Return the number of bytes actually written into buf[]. The number -** of bytes in the zero-filled tail is included in the return value only -** if those bytes were zeroed in buf[]. -*/ - static u32 sqlite3VdbeSerialPut( byte[] buf, int offset, int nBuf, Mem pMem, int file_format ) - { - u32 serial_type = sqlite3VdbeSerialType( pMem, file_format ); - u32 len; - - /* Integer and Real */ - if ( serial_type <= 7 && serial_type > 0 ) - { - u64 v; - u32 i; - if ( serial_type == 7 ) - { - //Debug.Assert( sizeof( v) == sizeof(pMem.r)); + /* + ** Write the serialized data blob for the value stored in pMem into + ** buf. It is assumed that the caller has allocated sufficient space. + ** Return the number of bytes written. + ** + ** nBuf is the amount of space left in buf[]. nBuf must always be + ** large enough to hold the entire field. Except, if the field is + ** a blob with a zero-filled tail, then buf[] might be just the right + ** size to hold everything except for the zero-filled tail. If buf[] + ** is only big enough to hold the non-zero prefix, then only write that + ** prefix into buf[]. But if buf[] is large enough to hold both the + ** prefix and the tail then write the prefix and set the tail to all + ** zeros. + ** + ** Return the number of bytes actually written into buf[]. The number + ** of bytes in the zero-filled tail is included in the return value only + ** if those bytes were zeroed in buf[]. + */ + static u32 sqlite3VdbeSerialPut(byte[] buf, int offset, int nBuf, Mem pMem, int file_format) { + u32 serial_type = sqlite3VdbeSerialType(pMem, file_format); + u32 len; + + /* Integer and Real */ + if (serial_type <= 7 && serial_type > 0) { + u64 v; + u32 i; + if (serial_type == 7) { + //Debug.Assert( sizeof( v) == sizeof(pMem.r)); #if WINDOWS_PHONE || WINDOWS_MOBILE v = (ulong)BitConverter.ToInt64(BitConverter.GetBytes(pMem.r),0); #else - v = (ulong)BitConverter.DoubleToInt64Bits( pMem.r );// memcpy( &v, pMem.r, v ).Length; + v = (ulong)BitConverter.DoubleToInt64Bits(pMem.r);// memcpy( &v, pMem.r, v ).Length; #endif -#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT +#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT swapMixedEndianFloat( v ); #endif - } - else - { - v = (ulong)pMem.u.i; - } - len = i = sqlite3VdbeSerialTypeLen( serial_type ); - Debug.Assert( len <= (u32)nBuf ); - while ( i-- != 0 ) - { - buf[offset + i] = (u8)( v & 0xFF ); - v >>= 8; - } - return len; - } + } else { + v = (ulong)pMem.u.i; + } + len = i = sqlite3VdbeSerialTypeLen(serial_type); + Debug.Assert(len <= (u32)nBuf); + while (i-- != 0) { + buf[offset + i] = (u8)(v & 0xFF); + v >>= 8; + } + return len; + } - /* String or blob */ - if ( serial_type >= 12 ) - { - // TO DO -- PASS TESTS WITH THIS ON Debug.Assert( pMem.n + ( ( pMem.flags & MEM_Zero ) != 0 ? pMem.u.nZero : 0 ) == (int)sqlite3VdbeSerialTypeLen( serial_type ) ); - Debug.Assert( pMem.n <= nBuf ); - if ( ( len = (u32)pMem.n ) != 0 ) - if ( pMem.zBLOB == null && String.IsNullOrEmpty( pMem.z ) ) - { - } - else if ( pMem.zBLOB != null && (( pMem.flags & MEM_Blob ) != 0 || pMem.z == null )) - Buffer.BlockCopy( pMem.zBLOB, 0, buf, offset, (int)len );//memcpy( buf, pMem.z, len ); - else - Buffer.BlockCopy( Encoding.UTF8.GetBytes( pMem.z ), 0, buf, offset, (int)len );//memcpy( buf, pMem.z, len ); - if ( ( pMem.flags & MEM_Zero ) != 0 ) - { - len += (u32)pMem.u.nZero; - Debug.Assert( nBuf >= 0 ); - if ( len > (u32)nBuf ) - { - len = (u32)nBuf; - } - Array.Clear( buf, offset + pMem.n, (int)( len - pMem.n ) );// memset( &buf[pMem.n], 0, len - pMem.n ); - } - return len; - } + /* String or blob */ + if (serial_type >= 12) { + // TO DO -- PASS TESTS WITH THIS ON Debug.Assert( pMem.n + ( ( pMem.flags & MEM_Zero ) != 0 ? pMem.u.nZero : 0 ) == (int)sqlite3VdbeSerialTypeLen( serial_type ) ); + Debug.Assert(pMem.n <= nBuf); + if ((len = (u32)pMem.n) != 0) + if (pMem.zBLOB == null && String.IsNullOrEmpty(pMem.z)) { + } else if (pMem.zBLOB != null && ((pMem.flags & MEM_Blob) != 0 || pMem.z == null)) + Buffer.BlockCopy(pMem.zBLOB, 0, buf, offset, (int)len);//memcpy( buf, pMem.z, len ); + else + Buffer.BlockCopy(Encoding.UTF8.GetBytes(pMem.z), 0, buf, offset, (int)len);//memcpy( buf, pMem.z, len ); + if ((pMem.flags & MEM_Zero) != 0) { + len += (u32)pMem.u.nZero; + Debug.Assert(nBuf >= 0); + if (len > (u32)nBuf) { + len = (u32)nBuf; + } + Array.Clear(buf, offset + pMem.n, (int)(len - pMem.n));// memset( &buf[pMem.n], 0, len - pMem.n ); + } + return len; + } - /* NULL or constants 0 or 1 */ - return 0; - } + /* NULL or constants 0 or 1 */ + return 0; + } - /* - ** Deserialize the data blob pointed to by buf as serial type serial_type - ** and store the result in pMem. Return the number of bytes read. - */ - static u32 sqlite3VdbeSerialGet( - byte[] buf, /* Buffer to deserialize from */ - int offset, /* Offset into Buffer */ - u32 serial_type, /* Serial type to deserialize */ - Mem pMem /* Memory cell to write value into */ - ) - { - switch ( serial_type ) - { - case 10: /* Reserved for future use */ - case 11: /* Reserved for future use */ - case 0: - { /* NULL */ - pMem.flags = MEM_Null; - pMem.n = 0; - pMem.z = null; - pMem.zBLOB = null; - break; - } - case 1: - { /* 1-byte signed integer */ - pMem.u.i = (sbyte)buf[offset + 0]; - pMem.flags = MEM_Int; - return 1; - } - case 2: - { /* 2-byte signed integer */ - pMem.u.i = (int)( ( ( (sbyte)buf[offset + 0] ) << 8 ) | buf[offset + 1] ); - pMem.flags = MEM_Int; - return 2; - } - case 3: - { /* 3-byte signed integer */ - pMem.u.i = (int)( ( ( (sbyte)buf[offset + 0] ) << 16 ) | ( buf[offset + 1] << 8 ) | buf[offset + 2] ); - pMem.flags = MEM_Int; - return 3; - } - case 4: - { /* 4-byte signed integer */ - pMem.u.i = (int)( ( (sbyte)buf[offset + 0] << 24 ) | ( buf[offset + 1] << 16 ) | ( buf[offset + 2] << 8 ) | buf[offset + 3] ); - pMem.flags = MEM_Int; - return 4; - } - case 5: - { /* 6-byte signed integer */ - u64 x = (ulong)( ( ( (sbyte)buf[offset + 0] ) << 8 ) | buf[offset + 1] ); - u32 y = (u32)( ( buf[offset + 2] << 24 ) | ( buf[offset + 3] << 16 ) | ( buf[offset + 4] << 8 ) | buf[offset + 5] ); - x = ( x << 32 ) | y; - pMem.u.i = (i64)x; - pMem.flags = MEM_Int; - return 6; - } - case 6: /* 8-byte signed integer */ - case 7: - { /* IEEE floating point */ - u64 x; - u32 y; + /* + ** Deserialize the data blob pointed to by buf as serial type serial_type + ** and store the result in pMem. Return the number of bytes read. + */ + static u32 sqlite3VdbeSerialGet( + byte[] buf, /* Buffer to deserialize from */ + int offset, /* Offset into Buffer */ + u32 serial_type, /* Serial type to deserialize */ + Mem pMem /* Memory cell to write value into */ + ) { + switch (serial_type) { + case 10: /* Reserved for future use */ + case 11: /* Reserved for future use */ + case 0: { /* NULL */ + pMem.flags = MEM_Null; + pMem.n = 0; + pMem.z = null; + pMem.zBLOB = null; + break; + } + case 1: { /* 1-byte signed integer */ + pMem.u.i = (sbyte)buf[offset + 0]; + pMem.flags = MEM_Int; + return 1; + } + case 2: { /* 2-byte signed integer */ + pMem.u.i = (int)((((sbyte)buf[offset + 0]) << 8) | buf[offset + 1]); + pMem.flags = MEM_Int; + return 2; + } + case 3: { /* 3-byte signed integer */ + pMem.u.i = (int)((((sbyte)buf[offset + 0]) << 16) | (buf[offset + 1] << 8) | buf[offset + 2]); + pMem.flags = MEM_Int; + return 3; + } + case 4: { /* 4-byte signed integer */ + pMem.u.i = (int)(((sbyte)buf[offset + 0] << 24) | (buf[offset + 1] << 16) | (buf[offset + 2] << 8) | buf[offset + 3]); + pMem.flags = MEM_Int; + return 4; + } + case 5: { /* 6-byte signed integer */ + u64 x = (ulong)((((sbyte)buf[offset + 0]) << 8) | buf[offset + 1]); + u32 y = (u32)((buf[offset + 2] << 24) | (buf[offset + 3] << 16) | (buf[offset + 4] << 8) | buf[offset + 5]); + x = (x << 32) | y; + pMem.u.i = (i64)x; + pMem.flags = MEM_Int; + return 6; + } + case 6: /* 8-byte signed integer */ + case 7: { /* IEEE floating point */ + u64 x; + u32 y; #if !NDEBUG && !SQLITE_OMIT_FLOATING_POINT - /* Verify that integers and floating point values use the same -** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is -** defined that 64-bit floating point values really are mixed -** endian. -*/ - const u64 t1 = ( (u64)0x3ff00000 ) << 32; - const double r1 = 1.0; - u64 t2 = t1; -#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT + /* Verify that integers and floating point values use the same + ** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is + ** defined that 64-bit floating point values really are mixed + ** endian. + */ + const u64 t1 = ((u64)0x3ff00000) << 32; + const double r1 = 1.0; + u64 t2 = t1; +#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT swapMixedEndianFloat(t2); #endif - Debug.Assert( sizeof( double ) == sizeof( u64 ) && memcmp( BitConverter.GetBytes( r1 ), BitConverter.GetBytes( t2 ), sizeof( double ) ) == 0 );//Debug.Assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, t2, sizeof(r1))==0 ); + Debug.Assert(sizeof(double) == sizeof(u64) && memcmp(BitConverter.GetBytes(r1), BitConverter.GetBytes(t2), sizeof(double)) == 0);//Debug.Assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, t2, sizeof(r1))==0 ); #endif - x = (u64)( ( buf[offset + 0] << 24 ) | ( buf[offset + 1] << 16 ) | ( buf[offset + 2] << 8 ) | buf[offset + 3] ); - y = (u32)( ( buf[offset + 4] << 24 ) | ( buf[offset + 5] << 16 ) | ( buf[offset + 6] << 8 ) | buf[offset + 7] ); - x = ( x << 32 ) | y; - if ( serial_type == 6 ) - { - pMem.u.i = (i64)x; - pMem.flags = MEM_Int; - } - else - { - Debug.Assert( sizeof( i64 ) == 8 && sizeof( double ) == 8 ); -#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT + x = (u64)((buf[offset + 0] << 24) | (buf[offset + 1] << 16) | (buf[offset + 2] << 8) | buf[offset + 3]); + y = (u32)((buf[offset + 4] << 24) | (buf[offset + 5] << 16) | (buf[offset + 6] << 8) | buf[offset + 7]); + x = (x << 32) | y; + if (serial_type == 6) { + pMem.u.i = (i64)x; + pMem.flags = MEM_Int; + } else { + Debug.Assert(sizeof(i64) == 8 && sizeof(double) == 8); +#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT swapMixedEndianFloat(x); #endif #if WINDOWS_PHONE || WINDOWS_MOBILE pMem.r = BitConverter.ToDouble(BitConverter.GetBytes((long)x), 0); #else - pMem.r = BitConverter.Int64BitsToDouble( (long)x );// memcpy(pMem.r, x, sizeof(x)) + pMem.r = BitConverter.Int64BitsToDouble((long)x);// memcpy(pMem.r, x, sizeof(x)) #endif - pMem.flags = (u16)( sqlite3IsNaN( pMem.r ) ? MEM_Null : MEM_Real ); + pMem.flags = (u16)(sqlite3IsNaN(pMem.r) ? MEM_Null : MEM_Real); + } + return 8; + } + case 8: /* Integer 0 */ + case 9: { /* Integer 1 */ + pMem.u.i = serial_type - 8; + pMem.flags = MEM_Int; + return 0; + } + default: { + u32 len = (serial_type - 12) / 2; + pMem.n = (int)len; + pMem.xDel = null; + if ((serial_type & 0x01) != 0) { + pMem.flags = MEM_Str | MEM_Ephem; + if (len <= buf.Length - offset) { + pMem.z = Encoding.UTF8.GetString(buf, offset, (int)len);//memcpy( buf, pMem.z, len ); + pMem.n = pMem.z.Length; + } else { + pMem.z = ""; // Corrupted Data + pMem.n = 0; + } + pMem.zBLOB = null; + } else { + pMem.z = null; + pMem.zBLOB = sqlite3Malloc((int)len); + pMem.flags = MEM_Blob | MEM_Ephem; + if (len <= buf.Length - offset) { + Buffer.BlockCopy(buf, offset, pMem.zBLOB, 0, (int)len);//memcpy( buf, pMem.z, len ); + } else { + Buffer.BlockCopy(buf, offset, pMem.zBLOB, 0, buf.Length - offset - 1); + } + } + return len; + } } - return 8; - } - case 8: /* Integer 0 */ - case 9: - { /* Integer 1 */ - pMem.u.i = serial_type - 8; - pMem.flags = MEM_Int; return 0; - } - default: - { - u32 len = ( serial_type - 12 ) / 2; - pMem.n = (int)len; - pMem.xDel = null; - if ( ( serial_type & 0x01 ) != 0 ) - { - pMem.flags = MEM_Str | MEM_Ephem; - if ( len <= buf.Length - offset ) - { - pMem.z = Encoding.UTF8.GetString( buf, offset, (int)len );//memcpy( buf, pMem.z, len ); - pMem.n = pMem.z.Length; - } - else - { - pMem.z = ""; // Corrupted Data - pMem.n = 0; - } - pMem.zBLOB = null; - } - else - { - pMem.z = null; - pMem.zBLOB = sqlite3Malloc( (int)len ); - pMem.flags = MEM_Blob | MEM_Ephem; - if ( len <= buf.Length - offset ) - { - Buffer.BlockCopy( buf, offset, pMem.zBLOB, 0, (int)len );//memcpy( buf, pMem.z, len ); - } - else - { - Buffer.BlockCopy( buf, offset, pMem.zBLOB, 0, buf.Length - offset - 1 ); - } - } - return len; - } - } - return 0; - } + } - static int sqlite3VdbeSerialGet( - byte[] buf, /* Buffer to deserialize from */ - u32 serial_type, /* Serial type to deserialize */ - Mem pMem /* Memory cell to write value into */ - ) - { - switch ( serial_type ) - { - case 10: /* Reserved for future use */ - case 11: /* Reserved for future use */ - case 0: - { /* NULL */ - pMem.flags = MEM_Null; - break; - } - case 1: - { /* 1-byte signed integer */ - pMem.u.i = (sbyte)buf[0]; - pMem.flags = MEM_Int; - return 1; - } - case 2: - { /* 2-byte signed integer */ - pMem.u.i = (int)( ( ( buf[0] ) << 8 ) | buf[1] ); - pMem.flags = MEM_Int; - return 2; - } - case 3: - { /* 3-byte signed integer */ - pMem.u.i = (int)( ( ( buf[0] ) << 16 ) | ( buf[1] << 8 ) | buf[2] ); - pMem.flags = MEM_Int; - return 3; - } - case 4: - { /* 4-byte signed integer */ - pMem.u.i = (int)( ( buf[0] << 24 ) | ( buf[1] << 16 ) | ( buf[2] << 8 ) | buf[3] ); - pMem.flags = MEM_Int; - return 4; - } - case 5: - { /* 6-byte signed integer */ - u64 x = (ulong)( ( ( buf[0] ) << 8 ) | buf[1] ); - u32 y = (u32)( ( buf[2] << 24 ) | ( buf[3] << 16 ) | ( buf[4] << 8 ) | buf[5] ); - x = ( x << 32 ) | y; - pMem.u.i = (i64)x; - pMem.flags = MEM_Int; - return 6; - } - case 6: /* 8-byte signed integer */ - case 7: - { /* IEEE floating point */ - u64 x; - u32 y; + static int sqlite3VdbeSerialGet( + byte[] buf, /* Buffer to deserialize from */ + u32 serial_type, /* Serial type to deserialize */ + Mem pMem /* Memory cell to write value into */ + ) { + switch (serial_type) { + case 10: /* Reserved for future use */ + case 11: /* Reserved for future use */ + case 0: { /* NULL */ + pMem.flags = MEM_Null; + break; + } + case 1: { /* 1-byte signed integer */ + pMem.u.i = (sbyte)buf[0]; + pMem.flags = MEM_Int; + return 1; + } + case 2: { /* 2-byte signed integer */ + pMem.u.i = (int)(((buf[0]) << 8) | buf[1]); + pMem.flags = MEM_Int; + return 2; + } + case 3: { /* 3-byte signed integer */ + pMem.u.i = (int)(((buf[0]) << 16) | (buf[1] << 8) | buf[2]); + pMem.flags = MEM_Int; + return 3; + } + case 4: { /* 4-byte signed integer */ + pMem.u.i = (int)((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]); + pMem.flags = MEM_Int; + return 4; + } + case 5: { /* 6-byte signed integer */ + u64 x = (ulong)(((buf[0]) << 8) | buf[1]); + u32 y = (u32)((buf[2] << 24) | (buf[3] << 16) | (buf[4] << 8) | buf[5]); + x = (x << 32) | y; + pMem.u.i = (i64)x; + pMem.flags = MEM_Int; + return 6; + } + case 6: /* 8-byte signed integer */ + case 7: { /* IEEE floating point */ + u64 x; + u32 y; #if !NDEBUG && !SQLITE_OMIT_FLOATING_POINT - /* Verify that integers and floating point values use the same -** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is -** defined that 64-bit floating point values really are mixed -** endian. -*/ - const u64 t1 = ( (u64)0x3ff00000 ) << 32; - const double r1 = 1.0; - u64 t2 = t1; -#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT + /* Verify that integers and floating point values use the same + ** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is + ** defined that 64-bit floating point values really are mixed + ** endian. + */ + const u64 t1 = ((u64)0x3ff00000) << 32; + const double r1 = 1.0; + u64 t2 = t1; +#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT swapMixedEndianFloat(t2); #endif - Debug.Assert( sizeof( double ) == sizeof( u64 ) && memcmp( BitConverter.GetBytes( r1 ), BitConverter.GetBytes( t2 ), sizeof( double ) ) == 0 );//Debug.Assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, t2, sizeof(r1))==0 ); + Debug.Assert(sizeof(double) == sizeof(u64) && memcmp(BitConverter.GetBytes(r1), BitConverter.GetBytes(t2), sizeof(double)) == 0);//Debug.Assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, t2, sizeof(r1))==0 ); #endif - x = (u64)( ( buf[0] << 24 ) | ( buf[1] << 16 ) | ( buf[2] << 8 ) | buf[3] ); - y = (u32)( ( buf[4] << 24 ) | ( buf[5] << 16 ) | ( buf[6] << 8 ) | buf[7] ); - x = ( x << 32 ) | y; - if ( serial_type == 6 ) - { - pMem.u.i = (i64)x; - pMem.flags = MEM_Int; - } - else - { - Debug.Assert( sizeof( i64 ) == 8 && sizeof( double ) == 8 ); -#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT + x = (u64)((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]); + y = (u32)((buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7]); + x = (x << 32) | y; + if (serial_type == 6) { + pMem.u.i = (i64)x; + pMem.flags = MEM_Int; + } else { + Debug.Assert(sizeof(i64) == 8 && sizeof(double) == 8); +#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT swapMixedEndianFloat(x); #endif #if WINDOWS_PHONE || WINDOWS_MOBILE pMem.r = BitConverter.ToDouble(BitConverter.GetBytes((long)x), 0); #else - pMem.r = BitConverter.Int64BitsToDouble( (long)x );// memcpy(pMem.r, x, sizeof(x)) + pMem.r = BitConverter.Int64BitsToDouble((long)x);// memcpy(pMem.r, x, sizeof(x)) #endif - pMem.flags = MEM_Real; + pMem.flags = MEM_Real; + } + return 8; + } + case 8: /* Integer 0 */ + case 9: { /* Integer 1 */ + pMem.u.i = serial_type - 8; + pMem.flags = MEM_Int; + return 0; + } + default: { + int len = (int)((serial_type - 12) / 2); + pMem.xDel = null; + if ((serial_type & 0x01) != 0) { + pMem.flags = MEM_Str | MEM_Ephem; + pMem.z = Encoding.UTF8.GetString(buf, 0, len);//memcpy( buf, pMem.z, len ); + pMem.n = pMem.z.Length;// len; + pMem.zBLOB = null; + } else { + pMem.flags = MEM_Blob | MEM_Ephem; + pMem.zBLOB = sqlite3Malloc(len); + buf.CopyTo(pMem.zBLOB, 0); + pMem.n = len;// len; + pMem.z = null; + } + return len; + } } - return 8; - } - case 8: /* Integer 0 */ - case 9: - { /* Integer 1 */ - pMem.u.i = serial_type - 8; - pMem.flags = MEM_Int; return 0; - } - default: - { - int len = (int)( ( serial_type - 12 ) / 2 ); - pMem.xDel = null; - if ( ( serial_type & 0x01 ) != 0 ) + } + + /* + ** Given the nKey-byte encoding of a record in pKey[], parse the + ** record into a UnpackedRecord structure. Return a pointer to + ** that structure. + ** + ** The calling function might provide szSpace bytes of memory + ** space at pSpace. This space can be used to hold the returned + ** VDbeParsedRecord structure if it is large enough. If it is + ** not big enough, space is obtained from sqlite3Malloc(). + ** + ** The returned structure should be closed by a call to + ** sqlite3VdbeDeleteUnpackedRecord(). + */ + static UnpackedRecord sqlite3VdbeRecordUnpack( + KeyInfo pKeyInfo, /* Information about the record format */ + int nKey, /* Size of the binary record */ + byte[] pKey, /* The binary record */ + UnpackedRecord pSpace, // char *pSpace, /* Unaligned space available to hold the object */ + int szSpace /* Size of pSpace[] in bytes */ + ) { + byte[] aKey = pKey; + UnpackedRecord p; /* The unpacked record that we will return */ + int nByte; /* Memory space needed to hold p, in bytes */ + int d; + u32 idx; + int u; /* Unsigned loop counter */ + int szHdr = 0; + Mem pMem; + int nOff; /* Increase pSpace by this much to 8-byte align it */ + + /* + ** We want to shift the pointer pSpace up such that it is 8-byte aligned. + ** Thus, we need to calculate a value, nOff, between 0 and 7, to shift + ** it by. If pSpace is already 8-byte aligned, nOff should be zero. + */ + //nOff = ( 8 - ( SQLITE_PTR_TO_INT( pSpace ) & 7 ) ) & 7; + //pSpace += nOff; + //szSpace -= nOff; + //nByte = ROUND8( sizeof( UnpackedRecord ) ) + sizeof( Mem ) * ( pKeyInfo->nField + 1 ); + //if ( nByte > szSpace) + //{ + //var p = new UnpackedRecord();//sqlite3DbMallocRaw(pKeyInfo.db, nByte); + // if ( p == null ) return null; + // p.flags = UNPACKED_NEED_FREE | UNPACKED_NEED_DESTROY; + //} + //else { - pMem.flags = MEM_Str | MEM_Ephem; - pMem.z = Encoding.UTF8.GetString( buf, 0, len );//memcpy( buf, pMem.z, len ); - pMem.n = pMem.z.Length;// len; - pMem.zBLOB = null; + p = pSpace;//(UnpackedRecord)pSpace; + p.flags = UNPACKED_NEED_DESTROY; } - else - { - pMem.flags = MEM_Blob | MEM_Ephem; - pMem.zBLOB = sqlite3Malloc( len ); - buf.CopyTo( pMem.zBLOB, 0 ); - pMem.n = len;// len; - pMem.z = null; + p.pKeyInfo = pKeyInfo; + p.nField = (u16)(pKeyInfo.nField + 1); + //p->aMem = pMem = (Mem)&( (char)p )[ROUND8( sizeof( UnpackedRecord ) )]; + //Debug.Assert( EIGHT_BYTE_ALIGNMENT( pMem ) ); + p.aMem = new Mem[p.nField + 1]; + idx = (u32)getVarint32(aKey, 0, out szHdr);// GetVarint( aKey, szHdr ); + d = (int)szHdr; + u = 0; + while (idx < (int)szHdr && u < p.nField && d <= nKey) { + p.aMem[u] = sqlite3Malloc(p.aMem[u]); + pMem = p.aMem[u]; + u32 serial_type = 0; + + idx += (u32)getVarint32(aKey, idx, out serial_type);// GetVarint( aKey + idx, serial_type ); + pMem.enc = pKeyInfo.enc; + pMem.db = pKeyInfo.db; + /* pMem->flags = 0; // sqlite3VdbeSerialGet() will set this for us */ + //pMem.zMalloc = null; + d += (int)sqlite3VdbeSerialGet(aKey, d, serial_type, pMem); + //pMem++; + u++; } - return len; - } - } - return 0; - } - - /* - ** Given the nKey-byte encoding of a record in pKey[], parse the - ** record into a UnpackedRecord structure. Return a pointer to - ** that structure. - ** - ** The calling function might provide szSpace bytes of memory - ** space at pSpace. This space can be used to hold the returned - ** VDbeParsedRecord structure if it is large enough. If it is - ** not big enough, space is obtained from sqlite3Malloc(). - ** - ** The returned structure should be closed by a call to - ** sqlite3VdbeDeleteUnpackedRecord(). - */ - static UnpackedRecord sqlite3VdbeRecordUnpack( - KeyInfo pKeyInfo, /* Information about the record format */ - int nKey, /* Size of the binary record */ - byte[] pKey, /* The binary record */ - UnpackedRecord pSpace, // char *pSpace, /* Unaligned space available to hold the object */ - int szSpace /* Size of pSpace[] in bytes */ - ) - { - byte[] aKey = pKey; - UnpackedRecord p; /* The unpacked record that we will return */ - int nByte; /* Memory space needed to hold p, in bytes */ - int d; - u32 idx; - int u; /* Unsigned loop counter */ - int szHdr = 0; - Mem pMem; - int nOff; /* Increase pSpace by this much to 8-byte align it */ - - /* - ** We want to shift the pointer pSpace up such that it is 8-byte aligned. - ** Thus, we need to calculate a value, nOff, between 0 and 7, to shift - ** it by. If pSpace is already 8-byte aligned, nOff should be zero. - */ - //nOff = ( 8 - ( SQLITE_PTR_TO_INT( pSpace ) & 7 ) ) & 7; - //pSpace += nOff; - //szSpace -= nOff; - //nByte = ROUND8( sizeof( UnpackedRecord ) ) + sizeof( Mem ) * ( pKeyInfo->nField + 1 ); - //if ( nByte > szSpace) - //{ - //var p = new UnpackedRecord();//sqlite3DbMallocRaw(pKeyInfo.db, nByte); - // if ( p == null ) return null; - // p.flags = UNPACKED_NEED_FREE | UNPACKED_NEED_DESTROY; - //} - //else - { - p = pSpace;//(UnpackedRecord)pSpace; - p.flags = UNPACKED_NEED_DESTROY; - } - p.pKeyInfo = pKeyInfo; - p.nField = (u16)( pKeyInfo.nField + 1 ); - //p->aMem = pMem = (Mem)&( (char)p )[ROUND8( sizeof( UnpackedRecord ) )]; - //Debug.Assert( EIGHT_BYTE_ALIGNMENT( pMem ) ); - p.aMem = new Mem[p.nField + 1]; - idx = (u32)getVarint32( aKey, 0, out szHdr );// GetVarint( aKey, szHdr ); - d = (int)szHdr; - u = 0; - while ( idx < (int)szHdr && u < p.nField && d <= nKey ) - { - p.aMem[u] = sqlite3Malloc( p.aMem[u] ); - pMem = p.aMem[u]; - u32 serial_type = 0; - - idx += (u32)getVarint32( aKey, idx, out serial_type );// GetVarint( aKey + idx, serial_type ); - pMem.enc = pKeyInfo.enc; - pMem.db = pKeyInfo.db; - /* pMem->flags = 0; // sqlite3VdbeSerialGet() will set this for us */ - //pMem.zMalloc = null; - d += (int)sqlite3VdbeSerialGet( aKey, d, serial_type, pMem ); - //pMem++; - u++; - } - Debug.Assert( u <= pKeyInfo.nField + 1 ); - p.nField = (u16)u; - return p;// (void)p; - } + Debug.Assert(u <= pKeyInfo.nField + 1); + p.nField = (u16)u; + return p;// (void)p; + } - /* - ** This routine destroys a UnpackedRecord object. - */ - static void sqlite3VdbeDeleteUnpackedRecord( UnpackedRecord p ) - { + /* + ** This routine destroys a UnpackedRecord object. + */ + static void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord p) { #if SQLITE_DEBUG - int i; - Mem pMem; - Debug.Assert( p != null ); - Debug.Assert( ( p.flags & UNPACKED_NEED_DESTROY ) != 0 ); - //for ( i = 0, pMem = p->aMem ; i < p->nField ; i++, pMem++ ) - //{ - // /* The unpacked record is always constructed by the - // ** sqlite3VdbeUnpackRecord() function above, which makes all - // ** strings and blobs static. And none of the elements are - // ** ever transformed, so there is never anything to delete. - // */ - // if ( NEVER( pMem->zMalloc ) ) sqlite3VdbeMemRelease( pMem ); - //} + int i; + Mem pMem; + Debug.Assert(p != null); + Debug.Assert((p.flags & UNPACKED_NEED_DESTROY) != 0); + //for ( i = 0, pMem = p->aMem ; i < p->nField ; i++, pMem++ ) + //{ + // /* The unpacked record is always constructed by the + // ** sqlite3VdbeUnpackRecord() function above, which makes all + // ** strings and blobs static. And none of the elements are + // ** ever transformed, so there is never anything to delete. + // */ + // if ( NEVER( pMem->zMalloc ) ) sqlite3VdbeMemRelease( pMem ); + //} #endif - if ( ( p.flags & UNPACKED_NEED_FREE ) != 0 ) - { - sqlite3DbFree( p.pKeyInfo.db, ref p.aMem ); - p = null; - } - } - - /* - ** This function compares the two table rows or index records - ** specified by {nKey1, pKey1} and pPKey2. It returns a negative, zero - ** or positive integer if key1 is less than, equal to or - ** greater than key2. The {nKey1, pKey1} key must be a blob - ** created by th OP_MakeRecord opcode of the VDBE. The pPKey2 - ** key must be a parsed key such as obtained from - ** sqlite3VdbeParseRecord. - ** - ** Key1 and Key2 do not have to contain the same number of fields. - ** The key with fewer fields is usually compares less than the - ** longer key. However if the UNPACKED_INCRKEY flags in pPKey2 is set - ** and the common prefixes are equal, then key1 is less than key2. - ** Or if the UNPACKED_MATCH_PREFIX flag is set and the prefixes are - ** equal, then the keys are considered to be equal and - ** the parts beyond the common prefix are ignored. - ** - ** If the UNPACKED_IGNORE_ROWID flag is set, then the last byte of - ** the header of pKey1 is ignored. It is assumed that pKey1 is - ** an index key, and thus ends with a rowid value. The last byte - ** of the header will therefore be the serial type of the rowid: - ** one of 1, 2, 3, 4, 5, 6, 8, or 9 - the integer serial types. - ** The serial type of the final rowid will always be a single byte. - ** By ignoring this last byte of the header, we force the comparison - ** to ignore the rowid at the end of key1. - */ - - static Mem mem1 = new Mem(); - // ALTERNATE FORM for C# - static int sqlite3VdbeRecordCompare( - int nKey1, byte[] pKey1, /* Left key */ - UnpackedRecord pPKey2 /* Right key */ - ) - { - return sqlite3VdbeRecordCompare( nKey1, pKey1, 0, pPKey2 ); - } - - static int sqlite3VdbeRecordCompare( - int nKey1, byte[] pKey1, /* Left key */ - int offset, - UnpackedRecord pPKey2 /* Right key */ - ) - { - int d1; /* Offset into aKey[] of next data element */ - u32 idx1; /* Offset into aKey[] of next header element */ - u32 szHdr1; /* Number of bytes in header */ - int i = 0; - int nField; - int rc = 0; - - //byte[] aKey1 = new byte[pKey1.Length - offset]; - //Buffer.BlockCopy( pKey1, offset, aKey1, 0, aKey1.Length ); - KeyInfo pKeyInfo; - - pKeyInfo = pPKey2.pKeyInfo; - mem1.enc = pKeyInfo.enc; - mem1.db = pKeyInfo.db; - /* mem1.flags = 0; // Will be initialized by sqlite3VdbeSerialGet() */ - // VVA_ONLY( mem1.zMalloc = 0; ) /* Only needed by Debug.Assert() statements */ - - /* Compilers may complain that mem1.u.i is potentially uninitialized. - ** We could initialize it, as shown here, to silence those complaints. - ** But in fact, mem1.u.i will never actually be used uninitialized, and doing - ** the unnecessary initialization has a measurable negative performance - ** impact, since this routine is a very high runner. And so, we choose - ** to ignore the compiler warnings and leave this variable uninitialized. - */ - /* mem1.u.i = 0; // not needed, here to silence compiler warning */ - - idx1 = (u32)( ( szHdr1 = pKey1[offset] ) <= 0x7f ? 1 : getVarint32( pKey1, offset, out szHdr1 ) );// GetVarint( aKey1, szHdr1 ); - d1 = (int)szHdr1; - if ( ( pPKey2.flags & UNPACKED_IGNORE_ROWID ) != 0 ) - { - szHdr1--; - } - nField = pKeyInfo.nField; - while ( idx1 < szHdr1 && i < pPKey2.nField ) - { - u32 serial_type1; - - /* Read the serial types for the next element in each key. */ - idx1 += (u32)( ( serial_type1 = pKey1[offset + idx1] ) <= 0x7f ? 1 : getVarint32( pKey1, (uint)( offset + idx1 ), out serial_type1 ) ); //GetVarint( aKey1 + idx1, serial_type1 ); - if ( d1 <= 0 || d1 >= nKey1 && sqlite3VdbeSerialTypeLen( serial_type1 ) > 0 ) - break; - - /* Extract the values to be compared. - */ - d1 += (int)sqlite3VdbeSerialGet( pKey1, offset + d1, serial_type1, mem1 );//sqlite3VdbeSerialGet( aKey1, d1, serial_type1, mem1 ); + if ((p.flags & UNPACKED_NEED_FREE) != 0) { + sqlite3DbFree(p.pKeyInfo.db, ref p.aMem); + p = null; + } + } - /* Do the comparison + /* + ** This function compares the two table rows or index records + ** specified by {nKey1, pKey1} and pPKey2. It returns a negative, zero + ** or positive integer if key1 is less than, equal to or + ** greater than key2. The {nKey1, pKey1} key must be a blob + ** created by th OP_MakeRecord opcode of the VDBE. The pPKey2 + ** key must be a parsed key such as obtained from + ** sqlite3VdbeParseRecord. + ** + ** Key1 and Key2 do not have to contain the same number of fields. + ** The key with fewer fields is usually compares less than the + ** longer key. However if the UNPACKED_INCRKEY flags in pPKey2 is set + ** and the common prefixes are equal, then key1 is less than key2. + ** Or if the UNPACKED_MATCH_PREFIX flag is set and the prefixes are + ** equal, then the keys are considered to be equal and + ** the parts beyond the common prefix are ignored. + ** + ** If the UNPACKED_IGNORE_ROWID flag is set, then the last byte of + ** the header of pKey1 is ignored. It is assumed that pKey1 is + ** an index key, and thus ends with a rowid value. The last byte + ** of the header will therefore be the serial type of the rowid: + ** one of 1, 2, 3, 4, 5, 6, 8, or 9 - the integer serial types. + ** The serial type of the final rowid will always be a single byte. + ** By ignoring this last byte of the header, we force the comparison + ** to ignore the rowid at the end of key1. */ - rc = sqlite3MemCompare( mem1, pPKey2.aMem[i], i < nField ? pKeyInfo.aColl[i] : null ); - if ( rc != 0 ) - { - //Debug.Assert( mem1.zMalloc==null ); /* See comment below */ - - /* Invert the result if we are using DESC sort order. */ - if ( pKeyInfo.aSortOrder != null && i < nField && pKeyInfo.aSortOrder[i] != 0 ) - { - rc = -rc; - } - - /* If the PREFIX_SEARCH flag is set and all fields except the final - ** rowid field were equal, then clear the PREFIX_SEARCH flag and set - ** pPKey2->rowid to the value of the rowid field in (pKey1, nKey1). - ** This is used by the OP_IsUnique opcode. - */ - if ( ( pPKey2.flags & UNPACKED_PREFIX_SEARCH ) != 0 && i == ( pPKey2.nField - 1 ) ) - { - Debug.Assert( idx1 == szHdr1 && rc != 0 ); - Debug.Assert( ( mem1.flags & MEM_Int ) != 0 ); - pPKey2.flags = (ushort)( pPKey2.flags & ~UNPACKED_PREFIX_SEARCH ); - pPKey2.rowid = mem1.u.i; - } - - return rc; - } - i++; - } - /* No memory allocation is ever used on mem1. Prove this using - ** the following Debug.Assert(). If the Debug.Assert() fails, it indicates a - ** memory leak and a need to call sqlite3VdbeMemRelease(&mem1). - */ - //Debug.Assert( mem1.zMalloc==null ); - - /* rc==0 here means that one of the keys ran out of fields and - ** all the fields up to that point were equal. If the UNPACKED_INCRKEY - ** flag is set, then break the tie by treating key2 as larger. - ** If the UPACKED_PREFIX_MATCH flag is set, then keys with common prefixes - ** are considered to be equal. Otherwise, the longer key is the - ** larger. As it happens, the pPKey2 will always be the longer - ** if there is a difference. - */ - Debug.Assert( rc == 0 ); - if ( ( pPKey2.flags & UNPACKED_INCRKEY ) != 0 ) - { - rc = -1; - } - else if ( ( pPKey2.flags & UNPACKED_PREFIX_MATCH ) != 0 ) - { - /* Leave rc==0 */ - } - else if ( idx1 < szHdr1 ) - { - rc = 1; - } - return rc; - } + static Mem mem1 = new Mem(); + // ALTERNATE FORM for C# + static int sqlite3VdbeRecordCompare( + int nKey1, byte[] pKey1, /* Left key */ + UnpackedRecord pPKey2 /* Right key */ + ) { + return sqlite3VdbeRecordCompare(nKey1, pKey1, 0, pPKey2); + } + + static int sqlite3VdbeRecordCompare( + int nKey1, byte[] pKey1, /* Left key */ + int offset, + UnpackedRecord pPKey2 /* Right key */ + ) { + int d1; /* Offset into aKey[] of next data element */ + u32 idx1; /* Offset into aKey[] of next header element */ + u32 szHdr1; /* Number of bytes in header */ + int i = 0; + int nField; + int rc = 0; + + //byte[] aKey1 = new byte[pKey1.Length - offset]; + //Buffer.BlockCopy( pKey1, offset, aKey1, 0, aKey1.Length ); + KeyInfo pKeyInfo; + + pKeyInfo = pPKey2.pKeyInfo; + mem1.enc = pKeyInfo.enc; + mem1.db = pKeyInfo.db; + /* mem1.flags = 0; // Will be initialized by sqlite3VdbeSerialGet() */ + // VVA_ONLY( mem1.zMalloc = 0; ) /* Only needed by Debug.Assert() statements */ + + /* Compilers may complain that mem1.u.i is potentially uninitialized. + ** We could initialize it, as shown here, to silence those complaints. + ** But in fact, mem1.u.i will never actually be used uninitialized, and doing + ** the unnecessary initialization has a measurable negative performance + ** impact, since this routine is a very high runner. And so, we choose + ** to ignore the compiler warnings and leave this variable uninitialized. + */ + /* mem1.u.i = 0; // not needed, here to silence compiler warning */ + + idx1 = (u32)((szHdr1 = pKey1[offset]) <= 0x7f ? 1 : getVarint32(pKey1, offset, out szHdr1));// GetVarint( aKey1, szHdr1 ); + d1 = (int)szHdr1; + if ((pPKey2.flags & UNPACKED_IGNORE_ROWID) != 0) { + szHdr1--; + } + nField = pKeyInfo.nField; + while (idx1 < szHdr1 && i < pPKey2.nField) { + u32 serial_type1; + + /* Read the serial types for the next element in each key. */ + idx1 += (u32)((serial_type1 = pKey1[offset + idx1]) <= 0x7f ? 1 : getVarint32(pKey1, (uint)(offset + idx1), out serial_type1)); //GetVarint( aKey1 + idx1, serial_type1 ); + if (d1 <= 0 || d1 >= nKey1 && sqlite3VdbeSerialTypeLen(serial_type1) > 0) + break; + + /* Extract the values to be compared. + */ + d1 += (int)sqlite3VdbeSerialGet(pKey1, offset + d1, serial_type1, mem1);//sqlite3VdbeSerialGet( aKey1, d1, serial_type1, mem1 ); + + /* Do the comparison + */ + rc = sqlite3MemCompare(mem1, pPKey2.aMem[i], i < nField ? pKeyInfo.aColl[i] : null); + if (rc != 0) { + //Debug.Assert( mem1.zMalloc==null ); /* See comment below */ + + /* Invert the result if we are using DESC sort order. */ + if (pKeyInfo.aSortOrder != null && i < nField && pKeyInfo.aSortOrder[i] != 0) { + rc = -rc; + } + + /* If the PREFIX_SEARCH flag is set and all fields except the final + ** rowid field were equal, then clear the PREFIX_SEARCH flag and set + ** pPKey2->rowid to the value of the rowid field in (pKey1, nKey1). + ** This is used by the OP_IsUnique opcode. + */ + if ((pPKey2.flags & UNPACKED_PREFIX_SEARCH) != 0 && i == (pPKey2.nField - 1)) { + Debug.Assert(idx1 == szHdr1 && rc != 0); + Debug.Assert((mem1.flags & MEM_Int) != 0); + pPKey2.flags = (ushort)(pPKey2.flags & ~UNPACKED_PREFIX_SEARCH); + pPKey2.rowid = mem1.u.i; + } + + return rc; + } + i++; + } - /* - ** pCur points at an index entry created using the OP_MakeRecord opcode. - ** Read the rowid (the last field in the record) and store it in *rowid. - ** Return SQLITE_OK if everything works, or an error code otherwise. - ** - ** pCur might be pointing to text obtained from a corrupt database file. - ** So the content cannot be trusted. Do appropriate checks on the content. - */ - static int sqlite3VdbeIdxRowid( sqlite3 db, BtCursor pCur, ref i64 rowid ) - { - i64 nCellKey = 0; - int rc; - u32 szHdr = 0; /* Size of the header */ - u32 typeRowid = 0; /* Serial type of the rowid */ - u32 lenRowid; /* Size of the rowid */ - Mem m = null; - Mem v = null; - v = sqlite3Malloc( v ); - UNUSED_PARAMETER( db ); - - /* Get the size of the index entry. Only indices entries of less - ** than 2GiB are support - anything large must be database corruption. - ** Any corruption is detected in sqlite3BtreeParseCellPtr(), though, so - ** this code can safely assume that nCellKey is 32-bits - */ - Debug.Assert( sqlite3BtreeCursorIsValid( pCur ) ); - rc = sqlite3BtreeKeySize( pCur, ref nCellKey ); - Debug.Assert( rc == SQLITE_OK ); /* pCur is always valid so KeySize cannot fail */ - Debug.Assert( ( (u32)nCellKey & SQLITE_MAX_U32 ) == (u64)nCellKey ); - - /* Read in the complete content of the index entry */ - m = sqlite3Malloc( m ); - // memset(&m, 0, sizeof(m)); - rc = sqlite3VdbeMemFromBtree( pCur, 0, (int)nCellKey, true, m ); - if ( rc != 0 ) - { - return rc; - } + /* No memory allocation is ever used on mem1. Prove this using + ** the following Debug.Assert(). If the Debug.Assert() fails, it indicates a + ** memory leak and a need to call sqlite3VdbeMemRelease(&mem1). + */ + //Debug.Assert( mem1.zMalloc==null ); + + /* rc==0 here means that one of the keys ran out of fields and + ** all the fields up to that point were equal. If the UNPACKED_INCRKEY + ** flag is set, then break the tie by treating key2 as larger. + ** If the UPACKED_PREFIX_MATCH flag is set, then keys with common prefixes + ** are considered to be equal. Otherwise, the longer key is the + ** larger. As it happens, the pPKey2 will always be the longer + ** if there is a difference. + */ + Debug.Assert(rc == 0); + if ((pPKey2.flags & UNPACKED_INCRKEY) != 0) { + rc = -1; + } else if ((pPKey2.flags & UNPACKED_PREFIX_MATCH) != 0) { + /* Leave rc==0 */ + } else if (idx1 < szHdr1) { + rc = 1; + } + return rc; + } - /* The index entry must begin with a header size */ - getVarint32( m.zBLOB, 0, out szHdr ); - testcase( szHdr == 3 ); - testcase( szHdr == m.n ); - if ( unlikely( szHdr < 3 || (int)szHdr > m.n ) ) - { - goto idx_rowid_corruption; - } + /* + ** pCur points at an index entry created using the OP_MakeRecord opcode. + ** Read the rowid (the last field in the record) and store it in *rowid. + ** Return SQLITE_OK if everything works, or an error code otherwise. + ** + ** pCur might be pointing to text obtained from a corrupt database file. + ** So the content cannot be trusted. Do appropriate checks on the content. + */ + static int sqlite3VdbeIdxRowid(sqlite3 db, BtCursor pCur, ref i64 rowid) { + i64 nCellKey = 0; + int rc; + u32 szHdr = 0; /* Size of the header */ + u32 typeRowid = 0; /* Serial type of the rowid */ + u32 lenRowid; /* Size of the rowid */ + Mem m = null; + Mem v = null; + v = sqlite3Malloc(v); + UNUSED_PARAMETER(db); + + /* Get the size of the index entry. Only indices entries of less + ** than 2GiB are support - anything large must be database corruption. + ** Any corruption is detected in sqlite3BtreeParseCellPtr(), though, so + ** this code can safely assume that nCellKey is 32-bits + */ + Debug.Assert(sqlite3BtreeCursorIsValid(pCur)); + rc = sqlite3BtreeKeySize(pCur, ref nCellKey); + Debug.Assert(rc == SQLITE_OK); /* pCur is always valid so KeySize cannot fail */ + Debug.Assert(((u32)nCellKey & SQLITE_MAX_U32) == (u64)nCellKey); + + /* Read in the complete content of the index entry */ + m = sqlite3Malloc(m); + // memset(&m, 0, sizeof(m)); + rc = sqlite3VdbeMemFromBtree(pCur, 0, (int)nCellKey, true, m); + if (rc != 0) { + return rc; + } - /* The last field of the index should be an integer - the ROWID. - ** Verify that the last entry really is an integer. */ - getVarint32( m.zBLOB, szHdr - 1, out typeRowid ); - testcase( typeRowid == 1 ); - testcase( typeRowid == 2 ); - testcase( typeRowid == 3 ); - testcase( typeRowid == 4 ); - testcase( typeRowid == 5 ); - testcase( typeRowid == 6 ); - testcase( typeRowid == 8 ); - testcase( typeRowid == 9 ); - if ( unlikely( typeRowid < 1 || typeRowid > 9 || typeRowid == 7 ) ) - { - goto idx_rowid_corruption; - } - lenRowid = (u32)sqlite3VdbeSerialTypeLen( typeRowid ); - testcase( (u32)m.n == szHdr + lenRowid ); - if ( unlikely( (u32)m.n < szHdr + lenRowid ) ) - { - goto idx_rowid_corruption; - } + /* The index entry must begin with a header size */ + getVarint32(m.zBLOB, 0, out szHdr); + testcase(szHdr == 3); + testcase(szHdr == m.n); + if (unlikely(szHdr < 3 || (int)szHdr > m.n)) { + goto idx_rowid_corruption; + } - /* Fetch the integer off the end of the index record */ - sqlite3VdbeSerialGet( m.zBLOB, (int)( m.n - lenRowid ), typeRowid, v ); - rowid = v.u.i; - sqlite3VdbeMemRelease( m ); - return SQLITE_OK; - - /* Jump here if database corruption is detected after m has been - ** allocated. Free the m object and return SQLITE_CORRUPT. */ -idx_rowid_corruption: - //testcase( m.zMalloc != 0 ); - sqlite3VdbeMemRelease( m ); - return SQLITE_CORRUPT_BKPT(); - } + /* The last field of the index should be an integer - the ROWID. + ** Verify that the last entry really is an integer. */ + getVarint32(m.zBLOB, szHdr - 1, out typeRowid); + testcase(typeRowid == 1); + testcase(typeRowid == 2); + testcase(typeRowid == 3); + testcase(typeRowid == 4); + testcase(typeRowid == 5); + testcase(typeRowid == 6); + testcase(typeRowid == 8); + testcase(typeRowid == 9); + if (unlikely(typeRowid < 1 || typeRowid > 9 || typeRowid == 7)) { + goto idx_rowid_corruption; + } + lenRowid = (u32)sqlite3VdbeSerialTypeLen(typeRowid); + testcase((u32)m.n == szHdr + lenRowid); + if (unlikely((u32)m.n < szHdr + lenRowid)) { + goto idx_rowid_corruption; + } - /* - ** Compare the key of the index entry that cursor pC is pointing to against - ** the key string in pUnpacked. Write into *pRes a number - ** that is negative, zero, or positive if pC is less than, equal to, - ** or greater than pUnpacked. Return SQLITE_OK on success. - ** - ** pUnpacked is either created without a rowid or is truncated so that it - ** omits the rowid at the end. The rowid at the end of the index entry - ** is ignored as well. Hence, this routine only compares the prefixes - ** of the keys prior to the final rowid, not the entire key. - */ - static int sqlite3VdbeIdxKeyCompare( - VdbeCursor pC, /* The cursor to compare against */ - UnpackedRecord pUnpacked, /* Unpacked version of key to compare against */ - ref int res /* Write the comparison result here */ - ) - { - i64 nCellKey = 0; - int rc; - BtCursor pCur = pC.pCursor; - Mem m = null; - - Debug.Assert( sqlite3BtreeCursorIsValid( pCur ) ); - rc = sqlite3BtreeKeySize( pCur, ref nCellKey ); - Debug.Assert( rc == SQLITE_OK ); /* pCur is always valid so KeySize cannot fail */ - /* nCellKey will always be between 0 and 0xffffffff because of the say - ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */ - if ( nCellKey <= 0 || nCellKey > 0x7fffffff ) - { - res = 0; - return SQLITE_CORRUPT_BKPT(); - } + /* Fetch the integer off the end of the index record */ + sqlite3VdbeSerialGet(m.zBLOB, (int)(m.n - lenRowid), typeRowid, v); + rowid = v.u.i; + sqlite3VdbeMemRelease(m); + return SQLITE_OK; + + /* Jump here if database corruption is detected after m has been + ** allocated. Free the m object and return SQLITE_CORRUPT. */ + idx_rowid_corruption: + //testcase( m.zMalloc != 0 ); + sqlite3VdbeMemRelease(m); + return SQLITE_CORRUPT_BKPT(); + } + + /* + ** Compare the key of the index entry that cursor pC is pointing to against + ** the key string in pUnpacked. Write into *pRes a number + ** that is negative, zero, or positive if pC is less than, equal to, + ** or greater than pUnpacked. Return SQLITE_OK on success. + ** + ** pUnpacked is either created without a rowid or is truncated so that it + ** omits the rowid at the end. The rowid at the end of the index entry + ** is ignored as well. Hence, this routine only compares the prefixes + ** of the keys prior to the final rowid, not the entire key. + */ + static int sqlite3VdbeIdxKeyCompare( + VdbeCursor pC, /* The cursor to compare against */ + UnpackedRecord pUnpacked, /* Unpacked version of key to compare against */ + ref int res /* Write the comparison result here */ + ) { + i64 nCellKey = 0; + int rc; + BtCursor pCur = pC.pCursor; + Mem m = null; + + Debug.Assert(sqlite3BtreeCursorIsValid(pCur)); + rc = sqlite3BtreeKeySize(pCur, ref nCellKey); + Debug.Assert(rc == SQLITE_OK); /* pCur is always valid so KeySize cannot fail */ + /* nCellKey will always be between 0 and 0xffffffff because of the say + ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */ + if (nCellKey <= 0 || nCellKey > 0x7fffffff) { + res = 0; + return SQLITE_CORRUPT_BKPT(); + } - m = sqlite3Malloc( m ); - // memset(&m, 0, sizeof(m)); - rc = sqlite3VdbeMemFromBtree( pC.pCursor, 0, (int)nCellKey, true, m ); - if ( rc != 0 ) - { - return rc; - } - Debug.Assert( ( pUnpacked.flags & UNPACKED_IGNORE_ROWID ) != 0 ); - res = sqlite3VdbeRecordCompare( m.n, m.zBLOB, pUnpacked ); - sqlite3VdbeMemRelease( m ); - return SQLITE_OK; - } + m = sqlite3Malloc(m); + // memset(&m, 0, sizeof(m)); + rc = sqlite3VdbeMemFromBtree(pC.pCursor, 0, (int)nCellKey, true, m); + if (rc != 0) { + return rc; + } + Debug.Assert((pUnpacked.flags & UNPACKED_IGNORE_ROWID) != 0); + res = sqlite3VdbeRecordCompare(m.n, m.zBLOB, pUnpacked); + sqlite3VdbeMemRelease(m); + return SQLITE_OK; + } - /* - ** This routine sets the value to be returned by subsequent calls to - ** sqlite3_changes() on the database handle 'db'. - */ - static void sqlite3VdbeSetChanges( sqlite3 db, int nChange ) - { - Debug.Assert( sqlite3_mutex_held( db.mutex ) ); - db.nChange = nChange; - db.nTotalChange += nChange; - } + /* + ** This routine sets the value to be returned by subsequent calls to + ** sqlite3_changes() on the database handle 'db'. + */ + static void sqlite3VdbeSetChanges(sqlite3 db, int nChange) { + Debug.Assert(sqlite3_mutex_held(db.mutex)); + db.nChange = nChange; + db.nTotalChange += nChange; + } - /* - ** Set a flag in the vdbe to update the change counter when it is finalised - ** or reset. - */ - static void sqlite3VdbeCountChanges( Vdbe v ) - { - v.changeCntOn = true; - } + /* + ** Set a flag in the vdbe to update the change counter when it is finalised + ** or reset. + */ + static void sqlite3VdbeCountChanges(Vdbe v) { + v.changeCntOn = true; + } - /* - ** Mark every prepared statement associated with a database connection - ** as expired. - ** - ** An expired statement means that recompilation of the statement is - ** recommend. Statements expire when things happen that make their - ** programs obsolete. Removing user-defined functions or collating - ** sequences, or changing an authorization function are the types of - ** things that make prepared statements obsolete. - */ - static void sqlite3ExpirePreparedStatements( sqlite3 db ) - { - Vdbe p; - for ( p = db.pVdbe; p != null; p = p.pNext ) - { - p.expired = true; - } - } + /* + ** Mark every prepared statement associated with a database connection + ** as expired. + ** + ** An expired statement means that recompilation of the statement is + ** recommend. Statements expire when things happen that make their + ** programs obsolete. Removing user-defined functions or collating + ** sequences, or changing an authorization function are the types of + ** things that make prepared statements obsolete. + */ + static void sqlite3ExpirePreparedStatements(sqlite3 db) { + Vdbe p; + for (p = db.pVdbe; p != null; p = p.pNext) { + p.expired = true; + } + } - /* - ** Return the database associated with the Vdbe. - */ - static sqlite3 sqlite3VdbeDb( Vdbe v ) - { - return v.db; - } - /* - ** Return a pointer to an sqlite3_value structure containing the value bound - ** parameter iVar of VM v. Except, if the value is an SQL NULL, return - ** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_* - ** constants) to the value before returning it. - ** - ** The returned value must be freed by the caller using sqlite3ValueFree(). - */ - static sqlite3_value sqlite3VdbeGetValue( Vdbe v, int iVar, u8 aff ) - { - Debug.Assert( iVar > 0 ); - if ( v != null ) - { - Mem pMem = v.aVar[iVar - 1]; - if ( 0 == ( pMem.flags & MEM_Null ) ) - { - sqlite3_value pRet = sqlite3ValueNew( v.db ); - if ( pRet != null ) - { - sqlite3VdbeMemCopy( (Mem)pRet, pMem ); - sqlite3ValueApplyAffinity( pRet, (char)aff, SQLITE_UTF8 ); - sqlite3VdbeMemStoreType( (Mem)pRet ); - } - return pRet; + /* + ** Return the database associated with the Vdbe. + */ + static sqlite3 sqlite3VdbeDb(Vdbe v) { + return v.db; + } + /* + ** Return a pointer to an sqlite3_value structure containing the value bound + ** parameter iVar of VM v. Except, if the value is an SQL NULL, return + ** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_* + ** constants) to the value before returning it. + ** + ** The returned value must be freed by the caller using sqlite3ValueFree(). + */ + static sqlite3_value sqlite3VdbeGetValue(Vdbe v, int iVar, u8 aff) { + Debug.Assert(iVar > 0); + if (v != null) { + Mem pMem = v.aVar[iVar - 1]; + if (0 == (pMem.flags & MEM_Null)) { + sqlite3_value pRet = sqlite3ValueNew(v.db); + if (pRet != null) { + sqlite3VdbeMemCopy((Mem)pRet, pMem); + sqlite3ValueApplyAffinity(pRet, (char)aff, SQLITE_UTF8); + sqlite3VdbeMemStoreType((Mem)pRet); + } + return pRet; + } + } + return null; } - } - return null; - } - /* - ** Configure SQL variable iVar so that binding a new value to it signals - ** to sqlite3_reoptimize() that re-preparing the statement may result - ** in a better query plan. - */ - static void sqlite3VdbeSetVarmask( Vdbe v, int iVar ) - { - Debug.Assert( iVar > 0 ); - if ( iVar > 32 ) - { - v.expmask = 0xffffffff; - } - else - { - v.expmask |= ( (u32)1 << ( iVar - 1 ) ); - } + /* + ** Configure SQL variable iVar so that binding a new value to it signals + ** to sqlite3_reoptimize() that re-preparing the statement may result + ** in a better query plan. + */ + static void sqlite3VdbeSetVarmask(Vdbe v, int iVar) { + Debug.Assert(iVar > 0); + if (iVar > 32) { + v.expmask = 0xffffffff; + } else { + v.expmask |= ((u32)1 << (iVar - 1)); + } + } } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/vdbeblob_c.cs b/Src/IronPython.SQLite/c#sqlite/vdbeblob_c.cs index 0e6f7abb6..33abe5c6a 100644 --- a/Src/IronPython.SQLite/c#sqlite/vdbeblob_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/vdbeblob_c.cs @@ -1,34 +1,28 @@ -using System.Diagnostics; - -namespace Community.CsharpSqlite -{ - using sqlite3_stmt = Sqlite3.Vdbe; - - public partial class Sqlite3 - { - /* - ** 2007 May 1 - ** - ** 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 contains code used to implement incremental BLOB I/O. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include "vdbeInt.h" +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2007 May 1 + ** + ** 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 contains code used to implement incremental BLOB I/O. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include "vdbeInt.h" #if !SQLITE_OMIT_INCRBLOB /* @@ -399,5 +393,5 @@ int sqlite3_blob_bytes(sqlite3_blob *pBlob){ } #endif // * #if !SQLITE_OMIT_INCRBLOB */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/vdbemem_c.cs b/Src/IronPython.SQLite/c#sqlite/vdbemem_c.cs index e95b8cfd3..280460dce 100644 --- a/Src/IronPython.SQLite/c#sqlite/vdbemem_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/vdbemem_c.cs @@ -3,83 +3,79 @@ using System.Text; using i64 = System.Int64; -using u8 = System.Byte; using u16 = System.UInt16; using u32 = System.UInt32; +using u8 = System.Byte; -namespace Community.CsharpSqlite -{ - using sqlite3_value = Sqlite3.Mem; - using System.Globalization; - - public partial class Sqlite3 - { - /* - ** 2004 May 26 - ** - ** 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 contains code use to manipulate "Mem" structure. A "Mem" - ** stores a single value in the VDBE. Mem is an opaque structure visible - ** only within the VDBE. Interface routines refer to a Mem using the - ** name sqlite_value - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include "vdbeInt.h" +namespace Community.CsharpSqlite { + using System.Globalization; + + using sqlite3_value = Sqlite3.Mem; + + public partial class Sqlite3 { + /* + ** 2004 May 26 + ** + ** 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 contains code use to manipulate "Mem" structure. A "Mem" + ** stores a single value in the VDBE. Mem is an opaque structure visible + ** only within the VDBE. Interface routines refer to a Mem using the + ** name sqlite_value + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include "vdbeInt.h" - /* - ** Call sqlite3VdbeMemExpandBlob() on the supplied value (type Mem*) - ** P if required. - */ - //#define expandBlob(P) (((P)->flags&MEM_Zero)?sqlite3VdbeMemExpandBlob(P):0) - static void expandBlob( Mem P ) - { - if ( ( P.flags & MEM_Zero ) != 0 ) - sqlite3VdbeMemExpandBlob( P ); - } // TODO -- Convert to inline for speed - - /* - ** If pMem is an object with a valid string representation, this routine - ** ensures the internal encoding for the string representation is - ** 'desiredEnc', one of SQLITE_UTF8, SQLITE_UTF16LE or SQLITE_UTF16BE. - ** - ** If pMem is not a string object, or the encoding of the string - ** representation is already stored using the requested encoding, then this - ** routine is a no-op. - ** - ** SQLITE_OK is returned if the conversion is successful (or not required). - ** SQLITE_NOMEM may be returned if a malloc() fails during conversion - ** between formats. - */ - static int sqlite3VdbeChangeEncoding( Mem pMem, int desiredEnc ) - { - int rc; - Debug.Assert( ( pMem.flags & MEM_RowSet ) == 0 ); - Debug.Assert( desiredEnc == SQLITE_UTF8 || desiredEnc == SQLITE_UTF16LE - || desiredEnc == SQLITE_UTF16BE ); - if ( ( pMem.flags & MEM_Str ) == 0 || pMem.enc == desiredEnc ) - { - if ( String.IsNullOrEmpty( pMem.z ) && pMem.zBLOB != null ) - pMem.z = Encoding.UTF8.GetString( pMem.zBLOB, 0, pMem.zBLOB.Length ); - return SQLITE_OK; - } - Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); -#if SQLITE_OMIT_UTF16 - return SQLITE_ERROR; + /* + ** Call sqlite3VdbeMemExpandBlob() on the supplied value (type Mem*) + ** P if required. + */ + //#define expandBlob(P) (((P)->flags&MEM_Zero)?sqlite3VdbeMemExpandBlob(P):0) + static void expandBlob(Mem P) { + if ((P.flags & MEM_Zero) != 0) + sqlite3VdbeMemExpandBlob(P); + } // TODO -- Convert to inline for speed + + /* + ** If pMem is an object with a valid string representation, this routine + ** ensures the internal encoding for the string representation is + ** 'desiredEnc', one of SQLITE_UTF8, SQLITE_UTF16LE or SQLITE_UTF16BE. + ** + ** If pMem is not a string object, or the encoding of the string + ** representation is already stored using the requested encoding, then this + ** routine is a no-op. + ** + ** SQLITE_OK is returned if the conversion is successful (or not required). + ** SQLITE_NOMEM may be returned if a malloc() fails during conversion + ** between formats. + */ + static int sqlite3VdbeChangeEncoding(Mem pMem, int desiredEnc) { + int rc; + Debug.Assert((pMem.flags & MEM_RowSet) == 0); + Debug.Assert(desiredEnc == SQLITE_UTF8 || desiredEnc == SQLITE_UTF16LE + || desiredEnc == SQLITE_UTF16BE); + if ((pMem.flags & MEM_Str) == 0 || pMem.enc == desiredEnc) { + if (String.IsNullOrEmpty(pMem.z) && pMem.zBLOB != null) + pMem.z = Encoding.UTF8.GetString(pMem.zBLOB, 0, pMem.zBLOB.Length); + return SQLITE_OK; + } + Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); +#if SQLITE_OMIT_UTF16 + return SQLITE_ERROR; #else /* MemTranslate() may return SQLITE_OK or SQLITE_NOMEM. If NOMEM is returned, @@ -91,106 +87,97 @@ static int sqlite3VdbeChangeEncoding( Mem pMem, int desiredEnc ) Debug.Assert(rc==SQLITE_NOMEM || pMem.enc==desiredEnc); return rc; #endif - } + } - /* - ** Make sure pMem.z points to a writable allocation of at least - ** n bytes. - ** - ** If the memory cell currently contains string or blob data - ** and the third argument passed to this function is true, the - ** current content of the cell is preserved. Otherwise, it may - ** be discarded. - ** - ** This function sets the MEM_Dyn flag and clears any xDel callback. - ** It also clears MEM_Ephem and MEM_Static. If the preserve flag is - ** not set, Mem.n is zeroed. - */ - static int sqlite3VdbeMemGrow( Mem pMem, int n, int preserve ) - { - // TODO -- What do we want to do about this routine? - //Debug.Assert( 1 >= - // ((pMem.zMalloc !=null )? 1 : 0) + //&& pMem.zMalloc==pMem.z) ? 1 : 0) + - // (((pMem.flags & MEM_Dyn)!=0 && pMem.xDel!=null) ? 1 : 0) + - // ((pMem.flags & MEM_Ephem)!=0 ? 1 : 0) + - // ((pMem.flags & MEM_Static)!=0 ? 1 : 0) - //); - //assert( (pMem->flags&MEM_RowSet)==0 ); - - //if( n<32 ) n = 32; - //if( sqlite3DbMallocSize(pMem->db, pMem.zMalloc)db,ref pMem.zMalloc); - pMem.z = "";// sqlite3DbMallocRaw( pMem.db, n ); - } - //} - - // if( pMem->z && preserve && pMem->zMalloc && pMem->z!=pMem->zMalloc ){ - // memcpy(pMem.zMalloc, pMem.z, pMem.n); - //} - if ( ( pMem.flags & MEM_Dyn ) != 0 && pMem.xDel != null ) - { - pMem.xDel( ref pMem.z ); - } - - // TODO --pMem.z = pMem.zMalloc; - if ( pMem.z == null ) - { - pMem.flags = MEM_Null; - } - else - { - pMem.flags = (u16)( pMem.flags & ~( MEM_Ephem | MEM_Static ) ); - } - pMem.xDel = null; - return pMem.z != null ? SQLITE_OK : SQLITE_NOMEM; - } + /* + ** Make sure pMem.z points to a writable allocation of at least + ** n bytes. + ** + ** If the memory cell currently contains string or blob data + ** and the third argument passed to this function is true, the + ** current content of the cell is preserved. Otherwise, it may + ** be discarded. + ** + ** This function sets the MEM_Dyn flag and clears any xDel callback. + ** It also clears MEM_Ephem and MEM_Static. If the preserve flag is + ** not set, Mem.n is zeroed. + */ + static int sqlite3VdbeMemGrow(Mem pMem, int n, int preserve) { + // TODO -- What do we want to do about this routine? + //Debug.Assert( 1 >= + // ((pMem.zMalloc !=null )? 1 : 0) + //&& pMem.zMalloc==pMem.z) ? 1 : 0) + + // (((pMem.flags & MEM_Dyn)!=0 && pMem.xDel!=null) ? 1 : 0) + + // ((pMem.flags & MEM_Ephem)!=0 ? 1 : 0) + + // ((pMem.flags & MEM_Static)!=0 ? 1 : 0) + //); + //assert( (pMem->flags&MEM_RowSet)==0 ); + + //if( n<32 ) n = 32; + //if( sqlite3DbMallocSize(pMem->db, pMem.zMalloc)db,ref pMem.zMalloc); + pMem.z = "";// sqlite3DbMallocRaw( pMem.db, n ); + } + //} + + // if( pMem->z && preserve && pMem->zMalloc && pMem->z!=pMem->zMalloc ){ + // memcpy(pMem.zMalloc, pMem.z, pMem.n); + //} + if ((pMem.flags & MEM_Dyn) != 0 && pMem.xDel != null) { + pMem.xDel(ref pMem.z); + } + + // TODO --pMem.z = pMem.zMalloc; + if (pMem.z == null) { + pMem.flags = MEM_Null; + } else { + pMem.flags = (u16)(pMem.flags & ~(MEM_Ephem | MEM_Static)); + } + pMem.xDel = null; + return pMem.z != null ? SQLITE_OK : SQLITE_NOMEM; + } - /* - ** Make the given Mem object MEM_Dyn. In other words, make it so - ** that any TEXT or BLOB content is stored in memory obtained from - ** malloc(). In this way, we know that the memory is safe to be - ** overwritten or altered. - ** - ** Return SQLITE_OK on success or SQLITE_NOMEM if malloc fails. - */ - static int sqlite3VdbeMemMakeWriteable( Mem pMem ) - { - int f; - Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); - Debug.Assert( ( pMem.flags & MEM_RowSet ) == 0 ); - expandBlob( pMem ); - f = pMem.flags; - if ( ( f & ( MEM_Str | MEM_Blob ) ) != 0 ) // TODO -- && pMem.z != pMem.zMalloc ) - { - if ( sqlite3VdbeMemGrow( pMem, pMem.n + 2, 1 ) != 0 ) - //{ - // return SQLITE_NOMEM; - //} - //pMem.z[pMem->n] = 0; - //pMem.z[pMem->n + 1] = 0; - pMem.flags |= MEM_Term; + /* + ** Make the given Mem object MEM_Dyn. In other words, make it so + ** that any TEXT or BLOB content is stored in memory obtained from + ** malloc(). In this way, we know that the memory is safe to be + ** overwritten or altered. + ** + ** Return SQLITE_OK on success or SQLITE_NOMEM if malloc fails. + */ + static int sqlite3VdbeMemMakeWriteable(Mem pMem) { + int f; + Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); + Debug.Assert((pMem.flags & MEM_RowSet) == 0); + expandBlob(pMem); + f = pMem.flags; + if ((f & (MEM_Str | MEM_Blob)) != 0) // TODO -- && pMem.z != pMem.zMalloc ) + { + if (sqlite3VdbeMemGrow(pMem, pMem.n + 2, 1) != 0) + //{ + // return SQLITE_NOMEM; + //} + //pMem.z[pMem->n] = 0; + //pMem.z[pMem->n + 1] = 0; + pMem.flags |= MEM_Term; #if SQLITE_DEBUG - pMem.pScopyFrom = null; + pMem.pScopyFrom = null; #endif - } + } - return SQLITE_OK; - } - /* - ** If the given Mem* has a zero-filled tail, turn it into an ordinary - ** blob stored in dynamically allocated space. - */ + return SQLITE_OK; + } + /* + ** If the given Mem* has a zero-filled tail, turn it into an ordinary + ** blob stored in dynamically allocated space. + */ #if !SQLITE_OMIT_INCRBLOB static int sqlite3VdbeMemExpandBlob( Mem pMem ) { @@ -232,861 +219,740 @@ static int sqlite3VdbeMemExpandBlob( Mem pMem ) #endif - /* -** Make sure the given Mem is \u0000 terminated. -*/ - static int sqlite3VdbeMemNulTerminate( Mem pMem ) - { - Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); - if ( ( pMem.flags & MEM_Term ) != 0 || ( pMem.flags & MEM_Str ) == 0 ) - { - return SQLITE_OK; /* Nothing to do */ - } - //if ( pMem.n != 0 && sqlite3VdbeMemGrow( pMem, pMem.n + 2, 1 ) != 0 ) - //{ - // return SQLITE_NOMEM; - //} - // pMem.z[pMem->n] = 0; - // pMem.z[pMem->n+1] = 0; - if ( pMem.z != null && pMem.n < pMem.z.Length ) - pMem.z = pMem.z.Substring( 0, pMem.n ); - pMem.flags |= MEM_Term; - return SQLITE_OK; - } - - /* - ** Add MEM_Str to the set of representations for the given Mem. Numbers - ** are converted using sqlite3_snprintf(). Converting a BLOB to a string - ** is a no-op. - ** - ** Existing representations MEM_Int and MEM_Real are *not* invalidated. - ** - ** A MEM_Null value will never be passed to this function. This function is - ** used for converting values to text for returning to the user (i.e. via - ** sqlite3_value_text()), or for ensuring that values to be used as btree - ** keys are strings. In the former case a NULL pointer is returned the - ** user and the later is an internal programming error. - */ - static int sqlite3VdbeMemStringify( Mem pMem, int enc ) - { - int rc = SQLITE_OK; - int fg = pMem.flags; - const int nByte = 32; - - Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); - Debug.Assert( ( fg & MEM_Zero ) == 0 ); - Debug.Assert( ( fg & ( MEM_Str | MEM_Blob ) ) == 0 ); - Debug.Assert( ( fg & ( MEM_Int | MEM_Real ) ) != 0 ); - Debug.Assert( ( pMem.flags & MEM_RowSet ) == 0 ); - //assert( EIGHT_BYTE_ALIGNMENT(pMem) ); - - if ( sqlite3VdbeMemGrow( pMem, nByte, 0 ) != 0 ) - { - return SQLITE_NOMEM; - } - - /* For a Real or Integer, use sqlite3_snprintf() to produce the UTF-8 - ** string representation of the value. Then, if the required encoding - ** is UTF-16le or UTF-16be do a translation. - ** - ** FIX ME: It would be better if sqlite3_snprintf() could do UTF-16. - */ - if ( ( fg & MEM_Int ) != 0 ) - { - pMem.z = pMem.u.i.ToString(); //sqlite3_snprintf(nByte, pMem.z, "%lld", pMem->u.i); - } - else - { - Debug.Assert( ( fg & MEM_Real ) != 0 ); - if ( Double.IsNegativeInfinity( pMem.r ) ) - pMem.z = "-Inf"; - else if ( Double.IsInfinity( pMem.r ) ) - pMem.z = "Inf"; - else if ( Double.IsPositiveInfinity( pMem.r ) ) - pMem.z = "+Inf"; - else if ( pMem.r.ToString( CultureInfo.InvariantCulture ).Contains( "." ) ) - pMem.z = pMem.r.ToString( CultureInfo.InvariantCulture ).ToLowerInvariant();//sqlite3_snprintf(nByte, pMem.z, "%!.15g", pMem->r); - else - pMem.z = pMem.r.ToString( CultureInfo.InvariantCulture) + ".0"; - } - pMem.n = sqlite3Strlen30( pMem.z ); - pMem.enc = SQLITE_UTF8; - pMem.flags |= MEM_Str | MEM_Term; - sqlite3VdbeChangeEncoding( pMem, enc ); - return rc; - } - - /* - ** Memory cell pMem contains the context of an aggregate function. - ** This routine calls the finalize method for that function. The - ** result of the aggregate is stored back into pMem. - ** - ** Return SQLITE_ERROR if the finalizer reports an error. SQLITE_OK - ** otherwise. - */ - static int sqlite3VdbeMemFinalize( Mem pMem, FuncDef pFunc ) - { - int rc = SQLITE_OK; - if ( ALWAYS( pFunc != null && pFunc.xFinalize != null ) ) - { - sqlite3_context ctx = new sqlite3_context(); - Debug.Assert( ( pMem.flags & MEM_Null ) != 0 || pFunc == pMem.u.pDef ); - Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); - //memset(&ctx, 0, sizeof(ctx)); - ctx.s.flags = MEM_Null; - ctx.s.db = pMem.db; - ctx.pMem = pMem; - ctx.pFunc = pFunc; - pFunc.xFinalize( ctx ); /* IMP: R-24505-23230 */ - Debug.Assert( 0 == ( pMem.flags & MEM_Dyn ) && pMem.xDel == null ); - sqlite3DbFree( pMem.db, ref pMem.zBLOB );//zMalloc ); - ctx.s.CopyTo( ref pMem );//memcpy(pMem, &ctx.s, sizeof(ctx.s)); - rc = ctx.isError; - } - return rc; - } - - /* - ** If the memory cell contains a string value that must be freed by - ** invoking an external callback, free it now. Calling this function - ** does not free any Mem.zMalloc buffer. + /* + ** Make sure the given Mem is \u0000 terminated. */ - static void sqlite3VdbeMemReleaseExternal( Mem p ) - { - Debug.Assert( p.db == null || sqlite3_mutex_held( p.db.mutex ) ); - testcase( p.flags & MEM_Agg ); - testcase( p.flags & MEM_Dyn ); - testcase( p.flags & MEM_RowSet ); - testcase( p.flags & MEM_Frame ); - if ( ( p.flags & ( MEM_Agg | MEM_Dyn | MEM_RowSet | MEM_Frame ) ) != 0 ) - { - if ( ( p.flags & MEM_Agg ) != 0 ) - { - sqlite3VdbeMemFinalize( p, p.u.pDef ); - Debug.Assert( ( p.flags & MEM_Agg ) == 0 ); - sqlite3VdbeMemRelease( p ); + static int sqlite3VdbeMemNulTerminate(Mem pMem) { + Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); + if ((pMem.flags & MEM_Term) != 0 || (pMem.flags & MEM_Str) == 0) { + return SQLITE_OK; /* Nothing to do */ + } + //if ( pMem.n != 0 && sqlite3VdbeMemGrow( pMem, pMem.n + 2, 1 ) != 0 ) + //{ + // return SQLITE_NOMEM; + //} + // pMem.z[pMem->n] = 0; + // pMem.z[pMem->n+1] = 0; + if (pMem.z != null && pMem.n < pMem.z.Length) + pMem.z = pMem.z.Substring(0, pMem.n); + pMem.flags |= MEM_Term; + return SQLITE_OK; } - else if ( ( p.flags & MEM_Dyn ) != 0 && p.xDel != null ) - { - Debug.Assert( ( p.flags & MEM_RowSet ) == 0 ); - p.xDel( ref p.z ); - p.xDel = null; + + /* + ** Add MEM_Str to the set of representations for the given Mem. Numbers + ** are converted using sqlite3_snprintf(). Converting a BLOB to a string + ** is a no-op. + ** + ** Existing representations MEM_Int and MEM_Real are *not* invalidated. + ** + ** A MEM_Null value will never be passed to this function. This function is + ** used for converting values to text for returning to the user (i.e. via + ** sqlite3_value_text()), or for ensuring that values to be used as btree + ** keys are strings. In the former case a NULL pointer is returned the + ** user and the later is an internal programming error. + */ + static int sqlite3VdbeMemStringify(Mem pMem, int enc) { + int rc = SQLITE_OK; + int fg = pMem.flags; + const int nByte = 32; + + Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); + Debug.Assert((fg & MEM_Zero) == 0); + Debug.Assert((fg & (MEM_Str | MEM_Blob)) == 0); + Debug.Assert((fg & (MEM_Int | MEM_Real)) != 0); + Debug.Assert((pMem.flags & MEM_RowSet) == 0); + //assert( EIGHT_BYTE_ALIGNMENT(pMem) ); + + if (sqlite3VdbeMemGrow(pMem, nByte, 0) != 0) { + return SQLITE_NOMEM; + } + + /* For a Real or Integer, use sqlite3_snprintf() to produce the UTF-8 + ** string representation of the value. Then, if the required encoding + ** is UTF-16le or UTF-16be do a translation. + ** + ** FIX ME: It would be better if sqlite3_snprintf() could do UTF-16. + */ + if ((fg & MEM_Int) != 0) { + pMem.z = pMem.u.i.ToString(); //sqlite3_snprintf(nByte, pMem.z, "%lld", pMem->u.i); + } else { + Debug.Assert((fg & MEM_Real) != 0); + if (Double.IsNegativeInfinity(pMem.r)) + pMem.z = "-Inf"; + else if (Double.IsInfinity(pMem.r)) + pMem.z = "Inf"; + else if (Double.IsPositiveInfinity(pMem.r)) + pMem.z = "+Inf"; + else if (pMem.r.ToString(CultureInfo.InvariantCulture).Contains(".")) + pMem.z = pMem.r.ToString(CultureInfo.InvariantCulture).ToLowerInvariant();//sqlite3_snprintf(nByte, pMem.z, "%!.15g", pMem->r); + else + pMem.z = pMem.r.ToString(CultureInfo.InvariantCulture) + ".0"; + } + pMem.n = sqlite3Strlen30(pMem.z); + pMem.enc = SQLITE_UTF8; + pMem.flags |= MEM_Str | MEM_Term; + sqlite3VdbeChangeEncoding(pMem, enc); + return rc; } - else if ( ( p.flags & MEM_RowSet ) != 0 ) - { - sqlite3RowSetClear( p.u.pRowSet ); + + /* + ** Memory cell pMem contains the context of an aggregate function. + ** This routine calls the finalize method for that function. The + ** result of the aggregate is stored back into pMem. + ** + ** Return SQLITE_ERROR if the finalizer reports an error. SQLITE_OK + ** otherwise. + */ + static int sqlite3VdbeMemFinalize(Mem pMem, FuncDef pFunc) { + int rc = SQLITE_OK; + if (ALWAYS(pFunc != null && pFunc.xFinalize != null)) { + sqlite3_context ctx = new sqlite3_context(); + Debug.Assert((pMem.flags & MEM_Null) != 0 || pFunc == pMem.u.pDef); + Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); + //memset(&ctx, 0, sizeof(ctx)); + ctx.s.flags = MEM_Null; + ctx.s.db = pMem.db; + ctx.pMem = pMem; + ctx.pFunc = pFunc; + pFunc.xFinalize(ctx); /* IMP: R-24505-23230 */ + Debug.Assert(0 == (pMem.flags & MEM_Dyn) && pMem.xDel == null); + sqlite3DbFree(pMem.db, ref pMem.zBLOB);//zMalloc ); + ctx.s.CopyTo(ref pMem);//memcpy(pMem, &ctx.s, sizeof(ctx.s)); + rc = ctx.isError; + } + return rc; } - else if ( ( p.flags & MEM_Frame ) != 0 ) - { - sqlite3VdbeMemSetNull( p ); + + /* + ** If the memory cell contains a string value that must be freed by + ** invoking an external callback, free it now. Calling this function + ** does not free any Mem.zMalloc buffer. + */ + static void sqlite3VdbeMemReleaseExternal(Mem p) { + Debug.Assert(p.db == null || sqlite3_mutex_held(p.db.mutex)); + testcase(p.flags & MEM_Agg); + testcase(p.flags & MEM_Dyn); + testcase(p.flags & MEM_RowSet); + testcase(p.flags & MEM_Frame); + if ((p.flags & (MEM_Agg | MEM_Dyn | MEM_RowSet | MEM_Frame)) != 0) { + if ((p.flags & MEM_Agg) != 0) { + sqlite3VdbeMemFinalize(p, p.u.pDef); + Debug.Assert((p.flags & MEM_Agg) == 0); + sqlite3VdbeMemRelease(p); + } else if ((p.flags & MEM_Dyn) != 0 && p.xDel != null) { + Debug.Assert((p.flags & MEM_RowSet) == 0); + p.xDel(ref p.z); + p.xDel = null; + } else if ((p.flags & MEM_RowSet) != 0) { + sqlite3RowSetClear(p.u.pRowSet); + } else if ((p.flags & MEM_Frame) != 0) { + sqlite3VdbeMemSetNull(p); + } + } + p.n = 0; + p.z = null; + p.zBLOB = null; } - } - p.n = 0; - p.z = null; - p.zBLOB = null; - } - /* - ** Release any memory held by the Mem. This may leave the Mem in an - ** inconsistent state, for example with (Mem.z==0) and - ** (Mem.type==SQLITE_TEXT). - */ - static void sqlite3VdbeMemRelease( Mem p ) - { - sqlite3VdbeMemReleaseExternal( p ); - sqlite3DbFree( p.db, ref p.zBLOB );//zMalloc ); - p.z = null; - //p.zMalloc = 0; - p.xDel = null; - } + /* + ** Release any memory held by the Mem. This may leave the Mem in an + ** inconsistent state, for example with (Mem.z==0) and + ** (Mem.type==SQLITE_TEXT). + */ + static void sqlite3VdbeMemRelease(Mem p) { + sqlite3VdbeMemReleaseExternal(p); + sqlite3DbFree(p.db, ref p.zBLOB);//zMalloc ); + p.z = null; + //p.zMalloc = 0; + p.xDel = null; + } - /* - ** Convert a 64-bit IEEE double into a 64-bit signed integer. - ** If the double is too large, return 0x8000000000000000. - ** - ** Most systems appear to do this simply by assigning - ** variables and without the extra range tests. But - ** there are reports that windows throws an expection - ** if the floating point value is out of range. (See ticket #2880.) - ** Because we do not completely understand the problem, we will - ** take the conservative approach and always do range tests - ** before attempting the conversion. - */ - static i64 doubleToInt64( double r ) - { + /* + ** Convert a 64-bit IEEE double into a 64-bit signed integer. + ** If the double is too large, return 0x8000000000000000. + ** + ** Most systems appear to do this simply by assigning + ** variables and without the extra range tests. But + ** there are reports that windows throws an expection + ** if the floating point value is out of range. (See ticket #2880.) + ** Because we do not completely understand the problem, we will + ** take the conservative approach and always do range tests + ** before attempting the conversion. + */ + static i64 doubleToInt64(double r) { #if SQLITE_OMIT_FLOATING_POINT /* When floating-point is omitted, double and int64 are the same thing */ return r; #else - /* -** Many compilers we encounter do not define constants for the -** minimum and maximum 64-bit integers, or they define them -** inconsistently. And many do not understand the "LL" notation. -** So we define our own static constants here using nothing -** larger than a 32-bit integer constant. -*/ - const i64 maxInt = LARGEST_INT64; - const i64 minInt = SMALLEST_INT64; - - if ( r < (double)minInt ) - { - return minInt; - } - else if ( r > (double)maxInt ) - { - /* minInt is correct here - not maxInt. It turns out that assigning - ** a very large positive number to an integer results in a very large - ** negative integer. This makes no sense, but it is what x86 hardware - ** does so for compatibility we will do the same in software. */ - return minInt; - } - else - { - return (i64)r; - } + /* + ** Many compilers we encounter do not define constants for the + ** minimum and maximum 64-bit integers, or they define them + ** inconsistently. And many do not understand the "LL" notation. + ** So we define our own static constants here using nothing + ** larger than a 32-bit integer constant. + */ + const i64 maxInt = LARGEST_INT64; + const i64 minInt = SMALLEST_INT64; + + if (r < (double)minInt) { + return minInt; + } else if (r > (double)maxInt) { + /* minInt is correct here - not maxInt. It turns out that assigning + ** a very large positive number to an integer results in a very large + ** negative integer. This makes no sense, but it is what x86 hardware + ** does so for compatibility we will do the same in software. */ + return minInt; + } else { + return (i64)r; + } #endif - } + } - /* - ** Return some kind of integer value which is the best we can do - ** at representing the value that *pMem describes as an integer. - ** If pMem is an integer, then the value is exact. If pMem is - ** a floating-point then the value returned is the integer part. - ** If pMem is a string or blob, then we make an attempt to convert - ** it into a integer and return that. If pMem represents an - ** an SQL-NULL value, return 0. - ** - ** If pMem represents a string value, its encoding might be changed. - */ - static i64 sqlite3VdbeIntValue( Mem pMem ) - { - int flags; - Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); - // assert( EIGHT_BYTE_ALIGNMENT(pMem) ); - flags = pMem.flags; - if ( ( flags & MEM_Int ) != 0 ) - { - return pMem.u.i; - } - else if ( ( flags & MEM_Real ) != 0 ) - { - return doubleToInt64( pMem.r ); - } - else if ( ( flags & ( MEM_Str ) ) != 0 ) - { - i64 value = 0; - Debug.Assert( pMem.z != null || pMem.n == 0 ); - testcase( pMem.z == null ); - sqlite3Atoi64( pMem.z, ref value, pMem.n, pMem.enc ); - return value; - } - else if ( ( flags & ( MEM_Blob ) ) != 0 ) - { - i64 value = 0; - Debug.Assert( pMem.zBLOB != null || pMem.n == 0 ); - testcase( pMem.zBLOB == null ); - sqlite3Atoi64( Encoding.UTF8.GetString( pMem.zBLOB, 0, pMem.n ), ref value, pMem.n, pMem.enc ); - return value; - } - else - { - return 0; - } - } + /* + ** Return some kind of integer value which is the best we can do + ** at representing the value that *pMem describes as an integer. + ** If pMem is an integer, then the value is exact. If pMem is + ** a floating-point then the value returned is the integer part. + ** If pMem is a string or blob, then we make an attempt to convert + ** it into a integer and return that. If pMem represents an + ** an SQL-NULL value, return 0. + ** + ** If pMem represents a string value, its encoding might be changed. + */ + static i64 sqlite3VdbeIntValue(Mem pMem) { + int flags; + Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); + // assert( EIGHT_BYTE_ALIGNMENT(pMem) ); + flags = pMem.flags; + if ((flags & MEM_Int) != 0) { + return pMem.u.i; + } else if ((flags & MEM_Real) != 0) { + return doubleToInt64(pMem.r); + } else if ((flags & (MEM_Str)) != 0) { + i64 value = 0; + Debug.Assert(pMem.z != null || pMem.n == 0); + testcase(pMem.z == null); + sqlite3Atoi64(pMem.z, ref value, pMem.n, pMem.enc); + return value; + } else if ((flags & (MEM_Blob)) != 0) { + i64 value = 0; + Debug.Assert(pMem.zBLOB != null || pMem.n == 0); + testcase(pMem.zBLOB == null); + sqlite3Atoi64(Encoding.UTF8.GetString(pMem.zBLOB, 0, pMem.n), ref value, pMem.n, pMem.enc); + return value; + } else { + return 0; + } + } - /* - ** Return the best representation of pMem that we can get into a - ** double. If pMem is already a double or an integer, return its - ** value. If it is a string or blob, try to convert it to a double. - ** If it is a NULL, return 0.0. - */ - static double sqlite3VdbeRealValue( Mem pMem ) - { - Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); - //assert( EIGHT_BYTE_ALIGNMENT(pMem) ); - if ( ( pMem.flags & MEM_Real ) != 0 ) - { - return pMem.r; - } - else if ( ( pMem.flags & MEM_Int ) != 0 ) - { - return (double)pMem.u.i; - } - else if ( ( pMem.flags & ( MEM_Str ) ) != 0 ) - { - /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ - double val = (double)0; - sqlite3AtoF( pMem.z, ref val, pMem.n, pMem.enc ); - return val; - } - else if ( ( pMem.flags & ( MEM_Blob ) ) != 0 ) - { - /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ - double val = (double)0; - Debug.Assert( pMem.zBLOB != null || pMem.n == 0 ); - sqlite3AtoF( Encoding.UTF8.GetString( pMem.zBLOB, 0, pMem.n ), ref val, pMem.n, pMem.enc ); - return val; - } - else - { - /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ - return (double)0; - } - } + /* + ** Return the best representation of pMem that we can get into a + ** double. If pMem is already a double or an integer, return its + ** value. If it is a string or blob, try to convert it to a double. + ** If it is a NULL, return 0.0. + */ + static double sqlite3VdbeRealValue(Mem pMem) { + Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); + //assert( EIGHT_BYTE_ALIGNMENT(pMem) ); + if ((pMem.flags & MEM_Real) != 0) { + return pMem.r; + } else if ((pMem.flags & MEM_Int) != 0) { + return (double)pMem.u.i; + } else if ((pMem.flags & (MEM_Str)) != 0) { + /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ + double val = (double)0; + sqlite3AtoF(pMem.z, ref val, pMem.n, pMem.enc); + return val; + } else if ((pMem.flags & (MEM_Blob)) != 0) { + /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ + double val = (double)0; + Debug.Assert(pMem.zBLOB != null || pMem.n == 0); + sqlite3AtoF(Encoding.UTF8.GetString(pMem.zBLOB, 0, pMem.n), ref val, pMem.n, pMem.enc); + return val; + } else { + /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ + return (double)0; + } + } - /* - ** The MEM structure is already a MEM_Real. Try to also make it a - ** MEM_Int if we can. - */ - static void sqlite3VdbeIntegerAffinity( Mem pMem ) - { - Debug.Assert( ( pMem.flags & MEM_Real ) != 0 ); - Debug.Assert( ( pMem.flags & MEM_RowSet ) == 0 ); - Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); - //assert( EIGHT_BYTE_ALIGNMENT(pMem) ); - - pMem.u.i = doubleToInt64( pMem.r ); - - /* Only mark the value as an integer if - ** - ** (1) the round-trip conversion real->int->real is a no-op, and - ** (2) The integer is neither the largest nor the smallest - ** possible integer (ticket #3922) - ** - ** The second and third terms in the following conditional enforces - ** the second condition under the assumption that addition overflow causes - ** values to wrap around. On x86 hardware, the third term is always - ** true and could be omitted. But we leave it in because other - ** architectures might behave differently. - */ - if ( pMem.r == (double)pMem.u.i && pMem.u.i > SMALLEST_INT64 - && ALWAYS( pMem.u.i < LARGEST_INT64 ) ) - { - pMem.flags |= MEM_Int; - } - } + /* + ** The MEM structure is already a MEM_Real. Try to also make it a + ** MEM_Int if we can. + */ + static void sqlite3VdbeIntegerAffinity(Mem pMem) { + Debug.Assert((pMem.flags & MEM_Real) != 0); + Debug.Assert((pMem.flags & MEM_RowSet) == 0); + Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); + //assert( EIGHT_BYTE_ALIGNMENT(pMem) ); + + pMem.u.i = doubleToInt64(pMem.r); + + /* Only mark the value as an integer if + ** + ** (1) the round-trip conversion real->int->real is a no-op, and + ** (2) The integer is neither the largest nor the smallest + ** possible integer (ticket #3922) + ** + ** The second and third terms in the following conditional enforces + ** the second condition under the assumption that addition overflow causes + ** values to wrap around. On x86 hardware, the third term is always + ** true and could be omitted. But we leave it in because other + ** architectures might behave differently. + */ + if (pMem.r == (double)pMem.u.i && pMem.u.i > SMALLEST_INT64 + && ALWAYS(pMem.u.i < LARGEST_INT64)) { + pMem.flags |= MEM_Int; + } + } - /* - ** Convert pMem to type integer. Invalidate any prior representations. - */ - static int sqlite3VdbeMemIntegerify( Mem pMem ) - { - Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); - Debug.Assert( ( pMem.flags & MEM_RowSet ) == 0 ); - //assert( EIGHT_BYTE_ALIGNMENT(pMem) ); - - pMem.u.i = sqlite3VdbeIntValue( pMem ); - MemSetTypeFlag( pMem, MEM_Int ); - return SQLITE_OK; - } + /* + ** Convert pMem to type integer. Invalidate any prior representations. + */ + static int sqlite3VdbeMemIntegerify(Mem pMem) { + Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); + Debug.Assert((pMem.flags & MEM_RowSet) == 0); + //assert( EIGHT_BYTE_ALIGNMENT(pMem) ); + + pMem.u.i = sqlite3VdbeIntValue(pMem); + MemSetTypeFlag(pMem, MEM_Int); + return SQLITE_OK; + } - /* - ** Convert pMem so that it is of type MEM_Real. - ** Invalidate any prior representations. - */ - static int sqlite3VdbeMemRealify( Mem pMem ) - { - Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); - //assert( EIGHT_BYTE_ALIGNMENT(pMem) ); - - pMem.r = sqlite3VdbeRealValue( pMem ); - MemSetTypeFlag( pMem, MEM_Real ); - return SQLITE_OK; - } + /* + ** Convert pMem so that it is of type MEM_Real. + ** Invalidate any prior representations. + */ + static int sqlite3VdbeMemRealify(Mem pMem) { + Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); + //assert( EIGHT_BYTE_ALIGNMENT(pMem) ); - /* - ** Convert pMem so that it has types MEM_Real or MEM_Int or both. - ** Invalidate any prior representations. - ** - ** Every effort is made to force the conversion, even if the input - ** is a string that does not look completely like a number. Convert - ** as much of the string as we can and ignore the rest. - */ - static int sqlite3VdbeMemNumerify( Mem pMem ) - { - if ( ( pMem.flags & ( MEM_Int | MEM_Real | MEM_Null ) ) == 0 ) - { - Debug.Assert( ( pMem.flags & ( MEM_Blob | MEM_Str ) ) != 0 ); - Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); - if ( ( pMem.flags & MEM_Blob ) != 0 && pMem.z == null ) - { - if ( 0 == sqlite3Atoi64( Encoding.UTF8.GetString( pMem.zBLOB, 0, pMem.zBLOB.Length ), ref pMem.u.i, pMem.n, pMem.enc ) ) - MemSetTypeFlag( pMem, MEM_Int ); - else - { - pMem.r = sqlite3VdbeRealValue( pMem ); - MemSetTypeFlag( pMem, MEM_Real ); - sqlite3VdbeIntegerAffinity( pMem ); - } + pMem.r = sqlite3VdbeRealValue(pMem); + MemSetTypeFlag(pMem, MEM_Real); + return SQLITE_OK; } - else if ( 0 == sqlite3Atoi64( pMem.z, ref pMem.u.i, pMem.n, pMem.enc ) ) - { - MemSetTypeFlag( pMem, MEM_Int ); - } - else - { - pMem.r = sqlite3VdbeRealValue( pMem ); - MemSetTypeFlag( pMem, MEM_Real ); - sqlite3VdbeIntegerAffinity( pMem ); + + /* + ** Convert pMem so that it has types MEM_Real or MEM_Int or both. + ** Invalidate any prior representations. + ** + ** Every effort is made to force the conversion, even if the input + ** is a string that does not look completely like a number. Convert + ** as much of the string as we can and ignore the rest. + */ + static int sqlite3VdbeMemNumerify(Mem pMem) { + if ((pMem.flags & (MEM_Int | MEM_Real | MEM_Null)) == 0) { + Debug.Assert((pMem.flags & (MEM_Blob | MEM_Str)) != 0); + Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); + if ((pMem.flags & MEM_Blob) != 0 && pMem.z == null) { + if (0 == sqlite3Atoi64(Encoding.UTF8.GetString(pMem.zBLOB, 0, pMem.zBLOB.Length), ref pMem.u.i, pMem.n, pMem.enc)) + MemSetTypeFlag(pMem, MEM_Int); + else { + pMem.r = sqlite3VdbeRealValue(pMem); + MemSetTypeFlag(pMem, MEM_Real); + sqlite3VdbeIntegerAffinity(pMem); + } + } else if (0 == sqlite3Atoi64(pMem.z, ref pMem.u.i, pMem.n, pMem.enc)) { + MemSetTypeFlag(pMem, MEM_Int); + } else { + pMem.r = sqlite3VdbeRealValue(pMem); + MemSetTypeFlag(pMem, MEM_Real); + sqlite3VdbeIntegerAffinity(pMem); + } + } + Debug.Assert((pMem.flags & (MEM_Int | MEM_Real | MEM_Null)) != 0); + pMem.flags = (ushort)(pMem.flags & ~(MEM_Str | MEM_Blob)); + return SQLITE_OK; } - } - Debug.Assert( ( pMem.flags & ( MEM_Int | MEM_Real | MEM_Null ) ) != 0 ); - pMem.flags = (ushort)( pMem.flags & ~( MEM_Str | MEM_Blob ) ); - return SQLITE_OK; - } #if !SQLITE_OMIT_FLOATING_POINT - /* -** Delete any previous value and set the value stored in pMem to NULL. -*/ - static void sqlite3VdbeMemSetNull( Mem pMem ) - { - if ( ( pMem.flags & MEM_Frame ) != 0 ) - { - VdbeFrame pFrame = pMem.u.pFrame; - pFrame.pParent = pFrame.v.pDelFrame; - pFrame.v.pDelFrame = pFrame; - } - if ( ( pMem.flags & MEM_RowSet ) != 0 ) - { - sqlite3RowSetClear( pMem.u.pRowSet ); - } - MemSetTypeFlag( pMem, MEM_Null ); - sqlite3_free( ref pMem.zBLOB ); - pMem.z = null; - pMem.type = SQLITE_NULL; - } + /* + ** Delete any previous value and set the value stored in pMem to NULL. + */ + static void sqlite3VdbeMemSetNull(Mem pMem) { + if ((pMem.flags & MEM_Frame) != 0) { + VdbeFrame pFrame = pMem.u.pFrame; + pFrame.pParent = pFrame.v.pDelFrame; + pFrame.v.pDelFrame = pFrame; + } + if ((pMem.flags & MEM_RowSet) != 0) { + sqlite3RowSetClear(pMem.u.pRowSet); + } + MemSetTypeFlag(pMem, MEM_Null); + sqlite3_free(ref pMem.zBLOB); + pMem.z = null; + pMem.type = SQLITE_NULL; + } #endif - /* -** Delete any previous value and set the value to be a BLOB of length -** n containing all zeros. -*/ - static void sqlite3VdbeMemSetZeroBlob( Mem pMem, int n ) - { - sqlite3VdbeMemRelease( pMem ); - pMem.flags = MEM_Blob | MEM_Zero; - pMem.type = SQLITE_BLOB; - pMem.n = 0; - if ( n < 0 ) - n = 0; - pMem.u.nZero = n; - pMem.enc = SQLITE_UTF8; + /* + ** Delete any previous value and set the value to be a BLOB of length + ** n containing all zeros. + */ + static void sqlite3VdbeMemSetZeroBlob(Mem pMem, int n) { + sqlite3VdbeMemRelease(pMem); + pMem.flags = MEM_Blob | MEM_Zero; + pMem.type = SQLITE_BLOB; + pMem.n = 0; + if (n < 0) + n = 0; + pMem.u.nZero = n; + pMem.enc = SQLITE_UTF8; #if SQLITE_OMIT_INCRBLOB - sqlite3VdbeMemGrow( pMem, n, 0 ); - //if( pMem.z!= null ){ - pMem.n = n; - pMem.z = null;//memset(pMem.z, 0, n); - pMem.zBLOB = sqlite3Malloc( n ); - //} + sqlite3VdbeMemGrow(pMem, n, 0); + //if( pMem.z!= null ){ + pMem.n = n; + pMem.z = null;//memset(pMem.z, 0, n); + pMem.zBLOB = sqlite3Malloc(n); + //} #endif - } + } - /* - ** Delete any previous value and set the value stored in pMem to val, - ** manifest type INTEGER. - */ - static void sqlite3VdbeMemSetInt64( Mem pMem, i64 val ) - { - sqlite3VdbeMemRelease( pMem ); - pMem.u.i = val; - pMem.flags = MEM_Int; - pMem.type = SQLITE_INTEGER; - } + /* + ** Delete any previous value and set the value stored in pMem to val, + ** manifest type INTEGER. + */ + static void sqlite3VdbeMemSetInt64(Mem pMem, i64 val) { + sqlite3VdbeMemRelease(pMem); + pMem.u.i = val; + pMem.flags = MEM_Int; + pMem.type = SQLITE_INTEGER; + } - /* - ** Delete any previous value and set the value stored in pMem to val, - ** manifest type REAL. - */ - static void sqlite3VdbeMemSetDouble( Mem pMem, double val ) - { - if ( sqlite3IsNaN( val ) ) - { - sqlite3VdbeMemSetNull( pMem ); - } - else - { - sqlite3VdbeMemRelease( pMem ); - pMem.r = val; - pMem.flags = MEM_Real; - pMem.type = SQLITE_FLOAT; - } - } + /* + ** Delete any previous value and set the value stored in pMem to val, + ** manifest type REAL. + */ + static void sqlite3VdbeMemSetDouble(Mem pMem, double val) { + if (sqlite3IsNaN(val)) { + sqlite3VdbeMemSetNull(pMem); + } else { + sqlite3VdbeMemRelease(pMem); + pMem.r = val; + pMem.flags = MEM_Real; + pMem.type = SQLITE_FLOAT; + } + } - /* - ** Delete any previous value and set the value of pMem to be an - ** empty boolean index. - */ - static void sqlite3VdbeMemSetRowSet( Mem pMem ) - { - sqlite3 db = pMem.db; - Debug.Assert( db != null ); - Debug.Assert( ( pMem.flags & MEM_RowSet ) == 0 ); - sqlite3VdbeMemRelease( pMem ); - //pMem.zMalloc = sqlite3DbMallocRaw( db, 64 ); - //if ( db.mallocFailed != 0 ) - //{ - // pMem.flags = MEM_Null; - //} - //else - { - //Debug.Assert( pMem.zMalloc ); - pMem.u.pRowSet = new RowSet( db, 5 );// sqlite3RowSetInit( db, pMem.zMalloc, - // sqlite3DbMallocSize( db, pMem.zMalloc ) ); - Debug.Assert( pMem.u.pRowSet != null ); - pMem.flags = MEM_RowSet; - } - } + /* + ** Delete any previous value and set the value of pMem to be an + ** empty boolean index. + */ + static void sqlite3VdbeMemSetRowSet(Mem pMem) { + sqlite3 db = pMem.db; + Debug.Assert(db != null); + Debug.Assert((pMem.flags & MEM_RowSet) == 0); + sqlite3VdbeMemRelease(pMem); + //pMem.zMalloc = sqlite3DbMallocRaw( db, 64 ); + //if ( db.mallocFailed != 0 ) + //{ + // pMem.flags = MEM_Null; + //} + //else + { + //Debug.Assert( pMem.zMalloc ); + pMem.u.pRowSet = new RowSet(db, 5);// sqlite3RowSetInit( db, pMem.zMalloc, + // sqlite3DbMallocSize( db, pMem.zMalloc ) ); + Debug.Assert(pMem.u.pRowSet != null); + pMem.flags = MEM_RowSet; + } + } - /* - ** Return true if the Mem object contains a TEXT or BLOB that is - ** too large - whose size exceeds p.db.aLimit[SQLITE_LIMIT_LENGTH]. - */ - static bool sqlite3VdbeMemTooBig( Mem p ) - { - //Debug.Assert( p.db != null ); - if ( ( p.flags & ( MEM_Str | MEM_Blob ) ) != 0 ) - { - int n = p.n; - if ( ( p.flags & MEM_Zero ) != 0 ) - { - n += p.u.nZero; + /* + ** Return true if the Mem object contains a TEXT or BLOB that is + ** too large - whose size exceeds p.db.aLimit[SQLITE_LIMIT_LENGTH]. + */ + static bool sqlite3VdbeMemTooBig(Mem p) { + //Debug.Assert( p.db != null ); + if ((p.flags & (MEM_Str | MEM_Blob)) != 0) { + int n = p.n; + if ((p.flags & MEM_Zero) != 0) { + n += p.u.nZero; + } + return n > p.db.aLimit[SQLITE_LIMIT_LENGTH]; + } + return false; } - return n > p.db.aLimit[SQLITE_LIMIT_LENGTH]; - } - return false; - } #if SQLITE_DEBUG - /* -** This routine prepares a memory cell for modication by breaking -** its link to a shallow copy and by marking any current shallow -** copies of this cell as invalid. -** -** This is used for testing and debugging only - to make sure shallow -** copies are not misused. -*/ - static void sqlite3VdbeMemPrepareToChange( Vdbe pVdbe, Mem pMem ) - { - int i; - Mem pX; - for ( i = 1; i <= pVdbe.nMem; i++ ) - { - pX = pVdbe.aMem[i]; - if ( pX.pScopyFrom == pMem ) - { - pX.flags |= MEM_Invalid; - pX.pScopyFrom = null; + /* + ** This routine prepares a memory cell for modication by breaking + ** its link to a shallow copy and by marking any current shallow + ** copies of this cell as invalid. + ** + ** This is used for testing and debugging only - to make sure shallow + ** copies are not misused. + */ + static void sqlite3VdbeMemPrepareToChange(Vdbe pVdbe, Mem pMem) { + int i; + Mem pX; + for (i = 1; i <= pVdbe.nMem; i++) { + pX = pVdbe.aMem[i]; + if (pX.pScopyFrom == pMem) { + pX.flags |= MEM_Invalid; + pX.pScopyFrom = null; + } + } + pMem.pScopyFrom = null; } - } - pMem.pScopyFrom = null; - } #endif //* SQLITE_DEBUG */ - /* -** Size of struct Mem not including the Mem.zMalloc member. -*/ - //#define MEMCELLSIZE (size_t)(&(((Mem *)0).zMalloc)) - - /* - ** Make an shallow copy of pFrom into pTo. Prior contents of - ** pTo are freed. The pFrom.z field is not duplicated. If - ** pFrom.z is used, then pTo.z points to the same thing as pFrom.z - ** and flags gets srcType (either MEM_Ephem or MEM_Static). + /* + ** Size of struct Mem not including the Mem.zMalloc member. */ - static void sqlite3VdbeMemShallowCopy( Mem pTo, Mem pFrom, int srcType ) - { - Debug.Assert( ( pFrom.flags & MEM_RowSet ) == 0 ); - sqlite3VdbeMemReleaseExternal( pTo ); - pFrom.CopyTo( ref pTo );// memcpy(pTo, pFrom, MEMCELLSIZE); - pTo.xDel = null; - if ( ( pFrom.flags & MEM_Static ) != 0 ) - { - pTo.flags = (u16)( pFrom.flags & ~( MEM_Dyn | MEM_Static | MEM_Ephem ) ); - Debug.Assert( srcType == MEM_Ephem || srcType == MEM_Static ); - pTo.flags |= (u16)srcType; - } - } + //#define MEMCELLSIZE (size_t)(&(((Mem *)0).zMalloc)) - /* - ** Make a full copy of pFrom into pTo. Prior contents of pTo are - ** freed before the copy is made. - */ - static int sqlite3VdbeMemCopy( Mem pTo, Mem pFrom ) - { - int rc = SQLITE_OK; - - Debug.Assert( ( pFrom.flags & MEM_RowSet ) == 0 ); - sqlite3VdbeMemReleaseExternal( pTo ); - pFrom.CopyTo( ref pTo );// memcpy(pTo, pFrom, MEMCELLSIZE); - pTo.flags = (u16)( pTo.flags & ~MEM_Dyn ); - - if ( ( pTo.flags & ( MEM_Str | MEM_Blob ) ) != 0 ) - { - if ( 0 == ( pFrom.flags & MEM_Static ) ) - { - pTo.flags |= MEM_Ephem; - rc = sqlite3VdbeMemMakeWriteable( pTo ); + /* + ** Make an shallow copy of pFrom into pTo. Prior contents of + ** pTo are freed. The pFrom.z field is not duplicated. If + ** pFrom.z is used, then pTo.z points to the same thing as pFrom.z + ** and flags gets srcType (either MEM_Ephem or MEM_Static). + */ + static void sqlite3VdbeMemShallowCopy(Mem pTo, Mem pFrom, int srcType) { + Debug.Assert((pFrom.flags & MEM_RowSet) == 0); + sqlite3VdbeMemReleaseExternal(pTo); + pFrom.CopyTo(ref pTo);// memcpy(pTo, pFrom, MEMCELLSIZE); + pTo.xDel = null; + if ((pFrom.flags & MEM_Static) != 0) { + pTo.flags = (u16)(pFrom.flags & ~(MEM_Dyn | MEM_Static | MEM_Ephem)); + Debug.Assert(srcType == MEM_Ephem || srcType == MEM_Static); + pTo.flags |= (u16)srcType; + } } - } - return rc; - } + /* + ** Make a full copy of pFrom into pTo. Prior contents of pTo are + ** freed before the copy is made. + */ + static int sqlite3VdbeMemCopy(Mem pTo, Mem pFrom) { + int rc = SQLITE_OK; + Debug.Assert((pFrom.flags & MEM_RowSet) == 0); + sqlite3VdbeMemReleaseExternal(pTo); + pFrom.CopyTo(ref pTo);// memcpy(pTo, pFrom, MEMCELLSIZE); + pTo.flags = (u16)(pTo.flags & ~MEM_Dyn); + if ((pTo.flags & (MEM_Str | MEM_Blob)) != 0) { + if (0 == (pFrom.flags & MEM_Static)) { + pTo.flags |= MEM_Ephem; + rc = sqlite3VdbeMemMakeWriteable(pTo); + } + } + return rc; + } - /* - ** Transfer the contents of pFrom to pTo. Any existing value in pTo is - ** freed. If pFrom contains ephemeral data, a copy is made. - ** - ** pFrom contains an SQL NULL when this routine returns. - */ - static void sqlite3VdbeMemMove( Mem pTo, Mem pFrom ) - { - Debug.Assert( pFrom.db == null || sqlite3_mutex_held( pFrom.db.mutex ) ); - Debug.Assert( pTo.db == null || sqlite3_mutex_held( pTo.db.mutex ) ); - Debug.Assert( pFrom.db == null || pTo.db == null || pFrom.db == pTo.db ); - sqlite3VdbeMemRelease( pTo ); - pFrom.CopyTo( ref pTo );// memcpy(pTo, pFrom, Mem).Length; - pFrom.flags = MEM_Null; - pFrom.xDel = null; - pFrom.z = null; - sqlite3_free( ref pFrom.zBLOB ); //pFrom.zMalloc=0; - } - /* - ** Change the value of a Mem to be a string or a BLOB. - ** - ** The memory management strategy depends on the value of the xDel - ** parameter. If the value passed is SQLITE_TRANSIENT, then the - ** string is copied into a (possibly existing) buffer managed by the - ** Mem structure. Otherwise, any existing buffer is freed and the - ** pointer copied. - ** - ** If the string is too large (if it exceeds the SQLITE_LIMIT_LENGTH - ** size limit) then no memory allocation occurs. If the string can be - ** stored without allocating memory, then it is. If a memory allocation - ** is required to store the string, then value of pMem is unchanged. In - ** either case, SQLITE_TOOBIG is returned. - */ - static int sqlite3VdbeMemSetBlob( - Mem pMem, /* Memory cell to set to string value */ - byte[] zBlob, /* Blob pointer */ - int n, /* Bytes in Blob */ - u8 enc, /* 0 for BLOBs */ - dxDel xDel /* Destructor function */ - ) - { - return sqlite3VdbeMemSetBlob( pMem, zBlob, 0, n >= 0 ? n : zBlob.Length, enc, xDel ); - } // Call w/o offset - - static int sqlite3VdbeMemSetBlob( - Mem pMem, /* Memory cell to set to string value */ - byte[] zBlob, /* Blob pointer */ - int offset, /* offset into string */ - int n, /* Bytes in string, or negative */ - u8 enc, /* Encoding of z. 0 for BLOBs */ - dxDel xDel//)(void*)/* Destructor function */ - ) - { - int nByte = n; /* New value for pMem->n */ - int iLimit; /* Maximum allowed string or blob size */ - - Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); - Debug.Assert( ( pMem.flags & MEM_RowSet ) == 0 ); - - /* If zBlob is a NULL pointer, set pMem to contain an SQL NULL. */ - if ( zBlob == null || zBlob.Length < offset ) - { - sqlite3VdbeMemSetNull( pMem ); - return SQLITE_OK; - } - - if ( pMem.db != null ) - { - iLimit = pMem.db.aLimit[SQLITE_LIMIT_LENGTH]; - } - else - { - iLimit = SQLITE_MAX_LENGTH; - } - if ( nByte < 0 ) - { - Debug.Assert( enc != 0 ); - if ( enc == SQLITE_UTF8 ) - { - for ( nByte = 0; nByte <= iLimit && nByte < zBlob.Length - offset && zBlob[offset + nByte] != 0; nByte++ ) - { - } - } - else - { - for ( nByte = 0; nByte <= iLimit && zBlob[nByte + offset] != 0 || zBlob[offset + nByte + 1] != 0; nByte += 2 ) - { - } - } - } - /* The following block sets the new values of Mem.z and Mem.xDel. It - ** also sets a flag in local variable "flags" to indicate the memory - ** management (one of MEM_Dyn or MEM_Static). - */ - Debug.Assert( enc == 0 ); - { - pMem.z = null; - pMem.zBLOB = sqlite3Malloc( n ); - Buffer.BlockCopy( zBlob, offset, pMem.zBLOB, 0, n ); - } - pMem.n = nByte; - pMem.flags = MEM_Blob | MEM_Term; - pMem.enc = ( enc == 0 ? SQLITE_UTF8 : enc ); - pMem.type = ( enc == 0 ? SQLITE_BLOB : SQLITE_TEXT ); - - if ( nByte > iLimit ) - { - return SQLITE_TOOBIG; - } - - return SQLITE_OK; - } - static int sqlite3VdbeMemSetStr( - Mem pMem, /* Memory cell to set to string value */ - string z, /* String pointer */ - int n, /* Bytes in string, or negative */ - u8 enc, /* Encoding of z. 0 for BLOBs */ - dxDel xDel /* Destructor function */ - ) - { - return sqlite3VdbeMemSetStr( pMem, z, 0, n, enc, xDel ); - } // Call w/o offset - - static int sqlite3VdbeMemSetStr( - Mem pMem, /* Memory cell to set to string value */ - string z, /* String pointer */ - int offset, /* offset into string */ - int n, /* Bytes in string, or negative */ - u8 enc, /* Encoding of z. 0 for BLOBs */ - dxDel xDel//)(void*)/* Destructor function */ - ) - { - int nByte = n; /* New value for pMem->n */ - int iLimit; /* Maximum allowed string or blob size */ - u16 flags = 0; /* New value for pMem->flags */ - - Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); - Debug.Assert( ( pMem.flags & MEM_RowSet ) == 0 ); - - /* If z is a NULL pointer, set pMem to contain an SQL NULL. */ - if ( z == null || z.Length < offset ) - { - sqlite3VdbeMemSetNull( pMem ); - return SQLITE_OK; - } - - if ( pMem.db != null ) - { - iLimit = pMem.db.aLimit[SQLITE_LIMIT_LENGTH]; - } - else - { - iLimit = SQLITE_MAX_LENGTH; - } - flags = (u16)( enc == 0 ? MEM_Blob : MEM_Str ); - if ( nByte < 0 ) - { - Debug.Assert( enc != 0 ); - if ( enc == SQLITE_UTF8 ) - { - for ( nByte = 0; nByte <= iLimit && nByte < z.Length - offset && z[offset + nByte] != 0; nByte++ ) - { - } - } - else - { - for ( nByte = 0; nByte <= iLimit && z[nByte + offset] != 0 || z[offset + nByte + 1] != 0; nByte += 2 ) - { - } + /* + ** Transfer the contents of pFrom to pTo. Any existing value in pTo is + ** freed. If pFrom contains ephemeral data, a copy is made. + ** + ** pFrom contains an SQL NULL when this routine returns. + */ + static void sqlite3VdbeMemMove(Mem pTo, Mem pFrom) { + Debug.Assert(pFrom.db == null || sqlite3_mutex_held(pFrom.db.mutex)); + Debug.Assert(pTo.db == null || sqlite3_mutex_held(pTo.db.mutex)); + Debug.Assert(pFrom.db == null || pTo.db == null || pFrom.db == pTo.db); + sqlite3VdbeMemRelease(pTo); + pFrom.CopyTo(ref pTo);// memcpy(pTo, pFrom, Mem).Length; + pFrom.flags = MEM_Null; + pFrom.xDel = null; + pFrom.z = null; + sqlite3_free(ref pFrom.zBLOB); //pFrom.zMalloc=0; } - flags |= MEM_Term; - } - /* The following block sets the new values of Mem.z and Mem.xDel. It - ** also sets a flag in local variable "flags" to indicate the memory - ** management (one of MEM_Dyn or MEM_Static). - */ - if ( xDel == SQLITE_TRANSIENT ) - { - u32 nAlloc = (u32)nByte; - if ( ( flags & MEM_Term ) != 0 ) - { - nAlloc += (u32)( enc == SQLITE_UTF8 ? 1 : 2 ); - } - if ( nByte > iLimit ) - { - return SQLITE_TOOBIG; - } - if ( sqlite3VdbeMemGrow( pMem, (int)nAlloc, 0 ) != 0 ) - { - return SQLITE_NOMEM; - } - //if ( nAlloc < z.Length ) - //pMem.z = new byte[nAlloc]; Buffer.BlockCopy( z, 0, pMem.z, 0, (int)nAlloc ); } - //else - if ( enc == 0 ) - { - pMem.z = null; - pMem.zBLOB = sqlite3Malloc( n ); - for ( int i = 0; i < n && i < z.Length - offset; i++ ) - pMem.zBLOB[i] = (byte)z[offset + i]; - } - else - { - pMem.z = n > 0 && z.Length - offset > n ? z.Substring( offset, n ) : z.Substring( offset );//memcpy(pMem.z, z, nAlloc); - sqlite3_free( ref pMem.zBLOB ); - } - } - else if ( xDel == SQLITE_DYNAMIC ) - { - sqlite3VdbeMemRelease( pMem ); - //pMem.zMalloc = pMem.z = (char*)z; - if ( enc == 0 ) - { - pMem.z = null; - if ( pMem.zBLOB != null ) - sqlite3_free( ref pMem.zBLOB ); - pMem.zBLOB = Encoding.UTF8.GetBytes( offset == 0 ? z : z.Length + offset < n ? z.Substring( offset, n ) : z.Substring( offset ) ); - } - else - { - pMem.z = n > 0 && z.Length - offset > n ? z.Substring( offset, n ) : z.Substring( offset );//memcpy(pMem.z, z, nAlloc); - sqlite3_free( ref pMem.zBLOB ); - } - pMem.xDel = null; - } - else - { - sqlite3VdbeMemRelease( pMem ); - if ( enc == 0 ) - { - pMem.z = null; - if ( pMem.zBLOB != null ) - sqlite3_free( ref pMem.zBLOB ); - pMem.zBLOB = Encoding.UTF8.GetBytes( offset == 0 ? z : z.Length + offset < n ? z.Substring( offset, n ) : z.Substring( offset ) ); - } - else - { - pMem.z = n > 0 && z.Length - offset > n ? z.Substring( offset, n ) : z.Substring( offset );//memcpy(pMem.z, z, nAlloc); - sqlite3_free( ref pMem.zBLOB ); + /* + ** Change the value of a Mem to be a string or a BLOB. + ** + ** The memory management strategy depends on the value of the xDel + ** parameter. If the value passed is SQLITE_TRANSIENT, then the + ** string is copied into a (possibly existing) buffer managed by the + ** Mem structure. Otherwise, any existing buffer is freed and the + ** pointer copied. + ** + ** If the string is too large (if it exceeds the SQLITE_LIMIT_LENGTH + ** size limit) then no memory allocation occurs. If the string can be + ** stored without allocating memory, then it is. If a memory allocation + ** is required to store the string, then value of pMem is unchanged. In + ** either case, SQLITE_TOOBIG is returned. + */ + static int sqlite3VdbeMemSetBlob( + Mem pMem, /* Memory cell to set to string value */ + byte[] zBlob, /* Blob pointer */ + int n, /* Bytes in Blob */ + u8 enc, /* 0 for BLOBs */ + dxDel xDel /* Destructor function */ + ) { + return sqlite3VdbeMemSetBlob(pMem, zBlob, 0, n >= 0 ? n : zBlob.Length, enc, xDel); + } // Call w/o offset + + static int sqlite3VdbeMemSetBlob( + Mem pMem, /* Memory cell to set to string value */ + byte[] zBlob, /* Blob pointer */ + int offset, /* offset into string */ + int n, /* Bytes in string, or negative */ + u8 enc, /* Encoding of z. 0 for BLOBs */ + dxDel xDel//)(void*)/* Destructor function */ + ) { + int nByte = n; /* New value for pMem->n */ + int iLimit; /* Maximum allowed string or blob size */ + + Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); + Debug.Assert((pMem.flags & MEM_RowSet) == 0); + + /* If zBlob is a NULL pointer, set pMem to contain an SQL NULL. */ + if (zBlob == null || zBlob.Length < offset) { + sqlite3VdbeMemSetNull(pMem); + return SQLITE_OK; + } + + if (pMem.db != null) { + iLimit = pMem.db.aLimit[SQLITE_LIMIT_LENGTH]; + } else { + iLimit = SQLITE_MAX_LENGTH; + } + if (nByte < 0) { + Debug.Assert(enc != 0); + if (enc == SQLITE_UTF8) { + for (nByte = 0; nByte <= iLimit && nByte < zBlob.Length - offset && zBlob[offset + nByte] != 0; nByte++) { + } + } else { + for (nByte = 0; nByte <= iLimit && zBlob[nByte + offset] != 0 || zBlob[offset + nByte + 1] != 0; nByte += 2) { + } + } + } + + /* The following block sets the new values of Mem.z and Mem.xDel. It + ** also sets a flag in local variable "flags" to indicate the memory + ** management (one of MEM_Dyn or MEM_Static). + */ + Debug.Assert(enc == 0); + { + pMem.z = null; + pMem.zBLOB = sqlite3Malloc(n); + Buffer.BlockCopy(zBlob, offset, pMem.zBLOB, 0, n); + } + pMem.n = nByte; + pMem.flags = MEM_Blob | MEM_Term; + pMem.enc = (enc == 0 ? SQLITE_UTF8 : enc); + pMem.type = (enc == 0 ? SQLITE_BLOB : SQLITE_TEXT); + + if (nByte > iLimit) { + return SQLITE_TOOBIG; + } + + return SQLITE_OK; } - pMem.xDel = xDel; - flags |= (u16)( ( xDel == SQLITE_STATIC ) ? MEM_Static : MEM_Dyn ); - } - pMem.n = nByte; - pMem.flags = flags; - pMem.enc = ( enc == 0 ? SQLITE_UTF8 : enc ); - pMem.type = ( enc == 0 ? SQLITE_BLOB : SQLITE_TEXT ); + + static int sqlite3VdbeMemSetStr( + Mem pMem, /* Memory cell to set to string value */ + string z, /* String pointer */ + int n, /* Bytes in string, or negative */ + u8 enc, /* Encoding of z. 0 for BLOBs */ + dxDel xDel /* Destructor function */ + ) { + return sqlite3VdbeMemSetStr(pMem, z, 0, n, enc, xDel); + } // Call w/o offset + + static int sqlite3VdbeMemSetStr( + Mem pMem, /* Memory cell to set to string value */ + string z, /* String pointer */ + int offset, /* offset into string */ + int n, /* Bytes in string, or negative */ + u8 enc, /* Encoding of z. 0 for BLOBs */ + dxDel xDel//)(void*)/* Destructor function */ + ) { + int nByte = n; /* New value for pMem->n */ + int iLimit; /* Maximum allowed string or blob size */ + u16 flags = 0; /* New value for pMem->flags */ + + Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); + Debug.Assert((pMem.flags & MEM_RowSet) == 0); + + /* If z is a NULL pointer, set pMem to contain an SQL NULL. */ + if (z == null || z.Length < offset) { + sqlite3VdbeMemSetNull(pMem); + return SQLITE_OK; + } + + if (pMem.db != null) { + iLimit = pMem.db.aLimit[SQLITE_LIMIT_LENGTH]; + } else { + iLimit = SQLITE_MAX_LENGTH; + } + flags = (u16)(enc == 0 ? MEM_Blob : MEM_Str); + if (nByte < 0) { + Debug.Assert(enc != 0); + if (enc == SQLITE_UTF8) { + for (nByte = 0; nByte <= iLimit && nByte < z.Length - offset && z[offset + nByte] != 0; nByte++) { + } + } else { + for (nByte = 0; nByte <= iLimit && z[nByte + offset] != 0 || z[offset + nByte + 1] != 0; nByte += 2) { + } + } + flags |= MEM_Term; + } + + /* The following block sets the new values of Mem.z and Mem.xDel. It + ** also sets a flag in local variable "flags" to indicate the memory + ** management (one of MEM_Dyn or MEM_Static). + */ + if (xDel == SQLITE_TRANSIENT) { + u32 nAlloc = (u32)nByte; + if ((flags & MEM_Term) != 0) { + nAlloc += (u32)(enc == SQLITE_UTF8 ? 1 : 2); + } + if (nByte > iLimit) { + return SQLITE_TOOBIG; + } + if (sqlite3VdbeMemGrow(pMem, (int)nAlloc, 0) != 0) { + return SQLITE_NOMEM; + } + //if ( nAlloc < z.Length ) + //pMem.z = new byte[nAlloc]; Buffer.BlockCopy( z, 0, pMem.z, 0, (int)nAlloc ); } + //else + if (enc == 0) { + pMem.z = null; + pMem.zBLOB = sqlite3Malloc(n); + for (int i = 0; i < n && i < z.Length - offset; i++) + pMem.zBLOB[i] = (byte)z[offset + i]; + } else { + pMem.z = n > 0 && z.Length - offset > n ? z.Substring(offset, n) : z.Substring(offset);//memcpy(pMem.z, z, nAlloc); + sqlite3_free(ref pMem.zBLOB); + } + } else if (xDel == SQLITE_DYNAMIC) { + sqlite3VdbeMemRelease(pMem); + //pMem.zMalloc = pMem.z = (char*)z; + if (enc == 0) { + pMem.z = null; + if (pMem.zBLOB != null) + sqlite3_free(ref pMem.zBLOB); + pMem.zBLOB = Encoding.UTF8.GetBytes(offset == 0 ? z : z.Length + offset < n ? z.Substring(offset, n) : z.Substring(offset)); + } else { + pMem.z = n > 0 && z.Length - offset > n ? z.Substring(offset, n) : z.Substring(offset);//memcpy(pMem.z, z, nAlloc); + sqlite3_free(ref pMem.zBLOB); + } + pMem.xDel = null; + } else { + sqlite3VdbeMemRelease(pMem); + if (enc == 0) { + pMem.z = null; + if (pMem.zBLOB != null) + sqlite3_free(ref pMem.zBLOB); + pMem.zBLOB = Encoding.UTF8.GetBytes(offset == 0 ? z : z.Length + offset < n ? z.Substring(offset, n) : z.Substring(offset)); + } else { + pMem.z = n > 0 && z.Length - offset > n ? z.Substring(offset, n) : z.Substring(offset);//memcpy(pMem.z, z, nAlloc); + sqlite3_free(ref pMem.zBLOB); + } + pMem.xDel = xDel; + flags |= (u16)((xDel == SQLITE_STATIC) ? MEM_Static : MEM_Dyn); + } + pMem.n = nByte; + pMem.flags = flags; + pMem.enc = (enc == 0 ? SQLITE_UTF8 : enc); + pMem.type = (enc == 0 ? SQLITE_BLOB : SQLITE_TEXT); #if !SQLITE_OMIT_UTF16 if( pMem.enc!=SQLITE_UTF8 && sqlite3VdbeMemHandleBom(pMem)!=0 ){ @@ -1094,514 +960,440 @@ static int sqlite3VdbeMemSetStr( } #endif - if ( nByte > iLimit ) - { - return SQLITE_TOOBIG; - } - - return SQLITE_OK; - } + if (nByte > iLimit) { + return SQLITE_TOOBIG; + } - /* - ** Compare the values contained by the two memory cells, returning - ** negative, zero or positive if pMem1 is less than, equal to, or greater - ** than pMem2. Sorting order is NULL's first, followed by numbers (integers - ** and reals) sorted numerically, followed by text ordered by the collating - ** sequence pColl and finally blob's ordered by memcmp(). - ** - ** Two NULL values are considered equal by this function. - */ - static int sqlite3MemCompare( Mem pMem1, Mem pMem2, CollSeq pColl ) - { - int rc; - int f1, f2; - int combined_flags; - - f1 = pMem1.flags; - f2 = pMem2.flags; - combined_flags = f1 | f2; - Debug.Assert( ( combined_flags & MEM_RowSet ) == 0 ); - - /* If one value is NULL, it is less than the other. If both values - ** are NULL, return 0. - */ - if ( ( combined_flags & MEM_Null ) != 0 ) - { - return ( f2 & MEM_Null ) - ( f1 & MEM_Null ); - } - - /* If one value is a number and the other is not, the number is less. - ** If both are numbers, compare as reals if one is a real, or as integers - ** if both values are integers. - */ - if ( ( combined_flags & ( MEM_Int | MEM_Real ) ) != 0 ) - { - if ( ( f1 & ( MEM_Int | MEM_Real ) ) == 0 ) - { - return 1; - } - if ( ( f2 & ( MEM_Int | MEM_Real ) ) == 0 ) - { - return -1; - } - if ( ( f1 & f2 & MEM_Int ) == 0 ) - { - double r1, r2; - if ( ( f1 & MEM_Real ) == 0 ) - { - r1 = (double)pMem1.u.i; - } - else - { - r1 = pMem1.r; - } - if ( ( f2 & MEM_Real ) == 0 ) - { - r2 = (double)pMem2.u.i; - } - else - { - r2 = pMem2.r; - } - if ( r1 < r2 ) - return -1; - if ( r1 > r2 ) - return 1; - return 0; - } - else - { - Debug.Assert( ( f1 & MEM_Int ) != 0 ); - Debug.Assert( ( f2 & MEM_Int ) != 0 ); - if ( pMem1.u.i < pMem2.u.i ) - return -1; - if ( pMem1.u.i > pMem2.u.i ) - return 1; - return 0; + return SQLITE_OK; } - } - /* If one value is a string and the other is a blob, the string is less. - ** If both are strings, compare using the collating functions. - */ - if ( ( combined_flags & MEM_Str ) != 0 ) - { - if ( ( f1 & MEM_Str ) == 0 ) - { - return 1; - } - if ( ( f2 & MEM_Str ) == 0 ) - { - return -1; + /* + ** Compare the values contained by the two memory cells, returning + ** negative, zero or positive if pMem1 is less than, equal to, or greater + ** than pMem2. Sorting order is NULL's first, followed by numbers (integers + ** and reals) sorted numerically, followed by text ordered by the collating + ** sequence pColl and finally blob's ordered by memcmp(). + ** + ** Two NULL values are considered equal by this function. + */ + static int sqlite3MemCompare(Mem pMem1, Mem pMem2, CollSeq pColl) { + int rc; + int f1, f2; + int combined_flags; + + f1 = pMem1.flags; + f2 = pMem2.flags; + combined_flags = f1 | f2; + Debug.Assert((combined_flags & MEM_RowSet) == 0); + + /* If one value is NULL, it is less than the other. If both values + ** are NULL, return 0. + */ + if ((combined_flags & MEM_Null) != 0) { + return (f2 & MEM_Null) - (f1 & MEM_Null); + } + + /* If one value is a number and the other is not, the number is less. + ** If both are numbers, compare as reals if one is a real, or as integers + ** if both values are integers. + */ + if ((combined_flags & (MEM_Int | MEM_Real)) != 0) { + if ((f1 & (MEM_Int | MEM_Real)) == 0) { + return 1; + } + if ((f2 & (MEM_Int | MEM_Real)) == 0) { + return -1; + } + if ((f1 & f2 & MEM_Int) == 0) { + double r1, r2; + if ((f1 & MEM_Real) == 0) { + r1 = (double)pMem1.u.i; + } else { + r1 = pMem1.r; + } + if ((f2 & MEM_Real) == 0) { + r2 = (double)pMem2.u.i; + } else { + r2 = pMem2.r; + } + if (r1 < r2) + return -1; + if (r1 > r2) + return 1; + return 0; + } else { + Debug.Assert((f1 & MEM_Int) != 0); + Debug.Assert((f2 & MEM_Int) != 0); + if (pMem1.u.i < pMem2.u.i) + return -1; + if (pMem1.u.i > pMem2.u.i) + return 1; + return 0; + } + } + + /* If one value is a string and the other is a blob, the string is less. + ** If both are strings, compare using the collating functions. + */ + if ((combined_flags & MEM_Str) != 0) { + if ((f1 & MEM_Str) == 0) { + return 1; + } + if ((f2 & MEM_Str) == 0) { + return -1; + } + + Debug.Assert(pMem1.enc == pMem2.enc); + Debug.Assert(pMem1.enc == SQLITE_UTF8 || + pMem1.enc == SQLITE_UTF16LE || pMem1.enc == SQLITE_UTF16BE); + + /* The collation sequence must be defined at this point, even if + ** the user deletes the collation sequence after the vdbe program is + ** compiled (this was not always the case). + */ + Debug.Assert(pColl == null || pColl.xCmp != null); + + if (pColl != null) { + if (pMem1.enc == pColl.enc) { + /* The strings are already in the correct encoding. Call the + ** comparison function directly */ + return pColl.xCmp(pColl.pUser, pMem1.n, pMem1.z, pMem2.n, pMem2.z); + } else { + string v1, v2; + int n1, n2; + Mem c1 = null; + Mem c2 = null; + + c1 = sqlite3Malloc(c1);// memset( &c1, 0, sizeof( c1 ) ); + c2 = sqlite3Malloc(c2);// memset( &c2, 0, sizeof( c2 ) ); + + sqlite3VdbeMemShallowCopy(c1, pMem1, MEM_Ephem); + sqlite3VdbeMemShallowCopy(c2, pMem2, MEM_Ephem); + v1 = sqlite3ValueText((sqlite3_value)c1, pColl.enc); + n1 = v1 == null ? 0 : c1.n; + v2 = sqlite3ValueText((sqlite3_value)c2, pColl.enc); + n2 = v2 == null ? 0 : c2.n; + rc = pColl.xCmp(pColl.pUser, n1, v1, n2, v2); + sqlite3VdbeMemRelease(c1); + sqlite3VdbeMemRelease(c2); + return rc; + } + } + /* If a NULL pointer was passed as the collate function, fall through + ** to the blob case and use memcmp(). */ + } + + /* Both values must be blobs. Compare using memcmp(). */ + if ((pMem1.flags & MEM_Blob) != 0) + if (pMem1.zBLOB != null) + rc = memcmp(pMem1.zBLOB, pMem2.zBLOB, (pMem1.n > pMem2.n) ? pMem2.n : pMem1.n); + else + rc = memcmp(pMem1.z, pMem2.zBLOB, (pMem1.n > pMem2.n) ? pMem2.n : pMem1.n); + else + rc = memcmp(pMem1.z, pMem2.z, (pMem1.n > pMem2.n) ? pMem2.n : pMem1.n); + if (rc == 0) { + rc = pMem1.n - pMem2.n; + } + return rc; } - Debug.Assert( pMem1.enc == pMem2.enc ); - Debug.Assert( pMem1.enc == SQLITE_UTF8 || - pMem1.enc == SQLITE_UTF16LE || pMem1.enc == SQLITE_UTF16BE ); - - /* The collation sequence must be defined at this point, even if - ** the user deletes the collation sequence after the vdbe program is - ** compiled (this was not always the case). + /* + ** Move data out of a btree key or data field and into a Mem structure. + ** The data or key is taken from the entry that pCur is currently pointing + ** to. offset and amt determine what portion of the data or key to retrieve. + ** key is true to get the key or false to get data. The result is written + ** into the pMem element. + ** + ** The pMem structure is assumed to be uninitialized. Any prior content + ** is overwritten without being freed. + ** + ** If this routine fails for any reason (malloc returns NULL or unable + ** to read from the disk) then the pMem is left in an inconsistent state. */ - Debug.Assert( pColl == null || pColl.xCmp != null ); - - if ( pColl != null ) - { - if ( pMem1.enc == pColl.enc ) - { - /* The strings are already in the correct encoding. Call the - ** comparison function directly */ - return pColl.xCmp( pColl.pUser, pMem1.n, pMem1.z, pMem2.n, pMem2.z ); - } - else - { - string v1, v2; - int n1, n2; - Mem c1 = null; - Mem c2 = null; - - c1 = sqlite3Malloc( c1 );// memset( &c1, 0, sizeof( c1 ) ); - c2 = sqlite3Malloc( c2 );// memset( &c2, 0, sizeof( c2 ) ); - - sqlite3VdbeMemShallowCopy( c1, pMem1, MEM_Ephem ); - sqlite3VdbeMemShallowCopy( c2, pMem2, MEM_Ephem ); - v1 = sqlite3ValueText( (sqlite3_value)c1, pColl.enc ); - n1 = v1 == null ? 0 : c1.n; - v2 = sqlite3ValueText( (sqlite3_value)c2, pColl.enc ); - n2 = v2 == null ? 0 : c2.n; - rc = pColl.xCmp( pColl.pUser, n1, v1, n2, v2 ); - sqlite3VdbeMemRelease( c1 ); - sqlite3VdbeMemRelease( c2 ); + static int sqlite3VdbeMemFromBtree( + BtCursor pCur, /* Cursor pointing at record to retrieve. */ + int offset, /* Offset from the start of data to return bytes from. */ + int amt, /* Number of bytes to return. */ + bool key, /* If true, retrieve from the btree key, not data. */ + Mem pMem /* OUT: Return data in this Mem structure. */ + ) { + byte[] zData; /* Data from the btree layer */ + int available = 0; /* Number of bytes available on the local btree page */ + int rc = SQLITE_OK; /* Return code */ + + Debug.Assert(sqlite3BtreeCursorIsValid(pCur)); + + /* Note: the calls to BtreeKeyFetch() and DataFetch() below assert() + ** that both the BtShared and database handle mutexes are held. */ + Debug.Assert((pMem.flags & MEM_RowSet) == 0); + int outOffset = -1; + if (key) { + zData = sqlite3BtreeKeyFetch(pCur, ref available, ref outOffset); + } else { + zData = sqlite3BtreeDataFetch(pCur, ref available, ref outOffset); + } + Debug.Assert(zData != null); + + if (offset + amt <= available && (pMem.flags & MEM_Dyn) == 0) { + sqlite3VdbeMemRelease(pMem); + pMem.zBLOB = sqlite3Malloc(amt); + Buffer.BlockCopy(zData, offset, pMem.zBLOB, 0, amt);//pMem.z = &zData[offset]; + pMem.flags = MEM_Blob | MEM_Ephem; + } else if (SQLITE_OK == (rc = sqlite3VdbeMemGrow(pMem, amt + 2, 0))) { + pMem.enc = 0; + pMem.type = SQLITE_BLOB; + pMem.z = null; + pMem.zBLOB = sqlite3Malloc(amt); + pMem.flags = MEM_Blob | MEM_Dyn | MEM_Term; + if (key) { + rc = sqlite3BtreeKey(pCur, (u32)offset, (u32)amt, pMem.zBLOB); + } else { + rc = sqlite3BtreeData(pCur, (u32)offset, (u32)amt, pMem.zBLOB);//pMem.z = pMem_z ; + } + //pMem.z[amt] = 0; + //pMem.z[amt+1] = 0; + if (rc != SQLITE_OK) { + sqlite3VdbeMemRelease(pMem); + } + } + pMem.n = amt; + sqlite3_free(ref zData); + return rc; - } } - /* If a NULL pointer was passed as the collate function, fall through - ** to the blob case and use memcmp(). */ - } - - /* Both values must be blobs. Compare using memcmp(). */ - if ( ( pMem1.flags & MEM_Blob ) != 0 ) - if ( pMem1.zBLOB != null ) - rc = memcmp( pMem1.zBLOB, pMem2.zBLOB, ( pMem1.n > pMem2.n ) ? pMem2.n : pMem1.n ); - else - rc = memcmp( pMem1.z, pMem2.zBLOB, ( pMem1.n > pMem2.n ) ? pMem2.n : pMem1.n ); - else - rc = memcmp( pMem1.z, pMem2.z, ( pMem1.n > pMem2.n ) ? pMem2.n : pMem1.n ); - if ( rc == 0 ) - { - rc = pMem1.n - pMem2.n; - } - return rc; - } - /* - ** Move data out of a btree key or data field and into a Mem structure. - ** The data or key is taken from the entry that pCur is currently pointing - ** to. offset and amt determine what portion of the data or key to retrieve. - ** key is true to get the key or false to get data. The result is written - ** into the pMem element. - ** - ** The pMem structure is assumed to be uninitialized. Any prior content - ** is overwritten without being freed. - ** - ** If this routine fails for any reason (malloc returns NULL or unable - ** to read from the disk) then the pMem is left in an inconsistent state. - */ - static int sqlite3VdbeMemFromBtree( - BtCursor pCur, /* Cursor pointing at record to retrieve. */ - int offset, /* Offset from the start of data to return bytes from. */ - int amt, /* Number of bytes to return. */ - bool key, /* If true, retrieve from the btree key, not data. */ - Mem pMem /* OUT: Return data in this Mem structure. */ - ) - { - byte[] zData; /* Data from the btree layer */ - int available = 0; /* Number of bytes available on the local btree page */ - int rc = SQLITE_OK; /* Return code */ - - Debug.Assert( sqlite3BtreeCursorIsValid( pCur ) ); - - /* Note: the calls to BtreeKeyFetch() and DataFetch() below assert() - ** that both the BtShared and database handle mutexes are held. */ - Debug.Assert( ( pMem.flags & MEM_RowSet ) == 0 ); - int outOffset = -1; - if ( key ) - { - zData = sqlite3BtreeKeyFetch( pCur, ref available, ref outOffset ); - } - else - { - zData = sqlite3BtreeDataFetch( pCur, ref available, ref outOffset ); - } - Debug.Assert( zData != null ); - - if ( offset + amt <= available && ( pMem.flags & MEM_Dyn ) == 0 ) - { - sqlite3VdbeMemRelease( pMem ); - pMem.zBLOB = sqlite3Malloc( amt ); - Buffer.BlockCopy( zData, offset, pMem.zBLOB, 0, amt );//pMem.z = &zData[offset]; - pMem.flags = MEM_Blob | MEM_Ephem; - } - else if ( SQLITE_OK == ( rc = sqlite3VdbeMemGrow( pMem, amt + 2, 0 ) ) ) - { - pMem.enc = 0; - pMem.type = SQLITE_BLOB; - pMem.z = null; - pMem.zBLOB = sqlite3Malloc( amt ); - pMem.flags = MEM_Blob | MEM_Dyn | MEM_Term; - if ( key ) - { - rc = sqlite3BtreeKey( pCur, (u32)offset, (u32)amt, pMem.zBLOB ); - } - else - { - rc = sqlite3BtreeData( pCur, (u32)offset, (u32)amt, pMem.zBLOB );//pMem.z = pMem_z ; - } - //pMem.z[amt] = 0; - //pMem.z[amt+1] = 0; - if ( rc != SQLITE_OK ) - { - sqlite3VdbeMemRelease( pMem ); + /* This function is only available internally, it is not part of the + ** external API. It works in a similar way to sqlite3_value_text(), + ** except the data returned is in the encoding specified by the second + ** parameter, which must be one of SQLITE_UTF16BE, SQLITE_UTF16LE or + ** SQLITE_UTF8. + ** + ** (2006-02-16:) The enc value can be or-ed with SQLITE_UTF16_ALIGNED. + ** If that is the case, then the result must be aligned on an even byte + ** boundary. + */ + static string sqlite3ValueText(sqlite3_value pVal, int enc) { + if (pVal == null) + return null; + + Debug.Assert(pVal.db == null || sqlite3_mutex_held(pVal.db.mutex)); + Debug.Assert((enc & 3) == (enc & ~SQLITE_UTF16_ALIGNED)); + Debug.Assert((pVal.flags & MEM_RowSet) == 0); + + if ((pVal.flags & MEM_Null) != 0) { + return null; + } + Debug.Assert((MEM_Blob >> 3) == MEM_Str); + pVal.flags |= (u16)((pVal.flags & MEM_Blob) >> 3); + if ((pVal.flags & MEM_Zero) != 0) + sqlite3VdbeMemExpandBlob(pVal); // expandBlob(pVal); + if ((pVal.flags & MEM_Str) != 0) { + if (sqlite3VdbeChangeEncoding(pVal, enc & ~SQLITE_UTF16_ALIGNED) != SQLITE_OK) { + return null; // Encoding Error + } + if ((enc & SQLITE_UTF16_ALIGNED) != 0 && 1 == (1 & (pVal.z[0]))) //1==(1&SQLITE_PTR_TO_INT(pVal.z)) + { + Debug.Assert((pVal.flags & (MEM_Ephem | MEM_Static)) != 0); + if (sqlite3VdbeMemMakeWriteable(pVal) != SQLITE_OK) { + return null; + } + } + sqlite3VdbeMemNulTerminate(pVal); /* IMP: R-59893-45467 */ + } else { + Debug.Assert((pVal.flags & MEM_Blob) == 0); + sqlite3VdbeMemStringify(pVal, enc); + // assert( 0==(1&SQLITE_PTR_TO_INT(pVal->z)) ); + } + Debug.Assert(pVal.enc == (enc & ~SQLITE_UTF16_ALIGNED) || pVal.db == null + //|| pVal.db.mallocFailed != 0 + ); + if (pVal.enc == (enc & ~SQLITE_UTF16_ALIGNED)) { + return pVal.z; + } else { + return null; + } } - } - pMem.n = amt; - sqlite3_free( ref zData ); - return rc; - } - - /* This function is only available internally, it is not part of the - ** external API. It works in a similar way to sqlite3_value_text(), - ** except the data returned is in the encoding specified by the second - ** parameter, which must be one of SQLITE_UTF16BE, SQLITE_UTF16LE or - ** SQLITE_UTF8. - ** - ** (2006-02-16:) The enc value can be or-ed with SQLITE_UTF16_ALIGNED. - ** If that is the case, then the result must be aligned on an even byte - ** boundary. - */ - static string sqlite3ValueText( sqlite3_value pVal, int enc ) - { - if ( pVal == null ) - return null; - - Debug.Assert( pVal.db == null || sqlite3_mutex_held( pVal.db.mutex ) ); - Debug.Assert( ( enc & 3 ) == ( enc & ~SQLITE_UTF16_ALIGNED ) ); - Debug.Assert( ( pVal.flags & MEM_RowSet ) == 0 ); - - if ( ( pVal.flags & MEM_Null ) != 0 ) - { - return null; - } - Debug.Assert( ( MEM_Blob >> 3 ) == MEM_Str ); - pVal.flags |= (u16)( ( pVal.flags & MEM_Blob ) >> 3 ); - if ( ( pVal.flags & MEM_Zero ) != 0 ) - sqlite3VdbeMemExpandBlob( pVal ); // expandBlob(pVal); - if ( ( pVal.flags & MEM_Str ) != 0 ) - { - if ( sqlite3VdbeChangeEncoding( pVal, enc & ~SQLITE_UTF16_ALIGNED ) != SQLITE_OK ) - { - return null; // Encoding Error - } - if ( ( enc & SQLITE_UTF16_ALIGNED ) != 0 && 1 == ( 1 & ( pVal.z[0] ) ) ) //1==(1&SQLITE_PTR_TO_INT(pVal.z)) - { - Debug.Assert( ( pVal.flags & ( MEM_Ephem | MEM_Static ) ) != 0 ); - if ( sqlite3VdbeMemMakeWriteable( pVal ) != SQLITE_OK ) - { - return null; - } + /* + ** Create a new sqlite3_value object. + */ + static sqlite3_value sqlite3ValueNew(sqlite3 db) { + Mem p = null; + p = sqlite3DbMallocZero(db, p); + //if ( p != null ) + //{ + p.flags = MEM_Null; + p.type = SQLITE_NULL; + p.db = db; + //} + return p; } - sqlite3VdbeMemNulTerminate( pVal ); /* IMP: R-59893-45467 */ - } - else - { - Debug.Assert( ( pVal.flags & MEM_Blob ) == 0 ); - sqlite3VdbeMemStringify( pVal, enc ); - // assert( 0==(1&SQLITE_PTR_TO_INT(pVal->z)) ); - } - Debug.Assert( pVal.enc == ( enc & ~SQLITE_UTF16_ALIGNED ) || pVal.db == null - //|| pVal.db.mallocFailed != 0 - ); - if ( pVal.enc == ( enc & ~SQLITE_UTF16_ALIGNED ) ) - { - return pVal.z; - } - else - { - return null; - } - } - - /* - ** Create a new sqlite3_value object. - */ - static sqlite3_value sqlite3ValueNew( sqlite3 db ) - { - Mem p = null; - p = sqlite3DbMallocZero( db, p ); - //if ( p != null ) - //{ - p.flags = MEM_Null; - p.type = SQLITE_NULL; - p.db = db; - //} - return p; - } - /* - ** Create a new sqlite3_value object, containing the value of pExpr. - ** - ** This only works for very simple expressions that consist of one constant - ** token (i.e. "5", "5.1", "'a string'"). If the expression can - ** be converted directly into a value, then the value is allocated and - ** a pointer written to ppVal. The caller is responsible for deallocating - ** the value by passing it to sqlite3ValueFree() later on. If the expression - ** cannot be converted to a value, then ppVal is set to NULL. - */ - static int sqlite3ValueFromExpr( - sqlite3 db, /* The database connection */ - Expr pExpr, /* The expression to evaluate */ - int enc, /* Encoding to use */ - char affinity, /* Affinity to use */ - ref sqlite3_value ppVal /* Write the new value here */ - ) - { - int op; - string zVal = ""; - sqlite3_value pVal = null; - int negInt = 1; - string zNeg = ""; - - if ( pExpr == null ) - { - ppVal = null; - return SQLITE_OK; - } - op = pExpr.op; - - /* op can only be TK_REGISTER if we have compiled with SQLITE_ENABLE_STAT2. - ** The ifdef here is to enable us to achieve 100% branch test coverage even - ** when SQLITE_ENABLE_STAT2 is omitted. - */ + /* + ** Create a new sqlite3_value object, containing the value of pExpr. + ** + ** This only works for very simple expressions that consist of one constant + ** token (i.e. "5", "5.1", "'a string'"). If the expression can + ** be converted directly into a value, then the value is allocated and + ** a pointer written to ppVal. The caller is responsible for deallocating + ** the value by passing it to sqlite3ValueFree() later on. If the expression + ** cannot be converted to a value, then ppVal is set to NULL. + */ + static int sqlite3ValueFromExpr( + sqlite3 db, /* The database connection */ + Expr pExpr, /* The expression to evaluate */ + int enc, /* Encoding to use */ + char affinity, /* Affinity to use */ + ref sqlite3_value ppVal /* Write the new value here */ + ) { + int op; + string zVal = ""; + sqlite3_value pVal = null; + int negInt = 1; + string zNeg = ""; + + if (pExpr == null) { + ppVal = null; + return SQLITE_OK; + } + op = pExpr.op; + + /* op can only be TK_REGISTER if we have compiled with SQLITE_ENABLE_STAT2. + ** The ifdef here is to enable us to achieve 100% branch test coverage even + ** when SQLITE_ENABLE_STAT2 is omitted. + */ #if SQLITE_ENABLE_STAT2 if ( op == TK_REGISTER ) op = pExpr.op2; #else -if( NEVER(op==TK_REGISTER) ) op = pExpr.op2; + if (NEVER(op == TK_REGISTER)) op = pExpr.op2; #endif - /* Handle negative integers in a single step. This is needed in the -** case when the value is -9223372036854775808. -*/ - if ( op == TK_UMINUS - && ( pExpr.pLeft.op == TK_INTEGER || pExpr.pLeft.op == TK_FLOAT ) ) - { - pExpr = pExpr.pLeft; - op = pExpr.op; - negInt = -1; - zNeg = "-"; - } - - if ( op == TK_STRING || op == TK_FLOAT || op == TK_INTEGER ) - { - pVal = sqlite3ValueNew( db ); - if ( pVal == null ) - goto no_mem; - if ( ExprHasProperty( pExpr, EP_IntValue ) ) - { - sqlite3VdbeMemSetInt64( pVal, (i64)pExpr.u.iValue * negInt ); - } - else - { - zVal = sqlite3MPrintf( db, "%s%s", zNeg, pExpr.u.zToken ); - //if ( zVal == null ) goto no_mem; - sqlite3ValueSetStr( pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC ); - if ( op == TK_FLOAT ) - pVal.type = SQLITE_FLOAT; - } - if ( ( op == TK_INTEGER || op == TK_FLOAT ) && affinity == SQLITE_AFF_NONE ) - { - sqlite3ValueApplyAffinity( pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8 ); - } - else - { - sqlite3ValueApplyAffinity( pVal, affinity, SQLITE_UTF8 ); - } - if ( ( pVal.flags & ( MEM_Int | MEM_Real ) ) != 0 ) - pVal.flags = (ushort)( pVal.flags & ~MEM_Str ); - if ( enc != SQLITE_UTF8 ) - { - sqlite3VdbeChangeEncoding( pVal, enc ); - } - } - if ( enc != SQLITE_UTF8 ) - { - sqlite3VdbeChangeEncoding( pVal, enc ); - } - else if ( op == TK_UMINUS ) - { - /* This branch happens for multiple negative signs. Ex: -(-5) */ - if ( SQLITE_OK == sqlite3ValueFromExpr( db, pExpr.pLeft, enc, affinity, ref pVal ) ) - { - sqlite3VdbeMemNumerify( pVal ); - if ( pVal.u.i == SMALLEST_INT64 ) - { - pVal.flags &= MEM_Int; - pVal.flags |= MEM_Real; - pVal.r = (double)LARGEST_INT64; - } - else - { - pVal.u.i = -pVal.u.i; - } - pVal.r = -pVal.r; - sqlite3ValueApplyAffinity( pVal, affinity, enc ); - } - } - else if ( op == TK_NULL ) - { - pVal = sqlite3ValueNew( db ); - if ( pVal == null) - goto no_mem; - } + /* Handle negative integers in a single step. This is needed in the + ** case when the value is -9223372036854775808. + */ + if (op == TK_UMINUS + && (pExpr.pLeft.op == TK_INTEGER || pExpr.pLeft.op == TK_FLOAT)) { + pExpr = pExpr.pLeft; + op = pExpr.op; + negInt = -1; + zNeg = "-"; + } + + if (op == TK_STRING || op == TK_FLOAT || op == TK_INTEGER) { + pVal = sqlite3ValueNew(db); + if (pVal == null) + goto no_mem; + if (ExprHasProperty(pExpr, EP_IntValue)) { + sqlite3VdbeMemSetInt64(pVal, (i64)pExpr.u.iValue * negInt); + } else { + zVal = sqlite3MPrintf(db, "%s%s", zNeg, pExpr.u.zToken); + //if ( zVal == null ) goto no_mem; + sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC); + if (op == TK_FLOAT) + pVal.type = SQLITE_FLOAT; + } + if ((op == TK_INTEGER || op == TK_FLOAT) && affinity == SQLITE_AFF_NONE) { + sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8); + } else { + sqlite3ValueApplyAffinity(pVal, affinity, SQLITE_UTF8); + } + if ((pVal.flags & (MEM_Int | MEM_Real)) != 0) + pVal.flags = (ushort)(pVal.flags & ~MEM_Str); + if (enc != SQLITE_UTF8) { + sqlite3VdbeChangeEncoding(pVal, enc); + } + } + if (enc != SQLITE_UTF8) { + sqlite3VdbeChangeEncoding(pVal, enc); + } else if (op == TK_UMINUS) { + /* This branch happens for multiple negative signs. Ex: -(-5) */ + if (SQLITE_OK == sqlite3ValueFromExpr(db, pExpr.pLeft, enc, affinity, ref pVal)) { + sqlite3VdbeMemNumerify(pVal); + if (pVal.u.i == SMALLEST_INT64) { + pVal.flags &= MEM_Int; + pVal.flags |= MEM_Real; + pVal.r = (double)LARGEST_INT64; + } else { + pVal.u.i = -pVal.u.i; + } + pVal.r = -pVal.r; + sqlite3ValueApplyAffinity(pVal, affinity, enc); + } + } else if (op == TK_NULL) { + pVal = sqlite3ValueNew(db); + if (pVal == null) + goto no_mem; + } #if !SQLITE_OMIT_BLOB_LITERAL - else if ( op == TK_BLOB ) - { - int nVal; - Debug.Assert( pExpr.u.zToken[0] == 'x' || pExpr.u.zToken[0] == 'X' ); - Debug.Assert( pExpr.u.zToken[1] == '\'' ); - pVal = sqlite3ValueNew( db ); - if ( null == pVal ) - goto no_mem; - zVal = pExpr.u.zToken.Substring( 2 ); - nVal = sqlite3Strlen30( zVal ) - 1; - Debug.Assert( zVal[nVal] == '\'' ); - byte[] blob = sqlite3HexToBlob( db, zVal, nVal ); - sqlite3VdbeMemSetStr( pVal, Encoding.UTF8.GetString( blob, 0, blob.Length ), nVal / 2, 0, SQLITE_DYNAMIC ); - } + else if (op == TK_BLOB) { + int nVal; + Debug.Assert(pExpr.u.zToken[0] == 'x' || pExpr.u.zToken[0] == 'X'); + Debug.Assert(pExpr.u.zToken[1] == '\''); + pVal = sqlite3ValueNew(db); + if (null == pVal) + goto no_mem; + zVal = pExpr.u.zToken.Substring(2); + nVal = sqlite3Strlen30(zVal) - 1; + Debug.Assert(zVal[nVal] == '\''); + byte[] blob = sqlite3HexToBlob(db, zVal, nVal); + sqlite3VdbeMemSetStr(pVal, Encoding.UTF8.GetString(blob, 0, blob.Length), nVal / 2, 0, SQLITE_DYNAMIC); + } #endif - if ( pVal != null ) - { - sqlite3VdbeMemStoreType( pVal ); - } + if (pVal != null) { + sqlite3VdbeMemStoreType(pVal); + } - ppVal = pVal; - return SQLITE_OK; + ppVal = pVal; + return SQLITE_OK; -no_mem: - //db.mallocFailed = 1; - sqlite3DbFree( db, ref zVal ); - pVal = null;// sqlite3ValueFree(pVal); - ppVal = null; - return SQLITE_NOMEM; - } - - /* - ** Change the string value of an sqlite3_value object - */ - static void sqlite3ValueSetStr( - sqlite3_value v, /* Value to be set */ - int n, /* Length of string z */ - string z, /* Text of the new string */ - u8 enc, /* Encoding to use */ - dxDel xDel//)(void*) /* Destructor for the string */ - ) - { - if ( v != null ) - sqlite3VdbeMemSetStr( v, z, n, enc, xDel ); - } + no_mem: + //db.mallocFailed = 1; + sqlite3DbFree(db, ref zVal); + pVal = null;// sqlite3ValueFree(pVal); + ppVal = null; + return SQLITE_NOMEM; + } - /* - ** Free an sqlite3_value object - */ - static void sqlite3ValueFree( ref sqlite3_value v ) - { - if ( v == null ) - return; - sqlite3VdbeMemRelease( v ); - sqlite3DbFree( v.db, ref v ); - } + /* + ** Change the string value of an sqlite3_value object + */ + static void sqlite3ValueSetStr( + sqlite3_value v, /* Value to be set */ + int n, /* Length of string z */ + string z, /* Text of the new string */ + u8 enc, /* Encoding to use */ + dxDel xDel//)(void*) /* Destructor for the string */ + ) { + if (v != null) + sqlite3VdbeMemSetStr(v, z, n, enc, xDel); + } - /* - ** Return the number of bytes in the sqlite3_value object assuming - ** that it uses the encoding "enc" - */ - static int sqlite3ValueBytes( sqlite3_value pVal, int enc ) - { - Mem p = (Mem)pVal; - if ( ( p.flags & MEM_Blob ) != 0 || sqlite3ValueText( pVal, enc ) != null ) - { - if ( ( p.flags & MEM_Zero ) != 0 ) - { - return p.n + p.u.nZero; + /* + ** Free an sqlite3_value object + */ + static void sqlite3ValueFree(ref sqlite3_value v) { + if (v == null) + return; + sqlite3VdbeMemRelease(v); + sqlite3DbFree(v.db, ref v); } - else - { - return p.z == null ? p.zBLOB.Length : p.n; + + /* + ** Return the number of bytes in the sqlite3_value object assuming + ** that it uses the encoding "enc" + */ + static int sqlite3ValueBytes(sqlite3_value pVal, int enc) { + Mem p = (Mem)pVal; + if ((p.flags & MEM_Blob) != 0 || sqlite3ValueText(pVal, enc) != null) { + if ((p.flags & MEM_Zero) != 0) { + return p.n + p.u.nZero; + } else { + return p.z == null ? p.zBLOB.Length : p.n; + } + } + return 0; } - } - return 0; } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/vdbetrace_c.cs b/Src/IronPython.SQLite/c#sqlite/vdbetrace_c.cs index 0431f52ba..523ef9d14 100644 --- a/Src/IronPython.SQLite/c#sqlite/vdbetrace_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/vdbetrace_c.cs @@ -1,170 +1,139 @@ -using System; using System.Diagnostics; -using System.Text; -using Bitmask = System.UInt64; -using u8 = System.Byte; -using u16 = System.UInt16; -using u32 = System.UInt32; - -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 2009 November 25 - ** - ** 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 contains code used to insert the values of host parameters - ** (aka "wildcards") into the SQL text output by sqlite3_trace(). - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include "vdbeInt.h" +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2009 November 25 + ** + ** 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 contains code used to insert the values of host parameters + ** (aka "wildcards") into the SQL text output by sqlite3_trace(). + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include "vdbeInt.h" #if !SQLITE_OMIT_TRACE - /* -** zSql is a zero-terminated string of UTF-8 SQL text. Return the number of -** bytes in this text up to but excluding the first character in -** a host parameter. If the text contains no host parameters, return -** the total number of bytes in the text. -*/ - static int findNextHostParameter( string zSql, int iOffset, ref int pnToken ) - { - int tokenType = 0; - int nTotal = 0; - int n; + /* + ** zSql is a zero-terminated string of UTF-8 SQL text. Return the number of + ** bytes in this text up to but excluding the first character in + ** a host parameter. If the text contains no host parameters, return + ** the total number of bytes in the text. + */ + static int findNextHostParameter(string zSql, int iOffset, ref int pnToken) { + int tokenType = 0; + int nTotal = 0; + int n; - pnToken = 0; - while ( iOffset < zSql.Length ) - { - n = sqlite3GetToken( zSql, iOffset, ref tokenType ); - Debug.Assert( n > 0 && tokenType != TK_ILLEGAL ); - if ( tokenType == TK_VARIABLE ) - { - pnToken = n; - break; + pnToken = 0; + while (iOffset < zSql.Length) { + n = sqlite3GetToken(zSql, iOffset, ref tokenType); + Debug.Assert(n > 0 && tokenType != TK_ILLEGAL); + if (tokenType == TK_VARIABLE) { + pnToken = n; + break; + } + nTotal += n; + iOffset += n;// zSql += n; + } + return nTotal; } - nTotal += n; - iOffset += n;// zSql += n; - } - return nTotal; - } - /* - ** This function returns a pointer to a nul-terminated string in memory - ** obtained from sqlite3DbMalloc(). If sqlite3.vdbeExecCnt is 1, then the - ** string contains a copy of zRawSql but with host parameters expanded to - ** their current bindings. Or, if sqlite3.vdbeExecCnt is greater than 1, - ** then the returned string holds a copy of zRawSql with "-- " prepended - ** to each line of text. - ** - ** The calling function is responsible for making sure the memory returned - ** is eventually freed. - ** - ** ALGORITHM: Scan the input string looking for host parameters in any of - ** these forms: ?, ?N, $A, @A, :A. Take care to avoid text within - ** string literals, quoted identifier names, and comments. For text forms, - ** the host parameter index is found by scanning the perpared - ** statement for the corresponding OP_Variable opcode. Once the host - ** parameter index is known, locate the value in p->aVar[]. Then render - ** the value as a literal in place of the host parameter name. - */ - static string sqlite3VdbeExpandSql( - Vdbe p, /* The prepared statement being evaluated */ - string zRawSql /* Raw text of the SQL statement */ - ) - { - sqlite3 db; /* The database connection */ - int idx = 0; /* Index of a host parameter */ - int nextIndex = 1; /* Index of next ? host parameter */ - int n; /* Length of a token prefix */ - int nToken = 0; /* Length of the parameter token */ - int i; /* Loop counter */ - Mem pVar; /* Value of a host parameter */ - StrAccum _out = new StrAccum( 1000 ); /* Accumulate the _output here */ - int izRawSql = 0; + /* + ** This function returns a pointer to a nul-terminated string in memory + ** obtained from sqlite3DbMalloc(). If sqlite3.vdbeExecCnt is 1, then the + ** string contains a copy of zRawSql but with host parameters expanded to + ** their current bindings. Or, if sqlite3.vdbeExecCnt is greater than 1, + ** then the returned string holds a copy of zRawSql with "-- " prepended + ** to each line of text. + ** + ** The calling function is responsible for making sure the memory returned + ** is eventually freed. + ** + ** ALGORITHM: Scan the input string looking for host parameters in any of + ** these forms: ?, ?N, $A, @A, :A. Take care to avoid text within + ** string literals, quoted identifier names, and comments. For text forms, + ** the host parameter index is found by scanning the perpared + ** statement for the corresponding OP_Variable opcode. Once the host + ** parameter index is known, locate the value in p->aVar[]. Then render + ** the value as a literal in place of the host parameter name. + */ + static string sqlite3VdbeExpandSql( + Vdbe p, /* The prepared statement being evaluated */ + string zRawSql /* Raw text of the SQL statement */ + ) { + sqlite3 db; /* The database connection */ + int idx = 0; /* Index of a host parameter */ + int nextIndex = 1; /* Index of next ? host parameter */ + int n; /* Length of a token prefix */ + int nToken = 0; /* Length of the parameter token */ + int i; /* Loop counter */ + Mem pVar; /* Value of a host parameter */ + StrAccum _out = new StrAccum(1000); /* Accumulate the _output here */ + int izRawSql = 0; - db = p.db; - sqlite3StrAccumInit( _out, null, 100, - db.aLimit[SQLITE_LIMIT_LENGTH] ); - _out.db = db; - if ( db.vdbeExecCnt > 1 ) - { - while ( izRawSql < zRawSql.Length ) - { - //string zStart = zRawSql; - while ( zRawSql[izRawSql++] != '\n' && izRawSql < zRawSql.Length ) - ; - sqlite3StrAccumAppend( _out, "-- ", 3 ); - sqlite3StrAccumAppend( _out, zRawSql, (int)izRawSql );//zRawSql - zStart ); - } - } - else - { - while ( izRawSql < zRawSql.Length ) - { - n = findNextHostParameter( zRawSql, izRawSql, ref nToken ); - Debug.Assert( n > 0 ); - sqlite3StrAccumAppend( _out, zRawSql.Substring( izRawSql, n ), n ); - izRawSql += n; - Debug.Assert( izRawSql < zRawSql.Length || nToken == 0 ); - if ( nToken == 0 ) - break; - if ( zRawSql[izRawSql] == '?' ) - { - if ( nToken > 1 ) - { - Debug.Assert( sqlite3Isdigit( zRawSql[izRawSql + 1] ) ); - sqlite3GetInt32( zRawSql, izRawSql + 1, ref idx ); - } - else - { - idx = nextIndex; - } - } - else - { - Debug.Assert( zRawSql[izRawSql] == ':' || zRawSql[izRawSql] == '$' || zRawSql[izRawSql] == '@' ); - testcase( zRawSql[izRawSql] == ':' ); - testcase( zRawSql[izRawSql] == '$' ); - testcase( zRawSql[izRawSql] == '@' ); - idx = sqlite3VdbeParameterIndex( p, zRawSql.Substring( izRawSql, nToken ), nToken ); - Debug.Assert( idx > 0 ); - } - izRawSql += nToken; - nextIndex = idx + 1; - Debug.Assert( idx > 0 && idx <= p.nVar ); - pVar = p.aVar[idx - 1]; - if ( ( pVar.flags & MEM_Null ) != 0 ) - { - sqlite3StrAccumAppend( _out, "NULL", 4 ); - } - else if ( ( pVar.flags & MEM_Int ) != 0 ) - { - sqlite3XPrintf( _out, "%lld", pVar.u.i ); - } - else if ( ( pVar.flags & MEM_Real ) != 0 ) - { - sqlite3XPrintf( _out, "%!.15g", pVar.r ); - } - else if ( ( pVar.flags & MEM_Str ) != 0 ) - { + db = p.db; + sqlite3StrAccumInit(_out, null, 100, + db.aLimit[SQLITE_LIMIT_LENGTH]); + _out.db = db; + if (db.vdbeExecCnt > 1) { + while (izRawSql < zRawSql.Length) { + //string zStart = zRawSql; + while (zRawSql[izRawSql++] != '\n' && izRawSql < zRawSql.Length) + ; + sqlite3StrAccumAppend(_out, "-- ", 3); + sqlite3StrAccumAppend(_out, zRawSql, (int)izRawSql);//zRawSql - zStart ); + } + } else { + while (izRawSql < zRawSql.Length) { + n = findNextHostParameter(zRawSql, izRawSql, ref nToken); + Debug.Assert(n > 0); + sqlite3StrAccumAppend(_out, zRawSql.Substring(izRawSql, n), n); + izRawSql += n; + Debug.Assert(izRawSql < zRawSql.Length || nToken == 0); + if (nToken == 0) + break; + if (zRawSql[izRawSql] == '?') { + if (nToken > 1) { + Debug.Assert(sqlite3Isdigit(zRawSql[izRawSql + 1])); + sqlite3GetInt32(zRawSql, izRawSql + 1, ref idx); + } else { + idx = nextIndex; + } + } else { + Debug.Assert(zRawSql[izRawSql] == ':' || zRawSql[izRawSql] == '$' || zRawSql[izRawSql] == '@'); + testcase(zRawSql[izRawSql] == ':'); + testcase(zRawSql[izRawSql] == '$'); + testcase(zRawSql[izRawSql] == '@'); + idx = sqlite3VdbeParameterIndex(p, zRawSql.Substring(izRawSql, nToken), nToken); + Debug.Assert(idx > 0); + } + izRawSql += nToken; + nextIndex = idx + 1; + Debug.Assert(idx > 0 && idx <= p.nVar); + pVar = p.aVar[idx - 1]; + if ((pVar.flags & MEM_Null) != 0) { + sqlite3StrAccumAppend(_out, "NULL", 4); + } else if ((pVar.flags & MEM_Int) != 0) { + sqlite3XPrintf(_out, "%lld", pVar.u.i); + } else if ((pVar.flags & MEM_Real) != 0) { + sqlite3XPrintf(_out, "%!.15g", pVar.r); + } else if ((pVar.flags & MEM_Str) != 0) { #if !SQLITE_OMIT_UTF16 u8 enc = ENC(db); if( enc!=SQLITE_UTF8 ){ @@ -177,29 +146,24 @@ string zRawSql /* Raw text of the SQL statement */ sqlite3VdbeMemRelease(&utf8); }else #endif - { - sqlite3XPrintf( _out, "'%.*q'", pVar.n, pVar.z ); + { + sqlite3XPrintf(_out, "'%.*q'", pVar.n, pVar.z); + } + } else if ((pVar.flags & MEM_Zero) != 0) { + sqlite3XPrintf(_out, "zeroblob(%d)", pVar.u.nZero); + } else { + Debug.Assert((pVar.flags & MEM_Blob) != 0); + sqlite3StrAccumAppend(_out, "x'", 2); + for (i = 0; i < pVar.n; i++) { + sqlite3XPrintf(_out, "%02x", pVar.zBLOB[i] & 0xff); + } + sqlite3StrAccumAppend(_out, "'", 1); + } + } } - } - else if ( ( pVar.flags & MEM_Zero ) != 0 ) - { - sqlite3XPrintf( _out, "zeroblob(%d)", pVar.u.nZero ); - } - else - { - Debug.Assert( ( pVar.flags & MEM_Blob ) != 0 ); - sqlite3StrAccumAppend( _out, "x'", 2 ); - for ( i = 0; i < pVar.n; i++ ) - { - sqlite3XPrintf( _out, "%02x", pVar.zBLOB[i] & 0xff ); - } - sqlite3StrAccumAppend( _out, "'", 1 ); - } + return sqlite3StrAccumFinish(_out); } - } - return sqlite3StrAccumFinish( _out ); - } #endif //* #if !SQLITE_OMIT_TRACE */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/vtab_c.cs b/Src/IronPython.SQLite/c#sqlite/vtab_c.cs index 940cebf0a..73e22118e 100644 --- a/Src/IronPython.SQLite/c#sqlite/vtab_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/vtab_c.cs @@ -2,356 +2,326 @@ using System.Diagnostics; using System.Text; -using u8 = System.Byte; - -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 2006 June 10 - ** - ** 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 contains code used to help implement virtual tables. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2006 June 10 + ** + ** 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 contains code used to help implement virtual tables. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ #if !SQLITE_OMIT_VIRTUALTABLE - //#include "sqliteInt.h" - - /* - ** Before a virtual table xCreate() or xConnect() method is invoked, the - ** sqlite3.pVtabCtx member variable is set to point to an instance of - ** this struct allocated on the stack. It is used by the implementation of - ** the sqlite3_declare_vtab() and sqlite3_vtab_config() APIs, both of which - ** are invoked only from within xCreate and xConnect methods. - */ - public class VtabCtx - { - public Table pTab; - public VTable pVTable; - }; - - /* - ** The actual function that does the work of creating a new module. - ** This function implements the sqlite3_create_module() and - ** sqlite3_create_module_v2() interfaces. - */ - static int createModule( - sqlite3 db, /* Database in which module is registered */ - string zName, /* Name assigned to this module */ - sqlite3_module pModule, /* The definition of the module */ - object pAux, /* Context pointer for xCreate/xConnect */ - smdxDestroy xDestroy /* Module destructor function */ - ) - { - int rc, nName; - Module pMod; - - sqlite3_mutex_enter( db.mutex ); - nName = sqlite3Strlen30( zName ); - pMod = new Module();// (Module)sqlite3DbMallocRaw( db, sizeof( Module ) + nName + 1 ); - if ( pMod != null ) - { - Module pDel; - string zCopy;// = (char )(&pMod[1]); - zCopy = zName;//memcpy(zCopy, zName, nName+1); - pMod.zName = zCopy; - pMod.pModule = pModule; - pMod.pAux = pAux; - pMod.xDestroy = xDestroy; - pDel = (Module)sqlite3HashInsert( ref db.aModule, zCopy, nName, pMod ); - if ( pDel != null && pDel.xDestroy != null ) - { - sqlite3ResetInternalSchema( db, -1 ); - pDel.xDestroy( ref pDel.pAux ); + //#include "sqliteInt.h" + + /* + ** Before a virtual table xCreate() or xConnect() method is invoked, the + ** sqlite3.pVtabCtx member variable is set to point to an instance of + ** this struct allocated on the stack. It is used by the implementation of + ** the sqlite3_declare_vtab() and sqlite3_vtab_config() APIs, both of which + ** are invoked only from within xCreate and xConnect methods. + */ + public class VtabCtx { + public Table pTab; + public VTable pVTable; + }; + + /* + ** The actual function that does the work of creating a new module. + ** This function implements the sqlite3_create_module() and + ** sqlite3_create_module_v2() interfaces. + */ + static int createModule( + sqlite3 db, /* Database in which module is registered */ + string zName, /* Name assigned to this module */ + sqlite3_module pModule, /* The definition of the module */ + object pAux, /* Context pointer for xCreate/xConnect */ + smdxDestroy xDestroy /* Module destructor function */ + ) { + int rc, nName; + Module pMod; + + sqlite3_mutex_enter(db.mutex); + nName = sqlite3Strlen30(zName); + pMod = new Module();// (Module)sqlite3DbMallocRaw( db, sizeof( Module ) + nName + 1 ); + if (pMod != null) { + Module pDel; + string zCopy;// = (char )(&pMod[1]); + zCopy = zName;//memcpy(zCopy, zName, nName+1); + pMod.zName = zCopy; + pMod.pModule = pModule; + pMod.pAux = pAux; + pMod.xDestroy = xDestroy; + pDel = (Module)sqlite3HashInsert(ref db.aModule, zCopy, nName, pMod); + if (pDel != null && pDel.xDestroy != null) { + sqlite3ResetInternalSchema(db, -1); + pDel.xDestroy(ref pDel.pAux); + } + sqlite3DbFree(db, ref pDel); + //if( pDel==pMod ){ + // db.mallocFailed = 1; + //} + } else if (xDestroy != null) { + xDestroy(ref pAux); + } + rc = sqlite3ApiExit(db, SQLITE_OK); + sqlite3_mutex_leave(db.mutex); + return rc; } - sqlite3DbFree( db, ref pDel ); - //if( pDel==pMod ){ - // db.mallocFailed = 1; - //} - } - else if ( xDestroy != null ) - { - xDestroy( ref pAux ); - } - rc = sqlite3ApiExit( db, SQLITE_OK ); - sqlite3_mutex_leave( db.mutex ); - return rc; - } - /* - ** External API function used to create a new virtual-table module. - */ - static int sqlite3_create_module( - sqlite3 db, /* Database in which module is registered */ - string zName, /* Name assigned to this module */ - sqlite3_module pModule, /* The definition of the module */ - object pAux /* Context pointer for xCreate/xConnect */ - ) - { - return createModule( db, zName, pModule, pAux, null ); - } - - /* - ** External API function used to create a new virtual-table module. - */ - static int sqlite3_create_module_v2( - sqlite3 db, /* Database in which module is registered */ - string zName, /* Name assigned to this module */ - sqlite3_module pModule, /* The definition of the module */ - sqlite3_vtab pAux, /* Context pointer for xCreate/xConnect */ - smdxDestroy xDestroy /* Module destructor function */ - ) - { - return createModule( db, zName, pModule, pAux, xDestroy ); - } + /* + ** External API function used to create a new virtual-table module. + */ + static int sqlite3_create_module( + sqlite3 db, /* Database in which module is registered */ + string zName, /* Name assigned to this module */ + sqlite3_module pModule, /* The definition of the module */ + object pAux /* Context pointer for xCreate/xConnect */ + ) { + return createModule(db, zName, pModule, pAux, null); + } - /* - ** Lock the virtual table so that it cannot be disconnected. - ** Locks nest. Every lock should have a corresponding unlock. - ** If an unlock is omitted, resources leaks will occur. - ** - ** If a disconnect is attempted while a virtual table is locked, - ** the disconnect is deferred until all locks have been removed. - */ - static void sqlite3VtabLock( VTable pVTab ) - { - pVTab.nRef++; - } + /* + ** External API function used to create a new virtual-table module. + */ + static int sqlite3_create_module_v2( + sqlite3 db, /* Database in which module is registered */ + string zName, /* Name assigned to this module */ + sqlite3_module pModule, /* The definition of the module */ + sqlite3_vtab pAux, /* Context pointer for xCreate/xConnect */ + smdxDestroy xDestroy /* Module destructor function */ + ) { + return createModule(db, zName, pModule, pAux, xDestroy); + } + /* + ** Lock the virtual table so that it cannot be disconnected. + ** Locks nest. Every lock should have a corresponding unlock. + ** If an unlock is omitted, resources leaks will occur. + ** + ** If a disconnect is attempted while a virtual table is locked, + ** the disconnect is deferred until all locks have been removed. + */ + static void sqlite3VtabLock(VTable pVTab) { + pVTab.nRef++; + } - /* - ** pTab is a pointer to a Table structure representing a virtual-table. - ** Return a pointer to the VTable object used by connection db to access - ** this virtual-table, if one has been created, or NULL otherwise. - */ - static VTable sqlite3GetVTable( sqlite3 db, Table pTab ) - { - VTable pVtab; - Debug.Assert( IsVirtual( pTab ) ); - for ( pVtab = pTab.pVTable; pVtab != null && pVtab.db != db; pVtab = pVtab.pNext ) - ; - return pVtab; - } - /* - ** Decrement the ref-count on a virtual table object. When the ref-count - ** reaches zero, call the xDisconnect() method to delete the object. - */ - static void sqlite3VtabUnlock( VTable pVTab ) - { - sqlite3 db = pVTab.db; - - Debug.Assert( db != null); - Debug.Assert( pVTab.nRef > 0 ); - Debug.Assert( sqlite3SafetyCheckOk( db ) ); - - pVTab.nRef--; - if ( pVTab.nRef == 0 ) - { - object p = pVTab.pVtab; - if ( p != null ) - { - ((sqlite3_vtab)p).pModule.xDisconnect( ref p ); + /* + ** pTab is a pointer to a Table structure representing a virtual-table. + ** Return a pointer to the VTable object used by connection db to access + ** this virtual-table, if one has been created, or NULL otherwise. + */ + static VTable sqlite3GetVTable(sqlite3 db, Table pTab) { + VTable pVtab; + Debug.Assert(IsVirtual(pTab)); + for (pVtab = pTab.pVTable; pVtab != null && pVtab.db != db; pVtab = pVtab.pNext) + ; + return pVtab; } - sqlite3DbFree( db, ref pVTab ); - } - } - /* - ** Table p is a virtual table. This function moves all elements in the - ** p.pVTable list to the sqlite3.pDisconnect lists of their associated - ** database connections to be disconnected at the next opportunity. - ** Except, if argument db is not NULL, then the entry associated with - ** connection db is left in the p.pVTable list. - */ - static VTable vtabDisconnectAll( sqlite3 db, Table p ) - { - VTable pRet = null; - VTable pVTable = p.pVTable; - p.pVTable = null; - - /* Assert that the mutex (if any) associated with the BtShared database - ** that contains table p is held by the caller. See header comments - ** above function sqlite3VtabUnlockList() for an explanation of why - ** this makes it safe to access the sqlite3.pDisconnect list of any - ** database connection that may have an entry in the p.pVTable list. - */ - Debug.Assert( db == null || sqlite3SchemaMutexHeld( db, 0, p.pSchema ) ); - - while ( pVTable != null ) - { - sqlite3 db2 = pVTable.db; - VTable pNext = pVTable.pNext; - Debug.Assert( db2 != null ); - if ( db2 == db ) - { - pRet = pVTable; - p.pVTable = pRet; - pRet.pNext = null; - } - else - { - pVTable.pNext = db2.pDisconnect; - db2.pDisconnect = pVTable; + /* + ** Decrement the ref-count on a virtual table object. When the ref-count + ** reaches zero, call the xDisconnect() method to delete the object. + */ + static void sqlite3VtabUnlock(VTable pVTab) { + sqlite3 db = pVTab.db; + + Debug.Assert(db != null); + Debug.Assert(pVTab.nRef > 0); + Debug.Assert(sqlite3SafetyCheckOk(db)); + + pVTab.nRef--; + if (pVTab.nRef == 0) { + object p = pVTab.pVtab; + if (p != null) { + ((sqlite3_vtab)p).pModule.xDisconnect(ref p); + } + sqlite3DbFree(db, ref pVTab); + } } - pVTable = pNext; - } - Debug.Assert( null == db || pRet != null ); - return pRet; - } + /* + ** Table p is a virtual table. This function moves all elements in the + ** p.pVTable list to the sqlite3.pDisconnect lists of their associated + ** database connections to be disconnected at the next opportunity. + ** Except, if argument db is not NULL, then the entry associated with + ** connection db is left in the p.pVTable list. + */ + static VTable vtabDisconnectAll(sqlite3 db, Table p) { + VTable pRet = null; + VTable pVTable = p.pVTable; + p.pVTable = null; + + /* Assert that the mutex (if any) associated with the BtShared database + ** that contains table p is held by the caller. See header comments + ** above function sqlite3VtabUnlockList() for an explanation of why + ** this makes it safe to access the sqlite3.pDisconnect list of any + ** database connection that may have an entry in the p.pVTable list. + */ + Debug.Assert(db == null || sqlite3SchemaMutexHeld(db, 0, p.pSchema)); + + while (pVTable != null) { + sqlite3 db2 = pVTable.db; + VTable pNext = pVTable.pNext; + Debug.Assert(db2 != null); + if (db2 == db) { + pRet = pVTable; + p.pVTable = pRet; + pRet.pNext = null; + } else { + pVTable.pNext = db2.pDisconnect; + db2.pDisconnect = pVTable; + } + pVTable = pNext; + } + Debug.Assert(null == db || pRet != null); + return pRet; + } - /* - ** Disconnect all the virtual table objects in the sqlite3.pDisconnect list. - ** - ** This function may only be called when the mutexes associated with all - ** shared b-tree databases opened using connection db are held by the - ** caller. This is done to protect the sqlite3.pDisconnect list. The - ** sqlite3.pDisconnect list is accessed only as follows: - ** - ** 1) By this function. In this case, all BtShared mutexes and the mutex - ** associated with the database handle itself must be held. - ** - ** 2) By function vtabDisconnectAll(), when it adds a VTable entry to - ** the sqlite3.pDisconnect list. In this case either the BtShared mutex - ** associated with the database the virtual table is stored in is held - ** or, if the virtual table is stored in a non-sharable database, then - ** the database handle mutex is held. - ** - ** As a result, a sqlite3.pDisconnect cannot be accessed simultaneously - ** by multiple threads. It is thread-safe. - */ - static void sqlite3VtabUnlockList( sqlite3 db ) - { - VTable p = db.pDisconnect; - db.pDisconnect = null; - - Debug.Assert( sqlite3BtreeHoldsAllMutexes( db ) ); - Debug.Assert( sqlite3_mutex_held( db.mutex ) ); - - if ( p != null ) - { - sqlite3ExpirePreparedStatements( db ); - do - { - VTable pNext = p.pNext; - sqlite3VtabUnlock( p ); - p = pNext; - } while ( p != null ); - } - } - /* - ** Clear any and all virtual-table information from the Table record. - ** This routine is called, for example, just before deleting the Table - ** record. - ** - ** Since it is a virtual-table, the Table structure contains a pointer - ** to the head of a linked list of VTable structures. Each VTable - ** structure is associated with a single sqlite3* user of the schema. - ** The reference count of the VTable structure associated with database - ** connection db is decremented immediately (which may lead to the - ** structure being xDisconnected and free). Any other VTable structures - ** in the list are moved to the sqlite3.pDisconnect list of the associated - ** database connection. - */ - static void sqlite3VtabClear( sqlite3 db, Table p ) - { - if ( null == db || db.pnBytesFreed == 0 ) - vtabDisconnectAll( null, p ); - if ( p.azModuleArg != null ) - { - int i; - for ( i = 0; i < p.nModuleArg; i++ ) - { - sqlite3DbFree( db, ref p.azModuleArg[i] ); + /* + ** Disconnect all the virtual table objects in the sqlite3.pDisconnect list. + ** + ** This function may only be called when the mutexes associated with all + ** shared b-tree databases opened using connection db are held by the + ** caller. This is done to protect the sqlite3.pDisconnect list. The + ** sqlite3.pDisconnect list is accessed only as follows: + ** + ** 1) By this function. In this case, all BtShared mutexes and the mutex + ** associated with the database handle itself must be held. + ** + ** 2) By function vtabDisconnectAll(), when it adds a VTable entry to + ** the sqlite3.pDisconnect list. In this case either the BtShared mutex + ** associated with the database the virtual table is stored in is held + ** or, if the virtual table is stored in a non-sharable database, then + ** the database handle mutex is held. + ** + ** As a result, a sqlite3.pDisconnect cannot be accessed simultaneously + ** by multiple threads. It is thread-safe. + */ + static void sqlite3VtabUnlockList(sqlite3 db) { + VTable p = db.pDisconnect; + db.pDisconnect = null; + + Debug.Assert(sqlite3BtreeHoldsAllMutexes(db)); + Debug.Assert(sqlite3_mutex_held(db.mutex)); + + if (p != null) { + sqlite3ExpirePreparedStatements(db); + do { + VTable pNext = p.pNext; + sqlite3VtabUnlock(p); + p = pNext; + } while (p != null); + } } - sqlite3DbFree( db, ref p.azModuleArg ); - } - } - /* - ** Add a new module argument to pTable.azModuleArg[]. - ** The string is not copied - the pointer is stored. The - ** string will be freed automatically when the table is - ** deleted. - */ - static void addModuleArgument( sqlite3 db, Table pTable, string zArg ) - { - int i = pTable.nModuleArg++; - //int nBytes = sizeof(char )*(1+pTable.nModuleArg); - //string[] azModuleArg; - //sqlite3DbRealloc( db, pTable.azModuleArg, nBytes ); - if ( pTable.azModuleArg == null || pTable.azModuleArg.Length < pTable.nModuleArg ) - Array.Resize( ref pTable.azModuleArg, 3 + pTable.nModuleArg ); - //if ( azModuleArg == null ) - //{ - // int j; - // for ( j = 0; j < i; j++ ) - // { - // sqlite3DbFree( db, ref pTable.azModuleArg[j] ); - // } - // sqlite3DbFree( db, ref zArg ); - // sqlite3DbFree( db, ref pTable.azModuleArg ); - // pTable.nModuleArg = 0; - //} - //else - { - pTable.azModuleArg[i] = zArg; - //pTable.azModuleArg[i + 1] = null; - //azModuleArg[i+1] = 0; - } - //pTable.azModuleArg = azModuleArg; - } + /* + ** Clear any and all virtual-table information from the Table record. + ** This routine is called, for example, just before deleting the Table + ** record. + ** + ** Since it is a virtual-table, the Table structure contains a pointer + ** to the head of a linked list of VTable structures. Each VTable + ** structure is associated with a single sqlite3* user of the schema. + ** The reference count of the VTable structure associated with database + ** connection db is decremented immediately (which may lead to the + ** structure being xDisconnected and free). Any other VTable structures + ** in the list are moved to the sqlite3.pDisconnect list of the associated + ** database connection. + */ + static void sqlite3VtabClear(sqlite3 db, Table p) { + if (null == db || db.pnBytesFreed == 0) + vtabDisconnectAll(null, p); + if (p.azModuleArg != null) { + int i; + for (i = 0; i < p.nModuleArg; i++) { + sqlite3DbFree(db, ref p.azModuleArg[i]); + } + sqlite3DbFree(db, ref p.azModuleArg); + } + } - /* - ** The parser calls this routine when it first sees a CREATE VIRTUAL TABLE - ** statement. The module name has been parsed, but the optional list - ** of parameters that follow the module name are still pending. - */ - static void sqlite3VtabBeginParse( - Parse pParse, /* Parsing context */ - Token pName1, /* Name of new table, or database name */ - Token pName2, /* Name of new table or NULL */ - Token pModuleName /* Name of the module for the virtual table */ - ) - { - int iDb; /* The database the table is being created in */ - Table pTable; /* The new virtual table */ - sqlite3 db; /* Database connection */ - - sqlite3StartTable( pParse, pName1, pName2, 0, 0, 1, 0 ); - pTable = pParse.pNewTable; - if ( pTable == null ) - return; - Debug.Assert( null == pTable.pIndex ); - - db = pParse.db; - iDb = sqlite3SchemaToIndex( db, pTable.pSchema ); - Debug.Assert( iDb >= 0 ); - - pTable.tabFlags |= TF_Virtual; - pTable.nModuleArg = 0; - addModuleArgument( db, pTable, sqlite3NameFromToken( db, pModuleName ) ); - addModuleArgument( db, pTable, db.aDb[iDb].zName);//sqlite3DbStrDup( db, db.aDb[iDb].zName ) ); - addModuleArgument( db, pTable, pTable.zName );//sqlite3DbStrDup( db, pTable.zName ) ); - pParse.sNameToken.n = pParse.sNameToken.z.Length;// (int)[pModuleName.n] - pName1.z ); + /* + ** Add a new module argument to pTable.azModuleArg[]. + ** The string is not copied - the pointer is stored. The + ** string will be freed automatically when the table is + ** deleted. + */ + static void addModuleArgument(sqlite3 db, Table pTable, string zArg) { + int i = pTable.nModuleArg++; + //int nBytes = sizeof(char )*(1+pTable.nModuleArg); + //string[] azModuleArg; + //sqlite3DbRealloc( db, pTable.azModuleArg, nBytes ); + if (pTable.azModuleArg == null || pTable.azModuleArg.Length < pTable.nModuleArg) + Array.Resize(ref pTable.azModuleArg, 3 + pTable.nModuleArg); + //if ( azModuleArg == null ) + //{ + // int j; + // for ( j = 0; j < i; j++ ) + // { + // sqlite3DbFree( db, ref pTable.azModuleArg[j] ); + // } + // sqlite3DbFree( db, ref zArg ); + // sqlite3DbFree( db, ref pTable.azModuleArg ); + // pTable.nModuleArg = 0; + //} + //else + { + pTable.azModuleArg[i] = zArg; + //pTable.azModuleArg[i + 1] = null; + //azModuleArg[i+1] = 0; + } + //pTable.azModuleArg = azModuleArg; + } + + /* + ** The parser calls this routine when it first sees a CREATE VIRTUAL TABLE + ** statement. The module name has been parsed, but the optional list + ** of parameters that follow the module name are still pending. + */ + static void sqlite3VtabBeginParse( + Parse pParse, /* Parsing context */ + Token pName1, /* Name of new table, or database name */ + Token pName2, /* Name of new table or NULL */ + Token pModuleName /* Name of the module for the virtual table */ + ) { + int iDb; /* The database the table is being created in */ + Table pTable; /* The new virtual table */ + sqlite3 db; /* Database connection */ + + sqlite3StartTable(pParse, pName1, pName2, 0, 0, 1, 0); + pTable = pParse.pNewTable; + if (pTable == null) + return; + Debug.Assert(null == pTable.pIndex); + + db = pParse.db; + iDb = sqlite3SchemaToIndex(db, pTable.pSchema); + Debug.Assert(iDb >= 0); + + pTable.tabFlags |= TF_Virtual; + pTable.nModuleArg = 0; + addModuleArgument(db, pTable, sqlite3NameFromToken(db, pModuleName)); + addModuleArgument(db, pTable, db.aDb[iDb].zName);//sqlite3DbStrDup( db, db.aDb[iDb].zName ) ); + addModuleArgument(db, pTable, pTable.zName);//sqlite3DbStrDup( db, pTable.zName ) ); + pParse.sNameToken.n = pParse.sNameToken.z.Length;// (int)[pModuleName.n] - pName1.z ); #if !SQLITE_OMIT_AUTHORIZATION /* Creating a virtual table invokes the authorization callback twice. @@ -364,878 +334,793 @@ static void sqlite3VtabBeginParse( pTable->azModuleArg[0], pParse->db->aDb[iDb].zName); } #endif - } - - /* - ** This routine takes the module argument that has been accumulating - ** in pParse.zArg[] and appends it to the list of arguments on the - ** virtual table currently under construction in pParse.pTable. - */ - static void addArgumentToVtab( Parse pParse ) - { - if ( pParse.sArg.z != null && ALWAYS( pParse.pNewTable ) ) - { - string z = pParse.sArg.z.Substring( 0, pParse.sArg.n ); - ////int n = pParse.sArg.n; - sqlite3 db = pParse.db; - addModuleArgument( db, pParse.pNewTable, z );////sqlite3DbStrNDup( db, z, n ) ); - } - } - - /* - ** The parser calls this routine after the CREATE VIRTUAL TABLE statement - ** has been completely parsed. - */ - static void sqlite3VtabFinishParse( Parse pParse, Token pEnd ) - { - Table pTab = pParse.pNewTable; /* The table being constructed */ - sqlite3 db = pParse.db; /* The database connection */ - - if ( pTab == null ) - return; - addArgumentToVtab( pParse ); - pParse.sArg.z = ""; - if ( pTab.nModuleArg < 1 ) - return; - - /* If the CREATE VIRTUAL TABLE statement is being entered for the - ** first time (in other words if the virtual table is actually being - ** created now instead of just being read out of sqlite_master) then - ** do additional initialization work and store the statement text - ** in the sqlite_master table. - */ - if ( 0 == db.init.busy ) - { - string zStmt; - string zWhere; - int iDb; - Vdbe v; - - /* Compute the complete text of the CREATE VIRTUAL TABLE statement */ - if ( pEnd != null ) - { - pParse.sNameToken.n = pParse.sNameToken.z.Length;//(int)( pEnd.z - pParse.sNameToken.z ) + pEnd.n; } - zStmt = sqlite3MPrintf( db, "CREATE VIRTUAL TABLE %T", pParse.sNameToken.z.Substring(0,pParse.sNameToken.n) ); - /* A slot for the record has already been allocated in the - ** SQLITE_MASTER table. We just need to update that slot with all - ** the information we've collected. - ** - ** The VM register number pParse.regRowid holds the rowid of an - ** entry in the sqlite_master table tht was created for this vtab - ** by sqlite3StartTable(). + /* + ** This routine takes the module argument that has been accumulating + ** in pParse.zArg[] and appends it to the list of arguments on the + ** virtual table currently under construction in pParse.pTable. */ - iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); - sqlite3NestedParse( pParse, - "UPDATE %Q.%s " + - "SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q " + - "WHERE rowid=#%d", - db.aDb[iDb].zName, SCHEMA_TABLE( iDb ), - pTab.zName, - pTab.zName, - zStmt, - pParse.regRowid - ); - sqlite3DbFree( db, ref zStmt ); - v = sqlite3GetVdbe( pParse ); - sqlite3ChangeCookie( pParse, iDb ); - - sqlite3VdbeAddOp2( v, OP_Expire, 0, 0 ); - zWhere = sqlite3MPrintf( db, "name='%q' AND type='table'", pTab.zName ); - sqlite3VdbeAddParseSchemaOp( v, iDb, zWhere ); - sqlite3VdbeAddOp4( v, OP_VCreate, iDb, 0, 0, - pTab.zName, sqlite3Strlen30( pTab.zName ) + 1 ); - } - - /* If we are rereading the sqlite_master table create the in-memory - ** record of the table. The xConnect() method is not called until - ** the first time the virtual table is used in an SQL statement. This - ** allows a schema that contains virtual tables to be loaded before - ** the required virtual table implementations are registered. */ - else - { - Table pOld; - Schema pSchema = pTab.pSchema; - string zName = pTab.zName; - int nName = sqlite3Strlen30( zName ); - Debug.Assert( sqlite3SchemaMutexHeld( db, 0, pSchema ) ); - pOld = sqlite3HashInsert( ref pSchema.tblHash, zName, nName, pTab ); - if ( pOld != null ) - { - //db.mallocFailed = 1; - Debug.Assert( pTab == pOld ); /* Malloc must have failed inside HashInsert() */ - return; + static void addArgumentToVtab(Parse pParse) { + if (pParse.sArg.z != null && ALWAYS(pParse.pNewTable)) { + string z = pParse.sArg.z.Substring(0, pParse.sArg.n); + ////int n = pParse.sArg.n; + sqlite3 db = pParse.db; + addModuleArgument(db, pParse.pNewTable, z);////sqlite3DbStrNDup( db, z, n ) ); + } } - pParse.pNewTable = null; - } - } - /* - ** The parser calls this routine when it sees the first token - ** of an argument to the module name in a CREATE VIRTUAL TABLE statement. - */ - static void sqlite3VtabArgInit( Parse pParse ) - { - addArgumentToVtab( pParse ); - pParse.sArg.z = null; - pParse.sArg.n = 0; - } + /* + ** The parser calls this routine after the CREATE VIRTUAL TABLE statement + ** has been completely parsed. + */ + static void sqlite3VtabFinishParse(Parse pParse, Token pEnd) { + Table pTab = pParse.pNewTable; /* The table being constructed */ + sqlite3 db = pParse.db; /* The database connection */ + + if (pTab == null) + return; + addArgumentToVtab(pParse); + pParse.sArg.z = ""; + if (pTab.nModuleArg < 1) + return; + + /* If the CREATE VIRTUAL TABLE statement is being entered for the + ** first time (in other words if the virtual table is actually being + ** created now instead of just being read out of sqlite_master) then + ** do additional initialization work and store the statement text + ** in the sqlite_master table. + */ + if (0 == db.init.busy) { + string zStmt; + string zWhere; + int iDb; + Vdbe v; + + /* Compute the complete text of the CREATE VIRTUAL TABLE statement */ + if (pEnd != null) { + pParse.sNameToken.n = pParse.sNameToken.z.Length;//(int)( pEnd.z - pParse.sNameToken.z ) + pEnd.n; + } + zStmt = sqlite3MPrintf(db, "CREATE VIRTUAL TABLE %T", pParse.sNameToken.z.Substring(0, pParse.sNameToken.n)); + + /* A slot for the record has already been allocated in the + ** SQLITE_MASTER table. We just need to update that slot with all + ** the information we've collected. + ** + ** The VM register number pParse.regRowid holds the rowid of an + ** entry in the sqlite_master table tht was created for this vtab + ** by sqlite3StartTable(). + */ + iDb = sqlite3SchemaToIndex(db, pTab.pSchema); + sqlite3NestedParse(pParse, + "UPDATE %Q.%s " + + "SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q " + + "WHERE rowid=#%d", + db.aDb[iDb].zName, SCHEMA_TABLE(iDb), + pTab.zName, + pTab.zName, + zStmt, + pParse.regRowid + ); + sqlite3DbFree(db, ref zStmt); + v = sqlite3GetVdbe(pParse); + sqlite3ChangeCookie(pParse, iDb); + + sqlite3VdbeAddOp2(v, OP_Expire, 0, 0); + zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab.zName); + sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere); + sqlite3VdbeAddOp4(v, OP_VCreate, iDb, 0, 0, + pTab.zName, sqlite3Strlen30(pTab.zName) + 1); + } - /* - ** The parser calls this routine for each token after the first token - ** in an argument to the module name in a CREATE VIRTUAL TABLE statement. - */ - static void sqlite3VtabArgExtend( Parse pParse, Token p ) - { - Token pArg = pParse.sArg; - if ( pArg.z == null ) - { - pArg.z = p.z; - pArg.n = p.n; - } - else - { - //Debug.Assert( pArg.z< p.z ); - pArg.n += p.n+1;//(int)( p.z[p.n] - pArg.z ); - } - } + /* If we are rereading the sqlite_master table create the in-memory + ** record of the table. The xConnect() method is not called until + ** the first time the virtual table is used in an SQL statement. This + ** allows a schema that contains virtual tables to be loaded before + ** the required virtual table implementations are registered. */ + else { + Table pOld; + Schema pSchema = pTab.pSchema; + string zName = pTab.zName; + int nName = sqlite3Strlen30(zName); + Debug.Assert(sqlite3SchemaMutexHeld(db, 0, pSchema)); + pOld = sqlite3HashInsert(ref pSchema.tblHash, zName, nName, pTab); + if (pOld != null) { + //db.mallocFailed = 1; + Debug.Assert(pTab == pOld); /* Malloc must have failed inside HashInsert() */ + return; + } + pParse.pNewTable = null; + } + } - /* - ** Invoke a virtual table constructor (either xCreate or xConnect). The - ** pointer to the function to invoke is passed as the fourth parameter - ** to this procedure. - */ - static int vtabCallConstructor( - sqlite3 db, - Table pTab, - Module pMod, - smdxCreateConnect xConstruct, - ref string pzErr - ) - { - VtabCtx sCtx = new VtabCtx(); - VTable pVTable; - int rc; - string[] azArg = pTab.azModuleArg; - int nArg = pTab.nModuleArg; - string zErr = null; - string zModuleName = sqlite3MPrintf( db, "%s", pTab.zName ); - - //if ( String.IsNullOrEmpty( zModuleName ) ) - //{ - // return SQLITE_NOMEM; - //} - - pVTable = new VTable();//sqlite3DbMallocZero( db, sizeof( VTable ) ); - //if ( null == pVTable ) - //{ - // sqlite3DbFree( db, ref zModuleName ); - // return SQLITE_NOMEM; - //} - pVTable.db = db; - pVTable.pMod = pMod; - - /* Invoke the virtual table constructor */ - //assert( &db->pVtabCtx ); - Debug.Assert( xConstruct != null ); - sCtx.pTab = pTab; - sCtx.pVTable = pVTable; - db.pVtabCtx = sCtx; - rc = xConstruct( db, pMod.pAux, nArg, azArg, out pVTable.pVtab, out zErr ); - db.pVtabCtx = null; - //if ( rc == SQLITE_NOMEM ) - // db.mallocFailed = 1; - - if ( SQLITE_OK != rc ) - { - if ( zErr == "" ) - { - pzErr = sqlite3MPrintf( db, "vtable constructor failed: %s", zModuleName ); + /* + ** The parser calls this routine when it sees the first token + ** of an argument to the module name in a CREATE VIRTUAL TABLE statement. + */ + static void sqlite3VtabArgInit(Parse pParse) { + addArgumentToVtab(pParse); + pParse.sArg.z = null; + pParse.sArg.n = 0; } - else - { - pzErr = sqlite3MPrintf( db, "%s", zErr ); - zErr = null;//sqlite3_free( zErr ); + + /* + ** The parser calls this routine for each token after the first token + ** in an argument to the module name in a CREATE VIRTUAL TABLE statement. + */ + static void sqlite3VtabArgExtend(Parse pParse, Token p) { + Token pArg = pParse.sArg; + if (pArg.z == null) { + pArg.z = p.z; + pArg.n = p.n; + } else { + //Debug.Assert( pArg.z< p.z ); + pArg.n += p.n + 1;//(int)( p.z[p.n] - pArg.z ); + } } - sqlite3DbFree( db, ref pVTable ); - } - else if ( ALWAYS( pVTable.pVtab ) ) - { - /* Justification of ALWAYS(): A correct vtab constructor must allocate - ** the sqlite3_vtab object if successful. */ - pVTable.pVtab.pModule = pMod.pModule; - pVTable.nRef = 1; - if ( sCtx.pTab != null ) - { - string zFormat = "vtable constructor did not declare schema: %s"; - pzErr = sqlite3MPrintf( db, zFormat, pTab.zName ); - sqlite3VtabUnlock( pVTable ); - rc = SQLITE_ERROR; + + /* + ** Invoke a virtual table constructor (either xCreate or xConnect). The + ** pointer to the function to invoke is passed as the fourth parameter + ** to this procedure. + */ + static int vtabCallConstructor( + sqlite3 db, + Table pTab, + Module pMod, + smdxCreateConnect xConstruct, + ref string pzErr + ) { + VtabCtx sCtx = new VtabCtx(); + VTable pVTable; + int rc; + string[] azArg = pTab.azModuleArg; + int nArg = pTab.nModuleArg; + string zErr = null; + string zModuleName = sqlite3MPrintf(db, "%s", pTab.zName); + + //if ( String.IsNullOrEmpty( zModuleName ) ) + //{ + // return SQLITE_NOMEM; + //} + + pVTable = new VTable();//sqlite3DbMallocZero( db, sizeof( VTable ) ); + //if ( null == pVTable ) + //{ + // sqlite3DbFree( db, ref zModuleName ); + // return SQLITE_NOMEM; + //} + pVTable.db = db; + pVTable.pMod = pMod; + + /* Invoke the virtual table constructor */ + //assert( &db->pVtabCtx ); + Debug.Assert(xConstruct != null); + sCtx.pTab = pTab; + sCtx.pVTable = pVTable; + db.pVtabCtx = sCtx; + rc = xConstruct(db, pMod.pAux, nArg, azArg, out pVTable.pVtab, out zErr); + db.pVtabCtx = null; + //if ( rc == SQLITE_NOMEM ) + // db.mallocFailed = 1; + + if (SQLITE_OK != rc) { + if (zErr == "") { + pzErr = sqlite3MPrintf(db, "vtable constructor failed: %s", zModuleName); + } else { + pzErr = sqlite3MPrintf(db, "%s", zErr); + zErr = null;//sqlite3_free( zErr ); + } + sqlite3DbFree(db, ref pVTable); + } else if (ALWAYS(pVTable.pVtab)) { + /* Justification of ALWAYS(): A correct vtab constructor must allocate + ** the sqlite3_vtab object if successful. */ + pVTable.pVtab.pModule = pMod.pModule; + pVTable.nRef = 1; + if (sCtx.pTab != null) { + string zFormat = "vtable constructor did not declare schema: %s"; + pzErr = sqlite3MPrintf(db, zFormat, pTab.zName); + sqlite3VtabUnlock(pVTable); + rc = SQLITE_ERROR; + } else { + int iCol; + /* If everything went according to plan, link the new VTable structure + ** into the linked list headed by pTab->pVTable. Then loop through the + ** columns of the table to see if any of them contain the token "hidden". + ** If so, set the Column.isHidden flag and remove the token from + ** the type string. */ + pVTable.pNext = pTab.pVTable; + pTab.pVTable = pVTable; + + for (iCol = 0; iCol < pTab.nCol; iCol++) { + if (String.IsNullOrEmpty(pTab.aCol[iCol].zType)) + continue; + StringBuilder zType = new StringBuilder(pTab.aCol[iCol].zType); + int nType; + int i = 0; + //if ( zType ) + // continue; + nType = sqlite3Strlen30(zType); + if (sqlite3StrNICmp("hidden", 0, zType.ToString(), 6) != 0 || (zType.Length > 6 && zType[6] != ' ')) { + for (i = 0; i < nType; i++) { + if ((0 == sqlite3StrNICmp(" hidden", zType.ToString().Substring(i), 7)) + && (i + 7 == zType.Length || (zType[i + 7] == '\0' || zType[i + 7] == ' ')) + ) { + i++; + break; + } + } + } + if (i < nType) { + int j; + int nDel = 6 + (zType.Length > i + 6 ? 1 : 0); + for (j = i; (j + nDel) < nType; j++) { + zType[j] = zType[j + nDel]; + } + if (zType[i] == '\0' && i > 0) { + Debug.Assert(zType[i - 1] == ' '); + zType.Length = i;//[i - 1] = '\0'; + } + pTab.aCol[iCol].isHidden = 1; + pTab.aCol[iCol].zType = zType.ToString().Substring(0, j); + } + } + } + } + + sqlite3DbFree(db, ref zModuleName); + return rc; } - else - { - int iCol; - /* If everything went according to plan, link the new VTable structure - ** into the linked list headed by pTab->pVTable. Then loop through the - ** columns of the table to see if any of them contain the token "hidden". - ** If so, set the Column.isHidden flag and remove the token from - ** the type string. */ - pVTable.pNext = pTab.pVTable; - pTab.pVTable = pVTable; - - for ( iCol = 0; iCol < pTab.nCol; iCol++ ) - { - if ( String.IsNullOrEmpty( pTab.aCol[iCol].zType ) ) - continue; - StringBuilder zType = new StringBuilder( pTab.aCol[iCol].zType); - int nType; - int i = 0; - //if ( zType ) - // continue; - nType = sqlite3Strlen30( zType ); - if ( sqlite3StrNICmp( "hidden", 0, zType.ToString(), 6 ) != 0 || ( zType.Length > 6 && zType[6] != ' ' ) ) - { - for ( i = 0; i < nType; i++ ) - { - if ( ( 0 == sqlite3StrNICmp( " hidden", zType.ToString().Substring( i ), 7 ) ) - && ( i+7 == zType.Length || (zType[i + 7] == '\0' || zType[i + 7] == ' ' )) - ) - { - i++; - break; + + /* + ** This function is invoked by the parser to call the xConnect() method + ** of the virtual table pTab. If an error occurs, an error code is returned + ** and an error left in pParse. + ** + ** This call is a no-op if table pTab is not a virtual table. + */ + static int sqlite3VtabCallConnect(Parse pParse, Table pTab) { + sqlite3 db = pParse.db; + string zMod; + Module pMod; + int rc; + + Debug.Assert(pTab != null); + if ((pTab.tabFlags & TF_Virtual) == 0 || sqlite3GetVTable(db, pTab) != null) { + return SQLITE_OK; + } + + /* Locate the required virtual table module */ + zMod = pTab.azModuleArg[0]; + pMod = (Module)sqlite3HashFind(db.aModule, zMod, sqlite3Strlen30(zMod), (Module)null); + + if (null == pMod) { + string zModule = pTab.azModuleArg[0]; + sqlite3ErrorMsg(pParse, "no such module: %s", zModule); + rc = SQLITE_ERROR; + } else { + string zErr = null; + rc = vtabCallConstructor(db, pTab, pMod, pMod.pModule.xConnect, ref zErr); + if (rc != SQLITE_OK) { + sqlite3ErrorMsg(pParse, "%s", zErr); } - } + zErr = null;//sqlite3DbFree( db, zErr ); } - if ( i < nType ) - { - int j; - int nDel = 6 + ( zType.Length > i + 6 ? 1 : 0 ); - for ( j = i; ( j + nDel ) < nType; j++ ) - { - zType[j] = zType[j + nDel]; - } - if ( zType[i] == '\0' && i > 0 ) - { - Debug.Assert( zType[i - 1] == ' ' ); - zType.Length = i;//[i - 1] = '\0'; - } - pTab.aCol[iCol].isHidden = 1; - pTab.aCol[iCol].zType = zType.ToString().Substring(0,j); + + return rc; + } + /* + ** Grow the db.aVTrans[] array so that there is room for at least one + ** more v-table. Return SQLITE_NOMEM if a malloc fails, or SQLITE_OK otherwise. + */ + static int growVTrans(sqlite3 db) { + const int ARRAY_INCR = 5; + + /* Grow the sqlite3.aVTrans array if required */ + if ((db.nVTrans % ARRAY_INCR) == 0) { + //VTable** aVTrans; + //int nBytes = sizeof( sqlite3_vtab* ) * ( db.nVTrans + ARRAY_INCR ); + //aVTrans = sqlite3DbRealloc( db, (void)db.aVTrans, nBytes ); + //if ( !aVTrans ) + //{ + // return SQLITE_NOMEM; + //} + //memset( &aVTrans[db.nVTrans], 0, sizeof( sqlite3_vtab* ) * ARRAY_INCR ); + Array.Resize(ref db.aVTrans, db.nVTrans + ARRAY_INCR); } - } + + return SQLITE_OK; } - } - sqlite3DbFree( db, ref zModuleName ); - return rc; - } + /* + ** Add the virtual table pVTab to the array sqlite3.aVTrans[]. Space should + ** have already been reserved using growVTrans(). + */ + static void addToVTrans(sqlite3 db, VTable pVTab) { + /* Add pVtab to the end of sqlite3.aVTrans */ + db.aVTrans[db.nVTrans++] = pVTab; + sqlite3VtabLock(pVTab); + } + + /* + ** This function is invoked by the vdbe to call the xCreate method + ** of the virtual table named zTab in database iDb. + ** + ** If an error occurs, *pzErr is set to point an an English language + ** description of the error and an SQLITE_XXX error code is returned. + ** In this case the caller must call sqlite3DbFree(db, ) on *pzErr. + */ + static int sqlite3VtabCallCreate(sqlite3 db, int iDb, string zTab, ref string pzErr) { + int rc = SQLITE_OK; + Table pTab; + Module pMod; + string zMod; + + pTab = sqlite3FindTable(db, zTab, db.aDb[iDb].zName); + Debug.Assert(pTab != null && (pTab.tabFlags & TF_Virtual) != 0 && null == pTab.pVTable); + + /* Locate the required virtual table module */ + zMod = pTab.azModuleArg[0]; + pMod = (Module)sqlite3HashFind(db.aModule, zMod, sqlite3Strlen30(zMod), (Module)null); + + /* If the module has been registered and includes a Create method, + ** invoke it now. If the module has not been registered, return an + ** error. Otherwise, do nothing. + */ + if (null == pMod) { + pzErr = sqlite3MPrintf(db, "no such module: %s", zMod); + rc = SQLITE_ERROR; + } else { + rc = vtabCallConstructor(db, pTab, pMod, pMod.pModule.xCreate, ref pzErr); + } + + /* Justification of ALWAYS(): The xConstructor method is required to + ** create a valid sqlite3_vtab if it returns SQLITE_OK. */ + if (rc == SQLITE_OK && ALWAYS(sqlite3GetVTable(db, pTab))) { + rc = growVTrans(db); + if (rc == SQLITE_OK) { + addToVTrans(db, sqlite3GetVTable(db, pTab)); + } + } - /* - ** This function is invoked by the parser to call the xConnect() method - ** of the virtual table pTab. If an error occurs, an error code is returned - ** and an error left in pParse. - ** - ** This call is a no-op if table pTab is not a virtual table. - */ - static int sqlite3VtabCallConnect( Parse pParse, Table pTab ) - { - sqlite3 db = pParse.db; - string zMod; - Module pMod; - int rc; - - Debug.Assert( pTab != null); - if ( ( pTab.tabFlags & TF_Virtual ) == 0 || sqlite3GetVTable( db, pTab )!= null ) - { - return SQLITE_OK; - } - - /* Locate the required virtual table module */ - zMod = pTab.azModuleArg[0]; - pMod = (Module)sqlite3HashFind( db.aModule, zMod, sqlite3Strlen30( zMod ), (Module)null ); - - if ( null == pMod ) - { - string zModule = pTab.azModuleArg[0]; - sqlite3ErrorMsg( pParse, "no such module: %s", zModule ); - rc = SQLITE_ERROR; - } - else - { - string zErr = null; - rc = vtabCallConstructor( db, pTab, pMod, pMod.pModule.xConnect, ref zErr ); - if ( rc != SQLITE_OK ) - { - sqlite3ErrorMsg( pParse, "%s", zErr ); + return rc; } - zErr = null;//sqlite3DbFree( db, zErr ); - } - return rc; - } - /* - ** Grow the db.aVTrans[] array so that there is room for at least one - ** more v-table. Return SQLITE_NOMEM if a malloc fails, or SQLITE_OK otherwise. - */ - static int growVTrans( sqlite3 db ) - { - const int ARRAY_INCR = 5; - - /* Grow the sqlite3.aVTrans array if required */ - if ( ( db.nVTrans % ARRAY_INCR ) == 0 ) - { - //VTable** aVTrans; - //int nBytes = sizeof( sqlite3_vtab* ) * ( db.nVTrans + ARRAY_INCR ); - //aVTrans = sqlite3DbRealloc( db, (void)db.aVTrans, nBytes ); - //if ( !aVTrans ) - //{ - // return SQLITE_NOMEM; - //} - //memset( &aVTrans[db.nVTrans], 0, sizeof( sqlite3_vtab* ) * ARRAY_INCR ); - Array.Resize( ref db.aVTrans, db.nVTrans + ARRAY_INCR ); - } - - return SQLITE_OK; - } + /* + ** This function is used to set the schema of a virtual table. It is only + ** valid to call this function from within the xCreate() or xConnect() of a + ** virtual table module. + */ + static int sqlite3_declare_vtab(sqlite3 db, string zCreateTable) { + Parse pParse; + + int rc = SQLITE_OK; + Table pTab; + string zErr = ""; + + sqlite3_mutex_enter(db.mutex); + if (null == db.pVtabCtx || null == (pTab = db.pVtabCtx.pTab)) { + sqlite3Error(db, SQLITE_MISUSE, 0); + sqlite3_mutex_leave(db.mutex); + return SQLITE_MISUSE_BKPT(); + } + Debug.Assert((pTab.tabFlags & TF_Virtual) != 0); + + pParse = new Parse();//sqlite3StackAllocZero(db, sizeof(*pParse)); + //if ( pParse == null ) + //{ + // rc = SQLITE_NOMEM; + //} + //else + { + pParse.declareVtab = 1; + pParse.db = db; + pParse.nQueryLoop = 1; + + if (SQLITE_OK == sqlite3RunParser(pParse, zCreateTable, ref zErr) + && pParse.pNewTable != null + //&& !db.mallocFailed + && null == pParse.pNewTable.pSelect + && (pParse.pNewTable.tabFlags & TF_Virtual) == 0 + ) { + if (null == pTab.aCol) { + pTab.aCol = pParse.pNewTable.aCol; + pTab.nCol = pParse.pNewTable.nCol; + pParse.pNewTable.nCol = 0; + pParse.pNewTable.aCol = null; + } + db.pVtabCtx.pTab = null; + } else { + sqlite3Error(db, SQLITE_ERROR, (zErr != null ? "%s" : null), zErr); + zErr = null;//sqlite3DbFree( db, zErr ); + rc = SQLITE_ERROR; + } + pParse.declareVtab = 0; - /* - ** Add the virtual table pVTab to the array sqlite3.aVTrans[]. Space should - ** have already been reserved using growVTrans(). - */ - static void addToVTrans( sqlite3 db, VTable pVTab ) - { - /* Add pVtab to the end of sqlite3.aVTrans */ - db.aVTrans[db.nVTrans++] = pVTab; - sqlite3VtabLock( pVTab ); - } + if (pParse.pVdbe != null) { + sqlite3VdbeFinalize(ref pParse.pVdbe); + } + sqlite3DeleteTable(db, ref pParse.pNewTable); + //sqlite3StackFree( db, pParse ); + } - /* - ** This function is invoked by the vdbe to call the xCreate method - ** of the virtual table named zTab in database iDb. - ** - ** If an error occurs, *pzErr is set to point an an English language - ** description of the error and an SQLITE_XXX error code is returned. - ** In this case the caller must call sqlite3DbFree(db, ) on *pzErr. - */ - static int sqlite3VtabCallCreate( sqlite3 db, int iDb, string zTab, ref string pzErr ) - { - int rc = SQLITE_OK; - Table pTab; - Module pMod; - string zMod; - - pTab = sqlite3FindTable( db, zTab, db.aDb[iDb].zName ); - Debug.Assert( pTab != null && ( pTab.tabFlags & TF_Virtual ) != 0 && null == pTab.pVTable ); - - /* Locate the required virtual table module */ - zMod = pTab.azModuleArg[0]; - pMod = (Module)sqlite3HashFind( db.aModule, zMod, sqlite3Strlen30( zMod ), (Module)null ); - - /* If the module has been registered and includes a Create method, - ** invoke it now. If the module has not been registered, return an - ** error. Otherwise, do nothing. - */ - if ( null == pMod ) - { - pzErr = sqlite3MPrintf( db, "no such module: %s", zMod ); - rc = SQLITE_ERROR; - } - else - { - rc = vtabCallConstructor( db, pTab, pMod, pMod.pModule.xCreate, ref pzErr ); - } - - /* Justification of ALWAYS(): The xConstructor method is required to - ** create a valid sqlite3_vtab if it returns SQLITE_OK. */ - if ( rc == SQLITE_OK && ALWAYS( sqlite3GetVTable( db, pTab ) ) ) - { - rc = growVTrans( db ); - if ( rc == SQLITE_OK ) - { - addToVTrans( db, sqlite3GetVTable( db, pTab ) ); + Debug.Assert((rc & 0xff) == rc); + rc = sqlite3ApiExit(db, rc); + sqlite3_mutex_leave(db.mutex); + return rc; } - } - return rc; - } + /* + ** This function is invoked by the vdbe to call the xDestroy method + ** of the virtual table named zTab in database iDb. This occurs + ** when a DROP TABLE is mentioned. + ** + ** This call is a no-op if zTab is not a virtual table. + */ + static int sqlite3VtabCallDestroy(sqlite3 db, int iDb, string zTab) { + int rc = SQLITE_OK; + Table pTab; + + pTab = sqlite3FindTable(db, zTab, db.aDb[iDb].zName); + if (ALWAYS(pTab != null && pTab.pVTable != null)) { + VTable p = vtabDisconnectAll(db, pTab); + + Debug.Assert(rc == SQLITE_OK); + object obj = p.pVtab; + rc = p.pMod.pModule.xDestroy(ref obj); + p.pVtab = null; + + /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */ + if (rc == SQLITE_OK) { + Debug.Assert(pTab.pVTable == p && p.pNext == null); + p.pVtab = null; + pTab.pVTable = null; + sqlite3VtabUnlock(p); + } + } - /* - ** This function is used to set the schema of a virtual table. It is only - ** valid to call this function from within the xCreate() or xConnect() of a - ** virtual table module. - */ - static int sqlite3_declare_vtab( sqlite3 db, string zCreateTable ) - { - Parse pParse; - - int rc = SQLITE_OK; - Table pTab; - string zErr = ""; - - sqlite3_mutex_enter( db.mutex ); - if ( null == db.pVtabCtx || null == ( pTab = db.pVtabCtx.pTab ) ) - { - sqlite3Error( db, SQLITE_MISUSE, 0 ); - sqlite3_mutex_leave( db.mutex ); - return SQLITE_MISUSE_BKPT(); - } - Debug.Assert( ( pTab.tabFlags & TF_Virtual ) != 0 ); - - pParse = new Parse();//sqlite3StackAllocZero(db, sizeof(*pParse)); - //if ( pParse == null ) - //{ - // rc = SQLITE_NOMEM; - //} - //else - { - pParse.declareVtab = 1; - pParse.db = db; - pParse.nQueryLoop = 1; - - if ( SQLITE_OK == sqlite3RunParser( pParse, zCreateTable, ref zErr ) - && pParse.pNewTable != null - //&& !db.mallocFailed - && null==pParse.pNewTable.pSelect - && ( pParse.pNewTable.tabFlags & TF_Virtual ) == 0 - ) - { - if ( null==pTab.aCol ) - { - pTab.aCol = pParse.pNewTable.aCol; - pTab.nCol = pParse.pNewTable.nCol; - pParse.pNewTable.nCol = 0; - pParse.pNewTable.aCol = null; - } - db.pVtabCtx.pTab = null; + return rc; } - else - { - sqlite3Error( db, SQLITE_ERROR, ( zErr != null ? "%s" : null ), zErr ); - zErr = null;//sqlite3DbFree( db, zErr ); - rc = SQLITE_ERROR; + + /* + ** This function invokes either the xRollback or xCommit method + ** of each of the virtual tables in the sqlite3.aVTrans array. The method + ** called is identified by the second argument, "offset", which is + ** the offset of the method to call in the sqlite3_module structure. + ** + ** The array is cleared after invoking the callbacks. + */ + static void callFinaliser(sqlite3 db, int offset) { + int i; + if (db.aVTrans != null) { + for (i = 0; i < db.nVTrans; i++) { + VTable pVTab = db.aVTrans[i]; + sqlite3_vtab p = pVTab.pVtab; + if (p != null) { + //int (*x)(sqlite3_vtab ); + //x = *(int (*)(sqlite3_vtab ))((char )p.pModule + offset); + //if( x ) x(p); + if (offset == 0) { + if (p.pModule.xCommit != null) + p.pModule.xCommit(p); + } else { + if (p.pModule.xRollback != null) + p.pModule.xRollback(p); + } + } + pVTab.iSavepoint = 0; + sqlite3VtabUnlock(pVTab); + } + sqlite3DbFree(db, ref db.aVTrans); + db.nVTrans = 0; + db.aVTrans = null; + } } - pParse.declareVtab = 0; - if ( pParse.pVdbe !=null) - { - sqlite3VdbeFinalize( ref pParse.pVdbe ); + /* + ** Invoke the xSync method of all virtual tables in the sqlite3.aVTrans + ** array. Return the error code for the first error that occurs, or + ** SQLITE_OK if all xSync operations are successful. + ** + ** Set *pzErrmsg to point to a buffer that should be released using + ** sqlite3DbFree() containing an error message, if one is available. + */ + static int sqlite3VtabSync(sqlite3 db, ref string pzErrmsg) { + int i; + int rc = SQLITE_OK; + VTable[] aVTrans = db.aVTrans; + + db.aVTrans = null; + for (i = 0; rc == SQLITE_OK && i < db.nVTrans; i++) { + smdxFunction x;//int (*x)(sqlite3_vtab ); + sqlite3_vtab pVtab = aVTrans[i].pVtab; + if (pVtab != null && (x = pVtab.pModule.xSync) != null) { + rc = x(pVtab); + //sqlite3DbFree(db, ref pzErrmsg); + pzErrmsg = pVtab.zErrMsg;// sqlite3DbStrDup( db, pVtab.zErrMsg ); + pVtab.zErrMsg = null;//sqlite3_free( ref pVtab.zErrMsg ); + } + } + db.aVTrans = aVTrans; + return rc; } - sqlite3DeleteTable( db, ref pParse.pNewTable ); - //sqlite3StackFree( db, pParse ); - } - - Debug.Assert( ( rc & 0xff ) == rc ); - rc = sqlite3ApiExit( db, rc ); - sqlite3_mutex_leave( db.mutex ); - return rc; - } - /* - ** This function is invoked by the vdbe to call the xDestroy method - ** of the virtual table named zTab in database iDb. This occurs - ** when a DROP TABLE is mentioned. - ** - ** This call is a no-op if zTab is not a virtual table. - */ - static int sqlite3VtabCallDestroy( sqlite3 db, int iDb, string zTab ) - { - int rc = SQLITE_OK; - Table pTab; - - pTab = sqlite3FindTable( db, zTab, db.aDb[iDb].zName ); - if ( ALWAYS( pTab != null && pTab.pVTable != null ) ) - { - VTable p = vtabDisconnectAll( db, pTab ); - - Debug.Assert( rc == SQLITE_OK ); - object obj = p.pVtab; - rc = p.pMod.pModule.xDestroy( ref obj ); - p.pVtab = null; - - /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */ - if ( rc == SQLITE_OK ) - { - Debug.Assert( pTab.pVTable == p && p.pNext == null ); - p.pVtab = null; - pTab.pVTable = null; - sqlite3VtabUnlock( p ); + /* + ** Invoke the xRollback method of all virtual tables in the + ** sqlite3.aVTrans array. Then clear the array itself. + */ + static int sqlite3VtabRollback(sqlite3 db) { + callFinaliser(db, 1);//offsetof( sqlite3_module, xRollback ) ); + return SQLITE_OK; } - } - return rc; - } + /* + ** Invoke the xCommit method of all virtual tables in the + ** sqlite3.aVTrans array. Then clear the array itself. + */ + static int sqlite3VtabCommit(sqlite3 db) { + callFinaliser(db, 0);//offsetof( sqlite3_module, xCommit ) ); + return SQLITE_OK; + } - /* - ** This function invokes either the xRollback or xCommit method - ** of each of the virtual tables in the sqlite3.aVTrans array. The method - ** called is identified by the second argument, "offset", which is - ** the offset of the method to call in the sqlite3_module structure. - ** - ** The array is cleared after invoking the callbacks. - */ - static void callFinaliser( sqlite3 db, int offset ) - { - int i; - if ( db.aVTrans != null ) - { - for ( i = 0; i < db.nVTrans; i++ ) - { - VTable pVTab = db.aVTrans[i]; - sqlite3_vtab p = pVTab.pVtab; - if ( p != null ) - { - //int (*x)(sqlite3_vtab ); - //x = *(int (*)(sqlite3_vtab ))((char )p.pModule + offset); - //if( x ) x(p); - if ( offset == 0 ) - { - if ( p.pModule.xCommit != null ) - p.pModule.xCommit( p ); + /* + ** If the virtual table pVtab supports the transaction interface + ** (xBegin/xRollback/xCommit and optionally xSync) and a transaction is + ** not currently open, invoke the xBegin method now. + ** + ** If the xBegin call is successful, place the sqlite3_vtab pointer + ** in the sqlite3.aVTrans array. + */ + static int sqlite3VtabBegin(sqlite3 db, VTable pVTab) { + int rc = SQLITE_OK; + sqlite3_module pModule; + + /* Special case: If db.aVTrans is NULL and db.nVTrans is greater + ** than zero, then this function is being called from within a + ** virtual module xSync() callback. It is illegal to write to + ** virtual module tables in this case, so return SQLITE_LOCKED. + */ + if (sqlite3VtabInSync(db)) { + return SQLITE_LOCKED; } - else - { - if ( p.pModule.xRollback != null ) - p.pModule.xRollback( p ); + if (null == pVTab) { + return SQLITE_OK; } - } - pVTab.iSavepoint = 0; - sqlite3VtabUnlock( pVTab ); - } - sqlite3DbFree( db, ref db.aVTrans ); - db.nVTrans = 0; - db.aVTrans = null; - } - } + pModule = pVTab.pVtab.pModule; - /* - ** Invoke the xSync method of all virtual tables in the sqlite3.aVTrans - ** array. Return the error code for the first error that occurs, or - ** SQLITE_OK if all xSync operations are successful. - ** - ** Set *pzErrmsg to point to a buffer that should be released using - ** sqlite3DbFree() containing an error message, if one is available. - */ - static int sqlite3VtabSync( sqlite3 db, ref string pzErrmsg ) - { - int i; - int rc = SQLITE_OK; - VTable[] aVTrans = db.aVTrans; - - db.aVTrans = null; - for ( i = 0; rc == SQLITE_OK && i < db.nVTrans; i++ ) - { - smdxFunction x;//int (*x)(sqlite3_vtab ); - sqlite3_vtab pVtab = aVTrans[i].pVtab; - if ( pVtab != null && ( x = pVtab.pModule.xSync ) != null ) - { - rc = x( pVtab ); - //sqlite3DbFree(db, ref pzErrmsg); - pzErrmsg = pVtab.zErrMsg;// sqlite3DbStrDup( db, pVtab.zErrMsg ); - pVtab.zErrMsg = null;//sqlite3_free( ref pVtab.zErrMsg ); - } - } - db.aVTrans = aVTrans; - return rc; - } + if (pModule.xBegin != null) { + int i; - /* - ** Invoke the xRollback method of all virtual tables in the - ** sqlite3.aVTrans array. Then clear the array itself. - */ - static int sqlite3VtabRollback( sqlite3 db ) - { - callFinaliser( db, 1 );//offsetof( sqlite3_module, xRollback ) ); - return SQLITE_OK; - } + /* If pVtab is already in the aVTrans array, return early */ + for (i = 0; i < db.nVTrans; i++) { + if (db.aVTrans[i] == pVTab) { + return SQLITE_OK; + } + } - /* - ** Invoke the xCommit method of all virtual tables in the - ** sqlite3.aVTrans array. Then clear the array itself. - */ - static int sqlite3VtabCommit( sqlite3 db ) - { - callFinaliser( db, 0 );//offsetof( sqlite3_module, xCommit ) ); - return SQLITE_OK; - } + /* Invoke the xBegin method. If successful, add the vtab to the + ** sqlite3.aVTrans[] array. */ + rc = growVTrans(db); + if (rc == SQLITE_OK) { + rc = pModule.xBegin(pVTab.pVtab); + if (rc == SQLITE_OK) { + addToVTrans(db, pVTab); + } + } + } + return rc; + } - /* - ** If the virtual table pVtab supports the transaction interface - ** (xBegin/xRollback/xCommit and optionally xSync) and a transaction is - ** not currently open, invoke the xBegin method now. - ** - ** If the xBegin call is successful, place the sqlite3_vtab pointer - ** in the sqlite3.aVTrans array. - */ - static int sqlite3VtabBegin( sqlite3 db, VTable pVTab ) - { - int rc = SQLITE_OK; - sqlite3_module pModule; - - /* Special case: If db.aVTrans is NULL and db.nVTrans is greater - ** than zero, then this function is being called from within a - ** virtual module xSync() callback. It is illegal to write to - ** virtual module tables in this case, so return SQLITE_LOCKED. - */ - if ( sqlite3VtabInSync( db ) ) - { - return SQLITE_LOCKED; - } - if ( null == pVTab ) - { - return SQLITE_OK; - } - pModule = pVTab.pVtab.pModule; - - if ( pModule.xBegin != null ) - { - int i; - - /* If pVtab is already in the aVTrans array, return early */ - for ( i = 0; i < db.nVTrans; i++ ) - { - if ( db.aVTrans[i] == pVTab ) - { - return SQLITE_OK; - } + /* + ** Invoke either the xSavepoint, xRollbackTo or xRelease method of all + ** virtual tables that currently have an open transaction. Pass iSavepoint + ** as the second argument to the virtual table method invoked. + ** + ** If op is SAVEPOINT_BEGIN, the xSavepoint method is invoked. If it is + ** SAVEPOINT_ROLLBACK, the xRollbackTo method. Otherwise, if op is + ** SAVEPOINT_RELEASE, then the xRelease method of each virtual table with + ** an open transaction is invoked. + ** + ** If any virtual table method returns an error code other than SQLITE_OK, + ** processing is abandoned and the error returned to the caller of this + ** function immediately. If all calls to virtual table methods are successful, + ** SQLITE_OK is returned. + */ + static int sqlite3VtabSavepoint(sqlite3 db, int op, int iSavepoint) { + int rc = SQLITE_OK; + + Debug.Assert(op == SAVEPOINT_RELEASE || op == SAVEPOINT_ROLLBACK || op == SAVEPOINT_BEGIN); + Debug.Assert(iSavepoint >= 0); + if (db.aVTrans != null) { + int i; + for (i = 0; rc == SQLITE_OK && i < db.nVTrans; i++) { + VTable pVTab = db.aVTrans[i]; + sqlite3_module pMod = pVTab.pMod.pModule; + if (pMod.iVersion >= 2) { + smdxFunctionArg xMethod = null; //int (*xMethod)(sqlite3_vtab *, int); + switch (op) { + case SAVEPOINT_BEGIN: + xMethod = pMod.xSavepoint; + pVTab.iSavepoint = iSavepoint + 1; + break; + case SAVEPOINT_ROLLBACK: + xMethod = pMod.xRollbackTo; + break; + default: + xMethod = pMod.xRelease; + break; + } + if (xMethod != null && pVTab.iSavepoint > iSavepoint) { + rc = xMethod(db.aVTrans[i].pVtab, iSavepoint); + } + } + } + } + return rc; } - /* Invoke the xBegin method. If successful, add the vtab to the - ** sqlite3.aVTrans[] array. */ - rc = growVTrans( db ); - if ( rc == SQLITE_OK ) - { - rc = pModule.xBegin( pVTab.pVtab ); - if ( rc == SQLITE_OK ) - { - addToVTrans( db, pVTab ); - } + /* + ** The first parameter (pDef) is a function implementation. The + ** second parameter (pExpr) is the first argument to this function. + ** If pExpr is a column in a virtual table, then let the virtual + ** table implementation have an opportunity to overload the function. + ** + ** This routine is used to allow virtual table implementations to + ** overload MATCH, LIKE, GLOB, and REGEXP operators. + ** + ** Return either the pDef argument (indicating no change) or a + ** new FuncDef structure that is marked as ephemeral using the + ** SQLITE_FUNC_EPHEM flag. + */ + static FuncDef sqlite3VtabOverloadFunction( + sqlite3 db, /* Database connection for reporting malloc problems */ + FuncDef pDef, /* Function to possibly overload */ + int nArg, /* Number of arguments to the function */ + Expr pExpr /* First argument to the function */ + ) { + Table pTab; + sqlite3_vtab pVtab; + sqlite3_module pMod; + dxFunc xFunc = null;//void (*xFunc)(sqlite3_context*,int,sqlite3_value*) = 0; + object pArg = null; + FuncDef pNew; + int rc = 0; + string zLowerName; + string z; + + /* Check to see the left operand is a column in a virtual table */ + if (NEVER(pExpr == null)) + return pDef; + if (pExpr.op != TK_COLUMN) + return pDef; + pTab = pExpr.pTab; + if (NEVER(pTab == null)) + return pDef; + if ((pTab.tabFlags & TF_Virtual) == 0) + return pDef; + pVtab = sqlite3GetVTable(db, pTab).pVtab; + Debug.Assert(pVtab != null); + Debug.Assert(pVtab.pModule != null); + pMod = (sqlite3_module)pVtab.pModule; + if (pMod.xFindFunction == null) + return pDef; + + /* Call the xFindFunction method on the virtual table implementation + ** to see if the implementation wants to overload this function + */ + zLowerName = pDef.zName;//sqlite3DbStrDup(db, pDef.zName); + if (zLowerName != null) { + //for(z=(unsigned char)zLowerName; *z; z++){ + // *z = sqlite3UpperToLower[*z]; + //} + rc = pMod.xFindFunction(pVtab, nArg, zLowerName.ToLowerInvariant(), ref xFunc, ref pArg); + sqlite3DbFree(db, ref zLowerName); + } + if (rc == 0) { + return pDef; + } + + /* Create a new ephemeral function definition for the overloaded + ** function */ + //sqlite3DbMallocZero(db, sizeof(*pNew) + // + sqlite3Strlen30(pDef.zName) + 1); + //if ( pNew == null ) + //{ + // return pDef; + //} + pNew = pDef.Copy(); + pNew.zName = pDef.zName; + //pNew.zName = (char )&pNew[1]; + //memcpy(pNew.zName, pDef.zName, sqlite3Strlen30(pDef.zName)+1); + pNew.xFunc = xFunc; + pNew.pUserData = pArg; + pNew.flags |= SQLITE_FUNC_EPHEM; + return pNew; } - } - return rc; - } - /* - ** Invoke either the xSavepoint, xRollbackTo or xRelease method of all - ** virtual tables that currently have an open transaction. Pass iSavepoint - ** as the second argument to the virtual table method invoked. - ** - ** If op is SAVEPOINT_BEGIN, the xSavepoint method is invoked. If it is - ** SAVEPOINT_ROLLBACK, the xRollbackTo method. Otherwise, if op is - ** SAVEPOINT_RELEASE, then the xRelease method of each virtual table with - ** an open transaction is invoked. - ** - ** If any virtual table method returns an error code other than SQLITE_OK, - ** processing is abandoned and the error returned to the caller of this - ** function immediately. If all calls to virtual table methods are successful, - ** SQLITE_OK is returned. - */ - static int sqlite3VtabSavepoint( sqlite3 db, int op, int iSavepoint ) - { - int rc = SQLITE_OK; - - Debug.Assert( op == SAVEPOINT_RELEASE || op == SAVEPOINT_ROLLBACK || op == SAVEPOINT_BEGIN ); - Debug.Assert( iSavepoint >= 0 ); - if ( db.aVTrans != null ) - { - int i; - for ( i = 0; rc == SQLITE_OK && i < db.nVTrans; i++ ) - { - VTable pVTab = db.aVTrans[i]; - sqlite3_module pMod = pVTab.pMod.pModule; - if ( pMod.iVersion >= 2 ) - { - smdxFunctionArg xMethod = null; //int (*xMethod)(sqlite3_vtab *, int); - switch ( op ) - { - case SAVEPOINT_BEGIN: - xMethod = pMod.xSavepoint; - pVTab.iSavepoint = iSavepoint + 1; - break; - case SAVEPOINT_ROLLBACK: - xMethod = pMod.xRollbackTo; - break; - default: - xMethod = pMod.xRelease; - break; + /* + ** Make sure virtual table pTab is contained in the pParse.apVirtualLock[] + ** array so that an OP_VBegin will get generated for it. Add pTab to the + ** array if it is missing. If pTab is already in the array, this routine + ** is a no-op. + */ + static void sqlite3VtabMakeWritable(Parse pParse, Table pTab) { + Parse pToplevel = sqlite3ParseToplevel(pParse); + int i, n; + //Table[] apVtabLock = null; + + Debug.Assert(IsVirtual(pTab)); + for (i = 0; i < pToplevel.nVtabLock; i++) { + if (pTab == pToplevel.apVtabLock[i]) + return; } - if ( xMethod != null && pVTab.iSavepoint > iSavepoint ) + n = pToplevel.apVtabLock == null ? 1 : pToplevel.apVtabLock.Length + 1;//(pToplevel.nVtabLock+1)*sizeof(pToplevel.apVtabLock[0]); + //sqlite3_realloc( pToplevel.apVtabLock, n ); + //if ( apVtabLock != null ) { - rc = xMethod( db.aVTrans[i].pVtab, iSavepoint ); + Array.Resize(ref pToplevel.apVtabLock, n);// pToplevel.apVtabLock= apVtabLock; + pToplevel.apVtabLock[pToplevel.nVtabLock++] = pTab; } - } + //else + //{ + // pToplevel.db.mallocFailed = 1; + //} } - } - return rc; - } - /* - ** The first parameter (pDef) is a function implementation. The - ** second parameter (pExpr) is the first argument to this function. - ** If pExpr is a column in a virtual table, then let the virtual - ** table implementation have an opportunity to overload the function. - ** - ** This routine is used to allow virtual table implementations to - ** overload MATCH, LIKE, GLOB, and REGEXP operators. - ** - ** Return either the pDef argument (indicating no change) or a - ** new FuncDef structure that is marked as ephemeral using the - ** SQLITE_FUNC_EPHEM flag. - */ - static FuncDef sqlite3VtabOverloadFunction( - sqlite3 db, /* Database connection for reporting malloc problems */ - FuncDef pDef, /* Function to possibly overload */ - int nArg, /* Number of arguments to the function */ - Expr pExpr /* First argument to the function */ - ) - { - Table pTab; - sqlite3_vtab pVtab; - sqlite3_module pMod; - dxFunc xFunc = null;//void (*xFunc)(sqlite3_context*,int,sqlite3_value*) = 0; - object pArg = null; - FuncDef pNew; - int rc = 0; - string zLowerName; - string z; - - /* Check to see the left operand is a column in a virtual table */ - if ( NEVER( pExpr == null ) ) - return pDef; - if ( pExpr.op != TK_COLUMN ) - return pDef; - pTab = pExpr.pTab; - if ( NEVER( pTab == null ) ) - return pDef; - if ( ( pTab.tabFlags & TF_Virtual ) == 0 ) - return pDef; - pVtab = sqlite3GetVTable( db, pTab ).pVtab; - Debug.Assert( pVtab != null ); - Debug.Assert( pVtab.pModule != null ); - pMod = (sqlite3_module)pVtab.pModule; - if ( pMod.xFindFunction == null ) - return pDef; - - /* Call the xFindFunction method on the virtual table implementation - ** to see if the implementation wants to overload this function - */ - zLowerName = pDef.zName;//sqlite3DbStrDup(db, pDef.zName); - if ( zLowerName != null ) - { - //for(z=(unsigned char)zLowerName; *z; z++){ - // *z = sqlite3UpperToLower[*z]; - //} - rc = pMod.xFindFunction( pVtab, nArg, zLowerName.ToLowerInvariant(), ref xFunc, ref pArg ); - sqlite3DbFree( db, ref zLowerName ); - } - if ( rc == 0 ) - { - return pDef; - } - - /* Create a new ephemeral function definition for the overloaded - ** function */ - //sqlite3DbMallocZero(db, sizeof(*pNew) - // + sqlite3Strlen30(pDef.zName) + 1); - //if ( pNew == null ) - //{ - // return pDef; - //} - pNew = pDef.Copy(); - pNew.zName = pDef.zName; - //pNew.zName = (char )&pNew[1]; - //memcpy(pNew.zName, pDef.zName, sqlite3Strlen30(pDef.zName)+1); - pNew.xFunc = xFunc; - pNew.pUserData = pArg; - pNew.flags |= SQLITE_FUNC_EPHEM; - return pNew; - } - - /* - ** Make sure virtual table pTab is contained in the pParse.apVirtualLock[] - ** array so that an OP_VBegin will get generated for it. Add pTab to the - ** array if it is missing. If pTab is already in the array, this routine - ** is a no-op. - */ - static void sqlite3VtabMakeWritable( Parse pParse, Table pTab ) - { - Parse pToplevel = sqlite3ParseToplevel( pParse ); - int i, n; - //Table[] apVtabLock = null; - - Debug.Assert( IsVirtual( pTab ) ); - for ( i = 0; i < pToplevel.nVtabLock; i++ ) - { - if ( pTab == pToplevel.apVtabLock[i] ) - return; - } - n = pToplevel.apVtabLock == null ? 1 : pToplevel.apVtabLock.Length + 1;//(pToplevel.nVtabLock+1)*sizeof(pToplevel.apVtabLock[0]); - //sqlite3_realloc( pToplevel.apVtabLock, n ); - //if ( apVtabLock != null ) - { - Array.Resize( ref pToplevel.apVtabLock, n );// pToplevel.apVtabLock= apVtabLock; - pToplevel.apVtabLock[pToplevel.nVtabLock++] = pTab; - } - //else - //{ - // pToplevel.db.mallocFailed = 1; - //} - } - - static int[] aMap = new int[] { - SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE + static int[] aMap = new int[] { + SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE }; - /* - ** Return the ON CONFLICT resolution mode in effect for the virtual - ** table update operation currently in progress. - ** - ** The results of this routine are undefined unless it is called from - ** within an xUpdate method. - */ - static int sqlite3_vtab_on_conflict( sqlite3 db ){ - //static const unsigned char aMap[] = { - // SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE - //}; - Debug.Assert( OE_Rollback==1 && OE_Abort==2 && OE_Fail==3 ); - Debug.Assert( OE_Ignore==4 && OE_Replace==5 ); - Debug.Assert( db.vtabOnConflict>=1 && db.vtabOnConflict<=5 ); - return (int)aMap[db.vtabOnConflict-1]; -} + /* + ** Return the ON CONFLICT resolution mode in effect for the virtual + ** table update operation currently in progress. + ** + ** The results of this routine are undefined unless it is called from + ** within an xUpdate method. + */ + static int sqlite3_vtab_on_conflict(sqlite3 db) { + //static const unsigned char aMap[] = { + // SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE + //}; + Debug.Assert(OE_Rollback == 1 && OE_Abort == 2 && OE_Fail == 3); + Debug.Assert(OE_Ignore == 4 && OE_Replace == 5); + Debug.Assert(db.vtabOnConflict >= 1 && db.vtabOnConflict <= 5); + return (int)aMap[db.vtabOnConflict - 1]; + } - /* - ** Call from within the xCreate() or xConnect() methods to provide - ** the SQLite core with additional information about the behavior - ** of the virtual table being implemented. - */ - static int sqlite3_vtab_config( sqlite3 db, int op, params object[] ap ){ // TODO ...){ - //va_list ap; - int rc = SQLITE_OK; - - sqlite3_mutex_enter(db.mutex); - - va_start(ap, "op"); - switch( op ){ - case SQLITE_VTAB_CONSTRAINT_SUPPORT: { - VtabCtx p = db.pVtabCtx; - if( null == p ){ - rc = SQLITE_MISUSE_BKPT(); - }else{ - Debug.Assert( p.pTab == null || ( p.pTab.tabFlags & TF_Virtual ) != 0 ); - p.pVTable.bConstraint = (Byte)va_arg(ap, (Int32)0); - } - break; - } - default: - rc = SQLITE_MISUSE_BKPT(); - break; - } - va_end(ref ap); + /* + ** Call from within the xCreate() or xConnect() methods to provide + ** the SQLite core with additional information about the behavior + ** of the virtual table being implemented. + */ + static int sqlite3_vtab_config(sqlite3 db, int op, params object[] ap) { // TODO ...){ + //va_list ap; + int rc = SQLITE_OK; + + sqlite3_mutex_enter(db.mutex); + + va_start(ap, "op"); + switch (op) { + case SQLITE_VTAB_CONSTRAINT_SUPPORT: { + VtabCtx p = db.pVtabCtx; + if (null == p) { + rc = SQLITE_MISUSE_BKPT(); + } else { + Debug.Assert(p.pTab == null || (p.pTab.tabFlags & TF_Virtual) != 0); + p.pVTable.bConstraint = (Byte)va_arg(ap, (Int32)0); + } + break; + } + default: + rc = SQLITE_MISUSE_BKPT(); + break; + } + va_end(ref ap); - if( rc!=SQLITE_OK ) sqlite3Error(db, rc, 0); - sqlite3_mutex_leave(db.mutex); - return rc; -} + if (rc != SQLITE_OK) sqlite3Error(db, rc, 0); + sqlite3_mutex_leave(db.mutex); + return rc; + } #endif //* SQLITE_OMIT_VIRTUALTABLE */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/wal_c.cs b/Src/IronPython.SQLite/c#sqlite/wal_c.cs index 00db88b42..abea4175f 100644 --- a/Src/IronPython.SQLite/c#sqlite/wal_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/wal_c.cs @@ -1,262 +1,253 @@ -using System; -using System.Diagnostics; -using System.Text; - -using Bitmask = System.UInt64; -using u32 = System.UInt32; - -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 2010 February 1 - ** - ** 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 contains the implementation of a write-ahead log (WAL) used in - ** "journal_mode=WAL" mode. - ** - ** WRITE-AHEAD LOG (WAL) FILE FORMAT - ** - ** A WAL file consists of a header followed by zero or more "frames". - ** Each frame records the revised content of a single page from the - ** database file. All changes to the database are recorded by writing - ** frames into the WAL. Transactions commit when a frame is written that - ** contains a commit marker. A single WAL can and usually does record - ** multiple transactions. Periodically, the content of the WAL is - ** transferred back into the database file in an operation called a - ** "checkpoint". - ** - ** A single WAL file can be used multiple times. In other words, the - ** WAL can fill up with frames and then be checkpointed and then new - ** frames can overwrite the old ones. A WAL always grows from beginning - ** toward the end. Checksums and counters attached to each frame are - ** used to determine which frames within the WAL are valid and which - ** are leftovers from prior checkpoints. - ** - ** The WAL header is 32 bytes in size and consists of the following eight - ** big-endian 32-bit unsigned integer values: - ** - ** 0: Magic number. 0x377f0682 or 0x377f0683 - ** 4: File format version. Currently 3007000 - ** 8: Database page size. Example: 1024 - ** 12: Checkpoint sequence number - ** 16: Salt-1, random integer incremented with each checkpoint - ** 20: Salt-2, a different random integer changing with each ckpt - ** 24: Checksum-1 (first part of checksum for first 24 bytes of header). - ** 28: Checksum-2 (second part of checksum for first 24 bytes of header). - ** - ** Immediately following the wal-header are zero or more frames. Each - ** frame consists of a 24-byte frame-header followed by a bytes - ** of page data. The frame-header is six big-endian 32-bit unsigned - ** integer values, as follows: - ** - ** 0: Page number. - ** 4: For commit records, the size of the database image in pages - ** after the commit. For all other records, zero. - ** 8: Salt-1 (copied from the header) - ** 12: Salt-2 (copied from the header) - ** 16: Checksum-1. - ** 20: Checksum-2. - ** - ** A frame is considered valid if and only if the following conditions are - ** true: - ** - ** (1) The salt-1 and salt-2 values in the frame-header match - ** salt values in the wal-header - ** - ** (2) The checksum values in the final 8 bytes of the frame-header - ** exactly match the checksum computed consecutively on the - ** WAL header and the first 8 bytes and the content of all frames - ** up to and including the current frame. - ** - ** The checksum is computed using 32-bit big-endian integers if the - ** magic number in the first 4 bytes of the WAL is 0x377f0683 and it - ** is computed using little-endian if the magic number is 0x377f0682. - ** The checksum values are always stored in the frame header in a - ** big-endian format regardless of which byte order is used to compute - ** the checksum. The checksum is computed by interpreting the input as - ** an even number of unsigned 32-bit integers: x[0] through x[N]. The - ** algorithm used for the checksum is as follows: - ** - ** for i from 0 to n-1 step 2: - ** s0 += x[i] + s1; - ** s1 += x[i+1] + s0; - ** endfor - ** - ** Note that s0 and s1 are both weighted checksums using fibonacci weights - ** in reverse order (the largest fibonacci weight occurs on the first element - ** of the sequence being summed.) The s1 value spans all 32-bit - ** terms of the sequence whereas s0 omits the final term. - ** - ** On a checkpoint, the WAL is first VFS.xSync-ed, then valid content of the - ** WAL is transferred into the database, then the database is VFS.xSync-ed. - ** The VFS.xSync operations serve as write barriers - all writes launched - ** before the xSync must complete before any write that launches after the - ** xSync begins. - ** - ** After each checkpoint, the salt-1 value is incremented and the salt-2 - ** value is randomized. This prevents old and new frames in the WAL from - ** being considered valid at the same time and being checkpointing together - ** following a crash. - ** - ** READER ALGORITHM - ** - ** To read a page from the database (call it page number P), a reader - ** first checks the WAL to see if it contains page P. If so, then the - ** last valid instance of page P that is a followed by a commit frame - ** or is a commit frame itself becomes the value read. If the WAL - ** contains no copies of page P that are valid and which are a commit - ** frame or are followed by a commit frame, then page P is read from - ** the database file. - ** - ** To start a read transaction, the reader records the index of the last - ** valid frame in the WAL. The reader uses this recorded "mxFrame" value - ** for all subsequent read operations. New transactions can be appended - ** to the WAL, but as long as the reader uses its original mxFrame value - ** and ignores the newly appended content, it will see a consistent snapshot - ** of the database from a single point in time. This technique allows - ** multiple concurrent readers to view different versions of the database - ** content simultaneously. - ** - ** The reader algorithm in the previous paragraphs works correctly, but - ** because frames for page P can appear anywhere within the WAL, the - ** reader has to scan the entire WAL looking for page P frames. If the - ** WAL is large (multiple megabytes is typical) that scan can be slow, - ** and read performance suffers. To overcome this problem, a separate - ** data structure called the wal-index is maintained to expedite the - ** search for frames of a particular page. - ** - ** WAL-INDEX FORMAT - ** - ** Conceptually, the wal-index is shared memory, though VFS implementations - ** might choose to implement the wal-index using a mmapped file. Because - ** the wal-index is shared memory, SQLite does not support journal_mode=WAL - ** on a network filesystem. All users of the database must be able to - ** share memory. - ** - ** The wal-index is transient. After a crash, the wal-index can (and should - ** be) reconstructed from the original WAL file. In fact, the VFS is required - ** to either truncate or zero the header of the wal-index when the last - ** connection to it closes. Because the wal-index is transient, it can - ** use an architecture-specific format; it does not have to be cross-platform. - ** Hence, unlike the database and WAL file formats which store all values - ** as big endian, the wal-index can store multi-byte values in the native - ** byte order of the host computer. - ** - ** The purpose of the wal-index is to answer this question quickly: Given - ** a page number P, return the index of the last frame for page P in the WAL, - ** or return NULL if there are no frames for page P in the WAL. - ** - ** The wal-index consists of a header region, followed by an one or - ** more index blocks. - ** - ** The wal-index header contains the total number of frames within the WAL - ** in the the mxFrame field. - ** - ** Each index block except for the first contains information on - ** HASHTABLE_NPAGE frames. The first index block contains information on - ** HASHTABLE_NPAGE_ONE frames. The values of HASHTABLE_NPAGE_ONE and - ** HASHTABLE_NPAGE are selected so that together the wal-index header and - ** first index block are the same size as all other index blocks in the - ** wal-index. - ** - ** Each index block contains two sections, a page-mapping that contains the - ** database page number associated with each wal frame, and a hash-table - ** that allows readers to query an index block for a specific page number. - ** The page-mapping is an array of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE - ** for the first index block) 32-bit page numbers. The first entry in the - ** first index-block contains the database page number corresponding to the - ** first frame in the WAL file. The first entry in the second index block - ** in the WAL file corresponds to the (HASHTABLE_NPAGE_ONE+1)th frame in - ** the log, and so on. - ** - ** The last index block in a wal-index usually contains less than the full - ** complement of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE) page-numbers, - ** depending on the contents of the WAL file. This does not change the - ** allocated size of the page-mapping array - the page-mapping array merely - ** contains unused entries. - ** - ** Even without using the hash table, the last frame for page P - ** can be found by scanning the page-mapping sections of each index block - ** starting with the last index block and moving toward the first, and - ** within each index block, starting at the end and moving toward the - ** beginning. The first entry that equals P corresponds to the frame - ** holding the content for that page. - ** - ** The hash table consists of HASHTABLE_NSLOT 16-bit unsigned integers. - ** HASHTABLE_NSLOT = 2*HASHTABLE_NPAGE, and there is one entry in the - ** hash table for each page number in the mapping section, so the hash - ** table is never more than half full. The expected number of collisions - ** prior to finding a match is 1. Each entry of the hash table is an - ** 1-based index of an entry in the mapping section of the same - ** index block. Let K be the 1-based index of the largest entry in - ** the mapping section. (For index blocks other than the last, K will - ** always be exactly HASHTABLE_NPAGE (4096) and for the last index block - ** K will be (mxFrame%HASHTABLE_NPAGE).) Unused slots of the hash table - ** contain a value of 0. - ** - ** To look for page P in the hash table, first compute a hash iKey on - ** P as follows: - ** - ** iKey = (P * 383) % HASHTABLE_NSLOT - ** - ** Then start scanning entries of the hash table, starting with iKey - ** (wrapping around to the beginning when the end of the hash table is - ** reached) until an unused hash slot is found. Let the first unused slot - ** be at index iUnused. (iUnused might be less than iKey if there was - ** wrap-around.) Because the hash table is never more than half full, - ** the search is guaranteed to eventually hit an unused entry. Let - ** iMax be the value between iKey and iUnused, closest to iUnused, - ** where aHash[iMax]==P. If there is no iMax entry (if there exists - ** no hash slot such that aHash[i]==p) then page P is not in the - ** current index block. Otherwise the iMax-th mapping entry of the - ** current index block corresponds to the last entry that references - ** page P. - ** - ** A hash search begins with the last index block and moves toward the - ** first index block, looking for entries corresponding to page P. On - ** average, only two or three slots in each index block need to be - ** examined in order to either find the last entry for page P, or to - ** establish that no such entry exists in the block. Each index block - ** holds over 4000 entries. So two or three index blocks are sufficient - ** to cover a typical 10 megabyte WAL file, assuming 1K pages. 8 or 10 - ** comparisons (on average) suffice to either locate a frame in the - ** WAL or to establish that the frame does not exist in the WAL. This - ** is much faster than scanning the entire 10MB WAL. - ** - ** Note that entries are added in order of increasing K. Hence, one - ** reader might be using some value K0 and a second reader that started - ** at a later time (after additional transactions were added to the WAL - ** and to the wal-index) might be using a different value K1, where K1>K0. - ** Both readers can use the same hash table and mapping section to get - ** the correct result. There may be entries in the hash table with - ** K>K0 but to the first reader, those entries will appear to be unused - ** slots in the hash table and so the first reader will get an answer as - ** if no values greater than K0 had ever been inserted into the hash table - ** in the first place - which is what reader one wants. Meanwhile, the - ** second reader using K1 will see additional values that were inserted - ** later, which is exactly what reader two wants. - ** - ** When a rollback occurs, the value of K is decreased. Hash table entries - ** that correspond to frames greater than the new K value are removed - ** from the hash table at this point. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2010 February 1 + ** + ** 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 contains the implementation of a write-ahead log (WAL) used in + ** "journal_mode=WAL" mode. + ** + ** WRITE-AHEAD LOG (WAL) FILE FORMAT + ** + ** A WAL file consists of a header followed by zero or more "frames". + ** Each frame records the revised content of a single page from the + ** database file. All changes to the database are recorded by writing + ** frames into the WAL. Transactions commit when a frame is written that + ** contains a commit marker. A single WAL can and usually does record + ** multiple transactions. Periodically, the content of the WAL is + ** transferred back into the database file in an operation called a + ** "checkpoint". + ** + ** A single WAL file can be used multiple times. In other words, the + ** WAL can fill up with frames and then be checkpointed and then new + ** frames can overwrite the old ones. A WAL always grows from beginning + ** toward the end. Checksums and counters attached to each frame are + ** used to determine which frames within the WAL are valid and which + ** are leftovers from prior checkpoints. + ** + ** The WAL header is 32 bytes in size and consists of the following eight + ** big-endian 32-bit unsigned integer values: + ** + ** 0: Magic number. 0x377f0682 or 0x377f0683 + ** 4: File format version. Currently 3007000 + ** 8: Database page size. Example: 1024 + ** 12: Checkpoint sequence number + ** 16: Salt-1, random integer incremented with each checkpoint + ** 20: Salt-2, a different random integer changing with each ckpt + ** 24: Checksum-1 (first part of checksum for first 24 bytes of header). + ** 28: Checksum-2 (second part of checksum for first 24 bytes of header). + ** + ** Immediately following the wal-header are zero or more frames. Each + ** frame consists of a 24-byte frame-header followed by a bytes + ** of page data. The frame-header is six big-endian 32-bit unsigned + ** integer values, as follows: + ** + ** 0: Page number. + ** 4: For commit records, the size of the database image in pages + ** after the commit. For all other records, zero. + ** 8: Salt-1 (copied from the header) + ** 12: Salt-2 (copied from the header) + ** 16: Checksum-1. + ** 20: Checksum-2. + ** + ** A frame is considered valid if and only if the following conditions are + ** true: + ** + ** (1) The salt-1 and salt-2 values in the frame-header match + ** salt values in the wal-header + ** + ** (2) The checksum values in the final 8 bytes of the frame-header + ** exactly match the checksum computed consecutively on the + ** WAL header and the first 8 bytes and the content of all frames + ** up to and including the current frame. + ** + ** The checksum is computed using 32-bit big-endian integers if the + ** magic number in the first 4 bytes of the WAL is 0x377f0683 and it + ** is computed using little-endian if the magic number is 0x377f0682. + ** The checksum values are always stored in the frame header in a + ** big-endian format regardless of which byte order is used to compute + ** the checksum. The checksum is computed by interpreting the input as + ** an even number of unsigned 32-bit integers: x[0] through x[N]. The + ** algorithm used for the checksum is as follows: + ** + ** for i from 0 to n-1 step 2: + ** s0 += x[i] + s1; + ** s1 += x[i+1] + s0; + ** endfor + ** + ** Note that s0 and s1 are both weighted checksums using fibonacci weights + ** in reverse order (the largest fibonacci weight occurs on the first element + ** of the sequence being summed.) The s1 value spans all 32-bit + ** terms of the sequence whereas s0 omits the final term. + ** + ** On a checkpoint, the WAL is first VFS.xSync-ed, then valid content of the + ** WAL is transferred into the database, then the database is VFS.xSync-ed. + ** The VFS.xSync operations serve as write barriers - all writes launched + ** before the xSync must complete before any write that launches after the + ** xSync begins. + ** + ** After each checkpoint, the salt-1 value is incremented and the salt-2 + ** value is randomized. This prevents old and new frames in the WAL from + ** being considered valid at the same time and being checkpointing together + ** following a crash. + ** + ** READER ALGORITHM + ** + ** To read a page from the database (call it page number P), a reader + ** first checks the WAL to see if it contains page P. If so, then the + ** last valid instance of page P that is a followed by a commit frame + ** or is a commit frame itself becomes the value read. If the WAL + ** contains no copies of page P that are valid and which are a commit + ** frame or are followed by a commit frame, then page P is read from + ** the database file. + ** + ** To start a read transaction, the reader records the index of the last + ** valid frame in the WAL. The reader uses this recorded "mxFrame" value + ** for all subsequent read operations. New transactions can be appended + ** to the WAL, but as long as the reader uses its original mxFrame value + ** and ignores the newly appended content, it will see a consistent snapshot + ** of the database from a single point in time. This technique allows + ** multiple concurrent readers to view different versions of the database + ** content simultaneously. + ** + ** The reader algorithm in the previous paragraphs works correctly, but + ** because frames for page P can appear anywhere within the WAL, the + ** reader has to scan the entire WAL looking for page P frames. If the + ** WAL is large (multiple megabytes is typical) that scan can be slow, + ** and read performance suffers. To overcome this problem, a separate + ** data structure called the wal-index is maintained to expedite the + ** search for frames of a particular page. + ** + ** WAL-INDEX FORMAT + ** + ** Conceptually, the wal-index is shared memory, though VFS implementations + ** might choose to implement the wal-index using a mmapped file. Because + ** the wal-index is shared memory, SQLite does not support journal_mode=WAL + ** on a network filesystem. All users of the database must be able to + ** share memory. + ** + ** The wal-index is transient. After a crash, the wal-index can (and should + ** be) reconstructed from the original WAL file. In fact, the VFS is required + ** to either truncate or zero the header of the wal-index when the last + ** connection to it closes. Because the wal-index is transient, it can + ** use an architecture-specific format; it does not have to be cross-platform. + ** Hence, unlike the database and WAL file formats which store all values + ** as big endian, the wal-index can store multi-byte values in the native + ** byte order of the host computer. + ** + ** The purpose of the wal-index is to answer this question quickly: Given + ** a page number P, return the index of the last frame for page P in the WAL, + ** or return NULL if there are no frames for page P in the WAL. + ** + ** The wal-index consists of a header region, followed by an one or + ** more index blocks. + ** + ** The wal-index header contains the total number of frames within the WAL + ** in the the mxFrame field. + ** + ** Each index block except for the first contains information on + ** HASHTABLE_NPAGE frames. The first index block contains information on + ** HASHTABLE_NPAGE_ONE frames. The values of HASHTABLE_NPAGE_ONE and + ** HASHTABLE_NPAGE are selected so that together the wal-index header and + ** first index block are the same size as all other index blocks in the + ** wal-index. + ** + ** Each index block contains two sections, a page-mapping that contains the + ** database page number associated with each wal frame, and a hash-table + ** that allows readers to query an index block for a specific page number. + ** The page-mapping is an array of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE + ** for the first index block) 32-bit page numbers. The first entry in the + ** first index-block contains the database page number corresponding to the + ** first frame in the WAL file. The first entry in the second index block + ** in the WAL file corresponds to the (HASHTABLE_NPAGE_ONE+1)th frame in + ** the log, and so on. + ** + ** The last index block in a wal-index usually contains less than the full + ** complement of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE) page-numbers, + ** depending on the contents of the WAL file. This does not change the + ** allocated size of the page-mapping array - the page-mapping array merely + ** contains unused entries. + ** + ** Even without using the hash table, the last frame for page P + ** can be found by scanning the page-mapping sections of each index block + ** starting with the last index block and moving toward the first, and + ** within each index block, starting at the end and moving toward the + ** beginning. The first entry that equals P corresponds to the frame + ** holding the content for that page. + ** + ** The hash table consists of HASHTABLE_NSLOT 16-bit unsigned integers. + ** HASHTABLE_NSLOT = 2*HASHTABLE_NPAGE, and there is one entry in the + ** hash table for each page number in the mapping section, so the hash + ** table is never more than half full. The expected number of collisions + ** prior to finding a match is 1. Each entry of the hash table is an + ** 1-based index of an entry in the mapping section of the same + ** index block. Let K be the 1-based index of the largest entry in + ** the mapping section. (For index blocks other than the last, K will + ** always be exactly HASHTABLE_NPAGE (4096) and for the last index block + ** K will be (mxFrame%HASHTABLE_NPAGE).) Unused slots of the hash table + ** contain a value of 0. + ** + ** To look for page P in the hash table, first compute a hash iKey on + ** P as follows: + ** + ** iKey = (P * 383) % HASHTABLE_NSLOT + ** + ** Then start scanning entries of the hash table, starting with iKey + ** (wrapping around to the beginning when the end of the hash table is + ** reached) until an unused hash slot is found. Let the first unused slot + ** be at index iUnused. (iUnused might be less than iKey if there was + ** wrap-around.) Because the hash table is never more than half full, + ** the search is guaranteed to eventually hit an unused entry. Let + ** iMax be the value between iKey and iUnused, closest to iUnused, + ** where aHash[iMax]==P. If there is no iMax entry (if there exists + ** no hash slot such that aHash[i]==p) then page P is not in the + ** current index block. Otherwise the iMax-th mapping entry of the + ** current index block corresponds to the last entry that references + ** page P. + ** + ** A hash search begins with the last index block and moves toward the + ** first index block, looking for entries corresponding to page P. On + ** average, only two or three slots in each index block need to be + ** examined in order to either find the last entry for page P, or to + ** establish that no such entry exists in the block. Each index block + ** holds over 4000 entries. So two or three index blocks are sufficient + ** to cover a typical 10 megabyte WAL file, assuming 1K pages. 8 or 10 + ** comparisons (on average) suffice to either locate a frame in the + ** WAL or to establish that the frame does not exist in the WAL. This + ** is much faster than scanning the entire 10MB WAL. + ** + ** Note that entries are added in order of increasing K. Hence, one + ** reader might be using some value K0 and a second reader that started + ** at a later time (after additional transactions were added to the WAL + ** and to the wal-index) might be using a different value K1, where K1>K0. + ** Both readers can use the same hash table and mapping section to get + ** the correct result. There may be entries in the hash table with + ** K>K0 but to the first reader, those entries will appear to be unused + ** slots in the hash table and so the first reader will get an answer as + ** if no values greater than K0 had ever been inserted into the hash table + ** in the first place - which is what reader one wants. Meanwhile, the + ** second reader using K1 will see additional values that were inserted + ** later, which is exactly what reader two wants. + ** + ** When a rollback occurs, the value of K is decreased. Hash table entries + ** that correspond to frames greater than the new K value are removed + ** from the hash table at this point. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ #if !SQLITE_OMIT_WAL //#include "wal.h" @@ -2966,5 +2957,5 @@ int sqlite3WalHeapMemory(Wal *pWal){ } #endif //* #if !SQLITE_OMIT_WAL */ - } + } } diff --git a/Src/IronPython.SQLite/c#sqlite/wal_h.cs b/Src/IronPython.SQLite/c#sqlite/wal_h.cs index c80dd778c..2eae2199b 100644 --- a/Src/IronPython.SQLite/c#sqlite/wal_h.cs +++ b/Src/IronPython.SQLite/c#sqlite/wal_h.cs @@ -5,141 +5,123 @@ using Wal = System.Object; #endif -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 2010 February 1 - ** - ** 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 header file defines the interface to the write-ahead logging - ** system. Refer to the comments below and the header comment attached to - ** the implementation of each function in log.c for further details. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - - //#if !_WAL_H_ - //#define _WAL_H_ - - //#include "sqliteInt.h" +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2010 February 1 + ** + ** 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 header file defines the interface to the write-ahead logging + ** system. Refer to the comments below and the header comment attached to + ** the implementation of each function in log.c for further details. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + + //#if !_WAL_H_ + //#define _WAL_H_ + + //#include "sqliteInt.h" #if SQLITE_OMIT_WAL - //# define sqlite3WalOpen(x,y,z) 0 - static int sqlite3WalOpen( sqlite3_vfs x, sqlite3_file y, string z ) - { - return 0; - } - - //# define sqlite3WalLimit(x,y) - static void sqlite3WalLimit( sqlite3_vfs x, long y ) - { - } - - //# define sqlite3WalClose(w,x,y,z) 0 - static int sqlite3WalClose( Wal w, int x, int y, u8 z ) - { - return 0; - } - - //# define sqlite3WalBeginReadTransaction(y,z) 0 - static int sqlite3WalBeginReadTransaction( Wal y, int z ) - { - return 0; - } - - //# define sqlite3WalEndReadTransaction(z) - static void sqlite3WalEndReadTransaction( Wal z ) - { - } - - //# define sqlite3WalRead(v,w,x,y,z) 0 - static int sqlite3WalRead( Wal v, Pgno w, ref int x, int y, u8[] z ) - { - return 0; - } - - //# define sqlite3WalDbsize(y) 0 - static Pgno sqlite3WalDbsize( Wal y ) - { - return 0; - } - - //# define sqlite3WalBeginWriteTransaction(y) 0 - static int sqlite3WalBeginWriteTransaction( Wal y ) - { - return 0; - } - - //# define sqlite3WalEndWriteTransaction(x) 0 - static int sqlite3WalEndWriteTransaction( Wal x ) - { - return 0; - } - - //# define sqlite3WalUndo(x,y,z) 0 - static int sqlite3WalUndo( Wal x, int y, object z ) - { - return 0; - } - - - //# define sqlite3WalSavepoint(y,z) - static void sqlite3WalSavepoint( Wal y, object z ) - { - } - - //# define sqlite3WalSavepointUndo(y,z) 0 - static int sqlite3WalSavepointUndo( Wal y, object z ) - { - return 0; - } - - //# define sqlite3WalFrames(u,v,w,x,y,z) 0 - static int sqlite3WalFrames( Wal u, int v, PgHdr w, Pgno x, int y, int z ) - { - return 0; - } - - //# define sqlite3WalCheckpoint(r,s,t,u,v,w,x,y,z) 0 - static int sqlite3WalCheckpoint( Wal r, int s, int t, u8[] u, int v, int w, u8[]x, ref int y, ref int z )//r,s,t,u,v,w,x,y,z - { - y = 0; - z = 0; - return 0; - } - - //# define sqlite3WalCallback(z) 0 - static int sqlite3WalCallback( Wal z ) - { - return 0; - } - - //# define sqlite3WalExclusiveMode(y,z) 0 - static bool sqlite3WalExclusiveMode( Wal y, int z ) - { - return false; - } - - //# define sqlite3WalHeapMemory(z) 0 - static bool sqlite3WalHeapMemory( Wal z ) - { - return false; - } + //# define sqlite3WalOpen(x,y,z) 0 + static int sqlite3WalOpen(sqlite3_vfs x, sqlite3_file y, string z) { + return 0; + } + + //# define sqlite3WalLimit(x,y) + static void sqlite3WalLimit(sqlite3_vfs x, long y) { + } + + //# define sqlite3WalClose(w,x,y,z) 0 + static int sqlite3WalClose(Wal w, int x, int y, u8 z) { + return 0; + } + + //# define sqlite3WalBeginReadTransaction(y,z) 0 + static int sqlite3WalBeginReadTransaction(Wal y, int z) { + return 0; + } + + //# define sqlite3WalEndReadTransaction(z) + static void sqlite3WalEndReadTransaction(Wal z) { + } + + //# define sqlite3WalRead(v,w,x,y,z) 0 + static int sqlite3WalRead(Wal v, Pgno w, ref int x, int y, u8[] z) { + return 0; + } + + //# define sqlite3WalDbsize(y) 0 + static Pgno sqlite3WalDbsize(Wal y) { + return 0; + } + + //# define sqlite3WalBeginWriteTransaction(y) 0 + static int sqlite3WalBeginWriteTransaction(Wal y) { + return 0; + } + + //# define sqlite3WalEndWriteTransaction(x) 0 + static int sqlite3WalEndWriteTransaction(Wal x) { + return 0; + } + + //# define sqlite3WalUndo(x,y,z) 0 + static int sqlite3WalUndo(Wal x, int y, object z) { + return 0; + } + + + //# define sqlite3WalSavepoint(y,z) + static void sqlite3WalSavepoint(Wal y, object z) { + } + + //# define sqlite3WalSavepointUndo(y,z) 0 + static int sqlite3WalSavepointUndo(Wal y, object z) { + return 0; + } + + //# define sqlite3WalFrames(u,v,w,x,y,z) 0 + static int sqlite3WalFrames(Wal u, int v, PgHdr w, Pgno x, int y, int z) { + return 0; + } + + //# define sqlite3WalCheckpoint(r,s,t,u,v,w,x,y,z) 0 + static int sqlite3WalCheckpoint(Wal r, int s, int t, u8[] u, int v, int w, u8[] x, ref int y, ref int z)//r,s,t,u,v,w,x,y,z + { + y = 0; + z = 0; + return 0; + } + + //# define sqlite3WalCallback(z) 0 + static int sqlite3WalCallback(Wal z) { + return 0; + } + + //# define sqlite3WalExclusiveMode(y,z) 0 + static bool sqlite3WalExclusiveMode(Wal y, int z) { + return false; + } + + //# define sqlite3WalHeapMemory(z) 0 + static bool sqlite3WalHeapMemory(Wal z) { + return false; + } #else @@ -224,6 +206,6 @@ int sqlite3WalCheckpoint( int sqlite3WalHeapMemory(Wal *pWal); #endif //* ifndef SQLITE_OMIT_WAL */ - //#endif //* _WAL_H_ */ - } + //#endif //* _WAL_H_ */ + } } diff --git a/Src/IronPython.SQLite/c#sqlite/walker_c.cs b/Src/IronPython.SQLite/c#sqlite/walker_c.cs index b0cd879d1..bbd53fabe 100644 --- a/Src/IronPython.SQLite/c#sqlite/walker_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/walker_c.cs @@ -1,190 +1,167 @@ -using System; -using System.Diagnostics; -using System.Text; +namespace Community.CsharpSqlite { + public partial class Sqlite3 { + /* + ** 2008 August 16 + ** + ** 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 contains routines used for walking the parser tree for + ** an SQL statement. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include + //#include -using Bitmask = System.UInt64; -using u32 = System.UInt32; -namespace Community.CsharpSqlite -{ - public partial class Sqlite3 - { - /* - ** 2008 August 16 - ** - ** 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 contains routines used for walking the parser tree for - ** an SQL statement. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include - //#include - - - /* - ** Walk an expression tree. Invoke the callback once for each node - ** of the expression, while decending. (In other words, the callback - ** is invoked before visiting children.) - ** - ** The return value from the callback should be one of the WRC_* - ** constants to specify how to proceed with the walk. - ** - ** WRC_Continue Continue descending down the tree. - ** - ** WRC_Prune Do not descend into child nodes. But allow - ** the walk to continue with sibling nodes. - ** - ** WRC_Abort Do no more callbacks. Unwind the stack and - ** return the top-level walk call. - ** - ** The return value from this routine is WRC_Abort to abandon the tree walk - ** and WRC_Continue to continue. - */ - static int sqlite3WalkExpr( Walker pWalker, ref Expr pExpr ) - { - int rc; - if ( pExpr == null ) - return WRC_Continue; - testcase( ExprHasProperty( pExpr, EP_TokenOnly ) ); - testcase( ExprHasProperty( pExpr, EP_Reduced ) ); - rc = pWalker.xExprCallback( pWalker, ref pExpr ); - if ( rc == WRC_Continue - && !ExprHasAnyProperty( pExpr, EP_TokenOnly ) ) - { - if ( sqlite3WalkExpr( pWalker, ref pExpr.pLeft ) != 0 ) - return WRC_Abort; - if ( sqlite3WalkExpr( pWalker, ref pExpr.pRight ) != 0 ) - return WRC_Abort; - if ( ExprHasProperty( pExpr, EP_xIsSelect ) ) - { - if ( sqlite3WalkSelect( pWalker, pExpr.x.pSelect ) != 0 ) - return WRC_Abort; - } - else - { - if ( sqlite3WalkExprList( pWalker, pExpr.x.pList ) != 0 ) - return WRC_Abort; + /* + ** Walk an expression tree. Invoke the callback once for each node + ** of the expression, while decending. (In other words, the callback + ** is invoked before visiting children.) + ** + ** The return value from the callback should be one of the WRC_* + ** constants to specify how to proceed with the walk. + ** + ** WRC_Continue Continue descending down the tree. + ** + ** WRC_Prune Do not descend into child nodes. But allow + ** the walk to continue with sibling nodes. + ** + ** WRC_Abort Do no more callbacks. Unwind the stack and + ** return the top-level walk call. + ** + ** The return value from this routine is WRC_Abort to abandon the tree walk + ** and WRC_Continue to continue. + */ + static int sqlite3WalkExpr(Walker pWalker, ref Expr pExpr) { + int rc; + if (pExpr == null) + return WRC_Continue; + testcase(ExprHasProperty(pExpr, EP_TokenOnly)); + testcase(ExprHasProperty(pExpr, EP_Reduced)); + rc = pWalker.xExprCallback(pWalker, ref pExpr); + if (rc == WRC_Continue + && !ExprHasAnyProperty(pExpr, EP_TokenOnly)) { + if (sqlite3WalkExpr(pWalker, ref pExpr.pLeft) != 0) + return WRC_Abort; + if (sqlite3WalkExpr(pWalker, ref pExpr.pRight) != 0) + return WRC_Abort; + if (ExprHasProperty(pExpr, EP_xIsSelect)) { + if (sqlite3WalkSelect(pWalker, pExpr.x.pSelect) != 0) + return WRC_Abort; + } else { + if (sqlite3WalkExprList(pWalker, pExpr.x.pList) != 0) + return WRC_Abort; + } + } + return rc & WRC_Abort; } - } - return rc & WRC_Abort; - } - /* - ** Call sqlite3WalkExpr() for every expression in list p or until - ** an abort request is seen. - */ - static int sqlite3WalkExprList( Walker pWalker, ExprList p ) - { - int i; - ExprList_item pItem; - if ( p != null ) - { - for ( i = p.nExpr; i > 0; i-- ) - {//, pItem++){ - pItem = p.a[p.nExpr - i]; - if ( sqlite3WalkExpr( pWalker, ref pItem.pExpr ) != 0 ) - return WRC_Abort; + /* + ** Call sqlite3WalkExpr() for every expression in list p or until + ** an abort request is seen. + */ + static int sqlite3WalkExprList(Walker pWalker, ExprList p) { + int i; + ExprList_item pItem; + if (p != null) { + for (i = p.nExpr; i > 0; i--) {//, pItem++){ + pItem = p.a[p.nExpr - i]; + if (sqlite3WalkExpr(pWalker, ref pItem.pExpr) != 0) + return WRC_Abort; + } + } + return WRC_Continue; } - } - return WRC_Continue; - } - /* - ** Walk all expressions associated with SELECT statement p. Do - ** not invoke the SELECT callback on p, but do (of course) invoke - ** any expr callbacks and SELECT callbacks that come from subqueries. - ** Return WRC_Abort or WRC_Continue. - */ - static int sqlite3WalkSelectExpr( Walker pWalker, Select p ) - { - if ( sqlite3WalkExprList( pWalker, p.pEList ) != 0 ) - return WRC_Abort; - if ( sqlite3WalkExpr( pWalker, ref p.pWhere ) != 0 ) - return WRC_Abort; - if ( sqlite3WalkExprList( pWalker, p.pGroupBy ) != 0 ) - return WRC_Abort; - if ( sqlite3WalkExpr( pWalker, ref p.pHaving ) != 0 ) - return WRC_Abort; - if ( sqlite3WalkExprList( pWalker, p.pOrderBy ) != 0 ) - return WRC_Abort; - if ( sqlite3WalkExpr( pWalker, ref p.pLimit ) != 0 ) - return WRC_Abort; - if ( sqlite3WalkExpr( pWalker, ref p.pOffset ) != 0 ) - return WRC_Abort; - return WRC_Continue; - } + /* + ** Walk all expressions associated with SELECT statement p. Do + ** not invoke the SELECT callback on p, but do (of course) invoke + ** any expr callbacks and SELECT callbacks that come from subqueries. + ** Return WRC_Abort or WRC_Continue. + */ + static int sqlite3WalkSelectExpr(Walker pWalker, Select p) { + if (sqlite3WalkExprList(pWalker, p.pEList) != 0) + return WRC_Abort; + if (sqlite3WalkExpr(pWalker, ref p.pWhere) != 0) + return WRC_Abort; + if (sqlite3WalkExprList(pWalker, p.pGroupBy) != 0) + return WRC_Abort; + if (sqlite3WalkExpr(pWalker, ref p.pHaving) != 0) + return WRC_Abort; + if (sqlite3WalkExprList(pWalker, p.pOrderBy) != 0) + return WRC_Abort; + if (sqlite3WalkExpr(pWalker, ref p.pLimit) != 0) + return WRC_Abort; + if (sqlite3WalkExpr(pWalker, ref p.pOffset) != 0) + return WRC_Abort; + return WRC_Continue; + } - /* - ** Walk the parse trees associated with all subqueries in the - ** FROM clause of SELECT statement p. Do not invoke the select - ** callback on p, but do invoke it on each FROM clause subquery - ** and on any subqueries further down in the tree. Return - ** WRC_Abort or WRC_Continue; - */ - static int sqlite3WalkSelectFrom( Walker pWalker, Select p ) - { - SrcList pSrc; - int i; - SrcList_item pItem; + /* + ** Walk the parse trees associated with all subqueries in the + ** FROM clause of SELECT statement p. Do not invoke the select + ** callback on p, but do invoke it on each FROM clause subquery + ** and on any subqueries further down in the tree. Return + ** WRC_Abort or WRC_Continue; + */ + static int sqlite3WalkSelectFrom(Walker pWalker, Select p) { + SrcList pSrc; + int i; + SrcList_item pItem; - pSrc = p.pSrc; - if ( ALWAYS( pSrc ) ) - { - for ( i = pSrc.nSrc; i > 0; i-- )// pItem++ ) - { - pItem = pSrc.a[pSrc.nSrc - i]; - if ( sqlite3WalkSelect( pWalker, pItem.pSelect ) != 0 ) - { - return WRC_Abort; - } + pSrc = p.pSrc; + if (ALWAYS(pSrc)) { + for (i = pSrc.nSrc; i > 0; i--)// pItem++ ) + { + pItem = pSrc.a[pSrc.nSrc - i]; + if (sqlite3WalkSelect(pWalker, pItem.pSelect) != 0) { + return WRC_Abort; + } + } + } + return WRC_Continue; } - } - return WRC_Continue; - } - /* - ** Call sqlite3WalkExpr() for every expression in Select statement p. - ** Invoke sqlite3WalkSelect() for subqueries in the FROM clause and - ** on the compound select chain, p.pPrior. - ** - ** Return WRC_Continue under normal conditions. Return WRC_Abort if - ** there is an abort request. - ** - ** If the Walker does not have an xSelectCallback() then this routine - ** is a no-op returning WRC_Continue. - */ - static int sqlite3WalkSelect( Walker pWalker, Select p ) - { - int rc; - if ( p == null || pWalker.xSelectCallback == null ) - return WRC_Continue; - rc = WRC_Continue; - while ( p != null ) - { - rc = pWalker.xSelectCallback( pWalker, p ); - if ( rc != 0 ) - break; - if ( sqlite3WalkSelectExpr( pWalker, p ) != 0 ) - return WRC_Abort; - if ( sqlite3WalkSelectFrom( pWalker, p ) != 0 ) - return WRC_Abort; - p = p.pPrior; - } - return rc & WRC_Abort; + /* + ** Call sqlite3WalkExpr() for every expression in Select statement p. + ** Invoke sqlite3WalkSelect() for subqueries in the FROM clause and + ** on the compound select chain, p.pPrior. + ** + ** Return WRC_Continue under normal conditions. Return WRC_Abort if + ** there is an abort request. + ** + ** If the Walker does not have an xSelectCallback() then this routine + ** is a no-op returning WRC_Continue. + */ + static int sqlite3WalkSelect(Walker pWalker, Select p) { + int rc; + if (p == null || pWalker.xSelectCallback == null) + return WRC_Continue; + rc = WRC_Continue; + while (p != null) { + rc = pWalker.xSelectCallback(pWalker, p); + if (rc != 0) + break; + if (sqlite3WalkSelectExpr(pWalker, p) != 0) + return WRC_Abort; + if (sqlite3WalkSelectFrom(pWalker, p) != 0) + return WRC_Abort; + p = p.pPrior; + } + return rc & WRC_Abort; + } } - } } diff --git a/Src/IronPython.SQLite/c#sqlite/where_c.cs b/Src/IronPython.SQLite/c#sqlite/where_c.cs index fc26723c3..045317ca1 100644 --- a/Src/IronPython.SQLite/c#sqlite/where_c.cs +++ b/Src/IronPython.SQLite/c#sqlite/where_c.cs @@ -3,1580 +3,1452 @@ using System.Text; using Bitmask = System.UInt64; - using i16 = System.Int16; -using u8 = System.Byte; +using sqlite3_int64 = System.Int64; using u16 = System.UInt16; using u32 = System.UInt32; +using u8 = System.Byte; -using sqlite3_int64 = System.Int64; - -namespace Community.CsharpSqlite -{ - using sqlite3_value = Sqlite3.Mem; - public partial class Sqlite3 - { - /* - ** 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. - ** - ************************************************************************* - ** This module contains C code that generates VDBE code used to process - ** the WHERE clause of SQL statements. This module is responsible for - ** generating the code that loops through a table looking for applicable - ** rows. Indices are selected and used to speed the search when doing - ** so is applicable. Because this module is responsible for selecting - ** indices, you might also think of this module as the "query optimizer". - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908ecd7 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +namespace Community.CsharpSqlite { + using sqlite3_value = Sqlite3.Mem; + public partial class Sqlite3 { + /* + ** 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. + ** + ************************************************************************* + ** This module contains C code that generates VDBE code used to process + ** the WHERE clause of SQL statements. This module is responsible for + ** generating the code that loops through a table looking for applicable + ** rows. Indices are selected and used to speed the search when doing + ** so is applicable. Because this module is responsible for selecting + ** indices, you might also think of this module as the "query optimizer". + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908ecd7 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" - /* - ** Trace output macros - */ -#if (SQLITE_TEST) || (SQLITE_DEBUG) - static bool sqlite3WhereTrace = false; + /* + ** Trace output macros + */ +#if (SQLITE_TEST) || (SQLITE_DEBUG) + static bool sqlite3WhereTrace = false; #endif -#if (SQLITE_TEST) && (SQLITE_DEBUG) && TRACE +#if (SQLITE_TEST) && (SQLITE_DEBUG) && TRACE //# define WHERETRACE(X) if(sqlite3WhereTrace) sqlite3DebugPrintf X static void WHERETRACE( string X, params object[] ap ) { if ( sqlite3WhereTrace ) sqlite3DebugPrintf( X, ap ); } #else - //# define WHERETRACE(X) - static void WHERETRACE( string X, params object[] ap ) - { - } + //# define WHERETRACE(X) + static void WHERETRACE(string X, params object[] ap) { + } #endif - /* Forward reference -*/ - //typedef struct WhereClause WhereClause; - //typedef struct WhereMaskSet WhereMaskSet; - //typedef struct WhereOrInfo WhereOrInfo; - //typedef struct WhereAndInfo WhereAndInfo; - //typedef struct WhereCost WhereCost; - - /* - ** The query generator uses an array of instances of this structure to - ** help it analyze the subexpressions of the WHERE clause. Each WHERE - ** clause subexpression is separated from the others by AND operators, - ** usually, or sometimes subexpressions separated by OR. - ** - ** All WhereTerms are collected into a single WhereClause structure. - ** The following identity holds: - ** - ** WhereTerm.pWC.a[WhereTerm.idx] == WhereTerm - ** - ** When a term is of the form: - ** - ** X - ** - ** where X is a column name and is one of certain operators, - ** then WhereTerm.leftCursor and WhereTerm.u.leftColumn record the - ** cursor number and column number for X. WhereTerm.eOperator records - ** the using a bitmask encoding defined by WO_xxx below. The - ** use of a bitmask encoding for the operator allows us to search - ** quickly for terms that match any of several different operators. - ** - ** A WhereTerm might also be two or more subterms connected by OR: - ** - ** (t1.X ) OR (t1.Y ) OR .... - ** - ** In this second case, wtFlag as the TERM_ORINFO set and eOperator==WO_OR - ** and the WhereTerm.u.pOrInfo field points to auxiliary information that - ** is collected about the - ** - ** If a term in the WHERE clause does not match either of the two previous - ** categories, then eOperator==0. The WhereTerm.pExpr field is still set - ** to the original subexpression content and wtFlags is set up appropriately - ** but no other fields in the WhereTerm object are meaningful. - ** - ** When eOperator!=0, prereqRight and prereqAll record sets of cursor numbers, - ** but they do so indirectly. A single WhereMaskSet structure translates - ** cursor number into bits and the translated bit is stored in the prereq - ** fields. The translation is used in order to maximize the number of - ** bits that will fit in a Bitmask. The VDBE cursor numbers might be - ** spread out over the non-negative integers. For example, the cursor - ** numbers might be 3, 8, 9, 10, 20, 23, 41, and 45. The WhereMaskSet - ** translates these sparse cursor numbers into consecutive integers - ** beginning with 0 in order to make the best possible use of the available - ** bits in the Bitmask. So, in the example above, the cursor numbers - ** would be mapped into integers 0 through 7. - ** - ** The number of terms in a join is limited by the number of bits - ** in prereqRight and prereqAll. The default is 64 bits, hence SQLite - ** is only able to process joins with 64 or fewer tables. + /* Forward reference */ - //typedef struct WhereTerm WhereTerm; - public class WhereTerm - { - public Expr pExpr; /* Pointer to the subexpression that is this term */ - public int iParent; /* Disable pWC.a[iParent] when this term disabled */ - public int leftCursor; /* Cursor number of X in "X " */ - public class _u - { - public int leftColumn; /* Column number of X in "X " */ - public WhereOrInfo pOrInfo; /* Extra information if eOperator==WO_OR */ - public WhereAndInfo pAndInfo; /* Extra information if eOperator==WO_AND */ - } - public _u u = new _u(); - public u16 eOperator; /* A WO_xx value describing */ - public u8 wtFlags; /* TERM_xxx bit flags. See below */ - public u8 nChild; /* Number of children that must disable us */ - public WhereClause pWC; /* The clause this term is part of */ - public Bitmask prereqRight; /* Bitmask of tables used by pExpr.pRight */ - public Bitmask prereqAll; /* Bitmask of tables referenced by pExpr */ - }; + //typedef struct WhereClause WhereClause; + //typedef struct WhereMaskSet WhereMaskSet; + //typedef struct WhereOrInfo WhereOrInfo; + //typedef struct WhereAndInfo WhereAndInfo; + //typedef struct WhereCost WhereCost; - /* - ** Allowed values of WhereTerm.wtFlags - */ - //#define TERM_DYNAMIC 0x01 /* Need to call sqlite3ExprDelete(db, ref pExpr) */ - //#define TERM_VIRTUAL 0x02 /* Added by the optimizer. Do not code */ - //#define TERM_CODED 0x04 /* This term is already coded */ - //#define TERM_COPIED 0x08 /* Has a child */ - //#define TERM_ORINFO 0x10 /* Need to free the WhereTerm.u.pOrInfo object */ - //#define TERM_ANDINFO 0x20 /* Need to free the WhereTerm.u.pAndInfo obj */ - //#define TERM_OR_OK 0x40 /* Used during OR-clause processing */ + /* + ** The query generator uses an array of instances of this structure to + ** help it analyze the subexpressions of the WHERE clause. Each WHERE + ** clause subexpression is separated from the others by AND operators, + ** usually, or sometimes subexpressions separated by OR. + ** + ** All WhereTerms are collected into a single WhereClause structure. + ** The following identity holds: + ** + ** WhereTerm.pWC.a[WhereTerm.idx] == WhereTerm + ** + ** When a term is of the form: + ** + ** X + ** + ** where X is a column name and is one of certain operators, + ** then WhereTerm.leftCursor and WhereTerm.u.leftColumn record the + ** cursor number and column number for X. WhereTerm.eOperator records + ** the using a bitmask encoding defined by WO_xxx below. The + ** use of a bitmask encoding for the operator allows us to search + ** quickly for terms that match any of several different operators. + ** + ** A WhereTerm might also be two or more subterms connected by OR: + ** + ** (t1.X ) OR (t1.Y ) OR .... + ** + ** In this second case, wtFlag as the TERM_ORINFO set and eOperator==WO_OR + ** and the WhereTerm.u.pOrInfo field points to auxiliary information that + ** is collected about the + ** + ** If a term in the WHERE clause does not match either of the two previous + ** categories, then eOperator==0. The WhereTerm.pExpr field is still set + ** to the original subexpression content and wtFlags is set up appropriately + ** but no other fields in the WhereTerm object are meaningful. + ** + ** When eOperator!=0, prereqRight and prereqAll record sets of cursor numbers, + ** but they do so indirectly. A single WhereMaskSet structure translates + ** cursor number into bits and the translated bit is stored in the prereq + ** fields. The translation is used in order to maximize the number of + ** bits that will fit in a Bitmask. The VDBE cursor numbers might be + ** spread out over the non-negative integers. For example, the cursor + ** numbers might be 3, 8, 9, 10, 20, 23, 41, and 45. The WhereMaskSet + ** translates these sparse cursor numbers into consecutive integers + ** beginning with 0 in order to make the best possible use of the available + ** bits in the Bitmask. So, in the example above, the cursor numbers + ** would be mapped into integers 0 through 7. + ** + ** The number of terms in a join is limited by the number of bits + ** in prereqRight and prereqAll. The default is 64 bits, hence SQLite + ** is only able to process joins with 64 or fewer tables. + */ + //typedef struct WhereTerm WhereTerm; + public class WhereTerm { + public Expr pExpr; /* Pointer to the subexpression that is this term */ + public int iParent; /* Disable pWC.a[iParent] when this term disabled */ + public int leftCursor; /* Cursor number of X in "X " */ + public class _u { + public int leftColumn; /* Column number of X in "X " */ + public WhereOrInfo pOrInfo; /* Extra information if eOperator==WO_OR */ + public WhereAndInfo pAndInfo; /* Extra information if eOperator==WO_AND */ + } + public _u u = new _u(); + public u16 eOperator; /* A WO_xx value describing */ + public u8 wtFlags; /* TERM_xxx bit flags. See below */ + public u8 nChild; /* Number of children that must disable us */ + public WhereClause pWC; /* The clause this term is part of */ + public Bitmask prereqRight; /* Bitmask of tables used by pExpr.pRight */ + public Bitmask prereqAll; /* Bitmask of tables referenced by pExpr */ + }; + + /* + ** Allowed values of WhereTerm.wtFlags + */ + //#define TERM_DYNAMIC 0x01 /* Need to call sqlite3ExprDelete(db, ref pExpr) */ + //#define TERM_VIRTUAL 0x02 /* Added by the optimizer. Do not code */ + //#define TERM_CODED 0x04 /* This term is already coded */ + //#define TERM_COPIED 0x08 /* Has a child */ + //#define TERM_ORINFO 0x10 /* Need to free the WhereTerm.u.pOrInfo object */ + //#define TERM_ANDINFO 0x20 /* Need to free the WhereTerm.u.pAndInfo obj */ + //#define TERM_OR_OK 0x40 /* Used during OR-clause processing */ #if SQLITE_ENABLE_STAT2 //# define TERM_VNULL 0x80 /* Manufactured x>NULL or x<=NULL term */ #else -//# define TERM_VNULL 0x00 /* Disabled if not using stat2 */ + //# define TERM_VNULL 0x00 /* Disabled if not using stat2 */ #endif - const int TERM_DYNAMIC = 0x01; /* Need to call sqlite3ExprDelete(db, ref pExpr) */ - const int TERM_VIRTUAL = 0x02; /* Added by the optimizer. Do not code */ - const int TERM_CODED = 0x04; /* This term is already coded */ - const int TERM_COPIED = 0x08; /* Has a child */ - const int TERM_ORINFO = 0x10; /* Need to free the WhereTerm.u.pOrInfo object */ - const int TERM_ANDINFO = 0x20; /* Need to free the WhereTerm.u.pAndInfo obj */ - const int TERM_OR_OK = 0x40; /* Used during OR-clause processing */ + const int TERM_DYNAMIC = 0x01; /* Need to call sqlite3ExprDelete(db, ref pExpr) */ + const int TERM_VIRTUAL = 0x02; /* Added by the optimizer. Do not code */ + const int TERM_CODED = 0x04; /* This term is already coded */ + const int TERM_COPIED = 0x08; /* Has a child */ + const int TERM_ORINFO = 0x10; /* Need to free the WhereTerm.u.pOrInfo object */ + const int TERM_ANDINFO = 0x20; /* Need to free the WhereTerm.u.pAndInfo obj */ + const int TERM_OR_OK = 0x40; /* Used during OR-clause processing */ #if SQLITE_ENABLE_STAT2 const int TERM_VNULL = 0x80; /* Manufactured x>NULL or x<=NULL term */ #else - const int TERM_VNULL = 0x00; /* Disabled if not using stat2 */ + const int TERM_VNULL = 0x00; /* Disabled if not using stat2 */ #endif - /* - ** An instance of the following structure holds all information about a - ** WHERE clause. Mostly this is a container for one or more WhereTerms. - */ - public class WhereClause - { - public Parse pParse; /* The parser context */ - public WhereMaskSet pMaskSet; /* Mapping of table cursor numbers to bitmasks */ - public Bitmask vmask; /* Bitmask identifying virtual table cursors */ - public u8 op; /* Split operator. TK_AND or TK_OR */ - public int nTerm; /* Number of terms */ - public int nSlot; /* Number of entries in a[] */ - public WhereTerm[] a; /* Each a[] describes a term of the WHERE cluase */ + /* + ** An instance of the following structure holds all information about a + ** WHERE clause. Mostly this is a container for one or more WhereTerms. + */ + public class WhereClause { + public Parse pParse; /* The parser context */ + public WhereMaskSet pMaskSet; /* Mapping of table cursor numbers to bitmasks */ + public Bitmask vmask; /* Bitmask identifying virtual table cursors */ + public u8 op; /* Split operator. TK_AND or TK_OR */ + public int nTerm; /* Number of terms */ + public int nSlot; /* Number of entries in a[] */ + public WhereTerm[] a; /* Each a[] describes a term of the WHERE cluase */ #if (SQLITE_SMALL_STACK) public WhereTerm[] aStatic = new WhereTerm[1]; /* Initial static space for a[] */ #else - public WhereTerm[] aStatic = new WhereTerm[8]; /* Initial static space for a[] */ + public WhereTerm[] aStatic = new WhereTerm[8]; /* Initial static space for a[] */ #endif - public void CopyTo( WhereClause wc ) - { - wc.pParse = this.pParse; - wc.pMaskSet = new WhereMaskSet(); - this.pMaskSet.CopyTo( wc.pMaskSet ); - wc.op = this.op; - wc.nTerm = this.nTerm; - wc.nSlot = this.nSlot; - wc.a = (WhereTerm[])this.a.Clone(); - wc.aStatic = (WhereTerm[])this.aStatic.Clone(); - } - }; - - /* - ** A WhereTerm with eOperator==WO_OR has its u.pOrInfo pointer set to - ** a dynamically allocated instance of the following structure. - */ - public class WhereOrInfo - { - public WhereClause wc = new WhereClause();/* Decomposition into subterms */ - public Bitmask indexable; /* Bitmask of all indexable tables in the clause */ - }; - - /* - ** A WhereTerm with eOperator==WO_AND has its u.pAndInfo pointer set to - ** a dynamically allocated instance of the following structure. - */ - public class WhereAndInfo - { - public WhereClause wc = new WhereClause(); /* The subexpression broken out */ - }; + public void CopyTo(WhereClause wc) { + wc.pParse = this.pParse; + wc.pMaskSet = new WhereMaskSet(); + this.pMaskSet.CopyTo(wc.pMaskSet); + wc.op = this.op; + wc.nTerm = this.nTerm; + wc.nSlot = this.nSlot; + wc.a = (WhereTerm[])this.a.Clone(); + wc.aStatic = (WhereTerm[])this.aStatic.Clone(); + } + }; - /* - ** An instance of the following structure keeps track of a mapping - ** between VDBE cursor numbers and bits of the bitmasks in WhereTerm. - ** - ** The VDBE cursor numbers are small integers contained in - ** SrcList_item.iCursor and Expr.iTable fields. For any given WHERE - ** clause, the cursor numbers might not begin with 0 and they might - ** contain gaps in the numbering sequence. But we want to make maximum - ** use of the bits in our bitmasks. This structure provides a mapping - ** from the sparse cursor numbers into consecutive integers beginning - ** with 0. - ** - ** If WhereMaskSet.ix[A]==B it means that The A-th bit of a Bitmask - ** corresponds VDBE cursor number B. The A-th bit of a bitmask is 1<EXPR */ - //#define WHERE_COLUMN_EQ 0x00010000 /* x=EXPR or x IN (...) or x IS NULL */ - //#define WHERE_COLUMN_RANGE 0x00020000 /* xEXPR */ - //#define WHERE_COLUMN_IN 0x00040000 /* x IN (...) */ - //#define WHERE_COLUMN_NULL 0x00080000 /* x IS NULL */ - //#define WHERE_INDEXED 0x000f0000 /* Anything that uses an index */ - //#define WHERE_IN_ABLE 0x000f1000 /* Able to support an IN operator */ - //#define WHERE_NOT_FULLSCAN 0x100f3000 /* Does not do a full table scan */ - //#define WHERE_TOP_LIMIT 0x00100000 /* xEXPR or x>=EXPR constraint */ - //#define WHERE_BOTH_LIMIT 0x00300000 /* Both x>EXPR and xEXPR */ + //#define WHERE_COLUMN_EQ 0x00010000 /* x=EXPR or x IN (...) or x IS NULL */ + //#define WHERE_COLUMN_RANGE 0x00020000 /* xEXPR */ + //#define WHERE_COLUMN_IN 0x00040000 /* x IN (...) */ + //#define WHERE_COLUMN_NULL 0x00080000 /* x IS NULL */ + //#define WHERE_INDEXED 0x000f0000 /* Anything that uses an index */ + //#define WHERE_IN_ABLE 0x000f1000 /* Able to support an IN operator */ + //#define WHERE_NOT_FULLSCAN 0x100f3000 /* Does not do a full table scan */ + //#define WHERE_TOP_LIMIT 0x00100000 /* xEXPR or x>=EXPR constraint */ + //#define WHERE_BOTH_LIMIT 0x00300000 /* Both x>EXPR and x= 0; i-- )//, a++) - { - a = pWC.a[i]; - if ( ( a.wtFlags & TERM_DYNAMIC ) != 0 ) - { - sqlite3ExprDelete( db, ref a.pExpr ); + /* + ** Deallocate all memory Debug.Associated with a WhereAndInfo object. + */ + static void whereAndInfoDelete(sqlite3 db, WhereAndInfo p) { + whereClauseClear(p.wc); + sqlite3DbFree(db, ref p); } - if ( ( a.wtFlags & TERM_ORINFO ) != 0 ) - { - whereOrInfoDelete( db, a.u.pOrInfo ); + + /* + ** Deallocate a WhereClause structure. The WhereClause structure + ** itself is not freed. This routine is the inverse of whereClauseInit(). + */ + static void whereClauseClear(WhereClause pWC) { + int i; + WhereTerm a; + sqlite3 db = pWC.pParse.db; + for (i = pWC.nTerm - 1; i >= 0; i--)//, a++) + { + a = pWC.a[i]; + if ((a.wtFlags & TERM_DYNAMIC) != 0) { + sqlite3ExprDelete(db, ref a.pExpr); + } + if ((a.wtFlags & TERM_ORINFO) != 0) { + whereOrInfoDelete(db, a.u.pOrInfo); + } else if ((a.wtFlags & TERM_ANDINFO) != 0) { + whereAndInfoDelete(db, a.u.pAndInfo); + } + } + if (pWC.a != pWC.aStatic) { + sqlite3DbFree(db, ref pWC.a); + } } - else if ( ( a.wtFlags & TERM_ANDINFO ) != 0 ) - { - whereAndInfoDelete( db, a.u.pAndInfo ); + + /* + ** Add a single new WhereTerm entry to the WhereClause object pWC. + ** The new WhereTerm object is constructed from Expr p and with wtFlags. + ** The index in pWC.a[] of the new WhereTerm is returned on success. + ** 0 is returned if the new WhereTerm could not be added due to a memory + ** allocation error. The memory allocation failure will be recorded in + ** the db.mallocFailed flag so that higher-level functions can detect it. + ** + ** This routine will increase the size of the pWC.a[] array as necessary. + ** + ** If the wtFlags argument includes TERM_DYNAMIC, then responsibility + ** for freeing the expression p is Debug.Assumed by the WhereClause object pWC. + ** This is true even if this routine fails to allocate a new WhereTerm. + ** + ** WARNING: This routine might reallocate the space used to store + ** WhereTerms. All pointers to WhereTerms should be invalidated after + ** calling this routine. Such pointers may be reinitialized by referencing + ** the pWC.a[] array. + */ + static int whereClauseInsert(WhereClause pWC, Expr p, u8 wtFlags) { + WhereTerm pTerm; + int idx; + testcase(wtFlags & TERM_VIRTUAL); /* EV: R-00211-15100 */ + if (pWC.nTerm >= pWC.nSlot) { + //WhereTerm pOld = pWC.a; + //sqlite3 db = pWC.pParse.db; + Array.Resize(ref pWC.a, pWC.nSlot * 2); + //pWC.a = sqlite3DbMallocRaw(db, sizeof(pWC.a[0])*pWC.nSlot*2 ); + //if( pWC.a==null ){ + // if( wtFlags & TERM_DYNAMIC ){ + // sqlite3ExprDelete(db, ref p); + // } + // pWC.a = pOld; + // return 0; + //} + //memcpy(pWC.a, pOld, sizeof(pWC.a[0])*pWC.nTerm); + //if( pOld!=pWC.aStatic ){ + // sqlite3DbFree(db, ref pOld); + //} + //pWC.nSlot = sqlite3DbMallocSize(db, pWC.a)/sizeof(pWC.a[0]); + pWC.nSlot = pWC.a.Length - 1; + } + pWC.a[idx = pWC.nTerm++] = new WhereTerm(); + pTerm = pWC.a[idx]; + pTerm.pExpr = p; + pTerm.wtFlags = wtFlags; + pTerm.pWC = pWC; + pTerm.iParent = -1; + return idx; } - } - if ( pWC.a != pWC.aStatic ) - { - sqlite3DbFree( db, ref pWC.a ); - } - } - /* - ** Add a single new WhereTerm entry to the WhereClause object pWC. - ** The new WhereTerm object is constructed from Expr p and with wtFlags. - ** The index in pWC.a[] of the new WhereTerm is returned on success. - ** 0 is returned if the new WhereTerm could not be added due to a memory - ** allocation error. The memory allocation failure will be recorded in - ** the db.mallocFailed flag so that higher-level functions can detect it. - ** - ** This routine will increase the size of the pWC.a[] array as necessary. - ** - ** If the wtFlags argument includes TERM_DYNAMIC, then responsibility - ** for freeing the expression p is Debug.Assumed by the WhereClause object pWC. - ** This is true even if this routine fails to allocate a new WhereTerm. - ** - ** WARNING: This routine might reallocate the space used to store - ** WhereTerms. All pointers to WhereTerms should be invalidated after - ** calling this routine. Such pointers may be reinitialized by referencing - ** the pWC.a[] array. - */ - static int whereClauseInsert( WhereClause pWC, Expr p, u8 wtFlags ) - { - WhereTerm pTerm; - int idx; - testcase( wtFlags & TERM_VIRTUAL ); /* EV: R-00211-15100 */ - if ( pWC.nTerm >= pWC.nSlot ) - { - //WhereTerm pOld = pWC.a; - //sqlite3 db = pWC.pParse.db; - Array.Resize( ref pWC.a, pWC.nSlot * 2 ); - //pWC.a = sqlite3DbMallocRaw(db, sizeof(pWC.a[0])*pWC.nSlot*2 ); - //if( pWC.a==null ){ - // if( wtFlags & TERM_DYNAMIC ){ - // sqlite3ExprDelete(db, ref p); - // } - // pWC.a = pOld; - // return 0; - //} - //memcpy(pWC.a, pOld, sizeof(pWC.a[0])*pWC.nTerm); - //if( pOld!=pWC.aStatic ){ - // sqlite3DbFree(db, ref pOld); - //} - //pWC.nSlot = sqlite3DbMallocSize(db, pWC.a)/sizeof(pWC.a[0]); - pWC.nSlot = pWC.a.Length - 1; - } - pWC.a[idx = pWC.nTerm++] = new WhereTerm(); - pTerm = pWC.a[idx]; - pTerm.pExpr = p; - pTerm.wtFlags = wtFlags; - pTerm.pWC = pWC; - pTerm.iParent = -1; - return idx; - } + /* + ** This routine identifies subexpressions in the WHERE clause where + ** each subexpression is separated by the AND operator or some other + ** operator specified in the op parameter. The WhereClause structure + ** is filled with pointers to subexpressions. For example: + ** + ** WHERE a=='hello' AND coalesce(b,11)<10 AND (c+12!=d OR c==22) + ** \________/ \_______________/ \________________/ + ** slot[0] slot[1] slot[2] + ** + ** The original WHERE clause in pExpr is unaltered. All this routine + ** does is make slot[] entries point to substructure within pExpr. + ** + ** In the previous sentence and in the diagram, "slot[]" refers to + ** the WhereClause.a[] array. The slot[] array grows as needed to contain + ** all terms of the WHERE clause. + */ + static void whereSplit(WhereClause pWC, Expr pExpr, int op) { + pWC.op = (u8)op; + if (pExpr == null) + return; + if (pExpr.op != op) { + whereClauseInsert(pWC, pExpr, 0); + } else { + whereSplit(pWC, pExpr.pLeft, op); + whereSplit(pWC, pExpr.pRight, op); + } + } - /* - ** This routine identifies subexpressions in the WHERE clause where - ** each subexpression is separated by the AND operator or some other - ** operator specified in the op parameter. The WhereClause structure - ** is filled with pointers to subexpressions. For example: - ** - ** WHERE a=='hello' AND coalesce(b,11)<10 AND (c+12!=d OR c==22) - ** \________/ \_______________/ \________________/ - ** slot[0] slot[1] slot[2] - ** - ** The original WHERE clause in pExpr is unaltered. All this routine - ** does is make slot[] entries point to substructure within pExpr. - ** - ** In the previous sentence and in the diagram, "slot[]" refers to - ** the WhereClause.a[] array. The slot[] array grows as needed to contain - ** all terms of the WHERE clause. - */ - static void whereSplit( WhereClause pWC, Expr pExpr, int op ) - { - pWC.op = (u8)op; - if ( pExpr == null ) - return; - if ( pExpr.op != op ) - { - whereClauseInsert( pWC, pExpr, 0 ); - } - else - { - whereSplit( pWC, pExpr.pLeft, op ); - whereSplit( pWC, pExpr.pRight, op ); - } - } + /* + ** Initialize an expression mask set (a WhereMaskSet object) + */ + //#define initMaskSet(P) memset(P, 0, sizeof(*P)) - /* - ** Initialize an expression mask set (a WhereMaskSet object) - */ - //#define initMaskSet(P) memset(P, 0, sizeof(*P)) + /* + ** Return the bitmask for the given cursor number. Return 0 if + ** iCursor is not in the set. + */ + static Bitmask getMask(WhereMaskSet pMaskSet, int iCursor) { + int i; + Debug.Assert(pMaskSet.n <= (int)sizeof(Bitmask) * 8); + for (i = 0; i < pMaskSet.n; i++) { + if (pMaskSet.ix[i] == iCursor) { + return ((Bitmask)1) << i; + } + } + return 0; + } - /* - ** Return the bitmask for the given cursor number. Return 0 if - ** iCursor is not in the set. - */ - static Bitmask getMask( WhereMaskSet pMaskSet, int iCursor ) - { - int i; - Debug.Assert( pMaskSet.n <= (int)sizeof( Bitmask ) * 8 ); - for ( i = 0; i < pMaskSet.n; i++ ) - { - if ( pMaskSet.ix[i] == iCursor ) - { - return ( (Bitmask)1 ) << i; + /* + ** Create a new mask for cursor iCursor. + ** + ** There is one cursor per table in the FROM clause. The number of + ** tables in the FROM clause is limited by a test early in the + ** sqlite3WhereBegin() routine. So we know that the pMaskSet.ix[] + ** array will never overflow. + */ + static void createMask(WhereMaskSet pMaskSet, int iCursor) { + Debug.Assert(pMaskSet.n < ArraySize(pMaskSet.ix)); + pMaskSet.ix[pMaskSet.n++] = iCursor; } - } - return 0; - } - /* - ** Create a new mask for cursor iCursor. - ** - ** There is one cursor per table in the FROM clause. The number of - ** tables in the FROM clause is limited by a test early in the - ** sqlite3WhereBegin() routine. So we know that the pMaskSet.ix[] - ** array will never overflow. - */ - static void createMask( WhereMaskSet pMaskSet, int iCursor ) - { - Debug.Assert( pMaskSet.n < ArraySize( pMaskSet.ix ) ); - pMaskSet.ix[pMaskSet.n++] = iCursor; - } + /* + ** This routine walks (recursively) an expression tree and generates + ** a bitmask indicating which tables are used in that expression + ** tree. + ** + ** In order for this routine to work, the calling function must have + ** previously invoked sqlite3ResolveExprNames() on the expression. See + ** the header comment on that routine for additional information. + ** The sqlite3ResolveExprNames() routines looks for column names and + ** sets their opcodes to TK_COLUMN and their Expr.iTable fields to + ** the VDBE cursor number of the table. This routine just has to + ** translate the cursor numbers into bitmask values and OR all + ** the bitmasks together. + */ + //static Bitmask exprListTableUsage(WhereMaskSet*, ExprList); + //static Bitmask exprSelectTableUsage(WhereMaskSet*, Select); + static Bitmask exprTableUsage(WhereMaskSet pMaskSet, Expr p) { + Bitmask mask = 0; + if (p == null) + return 0; + if (p.op == TK_COLUMN) { + mask = getMask(pMaskSet, p.iTable); + return mask; + } + mask = exprTableUsage(pMaskSet, p.pRight); + mask |= exprTableUsage(pMaskSet, p.pLeft); + if (ExprHasProperty(p, EP_xIsSelect)) { + mask |= exprSelectTableUsage(pMaskSet, p.x.pSelect); + } else { + mask |= exprListTableUsage(pMaskSet, p.x.pList); + } + return mask; + } + static Bitmask exprListTableUsage(WhereMaskSet pMaskSet, ExprList pList) { + int i; + Bitmask mask = 0; + if (pList != null) { + for (i = 0; i < pList.nExpr; i++) { + mask |= exprTableUsage(pMaskSet, pList.a[i].pExpr); + } + } + return mask; + } + static Bitmask exprSelectTableUsage(WhereMaskSet pMaskSet, Select pS) { + Bitmask mask = 0; + while (pS != null) { + mask |= exprListTableUsage(pMaskSet, pS.pEList); + mask |= exprListTableUsage(pMaskSet, pS.pGroupBy); + mask |= exprListTableUsage(pMaskSet, pS.pOrderBy); + mask |= exprTableUsage(pMaskSet, pS.pWhere); + mask |= exprTableUsage(pMaskSet, pS.pHaving); + pS = pS.pPrior; + } + return mask; + } - /* - ** This routine walks (recursively) an expression tree and generates - ** a bitmask indicating which tables are used in that expression - ** tree. - ** - ** In order for this routine to work, the calling function must have - ** previously invoked sqlite3ResolveExprNames() on the expression. See - ** the header comment on that routine for additional information. - ** The sqlite3ResolveExprNames() routines looks for column names and - ** sets their opcodes to TK_COLUMN and their Expr.iTable fields to - ** the VDBE cursor number of the table. This routine just has to - ** translate the cursor numbers into bitmask values and OR all - ** the bitmasks together. - */ - //static Bitmask exprListTableUsage(WhereMaskSet*, ExprList); - //static Bitmask exprSelectTableUsage(WhereMaskSet*, Select); - static Bitmask exprTableUsage( WhereMaskSet pMaskSet, Expr p ) - { - Bitmask mask = 0; - if ( p == null ) - return 0; - if ( p.op == TK_COLUMN ) - { - mask = getMask( pMaskSet, p.iTable ); - return mask; - } - mask = exprTableUsage( pMaskSet, p.pRight ); - mask |= exprTableUsage( pMaskSet, p.pLeft ); - if ( ExprHasProperty( p, EP_xIsSelect ) ) - { - mask |= exprSelectTableUsage( pMaskSet, p.x.pSelect ); - } - else - { - mask |= exprListTableUsage( pMaskSet, p.x.pList ); - } - return mask; - } - static Bitmask exprListTableUsage( WhereMaskSet pMaskSet, ExprList pList ) - { - int i; - Bitmask mask = 0; - if ( pList != null ) - { - for ( i = 0; i < pList.nExpr; i++ ) - { - mask |= exprTableUsage( pMaskSet, pList.a[i].pExpr ); + /* + ** Return TRUE if the given operator is one of the operators that is + ** allowed for an indexable WHERE clause term. The allowed operators are + ** "=", "<", ">", "<=", ">=", and "IN". + ** + ** IMPLEMENTATION-OF: R-59926-26393 To be usable by an index a term must be + ** of one of the following forms: column = expression column > expression + ** column >= expression column < expression column <= expression + ** expression = column expression > column expression >= column + ** expression < column expression <= column column IN + ** (expression-list) column IN (subquery) column IS NULL + */ + static bool allowedOp(int op) { + Debug.Assert(TK_GT > TK_EQ && TK_GT < TK_GE); + Debug.Assert(TK_LT > TK_EQ && TK_LT < TK_GE); + Debug.Assert(TK_LE > TK_EQ && TK_LE < TK_GE); + Debug.Assert(TK_GE == TK_EQ + 4); + return op == TK_IN || (op >= TK_EQ && op <= TK_GE) || op == TK_ISNULL; } - } - return mask; - } - static Bitmask exprSelectTableUsage( WhereMaskSet pMaskSet, Select pS ) - { - Bitmask mask = 0; - while ( pS != null ) - { - mask |= exprListTableUsage( pMaskSet, pS.pEList ); - mask |= exprListTableUsage( pMaskSet, pS.pGroupBy ); - mask |= exprListTableUsage( pMaskSet, pS.pOrderBy ); - mask |= exprTableUsage( pMaskSet, pS.pWhere ); - mask |= exprTableUsage( pMaskSet, pS.pHaving ); - pS = pS.pPrior; - } - return mask; - } - /* - ** Return TRUE if the given operator is one of the operators that is - ** allowed for an indexable WHERE clause term. The allowed operators are - ** "=", "<", ">", "<=", ">=", and "IN". - ** - ** IMPLEMENTATION-OF: R-59926-26393 To be usable by an index a term must be - ** of one of the following forms: column = expression column > expression - ** column >= expression column < expression column <= expression - ** expression = column expression > column expression >= column - ** expression < column expression <= column column IN - ** (expression-list) column IN (subquery) column IS NULL - */ - static bool allowedOp( int op ) - { - Debug.Assert( TK_GT > TK_EQ && TK_GT < TK_GE ); - Debug.Assert( TK_LT > TK_EQ && TK_LT < TK_GE ); - Debug.Assert( TK_LE > TK_EQ && TK_LE < TK_GE ); - Debug.Assert( TK_GE == TK_EQ + 4 ); - return op == TK_IN || ( op >= TK_EQ && op <= TK_GE ) || op == TK_ISNULL; - } - - /* - ** Swap two objects of type TYPE. - */ - //#define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;} - - /* - ** Commute a comparison operator. Expressions of the form "X op Y" - ** are converted into "Y op X". - ** - ** If a collation sequence is Debug.Associated with either the left or right - ** side of the comparison, it remains Debug.Associated with the same side after - ** the commutation. So "Y collate NOCASE op X" becomes - ** "X collate NOCASE op Y". This is because any collation sequence on - ** the left hand side of a comparison overrides any collation sequence - ** attached to the right. For the same reason the EP_ExpCollate flag - ** is not commuted. - */ - static void exprCommute( Parse pParse, Expr pExpr ) - { - u16 expRight = (u16)( pExpr.pRight.flags & EP_ExpCollate ); - u16 expLeft = (u16)( pExpr.pLeft.flags & EP_ExpCollate ); - Debug.Assert( allowedOp( pExpr.op ) && pExpr.op != TK_IN ); - pExpr.pRight.pColl = sqlite3ExprCollSeq( pParse, pExpr.pRight ); - pExpr.pLeft.pColl = sqlite3ExprCollSeq( pParse, pExpr.pLeft ); - SWAP( ref pExpr.pRight.pColl, ref pExpr.pLeft.pColl ); - pExpr.pRight.flags = (u16)( ( pExpr.pRight.flags & ~EP_ExpCollate ) | expLeft ); - pExpr.pLeft.flags = (u16)( ( pExpr.pLeft.flags & ~EP_ExpCollate ) | expRight ); - SWAP( ref pExpr.pRight, ref pExpr.pLeft ); - if ( pExpr.op >= TK_GT ) - { - Debug.Assert( TK_LT == TK_GT + 2 ); - Debug.Assert( TK_GE == TK_LE + 2 ); - Debug.Assert( TK_GT > TK_EQ ); - Debug.Assert( TK_GT < TK_LE ); - Debug.Assert( pExpr.op >= TK_GT && pExpr.op <= TK_GE ); - pExpr.op = (u8)( ( ( pExpr.op - TK_GT ) ^ 2 ) + TK_GT ); - } - } - - /* - ** Translate from TK_xx operator to WO_xx bitmask. - */ - static u16 operatorMask( int op ) - { - u16 c; - Debug.Assert( allowedOp( op ) ); - if ( op == TK_IN ) - { - c = WO_IN; - } - else if ( op == TK_ISNULL ) - { - c = WO_ISNULL; - } - else - { - Debug.Assert( ( WO_EQ << ( op - TK_EQ ) ) < 0x7fff ); - c = (u16)( WO_EQ << ( op - TK_EQ ) ); - } - Debug.Assert( op != TK_ISNULL || c == WO_ISNULL ); - Debug.Assert( op != TK_IN || c == WO_IN ); - Debug.Assert( op != TK_EQ || c == WO_EQ ); - Debug.Assert( op != TK_LT || c == WO_LT ); - Debug.Assert( op != TK_LE || c == WO_LE ); - Debug.Assert( op != TK_GT || c == WO_GT ); - Debug.Assert( op != TK_GE || c == WO_GE ); - return c; - } - - /* - ** Search for a term in the WHERE clause that is of the form "X " - ** where X is a reference to the iColumn of table iCur and is one of - ** the WO_xx operator codes specified by the op parameter. - ** Return a pointer to the term. Return 0 if not found. - */ - static WhereTerm findTerm( - WhereClause pWC, /* The WHERE clause to be searched */ - int iCur, /* Cursor number of LHS */ - int iColumn, /* Column number of LHS */ - Bitmask notReady, /* RHS must not overlap with this mask */ - u32 op, /* Mask of WO_xx values describing operator */ - Index pIdx /* Must be compatible with this index, if not NULL */ - ) - { - WhereTerm pTerm; - int k; - Debug.Assert( iCur >= 0 ); - op &= WO_ALL; - for ( k = pWC.nTerm; k != 0; k-- )//, pTerm++) - { - pTerm = pWC.a[pWC.nTerm - k]; - if ( pTerm.leftCursor == iCur - && ( pTerm.prereqRight & notReady ) == 0 - && pTerm.u.leftColumn == iColumn - && ( pTerm.eOperator & op ) != 0 - ) - { - if ( pIdx != null && pTerm.eOperator != WO_ISNULL ) - { - Expr pX = pTerm.pExpr; - CollSeq pColl; - char idxaff; - int j; - Parse pParse = pWC.pParse; + /* + ** Swap two objects of type TYPE. + */ + //#define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;} - idxaff = pIdx.pTable.aCol[iColumn].affinity; - if ( !sqlite3IndexAffinityOk( pX, idxaff ) ) - continue; + /* + ** Commute a comparison operator. Expressions of the form "X op Y" + ** are converted into "Y op X". + ** + ** If a collation sequence is Debug.Associated with either the left or right + ** side of the comparison, it remains Debug.Associated with the same side after + ** the commutation. So "Y collate NOCASE op X" becomes + ** "X collate NOCASE op Y". This is because any collation sequence on + ** the left hand side of a comparison overrides any collation sequence + ** attached to the right. For the same reason the EP_ExpCollate flag + ** is not commuted. + */ + static void exprCommute(Parse pParse, Expr pExpr) { + u16 expRight = (u16)(pExpr.pRight.flags & EP_ExpCollate); + u16 expLeft = (u16)(pExpr.pLeft.flags & EP_ExpCollate); + Debug.Assert(allowedOp(pExpr.op) && pExpr.op != TK_IN); + pExpr.pRight.pColl = sqlite3ExprCollSeq(pParse, pExpr.pRight); + pExpr.pLeft.pColl = sqlite3ExprCollSeq(pParse, pExpr.pLeft); + SWAP(ref pExpr.pRight.pColl, ref pExpr.pLeft.pColl); + pExpr.pRight.flags = (u16)((pExpr.pRight.flags & ~EP_ExpCollate) | expLeft); + pExpr.pLeft.flags = (u16)((pExpr.pLeft.flags & ~EP_ExpCollate) | expRight); + SWAP(ref pExpr.pRight, ref pExpr.pLeft); + if (pExpr.op >= TK_GT) { + Debug.Assert(TK_LT == TK_GT + 2); + Debug.Assert(TK_GE == TK_LE + 2); + Debug.Assert(TK_GT > TK_EQ); + Debug.Assert(TK_GT < TK_LE); + Debug.Assert(pExpr.op >= TK_GT && pExpr.op <= TK_GE); + pExpr.op = (u8)(((pExpr.op - TK_GT) ^ 2) + TK_GT); + } + } - /* Figure out the collation sequence required from an index for - ** it to be useful for optimising expression pX. Store this - ** value in variable pColl. - */ - Debug.Assert( pX.pLeft != null ); - pColl = sqlite3BinaryCompareCollSeq( pParse, pX.pLeft, pX.pRight ); - Debug.Assert( pColl != null || pParse.nErr != 0 ); + /* + ** Translate from TK_xx operator to WO_xx bitmask. + */ + static u16 operatorMask(int op) { + u16 c; + Debug.Assert(allowedOp(op)); + if (op == TK_IN) { + c = WO_IN; + } else if (op == TK_ISNULL) { + c = WO_ISNULL; + } else { + Debug.Assert((WO_EQ << (op - TK_EQ)) < 0x7fff); + c = (u16)(WO_EQ << (op - TK_EQ)); + } + Debug.Assert(op != TK_ISNULL || c == WO_ISNULL); + Debug.Assert(op != TK_IN || c == WO_IN); + Debug.Assert(op != TK_EQ || c == WO_EQ); + Debug.Assert(op != TK_LT || c == WO_LT); + Debug.Assert(op != TK_LE || c == WO_LE); + Debug.Assert(op != TK_GT || c == WO_GT); + Debug.Assert(op != TK_GE || c == WO_GE); + return c; + } - for ( j = 0; pIdx.aiColumn[j] != iColumn; j++ ) + /* + ** Search for a term in the WHERE clause that is of the form "X " + ** where X is a reference to the iColumn of table iCur and is one of + ** the WO_xx operator codes specified by the op parameter. + ** Return a pointer to the term. Return 0 if not found. + */ + static WhereTerm findTerm( + WhereClause pWC, /* The WHERE clause to be searched */ + int iCur, /* Cursor number of LHS */ + int iColumn, /* Column number of LHS */ + Bitmask notReady, /* RHS must not overlap with this mask */ + u32 op, /* Mask of WO_xx values describing operator */ + Index pIdx /* Must be compatible with this index, if not NULL */ + ) { + WhereTerm pTerm; + int k; + Debug.Assert(iCur >= 0); + op &= WO_ALL; + for (k = pWC.nTerm; k != 0; k--)//, pTerm++) { - if ( NEVER( j >= pIdx.nColumn ) ) - return null; + pTerm = pWC.a[pWC.nTerm - k]; + if (pTerm.leftCursor == iCur + && (pTerm.prereqRight & notReady) == 0 + && pTerm.u.leftColumn == iColumn + && (pTerm.eOperator & op) != 0 + ) { + if (pIdx != null && pTerm.eOperator != WO_ISNULL) { + Expr pX = pTerm.pExpr; + CollSeq pColl; + char idxaff; + int j; + Parse pParse = pWC.pParse; + + idxaff = pIdx.pTable.aCol[iColumn].affinity; + if (!sqlite3IndexAffinityOk(pX, idxaff)) + continue; + + /* Figure out the collation sequence required from an index for + ** it to be useful for optimising expression pX. Store this + ** value in variable pColl. + */ + Debug.Assert(pX.pLeft != null); + pColl = sqlite3BinaryCompareCollSeq(pParse, pX.pLeft, pX.pRight); + Debug.Assert(pColl != null || pParse.nErr != 0); + + for (j = 0; pIdx.aiColumn[j] != iColumn; j++) { + if (NEVER(j >= pIdx.nColumn)) + return null; + } + if (pColl != null && !pColl.zName.Equals(pIdx.azColl[j], StringComparison.OrdinalIgnoreCase)) + continue; + } + return pTerm; + } } - if ( pColl != null && !pColl.zName.Equals( pIdx.azColl[j], StringComparison.OrdinalIgnoreCase ) ) - continue; - } - return pTerm; + return null; } - } - return null; - } - /* Forward reference */ - //static void exprAnalyze(SrcList*, WhereClause*, int); + /* Forward reference */ + //static void exprAnalyze(SrcList*, WhereClause*, int); - /* - ** Call exprAnalyze on all terms in a WHERE clause. - ** + /* + ** Call exprAnalyze on all terms in a WHERE clause. + ** + ** + */ + static void exprAnalyzeAll( + SrcList pTabList, /* the FROM clause */ + WhereClause pWC /* the WHERE clause to be analyzed */ + ) { + int i; + for (i = pWC.nTerm - 1; i >= 0; i--) { + exprAnalyze(pTabList, pWC, i); + } + } + +#if !SQLITE_OMIT_LIKE_OPTIMIZATION + /* + ** Check to see if the given expression is a LIKE or GLOB operator that + ** can be optimized using inequality constraints. Return TRUE if it is + ** so and false if not. ** + ** In order for the operator to be optimizible, the RHS must be a string + ** literal that does not begin with a wildcard. */ - static void exprAnalyzeAll( - SrcList pTabList, /* the FROM clause */ - WhereClause pWC /* the WHERE clause to be analyzed */ - ) - { - int i; - for ( i = pWC.nTerm - 1; i >= 0; i-- ) - { - exprAnalyze( pTabList, pWC, i ); - } - } - -#if !SQLITE_OMIT_LIKE_OPTIMIZATION - /* -** Check to see if the given expression is a LIKE or GLOB operator that -** can be optimized using inequality constraints. Return TRUE if it is -** so and false if not. -** -** In order for the operator to be optimizible, the RHS must be a string -** literal that does not begin with a wildcard. -*/ - static int isLikeOrGlob( - Parse pParse, /* Parsing and code generating context */ - Expr pExpr, /* Test this expression */ - ref Expr ppPrefix, /* Pointer to TK_STRING expression with pattern prefix */ - ref bool pisComplete, /* True if the only wildcard is % in the last character */ - ref bool pnoCase /* True if uppercase is equivalent to lowercase */ - ) - { - string z = null; /* String on RHS of LIKE operator */ - Expr pRight, pLeft; /* Right and left size of LIKE operator */ - ExprList pList; /* List of operands to the LIKE operator */ - int c = 0; /* One character in z[] */ - int cnt; /* Number of non-wildcard prefix characters */ - char[] wc = new char[3]; /* Wildcard characters */ - sqlite3 db = pParse.db; /* Data_base connection */ - sqlite3_value pVal = null; - int op; /* Opcode of pRight */ - - if ( !sqlite3IsLikeFunction( db, pExpr, ref pnoCase, wc ) ) - { - return 0; - } - //#if SQLITE_EBCDIC - //if( pnoCase ) return 0; - //#endif - pList = pExpr.x.pList; - pLeft = pList.a[1].pExpr; - if ( pLeft.op != TK_COLUMN || sqlite3ExprAffinity( pLeft ) != SQLITE_AFF_TEXT ) - { - /* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must - ** be the name of an indexed column with TEXT affinity. */ - return 0; - } - Debug.Assert( pLeft.iColumn != ( -1 ) ); /* Because IPK never has AFF_TEXT */ + static int isLikeOrGlob( + Parse pParse, /* Parsing and code generating context */ + Expr pExpr, /* Test this expression */ + ref Expr ppPrefix, /* Pointer to TK_STRING expression with pattern prefix */ + ref bool pisComplete, /* True if the only wildcard is % in the last character */ + ref bool pnoCase /* True if uppercase is equivalent to lowercase */ + ) { + string z = null; /* String on RHS of LIKE operator */ + Expr pRight, pLeft; /* Right and left size of LIKE operator */ + ExprList pList; /* List of operands to the LIKE operator */ + int c = 0; /* One character in z[] */ + int cnt; /* Number of non-wildcard prefix characters */ + char[] wc = new char[3]; /* Wildcard characters */ + sqlite3 db = pParse.db; /* Data_base connection */ + sqlite3_value pVal = null; + int op; /* Opcode of pRight */ + + if (!sqlite3IsLikeFunction(db, pExpr, ref pnoCase, wc)) { + return 0; + } + //#if SQLITE_EBCDIC + //if( pnoCase ) return 0; + //#endif + pList = pExpr.x.pList; + pLeft = pList.a[1].pExpr; + if (pLeft.op != TK_COLUMN || sqlite3ExprAffinity(pLeft) != SQLITE_AFF_TEXT) { + /* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must + ** be the name of an indexed column with TEXT affinity. */ + return 0; + } + Debug.Assert(pLeft.iColumn != (-1)); /* Because IPK never has AFF_TEXT */ - pRight = pList.a[0].pExpr; - op = pRight.op; - if ( op == TK_REGISTER ) - { - op = pRight.op2; - } - if ( op == TK_VARIABLE ) - { - Vdbe pReprepare = pParse.pReprepare; - int iCol = pRight.iColumn; - pVal = sqlite3VdbeGetValue( pReprepare, iCol, (byte)SQLITE_AFF_NONE ); - if ( pVal != null && sqlite3_value_type( pVal ) == SQLITE_TEXT ) - { - z = sqlite3_value_text( pVal ); - } - sqlite3VdbeSetVarmask( pParse.pVdbe, iCol ); /* IMP: R-23257-02778 */ - Debug.Assert( pRight.op == TK_VARIABLE || pRight.op == TK_REGISTER ); - } - else if ( op == TK_STRING ) - { - z = pRight.u.zToken; - } - if ( !String.IsNullOrEmpty( z ) ) - { - cnt = 0; - while ( cnt < z.Length && ( c = z[cnt] ) != 0 && c != wc[0] && c != wc[1] && c != wc[2] ) - { - cnt++; - } - if ( cnt != 0 && 255 != (u8)z[cnt - 1] ) - { - Expr pPrefix; - pisComplete = c == wc[0] && cnt == z.Length - 1; - pPrefix = sqlite3Expr( db, TK_STRING, z ); - if ( pPrefix != null ) - pPrefix.u.zToken = pPrefix.u.zToken.Substring( 0, cnt ); - ppPrefix = pPrefix; - if ( op == TK_VARIABLE ) - { - Vdbe v = pParse.pVdbe; - sqlite3VdbeSetVarmask( v, pRight.iColumn ); /* IMP: R-23257-02778 */ - if ( pisComplete && pRight.u.zToken.Length > 1 ) - { - /* If the rhs of the LIKE expression is a variable, and the current - ** value of the variable means there is no need to invoke the LIKE - ** function, then no OP_Variable will be added to the program. - ** This causes problems for the sqlite3_bind_parameter_name() - ** API. To workaround them, add a dummy OP_Variable here. - */ - int r1 = sqlite3GetTempReg( pParse ); - sqlite3ExprCodeTarget( pParse, pRight, r1 ); - sqlite3VdbeChangeP3( v, sqlite3VdbeCurrentAddr( v ) - 1, 0 ); - sqlite3ReleaseTempReg( pParse, r1 ); + pRight = pList.a[0].pExpr; + op = pRight.op; + if (op == TK_REGISTER) { + op = pRight.op2; + } + if (op == TK_VARIABLE) { + Vdbe pReprepare = pParse.pReprepare; + int iCol = pRight.iColumn; + pVal = sqlite3VdbeGetValue(pReprepare, iCol, (byte)SQLITE_AFF_NONE); + if (pVal != null && sqlite3_value_type(pVal) == SQLITE_TEXT) { + z = sqlite3_value_text(pVal); + } + sqlite3VdbeSetVarmask(pParse.pVdbe, iCol); /* IMP: R-23257-02778 */ + Debug.Assert(pRight.op == TK_VARIABLE || pRight.op == TK_REGISTER); + } else if (op == TK_STRING) { + z = pRight.u.zToken; + } + if (!String.IsNullOrEmpty(z)) { + cnt = 0; + while (cnt < z.Length && (c = z[cnt]) != 0 && c != wc[0] && c != wc[1] && c != wc[2]) { + cnt++; + } + if (cnt != 0 && 255 != (u8)z[cnt - 1]) { + Expr pPrefix; + pisComplete = c == wc[0] && cnt == z.Length - 1; + pPrefix = sqlite3Expr(db, TK_STRING, z); + if (pPrefix != null) + pPrefix.u.zToken = pPrefix.u.zToken.Substring(0, cnt); + ppPrefix = pPrefix; + if (op == TK_VARIABLE) { + Vdbe v = pParse.pVdbe; + sqlite3VdbeSetVarmask(v, pRight.iColumn); /* IMP: R-23257-02778 */ + if (pisComplete && pRight.u.zToken.Length > 1) { + /* If the rhs of the LIKE expression is a variable, and the current + ** value of the variable means there is no need to invoke the LIKE + ** function, then no OP_Variable will be added to the program. + ** This causes problems for the sqlite3_bind_parameter_name() + ** API. To workaround them, add a dummy OP_Variable here. + */ + int r1 = sqlite3GetTempReg(pParse); + sqlite3ExprCodeTarget(pParse, pRight, r1); + sqlite3VdbeChangeP3(v, sqlite3VdbeCurrentAddr(v) - 1, 0); + sqlite3ReleaseTempReg(pParse, r1); + } + } + } else { + z = null; + } } - } - } - else - { - z = null; - } - } - sqlite3ValueFree( ref pVal ); - return ( z != null ) ? 1 : 0; - } + sqlite3ValueFree(ref pVal); + return (z != null) ? 1 : 0; + } #endif //* SQLITE_OMIT_LIKE_OPTIMIZATION */ -#if !SQLITE_OMIT_VIRTUALTABLE -/* -** Check to see if the given expression is of the form -** -** column MATCH expr -** -** If it is then return TRUE. If not, return FALSE. -*/ -static int isMatchOfColumn( -Expr pExpr /* Test this expression */ -){ -ExprList pList; +#if !SQLITE_OMIT_VIRTUALTABLE + /* + ** Check to see if the given expression is of the form + ** + ** column MATCH expr + ** + ** If it is then return TRUE. If not, return FALSE. + */ + static int isMatchOfColumn( + Expr pExpr /* Test this expression */ + ) { + ExprList pList; -if( pExpr.op!=TK_FUNCTION ){ -return 0; -} -if( !pExpr.u.zToken.Equals("match", StringComparison.OrdinalIgnoreCase ) ){ -return 0; -} -pList = pExpr.x.pList; -if( pList.nExpr!=2 ){ - return 0; -} -if( pList.a[1].pExpr.op != TK_COLUMN ){ -return 0; -} -return 1; -} + if (pExpr.op != TK_FUNCTION) { + return 0; + } + if (!pExpr.u.zToken.Equals("match", StringComparison.OrdinalIgnoreCase)) { + return 0; + } + pList = pExpr.x.pList; + if (pList.nExpr != 2) { + return 0; + } + if (pList.a[1].pExpr.op != TK_COLUMN) { + return 0; + } + return 1; + } #endif //* SQLITE_OMIT_VIRTUALTABLE */ - /* -** If the pBase expression originated in the ON or USING clause of -** a join, then transfer the appropriate markings over to derived. -*/ - static void transferJoinMarkings( Expr pDerived, Expr pBase ) - { - pDerived.flags = (u16)( pDerived.flags | pBase.flags & EP_FromJoin ); - pDerived.iRightJoinTable = pBase.iRightJoinTable; - } + /* + ** If the pBase expression originated in the ON or USING clause of + ** a join, then transfer the appropriate markings over to derived. + */ + static void transferJoinMarkings(Expr pDerived, Expr pBase) { + pDerived.flags = (u16)(pDerived.flags | pBase.flags & EP_FromJoin); + pDerived.iRightJoinTable = pBase.iRightJoinTable; + } -#if !(SQLITE_OMIT_OR_OPTIMIZATION) && !(SQLITE_OMIT_SUBQUERY) - /* -** Analyze a term that consists of two or more OR-connected -** subterms. So in: -** -** ... WHERE (a=5) AND (b=7 OR c=9 OR d=13) AND (d=13) -** ^^^^^^^^^^^^^^^^^^^^ -** -** This routine analyzes terms such as the middle term in the above example. -** A WhereOrTerm object is computed and attached to the term under -** analysis, regardless of the outcome of the analysis. Hence: -** -** WhereTerm.wtFlags |= TERM_ORINFO -** WhereTerm.u.pOrInfo = a dynamically allocated WhereOrTerm object -** -** The term being analyzed must have two or more of OR-connected subterms. -** A single subterm might be a set of AND-connected sub-subterms. -** Examples of terms under analysis: -** -** (A) t1.x=t2.y OR t1.x=t2.z OR t1.y=15 OR t1.z=t3.a+5 -** (B) x=expr1 OR expr2=x OR x=expr3 -** (C) t1.x=t2.y OR (t1.x=t2.z AND t1.y=15) -** (D) x=expr1 OR (y>11 AND y<22 AND z LIKE '*hello*') -** (E) (p.a=1 AND q.b=2 AND r.c=3) OR (p.x=4 AND q.y=5 AND r.z=6) -** -** CASE 1: -** -** If all subterms are of the form T.C=expr for some single column of C -** a single table T (as shown in example B above) then create a new virtual -** term that is an equivalent IN expression. In other words, if the term -** being analyzed is: -** -** x = expr1 OR expr2 = x OR x = expr3 -** -** then create a new virtual term like this: -** -** x IN (expr1,expr2,expr3) -** -** CASE 2: -** -** If all subterms are indexable by a single table T, then set -** -** WhereTerm.eOperator = WO_OR -** WhereTerm.u.pOrInfo.indexable |= the cursor number for table T -** -** A subterm is "indexable" if it is of the form -** "T.C " where C is any column of table T and -** is one of "=", "<", "<=", ">", ">=", "IS NULL", or "IN". -** A subterm is also indexable if it is an AND of two or more -** subsubterms at least one of which is indexable. Indexable AND -** subterms have their eOperator set to WO_AND and they have -** u.pAndInfo set to a dynamically allocated WhereAndTerm object. -** -** From another point of view, "indexable" means that the subterm could -** potentially be used with an index if an appropriate index exists. -** This analysis does not consider whether or not the index exists; that -** is something the bestIndex() routine will determine. This analysis -** only looks at whether subterms appropriate for indexing exist. -** -** All examples A through E above all satisfy case 2. But if a term -** also statisfies case 1 (such as B) we know that the optimizer will -** always prefer case 1, so in that case we pretend that case 2 is not -** satisfied. -** -** It might be the case that multiple tables are indexable. For example, -** (E) above is indexable on tables P, Q, and R. -** -** Terms that satisfy case 2 are candidates for lookup by using -** separate indices to find rowids for each subterm and composing -** the union of all rowids using a RowSet object. This is similar -** to "bitmap indices" in other data_base engines. -** -** OTHERWISE: -** -** If neither case 1 nor case 2 apply, then leave the eOperator set to -** zero. This term is not useful for search. -*/ - static void exprAnalyzeOrTerm( - SrcList pSrc, /* the FROM clause */ - WhereClause pWC, /* the complete WHERE clause */ - int idxTerm /* Index of the OR-term to be analyzed */ - ) - { - Parse pParse = pWC.pParse; /* Parser context */ - sqlite3 db = pParse.db; /* Data_base connection */ - WhereTerm pTerm = pWC.a[idxTerm]; /* The term to be analyzed */ - Expr pExpr = pTerm.pExpr; /* The expression of the term */ - WhereMaskSet pMaskSet = pWC.pMaskSet; /* Table use masks */ - int i; /* Loop counters */ - WhereClause pOrWc; /* Breakup of pTerm into subterms */ - WhereTerm pOrTerm; /* A Sub-term within the pOrWc */ - WhereOrInfo pOrInfo; /* Additional information Debug.Associated with pTerm */ - Bitmask chngToIN; /* Tables that might satisfy case 1 */ - Bitmask indexable; /* Tables that are indexable, satisfying case 2 */ - - /* - ** Break the OR clause into its separate subterms. The subterms are - ** stored in a WhereClause structure containing within the WhereOrInfo - ** object that is attached to the original OR clause term. - */ - Debug.Assert( ( pTerm.wtFlags & ( TERM_DYNAMIC | TERM_ORINFO | TERM_ANDINFO ) ) == 0 ); - Debug.Assert( pExpr.op == TK_OR ); - pTerm.u.pOrInfo = pOrInfo = new WhereOrInfo();//sqlite3DbMallocZero(db, sizeof(*pOrInfo)); - if ( pOrInfo == null ) - return; - pTerm.wtFlags |= TERM_ORINFO; - pOrWc = pOrInfo.wc; - whereClauseInit( pOrWc, pWC.pParse, pMaskSet ); - whereSplit( pOrWc, pExpr, TK_OR ); - exprAnalyzeAll( pSrc, pOrWc ); - // if ( db.mallocFailed != 0 ) return; - Debug.Assert( pOrWc.nTerm >= 2 ); - - /* - ** Compute the set of tables that might satisfy cases 1 or 2. - */ - indexable = ~(Bitmask)0; - chngToIN = ~( pWC.vmask ); - for ( i = pOrWc.nTerm - 1; i >= 0 && indexable != 0; i-- )//, pOrTerm++ ) - { - pOrTerm = pOrWc.a[i]; - if ( ( pOrTerm.eOperator & WO_SINGLE ) == 0 ) - { - WhereAndInfo pAndInfo; - Debug.Assert( pOrTerm.eOperator == 0 ); - Debug.Assert( ( pOrTerm.wtFlags & ( TERM_ANDINFO | TERM_ORINFO ) ) == 0 ); - chngToIN = 0; - pAndInfo = new WhereAndInfo();//sqlite3DbMallocRaw(db, sizeof(*pAndInfo)); - if ( pAndInfo != null ) - { - WhereClause pAndWC; - WhereTerm pAndTerm; - int j; - Bitmask b = 0; - pOrTerm.u.pAndInfo = pAndInfo; - pOrTerm.wtFlags |= TERM_ANDINFO; - pOrTerm.eOperator = WO_AND; - pAndWC = pAndInfo.wc; - whereClauseInit( pAndWC, pWC.pParse, pMaskSet ); - whereSplit( pAndWC, pOrTerm.pExpr, TK_AND ); - exprAnalyzeAll( pSrc, pAndWC ); - //testcase( db.mallocFailed ); - ////if ( 0 == db.mallocFailed ) +#if !(SQLITE_OMIT_OR_OPTIMIZATION) && !(SQLITE_OMIT_SUBQUERY) + /* + ** Analyze a term that consists of two or more OR-connected + ** subterms. So in: + ** + ** ... WHERE (a=5) AND (b=7 OR c=9 OR d=13) AND (d=13) + ** ^^^^^^^^^^^^^^^^^^^^ + ** + ** This routine analyzes terms such as the middle term in the above example. + ** A WhereOrTerm object is computed and attached to the term under + ** analysis, regardless of the outcome of the analysis. Hence: + ** + ** WhereTerm.wtFlags |= TERM_ORINFO + ** WhereTerm.u.pOrInfo = a dynamically allocated WhereOrTerm object + ** + ** The term being analyzed must have two or more of OR-connected subterms. + ** A single subterm might be a set of AND-connected sub-subterms. + ** Examples of terms under analysis: + ** + ** (A) t1.x=t2.y OR t1.x=t2.z OR t1.y=15 OR t1.z=t3.a+5 + ** (B) x=expr1 OR expr2=x OR x=expr3 + ** (C) t1.x=t2.y OR (t1.x=t2.z AND t1.y=15) + ** (D) x=expr1 OR (y>11 AND y<22 AND z LIKE '*hello*') + ** (E) (p.a=1 AND q.b=2 AND r.c=3) OR (p.x=4 AND q.y=5 AND r.z=6) + ** + ** CASE 1: + ** + ** If all subterms are of the form T.C=expr for some single column of C + ** a single table T (as shown in example B above) then create a new virtual + ** term that is an equivalent IN expression. In other words, if the term + ** being analyzed is: + ** + ** x = expr1 OR expr2 = x OR x = expr3 + ** + ** then create a new virtual term like this: + ** + ** x IN (expr1,expr2,expr3) + ** + ** CASE 2: + ** + ** If all subterms are indexable by a single table T, then set + ** + ** WhereTerm.eOperator = WO_OR + ** WhereTerm.u.pOrInfo.indexable |= the cursor number for table T + ** + ** A subterm is "indexable" if it is of the form + ** "T.C " where C is any column of table T and + ** is one of "=", "<", "<=", ">", ">=", "IS NULL", or "IN". + ** A subterm is also indexable if it is an AND of two or more + ** subsubterms at least one of which is indexable. Indexable AND + ** subterms have their eOperator set to WO_AND and they have + ** u.pAndInfo set to a dynamically allocated WhereAndTerm object. + ** + ** From another point of view, "indexable" means that the subterm could + ** potentially be used with an index if an appropriate index exists. + ** This analysis does not consider whether or not the index exists; that + ** is something the bestIndex() routine will determine. This analysis + ** only looks at whether subterms appropriate for indexing exist. + ** + ** All examples A through E above all satisfy case 2. But if a term + ** also statisfies case 1 (such as B) we know that the optimizer will + ** always prefer case 1, so in that case we pretend that case 2 is not + ** satisfied. + ** + ** It might be the case that multiple tables are indexable. For example, + ** (E) above is indexable on tables P, Q, and R. + ** + ** Terms that satisfy case 2 are candidates for lookup by using + ** separate indices to find rowids for each subterm and composing + ** the union of all rowids using a RowSet object. This is similar + ** to "bitmap indices" in other data_base engines. + ** + ** OTHERWISE: + ** + ** If neither case 1 nor case 2 apply, then leave the eOperator set to + ** zero. This term is not useful for search. + */ + static void exprAnalyzeOrTerm( + SrcList pSrc, /* the FROM clause */ + WhereClause pWC, /* the complete WHERE clause */ + int idxTerm /* Index of the OR-term to be analyzed */ + ) { + Parse pParse = pWC.pParse; /* Parser context */ + sqlite3 db = pParse.db; /* Data_base connection */ + WhereTerm pTerm = pWC.a[idxTerm]; /* The term to be analyzed */ + Expr pExpr = pTerm.pExpr; /* The expression of the term */ + WhereMaskSet pMaskSet = pWC.pMaskSet; /* Table use masks */ + int i; /* Loop counters */ + WhereClause pOrWc; /* Breakup of pTerm into subterms */ + WhereTerm pOrTerm; /* A Sub-term within the pOrWc */ + WhereOrInfo pOrInfo; /* Additional information Debug.Associated with pTerm */ + Bitmask chngToIN; /* Tables that might satisfy case 1 */ + Bitmask indexable; /* Tables that are indexable, satisfying case 2 */ + + /* + ** Break the OR clause into its separate subterms. The subterms are + ** stored in a WhereClause structure containing within the WhereOrInfo + ** object that is attached to the original OR clause term. + */ + Debug.Assert((pTerm.wtFlags & (TERM_DYNAMIC | TERM_ORINFO | TERM_ANDINFO)) == 0); + Debug.Assert(pExpr.op == TK_OR); + pTerm.u.pOrInfo = pOrInfo = new WhereOrInfo();//sqlite3DbMallocZero(db, sizeof(*pOrInfo)); + if (pOrInfo == null) + return; + pTerm.wtFlags |= TERM_ORINFO; + pOrWc = pOrInfo.wc; + whereClauseInit(pOrWc, pWC.pParse, pMaskSet); + whereSplit(pOrWc, pExpr, TK_OR); + exprAnalyzeAll(pSrc, pOrWc); + // if ( db.mallocFailed != 0 ) return; + Debug.Assert(pOrWc.nTerm >= 2); + + /* + ** Compute the set of tables that might satisfy cases 1 or 2. + */ + indexable = ~(Bitmask)0; + chngToIN = ~(pWC.vmask); + for (i = pOrWc.nTerm - 1; i >= 0 && indexable != 0; i--)//, pOrTerm++ ) { - for ( j = 0; j < pAndWC.nTerm; j++ )//, pAndTerm++ ) - { - pAndTerm = pAndWC.a[j]; - Debug.Assert( pAndTerm.pExpr != null ); - if ( allowedOp( pAndTerm.pExpr.op ) ) - { - b |= getMask( pMaskSet, pAndTerm.leftCursor ); + pOrTerm = pOrWc.a[i]; + if ((pOrTerm.eOperator & WO_SINGLE) == 0) { + WhereAndInfo pAndInfo; + Debug.Assert(pOrTerm.eOperator == 0); + Debug.Assert((pOrTerm.wtFlags & (TERM_ANDINFO | TERM_ORINFO)) == 0); + chngToIN = 0; + pAndInfo = new WhereAndInfo();//sqlite3DbMallocRaw(db, sizeof(*pAndInfo)); + if (pAndInfo != null) { + WhereClause pAndWC; + WhereTerm pAndTerm; + int j; + Bitmask b = 0; + pOrTerm.u.pAndInfo = pAndInfo; + pOrTerm.wtFlags |= TERM_ANDINFO; + pOrTerm.eOperator = WO_AND; + pAndWC = pAndInfo.wc; + whereClauseInit(pAndWC, pWC.pParse, pMaskSet); + whereSplit(pAndWC, pOrTerm.pExpr, TK_AND); + exprAnalyzeAll(pSrc, pAndWC); + //testcase( db.mallocFailed ); + ////if ( 0 == db.mallocFailed ) + { + for (j = 0; j < pAndWC.nTerm; j++)//, pAndTerm++ ) + { + pAndTerm = pAndWC.a[j]; + Debug.Assert(pAndTerm.pExpr != null); + if (allowedOp(pAndTerm.pExpr.op)) { + b |= getMask(pMaskSet, pAndTerm.leftCursor); + } + } + } + indexable &= b; + } + } else if ((pOrTerm.wtFlags & TERM_COPIED) != 0) { + /* Skip this term for now. We revisit it when we process the + ** corresponding TERM_VIRTUAL term */ + } else { + Bitmask b; + b = getMask(pMaskSet, pOrTerm.leftCursor); + if ((pOrTerm.wtFlags & TERM_VIRTUAL) != 0) { + WhereTerm pOther = pOrWc.a[pOrTerm.iParent]; + b |= getMask(pMaskSet, pOther.leftCursor); + } + indexable &= b; + if (pOrTerm.eOperator != WO_EQ) { + chngToIN = 0; + } else { + chngToIN &= b; + } } - } } - indexable &= b; - } - } - else if ( ( pOrTerm.wtFlags & TERM_COPIED ) != 0 ) - { - /* Skip this term for now. We revisit it when we process the - ** corresponding TERM_VIRTUAL term */ - } - else - { - Bitmask b; - b = getMask( pMaskSet, pOrTerm.leftCursor ); - if ( ( pOrTerm.wtFlags & TERM_VIRTUAL ) != 0 ) - { - WhereTerm pOther = pOrWc.a[pOrTerm.iParent]; - b |= getMask( pMaskSet, pOther.leftCursor ); - } - indexable &= b; - if ( pOrTerm.eOperator != WO_EQ ) - { - chngToIN = 0; - } - else - { - chngToIN &= b; - } - } - } - /* - ** Record the set of tables that satisfy case 2. The set might be - ** empty. - */ - pOrInfo.indexable = indexable; - pTerm.eOperator = (u16)( indexable == 0 ? 0 : WO_OR ); + /* + ** Record the set of tables that satisfy case 2. The set might be + ** empty. + */ + pOrInfo.indexable = indexable; + pTerm.eOperator = (u16)(indexable == 0 ? 0 : WO_OR); - /* - ** chngToIN holds a set of tables that *might* satisfy case 1. But - ** we have to do some additional checking to see if case 1 really - ** is satisfied. - ** - ** chngToIN will hold either 0, 1, or 2 bits. The 0-bit case means - ** that there is no possibility of transforming the OR clause into an - ** IN operator because one or more terms in the OR clause contain - ** something other than == on a column in the single table. The 1-bit - ** case means that every term of the OR clause is of the form - ** "table.column=expr" for some single table. The one bit that is set - ** will correspond to the common table. We still need to check to make - ** sure the same column is used on all terms. The 2-bit case is when - ** the all terms are of the form "table1.column=table2.column". It - ** might be possible to form an IN operator with either table1.column - ** or table2.column as the LHS if either is common to every term of - ** the OR clause. - ** - ** Note that terms of the form "table.column1=table.column2" (the - ** same table on both sizes of the ==) cannot be optimized. - */ - if ( chngToIN != 0 ) - { - int okToChngToIN = 0; /* True if the conversion to IN is valid */ - int iColumn = -1; /* Column index on lhs of IN operator */ - int iCursor = -1; /* Table cursor common to all terms */ - int j = 0; /* Loop counter */ - - /* Search for a table and column that appears on one side or the - ** other of the == operator in every subterm. That table and column - ** will be recorded in iCursor and iColumn. There might not be any - ** such table and column. Set okToChngToIN if an appropriate table - ** and column is found but leave okToChngToIN false if not found. - */ - for ( j = 0; j < 2 && 0 == okToChngToIN; j++ ) - { - //pOrTerm = pOrWc.a; - for ( i = pOrWc.nTerm - 1; i >= 0; i-- )//, pOrTerm++) - { - pOrTerm = pOrWc.a[pOrWc.nTerm - 1 - i]; - Debug.Assert( pOrTerm.eOperator == WO_EQ ); - pOrTerm.wtFlags = (u8)( pOrTerm.wtFlags & ~TERM_OR_OK ); - if ( pOrTerm.leftCursor == iCursor ) - { - /* This is the 2-bit case and we are on the second iteration and - ** current term is from the first iteration. So skip this term. */ - Debug.Assert( j == 1 ); - continue; - } - if ( ( chngToIN & getMask( pMaskSet, pOrTerm.leftCursor ) ) == 0 ) - { - /* This term must be of the form t1.a==t2.b where t2 is in the - ** chngToIN set but t1 is not. This term will be either preceeded - ** or follwed by an inverted copy (t2.b==t1.a). Skip this term - ** and use its inversion. */ - testcase( pOrTerm.wtFlags & TERM_COPIED ); - testcase( pOrTerm.wtFlags & TERM_VIRTUAL ); - Debug.Assert( ( pOrTerm.wtFlags & ( TERM_COPIED | TERM_VIRTUAL ) ) != 0 ); - continue; - } - iColumn = pOrTerm.u.leftColumn; - iCursor = pOrTerm.leftCursor; - break; - } - if ( i < 0 ) - { - /* No candidate table+column was found. This can only occur - ** on the second iteration */ - Debug.Assert( j == 1 ); - Debug.Assert( ( chngToIN & ( chngToIN - 1 ) ) == 0 ); - Debug.Assert( chngToIN == getMask( pMaskSet, iCursor ) ); - break; - } - testcase( j == 1 ); + /* + ** chngToIN holds a set of tables that *might* satisfy case 1. But + ** we have to do some additional checking to see if case 1 really + ** is satisfied. + ** + ** chngToIN will hold either 0, 1, or 2 bits. The 0-bit case means + ** that there is no possibility of transforming the OR clause into an + ** IN operator because one or more terms in the OR clause contain + ** something other than == on a column in the single table. The 1-bit + ** case means that every term of the OR clause is of the form + ** "table.column=expr" for some single table. The one bit that is set + ** will correspond to the common table. We still need to check to make + ** sure the same column is used on all terms. The 2-bit case is when + ** the all terms are of the form "table1.column=table2.column". It + ** might be possible to form an IN operator with either table1.column + ** or table2.column as the LHS if either is common to every term of + ** the OR clause. + ** + ** Note that terms of the form "table.column1=table.column2" (the + ** same table on both sizes of the ==) cannot be optimized. + */ + if (chngToIN != 0) { + int okToChngToIN = 0; /* True if the conversion to IN is valid */ + int iColumn = -1; /* Column index on lhs of IN operator */ + int iCursor = -1; /* Table cursor common to all terms */ + int j = 0; /* Loop counter */ + + /* Search for a table and column that appears on one side or the + ** other of the == operator in every subterm. That table and column + ** will be recorded in iCursor and iColumn. There might not be any + ** such table and column. Set okToChngToIN if an appropriate table + ** and column is found but leave okToChngToIN false if not found. + */ + for (j = 0; j < 2 && 0 == okToChngToIN; j++) { + //pOrTerm = pOrWc.a; + for (i = pOrWc.nTerm - 1; i >= 0; i--)//, pOrTerm++) + { + pOrTerm = pOrWc.a[pOrWc.nTerm - 1 - i]; + Debug.Assert(pOrTerm.eOperator == WO_EQ); + pOrTerm.wtFlags = (u8)(pOrTerm.wtFlags & ~TERM_OR_OK); + if (pOrTerm.leftCursor == iCursor) { + /* This is the 2-bit case and we are on the second iteration and + ** current term is from the first iteration. So skip this term. */ + Debug.Assert(j == 1); + continue; + } + if ((chngToIN & getMask(pMaskSet, pOrTerm.leftCursor)) == 0) { + /* This term must be of the form t1.a==t2.b where t2 is in the + ** chngToIN set but t1 is not. This term will be either preceeded + ** or follwed by an inverted copy (t2.b==t1.a). Skip this term + ** and use its inversion. */ + testcase(pOrTerm.wtFlags & TERM_COPIED); + testcase(pOrTerm.wtFlags & TERM_VIRTUAL); + Debug.Assert((pOrTerm.wtFlags & (TERM_COPIED | TERM_VIRTUAL)) != 0); + continue; + } + iColumn = pOrTerm.u.leftColumn; + iCursor = pOrTerm.leftCursor; + break; + } + if (i < 0) { + /* No candidate table+column was found. This can only occur + ** on the second iteration */ + Debug.Assert(j == 1); + Debug.Assert((chngToIN & (chngToIN - 1)) == 0); + Debug.Assert(chngToIN == getMask(pMaskSet, iCursor)); + break; + } + testcase(j == 1); + + /* We have found a candidate table and column. Check to see if that + ** table and column is common to every term in the OR clause */ + okToChngToIN = 1; + for (; i >= 0 && okToChngToIN != 0; i--)//, pOrTerm++) + { + pOrTerm = pOrWc.a[pOrWc.nTerm - 1 - i]; + Debug.Assert(pOrTerm.eOperator == WO_EQ); + if (pOrTerm.leftCursor != iCursor) { + pOrTerm.wtFlags = (u8)(pOrTerm.wtFlags & ~TERM_OR_OK); + } else if (pOrTerm.u.leftColumn != iColumn) { + okToChngToIN = 0; + } else { + int affLeft, affRight; + /* If the right-hand side is also a column, then the affinities + ** of both right and left sides must be such that no type + ** conversions are required on the right. (Ticket #2249) + */ + affRight = sqlite3ExprAffinity(pOrTerm.pExpr.pRight); + affLeft = sqlite3ExprAffinity(pOrTerm.pExpr.pLeft); + if (affRight != 0 && affRight != affLeft) { + okToChngToIN = 0; + } else { + pOrTerm.wtFlags |= TERM_OR_OK; + } + } + } + } - /* We have found a candidate table and column. Check to see if that - ** table and column is common to every term in the OR clause */ - okToChngToIN = 1; - for ( ; i >= 0 && okToChngToIN != 0; i-- )//, pOrTerm++) - { - pOrTerm = pOrWc.a[pOrWc.nTerm - 1 - i]; - Debug.Assert( pOrTerm.eOperator == WO_EQ ); - if ( pOrTerm.leftCursor != iCursor ) - { - pOrTerm.wtFlags = (u8)( pOrTerm.wtFlags & ~TERM_OR_OK ); - } - else if ( pOrTerm.u.leftColumn != iColumn ) - { - okToChngToIN = 0; - } - else - { - int affLeft, affRight; - /* If the right-hand side is also a column, then the affinities - ** of both right and left sides must be such that no type - ** conversions are required on the right. (Ticket #2249) - */ - affRight = sqlite3ExprAffinity( pOrTerm.pExpr.pRight ); - affLeft = sqlite3ExprAffinity( pOrTerm.pExpr.pLeft ); - if ( affRight != 0 && affRight != affLeft ) - { - okToChngToIN = 0; - } - else - { - pOrTerm.wtFlags |= TERM_OR_OK; - } + /* At this point, okToChngToIN is true if original pTerm satisfies + ** case 1. In that case, construct a new virtual term that is + ** pTerm converted into an IN operator. + ** + ** EV: R-00211-15100 + */ + if (okToChngToIN != 0) { + Expr pDup; /* A transient duplicate expression */ + ExprList pList = null; /* The RHS of the IN operator */ + Expr pLeft = null; /* The LHS of the IN operator */ + Expr pNew; /* The complete IN operator */ + + for (i = pOrWc.nTerm - 1; i >= 0; i--)//, pOrTerm++) + { + pOrTerm = pOrWc.a[pOrWc.nTerm - 1 - i]; + if ((pOrTerm.wtFlags & TERM_OR_OK) == 0) + continue; + Debug.Assert(pOrTerm.eOperator == WO_EQ); + Debug.Assert(pOrTerm.leftCursor == iCursor); + Debug.Assert(pOrTerm.u.leftColumn == iColumn); + pDup = sqlite3ExprDup(db, pOrTerm.pExpr.pRight, 0); + pList = sqlite3ExprListAppend(pWC.pParse, pList, pDup); + pLeft = pOrTerm.pExpr.pLeft; + } + Debug.Assert(pLeft != null); + pDup = sqlite3ExprDup(db, pLeft, 0); + pNew = sqlite3PExpr(pParse, TK_IN, pDup, null, null); + if (pNew != null) { + int idxNew; + transferJoinMarkings(pNew, pExpr); + Debug.Assert(!ExprHasProperty(pNew, EP_xIsSelect)); + pNew.x.pList = pList; + idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL | TERM_DYNAMIC); + testcase(idxNew == 0); + exprAnalyze(pSrc, pWC, idxNew); + pTerm = pWC.a[idxTerm]; + pWC.a[idxNew].iParent = idxTerm; + pTerm.nChild = 1; + } else { + sqlite3ExprListDelete(db, ref pList); + } + pTerm.eOperator = WO_NOOP; /* case 1 trumps case 2 */ + } } - } } - - /* At this point, okToChngToIN is true if original pTerm satisfies - ** case 1. In that case, construct a new virtual term that is - ** pTerm converted into an IN operator. - ** - ** EV: R-00211-15100 - */ - if ( okToChngToIN != 0 ) - { - Expr pDup; /* A transient duplicate expression */ - ExprList pList = null; /* The RHS of the IN operator */ - Expr pLeft = null; /* The LHS of the IN operator */ - Expr pNew; /* The complete IN operator */ - - for ( i = pOrWc.nTerm - 1; i >= 0; i-- )//, pOrTerm++) - { - pOrTerm = pOrWc.a[pOrWc.nTerm - 1 - i]; - if ( ( pOrTerm.wtFlags & TERM_OR_OK ) == 0 ) - continue; - Debug.Assert( pOrTerm.eOperator == WO_EQ ); - Debug.Assert( pOrTerm.leftCursor == iCursor ); - Debug.Assert( pOrTerm.u.leftColumn == iColumn ); - pDup = sqlite3ExprDup( db, pOrTerm.pExpr.pRight, 0 ); - pList = sqlite3ExprListAppend( pWC.pParse, pList, pDup ); - pLeft = pOrTerm.pExpr.pLeft; - } - Debug.Assert( pLeft != null ); - pDup = sqlite3ExprDup( db, pLeft, 0 ); - pNew = sqlite3PExpr( pParse, TK_IN, pDup, null, null ); - if ( pNew != null ) - { - int idxNew; - transferJoinMarkings( pNew, pExpr ); - Debug.Assert( !ExprHasProperty( pNew, EP_xIsSelect ) ); - pNew.x.pList = pList; - idxNew = whereClauseInsert( pWC, pNew, TERM_VIRTUAL | TERM_DYNAMIC ); - testcase( idxNew == 0 ); - exprAnalyze( pSrc, pWC, idxNew ); - pTerm = pWC.a[idxTerm]; - pWC.a[idxNew].iParent = idxTerm; - pTerm.nChild = 1; - } - else - { - sqlite3ExprListDelete( db, ref pList ); - } - pTerm.eOperator = WO_NOOP; /* case 1 trumps case 2 */ - } - } - } #endif //* !SQLITE_OMIT_OR_OPTIMIZATION && !SQLITE_OMIT_SUBQUERY */ - /* -** The input to this routine is an WhereTerm structure with only the -** "pExpr" field filled in. The job of this routine is to analyze the -** subexpression and populate all the other fields of the WhereTerm -** structure. -** -** If the expression is of the form " X" it gets commuted -** to the standard form of "X ". -** -** If the expression is of the form "X Y" where both X and Y are -** columns, then the original expression is unchanged and a new virtual -** term of the form "Y X" is added to the WHERE clause and -** analyzed separately. The original term is marked with TERM_COPIED -** and the new term is marked with TERM_DYNAMIC (because it's pExpr -** needs to be freed with the WhereClause) and TERM_VIRTUAL (because it -** is a commuted copy of a prior term.) The original term has nChild=1 -** and the copy has idxParent set to the index of the original term. -*/ - static void exprAnalyze( - SrcList pSrc, /* the FROM clause */ - WhereClause pWC, /* the WHERE clause */ - int idxTerm /* Index of the term to be analyzed */ - ) - { - WhereTerm pTerm; /* The term to be analyzed */ - WhereMaskSet pMaskSet; /* Set of table index masks */ - Expr pExpr; /* The expression to be analyzed */ - Bitmask prereqLeft; /* Prerequesites of the pExpr.pLeft */ - Bitmask prereqAll; /* Prerequesites of pExpr */ - Bitmask extraRight = 0; /* Extra dependencies on LEFT JOIN */ - Expr pStr1 = null; /* RHS of LIKE/GLOB operator */ - bool isComplete = false; /* RHS of LIKE/GLOB ends with wildcard */ - bool noCase = false; /* LIKE/GLOB distinguishes case */ - int op; /* Top-level operator. pExpr.op */ - Parse pParse = pWC.pParse; /* Parsing context */ - sqlite3 db = pParse.db; /* Data_base connection */ - - //if ( db.mallocFailed != 0 ) - //{ - // return; - //} - pTerm = pWC.a[idxTerm]; - pMaskSet = pWC.pMaskSet; - pExpr = pTerm.pExpr; - prereqLeft = exprTableUsage( pMaskSet, pExpr.pLeft ); - op = pExpr.op; - if ( op == TK_IN ) - { - Debug.Assert( pExpr.pRight == null ); - if ( ExprHasProperty( pExpr, EP_xIsSelect ) ) - { - pTerm.prereqRight = exprSelectTableUsage( pMaskSet, pExpr.x.pSelect ); - } - else - { - pTerm.prereqRight = exprListTableUsage( pMaskSet, pExpr.x.pList ); - } - } - else if ( op == TK_ISNULL ) - { - pTerm.prereqRight = 0; - } - else - { - pTerm.prereqRight = exprTableUsage( pMaskSet, pExpr.pRight ); - } - prereqAll = exprTableUsage( pMaskSet, pExpr ); - if ( ExprHasProperty( pExpr, EP_FromJoin ) ) - { - Bitmask x = getMask( pMaskSet, pExpr.iRightJoinTable ); - prereqAll |= x; - extraRight = x - 1; /* ON clause terms may not be used with an index -** on left table of a LEFT JOIN. Ticket #3015 */ - } - pTerm.prereqAll = prereqAll; - pTerm.leftCursor = -1; - pTerm.iParent = -1; - pTerm.eOperator = 0; - if ( allowedOp( op ) && ( pTerm.prereqRight & prereqLeft ) == 0 ) - { - Expr pLeft = pExpr.pLeft; - Expr pRight = pExpr.pRight; - if ( pLeft.op == TK_COLUMN ) - { - pTerm.leftCursor = pLeft.iTable; - pTerm.u.leftColumn = pLeft.iColumn; - pTerm.eOperator = operatorMask( op ); - } - if ( pRight != null && pRight.op == TK_COLUMN ) - { - WhereTerm pNew; - Expr pDup; - if ( pTerm.leftCursor >= 0 ) - { - int idxNew; - pDup = sqlite3ExprDup( db, pExpr, 0 ); + /* + ** The input to this routine is an WhereTerm structure with only the + ** "pExpr" field filled in. The job of this routine is to analyze the + ** subexpression and populate all the other fields of the WhereTerm + ** structure. + ** + ** If the expression is of the form " X" it gets commuted + ** to the standard form of "X ". + ** + ** If the expression is of the form "X Y" where both X and Y are + ** columns, then the original expression is unchanged and a new virtual + ** term of the form "Y X" is added to the WHERE clause and + ** analyzed separately. The original term is marked with TERM_COPIED + ** and the new term is marked with TERM_DYNAMIC (because it's pExpr + ** needs to be freed with the WhereClause) and TERM_VIRTUAL (because it + ** is a commuted copy of a prior term.) The original term has nChild=1 + ** and the copy has idxParent set to the index of the original term. + */ + static void exprAnalyze( + SrcList pSrc, /* the FROM clause */ + WhereClause pWC, /* the WHERE clause */ + int idxTerm /* Index of the term to be analyzed */ + ) { + WhereTerm pTerm; /* The term to be analyzed */ + WhereMaskSet pMaskSet; /* Set of table index masks */ + Expr pExpr; /* The expression to be analyzed */ + Bitmask prereqLeft; /* Prerequesites of the pExpr.pLeft */ + Bitmask prereqAll; /* Prerequesites of pExpr */ + Bitmask extraRight = 0; /* Extra dependencies on LEFT JOIN */ + Expr pStr1 = null; /* RHS of LIKE/GLOB operator */ + bool isComplete = false; /* RHS of LIKE/GLOB ends with wildcard */ + bool noCase = false; /* LIKE/GLOB distinguishes case */ + int op; /* Top-level operator. pExpr.op */ + Parse pParse = pWC.pParse; /* Parsing context */ + sqlite3 db = pParse.db; /* Data_base connection */ + //if ( db.mallocFailed != 0 ) //{ - // sqlite3ExprDelete( db, ref pDup ); // return; //} - idxNew = whereClauseInsert( pWC, pDup, TERM_VIRTUAL | TERM_DYNAMIC ); - if ( idxNew == 0 ) - return; - pNew = pWC.a[idxNew]; - pNew.iParent = idxTerm; pTerm = pWC.a[idxTerm]; - pTerm.nChild = 1; - pTerm.wtFlags |= TERM_COPIED; - } - else - { - pDup = pExpr; - pNew = pTerm; - } - exprCommute( pParse, pDup ); - pLeft = pDup.pLeft; - pNew.leftCursor = pLeft.iTable; - pNew.u.leftColumn = pLeft.iColumn; - testcase( ( prereqLeft | extraRight ) != prereqLeft ); - pNew.prereqRight = prereqLeft | extraRight; - pNew.prereqAll = prereqAll; - pNew.eOperator = operatorMask( pDup.op ); - } - } + pMaskSet = pWC.pMaskSet; + pExpr = pTerm.pExpr; + prereqLeft = exprTableUsage(pMaskSet, pExpr.pLeft); + op = pExpr.op; + if (op == TK_IN) { + Debug.Assert(pExpr.pRight == null); + if (ExprHasProperty(pExpr, EP_xIsSelect)) { + pTerm.prereqRight = exprSelectTableUsage(pMaskSet, pExpr.x.pSelect); + } else { + pTerm.prereqRight = exprListTableUsage(pMaskSet, pExpr.x.pList); + } + } else if (op == TK_ISNULL) { + pTerm.prereqRight = 0; + } else { + pTerm.prereqRight = exprTableUsage(pMaskSet, pExpr.pRight); + } + prereqAll = exprTableUsage(pMaskSet, pExpr); + if (ExprHasProperty(pExpr, EP_FromJoin)) { + Bitmask x = getMask(pMaskSet, pExpr.iRightJoinTable); + prereqAll |= x; + extraRight = x - 1; /* ON clause terms may not be used with an index +** on left table of a LEFT JOIN. Ticket #3015 */ + } + pTerm.prereqAll = prereqAll; + pTerm.leftCursor = -1; + pTerm.iParent = -1; + pTerm.eOperator = 0; + if (allowedOp(op) && (pTerm.prereqRight & prereqLeft) == 0) { + Expr pLeft = pExpr.pLeft; + Expr pRight = pExpr.pRight; + if (pLeft.op == TK_COLUMN) { + pTerm.leftCursor = pLeft.iTable; + pTerm.u.leftColumn = pLeft.iColumn; + pTerm.eOperator = operatorMask(op); + } + if (pRight != null && pRight.op == TK_COLUMN) { + WhereTerm pNew; + Expr pDup; + if (pTerm.leftCursor >= 0) { + int idxNew; + pDup = sqlite3ExprDup(db, pExpr, 0); + //if ( db.mallocFailed != 0 ) + //{ + // sqlite3ExprDelete( db, ref pDup ); + // return; + //} + idxNew = whereClauseInsert(pWC, pDup, TERM_VIRTUAL | TERM_DYNAMIC); + if (idxNew == 0) + return; + pNew = pWC.a[idxNew]; + pNew.iParent = idxTerm; + pTerm = pWC.a[idxTerm]; + pTerm.nChild = 1; + pTerm.wtFlags |= TERM_COPIED; + } else { + pDup = pExpr; + pNew = pTerm; + } + exprCommute(pParse, pDup); + pLeft = pDup.pLeft; + pNew.leftCursor = pLeft.iTable; + pNew.u.leftColumn = pLeft.iColumn; + testcase((prereqLeft | extraRight) != prereqLeft); + pNew.prereqRight = prereqLeft | extraRight; + pNew.prereqAll = prereqAll; + pNew.eOperator = operatorMask(pDup.op); + } + } -#if !SQLITE_OMIT_BETWEEN_OPTIMIZATION - /* If a term is the BETWEEN operator, create two new virtual terms -** that define the range that the BETWEEN implements. For example: -** -** a BETWEEN b AND c -** -** is converted into: -** -** (a BETWEEN b AND c) AND (a>=b) AND (a<=c) -** -** The two new terms are added onto the end of the WhereClause object. -** The new terms are "dynamic" and are children of the original BETWEEN -** term. That means that if the BETWEEN term is coded, the children are -** skipped. Or, if the children are satisfied by an index, the original -** BETWEEN term is skipped. -*/ - else if ( pExpr.op == TK_BETWEEN && pWC.op == TK_AND ) - { - ExprList pList = pExpr.x.pList; - int i; - u8[] ops = new u8[] { TK_GE, TK_LE }; - Debug.Assert( pList != null ); - Debug.Assert( pList.nExpr == 2 ); - for ( i = 0; i < 2; i++ ) - { - Expr pNewExpr; - int idxNew; - pNewExpr = sqlite3PExpr( pParse, ops[i], - sqlite3ExprDup( db, pExpr.pLeft, 0 ), - sqlite3ExprDup( db, pList.a[i].pExpr, 0 ), null ); - idxNew = whereClauseInsert( pWC, pNewExpr, TERM_VIRTUAL | TERM_DYNAMIC ); - testcase( idxNew == 0 ); - exprAnalyze( pSrc, pWC, idxNew ); - pTerm = pWC.a[idxTerm]; - pWC.a[idxNew].iParent = idxTerm; - } - pTerm.nChild = 2; - } +#if !SQLITE_OMIT_BETWEEN_OPTIMIZATION + /* If a term is the BETWEEN operator, create two new virtual terms + ** that define the range that the BETWEEN implements. For example: + ** + ** a BETWEEN b AND c + ** + ** is converted into: + ** + ** (a BETWEEN b AND c) AND (a>=b) AND (a<=c) + ** + ** The two new terms are added onto the end of the WhereClause object. + ** The new terms are "dynamic" and are children of the original BETWEEN + ** term. That means that if the BETWEEN term is coded, the children are + ** skipped. Or, if the children are satisfied by an index, the original + ** BETWEEN term is skipped. + */ + else if (pExpr.op == TK_BETWEEN && pWC.op == TK_AND) { + ExprList pList = pExpr.x.pList; + int i; + u8[] ops = new u8[] { TK_GE, TK_LE }; + Debug.Assert(pList != null); + Debug.Assert(pList.nExpr == 2); + for (i = 0; i < 2; i++) { + Expr pNewExpr; + int idxNew; + pNewExpr = sqlite3PExpr(pParse, ops[i], + sqlite3ExprDup(db, pExpr.pLeft, 0), + sqlite3ExprDup(db, pList.a[i].pExpr, 0), null); + idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL | TERM_DYNAMIC); + testcase(idxNew == 0); + exprAnalyze(pSrc, pWC, idxNew); + pTerm = pWC.a[idxTerm]; + pWC.a[idxNew].iParent = idxTerm; + } + pTerm.nChild = 2; + } #endif //* SQLITE_OMIT_BETWEEN_OPTIMIZATION */ -#if !(SQLITE_OMIT_OR_OPTIMIZATION) && !(SQLITE_OMIT_SUBQUERY) - /* Analyze a term that is composed of two or more subterms connected by -** an OR operator. -*/ - else if ( pExpr.op == TK_OR ) - { - Debug.Assert( pWC.op == TK_AND ); - exprAnalyzeOrTerm( pSrc, pWC, idxTerm ); - pTerm = pWC.a[idxTerm]; - } +#if !(SQLITE_OMIT_OR_OPTIMIZATION) && !(SQLITE_OMIT_SUBQUERY) + /* Analyze a term that is composed of two or more subterms connected by + ** an OR operator. + */ + else if (pExpr.op == TK_OR) { + Debug.Assert(pWC.op == TK_AND); + exprAnalyzeOrTerm(pSrc, pWC, idxTerm); + pTerm = pWC.a[idxTerm]; + } #endif //* SQLITE_OMIT_OR_OPTIMIZATION */ -#if !SQLITE_OMIT_LIKE_OPTIMIZATION - /* Add constraints to reduce the search space on a LIKE or GLOB -** operator. -** -** A like pattern of the form "x LIKE 'abc%'" is changed into constraints -** -** x>='abc' AND x<'abd' AND x LIKE 'abc%' -** -** The last character of the prefix "abc" is incremented to form the -** termination condition "abd". -*/ - if ( pWC.op == TK_AND - && isLikeOrGlob( pParse, pExpr, ref pStr1, ref isComplete, ref noCase ) != 0 - ) - { - Expr pLeft; /* LHS of LIKE/GLOB operator */ - Expr pStr2; /* Copy of pStr1 - RHS of LIKE/GLOB operator */ - Expr pNewExpr1; - Expr pNewExpr2; - int idxNew1; - int idxNew2; - CollSeq pColl; /* Collating sequence to use */ - - pLeft = pExpr.x.pList.a[1].pExpr; - pStr2 = sqlite3ExprDup( db, pStr1, 0 ); - ////if ( 0 == db.mallocFailed ) - { - int c, pC; /* Last character before the first wildcard */ - pC = pStr2.u.zToken[sqlite3Strlen30( pStr2.u.zToken ) - 1]; - c = pC; - if ( noCase ) - { - /* The point is to increment the last character before the first - ** wildcard. But if we increment '@', that will push it into the - ** alphabetic range where case conversions will mess up the - ** inequality. To avoid this, make sure to also run the full - ** LIKE on all candidate expressions by clearing the isComplete flag - */ - if ( c == 'A' - 1 ) - isComplete = false; /* EV: R-64339-08207 */ - c = sqlite3UpperToLower[c]; - } - pStr2.u.zToken = pStr2.u.zToken.Substring( 0, sqlite3Strlen30( pStr2.u.zToken ) - 1 ) + (char)( c + 1 );// pC = c + 1; - } - pColl = sqlite3FindCollSeq( db, SQLITE_UTF8, noCase ? "NOCASE" : "BINARY", 0 ); - pNewExpr1 = sqlite3PExpr( pParse, TK_GE, - sqlite3ExprSetColl( sqlite3ExprDup( db, pLeft, 0 ), pColl ), - pStr1, 0 ); - idxNew1 = whereClauseInsert( pWC, pNewExpr1, TERM_VIRTUAL | TERM_DYNAMIC ); - testcase( idxNew1 == 0 ); - exprAnalyze( pSrc, pWC, idxNew1 ); - pNewExpr2 = sqlite3PExpr( pParse, TK_LT, - sqlite3ExprSetColl( sqlite3ExprDup( db, pLeft, 0 ), pColl ), - pStr2, null ); - idxNew2 = whereClauseInsert( pWC, pNewExpr2, TERM_VIRTUAL | TERM_DYNAMIC ); - testcase( idxNew2 == 0 ); - exprAnalyze( pSrc, pWC, idxNew2 ); - pTerm = pWC.a[idxTerm]; - if ( isComplete ) - { - pWC.a[idxNew1].iParent = idxTerm; - pWC.a[idxNew2].iParent = idxTerm; - pTerm.nChild = 2; - } - } +#if !SQLITE_OMIT_LIKE_OPTIMIZATION + /* Add constraints to reduce the search space on a LIKE or GLOB + ** operator. + ** + ** A like pattern of the form "x LIKE 'abc%'" is changed into constraints + ** + ** x>='abc' AND x<'abd' AND x LIKE 'abc%' + ** + ** The last character of the prefix "abc" is incremented to form the + ** termination condition "abd". + */ + if (pWC.op == TK_AND + && isLikeOrGlob(pParse, pExpr, ref pStr1, ref isComplete, ref noCase) != 0 + ) { + Expr pLeft; /* LHS of LIKE/GLOB operator */ + Expr pStr2; /* Copy of pStr1 - RHS of LIKE/GLOB operator */ + Expr pNewExpr1; + Expr pNewExpr2; + int idxNew1; + int idxNew2; + CollSeq pColl; /* Collating sequence to use */ + + pLeft = pExpr.x.pList.a[1].pExpr; + pStr2 = sqlite3ExprDup(db, pStr1, 0); + ////if ( 0 == db.mallocFailed ) + { + int c, pC; /* Last character before the first wildcard */ + pC = pStr2.u.zToken[sqlite3Strlen30(pStr2.u.zToken) - 1]; + c = pC; + if (noCase) { + /* The point is to increment the last character before the first + ** wildcard. But if we increment '@', that will push it into the + ** alphabetic range where case conversions will mess up the + ** inequality. To avoid this, make sure to also run the full + ** LIKE on all candidate expressions by clearing the isComplete flag + */ + if (c == 'A' - 1) + isComplete = false; /* EV: R-64339-08207 */ + c = sqlite3UpperToLower[c]; + } + pStr2.u.zToken = pStr2.u.zToken.Substring(0, sqlite3Strlen30(pStr2.u.zToken) - 1) + (char)(c + 1);// pC = c + 1; + } + pColl = sqlite3FindCollSeq(db, SQLITE_UTF8, noCase ? "NOCASE" : "BINARY", 0); + pNewExpr1 = sqlite3PExpr(pParse, TK_GE, + sqlite3ExprSetColl(sqlite3ExprDup(db, pLeft, 0), pColl), + pStr1, 0); + idxNew1 = whereClauseInsert(pWC, pNewExpr1, TERM_VIRTUAL | TERM_DYNAMIC); + testcase(idxNew1 == 0); + exprAnalyze(pSrc, pWC, idxNew1); + pNewExpr2 = sqlite3PExpr(pParse, TK_LT, + sqlite3ExprSetColl(sqlite3ExprDup(db, pLeft, 0), pColl), + pStr2, null); + idxNew2 = whereClauseInsert(pWC, pNewExpr2, TERM_VIRTUAL | TERM_DYNAMIC); + testcase(idxNew2 == 0); + exprAnalyze(pSrc, pWC, idxNew2); + pTerm = pWC.a[idxTerm]; + if (isComplete) { + pWC.a[idxNew1].iParent = idxTerm; + pWC.a[idxNew2].iParent = idxTerm; + pTerm.nChild = 2; + } + } #endif //* SQLITE_OMIT_LIKE_OPTIMIZATION */ -#if !SQLITE_OMIT_VIRTUALTABLE -/* Add a WO_MATCH auxiliary term to the constraint set if the -** current expression is of the form: column MATCH expr. -** This information is used by the xBestIndex methods of -** virtual tables. The native query optimizer does not attempt -** to do anything with MATCH functions. -*/ - if ( isMatchOfColumn( pExpr ) != 0 ) - { - int idxNew; - Expr pRight, pLeft; - WhereTerm pNewTerm; - Bitmask prereqColumn, prereqExpr; - - pRight = pExpr.x.pList.a[0].pExpr; - pLeft = pExpr.x.pList.a[1].pExpr; - prereqExpr = exprTableUsage( pMaskSet, pRight ); - prereqColumn = exprTableUsage( pMaskSet, pLeft ); - if ( ( prereqExpr & prereqColumn ) == 0 ) - { - Expr pNewExpr; - pNewExpr = sqlite3PExpr( pParse, TK_MATCH, - null, sqlite3ExprDup( db, pRight, 0 ), null ); - idxNew = whereClauseInsert( pWC, pNewExpr, TERM_VIRTUAL | TERM_DYNAMIC ); - testcase( idxNew == 0 ); - pNewTerm = pWC.a[idxNew]; - pNewTerm.prereqRight = prereqExpr; - pNewTerm.leftCursor = pLeft.iTable; - pNewTerm.u.leftColumn = pLeft.iColumn; - pNewTerm.eOperator = WO_MATCH; - pNewTerm.iParent = idxTerm; - pTerm = pWC.a[idxTerm]; - pTerm.nChild = 1; - pTerm.wtFlags |= TERM_COPIED; - pNewTerm.prereqAll = pTerm.prereqAll; - } -} +#if !SQLITE_OMIT_VIRTUALTABLE + /* Add a WO_MATCH auxiliary term to the constraint set if the + ** current expression is of the form: column MATCH expr. + ** This information is used by the xBestIndex methods of + ** virtual tables. The native query optimizer does not attempt + ** to do anything with MATCH functions. + */ + if (isMatchOfColumn(pExpr) != 0) { + int idxNew; + Expr pRight, pLeft; + WhereTerm pNewTerm; + Bitmask prereqColumn, prereqExpr; + + pRight = pExpr.x.pList.a[0].pExpr; + pLeft = pExpr.x.pList.a[1].pExpr; + prereqExpr = exprTableUsage(pMaskSet, pRight); + prereqColumn = exprTableUsage(pMaskSet, pLeft); + if ((prereqExpr & prereqColumn) == 0) { + Expr pNewExpr; + pNewExpr = sqlite3PExpr(pParse, TK_MATCH, + null, sqlite3ExprDup(db, pRight, 0), null); + idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL | TERM_DYNAMIC); + testcase(idxNew == 0); + pNewTerm = pWC.a[idxNew]; + pNewTerm.prereqRight = prereqExpr; + pNewTerm.leftCursor = pLeft.iTable; + pNewTerm.u.leftColumn = pLeft.iColumn; + pNewTerm.eOperator = WO_MATCH; + pNewTerm.iParent = idxTerm; + pTerm = pWC.a[idxTerm]; + pTerm.nChild = 1; + pTerm.wtFlags |= TERM_COPIED; + pNewTerm.prereqAll = pTerm.prereqAll; + } + } #endif //* SQLITE_OMIT_VIRTUALTABLE */ #if SQLITE_ENABLE_STAT2 @@ -1622,265 +1494,234 @@ int idxTerm /* Index of the term to be analyzed */ } #endif //* SQLITE_ENABLE_STAT2 */ - /* Prevent ON clause terms of a LEFT JOIN from being used to drive -** an index for tables to the left of the join. -*/ - pTerm.prereqRight |= extraRight; - } - - /* - ** Return TRUE if any of the expressions in pList.a[iFirst...] contain - ** a reference to any table other than the iBase table. - */ - static bool referencesOtherTables( - ExprList pList, /* Search expressions in ths list */ - WhereMaskSet pMaskSet, /* Mapping from tables to bitmaps */ - int iFirst, /* Be searching with the iFirst-th expression */ - int iBase /* Ignore references to this table */ - ) - { - Bitmask allowed = ~getMask( pMaskSet, iBase ); - while ( iFirst < pList.nExpr ) - { - if ( ( exprTableUsage( pMaskSet, pList.a[iFirst++].pExpr ) & allowed ) != 0 ) - { - return true; - } - } - return false; - } - - - /* - ** This routine decides if pIdx can be used to satisfy the ORDER BY - ** clause. If it can, it returns 1. If pIdx cannot satisfy the - ** ORDER BY clause, this routine returns 0. - ** - ** pOrderBy is an ORDER BY clause from a SELECT statement. pTab is the - ** left-most table in the FROM clause of that same SELECT statement and - ** the table has a cursor number of "_base". pIdx is an index on pTab. - ** - ** nEqCol is the number of columns of pIdx that are used as equality - ** constraints. Any of these columns may be missing from the ORDER BY - ** clause and the match can still be a success. - ** - ** All terms of the ORDER BY that match against the index must be either - ** ASC or DESC. (Terms of the ORDER BY clause past the end of a UNIQUE - ** index do not need to satisfy this constraint.) The pbRev value is - ** set to 1 if the ORDER BY clause is all DESC and it is set to 0 if - ** the ORDER BY clause is all ASC. - */ - static bool isSortingIndex( - Parse pParse, /* Parsing context */ - WhereMaskSet pMaskSet, /* Mapping from table cursor numbers to bitmaps */ - Index pIdx, /* The index we are testing */ - int _base, /* Cursor number for the table to be sorted */ - ExprList pOrderBy, /* The ORDER BY clause */ - int nEqCol, /* Number of index columns with == constraints */ - int wsFlags, /* Index usages flags */ - ref int pbRev /* Set to 1 if ORDER BY is DESC */ - ) - { - int i, j; /* Loop counters */ - int sortOrder = 0; /* XOR of index and ORDER BY sort direction */ - int nTerm; /* Number of ORDER BY terms */ - ExprList_item pTerm; /* A term of the ORDER BY clause */ - sqlite3 db = pParse.db; - - Debug.Assert( pOrderBy != null ); - nTerm = pOrderBy.nExpr; - Debug.Assert( nTerm > 0 ); - - /* Argument pIdx must either point to a 'real' named index structure, - ** or an index structure allocated on the stack by bestBtreeIndex() to - ** represent the rowid index that is part of every table. */ - Debug.Assert( !String.IsNullOrEmpty( pIdx.zName ) || ( pIdx.nColumn == 1 && pIdx.aiColumn[0] == -1 ) ); - - /* Match terms of the ORDER BY clause against columns of - ** the index. - ** - ** Note that indices have pIdx.nColumn regular columns plus - ** one additional column containing the rowid. The rowid column - ** of the index is also allowed to match against the ORDER BY - ** clause. + /* Prevent ON clause terms of a LEFT JOIN from being used to drive + ** an index for tables to the left of the join. */ - for ( i = j = 0; j < nTerm && i <= pIdx.nColumn; i++ ) - { - pTerm = pOrderBy.a[j]; - Expr pExpr; /* The expression of the ORDER BY pTerm */ - CollSeq pColl; /* The collating sequence of pExpr */ - int termSortOrder; /* Sort order for this term */ - int iColumn; /* The i-th column of the index. -1 for rowid */ - int iSortOrder; /* 1 for DESC, 0 for ASC on the i-th index term */ - string zColl; /* Name of the collating sequence for i-th index term */ - - pExpr = pTerm.pExpr; - if ( pExpr.op != TK_COLUMN || pExpr.iTable != _base ) - { - /* Can not use an index sort on anything that is not a column in the - ** left-most table of the FROM clause */ - break; + pTerm.prereqRight |= extraRight; } - pColl = sqlite3ExprCollSeq( pParse, pExpr ); - if ( null == pColl ) - { - pColl = db.pDfltColl; - } - if ( !String.IsNullOrEmpty( pIdx.zName ) && i < pIdx.nColumn ) - { - iColumn = pIdx.aiColumn[i]; - if ( iColumn == pIdx.pTable.iPKey ) - { - iColumn = -1; - } - iSortOrder = pIdx.aSortOrder[i]; - zColl = pIdx.azColl[i]; - } - else - { - iColumn = -1; - iSortOrder = 0; - zColl = pColl.zName; + + /* + ** Return TRUE if any of the expressions in pList.a[iFirst...] contain + ** a reference to any table other than the iBase table. + */ + static bool referencesOtherTables( + ExprList pList, /* Search expressions in ths list */ + WhereMaskSet pMaskSet, /* Mapping from tables to bitmaps */ + int iFirst, /* Be searching with the iFirst-th expression */ + int iBase /* Ignore references to this table */ + ) { + Bitmask allowed = ~getMask(pMaskSet, iBase); + while (iFirst < pList.nExpr) { + if ((exprTableUsage(pMaskSet, pList.a[iFirst++].pExpr) & allowed) != 0) { + return true; + } + } + return false; } - if ( pExpr.iColumn != iColumn || !pColl.zName.Equals( zColl, StringComparison.OrdinalIgnoreCase ) ) - { - /* Term j of the ORDER BY clause does not match column i of the index */ - if ( i < nEqCol ) - { - /* If an index column that is constrained by == fails to match an - ** ORDER BY term, that is OK. Just ignore that column of the index - */ - continue; - } - else if ( i == pIdx.nColumn ) - { - /* Index column i is the rowid. All other terms match. */ - break; - } - else - { - /* If an index column fails to match and is not constrained by == - ** then the index cannot satisfy the ORDER BY constraint. + + + /* + ** This routine decides if pIdx can be used to satisfy the ORDER BY + ** clause. If it can, it returns 1. If pIdx cannot satisfy the + ** ORDER BY clause, this routine returns 0. + ** + ** pOrderBy is an ORDER BY clause from a SELECT statement. pTab is the + ** left-most table in the FROM clause of that same SELECT statement and + ** the table has a cursor number of "_base". pIdx is an index on pTab. + ** + ** nEqCol is the number of columns of pIdx that are used as equality + ** constraints. Any of these columns may be missing from the ORDER BY + ** clause and the match can still be a success. + ** + ** All terms of the ORDER BY that match against the index must be either + ** ASC or DESC. (Terms of the ORDER BY clause past the end of a UNIQUE + ** index do not need to satisfy this constraint.) The pbRev value is + ** set to 1 if the ORDER BY clause is all DESC and it is set to 0 if + ** the ORDER BY clause is all ASC. + */ + static bool isSortingIndex( + Parse pParse, /* Parsing context */ + WhereMaskSet pMaskSet, /* Mapping from table cursor numbers to bitmaps */ + Index pIdx, /* The index we are testing */ + int _base, /* Cursor number for the table to be sorted */ + ExprList pOrderBy, /* The ORDER BY clause */ + int nEqCol, /* Number of index columns with == constraints */ + int wsFlags, /* Index usages flags */ + ref int pbRev /* Set to 1 if ORDER BY is DESC */ + ) { + int i, j; /* Loop counters */ + int sortOrder = 0; /* XOR of index and ORDER BY sort direction */ + int nTerm; /* Number of ORDER BY terms */ + ExprList_item pTerm; /* A term of the ORDER BY clause */ + sqlite3 db = pParse.db; + + Debug.Assert(pOrderBy != null); + nTerm = pOrderBy.nExpr; + Debug.Assert(nTerm > 0); + + /* Argument pIdx must either point to a 'real' named index structure, + ** or an index structure allocated on the stack by bestBtreeIndex() to + ** represent the rowid index that is part of every table. */ + Debug.Assert(!String.IsNullOrEmpty(pIdx.zName) || (pIdx.nColumn == 1 && pIdx.aiColumn[0] == -1)); + + /* Match terms of the ORDER BY clause against columns of + ** the index. + ** + ** Note that indices have pIdx.nColumn regular columns plus + ** one additional column containing the rowid. The rowid column + ** of the index is also allowed to match against the ORDER BY + ** clause. */ + for (i = j = 0; j < nTerm && i <= pIdx.nColumn; i++) { + pTerm = pOrderBy.a[j]; + Expr pExpr; /* The expression of the ORDER BY pTerm */ + CollSeq pColl; /* The collating sequence of pExpr */ + int termSortOrder; /* Sort order for this term */ + int iColumn; /* The i-th column of the index. -1 for rowid */ + int iSortOrder; /* 1 for DESC, 0 for ASC on the i-th index term */ + string zColl; /* Name of the collating sequence for i-th index term */ + + pExpr = pTerm.pExpr; + if (pExpr.op != TK_COLUMN || pExpr.iTable != _base) { + /* Can not use an index sort on anything that is not a column in the + ** left-most table of the FROM clause */ + break; + } + pColl = sqlite3ExprCollSeq(pParse, pExpr); + if (null == pColl) { + pColl = db.pDfltColl; + } + if (!String.IsNullOrEmpty(pIdx.zName) && i < pIdx.nColumn) { + iColumn = pIdx.aiColumn[i]; + if (iColumn == pIdx.pTable.iPKey) { + iColumn = -1; + } + iSortOrder = pIdx.aSortOrder[i]; + zColl = pIdx.azColl[i]; + } else { + iColumn = -1; + iSortOrder = 0; + zColl = pColl.zName; + } + if (pExpr.iColumn != iColumn || !pColl.zName.Equals(zColl, StringComparison.OrdinalIgnoreCase)) { + /* Term j of the ORDER BY clause does not match column i of the index */ + if (i < nEqCol) { + /* If an index column that is constrained by == fails to match an + ** ORDER BY term, that is OK. Just ignore that column of the index + */ + continue; + } else if (i == pIdx.nColumn) { + /* Index column i is the rowid. All other terms match. */ + break; + } else { + /* If an index column fails to match and is not constrained by == + ** then the index cannot satisfy the ORDER BY constraint. + */ + return false; + } + } + Debug.Assert(pIdx.aSortOrder != null || iColumn == -1); + Debug.Assert(pTerm.sortOrder == 0 || pTerm.sortOrder == 1); + Debug.Assert(iSortOrder == 0 || iSortOrder == 1); + termSortOrder = iSortOrder ^ pTerm.sortOrder; + if (i > nEqCol) { + if (termSortOrder != sortOrder) { + /* Indices can only be used if all ORDER BY terms past the + ** equality constraints are all either DESC or ASC. */ + return false; + } + } else { + sortOrder = termSortOrder; + } + j++; + //pTerm++; + if (iColumn < 0 && !referencesOtherTables(pOrderBy, pMaskSet, j, _base)) { + /* If the indexed column is the primary key and everything matches + ** so far and none of the ORDER BY terms to the right reference other + ** tables in the join, then we are Debug.Assured that the index can be used + ** to sort because the primary key is unique and so none of the other + ** columns will make any difference + */ + j = nTerm; + } + } + + pbRev = sortOrder != 0 ? 1 : 0; + if (j >= nTerm) { + /* All terms of the ORDER BY clause are covered by this index so + ** this index can be used for sorting. */ + return true; + } + if (pIdx.onError != OE_None && i == pIdx.nColumn + && (wsFlags & WHERE_COLUMN_NULL) == 0 + && !referencesOtherTables(pOrderBy, pMaskSet, j, _base)) { + /* All terms of this index match some prefix of the ORDER BY clause + ** and the index is UNIQUE and no terms on the tail of the ORDER BY + ** clause reference other tables in a join. If this is all true then + ** the order by clause is superfluous. Not that if the matching + ** condition is IS NULL then the result is not necessarily unique + ** even on a UNIQUE index, so disallow those cases. */ + return true; + } return false; - } } - Debug.Assert( pIdx.aSortOrder != null || iColumn == -1 ); - Debug.Assert( pTerm.sortOrder == 0 || pTerm.sortOrder == 1 ); - Debug.Assert( iSortOrder == 0 || iSortOrder == 1 ); - termSortOrder = iSortOrder ^ pTerm.sortOrder; - if ( i > nEqCol ) - { - if ( termSortOrder != sortOrder ) - { - /* Indices can only be used if all ORDER BY terms past the - ** equality constraints are all either DESC or ASC. */ - return false; - } + + /* + ** Prepare a crude estimate of the logarithm of the input value. + ** The results need not be exact. This is only used for estimating + ** the total cost of performing operations with O(logN) or O(NlogN) + ** complexity. Because N is just a guess, it is no great tragedy if + ** logN is a little off. + */ + static double estLog(double N) { + double logN = 1; + double x = 10; + while (N > x) { + logN += 1; + x *= 10; + } + return logN; } - else - { - sortOrder = termSortOrder; + + /* + ** Two routines for printing the content of an sqlite3_index_info + ** structure. Used for testing and debugging only. If neither + ** SQLITE_TEST or SQLITE_DEBUG are defined, then these routines + ** are no-ops. + */ +#if !(SQLITE_OMIT_VIRTUALTABLE) && (SQLITE_DEBUG) + static void TRACE_IDX_INPUTS(sqlite3_index_info p) { + int i; + if (!sqlite3WhereTrace) return; + for (i = 0; i < p.nConstraint; i++) { + sqlite3DebugPrintf(" constraint[%d]: col=%d termid=%d op=%d usabled=%d\n", + i, + p.aConstraint[i].iColumn, + p.aConstraint[i].iTermOffset, + p.aConstraint[i].op, + p.aConstraint[i].usable); + } + for (i = 0; i < p.nOrderBy; i++) { + sqlite3DebugPrintf(" orderby[%d]: col=%d desc=%d\n", + i, + p.aOrderBy[i].iColumn, + p.aOrderBy[i].desc); + } } - j++; - //pTerm++; - if ( iColumn < 0 && !referencesOtherTables( pOrderBy, pMaskSet, j, _base ) ) - { - /* If the indexed column is the primary key and everything matches - ** so far and none of the ORDER BY terms to the right reference other - ** tables in the join, then we are Debug.Assured that the index can be used - ** to sort because the primary key is unique and so none of the other - ** columns will make any difference - */ - j = nTerm; + static void TRACE_IDX_OUTPUTS(sqlite3_index_info p) { + int i; + if (!sqlite3WhereTrace) return; + for (i = 0; i < p.nConstraint; i++) { + sqlite3DebugPrintf(" usage[%d]: argvIdx=%d omit=%d\n", + i, + p.aConstraintUsage[i].argvIndex, + p.aConstraintUsage[i].omit); + } + sqlite3DebugPrintf(" idxNum=%d\n", p.idxNum); + sqlite3DebugPrintf(" idxStr=%s\n", p.idxStr); + sqlite3DebugPrintf(" orderByConsumed=%d\n", p.orderByConsumed); + sqlite3DebugPrintf(" estimatedCost=%g\n", p.estimatedCost); } - } - - pbRev = sortOrder != 0 ? 1 : 0; - if ( j >= nTerm ) - { - /* All terms of the ORDER BY clause are covered by this index so - ** this index can be used for sorting. */ - return true; - } - if ( pIdx.onError != OE_None && i == pIdx.nColumn - && ( wsFlags & WHERE_COLUMN_NULL ) == 0 - && !referencesOtherTables( pOrderBy, pMaskSet, j, _base ) ) - { - /* All terms of this index match some prefix of the ORDER BY clause - ** and the index is UNIQUE and no terms on the tail of the ORDER BY - ** clause reference other tables in a join. If this is all true then - ** the order by clause is superfluous. Not that if the matching - ** condition is IS NULL then the result is not necessarily unique - ** even on a UNIQUE index, so disallow those cases. */ - return true; - } - return false; - } - - /* - ** Prepare a crude estimate of the logarithm of the input value. - ** The results need not be exact. This is only used for estimating - ** the total cost of performing operations with O(logN) or O(NlogN) - ** complexity. Because N is just a guess, it is no great tragedy if - ** logN is a little off. - */ - static double estLog( double N ) - { - double logN = 1; - double x = 10; - while ( N > x ) - { - logN += 1; - x *= 10; - } - return logN; - } - - /* - ** Two routines for printing the content of an sqlite3_index_info - ** structure. Used for testing and debugging only. If neither - ** SQLITE_TEST or SQLITE_DEBUG are defined, then these routines - ** are no-ops. - */ -#if !(SQLITE_OMIT_VIRTUALTABLE) && (SQLITE_DEBUG) -static void TRACE_IDX_INPUTS( sqlite3_index_info p ) -{ -int i; -if ( !sqlite3WhereTrace ) return; -for ( i = 0 ; i < p.nConstraint ; i++ ) -{ -sqlite3DebugPrintf( " constraint[%d]: col=%d termid=%d op=%d usabled=%d\n", -i, -p.aConstraint[i].iColumn, -p.aConstraint[i].iTermOffset, -p.aConstraint[i].op, -p.aConstraint[i].usable ); -} -for ( i = 0 ; i < p.nOrderBy ; i++ ) -{ -sqlite3DebugPrintf( " orderby[%d]: col=%d desc=%d\n", -i, -p.aOrderBy[i].iColumn, -p.aOrderBy[i].desc ); -} -} -static void TRACE_IDX_OUTPUTS( sqlite3_index_info p ) -{ -int i; -if ( !sqlite3WhereTrace ) return; -for ( i = 0 ; i < p.nConstraint ; i++ ) -{ -sqlite3DebugPrintf( " usage[%d]: argvIdx=%d omit=%d\n", -i, -p.aConstraintUsage[i].argvIndex, -p.aConstraintUsage[i].omit ); -} -sqlite3DebugPrintf( " idxNum=%d\n", p.idxNum ); -sqlite3DebugPrintf( " idxStr=%s\n", p.idxStr ); -sqlite3DebugPrintf( " orderByConsumed=%d\n", p.orderByConsumed ); -sqlite3DebugPrintf( " estimatedCost=%g\n", p.estimatedCost ); -} #else //#define TRACE_IDX_INPUTS(A) static void TRACE_IDX_INPUTS( sqlite3_index_info p ) { } @@ -1888,228 +1729,210 @@ static void TRACE_IDX_INPUTS( sqlite3_index_info p ) { } static void TRACE_IDX_OUTPUTS( sqlite3_index_info p ) { } #endif - /* -** Required because bestIndex() is called by bestOrClauseIndex() -*/ - //static void bestIndex( - //Parse*, WhereClause*, struct SrcList_item*, - //Bitmask, ExprList*, WhereCost); - - /* - ** This routine attempts to find an scanning strategy that can be used - ** to optimize an 'OR' expression that is part of a WHERE clause. - ** - ** The table associated with FROM clause term pSrc may be either a - ** regular B-Tree table or a virtual table. + /* + ** Required because bestIndex() is called by bestOrClauseIndex() */ - static void bestOrClauseIndex( - Parse pParse, /* The parsing context */ - WhereClause pWC, /* The WHERE clause */ - SrcList_item pSrc, /* The FROM clause term to search */ - Bitmask notReady, /* Mask of cursors not available for indexing */ - Bitmask notValid, /* Cursors not available for any purpose */ - ExprList pOrderBy, /* The ORDER BY clause */ - WhereCost pCost /* Lowest cost query plan */ - ) - { + //static void bestIndex( + //Parse*, WhereClause*, struct SrcList_item*, + //Bitmask, ExprList*, WhereCost); + + /* + ** This routine attempts to find an scanning strategy that can be used + ** to optimize an 'OR' expression that is part of a WHERE clause. + ** + ** The table associated with FROM clause term pSrc may be either a + ** regular B-Tree table or a virtual table. + */ + static void bestOrClauseIndex( + Parse pParse, /* The parsing context */ + WhereClause pWC, /* The WHERE clause */ + SrcList_item pSrc, /* The FROM clause term to search */ + Bitmask notReady, /* Mask of cursors not available for indexing */ + Bitmask notValid, /* Cursors not available for any purpose */ + ExprList pOrderBy, /* The ORDER BY clause */ + WhereCost pCost /* Lowest cost query plan */ + ) { #if !SQLITE_OMIT_OR_OPTIMIZATION - int iCur = pSrc.iCursor; /* The cursor of the table to be accessed */ - Bitmask maskSrc = getMask( pWC.pMaskSet, iCur ); /* Bitmask for pSrc */ - WhereTerm pWCEnd = pWC.a[pWC.nTerm]; /* End of pWC.a[] */ - WhereTerm pTerm; /* A single term of the WHERE clause */ - - /* No OR-clause optimization allowed if the INDEXED BY or NOT INDEXED clauses - ** are used */ - if ( pSrc.notIndexed != 0 || pSrc.pIndex != null ) - { - return; - } + int iCur = pSrc.iCursor; /* The cursor of the table to be accessed */ + Bitmask maskSrc = getMask(pWC.pMaskSet, iCur); /* Bitmask for pSrc */ + WhereTerm pWCEnd = pWC.a[pWC.nTerm]; /* End of pWC.a[] */ + WhereTerm pTerm; /* A single term of the WHERE clause */ + + /* No OR-clause optimization allowed if the INDEXED BY or NOT INDEXED clauses + ** are used */ + if (pSrc.notIndexed != 0 || pSrc.pIndex != null) { + return; + } - /* Search the WHERE clause terms for a usable WO_OR term. */ - for ( int _pt = 0; _pt < pWC.nTerm; _pt++ )//= pCost.rCost ) - break; - } - - /* If there is an ORDER BY clause, increase the scan cost to account - ** for the cost of the sort. */ - if ( pOrderBy != null ) - { -#if (SQLITE_TEST) && (SQLITE_DEBUG) + if (pOrTerm.eOperator == WO_AND) { + WhereClause pAndWC = pOrTerm.u.pAndInfo.wc; + bestIndex(pParse, pAndWC, pSrc, notReady, notValid, null, ref sTermCost); + } else if (pOrTerm.leftCursor == iCur) { + WhereClause tempWC = new WhereClause(); + tempWC.pParse = pWC.pParse; + tempWC.pMaskSet = pWC.pMaskSet; + tempWC.op = TK_AND; + tempWC.a = new WhereTerm[2]; + tempWC.a[0] = pOrTerm; + tempWC.nTerm = 1; + bestIndex(pParse, tempWC, pSrc, notReady, notValid, null, ref sTermCost); + } else { + continue; + } + rTotal += sTermCost.rCost; + nRow += sTermCost.plan.nRow; + used |= sTermCost.used; + if (rTotal >= pCost.rCost) + break; + } + + /* If there is an ORDER BY clause, increase the scan cost to account + ** for the cost of the sort. */ + if (pOrderBy != null) { +#if (SQLITE_TEST) && (SQLITE_DEBUG) WHERETRACE( "... sorting increases OR cost %.9g to %.9g\n", rTotal, rTotal + nRow * estLog( nRow ) ); #endif - rTotal += nRow * estLog( nRow ); - } + rTotal += nRow * estLog(nRow); + } - /* If the cost of scanning using this OR term for optimization is - ** less than the current cost stored in pCost, replace the contents - ** of pCost. */ -#if (SQLITE_TEST) && (SQLITE_DEBUG) + /* If the cost of scanning using this OR term for optimization is + ** less than the current cost stored in pCost, replace the contents + ** of pCost. */ +#if (SQLITE_TEST) && (SQLITE_DEBUG) WHERETRACE( "... multi-index OR cost=%.9g nrow=%.9g\n", rTotal, nRow ); #endif - if ( rTotal < pCost.rCost ) - { - pCost.rCost = rTotal; - pCost.used = used; - pCost.plan.nRow = nRow; - pCost.plan.wsFlags = (uint)flags; - pCost.plan.u.pTerm = pTerm; - } - } - } + if (rTotal < pCost.rCost) { + pCost.rCost = rTotal; + pCost.used = used; + pCost.plan.nRow = nRow; + pCost.plan.wsFlags = (uint)flags; + pCost.plan.u.pTerm = pTerm; + } + } + } #endif //* SQLITE_OMIT_OR_OPTIMIZATION */ - } + } #if !SQLITE_OMIT_AUTOMATIC_INDEX - /* -** Return TRUE if the WHERE clause term pTerm is of a form where it -** could be used with an index to access pSrc, assuming an appropriate -** index existed. -*/ - static int termCanDriveIndex( - WhereTerm pTerm, /* WHERE clause term to check */ - SrcList_item pSrc, /* Table we are trying to access */ - Bitmask notReady /* Tables in outer loops of the join */ - ) - { - char aff; - if ( pTerm.leftCursor != pSrc.iCursor ) - return 0; - if ( pTerm.eOperator != WO_EQ ) - return 0; - if ( ( pTerm.prereqRight & notReady ) != 0 ) - return 0; - aff = pSrc.pTab.aCol[pTerm.u.leftColumn].affinity; - if ( !sqlite3IndexAffinityOk( pTerm.pExpr, aff ) ) - return 0; - return 1; - } + /* + ** Return TRUE if the WHERE clause term pTerm is of a form where it + ** could be used with an index to access pSrc, assuming an appropriate + ** index existed. + */ + static int termCanDriveIndex( + WhereTerm pTerm, /* WHERE clause term to check */ + SrcList_item pSrc, /* Table we are trying to access */ + Bitmask notReady /* Tables in outer loops of the join */ + ) { + char aff; + if (pTerm.leftCursor != pSrc.iCursor) + return 0; + if (pTerm.eOperator != WO_EQ) + return 0; + if ((pTerm.prereqRight & notReady) != 0) + return 0; + aff = pSrc.pTab.aCol[pTerm.u.leftColumn].affinity; + if (!sqlite3IndexAffinityOk(pTerm.pExpr, aff)) + return 0; + return 1; + } #endif #if !SQLITE_OMIT_AUTOMATIC_INDEX - /* -** If the query plan for pSrc specified in pCost is a full table scan -** and indexing is allows (if there is no NOT INDEXED clause) and it -** possible to construct a transient index that would perform better -** than a full table scan even when the cost of constructing the index -** is taken into account, then alter the query plan to use the -** transient index. -*/ - static void bestAutomaticIndex( - Parse pParse, /* The parsing context */ - WhereClause pWC, /* The WHERE clause */ - SrcList_item pSrc, /* The FROM clause term to search */ - Bitmask notReady, /* Mask of cursors that are not available */ - WhereCost pCost /* Lowest cost query plan */ - ) - { - double nTableRow; /* Rows in the input table */ - double logN; /* log(nTableRow) */ - double costTempIdx; /* per-query cost of the transient index */ - WhereTerm pTerm; /* A single term of the WHERE clause */ - WhereTerm pWCEnd; /* End of pWC.a[] */ - Table pTable; /* Table that might be indexed */ - - if ( pParse.nQueryLoop <= (double)1 ) - { - /* There is no point in building an automatic index for a single scan */ - return; - } - if ( ( pParse.db.flags & SQLITE_AutoIndex ) == 0 ) - { - /* Automatic indices are disabled at run-time */ - return; - } - if ( ( pCost.plan.wsFlags & WHERE_NOT_FULLSCAN ) != 0 ) - { - /* We already have some kind of index in use for this query. */ - return; - } - if ( pSrc.notIndexed != 0 ) - { - /* The NOT INDEXED clause appears in the SQL. */ - return; - } + /* + ** If the query plan for pSrc specified in pCost is a full table scan + ** and indexing is allows (if there is no NOT INDEXED clause) and it + ** possible to construct a transient index that would perform better + ** than a full table scan even when the cost of constructing the index + ** is taken into account, then alter the query plan to use the + ** transient index. + */ + static void bestAutomaticIndex( + Parse pParse, /* The parsing context */ + WhereClause pWC, /* The WHERE clause */ + SrcList_item pSrc, /* The FROM clause term to search */ + Bitmask notReady, /* Mask of cursors that are not available */ + WhereCost pCost /* Lowest cost query plan */ + ) { + double nTableRow; /* Rows in the input table */ + double logN; /* log(nTableRow) */ + double costTempIdx; /* per-query cost of the transient index */ + WhereTerm pTerm; /* A single term of the WHERE clause */ + WhereTerm pWCEnd; /* End of pWC.a[] */ + Table pTable; /* Table that might be indexed */ + + if (pParse.nQueryLoop <= (double)1) { + /* There is no point in building an automatic index for a single scan */ + return; + } + if ((pParse.db.flags & SQLITE_AutoIndex) == 0) { + /* Automatic indices are disabled at run-time */ + return; + } + if ((pCost.plan.wsFlags & WHERE_NOT_FULLSCAN) != 0) { + /* We already have some kind of index in use for this query. */ + return; + } + if (pSrc.notIndexed != 0) { + /* The NOT INDEXED clause appears in the SQL. */ + return; + } - Debug.Assert( pParse.nQueryLoop >= (double)1 ); - pTable = pSrc.pTab; - nTableRow = pTable.nRowEst; - logN = estLog( nTableRow ); - costTempIdx = 2 * logN * ( nTableRow / pParse.nQueryLoop + 1 ); - if ( costTempIdx >= pCost.rCost ) - { - /* The cost of creating the transient table would be greater than - ** doing the full table scan */ - return; - } + Debug.Assert(pParse.nQueryLoop >= (double)1); + pTable = pSrc.pTab; + nTableRow = pTable.nRowEst; + logN = estLog(nTableRow); + costTempIdx = 2 * logN * (nTableRow / pParse.nQueryLoop + 1); + if (costTempIdx >= pCost.rCost) { + /* The cost of creating the transient table would be greater than + ** doing the full table scan */ + return; + } - /* Search for any equality comparison term */ - //pWCEnd = pWC.a[pWC.nTerm]; - for ( int ipTerm = 0; ipTerm < pWC.nTerm; ipTerm++ )//; pTerm= BMS ? ( (Bitmask)1 ) << ( BMS - 1 ) : ( (Bitmask)1 ) << iCol; - testcase( iCol == BMS ); - testcase( iCol == BMS - 1 ); - if ( ( idxCols & cMask ) == 0 ) - { - nColumn++; - idxCols |= cMask; - } - } - } - Debug.Assert( nColumn > 0 ); - pLevel.plan.nEq = (u32)nColumn; - - /* Count the number of additional columns needed to create a - ** covering index. A "covering index" is an index that contains all - ** columns that are needed by the query. With a covering index, the - ** original table never needs to be accessed. Automatic indices must - ** be a covering index because the index will not be updated if the - ** original table changes and the index and table cannot both be used - ** if they go out of sync. - */ - extraCols = pSrc.colUsed & ( ~idxCols | ( ( (Bitmask)1 ) << ( BMS - 1 ) ) ); - mxBitCol = ( pTable.nCol >= BMS - 1 ) ? BMS - 1 : pTable.nCol; - testcase( pTable.nCol == BMS - 1 ); - testcase( pTable.nCol == BMS - 2 ); - for ( i = 0; i < mxBitCol; i++ ) - { - if ( ( extraCols & ( ( (Bitmask)1 ) << i ) ) != 0 ) - nColumn++; - } - if ( ( pSrc.colUsed & ( ( (Bitmask)1 ) << ( BMS - 1 ) ) ) != 0 ) - { - nColumn += pTable.nCol - BMS + 1; - } - pLevel.plan.wsFlags |= WHERE_COLUMN_EQ | WHERE_IDX_ONLY | WO_EQ; - - /* Construct the Index object to describe this index */ - //nByte = sizeof(Index); - //nByte += nColumn*sizeof(int); /* Index.aiColumn */ - //nByte += nColumn*sizeof(char); /* Index.azColl */ - //nByte += nColumn; /* Index.aSortOrder */ - //pIdx = sqlite3DbMallocZero(pParse.db, nByte); - //if( pIdx==null) return; - pIdx = new Index(); - pLevel.plan.u.pIdx = pIdx; - pIdx.azColl = new string[nColumn + 1];// pIdx[1]; - pIdx.aiColumn = new int[nColumn + 1];// pIdx.azColl[nColumn]; - pIdx.aSortOrder = new u8[nColumn + 1];// pIdx.aiColumn[nColumn]; - pIdx.zName = "auto-index"; - pIdx.nColumn = nColumn; - pIdx.pTable = pTable; - n = 0; - idxCols = 0; - //for(pTerm=pWC.a; pTerm= BMS ? ( (Bitmask)1 ) << ( BMS - 1 ) : ( (Bitmask)1 ) << iCol; - if ( ( idxCols & cMask ) == 0 ) - { - Expr pX = pTerm.pExpr; - idxCols |= cMask; - pIdx.aiColumn[n] = pTerm.u.leftColumn; - pColl = sqlite3BinaryCompareCollSeq( pParse, pX.pLeft, pX.pRight ); - pIdx.azColl[n] = ALWAYS( pColl != null ) ? pColl.zName : "BINARY"; - n++; - } - } - } - Debug.Assert( (u32)n == pLevel.plan.nEq ); - - /* Add additional columns needed to make the automatic index into - ** a covering index */ - for ( i = 0; i < mxBitCol; i++ ) - { - if ( ( extraCols & ( ( (Bitmask)1 ) << i ) ) != 0 ) - { - pIdx.aiColumn[n] = i; - pIdx.azColl[n] = "BINARY"; - n++; - } - } - if ( ( pSrc.colUsed & ( ( (Bitmask)1 ) << ( BMS - 1 ) ) ) != 0 ) - { - for ( i = BMS - 1; i < pTable.nCol; i++ ) - { - pIdx.aiColumn[n] = i; - pIdx.azColl[n] = "BINARY"; - n++; + /* + ** Generate code to construct the Index object for an automatic index + ** and to set up the WhereLevel object pLevel so that the code generator + ** makes use of the automatic index. + */ + static void constructAutomaticIndex( + Parse pParse, /* The parsing context */ + WhereClause pWC, /* The WHERE clause */ + SrcList_item pSrc, /* The FROM clause term to get the next index */ + Bitmask notReady, /* Mask of cursors that are not available */ + WhereLevel pLevel /* Write new index here */ + ) { + int nColumn; /* Number of columns in the constructed index */ + WhereTerm pTerm; /* A single term of the WHERE clause */ + WhereTerm pWCEnd; /* End of pWC.a[] */ + int nByte; /* Byte of memory needed for pIdx */ + Index pIdx; /* Object describing the transient index */ + Vdbe v; /* Prepared statement under construction */ + int regIsInit; /* Register set by initialization */ + int addrInit; /* Address of the initialization bypass jump */ + Table pTable; /* The table being indexed */ + KeyInfo pKeyinfo; /* Key information for the index */ + int addrTop; /* Top of the index fill loop */ + int regRecord; /* Register holding an index record */ + int n; /* Column counter */ + int i; /* Loop counter */ + int mxBitCol; /* Maximum column in pSrc.colUsed */ + CollSeq pColl; /* Collating sequence to on a column */ + Bitmask idxCols; /* Bitmap of columns used for indexing */ + Bitmask extraCols; /* Bitmap of additional columns */ + + /* Generate code to skip over the creation and initialization of the + ** transient index on 2nd and subsequent iterations of the loop. */ + v = pParse.pVdbe; + Debug.Assert(v != null); + regIsInit = ++pParse.nMem; + addrInit = sqlite3VdbeAddOp1(v, OP_If, regIsInit); + sqlite3VdbeAddOp2(v, OP_Integer, 1, regIsInit); + + /* Count the number of columns that will be added to the index + ** and used to match WHERE clause constraints */ + nColumn = 0; + pTable = pSrc.pTab; + //pWCEnd = pWC.a[pWC.nTerm]; + idxCols = 0; + for (int ipTerm = 0; ipTerm < pWC.nTerm; ipTerm++)//; pTerm= BMS ? ((Bitmask)1) << (BMS - 1) : ((Bitmask)1) << iCol; + testcase(iCol == BMS); + testcase(iCol == BMS - 1); + if ((idxCols & cMask) == 0) { + nColumn++; + idxCols |= cMask; + } + } + } + Debug.Assert(nColumn > 0); + pLevel.plan.nEq = (u32)nColumn; + + /* Count the number of additional columns needed to create a + ** covering index. A "covering index" is an index that contains all + ** columns that are needed by the query. With a covering index, the + ** original table never needs to be accessed. Automatic indices must + ** be a covering index because the index will not be updated if the + ** original table changes and the index and table cannot both be used + ** if they go out of sync. + */ + extraCols = pSrc.colUsed & (~idxCols | (((Bitmask)1) << (BMS - 1))); + mxBitCol = (pTable.nCol >= BMS - 1) ? BMS - 1 : pTable.nCol; + testcase(pTable.nCol == BMS - 1); + testcase(pTable.nCol == BMS - 2); + for (i = 0; i < mxBitCol; i++) { + if ((extraCols & (((Bitmask)1) << i)) != 0) + nColumn++; + } + if ((pSrc.colUsed & (((Bitmask)1) << (BMS - 1))) != 0) { + nColumn += pTable.nCol - BMS + 1; + } + pLevel.plan.wsFlags |= WHERE_COLUMN_EQ | WHERE_IDX_ONLY | WO_EQ; + + /* Construct the Index object to describe this index */ + //nByte = sizeof(Index); + //nByte += nColumn*sizeof(int); /* Index.aiColumn */ + //nByte += nColumn*sizeof(char); /* Index.azColl */ + //nByte += nColumn; /* Index.aSortOrder */ + //pIdx = sqlite3DbMallocZero(pParse.db, nByte); + //if( pIdx==null) return; + pIdx = new Index(); + pLevel.plan.u.pIdx = pIdx; + pIdx.azColl = new string[nColumn + 1];// pIdx[1]; + pIdx.aiColumn = new int[nColumn + 1];// pIdx.azColl[nColumn]; + pIdx.aSortOrder = new u8[nColumn + 1];// pIdx.aiColumn[nColumn]; + pIdx.zName = "auto-index"; + pIdx.nColumn = nColumn; + pIdx.pTable = pTable; + n = 0; + idxCols = 0; + //for(pTerm=pWC.a; pTerm= BMS ? ((Bitmask)1) << (BMS - 1) : ((Bitmask)1) << iCol; + if ((idxCols & cMask) == 0) { + Expr pX = pTerm.pExpr; + idxCols |= cMask; + pIdx.aiColumn[n] = pTerm.u.leftColumn; + pColl = sqlite3BinaryCompareCollSeq(pParse, pX.pLeft, pX.pRight); + pIdx.azColl[n] = ALWAYS(pColl != null) ? pColl.zName : "BINARY"; + n++; + } + } + } + Debug.Assert((u32)n == pLevel.plan.nEq); + + /* Add additional columns needed to make the automatic index into + ** a covering index */ + for (i = 0; i < mxBitCol; i++) { + if ((extraCols & (((Bitmask)1) << i)) != 0) { + pIdx.aiColumn[n] = i; + pIdx.azColl[n] = "BINARY"; + n++; + } + } + if ((pSrc.colUsed & (((Bitmask)1) << (BMS - 1))) != 0) { + for (i = BMS - 1; i < pTable.nCol; i++) { + pIdx.aiColumn[n] = i; + pIdx.azColl[n] = "BINARY"; + n++; + } + } + Debug.Assert(n == nColumn); + + /* Create the automatic index */ + pKeyinfo = sqlite3IndexKeyinfo(pParse, pIdx); + Debug.Assert(pLevel.iIdxCur >= 0); + sqlite3VdbeAddOp4(v, OP_OpenAutoindex, pLevel.iIdxCur, nColumn + 1, 0, + pKeyinfo, P4_KEYINFO_HANDOFF); + VdbeComment(v, "for %s", pTable.zName); + + /* Fill the automatic index with content */ + addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel.iTabCur); + regRecord = sqlite3GetTempReg(pParse); + sqlite3GenerateIndexKey(pParse, pIdx, pLevel.iTabCur, regRecord, true); + sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel.iIdxCur, regRecord); + sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); + sqlite3VdbeAddOp2(v, OP_Next, pLevel.iTabCur, addrTop + 1); + sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX); + sqlite3VdbeJumpHere(v, addrTop); + sqlite3ReleaseTempReg(pParse, regRecord); + + /* Jump here when skipping the initialization */ + sqlite3VdbeJumpHere(v, addrInit); } - } - Debug.Assert( n == nColumn ); - - /* Create the automatic index */ - pKeyinfo = sqlite3IndexKeyinfo( pParse, pIdx ); - Debug.Assert( pLevel.iIdxCur >= 0 ); - sqlite3VdbeAddOp4( v, OP_OpenAutoindex, pLevel.iIdxCur, nColumn + 1, 0, - pKeyinfo, P4_KEYINFO_HANDOFF ); - VdbeComment( v, "for %s", pTable.zName ); - - /* Fill the automatic index with content */ - addrTop = sqlite3VdbeAddOp1( v, OP_Rewind, pLevel.iTabCur ); - regRecord = sqlite3GetTempReg( pParse ); - sqlite3GenerateIndexKey( pParse, pIdx, pLevel.iTabCur, regRecord, true ); - sqlite3VdbeAddOp2( v, OP_IdxInsert, pLevel.iIdxCur, regRecord ); - sqlite3VdbeChangeP5( v, OPFLAG_USESEEKRESULT ); - sqlite3VdbeAddOp2( v, OP_Next, pLevel.iTabCur, addrTop + 1 ); - sqlite3VdbeChangeP5( v, SQLITE_STMTSTATUS_AUTOINDEX ); - sqlite3VdbeJumpHere( v, addrTop ); - sqlite3ReleaseTempReg( pParse, regRecord ); - - /* Jump here when skipping the initialization */ - sqlite3VdbeJumpHere( v, addrInit ); - } #endif //* SQLITE_OMIT_AUTOMATIC_INDEX */ #if !SQLITE_OMIT_VIRTUALTABLE - /* -** Allocate and populate an sqlite3_index_info structure. It is the -** responsibility of the caller to eventually release the structure -** by passing the pointer returned by this function to //sqlite3_free(). -*/ - static sqlite3_index_info allocateIndexInfo( - Parse pParse, - WhereClause pWC, - SrcList_item pSrc, - ExprList pOrderBy - ) - { - int i, j; - int nTerm; - sqlite3_index_constraint[] pIdxCons; - sqlite3_index_orderby[] pIdxOrderBy; - sqlite3_index_constraint_usage[] pUsage; - WhereTerm pTerm; - int nOrderBy; - sqlite3_index_info pIdxInfo; - -#if (SQLITE_TEST) && (SQLITE_DEBUG) + /* + ** Allocate and populate an sqlite3_index_info structure. It is the + ** responsibility of the caller to eventually release the structure + ** by passing the pointer returned by this function to //sqlite3_free(). + */ + static sqlite3_index_info allocateIndexInfo( + Parse pParse, + WhereClause pWC, + SrcList_item pSrc, + ExprList pOrderBy + ) { + int i, j; + int nTerm; + sqlite3_index_constraint[] pIdxCons; + sqlite3_index_orderby[] pIdxOrderBy; + sqlite3_index_constraint_usage[] pUsage; + WhereTerm pTerm; + int nOrderBy; + sqlite3_index_info pIdxInfo; + +#if (SQLITE_TEST) && (SQLITE_DEBUG) WHERETRACE( "Recomputing index info for %s...\n", pSrc.pTab.zName ); #endif - /* Count the number of possible WHERE clause constraints referring -** to this virtual table */ - for ( i = nTerm = 0; i < pWC.nTerm; i++)//, pTerm++ ) - { - pTerm = pWC.a[i]; - if ( pTerm.leftCursor != pSrc.iCursor ) - continue; - Debug.Assert( ( pTerm.eOperator & ( pTerm.eOperator - 1 ) ) == 0 ); - testcase( pTerm.eOperator == WO_IN ); - testcase( pTerm.eOperator == WO_ISNULL ); - if ( ( pTerm.eOperator & ( WO_IN | WO_ISNULL ) ) != 0 ) - continue; - nTerm++; - } + /* Count the number of possible WHERE clause constraints referring + ** to this virtual table */ + for (i = nTerm = 0; i < pWC.nTerm; i++)//, pTerm++ ) + { + pTerm = pWC.a[i]; + if (pTerm.leftCursor != pSrc.iCursor) + continue; + Debug.Assert((pTerm.eOperator & (pTerm.eOperator - 1)) == 0); + testcase(pTerm.eOperator == WO_IN); + testcase(pTerm.eOperator == WO_ISNULL); + if ((pTerm.eOperator & (WO_IN | WO_ISNULL)) != 0) + continue; + nTerm++; + } - /* If the ORDER BY clause contains only columns in the current - ** virtual table then allocate space for the aOrderBy part of - ** the sqlite3_index_info structure. - */ - nOrderBy = 0; - if ( pOrderBy != null ) - { - for ( i = 0; i < pOrderBy.nExpr; i++ ) - { - Expr pExpr = pOrderBy.a[i].pExpr; - if ( pExpr.op != TK_COLUMN || pExpr.iTable != pSrc.iCursor ) - break; - } - if ( i == pOrderBy.nExpr ) - { - nOrderBy = pOrderBy.nExpr; - } - } + /* If the ORDER BY clause contains only columns in the current + ** virtual table then allocate space for the aOrderBy part of + ** the sqlite3_index_info structure. + */ + nOrderBy = 0; + if (pOrderBy != null) { + for (i = 0; i < pOrderBy.nExpr; i++) { + Expr pExpr = pOrderBy.a[i].pExpr; + if (pExpr.op != TK_COLUMN || pExpr.iTable != pSrc.iCursor) + break; + } + if (i == pOrderBy.nExpr) { + nOrderBy = pOrderBy.nExpr; + } + } - /* Allocate the sqlite3_index_info structure - */ - pIdxInfo = new sqlite3_index_info(); - //sqlite3DbMallocZero(pParse.db, sizeof(*pIdxInfo) - //+ (sizeof(*pIdxCons) + sizeof(*pUsage))*nTerm - //+ sizeof(*pIdxOrderBy)*nOrderBy ); - //if ( pIdxInfo == null ) - //{ - // sqlite3ErrorMsg( pParse, "out of memory" ); - // /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ - // return null; - //} + /* Allocate the sqlite3_index_info structure + */ + pIdxInfo = new sqlite3_index_info(); + //sqlite3DbMallocZero(pParse.db, sizeof(*pIdxInfo) + //+ (sizeof(*pIdxCons) + sizeof(*pUsage))*nTerm + //+ sizeof(*pIdxOrderBy)*nOrderBy ); + //if ( pIdxInfo == null ) + //{ + // sqlite3ErrorMsg( pParse, "out of memory" ); + // /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ + // return null; + //} - /* Initialize the structure. The sqlite3_index_info structure contains - ** many fields that are declared "const" to prevent xBestIndex from - ** changing them. We have to do some funky casting in order to - ** initialize those fields. - */ - pIdxCons = new sqlite3_index_constraint[nTerm];//(sqlite3_index_constraint)pIdxInfo[1]; - pIdxOrderBy = new sqlite3_index_orderby[nOrderBy];//(sqlite3_index_orderby)pIdxCons[nTerm]; - pUsage = new sqlite3_index_constraint_usage[nTerm];//(sqlite3_index_constraint_usage)pIdxOrderBy[nOrderBy]; - pIdxInfo.nConstraint = nTerm; - pIdxInfo.nOrderBy = nOrderBy; - pIdxInfo.aConstraint = pIdxCons; - pIdxInfo.aOrderBy = pIdxOrderBy; - pIdxInfo.aConstraintUsage = - pUsage; - - for ( i = j = 0; i < pWC.nTerm; i++)//, pTerm++ ) - { - pTerm = pWC.a[i]; - if ( pTerm.leftCursor != pSrc.iCursor ) - continue; - Debug.Assert( ( pTerm.eOperator & ( pTerm.eOperator - 1 ) ) == 0 ); - testcase( pTerm.eOperator == WO_IN ); - testcase( pTerm.eOperator == WO_ISNULL ); - if ( ( pTerm.eOperator & ( WO_IN | WO_ISNULL ) ) != 0 ) - continue; - if ( pIdxCons[j] == null ) - pIdxCons[j] = new sqlite3_index_constraint(); - pIdxCons[j].iColumn = pTerm.u.leftColumn; - pIdxCons[j].iTermOffset = i; - pIdxCons[j].op = (u8)pTerm.eOperator; - /* The direct Debug.Assignment in the previous line is possible only because - ** the WO_ and SQLITE_INDEX_CONSTRAINT_ codes are identical. The - ** following Debug.Asserts verify this fact. */ - Debug.Assert( WO_EQ == SQLITE_INDEX_CONSTRAINT_EQ ); - Debug.Assert( WO_LT == SQLITE_INDEX_CONSTRAINT_LT ); - Debug.Assert( WO_LE == SQLITE_INDEX_CONSTRAINT_LE ); - Debug.Assert( WO_GT == SQLITE_INDEX_CONSTRAINT_GT ); - Debug.Assert( WO_GE == SQLITE_INDEX_CONSTRAINT_GE ); - Debug.Assert( WO_MATCH == SQLITE_INDEX_CONSTRAINT_MATCH ); - Debug.Assert( ( pTerm.eOperator & ( WO_EQ | WO_LT | WO_LE | WO_GT | WO_GE | WO_MATCH ) ) != 0 ); - j++; - } - for ( i = 0; i < nOrderBy; i++ ) - { - Expr pExpr = pOrderBy.a[i].pExpr; - if ( pIdxOrderBy[i] == null ) - pIdxOrderBy[i] = new sqlite3_index_orderby(); - pIdxOrderBy[i].iColumn = pExpr.iColumn; - pIdxOrderBy[i].desc = pOrderBy.a[i].sortOrder != 0; - } + /* Initialize the structure. The sqlite3_index_info structure contains + ** many fields that are declared "const" to prevent xBestIndex from + ** changing them. We have to do some funky casting in order to + ** initialize those fields. + */ + pIdxCons = new sqlite3_index_constraint[nTerm];//(sqlite3_index_constraint)pIdxInfo[1]; + pIdxOrderBy = new sqlite3_index_orderby[nOrderBy];//(sqlite3_index_orderby)pIdxCons[nTerm]; + pUsage = new sqlite3_index_constraint_usage[nTerm];//(sqlite3_index_constraint_usage)pIdxOrderBy[nOrderBy]; + pIdxInfo.nConstraint = nTerm; + pIdxInfo.nOrderBy = nOrderBy; + pIdxInfo.aConstraint = pIdxCons; + pIdxInfo.aOrderBy = pIdxOrderBy; + pIdxInfo.aConstraintUsage = + pUsage; + + for (i = j = 0; i < pWC.nTerm; i++)//, pTerm++ ) + { + pTerm = pWC.a[i]; + if (pTerm.leftCursor != pSrc.iCursor) + continue; + Debug.Assert((pTerm.eOperator & (pTerm.eOperator - 1)) == 0); + testcase(pTerm.eOperator == WO_IN); + testcase(pTerm.eOperator == WO_ISNULL); + if ((pTerm.eOperator & (WO_IN | WO_ISNULL)) != 0) + continue; + if (pIdxCons[j] == null) + pIdxCons[j] = new sqlite3_index_constraint(); + pIdxCons[j].iColumn = pTerm.u.leftColumn; + pIdxCons[j].iTermOffset = i; + pIdxCons[j].op = (u8)pTerm.eOperator; + /* The direct Debug.Assignment in the previous line is possible only because + ** the WO_ and SQLITE_INDEX_CONSTRAINT_ codes are identical. The + ** following Debug.Asserts verify this fact. */ + Debug.Assert(WO_EQ == SQLITE_INDEX_CONSTRAINT_EQ); + Debug.Assert(WO_LT == SQLITE_INDEX_CONSTRAINT_LT); + Debug.Assert(WO_LE == SQLITE_INDEX_CONSTRAINT_LE); + Debug.Assert(WO_GT == SQLITE_INDEX_CONSTRAINT_GT); + Debug.Assert(WO_GE == SQLITE_INDEX_CONSTRAINT_GE); + Debug.Assert(WO_MATCH == SQLITE_INDEX_CONSTRAINT_MATCH); + Debug.Assert((pTerm.eOperator & (WO_EQ | WO_LT | WO_LE | WO_GT | WO_GE | WO_MATCH)) != 0); + j++; + } + for (i = 0; i < nOrderBy; i++) { + Expr pExpr = pOrderBy.a[i].pExpr; + if (pIdxOrderBy[i] == null) + pIdxOrderBy[i] = new sqlite3_index_orderby(); + pIdxOrderBy[i].iColumn = pExpr.iColumn; + pIdxOrderBy[i].desc = pOrderBy.a[i].sortOrder != 0; + } - return pIdxInfo; - } + return pIdxInfo; + } - /* - ** The table object reference passed as the second argument to this function - ** must represent a virtual table. This function invokes the xBestIndex() - ** method of the virtual table with the sqlite3_index_info pointer passed - ** as the argument. - ** - ** If an error occurs, pParse is populated with an error message and a - ** non-zero value is returned. Otherwise, 0 is returned and the output - ** part of the sqlite3_index_info structure is left populated. - ** - ** Whether or not an error is returned, it is the responsibility of the - ** caller to eventually free p.idxStr if p.needToFreeIdxStr indicates - ** that this is required. - */ - static int vtabBestIndex( Parse pParse, Table pTab, sqlite3_index_info p ) - { - sqlite3_vtab pVtab = sqlite3GetVTable( pParse.db, pTab ).pVtab; - int i; - int rc; + /* + ** The table object reference passed as the second argument to this function + ** must represent a virtual table. This function invokes the xBestIndex() + ** method of the virtual table with the sqlite3_index_info pointer passed + ** as the argument. + ** + ** If an error occurs, pParse is populated with an error message and a + ** non-zero value is returned. Otherwise, 0 is returned and the output + ** part of the sqlite3_index_info structure is left populated. + ** + ** Whether or not an error is returned, it is the responsibility of the + ** caller to eventually free p.idxStr if p.needToFreeIdxStr indicates + ** that this is required. + */ + static int vtabBestIndex(Parse pParse, Table pTab, sqlite3_index_info p) { + sqlite3_vtab pVtab = sqlite3GetVTable(pParse.db, pTab).pVtab; + int i; + int rc; -#if (SQLITE_TEST) && (SQLITE_DEBUG) +#if (SQLITE_TEST) && (SQLITE_DEBUG) WHERETRACE( "xBestIndex for %s\n", pTab.zName ); #endif - TRACE_IDX_INPUTS( p ); - rc = pVtab.pModule.xBestIndex( pVtab, ref p ); - TRACE_IDX_OUTPUTS( p ); - - if ( rc != SQLITE_OK ) - { - //if ( rc == SQLITE_NOMEM ) - //{ - // pParse.db.mallocFailed = 1; - //} - // else - if ( String.IsNullOrEmpty( pVtab.zErrMsg ) ) - { - sqlite3ErrorMsg( pParse, "%s", sqlite3ErrStr( rc ) ); - } - else - { - sqlite3ErrorMsg( pParse, "%s", pVtab.zErrMsg ); - } - } - //sqlite3_free( pVtab.zErrMsg ); - pVtab.zErrMsg = null; + TRACE_IDX_INPUTS(p); + rc = pVtab.pModule.xBestIndex(pVtab, ref p); + TRACE_IDX_OUTPUTS(p); + + if (rc != SQLITE_OK) { + //if ( rc == SQLITE_NOMEM ) + //{ + // pParse.db.mallocFailed = 1; + //} + // else + if (String.IsNullOrEmpty(pVtab.zErrMsg)) { + sqlite3ErrorMsg(pParse, "%s", sqlite3ErrStr(rc)); + } else { + sqlite3ErrorMsg(pParse, "%s", pVtab.zErrMsg); + } + } + //sqlite3_free( pVtab.zErrMsg ); + pVtab.zErrMsg = null; - for ( i = 0; i < p.nConstraint; i++ ) - { - if ( !p.aConstraint[i].usable && p.aConstraintUsage[i].argvIndex > 0 ) - { - sqlite3ErrorMsg( pParse, - "table %s: xBestIndex returned an invalid plan", pTab.zName ); - } - } + for (i = 0; i < p.nConstraint; i++) { + if (!p.aConstraint[i].usable && p.aConstraintUsage[i].argvIndex > 0) { + sqlite3ErrorMsg(pParse, + "table %s: xBestIndex returned an invalid plan", pTab.zName); + } + } - return pParse.nErr; - } + return pParse.nErr; + } - /* - ** Compute the best index for a virtual table. - ** - ** The best index is computed by the xBestIndex method of the virtual - ** table module. This routine is really just a wrapper that sets up - ** the sqlite3_index_info structure that is used to communicate with - ** xBestIndex. - ** - ** In a join, this routine might be called multiple times for the - ** same virtual table. The sqlite3_index_info structure is created - ** and initialized on the first invocation and reused on all subsequent - ** invocations. The sqlite3_index_info structure is also used when - ** code is generated to access the virtual table. The whereInfoDelete() - ** routine takes care of freeing the sqlite3_index_info structure after - ** everybody has finished with it. - */ - static void bestVirtualIndex( - Parse pParse, /* The parsing context */ - WhereClause pWC, /* The WHERE clause */ - SrcList_item pSrc, /* The FROM clause term to search */ - Bitmask notReady, /* Mask of cursors not available for index */ - Bitmask notValid, /* Cursors not valid for any purpose */ - ExprList pOrderBy, /* The order by clause */ - ref WhereCost pCost, /* Lowest cost query plan */ - ref sqlite3_index_info ppIdxInfo /* Index information passed to xBestIndex */ - ) - { - Table pTab = pSrc.pTab; - sqlite3_index_info pIdxInfo; - sqlite3_index_constraint pIdxCons; - sqlite3_index_constraint_usage[] pUsage = null; - WhereTerm pTerm; - int i, j; - int nOrderBy; - double rCost; - - - /* Make sure wsFlags is initialized to some sane value. Otherwise, if the - ** malloc in allocateIndexInfo() fails and this function returns leaving - ** wsFlags in an uninitialized state, the caller may behave unpredictably. - */ - pCost = new WhereCost();//memset(pCost, 0, sizeof(*pCost)); - pCost.plan.wsFlags = WHERE_VIRTUALTABLE; + /* + ** Compute the best index for a virtual table. + ** + ** The best index is computed by the xBestIndex method of the virtual + ** table module. This routine is really just a wrapper that sets up + ** the sqlite3_index_info structure that is used to communicate with + ** xBestIndex. + ** + ** In a join, this routine might be called multiple times for the + ** same virtual table. The sqlite3_index_info structure is created + ** and initialized on the first invocation and reused on all subsequent + ** invocations. The sqlite3_index_info structure is also used when + ** code is generated to access the virtual table. The whereInfoDelete() + ** routine takes care of freeing the sqlite3_index_info structure after + ** everybody has finished with it. + */ + static void bestVirtualIndex( + Parse pParse, /* The parsing context */ + WhereClause pWC, /* The WHERE clause */ + SrcList_item pSrc, /* The FROM clause term to search */ + Bitmask notReady, /* Mask of cursors not available for index */ + Bitmask notValid, /* Cursors not valid for any purpose */ + ExprList pOrderBy, /* The order by clause */ + ref WhereCost pCost, /* Lowest cost query plan */ + ref sqlite3_index_info ppIdxInfo /* Index information passed to xBestIndex */ + ) { + Table pTab = pSrc.pTab; + sqlite3_index_info pIdxInfo; + sqlite3_index_constraint pIdxCons; + sqlite3_index_constraint_usage[] pUsage = null; + WhereTerm pTerm; + int i, j; + int nOrderBy; + double rCost; + + + /* Make sure wsFlags is initialized to some sane value. Otherwise, if the + ** malloc in allocateIndexInfo() fails and this function returns leaving + ** wsFlags in an uninitialized state, the caller may behave unpredictably. + */ + pCost = new WhereCost();//memset(pCost, 0, sizeof(*pCost)); + pCost.plan.wsFlags = WHERE_VIRTUALTABLE; - /* If the sqlite3_index_info structure has not been previously - ** allocated and initialized, then allocate and initialize it now. - */ - pIdxInfo = ppIdxInfo; - if ( pIdxInfo == null ) - { - ppIdxInfo = pIdxInfo = allocateIndexInfo( pParse, pWC, pSrc, pOrderBy ); - } - if ( pIdxInfo == null ) - { - return; - } + /* If the sqlite3_index_info structure has not been previously + ** allocated and initialized, then allocate and initialize it now. + */ + pIdxInfo = ppIdxInfo; + if (pIdxInfo == null) { + ppIdxInfo = pIdxInfo = allocateIndexInfo(pParse, pWC, pSrc, pOrderBy); + } + if (pIdxInfo == null) { + return; + } - /* At this point, the sqlite3_index_info structure that pIdxInfo points - ** to will have been initialized, either during the current invocation or - ** during some prior invocation. Now we just have to customize the - ** details of pIdxInfo for the current invocation and pDebug.Ass it to - ** xBestIndex. - */ + /* At this point, the sqlite3_index_info structure that pIdxInfo points + ** to will have been initialized, either during the current invocation or + ** during some prior invocation. Now we just have to customize the + ** details of pIdxInfo for the current invocation and pDebug.Ass it to + ** xBestIndex. + */ - /* The module name must be defined. Also, by this point there must - ** be a pointer to an sqlite3_vtab structure. Otherwise - ** sqlite3ViewGetColumnNames() would have picked up the error. - */ - Debug.Assert( pTab.azModuleArg != null && pTab.azModuleArg[0] != null ); - Debug.Assert( sqlite3GetVTable( pParse.db, pTab ) != null ); + /* The module name must be defined. Also, by this point there must + ** be a pointer to an sqlite3_vtab structure. Otherwise + ** sqlite3ViewGetColumnNames() would have picked up the error. + */ + Debug.Assert(pTab.azModuleArg != null && pTab.azModuleArg[0] != null); + Debug.Assert(sqlite3GetVTable(pParse.db, pTab) != null); - /* Set the aConstraint[].usable fields and initialize all - ** output variables to zero. - ** - ** aConstraint[].usable is true for constraints where the right-hand - ** side contains only references to tables to the left of the current - ** table. In other words, if the constraint is of the form: - ** - ** column = expr - ** - ** and we are evaluating a join, then the constraint on column is - ** only valid if all tables referenced in expr occur to the left - ** of the table containing column. - ** - ** The aConstraints[] array contains entries for all constraints - ** on the current table. That way we only have to compute it once - ** even though we might try to pick the best index multiple times. - ** For each attempt at picking an index, the order of tables in the - ** join might be different so we have to recompute the usable flag - ** each time. - */ - //pIdxCons = *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint; - //pUsage = pIdxInfo->aConstraintUsage; - for ( i = 0; i < pIdxInfo.nConstraint; i++) - { - pIdxCons = pIdxInfo.aConstraint[i]; - pUsage = pIdxInfo.aConstraintUsage; - j = pIdxCons.iTermOffset; - pTerm = pWC.a[j]; - pIdxCons.usable = ( pTerm.prereqRight & notReady ) == 0; - pUsage[i] = new sqlite3_index_constraint_usage(); - } - // memset(pUsage, 0, sizeof(pUsage[0])*pIdxInfo.nConstraint); - if ( pIdxInfo.needToFreeIdxStr!=0 ) - { - //sqlite3_free(ref pIdxInfo.idxStr); - } - pIdxInfo.idxStr = null; - pIdxInfo.idxNum = 0; - pIdxInfo.needToFreeIdxStr = 0; - pIdxInfo.orderByConsumed = false; - /* ((double)2) In case of SQLITE_OMIT_FLOATING_POINT... */ - pIdxInfo.estimatedCost = SQLITE_BIG_DBL / ( (double)2 ); - nOrderBy = pIdxInfo.nOrderBy; - if ( null == pOrderBy ) - { - pIdxInfo.nOrderBy = 0; - } + /* Set the aConstraint[].usable fields and initialize all + ** output variables to zero. + ** + ** aConstraint[].usable is true for constraints where the right-hand + ** side contains only references to tables to the left of the current + ** table. In other words, if the constraint is of the form: + ** + ** column = expr + ** + ** and we are evaluating a join, then the constraint on column is + ** only valid if all tables referenced in expr occur to the left + ** of the table containing column. + ** + ** The aConstraints[] array contains entries for all constraints + ** on the current table. That way we only have to compute it once + ** even though we might try to pick the best index multiple times. + ** For each attempt at picking an index, the order of tables in the + ** join might be different so we have to recompute the usable flag + ** each time. + */ + //pIdxCons = *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint; + //pUsage = pIdxInfo->aConstraintUsage; + for (i = 0; i < pIdxInfo.nConstraint; i++) { + pIdxCons = pIdxInfo.aConstraint[i]; + pUsage = pIdxInfo.aConstraintUsage; + j = pIdxCons.iTermOffset; + pTerm = pWC.a[j]; + pIdxCons.usable = (pTerm.prereqRight & notReady) == 0; + pUsage[i] = new sqlite3_index_constraint_usage(); + } + // memset(pUsage, 0, sizeof(pUsage[0])*pIdxInfo.nConstraint); + if (pIdxInfo.needToFreeIdxStr != 0) { + //sqlite3_free(ref pIdxInfo.idxStr); + } + pIdxInfo.idxStr = null; + pIdxInfo.idxNum = 0; + pIdxInfo.needToFreeIdxStr = 0; + pIdxInfo.orderByConsumed = false; + /* ((double)2) In case of SQLITE_OMIT_FLOATING_POINT... */ + pIdxInfo.estimatedCost = SQLITE_BIG_DBL / ((double)2); + nOrderBy = pIdxInfo.nOrderBy; + if (null == pOrderBy) { + pIdxInfo.nOrderBy = 0; + } - if ( vtabBestIndex( pParse, pTab, pIdxInfo ) != 0 ) - { - return; - } + if (vtabBestIndex(pParse, pTab, pIdxInfo) != 0) { + return; + } - //pIdxCons = (sqlite3_index_constraint)pIdxInfo.aConstraint; - for ( i = 0; i < pIdxInfo.nConstraint; i++ ) - { - if ( pUsage[i].argvIndex > 0 ) - { - //pCost.used |= pWC.a[pIdxCons[i].iTermOffset].prereqRight; - pCost.used |= pWC.a[pIdxInfo.aConstraint[i].iTermOffset].prereqRight; - } - } + //pIdxCons = (sqlite3_index_constraint)pIdxInfo.aConstraint; + for (i = 0; i < pIdxInfo.nConstraint; i++) { + if (pUsage[i].argvIndex > 0) { + //pCost.used |= pWC.a[pIdxCons[i].iTermOffset].prereqRight; + pCost.used |= pWC.a[pIdxInfo.aConstraint[i].iTermOffset].prereqRight; + } + } - /* If there is an ORDER BY clause, and the selected virtual table index - ** does not satisfy it, increase the cost of the scan accordingly. This - ** matches the processing for non-virtual tables in bestBtreeIndex(). - */ - rCost = pIdxInfo.estimatedCost; - if ( pOrderBy != null && !pIdxInfo.orderByConsumed ) - { - rCost += estLog( rCost ) * rCost; - } + /* If there is an ORDER BY clause, and the selected virtual table index + ** does not satisfy it, increase the cost of the scan accordingly. This + ** matches the processing for non-virtual tables in bestBtreeIndex(). + */ + rCost = pIdxInfo.estimatedCost; + if (pOrderBy != null && !pIdxInfo.orderByConsumed) { + rCost += estLog(rCost) * rCost; + } - /* The cost is not allowed to be larger than SQLITE_BIG_DBL (the - ** inital value of lowestCost in this loop. If it is, then the - ** (cost ? AND a < ? ... -** |_____| |_____| -** | | -** pLower pUpper -** -** If either of the upper or lower bound is not present, then NULL is passed in -** place of the corresponding WhereTerm. -** -** The nEq parameter is passed the index of the index column subject to the -** range constraint. Or, equivalently, the number of equality constraints -** optimized by the proposed index scan. For example, assuming index p is -** on t1(a, b), and the SQL query is: -** -** ... FROM t1 WHERE a = ? AND b > ? AND b < ? ... -** -** then nEq should be passed the value 1 (as the range restricted column, -** b, is the second left-most column of the index). Or, if the query is: -** -** ... FROM t1 WHERE a > ? AND a < ? ... -** -** then nEq should be passed 0. -** -** The returned value is an integer between 1 and 100, inclusive. A return -** value of 1 indicates that the proposed range scan is expected to visit -** approximately 1/100th (1%) of the rows selected by the nEq equality -** constraints (if any). A return value of 100 indicates that it is expected -** that the range scan will visit every row (100%) selected by the equality -** constraints. -** -** In the absence of sqlite_stat2 ANALYZE data, each range inequality -** reduces the search space by 3/4ths. Hence a single constraint (x>?) -** results in a return of 25 and a range constraint (x>? AND x123" Might be NULL */ - WhereTerm pUpper, /* Upper bound on the range. ex: "x<455" Might be NULL */ - out int piEst /* OUT: Return value */ - ) - { - int rc = SQLITE_OK; + /* + ** This function is used to estimate the number of rows that will be visited + ** by scanning an index for a range of values. The range may have an upper + ** bound, a lower bound, or both. The WHERE clause terms that set the upper + ** and lower bounds are represented by pLower and pUpper respectively. For + ** example, assuming that index p is on t1(a): + ** + ** ... FROM t1 WHERE a > ? AND a < ? ... + ** |_____| |_____| + ** | | + ** pLower pUpper + ** + ** If either of the upper or lower bound is not present, then NULL is passed in + ** place of the corresponding WhereTerm. + ** + ** The nEq parameter is passed the index of the index column subject to the + ** range constraint. Or, equivalently, the number of equality constraints + ** optimized by the proposed index scan. For example, assuming index p is + ** on t1(a, b), and the SQL query is: + ** + ** ... FROM t1 WHERE a = ? AND b > ? AND b < ? ... + ** + ** then nEq should be passed the value 1 (as the range restricted column, + ** b, is the second left-most column of the index). Or, if the query is: + ** + ** ... FROM t1 WHERE a > ? AND a < ? ... + ** + ** then nEq should be passed 0. + ** + ** The returned value is an integer between 1 and 100, inclusive. A return + ** value of 1 indicates that the proposed range scan is expected to visit + ** approximately 1/100th (1%) of the rows selected by the nEq equality + ** constraints (if any). A return value of 100 indicates that it is expected + ** that the range scan will visit every row (100%) selected by the equality + ** constraints. + ** + ** In the absence of sqlite_stat2 ANALYZE data, each range inequality + ** reduces the search space by 3/4ths. Hence a single constraint (x>?) + ** results in a return of 25 and a range constraint (x>? AND x123" Might be NULL */ + WhereTerm pUpper, /* Upper bound on the range. ex: "x<455" Might be NULL */ + out int piEst /* OUT: Return value */ + ) { + int rc = SQLITE_OK; #if SQLITE_ENABLE_STAT2 @@ -2960,18 +2744,18 @@ static int whereRangeScanEst( } range_est_fallback: #else -UNUSED_PARAMETER(pParse); -UNUSED_PARAMETER(p); -UNUSED_PARAMETER(nEq); + UNUSED_PARAMETER(pParse); + UNUSED_PARAMETER(p); + UNUSED_PARAMETER(nEq); #endif - Debug.Assert( pLower != null || pUpper != null ); - piEst = 100; - if ( pLower != null && ( pLower.wtFlags & TERM_VNULL ) == 0 ) - piEst /= 4; - if ( pUpper != null ) - piEst /= 4; - return rc; - } + Debug.Assert(pLower != null || pUpper != null); + piEst = 100; + if (pLower != null && (pLower.wtFlags & TERM_VNULL) == 0) + piEst /= 4; + if (pUpper != null) + piEst /= 4; + return rc; + } #if SQLITE_ENABLE_STAT2 /* @@ -3140,331 +2924,297 @@ ref double pnRow /* Write the revised row estimate here */ #endif //* defined(SQLITE_ENABLE_STAT2) */ - /* -** Find the best query plan for accessing a particular table. Write the -** best query plan and its cost into the WhereCost object supplied as the -** last parameter. -** -** The lowest cost plan wins. The cost is an estimate of the amount of -** CPU and disk I/O needed to process the requested result. -** Factors that influence cost include: -** -** * The estimated number of rows that will be retrieved. (The -** fewer the better.) -** -** * Whether or not sorting must occur. -** -** * Whether or not there must be separate lookups in the -** index and in the main table. -** -** If there was an INDEXED BY clause (pSrc->pIndex) attached to the table in -** the SQL statement, then this function only considers plans using the -** named index. If no such plan is found, then the returned cost is -** SQLITE_BIG_DBL. If a plan is found that uses the named index, -** then the cost is calculated in the usual way. -** -** If a NOT INDEXED clause (pSrc->notIndexed!=0) was attached to the table -** in the SELECT statement, then no indexes are considered. However, the -** selected plan may still take advantage of the built-in rowid primary key -** index. -*/ - static void bestBtreeIndex( - Parse pParse, /* The parsing context */ - WhereClause pWC, /* The WHERE clause */ - SrcList_item pSrc, /* The FROM clause term to search */ - Bitmask notReady, /* Mask of cursors not available for indexing */ - Bitmask notValid, /* Cursors not available for any purpose */ - ExprList pOrderBy, /* The ORDER BY clause */ - ref WhereCost pCost /* Lowest cost query plan */ - ) - { - int iCur = pSrc.iCursor; /* The cursor of the table to be accessed */ - Index pProbe; /* An index we are evaluating */ - Index pIdx; /* Copy of pProbe, or zero for IPK index */ - u32 eqTermMask; /* Current mask of valid equality operators */ - u32 idxEqTermMask; /* Index mask of valid equality operators */ - Index sPk; /* A fake index object for the primary key */ - int[] aiRowEstPk = new int[2]; /* The aiRowEst[] value for the sPk index */ - int aiColumnPk = -1; /* The aColumn[] value for the sPk index */ - int wsFlagMask; /* Allowed flags in pCost.plan.wsFlag */ - - /* Initialize the cost to a worst-case value */ - if ( pCost == null ) - pCost = new WhereCost(); - else - pCost.Clear(); //memset(pCost, 0, sizeof(*pCost)); - pCost.rCost = SQLITE_BIG_DBL; + /* + ** Find the best query plan for accessing a particular table. Write the + ** best query plan and its cost into the WhereCost object supplied as the + ** last parameter. + ** + ** The lowest cost plan wins. The cost is an estimate of the amount of + ** CPU and disk I/O needed to process the requested result. + ** Factors that influence cost include: + ** + ** * The estimated number of rows that will be retrieved. (The + ** fewer the better.) + ** + ** * Whether or not sorting must occur. + ** + ** * Whether or not there must be separate lookups in the + ** index and in the main table. + ** + ** If there was an INDEXED BY clause (pSrc->pIndex) attached to the table in + ** the SQL statement, then this function only considers plans using the + ** named index. If no such plan is found, then the returned cost is + ** SQLITE_BIG_DBL. If a plan is found that uses the named index, + ** then the cost is calculated in the usual way. + ** + ** If a NOT INDEXED clause (pSrc->notIndexed!=0) was attached to the table + ** in the SELECT statement, then no indexes are considered. However, the + ** selected plan may still take advantage of the built-in rowid primary key + ** index. + */ + static void bestBtreeIndex( + Parse pParse, /* The parsing context */ + WhereClause pWC, /* The WHERE clause */ + SrcList_item pSrc, /* The FROM clause term to search */ + Bitmask notReady, /* Mask of cursors not available for indexing */ + Bitmask notValid, /* Cursors not available for any purpose */ + ExprList pOrderBy, /* The ORDER BY clause */ + ref WhereCost pCost /* Lowest cost query plan */ + ) { + int iCur = pSrc.iCursor; /* The cursor of the table to be accessed */ + Index pProbe; /* An index we are evaluating */ + Index pIdx; /* Copy of pProbe, or zero for IPK index */ + u32 eqTermMask; /* Current mask of valid equality operators */ + u32 idxEqTermMask; /* Index mask of valid equality operators */ + Index sPk; /* A fake index object for the primary key */ + int[] aiRowEstPk = new int[2]; /* The aiRowEst[] value for the sPk index */ + int aiColumnPk = -1; /* The aColumn[] value for the sPk index */ + int wsFlagMask; /* Allowed flags in pCost.plan.wsFlag */ + + /* Initialize the cost to a worst-case value */ + if (pCost == null) + pCost = new WhereCost(); + else + pCost.Clear(); //memset(pCost, 0, sizeof(*pCost)); + pCost.rCost = SQLITE_BIG_DBL; - /* If the pSrc table is the right table of a LEFT JOIN then we may not - ** use an index to satisfy IS NULL constraints on that table. This is - ** because columns might end up being NULL if the table does not match - - ** a circumstance which the index cannot help us discover. Ticket #2177. - */ - if ( ( pSrc.jointype & JT_LEFT ) != 0 ) - { - idxEqTermMask = WO_EQ | WO_IN; - } - else - { - idxEqTermMask = WO_EQ | WO_IN | WO_ISNULL; - } + /* If the pSrc table is the right table of a LEFT JOIN then we may not + ** use an index to satisfy IS NULL constraints on that table. This is + ** because columns might end up being NULL if the table does not match - + ** a circumstance which the index cannot help us discover. Ticket #2177. + */ + if ((pSrc.jointype & JT_LEFT) != 0) { + idxEqTermMask = WO_EQ | WO_IN; + } else { + idxEqTermMask = WO_EQ | WO_IN | WO_ISNULL; + } - if ( pSrc.pIndex != null ) - { - /* An INDEXED BY clause specifies a particular index to use */ - pIdx = pProbe = pSrc.pIndex; - wsFlagMask = ~( WHERE_ROWID_EQ | WHERE_ROWID_RANGE ); - eqTermMask = idxEqTermMask; - } - else - { - /* There is no INDEXED BY clause. Create a fake Index object in local - ** variable sPk to represent the rowid primary key index. Make this - ** fake index the first in a chain of Index objects with all of the real - ** indices to follow */ - Index pFirst; /* First of real indices on the table */ - sPk = new Index(); // memset( &sPk, 0, sizeof( Index ) ); - sPk.aSortOrder = new byte[1]; - sPk.azColl = new string[1]; - sPk.azColl[0] = ""; - sPk.nColumn = 1; - sPk.aiColumn = new int[1]; - sPk.aiColumn[0] = aiColumnPk; - sPk.aiRowEst = aiRowEstPk; - sPk.onError = OE_Replace; - sPk.pTable = pSrc.pTab; - aiRowEstPk[0] = (int)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; - wsFlagMask = ~( - WHERE_COLUMN_IN | WHERE_COLUMN_EQ | WHERE_COLUMN_NULL | WHERE_COLUMN_RANGE - ); - eqTermMask = WO_EQ | WO_IN; - pIdx = null; - } + if (pSrc.pIndex != null) { + /* An INDEXED BY clause specifies a particular index to use */ + pIdx = pProbe = pSrc.pIndex; + wsFlagMask = ~(WHERE_ROWID_EQ | WHERE_ROWID_RANGE); + eqTermMask = idxEqTermMask; + } else { + /* There is no INDEXED BY clause. Create a fake Index object in local + ** variable sPk to represent the rowid primary key index. Make this + ** fake index the first in a chain of Index objects with all of the real + ** indices to follow */ + Index pFirst; /* First of real indices on the table */ + sPk = new Index(); // memset( &sPk, 0, sizeof( Index ) ); + sPk.aSortOrder = new byte[1]; + sPk.azColl = new string[1]; + sPk.azColl[0] = ""; + sPk.nColumn = 1; + sPk.aiColumn = new int[1]; + sPk.aiColumn[0] = aiColumnPk; + sPk.aiRowEst = aiRowEstPk; + sPk.onError = OE_Replace; + sPk.pTable = pSrc.pTab; + aiRowEstPk[0] = (int)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; + wsFlagMask = ~( + WHERE_COLUMN_IN | WHERE_COLUMN_EQ | WHERE_COLUMN_NULL | WHERE_COLUMN_RANGE + ); + eqTermMask = WO_EQ | WO_IN; + pIdx = null; + } - /* Loop over all indices looking for the best one to use - */ - for ( ; pProbe != null; pIdx = pProbe = pProbe.pNext ) - { - int[] aiRowEst = pProbe.aiRowEst; - double cost; /* Cost of using pProbe */ - double nRow; /* Estimated number of rows in result set */ - double log10N = 0; /* base-10 logarithm of nRow (inexact) */ - int rev = 0; /* True to scan in reverse order */ - int wsFlags = 0; - Bitmask used = 0; - - /* The following variables are populated based on the properties of - ** index being evaluated. They are then used to determine the expected - ** cost and number of rows returned. - ** - ** nEq: - ** Number of equality terms that can be implemented using the index. - ** In other words, the number of initial fields in the index that - ** are used in == or IN or NOT NULL constraints of the WHERE clause. - ** - ** nInMul: - ** The "in-multiplier". This is an estimate of how many seek operations - ** SQLite must perform on the index in question. For example, if the - ** WHERE clause is: - ** - ** WHERE a IN (1, 2, 3) AND b IN (4, 5, 6) - ** - ** SQLite must perform 9 lookups on an index on (a, b), so nInMul is - ** set to 9. Given the same schema and either of the following WHERE - ** clauses: - ** - ** WHERE a = 1 - ** WHERE a >= 2 - ** - ** nInMul is set to 1. - ** - ** If there exists a WHERE term of the form "x IN (SELECT ...)", then - ** the sub-select is assumed to return 25 rows for the purposes of - ** determining nInMul. - ** - ** bInEst: - ** Set to true if there was at least one "x IN (SELECT ...)" term used - ** in determining the value of nInMul. Note that the RHS of the - ** IN operator must be a SELECT, not a value list, for this variable - ** to be true. - ** - ** estBound: - ** An estimate on the amount of the table that must be searched. A - ** value of 100 means the entire table is searched. Range constraints - ** might reduce this to a value less than 100 to indicate that only - ** a fraction of the table needs searching. In the absence of - ** sqlite_stat2 ANALYZE data, a single inequality reduces the search - ** space to 1/4rd its original size. So an x>? constraint reduces - ** estBound to 25. Two constraints (x>? AND x= 2 + ** + ** nInMul is set to 1. + ** + ** If there exists a WHERE term of the form "x IN (SELECT ...)", then + ** the sub-select is assumed to return 25 rows for the purposes of + ** determining nInMul. + ** + ** bInEst: + ** Set to true if there was at least one "x IN (SELECT ...)" term used + ** in determining the value of nInMul. Note that the RHS of the + ** IN operator must be a SELECT, not a value list, for this variable + ** to be true. + ** + ** estBound: + ** An estimate on the amount of the table that must be searched. A + ** value of 100 means the entire table is searched. Range constraints + ** might reduce this to a value less than 100 to indicate that only + ** a fraction of the table needs searching. In the absence of + ** sqlite_stat2 ANALYZE data, a single inequality reduces the search + ** space to 1/4rd its original size. So an x>? constraint reduces + ** estBound to 25. Two constraints (x>? AND x aiRowEst[0] ) - { - nRow = aiRowEst[0] / 2; - nInMul = (int)( nRow / aiRowEst[nEq] ); - } + /* + ** Estimate the number of rows of output. For an "x IN (SELECT...)" + ** constraint, do not let the estimate exceed half the rows in the table. + */ + nRow = (double)(aiRowEst[nEq] * nInMul); + if (bInEst != 0 && nRow * 2 > aiRowEst[0]) { + nRow = aiRowEst[0] / 2; + nInMul = (int)(nRow / aiRowEst[nEq]); + } #if SQLITE_ENABLE_STAT2 /* If the constraint is of the form x=VALUE and histogram @@ -3485,164 +3235,142 @@ ref WhereCost pCost /* Lowest cost query plan */ whereInScanEst( pParse, pProbe, pFirstTerm.pExpr.x.pList, ref nRow ); } } -#endif //* SQLITE_ENABLE_STAT2 */ - - /* Adjust the number of output rows and downward to reflect rows - ** that are excluded by range constraints. - */ - nRow = ( nRow * (double)estBound ) / (double)100; - if ( nRow < 1 ) - nRow = 1; - - /* Experiments run on real SQLite databases show that the time needed - ** to do a binary search to locate a row in a table or index is roughly - ** log10(N) times the time to move from one row to the next row within - ** a table or index. The actual times can vary, with the size of - ** records being an important factor. Both moves and searches are - ** slower with larger records, presumably because fewer records fit - ** on one page and hence more pages have to be fetched. - ** - ** The ANALYZE command and the sqlite_stat1 and sqlite_stat2 tables do - ** not give us data on the relative sizes of table and index records. - ** So this computation assumes table records are about twice as big - ** as index records - */ - if ( ( wsFlags & WHERE_NOT_FULLSCAN ) == 0 ) - { - /* The cost of a full table scan is a number of move operations equal - ** to the number of rows in the table. - ** - ** We add an additional 4x penalty to full table scans. This causes - ** the cost function to err on the side of choosing an index over - ** choosing a full scan. This 4x full-scan penalty is an arguable - ** decision and one which we expect to revisit in the future. But - ** it seems to be working well enough at the moment. - */ - cost = aiRowEst[0] * 4; - } - else - { - log10N = estLog( aiRowEst[0] ); - cost = nRow; - if ( pIdx != null ) - { - if ( bLookup != 0 ) - { - /* For an index lookup followed by a table lookup: - ** nInMul index searches to find the start of each index range - ** + nRow steps through the index - ** + nRow table searches to lookup the table entry using the rowid - */ - cost += ( nInMul + nRow ) * log10N; - } - else - { - /* For a covering index: - ** nInMul index searches to find the initial entry - ** + nRow steps through the index - */ - cost += nInMul * log10N; - } - } - else - { - /* For a rowid primary key lookup: - ** nInMult table searches to find the initial entry for each range - ** + nRow steps through the table - */ - cost += nInMul * log10N; - } - } - - /* Add in the estimated cost of sorting the result. Actual experimental - ** measurements of sorting performance in SQLite show that sorting time - ** adds C*N*log10(N) to the cost, where N is the number of rows to be - ** sorted and C is a factor between 1.95 and 4.3. We will split the - ** difference and select C of 3.0. - */ - if ( bSort != 0 ) - { - cost += nRow * estLog( nRow ) * 3; - } +#endif //* SQLITE_ENABLE_STAT2 */ - /**** Cost of using this index has now been computed ****/ + /* Adjust the number of output rows and downward to reflect rows + ** that are excluded by range constraints. + */ + nRow = (nRow * (double)estBound) / (double)100; + if (nRow < 1) + nRow = 1; + + /* Experiments run on real SQLite databases show that the time needed + ** to do a binary search to locate a row in a table or index is roughly + ** log10(N) times the time to move from one row to the next row within + ** a table or index. The actual times can vary, with the size of + ** records being an important factor. Both moves and searches are + ** slower with larger records, presumably because fewer records fit + ** on one page and hence more pages have to be fetched. + ** + ** The ANALYZE command and the sqlite_stat1 and sqlite_stat2 tables do + ** not give us data on the relative sizes of table and index records. + ** So this computation assumes table records are about twice as big + ** as index records + */ + if ((wsFlags & WHERE_NOT_FULLSCAN) == 0) { + /* The cost of a full table scan is a number of move operations equal + ** to the number of rows in the table. + ** + ** We add an additional 4x penalty to full table scans. This causes + ** the cost function to err on the side of choosing an index over + ** choosing a full scan. This 4x full-scan penalty is an arguable + ** decision and one which we expect to revisit in the future. But + ** it seems to be working well enough at the moment. + */ + cost = aiRowEst[0] * 4; + } else { + log10N = estLog(aiRowEst[0]); + cost = nRow; + if (pIdx != null) { + if (bLookup != 0) { + /* For an index lookup followed by a table lookup: + ** nInMul index searches to find the start of each index range + ** + nRow steps through the index + ** + nRow table searches to lookup the table entry using the rowid + */ + cost += (nInMul + nRow) * log10N; + } else { + /* For a covering index: + ** nInMul index searches to find the initial entry + ** + nRow steps through the index + */ + cost += nInMul * log10N; + } + } else { + /* For a rowid primary key lookup: + ** nInMult table searches to find the initial entry for each range + ** + nRow steps through the table + */ + cost += nInMul * log10N; + } + } - /* If there are additional constraints on this table that cannot - ** be used with the current index, but which might lower the number - ** of output rows, adjust the nRow value accordingly. This only - ** matters if the current index is the least costly, so do not bother - ** with this step if we already know this index will not be chosen. - ** Also, never reduce the output row count below 2 using this step. - ** - ** It is critical that the notValid mask be used here instead of - ** the notReady mask. When computing an "optimal" index, the notReady - ** mask will only have one bit set - the bit for the current table. - ** The notValid mask, on the other hand, always has all bits set for - ** tables that are not in outer loops. If notReady is used here instead - ** of notValid, then a optimal index that depends on inner joins loops - ** might be selected even when there exists an optimal index that has - ** no such dependency. - */ - if ( nRow > 2 && cost <= pCost.rCost ) - { - //int k; /* Loop counter */ - int nSkipEq = nEq; /* Number of == constraints to skip */ - int nSkipRange = nBound; /* Number of < constraints to skip */ - Bitmask thisTab; /* Bitmap for pSrc */ + /* Add in the estimated cost of sorting the result. Actual experimental + ** measurements of sorting performance in SQLite show that sorting time + ** adds C*N*log10(N) to the cost, where N is the number of rows to be + ** sorted and C is a factor between 1.95 and 4.3. We will split the + ** difference and select C of 3.0. + */ + if (bSort != 0) { + cost += nRow * estLog(nRow) * 3; + } - thisTab = getMask( pWC.pMaskSet, iCur ); - for ( int ipTerm = 0, k = pWC.nTerm; nRow > 2 && k != 0; k--, ipTerm++ )//pTerm++) - { - pTerm = pWC.a[ipTerm]; - if ( ( pTerm.wtFlags & TERM_VIRTUAL ) != 0 ) - continue; - if ( ( pTerm.prereqAll & notValid ) != thisTab ) - continue; - if ( ( pTerm.eOperator & ( WO_EQ | WO_IN | WO_ISNULL ) ) != 0 ) - { - if ( nSkipEq != 0 ) - { - /* Ignore the first nEq equality matches since the index - ** has already accounted for these */ - nSkipEq--; - } - else - { - /* Assume each additional equality match reduces the result - ** set size by a factor of 10 */ - nRow /= 10; - } - } - else if ( ( pTerm.eOperator & ( WO_LT | WO_LE | WO_GT | WO_GE ) ) != 0 ) - { - if ( nSkipRange != 0 ) - { - /* Ignore the first nSkipRange range constraints since the index - ** has already accounted for these */ - nSkipRange--; - } - else - { - /* Assume each additional range constraint reduces the result - ** set size by a factor of 3. Indexed range constraints reduce - ** the search space by a larger factor: 4. We make indexed range - ** more selective intentionally because of the subjective - ** observation that indexed range constraints really are more - ** selective in practice, on average. */ - nRow /= 3; - } - } - else if ( pTerm.eOperator != WO_NOOP ) - { - /* Any other expression lowers the output row count by half */ - nRow /= 2; - } - } - if ( nRow < 2 ) - nRow = 2; - } + /**** Cost of using this index has now been computed ****/ + + /* If there are additional constraints on this table that cannot + ** be used with the current index, but which might lower the number + ** of output rows, adjust the nRow value accordingly. This only + ** matters if the current index is the least costly, so do not bother + ** with this step if we already know this index will not be chosen. + ** Also, never reduce the output row count below 2 using this step. + ** + ** It is critical that the notValid mask be used here instead of + ** the notReady mask. When computing an "optimal" index, the notReady + ** mask will only have one bit set - the bit for the current table. + ** The notValid mask, on the other hand, always has all bits set for + ** tables that are not in outer loops. If notReady is used here instead + ** of notValid, then a optimal index that depends on inner joins loops + ** might be selected even when there exists an optimal index that has + ** no such dependency. + */ + if (nRow > 2 && cost <= pCost.rCost) { + //int k; /* Loop counter */ + int nSkipEq = nEq; /* Number of == constraints to skip */ + int nSkipRange = nBound; /* Number of < constraints to skip */ + Bitmask thisTab; /* Bitmap for pSrc */ + + thisTab = getMask(pWC.pMaskSet, iCur); + for (int ipTerm = 0, k = pWC.nTerm; nRow > 2 && k != 0; k--, ipTerm++)//pTerm++) + { + pTerm = pWC.a[ipTerm]; + if ((pTerm.wtFlags & TERM_VIRTUAL) != 0) + continue; + if ((pTerm.prereqAll & notValid) != thisTab) + continue; + if ((pTerm.eOperator & (WO_EQ | WO_IN | WO_ISNULL)) != 0) { + if (nSkipEq != 0) { + /* Ignore the first nEq equality matches since the index + ** has already accounted for these */ + nSkipEq--; + } else { + /* Assume each additional equality match reduces the result + ** set size by a factor of 10 */ + nRow /= 10; + } + } else if ((pTerm.eOperator & (WO_LT | WO_LE | WO_GT | WO_GE)) != 0) { + if (nSkipRange != 0) { + /* Ignore the first nSkipRange range constraints since the index + ** has already accounted for these */ + nSkipRange--; + } else { + /* Assume each additional range constraint reduces the result + ** set size by a factor of 3. Indexed range constraints reduce + ** the search space by a larger factor: 4. We make indexed range + ** more selective intentionally because of the subjective + ** observation that indexed range constraints really are more + ** selective in practice, on average. */ + nRow /= 3; + } + } else if (pTerm.eOperator != WO_NOOP) { + /* Any other expression lowers the output row count by half */ + nRow /= 2; + } + } + if (nRow < 2) + nRow = 2; + } -#if (SQLITE_TEST) && (SQLITE_DEBUG) +#if (SQLITE_TEST) && (SQLITE_DEBUG) WHERETRACE( "%s(%s): nEq=%d nInMul=%d estBound=%d bSort=%d bLookup=%d wsFlags=0x%x\n" + " notReady=0x%llx log10N=%.1f nRow=%.1f cost=%.1f used=0x%llx\n", @@ -3651,836 +3379,749 @@ ref WhereCost pCost /* Lowest cost query plan */ notReady, log10N, cost, used ); #endif - /* If this index is the best we have seen so far, then record this -** index and its cost in the pCost structure. -*/ - if ( ( null == pIdx || wsFlags != 0 ) - && ( cost < pCost.rCost || ( cost <= pCost.rCost && nRow < pCost.plan.nRow ) ) - ) - { - pCost.rCost = cost; - pCost.used = used; - pCost.plan.nRow = nRow; - pCost.plan.wsFlags = (uint)( wsFlags & wsFlagMask ); - pCost.plan.nEq = (uint)nEq; - pCost.plan.u.pIdx = pIdx; - } + /* If this index is the best we have seen so far, then record this + ** index and its cost in the pCost structure. + */ + if ((null == pIdx || wsFlags != 0) + && (cost < pCost.rCost || (cost <= pCost.rCost && nRow < pCost.plan.nRow)) + ) { + pCost.rCost = cost; + pCost.used = used; + pCost.plan.nRow = nRow; + pCost.plan.wsFlags = (uint)(wsFlags & wsFlagMask); + pCost.plan.nEq = (uint)nEq; + pCost.plan.u.pIdx = pIdx; + } - /* If there was an INDEXED BY clause, then only that one index is - ** considered. */ - if ( pSrc.pIndex != null ) - break; + /* If there was an INDEXED BY clause, then only that one index is + ** considered. */ + if (pSrc.pIndex != null) + break; - /* Reset masks for the next index in the loop */ - wsFlagMask = ~( WHERE_ROWID_EQ | WHERE_ROWID_RANGE ); - eqTermMask = idxEqTermMask; - } + /* Reset masks for the next index in the loop */ + wsFlagMask = ~(WHERE_ROWID_EQ | WHERE_ROWID_RANGE); + eqTermMask = idxEqTermMask; + } - /* If there is no ORDER BY clause and the SQLITE_ReverseOrder flag - ** is set, then reverse the order that the index will be scanned - ** in. This is used for application testing, to help find cases - ** where application behaviour depends on the (undefined) order that - ** SQLite outputs rows in in the absence of an ORDER BY clause. */ - if ( null == pOrderBy && ( pParse.db.flags & SQLITE_ReverseOrder ) != 0 ) - { - pCost.plan.wsFlags |= WHERE_REVERSE; - } + /* If there is no ORDER BY clause and the SQLITE_ReverseOrder flag + ** is set, then reverse the order that the index will be scanned + ** in. This is used for application testing, to help find cases + ** where application behaviour depends on the (undefined) order that + ** SQLite outputs rows in in the absence of an ORDER BY clause. */ + if (null == pOrderBy && (pParse.db.flags & SQLITE_ReverseOrder) != 0) { + pCost.plan.wsFlags |= WHERE_REVERSE; + } - Debug.Assert( pOrderBy != null || ( pCost.plan.wsFlags & WHERE_ORDERBY ) == 0 ); - Debug.Assert( pCost.plan.u.pIdx == null || ( pCost.plan.wsFlags & WHERE_ROWID_EQ ) == 0 ); - Debug.Assert( pSrc.pIndex == null - || pCost.plan.u.pIdx == null - || pCost.plan.u.pIdx == pSrc.pIndex - ); + Debug.Assert(pOrderBy != null || (pCost.plan.wsFlags & WHERE_ORDERBY) == 0); + Debug.Assert(pCost.plan.u.pIdx == null || (pCost.plan.wsFlags & WHERE_ROWID_EQ) == 0); + Debug.Assert(pSrc.pIndex == null + || pCost.plan.u.pIdx == null + || pCost.plan.u.pIdx == pSrc.pIndex + ); -#if (SQLITE_TEST) && (SQLITE_DEBUG) +#if (SQLITE_TEST) && (SQLITE_DEBUG) WHERETRACE( "best index is: %s\n", ( ( pCost.plan.wsFlags & WHERE_NOT_FULLSCAN ) == 0 ? "none" : pCost.plan.u.pIdx != null ? pCost.plan.u.pIdx.zName : "ipk" ) ); #endif - bestOrClauseIndex( pParse, pWC, pSrc, notReady, notValid, pOrderBy, pCost ); - bestAutomaticIndex( pParse, pWC, pSrc, notReady, pCost ); - pCost.plan.wsFlags |= (u32)eqTermMask; - } + bestOrClauseIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, pCost); + bestAutomaticIndex(pParse, pWC, pSrc, notReady, pCost); + pCost.plan.wsFlags |= (u32)eqTermMask; + } - /* - ** Find the query plan for accessing table pSrc.pTab. Write the - ** best query plan and its cost into the WhereCost object supplied - ** as the last parameter. This function may calculate the cost of - ** both real and virtual table scans. - */ - static void bestIndex( - Parse pParse, /* The parsing context */ - WhereClause pWC, /* The WHERE clause */ - SrcList_item pSrc, /* The FROM clause term to search */ - Bitmask notReady, /* Mask of cursors not available for indexing */ - Bitmask notValid, /* Cursors not available for any purpose */ - ExprList pOrderBy, /* The ORDER BY clause */ - ref WhereCost pCost /* Lowest cost query plan */ - ) - { + /* + ** Find the query plan for accessing table pSrc.pTab. Write the + ** best query plan and its cost into the WhereCost object supplied + ** as the last parameter. This function may calculate the cost of + ** both real and virtual table scans. + */ + static void bestIndex( + Parse pParse, /* The parsing context */ + WhereClause pWC, /* The WHERE clause */ + SrcList_item pSrc, /* The FROM clause term to search */ + Bitmask notReady, /* Mask of cursors not available for indexing */ + Bitmask notValid, /* Cursors not available for any purpose */ + ExprList pOrderBy, /* The ORDER BY clause */ + ref WhereCost pCost /* Lowest cost query plan */ + ) { #if !SQLITE_OMIT_VIRTUALTABLE - if ( IsVirtual( pSrc.pTab ) ) - { - sqlite3_index_info p = null; - bestVirtualIndex( pParse, pWC, pSrc, notReady, notValid, pOrderBy, ref pCost, ref p ); - if ( p.needToFreeIdxStr != 0 ) - { - //sqlite3_free(ref p.idxStr); - } - sqlite3DbFree( pParse.db, ref p ); - } - else + if (IsVirtual(pSrc.pTab)) { + sqlite3_index_info p = null; + bestVirtualIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, ref pCost, ref p); + if (p.needToFreeIdxStr != 0) { + //sqlite3_free(ref p.idxStr); + } + sqlite3DbFree(pParse.db, ref p); + } else #endif - { - bestBtreeIndex( pParse, pWC, pSrc, notReady, notValid, pOrderBy, ref pCost ); - } - } - - /* - ** Disable a term in the WHERE clause. Except, do not disable the term - ** if it controls a LEFT OUTER JOIN and it did not originate in the ON - ** or USING clause of that join. - ** - ** Consider the term t2.z='ok' in the following queries: - ** - ** (1) SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x WHERE t2.z='ok' - ** (2) SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x AND t2.z='ok' - ** (3) SELECT * FROM t1, t2 WHERE t1.a=t2.x AND t2.z='ok' - ** - ** The t2.z='ok' is disabled in the in (2) because it originates - ** in the ON clause. The term is disabled in (3) because it is not part - ** of a LEFT OUTER JOIN. In (1), the term is not disabled. - ** - ** IMPLEMENTATION-OF: R-24597-58655 No tests are done for terms that are - ** completely satisfied by indices. - ** - ** Disabling a term causes that term to not be tested in the inner loop - ** of the join. Disabling is an optimization. When terms are satisfied - ** by indices, we disable them to prevent redundant tests in the inner - ** loop. We would get the correct results if nothing were ever disabled, - ** but joins might run a little slower. The trick is to disable as much - ** as we can without disabling too much. If we disabled in (1), we'd get - ** the wrong answer. See ticket #813. - */ - static void disableTerm( WhereLevel pLevel, WhereTerm pTerm ) - { - if ( pTerm != null - && ( pTerm.wtFlags & TERM_CODED ) == 0 - && ( pLevel.iLeftJoin == 0 || ExprHasProperty( pTerm.pExpr, EP_FromJoin ) ) ) - { - pTerm.wtFlags |= TERM_CODED; - if ( pTerm.iParent >= 0 ) - { - WhereTerm pOther = pTerm.pWC.a[pTerm.iParent]; - if ( ( --pOther.nChild ) == 0 ) - { - disableTerm( pLevel, pOther ); - } + { + bestBtreeIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, ref pCost); + } } - } - } - - /* - ** Code an OP_Affinity opcode to apply the column affinity string zAff - ** to the n registers starting at base. - ** - ** As an optimization, SQLITE_AFF_NONE entries (which are no-ops) at the - ** beginning and end of zAff are ignored. If all entries in zAff are - ** SQLITE_AFF_NONE, then no code gets generated. - ** - ** This routine makes its own copy of zAff so that the caller is free - ** to modify zAff after this routine returns. - */ - static void codeApplyAffinity( Parse pParse, int _base, int n, string zAff ) - { - Vdbe v = pParse.pVdbe; - //if (zAff == 0) - //{ - // Debug.Assert(pParse.db.mallocFailed); - // return; - //} - Debug.Assert( v != null ); - /* Adjust base and n to skip over SQLITE_AFF_NONE entries at the beginning - ** and end of the affinity string. - */ - while ( n > 0 && zAff[0] == SQLITE_AFF_NONE ) - { - n--; - _base++; - zAff = zAff.Substring( 1 );// zAff++; - } - while ( n > 1 && zAff[n - 1] == SQLITE_AFF_NONE ) - { - n--; - } - /* Code the OP_Affinity opcode if there is anything left to do. */ - if ( n > 0 ) - { - sqlite3VdbeAddOp2( v, OP_Affinity, _base, n ); - sqlite3VdbeChangeP4( v, -1, zAff, n ); - sqlite3ExprCacheAffinityChange( pParse, _base, n ); - } - } + /* + ** Disable a term in the WHERE clause. Except, do not disable the term + ** if it controls a LEFT OUTER JOIN and it did not originate in the ON + ** or USING clause of that join. + ** + ** Consider the term t2.z='ok' in the following queries: + ** + ** (1) SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x WHERE t2.z='ok' + ** (2) SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x AND t2.z='ok' + ** (3) SELECT * FROM t1, t2 WHERE t1.a=t2.x AND t2.z='ok' + ** + ** The t2.z='ok' is disabled in the in (2) because it originates + ** in the ON clause. The term is disabled in (3) because it is not part + ** of a LEFT OUTER JOIN. In (1), the term is not disabled. + ** + ** IMPLEMENTATION-OF: R-24597-58655 No tests are done for terms that are + ** completely satisfied by indices. + ** + ** Disabling a term causes that term to not be tested in the inner loop + ** of the join. Disabling is an optimization. When terms are satisfied + ** by indices, we disable them to prevent redundant tests in the inner + ** loop. We would get the correct results if nothing were ever disabled, + ** but joins might run a little slower. The trick is to disable as much + ** as we can without disabling too much. If we disabled in (1), we'd get + ** the wrong answer. See ticket #813. + */ + static void disableTerm(WhereLevel pLevel, WhereTerm pTerm) { + if (pTerm != null + && (pTerm.wtFlags & TERM_CODED) == 0 + && (pLevel.iLeftJoin == 0 || ExprHasProperty(pTerm.pExpr, EP_FromJoin))) { + pTerm.wtFlags |= TERM_CODED; + if (pTerm.iParent >= 0) { + WhereTerm pOther = pTerm.pWC.a[pTerm.iParent]; + if ((--pOther.nChild) == 0) { + disableTerm(pLevel, pOther); + } + } + } + } - /* - ** Generate code for a single equality term of the WHERE clause. An equality - ** term can be either X=expr or X IN (...). pTerm is the term to be - ** coded. - ** - ** The current value for the constraint is left in register iReg. - ** - ** For a constraint of the form X=expr, the expression is evaluated and its - ** result is left on the stack. For constraints of the form X IN (...) - ** this routine sets up a loop that will iterate over all values of X. - */ - static int codeEqualityTerm( - Parse pParse, /* The parsing context */ - WhereTerm pTerm, /* The term of the WHERE clause to be coded */ - WhereLevel pLevel, /* When level of the FROM clause we are working on */ - int iTarget /* Attempt to leave results in this register */ - ) - { - Expr pX = pTerm.pExpr; - Vdbe v = pParse.pVdbe; - int iReg; /* Register holding results */ + /* + ** Code an OP_Affinity opcode to apply the column affinity string zAff + ** to the n registers starting at base. + ** + ** As an optimization, SQLITE_AFF_NONE entries (which are no-ops) at the + ** beginning and end of zAff are ignored. If all entries in zAff are + ** SQLITE_AFF_NONE, then no code gets generated. + ** + ** This routine makes its own copy of zAff so that the caller is free + ** to modify zAff after this routine returns. + */ + static void codeApplyAffinity(Parse pParse, int _base, int n, string zAff) { + Vdbe v = pParse.pVdbe; + //if (zAff == 0) + //{ + // Debug.Assert(pParse.db.mallocFailed); + // return; + //} + Debug.Assert(v != null); + /* Adjust base and n to skip over SQLITE_AFF_NONE entries at the beginning + ** and end of the affinity string. + */ + while (n > 0 && zAff[0] == SQLITE_AFF_NONE) { + n--; + _base++; + zAff = zAff.Substring(1);// zAff++; + } + while (n > 1 && zAff[n - 1] == SQLITE_AFF_NONE) { + n--; + } - Debug.Assert( iTarget > 0 ); - if ( pX.op == TK_EQ ) - { - iReg = sqlite3ExprCodeTarget( pParse, pX.pRight, iTarget ); - } - else if ( pX.op == TK_ISNULL ) - { - iReg = iTarget; - sqlite3VdbeAddOp2( v, OP_Null, 0, iReg ); -#if !SQLITE_OMIT_SUBQUERY - } - else - { - int eType; - int iTab; - InLoop pIn; - - Debug.Assert( pX.op == TK_IN ); - iReg = iTarget; - int iDummy = -1; - eType = sqlite3FindInIndex( pParse, pX, ref iDummy ); - iTab = pX.iTable; - sqlite3VdbeAddOp2( v, OP_Rewind, iTab, 0 ); - Debug.Assert( ( pLevel.plan.wsFlags & WHERE_IN_ABLE ) != 0 ); - if ( pLevel.u._in.nIn == 0 ) - { - pLevel.addrNxt = sqlite3VdbeMakeLabel( v ); - } - pLevel.u._in.nIn++; - if ( pLevel.u._in.aInLoop == null ) - pLevel.u._in.aInLoop = new InLoop[pLevel.u._in.nIn]; - else - Array.Resize( ref pLevel.u._in.aInLoop, pLevel.u._in.nIn ); - //sqlite3DbReallocOrFree(pParse.db, pLevel.u._in.aInLoop, - // sizeof(pLevel.u._in.aInLoop[0])*pLevel.u._in.nIn); - //pIn = pLevel.u._in.aInLoop; - if ( pLevel.u._in.aInLoop != null )//(pIn ) - { - pLevel.u._in.aInLoop[pLevel.u._in.nIn - 1] = new InLoop(); - pIn = pLevel.u._in.aInLoop[pLevel.u._in.nIn - 1];//pIn++ - pIn.iCur = iTab; - if ( eType == IN_INDEX_ROWID ) - { - pIn.addrInTop = sqlite3VdbeAddOp2( v, OP_Rowid, iTab, iReg ); - } - else - { - pIn.addrInTop = sqlite3VdbeAddOp3( v, OP_Column, iTab, 0, iReg ); - } - sqlite3VdbeAddOp1( v, OP_IsNull, iReg ); - } - else - { - pLevel.u._in.nIn = 0; + /* Code the OP_Affinity opcode if there is anything left to do. */ + if (n > 0) { + sqlite3VdbeAddOp2(v, OP_Affinity, _base, n); + sqlite3VdbeChangeP4(v, -1, zAff, n); + sqlite3ExprCacheAffinityChange(pParse, _base, n); + } } + + /* + ** Generate code for a single equality term of the WHERE clause. An equality + ** term can be either X=expr or X IN (...). pTerm is the term to be + ** coded. + ** + ** The current value for the constraint is left in register iReg. + ** + ** For a constraint of the form X=expr, the expression is evaluated and its + ** result is left on the stack. For constraints of the form X IN (...) + ** this routine sets up a loop that will iterate over all values of X. + */ + static int codeEqualityTerm( + Parse pParse, /* The parsing context */ + WhereTerm pTerm, /* The term of the WHERE clause to be coded */ + WhereLevel pLevel, /* When level of the FROM clause we are working on */ + int iTarget /* Attempt to leave results in this register */ + ) { + Expr pX = pTerm.pExpr; + Vdbe v = pParse.pVdbe; + int iReg; /* Register holding results */ + + Debug.Assert(iTarget > 0); + if (pX.op == TK_EQ) { + iReg = sqlite3ExprCodeTarget(pParse, pX.pRight, iTarget); + } else if (pX.op == TK_ISNULL) { + iReg = iTarget; + sqlite3VdbeAddOp2(v, OP_Null, 0, iReg); +#if !SQLITE_OMIT_SUBQUERY + } else { + int eType; + int iTab; + InLoop pIn; + + Debug.Assert(pX.op == TK_IN); + iReg = iTarget; + int iDummy = -1; + eType = sqlite3FindInIndex(pParse, pX, ref iDummy); + iTab = pX.iTable; + sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0); + Debug.Assert((pLevel.plan.wsFlags & WHERE_IN_ABLE) != 0); + if (pLevel.u._in.nIn == 0) { + pLevel.addrNxt = sqlite3VdbeMakeLabel(v); + } + pLevel.u._in.nIn++; + if (pLevel.u._in.aInLoop == null) + pLevel.u._in.aInLoop = new InLoop[pLevel.u._in.nIn]; + else + Array.Resize(ref pLevel.u._in.aInLoop, pLevel.u._in.nIn); + //sqlite3DbReallocOrFree(pParse.db, pLevel.u._in.aInLoop, + // sizeof(pLevel.u._in.aInLoop[0])*pLevel.u._in.nIn); + //pIn = pLevel.u._in.aInLoop; + if (pLevel.u._in.aInLoop != null)//(pIn ) + { + pLevel.u._in.aInLoop[pLevel.u._in.nIn - 1] = new InLoop(); + pIn = pLevel.u._in.aInLoop[pLevel.u._in.nIn - 1];//pIn++ + pIn.iCur = iTab; + if (eType == IN_INDEX_ROWID) { + pIn.addrInTop = sqlite3VdbeAddOp2(v, OP_Rowid, iTab, iReg); + } else { + pIn.addrInTop = sqlite3VdbeAddOp3(v, OP_Column, iTab, 0, iReg); + } + sqlite3VdbeAddOp1(v, OP_IsNull, iReg); + } else { + pLevel.u._in.nIn = 0; + } #endif - } - disableTerm( pLevel, pTerm ); - return iReg; - } + } + disableTerm(pLevel, pTerm); + return iReg; + } - /* - ** Generate code for a single equality term of the WHERE clause. An equality - ** term can be either X=expr or X IN (...). pTerm is the term to be - ** coded. - ** - ** For example, consider table t1(a,b,c,d,e,f) with index i1(a,b,c). - ** Suppose the WHERE clause is this: a==5 AND b IN (1,2,3) AND c>5 AND c<10 - ** The index has as many as three equality constraints, but in this - ** example, the third "c" value is an inequality. So only two - ** constraints are coded. This routine will generate code to evaluate - ** a==5 and b IN (1,2,3). The current values for a and b will be stored - ** in consecutive registers and the index of the first register is returned. - ** - ** In the example above nEq==2. But this subroutine works for any value - ** of nEq including 0. If nEq==null, this routine is nearly a no-op. - ** The only thing it does is allocate the pLevel.iMem memory cell and - ** compute the affinity string. - ** - ** This routine always allocates at least one memory cell and returns - ** the index of that memory cell. The code that - ** calls this routine will use that memory cell to store the termination - ** key value of the loop. If one or more IN operators appear, then - ** this routine allocates an additional nEq memory cells for internal - ** use. - ** - ** Before returning, *pzAff is set to point to a buffer containing a - ** copy of the column affinity string of the index allocated using - ** sqlite3DbMalloc(). Except, entries in the copy of the string associated - ** with equality constraints that use NONE affinity are set to - ** SQLITE_AFF_NONE. This is to deal with SQL such as the following: - ** - ** CREATE TABLE t1(a TEXT PRIMARY KEY, b); - ** SELECT ... FROM t1 AS t2, t1 WHERE t1.a = t2.b; - ** - ** In the example above, the index on t1(a) has TEXT affinity. But since - ** the right hand side of the equality constraint (t2.b) has NONE affinity, - ** no conversion should be attempted before using a t2.b value as part of - ** a key to search the index. Hence the first byte in the returned affinity - ** string in this example would be set to SQLITE_AFF_NONE. - */ - static int codeAllEqualityTerms( - Parse pParse, /* Parsing context */ - WhereLevel pLevel, /* Which nested loop of the FROM we are coding */ - WhereClause pWC, /* The WHERE clause */ - Bitmask notReady, /* Which parts of FROM have not yet been coded */ - int nExtraReg, /* Number of extra registers to allocate */ - out StringBuilder pzAff /* OUT: Set to point to affinity string */ - ) - { - int nEq = (int)pLevel.plan.nEq; /* The number of == or IN constraints to code */ - Vdbe v = pParse.pVdbe; /* The vm under construction */ - Index pIdx; /* The index being used for this loop */ - int iCur = pLevel.iTabCur; /* The cursor of the table */ - WhereTerm pTerm; /* A single constraint term */ - int j; /* Loop counter */ - int regBase; /* Base register */ - int nReg; /* Number of registers to allocate */ - StringBuilder zAff; /* Affinity string to return */ - - /* This module is only called on query plans that use an index. */ - Debug.Assert( ( pLevel.plan.wsFlags & WHERE_INDEXED ) != 0 ); - pIdx = pLevel.plan.u.pIdx; - - /* Figure out how many memory cells we will need then allocate them. - */ - regBase = pParse.nMem + 1; - nReg = (int)( pLevel.plan.nEq + nExtraReg ); - pParse.nMem += nReg; + /* + ** Generate code for a single equality term of the WHERE clause. An equality + ** term can be either X=expr or X IN (...). pTerm is the term to be + ** coded. + ** + ** For example, consider table t1(a,b,c,d,e,f) with index i1(a,b,c). + ** Suppose the WHERE clause is this: a==5 AND b IN (1,2,3) AND c>5 AND c<10 + ** The index has as many as three equality constraints, but in this + ** example, the third "c" value is an inequality. So only two + ** constraints are coded. This routine will generate code to evaluate + ** a==5 and b IN (1,2,3). The current values for a and b will be stored + ** in consecutive registers and the index of the first register is returned. + ** + ** In the example above nEq==2. But this subroutine works for any value + ** of nEq including 0. If nEq==null, this routine is nearly a no-op. + ** The only thing it does is allocate the pLevel.iMem memory cell and + ** compute the affinity string. + ** + ** This routine always allocates at least one memory cell and returns + ** the index of that memory cell. The code that + ** calls this routine will use that memory cell to store the termination + ** key value of the loop. If one or more IN operators appear, then + ** this routine allocates an additional nEq memory cells for internal + ** use. + ** + ** Before returning, *pzAff is set to point to a buffer containing a + ** copy of the column affinity string of the index allocated using + ** sqlite3DbMalloc(). Except, entries in the copy of the string associated + ** with equality constraints that use NONE affinity are set to + ** SQLITE_AFF_NONE. This is to deal with SQL such as the following: + ** + ** CREATE TABLE t1(a TEXT PRIMARY KEY, b); + ** SELECT ... FROM t1 AS t2, t1 WHERE t1.a = t2.b; + ** + ** In the example above, the index on t1(a) has TEXT affinity. But since + ** the right hand side of the equality constraint (t2.b) has NONE affinity, + ** no conversion should be attempted before using a t2.b value as part of + ** a key to search the index. Hence the first byte in the returned affinity + ** string in this example would be set to SQLITE_AFF_NONE. + */ + static int codeAllEqualityTerms( + Parse pParse, /* Parsing context */ + WhereLevel pLevel, /* Which nested loop of the FROM we are coding */ + WhereClause pWC, /* The WHERE clause */ + Bitmask notReady, /* Which parts of FROM have not yet been coded */ + int nExtraReg, /* Number of extra registers to allocate */ + out StringBuilder pzAff /* OUT: Set to point to affinity string */ + ) { + int nEq = (int)pLevel.plan.nEq; /* The number of == or IN constraints to code */ + Vdbe v = pParse.pVdbe; /* The vm under construction */ + Index pIdx; /* The index being used for this loop */ + int iCur = pLevel.iTabCur; /* The cursor of the table */ + WhereTerm pTerm; /* A single constraint term */ + int j; /* Loop counter */ + int regBase; /* Base register */ + int nReg; /* Number of registers to allocate */ + StringBuilder zAff; /* Affinity string to return */ + + /* This module is only called on query plans that use an index. */ + Debug.Assert((pLevel.plan.wsFlags & WHERE_INDEXED) != 0); + pIdx = pLevel.plan.u.pIdx; + + /* Figure out how many memory cells we will need then allocate them. + */ + regBase = pParse.nMem + 1; + nReg = (int)(pLevel.plan.nEq + nExtraReg); + pParse.nMem += nReg; - zAff = new StringBuilder( sqlite3IndexAffinityStr( v, pIdx ) );//sqlite3DbStrDup(pParse.db, sqlite3IndexAffinityStr(v, pIdx)); - //if( null==zAff ){ - // pParse.db.mallocFailed = 1; - //} + zAff = new StringBuilder(sqlite3IndexAffinityStr(v, pIdx));//sqlite3DbStrDup(pParse.db, sqlite3IndexAffinityStr(v, pIdx)); + //if( null==zAff ){ + // pParse.db.mallocFailed = 1; + //} - /* Evaluate the equality constraints - */ - Debug.Assert( pIdx.nColumn >= nEq ); - for ( j = 0; j < nEq; j++ ) - { - int r1; - int k = pIdx.aiColumn[j]; - pTerm = findTerm( pWC, iCur, k, notReady, pLevel.plan.wsFlags, pIdx ); - if ( NEVER( pTerm == null ) ) - break; - /* The following true for indices with redundant columns. - ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */ - testcase( ( pTerm.wtFlags & TERM_CODED ) != 0 ); - testcase( pTerm.wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ - r1 = codeEqualityTerm( pParse, pTerm, pLevel, regBase + j ); - if ( r1 != regBase + j ) - { - if ( nReg == 1 ) - { - sqlite3ReleaseTempReg( pParse, regBase ); - regBase = r1; - } - else - { - sqlite3VdbeAddOp2( v, OP_SCopy, r1, regBase + j ); - } - } - testcase( pTerm.eOperator & WO_ISNULL ); - testcase( pTerm.eOperator & WO_IN ); - if ( ( pTerm.eOperator & ( WO_ISNULL | WO_IN ) ) == 0 ) - { - Expr pRight = pTerm.pExpr.pRight; - sqlite3ExprCodeIsNullJump( v, pRight, regBase + j, pLevel.addrBrk ); - if ( zAff.Length > 0 ) - { - if ( sqlite3CompareAffinity( pRight, zAff[j] ) == SQLITE_AFF_NONE ) - { - zAff[j] = SQLITE_AFF_NONE; - } - if ( ( sqlite3ExprNeedsNoAffinityChange( pRight, zAff[j] ) ) != 0 ) - { - zAff[j] = SQLITE_AFF_NONE; + /* Evaluate the equality constraints + */ + Debug.Assert(pIdx.nColumn >= nEq); + for (j = 0; j < nEq; j++) { + int r1; + int k = pIdx.aiColumn[j]; + pTerm = findTerm(pWC, iCur, k, notReady, pLevel.plan.wsFlags, pIdx); + if (NEVER(pTerm == null)) + break; + /* The following true for indices with redundant columns. + ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */ + testcase((pTerm.wtFlags & TERM_CODED) != 0); + testcase(pTerm.wtFlags & TERM_VIRTUAL); /* EV: R-30575-11662 */ + r1 = codeEqualityTerm(pParse, pTerm, pLevel, regBase + j); + if (r1 != regBase + j) { + if (nReg == 1) { + sqlite3ReleaseTempReg(pParse, regBase); + regBase = r1; + } else { + sqlite3VdbeAddOp2(v, OP_SCopy, r1, regBase + j); + } + } + testcase(pTerm.eOperator & WO_ISNULL); + testcase(pTerm.eOperator & WO_IN); + if ((pTerm.eOperator & (WO_ISNULL | WO_IN)) == 0) { + Expr pRight = pTerm.pExpr.pRight; + sqlite3ExprCodeIsNullJump(v, pRight, regBase + j, pLevel.addrBrk); + if (zAff.Length > 0) { + if (sqlite3CompareAffinity(pRight, zAff[j]) == SQLITE_AFF_NONE) { + zAff[j] = SQLITE_AFF_NONE; + } + if ((sqlite3ExprNeedsNoAffinityChange(pRight, zAff[j])) != 0) { + zAff[j] = SQLITE_AFF_NONE; + } + } + } } - } + pzAff = zAff; + return regBase; } - } - pzAff = zAff; - return regBase; - } #if !SQLITE_OMIT_EXPLAIN - /* -** This routine is a helper for explainIndexRange() below -** -** pStr holds the text of an expression that we are building up one term -** at a time. This routine adds a new term to the end of the expression. -** Terms are separated by AND so add the "AND" text for second and subsequent -** terms only. -*/ - static void explainAppendTerm( - StrAccum pStr, /* The text expression being built */ - int iTerm, /* Index of this term. First is zero */ - string zColumn, /* Name of the column */ - string zOp /* Name of the operator */ - ) - { - if ( iTerm != 0 ) - sqlite3StrAccumAppend( pStr, " AND ", 5 ); - sqlite3StrAccumAppend( pStr, zColumn, -1 ); - sqlite3StrAccumAppend( pStr, zOp, 1 ); - sqlite3StrAccumAppend( pStr, "?", 1 ); - } - - /* - ** Argument pLevel describes a strategy for scanning table pTab. This - ** function returns a pointer to a string buffer containing a description - ** of the subset of table rows scanned by the strategy in the form of an - ** SQL expression. Or, if all rows are scanned, NULL is returned. - ** - ** For example, if the query: - ** - ** SELECT * FROM t1 WHERE a=1 AND b>2; - ** - ** is run and there is an index on (a, b), then this function returns a - ** string similar to: - ** - ** "a=? AND b>?" + /* + ** This routine is a helper for explainIndexRange() below ** - ** The returned pointer points to memory obtained from sqlite3DbMalloc(). - ** It is the responsibility of the caller to free the buffer when it is - ** no longer required. + ** pStr holds the text of an expression that we are building up one term + ** at a time. This routine adds a new term to the end of the expression. + ** Terms are separated by AND so add the "AND" text for second and subsequent + ** terms only. */ - static string explainIndexRange( sqlite3 db, WhereLevel pLevel, Table pTab ) - { - WherePlan pPlan = pLevel.plan; - Index pIndex = pPlan.u.pIdx; - uint nEq = pPlan.nEq; - int i, j; - Column[] aCol = pTab.aCol; - int[] aiColumn = pIndex.aiColumn; - StrAccum txt = new StrAccum( 100 ); - - if ( nEq == 0 && ( pPlan.wsFlags & ( WHERE_BTM_LIMIT | WHERE_TOP_LIMIT ) ) == 0 ) - { - return null; - } - sqlite3StrAccumInit( txt, null, 0, SQLITE_MAX_LENGTH ); - txt.db = db; - sqlite3StrAccumAppend( txt, " (", 2 ); - for ( i = 0; i < nEq; i++ ) - { - explainAppendTerm( txt, i, aCol[aiColumn[i]].zName, "=" ); - } + static void explainAppendTerm( + StrAccum pStr, /* The text expression being built */ + int iTerm, /* Index of this term. First is zero */ + string zColumn, /* Name of the column */ + string zOp /* Name of the operator */ + ) { + if (iTerm != 0) + sqlite3StrAccumAppend(pStr, " AND ", 5); + sqlite3StrAccumAppend(pStr, zColumn, -1); + sqlite3StrAccumAppend(pStr, zOp, 1); + sqlite3StrAccumAppend(pStr, "?", 1); + } - j = i; - if ( ( pPlan.wsFlags & WHERE_BTM_LIMIT ) != 0 ) - { - explainAppendTerm( txt, i++, aCol[aiColumn[j]].zName, ">" ); - } - if ( ( pPlan.wsFlags & WHERE_TOP_LIMIT ) != 0 ) - { - explainAppendTerm( txt, i, aCol[aiColumn[j]].zName, "<" ); - } - sqlite3StrAccumAppend( txt, ")", 1 ); - return sqlite3StrAccumFinish( txt ); - } + /* + ** Argument pLevel describes a strategy for scanning table pTab. This + ** function returns a pointer to a string buffer containing a description + ** of the subset of table rows scanned by the strategy in the form of an + ** SQL expression. Or, if all rows are scanned, NULL is returned. + ** + ** For example, if the query: + ** + ** SELECT * FROM t1 WHERE a=1 AND b>2; + ** + ** is run and there is an index on (a, b), then this function returns a + ** string similar to: + ** + ** "a=? AND b>?" + ** + ** The returned pointer points to memory obtained from sqlite3DbMalloc(). + ** It is the responsibility of the caller to free the buffer when it is + ** no longer required. + */ + static string explainIndexRange(sqlite3 db, WhereLevel pLevel, Table pTab) { + WherePlan pPlan = pLevel.plan; + Index pIndex = pPlan.u.pIdx; + uint nEq = pPlan.nEq; + int i, j; + Column[] aCol = pTab.aCol; + int[] aiColumn = pIndex.aiColumn; + StrAccum txt = new StrAccum(100); + + if (nEq == 0 && (pPlan.wsFlags & (WHERE_BTM_LIMIT | WHERE_TOP_LIMIT)) == 0) { + return null; + } + sqlite3StrAccumInit(txt, null, 0, SQLITE_MAX_LENGTH); + txt.db = db; + sqlite3StrAccumAppend(txt, " (", 2); + for (i = 0; i < nEq; i++) { + explainAppendTerm(txt, i, aCol[aiColumn[i]].zName, "="); + } - /* - ** This function is a no-op unless currently processing an EXPLAIN QUERY PLAN - ** command. If the query being compiled is an EXPLAIN QUERY PLAN, a single - ** record is added to the output to describe the table scan strategy in - ** pLevel. - */ - static void explainOneScan( - Parse pParse, /* Parse context */ - SrcList pTabList, /* Table list this loop refers to */ - WhereLevel pLevel, /* Scan to write OP_Explain opcode for */ - int iLevel, /* Value for "level" column of output */ - int iFrom, /* Value for "from" column of output */ - u16 wctrlFlags /* Flags passed to sqlite3WhereBegin() */ - ) - { - if ( pParse.explain == 2 ) - { - u32 flags = pLevel.plan.wsFlags; - SrcList_item pItem = pTabList.a[pLevel.iFrom]; - Vdbe v = pParse.pVdbe; /* VM being constructed */ - sqlite3 db = pParse.db; /* Database handle */ - StringBuilder zMsg = new StringBuilder( 1000 ); /* Text to add to EQP output */ - sqlite3_int64 nRow; /* Expected number of rows visited by scan */ - int iId = pParse.iSelectId; /* Select id (left-most output column) */ - bool isSearch; /* True for a SEARCH. False for SCAN. */ - - if ( ( flags & WHERE_MULTI_OR ) != 0 || ( wctrlFlags & WHERE_ONETABLE_ONLY ) != 0 ) - return; - - isSearch = ( pLevel.plan.nEq > 0 ) - || ( flags & ( WHERE_BTM_LIMIT | WHERE_TOP_LIMIT ) ) != 0 - || ( wctrlFlags & ( WHERE_ORDERBY_MIN | WHERE_ORDERBY_MAX ) ) != 0; - - zMsg.Append( sqlite3MPrintf( db, "%s", isSearch ? "SEARCH" : "SCAN" ) ); - if ( pItem.pSelect != null ) - { - zMsg.Append( sqlite3MAppendf( db, null, " SUBQUERY %d", pItem.iSelectId ) ); - } - else - { - zMsg.Append( sqlite3MAppendf( db, null, " TABLE %s", pItem.zName ) ); + j = i; + if ((pPlan.wsFlags & WHERE_BTM_LIMIT) != 0) { + explainAppendTerm(txt, i++, aCol[aiColumn[j]].zName, ">"); + } + if ((pPlan.wsFlags & WHERE_TOP_LIMIT) != 0) { + explainAppendTerm(txt, i, aCol[aiColumn[j]].zName, "<"); + } + sqlite3StrAccumAppend(txt, ")", 1); + return sqlite3StrAccumFinish(txt); } - if ( pItem.zAlias != null ) - { - zMsg.Append( sqlite3MAppendf( db, null, " AS %s", pItem.zAlias ) ); - } - if ( ( flags & WHERE_INDEXED ) != 0 ) - { - string zWhere = explainIndexRange( db, pLevel, pItem.pTab ); - zMsg.Append( sqlite3MAppendf( db, null, " USING %s%sINDEX%s%s%s", - ( ( flags & WHERE_TEMP_INDEX ) != 0 ? "AUTOMATIC " : "" ), - ( ( flags & WHERE_IDX_ONLY ) != 0 ? "COVERING " : "" ), - ( ( flags & WHERE_TEMP_INDEX ) != 0 ? "" : " " ), - ( ( flags & WHERE_TEMP_INDEX ) != 0 ? "" : pLevel.plan.u.pIdx.zName ), - zWhere != null ? zWhere : "" - ) ); - sqlite3DbFree( db, ref zWhere ); - } - else if ( ( flags & ( WHERE_ROWID_EQ | WHERE_ROWID_RANGE ) ) != 0 ) - { - zMsg.Append( " USING INTEGER PRIMARY KEY" ); + /* + ** This function is a no-op unless currently processing an EXPLAIN QUERY PLAN + ** command. If the query being compiled is an EXPLAIN QUERY PLAN, a single + ** record is added to the output to describe the table scan strategy in + ** pLevel. + */ + static void explainOneScan( + Parse pParse, /* Parse context */ + SrcList pTabList, /* Table list this loop refers to */ + WhereLevel pLevel, /* Scan to write OP_Explain opcode for */ + int iLevel, /* Value for "level" column of output */ + int iFrom, /* Value for "from" column of output */ + u16 wctrlFlags /* Flags passed to sqlite3WhereBegin() */ + ) { + if (pParse.explain == 2) { + u32 flags = pLevel.plan.wsFlags; + SrcList_item pItem = pTabList.a[pLevel.iFrom]; + Vdbe v = pParse.pVdbe; /* VM being constructed */ + sqlite3 db = pParse.db; /* Database handle */ + StringBuilder zMsg = new StringBuilder(1000); /* Text to add to EQP output */ + sqlite3_int64 nRow; /* Expected number of rows visited by scan */ + int iId = pParse.iSelectId; /* Select id (left-most output column) */ + bool isSearch; /* True for a SEARCH. False for SCAN. */ + + if ((flags & WHERE_MULTI_OR) != 0 || (wctrlFlags & WHERE_ONETABLE_ONLY) != 0) + return; + + isSearch = (pLevel.plan.nEq > 0) + || (flags & (WHERE_BTM_LIMIT | WHERE_TOP_LIMIT)) != 0 + || (wctrlFlags & (WHERE_ORDERBY_MIN | WHERE_ORDERBY_MAX)) != 0; + + zMsg.Append(sqlite3MPrintf(db, "%s", isSearch ? "SEARCH" : "SCAN")); + if (pItem.pSelect != null) { + zMsg.Append(sqlite3MAppendf(db, null, " SUBQUERY %d", pItem.iSelectId)); + } else { + zMsg.Append(sqlite3MAppendf(db, null, " TABLE %s", pItem.zName)); + } - if ( ( flags & WHERE_ROWID_EQ ) != 0 ) - { - zMsg.Append( " (rowid=?)" ); - } - else if ( ( flags & WHERE_BOTH_LIMIT ) == WHERE_BOTH_LIMIT ) - { - zMsg.Append( " (rowid>? AND rowid?)" ); - } - else if ( ( flags & WHERE_TOP_LIMIT ) != 0 ) - { - zMsg.Append( " (rowid? AND rowid?)"); + } else if ((flags & WHERE_TOP_LIMIT) != 0) { + zMsg.Append(" (rowid 0 && ( pTabItem.jointype & JT_LEFT ) != 0 )// Check value of pTabItem[0].jointype - { - pLevel.iLeftJoin = ++pParse.nMem; - sqlite3VdbeAddOp2( v, OP_Integer, 0, pLevel.iLeftJoin ); + /* If this is the right table of a LEFT OUTER JOIN, allocate and + ** initialize a memory cell that records if this table matches any + ** row of the left table of the join. + */ + if (pLevel.iFrom > 0 && (pTabItem.jointype & JT_LEFT) != 0)// Check value of pTabItem[0].jointype + { + pLevel.iLeftJoin = ++pParse.nMem; + sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel.iLeftJoin); #if SQLITE_DEBUG - VdbeComment( v, "init LEFT JOIN no-match flag" ); + VdbeComment(v, "init LEFT JOIN no-match flag"); #endif - } - -#if !SQLITE_OMIT_VIRTUALTABLE - if ( ( pLevel.plan.wsFlags & WHERE_VIRTUALTABLE ) != 0 ) - { - /* Case 0: The table is a virtual-table. Use the VFilter and VNext - ** to access the data. - */ - int iReg; /* P3 Value for OP_VFilter */ - sqlite3_index_info pVtabIdx = pLevel.plan.u.pVtabIdx; - int nConstraint = pVtabIdx.nConstraint; - sqlite3_index_constraint_usage[] aUsage = pVtabIdx.aConstraintUsage; - sqlite3_index_constraint[] aConstraint = pVtabIdx.aConstraint; - - sqlite3ExprCachePush( pParse ); - iReg = sqlite3GetTempRange( pParse, nConstraint + 2 ); - for ( j = 1; j <= nConstraint; j++ ) - { - for ( k = 0; k < nConstraint; k++ ) - { - if ( aUsage[k].argvIndex == j ) - { - int iTerm = aConstraint[k].iTermOffset; - sqlite3ExprCode( pParse, pWC.a[iTerm].pExpr.pRight, iReg + j + 1 ); - break; } - } - if ( k == nConstraint ) - break; - } - sqlite3VdbeAddOp2( v, OP_Integer, pVtabIdx.idxNum, iReg ); - sqlite3VdbeAddOp2( v, OP_Integer, j - 1, iReg + 1 ); - sqlite3VdbeAddOp4( v, OP_VFilter, iCur, addrBrk, iReg, pVtabIdx.idxStr, - pVtabIdx.needToFreeIdxStr != 0 ? P4_MPRINTF : P4_STATIC ); - pVtabIdx.needToFreeIdxStr = 0; - for ( j = 0; j < nConstraint; j++ ) - { - if ( aUsage[j].omit != false ) - { - int iTerm = aConstraint[j].iTermOffset; - disableTerm( pLevel, pWC.a[iTerm] ); - } - } - pLevel.op = OP_VNext; - pLevel.p1 = iCur; - pLevel.p2 = sqlite3VdbeCurrentAddr( v ); - sqlite3ReleaseTempRange( pParse, iReg, nConstraint + 2 ); - sqlite3ExprCachePop( pParse, 1 ); - } - else + +#if !SQLITE_OMIT_VIRTUALTABLE + if ((pLevel.plan.wsFlags & WHERE_VIRTUALTABLE) != 0) { + /* Case 0: The table is a virtual-table. Use the VFilter and VNext + ** to access the data. + */ + int iReg; /* P3 Value for OP_VFilter */ + sqlite3_index_info pVtabIdx = pLevel.plan.u.pVtabIdx; + int nConstraint = pVtabIdx.nConstraint; + sqlite3_index_constraint_usage[] aUsage = pVtabIdx.aConstraintUsage; + sqlite3_index_constraint[] aConstraint = pVtabIdx.aConstraint; + + sqlite3ExprCachePush(pParse); + iReg = sqlite3GetTempRange(pParse, nConstraint + 2); + for (j = 1; j <= nConstraint; j++) { + for (k = 0; k < nConstraint; k++) { + if (aUsage[k].argvIndex == j) { + int iTerm = aConstraint[k].iTermOffset; + sqlite3ExprCode(pParse, pWC.a[iTerm].pExpr.pRight, iReg + j + 1); + break; + } + } + if (k == nConstraint) + break; + } + sqlite3VdbeAddOp2(v, OP_Integer, pVtabIdx.idxNum, iReg); + sqlite3VdbeAddOp2(v, OP_Integer, j - 1, iReg + 1); + sqlite3VdbeAddOp4(v, OP_VFilter, iCur, addrBrk, iReg, pVtabIdx.idxStr, + pVtabIdx.needToFreeIdxStr != 0 ? P4_MPRINTF : P4_STATIC); + pVtabIdx.needToFreeIdxStr = 0; + for (j = 0; j < nConstraint; j++) { + if (aUsage[j].omit != false) { + int iTerm = aConstraint[j].iTermOffset; + disableTerm(pLevel, pWC.a[iTerm]); + } + } + pLevel.op = OP_VNext; + pLevel.p1 = iCur; + pLevel.p2 = sqlite3VdbeCurrentAddr(v); + sqlite3ReleaseTempRange(pParse, iReg, nConstraint + 2); + sqlite3ExprCachePop(pParse, 1); + } else #endif //* SQLITE_OMIT_VIRTUALTABLE */ - if ( ( pLevel.plan.wsFlags & WHERE_ROWID_EQ ) != 0 ) - { - /* Case 1: We can directly reference a single row using an - ** equality comparison against the ROWID field. Or - ** we reference multiple rows using a "rowid IN (...)" - ** construct. - */ - iReleaseReg = sqlite3GetTempReg( pParse ); - pTerm = findTerm( pWC, iCur, -1, notReady, WO_EQ | WO_IN, null ); - Debug.Assert( pTerm != null ); - Debug.Assert( pTerm.pExpr != null ); - Debug.Assert( pTerm.leftCursor == iCur ); - Debug.Assert( omitTable == 0 ); - testcase( pTerm.wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ - iRowidReg = codeEqualityTerm( pParse, pTerm, pLevel, iReleaseReg ); - addrNxt = pLevel.addrNxt; - sqlite3VdbeAddOp2( v, OP_MustBeInt, iRowidReg, addrNxt ); - sqlite3VdbeAddOp3( v, OP_NotExists, iCur, addrNxt, iRowidReg ); - sqlite3ExprCacheStore( pParse, iCur, -1, iRowidReg ); + if ((pLevel.plan.wsFlags & WHERE_ROWID_EQ) != 0) { + /* Case 1: We can directly reference a single row using an + ** equality comparison against the ROWID field. Or + ** we reference multiple rows using a "rowid IN (...)" + ** construct. + */ + iReleaseReg = sqlite3GetTempReg(pParse); + pTerm = findTerm(pWC, iCur, -1, notReady, WO_EQ | WO_IN, null); + Debug.Assert(pTerm != null); + Debug.Assert(pTerm.pExpr != null); + Debug.Assert(pTerm.leftCursor == iCur); + Debug.Assert(omitTable == 0); + testcase(pTerm.wtFlags & TERM_VIRTUAL); /* EV: R-30575-11662 */ + iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, iReleaseReg); + addrNxt = pLevel.addrNxt; + sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt); + sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg); + sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg); #if SQLITE_DEBUG - VdbeComment( v, "pk" ); + VdbeComment(v, "pk"); #endif - pLevel.op = OP_Noop; - } - else if ( ( pLevel.plan.wsFlags & WHERE_ROWID_RANGE ) != 0 ) - { - /* Case 2: We have an inequality comparison against the ROWID field. - */ - int testOp = OP_Noop; - int start; - int memEndValue = 0; - WhereTerm pStart, pEnd; - - Debug.Assert( omitTable == 0 ); - pStart = findTerm( pWC, iCur, -1, notReady, WO_GT | WO_GE, null ); - pEnd = findTerm( pWC, iCur, -1, notReady, WO_LT | WO_LE, null ); - if ( bRev != 0 ) - { - pTerm = pStart; - pStart = pEnd; - pEnd = pTerm; - } - if ( pStart != null ) - { - Expr pX; /* The expression that defines the start bound */ - int r1, rTemp = 0; /* Registers for holding the start boundary */ - - /* The following constant maps TK_xx codes into corresponding - ** seek opcodes. It depends on a particular ordering of TK_xx - */ - u8[] aMoveOp = new u8[]{ + pLevel.op = OP_Noop; + } else if ((pLevel.plan.wsFlags & WHERE_ROWID_RANGE) != 0) { + /* Case 2: We have an inequality comparison against the ROWID field. + */ + int testOp = OP_Noop; + int start; + int memEndValue = 0; + WhereTerm pStart, pEnd; + + Debug.Assert(omitTable == 0); + pStart = findTerm(pWC, iCur, -1, notReady, WO_GT | WO_GE, null); + pEnd = findTerm(pWC, iCur, -1, notReady, WO_LT | WO_LE, null); + if (bRev != 0) { + pTerm = pStart; + pStart = pEnd; + pEnd = pTerm; + } + if (pStart != null) { + Expr pX; /* The expression that defines the start bound */ + int r1, rTemp = 0; /* Registers for holding the start boundary */ + + /* The following constant maps TK_xx codes into corresponding + ** seek opcodes. It depends on a particular ordering of TK_xx + */ + u8[] aMoveOp = new u8[]{ /* TK_GT */ OP_SeekGt, /* TK_LE */ OP_SeekLe, /* TK_LT */ OP_SeekLt, /* TK_GE */ OP_SeekGe }; - Debug.Assert( TK_LE == TK_GT + 1 ); /* Make sure the ordering.. */ - Debug.Assert( TK_LT == TK_GT + 2 ); /* ... of the TK_xx values... */ - Debug.Assert( TK_GE == TK_GT + 3 ); /* ... is correcct. */ - - testcase( pStart.wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ - pX = pStart.pExpr; - Debug.Assert( pX != null ); - Debug.Assert( pStart.leftCursor == iCur ); - r1 = sqlite3ExprCodeTemp( pParse, pX.pRight, ref rTemp ); - sqlite3VdbeAddOp3( v, aMoveOp[pX.op - TK_GT], iCur, addrBrk, r1 ); + Debug.Assert(TK_LE == TK_GT + 1); /* Make sure the ordering.. */ + Debug.Assert(TK_LT == TK_GT + 2); /* ... of the TK_xx values... */ + Debug.Assert(TK_GE == TK_GT + 3); /* ... is correcct. */ + + testcase(pStart.wtFlags & TERM_VIRTUAL); /* EV: R-30575-11662 */ + pX = pStart.pExpr; + Debug.Assert(pX != null); + Debug.Assert(pStart.leftCursor == iCur); + r1 = sqlite3ExprCodeTemp(pParse, pX.pRight, ref rTemp); + sqlite3VdbeAddOp3(v, aMoveOp[pX.op - TK_GT], iCur, addrBrk, r1); #if SQLITE_DEBUG - VdbeComment( v, "pk" ); + VdbeComment(v, "pk"); #endif - sqlite3ExprCacheAffinityChange( pParse, r1, 1 ); - sqlite3ReleaseTempReg( pParse, rTemp ); - disableTerm( pLevel, pStart ); - } - else - { - sqlite3VdbeAddOp2( v, bRev != 0 ? OP_Last : OP_Rewind, iCur, addrBrk ); - } - if ( pEnd != null ) - { - Expr pX; - pX = pEnd.pExpr; - Debug.Assert( pX != null ); - Debug.Assert( pEnd.leftCursor == iCur ); - testcase( pEnd.wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ - memEndValue = ++pParse.nMem; - sqlite3ExprCode( pParse, pX.pRight, memEndValue ); - if ( pX.op == TK_LT || pX.op == TK_GT ) - { - testOp = bRev != 0 ? OP_Le : OP_Ge; - } - else - { - testOp = bRev != 0 ? OP_Lt : OP_Gt; - } - disableTerm( pLevel, pEnd ); - } - start = sqlite3VdbeCurrentAddr( v ); - pLevel.op = (u8)( bRev != 0 ? OP_Prev : OP_Next ); - pLevel.p1 = iCur; - pLevel.p2 = start; - if ( pStart == null && pEnd == null ) - { - pLevel.p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP; - } - else - { - Debug.Assert( pLevel.p5 == 0 ); - } - if ( testOp != OP_Noop ) - { - iRowidReg = iReleaseReg = sqlite3GetTempReg( pParse ); - sqlite3VdbeAddOp2( v, OP_Rowid, iCur, iRowidReg ); - sqlite3ExprCacheStore( pParse, iCur, -1, iRowidReg ); - sqlite3VdbeAddOp3( v, testOp, memEndValue, addrBrk, iRowidReg ); - sqlite3VdbeChangeP5( v, SQLITE_AFF_NUMERIC | SQLITE_JUMPIFNULL ); - } - } - else if ( ( pLevel.plan.wsFlags & ( WHERE_COLUMN_RANGE | WHERE_COLUMN_EQ ) ) != 0 ) - { - /* Case 3: A scan using an index. - ** - ** The WHERE clause may contain zero or more equality - ** terms ("==" or "IN" operators) that refer to the N - ** left-most columns of the index. It may also contain - ** inequality constraints (>, <, >= or <=) on the indexed - ** column that immediately follows the N equalities. Only - ** the right-most column can be an inequality - the rest must - ** use the "==" and "IN" operators. For example, if the - ** index is on (x,y,z), then the following clauses are all - ** optimized: - ** - ** x=5 - ** x=5 AND y=10 - ** x=5 AND y<10 - ** x=5 AND y>5 AND y<10 - ** x=5 AND y=5 AND z<=10 - ** - ** The z<10 term of the following cannot be used, only - ** the x=5 term: - ** - ** x=5 AND z<10 - ** - ** N may be zero if there are inequality constraints. - ** If there are no inequality constraints, then N is at - ** least one. - ** - ** This case is also used when there are no WHERE clause - ** constraints but an index is selected anyway, in order - ** to force the output order to conform to an ORDER BY. - */ - u8[] aStartOp = new u8[] { + sqlite3ExprCacheAffinityChange(pParse, r1, 1); + sqlite3ReleaseTempReg(pParse, rTemp); + disableTerm(pLevel, pStart); + } else { + sqlite3VdbeAddOp2(v, bRev != 0 ? OP_Last : OP_Rewind, iCur, addrBrk); + } + if (pEnd != null) { + Expr pX; + pX = pEnd.pExpr; + Debug.Assert(pX != null); + Debug.Assert(pEnd.leftCursor == iCur); + testcase(pEnd.wtFlags & TERM_VIRTUAL); /* EV: R-30575-11662 */ + memEndValue = ++pParse.nMem; + sqlite3ExprCode(pParse, pX.pRight, memEndValue); + if (pX.op == TK_LT || pX.op == TK_GT) { + testOp = bRev != 0 ? OP_Le : OP_Ge; + } else { + testOp = bRev != 0 ? OP_Lt : OP_Gt; + } + disableTerm(pLevel, pEnd); + } + start = sqlite3VdbeCurrentAddr(v); + pLevel.op = (u8)(bRev != 0 ? OP_Prev : OP_Next); + pLevel.p1 = iCur; + pLevel.p2 = start; + if (pStart == null && pEnd == null) { + pLevel.p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP; + } else { + Debug.Assert(pLevel.p5 == 0); + } + if (testOp != OP_Noop) { + iRowidReg = iReleaseReg = sqlite3GetTempReg(pParse); + sqlite3VdbeAddOp2(v, OP_Rowid, iCur, iRowidReg); + sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg); + sqlite3VdbeAddOp3(v, testOp, memEndValue, addrBrk, iRowidReg); + sqlite3VdbeChangeP5(v, SQLITE_AFF_NUMERIC | SQLITE_JUMPIFNULL); + } + } else if ((pLevel.plan.wsFlags & (WHERE_COLUMN_RANGE | WHERE_COLUMN_EQ)) != 0) { + /* Case 3: A scan using an index. + ** + ** The WHERE clause may contain zero or more equality + ** terms ("==" or "IN" operators) that refer to the N + ** left-most columns of the index. It may also contain + ** inequality constraints (>, <, >= or <=) on the indexed + ** column that immediately follows the N equalities. Only + ** the right-most column can be an inequality - the rest must + ** use the "==" and "IN" operators. For example, if the + ** index is on (x,y,z), then the following clauses are all + ** optimized: + ** + ** x=5 + ** x=5 AND y=10 + ** x=5 AND y<10 + ** x=5 AND y>5 AND y<10 + ** x=5 AND y=5 AND z<=10 + ** + ** The z<10 term of the following cannot be used, only + ** the x=5 term: + ** + ** x=5 AND z<10 + ** + ** N may be zero if there are inequality constraints. + ** If there are no inequality constraints, then N is at + ** least one. + ** + ** This case is also used when there are no WHERE clause + ** constraints but an index is selected anyway, in order + ** to force the output order to conform to an ORDER BY. + */ + u8[] aStartOp = new u8[] { 0, 0, OP_Rewind, /* 2: (!start_constraints && startEq && !bRev) */ @@ -4490,471 +4131,432 @@ Bitmask notReady /* Which tables are currently available */ OP_SeekGe, /* 6: (start_constraints && startEq && !bRev) */ OP_SeekLe /* 7: (start_constraints && startEq && bRev) */ }; - u8[] aEndOp = new u8[] { + u8[] aEndOp = new u8[] { OP_Noop, /* 0: (!end_constraints) */ OP_IdxGE, /* 1: (end_constraints && !bRev) */ OP_IdxLT /* 2: (end_constraints && bRev) */ }; - int nEq = (int)pLevel.plan.nEq; /* Number of == or IN terms */ - int isMinQuery = 0; /* If this is an optimized SELECT min(x).. */ - int regBase; /* Base register holding constraint values */ - int r1; /* Temp register */ - WhereTerm pRangeStart = null; /* Inequality constraint at range start */ - WhereTerm pRangeEnd = null; /* Inequality constraint at range end */ - int startEq; /* True if range start uses ==, >= or <= */ - int endEq; /* True if range end uses ==, >= or <= */ - int start_constraints; /* Start of range is constrained */ - int nConstraint; /* Number of constraint terms */ - Index pIdx; /* The index we will be using */ - int iIdxCur; /* The VDBE cursor for the index */ - int nExtraReg = 0; /* Number of extra registers needed */ - int op; /* Instruction opcode */ - StringBuilder zStartAff = new StringBuilder( "" ); - ;/* Affinity for start of range constraint */ - StringBuilder zEndAff; /* Affinity for end of range constraint */ - - pIdx = pLevel.plan.u.pIdx; - iIdxCur = pLevel.iIdxCur; - k = pIdx.aiColumn[nEq]; /* Column for inequality constraints */ - - /* If this loop satisfies a sort order (pOrderBy) request that - ** was pDebug.Assed to this function to implement a "SELECT min(x) ..." - ** query, then the caller will only allow the loop to run for - ** a single iteration. This means that the first row returned - ** should not have a NULL value stored in 'x'. If column 'x' is - ** the first one after the nEq equality constraints in the index, - ** this requires some special handling. - */ - if ( ( wctrlFlags & WHERE_ORDERBY_MIN ) != 0 - && ( ( pLevel.plan.wsFlags & WHERE_ORDERBY ) != 0 ) - && ( pIdx.nColumn > nEq ) - ) - { - /* Debug.Assert( pOrderBy.nExpr==1 ); */ - /* Debug.Assert( pOrderBy.a[0].pExpr.iColumn==pIdx.aiColumn[nEq] ); */ - isMinQuery = 1; - nExtraReg = 1; - } + int nEq = (int)pLevel.plan.nEq; /* Number of == or IN terms */ + int isMinQuery = 0; /* If this is an optimized SELECT min(x).. */ + int regBase; /* Base register holding constraint values */ + int r1; /* Temp register */ + WhereTerm pRangeStart = null; /* Inequality constraint at range start */ + WhereTerm pRangeEnd = null; /* Inequality constraint at range end */ + int startEq; /* True if range start uses ==, >= or <= */ + int endEq; /* True if range end uses ==, >= or <= */ + int start_constraints; /* Start of range is constrained */ + int nConstraint; /* Number of constraint terms */ + Index pIdx; /* The index we will be using */ + int iIdxCur; /* The VDBE cursor for the index */ + int nExtraReg = 0; /* Number of extra registers needed */ + int op; /* Instruction opcode */ + StringBuilder zStartAff = new StringBuilder(""); + ;/* Affinity for start of range constraint */ + StringBuilder zEndAff; /* Affinity for end of range constraint */ + + pIdx = pLevel.plan.u.pIdx; + iIdxCur = pLevel.iIdxCur; + k = pIdx.aiColumn[nEq]; /* Column for inequality constraints */ + + /* If this loop satisfies a sort order (pOrderBy) request that + ** was pDebug.Assed to this function to implement a "SELECT min(x) ..." + ** query, then the caller will only allow the loop to run for + ** a single iteration. This means that the first row returned + ** should not have a NULL value stored in 'x'. If column 'x' is + ** the first one after the nEq equality constraints in the index, + ** this requires some special handling. + */ + if ((wctrlFlags & WHERE_ORDERBY_MIN) != 0 + && ((pLevel.plan.wsFlags & WHERE_ORDERBY) != 0) + && (pIdx.nColumn > nEq) + ) { + /* Debug.Assert( pOrderBy.nExpr==1 ); */ + /* Debug.Assert( pOrderBy.a[0].pExpr.iColumn==pIdx.aiColumn[nEq] ); */ + isMinQuery = 1; + nExtraReg = 1; + } - /* Find any inequality constraint terms for the start and end - ** of the range. - */ - if ( ( pLevel.plan.wsFlags & WHERE_TOP_LIMIT ) != 0 ) - { - pRangeEnd = findTerm( pWC, iCur, k, notReady, ( WO_LT | WO_LE ), pIdx ); - nExtraReg = 1; - } - if ( ( pLevel.plan.wsFlags & WHERE_BTM_LIMIT ) != 0 ) - { - pRangeStart = findTerm( pWC, iCur, k, notReady, ( WO_GT | WO_GE ), pIdx ); - nExtraReg = 1; - } + /* Find any inequality constraint terms for the start and end + ** of the range. + */ + if ((pLevel.plan.wsFlags & WHERE_TOP_LIMIT) != 0) { + pRangeEnd = findTerm(pWC, iCur, k, notReady, (WO_LT | WO_LE), pIdx); + nExtraReg = 1; + } + if ((pLevel.plan.wsFlags & WHERE_BTM_LIMIT) != 0) { + pRangeStart = findTerm(pWC, iCur, k, notReady, (WO_GT | WO_GE), pIdx); + nExtraReg = 1; + } - /* Generate code to evaluate all constraint terms using == or IN - ** and store the values of those terms in an array of registers - ** starting at regBase. - */ - regBase = codeAllEqualityTerms( - pParse, pLevel, pWC, notReady, nExtraReg, out zStartAff - ); - zEndAff = new StringBuilder( zStartAff.ToString() );//sqlite3DbStrDup(pParse.db, zStartAff); - addrNxt = pLevel.addrNxt; - - /* If we are doing a reverse order scan on an ascending index, or - ** a forward order scan on a descending index, interchange the - ** start and end terms (pRangeStart and pRangeEnd). - */ - if ( nEq < pIdx.nColumn && bRev == ( pIdx.aSortOrder[nEq] == SQLITE_SO_ASC ? 1 : 0 ) ) - { - SWAP( ref pRangeEnd, ref pRangeStart ); - } + /* Generate code to evaluate all constraint terms using == or IN + ** and store the values of those terms in an array of registers + ** starting at regBase. + */ + regBase = codeAllEqualityTerms( + pParse, pLevel, pWC, notReady, nExtraReg, out zStartAff + ); + zEndAff = new StringBuilder(zStartAff.ToString());//sqlite3DbStrDup(pParse.db, zStartAff); + addrNxt = pLevel.addrNxt; + + /* If we are doing a reverse order scan on an ascending index, or + ** a forward order scan on a descending index, interchange the + ** start and end terms (pRangeStart and pRangeEnd). + */ + if (nEq < pIdx.nColumn && bRev == (pIdx.aSortOrder[nEq] == SQLITE_SO_ASC ? 1 : 0)) { + SWAP(ref pRangeEnd, ref pRangeStart); + } - testcase( pRangeStart != null && ( pRangeStart.eOperator & WO_LE ) != 0 ); - testcase( pRangeStart != null && ( pRangeStart.eOperator & WO_GE ) != 0 ); - testcase( pRangeEnd != null && ( pRangeEnd.eOperator & WO_LE ) != 0 ); - testcase( pRangeEnd != null && ( pRangeEnd.eOperator & WO_GE ) != 0 ); - startEq = ( null == pRangeStart || ( pRangeStart.eOperator & ( WO_LE | WO_GE ) ) != 0 ) ? 1 : 0; - endEq = ( null == pRangeEnd || ( pRangeEnd.eOperator & ( WO_LE | WO_GE ) ) != 0 ) ? 1 : 0; - start_constraints = ( pRangeStart != null || nEq > 0 ) ? 1 : 0; - - /* Seek the index cursor to the start of the range. */ - nConstraint = nEq; - if ( pRangeStart != null ) - { - Expr pRight = pRangeStart.pExpr.pRight; - sqlite3ExprCode( pParse, pRight, regBase + nEq ); - if ( ( pRangeStart.wtFlags & TERM_VNULL ) == 0 ) - { - sqlite3ExprCodeIsNullJump( v, pRight, regBase + nEq, addrNxt ); - } - if ( zStartAff.Length != 0 ) - { - if ( sqlite3CompareAffinity( pRight, zStartAff[nEq] ) == SQLITE_AFF_NONE ) - { - /* Since the comparison is to be performed with no conversions - ** applied to the operands, set the affinity to apply to pRight to - ** SQLITE_AFF_NONE. */ - zStartAff[nEq] = SQLITE_AFF_NONE; - } - if ( ( sqlite3ExprNeedsNoAffinityChange( pRight, zStartAff[nEq] ) ) != 0 ) - { - zStartAff[nEq] = SQLITE_AFF_NONE; - } - } - nConstraint++; - testcase( pRangeStart.wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ - } - else if ( isMinQuery != 0 ) - { - sqlite3VdbeAddOp2( v, OP_Null, 0, regBase + nEq ); - nConstraint++; - startEq = 0; - start_constraints = 1; - } - codeApplyAffinity( pParse, regBase, nConstraint, zStartAff.ToString() ); - op = aStartOp[( start_constraints << 2 ) + ( startEq << 1 ) + bRev]; - Debug.Assert( op != 0 ); - testcase( op == OP_Rewind ); - testcase( op == OP_Last ); - testcase( op == OP_SeekGt ); - testcase( op == OP_SeekGe ); - testcase( op == OP_SeekLe ); - testcase( op == OP_SeekLt ); - sqlite3VdbeAddOp4Int( v, op, iIdxCur, addrNxt, regBase, nConstraint ); - - /* Load the value for the inequality constraint at the end of the - ** range (if any). - */ - nConstraint = nEq; - if ( pRangeEnd != null ) - { - Expr pRight = pRangeEnd.pExpr.pRight; - sqlite3ExprCacheRemove( pParse, regBase + nEq, 1 ); - sqlite3ExprCode( pParse, pRight, regBase + nEq ); - if ( ( pRangeEnd.wtFlags & TERM_VNULL ) == 0 ) - { - sqlite3ExprCodeIsNullJump( v, pRight, regBase + nEq, addrNxt ); - } - if ( zEndAff.Length > 0 ) - { - if ( sqlite3CompareAffinity( pRight, zEndAff[nEq] ) == SQLITE_AFF_NONE ) - { - /* Since the comparison is to be performed with no conversions - ** applied to the operands, set the affinity to apply to pRight to - ** SQLITE_AFF_NONE. */ - zEndAff[nEq] = SQLITE_AFF_NONE; - } - if ( ( sqlite3ExprNeedsNoAffinityChange( pRight, zEndAff[nEq] ) ) != 0 ) - { - zEndAff[nEq] = SQLITE_AFF_NONE; - } - } - codeApplyAffinity( pParse, regBase, nEq + 1, zEndAff.ToString() ); - nConstraint++; - testcase( pRangeEnd.wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ - } - sqlite3DbFree( pParse.db, ref zStartAff ); - sqlite3DbFree( pParse.db, ref zEndAff ); - - /* Top of the loop body */ - pLevel.p2 = sqlite3VdbeCurrentAddr( v ); - - /* Check if the index cursor is past the end of the range. */ - op = aEndOp[( ( pRangeEnd != null || nEq != 0 ) ? 1 : 0 ) * ( 1 + bRev )]; - testcase( op == OP_Noop ); - testcase( op == OP_IdxGE ); - testcase( op == OP_IdxLT ); - if ( op != OP_Noop ) - { - sqlite3VdbeAddOp4Int( v, op, iIdxCur, addrNxt, regBase, nConstraint ); - sqlite3VdbeChangeP5( v, (u8)( endEq != bRev ? 1 : 0 ) ); - } + testcase(pRangeStart != null && (pRangeStart.eOperator & WO_LE) != 0); + testcase(pRangeStart != null && (pRangeStart.eOperator & WO_GE) != 0); + testcase(pRangeEnd != null && (pRangeEnd.eOperator & WO_LE) != 0); + testcase(pRangeEnd != null && (pRangeEnd.eOperator & WO_GE) != 0); + startEq = (null == pRangeStart || (pRangeStart.eOperator & (WO_LE | WO_GE)) != 0) ? 1 : 0; + endEq = (null == pRangeEnd || (pRangeEnd.eOperator & (WO_LE | WO_GE)) != 0) ? 1 : 0; + start_constraints = (pRangeStart != null || nEq > 0) ? 1 : 0; + + /* Seek the index cursor to the start of the range. */ + nConstraint = nEq; + if (pRangeStart != null) { + Expr pRight = pRangeStart.pExpr.pRight; + sqlite3ExprCode(pParse, pRight, regBase + nEq); + if ((pRangeStart.wtFlags & TERM_VNULL) == 0) { + sqlite3ExprCodeIsNullJump(v, pRight, regBase + nEq, addrNxt); + } + if (zStartAff.Length != 0) { + if (sqlite3CompareAffinity(pRight, zStartAff[nEq]) == SQLITE_AFF_NONE) { + /* Since the comparison is to be performed with no conversions + ** applied to the operands, set the affinity to apply to pRight to + ** SQLITE_AFF_NONE. */ + zStartAff[nEq] = SQLITE_AFF_NONE; + } + if ((sqlite3ExprNeedsNoAffinityChange(pRight, zStartAff[nEq])) != 0) { + zStartAff[nEq] = SQLITE_AFF_NONE; + } + } + nConstraint++; + testcase(pRangeStart.wtFlags & TERM_VIRTUAL); /* EV: R-30575-11662 */ + } else if (isMinQuery != 0) { + sqlite3VdbeAddOp2(v, OP_Null, 0, regBase + nEq); + nConstraint++; + startEq = 0; + start_constraints = 1; + } + codeApplyAffinity(pParse, regBase, nConstraint, zStartAff.ToString()); + op = aStartOp[(start_constraints << 2) + (startEq << 1) + bRev]; + Debug.Assert(op != 0); + testcase(op == OP_Rewind); + testcase(op == OP_Last); + testcase(op == OP_SeekGt); + testcase(op == OP_SeekGe); + testcase(op == OP_SeekLe); + testcase(op == OP_SeekLt); + sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint); + + /* Load the value for the inequality constraint at the end of the + ** range (if any). + */ + nConstraint = nEq; + if (pRangeEnd != null) { + Expr pRight = pRangeEnd.pExpr.pRight; + sqlite3ExprCacheRemove(pParse, regBase + nEq, 1); + sqlite3ExprCode(pParse, pRight, regBase + nEq); + if ((pRangeEnd.wtFlags & TERM_VNULL) == 0) { + sqlite3ExprCodeIsNullJump(v, pRight, regBase + nEq, addrNxt); + } + if (zEndAff.Length > 0) { + if (sqlite3CompareAffinity(pRight, zEndAff[nEq]) == SQLITE_AFF_NONE) { + /* Since the comparison is to be performed with no conversions + ** applied to the operands, set the affinity to apply to pRight to + ** SQLITE_AFF_NONE. */ + zEndAff[nEq] = SQLITE_AFF_NONE; + } + if ((sqlite3ExprNeedsNoAffinityChange(pRight, zEndAff[nEq])) != 0) { + zEndAff[nEq] = SQLITE_AFF_NONE; + } + } + codeApplyAffinity(pParse, regBase, nEq + 1, zEndAff.ToString()); + nConstraint++; + testcase(pRangeEnd.wtFlags & TERM_VIRTUAL); /* EV: R-30575-11662 */ + } + sqlite3DbFree(pParse.db, ref zStartAff); + sqlite3DbFree(pParse.db, ref zEndAff); + + /* Top of the loop body */ + pLevel.p2 = sqlite3VdbeCurrentAddr(v); + + /* Check if the index cursor is past the end of the range. */ + op = aEndOp[((pRangeEnd != null || nEq != 0) ? 1 : 0) * (1 + bRev)]; + testcase(op == OP_Noop); + testcase(op == OP_IdxGE); + testcase(op == OP_IdxLT); + if (op != OP_Noop) { + sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint); + sqlite3VdbeChangeP5(v, (u8)(endEq != bRev ? 1 : 0)); + } - /* If there are inequality constraints, check that the value - ** of the table column that the inequality contrains is not NULL. - ** If it is, jump to the next iteration of the loop. - */ - r1 = sqlite3GetTempReg( pParse ); - testcase( pLevel.plan.wsFlags & WHERE_BTM_LIMIT ); - testcase( pLevel.plan.wsFlags & WHERE_TOP_LIMIT ); - if ( ( pLevel.plan.wsFlags & ( WHERE_BTM_LIMIT | WHERE_TOP_LIMIT ) ) != 0 ) - { - sqlite3VdbeAddOp3( v, OP_Column, iIdxCur, nEq, r1 ); - sqlite3VdbeAddOp2( v, OP_IsNull, r1, addrCont ); - } - sqlite3ReleaseTempReg( pParse, r1 ); + /* If there are inequality constraints, check that the value + ** of the table column that the inequality contrains is not NULL. + ** If it is, jump to the next iteration of the loop. + */ + r1 = sqlite3GetTempReg(pParse); + testcase(pLevel.plan.wsFlags & WHERE_BTM_LIMIT); + testcase(pLevel.plan.wsFlags & WHERE_TOP_LIMIT); + if ((pLevel.plan.wsFlags & (WHERE_BTM_LIMIT | WHERE_TOP_LIMIT)) != 0) { + sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, nEq, r1); + sqlite3VdbeAddOp2(v, OP_IsNull, r1, addrCont); + } + sqlite3ReleaseTempReg(pParse, r1); + + /* Seek the table cursor, if required */ + disableTerm(pLevel, pRangeStart); + disableTerm(pLevel, pRangeEnd); + if (0 == omitTable) { + iRowidReg = iReleaseReg = sqlite3GetTempReg(pParse); + sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, iRowidReg); + sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg); + sqlite3VdbeAddOp2(v, OP_Seek, iCur, iRowidReg); /* Deferred seek */ + } - /* Seek the table cursor, if required */ - disableTerm( pLevel, pRangeStart ); - disableTerm( pLevel, pRangeEnd ); - if ( 0 == omitTable ) - { - iRowidReg = iReleaseReg = sqlite3GetTempReg( pParse ); - sqlite3VdbeAddOp2( v, OP_IdxRowid, iIdxCur, iRowidReg ); - sqlite3ExprCacheStore( pParse, iCur, -1, iRowidReg ); - sqlite3VdbeAddOp2( v, OP_Seek, iCur, iRowidReg ); /* Deferred seek */ - } + /* Record the instruction used to terminate the loop. Disable + ** WHERE clause terms made redundant by the index range scan. + */ + if ((pLevel.plan.wsFlags & WHERE_UNIQUE) != 0) { + pLevel.op = OP_Noop; + } else if (bRev != 0) { + pLevel.op = OP_Prev; + } else { + pLevel.op = OP_Next; + } + pLevel.p1 = iIdxCur; + } else - /* Record the instruction used to terminate the loop. Disable - ** WHERE clause terms made redundant by the index range scan. - */ - if ( ( pLevel.plan.wsFlags & WHERE_UNIQUE ) != 0 ) - { - pLevel.op = OP_Noop; - } - else if ( bRev != 0 ) - { - pLevel.op = OP_Prev; - } - else - { - pLevel.op = OP_Next; - } - pLevel.p1 = iIdxCur; - } - else +#if !SQLITE_OMIT_OR_OPTIMIZATION + if ((pLevel.plan.wsFlags & WHERE_MULTI_OR) != 0) { + /* Case 4: Two or more separately indexed terms connected by OR + ** + ** Example: + ** + ** CREATE TABLE t1(a,b,c,d); + ** CREATE INDEX i1 ON t1(a); + ** CREATE INDEX i2 ON t1(b); + ** CREATE INDEX i3 ON t1(c); + ** + ** SELECT * FROM t1 WHERE a=5 OR b=7 OR (c=11 AND d=13) + ** + ** In the example, there are three indexed terms connected by OR. + ** The top of the loop looks like this: + ** + ** Null 1 # Zero the rowset in reg 1 + ** + ** Then, for each indexed term, the following. The arguments to + ** RowSetTest are such that the rowid of the current row is inserted + ** into the RowSet. If it is already present, control skips the + ** Gosub opcode and jumps straight to the code generated by WhereEnd(). + ** + ** sqlite3WhereBegin() + ** RowSetTest # Insert rowid into rowset + ** Gosub 2 A + ** sqlite3WhereEnd() + ** + ** Following the above, code to terminate the loop. Label A, the target + ** of the Gosub above, jumps to the instruction right after the Goto. + ** + ** Null 1 # Zero the rowset in reg 1 + ** Goto B # The loop is finished. + ** + ** A: # Return data, whatever. + ** + ** Return 2 # Jump back to the Gosub + ** + ** B: + ** + */ + WhereClause pOrWc; /* The OR-clause broken out into subterms */ + SrcList pOrTab; /* Shortened table list or OR-clause generation */ + + int regReturn = ++pParse.nMem; /* Register used with OP_Gosub */ + int regRowset = 0; /* Register for RowSet object */ + int regRowid = 0; /* Register holding rowid */ + int iLoopBody = sqlite3VdbeMakeLabel(v);/* Start of loop body */ + int iRetInit; /* Address of regReturn init */ + int untestedTerms = 0; /* Some terms not completely tested */ + int ii; + pTerm = pLevel.plan.u.pTerm; + Debug.Assert(pTerm != null); + Debug.Assert(pTerm.eOperator == WO_OR); + Debug.Assert((pTerm.wtFlags & TERM_ORINFO) != 0); + pOrWc = pTerm.u.pOrInfo.wc; + pLevel.op = OP_Return; + pLevel.p1 = regReturn; + + /* Set up a new SrcList in pOrTab containing the table being scanned + ** by this loop in the a[0] slot and all notReady tables in a[1..] slots. + ** This becomes the SrcList in the recursive call to sqlite3WhereBegin(). + */ + if (pWInfo.nLevel > 1) { + int nNotReady; /* The number of notReady tables */ + SrcList_item[] origSrc; /* Original list of tables */ + nNotReady = pWInfo.nLevel - iLevel - 1; + //sqlite3StackAllocRaw(pParse.db, + //sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab.a[0])); + pOrTab = new SrcList(); + pOrTab.a = new SrcList_item[nNotReady + 1]; + //if( pOrTab==0 ) return notReady; + pOrTab.nAlloc = (i16)(nNotReady + 1); + pOrTab.nSrc = pOrTab.nAlloc; + pOrTab.a[0] = pTabItem;//memcpy(pOrTab.a, pTabItem, sizeof(*pTabItem)); + origSrc = pWInfo.pTabList.a; + for (k = 1; k <= nNotReady; k++) { + pOrTab.a[k] = origSrc[pWInfo.a[iLevel + k].iFrom];// memcpy(&pOrTab.a[k], &origSrc[pLevel[k].iFrom], sizeof(pOrTab.a[k])); + } + } else { + pOrTab = pWInfo.pTabList; + } + + /* Initialize the rowset register to contain NULL. An SQL NULL is + ** equivalent to an empty rowset. + ** + ** Also initialize regReturn to contain the address of the instruction + ** immediately following the OP_Return at the bottom of the loop. This + ** is required in a few obscure LEFT JOIN cases where control jumps + ** over the top of the loop into the body of it. In this case the + ** correct response for the end-of-loop code (the OP_Return) is to + ** fall through to the next instruction, just as an OP_Next does if + ** called on an uninitialized cursor. + */ + if ((wctrlFlags & WHERE_DUPLICATES_OK) == 0) { + regRowset = ++pParse.nMem; + regRowid = ++pParse.nMem; + sqlite3VdbeAddOp2(v, OP_Null, 0, regRowset); + } + iRetInit = sqlite3VdbeAddOp2(v, OP_Integer, 0, regReturn); + + for (ii = 0; ii < pOrWc.nTerm; ii++) { + WhereTerm pOrTerm = pOrWc.a[ii]; + if (pOrTerm.leftCursor == iCur || pOrTerm.eOperator == WO_AND) { + WhereInfo pSubWInfo; /* Info for single OR-term scan */ + + /* Loop through table entries that match term pOrTerm. */ + ExprList elDummy = null; + pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrTerm.pExpr, ref elDummy, + WHERE_OMIT_OPEN | WHERE_OMIT_CLOSE | + WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY); + if (pSubWInfo != null) { + explainOneScan( + pParse, pOrTab, pSubWInfo.a[0], iLevel, pLevel.iFrom, 0 + ); + if ((wctrlFlags & WHERE_DUPLICATES_OK) == 0) { + int iSet = ((ii == pOrWc.nTerm - 1) ? -1 : ii); + int r; + r = sqlite3ExprCodeGetColumn(pParse, pTabItem.pTab, -1, iCur, + regRowid); + sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset, + sqlite3VdbeCurrentAddr(v) + 2, r, iSet); + } + sqlite3VdbeAddOp2(v, OP_Gosub, regReturn, iLoopBody); + + /* The pSubWInfo.untestedTerms flag means that this OR term + ** contained one or more AND term from a notReady table. The + ** terms from the notReady table could not be tested and will + ** need to be tested later. + */ + if (pSubWInfo.untestedTerms != 0) + untestedTerms = 1; + + /* Finish the loop through table entries that match term pOrTerm. */ + sqlite3WhereEnd(pSubWInfo); + } + } + } + sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v)); + sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel.addrBrk); + sqlite3VdbeResolveLabel(v, iLoopBody); + + if (pWInfo.nLevel > 1) + sqlite3DbFree(pParse.db, ref pOrTab);//sqlite3DbFree(pParse.db, pOrTab) + if (0 == untestedTerms) + disableTerm(pLevel, pTerm); + } else +#endif //* SQLITE_OMIT_OR_OPTIMIZATION */ -#if !SQLITE_OMIT_OR_OPTIMIZATION - if ( ( pLevel.plan.wsFlags & WHERE_MULTI_OR ) != 0 ) - { - /* Case 4: Two or more separately indexed terms connected by OR - ** - ** Example: - ** - ** CREATE TABLE t1(a,b,c,d); - ** CREATE INDEX i1 ON t1(a); - ** CREATE INDEX i2 ON t1(b); - ** CREATE INDEX i3 ON t1(c); - ** - ** SELECT * FROM t1 WHERE a=5 OR b=7 OR (c=11 AND d=13) - ** - ** In the example, there are three indexed terms connected by OR. - ** The top of the loop looks like this: - ** - ** Null 1 # Zero the rowset in reg 1 - ** - ** Then, for each indexed term, the following. The arguments to - ** RowSetTest are such that the rowid of the current row is inserted - ** into the RowSet. If it is already present, control skips the - ** Gosub opcode and jumps straight to the code generated by WhereEnd(). - ** - ** sqlite3WhereBegin() - ** RowSetTest # Insert rowid into rowset - ** Gosub 2 A - ** sqlite3WhereEnd() - ** - ** Following the above, code to terminate the loop. Label A, the target - ** of the Gosub above, jumps to the instruction right after the Goto. - ** - ** Null 1 # Zero the rowset in reg 1 - ** Goto B # The loop is finished. - ** - ** A: # Return data, whatever. - ** - ** Return 2 # Jump back to the Gosub - ** - ** B: - ** - */ - WhereClause pOrWc; /* The OR-clause broken out into subterms */ - SrcList pOrTab; /* Shortened table list or OR-clause generation */ - - int regReturn = ++pParse.nMem; /* Register used with OP_Gosub */ - int regRowset = 0; /* Register for RowSet object */ - int regRowid = 0; /* Register holding rowid */ - int iLoopBody = sqlite3VdbeMakeLabel( v );/* Start of loop body */ - int iRetInit; /* Address of regReturn init */ - int untestedTerms = 0; /* Some terms not completely tested */ - int ii; - pTerm = pLevel.plan.u.pTerm; - Debug.Assert( pTerm != null ); - Debug.Assert( pTerm.eOperator == WO_OR ); - Debug.Assert( ( pTerm.wtFlags & TERM_ORINFO ) != 0 ); - pOrWc = pTerm.u.pOrInfo.wc; - pLevel.op = OP_Return; - pLevel.p1 = regReturn; - - /* Set up a new SrcList in pOrTab containing the table being scanned - ** by this loop in the a[0] slot and all notReady tables in a[1..] slots. - ** This becomes the SrcList in the recursive call to sqlite3WhereBegin(). - */ - if ( pWInfo.nLevel > 1 ) - { - int nNotReady; /* The number of notReady tables */ - SrcList_item[] origSrc; /* Original list of tables */ - nNotReady = pWInfo.nLevel - iLevel - 1; - //sqlite3StackAllocRaw(pParse.db, - //sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab.a[0])); - pOrTab = new SrcList(); - pOrTab.a = new SrcList_item[nNotReady + 1]; - //if( pOrTab==0 ) return notReady; - pOrTab.nAlloc = (i16)( nNotReady + 1 ); - pOrTab.nSrc = pOrTab.nAlloc; - pOrTab.a[0] = pTabItem;//memcpy(pOrTab.a, pTabItem, sizeof(*pTabItem)); - origSrc = pWInfo.pTabList.a; - for ( k = 1; k <= nNotReady; k++ ) { - pOrTab.a[k] = origSrc[pWInfo.a[iLevel + k].iFrom];// memcpy(&pOrTab.a[k], &origSrc[pLevel[k].iFrom], sizeof(pOrTab.a[k])); - } - } - else - { - pOrTab = pWInfo.pTabList; + /* Case 5: There is no usable index. We must do a complete + ** scan of the entire table. + */ + u8[] aStep = new u8[] { OP_Next, OP_Prev }; + u8[] aStart = new u8[] { OP_Rewind, OP_Last }; + Debug.Assert(bRev == 0 || bRev == 1); + Debug.Assert(omitTable == 0); + pLevel.op = aStep[bRev]; + pLevel.p1 = iCur; + pLevel.p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrBrk); + pLevel.p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP; } + notReady &= ~getMask(pWC.pMaskSet, iCur); - /* Initialize the rowset register to contain NULL. An SQL NULL is - ** equivalent to an empty rowset. + /* Insert code to test every subexpression that can be completely + ** computed using the current set of tables. ** - ** Also initialize regReturn to contain the address of the instruction - ** immediately following the OP_Return at the bottom of the loop. This - ** is required in a few obscure LEFT JOIN cases where control jumps - ** over the top of the loop into the body of it. In this case the - ** correct response for the end-of-loop code (the OP_Return) is to - ** fall through to the next instruction, just as an OP_Next does if - ** called on an uninitialized cursor. + ** IMPLEMENTATION-OF: R-49525-50935 Terms that cannot be satisfied through + ** the use of indices become tests that are evaluated against each row of + ** the relevant input tables. */ - if ( ( wctrlFlags & WHERE_DUPLICATES_OK ) == 0 ) + for (j = pWC.nTerm; j > 0; j--)//, pTerm++) { - regRowset = ++pParse.nMem; - regRowid = ++pParse.nMem; - sqlite3VdbeAddOp2( v, OP_Null, 0, regRowset ); - } - iRetInit = sqlite3VdbeAddOp2( v, OP_Integer, 0, regReturn ); - - for ( ii = 0; ii < pOrWc.nTerm; ii++ ) - { - WhereTerm pOrTerm = pOrWc.a[ii]; - if ( pOrTerm.leftCursor == iCur || pOrTerm.eOperator == WO_AND ) - { - WhereInfo pSubWInfo; /* Info for single OR-term scan */ - - /* Loop through table entries that match term pOrTerm. */ - ExprList elDummy = null; - pSubWInfo = sqlite3WhereBegin( pParse, pOrTab, pOrTerm.pExpr, ref elDummy, - WHERE_OMIT_OPEN | WHERE_OMIT_CLOSE | - WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY ); - if ( pSubWInfo != null ) + pTerm = pWC.a[pWC.nTerm - j]; + Expr pE; + testcase(pTerm.wtFlags & TERM_VIRTUAL); /* IMP: R-30575-11662 */ + testcase(pTerm.wtFlags & TERM_CODED); + if ((pTerm.wtFlags & (TERM_VIRTUAL | TERM_CODED)) != 0) + continue; + if ((pTerm.prereqAll & notReady) != 0) { + testcase(pWInfo.untestedTerms == 0 + && (pWInfo.wctrlFlags & WHERE_ONETABLE_ONLY) != 0); + pWInfo.untestedTerms = 1; + continue; + } + pE = pTerm.pExpr; + Debug.Assert(pE != null); + if (pLevel.iLeftJoin != 0 && !((pE.flags & EP_FromJoin) == EP_FromJoin))// !ExprHasProperty(pE, EP_FromJoin) ){ { - explainOneScan( - pParse, pOrTab, pSubWInfo.a[0], iLevel, pLevel.iFrom, 0 - ); - if ( ( wctrlFlags & WHERE_DUPLICATES_OK ) == 0 ) - { - int iSet = ( ( ii == pOrWc.nTerm - 1 ) ? -1 : ii ); - int r; - r = sqlite3ExprCodeGetColumn( pParse, pTabItem.pTab, -1, iCur, - regRowid ); - sqlite3VdbeAddOp4Int( v, OP_RowSetTest, regRowset, - sqlite3VdbeCurrentAddr( v ) + 2, r, iSet ); - } - sqlite3VdbeAddOp2( v, OP_Gosub, regReturn, iLoopBody ); - - /* The pSubWInfo.untestedTerms flag means that this OR term - ** contained one or more AND term from a notReady table. The - ** terms from the notReady table could not be tested and will - ** need to be tested later. - */ - if ( pSubWInfo.untestedTerms != 0 ) - untestedTerms = 1; - - /* Finish the loop through table entries that match term pOrTerm. */ - sqlite3WhereEnd( pSubWInfo ); + continue; } - } + sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL); + pTerm.wtFlags |= TERM_CODED; } - sqlite3VdbeChangeP1( v, iRetInit, sqlite3VdbeCurrentAddr( v ) ); - sqlite3VdbeAddOp2( v, OP_Goto, 0, pLevel.addrBrk ); - sqlite3VdbeResolveLabel( v, iLoopBody ); - - if ( pWInfo.nLevel > 1 ) - sqlite3DbFree( pParse.db, ref pOrTab );//sqlite3DbFree(pParse.db, pOrTab) - if ( 0 == untestedTerms ) - disableTerm( pLevel, pTerm ); - } - else -#endif //* SQLITE_OMIT_OR_OPTIMIZATION */ - { - /* Case 5: There is no usable index. We must do a complete - ** scan of the entire table. + /* For a LEFT OUTER JOIN, generate code that will record the fact that + ** at least one row of the right table has matched the left table. */ - u8[] aStep = new u8[] { OP_Next, OP_Prev }; - u8[] aStart = new u8[] { OP_Rewind, OP_Last }; - Debug.Assert( bRev == 0 || bRev == 1 ); - Debug.Assert( omitTable == 0 ); - pLevel.op = aStep[bRev]; - pLevel.p1 = iCur; - pLevel.p2 = 1 + sqlite3VdbeAddOp2( v, aStart[bRev], iCur, addrBrk ); - pLevel.p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP; - } - notReady &= ~getMask( pWC.pMaskSet, iCur ); - - /* Insert code to test every subexpression that can be completely - ** computed using the current set of tables. - ** - ** IMPLEMENTATION-OF: R-49525-50935 Terms that cannot be satisfied through - ** the use of indices become tests that are evaluated against each row of - ** the relevant input tables. - */ - for ( j = pWC.nTerm; j > 0; j-- )//, pTerm++) - { - pTerm = pWC.a[pWC.nTerm - j]; - Expr pE; - testcase( pTerm.wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */ - testcase( pTerm.wtFlags & TERM_CODED ); - if ( ( pTerm.wtFlags & ( TERM_VIRTUAL | TERM_CODED ) ) != 0 ) - continue; - if ( ( pTerm.prereqAll & notReady ) != 0 ) - { - testcase( pWInfo.untestedTerms == 0 - && ( pWInfo.wctrlFlags & WHERE_ONETABLE_ONLY ) != 0 ); - pWInfo.untestedTerms = 1; - continue; - } - pE = pTerm.pExpr; - Debug.Assert( pE != null ); - if ( pLevel.iLeftJoin != 0 && !( ( pE.flags & EP_FromJoin ) == EP_FromJoin ) )// !ExprHasProperty(pE, EP_FromJoin) ){ - { - continue; - } - sqlite3ExprIfFalse( pParse, pE, addrCont, SQLITE_JUMPIFNULL ); - pTerm.wtFlags |= TERM_CODED; - } - - /* For a LEFT OUTER JOIN, generate code that will record the fact that - ** at least one row of the right table has matched the left table. - */ - if ( pLevel.iLeftJoin != 0 ) - { - pLevel.addrFirst = sqlite3VdbeCurrentAddr( v ); - sqlite3VdbeAddOp2( v, OP_Integer, 1, pLevel.iLeftJoin ); + if (pLevel.iLeftJoin != 0) { + pLevel.addrFirst = sqlite3VdbeCurrentAddr(v); + sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel.iLeftJoin); #if SQLITE_DEBUG - VdbeComment( v, "record LEFT JOIN hit" ); + VdbeComment(v, "record LEFT JOIN hit"); #endif - sqlite3ExprCacheClear( pParse ); - for ( j = 0; j < pWC.nTerm; j++ )//, pTerm++) - { - pTerm = pWC.a[j]; - testcase( pTerm.wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */ - testcase( pTerm.wtFlags & TERM_CODED ); - if ( ( pTerm.wtFlags & ( TERM_VIRTUAL | TERM_CODED ) ) != 0 ) - continue; - if ( ( pTerm.prereqAll & notReady ) != 0 ) - { - Debug.Assert( pWInfo.untestedTerms != 0 ); - continue; - } - Debug.Assert( pTerm.pExpr != null ); - sqlite3ExprIfFalse( pParse, pTerm.pExpr, addrCont, SQLITE_JUMPIFNULL ); - pTerm.wtFlags |= TERM_CODED; - } - } + sqlite3ExprCacheClear(pParse); + for (j = 0; j < pWC.nTerm; j++)//, pTerm++) + { + pTerm = pWC.a[j]; + testcase(pTerm.wtFlags & TERM_VIRTUAL); /* IMP: R-30575-11662 */ + testcase(pTerm.wtFlags & TERM_CODED); + if ((pTerm.wtFlags & (TERM_VIRTUAL | TERM_CODED)) != 0) + continue; + if ((pTerm.prereqAll & notReady) != 0) { + Debug.Assert(pWInfo.untestedTerms != 0); + continue; + } + Debug.Assert(pTerm.pExpr != null); + sqlite3ExprIfFalse(pParse, pTerm.pExpr, addrCont, SQLITE_JUMPIFNULL); + pTerm.wtFlags |= TERM_CODED; + } + } - sqlite3ReleaseTempReg( pParse, iReleaseReg ); - return notReady; - } + sqlite3ReleaseTempReg(pParse, iReleaseReg); + return notReady; + } -#if (SQLITE_TEST) +#if (SQLITE_TEST) /* ** The following variable holds a text description of query plan generated ** by the most recent call to sqlite3WhereBegin(). Each call to WhereBegin @@ -4965,639 +4567,594 @@ Bitmask notReady /* Which tables are currently available */ //char sqlite3_query_plan[BMS*2*40]; /* Text of the join */ static StringBuilder sqlite3_query_plan; #else - static tcl.lang.Var.SQLITE3_GETSET sqlite3_query_plan = new tcl.lang.Var.SQLITE3_GETSET( "sqlite3_query_plan" ); -#endif - static int nQPlan = 0; /* Next free slow in _query_plan[] */ - -#endif //* SQLITE_TEST */ - - - /* -** Free a WhereInfo structure -*/ - static void whereInfoFree( sqlite3 db, WhereInfo pWInfo ) - { - if ( ALWAYS( pWInfo != null ) ) - { - int i; - for ( i = 0; i < pWInfo.nLevel; i++ ) - { - sqlite3_index_info pInfo = pWInfo.a[i] != null ? pWInfo.a[i].pIdxInfo : null; - if ( pInfo != null ) - { - /* Debug.Assert( pInfo.needToFreeIdxStr==0 || db.mallocFailed ); */ - if ( pInfo.needToFreeIdxStr != 0 ) - { - //sqlite3_free( ref pInfo.idxStr ); - } - sqlite3DbFree( db, ref pInfo ); - } - if ( pWInfo.a[i] != null && ( pWInfo.a[i].plan.wsFlags & WHERE_TEMP_INDEX ) != 0 ) - { - Index pIdx = pWInfo.a[i].plan.u.pIdx; - if ( pIdx != null ) - { - sqlite3DbFree( db, ref pIdx.zColAff ); - sqlite3DbFree( db, ref pIdx ); - } - } - } - whereClauseClear( pWInfo.pWC ); - sqlite3DbFree( db, ref pWInfo ); - } - } - - - /* - ** Generate the beginning of the loop used for WHERE clause processing. - ** The return value is a pointer to an opaque structure that contains - ** information needed to terminate the loop. Later, the calling routine - ** should invoke sqlite3WhereEnd() with the return value of this function - ** in order to complete the WHERE clause processing. - ** - ** If an error occurs, this routine returns NULL. - ** - ** The basic idea is to do a nested loop, one loop for each table in - ** the FROM clause of a select. (INSERT and UPDATE statements are the - ** same as a SELECT with only a single table in the FROM clause.) For - ** example, if the SQL is this: - ** - ** SELECT * FROM t1, t2, t3 WHERE ...; - ** - ** Then the code generated is conceptually like the following: - ** - ** foreach row1 in t1 do \ Code generated - ** foreach row2 in t2 do |-- by sqlite3WhereBegin() - ** foreach row3 in t3 do / - ** ... - ** end \ Code generated - ** end |-- by sqlite3WhereEnd() - ** end / - ** - ** Note that the loops might not be nested in the order in which they - ** appear in the FROM clause if a different order is better able to make - ** use of indices. Note also that when the IN operator appears in - ** the WHERE clause, it might result in additional nested loops for - ** scanning through all values on the right-hand side of the IN. - ** - ** There are Btree cursors Debug.Associated with each table. t1 uses cursor - ** number pTabList.a[0].iCursor. t2 uses the cursor pTabList.a[1].iCursor. - ** And so forth. This routine generates code to open those VDBE cursors - ** and sqlite3WhereEnd() generates the code to close them. - ** - ** The code that sqlite3WhereBegin() generates leaves the cursors named - ** in pTabList pointing at their appropriate entries. The [...] code - ** can use OP_Column and OP_Rowid opcodes on these cursors to extract - ** data from the various tables of the loop. - ** - ** If the WHERE clause is empty, the foreach loops must each scan their - ** entire tables. Thus a three-way join is an O(N^3) operation. But if - ** the tables have indices and there are terms in the WHERE clause that - ** refer to those indices, a complete table scan can be avoided and the - ** code will run much faster. Most of the work of this routine is checking - ** to see if there are indices that can be used to speed up the loop. - ** - ** Terms of the WHERE clause are also used to limit which rows actually - ** make it to the "..." in the middle of the loop. After each "foreach", - ** terms of the WHERE clause that use only terms in that loop and outer - ** loops are evaluated and if false a jump is made around all subsequent - ** inner loops (or around the "..." if the test occurs within the inner- - ** most loop) - ** - ** OUTER JOINS - ** - ** An outer join of tables t1 and t2 is conceptally coded as follows: - ** - ** foreach row1 in t1 do - ** flag = 0 - ** foreach row2 in t2 do - ** start: - ** ... - ** flag = 1 - ** end - ** if flag==null then - ** move the row2 cursor to a null row - ** goto start - ** fi - ** end - ** - ** ORDER BY CLAUSE PROCESSING - ** - ** ppOrderBy is a pointer to the ORDER BY clause of a SELECT statement, - ** if there is one. If there is no ORDER BY clause or if this routine - ** is called from an UPDATE or DELETE statement, then ppOrderBy is NULL. - ** - ** If an index can be used so that the natural output order of the table - ** scan is correct for the ORDER BY clause, then that index is used and - ** ppOrderBy is set to NULL. This is an optimization that prevents an - ** unnecessary sort of the result set if an index appropriate for the - ** ORDER BY clause already exists. - ** - ** If the where clause loops cannot be arranged to provide the correct - ** output order, then the ppOrderBy is unchanged. - */ - static WhereInfo sqlite3WhereBegin( - Parse pParse, /* The parser context */ - SrcList pTabList, /* A list of all tables to be scanned */ - Expr pWhere, /* The WHERE clause */ - ref ExprList ppOrderBy, /* An ORDER BY clause, or NULL */ - u16 wctrlFlags /* One of the WHERE_* flags defined in sqliteInt.h */ - ) - { - int i; /* Loop counter */ - int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */ - int nTabList; /* Number of elements in pTabList */ - WhereInfo pWInfo; /* Will become the return value of this function */ - Vdbe v = pParse.pVdbe; /* The virtual data_base engine */ - Bitmask notReady; /* Cursors that are not yet positioned */ - WhereMaskSet pMaskSet; /* The expression mask set */ - WhereClause pWC = new WhereClause(); /* Decomposition of the WHERE clause */ - SrcList_item pTabItem; /* A single entry from pTabList */ - WhereLevel pLevel; /* A single level in the pWInfo list */ - int iFrom; /* First unused FROM clause element */ - int andFlags; /* AND-ed combination of all pWC.a[].wtFlags */ - sqlite3 db; /* Data_base connection */ - - /* The number of tables in the FROM clause is limited by the number of - ** bits in a Bitmask - */ - testcase( pTabList.nSrc == BMS ); - if ( pTabList.nSrc > BMS ) - { - sqlite3ErrorMsg( pParse, "at most %d tables in a join", BMS ); - return null; - } - - /* This function normally generates a nested loop for all tables in - ** pTabList. But if the WHERE_ONETABLE_ONLY flag is set, then we should - ** only generate code for the first table in pTabList and assume that - ** any cursors associated with subsequent tables are uninitialized. - */ - nTabList = ( ( wctrlFlags & WHERE_ONETABLE_ONLY ) != 0 ) ? 1 : (int)pTabList.nSrc; - - /* Allocate and initialize the WhereInfo structure that will become the - ** return value. A single allocation is used to store the WhereInfo - ** struct, the contents of WhereInfo.a[], the WhereClause structure - ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte - ** field (type Bitmask) it must be aligned on an 8-byte boundary on - ** some architectures. Hence the ROUND8() below. - */ - db = pParse.db; - pWInfo = new WhereInfo(); - //nByteWInfo = ROUND8(sizeof(WhereInfo)+(nTabList-1)*sizeof(WhereLevel)); - //pWInfo = sqlite3DbMallocZero( db, - // nByteWInfo + - // sizeof( WhereClause ) + - // sizeof( WhereMaskSet ) - //); - pWInfo.a = new WhereLevel[pTabList.nSrc]; - for ( int ai = 0; ai < pWInfo.a.Length; ai++ ) - { - pWInfo.a[ai] = new WhereLevel(); - } - //if ( db.mallocFailed != 0 ) - //{ - //sqlite3DbFree(db, pWInfo); - //pWInfo = 0; - // goto whereBeginError; - //} - pWInfo.nLevel = nTabList; - pWInfo.pParse = pParse; - pWInfo.pTabList = pTabList; - pWInfo.iBreak = sqlite3VdbeMakeLabel( v ); - pWInfo.pWC = pWC = new WhereClause();// (WhereClause )((u8 )pWInfo)[nByteWInfo]; - pWInfo.wctrlFlags = wctrlFlags; - pWInfo.savedNQueryLoop = pParse.nQueryLoop; - //pMaskSet = (WhereMaskSet)pWC[1]; - - /* Split the WHERE clause into separate subexpressions where each - ** subexpression is separated by an AND operator. - */ - pMaskSet = new WhereMaskSet();//initMaskSet(pMaskSet); - whereClauseInit( pWC, pParse, pMaskSet ); - sqlite3ExprCodeConstants( pParse, pWhere ); - whereSplit( pWC, pWhere, TK_AND ); /* IMP: R-15842-53296 */ - - /* Special case: a WHERE clause that is constant. Evaluate the - ** expression and either jump over all of the code or fall thru. - */ - if ( pWhere != null && ( nTabList == 0 || sqlite3ExprIsConstantNotJoin( pWhere ) != 0 ) ) - { - sqlite3ExprIfFalse( pParse, pWhere, pWInfo.iBreak, SQLITE_JUMPIFNULL ); - pWhere = null; - } - - /* Assign a bit from the bitmask to every term in the FROM clause. - ** - ** When assigning bitmask values to FROM clause cursors, it must be - ** the case that if X is the bitmask for the N-th FROM clause term then - ** the bitmask for all FROM clause terms to the left of the N-th term - ** is (X-1). An expression from the ON clause of a LEFT JOIN can use - ** its Expr.iRightJoinTable value to find the bitmask of the right table - ** of the join. Subtracting one from the right table bitmask gives a - ** bitmask for all tables to the left of the join. Knowing the bitmask - ** for all tables to the left of a left join is important. Ticket #3015. - ** - ** Configure the WhereClause.vmask variable so that bits that correspond - ** to virtual table cursors are set. This is used to selectively disable - ** the OR-to-IN transformation in exprAnalyzeOrTerm(). It is not helpful - ** with virtual tables. - ** - ** Note that bitmasks are created for all pTabList.nSrc tables in - ** pTabList, not just the first nTabList tables. nTabList is normally - ** equal to pTabList.nSrc but might be shortened to 1 if the - ** WHERE_ONETABLE_ONLY flag is set. - */ - Debug.Assert( pWC.vmask == 0 && pMaskSet.n == 0 ); - for ( i = 0; i < pTabList.nSrc; i++ ) - { - createMask( pMaskSet, pTabList.a[i].iCursor ); -#if !SQLITE_OMIT_VIRTUALTABLE - if ( ALWAYS( pTabList.a[i].pTab ) && IsVirtual( pTabList.a[i].pTab ) ) - { - pWC.vmask |= ( (Bitmask)1 << i ); - } + static tcl.lang.Var.SQLITE3_GETSET sqlite3_query_plan = new tcl.lang.Var.SQLITE3_GETSET( "sqlite3_query_plan" ); #endif - } -#if !NDEBUG - { - Bitmask toTheLeft = 0; - for ( i = 0; i < pTabList.nSrc; i++ ) - { - Bitmask m = getMask( pMaskSet, pTabList.a[i].iCursor ); - Debug.Assert( ( m - 1 ) == toTheLeft ); - toTheLeft |= m; + static int nQPlan = 0; /* Next free slow in _query_plan[] */ + +#endif //* SQLITE_TEST */ + + + /* + ** Free a WhereInfo structure + */ + static void whereInfoFree(sqlite3 db, WhereInfo pWInfo) { + if (ALWAYS(pWInfo != null)) { + int i; + for (i = 0; i < pWInfo.nLevel; i++) { + sqlite3_index_info pInfo = pWInfo.a[i] != null ? pWInfo.a[i].pIdxInfo : null; + if (pInfo != null) { + /* Debug.Assert( pInfo.needToFreeIdxStr==0 || db.mallocFailed ); */ + if (pInfo.needToFreeIdxStr != 0) { + //sqlite3_free( ref pInfo.idxStr ); + } + sqlite3DbFree(db, ref pInfo); + } + if (pWInfo.a[i] != null && (pWInfo.a[i].plan.wsFlags & WHERE_TEMP_INDEX) != 0) { + Index pIdx = pWInfo.a[i].plan.u.pIdx; + if (pIdx != null) { + sqlite3DbFree(db, ref pIdx.zColAff); + sqlite3DbFree(db, ref pIdx); + } + } + } + whereClauseClear(pWInfo.pWC); + sqlite3DbFree(db, ref pWInfo); + } } - } -#endif - /* Analyze all of the subexpressions. Note that exprAnalyze() might -** add new virtual terms onto the end of the WHERE clause. We do not -** want to analyze these virtual terms, so start analyzing at the end -** and work forward so that the added virtual terms are never processed. -*/ - exprAnalyzeAll( pTabList, pWC ); - //if ( db.mallocFailed != 0 ) - //{ - // goto whereBeginError; - //} - /* Chose the best index to use for each table in the FROM clause. - ** - ** This loop fills in the following fields: - ** - ** pWInfo.a[].pIdx The index to use for this level of the loop. - ** pWInfo.a[].wsFlags WHERE_xxx flags Debug.Associated with pIdx - ** pWInfo.a[].nEq The number of == and IN constraints - ** pWInfo.a[].iFrom Which term of the FROM clause is being coded - ** pWInfo.a[].iTabCur The VDBE cursor for the data_base table - ** pWInfo.a[].iIdxCur The VDBE cursor for the index - ** pWInfo.a[].pTerm When wsFlags==WO_OR, the OR-clause term - ** - ** This loop also figures out the nesting order of tables in the FROM - ** clause. - */ - notReady = ~(Bitmask)0; - andFlags = ~0; -#if (SQLITE_TEST) && (SQLITE_DEBUG) - WHERETRACE( "*** Optimizer Start ***\n" ); -#endif - for ( i = iFrom = 0; i < nTabList; i++ )//, pLevel++ ) - { - pLevel = pWInfo.a[i]; - WhereCost bestPlan; /* Most efficient plan seen so far */ - Index pIdx; /* Index for FROM table at pTabItem */ - int j; /* For looping over FROM tables */ - int bestJ = -1; /* The value of j */ - Bitmask m; /* Bitmask value for j or bestJ */ - int isOptimal; /* Iterator for optimal/non-optimal search */ - int nUnconstrained; /* Number tables without INDEXED BY */ - Bitmask notIndexed; /* Mask of tables that cannot use an index */ - - bestPlan = new WhereCost();// memset( &bestPlan, 0, sizeof( bestPlan ) ); - bestPlan.rCost = SQLITE_BIG_DBL; -#if (SQLITE_TEST) && (SQLITE_DEBUG) - WHERETRACE( "*** Begin search for loop %d ***\n", i ); -#endif + /* + ** Generate the beginning of the loop used for WHERE clause processing. + ** The return value is a pointer to an opaque structure that contains + ** information needed to terminate the loop. Later, the calling routine + ** should invoke sqlite3WhereEnd() with the return value of this function + ** in order to complete the WHERE clause processing. + ** + ** If an error occurs, this routine returns NULL. + ** + ** The basic idea is to do a nested loop, one loop for each table in + ** the FROM clause of a select. (INSERT and UPDATE statements are the + ** same as a SELECT with only a single table in the FROM clause.) For + ** example, if the SQL is this: + ** + ** SELECT * FROM t1, t2, t3 WHERE ...; + ** + ** Then the code generated is conceptually like the following: + ** + ** foreach row1 in t1 do \ Code generated + ** foreach row2 in t2 do |-- by sqlite3WhereBegin() + ** foreach row3 in t3 do / + ** ... + ** end \ Code generated + ** end |-- by sqlite3WhereEnd() + ** end / + ** + ** Note that the loops might not be nested in the order in which they + ** appear in the FROM clause if a different order is better able to make + ** use of indices. Note also that when the IN operator appears in + ** the WHERE clause, it might result in additional nested loops for + ** scanning through all values on the right-hand side of the IN. + ** + ** There are Btree cursors Debug.Associated with each table. t1 uses cursor + ** number pTabList.a[0].iCursor. t2 uses the cursor pTabList.a[1].iCursor. + ** And so forth. This routine generates code to open those VDBE cursors + ** and sqlite3WhereEnd() generates the code to close them. + ** + ** The code that sqlite3WhereBegin() generates leaves the cursors named + ** in pTabList pointing at their appropriate entries. The [...] code + ** can use OP_Column and OP_Rowid opcodes on these cursors to extract + ** data from the various tables of the loop. + ** + ** If the WHERE clause is empty, the foreach loops must each scan their + ** entire tables. Thus a three-way join is an O(N^3) operation. But if + ** the tables have indices and there are terms in the WHERE clause that + ** refer to those indices, a complete table scan can be avoided and the + ** code will run much faster. Most of the work of this routine is checking + ** to see if there are indices that can be used to speed up the loop. + ** + ** Terms of the WHERE clause are also used to limit which rows actually + ** make it to the "..." in the middle of the loop. After each "foreach", + ** terms of the WHERE clause that use only terms in that loop and outer + ** loops are evaluated and if false a jump is made around all subsequent + ** inner loops (or around the "..." if the test occurs within the inner- + ** most loop) + ** + ** OUTER JOINS + ** + ** An outer join of tables t1 and t2 is conceptally coded as follows: + ** + ** foreach row1 in t1 do + ** flag = 0 + ** foreach row2 in t2 do + ** start: + ** ... + ** flag = 1 + ** end + ** if flag==null then + ** move the row2 cursor to a null row + ** goto start + ** fi + ** end + ** + ** ORDER BY CLAUSE PROCESSING + ** + ** ppOrderBy is a pointer to the ORDER BY clause of a SELECT statement, + ** if there is one. If there is no ORDER BY clause or if this routine + ** is called from an UPDATE or DELETE statement, then ppOrderBy is NULL. + ** + ** If an index can be used so that the natural output order of the table + ** scan is correct for the ORDER BY clause, then that index is used and + ** ppOrderBy is set to NULL. This is an optimization that prevents an + ** unnecessary sort of the result set if an index appropriate for the + ** ORDER BY clause already exists. + ** + ** If the where clause loops cannot be arranged to provide the correct + ** output order, then the ppOrderBy is unchanged. + */ + static WhereInfo sqlite3WhereBegin( + Parse pParse, /* The parser context */ + SrcList pTabList, /* A list of all tables to be scanned */ + Expr pWhere, /* The WHERE clause */ + ref ExprList ppOrderBy, /* An ORDER BY clause, or NULL */ + u16 wctrlFlags /* One of the WHERE_* flags defined in sqliteInt.h */ + ) { + int i; /* Loop counter */ + int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */ + int nTabList; /* Number of elements in pTabList */ + WhereInfo pWInfo; /* Will become the return value of this function */ + Vdbe v = pParse.pVdbe; /* The virtual data_base engine */ + Bitmask notReady; /* Cursors that are not yet positioned */ + WhereMaskSet pMaskSet; /* The expression mask set */ + WhereClause pWC = new WhereClause(); /* Decomposition of the WHERE clause */ + SrcList_item pTabItem; /* A single entry from pTabList */ + WhereLevel pLevel; /* A single level in the pWInfo list */ + int iFrom; /* First unused FROM clause element */ + int andFlags; /* AND-ed combination of all pWC.a[].wtFlags */ + sqlite3 db; /* Data_base connection */ + + /* The number of tables in the FROM clause is limited by the number of + ** bits in a Bitmask + */ + testcase(pTabList.nSrc == BMS); + if (pTabList.nSrc > BMS) { + sqlite3ErrorMsg(pParse, "at most %d tables in a join", BMS); + return null; + } - /* Loop through the remaining entries in the FROM clause to find the -** next nested loop. The loop tests all FROM clause entries -** either once or twice. -** -** The first test is always performed if there are two or more entries -** remaining and never performed if there is only one FROM clause entry -** to choose from. The first test looks for an "optimal" scan. In -** this context an optimal scan is one that uses the same strategy -** for the given FROM clause entry as would be selected if the entry -** were used as the innermost nested loop. In other words, a table -** is chosen such that the cost of running that table cannot be reduced -** by waiting for other tables to run first. This "optimal" test works -** by first assuming that the FROM clause is on the inner loop and finding -** its query plan, then checking to see if that query plan uses any -** other FROM clause terms that are notReady. If no notReady terms are -** used then the "optimal" query plan works. -** -** Note that the WhereCost.nRow parameter for an optimal scan might -** not be as small as it would be if the table really were the innermost -** join. The nRow value can be reduced by WHERE clause constraints -** that do not use indices. But this nRow reduction only happens if the -** table really is the innermost join. -** -** The second loop iteration is only performed if no optimal scan -** strategies were found by the first iteration. This second iteration -** is used to search for the lowest cost scan overall. -** -** Previous versions of SQLite performed only the second iteration - -** the next outermost loop was always that with the lowest overall -** cost. However, this meant that SQLite could select the wrong plan -** for scripts such as the following: -** -** CREATE TABLE t1(a, b); -** CREATE TABLE t2(c, d); -** SELECT * FROM t2, t1 WHERE t2.rowid = t1.a; -** -** The best strategy is to iterate through table t1 first. However it -** is not possible to determine this with a simple greedy algorithm. -** Since the cost of a linear scan through table t2 is the same -** as the cost of a linear scan through table t1, a simple greedy -** algorithm may choose to use t2 for the outer loop, which is a much -** costlier approach. -*/ - nUnconstrained = 0; - notIndexed = 0; - for ( isOptimal = ( iFrom < nTabList - 1 ) ? 1 : 0; isOptimal >= 0 && bestJ < 0; isOptimal-- ) - { - Bitmask mask; /* Mask of tables not yet ready */ - for ( j = iFrom; j < nTabList; j++ )//, pTabItem++) - { - pTabItem = pTabList.a[j]; - int doNotReorder; /* True if this table should not be reordered */ - WhereCost sCost = new WhereCost(); /* Cost information from best[Virtual]Index() */ - ExprList pOrderBy; /* ORDER BY clause for index to optimize */ + /* This function normally generates a nested loop for all tables in + ** pTabList. But if the WHERE_ONETABLE_ONLY flag is set, then we should + ** only generate code for the first table in pTabList and assume that + ** any cursors associated with subsequent tables are uninitialized. + */ + nTabList = ((wctrlFlags & WHERE_ONETABLE_ONLY) != 0) ? 1 : (int)pTabList.nSrc; + + /* Allocate and initialize the WhereInfo structure that will become the + ** return value. A single allocation is used to store the WhereInfo + ** struct, the contents of WhereInfo.a[], the WhereClause structure + ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte + ** field (type Bitmask) it must be aligned on an 8-byte boundary on + ** some architectures. Hence the ROUND8() below. + */ + db = pParse.db; + pWInfo = new WhereInfo(); + //nByteWInfo = ROUND8(sizeof(WhereInfo)+(nTabList-1)*sizeof(WhereLevel)); + //pWInfo = sqlite3DbMallocZero( db, + // nByteWInfo + + // sizeof( WhereClause ) + + // sizeof( WhereMaskSet ) + //); + pWInfo.a = new WhereLevel[pTabList.nSrc]; + for (int ai = 0; ai < pWInfo.a.Length; ai++) { + pWInfo.a[ai] = new WhereLevel(); + } + //if ( db.mallocFailed != 0 ) + //{ + //sqlite3DbFree(db, pWInfo); + //pWInfo = 0; + // goto whereBeginError; + //} + pWInfo.nLevel = nTabList; + pWInfo.pParse = pParse; + pWInfo.pTabList = pTabList; + pWInfo.iBreak = sqlite3VdbeMakeLabel(v); + pWInfo.pWC = pWC = new WhereClause();// (WhereClause )((u8 )pWInfo)[nByteWInfo]; + pWInfo.wctrlFlags = wctrlFlags; + pWInfo.savedNQueryLoop = pParse.nQueryLoop; + //pMaskSet = (WhereMaskSet)pWC[1]; + + /* Split the WHERE clause into separate subexpressions where each + ** subexpression is separated by an AND operator. + */ + pMaskSet = new WhereMaskSet();//initMaskSet(pMaskSet); + whereClauseInit(pWC, pParse, pMaskSet); + sqlite3ExprCodeConstants(pParse, pWhere); + whereSplit(pWC, pWhere, TK_AND); /* IMP: R-15842-53296 */ - doNotReorder = ( pTabItem.jointype & ( JT_LEFT | JT_CROSS ) ) != 0 ? 1 : 0; - if ( ( j != iFrom && doNotReorder != 0 ) ) - break; - m = getMask( pMaskSet, pTabItem.iCursor ); - if ( ( m & notReady ) == 0 ) - { - if ( j == iFrom ) - iFrom++; - continue; + /* Special case: a WHERE clause that is constant. Evaluate the + ** expression and either jump over all of the code or fall thru. + */ + if (pWhere != null && (nTabList == 0 || sqlite3ExprIsConstantNotJoin(pWhere) != 0)) { + sqlite3ExprIfFalse(pParse, pWhere, pWInfo.iBreak, SQLITE_JUMPIFNULL); + pWhere = null; } - mask = ( isOptimal != 0 ? m : notReady ); - pOrderBy = ( ( i == 0 && ppOrderBy != null ) ? ppOrderBy : null ); - if ( pTabItem.pIndex == null ) - nUnconstrained++; -#if (SQLITE_TEST) && (SQLITE_DEBUG) - WHERETRACE( "=== trying table %d with isOptimal=%d ===\n", - j, isOptimal ); + /* Assign a bit from the bitmask to every term in the FROM clause. + ** + ** When assigning bitmask values to FROM clause cursors, it must be + ** the case that if X is the bitmask for the N-th FROM clause term then + ** the bitmask for all FROM clause terms to the left of the N-th term + ** is (X-1). An expression from the ON clause of a LEFT JOIN can use + ** its Expr.iRightJoinTable value to find the bitmask of the right table + ** of the join. Subtracting one from the right table bitmask gives a + ** bitmask for all tables to the left of the join. Knowing the bitmask + ** for all tables to the left of a left join is important. Ticket #3015. + ** + ** Configure the WhereClause.vmask variable so that bits that correspond + ** to virtual table cursors are set. This is used to selectively disable + ** the OR-to-IN transformation in exprAnalyzeOrTerm(). It is not helpful + ** with virtual tables. + ** + ** Note that bitmasks are created for all pTabList.nSrc tables in + ** pTabList, not just the first nTabList tables. nTabList is normally + ** equal to pTabList.nSrc but might be shortened to 1 if the + ** WHERE_ONETABLE_ONLY flag is set. + */ + Debug.Assert(pWC.vmask == 0 && pMaskSet.n == 0); + for (i = 0; i < pTabList.nSrc; i++) { + createMask(pMaskSet, pTabList.a[i].iCursor); +#if !SQLITE_OMIT_VIRTUALTABLE + if (ALWAYS(pTabList.a[i].pTab) && IsVirtual(pTabList.a[i].pTab)) { + pWC.vmask |= ((Bitmask)1 << i); + } #endif - Debug.Assert( pTabItem.pTab != null ); -#if !SQLITE_OMIT_VIRTUALTABLE - if ( IsVirtual( pTabItem.pTab ) ) - { - sqlite3_index_info pp = pWInfo.a[j].pIdxInfo; - bestVirtualIndex( pParse, pWC, pTabItem, mask, notReady, pOrderBy, - ref sCost, ref pp ); } - else -#endif +#if !NDEBUG { - bestBtreeIndex( pParse, pWC, pTabItem, mask, notReady, pOrderBy, - ref sCost ); + Bitmask toTheLeft = 0; + for (i = 0; i < pTabList.nSrc; i++) { + Bitmask m = getMask(pMaskSet, pTabList.a[i].iCursor); + Debug.Assert((m - 1) == toTheLeft); + toTheLeft |= m; + } } - Debug.Assert( isOptimal != 0 || ( sCost.used & notReady ) == 0 ); - - /* If an INDEXED BY clause is present, then the plan must use that - ** index if it uses any index at all */ - Debug.Assert( pTabItem.pIndex == null - || ( sCost.plan.wsFlags & WHERE_NOT_FULLSCAN ) == 0 - || sCost.plan.u.pIdx == pTabItem.pIndex ); +#endif - if ( isOptimal != 0 && ( sCost.plan.wsFlags & WHERE_NOT_FULLSCAN ) == 0 ) - { - notIndexed |= m; - } + /* Analyze all of the subexpressions. Note that exprAnalyze() might + ** add new virtual terms onto the end of the WHERE clause. We do not + ** want to analyze these virtual terms, so start analyzing at the end + ** and work forward so that the added virtual terms are never processed. + */ + exprAnalyzeAll(pTabList, pWC); + //if ( db.mallocFailed != 0 ) + //{ + // goto whereBeginError; + //} - /* Conditions under which this table becomes the best so far: - ** - ** (1) The table must not depend on other tables that have not - ** yet run. + /* Chose the best index to use for each table in the FROM clause. ** - ** (2) A full-table-scan plan cannot supercede indexed plan unless - ** the full-table-scan is an "optimal" plan as defined above. + ** This loop fills in the following fields: ** - ** (3) All tables have an INDEXED BY clause or this table lacks an - ** INDEXED BY clause or this table uses the specific - ** index specified by its INDEXED BY clause. This rule ensures - ** that a best-so-far is always selected even if an impossible - ** combination of INDEXED BY clauses are given. The error - ** will be detected and relayed back to the application later. - ** The NEVER() comes about because rule (2) above prevents - ** An indexable full-table-scan from reaching rule (3). + ** pWInfo.a[].pIdx The index to use for this level of the loop. + ** pWInfo.a[].wsFlags WHERE_xxx flags Debug.Associated with pIdx + ** pWInfo.a[].nEq The number of == and IN constraints + ** pWInfo.a[].iFrom Which term of the FROM clause is being coded + ** pWInfo.a[].iTabCur The VDBE cursor for the data_base table + ** pWInfo.a[].iIdxCur The VDBE cursor for the index + ** pWInfo.a[].pTerm When wsFlags==WO_OR, the OR-clause term ** - ** (4) The plan cost must be lower than prior plans or else the - ** cost must be the same and the number of rows must be lower. + ** This loop also figures out the nesting order of tables in the FROM + ** clause. */ - if ( ( sCost.used & notReady ) == 0 /* (1) */ - && ( bestJ < 0 || ( notIndexed & m ) != 0 /* (2) */ - || ( bestPlan.plan.wsFlags & WHERE_NOT_FULLSCAN ) == 0 - || ( sCost.plan.wsFlags & WHERE_NOT_FULLSCAN ) != 0 ) - && ( nUnconstrained == 0 || pTabItem.pIndex == null /* (3) */ - || NEVER( ( sCost.plan.wsFlags & WHERE_NOT_FULLSCAN ) != 0 ) ) - && ( bestJ < 0 || sCost.rCost < bestPlan.rCost /* (4) */ - || ( sCost.rCost <= bestPlan.rCost - && sCost.plan.nRow < bestPlan.plan.nRow ) ) - ) + notReady = ~(Bitmask)0; + andFlags = ~0; +#if (SQLITE_TEST) && (SQLITE_DEBUG) + WHERETRACE( "*** Optimizer Start ***\n" ); +#endif + for (i = iFrom = 0; i < nTabList; i++)//, pLevel++ ) { -#if (SQLITE_TEST) && (SQLITE_DEBUG) + pLevel = pWInfo.a[i]; + WhereCost bestPlan; /* Most efficient plan seen so far */ + Index pIdx; /* Index for FROM table at pTabItem */ + int j; /* For looping over FROM tables */ + int bestJ = -1; /* The value of j */ + Bitmask m; /* Bitmask value for j or bestJ */ + int isOptimal; /* Iterator for optimal/non-optimal search */ + int nUnconstrained; /* Number tables without INDEXED BY */ + Bitmask notIndexed; /* Mask of tables that cannot use an index */ + + bestPlan = new WhereCost();// memset( &bestPlan, 0, sizeof( bestPlan ) ); + bestPlan.rCost = SQLITE_BIG_DBL; +#if (SQLITE_TEST) && (SQLITE_DEBUG) + WHERETRACE( "*** Begin search for loop %d ***\n", i ); +#endif + + /* Loop through the remaining entries in the FROM clause to find the + ** next nested loop. The loop tests all FROM clause entries + ** either once or twice. + ** + ** The first test is always performed if there are two or more entries + ** remaining and never performed if there is only one FROM clause entry + ** to choose from. The first test looks for an "optimal" scan. In + ** this context an optimal scan is one that uses the same strategy + ** for the given FROM clause entry as would be selected if the entry + ** were used as the innermost nested loop. In other words, a table + ** is chosen such that the cost of running that table cannot be reduced + ** by waiting for other tables to run first. This "optimal" test works + ** by first assuming that the FROM clause is on the inner loop and finding + ** its query plan, then checking to see if that query plan uses any + ** other FROM clause terms that are notReady. If no notReady terms are + ** used then the "optimal" query plan works. + ** + ** Note that the WhereCost.nRow parameter for an optimal scan might + ** not be as small as it would be if the table really were the innermost + ** join. The nRow value can be reduced by WHERE clause constraints + ** that do not use indices. But this nRow reduction only happens if the + ** table really is the innermost join. + ** + ** The second loop iteration is only performed if no optimal scan + ** strategies were found by the first iteration. This second iteration + ** is used to search for the lowest cost scan overall. + ** + ** Previous versions of SQLite performed only the second iteration - + ** the next outermost loop was always that with the lowest overall + ** cost. However, this meant that SQLite could select the wrong plan + ** for scripts such as the following: + ** + ** CREATE TABLE t1(a, b); + ** CREATE TABLE t2(c, d); + ** SELECT * FROM t2, t1 WHERE t2.rowid = t1.a; + ** + ** The best strategy is to iterate through table t1 first. However it + ** is not possible to determine this with a simple greedy algorithm. + ** Since the cost of a linear scan through table t2 is the same + ** as the cost of a linear scan through table t1, a simple greedy + ** algorithm may choose to use t2 for the outer loop, which is a much + ** costlier approach. + */ + nUnconstrained = 0; + notIndexed = 0; + for (isOptimal = (iFrom < nTabList - 1) ? 1 : 0; isOptimal >= 0 && bestJ < 0; isOptimal--) { + Bitmask mask; /* Mask of tables not yet ready */ + for (j = iFrom; j < nTabList; j++)//, pTabItem++) + { + pTabItem = pTabList.a[j]; + int doNotReorder; /* True if this table should not be reordered */ + WhereCost sCost = new WhereCost(); /* Cost information from best[Virtual]Index() */ + ExprList pOrderBy; /* ORDER BY clause for index to optimize */ + + doNotReorder = (pTabItem.jointype & (JT_LEFT | JT_CROSS)) != 0 ? 1 : 0; + if ((j != iFrom && doNotReorder != 0)) + break; + m = getMask(pMaskSet, pTabItem.iCursor); + if ((m & notReady) == 0) { + if (j == iFrom) + iFrom++; + continue; + } + mask = (isOptimal != 0 ? m : notReady); + pOrderBy = ((i == 0 && ppOrderBy != null) ? ppOrderBy : null); + if (pTabItem.pIndex == null) + nUnconstrained++; + +#if (SQLITE_TEST) && (SQLITE_DEBUG) + WHERETRACE( "=== trying table %d with isOptimal=%d ===\n", + j, isOptimal ); +#endif + Debug.Assert(pTabItem.pTab != null); +#if !SQLITE_OMIT_VIRTUALTABLE + if (IsVirtual(pTabItem.pTab)) { + sqlite3_index_info pp = pWInfo.a[j].pIdxInfo; + bestVirtualIndex(pParse, pWC, pTabItem, mask, notReady, pOrderBy, + ref sCost, ref pp); + } else +#endif + { + bestBtreeIndex(pParse, pWC, pTabItem, mask, notReady, pOrderBy, + ref sCost); + } + Debug.Assert(isOptimal != 0 || (sCost.used & notReady) == 0); + + /* If an INDEXED BY clause is present, then the plan must use that + ** index if it uses any index at all */ + Debug.Assert(pTabItem.pIndex == null + || (sCost.plan.wsFlags & WHERE_NOT_FULLSCAN) == 0 + || sCost.plan.u.pIdx == pTabItem.pIndex); + + if (isOptimal != 0 && (sCost.plan.wsFlags & WHERE_NOT_FULLSCAN) == 0) { + notIndexed |= m; + } + + /* Conditions under which this table becomes the best so far: + ** + ** (1) The table must not depend on other tables that have not + ** yet run. + ** + ** (2) A full-table-scan plan cannot supercede indexed plan unless + ** the full-table-scan is an "optimal" plan as defined above. + ** + ** (3) All tables have an INDEXED BY clause or this table lacks an + ** INDEXED BY clause or this table uses the specific + ** index specified by its INDEXED BY clause. This rule ensures + ** that a best-so-far is always selected even if an impossible + ** combination of INDEXED BY clauses are given. The error + ** will be detected and relayed back to the application later. + ** The NEVER() comes about because rule (2) above prevents + ** An indexable full-table-scan from reaching rule (3). + ** + ** (4) The plan cost must be lower than prior plans or else the + ** cost must be the same and the number of rows must be lower. + */ + if ((sCost.used & notReady) == 0 /* (1) */ + && (bestJ < 0 || (notIndexed & m) != 0 /* (2) */ + || (bestPlan.plan.wsFlags & WHERE_NOT_FULLSCAN) == 0 + || (sCost.plan.wsFlags & WHERE_NOT_FULLSCAN) != 0) + && (nUnconstrained == 0 || pTabItem.pIndex == null /* (3) */ + || NEVER((sCost.plan.wsFlags & WHERE_NOT_FULLSCAN) != 0)) + && (bestJ < 0 || sCost.rCost < bestPlan.rCost /* (4) */ + || (sCost.rCost <= bestPlan.rCost + && sCost.plan.nRow < bestPlan.plan.nRow)) + ) { +#if (SQLITE_TEST) && (SQLITE_DEBUG) WHERETRACE( "=== table %d is best so far" + " with cost=%g and nRow=%g\n", j, sCost.rCost, sCost.plan.nRow ); #endif - bestPlan = sCost; - bestJ = j; - } - if ( doNotReorder != 0 ) - break; - } - } - Debug.Assert( bestJ >= 0 ); - Debug.Assert( ( notReady & getMask( pMaskSet, pTabList.a[bestJ].iCursor ) ) != 0 ); + bestPlan = sCost; + bestJ = j; + } + if (doNotReorder != 0) + break; + } + } + Debug.Assert(bestJ >= 0); + Debug.Assert((notReady & getMask(pMaskSet, pTabList.a[bestJ].iCursor)) != 0); #if (SQLITE_TEST) && (SQLITE_DEBUG) WHERETRACE( "*** Optimizer selects table %d for loop %d" + " with cost=%g and nRow=%g\n", bestJ, i,//pLevel-pWInfo.a, bestPlan.rCost, bestPlan.plan.nRow ); #endif - if ( ( bestPlan.plan.wsFlags & WHERE_ORDERBY ) != 0 ) - { - ppOrderBy = null; - } - andFlags = (int)( andFlags & bestPlan.plan.wsFlags ); - pLevel.plan = bestPlan.plan; - testcase( bestPlan.plan.wsFlags & WHERE_INDEXED ); - testcase( bestPlan.plan.wsFlags & WHERE_TEMP_INDEX ); - if ( ( bestPlan.plan.wsFlags & ( WHERE_INDEXED | WHERE_TEMP_INDEX ) ) != 0 ) - { - pLevel.iIdxCur = pParse.nTab++; - } - else - { - pLevel.iIdxCur = -1; - } - notReady &= ~getMask( pMaskSet, pTabList.a[bestJ].iCursor ); - pLevel.iFrom = (u8)bestJ; - if ( bestPlan.plan.nRow >= (double)1 ) - { - pParse.nQueryLoop *= bestPlan.plan.nRow; - } + if ((bestPlan.plan.wsFlags & WHERE_ORDERBY) != 0) { + ppOrderBy = null; + } + andFlags = (int)(andFlags & bestPlan.plan.wsFlags); + pLevel.plan = bestPlan.plan; + testcase(bestPlan.plan.wsFlags & WHERE_INDEXED); + testcase(bestPlan.plan.wsFlags & WHERE_TEMP_INDEX); + if ((bestPlan.plan.wsFlags & (WHERE_INDEXED | WHERE_TEMP_INDEX)) != 0) { + pLevel.iIdxCur = pParse.nTab++; + } else { + pLevel.iIdxCur = -1; + } + notReady &= ~getMask(pMaskSet, pTabList.a[bestJ].iCursor); + pLevel.iFrom = (u8)bestJ; + if (bestPlan.plan.nRow >= (double)1) { + pParse.nQueryLoop *= bestPlan.plan.nRow; + } - /* Check that if the table scanned by this loop iteration had an - ** INDEXED BY clause attached to it, that the named index is being - ** used for the scan. If not, then query compilation has failed. - ** Return an error. - */ - pIdx = pTabList.a[bestJ].pIndex; - if ( pIdx != null ) - { - if ( ( bestPlan.plan.wsFlags & WHERE_INDEXED ) == 0 ) - { - sqlite3ErrorMsg( pParse, "cannot use index: %s", pIdx.zName ); - goto whereBeginError; - } - else - { - /* If an INDEXED BY clause is used, the bestIndex() function is - ** guaranteed to find the index specified in the INDEXED BY clause - ** if it find an index at all. */ - Debug.Assert( bestPlan.plan.u.pIdx == pIdx ); - } - } - } + /* Check that if the table scanned by this loop iteration had an + ** INDEXED BY clause attached to it, that the named index is being + ** used for the scan. If not, then query compilation has failed. + ** Return an error. + */ + pIdx = pTabList.a[bestJ].pIndex; + if (pIdx != null) { + if ((bestPlan.plan.wsFlags & WHERE_INDEXED) == 0) { + sqlite3ErrorMsg(pParse, "cannot use index: %s", pIdx.zName); + goto whereBeginError; + } else { + /* If an INDEXED BY clause is used, the bestIndex() function is + ** guaranteed to find the index specified in the INDEXED BY clause + ** if it find an index at all. */ + Debug.Assert(bestPlan.plan.u.pIdx == pIdx); + } + } + } #if (SQLITE_TEST) && (SQLITE_DEBUG) WHERETRACE( "*** Optimizer Finished ***\n" ); #endif - if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) - { - goto whereBeginError; - } - - /* If the total query only selects a single row, then the ORDER BY - ** clause is irrelevant. - */ - if ( ( andFlags & WHERE_UNIQUE ) != 0 && ppOrderBy != null ) - { - ppOrderBy = null; - } + if (pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) { + goto whereBeginError; + } - /* If the caller is an UPDATE or DELETE statement that is requesting - ** to use a one-pDebug.Ass algorithm, determine if this is appropriate. - ** The one-pass algorithm only works if the WHERE clause constraints - ** the statement to update a single row. - */ - Debug.Assert( ( wctrlFlags & WHERE_ONEPASS_DESIRED ) == 0 || pWInfo.nLevel == 1 ); - if ( ( wctrlFlags & WHERE_ONEPASS_DESIRED ) != 0 && ( andFlags & WHERE_UNIQUE ) != 0 ) - { - pWInfo.okOnePass = 1; - pWInfo.a[0].plan.wsFlags = (u32)( pWInfo.a[0].plan.wsFlags & ~WHERE_IDX_ONLY ); - } + /* If the total query only selects a single row, then the ORDER BY + ** clause is irrelevant. + */ + if ((andFlags & WHERE_UNIQUE) != 0 && ppOrderBy != null) { + ppOrderBy = null; + } - /* Open all tables in the pTabList and any indices selected for - ** searching those tables. - */ - sqlite3CodeVerifySchema( pParse, -1 ); /* Insert the cookie verifier Goto */ - notReady = ~(Bitmask)0; - pWInfo.nRowOut = (double)1; - for ( i = 0; i < nTabList; i++ )//, pLevel++ ) - { - pLevel = pWInfo.a[i]; - Table pTab; /* Table to open */ - int iDb; /* Index of data_base containing table/index */ + /* If the caller is an UPDATE or DELETE statement that is requesting + ** to use a one-pDebug.Ass algorithm, determine if this is appropriate. + ** The one-pass algorithm only works if the WHERE clause constraints + ** the statement to update a single row. + */ + Debug.Assert((wctrlFlags & WHERE_ONEPASS_DESIRED) == 0 || pWInfo.nLevel == 1); + if ((wctrlFlags & WHERE_ONEPASS_DESIRED) != 0 && (andFlags & WHERE_UNIQUE) != 0) { + pWInfo.okOnePass = 1; + pWInfo.a[0].plan.wsFlags = (u32)(pWInfo.a[0].plan.wsFlags & ~WHERE_IDX_ONLY); + } - pTabItem = pTabList.a[pLevel.iFrom]; - pTab = pTabItem.pTab; - pLevel.iTabCur = pTabItem.iCursor; - pWInfo.nRowOut *= pLevel.plan.nRow; - iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); - if ( ( pTab.tabFlags & TF_Ephemeral ) != 0 || pTab.pSelect != null ) - { - /* Do nothing */ - } - else -#if !SQLITE_OMIT_VIRTUALTABLE - if ( ( pLevel.plan.wsFlags & WHERE_VIRTUALTABLE ) != 0 ) - { - VTable pVTab = sqlite3GetVTable( db, pTab ); - int iCur = pTabItem.iCursor; - sqlite3VdbeAddOp4( v, OP_VOpen, iCur, 0, 0, - pVTab, P4_VTAB ); - } - else -#endif - if ( ( pLevel.plan.wsFlags & WHERE_IDX_ONLY ) == 0 - && ( wctrlFlags & WHERE_OMIT_OPEN ) == 0 ) + /* Open all tables in the pTabList and any indices selected for + ** searching those tables. + */ + sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */ + notReady = ~(Bitmask)0; + pWInfo.nRowOut = (double)1; + for (i = 0; i < nTabList; i++)//, pLevel++ ) { - int op = pWInfo.okOnePass != 0 ? OP_OpenWrite : OP_OpenRead; - sqlite3OpenTable( pParse, pTabItem.iCursor, iDb, pTab, op ); - testcase( pTab.nCol == BMS - 1 ); - testcase( pTab.nCol == BMS ); - if ( 0 == pWInfo.okOnePass && pTab.nCol < BMS ) - { - Bitmask b = pTabItem.colUsed; - int n = 0; - for ( ; b != 0; b = b >> 1, n++ ) - { + pLevel = pWInfo.a[i]; + Table pTab; /* Table to open */ + int iDb; /* Index of data_base containing table/index */ + + pTabItem = pTabList.a[pLevel.iFrom]; + pTab = pTabItem.pTab; + pLevel.iTabCur = pTabItem.iCursor; + pWInfo.nRowOut *= pLevel.plan.nRow; + iDb = sqlite3SchemaToIndex(db, pTab.pSchema); + if ((pTab.tabFlags & TF_Ephemeral) != 0 || pTab.pSelect != null) { + /* Do nothing */ + } else +#if !SQLITE_OMIT_VIRTUALTABLE + if ((pLevel.plan.wsFlags & WHERE_VIRTUALTABLE) != 0) { + VTable pVTab = sqlite3GetVTable(db, pTab); + int iCur = pTabItem.iCursor; + sqlite3VdbeAddOp4(v, OP_VOpen, iCur, 0, 0, + pVTab, P4_VTAB); + } else +#endif + if ((pLevel.plan.wsFlags & WHERE_IDX_ONLY) == 0 + && (wctrlFlags & WHERE_OMIT_OPEN) == 0) { + int op = pWInfo.okOnePass != 0 ? OP_OpenWrite : OP_OpenRead; + sqlite3OpenTable(pParse, pTabItem.iCursor, iDb, pTab, op); + testcase(pTab.nCol == BMS - 1); + testcase(pTab.nCol == BMS); + if (0 == pWInfo.okOnePass && pTab.nCol < BMS) { + Bitmask b = pTabItem.colUsed; + int n = 0; + for (; b != 0; b = b >> 1, n++) { + } + sqlite3VdbeChangeP4(v, sqlite3VdbeCurrentAddr(v) - 1, + n, P4_INT32);//SQLITE_INT_TO_PTR(n) + Debug.Assert(n <= pTab.nCol); + } + } else { + sqlite3TableLock(pParse, iDb, pTab.tnum, 0, pTab.zName); } - sqlite3VdbeChangeP4( v, sqlite3VdbeCurrentAddr( v ) - 1, - n, P4_INT32 );//SQLITE_INT_TO_PTR(n) - Debug.Assert( n <= pTab.nCol ); - } - } - else - { - sqlite3TableLock( pParse, iDb, pTab.tnum, 0, pTab.zName ); - } #if !SQLITE_OMIT_AUTOMATIC_INDEX - if ( ( pLevel.plan.wsFlags & WHERE_TEMP_INDEX ) != 0 ) - { - constructAutomaticIndex( pParse, pWC, pTabItem, notReady, pLevel ); - } - else + if ((pLevel.plan.wsFlags & WHERE_TEMP_INDEX) != 0) { + constructAutomaticIndex(pParse, pWC, pTabItem, notReady, pLevel); + } else #endif - if ( ( pLevel.plan.wsFlags & WHERE_INDEXED ) != 0 ) - { - Index pIx = pLevel.plan.u.pIdx; - KeyInfo pKey = sqlite3IndexKeyinfo( pParse, pIx ); - int iIdxCur = pLevel.iIdxCur; - Debug.Assert( pIx.pSchema == pTab.pSchema ); - Debug.Assert( iIdxCur >= 0 ); - sqlite3VdbeAddOp4( v, OP_OpenRead, iIdxCur, pIx.tnum, iDb, - pKey, P4_KEYINFO_HANDOFF ); + if ((pLevel.plan.wsFlags & WHERE_INDEXED) != 0) { + Index pIx = pLevel.plan.u.pIdx; + KeyInfo pKey = sqlite3IndexKeyinfo(pParse, pIx); + int iIdxCur = pLevel.iIdxCur; + Debug.Assert(pIx.pSchema == pTab.pSchema); + Debug.Assert(iIdxCur >= 0); + sqlite3VdbeAddOp4(v, OP_OpenRead, iIdxCur, pIx.tnum, iDb, + pKey, P4_KEYINFO_HANDOFF); #if SQLITE_DEBUG - VdbeComment( v, "%s", pIx.zName ); + VdbeComment(v, "%s", pIx.zName); #endif - } - sqlite3CodeVerifySchema( pParse, iDb ); - notReady &= ~getMask( pWC.pMaskSet, pTabItem.iCursor ); - } - pWInfo.iTop = sqlite3VdbeCurrentAddr( v ); - //if( db.mallocFailed ) goto whereBeginError; + } + sqlite3CodeVerifySchema(pParse, iDb); + notReady &= ~getMask(pWC.pMaskSet, pTabItem.iCursor); + } + pWInfo.iTop = sqlite3VdbeCurrentAddr(v); + //if( db.mallocFailed ) goto whereBeginError; - /* Generate the code to do the search. Each iteration of the for - ** loop below generates code for a single nested loop of the VM - ** program. - */ - notReady = ~(Bitmask)0; - for ( i = 0; i < nTabList; i++ ) - { - pLevel = pWInfo.a[i]; - explainOneScan( pParse, pTabList, pLevel, i, pLevel.iFrom, wctrlFlags ); - notReady = codeOneLoopStart( pWInfo, i, wctrlFlags, notReady ); - pWInfo.iContinue = pLevel.addrCont; - } + /* Generate the code to do the search. Each iteration of the for + ** loop below generates code for a single nested loop of the VM + ** program. + */ + notReady = ~(Bitmask)0; + for (i = 0; i < nTabList; i++) { + pLevel = pWInfo.a[i]; + explainOneScan(pParse, pTabList, pLevel, i, pLevel.iFrom, wctrlFlags); + notReady = codeOneLoopStart(pWInfo, i, wctrlFlags, notReady); + pWInfo.iContinue = pLevel.addrCont; + } #if SQLITE_TEST //* For testing and debugging use only */ /* Record in the query plan information about the current table @@ -5671,173 +5228,154 @@ u16 wctrlFlags /* One of the WHERE_* flags defined in sqliteInt.h */ nQPlan = 0; #endif //* SQLITE_TEST // Testing and debugging use only */ - /* Record the continuation address in the WhereInfo structure. Then -** clean up and return. -*/ - return pWInfo; - - /* Jump here if malloc fails */ -whereBeginError: - if ( pWInfo != null ) - { - pParse.nQueryLoop = pWInfo.savedNQueryLoop; - whereInfoFree( db, pWInfo ); - } - return null; - } - - /* - ** Generate the end of the WHERE loop. See comments on - ** sqlite3WhereBegin() for additional information. - */ - static void sqlite3WhereEnd( WhereInfo pWInfo ) - { - Parse pParse = pWInfo.pParse; - Vdbe v = pParse.pVdbe; - int i; - WhereLevel pLevel; - SrcList pTabList = pWInfo.pTabList; - sqlite3 db = pParse.db; - - /* Generate loop termination code. - */ - sqlite3ExprCacheClear( pParse ); - for ( i = pWInfo.nLevel - 1; i >= 0; i-- ) - { - pLevel = pWInfo.a[i]; - sqlite3VdbeResolveLabel( v, pLevel.addrCont ); - if ( pLevel.op != OP_Noop ) - { - sqlite3VdbeAddOp2( v, pLevel.op, pLevel.p1, pLevel.p2 ); - sqlite3VdbeChangeP5( v, pLevel.p5 ); - } - if ( ( pLevel.plan.wsFlags & WHERE_IN_ABLE ) != 0 && pLevel.u._in.nIn > 0 ) - { - InLoop pIn; - int j; - sqlite3VdbeResolveLabel( v, pLevel.addrNxt ); - for ( j = pLevel.u._in.nIn; j > 0; j-- )//, pIn--) - { - pIn = pLevel.u._in.aInLoop[j - 1]; - sqlite3VdbeJumpHere( v, pIn.addrInTop + 1 ); - sqlite3VdbeAddOp2( v, OP_Next, pIn.iCur, pIn.addrInTop ); - sqlite3VdbeJumpHere( v, pIn.addrInTop - 1 ); - } - sqlite3DbFree( db, ref pLevel.u._in.aInLoop ); - } - sqlite3VdbeResolveLabel( v, pLevel.addrBrk ); - if ( pLevel.iLeftJoin != 0 ) - { - int addr; - addr = sqlite3VdbeAddOp1( v, OP_IfPos, pLevel.iLeftJoin ); - Debug.Assert( ( pLevel.plan.wsFlags & WHERE_IDX_ONLY ) == 0 - || ( pLevel.plan.wsFlags & WHERE_INDEXED ) != 0 ); - if ( ( pLevel.plan.wsFlags & WHERE_IDX_ONLY ) == 0 ) - { - sqlite3VdbeAddOp1( v, OP_NullRow, pTabList.a[i].iCursor ); - } - if ( pLevel.iIdxCur >= 0 ) - { - sqlite3VdbeAddOp1( v, OP_NullRow, pLevel.iIdxCur ); - } - if ( pLevel.op == OP_Return ) - { - sqlite3VdbeAddOp2( v, OP_Gosub, pLevel.p1, pLevel.addrFirst ); - } - else - { - sqlite3VdbeAddOp2( v, OP_Goto, 0, pLevel.addrFirst ); - } - sqlite3VdbeJumpHere( v, addr ); - } - } - - /* The "break" point is here, just past the end of the outer loop. - ** Set it. + /* Record the continuation address in the WhereInfo structure. Then + ** clean up and return. */ - sqlite3VdbeResolveLabel( v, pWInfo.iBreak ); + return pWInfo; - /* Close all of the cursors that were opened by sqlite3WhereBegin. - */ - Debug.Assert( pWInfo.nLevel == 1 || pWInfo.nLevel == pTabList.nSrc ); - for ( i = 0; i < pWInfo.nLevel; i++ )// for(i=0, pLevel=pWInfo.a; i= 0; i--) { + pLevel = pWInfo.a[i]; + sqlite3VdbeResolveLabel(v, pLevel.addrCont); + if (pLevel.op != OP_Noop) { + sqlite3VdbeAddOp2(v, pLevel.op, pLevel.p1, pLevel.p2); + sqlite3VdbeChangeP5(v, pLevel.p5); + } + if ((pLevel.plan.wsFlags & WHERE_IN_ABLE) != 0 && pLevel.u._in.nIn > 0) { + InLoop pIn; + int j; + sqlite3VdbeResolveLabel(v, pLevel.addrNxt); + for (j = pLevel.u._in.nIn; j > 0; j--)//, pIn--) + { + pIn = pLevel.u._in.aInLoop[j - 1]; + sqlite3VdbeJumpHere(v, pIn.addrInTop + 1); + sqlite3VdbeAddOp2(v, OP_Next, pIn.iCur, pIn.addrInTop); + sqlite3VdbeJumpHere(v, pIn.addrInTop - 1); + } + sqlite3DbFree(db, ref pLevel.u._in.aInLoop); + } + sqlite3VdbeResolveLabel(v, pLevel.addrBrk); + if (pLevel.iLeftJoin != 0) { + int addr; + addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel.iLeftJoin); + Debug.Assert((pLevel.plan.wsFlags & WHERE_IDX_ONLY) == 0 + || (pLevel.plan.wsFlags & WHERE_INDEXED) != 0); + if ((pLevel.plan.wsFlags & WHERE_IDX_ONLY) == 0) { + sqlite3VdbeAddOp1(v, OP_NullRow, pTabList.a[i].iCursor); + } + if (pLevel.iIdxCur >= 0) { + sqlite3VdbeAddOp1(v, OP_NullRow, pLevel.iIdxCur); + } + if (pLevel.op == OP_Return) { + sqlite3VdbeAddOp2(v, OP_Gosub, pLevel.p1, pLevel.addrFirst); + } else { + sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel.addrFirst); + } + sqlite3VdbeJumpHere(v, addr); + } } - else if ( pOp.opcode == OP_Rowid ) + + /* The "break" point is here, just past the end of the outer loop. + ** Set it. + */ + sqlite3VdbeResolveLabel(v, pWInfo.iBreak); + + /* Close all of the cursors that were opened by sqlite3WhereBegin. + */ + Debug.Assert(pWInfo.nLevel == 1 || pWInfo.nLevel == pTabList.nSrc); + for (i = 0; i < pWInfo.nLevel; i++)// for(i=0, pLevel=pWInfo.a; i ConstantFold()?.IsConstant ?? false; - internal virtual object GetConstantValue() { + internal virtual object GetConstantValue() { var folded = ConstantFold(); if (folded != null && folded.IsConstant) { return folded.GetConstantValue(); diff --git a/Src/IronPython/Compiler/Ast/ExpressionStatement.cs b/Src/IronPython/Compiler/Ast/ExpressionStatement.cs index 28e851e39..8a7d7866f 100644 --- a/Src/IronPython/Compiler/Ast/ExpressionStatement.cs +++ b/Src/IronPython/Compiler/Ast/ExpressionStatement.cs @@ -4,8 +4,6 @@ using MSAst = System.Linq.Expressions; -using AstUtils = Microsoft.Scripting.Ast.Utils; - namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/Src/IronPython/Compiler/Ast/FlowChecker.cs b/Src/IronPython/Compiler/Ast/FlowChecker.cs index 8b3acf40f..be702b199 100644 --- a/Src/IronPython/Compiler/Ast/FlowChecker.cs +++ b/Src/IronPython/Compiler/Ast/FlowChecker.cs @@ -5,7 +5,6 @@ using System.Collections; using System.Collections.Generic; using System.Diagnostics; -using Microsoft.Scripting; /* * The data flow. @@ -122,7 +121,7 @@ internal class FlowDeleter : PythonWalkerNonRecursive { public FlowDeleter(FlowChecker fc) { _fc = fc; } - + public override bool Walk(NameExpression node) { _fc.Delete(node.Name); return false; diff --git a/Src/IronPython/Compiler/Ast/ForStatement.cs b/Src/IronPython/Compiler/Ast/ForStatement.cs index bb18f05c6..8f16e36c0 100644 --- a/Src/IronPython/Compiler/Ast/ForStatement.cs +++ b/Src/IronPython/Compiler/Ast/ForStatement.cs @@ -2,18 +2,16 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using MSAst = System.Linq.Expressions; - using System; using System.Collections; using System.Collections.Generic; -using Microsoft.Scripting; - using IronPython.Runtime.Binding; -using IronPython.Runtime.Operations; + +using Microsoft.Scripting; using AstUtils = Microsoft.Scripting.Ast.Utils; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; @@ -68,8 +66,8 @@ internal static MSAst.Expression TransformFor(ScopeStatement parent, MSAst.Param Binders.UnaryOperationBinder( parent.GlobalParent.PyContext, PythonOperationKind.GetEnumeratorForIteration - ), - parent.GlobalParent.CompilationMode, + ), + parent.GlobalParent.CompilationMode, AstUtils.Convert(list, typeof(object)) ) ); diff --git a/Src/IronPython/Compiler/Ast/FromImportStatement.cs b/Src/IronPython/Compiler/Ast/FromImportStatement.cs index 19e46d9d7..f183b460a 100644 --- a/Src/IronPython/Compiler/Ast/FromImportStatement.cs +++ b/Src/IronPython/Compiler/Ast/FromImportStatement.cs @@ -2,13 +2,13 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using MSAst = System.Linq.Expressions; - using System.Collections.Generic; using System.Runtime.CompilerServices; + using Microsoft.Scripting.Runtime; -using Microsoft.Scripting; + using AstUtils = Microsoft.Scripting.Ast.Utils; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/Src/IronPython/Compiler/Ast/FunctionDefinition.cs b/Src/IronPython/Compiler/Ast/FunctionDefinition.cs index edc452a27..6c97816bd 100644 --- a/Src/IronPython/Compiler/Ast/FunctionDefinition.cs +++ b/Src/IronPython/Compiler/Ast/FunctionDefinition.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Runtime.CompilerServices; using System.Text; using System.Threading; -using System.Runtime.CompilerServices; - -using Microsoft.Scripting; -using Microsoft.Scripting.Interpreter; -using Microsoft.Scripting.Utils; using IronPython.Runtime; using IronPython.Runtime.Operations; -using MSAst = System.Linq.Expressions; +using Microsoft.Scripting; +using Microsoft.Scripting.Interpreter; +using Microsoft.Scripting.Utils; -using LightLambdaExpression = Microsoft.Scripting.Ast.LightLambdaExpression; using AstUtils = Microsoft.Scripting.Ast.Utils; +using LightLambdaExpression = Microsoft.Scripting.Ast.LightLambdaExpression; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; @@ -85,8 +84,7 @@ internal override MSAst.Expression LocalContext { internal override int ArgCount { get { int argCount = 0; - for (argCount = 0; argCount < _parameters.Length; argCount++) - { + for (argCount = 0; argCount < _parameters.Length; argCount++) { Parameter p = _parameters[argCount]; if (p.IsDictionary || p.IsList || p.IsKeywordOnly) break; } @@ -256,7 +254,7 @@ internal override void Bind(PythonNameBinder binder) { NeedsLocalsDictionary = true; } } - + internal override void FinishBind(PythonNameBinder binder) { foreach (var param in _parameters) { _variableMapping[param.PythonVariable] = param.FinishBind(forceClosureCell: ExposesLocalVariable(param.PythonVariable)); @@ -286,7 +284,7 @@ public override MSAst.Expression Reduce() { new SourceSpan(GlobalParent.IndexToLocation(StartIndex), GlobalParent.IndexToLocation(HeaderIndex)) ); } - + /// /// Returns an expression which creates the function object. /// @@ -563,7 +561,7 @@ public override int ConsumedStack { get { return _defaultCount + (_kwdefaultCount * 2) + (_annotationCount * 2) + (_context == null ? 1 : 0) + - (_name == null ? 1 : 0); + (_name == null ? 1 : 0); } } @@ -779,7 +777,7 @@ internal override IList GetVarNames() { return res; } - + private void InitializeParameters(List init, bool needsWrapperMethod, MSAst.Expression[] parameters) { for (int i = 0; i < _parameters.Length; i++) { Parameter p = _parameters[i]; @@ -829,10 +827,10 @@ private static Type GetDelegateType(Parameter[] parameters, bool wrapper, out De internal override void RewriteBody(MSAst.ExpressionVisitor visitor) { _dlrBody = null; // clear the cached body if we've been reduced - + MSAst.Expression funcCode = GlobalParent.Constant(GetOrMakeFunctionCode()); FuncCodeExpr = funcCode; - + Body = new RewrittenBodyStatement(Body, visitor.Visit(Body)); } diff --git a/Src/IronPython/Compiler/Ast/GeneratorExpression.cs b/Src/IronPython/Compiler/Ast/GeneratorExpression.cs index 1916c55ec..8486bed32 100644 --- a/Src/IronPython/Compiler/Ast/GeneratorExpression.cs +++ b/Src/IronPython/Compiler/Ast/GeneratorExpression.cs @@ -4,14 +4,6 @@ using MSAst = System.Linq.Expressions; -using System; -using System.Diagnostics; - -using Microsoft.Scripting.Actions; - -using IronPython.Runtime; -using IronPython.Runtime.Binding; - namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/Src/IronPython/Compiler/Ast/GetGlobalContextExpression.cs b/Src/IronPython/Compiler/Ast/GetGlobalContextExpression.cs index 4d88e2668..8ff512e7e 100644 --- a/Src/IronPython/Compiler/Ast/GetGlobalContextExpression.cs +++ b/Src/IronPython/Compiler/Ast/GetGlobalContextExpression.cs @@ -3,13 +3,12 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; -using System.Text; using IronPython.Runtime; -using Microsoft.Scripting.Interpreter; using IronPython.Runtime.Operations; +using Microsoft.Scripting.Interpreter; + using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { diff --git a/Src/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs b/Src/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs index 86882e7d8..706f19d63 100644 --- a/Src/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs +++ b/Src/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs @@ -4,11 +4,11 @@ using System; -using Microsoft.Scripting.Interpreter; - using IronPython.Runtime; using IronPython.Runtime.Operations; +using Microsoft.Scripting.Interpreter; + using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { diff --git a/Src/IronPython/Compiler/Ast/IfStatement.cs b/Src/IronPython/Compiler/Ast/IfStatement.cs index 715081dbb..58ed3fc9e 100644 --- a/Src/IronPython/Compiler/Ast/IfStatement.cs +++ b/Src/IronPython/Compiler/Ast/IfStatement.cs @@ -2,19 +2,14 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using MSAst = System.Linq.Expressions; - -using System; using System.Collections.Generic; -using System.Diagnostics; using Microsoft.Scripting; using Microsoft.Scripting.Ast; using Microsoft.Scripting.Interpreter; -using IronPython.Runtime; - using AstUtils = Microsoft.Scripting.Ast.Utils; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/Src/IronPython/Compiler/Ast/ImportStatement.cs b/Src/IronPython/Compiler/Ast/ImportStatement.cs index 40c473815..79e415989 100644 --- a/Src/IronPython/Compiler/Ast/ImportStatement.cs +++ b/Src/IronPython/Compiler/Ast/ImportStatement.cs @@ -2,14 +2,13 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using MSAst = System.Linq.Expressions; - using System.Collections.Generic; using System.Runtime.CompilerServices; -using Microsoft.Scripting; using Microsoft.Scripting.Runtime; + using AstUtils = Microsoft.Scripting.Ast.Utils; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/Src/IronPython/Compiler/Ast/IndexExpression.cs b/Src/IronPython/Compiler/Ast/IndexExpression.cs index fdc830ea7..cef6e199a 100644 --- a/Src/IronPython/Compiler/Ast/IndexExpression.cs +++ b/Src/IronPython/Compiler/Ast/IndexExpression.cs @@ -2,14 +2,14 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using MSAst = System.Linq.Expressions; - using IronPython.Runtime; using IronPython.Runtime.Binding; using Microsoft.Scripting; using Microsoft.Scripting.Utils; +using MSAst = System.Linq.Expressions; + namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/Src/IronPython/Compiler/Ast/LambdaExpression.cs b/Src/IronPython/Compiler/Ast/LambdaExpression.cs index b915e22f0..2f50c2453 100644 --- a/Src/IronPython/Compiler/Ast/LambdaExpression.cs +++ b/Src/IronPython/Compiler/Ast/LambdaExpression.cs @@ -4,8 +4,6 @@ using MSAst = System.Linq.Expressions; -using System; - namespace IronPython.Compiler.Ast { public class LambdaExpression : Expression { public LambdaExpression(FunctionDefinition function) { diff --git a/Src/IronPython/Compiler/Ast/MemberExpression.cs b/Src/IronPython/Compiler/Ast/MemberExpression.cs index 2f34a8936..67fb1c85c 100644 --- a/Src/IronPython/Compiler/Ast/MemberExpression.cs +++ b/Src/IronPython/Compiler/Ast/MemberExpression.cs @@ -2,13 +2,12 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using MSAst = System.Linq.Expressions; - -using System; -using System.Dynamic; using IronPython.Runtime.Binding; + using Microsoft.Scripting; + using AstUtils = Microsoft.Scripting.Ast.Utils; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/Src/IronPython/Compiler/Ast/ModuleName.cs b/Src/IronPython/Compiler/Ast/ModuleName.cs index db9990fb1..1e60c448f 100644 --- a/Src/IronPython/Compiler/Ast/ModuleName.cs +++ b/Src/IronPython/Compiler/Ast/ModuleName.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using Microsoft.Scripting; - namespace IronPython.Compiler.Ast { public class ModuleName : DottedName { public ModuleName(string[] names) diff --git a/Src/IronPython/Compiler/Ast/NameExpression.cs b/Src/IronPython/Compiler/Ast/NameExpression.cs index daa62ce51..f7c0a5a54 100644 --- a/Src/IronPython/Compiler/Ast/NameExpression.cs +++ b/Src/IronPython/Compiler/Ast/NameExpression.cs @@ -2,13 +2,12 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using MSAst = System.Linq.Expressions; +using IronPython.Runtime.Binding; using Microsoft.Scripting; -using IronPython.Runtime.Binding; - using AstUtils = Microsoft.Scripting.Ast.Utils; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; @@ -78,7 +77,7 @@ internal override MSAst.Expression TransformSet(SourceSpan span, MSAst.Expressio assignment = Ast.Call( null, AstMethods.SetName, - Parent.LocalContext, + Parent.LocalContext, Ast.Constant(Name), AstUtils.Convert(right, typeof(object)) ); diff --git a/Src/IronPython/Compiler/Ast/Node.cs b/Src/IronPython/Compiler/Ast/Node.cs index c15820c82..8021ab4dd 100644 --- a/Src/IronPython/Compiler/Ast/Node.cs +++ b/Src/IronPython/Compiler/Ast/Node.cs @@ -4,24 +4,21 @@ #nullable enable -using Microsoft.Scripting; - -using MSAst = System.Linq.Expressions; -using System.Linq.Expressions; - using System; using System.Collections.Generic; using System.Diagnostics; +using System.Linq.Expressions; + +using IronPython.Runtime.Binding; +using IronPython.Runtime.Operations; +using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Ast; -using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime; -using IronPython.Runtime.Binding; -using IronPython.Runtime.Operations; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; @@ -89,7 +86,7 @@ public int StartIndex { IndexSpan = new IndexSpan(value, 0); } } - + internal SourceLocation IndexToLocation(int index) { if (index == -1) { return SourceLocation.Invalid; @@ -205,7 +202,7 @@ internal static MSAst.Expression TransformOrConstantNull(Expression? expression, internal MSAst.Expression TransformAndDynamicConvert(Expression expression, Type/*!*/ type) { Assert.NotNull(expression); - + MSAst.Expression res = expression; // Do we need conversion? @@ -216,7 +213,7 @@ internal MSAst.Expression TransformAndDynamicConvert(Expression expression, Type if (reduced is LightDynamicExpression) { reduced = reduced.Reduce(); } - + // Add conversion step to the AST MSAst.DynamicExpression? ae = reduced as MSAst.DynamicExpression; ReducableDynamicExpression? rde = reduced as ReducableDynamicExpression; @@ -240,7 +237,7 @@ internal MSAst.Expression TransformAndDynamicConvert(Expression expression, Type for (int i = 0; i < infos.Length; i++) { infos[i] = ParameterMappingInfo.Parameter(i); } - + res = Expression.Dynamic( GlobalParent.PyContext.BinaryOperationRetType( binder, @@ -443,7 +440,7 @@ internal static MSAst.ParameterExpression/*!*/ LineNumberUpdated { return _lineNumberUpdated; } } - + internal static MSAst.Expression UpdateLineNumber(int line) { return Ast.Assign(LineNumberExpression, AstUtils.Constant(line)); } diff --git a/Src/IronPython/Compiler/Ast/OrExpression.cs b/Src/IronPython/Compiler/Ast/OrExpression.cs index baf33bd20..8e907d89c 100644 --- a/Src/IronPython/Compiler/Ast/OrExpression.cs +++ b/Src/IronPython/Compiler/Ast/OrExpression.cs @@ -5,6 +5,7 @@ #nullable enable using System; + using Microsoft.Scripting.Actions; using Microsoft.Scripting.Utils; diff --git a/Src/IronPython/Compiler/Ast/Parameter.cs b/Src/IronPython/Compiler/Ast/Parameter.cs index 03a123fd1..bfea948fa 100644 --- a/Src/IronPython/Compiler/Ast/Parameter.cs +++ b/Src/IronPython/Compiler/Ast/Parameter.cs @@ -4,10 +4,7 @@ using System.Collections.Generic; -using Microsoft.Scripting; - using IronPython.Runtime; -using IronPython.Runtime.Binding; using MSAst = System.Linq.Expressions; diff --git a/Src/IronPython/Compiler/Ast/ParenthesisExpression.cs b/Src/IronPython/Compiler/Ast/ParenthesisExpression.cs index 2aa62f4a2..c1ceb8fb0 100644 --- a/Src/IronPython/Compiler/Ast/ParenthesisExpression.cs +++ b/Src/IronPython/Compiler/Ast/ParenthesisExpression.cs @@ -4,10 +4,10 @@ using System; -using Microsoft.Scripting; - using IronPython.Runtime.Binding; +using Microsoft.Scripting; + using MSAst = System.Linq.Expressions; diff --git a/Src/IronPython/Compiler/Ast/PythonAst.cs b/Src/IronPython/Compiler/Ast/PythonAst.cs index 383537c33..8c5e6b2d5 100644 --- a/Src/IronPython/Compiler/Ast/PythonAst.cs +++ b/Src/IronPython/Compiler/Ast/PythonAst.cs @@ -6,23 +6,19 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; -using System.Dynamic; using System.IO; using System.Runtime.CompilerServices; +using IronPython.Runtime; +using IronPython.Runtime.Binding; + using Microsoft.Scripting; using Microsoft.Scripting.Actions; -using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime; -using IronPython.Runtime.Binding; -using IronPython.Runtime.Operations; - -using MSAst = System.Linq.Expressions; - using AstUtils = Microsoft.Scripting.Ast.Utils; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; @@ -68,7 +64,7 @@ public PythonAst(Statement body, bool isModule, ModuleOptions languageFeatures, ContractUtils.RequiresNotNull(body, nameof(body)); _body = body; - + _lineLocations = lineLocations; } @@ -98,7 +94,7 @@ public PythonAst(bool isModule, ModuleOptions languageFeatures, bool printExpres Debug.Assert(_name != null); PythonOptions po = ((PythonContext)context.SourceUnit.LanguageContext).PythonOptions; - if (po.EnableProfiler + if (po.EnableProfiler #if FEATURE_REFEMIT && _mode != CompilationMode.ToDisk #endif @@ -183,7 +179,7 @@ internal override void FinishBind(PythonNameBinder binder) { #if FEATURE_REFEMIT if (_mode == CompilationMode.ToDisk) { _arrayExpression = _globalArray; - } else + } else #endif { var newArray = new ConstantExpression(globalArray); @@ -397,7 +393,7 @@ internal MSAst.Expression ReduceWorker() { block.Add(_body); MSAst.Expression body = Ast.Block(block.ToReadOnlyCollection()); - + body = WrapScopeStatements(body, Body.CanThrow); // new ComboActionRewriter().VisitNode(Transform(ag)) body = AddModulePublishing(body); @@ -552,7 +548,7 @@ internal void PrepareScope(ReadOnlyCollectionBuilder internal new MSAst.Expression Constant(object value) { return new PythonConstantExpression(CompilationMode, value); } - + #endregion #region Binder Factories @@ -579,7 +575,7 @@ internal void PrepareScope(ReadOnlyCollectionBuilder ); } - + internal MSAst.Expression/*!*/ Operation(Type/*!*/ resultType, PythonOperationKind operation, MSAst.Expression arg0) { if (resultType == typeof(object)) { return new PythonDynamicExpression1( @@ -591,7 +587,7 @@ internal void PrepareScope(ReadOnlyCollectionBuilder arg0 ); } - + return CompilationMode.Dynamic( Binders.UnaryOperationBinder( PyContext, @@ -640,7 +636,7 @@ internal void PrepareScope(ReadOnlyCollectionBuilder return new DynamicGetMemberExpression(PyContext.GetMember(name), _mode, target, LocalContext); } - + internal MSAst.Expression/*!*/ Delete(Type/*!*/ resultType, string/*!*/ name, MSAst.Expression/*!*/ target) { return CompilationMode.Dynamic( PyContext.DeleteMember( @@ -677,7 +673,7 @@ internal void PrepareScope(ReadOnlyCollectionBuilder ), CompilationMode, expressions - ); + ); } internal MSAst.Expression/*!*/ SetSlice(MSAst.Expression/*!*/[]/*!*/ expressions) { @@ -685,10 +681,10 @@ internal void PrepareScope(ReadOnlyCollectionBuilder PyContext.SetSliceBinder, CompilationMode, expressions - ); + ); } - internal MSAst.Expression/*!*/ DeleteIndex(MSAst.Expression/*!*/[]/*!*/ expressions) { + internal MSAst.Expression/*!*/ DeleteIndex(MSAst.Expression/*!*/[]/*!*/ expressions) { return CompilationMode.Dynamic( PyContext.DeleteIndex( expressions.Length @@ -703,7 +699,7 @@ internal void PrepareScope(ReadOnlyCollectionBuilder PyContext.DeleteSlice, CompilationMode, expressions - ); + ); } #endregion diff --git a/Src/IronPython/Compiler/Ast/PythonNameBinder.cs b/Src/IronPython/Compiler/Ast/PythonNameBinder.cs index 68e5eb2c4..d5f070d6c 100644 --- a/Src/IronPython/Compiler/Ast/PythonNameBinder.cs +++ b/Src/IronPython/Compiler/Ast/PythonNameBinder.cs @@ -2,16 +2,16 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using MSAst = System.Linq.Expressions; - using System.Collections.Generic; using System.Diagnostics; +using IronPython.Runtime; + using Microsoft.Scripting; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime; +using MSAst = System.Linq.Expressions; /* * The name binding: @@ -589,14 +589,14 @@ public override bool Walk(WhileStatement node) { public override bool Walk(BreakStatement node) { node.Parent = _currentScope; node.LoopStatement = _loops[_loops.Count - 1]; - + return base.Walk(node); } public override bool Walk(ContinueStatement node) { node.Parent = _currentScope; node.LoopStatement = _loops[_loops.Count - 1]; - + return base.Walk(node); } diff --git a/Src/IronPython/Compiler/Ast/PythonVariable.cs b/Src/IronPython/Compiler/Ast/PythonVariable.cs index 85c41bcaf..7d8276a84 100644 --- a/Src/IronPython/Compiler/Ast/PythonVariable.cs +++ b/Src/IronPython/Compiler/Ast/PythonVariable.cs @@ -4,20 +4,11 @@ #nullable enable -using MSAst = System.Linq.Expressions; - -using System; using System.Diagnostics; -using Microsoft.Scripting; -using Microsoft.Scripting.Ast; using Microsoft.Scripting.Utils; -using IronPython.Runtime; - namespace IronPython.Compiler.Ast { - using Ast = MSAst.Expression; - [DebuggerDisplay("{Kind} {Name} from {Scope.Name}")] public class PythonVariable { diff --git a/Src/IronPython/Compiler/Ast/RelativeModuleName.cs b/Src/IronPython/Compiler/Ast/RelativeModuleName.cs index 9d465cb71..cdb588356 100644 --- a/Src/IronPython/Compiler/Ast/RelativeModuleName.cs +++ b/Src/IronPython/Compiler/Ast/RelativeModuleName.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using Microsoft.Scripting; - namespace IronPython.Compiler.Ast { public class RelativeModuleName : ModuleName { public RelativeModuleName(string[] names, int dotCount) diff --git a/Src/IronPython/Compiler/Ast/ScopeStatement.cs b/Src/IronPython/Compiler/Ast/ScopeStatement.cs index 28d571804..4a08f0aaa 100644 --- a/Src/IronPython/Compiler/Ast/ScopeStatement.cs +++ b/Src/IronPython/Compiler/Ast/ScopeStatement.cs @@ -92,7 +92,7 @@ public abstract class ScopeStatement : Statement { /// /// It is used to ensure that the first argument is accessible through a closure cell. /// - internal bool ContainsSuperCall{ get; set; } + internal bool ContainsSuperCall { get; set; } public virtual string Name => ""; @@ -439,7 +439,7 @@ private PythonVariable CreateNonlocalVariable(string name) { } internal void EnsureNonlocalVariable(string name, NonlocalStatement node) { - _nonlocalVars ??= new(); + _nonlocalVars ??= new(); if (!_nonlocalVars.ContainsKey(name)) { CreateNonlocalVariable(name); _nonlocalVars[name] = node; @@ -611,7 +611,7 @@ internal MSAst.Expression? FuncCodeExpr { internal MSAst.MethodCallExpression CreateLocalContext(MSAst.Expression parentContext, bool newNamespace = true) { var closureVariables = _closureVariables ?? Array.Empty(); - + int numFreeVars = FreeVariables?.Count ?? 0; int firstArgIdx = -1; if ((NeedsLocalsDictionary || ContainsSuperCall) && ArgCount > 0) { diff --git a/Src/IronPython/Compiler/Ast/SerializedScopeStatement.cs b/Src/IronPython/Compiler/Ast/SerializedScopeStatement.cs index 35e3734a1..9b1e59e25 100644 --- a/Src/IronPython/Compiler/Ast/SerializedScopeStatement.cs +++ b/Src/IronPython/Compiler/Ast/SerializedScopeStatement.cs @@ -3,15 +3,9 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; -using System.Text; - -using Microsoft.Scripting; using IronPython.Runtime; -using MSAst = System.Linq.Expressions; - namespace IronPython.Compiler.Ast { /// /// Fake ScopeStatement for FunctionCode's to hold on to after we have deserialized pre-compiled code. diff --git a/Src/IronPython/Compiler/Ast/SliceExpression.cs b/Src/IronPython/Compiler/Ast/SliceExpression.cs index ce3a185fa..484a1f5db 100644 --- a/Src/IronPython/Compiler/Ast/SliceExpression.cs +++ b/Src/IronPython/Compiler/Ast/SliceExpression.cs @@ -7,8 +7,6 @@ using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { - using Ast = MSAst.Expression; - public class SliceExpression : Expression { public SliceExpression(Expression? start, Expression? stop, Expression? step) { SliceStart = start; diff --git a/Src/IronPython/Compiler/Ast/SuiteStatement.cs b/Src/IronPython/Compiler/Ast/SuiteStatement.cs index 6d4299ea9..679b170f4 100644 --- a/Src/IronPython/Compiler/Ast/SuiteStatement.cs +++ b/Src/IronPython/Compiler/Ast/SuiteStatement.cs @@ -2,21 +2,17 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using MSAst = System.Linq.Expressions; - using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Diagnostics; using System.Runtime.CompilerServices; -using Microsoft.Scripting; using Microsoft.Scripting.Utils; using AstUtils = Microsoft.Scripting.Ast.Utils; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; - + public sealed class SuiteStatement : Statement { private readonly Statement[] _statements; @@ -27,7 +23,7 @@ public SuiteStatement(Statement[] statements) { public IList Statements { get { return _statements; } - } + } public override MSAst.Expression Reduce() { if (_statements.Length == 0) { @@ -52,7 +48,7 @@ public override MSAst.Expression Reduce() { } curStart = newline; } - + return Ast.Block(statements.ToReadOnlyCollection()); } @@ -100,7 +96,7 @@ public override void Walk(PythonWalker walker) { } public override string Documentation { - get { + get { if (_statements.Length > 0) { return _statements[0].Documentation; } diff --git a/Src/IronPython/Compiler/Ast/TryStatement.cs b/Src/IronPython/Compiler/Ast/TryStatement.cs index 84d431190..1fa19a0ef 100644 --- a/Src/IronPython/Compiler/Ast/TryStatement.cs +++ b/Src/IronPython/Compiler/Ast/TryStatement.cs @@ -9,17 +9,14 @@ using System.Diagnostics; using System.Runtime.CompilerServices; +using IronPython.Runtime.Binding; + using Microsoft.Scripting; -using Microsoft.Scripting.Ast; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Binding; -using IronPython.Runtime.Operations; - -using MSAst = System.Linq.Expressions; - using AstUtils = Microsoft.Scripting.Ast.Utils; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/Src/IronPython/Compiler/Ast/UnaryExpression.cs b/Src/IronPython/Compiler/Ast/UnaryExpression.cs index dbdc75af7..28e2be18a 100644 --- a/Src/IronPython/Compiler/Ast/UnaryExpression.cs +++ b/Src/IronPython/Compiler/Ast/UnaryExpression.cs @@ -2,17 +2,13 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using MSAst = System.Linq.Expressions; - -using System; using System.Diagnostics; using IronPython.Runtime.Binding; -namespace IronPython.Compiler.Ast { - using Ast = MSAst.Expression; - using AstUtils = Microsoft.Scripting.Ast.Utils; +using MSAst = System.Linq.Expressions; +namespace IronPython.Compiler.Ast { public class UnaryExpression : Expression { public UnaryExpression(PythonOperator op, Expression expression) { Operator = op; diff --git a/Src/IronPython/Compiler/Ast/WhileStatement.cs b/Src/IronPython/Compiler/Ast/WhileStatement.cs index 9d8b24848..b4cfab035 100644 --- a/Src/IronPython/Compiler/Ast/WhileStatement.cs +++ b/Src/IronPython/Compiler/Ast/WhileStatement.cs @@ -2,12 +2,11 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using MSAst = System.Linq.Expressions; - using Microsoft.Scripting; using Microsoft.Scripting.Interpreter; using AstUtils = Microsoft.Scripting.Ast.Utils; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { diff --git a/Src/IronPython/Compiler/Ast/WithStatement.cs b/Src/IronPython/Compiler/Ast/WithStatement.cs index 6712de29b..3f386f61d 100644 --- a/Src/IronPython/Compiler/Ast/WithStatement.cs +++ b/Src/IronPython/Compiler/Ast/WithStatement.cs @@ -3,17 +3,15 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Runtime.CompilerServices; -using Microsoft.Scripting; -using Microsoft.Scripting.Actions; - using IronPython.Runtime.Binding; -using MSAst = System.Linq.Expressions; +using Microsoft.Scripting; +using Microsoft.Scripting.Actions; using AstUtils = Microsoft.Scripting.Ast.Utils; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; @@ -170,29 +168,29 @@ public override MSAst.Expression Reduce() { Ast.Assign(previousException, Ast.Call(AstMethods.SaveCurrentException)), _var != null ? (MSAst.Expression)Ast.Block( - // VAR = value + // VAR = value _var.TransformSet(SourceSpan.None, value, PythonOperationKind.None), - // BLOCK + // BLOCK _body, AstUtils.Empty() ) : - // BLOCK + // BLOCK (MSAst.Expression)_body // except:, // try statement location ).Catch(exception = Ast.Variable(typeof(Exception), "exception"), - // Python specific exception handling code + // Python specific exception handling code TryStatement.GetTracebackHeader( this, exception, GlobalParent.AddDebugInfoAndVoid( Ast.Block( Ast.Call(AstMethods.SetCurrentException, Parent.LocalContext, exception), - // exc = False + // exc = False MakeAssignment( exc, AstUtils.Constant(false) ), - // if not exit(*sys.exc_info()): - // raise + // if not exit(*sys.exc_info()): + // raise AstUtils.IfThen( GlobalParent.Convert( typeof(bool), @@ -221,8 +219,8 @@ public override MSAst.Expression Reduce() { // finally: ).Finally( Ast.Call(AstMethods.RestoreCurrentException, previousException), - // if exc: - // exit(None, None, None) + // if exc: + // exit(None, None, None) AstUtils.IfThen( exc, GlobalParent.AddDebugInfoAndVoid( diff --git a/Src/IronPython/Compiler/Ast/YieldExpression.cs b/Src/IronPython/Compiler/Ast/YieldExpression.cs index 266a157aa..332bc4b51 100644 --- a/Src/IronPython/Compiler/Ast/YieldExpression.cs +++ b/Src/IronPython/Compiler/Ast/YieldExpression.cs @@ -4,13 +4,13 @@ #nullable enable -using MSAst = System.Linq.Expressions; - -using System; using System.Diagnostics; + using Microsoft.Scripting; using Microsoft.Scripting.Runtime; + using AstUtils = Microsoft.Scripting.Ast.Utils; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/Src/IronPython/Compiler/Ast/YieldFromExpression.cs b/Src/IronPython/Compiler/Ast/YieldFromExpression.cs index 47ce30213..aa2ca83ef 100644 --- a/Src/IronPython/Compiler/Ast/YieldFromExpression.cs +++ b/Src/IronPython/Compiler/Ast/YieldFromExpression.cs @@ -4,12 +4,8 @@ #nullable enable -using MSAst = System.Linq.Expressions; - -using System; -using System.Diagnostics; -using Microsoft.Scripting; using AstUtils = Microsoft.Scripting.Ast.Utils; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/Src/IronPython/Compiler/ClosureExpression.cs b/Src/IronPython/Compiler/ClosureExpression.cs index 8520ea877..c112796f2 100644 --- a/Src/IronPython/Compiler/ClosureExpression.cs +++ b/Src/IronPython/Compiler/ClosureExpression.cs @@ -2,18 +2,17 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; +using System.Linq.Expressions; using System.Reflection; +using IronPython.Runtime; +using IronPython.Runtime.Operations; + using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime; -using IronPython.Runtime.Operations; - namespace IronPython.Compiler { /// /// Small reducable node which just fetches the value from a ClosureCell diff --git a/Src/IronPython/Compiler/ClosureInfo.cs b/Src/IronPython/Compiler/ClosureInfo.cs index 1408530f7..7d6e4fa4e 100644 --- a/Src/IronPython/Compiler/ClosureInfo.cs +++ b/Src/IronPython/Compiler/ClosureInfo.cs @@ -2,16 +2,12 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; - -using Microsoft.Scripting; - using IronPython.Compiler.Ast; -using MSAst = System.Linq.Expressions; - using Microsoft.Scripting.Utils; +using MSAst = System.Linq.Expressions; + namespace IronPython.Compiler { /// /// Tracking for variables lifted into closure objects. Used to store information in a function diff --git a/Src/IronPython/Compiler/CollectableCompilationMode.cs b/Src/IronPython/Compiler/CollectableCompilationMode.cs index efad65c5f..56e7edacc 100644 --- a/Src/IronPython/Compiler/CollectableCompilationMode.cs +++ b/Src/IronPython/Compiler/CollectableCompilationMode.cs @@ -2,20 +2,17 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using MSAst = System.Linq.Expressions; - using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Runtime.CompilerServices; -using Microsoft.Scripting; +using IronPython.Runtime; + using Microsoft.Scripting.Ast; using Microsoft.Scripting.Utils; -using IronPython.Runtime; - using AstUtils = Microsoft.Scripting.Ast.Utils; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { diff --git a/Src/IronPython/Compiler/CompilationMode.cs b/Src/IronPython/Compiler/CompilationMode.cs index e5606ccb7..9a6fbfb57 100644 --- a/Src/IronPython/Compiler/CompilationMode.cs +++ b/Src/IronPython/Compiler/CompilationMode.cs @@ -2,22 +2,20 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using MSAst = System.Linq.Expressions; - - using System; using System.Collections.Generic; using System.Dynamic; +using System.Reflection; using System.Runtime.CompilerServices; +using IronPython.Compiler.Ast; +using IronPython.Runtime; + using Microsoft.Scripting; using Microsoft.Scripting.Ast; using Microsoft.Scripting.Utils; -using IronPython.Compiler.Ast; -using IronPython.Runtime; -using System.Collections; -using System.Reflection; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler { public delegate object LookupCompilationDelegate(CodeContext context, FunctionCode code); @@ -32,20 +30,20 @@ internal abstract class CompilationMode { /// Compilation will proceed in a manner in which the resulting AST can be serialized to disk. /// public static readonly CompilationMode ToDisk = new ToDiskCompilationMode(); - + /// /// Compilation will use a type and declare static fields for globals. The resulting type /// is uncollectible and therefore extended use of this will cause memory leaks. /// public static readonly CompilationMode Uncollectable = new UncollectableCompilationMode(); #endif - + /// /// Compilation will use an array for globals. The resulting code will be fully collectible /// and once all references are released will be collected. /// public static readonly CompilationMode Collectable = new CollectableCompilationMode(); - + /// /// Compilation will force all global accesses to do a full lookup. This will also happen for /// any unbound local references. This is the slowest form of code generation and is only @@ -122,7 +120,7 @@ public virtual void PublishContext(CodeContext codeContext, ConstantInfo _contex public MSAst.Expression/*!*/ Dynamic(DynamicMetaObjectBinder/*!*/ binder, Type/*!*/ retType, MSAst.Expression/*!*/[]/*!*/ args) { Assert.NotNull(binder, retType, args); Assert.NotNullItems(args); - + switch (args.Length) { case 1: return Dynamic(binder, retType, args[0]); case 2: return Dynamic(binder, retType, args[0], args[1]); diff --git a/Src/IronPython/Compiler/GeneratorRewriter.cs b/Src/IronPython/Compiler/GeneratorRewriter.cs index ee48035eb..5fe5e3cb6 100644 --- a/Src/IronPython/Compiler/GeneratorRewriter.cs +++ b/Src/IronPython/Compiler/GeneratorRewriter.cs @@ -2,22 +2,21 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; +using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; +using IronPython.Runtime; +using IronPython.Runtime.Operations; + using Microsoft.Scripting; using Microsoft.Scripting.Ast; using Microsoft.Scripting.Utils; -using IronPython.Runtime; -using IronPython.Runtime.Operations; - using AstUtils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Compiler { @@ -56,7 +55,7 @@ internal sealed class GeneratorRewriter : DynamicExpressionVisitor { internal const int NotStarted = -1; internal const int Finished = 0; internal static ParameterExpression _generatorParam = Expression.Parameter(typeof(PythonGenerator), "$generator"); - + internal GeneratorRewriter(string name, Expression body) { _body = body; _name = name; @@ -64,8 +63,8 @@ internal GeneratorRewriter(string name, Expression body) { _gotoRouter = Expression.Variable(typeof(int), "$gotoRouter"); } - internal Expression Reduce(bool shouldInterpret, bool emitDebugSymbols, int compilationThreshold, - IList parameters, Func>, + internal Expression Reduce(bool shouldInterpret, bool emitDebugSymbols, int compilationThreshold, + IList parameters, Func>, Expression>> bodyConverter) { _state = LiftVariable(Expression.Parameter(typeof(int), "state")); @@ -132,7 +131,7 @@ internal Expression Reduce(bool shouldInterpret, bool emitDebugSymbols, int comp _name, new ParameterExpression[] { tupleArg } ); - + // Generate a call to PythonOps.MakeGeneratorClosure(Tuple data, object generatorCode) return Expression.Block( new[] { tupleTmp, ret }, @@ -232,7 +231,7 @@ private class GotoRewriter : ExpressionVisitor { private readonly GotoRewriteInfo _gotoInfo; private readonly LabelTarget _target; private readonly GeneratorRewriter _rewriter; - + public GotoRewriter(GeneratorRewriter rewriter, GotoRewriteInfo gotoInfo, LabelTarget target) { _gotoInfo = gotoInfo; _target = target; @@ -262,12 +261,12 @@ private Expression MakeAssignBlock(Expression variable, Expression value) { if (blockRhs.NodeType == ExpressionType.Label) { var label = (LabelExpression)blockRhs; GotoRewriteInfo curVariable = new GotoRewriteInfo(variable, Expression.Label(label.Target.Name + "_voided")); - + var rewriter = new GotoRewriter(this, curVariable, label.Target); for (int i = 0; i < newBlock.Count - 1; i++) { newBlock[i] = rewriter.Visit(newBlock[i]); } - + newBlock[newBlock.Count - 1] = MakeAssignLabel(variable, curVariable, label.Target, rewriter.Visit(label.DefaultValue)); } else { newBlock[newBlock.Count - 1] = MakeAssign(variable, newBlock[newBlock.Count - 1]); @@ -372,7 +371,7 @@ protected override Expression VisitTry(TryExpression node) { // the catch block had one. It needs to be hoisted because // the catch might contain yields. var deferredVar = c.Variable ?? Expression.Variable(c.Test, null); - LiftVariable(deferredVar); + LiftVariable(deferredVar); // We need to ensure that filters can access the exception // variable @@ -395,7 +394,7 @@ protected override Expression VisitTry(TryExpression node) { // We need to rewrite rethrows into "throw deferredVar" var catchBody = new RethrowRewriter { Exception = deferredVar }.Visit(c.Body); - + // if (deferredVar != null) { // ... catch body ... // } @@ -547,7 +546,7 @@ protected override CatchBlock VisitCatchBlock(CatchBlock node) { // No one needs this yet, and it's not clear what it should even do throw new NotSupportedException("yield in filter is not allowed"); } - + Expression b = Visit(node.Body); if (v == node.Variable && b == node.Body && f == node.Filter) { return node; @@ -973,7 +972,7 @@ private sealed class YieldMarker { internal YieldMarker(int state) { State = state; } - } + } } /// @@ -1025,7 +1024,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) { internal sealed class DelayedTupleAssign : Expression { private readonly Expression _lhs, _rhs; - + public DelayedTupleAssign(Expression lhs, Expression rhs) { _lhs = lhs; _rhs = rhs; diff --git a/Src/IronPython/Compiler/LookupCompilationMode.cs b/Src/IronPython/Compiler/LookupCompilationMode.cs index b0d84058b..db128388f 100644 --- a/Src/IronPython/Compiler/LookupCompilationMode.cs +++ b/Src/IronPython/Compiler/LookupCompilationMode.cs @@ -2,22 +2,13 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using MSAst = System.Linq.Expressions; - -using System; -using System.Collections.Generic; - using Microsoft.Scripting; using Microsoft.Scripting.Ast; -using Microsoft.Scripting.Utils; - -using IronPython.Runtime; using AstUtils = Microsoft.Scripting.Ast.Utils; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { - using Ast = MSAst.Expression; - /// /// Provides globals for when we need to lookup into a dictionary for each global access. /// diff --git a/Src/IronPython/Compiler/OnDiskScriptCode.cs b/Src/IronPython/Compiler/OnDiskScriptCode.cs index 046574d30..a0fb06d1b 100644 --- a/Src/IronPython/Compiler/OnDiskScriptCode.cs +++ b/Src/IronPython/Compiler/OnDiskScriptCode.cs @@ -4,15 +4,11 @@ using System; using System.Collections.Generic; -using System.Text; -using System.Reflection; + +using IronPython.Runtime; using Microsoft.Scripting; using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - -using IronPython.Runtime; -using IronPython.Runtime.Operations; namespace IronPython.Compiler { /// diff --git a/Src/IronPython/Compiler/Parser.cs b/Src/IronPython/Compiler/Parser.cs index ddbf3b02e..1e8270721 100644 --- a/Src/IronPython/Compiler/Parser.cs +++ b/Src/IronPython/Compiler/Parser.cs @@ -10,16 +10,16 @@ using System.Numerics; using System.Text; -using Microsoft.Scripting; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - using IronPython.Compiler.Ast; using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + namespace IronPython.Compiler { // this file is your friend (check the python version that is being developed against) // https://raw.githubusercontent.com/python/cpython/v3.4.10/Grammar/Grammar diff --git a/Src/IronPython/Compiler/PythonCallTargets.cs b/Src/IronPython/Compiler/PythonCallTargets.cs index 03231df95..3fa32c1bf 100644 --- a/Src/IronPython/Compiler/PythonCallTargets.cs +++ b/Src/IronPython/Compiler/PythonCallTargets.cs @@ -3,8 +3,7 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections; -using Microsoft.Scripting.Utils; + using IronPython.Runtime; using IronPython.Runtime.Operations; @@ -106,7 +105,7 @@ public static object OriginalCallTarget15(PythonFunction function, object arg0, // *** END GENERATED CODE *** #endregion - + public const int MaxArgs = 15; internal static Type GetPythonTargetType(bool wrapper, int parameters, out Delegate originalTarget) { if (!wrapper) { @@ -116,58 +115,58 @@ internal static Type GetPythonTargetType(bool wrapper, int parameters, out Deleg // *** BEGIN GENERATED CODE *** // generated by function: gen_python_switch from: generate_calls.py - case 0: + case 0: originalTarget = (Func)OriginalCallTarget0; return typeof(Func); - case 1: + case 1: originalTarget = (Func)OriginalCallTarget1; return typeof(Func); - case 2: + case 2: originalTarget = (Func)OriginalCallTarget2; return typeof(Func); - case 3: + case 3: originalTarget = (Func)OriginalCallTarget3; return typeof(Func); - case 4: + case 4: originalTarget = (Func)OriginalCallTarget4; return typeof(Func); - case 5: + case 5: originalTarget = (Func)OriginalCallTarget5; return typeof(Func); - case 6: + case 6: originalTarget = (Func)OriginalCallTarget6; return typeof(Func); - case 7: + case 7: originalTarget = (Func)OriginalCallTarget7; return typeof(Func); - case 8: + case 8: originalTarget = (Func)OriginalCallTarget8; return typeof(Func); - case 9: + case 9: originalTarget = (Func)OriginalCallTarget9; return typeof(Func); - case 10: + case 10: originalTarget = (Func)OriginalCallTarget10; return typeof(Func); - case 11: + case 11: originalTarget = (Func)OriginalCallTarget11; return typeof(Func); - case 12: + case 12: originalTarget = (Func)OriginalCallTarget12; return typeof(Func); - case 13: + case 13: originalTarget = (Func)OriginalCallTarget13; return typeof(Func); - case 14: + case 14: originalTarget = (Func)OriginalCallTarget14; return typeof(Func); - case 15: + case 15: originalTarget = (Func)OriginalCallTarget15; return typeof(Func); - // *** END GENERATED CODE *** + // *** END GENERATED CODE *** - #endregion + #endregion } } diff --git a/Src/IronPython/Compiler/PythonCompilerOptions.cs b/Src/IronPython/Compiler/PythonCompilerOptions.cs index 645ee7491..ce1aec8e1 100644 --- a/Src/IronPython/Compiler/PythonCompilerOptions.cs +++ b/Src/IronPython/Compiler/PythonCompilerOptions.cs @@ -4,10 +4,10 @@ using System; -using Microsoft.Scripting; - using IronPython.Runtime; +using Microsoft.Scripting; + namespace IronPython.Compiler { [Serializable] public sealed class PythonCompilerOptions : CompilerOptions { diff --git a/Src/IronPython/Compiler/PythonDynamicExpression.cs b/Src/IronPython/Compiler/PythonDynamicExpression.cs index af518004f..631bdc43e 100644 --- a/Src/IronPython/Compiler/PythonDynamicExpression.cs +++ b/Src/IronPython/Compiler/PythonDynamicExpression.cs @@ -2,22 +2,23 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; +using System.Collections.Generic; using System.Dynamic; +using System.Linq.Expressions; using System.Runtime.CompilerServices; + using IronPython.Runtime; + using Microsoft.Scripting.Ast; using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Utils; -using System.Collections.Generic; namespace IronPython.Compiler { internal sealed class PythonDynamicExpression1 : LightDynamicExpression1 { private readonly CompilationMode/*!*/ _mode; - public PythonDynamicExpression1(CallSiteBinder/*!*/ binder, CompilationMode/*!*/ mode, Expression/*!*/ arg0) + public PythonDynamicExpression1(CallSiteBinder/*!*/ binder, CompilationMode/*!*/ mode, Expression/*!*/ arg0) : base(binder, arg0) { _mode = mode; } @@ -213,7 +214,7 @@ public override void AddInstructions(LightCompiler compiler) { compiler.Compile(GetArgument(i)); } - switch(ArgumentCount) { + switch (ArgumentCount) { case 1: compiler.Instructions.EmitDynamic(Binder); break; case 2: compiler.Instructions.EmitDynamic(Binder); break; case 3: compiler.Instructions.EmitDynamic(Binder); break; @@ -228,7 +229,7 @@ public override void AddInstructions(LightCompiler compiler) { case 12: compiler.Instructions.EmitDynamic(Binder); break; case 13: compiler.Instructions.EmitDynamic(Binder); break; case 14: compiler.Instructions.EmitDynamic(Binder); break; - case 15: compiler.Instructions.EmitDynamic(Binder); break; + case 15: compiler.Instructions.EmitDynamic(Binder); break; } } else { base.AddInstructions(compiler); diff --git a/Src/IronPython/Compiler/PythonGlobal.cs b/Src/IronPython/Compiler/PythonGlobal.cs index c67c1f43c..d0bd28584 100644 --- a/Src/IronPython/Compiler/PythonGlobal.cs +++ b/Src/IronPython/Compiler/PythonGlobal.cs @@ -8,14 +8,12 @@ using System.Diagnostics; using System.Reflection; -using Microsoft.Scripting; -using Microsoft.Scripting.Ast; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - using IronPython.Runtime; using IronPython.Runtime.Operations; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + namespace IronPython.Compiler { /// /// Provides cached global variable for modules to enable optimized access to diff --git a/Src/IronPython/Compiler/PythonGlobalVariableExpression.cs b/Src/IronPython/Compiler/PythonGlobalVariableExpression.cs index e108d8997..5ce026ef1 100644 --- a/Src/IronPython/Compiler/PythonGlobalVariableExpression.cs +++ b/Src/IronPython/Compiler/PythonGlobalVariableExpression.cs @@ -2,22 +2,20 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; using System.Diagnostics; +using System.Linq.Expressions; + +using IronPython.Runtime; +using IronPython.Runtime.Operations; -using Microsoft.Scripting; using Microsoft.Scripting.Ast; using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime; -using IronPython.Runtime.Operations; - namespace IronPython.Compiler { - internal interface IPythonVariableExpression { + internal interface IPythonVariableExpression { Expression/*!*/ Assign(Expression/*!*/ value); Expression/*!*/ Delete(); Expression/*!*/ Create(); @@ -93,7 +91,7 @@ public override bool CanReduce { public Expression/*!*/ RawValue() { return new PythonRawGlobalValueExpression(this); - } + } public Expression/*!*/ Assign(Expression/*!*/ value) { return new PythonSetGlobalVariableExpression(this, value); diff --git a/Src/IronPython/Compiler/PythonSavableScriptCode.cs b/Src/IronPython/Compiler/PythonSavableScriptCode.cs index 78a70bcd6..2fc82716f 100644 --- a/Src/IronPython/Compiler/PythonSavableScriptCode.cs +++ b/Src/IronPython/Compiler/PythonSavableScriptCode.cs @@ -3,20 +3,15 @@ // See the LICENSE file in the project root for more information. #if FEATURE_REFEMIT -using System.Linq.Expressions; - using System; using System.Collections.Generic; +using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using Microsoft.Scripting; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - -using IronPython.Runtime; -using IronPython.Runtime.Operations; namespace IronPython.Compiler { /// @@ -27,7 +22,7 @@ internal class PythonSavableScriptCode : SavableScriptCode, ICustomScriptCodeDat private readonly Expression _code; private readonly string[] _names; private readonly string _moduleName; - + public PythonSavableScriptCode(Expression code, SourceUnit sourceUnit, string[] names, string moduleName) : base(sourceUnit) { _code = code; diff --git a/Src/IronPython/Compiler/PythonScriptCode.cs b/Src/IronPython/Compiler/PythonScriptCode.cs index fdda7b685..ef5d71f5a 100644 --- a/Src/IronPython/Compiler/PythonScriptCode.cs +++ b/Src/IronPython/Compiler/PythonScriptCode.cs @@ -2,23 +2,21 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; -using Microsoft.Scripting.Ast; -using MSAst = System.Linq.Expressions; - using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Threading; +using System.Linq.Expressions; + +using IronPython.Compiler.Ast; +using IronPython.Runtime; +using IronPython.Runtime.Operations; using Microsoft.Scripting; +using Microsoft.Scripting.Ast; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Compiler.Ast; -using IronPython.Runtime; -using IronPython.Runtime.Operations; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler { @@ -48,7 +46,7 @@ public override object Run() { public override object Run(Scope scope) { CodeContext ctx = GetContextForScope(scope, SourceUnit); - + if (SourceUnit.Kind == SourceCodeKind.Expression) { return EvalWrapper(ctx); } @@ -127,10 +125,10 @@ private bool ShouldInterpret(PythonContext pc) { } private static PythonConstantExpression ExtractConstant(LightExpression lambda) { - if (!(lambda.Body is BlockExpression body) || - body.Expressions.Count != 2 || - !(body.Expressions[0] is DebugInfoExpression) || - body.Expressions[1].NodeType != ExpressionType.Convert || + if (!(lambda.Body is BlockExpression body) || + body.Expressions.Count != 2 || + !(body.Expressions[0] is DebugInfoExpression) || + body.Expressions[1].NodeType != ExpressionType.Convert || !(((MSAst.UnaryExpression)body.Expressions[1]).Operand is PythonConstantExpression)) { return null; } diff --git a/Src/IronPython/Compiler/ReducableDynamicExpression.cs b/Src/IronPython/Compiler/ReducableDynamicExpression.cs index 7d12f0734..2b5d16bf3 100644 --- a/Src/IronPython/Compiler/ReducableDynamicExpression.cs +++ b/Src/IronPython/Compiler/ReducableDynamicExpression.cs @@ -2,17 +2,13 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; -using Microsoft.Scripting.Ast; - using System; using System.Collections.Generic; -using System.Diagnostics; -using System.Reflection; -using System.Reflection.Emit; -using System.Runtime.CompilerServices; using System.Dynamic; +using System.Linq.Expressions; + using Microsoft.Scripting.Actions; +using Microsoft.Scripting.Ast; namespace IronPython.Compiler { /// diff --git a/Src/IronPython/Compiler/RunnableScriptCode.cs b/Src/IronPython/Compiler/RunnableScriptCode.cs index 6865bfdc0..82dc2ee83 100644 --- a/Src/IronPython/Compiler/RunnableScriptCode.cs +++ b/Src/IronPython/Compiler/RunnableScriptCode.cs @@ -7,13 +7,12 @@ using System.Diagnostics; using System.Threading; -using Microsoft.Scripting; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - using IronPython.Runtime; using IronPython.Runtime.Operations; +using Microsoft.Scripting; +using Microsoft.Scripting.Runtime; + namespace IronPython.Compiler { internal abstract class RunnableScriptCode : ScriptCode { internal FunctionCode _code; @@ -83,7 +82,7 @@ public FunctionCode Code { } public abstract FunctionCode GetFunctionCode(bool register); - + protected void PushFrame(CodeContext context, FunctionCode code) { if (((PythonContext)SourceUnit.LanguageContext).PythonOptions.Frames) { PythonOps.PushFrame(context, code); diff --git a/Src/IronPython/Compiler/RuntimeScriptCode.cs b/Src/IronPython/Compiler/RuntimeScriptCode.cs index 6e0069b72..a5cdbb7fb 100644 --- a/Src/IronPython/Compiler/RuntimeScriptCode.cs +++ b/Src/IronPython/Compiler/RuntimeScriptCode.cs @@ -2,20 +2,19 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using MSAst = System.Linq.Expressions; - using System; using System.Diagnostics; using System.Threading; +using IronPython.Compiler.Ast; +using IronPython.Runtime; +using IronPython.Runtime.Operations; + using Microsoft.Scripting; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; -using IronPython.Compiler.Ast; -using IronPython.Runtime; -using IronPython.Runtime.Operations; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler { /// @@ -84,7 +83,7 @@ private object InvokeTarget(Scope scope) { // exec/eval code. Therefore we don't need to do any of that here. return _unoptimizedCode.Run(scope); } - + private object OptimizedEvalWrapper(FunctionCode funcCode) { try { return _optimizedTarget(funcCode); @@ -107,7 +106,7 @@ private void EnsureCompiled() { private Func/*!*/ Compile() { var pco = (PythonCompilerOptions)Ast.CompilerContext.Options; var pc = (PythonContext)SourceUnit.LanguageContext; - + if (pc.ShouldInterpret(pco, SourceUnit)) { return ((Microsoft.Scripting.Ast.LightExpression>)Ast.GetLambda()).Compile(pc.Options.CompilationThreshold); } else { diff --git a/Src/IronPython/Compiler/ToDiskCompilationMode.cs b/Src/IronPython/Compiler/ToDiskCompilationMode.cs index 40c089791..1bca21ce7 100644 --- a/Src/IronPython/Compiler/ToDiskCompilationMode.cs +++ b/Src/IronPython/Compiler/ToDiskCompilationMode.cs @@ -4,19 +4,15 @@ #if FEATURE_REFEMIT -using MSAst = System.Linq.Expressions; - -using System; using System.Collections.Generic; +using IronPython.Runtime.Operations; + using Microsoft.Scripting; using Microsoft.Scripting.Ast; -using Microsoft.Scripting.Utils; - -using IronPython.Runtime; -using IronPython.Runtime.Operations; using AstUtils = Microsoft.Scripting.Ast.Utils; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { diff --git a/Src/IronPython/Compiler/Token.cs b/Src/IronPython/Compiler/Token.cs index 88ed87b1f..11c1dfb5c 100644 --- a/Src/IronPython/Compiler/Token.cs +++ b/Src/IronPython/Compiler/Token.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System; -using System.Dynamic; + using Microsoft.Scripting; namespace IronPython.Compiler { diff --git a/Src/IronPython/Compiler/UncollectableCompilationMode.cs b/Src/IronPython/Compiler/UncollectableCompilationMode.cs index 15ece0f17..4901385e0 100644 --- a/Src/IronPython/Compiler/UncollectableCompilationMode.cs +++ b/Src/IronPython/Compiler/UncollectableCompilationMode.cs @@ -11,16 +11,15 @@ using System.Reflection; using System.Runtime.CompilerServices; -using Microsoft.Scripting; +using IronPython.Runtime; + using Microsoft.Scripting.Ast; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Utils; -using IronPython.Runtime; - -using MSAst = System.Linq.Expressions; using AstUtils = Microsoft.Scripting.Ast.Utils; +using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { @@ -49,7 +48,7 @@ public override LightLambdaExpression ReduceAst(PythonAst instance, string name) public override MSAst.Expression/*!*/ GetConstant(object value) { // if we can emit the value and we won't be continiously boxing/unboxing // then don't bother caching the value in a static field. - + // TODO: Sometimes we don't want to pre-box the values, such as if it's an int // going to a call site which can be strongly typed. We need to coordinate // more with whoever consumes the values. @@ -177,7 +176,7 @@ public void AddInstructions(LightCompiler compiler) { public static SiteInfo/*!*/ NextSite(DynamicMetaObjectBinder/*!*/ binder) where T : class { lock (StorageData.SiteLockObj) { int index = SiteStorage.SiteCount++; - + int arrIndex = index - StorageData.SiteTypes * StorageData.StaticFields; Type storageType = SiteStorage.SiteStorageType(index); @@ -239,7 +238,7 @@ public override void PublishContext(CodeContext/*!*/ context, ConstantInfo/*!*/ ((CodeContextExpression)codeContextInfo.Expression).Context = context; } - + private static void PublishConstant(object constant, ConstantInfo info) { StorageData.ConstantStorageType(info.Offset); @@ -309,7 +308,7 @@ public static DelegateCache FirstCacheNode(Type/*!*/ argType) { public DelegateCache NextCacheNode(Type/*!*/ argType) { Assert.NotNull(argType); - + DelegateCache nextCacheNode; if (TypeChain == null) { TypeChain = new Dictionary(); @@ -332,7 +331,7 @@ internal abstract class ReducibleExpression : MSAst.Expression { private readonly int _offset; private int _start = -1; private FieldInfo _fieldInfo; - + public ReducibleExpression(int offset) { _offset = offset; } @@ -341,7 +340,7 @@ public ReducibleExpression(int offset) { public abstract int FieldCount { get; } public abstract override Type/*!*/ Type { get; } protected abstract Type/*!*/ GetStorageType(int index); - + public FieldInfo FieldInfo { get { return _fieldInfo; @@ -432,7 +431,7 @@ public override Type/*!*/ Type { return returnType; } else { return typeof(object); - } + } } } diff --git a/Src/IronPython/Hosting/Python.cs b/Src/IronPython/Hosting/Python.cs index 32e666307..e5acde0ba 100644 --- a/Src/IronPython/Hosting/Python.cs +++ b/Src/IronPython/Hosting/Python.cs @@ -5,14 +5,14 @@ using System; using System.Collections.Generic; -using Microsoft.Scripting.Utils; -using Microsoft.Scripting.Hosting; -using Microsoft.Scripting.Hosting.Providers; - using IronPython.Modules; using IronPython.Runtime; using IronPython.Runtime.Exceptions; +using Microsoft.Scripting.Hosting; +using Microsoft.Scripting.Hosting.Providers; +using Microsoft.Scripting.Utils; + namespace IronPython.Hosting { /// @@ -198,11 +198,11 @@ public static class Python { /// /// /// - public static void ImportModule (this ScriptScope/*!*/ scope, string/*!*/ moduleName) { - ContractUtils.RequiresNotNull (scope, nameof(scope)); - ContractUtils.RequiresNotNull (moduleName, nameof(moduleName)); + public static void ImportModule(this ScriptScope/*!*/ scope, string/*!*/ moduleName) { + ContractUtils.RequiresNotNull(scope, nameof(scope)); + ContractUtils.RequiresNotNull(moduleName, nameof(moduleName)); - scope.SetVariable (moduleName, scope.Engine.ImportModule (moduleName)); + scope.SetVariable(moduleName, scope.Engine.ImportModule(moduleName)); } /// diff --git a/Src/IronPython/Hosting/PythonCodeDomCodeGen.cs b/Src/IronPython/Hosting/PythonCodeDomCodeGen.cs index 76c711b01..75f150ca1 100644 --- a/Src/IronPython/Hosting/PythonCodeDomCodeGen.cs +++ b/Src/IronPython/Hosting/PythonCodeDomCodeGen.cs @@ -4,6 +4,7 @@ using System.CodeDom; using System.Collections.Generic; + using Microsoft.Scripting.Runtime; #if FEATURE_CODEDOM @@ -44,8 +45,7 @@ protected override void WriteSnippetStatement(CodeSnippetStatement s) { int indentLen = lastLine.Length; if (indentLen > _indents.Peek()) { _indents.Push(indentLen); - } - else { + } else { while (indentLen < _indents.Peek()) { _indents.Pop(); } diff --git a/Src/IronPython/Hosting/PythonConsoleOptions.cs b/Src/IronPython/Hosting/PythonConsoleOptions.cs index b8b3dde7e..d79afa33f 100644 --- a/Src/IronPython/Hosting/PythonConsoleOptions.cs +++ b/Src/IronPython/Hosting/PythonConsoleOptions.cs @@ -3,7 +3,8 @@ // See the LICENSE file in the project root for more information. using System; -using Microsoft.Scripting.Hosting.Shell; + +using Microsoft.Scripting.Hosting.Shell; namespace IronPython.Hosting { [CLSCompliant(true)] diff --git a/Src/IronPython/Hosting/PythonService.cs b/Src/IronPython/Hosting/PythonService.cs index c790b9b8e..6948d16b1 100644 --- a/Src/IronPython/Hosting/PythonService.cs +++ b/Src/IronPython/Hosting/PythonService.cs @@ -11,8 +11,10 @@ using System; using System.Collections.Generic; using System.Threading; + using IronPython.Runtime; using IronPython.Runtime.Operations; + using Microsoft.Scripting.Hosting; using Microsoft.Scripting.Hosting.Providers; using Microsoft.Scripting.Utils; @@ -76,7 +78,7 @@ public PythonService(PythonContext/*!*/ context, ScriptEngine/*!*/ engine) { _context.PublishModule(name, module); module.__init__(name, docString); module.__dict__["__file__"] = filename; - + return HostingHelpers.CreateScriptScope(_engine, module.Scope); } @@ -114,7 +116,7 @@ public ObjectHandle GetSetCommandDispatcher(ObjectHandle dispatcher) { if (res != null) { return new ObjectHandle(res); } - + return null; } diff --git a/Src/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs b/Src/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs index 2f987168e..bd64248c7 100644 --- a/Src/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs +++ b/Src/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Buffers; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; diff --git a/Src/IronPython/Modules/_ast.cs b/Src/IronPython/Modules/_ast.cs index 42d5deabc..ce982b244 100755 --- a/Src/IronPython/Modules/_ast.cs +++ b/Src/IronPython/Modules/_ast.cs @@ -10,7 +10,6 @@ using System.Collections; using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using System.Numerics; using System.Runtime.InteropServices; diff --git a/Src/IronPython/Modules/_fileio.cs b/Src/IronPython/Modules/_fileio.cs index 1069ea15b..ac5d1a774 100644 --- a/Src/IronPython/Modules/_fileio.cs +++ b/Src/IronPython/Modules/_fileio.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Diagnostics; using System.Dynamic; using System.IO; using System.Linq.Expressions; @@ -19,7 +18,6 @@ using Microsoft.Scripting; using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; // TODO: Documentation copied from CPython is inadequate in some places and wrong in others. @@ -127,8 +125,7 @@ public FileIO(CodeContext/*!*/ context, string name, string mode = "r", bool clo default: throw new InvalidOperationException(); } - } - else { + } else { object fdobj = PythonOps.CallWithContext(context, opener, name, flags); if (fdobj is int fd) { if (fd < 0) { diff --git a/Src/IronPython/Modules/_imp.cs b/Src/IronPython/Modules/_imp.cs index 1e91700cf..11d81dee0 100644 --- a/Src/IronPython/Modules/_imp.cs +++ b/Src/IronPython/Modules/_imp.cs @@ -10,8 +10,6 @@ using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting.Utils; - [assembly: PythonModule("_imp", typeof(IronPython.Modules.PythonImport))] namespace IronPython.Modules { public static class PythonImport { @@ -59,7 +57,7 @@ public static void release_lock(CodeContext/*!*/ context) { throw PythonOps.RuntimeError("not holding the import lock"); } SetLockCount(context, lockCount - 1); - } + } } public static object init_builtin(CodeContext/*!*/ context, [NotNone] string/*!*/ name) { @@ -107,7 +105,7 @@ public static int is_builtin(CodeContext/*!*/ context, string/*!*/ name) { return -1; } - + return 1; } return 0; diff --git a/Src/IronPython/Modules/_io.cs b/Src/IronPython/Modules/_io.cs index d5b89b13d..faf720c8a 100644 --- a/Src/IronPython/Modules/_io.cs +++ b/Src/IronPython/Modules/_io.cs @@ -14,15 +14,15 @@ using System.Runtime.InteropServices; using System.Text; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - using IronPython.Runtime; using IronPython.Runtime.Binding; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + [assembly: PythonModule("_io", typeof(IronPython.Modules.PythonIOModule))] namespace IronPython.Modules { public static partial class PythonIOModule { @@ -32,7 +32,7 @@ public static partial class PythonIOModule { private static readonly object _unsupportedOperationKey = new object(); // Values of the O_flags below has to be identical with flags defined in PythonNT - + #region Generated Common O_Flags // *** BEGIN GENERATED CODE *** @@ -161,18 +161,18 @@ public virtual bool isatty(CodeContext/*!*/ context) { } [PythonHidden] - public virtual Bytes peek(CodeContext/*!*/ context, int length=0) { + public virtual Bytes peek(CodeContext/*!*/ context, int length = 0) { _checkClosed(); throw AttributeError("peek"); } [PythonHidden] - public virtual object read(CodeContext/*!*/ context, object length=null) { + public virtual object read(CodeContext/*!*/ context, object length = null) { throw AttributeError("read"); } [PythonHidden] - public virtual Bytes read1(CodeContext/*!*/ context, int length=0) { + public virtual Bytes read1(CodeContext/*!*/ context, int length = 0) { throw AttributeError("read1"); } @@ -190,7 +190,7 @@ public virtual object readline(CodeContext/*!*/ context, int limit) { if (cur == null) { break; } - + Bytes curBytes = GetBytes(cur, "read()"); if (curBytes.Count == 0) { break; @@ -206,7 +206,7 @@ public virtual object readline(CodeContext/*!*/ context, int limit) { return Bytes.Concat(res, count); } - public object readline(CodeContext/*!*/ context, object limit=null) { + public object readline(CodeContext/*!*/ context, object limit = null) { return readline(context, GetInt(limit, -1)); } @@ -214,7 +214,7 @@ public virtual PythonList readlines() { return readlines(null); } - public virtual PythonList readlines(object hint=null) { + public virtual PythonList readlines(object hint = null) { int size = GetInt(hint, -1); PythonList res = new PythonList(); @@ -251,7 +251,7 @@ public virtual PythonList readlines(object hint=null) { return res; } - public virtual BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optional]object whence) { + public virtual BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optional] object whence) { throw UnsupportedOperation(context, "seek"); } @@ -263,7 +263,7 @@ public virtual BigInteger tell(CodeContext/*!*/ context) { return seek(context, 0, 1); } - public virtual BigInteger truncate(CodeContext/*!*/ context, object pos=null) { + public virtual BigInteger truncate(CodeContext/*!*/ context, object pos = null) { throw UnsupportedOperation(context, "truncate"); } @@ -402,7 +402,7 @@ private PythonDictionary EnsureCustomAttributes() { DynamicMetaObject IDynamicMetaObjectProvider.GetMetaObject(Expression parameter) { return new MetaExpandable<_IOBase>(parameter, this); } - + #endregion #region Private implementation details @@ -424,7 +424,7 @@ internal Exception AttributeError(string attrName) { internal Exception InvalidPosition(BigInteger pos) { return PythonOps.IOError("Raw stream returned invalid position {0}", pos); } - + #endregion } @@ -434,7 +434,7 @@ public _RawIOBase(CodeContext/*!*/ context) : base(context) { } #region Public API - public override object read(CodeContext/*!*/ context, object size=null) { + public override object read(CodeContext/*!*/ context, object size = null) { int sizeInt = GetInt(size, -1); if (sizeInt < 0) { return readall(context); @@ -480,7 +480,7 @@ public override BigInteger write(CodeContext/*!*/ context, object buf) { } #endregion - + #region IDynamicMetaObjectProvider Members DynamicMetaObject IDynamicMetaObjectProvider.GetMetaObject(Expression parameter) { @@ -500,7 +500,7 @@ public virtual object detach(CodeContext/*!*/ context) { throw UnsupportedOperation(context, "detach"); } - public override object read(CodeContext/*!*/ context, object length=null) { + public override object read(CodeContext/*!*/ context, object length = null) { throw UnsupportedOperation(context, "read"); } @@ -573,15 +573,15 @@ public virtual object newlines { get { return null; } } - public override object read(CodeContext/*!*/ context, [DefaultParameterValue(-1)]object length) { + public override object read(CodeContext/*!*/ context, [DefaultParameterValue(-1)] object length) { throw UnsupportedOperation(context, "read"); } - public override object readline(CodeContext/*!*/ context, int limit=-1) { + public override object readline(CodeContext/*!*/ context, int limit = -1) { throw UnsupportedOperation(context, "readline"); } - public override BigInteger truncate(CodeContext/*!*/ context, object pos=null) { + public override BigInteger truncate(CodeContext/*!*/ context, object pos = null) { throw UnsupportedOperation(context, "truncate"); } @@ -609,7 +609,7 @@ public class BufferedReader : _BufferedIOBase, IDynamicMetaObjectProvider { private Bytes _readBuf; private int _readBufPos; - internal static BufferedReader Create(CodeContext/*!*/ context, object raw, int buffer_size=DEFAULT_BUFFER_SIZE) { + internal static BufferedReader Create(CodeContext/*!*/ context, object raw, int buffer_size = DEFAULT_BUFFER_SIZE) { var res = new BufferedReader(context, raw, buffer_size); res.__init__(context, raw, buffer_size); return res; @@ -624,7 +624,7 @@ params object[] args public void __init__( CodeContext/*!*/ context, object raw, - int buffer_size=DEFAULT_BUFFER_SIZE + int buffer_size = DEFAULT_BUFFER_SIZE ) { this.raw = raw; @@ -659,7 +659,7 @@ public object raw { #region _BufferedIOMixin - public override BigInteger truncate(CodeContext/*!*/ context, object pos=null) { + public override BigInteger truncate(CodeContext/*!*/ context, object pos = null) { if (_rawIO != null) { return _rawIO.truncate(context, pos); } @@ -756,7 +756,7 @@ public override bool isatty(CodeContext/*!*/ context) { #endregion - public override object read(CodeContext/*!*/ context, object length=null) { + public override object read(CodeContext/*!*/ context, object length = null) { int len = GetInt(length, -1); if (len < -1) { @@ -795,7 +795,7 @@ private Bytes ReadNoLock(CodeContext/*!*/ context, int length, bool read1 = fals } break; } - chunks.Add(chunk); + chunks.Add(chunk); count += chunk.Count; if (read1) break; } @@ -856,7 +856,7 @@ private Bytes ReadNoLock(CodeContext/*!*/ context, int length, bool read1 = fals } } - public override Bytes peek(CodeContext/*!*/ context, int length=0) { + public override Bytes peek(CodeContext/*!*/ context, int length = 0) { _checkClosed(); if (length <= 0 || length > _bufSize) { @@ -890,7 +890,7 @@ private Bytes PeekNoLock(CodeContext/*!*/ context, int length) { return _readBuf; } - public override Bytes read1(CodeContext/*!*/ context, int length=0) { + public override Bytes read1(CodeContext/*!*/ context, int length = 0) { if (length == 0) { return Bytes.Empty; } else if (length < 0) { @@ -990,13 +990,13 @@ public override BigInteger tell(CodeContext/*!*/ context) { return res - _readBuf.Count + _readBufPos; } - public BigInteger seek(double offset, [Optional]object whence) { + public BigInteger seek(double offset, [Optional] object whence) { _checkClosed(); throw PythonOps.TypeError("an integer is required"); } - public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optional]object whence) { + public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optional] object whence) { int whenceInt = GetInt(whence); if (whenceInt < 0 || whenceInt > 2) { throw PythonOps.ValueError("invalid whence ({0}, should be 0, 1, or 2)", whenceInt); @@ -1018,7 +1018,7 @@ public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optio ResetReadBuf(); if (pos < 0) { throw InvalidPosition(pos); - } + } GC.KeepAlive(this); return pos; @@ -1056,7 +1056,7 @@ private Bytes ResetReadBuf() { _readBufPos = 0; } _readBuf = Bytes.Empty; - + return res; } @@ -1073,8 +1073,8 @@ public class BufferedWriter : _BufferedIOBase, IDynamicMetaObjectProvider { internal static BufferedWriter Create(CodeContext/*!*/ context, object raw, - int buffer_size=DEFAULT_BUFFER_SIZE, - object max_buffer_size=null) { + int buffer_size = DEFAULT_BUFFER_SIZE, + object max_buffer_size = null) { var res = new BufferedWriter(context, raw, buffer_size, max_buffer_size); res.__init__(context, raw, buffer_size, max_buffer_size); @@ -1084,8 +1084,8 @@ internal static BufferedWriter Create(CodeContext/*!*/ context, public BufferedWriter( CodeContext/*!*/ context, object raw, - int buffer_size=DEFAULT_BUFFER_SIZE, - object max_buffer_size=null + int buffer_size = DEFAULT_BUFFER_SIZE, + object max_buffer_size = null ) : base(context) { } @@ -1093,8 +1093,8 @@ public BufferedWriter( public void __init__( CodeContext/*!*/ context, object raw, - int buffer_size=DEFAULT_BUFFER_SIZE, - object max_buffer_size=null + int buffer_size = DEFAULT_BUFFER_SIZE, + object max_buffer_size = null ) { if (max_buffer_size != null) { PythonOps.Warn(context, PythonExceptions.DeprecationWarning, "max_buffer_size is deprecated"); @@ -1260,7 +1260,7 @@ public override BigInteger write(CodeContext/*!*/ context, object buf) { } } - public override BigInteger truncate(CodeContext/*!*/ context, object pos=null) { + public override BigInteger truncate(CodeContext/*!*/ context, object pos = null) { lock (this) { FlushNoLock(context); if (pos == null) { @@ -1342,13 +1342,13 @@ public override BigInteger tell(CodeContext/*!*/ context) { return res + _writeBuf.Count; } - public BigInteger seek(double offset, [Optional]object whence) { + public BigInteger seek(double offset, [Optional] object whence) { _checkClosed(); throw PythonOps.TypeError("an integer is required"); } - public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optional]object whence) { + public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optional] object whence) { int whenceInt = GetInt(whence); if (whenceInt < 0 || whenceInt > 2) { throw PythonOps.ValueError("invalid whence ({0}, should be 0, 1, or 2)", whenceInt); @@ -1392,7 +1392,7 @@ DynamicMetaObject IDynamicMetaObjectProvider.GetMetaObject(Expression parameter) [PythonType] public class BufferedRandom : _BufferedIOBase, IDynamicMetaObjectProvider { private _IOBase _inner; - + private int _bufSize; private Bytes _readBuf; private int _readBufPos; @@ -1400,8 +1400,8 @@ public class BufferedRandom : _BufferedIOBase, IDynamicMetaObjectProvider { internal static BufferedRandom Create(CodeContext/*!*/ context, _IOBase raw, - int buffer_size=DEFAULT_BUFFER_SIZE, - object max_buffer_size=null) { + int buffer_size = DEFAULT_BUFFER_SIZE, + object max_buffer_size = null) { var res = new BufferedRandom(context, raw, buffer_size, max_buffer_size); res.__init__(context, raw, buffer_size, max_buffer_size); return res; @@ -1410,16 +1410,16 @@ internal static BufferedRandom Create(CodeContext/*!*/ context, public BufferedRandom( CodeContext/*!*/ context, _IOBase raw, - int buffer_size=DEFAULT_BUFFER_SIZE, - object max_buffer_size=null + int buffer_size = DEFAULT_BUFFER_SIZE, + object max_buffer_size = null ) : base(context) { } public void __init__( CodeContext/*!*/ context, _IOBase raw, - int buffer_size=DEFAULT_BUFFER_SIZE, - object max_buffer_size=null + int buffer_size = DEFAULT_BUFFER_SIZE, + object max_buffer_size = null ) { if (max_buffer_size != null) { PythonOps.Warn(context, PythonExceptions.DeprecationWarning, "max_buffer_size is deprecated"); @@ -1521,7 +1521,7 @@ public override bool isatty(CodeContext/*!*/ context) { #region BufferedReader - public override object read(CodeContext/*!*/ context, object length=null) { + public override object read(CodeContext/*!*/ context, object length = null) { flush(context); int len = GetInt(length, -1); @@ -1602,7 +1602,7 @@ private Bytes ReadNoLock(CodeContext/*!*/ context, int length) { } } - public override Bytes peek(CodeContext/*!*/ context, int length=0) { + public override Bytes peek(CodeContext/*!*/ context, int length = 0) { _checkClosed(); flush(context); @@ -1630,7 +1630,7 @@ private Bytes PeekNoLock(CodeContext/*!*/ context, int length) { return _readBuf; } - public override Bytes read1(CodeContext/*!*/ context, int length=0) { + public override Bytes read1(CodeContext/*!*/ context, int length = 0) { flush(context); if (length == 0) { return Bytes.Empty; @@ -1747,13 +1747,13 @@ public override BigInteger readinto(CodeContext/*!*/ context, object buf) { return base.readinto(context, buf); } - public BigInteger seek(double offset, [Optional]object whence) { + public BigInteger seek(double offset, [Optional] object whence) { _checkClosed(); throw PythonOps.TypeError("an integer is required"); } - public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optional]object whence) { + public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optional] object whence) { int whenceInt = GetInt(whence); if (whenceInt < 0 || whenceInt > 2) { throw PythonOps.ValueError("invalid whence ({0}, should be 0, 1, or 2)", whenceInt); @@ -1777,7 +1777,7 @@ public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optio } } - public override BigInteger truncate(CodeContext/*!*/ context, object pos=null) { + public override BigInteger truncate(CodeContext/*!*/ context, object pos = null) { lock (this) { FlushNoLock(context); if (pos == null) { @@ -1822,8 +1822,8 @@ public BufferedRWPair( CodeContext/*!*/ context, object reader, object writer, - int buffer_size=DEFAULT_BUFFER_SIZE, - object max_buffer_size=null + int buffer_size = DEFAULT_BUFFER_SIZE, + object max_buffer_size = null ) : base(context) { } @@ -1831,8 +1831,8 @@ public void __init__( CodeContext/*!*/ context, object reader, object writer, - int buffer_size=DEFAULT_BUFFER_SIZE, - object max_buffer_size=null + int buffer_size = DEFAULT_BUFFER_SIZE, + object max_buffer_size = null ) { if (max_buffer_size != null) { PythonOps.Warn(context, PythonExceptions.DeprecationWarning, "max_buffer_size is deprecated"); @@ -1870,7 +1870,7 @@ public object writer { } } - public override object read(CodeContext/*!*/ context, object length=null) { + public override object read(CodeContext/*!*/ context, object length = null) { var res = _reader.read(context, length); GC.KeepAlive(this); return res; @@ -1888,7 +1888,7 @@ public override BigInteger write(CodeContext/*!*/ context, object buf) { return res; } - public override Bytes peek(CodeContext/*!*/ context, int length=0) { + public override Bytes peek(CodeContext/*!*/ context, int length = 0) { var res = _reader.peek(context, length); GC.KeepAlive(this); return res; @@ -1997,7 +1997,7 @@ public void __init__( bool line_buffering = false, bool write_through = false ) { - switch(newline) { + switch (newline) { case null: case "": case "\n": @@ -2199,7 +2199,7 @@ public override BigInteger tell(CodeContext/*!*/ context) { // skip backwards to snapshot point pos -= _nextInput.Count; - + // determine number of decoded chars used up after snapshot int skip = _decodedCharsUsed; if (skip == 0) { @@ -2279,7 +2279,7 @@ public override BigInteger tell(CodeContext/*!*/ context) { } } - public override BigInteger truncate(CodeContext/*!*/ context, object pos=null) { + public override BigInteger truncate(CodeContext/*!*/ context, object pos = null) { flush(context); if (pos == null) { pos = tell(context); @@ -2317,9 +2317,9 @@ public override object detach(CodeContext/*!*/ context) { return res; } - public BigInteger seek(double offset, [Optional]object whence) => throw PythonOps.TypeError("integer argument expected, got float"); + public BigInteger seek(double offset, [Optional] object whence) => throw PythonOps.TypeError("integer argument expected, got float"); - public override BigInteger seek(CodeContext/*!*/ context, BigInteger cookie, [Optional]object whence) { + public override BigInteger seek(CodeContext/*!*/ context, BigInteger cookie, [Optional] object whence) { int whenceInt = GetInt(whence); if (closed) { throw PythonOps.ValueError("tell on closed file"); @@ -2451,7 +2451,7 @@ public override BigInteger seek(CodeContext/*!*/ context, BigInteger cookie, [Op return cookie; } - public override object read(CodeContext/*!*/ context, object length=null) { + public override object read(CodeContext/*!*/ context, object length = null) { _checkClosed(); if (!readable(context)) { throw UnsupportedOperationWithMessage(context, "not readable"); @@ -2497,7 +2497,7 @@ public override object read(CodeContext/*!*/ context, object length=null) { } } - public override object readline(CodeContext/*!*/ context, int limit=-1) { + public override object readline(CodeContext/*!*/ context, int limit = -1) { _checkClosed("read from closed file"); if (!readable(context)) { throw UnsupportedOperationWithMessage(context, "not readable"); @@ -2577,7 +2577,7 @@ public override object readline(CodeContext/*!*/ context, int limit=-1) { } #endregion - + #region IEnumerator Members private object _current; @@ -2795,13 +2795,13 @@ private bool ReadChunk(CodeContext/*!*/ context) { public static _IOBase open( CodeContext/*!*/ context, object file, - string mode="r", - int buffering=-1, - string encoding=null, - string errors=null, - string newline=null, - bool closefd=true, - object opener=null + string mode = "r", + int buffering = -1, + string encoding = null, + string errors = null, + string newline = null, + bool closefd = true, + object opener = null ) { string fname = null; if (!Converter.TryConvertToIndex(file, out int fd, false, false)) { @@ -2898,15 +2898,13 @@ internal static TextIOWrapper CreateConsole(PythonContext context, SharedIO io, var fio = new FileIO(cc, sio) { name = name }; var buffer = BufferedReader.Create(cc, fio, DEFAULT_BUFFER_SIZE); return TextIOWrapper.Create(cc, buffer, encoding, null, null, true); - } - else if (type == ConsoleStreamType.Output) { + } else if (type == ConsoleStreamType.Output) { var encoding = StringOps.GetEncodingName(io.OutputEncoding); sio = new StreamBox(io.GetStreamProxy(type), type); var fio = new FileIO(cc, sio) { name = name }; var buffer = BufferedWriter.Create(cc, fio, DEFAULT_BUFFER_SIZE, null); return TextIOWrapper.Create(cc, buffer, encoding, null, null, true); - } - else { + } else { Debug.Assert(type == ConsoleStreamType.ErrorOutput); var encoding = StringOps.GetEncodingName(io.ErrorEncoding); sio = new StreamBox(io.GetStreamProxy(type), type); @@ -2936,13 +2934,13 @@ internal enum LineEnding { private string _errors; #pragma warning restore 414 - public IncrementalNewlineDecoder(object decoder, bool translate, string errors="strict") { + public IncrementalNewlineDecoder(object decoder, bool translate, string errors = "strict") { _decoder = decoder; _translate = translate; _errors = errors; } - public string decode(CodeContext/*!*/ context, [NotNone] IList input, bool final=false) { + public string decode(CodeContext/*!*/ context, [NotNone] IList input, bool final = false) { object output; if (_decoder == null) { output = input.MakeString(); @@ -2966,7 +2964,7 @@ public string decode(CodeContext/*!*/ context, [NotNone] IList input, bool return DecodeWorker(context, decoded, final); } - public string decode(CodeContext/*!*/ context, [NotNone] string input, bool final=false) { + public string decode(CodeContext/*!*/ context, [NotNone] string input, bool final = false) { if (_decoder == null) { return DecodeWorker(context, input, final); } @@ -3150,7 +3148,7 @@ private static int GetInt(object i, string msg, params object[] args) { if (msg == null) { throw PythonOps.TypeError("integer argument expected, got '{0}'", PythonOps.GetPythonTypeName(i)); } - + throw PythonOps.TypeError(msg, args); } @@ -3185,7 +3183,7 @@ private static bool TryGetInt(object i, out int value) { /// Convert string or bytes into bytes /// private static Bytes GetBytes(object o, string name) { - if(o == null) + if (o == null) return null; if (o is Bytes bytes) { diff --git a/Src/IronPython/Runtime/ArrayData.cs b/Src/IronPython/Runtime/ArrayData.cs index c8f2b60ca..6f33f48f9 100644 --- a/Src/IronPython/Runtime/ArrayData.cs +++ b/Src/IronPython/Runtime/ArrayData.cs @@ -20,7 +20,7 @@ namespace IronPython.Runtime { internal interface ArrayData : IList { Type StorageType { get; } - bool CanStore([NotNullWhen(true)]object? item); + bool CanStore([NotNullWhen(true)] object? item); int CountItems(object? item); IntPtr GetAddress(); void AddRange(ArrayData value); @@ -131,7 +131,7 @@ public void AddRange(IEnumerable collection) { void ArrayData.AddRange(ArrayData value) => AddRange((ArrayData)value); - bool ArrayData.CanStore([NotNullWhen(true)]object? item) + bool ArrayData.CanStore([NotNullWhen(true)] object? item) => TryConvert(item, out _); public void Clear() { @@ -144,7 +144,7 @@ public void Clear() { public bool Contains(T item) => _size != 0 && IndexOf(item) != -1; - bool IList.Contains([NotNullWhen(true)]object? item) + bool IList.Contains([NotNullWhen(true)] object? item) => TryConvert(item, out T value) && Contains(value); public void CopyTo(T[] array, int arrayIndex) @@ -368,7 +368,7 @@ public void Reverse() public Span AsByteSpan() => MemoryMarshal.AsBytes(_items.AsSpan(0, _size)); - private static bool TryConvert([NotNullWhen(true)]object? value, out T result) { + private static bool TryConvert([NotNullWhen(true)] object? value, out T result) { if (value is null) { result = default; return false; @@ -433,7 +433,7 @@ public void Dispose() { public int Offset => 0; - public string? Format => _flags.HasFlag(BufferFlags.Format)? _format : null; + public string? Format => _flags.HasFlag(BufferFlags.Format) ? _format : null; public int ItemCount => _arrayData.Count; diff --git a/Src/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs b/Src/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs index 9be44b4a9..cd732e55f 100644 --- a/Src/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs +++ b/Src/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs @@ -4,14 +4,12 @@ using System; using System.Dynamic; -using System.Runtime.CompilerServices; - using System.Linq.Expressions; +using IronPython.Runtime.Operations; + using Microsoft.Scripting.Actions; -using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; -using IronPython.Runtime.Operations; namespace IronPython.Runtime.Binding { internal partial class BinaryRetTypeBinder : ComboBinder, IExpressionSerializable { @@ -42,7 +40,7 @@ public override Type ReturnType { #region IExpressionSerializable Members public Expression CreateExpression() { - + return Expression.Call( typeof(PythonOps).GetMethod(nameof(PythonOps.MakeComboAction)), BindingHelpers.CreateBinderStateExpression(), diff --git a/Src/IronPython/Runtime/Binding/Binders.cs b/Src/IronPython/Runtime/Binding/Binders.cs index 36f0d7f1e..38479d579 100644 --- a/Src/IronPython/Runtime/Binding/Binders.cs +++ b/Src/IronPython/Runtime/Binding/Binders.cs @@ -2,16 +2,13 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; using System.Dynamic; +using System.Linq.Expressions; using Microsoft.Scripting.Actions; namespace IronPython.Runtime.Binding { - using Ast = Expression; - internal static class Binders { /// /// Backwards compatible Convert for the old sites that need to flow CodeContext @@ -48,7 +45,7 @@ internal static class Binders { public static DynamicMetaObjectBinder UnaryOperationBinder(PythonContext state, PythonOperationKind operatorName) { ExpressionType? et = GetExpressionTypeFromUnaryOperator(operatorName); - + if (et == null) { return state.Operation( operatorName diff --git a/Src/IronPython/Runtime/Binding/BindingHelpers.cs b/Src/IronPython/Runtime/Binding/BindingHelpers.cs index 2119d635d..6d8d41cea 100644 --- a/Src/IronPython/Runtime/Binding/BindingHelpers.cs +++ b/Src/IronPython/Runtime/Binding/BindingHelpers.cs @@ -2,22 +2,21 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; -using System.Numerics; - using System; using System.Diagnostics; using System.Dynamic; +using System.Linq.Expressions; +using System.Numerics; using System.Reflection; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + using Microsoft.Scripting.Actions; using Microsoft.Scripting.Actions.Calls; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -95,7 +94,7 @@ internal static CallSignature GetCallSignature(DynamicMetaObjectBinder/*!*/ acti if (action is InvokeMemberBinder cla) { return CallInfoToSignature(cla.CallInfo); } - + // DLR Create action which we hand off to our call code, also // has an argument array. CreateInstanceBinder ca = action as CreateInstanceBinder; @@ -125,7 +124,7 @@ internal static CallSignature GetCallSignature(DynamicMetaObjectBinder/*!*/ acti return action.Defer(args); } - return AddDynamicTestAndDefer(action, + return AddDynamicTestAndDefer(action, action.FallbackInvoke( new DynamicMetaObject( Binders.Get( @@ -196,7 +195,7 @@ internal static bool IsSubclassOf(DynamicMetaObject/*!*/ xType, DynamicMetaObjec PythonType y = MetaPythonObject.GetPythonType(yType); return x.IsSubclassOf(y); } - + private static BuiltinFunction TryConvertToBuiltinFunction(object o) { if (o is BuiltinMethodDescriptor md) { return md.Template; @@ -222,7 +221,7 @@ private static BuiltinFunction TryConvertToBuiltinFunction(object o) { AstUtils.Convert(res.Expression, bestType), AstUtils.Convert(defer, bestType) ), - res.Restrictions + res.Restrictions ); } @@ -237,13 +236,13 @@ private static BuiltinFunction TryConvertToBuiltinFunction(object o) { return res; } - + internal static ValidationInfo/*!*/ GetValidationInfo(DynamicMetaObject/*!*/ tested, PythonType type) { return new ValidationInfo( Ast.AndAlso( Ast.TypeEqual(tested.Expression, type.UnderlyingSystemType), CheckTypeVersion( - AstUtils.Convert(tested.Expression, type.UnderlyingSystemType), + AstUtils.Convert(tested.Expression, type.UnderlyingSystemType), type.Version ) ) @@ -308,9 +307,9 @@ private static BuiltinFunction TryConvertToBuiltinFunction(object o) { internal static Expression AddRecursionCheck(PythonContext pyContext, Expression expr) { ParameterExpression tmp = Ast.Variable(expr.Type, "callres"); - expr = + expr = Ast.Block( - new [] { tmp }, + new[] { tmp }, AstUtils.Try( Ast.Call(typeof(PythonOps).GetMethod(nameof(PythonOps.FunctionPushFrame)), Ast.Constant(pyContext)), Ast.Assign(tmp, expr) diff --git a/Src/IronPython/Runtime/Binding/BindingWarnings.cs b/Src/IronPython/Runtime/Binding/BindingWarnings.cs index 9776e3297..1ba44d942 100644 --- a/Src/IronPython/Runtime/Binding/BindingWarnings.cs +++ b/Src/IronPython/Runtime/Binding/BindingWarnings.cs @@ -4,7 +4,6 @@ using System; using System.Linq.Expressions; -using System.Reflection; using System.Threading; using IronPython.Runtime.Exceptions; diff --git a/Src/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs b/Src/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs index 1760542dc..e0ce789de 100644 --- a/Src/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs +++ b/Src/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs @@ -2,19 +2,9 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - -using System; -using System.Collections.Generic; -using System.Diagnostics; using System.Dynamic; -using Microsoft.Scripting; using Microsoft.Scripting.Actions; -using Microsoft.Scripting.Actions.Calls; -using Microsoft.Scripting.Utils; - -using IronPython.Runtime.Operations; using AstUtils = Microsoft.Scripting.Ast.Utils; diff --git a/Src/IronPython/Runtime/Binding/ConditionalBuilder.cs b/Src/IronPython/Runtime/Binding/ConditionalBuilder.cs index ec61a5a7e..3d05a2c4c 100644 --- a/Src/IronPython/Runtime/Binding/ConditionalBuilder.cs +++ b/Src/IronPython/Runtime/Binding/ConditionalBuilder.cs @@ -2,12 +2,10 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; using System.Collections.Generic; -using System.Text; using System.Dynamic; +using System.Linq.Expressions; namespace IronPython.Runtime.Binding { using Ast = Expression; @@ -63,7 +61,7 @@ public void ExtendLastCondition(Expression condition) { condition); } } - + /// /// Adds the non-conditional terminating node. /// diff --git a/Src/IronPython/Runtime/Binding/ContextArgBuilder.cs b/Src/IronPython/Runtime/Binding/ContextArgBuilder.cs index 33edf183f..a137d632a 100644 --- a/Src/IronPython/Runtime/Binding/ContextArgBuilder.cs +++ b/Src/IronPython/Runtime/Binding/ContextArgBuilder.cs @@ -3,14 +3,9 @@ // See the LICENSE file in the project root for more information. using System.Linq.Expressions; - -using System.Collections.Generic; -using System.Diagnostics; using System.Reflection; -using System; -using System.Dynamic; + using Microsoft.Scripting.Actions.Calls; -using Microsoft.Scripting.Utils; namespace IronPython.Runtime.Binding { @@ -18,8 +13,8 @@ namespace IronPython.Runtime.Binding { /// ArgBuilder which provides the CodeContext parameter to a method. /// public sealed class ContextArgBuilder : ArgBuilder { - public ContextArgBuilder(ParameterInfo info) - : base(info){ + public ContextArgBuilder(ParameterInfo info) + : base(info) { } public override int Priority { diff --git a/Src/IronPython/Runtime/Binding/ConversionBinder.cs b/Src/IronPython/Runtime/Binding/ConversionBinder.cs index 61349b7aa..038974434 100644 --- a/Src/IronPython/Runtime/Binding/ConversionBinder.cs +++ b/Src/IronPython/Runtime/Binding/ConversionBinder.cs @@ -2,26 +2,25 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Dynamic; +using System.Linq.Expressions; using System.Numerics; +using System.Reflection; using System.Runtime.CompilerServices; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; -using System.Reflection; - namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -546,7 +545,7 @@ public override bool Equals(object obj) { return false; } - return ob._context.Binder == _context.Binder && + return ob._context.Binder == _context.Binder && _kind == ob._kind && base.Equals(obj) && _retObject == ob._retObject; } diff --git a/Src/IronPython/Runtime/Binding/CreateFallbackBinder.cs b/Src/IronPython/Runtime/Binding/CreateFallbackBinder.cs index 2b6a9aaa0..07b739b28 100644 --- a/Src/IronPython/Runtime/Binding/CreateFallbackBinder.cs +++ b/Src/IronPython/Runtime/Binding/CreateFallbackBinder.cs @@ -2,17 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - -using System; -using System.Collections.Generic; -using System.Diagnostics; using System.Dynamic; -using IronPython.Runtime.Operations; -using Microsoft.Scripting; -using Microsoft.Scripting.Actions; -using Microsoft.Scripting.Utils; -using AstUtils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Runtime.Binding { /// diff --git a/Src/IronPython/Runtime/Binding/FastBindResult.cs b/Src/IronPython/Runtime/Binding/FastBindResult.cs index e6866a55c..7f4a07761 100644 --- a/Src/IronPython/Runtime/Binding/FastBindResult.cs +++ b/Src/IronPython/Runtime/Binding/FastBindResult.cs @@ -2,17 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - -using System; -using System.Dynamic; -using System.Runtime.CompilerServices; - -using Microsoft.Scripting.Actions; - namespace IronPython.Runtime.Binding { - using Ast = Expression; - internal readonly struct FastBindResult where T : class { public readonly T Target; public readonly bool ShouldCache; diff --git a/Src/IronPython/Runtime/Binding/FastGetBase.cs b/Src/IronPython/Runtime/Binding/FastGetBase.cs index bb849308c..9ab7f96d7 100644 --- a/Src/IronPython/Runtime/Binding/FastGetBase.cs +++ b/Src/IronPython/Runtime/Binding/FastGetBase.cs @@ -5,8 +5,6 @@ using System; using System.Runtime.CompilerServices; -using Microsoft.Scripting.Utils; - using IronPython.Runtime.Types; namespace IronPython.Runtime.Binding { diff --git a/Src/IronPython/Runtime/Binding/FastSetBase.cs b/Src/IronPython/Runtime/Binding/FastSetBase.cs index 4d0b3352b..d553eadb2 100644 --- a/Src/IronPython/Runtime/Binding/FastSetBase.cs +++ b/Src/IronPython/Runtime/Binding/FastSetBase.cs @@ -4,7 +4,6 @@ using System; using System.Runtime.CompilerServices; -using Microsoft.Scripting.Utils; namespace IronPython.Runtime.Binding { internal class FastSetBase { diff --git a/Src/IronPython/Runtime/Binding/IComConvertible.cs b/Src/IronPython/Runtime/Binding/IComConvertible.cs index 4fdb80c4a..a588d408f 100644 --- a/Src/IronPython/Runtime/Binding/IComConvertible.cs +++ b/Src/IronPython/Runtime/Binding/IComConvertible.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Collections.Generic; using System.Dynamic; -using System.Text; namespace IronPython.Runtime.Binding { /// diff --git a/Src/IronPython/Runtime/Binding/IFastGettable.cs b/Src/IronPython/Runtime/Binding/IFastGettable.cs index fc728450c..b1b457d8e 100644 --- a/Src/IronPython/Runtime/Binding/IFastGettable.cs +++ b/Src/IronPython/Runtime/Binding/IFastGettable.cs @@ -2,13 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - -using System; -using System.Dynamic; - -using Microsoft.Scripting.Actions; - using System.Runtime.CompilerServices; namespace IronPython.Runtime.Binding { diff --git a/Src/IronPython/Runtime/Binding/IFastInvokable.cs b/Src/IronPython/Runtime/Binding/IFastInvokable.cs index e0bf05d73..d4aa4a78f 100644 --- a/Src/IronPython/Runtime/Binding/IFastInvokable.cs +++ b/Src/IronPython/Runtime/Binding/IFastInvokable.cs @@ -2,12 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - -using System; -using System.Dynamic; using System.Runtime.CompilerServices; -using Microsoft.Scripting.Actions; namespace IronPython.Runtime.Binding { internal interface IFastInvokable { diff --git a/Src/IronPython/Runtime/Binding/IFastSettable.cs b/Src/IronPython/Runtime/Binding/IFastSettable.cs index dcfe19c99..2b5abe432 100644 --- a/Src/IronPython/Runtime/Binding/IFastSettable.cs +++ b/Src/IronPython/Runtime/Binding/IFastSettable.cs @@ -2,14 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - -using System; -using System.Dynamic; - -using Microsoft.Scripting.Actions; - -using Microsoft.Scripting.Runtime; using System.Runtime.CompilerServices; namespace IronPython.Runtime.Binding { diff --git a/Src/IronPython/Runtime/Binding/IPythonConvertible.cs b/Src/IronPython/Runtime/Binding/IPythonConvertible.cs index ceb0e3edc..e4534eb16 100644 --- a/Src/IronPython/Runtime/Binding/IPythonConvertible.cs +++ b/Src/IronPython/Runtime/Binding/IPythonConvertible.cs @@ -2,11 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - -using System; using System.Dynamic; -using Microsoft.Scripting.Actions; namespace IronPython.Runtime.Binding { internal interface IPythonConvertible { diff --git a/Src/IronPython/Runtime/Binding/IPythonGetable.cs b/Src/IronPython/Runtime/Binding/IPythonGetable.cs index 468dbc2fe..02c6fbdc1 100644 --- a/Src/IronPython/Runtime/Binding/IPythonGetable.cs +++ b/Src/IronPython/Runtime/Binding/IPythonGetable.cs @@ -2,9 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - -using System; using System.Dynamic; namespace IronPython.Runtime.Binding { diff --git a/Src/IronPython/Runtime/Binding/IPythonInvokable.cs b/Src/IronPython/Runtime/Binding/IPythonInvokable.cs index 217e75fe9..58f0fa455 100644 --- a/Src/IronPython/Runtime/Binding/IPythonInvokable.cs +++ b/Src/IronPython/Runtime/Binding/IPythonInvokable.cs @@ -2,10 +2,8 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - -using System; using System.Dynamic; +using System.Linq.Expressions; namespace IronPython.Runtime.Binding { /// diff --git a/Src/IronPython/Runtime/Binding/IPythonOperable.cs b/Src/IronPython/Runtime/Binding/IPythonOperable.cs index e17eebd91..2dfba352d 100644 --- a/Src/IronPython/Runtime/Binding/IPythonOperable.cs +++ b/Src/IronPython/Runtime/Binding/IPythonOperable.cs @@ -2,9 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Collections.Generic; -using System.Text; using System.Dynamic; namespace IronPython.Runtime.Binding { diff --git a/Src/IronPython/Runtime/Binding/IPythonSite.cs b/Src/IronPython/Runtime/Binding/IPythonSite.cs index d1aa81cd0..72164159d 100644 --- a/Src/IronPython/Runtime/Binding/IPythonSite.cs +++ b/Src/IronPython/Runtime/Binding/IPythonSite.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace IronPython.Runtime.Binding { +namespace IronPython.Runtime.Binding { internal interface IPythonSite { /// /// Gets the PythonContext which the CallSiteBinder is associated with. diff --git a/Src/IronPython/Runtime/Binding/MetaBuiltinFunction.cs b/Src/IronPython/Runtime/Binding/MetaBuiltinFunction.cs index fb0c4846d..0b736e6af 100644 --- a/Src/IronPython/Runtime/Binding/MetaBuiltinFunction.cs +++ b/Src/IronPython/Runtime/Binding/MetaBuiltinFunction.cs @@ -2,13 +2,13 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; -using System.Collections; -using System.Reflection; -using System.Runtime.CompilerServices; using System.Dynamic; +using System.Linq.Expressions; +using System.Runtime.CompilerServices; + +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; using Microsoft.Scripting; using Microsoft.Scripting.Actions; @@ -17,9 +17,6 @@ using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -124,9 +121,9 @@ DynamicMetaObject IPythonOperable.BindOperation(PythonOperationBinder action, Dy newArgs, BindingHelpers.GetCallSignature(call), codeContext - ), - Value.Targets, - selfRestrict, + ), + Value.Targets, + selfRestrict, Value.Name, PythonNarrowing.None, Value.IsBinaryOperator ? PythonNarrowing.BinaryOperator : NarrowingLevel.All, @@ -161,48 +158,48 @@ out target ); DynamicMetaObject self = GetInstance(instance, CompilerHelpers.GetType(Value.BindingSelf)); - return Value.MakeBuiltinFunctionCall( - call, - codeContext, - this, - ArrayUtils.Insert(self, args), - true, // has self - selfRestrict, - (newArgs) => { - CallSignature signature = BindingHelpers.GetCallSignature(call); - PythonContext state = PythonContext.GetPythonContext(call); - BindingTarget target; - PythonOverloadResolver resolver; - if (Value.IsReversedOperator) { - resolver = new PythonOverloadResolver( - state.Binder, - newArgs, - GetReversedSignature(signature), - codeContext - ); - } else { - resolver = new PythonOverloadResolver( - state.Binder, - self, - args, - signature, - codeContext - ); - } - - DynamicMetaObject res = state.Binder.CallMethod( - resolver, - Value.Targets, - self.Restrictions, - Value.Name, - NarrowingLevel.None, - Value.IsBinaryOperator ? PythonNarrowing.BinaryOperator : NarrowingLevel.All, - out target + return Value.MakeBuiltinFunctionCall( + call, + codeContext, + this, + ArrayUtils.Insert(self, args), + true, // has self + selfRestrict, + (newArgs) => { + CallSignature signature = BindingHelpers.GetCallSignature(call); + PythonContext state = PythonContext.GetPythonContext(call); + BindingTarget target; + PythonOverloadResolver resolver; + if (Value.IsReversedOperator) { + resolver = new PythonOverloadResolver( + state.Binder, + newArgs, + GetReversedSignature(signature), + codeContext + ); + } else { + resolver = new PythonOverloadResolver( + state.Binder, + self, + args, + signature, + codeContext ); - - return BindingHelpers.CheckLightThrow(call, res, target); } - ); + + DynamicMetaObject res = state.Binder.CallMethod( + resolver, + Value.Targets, + self.Restrictions, + Value.Name, + NarrowingLevel.None, + Value.IsBinaryOperator ? PythonNarrowing.BinaryOperator : NarrowingLevel.All, + out target + ); + + return BindingHelpers.CheckLightThrow(call, res, target); + } + ); } private DynamicMetaObject/*!*/ GetInstance(Expression/*!*/ instance, Type/*!*/ testType) { diff --git a/Src/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs b/Src/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs index 10713fbae..528dfb0a2 100644 --- a/Src/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs +++ b/Src/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs @@ -2,19 +2,17 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Dynamic; using System.Linq.Expressions; -using System; -using System.Dynamic; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Actions.Calls; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -93,7 +91,7 @@ out target ); return BindingHelpers.CheckLightThrow(call, res, target); - }); + }); } internal Expression MakeFunctionTest(Expression functionTarget) { diff --git a/Src/IronPython/Runtime/Binding/MetaPythonFunction.cs b/Src/IronPython/Runtime/Binding/MetaPythonFunction.cs index cd492f595..93ba70899 100644 --- a/Src/IronPython/Runtime/Binding/MetaPythonFunction.cs +++ b/Src/IronPython/Runtime/Binding/MetaPythonFunction.cs @@ -2,14 +2,15 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; -using System.Reflection; using System.Dynamic; +using System.Linq.Expressions; +using System.Reflection; + +using IronPython.Runtime.Operations; using Microsoft.Scripting; using Microsoft.Scripting.Actions; @@ -17,9 +18,6 @@ using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -218,7 +216,7 @@ public override DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder) { Expression.Convert(Expression, typeof(PythonFunction)) ), BindingRestrictions.GetTypeRestriction(Expression, typeof(PythonFunction)) - ); + ); } // first get the default binder value @@ -346,9 +344,9 @@ public FunctionBinderHelper(DynamicMetaObjectBinder/*!*/ call, MetaPythonFunctio } return BindingHelpers.AddDynamicTestAndDefer( - _call, - res, - deferArgs, + _call, + res, + deferArgs, new ValidationInfo(_deferTest), res.Expression.Type // force defer to our return type, our restrictions guarantee this to be true (only defaults can change, and we restrict to the delegate type) ); @@ -891,7 +889,7 @@ private static Expression VariableOrNull(ParameterExpression var, Type type) { Type target = _func.Value.__code__.Target.GetType(); if (target == typeof(Func)) { exprArgs = new Expression[] { - AstUtils.NewArrayHelper(typeof(object), exprArgs) + AstUtils.NewArrayHelper(typeof(object), exprArgs) }; } @@ -913,7 +911,7 @@ private static Expression VariableOrNull(ParameterExpression var, Type type) { Debug.Assert(_dict == null); userDict = userDict.Restrict(userDict.GetLimitType()); - _temps.Add(_dict = Ast.Variable(typeof(PythonDictionary), "$dict")); + _temps.Add(_dict = Ast.Variable(typeof(PythonDictionary), "$dict")); EnsureInit(); @@ -1037,7 +1035,7 @@ private Expression MakeDictionary(Dictionary namedArgs) // If calling generator, create the instance of PythonGenerator first // and add it into the list of arguments invokeArgs = ArrayUtils.Insert(GetFunctionParam(), invokeArgs); - + Expression invoke = AstUtils.SimpleCallHelper( Ast.Convert( Ast.Call( @@ -1085,7 +1083,7 @@ private void MakeUnexpectedKeywordError(Dictionary namedArgs ), typeof(PythonOps) ); - } + } private void EnsureInit() { if (_init == null) _init = new List(); diff --git a/Src/IronPython/Runtime/Binding/MetaPythonObject.cs b/Src/IronPython/Runtime/Binding/MetaPythonObject.cs index 3b0631a5c..04f3a40e1 100644 --- a/Src/IronPython/Runtime/Binding/MetaPythonObject.cs +++ b/Src/IronPython/Runtime/Binding/MetaPythonObject.cs @@ -2,16 +2,16 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; using System.Diagnostics; using System.Dynamic; -using Microsoft.Scripting.Actions; +using System.Linq.Expressions; + +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + using Microsoft.Scripting.Ast; using Microsoft.Scripting.Runtime; -using IronPython.Runtime.Types; -using IronPython.Runtime.Operations; namespace IronPython.Runtime.Binding { using Ast = Expression; @@ -37,7 +37,7 @@ public MetaPythonObject(Expression/*!*/ expression, BindingRestrictions/*!*/ res internal static MethodCallExpression MakeTryGetTypeMember(PythonContext/*!*/ PythonContext, PythonTypeSlot dts, Expression self, ParameterExpression tmp) { return MakeTryGetTypeMember( PythonContext, - dts, + dts, tmp, self, Ast.Property( @@ -100,7 +100,7 @@ public PythonType/*!*/ PythonType { PythonContext state = PythonContext.GetPythonContext(action); CodeContext context = state != null ? state.SharedContext : DefaultContext.Default; - + return new DynamicMetaObject( Ast.Convert( Ast.Call( diff --git a/Src/IronPython/Runtime/Binding/MetaPythonType.Calls.cs b/Src/IronPython/Runtime/Binding/MetaPythonType.Calls.cs index c61c530fa..b69221da4 100644 --- a/Src/IronPython/Runtime/Binding/MetaPythonType.Calls.cs +++ b/Src/IronPython/Runtime/Binding/MetaPythonType.Calls.cs @@ -2,24 +2,22 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; using System.Collections.Generic; using System.Diagnostics; using System.Dynamic; +using System.Linq.Expressions; using System.Reflection; +using IronPython.Runtime.Exceptions; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + using Microsoft.Scripting; using Microsoft.Scripting.Actions; -using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Exceptions; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -42,7 +40,7 @@ internal partial class MetaPythonType : MetaPythonObject, IPythonInvokable { #region MetaObject Overrides public override DynamicMetaObject/*!*/ BindInvokeMember(InvokeMemberBinder/*!*/ action, DynamicMetaObject/*!*/[]/*!*/ args) { - + foreach (PythonType pt in Value.ResolutionOrder) { if (pt.IsSystemType) { return action.FallbackInvokeMember(this, args); @@ -110,7 +108,7 @@ internal partial class MetaPythonType : MetaPythonObject, IPythonInvokable { string msg; if (Value.UnderlyingSystemType.IsAbstract) { msg = String.Format("Cannot create instances of {0} because it is abstract", Value.Name); - }else{ + } else { msg = String.Format("Cannot create instances of {0} because it has no public constructors", Value.Name); } return new DynamicMetaObject( @@ -158,16 +156,16 @@ internal partial class MetaPythonType : MetaPythonObject, IPythonInvokable { GetAdapters(ai, call, codeContext, out newAdapter, out initAdapter); PythonContext state = PythonContext.GetPythonContext(call); - + // get the expression for calling __new__ DynamicMetaObject createExpr = newAdapter.GetExpression(state.Binder); if (createExpr.Expression.Type == typeof(void)) { return BindingHelpers.AddDynamicTestAndDefer( call, createExpr, - args, + args, valInfo - ); + ); } Expression res; @@ -252,7 +250,7 @@ internal partial class MetaPythonType : MetaPythonObject, IPythonInvokable { valInfo ); } - + #endregion #region Adapter support @@ -427,16 +425,16 @@ public ConstructorNewAdapter(ArgumentValues/*!*/ ai, PythonType/*!*/ creating, P if (_creating.IsSystemType || _creating.HasSystemCtor) { resolve = new PythonOverloadResolver( - binder, - Arguments.Arguments, - Arguments.Signature, + binder, + Arguments.Arguments, + Arguments.Signature, CodeContext ); } else { resolve = new PythonOverloadResolver( - binder, - ArrayUtils.Insert(Arguments.Self, Arguments.Arguments), - GetDynamicNewSignature(), + binder, + ArrayUtils.Insert(Arguments.Self, Arguments.Arguments), + GetDynamicNewSignature(), CodeContext ); } @@ -500,13 +498,13 @@ protected InitAdapter(ArgumentValues/*!*/ ai, PythonContext/*!*/ state, Expressi args.ToArray() ), Arguments.Self.Restrictions.Merge(createExpr.Restrictions) - ); + ); } } private class SlotInitAdapter : InitAdapter { private readonly PythonTypeSlot/*!*/ _slot; - + public SlotInitAdapter(PythonTypeSlot/*!*/ slot, ArgumentValues/*!*/ ai, PythonContext/*!*/ state, Expression/*!*/ codeContext) : base(ai, state, codeContext) { _slot = slot; @@ -592,8 +590,8 @@ public BuiltinInitAdapter(ArgumentValues/*!*/ ai, BuiltinFunction/*!*/ method, P ) ), GetErrorRestrictions(ai) - ), - ai.Arguments, + ), + ai.Arguments, valInfo ); } @@ -657,7 +655,7 @@ public BuiltinInitAdapter(ArgumentValues/*!*/ ai, BuiltinFunction/*!*/ method, P private static BindingRestrictions GetInstanceRestriction(ArgumentValues ai) { return BindingRestrictions.GetInstanceRestriction(ai.Self.Expression, ai.Self.Value); } - + private bool HasFinalizer(DynamicMetaObjectBinder/*!*/ action) { // only user types have finalizers... if (Value.IsSystemType) return false; @@ -692,7 +690,7 @@ private bool TooManyArgsForDefaultNew(DynamicMetaObjectBinder/*!*/ action, Dynam for (int i = 0; i < infos.Length; i++) { Argument curArg = infos[i]; - switch(curArg.Kind) { + switch (curArg.Kind) { case ArgumentType.List: // Deferral? if (((IList)args[i].Value).Count > 0) { @@ -707,7 +705,7 @@ private bool TooManyArgsForDefaultNew(DynamicMetaObjectBinder/*!*/ action, Dynam break; default: return true; - } + } } } return false; @@ -737,7 +735,7 @@ private bool IsStandardDotNetType(DynamicMetaObjectBinder/*!*/ action) { !Value.IsPythonType && !bState.Binder.HasExtensionTypes(Value.UnderlyingSystemType) && !typeof(Delegate).IsAssignableFrom(Value.UnderlyingSystemType) && - !Value.UnderlyingSystemType.IsArray; + !Value.UnderlyingSystemType.IsArray; } #endregion diff --git a/Src/IronPython/Runtime/Binding/MetaPythonType.Members.cs b/Src/IronPython/Runtime/Binding/MetaPythonType.Members.cs index c88ee5363..e3d5e364f 100644 --- a/Src/IronPython/Runtime/Binding/MetaPythonType.Members.cs +++ b/Src/IronPython/Runtime/Binding/MetaPythonType.Members.cs @@ -3,24 +3,22 @@ // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; using System.Collections.Generic; using System.Diagnostics; using System.Dynamic; +using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Threading; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; namespace IronPython.Runtime.Binding { using Ast = Expression; @@ -224,7 +222,7 @@ public TResult MakeTypeGetMember() { if (!isFinal) { // the member doesn't exist anywhere in the type hierarchy, see if // we define __getattr__ on our meta type. - if (metaType.TryResolveSlot(_context, "__getattr__", out pts) && + if (metaType.TryResolveSlot(_context, "__getattr__", out pts) && !pts.IsSetDescriptor(lookupContext, metaType)) { // we tried get/set descriptors initially AddMetaGetAttribute(metaType, pts); @@ -273,7 +271,7 @@ public MetaGetBinderHelper(MetaPythonType type, DynamicMetaObjectBinder member, _state = PythonContext.GetPythonContext(member); _valInfo = validationInfo; _metaValInfo = metaValidation; - } + } private void EnsureTmp() { if (_tmp == null) { diff --git a/Src/IronPython/Runtime/Binding/MetaPythonType.cs b/Src/IronPython/Runtime/Binding/MetaPythonType.cs index 816704566..90cd7e469 100644 --- a/Src/IronPython/Runtime/Binding/MetaPythonType.cs +++ b/Src/IronPython/Runtime/Binding/MetaPythonType.cs @@ -2,20 +2,16 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; -using System.Collections.Generic; using System.Dynamic; +using System.Linq.Expressions; + +using IronPython.Runtime.Types; -using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Types; - namespace IronPython.Runtime.Binding { - using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; internal partial class MetaPythonType : MetaPythonObject, IPythonConvertible { diff --git a/Src/IronPython/Runtime/Binding/MetaUserObject.Members.cs b/Src/IronPython/Runtime/Binding/MetaUserObject.Members.cs index d7a1a1f12..452a87ea3 100644 --- a/Src/IronPython/Runtime/Binding/MetaUserObject.Members.cs +++ b/Src/IronPython/Runtime/Binding/MetaUserObject.Members.cs @@ -2,13 +2,18 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; +using System.Collections.Generic; using System.Diagnostics; using System.Dynamic; +using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; +using System.Threading; + +using IronPython.Runtime.Exceptions; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; using Microsoft.Scripting; using Microsoft.Scripting.Actions; @@ -16,13 +21,6 @@ using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Exceptions; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - -using System.Threading; -using System.Collections.Generic; - namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -32,7 +30,7 @@ internal partial class MetaUserObject : MetaPythonObject, IPythonGetable { public DynamicMetaObject GetMember(PythonGetMemberBinder/*!*/ member, DynamicMetaObject/*!*/ codeContext) { return GetMemberWorker(member, codeContext); - } + } #endregion @@ -133,7 +131,7 @@ public TResult Bind(CodeContext context, string name) { protected abstract TResult BindGetAttribute(PythonTypeSlot foundSlot); protected abstract TResult FinishRule(); protected abstract void MakeDictionaryAccess(); - + public IPythonObject Value { get { return _value; @@ -222,7 +220,7 @@ public MetaGetBinderHelper(MetaUserObject target, DynamicMetaObjectBinder binder info.Validation ); } - + protected abstract DynamicMetaObject FallbackError(); protected abstract DynamicMetaObject Fallback(); @@ -333,7 +331,7 @@ protected override void MakeSlotAccess(PythonTypeSlot foundSlot, bool systemType MakeSlotAccess(foundSlot); } } - + private void MakeSlotAccess(PythonTypeSlot dts) { if (dts is ReflectedSlotProperty rsp) { // we need to fall back to __getattr__ if the value is not defined, so call it and check the result. @@ -488,7 +486,7 @@ public Expression Expression { get { return _target.Expression; } - } + } } internal class FastGetBinderHelper : GetOrInvokeBinderHelper { @@ -526,12 +524,12 @@ protected override void MakeSlotAccess(PythonTypeSlot foundSlot, bool systemType } _slot = foundSlot; } - + public FastBindResult> GetBinding(CodeContext context, string name) { var cachedGets = GetCachedGets(); var key = CachedGetKey.Make(name, context.ModuleContext.ExtensionMethods); FastGetBase dlg; - lock (cachedGets) { + lock (cachedGets) { if (!cachedGets.TryGetValue(key, out dlg) || !dlg.IsValid(Value.PythonType)) { var binding = Bind(context, name); if (binding != null) { @@ -599,7 +597,7 @@ protected override FastGetBase FinishRule() { private Func FallbackError() { Type finalType = Value.PythonType.FinalSystemType; - if (typeof(IDynamicMetaObjectProvider).IsAssignableFrom(finalType)) { + if (typeof(IDynamicMetaObjectProvider).IsAssignableFrom(finalType)) { return ((IFastGettable)Value).MakeGetBinding(_site, _binder, _context, _binder.Name); } @@ -621,9 +619,9 @@ protected override FastGetBase BindGetAttribute(PythonTypeSlot foundSlot) { Debug.Assert(Value is IFastGettable); PythonTypeSlot baseSlot; - if (TryGetGetAttribute(_context, DynamicHelpers.GetPythonTypeFromType(finalType), out baseSlot) && + if (TryGetGetAttribute(_context, DynamicHelpers.GetPythonTypeFromType(finalType), out baseSlot) && baseSlot == foundSlot) { - + return new ChainedUserGet(_binder, _version, FallbackError()); } } @@ -705,7 +703,7 @@ private static bool TryGetGetAttribute(CodeContext/*!*/ context, PythonType/*!*/ } return false; } - + private static MethodCallExpression/*!*/ MakeGetAttrTestAndGet(GetBindingInfo/*!*/ info, Expression/*!*/ getattr) { return Ast.Call( PythonTypeInfo._PythonOps.SlotTryGetBoundValue, @@ -723,8 +721,8 @@ private static bool TryGetGetAttribute(CodeContext/*!*/ context, PythonType/*!*/ ), info.Result ); - } - + } + private static Expression/*!*/ GetWeakSlot(PythonTypeSlot slot) { return AstUtils.Convert(AstUtils.WeakConstant(slot), typeof(PythonTypeSlot)); } @@ -757,7 +755,7 @@ public SetBinderHelper(CodeContext/*!*/ context, IPythonObject/*!*/ instance, ob _context = context; } - public TResult Bind(string name) { + public TResult Bind(string name) { bool bound = false; // call __setattr__ if it exists @@ -809,7 +807,7 @@ public object Value { } protected abstract TResult Finish(); - + protected abstract void MakeSetAttrTarget(PythonTypeSlot dts); protected abstract void MakeSlotsSetTarget(ReflectedSlotProperty prop); protected abstract void MakeSlotSetOrFallback(PythonTypeSlot dts, bool systemTypeResolution); @@ -837,13 +835,13 @@ protected override SetMemberDelegates Finish() { return new SetMemberDelegates(_context, Instance.PythonType, OptimizedSetKind.SetAttr, _binder.Name, _version, _setattrSlot, null); } else if (_slotProp != null) { return new SetMemberDelegates(_context, Instance.PythonType, OptimizedSetKind.UserSlot, _binder.Name, _version, null, _slotProp.Setter); - } else if(_dictSet) { + } else if (_dictSet) { return new SetMemberDelegates(_context, Instance.PythonType, OptimizedSetKind.SetDict, _binder.Name, _version, null, null); } else { return new SetMemberDelegates(_context, Instance.PythonType, OptimizedSetKind.Error, _binder.Name, _version, null, null); - } + } } - + public FastBindResult> MakeSet() { var cachedSets = GetCachedSets(); @@ -955,14 +953,14 @@ protected override void MakeSetAttrTarget(PythonTypeSlot dts) { protected override DynamicMetaObject Finish() { PerfTrack.NoteEvent(PerfTrack.Categories.Binding, _resolution); PerfTrack.NoteEvent(PerfTrack.Categories.BindingTarget, "UserSet"); - + Debug.Assert(_result != null); _result = new DynamicMetaObject( _result.Expression, _target.Restrict(Instance.GetType()).Restrictions.Merge(_result.Restrictions) ); - + Debug.Assert(!_result.Expression.Type.IsValueType); return BindingHelpers.AddDynamicTestAndDefer( @@ -1047,7 +1045,7 @@ protected override void MakeSlotSetOrFallback(PythonTypeSlot dts, bool systemTyp _result = MakeSlotSet(_info, dts); } } - + protected override void MakeSlotsSetTarget(ReflectedSlotProperty prop) { _resolution += "Slot "; MakeSlotsSetTargetHelper(_info, prop, _value.Expression); @@ -1214,7 +1212,7 @@ private static DynamicMetaObject MakeSlotSet(SetBindingInfo/*!*/ info, PythonTyp if (dts is ReflectedSlotProperty rsp) { MakeSlotsDeleteTarget(info, rsp); } - + if (!info.Body.IsFinal && dts != null) { MakeSlotDelete(info, dts); } @@ -1268,7 +1266,7 @@ private static DynamicMetaObject MakeSlotDelete(DeleteBindingInfo/*!*/ info, Pyt Ast.NotEqual( tmpDeleter, AstUtils.Constant(null) - ), + ), Ast.Dynamic( PythonContext.GetPythonContext(info.Action).InvokeOne, typeof(object), diff --git a/Src/IronPython/Runtime/Binding/MetaUserObject.cs b/Src/IronPython/Runtime/Binding/MetaUserObject.cs index 74b94eb48..542649d73 100644 --- a/Src/IronPython/Runtime/Binding/MetaUserObject.cs +++ b/Src/IronPython/Runtime/Binding/MetaUserObject.cs @@ -2,22 +2,20 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; -using System.Numerics; - using System; using System.Collections; -using System.Collections.Generic; using System.Dynamic; +using System.Linq.Expressions; +using System.Numerics; + +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -84,7 +82,7 @@ public DynamicMetaObject ConvertWorker(DynamicMetaObjectBinder binder, Type type public override DynamicMetaObject/*!*/ BindDeleteIndex(DeleteIndexBinder/*!*/ binder, DynamicMetaObject/*!*/[]/*!*/ indexes) { return PythonProtocol.Index(binder, PythonIndexType.DeleteItem, ArrayUtils.Insert(this, indexes)); - } + } public override DynamicMetaObject/*!*/ BindInvoke(InvokeBinder/*!*/ action, DynamicMetaObject/*!*/[]/*!*/ args) { Expression context = Ast.Call( @@ -96,8 +94,8 @@ public DynamicMetaObject ConvertWorker(DynamicMetaObjectBinder binder, Type type ); return InvokeWorker( - action, - context, + action, + context, args ); } @@ -125,7 +123,7 @@ public override System.Collections.Generic.IEnumerable GetDynamicMemberN if (Value.PythonType.TryResolveSlot(context.SharedContext, "__call__", out callSlot) && TypeCache.PythonType.TryResolveSlot(context.SharedContext, "__call__", out typeCallSlot) && callSlot == typeCallSlot) { - + return InvokeFallback(action, codeContext, args); } } @@ -185,7 +183,7 @@ private DynamicMetaObject TryPythonConversion(DynamicMetaObjectBinder conversion } } else if (type == typeof(IEnumerable)) { return PythonConversionBinder.ConvertToIEnumerable(conversion, Restrict(Value.GetType())); - } else if (type == typeof(IEnumerator)){ + } else if (type == typeof(IEnumerator)) { return PythonConversionBinder.ConvertToIEnumerator(conversion, Restrict(Value.GetType())); } else if (type.IsSubclassOf(typeof(Delegate))) { return MakeDelegateTarget(conversion, type, Restrict(Value.GetType())); @@ -364,14 +362,14 @@ private static bool IsBuiltinConversion(CodeContext/*!*/ context, PythonTypeSlot db.MakeConversionError( convertToAction.Type, self.Expression - ), + ), typeof(object) ); default: throw new InvalidOperationException(convertToAction.ResultKind.ToString()); } } - + /// /// Helper for falling back - if we have a base object fallback to it first (which can /// then fallback to the calling site), otherwise fallback to the calling site. diff --git a/Src/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs b/Src/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs index bae68d0f9..c7fc38419 100644 --- a/Src/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs +++ b/Src/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs @@ -2,25 +2,22 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; -using Microsoft.Scripting.Ast; - using System; using System.Dynamic; -using System.Reflection; +using System.Linq.Expressions; using System.Runtime.CompilerServices; +using IronPython.Runtime.Operations; + using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - namespace IronPython.Runtime.Binding { + using Microsoft.Scripting.Actions; + using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; - using Microsoft.Scripting.Actions; internal class PythonBinaryOperationBinder : BinaryOperationBinder, IPythonSite, IExpressionSerializable, ILightExceptionBinder { private readonly PythonContext/*!*/ _context; @@ -30,7 +27,7 @@ public PythonBinaryOperationBinder(PythonContext/*!*/ context, ExpressionType op : base(operation) { _context = context; } - + public override DynamicMetaObject FallbackBinaryOperation(DynamicMetaObject target, DynamicMetaObject arg, DynamicMetaObject errorSuggestion) { return PythonProtocol.Operation(this, target, arg, errorSuggestion); } @@ -75,7 +72,7 @@ public override T BindDelegate(CallSite site, object[] args) { return BindModulo(site, args); } } else { - switch(Operation) { + switch (Operation) { case ExpressionType.Modulo: return BindModulo(site, args); case ExpressionType.Multiply: @@ -275,7 +272,7 @@ private T BindAdd(CallSite site, object[] args) where T : class { } else if (!t.IsEnum) { switch (t.GetTypeCode()) { case TypeCode.Double: - if(typeof(T) == typeof(Func)) { + if (typeof(T) == typeof(Func)) { return (T)(object)new Func(DoubleAdd); } break; @@ -395,7 +392,7 @@ private object StringModulo(CallSite site, object self, object other) { } private object DoubleAdd(CallSite site, object self, object other) { - if (self != null && self.GetType() == typeof(double) && + if (self != null && self.GetType() == typeof(double) && other != null && other.GetType() == typeof(double)) { return (double)self + (double)other; } @@ -404,7 +401,7 @@ private object DoubleAdd(CallSite site, object self, object other) { } private object IntAdd(CallSite site, object self, object other) { - if (self != null && self.GetType() == typeof(int) && + if (self != null && self.GetType() == typeof(int) && other != null && other.GetType() == typeof(int)) { return Int32Ops.Add((int)self, (int)other); } @@ -583,7 +580,7 @@ private object TupleAdd(CallSite site, object self, object other) { } private object StringAdd(CallSite site, object self, object other) { - if (self != null && self.GetType() == typeof(string) && + if (self != null && self.GetType() == typeof(string) && other != null && other.GetType() == typeof(string)) { return StringOps.Add((string)self, (string)other); } @@ -592,7 +589,7 @@ private object StringAdd(CallSite site, object self, object other) { } private object StringAdd(CallSite site, string self, object other) { - if (self != null && + if (self != null && other != null && other.GetType() == typeof(string)) { return StringOps.Add(self, (string)other); } @@ -608,7 +605,7 @@ private object StringAdd(CallSite site, object self, string other) { return ((CallSite>)site).Update(site, self, other); } - + private object DoubleSubtract(CallSite site, object self, object other) { if (self != null && self.GetType() == typeof(double) && other != null && other.GetType() == typeof(double)) { @@ -687,7 +684,7 @@ private object StringEqual(CallSite site, object self, string other) { return ((CallSite>)site).Update(site, self, other); } - + private object DoubleNotEqual(CallSite site, object self, object other) { if (self != null && self.GetType() == typeof(double) && other != null && other.GetType() == typeof(double)) { diff --git a/Src/IronPython/Runtime/Binding/PythonBinder.Create.cs b/Src/IronPython/Runtime/Binding/PythonBinder.Create.cs index c94067050..5b4974cd5 100644 --- a/Src/IronPython/Runtime/Binding/PythonBinder.Create.cs +++ b/Src/IronPython/Runtime/Binding/PythonBinder.Create.cs @@ -2,17 +2,15 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; using System.Dynamic; +using System.Linq.Expressions; using System.Reflection; -using Microsoft.Scripting.Actions; -using Microsoft.Scripting.Generation; -using Microsoft.Scripting.Utils; using IronPython.Runtime.Operations; +using Microsoft.Scripting.Actions; + using AstUtils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Runtime.Binding { diff --git a/Src/IronPython/Runtime/Binding/PythonBinder.cs b/Src/IronPython/Runtime/Binding/PythonBinder.cs index 50ae3404b..9db715591 100644 --- a/Src/IronPython/Runtime/Binding/PythonBinder.cs +++ b/Src/IronPython/Runtime/Binding/PythonBinder.cs @@ -2,18 +2,21 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; -using System.Numerics; - using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Dynamic; using System.Linq; +using System.Linq.Expressions; +using System.Numerics; using System.Reflection; using System.Threading; +using IronPython.Runtime.Exceptions; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Actions.Calls; @@ -21,10 +24,6 @@ using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Exceptions; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -43,7 +42,7 @@ public PythonBinder(PythonContext/*!*/ pythonContext, CodeContext context) { ContractUtils.RequiresNotNull(pythonContext, nameof(pythonContext)); _dlrExtensionTypes = MakeExtensionTypes(); - _context = pythonContext; + _context = pythonContext; if (context != null) { context.LanguageContext.DomainManager.AssemblyLoaded += new EventHandler(DomainManager_AssemblyLoaded); @@ -82,7 +81,7 @@ public PythonBinder(PythonBinder binder) { } return expr; } - + Type visType = Context.Binder.PrivateBinding ? toType : CompilerHelpers.GetVisibleType(toType); if (exprType == typeof(PythonType) && visType == typeof(Type)) { @@ -185,17 +184,17 @@ public override ErrorInfo MakeSetValueTypeFieldError(FieldTracker field, Dynamic Expression.Assign( Expression.Field( AstUtils.Convert( - instance.Expression, + instance.Expression, field.DeclaringType - ), + ), field.Field ), ConvertExpression( - value.Expression, - field.FieldType, - ConversionResultKind.ExplicitCast, + value.Expression, + field.FieldType, + ConversionResultKind.ExplicitCast, new PythonOverloadResolverFactory( - this, + this, Expression.Constant(_context.SharedContext) ) ) @@ -237,7 +236,7 @@ public override ErrorInfo MakeConversionError(Type toType, Expression value) { return MakeMissingMemberError(accessingType, instance, info.Name); } - public override ErrorInfo/*!*/ MakeStaticPropertyInstanceAccessError(PropertyTracker/*!*/ tracker, bool isAssignment, IList/*!*/ parameters) { + public override ErrorInfo/*!*/ MakeStaticPropertyInstanceAccessError(PropertyTracker/*!*/ tracker, bool isAssignment, IList/*!*/ parameters) { ContractUtils.RequiresNotNull(tracker, nameof(tracker)); ContractUtils.RequiresNotNull(parameters, nameof(parameters)); @@ -281,7 +280,7 @@ public override string GetTypeName(Type t) { } - public override ErrorInfo/*!*/ MakeEventValidation(MemberGroup/*!*/ members, DynamicMetaObject eventObject, DynamicMetaObject/*!*/ value, OverloadResolverFactory/*!*/ factory) { + public override ErrorInfo/*!*/ MakeEventValidation(MemberGroup/*!*/ members, DynamicMetaObject eventObject, DynamicMetaObject/*!*/ value, OverloadResolverFactory/*!*/ factory) { EventTracker ev = (EventTracker)members[0]; return ErrorInfo.FromValueNoError( @@ -405,7 +404,7 @@ public override IList GetExtensionTypes(Type t) { return list; } - + private void AddExtensionTypes(Type t, List list) { ExtensionTypeInfo extType; if (_sysTypes.TryGetValue(t, out extType)) { @@ -461,16 +460,16 @@ private static DynamicMetaObject ReturnMemberTracker(Type type, MemberTracker me case TrackerTypes.Bound: return new DynamicMetaObject(ReturnBoundTracker((BoundMemberTracker)memberTracker, privateBinding), BindingRestrictions.Empty); case TrackerTypes.Property: - return new DynamicMetaObject(ReturnPropertyTracker((PropertyTracker)memberTracker, privateBinding), BindingRestrictions.Empty);; + return new DynamicMetaObject(ReturnPropertyTracker((PropertyTracker)memberTracker, privateBinding), BindingRestrictions.Empty); ; case TrackerTypes.Event: return new DynamicMetaObject(Ast.Call( typeof(PythonOps).GetMethod(nameof(PythonOps.MakeBoundEvent)), AstUtils.Constant(PythonTypeOps.GetReflectedEvent((EventTracker)memberTracker)), AstUtils.Constant(null), AstUtils.Constant(type) - ), BindingRestrictions.Empty);; + ), BindingRestrictions.Empty); ; case TrackerTypes.Field: - return new DynamicMetaObject(ReturnFieldTracker((FieldTracker)memberTracker), BindingRestrictions.Empty);; + return new DynamicMetaObject(ReturnFieldTracker((FieldTracker)memberTracker), BindingRestrictions.Empty); ; case TrackerTypes.MethodGroup: return new DynamicMetaObject(ReturnMethodGroup((MethodGroup)memberTracker), BindingRestrictions.Empty); ; case TrackerTypes.Constructor: @@ -589,7 +588,7 @@ public void LookupMembers(CodeContext/*!*/ context, PythonType/*!*/ type, Python if (!members.ContainsKey(rm.Name)) { members[rm.Name] = new KeyValuePair( - PythonTypeOps.GetSlot(rm.Member, rm.Name, PrivateBinding), + PythonTypeOps.GetSlot(rm.Member, rm.Name, PrivateBinding), rm.Member ); } @@ -625,7 +624,7 @@ public void ResolveMemberNames(CodeContext/*!*/ context, PythonType/*!*/ type, P if (!members.ContainsKey(rm.Name)) { members[rm.Name] = new KeyValuePair( - PythonTypeOps.GetSlot(rm.Member, rm.Name, PrivateBinding), + PythonTypeOps.GetSlot(rm.Member, rm.Name, PrivateBinding), rm.Member ); } @@ -1084,7 +1083,7 @@ private void EnsureInfo() { private class SlotCacheInfo { public SlotCacheInfo() { Members = new Dictionary>(StringComparer.Ordinal); - } + } public bool TryGetSlot(string/*!*/ name, out PythonTypeSlot slot) { Debug.Assert(name != null); diff --git a/Src/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs b/Src/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs index 9b05ba4fe..e747621f4 100644 --- a/Src/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs +++ b/Src/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs @@ -2,16 +2,15 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Dynamic; using System.Linq.Expressions; -using System; -using System.Dynamic; +using IronPython.Runtime.Operations; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using AstUtils = Microsoft.Scripting.Ast.Utils; -using IronPython.Runtime.Operations; +using AstUtils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Runtime.Binding { using Ast = Expression; @@ -25,7 +24,7 @@ public PythonDeleteIndexBinder(PythonContext/*!*/ context, int argCount) } public override DynamicMetaObject FallbackDeleteIndex(DynamicMetaObject target, DynamicMetaObject[] indexes, DynamicMetaObject errorSuggestion) { - return PythonProtocol.Index(this, PythonIndexType.DeleteItem, ArrayUtils.Insert(target, indexes),errorSuggestion); + return PythonProtocol.Index(this, PythonIndexType.DeleteItem, ArrayUtils.Insert(target, indexes), errorSuggestion); } public override int GetHashCode() { diff --git a/Src/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs b/Src/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs index 5c3ee8175..0087c4b19 100644 --- a/Src/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs +++ b/Src/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs @@ -2,16 +2,12 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - -using System; -using Microsoft.Scripting; using System.Dynamic; -using Microsoft.Scripting.Runtime; +using System.Linq.Expressions; -using IronPython.Runtime.Binding; using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; + +using Microsoft.Scripting.Runtime; namespace IronPython.Runtime.Binding { using Ast = Expression; diff --git a/Src/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs b/Src/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs index af5c43ba1..e1a1c0f89 100644 --- a/Src/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs +++ b/Src/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs @@ -2,16 +2,14 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Dynamic; using System.Linq.Expressions; -using System; -using System.Dynamic; +using IronPython.Runtime.Operations; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Operations; - namespace IronPython.Runtime.Binding { using Ast = Expression; diff --git a/Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs b/Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs index 276366231..b961bb0f3 100644 --- a/Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs +++ b/Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs @@ -5,11 +5,10 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; + using Microsoft.Scripting.Actions; using Microsoft.Scripting.Actions.Calls; using Microsoft.Scripting.Utils; -using System.Diagnostics; namespace IronPython.Runtime.Binding { internal class PythonExtensionBinder : PythonBinder { @@ -47,10 +46,10 @@ public override MemberGroup GetMember(MemberRequestKind actionKind, Type type, s } internal static bool IsApplicableExtensionMethod(Type instanceType, Type extensionMethodThisType) { - + if (extensionMethodThisType.ContainsGenericParameters) { Dictionary binding = new Dictionary(); - + if (extensionMethodThisType.IsArray) { if (instanceType.IsArray) { extensionMethodThisType = extensionMethodThisType.GetElementType(); diff --git a/Src/IronPython/Runtime/Binding/PythonGetIndexBinder.cs b/Src/IronPython/Runtime/Binding/PythonGetIndexBinder.cs index db210247c..811261fb8 100644 --- a/Src/IronPython/Runtime/Binding/PythonGetIndexBinder.cs +++ b/Src/IronPython/Runtime/Binding/PythonGetIndexBinder.cs @@ -2,18 +2,16 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; using System.Dynamic; -using System.Reflection; +using System.Linq.Expressions; using System.Runtime.CompilerServices; +using IronPython.Runtime.Operations; + +using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using Microsoft.Scripting.Generation; - -using IronPython.Runtime.Operations; namespace IronPython.Runtime.Binding { using Ast = Expression; @@ -107,7 +105,7 @@ private object TupleIndex(CallSite site, object target, object index) { if (target is PythonTuple lst && index != null && index.GetType() == typeof(int)) { return lst[(int)index]; } - + return ((CallSite>)site).Update(site, target, index); } diff --git a/Src/IronPython/Runtime/Binding/PythonGetMemberBinder.cs b/Src/IronPython/Runtime/Binding/PythonGetMemberBinder.cs index d674d83bf..3d9387a30 100644 --- a/Src/IronPython/Runtime/Binding/PythonGetMemberBinder.cs +++ b/Src/IronPython/Runtime/Binding/PythonGetMemberBinder.cs @@ -2,27 +2,26 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; -using Microsoft.Scripting.Ast; - using System; using System.Diagnostics; using System.Dynamic; +using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using System.Threading; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + using Microsoft.Scripting; using Microsoft.Scripting.Actions; +using Microsoft.Scripting.Ast; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; diff --git a/Src/IronPython/Runtime/Binding/PythonGetSliceBinder.cs b/Src/IronPython/Runtime/Binding/PythonGetSliceBinder.cs index 3cd18aaea..b6cffeee8 100644 --- a/Src/IronPython/Runtime/Binding/PythonGetSliceBinder.cs +++ b/Src/IronPython/Runtime/Binding/PythonGetSliceBinder.cs @@ -2,16 +2,14 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Dynamic; using System.Linq.Expressions; -using System; -using System.Dynamic; +using IronPython.Runtime.Operations; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Operations; - namespace IronPython.Runtime.Binding { using Ast = Expression; diff --git a/Src/IronPython/Runtime/Binding/PythonIndexType.cs b/Src/IronPython/Runtime/Binding/PythonIndexType.cs index bafaafefb..10580d390 100644 --- a/Src/IronPython/Runtime/Binding/PythonIndexType.cs +++ b/Src/IronPython/Runtime/Binding/PythonIndexType.cs @@ -2,10 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Collections.Generic; -using System.Text; - namespace IronPython.Runtime.Binding { internal enum PythonIndexType { GetItem, diff --git a/Src/IronPython/Runtime/Binding/PythonInvokeBinder.cs b/Src/IronPython/Runtime/Binding/PythonInvokeBinder.cs index 72cd330c3..9967b3dc8 100644 --- a/Src/IronPython/Runtime/Binding/PythonInvokeBinder.cs +++ b/Src/IronPython/Runtime/Binding/PythonInvokeBinder.cs @@ -2,23 +2,21 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; -using Microsoft.Scripting.Ast; - using System; using System.Collections.Generic; using System.Diagnostics; using System.Dynamic; +using System.Linq.Expressions; using System.Runtime.CompilerServices; +using IronPython.Runtime.Operations; + using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Operations; - using AstUtils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Runtime.Binding { @@ -260,7 +258,7 @@ private void TranslateArguments(DynamicMetaObject target, DynamicMetaObject/*!*/ throw new InvalidOperationException(); } } - + callInfo = new CallInfo(metaArgs.Count - 1, namedArgNames.ToArray()); test = splatArgTest; @@ -297,7 +295,7 @@ public virtual bool SupportsLightThrow { get { return false; } } - public virtual CallSiteBinder GetLightExceptionBinder() { + public virtual CallSiteBinder GetLightExceptionBinder() { if (_lightThrowBinder == null) { _lightThrowBinder = new LightThrowBinder(_context, _signature); } diff --git a/Src/IronPython/Runtime/Binding/PythonOperationBinder.cs b/Src/IronPython/Runtime/Binding/PythonOperationBinder.cs index 6f5b01b1e..13911421d 100644 --- a/Src/IronPython/Runtime/Binding/PythonOperationBinder.cs +++ b/Src/IronPython/Runtime/Binding/PythonOperationBinder.cs @@ -2,21 +2,20 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; using System.Collections; using System.Collections.Generic; using System.Dynamic; +using System.Linq.Expressions; using System.Runtime.CompilerServices; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using AstUtils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Runtime.Binding { @@ -43,7 +42,7 @@ public override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObje } public override T BindDelegate(CallSite site, object[] args) { - switch(_operation) { + switch (_operation) { case PythonOperationKind.Hash: if (CompilerHelpers.GetType(args[0]) == typeof(PythonType)) { if (typeof(T) == typeof(Func)) { @@ -100,7 +99,7 @@ public override T BindDelegate(CallSite site, object[] args) { Type tType = typeof(T); if (tType == typeof(Func)) { return (T)(object)new Func(StringContains); - } else if(tType == typeof(Func)) { + } else if (tType == typeof(Func)) { return (T)(object)new Func(StringContains); } else if (tType == typeof(Func)) { return (T)(object)new Func(StringContains); @@ -113,25 +112,25 @@ public override T BindDelegate(CallSite site, object[] args) { } } break; - + } return base.BindDelegate(site, args); } private KeyValuePair GetListEnumerator(CallSite site, PythonList value) { - return new KeyValuePair(new PythonListIterator(value), null); + return new KeyValuePair(new PythonListIterator(value), null); } private KeyValuePair GetListEnumerator(CallSite site, object value) { if (value != null && value.GetType() == typeof(PythonList)) { - return new KeyValuePair(new PythonListIterator((PythonList)value), null); + return new KeyValuePair(new PythonListIterator((PythonList)value), null); } return ((CallSite>>)site).Update(site, value); } private KeyValuePair GetTupleEnumerator(CallSite site, PythonTuple value) { - return new KeyValuePair(new PythonTupleEnumerator(value), null); + return new KeyValuePair(new PythonTupleEnumerator(value), null); } private KeyValuePair GetTupleEnumerator(CallSite site, object value) { @@ -233,7 +232,7 @@ public override Type ReturnType { case PythonOperationKind.CallSignatures: return typeof(IList); case PythonOperationKind.Documentation: return typeof(string); } - return typeof(object); + return typeof(object); } } diff --git a/Src/IronPython/Runtime/Binding/PythonOperationKind.cs b/Src/IronPython/Runtime/Binding/PythonOperationKind.cs index a2f0112a8..7e0d0dce7 100644 --- a/Src/IronPython/Runtime/Binding/PythonOperationKind.cs +++ b/Src/IronPython/Runtime/Binding/PythonOperationKind.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace IronPython.Runtime.Binding { +namespace IronPython.Runtime.Binding { /// /// Custom dynamic site kinds for simple sites that just take a fixed set of parameters. /// @@ -201,8 +197,8 @@ internal enum PythonOperationKind { ///Operator for performing reverse divmod ReverseDivMod = DivMod | Reversed, - InPlace = 0x20000000, - Reversed = 0x10000000, - Comparison = 0x08000000, + InPlace = 0x20000000, + Reversed = 0x10000000, + Comparison = 0x08000000, } } diff --git a/Src/IronPython/Runtime/Binding/PythonOverloadResolver.cs b/Src/IronPython/Runtime/Binding/PythonOverloadResolver.cs index 434d46f79..c93ada3f2 100644 --- a/Src/IronPython/Runtime/Binding/PythonOverloadResolver.cs +++ b/Src/IronPython/Runtime/Binding/PythonOverloadResolver.cs @@ -10,12 +10,12 @@ using System.Numerics; using System.Reflection; +using IronPython.Runtime.Operations; + using Microsoft.Scripting.Actions; using Microsoft.Scripting.Actions.Calls; -using Microsoft.Scripting.Utils; -using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; -using IronPython.Runtime.Operations; +using Microsoft.Scripting.Utils; namespace IronPython.Runtime.Binding { internal sealed class PythonOverloadResolverFactory : OverloadResolverFactory { @@ -242,10 +242,10 @@ private static Candidate SelectWiderNumericType(Type candidateOneType, Type cand if (GetUnmanagedNumericTypeWidth(candidateTwoType) is not int candidateTwoWidth) return Candidate.Ambiguous; Candidate preferred = Comparer.Default.Compare(candidateOneWidth, candidateTwoWidth) switch { - 1 => Candidate.One, - 0 => Candidate.Equivalent, + 1 => Candidate.One, + 0 => Candidate.Equivalent, -1 => Candidate.Two, - _ => throw new InvalidOperationException() + _ => throw new InvalidOperationException() }; if (preferred == Candidate.One && Converter.IsUnsignedInt(candidateOneType) && !Converter.IsUnsignedInt(candidateTwoType)) { diff --git a/Src/IronPython/Runtime/Binding/PythonProtocol.Operations.cs b/Src/IronPython/Runtime/Binding/PythonProtocol.Operations.cs index 61f916e14..bdd1120d9 100644 --- a/Src/IronPython/Runtime/Binding/PythonProtocol.Operations.cs +++ b/Src/IronPython/Runtime/Binding/PythonProtocol.Operations.cs @@ -2,17 +2,19 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; -using System.Numerics; - using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Dynamic; +using System.Linq.Expressions; +using System.Numerics; using System.Reflection; using System.Text; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Actions.Calls; @@ -21,9 +23,6 @@ using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -266,7 +265,7 @@ private static DynamicMetaObject MakeBinaryOperation(DynamicMetaObjectBinder ope null, // test Ast.Assign(curIndex, Ast.Add(curIndex, AstUtils.Constant(1))), // increment Ast.Block( // body - // getItemRes = param0.__getitem__(curIndex) + // getItemRes = param0.__getitem__(curIndex) Utils.Try( Ast.Block( Ast.Assign( @@ -276,11 +275,11 @@ private static DynamicMetaObject MakeBinaryOperation(DynamicMetaObjectBinder ope Ast.Empty() ) ).Catch( - // end of indexes, return false + // end of indexes, return false typeof(IndexOutOfRangeException), Ast.Break(target) ), - // if(getItemRes == param1) return true + // if(getItemRes == param1) return true Utils.If( DynamicExpression.Dynamic( state.BinaryOperationRetType( @@ -554,8 +553,7 @@ private static NewExpression MakeEnumeratorResult(Expression tmp) { } else { notExpr = errorSuggestion.Expression; } - } - else { + } else { Debug.Assert(res.Expression.Type == typeof(bool)); notExpr = Ast.IsFalse(res.Expression); self = res; @@ -991,7 +989,7 @@ private static void MakeSlotCallWorker(PythonContext/*!*/ state, PythonTypeSlot/ SlotOrFunction.GetCombinedTargets(fop, rop, out fop, out rop); bool shouldWarn = false; - + // if the left operand is an instance of a built-in type or a new-style class, and the right operand is an instance of a proper subclass of that type or class // and overrides the base's __rop__() method, the right operand's __rop__() method is tried before the left operand's __op__() method. PythonType xPythonType = MetaPythonObject.GetPythonType(xType); @@ -1143,15 +1141,15 @@ private static DynamicMetaObject MakeUnindexableError(DynamicMetaObjectBinder op private static DynamicMetaObject/*!*/[]/*!*/ GetItemSliceArguments(PythonContext state, PythonIndexType op, DynamicMetaObject/*!*/[]/*!*/ types) { DynamicMetaObject[] args; if (op == PythonIndexType.SetSlice) { - args = new DynamicMetaObject[] { + args = new DynamicMetaObject[] { types[0].Restrict(types[0].GetLimitType()), - GetSetSlice(state, types), + GetSetSlice(state, types), types[types.Length- 1].Restrict(types[types.Length - 1].GetLimitType()) }; } else { Debug.Assert(op == PythonIndexType.GetSlice || op == PythonIndexType.DeleteSlice); - args = new DynamicMetaObject[] { + args = new DynamicMetaObject[] { types[0].Restrict(types[0].GetLimitType()), GetGetOrDeleteSlice(state, types) }; @@ -1417,7 +1415,7 @@ public ItemBuilder(DynamicMetaObject/*!*/[]/*!*/ types, Callable/*!*/ callable) public override DynamicMetaObject/*!*/ MakeRule(DynamicMetaObjectBinder/*!*/ metaBinder, PythonContext/*!*/ binder, DynamicMetaObject/*!*/[]/*!*/ args) { DynamicMetaObject[] tupleArgs = Callable.GetTupleArguments(args); - return Callable.CompleteRuleTarget(metaBinder, tupleArgs, delegate() { + return Callable.CompleteRuleTarget(metaBinder, tupleArgs, delegate () { if (args[1].GetLimitType() != typeof(Slice) && GetTypeAt(1).TryResolveSlot(binder.SharedContext, "__index__", out _)) { args[1] = new DynamicMetaObject( DynamicExpression.Dynamic( @@ -1742,7 +1740,7 @@ public static PythonOperationKind OperatorToReverseOperator(PythonOperationKind Expression error = action.Throw( Ast.Call( - typeof(PythonOps).GetMethod(nameof(PythonOps.SimpleTypeError)), + typeof(PythonOps).GetMethod(nameof(PythonOps.SimpleTypeError)), Ast.Constant(message) ), typeof(object) diff --git a/Src/IronPython/Runtime/Binding/PythonSetIndexBinder.cs b/Src/IronPython/Runtime/Binding/PythonSetIndexBinder.cs index 89ffc18f1..7b2b028c3 100644 --- a/Src/IronPython/Runtime/Binding/PythonSetIndexBinder.cs +++ b/Src/IronPython/Runtime/Binding/PythonSetIndexBinder.cs @@ -2,17 +2,15 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; using System.Dynamic; +using System.Linq.Expressions; using System.Runtime.CompilerServices; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - using IronPython.Runtime.Operations; +using Microsoft.Scripting.Runtime; + using AstUtils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Runtime.Binding { @@ -33,7 +31,7 @@ public override DynamicMetaObject FallbackSetIndex(DynamicMetaObject target, Dyn return com; } #endif - + DynamicMetaObject[] finalArgs = new DynamicMetaObject[indexes.Length + 2]; finalArgs[0] = target; for (int i = 0; i < indexes.Length; i++) { @@ -53,7 +51,7 @@ public override T BindDelegate(CallSite site, object[] args) { return base.BindDelegate(site, args); } - + private object DictAssign(CallSite site, object dict, object key, object value) { if (dict != null && dict.GetType() == typeof(PythonDictionary)) { ((PythonDictionary)dict)[key] = value; diff --git a/Src/IronPython/Runtime/Binding/PythonSetMemberBinder.cs b/Src/IronPython/Runtime/Binding/PythonSetMemberBinder.cs index 347e1c1bb..619b65c35 100644 --- a/Src/IronPython/Runtime/Binding/PythonSetMemberBinder.cs +++ b/Src/IronPython/Runtime/Binding/PythonSetMemberBinder.cs @@ -2,22 +2,22 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Dynamic; using System.Linq.Expressions; -using System; -using System.Dynamic; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + using Microsoft.Scripting; using Microsoft.Scripting.Runtime; -using AstUtils = Microsoft.Scripting.Ast.Utils; -using IronPython.Runtime.Binding; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; +using AstUtils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Runtime.Binding { - using Ast = Expression; using System.Runtime.CompilerServices; + using Ast = Expression; + internal class PythonSetMemberBinder : SetMemberBinder, IPythonSite, IExpressionSerializable { private readonly PythonContext/*!*/ _context; diff --git a/Src/IronPython/Runtime/Binding/PythonSetSliceBinder.cs b/Src/IronPython/Runtime/Binding/PythonSetSliceBinder.cs index db3f13b12..64e2f394c 100644 --- a/Src/IronPython/Runtime/Binding/PythonSetSliceBinder.cs +++ b/Src/IronPython/Runtime/Binding/PythonSetSliceBinder.cs @@ -2,16 +2,14 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Dynamic; using System.Linq.Expressions; -using System; -using System.Dynamic; +using IronPython.Runtime.Operations; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Operations; - namespace IronPython.Runtime.Binding { using Ast = Expression; @@ -23,7 +21,7 @@ public PythonSetSliceBinder(PythonContext/*!*/ context) { _context = context; } - public override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args) { + public override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args) { return PythonProtocol.Index(this, PythonIndexType.SetSlice, ArrayUtils.Insert(target, args)); } diff --git a/Src/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs b/Src/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs index abaf83227..7be52081a 100644 --- a/Src/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs +++ b/Src/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs @@ -2,17 +2,15 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; using System.Dynamic; +using System.Linq.Expressions; using System.Runtime.CompilerServices; +using IronPython.Runtime.Operations; + using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - -using IronPython.Runtime.Operations; namespace IronPython.Runtime.Binding { using Ast = Expression; diff --git a/Src/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs b/Src/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs index 949a9873d..38801afe2 100644 --- a/Src/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs +++ b/Src/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs @@ -2,19 +2,17 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; -using System.Collections.Generic; -using System.Dynamic; +using System.Linq.Expressions; using System.Reflection; -using AstUtils = Microsoft.Scripting.Ast.Utils; + using Microsoft.Scripting.Actions.Calls; -using Microsoft.Scripting.Utils; + +using AstUtils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Runtime.Binding { public sealed class SiteLocalStorageBuilder : ArgBuilder { - public SiteLocalStorageBuilder(ParameterInfo info) + public SiteLocalStorageBuilder(ParameterInfo info) : base(info) { } diff --git a/Src/IronPython/Runtime/Binding/SlotOrFunction.cs b/Src/IronPython/Runtime/Binding/SlotOrFunction.cs index 5f54c0fb2..a48863992 100644 --- a/Src/IronPython/Runtime/Binding/SlotOrFunction.cs +++ b/Src/IronPython/Runtime/Binding/SlotOrFunction.cs @@ -2,20 +2,19 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; using System.Collections.Generic; using System.Diagnostics; -using System.Reflection; using System.Dynamic; +using System.Linq.Expressions; +using System.Reflection; + using IronPython.Runtime.Types; -using Microsoft.Scripting; + using Microsoft.Scripting.Actions; using Microsoft.Scripting.Actions.Calls; -using Microsoft.Scripting.Generation; -using Microsoft.Scripting.Utils; using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; namespace IronPython.Runtime.Binding { using Ast = Expression; @@ -240,9 +239,9 @@ internal static bool TryGetBinder(PythonContext/*!*/ state, DynamicMetaObject/*! } var mc = new PythonOverloadResolver( - state.Binder, + state.Binder, types, - new CallSignature(types.Length), + new CallSignature(types.Length), AstUtils.Constant(state.SharedContext) ); diff --git a/Src/IronPython/Runtime/Binding/WarningInfo.cs b/Src/IronPython/Runtime/Binding/WarningInfo.cs index 616ecd3af..d23c10469 100644 --- a/Src/IronPython/Runtime/Binding/WarningInfo.cs +++ b/Src/IronPython/Runtime/Binding/WarningInfo.cs @@ -7,6 +7,7 @@ using IronPython.Runtime.Operations; using IronPython.Runtime.Types; + using Microsoft.Scripting.Utils; using AstUtils = Microsoft.Scripting.Ast.Utils; diff --git a/Src/IronPython/Runtime/BufferProtocol.cs b/Src/IronPython/Runtime/BufferProtocol.cs index f537ae709..1b4b6321c 100644 --- a/Src/IronPython/Runtime/BufferProtocol.cs +++ b/Src/IronPython/Runtime/BufferProtocol.cs @@ -30,7 +30,7 @@ public enum BufferFlags { /// /// The buffer must be writable. The consumer cannot handle read-only buffers. /// - Writable = 0x0001, + Writable = 0x0001, /// /// The consumer expects the item format to be reported and is prepared to deal with items that are more complex than a byte. @@ -38,30 +38,30 @@ public enum BufferFlags { /// /// If format is requested, the consumer must also indicate preparedness to handle shape ( flag set). /// - Format = 0x0004, + Format = 0x0004, /// /// An N-dimensional array, 0 <= N <= 64. The dimensions are reported as shape. /// - ND = 0x0008, + ND = 0x0008, /// /// An N-dimensional array with strides, so data may not be memory contiguous. /// However, it will fit in a contiguous memory range. /// - Strides = 0x0010 | ND, + Strides = 0x0010 | ND, /// /// An N-dimensional array with strides, so it may not be memory contiguous. /// The last dimension is contiguous. /// - CContiguous = 0x0020 | Strides, + CContiguous = 0x0020 | Strides, /// /// An N-dimensional array with strides, so it may not be memory contiguous. /// The first dimension is contiguous. /// - FContiguous = 0x0040 | Strides, + FContiguous = 0x0040 | Strides, /// /// The client is prepared to deal with either or . @@ -72,29 +72,29 @@ public enum BufferFlags { /// An N-dimensional array that has a complex structure, where higher dimensions /// may contains pointers to memory blocks holding lower dimensions. /// - Indirect = 0x0100 | Strides, + Indirect = 0x0100 | Strides, #region Flag combinations for common requests /// /// Unformatted (i.e. byte-oriented) read-only blob with no structure. /// - Simple = 0, + Simple = 0, /// /// Contiguous writable buffer of any dimension. /// - Contig = ND | Writable, + Contig = ND | Writable, /// /// Contiguous buffer of any dimension. /// - ContigRO = ND, + ContigRO = ND, /// /// Writable byte buffer of any dimension, possibly non-contiguous, but with no embedded pointers. /// - Strided = Strides | Writable, + Strided = Strides | Writable, /// /// Byte buffer of any dimension, possibly non-contiguous, but with no embedded pointers. @@ -105,7 +105,7 @@ public enum BufferFlags { /// Writable buffer of any dimension, possibly non-contiguous, but with no embedded pointers. /// Elements can be any struct type. /// - Records = Strides | Writable | Format, + Records = Strides | Writable | Format, /// /// Buffer of any dimension, possibly non-contiguous, but with no embedded pointers. @@ -113,8 +113,8 @@ public enum BufferFlags { /// RecordsRO = Strides | Format, - Full = Indirect | Writable | Format, - FullRO = Indirect | Format, + Full = Indirect | Writable | Format, + FullRO = Indirect | Format, #endregion } diff --git a/Src/IronPython/Runtime/BuiltinPythonModule.cs b/Src/IronPython/Runtime/BuiltinPythonModule.cs index 65e973fd6..ee315159d 100644 --- a/Src/IronPython/Runtime/BuiltinPythonModule.cs +++ b/Src/IronPython/Runtime/BuiltinPythonModule.cs @@ -2,9 +2,10 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; + using IronPython.Compiler; + using Microsoft.Scripting.Utils; namespace IronPython.Runtime { diff --git a/Src/IronPython/Runtime/BuiltinsDictionaryStorage.cs b/Src/IronPython/Runtime/BuiltinsDictionaryStorage.cs index 06e5ebafc..c5b4e5e5b 100644 --- a/Src/IronPython/Runtime/BuiltinsDictionaryStorage.cs +++ b/Src/IronPython/Runtime/BuiltinsDictionaryStorage.cs @@ -4,11 +4,10 @@ using System; -using Microsoft.Scripting; -using Microsoft.Scripting.Runtime; - using IronPython.Modules; +using Microsoft.Scripting.Runtime; + namespace IronPython.Runtime { internal class BuiltinsDictionaryStorage : ModuleDictionaryStorage { private readonly EventHandler/*!*/ _change; @@ -28,7 +27,7 @@ public override void Add(ref DictionaryStorage storage, object key, object value } base.Add(ref storage, key, value); } - + protected override void LazyAdd(object name, object value) { base.Add(name, value); } diff --git a/Src/IronPython/Runtime/ByteArray.cs b/Src/IronPython/Runtime/ByteArray.cs index ef3f6a2a0..d3a21b3fc 100644 --- a/Src/IronPython/Runtime/ByteArray.cs +++ b/Src/IronPython/Runtime/ByteArray.cs @@ -9,16 +9,15 @@ using System.Collections.Generic; using System.Numerics; using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; using System.Text; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + namespace IronPython.Runtime { /// /// bytearray(string, encoding[, errors]) -> bytearray @@ -295,7 +294,7 @@ public int count([BytesLike, NotNone] IList sub, object? start, object? en int istart = start != null ? Converter.ConvertToIndex(start) : 0; lock (this) { int iend = end != null ? Converter.ConvertToIndex(end) : _bytes.Count; - return _bytes.CountOf(sub, istart, iend); + return _bytes.CountOf(sub, istart, iend); } } @@ -660,7 +659,7 @@ public ByteArray lstrip() { } } - public ByteArray lstrip([BytesLike]IList? chars) { + public ByteArray lstrip([BytesLike] IList? chars) { if (chars == null) return lstrip(); lock (this) { var res = _bytes.LeftStrip(chars); @@ -844,7 +843,7 @@ public PythonTuple rpartition([BytesLike, NotNone] IList sep) { } [return: SequenceTypeInfo(typeof(ByteArray))] - public PythonList rsplit([BytesLike]IList? sep = null, int maxsplit = -1) { + public PythonList rsplit([BytesLike] IList? sep = null, int maxsplit = -1) { lock (this) { return _bytes.RightSplit(sep, maxsplit, x => new ByteArray(new List(x))); } @@ -857,7 +856,7 @@ public ByteArray rstrip() { } } - public ByteArray rstrip([BytesLike]IList? chars) { + public ByteArray rstrip([BytesLike] IList? chars) { if (chars == null) return rstrip(); lock (this) { var res = _bytes.RightStrip(chars); @@ -866,7 +865,7 @@ public ByteArray rstrip([BytesLike]IList? chars) { } [return: SequenceTypeInfo(typeof(ByteArray))] - public PythonList split([BytesLike]IList? sep = null, int maxsplit = -1) { + public PythonList split([BytesLike] IList? sep = null, int maxsplit = -1) { lock (this) { return _bytes.Split(sep, maxsplit, x => new ByteArray(x)); } @@ -962,7 +961,7 @@ public ByteArray strip() { } } - public ByteArray strip([BytesLike]IList? chars) { + public ByteArray strip([BytesLike] IList? chars) { if (chars == null) return strip(); lock (this) { var res = _bytes.Strip(chars); @@ -989,7 +988,7 @@ private void ValidateTable(IList? table) { } } - public ByteArray translate([BytesLike]IList? table) { + public ByteArray translate([BytesLike] IList? table) { ValidateTable(table); lock (this) { return new ByteArray(_bytes.Translate(table, null)); @@ -997,14 +996,14 @@ public ByteArray translate([BytesLike]IList? table) { } - public ByteArray translate([BytesLike]IList? table, [BytesLike, NotNone] IList delete) { + public ByteArray translate([BytesLike] IList? table, [BytesLike, NotNone] IList delete) { ValidateTable(table); lock (this) { return new ByteArray(_bytes.Translate(table, delete)); } } - public ByteArray translate([BytesLike]IList? table, object? delete) { + public ByteArray translate([BytesLike] IList? table, object? delete) { if (delete is IBufferProtocol bufferProtocol) { using var buffer = bufferProtocol.GetBuffer(); return translate(table, buffer.AsReadOnlySpan().ToArray()); diff --git a/Src/IronPython/Runtime/Bytes.cs b/Src/IronPython/Runtime/Bytes.cs index 1bb46f213..1c92b716c 100644 --- a/Src/IronPython/Runtime/Bytes.cs +++ b/Src/IronPython/Runtime/Bytes.cs @@ -14,12 +14,13 @@ using System.Numerics; using System.Text; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; + +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + using NotNullWhenAttribute = System.Diagnostics.CodeAnalysis.NotNullWhenAttribute; namespace IronPython.Runtime { @@ -531,7 +532,7 @@ public Bytes lstrip() { return res == null ? this.AsBytes() : new Bytes(res); } - public Bytes lstrip([BytesLike]IList? chars) { + public Bytes lstrip([BytesLike] IList? chars) { if (chars == null) return lstrip(); var res = _bytes.LeftStrip(chars); return res == null ? this.AsBytes() : new Bytes(res); @@ -700,7 +701,7 @@ public PythonTuple rpartition([BytesLike, NotNone] IList sep) { } [return: SequenceTypeInfo(typeof(Bytes))] - public PythonList rsplit([BytesLike]IList? sep = null, int maxsplit = -1) { + public PythonList rsplit([BytesLike] IList? sep = null, int maxsplit = -1) { return _bytes.RightSplit(sep, maxsplit, x => new Bytes(new List(x))); } @@ -709,14 +710,14 @@ public Bytes rstrip() { return res == null ? this.AsBytes() : new Bytes(res); } - public Bytes rstrip([BytesLike]IList? chars) { + public Bytes rstrip([BytesLike] IList? chars) { if (chars == null) return rstrip(); var res = _bytes.RightStrip(chars); return res == null ? this.AsBytes() : new Bytes(res); } [return: SequenceTypeInfo(typeof(Bytes))] - public PythonList split([BytesLike]IList? sep = null, int maxsplit = -1) { + public PythonList split([BytesLike] IList? sep = null, int maxsplit = -1) { return _bytes.Split(sep, maxsplit, x => new Bytes(x)); } @@ -790,7 +791,7 @@ public Bytes strip() { return res == null ? this.AsBytes() : new Bytes(res); } - public Bytes strip([BytesLike]IList? chars) { + public Bytes strip([BytesLike] IList? chars) { if (chars == null) return strip(); var res = _bytes.Strip(chars); return res == null ? this.AsBytes() : new Bytes(res); @@ -815,7 +816,7 @@ private void ValidateTable(IList? table) { } } - public Bytes translate([BytesLike]IList? table) { + public Bytes translate([BytesLike] IList? table) { ValidateTable(table); if (table is null) return AsBytes(); var res = _bytes.Translate(table, null, out bool changed); @@ -823,7 +824,7 @@ public Bytes translate([BytesLike]IList? table) { return AsBytes(); } - public Bytes translate([BytesLike]IList? table, [BytesLike, NotNone] IList delete) { + public Bytes translate([BytesLike] IList? table, [BytesLike, NotNone] IList delete) { ValidateTable(table); if (table is null && delete.Count == 0) return AsBytes(); var res = _bytes.Translate(table, delete, out bool changed); @@ -831,7 +832,7 @@ public Bytes translate([BytesLike]IList? table, [BytesLike, NotNone] IList return AsBytes(); } - public Bytes translate([BytesLike]IList? table, object? delete) { + public Bytes translate([BytesLike] IList? table, object? delete) { if (delete is IBufferProtocol bufferProtocol) { using var buffer = bufferProtocol.GetBuffer(); return translate(table, buffer.AsReadOnlySpan().ToArray()); diff --git a/Src/IronPython/Runtime/ClassMethodDescriptor.cs b/Src/IronPython/Runtime/ClassMethodDescriptor.cs index c04c03289..4cab7c741 100644 --- a/Src/IronPython/Runtime/ClassMethodDescriptor.cs +++ b/Src/IronPython/Runtime/ClassMethodDescriptor.cs @@ -3,8 +3,10 @@ // See the LICENSE file in the project root for more information. using System; + using IronPython.Runtime.Operations; using IronPython.Runtime.Types; + using Microsoft.Scripting.Runtime; namespace IronPython.Runtime { @@ -23,7 +25,7 @@ internal override bool TryGetValue(CodeContext context, object instance, PythonT } #region Descriptor Protocol - + private PythonType CheckGetArgs(CodeContext context, object instance, PythonType owner) { if (owner == null) { if (instance == null) throw PythonOps.TypeError("__get__(None, None) is invalid"); @@ -68,5 +70,5 @@ public override bool Equals(object obj) { public override int GetHashCode() { return ~_func.GetHashCode(); } - } + } } diff --git a/Src/IronPython/Runtime/ClrModule.cs b/Src/IronPython/Runtime/ClrModule.cs index 7e7b404bc..0ceddef7f 100644 --- a/Src/IronPython/Runtime/ClrModule.cs +++ b/Src/IronPython/Runtime/ClrModule.cs @@ -171,7 +171,7 @@ assembly on disk. After the load the assemblies namespaces and top-level types will be available via import Namespace.")] public static Assembly/*!*/ LoadAssemblyFromFileWithPath(CodeContext/*!*/ context, string/*!*/ file) { if (file == null) throw new TypeErrorException("LoadAssemblyFromFileWithPath: arg 1 must be a string."); - + Assembly res; if (!context.LanguageContext.TryLoadAssemblyFromFileWithPath(file, out res)) { if (!Path.IsPathRooted(file)) { @@ -253,7 +253,7 @@ public static string GetString(byte[] bytes) { [Documentation("Converts maxCount of an array of bytes to a string")] public static string GetString(byte[] bytes, int maxCount) { - int bytesToCopy = Math.Min(bytes.Length, maxCount); + int bytesToCopy = Math.Min(bytes.Length, maxCount); return Encoding.GetEncoding("iso-8859-1").GetString(bytes, 0, bytesToCopy); } @@ -699,7 +699,7 @@ internal override bool GetAlwaysSucceeds { #region IFancyCallable Members [SpecialName] - public object Call(CodeContext context, [ParamDictionary]IDictionary dict, params object[] args) { + public object Call(CodeContext context, [ParamDictionary] IDictionary dict, params object[] args) { ValidateArgs(args); if (_inst != null) { @@ -794,7 +794,7 @@ internal override bool GetAlwaysSucceeds { #region IFancyCallable Members [SpecialName] - public object Call(CodeContext context, [ParamDictionary]IDictionary dict, params object[] args) { + public object Call(CodeContext context, [ParamDictionary] IDictionary dict, params object[] args) { object ret; if (_inst != null) { ret = PythonCalls.CallWithKeywordArgs(context, _func, ArrayUtils.Insert(_inst, args), dict); @@ -870,7 +870,7 @@ public static object Convert(CodeContext/*!*/ context, object o, Type toType) { /// Provides a helper for compiling a group of modules into a single assembly. The assembly can later be /// reloaded using the clr.AddReference API. /// - public static void CompileModules(CodeContext/*!*/ context, string/*!*/ assemblyName, [ParamDictionary]IDictionary kwArgs, params string/*!*/[]/*!*/ filenames) { + public static void CompileModules(CodeContext/*!*/ context, string/*!*/ assemblyName, [ParamDictionary] IDictionary kwArgs, params string/*!*/[]/*!*/ filenames) { ContractUtils.RequiresNotNull(assemblyName, nameof(assemblyName)); ContractUtils.RequiresNotNullItems(filenames, nameof(filenames)); @@ -996,7 +996,7 @@ public static void CompileSubclassTypes(string/*!*/ assemblyName, params object[ /// public static PythonTuple GetSubclassedTypes() { List res = new List(); - + foreach (NewTypeInfo info in NewTypeMaker._newTypes.Keys) { Type clrBaseType = info.BaseType; Type tempType = clrBaseType; @@ -1129,7 +1129,7 @@ private static void SortModules(List modules) { /// /// All times are expressed in the same unit of measure as DateTime.Ticks /// - public static PythonTuple GetProfilerData(CodeContext/*!*/ context, bool includeUnused=false) { + public static PythonTuple GetProfilerData(CodeContext/*!*/ context, bool includeUnused = false) { return new PythonTuple(Profiler.GetProfiler(context.LanguageContext).GetProfile(includeUnused)); } diff --git a/Src/IronPython/Runtime/CodeContext.cs b/Src/IronPython/Runtime/CodeContext.cs index 404f3c28a..0f8a8e82a 100644 --- a/Src/IronPython/Runtime/CodeContext.cs +++ b/Src/IronPython/Runtime/CodeContext.cs @@ -4,14 +4,13 @@ #nullable enable -using System; using System.Diagnostics; +using IronPython.Compiler; + using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Compiler; - namespace IronPython.Runtime { /// diff --git a/Src/IronPython/Runtime/CollectionDebugView.cs b/Src/IronPython/Runtime/CollectionDebugView.cs index fc070aa21..f224255ed 100644 --- a/Src/IronPython/Runtime/CollectionDebugView.cs +++ b/Src/IronPython/Runtime/CollectionDebugView.cs @@ -2,11 +2,9 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; +using System.Collections; using System.Collections.Generic; -using System.Text; using System.Diagnostics; -using System.Collections; namespace IronPython.Runtime { internal class CollectionDebugProxy { diff --git a/Src/IronPython/Runtime/CommonDictionaryStorage.cs b/Src/IronPython/Runtime/CommonDictionaryStorage.cs index dba8f9af8..43a7b0036 100644 --- a/Src/IronPython/Runtime/CommonDictionaryStorage.cs +++ b/Src/IronPython/Runtime/CommonDictionaryStorage.cs @@ -10,13 +10,11 @@ using System.Runtime.Serialization; using System.Threading; -using Microsoft.Scripting.Generation; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting.Runtime; + namespace IronPython.Runtime { /// /// General purpose storage used for most PythonDictionarys. diff --git a/Src/IronPython/Runtime/CompiledLoader.cs b/Src/IronPython/Runtime/CompiledLoader.cs index 06f29cb3e..26db14f37 100644 --- a/Src/IronPython/Runtime/CompiledLoader.cs +++ b/Src/IronPython/Runtime/CompiledLoader.cs @@ -6,10 +6,9 @@ using System.Collections.Generic; using System.IO; -using Microsoft.Scripting; - using IronPython.Compiler; -using IronPython.Runtime.Operations; + +using Microsoft.Scripting; namespace IronPython.Runtime { public class CompiledLoader { diff --git a/Src/IronPython/Runtime/ConstantDictionaryStorage.cs b/Src/IronPython/Runtime/ConstantDictionaryStorage.cs index c5fc42eb6..2107abb8c 100644 --- a/Src/IronPython/Runtime/ConstantDictionaryStorage.cs +++ b/Src/IronPython/Runtime/ConstantDictionaryStorage.cs @@ -2,14 +2,14 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using MSAst = System.Linq.Expressions; - using System; using System.Collections.Generic; -using System.Text; -using Microsoft.Scripting.Runtime; + using IronPython.Runtime.Operations; -using Microsoft.Scripting.Generation; + +using Microsoft.Scripting.Runtime; + +using MSAst = System.Linq.Expressions; using Utils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Runtime { @@ -34,7 +34,7 @@ public override void Add(ref DictionaryStorage storage, object key, object value return; } } - + // race, try again... storage.Add(ref storage, key, value); } @@ -54,7 +54,7 @@ public override bool Remove(ref DictionaryStorage storage, object key) { // race, try again return storage.Remove(ref storage, key); } - + return false; } diff --git a/Src/IronPython/Runtime/Converter.cs b/Src/IronPython/Runtime/Converter.cs index 8dc38890d..464686131 100644 --- a/Src/IronPython/Runtime/Converter.cs +++ b/Src/IronPython/Runtime/Converter.cs @@ -47,19 +47,19 @@ public static partial class Converter { private static readonly CallSite> _floatSite = MakeExplicitConvertSite(); private static readonly CallSite> - _tryByteSite = MakeExplicitTrySite(), - _trySByteSite = MakeExplicitTrySite(), - _tryInt16Site = MakeExplicitTrySite(), - _tryInt32Site = MakeExplicitTrySite(), - _tryInt64Site = MakeExplicitTrySite(), - _tryUInt16Site = MakeExplicitTrySite(), - _tryUInt32Site = MakeExplicitTrySite(), - _tryUInt64Site = MakeExplicitTrySite(), - _tryDoubleSite = MakeExplicitTrySite(), - _tryCharSite = MakeExplicitTrySite(), + _tryByteSite = MakeExplicitTrySite(), + _trySByteSite = MakeExplicitTrySite(), + _tryInt16Site = MakeExplicitTrySite(), + _tryInt32Site = MakeExplicitTrySite(), + _tryInt64Site = MakeExplicitTrySite(), + _tryUInt16Site = MakeExplicitTrySite(), + _tryUInt32Site = MakeExplicitTrySite(), + _tryUInt64Site = MakeExplicitTrySite(), + _tryDoubleSite = MakeExplicitTrySite(), + _tryCharSite = MakeExplicitTrySite(), _tryBigIntegerSite = MakeExplicitTrySite(), - _tryComplexSite = MakeExplicitTrySite(), - _tryStringSite = MakeExplicitTrySite(); + _tryComplexSite = MakeExplicitTrySite(), + _tryStringSite = MakeExplicitTrySite(); private static CallSite> MakeImplicitConvertSite() { return MakeConvertSite(ConversionResultKind.ImplicitCast); diff --git a/Src/IronPython/Runtime/CustomDictionaryStorage.cs b/Src/IronPython/Runtime/CustomDictionaryStorage.cs index 072c156e8..351309d00 100644 --- a/Src/IronPython/Runtime/CustomDictionaryStorage.cs +++ b/Src/IronPython/Runtime/CustomDictionaryStorage.cs @@ -8,7 +8,6 @@ using System.Collections.Generic; using System.Linq; -using Microsoft.Scripting; using Microsoft.Scripting.Runtime; namespace IronPython.Runtime { diff --git a/Src/IronPython/Runtime/DebuggerDictionaryStorage.cs b/Src/IronPython/Runtime/DebuggerDictionaryStorage.cs index ae28867e1..5b2e96194 100644 --- a/Src/IronPython/Runtime/DebuggerDictionaryStorage.cs +++ b/Src/IronPython/Runtime/DebuggerDictionaryStorage.cs @@ -5,8 +5,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Threading; -using Microsoft.Scripting; namespace IronPython.Runtime { /// diff --git a/Src/IronPython/Runtime/DefaultContext.cs b/Src/IronPython/Runtime/DefaultContext.cs index 663706507..ce385a3e7 100644 --- a/Src/IronPython/Runtime/DefaultContext.cs +++ b/Src/IronPython/Runtime/DefaultContext.cs @@ -4,7 +4,7 @@ using System.Diagnostics; using System.Threading; -using IronPython.Runtime.Binding; + using Microsoft.Scripting; using Microsoft.Scripting.Runtime; @@ -14,13 +14,13 @@ public static class DefaultContext { internal static CodeContext _default; [MultiRuntimeAware] internal static CodeContext _defaultCLS; - + public static ContextId Id { get { return Default.LanguageContext.ContextId; } } - + public static CodeContext Default { get { Debug.Assert(_default != null); diff --git a/Src/IronPython/Runtime/Descriptors.cs b/Src/IronPython/Runtime/Descriptors.cs index d448ca334..7f6b7f0b8 100644 --- a/Src/IronPython/Runtime/Descriptors.cs +++ b/Src/IronPython/Runtime/Descriptors.cs @@ -2,18 +2,15 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -using Microsoft.Scripting; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting; +using Microsoft.Scripting.Runtime; + namespace IronPython.Runtime { [PythonType] public class staticmethod : PythonTypeSlot { @@ -25,7 +22,7 @@ public staticmethod(CodeContext/*!*/ context, object func) { public void __init__(CodeContext/*!*/ context, object func) { _func = func; - } + } internal override bool TryGetValue(CodeContext context, object instance, PythonType owner, out object value) { value = __get__(instance, owner); @@ -156,7 +153,7 @@ internal override bool TrySetValue(CodeContext context, object instance, PythonT internal override bool TryDeleteValue(CodeContext context, object instance, PythonType owner) { if (instance == null) { return false; - } + } __delete__(context, instance); return true; } @@ -166,9 +163,9 @@ public bool __isabstractmethod__ { object isabstract; if (PythonOps.TryGetBoundAttr(_fget, "__isabstractmethod__", out isabstract)) { return PythonOps.IsTrue(isabstract); - } else if(PythonOps.TryGetBoundAttr(_fset, "__isabstractmethod__", out isabstract)) { + } else if (PythonOps.TryGetBoundAttr(_fset, "__isabstractmethod__", out isabstract)) { return PythonOps.IsTrue(isabstract); - } else if(PythonOps.TryGetBoundAttr(_fdel, "__isabstractmethod__", out isabstract)) { + } else if (PythonOps.TryGetBoundAttr(_fdel, "__isabstractmethod__", out isabstract)) { return PythonOps.IsTrue(isabstract); } return false; @@ -207,7 +204,7 @@ public object fget { } } - public override object __get__(CodeContext/*!*/ context, object instance, object owner=null) { + public override object __get__(CodeContext/*!*/ context, object instance, object owner = null) { if (instance == null) { return this; } else if (fget != null) { diff --git a/Src/IronPython/Runtime/DictionaryOps.cs b/Src/IronPython/Runtime/DictionaryOps.cs index cf5f3cd0d..0bbca1c32 100644 --- a/Src/IronPython/Runtime/DictionaryOps.cs +++ b/Src/IronPython/Runtime/DictionaryOps.cs @@ -2,20 +2,16 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; -using System.Runtime.CompilerServices; using System.Text; -using Microsoft.Scripting; -using Microsoft.Scripting.Runtime; - -using IronPython.Runtime.Binding; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting.Runtime; + namespace IronPython.Runtime { /// /// Provides both helpers for implementing Python dictionaries as well diff --git a/Src/IronPython/Runtime/DictionaryStorage.cs b/Src/IronPython/Runtime/DictionaryStorage.cs index 696da464f..0a4e7c22e 100644 --- a/Src/IronPython/Runtime/DictionaryStorage.cs +++ b/Src/IronPython/Runtime/DictionaryStorage.cs @@ -8,7 +8,6 @@ using System.Collections.Generic; using System.Diagnostics; -using Microsoft.Scripting; using Microsoft.Scripting.Runtime; namespace IronPython.Runtime { @@ -24,7 +23,7 @@ namespace IronPython.Runtime { /// around large operations and call lock free functions. /// [Serializable] - internal abstract class DictionaryStorage { + internal abstract class DictionaryStorage { public abstract void Add(ref DictionaryStorage storage, object? key, object? value); public virtual void AddNoLock(ref DictionaryStorage storage, object? key, object? value) { @@ -123,7 +122,7 @@ public virtual void EnsureCapacityNoLock(int size) { public virtual IEnumerator> GetEnumerator() { return GetItems().GetEnumerator(); } - + /// /// Provides fast access to the __path__ attribute if the dictionary storage supports caching it. /// diff --git a/Src/IronPython/Runtime/DictionaryTypeInfoAttribute.cs b/Src/IronPython/Runtime/DictionaryTypeInfoAttribute.cs index 583d8269c..36fa3cd59 100644 --- a/Src/IronPython/Runtime/DictionaryTypeInfoAttribute.cs +++ b/Src/IronPython/Runtime/DictionaryTypeInfoAttribute.cs @@ -12,7 +12,7 @@ namespace IronPython.Runtime { /// inspected to get type information about the types of the keys and values of the expected /// dictionary or the returned dictionary. /// - [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, AllowMultiple=false)] + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, AllowMultiple = false)] public sealed class DictionaryTypeInfoAttribute : Attribute { public DictionaryTypeInfoAttribute(Type keyType, Type valueType) { KeyType = keyType; diff --git a/Src/IronPython/Runtime/EmptyDictionaryStorage.cs b/Src/IronPython/Runtime/EmptyDictionaryStorage.cs index 3e86ff4fa..0c27d814e 100644 --- a/Src/IronPython/Runtime/EmptyDictionaryStorage.cs +++ b/Src/IronPython/Runtime/EmptyDictionaryStorage.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; using IronPython.Runtime.Operations; @@ -24,7 +23,7 @@ public override void Add(ref DictionaryStorage storage, object key, object value return; } } - + // race, try again... storage.Add(ref storage, key, value); } diff --git a/Src/IronPython/Runtime/Enumerate.cs b/Src/IronPython/Runtime/Enumerate.cs index c8fae3449..22b785e32 100644 --- a/Src/IronPython/Runtime/Enumerate.cs +++ b/Src/IronPython/Runtime/Enumerate.cs @@ -9,12 +9,12 @@ using System.Numerics; using System.Runtime.CompilerServices; -using Microsoft.Scripting.Runtime; - using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting.Runtime; + namespace IronPython.Runtime { /* * Enumerators exposed to Python code directly diff --git a/Src/IronPython/Runtime/ErrorCodes.cs b/Src/IronPython/Runtime/ErrorCodes.cs index 3718dcf28..d36d66a82 100644 --- a/Src/IronPython/Runtime/ErrorCodes.cs +++ b/Src/IronPython/Runtime/ErrorCodes.cs @@ -25,12 +25,12 @@ public static class ErrorCodes { /// /// The error was a general syntax error /// - public const int SyntaxError = 0x0010; + public const int SyntaxError = 0x0010; /// /// The error was an indentation error. /// - public const int IndentationError = 0x0020; + public const int IndentationError = 0x0020; /// /// The error was a tab error. diff --git a/Src/IronPython/Runtime/Exceptions/AttributeErrorException.cs b/Src/IronPython/Runtime/Exceptions/AttributeErrorException.cs index ec4a18038..effd22634 100644 --- a/Src/IronPython/Runtime/Exceptions/AttributeErrorException.cs +++ b/Src/IronPython/Runtime/Exceptions/AttributeErrorException.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Runtime.Serialization; + using Microsoft.Scripting.Runtime; namespace IronPython.Runtime.Exceptions { diff --git a/Src/IronPython/Runtime/Exceptions/IndentationException.cs b/Src/IronPython/Runtime/Exceptions/IndentationException.cs index 508522cb0..5e19ceabd 100644 --- a/Src/IronPython/Runtime/Exceptions/IndentationException.cs +++ b/Src/IronPython/Runtime/Exceptions/IndentationException.cs @@ -5,6 +5,7 @@ using System; using System.Runtime.Serialization; using System.Security; + using Microsoft.Scripting; using Microsoft.Scripting.Utils; diff --git a/Src/IronPython/Runtime/Exceptions/PythonException.cs b/Src/IronPython/Runtime/Exceptions/PythonException.cs index 45e9e169e..d909d13ef 100644 --- a/Src/IronPython/Runtime/Exceptions/PythonException.cs +++ b/Src/IronPython/Runtime/Exceptions/PythonException.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.Runtime.Serialization; + using Microsoft.Scripting.Runtime; namespace IronPython.Runtime.Exceptions { diff --git a/Src/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs b/Src/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs index 6a7bc59e5..20aef855a 100644 --- a/Src/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs +++ b/Src/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs @@ -87,8 +87,7 @@ public static object __new__([NotNone] PythonType/*!*/ cls, [NotNone] params obj BaseException res; if (cls.UnderlyingSystemType == typeof(BaseException)) { res = new BaseException(cls); - } - else { + } else { res = (BaseException)Activator.CreateInstance(cls.UnderlyingSystemType, cls)!; } res._args = new PythonTuple(args\u00F8); @@ -180,8 +179,7 @@ internal set { } public override string/*!*/ ToString() { - return (_args.__len__()) switch - { + return (_args.__len__()) switch { 0 => string.Empty, 1 => PythonOps.ToString(_args[0]), _ => _args.ToString(), diff --git a/Src/IronPython/Runtime/Exceptions/PythonExceptions.cs b/Src/IronPython/Runtime/Exceptions/PythonExceptions.cs index be0a8567d..45253538d 100644 --- a/Src/IronPython/Runtime/Exceptions/PythonExceptions.cs +++ b/Src/IronPython/Runtime/Exceptions/PythonExceptions.cs @@ -6,23 +6,20 @@ using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; -using System.Dynamic; using System.IO; -using System.Linq.Expressions; using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; using System.Threading; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + using Microsoft.Scripting; using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - #if !FEATURE_REMOTING using MarshalByRefObject = System.Object; #endif @@ -122,7 +119,7 @@ public override string ToString() { } public partial class _OSError { - public static new object __new__(PythonType cls, [ParamDictionary]IDictionary kwArgs, params object[] args) { + public static new object __new__(PythonType cls, [ParamDictionary] IDictionary kwArgs, params object[] args) { if (cls == OSError && args.Length >= 1 && args[0] is int errno) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { if (args.Length >= 4 && args[3] is int winerror) { @@ -223,8 +220,7 @@ private static Error ErrnoToErrorEnum(int errno) { } private static PythonType ErrnoToPythonType(Error errno) { - var res = errno switch - { + var res = errno switch { Error.EPERM => PermissionError, Error.ENOENT => FileNotFoundError, Error.ESRCH => ProcessLookupError, @@ -239,8 +235,7 @@ private static PythonType ErrnoToPythonType(Error errno) { _ => null }; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { - res ??= errno switch - { + res ??= errno switch { // Windows or remapped OSX Error.WSAEWOULDBLOCK => BlockingIOError, Error.WSAEINPROGRESS => BlockingIOError, @@ -253,8 +248,7 @@ private static PythonType ErrnoToPythonType(Error errno) { _ => null }; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { - res ??= errno switch - { + res ??= errno switch { // Linux Error.ECONNABORTED => ConnectionAbortedError, Error.ECONNRESET => ConnectionResetError, @@ -529,7 +523,7 @@ internal static int WinErrorToErrno(int winerror) { } public partial class _ImportError { - public void __init__([ParamDictionary]IDictionary kwargs, params object[] args) { + public void __init__([ParamDictionary] IDictionary kwargs, params object[] args) { base.__init__(args); foreach (var pair in kwargs) { diff --git a/Src/IronPython/Runtime/Exceptions/SystemExitException.cs b/Src/IronPython/Runtime/Exceptions/SystemExitException.cs index 6444bb4c6..15f34df3d 100644 --- a/Src/IronPython/Runtime/Exceptions/SystemExitException.cs +++ b/Src/IronPython/Runtime/Exceptions/SystemExitException.cs @@ -4,6 +4,7 @@ using System; using System.Runtime.Serialization; + using IronPython.Modules; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; diff --git a/Src/IronPython/Runtime/Exceptions/TabException.cs b/Src/IronPython/Runtime/Exceptions/TabException.cs index 7d0815d86..e7f715a61 100644 --- a/Src/IronPython/Runtime/Exceptions/TabException.cs +++ b/Src/IronPython/Runtime/Exceptions/TabException.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System; -using System.Dynamic; + using Microsoft.Scripting; namespace IronPython.Runtime.Exceptions { diff --git a/Src/IronPython/Runtime/Exceptions/TraceBack.cs b/Src/IronPython/Runtime/Exceptions/TraceBack.cs index 49f1bb208..912331e93 100644 --- a/Src/IronPython/Runtime/Exceptions/TraceBack.cs +++ b/Src/IronPython/Runtime/Exceptions/TraceBack.cs @@ -8,11 +8,11 @@ using System.Runtime.CompilerServices; using System.Text; +using IronPython.Runtime.Operations; + using Microsoft.Scripting; using Microsoft.Scripting.Runtime; -using IronPython.Runtime.Operations; - [module: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "IronPython.Runtime.Exceptions.TraceBackFrame..ctor(System.Object,System.Object,System.Object)", MessageId = "0#globals")] [module: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "IronPython.Runtime.Exceptions.TraceBackFrame.Globals", MessageId = "Globals")] @@ -118,11 +118,11 @@ internal TraceBackFrame(PythonTracebackListener traceAdapter, FunctionCode code, [SpecialName, PropertyMethod] public object Getf_trace() { - if (_traceAdapter != null) { - return _traceObject; - } else { - return null; - } + if (_traceAdapter != null) { + return _traceObject; + } else { + return null; + } } [SpecialName, PropertyMethod] @@ -230,7 +230,7 @@ private void SetLineNumber(int newLineNum) { Dictionary currentLoopIds = null; bool inForLoopOrFinally = loopAndFinallyLocations != null && loopAndFinallyLocations.TryGetValue(_lineNo, out currentLoopIds); - + int originalNewLine = newLineNum; if (newLineNum < funcCode.Span.Start.Line) { @@ -246,7 +246,7 @@ private void SetLineNumber(int newLineNum) { // Check if we're jumping onto a handler bool handlerIsFinally; if (handlerLocations != null && handlerLocations.TryGetValue(newLineNum, out handlerIsFinally)) { - throw PythonOps.ValueError("can't jump to 'except' line"); + throw PythonOps.ValueError("can't jump to 'except' line"); } // Check if we're jumping into a for-loop diff --git a/Src/IronPython/Runtime/Exceptions/TypeErrorException.cs b/Src/IronPython/Runtime/Exceptions/TypeErrorException.cs index 4e96b88a8..62ff49703 100644 --- a/Src/IronPython/Runtime/Exceptions/TypeErrorException.cs +++ b/Src/IronPython/Runtime/Exceptions/TypeErrorException.cs @@ -5,8 +5,9 @@ using System; using System.Collections.Generic; using System.Runtime.Serialization; -using Microsoft.Scripting.Runtime; + using Microsoft.Scripting; +using Microsoft.Scripting.Runtime; namespace IronPython.Runtime.Exceptions { #region Generated TypeErrorException @@ -44,7 +45,7 @@ PythonExceptions.BaseException IPythonAwareException.PythonException { newEx.InitializeFromClr(this); _pyExceptionObject = newEx; } - return _pyExceptionObject; + return _pyExceptionObject; } set { _pyExceptionObject = value; } } diff --git a/Src/IronPython/Runtime/Exceptions/ValueErrorException.cs b/Src/IronPython/Runtime/Exceptions/ValueErrorException.cs index 9b86c8201..65e91a4fc 100644 --- a/Src/IronPython/Runtime/Exceptions/ValueErrorException.cs +++ b/Src/IronPython/Runtime/Exceptions/ValueErrorException.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Runtime.Serialization; + using Microsoft.Scripting.Runtime; namespace IronPython.Runtime.Exceptions { diff --git a/Src/IronPython/Runtime/FunctionAttributes.cs b/Src/IronPython/Runtime/FunctionAttributes.cs index 6ffc0c85b..325c6831b 100644 --- a/Src/IronPython/Runtime/FunctionAttributes.cs +++ b/Src/IronPython/Runtime/FunctionAttributes.cs @@ -7,11 +7,11 @@ namespace IronPython.Runtime { [Flags] public enum FunctionAttributes { - None = 0, + None = 0, /// /// Set if the function includes a *args argument list. /// - ArgumentList = 0x04, + ArgumentList = 0x04, /// /// Set if the function includes a **kwargs argument dictionary. /// diff --git a/Src/IronPython/Runtime/FunctionCode.cs b/Src/IronPython/Runtime/FunctionCode.cs index bbaef9e05..406e7a072 100644 --- a/Src/IronPython/Runtime/FunctionCode.cs +++ b/Src/IronPython/Runtime/FunctionCode.cs @@ -2,27 +2,26 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; -using Microsoft.Scripting.Ast; - using System; using System.Collections.Generic; using System.Diagnostics; +using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Threading; +using IronPython.Compiler; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + using Microsoft.Scripting; +using Microsoft.Scripting.Ast; using Microsoft.Scripting.Debugging.CompilerServices; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Compiler; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - namespace IronPython.Runtime { /// /// Represents a piece of code. This can reference either a CompiledCode @@ -772,7 +771,7 @@ private LambdaExpression GetGeneratorOrNormalLambdaTracing(PythonContext context ); } - + /// /// Gets the correct final LambdaExpression for this piece of code. /// @@ -784,8 +783,8 @@ private LightLambdaExpression GetGeneratorOrNormalLambda() { finalCode = Code; } else { finalCode = Code.ToGenerator( - _lambda.ShouldInterpret, - _lambda.EmitDebugSymbols, + _lambda.ShouldInterpret, + _lambda.EmitDebugSymbols, _lambda.GlobalParent.PyContext.Options.CompilationThreshold ); } @@ -838,7 +837,7 @@ private Delegate CompileLambda(LambdaExpression code, EventHandler || + if (finalTarget is Func || finalTarget is Func || finalTarget is LookupCompilationDelegate) { // no recursion enforcement on classes or modules diff --git a/Src/IronPython/Runtime/Generator.cs b/Src/IronPython/Runtime/Generator.cs index b1210df4c..e27a10a3a 100644 --- a/Src/IronPython/Runtime/Generator.cs +++ b/Src/IronPython/Runtime/Generator.cs @@ -10,14 +10,14 @@ using System.Diagnostics; using System.Threading; -using Microsoft.Scripting; -using Microsoft.Scripting.Runtime; - using IronPython.Compiler; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting; +using Microsoft.Scripting.Runtime; + namespace IronPython.Runtime { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix"), PythonType("generator")] [DontMapIDisposableToContextManager, DontMapIEnumerableToContains] @@ -76,7 +76,7 @@ public object __next__() { if (Closed) { return LightExceptions.Throw(PythonOps.StopIteration()); } - + object res = NextWorker(); if (res == OperationFailed.Value) { if (FinalValue is null) @@ -365,8 +365,7 @@ private void SaveFunctionStack(bool done) { stack.RemoveAt(stack.Count - 1); Debug.Assert(functionStack.Context is not null); fnStack = new FunctionStack(functionStack.Context!, functionStack.Code); // don't keep the frame since f_back may be invalid - } - else { + } else { fnStack = null; } } diff --git a/Src/IronPython/Runtime/GlobalDictionaryStorage.cs b/Src/IronPython/Runtime/GlobalDictionaryStorage.cs index 6a31eaae6..d17bfa980 100644 --- a/Src/IronPython/Runtime/GlobalDictionaryStorage.cs +++ b/Src/IronPython/Runtime/GlobalDictionaryStorage.cs @@ -4,16 +4,13 @@ #nullable enable -using System; using System.Collections.Generic; -using Microsoft.Scripting; +using IronPython.Compiler; + using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime; -using IronPython.Compiler; - namespace IronPython.Runtime { internal class GlobalDictionaryStorage : CustomDictionaryStorage { private readonly Dictionary/*!*/ _globals; diff --git a/Src/IronPython/Runtime/Implementation.cs b/Src/IronPython/Runtime/Implementation.cs index cc244460f..45f9f0732 100644 --- a/Src/IronPython/Runtime/Implementation.cs +++ b/Src/IronPython/Runtime/Implementation.cs @@ -3,11 +3,8 @@ // See the LICENSE file in the project root for more information. using System; -using System.Linq; using System.Reflection; -using IronPython.Runtime.Operations; - namespace IronPython.Runtime { [PythonType("sys.version_info")] public class VersionInfo : PythonTuple { diff --git a/Src/IronPython/Runtime/Importer.cs b/Src/IronPython/Runtime/Importer.cs index 24b90ccd6..db81e4031 100644 --- a/Src/IronPython/Runtime/Importer.cs +++ b/Src/IronPython/Runtime/Importer.cs @@ -10,16 +10,16 @@ using System.Reflection; using System.Text; -using Microsoft.Scripting; -using Microsoft.Scripting.Actions; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - using IronPython.Modules; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting; +using Microsoft.Scripting.Actions; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + namespace IronPython.Runtime { /// @@ -576,7 +576,7 @@ private static object ImportTopAbsolute(CodeContext/*!*/ context, string/*!*/ na return ret; } - private static string [] SubArray(string[] t, int len) { + private static string[] SubArray(string[] t, int len) { var ret = new string[len]; Array.Copy(t, ret, len); return ret; @@ -914,7 +914,7 @@ internal static PythonModule LoadPackageFromSource(CodeContext/*!*/ context, str return null; } - if(context.LanguageContext.DomainManager.Platform.DirectoryExists(path) && !context.LanguageContext.DomainManager.Platform.FileExists(context.LanguageContext.DomainManager.Platform.CombinePaths(path, "__init__.py"))) { + if (context.LanguageContext.DomainManager.Platform.DirectoryExists(path) && !context.LanguageContext.DomainManager.Platform.FileExists(context.LanguageContext.DomainManager.Platform.CombinePaths(path, "__init__.py"))) { PythonOps.Warn(context, PythonExceptions.ImportWarning, "Not importing directory '{0}': missing __init__.py", path); } diff --git a/Src/IronPython/Runtime/Index.cs b/Src/IronPython/Runtime/Index.cs index 34efd5270..779854c43 100644 --- a/Src/IronPython/Runtime/Index.cs +++ b/Src/IronPython/Runtime/Index.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Microsoft.Scripting.Utils; +using Microsoft.Scripting.Utils; namespace IronPython.Runtime { /// diff --git a/Src/IronPython/Runtime/InstancedModuleDictionaryStorage.cs b/Src/IronPython/Runtime/InstancedModuleDictionaryStorage.cs index d1682025c..c48102122 100644 --- a/Src/IronPython/Runtime/InstancedModuleDictionaryStorage.cs +++ b/Src/IronPython/Runtime/InstancedModuleDictionaryStorage.cs @@ -2,8 +2,8 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; + using IronPython.Compiler; namespace IronPython.Runtime { diff --git a/Src/IronPython/Runtime/Interfaces.cs b/Src/IronPython/Runtime/Interfaces.cs index 4f33ce05d..6593c587b 100644 --- a/Src/IronPython/Runtime/Interfaces.cs +++ b/Src/IronPython/Runtime/Interfaces.cs @@ -13,7 +13,7 @@ namespace IronPython.Runtime { public interface ICodeFormattable { string/*!*/ __repr__(CodeContext/*!*/ context); - } + } /// /// Defines the internal interface used for accessing weak references and adding finalizers diff --git a/Src/IronPython/Runtime/MemoryStreamContentProvider.cs b/Src/IronPython/Runtime/MemoryStreamContentProvider.cs index 4fd4e5704..c72a95f65 100644 --- a/Src/IronPython/Runtime/MemoryStreamContentProvider.cs +++ b/Src/IronPython/Runtime/MemoryStreamContentProvider.cs @@ -4,6 +4,7 @@ using System; using System.IO; + using Microsoft.Scripting; using Microsoft.Scripting.Utils; diff --git a/Src/IronPython/Runtime/MemoryView.cs b/Src/IronPython/Runtime/MemoryView.cs index ffd9bbaab..958c398b7 100644 --- a/Src/IronPython/Runtime/MemoryView.cs +++ b/Src/IronPython/Runtime/MemoryView.cs @@ -9,8 +9,8 @@ using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -using System.Threading; using System.Linq; +using System.Threading; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; @@ -57,7 +57,7 @@ public MemoryView([NotNone] IBufferProtocol @object) { ReadOnlySpan memblock = _buffer.AsReadOnlySpan(); - if ( (_buffer.ItemCount != 0 && !VerifyStructure(memblock.Length, _buffer.ItemSize, _buffer.NumOfDims, _buffer.Shape, _buffer.Strides, _buffer.Offset)) + if ((_buffer.ItemCount != 0 && !VerifyStructure(memblock.Length, _buffer.ItemSize, _buffer.NumOfDims, _buffer.Shape, _buffer.Strides, _buffer.Offset)) || (_buffer.Shape == null && (_buffer.Offset != 0 || _buffer.NumBytes() != memblock.Length)) ) { throw PythonOps.BufferError("memoryview: invalid buffer exported from object of type {0}", PythonOps.GetPythonTypeName(@object)); @@ -100,19 +100,19 @@ public MemoryView([NotNone] IBufferProtocol @object) { } public MemoryView([NotNone] MemoryView @object) { - _exporter = @object._exporter; - _flags = BufferFlags.RecordsRO; - _buffer = _exporter.GetBuffer(_flags); - _offset = @object._offset; - _isReadOnly = @object._isReadOnly; - _numDims = @object._numDims; - _format = @object._format; - _itemSize = @object._itemSize; - _shape = @object._shape; - _strides = @object._strides; - _isCContig = @object._isCContig; - _isFContig = @object._isFContig; - _numItems = @object._numItems; + _exporter = @object._exporter; + _flags = BufferFlags.RecordsRO; + _buffer = _exporter.GetBuffer(_flags); + _offset = @object._offset; + _isReadOnly = @object._isReadOnly; + _numDims = @object._numDims; + _format = @object._format; + _itemSize = @object._itemSize; + _shape = @object._shape; + _strides = @object._strides; + _isCContig = @object._isCContig; + _isFContig = @object._isFContig; + _numItems = @object._numItems; } internal MemoryView(IBufferProtocol @object, bool readOnly) : this(@object) { @@ -180,7 +180,7 @@ private MemoryView(MemoryView @object, BufferFlags flags) : this(@object) { if (_buffer != null) { _buffer.Dispose(); } - } catch {} + } catch { } } [MemberNotNull(nameof(_buffer))] @@ -385,8 +385,7 @@ public string hex() { if (_isCContig) { return Bytes.ToHex(_buffer.AsReadOnlySpan().Slice(_offset, _numItems * _itemSize)); - } - else { + } else { var builder = new System.Text.StringBuilder(_numItems * _itemSize * 2); foreach (byte b in this.EnumerateBytes()) { builder.Append(ToAscii(b >> 4)); @@ -447,7 +446,7 @@ public MemoryView cast([NotNone] string format) { return cast(format, null); } - public MemoryView cast([NotNone] string format, [NotNone, AllowNull]object shape) { + public MemoryView cast([NotNone] string format, [NotNone, AllowNull] object shape) { if (!_isCContig) { throw PythonOps.TypeError("memoryview: casts are restricted to C-contiguous views"); } @@ -475,7 +474,7 @@ public MemoryView cast([NotNone] string format, [NotNone, AllowNull]object shape } } - if ( !TypecodeOps.TryDecomposeTypecode(format, out char byteorder, out char typecode) + if (!TypecodeOps.TryDecomposeTypecode(format, out char byteorder, out char typecode) || !IsSupportedTypecode(typecode) || byteorder != '@' ) { diff --git a/Src/IronPython/Runtime/Method.cs b/Src/IronPython/Runtime/Method.cs index 83e3dfaca..390a0aa38 100644 --- a/Src/IronPython/Runtime/Method.cs +++ b/Src/IronPython/Runtime/Method.cs @@ -8,12 +8,12 @@ using System.Linq.Expressions; using System.Runtime.CompilerServices; -using Microsoft.Scripting; -using Microsoft.Scripting.Runtime; - using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting; +using Microsoft.Scripting.Runtime; + namespace IronPython.Runtime { [PythonType("method"), DontMapGetMemberNamesToDir] public sealed partial class Method : PythonTypeSlot, IWeakReferenceable, IPythonMembersList, IDynamicMetaObjectProvider, ICodeFormattable, Binding.IFastInvokable { @@ -49,7 +49,7 @@ public object Call(CodeContext/*!*/ context, params object[] args) => context.LanguageContext.CallSplat(this, args); [SpecialName] - public object Call(CodeContext/*!*/ context, [ParamDictionary]IDictionary kwArgs, params object[] args) + public object Call(CodeContext/*!*/ context, [ParamDictionary] IDictionary kwArgs, params object[] args) => context.LanguageContext.CallWithKeywords(this, args, kwArgs); #region Object Overrides @@ -117,11 +117,11 @@ IList IPythonMembersList.GetMemberNames(CodeContext/*!*/ context) { if (__func__ is PythonFunction pf) { PythonDictionary dict = pf.__dict__; - + // Check the func foreach (KeyValuePair kvp in dict) { ret.AddNoLockNoDups(kvp.Key); - } + } } return ret; diff --git a/Src/IronPython/Runtime/ModuleContext.cs b/Src/IronPython/Runtime/ModuleContext.cs index db8c00430..45d2db2be 100644 --- a/Src/IronPython/Runtime/ModuleContext.cs +++ b/Src/IronPython/Runtime/ModuleContext.cs @@ -2,8 +2,8 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Diagnostics; + using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; diff --git a/Src/IronPython/Runtime/ModuleDictionaryStorage.cs b/Src/IronPython/Runtime/ModuleDictionaryStorage.cs index e4a7887ee..ad22a86e8 100644 --- a/Src/IronPython/Runtime/ModuleDictionaryStorage.cs +++ b/Src/IronPython/Runtime/ModuleDictionaryStorage.cs @@ -6,8 +6,10 @@ using System.Collections.Generic; using System.Diagnostics; using System.Reflection; + using IronPython.Compiler; using IronPython.Runtime.Types; + using Microsoft.Scripting.Actions; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; @@ -217,7 +219,7 @@ public override bool TryGetValue(object key, out object value) { return value != Uninitialized.Instance; } - if(key is string strKey) { + if (key is string strKey) { return TryGetLazyValue(strKey, out value); } diff --git a/Src/IronPython/Runtime/ModuleGlobalCache.cs b/Src/IronPython/Runtime/ModuleGlobalCache.cs index f6c55203a..aa2a406e4 100644 --- a/Src/IronPython/Runtime/ModuleGlobalCache.cs +++ b/Src/IronPython/Runtime/ModuleGlobalCache.cs @@ -2,14 +2,13 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Diagnostics; +using IronPython.Runtime.Exceptions; + using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Exceptions; - namespace IronPython.Runtime { /// /// Cached global value. Created and maintained on a per-language basis. Default diff --git a/Src/IronPython/Runtime/ModuleLoader.cs b/Src/IronPython/Runtime/ModuleLoader.cs index 3966d0157..7a214e8db 100644 --- a/Src/IronPython/Runtime/ModuleLoader.cs +++ b/Src/IronPython/Runtime/ModuleLoader.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using Microsoft.Scripting; using IronPython.Compiler; namespace IronPython.Runtime { diff --git a/Src/IronPython/Runtime/ModuleOptions.cs b/Src/IronPython/Runtime/ModuleOptions.cs index 9d051028c..1ab443470 100644 --- a/Src/IronPython/Runtime/ModuleOptions.cs +++ b/Src/IronPython/Runtime/ModuleOptions.cs @@ -3,8 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; -using System.Text; namespace IronPython.Runtime { [Flags] diff --git a/Src/IronPython/Runtime/NewStringFormatter.cs b/Src/IronPython/Runtime/NewStringFormatter.cs index 84ca824ab..00117b00c 100644 --- a/Src/IronPython/Runtime/NewStringFormatter.cs +++ b/Src/IronPython/Runtime/NewStringFormatter.cs @@ -6,12 +6,12 @@ using System.Collections.Generic; using System.Text; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - using IronPython.Modules; using IronPython.Runtime.Operations; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + namespace IronPython.Runtime { /// /// New string formatter for 'str'.format(...) calls and support for the Formatter diff --git a/Src/IronPython/Runtime/ObjectAttributesAdapter.cs b/Src/IronPython/Runtime/ObjectAttributesAdapter.cs index d5c267d75..f01d56111 100644 --- a/Src/IronPython/Runtime/ObjectAttributesAdapter.cs +++ b/Src/IronPython/Runtime/ObjectAttributesAdapter.cs @@ -6,10 +6,11 @@ using System.Collections; using System.Collections.Generic; + using IronPython.Runtime.Operations; namespace IronPython.Runtime { - internal class ObjectAttributesAdapter : DictionaryStorage { + internal class ObjectAttributesAdapter : DictionaryStorage { private readonly object _backing; private readonly CodeContext/*!*/ _context; @@ -55,7 +56,7 @@ public override bool TryGetValue(object? key, out object? value) { } public override int Count { - get { return PythonOps.Length(_backing); } + get { return PythonOps.Length(_backing); } } public override void Clear(ref DictionaryStorage storage) { diff --git a/Src/IronPython/Runtime/ObjectDebugView.cs b/Src/IronPython/Runtime/ObjectDebugView.cs index 803cf391d..0cc08640a 100644 --- a/Src/IronPython/Runtime/ObjectDebugView.cs +++ b/Src/IronPython/Runtime/ObjectDebugView.cs @@ -2,10 +2,8 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Collections.Generic; -using System.Text; using System.Diagnostics; + using IronPython.Runtime.Operations; namespace IronPython.Runtime { diff --git a/Src/IronPython/Runtime/Operations/ArrayOps.cs b/Src/IronPython/Runtime/Operations/ArrayOps.cs index f80cd9734..ecfa9b46b 100644 --- a/Src/IronPython/Runtime/Operations/ArrayOps.cs +++ b/Src/IronPython/Runtime/Operations/ArrayOps.cs @@ -10,11 +10,11 @@ using System.Diagnostics; using System.Text; +using IronPython.Runtime.Types; + using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Types; - using SpecialNameAttribute = System.Runtime.CompilerServices.SpecialNameAttribute; namespace IronPython.Runtime.Operations { diff --git a/Src/IronPython/Runtime/Operations/BigIntegerOps.cs b/Src/IronPython/Runtime/Operations/BigIntegerOps.cs index 6ed328bf2..59099a442 100644 --- a/Src/IronPython/Runtime/Operations/BigIntegerOps.cs +++ b/Src/IronPython/Runtime/Operations/BigIntegerOps.cs @@ -5,7 +5,6 @@ #nullable enable using System; -using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; @@ -14,12 +13,32 @@ using System.Runtime.CompilerServices; using System.Text; + +/* Unmerged change from project 'IronPython (net6.0)' +Before: using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Exceptions; +After: +using IronPython.Runtime.Exceptions; +*/ using IronPython.Runtime.Exceptions; using IronPython.Runtime.Types; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + + +/* Unmerged change from project 'IronPython (net6.0)' +Before: +namespace IronPython.Runtime.Operations { +After: +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + +namespace IronPython.Runtime.Operations { +*/ namespace IronPython.Runtime.Operations { public static partial class BigIntegerOps { @@ -757,8 +776,7 @@ public static BigInteger ToBigInteger(BigInteger self) { if (spec.Fill == '0' && spec.Width > 1) { digits = FormattingHelper.ToCultureString(val, culture.NumberFormat, spec, (spec.Sign != null && spec.Sign != '-' || self < 0) ? spec.Width - 1 : null); - } - else { + } else { digits = FormattingHelper.ToCultureString(val, culture.NumberFormat, spec); } break; @@ -825,7 +843,7 @@ public static BigInteger ToBigInteger(BigInteger self) { int iVal; if (!self.AsInt32(out iVal)) { throw PythonOps.OverflowError("Python int too large to convert to System.Int32"); - } else if(iVal < 0 || iVal > 0x10ffff) { + } else if (iVal < 0 || iVal > 0x10ffff) { throw PythonOps.OverflowError("%c arg not in range(0x110000)"); } @@ -853,7 +871,7 @@ public static Bytes to_bytes(BigInteger value, int length, [NotNone] string byte #if NETCOREAPP var bytes = new byte[length]; - int start = isLittle? 0 : length - value.GetByteCount(isUnsigned: !signed); + int start = isLittle ? 0 : length - value.GetByteCount(isUnsigned: !signed); if (start < 0) ThrowOverflow(); if (!value.TryWriteBytes(bytes.AsSpan(start), out int written, isUnsigned: !signed, isBigEndian: !isLittle)) { ThrowOverflow(); diff --git a/Src/IronPython/Runtime/Operations/BoolOps.cs b/Src/IronPython/Runtime/Operations/BoolOps.cs index 9654968e3..848d2772b 100644 --- a/Src/IronPython/Runtime/Operations/BoolOps.cs +++ b/Src/IronPython/Runtime/Operations/BoolOps.cs @@ -6,6 +6,7 @@ using System.Numerics; using Microsoft.Scripting.Runtime; + using SpecialNameAttribute = System.Runtime.CompilerServices.SpecialNameAttribute; namespace IronPython.Runtime.Operations { @@ -26,7 +27,7 @@ public static bool __new__(object cls, object o) { public static bool BitwiseAnd(bool x, bool y) { return x & y; } - + [SpecialName] public static bool BitwiseOr(bool x, bool y) { return x | y; diff --git a/Src/IronPython/Runtime/Operations/ByteOps.cs b/Src/IronPython/Runtime/Operations/ByteOps.cs index 50418728b..05f7882d6 100644 --- a/Src/IronPython/Runtime/Operations/ByteOps.cs +++ b/Src/IronPython/Runtime/Operations/ByteOps.cs @@ -7,11 +7,8 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq; using System.Numerics; -using Microsoft.Scripting.Utils; - namespace IronPython.Runtime.Operations { public static partial class ByteOps { internal static byte ToByteChecked(this int item) { diff --git a/Src/IronPython/Runtime/Operations/CharOps.cs b/Src/IronPython/Runtime/Operations/CharOps.cs index 10e76d84d..700bbc4be 100644 --- a/Src/IronPython/Runtime/Operations/CharOps.cs +++ b/Src/IronPython/Runtime/Operations/CharOps.cs @@ -6,9 +6,10 @@ using System.Runtime.CompilerServices; -using Microsoft.Scripting.Runtime; using IronPython.Runtime.Types; +using Microsoft.Scripting.Runtime; + namespace IronPython.Runtime.Operations { /// diff --git a/Src/IronPython/Runtime/Operations/DBNullOps.cs b/Src/IronPython/Runtime/Operations/DBNullOps.cs index f2b1628b7..a46f9ca39 100644 --- a/Src/IronPython/Runtime/Operations/DBNullOps.cs +++ b/Src/IronPython/Runtime/Operations/DBNullOps.cs @@ -15,7 +15,7 @@ public static object __new__(object cls) { return DBNull.Value; } - public static bool __bool__(DBNull value) { + public static bool __bool__(DBNull value) { return false; } } diff --git a/Src/IronPython/Runtime/Operations/DelegateOps.cs b/Src/IronPython/Runtime/Operations/DelegateOps.cs index 90376973e..30fe2b9cc 100644 --- a/Src/IronPython/Runtime/Operations/DelegateOps.cs +++ b/Src/IronPython/Runtime/Operations/DelegateOps.cs @@ -7,12 +7,12 @@ using System; using System.Collections.Generic; +using IronPython.Runtime.Types; + using Microsoft.Scripting; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Types; - namespace IronPython.Runtime.Operations { public static class DelegateOps { @@ -48,7 +48,7 @@ public static object Call(CodeContext/*!*/ context, Delegate @delegate, params o return context.LanguageContext.CallSplat(@delegate, args); } - public static object Call(CodeContext/*!*/ context, Delegate @delegate, [ParamDictionary]IDictionary dict, params object[] args) { + public static object Call(CodeContext/*!*/ context, Delegate @delegate, [ParamDictionary] IDictionary dict, params object[] args) { return context.LanguageContext.CallWithKeywords(@delegate, args, dict); } diff --git a/Src/IronPython/Runtime/Operations/EnumOps.cs b/Src/IronPython/Runtime/Operations/EnumOps.cs index 6c0085772..5eab047ca 100644 --- a/Src/IronPython/Runtime/Operations/EnumOps.cs +++ b/Src/IronPython/Runtime/Operations/EnumOps.cs @@ -44,7 +44,7 @@ public static object ExclusiveOr(object self, object other) { } [SpecialName] - public static object OnesComplement(object self) { + public static object OnesComplement(object self) { object result = EnumUtils.OnesComplement(self); if (result != null) { return result; diff --git a/Src/IronPython/Runtime/Operations/FloatOps.cs b/Src/IronPython/Runtime/Operations/FloatOps.cs index fa02bc04e..5e182dc6e 100644 --- a/Src/IronPython/Runtime/Operations/FloatOps.cs +++ b/Src/IronPython/Runtime/Operations/FloatOps.cs @@ -869,7 +869,7 @@ internal static string DoubleToFormatString(CodeContext/*!*/ context, double sel // only have as single digit avoid exponents. if (digitCnt > spec.Precision.Value && digitCnt != 1) { // first round off the decimal value - self = MathUtils.Round(self, 0 , MidpointRounding.ToEven); + self = MathUtils.Round(self, 0, MidpointRounding.ToEven); // then remove any insignificant digits double pow = Math.Pow(10, digitCnt - Math.Max(spec.Precision.Value, 1)); @@ -1043,7 +1043,7 @@ public static double __round__(double self, int ndigits) { } var result = MathUtils.Round(self, ndigits, MidpointRounding.ToEven); - + if (double.IsInfinity(result)) { throw PythonOps.OverflowError("rounded value too large to represent"); } @@ -1065,8 +1065,7 @@ public static double __round__(double self, BigInteger ndigits) { public static double __round__(double self, object ndigits) { var index = PythonOps.Index(ndigits); - switch (index) - { + switch (index) { case int i: return __round__(self, i); diff --git a/Src/IronPython/Runtime/Operations/IListOfByteOps.cs b/Src/IronPython/Runtime/Operations/IListOfByteOps.cs index b43e26195..9499a4b3e 100644 --- a/Src/IronPython/Runtime/Operations/IListOfByteOps.cs +++ b/Src/IronPython/Runtime/Operations/IListOfByteOps.cs @@ -52,7 +52,7 @@ internal static bool EndsWith(this IList self, IList suffix) { internal static bool EndsWith(this IList self, IList suffix, int start, int end) { int len = self.Count; - if(!PythonOps.TryFixSubsequenceIndices(len, ref start, ref end)) { + if (!PythonOps.TryFixSubsequenceIndices(len, ref start, ref end)) { return false; } @@ -305,7 +305,7 @@ internal static bool StartsWith(this IList self, IList prefix) { internal static bool StartsWith(this IList self, IList prefix, int start, int end) { int len = self.Count; - if(!PythonOps.TryFixSubsequenceIndices(len, ref start, ref end)) { + if (!PythonOps.TryFixSubsequenceIndices(len, ref start, ref end)) { return false; } @@ -638,8 +638,7 @@ internal static List Translate(this IList bytes, IList? table, if (b != t) changed = true; res.Add(t); } - } - else { + } else { changed = true; } } diff --git a/Src/IronPython/Runtime/Operations/InstanceOps.cs b/Src/IronPython/Runtime/Operations/InstanceOps.cs index 2b6c6578f..31387f47e 100644 --- a/Src/IronPython/Runtime/Operations/InstanceOps.cs +++ b/Src/IronPython/Runtime/Operations/InstanceOps.cs @@ -2,23 +2,21 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Dynamic; +using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; +using IronPython.Runtime.Types; + using Microsoft.Scripting; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Exceptions; -using IronPython.Runtime.Types; - namespace IronPython.Runtime.Operations { /// /// InstanceOps contains methods that get added to CLS types depending on what @@ -107,7 +105,7 @@ public static object DefaultNew(CodeContext context, PythonType type\u00F8, para return type\u00F8.CreateInstance(context); } - public static object DefaultNewClsKW(CodeContext context, PythonType type\u00F8, [ParamDictionary]IDictionary kwargs\u00F8, params object[] args\u00F8) { + public static object DefaultNewClsKW(CodeContext context, PythonType type\u00F8, [ParamDictionary] IDictionary kwargs\u00F8, params object[] args\u00F8) { object res = DefaultNew(context, type\u00F8, args\u00F8); if (kwargs\u00F8.Count > 0) { @@ -127,13 +125,13 @@ public static object OverloadedNewBasic(CodeContext context, SiteLocalStorage kwargs\u00F8) { + public static object OverloadedNewKW(CodeContext context, BuiltinFunction overloads\u00F8, PythonType type\u00F8, [ParamDictionary] IDictionary kwargs\u00F8) { if (type\u00F8 == null) throw PythonOps.TypeError("__new__ expected type object, got {0}", PythonOps.Repr(context, DynamicHelpers.GetPythonType(type\u00F8))); return overloads\u00F8.Call(context, null, null, ArrayUtils.EmptyObjects, kwargs\u00F8); } - public static object OverloadedNewClsKW(CodeContext context, BuiltinFunction overloads\u00F8, PythonType type\u00F8, [ParamDictionary]IDictionary kwargs\u00F8, params object[] args\u00F8) { + public static object OverloadedNewClsKW(CodeContext context, BuiltinFunction overloads\u00F8, PythonType type\u00F8, [ParamDictionary] IDictionary kwargs\u00F8, params object[] args\u00F8) { if (type\u00F8 == null) throw PythonOps.TypeError("__new__ expected type object, got {0}", PythonOps.Repr(context, DynamicHelpers.GetPythonType(type\u00F8))); if (args\u00F8 == null) args\u00F8 = new object[1]; @@ -145,7 +143,7 @@ public static void DefaultInit(CodeContext context, object self, params object[] } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "self"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "kwargs\u00F8"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "context"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "args\u00F8")] - public static void DefaultInitKW(CodeContext context, object self, [ParamDictionary]IDictionary kwargs\u00F8, params object[] args\u00F8) { + public static void DefaultInitKW(CodeContext context, object self, [ParamDictionary] IDictionary kwargs\u00F8, params object[] args\u00F8) { } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "context")] @@ -158,18 +156,18 @@ public static object NonDefaultNew(CodeContext context, PythonType type\u00F8, p [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "context")] [StaticExtensionMethod] - public static object NonDefaultNewKW(CodeContext context, PythonType type\u00F8, [ParamDictionary]IDictionary kwargs\u00F8, params object[] args\u00F8) { + public static object NonDefaultNewKW(CodeContext context, PythonType type\u00F8, [ParamDictionary] IDictionary kwargs\u00F8, params object[] args\u00F8) { if (type\u00F8 == null) throw PythonOps.TypeError("__new__ expected type object, got {0}", PythonOps.Repr(context, DynamicHelpers.GetPythonType(type\u00F8))); if (args\u00F8 == null) args\u00F8 = new object[1]; - string []names; + string[] names; GetKeywordArgs(kwargs\u00F8, args\u00F8, out args\u00F8, out names); return type\u00F8.CreateInstance(context, args\u00F8, names); } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "context")] [StaticExtensionMethod] - public static object NonDefaultNewKWNoParams(CodeContext context, PythonType type\u00F8, [ParamDictionary]IDictionary kwargs\u00F8) { + public static object NonDefaultNewKWNoParams(CodeContext context, PythonType type\u00F8, [ParamDictionary] IDictionary kwargs\u00F8) { if (type\u00F8 == null) throw PythonOps.TypeError("__new__ expected type object, got {0}", PythonOps.Repr(context, DynamicHelpers.GetPythonType(type\u00F8))); string[] names; diff --git a/Src/IronPython/Runtime/Operations/IntOps.cs b/Src/IronPython/Runtime/Operations/IntOps.cs index 075e0bd41..156680e64 100644 --- a/Src/IronPython/Runtime/Operations/IntOps.cs +++ b/Src/IronPython/Runtime/Operations/IntOps.cs @@ -10,11 +10,11 @@ using System.Numerics; using System.Text; +using IronPython.Runtime.Types; + using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Types; - using SpecialNameAttribute = System.Runtime.CompilerServices.SpecialNameAttribute; namespace IronPython.Runtime.Operations { diff --git a/Src/IronPython/Runtime/Operations/MarshalOps.cs b/Src/IronPython/Runtime/Operations/MarshalOps.cs index 5c043c803..90f4853cf 100644 --- a/Src/IronPython/Runtime/Operations/MarshalOps.cs +++ b/Src/IronPython/Runtime/Operations/MarshalOps.cs @@ -10,15 +10,15 @@ namespace IronPython.Runtime.Operations { public class MarshalOps { - public static byte[] GetBytes (object o, int version) { - MarshalWriter mw = new MarshalWriter (version); - mw.WriteObject (o); - return mw.GetBytes (); + public static byte[] GetBytes(object o, int version) { + MarshalWriter mw = new MarshalWriter(version); + mw.WriteObject(o); + return mw.GetBytes(); } - public static object GetObject (IEnumerator bytes) { - MarshalReader mr = new MarshalReader (bytes); - return mr.ReadObject (); + public static object GetObject(IEnumerator bytes) { + MarshalReader mr = new MarshalReader(bytes); + return mr.ReadObject(); } @@ -56,75 +56,75 @@ private class MarshalWriter { private readonly int _version; private readonly Dictionary _strings; - public MarshalWriter (int version) { - _bytes = new List (); + public MarshalWriter(int version) { + _bytes = new List(); _version = version; if (_version > 0) { - _strings = new Dictionary (); + _strings = new Dictionary(); } } - public void WriteObject (object o) { - List infinite = PythonOps.GetReprInfinite (); + public void WriteObject(object o) { + List infinite = PythonOps.GetReprInfinite(); - if (infinite.Contains (o)) throw PythonOps.ValueError ("Marshaled data contains infinite cycle"); + if (infinite.Contains(o)) throw PythonOps.ValueError("Marshaled data contains infinite cycle"); int index = infinite.Count; - infinite.Add (o); + infinite.Add(o); try { - if (o == null) _bytes.Add ((byte)'N'); - else if (o == ScriptingRuntimeHelpers.True || (o is bool && (bool)o)) _bytes.Add ((byte)'T'); - else if (o == ScriptingRuntimeHelpers.False || (o is bool && (!(bool)o))) _bytes.Add ((byte)'F'); + if (o == null) _bytes.Add((byte)'N'); + else if (o == ScriptingRuntimeHelpers.True || (o is bool && (bool)o)) _bytes.Add((byte)'T'); + else if (o == ScriptingRuntimeHelpers.False || (o is bool && (!(bool)o))) _bytes.Add((byte)'F'); else if (o is IBufferProtocol) WriteBufferProtocol((IBufferProtocol)o); else if (o is string) WriteString(o as string); - else if (o is int) WriteInt ((int)o); - else if (o is float) WriteFloat ((float)o); - else if (o is double) WriteFloat ((double)o); - else if (o is long) WriteLong ((long)o); - else if (o.GetType () == typeof (PythonList)) WriteList (o); - else if (o.GetType () == typeof (PythonDictionary)) WriteDict (o); - else if (o.GetType () == typeof (PythonTuple)) WriteTuple (o); - else if (o.GetType () == typeof (SetCollection)) WriteSet (o); - else if (o.GetType () == typeof (FrozenSetCollection)) WriteFrozenSet (o); - else if (o is BigInteger) WriteInteger ((BigInteger)o); - else if (o is Complex) WriteComplex ((Complex)o); - else if (o == PythonExceptions.StopIteration) WriteStopIteration (); - else throw PythonOps.ValueError ("unmarshallable object " + o.GetType().ToString()); + else if (o is int) WriteInt((int)o); + else if (o is float) WriteFloat((float)o); + else if (o is double) WriteFloat((double)o); + else if (o is long) WriteLong((long)o); + else if (o.GetType() == typeof(PythonList)) WriteList(o); + else if (o.GetType() == typeof(PythonDictionary)) WriteDict(o); + else if (o.GetType() == typeof(PythonTuple)) WriteTuple(o); + else if (o.GetType() == typeof(SetCollection)) WriteSet(o); + else if (o.GetType() == typeof(FrozenSetCollection)) WriteFrozenSet(o); + else if (o is BigInteger) WriteInteger((BigInteger)o); + else if (o is Complex) WriteComplex((Complex)o); + else if (o == PythonExceptions.StopIteration) WriteStopIteration(); + else throw PythonOps.ValueError("unmarshallable object " + o.GetType().ToString()); } finally { - infinite.RemoveAt (index); + infinite.RemoveAt(index); } } - private void WriteFloat (float f) { + private void WriteFloat(float f) { if (_version > 1) { - _bytes.Add ((byte)'g'); - _bytes.AddRange (BitConverter.GetBytes ((double)f)); + _bytes.Add((byte)'g'); + _bytes.AddRange(BitConverter.GetBytes((double)f)); } else { - _bytes.Add ((byte)'f'); - WriteDoubleString (f); + _bytes.Add((byte)'f'); + WriteDoubleString(f); } } - private void WriteFloat (double f) { + private void WriteFloat(double f) { if (_version > 1) { - _bytes.Add ((byte)'g'); - _bytes.AddRange (BitConverter.GetBytes (f)); + _bytes.Add((byte)'g'); + _bytes.AddRange(BitConverter.GetBytes(f)); } else { - _bytes.Add ((byte)'f'); - WriteDoubleString (f); + _bytes.Add((byte)'f'); + WriteDoubleString(f); } } - private void WriteDoubleString (double d) { - string s = DoubleOps.__repr__ (DefaultContext.Default, d); - _bytes.Add ((byte)s.Length); + private void WriteDoubleString(double d) { + string s = DoubleOps.__repr__(DefaultContext.Default, d); + _bytes.Add((byte)s.Length); for (int i = 0; i < s.Length; i++) { - _bytes.Add ((byte)s[i]); + _bytes.Add((byte)s[i]); } } - private void WriteInteger (BigInteger val) { - _bytes.Add ((byte)'l'); + private void WriteInteger(BigInteger val) { + _bytes.Add((byte)'l'); int wordCount = 0, dir; if (val < BigInteger.Zero) { val *= -1; @@ -133,50 +133,50 @@ private void WriteInteger (BigInteger val) { dir = 1; } - List bytes = new List (); + List bytes = new List(); while (val != BigInteger.Zero) { int word = (int)(val & 0x7FFF); val = val >> 15; - bytes.Add ((byte)(word & 0xFF)); - bytes.Add ((byte)((word >> 8) & 0xFF)); + bytes.Add((byte)(word & 0xFF)); + bytes.Add((byte)((word >> 8) & 0xFF)); wordCount += dir; } - WriteInt32 (wordCount); + WriteInt32(wordCount); - _bytes.AddRange (bytes); + _bytes.AddRange(bytes); } - private void WriteLong (long l) { - _bytes.Add ((byte)'I'); + private void WriteLong(long l) { + _bytes.Add((byte)'I'); for (int i = 0; i < 8; i++) { - _bytes.Add ((byte)(l & 0xff)); + _bytes.Add((byte)(l & 0xff)); l = l >> 8; } } - private void WriteComplex (Complex val) { - _bytes.Add ((byte)'x'); - WriteDoubleString (val.Real); - WriteDoubleString (val.Imaginary); + private void WriteComplex(Complex val) { + _bytes.Add((byte)'x'); + WriteDoubleString(val.Real); + WriteDoubleString(val.Imaginary); } - private void WriteStopIteration () { - _bytes.Add ((byte)'S'); + private void WriteStopIteration() { + _bytes.Add((byte)'S'); } - private void WriteInt (int val) { - _bytes.Add ((byte)'i'); - WriteInt32 (val); + private void WriteInt(int val) { + _bytes.Add((byte)'i'); + WriteInt32(val); } - private void WriteInt32 (int val) { - _bytes.Add ((byte)(val & 0xff)); - _bytes.Add ((byte)((val >> 8) & 0xff)); - _bytes.Add ((byte)((val >> 16) & 0xff)); - _bytes.Add ((byte)((val >> 24) & 0xff)); + private void WriteInt32(int val) { + _bytes.Add((byte)(val & 0xff)); + _bytes.Add((byte)((val >> 8) & 0xff)); + _bytes.Add((byte)((val >> 16) & 0xff)); + _bytes.Add((byte)((val >> 24) & 0xff)); } private void WriteBufferProtocol(IBufferProtocol b) { @@ -195,55 +195,55 @@ private void WriteString(string s) { _bytes.AddRange(utfBytes); } - private void WriteList (object o) { + private void WriteList(object o) { PythonList l = o as PythonList; - _bytes.Add ((byte)'['); - WriteInt32 (l.__len__ ()); - for (int i = 0; i < l.__len__ (); i++) { - WriteObject (l[i]); + _bytes.Add((byte)'['); + WriteInt32(l.__len__()); + for (int i = 0; i < l.__len__(); i++) { + WriteObject(l[i]); } } - private void WriteDict (object o) { + private void WriteDict(object o) { PythonDictionary d = o as PythonDictionary; - _bytes.Add ((byte)'{'); - IEnumerator> ie = ((IEnumerable>)d).GetEnumerator (); - while (ie.MoveNext ()) { - WriteObject (ie.Current.Key); - WriteObject (ie.Current.Value); + _bytes.Add((byte)'{'); + IEnumerator> ie = ((IEnumerable>)d).GetEnumerator(); + while (ie.MoveNext()) { + WriteObject(ie.Current.Key); + WriteObject(ie.Current.Value); } - _bytes.Add ((byte)'0'); + _bytes.Add((byte)'0'); } - private void WriteTuple (object o) { + private void WriteTuple(object o) { PythonTuple t = o as PythonTuple; - _bytes.Add ((byte)'('); - WriteInt32 (t.__len__ ()); - for (int i = 0; i < t.__len__ (); i++) { - WriteObject (t[i]); + _bytes.Add((byte)'('); + WriteInt32(t.__len__()); + for (int i = 0; i < t.__len__(); i++) { + WriteObject(t[i]); } } - private void WriteSet (object set) { + private void WriteSet(object set) { SetCollection s = set as SetCollection; - _bytes.Add ((byte)'<'); - WriteInt32 (s.__len__ ()); + _bytes.Add((byte)'<'); + WriteInt32(s.__len__()); foreach (object o in s) { - WriteObject (o); + WriteObject(o); } } - private void WriteFrozenSet (object set) { + private void WriteFrozenSet(object set) { FrozenSetCollection s = set as FrozenSetCollection; - _bytes.Add ((byte)'>'); - WriteInt32 (s.__len__ ()); + _bytes.Add((byte)'>'); + WriteInt32(s.__len__()); foreach (object o in s) { - WriteObject (o); + WriteObject(o); } } - public byte[] GetBytes () { - return _bytes.ToArray (); + public byte[] GetBytes() { + return _bytes.ToArray(); } } @@ -253,37 +253,37 @@ private class MarshalReader { private readonly Dictionary _strings; private object _result; - public MarshalReader (IEnumerator bytes) { + public MarshalReader(IEnumerator bytes) { _myBytes = bytes; - _strings = new Dictionary (); + _strings = new Dictionary(); } - public object ReadObject () { - while (_myBytes.MoveNext ()) { + public object ReadObject() { + while (_myBytes.MoveNext()) { byte cur = _myBytes.Current; object res; switch ((char)cur) { - case '(': PushStack (StackType.Tuple); break; - case '[': PushStack (StackType.List); break; - case '{': PushStack (StackType.Dict); break; - case '<': PushStack (StackType.Set); break; - case '>': PushStack (StackType.FrozenSet); break; + case '(': PushStack(StackType.Tuple); break; + case '[': PushStack(StackType.List); break; + case '{': PushStack(StackType.Dict); break; + case '<': PushStack(StackType.Set); break; + case '>': PushStack(StackType.FrozenSet); break; case '0': // end of dictionary if (_stack == null || _stack.Count == 0) { - throw PythonOps.ValueError ("bad marshal data"); + throw PythonOps.ValueError("bad marshal data"); } - _stack.Peek ().StackCount = 0; + _stack.Peek().StackCount = 0; break; // case 'c': break; default: - res = YieldSimple (); + res = YieldSimple(); if (_stack == null) { return res; } do { - res = UpdateStack (res); + res = UpdateStack(res); } while (res != null && _stack.Count > 0); if (_stack.Count == 0) { @@ -294,8 +294,8 @@ public object ReadObject () { } // handle empty lists/tuples... - if (_stack != null && _stack.Count > 0 && _stack.Peek ().StackCount == 0) { - ProcStack ps = _stack.Pop (); + if (_stack != null && _stack.Count > 0 && _stack.Peek().StackCount == 0) { + ProcStack ps = _stack.Pop(); res = ps.StackObj; if (ps.StackType == StackType.Tuple) { @@ -307,7 +307,7 @@ public object ReadObject () { if (_stack.Count > 0) { // empty list/tuple do { - res = UpdateStack (res); + res = UpdateStack(res); } while (res != null && _stack.Count > 0); if (_stack.Count == 0) break; } else { @@ -320,40 +320,40 @@ public object ReadObject () { return _result; } - private void PushStack (StackType type) { - ProcStack newStack = new ProcStack (); + private void PushStack(StackType type) { + ProcStack newStack = new ProcStack(); newStack.StackType = type; switch (type) { case StackType.Dict: - newStack.StackObj = new PythonDictionary (); + newStack.StackObj = new PythonDictionary(); newStack.StackCount = -1; break; case StackType.List: - newStack.StackObj = new PythonList (); - newStack.StackCount = ReadInt32 (); + newStack.StackObj = new PythonList(); + newStack.StackCount = ReadInt32(); break; case StackType.Tuple: - newStack.StackCount = ReadInt32 (); - newStack.StackObj = new List (newStack.StackCount); + newStack.StackCount = ReadInt32(); + newStack.StackObj = new List(newStack.StackCount); break; case StackType.Set: - newStack.StackObj = new SetCollection (); - newStack.StackCount = ReadInt32 (); + newStack.StackObj = new SetCollection(); + newStack.StackCount = ReadInt32(); break; case StackType.FrozenSet: - newStack.StackCount = ReadInt32 (); - newStack.StackObj = new List (newStack.StackCount); + newStack.StackCount = ReadInt32(); + newStack.StackObj = new List(newStack.StackCount); break; } - if (_stack == null) _stack = new Stack (); + if (_stack == null) _stack = new Stack(); - _stack.Push (newStack); + _stack.Push(newStack); } - private object UpdateStack (object res) { - ProcStack curStack = _stack.Peek (); + private object UpdateStack(object res) { + ProcStack curStack = _stack.Peek(); switch (curStack.StackType) { case StackType.Dict: PythonDictionary od = curStack.StackObj as PythonDictionary; @@ -367,11 +367,11 @@ private object UpdateStack (object res) { break; case StackType.Tuple: List objs = curStack.StackObj as List; - objs.Add (res); + objs.Add(res); curStack.StackCount--; if (curStack.StackCount == 0) { - _stack.Pop (); - object tuple = PythonTuple.Make (objs); + _stack.Pop(); + object tuple = PythonTuple.Make(objs); if (_stack.Count == 0) { _result = tuple; } @@ -380,10 +380,10 @@ private object UpdateStack (object res) { break; case StackType.List: PythonList ol = curStack.StackObj as PythonList; - ol.AddNoLock (res); + ol.AddNoLock(res); curStack.StackCount--; if (curStack.StackCount == 0) { - _stack.Pop (); + _stack.Pop(); if (_stack.Count == 0) { _result = ol; } @@ -392,10 +392,10 @@ private object UpdateStack (object res) { break; case StackType.Set: SetCollection os = curStack.StackObj as SetCollection; - os.add (res); + os.add(res); curStack.StackCount--; if (curStack.StackCount == 0) { - _stack.Pop (); + _stack.Pop(); if (_stack.Count == 0) { _result = os; } @@ -404,10 +404,10 @@ private object UpdateStack (object res) { break; case StackType.FrozenSet: List ofs = curStack.StackObj as List; - ofs.Add (res); + ofs.Add(res); curStack.StackCount--; if (curStack.StackCount == 0) { - _stack.Pop (); + _stack.Pop(); object frozenSet = FrozenSetCollection.Make(ofs); if (_stack.Count == 0) { _result = frozenSet; @@ -435,34 +435,34 @@ private class ProcStack { public object Key; } - private object YieldSimple () { + private object YieldSimple() { object res; switch ((char)_myBytes.Current) { // simple ops to be read in - case 'i': res = ReadInt (); break; - case 'l': res = ReadBigInteger (); break; + case 'i': res = ReadInt(); break; + case 'l': res = ReadBigInteger(); break; case 'T': res = ScriptingRuntimeHelpers.True; break; case 'F': res = ScriptingRuntimeHelpers.False; break; - case 'f': res = ReadFloat (); break; - case 't': res = ReadAsciiString (); break; - case 'u': res = ReadUnicodeString (); break; + case 'f': res = ReadFloat(); break; + case 't': res = ReadAsciiString(); break; + case 'u': res = ReadUnicodeString(); break; case 'S': res = PythonExceptions.StopIteration; break; case 'N': res = null; break; - case 'x': res = ReadComplex (); break; - case 's': res = ReadBuffer (); break; - case 'I': res = ReadLong (); break; - case 'R': res = _strings[ReadInt32 ()]; break; - case 'g': res = ReadBinaryFloat (); break; - default: throw PythonOps.ValueError ("bad marshal data"); + case 'x': res = ReadComplex(); break; + case 's': res = ReadBuffer(); break; + case 'I': res = ReadLong(); break; + case 'R': res = _strings[ReadInt32()]; break; + case 'g': res = ReadBinaryFloat(); break; + default: throw PythonOps.ValueError("bad marshal data"); } return res; } - private byte[] ReadBytes (int len) { + private byte[] ReadBytes(int len) { byte[] bytes = new byte[len]; for (int i = 0; i < len; i++) { - if (!_myBytes.MoveNext ()) { - throw PythonOps.ValueError ("bad marshal data"); + if (!_myBytes.MoveNext()) { + throw PythonOps.ValueError("bad marshal data"); } bytes[i] = _myBytes.Current; } @@ -470,8 +470,8 @@ private byte[] ReadBytes (int len) { return bytes; } - private int ReadInt32 () { - byte[] intBytes = ReadBytes (4); + private int ReadInt32() { + byte[] intBytes = ReadBytes(4); int res = intBytes[0] | (intBytes[1] << 8) | @@ -481,10 +481,10 @@ private int ReadInt32 () { return res; } - private double ReadFloatStr () { - MoveNext (); + private double ReadFloatStr() { + MoveNext(); - string str = DecodeString (Encoding.ASCII, ReadBytes (_myBytes.Current)); + string str = DecodeString(Encoding.ASCII, ReadBytes(_myBytes.Current)); if (double.TryParse(str, NumberStyles.Float, CultureInfo.InvariantCulture, out double res)) { return res; @@ -492,32 +492,32 @@ private double ReadFloatStr () { return 0; } - private void MoveNext () { - if (!_myBytes.MoveNext ()) { - throw PythonOps.EofError ("EOF read where object expected"); + private void MoveNext() { + if (!_myBytes.MoveNext()) { + throw PythonOps.EofError("EOF read where object expected"); } } - private string DecodeString (Encoding enc, byte[] bytes) { - return enc.GetString (bytes, 0, bytes.Length); + private string DecodeString(Encoding enc, byte[] bytes) { + return enc.GetString(bytes, 0, bytes.Length); } - private object ReadInt () { - + private object ReadInt() { + // bytes not present are treated as being -1 - byte b1 = ReadIntPart (); - byte b2 = ReadIntPart (); - byte b3 = ReadIntPart (); - byte b4 = ReadIntPart (); + byte b1 = ReadIntPart(); + byte b2 = ReadIntPart(); + byte b3 = ReadIntPart(); + byte b4 = ReadIntPart(); byte[] bytes = new byte[] { b1, b2, b3, b4 }; - return ScriptingRuntimeHelpers.Int32ToObject (BitConverter.ToInt32 (bytes, 0)); + return ScriptingRuntimeHelpers.Int32ToObject(BitConverter.ToInt32(bytes, 0)); //return Ops.int2object(b1 | (b2 << 8) | (b3 << 16) | (b4 << 24)); } - private byte ReadIntPart () { + private byte ReadIntPart() { byte b; - if (_myBytes.MoveNext ()) { + if (_myBytes.MoveNext()) { b = _myBytes.Current; } else { b = 255; @@ -525,38 +525,38 @@ private byte ReadIntPart () { return b; } - private object ReadFloat () { - return ReadFloatStr (); + private object ReadFloat() { + return ReadFloatStr(); } - private object ReadBinaryFloat () { - return BitConverter.ToDouble (ReadBytes (8), 0); + private object ReadBinaryFloat() { + return BitConverter.ToDouble(ReadBytes(8), 0); } - private object ReadAsciiString () { + private object ReadAsciiString() { // Legacy IronPython 2 behavior, accepts Latin-1 - string res = DecodeString (StringOps.Latin1Encoding, ReadBytes (ReadInt32 ())); + string res = DecodeString(StringOps.Latin1Encoding, ReadBytes(ReadInt32())); _strings[_strings.Count] = res; return res; } - private object ReadUnicodeString () { - return DecodeString (Encoding.UTF8, ReadBytes (ReadInt32 ())); + private object ReadUnicodeString() { + return DecodeString(Encoding.UTF8, ReadBytes(ReadInt32())); } - private object ReadComplex () { - double real = ReadFloatStr (); - double imag = ReadFloatStr (); + private object ReadComplex() { + double real = ReadFloatStr(); + double imag = ReadFloatStr(); - return new Complex (real, imag); + return new Complex(real, imag); } - private object ReadBuffer () { - return Bytes.Make (ReadBytes (ReadInt32 ())); + private object ReadBuffer() { + return Bytes.Make(ReadBytes(ReadInt32())); } - private object ReadLong () { - byte[] bytes = ReadBytes (8); + private object ReadLong() { + byte[] bytes = ReadBytes(8); long res = 0; for (int i = 0; i < 8; i++) { @@ -566,8 +566,8 @@ private object ReadLong () { return res; } - private object ReadBigInteger () { - int encodingSize = ReadInt32 (); + private object ReadBigInteger() { + int encodingSize = ReadInt32(); if (encodingSize == 0) { return BigInteger.Zero; } @@ -579,7 +579,7 @@ private object ReadBigInteger () { } int len = encodingSize * 2; - byte[] bytes = ReadBytes (len); + byte[] bytes = ReadBytes(len); // re-pack our 15-bit values into bytes byte[] data = new byte[bytes.Length]; @@ -613,7 +613,7 @@ private object ReadBigInteger () { } // and finally pass the data onto the big integer. - BigInteger res = new BigInteger (data); + BigInteger res = new BigInteger(data); return sign < 0 ? -res : res; } } diff --git a/Src/IronPython/Runtime/Operations/NamespaceTrackerOps.cs b/Src/IronPython/Runtime/Operations/NamespaceTrackerOps.cs index 2b1b335b9..97917f17a 100644 --- a/Src/IronPython/Runtime/Operations/NamespaceTrackerOps.cs +++ b/Src/IronPython/Runtime/Operations/NamespaceTrackerOps.cs @@ -4,17 +4,14 @@ #nullable enable -using System; -using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Text; -using Microsoft.Scripting; +using IronPython.Runtime.Types; + using Microsoft.Scripting.Actions; using Microsoft.Scripting.Runtime; -using IronPython.Runtime.Types; - namespace IronPython.Runtime.Operations { public static class NamespaceTrackerOps { [SpecialName, PropertyMethod] diff --git a/Src/IronPython/Runtime/Operations/ObjectOps.cs b/Src/IronPython/Runtime/Operations/ObjectOps.cs index 058259ba5..a34032f87 100644 --- a/Src/IronPython/Runtime/Operations/ObjectOps.cs +++ b/Src/IronPython/Runtime/Operations/ObjectOps.cs @@ -6,15 +6,13 @@ using System; using System.Collections.Generic; -using System.Numerics; using System.Reflection; using System.Threading; +using IronPython.Runtime.Types; + using Microsoft.Scripting; using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - -using IronPython.Runtime.Types; namespace IronPython.Runtime.Operations { @@ -74,7 +72,7 @@ public static void __init__(CodeContext/*!*/ context, object self, [NotNone] par /// /// Initializes the object. The base class does nothing. /// - public static void __init__(CodeContext/*!*/ context, object self, [ParamDictionary]IDictionary kwargs, params object[] args\u00F8) { + public static void __init__(CodeContext/*!*/ context, object self, [ParamDictionary] IDictionary kwargs, params object[] args\u00F8) { InstanceOps.CheckInitArgs(context, kwargs, args\u00F8, self); } @@ -108,7 +106,7 @@ public static object __new__(CodeContext/*!*/ context, PythonType cls, [NotNone] /// Creates a new instance of the type /// [StaticExtensionMethod] - public static object __new__(CodeContext/*!*/ context, PythonType cls, [ParamDictionary]IDictionary kwargs\u00F8, [NotNone] params object[] args\u00F8) { + public static object __new__(CodeContext/*!*/ context, PythonType cls, [ParamDictionary] IDictionary kwargs\u00F8, [NotNone] params object[] args\u00F8) { if (cls == null) { throw PythonOps.TypeError("__new__ expected type object, got {0}", PythonOps.Repr(context, DynamicHelpers.GetPythonType(cls))); } diff --git a/Src/IronPython/Runtime/Operations/PythonCalls.cs b/Src/IronPython/Runtime/Operations/PythonCalls.cs index 5ef15414b..6135391bf 100644 --- a/Src/IronPython/Runtime/Operations/PythonCalls.cs +++ b/Src/IronPython/Runtime/Operations/PythonCalls.cs @@ -4,9 +4,7 @@ #nullable enable -using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; namespace IronPython.Runtime.Operations { public static partial class PythonCalls { diff --git a/Src/IronPython/Runtime/Operations/PythonOps.cs b/Src/IronPython/Runtime/Operations/PythonOps.cs index 380c5006f..aad57dd2b 100644 --- a/Src/IronPython/Runtime/Operations/PythonOps.cs +++ b/Src/IronPython/Runtime/Operations/PythonOps.cs @@ -23,6 +23,13 @@ using System.Text; using System.Threading; +using IronPython.Compiler; +using IronPython.Hosting; +using IronPython.Modules; +using IronPython.Runtime.Binding; +using IronPython.Runtime.Exceptions; +using IronPython.Runtime.Types; + using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Ast; @@ -32,13 +39,6 @@ using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Compiler; -using IronPython.Hosting; -using IronPython.Modules; -using IronPython.Runtime.Binding; -using IronPython.Runtime.Exceptions; -using IronPython.Runtime.Types; - using NotNullAttribute = System.Diagnostics.CodeAnalysis.NotNullAttribute; namespace IronPython.Runtime.Operations { @@ -107,7 +107,7 @@ public static PythonDictionary MakeHomogeneousDictFromItems(object[] data) { return new PythonDictionary(new CommonDictionaryStorage(data, true)); } - public static bool IsCallable(CodeContext/*!*/ context, [NotNullWhen(true)]object? o) { + public static bool IsCallable(CodeContext/*!*/ context, [NotNullWhen(true)] object? o) { // This tells if an object can be called, but does not make a claim about the parameter list. // In 1.x, we could check for certain interfaces like ICallable*, but those interfaces were deprecated // in favor of dynamic sites. @@ -391,7 +391,7 @@ internal static bool IsSubClass(PythonType/*!*/ c, PythonType/*!*/ typeinfo) { return typeinfo.__subclasscheck__(c); } - internal static bool IsSubClass(CodeContext/*!*/ context, PythonType c, [NotNull]object? typeinfo) { + internal static bool IsSubClass(CodeContext/*!*/ context, PythonType c, [NotNull] object? typeinfo) { if (c == null) throw PythonOps.TypeError("issubclass: arg 1 must be a class"); if (typeinfo == null) throw PythonOps.TypeError("issubclass: arg 2 must be a class"); @@ -476,7 +476,7 @@ internal static bool IsInstance(CodeContext/*!*/ context, object? o, PythonTuple } // used by Ironclad - public static bool IsInstance(CodeContext/*!*/ context, object? o, [NotNull]object? typeinfo) { + public static bool IsInstance(CodeContext/*!*/ context, object? o, [NotNull] object? typeinfo) { if (typeinfo == null) throw PythonOps.TypeError("isinstance: arg 2 must be a class, type, or tuple of classes and types"); if (typeinfo is PythonTuple tt) { @@ -505,7 +505,7 @@ private static bool IsInstanceDynamic(object? o, object typeinfo, PythonType odt return false; } - private static bool IsSubclassSlow([NotNullWhen(true)]object? cls, object typeinfo) { + private static bool IsSubclassSlow([NotNullWhen(true)] object? cls, object typeinfo) { if (cls == null) return false; // Same type @@ -2178,7 +2178,7 @@ public static object GetEnumeratorObject(CodeContext/*!*/ context, object? o) { throw TypeErrorForNotIterable(o); } - private static bool TryGetEnumeratorObject(CodeContext/*!*/ context, object? o, [NotNullWhen(true)]out object? enumerator) { + private static bool TryGetEnumeratorObject(CodeContext/*!*/ context, object? o, [NotNullWhen(true)] out object? enumerator) { // IronPython defines __getitem__ on PythonType (to support generics and .NET enums) // which would make it "iterable" even though it is not. if (o is PythonType pt && !pt.IsIterable(context)) { @@ -2212,7 +2212,7 @@ public static KeyValuePair ThrowTypeErrorForBadIterati throw PythonOps.TypeError("iteration over non-sequence of type {0}", PythonOps.GetPythonTypeName(enumerable)); } - internal static bool TryGetEnumerator(CodeContext/*!*/ context, [NotNullWhen(true)]object? enumerable, [NotNullWhen(true)]out IEnumerator? enumerator) { + internal static bool TryGetEnumerator(CodeContext/*!*/ context, [NotNullWhen(true)] object? enumerable, [NotNullWhen(true)] out IEnumerator? enumerator) { enumerator = null; // IronPython defines __getitem__ on PythonType (to support generics and .NET enums) @@ -2856,7 +2856,7 @@ public static object GetInitSlotMember(CodeContext/*!*/ context, PythonType type /// Helper to determine if the value is a simple numeric type (int or big int or bool) - used for OldInstance /// deprecated form of slicing. /// - public static bool IsNumericObject([NotNullWhen(true)]object? value) { + public static bool IsNumericObject([NotNullWhen(true)] object? value) { return value is int || value is BigInteger || value is Extensible || value is bool; } @@ -2920,8 +2920,7 @@ internal static MethodInfo GetConversionHelper(string name, ConversionResultKind } public static object ConvertToPythonPrimitive(object value) { - return value switch - { + return value switch { float f => (double)f, sbyte sb => (int)sb, byte b => (int)b, @@ -4078,7 +4077,7 @@ public static Exception TypeErrorForArgumentCountMismatch(string methodName, int methodName, expectedArgCount, expectedArgCount == 1 ? "" : "s", actualArgCount); } - public static Exception TypeErrorForOptionalArgumentCountMismatch(string methodName, int expectedArgCount, int actualArgCount, bool positional=false) { + public static Exception TypeErrorForOptionalArgumentCountMismatch(string methodName, int expectedArgCount, int actualArgCount, bool positional = false) { return TypeError("{0}() takes at most {1} {2}argument{3} ({4} given)", methodName, expectedArgCount, positional ? "positional " : "", expectedArgCount == 1 ? "" : "s", actualArgCount); } diff --git a/Src/IronPython/Runtime/Operations/PythonTypeOps.cs b/Src/IronPython/Runtime/Operations/PythonTypeOps.cs index 9edf44394..d6b95d84f 100644 --- a/Src/IronPython/Runtime/Operations/PythonTypeOps.cs +++ b/Src/IronPython/Runtime/Operations/PythonTypeOps.cs @@ -5,11 +5,13 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Reflection; using System.Dynamic; using System.Linq; +using System.Reflection; + using IronPython.Runtime.Binding; using IronPython.Runtime.Types; + using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Generation; @@ -83,7 +85,7 @@ internal static object CallWorker(CodeContext/*!*/ context, PythonType dt, IDict argNames[i++ - args.Length] = kvp.Key; } - return CallWorker(context, dt, new KwCallInfo(allArgs, argNames)); + return CallWorker(context, dt, new KwCallInfo(allArgs, argNames)); } internal static object CallWorker(CodeContext/*!*/ context, PythonType dt, KwCallInfo args) { @@ -114,7 +116,7 @@ private static object GetInitMethod(CodeContext/*!*/ context, PythonType dt, obj PythonType cdt = dt.ResolutionOrder[i]; PythonTypeSlot dts; object value; - + if (cdt.TryLookupSlot(context, "__init__", out dts) && dts.TryGetValue(context, newObject, dt, out value)) { return value; @@ -170,7 +172,7 @@ private static bool ShouldInvokeInit(PythonType cls, PythonType newObjectType, i // or if this is the user doing type(x), or if it's a standard // .NET type which doesn't have an __init__ method (this is a perf optimization) return (!cls.IsSystemType || cls.IsPythonType) && - newObjectType.IsSubclassOf(cls) && + newObjectType.IsSubclassOf(cls) && (cls != TypeCache.PythonType || argCnt > 1); } @@ -230,7 +232,7 @@ internal static TrackerTypes GetMemberType(MemberGroup members) { group = FilterNewSlots(group); TrackerTypes tt = GetMemberType(group); - switch(tt) { + switch (tt) { case TrackerTypes.Method: bool checkStatic = false; List mems = new List(); @@ -241,37 +243,37 @@ internal static TrackerTypes GetMemberType(MemberGroup members) { } Type declType = group[0].DeclaringType; - MemberInfo[] memArray = mems.ToArray(); + MemberInfo[] memArray = mems.ToArray(); FunctionType ft = GetMethodFunctionType(declType, memArray, checkStatic); return GetFinalSlotForFunction(GetBuiltinFunction(declType, group[0].Name, name, ft, memArray)); - + case TrackerTypes.Field: return GetReflectedField(((FieldTracker)group[0]).Field); - + case TrackerTypes.Property: - return GetReflectedProperty((PropertyTracker)group[0], group, privateBinding); - + return GetReflectedProperty((PropertyTracker)group[0], group, privateBinding); + case TrackerTypes.Event: return GetReflectedEvent(((EventTracker)group[0])); - + case TrackerTypes.Type: TypeTracker type = (TypeTracker)group[0]; for (int i = 1; i < group.Count; i++) { type = TypeGroup.UpdateTypeEntity(type, (TypeTracker)group[i]); } - + if (type is TypeGroup) { return new PythonTypeUserDescriptorSlot(type, true); } return new PythonTypeUserDescriptorSlot(DynamicHelpers.GetPythonTypeFromType(type.Type), true); - + case TrackerTypes.Constructor: return GetConstructorFunction(group[0].DeclaringType, privateBinding); - + case TrackerTypes.Custom: return ((PythonCustomTracker)group[0]).GetSlot(); - + default: // if we have a new slot in the derived class filter out the // members from the base class. @@ -311,7 +313,7 @@ private static BuiltinFunction GetConstructorFunction(Type t, bool privateBindin return GetConstructor(t, ctorFunc, ctors); } - + internal static MethodBase[] GetConstructors(Type t, bool privateBinding, bool includeProtected = false) { MethodBase[] ctors = CompilerHelpers.GetConstructors(t, privateBinding, includeProtected); if (t.IsEnum) { @@ -320,7 +322,7 @@ internal static MethodBase[] GetConstructors(Type t, bool privateBinding, bool i } return ctors; } - // support for EnumType(number) + // support for EnumType(number) private static T CreateEnum(object value) { if (value == null) { throw PythonOps.ValueError( @@ -364,7 +366,7 @@ internal static BuiltinFunction GetConstructorFunction(Type type, string name) { methods.Add(ci); } } - + if (type.IsValueType && !hasDefaultConstructor && type != typeof(void)) { try { methods.Add(typeof(ScriptingRuntimeHelpers).GetMethod(nameof(ScriptingRuntimeHelpers.CreateInstance), ReflectionUtils.EmptyTypes).MakeGenericMethod(type)); @@ -480,7 +482,7 @@ public static MemberInfo[] GetNonBaseHelperMemberInfos(MemberInfo[] members) { BuiltinFunction res = null; if (mems.Length != 0) { - FunctionType ft = funcType ?? GetMethodFunctionType(type, mems); + FunctionType ft = funcType ?? GetMethodFunctionType(type, mems); type = GetBaseDeclaringType(type, mems); BuiltinFunctionKey cache = new BuiltinFunctionKey(type, new ReflectionCache.MethodBaseCache(cacheName, GetNonBaseHelperMethodInfos(mems)), ft); @@ -540,7 +542,7 @@ private static Type GetCommonBaseType(Type xType, Type yType) { private static Type GetBaseDeclaringType(Type type, MemberInfo/*!*/[] mems) { // get the base most declaring type, first sort the list so that // the most derived class is at the beginning. - Array.Sort(mems, delegate(MemberInfo x, MemberInfo y) { + Array.Sort(mems, delegate (MemberInfo x, MemberInfo y) { if (x.DeclaringType.IsSubclassOf(y.DeclaringType)) { return -1; } else if (y.DeclaringType.IsSubclassOf(x.DeclaringType)) { @@ -602,7 +604,7 @@ internal static FunctionType GetMethodFunctionType(Type/*!*/ type, MemberInfo/*! if (mi.IsStatic && mi.IsSpecialName) { ParameterInfo[] pis = mi.GetParameters(); - if ((pis.Length == 2 && pis[0].ParameterType != typeof(CodeContext)) || + if ((pis.Length == 2 && pis[0].ParameterType != typeof(CodeContext)) || (pis.Length == 3 && pis[0].ParameterType == typeof(CodeContext))) { ft |= FunctionType.BinaryOperator; @@ -657,8 +659,8 @@ private static bool IsMethodAlwaysVisible(Type/*!*/ type, MemberInfo/*!*/[]/*!*/ } } } else if (type.IsAssignableFrom(typeof(int))) { // GH #52 - // only show methods defined outside of int - foreach (MethodInfo mi in methods) { + // only show methods defined outside of int + foreach (MethodInfo mi in methods) { Debug.Assert(!mi.DeclaringType.IsInterface || typeof(int).GetInterfaces().Contains(mi.DeclaringType)); if (PythonBinder.IsPythonSupportingType(mi.DeclaringType) || mi.DeclaringType.IsInterface || @@ -675,7 +677,7 @@ private static bool IsMethodAlwaysVisible(Type/*!*/ type, MemberInfo/*!*/[]/*!*/ /// a function is static if it's a static .NET method and it's defined on the type or is an extension method /// with StaticExtensionMethod decoration. /// - private static bool IsStaticFunction(Type type, MethodInfo mi) { + private static bool IsStaticFunction(Type type, MethodInfo mi) { return mi.IsStatic && // method must be truly static !mi.IsDefined(typeof(WrapperDescriptorAttribute), false) && // wrapper descriptors are instance methods (mi.DeclaringType.IsAssignableFrom(type) || mi.IsDefined(typeof(StaticExtensionMethodAttribute), false)); // or it's not an extension method or it's a static extension method @@ -814,7 +816,7 @@ internal static ReflectedGetterSetter GetReflectedProperty(PropertyTracker pt, M _propertyCache[pt] = rp; return rp; - } + } } private static MethodInfo FilterProtectedGetterOrSetter(MethodInfo info, bool privateBinding) { @@ -884,7 +886,7 @@ internal static bool TryInvokeTernaryOperator(CodeContext context, object o, obj /// internal static PythonTuple EnsureBaseType(PythonTuple bases) { bool hasInterface = false; - foreach (object baseClass in bases) { + foreach (object baseClass in bases) { PythonType dt = baseClass as PythonType; if (!dt.UnderlyingSystemType.IsInterface) { diff --git a/Src/IronPython/Runtime/Operations/StringOps.cs b/Src/IronPython/Runtime/Operations/StringOps.cs index 9a3e98a7c..2fb8bb95c 100644 --- a/Src/IronPython/Runtime/Operations/StringOps.cs +++ b/Src/IronPython/Runtime/Operations/StringOps.cs @@ -16,18 +16,18 @@ using System.Numerics; using System.Reflection; using System.Runtime.InteropServices; -using System.Threading; using System.Text; +using System.Threading; + +using IronPython.Runtime.Exceptions; +using IronPython.Runtime.Types; using Microsoft.Scripting; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Exceptions; -using IronPython.Runtime.Types; - -using SpecialNameAttribute = System.Runtime.CompilerServices.SpecialNameAttribute; using NotNullAttribute = System.Diagnostics.CodeAnalysis.NotNullAttribute; +using SpecialNameAttribute = System.Runtime.CompilerServices.SpecialNameAttribute; namespace IronPython.Runtime.Operations { /// @@ -1318,7 +1318,7 @@ public static string zfill([NotNone] this string self, int width) { /// /// Conversion can be 'r' for repr or 's' for string. /// - public static string/*!*/ format(CodeContext/*!*/ context, [NotNone] string format_string\u00F8, [ParamDictionary]IDictionary kwargs\u00F8, params object[] args\u00F8) { + public static string/*!*/ format(CodeContext/*!*/ context, [NotNone] string format_string\u00F8, [ParamDictionary] IDictionary kwargs\u00F8, params object[] args\u00F8) { return NewStringFormatter.FormatString( context.LanguageContext, format_string\u00F8, @@ -1729,7 +1729,7 @@ private static string RawUnicodeEscapeEncode(string s, int start, int count, boo return b?.ToString() ?? s.Substring(start, count); } - private static void StringBuilderInit([NotNull]ref StringBuilder? sb, string s, int start, int end) { + private static void StringBuilderInit([NotNull] ref StringBuilder? sb, string s, int start, int end) { if (sb != null) return; sb = new StringBuilder(s.Length); @@ -1912,7 +1912,7 @@ internal static Bytes RawEncode(CodeContext/*!*/ context, string s, string encod internal static Bytes DoEncodeAscii(string s) => DoEncode(DefaultContext.Default, s, "strict", "ascii", Encoding.ASCII, includePreamble: false); - internal static bool TryEncodeAscii(string s, [NotNullWhen(true)]out Bytes? b) { + internal static bool TryEncodeAscii(string s, [NotNullWhen(true)] out Bytes? b) { try { b = DoEncodeAscii(s); return true; @@ -2012,17 +2012,17 @@ static CodecsInfo() { // set up well-known/often-used mappings d["iso_8859_1"] = d["iso8859_1"] = d["8859"] = d["iso8859"] = d["cp28591"] = d["28591"] = d["cp819"] = d["819"] - = d["latin_1"] = d["latin1"] = d["latin"] = d["l1"] = makeEncodingProxy(() => Latin1Encoding); + = d["latin_1"] = d["latin1"] = d["latin"] = d["l1"] = makeEncodingProxy(() => Latin1Encoding); d["cp20127"] = d["us_ascii"] = d["us"] = d["ascii"] = d["646"] = makeEncodingProxy(() => Encoding.ASCII); - d["cp65000"] = d["utf_7"] = d["u7"] = d["unicode_1_1_utf_7"] = makeEncodingProxy(() => new UTF7Encoding(allowOptionals: true)); - d["cp65001"] = d["utf_8"] = d["utf8"] = d["u8"] = makeEncodingProxy(() => new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); - d["utf_8_sig"] = makeEncodingProxy(() => new UTF8Encoding(encoderShouldEmitUTF8Identifier: true)); - d["utf_16le"] = d["utf_16_le"] = makeEncodingProxy(() => new UnicodeEncoding(bigEndian: false, byteOrderMark: false)); - d["cp1200"] = d["utf_16"] = d["utf16"] = d["u16"] = makeEncodingProxy(() => new UnicodeEncoding(bigEndian: !BitConverter.IsLittleEndian, byteOrderMark: true)); - d["cp1201"] = d["utf_16be"] = d["utf_16_be"] = makeEncodingProxy(() => new UnicodeEncoding(bigEndian: true, byteOrderMark: false)); - d["utf_32le"] = d["utf_32_le"] = makeEncodingProxy(() => new UTF32Encoding(bigEndian: false, byteOrderMark: false)); - d["cp12000"] = d["utf_32"] = d["utf32"] = d["u32"] = makeEncodingProxy(() => new UTF32Encoding(bigEndian: !BitConverter.IsLittleEndian, byteOrderMark: true)); - d["cp12001"] = d["utf_32be"] = d["utf_32_be"] = makeEncodingProxy(() => new UTF32Encoding(bigEndian: true, byteOrderMark: false)); + d["cp65000"] = d["utf_7"] = d["u7"] = d["unicode_1_1_utf_7"] = makeEncodingProxy(() => new UTF7Encoding(allowOptionals: true)); + d["cp65001"] = d["utf_8"] = d["utf8"] = d["u8"] = makeEncodingProxy(() => new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); + d["utf_8_sig"] = makeEncodingProxy(() => new UTF8Encoding(encoderShouldEmitUTF8Identifier: true)); + d["utf_16le"] = d["utf_16_le"] = makeEncodingProxy(() => new UnicodeEncoding(bigEndian: false, byteOrderMark: false)); + d["cp1200"] = d["utf_16"] = d["utf16"] = d["u16"] = makeEncodingProxy(() => new UnicodeEncoding(bigEndian: !BitConverter.IsLittleEndian, byteOrderMark: true)); + d["cp1201"] = d["utf_16be"] = d["utf_16_be"] = makeEncodingProxy(() => new UnicodeEncoding(bigEndian: true, byteOrderMark: false)); + d["utf_32le"] = d["utf_32_le"] = makeEncodingProxy(() => new UTF32Encoding(bigEndian: false, byteOrderMark: false)); + d["cp12000"] = d["utf_32"] = d["utf32"] = d["u32"] = makeEncodingProxy(() => new UTF32Encoding(bigEndian: !BitConverter.IsLittleEndian, byteOrderMark: true)); + d["cp12001"] = d["utf_32be"] = d["utf_32_be"] = makeEncodingProxy(() => new UTF32Encoding(bigEndian: true, byteOrderMark: false)); // set up internal codecs d["raw_unicode_escape"] = makeEncodingProxy(() => RawUnicodeEscapeEncoding); @@ -2079,9 +2079,9 @@ static CodecsInfo() { #if DEBUG foreach (KeyValuePair> kvp in d) { // all codecs should be stored in lowercase because we only look up from lowercase strings - #pragma warning disable CA1862 // disable warning about comparing with ToLower() +#pragma warning disable CA1862 // disable warning about comparing with ToLower() Debug.Assert(kvp.Key.ToLower(CultureInfo.InvariantCulture) == kvp.Key); - #pragma warning restore +#pragma warning restore // all codec names should use underscores instead of dashes to match lookup values Debug.Assert(kvp.Key.IndexOf('-') < 0); } @@ -2173,7 +2173,7 @@ private static PythonList SplitInternal(string self, string separator, int maxsp } } - private static void AssertStringOrTuple([NotNull]object? prefix) { + private static void AssertStringOrTuple([NotNull] object? prefix) { if (prefix == null) { throw PythonOps.TypeError("expected string or tuple, got NoneType"); } @@ -2731,7 +2731,7 @@ static string NameReplaceEncode(string s, int start, int count) { } private delegate string? DecodeErrorHandler(IList bytes, int start, ref int end); - private delegate Bytes? EncodeErrorHandler(string text, int start, ref int end); + private delegate Bytes? EncodeErrorHandler(string text, int start, ref int end); private static object SurrogateEscapeErrors(object unicodeError) { return SurrogateErrorsImpl(unicodeError, surrogateEscapeDecode, surrogateEscapeEncode); @@ -2890,7 +2890,7 @@ private static object SurrogateErrorsImpl(object unicodeError, DecodeErrorHandle int end = dfe.BytesUnknown.Length; string? res = decodeFallback(dfe.BytesUnknown, 0, ref end); if (res == null) throw dfe; - return PythonTuple.MakeTuple(res, dfe.Index + end); + return PythonTuple.MakeTuple(res, dfe.Index + end); } case EncoderFallbackException efe: { diff --git a/Src/IronPython/Runtime/Operations/TypeGroupOps.cs b/Src/IronPython/Runtime/Operations/TypeGroupOps.cs index 19354664c..af109c56e 100644 --- a/Src/IronPython/Runtime/Operations/TypeGroupOps.cs +++ b/Src/IronPython/Runtime/Operations/TypeGroupOps.cs @@ -20,8 +20,8 @@ public static class TypeGroupOps { public static string __repr__(TypeGroup self) { StringBuilder sb = new StringBuilder(" MakeGetBinding(CodeContext codeCont } return (Binding.FastBindResult)(object)new Binding.MetaUserObject.FastGetBinderHelper( codeContext, - (CallSite>)(object)site, - self, + (CallSite>)(object)site, + self, getBinder).GetBinding(codeContext, getBinder.Name); } @@ -390,7 +388,7 @@ internal static FastBindResult MakeSetBinding(CodeContext codeContext, Cal /// public class UserTypeDebugView { private readonly IPythonObject _userObject; - + public UserTypeDebugView(IPythonObject userObject) { _userObject = userObject; } @@ -416,8 +414,8 @@ internal List Members { if (slots != null) { var mro = _userObject.PythonType.ResolutionOrder; List slotNames = new List(); - - for(int i = mro.Count - 1; i>= 0; i--) { + + for (int i = mro.Count - 1; i >= 0; i--) { slotNames.AddRange(mro[i].GetTypeSlots()); } diff --git a/Src/IronPython/Runtime/OutputWriter.cs b/Src/IronPython/Runtime/OutputWriter.cs index 6aca910a9..d56465dfb 100644 --- a/Src/IronPython/Runtime/OutputWriter.cs +++ b/Src/IronPython/Runtime/OutputWriter.cs @@ -5,8 +5,9 @@ using System; using System.IO; using System.Text; + using IronPython.Runtime.Operations; -using Microsoft.Scripting; + using Microsoft.Scripting.Utils; namespace IronPython.Runtime { diff --git a/Src/IronPython/Runtime/Profiler.cs b/Src/IronPython/Runtime/Profiler.cs index bc0d245e4..1e0dbe5cd 100644 --- a/Src/IronPython/Runtime/Profiler.cs +++ b/Src/IronPython/Runtime/Profiler.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using MSAst = System.Linq.Expressions; - using System; using System.Collections.Generic; using System.Diagnostics; @@ -12,10 +10,11 @@ using System.Text; using System.Threading; +using IronPython.Compiler; + using Microsoft.Scripting; -using Microsoft.Scripting.Actions.Calls; -using IronPython.Compiler; +using MSAst = System.Linq.Expressions; namespace IronPython.Runtime { using Ast = MSAst.Expression; @@ -226,7 +225,7 @@ internal MSAst.Expression AddOuterProfiling(MSAst.Expression/*!*/ body, MSAst.Pa AstUtils.Constant(profileIndex) ) ), - AstUtils.Try( + AstUtils.Try( body ).Finally( Ast.Call( diff --git a/Src/IronPython/Runtime/PythonContext.cs b/Src/IronPython/Runtime/PythonContext.cs index d13d72a75..697a6f524 100644 --- a/Src/IronPython/Runtime/PythonContext.cs +++ b/Src/IronPython/Runtime/PythonContext.cs @@ -18,13 +18,6 @@ using System.Text; using System.Threading; -using Microsoft.Scripting; -using Microsoft.Scripting.Actions; -using Microsoft.Scripting.Debugging.CompilerServices; -using Microsoft.Scripting.Generation; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - using IronPython.Compiler; using IronPython.Hosting; using IronPython.Modules; @@ -33,6 +26,13 @@ using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting; +using Microsoft.Scripting.Actions; +using Microsoft.Scripting.Debugging.CompilerServices; +using Microsoft.Scripting.Generation; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + using Debugging = Microsoft.Scripting.Debugging; using PyAst = IronPython.Compiler.Ast; diff --git a/Src/IronPython/Runtime/PythonDictionary.cs b/Src/IronPython/Runtime/PythonDictionary.cs index 8a6033482..65b36998d 100644 --- a/Src/IronPython/Runtime/PythonDictionary.cs +++ b/Src/IronPython/Runtime/PythonDictionary.cs @@ -10,12 +10,12 @@ using System.Security; using System.Text; -using Microsoft.Scripting; -using Microsoft.Scripting.Runtime; - using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting; +using Microsoft.Scripting.Runtime; + namespace IronPython.Runtime { [PythonType("dict"), Serializable, DebuggerTypeProxy(typeof(DebugProxy)), DebuggerDisplay("Count = {Count}")] @@ -87,12 +87,12 @@ internal static PythonDictionary MakeSymbolDictionary(int count) { return new PythonDictionary(new StringDictionaryStorage(count)); } - public void __init__(CodeContext/*!*/ context, object o\u00F8, [ParamDictionary]IDictionary kwArgs) { + public void __init__(CodeContext/*!*/ context, object o\u00F8, [ParamDictionary] IDictionary kwArgs) { update(context, o\u00F8); update(context, kwArgs); } - public void __init__(CodeContext/*!*/ context, [ParamDictionary]IDictionary kwArgs) { + public void __init__(CodeContext/*!*/ context, [ParamDictionary] IDictionary kwArgs) { update(context, kwArgs); } @@ -356,7 +356,7 @@ public object setdefault(object key, object defaultValue) { public void update() { } - public void update(CodeContext/*!*/ context, [ParamDictionary]IDictionary other\u00F8) { + public void update(CodeContext/*!*/ context, [ParamDictionary] IDictionary other\u00F8) { DictionaryOps.update(context, this, other\u00F8); } @@ -364,7 +364,7 @@ public void update(CodeContext/*!*/ context, object other\u00F8) { DictionaryOps.update(context, this, other\u00F8); } - public void update(CodeContext/*!*/ context, object other\u00F8, [ParamDictionary]IDictionary otherArgs\u00F8) { + public void update(CodeContext/*!*/ context, object other\u00F8, [ParamDictionary] IDictionary otherArgs\u00F8) { DictionaryOps.update(context, this, other\u00F8); DictionaryOps.update(context, this, otherArgs\u00F8); } @@ -1491,7 +1491,7 @@ void ICollection.CopyTo(object[] array, int arrayIndex) { int ICollection.Count => _dict.Count; - bool ICollection.IsReadOnly => true; + bool ICollection.IsReadOnly => true; bool ICollection.Remove(object item) => throw new NotSupportedException("Collection is read-only"); diff --git a/Src/IronPython/Runtime/PythonDocumentationProvider.cs b/Src/IronPython/Runtime/PythonDocumentationProvider.cs index adc89c53b..572cb8bb2 100644 --- a/Src/IronPython/Runtime/PythonDocumentationProvider.cs +++ b/Src/IronPython/Runtime/PythonDocumentationProvider.cs @@ -6,13 +6,11 @@ using System.Collections.Generic; using System.Reflection; -using Microsoft.Scripting; +using IronPython.Runtime.Types; + using Microsoft.Scripting.Actions; using Microsoft.Scripting.Hosting; using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - -using IronPython.Runtime.Types; namespace IronPython.Runtime { internal class PythonDocumentationProvider : DocumentationProvider { @@ -79,7 +77,7 @@ private static MemberDoc MakeMemberDoc(string name, object value, bool fromClass if (value is BuiltinFunction) { kind = MemberKind.Function; } else if (value is NamespaceTracker) { - kind = MemberKind.Namespace; + kind = MemberKind.Namespace; } else if (value is PythonFunction) { kind = fromClass ? MemberKind.Method : MemberKind.Function; } else if (value is BuiltinMethodDescriptor || value is Method) { @@ -123,7 +121,7 @@ public override ICollection GetOverloads(object value) { } if (value is PythonFunction pf) { - return new[] { + return new[] { new OverloadDoc( pf.__name__, pf.__doc__ as string, diff --git a/Src/IronPython/Runtime/PythonDynamicStackFrame.cs b/Src/IronPython/Runtime/PythonDynamicStackFrame.cs index e9ad9984a..9dda5b494 100644 --- a/Src/IronPython/Runtime/PythonDynamicStackFrame.cs +++ b/Src/IronPython/Runtime/PythonDynamicStackFrame.cs @@ -17,8 +17,7 @@ namespace IronPython.Runtime { /// function code object which is needed to build frame objects from. /// [Serializable] - internal sealed class PythonDynamicStackFrame : DynamicStackFrame, ISerializable - { + internal sealed class PythonDynamicStackFrame : DynamicStackFrame, ISerializable { private readonly CodeContext _context; private readonly FunctionCode _code; diff --git a/Src/IronPython/Runtime/PythonEncoding.cs b/Src/IronPython/Runtime/PythonEncoding.cs index da40a4bb9..fe7c00c4e 100644 --- a/Src/IronPython/Runtime/PythonEncoding.cs +++ b/Src/IronPython/Runtime/PythonEncoding.cs @@ -4,11 +4,6 @@ #nullable enable -using IronPython.Runtime.Exceptions; -using IronPython.Runtime.Operations; - -using Microsoft.Scripting.Runtime; - using System; using System.Collections.Generic; using System.Diagnostics; @@ -17,6 +12,11 @@ using System.Runtime.InteropServices; using System.Text; +using IronPython.Runtime.Exceptions; +using IronPython.Runtime.Operations; + +using Microsoft.Scripting.Runtime; + namespace IronPython.Runtime { /// @@ -953,7 +953,7 @@ public override Tuple, ReadOnlyMemory> GetFallbackCha if ((runeUnknown & ~0xff) != LoneSurrogateBase) { // EncoderFallbackException(string, char, int) is not accessible here throw PythonOps.UnicodeEncodeError( - $"'surrogateescape' error handler: value not in range(0x{LoneSurrogateBase:x4}, 0x{LoneSurrogateBase+0x100:x4})", + $"'surrogateescape' error handler: value not in range(0x{LoneSurrogateBase:x4}, 0x{LoneSurrogateBase + 0x100:x4})", runeUnknown, index ); @@ -1262,7 +1262,7 @@ public override void Reset() { _buffer = null; } - protected void Throw(byte[] bytesUnknown, int index) + protected void Throw(byte[] bytesUnknown, int index) => throw new DecoderFallbackException($"'surrogatepass' error handler: not a surrogate character", bytesUnknown, index); } } @@ -1453,7 +1453,7 @@ public override void FinalizeIncrement(int endIndex, bool flush) { int retain = _previousData.Length - span.Length; if (retain <= 0) { _previousDataLen = 0; - } else if (retain < _previousDataLen) { + } else if (retain < _previousDataLen) { Array.Copy(_previousData, _previousDataLen - retain, _previousData, 0, retain); _previousDataLen = retain; } diff --git a/Src/IronPython/Runtime/PythonFileManager.cs b/Src/IronPython/Runtime/PythonFileManager.cs index 5070b9ffa..9e919ee36 100644 --- a/Src/IronPython/Runtime/PythonFileManager.cs +++ b/Src/IronPython/Runtime/PythonFileManager.cs @@ -8,15 +8,15 @@ using System.Buffers; using System.Collections.Concurrent; using System.Collections.Generic; +using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; +using IronPython.Runtime.Operations; + using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Operations; -using System.Diagnostics; - namespace IronPython.Runtime { /// @@ -96,7 +96,7 @@ bool isattyUnix() { } } - public long Truncate(long size) { + public long Truncate(long size) { long pos = _readStream.Position; _writeStream.SetLength(size); _readStream.Seek(pos, SeekOrigin.Begin); @@ -268,7 +268,7 @@ public bool TryGetStreams(int id, [NotNullWhen(true)] out StreamBox? streams) { public StreamBox GetStreams(int id) { if (TryGetStreams(id, out StreamBox? streams)) { - return streams; + return streams; } throw PythonOps.OSError(9, "Bad file descriptor"); } @@ -290,7 +290,7 @@ public void EnsureRefStreams(StreamBox streams) { public void AddRefStreams(StreamBox streams) { Debug.Assert(streams.Id >= 0); - _refs.AddOrUpdate(streams.ReadStream, 1, (_, v) => v + 1); + _refs.AddOrUpdate(streams.ReadStream, 1, (_, v) => v + 1); } public bool DerefStreamsAndCloseIfLast(StreamBox streams) { diff --git a/Src/IronPython/Runtime/PythonFunction.cs b/Src/IronPython/Runtime/PythonFunction.cs index 104dd3bf2..26976433f 100644 --- a/Src/IronPython/Runtime/PythonFunction.cs +++ b/Src/IronPython/Runtime/PythonFunction.cs @@ -99,7 +99,7 @@ internal PythonFunction(CodeContext/*!*/ context, FunctionCode funcInfo, object _annotations = annotations ?? new PythonDictionary(); Debug.Assert(_defaults.Length <= _code.co_argcount); - Debug.Assert((__kwdefaults__ ?.Count ?? 0) <= _code.co_kwonlyargcount); + Debug.Assert((__kwdefaults__?.Count ?? 0) <= _code.co_kwonlyargcount); if (modName != Uninitialized.Instance) { _module = modName; } @@ -211,7 +211,7 @@ public object __module__ { public FunctionCode __code__ { get { - return _code; + return _code; } set { if (value == null) { @@ -226,7 +226,7 @@ public object __call__(CodeContext/*!*/ context, params object[] args) { return PythonCalls.Call(context, this, args); } - public object __call__(CodeContext/*!*/ context, [ParamDictionary]IDictionary dict, params object[] args) { + public object __call__(CodeContext/*!*/ context, [ParamDictionary] IDictionary dict, params object[] args) { return PythonCalls.CallWithKeywordArgs(context, this, args, dict); } @@ -417,7 +417,7 @@ internal Exception BadKeywordArgumentError(int count) { } #endregion - + #region Custom member lookup operators IList IMembersList.GetMemberNames() { @@ -471,7 +471,7 @@ internal PythonDictionary EnsureDict() { } return _dict; } - + internal static int AddRecursionDepth(int change) { // ManagedThreadId starts at 1 and increases as we get more threads. // Therefore we keep track of a limited number of threads in an array @@ -523,8 +523,7 @@ internal override bool TryGetValue(CodeContext context, object instance, PythonT } [PythonType("cell")] - public sealed class ClosureCell : ICodeFormattable - { + public sealed class ClosureCell : ICodeFormattable { [PythonHidden] public object Value; diff --git a/Src/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs b/Src/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs index 30cd90a43..391d7e488 100644 --- a/Src/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs +++ b/Src/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace IronPython.Runtime { /// diff --git a/Src/IronPython/Runtime/PythonList.cs b/Src/IronPython/Runtime/PythonList.cs index 94c525199..b83898b96 100644 --- a/Src/IronPython/Runtime/PythonList.cs +++ b/Src/IronPython/Runtime/PythonList.cs @@ -12,15 +12,14 @@ using System.Text; using System.Threading; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + using Microsoft.Scripting; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Exceptions; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using SpecialNameAttribute = System.Runtime.CompilerServices.SpecialNameAttribute; namespace IronPython.Runtime { diff --git a/Src/IronPython/Runtime/PythonModule.cs b/Src/IronPython/Runtime/PythonModule.cs index 377f856b3..440b6f49a 100755 --- a/Src/IronPython/Runtime/PythonModule.cs +++ b/Src/IronPython/Runtime/PythonModule.cs @@ -10,14 +10,14 @@ using System.Runtime.CompilerServices; using System.Threading; -using Microsoft.Scripting; -using Microsoft.Scripting.Ast; -using Microsoft.Scripting.Runtime; - using IronPython.Runtime.Binding; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting; +using Microsoft.Scripting.Ast; +using Microsoft.Scripting.Runtime; + namespace IronPython.Runtime { /// /// Python module. Stores classes, functions, and data. Usually a module @@ -69,7 +69,7 @@ internal PythonModule(PythonDictionary dict) { } [StaticExtensionMethod] - public static PythonModule/*!*/ __new__(CodeContext/*!*/ context, PythonType/*!*/ cls, [ParamDictionary]IDictionary kwDict0, params object[]/*!*/ args\u00F8) { + public static PythonModule/*!*/ __new__(CodeContext/*!*/ context, PythonType/*!*/ cls, [ParamDictionary] IDictionary kwDict0, params object[]/*!*/ args\u00F8) { return __new__(context, cls, args\u00F8); } @@ -255,7 +255,7 @@ public DynamicMetaObject GetMember(PythonGetMemberBinder member, DynamicMetaObje private DynamicMetaObject GetMemberWorker(DynamicMetaObjectBinder binder, DynamicMetaObject codeContext) { string name = GetGetMemberName(binder); - var tmp = Expression.Variable(typeof(object), "res"); + var tmp = Expression.Variable(typeof(object), "res"); return new DynamicMetaObject( Expression.Block( @@ -360,7 +360,7 @@ IList IMembersList.GetMemberNames() { } #endregion - + internal class DebugProxy { private readonly PythonModule _module; @@ -380,6 +380,6 @@ public List Members { } } - + } } diff --git a/Src/IronPython/Runtime/PythonOptions.cs b/Src/IronPython/Runtime/PythonOptions.cs index 92125273f..3bde88d31 100644 --- a/Src/IronPython/Runtime/PythonOptions.cs +++ b/Src/IronPython/Runtime/PythonOptions.cs @@ -134,7 +134,7 @@ public sealed class PythonOptions : LanguageOptions { internal bool NoImportLib { get; } // TODO: get rid of me when we no longer bootstrap importlib - public PythonOptions() + public PythonOptions() : this(null) { } @@ -172,8 +172,8 @@ private static IDictionary EnsureSearchPaths(IDictionary() { { "SearchPaths", new[] { "." } } }; } else if (!options.ContainsKey("SearchPaths")) { - options["SearchPaths"] = new [] { "." }; - } + options["SearchPaths"] = new[] { "." }; + } return options; } diff --git a/Src/IronPython/Runtime/PythonScopeExtension.cs b/Src/IronPython/Runtime/PythonScopeExtension.cs index 3adb330b5..bad00ed33 100644 --- a/Src/IronPython/Runtime/PythonScopeExtension.cs +++ b/Src/IronPython/Runtime/PythonScopeExtension.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; using System.Threading; diff --git a/Src/IronPython/Runtime/PythonStrIterator.cs b/Src/IronPython/Runtime/PythonStrIterator.cs index 29f390338..02c04b350 100644 --- a/Src/IronPython/Runtime/PythonStrIterator.cs +++ b/Src/IronPython/Runtime/PythonStrIterator.cs @@ -7,12 +7,12 @@ using System.Collections; using System.Collections.Generic; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Types; -using IronPython.Runtime.Operations; - namespace IronPython.Runtime { // note: any changes in how this iterator works should also be applied in the // optimized overloads of Builtins.map() diff --git a/Src/IronPython/Runtime/PythonTracebackListener.cs b/Src/IronPython/Runtime/PythonTracebackListener.cs index ab96e1027..cd1f81629 100644 --- a/Src/IronPython/Runtime/PythonTracebackListener.cs +++ b/Src/IronPython/Runtime/PythonTracebackListener.cs @@ -5,13 +5,13 @@ using System; using System.Collections.Generic; -using Microsoft.Scripting; - using IronPython.Modules; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting; + using Debugging = Microsoft.Scripting.Debugging; namespace IronPython.Runtime { @@ -21,7 +21,7 @@ internal sealed class PythonTracebackListener : Debugging.ITraceCallback { private TracebackDelegate _traceDispatch; private bool _inTraceBack; private bool _exceptionThrown; - + #if PROFILE_SUPPORT private bool _profile; #endif @@ -72,7 +72,7 @@ internal void SetProfile(TracebackDelegate traceDispatch) { #region ITraceCallback Members - public void OnTraceEvent(Debugging.TraceEventKind kind, string name, string sourceFileName, SourceSpan sourceSpan, Func> scopeCallback, object payload, object customPayload) { + public void OnTraceEvent(Debugging.TraceEventKind kind, string name, string sourceFileName, SourceSpan sourceSpan, Func> scopeCallback, object payload, object customPayload) { if (kind == Debugging.TraceEventKind.ThreadExit || // We don't care about thread-exit events #if PROFILE_SUPPORT (_profile && kind == Debugging.TraceEventKind.TracePoint) || // Ignore code execute tracebacks when in profile mode @@ -111,7 +111,7 @@ public void OnTraceEvent(Debugging.TraceEventKind kind, string name, string sour if (traceDispatchObject == null) { return; } - + pyFrame.Setf_trace(traceDispatchObject); } else { if (thread.Count == 0) { @@ -141,12 +141,12 @@ public void OnTraceEvent(Debugging.TraceEventKind kind, string name, string sour thread.RemoveAt(thread.Count - 1); } } - } + } } #endregion - + private void DispatchTrace(List thread, Debugging.TraceEventKind kind, object payload, TracebackDelegate traceDispatch, object traceDispatchObject, TraceBackFrame pyFrame) { object args = null; diff --git a/Src/IronPython/Runtime/PythonTuple.cs b/Src/IronPython/Runtime/PythonTuple.cs index bdc5fd887..51e048af9 100644 --- a/Src/IronPython/Runtime/PythonTuple.cs +++ b/Src/IronPython/Runtime/PythonTuple.cs @@ -13,7 +13,6 @@ using System.Numerics; using System.Text; -using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; @@ -29,7 +28,7 @@ public class PythonTuple : IList, IList, ICodeFormattable, IExpressionS internal static readonly PythonTuple EMPTY = new PythonTuple(); - public PythonTuple([AllowNull]object o) { + public PythonTuple([AllowNull] object o) { _data = MakeItems(o); } diff --git a/Src/IronPython/Runtime/PythonTypeAttribute.cs b/Src/IronPython/Runtime/PythonTypeAttribute.cs index 32bb9e576..c05b5d966 100644 --- a/Src/IronPython/Runtime/PythonTypeAttribute.cs +++ b/Src/IronPython/Runtime/PythonTypeAttribute.cs @@ -3,8 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; -using System.Text; namespace IronPython.Runtime { /// diff --git a/Src/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs b/Src/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs index 2b6f3e216..53418ded7 100644 --- a/Src/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs +++ b/Src/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs @@ -4,7 +4,6 @@ #nullable enable -using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/Src/IronPython/Runtime/ScopeDictionaryStorage.cs b/Src/IronPython/Runtime/ScopeDictionaryStorage.cs index f472db7a2..06cb991ad 100644 --- a/Src/IronPython/Runtime/ScopeDictionaryStorage.cs +++ b/Src/IronPython/Runtime/ScopeDictionaryStorage.cs @@ -2,15 +2,13 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using Microsoft.Scripting; +using IronPython.Runtime.Operations; + using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Operations; - namespace IronPython.Runtime { /// /// Provides dictionary based storage which is backed by a Scope object. diff --git a/Src/IronPython/Runtime/SequenceTypeInfoAttribute.cs b/Src/IronPython/Runtime/SequenceTypeInfoAttribute.cs index 87fdd716c..02bc634f7 100644 --- a/Src/IronPython/Runtime/SequenceTypeInfoAttribute.cs +++ b/Src/IronPython/Runtime/SequenceTypeInfoAttribute.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using System.Collections.ObjectModel; namespace IronPython.Runtime { @@ -14,13 +12,13 @@ namespace IronPython.Runtime { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments"), AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, AllowMultiple = false)] public sealed class SequenceTypeInfoAttribute : Attribute { private readonly ReadOnlyCollection _types; - + public SequenceTypeInfoAttribute(params Type[] types) { _types = new ReadOnlyCollection(types); } public ReadOnlyCollection Types { - get{ + get { return _types; } } diff --git a/Src/IronPython/Runtime/SetStorage.cs b/Src/IronPython/Runtime/SetStorage.cs index 10ec4eb01..966a0621c 100644 --- a/Src/IronPython/Runtime/SetStorage.cs +++ b/Src/IronPython/Runtime/SetStorage.cs @@ -9,14 +9,12 @@ using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Text; -using System.Threading; - -using Microsoft.Scripting; -using Microsoft.Scripting.Utils; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting.Utils; + namespace IronPython.Runtime { /// /// General-purpose storage used for Python sets and frozensets. @@ -189,7 +187,7 @@ private static bool AddWorker( private void AddOrRemoveWorker(object/*!*/ item, int hashCode) { Debug.Assert(_buckets != null); Debug.Assert(item != null); - + for (int index = hashCode & (_buckets.Length - 1); ; ProbeNext(_buckets, ref index)) { Bucket bucket = _buckets[index]; if (bucket.Item == null) { @@ -318,7 +316,7 @@ public bool ContainsAlwaysHash(object item) { hashCode = _genericHash(item); eqFunc = _genericEquals; } - + return _count > 0 && ContainsWorker(_buckets, item, hashCode, eqFunc); } @@ -535,7 +533,7 @@ public bool IsDisjoint(SetStorage other) { public static bool IsDisjoint(SetStorage self, SetStorage other) { SortBySize(ref self, ref other); - + if (self._hasNull && other._hasNull) { return false; } @@ -625,7 +623,7 @@ public void UnionUpdate(SetStorage other) { Bucket[] otherBuckets = other._buckets; UpdateHelperFunctions(other); - + for (int i = 0; i < otherBuckets.Length; i++) { Bucket bucket = otherBuckets[i]; if (bucket.Item != null && bucket.Item != Removed) { @@ -711,7 +709,7 @@ public void DifferenceUpdate(SetStorage other) { Bucket bucket = buckets[i]; if (bucket.Item != null && bucket.Item != Removed && ContainsWorker(otherBuckets, bucket.Item, bucket.HashCode, eqFunc)) { - RemoveWorker(bucket.Item, bucket.HashCode, eqFunc); + RemoveWorker(bucket.Item, bucket.HashCode, eqFunc); } } } else { @@ -837,7 +835,7 @@ public static bool Equals(SetStorage x, SetStorage y, IEqualityComparer comparer if (object.ReferenceEquals(x, y)) { return true; } - + if (x._count != y._count || (x._hasNull ^ y._hasNull)) { return false; } @@ -1138,9 +1136,9 @@ private static Func GetEqFunc(SetStorage self, SetStorage internal static void SortBySize(ref SetStorage x, ref SetStorage y) { if (x._count > 0 && ((y._count > 0 && x._buckets.Length > y._buckets.Length) || y._count == 0)) { - SetStorage temp = x; - x = y; - y = temp; + SetStorage temp = x; + x = y; + y = temp; } } diff --git a/Src/IronPython/Runtime/Slice.cs b/Src/IronPython/Runtime/Slice.cs index c242caeb1..af8102f70 100644 --- a/Src/IronPython/Runtime/Slice.cs +++ b/Src/IronPython/Runtime/Slice.cs @@ -91,9 +91,9 @@ public int __hash__() { public bool __ne__([NotNone] Slice other) => !Equals(other); - public static object? operator >([NotNone] Slice self, [NotNone] Slice other)=> self.ToTuple() < other.ToTuple(); + public static object? operator >([NotNone] Slice self, [NotNone] Slice other) => self.ToTuple() < other.ToTuple(); - public static object? operator <([NotNone] Slice self, [NotNone] Slice other)=> self.ToTuple() < other.ToTuple(); + public static object? operator <([NotNone] Slice self, [NotNone] Slice other) => self.ToTuple() < other.ToTuple(); public static object? operator >=([NotNone] Slice self, [NotNone] Slice other) => self.ToTuple() >= other.ToTuple(); diff --git a/Src/IronPython/Runtime/StringDictionaryStorage.cs b/Src/IronPython/Runtime/StringDictionaryStorage.cs index 2bde1c38f..f1824b1ad 100644 --- a/Src/IronPython/Runtime/StringDictionaryStorage.cs +++ b/Src/IronPython/Runtime/StringDictionaryStorage.cs @@ -9,7 +9,6 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -using Microsoft.Scripting; using Microsoft.Scripting.Runtime; namespace IronPython.Runtime { @@ -202,6 +201,6 @@ private void EnsureData() { private object ToNonNullKey(object? key) => key is null ? _nullkey : key; - private object? FromNonNullKey(object key) => key == _nullkey? null : key; + private object? FromNonNullKey(object key) => key == _nullkey ? null : key; } } diff --git a/Src/IronPython/Runtime/StringFormatSpec.cs b/Src/IronPython/Runtime/StringFormatSpec.cs index 054ac58c9..27e2161c0 100644 --- a/Src/IronPython/Runtime/StringFormatSpec.cs +++ b/Src/IronPython/Runtime/StringFormatSpec.cs @@ -3,15 +3,11 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; -using System.Text; -using System.Diagnostics; - -using Microsoft.Scripting; -using Microsoft.Scripting.Utils; using IronPython.Runtime.Operations; +using Microsoft.Scripting.Utils; + namespace IronPython.Runtime { /// /// Provides a representation and parsing for the default formatting specification. This is used @@ -313,7 +309,7 @@ private StringFormatSpec(char? fill, char? alignment, char? sign, int? width, bo text = FinishText(text, sign, type); } - + return text; } diff --git a/Src/IronPython/Runtime/Super.cs b/Src/IronPython/Runtime/Super.cs index 85ee282c6..6997b4696 100644 --- a/Src/IronPython/Runtime/Super.cs +++ b/Src/IronPython/Runtime/Super.cs @@ -10,12 +10,11 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; -using Microsoft.Scripting; -using Microsoft.Scripting.Runtime; - using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting.Runtime; + namespace IronPython.Runtime { [PythonType("super")] public class Super : PythonTypeSlot, ICodeFormattable { @@ -117,7 +116,7 @@ public object? __self_class__ { } #endregion - + #region Custom member access [SpecialName] @@ -151,7 +150,7 @@ public object GetCustomMember(CodeContext context, [NotNone] string name) { // above us until we get a hit. lookupType++; while (lookupType < mro.Count) { - + if (TryLookupInBase(context, mro[lookupType], name, self, out value)) return value; @@ -189,7 +188,7 @@ private bool TryLookupInBase(CodeContext context, PythonType pt, string name, ob private PythonType? DescriptorContext { get { if (!DynamicHelpers.GetPythonType(_self).IsSubclassOf(_thisClass)) { - if(_self == _selfClass) // Using @classmethod + if (_self == _selfClass) // Using @classmethod return _selfClass as PythonType ?? _thisClass; return _thisClass; } diff --git a/Src/IronPython/Runtime/ThrowingErrorSink.cs b/Src/IronPython/Runtime/ThrowingErrorSink.cs index a2ea488f0..8bb8d4329 100644 --- a/Src/IronPython/Runtime/ThrowingErrorSink.cs +++ b/Src/IronPython/Runtime/ThrowingErrorSink.cs @@ -2,10 +2,10 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using Microsoft.Scripting; - using IronPython.Runtime.Operations; +using Microsoft.Scripting; + namespace IronPython.Runtime { internal class ThrowingErrorSink : ErrorSink { public static new readonly ThrowingErrorSink/*!*/ Default = new ThrowingErrorSink(); diff --git a/Src/IronPython/Runtime/TypecodeOps.cs b/Src/IronPython/Runtime/TypecodeOps.cs index e11e97ae1..4fc708b79 100644 --- a/Src/IronPython/Runtime/TypecodeOps.cs +++ b/Src/IronPython/Runtime/TypecodeOps.cs @@ -10,7 +10,6 @@ using System.Runtime.InteropServices; using IronPython.Runtime.Operations; -using Microsoft.Scripting.Utils; namespace IronPython.Runtime { internal static class TypecodeOps { @@ -81,7 +80,7 @@ public static int GetTypecodeWidth(char typecode) { } } - public static bool TryGetFromBytes(char typecode, ReadOnlySpan bytes, [NotNullWhen(true)]out object? result) { + public static bool TryGetFromBytes(char typecode, ReadOnlySpan bytes, [NotNullWhen(true)] out object? result) { switch (typecode) { case 'c': result = Bytes.FromByte(bytes[0]); diff --git a/Src/IronPython/Runtime/Types/BuiltinFunction.cs b/Src/IronPython/Runtime/Types/BuiltinFunction.cs index aa3abf12c..6553ac951 100644 --- a/Src/IronPython/Runtime/Types/BuiltinFunction.cs +++ b/Src/IronPython/Runtime/Types/BuiltinFunction.cs @@ -2,27 +2,26 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; +using System.Dynamic; +using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; -using System.Dynamic; using System.Text; using System.Threading; +using IronPython.Runtime.Binding; +using IronPython.Runtime.Operations; + using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Actions.Calls; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Binding; -using IronPython.Runtime.Operations; - namespace IronPython.Runtime.Types { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; diff --git a/Src/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs b/Src/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs index bdacd5e3b..bebb7021a 100644 --- a/Src/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs +++ b/Src/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs @@ -7,10 +7,10 @@ using System.Reflection; using System.Threading; -using Microsoft.Scripting.Runtime; - using IronPython.Runtime.Operations; +using Microsoft.Scripting.Runtime; + namespace IronPython.Runtime.Types { // Used to map signatures to specific targets on the embedded reflected method. @@ -62,7 +62,7 @@ private object GetOverload(Type[] sig, IList targets, bool wrapCtors if (wrapCtors) { return GetTargetFunction(bf); - } + } return bf; } diff --git a/Src/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs b/Src/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs index e9d4f07c1..4a08dd651 100644 --- a/Src/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs +++ b/Src/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs @@ -2,20 +2,18 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; using System.Collections.Generic; using System.Dynamic; +using System.Linq.Expressions; using System.Runtime.CompilerServices; -using Microsoft.Scripting; -using Microsoft.Scripting.Generation; -using Microsoft.Scripting.Utils; - using IronPython.Runtime.Binding; using IronPython.Runtime.Operations; +using Microsoft.Scripting; +using Microsoft.Scripting.Generation; + namespace IronPython.Runtime.Types { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -103,7 +101,7 @@ private void CheckSelf(CodeContext/*!*/ context, object self) { } #endregion - + #region Public Python API public string __name__ { @@ -118,7 +116,7 @@ public string __doc__ { } } - public object __call__(CodeContext context, SiteLocalStorage, object>>> storage, [ParamDictionary]IDictionary dictArgs, params object[] args) { + public object __call__(CodeContext context, SiteLocalStorage, object>>> storage, [ParamDictionary] IDictionary dictArgs, params object[] args) { return _template.__call__(context, storage, dictArgs, args); } diff --git a/Src/IronPython/Runtime/Types/CachedNewTypeInfo.cs b/Src/IronPython/Runtime/Types/CachedNewTypeInfo.cs index b3f1d7337..570ecd3c2 100644 --- a/Src/IronPython/Runtime/Types/CachedNewTypeInfo.cs +++ b/Src/IronPython/Runtime/Types/CachedNewTypeInfo.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; -using System.Text; + using Microsoft.Scripting.Utils; namespace IronPython.Runtime.Types { diff --git a/Src/IronPython/Runtime/Types/ConstructorFunction.cs b/Src/IronPython/Runtime/Types/ConstructorFunction.cs index 37e936e9a..b1bc94f4b 100644 --- a/Src/IronPython/Runtime/Types/ConstructorFunction.cs +++ b/Src/IronPython/Runtime/Types/ConstructorFunction.cs @@ -4,10 +4,9 @@ using System.Collections.Generic; using System.Reflection; -using Microsoft.Scripting.Utils; using System.Text; -using IronPython.Runtime.Operations; -using Microsoft.Scripting; + +using Microsoft.Scripting.Utils; namespace IronPython.Runtime.Types { [PythonType("builtin_function_or_method")] diff --git a/Src/IronPython/Runtime/Types/CustomAttributeTracker.cs b/Src/IronPython/Runtime/Types/CustomAttributeTracker.cs index e211d2514..f244b1785 100644 --- a/Src/IronPython/Runtime/Types/CustomAttributeTracker.cs +++ b/Src/IronPython/Runtime/Types/CustomAttributeTracker.cs @@ -2,21 +2,19 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; using System.Collections.Generic; using System.Diagnostics; using System.Dynamic; +using System.Linq.Expressions; using System.Reflection; -using Microsoft.Scripting; -using Microsoft.Scripting.Actions; -using Microsoft.Scripting.Actions.Calls; - using IronPython.Runtime.Binding; using IronPython.Runtime.Operations; +using Microsoft.Scripting.Actions; +using Microsoft.Scripting.Actions.Calls; + namespace IronPython.Runtime.Types { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -131,10 +129,10 @@ public override Type DeclaringType { internal class ClassMethodTracker : PythonCustomTracker { private MethodTracker/*!*/[]/*!*/ _trackers; - + public ClassMethodTracker(MemberGroup/*!*/ group) { List trackers = new List(group.Count); - + foreach (MethodTracker mt in group) { trackers.Add(mt); } @@ -185,8 +183,8 @@ public OperatorTracker(Type/*!*/ declaringType, string/*!*/ name, bool reversed, _reversed = reversed; _trackers = members; _name = name; - } - + } + public override PythonTypeSlot/*!*/ GetSlot() { List meths = new List(); foreach (MethodTracker mt in _trackers) { @@ -209,7 +207,7 @@ public OperatorTracker(Type/*!*/ declaringType, string/*!*/ name, bool reversed, } } - return PythonTypeOps.GetFinalSlotForFunction(PythonTypeOps.GetBuiltinFunction(DeclaringType, + return PythonTypeOps.GetFinalSlotForFunction(PythonTypeOps.GetBuiltinFunction(DeclaringType, Name, ft, meths.ToArray() diff --git a/Src/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs b/Src/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs index 1048c8d17..4b052e7cd 100644 --- a/Src/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs +++ b/Src/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs @@ -6,10 +6,10 @@ using System; using System.Collections.Generic; -using System.Diagnostics; +using System.Threading; + using Microsoft.Scripting; using Microsoft.Scripting.Runtime; -using System.Threading; namespace IronPython.Runtime.Types { /// @@ -113,7 +113,7 @@ public override bool TryGetValue(object? key, out object? value) { } public override int Count { - get { + get { int count = base.Count; foreach (object? o in _values) { if (o != Uninitialized.Instance) { @@ -171,7 +171,7 @@ public int FindKey(string key) { public bool TryGetValue(int index, out object? value) { value = _values[index]; return value != Uninitialized.Instance; - } + } public void SetExtraValue(int index, object? value) { _values[index] = value; diff --git a/Src/IronPython/Runtime/Types/DocBuilder.cs b/Src/IronPython/Runtime/Types/DocBuilder.cs index e2aca6332..4fc0ac47b 100644 --- a/Src/IronPython/Runtime/Types/DocBuilder.cs +++ b/Src/IronPython/Runtime/Types/DocBuilder.cs @@ -9,12 +9,11 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Text; -using System.Threading; + using Microsoft.Scripting; using Microsoft.Scripting.Hosting; using Microsoft.Scripting.Runtime; @@ -22,7 +21,7 @@ namespace IronPython.Runtime.Types { internal static class DocBuilder { - + internal static string GetDefaultDocumentation(string methodName) { switch (methodName) { case "__abs__": return "x.__abs__() <==> abs(x)"; @@ -156,8 +155,8 @@ public static string CreateAutoDoc(Type t) { summary = String.Concat( summary, - Environment.NewLine, Environment.NewLine, - "enum ", t.IsDefined(typeof(FlagsAttribute), false) ? "(flags) ": "", GetPythonTypeName(t), ", values: ", + Environment.NewLine, Environment.NewLine, + "enum ", t.IsDefined(typeof(FlagsAttribute), false) ? "(flags) " : "", GetPythonTypeName(t), ", values: ", String.Join(", ", names)); } return summary; @@ -220,7 +219,7 @@ public static OverloadDoc GetOverloadDoc(MethodBase info, string name, int endPa name = mi.Name.Substring(0, hashIndex); } } - } else if(name == null) { + } else if (name == null) { name = "__new__"; } @@ -310,11 +309,11 @@ public static OverloadDoc GetOverloadDoc(MethodBase info, string name, int endPa ) ); } - + if (returnCount > 1) { retType.Append(')'); } - + ParameterDoc retDoc = new ParameterDoc(String.Empty, retType.ToString(), returns); return new OverloadDoc( @@ -475,7 +474,7 @@ private static string GetXmlName(MethodBase info) { /// Converts a Type object into a string suitable for lookup in the help file. All generic types are /// converted down to their generic type definition. /// - private static void AppendTypeFormat(Type curType, StringBuilder res, ParameterInfo pi=null) { + private static void AppendTypeFormat(Type curType, StringBuilder res, ParameterInfo pi = null) { if (curType.IsGenericType) { curType = curType.GetGenericTypeDefinition(); } @@ -504,7 +503,7 @@ private static void AppendTypeFormat(Type curType, StringBuilder res, ParameterI res.Append('}'); } else { if (pi != null) { - if((pi.IsOut || pi.ParameterType.IsByRef) && curType.FullName.EndsWith('&')) { + if ((pi.IsOut || pi.ParameterType.IsByRef) && curType.FullName.EndsWith('&')) { res.Append(curType.FullName.Replace("&", "@")); } else { res.Append(curType.FullName); @@ -572,7 +571,7 @@ private static XPathDocument GetXPathDocument(Assembly asm) { // for 64-bit processes, we need to look in Program Files (x86) xml = Path.Combine( Path.Combine( - Environment.GetFolderPath(Environment.Is64BitProcess ? Environment.SpecialFolder.ProgramFilesX86 : Environment.SpecialFolder.ProgramFiles), + Environment.GetFolderPath(Environment.Is64BitProcess ? Environment.SpecialFolder.ProgramFilesX86 : Environment.SpecialFolder.ProgramFiles), _frameworkReferencePath ), baseFile @@ -674,7 +673,7 @@ private static void GetXmlDoc(Type type, out string summary) { case "summary": summary = XmlToString(iter); break; } } - } + } /// /// Gets the Xml documentation for the specified Field. diff --git a/Src/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs b/Src/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs index 07f78895e..7c63b5065 100644 --- a/Src/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs +++ b/Src/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs @@ -16,7 +16,7 @@ namespace IronPython.Runtime.Types { /// Dictionary-based storage needs to be provided for setting individual members /// Virtual methods exposed to Python need to support checking the types dictionary for invocations /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple=false, Inherited=true)] + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] internal sealed class DynamicBaseTypeAttribute : Attribute { } } diff --git a/Src/IronPython/Runtime/Types/EmptyType.cs b/Src/IronPython/Runtime/Types/EmptyType.cs index bb93fd268..df9508408 100644 --- a/Src/IronPython/Runtime/Types/EmptyType.cs +++ b/Src/IronPython/Runtime/Types/EmptyType.cs @@ -15,7 +15,7 @@ namespace IronPython.Runtime.Types { [PythonType("ellipsis"), Documentation(null)] public sealed class Ellipsis : ICodeFormattable { private static Ellipsis? _instance; - + private Ellipsis() { } internal static Ellipsis Value { @@ -50,9 +50,9 @@ public int __hash__() { [PythonType("NotImplementedType"), Documentation(null)] public sealed class NotImplementedType : ICodeFormattable { private static NotImplementedType? _instance; - + private NotImplementedType() { } - + internal static NotImplementedType Value { get { if (_instance == null) { diff --git a/Src/IronPython/Runtime/Types/ExtensionPropertyInfo.cs b/Src/IronPython/Runtime/Types/ExtensionPropertyInfo.cs index 25829373e..0b0562f2b 100644 --- a/Src/IronPython/Runtime/Types/ExtensionPropertyInfo.cs +++ b/Src/IronPython/Runtime/Types/ExtensionPropertyInfo.cs @@ -26,9 +26,9 @@ public ExtensionPropertyInfo(Type logicalDeclaringType, MethodInfo mi) { if (methodName.StartsWith("Get", StringComparison.Ordinal) || methodName.StartsWith("Set", StringComparison.Ordinal)) { GetPropertyMethods(mi, methodName, prefix, "Get", "Set", "Delete"); - } else if(methodName.StartsWith("get_", StringComparison.Ordinal) || methodName.StartsWith("set_", StringComparison.Ordinal)) { + } else if (methodName.StartsWith("get_", StringComparison.Ordinal) || methodName.StartsWith("set_", StringComparison.Ordinal)) { GetPropertyMethods(mi, methodName, prefix, "get_", "set_", null); - } + } #if FEATURE_REFEMIT else if (methodName.StartsWith(NewTypeMaker.FieldGetterPrefix, StringComparison.Ordinal) || methodName.StartsWith(NewTypeMaker.FieldSetterPrefix, StringComparison.Ordinal)) { GetPropertyMethods(mi, methodName, prefix, NewTypeMaker.FieldGetterPrefix, NewTypeMaker.FieldSetterPrefix, null); diff --git a/Src/IronPython/Runtime/Types/IPythonObject.cs b/Src/IronPython/Runtime/Types/IPythonObject.cs index ddb80f12f..3a2cdb5d0 100644 --- a/Src/IronPython/Runtime/Types/IPythonObject.cs +++ b/Src/IronPython/Runtime/Types/IPythonObject.cs @@ -2,9 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using Microsoft.Scripting; - namespace IronPython.Runtime.Types { /// /// This interface is used for implementing parts of the IronPython type system. It diff --git a/Src/IronPython/Runtime/Types/InstanceCreator.cs b/Src/IronPython/Runtime/Types/InstanceCreator.cs index db81d2a18..d668e2ab6 100644 --- a/Src/IronPython/Runtime/Types/InstanceCreator.cs +++ b/Src/IronPython/Runtime/Types/InstanceCreator.cs @@ -5,8 +5,9 @@ using System; using System.Runtime.CompilerServices; using System.Threading; -using IronPython.Runtime.Binding; + using IronPython.Runtime.Operations; + using Microsoft.Scripting.Actions; using Microsoft.Scripting.Utils; diff --git a/Src/IronPython/Runtime/Types/NameConverter.cs b/Src/IronPython/Runtime/Types/NameConverter.cs index 430862243..aa0eff0af 100644 --- a/Src/IronPython/Runtime/Types/NameConverter.cs +++ b/Src/IronPython/Runtime/Types/NameConverter.cs @@ -4,12 +4,12 @@ using System; using System.Reflection; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; using System.Text; -using IronPython.Runtime; + using IronPython.Runtime.Binding; -using IronPython.Runtime.Types; + +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; namespace IronPython.Runtime.Types { /// @@ -21,7 +21,7 @@ public static NameType TryGetName(PythonType dt, MethodInfo mi, out string name) return GetNameFromMethod(dt, mi, NameType.Method, ref name); } - + public static NameType TryGetName(PythonType dt, EventInfo ei, MethodInfo eventMethod, out string name) { name = ei.Name; NameType res = dt.IsPythonType ? NameType.PythonEvent : NameType.Event; @@ -63,7 +63,7 @@ public static string GetTypeName(Type t) { sb.Append(GetTypeName(tof)); } sb.Append(']'); - name = sb.ToString(); + name = sb.ToString(); } return name; } diff --git a/Src/IronPython/Runtime/Types/NewTypeInfo.cs b/Src/IronPython/Runtime/Types/NewTypeInfo.cs index 6fb52bc34..71a9dc06c 100644 --- a/Src/IronPython/Runtime/Types/NewTypeInfo.cs +++ b/Src/IronPython/Runtime/Types/NewTypeInfo.cs @@ -3,10 +3,10 @@ // See the LICENSE file in the project root for more information. using System; -using System.Reflection; using System.Collections.Generic; using IronPython.Runtime.Operations; + using Microsoft.Scripting.Utils; namespace IronPython.Runtime.Types { @@ -159,6 +159,6 @@ public override bool Equals(object obj) { return true; } return false; - } + } } } diff --git a/Src/IronPython/Runtime/Types/NewTypeMaker.cs b/Src/IronPython/Runtime/Types/NewTypeMaker.cs index dec81ef2e..b72a2b224 100644 --- a/Src/IronPython/Runtime/Types/NewTypeMaker.cs +++ b/Src/IronPython/Runtime/Types/NewTypeMaker.cs @@ -6,20 +6,20 @@ using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; +using System.Dynamic; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; -using System.Dynamic; using System.Text; +using IronPython.Runtime.Binding; +using IronPython.Runtime.Operations; + using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Binding; -using IronPython.Runtime.Operations; - namespace IronPython.Runtime.Types { /// /// Python class hierarchy is represented using the __class__ field in the object. It does not @@ -44,7 +44,7 @@ internal sealed class NewTypeMaker { private FieldInfo _dictField; private FieldInfo _slotsField; private FieldInfo _explicitMO; - + private ILGen _cctor; private int _site; @@ -70,7 +70,7 @@ internal sealed class NewTypeMaker { private static readonly Dictionary>> _overriddenMethods = new Dictionary>>(); [MultiRuntimeAware] private static readonly Dictionary>> _overriddenProperties = new Dictionary>>(); - + private NewTypeMaker(NewTypeInfo typeInfo) { _baseType = typeInfo.BaseType; @@ -105,7 +105,7 @@ private NewTypeMaker(NewTypeInfo typeInfo) { // creation code return new NewTypeMaker(typeInfo).CreateNewType(); }); - + return ret; } @@ -118,7 +118,7 @@ public static void SaveNewTypes(string assemblyName, IList types) { MethodBuilder mb = tb.DefineMethod(_constructorMethodName, MethodAttributes.Public | MethodAttributes.Static, typeof(CachedNewTypeInfo[]), ReflectionUtils.EmptyTypes); ILGenerator ilg = mb.GetILGenerator(); - + // new CachedTypeInfo[types.Count] // we leave this on the stack (duping it) and storing into it. EmitInt(ilg, types.Count); @@ -127,7 +127,7 @@ public static void SaveNewTypes(string assemblyName, IList types) { foreach (var v in types) { NewTypeInfo nti = NewTypeInfo.GetTypeInfo(String.Empty, v); - + var typeInfos = new NewTypeMaker(nti).SaveType(ag, "Python" + _typeCount++ + "$" + nti.BaseType.Name); // prepare for storing the element into our final array @@ -138,14 +138,14 @@ public static void SaveNewTypes(string assemblyName, IList types) { // load the type ilg.Emit(OpCodes.Ldtoken, typeInfos.Key); - ilg.Emit(OpCodes.Call, typeof(Type).GetMethod("GetTypeFromHandle")); + ilg.Emit(OpCodes.Call, typeof(Type).GetMethod("GetTypeFromHandle")); // create the dictionary of special names ilg.Emit(OpCodes.Newobj, typeof(Dictionary).GetConstructor(Array.Empty())); foreach (var specialName in typeInfos.Value) { // dup dict ilg.Emit(OpCodes.Dup); - + // emit key ilg.Emit(OpCodes.Ldstr, specialName.Key); @@ -161,7 +161,7 @@ public static void SaveNewTypes(string assemblyName, IList types) { } // assign to dict - ilg.Emit(OpCodes.Call, typeof(Dictionary).GetMethod("set_Item")); + ilg.Emit(OpCodes.Call, typeof(Dictionary).GetMethod("set_Item")); } // emit the interface types (if any) @@ -465,7 +465,7 @@ private void OverrideConstructor(ConstructorInfo parentConstructor) { MethodInfo init = typeof(PythonOps).GetMethod(nameof(PythonOps.InitializeUserTypeSlots)); il.EmitLoadArg(0); - + il.EmitLoadArg(typeArg); il.EmitCall(init); @@ -563,7 +563,7 @@ private bool NeedsPythonObject { private void ImplementDynamicObject() { // true if the user has explicitly included IDynamicMetaObjectProvider in the list of interfaces - bool explicitDynamicObject = false; + bool explicitDynamicObject = false; foreach (Type t in _interfaceTypes) { if (t == typeof(IDynamicMetaObjectProvider)) { explicitDynamicObject = true; @@ -633,7 +633,7 @@ private void ImplementDynamicObject() { il.Emit(OpCodes.Dup); il.Emit(OpCodes.Ldnull); il.Emit(OpCodes.Beq, retNull); - + // store the local value il.Emit(OpCodes.Stloc_S, retVal.LocalIndex); @@ -643,7 +643,7 @@ private void ImplementDynamicObject() { // user returned null, fallback to base impl il.MarkLabel(retNull); il.Emit(OpCodes.Pop); - + // no override exists il.MarkLabel(noOverride); @@ -664,7 +664,7 @@ private void ImplementDynamicObject() { il.EmitLoadArg(0); // this il.EmitLoadArg(1); // parameter - + // baseMetaObject if (baseIdo) { InterfaceMapping imap = _baseType.GetInterfaceMap(typeof(IDynamicMetaObjectProvider)); @@ -735,7 +735,7 @@ private void ImplementIPythonObject() { il.Emit(OpCodes.Ret); _tg.DefineMethodOverride(impl, decl); } - + // Types w/ DynamicBaseType attribute still need new slots implementation _slotsField = _tg.DefineField(SlotsAndWeakRefFieldName, typeof(object[]), FieldAttributes.Public); @@ -804,7 +804,7 @@ private void ImplementProtectedFieldAccessors(Dictionary speci // we need to create public helper methods that expose them. These methods are // used by the IDynamicMetaObjectProvider implementation (in MetaUserObject) - foreach (FieldInfo fi in _baseType.GetInheritedFields(flattenHierarchy: true)) { + foreach (FieldInfo fi in _baseType.GetInheritedFields(flattenHierarchy: true)) { if (!fi.IsProtected()) { continue; } @@ -900,13 +900,13 @@ private void OverrideMethods(Type type, Dictionary specialName added[key] = mi; } } - + if (type.IsAbstract && !type.IsInterface) { // abstract types can define interfaces w/o implementations foreach (Type iface in type.GetInterfaces()) { InterfaceMapping mapping = type.GetInterfaceMap(iface); for (int i = 0; i < mapping.TargetMethods.Length; i++) { - + if (mapping.TargetMethods[i] == null) { MethodInfo mi = mapping.InterfaceMethods[i]; @@ -1149,7 +1149,7 @@ private LocalBuilder EmitBaseClassCallCheckForProperties(ILGen il, MethodInfo ba // we're accessing a property return callTarget; } - + private MethodBuilder CreateVTableGetterOverride(MethodInfo mi, string name) { MethodBuilder impl; ILGen il; @@ -1273,7 +1273,7 @@ private MethodBuilder CreateVTableMethodOverride(MethodInfo mi, string name) { DefineVTableMethodOverride(mi, out impl, out il); //CompilerHelpers.GetArgumentNames(parameters)); TODO: Set names - LocalBuilder callTarget = EmitNonInheritedMethodLookup(name, il); + LocalBuilder callTarget = EmitNonInheritedMethodLookup(name, il); Label instanceCall = il.DefineLabel(); il.Emit(OpCodes.Brtrue, instanceCall); @@ -1602,7 +1602,7 @@ private static void AddBaseMethods(Type finishedType, Dictionary diff --git a/Src/IronPython/Runtime/Types/PythonAssemblyOps.cs b/Src/IronPython/Runtime/Types/PythonAssemblyOps.cs index c9afd3a8e..75695e2b2 100644 --- a/Src/IronPython/Runtime/Types/PythonAssemblyOps.cs +++ b/Src/IronPython/Runtime/Types/PythonAssemblyOps.cs @@ -6,7 +6,9 @@ using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; + using IronPython.Runtime.Types; + using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Runtime; @@ -73,5 +75,5 @@ private static TopNamespaceTracker GetReflectedAssembly(CodeContext/*!*/ context return reflectedAssembly; } } - } + } } diff --git a/Src/IronPython/Runtime/Types/PythonSiteCache.cs b/Src/IronPython/Runtime/Types/PythonSiteCache.cs index cbd0c8567..5820386ac 100644 --- a/Src/IronPython/Runtime/Types/PythonSiteCache.cs +++ b/Src/IronPython/Runtime/Types/PythonSiteCache.cs @@ -7,12 +7,10 @@ using System.Runtime.CompilerServices; using System.Threading; -using Microsoft.Scripting; -using Microsoft.Scripting.Actions; -using Microsoft.Scripting.Utils; - using IronPython.Runtime.Operations; +using Microsoft.Scripting.Actions; + namespace IronPython.Runtime.Types { /// /// Cached CallSites. User types are cached on the PythonType and System types are cached on the diff --git a/Src/IronPython/Runtime/Types/PythonType.cs b/Src/IronPython/Runtime/Types/PythonType.cs index 77e70c573..c01703ada 100644 --- a/Src/IronPython/Runtime/Types/PythonType.cs +++ b/Src/IronPython/Runtime/Types/PythonType.cs @@ -504,7 +504,7 @@ public object __call__(CodeContext context, params object[] args) { return PythonTypeOps.CallParams(context, this, args); } - public object __call__(CodeContext context, [ParamDictionary]IDictionary kwArgs, params object[] args) { + public object __call__(CodeContext context, [ParamDictionary] IDictionary kwArgs, params object[] args) { return PythonTypeOps.CallWorker(context, this, kwArgs, args); } @@ -575,8 +575,8 @@ public object this[string member] { public static object Get__module__(CodeContext/*!*/ context, PythonType self) { PythonTypeSlot pts; object res; - if (self._dict != null && - self._dict.TryGetValue("__module__", out pts) && + if (self._dict != null && + self._dict.TryGetValue("__module__", out pts) && pts.TryGetValue(context, self, DynamicHelpers.GetPythonType(self), out res)) { return res; } @@ -638,7 +638,7 @@ public static void Set__qualname__(PythonType type, string name) { type.QualName = name; } - public static PythonDictionary __prepare__([ParamDictionary]IDictionary kwargs, params object[] args) + public static PythonDictionary __prepare__([ParamDictionary] IDictionary kwargs, params object[] args) => new PythonDictionary(); public string/*!*/ __repr__(CodeContext/*!*/ context) { @@ -789,13 +789,13 @@ internal IList ResolutionOrder { /// internal static PythonType/*!*/ GetPythonType(Type type) { object res; - + if (!_pythonTypes.TryGetValue(type, out res)) { lock (_pythonTypes) { if (!_pythonTypes.TryGetValue(type, out res)) { res = new PythonType(type); - _pythonTypes.Add(type, res); + _pythonTypes.Add(type, res); } } } @@ -873,7 +873,7 @@ internal object CreateInstance(CodeContext context, params object[] args) { case 1: return _instanceCtor.CreateInstance(context, args[0]); case 2: return _instanceCtor.CreateInstance(context, args[0], args[1]); case 3: return _instanceCtor.CreateInstance(context, args[0], args[1], args[2]); - default: + default: return _instanceCtor.CreateInstance(context, args); } } @@ -908,7 +908,7 @@ internal bool TryGetLength(CodeContext context, object o, out int length) { PythonTypeSlot lenSlot = _lenSlot; if (lenSlot == null && !PythonOps.TryResolveTypeSlot(context, this, "__len__", out lenSlot)) { length = 0; - return false; + return false; } object func; @@ -973,7 +973,7 @@ internal CallSite> HashSite { } private void EnsureHashSite() { - if(_hashSite == null) { + if (_hashSite == null) { Interlocked.CompareExchange( ref _hashSite, CallSite>.Create( @@ -1169,7 +1169,7 @@ internal bool IsHiddenMember(string name) { return !TryResolveSlot(DefaultContext.Default, name, out _) && TryResolveSlot(DefaultContext.DefaultCLS, name, out _); } - + internal LateBoundInitBinder GetLateBoundInitBinder(CallSignature signature) { Debug.Assert(!IsSystemType); // going to hold onto a PythonContext, shouldn't ever be a system type Debug.Assert(_pythonContext != null); @@ -1178,7 +1178,7 @@ internal LateBoundInitBinder GetLateBoundInitBinder(CallSignature signature) { Interlocked.CompareExchange(ref _lateBoundInitBinders, new Dictionary(), null); } - lock(_lateBoundInitBinders) { + lock (_lateBoundInitBinders) { LateBoundInitBinder res; if (!_lateBoundInitBinders.TryGetValue(signature, out res)) { _lateBoundInitBinders[signature] = res = new LateBoundInitBinder(this, signature); @@ -1242,7 +1242,7 @@ internal bool TryResolveSlot(CodeContext context, string name, out PythonTypeSlo if (UnderlyingSystemType.IsInterface) { return TypeCache.Object.TryResolveSlot(context, name, out slot); } - + slot = null; return false; @@ -1339,7 +1339,7 @@ internal static PythonTypeSlot ToTypeSlot(object value) { } // We could do more checks for things which aren't descriptors - if (value != null) { + if (value != null) { return new PythonTypeUserDescriptorSlot(value); } @@ -1484,7 +1484,7 @@ internal bool TryGetNonCustomMember(CodeContext context, object instance, string PythonDictionary dict = sdo.Dict; hasValue = dict != null && dict.TryGetValue(name, out value); - } + } // then check through all the descriptors. If we have a data // descriptor it takes priority over the value we found in the @@ -1497,7 +1497,7 @@ internal bool TryGetNonCustomMember(CodeContext context, object instance, string if (!hasValue || slot.IsSetDescriptor(context, this)) { if (slot.TryGetValue(context, instance, this, out object newValue)) value = newValue; - return true; + return true; } } } @@ -1611,7 +1611,7 @@ internal bool TrySetMember(CodeContext context, object instance, string name, ob } setAttrSite.Target(setAttrSite, context, setattr, instance, name, value); - return true; + return true; } return TrySetNonCustomMember(context, instance, name, value); @@ -1641,8 +1641,7 @@ internal bool TrySetNonCustomMember(CodeContext context, object instance, string if ((iac = sdo.SetDict(iac)) == null) { return false; } - } - else { + } else { return false; } } @@ -1852,14 +1851,14 @@ private void InitializeUserType(CodeContext/*!*/ context, string name, PythonTup // if we directly inherit from 2 types with slots then the indexes would // conflict so inheritance isn't allowed. int slotCount = pt.GetUsedSlotCount(); - + if (slotCount != 0) { if (hasSlots) { throw PythonOps.TypeError("multiple bases have instance lay-out conflict"); } hasSlots = true; } - + pt.AddSubType(this); } @@ -1918,7 +1917,7 @@ private void InitializeUserType(CodeContext/*!*/ context, string name, PythonTup bool isPythonType = false; foreach (ConstructorInfo ci in ctors) { ParameterInfo[] pis = ci.GetParameters(); - if((pis.Length > 1 && pis[0].ParameterType == typeof(CodeContext) && pis[1].ParameterType == typeof(PythonType)) || + if ((pis.Length > 1 && pis[0].ParameterType == typeof(CodeContext) && pis[1].ParameterType == typeof(PythonType)) || (pis.Length > 0 && pis[0].ParameterType == typeof(PythonType))) { isPythonType = true; break; @@ -2034,7 +2033,7 @@ private void UpdateObjectNewAndInit(CodeContext context) { Debug.Assert(pt._objectInit != null && pt._objectNew != null); if (!pt._objectNew.Value) { - _objectNew = false; + _objectNew = false; } if (!pt._objectInit.Value) { @@ -2092,7 +2091,7 @@ private void PopulateDictionary(CodeContext/*!*/ context, string name, PythonTup if (slots != null) { slots.Remove("__classcell__"); _slots = slots.ToArray(); - + int index = _originalSlotCount; string typeName = IronPython.Compiler.Parser.GetPrivatePrefix(name); @@ -2118,7 +2117,7 @@ private void PopulateDictionary(CodeContext/*!*/ context, string name, PythonTup if (CheckForSlotWithDefault(context, _resolutionOrder, slots, "__dict__")) { _attrs |= PythonTypeAttributes.HasDictionary; bool inheritsDict = false; - for (int i = 1; i<_resolutionOrder.Count; i++) { + for (int i = 1; i < _resolutionOrder.Count; i++) { PythonType pt = _resolutionOrder[i]; if (pt.TryResolveSlot(context, "__dict__", out _)) { inheritsDict = true; @@ -2228,7 +2227,7 @@ private static void EnsureModule(CodeContext context, PythonDictionary dict) { } } } - + #endregion #region System type initialization @@ -2280,7 +2279,7 @@ private void AddSystemBases() { Type newType; if (TryReplaceExtensibleWithBase(curType, out newType)) { mro.Add(DynamicHelpers.GetPythonTypeFromType(newType)); - } else if(!curType.IsDefined(typeof(PythonHiddenBaseClassAttribute), false)) { + } else if (!curType.IsDefined(typeof(PythonHiddenBaseClassAttribute), false)) { mro.Add(DynamicHelpers.GetPythonTypeFromType(curType)); } curType = curType.BaseType; @@ -2317,7 +2316,7 @@ private void AddSystemInterfaces(List mro) { mro.Add(DynamicHelpers.GetPythonTypeFromType(typeof(ICollection))); mro.Add(DynamicHelpers.GetPythonTypeFromType(typeof(IEnumerable))); return; - } + } Type[] interfaces = _underlyingSystemType.GetInterfaces(); Dictionary methodMap = new Dictionary(); @@ -2326,7 +2325,7 @@ private void AddSystemInterfaces(List mro) { PythonType[] bases = new PythonType[_bases.Length + interfaces.Length]; Array.Copy(_bases, bases, _bases.Length); - for(int i = 0; i < interfaces.Length; i++) { + for (int i = 0; i < interfaces.Length; i++) { bases[i + _bases.Length] = PythonType.GetPythonType(interfaces[i]); } @@ -2354,11 +2353,11 @@ private void AddSystemInterfaces(List mro) { #endif InterfaceMapping mapping = _underlyingSystemType.GetInterfaceMap(iface); - + // grab all the interface methods which would hide other members for (int i = 0; i < mapping.TargetMethods.Length; i++) { MethodInfo target = mapping.TargetMethods[i]; - + if (target == null) { continue; } @@ -2394,7 +2393,7 @@ private void AddSystemInterfaces(List mro) { // no collisions so far... methodMap[iTarget.Name] = iface; } - } + } } } } @@ -2492,7 +2491,7 @@ private void EnsureDict() { null); } } - + /// /// Internal helper function to add a subtype /// @@ -2548,7 +2547,7 @@ private enum PythonTypeAttributes { /// The type has a ctor which does not accept PythonTypes. This is used /// for user defined types which implement __clrtype__ /// - SystemCtor = 0x20 + SystemCtor = 0x20 } #endregion @@ -2607,7 +2606,7 @@ internal WeakReferenceProxy(PythonContext context, PythonType type) { } public WeakRefTracker GetWeakRef() { - if(type.IsSystemType) { + if (type.IsSystemType) { return context.GetSystemPythonTypeWeakRef(type); } @@ -2616,7 +2615,7 @@ public WeakRefTracker GetWeakRef() { } public void SetFinalizer(WeakRefTracker value) { - if(type.IsSystemType) { + if (type.IsSystemType) { context.SetSystemPythonTypeFinalizer(type, value); } else { IWeakReferenceable weakref = (IWeakReferenceable)type; @@ -2625,10 +2624,10 @@ public void SetFinalizer(WeakRefTracker value) { } public bool SetWeakRef(WeakRefTracker value) { - if(type.IsSystemType) { + if (type.IsSystemType) { return context.SetSystemPythonTypeWeakRef(type, value); } - + IWeakReferenceable weakref = (IWeakReferenceable)type; return weakref.SetWeakRef(value); } @@ -2651,7 +2650,7 @@ public bool SetWeakRef(WeakRefTracker value) { /// internal WeakReference/*!*/ GetSharedWeakReference() { if (_weakRef == null) { - _weakRef = new WeakReference(this); + _weakRef = new WeakReference(this); } return _weakRef; @@ -2667,7 +2666,7 @@ T IFastSettable.MakeSetBinding(CallSite site, PythonSetMemberBinder binder if (!IsSystemType && !TryGetCustomSetAttr(Context.SharedContext, out _)) { CodeContext context = PythonContext.GetPythonContext(binder).SharedContext; string name = binder.Name; - + // optimized versions for possible literals that can show up in code. Type setType = typeof(T); if (setType == typeof(Func)) { @@ -2726,7 +2725,7 @@ internal class DebugProxy { public DebugProxy(PythonType type) { _type = type; } - + public PythonType[] __bases__ { get { return ArrayUtils.ToArray(_type.BaseTypes); @@ -2835,8 +2834,8 @@ public GetMemberDelegates(OptimizedGetKind getKind, PythonType type, PythonGetMe _fallback = fallback; _isNoThrow = binder.IsNoThrow; _extMethods = extMethods; - var optNames = type.GetOptimizedInstanceNames(); - + var optNames = type.GetOptimizedInstanceNames(); + switch (getKind) { case OptimizedGetKind.SlotDict: if (optNames != null) { @@ -2845,7 +2844,7 @@ public GetMemberDelegates(OptimizedGetKind getKind, PythonType type, PythonGetMe if (optNames != null && _dictIndex != -1) { _func = SlotDictOptimized; - _dictVersion = type.GetOptimizedInstanceVersion(); + _dictVersion = type.GetOptimizedInstanceVersion(); } else { _func = SlotDict; } @@ -2868,13 +2867,13 @@ public GetMemberDelegates(OptimizedGetKind getKind, PythonType type, PythonGetMe _func = UserSlotDictGetAttr; } else { _func = UserSlotDict; - } + } break; case OptimizedGetKind.UserSlotOnly: if (_getattrSlot != null) { _func = UserSlotOnlyGetAttr; } else { - _func = UserSlotOnly; + _func = UserSlotOnly; } break; default: throw new InvalidOperationException(); @@ -3098,7 +3097,7 @@ internal class SetMemberDelegates : FastSetBase { private readonly CodeContext _context; private readonly int _index, _keysVersion; - public SetMemberDelegates(CodeContext context, PythonType type, OptimizedSetKind kind, string name, int version, PythonTypeSlot slot, SlotSetValue slotFunc) + public SetMemberDelegates(CodeContext context, PythonType type, OptimizedSetKind kind, string name, int version, PythonTypeSlot slot, SlotSetValue slotFunc) : base(version) { _slot = slot; _name = name; @@ -3147,7 +3146,7 @@ public object SetDictOptimized(CallSite site, object self, TValue value) { return Update(site, self, value); } - + public object SetDict(CallSite site, object self, TValue value) { if (self is IPythonObject ipo && ipo.PythonType.Version == _version && ShouldUseNonOptimizedSite) { _hitCount++; @@ -3438,7 +3437,7 @@ public override bool Equals(CachedGetKey other) { if (!(other is CachedGetIdWeakRefExtensionMethod obj)) { return false; } - return obj._extMethodSet.Target == _extMethodSet.Target && + return obj._extMethodSet.Target == _extMethodSet.Target && obj.Name == Name; } diff --git a/Src/IronPython/Runtime/Types/PythonTypeDataSlot.cs b/Src/IronPython/Runtime/Types/PythonTypeDataSlot.cs index a17d1ee9a..dc0952f7d 100644 --- a/Src/IronPython/Runtime/Types/PythonTypeDataSlot.cs +++ b/Src/IronPython/Runtime/Types/PythonTypeDataSlot.cs @@ -2,10 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Collections.Generic; -using System.Text; - using IronPython.Runtime.Operations; namespace IronPython.Runtime.Types { diff --git a/Src/IronPython/Runtime/Types/PythonTypeDictSlot.cs b/Src/IronPython/Runtime/Types/PythonTypeDictSlot.cs index 22b3c3459..551058431 100644 --- a/Src/IronPython/Runtime/Types/PythonTypeDictSlot.cs +++ b/Src/IronPython/Runtime/Types/PythonTypeDictSlot.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using Microsoft.Scripting; using IronPython.Runtime.Operations; @@ -65,7 +64,7 @@ internal override bool IsSetDescriptor(CodeContext context, PythonType owner) { internal override bool TryDeleteValue(CodeContext context, object instance, PythonType owner) { if (instance is IPythonObject sdo) { - if(!sdo.PythonType.HasDictionary) { + if (!sdo.PythonType.HasDictionary) { return false; } diff --git a/Src/IronPython/Runtime/Types/PythonTypeInfo.cs b/Src/IronPython/Runtime/Types/PythonTypeInfo.cs index 87c537fd7..5d4866fd6 100644 --- a/Src/IronPython/Runtime/Types/PythonTypeInfo.cs +++ b/Src/IronPython/Runtime/Types/PythonTypeInfo.cs @@ -11,15 +11,15 @@ using System.Numerics; using System.Reflection; +using IronPython.Runtime.Binding; +using IronPython.Runtime.Operations; + using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Binding; -using IronPython.Runtime.Operations; - namespace IronPython.Runtime.Types { /// /// Helpers for interacting w/ .NET types. This includes: @@ -409,8 +409,7 @@ private class OperatorResolver : MemberResolver { if ((opInfo.Operator & PythonOperationKind.Comparison) != 0) { // we override these with our own comparisons continue; - } - else if (opInfo.Operator == PythonOperationKind.TrueDivide) { + } else if (opInfo.Operator == PythonOperationKind.TrueDivide) { // we override this with our own division PythonOperationKind which is different from .NET Complex. continue; } @@ -662,7 +661,7 @@ private class ProtectedMemberResolver : MemberResolver { EqualityResolver.Instance, new ComparisonResolver(typeof(IStructuralComparable), "StructuralComparable"), - + new OneOffResolver("__all__", AllResolver), new OneOffResolver("__contains__", ContainsResolver), new OneOffResolver("__dir__", DirResolver), @@ -1011,7 +1010,7 @@ internal static MemberGroup GetExtensionMemberGroup(Type type, MemberInfo[] news return GetInstanceOpsMethod(type, nameof(InstanceOps.IterMethodForEnumerator)); } } - + return MemberGroup.EmptyGroup; } @@ -1030,7 +1029,7 @@ internal static MemberGroup GetExtensionMemberGroup(Type type, MemberInfo[] news } MemberGroup res = binder.GetMember(type, "GetMemberNames"); - if (res == MemberGroup.EmptyGroup && + if (res == MemberGroup.EmptyGroup && !typeof(IPythonObject).IsAssignableFrom(type) && typeof(IDynamicMetaObjectProvider).IsAssignableFrom(type)) { res = GetInstanceOpsMethod(type, nameof(InstanceOps.DynamicDir)); @@ -1653,7 +1652,7 @@ private static string[] GetCastNames(Type fromType, Type toType) { /// Helper for creating a typecast resolver /// private static Func/*!*/ MakeConversionResolver(List castPrec) { - return delegate(MemberBinder/*!*/ binder, Type/*!*/ type) { + return delegate (MemberBinder/*!*/ binder, Type/*!*/ type) { MethodInfo cast = FindCastMethod(binder, type, castPrec); if (cast != null) { MethodTracker tracker = (MethodTracker)MemberTracker.FromMemberInfo(cast, type); @@ -1668,7 +1667,7 @@ private static string[] GetCastNames(Type fromType, Type toType) { /// /// false for a getter, true for a setter private static Func/*!*/ MakeIndexerResolver(bool set) { - return delegate(MemberBinder/*!*/ binder, Type/*!*/ type) { + return delegate (MemberBinder/*!*/ binder, Type/*!*/ type) { List members = null; foreach (MemberInfo member in type.GetDefaultMembers()) { @@ -2002,7 +2001,7 @@ static bool FilterProperty(MemberRequestKind action, PropertyInfo property) { return group; } - private static bool IsPropertyWithParameters(MethodTracker/*!*/ meth) { + private static bool IsPropertyWithParameters(MethodTracker/*!*/ meth) { if (meth.Method.Name.StartsWith("get_", StringComparison.Ordinal)) { if (!IsMethodDefaultMember(meth)) { ParameterInfo[] args = meth.Method.GetParameters(); @@ -2046,7 +2045,7 @@ private static bool IsPythonRecognizedOperator(string name) { if (oi != null) { EnsureOperatorTable(); - if(_pythonOperatorTable.ContainsValue(oi.Operator)) { + if (_pythonOperatorTable.ContainsValue(oi.Operator)) { isPythonRecognizedOperator = true; } } @@ -2082,7 +2081,7 @@ private static List MakeListWithPreviousMembers(MemberGroup group } return mts; } - + private static MethodInfo[] GetMethodSet(string name, int expected) { MethodInfo[] methods = typeof(InstanceOps).GetMethods(); MethodInfo[] filtered = new MethodInfo[expected]; diff --git a/Src/IronPython/Runtime/Types/PythonTypeSlot.cs b/Src/IronPython/Runtime/Types/PythonTypeSlot.cs index 5123fb104..797dcdeaa 100644 --- a/Src/IronPython/Runtime/Types/PythonTypeSlot.cs +++ b/Src/IronPython/Runtime/Types/PythonTypeSlot.cs @@ -2,15 +2,12 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System.Dynamic; -using System.Runtime.InteropServices; +using System.Linq.Expressions; using IronPython.Runtime.Binding; using IronPython.Runtime.Operations; -using Microsoft.Scripting.Utils; using AstUtils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Runtime.Types { @@ -44,7 +41,7 @@ internal virtual bool TrySetValue(CodeContext context, object instance, PythonTy /// Deletes the value stored in the slot from the instance. /// /// true if the value was deleted, false if it can't be deleted - internal virtual bool TryDeleteValue(CodeContext context, object instance, PythonType owner) { + internal virtual bool TryDeleteValue(CodeContext context, object instance, PythonType owner) { return false; } @@ -91,7 +88,7 @@ internal virtual void MakeGetExpression(PythonBinder/*!*/ binder, Expression/*!* builder.FinishCondition(Ast.Block(call, tmp)); } } - + /// /// True if TryGetValue will always succeed, false if it may fail. /// @@ -107,7 +104,7 @@ internal virtual bool IsSetDescriptor(CodeContext context, PythonType owner) { return false; } - public virtual object __get__(CodeContext/*!*/ context, object instance, object typeContext=null) { + public virtual object __get__(CodeContext/*!*/ context, object instance, object typeContext = null) { PythonType dt = typeContext as PythonType; object res; diff --git a/Src/IronPython/Runtime/Types/PythonTypeTypeSlot.cs b/Src/IronPython/Runtime/Types/PythonTypeTypeSlot.cs index 3c18fcfbe..49d6e6258 100644 --- a/Src/IronPython/Runtime/Types/PythonTypeTypeSlot.cs +++ b/Src/IronPython/Runtime/Types/PythonTypeTypeSlot.cs @@ -40,7 +40,7 @@ internal override bool TrySetValue(CodeContext context, object instance, PythonT if (!(value is PythonType dt)) throw PythonOps.TypeError("__class__ must be set to a class, not '{0}' object", PythonOps.GetPythonTypeName(value)); - if(dt.UnderlyingSystemType != DynamicHelpers.GetPythonType(instance).UnderlyingSystemType) + if (dt.UnderlyingSystemType != DynamicHelpers.GetPythonType(instance).UnderlyingSystemType) throw PythonOps.TypeErrorForIncompatibleObjectLayout("__class__ assignment", DynamicHelpers.GetPythonType(instance), dt.UnderlyingSystemType); sdo.SetPythonType(dt); diff --git a/Src/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs b/Src/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs index c3fffe03b..7a3d16947 100644 --- a/Src/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs +++ b/Src/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs @@ -4,6 +4,7 @@ using System; using System.Diagnostics; + using IronPython.Runtime.Operations; namespace IronPython.Runtime.Types { @@ -16,7 +17,7 @@ public sealed class PythonTypeUserDescriptorSlot : PythonTypeSlot { internal PythonTypeUserDescriptorSlot(object value) { Value = value; } - + internal PythonTypeUserDescriptorSlot(object value, bool isntDescriptor) { Value = value; if (isntDescriptor) { diff --git a/Src/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs b/Src/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs index 4b69d5ed1..467af40c7 100644 --- a/Src/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs +++ b/Src/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs @@ -47,7 +47,7 @@ internal override bool TrySetValue(CodeContext context, object instance, PythonT internal override bool TryDeleteValue(CodeContext context, object instance, PythonType owner) { throw PythonOps.TypeError("__weakref__ attribute cannot be deleted"); } - + public override string ToString() { return $""; } diff --git a/Src/IronPython/Runtime/Types/ReflectedEvent.cs b/Src/IronPython/Runtime/Types/ReflectedEvent.cs index db5c04d99..dc6f28038 100644 --- a/Src/IronPython/Runtime/Types/ReflectedEvent.cs +++ b/Src/IronPython/Runtime/Types/ReflectedEvent.cs @@ -5,8 +5,10 @@ using System; using System.Reflection; using System.Runtime.CompilerServices; + using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; + using Microsoft.Scripting.Actions; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Utils; @@ -64,7 +66,7 @@ internal override bool TrySetValue(CodeContext/*!*/ context, object instance, Py } private bool EventInfosDiffer(BoundEvent et) { - + // if they're the same object they're the same... if (et.Event.Info == Info) { return false; diff --git a/Src/IronPython/Runtime/Types/ReflectedExtensionProperty.cs b/Src/IronPython/Runtime/Types/ReflectedExtensionProperty.cs index 8e879de9b..89ebd3c7b 100644 --- a/Src/IronPython/Runtime/Types/ReflectedExtensionProperty.cs +++ b/Src/IronPython/Runtime/Types/ReflectedExtensionProperty.cs @@ -4,9 +4,11 @@ using System; using System.Reflection; -using Microsoft.Scripting.Utils; + using IronPython.Runtime.Operations; +using Microsoft.Scripting.Utils; + namespace IronPython.Runtime.Types { /// /// Represents a ReflectedProperty created for an extension method. Logically the property is an diff --git a/Src/IronPython/Runtime/Types/ReflectedField.cs b/Src/IronPython/Runtime/Types/ReflectedField.cs index b40d725ab..131b71c29 100644 --- a/Src/IronPython/Runtime/Types/ReflectedField.cs +++ b/Src/IronPython/Runtime/Types/ReflectedField.cs @@ -2,22 +2,20 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; using System.Diagnostics; using System.Dynamic; +using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; -using Microsoft.Scripting; -using Microsoft.Scripting.Actions; -using Microsoft.Scripting.Utils; - using IronPython.Runtime.Binding; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; +using Microsoft.Scripting; +using Microsoft.Scripting.Actions; + namespace IronPython.Runtime.Types { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -43,8 +41,8 @@ public ReflectedField(FieldInfo/*!*/ info) public FieldInfo Info { [PythonHidden] - get { - return _info; + get { + return _info; } } @@ -73,7 +71,7 @@ public object GetValue(CodeContext context, object instance) { public void SetValue(CodeContext context, object instance, object value) { if (!TrySetValueWorker(context, instance, DynamicHelpers.GetPythonType(instance), value, true)) { throw new InvalidOperationException("cannot set field"); - } + } } public void __set__(CodeContext/*!*/ context, object instance, object value) { diff --git a/Src/IronPython/Runtime/Types/ReflectedGetterSetter.cs b/Src/IronPython/Runtime/Types/ReflectedGetterSetter.cs index f96efc635..d1967d63a 100644 --- a/Src/IronPython/Runtime/Types/ReflectedGetterSetter.cs +++ b/Src/IronPython/Runtime/Types/ReflectedGetterSetter.cs @@ -7,8 +7,9 @@ using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; + using IronPython.Runtime.Operations; -using Microsoft.Scripting.Generation; + using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; @@ -136,8 +137,8 @@ internal static bool NeedToReturnProperty(object instance, MethodInfo[] mis) { } foreach (MethodInfo mi in mis) { - if (!mi.IsStatic || - (mi.IsDefined(typeof(PropertyMethodAttribute), true) && + if (!mi.IsStatic || + (mi.IsDefined(typeof(PropertyMethodAttribute), true) && !mi.IsDefined(typeof(StaticExtensionMethodAttribute), true)) && !mi.IsDefined(typeof(WrapperDescriptorAttribute), true)) { return true; @@ -163,7 +164,7 @@ internal bool CallSetter(CodeContext context, SiteLocalStorage @@ -28,7 +26,7 @@ public sealed class ReflectedIndexer : ReflectedGetterSetter { public ReflectedIndexer(PropertyInfo/*!*/ info, NameType nt, bool privateBinding) : base(new MethodInfo[] { info.GetGetMethod(privateBinding) }, new MethodInfo[] { info.GetSetMethod(privateBinding) }, nt) { Debug.Assert(info != null); - + _info = info; } diff --git a/Src/IronPython/Runtime/Types/ReflectedProperty.cs b/Src/IronPython/Runtime/Types/ReflectedProperty.cs index 558b172a6..7816a23db 100644 --- a/Src/IronPython/Runtime/Types/ReflectedProperty.cs +++ b/Src/IronPython/Runtime/Types/ReflectedProperty.cs @@ -2,22 +2,21 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Linq.Expressions; - using System; using System.Diagnostics; using System.Dynamic; +using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; +using IronPython.Runtime.Binding; +using IronPython.Runtime.Operations; + using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Binding; -using IronPython.Runtime.Operations; - using AstUtils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Runtime.Types { @@ -55,7 +54,7 @@ internal override bool TrySetValue(CodeContext context, object instance, PythonT if (instance == null) { foreach (MethodInfo mi in Setter) { - if(mi.IsStatic && DeclaringType != owner.UnderlyingSystemType) { + if (mi.IsStatic && DeclaringType != owner.UnderlyingSystemType) { return false; } else if (mi.IsProtected()) { throw PythonOps.TypeErrorForProtectedMember(owner.UnderlyingSystemType, _info.Name); @@ -198,7 +197,7 @@ internal override void MakeGetExpression(PythonBinder/*!*/ binder, Expression/*! ).Expression, typeof(object) ) - ); + ); } } diff --git a/Src/IronPython/Runtime/Types/ReflectedSlotProperty.cs b/Src/IronPython/Runtime/Types/ReflectedSlotProperty.cs index bf568d6af..94e5e5cee 100644 --- a/Src/IronPython/Runtime/Types/ReflectedSlotProperty.cs +++ b/Src/IronPython/Runtime/Types/ReflectedSlotProperty.cs @@ -5,13 +5,13 @@ using System; using System.Collections.Generic; +using IronPython.Runtime.Operations; + using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Operations; - namespace IronPython.Runtime.Types { - + /// /// Represents a member of a user-defined type which defines __slots__. The names listed in /// __slots__ have storage allocated for them with the type and provide fast get/set access. @@ -19,7 +19,7 @@ namespace IronPython.Runtime.Types { [PythonType("member_descriptor")] internal class ReflectedSlotProperty : PythonTypeDataSlot, ICodeFormattable { private readonly string/*!*/ _name, _typeName; - private readonly int/*!*/ _index; + private readonly int/*!*/ _index; private static readonly Dictionary _methods = new Dictionary(); @@ -124,5 +124,5 @@ private class SlotValue { } internal delegate object SlotGetValue(object instance); - internal delegate void SlotSetValue(object instance, object value); + internal delegate void SlotSetValue(object instance, object value); } diff --git a/Src/IronPython/Runtime/WeakRef.cs b/Src/IronPython/Runtime/WeakRef.cs index 5c73b7fa1..ddd4f0b48 100644 --- a/Src/IronPython/Runtime/WeakRef.cs +++ b/Src/IronPython/Runtime/WeakRef.cs @@ -8,11 +8,11 @@ using System.Linq; using System.Threading; +using IronPython.Runtime.Operations; + using Microsoft.Scripting.Actions; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Operations; - namespace IronPython.Runtime { /// @@ -26,7 +26,7 @@ private readonly struct CallbackInfo { private readonly object _callback; private readonly WeakHandle _longRef; private readonly WeakHandle _shortRef; - + public CallbackInfo(object callback, object weakRef) { _callback = callback; // we need a short ref & a long ref to deal with the case diff --git a/Src/IronPython/Runtime/WrapperDictionary.cs b/Src/IronPython/Runtime/WrapperDictionary.cs index 727a8cc2b..617cf8a67 100644 --- a/Src/IronPython/Runtime/WrapperDictionary.cs +++ b/Src/IronPython/Runtime/WrapperDictionary.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; -using Microsoft.Scripting; + using Microsoft.Scripting.Actions; namespace IronPython.Runtime { @@ -15,7 +15,7 @@ internal class WrapperDictionaryStorage : DictionaryStorage { public WrapperDictionaryStorage(TopNamespaceTracker/*!*/ data) { _data = data; } - + public override void Add(ref DictionaryStorage storage, object key, object value) { throw CannotModifyNamespaceDict(); } diff --git a/Src/IronPython/Runtime/Zip.cs b/Src/IronPython/Runtime/Zip.cs index 24a5a7988..cf7801f4d 100644 --- a/Src/IronPython/Runtime/Zip.cs +++ b/Src/IronPython/Runtime/Zip.cs @@ -7,11 +7,11 @@ using System; using System.Collections; -using Microsoft.Scripting.Runtime; - using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting.Runtime; + namespace IronPython.Runtime { [PythonType("zip")] diff --git a/Src/IronPythonCompiler/AssemblyResolver.cs b/Src/IronPythonCompiler/AssemblyResolver.cs index 57f388c8f..d8039a90e 100644 --- a/Src/IronPythonCompiler/AssemblyResolver.cs +++ b/Src/IronPythonCompiler/AssemblyResolver.cs @@ -1,9 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using IKVM.Reflection; diff --git a/Src/IronPythonCompiler/Config.cs b/Src/IronPythonCompiler/Config.cs index 72e0d6747..7bd6a6402 100644 --- a/Src/IronPythonCompiler/Config.cs +++ b/Src/IronPythonCompiler/Config.cs @@ -1,13 +1,10 @@ using System; -using System.IO; using System.Collections.Generic; -using System.Linq; +using System.IO; using System.Text; -using System.Text.RegularExpressions; -using IKVM.Reflection; + using IKVM.Reflection.Emit; -using System.Resources; -using System.Reflection; + using Microsoft.Scripting.Runtime; namespace IronPythonCompiler { diff --git a/Src/IronPythonCompiler/ConsoleOps.cs b/Src/IronPythonCompiler/ConsoleOps.cs index 93f1b7cf9..9cb352273 100644 --- a/Src/IronPythonCompiler/ConsoleOps.cs +++ b/Src/IronPythonCompiler/ConsoleOps.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace IronPythonCompiler { public static class ConsoleOps { diff --git a/Src/IronPythonCompiler/Properties/AssemblyInfo.cs b/Src/IronPythonCompiler/Properties/AssemblyInfo.cs index 9440f8282..fa8a17c2b 100644 --- a/Src/IronPythonCompiler/Properties/AssemblyInfo.cs +++ b/Src/IronPythonCompiler/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/Src/IronPythonTest/AttrInjectorTest.cs b/Src/IronPythonTest/AttrInjectorTest.cs index ee2aa0746..5dccf794e 100644 --- a/Src/IronPythonTest/AttrInjectorTest.cs +++ b/Src/IronPythonTest/AttrInjectorTest.cs @@ -5,9 +5,9 @@ using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Xml; -using IronPython.Runtime; + using IronPython.Runtime.Types; -using Microsoft.Scripting; + using Microsoft.Scripting.Runtime; [assembly: ExtensionType(typeof(XmlElement), typeof(IronPythonTest.AttrInjectorTest.SimpleXmlAttrInjector))] diff --git a/Src/IronPythonTest/BindTest.cs b/Src/IronPythonTest/BindTest.cs index f7c87ebf1..c4adcb248 100644 --- a/Src/IronPythonTest/BindTest.cs +++ b/Src/IronPythonTest/BindTest.cs @@ -8,12 +8,11 @@ using System.Numerics; using System.Runtime.InteropServices; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - using IronPython.Runtime; using IronPython.Runtime.Types; +using Microsoft.Scripting.Runtime; + namespace IronPythonTest { [Flags] public enum BindResult { @@ -275,7 +274,7 @@ public void M98(string a, string b, string c, string d, out int x, ref Dispatch Flag = 198; } - + public Single P01 { get; set; } @@ -464,55 +463,55 @@ public enum BigEnum : long { } public class DefaultValueTest { - public BindResult Test_Enum(BindResult param=BindResult.Bool) { + public BindResult Test_Enum(BindResult param = BindResult.Bool) { return param; } - public BigEnum Test_BigEnum(BigEnum param=BigEnum.BigValue) { + public BigEnum Test_BigEnum(BigEnum param = BigEnum.BigValue) { return param; } - public string Test_String(string param="Hello World") { + public string Test_String(string param = "Hello World") { return param; } - public int Test_Int(int param=5) { + public int Test_Int(int param = 5) { return param; } - public uint Test_UInt(uint param=uint.MaxValue) { + public uint Test_UInt(uint param = uint.MaxValue) { return param; } - public bool Test_Bool(bool param=true) { + public bool Test_Bool(bool param = true) { return param; } - public char Test_Char(char param='A') { + public char Test_Char(char param = 'A') { return param; } - public byte Test_Byte(byte param=2) { + public byte Test_Byte(byte param = 2) { return param; } - public sbyte Test_SByte(sbyte param=2) { + public sbyte Test_SByte(sbyte param = 2) { return param; } - public short Test_Short(short param=2) { + public short Test_Short(short param = 2) { return param; } - public ushort Test_UShort(ushort param=2) { + public ushort Test_UShort(ushort param = 2) { return param; } - public long Test_Long(long param=long.MaxValue) { + public long Test_Long(long param = long.MaxValue) { return param; } - public ulong Test_ULong(ulong param=ulong.MaxValue) { + public ulong Test_ULong(ulong param = ulong.MaxValue) { return param; } @@ -526,7 +525,7 @@ public string Test_Default_ValueType([DefaultParameterValue(1)] object o) { return o == null ? "(null)" : o.ToString(); } - public string Test_Default_Cast([Optional, DefaultParameterValue(1)]ref object o) { + public string Test_Default_Cast([Optional, DefaultParameterValue(1)] ref object o) { return o == null ? "(null)" : o.ToString(); } } @@ -883,7 +882,7 @@ public static PythonType M17(T x, IEnumerable y) { return DynamicHelpers.GetPythonTypeFromType(typeof(T)); } - + public static PythonType M18(T x) where T : IEnumerable { return DynamicHelpers.GetPythonTypeFromType(typeof(T)); } diff --git a/Src/IronPythonTest/BinderTest.cs b/Src/IronPythonTest/BinderTest.cs index 80b86733a..901bbf8a5 100644 --- a/Src/IronPythonTest/BinderTest.cs +++ b/Src/IronPythonTest/BinderTest.cs @@ -115,8 +115,8 @@ public class CNoOverloads { public void M706(out BigInteger arg) { arg = 2; Flag.Value = 706; } // Default Value - public void M710(Int32 arg=10) { Flag.Value = 710; } - public void M715(Int32 arg, Int32 arg2=10) { Flag.Value = 715; } + public void M710(Int32 arg = 10) { Flag.Value = 710; } + public void M715(Int32 arg, Int32 arg2 = 10) { Flag.Value = 715; } } @@ -147,7 +147,7 @@ public void M300(params C1[] args) { public void M402(Int32 arg3, ref Int32 arg1, out Int32 arg2) { arg1 = arg2 = arg3; } // default value does get used - public void M450(Int32 arg=80) { Flag.Value = arg; } + public void M450(Int32 arg = 80) { Flag.Value = arg; } // 8 args public void M500(Int32 arg1, Int32 arg2, Int32 arg3, Int32 arg4, Int32 arg5, Int32 arg6, Int32 arg7, Int32 arg8) { @@ -245,7 +245,7 @@ public class COtherOverloadConcern { // If 2 instances of a Python subclass of C3 that implements __int__ are passed as arguments this // the first overload should be preferred. public void M140(C3 a, int b) { Flag.Value = 140; } - public void M140(int a, int b) { Flag.Value = 240; } + public void M140(int a, int b) { Flag.Value = 240; } } public interface I1 { void M(); } @@ -322,18 +322,18 @@ public class COverloads_NoArgNecessary { public void M100(out Int32 arg) { arg = 1; Flag.Value = 200; } public void M101() { Flag.Value = 101; } - public void M101(Int32 arg=1) { Flag.Value = 201; } + public void M101(Int32 arg = 1) { Flag.Value = 201; } public void M102() { Flag.Value = 102; } public void M102(params Int32[] arg) { Flag.Value = 202; } public void M103(out Int32 arg) { arg = 1; Flag.Value = 103; } - public void M103(Int32 arg=1) { Flag.Value = 203; } + public void M103(Int32 arg = 1) { Flag.Value = 203; } public void M104(out Int32 arg) { arg = 1; Flag.Value = 104; } public void M104(params Int32[] arg) { Flag.Value = 204; } - public void M105(Int32 arg=1) { Flag.Value = 105; } + public void M105(Int32 arg = 1) { Flag.Value = 105; } public void M105(params Int32[] arg) { Flag.Value = 205; } public void M106(Int32 arg) { Flag.Value = 106; } @@ -364,7 +364,7 @@ public class COverloads_OneArg_NormalArg { public void M106(out Int32 arg, ref Int32 arg2) { arg = 1; Flag.Value = 206; } public void M107(Int32 arg) { Flag.Value = 107; } - public void M107(Int32 arg, Int32 arg2=1) { Flag.Value = 207; } + public void M107(Int32 arg, Int32 arg2 = 1) { Flag.Value = 207; } public void M108(Int32 arg) { Flag.Value = 108; } public void M108(Int32 arg, params Int32[] arg2) { Flag.Value = 208; } @@ -395,7 +395,7 @@ public class COverloads_OneArg_RefArg { public void M105(out Int32 arg, ref Int32 arg2) { arg = 1; Flag.Value = 205; } public void M106(ref Int32 arg) { Flag.Value = 106; } - public void M106(Int32 arg, Int32 arg2=1) { Flag.Value = 206; } + public void M106(Int32 arg, Int32 arg2 = 1) { Flag.Value = 206; } public void M107(ref Int32 arg) { Flag.Value = 107; } public void M107(Int32 arg, params Int32[] arg2) { Flag.Value = 207; } @@ -423,7 +423,7 @@ public class COverloads_OneArg_NullableArg { public void M104(out Int32 arg, ref Int32 arg2) { arg = 1; Flag.Value = 204; } public void M105(Int32? arg) { Flag.Value = 105; } - public void M105(Int32 arg, Int32 arg2=1) { Flag.Value = 205; } + public void M105(Int32 arg, Int32 arg2 = 1) { Flag.Value = 205; } public void M106(Int32? arg) { Flag.Value = 106; } public void M106(Int32 arg, params Int32[] arg2) { Flag.Value = 206; } @@ -467,7 +467,7 @@ public class COverloads_OneArg_NormalOut { public void M102(out Int32 arg, ref Int32 arg2) { arg = 1; Flag.Value = 202; } public void M103(Int32 arg1, out Int32 arg) { arg = 1; Flag.Value = 103; } - public void M103(Int32 arg, Int32 arg2=1) { Flag.Value = 203; } + public void M103(Int32 arg, Int32 arg2 = 1) { Flag.Value = 203; } public void M104(Int32 arg1, out Int32 arg) { arg = 1; Flag.Value = 104; } public void M104(Int32 arg, params Int32[] arg2) { Flag.Value = 204; } @@ -483,7 +483,7 @@ public class COverloads_OneArg_RefOut { public void M100(out Int32 arg, Int32 arg2) { arg = 1; Flag.Value = 200; } public void M101(ref Int32 arg1, out Int32 arg) { arg = 1; Flag.Value = 101; } - public void M101(Int32 arg, Int32 arg2=1) { Flag.Value = 201; } + public void M101(Int32 arg, Int32 arg2 = 1) { Flag.Value = 201; } public void M102(ref Int32 arg1, out Int32 arg) { arg = 1; Flag.Value = 102; } public void M102(Int32 arg, params Int32[] arg2) { Flag.Value = 202; } @@ -499,7 +499,7 @@ public class COverloads_OneArg_OutNormal { public void M100(out Int32 arg, ref Int32 arg2) { arg = 1; Flag.Value = 200; } public void M101(out Int32 arg, Int32 arg2) { arg = 1; Flag.Value = 101; } - public void M101(Int32 arg, Int32 arg2=1) { Flag.Value = 201; } + public void M101(Int32 arg, Int32 arg2 = 1) { Flag.Value = 201; } public void M102(out Int32 arg, Int32 arg2) { arg = 1; Flag.Value = 102; } public void M102(Int32 arg, params Int32[] arg2) { Flag.Value = 202; } @@ -512,7 +512,7 @@ public class COverloads_OneArg_OutNormal { public class COverloads_OneArg_OutRef { #region generated codes public void M100(out Int32 arg, ref Int32 arg2) { arg = 1; Flag.Value = 100; } - public void M100(Int32 arg, Int32 arg2=1) { Flag.Value = 200; } + public void M100(Int32 arg, Int32 arg2 = 1) { Flag.Value = 200; } public void M101(out Int32 arg, ref Int32 arg2) { arg = 1; Flag.Value = 101; } public void M101(Int32 arg, params Int32[] arg2) { Flag.Value = 201; } @@ -524,10 +524,10 @@ public class COverloads_OneArg_OutRef { } public class COverloads_OneArg_NormalDefault { #region generated codes - public void M100(Int32 arg, Int32 arg2=1) { Flag.Value = 100; } + public void M100(Int32 arg, Int32 arg2 = 1) { Flag.Value = 100; } public void M100(Int32 arg, params Int32[] arg2) { Flag.Value = 200; } - public void M101(Int32 arg, Int32 arg2=1) { Flag.Value = 101; } + public void M101(Int32 arg, Int32 arg2 = 1) { Flag.Value = 101; } public void M101(Int32 arg, Int32[] arg2) { Flag.Value = 201; } #endregion @@ -959,7 +959,7 @@ public interface IPublicInterface { public class InterfaceOnlyTest { public static IPublicInterface PrivateClass { get { - return new PrivateClass(); + return new PrivateClass(); } } } @@ -1001,7 +1001,7 @@ public void M() { } #endregion - + } internal class DerivedClassWithInterface : BaseClassNoInterface, I1 { diff --git a/Src/IronPythonTest/Cases/CPythonCases.cs b/Src/IronPythonTest/Cases/CPythonCases.cs index f3d568064..395765c2f 100644 --- a/Src/IronPythonTest/Cases/CPythonCases.cs +++ b/Src/IronPythonTest/Cases/CPythonCases.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; + using NUnit.Framework; namespace IronPythonTest.Cases { @@ -19,7 +20,7 @@ public override int Test(TestInfo testcase) { internal class CPythonCaseGenerator : CommonCaseGenerator { protected override IEnumerable GetTests() { var libFolder = Path.Combine("Src", "StdLib", "Lib"); - return GetFilenames(new [] { + return GetFilenames(new[] { System.Tuple.Create(category, Path.Combine(libFolder, "test")), System.Tuple.Create($"{category}.ctypes", Path.Combine(libFolder, "ctypes", "test")), System.Tuple.Create($"{category}.distutils", Path.Combine(libFolder, "distutils", "tests")), diff --git a/Src/IronPythonTest/Cases/CaseExecuter.cs b/Src/IronPythonTest/Cases/CaseExecuter.cs index d75cbc047..6bd56cc0e 100644 --- a/Src/IronPythonTest/Cases/CaseExecuter.cs +++ b/Src/IronPythonTest/Cases/CaseExecuter.cs @@ -8,7 +8,6 @@ using System.IO; using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -18,11 +17,11 @@ using IronPython.Runtime; using IronPython.Runtime.Exceptions; +using IronPythonTest.Util; + using Microsoft.Scripting; using Microsoft.Scripting.Hosting; -using IronPythonTest.Util; - namespace IronPythonTest.Cases { internal class CaseExecuter { private static string Executable { diff --git a/Src/IronPythonTest/Cases/CaseGenerator.cs b/Src/IronPythonTest/Cases/CaseGenerator.cs index 917ede67c..ff56e381a 100644 --- a/Src/IronPythonTest/Cases/CaseGenerator.cs +++ b/Src/IronPythonTest/Cases/CaseGenerator.cs @@ -10,6 +10,7 @@ using System.Runtime.InteropServices; using IronPython; + using IronPythonTest.Util; using NUnit.Framework; diff --git a/Src/IronPythonTest/Cases/IronPythonCases.cs b/Src/IronPythonTest/Cases/IronPythonCases.cs index 2cd431625..34760546f 100644 --- a/Src/IronPythonTest/Cases/IronPythonCases.cs +++ b/Src/IronPythonTest/Cases/IronPythonCases.cs @@ -5,11 +5,12 @@ using System.Collections.Generic; using System.IO; using System.Linq; + using NUnit.Framework; namespace IronPythonTest.Cases { [TestFixture(Category = "IronPython")] - public class IronPythonCases : CommonCases { + public class IronPythonCases : CommonCases { [Test, TestCaseSource(typeof(IronPythonCaseGenerator))] public override int Test(TestInfo testcase) { return TestImpl(testcase); diff --git a/Src/IronPythonTest/ClrType.cs b/Src/IronPythonTest/ClrType.cs index 787a4b42c..25fdcee73 100644 --- a/Src/IronPythonTest/ClrType.cs +++ b/Src/IronPythonTest/ClrType.cs @@ -3,10 +3,10 @@ // See the LICENSE file in the project root for more information. using System; -using IronPython.Runtime.Types; -using Microsoft.Scripting; -using IronPython.Runtime.Exceptions; + using IronPython.Runtime; +using IronPython.Runtime.Exceptions; +using IronPython.Runtime.Types; namespace IronPythonTest.interop.net.type.clrtype { diff --git a/Src/IronPythonTest/Conversions.cs b/Src/IronPythonTest/Conversions.cs index ee1b94372..4ac0b339c 100644 --- a/Src/IronPythonTest/Conversions.cs +++ b/Src/IronPythonTest/Conversions.cs @@ -2,10 +2,11 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using IronPython.Runtime; using System.Collections; using System.Collections.Generic; +using IronPython.Runtime; + namespace IronPythonTest { /// /// Base used for implicit operator tests where the operator is defined diff --git a/Src/IronPythonTest/DynamicRegressions.cs b/Src/IronPythonTest/DynamicRegressions.cs index 8bc731024..e3133421c 100644 --- a/Src/IronPythonTest/DynamicRegressions.cs +++ b/Src/IronPythonTest/DynamicRegressions.cs @@ -6,8 +6,8 @@ namespace IronPythonTest { public static class DynamicRegressions { - - public static string cp24117(dynamic inputObj){ + + public static string cp24117(dynamic inputObj) { return inputObj.ToString(); } @@ -21,12 +21,9 @@ public static void cp24118(dynamic pythonCode) { } private static void NamedMethod01(dynamic testObj) { - try - { + try { System.Console.WriteLine("1)-1 Exp=33, Act={0}", testObj.Normal01(a: 11, b: 22)); - } - catch (System.Exception e) - { + } catch (System.Exception e) { System.Console.WriteLine("1) a:v, b:v => {0}", e); System.Console.WriteLine("====================================="); } @@ -38,39 +35,32 @@ private static void NamedMethod01(dynamic testObj) { private static void NamedMethod02(dynamic testObj) { // b=1 System.Console.WriteLine("2)-1 Exp=11, Act={0}", testObj.Optional01(a: 10)); // OK - try - { + try { System.Console.WriteLine("2)-2 Exp=33, Act={0}", testObj.Optional01(a: 11, b: 22)); - } - catch (System.Exception e) - { + } catch (System.Exception e) { System.Console.WriteLine("2) a:v, b:v => {0}", e); System.Console.WriteLine("====================================="); } System.Console.WriteLine("2)-3 Exp=38, Act={0}", testObj.Optional01(b: 33, a: 5)); // OK } - + public static void cp24115(dynamic testObj) { try { testObj.x(); throw new Exception("Invoking non-existent method 'x' should have thrown"); - } - catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex) - { + } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex) { if (!ex.Message.Contains("'x'")) { throw new Exception("Error message didn't contain 'x'", ex); } } } - public static bool cp24111(dynamic testObj) - { + public static bool cp24111(dynamic testObj) { return !testObj; } - public static void cp24088(dynamic testObj) - { + public static void cp24088(dynamic testObj) { testObj += 3; } } diff --git a/Src/IronPythonTest/EncodingTest.cs b/Src/IronPythonTest/EncodingTest.cs index 7864f0a12..46884269d 100644 --- a/Src/IronPythonTest/EncodingTest.cs +++ b/Src/IronPythonTest/EncodingTest.cs @@ -4,11 +4,13 @@ #pragma warning disable SYSLIB0001 // UTF-7 code paths are obsolete in .NET 5 +using System.Linq; +using System.Text; + using IronPython.Runtime; using IronPython.Runtime.Operations; + using NUnit.Framework; -using System.Linq; -using System.Text; namespace IronPythonTest { diff --git a/Src/IronPythonTest/EngineTest.cs b/Src/IronPythonTest/EngineTest.cs index f6cd8b21f..22d686332 100644 --- a/Src/IronPythonTest/EngineTest.cs +++ b/Src/IronPythonTest/EngineTest.cs @@ -8,10 +8,8 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Diagnostics; using System.Dynamic; using System.IO; -using System.Reflection; using System.Runtime.CompilerServices; using System.Security; #if FEATURE_REMOTING @@ -28,7 +26,6 @@ using Microsoft.Scripting.Hosting; using Microsoft.Scripting.Runtime; -using IronPython; using IronPython.Hosting; using IronPython.Runtime; using IronPython.Runtime.Exceptions; diff --git a/Src/IronPythonTest/Events.cs b/Src/IronPythonTest/Events.cs index d765c7b85..f834ee97c 100644 --- a/Src/IronPythonTest/Events.cs +++ b/Src/IronPythonTest/Events.cs @@ -37,7 +37,7 @@ public static void CallOtherStatic(object sender, EventArgs args) { private bool _marker = false; - public bool Marker { + public bool Marker { get { return _marker; } set { _marker = value; } } diff --git a/Src/IronPythonTest/ExtensionMethodTest.cs b/Src/IronPythonTest/ExtensionMethodTest.cs index 8526e7411..458ff6250 100644 --- a/Src/IronPythonTest/ExtensionMethodTest.cs +++ b/Src/IronPythonTest/ExtensionMethodTest.cs @@ -2,14 +2,12 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using IronPython.Runtime; using System.Collections; +using System.Collections.Generic; using System.Numerics; +using IronPython.Runtime; + namespace IronPythonTest.ExtensionMethodTest { namespace LinqCollision { public static class WhereTest { diff --git a/Src/IronPythonTest/Indexable.cs b/Src/IronPythonTest/Indexable.cs index 3c5681e67..30c82ba39 100644 --- a/Src/IronPythonTest/Indexable.cs +++ b/Src/IronPythonTest/Indexable.cs @@ -590,7 +590,7 @@ public IEnumerator GetEnumerator() { yield return 3; } } - + public class UsePythonDictAsHashtable { private Hashtable table; diff --git a/Src/IronPythonTest/InheritTest.cs b/Src/IronPythonTest/InheritTest.cs index 28096c872..1e19ed30e 100644 --- a/Src/IronPythonTest/InheritTest.cs +++ b/Src/IronPythonTest/InheritTest.cs @@ -8,14 +8,15 @@ using System.Numerics; using System.Runtime.CompilerServices; using System.Text; + using IronPython.Runtime; namespace IronPythonTest { public interface IOverrideTestInterface { - object x { get;set;} + object x { get; set; } string Method(); - string y { get;set;} + string y { get; set; } string MethodOverridden(); object this[int index] { @@ -27,9 +28,9 @@ object this[int index] { public class OverrideTestDerivedClass : IOverrideTestInterface { public static string Value; - object IOverrideTestInterface.x { get { return "IOverrideTestInterface.x invoked"; } set { Value = value.ToString() + "x"; } } + object IOverrideTestInterface.x { get { return "IOverrideTestInterface.x invoked"; } set { Value = value.ToString() + "x"; } } string IOverrideTestInterface.Method() { return "IOverrideTestInterface.method() invoked"; } - string IOverrideTestInterface.y { get { return "IOverrideTestInterface.y invoked"; } set { Value = value.ToString() + "y"; } } + string IOverrideTestInterface.y { get { return "IOverrideTestInterface.y invoked"; } set { Value = value.ToString() + "y"; } } public string y { get { return "OverrideTestDerivedClass.y invoked"; } } string IOverrideTestInterface.MethodOverridden() { return "IOverrideTestInterface.MethodOverridden() invoked"; } public string MethodOverridden() { return "OverrideTestDerivedClass.MethodOverridden() invoked"; } @@ -182,7 +183,7 @@ public NewClass(int width, int height) : base(-1, -1) { public new virtual MySize Size { get { - return new MySize(size.width+1, size.height+1); + return new MySize(size.width + 1, size.height + 1); } set { size = value; @@ -191,19 +192,19 @@ public NewClass(int width, int height) : base(-1, -1) { public new virtual int Height { get { - return size.height*2 + 1; + return size.height * 2 + 1; } set { - size.height = value/2 + 1; + size.height = value / 2 + 1; } } public new virtual int Width { get { - return size.width*2 + 1; + return size.width * 2 + 1; } set { - size.width = value/2 + 1; + size.width = value / 2 + 1; } } } @@ -932,7 +933,7 @@ public object CallParamsWithContext(CodeContext context, params object[] arg) { return ParamsMethodWithContext(context, arg); } - public object CallIntParamsWithContext(CodeContext context, params int[] arg) { + public object CallIntParamsWithContext(CodeContext context, params int[] arg) { return ParamsIntMethodWithContext(context, arg); } } @@ -1127,7 +1128,7 @@ public static object[] GoWildBig(IGenericMethods i, bool first, string second, I public class FamilyOrAssembly { private object _value; - + protected internal int Method() { return 42; } diff --git a/Src/IronPythonTest/IronMath.cs b/Src/IronPythonTest/IronMath.cs index d824bc05e..63ffaa0fc 100644 --- a/Src/IronPythonTest/IronMath.cs +++ b/Src/IronPythonTest/IronMath.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Numerics; + using Microsoft.Scripting.Utils; namespace IronPythonTest { diff --git a/Src/IronPythonTest/MemberMappingTests.cs b/Src/IronPythonTest/MemberMappingTests.cs index 8d635a116..7540da5da 100644 --- a/Src/IronPythonTest/MemberMappingTests.cs +++ b/Src/IronPythonTest/MemberMappingTests.cs @@ -2,10 +2,9 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Collections.Generic; -using System.Text; using System.Collections; +using System.Collections.Generic; + using IronPython.Runtime.Operations; // Includes tests for mapping from .NET interfaces & known types to various Python protocol methods. diff --git a/Src/IronPythonTest/MemberOverloadTest.cs b/Src/IronPythonTest/MemberOverloadTest.cs index cbe04f170..25fb56b66 100644 --- a/Src/IronPythonTest/MemberOverloadTest.cs +++ b/Src/IronPythonTest/MemberOverloadTest.cs @@ -1,4 +1,5 @@ using System; + using IronPython.Runtime; namespace IronPythonTest { @@ -20,7 +21,7 @@ public void SetMember(string name, object value) { public void SetMember(CodeContext context, string name, object value) { throw new InvalidOperationException("Do not call SetMember1"); } - + public object GetBoundMember(string name) { throw new InvalidOperationException("Do not call GetBoundMember0"); } @@ -28,7 +29,7 @@ public object GetBoundMember(string name) { public object GetBoundMember(CodeContext context, string name) { throw new InvalidOperationException("Do not call GetBoundMember1"); } - + public object GetCustomMember(string name) { throw new InvalidOperationException("Do not call GetCustomMember0"); } @@ -36,7 +37,7 @@ public object GetCustomMember(string name) { public object GetCustomMember(CodeContext context, string name) { throw new InvalidOperationException("Do not call GetCustomMember1"); } - + public void DeleteMember(string name) { throw new InvalidOperationException("Do not call DeleteMember0"); } diff --git a/Src/IronPythonTest/MethodParametersStubs.cs b/Src/IronPythonTest/MethodParametersStubs.cs index 3b9f3a13c..e24f62914 100644 --- a/Src/IronPythonTest/MethodParametersStubs.cs +++ b/Src/IronPythonTest/MethodParametersStubs.cs @@ -5,16 +5,14 @@ using System.Collections; using System.Collections.Generic; using System.ComponentModel; -using System.Net.NetworkInformation; -using System.Runtime.InteropServices; using Microsoft.Scripting; namespace IronPythonTest { public static class DefaultParams { - public static int FuncWithDefaults(int x=1, - int y=2, - int z=3) { + public static int FuncWithDefaults(int x = 1, + int y = 2, + int z = 3) { return x + y + z; } } diff --git a/Src/IronPythonTest/NullableTest.cs b/Src/IronPythonTest/NullableTest.cs index 3bca6fb90..3c82e4fea 100644 --- a/Src/IronPythonTest/NullableTest.cs +++ b/Src/IronPythonTest/NullableTest.cs @@ -4,8 +4,8 @@ namespace IronPythonTest { public class NullableTest { - public enum NullableEnums { NE1=1, NE3=3 }; - + public enum NullableEnums { NE1 = 1, NE3 = 3 }; + private double? _dvalue; private long? _lvalue; private bool? _bvalue; @@ -16,20 +16,17 @@ public double? DProperty { set { _dvalue = value; } } - public long? LProperty - { + public long? LProperty { get { return _lvalue; } set { _lvalue = value; } } - public bool? BProperty - { + public bool? BProperty { get { return _bvalue; } set { _bvalue = value; } } - public NullableEnums? EProperty - { + public NullableEnums? EProperty { get { return _evalue; } set { _evalue = value; } } diff --git a/Src/IronPythonTest/OperatorTest.cs b/Src/IronPythonTest/OperatorTest.cs index dc6694f0e..757964cb6 100644 --- a/Src/IronPythonTest/OperatorTest.cs +++ b/Src/IronPythonTest/OperatorTest.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; + using Microsoft.Scripting.Runtime; [assembly: ExtensionType(typeof(IronPythonTest.ExtendedClass), typeof(IronPythonTest.ExtensionClass))] diff --git a/Src/IronPythonTest/ProtocolTest.cs b/Src/IronPythonTest/ProtocolTest.cs index 43649545e..c14c7a648 100644 --- a/Src/IronPythonTest/ProtocolTest.cs +++ b/Src/IronPythonTest/ProtocolTest.cs @@ -5,6 +5,7 @@ using System; using System.Collections; using System.Runtime.CompilerServices; + using NUnit.Framework; namespace IronPythonTest { diff --git a/Src/IronPythonTest/StaticTest.cs b/Src/IronPythonTest/StaticTest.cs index 67a356824..1a2e2d415 100644 --- a/Src/IronPythonTest/StaticTest.cs +++ b/Src/IronPythonTest/StaticTest.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Runtime.InteropServices; - namespace IronPythonTest.StaticTest { public class B { } public class D : B { } @@ -77,10 +75,10 @@ public class GB { public static string M4() { return "GB.M4-A"; } public static string M4(ref T arg) { return "GB.M4-B"; } - public static string M21(int arg1, int arg2=100) { return "GB.M21"; } + public static string M21(int arg1, int arg2 = 100) { return "GB.M21"; } public static string M22(int arg1) { return "GB.M22"; } - public static string M23(int arg=100) { return "GB.M23"; } - public static string M24(int arg=100) { return "GB.M24"; } + public static string M23(int arg = 100) { return "GB.M23"; } + public static string M24(int arg = 100) { return "GB.M24"; } public static string M25() { return "GB.M25"; } } @@ -92,10 +90,10 @@ public class GD : GB { public static string M4(ref int arg) { return "GD.M4"; } public static string M21(int arg1) { return "GD.M21"; } - public static string M22(int arg1, int arg2=100) { return "GD.M22"; } + public static string M22(int arg1, int arg2 = 100) { return "GD.M22"; } public static new string M23(int arg1) { return "GD.M23"; } public static string M24() { return "GD.M24"; } - public static string M25(int arg=100) { return "GD.M25"; } + public static string M25(int arg = 100) { return "GD.M25"; } } public class KB { diff --git a/Src/IronPythonTest/Stress/Engine.cs b/Src/IronPythonTest/Stress/Engine.cs index c71228736..1e35a7d4d 100644 --- a/Src/IronPythonTest/Stress/Engine.cs +++ b/Src/IronPythonTest/Stress/Engine.cs @@ -3,16 +3,17 @@ // See the LICENSE file in the project root for more information. using System; -using System.Diagnostics; + +using IronPython.Hosting; + using Microsoft.Scripting.Generation; using Microsoft.Scripting.Hosting; -using IronPython.Hosting; using NUnit.Framework; namespace IronPythonTest.Stress { - [TestFixture(Category="IronPython")] + [TestFixture(Category = "IronPython")] public class Engine #if FEATURE_REMOTING : MarshalByRefObject @@ -60,13 +61,11 @@ public void ScenarioXGC() { const long memoryThreshold = 100000; bool emitsUncollectibleCode = Snippets.Shared.SaveSnippets || _env.Setup.DebugMode; - if (!emitsUncollectibleCode) - { + if (!emitsUncollectibleCode) { System.Console.WriteLine("ScenarioGC used {0} bytes of memory.", memoryUsed); if (memoryUsed > memoryThreshold) throw new Exception(String.Format("ScenarioGC used {0} bytes of memory. The threshold is {1} bytes", memoryUsed, memoryThreshold)); - } - else { + } else { System.Console.WriteLine("Skipping memory usage test under SaveSnippets and/or Debug mode."); } } diff --git a/Src/IronPythonTest/StringDictionaryStorage.cs b/Src/IronPythonTest/StringDictionaryStorage.cs index 2efd51d12..5c7936cf2 100644 --- a/Src/IronPythonTest/StringDictionaryStorage.cs +++ b/Src/IronPythonTest/StringDictionaryStorage.cs @@ -3,14 +3,13 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections; using System.Collections.Generic; using System.Threading; -using Microsoft.Scripting.Runtime; - using IronPython.Runtime; +using Microsoft.Scripting.Runtime; + namespace IronPythonTest { [Serializable] internal class StringDictionaryStorage : DictionaryStorage { @@ -120,7 +119,7 @@ public override List> GetItems() { } return res; } - + public override DictionaryStorage Clone() { lock (this) { IDictionary dict; @@ -143,7 +142,7 @@ public override DictionaryStorage Clone() { private void EnsureObjectDictionary() { if (_objDict == null) { Interlocked.CompareExchange>(ref _objDict, new Dictionary(DefaultContext.DefaultPythonContext.EqualityComparer), null); - } + } } } } diff --git a/Src/IronPythonTest/TestBuiltinModule.cs b/Src/IronPythonTest/TestBuiltinModule.cs index 61aab573d..5ea4ccb60 100644 --- a/Src/IronPythonTest/TestBuiltinModule.cs +++ b/Src/IronPythonTest/TestBuiltinModule.cs @@ -2,12 +2,10 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using IronPython.Runtime; + using IronPython.Compiler; +using IronPython.Runtime; [assembly: PythonModule("test_new_module", typeof(IronPythonTest.TestBuiltinModule))] namespace IronPythonTest { diff --git a/Src/IronPythonTest/TypeDescriptor.cs b/Src/IronPythonTest/TypeDescriptor.cs index 1d56536ea..158a65dc2 100644 --- a/Src/IronPythonTest/TypeDescriptor.cs +++ b/Src/IronPythonTest/TypeDescriptor.cs @@ -105,7 +105,7 @@ public object CallCanConvertToForInt(object totest) { public interface IClassFactory { [return: MarshalAs(UnmanagedType.Interface)] object CreateInstance( - [MarshalAs(UnmanagedType.IUnknown)]object pOuterUnk, + [MarshalAs(UnmanagedType.IUnknown)] object pOuterUnk, ref Guid iid); void LockServer(bool Lock); diff --git a/Src/IronPythonTest/Util/IniParser.cs b/Src/IronPythonTest/Util/IniParser.cs index a5101dfc1..d4dca59a4 100644 --- a/Src/IronPythonTest/Util/IniParser.cs +++ b/Src/IronPythonTest/Util/IniParser.cs @@ -7,8 +7,8 @@ using System.IO; namespace IronPythonTest.Util { - using Section = Dictionary; using OptionStore = Dictionary>; + using Section = Dictionary; public class IniParser { private OptionStore options; @@ -68,7 +68,7 @@ private static OptionStore Parse(IEnumerable lines) { Section currentSection = new Section(); OptionStore options = new OptionStore(StringComparer.OrdinalIgnoreCase) { { "DEFAULT", currentSection } }; foreach (var rawline in lines) { - string line = rawline.Split(new [] { ';', '#' }, 2)[0].Trim(); + string line = rawline.Split(new[] { ';', '#' }, 2)[0].Trim(); if (string.IsNullOrEmpty(line)) continue; @@ -78,9 +78,9 @@ private static OptionStore Parse(IEnumerable lines) { if (!options.TryGetValue(sectionName, out currentSection)) { currentSection = new Section(); options.Add(sectionName, currentSection); - } + } } else { - var result = line.Split(new [] {'='}, 2); + var result = line.Split(new[] { '=' }, 2); var key = result[0].Trim(); var value = result.Length > 1 ? result[1] : "1"; @@ -122,7 +122,7 @@ public static bool AsBool(this string s) { } public static int AsInt(this string s) { - if(s == null) { + if (s == null) { throw new ArgumentNullException(nameof(s)); } diff --git a/Src/IronPythonTest/Util/TestManifest.cs b/Src/IronPythonTest/Util/TestManifest.cs index af01c800e..313560f5b 100644 --- a/Src/IronPythonTest/Util/TestManifest.cs +++ b/Src/IronPythonTest/Util/TestManifest.cs @@ -3,10 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; namespace IronPythonTest.Util { public class TestManifest { diff --git a/Src/IronPythonWindow/IronPythonWindow.cs b/Src/IronPythonWindow/IronPythonWindow.cs index 4bd2a22fc..92f31110d 100644 --- a/Src/IronPythonWindow/IronPythonWindow.cs +++ b/Src/IronPythonWindow/IronPythonWindow.cs @@ -5,8 +5,10 @@ using System; using System.Text; using System.Windows.Forms; + using IronPython.Hosting; using IronPython.Runtime; + using Microsoft.Scripting.Hosting; using Microsoft.Scripting.Hosting.Providers; using Microsoft.Scripting.Hosting.Shell; From 184bb15b7870238673247a0656c14210647347c0 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Sun, 17 Nov 2024 15:34:39 +0000 Subject: [PATCH 02/84] Remove unnecessary `Directory.Build.props` file --- IronPythonAnalyzer/Directory.Build.props | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 IronPythonAnalyzer/Directory.Build.props diff --git a/IronPythonAnalyzer/Directory.Build.props b/IronPythonAnalyzer/Directory.Build.props deleted file mode 100644 index c1df2220d..000000000 --- a/IronPythonAnalyzer/Directory.Build.props +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file From 6997cf5b28b507016a497f0b3fc457a1d84a5513 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Sun, 17 Nov 2024 15:35:49 +0000 Subject: [PATCH 03/84] Refactor analyzer project --- .../Analyzer.cs | 4 ++-- .../IronPython.DiagnosticAnalyzer.csproj | 0 IronPython.sln | 12 ++++++------ Src/IronPython/IronPython.csproj | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) rename IronPythonAnalyzer/IronPythonAnalyzer/IronPythonAnalyzerAnalyzer.cs => DiagnosticAnalyzer/Analyzer.cs (98%) rename IronPythonAnalyzer/IronPythonAnalyzer/IronPythonAnalyzer.csproj => DiagnosticAnalyzer/IronPython.DiagnosticAnalyzer.csproj (100%) diff --git a/IronPythonAnalyzer/IronPythonAnalyzer/IronPythonAnalyzerAnalyzer.cs b/DiagnosticAnalyzer/Analyzer.cs similarity index 98% rename from IronPythonAnalyzer/IronPythonAnalyzer/IronPythonAnalyzerAnalyzer.cs rename to DiagnosticAnalyzer/Analyzer.cs index 0cd941e1c..5060e974f 100644 --- a/IronPythonAnalyzer/IronPythonAnalyzer/IronPythonAnalyzerAnalyzer.cs +++ b/DiagnosticAnalyzer/Analyzer.cs @@ -9,9 +9,9 @@ using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Operations; -namespace IronPythonAnalyzer { +namespace IronPython.DiagnosticAnalyzer { [DiagnosticAnalyzer(LanguageNames.CSharp)] - public class IronPythonAnalyzerAnalyzer : DiagnosticAnalyzer { + public class Analyzer : Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer { public const string DiagnosticId = "IronPythonAnalyzer"; #pragma warning disable RS2008 // Enable analyzer release tracking diff --git a/IronPythonAnalyzer/IronPythonAnalyzer/IronPythonAnalyzer.csproj b/DiagnosticAnalyzer/IronPython.DiagnosticAnalyzer.csproj similarity index 100% rename from IronPythonAnalyzer/IronPythonAnalyzer/IronPythonAnalyzer.csproj rename to DiagnosticAnalyzer/IronPython.DiagnosticAnalyzer.csproj diff --git a/IronPython.sln b/IronPython.sln index 3de1c02d7..7a951f797 100644 --- a/IronPython.sln +++ b/IronPython.sln @@ -71,8 +71,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nuget", "nuget", "{EE77D917 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPythonConsole32", "Src\IronPythonConsole32\IronPythonConsole32.csproj", "{AD21022F-E7C1-4B74-97C1-0A0E48EFF992}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPythonAnalyzer", "IronPythonAnalyzer\IronPythonAnalyzer\IronPythonAnalyzer.csproj", "{DA3415F3-6922-42D0-93D7-BEE2E8603A18}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "choco", "choco", "{EA550FD8-2241-4131-8292-619D009E0199}" ProjectSection(SolutionItems) = preProject Package\choco\Choco.Packaging.targets = Package\choco\Choco.Packaging.targets @@ -106,6 +104,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "msi", "msi", "{450F93D5-DF0 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPythonWindow32", "Src\IronPythonWindow32\IronPythonWindow32.csproj", "{8F177DC2-9822-45BD-AB05-1F40FCA86168}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronPython.DiagnosticAnalyzer", "DiagnosticAnalyzer\IronPython.DiagnosticAnalyzer.csproj", "{2DFE89D7-0C39-44E9-94CD-496CC985DFC3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -164,14 +164,14 @@ Global {AD21022F-E7C1-4B74-97C1-0A0E48EFF992}.Debug|Any CPU.Build.0 = Debug|Any CPU {AD21022F-E7C1-4B74-97C1-0A0E48EFF992}.Release|Any CPU.ActiveCfg = Release|Any CPU {AD21022F-E7C1-4B74-97C1-0A0E48EFF992}.Release|Any CPU.Build.0 = Release|Any CPU - {DA3415F3-6922-42D0-93D7-BEE2E8603A18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DA3415F3-6922-42D0-93D7-BEE2E8603A18}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DA3415F3-6922-42D0-93D7-BEE2E8603A18}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DA3415F3-6922-42D0-93D7-BEE2E8603A18}.Release|Any CPU.Build.0 = Release|Any CPU {8F177DC2-9822-45BD-AB05-1F40FCA86168}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8F177DC2-9822-45BD-AB05-1F40FCA86168}.Debug|Any CPU.Build.0 = Debug|Any CPU {8F177DC2-9822-45BD-AB05-1F40FCA86168}.Release|Any CPU.ActiveCfg = Release|Any CPU {8F177DC2-9822-45BD-AB05-1F40FCA86168}.Release|Any CPU.Build.0 = Release|Any CPU + {2DFE89D7-0C39-44E9-94CD-496CC985DFC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2DFE89D7-0C39-44E9-94CD-496CC985DFC3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2DFE89D7-0C39-44E9-94CD-496CC985DFC3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2DFE89D7-0C39-44E9-94CD-496CC985DFC3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Src/IronPython/IronPython.csproj b/Src/IronPython/IronPython.csproj index 41e1bb9eb..e60b47251 100644 --- a/Src/IronPython/IronPython.csproj +++ b/Src/IronPython/IronPython.csproj @@ -58,7 +58,7 @@ - + false Analyzer From 1892629d3dcebca1de34ea16b202007f81fa6644 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Sun, 17 Nov 2024 15:40:38 +0000 Subject: [PATCH 04/84] Rename projects --- IronPython.sln | 12 ++++++------ Src/IronPython.Modules/IronPython.Modules.csproj | 2 +- ...ler.csproj => IronPython.CompilerServices.csproj} | 0 ...ythonConsole.csproj => IronPython.Console.csproj} | 0 ...nConsole32.csproj => IronPython.Console32.csproj} | 0 ...IronPythonTest.csproj => IronPython.Tests.csproj} | 0 ...nWindow.csproj => IronPython.Console.Host.csproj} | 0 ...dow32.csproj => IronPython.Console32.Host.csproj} | 0 8 files changed, 7 insertions(+), 7 deletions(-) rename Src/IronPythonCompiler/{IronPythonCompiler.csproj => IronPython.CompilerServices.csproj} (100%) rename Src/IronPythonConsole/{IronPythonConsole.csproj => IronPython.Console.csproj} (100%) rename Src/IronPythonConsole32/{IronPythonConsole32.csproj => IronPython.Console32.csproj} (100%) rename Src/IronPythonTest/{IronPythonTest.csproj => IronPython.Tests.csproj} (100%) rename Src/IronPythonWindow/{IronPythonWindow.csproj => IronPython.Console.Host.csproj} (100%) rename Src/IronPythonWindow32/{IronPythonWindow32.csproj => IronPython.Console32.Host.csproj} (100%) diff --git a/IronPython.sln b/IronPython.sln index 7a951f797..fb40cd0a7 100644 --- a/IronPython.sln +++ b/IronPython.sln @@ -9,11 +9,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Modules", "Src\I EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Wpf", "Src\IronPython.Wpf\IronPython.Wpf.csproj", "{65E997B7-E99B-4C83-B29E-9951429BB293}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPythonConsole", "Src\IronPythonConsole\IronPythonConsole.csproj", "{811AC32C-11F3-4ED8-92A7-A7E39C2BB704}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console", "Src\IronPythonConsole\IronPython.Console.csproj", "{811AC32C-11F3-4ED8-92A7-A7E39C2BB704}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPythonTest", "Src\IronPythonTest\IronPythonTest.csproj", "{B6B42537-07F8-4F6C-A99A-B155CAEB124E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Tests", "Src\IronPythonTest\IronPython.Tests.csproj", "{B6B42537-07F8-4F6C-A99A-B155CAEB124E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPythonWindow", "Src\IronPythonWindow\IronPythonWindow.csproj", "{81DA19C7-4FEC-47E7-981B-D9310D549F95}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console.Host", "Src\IronPythonWindow\IronPython.Console.Host.csproj", "{81DA19C7-4FEC-47E7-981B-D9310D549F95}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3A14D070-628F-44EF-92DD-47C8BE5C33CD}" ProjectSection(SolutionItems) = preProject @@ -47,7 +47,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{17737ACB Build\Tasks.Targets = Build\Tasks.Targets EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPythonCompiler", "Src\IronPythonCompiler\IronPythonCompiler.csproj", "{3DFB096E-AC09-4E7A-9288-7F7C33C288C7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.CompilerServices", "Src\IronPythonCompiler\IronPython.CompilerServices.csproj", "{3DFB096E-AC09-4E7A-9288-7F7C33C288C7}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DLR", "DLR", "{AC38EFB1-820D-4E90-BF40-BEF3AC825542}" EndProject @@ -69,7 +69,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nuget", "nuget", "{EE77D917 Package\nuget\IronPython.StdLib.nuspec = Package\nuget\IronPython.StdLib.nuspec EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPythonConsole32", "Src\IronPythonConsole32\IronPythonConsole32.csproj", "{AD21022F-E7C1-4B74-97C1-0A0E48EFF992}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32", "Src\IronPythonConsole32\IronPython.Console32.csproj", "{AD21022F-E7C1-4B74-97C1-0A0E48EFF992}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "choco", "choco", "{EA550FD8-2241-4131-8292-619D009E0199}" ProjectSection(SolutionItems) = preProject @@ -102,7 +102,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "msi", "msi", "{450F93D5-DF0 Package\msi\Version.wxi = Package\msi\Version.wxi EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPythonWindow32", "Src\IronPythonWindow32\IronPythonWindow32.csproj", "{8F177DC2-9822-45BD-AB05-1F40FCA86168}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32.Host", "Src\IronPythonWindow32\IronPython.Console32.Host.csproj", "{8F177DC2-9822-45BD-AB05-1F40FCA86168}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronPython.DiagnosticAnalyzer", "DiagnosticAnalyzer\IronPython.DiagnosticAnalyzer.csproj", "{2DFE89D7-0C39-44E9-94CD-496CC985DFC3}" EndProject diff --git a/Src/IronPython.Modules/IronPython.Modules.csproj b/Src/IronPython.Modules/IronPython.Modules.csproj index 4fc2771d2..7d90d5ffb 100644 --- a/Src/IronPython.Modules/IronPython.Modules.csproj +++ b/Src/IronPython.Modules/IronPython.Modules.csproj @@ -26,7 +26,7 @@ - + false Analyzer diff --git a/Src/IronPythonCompiler/IronPythonCompiler.csproj b/Src/IronPythonCompiler/IronPython.CompilerServices.csproj similarity index 100% rename from Src/IronPythonCompiler/IronPythonCompiler.csproj rename to Src/IronPythonCompiler/IronPython.CompilerServices.csproj diff --git a/Src/IronPythonConsole/IronPythonConsole.csproj b/Src/IronPythonConsole/IronPython.Console.csproj similarity index 100% rename from Src/IronPythonConsole/IronPythonConsole.csproj rename to Src/IronPythonConsole/IronPython.Console.csproj diff --git a/Src/IronPythonConsole32/IronPythonConsole32.csproj b/Src/IronPythonConsole32/IronPython.Console32.csproj similarity index 100% rename from Src/IronPythonConsole32/IronPythonConsole32.csproj rename to Src/IronPythonConsole32/IronPython.Console32.csproj diff --git a/Src/IronPythonTest/IronPythonTest.csproj b/Src/IronPythonTest/IronPython.Tests.csproj similarity index 100% rename from Src/IronPythonTest/IronPythonTest.csproj rename to Src/IronPythonTest/IronPython.Tests.csproj diff --git a/Src/IronPythonWindow/IronPythonWindow.csproj b/Src/IronPythonWindow/IronPython.Console.Host.csproj similarity index 100% rename from Src/IronPythonWindow/IronPythonWindow.csproj rename to Src/IronPythonWindow/IronPython.Console.Host.csproj diff --git a/Src/IronPythonWindow32/IronPythonWindow32.csproj b/Src/IronPythonWindow32/IronPython.Console32.Host.csproj similarity index 100% rename from Src/IronPythonWindow32/IronPythonWindow32.csproj rename to Src/IronPythonWindow32/IronPython.Console32.Host.csproj From dd91b5db97498ee690c824d67acaa204f478baf4 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Sun, 17 Nov 2024 17:50:03 +0000 Subject: [PATCH 05/84] Add back "unnecessary" `Directory.Build.props` file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apparently more necessary than I thought 😳 --- DiagnosticAnalyzer/Directory.Build.props | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 DiagnosticAnalyzer/Directory.Build.props diff --git a/DiagnosticAnalyzer/Directory.Build.props b/DiagnosticAnalyzer/Directory.Build.props new file mode 100644 index 000000000..8c119d541 --- /dev/null +++ b/DiagnosticAnalyzer/Directory.Build.props @@ -0,0 +1,2 @@ + + From fb3c09f46b39c769adf3eca2e2a6ec4afbb811f3 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Sun, 17 Nov 2024 17:57:35 +0000 Subject: [PATCH 06/84] Update `Src/README.md` --- Src/README.md | 17 +++++++++++++++++ Src/README.txt | 29 ----------------------------- 2 files changed, 17 insertions(+), 29 deletions(-) create mode 100644 Src/README.md delete mode 100644 Src/README.txt diff --git a/Src/README.md b/Src/README.md new file mode 100644 index 000000000..31bcd431b --- /dev/null +++ b/Src/README.md @@ -0,0 +1,17 @@ +# `src` + +- `IronPython`: Core compiler and runtime (IronPython.dll) + +IronPython.Tests: Targetted compiler and runtime unit tests hosted in a C# test harness. + +`Scripts`: Infrastructure scripts and helpers. + +`StdLib`: Python standard library imports. + +`Tests`: Test suites. + +Please see [the wiki](https://github.com/IronLanguages/ironpython3/wiki) for information on: + +- Setting up a development environment with easy access to utility scripts +- Building +- Running test diff --git a/Src/README.txt b/Src/README.txt deleted file mode 100644 index dca03ff17..000000000 --- a/Src/README.txt +++ /dev/null @@ -1,29 +0,0 @@ -Content description -------------------- - -IronPython - - Core compiler and runtime (IronPython.dll) - -IronPython.Tests - - Targetted compiler and runtime unit tests hosted in a C# test harness. - -Public - - Misc documentation, tutorial - -Samples - - demonstrations, such as comment checker, voice. - -Scripts - - Infrastructure scripts and helpers. - -StdLib - - Python standard library imports. - -Tests - - Test suites. - - -Please see http://wiki.github.com/IronLanguages/main for information on: -- Setting up a development environment with easy access to utility scripts -- Building -- Running test From 717b16cac045d6dc67e9ced853450a8bf33c00e2 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Sun, 17 Nov 2024 18:13:12 +0000 Subject: [PATCH 07/84] Fix NuGet inconsistencies and modernize structure --- IronPython.sln | 28 +++++++++--------- NuGet.config | 6 +--- {Tests => PythonTests}/IndicesTest.py | 0 .../Inputs/RemoteConsole.py | 0 {Tests => PythonTests}/Inputs/UseCLI.py | 0 {Tests => PythonTests}/Inputs/exit.py | 0 .../Inputs/exitFuncRaises.py | 0 {Tests => PythonTests}/Inputs/exitFuncRuns.py | 0 {Tests => PythonTests}/Inputs/raise.py | 0 .../Inputs/simpleCommand.py | 0 {Tests => PythonTests}/Inputs/syntaxError.py | 0 .../Inputs/uninitializedGlobal.py | 0 {Tests => PythonTests}/Modes/ConsoleFlags.ps1 | 0 .../Modes/ConsoleHelp.Debug.out | 0 .../Modes/ConsoleHelp.Release.out | 0 {Tests => PythonTests}/RunAgainstCpy.py | 0 .../Tools/baselines/__builtin__.log | 0 .../Tools/baselines/_codecs.log | 0 .../Tools/baselines/_collections.log | 0 .../Tools/baselines/_sre.log | 0 .../Tools/baselines/_struct.log | 0 .../Tools/baselines/_subprocess.log | 0 .../Tools/baselines/_weakref.log | 0 .../Tools/baselines/_winreg.log | 0 .../Tools/baselines/array.log | 0 .../Tools/baselines/cPickle.log | 0 .../Tools/baselines/cStringIO.log | 0 .../Tools/baselines/copy_reg.log | 0 .../Tools/baselines/datetime.log | 0 {Tests => PythonTests}/Tools/baselines/gc.log | 0 .../Tools/baselines/itertools.log | 0 .../Tools/baselines/math.log | 0 .../Tools/baselines/mmap.log | 0 .../Tools/baselines/msvcrt.log | 0 {Tests => PythonTests}/Tools/baselines/nt.log | 0 .../Tools/baselines/select.log | 0 .../Tools/baselines/signal.log | 0 .../Tools/baselines/sys.log | 0 .../Tools/baselines/thread.log | 0 .../Tools/baselines/time.log | 0 .../Tools/baselines/types_only.log | 0 .../Tools/baselines/xxsubtype.log | 0 .../Tools/check/_functools.log | 0 {Tests => PythonTests}/Tools/cleantests.py | 0 {Tests => PythonTests}/Tools/clr_helpers.py | 0 {Tests => PythonTests}/Tools/cmodule.py | 0 {Tests => PythonTests}/Tools/cpy_tests.py | 0 {Tests => PythonTests}/Tools/logmodule.py | 0 {Tests => PythonTests}/Tools/modulediff.py | 0 {Tests => PythonTests}/Tools/stdmodules.py | 0 .../_ctypes_test_linux32.pyd | Bin .../_ctypes_test_linux64.pyd | Bin {Tests => PythonTests}/_ctypes_test_win32.pyd | Bin {Tests => PythonTests}/_ctypes_test_win64.pyd | Bin {Tests => PythonTests}/badil.py | 0 {Tests => PythonTests}/c1.cs | 0 {Tests => PythonTests}/c2.cs | 0 {Tests => PythonTests}/c3.cs | 0 {Tests => PythonTests}/c4.cs | 0 {Tests => PythonTests}/check_result.bat | 0 {Tests => PythonTests}/compat/common.py | 0 {Tests => PythonTests}/compat/rulediff.py | 0 {Tests => PythonTests}/compat/runsbs.py | 0 {Tests => PythonTests}/compat/sbs_builtin.py | 0 .../compat/sbs_class_compare.py | 0 .../compat/sbs_exceptions/__init__.py | 0 .../compat/sbs_exceptions/define.py | 0 .../compat/sbs_exceptions/for_loop.py | 0 .../compat/sbs_exceptions/if_false.py | 0 .../compat/sbs_exceptions/if_true.py | 0 .../compat/sbs_exceptions/shared.py | 0 .../compat/sbs_exceptions/try_else.py | 0 .../compat/sbs_exceptions/try_except1.py | 0 .../compat/sbs_exceptions/try_except2.py | 0 .../compat/sbs_exceptions/try_except3.py | 0 .../compat/sbs_exceptions/try_finally1.py | 0 .../compat/sbs_exceptions/try_finally2.py | 0 .../compat/sbs_exceptions/try_finally3.py | 0 .../compat/sbs_exceptions/while_loop.py | 0 .../compat/sbs_func_args.py | 0 {Tests => PythonTests}/compat/sbs_library.cs | 0 {Tests => PythonTests}/compat/sbs_newtype.py | 0 .../compat/sbs_parse_string.py | 0 .../compat/sbs_simple_compare.py | 0 .../compat/sbs_simple_ops.py | 0 .../compat/sbs_true_division.py | 0 {Tests => PythonTests}/compat/sbs_typeop.py | 0 {Tests => PythonTests}/compat/testdata.py | 0 {Tests => PythonTests}/custombuiltins.py | 0 {Tests => PythonTests}/debugging/__init__.py | 0 .../debugging/mdbg_tool/__init__.py | 0 .../debugging/pdb_mod/__init__.py | 0 .../debugging/vs/__init__.py | 0 {Tests => PythonTests}/dllsite.py | 0 {Tests => PythonTests}/dummy_module.py | 0 .../dynamic_sanity/dynamic_runner.bat | 0 .../dynamic_sanity/dynamic_sanity.cs | 0 {Tests => PythonTests}/dynamic_sanity/mock.py | 0 .../encoded_files/bad_encoding_name.py | 0 .../encoded_files/bad_latin1_bom.py | 0 .../encoded_files/bad_latin1_bom_decl.py | 0 .../encoded_files/bad_latin1_nbsp.py | 0 .../encoded_files/bad_latin1_nodecl.py | 0 .../encoded_files/bad_utf8_bom_decl.py | 0 .../encoded_files/cp1019.py | 0 .../encoded_files/cp11334_bad.py | 0 .../encoded_files/cp11334_ok.py | 0 .../encoded_files/cp20472.py | 0 .../encoded_files/ok_encoding_nonascii.py | 0 .../encoded_files/ok_encoding_whitespace.py | 0 {Tests => PythonTests}/file_with_BOM.txt | 2 +- {Tests => PythonTests}/file_without_BOM.txt | 2 +- .../functions/test_signatures.py | 0 {Tests => PythonTests}/gen_stdlib_test.py | 0 {Tests => PythonTests}/gh129.zip | Bin {Tests => PythonTests}/harness.py | 0 .../hosting/editor_svcs/test_errorlistener.py | 0 .../editor_svcs/test_tokencategorizer.py | 0 .../import_extant/_vendor/__init__.py | 0 .../_vendor/packaging/__init__.py | 0 .../_vendor/packaging/_structures.py | 0 .../_vendor/packaging/version.py | 0 .../import_extant/extern/__init__.py | 0 {Tests => PythonTests}/interop/__init__.py | 0 .../interop/com/apps/MultiOffice.py | 0 .../interop/com/apps/adodb.py | 0 .../interop/com/apps/excel.py | 0 .../interop/com/apps/scriptpw.py | 0 .../interop/com/apps/word.py | 0 .../interop/com/compat/__init__.py | 0 .../interop/com/compat/hw.py | 0 .../interop/com/compat/hw_client.py | 0 .../interop/com/dlrcomlib/DispEvents.py | 0 .../interop/com/dlrcomlib/InOutParams.py | 0 .../interop/com/dlrcomlib/MultipleParams.py | 0 .../interop/com/dlrcomlib/OptionalParams.py | 0 .../interop/com/dlrcomlib/OutParams.py | 0 .../interop/com/dlrcomlib/ReturnValues.py | 0 .../interop/com/dlrcomlib/SimpleErrors.py | 0 .../interop/com/dlrcomlib/__init__.py | 0 .../interop/com/dlrcomlib/dlrcomserver.py | 0 .../interop/com/dlrcomlib/paramsinretval.py | 0 .../interop/com/dlrcomlib/properties.py | 0 .../com/dlrcomlib/pytraits/__init__.py | 0 .../interop/com/dlrcomlib/pytraits/method.py | 0 .../interop/com/dlrcomlib/pytraits/obj.py | 0 .../interop/com/dlrcomlib/pytraits/prop.py | 0 .../interop/com/dlrcomlib/typelib.py | 0 .../net/derivation/test_ctor_override.py | 0 .../net/derivation/test_event_override.py | 0 .../net/derivation/test_method_override.py | 0 .../net/derivation/test_method_signature.py | 0 .../net/derivation/test_property_override.py | 0 .../net/derivation/test_simplederive.py | 0 .../net/derivation/test_special_method.py | 0 .../net/dynamic/test_dynamic_regressions.py | 0 .../interop/net/event/test_delegate.py | 0 .../interop/net/event/test_event.py | 0 .../interop/net/field/test_field_misc.py | 0 .../net/field/test_fields_inside_enum.py | 0 .../interop/net/field/test_initonly_fields.py | 0 .../interop/net/field/test_instance_fields.py | 0 .../interop/net/field/test_literal_fields.py | 0 .../interop/net/field/test_static_fields.py | 0 .../interop/net/loadorder/module.py | 0 .../interop/net/loadorder/t1a.py | 0 .../interop/net/loadorder/t1b.py | 0 .../interop/net/loadorder/t1c.py | 0 .../interop/net/loadorder/t1d.py | 0 .../interop/net/loadorder/t2a.py | 0 .../interop/net/loadorder/t2b.py | 0 .../interop/net/loadorder/t2c.py | 0 .../interop/net/loadorder/t2d.py | 0 .../interop/net/loadorder/t2e.py | 0 .../interop/net/loadorder/t2f.py | 0 .../interop/net/loadorder/t2g.py | 0 .../interop/net/loadorder/t2h.py | 0 .../interop/net/loadorder/t3a.py | 0 .../interop/net/loadorder/t3b.py | 0 .../interop/net/loadorder/t3c0.py | 0 .../interop/net/loadorder/t3c1.py | 0 .../interop/net/loadorder/t3c2.py | 0 .../interop/net/loadorder/t3d.py | 0 .../interop/net/loadorder/t3e.py | 0 .../interop/net/loadorder/t3f.py | 0 .../interop/net/loadorder/t3g1.py | 0 .../interop/net/loadorder/t3g2.py | 0 .../interop/net/loadorder/t3h.py | 0 .../interop/net/loadorder/t3i.py | 0 .../interop/net/loadorder/t4a.py | 0 .../interop/net/loadorder/t4b.py | 0 .../interop/net/loadorder/t4c.py | 0 .../interop/net/loadorder/t5a.py | 0 .../interop/net/loadorder/t5b.py | 0 .../interop/net/loadorder/t5c1.py | 0 .../interop/net/loadorder/t5c2.py | 0 .../interop/net/loadorder/t6.py | 0 .../interop/net/loadorder/t7a.py | 0 .../interop/net/loadorder/t7b.py | 0 .../interop/net/loadorder/t7c.py | 0 .../interop/net/loadorder/t7d.py | 0 .../interop/net/loadorder/t7e.py | 0 .../interop/net/loadorder/t7f.py | 0 .../interop/net/method/test_arguments.py | 0 .../interop/net/method/test_op_explicit.py | 0 .../interop/net/method/test_op_implicit.py | 0 .../interop/net/method/test_operators.py | 0 .../interop/net/method/test_returnvalue.py | 0 .../interop/net/property/test_indexercs.py | 0 .../interop/net/property/test_indexervb.py | 0 .../interop/net/property/test_property.py | 0 .../interop/net/test_accessibility.py | 0 .../interop/net/test_dynamicobjectmodel.py | 0 .../interop/net/test_loadorder.py | 0 .../interop/net/type/test___clrtype.py | 0 .../interop/net/type/test_assembly.py | 0 .../interop/net/type/test_clr_array.py | 0 .../interop/net/type/test_ctor.py | 0 .../interop/net/type/test_defaultmember.py | 0 .../interop/net/type/test_reachtype.py | 0 .../net/versions/test_four_dot_zero.py | 0 {Tests => PythonTests}/modules/__init__.py | 0 .../modules/io_related/test__bytesio.py | 0 .../modules/io_related/test__fileio.py | 0 .../modules/io_related/test_binascii.py | 0 .../modules/io_related/test_cPickle.py | 0 .../modules/io_related/test_codecs.py | 0 .../modules/io_related/test_copyreg.py | 0 .../modules/io_related/test_fd.py | 0 .../modules/io_related/test_io_StringIO.py | 0 .../modules/io_related/test_marshal.py | 0 .../modules/io_related/test_re.py | 0 .../modules/misc/test__opcode.py | 0 .../modules/misc/test__random.py | 0 .../modules/misc/test__sha256.py | 0 .../modules/misc/test__sha512.py | 0 .../modules/misc/test__warnings.py | 0 .../modules/misc/test__weakref.py | 0 .../modules/misc/test_ctypes.py | 0 .../modules/misc/test_datetime.py | 0 .../modules/misc/test_math.py | 0 .../modules/misc/test_operator.py | 0 .../modules/misc/test_system_namespaces.py | 0 .../modules/misc/test_zlib.py | 0 .../modules/network_related/__init__.py | 0 .../modules/network_related/keycert.pem | 0 .../modules/network_related/test__socket.py | 0 .../modules/network_related/test__ssl.py | 0 .../modules/system_related/__init__.py | 0 .../modules/system_related/test__locale.py | 0 .../modules/system_related/test_errno.py | 0 .../modules/system_related/test_gc.py | 0 .../modules/system_related/test_nt.py | 0 .../modules/system_related/test_os.py | 0 .../modules/system_related/test_resource.py | 0 .../system_related/test_resource_stdlib.py | 0 .../modules/system_related/test_signal.py | 0 .../modules/system_related/test_sys.py | 0 .../system_related/test_sys_getframe.py | 0 .../modules/system_related/test_thread.py | 0 .../modules/system_related/test_time.py | 0 .../modules/type_related/__init__.py | 0 .../modules/type_related/test__struct.py | 0 .../modules/type_related/test_array.py | 0 .../test_bitfields_ctypes_stdlib.py | 0 .../modules/type_related/test_ctypes.py | 0 .../modules/type_related/test_types.py | 0 {Tests => PythonTests}/perf_micro_calls.py | 0 {Tests => PythonTests}/pickles/cp18666.pickle | 0 {Tests => PythonTests}/plans/debugging.html | 0 .../plans/debugging.mdbg_tool.html | 0 .../plans/debugging.pdb_mod.html | 0 .../plans/debugging.vs.html | 0 .../plans/generic_plan_template.py | 0 .../plans/interop.net.derivation.html | 0 ...rop.net.derivation.test_ctor_override.html | 0 ...op.net.derivation.test_event_override.html | 0 ...p.net.derivation.test_method_override.html | 0 ....net.derivation.test_method_signature.html | 0 ...net.derivation.test_property_override.html | 0 ...erop.net.derivation.test_simplederive.html | 0 ...op.net.derivation.test_special_method.html | 0 .../plans/interop.net.event.html | 0 .../interop.net.event.test_delegate.html | 0 .../plans/interop.net.event.test_event.html | 0 .../plans/interop.net.field.html | 0 .../interop.net.field.test_field_misc.html | 0 ...rop.net.field.test_fields_inside_enum.html | 0 {Tests => PythonTests}/plans/interop.net.html | 0 .../plans/interop.net.insert_csharp.html | 0 .../plans/interop.net.method.html | 0 .../interop.net.method.test_arguments.html | 0 .../interop.net.method.test_op_explicit.html | 0 .../interop.net.method.test_op_implicit.html | 0 .../interop.net.method.test_operators.html | 0 .../interop.net.method.test_returnvalue.html | 0 .../plans/interop.net.property.html | 0 .../interop.net.property.test_indexercs.html | 0 .../interop.net.property.test_indexervb.html | 0 .../interop.net.property.test_property.html | 0 .../plans/interop.net.test_accessibility.html | 0 .../interop.net.test_dynamicobjectmodel.html | 0 .../plans/interop.net.test_loadorder.html | 0 .../plans/interop.net.type.html | 0 .../plans/interop.net.type.test_assembly.html | 0 .../interop.net.type.test_clr_array.html | 0 .../plans/interop.net.type.test_ctor.html | 0 .../interop.net.type.test_defaultmember.html | 0 .../interop.net.type.test_reachtype.html | 0 {Tests => PythonTests}/pretest.py | 0 {Tests => PythonTests}/pyc/console_hw.py | 0 {Tests => PythonTests}/pyc/console_hw_args.py | 0 {Tests => PythonTests}/pyc/other_hw.py | 0 {Tests => PythonTests}/pyc/pkg/__init__.py | 0 {Tests => PythonTests}/pyc/pkg/a.py | 0 {Tests => PythonTests}/pyc/pkg/b.py | 0 {Tests => PythonTests}/pyc/pycpkgtest.py | 0 {Tests => PythonTests}/pyc/stdmodules_ok.ps1 | 0 {Tests => PythonTests}/pyc/test_pyc.ps1 | 0 {Tests => PythonTests}/pyc/winforms_hw.py | 0 {Tests => PythonTests}/run.py | 0 {Tests => PythonTests}/run_transformed.bat | 0 {Tests => PythonTests}/sample.txt.gz | Bin .../specialcontext/Consoleless.ps1 | 0 .../specialcontext/verify_ipyw.py | 0 {Tests => PythonTests}/stress/__init__.py | 0 .../stress/bigimport1_test.py | 0 {Tests => PythonTests}/test_array.py | 0 {Tests => PythonTests}/test_assert.py | 0 {Tests => PythonTests}/test_ast.py | 0 {Tests => PythonTests}/test_attr.py | 0 .../test_attribute_customize.py | 0 {Tests => PythonTests}/test_attrinjector.py | 0 {Tests => PythonTests}/test_bigint.py | 0 {Tests => PythonTests}/test_bool.py | 0 {Tests => PythonTests}/test_builtin_stdlib.py | 0 {Tests => PythonTests}/test_builtinfunc.py | 0 {Tests => PythonTests}/test_bytes.py | 0 {Tests => PythonTests}/test_bz2.py | 0 {Tests => PythonTests}/test_bz2_stdlib.py | 0 {Tests => PythonTests}/test_class.py | 0 {Tests => PythonTests}/test_class_stdlib.py | 0 {Tests => PythonTests}/test_cliclass.py | 0 {Tests => PythonTests}/test_closure.py | 0 {Tests => PythonTests}/test_clrexception.py | 0 {Tests => PythonTests}/test_clrload.py | 0 {Tests => PythonTests}/test_clrload2.py | 0 {Tests => PythonTests}/test_clrnuminterop.py | 0 {Tests => PythonTests}/test_clrtype.py | 0 {Tests => PythonTests}/test_clruse.py | 0 .../test_codeccallbacks_stdlib.py | 0 {Tests => PythonTests}/test_codecs.py | 0 {Tests => PythonTests}/test_codecs_stdlib.py | 0 {Tests => PythonTests}/test_compiler.py | 0 {Tests => PythonTests}/test_complex.py | 0 {Tests => PythonTests}/test_complex_stdlib.py | 0 {Tests => PythonTests}/test_conditional.py | 0 {Tests => PythonTests}/test_data.gz | Bin {Tests => PythonTests}/test_datetime.py | 0 .../test_datetime_stdlib.py | 0 {Tests => PythonTests}/test_decimal.py | 0 {Tests => PythonTests}/test_decorator.py | 0 {Tests => PythonTests}/test_delegate.py | 0 {Tests => PythonTests}/test_deque.py | 0 {Tests => PythonTests}/test_descr_stdlib.py | 0 {Tests => PythonTests}/test_dict.py | 0 {Tests => PythonTests}/test_dict_stdlib.py | 0 {Tests => PythonTests}/test_dictcomp.py | 0 {Tests => PythonTests}/test_dllsite.py | 0 {Tests => PythonTests}/test_dlrkwarg.py | 0 {Tests => PythonTests}/test_doc.py | 0 {Tests => PythonTests}/test_enum.py | 0 {Tests => PythonTests}/test_exceptions.py | 0 .../test_exceptions_generated.py | 0 {Tests => PythonTests}/test_excinfo.py | 0 {Tests => PythonTests}/test_exec.py | 0 {Tests => PythonTests}/test_file.py | 0 {Tests => PythonTests}/test_float_stdlib.py | 0 {Tests => PythonTests}/test_formatting.py | 0 {Tests => PythonTests}/test_function.py | 0 .../test_functools_stdlib.py | 0 {Tests => PythonTests}/test_fuzz_parser.py | 0 {Tests => PythonTests}/test_generator.py | 0 .../test_generator_throw.py | 0 {Tests => PythonTests}/test_genericmeth.py | 0 {Tests => PythonTests}/test_hash.py | 0 {Tests => PythonTests}/test_help.py | 0 {Tests => PythonTests}/test_httplib_stdlib.py | 0 {Tests => PythonTests}/test_imp.py | 0 {Tests => PythonTests}/test_importext.py | 0 {Tests => PythonTests}/test_importpkg.py | 0 {Tests => PythonTests}/test_in.py | 0 {Tests => PythonTests}/test_index.py | 0 {Tests => PythonTests}/test_inheritance.py | 0 {Tests => PythonTests}/test_int.py | 0 {Tests => PythonTests}/test_interactive.py | 0 {Tests => PythonTests}/test_io.py | 0 {Tests => PythonTests}/test_io_stdlib.py | 0 {Tests => PythonTests}/test_ipyc.py | 0 {Tests => PythonTests}/test_ipye.py | 0 {Tests => PythonTests}/test_ironmath.py | 0 {Tests => PythonTests}/test_is.py | 0 {Tests => PythonTests}/test_isinstance.py | 0 {Tests => PythonTests}/test_isinstance2.py | 0 {Tests => PythonTests}/test_iterator.py | 0 {Tests => PythonTests}/test_iteratorlength.py | 0 .../test_itertools_stdlib.py | 0 {Tests => PythonTests}/test_json.py | 0 {Tests => PythonTests}/test_kwarg.py | 0 {Tests => PythonTests}/test_list.py | 0 {Tests => PythonTests}/test_listcomp.py | 0 {Tests => PythonTests}/test_long_stdlib.py | 0 {Tests => PythonTests}/test_memory.py | 0 .../test_memoryio_stdlib.py | 0 {Tests => PythonTests}/test_memoryview.py | 0 {Tests => PythonTests}/test_metaclass.py | 0 {Tests => PythonTests}/test_methodbinder1.py | 0 {Tests => PythonTests}/test_methodbinder2.py | 0 {Tests => PythonTests}/test_methoddispatch.py | 0 {Tests => PythonTests}/test_missing.py | 0 {Tests => PythonTests}/test_namebinding.py | 0 {Tests => PythonTests}/test_nonetype.py | 0 {Tests => PythonTests}/test_nonlocal.py | 0 {Tests => PythonTests}/test_number.py | 0 {Tests => PythonTests}/test_numberhash.py | 0 {Tests => PythonTests}/test_numtypes.py | 0 {Tests => PythonTests}/test_pep380_stdlib.py | 0 {Tests => PythonTests}/test_peverify.py | 0 {Tests => PythonTests}/test_pow.py | 0 {Tests => PythonTests}/test_privateBinding.py | 0 {Tests => PythonTests}/test_property.py | 0 {Tests => PythonTests}/test_protected.py | 0 {Tests => PythonTests}/test_pyexpat.py | 0 {Tests => PythonTests}/test_python25.py | 0 {Tests => PythonTests}/test_python26.py | 0 {Tests => PythonTests}/test_range.py | 0 {Tests => PythonTests}/test_re_stdlib.py | 0 {Tests => PythonTests}/test_regressions.py | 0 .../test_regressions_compiled.py | 0 {Tests => PythonTests}/test_sax_stdlib.py | 0 {Tests => PythonTests}/test_scope_stdlib.py | 0 {Tests => PythonTests}/test_set.py | 0 {Tests => PythonTests}/test_setcomp.py | 0 {Tests => PythonTests}/test_shutil.py | 0 {Tests => PythonTests}/test_slice.py | 0 {Tests => PythonTests}/test_slots.py | 0 {Tests => PythonTests}/test_socket_stdlib.py | 0 {Tests => PythonTests}/test_specialcontext.py | 0 {Tests => PythonTests}/test_sqlite3_stdlib.py | 0 {Tests => PythonTests}/test_ssl_stdlib.py | 0 {Tests => PythonTests}/test_statics.py | 0 {Tests => PythonTests}/test_stdconsole.py | 0 {Tests => PythonTests}/test_stdmodules.py | 0 {Tests => PythonTests}/test_str.py | 0 {Tests => PythonTests}/test_str_bytes.py | 0 {Tests => PythonTests}/test_strformat.py | 0 {Tests => PythonTests}/test_struct.py | 0 {Tests => PythonTests}/test_struct_stdlib.py | 0 .../test_struct_threadsafe.py | 0 {Tests => PythonTests}/test_super.py | 0 {Tests => PythonTests}/test_superconsole.py | 0 .../test_surrogateescape.py | 0 .../test_surrogateescape_pythonfuture.py | 0 {Tests => PythonTests}/test_surrogatepass.py | 0 {Tests => PythonTests}/test_syntax.py | 0 {Tests => PythonTests}/test_sys_stdlib.py | 0 {Tests => PythonTests}/test_system_timers.py | 0 {Tests => PythonTests}/test_tcf.py | 0 {Tests => PythonTests}/test_threadsafety.py | 0 {Tests => PythonTests}/test_time_stdlib.py | 0 {Tests => PythonTests}/test_traceback.py | 0 {Tests => PythonTests}/test_tuple.py | 0 {Tests => PythonTests}/test_types_stdlib.py | 0 {Tests => PythonTests}/test_typing_stdlib.py | 0 {Tests => PythonTests}/test_unicode.py | 0 {Tests => PythonTests}/test_unicode_stdlib.py | 0 {Tests => PythonTests}/test_unpack.py | 0 .../test_utf8_mode_stdlib.py | 0 {Tests => PythonTests}/test_weakref.py | 0 {Tests => PythonTests}/test_weakset_stdlib.py | 0 {Tests => PythonTests}/test_winforms.py | 0 {Tests => PythonTests}/test_with.py | 0 {Tests => PythonTests}/test_zipimport.py | 0 {Tests => PythonTests}/testpkg1/__init__.py | 0 {Tests => PythonTests}/testpkg1/mod1.py | 0 {Tests => PythonTests}/timeit.py | 0 {Tests => PythonTests}/toimport.py | 0 {Tests => PythonTests}/transform.py | 0 Src/{ctypes_test => CTypes}/Makefile | 0 Src/{ctypes_test => CTypes}/_ctypes_test.c | 0 Src/{ctypes_test => CTypes}/_ctypes_test.sln | 0 .../_ctypes_test.vcxproj | 0 .../AssemblyResolver.cs | 0 .../Config.cs | 0 .../ConsoleOps.cs | 0 .../IronPython.CompilerServices.csproj | 0 .../Program.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../README.md | 0 .../IronPython.Console.Host.csproj | 0 .../IronPythonWindow.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../ipyw.ico | Bin Src/{IronPythonConsole => Console}/Console.cs | 0 .../IronPython.Console.csproj | 4 +-- .../Properties/AssemblyInfo.cs | 0 .../app.manifest | 0 .../ipy-mono.sh | 0 Src/{IronPythonConsole => Console}/ipy.ico | Bin Src/{IronPythonConsole => Console}/ipy.sh | 0 .../runtimeconfig.template.json | 0 .../IronPython.Console32.Host.csproj | 0 .../IronPython.Console32.csproj | 8 ++--- Src/IronPython/IronPython.csproj | 2 +- .../IronPython.Modules.csproj | 2 +- .../IterTools.cs | 0 .../ModuleOps.cs | 0 .../NtSignalState.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../ResourceMetaPathImporter.cs | 0 .../SimpleSignalState.cs | 0 .../_bisect.cs | 0 .../_codecs.cs | 0 .../_codecs_cn.cs | 0 .../_collections.cs | 0 Src/{IronPython.Modules => Modules}/_csv.cs | 0 .../_ctypes/Array.cs | 0 .../_ctypes/ArrayType.cs | 0 .../_ctypes/CData.cs | 0 .../_ctypes/CFuncPtr.cs | 0 .../_ctypes/CFuncPtrType.cs | 0 .../_ctypes/Extensions.cs | 0 .../_ctypes/Field.cs | 0 .../_ctypes/INativeType.cs | 0 .../_ctypes/LocalOrArg.cs | 0 .../_ctypes/MarshalCleanup.cs | 0 .../_ctypes/MemoryHolder.cs | 0 .../_ctypes/NativeArgument.cs | 0 .../_ctypes/NativeFunctions.cs | 0 .../_ctypes/Pointer.cs | 0 .../_ctypes/PointerType.cs | 0 .../_ctypes/SimpleCData.cs | 0 .../_ctypes/SimpleType.cs | 0 .../_ctypes/SimpleTypeKind.cs | 0 .../_ctypes/StructType.cs | 0 .../_ctypes/Structure.cs | 0 .../_ctypes/Union.cs | 0 .../_ctypes/UnionType.cs | 0 .../_ctypes/_ctypes.cs | 0 .../_ctypes_test.cs | 0 .../_datetime.cs | 0 .../_functools.cs | 0 Src/{IronPython.Modules => Modules}/_heapq.cs | 0 .../_multibytecodec.cs | 0 .../_multiprocessing.cs | 0 .../_opcode.cs | 0 .../_operator.cs | 0 .../_overlapped.cs | 0 .../_pickle.cs | 0 .../_posixsubprocess.cs | 0 .../_random.RandomGen.cs | 0 .../_random.cs | 0 .../_socket.cs | 0 Src/{IronPython.Modules => Modules}/_sre.cs | 0 Src/{IronPython.Modules => Modules}/_ssl.cs | 0 .../_string.cs | 0 .../_struct.cs | 0 .../_sysconfigdata.cs | 0 .../_thread.cs | 0 .../_warnings.cs | 0 .../_weakref.Generated.cs | 0 .../_weakref.cs | 0 .../_winapi.cs | 0 Src/{IronPython.Modules => Modules}/array.cs | 0 Src/{IronPython.Modules => Modules}/atexit.cs | 0 .../audioop.cs | 0 .../binascii.cs | 0 .../bz2/BZ2Compressor.cs | 0 .../bz2/BZ2Decompressor.cs | 0 .../bz2/BZ2Module.cs | 0 .../bz2/dotnetzip/BZip2/BZip2Compressor.cs | 0 .../bz2/dotnetzip/BZip2/BZip2InputStream.cs | 0 .../bz2/dotnetzip/BZip2/BZip2OutputStream.cs | 0 .../bz2/dotnetzip/BZip2/BitWriter.cs | 0 .../bz2/dotnetzip/BZip2/CRC32.cs | 0 .../BZip2/ParallelBZip2OutputStream.cs | 0 .../bz2/dotnetzip/BZip2/Rand.cs | 0 .../bz2/dotnetzip/source.txt | 0 Src/{IronPython.Modules => Modules}/cmath.cs | 0 Src/{IronPython.Modules => Modules}/errno.cs | 0 .../faulthandler.cs | 0 Src/{IronPython.Modules => Modules}/fcntl.cs | 0 Src/{IronPython.Modules => Modules}/gc.cs | 0 Src/{IronPython.Modules => Modules}/grp.cs | 0 .../hashlib/MD5CryptoServiceProvider.cs | 0 .../hashlib/SHA1CryptoServiceProvider.cs | 0 .../hashlib/SHA224.cs | 0 .../hashlib/SHA224Managed.cs | 0 .../hashlib/SHA256Managed.cs | 0 .../hashlib/SHA384Managed.cs | 0 .../hashlib/SHA512Managed.cs | 0 .../hashlib/SHAConstants.cs | 0 .../hashlib/_hashlib.cs | 0 .../hashlib/_md5.cs | 0 .../hashlib/_sha1.cs | 0 .../hashlib/_sha256.cs | 0 .../hashlib/_sha512.cs | 0 .../marshal.cs | 0 .../math.Generated.cs | 0 Src/{IronPython.Modules => Modules}/math.cs | 0 Src/{IronPython.Modules => Modules}/mmap.cs | 0 Src/{IronPython.Modules => Modules}/msvcrt.cs | 0 Src/{IronPython.Modules => Modules}/nt.cs | 0 .../policy.IronPython.Modules.config | 0 Src/{IronPython.Modules => Modules}/pwd.cs | 0 .../pyexpat.cs | 0 Src/{IronPython.Modules => Modules}/re.cs | 0 .../resource.cs | 0 Src/{IronPython.Modules => Modules}/select.cs | 0 Src/{IronPython.Modules => Modules}/signal.cs | 0 Src/{IronPython.Modules => Modules}/spwd.cs | 0 Src/{IronPython.Modules => Modules}/time.cs | 0 Src/{IronPython.Modules => Modules}/winreg.cs | 0 .../winsound.cs | 0 .../xxsubtype.cs | 0 .../zipimport.cs | 0 .../zlib/Compress.cs | 0 .../zlib/Decompress.cs | 0 .../zlib/ZlibModule.cs | 0 .../zlib/zlib.net/Adler32.cs | 0 .../zlib/zlib.net/Deflate.cs | 0 .../zlib/zlib.net/InfBlocks.cs | 0 .../zlib/zlib.net/InfCodes.cs | 0 .../zlib/zlib.net/InfTree.cs | 0 .../zlib/zlib.net/Inflate.cs | 0 .../zlib/zlib.net/StaticTree.cs | 0 .../zlib/zlib.net/Tree.cs | 0 .../zlib/zlib.net/ZStream.cs | 0 .../zlib/zlib.net/ZStreamException.cs | 0 .../zlib/zlib.net/Zlib.cs | 0 .../zlib/zlib.net/history.txt | 0 .../zlib/zlib.net/license.txt | 0 .../zlib/zlib.net/readme.txt | 0 .../Connection.cs | 0 Src/{IronPython.SQLite => SQLite}/Contants.cs | 0 Src/{IronPython.SQLite => SQLite}/Cursor.cs | 0 .../Exceptions.cs | 0 .../Extensions.cs | 0 .../IronPython.SQLite.csproj | 0 .../Properties/AssemblyInfo.cs | 0 Src/{IronPython.SQLite => SQLite}/Row.cs | 0 .../Statement.cs | 0 Src/{IronPython.SQLite => SQLite}/Util.cs | 0 Src/{IronPython.SQLite => SQLite}/_sqlite.cs | 0 .../c#sqlite/.editorconfig | 0 .../c#sqlite/BtreeInt_h.cs | 0 .../c#sqlite/Btree_h.cs | 0 .../c#sqlite/Delegates.cs | 0 .../c#sqlite/Hash_h.cs | 0 .../c#sqlite/VdbeInt_h.cs | 0 .../c#sqlite/Vdbe_h.cs | 0 .../c#sqlite/_Custom.cs | 0 .../c#sqlite/alter_c.cs | 0 .../c#sqlite/analyze_c.cs | 0 .../c#sqlite/attach_c.cs | 0 .../c#sqlite/auth_c.cs | 0 .../c#sqlite/backup_c.cs | 0 .../c#sqlite/bitvec_c.cs | 0 .../c#sqlite/btmutex_c.cs | 0 .../c#sqlite/btree_c.cs | 0 .../c#sqlite/build_c.cs | 0 .../c#sqlite/callback_c.cs | 0 .../c#sqlite/complete_c.cs | 0 .../c#sqlite/crypto.cs | 0 .../c#sqlite/ctime_c.cs | 0 .../c#sqlite/date_c.cs | 0 .../c#sqlite/delete_c.cs | 0 .../c#sqlite/expr_c.cs | 0 .../c#sqlite/fault_c.cs | 0 .../c#sqlite/fkey_c.cs | 0 .../c#sqlite/func_c.cs | 0 .../c#sqlite/global_c.cs | 0 .../c#sqlite/hash_c.cs | 0 .../c#sqlite/hwtime_c.cs | 0 .../c#sqlite/insert_c.cs | 0 .../c#sqlite/journal_c.cs | 0 .../c#sqlite/keywordhash_h.cs | 0 .../c#sqlite/legacy_c.cs | 0 .../c#sqlite/loadext_c.cs | 0 .../c#sqlite/main_c.cs | 0 .../c#sqlite/malloc_c.cs | 0 .../c#sqlite/mem_Pool.cs | 0 .../c#sqlite/memjournal_c.cs | 0 .../c#sqlite/mutex_c.cs | 0 .../c#sqlite/mutex_h.cs | 0 .../c#sqlite/mutex_noop_c.cs | 0 .../c#sqlite/mutex_w32.cs | 0 .../c#sqlite/notify_c.cs | 0 .../c#sqlite/opcodes_c.cs | 0 .../c#sqlite/opcodes_h.cs | 0 .../c#sqlite/os_c.cs | 0 .../c#sqlite/os_common_h.cs | 0 .../c#sqlite/os_h.cs | 0 .../c#sqlite/os_win_c.cs | 0 .../c#sqlite/pager_c.cs | 0 .../c#sqlite/pager_h.cs | 0 .../c#sqlite/parse_c.cs | 0 .../c#sqlite/parse_h.cs | 0 .../c#sqlite/pcache1_c.cs | 0 .../c#sqlite/pcache_c.cs | 0 .../c#sqlite/pcache_h.cs | 0 .../c#sqlite/pragma_c.cs | 0 .../c#sqlite/prepare_c.cs | 0 .../c#sqlite/printf_c.cs | 0 .../c#sqlite/random_c.cs | 0 .../c#sqlite/resolve_c.cs | 0 .../c#sqlite/rowset_c.cs | 0 .../c#sqlite/select_c.cs | 0 .../c#sqlite/sqlite3_h.cs | 0 .../c#sqlite/sqliteInt_h.cs | 0 .../c#sqlite/sqliteLimit_h.cs | 0 .../c#sqlite/status_c.cs | 0 .../c#sqlite/table_c.cs | 0 .../c#sqlite/tokenize_c.cs | 0 .../c#sqlite/trigger_c.cs | 0 .../c#sqlite/update_c.cs | 0 .../c#sqlite/utf_c.cs | 0 .../c#sqlite/util_c.cs | 0 .../c#sqlite/vacuum_c.cs | 0 .../c#sqlite/vdbe_c.cs | 0 .../c#sqlite/vdbeapi_c.cs | 0 .../c#sqlite/vdbeaux_c.cs | 0 .../c#sqlite/vdbeblob_c.cs | 0 .../c#sqlite/vdbemem_c.cs | 0 .../c#sqlite/vdbetrace_c.cs | 0 .../c#sqlite/vtab_c.cs | 0 .../c#sqlite/wal_c.cs | 0 .../c#sqlite/wal_h.cs | 0 .../c#sqlite/walker_c.cs | 0 .../c#sqlite/where_c.cs | 0 Src/{IronPythonTest => Tests}/AssemblyInfo.cs | 0 .../AttrInjectorTest.cs | 0 Src/{IronPythonTest => Tests}/BindTest.cs | 0 Src/{IronPythonTest => Tests}/BinderTest.cs | 0 .../Cases/CPythonCases.cs | 0 .../Cases/CPythonCasesManifest.ini | 0 .../Cases/CaseExecuter.cs | 0 .../Cases/CaseGenerator.cs | 0 .../Cases/CommonCases.cs | 0 .../Cases/IronPythonCases.cs | 0 .../Cases/IronPythonCasesManifest.ini | 0 Src/{IronPythonTest => Tests}/ClrType.cs | 0 Src/{IronPythonTest => Tests}/Cmplx.cs | 0 Src/{IronPythonTest => Tests}/Conversions.cs | 0 Src/{IronPythonTest => Tests}/DeTest.cs | 0 Src/{IronPythonTest => Tests}/DelegateTest.cs | 0 .../DynamicRegressions.cs | 0 Src/{IronPythonTest => Tests}/EncodingTest.cs | 0 Src/{IronPythonTest => Tests}/EngineTest.cs | 0 Src/{IronPythonTest => Tests}/Enums.cs | 0 Src/{IronPythonTest => Tests}/Events.cs | 0 .../ExceptionConverter.cs | 0 Src/{IronPythonTest => Tests}/Exceptions.cs | 0 Src/{IronPythonTest => Tests}/Explicit.cs | 0 .../ExtensionMethodTest.cs | 0 Src/{IronPythonTest => Tests}/GenMeth.cs | 0 Src/{IronPythonTest => Tests}/Indexable.cs | 0 Src/{IronPythonTest => Tests}/InheritTest.cs | 0 Src/{IronPythonTest => Tests}/IntegerTest.cs | 0 Src/{IronPythonTest => Tests}/IronMath.cs | 0 .../IronPython.Tests.csproj | 0 Src/{IronPythonTest => Tests}/LoadTest.cs | 0 .../MemberMappingTests.cs | 0 .../MemberOverloadTest.cs | 0 .../MethodParametersStubs.cs | 0 Src/{IronPythonTest => Tests}/NestedClass.cs | 0 Src/{IronPythonTest => Tests}/NullableTest.cs | 0 Src/{IronPythonTest => Tests}/OperatorTest.cs | 0 Src/{IronPythonTest => Tests}/ProtocolTest.cs | 0 Src/{IronPythonTest => Tests}/StaticTest.cs | 0 .../Stress/Engine.cs | 0 .../StringDictionaryStorage.cs | 0 .../TestBuiltinModule.cs | 0 .../TypeDescriptor.cs | 0 .../Util/IniParser.cs | 0 .../Util/TestManifest.cs | 0 .../DynamicXamlReader.cs | 0 .../IronPython.Wpf.csproj | 0 .../Properties/AssemblyInfo.cs | 0 Src/{IronPython.Wpf => Wpf}/_wpf.cs | 0 {Util => Utils}/NuGet/nuget.exe | Bin .../IKVM/IKVM.Reflection.License.txt | 0 .../References/IKVM/IKVM.Reflection.dll | Bin {Util => Utils}/References/Mono.Posix.dll | Bin 794 files changed, 25 insertions(+), 29 deletions(-) rename {Tests => PythonTests}/IndicesTest.py (100%) rename {Tests => PythonTests}/Inputs/RemoteConsole.py (100%) rename {Tests => PythonTests}/Inputs/UseCLI.py (100%) rename {Tests => PythonTests}/Inputs/exit.py (100%) rename {Tests => PythonTests}/Inputs/exitFuncRaises.py (100%) rename {Tests => PythonTests}/Inputs/exitFuncRuns.py (100%) rename {Tests => PythonTests}/Inputs/raise.py (100%) rename {Tests => PythonTests}/Inputs/simpleCommand.py (100%) rename {Tests => PythonTests}/Inputs/syntaxError.py (100%) rename {Tests => PythonTests}/Inputs/uninitializedGlobal.py (100%) rename {Tests => PythonTests}/Modes/ConsoleFlags.ps1 (100%) rename {Tests => PythonTests}/Modes/ConsoleHelp.Debug.out (100%) rename {Tests => PythonTests}/Modes/ConsoleHelp.Release.out (100%) rename {Tests => PythonTests}/RunAgainstCpy.py (100%) rename {Tests => PythonTests}/Tools/baselines/__builtin__.log (100%) rename {Tests => PythonTests}/Tools/baselines/_codecs.log (100%) rename {Tests => PythonTests}/Tools/baselines/_collections.log (100%) rename {Tests => PythonTests}/Tools/baselines/_sre.log (100%) rename {Tests => PythonTests}/Tools/baselines/_struct.log (100%) rename {Tests => PythonTests}/Tools/baselines/_subprocess.log (100%) rename {Tests => PythonTests}/Tools/baselines/_weakref.log (100%) rename {Tests => PythonTests}/Tools/baselines/_winreg.log (100%) rename {Tests => PythonTests}/Tools/baselines/array.log (100%) rename {Tests => PythonTests}/Tools/baselines/cPickle.log (100%) rename {Tests => PythonTests}/Tools/baselines/cStringIO.log (100%) rename {Tests => PythonTests}/Tools/baselines/copy_reg.log (100%) rename {Tests => PythonTests}/Tools/baselines/datetime.log (100%) rename {Tests => PythonTests}/Tools/baselines/gc.log (100%) rename {Tests => PythonTests}/Tools/baselines/itertools.log (100%) rename {Tests => PythonTests}/Tools/baselines/math.log (100%) rename {Tests => PythonTests}/Tools/baselines/mmap.log (100%) rename {Tests => PythonTests}/Tools/baselines/msvcrt.log (100%) rename {Tests => PythonTests}/Tools/baselines/nt.log (100%) rename {Tests => PythonTests}/Tools/baselines/select.log (100%) rename {Tests => PythonTests}/Tools/baselines/signal.log (100%) rename {Tests => PythonTests}/Tools/baselines/sys.log (100%) rename {Tests => PythonTests}/Tools/baselines/thread.log (100%) rename {Tests => PythonTests}/Tools/baselines/time.log (100%) rename {Tests => PythonTests}/Tools/baselines/types_only.log (100%) rename {Tests => PythonTests}/Tools/baselines/xxsubtype.log (100%) rename {Tests => PythonTests}/Tools/check/_functools.log (100%) rename {Tests => PythonTests}/Tools/cleantests.py (100%) rename {Tests => PythonTests}/Tools/clr_helpers.py (100%) rename {Tests => PythonTests}/Tools/cmodule.py (100%) rename {Tests => PythonTests}/Tools/cpy_tests.py (100%) rename {Tests => PythonTests}/Tools/logmodule.py (100%) rename {Tests => PythonTests}/Tools/modulediff.py (100%) rename {Tests => PythonTests}/Tools/stdmodules.py (100%) rename {Tests => PythonTests}/_ctypes_test_linux32.pyd (100%) rename {Tests => PythonTests}/_ctypes_test_linux64.pyd (100%) rename {Tests => PythonTests}/_ctypes_test_win32.pyd (100%) rename {Tests => PythonTests}/_ctypes_test_win64.pyd (100%) rename {Tests => PythonTests}/badil.py (100%) rename {Tests => PythonTests}/c1.cs (100%) rename {Tests => PythonTests}/c2.cs (100%) rename {Tests => PythonTests}/c3.cs (100%) rename {Tests => PythonTests}/c4.cs (100%) rename {Tests => PythonTests}/check_result.bat (100%) rename {Tests => PythonTests}/compat/common.py (100%) rename {Tests => PythonTests}/compat/rulediff.py (100%) rename {Tests => PythonTests}/compat/runsbs.py (100%) rename {Tests => PythonTests}/compat/sbs_builtin.py (100%) rename {Tests => PythonTests}/compat/sbs_class_compare.py (100%) rename {Tests => PythonTests}/compat/sbs_exceptions/__init__.py (100%) rename {Tests => PythonTests}/compat/sbs_exceptions/define.py (100%) rename {Tests => PythonTests}/compat/sbs_exceptions/for_loop.py (100%) rename {Tests => PythonTests}/compat/sbs_exceptions/if_false.py (100%) rename {Tests => PythonTests}/compat/sbs_exceptions/if_true.py (100%) rename {Tests => PythonTests}/compat/sbs_exceptions/shared.py (100%) rename {Tests => PythonTests}/compat/sbs_exceptions/try_else.py (100%) rename {Tests => PythonTests}/compat/sbs_exceptions/try_except1.py (100%) rename {Tests => PythonTests}/compat/sbs_exceptions/try_except2.py (100%) rename {Tests => PythonTests}/compat/sbs_exceptions/try_except3.py (100%) rename {Tests => PythonTests}/compat/sbs_exceptions/try_finally1.py (100%) rename {Tests => PythonTests}/compat/sbs_exceptions/try_finally2.py (100%) rename {Tests => PythonTests}/compat/sbs_exceptions/try_finally3.py (100%) rename {Tests => PythonTests}/compat/sbs_exceptions/while_loop.py (100%) rename {Tests => PythonTests}/compat/sbs_func_args.py (100%) rename {Tests => PythonTests}/compat/sbs_library.cs (100%) rename {Tests => PythonTests}/compat/sbs_newtype.py (100%) rename {Tests => PythonTests}/compat/sbs_parse_string.py (100%) rename {Tests => PythonTests}/compat/sbs_simple_compare.py (100%) rename {Tests => PythonTests}/compat/sbs_simple_ops.py (100%) rename {Tests => PythonTests}/compat/sbs_true_division.py (100%) rename {Tests => PythonTests}/compat/sbs_typeop.py (100%) rename {Tests => PythonTests}/compat/testdata.py (100%) rename {Tests => PythonTests}/custombuiltins.py (100%) rename {Tests => PythonTests}/debugging/__init__.py (100%) rename {Tests => PythonTests}/debugging/mdbg_tool/__init__.py (100%) rename {Tests => PythonTests}/debugging/pdb_mod/__init__.py (100%) rename {Tests => PythonTests}/debugging/vs/__init__.py (100%) rename {Tests => PythonTests}/dllsite.py (100%) rename {Tests => PythonTests}/dummy_module.py (100%) rename {Tests => PythonTests}/dynamic_sanity/dynamic_runner.bat (100%) rename {Tests => PythonTests}/dynamic_sanity/dynamic_sanity.cs (100%) rename {Tests => PythonTests}/dynamic_sanity/mock.py (100%) rename {Tests => PythonTests}/encoded_files/bad_encoding_name.py (100%) rename {Tests => PythonTests}/encoded_files/bad_latin1_bom.py (100%) rename {Tests => PythonTests}/encoded_files/bad_latin1_bom_decl.py (100%) rename {Tests => PythonTests}/encoded_files/bad_latin1_nbsp.py (100%) rename {Tests => PythonTests}/encoded_files/bad_latin1_nodecl.py (100%) rename {Tests => PythonTests}/encoded_files/bad_utf8_bom_decl.py (100%) rename {Tests => PythonTests}/encoded_files/cp1019.py (100%) rename {Tests => PythonTests}/encoded_files/cp11334_bad.py (100%) rename {Tests => PythonTests}/encoded_files/cp11334_ok.py (100%) rename {Tests => PythonTests}/encoded_files/cp20472.py (100%) rename {Tests => PythonTests}/encoded_files/ok_encoding_nonascii.py (100%) rename {Tests => PythonTests}/encoded_files/ok_encoding_whitespace.py (100%) rename {Tests => PythonTests}/file_with_BOM.txt (88%) rename {Tests => PythonTests}/file_without_BOM.txt (83%) rename {Tests => PythonTests}/functions/test_signatures.py (100%) rename {Tests => PythonTests}/gen_stdlib_test.py (100%) rename {Tests => PythonTests}/gh129.zip (100%) rename {Tests => PythonTests}/harness.py (100%) rename {Tests => PythonTests}/hosting/editor_svcs/test_errorlistener.py (100%) rename {Tests => PythonTests}/hosting/editor_svcs/test_tokencategorizer.py (100%) rename {Tests => PythonTests}/import_extant/_vendor/__init__.py (100%) rename {Tests => PythonTests}/import_extant/_vendor/packaging/__init__.py (100%) rename {Tests => PythonTests}/import_extant/_vendor/packaging/_structures.py (100%) rename {Tests => PythonTests}/import_extant/_vendor/packaging/version.py (100%) rename {Tests => PythonTests}/import_extant/extern/__init__.py (100%) rename {Tests => PythonTests}/interop/__init__.py (100%) rename {Tests => PythonTests}/interop/com/apps/MultiOffice.py (100%) rename {Tests => PythonTests}/interop/com/apps/adodb.py (100%) rename {Tests => PythonTests}/interop/com/apps/excel.py (100%) rename {Tests => PythonTests}/interop/com/apps/scriptpw.py (100%) rename {Tests => PythonTests}/interop/com/apps/word.py (100%) rename {Tests => PythonTests}/interop/com/compat/__init__.py (100%) rename {Tests => PythonTests}/interop/com/compat/hw.py (100%) rename {Tests => PythonTests}/interop/com/compat/hw_client.py (100%) rename {Tests => PythonTests}/interop/com/dlrcomlib/DispEvents.py (100%) rename {Tests => PythonTests}/interop/com/dlrcomlib/InOutParams.py (100%) rename {Tests => PythonTests}/interop/com/dlrcomlib/MultipleParams.py (100%) rename {Tests => PythonTests}/interop/com/dlrcomlib/OptionalParams.py (100%) rename {Tests => PythonTests}/interop/com/dlrcomlib/OutParams.py (100%) rename {Tests => PythonTests}/interop/com/dlrcomlib/ReturnValues.py (100%) rename {Tests => PythonTests}/interop/com/dlrcomlib/SimpleErrors.py (100%) rename {Tests => PythonTests}/interop/com/dlrcomlib/__init__.py (100%) rename {Tests => PythonTests}/interop/com/dlrcomlib/dlrcomserver.py (100%) rename {Tests => PythonTests}/interop/com/dlrcomlib/paramsinretval.py (100%) rename {Tests => PythonTests}/interop/com/dlrcomlib/properties.py (100%) rename {Tests => PythonTests}/interop/com/dlrcomlib/pytraits/__init__.py (100%) rename {Tests => PythonTests}/interop/com/dlrcomlib/pytraits/method.py (100%) rename {Tests => PythonTests}/interop/com/dlrcomlib/pytraits/obj.py (100%) rename {Tests => PythonTests}/interop/com/dlrcomlib/pytraits/prop.py (100%) rename {Tests => PythonTests}/interop/com/dlrcomlib/typelib.py (100%) rename {Tests => PythonTests}/interop/net/derivation/test_ctor_override.py (100%) rename {Tests => PythonTests}/interop/net/derivation/test_event_override.py (100%) rename {Tests => PythonTests}/interop/net/derivation/test_method_override.py (100%) rename {Tests => PythonTests}/interop/net/derivation/test_method_signature.py (100%) rename {Tests => PythonTests}/interop/net/derivation/test_property_override.py (100%) rename {Tests => PythonTests}/interop/net/derivation/test_simplederive.py (100%) rename {Tests => PythonTests}/interop/net/derivation/test_special_method.py (100%) rename {Tests => PythonTests}/interop/net/dynamic/test_dynamic_regressions.py (100%) rename {Tests => PythonTests}/interop/net/event/test_delegate.py (100%) rename {Tests => PythonTests}/interop/net/event/test_event.py (100%) rename {Tests => PythonTests}/interop/net/field/test_field_misc.py (100%) rename {Tests => PythonTests}/interop/net/field/test_fields_inside_enum.py (100%) rename {Tests => PythonTests}/interop/net/field/test_initonly_fields.py (100%) rename {Tests => PythonTests}/interop/net/field/test_instance_fields.py (100%) rename {Tests => PythonTests}/interop/net/field/test_literal_fields.py (100%) rename {Tests => PythonTests}/interop/net/field/test_static_fields.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/module.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t1a.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t1b.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t1c.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t1d.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t2a.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t2b.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t2c.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t2d.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t2e.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t2f.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t2g.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t2h.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t3a.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t3b.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t3c0.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t3c1.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t3c2.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t3d.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t3e.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t3f.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t3g1.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t3g2.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t3h.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t3i.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t4a.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t4b.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t4c.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t5a.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t5b.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t5c1.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t5c2.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t6.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t7a.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t7b.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t7c.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t7d.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t7e.py (100%) rename {Tests => PythonTests}/interop/net/loadorder/t7f.py (100%) rename {Tests => PythonTests}/interop/net/method/test_arguments.py (100%) rename {Tests => PythonTests}/interop/net/method/test_op_explicit.py (100%) rename {Tests => PythonTests}/interop/net/method/test_op_implicit.py (100%) rename {Tests => PythonTests}/interop/net/method/test_operators.py (100%) rename {Tests => PythonTests}/interop/net/method/test_returnvalue.py (100%) rename {Tests => PythonTests}/interop/net/property/test_indexercs.py (100%) rename {Tests => PythonTests}/interop/net/property/test_indexervb.py (100%) rename {Tests => PythonTests}/interop/net/property/test_property.py (100%) rename {Tests => PythonTests}/interop/net/test_accessibility.py (100%) rename {Tests => PythonTests}/interop/net/test_dynamicobjectmodel.py (100%) rename {Tests => PythonTests}/interop/net/test_loadorder.py (100%) rename {Tests => PythonTests}/interop/net/type/test___clrtype.py (100%) rename {Tests => PythonTests}/interop/net/type/test_assembly.py (100%) rename {Tests => PythonTests}/interop/net/type/test_clr_array.py (100%) rename {Tests => PythonTests}/interop/net/type/test_ctor.py (100%) rename {Tests => PythonTests}/interop/net/type/test_defaultmember.py (100%) rename {Tests => PythonTests}/interop/net/type/test_reachtype.py (100%) rename {Tests => PythonTests}/interop/net/versions/test_four_dot_zero.py (100%) rename {Tests => PythonTests}/modules/__init__.py (100%) rename {Tests => PythonTests}/modules/io_related/test__bytesio.py (100%) rename {Tests => PythonTests}/modules/io_related/test__fileio.py (100%) rename {Tests => PythonTests}/modules/io_related/test_binascii.py (100%) rename {Tests => PythonTests}/modules/io_related/test_cPickle.py (100%) rename {Tests => PythonTests}/modules/io_related/test_codecs.py (100%) rename {Tests => PythonTests}/modules/io_related/test_copyreg.py (100%) rename {Tests => PythonTests}/modules/io_related/test_fd.py (100%) rename {Tests => PythonTests}/modules/io_related/test_io_StringIO.py (100%) rename {Tests => PythonTests}/modules/io_related/test_marshal.py (100%) rename {Tests => PythonTests}/modules/io_related/test_re.py (100%) rename {Tests => PythonTests}/modules/misc/test__opcode.py (100%) rename {Tests => PythonTests}/modules/misc/test__random.py (100%) rename {Tests => PythonTests}/modules/misc/test__sha256.py (100%) rename {Tests => PythonTests}/modules/misc/test__sha512.py (100%) rename {Tests => PythonTests}/modules/misc/test__warnings.py (100%) rename {Tests => PythonTests}/modules/misc/test__weakref.py (100%) rename {Tests => PythonTests}/modules/misc/test_ctypes.py (100%) rename {Tests => PythonTests}/modules/misc/test_datetime.py (100%) rename {Tests => PythonTests}/modules/misc/test_math.py (100%) rename {Tests => PythonTests}/modules/misc/test_operator.py (100%) rename {Tests => PythonTests}/modules/misc/test_system_namespaces.py (100%) rename {Tests => PythonTests}/modules/misc/test_zlib.py (100%) rename {Tests => PythonTests}/modules/network_related/__init__.py (100%) rename {Tests => PythonTests}/modules/network_related/keycert.pem (100%) rename {Tests => PythonTests}/modules/network_related/test__socket.py (100%) rename {Tests => PythonTests}/modules/network_related/test__ssl.py (100%) rename {Tests => PythonTests}/modules/system_related/__init__.py (100%) rename {Tests => PythonTests}/modules/system_related/test__locale.py (100%) rename {Tests => PythonTests}/modules/system_related/test_errno.py (100%) rename {Tests => PythonTests}/modules/system_related/test_gc.py (100%) rename {Tests => PythonTests}/modules/system_related/test_nt.py (100%) rename {Tests => PythonTests}/modules/system_related/test_os.py (100%) rename {Tests => PythonTests}/modules/system_related/test_resource.py (100%) rename {Tests => PythonTests}/modules/system_related/test_resource_stdlib.py (100%) rename {Tests => PythonTests}/modules/system_related/test_signal.py (100%) rename {Tests => PythonTests}/modules/system_related/test_sys.py (100%) rename {Tests => PythonTests}/modules/system_related/test_sys_getframe.py (100%) rename {Tests => PythonTests}/modules/system_related/test_thread.py (100%) rename {Tests => PythonTests}/modules/system_related/test_time.py (100%) rename {Tests => PythonTests}/modules/type_related/__init__.py (100%) rename {Tests => PythonTests}/modules/type_related/test__struct.py (100%) rename {Tests => PythonTests}/modules/type_related/test_array.py (100%) rename {Tests => PythonTests}/modules/type_related/test_bitfields_ctypes_stdlib.py (100%) rename {Tests => PythonTests}/modules/type_related/test_ctypes.py (100%) rename {Tests => PythonTests}/modules/type_related/test_types.py (100%) rename {Tests => PythonTests}/perf_micro_calls.py (100%) rename {Tests => PythonTests}/pickles/cp18666.pickle (100%) rename {Tests => PythonTests}/plans/debugging.html (100%) rename {Tests => PythonTests}/plans/debugging.mdbg_tool.html (100%) rename {Tests => PythonTests}/plans/debugging.pdb_mod.html (100%) rename {Tests => PythonTests}/plans/debugging.vs.html (100%) rename {Tests => PythonTests}/plans/generic_plan_template.py (100%) rename {Tests => PythonTests}/plans/interop.net.derivation.html (100%) rename {Tests => PythonTests}/plans/interop.net.derivation.test_ctor_override.html (100%) rename {Tests => PythonTests}/plans/interop.net.derivation.test_event_override.html (100%) rename {Tests => PythonTests}/plans/interop.net.derivation.test_method_override.html (100%) rename {Tests => PythonTests}/plans/interop.net.derivation.test_method_signature.html (100%) rename {Tests => PythonTests}/plans/interop.net.derivation.test_property_override.html (100%) rename {Tests => PythonTests}/plans/interop.net.derivation.test_simplederive.html (100%) rename {Tests => PythonTests}/plans/interop.net.derivation.test_special_method.html (100%) rename {Tests => PythonTests}/plans/interop.net.event.html (100%) rename {Tests => PythonTests}/plans/interop.net.event.test_delegate.html (100%) rename {Tests => PythonTests}/plans/interop.net.event.test_event.html (100%) rename {Tests => PythonTests}/plans/interop.net.field.html (100%) rename {Tests => PythonTests}/plans/interop.net.field.test_field_misc.html (100%) rename {Tests => PythonTests}/plans/interop.net.field.test_fields_inside_enum.html (100%) rename {Tests => PythonTests}/plans/interop.net.html (100%) rename {Tests => PythonTests}/plans/interop.net.insert_csharp.html (100%) rename {Tests => PythonTests}/plans/interop.net.method.html (100%) rename {Tests => PythonTests}/plans/interop.net.method.test_arguments.html (100%) rename {Tests => PythonTests}/plans/interop.net.method.test_op_explicit.html (100%) rename {Tests => PythonTests}/plans/interop.net.method.test_op_implicit.html (100%) rename {Tests => PythonTests}/plans/interop.net.method.test_operators.html (100%) rename {Tests => PythonTests}/plans/interop.net.method.test_returnvalue.html (100%) rename {Tests => PythonTests}/plans/interop.net.property.html (100%) rename {Tests => PythonTests}/plans/interop.net.property.test_indexercs.html (100%) rename {Tests => PythonTests}/plans/interop.net.property.test_indexervb.html (100%) rename {Tests => PythonTests}/plans/interop.net.property.test_property.html (100%) rename {Tests => PythonTests}/plans/interop.net.test_accessibility.html (100%) rename {Tests => PythonTests}/plans/interop.net.test_dynamicobjectmodel.html (100%) rename {Tests => PythonTests}/plans/interop.net.test_loadorder.html (100%) rename {Tests => PythonTests}/plans/interop.net.type.html (100%) rename {Tests => PythonTests}/plans/interop.net.type.test_assembly.html (100%) rename {Tests => PythonTests}/plans/interop.net.type.test_clr_array.html (100%) rename {Tests => PythonTests}/plans/interop.net.type.test_ctor.html (100%) rename {Tests => PythonTests}/plans/interop.net.type.test_defaultmember.html (100%) rename {Tests => PythonTests}/plans/interop.net.type.test_reachtype.html (100%) rename {Tests => PythonTests}/pretest.py (100%) rename {Tests => PythonTests}/pyc/console_hw.py (100%) rename {Tests => PythonTests}/pyc/console_hw_args.py (100%) rename {Tests => PythonTests}/pyc/other_hw.py (100%) rename {Tests => PythonTests}/pyc/pkg/__init__.py (100%) rename {Tests => PythonTests}/pyc/pkg/a.py (100%) rename {Tests => PythonTests}/pyc/pkg/b.py (100%) rename {Tests => PythonTests}/pyc/pycpkgtest.py (100%) rename {Tests => PythonTests}/pyc/stdmodules_ok.ps1 (100%) rename {Tests => PythonTests}/pyc/test_pyc.ps1 (100%) rename {Tests => PythonTests}/pyc/winforms_hw.py (100%) rename {Tests => PythonTests}/run.py (100%) rename {Tests => PythonTests}/run_transformed.bat (100%) rename {Tests => PythonTests}/sample.txt.gz (100%) rename {Tests => PythonTests}/specialcontext/Consoleless.ps1 (100%) rename {Tests => PythonTests}/specialcontext/verify_ipyw.py (100%) rename {Tests => PythonTests}/stress/__init__.py (100%) rename {Tests => PythonTests}/stress/bigimport1_test.py (100%) rename {Tests => PythonTests}/test_array.py (100%) rename {Tests => PythonTests}/test_assert.py (100%) rename {Tests => PythonTests}/test_ast.py (100%) rename {Tests => PythonTests}/test_attr.py (100%) rename {Tests => PythonTests}/test_attribute_customize.py (100%) rename {Tests => PythonTests}/test_attrinjector.py (100%) rename {Tests => PythonTests}/test_bigint.py (100%) rename {Tests => PythonTests}/test_bool.py (100%) rename {Tests => PythonTests}/test_builtin_stdlib.py (100%) rename {Tests => PythonTests}/test_builtinfunc.py (100%) rename {Tests => PythonTests}/test_bytes.py (100%) rename {Tests => PythonTests}/test_bz2.py (100%) rename {Tests => PythonTests}/test_bz2_stdlib.py (100%) rename {Tests => PythonTests}/test_class.py (100%) rename {Tests => PythonTests}/test_class_stdlib.py (100%) rename {Tests => PythonTests}/test_cliclass.py (100%) rename {Tests => PythonTests}/test_closure.py (100%) rename {Tests => PythonTests}/test_clrexception.py (100%) rename {Tests => PythonTests}/test_clrload.py (100%) rename {Tests => PythonTests}/test_clrload2.py (100%) rename {Tests => PythonTests}/test_clrnuminterop.py (100%) rename {Tests => PythonTests}/test_clrtype.py (100%) rename {Tests => PythonTests}/test_clruse.py (100%) rename {Tests => PythonTests}/test_codeccallbacks_stdlib.py (100%) rename {Tests => PythonTests}/test_codecs.py (100%) rename {Tests => PythonTests}/test_codecs_stdlib.py (100%) rename {Tests => PythonTests}/test_compiler.py (100%) rename {Tests => PythonTests}/test_complex.py (100%) rename {Tests => PythonTests}/test_complex_stdlib.py (100%) rename {Tests => PythonTests}/test_conditional.py (100%) rename {Tests => PythonTests}/test_data.gz (100%) rename {Tests => PythonTests}/test_datetime.py (100%) rename {Tests => PythonTests}/test_datetime_stdlib.py (100%) rename {Tests => PythonTests}/test_decimal.py (100%) rename {Tests => PythonTests}/test_decorator.py (100%) rename {Tests => PythonTests}/test_delegate.py (100%) rename {Tests => PythonTests}/test_deque.py (100%) rename {Tests => PythonTests}/test_descr_stdlib.py (100%) rename {Tests => PythonTests}/test_dict.py (100%) rename {Tests => PythonTests}/test_dict_stdlib.py (100%) rename {Tests => PythonTests}/test_dictcomp.py (100%) rename {Tests => PythonTests}/test_dllsite.py (100%) rename {Tests => PythonTests}/test_dlrkwarg.py (100%) rename {Tests => PythonTests}/test_doc.py (100%) rename {Tests => PythonTests}/test_enum.py (100%) rename {Tests => PythonTests}/test_exceptions.py (100%) rename {Tests => PythonTests}/test_exceptions_generated.py (100%) rename {Tests => PythonTests}/test_excinfo.py (100%) rename {Tests => PythonTests}/test_exec.py (100%) rename {Tests => PythonTests}/test_file.py (100%) rename {Tests => PythonTests}/test_float_stdlib.py (100%) rename {Tests => PythonTests}/test_formatting.py (100%) rename {Tests => PythonTests}/test_function.py (100%) rename {Tests => PythonTests}/test_functools_stdlib.py (100%) rename {Tests => PythonTests}/test_fuzz_parser.py (100%) rename {Tests => PythonTests}/test_generator.py (100%) rename {Tests => PythonTests}/test_generator_throw.py (100%) rename {Tests => PythonTests}/test_genericmeth.py (100%) rename {Tests => PythonTests}/test_hash.py (100%) rename {Tests => PythonTests}/test_help.py (100%) rename {Tests => PythonTests}/test_httplib_stdlib.py (100%) rename {Tests => PythonTests}/test_imp.py (100%) rename {Tests => PythonTests}/test_importext.py (100%) rename {Tests => PythonTests}/test_importpkg.py (100%) rename {Tests => PythonTests}/test_in.py (100%) rename {Tests => PythonTests}/test_index.py (100%) rename {Tests => PythonTests}/test_inheritance.py (100%) rename {Tests => PythonTests}/test_int.py (100%) rename {Tests => PythonTests}/test_interactive.py (100%) rename {Tests => PythonTests}/test_io.py (100%) rename {Tests => PythonTests}/test_io_stdlib.py (100%) rename {Tests => PythonTests}/test_ipyc.py (100%) rename {Tests => PythonTests}/test_ipye.py (100%) rename {Tests => PythonTests}/test_ironmath.py (100%) rename {Tests => PythonTests}/test_is.py (100%) rename {Tests => PythonTests}/test_isinstance.py (100%) rename {Tests => PythonTests}/test_isinstance2.py (100%) rename {Tests => PythonTests}/test_iterator.py (100%) rename {Tests => PythonTests}/test_iteratorlength.py (100%) rename {Tests => PythonTests}/test_itertools_stdlib.py (100%) rename {Tests => PythonTests}/test_json.py (100%) rename {Tests => PythonTests}/test_kwarg.py (100%) rename {Tests => PythonTests}/test_list.py (100%) rename {Tests => PythonTests}/test_listcomp.py (100%) rename {Tests => PythonTests}/test_long_stdlib.py (100%) rename {Tests => PythonTests}/test_memory.py (100%) rename {Tests => PythonTests}/test_memoryio_stdlib.py (100%) rename {Tests => PythonTests}/test_memoryview.py (100%) rename {Tests => PythonTests}/test_metaclass.py (100%) rename {Tests => PythonTests}/test_methodbinder1.py (100%) rename {Tests => PythonTests}/test_methodbinder2.py (100%) rename {Tests => PythonTests}/test_methoddispatch.py (100%) rename {Tests => PythonTests}/test_missing.py (100%) rename {Tests => PythonTests}/test_namebinding.py (100%) rename {Tests => PythonTests}/test_nonetype.py (100%) rename {Tests => PythonTests}/test_nonlocal.py (100%) rename {Tests => PythonTests}/test_number.py (100%) rename {Tests => PythonTests}/test_numberhash.py (100%) rename {Tests => PythonTests}/test_numtypes.py (100%) rename {Tests => PythonTests}/test_pep380_stdlib.py (100%) rename {Tests => PythonTests}/test_peverify.py (100%) rename {Tests => PythonTests}/test_pow.py (100%) rename {Tests => PythonTests}/test_privateBinding.py (100%) rename {Tests => PythonTests}/test_property.py (100%) rename {Tests => PythonTests}/test_protected.py (100%) rename {Tests => PythonTests}/test_pyexpat.py (100%) rename {Tests => PythonTests}/test_python25.py (100%) rename {Tests => PythonTests}/test_python26.py (100%) rename {Tests => PythonTests}/test_range.py (100%) rename {Tests => PythonTests}/test_re_stdlib.py (100%) rename {Tests => PythonTests}/test_regressions.py (100%) rename {Tests => PythonTests}/test_regressions_compiled.py (100%) rename {Tests => PythonTests}/test_sax_stdlib.py (100%) rename {Tests => PythonTests}/test_scope_stdlib.py (100%) rename {Tests => PythonTests}/test_set.py (100%) rename {Tests => PythonTests}/test_setcomp.py (100%) rename {Tests => PythonTests}/test_shutil.py (100%) rename {Tests => PythonTests}/test_slice.py (100%) rename {Tests => PythonTests}/test_slots.py (100%) rename {Tests => PythonTests}/test_socket_stdlib.py (100%) rename {Tests => PythonTests}/test_specialcontext.py (100%) rename {Tests => PythonTests}/test_sqlite3_stdlib.py (100%) rename {Tests => PythonTests}/test_ssl_stdlib.py (100%) rename {Tests => PythonTests}/test_statics.py (100%) rename {Tests => PythonTests}/test_stdconsole.py (100%) rename {Tests => PythonTests}/test_stdmodules.py (100%) rename {Tests => PythonTests}/test_str.py (100%) rename {Tests => PythonTests}/test_str_bytes.py (100%) rename {Tests => PythonTests}/test_strformat.py (100%) rename {Tests => PythonTests}/test_struct.py (100%) rename {Tests => PythonTests}/test_struct_stdlib.py (100%) rename {Tests => PythonTests}/test_struct_threadsafe.py (100%) rename {Tests => PythonTests}/test_super.py (100%) rename {Tests => PythonTests}/test_superconsole.py (100%) rename {Tests => PythonTests}/test_surrogateescape.py (100%) rename {Tests => PythonTests}/test_surrogateescape_pythonfuture.py (100%) rename {Tests => PythonTests}/test_surrogatepass.py (100%) rename {Tests => PythonTests}/test_syntax.py (100%) rename {Tests => PythonTests}/test_sys_stdlib.py (100%) rename {Tests => PythonTests}/test_system_timers.py (100%) rename {Tests => PythonTests}/test_tcf.py (100%) rename {Tests => PythonTests}/test_threadsafety.py (100%) rename {Tests => PythonTests}/test_time_stdlib.py (100%) rename {Tests => PythonTests}/test_traceback.py (100%) rename {Tests => PythonTests}/test_tuple.py (100%) rename {Tests => PythonTests}/test_types_stdlib.py (100%) rename {Tests => PythonTests}/test_typing_stdlib.py (100%) rename {Tests => PythonTests}/test_unicode.py (100%) rename {Tests => PythonTests}/test_unicode_stdlib.py (100%) rename {Tests => PythonTests}/test_unpack.py (100%) rename {Tests => PythonTests}/test_utf8_mode_stdlib.py (100%) rename {Tests => PythonTests}/test_weakref.py (100%) rename {Tests => PythonTests}/test_weakset_stdlib.py (100%) rename {Tests => PythonTests}/test_winforms.py (100%) rename {Tests => PythonTests}/test_with.py (100%) rename {Tests => PythonTests}/test_zipimport.py (100%) rename {Tests => PythonTests}/testpkg1/__init__.py (100%) rename {Tests => PythonTests}/testpkg1/mod1.py (100%) rename {Tests => PythonTests}/timeit.py (100%) rename {Tests => PythonTests}/toimport.py (100%) rename {Tests => PythonTests}/transform.py (100%) rename Src/{ctypes_test => CTypes}/Makefile (100%) rename Src/{ctypes_test => CTypes}/_ctypes_test.c (100%) rename Src/{ctypes_test => CTypes}/_ctypes_test.sln (100%) rename Src/{ctypes_test => CTypes}/_ctypes_test.vcxproj (100%) rename Src/{IronPythonCompiler => CompilerServices}/AssemblyResolver.cs (100%) rename Src/{IronPythonCompiler => CompilerServices}/Config.cs (100%) rename Src/{IronPythonCompiler => CompilerServices}/ConsoleOps.cs (100%) rename Src/{IronPythonCompiler => CompilerServices}/IronPython.CompilerServices.csproj (100%) rename Src/{IronPythonCompiler => CompilerServices}/Program.cs (100%) rename Src/{IronPythonCompiler => CompilerServices}/Properties/AssemblyInfo.cs (100%) rename Src/{IronPythonCompiler => CompilerServices}/README.md (100%) rename Src/{IronPythonWindow => Console.Host}/IronPython.Console.Host.csproj (100%) rename Src/{IronPythonWindow => Console.Host}/IronPythonWindow.cs (100%) rename Src/{IronPythonWindow => Console.Host}/Properties/AssemblyInfo.cs (100%) rename Src/{IronPythonWindow => Console.Host}/ipyw.ico (100%) rename Src/{IronPythonConsole => Console}/Console.cs (100%) rename Src/{IronPythonConsole => Console}/IronPython.Console.csproj (90%) rename Src/{IronPythonConsole => Console}/Properties/AssemblyInfo.cs (100%) rename Src/{IronPythonConsole => Console}/app.manifest (100%) rename Src/{IronPythonConsole => Console}/ipy-mono.sh (100%) mode change 100755 => 100644 rename Src/{IronPythonConsole => Console}/ipy.ico (100%) rename Src/{IronPythonConsole => Console}/ipy.sh (100%) mode change 100755 => 100644 rename Src/{IronPythonConsole => Console}/runtimeconfig.template.json (100%) rename Src/{IronPythonWindow32 => Console32.Host}/IronPython.Console32.Host.csproj (100%) rename Src/{IronPythonConsole32 => Console32}/IronPython.Console32.csproj (68%) rename Src/{IronPython.Modules => Modules}/IronPython.Modules.csproj (95%) rename Src/{IronPython.Modules => Modules}/IterTools.cs (100%) rename Src/{IronPython.Modules => Modules}/ModuleOps.cs (100%) rename Src/{IronPython.Modules => Modules}/NtSignalState.cs (100%) rename Src/{IronPython.Modules => Modules}/Properties/AssemblyInfo.cs (100%) rename Src/{IronPython.Modules => Modules}/ResourceMetaPathImporter.cs (100%) rename Src/{IronPython.Modules => Modules}/SimpleSignalState.cs (100%) rename Src/{IronPython.Modules => Modules}/_bisect.cs (100%) rename Src/{IronPython.Modules => Modules}/_codecs.cs (100%) rename Src/{IronPython.Modules => Modules}/_codecs_cn.cs (100%) rename Src/{IronPython.Modules => Modules}/_collections.cs (100%) rename Src/{IronPython.Modules => Modules}/_csv.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/Array.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/ArrayType.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/CData.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/CFuncPtr.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/CFuncPtrType.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/Extensions.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/Field.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/INativeType.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/LocalOrArg.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/MarshalCleanup.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/MemoryHolder.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/NativeArgument.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/NativeFunctions.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/Pointer.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/PointerType.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/SimpleCData.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/SimpleType.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/SimpleTypeKind.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/StructType.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/Structure.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/Union.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/UnionType.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes/_ctypes.cs (100%) rename Src/{IronPython.Modules => Modules}/_ctypes_test.cs (100%) rename Src/{IronPython.Modules => Modules}/_datetime.cs (100%) rename Src/{IronPython.Modules => Modules}/_functools.cs (100%) rename Src/{IronPython.Modules => Modules}/_heapq.cs (100%) rename Src/{IronPython.Modules => Modules}/_multibytecodec.cs (100%) rename Src/{IronPython.Modules => Modules}/_multiprocessing.cs (100%) rename Src/{IronPython.Modules => Modules}/_opcode.cs (100%) rename Src/{IronPython.Modules => Modules}/_operator.cs (100%) rename Src/{IronPython.Modules => Modules}/_overlapped.cs (100%) rename Src/{IronPython.Modules => Modules}/_pickle.cs (100%) rename Src/{IronPython.Modules => Modules}/_posixsubprocess.cs (100%) rename Src/{IronPython.Modules => Modules}/_random.RandomGen.cs (100%) rename Src/{IronPython.Modules => Modules}/_random.cs (100%) rename Src/{IronPython.Modules => Modules}/_socket.cs (100%) rename Src/{IronPython.Modules => Modules}/_sre.cs (100%) rename Src/{IronPython.Modules => Modules}/_ssl.cs (100%) rename Src/{IronPython.Modules => Modules}/_string.cs (100%) rename Src/{IronPython.Modules => Modules}/_struct.cs (100%) rename Src/{IronPython.Modules => Modules}/_sysconfigdata.cs (100%) rename Src/{IronPython.Modules => Modules}/_thread.cs (100%) rename Src/{IronPython.Modules => Modules}/_warnings.cs (100%) rename Src/{IronPython.Modules => Modules}/_weakref.Generated.cs (100%) rename Src/{IronPython.Modules => Modules}/_weakref.cs (100%) rename Src/{IronPython.Modules => Modules}/_winapi.cs (100%) rename Src/{IronPython.Modules => Modules}/array.cs (100%) rename Src/{IronPython.Modules => Modules}/atexit.cs (100%) rename Src/{IronPython.Modules => Modules}/audioop.cs (100%) rename Src/{IronPython.Modules => Modules}/binascii.cs (100%) rename Src/{IronPython.Modules => Modules}/bz2/BZ2Compressor.cs (100%) rename Src/{IronPython.Modules => Modules}/bz2/BZ2Decompressor.cs (100%) rename Src/{IronPython.Modules => Modules}/bz2/BZ2Module.cs (100%) rename Src/{IronPython.Modules => Modules}/bz2/dotnetzip/BZip2/BZip2Compressor.cs (100%) rename Src/{IronPython.Modules => Modules}/bz2/dotnetzip/BZip2/BZip2InputStream.cs (100%) rename Src/{IronPython.Modules => Modules}/bz2/dotnetzip/BZip2/BZip2OutputStream.cs (100%) rename Src/{IronPython.Modules => Modules}/bz2/dotnetzip/BZip2/BitWriter.cs (100%) rename Src/{IronPython.Modules => Modules}/bz2/dotnetzip/BZip2/CRC32.cs (100%) rename Src/{IronPython.Modules => Modules}/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs (100%) rename Src/{IronPython.Modules => Modules}/bz2/dotnetzip/BZip2/Rand.cs (100%) rename Src/{IronPython.Modules => Modules}/bz2/dotnetzip/source.txt (100%) rename Src/{IronPython.Modules => Modules}/cmath.cs (100%) rename Src/{IronPython.Modules => Modules}/errno.cs (100%) rename Src/{IronPython.Modules => Modules}/faulthandler.cs (100%) rename Src/{IronPython.Modules => Modules}/fcntl.cs (100%) rename Src/{IronPython.Modules => Modules}/gc.cs (100%) rename Src/{IronPython.Modules => Modules}/grp.cs (100%) rename Src/{IronPython.Modules => Modules}/hashlib/MD5CryptoServiceProvider.cs (100%) rename Src/{IronPython.Modules => Modules}/hashlib/SHA1CryptoServiceProvider.cs (100%) rename Src/{IronPython.Modules => Modules}/hashlib/SHA224.cs (100%) rename Src/{IronPython.Modules => Modules}/hashlib/SHA224Managed.cs (100%) rename Src/{IronPython.Modules => Modules}/hashlib/SHA256Managed.cs (100%) rename Src/{IronPython.Modules => Modules}/hashlib/SHA384Managed.cs (100%) rename Src/{IronPython.Modules => Modules}/hashlib/SHA512Managed.cs (100%) rename Src/{IronPython.Modules => Modules}/hashlib/SHAConstants.cs (100%) rename Src/{IronPython.Modules => Modules}/hashlib/_hashlib.cs (100%) rename Src/{IronPython.Modules => Modules}/hashlib/_md5.cs (100%) rename Src/{IronPython.Modules => Modules}/hashlib/_sha1.cs (100%) rename Src/{IronPython.Modules => Modules}/hashlib/_sha256.cs (100%) rename Src/{IronPython.Modules => Modules}/hashlib/_sha512.cs (100%) rename Src/{IronPython.Modules => Modules}/marshal.cs (100%) rename Src/{IronPython.Modules => Modules}/math.Generated.cs (100%) rename Src/{IronPython.Modules => Modules}/math.cs (100%) rename Src/{IronPython.Modules => Modules}/mmap.cs (100%) rename Src/{IronPython.Modules => Modules}/msvcrt.cs (100%) rename Src/{IronPython.Modules => Modules}/nt.cs (100%) rename Src/{IronPython.Modules => Modules}/policy.IronPython.Modules.config (100%) rename Src/{IronPython.Modules => Modules}/pwd.cs (100%) rename Src/{IronPython.Modules => Modules}/pyexpat.cs (100%) rename Src/{IronPython.Modules => Modules}/re.cs (100%) rename Src/{IronPython.Modules => Modules}/resource.cs (100%) rename Src/{IronPython.Modules => Modules}/select.cs (100%) rename Src/{IronPython.Modules => Modules}/signal.cs (100%) rename Src/{IronPython.Modules => Modules}/spwd.cs (100%) rename Src/{IronPython.Modules => Modules}/time.cs (100%) rename Src/{IronPython.Modules => Modules}/winreg.cs (100%) rename Src/{IronPython.Modules => Modules}/winsound.cs (100%) rename Src/{IronPython.Modules => Modules}/xxsubtype.cs (100%) rename Src/{IronPython.Modules => Modules}/zipimport.cs (100%) rename Src/{IronPython.Modules => Modules}/zlib/Compress.cs (100%) rename Src/{IronPython.Modules => Modules}/zlib/Decompress.cs (100%) rename Src/{IronPython.Modules => Modules}/zlib/ZlibModule.cs (100%) rename Src/{IronPython.Modules => Modules}/zlib/zlib.net/Adler32.cs (100%) rename Src/{IronPython.Modules => Modules}/zlib/zlib.net/Deflate.cs (100%) rename Src/{IronPython.Modules => Modules}/zlib/zlib.net/InfBlocks.cs (100%) rename Src/{IronPython.Modules => Modules}/zlib/zlib.net/InfCodes.cs (100%) rename Src/{IronPython.Modules => Modules}/zlib/zlib.net/InfTree.cs (100%) rename Src/{IronPython.Modules => Modules}/zlib/zlib.net/Inflate.cs (100%) rename Src/{IronPython.Modules => Modules}/zlib/zlib.net/StaticTree.cs (100%) rename Src/{IronPython.Modules => Modules}/zlib/zlib.net/Tree.cs (100%) rename Src/{IronPython.Modules => Modules}/zlib/zlib.net/ZStream.cs (100%) rename Src/{IronPython.Modules => Modules}/zlib/zlib.net/ZStreamException.cs (100%) rename Src/{IronPython.Modules => Modules}/zlib/zlib.net/Zlib.cs (100%) rename Src/{IronPython.Modules => Modules}/zlib/zlib.net/history.txt (100%) rename Src/{IronPython.Modules => Modules}/zlib/zlib.net/license.txt (100%) rename Src/{IronPython.Modules => Modules}/zlib/zlib.net/readme.txt (100%) rename Src/{IronPython.SQLite => SQLite}/Connection.cs (100%) rename Src/{IronPython.SQLite => SQLite}/Contants.cs (100%) rename Src/{IronPython.SQLite => SQLite}/Cursor.cs (100%) rename Src/{IronPython.SQLite => SQLite}/Exceptions.cs (100%) rename Src/{IronPython.SQLite => SQLite}/Extensions.cs (100%) rename Src/{IronPython.SQLite => SQLite}/IronPython.SQLite.csproj (100%) rename Src/{IronPython.SQLite => SQLite}/Properties/AssemblyInfo.cs (100%) rename Src/{IronPython.SQLite => SQLite}/Row.cs (100%) rename Src/{IronPython.SQLite => SQLite}/Statement.cs (100%) rename Src/{IronPython.SQLite => SQLite}/Util.cs (100%) rename Src/{IronPython.SQLite => SQLite}/_sqlite.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/.editorconfig (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/BtreeInt_h.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/Btree_h.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/Delegates.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/Hash_h.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/VdbeInt_h.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/Vdbe_h.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/_Custom.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/alter_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/analyze_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/attach_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/auth_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/backup_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/bitvec_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/btmutex_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/btree_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/build_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/callback_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/complete_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/crypto.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/ctime_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/date_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/delete_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/expr_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/fault_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/fkey_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/func_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/global_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/hash_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/hwtime_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/insert_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/journal_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/keywordhash_h.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/legacy_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/loadext_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/main_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/malloc_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/mem_Pool.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/memjournal_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/mutex_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/mutex_h.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/mutex_noop_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/mutex_w32.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/notify_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/opcodes_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/opcodes_h.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/os_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/os_common_h.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/os_h.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/os_win_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/pager_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/pager_h.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/parse_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/parse_h.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/pcache1_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/pcache_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/pcache_h.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/pragma_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/prepare_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/printf_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/random_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/resolve_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/rowset_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/select_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/sqlite3_h.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/sqliteInt_h.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/sqliteLimit_h.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/status_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/table_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/tokenize_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/trigger_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/update_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/utf_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/util_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/vacuum_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/vdbe_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/vdbeapi_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/vdbeaux_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/vdbeblob_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/vdbemem_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/vdbetrace_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/vtab_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/wal_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/wal_h.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/walker_c.cs (100%) rename Src/{IronPython.SQLite => SQLite}/c#sqlite/where_c.cs (100%) rename Src/{IronPythonTest => Tests}/AssemblyInfo.cs (100%) rename Src/{IronPythonTest => Tests}/AttrInjectorTest.cs (100%) rename Src/{IronPythonTest => Tests}/BindTest.cs (100%) rename Src/{IronPythonTest => Tests}/BinderTest.cs (100%) rename Src/{IronPythonTest => Tests}/Cases/CPythonCases.cs (100%) rename Src/{IronPythonTest => Tests}/Cases/CPythonCasesManifest.ini (100%) rename Src/{IronPythonTest => Tests}/Cases/CaseExecuter.cs (100%) rename Src/{IronPythonTest => Tests}/Cases/CaseGenerator.cs (100%) rename Src/{IronPythonTest => Tests}/Cases/CommonCases.cs (100%) rename Src/{IronPythonTest => Tests}/Cases/IronPythonCases.cs (100%) rename Src/{IronPythonTest => Tests}/Cases/IronPythonCasesManifest.ini (100%) rename Src/{IronPythonTest => Tests}/ClrType.cs (100%) rename Src/{IronPythonTest => Tests}/Cmplx.cs (100%) rename Src/{IronPythonTest => Tests}/Conversions.cs (100%) rename Src/{IronPythonTest => Tests}/DeTest.cs (100%) rename Src/{IronPythonTest => Tests}/DelegateTest.cs (100%) rename Src/{IronPythonTest => Tests}/DynamicRegressions.cs (100%) rename Src/{IronPythonTest => Tests}/EncodingTest.cs (100%) rename Src/{IronPythonTest => Tests}/EngineTest.cs (100%) rename Src/{IronPythonTest => Tests}/Enums.cs (100%) rename Src/{IronPythonTest => Tests}/Events.cs (100%) rename Src/{IronPythonTest => Tests}/ExceptionConverter.cs (100%) rename Src/{IronPythonTest => Tests}/Exceptions.cs (100%) rename Src/{IronPythonTest => Tests}/Explicit.cs (100%) rename Src/{IronPythonTest => Tests}/ExtensionMethodTest.cs (100%) rename Src/{IronPythonTest => Tests}/GenMeth.cs (100%) rename Src/{IronPythonTest => Tests}/Indexable.cs (100%) rename Src/{IronPythonTest => Tests}/InheritTest.cs (100%) rename Src/{IronPythonTest => Tests}/IntegerTest.cs (100%) rename Src/{IronPythonTest => Tests}/IronMath.cs (100%) rename Src/{IronPythonTest => Tests}/IronPython.Tests.csproj (100%) rename Src/{IronPythonTest => Tests}/LoadTest.cs (100%) rename Src/{IronPythonTest => Tests}/MemberMappingTests.cs (100%) rename Src/{IronPythonTest => Tests}/MemberOverloadTest.cs (100%) rename Src/{IronPythonTest => Tests}/MethodParametersStubs.cs (100%) rename Src/{IronPythonTest => Tests}/NestedClass.cs (100%) rename Src/{IronPythonTest => Tests}/NullableTest.cs (100%) rename Src/{IronPythonTest => Tests}/OperatorTest.cs (100%) rename Src/{IronPythonTest => Tests}/ProtocolTest.cs (100%) rename Src/{IronPythonTest => Tests}/StaticTest.cs (100%) rename Src/{IronPythonTest => Tests}/Stress/Engine.cs (100%) rename Src/{IronPythonTest => Tests}/StringDictionaryStorage.cs (100%) rename Src/{IronPythonTest => Tests}/TestBuiltinModule.cs (100%) rename Src/{IronPythonTest => Tests}/TypeDescriptor.cs (100%) rename Src/{IronPythonTest => Tests}/Util/IniParser.cs (100%) rename Src/{IronPythonTest => Tests}/Util/TestManifest.cs (100%) rename Src/{IronPython.Wpf => Wpf}/DynamicXamlReader.cs (100%) rename Src/{IronPython.Wpf => Wpf}/IronPython.Wpf.csproj (100%) rename Src/{IronPython.Wpf => Wpf}/Properties/AssemblyInfo.cs (100%) rename Src/{IronPython.Wpf => Wpf}/_wpf.cs (100%) rename {Util => Utils}/NuGet/nuget.exe (100%) rename {Util => Utils}/References/IKVM/IKVM.Reflection.License.txt (100%) rename {Util => Utils}/References/IKVM/IKVM.Reflection.dll (100%) rename {Util => Utils}/References/Mono.Posix.dll (100%) diff --git a/IronPython.sln b/IronPython.sln index fb40cd0a7..9d9ace479 100644 --- a/IronPython.sln +++ b/IronPython.sln @@ -5,15 +5,15 @@ VisualStudioVersion = 17.9.34714.143 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython", "Src\IronPython\IronPython.csproj", "{95289EA9-5778-489D-AB48-F81F2CE2DA32}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Modules", "Src\IronPython.Modules\IronPython.Modules.csproj", "{155CE436-1669-4A48-8095-410F2430237F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Modules", "Src\Modules\IronPython.Modules.csproj", "{155CE436-1669-4A48-8095-410F2430237F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Wpf", "Src\IronPython.Wpf\IronPython.Wpf.csproj", "{65E997B7-E99B-4C83-B29E-9951429BB293}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Wpf", "Src\Wpf\IronPython.Wpf.csproj", "{65E997B7-E99B-4C83-B29E-9951429BB293}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console", "Src\IronPythonConsole\IronPython.Console.csproj", "{811AC32C-11F3-4ED8-92A7-A7E39C2BB704}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console", "Src\Console\IronPython.Console.csproj", "{811AC32C-11F3-4ED8-92A7-A7E39C2BB704}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Tests", "Src\IronPythonTest\IronPython.Tests.csproj", "{B6B42537-07F8-4F6C-A99A-B155CAEB124E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Tests", "Src\Tests\IronPython.Tests.csproj", "{B6B42537-07F8-4F6C-A99A-B155CAEB124E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console.Host", "Src\IronPythonWindow\IronPython.Console.Host.csproj", "{81DA19C7-4FEC-47E7-981B-D9310D549F95}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console.Host", "Src\Console.Host\IronPython.Console.Host.csproj", "{81DA19C7-4FEC-47E7-981B-D9310D549F95}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3A14D070-628F-44EF-92DD-47C8BE5C33CD}" ProjectSection(SolutionItems) = preProject @@ -29,8 +29,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.SQLite", "Src\IronPython.SQLite\IronPython.SQLite.csproj", "{4A617A40-2BA7-4713-AAFE-F90C4325C581}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{17737ACB-40C6-41A6-83DA-3203A4DCEC19}" ProjectSection(SolutionItems) = preProject Build\After.targets = Build\After.targets @@ -47,7 +45,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{17737ACB Build\Tasks.Targets = Build\Tasks.Targets EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.CompilerServices", "Src\IronPythonCompiler\IronPython.CompilerServices.csproj", "{3DFB096E-AC09-4E7A-9288-7F7C33C288C7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.CompilerServices", "Src\CompilerServices\IronPython.CompilerServices.csproj", "{3DFB096E-AC09-4E7A-9288-7F7C33C288C7}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DLR", "DLR", "{AC38EFB1-820D-4E90-BF40-BEF3AC825542}" EndProject @@ -69,7 +67,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nuget", "nuget", "{EE77D917 Package\nuget\IronPython.StdLib.nuspec = Package\nuget\IronPython.StdLib.nuspec EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32", "Src\IronPythonConsole32\IronPython.Console32.csproj", "{AD21022F-E7C1-4B74-97C1-0A0E48EFF992}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32", "Src\Console32\IronPython.Console32.csproj", "{AD21022F-E7C1-4B74-97C1-0A0E48EFF992}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "choco", "choco", "{EA550FD8-2241-4131-8292-619D009E0199}" ProjectSection(SolutionItems) = preProject @@ -102,10 +100,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "msi", "msi", "{450F93D5-DF0 Package\msi\Version.wxi = Package\msi\Version.wxi EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32.Host", "Src\IronPythonWindow32\IronPython.Console32.Host.csproj", "{8F177DC2-9822-45BD-AB05-1F40FCA86168}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32.Host", "Src\Console32.Host\IronPython.Console32.Host.csproj", "{8F177DC2-9822-45BD-AB05-1F40FCA86168}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronPython.DiagnosticAnalyzer", "DiagnosticAnalyzer\IronPython.DiagnosticAnalyzer.csproj", "{2DFE89D7-0C39-44E9-94CD-496CC985DFC3}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronPython.SQLite", "Src\SQLite\IronPython.SQLite.csproj", "{2F1071BF-891C-42A3-8A82-6B8A168BDE64}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -136,10 +136,6 @@ Global {81DA19C7-4FEC-47E7-981B-D9310D549F95}.Debug|Any CPU.Build.0 = Debug|Any CPU {81DA19C7-4FEC-47E7-981B-D9310D549F95}.Release|Any CPU.ActiveCfg = Release|Any CPU {81DA19C7-4FEC-47E7-981B-D9310D549F95}.Release|Any CPU.Build.0 = Release|Any CPU - {4A617A40-2BA7-4713-AAFE-F90C4325C581}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4A617A40-2BA7-4713-AAFE-F90C4325C581}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4A617A40-2BA7-4713-AAFE-F90C4325C581}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4A617A40-2BA7-4713-AAFE-F90C4325C581}.Release|Any CPU.Build.0 = Release|Any CPU {3DFB096E-AC09-4E7A-9288-7F7C33C288C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3DFB096E-AC09-4E7A-9288-7F7C33C288C7}.Debug|Any CPU.Build.0 = Debug|Any CPU {3DFB096E-AC09-4E7A-9288-7F7C33C288C7}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -172,6 +168,10 @@ Global {2DFE89D7-0C39-44E9-94CD-496CC985DFC3}.Debug|Any CPU.Build.0 = Debug|Any CPU {2DFE89D7-0C39-44E9-94CD-496CC985DFC3}.Release|Any CPU.ActiveCfg = Release|Any CPU {2DFE89D7-0C39-44E9-94CD-496CC985DFC3}.Release|Any CPU.Build.0 = Release|Any CPU + {2F1071BF-891C-42A3-8A82-6B8A168BDE64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F1071BF-891C-42A3-8A82-6B8A168BDE64}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F1071BF-891C-42A3-8A82-6B8A168BDE64}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F1071BF-891C-42A3-8A82-6B8A168BDE64}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/NuGet.config b/NuGet.config index b486c587e..0785af9ef 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,10 +1,6 @@ - - - - - + diff --git a/Tests/IndicesTest.py b/PythonTests/IndicesTest.py similarity index 100% rename from Tests/IndicesTest.py rename to PythonTests/IndicesTest.py diff --git a/Tests/Inputs/RemoteConsole.py b/PythonTests/Inputs/RemoteConsole.py similarity index 100% rename from Tests/Inputs/RemoteConsole.py rename to PythonTests/Inputs/RemoteConsole.py diff --git a/Tests/Inputs/UseCLI.py b/PythonTests/Inputs/UseCLI.py similarity index 100% rename from Tests/Inputs/UseCLI.py rename to PythonTests/Inputs/UseCLI.py diff --git a/Tests/Inputs/exit.py b/PythonTests/Inputs/exit.py similarity index 100% rename from Tests/Inputs/exit.py rename to PythonTests/Inputs/exit.py diff --git a/Tests/Inputs/exitFuncRaises.py b/PythonTests/Inputs/exitFuncRaises.py similarity index 100% rename from Tests/Inputs/exitFuncRaises.py rename to PythonTests/Inputs/exitFuncRaises.py diff --git a/Tests/Inputs/exitFuncRuns.py b/PythonTests/Inputs/exitFuncRuns.py similarity index 100% rename from Tests/Inputs/exitFuncRuns.py rename to PythonTests/Inputs/exitFuncRuns.py diff --git a/Tests/Inputs/raise.py b/PythonTests/Inputs/raise.py similarity index 100% rename from Tests/Inputs/raise.py rename to PythonTests/Inputs/raise.py diff --git a/Tests/Inputs/simpleCommand.py b/PythonTests/Inputs/simpleCommand.py similarity index 100% rename from Tests/Inputs/simpleCommand.py rename to PythonTests/Inputs/simpleCommand.py diff --git a/Tests/Inputs/syntaxError.py b/PythonTests/Inputs/syntaxError.py similarity index 100% rename from Tests/Inputs/syntaxError.py rename to PythonTests/Inputs/syntaxError.py diff --git a/Tests/Inputs/uninitializedGlobal.py b/PythonTests/Inputs/uninitializedGlobal.py similarity index 100% rename from Tests/Inputs/uninitializedGlobal.py rename to PythonTests/Inputs/uninitializedGlobal.py diff --git a/Tests/Modes/ConsoleFlags.ps1 b/PythonTests/Modes/ConsoleFlags.ps1 similarity index 100% rename from Tests/Modes/ConsoleFlags.ps1 rename to PythonTests/Modes/ConsoleFlags.ps1 diff --git a/Tests/Modes/ConsoleHelp.Debug.out b/PythonTests/Modes/ConsoleHelp.Debug.out similarity index 100% rename from Tests/Modes/ConsoleHelp.Debug.out rename to PythonTests/Modes/ConsoleHelp.Debug.out diff --git a/Tests/Modes/ConsoleHelp.Release.out b/PythonTests/Modes/ConsoleHelp.Release.out similarity index 100% rename from Tests/Modes/ConsoleHelp.Release.out rename to PythonTests/Modes/ConsoleHelp.Release.out diff --git a/Tests/RunAgainstCpy.py b/PythonTests/RunAgainstCpy.py similarity index 100% rename from Tests/RunAgainstCpy.py rename to PythonTests/RunAgainstCpy.py diff --git a/Tests/Tools/baselines/__builtin__.log b/PythonTests/Tools/baselines/__builtin__.log similarity index 100% rename from Tests/Tools/baselines/__builtin__.log rename to PythonTests/Tools/baselines/__builtin__.log diff --git a/Tests/Tools/baselines/_codecs.log b/PythonTests/Tools/baselines/_codecs.log similarity index 100% rename from Tests/Tools/baselines/_codecs.log rename to PythonTests/Tools/baselines/_codecs.log diff --git a/Tests/Tools/baselines/_collections.log b/PythonTests/Tools/baselines/_collections.log similarity index 100% rename from Tests/Tools/baselines/_collections.log rename to PythonTests/Tools/baselines/_collections.log diff --git a/Tests/Tools/baselines/_sre.log b/PythonTests/Tools/baselines/_sre.log similarity index 100% rename from Tests/Tools/baselines/_sre.log rename to PythonTests/Tools/baselines/_sre.log diff --git a/Tests/Tools/baselines/_struct.log b/PythonTests/Tools/baselines/_struct.log similarity index 100% rename from Tests/Tools/baselines/_struct.log rename to PythonTests/Tools/baselines/_struct.log diff --git a/Tests/Tools/baselines/_subprocess.log b/PythonTests/Tools/baselines/_subprocess.log similarity index 100% rename from Tests/Tools/baselines/_subprocess.log rename to PythonTests/Tools/baselines/_subprocess.log diff --git a/Tests/Tools/baselines/_weakref.log b/PythonTests/Tools/baselines/_weakref.log similarity index 100% rename from Tests/Tools/baselines/_weakref.log rename to PythonTests/Tools/baselines/_weakref.log diff --git a/Tests/Tools/baselines/_winreg.log b/PythonTests/Tools/baselines/_winreg.log similarity index 100% rename from Tests/Tools/baselines/_winreg.log rename to PythonTests/Tools/baselines/_winreg.log diff --git a/Tests/Tools/baselines/array.log b/PythonTests/Tools/baselines/array.log similarity index 100% rename from Tests/Tools/baselines/array.log rename to PythonTests/Tools/baselines/array.log diff --git a/Tests/Tools/baselines/cPickle.log b/PythonTests/Tools/baselines/cPickle.log similarity index 100% rename from Tests/Tools/baselines/cPickle.log rename to PythonTests/Tools/baselines/cPickle.log diff --git a/Tests/Tools/baselines/cStringIO.log b/PythonTests/Tools/baselines/cStringIO.log similarity index 100% rename from Tests/Tools/baselines/cStringIO.log rename to PythonTests/Tools/baselines/cStringIO.log diff --git a/Tests/Tools/baselines/copy_reg.log b/PythonTests/Tools/baselines/copy_reg.log similarity index 100% rename from Tests/Tools/baselines/copy_reg.log rename to PythonTests/Tools/baselines/copy_reg.log diff --git a/Tests/Tools/baselines/datetime.log b/PythonTests/Tools/baselines/datetime.log similarity index 100% rename from Tests/Tools/baselines/datetime.log rename to PythonTests/Tools/baselines/datetime.log diff --git a/Tests/Tools/baselines/gc.log b/PythonTests/Tools/baselines/gc.log similarity index 100% rename from Tests/Tools/baselines/gc.log rename to PythonTests/Tools/baselines/gc.log diff --git a/Tests/Tools/baselines/itertools.log b/PythonTests/Tools/baselines/itertools.log similarity index 100% rename from Tests/Tools/baselines/itertools.log rename to PythonTests/Tools/baselines/itertools.log diff --git a/Tests/Tools/baselines/math.log b/PythonTests/Tools/baselines/math.log similarity index 100% rename from Tests/Tools/baselines/math.log rename to PythonTests/Tools/baselines/math.log diff --git a/Tests/Tools/baselines/mmap.log b/PythonTests/Tools/baselines/mmap.log similarity index 100% rename from Tests/Tools/baselines/mmap.log rename to PythonTests/Tools/baselines/mmap.log diff --git a/Tests/Tools/baselines/msvcrt.log b/PythonTests/Tools/baselines/msvcrt.log similarity index 100% rename from Tests/Tools/baselines/msvcrt.log rename to PythonTests/Tools/baselines/msvcrt.log diff --git a/Tests/Tools/baselines/nt.log b/PythonTests/Tools/baselines/nt.log similarity index 100% rename from Tests/Tools/baselines/nt.log rename to PythonTests/Tools/baselines/nt.log diff --git a/Tests/Tools/baselines/select.log b/PythonTests/Tools/baselines/select.log similarity index 100% rename from Tests/Tools/baselines/select.log rename to PythonTests/Tools/baselines/select.log diff --git a/Tests/Tools/baselines/signal.log b/PythonTests/Tools/baselines/signal.log similarity index 100% rename from Tests/Tools/baselines/signal.log rename to PythonTests/Tools/baselines/signal.log diff --git a/Tests/Tools/baselines/sys.log b/PythonTests/Tools/baselines/sys.log similarity index 100% rename from Tests/Tools/baselines/sys.log rename to PythonTests/Tools/baselines/sys.log diff --git a/Tests/Tools/baselines/thread.log b/PythonTests/Tools/baselines/thread.log similarity index 100% rename from Tests/Tools/baselines/thread.log rename to PythonTests/Tools/baselines/thread.log diff --git a/Tests/Tools/baselines/time.log b/PythonTests/Tools/baselines/time.log similarity index 100% rename from Tests/Tools/baselines/time.log rename to PythonTests/Tools/baselines/time.log diff --git a/Tests/Tools/baselines/types_only.log b/PythonTests/Tools/baselines/types_only.log similarity index 100% rename from Tests/Tools/baselines/types_only.log rename to PythonTests/Tools/baselines/types_only.log diff --git a/Tests/Tools/baselines/xxsubtype.log b/PythonTests/Tools/baselines/xxsubtype.log similarity index 100% rename from Tests/Tools/baselines/xxsubtype.log rename to PythonTests/Tools/baselines/xxsubtype.log diff --git a/Tests/Tools/check/_functools.log b/PythonTests/Tools/check/_functools.log similarity index 100% rename from Tests/Tools/check/_functools.log rename to PythonTests/Tools/check/_functools.log diff --git a/Tests/Tools/cleantests.py b/PythonTests/Tools/cleantests.py similarity index 100% rename from Tests/Tools/cleantests.py rename to PythonTests/Tools/cleantests.py diff --git a/Tests/Tools/clr_helpers.py b/PythonTests/Tools/clr_helpers.py similarity index 100% rename from Tests/Tools/clr_helpers.py rename to PythonTests/Tools/clr_helpers.py diff --git a/Tests/Tools/cmodule.py b/PythonTests/Tools/cmodule.py similarity index 100% rename from Tests/Tools/cmodule.py rename to PythonTests/Tools/cmodule.py diff --git a/Tests/Tools/cpy_tests.py b/PythonTests/Tools/cpy_tests.py similarity index 100% rename from Tests/Tools/cpy_tests.py rename to PythonTests/Tools/cpy_tests.py diff --git a/Tests/Tools/logmodule.py b/PythonTests/Tools/logmodule.py similarity index 100% rename from Tests/Tools/logmodule.py rename to PythonTests/Tools/logmodule.py diff --git a/Tests/Tools/modulediff.py b/PythonTests/Tools/modulediff.py similarity index 100% rename from Tests/Tools/modulediff.py rename to PythonTests/Tools/modulediff.py diff --git a/Tests/Tools/stdmodules.py b/PythonTests/Tools/stdmodules.py similarity index 100% rename from Tests/Tools/stdmodules.py rename to PythonTests/Tools/stdmodules.py diff --git a/Tests/_ctypes_test_linux32.pyd b/PythonTests/_ctypes_test_linux32.pyd similarity index 100% rename from Tests/_ctypes_test_linux32.pyd rename to PythonTests/_ctypes_test_linux32.pyd diff --git a/Tests/_ctypes_test_linux64.pyd b/PythonTests/_ctypes_test_linux64.pyd similarity index 100% rename from Tests/_ctypes_test_linux64.pyd rename to PythonTests/_ctypes_test_linux64.pyd diff --git a/Tests/_ctypes_test_win32.pyd b/PythonTests/_ctypes_test_win32.pyd similarity index 100% rename from Tests/_ctypes_test_win32.pyd rename to PythonTests/_ctypes_test_win32.pyd diff --git a/Tests/_ctypes_test_win64.pyd b/PythonTests/_ctypes_test_win64.pyd similarity index 100% rename from Tests/_ctypes_test_win64.pyd rename to PythonTests/_ctypes_test_win64.pyd diff --git a/Tests/badil.py b/PythonTests/badil.py similarity index 100% rename from Tests/badil.py rename to PythonTests/badil.py diff --git a/Tests/c1.cs b/PythonTests/c1.cs similarity index 100% rename from Tests/c1.cs rename to PythonTests/c1.cs diff --git a/Tests/c2.cs b/PythonTests/c2.cs similarity index 100% rename from Tests/c2.cs rename to PythonTests/c2.cs diff --git a/Tests/c3.cs b/PythonTests/c3.cs similarity index 100% rename from Tests/c3.cs rename to PythonTests/c3.cs diff --git a/Tests/c4.cs b/PythonTests/c4.cs similarity index 100% rename from Tests/c4.cs rename to PythonTests/c4.cs diff --git a/Tests/check_result.bat b/PythonTests/check_result.bat similarity index 100% rename from Tests/check_result.bat rename to PythonTests/check_result.bat diff --git a/Tests/compat/common.py b/PythonTests/compat/common.py similarity index 100% rename from Tests/compat/common.py rename to PythonTests/compat/common.py diff --git a/Tests/compat/rulediff.py b/PythonTests/compat/rulediff.py similarity index 100% rename from Tests/compat/rulediff.py rename to PythonTests/compat/rulediff.py diff --git a/Tests/compat/runsbs.py b/PythonTests/compat/runsbs.py similarity index 100% rename from Tests/compat/runsbs.py rename to PythonTests/compat/runsbs.py diff --git a/Tests/compat/sbs_builtin.py b/PythonTests/compat/sbs_builtin.py similarity index 100% rename from Tests/compat/sbs_builtin.py rename to PythonTests/compat/sbs_builtin.py diff --git a/Tests/compat/sbs_class_compare.py b/PythonTests/compat/sbs_class_compare.py similarity index 100% rename from Tests/compat/sbs_class_compare.py rename to PythonTests/compat/sbs_class_compare.py diff --git a/Tests/compat/sbs_exceptions/__init__.py b/PythonTests/compat/sbs_exceptions/__init__.py similarity index 100% rename from Tests/compat/sbs_exceptions/__init__.py rename to PythonTests/compat/sbs_exceptions/__init__.py diff --git a/Tests/compat/sbs_exceptions/define.py b/PythonTests/compat/sbs_exceptions/define.py similarity index 100% rename from Tests/compat/sbs_exceptions/define.py rename to PythonTests/compat/sbs_exceptions/define.py diff --git a/Tests/compat/sbs_exceptions/for_loop.py b/PythonTests/compat/sbs_exceptions/for_loop.py similarity index 100% rename from Tests/compat/sbs_exceptions/for_loop.py rename to PythonTests/compat/sbs_exceptions/for_loop.py diff --git a/Tests/compat/sbs_exceptions/if_false.py b/PythonTests/compat/sbs_exceptions/if_false.py similarity index 100% rename from Tests/compat/sbs_exceptions/if_false.py rename to PythonTests/compat/sbs_exceptions/if_false.py diff --git a/Tests/compat/sbs_exceptions/if_true.py b/PythonTests/compat/sbs_exceptions/if_true.py similarity index 100% rename from Tests/compat/sbs_exceptions/if_true.py rename to PythonTests/compat/sbs_exceptions/if_true.py diff --git a/Tests/compat/sbs_exceptions/shared.py b/PythonTests/compat/sbs_exceptions/shared.py similarity index 100% rename from Tests/compat/sbs_exceptions/shared.py rename to PythonTests/compat/sbs_exceptions/shared.py diff --git a/Tests/compat/sbs_exceptions/try_else.py b/PythonTests/compat/sbs_exceptions/try_else.py similarity index 100% rename from Tests/compat/sbs_exceptions/try_else.py rename to PythonTests/compat/sbs_exceptions/try_else.py diff --git a/Tests/compat/sbs_exceptions/try_except1.py b/PythonTests/compat/sbs_exceptions/try_except1.py similarity index 100% rename from Tests/compat/sbs_exceptions/try_except1.py rename to PythonTests/compat/sbs_exceptions/try_except1.py diff --git a/Tests/compat/sbs_exceptions/try_except2.py b/PythonTests/compat/sbs_exceptions/try_except2.py similarity index 100% rename from Tests/compat/sbs_exceptions/try_except2.py rename to PythonTests/compat/sbs_exceptions/try_except2.py diff --git a/Tests/compat/sbs_exceptions/try_except3.py b/PythonTests/compat/sbs_exceptions/try_except3.py similarity index 100% rename from Tests/compat/sbs_exceptions/try_except3.py rename to PythonTests/compat/sbs_exceptions/try_except3.py diff --git a/Tests/compat/sbs_exceptions/try_finally1.py b/PythonTests/compat/sbs_exceptions/try_finally1.py similarity index 100% rename from Tests/compat/sbs_exceptions/try_finally1.py rename to PythonTests/compat/sbs_exceptions/try_finally1.py diff --git a/Tests/compat/sbs_exceptions/try_finally2.py b/PythonTests/compat/sbs_exceptions/try_finally2.py similarity index 100% rename from Tests/compat/sbs_exceptions/try_finally2.py rename to PythonTests/compat/sbs_exceptions/try_finally2.py diff --git a/Tests/compat/sbs_exceptions/try_finally3.py b/PythonTests/compat/sbs_exceptions/try_finally3.py similarity index 100% rename from Tests/compat/sbs_exceptions/try_finally3.py rename to PythonTests/compat/sbs_exceptions/try_finally3.py diff --git a/Tests/compat/sbs_exceptions/while_loop.py b/PythonTests/compat/sbs_exceptions/while_loop.py similarity index 100% rename from Tests/compat/sbs_exceptions/while_loop.py rename to PythonTests/compat/sbs_exceptions/while_loop.py diff --git a/Tests/compat/sbs_func_args.py b/PythonTests/compat/sbs_func_args.py similarity index 100% rename from Tests/compat/sbs_func_args.py rename to PythonTests/compat/sbs_func_args.py diff --git a/Tests/compat/sbs_library.cs b/PythonTests/compat/sbs_library.cs similarity index 100% rename from Tests/compat/sbs_library.cs rename to PythonTests/compat/sbs_library.cs diff --git a/Tests/compat/sbs_newtype.py b/PythonTests/compat/sbs_newtype.py similarity index 100% rename from Tests/compat/sbs_newtype.py rename to PythonTests/compat/sbs_newtype.py diff --git a/Tests/compat/sbs_parse_string.py b/PythonTests/compat/sbs_parse_string.py similarity index 100% rename from Tests/compat/sbs_parse_string.py rename to PythonTests/compat/sbs_parse_string.py diff --git a/Tests/compat/sbs_simple_compare.py b/PythonTests/compat/sbs_simple_compare.py similarity index 100% rename from Tests/compat/sbs_simple_compare.py rename to PythonTests/compat/sbs_simple_compare.py diff --git a/Tests/compat/sbs_simple_ops.py b/PythonTests/compat/sbs_simple_ops.py similarity index 100% rename from Tests/compat/sbs_simple_ops.py rename to PythonTests/compat/sbs_simple_ops.py diff --git a/Tests/compat/sbs_true_division.py b/PythonTests/compat/sbs_true_division.py similarity index 100% rename from Tests/compat/sbs_true_division.py rename to PythonTests/compat/sbs_true_division.py diff --git a/Tests/compat/sbs_typeop.py b/PythonTests/compat/sbs_typeop.py similarity index 100% rename from Tests/compat/sbs_typeop.py rename to PythonTests/compat/sbs_typeop.py diff --git a/Tests/compat/testdata.py b/PythonTests/compat/testdata.py similarity index 100% rename from Tests/compat/testdata.py rename to PythonTests/compat/testdata.py diff --git a/Tests/custombuiltins.py b/PythonTests/custombuiltins.py similarity index 100% rename from Tests/custombuiltins.py rename to PythonTests/custombuiltins.py diff --git a/Tests/debugging/__init__.py b/PythonTests/debugging/__init__.py similarity index 100% rename from Tests/debugging/__init__.py rename to PythonTests/debugging/__init__.py diff --git a/Tests/debugging/mdbg_tool/__init__.py b/PythonTests/debugging/mdbg_tool/__init__.py similarity index 100% rename from Tests/debugging/mdbg_tool/__init__.py rename to PythonTests/debugging/mdbg_tool/__init__.py diff --git a/Tests/debugging/pdb_mod/__init__.py b/PythonTests/debugging/pdb_mod/__init__.py similarity index 100% rename from Tests/debugging/pdb_mod/__init__.py rename to PythonTests/debugging/pdb_mod/__init__.py diff --git a/Tests/debugging/vs/__init__.py b/PythonTests/debugging/vs/__init__.py similarity index 100% rename from Tests/debugging/vs/__init__.py rename to PythonTests/debugging/vs/__init__.py diff --git a/Tests/dllsite.py b/PythonTests/dllsite.py similarity index 100% rename from Tests/dllsite.py rename to PythonTests/dllsite.py diff --git a/Tests/dummy_module.py b/PythonTests/dummy_module.py similarity index 100% rename from Tests/dummy_module.py rename to PythonTests/dummy_module.py diff --git a/Tests/dynamic_sanity/dynamic_runner.bat b/PythonTests/dynamic_sanity/dynamic_runner.bat similarity index 100% rename from Tests/dynamic_sanity/dynamic_runner.bat rename to PythonTests/dynamic_sanity/dynamic_runner.bat diff --git a/Tests/dynamic_sanity/dynamic_sanity.cs b/PythonTests/dynamic_sanity/dynamic_sanity.cs similarity index 100% rename from Tests/dynamic_sanity/dynamic_sanity.cs rename to PythonTests/dynamic_sanity/dynamic_sanity.cs diff --git a/Tests/dynamic_sanity/mock.py b/PythonTests/dynamic_sanity/mock.py similarity index 100% rename from Tests/dynamic_sanity/mock.py rename to PythonTests/dynamic_sanity/mock.py diff --git a/Tests/encoded_files/bad_encoding_name.py b/PythonTests/encoded_files/bad_encoding_name.py similarity index 100% rename from Tests/encoded_files/bad_encoding_name.py rename to PythonTests/encoded_files/bad_encoding_name.py diff --git a/Tests/encoded_files/bad_latin1_bom.py b/PythonTests/encoded_files/bad_latin1_bom.py similarity index 100% rename from Tests/encoded_files/bad_latin1_bom.py rename to PythonTests/encoded_files/bad_latin1_bom.py diff --git a/Tests/encoded_files/bad_latin1_bom_decl.py b/PythonTests/encoded_files/bad_latin1_bom_decl.py similarity index 100% rename from Tests/encoded_files/bad_latin1_bom_decl.py rename to PythonTests/encoded_files/bad_latin1_bom_decl.py diff --git a/Tests/encoded_files/bad_latin1_nbsp.py b/PythonTests/encoded_files/bad_latin1_nbsp.py similarity index 100% rename from Tests/encoded_files/bad_latin1_nbsp.py rename to PythonTests/encoded_files/bad_latin1_nbsp.py diff --git a/Tests/encoded_files/bad_latin1_nodecl.py b/PythonTests/encoded_files/bad_latin1_nodecl.py similarity index 100% rename from Tests/encoded_files/bad_latin1_nodecl.py rename to PythonTests/encoded_files/bad_latin1_nodecl.py diff --git a/Tests/encoded_files/bad_utf8_bom_decl.py b/PythonTests/encoded_files/bad_utf8_bom_decl.py similarity index 100% rename from Tests/encoded_files/bad_utf8_bom_decl.py rename to PythonTests/encoded_files/bad_utf8_bom_decl.py diff --git a/Tests/encoded_files/cp1019.py b/PythonTests/encoded_files/cp1019.py similarity index 100% rename from Tests/encoded_files/cp1019.py rename to PythonTests/encoded_files/cp1019.py diff --git a/Tests/encoded_files/cp11334_bad.py b/PythonTests/encoded_files/cp11334_bad.py similarity index 100% rename from Tests/encoded_files/cp11334_bad.py rename to PythonTests/encoded_files/cp11334_bad.py diff --git a/Tests/encoded_files/cp11334_ok.py b/PythonTests/encoded_files/cp11334_ok.py similarity index 100% rename from Tests/encoded_files/cp11334_ok.py rename to PythonTests/encoded_files/cp11334_ok.py diff --git a/Tests/encoded_files/cp20472.py b/PythonTests/encoded_files/cp20472.py similarity index 100% rename from Tests/encoded_files/cp20472.py rename to PythonTests/encoded_files/cp20472.py diff --git a/Tests/encoded_files/ok_encoding_nonascii.py b/PythonTests/encoded_files/ok_encoding_nonascii.py similarity index 100% rename from Tests/encoded_files/ok_encoding_nonascii.py rename to PythonTests/encoded_files/ok_encoding_nonascii.py diff --git a/Tests/encoded_files/ok_encoding_whitespace.py b/PythonTests/encoded_files/ok_encoding_whitespace.py similarity index 100% rename from Tests/encoded_files/ok_encoding_whitespace.py rename to PythonTests/encoded_files/ok_encoding_whitespace.py diff --git a/Tests/file_with_BOM.txt b/PythonTests/file_with_BOM.txt similarity index 88% rename from Tests/file_with_BOM.txt rename to PythonTests/file_with_BOM.txt index 41bc4eb86..e451428cd 100644 --- a/Tests/file_with_BOM.txt +++ b/PythonTests/file_with_BOM.txt @@ -1 +1 @@ -BÓM +BÓM diff --git a/Tests/file_without_BOM.txt b/PythonTests/file_without_BOM.txt similarity index 83% rename from Tests/file_without_BOM.txt rename to PythonTests/file_without_BOM.txt index 5835e0bf5..cae98f32b 100644 --- a/Tests/file_without_BOM.txt +++ b/PythonTests/file_without_BOM.txt @@ -1 +1 @@ -BÓM +BÓM diff --git a/Tests/functions/test_signatures.py b/PythonTests/functions/test_signatures.py similarity index 100% rename from Tests/functions/test_signatures.py rename to PythonTests/functions/test_signatures.py diff --git a/Tests/gen_stdlib_test.py b/PythonTests/gen_stdlib_test.py similarity index 100% rename from Tests/gen_stdlib_test.py rename to PythonTests/gen_stdlib_test.py diff --git a/Tests/gh129.zip b/PythonTests/gh129.zip similarity index 100% rename from Tests/gh129.zip rename to PythonTests/gh129.zip diff --git a/Tests/harness.py b/PythonTests/harness.py similarity index 100% rename from Tests/harness.py rename to PythonTests/harness.py diff --git a/Tests/hosting/editor_svcs/test_errorlistener.py b/PythonTests/hosting/editor_svcs/test_errorlistener.py similarity index 100% rename from Tests/hosting/editor_svcs/test_errorlistener.py rename to PythonTests/hosting/editor_svcs/test_errorlistener.py diff --git a/Tests/hosting/editor_svcs/test_tokencategorizer.py b/PythonTests/hosting/editor_svcs/test_tokencategorizer.py similarity index 100% rename from Tests/hosting/editor_svcs/test_tokencategorizer.py rename to PythonTests/hosting/editor_svcs/test_tokencategorizer.py diff --git a/Tests/import_extant/_vendor/__init__.py b/PythonTests/import_extant/_vendor/__init__.py similarity index 100% rename from Tests/import_extant/_vendor/__init__.py rename to PythonTests/import_extant/_vendor/__init__.py diff --git a/Tests/import_extant/_vendor/packaging/__init__.py b/PythonTests/import_extant/_vendor/packaging/__init__.py similarity index 100% rename from Tests/import_extant/_vendor/packaging/__init__.py rename to PythonTests/import_extant/_vendor/packaging/__init__.py diff --git a/Tests/import_extant/_vendor/packaging/_structures.py b/PythonTests/import_extant/_vendor/packaging/_structures.py similarity index 100% rename from Tests/import_extant/_vendor/packaging/_structures.py rename to PythonTests/import_extant/_vendor/packaging/_structures.py diff --git a/Tests/import_extant/_vendor/packaging/version.py b/PythonTests/import_extant/_vendor/packaging/version.py similarity index 100% rename from Tests/import_extant/_vendor/packaging/version.py rename to PythonTests/import_extant/_vendor/packaging/version.py diff --git a/Tests/import_extant/extern/__init__.py b/PythonTests/import_extant/extern/__init__.py similarity index 100% rename from Tests/import_extant/extern/__init__.py rename to PythonTests/import_extant/extern/__init__.py diff --git a/Tests/interop/__init__.py b/PythonTests/interop/__init__.py similarity index 100% rename from Tests/interop/__init__.py rename to PythonTests/interop/__init__.py diff --git a/Tests/interop/com/apps/MultiOffice.py b/PythonTests/interop/com/apps/MultiOffice.py similarity index 100% rename from Tests/interop/com/apps/MultiOffice.py rename to PythonTests/interop/com/apps/MultiOffice.py diff --git a/Tests/interop/com/apps/adodb.py b/PythonTests/interop/com/apps/adodb.py similarity index 100% rename from Tests/interop/com/apps/adodb.py rename to PythonTests/interop/com/apps/adodb.py diff --git a/Tests/interop/com/apps/excel.py b/PythonTests/interop/com/apps/excel.py similarity index 100% rename from Tests/interop/com/apps/excel.py rename to PythonTests/interop/com/apps/excel.py diff --git a/Tests/interop/com/apps/scriptpw.py b/PythonTests/interop/com/apps/scriptpw.py similarity index 100% rename from Tests/interop/com/apps/scriptpw.py rename to PythonTests/interop/com/apps/scriptpw.py diff --git a/Tests/interop/com/apps/word.py b/PythonTests/interop/com/apps/word.py similarity index 100% rename from Tests/interop/com/apps/word.py rename to PythonTests/interop/com/apps/word.py diff --git a/Tests/interop/com/compat/__init__.py b/PythonTests/interop/com/compat/__init__.py similarity index 100% rename from Tests/interop/com/compat/__init__.py rename to PythonTests/interop/com/compat/__init__.py diff --git a/Tests/interop/com/compat/hw.py b/PythonTests/interop/com/compat/hw.py similarity index 100% rename from Tests/interop/com/compat/hw.py rename to PythonTests/interop/com/compat/hw.py diff --git a/Tests/interop/com/compat/hw_client.py b/PythonTests/interop/com/compat/hw_client.py similarity index 100% rename from Tests/interop/com/compat/hw_client.py rename to PythonTests/interop/com/compat/hw_client.py diff --git a/Tests/interop/com/dlrcomlib/DispEvents.py b/PythonTests/interop/com/dlrcomlib/DispEvents.py similarity index 100% rename from Tests/interop/com/dlrcomlib/DispEvents.py rename to PythonTests/interop/com/dlrcomlib/DispEvents.py diff --git a/Tests/interop/com/dlrcomlib/InOutParams.py b/PythonTests/interop/com/dlrcomlib/InOutParams.py similarity index 100% rename from Tests/interop/com/dlrcomlib/InOutParams.py rename to PythonTests/interop/com/dlrcomlib/InOutParams.py diff --git a/Tests/interop/com/dlrcomlib/MultipleParams.py b/PythonTests/interop/com/dlrcomlib/MultipleParams.py similarity index 100% rename from Tests/interop/com/dlrcomlib/MultipleParams.py rename to PythonTests/interop/com/dlrcomlib/MultipleParams.py diff --git a/Tests/interop/com/dlrcomlib/OptionalParams.py b/PythonTests/interop/com/dlrcomlib/OptionalParams.py similarity index 100% rename from Tests/interop/com/dlrcomlib/OptionalParams.py rename to PythonTests/interop/com/dlrcomlib/OptionalParams.py diff --git a/Tests/interop/com/dlrcomlib/OutParams.py b/PythonTests/interop/com/dlrcomlib/OutParams.py similarity index 100% rename from Tests/interop/com/dlrcomlib/OutParams.py rename to PythonTests/interop/com/dlrcomlib/OutParams.py diff --git a/Tests/interop/com/dlrcomlib/ReturnValues.py b/PythonTests/interop/com/dlrcomlib/ReturnValues.py similarity index 100% rename from Tests/interop/com/dlrcomlib/ReturnValues.py rename to PythonTests/interop/com/dlrcomlib/ReturnValues.py diff --git a/Tests/interop/com/dlrcomlib/SimpleErrors.py b/PythonTests/interop/com/dlrcomlib/SimpleErrors.py similarity index 100% rename from Tests/interop/com/dlrcomlib/SimpleErrors.py rename to PythonTests/interop/com/dlrcomlib/SimpleErrors.py diff --git a/Tests/interop/com/dlrcomlib/__init__.py b/PythonTests/interop/com/dlrcomlib/__init__.py similarity index 100% rename from Tests/interop/com/dlrcomlib/__init__.py rename to PythonTests/interop/com/dlrcomlib/__init__.py diff --git a/Tests/interop/com/dlrcomlib/dlrcomserver.py b/PythonTests/interop/com/dlrcomlib/dlrcomserver.py similarity index 100% rename from Tests/interop/com/dlrcomlib/dlrcomserver.py rename to PythonTests/interop/com/dlrcomlib/dlrcomserver.py diff --git a/Tests/interop/com/dlrcomlib/paramsinretval.py b/PythonTests/interop/com/dlrcomlib/paramsinretval.py similarity index 100% rename from Tests/interop/com/dlrcomlib/paramsinretval.py rename to PythonTests/interop/com/dlrcomlib/paramsinretval.py diff --git a/Tests/interop/com/dlrcomlib/properties.py b/PythonTests/interop/com/dlrcomlib/properties.py similarity index 100% rename from Tests/interop/com/dlrcomlib/properties.py rename to PythonTests/interop/com/dlrcomlib/properties.py diff --git a/Tests/interop/com/dlrcomlib/pytraits/__init__.py b/PythonTests/interop/com/dlrcomlib/pytraits/__init__.py similarity index 100% rename from Tests/interop/com/dlrcomlib/pytraits/__init__.py rename to PythonTests/interop/com/dlrcomlib/pytraits/__init__.py diff --git a/Tests/interop/com/dlrcomlib/pytraits/method.py b/PythonTests/interop/com/dlrcomlib/pytraits/method.py similarity index 100% rename from Tests/interop/com/dlrcomlib/pytraits/method.py rename to PythonTests/interop/com/dlrcomlib/pytraits/method.py diff --git a/Tests/interop/com/dlrcomlib/pytraits/obj.py b/PythonTests/interop/com/dlrcomlib/pytraits/obj.py similarity index 100% rename from Tests/interop/com/dlrcomlib/pytraits/obj.py rename to PythonTests/interop/com/dlrcomlib/pytraits/obj.py diff --git a/Tests/interop/com/dlrcomlib/pytraits/prop.py b/PythonTests/interop/com/dlrcomlib/pytraits/prop.py similarity index 100% rename from Tests/interop/com/dlrcomlib/pytraits/prop.py rename to PythonTests/interop/com/dlrcomlib/pytraits/prop.py diff --git a/Tests/interop/com/dlrcomlib/typelib.py b/PythonTests/interop/com/dlrcomlib/typelib.py similarity index 100% rename from Tests/interop/com/dlrcomlib/typelib.py rename to PythonTests/interop/com/dlrcomlib/typelib.py diff --git a/Tests/interop/net/derivation/test_ctor_override.py b/PythonTests/interop/net/derivation/test_ctor_override.py similarity index 100% rename from Tests/interop/net/derivation/test_ctor_override.py rename to PythonTests/interop/net/derivation/test_ctor_override.py diff --git a/Tests/interop/net/derivation/test_event_override.py b/PythonTests/interop/net/derivation/test_event_override.py similarity index 100% rename from Tests/interop/net/derivation/test_event_override.py rename to PythonTests/interop/net/derivation/test_event_override.py diff --git a/Tests/interop/net/derivation/test_method_override.py b/PythonTests/interop/net/derivation/test_method_override.py similarity index 100% rename from Tests/interop/net/derivation/test_method_override.py rename to PythonTests/interop/net/derivation/test_method_override.py diff --git a/Tests/interop/net/derivation/test_method_signature.py b/PythonTests/interop/net/derivation/test_method_signature.py similarity index 100% rename from Tests/interop/net/derivation/test_method_signature.py rename to PythonTests/interop/net/derivation/test_method_signature.py diff --git a/Tests/interop/net/derivation/test_property_override.py b/PythonTests/interop/net/derivation/test_property_override.py similarity index 100% rename from Tests/interop/net/derivation/test_property_override.py rename to PythonTests/interop/net/derivation/test_property_override.py diff --git a/Tests/interop/net/derivation/test_simplederive.py b/PythonTests/interop/net/derivation/test_simplederive.py similarity index 100% rename from Tests/interop/net/derivation/test_simplederive.py rename to PythonTests/interop/net/derivation/test_simplederive.py diff --git a/Tests/interop/net/derivation/test_special_method.py b/PythonTests/interop/net/derivation/test_special_method.py similarity index 100% rename from Tests/interop/net/derivation/test_special_method.py rename to PythonTests/interop/net/derivation/test_special_method.py diff --git a/Tests/interop/net/dynamic/test_dynamic_regressions.py b/PythonTests/interop/net/dynamic/test_dynamic_regressions.py similarity index 100% rename from Tests/interop/net/dynamic/test_dynamic_regressions.py rename to PythonTests/interop/net/dynamic/test_dynamic_regressions.py diff --git a/Tests/interop/net/event/test_delegate.py b/PythonTests/interop/net/event/test_delegate.py similarity index 100% rename from Tests/interop/net/event/test_delegate.py rename to PythonTests/interop/net/event/test_delegate.py diff --git a/Tests/interop/net/event/test_event.py b/PythonTests/interop/net/event/test_event.py similarity index 100% rename from Tests/interop/net/event/test_event.py rename to PythonTests/interop/net/event/test_event.py diff --git a/Tests/interop/net/field/test_field_misc.py b/PythonTests/interop/net/field/test_field_misc.py similarity index 100% rename from Tests/interop/net/field/test_field_misc.py rename to PythonTests/interop/net/field/test_field_misc.py diff --git a/Tests/interop/net/field/test_fields_inside_enum.py b/PythonTests/interop/net/field/test_fields_inside_enum.py similarity index 100% rename from Tests/interop/net/field/test_fields_inside_enum.py rename to PythonTests/interop/net/field/test_fields_inside_enum.py diff --git a/Tests/interop/net/field/test_initonly_fields.py b/PythonTests/interop/net/field/test_initonly_fields.py similarity index 100% rename from Tests/interop/net/field/test_initonly_fields.py rename to PythonTests/interop/net/field/test_initonly_fields.py diff --git a/Tests/interop/net/field/test_instance_fields.py b/PythonTests/interop/net/field/test_instance_fields.py similarity index 100% rename from Tests/interop/net/field/test_instance_fields.py rename to PythonTests/interop/net/field/test_instance_fields.py diff --git a/Tests/interop/net/field/test_literal_fields.py b/PythonTests/interop/net/field/test_literal_fields.py similarity index 100% rename from Tests/interop/net/field/test_literal_fields.py rename to PythonTests/interop/net/field/test_literal_fields.py diff --git a/Tests/interop/net/field/test_static_fields.py b/PythonTests/interop/net/field/test_static_fields.py similarity index 100% rename from Tests/interop/net/field/test_static_fields.py rename to PythonTests/interop/net/field/test_static_fields.py diff --git a/Tests/interop/net/loadorder/module.py b/PythonTests/interop/net/loadorder/module.py similarity index 100% rename from Tests/interop/net/loadorder/module.py rename to PythonTests/interop/net/loadorder/module.py diff --git a/Tests/interop/net/loadorder/t1a.py b/PythonTests/interop/net/loadorder/t1a.py similarity index 100% rename from Tests/interop/net/loadorder/t1a.py rename to PythonTests/interop/net/loadorder/t1a.py diff --git a/Tests/interop/net/loadorder/t1b.py b/PythonTests/interop/net/loadorder/t1b.py similarity index 100% rename from Tests/interop/net/loadorder/t1b.py rename to PythonTests/interop/net/loadorder/t1b.py diff --git a/Tests/interop/net/loadorder/t1c.py b/PythonTests/interop/net/loadorder/t1c.py similarity index 100% rename from Tests/interop/net/loadorder/t1c.py rename to PythonTests/interop/net/loadorder/t1c.py diff --git a/Tests/interop/net/loadorder/t1d.py b/PythonTests/interop/net/loadorder/t1d.py similarity index 100% rename from Tests/interop/net/loadorder/t1d.py rename to PythonTests/interop/net/loadorder/t1d.py diff --git a/Tests/interop/net/loadorder/t2a.py b/PythonTests/interop/net/loadorder/t2a.py similarity index 100% rename from Tests/interop/net/loadorder/t2a.py rename to PythonTests/interop/net/loadorder/t2a.py diff --git a/Tests/interop/net/loadorder/t2b.py b/PythonTests/interop/net/loadorder/t2b.py similarity index 100% rename from Tests/interop/net/loadorder/t2b.py rename to PythonTests/interop/net/loadorder/t2b.py diff --git a/Tests/interop/net/loadorder/t2c.py b/PythonTests/interop/net/loadorder/t2c.py similarity index 100% rename from Tests/interop/net/loadorder/t2c.py rename to PythonTests/interop/net/loadorder/t2c.py diff --git a/Tests/interop/net/loadorder/t2d.py b/PythonTests/interop/net/loadorder/t2d.py similarity index 100% rename from Tests/interop/net/loadorder/t2d.py rename to PythonTests/interop/net/loadorder/t2d.py diff --git a/Tests/interop/net/loadorder/t2e.py b/PythonTests/interop/net/loadorder/t2e.py similarity index 100% rename from Tests/interop/net/loadorder/t2e.py rename to PythonTests/interop/net/loadorder/t2e.py diff --git a/Tests/interop/net/loadorder/t2f.py b/PythonTests/interop/net/loadorder/t2f.py similarity index 100% rename from Tests/interop/net/loadorder/t2f.py rename to PythonTests/interop/net/loadorder/t2f.py diff --git a/Tests/interop/net/loadorder/t2g.py b/PythonTests/interop/net/loadorder/t2g.py similarity index 100% rename from Tests/interop/net/loadorder/t2g.py rename to PythonTests/interop/net/loadorder/t2g.py diff --git a/Tests/interop/net/loadorder/t2h.py b/PythonTests/interop/net/loadorder/t2h.py similarity index 100% rename from Tests/interop/net/loadorder/t2h.py rename to PythonTests/interop/net/loadorder/t2h.py diff --git a/Tests/interop/net/loadorder/t3a.py b/PythonTests/interop/net/loadorder/t3a.py similarity index 100% rename from Tests/interop/net/loadorder/t3a.py rename to PythonTests/interop/net/loadorder/t3a.py diff --git a/Tests/interop/net/loadorder/t3b.py b/PythonTests/interop/net/loadorder/t3b.py similarity index 100% rename from Tests/interop/net/loadorder/t3b.py rename to PythonTests/interop/net/loadorder/t3b.py diff --git a/Tests/interop/net/loadorder/t3c0.py b/PythonTests/interop/net/loadorder/t3c0.py similarity index 100% rename from Tests/interop/net/loadorder/t3c0.py rename to PythonTests/interop/net/loadorder/t3c0.py diff --git a/Tests/interop/net/loadorder/t3c1.py b/PythonTests/interop/net/loadorder/t3c1.py similarity index 100% rename from Tests/interop/net/loadorder/t3c1.py rename to PythonTests/interop/net/loadorder/t3c1.py diff --git a/Tests/interop/net/loadorder/t3c2.py b/PythonTests/interop/net/loadorder/t3c2.py similarity index 100% rename from Tests/interop/net/loadorder/t3c2.py rename to PythonTests/interop/net/loadorder/t3c2.py diff --git a/Tests/interop/net/loadorder/t3d.py b/PythonTests/interop/net/loadorder/t3d.py similarity index 100% rename from Tests/interop/net/loadorder/t3d.py rename to PythonTests/interop/net/loadorder/t3d.py diff --git a/Tests/interop/net/loadorder/t3e.py b/PythonTests/interop/net/loadorder/t3e.py similarity index 100% rename from Tests/interop/net/loadorder/t3e.py rename to PythonTests/interop/net/loadorder/t3e.py diff --git a/Tests/interop/net/loadorder/t3f.py b/PythonTests/interop/net/loadorder/t3f.py similarity index 100% rename from Tests/interop/net/loadorder/t3f.py rename to PythonTests/interop/net/loadorder/t3f.py diff --git a/Tests/interop/net/loadorder/t3g1.py b/PythonTests/interop/net/loadorder/t3g1.py similarity index 100% rename from Tests/interop/net/loadorder/t3g1.py rename to PythonTests/interop/net/loadorder/t3g1.py diff --git a/Tests/interop/net/loadorder/t3g2.py b/PythonTests/interop/net/loadorder/t3g2.py similarity index 100% rename from Tests/interop/net/loadorder/t3g2.py rename to PythonTests/interop/net/loadorder/t3g2.py diff --git a/Tests/interop/net/loadorder/t3h.py b/PythonTests/interop/net/loadorder/t3h.py similarity index 100% rename from Tests/interop/net/loadorder/t3h.py rename to PythonTests/interop/net/loadorder/t3h.py diff --git a/Tests/interop/net/loadorder/t3i.py b/PythonTests/interop/net/loadorder/t3i.py similarity index 100% rename from Tests/interop/net/loadorder/t3i.py rename to PythonTests/interop/net/loadorder/t3i.py diff --git a/Tests/interop/net/loadorder/t4a.py b/PythonTests/interop/net/loadorder/t4a.py similarity index 100% rename from Tests/interop/net/loadorder/t4a.py rename to PythonTests/interop/net/loadorder/t4a.py diff --git a/Tests/interop/net/loadorder/t4b.py b/PythonTests/interop/net/loadorder/t4b.py similarity index 100% rename from Tests/interop/net/loadorder/t4b.py rename to PythonTests/interop/net/loadorder/t4b.py diff --git a/Tests/interop/net/loadorder/t4c.py b/PythonTests/interop/net/loadorder/t4c.py similarity index 100% rename from Tests/interop/net/loadorder/t4c.py rename to PythonTests/interop/net/loadorder/t4c.py diff --git a/Tests/interop/net/loadorder/t5a.py b/PythonTests/interop/net/loadorder/t5a.py similarity index 100% rename from Tests/interop/net/loadorder/t5a.py rename to PythonTests/interop/net/loadorder/t5a.py diff --git a/Tests/interop/net/loadorder/t5b.py b/PythonTests/interop/net/loadorder/t5b.py similarity index 100% rename from Tests/interop/net/loadorder/t5b.py rename to PythonTests/interop/net/loadorder/t5b.py diff --git a/Tests/interop/net/loadorder/t5c1.py b/PythonTests/interop/net/loadorder/t5c1.py similarity index 100% rename from Tests/interop/net/loadorder/t5c1.py rename to PythonTests/interop/net/loadorder/t5c1.py diff --git a/Tests/interop/net/loadorder/t5c2.py b/PythonTests/interop/net/loadorder/t5c2.py similarity index 100% rename from Tests/interop/net/loadorder/t5c2.py rename to PythonTests/interop/net/loadorder/t5c2.py diff --git a/Tests/interop/net/loadorder/t6.py b/PythonTests/interop/net/loadorder/t6.py similarity index 100% rename from Tests/interop/net/loadorder/t6.py rename to PythonTests/interop/net/loadorder/t6.py diff --git a/Tests/interop/net/loadorder/t7a.py b/PythonTests/interop/net/loadorder/t7a.py similarity index 100% rename from Tests/interop/net/loadorder/t7a.py rename to PythonTests/interop/net/loadorder/t7a.py diff --git a/Tests/interop/net/loadorder/t7b.py b/PythonTests/interop/net/loadorder/t7b.py similarity index 100% rename from Tests/interop/net/loadorder/t7b.py rename to PythonTests/interop/net/loadorder/t7b.py diff --git a/Tests/interop/net/loadorder/t7c.py b/PythonTests/interop/net/loadorder/t7c.py similarity index 100% rename from Tests/interop/net/loadorder/t7c.py rename to PythonTests/interop/net/loadorder/t7c.py diff --git a/Tests/interop/net/loadorder/t7d.py b/PythonTests/interop/net/loadorder/t7d.py similarity index 100% rename from Tests/interop/net/loadorder/t7d.py rename to PythonTests/interop/net/loadorder/t7d.py diff --git a/Tests/interop/net/loadorder/t7e.py b/PythonTests/interop/net/loadorder/t7e.py similarity index 100% rename from Tests/interop/net/loadorder/t7e.py rename to PythonTests/interop/net/loadorder/t7e.py diff --git a/Tests/interop/net/loadorder/t7f.py b/PythonTests/interop/net/loadorder/t7f.py similarity index 100% rename from Tests/interop/net/loadorder/t7f.py rename to PythonTests/interop/net/loadorder/t7f.py diff --git a/Tests/interop/net/method/test_arguments.py b/PythonTests/interop/net/method/test_arguments.py similarity index 100% rename from Tests/interop/net/method/test_arguments.py rename to PythonTests/interop/net/method/test_arguments.py diff --git a/Tests/interop/net/method/test_op_explicit.py b/PythonTests/interop/net/method/test_op_explicit.py similarity index 100% rename from Tests/interop/net/method/test_op_explicit.py rename to PythonTests/interop/net/method/test_op_explicit.py diff --git a/Tests/interop/net/method/test_op_implicit.py b/PythonTests/interop/net/method/test_op_implicit.py similarity index 100% rename from Tests/interop/net/method/test_op_implicit.py rename to PythonTests/interop/net/method/test_op_implicit.py diff --git a/Tests/interop/net/method/test_operators.py b/PythonTests/interop/net/method/test_operators.py similarity index 100% rename from Tests/interop/net/method/test_operators.py rename to PythonTests/interop/net/method/test_operators.py diff --git a/Tests/interop/net/method/test_returnvalue.py b/PythonTests/interop/net/method/test_returnvalue.py similarity index 100% rename from Tests/interop/net/method/test_returnvalue.py rename to PythonTests/interop/net/method/test_returnvalue.py diff --git a/Tests/interop/net/property/test_indexercs.py b/PythonTests/interop/net/property/test_indexercs.py similarity index 100% rename from Tests/interop/net/property/test_indexercs.py rename to PythonTests/interop/net/property/test_indexercs.py diff --git a/Tests/interop/net/property/test_indexervb.py b/PythonTests/interop/net/property/test_indexervb.py similarity index 100% rename from Tests/interop/net/property/test_indexervb.py rename to PythonTests/interop/net/property/test_indexervb.py diff --git a/Tests/interop/net/property/test_property.py b/PythonTests/interop/net/property/test_property.py similarity index 100% rename from Tests/interop/net/property/test_property.py rename to PythonTests/interop/net/property/test_property.py diff --git a/Tests/interop/net/test_accessibility.py b/PythonTests/interop/net/test_accessibility.py similarity index 100% rename from Tests/interop/net/test_accessibility.py rename to PythonTests/interop/net/test_accessibility.py diff --git a/Tests/interop/net/test_dynamicobjectmodel.py b/PythonTests/interop/net/test_dynamicobjectmodel.py similarity index 100% rename from Tests/interop/net/test_dynamicobjectmodel.py rename to PythonTests/interop/net/test_dynamicobjectmodel.py diff --git a/Tests/interop/net/test_loadorder.py b/PythonTests/interop/net/test_loadorder.py similarity index 100% rename from Tests/interop/net/test_loadorder.py rename to PythonTests/interop/net/test_loadorder.py diff --git a/Tests/interop/net/type/test___clrtype.py b/PythonTests/interop/net/type/test___clrtype.py similarity index 100% rename from Tests/interop/net/type/test___clrtype.py rename to PythonTests/interop/net/type/test___clrtype.py diff --git a/Tests/interop/net/type/test_assembly.py b/PythonTests/interop/net/type/test_assembly.py similarity index 100% rename from Tests/interop/net/type/test_assembly.py rename to PythonTests/interop/net/type/test_assembly.py diff --git a/Tests/interop/net/type/test_clr_array.py b/PythonTests/interop/net/type/test_clr_array.py similarity index 100% rename from Tests/interop/net/type/test_clr_array.py rename to PythonTests/interop/net/type/test_clr_array.py diff --git a/Tests/interop/net/type/test_ctor.py b/PythonTests/interop/net/type/test_ctor.py similarity index 100% rename from Tests/interop/net/type/test_ctor.py rename to PythonTests/interop/net/type/test_ctor.py diff --git a/Tests/interop/net/type/test_defaultmember.py b/PythonTests/interop/net/type/test_defaultmember.py similarity index 100% rename from Tests/interop/net/type/test_defaultmember.py rename to PythonTests/interop/net/type/test_defaultmember.py diff --git a/Tests/interop/net/type/test_reachtype.py b/PythonTests/interop/net/type/test_reachtype.py similarity index 100% rename from Tests/interop/net/type/test_reachtype.py rename to PythonTests/interop/net/type/test_reachtype.py diff --git a/Tests/interop/net/versions/test_four_dot_zero.py b/PythonTests/interop/net/versions/test_four_dot_zero.py similarity index 100% rename from Tests/interop/net/versions/test_four_dot_zero.py rename to PythonTests/interop/net/versions/test_four_dot_zero.py diff --git a/Tests/modules/__init__.py b/PythonTests/modules/__init__.py similarity index 100% rename from Tests/modules/__init__.py rename to PythonTests/modules/__init__.py diff --git a/Tests/modules/io_related/test__bytesio.py b/PythonTests/modules/io_related/test__bytesio.py similarity index 100% rename from Tests/modules/io_related/test__bytesio.py rename to PythonTests/modules/io_related/test__bytesio.py diff --git a/Tests/modules/io_related/test__fileio.py b/PythonTests/modules/io_related/test__fileio.py similarity index 100% rename from Tests/modules/io_related/test__fileio.py rename to PythonTests/modules/io_related/test__fileio.py diff --git a/Tests/modules/io_related/test_binascii.py b/PythonTests/modules/io_related/test_binascii.py similarity index 100% rename from Tests/modules/io_related/test_binascii.py rename to PythonTests/modules/io_related/test_binascii.py diff --git a/Tests/modules/io_related/test_cPickle.py b/PythonTests/modules/io_related/test_cPickle.py similarity index 100% rename from Tests/modules/io_related/test_cPickle.py rename to PythonTests/modules/io_related/test_cPickle.py diff --git a/Tests/modules/io_related/test_codecs.py b/PythonTests/modules/io_related/test_codecs.py similarity index 100% rename from Tests/modules/io_related/test_codecs.py rename to PythonTests/modules/io_related/test_codecs.py diff --git a/Tests/modules/io_related/test_copyreg.py b/PythonTests/modules/io_related/test_copyreg.py similarity index 100% rename from Tests/modules/io_related/test_copyreg.py rename to PythonTests/modules/io_related/test_copyreg.py diff --git a/Tests/modules/io_related/test_fd.py b/PythonTests/modules/io_related/test_fd.py similarity index 100% rename from Tests/modules/io_related/test_fd.py rename to PythonTests/modules/io_related/test_fd.py diff --git a/Tests/modules/io_related/test_io_StringIO.py b/PythonTests/modules/io_related/test_io_StringIO.py similarity index 100% rename from Tests/modules/io_related/test_io_StringIO.py rename to PythonTests/modules/io_related/test_io_StringIO.py diff --git a/Tests/modules/io_related/test_marshal.py b/PythonTests/modules/io_related/test_marshal.py similarity index 100% rename from Tests/modules/io_related/test_marshal.py rename to PythonTests/modules/io_related/test_marshal.py diff --git a/Tests/modules/io_related/test_re.py b/PythonTests/modules/io_related/test_re.py similarity index 100% rename from Tests/modules/io_related/test_re.py rename to PythonTests/modules/io_related/test_re.py diff --git a/Tests/modules/misc/test__opcode.py b/PythonTests/modules/misc/test__opcode.py similarity index 100% rename from Tests/modules/misc/test__opcode.py rename to PythonTests/modules/misc/test__opcode.py diff --git a/Tests/modules/misc/test__random.py b/PythonTests/modules/misc/test__random.py similarity index 100% rename from Tests/modules/misc/test__random.py rename to PythonTests/modules/misc/test__random.py diff --git a/Tests/modules/misc/test__sha256.py b/PythonTests/modules/misc/test__sha256.py similarity index 100% rename from Tests/modules/misc/test__sha256.py rename to PythonTests/modules/misc/test__sha256.py diff --git a/Tests/modules/misc/test__sha512.py b/PythonTests/modules/misc/test__sha512.py similarity index 100% rename from Tests/modules/misc/test__sha512.py rename to PythonTests/modules/misc/test__sha512.py diff --git a/Tests/modules/misc/test__warnings.py b/PythonTests/modules/misc/test__warnings.py similarity index 100% rename from Tests/modules/misc/test__warnings.py rename to PythonTests/modules/misc/test__warnings.py diff --git a/Tests/modules/misc/test__weakref.py b/PythonTests/modules/misc/test__weakref.py similarity index 100% rename from Tests/modules/misc/test__weakref.py rename to PythonTests/modules/misc/test__weakref.py diff --git a/Tests/modules/misc/test_ctypes.py b/PythonTests/modules/misc/test_ctypes.py similarity index 100% rename from Tests/modules/misc/test_ctypes.py rename to PythonTests/modules/misc/test_ctypes.py diff --git a/Tests/modules/misc/test_datetime.py b/PythonTests/modules/misc/test_datetime.py similarity index 100% rename from Tests/modules/misc/test_datetime.py rename to PythonTests/modules/misc/test_datetime.py diff --git a/Tests/modules/misc/test_math.py b/PythonTests/modules/misc/test_math.py similarity index 100% rename from Tests/modules/misc/test_math.py rename to PythonTests/modules/misc/test_math.py diff --git a/Tests/modules/misc/test_operator.py b/PythonTests/modules/misc/test_operator.py similarity index 100% rename from Tests/modules/misc/test_operator.py rename to PythonTests/modules/misc/test_operator.py diff --git a/Tests/modules/misc/test_system_namespaces.py b/PythonTests/modules/misc/test_system_namespaces.py similarity index 100% rename from Tests/modules/misc/test_system_namespaces.py rename to PythonTests/modules/misc/test_system_namespaces.py diff --git a/Tests/modules/misc/test_zlib.py b/PythonTests/modules/misc/test_zlib.py similarity index 100% rename from Tests/modules/misc/test_zlib.py rename to PythonTests/modules/misc/test_zlib.py diff --git a/Tests/modules/network_related/__init__.py b/PythonTests/modules/network_related/__init__.py similarity index 100% rename from Tests/modules/network_related/__init__.py rename to PythonTests/modules/network_related/__init__.py diff --git a/Tests/modules/network_related/keycert.pem b/PythonTests/modules/network_related/keycert.pem similarity index 100% rename from Tests/modules/network_related/keycert.pem rename to PythonTests/modules/network_related/keycert.pem diff --git a/Tests/modules/network_related/test__socket.py b/PythonTests/modules/network_related/test__socket.py similarity index 100% rename from Tests/modules/network_related/test__socket.py rename to PythonTests/modules/network_related/test__socket.py diff --git a/Tests/modules/network_related/test__ssl.py b/PythonTests/modules/network_related/test__ssl.py similarity index 100% rename from Tests/modules/network_related/test__ssl.py rename to PythonTests/modules/network_related/test__ssl.py diff --git a/Tests/modules/system_related/__init__.py b/PythonTests/modules/system_related/__init__.py similarity index 100% rename from Tests/modules/system_related/__init__.py rename to PythonTests/modules/system_related/__init__.py diff --git a/Tests/modules/system_related/test__locale.py b/PythonTests/modules/system_related/test__locale.py similarity index 100% rename from Tests/modules/system_related/test__locale.py rename to PythonTests/modules/system_related/test__locale.py diff --git a/Tests/modules/system_related/test_errno.py b/PythonTests/modules/system_related/test_errno.py similarity index 100% rename from Tests/modules/system_related/test_errno.py rename to PythonTests/modules/system_related/test_errno.py diff --git a/Tests/modules/system_related/test_gc.py b/PythonTests/modules/system_related/test_gc.py similarity index 100% rename from Tests/modules/system_related/test_gc.py rename to PythonTests/modules/system_related/test_gc.py diff --git a/Tests/modules/system_related/test_nt.py b/PythonTests/modules/system_related/test_nt.py similarity index 100% rename from Tests/modules/system_related/test_nt.py rename to PythonTests/modules/system_related/test_nt.py diff --git a/Tests/modules/system_related/test_os.py b/PythonTests/modules/system_related/test_os.py similarity index 100% rename from Tests/modules/system_related/test_os.py rename to PythonTests/modules/system_related/test_os.py diff --git a/Tests/modules/system_related/test_resource.py b/PythonTests/modules/system_related/test_resource.py similarity index 100% rename from Tests/modules/system_related/test_resource.py rename to PythonTests/modules/system_related/test_resource.py diff --git a/Tests/modules/system_related/test_resource_stdlib.py b/PythonTests/modules/system_related/test_resource_stdlib.py similarity index 100% rename from Tests/modules/system_related/test_resource_stdlib.py rename to PythonTests/modules/system_related/test_resource_stdlib.py diff --git a/Tests/modules/system_related/test_signal.py b/PythonTests/modules/system_related/test_signal.py similarity index 100% rename from Tests/modules/system_related/test_signal.py rename to PythonTests/modules/system_related/test_signal.py diff --git a/Tests/modules/system_related/test_sys.py b/PythonTests/modules/system_related/test_sys.py similarity index 100% rename from Tests/modules/system_related/test_sys.py rename to PythonTests/modules/system_related/test_sys.py diff --git a/Tests/modules/system_related/test_sys_getframe.py b/PythonTests/modules/system_related/test_sys_getframe.py similarity index 100% rename from Tests/modules/system_related/test_sys_getframe.py rename to PythonTests/modules/system_related/test_sys_getframe.py diff --git a/Tests/modules/system_related/test_thread.py b/PythonTests/modules/system_related/test_thread.py similarity index 100% rename from Tests/modules/system_related/test_thread.py rename to PythonTests/modules/system_related/test_thread.py diff --git a/Tests/modules/system_related/test_time.py b/PythonTests/modules/system_related/test_time.py similarity index 100% rename from Tests/modules/system_related/test_time.py rename to PythonTests/modules/system_related/test_time.py diff --git a/Tests/modules/type_related/__init__.py b/PythonTests/modules/type_related/__init__.py similarity index 100% rename from Tests/modules/type_related/__init__.py rename to PythonTests/modules/type_related/__init__.py diff --git a/Tests/modules/type_related/test__struct.py b/PythonTests/modules/type_related/test__struct.py similarity index 100% rename from Tests/modules/type_related/test__struct.py rename to PythonTests/modules/type_related/test__struct.py diff --git a/Tests/modules/type_related/test_array.py b/PythonTests/modules/type_related/test_array.py similarity index 100% rename from Tests/modules/type_related/test_array.py rename to PythonTests/modules/type_related/test_array.py diff --git a/Tests/modules/type_related/test_bitfields_ctypes_stdlib.py b/PythonTests/modules/type_related/test_bitfields_ctypes_stdlib.py similarity index 100% rename from Tests/modules/type_related/test_bitfields_ctypes_stdlib.py rename to PythonTests/modules/type_related/test_bitfields_ctypes_stdlib.py diff --git a/Tests/modules/type_related/test_ctypes.py b/PythonTests/modules/type_related/test_ctypes.py similarity index 100% rename from Tests/modules/type_related/test_ctypes.py rename to PythonTests/modules/type_related/test_ctypes.py diff --git a/Tests/modules/type_related/test_types.py b/PythonTests/modules/type_related/test_types.py similarity index 100% rename from Tests/modules/type_related/test_types.py rename to PythonTests/modules/type_related/test_types.py diff --git a/Tests/perf_micro_calls.py b/PythonTests/perf_micro_calls.py similarity index 100% rename from Tests/perf_micro_calls.py rename to PythonTests/perf_micro_calls.py diff --git a/Tests/pickles/cp18666.pickle b/PythonTests/pickles/cp18666.pickle similarity index 100% rename from Tests/pickles/cp18666.pickle rename to PythonTests/pickles/cp18666.pickle diff --git a/Tests/plans/debugging.html b/PythonTests/plans/debugging.html similarity index 100% rename from Tests/plans/debugging.html rename to PythonTests/plans/debugging.html diff --git a/Tests/plans/debugging.mdbg_tool.html b/PythonTests/plans/debugging.mdbg_tool.html similarity index 100% rename from Tests/plans/debugging.mdbg_tool.html rename to PythonTests/plans/debugging.mdbg_tool.html diff --git a/Tests/plans/debugging.pdb_mod.html b/PythonTests/plans/debugging.pdb_mod.html similarity index 100% rename from Tests/plans/debugging.pdb_mod.html rename to PythonTests/plans/debugging.pdb_mod.html diff --git a/Tests/plans/debugging.vs.html b/PythonTests/plans/debugging.vs.html similarity index 100% rename from Tests/plans/debugging.vs.html rename to PythonTests/plans/debugging.vs.html diff --git a/Tests/plans/generic_plan_template.py b/PythonTests/plans/generic_plan_template.py similarity index 100% rename from Tests/plans/generic_plan_template.py rename to PythonTests/plans/generic_plan_template.py diff --git a/Tests/plans/interop.net.derivation.html b/PythonTests/plans/interop.net.derivation.html similarity index 100% rename from Tests/plans/interop.net.derivation.html rename to PythonTests/plans/interop.net.derivation.html diff --git a/Tests/plans/interop.net.derivation.test_ctor_override.html b/PythonTests/plans/interop.net.derivation.test_ctor_override.html similarity index 100% rename from Tests/plans/interop.net.derivation.test_ctor_override.html rename to PythonTests/plans/interop.net.derivation.test_ctor_override.html diff --git a/Tests/plans/interop.net.derivation.test_event_override.html b/PythonTests/plans/interop.net.derivation.test_event_override.html similarity index 100% rename from Tests/plans/interop.net.derivation.test_event_override.html rename to PythonTests/plans/interop.net.derivation.test_event_override.html diff --git a/Tests/plans/interop.net.derivation.test_method_override.html b/PythonTests/plans/interop.net.derivation.test_method_override.html similarity index 100% rename from Tests/plans/interop.net.derivation.test_method_override.html rename to PythonTests/plans/interop.net.derivation.test_method_override.html diff --git a/Tests/plans/interop.net.derivation.test_method_signature.html b/PythonTests/plans/interop.net.derivation.test_method_signature.html similarity index 100% rename from Tests/plans/interop.net.derivation.test_method_signature.html rename to PythonTests/plans/interop.net.derivation.test_method_signature.html diff --git a/Tests/plans/interop.net.derivation.test_property_override.html b/PythonTests/plans/interop.net.derivation.test_property_override.html similarity index 100% rename from Tests/plans/interop.net.derivation.test_property_override.html rename to PythonTests/plans/interop.net.derivation.test_property_override.html diff --git a/Tests/plans/interop.net.derivation.test_simplederive.html b/PythonTests/plans/interop.net.derivation.test_simplederive.html similarity index 100% rename from Tests/plans/interop.net.derivation.test_simplederive.html rename to PythonTests/plans/interop.net.derivation.test_simplederive.html diff --git a/Tests/plans/interop.net.derivation.test_special_method.html b/PythonTests/plans/interop.net.derivation.test_special_method.html similarity index 100% rename from Tests/plans/interop.net.derivation.test_special_method.html rename to PythonTests/plans/interop.net.derivation.test_special_method.html diff --git a/Tests/plans/interop.net.event.html b/PythonTests/plans/interop.net.event.html similarity index 100% rename from Tests/plans/interop.net.event.html rename to PythonTests/plans/interop.net.event.html diff --git a/Tests/plans/interop.net.event.test_delegate.html b/PythonTests/plans/interop.net.event.test_delegate.html similarity index 100% rename from Tests/plans/interop.net.event.test_delegate.html rename to PythonTests/plans/interop.net.event.test_delegate.html diff --git a/Tests/plans/interop.net.event.test_event.html b/PythonTests/plans/interop.net.event.test_event.html similarity index 100% rename from Tests/plans/interop.net.event.test_event.html rename to PythonTests/plans/interop.net.event.test_event.html diff --git a/Tests/plans/interop.net.field.html b/PythonTests/plans/interop.net.field.html similarity index 100% rename from Tests/plans/interop.net.field.html rename to PythonTests/plans/interop.net.field.html diff --git a/Tests/plans/interop.net.field.test_field_misc.html b/PythonTests/plans/interop.net.field.test_field_misc.html similarity index 100% rename from Tests/plans/interop.net.field.test_field_misc.html rename to PythonTests/plans/interop.net.field.test_field_misc.html diff --git a/Tests/plans/interop.net.field.test_fields_inside_enum.html b/PythonTests/plans/interop.net.field.test_fields_inside_enum.html similarity index 100% rename from Tests/plans/interop.net.field.test_fields_inside_enum.html rename to PythonTests/plans/interop.net.field.test_fields_inside_enum.html diff --git a/Tests/plans/interop.net.html b/PythonTests/plans/interop.net.html similarity index 100% rename from Tests/plans/interop.net.html rename to PythonTests/plans/interop.net.html diff --git a/Tests/plans/interop.net.insert_csharp.html b/PythonTests/plans/interop.net.insert_csharp.html similarity index 100% rename from Tests/plans/interop.net.insert_csharp.html rename to PythonTests/plans/interop.net.insert_csharp.html diff --git a/Tests/plans/interop.net.method.html b/PythonTests/plans/interop.net.method.html similarity index 100% rename from Tests/plans/interop.net.method.html rename to PythonTests/plans/interop.net.method.html diff --git a/Tests/plans/interop.net.method.test_arguments.html b/PythonTests/plans/interop.net.method.test_arguments.html similarity index 100% rename from Tests/plans/interop.net.method.test_arguments.html rename to PythonTests/plans/interop.net.method.test_arguments.html diff --git a/Tests/plans/interop.net.method.test_op_explicit.html b/PythonTests/plans/interop.net.method.test_op_explicit.html similarity index 100% rename from Tests/plans/interop.net.method.test_op_explicit.html rename to PythonTests/plans/interop.net.method.test_op_explicit.html diff --git a/Tests/plans/interop.net.method.test_op_implicit.html b/PythonTests/plans/interop.net.method.test_op_implicit.html similarity index 100% rename from Tests/plans/interop.net.method.test_op_implicit.html rename to PythonTests/plans/interop.net.method.test_op_implicit.html diff --git a/Tests/plans/interop.net.method.test_operators.html b/PythonTests/plans/interop.net.method.test_operators.html similarity index 100% rename from Tests/plans/interop.net.method.test_operators.html rename to PythonTests/plans/interop.net.method.test_operators.html diff --git a/Tests/plans/interop.net.method.test_returnvalue.html b/PythonTests/plans/interop.net.method.test_returnvalue.html similarity index 100% rename from Tests/plans/interop.net.method.test_returnvalue.html rename to PythonTests/plans/interop.net.method.test_returnvalue.html diff --git a/Tests/plans/interop.net.property.html b/PythonTests/plans/interop.net.property.html similarity index 100% rename from Tests/plans/interop.net.property.html rename to PythonTests/plans/interop.net.property.html diff --git a/Tests/plans/interop.net.property.test_indexercs.html b/PythonTests/plans/interop.net.property.test_indexercs.html similarity index 100% rename from Tests/plans/interop.net.property.test_indexercs.html rename to PythonTests/plans/interop.net.property.test_indexercs.html diff --git a/Tests/plans/interop.net.property.test_indexervb.html b/PythonTests/plans/interop.net.property.test_indexervb.html similarity index 100% rename from Tests/plans/interop.net.property.test_indexervb.html rename to PythonTests/plans/interop.net.property.test_indexervb.html diff --git a/Tests/plans/interop.net.property.test_property.html b/PythonTests/plans/interop.net.property.test_property.html similarity index 100% rename from Tests/plans/interop.net.property.test_property.html rename to PythonTests/plans/interop.net.property.test_property.html diff --git a/Tests/plans/interop.net.test_accessibility.html b/PythonTests/plans/interop.net.test_accessibility.html similarity index 100% rename from Tests/plans/interop.net.test_accessibility.html rename to PythonTests/plans/interop.net.test_accessibility.html diff --git a/Tests/plans/interop.net.test_dynamicobjectmodel.html b/PythonTests/plans/interop.net.test_dynamicobjectmodel.html similarity index 100% rename from Tests/plans/interop.net.test_dynamicobjectmodel.html rename to PythonTests/plans/interop.net.test_dynamicobjectmodel.html diff --git a/Tests/plans/interop.net.test_loadorder.html b/PythonTests/plans/interop.net.test_loadorder.html similarity index 100% rename from Tests/plans/interop.net.test_loadorder.html rename to PythonTests/plans/interop.net.test_loadorder.html diff --git a/Tests/plans/interop.net.type.html b/PythonTests/plans/interop.net.type.html similarity index 100% rename from Tests/plans/interop.net.type.html rename to PythonTests/plans/interop.net.type.html diff --git a/Tests/plans/interop.net.type.test_assembly.html b/PythonTests/plans/interop.net.type.test_assembly.html similarity index 100% rename from Tests/plans/interop.net.type.test_assembly.html rename to PythonTests/plans/interop.net.type.test_assembly.html diff --git a/Tests/plans/interop.net.type.test_clr_array.html b/PythonTests/plans/interop.net.type.test_clr_array.html similarity index 100% rename from Tests/plans/interop.net.type.test_clr_array.html rename to PythonTests/plans/interop.net.type.test_clr_array.html diff --git a/Tests/plans/interop.net.type.test_ctor.html b/PythonTests/plans/interop.net.type.test_ctor.html similarity index 100% rename from Tests/plans/interop.net.type.test_ctor.html rename to PythonTests/plans/interop.net.type.test_ctor.html diff --git a/Tests/plans/interop.net.type.test_defaultmember.html b/PythonTests/plans/interop.net.type.test_defaultmember.html similarity index 100% rename from Tests/plans/interop.net.type.test_defaultmember.html rename to PythonTests/plans/interop.net.type.test_defaultmember.html diff --git a/Tests/plans/interop.net.type.test_reachtype.html b/PythonTests/plans/interop.net.type.test_reachtype.html similarity index 100% rename from Tests/plans/interop.net.type.test_reachtype.html rename to PythonTests/plans/interop.net.type.test_reachtype.html diff --git a/Tests/pretest.py b/PythonTests/pretest.py similarity index 100% rename from Tests/pretest.py rename to PythonTests/pretest.py diff --git a/Tests/pyc/console_hw.py b/PythonTests/pyc/console_hw.py similarity index 100% rename from Tests/pyc/console_hw.py rename to PythonTests/pyc/console_hw.py diff --git a/Tests/pyc/console_hw_args.py b/PythonTests/pyc/console_hw_args.py similarity index 100% rename from Tests/pyc/console_hw_args.py rename to PythonTests/pyc/console_hw_args.py diff --git a/Tests/pyc/other_hw.py b/PythonTests/pyc/other_hw.py similarity index 100% rename from Tests/pyc/other_hw.py rename to PythonTests/pyc/other_hw.py diff --git a/Tests/pyc/pkg/__init__.py b/PythonTests/pyc/pkg/__init__.py similarity index 100% rename from Tests/pyc/pkg/__init__.py rename to PythonTests/pyc/pkg/__init__.py diff --git a/Tests/pyc/pkg/a.py b/PythonTests/pyc/pkg/a.py similarity index 100% rename from Tests/pyc/pkg/a.py rename to PythonTests/pyc/pkg/a.py diff --git a/Tests/pyc/pkg/b.py b/PythonTests/pyc/pkg/b.py similarity index 100% rename from Tests/pyc/pkg/b.py rename to PythonTests/pyc/pkg/b.py diff --git a/Tests/pyc/pycpkgtest.py b/PythonTests/pyc/pycpkgtest.py similarity index 100% rename from Tests/pyc/pycpkgtest.py rename to PythonTests/pyc/pycpkgtest.py diff --git a/Tests/pyc/stdmodules_ok.ps1 b/PythonTests/pyc/stdmodules_ok.ps1 similarity index 100% rename from Tests/pyc/stdmodules_ok.ps1 rename to PythonTests/pyc/stdmodules_ok.ps1 diff --git a/Tests/pyc/test_pyc.ps1 b/PythonTests/pyc/test_pyc.ps1 similarity index 100% rename from Tests/pyc/test_pyc.ps1 rename to PythonTests/pyc/test_pyc.ps1 diff --git a/Tests/pyc/winforms_hw.py b/PythonTests/pyc/winforms_hw.py similarity index 100% rename from Tests/pyc/winforms_hw.py rename to PythonTests/pyc/winforms_hw.py diff --git a/Tests/run.py b/PythonTests/run.py similarity index 100% rename from Tests/run.py rename to PythonTests/run.py diff --git a/Tests/run_transformed.bat b/PythonTests/run_transformed.bat similarity index 100% rename from Tests/run_transformed.bat rename to PythonTests/run_transformed.bat diff --git a/Tests/sample.txt.gz b/PythonTests/sample.txt.gz similarity index 100% rename from Tests/sample.txt.gz rename to PythonTests/sample.txt.gz diff --git a/Tests/specialcontext/Consoleless.ps1 b/PythonTests/specialcontext/Consoleless.ps1 similarity index 100% rename from Tests/specialcontext/Consoleless.ps1 rename to PythonTests/specialcontext/Consoleless.ps1 diff --git a/Tests/specialcontext/verify_ipyw.py b/PythonTests/specialcontext/verify_ipyw.py similarity index 100% rename from Tests/specialcontext/verify_ipyw.py rename to PythonTests/specialcontext/verify_ipyw.py diff --git a/Tests/stress/__init__.py b/PythonTests/stress/__init__.py similarity index 100% rename from Tests/stress/__init__.py rename to PythonTests/stress/__init__.py diff --git a/Tests/stress/bigimport1_test.py b/PythonTests/stress/bigimport1_test.py similarity index 100% rename from Tests/stress/bigimport1_test.py rename to PythonTests/stress/bigimport1_test.py diff --git a/Tests/test_array.py b/PythonTests/test_array.py similarity index 100% rename from Tests/test_array.py rename to PythonTests/test_array.py diff --git a/Tests/test_assert.py b/PythonTests/test_assert.py similarity index 100% rename from Tests/test_assert.py rename to PythonTests/test_assert.py diff --git a/Tests/test_ast.py b/PythonTests/test_ast.py similarity index 100% rename from Tests/test_ast.py rename to PythonTests/test_ast.py diff --git a/Tests/test_attr.py b/PythonTests/test_attr.py similarity index 100% rename from Tests/test_attr.py rename to PythonTests/test_attr.py diff --git a/Tests/test_attribute_customize.py b/PythonTests/test_attribute_customize.py similarity index 100% rename from Tests/test_attribute_customize.py rename to PythonTests/test_attribute_customize.py diff --git a/Tests/test_attrinjector.py b/PythonTests/test_attrinjector.py similarity index 100% rename from Tests/test_attrinjector.py rename to PythonTests/test_attrinjector.py diff --git a/Tests/test_bigint.py b/PythonTests/test_bigint.py similarity index 100% rename from Tests/test_bigint.py rename to PythonTests/test_bigint.py diff --git a/Tests/test_bool.py b/PythonTests/test_bool.py similarity index 100% rename from Tests/test_bool.py rename to PythonTests/test_bool.py diff --git a/Tests/test_builtin_stdlib.py b/PythonTests/test_builtin_stdlib.py similarity index 100% rename from Tests/test_builtin_stdlib.py rename to PythonTests/test_builtin_stdlib.py diff --git a/Tests/test_builtinfunc.py b/PythonTests/test_builtinfunc.py similarity index 100% rename from Tests/test_builtinfunc.py rename to PythonTests/test_builtinfunc.py diff --git a/Tests/test_bytes.py b/PythonTests/test_bytes.py similarity index 100% rename from Tests/test_bytes.py rename to PythonTests/test_bytes.py diff --git a/Tests/test_bz2.py b/PythonTests/test_bz2.py similarity index 100% rename from Tests/test_bz2.py rename to PythonTests/test_bz2.py diff --git a/Tests/test_bz2_stdlib.py b/PythonTests/test_bz2_stdlib.py similarity index 100% rename from Tests/test_bz2_stdlib.py rename to PythonTests/test_bz2_stdlib.py diff --git a/Tests/test_class.py b/PythonTests/test_class.py similarity index 100% rename from Tests/test_class.py rename to PythonTests/test_class.py diff --git a/Tests/test_class_stdlib.py b/PythonTests/test_class_stdlib.py similarity index 100% rename from Tests/test_class_stdlib.py rename to PythonTests/test_class_stdlib.py diff --git a/Tests/test_cliclass.py b/PythonTests/test_cliclass.py similarity index 100% rename from Tests/test_cliclass.py rename to PythonTests/test_cliclass.py diff --git a/Tests/test_closure.py b/PythonTests/test_closure.py similarity index 100% rename from Tests/test_closure.py rename to PythonTests/test_closure.py diff --git a/Tests/test_clrexception.py b/PythonTests/test_clrexception.py similarity index 100% rename from Tests/test_clrexception.py rename to PythonTests/test_clrexception.py diff --git a/Tests/test_clrload.py b/PythonTests/test_clrload.py similarity index 100% rename from Tests/test_clrload.py rename to PythonTests/test_clrload.py diff --git a/Tests/test_clrload2.py b/PythonTests/test_clrload2.py similarity index 100% rename from Tests/test_clrload2.py rename to PythonTests/test_clrload2.py diff --git a/Tests/test_clrnuminterop.py b/PythonTests/test_clrnuminterop.py similarity index 100% rename from Tests/test_clrnuminterop.py rename to PythonTests/test_clrnuminterop.py diff --git a/Tests/test_clrtype.py b/PythonTests/test_clrtype.py similarity index 100% rename from Tests/test_clrtype.py rename to PythonTests/test_clrtype.py diff --git a/Tests/test_clruse.py b/PythonTests/test_clruse.py similarity index 100% rename from Tests/test_clruse.py rename to PythonTests/test_clruse.py diff --git a/Tests/test_codeccallbacks_stdlib.py b/PythonTests/test_codeccallbacks_stdlib.py similarity index 100% rename from Tests/test_codeccallbacks_stdlib.py rename to PythonTests/test_codeccallbacks_stdlib.py diff --git a/Tests/test_codecs.py b/PythonTests/test_codecs.py similarity index 100% rename from Tests/test_codecs.py rename to PythonTests/test_codecs.py diff --git a/Tests/test_codecs_stdlib.py b/PythonTests/test_codecs_stdlib.py similarity index 100% rename from Tests/test_codecs_stdlib.py rename to PythonTests/test_codecs_stdlib.py diff --git a/Tests/test_compiler.py b/PythonTests/test_compiler.py similarity index 100% rename from Tests/test_compiler.py rename to PythonTests/test_compiler.py diff --git a/Tests/test_complex.py b/PythonTests/test_complex.py similarity index 100% rename from Tests/test_complex.py rename to PythonTests/test_complex.py diff --git a/Tests/test_complex_stdlib.py b/PythonTests/test_complex_stdlib.py similarity index 100% rename from Tests/test_complex_stdlib.py rename to PythonTests/test_complex_stdlib.py diff --git a/Tests/test_conditional.py b/PythonTests/test_conditional.py similarity index 100% rename from Tests/test_conditional.py rename to PythonTests/test_conditional.py diff --git a/Tests/test_data.gz b/PythonTests/test_data.gz similarity index 100% rename from Tests/test_data.gz rename to PythonTests/test_data.gz diff --git a/Tests/test_datetime.py b/PythonTests/test_datetime.py similarity index 100% rename from Tests/test_datetime.py rename to PythonTests/test_datetime.py diff --git a/Tests/test_datetime_stdlib.py b/PythonTests/test_datetime_stdlib.py similarity index 100% rename from Tests/test_datetime_stdlib.py rename to PythonTests/test_datetime_stdlib.py diff --git a/Tests/test_decimal.py b/PythonTests/test_decimal.py similarity index 100% rename from Tests/test_decimal.py rename to PythonTests/test_decimal.py diff --git a/Tests/test_decorator.py b/PythonTests/test_decorator.py similarity index 100% rename from Tests/test_decorator.py rename to PythonTests/test_decorator.py diff --git a/Tests/test_delegate.py b/PythonTests/test_delegate.py similarity index 100% rename from Tests/test_delegate.py rename to PythonTests/test_delegate.py diff --git a/Tests/test_deque.py b/PythonTests/test_deque.py similarity index 100% rename from Tests/test_deque.py rename to PythonTests/test_deque.py diff --git a/Tests/test_descr_stdlib.py b/PythonTests/test_descr_stdlib.py similarity index 100% rename from Tests/test_descr_stdlib.py rename to PythonTests/test_descr_stdlib.py diff --git a/Tests/test_dict.py b/PythonTests/test_dict.py similarity index 100% rename from Tests/test_dict.py rename to PythonTests/test_dict.py diff --git a/Tests/test_dict_stdlib.py b/PythonTests/test_dict_stdlib.py similarity index 100% rename from Tests/test_dict_stdlib.py rename to PythonTests/test_dict_stdlib.py diff --git a/Tests/test_dictcomp.py b/PythonTests/test_dictcomp.py similarity index 100% rename from Tests/test_dictcomp.py rename to PythonTests/test_dictcomp.py diff --git a/Tests/test_dllsite.py b/PythonTests/test_dllsite.py similarity index 100% rename from Tests/test_dllsite.py rename to PythonTests/test_dllsite.py diff --git a/Tests/test_dlrkwarg.py b/PythonTests/test_dlrkwarg.py similarity index 100% rename from Tests/test_dlrkwarg.py rename to PythonTests/test_dlrkwarg.py diff --git a/Tests/test_doc.py b/PythonTests/test_doc.py similarity index 100% rename from Tests/test_doc.py rename to PythonTests/test_doc.py diff --git a/Tests/test_enum.py b/PythonTests/test_enum.py similarity index 100% rename from Tests/test_enum.py rename to PythonTests/test_enum.py diff --git a/Tests/test_exceptions.py b/PythonTests/test_exceptions.py similarity index 100% rename from Tests/test_exceptions.py rename to PythonTests/test_exceptions.py diff --git a/Tests/test_exceptions_generated.py b/PythonTests/test_exceptions_generated.py similarity index 100% rename from Tests/test_exceptions_generated.py rename to PythonTests/test_exceptions_generated.py diff --git a/Tests/test_excinfo.py b/PythonTests/test_excinfo.py similarity index 100% rename from Tests/test_excinfo.py rename to PythonTests/test_excinfo.py diff --git a/Tests/test_exec.py b/PythonTests/test_exec.py similarity index 100% rename from Tests/test_exec.py rename to PythonTests/test_exec.py diff --git a/Tests/test_file.py b/PythonTests/test_file.py similarity index 100% rename from Tests/test_file.py rename to PythonTests/test_file.py diff --git a/Tests/test_float_stdlib.py b/PythonTests/test_float_stdlib.py similarity index 100% rename from Tests/test_float_stdlib.py rename to PythonTests/test_float_stdlib.py diff --git a/Tests/test_formatting.py b/PythonTests/test_formatting.py similarity index 100% rename from Tests/test_formatting.py rename to PythonTests/test_formatting.py diff --git a/Tests/test_function.py b/PythonTests/test_function.py similarity index 100% rename from Tests/test_function.py rename to PythonTests/test_function.py diff --git a/Tests/test_functools_stdlib.py b/PythonTests/test_functools_stdlib.py similarity index 100% rename from Tests/test_functools_stdlib.py rename to PythonTests/test_functools_stdlib.py diff --git a/Tests/test_fuzz_parser.py b/PythonTests/test_fuzz_parser.py similarity index 100% rename from Tests/test_fuzz_parser.py rename to PythonTests/test_fuzz_parser.py diff --git a/Tests/test_generator.py b/PythonTests/test_generator.py similarity index 100% rename from Tests/test_generator.py rename to PythonTests/test_generator.py diff --git a/Tests/test_generator_throw.py b/PythonTests/test_generator_throw.py similarity index 100% rename from Tests/test_generator_throw.py rename to PythonTests/test_generator_throw.py diff --git a/Tests/test_genericmeth.py b/PythonTests/test_genericmeth.py similarity index 100% rename from Tests/test_genericmeth.py rename to PythonTests/test_genericmeth.py diff --git a/Tests/test_hash.py b/PythonTests/test_hash.py similarity index 100% rename from Tests/test_hash.py rename to PythonTests/test_hash.py diff --git a/Tests/test_help.py b/PythonTests/test_help.py similarity index 100% rename from Tests/test_help.py rename to PythonTests/test_help.py diff --git a/Tests/test_httplib_stdlib.py b/PythonTests/test_httplib_stdlib.py similarity index 100% rename from Tests/test_httplib_stdlib.py rename to PythonTests/test_httplib_stdlib.py diff --git a/Tests/test_imp.py b/PythonTests/test_imp.py similarity index 100% rename from Tests/test_imp.py rename to PythonTests/test_imp.py diff --git a/Tests/test_importext.py b/PythonTests/test_importext.py similarity index 100% rename from Tests/test_importext.py rename to PythonTests/test_importext.py diff --git a/Tests/test_importpkg.py b/PythonTests/test_importpkg.py similarity index 100% rename from Tests/test_importpkg.py rename to PythonTests/test_importpkg.py diff --git a/Tests/test_in.py b/PythonTests/test_in.py similarity index 100% rename from Tests/test_in.py rename to PythonTests/test_in.py diff --git a/Tests/test_index.py b/PythonTests/test_index.py similarity index 100% rename from Tests/test_index.py rename to PythonTests/test_index.py diff --git a/Tests/test_inheritance.py b/PythonTests/test_inheritance.py similarity index 100% rename from Tests/test_inheritance.py rename to PythonTests/test_inheritance.py diff --git a/Tests/test_int.py b/PythonTests/test_int.py similarity index 100% rename from Tests/test_int.py rename to PythonTests/test_int.py diff --git a/Tests/test_interactive.py b/PythonTests/test_interactive.py similarity index 100% rename from Tests/test_interactive.py rename to PythonTests/test_interactive.py diff --git a/Tests/test_io.py b/PythonTests/test_io.py similarity index 100% rename from Tests/test_io.py rename to PythonTests/test_io.py diff --git a/Tests/test_io_stdlib.py b/PythonTests/test_io_stdlib.py similarity index 100% rename from Tests/test_io_stdlib.py rename to PythonTests/test_io_stdlib.py diff --git a/Tests/test_ipyc.py b/PythonTests/test_ipyc.py similarity index 100% rename from Tests/test_ipyc.py rename to PythonTests/test_ipyc.py diff --git a/Tests/test_ipye.py b/PythonTests/test_ipye.py similarity index 100% rename from Tests/test_ipye.py rename to PythonTests/test_ipye.py diff --git a/Tests/test_ironmath.py b/PythonTests/test_ironmath.py similarity index 100% rename from Tests/test_ironmath.py rename to PythonTests/test_ironmath.py diff --git a/Tests/test_is.py b/PythonTests/test_is.py similarity index 100% rename from Tests/test_is.py rename to PythonTests/test_is.py diff --git a/Tests/test_isinstance.py b/PythonTests/test_isinstance.py similarity index 100% rename from Tests/test_isinstance.py rename to PythonTests/test_isinstance.py diff --git a/Tests/test_isinstance2.py b/PythonTests/test_isinstance2.py similarity index 100% rename from Tests/test_isinstance2.py rename to PythonTests/test_isinstance2.py diff --git a/Tests/test_iterator.py b/PythonTests/test_iterator.py similarity index 100% rename from Tests/test_iterator.py rename to PythonTests/test_iterator.py diff --git a/Tests/test_iteratorlength.py b/PythonTests/test_iteratorlength.py similarity index 100% rename from Tests/test_iteratorlength.py rename to PythonTests/test_iteratorlength.py diff --git a/Tests/test_itertools_stdlib.py b/PythonTests/test_itertools_stdlib.py similarity index 100% rename from Tests/test_itertools_stdlib.py rename to PythonTests/test_itertools_stdlib.py diff --git a/Tests/test_json.py b/PythonTests/test_json.py similarity index 100% rename from Tests/test_json.py rename to PythonTests/test_json.py diff --git a/Tests/test_kwarg.py b/PythonTests/test_kwarg.py similarity index 100% rename from Tests/test_kwarg.py rename to PythonTests/test_kwarg.py diff --git a/Tests/test_list.py b/PythonTests/test_list.py similarity index 100% rename from Tests/test_list.py rename to PythonTests/test_list.py diff --git a/Tests/test_listcomp.py b/PythonTests/test_listcomp.py similarity index 100% rename from Tests/test_listcomp.py rename to PythonTests/test_listcomp.py diff --git a/Tests/test_long_stdlib.py b/PythonTests/test_long_stdlib.py similarity index 100% rename from Tests/test_long_stdlib.py rename to PythonTests/test_long_stdlib.py diff --git a/Tests/test_memory.py b/PythonTests/test_memory.py similarity index 100% rename from Tests/test_memory.py rename to PythonTests/test_memory.py diff --git a/Tests/test_memoryio_stdlib.py b/PythonTests/test_memoryio_stdlib.py similarity index 100% rename from Tests/test_memoryio_stdlib.py rename to PythonTests/test_memoryio_stdlib.py diff --git a/Tests/test_memoryview.py b/PythonTests/test_memoryview.py similarity index 100% rename from Tests/test_memoryview.py rename to PythonTests/test_memoryview.py diff --git a/Tests/test_metaclass.py b/PythonTests/test_metaclass.py similarity index 100% rename from Tests/test_metaclass.py rename to PythonTests/test_metaclass.py diff --git a/Tests/test_methodbinder1.py b/PythonTests/test_methodbinder1.py similarity index 100% rename from Tests/test_methodbinder1.py rename to PythonTests/test_methodbinder1.py diff --git a/Tests/test_methodbinder2.py b/PythonTests/test_methodbinder2.py similarity index 100% rename from Tests/test_methodbinder2.py rename to PythonTests/test_methodbinder2.py diff --git a/Tests/test_methoddispatch.py b/PythonTests/test_methoddispatch.py similarity index 100% rename from Tests/test_methoddispatch.py rename to PythonTests/test_methoddispatch.py diff --git a/Tests/test_missing.py b/PythonTests/test_missing.py similarity index 100% rename from Tests/test_missing.py rename to PythonTests/test_missing.py diff --git a/Tests/test_namebinding.py b/PythonTests/test_namebinding.py similarity index 100% rename from Tests/test_namebinding.py rename to PythonTests/test_namebinding.py diff --git a/Tests/test_nonetype.py b/PythonTests/test_nonetype.py similarity index 100% rename from Tests/test_nonetype.py rename to PythonTests/test_nonetype.py diff --git a/Tests/test_nonlocal.py b/PythonTests/test_nonlocal.py similarity index 100% rename from Tests/test_nonlocal.py rename to PythonTests/test_nonlocal.py diff --git a/Tests/test_number.py b/PythonTests/test_number.py similarity index 100% rename from Tests/test_number.py rename to PythonTests/test_number.py diff --git a/Tests/test_numberhash.py b/PythonTests/test_numberhash.py similarity index 100% rename from Tests/test_numberhash.py rename to PythonTests/test_numberhash.py diff --git a/Tests/test_numtypes.py b/PythonTests/test_numtypes.py similarity index 100% rename from Tests/test_numtypes.py rename to PythonTests/test_numtypes.py diff --git a/Tests/test_pep380_stdlib.py b/PythonTests/test_pep380_stdlib.py similarity index 100% rename from Tests/test_pep380_stdlib.py rename to PythonTests/test_pep380_stdlib.py diff --git a/Tests/test_peverify.py b/PythonTests/test_peverify.py similarity index 100% rename from Tests/test_peverify.py rename to PythonTests/test_peverify.py diff --git a/Tests/test_pow.py b/PythonTests/test_pow.py similarity index 100% rename from Tests/test_pow.py rename to PythonTests/test_pow.py diff --git a/Tests/test_privateBinding.py b/PythonTests/test_privateBinding.py similarity index 100% rename from Tests/test_privateBinding.py rename to PythonTests/test_privateBinding.py diff --git a/Tests/test_property.py b/PythonTests/test_property.py similarity index 100% rename from Tests/test_property.py rename to PythonTests/test_property.py diff --git a/Tests/test_protected.py b/PythonTests/test_protected.py similarity index 100% rename from Tests/test_protected.py rename to PythonTests/test_protected.py diff --git a/Tests/test_pyexpat.py b/PythonTests/test_pyexpat.py similarity index 100% rename from Tests/test_pyexpat.py rename to PythonTests/test_pyexpat.py diff --git a/Tests/test_python25.py b/PythonTests/test_python25.py similarity index 100% rename from Tests/test_python25.py rename to PythonTests/test_python25.py diff --git a/Tests/test_python26.py b/PythonTests/test_python26.py similarity index 100% rename from Tests/test_python26.py rename to PythonTests/test_python26.py diff --git a/Tests/test_range.py b/PythonTests/test_range.py similarity index 100% rename from Tests/test_range.py rename to PythonTests/test_range.py diff --git a/Tests/test_re_stdlib.py b/PythonTests/test_re_stdlib.py similarity index 100% rename from Tests/test_re_stdlib.py rename to PythonTests/test_re_stdlib.py diff --git a/Tests/test_regressions.py b/PythonTests/test_regressions.py similarity index 100% rename from Tests/test_regressions.py rename to PythonTests/test_regressions.py diff --git a/Tests/test_regressions_compiled.py b/PythonTests/test_regressions_compiled.py similarity index 100% rename from Tests/test_regressions_compiled.py rename to PythonTests/test_regressions_compiled.py diff --git a/Tests/test_sax_stdlib.py b/PythonTests/test_sax_stdlib.py similarity index 100% rename from Tests/test_sax_stdlib.py rename to PythonTests/test_sax_stdlib.py diff --git a/Tests/test_scope_stdlib.py b/PythonTests/test_scope_stdlib.py similarity index 100% rename from Tests/test_scope_stdlib.py rename to PythonTests/test_scope_stdlib.py diff --git a/Tests/test_set.py b/PythonTests/test_set.py similarity index 100% rename from Tests/test_set.py rename to PythonTests/test_set.py diff --git a/Tests/test_setcomp.py b/PythonTests/test_setcomp.py similarity index 100% rename from Tests/test_setcomp.py rename to PythonTests/test_setcomp.py diff --git a/Tests/test_shutil.py b/PythonTests/test_shutil.py similarity index 100% rename from Tests/test_shutil.py rename to PythonTests/test_shutil.py diff --git a/Tests/test_slice.py b/PythonTests/test_slice.py similarity index 100% rename from Tests/test_slice.py rename to PythonTests/test_slice.py diff --git a/Tests/test_slots.py b/PythonTests/test_slots.py similarity index 100% rename from Tests/test_slots.py rename to PythonTests/test_slots.py diff --git a/Tests/test_socket_stdlib.py b/PythonTests/test_socket_stdlib.py similarity index 100% rename from Tests/test_socket_stdlib.py rename to PythonTests/test_socket_stdlib.py diff --git a/Tests/test_specialcontext.py b/PythonTests/test_specialcontext.py similarity index 100% rename from Tests/test_specialcontext.py rename to PythonTests/test_specialcontext.py diff --git a/Tests/test_sqlite3_stdlib.py b/PythonTests/test_sqlite3_stdlib.py similarity index 100% rename from Tests/test_sqlite3_stdlib.py rename to PythonTests/test_sqlite3_stdlib.py diff --git a/Tests/test_ssl_stdlib.py b/PythonTests/test_ssl_stdlib.py similarity index 100% rename from Tests/test_ssl_stdlib.py rename to PythonTests/test_ssl_stdlib.py diff --git a/Tests/test_statics.py b/PythonTests/test_statics.py similarity index 100% rename from Tests/test_statics.py rename to PythonTests/test_statics.py diff --git a/Tests/test_stdconsole.py b/PythonTests/test_stdconsole.py similarity index 100% rename from Tests/test_stdconsole.py rename to PythonTests/test_stdconsole.py diff --git a/Tests/test_stdmodules.py b/PythonTests/test_stdmodules.py similarity index 100% rename from Tests/test_stdmodules.py rename to PythonTests/test_stdmodules.py diff --git a/Tests/test_str.py b/PythonTests/test_str.py similarity index 100% rename from Tests/test_str.py rename to PythonTests/test_str.py diff --git a/Tests/test_str_bytes.py b/PythonTests/test_str_bytes.py similarity index 100% rename from Tests/test_str_bytes.py rename to PythonTests/test_str_bytes.py diff --git a/Tests/test_strformat.py b/PythonTests/test_strformat.py similarity index 100% rename from Tests/test_strformat.py rename to PythonTests/test_strformat.py diff --git a/Tests/test_struct.py b/PythonTests/test_struct.py similarity index 100% rename from Tests/test_struct.py rename to PythonTests/test_struct.py diff --git a/Tests/test_struct_stdlib.py b/PythonTests/test_struct_stdlib.py similarity index 100% rename from Tests/test_struct_stdlib.py rename to PythonTests/test_struct_stdlib.py diff --git a/Tests/test_struct_threadsafe.py b/PythonTests/test_struct_threadsafe.py similarity index 100% rename from Tests/test_struct_threadsafe.py rename to PythonTests/test_struct_threadsafe.py diff --git a/Tests/test_super.py b/PythonTests/test_super.py similarity index 100% rename from Tests/test_super.py rename to PythonTests/test_super.py diff --git a/Tests/test_superconsole.py b/PythonTests/test_superconsole.py similarity index 100% rename from Tests/test_superconsole.py rename to PythonTests/test_superconsole.py diff --git a/Tests/test_surrogateescape.py b/PythonTests/test_surrogateescape.py similarity index 100% rename from Tests/test_surrogateescape.py rename to PythonTests/test_surrogateescape.py diff --git a/Tests/test_surrogateescape_pythonfuture.py b/PythonTests/test_surrogateescape_pythonfuture.py similarity index 100% rename from Tests/test_surrogateescape_pythonfuture.py rename to PythonTests/test_surrogateescape_pythonfuture.py diff --git a/Tests/test_surrogatepass.py b/PythonTests/test_surrogatepass.py similarity index 100% rename from Tests/test_surrogatepass.py rename to PythonTests/test_surrogatepass.py diff --git a/Tests/test_syntax.py b/PythonTests/test_syntax.py similarity index 100% rename from Tests/test_syntax.py rename to PythonTests/test_syntax.py diff --git a/Tests/test_sys_stdlib.py b/PythonTests/test_sys_stdlib.py similarity index 100% rename from Tests/test_sys_stdlib.py rename to PythonTests/test_sys_stdlib.py diff --git a/Tests/test_system_timers.py b/PythonTests/test_system_timers.py similarity index 100% rename from Tests/test_system_timers.py rename to PythonTests/test_system_timers.py diff --git a/Tests/test_tcf.py b/PythonTests/test_tcf.py similarity index 100% rename from Tests/test_tcf.py rename to PythonTests/test_tcf.py diff --git a/Tests/test_threadsafety.py b/PythonTests/test_threadsafety.py similarity index 100% rename from Tests/test_threadsafety.py rename to PythonTests/test_threadsafety.py diff --git a/Tests/test_time_stdlib.py b/PythonTests/test_time_stdlib.py similarity index 100% rename from Tests/test_time_stdlib.py rename to PythonTests/test_time_stdlib.py diff --git a/Tests/test_traceback.py b/PythonTests/test_traceback.py similarity index 100% rename from Tests/test_traceback.py rename to PythonTests/test_traceback.py diff --git a/Tests/test_tuple.py b/PythonTests/test_tuple.py similarity index 100% rename from Tests/test_tuple.py rename to PythonTests/test_tuple.py diff --git a/Tests/test_types_stdlib.py b/PythonTests/test_types_stdlib.py similarity index 100% rename from Tests/test_types_stdlib.py rename to PythonTests/test_types_stdlib.py diff --git a/Tests/test_typing_stdlib.py b/PythonTests/test_typing_stdlib.py similarity index 100% rename from Tests/test_typing_stdlib.py rename to PythonTests/test_typing_stdlib.py diff --git a/Tests/test_unicode.py b/PythonTests/test_unicode.py similarity index 100% rename from Tests/test_unicode.py rename to PythonTests/test_unicode.py diff --git a/Tests/test_unicode_stdlib.py b/PythonTests/test_unicode_stdlib.py similarity index 100% rename from Tests/test_unicode_stdlib.py rename to PythonTests/test_unicode_stdlib.py diff --git a/Tests/test_unpack.py b/PythonTests/test_unpack.py similarity index 100% rename from Tests/test_unpack.py rename to PythonTests/test_unpack.py diff --git a/Tests/test_utf8_mode_stdlib.py b/PythonTests/test_utf8_mode_stdlib.py similarity index 100% rename from Tests/test_utf8_mode_stdlib.py rename to PythonTests/test_utf8_mode_stdlib.py diff --git a/Tests/test_weakref.py b/PythonTests/test_weakref.py similarity index 100% rename from Tests/test_weakref.py rename to PythonTests/test_weakref.py diff --git a/Tests/test_weakset_stdlib.py b/PythonTests/test_weakset_stdlib.py similarity index 100% rename from Tests/test_weakset_stdlib.py rename to PythonTests/test_weakset_stdlib.py diff --git a/Tests/test_winforms.py b/PythonTests/test_winforms.py similarity index 100% rename from Tests/test_winforms.py rename to PythonTests/test_winforms.py diff --git a/Tests/test_with.py b/PythonTests/test_with.py similarity index 100% rename from Tests/test_with.py rename to PythonTests/test_with.py diff --git a/Tests/test_zipimport.py b/PythonTests/test_zipimport.py similarity index 100% rename from Tests/test_zipimport.py rename to PythonTests/test_zipimport.py diff --git a/Tests/testpkg1/__init__.py b/PythonTests/testpkg1/__init__.py similarity index 100% rename from Tests/testpkg1/__init__.py rename to PythonTests/testpkg1/__init__.py diff --git a/Tests/testpkg1/mod1.py b/PythonTests/testpkg1/mod1.py similarity index 100% rename from Tests/testpkg1/mod1.py rename to PythonTests/testpkg1/mod1.py diff --git a/Tests/timeit.py b/PythonTests/timeit.py similarity index 100% rename from Tests/timeit.py rename to PythonTests/timeit.py diff --git a/Tests/toimport.py b/PythonTests/toimport.py similarity index 100% rename from Tests/toimport.py rename to PythonTests/toimport.py diff --git a/Tests/transform.py b/PythonTests/transform.py similarity index 100% rename from Tests/transform.py rename to PythonTests/transform.py diff --git a/Src/ctypes_test/Makefile b/Src/CTypes/Makefile similarity index 100% rename from Src/ctypes_test/Makefile rename to Src/CTypes/Makefile diff --git a/Src/ctypes_test/_ctypes_test.c b/Src/CTypes/_ctypes_test.c similarity index 100% rename from Src/ctypes_test/_ctypes_test.c rename to Src/CTypes/_ctypes_test.c diff --git a/Src/ctypes_test/_ctypes_test.sln b/Src/CTypes/_ctypes_test.sln similarity index 100% rename from Src/ctypes_test/_ctypes_test.sln rename to Src/CTypes/_ctypes_test.sln diff --git a/Src/ctypes_test/_ctypes_test.vcxproj b/Src/CTypes/_ctypes_test.vcxproj similarity index 100% rename from Src/ctypes_test/_ctypes_test.vcxproj rename to Src/CTypes/_ctypes_test.vcxproj diff --git a/Src/IronPythonCompiler/AssemblyResolver.cs b/Src/CompilerServices/AssemblyResolver.cs similarity index 100% rename from Src/IronPythonCompiler/AssemblyResolver.cs rename to Src/CompilerServices/AssemblyResolver.cs diff --git a/Src/IronPythonCompiler/Config.cs b/Src/CompilerServices/Config.cs similarity index 100% rename from Src/IronPythonCompiler/Config.cs rename to Src/CompilerServices/Config.cs diff --git a/Src/IronPythonCompiler/ConsoleOps.cs b/Src/CompilerServices/ConsoleOps.cs similarity index 100% rename from Src/IronPythonCompiler/ConsoleOps.cs rename to Src/CompilerServices/ConsoleOps.cs diff --git a/Src/IronPythonCompiler/IronPython.CompilerServices.csproj b/Src/CompilerServices/IronPython.CompilerServices.csproj similarity index 100% rename from Src/IronPythonCompiler/IronPython.CompilerServices.csproj rename to Src/CompilerServices/IronPython.CompilerServices.csproj diff --git a/Src/IronPythonCompiler/Program.cs b/Src/CompilerServices/Program.cs similarity index 100% rename from Src/IronPythonCompiler/Program.cs rename to Src/CompilerServices/Program.cs diff --git a/Src/IronPythonCompiler/Properties/AssemblyInfo.cs b/Src/CompilerServices/Properties/AssemblyInfo.cs similarity index 100% rename from Src/IronPythonCompiler/Properties/AssemblyInfo.cs rename to Src/CompilerServices/Properties/AssemblyInfo.cs diff --git a/Src/IronPythonCompiler/README.md b/Src/CompilerServices/README.md similarity index 100% rename from Src/IronPythonCompiler/README.md rename to Src/CompilerServices/README.md diff --git a/Src/IronPythonWindow/IronPython.Console.Host.csproj b/Src/Console.Host/IronPython.Console.Host.csproj similarity index 100% rename from Src/IronPythonWindow/IronPython.Console.Host.csproj rename to Src/Console.Host/IronPython.Console.Host.csproj diff --git a/Src/IronPythonWindow/IronPythonWindow.cs b/Src/Console.Host/IronPythonWindow.cs similarity index 100% rename from Src/IronPythonWindow/IronPythonWindow.cs rename to Src/Console.Host/IronPythonWindow.cs diff --git a/Src/IronPythonWindow/Properties/AssemblyInfo.cs b/Src/Console.Host/Properties/AssemblyInfo.cs similarity index 100% rename from Src/IronPythonWindow/Properties/AssemblyInfo.cs rename to Src/Console.Host/Properties/AssemblyInfo.cs diff --git a/Src/IronPythonWindow/ipyw.ico b/Src/Console.Host/ipyw.ico similarity index 100% rename from Src/IronPythonWindow/ipyw.ico rename to Src/Console.Host/ipyw.ico diff --git a/Src/IronPythonConsole/Console.cs b/Src/Console/Console.cs similarity index 100% rename from Src/IronPythonConsole/Console.cs rename to Src/Console/Console.cs diff --git a/Src/IronPythonConsole/IronPython.Console.csproj b/Src/Console/IronPython.Console.csproj similarity index 90% rename from Src/IronPythonConsole/IronPython.Console.csproj rename to Src/Console/IronPython.Console.csproj index a933ddd3f..1c8057427 100644 --- a/Src/IronPythonConsole/IronPython.Console.csproj +++ b/Src/Console/IronPython.Console.csproj @@ -15,13 +15,13 @@ - + false Content PreserveNewest - + false Content PreserveNewest diff --git a/Src/IronPythonConsole/Properties/AssemblyInfo.cs b/Src/Console/Properties/AssemblyInfo.cs similarity index 100% rename from Src/IronPythonConsole/Properties/AssemblyInfo.cs rename to Src/Console/Properties/AssemblyInfo.cs diff --git a/Src/IronPythonConsole/app.manifest b/Src/Console/app.manifest similarity index 100% rename from Src/IronPythonConsole/app.manifest rename to Src/Console/app.manifest diff --git a/Src/IronPythonConsole/ipy-mono.sh b/Src/Console/ipy-mono.sh old mode 100755 new mode 100644 similarity index 100% rename from Src/IronPythonConsole/ipy-mono.sh rename to Src/Console/ipy-mono.sh diff --git a/Src/IronPythonConsole/ipy.ico b/Src/Console/ipy.ico similarity index 100% rename from Src/IronPythonConsole/ipy.ico rename to Src/Console/ipy.ico diff --git a/Src/IronPythonConsole/ipy.sh b/Src/Console/ipy.sh old mode 100755 new mode 100644 similarity index 100% rename from Src/IronPythonConsole/ipy.sh rename to Src/Console/ipy.sh diff --git a/Src/IronPythonConsole/runtimeconfig.template.json b/Src/Console/runtimeconfig.template.json similarity index 100% rename from Src/IronPythonConsole/runtimeconfig.template.json rename to Src/Console/runtimeconfig.template.json diff --git a/Src/IronPythonWindow32/IronPython.Console32.Host.csproj b/Src/Console32.Host/IronPython.Console32.Host.csproj similarity index 100% rename from Src/IronPythonWindow32/IronPython.Console32.Host.csproj rename to Src/Console32.Host/IronPython.Console32.Host.csproj diff --git a/Src/IronPythonConsole32/IronPython.Console32.csproj b/Src/Console32/IronPython.Console32.csproj similarity index 68% rename from Src/IronPythonConsole32/IronPython.Console32.csproj rename to Src/Console32/IronPython.Console32.csproj index ec88a8b4c..1dda10bf9 100644 --- a/Src/IronPythonConsole32/IronPython.Console32.csproj +++ b/Src/Console32/IronPython.Console32.csproj @@ -6,20 +6,20 @@ Exe IronPythonConsole ipy32 - ..\IronPythonConsole\ipy.ico + ..\Console\ipy.ico true - + false - - + + diff --git a/Src/IronPython/IronPython.csproj b/Src/IronPython/IronPython.csproj index e60b47251..4af3f1695 100644 --- a/Src/IronPython/IronPython.csproj +++ b/Src/IronPython/IronPython.csproj @@ -23,7 +23,7 @@ True - ..\..\Util\References\Mono.Posix.dll + ..\..\Utils\References\Mono.Posix.dll diff --git a/Src/IronPython.Modules/IronPython.Modules.csproj b/Src/Modules/IronPython.Modules.csproj similarity index 95% rename from Src/IronPython.Modules/IronPython.Modules.csproj rename to Src/Modules/IronPython.Modules.csproj index 7d90d5ffb..0f54dd0d0 100644 --- a/Src/IronPython.Modules/IronPython.Modules.csproj +++ b/Src/Modules/IronPython.Modules.csproj @@ -10,7 +10,7 @@ True - ..\..\Util\References\Mono.Posix.dll + ..\..\Utils\References\Mono.Posix.dll diff --git a/Src/IronPython.Modules/IterTools.cs b/Src/Modules/IterTools.cs similarity index 100% rename from Src/IronPython.Modules/IterTools.cs rename to Src/Modules/IterTools.cs diff --git a/Src/IronPython.Modules/ModuleOps.cs b/Src/Modules/ModuleOps.cs similarity index 100% rename from Src/IronPython.Modules/ModuleOps.cs rename to Src/Modules/ModuleOps.cs diff --git a/Src/IronPython.Modules/NtSignalState.cs b/Src/Modules/NtSignalState.cs similarity index 100% rename from Src/IronPython.Modules/NtSignalState.cs rename to Src/Modules/NtSignalState.cs diff --git a/Src/IronPython.Modules/Properties/AssemblyInfo.cs b/Src/Modules/Properties/AssemblyInfo.cs similarity index 100% rename from Src/IronPython.Modules/Properties/AssemblyInfo.cs rename to Src/Modules/Properties/AssemblyInfo.cs diff --git a/Src/IronPython.Modules/ResourceMetaPathImporter.cs b/Src/Modules/ResourceMetaPathImporter.cs similarity index 100% rename from Src/IronPython.Modules/ResourceMetaPathImporter.cs rename to Src/Modules/ResourceMetaPathImporter.cs diff --git a/Src/IronPython.Modules/SimpleSignalState.cs b/Src/Modules/SimpleSignalState.cs similarity index 100% rename from Src/IronPython.Modules/SimpleSignalState.cs rename to Src/Modules/SimpleSignalState.cs diff --git a/Src/IronPython.Modules/_bisect.cs b/Src/Modules/_bisect.cs similarity index 100% rename from Src/IronPython.Modules/_bisect.cs rename to Src/Modules/_bisect.cs diff --git a/Src/IronPython.Modules/_codecs.cs b/Src/Modules/_codecs.cs similarity index 100% rename from Src/IronPython.Modules/_codecs.cs rename to Src/Modules/_codecs.cs diff --git a/Src/IronPython.Modules/_codecs_cn.cs b/Src/Modules/_codecs_cn.cs similarity index 100% rename from Src/IronPython.Modules/_codecs_cn.cs rename to Src/Modules/_codecs_cn.cs diff --git a/Src/IronPython.Modules/_collections.cs b/Src/Modules/_collections.cs similarity index 100% rename from Src/IronPython.Modules/_collections.cs rename to Src/Modules/_collections.cs diff --git a/Src/IronPython.Modules/_csv.cs b/Src/Modules/_csv.cs similarity index 100% rename from Src/IronPython.Modules/_csv.cs rename to Src/Modules/_csv.cs diff --git a/Src/IronPython.Modules/_ctypes/Array.cs b/Src/Modules/_ctypes/Array.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/Array.cs rename to Src/Modules/_ctypes/Array.cs diff --git a/Src/IronPython.Modules/_ctypes/ArrayType.cs b/Src/Modules/_ctypes/ArrayType.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/ArrayType.cs rename to Src/Modules/_ctypes/ArrayType.cs diff --git a/Src/IronPython.Modules/_ctypes/CData.cs b/Src/Modules/_ctypes/CData.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/CData.cs rename to Src/Modules/_ctypes/CData.cs diff --git a/Src/IronPython.Modules/_ctypes/CFuncPtr.cs b/Src/Modules/_ctypes/CFuncPtr.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/CFuncPtr.cs rename to Src/Modules/_ctypes/CFuncPtr.cs diff --git a/Src/IronPython.Modules/_ctypes/CFuncPtrType.cs b/Src/Modules/_ctypes/CFuncPtrType.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/CFuncPtrType.cs rename to Src/Modules/_ctypes/CFuncPtrType.cs diff --git a/Src/IronPython.Modules/_ctypes/Extensions.cs b/Src/Modules/_ctypes/Extensions.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/Extensions.cs rename to Src/Modules/_ctypes/Extensions.cs diff --git a/Src/IronPython.Modules/_ctypes/Field.cs b/Src/Modules/_ctypes/Field.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/Field.cs rename to Src/Modules/_ctypes/Field.cs diff --git a/Src/IronPython.Modules/_ctypes/INativeType.cs b/Src/Modules/_ctypes/INativeType.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/INativeType.cs rename to Src/Modules/_ctypes/INativeType.cs diff --git a/Src/IronPython.Modules/_ctypes/LocalOrArg.cs b/Src/Modules/_ctypes/LocalOrArg.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/LocalOrArg.cs rename to Src/Modules/_ctypes/LocalOrArg.cs diff --git a/Src/IronPython.Modules/_ctypes/MarshalCleanup.cs b/Src/Modules/_ctypes/MarshalCleanup.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/MarshalCleanup.cs rename to Src/Modules/_ctypes/MarshalCleanup.cs diff --git a/Src/IronPython.Modules/_ctypes/MemoryHolder.cs b/Src/Modules/_ctypes/MemoryHolder.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/MemoryHolder.cs rename to Src/Modules/_ctypes/MemoryHolder.cs diff --git a/Src/IronPython.Modules/_ctypes/NativeArgument.cs b/Src/Modules/_ctypes/NativeArgument.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/NativeArgument.cs rename to Src/Modules/_ctypes/NativeArgument.cs diff --git a/Src/IronPython.Modules/_ctypes/NativeFunctions.cs b/Src/Modules/_ctypes/NativeFunctions.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/NativeFunctions.cs rename to Src/Modules/_ctypes/NativeFunctions.cs diff --git a/Src/IronPython.Modules/_ctypes/Pointer.cs b/Src/Modules/_ctypes/Pointer.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/Pointer.cs rename to Src/Modules/_ctypes/Pointer.cs diff --git a/Src/IronPython.Modules/_ctypes/PointerType.cs b/Src/Modules/_ctypes/PointerType.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/PointerType.cs rename to Src/Modules/_ctypes/PointerType.cs diff --git a/Src/IronPython.Modules/_ctypes/SimpleCData.cs b/Src/Modules/_ctypes/SimpleCData.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/SimpleCData.cs rename to Src/Modules/_ctypes/SimpleCData.cs diff --git a/Src/IronPython.Modules/_ctypes/SimpleType.cs b/Src/Modules/_ctypes/SimpleType.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/SimpleType.cs rename to Src/Modules/_ctypes/SimpleType.cs diff --git a/Src/IronPython.Modules/_ctypes/SimpleTypeKind.cs b/Src/Modules/_ctypes/SimpleTypeKind.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/SimpleTypeKind.cs rename to Src/Modules/_ctypes/SimpleTypeKind.cs diff --git a/Src/IronPython.Modules/_ctypes/StructType.cs b/Src/Modules/_ctypes/StructType.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/StructType.cs rename to Src/Modules/_ctypes/StructType.cs diff --git a/Src/IronPython.Modules/_ctypes/Structure.cs b/Src/Modules/_ctypes/Structure.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/Structure.cs rename to Src/Modules/_ctypes/Structure.cs diff --git a/Src/IronPython.Modules/_ctypes/Union.cs b/Src/Modules/_ctypes/Union.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/Union.cs rename to Src/Modules/_ctypes/Union.cs diff --git a/Src/IronPython.Modules/_ctypes/UnionType.cs b/Src/Modules/_ctypes/UnionType.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/UnionType.cs rename to Src/Modules/_ctypes/UnionType.cs diff --git a/Src/IronPython.Modules/_ctypes/_ctypes.cs b/Src/Modules/_ctypes/_ctypes.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes/_ctypes.cs rename to Src/Modules/_ctypes/_ctypes.cs diff --git a/Src/IronPython.Modules/_ctypes_test.cs b/Src/Modules/_ctypes_test.cs similarity index 100% rename from Src/IronPython.Modules/_ctypes_test.cs rename to Src/Modules/_ctypes_test.cs diff --git a/Src/IronPython.Modules/_datetime.cs b/Src/Modules/_datetime.cs similarity index 100% rename from Src/IronPython.Modules/_datetime.cs rename to Src/Modules/_datetime.cs diff --git a/Src/IronPython.Modules/_functools.cs b/Src/Modules/_functools.cs similarity index 100% rename from Src/IronPython.Modules/_functools.cs rename to Src/Modules/_functools.cs diff --git a/Src/IronPython.Modules/_heapq.cs b/Src/Modules/_heapq.cs similarity index 100% rename from Src/IronPython.Modules/_heapq.cs rename to Src/Modules/_heapq.cs diff --git a/Src/IronPython.Modules/_multibytecodec.cs b/Src/Modules/_multibytecodec.cs similarity index 100% rename from Src/IronPython.Modules/_multibytecodec.cs rename to Src/Modules/_multibytecodec.cs diff --git a/Src/IronPython.Modules/_multiprocessing.cs b/Src/Modules/_multiprocessing.cs similarity index 100% rename from Src/IronPython.Modules/_multiprocessing.cs rename to Src/Modules/_multiprocessing.cs diff --git a/Src/IronPython.Modules/_opcode.cs b/Src/Modules/_opcode.cs similarity index 100% rename from Src/IronPython.Modules/_opcode.cs rename to Src/Modules/_opcode.cs diff --git a/Src/IronPython.Modules/_operator.cs b/Src/Modules/_operator.cs similarity index 100% rename from Src/IronPython.Modules/_operator.cs rename to Src/Modules/_operator.cs diff --git a/Src/IronPython.Modules/_overlapped.cs b/Src/Modules/_overlapped.cs similarity index 100% rename from Src/IronPython.Modules/_overlapped.cs rename to Src/Modules/_overlapped.cs diff --git a/Src/IronPython.Modules/_pickle.cs b/Src/Modules/_pickle.cs similarity index 100% rename from Src/IronPython.Modules/_pickle.cs rename to Src/Modules/_pickle.cs diff --git a/Src/IronPython.Modules/_posixsubprocess.cs b/Src/Modules/_posixsubprocess.cs similarity index 100% rename from Src/IronPython.Modules/_posixsubprocess.cs rename to Src/Modules/_posixsubprocess.cs diff --git a/Src/IronPython.Modules/_random.RandomGen.cs b/Src/Modules/_random.RandomGen.cs similarity index 100% rename from Src/IronPython.Modules/_random.RandomGen.cs rename to Src/Modules/_random.RandomGen.cs diff --git a/Src/IronPython.Modules/_random.cs b/Src/Modules/_random.cs similarity index 100% rename from Src/IronPython.Modules/_random.cs rename to Src/Modules/_random.cs diff --git a/Src/IronPython.Modules/_socket.cs b/Src/Modules/_socket.cs similarity index 100% rename from Src/IronPython.Modules/_socket.cs rename to Src/Modules/_socket.cs diff --git a/Src/IronPython.Modules/_sre.cs b/Src/Modules/_sre.cs similarity index 100% rename from Src/IronPython.Modules/_sre.cs rename to Src/Modules/_sre.cs diff --git a/Src/IronPython.Modules/_ssl.cs b/Src/Modules/_ssl.cs similarity index 100% rename from Src/IronPython.Modules/_ssl.cs rename to Src/Modules/_ssl.cs diff --git a/Src/IronPython.Modules/_string.cs b/Src/Modules/_string.cs similarity index 100% rename from Src/IronPython.Modules/_string.cs rename to Src/Modules/_string.cs diff --git a/Src/IronPython.Modules/_struct.cs b/Src/Modules/_struct.cs similarity index 100% rename from Src/IronPython.Modules/_struct.cs rename to Src/Modules/_struct.cs diff --git a/Src/IronPython.Modules/_sysconfigdata.cs b/Src/Modules/_sysconfigdata.cs similarity index 100% rename from Src/IronPython.Modules/_sysconfigdata.cs rename to Src/Modules/_sysconfigdata.cs diff --git a/Src/IronPython.Modules/_thread.cs b/Src/Modules/_thread.cs similarity index 100% rename from Src/IronPython.Modules/_thread.cs rename to Src/Modules/_thread.cs diff --git a/Src/IronPython.Modules/_warnings.cs b/Src/Modules/_warnings.cs similarity index 100% rename from Src/IronPython.Modules/_warnings.cs rename to Src/Modules/_warnings.cs diff --git a/Src/IronPython.Modules/_weakref.Generated.cs b/Src/Modules/_weakref.Generated.cs similarity index 100% rename from Src/IronPython.Modules/_weakref.Generated.cs rename to Src/Modules/_weakref.Generated.cs diff --git a/Src/IronPython.Modules/_weakref.cs b/Src/Modules/_weakref.cs similarity index 100% rename from Src/IronPython.Modules/_weakref.cs rename to Src/Modules/_weakref.cs diff --git a/Src/IronPython.Modules/_winapi.cs b/Src/Modules/_winapi.cs similarity index 100% rename from Src/IronPython.Modules/_winapi.cs rename to Src/Modules/_winapi.cs diff --git a/Src/IronPython.Modules/array.cs b/Src/Modules/array.cs similarity index 100% rename from Src/IronPython.Modules/array.cs rename to Src/Modules/array.cs diff --git a/Src/IronPython.Modules/atexit.cs b/Src/Modules/atexit.cs similarity index 100% rename from Src/IronPython.Modules/atexit.cs rename to Src/Modules/atexit.cs diff --git a/Src/IronPython.Modules/audioop.cs b/Src/Modules/audioop.cs similarity index 100% rename from Src/IronPython.Modules/audioop.cs rename to Src/Modules/audioop.cs diff --git a/Src/IronPython.Modules/binascii.cs b/Src/Modules/binascii.cs similarity index 100% rename from Src/IronPython.Modules/binascii.cs rename to Src/Modules/binascii.cs diff --git a/Src/IronPython.Modules/bz2/BZ2Compressor.cs b/Src/Modules/bz2/BZ2Compressor.cs similarity index 100% rename from Src/IronPython.Modules/bz2/BZ2Compressor.cs rename to Src/Modules/bz2/BZ2Compressor.cs diff --git a/Src/IronPython.Modules/bz2/BZ2Decompressor.cs b/Src/Modules/bz2/BZ2Decompressor.cs similarity index 100% rename from Src/IronPython.Modules/bz2/BZ2Decompressor.cs rename to Src/Modules/bz2/BZ2Decompressor.cs diff --git a/Src/IronPython.Modules/bz2/BZ2Module.cs b/Src/Modules/bz2/BZ2Module.cs similarity index 100% rename from Src/IronPython.Modules/bz2/BZ2Module.cs rename to Src/Modules/bz2/BZ2Module.cs diff --git a/Src/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs b/Src/Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs similarity index 100% rename from Src/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs rename to Src/Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs diff --git a/Src/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs b/Src/Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs similarity index 100% rename from Src/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs rename to Src/Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs diff --git a/Src/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs b/Src/Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs similarity index 100% rename from Src/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs rename to Src/Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs diff --git a/Src/IronPython.Modules/bz2/dotnetzip/BZip2/BitWriter.cs b/Src/Modules/bz2/dotnetzip/BZip2/BitWriter.cs similarity index 100% rename from Src/IronPython.Modules/bz2/dotnetzip/BZip2/BitWriter.cs rename to Src/Modules/bz2/dotnetzip/BZip2/BitWriter.cs diff --git a/Src/IronPython.Modules/bz2/dotnetzip/BZip2/CRC32.cs b/Src/Modules/bz2/dotnetzip/BZip2/CRC32.cs similarity index 100% rename from Src/IronPython.Modules/bz2/dotnetzip/BZip2/CRC32.cs rename to Src/Modules/bz2/dotnetzip/BZip2/CRC32.cs diff --git a/Src/IronPython.Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs b/Src/Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs similarity index 100% rename from Src/IronPython.Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs rename to Src/Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs diff --git a/Src/IronPython.Modules/bz2/dotnetzip/BZip2/Rand.cs b/Src/Modules/bz2/dotnetzip/BZip2/Rand.cs similarity index 100% rename from Src/IronPython.Modules/bz2/dotnetzip/BZip2/Rand.cs rename to Src/Modules/bz2/dotnetzip/BZip2/Rand.cs diff --git a/Src/IronPython.Modules/bz2/dotnetzip/source.txt b/Src/Modules/bz2/dotnetzip/source.txt similarity index 100% rename from Src/IronPython.Modules/bz2/dotnetzip/source.txt rename to Src/Modules/bz2/dotnetzip/source.txt diff --git a/Src/IronPython.Modules/cmath.cs b/Src/Modules/cmath.cs similarity index 100% rename from Src/IronPython.Modules/cmath.cs rename to Src/Modules/cmath.cs diff --git a/Src/IronPython.Modules/errno.cs b/Src/Modules/errno.cs similarity index 100% rename from Src/IronPython.Modules/errno.cs rename to Src/Modules/errno.cs diff --git a/Src/IronPython.Modules/faulthandler.cs b/Src/Modules/faulthandler.cs similarity index 100% rename from Src/IronPython.Modules/faulthandler.cs rename to Src/Modules/faulthandler.cs diff --git a/Src/IronPython.Modules/fcntl.cs b/Src/Modules/fcntl.cs similarity index 100% rename from Src/IronPython.Modules/fcntl.cs rename to Src/Modules/fcntl.cs diff --git a/Src/IronPython.Modules/gc.cs b/Src/Modules/gc.cs similarity index 100% rename from Src/IronPython.Modules/gc.cs rename to Src/Modules/gc.cs diff --git a/Src/IronPython.Modules/grp.cs b/Src/Modules/grp.cs similarity index 100% rename from Src/IronPython.Modules/grp.cs rename to Src/Modules/grp.cs diff --git a/Src/IronPython.Modules/hashlib/MD5CryptoServiceProvider.cs b/Src/Modules/hashlib/MD5CryptoServiceProvider.cs similarity index 100% rename from Src/IronPython.Modules/hashlib/MD5CryptoServiceProvider.cs rename to Src/Modules/hashlib/MD5CryptoServiceProvider.cs diff --git a/Src/IronPython.Modules/hashlib/SHA1CryptoServiceProvider.cs b/Src/Modules/hashlib/SHA1CryptoServiceProvider.cs similarity index 100% rename from Src/IronPython.Modules/hashlib/SHA1CryptoServiceProvider.cs rename to Src/Modules/hashlib/SHA1CryptoServiceProvider.cs diff --git a/Src/IronPython.Modules/hashlib/SHA224.cs b/Src/Modules/hashlib/SHA224.cs similarity index 100% rename from Src/IronPython.Modules/hashlib/SHA224.cs rename to Src/Modules/hashlib/SHA224.cs diff --git a/Src/IronPython.Modules/hashlib/SHA224Managed.cs b/Src/Modules/hashlib/SHA224Managed.cs similarity index 100% rename from Src/IronPython.Modules/hashlib/SHA224Managed.cs rename to Src/Modules/hashlib/SHA224Managed.cs diff --git a/Src/IronPython.Modules/hashlib/SHA256Managed.cs b/Src/Modules/hashlib/SHA256Managed.cs similarity index 100% rename from Src/IronPython.Modules/hashlib/SHA256Managed.cs rename to Src/Modules/hashlib/SHA256Managed.cs diff --git a/Src/IronPython.Modules/hashlib/SHA384Managed.cs b/Src/Modules/hashlib/SHA384Managed.cs similarity index 100% rename from Src/IronPython.Modules/hashlib/SHA384Managed.cs rename to Src/Modules/hashlib/SHA384Managed.cs diff --git a/Src/IronPython.Modules/hashlib/SHA512Managed.cs b/Src/Modules/hashlib/SHA512Managed.cs similarity index 100% rename from Src/IronPython.Modules/hashlib/SHA512Managed.cs rename to Src/Modules/hashlib/SHA512Managed.cs diff --git a/Src/IronPython.Modules/hashlib/SHAConstants.cs b/Src/Modules/hashlib/SHAConstants.cs similarity index 100% rename from Src/IronPython.Modules/hashlib/SHAConstants.cs rename to Src/Modules/hashlib/SHAConstants.cs diff --git a/Src/IronPython.Modules/hashlib/_hashlib.cs b/Src/Modules/hashlib/_hashlib.cs similarity index 100% rename from Src/IronPython.Modules/hashlib/_hashlib.cs rename to Src/Modules/hashlib/_hashlib.cs diff --git a/Src/IronPython.Modules/hashlib/_md5.cs b/Src/Modules/hashlib/_md5.cs similarity index 100% rename from Src/IronPython.Modules/hashlib/_md5.cs rename to Src/Modules/hashlib/_md5.cs diff --git a/Src/IronPython.Modules/hashlib/_sha1.cs b/Src/Modules/hashlib/_sha1.cs similarity index 100% rename from Src/IronPython.Modules/hashlib/_sha1.cs rename to Src/Modules/hashlib/_sha1.cs diff --git a/Src/IronPython.Modules/hashlib/_sha256.cs b/Src/Modules/hashlib/_sha256.cs similarity index 100% rename from Src/IronPython.Modules/hashlib/_sha256.cs rename to Src/Modules/hashlib/_sha256.cs diff --git a/Src/IronPython.Modules/hashlib/_sha512.cs b/Src/Modules/hashlib/_sha512.cs similarity index 100% rename from Src/IronPython.Modules/hashlib/_sha512.cs rename to Src/Modules/hashlib/_sha512.cs diff --git a/Src/IronPython.Modules/marshal.cs b/Src/Modules/marshal.cs similarity index 100% rename from Src/IronPython.Modules/marshal.cs rename to Src/Modules/marshal.cs diff --git a/Src/IronPython.Modules/math.Generated.cs b/Src/Modules/math.Generated.cs similarity index 100% rename from Src/IronPython.Modules/math.Generated.cs rename to Src/Modules/math.Generated.cs diff --git a/Src/IronPython.Modules/math.cs b/Src/Modules/math.cs similarity index 100% rename from Src/IronPython.Modules/math.cs rename to Src/Modules/math.cs diff --git a/Src/IronPython.Modules/mmap.cs b/Src/Modules/mmap.cs similarity index 100% rename from Src/IronPython.Modules/mmap.cs rename to Src/Modules/mmap.cs diff --git a/Src/IronPython.Modules/msvcrt.cs b/Src/Modules/msvcrt.cs similarity index 100% rename from Src/IronPython.Modules/msvcrt.cs rename to Src/Modules/msvcrt.cs diff --git a/Src/IronPython.Modules/nt.cs b/Src/Modules/nt.cs similarity index 100% rename from Src/IronPython.Modules/nt.cs rename to Src/Modules/nt.cs diff --git a/Src/IronPython.Modules/policy.IronPython.Modules.config b/Src/Modules/policy.IronPython.Modules.config similarity index 100% rename from Src/IronPython.Modules/policy.IronPython.Modules.config rename to Src/Modules/policy.IronPython.Modules.config diff --git a/Src/IronPython.Modules/pwd.cs b/Src/Modules/pwd.cs similarity index 100% rename from Src/IronPython.Modules/pwd.cs rename to Src/Modules/pwd.cs diff --git a/Src/IronPython.Modules/pyexpat.cs b/Src/Modules/pyexpat.cs similarity index 100% rename from Src/IronPython.Modules/pyexpat.cs rename to Src/Modules/pyexpat.cs diff --git a/Src/IronPython.Modules/re.cs b/Src/Modules/re.cs similarity index 100% rename from Src/IronPython.Modules/re.cs rename to Src/Modules/re.cs diff --git a/Src/IronPython.Modules/resource.cs b/Src/Modules/resource.cs similarity index 100% rename from Src/IronPython.Modules/resource.cs rename to Src/Modules/resource.cs diff --git a/Src/IronPython.Modules/select.cs b/Src/Modules/select.cs similarity index 100% rename from Src/IronPython.Modules/select.cs rename to Src/Modules/select.cs diff --git a/Src/IronPython.Modules/signal.cs b/Src/Modules/signal.cs similarity index 100% rename from Src/IronPython.Modules/signal.cs rename to Src/Modules/signal.cs diff --git a/Src/IronPython.Modules/spwd.cs b/Src/Modules/spwd.cs similarity index 100% rename from Src/IronPython.Modules/spwd.cs rename to Src/Modules/spwd.cs diff --git a/Src/IronPython.Modules/time.cs b/Src/Modules/time.cs similarity index 100% rename from Src/IronPython.Modules/time.cs rename to Src/Modules/time.cs diff --git a/Src/IronPython.Modules/winreg.cs b/Src/Modules/winreg.cs similarity index 100% rename from Src/IronPython.Modules/winreg.cs rename to Src/Modules/winreg.cs diff --git a/Src/IronPython.Modules/winsound.cs b/Src/Modules/winsound.cs similarity index 100% rename from Src/IronPython.Modules/winsound.cs rename to Src/Modules/winsound.cs diff --git a/Src/IronPython.Modules/xxsubtype.cs b/Src/Modules/xxsubtype.cs similarity index 100% rename from Src/IronPython.Modules/xxsubtype.cs rename to Src/Modules/xxsubtype.cs diff --git a/Src/IronPython.Modules/zipimport.cs b/Src/Modules/zipimport.cs similarity index 100% rename from Src/IronPython.Modules/zipimport.cs rename to Src/Modules/zipimport.cs diff --git a/Src/IronPython.Modules/zlib/Compress.cs b/Src/Modules/zlib/Compress.cs similarity index 100% rename from Src/IronPython.Modules/zlib/Compress.cs rename to Src/Modules/zlib/Compress.cs diff --git a/Src/IronPython.Modules/zlib/Decompress.cs b/Src/Modules/zlib/Decompress.cs similarity index 100% rename from Src/IronPython.Modules/zlib/Decompress.cs rename to Src/Modules/zlib/Decompress.cs diff --git a/Src/IronPython.Modules/zlib/ZlibModule.cs b/Src/Modules/zlib/ZlibModule.cs similarity index 100% rename from Src/IronPython.Modules/zlib/ZlibModule.cs rename to Src/Modules/zlib/ZlibModule.cs diff --git a/Src/IronPython.Modules/zlib/zlib.net/Adler32.cs b/Src/Modules/zlib/zlib.net/Adler32.cs similarity index 100% rename from Src/IronPython.Modules/zlib/zlib.net/Adler32.cs rename to Src/Modules/zlib/zlib.net/Adler32.cs diff --git a/Src/IronPython.Modules/zlib/zlib.net/Deflate.cs b/Src/Modules/zlib/zlib.net/Deflate.cs similarity index 100% rename from Src/IronPython.Modules/zlib/zlib.net/Deflate.cs rename to Src/Modules/zlib/zlib.net/Deflate.cs diff --git a/Src/IronPython.Modules/zlib/zlib.net/InfBlocks.cs b/Src/Modules/zlib/zlib.net/InfBlocks.cs similarity index 100% rename from Src/IronPython.Modules/zlib/zlib.net/InfBlocks.cs rename to Src/Modules/zlib/zlib.net/InfBlocks.cs diff --git a/Src/IronPython.Modules/zlib/zlib.net/InfCodes.cs b/Src/Modules/zlib/zlib.net/InfCodes.cs similarity index 100% rename from Src/IronPython.Modules/zlib/zlib.net/InfCodes.cs rename to Src/Modules/zlib/zlib.net/InfCodes.cs diff --git a/Src/IronPython.Modules/zlib/zlib.net/InfTree.cs b/Src/Modules/zlib/zlib.net/InfTree.cs similarity index 100% rename from Src/IronPython.Modules/zlib/zlib.net/InfTree.cs rename to Src/Modules/zlib/zlib.net/InfTree.cs diff --git a/Src/IronPython.Modules/zlib/zlib.net/Inflate.cs b/Src/Modules/zlib/zlib.net/Inflate.cs similarity index 100% rename from Src/IronPython.Modules/zlib/zlib.net/Inflate.cs rename to Src/Modules/zlib/zlib.net/Inflate.cs diff --git a/Src/IronPython.Modules/zlib/zlib.net/StaticTree.cs b/Src/Modules/zlib/zlib.net/StaticTree.cs similarity index 100% rename from Src/IronPython.Modules/zlib/zlib.net/StaticTree.cs rename to Src/Modules/zlib/zlib.net/StaticTree.cs diff --git a/Src/IronPython.Modules/zlib/zlib.net/Tree.cs b/Src/Modules/zlib/zlib.net/Tree.cs similarity index 100% rename from Src/IronPython.Modules/zlib/zlib.net/Tree.cs rename to Src/Modules/zlib/zlib.net/Tree.cs diff --git a/Src/IronPython.Modules/zlib/zlib.net/ZStream.cs b/Src/Modules/zlib/zlib.net/ZStream.cs similarity index 100% rename from Src/IronPython.Modules/zlib/zlib.net/ZStream.cs rename to Src/Modules/zlib/zlib.net/ZStream.cs diff --git a/Src/IronPython.Modules/zlib/zlib.net/ZStreamException.cs b/Src/Modules/zlib/zlib.net/ZStreamException.cs similarity index 100% rename from Src/IronPython.Modules/zlib/zlib.net/ZStreamException.cs rename to Src/Modules/zlib/zlib.net/ZStreamException.cs diff --git a/Src/IronPython.Modules/zlib/zlib.net/Zlib.cs b/Src/Modules/zlib/zlib.net/Zlib.cs similarity index 100% rename from Src/IronPython.Modules/zlib/zlib.net/Zlib.cs rename to Src/Modules/zlib/zlib.net/Zlib.cs diff --git a/Src/IronPython.Modules/zlib/zlib.net/history.txt b/Src/Modules/zlib/zlib.net/history.txt similarity index 100% rename from Src/IronPython.Modules/zlib/zlib.net/history.txt rename to Src/Modules/zlib/zlib.net/history.txt diff --git a/Src/IronPython.Modules/zlib/zlib.net/license.txt b/Src/Modules/zlib/zlib.net/license.txt similarity index 100% rename from Src/IronPython.Modules/zlib/zlib.net/license.txt rename to Src/Modules/zlib/zlib.net/license.txt diff --git a/Src/IronPython.Modules/zlib/zlib.net/readme.txt b/Src/Modules/zlib/zlib.net/readme.txt similarity index 100% rename from Src/IronPython.Modules/zlib/zlib.net/readme.txt rename to Src/Modules/zlib/zlib.net/readme.txt diff --git a/Src/IronPython.SQLite/Connection.cs b/Src/SQLite/Connection.cs similarity index 100% rename from Src/IronPython.SQLite/Connection.cs rename to Src/SQLite/Connection.cs diff --git a/Src/IronPython.SQLite/Contants.cs b/Src/SQLite/Contants.cs similarity index 100% rename from Src/IronPython.SQLite/Contants.cs rename to Src/SQLite/Contants.cs diff --git a/Src/IronPython.SQLite/Cursor.cs b/Src/SQLite/Cursor.cs similarity index 100% rename from Src/IronPython.SQLite/Cursor.cs rename to Src/SQLite/Cursor.cs diff --git a/Src/IronPython.SQLite/Exceptions.cs b/Src/SQLite/Exceptions.cs similarity index 100% rename from Src/IronPython.SQLite/Exceptions.cs rename to Src/SQLite/Exceptions.cs diff --git a/Src/IronPython.SQLite/Extensions.cs b/Src/SQLite/Extensions.cs similarity index 100% rename from Src/IronPython.SQLite/Extensions.cs rename to Src/SQLite/Extensions.cs diff --git a/Src/IronPython.SQLite/IronPython.SQLite.csproj b/Src/SQLite/IronPython.SQLite.csproj similarity index 100% rename from Src/IronPython.SQLite/IronPython.SQLite.csproj rename to Src/SQLite/IronPython.SQLite.csproj diff --git a/Src/IronPython.SQLite/Properties/AssemblyInfo.cs b/Src/SQLite/Properties/AssemblyInfo.cs similarity index 100% rename from Src/IronPython.SQLite/Properties/AssemblyInfo.cs rename to Src/SQLite/Properties/AssemblyInfo.cs diff --git a/Src/IronPython.SQLite/Row.cs b/Src/SQLite/Row.cs similarity index 100% rename from Src/IronPython.SQLite/Row.cs rename to Src/SQLite/Row.cs diff --git a/Src/IronPython.SQLite/Statement.cs b/Src/SQLite/Statement.cs similarity index 100% rename from Src/IronPython.SQLite/Statement.cs rename to Src/SQLite/Statement.cs diff --git a/Src/IronPython.SQLite/Util.cs b/Src/SQLite/Util.cs similarity index 100% rename from Src/IronPython.SQLite/Util.cs rename to Src/SQLite/Util.cs diff --git a/Src/IronPython.SQLite/_sqlite.cs b/Src/SQLite/_sqlite.cs similarity index 100% rename from Src/IronPython.SQLite/_sqlite.cs rename to Src/SQLite/_sqlite.cs diff --git a/Src/IronPython.SQLite/c#sqlite/.editorconfig b/Src/SQLite/c#sqlite/.editorconfig similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/.editorconfig rename to Src/SQLite/c#sqlite/.editorconfig diff --git a/Src/IronPython.SQLite/c#sqlite/BtreeInt_h.cs b/Src/SQLite/c#sqlite/BtreeInt_h.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/BtreeInt_h.cs rename to Src/SQLite/c#sqlite/BtreeInt_h.cs diff --git a/Src/IronPython.SQLite/c#sqlite/Btree_h.cs b/Src/SQLite/c#sqlite/Btree_h.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/Btree_h.cs rename to Src/SQLite/c#sqlite/Btree_h.cs diff --git a/Src/IronPython.SQLite/c#sqlite/Delegates.cs b/Src/SQLite/c#sqlite/Delegates.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/Delegates.cs rename to Src/SQLite/c#sqlite/Delegates.cs diff --git a/Src/IronPython.SQLite/c#sqlite/Hash_h.cs b/Src/SQLite/c#sqlite/Hash_h.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/Hash_h.cs rename to Src/SQLite/c#sqlite/Hash_h.cs diff --git a/Src/IronPython.SQLite/c#sqlite/VdbeInt_h.cs b/Src/SQLite/c#sqlite/VdbeInt_h.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/VdbeInt_h.cs rename to Src/SQLite/c#sqlite/VdbeInt_h.cs diff --git a/Src/IronPython.SQLite/c#sqlite/Vdbe_h.cs b/Src/SQLite/c#sqlite/Vdbe_h.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/Vdbe_h.cs rename to Src/SQLite/c#sqlite/Vdbe_h.cs diff --git a/Src/IronPython.SQLite/c#sqlite/_Custom.cs b/Src/SQLite/c#sqlite/_Custom.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/_Custom.cs rename to Src/SQLite/c#sqlite/_Custom.cs diff --git a/Src/IronPython.SQLite/c#sqlite/alter_c.cs b/Src/SQLite/c#sqlite/alter_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/alter_c.cs rename to Src/SQLite/c#sqlite/alter_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/analyze_c.cs b/Src/SQLite/c#sqlite/analyze_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/analyze_c.cs rename to Src/SQLite/c#sqlite/analyze_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/attach_c.cs b/Src/SQLite/c#sqlite/attach_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/attach_c.cs rename to Src/SQLite/c#sqlite/attach_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/auth_c.cs b/Src/SQLite/c#sqlite/auth_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/auth_c.cs rename to Src/SQLite/c#sqlite/auth_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/backup_c.cs b/Src/SQLite/c#sqlite/backup_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/backup_c.cs rename to Src/SQLite/c#sqlite/backup_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/bitvec_c.cs b/Src/SQLite/c#sqlite/bitvec_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/bitvec_c.cs rename to Src/SQLite/c#sqlite/bitvec_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/btmutex_c.cs b/Src/SQLite/c#sqlite/btmutex_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/btmutex_c.cs rename to Src/SQLite/c#sqlite/btmutex_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/btree_c.cs b/Src/SQLite/c#sqlite/btree_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/btree_c.cs rename to Src/SQLite/c#sqlite/btree_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/build_c.cs b/Src/SQLite/c#sqlite/build_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/build_c.cs rename to Src/SQLite/c#sqlite/build_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/callback_c.cs b/Src/SQLite/c#sqlite/callback_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/callback_c.cs rename to Src/SQLite/c#sqlite/callback_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/complete_c.cs b/Src/SQLite/c#sqlite/complete_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/complete_c.cs rename to Src/SQLite/c#sqlite/complete_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/crypto.cs b/Src/SQLite/c#sqlite/crypto.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/crypto.cs rename to Src/SQLite/c#sqlite/crypto.cs diff --git a/Src/IronPython.SQLite/c#sqlite/ctime_c.cs b/Src/SQLite/c#sqlite/ctime_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/ctime_c.cs rename to Src/SQLite/c#sqlite/ctime_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/date_c.cs b/Src/SQLite/c#sqlite/date_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/date_c.cs rename to Src/SQLite/c#sqlite/date_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/delete_c.cs b/Src/SQLite/c#sqlite/delete_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/delete_c.cs rename to Src/SQLite/c#sqlite/delete_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/expr_c.cs b/Src/SQLite/c#sqlite/expr_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/expr_c.cs rename to Src/SQLite/c#sqlite/expr_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/fault_c.cs b/Src/SQLite/c#sqlite/fault_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/fault_c.cs rename to Src/SQLite/c#sqlite/fault_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/fkey_c.cs b/Src/SQLite/c#sqlite/fkey_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/fkey_c.cs rename to Src/SQLite/c#sqlite/fkey_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/func_c.cs b/Src/SQLite/c#sqlite/func_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/func_c.cs rename to Src/SQLite/c#sqlite/func_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/global_c.cs b/Src/SQLite/c#sqlite/global_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/global_c.cs rename to Src/SQLite/c#sqlite/global_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/hash_c.cs b/Src/SQLite/c#sqlite/hash_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/hash_c.cs rename to Src/SQLite/c#sqlite/hash_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/hwtime_c.cs b/Src/SQLite/c#sqlite/hwtime_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/hwtime_c.cs rename to Src/SQLite/c#sqlite/hwtime_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/insert_c.cs b/Src/SQLite/c#sqlite/insert_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/insert_c.cs rename to Src/SQLite/c#sqlite/insert_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/journal_c.cs b/Src/SQLite/c#sqlite/journal_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/journal_c.cs rename to Src/SQLite/c#sqlite/journal_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/keywordhash_h.cs b/Src/SQLite/c#sqlite/keywordhash_h.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/keywordhash_h.cs rename to Src/SQLite/c#sqlite/keywordhash_h.cs diff --git a/Src/IronPython.SQLite/c#sqlite/legacy_c.cs b/Src/SQLite/c#sqlite/legacy_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/legacy_c.cs rename to Src/SQLite/c#sqlite/legacy_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/loadext_c.cs b/Src/SQLite/c#sqlite/loadext_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/loadext_c.cs rename to Src/SQLite/c#sqlite/loadext_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/main_c.cs b/Src/SQLite/c#sqlite/main_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/main_c.cs rename to Src/SQLite/c#sqlite/main_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/malloc_c.cs b/Src/SQLite/c#sqlite/malloc_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/malloc_c.cs rename to Src/SQLite/c#sqlite/malloc_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/mem_Pool.cs b/Src/SQLite/c#sqlite/mem_Pool.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/mem_Pool.cs rename to Src/SQLite/c#sqlite/mem_Pool.cs diff --git a/Src/IronPython.SQLite/c#sqlite/memjournal_c.cs b/Src/SQLite/c#sqlite/memjournal_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/memjournal_c.cs rename to Src/SQLite/c#sqlite/memjournal_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/mutex_c.cs b/Src/SQLite/c#sqlite/mutex_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/mutex_c.cs rename to Src/SQLite/c#sqlite/mutex_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/mutex_h.cs b/Src/SQLite/c#sqlite/mutex_h.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/mutex_h.cs rename to Src/SQLite/c#sqlite/mutex_h.cs diff --git a/Src/IronPython.SQLite/c#sqlite/mutex_noop_c.cs b/Src/SQLite/c#sqlite/mutex_noop_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/mutex_noop_c.cs rename to Src/SQLite/c#sqlite/mutex_noop_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/mutex_w32.cs b/Src/SQLite/c#sqlite/mutex_w32.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/mutex_w32.cs rename to Src/SQLite/c#sqlite/mutex_w32.cs diff --git a/Src/IronPython.SQLite/c#sqlite/notify_c.cs b/Src/SQLite/c#sqlite/notify_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/notify_c.cs rename to Src/SQLite/c#sqlite/notify_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/opcodes_c.cs b/Src/SQLite/c#sqlite/opcodes_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/opcodes_c.cs rename to Src/SQLite/c#sqlite/opcodes_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/opcodes_h.cs b/Src/SQLite/c#sqlite/opcodes_h.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/opcodes_h.cs rename to Src/SQLite/c#sqlite/opcodes_h.cs diff --git a/Src/IronPython.SQLite/c#sqlite/os_c.cs b/Src/SQLite/c#sqlite/os_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/os_c.cs rename to Src/SQLite/c#sqlite/os_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/os_common_h.cs b/Src/SQLite/c#sqlite/os_common_h.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/os_common_h.cs rename to Src/SQLite/c#sqlite/os_common_h.cs diff --git a/Src/IronPython.SQLite/c#sqlite/os_h.cs b/Src/SQLite/c#sqlite/os_h.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/os_h.cs rename to Src/SQLite/c#sqlite/os_h.cs diff --git a/Src/IronPython.SQLite/c#sqlite/os_win_c.cs b/Src/SQLite/c#sqlite/os_win_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/os_win_c.cs rename to Src/SQLite/c#sqlite/os_win_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/pager_c.cs b/Src/SQLite/c#sqlite/pager_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/pager_c.cs rename to Src/SQLite/c#sqlite/pager_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/pager_h.cs b/Src/SQLite/c#sqlite/pager_h.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/pager_h.cs rename to Src/SQLite/c#sqlite/pager_h.cs diff --git a/Src/IronPython.SQLite/c#sqlite/parse_c.cs b/Src/SQLite/c#sqlite/parse_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/parse_c.cs rename to Src/SQLite/c#sqlite/parse_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/parse_h.cs b/Src/SQLite/c#sqlite/parse_h.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/parse_h.cs rename to Src/SQLite/c#sqlite/parse_h.cs diff --git a/Src/IronPython.SQLite/c#sqlite/pcache1_c.cs b/Src/SQLite/c#sqlite/pcache1_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/pcache1_c.cs rename to Src/SQLite/c#sqlite/pcache1_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/pcache_c.cs b/Src/SQLite/c#sqlite/pcache_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/pcache_c.cs rename to Src/SQLite/c#sqlite/pcache_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/pcache_h.cs b/Src/SQLite/c#sqlite/pcache_h.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/pcache_h.cs rename to Src/SQLite/c#sqlite/pcache_h.cs diff --git a/Src/IronPython.SQLite/c#sqlite/pragma_c.cs b/Src/SQLite/c#sqlite/pragma_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/pragma_c.cs rename to Src/SQLite/c#sqlite/pragma_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/prepare_c.cs b/Src/SQLite/c#sqlite/prepare_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/prepare_c.cs rename to Src/SQLite/c#sqlite/prepare_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/printf_c.cs b/Src/SQLite/c#sqlite/printf_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/printf_c.cs rename to Src/SQLite/c#sqlite/printf_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/random_c.cs b/Src/SQLite/c#sqlite/random_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/random_c.cs rename to Src/SQLite/c#sqlite/random_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/resolve_c.cs b/Src/SQLite/c#sqlite/resolve_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/resolve_c.cs rename to Src/SQLite/c#sqlite/resolve_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/rowset_c.cs b/Src/SQLite/c#sqlite/rowset_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/rowset_c.cs rename to Src/SQLite/c#sqlite/rowset_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/select_c.cs b/Src/SQLite/c#sqlite/select_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/select_c.cs rename to Src/SQLite/c#sqlite/select_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/sqlite3_h.cs b/Src/SQLite/c#sqlite/sqlite3_h.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/sqlite3_h.cs rename to Src/SQLite/c#sqlite/sqlite3_h.cs diff --git a/Src/IronPython.SQLite/c#sqlite/sqliteInt_h.cs b/Src/SQLite/c#sqlite/sqliteInt_h.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/sqliteInt_h.cs rename to Src/SQLite/c#sqlite/sqliteInt_h.cs diff --git a/Src/IronPython.SQLite/c#sqlite/sqliteLimit_h.cs b/Src/SQLite/c#sqlite/sqliteLimit_h.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/sqliteLimit_h.cs rename to Src/SQLite/c#sqlite/sqliteLimit_h.cs diff --git a/Src/IronPython.SQLite/c#sqlite/status_c.cs b/Src/SQLite/c#sqlite/status_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/status_c.cs rename to Src/SQLite/c#sqlite/status_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/table_c.cs b/Src/SQLite/c#sqlite/table_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/table_c.cs rename to Src/SQLite/c#sqlite/table_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/tokenize_c.cs b/Src/SQLite/c#sqlite/tokenize_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/tokenize_c.cs rename to Src/SQLite/c#sqlite/tokenize_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/trigger_c.cs b/Src/SQLite/c#sqlite/trigger_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/trigger_c.cs rename to Src/SQLite/c#sqlite/trigger_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/update_c.cs b/Src/SQLite/c#sqlite/update_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/update_c.cs rename to Src/SQLite/c#sqlite/update_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/utf_c.cs b/Src/SQLite/c#sqlite/utf_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/utf_c.cs rename to Src/SQLite/c#sqlite/utf_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/util_c.cs b/Src/SQLite/c#sqlite/util_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/util_c.cs rename to Src/SQLite/c#sqlite/util_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/vacuum_c.cs b/Src/SQLite/c#sqlite/vacuum_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/vacuum_c.cs rename to Src/SQLite/c#sqlite/vacuum_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/vdbe_c.cs b/Src/SQLite/c#sqlite/vdbe_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/vdbe_c.cs rename to Src/SQLite/c#sqlite/vdbe_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/vdbeapi_c.cs b/Src/SQLite/c#sqlite/vdbeapi_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/vdbeapi_c.cs rename to Src/SQLite/c#sqlite/vdbeapi_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/vdbeaux_c.cs b/Src/SQLite/c#sqlite/vdbeaux_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/vdbeaux_c.cs rename to Src/SQLite/c#sqlite/vdbeaux_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/vdbeblob_c.cs b/Src/SQLite/c#sqlite/vdbeblob_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/vdbeblob_c.cs rename to Src/SQLite/c#sqlite/vdbeblob_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/vdbemem_c.cs b/Src/SQLite/c#sqlite/vdbemem_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/vdbemem_c.cs rename to Src/SQLite/c#sqlite/vdbemem_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/vdbetrace_c.cs b/Src/SQLite/c#sqlite/vdbetrace_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/vdbetrace_c.cs rename to Src/SQLite/c#sqlite/vdbetrace_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/vtab_c.cs b/Src/SQLite/c#sqlite/vtab_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/vtab_c.cs rename to Src/SQLite/c#sqlite/vtab_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/wal_c.cs b/Src/SQLite/c#sqlite/wal_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/wal_c.cs rename to Src/SQLite/c#sqlite/wal_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/wal_h.cs b/Src/SQLite/c#sqlite/wal_h.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/wal_h.cs rename to Src/SQLite/c#sqlite/wal_h.cs diff --git a/Src/IronPython.SQLite/c#sqlite/walker_c.cs b/Src/SQLite/c#sqlite/walker_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/walker_c.cs rename to Src/SQLite/c#sqlite/walker_c.cs diff --git a/Src/IronPython.SQLite/c#sqlite/where_c.cs b/Src/SQLite/c#sqlite/where_c.cs similarity index 100% rename from Src/IronPython.SQLite/c#sqlite/where_c.cs rename to Src/SQLite/c#sqlite/where_c.cs diff --git a/Src/IronPythonTest/AssemblyInfo.cs b/Src/Tests/AssemblyInfo.cs similarity index 100% rename from Src/IronPythonTest/AssemblyInfo.cs rename to Src/Tests/AssemblyInfo.cs diff --git a/Src/IronPythonTest/AttrInjectorTest.cs b/Src/Tests/AttrInjectorTest.cs similarity index 100% rename from Src/IronPythonTest/AttrInjectorTest.cs rename to Src/Tests/AttrInjectorTest.cs diff --git a/Src/IronPythonTest/BindTest.cs b/Src/Tests/BindTest.cs similarity index 100% rename from Src/IronPythonTest/BindTest.cs rename to Src/Tests/BindTest.cs diff --git a/Src/IronPythonTest/BinderTest.cs b/Src/Tests/BinderTest.cs similarity index 100% rename from Src/IronPythonTest/BinderTest.cs rename to Src/Tests/BinderTest.cs diff --git a/Src/IronPythonTest/Cases/CPythonCases.cs b/Src/Tests/Cases/CPythonCases.cs similarity index 100% rename from Src/IronPythonTest/Cases/CPythonCases.cs rename to Src/Tests/Cases/CPythonCases.cs diff --git a/Src/IronPythonTest/Cases/CPythonCasesManifest.ini b/Src/Tests/Cases/CPythonCasesManifest.ini similarity index 100% rename from Src/IronPythonTest/Cases/CPythonCasesManifest.ini rename to Src/Tests/Cases/CPythonCasesManifest.ini diff --git a/Src/IronPythonTest/Cases/CaseExecuter.cs b/Src/Tests/Cases/CaseExecuter.cs similarity index 100% rename from Src/IronPythonTest/Cases/CaseExecuter.cs rename to Src/Tests/Cases/CaseExecuter.cs diff --git a/Src/IronPythonTest/Cases/CaseGenerator.cs b/Src/Tests/Cases/CaseGenerator.cs similarity index 100% rename from Src/IronPythonTest/Cases/CaseGenerator.cs rename to Src/Tests/Cases/CaseGenerator.cs diff --git a/Src/IronPythonTest/Cases/CommonCases.cs b/Src/Tests/Cases/CommonCases.cs similarity index 100% rename from Src/IronPythonTest/Cases/CommonCases.cs rename to Src/Tests/Cases/CommonCases.cs diff --git a/Src/IronPythonTest/Cases/IronPythonCases.cs b/Src/Tests/Cases/IronPythonCases.cs similarity index 100% rename from Src/IronPythonTest/Cases/IronPythonCases.cs rename to Src/Tests/Cases/IronPythonCases.cs diff --git a/Src/IronPythonTest/Cases/IronPythonCasesManifest.ini b/Src/Tests/Cases/IronPythonCasesManifest.ini similarity index 100% rename from Src/IronPythonTest/Cases/IronPythonCasesManifest.ini rename to Src/Tests/Cases/IronPythonCasesManifest.ini diff --git a/Src/IronPythonTest/ClrType.cs b/Src/Tests/ClrType.cs similarity index 100% rename from Src/IronPythonTest/ClrType.cs rename to Src/Tests/ClrType.cs diff --git a/Src/IronPythonTest/Cmplx.cs b/Src/Tests/Cmplx.cs similarity index 100% rename from Src/IronPythonTest/Cmplx.cs rename to Src/Tests/Cmplx.cs diff --git a/Src/IronPythonTest/Conversions.cs b/Src/Tests/Conversions.cs similarity index 100% rename from Src/IronPythonTest/Conversions.cs rename to Src/Tests/Conversions.cs diff --git a/Src/IronPythonTest/DeTest.cs b/Src/Tests/DeTest.cs similarity index 100% rename from Src/IronPythonTest/DeTest.cs rename to Src/Tests/DeTest.cs diff --git a/Src/IronPythonTest/DelegateTest.cs b/Src/Tests/DelegateTest.cs similarity index 100% rename from Src/IronPythonTest/DelegateTest.cs rename to Src/Tests/DelegateTest.cs diff --git a/Src/IronPythonTest/DynamicRegressions.cs b/Src/Tests/DynamicRegressions.cs similarity index 100% rename from Src/IronPythonTest/DynamicRegressions.cs rename to Src/Tests/DynamicRegressions.cs diff --git a/Src/IronPythonTest/EncodingTest.cs b/Src/Tests/EncodingTest.cs similarity index 100% rename from Src/IronPythonTest/EncodingTest.cs rename to Src/Tests/EncodingTest.cs diff --git a/Src/IronPythonTest/EngineTest.cs b/Src/Tests/EngineTest.cs similarity index 100% rename from Src/IronPythonTest/EngineTest.cs rename to Src/Tests/EngineTest.cs diff --git a/Src/IronPythonTest/Enums.cs b/Src/Tests/Enums.cs similarity index 100% rename from Src/IronPythonTest/Enums.cs rename to Src/Tests/Enums.cs diff --git a/Src/IronPythonTest/Events.cs b/Src/Tests/Events.cs similarity index 100% rename from Src/IronPythonTest/Events.cs rename to Src/Tests/Events.cs diff --git a/Src/IronPythonTest/ExceptionConverter.cs b/Src/Tests/ExceptionConverter.cs similarity index 100% rename from Src/IronPythonTest/ExceptionConverter.cs rename to Src/Tests/ExceptionConverter.cs diff --git a/Src/IronPythonTest/Exceptions.cs b/Src/Tests/Exceptions.cs similarity index 100% rename from Src/IronPythonTest/Exceptions.cs rename to Src/Tests/Exceptions.cs diff --git a/Src/IronPythonTest/Explicit.cs b/Src/Tests/Explicit.cs similarity index 100% rename from Src/IronPythonTest/Explicit.cs rename to Src/Tests/Explicit.cs diff --git a/Src/IronPythonTest/ExtensionMethodTest.cs b/Src/Tests/ExtensionMethodTest.cs similarity index 100% rename from Src/IronPythonTest/ExtensionMethodTest.cs rename to Src/Tests/ExtensionMethodTest.cs diff --git a/Src/IronPythonTest/GenMeth.cs b/Src/Tests/GenMeth.cs similarity index 100% rename from Src/IronPythonTest/GenMeth.cs rename to Src/Tests/GenMeth.cs diff --git a/Src/IronPythonTest/Indexable.cs b/Src/Tests/Indexable.cs similarity index 100% rename from Src/IronPythonTest/Indexable.cs rename to Src/Tests/Indexable.cs diff --git a/Src/IronPythonTest/InheritTest.cs b/Src/Tests/InheritTest.cs similarity index 100% rename from Src/IronPythonTest/InheritTest.cs rename to Src/Tests/InheritTest.cs diff --git a/Src/IronPythonTest/IntegerTest.cs b/Src/Tests/IntegerTest.cs similarity index 100% rename from Src/IronPythonTest/IntegerTest.cs rename to Src/Tests/IntegerTest.cs diff --git a/Src/IronPythonTest/IronMath.cs b/Src/Tests/IronMath.cs similarity index 100% rename from Src/IronPythonTest/IronMath.cs rename to Src/Tests/IronMath.cs diff --git a/Src/IronPythonTest/IronPython.Tests.csproj b/Src/Tests/IronPython.Tests.csproj similarity index 100% rename from Src/IronPythonTest/IronPython.Tests.csproj rename to Src/Tests/IronPython.Tests.csproj diff --git a/Src/IronPythonTest/LoadTest.cs b/Src/Tests/LoadTest.cs similarity index 100% rename from Src/IronPythonTest/LoadTest.cs rename to Src/Tests/LoadTest.cs diff --git a/Src/IronPythonTest/MemberMappingTests.cs b/Src/Tests/MemberMappingTests.cs similarity index 100% rename from Src/IronPythonTest/MemberMappingTests.cs rename to Src/Tests/MemberMappingTests.cs diff --git a/Src/IronPythonTest/MemberOverloadTest.cs b/Src/Tests/MemberOverloadTest.cs similarity index 100% rename from Src/IronPythonTest/MemberOverloadTest.cs rename to Src/Tests/MemberOverloadTest.cs diff --git a/Src/IronPythonTest/MethodParametersStubs.cs b/Src/Tests/MethodParametersStubs.cs similarity index 100% rename from Src/IronPythonTest/MethodParametersStubs.cs rename to Src/Tests/MethodParametersStubs.cs diff --git a/Src/IronPythonTest/NestedClass.cs b/Src/Tests/NestedClass.cs similarity index 100% rename from Src/IronPythonTest/NestedClass.cs rename to Src/Tests/NestedClass.cs diff --git a/Src/IronPythonTest/NullableTest.cs b/Src/Tests/NullableTest.cs similarity index 100% rename from Src/IronPythonTest/NullableTest.cs rename to Src/Tests/NullableTest.cs diff --git a/Src/IronPythonTest/OperatorTest.cs b/Src/Tests/OperatorTest.cs similarity index 100% rename from Src/IronPythonTest/OperatorTest.cs rename to Src/Tests/OperatorTest.cs diff --git a/Src/IronPythonTest/ProtocolTest.cs b/Src/Tests/ProtocolTest.cs similarity index 100% rename from Src/IronPythonTest/ProtocolTest.cs rename to Src/Tests/ProtocolTest.cs diff --git a/Src/IronPythonTest/StaticTest.cs b/Src/Tests/StaticTest.cs similarity index 100% rename from Src/IronPythonTest/StaticTest.cs rename to Src/Tests/StaticTest.cs diff --git a/Src/IronPythonTest/Stress/Engine.cs b/Src/Tests/Stress/Engine.cs similarity index 100% rename from Src/IronPythonTest/Stress/Engine.cs rename to Src/Tests/Stress/Engine.cs diff --git a/Src/IronPythonTest/StringDictionaryStorage.cs b/Src/Tests/StringDictionaryStorage.cs similarity index 100% rename from Src/IronPythonTest/StringDictionaryStorage.cs rename to Src/Tests/StringDictionaryStorage.cs diff --git a/Src/IronPythonTest/TestBuiltinModule.cs b/Src/Tests/TestBuiltinModule.cs similarity index 100% rename from Src/IronPythonTest/TestBuiltinModule.cs rename to Src/Tests/TestBuiltinModule.cs diff --git a/Src/IronPythonTest/TypeDescriptor.cs b/Src/Tests/TypeDescriptor.cs similarity index 100% rename from Src/IronPythonTest/TypeDescriptor.cs rename to Src/Tests/TypeDescriptor.cs diff --git a/Src/IronPythonTest/Util/IniParser.cs b/Src/Tests/Util/IniParser.cs similarity index 100% rename from Src/IronPythonTest/Util/IniParser.cs rename to Src/Tests/Util/IniParser.cs diff --git a/Src/IronPythonTest/Util/TestManifest.cs b/Src/Tests/Util/TestManifest.cs similarity index 100% rename from Src/IronPythonTest/Util/TestManifest.cs rename to Src/Tests/Util/TestManifest.cs diff --git a/Src/IronPython.Wpf/DynamicXamlReader.cs b/Src/Wpf/DynamicXamlReader.cs similarity index 100% rename from Src/IronPython.Wpf/DynamicXamlReader.cs rename to Src/Wpf/DynamicXamlReader.cs diff --git a/Src/IronPython.Wpf/IronPython.Wpf.csproj b/Src/Wpf/IronPython.Wpf.csproj similarity index 100% rename from Src/IronPython.Wpf/IronPython.Wpf.csproj rename to Src/Wpf/IronPython.Wpf.csproj diff --git a/Src/IronPython.Wpf/Properties/AssemblyInfo.cs b/Src/Wpf/Properties/AssemblyInfo.cs similarity index 100% rename from Src/IronPython.Wpf/Properties/AssemblyInfo.cs rename to Src/Wpf/Properties/AssemblyInfo.cs diff --git a/Src/IronPython.Wpf/_wpf.cs b/Src/Wpf/_wpf.cs similarity index 100% rename from Src/IronPython.Wpf/_wpf.cs rename to Src/Wpf/_wpf.cs diff --git a/Util/NuGet/nuget.exe b/Utils/NuGet/nuget.exe similarity index 100% rename from Util/NuGet/nuget.exe rename to Utils/NuGet/nuget.exe diff --git a/Util/References/IKVM/IKVM.Reflection.License.txt b/Utils/References/IKVM/IKVM.Reflection.License.txt similarity index 100% rename from Util/References/IKVM/IKVM.Reflection.License.txt rename to Utils/References/IKVM/IKVM.Reflection.License.txt diff --git a/Util/References/IKVM/IKVM.Reflection.dll b/Utils/References/IKVM/IKVM.Reflection.dll similarity index 100% rename from Util/References/IKVM/IKVM.Reflection.dll rename to Utils/References/IKVM/IKVM.Reflection.dll diff --git a/Util/References/Mono.Posix.dll b/Utils/References/Mono.Posix.dll similarity index 100% rename from Util/References/Mono.Posix.dll rename to Utils/References/Mono.Posix.dll From 669829263703a8ac62babc7c3b1ae80b973d6823 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Sun, 17 Nov 2024 18:18:56 +0000 Subject: [PATCH 08/84] Update `Src/README.md` --- Src/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Src/README.md b/Src/README.md index 31bcd431b..3cea95b51 100644 --- a/Src/README.md +++ b/Src/README.md @@ -2,13 +2,13 @@ - `IronPython`: Core compiler and runtime (IronPython.dll) -IronPython.Tests: Targetted compiler and runtime unit tests hosted in a C# test harness. +- `IronPython.Tests`: Targetted compiler and runtime unit tests hosted in a C# test harness. -`Scripts`: Infrastructure scripts and helpers. +- `Scripts`: Infrastructure scripts and helpers. -`StdLib`: Python standard library imports. +- `StdLib`: Python standard library imports. -`Tests`: Test suites. +- `Tests`: Test suites. Please see [the wiki](https://github.com/IronLanguages/ironpython3/wiki) for information on: From a2c85dcd1fc816f58a7df3cdd087e24eab86d01d Mon Sep 17 00:00:00 2001 From: Lamparter Date: Sun, 17 Nov 2024 18:25:31 +0000 Subject: [PATCH 09/84] Removed submodule Src/DLR --- .gitmodules | 6 +++--- Src/DLR | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) delete mode 160000 Src/DLR diff --git a/.gitmodules b/.gitmodules index 5cd8e15d8..c5aaa65cd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ -[submodule "Src/DLR"] - path = Src/DLR +[submodule "DLR"] + path = DLR url = https://github.com/IronLanguages/dlr - branch = main + branch = main \ No newline at end of file diff --git a/Src/DLR b/Src/DLR deleted file mode 160000 index fe26cf45d..000000000 --- a/Src/DLR +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fe26cf45d383be65a56f0d4b964644eff89e01a8 From 7e38e2d03077bb5ba7e8aada08409842c0048c0c Mon Sep 17 00:00:00 2001 From: Lamparter Date: Sun, 17 Nov 2024 18:28:39 +0000 Subject: [PATCH 10/84] Simplify root directory --- Src/App.Debug.config => App.Debug.config | 0 Src/App.Release.config => App.Release.config | 0 {Src/CTypes => CTypes}/Makefile | 0 {Src/CTypes => CTypes}/_ctypes_test.c | 0 {Src/CTypes => CTypes}/_ctypes_test.sln | 0 {Src/CTypes => CTypes}/_ctypes_test.vcxproj | 0 .../AssemblyResolver.cs | 0 .../Config.cs | 0 .../ConsoleOps.cs | 0 .../IronPython.CompilerServices.csproj | 4 +-- .../Program.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../README.md | 0 .../IronPython.Console.Host.csproj | 0 .../IronPythonWindow.cs | 0 .../Properties/AssemblyInfo.cs | 0 {Src/Console.Host => Console.Host}/ipyw.ico | Bin {Src/Console => Console}/Console.cs | 0 .../IronPython.Console.csproj | 0 .../Properties/AssemblyInfo.cs | 0 {Src/Console => Console}/app.manifest | 0 {Src/Console => Console}/ipy-mono.sh | 0 {Src/Console => Console}/ipy.ico | Bin {Src/Console => Console}/ipy.sh | 0 .../runtimeconfig.template.json | 0 .../IronPython.Console32.Host.csproj | 4 +-- .../IronPython.Console32.csproj | 0 DLR | 1 + IronPython.sln | 28 +++++++++--------- .../Compiler/Ast/AndExpression.cs | 0 .../Compiler/Ast/AnnotatedAssignStatement.cs | 0 .../Compiler/Ast/AssertStatement.cs | 0 .../Compiler/Ast/AssignmentStatement.cs | 0 .../Compiler/Ast/AstMethods.cs | 0 .../Compiler/Ast/AsyncStatement.cs | 0 .../Compiler/Ast/AugmentedAssignStatement.cs | 0 .../Ast/BinaryExpression.Generated.cs | 0 .../Compiler/Ast/BinaryExpression.cs | 0 .../Compiler/Ast/BreakStatement.cs | 0 .../Compiler/Ast/CallExpression.cs | 0 .../Compiler/Ast/ClassDefinition.cs | 0 .../Compiler/Ast/Comprehension.cs | 0 .../Compiler/Ast/ComprehensionFor.cs | 0 .../Compiler/Ast/ComprehensionIf.cs | 0 .../Compiler/Ast/ConditionalExpression.cs | 0 .../Compiler/Ast/ConstantExpression.cs | 0 .../Compiler/Ast/ContinueStatement.cs | 0 .../Compiler/Ast/DelStatement.cs | 0 .../Compiler/Ast/DictionaryExpression.cs | 0 .../Compiler/Ast/DottedName.cs | 0 .../Compiler/Ast/DynamicConvertExpression.cs | 0 .../Ast/DynamicGetMemberExpression.cs | 0 .../Compiler/Ast/EmptyStatement.cs | 0 .../Compiler/Ast/ErrorExpression.cs | 0 .../Compiler/Ast/Expression.cs | 0 .../Compiler/Ast/ExpressionStatement.cs | 0 .../Compiler/Ast/FlowChecker.cs | 0 .../Compiler/Ast/ForStatement.cs | 0 .../Compiler/Ast/FormattedValueExpression.cs | 0 .../Compiler/Ast/FromImportStatement.cs | 0 .../Compiler/Ast/FunctionDefinition.cs | 0 .../Compiler/Ast/GeneratorExpression.cs | 0 .../Ast/GetGlobalContextExpression.cs | 0 .../GetParentContextFromFunctionExpression.cs | 0 .../Compiler/Ast/GlobalStatement.cs | 0 .../Compiler/Ast/ILoopStatement.cs | 0 .../Compiler/Ast/IfStatement.cs | 0 .../Compiler/Ast/IfStatementTest.cs | 0 .../Compiler/Ast/ImportStatement.cs | 0 .../Compiler/Ast/IndexExpression.cs | 0 .../Compiler/Ast/JoinedStringExpression.cs | 0 .../Compiler/Ast/Keyword.cs | 0 .../Compiler/Ast/LambdaExpression.cs | 0 .../Compiler/Ast/ListExpression.cs | 0 .../Compiler/Ast/MemberExpression.cs | 0 .../Compiler/Ast/ModuleName.cs | 0 .../Compiler/Ast/NameExpression.cs | 0 .../Compiler/Ast/Node.cs | 0 .../Compiler/Ast/NonlocalStatement.cs | 0 .../Compiler/Ast/OrExpression.cs | 0 .../Compiler/Ast/Parameter.cs | 0 .../Compiler/Ast/ParenthesisExpression.cs | 0 .../Compiler/Ast/PythonAst.cs | 0 .../Compiler/Ast/PythonConstantExpression.cs | 0 .../Compiler/Ast/PythonNameBinder.cs | 0 .../Compiler/Ast/PythonReference.cs | 0 .../Compiler/Ast/PythonVariable.cs | 0 .../Compiler/Ast/PythonWalker.Generated.cs | 0 .../Compiler/Ast/RaiseStatement.cs | 0 .../Compiler/Ast/RelativeModuleName.cs | 0 .../Compiler/Ast/ReturnStatement.cs | 0 .../Compiler/Ast/ScopeStatement.cs | 0 .../Compiler/Ast/SequenceExpression.cs | 0 .../Compiler/Ast/SerializedScopeStatement.cs | 0 .../Compiler/Ast/SetExpression.cs | 0 .../Compiler/Ast/SliceExpression.cs | 0 .../Compiler/Ast/StarredExpression.cs | 0 .../Compiler/Ast/Statement.cs | 0 .../Compiler/Ast/SuiteStatement.cs | 0 .../Compiler/Ast/TryStatement.cs | 0 .../Compiler/Ast/TupleExpression.cs | 0 .../Compiler/Ast/UnaryExpression.cs | 0 .../Compiler/Ast/VariableKind.cs | 0 .../Compiler/Ast/WhileStatement.cs | 0 .../Compiler/Ast/WithStatement.cs | 0 .../Compiler/Ast/YieldExpression.cs | 0 .../Compiler/Ast/YieldFromExpression.cs | 0 .../Compiler/ClosureExpression.cs | 0 .../Compiler/ClosureInfo.cs | 0 .../Compiler/CollectableCompilationMode.cs | 0 .../Compiler/CompilationMode.cs | 0 .../Compiler/GeneratorRewriter.cs | 0 .../Compiler/LazyCode.cs | 0 .../Compiler/LookupCompilationMode.cs | 0 .../Compiler/OnDiskScriptCode.cs | 0 .../Compiler/Parser.cs | 0 .../Compiler/PythonCallTargets.cs | 0 .../Compiler/PythonCompilerOptions.cs | 0 .../Compiler/PythonDynamicExpression.cs | 0 .../Compiler/PythonGlobal.cs | 0 .../PythonGlobalVariableExpression.cs | 0 .../Compiler/PythonOperator.cs | 0 .../Compiler/PythonSavableScriptCode.cs | 0 .../Compiler/PythonScriptCode.cs | 0 .../Compiler/ReducableDynamicExpression.cs | 0 .../Compiler/RunnableScriptCode.cs | 0 .../Compiler/RuntimeScriptCode.cs | 0 .../Compiler/ToDiskCompilationMode.cs | 0 .../Compiler/Token.cs | 0 .../Compiler/TokenKind.Generated.cs | 0 .../Compiler/Tokenizer.Generated.cs | 0 .../Compiler/Tokenizer.cs | 0 .../UncollectableCompilationMode.Generated.cs | 0 .../Compiler/UncollectableCompilationMode.cs | 0 .../FakeInteropServices.cs | 0 .../Hosting/Python.cs | 0 .../Hosting/PythonCodeDomCodeGen.cs | 0 .../Hosting/PythonCommandLine.cs | 0 .../Hosting/PythonConsoleOptions.cs | 0 .../Hosting/PythonOptionsParser.cs | 0 .../Hosting/PythonService.cs | 0 .../Interop/Windows/Interop.Libraries.cs | 0 .../Windows/Kernel32/Interop.GetWindowsExW.cs | 0 .../Kernel32/Interop.OSVERSIONINFOEX.cs | 0 .../Windows/NtDll/Interop.RtlGetVersion.cs | 0 .../Windows/Ucrtbase/Interop.strerror.cs | 0 .../IronPython.csproj | 4 +-- .../Lib/iptest/__init__.py | 0 .../Lib/iptest/cominterop_util.py | 0 .../Lib/iptest/console_util.py | 0 .../Lib/iptest/file_util.py | 0 .../Lib/iptest/ipunittest.py | 0 .../Lib/iptest/misc_util.py | 0 .../Lib/iptest/process_util.py | 0 .../Lib/iptest/runner.py | 0 .../Lib/iptest/test_env.py | 0 .../Lib/iptest/type_util.py | 0 .../Modules/Builtin.Generated.cs | 0 .../Modules/Builtin.cs | 0 .../IronPython => IronPython}/Modules/_ast.cs | 0 .../Modules/_fileio.cs | 0 .../IronPython => IronPython}/Modules/_imp.cs | 0 {Src/IronPython => IronPython}/Modules/_io.cs | 0 .../Modules/_io/BytesIO.cs | 0 .../Modules/_io/StringIO.cs | 0 .../Modules/_locale.cs | 0 {Src/IronPython => IronPython}/Modules/sys.cs | 0 .../Modules/unicodedata.cs | 0 .../Modules/unicodedata/CaseFolding.txt | 0 .../unicodedata/EastAsianWidth-3.2.0.txt | 0 .../Modules/unicodedata/EastAsianWidth.txt | 0 .../unicodedata/IPyUnicodeData-3.2.0.txt.gz | Bin .../Modules/unicodedata/IPyUnicodeData.txt.gz | Bin .../Modules/unicodedata/NameAliases.txt | 0 .../Modules/unicodedata/UnicodeData-3.2.0.txt | 0 .../Modules/unicodedata/UnicodeData.txt | 0 .../Modules/unicodedata/genunicodedata.py | 0 .../Modules/unicodedata/license.txt | 0 .../Properties/AssemblyInfo.cs | 0 {Src => IronPython}/README.md | 0 .../Resources.Designer.cs | 0 {Src/IronPython => IronPython}/Resources.resx | 0 .../Runtime/ArrayData.cs | 0 .../Binding/BinaryRetTypeBinder.Generated.cs | 0 .../Runtime/Binding/BinaryRetTypeBinder.cs | 0 .../Runtime/Binding/Binders.cs | 0 .../Runtime/Binding/BindingHelpers.cs | 0 .../Runtime/Binding/BindingWarnings.cs | 0 .../Binding/CompatibilityInvokeBinder.cs | 0 .../Runtime/Binding/ConditionalBuilder.cs | 0 .../Runtime/Binding/ContextArgBuilder.cs | 0 .../Runtime/Binding/ConversionBinder.cs | 0 .../Runtime/Binding/CreateFallbackBinder.cs | 0 .../Runtime/Binding/FastBindResult.cs | 0 .../Runtime/Binding/FastGetBase.cs | 0 .../Runtime/Binding/FastSetBase.cs | 0 .../Runtime/Binding/IComConvertible.cs | 0 .../Runtime/Binding/IFastGettable.cs | 0 .../Runtime/Binding/IFastInvokable.cs | 0 .../Runtime/Binding/IFastSettable.cs | 0 .../Runtime/Binding/IPythonConvertible.cs | 0 .../Runtime/Binding/IPythonExpandable.cs | 0 .../Runtime/Binding/IPythonGetable.cs | 0 .../Runtime/Binding/IPythonInvokable.cs | 0 .../Runtime/Binding/IPythonOperable.cs | 0 .../Runtime/Binding/IPythonSite.cs | 0 .../Runtime/Binding/MetaBuiltinFunction.cs | 0 .../Binding/MetaBuiltinMethodDescriptor.cs | 0 .../Runtime/Binding/MetaMethod.cs | 0 .../Runtime/Binding/MetaPythonFunction.cs | 0 .../Runtime/Binding/MetaPythonObject.cs | 0 .../Runtime/Binding/MetaPythonType.Calls.cs | 0 .../Runtime/Binding/MetaPythonType.Members.cs | 0 .../Runtime/Binding/MetaPythonType.cs | 0 .../Runtime/Binding/MetaUserObject.Members.cs | 0 .../Runtime/Binding/MetaUserObject.cs | 0 .../Binding/PythonBinaryOperationBinder.cs | 0 .../Runtime/Binding/PythonBinder.Create.cs | 0 .../Runtime/Binding/PythonBinder.cs | 0 .../Binding/PythonDeleteIndexBinder.cs | 0 .../Binding/PythonDeleteMemberBinder.cs | 0 .../Binding/PythonDeleteSliceBinder.cs | 0 .../Runtime/Binding/PythonExtensionBinder.cs | 0 .../Runtime/Binding/PythonGetIndexBinder.cs | 0 .../Runtime/Binding/PythonGetMemberBinder.cs | 0 .../Runtime/Binding/PythonGetSliceBinder.cs | 0 .../Runtime/Binding/PythonIndexType.cs | 0 .../Runtime/Binding/PythonInvokeBinder.cs | 0 .../Runtime/Binding/PythonOperationBinder.cs | 0 .../Runtime/Binding/PythonOperationKind.cs | 0 .../Runtime/Binding/PythonOverloadResolver.cs | 0 .../Binding/PythonProtocol.Operations.cs | 0 .../Runtime/Binding/PythonProtocol.cs | 0 .../Runtime/Binding/PythonSetIndexBinder.cs | 0 .../Runtime/Binding/PythonSetMemberBinder.cs | 0 .../Runtime/Binding/PythonSetSliceBinder.cs | 0 .../Binding/PythonUnaryOperationBinder.cs | 0 .../Binding/SiteLocalStorageBuilder.cs | 0 .../Runtime/Binding/SlotOrFunction.cs | 0 .../Runtime/Binding/WarningInfo.cs | 0 .../Runtime/BufferProtocol.cs | 0 .../Runtime/BuiltinPythonModule.cs | 0 .../Runtime/BuiltinsDictionaryStorage.cs | 0 .../Runtime/ByteArray.cs | 0 .../Runtime/ByteArrayIterator.cs | 0 .../Runtime/Bytes.cs | 0 .../Runtime/BytesIterator.cs | 0 .../Runtime/BytesLikeAttribute.cs | 0 .../Runtime/ClassMethodAttribute.cs | 0 .../Runtime/ClassMethodDescriptor.cs | 0 .../Runtime/ClrModule.cs | 0 .../Runtime/CodeContext.cs | 0 .../Runtime/CollectionDebugView.cs | 0 .../Runtime/CommonDictionaryStorage.cs | 0 .../Runtime/CompareUtil.cs | 0 .../Runtime/CompileFlags.cs | 0 .../Runtime/CompiledLoader.cs | 0 .../Runtime/ConstantDictionaryStorage.cs | 0 .../Runtime/ConversionWrappers.cs | 0 .../Runtime/Converter.cs | 0 .../Runtime/CustomDictionaryStorage.cs | 0 .../Runtime/DebuggerDictionaryStorage.cs | 0 .../Runtime/DefaultContext.cs | 0 .../Runtime/Descriptors.cs | 0 .../Runtime/DictionaryOps.cs | 0 .../Runtime/DictionaryStorage.cs | 0 .../Runtime/DictionaryTypeInfoAttribute.cs | 0 .../DontMapGetMemberNamesToDirAttribute.cs | 0 .../DontMapICollectionToLenAttribute.cs | 0 ...MapIDisposableToContextManagerAttribute.cs | 0 .../DontMapIEnumerableToContainsAttribute.cs | 0 .../DontMapIEnumerableToIterAttribute.cs | 0 .../Runtime/EmptyDictionaryStorage.cs | 0 .../Runtime/Enumerate.cs | 0 .../Runtime/ErrorCodes.cs | 0 .../AssertionException.Generated.cs | 0 .../Exceptions/AttributeErrorException.cs | 0 .../BlockingIOException.Generated.cs | 0 .../BrokenPipeException.Generated.cs | 0 .../Exceptions/BufferException.Generated.cs | 0 .../BytesWarningException.Generated.cs | 0 .../ChildProcessException.Generated.cs | 0 .../ConnectionAbortedException.Generated.cs | 0 .../ConnectionException.Generated.cs | 0 .../ConnectionRefusedException.Generated.cs | 0 .../ConnectionResetException.Generated.cs | 0 .../DeprecationWarningException.Generated.cs | 0 .../FileExistsException.Generated.cs | 0 .../FloatingPointException.Generated.cs | 0 .../FutureWarningException.Generated.cs | 0 .../Exceptions/GeneratorExitException.cs | 0 .../Exceptions/ImportException.Generated.cs | 0 .../ImportWarningException.Generated.cs | 0 .../Exceptions/IndentationException.cs | 0 .../InterruptedException.Generated.cs | 0 .../IsADirectoryException.Generated.cs | 0 .../Exceptions/LookupException.Generated.cs | 0 .../Exceptions/ModuleNotFoundException.cs | 0 .../NotADirectoryException.Generated.cs | 0 .../Exceptions/OSException.Generated.cs | 0 ...ngDeprecationWarningException.Generated.cs | 0 .../ProcessLookupException.Generated.cs | 0 .../Runtime/Exceptions/PythonException.cs | 0 .../PythonExceptions.BaseException.cs | 0 .../Exceptions/PythonExceptions.Generated.cs | 0 .../Runtime/Exceptions/PythonExceptions.cs | 0 .../RecursionException.Generated.cs | 0 .../ReferenceException.Generated.cs | 0 .../ResourceWarningException.Generated.cs | 0 .../Exceptions/RuntimeException.Generated.cs | 0 .../RuntimeWarningException.Generated.cs | 0 .../StopAsyncIterationException.Generated.cs | 0 .../StopIterationException.Generated.cs | 0 .../SyntaxWarningException.Generated.cs | 0 .../Runtime/Exceptions/SystemExitException.cs | 0 .../Runtime/Exceptions/TabException.cs | 0 .../Runtime/Exceptions/TraceBack.cs | 0 .../Runtime/Exceptions/TypeErrorException.cs | 0 .../Exceptions/UnicodeException.Generated.cs | 0 .../UnicodeTranslateException.Generated.cs | 0 .../UnicodeWarningException.Generated.cs | 0 .../UserWarningException.Generated.cs | 0 .../Runtime/Exceptions/ValueErrorException.cs | 0 .../Runtime/ExtensionMethodSet.cs | 0 .../Runtime/Filter.cs | 0 .../Runtime/FormattingHelper.cs | 0 .../Runtime/FunctionAttributes.cs | 0 .../Runtime/FunctionCode.cs | 0 .../Runtime/Generator.cs | 0 .../Runtime/GlobalDictionaryStorage.cs | 0 .../Runtime/IParameterSequence.cs | 0 .../Runtime/Implementation.cs | 0 .../Runtime/Importer.cs | 0 .../Runtime/Index.cs | 0 .../InstancedModuleDictionaryStorage.cs | 0 .../Runtime/Interfaces.cs | 0 .../Runtime/KwCallInfo.cs | 0 .../Runtime/LiteralParser.cs | 0 {Src/IronPython => IronPython}/Runtime/Map.cs | 0 .../Runtime/MaybeNotImplementedAttribute.cs | 0 .../Runtime/MemoryStreamContentProvider.cs | 0 .../Runtime/MemoryView.cs | 0 .../Runtime/Method.Generated.cs | 0 .../Runtime/Method.cs | 0 .../Runtime/MissingParameter.cs | 0 .../Runtime/ModuleContext.cs | 0 .../Runtime/ModuleDictionaryStorage.cs | 0 .../Runtime/ModuleGlobalCache.cs | 0 .../Runtime/ModuleLoader.cs | 0 .../Runtime/ModuleOptions.cs | 0 .../Runtime/NameType.cs | 0 .../Runtime/NewStringFormatter.cs | 0 .../Runtime/ObjectAttributesAdapter.cs | 0 .../Runtime/ObjectDebugView.cs | 0 .../Runtime/Operations/ArrayOps.cs | 0 .../Runtime/Operations/BigIntegerOps.cs | 0 .../Runtime/Operations/BoolOps.cs | 0 .../Runtime/Operations/ByteOps.cs | 0 .../Runtime/Operations/CharOps.cs | 0 .../Runtime/Operations/ComOps.cs | 0 .../Runtime/Operations/ComplexOps.cs | 0 .../Operations/CustomTypeDescHelpers.cs | 0 .../Runtime/Operations/DBNullOps.cs | 0 .../Runtime/Operations/DateTimeOps.cs | 0 .../Runtime/Operations/DecimalOps.cs | 0 .../Runtime/Operations/DelegateOps.cs | 0 .../Runtime/Operations/DictionaryOfTOps.cs | 0 .../Runtime/Operations/EnumOps.cs | 0 .../Runtime/Operations/FloatOps.Generated.cs | 0 .../Runtime/Operations/FloatOps.cs | 0 .../Runtime/Operations/IListOfByteOps.cs | 0 .../Runtime/Operations/InstanceOps.cs | 0 .../Runtime/Operations/IntOps.Generated.cs | 0 .../Runtime/Operations/IntOps.cs | 0 .../Runtime/Operations/IntPtrOps.cs | 0 .../Runtime/Operations/ListOfTOps.cs | 0 .../Runtime/Operations/MarshalOps.cs | 0 .../Runtime/Operations/NamespaceTrackerOps.cs | 0 .../Runtime/Operations/ObjectOps.cs | 0 .../Runtime/Operations/PythonCalls.cs | 0 .../Runtime/Operations/PythonOps.Generated.cs | 0 .../Runtime/Operations/PythonOps.cs | 0 .../Runtime/Operations/PythonTypeOps.cs | 0 .../Runtime/Operations/StringOps.Generated.cs | 0 .../Runtime/Operations/StringOps.cs | 0 .../Runtime/Operations/TypeGroupOps.cs | 0 .../Runtime/Operations/TypeTrackerOps.cs | 0 .../Runtime/Operations/UIntPtrOps.cs | 0 .../Runtime/Operations/UserTypeOps.cs | 0 .../Runtime/OutputWriter.cs | 0 .../Runtime/PlatformsAttribute.cs | 0 .../Runtime/Profiler.cs | 0 .../Runtime/PythonContext.Generated.cs | 0 .../Runtime/PythonContext.cs | 0 .../Runtime/PythonDictionary.cs | 0 .../Runtime/PythonDocumentationProvider.cs | 0 .../Runtime/PythonDynamicStackFrame.cs | 0 .../Runtime/PythonEncoding.cs | 0 .../Runtime/PythonFileManager.cs | 0 .../Runtime/PythonFunction.Generated.cs | 0 .../Runtime/PythonFunction.cs | 0 .../Runtime/PythonHiddenAttribute.cs | 0 .../Runtime/PythonHiddenBaseClassAttribute.cs | 0 .../Runtime/PythonList.cs | 0 .../Runtime/PythonModule.cs | 0 .../Runtime/PythonModuleAttribute.cs | 0 .../Runtime/PythonNarrowing.cs | 0 .../Runtime/PythonOptions.cs | 0 .../Runtime/PythonRange.cs | 0 .../Runtime/PythonScopeExtension.cs | 0 .../Runtime/PythonStrIterator.cs | 0 .../Runtime/PythonTracebackListener.cs | 0 .../Runtime/PythonTuple.cs | 0 .../Runtime/PythonTypeAttribute.cs | 0 .../Runtime/Reversed.cs | 0 .../RuntimeVariablesDictionaryStorage.cs | 0 .../Runtime/ScopeDictionaryStorage.cs | 0 .../Runtime/SequenceTypeInfoAttribute.cs | 0 {Src/IronPython => IronPython}/Runtime/Set.cs | 0 .../Runtime/SetStorage.cs | 0 .../Runtime/SimpleNamespace.cs | 0 .../Runtime/SiteLocalStorage.cs | 0 .../Runtime/Slice.cs | 0 .../Runtime/StringDictionaryStorage.cs | 0 .../Runtime/StringFormatSpec.cs | 0 .../Runtime/StringFormatter.cs | 0 .../Runtime/Super.cs | 0 .../Runtime/Symbols.Generated.cs | 0 .../Runtime/ThrowingErrorSink.cs | 0 .../Runtime/TypecodeOps.cs | 0 .../Runtime/Types/BuiltinFunction.cs | 0 .../Types/BuiltinFunctionOverloadMapper.cs | 0 .../Runtime/Types/BuiltinMethodDescriptor.cs | 0 .../Runtime/Types/CachedNewTypeInfo.cs | 0 .../Runtime/Types/ConstructorFunction.cs | 0 .../Runtime/Types/CustomAttributeTracker.cs | 0 .../Types/CustomInstanceDictionaryStorage.cs | 0 .../Runtime/Types/DocBuilder.cs | 0 .../Runtime/Types/DynamicBaseTypeAttribute.cs | 0 .../Runtime/Types/DynamicHelpers.cs | 0 .../Runtime/Types/EmptyType.cs | 0 .../Runtime/Types/ExtensionPropertyInfo.cs | 0 .../Runtime/Types/FunctionType.cs | 0 .../Runtime/Types/IPythonObject.cs | 0 .../Runtime/Types/InstanceCreator.cs | 0 .../Runtime/Types/MappingProxy.cs | 0 .../Runtime/Types/Mro.cs | 0 .../Runtime/Types/NameConverter.cs | 0 .../Runtime/Types/NewTypeInfo.cs | 0 .../Runtime/Types/NewTypeMaker.cs | 0 .../Runtime/Types/OperatorMapping.cs | 0 .../Runtime/Types/ParameterInfoWrapper.cs | 0 .../Runtime/Types/PythonAssemblyOps.cs | 0 .../Runtime/Types/PythonSiteCache.cs | 0 .../Runtime/Types/PythonType.Generated.cs | 0 .../Runtime/Types/PythonType.cs | 0 .../Runtime/Types/PythonTypeDataSlot.cs | 0 .../Runtime/Types/PythonTypeDictSlot.cs | 0 .../Runtime/Types/PythonTypeInfo.Generated.cs | 0 .../Runtime/Types/PythonTypeInfo.cs | 0 .../Runtime/Types/PythonTypeSlot.cs | 0 .../Runtime/Types/PythonTypeTypeSlot.cs | 0 .../Types/PythonTypeUserDescriptorSlot.cs | 0 .../Runtime/Types/PythonTypeWeakRefSlot.cs | 0 .../Runtime/Types/ReflectedEvent.cs | 0 .../Types/ReflectedExtensionProperty.cs | 0 .../Runtime/Types/ReflectedField.cs | 0 .../Runtime/Types/ReflectedGetterSetter.cs | 0 .../Runtime/Types/ReflectedIndexer.cs | 0 .../Runtime/Types/ReflectedProperty.cs | 0 .../Runtime/Types/ReflectedSlotProperty.cs | 0 .../Runtime/Types/ResolvedMember.cs | 0 .../Runtime/Types/SlotFieldAttribute.cs | 0 .../Types/StaticUnderlyingSystemType.cs | 0 .../Runtime/Types/TypeCache.Generated.cs | 0 .../Runtime/UnboundNameException.cs | 0 .../Runtime/WeakRef.cs | 0 .../Runtime/WrapperDescriptorAttribute.cs | 0 .../Runtime/WrapperDictionary.cs | 0 {Src/IronPython => IronPython}/Runtime/Zip.cs | 0 .../SerializationStubs.cs | 0 .../StringExtensions.cs | 0 .../SystemRuntimeVersioning.cs | 0 .../policy.IronPython.config | 0 .../IronPython.Modules.csproj | 4 +-- {Src/Modules => Modules}/IterTools.cs | 0 {Src/Modules => Modules}/ModuleOps.cs | 0 {Src/Modules => Modules}/NtSignalState.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../ResourceMetaPathImporter.cs | 0 {Src/Modules => Modules}/SimpleSignalState.cs | 0 {Src/Modules => Modules}/_bisect.cs | 0 {Src/Modules => Modules}/_codecs.cs | 0 {Src/Modules => Modules}/_codecs_cn.cs | 0 {Src/Modules => Modules}/_collections.cs | 0 {Src/Modules => Modules}/_csv.cs | 0 {Src/Modules => Modules}/_ctypes/Array.cs | 0 {Src/Modules => Modules}/_ctypes/ArrayType.cs | 0 {Src/Modules => Modules}/_ctypes/CData.cs | 0 {Src/Modules => Modules}/_ctypes/CFuncPtr.cs | 0 .../_ctypes/CFuncPtrType.cs | 0 .../Modules => Modules}/_ctypes/Extensions.cs | 0 {Src/Modules => Modules}/_ctypes/Field.cs | 0 .../_ctypes/INativeType.cs | 0 .../Modules => Modules}/_ctypes/LocalOrArg.cs | 0 .../_ctypes/MarshalCleanup.cs | 0 .../_ctypes/MemoryHolder.cs | 0 .../_ctypes/NativeArgument.cs | 0 .../_ctypes/NativeFunctions.cs | 0 {Src/Modules => Modules}/_ctypes/Pointer.cs | 0 .../_ctypes/PointerType.cs | 0 .../_ctypes/SimpleCData.cs | 0 .../Modules => Modules}/_ctypes/SimpleType.cs | 0 .../_ctypes/SimpleTypeKind.cs | 0 .../Modules => Modules}/_ctypes/StructType.cs | 0 {Src/Modules => Modules}/_ctypes/Structure.cs | 0 {Src/Modules => Modules}/_ctypes/Union.cs | 0 {Src/Modules => Modules}/_ctypes/UnionType.cs | 0 {Src/Modules => Modules}/_ctypes/_ctypes.cs | 0 {Src/Modules => Modules}/_ctypes_test.cs | 0 {Src/Modules => Modules}/_datetime.cs | 0 {Src/Modules => Modules}/_functools.cs | 0 {Src/Modules => Modules}/_heapq.cs | 0 {Src/Modules => Modules}/_multibytecodec.cs | 0 {Src/Modules => Modules}/_multiprocessing.cs | 0 {Src/Modules => Modules}/_opcode.cs | 0 {Src/Modules => Modules}/_operator.cs | 0 {Src/Modules => Modules}/_overlapped.cs | 0 {Src/Modules => Modules}/_pickle.cs | 0 {Src/Modules => Modules}/_posixsubprocess.cs | 0 {Src/Modules => Modules}/_random.RandomGen.cs | 0 {Src/Modules => Modules}/_random.cs | 0 {Src/Modules => Modules}/_socket.cs | 0 {Src/Modules => Modules}/_sre.cs | 0 {Src/Modules => Modules}/_ssl.cs | 0 {Src/Modules => Modules}/_string.cs | 0 {Src/Modules => Modules}/_struct.cs | 0 {Src/Modules => Modules}/_sysconfigdata.cs | 0 {Src/Modules => Modules}/_thread.cs | 0 {Src/Modules => Modules}/_warnings.cs | 0 .../Modules => Modules}/_weakref.Generated.cs | 0 {Src/Modules => Modules}/_weakref.cs | 0 {Src/Modules => Modules}/_winapi.cs | 0 {Src/Modules => Modules}/array.cs | 0 {Src/Modules => Modules}/atexit.cs | 0 {Src/Modules => Modules}/audioop.cs | 0 {Src/Modules => Modules}/binascii.cs | 0 {Src/Modules => Modules}/bz2/BZ2Compressor.cs | 0 .../bz2/BZ2Decompressor.cs | 0 {Src/Modules => Modules}/bz2/BZ2Module.cs | 0 .../bz2/dotnetzip/BZip2/BZip2Compressor.cs | 0 .../bz2/dotnetzip/BZip2/BZip2InputStream.cs | 0 .../bz2/dotnetzip/BZip2/BZip2OutputStream.cs | 0 .../bz2/dotnetzip/BZip2/BitWriter.cs | 0 .../bz2/dotnetzip/BZip2/CRC32.cs | 0 .../BZip2/ParallelBZip2OutputStream.cs | 0 .../bz2/dotnetzip/BZip2/Rand.cs | 0 .../bz2/dotnetzip/source.txt | 0 {Src/Modules => Modules}/cmath.cs | 0 {Src/Modules => Modules}/errno.cs | 0 {Src/Modules => Modules}/faulthandler.cs | 0 {Src/Modules => Modules}/fcntl.cs | 0 {Src/Modules => Modules}/gc.cs | 0 {Src/Modules => Modules}/grp.cs | 0 .../hashlib/MD5CryptoServiceProvider.cs | 0 .../hashlib/SHA1CryptoServiceProvider.cs | 0 {Src/Modules => Modules}/hashlib/SHA224.cs | 0 .../hashlib/SHA224Managed.cs | 0 .../hashlib/SHA256Managed.cs | 0 .../hashlib/SHA384Managed.cs | 0 .../hashlib/SHA512Managed.cs | 0 .../hashlib/SHAConstants.cs | 0 {Src/Modules => Modules}/hashlib/_hashlib.cs | 0 {Src/Modules => Modules}/hashlib/_md5.cs | 0 {Src/Modules => Modules}/hashlib/_sha1.cs | 0 {Src/Modules => Modules}/hashlib/_sha256.cs | 0 {Src/Modules => Modules}/hashlib/_sha512.cs | 0 {Src/Modules => Modules}/marshal.cs | 0 {Src/Modules => Modules}/math.Generated.cs | 0 {Src/Modules => Modules}/math.cs | 0 {Src/Modules => Modules}/mmap.cs | 0 {Src/Modules => Modules}/msvcrt.cs | 0 {Src/Modules => Modules}/nt.cs | 0 .../policy.IronPython.Modules.config | 0 {Src/Modules => Modules}/pwd.cs | 0 {Src/Modules => Modules}/pyexpat.cs | 0 {Src/Modules => Modules}/re.cs | 0 {Src/Modules => Modules}/resource.cs | 0 {Src/Modules => Modules}/select.cs | 0 {Src/Modules => Modules}/signal.cs | 0 {Src/Modules => Modules}/spwd.cs | 0 {Src/Modules => Modules}/time.cs | 0 {Src/Modules => Modules}/winreg.cs | 0 {Src/Modules => Modules}/winsound.cs | 0 {Src/Modules => Modules}/xxsubtype.cs | 0 {Src/Modules => Modules}/zipimport.cs | 0 {Src/Modules => Modules}/zlib/Compress.cs | 0 {Src/Modules => Modules}/zlib/Decompress.cs | 0 {Src/Modules => Modules}/zlib/ZlibModule.cs | 0 .../zlib/zlib.net/Adler32.cs | 0 .../zlib/zlib.net/Deflate.cs | 0 .../zlib/zlib.net/InfBlocks.cs | 0 .../zlib/zlib.net/InfCodes.cs | 0 .../zlib/zlib.net/InfTree.cs | 0 .../zlib/zlib.net/Inflate.cs | 0 .../zlib/zlib.net/StaticTree.cs | 0 .../Modules => Modules}/zlib/zlib.net/Tree.cs | 0 .../zlib/zlib.net/ZStream.cs | 0 .../zlib/zlib.net/ZStreamException.cs | 0 .../Modules => Modules}/zlib/zlib.net/Zlib.cs | 0 .../zlib/zlib.net/history.txt | 0 .../zlib/zlib.net/license.txt | 0 .../zlib/zlib.net/readme.txt | 0 {Src/SQLite => SQLite}/Connection.cs | 0 {Src/SQLite => SQLite}/Contants.cs | 0 {Src/SQLite => SQLite}/Cursor.cs | 0 {Src/SQLite => SQLite}/Exceptions.cs | 0 {Src/SQLite => SQLite}/Extensions.cs | 0 .../IronPython.SQLite.csproj | 0 .../Properties/AssemblyInfo.cs | 0 {Src/SQLite => SQLite}/Row.cs | 0 {Src/SQLite => SQLite}/Statement.cs | 0 {Src/SQLite => SQLite}/Util.cs | 0 {Src/SQLite => SQLite}/_sqlite.cs | 0 {Src/SQLite => SQLite}/c#sqlite/.editorconfig | 0 {Src/SQLite => SQLite}/c#sqlite/BtreeInt_h.cs | 0 {Src/SQLite => SQLite}/c#sqlite/Btree_h.cs | 0 {Src/SQLite => SQLite}/c#sqlite/Delegates.cs | 0 {Src/SQLite => SQLite}/c#sqlite/Hash_h.cs | 0 {Src/SQLite => SQLite}/c#sqlite/VdbeInt_h.cs | 0 {Src/SQLite => SQLite}/c#sqlite/Vdbe_h.cs | 0 {Src/SQLite => SQLite}/c#sqlite/_Custom.cs | 0 {Src/SQLite => SQLite}/c#sqlite/alter_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/analyze_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/attach_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/auth_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/backup_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/bitvec_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/btmutex_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/btree_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/build_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/callback_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/complete_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/crypto.cs | 0 {Src/SQLite => SQLite}/c#sqlite/ctime_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/date_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/delete_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/expr_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/fault_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/fkey_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/func_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/global_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/hash_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/hwtime_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/insert_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/journal_c.cs | 0 .../c#sqlite/keywordhash_h.cs | 0 {Src/SQLite => SQLite}/c#sqlite/legacy_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/loadext_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/main_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/malloc_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/mem_Pool.cs | 0 .../c#sqlite/memjournal_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/mutex_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/mutex_h.cs | 0 .../c#sqlite/mutex_noop_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/mutex_w32.cs | 0 {Src/SQLite => SQLite}/c#sqlite/notify_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/opcodes_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/opcodes_h.cs | 0 {Src/SQLite => SQLite}/c#sqlite/os_c.cs | 0 .../SQLite => SQLite}/c#sqlite/os_common_h.cs | 0 {Src/SQLite => SQLite}/c#sqlite/os_h.cs | 0 {Src/SQLite => SQLite}/c#sqlite/os_win_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/pager_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/pager_h.cs | 0 {Src/SQLite => SQLite}/c#sqlite/parse_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/parse_h.cs | 0 {Src/SQLite => SQLite}/c#sqlite/pcache1_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/pcache_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/pcache_h.cs | 0 {Src/SQLite => SQLite}/c#sqlite/pragma_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/prepare_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/printf_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/random_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/resolve_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/rowset_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/select_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/sqlite3_h.cs | 0 .../SQLite => SQLite}/c#sqlite/sqliteInt_h.cs | 0 .../c#sqlite/sqliteLimit_h.cs | 0 {Src/SQLite => SQLite}/c#sqlite/status_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/table_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/tokenize_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/trigger_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/update_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/utf_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/util_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/vacuum_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/vdbe_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/vdbeapi_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/vdbeaux_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/vdbeblob_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/vdbemem_c.cs | 0 .../SQLite => SQLite}/c#sqlite/vdbetrace_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/vtab_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/wal_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/wal_h.cs | 0 {Src/SQLite => SQLite}/c#sqlite/walker_c.cs | 0 {Src/SQLite => SQLite}/c#sqlite/where_c.cs | 0 {Src/Scripts => Scripts}/CompareDirs.py | 0 .../Enter-IronPythonEnvironment.ps1 | 0 .../Install-IronPython.ps1 | 0 {Src/Scripts => Scripts}/clean.py | 0 {Src/Scripts => Scripts}/copyrights.py | 0 {Src/Scripts => Scripts}/generate.py | 0 .../generate_UncollectableCompilationMode.py | 0 {Src/Scripts => Scripts}/generate_alltypes.py | 0 {Src/Scripts => Scripts}/generate_calls.py | 0 {Src/Scripts => Scripts}/generate_casts.py | 0 .../generate_comdispatch.py | 0 .../generate_dict_views.py | 0 .../generate_dynamic_instructions.py | 0 {Src/Scripts => Scripts}/generate_dynsites.py | 0 .../generate_encoding_aliases.py | 0 .../generate_exception_factory.py | 0 .../generate_exceptions.py | 0 .../generate_indicestest.py | 0 {Src/Scripts => Scripts}/generate_math.py | 0 {Src/Scripts => Scripts}/generate_ops.py | 0 {Src/Scripts => Scripts}/generate_os_codes.py | 0 .../generate_reflected_calls.py | 0 {Src/Scripts => Scripts}/generate_set.py | 0 {Src/Scripts => Scripts}/generate_tuples.py | 0 .../Scripts => Scripts}/generate_typecache.py | 0 {Src/Scripts => Scripts}/generate_walker.py | 0 {Src/Scripts => Scripts}/ipcom.ps1 | 0 {Src/Scripts => Scripts}/make_meta1.py | 0 {Src/Scripts => Scripts}/radix_generator.py | 0 {Src/Scripts => Scripts}/run_compiled.py | 0 {Src/Scripts => Scripts}/run_interactive.py | 0 {Src/Scripts => Scripts}/smtpmailer.py | 0 {Src/Scripts => Scripts}/test_builder.py | 0 {Src/Scripts => Scripts}/test_cgcheck.py | 0 {Src/Scripts => Scripts}/test_parrot.py | 0 {Src/Scripts => Scripts}/test_pystone.py | 0 {Src/StdLib => StdLib}/.gitattributes | 0 {Src/StdLib => StdLib}/Lib/__future__.py | 0 {Src/StdLib => StdLib}/Lib/__phello__.foo.py | 0 {Src/StdLib => StdLib}/Lib/_bootlocale.py | 0 .../StdLib => StdLib}/Lib/_collections_abc.py | 0 {Src/StdLib => StdLib}/Lib/_compat_pickle.py | 0 {Src/StdLib => StdLib}/Lib/_dummy_thread.py | 0 {Src/StdLib => StdLib}/Lib/_markupbase.py | 0 {Src/StdLib => StdLib}/Lib/_osx_support.py | 0 {Src/StdLib => StdLib}/Lib/_pyio.py | 0 {Src/StdLib => StdLib}/Lib/_sitebuiltins.py | 0 {Src/StdLib => StdLib}/Lib/_strptime.py | 0 .../StdLib => StdLib}/Lib/_threading_local.py | 0 {Src/StdLib => StdLib}/Lib/_weakrefset.py | 0 {Src/StdLib => StdLib}/Lib/abc.py | 0 {Src/StdLib => StdLib}/Lib/aifc.py | 0 {Src/StdLib => StdLib}/Lib/antigravity.py | 0 {Src/StdLib => StdLib}/Lib/argparse.py | 0 {Src/StdLib => StdLib}/Lib/ast.py | 0 {Src/StdLib => StdLib}/Lib/asynchat.py | 0 .../StdLib => StdLib}/Lib/asyncio/__init__.py | 0 .../Lib/asyncio/base_events.py | 0 .../Lib/asyncio/base_subprocess.py | 0 {Src/StdLib => StdLib}/Lib/asyncio/compat.py | 0 .../Lib/asyncio/constants.py | 0 .../Lib/asyncio/coroutines.py | 0 {Src/StdLib => StdLib}/Lib/asyncio/events.py | 0 {Src/StdLib => StdLib}/Lib/asyncio/futures.py | 0 {Src/StdLib => StdLib}/Lib/asyncio/locks.py | 0 {Src/StdLib => StdLib}/Lib/asyncio/log.py | 0 .../Lib/asyncio/proactor_events.py | 0 .../Lib/asyncio/protocols.py | 0 {Src/StdLib => StdLib}/Lib/asyncio/queues.py | 0 .../Lib/asyncio/selector_events.py | 0 .../StdLib => StdLib}/Lib/asyncio/sslproto.py | 0 {Src/StdLib => StdLib}/Lib/asyncio/streams.py | 0 .../Lib/asyncio/subprocess.py | 0 {Src/StdLib => StdLib}/Lib/asyncio/tasks.py | 0 .../Lib/asyncio/test_utils.py | 0 .../Lib/asyncio/transports.py | 0 .../Lib/asyncio/unix_events.py | 0 .../Lib/asyncio/windows_events.py | 0 .../Lib/asyncio/windows_utils.py | 0 {Src/StdLib => StdLib}/Lib/asyncore.py | 0 {Src/StdLib => StdLib}/Lib/base64.py | 0 {Src/StdLib => StdLib}/Lib/bdb.py | 0 {Src/StdLib => StdLib}/Lib/binhex.py | 0 {Src/StdLib => StdLib}/Lib/bisect.py | 0 {Src/StdLib => StdLib}/Lib/bz2.py | 0 {Src/StdLib => StdLib}/Lib/cProfile.py | 0 {Src/StdLib => StdLib}/Lib/calendar.py | 0 {Src/StdLib => StdLib}/Lib/cgi.py | 0 {Src/StdLib => StdLib}/Lib/cgitb.py | 0 {Src/StdLib => StdLib}/Lib/chunk.py | 0 {Src/StdLib => StdLib}/Lib/clrtype.py | 0 {Src/StdLib => StdLib}/Lib/cmd.py | 0 {Src/StdLib => StdLib}/Lib/code.py | 0 {Src/StdLib => StdLib}/Lib/codecs.py | 0 {Src/StdLib => StdLib}/Lib/codeop.py | 0 .../Lib/collections/__init__.py | 0 .../Lib/collections/__main__.py | 0 {Src/StdLib => StdLib}/Lib/collections/abc.py | 0 {Src/StdLib => StdLib}/Lib/colorsys.py | 0 {Src/StdLib => StdLib}/Lib/compileall.py | 0 .../Lib/concurrent/__init__.py | 0 .../Lib/concurrent/futures/__init__.py | 0 .../Lib/concurrent/futures/_base.py | 0 .../Lib/concurrent/futures/process.py | 0 .../Lib/concurrent/futures/thread.py | 0 {Src/StdLib => StdLib}/Lib/configparser.py | 0 {Src/StdLib => StdLib}/Lib/contextlib.py | 0 {Src/StdLib => StdLib}/Lib/copy.py | 0 {Src/StdLib => StdLib}/Lib/copyreg.py | 0 {Src/StdLib => StdLib}/Lib/crypt.py | 0 {Src/StdLib => StdLib}/Lib/csv.py | 0 {Src/StdLib => StdLib}/Lib/ctypes/__init__.py | 0 {Src/StdLib => StdLib}/Lib/ctypes/_endian.py | 0 .../Lib/ctypes/macholib/README.ctypes | 0 .../Lib/ctypes/macholib/__init__.py | 0 .../Lib/ctypes/macholib/dyld.py | 0 .../Lib/ctypes/macholib/dylib.py | 0 .../Lib/ctypes/macholib/fetch_macholib | 0 .../Lib/ctypes/macholib/fetch_macholib.bat | 0 .../Lib/ctypes/macholib/framework.py | 0 .../Lib/ctypes/test/__init__.py | 0 .../Lib/ctypes/test/__main__.py | 0 .../Lib/ctypes/test/test_anon.py | 0 .../Lib/ctypes/test/test_array_in_pointer.py | 0 .../Lib/ctypes/test/test_arrays.py | 0 .../Lib/ctypes/test/test_as_parameter.py | 0 .../Lib/ctypes/test/test_bitfields.py | 0 .../Lib/ctypes/test/test_buffers.py | 0 .../Lib/ctypes/test/test_bytes.py | 0 .../Lib/ctypes/test/test_byteswap.py | 0 .../Lib/ctypes/test/test_callbacks.py | 0 .../Lib/ctypes/test/test_cast.py | 0 .../Lib/ctypes/test/test_cfuncs.py | 0 .../Lib/ctypes/test/test_checkretval.py | 0 .../Lib/ctypes/test/test_delattr.py | 0 .../Lib/ctypes/test/test_errno.py | 0 .../Lib/ctypes/test/test_find.py | 0 .../Lib/ctypes/test/test_frombuffer.py | 0 .../Lib/ctypes/test/test_funcptr.py | 0 .../Lib/ctypes/test/test_functions.py | 0 .../Lib/ctypes/test/test_incomplete.py | 0 .../Lib/ctypes/test/test_init.py | 0 .../Lib/ctypes/test/test_internals.py | 0 .../Lib/ctypes/test/test_keeprefs.py | 0 .../Lib/ctypes/test/test_libc.py | 0 .../Lib/ctypes/test/test_loading.py | 0 .../Lib/ctypes/test/test_macholib.py | 0 .../Lib/ctypes/test/test_memfunctions.py | 0 .../Lib/ctypes/test/test_numbers.py | 0 .../Lib/ctypes/test/test_objects.py | 0 .../Lib/ctypes/test/test_parameters.py | 0 .../Lib/ctypes/test/test_pep3118.py | 0 .../Lib/ctypes/test/test_pickling.py | 0 .../Lib/ctypes/test/test_pointers.py | 0 .../Lib/ctypes/test/test_prototypes.py | 0 .../Lib/ctypes/test/test_python_api.py | 0 .../Lib/ctypes/test/test_random_things.py | 0 .../Lib/ctypes/test/test_refcounts.py | 0 .../Lib/ctypes/test/test_repr.py | 0 .../Lib/ctypes/test/test_returnfuncptrs.py | 0 .../Lib/ctypes/test/test_simplesubclasses.py | 0 .../Lib/ctypes/test/test_sizes.py | 0 .../Lib/ctypes/test/test_slicing.py | 0 .../Lib/ctypes/test/test_stringptr.py | 0 .../Lib/ctypes/test/test_strings.py | 0 .../Lib/ctypes/test/test_struct_fields.py | 0 .../Lib/ctypes/test/test_structures.py | 0 .../ctypes/test/test_unaligned_structures.py | 0 .../Lib/ctypes/test/test_unicode.py | 0 .../Lib/ctypes/test/test_values.py | 0 .../Lib/ctypes/test/test_varsize_struct.py | 0 .../Lib/ctypes/test/test_win32.py | 0 .../Lib/ctypes/test/test_wintypes.py | 0 {Src/StdLib => StdLib}/Lib/ctypes/util.py | 0 {Src/StdLib => StdLib}/Lib/ctypes/wintypes.py | 0 {Src/StdLib => StdLib}/Lib/curses/__init__.py | 0 {Src/StdLib => StdLib}/Lib/curses/ascii.py | 0 {Src/StdLib => StdLib}/Lib/curses/has_key.py | 0 {Src/StdLib => StdLib}/Lib/curses/panel.py | 0 {Src/StdLib => StdLib}/Lib/curses/textpad.py | 0 {Src/StdLib => StdLib}/Lib/datetime.py | 0 {Src/StdLib => StdLib}/Lib/dbm/__init__.py | 0 {Src/StdLib => StdLib}/Lib/dbm/dumb.py | 0 {Src/StdLib => StdLib}/Lib/dbm/gnu.py | 0 {Src/StdLib => StdLib}/Lib/dbm/ndbm.py | 0 {Src/StdLib => StdLib}/Lib/decimal.py | 0 {Src/StdLib => StdLib}/Lib/difflib.py | 0 {Src/StdLib => StdLib}/Lib/dis.py | 0 {Src/StdLib => StdLib}/Lib/distutils/README | 0 .../Lib/distutils/__init__.py | 0 .../Lib/distutils/archive_util.py | 0 .../Lib/distutils/bcppcompiler.py | 0 .../Lib/distutils/ccompiler.py | 0 {Src/StdLib => StdLib}/Lib/distutils/cmd.py | 0 .../Lib/distutils/command/__init__.py | 0 .../Lib/distutils/command/bdist.py | 0 .../Lib/distutils/command/bdist_dumb.py | 0 .../Lib/distutils/command/bdist_msi.py | 0 .../Lib/distutils/command/bdist_rpm.py | 0 .../Lib/distutils/command/bdist_wininst.py | 0 .../Lib/distutils/command/build.py | 0 .../Lib/distutils/command/build_clib.py | 0 .../Lib/distutils/command/build_ext.py | 0 .../Lib/distutils/command/build_py.py | 0 .../Lib/distutils/command/build_scripts.py | 0 .../Lib/distutils/command/check.py | 0 .../Lib/distutils/command/clean.py | 0 .../Lib/distutils/command/command_template | 0 .../Lib/distutils/command/config.py | 0 .../Lib/distutils/command/install.py | 0 .../Lib/distutils/command/install_data.py | 0 .../Lib/distutils/command/install_egg_info.py | 0 .../Lib/distutils/command/install_headers.py | 0 .../Lib/distutils/command/install_lib.py | 0 .../Lib/distutils/command/install_scripts.py | 0 .../Lib/distutils/command/register.py | 0 .../Lib/distutils/command/sdist.py | 0 .../Lib/distutils/command/upload.py | 0 .../distutils/command/wininst-10.0-amd64.exe | Bin .../Lib/distutils/command/wininst-10.0.exe | Bin .../Lib/distutils/command/wininst-6.0.exe | Bin .../Lib/distutils/command/wininst-7.1.exe | Bin .../Lib/distutils/command/wininst-8.0.exe | Bin .../distutils/command/wininst-9.0-amd64.exe | Bin .../Lib/distutils/command/wininst-9.0.exe | Bin .../StdLib => StdLib}/Lib/distutils/config.py | 0 {Src/StdLib => StdLib}/Lib/distutils/core.py | 0 .../Lib/distutils/cygwinccompiler.py | 0 {Src/StdLib => StdLib}/Lib/distutils/debug.py | 0 .../Lib/distutils/dep_util.py | 0 .../Lib/distutils/dir_util.py | 0 {Src/StdLib => StdLib}/Lib/distutils/dist.py | 0 .../StdLib => StdLib}/Lib/distutils/errors.py | 0 .../Lib/distutils/extension.py | 0 .../Lib/distutils/fancy_getopt.py | 0 .../Lib/distutils/file_util.py | 0 .../Lib/distutils/filelist.py | 0 {Src/StdLib => StdLib}/Lib/distutils/log.py | 0 .../Lib/distutils/msvc9compiler.py | 0 .../Lib/distutils/msvccompiler.py | 0 {Src/StdLib => StdLib}/Lib/distutils/spawn.py | 0 .../Lib/distutils/sysconfig.py | 0 .../Lib/distutils/tests/Setup.sample | 0 .../Lib/distutils/tests/__init__.py | 0 .../Lib/distutils/tests/support.py | 0 .../Lib/distutils/tests/test_archive_util.py | 0 .../Lib/distutils/tests/test_bdist.py | 0 .../Lib/distutils/tests/test_bdist_dumb.py | 0 .../Lib/distutils/tests/test_bdist_msi.py | 0 .../Lib/distutils/tests/test_bdist_rpm.py | 0 .../Lib/distutils/tests/test_bdist_wininst.py | 0 .../Lib/distutils/tests/test_build.py | 0 .../Lib/distutils/tests/test_build_clib.py | 0 .../Lib/distutils/tests/test_build_ext.py | 0 .../Lib/distutils/tests/test_build_py.py | 0 .../Lib/distutils/tests/test_build_scripts.py | 0 .../Lib/distutils/tests/test_check.py | 0 .../Lib/distutils/tests/test_clean.py | 0 .../Lib/distutils/tests/test_cmd.py | 0 .../Lib/distutils/tests/test_config.py | 0 .../Lib/distutils/tests/test_config_cmd.py | 0 .../Lib/distutils/tests/test_core.py | 0 .../distutils/tests/test_cygwinccompiler.py | 0 .../Lib/distutils/tests/test_dep_util.py | 0 .../Lib/distutils/tests/test_dir_util.py | 0 .../Lib/distutils/tests/test_dist.py | 0 .../Lib/distutils/tests/test_extension.py | 0 .../Lib/distutils/tests/test_file_util.py | 0 .../Lib/distutils/tests/test_filelist.py | 0 .../Lib/distutils/tests/test_install.py | 0 .../Lib/distutils/tests/test_install_data.py | 0 .../distutils/tests/test_install_headers.py | 0 .../Lib/distutils/tests/test_install_lib.py | 0 .../distutils/tests/test_install_scripts.py | 0 .../Lib/distutils/tests/test_log.py | 0 .../Lib/distutils/tests/test_msvc9compiler.py | 0 .../Lib/distutils/tests/test_register.py | 0 .../Lib/distutils/tests/test_sdist.py | 0 .../Lib/distutils/tests/test_spawn.py | 0 .../Lib/distutils/tests/test_sysconfig.py | 0 .../Lib/distutils/tests/test_text_file.py | 0 .../Lib/distutils/tests/test_unixccompiler.py | 0 .../Lib/distutils/tests/test_upload.py | 0 .../Lib/distutils/tests/test_util.py | 0 .../Lib/distutils/tests/test_version.py | 0 .../distutils/tests/test_versionpredicate.py | 0 .../Lib/distutils/text_file.py | 0 .../Lib/distutils/unixccompiler.py | 0 {Src/StdLib => StdLib}/Lib/distutils/util.py | 0 .../Lib/distutils/version.py | 0 .../Lib/distutils/versionpredicate.py | 0 {Src/StdLib => StdLib}/Lib/doctest.py | 0 {Src/StdLib => StdLib}/Lib/dummy_threading.py | 0 {Src/StdLib => StdLib}/Lib/email/__init__.py | 0 .../Lib/email/_encoded_words.py | 0 .../Lib/email/_header_value_parser.py | 0 .../StdLib => StdLib}/Lib/email/_parseaddr.py | 0 .../Lib/email/_policybase.py | 0 .../Lib/email/architecture.rst | 0 .../StdLib => StdLib}/Lib/email/base64mime.py | 0 {Src/StdLib => StdLib}/Lib/email/charset.py | 0 .../Lib/email/contentmanager.py | 0 {Src/StdLib => StdLib}/Lib/email/encoders.py | 0 {Src/StdLib => StdLib}/Lib/email/errors.py | 0 .../StdLib => StdLib}/Lib/email/feedparser.py | 0 {Src/StdLib => StdLib}/Lib/email/generator.py | 0 {Src/StdLib => StdLib}/Lib/email/header.py | 0 .../Lib/email/headerregistry.py | 0 {Src/StdLib => StdLib}/Lib/email/iterators.py | 0 {Src/StdLib => StdLib}/Lib/email/message.py | 0 .../Lib/email/mime/__init__.py | 0 .../Lib/email/mime/application.py | 0 .../StdLib => StdLib}/Lib/email/mime/audio.py | 0 {Src/StdLib => StdLib}/Lib/email/mime/base.py | 0 .../StdLib => StdLib}/Lib/email/mime/image.py | 0 .../Lib/email/mime/message.py | 0 .../Lib/email/mime/multipart.py | 0 .../Lib/email/mime/nonmultipart.py | 0 {Src/StdLib => StdLib}/Lib/email/mime/text.py | 0 {Src/StdLib => StdLib}/Lib/email/parser.py | 0 {Src/StdLib => StdLib}/Lib/email/policy.py | 0 .../StdLib => StdLib}/Lib/email/quoprimime.py | 0 {Src/StdLib => StdLib}/Lib/email/utils.py | 0 .../Lib/encodings/__init__.py | 0 .../Lib/encodings/aliases.py | 0 {Src/StdLib => StdLib}/Lib/encodings/ascii.py | 0 .../Lib/encodings/base64_codec.py | 0 {Src/StdLib => StdLib}/Lib/encodings/big5.py | 0 .../Lib/encodings/big5hkscs.py | 0 .../Lib/encodings/bz2_codec.py | 0 .../Lib/encodings/charmap.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp037.py | 0 .../StdLib => StdLib}/Lib/encodings/cp1006.py | 0 .../StdLib => StdLib}/Lib/encodings/cp1026.py | 0 .../StdLib => StdLib}/Lib/encodings/cp1125.py | 0 .../StdLib => StdLib}/Lib/encodings/cp1140.py | 0 .../StdLib => StdLib}/Lib/encodings/cp1250.py | 0 .../StdLib => StdLib}/Lib/encodings/cp1251.py | 0 .../StdLib => StdLib}/Lib/encodings/cp1252.py | 0 .../StdLib => StdLib}/Lib/encodings/cp1253.py | 0 .../StdLib => StdLib}/Lib/encodings/cp1254.py | 0 .../StdLib => StdLib}/Lib/encodings/cp1255.py | 0 .../StdLib => StdLib}/Lib/encodings/cp1256.py | 0 .../StdLib => StdLib}/Lib/encodings/cp1257.py | 0 .../StdLib => StdLib}/Lib/encodings/cp1258.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp273.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp424.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp437.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp500.py | 0 .../Lib/encodings/cp65001.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp720.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp737.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp775.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp850.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp852.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp855.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp856.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp857.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp858.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp860.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp861.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp862.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp863.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp864.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp865.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp866.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp869.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp874.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp875.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp932.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp949.py | 0 {Src/StdLib => StdLib}/Lib/encodings/cp950.py | 0 .../Lib/encodings/euc_jis_2004.py | 0 .../Lib/encodings/euc_jisx0213.py | 0 .../StdLib => StdLib}/Lib/encodings/euc_jp.py | 0 .../StdLib => StdLib}/Lib/encodings/euc_kr.py | 0 .../Lib/encodings/gb18030.py | 0 .../StdLib => StdLib}/Lib/encodings/gb2312.py | 0 {Src/StdLib => StdLib}/Lib/encodings/gbk.py | 0 .../Lib/encodings/hex_codec.py | 0 .../Lib/encodings/hp_roman8.py | 0 {Src/StdLib => StdLib}/Lib/encodings/hz.py | 0 {Src/StdLib => StdLib}/Lib/encodings/idna.py | 0 .../Lib/encodings/iso2022_jp.py | 0 .../Lib/encodings/iso2022_jp_1.py | 0 .../Lib/encodings/iso2022_jp_2.py | 0 .../Lib/encodings/iso2022_jp_2004.py | 0 .../Lib/encodings/iso2022_jp_3.py | 0 .../Lib/encodings/iso2022_jp_ext.py | 0 .../Lib/encodings/iso2022_kr.py | 0 .../Lib/encodings/iso8859_1.py | 0 .../Lib/encodings/iso8859_10.py | 0 .../Lib/encodings/iso8859_11.py | 0 .../Lib/encodings/iso8859_13.py | 0 .../Lib/encodings/iso8859_14.py | 0 .../Lib/encodings/iso8859_15.py | 0 .../Lib/encodings/iso8859_16.py | 0 .../Lib/encodings/iso8859_2.py | 0 .../Lib/encodings/iso8859_3.py | 0 .../Lib/encodings/iso8859_4.py | 0 .../Lib/encodings/iso8859_5.py | 0 .../Lib/encodings/iso8859_6.py | 0 .../Lib/encodings/iso8859_7.py | 0 .../Lib/encodings/iso8859_8.py | 0 .../Lib/encodings/iso8859_9.py | 0 {Src/StdLib => StdLib}/Lib/encodings/johab.py | 0 .../StdLib => StdLib}/Lib/encodings/koi8_r.py | 0 .../StdLib => StdLib}/Lib/encodings/koi8_u.py | 0 .../Lib/encodings/latin_1.py | 0 .../Lib/encodings/mac_arabic.py | 0 .../Lib/encodings/mac_centeuro.py | 0 .../Lib/encodings/mac_croatian.py | 0 .../Lib/encodings/mac_cyrillic.py | 0 .../Lib/encodings/mac_farsi.py | 0 .../Lib/encodings/mac_greek.py | 0 .../Lib/encodings/mac_iceland.py | 0 .../Lib/encodings/mac_latin2.py | 0 .../Lib/encodings/mac_roman.py | 0 .../Lib/encodings/mac_romanian.py | 0 .../Lib/encodings/mac_turkish.py | 0 {Src/StdLib => StdLib}/Lib/encodings/mbcs.py | 0 .../StdLib => StdLib}/Lib/encodings/palmos.py | 0 .../Lib/encodings/ptcp154.py | 0 .../Lib/encodings/punycode.py | 0 .../Lib/encodings/quopri_codec.py | 0 .../Lib/encodings/raw_unicode_escape.py | 0 .../StdLib => StdLib}/Lib/encodings/rot_13.py | 0 .../Lib/encodings/shift_jis.py | 0 .../Lib/encodings/shift_jis_2004.py | 0 .../Lib/encodings/shift_jisx0213.py | 0 .../Lib/encodings/tis_620.py | 0 .../Lib/encodings/undefined.py | 0 .../Lib/encodings/unicode_escape.py | 0 .../Lib/encodings/unicode_internal.py | 0 .../StdLib => StdLib}/Lib/encodings/utf_16.py | 0 .../Lib/encodings/utf_16_be.py | 0 .../Lib/encodings/utf_16_le.py | 0 .../StdLib => StdLib}/Lib/encodings/utf_32.py | 0 .../Lib/encodings/utf_32_be.py | 0 .../Lib/encodings/utf_32_le.py | 0 {Src/StdLib => StdLib}/Lib/encodings/utf_7.py | 0 {Src/StdLib => StdLib}/Lib/encodings/utf_8.py | 0 .../Lib/encodings/utf_8_sig.py | 0 .../Lib/encodings/uu_codec.py | 0 .../Lib/encodings/zlib_codec.py | 0 .../Lib/ensurepip/__init__.py | 0 .../Lib/ensurepip/__main__.py | 0 .../_bundled/pip-18.1-py2.py3-none-any.whl | Bin .../setuptools-40.6.2-py2.py3-none-any.whl | Bin .../Lib/ensurepip/_uninstall.py | 0 {Src/StdLib => StdLib}/Lib/enum.py | 0 {Src/StdLib => StdLib}/Lib/filecmp.py | 0 {Src/StdLib => StdLib}/Lib/fileinput.py | 0 {Src/StdLib => StdLib}/Lib/fnmatch.py | 0 {Src/StdLib => StdLib}/Lib/formatter.py | 0 {Src/StdLib => StdLib}/Lib/fractions.py | 0 {Src/StdLib => StdLib}/Lib/ftplib.py | 0 {Src/StdLib => StdLib}/Lib/functools.py | 0 {Src/StdLib => StdLib}/Lib/genericpath.py | 0 {Src/StdLib => StdLib}/Lib/getopt.py | 0 {Src/StdLib => StdLib}/Lib/getpass.py | 0 {Src/StdLib => StdLib}/Lib/gettext.py | 0 {Src/StdLib => StdLib}/Lib/glob.py | 0 {Src/StdLib => StdLib}/Lib/gzip.py | 0 {Src/StdLib => StdLib}/Lib/hashlib.py | 0 {Src/StdLib => StdLib}/Lib/heapq.py | 0 {Src/StdLib => StdLib}/Lib/hmac.py | 0 {Src/StdLib => StdLib}/Lib/html/__init__.py | 0 {Src/StdLib => StdLib}/Lib/html/entities.py | 0 {Src/StdLib => StdLib}/Lib/html/parser.py | 0 {Src/StdLib => StdLib}/Lib/http/__init__.py | 0 {Src/StdLib => StdLib}/Lib/http/client.py | 0 {Src/StdLib => StdLib}/Lib/http/cookiejar.py | 0 {Src/StdLib => StdLib}/Lib/http/cookies.py | 0 {Src/StdLib => StdLib}/Lib/http/server.py | 0 .../Lib/idlelib/AutoComplete.py | 0 .../Lib/idlelib/AutoCompleteWindow.py | 0 .../Lib/idlelib/AutoExpand.py | 0 .../StdLib => StdLib}/Lib/idlelib/Bindings.py | 0 .../StdLib => StdLib}/Lib/idlelib/CREDITS.txt | 0 .../Lib/idlelib/CallTipWindow.py | 0 .../StdLib => StdLib}/Lib/idlelib/CallTips.py | 0 {Src/StdLib => StdLib}/Lib/idlelib/ChangeLog | 0 .../Lib/idlelib/ClassBrowser.py | 0 .../Lib/idlelib/CodeContext.py | 0 .../Lib/idlelib/ColorDelegator.py | 0 .../StdLib => StdLib}/Lib/idlelib/Debugger.py | 0 .../Lib/idlelib/Delegator.py | 0 .../Lib/idlelib/EditorWindow.py | 0 .../StdLib => StdLib}/Lib/idlelib/FileList.py | 0 .../Lib/idlelib/FormatParagraph.py | 0 .../Lib/idlelib/GrepDialog.py | 0 .../StdLib => StdLib}/Lib/idlelib/HISTORY.txt | 0 .../Lib/idlelib/HyperParser.py | 0 .../Lib/idlelib/IOBinding.py | 0 .../Lib/idlelib/Icons/folder.gif | Bin .../Lib/idlelib/Icons/idle.icns | Bin .../Lib/idlelib/Icons/idle.ico | Bin .../Lib/idlelib/Icons/idle_16.gif | Bin .../Lib/idlelib/Icons/idle_16.png | Bin .../Lib/idlelib/Icons/idle_32.gif | Bin .../Lib/idlelib/Icons/idle_32.png | Bin .../Lib/idlelib/Icons/idle_48.gif | Bin .../Lib/idlelib/Icons/idle_48.png | Bin .../Lib/idlelib/Icons/minusnode.gif | Bin .../Lib/idlelib/Icons/openfolder.gif | Bin .../Lib/idlelib/Icons/plusnode.gif | Bin .../Lib/idlelib/Icons/python.gif | Bin .../Lib/idlelib/Icons/tk.gif | Bin .../Lib/idlelib/IdleHistory.py | 0 .../Lib/idlelib/MultiCall.py | 0 .../Lib/idlelib/MultiStatusBar.py | 0 {Src/StdLib => StdLib}/Lib/idlelib/NEWS.txt | 0 .../Lib/idlelib/ObjectBrowser.py | 0 .../Lib/idlelib/OutputWindow.py | 0 .../Lib/idlelib/ParenMatch.py | 0 .../Lib/idlelib/PathBrowser.py | 0 .../Lib/idlelib/Percolator.py | 0 {Src/StdLib => StdLib}/Lib/idlelib/PyParse.py | 0 {Src/StdLib => StdLib}/Lib/idlelib/PyShell.py | 0 {Src/StdLib => StdLib}/Lib/idlelib/README.txt | 0 .../Lib/idlelib/RemoteDebugger.py | 0 .../Lib/idlelib/RemoteObjectBrowser.py | 0 .../Lib/idlelib/ReplaceDialog.py | 0 .../Lib/idlelib/RstripExtension.py | 0 .../Lib/idlelib/ScriptBinding.py | 0 .../Lib/idlelib/ScrolledList.py | 0 .../Lib/idlelib/SearchDialog.py | 0 .../Lib/idlelib/SearchDialogBase.py | 0 .../Lib/idlelib/SearchEngine.py | 0 .../Lib/idlelib/StackViewer.py | 0 {Src/StdLib => StdLib}/Lib/idlelib/TODO.txt | 0 {Src/StdLib => StdLib}/Lib/idlelib/ToolTip.py | 0 .../Lib/idlelib/TreeWidget.py | 0 .../Lib/idlelib/UndoDelegator.py | 0 .../Lib/idlelib/WidgetRedirector.py | 0 .../Lib/idlelib/WindowList.py | 0 .../Lib/idlelib/ZoomHeight.py | 0 .../StdLib => StdLib}/Lib/idlelib/__init__.py | 0 .../StdLib => StdLib}/Lib/idlelib/__main__.py | 0 .../Lib/idlelib/aboutDialog.py | 0 .../Lib/idlelib/config-extensions.def | 0 .../Lib/idlelib/config-highlight.def | 0 .../Lib/idlelib/config-keys.def | 0 .../Lib/idlelib/config-main.def | 0 .../Lib/idlelib/configDialog.py | 0 .../Lib/idlelib/configHandler.py | 0 .../Lib/idlelib/configHelpSourceEdit.py | 0 .../Lib/idlelib/configSectionNameDialog.py | 0 .../Lib/idlelib/dynOptionMenuWidget.py | 0 {Src/StdLib => StdLib}/Lib/idlelib/extend.txt | 0 {Src/StdLib => StdLib}/Lib/idlelib/help.html | 0 {Src/StdLib => StdLib}/Lib/idlelib/help.py | 0 {Src/StdLib => StdLib}/Lib/idlelib/help.txt | 0 {Src/StdLib => StdLib}/Lib/idlelib/idle.bat | 0 {Src/StdLib => StdLib}/Lib/idlelib/idle.py | 0 {Src/StdLib => StdLib}/Lib/idlelib/idle.pyw | 0 .../Lib/idlelib/idle_test/README.txt | 0 .../Lib/idlelib/idle_test/__init__.py | 0 .../Lib/idlelib/idle_test/htest.py | 0 .../Lib/idlelib/idle_test/mock_idle.py | 0 .../Lib/idlelib/idle_test/mock_tk.py | 0 .../idlelib/idle_test/test_autocomplete.py | 0 .../Lib/idlelib/idle_test/test_autoexpand.py | 0 .../Lib/idlelib/idle_test/test_calltips.py | 0 .../Lib/idlelib/idle_test/test_config_name.py | 0 .../idlelib/idle_test/test_configdialog.py | 0 .../Lib/idlelib/idle_test/test_delegator.py | 0 .../Lib/idlelib/idle_test/test_editor.py | 0 .../idlelib/idle_test/test_formatparagraph.py | 0 .../Lib/idlelib/idle_test/test_grep.py | 0 .../Lib/idlelib/idle_test/test_hyperparser.py | 0 .../Lib/idlelib/idle_test/test_idlehistory.py | 0 .../Lib/idlelib/idle_test/test_io.py | 0 .../Lib/idlelib/idle_test/test_parenmatch.py | 0 .../Lib/idlelib/idle_test/test_pathbrowser.py | 0 .../Lib/idlelib/idle_test/test_rstrip.py | 0 .../idle_test/test_searchdialogbase.py | 0 .../idlelib/idle_test/test_searchengine.py | 0 .../Lib/idlelib/idle_test/test_text.py | 0 .../Lib/idlelib/idle_test/test_textview.py | 0 .../Lib/idlelib/idle_test/test_warning.py | 0 .../Lib/idlelib/idle_test/test_widgetredir.py | 0 {Src/StdLib => StdLib}/Lib/idlelib/idlever.py | 0 .../Lib/idlelib/keybindingDialog.py | 0 .../Lib/idlelib/macosxSupport.py | 0 {Src/StdLib => StdLib}/Lib/idlelib/rpc.py | 0 {Src/StdLib => StdLib}/Lib/idlelib/run.py | 0 .../Lib/idlelib/tabbedpages.py | 0 .../StdLib => StdLib}/Lib/idlelib/textView.py | 0 {Src/StdLib => StdLib}/Lib/imaplib.py | 0 {Src/StdLib => StdLib}/Lib/imghdr.py | 0 {Src/StdLib => StdLib}/Lib/imp.py | 0 .../Lib/importlib/__init__.py | 0 .../Lib/importlib/_bootstrap.py | 0 {Src/StdLib => StdLib}/Lib/importlib/abc.py | 0 .../Lib/importlib/machinery.py | 0 {Src/StdLib => StdLib}/Lib/importlib/util.py | 0 {Src/StdLib => StdLib}/Lib/inspect.py | 0 {Src/StdLib => StdLib}/Lib/io.py | 0 {Src/StdLib => StdLib}/Lib/ipaddress.py | 0 {Src/StdLib => StdLib}/Lib/json/__init__.py | 0 {Src/StdLib => StdLib}/Lib/json/decoder.py | 0 {Src/StdLib => StdLib}/Lib/json/encoder.py | 0 {Src/StdLib => StdLib}/Lib/json/scanner.py | 0 {Src/StdLib => StdLib}/Lib/json/tool.py | 0 {Src/StdLib => StdLib}/Lib/keyword.py | 0 .../StdLib => StdLib}/Lib/lib2to3/Grammar.txt | 0 .../Lib/lib2to3/PatternGrammar.txt | 0 .../StdLib => StdLib}/Lib/lib2to3/__init__.py | 0 .../StdLib => StdLib}/Lib/lib2to3/__main__.py | 0 .../Lib/lib2to3/btm_matcher.py | 0 .../Lib/lib2to3/btm_utils.py | 0 .../Lib/lib2to3/fixer_base.py | 0 .../Lib/lib2to3/fixer_util.py | 0 .../Lib/lib2to3/fixes/__init__.py | 0 .../Lib/lib2to3/fixes/fix_apply.py | 0 .../Lib/lib2to3/fixes/fix_asserts.py | 0 .../Lib/lib2to3/fixes/fix_basestring.py | 0 .../Lib/lib2to3/fixes/fix_buffer.py | 0 .../Lib/lib2to3/fixes/fix_callable.py | 0 .../Lib/lib2to3/fixes/fix_dict.py | 0 .../Lib/lib2to3/fixes/fix_except.py | 0 .../Lib/lib2to3/fixes/fix_exec.py | 0 .../Lib/lib2to3/fixes/fix_execfile.py | 0 .../Lib/lib2to3/fixes/fix_exitfunc.py | 0 .../Lib/lib2to3/fixes/fix_filter.py | 0 .../Lib/lib2to3/fixes/fix_funcattrs.py | 0 .../Lib/lib2to3/fixes/fix_future.py | 0 .../Lib/lib2to3/fixes/fix_getcwdu.py | 0 .../Lib/lib2to3/fixes/fix_has_key.py | 0 .../Lib/lib2to3/fixes/fix_idioms.py | 0 .../Lib/lib2to3/fixes/fix_import.py | 0 .../Lib/lib2to3/fixes/fix_imports.py | 0 .../Lib/lib2to3/fixes/fix_imports2.py | 0 .../Lib/lib2to3/fixes/fix_input.py | 0 .../Lib/lib2to3/fixes/fix_intern.py | 0 .../Lib/lib2to3/fixes/fix_isinstance.py | 0 .../Lib/lib2to3/fixes/fix_itertools.py | 0 .../lib2to3/fixes/fix_itertools_imports.py | 0 .../Lib/lib2to3/fixes/fix_long.py | 0 .../Lib/lib2to3/fixes/fix_map.py | 0 .../Lib/lib2to3/fixes/fix_metaclass.py | 0 .../Lib/lib2to3/fixes/fix_methodattrs.py | 0 .../Lib/lib2to3/fixes/fix_ne.py | 0 .../Lib/lib2to3/fixes/fix_next.py | 0 .../Lib/lib2to3/fixes/fix_nonzero.py | 0 .../Lib/lib2to3/fixes/fix_numliterals.py | 0 .../Lib/lib2to3/fixes/fix_operator.py | 0 .../Lib/lib2to3/fixes/fix_paren.py | 0 .../Lib/lib2to3/fixes/fix_print.py | 0 .../Lib/lib2to3/fixes/fix_raise.py | 0 .../Lib/lib2to3/fixes/fix_raw_input.py | 0 .../Lib/lib2to3/fixes/fix_reduce.py | 0 .../Lib/lib2to3/fixes/fix_reload.py | 0 .../Lib/lib2to3/fixes/fix_renames.py | 0 .../Lib/lib2to3/fixes/fix_repr.py | 0 .../Lib/lib2to3/fixes/fix_set_literal.py | 0 .../Lib/lib2to3/fixes/fix_standarderror.py | 0 .../Lib/lib2to3/fixes/fix_sys_exc.py | 0 .../Lib/lib2to3/fixes/fix_throw.py | 0 .../Lib/lib2to3/fixes/fix_tuple_params.py | 0 .../Lib/lib2to3/fixes/fix_types.py | 0 .../Lib/lib2to3/fixes/fix_unicode.py | 0 .../Lib/lib2to3/fixes/fix_urllib.py | 0 .../Lib/lib2to3/fixes/fix_ws_comma.py | 0 .../Lib/lib2to3/fixes/fix_xrange.py | 0 .../Lib/lib2to3/fixes/fix_xreadlines.py | 0 .../Lib/lib2to3/fixes/fix_zip.py | 0 {Src/StdLib => StdLib}/Lib/lib2to3/main.py | 0 {Src/StdLib => StdLib}/Lib/lib2to3/patcomp.py | 0 .../Lib/lib2to3/pgen2/__init__.py | 0 .../Lib/lib2to3/pgen2/conv.py | 0 .../Lib/lib2to3/pgen2/driver.py | 0 .../Lib/lib2to3/pgen2/grammar.py | 0 .../Lib/lib2to3/pgen2/literals.py | 0 .../Lib/lib2to3/pgen2/parse.py | 0 .../Lib/lib2to3/pgen2/pgen.py | 0 .../Lib/lib2to3/pgen2/token.py | 0 .../Lib/lib2to3/pgen2/tokenize.py | 0 {Src/StdLib => StdLib}/Lib/lib2to3/pygram.py | 0 {Src/StdLib => StdLib}/Lib/lib2to3/pytree.py | 0 .../StdLib => StdLib}/Lib/lib2to3/refactor.py | 0 .../Lib/lib2to3/tests/__init__.py | 0 .../Lib/lib2to3/tests/__main__.py | 0 .../Lib/lib2to3/tests/data/README | 0 .../Lib/lib2to3/tests/data/bom.py | 0 .../Lib/lib2to3/tests/data/crlf.py | 0 .../lib2to3/tests/data/different_encoding.py | 0 .../Lib/lib2to3/tests/data/false_encoding.py | 0 .../lib2to3/tests/data/fixers/bad_order.py | 0 .../tests/data/fixers/myfixes/__init__.py | 0 .../tests/data/fixers/myfixes/fix_explicit.py | 0 .../tests/data/fixers/myfixes/fix_first.py | 0 .../tests/data/fixers/myfixes/fix_last.py | 0 .../tests/data/fixers/myfixes/fix_parrot.py | 0 .../tests/data/fixers/myfixes/fix_preorder.py | 0 .../lib2to3/tests/data/fixers/no_fixer_cls.py | 0 .../tests/data/fixers/parrot_example.py | 0 .../lib2to3/tests/data/infinite_recursion.py | 0 .../lib2to3/tests/data/py2_test_grammar.py | 0 .../lib2to3/tests/data/py3_test_grammar.py | 0 .../Lib/lib2to3/tests/pytree_idempotency.py | 0 .../Lib/lib2to3/tests/support.py | 0 .../Lib/lib2to3/tests/test_all_fixers.py | 0 .../Lib/lib2to3/tests/test_fixers.py | 0 .../Lib/lib2to3/tests/test_main.py | 0 .../Lib/lib2to3/tests/test_parser.py | 0 .../Lib/lib2to3/tests/test_pytree.py | 0 .../Lib/lib2to3/tests/test_refactor.py | 0 .../Lib/lib2to3/tests/test_util.py | 0 {Src/StdLib => StdLib}/Lib/linecache.py | 0 {Src/StdLib => StdLib}/Lib/locale.py | 0 .../StdLib => StdLib}/Lib/logging/__init__.py | 0 {Src/StdLib => StdLib}/Lib/logging/config.py | 0 .../StdLib => StdLib}/Lib/logging/handlers.py | 0 {Src/StdLib => StdLib}/Lib/lzma.py | 0 {Src/StdLib => StdLib}/Lib/macpath.py | 0 {Src/StdLib => StdLib}/Lib/macurl2path.py | 0 {Src/StdLib => StdLib}/Lib/mailbox.py | 0 {Src/StdLib => StdLib}/Lib/mailcap.py | 0 {Src/StdLib => StdLib}/Lib/mimetypes.py | 0 {Src/StdLib => StdLib}/Lib/modulefinder.py | 0 {Src/StdLib => StdLib}/Lib/msilib/__init__.py | 0 {Src/StdLib => StdLib}/Lib/msilib/schema.py | 0 {Src/StdLib => StdLib}/Lib/msilib/sequence.py | 0 {Src/StdLib => StdLib}/Lib/msilib/text.py | 0 .../Lib/multiprocessing/__init__.py | 0 .../Lib/multiprocessing/connection.py | 0 .../Lib/multiprocessing/context.py | 0 .../Lib/multiprocessing/dummy/__init__.py | 0 .../Lib/multiprocessing/dummy/connection.py | 0 .../Lib/multiprocessing/forkserver.py | 0 .../Lib/multiprocessing/heap.py | 0 .../Lib/multiprocessing/managers.py | 0 .../Lib/multiprocessing/pool.py | 0 .../Lib/multiprocessing/popen_fork.py | 0 .../Lib/multiprocessing/popen_forkserver.py | 0 .../Lib/multiprocessing/popen_spawn_posix.py | 0 .../Lib/multiprocessing/popen_spawn_win32.py | 0 .../Lib/multiprocessing/process.py | 0 .../Lib/multiprocessing/queues.py | 0 .../Lib/multiprocessing/reduction.py | 0 .../Lib/multiprocessing/resource_sharer.py | 0 .../Lib/multiprocessing/semaphore_tracker.py | 0 .../Lib/multiprocessing/sharedctypes.py | 0 .../Lib/multiprocessing/spawn.py | 0 .../Lib/multiprocessing/synchronize.py | 0 .../Lib/multiprocessing/util.py | 0 {Src/StdLib => StdLib}/Lib/netrc.py | 0 {Src/StdLib => StdLib}/Lib/nntplib.py | 0 {Src/StdLib => StdLib}/Lib/ntpath.py | 0 {Src/StdLib => StdLib}/Lib/nturl2path.py | 0 {Src/StdLib => StdLib}/Lib/numbers.py | 0 {Src/StdLib => StdLib}/Lib/opcode.py | 0 {Src/StdLib => StdLib}/Lib/operator.py | 0 {Src/StdLib => StdLib}/Lib/optparse.py | 0 {Src/StdLib => StdLib}/Lib/os.py | 0 {Src/StdLib => StdLib}/Lib/pathlib.py | 0 {Src/StdLib => StdLib}/Lib/pdb.py | 0 {Src/StdLib => StdLib}/Lib/pickle.py | 0 {Src/StdLib => StdLib}/Lib/pickletools.py | 0 {Src/StdLib => StdLib}/Lib/pipes.py | 0 {Src/StdLib => StdLib}/Lib/pkgutil.py | 0 {Src/StdLib => StdLib}/Lib/platform.py | 0 {Src/StdLib => StdLib}/Lib/plistlib.py | 0 {Src/StdLib => StdLib}/Lib/poplib.py | 0 {Src/StdLib => StdLib}/Lib/posixpath.py | 0 {Src/StdLib => StdLib}/Lib/pprint.py | 0 {Src/StdLib => StdLib}/Lib/profile.py | 0 {Src/StdLib => StdLib}/Lib/pstats.py | 0 {Src/StdLib => StdLib}/Lib/pty.py | 0 {Src/StdLib => StdLib}/Lib/py_compile.py | 0 {Src/StdLib => StdLib}/Lib/pyclbr.py | 0 {Src/StdLib => StdLib}/Lib/pydoc.py | 0 .../Lib/pydoc_data/__init__.py | 0 .../Lib/pydoc_data/_pydoc.css | 0 .../Lib/pydoc_data/topics.py | 0 {Src/StdLib => StdLib}/Lib/queue.py | 0 {Src/StdLib => StdLib}/Lib/quopri.py | 0 {Src/StdLib => StdLib}/Lib/random.py | 0 {Src/StdLib => StdLib}/Lib/re.py | 0 {Src/StdLib => StdLib}/Lib/reprlib.py | 0 {Src/StdLib => StdLib}/Lib/rlcompleter.py | 0 {Src/StdLib => StdLib}/Lib/runpy.py | 0 {Src/StdLib => StdLib}/Lib/sched.py | 0 {Src/StdLib => StdLib}/Lib/selectors.py | 0 {Src/StdLib => StdLib}/Lib/shelve.py | 0 {Src/StdLib => StdLib}/Lib/shlex.py | 0 {Src/StdLib => StdLib}/Lib/shutil.py | 0 .../Lib/site-packages/README | 0 {Src/StdLib => StdLib}/Lib/site.py | 0 {Src/StdLib => StdLib}/Lib/smtpd.py | 0 {Src/StdLib => StdLib}/Lib/smtplib.py | 0 {Src/StdLib => StdLib}/Lib/sndhdr.py | 0 {Src/StdLib => StdLib}/Lib/socket.py | 0 {Src/StdLib => StdLib}/Lib/socketserver.py | 0 .../StdLib => StdLib}/Lib/sqlite3/__init__.py | 0 {Src/StdLib => StdLib}/Lib/sqlite3/dbapi2.py | 0 {Src/StdLib => StdLib}/Lib/sqlite3/dump.py | 0 .../Lib/sqlite3/test/__init__.py | 0 .../Lib/sqlite3/test/dbapi.py | 0 .../Lib/sqlite3/test/dump.py | 0 .../Lib/sqlite3/test/factory.py | 0 .../Lib/sqlite3/test/hooks.py | 0 .../Lib/sqlite3/test/regression.py | 0 .../Lib/sqlite3/test/transactions.py | 0 .../Lib/sqlite3/test/types.py | 0 .../Lib/sqlite3/test/userfunctions.py | 0 {Src/StdLib => StdLib}/Lib/sre_compile.py | 0 {Src/StdLib => StdLib}/Lib/sre_constants.py | 0 {Src/StdLib => StdLib}/Lib/sre_parse.py | 0 {Src/StdLib => StdLib}/Lib/ssl.py | 0 {Src/StdLib => StdLib}/Lib/stat.py | 0 {Src/StdLib => StdLib}/Lib/statistics.py | 0 {Src/StdLib => StdLib}/Lib/string.py | 0 {Src/StdLib => StdLib}/Lib/stringprep.py | 0 {Src/StdLib => StdLib}/Lib/struct.py | 0 {Src/StdLib => StdLib}/Lib/subprocess.py | 0 {Src/StdLib => StdLib}/Lib/sunau.py | 0 {Src/StdLib => StdLib}/Lib/symbol.py | 0 {Src/StdLib => StdLib}/Lib/symtable.py | 0 {Src/StdLib => StdLib}/Lib/sysconfig.py | 0 {Src/StdLib => StdLib}/Lib/tabnanny.py | 0 {Src/StdLib => StdLib}/Lib/tarfile.py | 0 {Src/StdLib => StdLib}/Lib/telnetlib.py | 0 {Src/StdLib => StdLib}/Lib/tempfile.py | 0 {Src/StdLib => StdLib}/Lib/test/185test.db | Bin .../Lib/test/Sine-1000Hz-300ms.aif | Bin {Src/StdLib => StdLib}/Lib/test/__init__.py | 0 {Src/StdLib => StdLib}/Lib/test/__main__.py | 0 .../Lib/test/_test_multiprocessing.py | 0 .../Lib/test/audiodata/pluck-alaw.aifc | Bin .../Lib/test/audiodata/pluck-pcm16.aiff | Bin .../Lib/test/audiodata/pluck-pcm16.au | Bin .../Lib/test/audiodata/pluck-pcm16.wav | Bin .../Lib/test/audiodata/pluck-pcm24.aiff | Bin .../Lib/test/audiodata/pluck-pcm24.au | Bin .../Lib/test/audiodata/pluck-pcm24.wav | Bin .../Lib/test/audiodata/pluck-pcm32.aiff | Bin .../Lib/test/audiodata/pluck-pcm32.au | Bin .../Lib/test/audiodata/pluck-pcm32.wav | Bin .../Lib/test/audiodata/pluck-pcm8.aiff | Bin .../Lib/test/audiodata/pluck-pcm8.au | Bin .../Lib/test/audiodata/pluck-pcm8.wav | Bin .../Lib/test/audiodata/pluck-ulaw.aifc | Bin .../Lib/test/audiodata/pluck-ulaw.au | Bin {Src/StdLib => StdLib}/Lib/test/audiotest.au | Bin {Src/StdLib => StdLib}/Lib/test/audiotests.py | 0 {Src/StdLib => StdLib}/Lib/test/autotest.py | 0 {Src/StdLib => StdLib}/Lib/test/bad_coding.py | 0 .../StdLib => StdLib}/Lib/test/bad_coding2.py | 0 {Src/StdLib => StdLib}/Lib/test/badcert.pem | 0 {Src/StdLib => StdLib}/Lib/test/badkey.pem | 0 .../Lib/test/badsyntax_3131.py | 0 .../Lib/test/badsyntax_future10.py | 0 .../Lib/test/badsyntax_future3.py | 0 .../Lib/test/badsyntax_future4.py | 0 .../Lib/test/badsyntax_future5.py | 0 .../Lib/test/badsyntax_future6.py | 0 .../Lib/test/badsyntax_future7.py | 0 .../Lib/test/badsyntax_future8.py | 0 .../Lib/test/badsyntax_future9.py | 0 .../Lib/test/badsyntax_pep3120.py | 0 .../Lib/test/buffer_tests.py | 0 .../Lib/test/bytecode_helper.py | 0 .../Lib/test/capath/0e4015b9.0 | 0 .../Lib/test/capath/4e1295a3.0 | 0 .../Lib/test/capath/5ed36f99.0 | 0 .../Lib/test/capath/6e88d7b8.0 | 0 .../Lib/test/capath/99d0fa06.0 | 0 .../Lib/test/capath/ce7b8643.0 | 0 {Src/StdLib => StdLib}/Lib/test/cfgparser.1 | 0 {Src/StdLib => StdLib}/Lib/test/cfgparser.2 | 0 {Src/StdLib => StdLib}/Lib/test/cfgparser.3 | 0 .../Lib/test/check_soundcard.vbs | 0 .../Lib/test/cjkencodings/big5-utf8.txt | 0 .../Lib/test/cjkencodings/big5.txt | 0 .../Lib/test/cjkencodings/big5hkscs-utf8.txt | 0 .../Lib/test/cjkencodings/big5hkscs.txt | 0 .../Lib/test/cjkencodings/cp949-utf8.txt | 0 .../Lib/test/cjkencodings/cp949.txt | 0 .../test/cjkencodings/euc_jisx0213-utf8.txt | 0 .../Lib/test/cjkencodings/euc_jisx0213.txt | 0 .../Lib/test/cjkencodings/euc_jp-utf8.txt | 0 .../Lib/test/cjkencodings/euc_jp.txt | 0 .../Lib/test/cjkencodings/euc_kr-utf8.txt | 0 .../Lib/test/cjkencodings/euc_kr.txt | 0 .../Lib/test/cjkencodings/gb18030-utf8.txt | 0 .../Lib/test/cjkencodings/gb18030.txt | 0 .../Lib/test/cjkencodings/gb2312-utf8.txt | 0 .../Lib/test/cjkencodings/gb2312.txt | 0 .../Lib/test/cjkencodings/gbk-utf8.txt | 0 .../Lib/test/cjkencodings/gbk.txt | 0 .../Lib/test/cjkencodings/hz-utf8.txt | 0 .../Lib/test/cjkencodings/hz.txt | 0 .../Lib/test/cjkencodings/iso2022_jp-utf8.txt | 0 .../Lib/test/cjkencodings/iso2022_jp.txt | 0 .../Lib/test/cjkencodings/iso2022_kr-utf8.txt | 0 .../Lib/test/cjkencodings/iso2022_kr.txt | 0 .../Lib/test/cjkencodings/johab-utf8.txt | 0 .../Lib/test/cjkencodings/johab.txt | 0 .../Lib/test/cjkencodings/shift_jis-utf8.txt | 0 .../Lib/test/cjkencodings/shift_jis.txt | 0 .../test/cjkencodings/shift_jisx0213-utf8.txt | 0 .../Lib/test/cjkencodings/shift_jisx0213.txt | 0 .../Lib/test/cmath_testcases.txt | 0 .../StdLib => StdLib}/Lib/test/coding20731.py | 0 .../Lib/test/crashers/README | 0 .../Lib/test/crashers/bogus_code_obj.py | 0 .../Lib/test/crashers/gc_inspection.py | 0 .../Lib/test/crashers/infinite_loop_re.py | 0 .../test/crashers/mutation_inside_cyclegc.py | 0 .../Lib/test/crashers/recursive_call.py | 0 .../test/crashers/trace_at_recursion_limit.py | 0 .../Lib/test/crashers/underlying_dict.py | 0 .../Lib/test/curses_tests.py | 0 {Src/StdLib => StdLib}/Lib/test/data/README | 0 .../Lib/test/datetimetester.py | 0 .../Lib/test/decimaltestdata/abs.decTest | 0 .../Lib/test/decimaltestdata/add.decTest | 0 .../Lib/test/decimaltestdata/and.decTest | 0 .../Lib/test/decimaltestdata/base.decTest | 0 .../Lib/test/decimaltestdata/clamp.decTest | 0 .../Lib/test/decimaltestdata/class.decTest | 0 .../Lib/test/decimaltestdata/compare.decTest | 0 .../test/decimaltestdata/comparetotal.decTest | 0 .../decimaltestdata/comparetotmag.decTest | 0 .../Lib/test/decimaltestdata/copy.decTest | 0 .../Lib/test/decimaltestdata/copyabs.decTest | 0 .../test/decimaltestdata/copynegate.decTest | 0 .../Lib/test/decimaltestdata/copysign.decTest | 0 .../Lib/test/decimaltestdata/ddAbs.decTest | 0 .../Lib/test/decimaltestdata/ddAdd.decTest | 0 .../Lib/test/decimaltestdata/ddAnd.decTest | 0 .../Lib/test/decimaltestdata/ddBase.decTest | 0 .../test/decimaltestdata/ddCanonical.decTest | 0 .../Lib/test/decimaltestdata/ddClass.decTest | 0 .../test/decimaltestdata/ddCompare.decTest | 0 .../test/decimaltestdata/ddCompareSig.decTest | 0 .../decimaltestdata/ddCompareTotal.decTest | 0 .../decimaltestdata/ddCompareTotalMag.decTest | 0 .../Lib/test/decimaltestdata/ddCopy.decTest | 0 .../test/decimaltestdata/ddCopyAbs.decTest | 0 .../test/decimaltestdata/ddCopyNegate.decTest | 0 .../test/decimaltestdata/ddCopySign.decTest | 0 .../Lib/test/decimaltestdata/ddDivide.decTest | 0 .../test/decimaltestdata/ddDivideInt.decTest | 0 .../Lib/test/decimaltestdata/ddEncode.decTest | 0 .../Lib/test/decimaltestdata/ddFMA.decTest | 0 .../Lib/test/decimaltestdata/ddInvert.decTest | 0 .../Lib/test/decimaltestdata/ddLogB.decTest | 0 .../Lib/test/decimaltestdata/ddMax.decTest | 0 .../Lib/test/decimaltestdata/ddMaxMag.decTest | 0 .../Lib/test/decimaltestdata/ddMin.decTest | 0 .../Lib/test/decimaltestdata/ddMinMag.decTest | 0 .../Lib/test/decimaltestdata/ddMinus.decTest | 0 .../test/decimaltestdata/ddMultiply.decTest | 0 .../test/decimaltestdata/ddNextMinus.decTest | 0 .../test/decimaltestdata/ddNextPlus.decTest | 0 .../test/decimaltestdata/ddNextToward.decTest | 0 .../Lib/test/decimaltestdata/ddOr.decTest | 0 .../Lib/test/decimaltestdata/ddPlus.decTest | 0 .../test/decimaltestdata/ddQuantize.decTest | 0 .../Lib/test/decimaltestdata/ddReduce.decTest | 0 .../test/decimaltestdata/ddRemainder.decTest | 0 .../decimaltestdata/ddRemainderNear.decTest | 0 .../Lib/test/decimaltestdata/ddRotate.decTest | 0 .../decimaltestdata/ddSameQuantum.decTest | 0 .../Lib/test/decimaltestdata/ddScaleB.decTest | 0 .../Lib/test/decimaltestdata/ddShift.decTest | 0 .../test/decimaltestdata/ddSubtract.decTest | 0 .../test/decimaltestdata/ddToIntegral.decTest | 0 .../Lib/test/decimaltestdata/ddXor.decTest | 0 .../test/decimaltestdata/decDouble.decTest | 0 .../Lib/test/decimaltestdata/decQuad.decTest | 0 .../test/decimaltestdata/decSingle.decTest | 0 .../Lib/test/decimaltestdata/divide.decTest | 0 .../test/decimaltestdata/divideint.decTest | 0 .../Lib/test/decimaltestdata/dqAbs.decTest | 0 .../Lib/test/decimaltestdata/dqAdd.decTest | 0 .../Lib/test/decimaltestdata/dqAnd.decTest | 0 .../Lib/test/decimaltestdata/dqBase.decTest | 0 .../test/decimaltestdata/dqCanonical.decTest | 0 .../Lib/test/decimaltestdata/dqClass.decTest | 0 .../test/decimaltestdata/dqCompare.decTest | 0 .../test/decimaltestdata/dqCompareSig.decTest | 0 .../decimaltestdata/dqCompareTotal.decTest | 0 .../decimaltestdata/dqCompareTotalMag.decTest | 0 .../Lib/test/decimaltestdata/dqCopy.decTest | 0 .../test/decimaltestdata/dqCopyAbs.decTest | 0 .../test/decimaltestdata/dqCopyNegate.decTest | 0 .../test/decimaltestdata/dqCopySign.decTest | 0 .../Lib/test/decimaltestdata/dqDivide.decTest | 0 .../test/decimaltestdata/dqDivideInt.decTest | 0 .../Lib/test/decimaltestdata/dqEncode.decTest | 0 .../Lib/test/decimaltestdata/dqFMA.decTest | 0 .../Lib/test/decimaltestdata/dqInvert.decTest | 0 .../Lib/test/decimaltestdata/dqLogB.decTest | 0 .../Lib/test/decimaltestdata/dqMax.decTest | 0 .../Lib/test/decimaltestdata/dqMaxMag.decTest | 0 .../Lib/test/decimaltestdata/dqMin.decTest | 0 .../Lib/test/decimaltestdata/dqMinMag.decTest | 0 .../Lib/test/decimaltestdata/dqMinus.decTest | 0 .../test/decimaltestdata/dqMultiply.decTest | 0 .../test/decimaltestdata/dqNextMinus.decTest | 0 .../test/decimaltestdata/dqNextPlus.decTest | 0 .../test/decimaltestdata/dqNextToward.decTest | 0 .../Lib/test/decimaltestdata/dqOr.decTest | 0 .../Lib/test/decimaltestdata/dqPlus.decTest | 0 .../test/decimaltestdata/dqQuantize.decTest | 0 .../Lib/test/decimaltestdata/dqReduce.decTest | 0 .../test/decimaltestdata/dqRemainder.decTest | 0 .../decimaltestdata/dqRemainderNear.decTest | 0 .../Lib/test/decimaltestdata/dqRotate.decTest | 0 .../decimaltestdata/dqSameQuantum.decTest | 0 .../Lib/test/decimaltestdata/dqScaleB.decTest | 0 .../Lib/test/decimaltestdata/dqShift.decTest | 0 .../test/decimaltestdata/dqSubtract.decTest | 0 .../test/decimaltestdata/dqToIntegral.decTest | 0 .../Lib/test/decimaltestdata/dqXor.decTest | 0 .../Lib/test/decimaltestdata/dsBase.decTest | 0 .../Lib/test/decimaltestdata/dsEncode.decTest | 0 .../Lib/test/decimaltestdata/exp.decTest | 0 .../Lib/test/decimaltestdata/extra.decTest | 0 .../Lib/test/decimaltestdata/fma.decTest | 0 .../Lib/test/decimaltestdata/inexact.decTest | 0 .../Lib/test/decimaltestdata/invert.decTest | 0 .../Lib/test/decimaltestdata/ln.decTest | 0 .../Lib/test/decimaltestdata/log10.decTest | 0 .../Lib/test/decimaltestdata/logb.decTest | 0 .../Lib/test/decimaltestdata/max.decTest | 0 .../Lib/test/decimaltestdata/maxmag.decTest | 0 .../Lib/test/decimaltestdata/min.decTest | 0 .../Lib/test/decimaltestdata/minmag.decTest | 0 .../Lib/test/decimaltestdata/minus.decTest | 0 .../Lib/test/decimaltestdata/multiply.decTest | 0 .../test/decimaltestdata/nextminus.decTest | 0 .../Lib/test/decimaltestdata/nextplus.decTest | 0 .../test/decimaltestdata/nexttoward.decTest | 0 .../Lib/test/decimaltestdata/or.decTest | 0 .../Lib/test/decimaltestdata/plus.decTest | 0 .../Lib/test/decimaltestdata/power.decTest | 0 .../test/decimaltestdata/powersqrt.decTest | 0 .../Lib/test/decimaltestdata/quantize.decTest | 0 .../decimaltestdata/randomBound32.decTest | 0 .../Lib/test/decimaltestdata/randoms.decTest | 0 .../Lib/test/decimaltestdata/reduce.decTest | 0 .../test/decimaltestdata/remainder.decTest | 0 .../decimaltestdata/remainderNear.decTest | 0 .../Lib/test/decimaltestdata/rescale.decTest | 0 .../Lib/test/decimaltestdata/rotate.decTest | 0 .../Lib/test/decimaltestdata/rounding.decTest | 0 .../test/decimaltestdata/samequantum.decTest | 0 .../Lib/test/decimaltestdata/scaleb.decTest | 0 .../Lib/test/decimaltestdata/shift.decTest | 0 .../test/decimaltestdata/squareroot.decTest | 0 .../Lib/test/decimaltestdata/subtract.decTest | 0 .../Lib/test/decimaltestdata/testall.decTest | 0 .../test/decimaltestdata/tointegral.decTest | 0 .../test/decimaltestdata/tointegralx.decTest | 0 .../Lib/test/decimaltestdata/xor.decTest | 0 {Src/StdLib => StdLib}/Lib/test/dh1024.pem | 0 {Src/StdLib => StdLib}/Lib/test/dis_module.py | 0 .../Lib/test/doctest_aliases.py | 0 .../Lib/test/double_const.py | 0 {Src/StdLib => StdLib}/Lib/test/empty.vbs | 0 .../Lib/test/encoded_modules/__init__.py | 0 .../test/encoded_modules/module_iso_8859_1.py | 0 .../Lib/test/encoded_modules/module_koi8_r.py | 0 .../Lib/test/exception_hierarchy.txt | 0 {Src/StdLib => StdLib}/Lib/test/final_a.py | 0 {Src/StdLib => StdLib}/Lib/test/final_b.py | 0 .../Lib/test/floating_points.txt | 0 {Src/StdLib => StdLib}/Lib/test/fork_wait.py | 0 .../Lib/test/formatfloat_testcases.txt | 0 .../Lib/test/future_test1.py | 0 .../Lib/test/future_test2.py | 0 {Src/StdLib => StdLib}/Lib/test/gdb_sample.py | 0 {Src/StdLib => StdLib}/Lib/test/ieee754.txt | 0 .../Lib/test/imghdrdata/python.bmp | Bin .../Lib/test/imghdrdata/python.gif | Bin .../Lib/test/imghdrdata/python.jpg | Bin .../Lib/test/imghdrdata/python.pbm | 0 .../Lib/test/imghdrdata/python.pgm | Bin .../Lib/test/imghdrdata/python.png | Bin .../Lib/test/imghdrdata/python.ppm | Bin .../Lib/test/imghdrdata/python.ras | Bin .../Lib/test/imghdrdata/python.sgi | Bin .../Lib/test/imghdrdata/python.tiff | Bin .../Lib/test/imghdrdata/python.xbm | 0 .../Lib/test/inspect_fodder.py | 0 .../Lib/test/inspect_fodder2.py | 0 .../Lib/test/keycert.passwd.pem | 0 {Src/StdLib => StdLib}/Lib/test/keycert.pem | 0 {Src/StdLib => StdLib}/Lib/test/keycert2.pem | 0 {Src/StdLib => StdLib}/Lib/test/keycert3.pem | 0 {Src/StdLib => StdLib}/Lib/test/keycert4.pem | 0 .../Lib/test/leakers/README.txt | 0 .../Lib/test/leakers/__init__.py | 0 .../Lib/test/leakers/test_ctypes.py | 0 .../Lib/test/leakers/test_selftype.py | 0 {Src/StdLib => StdLib}/Lib/test/list_tests.py | 0 {Src/StdLib => StdLib}/Lib/test/lock_tests.py | 0 {Src/StdLib => StdLib}/Lib/test/mailcap.txt | 0 .../Lib/test/make_ssl_certs.py | 0 .../Lib/test/mapping_tests.py | 0 .../Lib/test/math_testcases.txt | 0 .../Lib/test/memory_watchdog.py | 0 {Src/StdLib => StdLib}/Lib/test/mime.types | 0 .../StdLib => StdLib}/Lib/test/mock_socket.py | 0 .../Lib/test/mod_generics_cache.py | 0 .../Lib/test/mp_fork_bomb.py | 0 .../Lib/test/multibytecodec_support.py | 0 {Src/StdLib => StdLib}/Lib/test/nokia.pem | 0 .../Lib/test/nullbytecert.pem | 0 {Src/StdLib => StdLib}/Lib/test/nullcert.pem | 0 .../Lib/test/outstanding_bugs.py | 0 .../Lib/test/pickletester.py | 0 {Src/StdLib => StdLib}/Lib/test/profilee.py | 0 {Src/StdLib => StdLib}/Lib/test/pstats.pck | Bin {Src/StdLib => StdLib}/Lib/test/pycacert.pem | 0 {Src/StdLib => StdLib}/Lib/test/pycakey.pem | 0 .../Lib/test/pyclbr_input.py | 0 {Src/StdLib => StdLib}/Lib/test/pydoc_mod.py | 0 .../StdLib => StdLib}/Lib/test/pydocfodder.py | 0 {Src/StdLib => StdLib}/Lib/test/pystone.py | 0 {Src/StdLib => StdLib}/Lib/test/randv2_32.pck | 0 {Src/StdLib => StdLib}/Lib/test/randv2_64.pck | 0 {Src/StdLib => StdLib}/Lib/test/randv3.pck | 0 {Src/StdLib => StdLib}/Lib/test/re_tests.py | 0 {Src/StdLib => StdLib}/Lib/test/regrtest.py | 0 {Src/StdLib => StdLib}/Lib/test/relimport.py | 0 {Src/StdLib => StdLib}/Lib/test/reperf.py | 0 .../StdLib => StdLib}/Lib/test/revocation.crl | 0 .../Lib/test/sample_doctest.py | 0 .../Lib/test/sample_doctest_no_docstrings.py | 0 .../Lib/test/sample_doctest_no_doctests.py | 0 .../Lib/test/script_helper.py | 0 .../Lib/test/selfsigned_pythontestdotnet.pem | 0 {Src/StdLib => StdLib}/Lib/test/seq_tests.py | 0 .../Lib/test/sgml_input.html | 0 {Src/StdLib => StdLib}/Lib/test/sha256.pem | 0 .../Lib/test/sndhdrdata/README | 0 .../Lib/test/sndhdrdata/sndhdr.8svx | Bin .../Lib/test/sndhdrdata/sndhdr.aifc | Bin .../Lib/test/sndhdrdata/sndhdr.aiff | Bin .../Lib/test/sndhdrdata/sndhdr.au | Bin .../Lib/test/sndhdrdata/sndhdr.hcom | Bin .../Lib/test/sndhdrdata/sndhdr.sndt | Bin .../Lib/test/sndhdrdata/sndhdr.voc | Bin .../Lib/test/sndhdrdata/sndhdr.wav | Bin {Src/StdLib => StdLib}/Lib/test/sortperf.py | 0 {Src/StdLib => StdLib}/Lib/test/ssl_cert.pem | 0 .../Lib/test/ssl_key.passwd.pem | 0 {Src/StdLib => StdLib}/Lib/test/ssl_key.pem | 0 .../StdLib => StdLib}/Lib/test/ssl_servers.py | 0 {Src/StdLib => StdLib}/Lib/test/ssltests.py | 0 .../Lib/test/string_tests.py | 0 .../Lib/test/subprocessdata/fd_status.py | 0 .../Lib/test/subprocessdata/input_reader.py | 0 .../Lib/test/subprocessdata/qcat.py | 0 .../Lib/test/subprocessdata/qgrep.py | 0 .../test/subprocessdata/sigchild_ignore.py | 0 .../Lib/test/support/__init__.py | 0 .../Lib/test/talos-2019-0758.pem | 0 .../Lib/test/test___all__.py | 0 .../Lib/test/test___future__.py | 0 .../Lib/test/test__locale.py | 0 .../Lib/test/test__opcode.py | 0 .../Lib/test/test__osx_support.py | 0 {Src/StdLib => StdLib}/Lib/test/test_abc.py | 0 .../Lib/test/test_abstract_numbers.py | 0 {Src/StdLib => StdLib}/Lib/test/test_aifc.py | 0 .../Lib/test/test_argparse.py | 0 {Src/StdLib => StdLib}/Lib/test/test_array.py | 0 {Src/StdLib => StdLib}/Lib/test/test_ast.py | 0 .../Lib/test/test_asynchat.py | 0 .../Lib/test/test_asyncio/__init__.py | 0 .../Lib/test/test_asyncio/__main__.py | 0 .../Lib/test/test_asyncio/echo.py | 0 .../Lib/test/test_asyncio/echo2.py | 0 .../Lib/test/test_asyncio/echo3.py | 0 .../Lib/test/test_asyncio/keycert3.pem | 0 .../Lib/test/test_asyncio/pycacert.pem | 0 .../Lib/test/test_asyncio/ssl_cert.pem | 0 .../Lib/test/test_asyncio/ssl_key.pem | 0 .../Lib/test/test_asyncio/test_base_events.py | 0 .../Lib/test/test_asyncio/test_events.py | 0 .../Lib/test/test_asyncio/test_futures.py | 0 .../Lib/test/test_asyncio/test_locks.py | 0 .../test/test_asyncio/test_proactor_events.py | 0 .../Lib/test/test_asyncio/test_queues.py | 0 .../test/test_asyncio/test_selector_events.py | 0 .../Lib/test/test_asyncio/test_sslproto.py | 0 .../Lib/test/test_asyncio/test_streams.py | 0 .../Lib/test/test_asyncio/test_subprocess.py | 0 .../Lib/test/test_asyncio/test_tasks.py | 0 .../Lib/test/test_asyncio/test_transports.py | 0 .../Lib/test/test_asyncio/test_unix_events.py | 0 .../test/test_asyncio/test_windows_events.py | 0 .../test/test_asyncio/test_windows_utils.py | 0 .../Lib/test/test_asyncore.py | 0 .../StdLib => StdLib}/Lib/test/test_atexit.py | 0 .../Lib/test/test_audioop.py | 0 .../Lib/test/test_augassign.py | 0 .../StdLib => StdLib}/Lib/test/test_base64.py | 0 .../Lib/test/test_bigaddrspace.py | 0 .../StdLib => StdLib}/Lib/test/test_bigmem.py | 0 .../Lib/test/test_binascii.py | 0 .../StdLib => StdLib}/Lib/test/test_binhex.py | 0 {Src/StdLib => StdLib}/Lib/test/test_binop.py | 0 .../StdLib => StdLib}/Lib/test/test_bisect.py | 0 {Src/StdLib => StdLib}/Lib/test/test_bool.py | 0 .../StdLib => StdLib}/Lib/test/test_buffer.py | 0 {Src/StdLib => StdLib}/Lib/test/test_bufio.py | 0 .../Lib/test/test_builtin.py | 0 {Src/StdLib => StdLib}/Lib/test/test_bytes.py | 0 {Src/StdLib => StdLib}/Lib/test/test_bz2.py | 0 .../Lib/test/test_calendar.py | 0 {Src/StdLib => StdLib}/Lib/test/test_call.py | 0 {Src/StdLib => StdLib}/Lib/test/test_capi.py | 0 {Src/StdLib => StdLib}/Lib/test/test_cgi.py | 0 {Src/StdLib => StdLib}/Lib/test/test_cgitb.py | 0 .../Lib/test/test_charmapcodec.py | 0 {Src/StdLib => StdLib}/Lib/test/test_class.py | 0 {Src/StdLib => StdLib}/Lib/test/test_cmath.py | 0 {Src/StdLib => StdLib}/Lib/test/test_cmd.py | 0 .../Lib/test/test_cmd_line.py | 0 .../Lib/test/test_cmd_line_script.py | 0 {Src/StdLib => StdLib}/Lib/test/test_code.py | 0 .../Lib/test/test_code_module.py | 0 .../Lib/test/test_codeccallbacks.py | 0 .../Lib/test/test_codecencodings_cn.py | 0 .../Lib/test/test_codecencodings_hk.py | 0 .../Lib/test/test_codecencodings_iso2022.py | 0 .../Lib/test/test_codecencodings_jp.py | 0 .../Lib/test/test_codecencodings_kr.py | 0 .../Lib/test/test_codecencodings_tw.py | 0 .../Lib/test/test_codecmaps_cn.py | 0 .../Lib/test/test_codecmaps_hk.py | 0 .../Lib/test/test_codecmaps_jp.py | 0 .../Lib/test/test_codecmaps_kr.py | 0 .../Lib/test/test_codecmaps_tw.py | 0 .../StdLib => StdLib}/Lib/test/test_codecs.py | 0 .../StdLib => StdLib}/Lib/test/test_codeop.py | 0 .../Lib/test/test_collections.py | 0 .../Lib/test/test_colorsys.py | 0 .../Lib/test/test_compare.py | 0 .../Lib/test/test_compile.py | 0 .../Lib/test/test_compileall.py | 0 .../Lib/test/test_complex.py | 0 .../Lib/test/test_concurrent_futures.py | 0 .../Lib/test/test_configparser.py | 0 .../Lib/test/test_contains.py | 0 .../Lib/test/test_contextlib.py | 0 {Src/StdLib => StdLib}/Lib/test/test_copy.py | 0 .../Lib/test/test_copyreg.py | 0 .../Lib/test/test_cprofile.py | 0 .../Lib/test/test_crashers.py | 0 {Src/StdLib => StdLib}/Lib/test/test_crypt.py | 0 {Src/StdLib => StdLib}/Lib/test/test_csv.py | 0 .../StdLib => StdLib}/Lib/test/test_ctypes.py | 0 .../StdLib => StdLib}/Lib/test/test_curses.py | 0 .../Lib/test/test_datetime.py | 0 {Src/StdLib => StdLib}/Lib/test/test_dbm.py | 0 .../Lib/test/test_dbm_dumb.py | 0 .../Lib/test/test_dbm_gnu.py | 0 .../Lib/test/test_dbm_ndbm.py | 0 .../Lib/test/test_decimal.py | 0 .../Lib/test/test_decorators.py | 0 .../Lib/test/test_defaultdict.py | 0 {Src/StdLib => StdLib}/Lib/test/test_deque.py | 0 {Src/StdLib => StdLib}/Lib/test/test_descr.py | 0 .../Lib/test/test_descrtut.py | 0 .../Lib/test/test_devpoll.py | 0 {Src/StdLib => StdLib}/Lib/test/test_dict.py | 0 .../Lib/test/test_dictcomps.py | 0 .../Lib/test/test_dictviews.py | 0 .../Lib/test/test_difflib.py | 0 .../Lib/test/test_difflib_expect.html | 0 {Src/StdLib => StdLib}/Lib/test/test_dis.py | 0 .../Lib/test/test_distutils.py | 0 .../Lib/test/test_doctest.py | 0 .../Lib/test/test_doctest.txt | 0 .../Lib/test/test_doctest2.py | 0 .../Lib/test/test_doctest2.txt | 0 .../Lib/test/test_doctest3.txt | 0 .../Lib/test/test_doctest4.txt | 0 .../Lib/test/test_docxmlrpc.py | 0 .../Lib/test/test_dummy_thread.py | 0 .../Lib/test/test_dummy_threading.py | 0 .../Lib/test/test_dynamic.py | 0 .../Lib/test/test_dynamicclassattribute.py | 0 .../Lib/test/test_email/__init__.py | 0 .../Lib/test/test_email/__main__.py | 0 .../Lib/test/test_email/data/PyBanner048.gif | Bin .../Lib/test/test_email/data/audiotest.au | Bin .../Lib/test/test_email/data/msg_01.txt | 0 .../Lib/test/test_email/data/msg_02.txt | 0 .../Lib/test/test_email/data/msg_03.txt | 0 .../Lib/test/test_email/data/msg_04.txt | 0 .../Lib/test/test_email/data/msg_05.txt | 0 .../Lib/test/test_email/data/msg_06.txt | 0 .../Lib/test/test_email/data/msg_07.txt | 0 .../Lib/test/test_email/data/msg_08.txt | 0 .../Lib/test/test_email/data/msg_09.txt | 0 .../Lib/test/test_email/data/msg_10.txt | 0 .../Lib/test/test_email/data/msg_11.txt | 0 .../Lib/test/test_email/data/msg_12.txt | 0 .../Lib/test/test_email/data/msg_12a.txt | 0 .../Lib/test/test_email/data/msg_13.txt | 0 .../Lib/test/test_email/data/msg_14.txt | 0 .../Lib/test/test_email/data/msg_15.txt | 0 .../Lib/test/test_email/data/msg_16.txt | 0 .../Lib/test/test_email/data/msg_17.txt | 0 .../Lib/test/test_email/data/msg_18.txt | 0 .../Lib/test/test_email/data/msg_19.txt | 0 .../Lib/test/test_email/data/msg_20.txt | 0 .../Lib/test/test_email/data/msg_21.txt | 0 .../Lib/test/test_email/data/msg_22.txt | 0 .../Lib/test/test_email/data/msg_23.txt | 0 .../Lib/test/test_email/data/msg_24.txt | 0 .../Lib/test/test_email/data/msg_25.txt | 0 .../Lib/test/test_email/data/msg_26.txt | 0 .../Lib/test/test_email/data/msg_27.txt | 0 .../Lib/test/test_email/data/msg_28.txt | 0 .../Lib/test/test_email/data/msg_29.txt | 0 .../Lib/test/test_email/data/msg_30.txt | 0 .../Lib/test/test_email/data/msg_31.txt | 0 .../Lib/test/test_email/data/msg_32.txt | 0 .../Lib/test/test_email/data/msg_33.txt | 0 .../Lib/test/test_email/data/msg_34.txt | 0 .../Lib/test/test_email/data/msg_35.txt | 0 .../Lib/test/test_email/data/msg_36.txt | 0 .../Lib/test/test_email/data/msg_37.txt | 0 .../Lib/test/test_email/data/msg_38.txt | 0 .../Lib/test/test_email/data/msg_39.txt | 0 .../Lib/test/test_email/data/msg_40.txt | 0 .../Lib/test/test_email/data/msg_41.txt | 0 .../Lib/test/test_email/data/msg_42.txt | 0 .../Lib/test/test_email/data/msg_43.txt | 0 .../Lib/test/test_email/data/msg_44.txt | 0 .../Lib/test/test_email/data/msg_45.txt | 0 .../Lib/test/test_email/data/msg_46.txt | 0 .../test/test_email/test__encoded_words.py | 0 .../test_email/test__header_value_parser.py | 0 .../Lib/test/test_email/test_asian_codecs.py | 0 .../test/test_email/test_contentmanager.py | 0 .../test/test_email/test_defect_handling.py | 0 .../Lib/test/test_email/test_email.py | 0 .../Lib/test/test_email/test_generator.py | 0 .../test/test_email/test_headerregistry.py | 0 .../Lib/test/test_email/test_inversion.py | 0 .../Lib/test/test_email/test_message.py | 0 .../Lib/test/test_email/test_parser.py | 0 .../Lib/test/test_email/test_pickleable.py | 0 .../Lib/test/test_email/test_policy.py | 0 .../Lib/test/test_email/test_utils.py | 0 .../Lib/test/test_email/torture_test.py | 0 .../Lib/test/test_ensurepip.py | 0 {Src/StdLib => StdLib}/Lib/test/test_enum.py | 0 .../Lib/test/test_enumerate.py | 0 {Src/StdLib => StdLib}/Lib/test/test_eof.py | 0 {Src/StdLib => StdLib}/Lib/test/test_epoll.py | 0 {Src/StdLib => StdLib}/Lib/test/test_errno.py | 0 .../Lib/test/test_exception_variations.py | 0 .../Lib/test/test_exceptions.py | 0 .../Lib/test/test_extcall.py | 0 .../Lib/test/test_faulthandler.py | 0 {Src/StdLib => StdLib}/Lib/test/test_fcntl.py | 0 {Src/StdLib => StdLib}/Lib/test/test_file.py | 0 .../Lib/test/test_file_eintr.py | 0 .../Lib/test/test_filecmp.py | 0 .../Lib/test/test_fileinput.py | 0 .../StdLib => StdLib}/Lib/test/test_fileio.py | 0 .../Lib/test/test_finalization.py | 0 {Src/StdLib => StdLib}/Lib/test/test_float.py | 0 {Src/StdLib => StdLib}/Lib/test/test_flufl.py | 0 .../Lib/test/test_fnmatch.py | 0 {Src/StdLib => StdLib}/Lib/test/test_fork1.py | 0 .../StdLib => StdLib}/Lib/test/test_format.py | 0 .../Lib/test/test_fractions.py | 0 {Src/StdLib => StdLib}/Lib/test/test_frame.py | 0 .../Lib/test/test_fstring.py | 0 .../StdLib => StdLib}/Lib/test/test_ftplib.py | 0 .../Lib/test/test_funcattrs.py | 0 .../Lib/test/test_functools.py | 0 .../StdLib => StdLib}/Lib/test/test_future.py | 0 .../Lib/test/test_future3.py | 0 .../Lib/test/test_future4.py | 0 .../Lib/test/test_future5.py | 0 {Src/StdLib => StdLib}/Lib/test/test_gc.py | 0 {Src/StdLib => StdLib}/Lib/test/test_gdb.py | 0 .../Lib/test/test_generators.py | 0 .../Lib/test/test_genericpath.py | 0 .../Lib/test/test_genexps.py | 0 .../Lib/test/test_getargs2.py | 0 .../StdLib => StdLib}/Lib/test/test_getopt.py | 0 .../Lib/test/test_getpass.py | 0 .../Lib/test/test_gettext.py | 0 {Src/StdLib => StdLib}/Lib/test/test_glob.py | 0 .../StdLib => StdLib}/Lib/test/test_global.py | 0 .../Lib/test/test_grammar.py | 0 {Src/StdLib => StdLib}/Lib/test/test_grp.py | 0 {Src/StdLib => StdLib}/Lib/test/test_gzip.py | 0 {Src/StdLib => StdLib}/Lib/test/test_hash.py | 0 .../Lib/test/test_hashlib.py | 0 {Src/StdLib => StdLib}/Lib/test/test_heapq.py | 0 {Src/StdLib => StdLib}/Lib/test/test_hmac.py | 0 {Src/StdLib => StdLib}/Lib/test/test_html.py | 0 .../Lib/test/test_htmlparser.py | 0 .../Lib/test/test_http_cookiejar.py | 0 .../Lib/test/test_http_cookies.py | 0 .../Lib/test/test_httplib.py | 0 .../Lib/test/test_httpservers.py | 0 {Src/StdLib => StdLib}/Lib/test/test_idle.py | 0 .../Lib/test/test_imaplib.py | 0 .../StdLib => StdLib}/Lib/test/test_imghdr.py | 0 {Src/StdLib => StdLib}/Lib/test/test_imp.py | 0 .../StdLib => StdLib}/Lib/test/test_import.py | 0 .../Lib/test/test_importlib/__init__.py | 0 .../Lib/test/test_importlib/__main__.py | 0 .../Lib/test/test_importlib/abc.py | 0 .../test/test_importlib/builtin/__init__.py | 0 .../test/test_importlib/builtin/__main__.py | 0 .../test_importlib/builtin/test_finder.py | 0 .../test_importlib/builtin/test_loader.py | 0 .../Lib/test/test_importlib/builtin/util.py | 0 .../test/test_importlib/extension/__init__.py | 0 .../test/test_importlib/extension/__main__.py | 0 .../extension/test_case_sensitivity.py | 0 .../test_importlib/extension/test_finder.py | 0 .../test_importlib/extension/test_loader.py | 0 .../extension/test_path_hook.py | 0 .../Lib/test/test_importlib/extension/util.py | 0 .../test/test_importlib/frozen/__init__.py | 0 .../test/test_importlib/frozen/__main__.py | 0 .../test/test_importlib/frozen/test_finder.py | 0 .../test/test_importlib/frozen/test_loader.py | 0 .../test/test_importlib/import_/__init__.py | 0 .../test/test_importlib/import_/__main__.py | 0 .../test_importlib/import_/test___loader__.py | 0 .../import_/test___package__.py | 0 .../test/test_importlib/import_/test_api.py | 0 .../test_importlib/import_/test_caching.py | 0 .../test_importlib/import_/test_fromlist.py | 0 .../test_importlib/import_/test_meta_path.py | 0 .../test_importlib/import_/test_packages.py | 0 .../test/test_importlib/import_/test_path.py | 0 .../import_/test_relative_imports.py | 0 .../Lib/test/test_importlib/import_/util.py | 0 .../namespace_pkgs/both_portions/foo/one.py | 0 .../namespace_pkgs/both_portions/foo/two.py | 0 .../namespace_pkgs/missing_directory.zip | Bin .../module_and_namespace_package/a_test.py | 0 .../module_and_namespace_package/a_test/empty | 0 .../namespace_pkgs/nested_portion1.zip | Bin .../not_a_namespace_pkg/foo/__init__.py | 0 .../not_a_namespace_pkg/foo/one.py | 0 .../namespace_pkgs/portion1/foo/one.py | 0 .../namespace_pkgs/portion2/foo/two.py | 0 .../project1/parent/child/one.py | 0 .../project2/parent/child/two.py | 0 .../project3/parent/child/three.py | 0 .../namespace_pkgs/top_level_portion1.zip | Bin .../Lib/test/test_importlib/regrtest.py | 0 .../test/test_importlib/source/__init__.py | 0 .../test/test_importlib/source/__main__.py | 0 .../source/test_case_sensitivity.py | 0 .../test_importlib/source/test_file_loader.py | 0 .../test/test_importlib/source/test_finder.py | 0 .../test_importlib/source/test_path_hook.py | 0 .../source/test_source_encoding.py | 0 .../Lib/test/test_importlib/source/util.py | 0 .../Lib/test/test_importlib/test_abc.py | 0 .../Lib/test/test_importlib/test_api.py | 0 .../Lib/test/test_importlib/test_locks.py | 0 .../test_importlib/test_namespace_pkgs.py | 0 .../Lib/test/test_importlib/test_spec.py | 0 .../Lib/test/test_importlib/test_util.py | 0 .../Lib/test/test_importlib/test_windows.py | 0 .../Lib/test/test_importlib/util.py | 0 {Src/StdLib => StdLib}/Lib/test/test_index.py | 0 .../Lib/test/test_inspect.py | 0 {Src/StdLib => StdLib}/Lib/test/test_int.py | 0 .../Lib/test/test_int_literal.py | 0 {Src/StdLib => StdLib}/Lib/test/test_io.py | 0 {Src/StdLib => StdLib}/Lib/test/test_ioctl.py | 0 .../Lib/test/test_ipaddress.py | 0 .../Lib/test/test_isinstance.py | 0 {Src/StdLib => StdLib}/Lib/test/test_iter.py | 0 .../Lib/test/test_iterlen.py | 0 .../Lib/test/test_itertools.py | 0 .../Lib/test/test_json/__init__.py | 0 .../Lib/test/test_json/__main__.py | 0 .../Lib/test/test_json/test_decode.py | 0 .../Lib/test/test_json/test_default.py | 0 .../Lib/test/test_json/test_dump.py | 0 .../test_json/test_encode_basestring_ascii.py | 0 .../Lib/test/test_json/test_enum.py | 0 .../Lib/test/test_json/test_fail.py | 0 .../Lib/test/test_json/test_float.py | 0 .../Lib/test/test_json/test_indent.py | 0 .../Lib/test/test_json/test_pass1.py | 0 .../Lib/test/test_json/test_pass2.py | 0 .../Lib/test/test_json/test_pass3.py | 0 .../Lib/test/test_json/test_recursion.py | 0 .../Lib/test/test_json/test_scanstring.py | 0 .../Lib/test/test_json/test_separators.py | 0 .../Lib/test/test_json/test_speedups.py | 0 .../Lib/test/test_json/test_tool.py | 0 .../Lib/test/test_json/test_unicode.py | 0 .../Lib/test/test_keyword.py | 0 .../Lib/test/test_keywordonlyarg.py | 0 .../StdLib => StdLib}/Lib/test/test_kqueue.py | 0 .../Lib/test/test_largefile.py | 0 .../Lib/test/test_lib2to3.py | 0 .../Lib/test/test_linecache.py | 0 {Src/StdLib => StdLib}/Lib/test/test_list.py | 0 .../Lib/test/test_listcomps.py | 0 .../StdLib => StdLib}/Lib/test/test_locale.py | 0 .../Lib/test/test_logging.py | 0 {Src/StdLib => StdLib}/Lib/test/test_long.py | 0 .../Lib/test/test_longexp.py | 0 {Src/StdLib => StdLib}/Lib/test/test_lzma.py | 0 .../Lib/test/test_macpath.py | 0 .../Lib/test/test_macurl2path.py | 0 .../Lib/test/test_mailbox.py | 0 .../Lib/test/test_mailcap.py | 0 .../Lib/test/test_marshal.py | 0 {Src/StdLib => StdLib}/Lib/test/test_math.py | 0 .../Lib/test/test_memoryio.py | 0 .../Lib/test/test_memoryview.py | 0 .../Lib/test/test_metaclass.py | 0 .../Lib/test/test_mimetypes.py | 0 .../Lib/test/test_minidom.py | 0 {Src/StdLib => StdLib}/Lib/test/test_mmap.py | 0 .../StdLib => StdLib}/Lib/test/test_module.py | 0 .../Lib/test/test_modulefinder.py | 0 .../StdLib => StdLib}/Lib/test/test_msilib.py | 0 .../Lib/test/test_multibytecodec.py | 0 .../Lib/test/test_multiprocessing_fork.py | 0 .../test/test_multiprocessing_forkserver.py | 0 .../test_multiprocessing_main_handling.py | 0 .../Lib/test/test_multiprocessing_spawn.py | 0 {Src/StdLib => StdLib}/Lib/test/test_netrc.py | 0 {Src/StdLib => StdLib}/Lib/test/test_nis.py | 0 .../Lib/test/test_nntplib.py | 0 .../Lib/test/test_normalization.py | 0 .../StdLib => StdLib}/Lib/test/test_ntpath.py | 0 .../Lib/test/test_numeric_tower.py | 0 .../Lib/test/test_opcodes.py | 0 .../Lib/test/test_openpty.py | 0 .../Lib/test/test_operator.py | 0 .../Lib/test/test_optparse.py | 0 .../Lib/test/test_ordered_dict.py | 0 {Src/StdLib => StdLib}/Lib/test/test_os.py | 0 .../Lib/test/test_ossaudiodev.py | 0 .../Lib/test/test_osx_env.py | 0 .../StdLib => StdLib}/Lib/test/test_parser.py | 0 .../Lib/test/test_pathlib.py | 0 {Src/StdLib => StdLib}/Lib/test/test_pdb.py | 0 .../Lib/test/test_peepholer.py | 0 .../StdLib => StdLib}/Lib/test/test_pep247.py | 0 .../StdLib => StdLib}/Lib/test/test_pep277.py | 0 .../StdLib => StdLib}/Lib/test/test_pep292.py | 0 .../Lib/test/test_pep3120.py | 0 .../Lib/test/test_pep3131.py | 0 .../Lib/test/test_pep3151.py | 0 .../StdLib => StdLib}/Lib/test/test_pep352.py | 0 .../StdLib => StdLib}/Lib/test/test_pep380.py | 0 .../StdLib => StdLib}/Lib/test/test_pep479.py | 0 .../StdLib => StdLib}/Lib/test/test_pickle.py | 0 .../Lib/test/test_pickletools.py | 0 {Src/StdLib => StdLib}/Lib/test/test_pipes.py | 0 {Src/StdLib => StdLib}/Lib/test/test_pkg.py | 0 .../Lib/test/test_pkgimport.py | 0 .../Lib/test/test_pkgutil.py | 0 .../Lib/test/test_platform.py | 0 .../Lib/test/test_plistlib.py | 0 {Src/StdLib => StdLib}/Lib/test/test_poll.py | 0 {Src/StdLib => StdLib}/Lib/test/test_popen.py | 0 .../StdLib => StdLib}/Lib/test/test_poplib.py | 0 {Src/StdLib => StdLib}/Lib/test/test_posix.py | 0 .../Lib/test/test_posixpath.py | 0 {Src/StdLib => StdLib}/Lib/test/test_pow.py | 0 .../StdLib => StdLib}/Lib/test/test_pprint.py | 0 {Src/StdLib => StdLib}/Lib/test/test_print.py | 0 .../Lib/test/test_profile.py | 0 .../Lib/test/test_property.py | 0 .../StdLib => StdLib}/Lib/test/test_pstats.py | 0 {Src/StdLib => StdLib}/Lib/test/test_pty.py | 0 .../Lib/test/test_pulldom.py | 0 {Src/StdLib => StdLib}/Lib/test/test_pwd.py | 0 .../Lib/test/test_py_compile.py | 0 .../StdLib => StdLib}/Lib/test/test_pyclbr.py | 0 {Src/StdLib => StdLib}/Lib/test/test_pydoc.py | 0 .../Lib/test/test_pyexpat.py | 0 {Src/StdLib => StdLib}/Lib/test/test_queue.py | 0 .../StdLib => StdLib}/Lib/test/test_quopri.py | 0 {Src/StdLib => StdLib}/Lib/test/test_raise.py | 0 .../StdLib => StdLib}/Lib/test/test_random.py | 0 {Src/StdLib => StdLib}/Lib/test/test_range.py | 0 {Src/StdLib => StdLib}/Lib/test/test_re.py | 0 .../Lib/test/test_readline.py | 0 .../Lib/test/test_regrtest.py | 0 .../Lib/test/test_reprlib.py | 0 .../Lib/test/test_resource.py | 0 .../Lib/test/test_richcmp.py | 0 .../Lib/test/test_rlcompleter.py | 0 .../Lib/test/test_robotparser.py | 0 {Src/StdLib => StdLib}/Lib/test/test_runpy.py | 0 {Src/StdLib => StdLib}/Lib/test/test_sax.py | 0 {Src/StdLib => StdLib}/Lib/test/test_sched.py | 0 {Src/StdLib => StdLib}/Lib/test/test_scope.py | 0 .../Lib/test/test_script_helper.py | 0 .../StdLib => StdLib}/Lib/test/test_select.py | 0 .../Lib/test/test_selectors.py | 0 {Src/StdLib => StdLib}/Lib/test/test_set.py | 0 .../Lib/test/test_setcomps.py | 0 .../StdLib => StdLib}/Lib/test/test_shelve.py | 0 {Src/StdLib => StdLib}/Lib/test/test_shlex.py | 0 .../StdLib => StdLib}/Lib/test/test_shutil.py | 0 .../StdLib => StdLib}/Lib/test/test_signal.py | 0 {Src/StdLib => StdLib}/Lib/test/test_site.py | 0 {Src/StdLib => StdLib}/Lib/test/test_slice.py | 0 {Src/StdLib => StdLib}/Lib/test/test_smtpd.py | 0 .../Lib/test/test_smtplib.py | 0 .../Lib/test/test_smtpnet.py | 0 .../StdLib => StdLib}/Lib/test/test_sndhdr.py | 0 .../StdLib => StdLib}/Lib/test/test_socket.py | 0 .../Lib/test/test_socketserver.py | 0 {Src/StdLib => StdLib}/Lib/test/test_sort.py | 0 .../Lib/test/test_source_encoding.py | 0 {Src/StdLib => StdLib}/Lib/test/test_spwd.py | 0 .../StdLib => StdLib}/Lib/test/test_sqlite.py | 0 {Src/StdLib => StdLib}/Lib/test/test_ssl.py | 0 .../Lib/test/test_startfile.py | 0 {Src/StdLib => StdLib}/Lib/test/test_stat.py | 0 .../Lib/test/test_statistics.py | 0 .../Lib/test/test_strftime.py | 0 .../StdLib => StdLib}/Lib/test/test_string.py | 0 .../Lib/test/test_stringprep.py | 0 .../StdLib => StdLib}/Lib/test/test_strlit.py | 0 .../Lib/test/test_strptime.py | 0 .../StdLib => StdLib}/Lib/test/test_strtod.py | 0 .../StdLib => StdLib}/Lib/test/test_struct.py | 0 .../Lib/test/test_structmembers.py | 0 .../Lib/test/test_structseq.py | 0 .../Lib/test/test_subprocess.py | 0 {Src/StdLib => StdLib}/Lib/test/test_sunau.py | 0 .../StdLib => StdLib}/Lib/test/test_sundry.py | 0 {Src/StdLib => StdLib}/Lib/test/test_super.py | 0 .../Lib/test/test_support.py | 0 .../Lib/test/test_symtable.py | 0 .../StdLib => StdLib}/Lib/test/test_syntax.py | 0 {Src/StdLib => StdLib}/Lib/test/test_sys.py | 0 .../Lib/test/test_sys_setprofile.py | 0 .../Lib/test/test_sys_settrace.py | 0 .../Lib/test/test_sysconfig.py | 0 .../StdLib => StdLib}/Lib/test/test_syslog.py | 0 .../Lib/test/test_tarfile.py | 0 {Src/StdLib => StdLib}/Lib/test/test_tcl.py | 0 .../Lib/test/test_telnetlib.py | 0 .../Lib/test/test_tempfile.py | 0 .../Lib/test/test_textwrap.py | 0 .../StdLib => StdLib}/Lib/test/test_thread.py | 0 .../Lib/test/test_threaded_import.py | 0 .../Lib/test/test_threadedtempfile.py | 0 .../Lib/test/test_threading.py | 0 .../Lib/test/test_threading_local.py | 0 .../Lib/test/test_threadsignals.py | 0 {Src/StdLib => StdLib}/Lib/test/test_time.py | 0 .../StdLib => StdLib}/Lib/test/test_timeit.py | 0 .../Lib/test/test_timeout.py | 0 {Src/StdLib => StdLib}/Lib/test/test_tk.py | 0 .../Lib/test/test_tokenize.py | 0 .../Lib/test/test_tools/__init__.py | 0 .../Lib/test/test_tools/__main__.py | 0 .../Lib/test/test_tools/test_gprof2html.py | 0 .../Lib/test/test_tools/test_md5sum.py | 0 .../Lib/test/test_tools/test_pdeps.py | 0 .../Lib/test/test_tools/test_pindent.py | 0 .../Lib/test/test_tools/test_reindent.py | 0 .../Lib/test/test_tools/test_sundry.py | 0 .../Lib/test/test_tools/test_unparse.py | 0 {Src/StdLib => StdLib}/Lib/test/test_trace.py | 0 .../Lib/test/test_traceback.py | 0 .../Lib/test/test_tracemalloc.py | 0 .../Lib/test/test_ttk_guionly.py | 0 .../Lib/test/test_ttk_textonly.py | 0 {Src/StdLib => StdLib}/Lib/test/test_tuple.py | 0 .../Lib/test/test_typechecks.py | 0 {Src/StdLib => StdLib}/Lib/test/test_types.py | 0 .../StdLib => StdLib}/Lib/test/test_typing.py | 0 {Src/StdLib => StdLib}/Lib/test/test_ucn.py | 0 {Src/StdLib => StdLib}/Lib/test/test_unary.py | 0 .../Lib/test/test_unicode.py | 0 .../Lib/test/test_unicode_file.py | 0 .../Lib/test/test_unicodedata.py | 0 .../Lib/test/test_unittest.py | 0 .../Lib/test/test_univnewlines.py | 0 .../StdLib => StdLib}/Lib/test/test_unpack.py | 0 .../Lib/test/test_unpack_ex.py | 0 .../StdLib => StdLib}/Lib/test/test_urllib.py | 0 .../Lib/test/test_urllib2.py | 0 .../Lib/test/test_urllib2_localnet.py | 0 .../Lib/test/test_urllib2net.py | 0 .../Lib/test/test_urllib_response.py | 0 .../Lib/test/test_urllibnet.py | 0 .../Lib/test/test_urlparse.py | 0 .../Lib/test/test_userdict.py | 0 .../Lib/test/test_userlist.py | 0 .../Lib/test/test_userstring.py | 0 .../Lib/test/test_utf8_mode.py | 0 {Src/StdLib => StdLib}/Lib/test/test_uu.py | 0 {Src/StdLib => StdLib}/Lib/test/test_uuid.py | 0 {Src/StdLib => StdLib}/Lib/test/test_venv.py | 0 {Src/StdLib => StdLib}/Lib/test/test_wait3.py | 0 {Src/StdLib => StdLib}/Lib/test/test_wait4.py | 0 .../Lib/test/test_warnings.py | 0 {Src/StdLib => StdLib}/Lib/test/test_wave.py | 0 .../Lib/test/test_weakref.py | 0 .../Lib/test/test_weakset.py | 0 .../Lib/test/test_webbrowser.py | 0 .../StdLib => StdLib}/Lib/test/test_winreg.py | 0 .../Lib/test/test_winsound.py | 0 {Src/StdLib => StdLib}/Lib/test/test_with.py | 0 .../Lib/test/test_wsgiref.py | 0 .../StdLib => StdLib}/Lib/test/test_xdrlib.py | 0 .../Lib/test/test_xml_dom_minicompat.py | 0 .../Lib/test/test_xml_etree.py | 0 .../Lib/test/test_xml_etree_c.py | 0 .../StdLib => StdLib}/Lib/test/test_xmlrpc.py | 0 .../Lib/test/test_xmlrpc_net.py | 0 .../Lib/test/test_zipfile.py | 0 .../Lib/test/test_zipfile64.py | 0 .../Lib/test/test_zipimport.py | 0 .../Lib/test/test_zipimport_support.py | 0 {Src/StdLib => StdLib}/Lib/test/test_zlib.py | 0 {Src/StdLib => StdLib}/Lib/test/testcodec.py | 0 {Src/StdLib => StdLib}/Lib/test/testtar.tar | Bin .../Lib/test/tf_inherit_check.py | 0 .../Lib/test/threaded_import_hangers.py | 0 .../Lib/test/time_hashlib.py | 0 ...-latin1-coding-cookie-and-utf8-bom-sig.txt | 0 ...no-coding-cookie-and-utf8-bom-sig-only.txt | 0 ...utf8-coding-cookie-and-no-utf8-bom-sig.txt | 0 ...ts-utf8-coding-cookie-and-utf8-bom-sig.txt | 0 .../Lib/test/tokenize_tests.txt | 0 .../Lib/test/tracedmodules/__init__.py | 0 .../Lib/test/tracedmodules/testmod.py | 0 .../Lib/test/warning_tests.py | 0 .../Lib/test/win_console_handler.py | 0 .../Lib/test/xmltestdata/simple-ns.xml | 0 .../Lib/test/xmltestdata/simple.xml | 0 .../Lib/test/xmltestdata/test.xml | 0 .../Lib/test/xmltestdata/test.xml.out | 0 {Src/StdLib => StdLib}/Lib/test/xmltests.py | 0 .../Lib/test/zip_cp437_header.zip | Bin {Src/StdLib => StdLib}/Lib/test/zipdir.zip | Bin {Src/StdLib => StdLib}/Lib/textwrap.py | 0 {Src/StdLib => StdLib}/Lib/this.py | 0 {Src/StdLib => StdLib}/Lib/threading.py | 0 {Src/StdLib => StdLib}/Lib/timeit.py | 0 .../StdLib => StdLib}/Lib/tkinter/__init__.py | 0 .../StdLib => StdLib}/Lib/tkinter/__main__.py | 0 {Src/StdLib => StdLib}/Lib/tkinter/_fix.py | 0 .../Lib/tkinter/colorchooser.py | 0 .../Lib/tkinter/commondialog.py | 0 .../Lib/tkinter/constants.py | 0 {Src/StdLib => StdLib}/Lib/tkinter/dialog.py | 0 {Src/StdLib => StdLib}/Lib/tkinter/dnd.py | 0 .../Lib/tkinter/filedialog.py | 0 {Src/StdLib => StdLib}/Lib/tkinter/font.py | 0 .../Lib/tkinter/messagebox.py | 0 .../Lib/tkinter/scrolledtext.py | 0 .../Lib/tkinter/simpledialog.py | 0 .../StdLib => StdLib}/Lib/tkinter/test/README | 0 .../Lib/tkinter/test/__init__.py | 0 .../Lib/tkinter/test/runtktests.py | 0 .../Lib/tkinter/test/support.py | 0 .../Lib/tkinter/test/test_tkinter/__init__.py | 0 .../tkinter/test/test_tkinter/test_font.py | 0 .../test_tkinter/test_geometry_managers.py | 0 .../tkinter/test/test_tkinter/test_images.py | 0 .../tkinter/test/test_tkinter/test_loadtk.py | 0 .../tkinter/test/test_tkinter/test_misc.py | 0 .../tkinter/test/test_tkinter/test_text.py | 0 .../test/test_tkinter/test_variables.py | 0 .../tkinter/test/test_tkinter/test_widgets.py | 0 .../Lib/tkinter/test/test_ttk/__init__.py | 0 .../tkinter/test/test_ttk/test_extensions.py | 0 .../tkinter/test/test_ttk/test_functions.py | 0 .../Lib/tkinter/test/test_ttk/test_style.py | 0 .../Lib/tkinter/test/test_ttk/test_widgets.py | 0 .../Lib/tkinter/test/widget_tests.py | 0 {Src/StdLib => StdLib}/Lib/tkinter/tix.py | 0 {Src/StdLib => StdLib}/Lib/tkinter/ttk.py | 0 {Src/StdLib => StdLib}/Lib/token.py | 0 {Src/StdLib => StdLib}/Lib/tokenize.py | 0 {Src/StdLib => StdLib}/Lib/trace.py | 0 {Src/StdLib => StdLib}/Lib/traceback.py | 0 {Src/StdLib => StdLib}/Lib/tracemalloc.py | 0 {Src/StdLib => StdLib}/Lib/tty.py | 0 {Src/StdLib => StdLib}/Lib/turtle.py | 0 .../Lib/turtledemo/__init__.py | 0 .../Lib/turtledemo/__main__.py | 0 .../Lib/turtledemo/bytedesign.py | 0 .../StdLib => StdLib}/Lib/turtledemo/chaos.py | 0 .../StdLib => StdLib}/Lib/turtledemo/clock.py | 0 .../Lib/turtledemo/colormixer.py | 0 .../Lib/turtledemo/forest.py | 0 .../Lib/turtledemo/fractalcurves.py | 0 .../Lib/turtledemo/lindenmayer.py | 0 .../Lib/turtledemo/minimal_hanoi.py | 0 {Src/StdLib => StdLib}/Lib/turtledemo/nim.py | 0 .../StdLib => StdLib}/Lib/turtledemo/paint.py | 0 .../StdLib => StdLib}/Lib/turtledemo/peace.py | 0 .../Lib/turtledemo/penrose.py | 0 .../Lib/turtledemo/planet_and_moon.py | 0 .../Lib/turtledemo/round_dance.py | 0 {Src/StdLib => StdLib}/Lib/turtledemo/tree.py | 0 .../Lib/turtledemo/turtle.cfg | 0 .../Lib/turtledemo/two_canvases.py | 0 .../Lib/turtledemo/wikipedia.py | 0 .../Lib/turtledemo/yinyang.py | 0 {Src/StdLib => StdLib}/Lib/types.py | 0 {Src/StdLib => StdLib}/Lib/typing.py | 0 .../Lib/unittest/__init__.py | 0 .../Lib/unittest/__main__.py | 0 {Src/StdLib => StdLib}/Lib/unittest/case.py | 0 {Src/StdLib => StdLib}/Lib/unittest/loader.py | 0 {Src/StdLib => StdLib}/Lib/unittest/main.py | 0 {Src/StdLib => StdLib}/Lib/unittest/mock.py | 0 {Src/StdLib => StdLib}/Lib/unittest/result.py | 0 {Src/StdLib => StdLib}/Lib/unittest/runner.py | 0 .../StdLib => StdLib}/Lib/unittest/signals.py | 0 {Src/StdLib => StdLib}/Lib/unittest/suite.py | 0 .../Lib/unittest/test/__init__.py | 0 .../Lib/unittest/test/__main__.py | 0 .../Lib/unittest/test/_test_warnings.py | 0 .../Lib/unittest/test/dummy.py | 0 .../Lib/unittest/test/support.py | 0 .../Lib/unittest/test/test_assertions.py | 0 .../Lib/unittest/test/test_break.py | 0 .../Lib/unittest/test/test_case.py | 0 .../Lib/unittest/test/test_discovery.py | 0 .../unittest/test/test_functiontestcase.py | 0 .../Lib/unittest/test/test_loader.py | 0 .../Lib/unittest/test/test_program.py | 0 .../Lib/unittest/test/test_result.py | 0 .../Lib/unittest/test/test_runner.py | 0 .../Lib/unittest/test/test_setups.py | 0 .../Lib/unittest/test/test_skipping.py | 0 .../Lib/unittest/test/test_suite.py | 0 .../Lib/unittest/test/testmock/__init__.py | 0 .../Lib/unittest/test/testmock/__main__.py | 0 .../Lib/unittest/test/testmock/support.py | 0 .../unittest/test/testmock/testcallable.py | 0 .../Lib/unittest/test/testmock/testhelpers.py | 0 .../test/testmock/testmagicmethods.py | 0 .../Lib/unittest/test/testmock/testmock.py | 0 .../Lib/unittest/test/testmock/testpatch.py | 0 .../unittest/test/testmock/testsentinel.py | 0 .../Lib/unittest/test/testmock/testwith.py | 0 {Src/StdLib => StdLib}/Lib/unittest/util.py | 0 {Src/StdLib => StdLib}/Lib/urllib/__init__.py | 0 {Src/StdLib => StdLib}/Lib/urllib/error.py | 0 {Src/StdLib => StdLib}/Lib/urllib/parse.py | 0 {Src/StdLib => StdLib}/Lib/urllib/request.py | 0 {Src/StdLib => StdLib}/Lib/urllib/response.py | 0 .../Lib/urllib/robotparser.py | 0 {Src/StdLib => StdLib}/Lib/uu.py | 0 {Src/StdLib => StdLib}/Lib/uuid.py | 0 {Src/StdLib => StdLib}/Lib/venv/__init__.py | 0 {Src/StdLib => StdLib}/Lib/venv/__main__.py | 0 .../Lib/venv/scripts/nt/Activate.ps1 | 0 .../Lib/venv/scripts/nt/activate.bat | 0 .../Lib/venv/scripts/nt/deactivate.bat | 0 .../Lib/venv/scripts/posix/activate | 0 .../Lib/venv/scripts/posix/activate.csh | 0 .../Lib/venv/scripts/posix/activate.fish | 0 {Src/StdLib => StdLib}/Lib/warnings.py | 0 {Src/StdLib => StdLib}/Lib/wave.py | 0 {Src/StdLib => StdLib}/Lib/weakref.py | 0 {Src/StdLib => StdLib}/Lib/webbrowser.py | 0 {Src/StdLib => StdLib}/Lib/wpf.py | 0 .../StdLib => StdLib}/Lib/wsgiref/__init__.py | 0 .../StdLib => StdLib}/Lib/wsgiref/handlers.py | 0 {Src/StdLib => StdLib}/Lib/wsgiref/headers.py | 0 .../Lib/wsgiref/simple_server.py | 0 {Src/StdLib => StdLib}/Lib/wsgiref/util.py | 0 .../StdLib => StdLib}/Lib/wsgiref/validate.py | 0 {Src/StdLib => StdLib}/Lib/xdrlib.py | 0 {Src/StdLib => StdLib}/Lib/xml/__init__.py | 0 .../Lib/xml/dom/NodeFilter.py | 0 .../StdLib => StdLib}/Lib/xml/dom/__init__.py | 0 {Src/StdLib => StdLib}/Lib/xml/dom/domreg.py | 0 .../Lib/xml/dom/expatbuilder.py | 0 .../Lib/xml/dom/minicompat.py | 0 {Src/StdLib => StdLib}/Lib/xml/dom/minidom.py | 0 {Src/StdLib => StdLib}/Lib/xml/dom/pulldom.py | 0 .../Lib/xml/dom/xmlbuilder.py | 0 .../Lib/xml/etree/ElementInclude.py | 0 .../Lib/xml/etree/ElementPath.py | 0 .../Lib/xml/etree/ElementTree.py | 0 .../Lib/xml/etree/__init__.py | 0 .../Lib/xml/etree/cElementTree.py | 0 .../Lib/xml/parsers/__init__.py | 0 .../Lib/xml/parsers/expat.py | 0 .../StdLib => StdLib}/Lib/xml/sax/__init__.py | 0 .../Lib/xml/sax/_exceptions.py | 0 .../Lib/xml/sax/expatreader.py | 0 {Src/StdLib => StdLib}/Lib/xml/sax/handler.py | 0 .../StdLib => StdLib}/Lib/xml/sax/saxutils.py | 0 .../Lib/xml/sax/xmlreader.py | 0 {Src/StdLib => StdLib}/Lib/xmlrpc/__init__.py | 0 {Src/StdLib => StdLib}/Lib/xmlrpc/client.py | 0 {Src/StdLib => StdLib}/Lib/xmlrpc/server.py | 0 {Src/StdLib => StdLib}/Lib/zipfile.py | 0 {Src/StdLib => StdLib}/StdLib.License.txt | 0 {Src/StdLib => StdLib}/StdLib.pyproj | 0 {Src/StdLib => StdLib}/stdlib-upgrade.txt | 0 {Src/StdLib => StdLib}/update-stdlib.cmd | 0 {Src/StdLib => StdLib}/update-stdlib.sh | 0 {Src/Tests => Tests}/AssemblyInfo.cs | 0 {Src/Tests => Tests}/AttrInjectorTest.cs | 0 {Src/Tests => Tests}/BindTest.cs | 0 {Src/Tests => Tests}/BinderTest.cs | 0 {Src/Tests => Tests}/Cases/CPythonCases.cs | 0 .../Cases/CPythonCasesManifest.ini | 0 {Src/Tests => Tests}/Cases/CaseExecuter.cs | 0 {Src/Tests => Tests}/Cases/CaseGenerator.cs | 0 {Src/Tests => Tests}/Cases/CommonCases.cs | 0 {Src/Tests => Tests}/Cases/IronPythonCases.cs | 0 .../Cases/IronPythonCasesManifest.ini | 0 {Src/Tests => Tests}/ClrType.cs | 0 {Src/Tests => Tests}/Cmplx.cs | 0 {Src/Tests => Tests}/Conversions.cs | 0 {Src/Tests => Tests}/DeTest.cs | 0 {Src/Tests => Tests}/DelegateTest.cs | 0 {Src/Tests => Tests}/DynamicRegressions.cs | 0 {Src/Tests => Tests}/EncodingTest.cs | 0 {Src/Tests => Tests}/EngineTest.cs | 0 {Src/Tests => Tests}/Enums.cs | 0 {Src/Tests => Tests}/Events.cs | 0 {Src/Tests => Tests}/ExceptionConverter.cs | 0 {Src/Tests => Tests}/Exceptions.cs | 0 {Src/Tests => Tests}/Explicit.cs | 0 {Src/Tests => Tests}/ExtensionMethodTest.cs | 0 {Src/Tests => Tests}/GenMeth.cs | 0 {Src/Tests => Tests}/Indexable.cs | 0 {Src/Tests => Tests}/InheritTest.cs | 0 {Src/Tests => Tests}/IntegerTest.cs | 0 {Src/Tests => Tests}/IronMath.cs | 0 {Src/Tests => Tests}/IronPython.Tests.csproj | 0 {Src/Tests => Tests}/LoadTest.cs | 0 {Src/Tests => Tests}/MemberMappingTests.cs | 0 {Src/Tests => Tests}/MemberOverloadTest.cs | 0 {Src/Tests => Tests}/MethodParametersStubs.cs | 0 {Src/Tests => Tests}/NestedClass.cs | 0 {Src/Tests => Tests}/NullableTest.cs | 0 {Src/Tests => Tests}/OperatorTest.cs | 0 {Src/Tests => Tests}/ProtocolTest.cs | 0 {Src/Tests => Tests}/StaticTest.cs | 0 {Src/Tests => Tests}/Stress/Engine.cs | 0 .../StringDictionaryStorage.cs | 0 {Src/Tests => Tests}/TestBuiltinModule.cs | 0 {Src/Tests => Tests}/TypeDescriptor.cs | 0 {Src/Tests => Tests}/Util/IniParser.cs | 0 {Src/Tests => Tests}/Util/TestManifest.cs | 0 {Src/Wpf => Wpf}/DynamicXamlReader.cs | 0 {Src/Wpf => Wpf}/IronPython.Wpf.csproj | 0 {Src/Wpf => Wpf}/Properties/AssemblyInfo.cs | 0 {Src/Wpf => Wpf}/_wpf.cs | 0 2687 files changed, 23 insertions(+), 22 deletions(-) rename Src/App.Debug.config => App.Debug.config (100%) rename Src/App.Release.config => App.Release.config (100%) rename {Src/CTypes => CTypes}/Makefile (100%) rename {Src/CTypes => CTypes}/_ctypes_test.c (100%) rename {Src/CTypes => CTypes}/_ctypes_test.sln (100%) rename {Src/CTypes => CTypes}/_ctypes_test.vcxproj (100%) rename {Src/CompilerServices => CompilerServices}/AssemblyResolver.cs (100%) rename {Src/CompilerServices => CompilerServices}/Config.cs (100%) rename {Src/CompilerServices => CompilerServices}/ConsoleOps.cs (100%) rename {Src/CompilerServices => CompilerServices}/IronPython.CompilerServices.csproj (84%) rename {Src/CompilerServices => CompilerServices}/Program.cs (100%) rename {Src/CompilerServices => CompilerServices}/Properties/AssemblyInfo.cs (100%) rename {Src/CompilerServices => CompilerServices}/README.md (100%) rename {Src/Console.Host => Console.Host}/IronPython.Console.Host.csproj (100%) rename {Src/Console.Host => Console.Host}/IronPythonWindow.cs (100%) rename {Src/Console.Host => Console.Host}/Properties/AssemblyInfo.cs (100%) rename {Src/Console.Host => Console.Host}/ipyw.ico (100%) rename {Src/Console => Console}/Console.cs (100%) rename {Src/Console => Console}/IronPython.Console.csproj (100%) rename {Src/Console => Console}/Properties/AssemblyInfo.cs (100%) rename {Src/Console => Console}/app.manifest (100%) rename {Src/Console => Console}/ipy-mono.sh (100%) rename {Src/Console => Console}/ipy.ico (100%) rename {Src/Console => Console}/ipy.sh (100%) rename {Src/Console => Console}/runtimeconfig.template.json (100%) rename {Src/Console32.Host => Console32.Host}/IronPython.Console32.Host.csproj (79%) rename {Src/Console32 => Console32}/IronPython.Console32.csproj (100%) create mode 160000 DLR rename {Src/IronPython => IronPython}/Compiler/Ast/AndExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/AnnotatedAssignStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/AssertStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/AssignmentStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/AstMethods.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/AsyncStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/AugmentedAssignStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/BinaryExpression.Generated.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/BinaryExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/BreakStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/CallExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/ClassDefinition.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/Comprehension.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/ComprehensionFor.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/ComprehensionIf.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/ConditionalExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/ConstantExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/ContinueStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/DelStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/DictionaryExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/DottedName.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/DynamicConvertExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/DynamicGetMemberExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/EmptyStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/ErrorExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/Expression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/ExpressionStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/FlowChecker.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/ForStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/FormattedValueExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/FromImportStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/FunctionDefinition.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/GeneratorExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/GetGlobalContextExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/GetParentContextFromFunctionExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/GlobalStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/ILoopStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/IfStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/IfStatementTest.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/ImportStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/IndexExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/JoinedStringExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/Keyword.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/LambdaExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/ListExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/MemberExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/ModuleName.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/NameExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/Node.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/NonlocalStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/OrExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/Parameter.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/ParenthesisExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/PythonAst.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/PythonConstantExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/PythonNameBinder.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/PythonReference.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/PythonVariable.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/PythonWalker.Generated.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/RaiseStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/RelativeModuleName.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/ReturnStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/ScopeStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/SequenceExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/SerializedScopeStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/SetExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/SliceExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/StarredExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/Statement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/SuiteStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/TryStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/TupleExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/UnaryExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/VariableKind.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/WhileStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/WithStatement.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/YieldExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Ast/YieldFromExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/ClosureExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/ClosureInfo.cs (100%) rename {Src/IronPython => IronPython}/Compiler/CollectableCompilationMode.cs (100%) rename {Src/IronPython => IronPython}/Compiler/CompilationMode.cs (100%) rename {Src/IronPython => IronPython}/Compiler/GeneratorRewriter.cs (100%) rename {Src/IronPython => IronPython}/Compiler/LazyCode.cs (100%) rename {Src/IronPython => IronPython}/Compiler/LookupCompilationMode.cs (100%) rename {Src/IronPython => IronPython}/Compiler/OnDiskScriptCode.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Parser.cs (100%) rename {Src/IronPython => IronPython}/Compiler/PythonCallTargets.cs (100%) rename {Src/IronPython => IronPython}/Compiler/PythonCompilerOptions.cs (100%) rename {Src/IronPython => IronPython}/Compiler/PythonDynamicExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/PythonGlobal.cs (100%) rename {Src/IronPython => IronPython}/Compiler/PythonGlobalVariableExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/PythonOperator.cs (100%) rename {Src/IronPython => IronPython}/Compiler/PythonSavableScriptCode.cs (100%) rename {Src/IronPython => IronPython}/Compiler/PythonScriptCode.cs (100%) rename {Src/IronPython => IronPython}/Compiler/ReducableDynamicExpression.cs (100%) rename {Src/IronPython => IronPython}/Compiler/RunnableScriptCode.cs (100%) rename {Src/IronPython => IronPython}/Compiler/RuntimeScriptCode.cs (100%) rename {Src/IronPython => IronPython}/Compiler/ToDiskCompilationMode.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Token.cs (100%) rename {Src/IronPython => IronPython}/Compiler/TokenKind.Generated.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Tokenizer.Generated.cs (100%) rename {Src/IronPython => IronPython}/Compiler/Tokenizer.cs (100%) rename {Src/IronPython => IronPython}/Compiler/UncollectableCompilationMode.Generated.cs (100%) rename {Src/IronPython => IronPython}/Compiler/UncollectableCompilationMode.cs (100%) rename {Src/IronPython => IronPython}/FakeInteropServices.cs (100%) rename {Src/IronPython => IronPython}/Hosting/Python.cs (100%) rename {Src/IronPython => IronPython}/Hosting/PythonCodeDomCodeGen.cs (100%) rename {Src/IronPython => IronPython}/Hosting/PythonCommandLine.cs (100%) rename {Src/IronPython => IronPython}/Hosting/PythonConsoleOptions.cs (100%) rename {Src/IronPython => IronPython}/Hosting/PythonOptionsParser.cs (100%) rename {Src/IronPython => IronPython}/Hosting/PythonService.cs (100%) rename {Src/IronPython => IronPython}/Interop/Windows/Interop.Libraries.cs (100%) rename {Src/IronPython => IronPython}/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs (100%) rename {Src/IronPython => IronPython}/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs (100%) rename {Src/IronPython => IronPython}/Interop/Windows/NtDll/Interop.RtlGetVersion.cs (100%) rename {Src/IronPython => IronPython}/Interop/Windows/Ucrtbase/Interop.strerror.cs (100%) rename {Src/IronPython => IronPython}/IronPython.csproj (94%) rename {Src/IronPython => IronPython}/Lib/iptest/__init__.py (100%) rename {Src/IronPython => IronPython}/Lib/iptest/cominterop_util.py (100%) rename {Src/IronPython => IronPython}/Lib/iptest/console_util.py (100%) rename {Src/IronPython => IronPython}/Lib/iptest/file_util.py (100%) rename {Src/IronPython => IronPython}/Lib/iptest/ipunittest.py (100%) rename {Src/IronPython => IronPython}/Lib/iptest/misc_util.py (100%) rename {Src/IronPython => IronPython}/Lib/iptest/process_util.py (100%) rename {Src/IronPython => IronPython}/Lib/iptest/runner.py (100%) rename {Src/IronPython => IronPython}/Lib/iptest/test_env.py (100%) rename {Src/IronPython => IronPython}/Lib/iptest/type_util.py (100%) rename {Src/IronPython => IronPython}/Modules/Builtin.Generated.cs (100%) rename {Src/IronPython => IronPython}/Modules/Builtin.cs (100%) rename {Src/IronPython => IronPython}/Modules/_ast.cs (100%) mode change 100755 => 100644 rename {Src/IronPython => IronPython}/Modules/_fileio.cs (100%) rename {Src/IronPython => IronPython}/Modules/_imp.cs (100%) rename {Src/IronPython => IronPython}/Modules/_io.cs (100%) rename {Src/IronPython => IronPython}/Modules/_io/BytesIO.cs (100%) rename {Src/IronPython => IronPython}/Modules/_io/StringIO.cs (100%) rename {Src/IronPython => IronPython}/Modules/_locale.cs (100%) rename {Src/IronPython => IronPython}/Modules/sys.cs (100%) rename {Src/IronPython => IronPython}/Modules/unicodedata.cs (100%) rename {Src/IronPython => IronPython}/Modules/unicodedata/CaseFolding.txt (100%) rename {Src/IronPython => IronPython}/Modules/unicodedata/EastAsianWidth-3.2.0.txt (100%) rename {Src/IronPython => IronPython}/Modules/unicodedata/EastAsianWidth.txt (100%) rename {Src/IronPython => IronPython}/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz (100%) rename {Src/IronPython => IronPython}/Modules/unicodedata/IPyUnicodeData.txt.gz (100%) rename {Src/IronPython => IronPython}/Modules/unicodedata/NameAliases.txt (100%) rename {Src/IronPython => IronPython}/Modules/unicodedata/UnicodeData-3.2.0.txt (100%) rename {Src/IronPython => IronPython}/Modules/unicodedata/UnicodeData.txt (100%) rename {Src/IronPython => IronPython}/Modules/unicodedata/genunicodedata.py (100%) rename {Src/IronPython => IronPython}/Modules/unicodedata/license.txt (100%) rename {Src/IronPython => IronPython}/Properties/AssemblyInfo.cs (100%) rename {Src => IronPython}/README.md (100%) rename {Src/IronPython => IronPython}/Resources.Designer.cs (100%) rename {Src/IronPython => IronPython}/Resources.resx (100%) rename {Src/IronPython => IronPython}/Runtime/ArrayData.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/BinaryRetTypeBinder.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/BinaryRetTypeBinder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/Binders.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/BindingHelpers.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/BindingWarnings.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/CompatibilityInvokeBinder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/ConditionalBuilder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/ContextArgBuilder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/ConversionBinder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/CreateFallbackBinder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/FastBindResult.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/FastGetBase.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/FastSetBase.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/IComConvertible.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/IFastGettable.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/IFastInvokable.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/IFastSettable.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/IPythonConvertible.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/IPythonExpandable.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/IPythonGetable.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/IPythonInvokable.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/IPythonOperable.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/IPythonSite.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/MetaBuiltinFunction.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/MetaBuiltinMethodDescriptor.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/MetaMethod.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/MetaPythonFunction.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/MetaPythonObject.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/MetaPythonType.Calls.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/MetaPythonType.Members.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/MetaPythonType.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/MetaUserObject.Members.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/MetaUserObject.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/PythonBinaryOperationBinder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/PythonBinder.Create.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/PythonBinder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/PythonDeleteIndexBinder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/PythonDeleteMemberBinder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/PythonDeleteSliceBinder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/PythonExtensionBinder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/PythonGetIndexBinder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/PythonGetMemberBinder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/PythonGetSliceBinder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/PythonIndexType.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/PythonInvokeBinder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/PythonOperationBinder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/PythonOperationKind.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/PythonOverloadResolver.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/PythonProtocol.Operations.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/PythonProtocol.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/PythonSetIndexBinder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/PythonSetMemberBinder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/PythonSetSliceBinder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/PythonUnaryOperationBinder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/SiteLocalStorageBuilder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/SlotOrFunction.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Binding/WarningInfo.cs (100%) rename {Src/IronPython => IronPython}/Runtime/BufferProtocol.cs (100%) rename {Src/IronPython => IronPython}/Runtime/BuiltinPythonModule.cs (100%) rename {Src/IronPython => IronPython}/Runtime/BuiltinsDictionaryStorage.cs (100%) rename {Src/IronPython => IronPython}/Runtime/ByteArray.cs (100%) rename {Src/IronPython => IronPython}/Runtime/ByteArrayIterator.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Bytes.cs (100%) rename {Src/IronPython => IronPython}/Runtime/BytesIterator.cs (100%) rename {Src/IronPython => IronPython}/Runtime/BytesLikeAttribute.cs (100%) rename {Src/IronPython => IronPython}/Runtime/ClassMethodAttribute.cs (100%) rename {Src/IronPython => IronPython}/Runtime/ClassMethodDescriptor.cs (100%) rename {Src/IronPython => IronPython}/Runtime/ClrModule.cs (100%) rename {Src/IronPython => IronPython}/Runtime/CodeContext.cs (100%) rename {Src/IronPython => IronPython}/Runtime/CollectionDebugView.cs (100%) rename {Src/IronPython => IronPython}/Runtime/CommonDictionaryStorage.cs (100%) rename {Src/IronPython => IronPython}/Runtime/CompareUtil.cs (100%) rename {Src/IronPython => IronPython}/Runtime/CompileFlags.cs (100%) rename {Src/IronPython => IronPython}/Runtime/CompiledLoader.cs (100%) rename {Src/IronPython => IronPython}/Runtime/ConstantDictionaryStorage.cs (100%) rename {Src/IronPython => IronPython}/Runtime/ConversionWrappers.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Converter.cs (100%) rename {Src/IronPython => IronPython}/Runtime/CustomDictionaryStorage.cs (100%) rename {Src/IronPython => IronPython}/Runtime/DebuggerDictionaryStorage.cs (100%) rename {Src/IronPython => IronPython}/Runtime/DefaultContext.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Descriptors.cs (100%) rename {Src/IronPython => IronPython}/Runtime/DictionaryOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/DictionaryStorage.cs (100%) rename {Src/IronPython => IronPython}/Runtime/DictionaryTypeInfoAttribute.cs (100%) rename {Src/IronPython => IronPython}/Runtime/DontMapGetMemberNamesToDirAttribute.cs (100%) rename {Src/IronPython => IronPython}/Runtime/DontMapICollectionToLenAttribute.cs (100%) rename {Src/IronPython => IronPython}/Runtime/DontMapIDisposableToContextManagerAttribute.cs (100%) rename {Src/IronPython => IronPython}/Runtime/DontMapIEnumerableToContainsAttribute.cs (100%) rename {Src/IronPython => IronPython}/Runtime/DontMapIEnumerableToIterAttribute.cs (100%) rename {Src/IronPython => IronPython}/Runtime/EmptyDictionaryStorage.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Enumerate.cs (100%) rename {Src/IronPython => IronPython}/Runtime/ErrorCodes.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/AssertionException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/AttributeErrorException.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/BlockingIOException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/BrokenPipeException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/BufferException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/BytesWarningException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/ChildProcessException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/ConnectionAbortedException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/ConnectionException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/ConnectionRefusedException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/ConnectionResetException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/DeprecationWarningException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/FileExistsException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/FloatingPointException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/FutureWarningException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/GeneratorExitException.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/ImportException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/ImportWarningException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/IndentationException.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/InterruptedException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/IsADirectoryException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/LookupException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/ModuleNotFoundException.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/NotADirectoryException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/OSException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/ProcessLookupException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/PythonException.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/PythonExceptions.BaseException.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/PythonExceptions.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/PythonExceptions.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/RecursionException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/ReferenceException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/ResourceWarningException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/RuntimeException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/RuntimeWarningException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/StopAsyncIterationException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/StopIterationException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/SyntaxWarningException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/SystemExitException.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/TabException.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/TraceBack.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/TypeErrorException.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/UnicodeException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/UnicodeTranslateException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/UnicodeWarningException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/UserWarningException.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Exceptions/ValueErrorException.cs (100%) rename {Src/IronPython => IronPython}/Runtime/ExtensionMethodSet.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Filter.cs (100%) rename {Src/IronPython => IronPython}/Runtime/FormattingHelper.cs (100%) rename {Src/IronPython => IronPython}/Runtime/FunctionAttributes.cs (100%) rename {Src/IronPython => IronPython}/Runtime/FunctionCode.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Generator.cs (100%) rename {Src/IronPython => IronPython}/Runtime/GlobalDictionaryStorage.cs (100%) rename {Src/IronPython => IronPython}/Runtime/IParameterSequence.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Implementation.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Importer.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Index.cs (100%) rename {Src/IronPython => IronPython}/Runtime/InstancedModuleDictionaryStorage.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Interfaces.cs (100%) rename {Src/IronPython => IronPython}/Runtime/KwCallInfo.cs (100%) rename {Src/IronPython => IronPython}/Runtime/LiteralParser.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Map.cs (100%) rename {Src/IronPython => IronPython}/Runtime/MaybeNotImplementedAttribute.cs (100%) rename {Src/IronPython => IronPython}/Runtime/MemoryStreamContentProvider.cs (100%) rename {Src/IronPython => IronPython}/Runtime/MemoryView.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Method.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Method.cs (100%) rename {Src/IronPython => IronPython}/Runtime/MissingParameter.cs (100%) rename {Src/IronPython => IronPython}/Runtime/ModuleContext.cs (100%) rename {Src/IronPython => IronPython}/Runtime/ModuleDictionaryStorage.cs (100%) rename {Src/IronPython => IronPython}/Runtime/ModuleGlobalCache.cs (100%) rename {Src/IronPython => IronPython}/Runtime/ModuleLoader.cs (100%) rename {Src/IronPython => IronPython}/Runtime/ModuleOptions.cs (100%) rename {Src/IronPython => IronPython}/Runtime/NameType.cs (100%) rename {Src/IronPython => IronPython}/Runtime/NewStringFormatter.cs (100%) rename {Src/IronPython => IronPython}/Runtime/ObjectAttributesAdapter.cs (100%) rename {Src/IronPython => IronPython}/Runtime/ObjectDebugView.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/ArrayOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/BigIntegerOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/BoolOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/ByteOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/CharOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/ComOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/ComplexOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/CustomTypeDescHelpers.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/DBNullOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/DateTimeOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/DecimalOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/DelegateOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/DictionaryOfTOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/EnumOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/FloatOps.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/FloatOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/IListOfByteOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/InstanceOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/IntOps.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/IntOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/IntPtrOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/ListOfTOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/MarshalOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/NamespaceTrackerOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/ObjectOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/PythonCalls.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/PythonOps.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/PythonOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/PythonTypeOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/StringOps.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/StringOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/TypeGroupOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/TypeTrackerOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/UIntPtrOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Operations/UserTypeOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/OutputWriter.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PlatformsAttribute.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Profiler.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PythonContext.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PythonContext.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PythonDictionary.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PythonDocumentationProvider.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PythonDynamicStackFrame.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PythonEncoding.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PythonFileManager.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PythonFunction.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PythonFunction.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PythonHiddenAttribute.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PythonHiddenBaseClassAttribute.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PythonList.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PythonModule.cs (100%) mode change 100755 => 100644 rename {Src/IronPython => IronPython}/Runtime/PythonModuleAttribute.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PythonNarrowing.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PythonOptions.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PythonRange.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PythonScopeExtension.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PythonStrIterator.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PythonTracebackListener.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PythonTuple.cs (100%) rename {Src/IronPython => IronPython}/Runtime/PythonTypeAttribute.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Reversed.cs (100%) rename {Src/IronPython => IronPython}/Runtime/RuntimeVariablesDictionaryStorage.cs (100%) rename {Src/IronPython => IronPython}/Runtime/ScopeDictionaryStorage.cs (100%) rename {Src/IronPython => IronPython}/Runtime/SequenceTypeInfoAttribute.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Set.cs (100%) rename {Src/IronPython => IronPython}/Runtime/SetStorage.cs (100%) rename {Src/IronPython => IronPython}/Runtime/SimpleNamespace.cs (100%) rename {Src/IronPython => IronPython}/Runtime/SiteLocalStorage.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Slice.cs (100%) rename {Src/IronPython => IronPython}/Runtime/StringDictionaryStorage.cs (100%) rename {Src/IronPython => IronPython}/Runtime/StringFormatSpec.cs (100%) rename {Src/IronPython => IronPython}/Runtime/StringFormatter.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Super.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Symbols.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/ThrowingErrorSink.cs (100%) rename {Src/IronPython => IronPython}/Runtime/TypecodeOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/BuiltinFunction.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/BuiltinFunctionOverloadMapper.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/BuiltinMethodDescriptor.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/CachedNewTypeInfo.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/ConstructorFunction.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/CustomAttributeTracker.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/CustomInstanceDictionaryStorage.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/DocBuilder.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/DynamicBaseTypeAttribute.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/DynamicHelpers.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/EmptyType.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/ExtensionPropertyInfo.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/FunctionType.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/IPythonObject.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/InstanceCreator.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/MappingProxy.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/Mro.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/NameConverter.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/NewTypeInfo.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/NewTypeMaker.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/OperatorMapping.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/ParameterInfoWrapper.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/PythonAssemblyOps.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/PythonSiteCache.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/PythonType.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/PythonType.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/PythonTypeDataSlot.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/PythonTypeDictSlot.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/PythonTypeInfo.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/PythonTypeInfo.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/PythonTypeSlot.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/PythonTypeTypeSlot.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/PythonTypeUserDescriptorSlot.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/PythonTypeWeakRefSlot.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/ReflectedEvent.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/ReflectedExtensionProperty.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/ReflectedField.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/ReflectedGetterSetter.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/ReflectedIndexer.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/ReflectedProperty.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/ReflectedSlotProperty.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/ResolvedMember.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/SlotFieldAttribute.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/StaticUnderlyingSystemType.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Types/TypeCache.Generated.cs (100%) rename {Src/IronPython => IronPython}/Runtime/UnboundNameException.cs (100%) rename {Src/IronPython => IronPython}/Runtime/WeakRef.cs (100%) rename {Src/IronPython => IronPython}/Runtime/WrapperDescriptorAttribute.cs (100%) rename {Src/IronPython => IronPython}/Runtime/WrapperDictionary.cs (100%) rename {Src/IronPython => IronPython}/Runtime/Zip.cs (100%) rename {Src/IronPython => IronPython}/SerializationStubs.cs (100%) rename {Src/IronPython => IronPython}/StringExtensions.cs (100%) rename {Src/IronPython => IronPython}/SystemRuntimeVersioning.cs (100%) rename {Src/IronPython => IronPython}/policy.IronPython.config (100%) rename {Src/Modules => Modules}/IronPython.Modules.csproj (89%) rename {Src/Modules => Modules}/IterTools.cs (100%) rename {Src/Modules => Modules}/ModuleOps.cs (100%) rename {Src/Modules => Modules}/NtSignalState.cs (100%) rename {Src/Modules => Modules}/Properties/AssemblyInfo.cs (100%) rename {Src/Modules => Modules}/ResourceMetaPathImporter.cs (100%) rename {Src/Modules => Modules}/SimpleSignalState.cs (100%) rename {Src/Modules => Modules}/_bisect.cs (100%) rename {Src/Modules => Modules}/_codecs.cs (100%) rename {Src/Modules => Modules}/_codecs_cn.cs (100%) rename {Src/Modules => Modules}/_collections.cs (100%) rename {Src/Modules => Modules}/_csv.cs (100%) rename {Src/Modules => Modules}/_ctypes/Array.cs (100%) rename {Src/Modules => Modules}/_ctypes/ArrayType.cs (100%) rename {Src/Modules => Modules}/_ctypes/CData.cs (100%) rename {Src/Modules => Modules}/_ctypes/CFuncPtr.cs (100%) rename {Src/Modules => Modules}/_ctypes/CFuncPtrType.cs (100%) rename {Src/Modules => Modules}/_ctypes/Extensions.cs (100%) rename {Src/Modules => Modules}/_ctypes/Field.cs (100%) rename {Src/Modules => Modules}/_ctypes/INativeType.cs (100%) rename {Src/Modules => Modules}/_ctypes/LocalOrArg.cs (100%) rename {Src/Modules => Modules}/_ctypes/MarshalCleanup.cs (100%) rename {Src/Modules => Modules}/_ctypes/MemoryHolder.cs (100%) rename {Src/Modules => Modules}/_ctypes/NativeArgument.cs (100%) rename {Src/Modules => Modules}/_ctypes/NativeFunctions.cs (100%) rename {Src/Modules => Modules}/_ctypes/Pointer.cs (100%) rename {Src/Modules => Modules}/_ctypes/PointerType.cs (100%) rename {Src/Modules => Modules}/_ctypes/SimpleCData.cs (100%) rename {Src/Modules => Modules}/_ctypes/SimpleType.cs (100%) rename {Src/Modules => Modules}/_ctypes/SimpleTypeKind.cs (100%) rename {Src/Modules => Modules}/_ctypes/StructType.cs (100%) rename {Src/Modules => Modules}/_ctypes/Structure.cs (100%) rename {Src/Modules => Modules}/_ctypes/Union.cs (100%) rename {Src/Modules => Modules}/_ctypes/UnionType.cs (100%) rename {Src/Modules => Modules}/_ctypes/_ctypes.cs (100%) rename {Src/Modules => Modules}/_ctypes_test.cs (100%) rename {Src/Modules => Modules}/_datetime.cs (100%) rename {Src/Modules => Modules}/_functools.cs (100%) rename {Src/Modules => Modules}/_heapq.cs (100%) rename {Src/Modules => Modules}/_multibytecodec.cs (100%) rename {Src/Modules => Modules}/_multiprocessing.cs (100%) rename {Src/Modules => Modules}/_opcode.cs (100%) rename {Src/Modules => Modules}/_operator.cs (100%) rename {Src/Modules => Modules}/_overlapped.cs (100%) rename {Src/Modules => Modules}/_pickle.cs (100%) rename {Src/Modules => Modules}/_posixsubprocess.cs (100%) rename {Src/Modules => Modules}/_random.RandomGen.cs (100%) rename {Src/Modules => Modules}/_random.cs (100%) rename {Src/Modules => Modules}/_socket.cs (100%) rename {Src/Modules => Modules}/_sre.cs (100%) rename {Src/Modules => Modules}/_ssl.cs (100%) rename {Src/Modules => Modules}/_string.cs (100%) rename {Src/Modules => Modules}/_struct.cs (100%) rename {Src/Modules => Modules}/_sysconfigdata.cs (100%) rename {Src/Modules => Modules}/_thread.cs (100%) rename {Src/Modules => Modules}/_warnings.cs (100%) rename {Src/Modules => Modules}/_weakref.Generated.cs (100%) rename {Src/Modules => Modules}/_weakref.cs (100%) rename {Src/Modules => Modules}/_winapi.cs (100%) rename {Src/Modules => Modules}/array.cs (100%) rename {Src/Modules => Modules}/atexit.cs (100%) rename {Src/Modules => Modules}/audioop.cs (100%) rename {Src/Modules => Modules}/binascii.cs (100%) rename {Src/Modules => Modules}/bz2/BZ2Compressor.cs (100%) rename {Src/Modules => Modules}/bz2/BZ2Decompressor.cs (100%) rename {Src/Modules => Modules}/bz2/BZ2Module.cs (100%) rename {Src/Modules => Modules}/bz2/dotnetzip/BZip2/BZip2Compressor.cs (100%) rename {Src/Modules => Modules}/bz2/dotnetzip/BZip2/BZip2InputStream.cs (100%) rename {Src/Modules => Modules}/bz2/dotnetzip/BZip2/BZip2OutputStream.cs (100%) rename {Src/Modules => Modules}/bz2/dotnetzip/BZip2/BitWriter.cs (100%) rename {Src/Modules => Modules}/bz2/dotnetzip/BZip2/CRC32.cs (100%) rename {Src/Modules => Modules}/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs (100%) rename {Src/Modules => Modules}/bz2/dotnetzip/BZip2/Rand.cs (100%) rename {Src/Modules => Modules}/bz2/dotnetzip/source.txt (100%) rename {Src/Modules => Modules}/cmath.cs (100%) rename {Src/Modules => Modules}/errno.cs (100%) rename {Src/Modules => Modules}/faulthandler.cs (100%) rename {Src/Modules => Modules}/fcntl.cs (100%) rename {Src/Modules => Modules}/gc.cs (100%) rename {Src/Modules => Modules}/grp.cs (100%) rename {Src/Modules => Modules}/hashlib/MD5CryptoServiceProvider.cs (100%) rename {Src/Modules => Modules}/hashlib/SHA1CryptoServiceProvider.cs (100%) rename {Src/Modules => Modules}/hashlib/SHA224.cs (100%) rename {Src/Modules => Modules}/hashlib/SHA224Managed.cs (100%) rename {Src/Modules => Modules}/hashlib/SHA256Managed.cs (100%) rename {Src/Modules => Modules}/hashlib/SHA384Managed.cs (100%) rename {Src/Modules => Modules}/hashlib/SHA512Managed.cs (100%) rename {Src/Modules => Modules}/hashlib/SHAConstants.cs (100%) rename {Src/Modules => Modules}/hashlib/_hashlib.cs (100%) rename {Src/Modules => Modules}/hashlib/_md5.cs (100%) rename {Src/Modules => Modules}/hashlib/_sha1.cs (100%) rename {Src/Modules => Modules}/hashlib/_sha256.cs (100%) rename {Src/Modules => Modules}/hashlib/_sha512.cs (100%) rename {Src/Modules => Modules}/marshal.cs (100%) rename {Src/Modules => Modules}/math.Generated.cs (100%) rename {Src/Modules => Modules}/math.cs (100%) rename {Src/Modules => Modules}/mmap.cs (100%) rename {Src/Modules => Modules}/msvcrt.cs (100%) rename {Src/Modules => Modules}/nt.cs (100%) rename {Src/Modules => Modules}/policy.IronPython.Modules.config (100%) rename {Src/Modules => Modules}/pwd.cs (100%) rename {Src/Modules => Modules}/pyexpat.cs (100%) rename {Src/Modules => Modules}/re.cs (100%) rename {Src/Modules => Modules}/resource.cs (100%) rename {Src/Modules => Modules}/select.cs (100%) rename {Src/Modules => Modules}/signal.cs (100%) rename {Src/Modules => Modules}/spwd.cs (100%) rename {Src/Modules => Modules}/time.cs (100%) rename {Src/Modules => Modules}/winreg.cs (100%) rename {Src/Modules => Modules}/winsound.cs (100%) rename {Src/Modules => Modules}/xxsubtype.cs (100%) rename {Src/Modules => Modules}/zipimport.cs (100%) rename {Src/Modules => Modules}/zlib/Compress.cs (100%) rename {Src/Modules => Modules}/zlib/Decompress.cs (100%) rename {Src/Modules => Modules}/zlib/ZlibModule.cs (100%) rename {Src/Modules => Modules}/zlib/zlib.net/Adler32.cs (100%) rename {Src/Modules => Modules}/zlib/zlib.net/Deflate.cs (100%) rename {Src/Modules => Modules}/zlib/zlib.net/InfBlocks.cs (100%) rename {Src/Modules => Modules}/zlib/zlib.net/InfCodes.cs (100%) rename {Src/Modules => Modules}/zlib/zlib.net/InfTree.cs (100%) rename {Src/Modules => Modules}/zlib/zlib.net/Inflate.cs (100%) rename {Src/Modules => Modules}/zlib/zlib.net/StaticTree.cs (100%) rename {Src/Modules => Modules}/zlib/zlib.net/Tree.cs (100%) rename {Src/Modules => Modules}/zlib/zlib.net/ZStream.cs (100%) rename {Src/Modules => Modules}/zlib/zlib.net/ZStreamException.cs (100%) rename {Src/Modules => Modules}/zlib/zlib.net/Zlib.cs (100%) rename {Src/Modules => Modules}/zlib/zlib.net/history.txt (100%) rename {Src/Modules => Modules}/zlib/zlib.net/license.txt (100%) rename {Src/Modules => Modules}/zlib/zlib.net/readme.txt (100%) rename {Src/SQLite => SQLite}/Connection.cs (100%) rename {Src/SQLite => SQLite}/Contants.cs (100%) rename {Src/SQLite => SQLite}/Cursor.cs (100%) rename {Src/SQLite => SQLite}/Exceptions.cs (100%) rename {Src/SQLite => SQLite}/Extensions.cs (100%) rename {Src/SQLite => SQLite}/IronPython.SQLite.csproj (100%) rename {Src/SQLite => SQLite}/Properties/AssemblyInfo.cs (100%) rename {Src/SQLite => SQLite}/Row.cs (100%) rename {Src/SQLite => SQLite}/Statement.cs (100%) rename {Src/SQLite => SQLite}/Util.cs (100%) rename {Src/SQLite => SQLite}/_sqlite.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/.editorconfig (100%) rename {Src/SQLite => SQLite}/c#sqlite/BtreeInt_h.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/Btree_h.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/Delegates.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/Hash_h.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/VdbeInt_h.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/Vdbe_h.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/_Custom.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/alter_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/analyze_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/attach_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/auth_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/backup_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/bitvec_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/btmutex_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/btree_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/build_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/callback_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/complete_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/crypto.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/ctime_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/date_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/delete_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/expr_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/fault_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/fkey_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/func_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/global_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/hash_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/hwtime_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/insert_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/journal_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/keywordhash_h.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/legacy_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/loadext_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/main_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/malloc_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/mem_Pool.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/memjournal_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/mutex_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/mutex_h.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/mutex_noop_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/mutex_w32.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/notify_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/opcodes_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/opcodes_h.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/os_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/os_common_h.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/os_h.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/os_win_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/pager_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/pager_h.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/parse_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/parse_h.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/pcache1_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/pcache_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/pcache_h.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/pragma_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/prepare_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/printf_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/random_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/resolve_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/rowset_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/select_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/sqlite3_h.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/sqliteInt_h.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/sqliteLimit_h.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/status_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/table_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/tokenize_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/trigger_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/update_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/utf_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/util_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/vacuum_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/vdbe_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/vdbeapi_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/vdbeaux_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/vdbeblob_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/vdbemem_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/vdbetrace_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/vtab_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/wal_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/wal_h.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/walker_c.cs (100%) rename {Src/SQLite => SQLite}/c#sqlite/where_c.cs (100%) rename {Src/Scripts => Scripts}/CompareDirs.py (100%) rename {Src/Scripts => Scripts}/Enter-IronPythonEnvironment.ps1 (100%) rename {Src/Scripts => Scripts}/Install-IronPython.ps1 (100%) mode change 100755 => 100644 rename {Src/Scripts => Scripts}/clean.py (100%) rename {Src/Scripts => Scripts}/copyrights.py (100%) rename {Src/Scripts => Scripts}/generate.py (100%) mode change 100755 => 100644 rename {Src/Scripts => Scripts}/generate_UncollectableCompilationMode.py (100%) rename {Src/Scripts => Scripts}/generate_alltypes.py (100%) rename {Src/Scripts => Scripts}/generate_calls.py (100%) rename {Src/Scripts => Scripts}/generate_casts.py (100%) rename {Src/Scripts => Scripts}/generate_comdispatch.py (100%) rename {Src/Scripts => Scripts}/generate_dict_views.py (100%) rename {Src/Scripts => Scripts}/generate_dynamic_instructions.py (100%) rename {Src/Scripts => Scripts}/generate_dynsites.py (100%) rename {Src/Scripts => Scripts}/generate_encoding_aliases.py (100%) rename {Src/Scripts => Scripts}/generate_exception_factory.py (100%) rename {Src/Scripts => Scripts}/generate_exceptions.py (100%) rename {Src/Scripts => Scripts}/generate_indicestest.py (100%) rename {Src/Scripts => Scripts}/generate_math.py (100%) rename {Src/Scripts => Scripts}/generate_ops.py (100%) mode change 100755 => 100644 rename {Src/Scripts => Scripts}/generate_os_codes.py (100%) rename {Src/Scripts => Scripts}/generate_reflected_calls.py (100%) rename {Src/Scripts => Scripts}/generate_set.py (100%) rename {Src/Scripts => Scripts}/generate_tuples.py (100%) rename {Src/Scripts => Scripts}/generate_typecache.py (100%) rename {Src/Scripts => Scripts}/generate_walker.py (100%) rename {Src/Scripts => Scripts}/ipcom.ps1 (100%) rename {Src/Scripts => Scripts}/make_meta1.py (100%) rename {Src/Scripts => Scripts}/radix_generator.py (100%) rename {Src/Scripts => Scripts}/run_compiled.py (100%) rename {Src/Scripts => Scripts}/run_interactive.py (100%) rename {Src/Scripts => Scripts}/smtpmailer.py (100%) rename {Src/Scripts => Scripts}/test_builder.py (100%) rename {Src/Scripts => Scripts}/test_cgcheck.py (100%) rename {Src/Scripts => Scripts}/test_parrot.py (100%) rename {Src/Scripts => Scripts}/test_pystone.py (100%) rename {Src/StdLib => StdLib}/.gitattributes (100%) rename {Src/StdLib => StdLib}/Lib/__future__.py (100%) rename {Src/StdLib => StdLib}/Lib/__phello__.foo.py (100%) rename {Src/StdLib => StdLib}/Lib/_bootlocale.py (100%) rename {Src/StdLib => StdLib}/Lib/_collections_abc.py (100%) rename {Src/StdLib => StdLib}/Lib/_compat_pickle.py (100%) rename {Src/StdLib => StdLib}/Lib/_dummy_thread.py (100%) rename {Src/StdLib => StdLib}/Lib/_markupbase.py (100%) rename {Src/StdLib => StdLib}/Lib/_osx_support.py (100%) rename {Src/StdLib => StdLib}/Lib/_pyio.py (100%) rename {Src/StdLib => StdLib}/Lib/_sitebuiltins.py (100%) rename {Src/StdLib => StdLib}/Lib/_strptime.py (100%) rename {Src/StdLib => StdLib}/Lib/_threading_local.py (100%) rename {Src/StdLib => StdLib}/Lib/_weakrefset.py (100%) rename {Src/StdLib => StdLib}/Lib/abc.py (100%) rename {Src/StdLib => StdLib}/Lib/aifc.py (100%) rename {Src/StdLib => StdLib}/Lib/antigravity.py (100%) rename {Src/StdLib => StdLib}/Lib/argparse.py (100%) rename {Src/StdLib => StdLib}/Lib/ast.py (100%) rename {Src/StdLib => StdLib}/Lib/asynchat.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/base_events.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/base_subprocess.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/compat.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/constants.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/coroutines.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/events.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/futures.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/locks.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/log.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/proactor_events.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/protocols.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/queues.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/selector_events.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/sslproto.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/streams.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/subprocess.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/tasks.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/test_utils.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/transports.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/unix_events.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/windows_events.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncio/windows_utils.py (100%) rename {Src/StdLib => StdLib}/Lib/asyncore.py (100%) rename {Src/StdLib => StdLib}/Lib/base64.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/bdb.py (100%) rename {Src/StdLib => StdLib}/Lib/binhex.py (100%) rename {Src/StdLib => StdLib}/Lib/bisect.py (100%) rename {Src/StdLib => StdLib}/Lib/bz2.py (100%) rename {Src/StdLib => StdLib}/Lib/cProfile.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/calendar.py (100%) rename {Src/StdLib => StdLib}/Lib/cgi.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/cgitb.py (100%) rename {Src/StdLib => StdLib}/Lib/chunk.py (100%) rename {Src/StdLib => StdLib}/Lib/clrtype.py (100%) rename {Src/StdLib => StdLib}/Lib/cmd.py (100%) rename {Src/StdLib => StdLib}/Lib/code.py (100%) rename {Src/StdLib => StdLib}/Lib/codecs.py (100%) rename {Src/StdLib => StdLib}/Lib/codeop.py (100%) rename {Src/StdLib => StdLib}/Lib/collections/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/collections/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/collections/abc.py (100%) rename {Src/StdLib => StdLib}/Lib/colorsys.py (100%) rename {Src/StdLib => StdLib}/Lib/compileall.py (100%) rename {Src/StdLib => StdLib}/Lib/concurrent/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/concurrent/futures/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/concurrent/futures/_base.py (100%) rename {Src/StdLib => StdLib}/Lib/concurrent/futures/process.py (100%) rename {Src/StdLib => StdLib}/Lib/concurrent/futures/thread.py (100%) rename {Src/StdLib => StdLib}/Lib/configparser.py (100%) rename {Src/StdLib => StdLib}/Lib/contextlib.py (100%) rename {Src/StdLib => StdLib}/Lib/copy.py (100%) rename {Src/StdLib => StdLib}/Lib/copyreg.py (100%) rename {Src/StdLib => StdLib}/Lib/crypt.py (100%) rename {Src/StdLib => StdLib}/Lib/csv.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/_endian.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/macholib/README.ctypes (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/macholib/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/macholib/dyld.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/macholib/dylib.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/macholib/fetch_macholib (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/ctypes/macholib/fetch_macholib.bat (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/macholib/framework.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_anon.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_array_in_pointer.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_arrays.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_as_parameter.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_bitfields.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_buffers.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_bytes.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_byteswap.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_callbacks.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_cast.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_cfuncs.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_checkretval.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_delattr.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_errno.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_find.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_frombuffer.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_funcptr.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_functions.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_incomplete.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_init.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_internals.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_keeprefs.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_libc.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_loading.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_macholib.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_memfunctions.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_numbers.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_objects.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_parameters.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_pep3118.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_pickling.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_pointers.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_prototypes.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_python_api.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_random_things.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_refcounts.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_repr.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_returnfuncptrs.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_simplesubclasses.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_sizes.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_slicing.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_stringptr.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_strings.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_struct_fields.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_structures.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_unaligned_structures.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_unicode.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_values.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_varsize_struct.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_win32.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/test/test_wintypes.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/util.py (100%) rename {Src/StdLib => StdLib}/Lib/ctypes/wintypes.py (100%) rename {Src/StdLib => StdLib}/Lib/curses/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/curses/ascii.py (100%) rename {Src/StdLib => StdLib}/Lib/curses/has_key.py (100%) rename {Src/StdLib => StdLib}/Lib/curses/panel.py (100%) rename {Src/StdLib => StdLib}/Lib/curses/textpad.py (100%) rename {Src/StdLib => StdLib}/Lib/datetime.py (100%) rename {Src/StdLib => StdLib}/Lib/dbm/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/dbm/dumb.py (100%) rename {Src/StdLib => StdLib}/Lib/dbm/gnu.py (100%) rename {Src/StdLib => StdLib}/Lib/dbm/ndbm.py (100%) rename {Src/StdLib => StdLib}/Lib/decimal.py (100%) rename {Src/StdLib => StdLib}/Lib/difflib.py (100%) rename {Src/StdLib => StdLib}/Lib/dis.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/README (100%) rename {Src/StdLib => StdLib}/Lib/distutils/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/archive_util.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/bcppcompiler.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/ccompiler.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/cmd.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/bdist.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/bdist_dumb.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/bdist_msi.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/bdist_rpm.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/bdist_wininst.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/build.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/build_clib.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/build_ext.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/build_py.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/build_scripts.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/check.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/clean.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/command_template (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/config.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/install.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/install_data.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/install_egg_info.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/install_headers.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/install_lib.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/install_scripts.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/register.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/sdist.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/upload.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/wininst-10.0-amd64.exe (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/wininst-10.0.exe (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/wininst-6.0.exe (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/wininst-7.1.exe (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/wininst-8.0.exe (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/wininst-9.0-amd64.exe (100%) rename {Src/StdLib => StdLib}/Lib/distutils/command/wininst-9.0.exe (100%) rename {Src/StdLib => StdLib}/Lib/distutils/config.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/core.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/cygwinccompiler.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/debug.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/dep_util.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/dir_util.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/dist.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/errors.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/extension.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/fancy_getopt.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/file_util.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/filelist.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/log.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/msvc9compiler.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/msvccompiler.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/spawn.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/sysconfig.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/Setup.sample (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/support.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_archive_util.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_bdist.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_bdist_dumb.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_bdist_msi.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_bdist_rpm.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_bdist_wininst.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_build.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_build_clib.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_build_ext.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_build_py.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_build_scripts.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_check.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_clean.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_cmd.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_config.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_config_cmd.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_core.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_cygwinccompiler.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_dep_util.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_dir_util.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_dist.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_extension.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_file_util.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_filelist.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_install.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_install_data.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_install_headers.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_install_lib.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_install_scripts.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_log.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_msvc9compiler.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_register.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_sdist.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_spawn.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_sysconfig.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_text_file.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_unixccompiler.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_upload.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_util.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_version.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/tests/test_versionpredicate.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/text_file.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/unixccompiler.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/util.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/version.py (100%) rename {Src/StdLib => StdLib}/Lib/distutils/versionpredicate.py (100%) rename {Src/StdLib => StdLib}/Lib/doctest.py (100%) rename {Src/StdLib => StdLib}/Lib/dummy_threading.py (100%) rename {Src/StdLib => StdLib}/Lib/email/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/email/_encoded_words.py (100%) rename {Src/StdLib => StdLib}/Lib/email/_header_value_parser.py (100%) rename {Src/StdLib => StdLib}/Lib/email/_parseaddr.py (100%) rename {Src/StdLib => StdLib}/Lib/email/_policybase.py (100%) rename {Src/StdLib => StdLib}/Lib/email/architecture.rst (100%) rename {Src/StdLib => StdLib}/Lib/email/base64mime.py (100%) rename {Src/StdLib => StdLib}/Lib/email/charset.py (100%) rename {Src/StdLib => StdLib}/Lib/email/contentmanager.py (100%) rename {Src/StdLib => StdLib}/Lib/email/encoders.py (100%) rename {Src/StdLib => StdLib}/Lib/email/errors.py (100%) rename {Src/StdLib => StdLib}/Lib/email/feedparser.py (100%) rename {Src/StdLib => StdLib}/Lib/email/generator.py (100%) rename {Src/StdLib => StdLib}/Lib/email/header.py (100%) rename {Src/StdLib => StdLib}/Lib/email/headerregistry.py (100%) rename {Src/StdLib => StdLib}/Lib/email/iterators.py (100%) rename {Src/StdLib => StdLib}/Lib/email/message.py (100%) rename {Src/StdLib => StdLib}/Lib/email/mime/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/email/mime/application.py (100%) rename {Src/StdLib => StdLib}/Lib/email/mime/audio.py (100%) rename {Src/StdLib => StdLib}/Lib/email/mime/base.py (100%) rename {Src/StdLib => StdLib}/Lib/email/mime/image.py (100%) rename {Src/StdLib => StdLib}/Lib/email/mime/message.py (100%) rename {Src/StdLib => StdLib}/Lib/email/mime/multipart.py (100%) rename {Src/StdLib => StdLib}/Lib/email/mime/nonmultipart.py (100%) rename {Src/StdLib => StdLib}/Lib/email/mime/text.py (100%) rename {Src/StdLib => StdLib}/Lib/email/parser.py (100%) rename {Src/StdLib => StdLib}/Lib/email/policy.py (100%) rename {Src/StdLib => StdLib}/Lib/email/quoprimime.py (100%) rename {Src/StdLib => StdLib}/Lib/email/utils.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/aliases.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/ascii.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/base64_codec.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/big5.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/big5hkscs.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/bz2_codec.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/charmap.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp037.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp1006.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp1026.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp1125.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp1140.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp1250.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp1251.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp1252.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp1253.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp1254.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp1255.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp1256.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp1257.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp1258.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp273.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp424.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp437.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp500.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp65001.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp720.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp737.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp775.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp850.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp852.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp855.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp856.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp857.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp858.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp860.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp861.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp862.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp863.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp864.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp865.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp866.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp869.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp874.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp875.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp932.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp949.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/cp950.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/euc_jis_2004.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/euc_jisx0213.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/euc_jp.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/euc_kr.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/gb18030.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/gb2312.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/gbk.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/hex_codec.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/hp_roman8.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/hz.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/idna.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso2022_jp.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso2022_jp_1.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso2022_jp_2.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso2022_jp_2004.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso2022_jp_3.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso2022_jp_ext.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso2022_kr.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso8859_1.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso8859_10.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso8859_11.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso8859_13.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso8859_14.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso8859_15.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso8859_16.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso8859_2.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso8859_3.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso8859_4.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso8859_5.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso8859_6.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso8859_7.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso8859_8.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/iso8859_9.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/johab.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/koi8_r.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/koi8_u.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/latin_1.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/mac_arabic.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/mac_centeuro.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/mac_croatian.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/mac_cyrillic.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/mac_farsi.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/mac_greek.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/mac_iceland.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/mac_latin2.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/mac_roman.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/mac_romanian.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/mac_turkish.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/mbcs.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/palmos.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/ptcp154.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/punycode.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/quopri_codec.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/raw_unicode_escape.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/rot_13.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/encodings/shift_jis.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/shift_jis_2004.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/shift_jisx0213.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/tis_620.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/undefined.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/unicode_escape.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/unicode_internal.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/utf_16.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/utf_16_be.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/utf_16_le.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/utf_32.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/utf_32_be.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/utf_32_le.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/utf_7.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/utf_8.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/utf_8_sig.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/uu_codec.py (100%) rename {Src/StdLib => StdLib}/Lib/encodings/zlib_codec.py (100%) rename {Src/StdLib => StdLib}/Lib/ensurepip/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/ensurepip/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl (100%) rename {Src/StdLib => StdLib}/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl (100%) rename {Src/StdLib => StdLib}/Lib/ensurepip/_uninstall.py (100%) rename {Src/StdLib => StdLib}/Lib/enum.py (100%) rename {Src/StdLib => StdLib}/Lib/filecmp.py (100%) rename {Src/StdLib => StdLib}/Lib/fileinput.py (100%) rename {Src/StdLib => StdLib}/Lib/fnmatch.py (100%) rename {Src/StdLib => StdLib}/Lib/formatter.py (100%) rename {Src/StdLib => StdLib}/Lib/fractions.py (100%) rename {Src/StdLib => StdLib}/Lib/ftplib.py (100%) rename {Src/StdLib => StdLib}/Lib/functools.py (100%) rename {Src/StdLib => StdLib}/Lib/genericpath.py (100%) rename {Src/StdLib => StdLib}/Lib/getopt.py (100%) rename {Src/StdLib => StdLib}/Lib/getpass.py (100%) rename {Src/StdLib => StdLib}/Lib/gettext.py (100%) rename {Src/StdLib => StdLib}/Lib/glob.py (100%) rename {Src/StdLib => StdLib}/Lib/gzip.py (100%) rename {Src/StdLib => StdLib}/Lib/hashlib.py (100%) rename {Src/StdLib => StdLib}/Lib/heapq.py (100%) rename {Src/StdLib => StdLib}/Lib/hmac.py (100%) rename {Src/StdLib => StdLib}/Lib/html/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/html/entities.py (100%) rename {Src/StdLib => StdLib}/Lib/html/parser.py (100%) rename {Src/StdLib => StdLib}/Lib/http/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/http/client.py (100%) rename {Src/StdLib => StdLib}/Lib/http/cookiejar.py (100%) rename {Src/StdLib => StdLib}/Lib/http/cookies.py (100%) rename {Src/StdLib => StdLib}/Lib/http/server.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/AutoComplete.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/AutoCompleteWindow.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/AutoExpand.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/Bindings.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/CREDITS.txt (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/CallTipWindow.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/CallTips.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/ChangeLog (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/ClassBrowser.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/CodeContext.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/ColorDelegator.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/Debugger.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/Delegator.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/EditorWindow.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/FileList.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/FormatParagraph.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/GrepDialog.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/HISTORY.txt (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/HyperParser.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/IOBinding.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/Icons/folder.gif (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/Icons/idle.icns (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/Icons/idle.ico (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/Icons/idle_16.gif (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/Icons/idle_16.png (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/Icons/idle_32.gif (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/Icons/idle_32.png (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/Icons/idle_48.gif (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/Icons/idle_48.png (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/Icons/minusnode.gif (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/Icons/openfolder.gif (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/Icons/plusnode.gif (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/Icons/python.gif (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/Icons/tk.gif (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/IdleHistory.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/MultiCall.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/MultiStatusBar.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/NEWS.txt (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/ObjectBrowser.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/OutputWindow.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/ParenMatch.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/PathBrowser.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/Percolator.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/PyParse.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/PyShell.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/idlelib/README.txt (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/RemoteDebugger.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/RemoteObjectBrowser.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/ReplaceDialog.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/RstripExtension.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/ScriptBinding.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/ScrolledList.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/SearchDialog.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/SearchDialogBase.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/SearchEngine.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/StackViewer.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/TODO.txt (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/ToolTip.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/TreeWidget.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/UndoDelegator.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/WidgetRedirector.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/WindowList.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/ZoomHeight.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/aboutDialog.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/config-extensions.def (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/config-highlight.def (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/config-keys.def (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/config-main.def (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/configDialog.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/configHandler.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/configHelpSourceEdit.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/configSectionNameDialog.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/dynOptionMenuWidget.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/extend.txt (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/help.html (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/help.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/help.txt (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle.bat (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/idlelib/idle.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle.pyw (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/README.txt (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/htest.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/mock_idle.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/mock_tk.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/test_autocomplete.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/test_autoexpand.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/test_calltips.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/test_config_name.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/test_configdialog.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/test_delegator.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/test_editor.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/test_formatparagraph.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/test_grep.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/test_hyperparser.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/test_idlehistory.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/test_io.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/test_parenmatch.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/test_pathbrowser.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/test_rstrip.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/test_searchdialogbase.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/test_searchengine.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/test_text.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/test_textview.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/test_warning.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idle_test/test_widgetredir.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/idlever.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/keybindingDialog.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/macosxSupport.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/rpc.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/run.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/tabbedpages.py (100%) rename {Src/StdLib => StdLib}/Lib/idlelib/textView.py (100%) rename {Src/StdLib => StdLib}/Lib/imaplib.py (100%) rename {Src/StdLib => StdLib}/Lib/imghdr.py (100%) rename {Src/StdLib => StdLib}/Lib/imp.py (100%) rename {Src/StdLib => StdLib}/Lib/importlib/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/importlib/_bootstrap.py (100%) rename {Src/StdLib => StdLib}/Lib/importlib/abc.py (100%) rename {Src/StdLib => StdLib}/Lib/importlib/machinery.py (100%) rename {Src/StdLib => StdLib}/Lib/importlib/util.py (100%) rename {Src/StdLib => StdLib}/Lib/inspect.py (100%) rename {Src/StdLib => StdLib}/Lib/io.py (100%) rename {Src/StdLib => StdLib}/Lib/ipaddress.py (100%) rename {Src/StdLib => StdLib}/Lib/json/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/json/decoder.py (100%) rename {Src/StdLib => StdLib}/Lib/json/encoder.py (100%) rename {Src/StdLib => StdLib}/Lib/json/scanner.py (100%) rename {Src/StdLib => StdLib}/Lib/json/tool.py (100%) rename {Src/StdLib => StdLib}/Lib/keyword.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/lib2to3/Grammar.txt (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/PatternGrammar.txt (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/btm_matcher.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/btm_utils.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixer_base.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixer_util.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_apply.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_asserts.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_basestring.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_buffer.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_callable.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_dict.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_except.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_exec.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_execfile.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_exitfunc.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_filter.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_funcattrs.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_future.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_getcwdu.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_has_key.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_idioms.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_import.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_imports.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_imports2.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_input.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_intern.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_isinstance.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_itertools.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_itertools_imports.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_long.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_map.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_metaclass.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_methodattrs.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_ne.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_next.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_nonzero.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_numliterals.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_operator.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_paren.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_print.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_raise.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_raw_input.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_reduce.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_reload.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_renames.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_repr.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_set_literal.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_standarderror.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_sys_exc.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_throw.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_tuple_params.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_types.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_unicode.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_urllib.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_ws_comma.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_xrange.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_xreadlines.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/fixes/fix_zip.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/main.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/patcomp.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/pgen2/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/pgen2/conv.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/pgen2/driver.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/pgen2/grammar.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/pgen2/literals.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/pgen2/parse.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/pgen2/pgen.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/pgen2/token.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/lib2to3/pgen2/tokenize.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/pygram.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/pytree.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/refactor.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/data/README (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/data/bom.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/data/crlf.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/data/different_encoding.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/data/false_encoding.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/data/fixers/bad_order.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/data/fixers/parrot_example.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/data/infinite_recursion.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/data/py2_test_grammar.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/data/py3_test_grammar.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/pytree_idempotency.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/support.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/test_all_fixers.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/test_fixers.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/test_main.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/test_parser.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/test_pytree.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/test_refactor.py (100%) rename {Src/StdLib => StdLib}/Lib/lib2to3/tests/test_util.py (100%) rename {Src/StdLib => StdLib}/Lib/linecache.py (100%) rename {Src/StdLib => StdLib}/Lib/locale.py (100%) rename {Src/StdLib => StdLib}/Lib/logging/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/logging/config.py (100%) rename {Src/StdLib => StdLib}/Lib/logging/handlers.py (100%) rename {Src/StdLib => StdLib}/Lib/lzma.py (100%) rename {Src/StdLib => StdLib}/Lib/macpath.py (100%) rename {Src/StdLib => StdLib}/Lib/macurl2path.py (100%) rename {Src/StdLib => StdLib}/Lib/mailbox.py (100%) rename {Src/StdLib => StdLib}/Lib/mailcap.py (100%) rename {Src/StdLib => StdLib}/Lib/mimetypes.py (100%) rename {Src/StdLib => StdLib}/Lib/modulefinder.py (100%) rename {Src/StdLib => StdLib}/Lib/msilib/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/msilib/schema.py (100%) rename {Src/StdLib => StdLib}/Lib/msilib/sequence.py (100%) rename {Src/StdLib => StdLib}/Lib/msilib/text.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/connection.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/context.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/dummy/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/dummy/connection.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/forkserver.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/heap.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/managers.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/pool.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/popen_fork.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/popen_forkserver.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/popen_spawn_posix.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/popen_spawn_win32.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/process.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/queues.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/reduction.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/resource_sharer.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/semaphore_tracker.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/sharedctypes.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/spawn.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/synchronize.py (100%) rename {Src/StdLib => StdLib}/Lib/multiprocessing/util.py (100%) rename {Src/StdLib => StdLib}/Lib/netrc.py (100%) rename {Src/StdLib => StdLib}/Lib/nntplib.py (100%) rename {Src/StdLib => StdLib}/Lib/ntpath.py (100%) rename {Src/StdLib => StdLib}/Lib/nturl2path.py (100%) rename {Src/StdLib => StdLib}/Lib/numbers.py (100%) rename {Src/StdLib => StdLib}/Lib/opcode.py (100%) rename {Src/StdLib => StdLib}/Lib/operator.py (100%) rename {Src/StdLib => StdLib}/Lib/optparse.py (100%) rename {Src/StdLib => StdLib}/Lib/os.py (100%) rename {Src/StdLib => StdLib}/Lib/pathlib.py (100%) rename {Src/StdLib => StdLib}/Lib/pdb.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/pickle.py (100%) rename {Src/StdLib => StdLib}/Lib/pickletools.py (100%) rename {Src/StdLib => StdLib}/Lib/pipes.py (100%) rename {Src/StdLib => StdLib}/Lib/pkgutil.py (100%) rename {Src/StdLib => StdLib}/Lib/platform.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/plistlib.py (100%) rename {Src/StdLib => StdLib}/Lib/poplib.py (100%) rename {Src/StdLib => StdLib}/Lib/posixpath.py (100%) rename {Src/StdLib => StdLib}/Lib/pprint.py (100%) rename {Src/StdLib => StdLib}/Lib/profile.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/pstats.py (100%) rename {Src/StdLib => StdLib}/Lib/pty.py (100%) rename {Src/StdLib => StdLib}/Lib/py_compile.py (100%) rename {Src/StdLib => StdLib}/Lib/pyclbr.py (100%) rename {Src/StdLib => StdLib}/Lib/pydoc.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/pydoc_data/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/pydoc_data/_pydoc.css (100%) rename {Src/StdLib => StdLib}/Lib/pydoc_data/topics.py (100%) rename {Src/StdLib => StdLib}/Lib/queue.py (100%) rename {Src/StdLib => StdLib}/Lib/quopri.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/random.py (100%) rename {Src/StdLib => StdLib}/Lib/re.py (100%) rename {Src/StdLib => StdLib}/Lib/reprlib.py (100%) rename {Src/StdLib => StdLib}/Lib/rlcompleter.py (100%) rename {Src/StdLib => StdLib}/Lib/runpy.py (100%) rename {Src/StdLib => StdLib}/Lib/sched.py (100%) rename {Src/StdLib => StdLib}/Lib/selectors.py (100%) rename {Src/StdLib => StdLib}/Lib/shelve.py (100%) rename {Src/StdLib => StdLib}/Lib/shlex.py (100%) rename {Src/StdLib => StdLib}/Lib/shutil.py (100%) rename {Src/StdLib => StdLib}/Lib/site-packages/README (100%) rename {Src/StdLib => StdLib}/Lib/site.py (100%) rename {Src/StdLib => StdLib}/Lib/smtpd.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/smtplib.py (100%) rename {Src/StdLib => StdLib}/Lib/sndhdr.py (100%) rename {Src/StdLib => StdLib}/Lib/socket.py (100%) rename {Src/StdLib => StdLib}/Lib/socketserver.py (100%) rename {Src/StdLib => StdLib}/Lib/sqlite3/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/sqlite3/dbapi2.py (100%) rename {Src/StdLib => StdLib}/Lib/sqlite3/dump.py (100%) rename {Src/StdLib => StdLib}/Lib/sqlite3/test/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/sqlite3/test/dbapi.py (100%) rename {Src/StdLib => StdLib}/Lib/sqlite3/test/dump.py (100%) rename {Src/StdLib => StdLib}/Lib/sqlite3/test/factory.py (100%) rename {Src/StdLib => StdLib}/Lib/sqlite3/test/hooks.py (100%) rename {Src/StdLib => StdLib}/Lib/sqlite3/test/regression.py (100%) rename {Src/StdLib => StdLib}/Lib/sqlite3/test/transactions.py (100%) rename {Src/StdLib => StdLib}/Lib/sqlite3/test/types.py (100%) rename {Src/StdLib => StdLib}/Lib/sqlite3/test/userfunctions.py (100%) rename {Src/StdLib => StdLib}/Lib/sre_compile.py (100%) rename {Src/StdLib => StdLib}/Lib/sre_constants.py (100%) rename {Src/StdLib => StdLib}/Lib/sre_parse.py (100%) rename {Src/StdLib => StdLib}/Lib/ssl.py (100%) rename {Src/StdLib => StdLib}/Lib/stat.py (100%) rename {Src/StdLib => StdLib}/Lib/statistics.py (100%) rename {Src/StdLib => StdLib}/Lib/string.py (100%) rename {Src/StdLib => StdLib}/Lib/stringprep.py (100%) rename {Src/StdLib => StdLib}/Lib/struct.py (100%) rename {Src/StdLib => StdLib}/Lib/subprocess.py (100%) rename {Src/StdLib => StdLib}/Lib/sunau.py (100%) rename {Src/StdLib => StdLib}/Lib/symbol.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/symtable.py (100%) rename {Src/StdLib => StdLib}/Lib/sysconfig.py (100%) rename {Src/StdLib => StdLib}/Lib/tabnanny.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/tarfile.py (100%) rename {Src/StdLib => StdLib}/Lib/telnetlib.py (100%) rename {Src/StdLib => StdLib}/Lib/tempfile.py (100%) rename {Src/StdLib => StdLib}/Lib/test/185test.db (100%) rename {Src/StdLib => StdLib}/Lib/test/Sine-1000Hz-300ms.aif (100%) rename {Src/StdLib => StdLib}/Lib/test/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/_test_multiprocessing.py (100%) rename {Src/StdLib => StdLib}/Lib/test/audiodata/pluck-alaw.aifc (100%) rename {Src/StdLib => StdLib}/Lib/test/audiodata/pluck-pcm16.aiff (100%) rename {Src/StdLib => StdLib}/Lib/test/audiodata/pluck-pcm16.au (100%) rename {Src/StdLib => StdLib}/Lib/test/audiodata/pluck-pcm16.wav (100%) rename {Src/StdLib => StdLib}/Lib/test/audiodata/pluck-pcm24.aiff (100%) rename {Src/StdLib => StdLib}/Lib/test/audiodata/pluck-pcm24.au (100%) rename {Src/StdLib => StdLib}/Lib/test/audiodata/pluck-pcm24.wav (100%) rename {Src/StdLib => StdLib}/Lib/test/audiodata/pluck-pcm32.aiff (100%) rename {Src/StdLib => StdLib}/Lib/test/audiodata/pluck-pcm32.au (100%) rename {Src/StdLib => StdLib}/Lib/test/audiodata/pluck-pcm32.wav (100%) rename {Src/StdLib => StdLib}/Lib/test/audiodata/pluck-pcm8.aiff (100%) rename {Src/StdLib => StdLib}/Lib/test/audiodata/pluck-pcm8.au (100%) rename {Src/StdLib => StdLib}/Lib/test/audiodata/pluck-pcm8.wav (100%) rename {Src/StdLib => StdLib}/Lib/test/audiodata/pluck-ulaw.aifc (100%) rename {Src/StdLib => StdLib}/Lib/test/audiodata/pluck-ulaw.au (100%) rename {Src/StdLib => StdLib}/Lib/test/audiotest.au (100%) rename {Src/StdLib => StdLib}/Lib/test/audiotests.py (100%) rename {Src/StdLib => StdLib}/Lib/test/autotest.py (100%) rename {Src/StdLib => StdLib}/Lib/test/bad_coding.py (100%) rename {Src/StdLib => StdLib}/Lib/test/bad_coding2.py (100%) rename {Src/StdLib => StdLib}/Lib/test/badcert.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/badkey.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/badsyntax_3131.py (100%) rename {Src/StdLib => StdLib}/Lib/test/badsyntax_future10.py (100%) rename {Src/StdLib => StdLib}/Lib/test/badsyntax_future3.py (100%) rename {Src/StdLib => StdLib}/Lib/test/badsyntax_future4.py (100%) rename {Src/StdLib => StdLib}/Lib/test/badsyntax_future5.py (100%) rename {Src/StdLib => StdLib}/Lib/test/badsyntax_future6.py (100%) rename {Src/StdLib => StdLib}/Lib/test/badsyntax_future7.py (100%) rename {Src/StdLib => StdLib}/Lib/test/badsyntax_future8.py (100%) rename {Src/StdLib => StdLib}/Lib/test/badsyntax_future9.py (100%) rename {Src/StdLib => StdLib}/Lib/test/badsyntax_pep3120.py (100%) rename {Src/StdLib => StdLib}/Lib/test/buffer_tests.py (100%) rename {Src/StdLib => StdLib}/Lib/test/bytecode_helper.py (100%) rename {Src/StdLib => StdLib}/Lib/test/capath/0e4015b9.0 (100%) rename {Src/StdLib => StdLib}/Lib/test/capath/4e1295a3.0 (100%) rename {Src/StdLib => StdLib}/Lib/test/capath/5ed36f99.0 (100%) rename {Src/StdLib => StdLib}/Lib/test/capath/6e88d7b8.0 (100%) rename {Src/StdLib => StdLib}/Lib/test/capath/99d0fa06.0 (100%) rename {Src/StdLib => StdLib}/Lib/test/capath/ce7b8643.0 (100%) rename {Src/StdLib => StdLib}/Lib/test/cfgparser.1 (100%) rename {Src/StdLib => StdLib}/Lib/test/cfgparser.2 (100%) rename {Src/StdLib => StdLib}/Lib/test/cfgparser.3 (100%) rename {Src/StdLib => StdLib}/Lib/test/check_soundcard.vbs (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/big5-utf8.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/big5.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/big5hkscs-utf8.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/big5hkscs.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/cp949-utf8.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/cp949.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/euc_jisx0213-utf8.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/euc_jisx0213.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/euc_jp-utf8.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/euc_jp.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/euc_kr-utf8.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/euc_kr.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/gb18030-utf8.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/gb18030.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/gb2312-utf8.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/gb2312.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/gbk-utf8.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/gbk.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/hz-utf8.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/hz.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/iso2022_jp-utf8.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/iso2022_jp.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/iso2022_kr-utf8.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/iso2022_kr.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/johab-utf8.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/johab.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/shift_jis-utf8.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/shift_jis.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/shift_jisx0213-utf8.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cjkencodings/shift_jisx0213.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/cmath_testcases.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/coding20731.py (100%) rename {Src/StdLib => StdLib}/Lib/test/crashers/README (100%) rename {Src/StdLib => StdLib}/Lib/test/crashers/bogus_code_obj.py (100%) rename {Src/StdLib => StdLib}/Lib/test/crashers/gc_inspection.py (100%) rename {Src/StdLib => StdLib}/Lib/test/crashers/infinite_loop_re.py (100%) rename {Src/StdLib => StdLib}/Lib/test/crashers/mutation_inside_cyclegc.py (100%) rename {Src/StdLib => StdLib}/Lib/test/crashers/recursive_call.py (100%) rename {Src/StdLib => StdLib}/Lib/test/crashers/trace_at_recursion_limit.py (100%) rename {Src/StdLib => StdLib}/Lib/test/crashers/underlying_dict.py (100%) rename {Src/StdLib => StdLib}/Lib/test/curses_tests.py (100%) rename {Src/StdLib => StdLib}/Lib/test/data/README (100%) rename {Src/StdLib => StdLib}/Lib/test/datetimetester.py (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/abs.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/add.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/and.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/base.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/clamp.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/class.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/compare.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/comparetotal.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/comparetotmag.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/copy.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/copyabs.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/copynegate.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/copysign.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddAbs.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddAdd.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddAnd.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddBase.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddCanonical.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddClass.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddCompare.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddCompareSig.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddCompareTotal.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddCompareTotalMag.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddCopy.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddCopyAbs.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddCopyNegate.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddCopySign.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddDivide.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddDivideInt.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddEncode.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddFMA.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddInvert.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddLogB.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddMax.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddMaxMag.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddMin.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddMinMag.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddMinus.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddMultiply.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddNextMinus.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddNextPlus.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddNextToward.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddOr.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddPlus.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddQuantize.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddReduce.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddRemainder.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddRemainderNear.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddRotate.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddSameQuantum.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddScaleB.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddShift.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddSubtract.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddToIntegral.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ddXor.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/decDouble.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/decQuad.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/decSingle.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/divide.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/divideint.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqAbs.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqAdd.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqAnd.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqBase.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqCanonical.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqClass.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqCompare.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqCompareSig.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqCompareTotal.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqCompareTotalMag.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqCopy.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqCopyAbs.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqCopyNegate.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqCopySign.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqDivide.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqDivideInt.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqEncode.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqFMA.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqInvert.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqLogB.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqMax.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqMaxMag.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqMin.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqMinMag.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqMinus.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqMultiply.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqNextMinus.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqNextPlus.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqNextToward.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqOr.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqPlus.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqQuantize.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqReduce.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqRemainder.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqRemainderNear.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqRotate.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqSameQuantum.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqScaleB.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqShift.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqSubtract.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqToIntegral.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dqXor.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dsBase.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/dsEncode.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/exp.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/extra.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/fma.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/inexact.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/invert.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/ln.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/log10.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/logb.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/max.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/maxmag.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/min.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/minmag.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/minus.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/multiply.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/nextminus.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/nextplus.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/nexttoward.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/or.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/plus.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/power.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/powersqrt.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/quantize.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/randomBound32.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/randoms.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/reduce.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/remainder.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/remainderNear.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/rescale.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/rotate.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/rounding.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/samequantum.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/scaleb.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/shift.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/squareroot.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/subtract.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/testall.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/tointegral.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/tointegralx.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/decimaltestdata/xor.decTest (100%) rename {Src/StdLib => StdLib}/Lib/test/dh1024.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/dis_module.py (100%) rename {Src/StdLib => StdLib}/Lib/test/doctest_aliases.py (100%) rename {Src/StdLib => StdLib}/Lib/test/double_const.py (100%) rename {Src/StdLib => StdLib}/Lib/test/empty.vbs (100%) rename {Src/StdLib => StdLib}/Lib/test/encoded_modules/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/encoded_modules/module_iso_8859_1.py (100%) rename {Src/StdLib => StdLib}/Lib/test/encoded_modules/module_koi8_r.py (100%) rename {Src/StdLib => StdLib}/Lib/test/exception_hierarchy.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/final_a.py (100%) rename {Src/StdLib => StdLib}/Lib/test/final_b.py (100%) rename {Src/StdLib => StdLib}/Lib/test/floating_points.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/fork_wait.py (100%) rename {Src/StdLib => StdLib}/Lib/test/formatfloat_testcases.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/future_test1.py (100%) rename {Src/StdLib => StdLib}/Lib/test/future_test2.py (100%) rename {Src/StdLib => StdLib}/Lib/test/gdb_sample.py (100%) rename {Src/StdLib => StdLib}/Lib/test/ieee754.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/imghdrdata/python.bmp (100%) rename {Src/StdLib => StdLib}/Lib/test/imghdrdata/python.gif (100%) rename {Src/StdLib => StdLib}/Lib/test/imghdrdata/python.jpg (100%) rename {Src/StdLib => StdLib}/Lib/test/imghdrdata/python.pbm (100%) rename {Src/StdLib => StdLib}/Lib/test/imghdrdata/python.pgm (100%) rename {Src/StdLib => StdLib}/Lib/test/imghdrdata/python.png (100%) rename {Src/StdLib => StdLib}/Lib/test/imghdrdata/python.ppm (100%) rename {Src/StdLib => StdLib}/Lib/test/imghdrdata/python.ras (100%) rename {Src/StdLib => StdLib}/Lib/test/imghdrdata/python.sgi (100%) rename {Src/StdLib => StdLib}/Lib/test/imghdrdata/python.tiff (100%) rename {Src/StdLib => StdLib}/Lib/test/imghdrdata/python.xbm (100%) rename {Src/StdLib => StdLib}/Lib/test/inspect_fodder.py (100%) rename {Src/StdLib => StdLib}/Lib/test/inspect_fodder2.py (100%) rename {Src/StdLib => StdLib}/Lib/test/keycert.passwd.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/keycert.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/keycert2.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/keycert3.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/keycert4.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/leakers/README.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/leakers/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/leakers/test_ctypes.py (100%) rename {Src/StdLib => StdLib}/Lib/test/leakers/test_selftype.py (100%) rename {Src/StdLib => StdLib}/Lib/test/list_tests.py (100%) rename {Src/StdLib => StdLib}/Lib/test/lock_tests.py (100%) rename {Src/StdLib => StdLib}/Lib/test/mailcap.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/make_ssl_certs.py (100%) rename {Src/StdLib => StdLib}/Lib/test/mapping_tests.py (100%) rename {Src/StdLib => StdLib}/Lib/test/math_testcases.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/memory_watchdog.py (100%) rename {Src/StdLib => StdLib}/Lib/test/mime.types (100%) rename {Src/StdLib => StdLib}/Lib/test/mock_socket.py (100%) rename {Src/StdLib => StdLib}/Lib/test/mod_generics_cache.py (100%) rename {Src/StdLib => StdLib}/Lib/test/mp_fork_bomb.py (100%) rename {Src/StdLib => StdLib}/Lib/test/multibytecodec_support.py (100%) rename {Src/StdLib => StdLib}/Lib/test/nokia.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/nullbytecert.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/nullcert.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/outstanding_bugs.py (100%) rename {Src/StdLib => StdLib}/Lib/test/pickletester.py (100%) rename {Src/StdLib => StdLib}/Lib/test/profilee.py (100%) rename {Src/StdLib => StdLib}/Lib/test/pstats.pck (100%) rename {Src/StdLib => StdLib}/Lib/test/pycacert.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/pycakey.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/pyclbr_input.py (100%) rename {Src/StdLib => StdLib}/Lib/test/pydoc_mod.py (100%) rename {Src/StdLib => StdLib}/Lib/test/pydocfodder.py (100%) rename {Src/StdLib => StdLib}/Lib/test/pystone.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/test/randv2_32.pck (100%) rename {Src/StdLib => StdLib}/Lib/test/randv2_64.pck (100%) rename {Src/StdLib => StdLib}/Lib/test/randv3.pck (100%) rename {Src/StdLib => StdLib}/Lib/test/re_tests.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/test/regrtest.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/test/relimport.py (100%) rename {Src/StdLib => StdLib}/Lib/test/reperf.py (100%) rename {Src/StdLib => StdLib}/Lib/test/revocation.crl (100%) rename {Src/StdLib => StdLib}/Lib/test/sample_doctest.py (100%) rename {Src/StdLib => StdLib}/Lib/test/sample_doctest_no_docstrings.py (100%) rename {Src/StdLib => StdLib}/Lib/test/sample_doctest_no_doctests.py (100%) rename {Src/StdLib => StdLib}/Lib/test/script_helper.py (100%) rename {Src/StdLib => StdLib}/Lib/test/selfsigned_pythontestdotnet.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/seq_tests.py (100%) rename {Src/StdLib => StdLib}/Lib/test/sgml_input.html (100%) rename {Src/StdLib => StdLib}/Lib/test/sha256.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/sndhdrdata/README (100%) rename {Src/StdLib => StdLib}/Lib/test/sndhdrdata/sndhdr.8svx (100%) rename {Src/StdLib => StdLib}/Lib/test/sndhdrdata/sndhdr.aifc (100%) rename {Src/StdLib => StdLib}/Lib/test/sndhdrdata/sndhdr.aiff (100%) rename {Src/StdLib => StdLib}/Lib/test/sndhdrdata/sndhdr.au (100%) rename {Src/StdLib => StdLib}/Lib/test/sndhdrdata/sndhdr.hcom (100%) rename {Src/StdLib => StdLib}/Lib/test/sndhdrdata/sndhdr.sndt (100%) rename {Src/StdLib => StdLib}/Lib/test/sndhdrdata/sndhdr.voc (100%) rename {Src/StdLib => StdLib}/Lib/test/sndhdrdata/sndhdr.wav (100%) rename {Src/StdLib => StdLib}/Lib/test/sortperf.py (100%) rename {Src/StdLib => StdLib}/Lib/test/ssl_cert.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/ssl_key.passwd.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/ssl_key.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/ssl_servers.py (100%) rename {Src/StdLib => StdLib}/Lib/test/ssltests.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/test/string_tests.py (100%) rename {Src/StdLib => StdLib}/Lib/test/subprocessdata/fd_status.py (100%) rename {Src/StdLib => StdLib}/Lib/test/subprocessdata/input_reader.py (100%) rename {Src/StdLib => StdLib}/Lib/test/subprocessdata/qcat.py (100%) rename {Src/StdLib => StdLib}/Lib/test/subprocessdata/qgrep.py (100%) rename {Src/StdLib => StdLib}/Lib/test/subprocessdata/sigchild_ignore.py (100%) rename {Src/StdLib => StdLib}/Lib/test/support/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/talos-2019-0758.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/test___all__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test___future__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test__locale.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test__opcode.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test__osx_support.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_abc.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_abstract_numbers.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_aifc.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_argparse.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_array.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/test/test_ast.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asynchat.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/echo.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/echo2.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/echo3.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/keycert3.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/pycacert.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/ssl_cert.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/ssl_key.pem (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/test_base_events.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/test_events.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/test_futures.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/test_locks.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/test_proactor_events.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/test_queues.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/test_selector_events.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/test_sslproto.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/test_streams.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/test_subprocess.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/test_tasks.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/test_transports.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/test_unix_events.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/test_windows_events.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncio/test_windows_utils.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_asyncore.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_atexit.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_audioop.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_augassign.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_base64.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_bigaddrspace.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_bigmem.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_binascii.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_binhex.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/test/test_binop.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_bisect.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_bool.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_buffer.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_bufio.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_builtin.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_bytes.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_bz2.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_calendar.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_call.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_capi.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_cgi.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_cgitb.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_charmapcodec.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_class.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_cmath.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_cmd.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_cmd_line.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_cmd_line_script.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_code.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_code_module.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_codeccallbacks.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_codecencodings_cn.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_codecencodings_hk.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_codecencodings_iso2022.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_codecencodings_jp.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_codecencodings_kr.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_codecencodings_tw.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_codecmaps_cn.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_codecmaps_hk.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_codecmaps_jp.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_codecmaps_kr.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_codecmaps_tw.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_codecs.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_codeop.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_collections.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_colorsys.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_compare.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_compile.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_compileall.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_complex.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_concurrent_futures.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_configparser.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_contains.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_contextlib.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_copy.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_copyreg.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_cprofile.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_crashers.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_crypt.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_csv.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_ctypes.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_curses.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_datetime.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_dbm.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_dbm_dumb.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_dbm_gnu.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_dbm_ndbm.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_decimal.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_decorators.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_defaultdict.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_deque.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_descr.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_descrtut.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_devpoll.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_dict.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_dictcomps.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_dictviews.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_difflib.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_difflib_expect.html (100%) rename {Src/StdLib => StdLib}/Lib/test/test_dis.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_distutils.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_doctest.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_doctest.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_doctest2.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_doctest2.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_doctest3.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_doctest4.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_docxmlrpc.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_dummy_thread.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_dummy_threading.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_dynamic.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_dynamicclassattribute.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/PyBanner048.gif (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/audiotest.au (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_01.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_02.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_03.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_04.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_05.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_06.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_07.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_08.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_09.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_10.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_11.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_12.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_12a.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_13.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_14.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_15.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_16.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_17.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_18.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_19.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_20.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_21.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_22.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_23.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_24.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_25.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_26.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_27.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_28.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_29.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_30.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_31.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_32.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_33.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_34.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_35.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_36.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_37.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_38.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_39.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_40.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_41.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_42.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_43.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_44.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_45.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/data/msg_46.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/test__encoded_words.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/test__header_value_parser.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/test_asian_codecs.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/test_contentmanager.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/test_defect_handling.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/test_email.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/test_generator.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/test_headerregistry.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/test_inversion.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/test_message.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/test_parser.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/test_pickleable.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/test_policy.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/test_utils.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_email/torture_test.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_ensurepip.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_enum.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_enumerate.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_eof.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_epoll.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_errno.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/test/test_exception_variations.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_exceptions.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_extcall.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_faulthandler.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_fcntl.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_file.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_file_eintr.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_filecmp.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_fileinput.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_fileio.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_finalization.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_float.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_flufl.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_fnmatch.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_fork1.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_format.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_fractions.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_frame.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_fstring.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_ftplib.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_funcattrs.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_functools.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_future.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_future3.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_future4.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_future5.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_gc.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_gdb.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_generators.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_genericpath.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_genexps.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_getargs2.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_getopt.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_getpass.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_gettext.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_glob.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_global.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_grammar.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_grp.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_gzip.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_hash.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_hashlib.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_heapq.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_hmac.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_html.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_htmlparser.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_http_cookiejar.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_http_cookies.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_httplib.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_httpservers.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_idle.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_imaplib.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_imghdr.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_imp.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_import.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/abc.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/builtin/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/builtin/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/builtin/test_finder.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/builtin/test_loader.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/builtin/util.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/extension/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/extension/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/extension/test_case_sensitivity.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/extension/test_finder.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/extension/test_loader.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/extension/test_path_hook.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/extension/util.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/frozen/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/frozen/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/frozen/test_finder.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/frozen/test_loader.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/import_/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/import_/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/import_/test___loader__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/import_/test___package__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/import_/test_api.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/import_/test_caching.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/import_/test_fromlist.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/import_/test_meta_path.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/import_/test_packages.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/import_/test_path.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/import_/test_relative_imports.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/import_/util.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/regrtest.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/source/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/source/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/source/test_case_sensitivity.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/source/test_file_loader.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/source/test_finder.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/source/test_path_hook.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/source/test_source_encoding.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/source/util.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/test_abc.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/test_api.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/test_locks.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/test_namespace_pkgs.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/test_spec.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/test_util.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/test_windows.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_importlib/util.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_index.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_inspect.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_int.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_int_literal.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_io.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_ioctl.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_ipaddress.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_isinstance.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_iter.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_iterlen.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_itertools.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_json/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_json/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_json/test_decode.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_json/test_default.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_json/test_dump.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_json/test_encode_basestring_ascii.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_json/test_enum.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_json/test_fail.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_json/test_float.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_json/test_indent.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_json/test_pass1.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_json/test_pass2.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_json/test_pass3.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_json/test_recursion.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_json/test_scanstring.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_json/test_separators.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_json/test_speedups.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_json/test_tool.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_json/test_unicode.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_keyword.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_keywordonlyarg.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_kqueue.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_largefile.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_lib2to3.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_linecache.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_list.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_listcomps.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_locale.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_logging.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_long.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_longexp.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_lzma.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_macpath.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_macurl2path.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_mailbox.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_mailcap.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_marshal.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_math.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_memoryio.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_memoryview.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_metaclass.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_mimetypes.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_minidom.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_mmap.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_module.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_modulefinder.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_msilib.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_multibytecodec.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_multiprocessing_fork.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_multiprocessing_forkserver.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_multiprocessing_main_handling.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_multiprocessing_spawn.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_netrc.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_nis.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_nntplib.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_normalization.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_ntpath.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_numeric_tower.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_opcodes.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_openpty.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_operator.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_optparse.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_ordered_dict.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_os.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_ossaudiodev.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_osx_env.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_parser.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pathlib.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/test/test_pdb.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_peepholer.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pep247.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pep277.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pep292.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pep3120.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pep3131.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pep3151.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pep352.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pep380.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pep479.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pickle.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pickletools.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pipes.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pkg.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pkgimport.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pkgutil.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_platform.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_plistlib.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_poll.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_popen.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_poplib.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_posix.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_posixpath.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pow.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pprint.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_print.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_profile.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_property.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pstats.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pty.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pulldom.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pwd.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_py_compile.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pyclbr.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pydoc.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_pyexpat.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_queue.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_quopri.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_raise.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_random.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_range.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_re.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_readline.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_regrtest.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_reprlib.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_resource.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_richcmp.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_rlcompleter.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_robotparser.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_runpy.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_sax.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_sched.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_scope.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_script_helper.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_select.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_selectors.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_set.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_setcomps.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_shelve.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_shlex.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_shutil.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_signal.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_site.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_slice.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_smtpd.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_smtplib.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_smtpnet.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_sndhdr.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_socket.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_socketserver.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_sort.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_source_encoding.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_spwd.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_sqlite.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_ssl.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_startfile.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_stat.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_statistics.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_strftime.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_string.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_stringprep.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_strlit.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_strptime.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_strtod.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_struct.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_structmembers.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_structseq.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_subprocess.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_sunau.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_sundry.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_super.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_support.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_symtable.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_syntax.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_sys.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_sys_setprofile.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_sys_settrace.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_sysconfig.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_syslog.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_tarfile.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_tcl.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_telnetlib.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_tempfile.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_textwrap.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_thread.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_threaded_import.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_threadedtempfile.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_threading.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_threading_local.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_threadsignals.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_time.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_timeit.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_timeout.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_tk.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_tokenize.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_tools/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_tools/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_tools/test_gprof2html.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_tools/test_md5sum.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_tools/test_pdeps.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_tools/test_pindent.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_tools/test_reindent.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_tools/test_sundry.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_tools/test_unparse.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_trace.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_traceback.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_tracemalloc.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_ttk_guionly.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_ttk_textonly.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_tuple.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_typechecks.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_types.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_typing.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_ucn.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_unary.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_unicode.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_unicode_file.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_unicodedata.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_unittest.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_univnewlines.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_unpack.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_unpack_ex.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_urllib.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_urllib2.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_urllib2_localnet.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_urllib2net.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_urllib_response.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_urllibnet.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_urlparse.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/test/test_userdict.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_userlist.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_userstring.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/test/test_utf8_mode.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_uu.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_uuid.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_venv.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_wait3.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_wait4.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_warnings.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_wave.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_weakref.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_weakset.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_webbrowser.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_winreg.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_winsound.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_with.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_wsgiref.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_xdrlib.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_xml_dom_minicompat.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_xml_etree.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_xml_etree_c.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_xmlrpc.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_xmlrpc_net.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_zipfile.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_zipfile64.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_zipimport.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_zipimport_support.py (100%) rename {Src/StdLib => StdLib}/Lib/test/test_zlib.py (100%) rename {Src/StdLib => StdLib}/Lib/test/testcodec.py (100%) rename {Src/StdLib => StdLib}/Lib/test/testtar.tar (100%) rename {Src/StdLib => StdLib}/Lib/test/tf_inherit_check.py (100%) rename {Src/StdLib => StdLib}/Lib/test/threaded_import_hangers.py (100%) rename {Src/StdLib => StdLib}/Lib/test/time_hashlib.py (100%) rename {Src/StdLib => StdLib}/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/tokenize_tests.txt (100%) rename {Src/StdLib => StdLib}/Lib/test/tracedmodules/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/test/tracedmodules/testmod.py (100%) rename {Src/StdLib => StdLib}/Lib/test/warning_tests.py (100%) rename {Src/StdLib => StdLib}/Lib/test/win_console_handler.py (100%) rename {Src/StdLib => StdLib}/Lib/test/xmltestdata/simple-ns.xml (100%) rename {Src/StdLib => StdLib}/Lib/test/xmltestdata/simple.xml (100%) rename {Src/StdLib => StdLib}/Lib/test/xmltestdata/test.xml (100%) rename {Src/StdLib => StdLib}/Lib/test/xmltestdata/test.xml.out (100%) rename {Src/StdLib => StdLib}/Lib/test/xmltests.py (100%) rename {Src/StdLib => StdLib}/Lib/test/zip_cp437_header.zip (100%) rename {Src/StdLib => StdLib}/Lib/test/zipdir.zip (100%) rename {Src/StdLib => StdLib}/Lib/textwrap.py (100%) rename {Src/StdLib => StdLib}/Lib/this.py (100%) rename {Src/StdLib => StdLib}/Lib/threading.py (100%) rename {Src/StdLib => StdLib}/Lib/timeit.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/_fix.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/colorchooser.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/commondialog.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/constants.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/dialog.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/dnd.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/filedialog.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/font.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/messagebox.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/scrolledtext.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/simpledialog.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/test/README (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/test/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/test/runtktests.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/test/support.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/test/test_tkinter/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/test/test_tkinter/test_font.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/test/test_tkinter/test_geometry_managers.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/test/test_tkinter/test_images.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/test/test_tkinter/test_loadtk.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/test/test_tkinter/test_misc.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/test/test_tkinter/test_text.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/test/test_tkinter/test_variables.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/test/test_tkinter/test_widgets.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/test/test_ttk/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/test/test_ttk/test_extensions.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/test/test_ttk/test_functions.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/test/test_ttk/test_style.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/test/test_ttk/test_widgets.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/test/widget_tests.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/tix.py (100%) rename {Src/StdLib => StdLib}/Lib/tkinter/ttk.py (100%) rename {Src/StdLib => StdLib}/Lib/token.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/tokenize.py (100%) rename {Src/StdLib => StdLib}/Lib/trace.py (100%) rename {Src/StdLib => StdLib}/Lib/traceback.py (100%) rename {Src/StdLib => StdLib}/Lib/tracemalloc.py (100%) rename {Src/StdLib => StdLib}/Lib/tty.py (100%) rename {Src/StdLib => StdLib}/Lib/turtle.py (100%) rename {Src/StdLib => StdLib}/Lib/turtledemo/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/turtledemo/__main__.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/turtledemo/bytedesign.py (100%) rename {Src/StdLib => StdLib}/Lib/turtledemo/chaos.py (100%) rename {Src/StdLib => StdLib}/Lib/turtledemo/clock.py (100%) rename {Src/StdLib => StdLib}/Lib/turtledemo/colormixer.py (100%) rename {Src/StdLib => StdLib}/Lib/turtledemo/forest.py (100%) rename {Src/StdLib => StdLib}/Lib/turtledemo/fractalcurves.py (100%) rename {Src/StdLib => StdLib}/Lib/turtledemo/lindenmayer.py (100%) rename {Src/StdLib => StdLib}/Lib/turtledemo/minimal_hanoi.py (100%) rename {Src/StdLib => StdLib}/Lib/turtledemo/nim.py (100%) rename {Src/StdLib => StdLib}/Lib/turtledemo/paint.py (100%) rename {Src/StdLib => StdLib}/Lib/turtledemo/peace.py (100%) rename {Src/StdLib => StdLib}/Lib/turtledemo/penrose.py (100%) rename {Src/StdLib => StdLib}/Lib/turtledemo/planet_and_moon.py (100%) rename {Src/StdLib => StdLib}/Lib/turtledemo/round_dance.py (100%) rename {Src/StdLib => StdLib}/Lib/turtledemo/tree.py (100%) rename {Src/StdLib => StdLib}/Lib/turtledemo/turtle.cfg (100%) rename {Src/StdLib => StdLib}/Lib/turtledemo/two_canvases.py (100%) rename {Src/StdLib => StdLib}/Lib/turtledemo/wikipedia.py (100%) rename {Src/StdLib => StdLib}/Lib/turtledemo/yinyang.py (100%) rename {Src/StdLib => StdLib}/Lib/types.py (100%) rename {Src/StdLib => StdLib}/Lib/typing.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/case.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/loader.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/main.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/mock.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/result.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/runner.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/signals.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/suite.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/_test_warnings.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/dummy.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/support.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/test_assertions.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/test_break.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/test_case.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/test_discovery.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/test_functiontestcase.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/test_loader.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/test_program.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/test_result.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/test_runner.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/test_setups.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/test_skipping.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/test_suite.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/testmock/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/testmock/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/testmock/support.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/testmock/testcallable.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/testmock/testhelpers.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/testmock/testmagicmethods.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/testmock/testmock.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/testmock/testpatch.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/testmock/testsentinel.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/test/testmock/testwith.py (100%) rename {Src/StdLib => StdLib}/Lib/unittest/util.py (100%) rename {Src/StdLib => StdLib}/Lib/urllib/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/urllib/error.py (100%) rename {Src/StdLib => StdLib}/Lib/urllib/parse.py (100%) rename {Src/StdLib => StdLib}/Lib/urllib/request.py (100%) rename {Src/StdLib => StdLib}/Lib/urllib/response.py (100%) rename {Src/StdLib => StdLib}/Lib/urllib/robotparser.py (100%) rename {Src/StdLib => StdLib}/Lib/uu.py (100%) mode change 100755 => 100644 rename {Src/StdLib => StdLib}/Lib/uuid.py (100%) rename {Src/StdLib => StdLib}/Lib/venv/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/venv/__main__.py (100%) rename {Src/StdLib => StdLib}/Lib/venv/scripts/nt/Activate.ps1 (100%) rename {Src/StdLib => StdLib}/Lib/venv/scripts/nt/activate.bat (100%) rename {Src/StdLib => StdLib}/Lib/venv/scripts/nt/deactivate.bat (100%) rename {Src/StdLib => StdLib}/Lib/venv/scripts/posix/activate (100%) rename {Src/StdLib => StdLib}/Lib/venv/scripts/posix/activate.csh (100%) rename {Src/StdLib => StdLib}/Lib/venv/scripts/posix/activate.fish (100%) rename {Src/StdLib => StdLib}/Lib/warnings.py (100%) rename {Src/StdLib => StdLib}/Lib/wave.py (100%) rename {Src/StdLib => StdLib}/Lib/weakref.py (100%) rename {Src/StdLib => StdLib}/Lib/webbrowser.py (100%) rename {Src/StdLib => StdLib}/Lib/wpf.py (100%) rename {Src/StdLib => StdLib}/Lib/wsgiref/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/wsgiref/handlers.py (100%) rename {Src/StdLib => StdLib}/Lib/wsgiref/headers.py (100%) rename {Src/StdLib => StdLib}/Lib/wsgiref/simple_server.py (100%) rename {Src/StdLib => StdLib}/Lib/wsgiref/util.py (100%) rename {Src/StdLib => StdLib}/Lib/wsgiref/validate.py (100%) rename {Src/StdLib => StdLib}/Lib/xdrlib.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/dom/NodeFilter.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/dom/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/dom/domreg.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/dom/expatbuilder.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/dom/minicompat.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/dom/minidom.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/dom/pulldom.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/dom/xmlbuilder.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/etree/ElementInclude.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/etree/ElementPath.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/etree/ElementTree.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/etree/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/etree/cElementTree.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/parsers/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/parsers/expat.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/sax/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/sax/_exceptions.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/sax/expatreader.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/sax/handler.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/sax/saxutils.py (100%) rename {Src/StdLib => StdLib}/Lib/xml/sax/xmlreader.py (100%) rename {Src/StdLib => StdLib}/Lib/xmlrpc/__init__.py (100%) rename {Src/StdLib => StdLib}/Lib/xmlrpc/client.py (100%) rename {Src/StdLib => StdLib}/Lib/xmlrpc/server.py (100%) rename {Src/StdLib => StdLib}/Lib/zipfile.py (100%) rename {Src/StdLib => StdLib}/StdLib.License.txt (100%) rename {Src/StdLib => StdLib}/StdLib.pyproj (100%) rename {Src/StdLib => StdLib}/stdlib-upgrade.txt (100%) rename {Src/StdLib => StdLib}/update-stdlib.cmd (100%) rename {Src/StdLib => StdLib}/update-stdlib.sh (100%) mode change 100755 => 100644 rename {Src/Tests => Tests}/AssemblyInfo.cs (100%) rename {Src/Tests => Tests}/AttrInjectorTest.cs (100%) rename {Src/Tests => Tests}/BindTest.cs (100%) rename {Src/Tests => Tests}/BinderTest.cs (100%) rename {Src/Tests => Tests}/Cases/CPythonCases.cs (100%) rename {Src/Tests => Tests}/Cases/CPythonCasesManifest.ini (100%) rename {Src/Tests => Tests}/Cases/CaseExecuter.cs (100%) rename {Src/Tests => Tests}/Cases/CaseGenerator.cs (100%) rename {Src/Tests => Tests}/Cases/CommonCases.cs (100%) rename {Src/Tests => Tests}/Cases/IronPythonCases.cs (100%) rename {Src/Tests => Tests}/Cases/IronPythonCasesManifest.ini (100%) rename {Src/Tests => Tests}/ClrType.cs (100%) rename {Src/Tests => Tests}/Cmplx.cs (100%) rename {Src/Tests => Tests}/Conversions.cs (100%) rename {Src/Tests => Tests}/DeTest.cs (100%) rename {Src/Tests => Tests}/DelegateTest.cs (100%) rename {Src/Tests => Tests}/DynamicRegressions.cs (100%) rename {Src/Tests => Tests}/EncodingTest.cs (100%) rename {Src/Tests => Tests}/EngineTest.cs (100%) rename {Src/Tests => Tests}/Enums.cs (100%) rename {Src/Tests => Tests}/Events.cs (100%) rename {Src/Tests => Tests}/ExceptionConverter.cs (100%) rename {Src/Tests => Tests}/Exceptions.cs (100%) rename {Src/Tests => Tests}/Explicit.cs (100%) rename {Src/Tests => Tests}/ExtensionMethodTest.cs (100%) rename {Src/Tests => Tests}/GenMeth.cs (100%) rename {Src/Tests => Tests}/Indexable.cs (100%) rename {Src/Tests => Tests}/InheritTest.cs (100%) rename {Src/Tests => Tests}/IntegerTest.cs (100%) rename {Src/Tests => Tests}/IronMath.cs (100%) rename {Src/Tests => Tests}/IronPython.Tests.csproj (100%) rename {Src/Tests => Tests}/LoadTest.cs (100%) rename {Src/Tests => Tests}/MemberMappingTests.cs (100%) rename {Src/Tests => Tests}/MemberOverloadTest.cs (100%) rename {Src/Tests => Tests}/MethodParametersStubs.cs (100%) rename {Src/Tests => Tests}/NestedClass.cs (100%) rename {Src/Tests => Tests}/NullableTest.cs (100%) rename {Src/Tests => Tests}/OperatorTest.cs (100%) rename {Src/Tests => Tests}/ProtocolTest.cs (100%) rename {Src/Tests => Tests}/StaticTest.cs (100%) rename {Src/Tests => Tests}/Stress/Engine.cs (100%) rename {Src/Tests => Tests}/StringDictionaryStorage.cs (100%) rename {Src/Tests => Tests}/TestBuiltinModule.cs (100%) rename {Src/Tests => Tests}/TypeDescriptor.cs (100%) rename {Src/Tests => Tests}/Util/IniParser.cs (100%) rename {Src/Tests => Tests}/Util/TestManifest.cs (100%) rename {Src/Wpf => Wpf}/DynamicXamlReader.cs (100%) rename {Src/Wpf => Wpf}/IronPython.Wpf.csproj (100%) rename {Src/Wpf => Wpf}/Properties/AssemblyInfo.cs (100%) rename {Src/Wpf => Wpf}/_wpf.cs (100%) diff --git a/Src/App.Debug.config b/App.Debug.config similarity index 100% rename from Src/App.Debug.config rename to App.Debug.config diff --git a/Src/App.Release.config b/App.Release.config similarity index 100% rename from Src/App.Release.config rename to App.Release.config diff --git a/Src/CTypes/Makefile b/CTypes/Makefile similarity index 100% rename from Src/CTypes/Makefile rename to CTypes/Makefile diff --git a/Src/CTypes/_ctypes_test.c b/CTypes/_ctypes_test.c similarity index 100% rename from Src/CTypes/_ctypes_test.c rename to CTypes/_ctypes_test.c diff --git a/Src/CTypes/_ctypes_test.sln b/CTypes/_ctypes_test.sln similarity index 100% rename from Src/CTypes/_ctypes_test.sln rename to CTypes/_ctypes_test.sln diff --git a/Src/CTypes/_ctypes_test.vcxproj b/CTypes/_ctypes_test.vcxproj similarity index 100% rename from Src/CTypes/_ctypes_test.vcxproj rename to CTypes/_ctypes_test.vcxproj diff --git a/Src/CompilerServices/AssemblyResolver.cs b/CompilerServices/AssemblyResolver.cs similarity index 100% rename from Src/CompilerServices/AssemblyResolver.cs rename to CompilerServices/AssemblyResolver.cs diff --git a/Src/CompilerServices/Config.cs b/CompilerServices/Config.cs similarity index 100% rename from Src/CompilerServices/Config.cs rename to CompilerServices/Config.cs diff --git a/Src/CompilerServices/ConsoleOps.cs b/CompilerServices/ConsoleOps.cs similarity index 100% rename from Src/CompilerServices/ConsoleOps.cs rename to CompilerServices/ConsoleOps.cs diff --git a/Src/CompilerServices/IronPython.CompilerServices.csproj b/CompilerServices/IronPython.CompilerServices.csproj similarity index 84% rename from Src/CompilerServices/IronPython.CompilerServices.csproj rename to CompilerServices/IronPython.CompilerServices.csproj index ffa1d0cb4..d10a7b092 100644 --- a/Src/CompilerServices/IronPython.CompilerServices.csproj +++ b/CompilerServices/IronPython.CompilerServices.csproj @@ -15,12 +15,12 @@ - + - ..\..\Util\References\IKVM\IKVM.Reflection.dll + ..\Utils\References\IKVM\IKVM.Reflection.dll diff --git a/Src/CompilerServices/Program.cs b/CompilerServices/Program.cs similarity index 100% rename from Src/CompilerServices/Program.cs rename to CompilerServices/Program.cs diff --git a/Src/CompilerServices/Properties/AssemblyInfo.cs b/CompilerServices/Properties/AssemblyInfo.cs similarity index 100% rename from Src/CompilerServices/Properties/AssemblyInfo.cs rename to CompilerServices/Properties/AssemblyInfo.cs diff --git a/Src/CompilerServices/README.md b/CompilerServices/README.md similarity index 100% rename from Src/CompilerServices/README.md rename to CompilerServices/README.md diff --git a/Src/Console.Host/IronPython.Console.Host.csproj b/Console.Host/IronPython.Console.Host.csproj similarity index 100% rename from Src/Console.Host/IronPython.Console.Host.csproj rename to Console.Host/IronPython.Console.Host.csproj diff --git a/Src/Console.Host/IronPythonWindow.cs b/Console.Host/IronPythonWindow.cs similarity index 100% rename from Src/Console.Host/IronPythonWindow.cs rename to Console.Host/IronPythonWindow.cs diff --git a/Src/Console.Host/Properties/AssemblyInfo.cs b/Console.Host/Properties/AssemblyInfo.cs similarity index 100% rename from Src/Console.Host/Properties/AssemblyInfo.cs rename to Console.Host/Properties/AssemblyInfo.cs diff --git a/Src/Console.Host/ipyw.ico b/Console.Host/ipyw.ico similarity index 100% rename from Src/Console.Host/ipyw.ico rename to Console.Host/ipyw.ico diff --git a/Src/Console/Console.cs b/Console/Console.cs similarity index 100% rename from Src/Console/Console.cs rename to Console/Console.cs diff --git a/Src/Console/IronPython.Console.csproj b/Console/IronPython.Console.csproj similarity index 100% rename from Src/Console/IronPython.Console.csproj rename to Console/IronPython.Console.csproj diff --git a/Src/Console/Properties/AssemblyInfo.cs b/Console/Properties/AssemblyInfo.cs similarity index 100% rename from Src/Console/Properties/AssemblyInfo.cs rename to Console/Properties/AssemblyInfo.cs diff --git a/Src/Console/app.manifest b/Console/app.manifest similarity index 100% rename from Src/Console/app.manifest rename to Console/app.manifest diff --git a/Src/Console/ipy-mono.sh b/Console/ipy-mono.sh similarity index 100% rename from Src/Console/ipy-mono.sh rename to Console/ipy-mono.sh diff --git a/Src/Console/ipy.ico b/Console/ipy.ico similarity index 100% rename from Src/Console/ipy.ico rename to Console/ipy.ico diff --git a/Src/Console/ipy.sh b/Console/ipy.sh similarity index 100% rename from Src/Console/ipy.sh rename to Console/ipy.sh diff --git a/Src/Console/runtimeconfig.template.json b/Console/runtimeconfig.template.json similarity index 100% rename from Src/Console/runtimeconfig.template.json rename to Console/runtimeconfig.template.json diff --git a/Src/Console32.Host/IronPython.Console32.Host.csproj b/Console32.Host/IronPython.Console32.Host.csproj similarity index 79% rename from Src/Console32.Host/IronPython.Console32.Host.csproj rename to Console32.Host/IronPython.Console32.Host.csproj index 0ed23ee55..ea150a3e0 100644 --- a/Src/Console32.Host/IronPython.Console32.Host.csproj +++ b/Console32.Host/IronPython.Console32.Host.csproj @@ -19,8 +19,8 @@ - - + + diff --git a/Src/Console32/IronPython.Console32.csproj b/Console32/IronPython.Console32.csproj similarity index 100% rename from Src/Console32/IronPython.Console32.csproj rename to Console32/IronPython.Console32.csproj diff --git a/DLR b/DLR new file mode 160000 index 000000000..fe26cf45d --- /dev/null +++ b/DLR @@ -0,0 +1 @@ +Subproject commit fe26cf45d383be65a56f0d4b964644eff89e01a8 diff --git a/IronPython.sln b/IronPython.sln index 9d9ace479..fe48235e5 100644 --- a/IronPython.sln +++ b/IronPython.sln @@ -3,17 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.9.34714.143 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython", "Src\IronPython\IronPython.csproj", "{95289EA9-5778-489D-AB48-F81F2CE2DA32}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython", "IronPython\IronPython.csproj", "{95289EA9-5778-489D-AB48-F81F2CE2DA32}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Modules", "Src\Modules\IronPython.Modules.csproj", "{155CE436-1669-4A48-8095-410F2430237F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Modules", "Modules\IronPython.Modules.csproj", "{155CE436-1669-4A48-8095-410F2430237F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Wpf", "Src\Wpf\IronPython.Wpf.csproj", "{65E997B7-E99B-4C83-B29E-9951429BB293}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Wpf", "Wpf\IronPython.Wpf.csproj", "{65E997B7-E99B-4C83-B29E-9951429BB293}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console", "Src\Console\IronPython.Console.csproj", "{811AC32C-11F3-4ED8-92A7-A7E39C2BB704}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console", "Console\IronPython.Console.csproj", "{811AC32C-11F3-4ED8-92A7-A7E39C2BB704}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Tests", "Src\Tests\IronPython.Tests.csproj", "{B6B42537-07F8-4F6C-A99A-B155CAEB124E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Tests", "Tests\IronPython.Tests.csproj", "{B6B42537-07F8-4F6C-A99A-B155CAEB124E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console.Host", "Src\Console.Host\IronPython.Console.Host.csproj", "{81DA19C7-4FEC-47E7-981B-D9310D549F95}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console.Host", "Console.Host\IronPython.Console.Host.csproj", "{81DA19C7-4FEC-47E7-981B-D9310D549F95}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3A14D070-628F-44EF-92DD-47C8BE5C33CD}" ProjectSection(SolutionItems) = preProject @@ -45,19 +45,19 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{17737ACB Build\Tasks.Targets = Build\Tasks.Targets EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.CompilerServices", "Src\CompilerServices\IronPython.CompilerServices.csproj", "{3DFB096E-AC09-4E7A-9288-7F7C33C288C7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.CompilerServices", "CompilerServices\IronPython.CompilerServices.csproj", "{3DFB096E-AC09-4E7A-9288-7F7C33C288C7}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DLR", "DLR", "{AC38EFB1-820D-4E90-BF40-BEF3AC825542}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Dynamic", "Src\DLR\Src\Microsoft.Dynamic\Microsoft.Dynamic.csproj", "{EB66B766-6354-4208-A3D4-AACBDCB5C3B3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Dynamic", "DLR\Src\Microsoft.Dynamic\Microsoft.Dynamic.csproj", "{EB66B766-6354-4208-A3D4-AACBDCB5C3B3}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Scripting", "Src\DLR\Src\Microsoft.Scripting\Microsoft.Scripting.csproj", "{02FF0909-F5AD-48CF-A86A-345E721B7E40}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Scripting", "DLR\Src\Microsoft.Scripting\Microsoft.Scripting.csproj", "{02FF0909-F5AD-48CF-A86A-345E721B7E40}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Scripting.Metadata", "Src\DLR\Src\Microsoft.Scripting.Metadata\Microsoft.Scripting.Metadata.csproj", "{ACDD9B9E-8FE6-439C-9521-1CCBA47F6143}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Scripting.Metadata", "DLR\Src\Microsoft.Scripting.Metadata\Microsoft.Scripting.Metadata.csproj", "{ACDD9B9E-8FE6-439C-9521-1CCBA47F6143}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{60836ADE-CAB7-4587-B6FB-8C4FEB872752}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClrAssembly", "Src\DLR\Tests\ClrAssembly\ClrAssembly.csproj", "{BEE737B9-18D5-48D9-8672-9A896213C98B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClrAssembly", "DLR\Tests\ClrAssembly\ClrAssembly.csproj", "{BEE737B9-18D5-48D9-8672-9A896213C98B}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Package", "Package", "{CE610DDE-D1DB-44D8-BAE9-BAAB00DA98F0}" EndProject @@ -67,7 +67,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nuget", "nuget", "{EE77D917 Package\nuget\IronPython.StdLib.nuspec = Package\nuget\IronPython.StdLib.nuspec EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32", "Src\Console32\IronPython.Console32.csproj", "{AD21022F-E7C1-4B74-97C1-0A0E48EFF992}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32", "Console32\IronPython.Console32.csproj", "{AD21022F-E7C1-4B74-97C1-0A0E48EFF992}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "choco", "choco", "{EA550FD8-2241-4131-8292-619D009E0199}" ProjectSection(SolutionItems) = preProject @@ -100,11 +100,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "msi", "msi", "{450F93D5-DF0 Package\msi\Version.wxi = Package\msi\Version.wxi EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32.Host", "Src\Console32.Host\IronPython.Console32.Host.csproj", "{8F177DC2-9822-45BD-AB05-1F40FCA86168}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32.Host", "Console32.Host\IronPython.Console32.Host.csproj", "{8F177DC2-9822-45BD-AB05-1F40FCA86168}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronPython.DiagnosticAnalyzer", "DiagnosticAnalyzer\IronPython.DiagnosticAnalyzer.csproj", "{2DFE89D7-0C39-44E9-94CD-496CC985DFC3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronPython.SQLite", "Src\SQLite\IronPython.SQLite.csproj", "{2F1071BF-891C-42A3-8A82-6B8A168BDE64}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronPython.SQLite", "SQLite\IronPython.SQLite.csproj", "{2F1071BF-891C-42A3-8A82-6B8A168BDE64}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Src/IronPython/Compiler/Ast/AndExpression.cs b/IronPython/Compiler/Ast/AndExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/AndExpression.cs rename to IronPython/Compiler/Ast/AndExpression.cs diff --git a/Src/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs b/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs rename to IronPython/Compiler/Ast/AnnotatedAssignStatement.cs diff --git a/Src/IronPython/Compiler/Ast/AssertStatement.cs b/IronPython/Compiler/Ast/AssertStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/AssertStatement.cs rename to IronPython/Compiler/Ast/AssertStatement.cs diff --git a/Src/IronPython/Compiler/Ast/AssignmentStatement.cs b/IronPython/Compiler/Ast/AssignmentStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/AssignmentStatement.cs rename to IronPython/Compiler/Ast/AssignmentStatement.cs diff --git a/Src/IronPython/Compiler/Ast/AstMethods.cs b/IronPython/Compiler/Ast/AstMethods.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/AstMethods.cs rename to IronPython/Compiler/Ast/AstMethods.cs diff --git a/Src/IronPython/Compiler/Ast/AsyncStatement.cs b/IronPython/Compiler/Ast/AsyncStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/AsyncStatement.cs rename to IronPython/Compiler/Ast/AsyncStatement.cs diff --git a/Src/IronPython/Compiler/Ast/AugmentedAssignStatement.cs b/IronPython/Compiler/Ast/AugmentedAssignStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/AugmentedAssignStatement.cs rename to IronPython/Compiler/Ast/AugmentedAssignStatement.cs diff --git a/Src/IronPython/Compiler/Ast/BinaryExpression.Generated.cs b/IronPython/Compiler/Ast/BinaryExpression.Generated.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/BinaryExpression.Generated.cs rename to IronPython/Compiler/Ast/BinaryExpression.Generated.cs diff --git a/Src/IronPython/Compiler/Ast/BinaryExpression.cs b/IronPython/Compiler/Ast/BinaryExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/BinaryExpression.cs rename to IronPython/Compiler/Ast/BinaryExpression.cs diff --git a/Src/IronPython/Compiler/Ast/BreakStatement.cs b/IronPython/Compiler/Ast/BreakStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/BreakStatement.cs rename to IronPython/Compiler/Ast/BreakStatement.cs diff --git a/Src/IronPython/Compiler/Ast/CallExpression.cs b/IronPython/Compiler/Ast/CallExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/CallExpression.cs rename to IronPython/Compiler/Ast/CallExpression.cs diff --git a/Src/IronPython/Compiler/Ast/ClassDefinition.cs b/IronPython/Compiler/Ast/ClassDefinition.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ClassDefinition.cs rename to IronPython/Compiler/Ast/ClassDefinition.cs diff --git a/Src/IronPython/Compiler/Ast/Comprehension.cs b/IronPython/Compiler/Ast/Comprehension.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/Comprehension.cs rename to IronPython/Compiler/Ast/Comprehension.cs diff --git a/Src/IronPython/Compiler/Ast/ComprehensionFor.cs b/IronPython/Compiler/Ast/ComprehensionFor.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ComprehensionFor.cs rename to IronPython/Compiler/Ast/ComprehensionFor.cs diff --git a/Src/IronPython/Compiler/Ast/ComprehensionIf.cs b/IronPython/Compiler/Ast/ComprehensionIf.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ComprehensionIf.cs rename to IronPython/Compiler/Ast/ComprehensionIf.cs diff --git a/Src/IronPython/Compiler/Ast/ConditionalExpression.cs b/IronPython/Compiler/Ast/ConditionalExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ConditionalExpression.cs rename to IronPython/Compiler/Ast/ConditionalExpression.cs diff --git a/Src/IronPython/Compiler/Ast/ConstantExpression.cs b/IronPython/Compiler/Ast/ConstantExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ConstantExpression.cs rename to IronPython/Compiler/Ast/ConstantExpression.cs diff --git a/Src/IronPython/Compiler/Ast/ContinueStatement.cs b/IronPython/Compiler/Ast/ContinueStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ContinueStatement.cs rename to IronPython/Compiler/Ast/ContinueStatement.cs diff --git a/Src/IronPython/Compiler/Ast/DelStatement.cs b/IronPython/Compiler/Ast/DelStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/DelStatement.cs rename to IronPython/Compiler/Ast/DelStatement.cs diff --git a/Src/IronPython/Compiler/Ast/DictionaryExpression.cs b/IronPython/Compiler/Ast/DictionaryExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/DictionaryExpression.cs rename to IronPython/Compiler/Ast/DictionaryExpression.cs diff --git a/Src/IronPython/Compiler/Ast/DottedName.cs b/IronPython/Compiler/Ast/DottedName.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/DottedName.cs rename to IronPython/Compiler/Ast/DottedName.cs diff --git a/Src/IronPython/Compiler/Ast/DynamicConvertExpression.cs b/IronPython/Compiler/Ast/DynamicConvertExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/DynamicConvertExpression.cs rename to IronPython/Compiler/Ast/DynamicConvertExpression.cs diff --git a/Src/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs b/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs rename to IronPython/Compiler/Ast/DynamicGetMemberExpression.cs diff --git a/Src/IronPython/Compiler/Ast/EmptyStatement.cs b/IronPython/Compiler/Ast/EmptyStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/EmptyStatement.cs rename to IronPython/Compiler/Ast/EmptyStatement.cs diff --git a/Src/IronPython/Compiler/Ast/ErrorExpression.cs b/IronPython/Compiler/Ast/ErrorExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ErrorExpression.cs rename to IronPython/Compiler/Ast/ErrorExpression.cs diff --git a/Src/IronPython/Compiler/Ast/Expression.cs b/IronPython/Compiler/Ast/Expression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/Expression.cs rename to IronPython/Compiler/Ast/Expression.cs diff --git a/Src/IronPython/Compiler/Ast/ExpressionStatement.cs b/IronPython/Compiler/Ast/ExpressionStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ExpressionStatement.cs rename to IronPython/Compiler/Ast/ExpressionStatement.cs diff --git a/Src/IronPython/Compiler/Ast/FlowChecker.cs b/IronPython/Compiler/Ast/FlowChecker.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/FlowChecker.cs rename to IronPython/Compiler/Ast/FlowChecker.cs diff --git a/Src/IronPython/Compiler/Ast/ForStatement.cs b/IronPython/Compiler/Ast/ForStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ForStatement.cs rename to IronPython/Compiler/Ast/ForStatement.cs diff --git a/Src/IronPython/Compiler/Ast/FormattedValueExpression.cs b/IronPython/Compiler/Ast/FormattedValueExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/FormattedValueExpression.cs rename to IronPython/Compiler/Ast/FormattedValueExpression.cs diff --git a/Src/IronPython/Compiler/Ast/FromImportStatement.cs b/IronPython/Compiler/Ast/FromImportStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/FromImportStatement.cs rename to IronPython/Compiler/Ast/FromImportStatement.cs diff --git a/Src/IronPython/Compiler/Ast/FunctionDefinition.cs b/IronPython/Compiler/Ast/FunctionDefinition.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/FunctionDefinition.cs rename to IronPython/Compiler/Ast/FunctionDefinition.cs diff --git a/Src/IronPython/Compiler/Ast/GeneratorExpression.cs b/IronPython/Compiler/Ast/GeneratorExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/GeneratorExpression.cs rename to IronPython/Compiler/Ast/GeneratorExpression.cs diff --git a/Src/IronPython/Compiler/Ast/GetGlobalContextExpression.cs b/IronPython/Compiler/Ast/GetGlobalContextExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/GetGlobalContextExpression.cs rename to IronPython/Compiler/Ast/GetGlobalContextExpression.cs diff --git a/Src/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs b/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs rename to IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs diff --git a/Src/IronPython/Compiler/Ast/GlobalStatement.cs b/IronPython/Compiler/Ast/GlobalStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/GlobalStatement.cs rename to IronPython/Compiler/Ast/GlobalStatement.cs diff --git a/Src/IronPython/Compiler/Ast/ILoopStatement.cs b/IronPython/Compiler/Ast/ILoopStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ILoopStatement.cs rename to IronPython/Compiler/Ast/ILoopStatement.cs diff --git a/Src/IronPython/Compiler/Ast/IfStatement.cs b/IronPython/Compiler/Ast/IfStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/IfStatement.cs rename to IronPython/Compiler/Ast/IfStatement.cs diff --git a/Src/IronPython/Compiler/Ast/IfStatementTest.cs b/IronPython/Compiler/Ast/IfStatementTest.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/IfStatementTest.cs rename to IronPython/Compiler/Ast/IfStatementTest.cs diff --git a/Src/IronPython/Compiler/Ast/ImportStatement.cs b/IronPython/Compiler/Ast/ImportStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ImportStatement.cs rename to IronPython/Compiler/Ast/ImportStatement.cs diff --git a/Src/IronPython/Compiler/Ast/IndexExpression.cs b/IronPython/Compiler/Ast/IndexExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/IndexExpression.cs rename to IronPython/Compiler/Ast/IndexExpression.cs diff --git a/Src/IronPython/Compiler/Ast/JoinedStringExpression.cs b/IronPython/Compiler/Ast/JoinedStringExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/JoinedStringExpression.cs rename to IronPython/Compiler/Ast/JoinedStringExpression.cs diff --git a/Src/IronPython/Compiler/Ast/Keyword.cs b/IronPython/Compiler/Ast/Keyword.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/Keyword.cs rename to IronPython/Compiler/Ast/Keyword.cs diff --git a/Src/IronPython/Compiler/Ast/LambdaExpression.cs b/IronPython/Compiler/Ast/LambdaExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/LambdaExpression.cs rename to IronPython/Compiler/Ast/LambdaExpression.cs diff --git a/Src/IronPython/Compiler/Ast/ListExpression.cs b/IronPython/Compiler/Ast/ListExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ListExpression.cs rename to IronPython/Compiler/Ast/ListExpression.cs diff --git a/Src/IronPython/Compiler/Ast/MemberExpression.cs b/IronPython/Compiler/Ast/MemberExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/MemberExpression.cs rename to IronPython/Compiler/Ast/MemberExpression.cs diff --git a/Src/IronPython/Compiler/Ast/ModuleName.cs b/IronPython/Compiler/Ast/ModuleName.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ModuleName.cs rename to IronPython/Compiler/Ast/ModuleName.cs diff --git a/Src/IronPython/Compiler/Ast/NameExpression.cs b/IronPython/Compiler/Ast/NameExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/NameExpression.cs rename to IronPython/Compiler/Ast/NameExpression.cs diff --git a/Src/IronPython/Compiler/Ast/Node.cs b/IronPython/Compiler/Ast/Node.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/Node.cs rename to IronPython/Compiler/Ast/Node.cs diff --git a/Src/IronPython/Compiler/Ast/NonlocalStatement.cs b/IronPython/Compiler/Ast/NonlocalStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/NonlocalStatement.cs rename to IronPython/Compiler/Ast/NonlocalStatement.cs diff --git a/Src/IronPython/Compiler/Ast/OrExpression.cs b/IronPython/Compiler/Ast/OrExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/OrExpression.cs rename to IronPython/Compiler/Ast/OrExpression.cs diff --git a/Src/IronPython/Compiler/Ast/Parameter.cs b/IronPython/Compiler/Ast/Parameter.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/Parameter.cs rename to IronPython/Compiler/Ast/Parameter.cs diff --git a/Src/IronPython/Compiler/Ast/ParenthesisExpression.cs b/IronPython/Compiler/Ast/ParenthesisExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ParenthesisExpression.cs rename to IronPython/Compiler/Ast/ParenthesisExpression.cs diff --git a/Src/IronPython/Compiler/Ast/PythonAst.cs b/IronPython/Compiler/Ast/PythonAst.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/PythonAst.cs rename to IronPython/Compiler/Ast/PythonAst.cs diff --git a/Src/IronPython/Compiler/Ast/PythonConstantExpression.cs b/IronPython/Compiler/Ast/PythonConstantExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/PythonConstantExpression.cs rename to IronPython/Compiler/Ast/PythonConstantExpression.cs diff --git a/Src/IronPython/Compiler/Ast/PythonNameBinder.cs b/IronPython/Compiler/Ast/PythonNameBinder.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/PythonNameBinder.cs rename to IronPython/Compiler/Ast/PythonNameBinder.cs diff --git a/Src/IronPython/Compiler/Ast/PythonReference.cs b/IronPython/Compiler/Ast/PythonReference.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/PythonReference.cs rename to IronPython/Compiler/Ast/PythonReference.cs diff --git a/Src/IronPython/Compiler/Ast/PythonVariable.cs b/IronPython/Compiler/Ast/PythonVariable.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/PythonVariable.cs rename to IronPython/Compiler/Ast/PythonVariable.cs diff --git a/Src/IronPython/Compiler/Ast/PythonWalker.Generated.cs b/IronPython/Compiler/Ast/PythonWalker.Generated.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/PythonWalker.Generated.cs rename to IronPython/Compiler/Ast/PythonWalker.Generated.cs diff --git a/Src/IronPython/Compiler/Ast/RaiseStatement.cs b/IronPython/Compiler/Ast/RaiseStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/RaiseStatement.cs rename to IronPython/Compiler/Ast/RaiseStatement.cs diff --git a/Src/IronPython/Compiler/Ast/RelativeModuleName.cs b/IronPython/Compiler/Ast/RelativeModuleName.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/RelativeModuleName.cs rename to IronPython/Compiler/Ast/RelativeModuleName.cs diff --git a/Src/IronPython/Compiler/Ast/ReturnStatement.cs b/IronPython/Compiler/Ast/ReturnStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ReturnStatement.cs rename to IronPython/Compiler/Ast/ReturnStatement.cs diff --git a/Src/IronPython/Compiler/Ast/ScopeStatement.cs b/IronPython/Compiler/Ast/ScopeStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ScopeStatement.cs rename to IronPython/Compiler/Ast/ScopeStatement.cs diff --git a/Src/IronPython/Compiler/Ast/SequenceExpression.cs b/IronPython/Compiler/Ast/SequenceExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/SequenceExpression.cs rename to IronPython/Compiler/Ast/SequenceExpression.cs diff --git a/Src/IronPython/Compiler/Ast/SerializedScopeStatement.cs b/IronPython/Compiler/Ast/SerializedScopeStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/SerializedScopeStatement.cs rename to IronPython/Compiler/Ast/SerializedScopeStatement.cs diff --git a/Src/IronPython/Compiler/Ast/SetExpression.cs b/IronPython/Compiler/Ast/SetExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/SetExpression.cs rename to IronPython/Compiler/Ast/SetExpression.cs diff --git a/Src/IronPython/Compiler/Ast/SliceExpression.cs b/IronPython/Compiler/Ast/SliceExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/SliceExpression.cs rename to IronPython/Compiler/Ast/SliceExpression.cs diff --git a/Src/IronPython/Compiler/Ast/StarredExpression.cs b/IronPython/Compiler/Ast/StarredExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/StarredExpression.cs rename to IronPython/Compiler/Ast/StarredExpression.cs diff --git a/Src/IronPython/Compiler/Ast/Statement.cs b/IronPython/Compiler/Ast/Statement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/Statement.cs rename to IronPython/Compiler/Ast/Statement.cs diff --git a/Src/IronPython/Compiler/Ast/SuiteStatement.cs b/IronPython/Compiler/Ast/SuiteStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/SuiteStatement.cs rename to IronPython/Compiler/Ast/SuiteStatement.cs diff --git a/Src/IronPython/Compiler/Ast/TryStatement.cs b/IronPython/Compiler/Ast/TryStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/TryStatement.cs rename to IronPython/Compiler/Ast/TryStatement.cs diff --git a/Src/IronPython/Compiler/Ast/TupleExpression.cs b/IronPython/Compiler/Ast/TupleExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/TupleExpression.cs rename to IronPython/Compiler/Ast/TupleExpression.cs diff --git a/Src/IronPython/Compiler/Ast/UnaryExpression.cs b/IronPython/Compiler/Ast/UnaryExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/UnaryExpression.cs rename to IronPython/Compiler/Ast/UnaryExpression.cs diff --git a/Src/IronPython/Compiler/Ast/VariableKind.cs b/IronPython/Compiler/Ast/VariableKind.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/VariableKind.cs rename to IronPython/Compiler/Ast/VariableKind.cs diff --git a/Src/IronPython/Compiler/Ast/WhileStatement.cs b/IronPython/Compiler/Ast/WhileStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/WhileStatement.cs rename to IronPython/Compiler/Ast/WhileStatement.cs diff --git a/Src/IronPython/Compiler/Ast/WithStatement.cs b/IronPython/Compiler/Ast/WithStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/WithStatement.cs rename to IronPython/Compiler/Ast/WithStatement.cs diff --git a/Src/IronPython/Compiler/Ast/YieldExpression.cs b/IronPython/Compiler/Ast/YieldExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/YieldExpression.cs rename to IronPython/Compiler/Ast/YieldExpression.cs diff --git a/Src/IronPython/Compiler/Ast/YieldFromExpression.cs b/IronPython/Compiler/Ast/YieldFromExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/YieldFromExpression.cs rename to IronPython/Compiler/Ast/YieldFromExpression.cs diff --git a/Src/IronPython/Compiler/ClosureExpression.cs b/IronPython/Compiler/ClosureExpression.cs similarity index 100% rename from Src/IronPython/Compiler/ClosureExpression.cs rename to IronPython/Compiler/ClosureExpression.cs diff --git a/Src/IronPython/Compiler/ClosureInfo.cs b/IronPython/Compiler/ClosureInfo.cs similarity index 100% rename from Src/IronPython/Compiler/ClosureInfo.cs rename to IronPython/Compiler/ClosureInfo.cs diff --git a/Src/IronPython/Compiler/CollectableCompilationMode.cs b/IronPython/Compiler/CollectableCompilationMode.cs similarity index 100% rename from Src/IronPython/Compiler/CollectableCompilationMode.cs rename to IronPython/Compiler/CollectableCompilationMode.cs diff --git a/Src/IronPython/Compiler/CompilationMode.cs b/IronPython/Compiler/CompilationMode.cs similarity index 100% rename from Src/IronPython/Compiler/CompilationMode.cs rename to IronPython/Compiler/CompilationMode.cs diff --git a/Src/IronPython/Compiler/GeneratorRewriter.cs b/IronPython/Compiler/GeneratorRewriter.cs similarity index 100% rename from Src/IronPython/Compiler/GeneratorRewriter.cs rename to IronPython/Compiler/GeneratorRewriter.cs diff --git a/Src/IronPython/Compiler/LazyCode.cs b/IronPython/Compiler/LazyCode.cs similarity index 100% rename from Src/IronPython/Compiler/LazyCode.cs rename to IronPython/Compiler/LazyCode.cs diff --git a/Src/IronPython/Compiler/LookupCompilationMode.cs b/IronPython/Compiler/LookupCompilationMode.cs similarity index 100% rename from Src/IronPython/Compiler/LookupCompilationMode.cs rename to IronPython/Compiler/LookupCompilationMode.cs diff --git a/Src/IronPython/Compiler/OnDiskScriptCode.cs b/IronPython/Compiler/OnDiskScriptCode.cs similarity index 100% rename from Src/IronPython/Compiler/OnDiskScriptCode.cs rename to IronPython/Compiler/OnDiskScriptCode.cs diff --git a/Src/IronPython/Compiler/Parser.cs b/IronPython/Compiler/Parser.cs similarity index 100% rename from Src/IronPython/Compiler/Parser.cs rename to IronPython/Compiler/Parser.cs diff --git a/Src/IronPython/Compiler/PythonCallTargets.cs b/IronPython/Compiler/PythonCallTargets.cs similarity index 100% rename from Src/IronPython/Compiler/PythonCallTargets.cs rename to IronPython/Compiler/PythonCallTargets.cs diff --git a/Src/IronPython/Compiler/PythonCompilerOptions.cs b/IronPython/Compiler/PythonCompilerOptions.cs similarity index 100% rename from Src/IronPython/Compiler/PythonCompilerOptions.cs rename to IronPython/Compiler/PythonCompilerOptions.cs diff --git a/Src/IronPython/Compiler/PythonDynamicExpression.cs b/IronPython/Compiler/PythonDynamicExpression.cs similarity index 100% rename from Src/IronPython/Compiler/PythonDynamicExpression.cs rename to IronPython/Compiler/PythonDynamicExpression.cs diff --git a/Src/IronPython/Compiler/PythonGlobal.cs b/IronPython/Compiler/PythonGlobal.cs similarity index 100% rename from Src/IronPython/Compiler/PythonGlobal.cs rename to IronPython/Compiler/PythonGlobal.cs diff --git a/Src/IronPython/Compiler/PythonGlobalVariableExpression.cs b/IronPython/Compiler/PythonGlobalVariableExpression.cs similarity index 100% rename from Src/IronPython/Compiler/PythonGlobalVariableExpression.cs rename to IronPython/Compiler/PythonGlobalVariableExpression.cs diff --git a/Src/IronPython/Compiler/PythonOperator.cs b/IronPython/Compiler/PythonOperator.cs similarity index 100% rename from Src/IronPython/Compiler/PythonOperator.cs rename to IronPython/Compiler/PythonOperator.cs diff --git a/Src/IronPython/Compiler/PythonSavableScriptCode.cs b/IronPython/Compiler/PythonSavableScriptCode.cs similarity index 100% rename from Src/IronPython/Compiler/PythonSavableScriptCode.cs rename to IronPython/Compiler/PythonSavableScriptCode.cs diff --git a/Src/IronPython/Compiler/PythonScriptCode.cs b/IronPython/Compiler/PythonScriptCode.cs similarity index 100% rename from Src/IronPython/Compiler/PythonScriptCode.cs rename to IronPython/Compiler/PythonScriptCode.cs diff --git a/Src/IronPython/Compiler/ReducableDynamicExpression.cs b/IronPython/Compiler/ReducableDynamicExpression.cs similarity index 100% rename from Src/IronPython/Compiler/ReducableDynamicExpression.cs rename to IronPython/Compiler/ReducableDynamicExpression.cs diff --git a/Src/IronPython/Compiler/RunnableScriptCode.cs b/IronPython/Compiler/RunnableScriptCode.cs similarity index 100% rename from Src/IronPython/Compiler/RunnableScriptCode.cs rename to IronPython/Compiler/RunnableScriptCode.cs diff --git a/Src/IronPython/Compiler/RuntimeScriptCode.cs b/IronPython/Compiler/RuntimeScriptCode.cs similarity index 100% rename from Src/IronPython/Compiler/RuntimeScriptCode.cs rename to IronPython/Compiler/RuntimeScriptCode.cs diff --git a/Src/IronPython/Compiler/ToDiskCompilationMode.cs b/IronPython/Compiler/ToDiskCompilationMode.cs similarity index 100% rename from Src/IronPython/Compiler/ToDiskCompilationMode.cs rename to IronPython/Compiler/ToDiskCompilationMode.cs diff --git a/Src/IronPython/Compiler/Token.cs b/IronPython/Compiler/Token.cs similarity index 100% rename from Src/IronPython/Compiler/Token.cs rename to IronPython/Compiler/Token.cs diff --git a/Src/IronPython/Compiler/TokenKind.Generated.cs b/IronPython/Compiler/TokenKind.Generated.cs similarity index 100% rename from Src/IronPython/Compiler/TokenKind.Generated.cs rename to IronPython/Compiler/TokenKind.Generated.cs diff --git a/Src/IronPython/Compiler/Tokenizer.Generated.cs b/IronPython/Compiler/Tokenizer.Generated.cs similarity index 100% rename from Src/IronPython/Compiler/Tokenizer.Generated.cs rename to IronPython/Compiler/Tokenizer.Generated.cs diff --git a/Src/IronPython/Compiler/Tokenizer.cs b/IronPython/Compiler/Tokenizer.cs similarity index 100% rename from Src/IronPython/Compiler/Tokenizer.cs rename to IronPython/Compiler/Tokenizer.cs diff --git a/Src/IronPython/Compiler/UncollectableCompilationMode.Generated.cs b/IronPython/Compiler/UncollectableCompilationMode.Generated.cs similarity index 100% rename from Src/IronPython/Compiler/UncollectableCompilationMode.Generated.cs rename to IronPython/Compiler/UncollectableCompilationMode.Generated.cs diff --git a/Src/IronPython/Compiler/UncollectableCompilationMode.cs b/IronPython/Compiler/UncollectableCompilationMode.cs similarity index 100% rename from Src/IronPython/Compiler/UncollectableCompilationMode.cs rename to IronPython/Compiler/UncollectableCompilationMode.cs diff --git a/Src/IronPython/FakeInteropServices.cs b/IronPython/FakeInteropServices.cs similarity index 100% rename from Src/IronPython/FakeInteropServices.cs rename to IronPython/FakeInteropServices.cs diff --git a/Src/IronPython/Hosting/Python.cs b/IronPython/Hosting/Python.cs similarity index 100% rename from Src/IronPython/Hosting/Python.cs rename to IronPython/Hosting/Python.cs diff --git a/Src/IronPython/Hosting/PythonCodeDomCodeGen.cs b/IronPython/Hosting/PythonCodeDomCodeGen.cs similarity index 100% rename from Src/IronPython/Hosting/PythonCodeDomCodeGen.cs rename to IronPython/Hosting/PythonCodeDomCodeGen.cs diff --git a/Src/IronPython/Hosting/PythonCommandLine.cs b/IronPython/Hosting/PythonCommandLine.cs similarity index 100% rename from Src/IronPython/Hosting/PythonCommandLine.cs rename to IronPython/Hosting/PythonCommandLine.cs diff --git a/Src/IronPython/Hosting/PythonConsoleOptions.cs b/IronPython/Hosting/PythonConsoleOptions.cs similarity index 100% rename from Src/IronPython/Hosting/PythonConsoleOptions.cs rename to IronPython/Hosting/PythonConsoleOptions.cs diff --git a/Src/IronPython/Hosting/PythonOptionsParser.cs b/IronPython/Hosting/PythonOptionsParser.cs similarity index 100% rename from Src/IronPython/Hosting/PythonOptionsParser.cs rename to IronPython/Hosting/PythonOptionsParser.cs diff --git a/Src/IronPython/Hosting/PythonService.cs b/IronPython/Hosting/PythonService.cs similarity index 100% rename from Src/IronPython/Hosting/PythonService.cs rename to IronPython/Hosting/PythonService.cs diff --git a/Src/IronPython/Interop/Windows/Interop.Libraries.cs b/IronPython/Interop/Windows/Interop.Libraries.cs similarity index 100% rename from Src/IronPython/Interop/Windows/Interop.Libraries.cs rename to IronPython/Interop/Windows/Interop.Libraries.cs diff --git a/Src/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs b/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs similarity index 100% rename from Src/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs rename to IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs diff --git a/Src/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs b/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs similarity index 100% rename from Src/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs rename to IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs diff --git a/Src/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs b/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs similarity index 100% rename from Src/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs rename to IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs diff --git a/Src/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs b/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs similarity index 100% rename from Src/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs rename to IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs diff --git a/Src/IronPython/IronPython.csproj b/IronPython/IronPython.csproj similarity index 94% rename from Src/IronPython/IronPython.csproj rename to IronPython/IronPython.csproj index 4af3f1695..68483bd1e 100644 --- a/Src/IronPython/IronPython.csproj +++ b/IronPython/IronPython.csproj @@ -23,7 +23,7 @@ True - ..\..\Utils\References\Mono.Posix.dll + ..\Utils\References\Mono.Posix.dll @@ -58,7 +58,7 @@ - + false Analyzer diff --git a/Src/IronPython/Lib/iptest/__init__.py b/IronPython/Lib/iptest/__init__.py similarity index 100% rename from Src/IronPython/Lib/iptest/__init__.py rename to IronPython/Lib/iptest/__init__.py diff --git a/Src/IronPython/Lib/iptest/cominterop_util.py b/IronPython/Lib/iptest/cominterop_util.py similarity index 100% rename from Src/IronPython/Lib/iptest/cominterop_util.py rename to IronPython/Lib/iptest/cominterop_util.py diff --git a/Src/IronPython/Lib/iptest/console_util.py b/IronPython/Lib/iptest/console_util.py similarity index 100% rename from Src/IronPython/Lib/iptest/console_util.py rename to IronPython/Lib/iptest/console_util.py diff --git a/Src/IronPython/Lib/iptest/file_util.py b/IronPython/Lib/iptest/file_util.py similarity index 100% rename from Src/IronPython/Lib/iptest/file_util.py rename to IronPython/Lib/iptest/file_util.py diff --git a/Src/IronPython/Lib/iptest/ipunittest.py b/IronPython/Lib/iptest/ipunittest.py similarity index 100% rename from Src/IronPython/Lib/iptest/ipunittest.py rename to IronPython/Lib/iptest/ipunittest.py diff --git a/Src/IronPython/Lib/iptest/misc_util.py b/IronPython/Lib/iptest/misc_util.py similarity index 100% rename from Src/IronPython/Lib/iptest/misc_util.py rename to IronPython/Lib/iptest/misc_util.py diff --git a/Src/IronPython/Lib/iptest/process_util.py b/IronPython/Lib/iptest/process_util.py similarity index 100% rename from Src/IronPython/Lib/iptest/process_util.py rename to IronPython/Lib/iptest/process_util.py diff --git a/Src/IronPython/Lib/iptest/runner.py b/IronPython/Lib/iptest/runner.py similarity index 100% rename from Src/IronPython/Lib/iptest/runner.py rename to IronPython/Lib/iptest/runner.py diff --git a/Src/IronPython/Lib/iptest/test_env.py b/IronPython/Lib/iptest/test_env.py similarity index 100% rename from Src/IronPython/Lib/iptest/test_env.py rename to IronPython/Lib/iptest/test_env.py diff --git a/Src/IronPython/Lib/iptest/type_util.py b/IronPython/Lib/iptest/type_util.py similarity index 100% rename from Src/IronPython/Lib/iptest/type_util.py rename to IronPython/Lib/iptest/type_util.py diff --git a/Src/IronPython/Modules/Builtin.Generated.cs b/IronPython/Modules/Builtin.Generated.cs similarity index 100% rename from Src/IronPython/Modules/Builtin.Generated.cs rename to IronPython/Modules/Builtin.Generated.cs diff --git a/Src/IronPython/Modules/Builtin.cs b/IronPython/Modules/Builtin.cs similarity index 100% rename from Src/IronPython/Modules/Builtin.cs rename to IronPython/Modules/Builtin.cs diff --git a/Src/IronPython/Modules/_ast.cs b/IronPython/Modules/_ast.cs old mode 100755 new mode 100644 similarity index 100% rename from Src/IronPython/Modules/_ast.cs rename to IronPython/Modules/_ast.cs diff --git a/Src/IronPython/Modules/_fileio.cs b/IronPython/Modules/_fileio.cs similarity index 100% rename from Src/IronPython/Modules/_fileio.cs rename to IronPython/Modules/_fileio.cs diff --git a/Src/IronPython/Modules/_imp.cs b/IronPython/Modules/_imp.cs similarity index 100% rename from Src/IronPython/Modules/_imp.cs rename to IronPython/Modules/_imp.cs diff --git a/Src/IronPython/Modules/_io.cs b/IronPython/Modules/_io.cs similarity index 100% rename from Src/IronPython/Modules/_io.cs rename to IronPython/Modules/_io.cs diff --git a/Src/IronPython/Modules/_io/BytesIO.cs b/IronPython/Modules/_io/BytesIO.cs similarity index 100% rename from Src/IronPython/Modules/_io/BytesIO.cs rename to IronPython/Modules/_io/BytesIO.cs diff --git a/Src/IronPython/Modules/_io/StringIO.cs b/IronPython/Modules/_io/StringIO.cs similarity index 100% rename from Src/IronPython/Modules/_io/StringIO.cs rename to IronPython/Modules/_io/StringIO.cs diff --git a/Src/IronPython/Modules/_locale.cs b/IronPython/Modules/_locale.cs similarity index 100% rename from Src/IronPython/Modules/_locale.cs rename to IronPython/Modules/_locale.cs diff --git a/Src/IronPython/Modules/sys.cs b/IronPython/Modules/sys.cs similarity index 100% rename from Src/IronPython/Modules/sys.cs rename to IronPython/Modules/sys.cs diff --git a/Src/IronPython/Modules/unicodedata.cs b/IronPython/Modules/unicodedata.cs similarity index 100% rename from Src/IronPython/Modules/unicodedata.cs rename to IronPython/Modules/unicodedata.cs diff --git a/Src/IronPython/Modules/unicodedata/CaseFolding.txt b/IronPython/Modules/unicodedata/CaseFolding.txt similarity index 100% rename from Src/IronPython/Modules/unicodedata/CaseFolding.txt rename to IronPython/Modules/unicodedata/CaseFolding.txt diff --git a/Src/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt b/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt similarity index 100% rename from Src/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt rename to IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt diff --git a/Src/IronPython/Modules/unicodedata/EastAsianWidth.txt b/IronPython/Modules/unicodedata/EastAsianWidth.txt similarity index 100% rename from Src/IronPython/Modules/unicodedata/EastAsianWidth.txt rename to IronPython/Modules/unicodedata/EastAsianWidth.txt diff --git a/Src/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz b/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz similarity index 100% rename from Src/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz rename to IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz diff --git a/Src/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz b/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz similarity index 100% rename from Src/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz rename to IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz diff --git a/Src/IronPython/Modules/unicodedata/NameAliases.txt b/IronPython/Modules/unicodedata/NameAliases.txt similarity index 100% rename from Src/IronPython/Modules/unicodedata/NameAliases.txt rename to IronPython/Modules/unicodedata/NameAliases.txt diff --git a/Src/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt b/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt similarity index 100% rename from Src/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt rename to IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt diff --git a/Src/IronPython/Modules/unicodedata/UnicodeData.txt b/IronPython/Modules/unicodedata/UnicodeData.txt similarity index 100% rename from Src/IronPython/Modules/unicodedata/UnicodeData.txt rename to IronPython/Modules/unicodedata/UnicodeData.txt diff --git a/Src/IronPython/Modules/unicodedata/genunicodedata.py b/IronPython/Modules/unicodedata/genunicodedata.py similarity index 100% rename from Src/IronPython/Modules/unicodedata/genunicodedata.py rename to IronPython/Modules/unicodedata/genunicodedata.py diff --git a/Src/IronPython/Modules/unicodedata/license.txt b/IronPython/Modules/unicodedata/license.txt similarity index 100% rename from Src/IronPython/Modules/unicodedata/license.txt rename to IronPython/Modules/unicodedata/license.txt diff --git a/Src/IronPython/Properties/AssemblyInfo.cs b/IronPython/Properties/AssemblyInfo.cs similarity index 100% rename from Src/IronPython/Properties/AssemblyInfo.cs rename to IronPython/Properties/AssemblyInfo.cs diff --git a/Src/README.md b/IronPython/README.md similarity index 100% rename from Src/README.md rename to IronPython/README.md diff --git a/Src/IronPython/Resources.Designer.cs b/IronPython/Resources.Designer.cs similarity index 100% rename from Src/IronPython/Resources.Designer.cs rename to IronPython/Resources.Designer.cs diff --git a/Src/IronPython/Resources.resx b/IronPython/Resources.resx similarity index 100% rename from Src/IronPython/Resources.resx rename to IronPython/Resources.resx diff --git a/Src/IronPython/Runtime/ArrayData.cs b/IronPython/Runtime/ArrayData.cs similarity index 100% rename from Src/IronPython/Runtime/ArrayData.cs rename to IronPython/Runtime/ArrayData.cs diff --git a/Src/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs b/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs rename to IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs diff --git a/Src/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs b/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs rename to IronPython/Runtime/Binding/BinaryRetTypeBinder.cs diff --git a/Src/IronPython/Runtime/Binding/Binders.cs b/IronPython/Runtime/Binding/Binders.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/Binders.cs rename to IronPython/Runtime/Binding/Binders.cs diff --git a/Src/IronPython/Runtime/Binding/BindingHelpers.cs b/IronPython/Runtime/Binding/BindingHelpers.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/BindingHelpers.cs rename to IronPython/Runtime/Binding/BindingHelpers.cs diff --git a/Src/IronPython/Runtime/Binding/BindingWarnings.cs b/IronPython/Runtime/Binding/BindingWarnings.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/BindingWarnings.cs rename to IronPython/Runtime/Binding/BindingWarnings.cs diff --git a/Src/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs b/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs rename to IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs diff --git a/Src/IronPython/Runtime/Binding/ConditionalBuilder.cs b/IronPython/Runtime/Binding/ConditionalBuilder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/ConditionalBuilder.cs rename to IronPython/Runtime/Binding/ConditionalBuilder.cs diff --git a/Src/IronPython/Runtime/Binding/ContextArgBuilder.cs b/IronPython/Runtime/Binding/ContextArgBuilder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/ContextArgBuilder.cs rename to IronPython/Runtime/Binding/ContextArgBuilder.cs diff --git a/Src/IronPython/Runtime/Binding/ConversionBinder.cs b/IronPython/Runtime/Binding/ConversionBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/ConversionBinder.cs rename to IronPython/Runtime/Binding/ConversionBinder.cs diff --git a/Src/IronPython/Runtime/Binding/CreateFallbackBinder.cs b/IronPython/Runtime/Binding/CreateFallbackBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/CreateFallbackBinder.cs rename to IronPython/Runtime/Binding/CreateFallbackBinder.cs diff --git a/Src/IronPython/Runtime/Binding/FastBindResult.cs b/IronPython/Runtime/Binding/FastBindResult.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/FastBindResult.cs rename to IronPython/Runtime/Binding/FastBindResult.cs diff --git a/Src/IronPython/Runtime/Binding/FastGetBase.cs b/IronPython/Runtime/Binding/FastGetBase.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/FastGetBase.cs rename to IronPython/Runtime/Binding/FastGetBase.cs diff --git a/Src/IronPython/Runtime/Binding/FastSetBase.cs b/IronPython/Runtime/Binding/FastSetBase.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/FastSetBase.cs rename to IronPython/Runtime/Binding/FastSetBase.cs diff --git a/Src/IronPython/Runtime/Binding/IComConvertible.cs b/IronPython/Runtime/Binding/IComConvertible.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/IComConvertible.cs rename to IronPython/Runtime/Binding/IComConvertible.cs diff --git a/Src/IronPython/Runtime/Binding/IFastGettable.cs b/IronPython/Runtime/Binding/IFastGettable.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/IFastGettable.cs rename to IronPython/Runtime/Binding/IFastGettable.cs diff --git a/Src/IronPython/Runtime/Binding/IFastInvokable.cs b/IronPython/Runtime/Binding/IFastInvokable.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/IFastInvokable.cs rename to IronPython/Runtime/Binding/IFastInvokable.cs diff --git a/Src/IronPython/Runtime/Binding/IFastSettable.cs b/IronPython/Runtime/Binding/IFastSettable.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/IFastSettable.cs rename to IronPython/Runtime/Binding/IFastSettable.cs diff --git a/Src/IronPython/Runtime/Binding/IPythonConvertible.cs b/IronPython/Runtime/Binding/IPythonConvertible.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/IPythonConvertible.cs rename to IronPython/Runtime/Binding/IPythonConvertible.cs diff --git a/Src/IronPython/Runtime/Binding/IPythonExpandable.cs b/IronPython/Runtime/Binding/IPythonExpandable.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/IPythonExpandable.cs rename to IronPython/Runtime/Binding/IPythonExpandable.cs diff --git a/Src/IronPython/Runtime/Binding/IPythonGetable.cs b/IronPython/Runtime/Binding/IPythonGetable.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/IPythonGetable.cs rename to IronPython/Runtime/Binding/IPythonGetable.cs diff --git a/Src/IronPython/Runtime/Binding/IPythonInvokable.cs b/IronPython/Runtime/Binding/IPythonInvokable.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/IPythonInvokable.cs rename to IronPython/Runtime/Binding/IPythonInvokable.cs diff --git a/Src/IronPython/Runtime/Binding/IPythonOperable.cs b/IronPython/Runtime/Binding/IPythonOperable.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/IPythonOperable.cs rename to IronPython/Runtime/Binding/IPythonOperable.cs diff --git a/Src/IronPython/Runtime/Binding/IPythonSite.cs b/IronPython/Runtime/Binding/IPythonSite.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/IPythonSite.cs rename to IronPython/Runtime/Binding/IPythonSite.cs diff --git a/Src/IronPython/Runtime/Binding/MetaBuiltinFunction.cs b/IronPython/Runtime/Binding/MetaBuiltinFunction.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/MetaBuiltinFunction.cs rename to IronPython/Runtime/Binding/MetaBuiltinFunction.cs diff --git a/Src/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs b/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs rename to IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs diff --git a/Src/IronPython/Runtime/Binding/MetaMethod.cs b/IronPython/Runtime/Binding/MetaMethod.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/MetaMethod.cs rename to IronPython/Runtime/Binding/MetaMethod.cs diff --git a/Src/IronPython/Runtime/Binding/MetaPythonFunction.cs b/IronPython/Runtime/Binding/MetaPythonFunction.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/MetaPythonFunction.cs rename to IronPython/Runtime/Binding/MetaPythonFunction.cs diff --git a/Src/IronPython/Runtime/Binding/MetaPythonObject.cs b/IronPython/Runtime/Binding/MetaPythonObject.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/MetaPythonObject.cs rename to IronPython/Runtime/Binding/MetaPythonObject.cs diff --git a/Src/IronPython/Runtime/Binding/MetaPythonType.Calls.cs b/IronPython/Runtime/Binding/MetaPythonType.Calls.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/MetaPythonType.Calls.cs rename to IronPython/Runtime/Binding/MetaPythonType.Calls.cs diff --git a/Src/IronPython/Runtime/Binding/MetaPythonType.Members.cs b/IronPython/Runtime/Binding/MetaPythonType.Members.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/MetaPythonType.Members.cs rename to IronPython/Runtime/Binding/MetaPythonType.Members.cs diff --git a/Src/IronPython/Runtime/Binding/MetaPythonType.cs b/IronPython/Runtime/Binding/MetaPythonType.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/MetaPythonType.cs rename to IronPython/Runtime/Binding/MetaPythonType.cs diff --git a/Src/IronPython/Runtime/Binding/MetaUserObject.Members.cs b/IronPython/Runtime/Binding/MetaUserObject.Members.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/MetaUserObject.Members.cs rename to IronPython/Runtime/Binding/MetaUserObject.Members.cs diff --git a/Src/IronPython/Runtime/Binding/MetaUserObject.cs b/IronPython/Runtime/Binding/MetaUserObject.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/MetaUserObject.cs rename to IronPython/Runtime/Binding/MetaUserObject.cs diff --git a/Src/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs b/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs rename to IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonBinder.Create.cs b/IronPython/Runtime/Binding/PythonBinder.Create.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonBinder.Create.cs rename to IronPython/Runtime/Binding/PythonBinder.Create.cs diff --git a/Src/IronPython/Runtime/Binding/PythonBinder.cs b/IronPython/Runtime/Binding/PythonBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonBinder.cs rename to IronPython/Runtime/Binding/PythonBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs b/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs rename to IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs b/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs rename to IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs b/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs rename to IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs b/IronPython/Runtime/Binding/PythonExtensionBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs rename to IronPython/Runtime/Binding/PythonExtensionBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonGetIndexBinder.cs b/IronPython/Runtime/Binding/PythonGetIndexBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonGetIndexBinder.cs rename to IronPython/Runtime/Binding/PythonGetIndexBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonGetMemberBinder.cs b/IronPython/Runtime/Binding/PythonGetMemberBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonGetMemberBinder.cs rename to IronPython/Runtime/Binding/PythonGetMemberBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonGetSliceBinder.cs b/IronPython/Runtime/Binding/PythonGetSliceBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonGetSliceBinder.cs rename to IronPython/Runtime/Binding/PythonGetSliceBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonIndexType.cs b/IronPython/Runtime/Binding/PythonIndexType.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonIndexType.cs rename to IronPython/Runtime/Binding/PythonIndexType.cs diff --git a/Src/IronPython/Runtime/Binding/PythonInvokeBinder.cs b/IronPython/Runtime/Binding/PythonInvokeBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonInvokeBinder.cs rename to IronPython/Runtime/Binding/PythonInvokeBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonOperationBinder.cs b/IronPython/Runtime/Binding/PythonOperationBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonOperationBinder.cs rename to IronPython/Runtime/Binding/PythonOperationBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonOperationKind.cs b/IronPython/Runtime/Binding/PythonOperationKind.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonOperationKind.cs rename to IronPython/Runtime/Binding/PythonOperationKind.cs diff --git a/Src/IronPython/Runtime/Binding/PythonOverloadResolver.cs b/IronPython/Runtime/Binding/PythonOverloadResolver.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonOverloadResolver.cs rename to IronPython/Runtime/Binding/PythonOverloadResolver.cs diff --git a/Src/IronPython/Runtime/Binding/PythonProtocol.Operations.cs b/IronPython/Runtime/Binding/PythonProtocol.Operations.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonProtocol.Operations.cs rename to IronPython/Runtime/Binding/PythonProtocol.Operations.cs diff --git a/Src/IronPython/Runtime/Binding/PythonProtocol.cs b/IronPython/Runtime/Binding/PythonProtocol.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonProtocol.cs rename to IronPython/Runtime/Binding/PythonProtocol.cs diff --git a/Src/IronPython/Runtime/Binding/PythonSetIndexBinder.cs b/IronPython/Runtime/Binding/PythonSetIndexBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonSetIndexBinder.cs rename to IronPython/Runtime/Binding/PythonSetIndexBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonSetMemberBinder.cs b/IronPython/Runtime/Binding/PythonSetMemberBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonSetMemberBinder.cs rename to IronPython/Runtime/Binding/PythonSetMemberBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonSetSliceBinder.cs b/IronPython/Runtime/Binding/PythonSetSliceBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonSetSliceBinder.cs rename to IronPython/Runtime/Binding/PythonSetSliceBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs b/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs rename to IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs diff --git a/Src/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs b/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs rename to IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs diff --git a/Src/IronPython/Runtime/Binding/SlotOrFunction.cs b/IronPython/Runtime/Binding/SlotOrFunction.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/SlotOrFunction.cs rename to IronPython/Runtime/Binding/SlotOrFunction.cs diff --git a/Src/IronPython/Runtime/Binding/WarningInfo.cs b/IronPython/Runtime/Binding/WarningInfo.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/WarningInfo.cs rename to IronPython/Runtime/Binding/WarningInfo.cs diff --git a/Src/IronPython/Runtime/BufferProtocol.cs b/IronPython/Runtime/BufferProtocol.cs similarity index 100% rename from Src/IronPython/Runtime/BufferProtocol.cs rename to IronPython/Runtime/BufferProtocol.cs diff --git a/Src/IronPython/Runtime/BuiltinPythonModule.cs b/IronPython/Runtime/BuiltinPythonModule.cs similarity index 100% rename from Src/IronPython/Runtime/BuiltinPythonModule.cs rename to IronPython/Runtime/BuiltinPythonModule.cs diff --git a/Src/IronPython/Runtime/BuiltinsDictionaryStorage.cs b/IronPython/Runtime/BuiltinsDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/BuiltinsDictionaryStorage.cs rename to IronPython/Runtime/BuiltinsDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/ByteArray.cs b/IronPython/Runtime/ByteArray.cs similarity index 100% rename from Src/IronPython/Runtime/ByteArray.cs rename to IronPython/Runtime/ByteArray.cs diff --git a/Src/IronPython/Runtime/ByteArrayIterator.cs b/IronPython/Runtime/ByteArrayIterator.cs similarity index 100% rename from Src/IronPython/Runtime/ByteArrayIterator.cs rename to IronPython/Runtime/ByteArrayIterator.cs diff --git a/Src/IronPython/Runtime/Bytes.cs b/IronPython/Runtime/Bytes.cs similarity index 100% rename from Src/IronPython/Runtime/Bytes.cs rename to IronPython/Runtime/Bytes.cs diff --git a/Src/IronPython/Runtime/BytesIterator.cs b/IronPython/Runtime/BytesIterator.cs similarity index 100% rename from Src/IronPython/Runtime/BytesIterator.cs rename to IronPython/Runtime/BytesIterator.cs diff --git a/Src/IronPython/Runtime/BytesLikeAttribute.cs b/IronPython/Runtime/BytesLikeAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/BytesLikeAttribute.cs rename to IronPython/Runtime/BytesLikeAttribute.cs diff --git a/Src/IronPython/Runtime/ClassMethodAttribute.cs b/IronPython/Runtime/ClassMethodAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/ClassMethodAttribute.cs rename to IronPython/Runtime/ClassMethodAttribute.cs diff --git a/Src/IronPython/Runtime/ClassMethodDescriptor.cs b/IronPython/Runtime/ClassMethodDescriptor.cs similarity index 100% rename from Src/IronPython/Runtime/ClassMethodDescriptor.cs rename to IronPython/Runtime/ClassMethodDescriptor.cs diff --git a/Src/IronPython/Runtime/ClrModule.cs b/IronPython/Runtime/ClrModule.cs similarity index 100% rename from Src/IronPython/Runtime/ClrModule.cs rename to IronPython/Runtime/ClrModule.cs diff --git a/Src/IronPython/Runtime/CodeContext.cs b/IronPython/Runtime/CodeContext.cs similarity index 100% rename from Src/IronPython/Runtime/CodeContext.cs rename to IronPython/Runtime/CodeContext.cs diff --git a/Src/IronPython/Runtime/CollectionDebugView.cs b/IronPython/Runtime/CollectionDebugView.cs similarity index 100% rename from Src/IronPython/Runtime/CollectionDebugView.cs rename to IronPython/Runtime/CollectionDebugView.cs diff --git a/Src/IronPython/Runtime/CommonDictionaryStorage.cs b/IronPython/Runtime/CommonDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/CommonDictionaryStorage.cs rename to IronPython/Runtime/CommonDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/CompareUtil.cs b/IronPython/Runtime/CompareUtil.cs similarity index 100% rename from Src/IronPython/Runtime/CompareUtil.cs rename to IronPython/Runtime/CompareUtil.cs diff --git a/Src/IronPython/Runtime/CompileFlags.cs b/IronPython/Runtime/CompileFlags.cs similarity index 100% rename from Src/IronPython/Runtime/CompileFlags.cs rename to IronPython/Runtime/CompileFlags.cs diff --git a/Src/IronPython/Runtime/CompiledLoader.cs b/IronPython/Runtime/CompiledLoader.cs similarity index 100% rename from Src/IronPython/Runtime/CompiledLoader.cs rename to IronPython/Runtime/CompiledLoader.cs diff --git a/Src/IronPython/Runtime/ConstantDictionaryStorage.cs b/IronPython/Runtime/ConstantDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/ConstantDictionaryStorage.cs rename to IronPython/Runtime/ConstantDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/ConversionWrappers.cs b/IronPython/Runtime/ConversionWrappers.cs similarity index 100% rename from Src/IronPython/Runtime/ConversionWrappers.cs rename to IronPython/Runtime/ConversionWrappers.cs diff --git a/Src/IronPython/Runtime/Converter.cs b/IronPython/Runtime/Converter.cs similarity index 100% rename from Src/IronPython/Runtime/Converter.cs rename to IronPython/Runtime/Converter.cs diff --git a/Src/IronPython/Runtime/CustomDictionaryStorage.cs b/IronPython/Runtime/CustomDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/CustomDictionaryStorage.cs rename to IronPython/Runtime/CustomDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/DebuggerDictionaryStorage.cs b/IronPython/Runtime/DebuggerDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/DebuggerDictionaryStorage.cs rename to IronPython/Runtime/DebuggerDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/DefaultContext.cs b/IronPython/Runtime/DefaultContext.cs similarity index 100% rename from Src/IronPython/Runtime/DefaultContext.cs rename to IronPython/Runtime/DefaultContext.cs diff --git a/Src/IronPython/Runtime/Descriptors.cs b/IronPython/Runtime/Descriptors.cs similarity index 100% rename from Src/IronPython/Runtime/Descriptors.cs rename to IronPython/Runtime/Descriptors.cs diff --git a/Src/IronPython/Runtime/DictionaryOps.cs b/IronPython/Runtime/DictionaryOps.cs similarity index 100% rename from Src/IronPython/Runtime/DictionaryOps.cs rename to IronPython/Runtime/DictionaryOps.cs diff --git a/Src/IronPython/Runtime/DictionaryStorage.cs b/IronPython/Runtime/DictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/DictionaryStorage.cs rename to IronPython/Runtime/DictionaryStorage.cs diff --git a/Src/IronPython/Runtime/DictionaryTypeInfoAttribute.cs b/IronPython/Runtime/DictionaryTypeInfoAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/DictionaryTypeInfoAttribute.cs rename to IronPython/Runtime/DictionaryTypeInfoAttribute.cs diff --git a/Src/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs b/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs rename to IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs diff --git a/Src/IronPython/Runtime/DontMapICollectionToLenAttribute.cs b/IronPython/Runtime/DontMapICollectionToLenAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/DontMapICollectionToLenAttribute.cs rename to IronPython/Runtime/DontMapICollectionToLenAttribute.cs diff --git a/Src/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs b/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs rename to IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs diff --git a/Src/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs b/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs rename to IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs diff --git a/Src/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs b/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs rename to IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs diff --git a/Src/IronPython/Runtime/EmptyDictionaryStorage.cs b/IronPython/Runtime/EmptyDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/EmptyDictionaryStorage.cs rename to IronPython/Runtime/EmptyDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/Enumerate.cs b/IronPython/Runtime/Enumerate.cs similarity index 100% rename from Src/IronPython/Runtime/Enumerate.cs rename to IronPython/Runtime/Enumerate.cs diff --git a/Src/IronPython/Runtime/ErrorCodes.cs b/IronPython/Runtime/ErrorCodes.cs similarity index 100% rename from Src/IronPython/Runtime/ErrorCodes.cs rename to IronPython/Runtime/ErrorCodes.cs diff --git a/Src/IronPython/Runtime/Exceptions/AssertionException.Generated.cs b/IronPython/Runtime/Exceptions/AssertionException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/AssertionException.Generated.cs rename to IronPython/Runtime/Exceptions/AssertionException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/AttributeErrorException.cs b/IronPython/Runtime/Exceptions/AttributeErrorException.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/AttributeErrorException.cs rename to IronPython/Runtime/Exceptions/AttributeErrorException.cs diff --git a/Src/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs b/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs rename to IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs b/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs rename to IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/BufferException.Generated.cs b/IronPython/Runtime/Exceptions/BufferException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/BufferException.Generated.cs rename to IronPython/Runtime/Exceptions/BufferException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs b/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs rename to IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs b/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs rename to IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs b/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs rename to IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs b/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs rename to IronPython/Runtime/Exceptions/ConnectionException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs b/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs rename to IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs b/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs rename to IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs b/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs rename to IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs b/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs rename to IronPython/Runtime/Exceptions/FileExistsException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs b/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs rename to IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs b/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs rename to IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/GeneratorExitException.cs b/IronPython/Runtime/Exceptions/GeneratorExitException.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/GeneratorExitException.cs rename to IronPython/Runtime/Exceptions/GeneratorExitException.cs diff --git a/Src/IronPython/Runtime/Exceptions/ImportException.Generated.cs b/IronPython/Runtime/Exceptions/ImportException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ImportException.Generated.cs rename to IronPython/Runtime/Exceptions/ImportException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs b/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs rename to IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/IndentationException.cs b/IronPython/Runtime/Exceptions/IndentationException.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/IndentationException.cs rename to IronPython/Runtime/Exceptions/IndentationException.cs diff --git a/Src/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs b/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs rename to IronPython/Runtime/Exceptions/InterruptedException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs b/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs rename to IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/LookupException.Generated.cs b/IronPython/Runtime/Exceptions/LookupException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/LookupException.Generated.cs rename to IronPython/Runtime/Exceptions/LookupException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs b/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs rename to IronPython/Runtime/Exceptions/ModuleNotFoundException.cs diff --git a/Src/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs b/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs rename to IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/OSException.Generated.cs b/IronPython/Runtime/Exceptions/OSException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/OSException.Generated.cs rename to IronPython/Runtime/Exceptions/OSException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs b/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs rename to IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs b/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs rename to IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/PythonException.cs b/IronPython/Runtime/Exceptions/PythonException.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/PythonException.cs rename to IronPython/Runtime/Exceptions/PythonException.cs diff --git a/Src/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs b/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs rename to IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs diff --git a/Src/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs b/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs rename to IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/PythonExceptions.cs b/IronPython/Runtime/Exceptions/PythonExceptions.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/PythonExceptions.cs rename to IronPython/Runtime/Exceptions/PythonExceptions.cs diff --git a/Src/IronPython/Runtime/Exceptions/RecursionException.Generated.cs b/IronPython/Runtime/Exceptions/RecursionException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/RecursionException.Generated.cs rename to IronPython/Runtime/Exceptions/RecursionException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs b/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs rename to IronPython/Runtime/Exceptions/ReferenceException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs b/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs rename to IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs b/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs rename to IronPython/Runtime/Exceptions/RuntimeException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs b/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs rename to IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs b/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs rename to IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs b/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs rename to IronPython/Runtime/Exceptions/StopIterationException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs b/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs rename to IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/SystemExitException.cs b/IronPython/Runtime/Exceptions/SystemExitException.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/SystemExitException.cs rename to IronPython/Runtime/Exceptions/SystemExitException.cs diff --git a/Src/IronPython/Runtime/Exceptions/TabException.cs b/IronPython/Runtime/Exceptions/TabException.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/TabException.cs rename to IronPython/Runtime/Exceptions/TabException.cs diff --git a/Src/IronPython/Runtime/Exceptions/TraceBack.cs b/IronPython/Runtime/Exceptions/TraceBack.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/TraceBack.cs rename to IronPython/Runtime/Exceptions/TraceBack.cs diff --git a/Src/IronPython/Runtime/Exceptions/TypeErrorException.cs b/IronPython/Runtime/Exceptions/TypeErrorException.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/TypeErrorException.cs rename to IronPython/Runtime/Exceptions/TypeErrorException.cs diff --git a/Src/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs b/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs rename to IronPython/Runtime/Exceptions/UnicodeException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs b/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs rename to IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs b/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs rename to IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs b/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs rename to IronPython/Runtime/Exceptions/UserWarningException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ValueErrorException.cs b/IronPython/Runtime/Exceptions/ValueErrorException.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ValueErrorException.cs rename to IronPython/Runtime/Exceptions/ValueErrorException.cs diff --git a/Src/IronPython/Runtime/ExtensionMethodSet.cs b/IronPython/Runtime/ExtensionMethodSet.cs similarity index 100% rename from Src/IronPython/Runtime/ExtensionMethodSet.cs rename to IronPython/Runtime/ExtensionMethodSet.cs diff --git a/Src/IronPython/Runtime/Filter.cs b/IronPython/Runtime/Filter.cs similarity index 100% rename from Src/IronPython/Runtime/Filter.cs rename to IronPython/Runtime/Filter.cs diff --git a/Src/IronPython/Runtime/FormattingHelper.cs b/IronPython/Runtime/FormattingHelper.cs similarity index 100% rename from Src/IronPython/Runtime/FormattingHelper.cs rename to IronPython/Runtime/FormattingHelper.cs diff --git a/Src/IronPython/Runtime/FunctionAttributes.cs b/IronPython/Runtime/FunctionAttributes.cs similarity index 100% rename from Src/IronPython/Runtime/FunctionAttributes.cs rename to IronPython/Runtime/FunctionAttributes.cs diff --git a/Src/IronPython/Runtime/FunctionCode.cs b/IronPython/Runtime/FunctionCode.cs similarity index 100% rename from Src/IronPython/Runtime/FunctionCode.cs rename to IronPython/Runtime/FunctionCode.cs diff --git a/Src/IronPython/Runtime/Generator.cs b/IronPython/Runtime/Generator.cs similarity index 100% rename from Src/IronPython/Runtime/Generator.cs rename to IronPython/Runtime/Generator.cs diff --git a/Src/IronPython/Runtime/GlobalDictionaryStorage.cs b/IronPython/Runtime/GlobalDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/GlobalDictionaryStorage.cs rename to IronPython/Runtime/GlobalDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/IParameterSequence.cs b/IronPython/Runtime/IParameterSequence.cs similarity index 100% rename from Src/IronPython/Runtime/IParameterSequence.cs rename to IronPython/Runtime/IParameterSequence.cs diff --git a/Src/IronPython/Runtime/Implementation.cs b/IronPython/Runtime/Implementation.cs similarity index 100% rename from Src/IronPython/Runtime/Implementation.cs rename to IronPython/Runtime/Implementation.cs diff --git a/Src/IronPython/Runtime/Importer.cs b/IronPython/Runtime/Importer.cs similarity index 100% rename from Src/IronPython/Runtime/Importer.cs rename to IronPython/Runtime/Importer.cs diff --git a/Src/IronPython/Runtime/Index.cs b/IronPython/Runtime/Index.cs similarity index 100% rename from Src/IronPython/Runtime/Index.cs rename to IronPython/Runtime/Index.cs diff --git a/Src/IronPython/Runtime/InstancedModuleDictionaryStorage.cs b/IronPython/Runtime/InstancedModuleDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/InstancedModuleDictionaryStorage.cs rename to IronPython/Runtime/InstancedModuleDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/Interfaces.cs b/IronPython/Runtime/Interfaces.cs similarity index 100% rename from Src/IronPython/Runtime/Interfaces.cs rename to IronPython/Runtime/Interfaces.cs diff --git a/Src/IronPython/Runtime/KwCallInfo.cs b/IronPython/Runtime/KwCallInfo.cs similarity index 100% rename from Src/IronPython/Runtime/KwCallInfo.cs rename to IronPython/Runtime/KwCallInfo.cs diff --git a/Src/IronPython/Runtime/LiteralParser.cs b/IronPython/Runtime/LiteralParser.cs similarity index 100% rename from Src/IronPython/Runtime/LiteralParser.cs rename to IronPython/Runtime/LiteralParser.cs diff --git a/Src/IronPython/Runtime/Map.cs b/IronPython/Runtime/Map.cs similarity index 100% rename from Src/IronPython/Runtime/Map.cs rename to IronPython/Runtime/Map.cs diff --git a/Src/IronPython/Runtime/MaybeNotImplementedAttribute.cs b/IronPython/Runtime/MaybeNotImplementedAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/MaybeNotImplementedAttribute.cs rename to IronPython/Runtime/MaybeNotImplementedAttribute.cs diff --git a/Src/IronPython/Runtime/MemoryStreamContentProvider.cs b/IronPython/Runtime/MemoryStreamContentProvider.cs similarity index 100% rename from Src/IronPython/Runtime/MemoryStreamContentProvider.cs rename to IronPython/Runtime/MemoryStreamContentProvider.cs diff --git a/Src/IronPython/Runtime/MemoryView.cs b/IronPython/Runtime/MemoryView.cs similarity index 100% rename from Src/IronPython/Runtime/MemoryView.cs rename to IronPython/Runtime/MemoryView.cs diff --git a/Src/IronPython/Runtime/Method.Generated.cs b/IronPython/Runtime/Method.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Method.Generated.cs rename to IronPython/Runtime/Method.Generated.cs diff --git a/Src/IronPython/Runtime/Method.cs b/IronPython/Runtime/Method.cs similarity index 100% rename from Src/IronPython/Runtime/Method.cs rename to IronPython/Runtime/Method.cs diff --git a/Src/IronPython/Runtime/MissingParameter.cs b/IronPython/Runtime/MissingParameter.cs similarity index 100% rename from Src/IronPython/Runtime/MissingParameter.cs rename to IronPython/Runtime/MissingParameter.cs diff --git a/Src/IronPython/Runtime/ModuleContext.cs b/IronPython/Runtime/ModuleContext.cs similarity index 100% rename from Src/IronPython/Runtime/ModuleContext.cs rename to IronPython/Runtime/ModuleContext.cs diff --git a/Src/IronPython/Runtime/ModuleDictionaryStorage.cs b/IronPython/Runtime/ModuleDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/ModuleDictionaryStorage.cs rename to IronPython/Runtime/ModuleDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/ModuleGlobalCache.cs b/IronPython/Runtime/ModuleGlobalCache.cs similarity index 100% rename from Src/IronPython/Runtime/ModuleGlobalCache.cs rename to IronPython/Runtime/ModuleGlobalCache.cs diff --git a/Src/IronPython/Runtime/ModuleLoader.cs b/IronPython/Runtime/ModuleLoader.cs similarity index 100% rename from Src/IronPython/Runtime/ModuleLoader.cs rename to IronPython/Runtime/ModuleLoader.cs diff --git a/Src/IronPython/Runtime/ModuleOptions.cs b/IronPython/Runtime/ModuleOptions.cs similarity index 100% rename from Src/IronPython/Runtime/ModuleOptions.cs rename to IronPython/Runtime/ModuleOptions.cs diff --git a/Src/IronPython/Runtime/NameType.cs b/IronPython/Runtime/NameType.cs similarity index 100% rename from Src/IronPython/Runtime/NameType.cs rename to IronPython/Runtime/NameType.cs diff --git a/Src/IronPython/Runtime/NewStringFormatter.cs b/IronPython/Runtime/NewStringFormatter.cs similarity index 100% rename from Src/IronPython/Runtime/NewStringFormatter.cs rename to IronPython/Runtime/NewStringFormatter.cs diff --git a/Src/IronPython/Runtime/ObjectAttributesAdapter.cs b/IronPython/Runtime/ObjectAttributesAdapter.cs similarity index 100% rename from Src/IronPython/Runtime/ObjectAttributesAdapter.cs rename to IronPython/Runtime/ObjectAttributesAdapter.cs diff --git a/Src/IronPython/Runtime/ObjectDebugView.cs b/IronPython/Runtime/ObjectDebugView.cs similarity index 100% rename from Src/IronPython/Runtime/ObjectDebugView.cs rename to IronPython/Runtime/ObjectDebugView.cs diff --git a/Src/IronPython/Runtime/Operations/ArrayOps.cs b/IronPython/Runtime/Operations/ArrayOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/ArrayOps.cs rename to IronPython/Runtime/Operations/ArrayOps.cs diff --git a/Src/IronPython/Runtime/Operations/BigIntegerOps.cs b/IronPython/Runtime/Operations/BigIntegerOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/BigIntegerOps.cs rename to IronPython/Runtime/Operations/BigIntegerOps.cs diff --git a/Src/IronPython/Runtime/Operations/BoolOps.cs b/IronPython/Runtime/Operations/BoolOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/BoolOps.cs rename to IronPython/Runtime/Operations/BoolOps.cs diff --git a/Src/IronPython/Runtime/Operations/ByteOps.cs b/IronPython/Runtime/Operations/ByteOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/ByteOps.cs rename to IronPython/Runtime/Operations/ByteOps.cs diff --git a/Src/IronPython/Runtime/Operations/CharOps.cs b/IronPython/Runtime/Operations/CharOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/CharOps.cs rename to IronPython/Runtime/Operations/CharOps.cs diff --git a/Src/IronPython/Runtime/Operations/ComOps.cs b/IronPython/Runtime/Operations/ComOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/ComOps.cs rename to IronPython/Runtime/Operations/ComOps.cs diff --git a/Src/IronPython/Runtime/Operations/ComplexOps.cs b/IronPython/Runtime/Operations/ComplexOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/ComplexOps.cs rename to IronPython/Runtime/Operations/ComplexOps.cs diff --git a/Src/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs b/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs rename to IronPython/Runtime/Operations/CustomTypeDescHelpers.cs diff --git a/Src/IronPython/Runtime/Operations/DBNullOps.cs b/IronPython/Runtime/Operations/DBNullOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/DBNullOps.cs rename to IronPython/Runtime/Operations/DBNullOps.cs diff --git a/Src/IronPython/Runtime/Operations/DateTimeOps.cs b/IronPython/Runtime/Operations/DateTimeOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/DateTimeOps.cs rename to IronPython/Runtime/Operations/DateTimeOps.cs diff --git a/Src/IronPython/Runtime/Operations/DecimalOps.cs b/IronPython/Runtime/Operations/DecimalOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/DecimalOps.cs rename to IronPython/Runtime/Operations/DecimalOps.cs diff --git a/Src/IronPython/Runtime/Operations/DelegateOps.cs b/IronPython/Runtime/Operations/DelegateOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/DelegateOps.cs rename to IronPython/Runtime/Operations/DelegateOps.cs diff --git a/Src/IronPython/Runtime/Operations/DictionaryOfTOps.cs b/IronPython/Runtime/Operations/DictionaryOfTOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/DictionaryOfTOps.cs rename to IronPython/Runtime/Operations/DictionaryOfTOps.cs diff --git a/Src/IronPython/Runtime/Operations/EnumOps.cs b/IronPython/Runtime/Operations/EnumOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/EnumOps.cs rename to IronPython/Runtime/Operations/EnumOps.cs diff --git a/Src/IronPython/Runtime/Operations/FloatOps.Generated.cs b/IronPython/Runtime/Operations/FloatOps.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/FloatOps.Generated.cs rename to IronPython/Runtime/Operations/FloatOps.Generated.cs diff --git a/Src/IronPython/Runtime/Operations/FloatOps.cs b/IronPython/Runtime/Operations/FloatOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/FloatOps.cs rename to IronPython/Runtime/Operations/FloatOps.cs diff --git a/Src/IronPython/Runtime/Operations/IListOfByteOps.cs b/IronPython/Runtime/Operations/IListOfByteOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/IListOfByteOps.cs rename to IronPython/Runtime/Operations/IListOfByteOps.cs diff --git a/Src/IronPython/Runtime/Operations/InstanceOps.cs b/IronPython/Runtime/Operations/InstanceOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/InstanceOps.cs rename to IronPython/Runtime/Operations/InstanceOps.cs diff --git a/Src/IronPython/Runtime/Operations/IntOps.Generated.cs b/IronPython/Runtime/Operations/IntOps.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/IntOps.Generated.cs rename to IronPython/Runtime/Operations/IntOps.Generated.cs diff --git a/Src/IronPython/Runtime/Operations/IntOps.cs b/IronPython/Runtime/Operations/IntOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/IntOps.cs rename to IronPython/Runtime/Operations/IntOps.cs diff --git a/Src/IronPython/Runtime/Operations/IntPtrOps.cs b/IronPython/Runtime/Operations/IntPtrOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/IntPtrOps.cs rename to IronPython/Runtime/Operations/IntPtrOps.cs diff --git a/Src/IronPython/Runtime/Operations/ListOfTOps.cs b/IronPython/Runtime/Operations/ListOfTOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/ListOfTOps.cs rename to IronPython/Runtime/Operations/ListOfTOps.cs diff --git a/Src/IronPython/Runtime/Operations/MarshalOps.cs b/IronPython/Runtime/Operations/MarshalOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/MarshalOps.cs rename to IronPython/Runtime/Operations/MarshalOps.cs diff --git a/Src/IronPython/Runtime/Operations/NamespaceTrackerOps.cs b/IronPython/Runtime/Operations/NamespaceTrackerOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/NamespaceTrackerOps.cs rename to IronPython/Runtime/Operations/NamespaceTrackerOps.cs diff --git a/Src/IronPython/Runtime/Operations/ObjectOps.cs b/IronPython/Runtime/Operations/ObjectOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/ObjectOps.cs rename to IronPython/Runtime/Operations/ObjectOps.cs diff --git a/Src/IronPython/Runtime/Operations/PythonCalls.cs b/IronPython/Runtime/Operations/PythonCalls.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/PythonCalls.cs rename to IronPython/Runtime/Operations/PythonCalls.cs diff --git a/Src/IronPython/Runtime/Operations/PythonOps.Generated.cs b/IronPython/Runtime/Operations/PythonOps.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/PythonOps.Generated.cs rename to IronPython/Runtime/Operations/PythonOps.Generated.cs diff --git a/Src/IronPython/Runtime/Operations/PythonOps.cs b/IronPython/Runtime/Operations/PythonOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/PythonOps.cs rename to IronPython/Runtime/Operations/PythonOps.cs diff --git a/Src/IronPython/Runtime/Operations/PythonTypeOps.cs b/IronPython/Runtime/Operations/PythonTypeOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/PythonTypeOps.cs rename to IronPython/Runtime/Operations/PythonTypeOps.cs diff --git a/Src/IronPython/Runtime/Operations/StringOps.Generated.cs b/IronPython/Runtime/Operations/StringOps.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/StringOps.Generated.cs rename to IronPython/Runtime/Operations/StringOps.Generated.cs diff --git a/Src/IronPython/Runtime/Operations/StringOps.cs b/IronPython/Runtime/Operations/StringOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/StringOps.cs rename to IronPython/Runtime/Operations/StringOps.cs diff --git a/Src/IronPython/Runtime/Operations/TypeGroupOps.cs b/IronPython/Runtime/Operations/TypeGroupOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/TypeGroupOps.cs rename to IronPython/Runtime/Operations/TypeGroupOps.cs diff --git a/Src/IronPython/Runtime/Operations/TypeTrackerOps.cs b/IronPython/Runtime/Operations/TypeTrackerOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/TypeTrackerOps.cs rename to IronPython/Runtime/Operations/TypeTrackerOps.cs diff --git a/Src/IronPython/Runtime/Operations/UIntPtrOps.cs b/IronPython/Runtime/Operations/UIntPtrOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/UIntPtrOps.cs rename to IronPython/Runtime/Operations/UIntPtrOps.cs diff --git a/Src/IronPython/Runtime/Operations/UserTypeOps.cs b/IronPython/Runtime/Operations/UserTypeOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/UserTypeOps.cs rename to IronPython/Runtime/Operations/UserTypeOps.cs diff --git a/Src/IronPython/Runtime/OutputWriter.cs b/IronPython/Runtime/OutputWriter.cs similarity index 100% rename from Src/IronPython/Runtime/OutputWriter.cs rename to IronPython/Runtime/OutputWriter.cs diff --git a/Src/IronPython/Runtime/PlatformsAttribute.cs b/IronPython/Runtime/PlatformsAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/PlatformsAttribute.cs rename to IronPython/Runtime/PlatformsAttribute.cs diff --git a/Src/IronPython/Runtime/Profiler.cs b/IronPython/Runtime/Profiler.cs similarity index 100% rename from Src/IronPython/Runtime/Profiler.cs rename to IronPython/Runtime/Profiler.cs diff --git a/Src/IronPython/Runtime/PythonContext.Generated.cs b/IronPython/Runtime/PythonContext.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/PythonContext.Generated.cs rename to IronPython/Runtime/PythonContext.Generated.cs diff --git a/Src/IronPython/Runtime/PythonContext.cs b/IronPython/Runtime/PythonContext.cs similarity index 100% rename from Src/IronPython/Runtime/PythonContext.cs rename to IronPython/Runtime/PythonContext.cs diff --git a/Src/IronPython/Runtime/PythonDictionary.cs b/IronPython/Runtime/PythonDictionary.cs similarity index 100% rename from Src/IronPython/Runtime/PythonDictionary.cs rename to IronPython/Runtime/PythonDictionary.cs diff --git a/Src/IronPython/Runtime/PythonDocumentationProvider.cs b/IronPython/Runtime/PythonDocumentationProvider.cs similarity index 100% rename from Src/IronPython/Runtime/PythonDocumentationProvider.cs rename to IronPython/Runtime/PythonDocumentationProvider.cs diff --git a/Src/IronPython/Runtime/PythonDynamicStackFrame.cs b/IronPython/Runtime/PythonDynamicStackFrame.cs similarity index 100% rename from Src/IronPython/Runtime/PythonDynamicStackFrame.cs rename to IronPython/Runtime/PythonDynamicStackFrame.cs diff --git a/Src/IronPython/Runtime/PythonEncoding.cs b/IronPython/Runtime/PythonEncoding.cs similarity index 100% rename from Src/IronPython/Runtime/PythonEncoding.cs rename to IronPython/Runtime/PythonEncoding.cs diff --git a/Src/IronPython/Runtime/PythonFileManager.cs b/IronPython/Runtime/PythonFileManager.cs similarity index 100% rename from Src/IronPython/Runtime/PythonFileManager.cs rename to IronPython/Runtime/PythonFileManager.cs diff --git a/Src/IronPython/Runtime/PythonFunction.Generated.cs b/IronPython/Runtime/PythonFunction.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/PythonFunction.Generated.cs rename to IronPython/Runtime/PythonFunction.Generated.cs diff --git a/Src/IronPython/Runtime/PythonFunction.cs b/IronPython/Runtime/PythonFunction.cs similarity index 100% rename from Src/IronPython/Runtime/PythonFunction.cs rename to IronPython/Runtime/PythonFunction.cs diff --git a/Src/IronPython/Runtime/PythonHiddenAttribute.cs b/IronPython/Runtime/PythonHiddenAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/PythonHiddenAttribute.cs rename to IronPython/Runtime/PythonHiddenAttribute.cs diff --git a/Src/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs b/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs rename to IronPython/Runtime/PythonHiddenBaseClassAttribute.cs diff --git a/Src/IronPython/Runtime/PythonList.cs b/IronPython/Runtime/PythonList.cs similarity index 100% rename from Src/IronPython/Runtime/PythonList.cs rename to IronPython/Runtime/PythonList.cs diff --git a/Src/IronPython/Runtime/PythonModule.cs b/IronPython/Runtime/PythonModule.cs old mode 100755 new mode 100644 similarity index 100% rename from Src/IronPython/Runtime/PythonModule.cs rename to IronPython/Runtime/PythonModule.cs diff --git a/Src/IronPython/Runtime/PythonModuleAttribute.cs b/IronPython/Runtime/PythonModuleAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/PythonModuleAttribute.cs rename to IronPython/Runtime/PythonModuleAttribute.cs diff --git a/Src/IronPython/Runtime/PythonNarrowing.cs b/IronPython/Runtime/PythonNarrowing.cs similarity index 100% rename from Src/IronPython/Runtime/PythonNarrowing.cs rename to IronPython/Runtime/PythonNarrowing.cs diff --git a/Src/IronPython/Runtime/PythonOptions.cs b/IronPython/Runtime/PythonOptions.cs similarity index 100% rename from Src/IronPython/Runtime/PythonOptions.cs rename to IronPython/Runtime/PythonOptions.cs diff --git a/Src/IronPython/Runtime/PythonRange.cs b/IronPython/Runtime/PythonRange.cs similarity index 100% rename from Src/IronPython/Runtime/PythonRange.cs rename to IronPython/Runtime/PythonRange.cs diff --git a/Src/IronPython/Runtime/PythonScopeExtension.cs b/IronPython/Runtime/PythonScopeExtension.cs similarity index 100% rename from Src/IronPython/Runtime/PythonScopeExtension.cs rename to IronPython/Runtime/PythonScopeExtension.cs diff --git a/Src/IronPython/Runtime/PythonStrIterator.cs b/IronPython/Runtime/PythonStrIterator.cs similarity index 100% rename from Src/IronPython/Runtime/PythonStrIterator.cs rename to IronPython/Runtime/PythonStrIterator.cs diff --git a/Src/IronPython/Runtime/PythonTracebackListener.cs b/IronPython/Runtime/PythonTracebackListener.cs similarity index 100% rename from Src/IronPython/Runtime/PythonTracebackListener.cs rename to IronPython/Runtime/PythonTracebackListener.cs diff --git a/Src/IronPython/Runtime/PythonTuple.cs b/IronPython/Runtime/PythonTuple.cs similarity index 100% rename from Src/IronPython/Runtime/PythonTuple.cs rename to IronPython/Runtime/PythonTuple.cs diff --git a/Src/IronPython/Runtime/PythonTypeAttribute.cs b/IronPython/Runtime/PythonTypeAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/PythonTypeAttribute.cs rename to IronPython/Runtime/PythonTypeAttribute.cs diff --git a/Src/IronPython/Runtime/Reversed.cs b/IronPython/Runtime/Reversed.cs similarity index 100% rename from Src/IronPython/Runtime/Reversed.cs rename to IronPython/Runtime/Reversed.cs diff --git a/Src/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs b/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs rename to IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/ScopeDictionaryStorage.cs b/IronPython/Runtime/ScopeDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/ScopeDictionaryStorage.cs rename to IronPython/Runtime/ScopeDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/SequenceTypeInfoAttribute.cs b/IronPython/Runtime/SequenceTypeInfoAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/SequenceTypeInfoAttribute.cs rename to IronPython/Runtime/SequenceTypeInfoAttribute.cs diff --git a/Src/IronPython/Runtime/Set.cs b/IronPython/Runtime/Set.cs similarity index 100% rename from Src/IronPython/Runtime/Set.cs rename to IronPython/Runtime/Set.cs diff --git a/Src/IronPython/Runtime/SetStorage.cs b/IronPython/Runtime/SetStorage.cs similarity index 100% rename from Src/IronPython/Runtime/SetStorage.cs rename to IronPython/Runtime/SetStorage.cs diff --git a/Src/IronPython/Runtime/SimpleNamespace.cs b/IronPython/Runtime/SimpleNamespace.cs similarity index 100% rename from Src/IronPython/Runtime/SimpleNamespace.cs rename to IronPython/Runtime/SimpleNamespace.cs diff --git a/Src/IronPython/Runtime/SiteLocalStorage.cs b/IronPython/Runtime/SiteLocalStorage.cs similarity index 100% rename from Src/IronPython/Runtime/SiteLocalStorage.cs rename to IronPython/Runtime/SiteLocalStorage.cs diff --git a/Src/IronPython/Runtime/Slice.cs b/IronPython/Runtime/Slice.cs similarity index 100% rename from Src/IronPython/Runtime/Slice.cs rename to IronPython/Runtime/Slice.cs diff --git a/Src/IronPython/Runtime/StringDictionaryStorage.cs b/IronPython/Runtime/StringDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/StringDictionaryStorage.cs rename to IronPython/Runtime/StringDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/StringFormatSpec.cs b/IronPython/Runtime/StringFormatSpec.cs similarity index 100% rename from Src/IronPython/Runtime/StringFormatSpec.cs rename to IronPython/Runtime/StringFormatSpec.cs diff --git a/Src/IronPython/Runtime/StringFormatter.cs b/IronPython/Runtime/StringFormatter.cs similarity index 100% rename from Src/IronPython/Runtime/StringFormatter.cs rename to IronPython/Runtime/StringFormatter.cs diff --git a/Src/IronPython/Runtime/Super.cs b/IronPython/Runtime/Super.cs similarity index 100% rename from Src/IronPython/Runtime/Super.cs rename to IronPython/Runtime/Super.cs diff --git a/Src/IronPython/Runtime/Symbols.Generated.cs b/IronPython/Runtime/Symbols.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Symbols.Generated.cs rename to IronPython/Runtime/Symbols.Generated.cs diff --git a/Src/IronPython/Runtime/ThrowingErrorSink.cs b/IronPython/Runtime/ThrowingErrorSink.cs similarity index 100% rename from Src/IronPython/Runtime/ThrowingErrorSink.cs rename to IronPython/Runtime/ThrowingErrorSink.cs diff --git a/Src/IronPython/Runtime/TypecodeOps.cs b/IronPython/Runtime/TypecodeOps.cs similarity index 100% rename from Src/IronPython/Runtime/TypecodeOps.cs rename to IronPython/Runtime/TypecodeOps.cs diff --git a/Src/IronPython/Runtime/Types/BuiltinFunction.cs b/IronPython/Runtime/Types/BuiltinFunction.cs similarity index 100% rename from Src/IronPython/Runtime/Types/BuiltinFunction.cs rename to IronPython/Runtime/Types/BuiltinFunction.cs diff --git a/Src/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs b/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs similarity index 100% rename from Src/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs rename to IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs diff --git a/Src/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs b/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs similarity index 100% rename from Src/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs rename to IronPython/Runtime/Types/BuiltinMethodDescriptor.cs diff --git a/Src/IronPython/Runtime/Types/CachedNewTypeInfo.cs b/IronPython/Runtime/Types/CachedNewTypeInfo.cs similarity index 100% rename from Src/IronPython/Runtime/Types/CachedNewTypeInfo.cs rename to IronPython/Runtime/Types/CachedNewTypeInfo.cs diff --git a/Src/IronPython/Runtime/Types/ConstructorFunction.cs b/IronPython/Runtime/Types/ConstructorFunction.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ConstructorFunction.cs rename to IronPython/Runtime/Types/ConstructorFunction.cs diff --git a/Src/IronPython/Runtime/Types/CustomAttributeTracker.cs b/IronPython/Runtime/Types/CustomAttributeTracker.cs similarity index 100% rename from Src/IronPython/Runtime/Types/CustomAttributeTracker.cs rename to IronPython/Runtime/Types/CustomAttributeTracker.cs diff --git a/Src/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs b/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs rename to IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/Types/DocBuilder.cs b/IronPython/Runtime/Types/DocBuilder.cs similarity index 100% rename from Src/IronPython/Runtime/Types/DocBuilder.cs rename to IronPython/Runtime/Types/DocBuilder.cs diff --git a/Src/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs b/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs rename to IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs diff --git a/Src/IronPython/Runtime/Types/DynamicHelpers.cs b/IronPython/Runtime/Types/DynamicHelpers.cs similarity index 100% rename from Src/IronPython/Runtime/Types/DynamicHelpers.cs rename to IronPython/Runtime/Types/DynamicHelpers.cs diff --git a/Src/IronPython/Runtime/Types/EmptyType.cs b/IronPython/Runtime/Types/EmptyType.cs similarity index 100% rename from Src/IronPython/Runtime/Types/EmptyType.cs rename to IronPython/Runtime/Types/EmptyType.cs diff --git a/Src/IronPython/Runtime/Types/ExtensionPropertyInfo.cs b/IronPython/Runtime/Types/ExtensionPropertyInfo.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ExtensionPropertyInfo.cs rename to IronPython/Runtime/Types/ExtensionPropertyInfo.cs diff --git a/Src/IronPython/Runtime/Types/FunctionType.cs b/IronPython/Runtime/Types/FunctionType.cs similarity index 100% rename from Src/IronPython/Runtime/Types/FunctionType.cs rename to IronPython/Runtime/Types/FunctionType.cs diff --git a/Src/IronPython/Runtime/Types/IPythonObject.cs b/IronPython/Runtime/Types/IPythonObject.cs similarity index 100% rename from Src/IronPython/Runtime/Types/IPythonObject.cs rename to IronPython/Runtime/Types/IPythonObject.cs diff --git a/Src/IronPython/Runtime/Types/InstanceCreator.cs b/IronPython/Runtime/Types/InstanceCreator.cs similarity index 100% rename from Src/IronPython/Runtime/Types/InstanceCreator.cs rename to IronPython/Runtime/Types/InstanceCreator.cs diff --git a/Src/IronPython/Runtime/Types/MappingProxy.cs b/IronPython/Runtime/Types/MappingProxy.cs similarity index 100% rename from Src/IronPython/Runtime/Types/MappingProxy.cs rename to IronPython/Runtime/Types/MappingProxy.cs diff --git a/Src/IronPython/Runtime/Types/Mro.cs b/IronPython/Runtime/Types/Mro.cs similarity index 100% rename from Src/IronPython/Runtime/Types/Mro.cs rename to IronPython/Runtime/Types/Mro.cs diff --git a/Src/IronPython/Runtime/Types/NameConverter.cs b/IronPython/Runtime/Types/NameConverter.cs similarity index 100% rename from Src/IronPython/Runtime/Types/NameConverter.cs rename to IronPython/Runtime/Types/NameConverter.cs diff --git a/Src/IronPython/Runtime/Types/NewTypeInfo.cs b/IronPython/Runtime/Types/NewTypeInfo.cs similarity index 100% rename from Src/IronPython/Runtime/Types/NewTypeInfo.cs rename to IronPython/Runtime/Types/NewTypeInfo.cs diff --git a/Src/IronPython/Runtime/Types/NewTypeMaker.cs b/IronPython/Runtime/Types/NewTypeMaker.cs similarity index 100% rename from Src/IronPython/Runtime/Types/NewTypeMaker.cs rename to IronPython/Runtime/Types/NewTypeMaker.cs diff --git a/Src/IronPython/Runtime/Types/OperatorMapping.cs b/IronPython/Runtime/Types/OperatorMapping.cs similarity index 100% rename from Src/IronPython/Runtime/Types/OperatorMapping.cs rename to IronPython/Runtime/Types/OperatorMapping.cs diff --git a/Src/IronPython/Runtime/Types/ParameterInfoWrapper.cs b/IronPython/Runtime/Types/ParameterInfoWrapper.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ParameterInfoWrapper.cs rename to IronPython/Runtime/Types/ParameterInfoWrapper.cs diff --git a/Src/IronPython/Runtime/Types/PythonAssemblyOps.cs b/IronPython/Runtime/Types/PythonAssemblyOps.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonAssemblyOps.cs rename to IronPython/Runtime/Types/PythonAssemblyOps.cs diff --git a/Src/IronPython/Runtime/Types/PythonSiteCache.cs b/IronPython/Runtime/Types/PythonSiteCache.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonSiteCache.cs rename to IronPython/Runtime/Types/PythonSiteCache.cs diff --git a/Src/IronPython/Runtime/Types/PythonType.Generated.cs b/IronPython/Runtime/Types/PythonType.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonType.Generated.cs rename to IronPython/Runtime/Types/PythonType.Generated.cs diff --git a/Src/IronPython/Runtime/Types/PythonType.cs b/IronPython/Runtime/Types/PythonType.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonType.cs rename to IronPython/Runtime/Types/PythonType.cs diff --git a/Src/IronPython/Runtime/Types/PythonTypeDataSlot.cs b/IronPython/Runtime/Types/PythonTypeDataSlot.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonTypeDataSlot.cs rename to IronPython/Runtime/Types/PythonTypeDataSlot.cs diff --git a/Src/IronPython/Runtime/Types/PythonTypeDictSlot.cs b/IronPython/Runtime/Types/PythonTypeDictSlot.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonTypeDictSlot.cs rename to IronPython/Runtime/Types/PythonTypeDictSlot.cs diff --git a/Src/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs b/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs rename to IronPython/Runtime/Types/PythonTypeInfo.Generated.cs diff --git a/Src/IronPython/Runtime/Types/PythonTypeInfo.cs b/IronPython/Runtime/Types/PythonTypeInfo.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonTypeInfo.cs rename to IronPython/Runtime/Types/PythonTypeInfo.cs diff --git a/Src/IronPython/Runtime/Types/PythonTypeSlot.cs b/IronPython/Runtime/Types/PythonTypeSlot.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonTypeSlot.cs rename to IronPython/Runtime/Types/PythonTypeSlot.cs diff --git a/Src/IronPython/Runtime/Types/PythonTypeTypeSlot.cs b/IronPython/Runtime/Types/PythonTypeTypeSlot.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonTypeTypeSlot.cs rename to IronPython/Runtime/Types/PythonTypeTypeSlot.cs diff --git a/Src/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs b/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs rename to IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs diff --git a/Src/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs b/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs rename to IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs diff --git a/Src/IronPython/Runtime/Types/ReflectedEvent.cs b/IronPython/Runtime/Types/ReflectedEvent.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ReflectedEvent.cs rename to IronPython/Runtime/Types/ReflectedEvent.cs diff --git a/Src/IronPython/Runtime/Types/ReflectedExtensionProperty.cs b/IronPython/Runtime/Types/ReflectedExtensionProperty.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ReflectedExtensionProperty.cs rename to IronPython/Runtime/Types/ReflectedExtensionProperty.cs diff --git a/Src/IronPython/Runtime/Types/ReflectedField.cs b/IronPython/Runtime/Types/ReflectedField.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ReflectedField.cs rename to IronPython/Runtime/Types/ReflectedField.cs diff --git a/Src/IronPython/Runtime/Types/ReflectedGetterSetter.cs b/IronPython/Runtime/Types/ReflectedGetterSetter.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ReflectedGetterSetter.cs rename to IronPython/Runtime/Types/ReflectedGetterSetter.cs diff --git a/Src/IronPython/Runtime/Types/ReflectedIndexer.cs b/IronPython/Runtime/Types/ReflectedIndexer.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ReflectedIndexer.cs rename to IronPython/Runtime/Types/ReflectedIndexer.cs diff --git a/Src/IronPython/Runtime/Types/ReflectedProperty.cs b/IronPython/Runtime/Types/ReflectedProperty.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ReflectedProperty.cs rename to IronPython/Runtime/Types/ReflectedProperty.cs diff --git a/Src/IronPython/Runtime/Types/ReflectedSlotProperty.cs b/IronPython/Runtime/Types/ReflectedSlotProperty.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ReflectedSlotProperty.cs rename to IronPython/Runtime/Types/ReflectedSlotProperty.cs diff --git a/Src/IronPython/Runtime/Types/ResolvedMember.cs b/IronPython/Runtime/Types/ResolvedMember.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ResolvedMember.cs rename to IronPython/Runtime/Types/ResolvedMember.cs diff --git a/Src/IronPython/Runtime/Types/SlotFieldAttribute.cs b/IronPython/Runtime/Types/SlotFieldAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/Types/SlotFieldAttribute.cs rename to IronPython/Runtime/Types/SlotFieldAttribute.cs diff --git a/Src/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs b/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs similarity index 100% rename from Src/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs rename to IronPython/Runtime/Types/StaticUnderlyingSystemType.cs diff --git a/Src/IronPython/Runtime/Types/TypeCache.Generated.cs b/IronPython/Runtime/Types/TypeCache.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Types/TypeCache.Generated.cs rename to IronPython/Runtime/Types/TypeCache.Generated.cs diff --git a/Src/IronPython/Runtime/UnboundNameException.cs b/IronPython/Runtime/UnboundNameException.cs similarity index 100% rename from Src/IronPython/Runtime/UnboundNameException.cs rename to IronPython/Runtime/UnboundNameException.cs diff --git a/Src/IronPython/Runtime/WeakRef.cs b/IronPython/Runtime/WeakRef.cs similarity index 100% rename from Src/IronPython/Runtime/WeakRef.cs rename to IronPython/Runtime/WeakRef.cs diff --git a/Src/IronPython/Runtime/WrapperDescriptorAttribute.cs b/IronPython/Runtime/WrapperDescriptorAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/WrapperDescriptorAttribute.cs rename to IronPython/Runtime/WrapperDescriptorAttribute.cs diff --git a/Src/IronPython/Runtime/WrapperDictionary.cs b/IronPython/Runtime/WrapperDictionary.cs similarity index 100% rename from Src/IronPython/Runtime/WrapperDictionary.cs rename to IronPython/Runtime/WrapperDictionary.cs diff --git a/Src/IronPython/Runtime/Zip.cs b/IronPython/Runtime/Zip.cs similarity index 100% rename from Src/IronPython/Runtime/Zip.cs rename to IronPython/Runtime/Zip.cs diff --git a/Src/IronPython/SerializationStubs.cs b/IronPython/SerializationStubs.cs similarity index 100% rename from Src/IronPython/SerializationStubs.cs rename to IronPython/SerializationStubs.cs diff --git a/Src/IronPython/StringExtensions.cs b/IronPython/StringExtensions.cs similarity index 100% rename from Src/IronPython/StringExtensions.cs rename to IronPython/StringExtensions.cs diff --git a/Src/IronPython/SystemRuntimeVersioning.cs b/IronPython/SystemRuntimeVersioning.cs similarity index 100% rename from Src/IronPython/SystemRuntimeVersioning.cs rename to IronPython/SystemRuntimeVersioning.cs diff --git a/Src/IronPython/policy.IronPython.config b/IronPython/policy.IronPython.config similarity index 100% rename from Src/IronPython/policy.IronPython.config rename to IronPython/policy.IronPython.config diff --git a/Src/Modules/IronPython.Modules.csproj b/Modules/IronPython.Modules.csproj similarity index 89% rename from Src/Modules/IronPython.Modules.csproj rename to Modules/IronPython.Modules.csproj index 0f54dd0d0..2463bf256 100644 --- a/Src/Modules/IronPython.Modules.csproj +++ b/Modules/IronPython.Modules.csproj @@ -10,7 +10,7 @@ True - ..\..\Utils\References\Mono.Posix.dll + ..\Utils\References\Mono.Posix.dll @@ -26,7 +26,7 @@ - + false Analyzer diff --git a/Src/Modules/IterTools.cs b/Modules/IterTools.cs similarity index 100% rename from Src/Modules/IterTools.cs rename to Modules/IterTools.cs diff --git a/Src/Modules/ModuleOps.cs b/Modules/ModuleOps.cs similarity index 100% rename from Src/Modules/ModuleOps.cs rename to Modules/ModuleOps.cs diff --git a/Src/Modules/NtSignalState.cs b/Modules/NtSignalState.cs similarity index 100% rename from Src/Modules/NtSignalState.cs rename to Modules/NtSignalState.cs diff --git a/Src/Modules/Properties/AssemblyInfo.cs b/Modules/Properties/AssemblyInfo.cs similarity index 100% rename from Src/Modules/Properties/AssemblyInfo.cs rename to Modules/Properties/AssemblyInfo.cs diff --git a/Src/Modules/ResourceMetaPathImporter.cs b/Modules/ResourceMetaPathImporter.cs similarity index 100% rename from Src/Modules/ResourceMetaPathImporter.cs rename to Modules/ResourceMetaPathImporter.cs diff --git a/Src/Modules/SimpleSignalState.cs b/Modules/SimpleSignalState.cs similarity index 100% rename from Src/Modules/SimpleSignalState.cs rename to Modules/SimpleSignalState.cs diff --git a/Src/Modules/_bisect.cs b/Modules/_bisect.cs similarity index 100% rename from Src/Modules/_bisect.cs rename to Modules/_bisect.cs diff --git a/Src/Modules/_codecs.cs b/Modules/_codecs.cs similarity index 100% rename from Src/Modules/_codecs.cs rename to Modules/_codecs.cs diff --git a/Src/Modules/_codecs_cn.cs b/Modules/_codecs_cn.cs similarity index 100% rename from Src/Modules/_codecs_cn.cs rename to Modules/_codecs_cn.cs diff --git a/Src/Modules/_collections.cs b/Modules/_collections.cs similarity index 100% rename from Src/Modules/_collections.cs rename to Modules/_collections.cs diff --git a/Src/Modules/_csv.cs b/Modules/_csv.cs similarity index 100% rename from Src/Modules/_csv.cs rename to Modules/_csv.cs diff --git a/Src/Modules/_ctypes/Array.cs b/Modules/_ctypes/Array.cs similarity index 100% rename from Src/Modules/_ctypes/Array.cs rename to Modules/_ctypes/Array.cs diff --git a/Src/Modules/_ctypes/ArrayType.cs b/Modules/_ctypes/ArrayType.cs similarity index 100% rename from Src/Modules/_ctypes/ArrayType.cs rename to Modules/_ctypes/ArrayType.cs diff --git a/Src/Modules/_ctypes/CData.cs b/Modules/_ctypes/CData.cs similarity index 100% rename from Src/Modules/_ctypes/CData.cs rename to Modules/_ctypes/CData.cs diff --git a/Src/Modules/_ctypes/CFuncPtr.cs b/Modules/_ctypes/CFuncPtr.cs similarity index 100% rename from Src/Modules/_ctypes/CFuncPtr.cs rename to Modules/_ctypes/CFuncPtr.cs diff --git a/Src/Modules/_ctypes/CFuncPtrType.cs b/Modules/_ctypes/CFuncPtrType.cs similarity index 100% rename from Src/Modules/_ctypes/CFuncPtrType.cs rename to Modules/_ctypes/CFuncPtrType.cs diff --git a/Src/Modules/_ctypes/Extensions.cs b/Modules/_ctypes/Extensions.cs similarity index 100% rename from Src/Modules/_ctypes/Extensions.cs rename to Modules/_ctypes/Extensions.cs diff --git a/Src/Modules/_ctypes/Field.cs b/Modules/_ctypes/Field.cs similarity index 100% rename from Src/Modules/_ctypes/Field.cs rename to Modules/_ctypes/Field.cs diff --git a/Src/Modules/_ctypes/INativeType.cs b/Modules/_ctypes/INativeType.cs similarity index 100% rename from Src/Modules/_ctypes/INativeType.cs rename to Modules/_ctypes/INativeType.cs diff --git a/Src/Modules/_ctypes/LocalOrArg.cs b/Modules/_ctypes/LocalOrArg.cs similarity index 100% rename from Src/Modules/_ctypes/LocalOrArg.cs rename to Modules/_ctypes/LocalOrArg.cs diff --git a/Src/Modules/_ctypes/MarshalCleanup.cs b/Modules/_ctypes/MarshalCleanup.cs similarity index 100% rename from Src/Modules/_ctypes/MarshalCleanup.cs rename to Modules/_ctypes/MarshalCleanup.cs diff --git a/Src/Modules/_ctypes/MemoryHolder.cs b/Modules/_ctypes/MemoryHolder.cs similarity index 100% rename from Src/Modules/_ctypes/MemoryHolder.cs rename to Modules/_ctypes/MemoryHolder.cs diff --git a/Src/Modules/_ctypes/NativeArgument.cs b/Modules/_ctypes/NativeArgument.cs similarity index 100% rename from Src/Modules/_ctypes/NativeArgument.cs rename to Modules/_ctypes/NativeArgument.cs diff --git a/Src/Modules/_ctypes/NativeFunctions.cs b/Modules/_ctypes/NativeFunctions.cs similarity index 100% rename from Src/Modules/_ctypes/NativeFunctions.cs rename to Modules/_ctypes/NativeFunctions.cs diff --git a/Src/Modules/_ctypes/Pointer.cs b/Modules/_ctypes/Pointer.cs similarity index 100% rename from Src/Modules/_ctypes/Pointer.cs rename to Modules/_ctypes/Pointer.cs diff --git a/Src/Modules/_ctypes/PointerType.cs b/Modules/_ctypes/PointerType.cs similarity index 100% rename from Src/Modules/_ctypes/PointerType.cs rename to Modules/_ctypes/PointerType.cs diff --git a/Src/Modules/_ctypes/SimpleCData.cs b/Modules/_ctypes/SimpleCData.cs similarity index 100% rename from Src/Modules/_ctypes/SimpleCData.cs rename to Modules/_ctypes/SimpleCData.cs diff --git a/Src/Modules/_ctypes/SimpleType.cs b/Modules/_ctypes/SimpleType.cs similarity index 100% rename from Src/Modules/_ctypes/SimpleType.cs rename to Modules/_ctypes/SimpleType.cs diff --git a/Src/Modules/_ctypes/SimpleTypeKind.cs b/Modules/_ctypes/SimpleTypeKind.cs similarity index 100% rename from Src/Modules/_ctypes/SimpleTypeKind.cs rename to Modules/_ctypes/SimpleTypeKind.cs diff --git a/Src/Modules/_ctypes/StructType.cs b/Modules/_ctypes/StructType.cs similarity index 100% rename from Src/Modules/_ctypes/StructType.cs rename to Modules/_ctypes/StructType.cs diff --git a/Src/Modules/_ctypes/Structure.cs b/Modules/_ctypes/Structure.cs similarity index 100% rename from Src/Modules/_ctypes/Structure.cs rename to Modules/_ctypes/Structure.cs diff --git a/Src/Modules/_ctypes/Union.cs b/Modules/_ctypes/Union.cs similarity index 100% rename from Src/Modules/_ctypes/Union.cs rename to Modules/_ctypes/Union.cs diff --git a/Src/Modules/_ctypes/UnionType.cs b/Modules/_ctypes/UnionType.cs similarity index 100% rename from Src/Modules/_ctypes/UnionType.cs rename to Modules/_ctypes/UnionType.cs diff --git a/Src/Modules/_ctypes/_ctypes.cs b/Modules/_ctypes/_ctypes.cs similarity index 100% rename from Src/Modules/_ctypes/_ctypes.cs rename to Modules/_ctypes/_ctypes.cs diff --git a/Src/Modules/_ctypes_test.cs b/Modules/_ctypes_test.cs similarity index 100% rename from Src/Modules/_ctypes_test.cs rename to Modules/_ctypes_test.cs diff --git a/Src/Modules/_datetime.cs b/Modules/_datetime.cs similarity index 100% rename from Src/Modules/_datetime.cs rename to Modules/_datetime.cs diff --git a/Src/Modules/_functools.cs b/Modules/_functools.cs similarity index 100% rename from Src/Modules/_functools.cs rename to Modules/_functools.cs diff --git a/Src/Modules/_heapq.cs b/Modules/_heapq.cs similarity index 100% rename from Src/Modules/_heapq.cs rename to Modules/_heapq.cs diff --git a/Src/Modules/_multibytecodec.cs b/Modules/_multibytecodec.cs similarity index 100% rename from Src/Modules/_multibytecodec.cs rename to Modules/_multibytecodec.cs diff --git a/Src/Modules/_multiprocessing.cs b/Modules/_multiprocessing.cs similarity index 100% rename from Src/Modules/_multiprocessing.cs rename to Modules/_multiprocessing.cs diff --git a/Src/Modules/_opcode.cs b/Modules/_opcode.cs similarity index 100% rename from Src/Modules/_opcode.cs rename to Modules/_opcode.cs diff --git a/Src/Modules/_operator.cs b/Modules/_operator.cs similarity index 100% rename from Src/Modules/_operator.cs rename to Modules/_operator.cs diff --git a/Src/Modules/_overlapped.cs b/Modules/_overlapped.cs similarity index 100% rename from Src/Modules/_overlapped.cs rename to Modules/_overlapped.cs diff --git a/Src/Modules/_pickle.cs b/Modules/_pickle.cs similarity index 100% rename from Src/Modules/_pickle.cs rename to Modules/_pickle.cs diff --git a/Src/Modules/_posixsubprocess.cs b/Modules/_posixsubprocess.cs similarity index 100% rename from Src/Modules/_posixsubprocess.cs rename to Modules/_posixsubprocess.cs diff --git a/Src/Modules/_random.RandomGen.cs b/Modules/_random.RandomGen.cs similarity index 100% rename from Src/Modules/_random.RandomGen.cs rename to Modules/_random.RandomGen.cs diff --git a/Src/Modules/_random.cs b/Modules/_random.cs similarity index 100% rename from Src/Modules/_random.cs rename to Modules/_random.cs diff --git a/Src/Modules/_socket.cs b/Modules/_socket.cs similarity index 100% rename from Src/Modules/_socket.cs rename to Modules/_socket.cs diff --git a/Src/Modules/_sre.cs b/Modules/_sre.cs similarity index 100% rename from Src/Modules/_sre.cs rename to Modules/_sre.cs diff --git a/Src/Modules/_ssl.cs b/Modules/_ssl.cs similarity index 100% rename from Src/Modules/_ssl.cs rename to Modules/_ssl.cs diff --git a/Src/Modules/_string.cs b/Modules/_string.cs similarity index 100% rename from Src/Modules/_string.cs rename to Modules/_string.cs diff --git a/Src/Modules/_struct.cs b/Modules/_struct.cs similarity index 100% rename from Src/Modules/_struct.cs rename to Modules/_struct.cs diff --git a/Src/Modules/_sysconfigdata.cs b/Modules/_sysconfigdata.cs similarity index 100% rename from Src/Modules/_sysconfigdata.cs rename to Modules/_sysconfigdata.cs diff --git a/Src/Modules/_thread.cs b/Modules/_thread.cs similarity index 100% rename from Src/Modules/_thread.cs rename to Modules/_thread.cs diff --git a/Src/Modules/_warnings.cs b/Modules/_warnings.cs similarity index 100% rename from Src/Modules/_warnings.cs rename to Modules/_warnings.cs diff --git a/Src/Modules/_weakref.Generated.cs b/Modules/_weakref.Generated.cs similarity index 100% rename from Src/Modules/_weakref.Generated.cs rename to Modules/_weakref.Generated.cs diff --git a/Src/Modules/_weakref.cs b/Modules/_weakref.cs similarity index 100% rename from Src/Modules/_weakref.cs rename to Modules/_weakref.cs diff --git a/Src/Modules/_winapi.cs b/Modules/_winapi.cs similarity index 100% rename from Src/Modules/_winapi.cs rename to Modules/_winapi.cs diff --git a/Src/Modules/array.cs b/Modules/array.cs similarity index 100% rename from Src/Modules/array.cs rename to Modules/array.cs diff --git a/Src/Modules/atexit.cs b/Modules/atexit.cs similarity index 100% rename from Src/Modules/atexit.cs rename to Modules/atexit.cs diff --git a/Src/Modules/audioop.cs b/Modules/audioop.cs similarity index 100% rename from Src/Modules/audioop.cs rename to Modules/audioop.cs diff --git a/Src/Modules/binascii.cs b/Modules/binascii.cs similarity index 100% rename from Src/Modules/binascii.cs rename to Modules/binascii.cs diff --git a/Src/Modules/bz2/BZ2Compressor.cs b/Modules/bz2/BZ2Compressor.cs similarity index 100% rename from Src/Modules/bz2/BZ2Compressor.cs rename to Modules/bz2/BZ2Compressor.cs diff --git a/Src/Modules/bz2/BZ2Decompressor.cs b/Modules/bz2/BZ2Decompressor.cs similarity index 100% rename from Src/Modules/bz2/BZ2Decompressor.cs rename to Modules/bz2/BZ2Decompressor.cs diff --git a/Src/Modules/bz2/BZ2Module.cs b/Modules/bz2/BZ2Module.cs similarity index 100% rename from Src/Modules/bz2/BZ2Module.cs rename to Modules/bz2/BZ2Module.cs diff --git a/Src/Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs b/Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs similarity index 100% rename from Src/Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs rename to Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs diff --git a/Src/Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs b/Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs similarity index 100% rename from Src/Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs rename to Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs diff --git a/Src/Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs b/Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs similarity index 100% rename from Src/Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs rename to Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs diff --git a/Src/Modules/bz2/dotnetzip/BZip2/BitWriter.cs b/Modules/bz2/dotnetzip/BZip2/BitWriter.cs similarity index 100% rename from Src/Modules/bz2/dotnetzip/BZip2/BitWriter.cs rename to Modules/bz2/dotnetzip/BZip2/BitWriter.cs diff --git a/Src/Modules/bz2/dotnetzip/BZip2/CRC32.cs b/Modules/bz2/dotnetzip/BZip2/CRC32.cs similarity index 100% rename from Src/Modules/bz2/dotnetzip/BZip2/CRC32.cs rename to Modules/bz2/dotnetzip/BZip2/CRC32.cs diff --git a/Src/Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs b/Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs similarity index 100% rename from Src/Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs rename to Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs diff --git a/Src/Modules/bz2/dotnetzip/BZip2/Rand.cs b/Modules/bz2/dotnetzip/BZip2/Rand.cs similarity index 100% rename from Src/Modules/bz2/dotnetzip/BZip2/Rand.cs rename to Modules/bz2/dotnetzip/BZip2/Rand.cs diff --git a/Src/Modules/bz2/dotnetzip/source.txt b/Modules/bz2/dotnetzip/source.txt similarity index 100% rename from Src/Modules/bz2/dotnetzip/source.txt rename to Modules/bz2/dotnetzip/source.txt diff --git a/Src/Modules/cmath.cs b/Modules/cmath.cs similarity index 100% rename from Src/Modules/cmath.cs rename to Modules/cmath.cs diff --git a/Src/Modules/errno.cs b/Modules/errno.cs similarity index 100% rename from Src/Modules/errno.cs rename to Modules/errno.cs diff --git a/Src/Modules/faulthandler.cs b/Modules/faulthandler.cs similarity index 100% rename from Src/Modules/faulthandler.cs rename to Modules/faulthandler.cs diff --git a/Src/Modules/fcntl.cs b/Modules/fcntl.cs similarity index 100% rename from Src/Modules/fcntl.cs rename to Modules/fcntl.cs diff --git a/Src/Modules/gc.cs b/Modules/gc.cs similarity index 100% rename from Src/Modules/gc.cs rename to Modules/gc.cs diff --git a/Src/Modules/grp.cs b/Modules/grp.cs similarity index 100% rename from Src/Modules/grp.cs rename to Modules/grp.cs diff --git a/Src/Modules/hashlib/MD5CryptoServiceProvider.cs b/Modules/hashlib/MD5CryptoServiceProvider.cs similarity index 100% rename from Src/Modules/hashlib/MD5CryptoServiceProvider.cs rename to Modules/hashlib/MD5CryptoServiceProvider.cs diff --git a/Src/Modules/hashlib/SHA1CryptoServiceProvider.cs b/Modules/hashlib/SHA1CryptoServiceProvider.cs similarity index 100% rename from Src/Modules/hashlib/SHA1CryptoServiceProvider.cs rename to Modules/hashlib/SHA1CryptoServiceProvider.cs diff --git a/Src/Modules/hashlib/SHA224.cs b/Modules/hashlib/SHA224.cs similarity index 100% rename from Src/Modules/hashlib/SHA224.cs rename to Modules/hashlib/SHA224.cs diff --git a/Src/Modules/hashlib/SHA224Managed.cs b/Modules/hashlib/SHA224Managed.cs similarity index 100% rename from Src/Modules/hashlib/SHA224Managed.cs rename to Modules/hashlib/SHA224Managed.cs diff --git a/Src/Modules/hashlib/SHA256Managed.cs b/Modules/hashlib/SHA256Managed.cs similarity index 100% rename from Src/Modules/hashlib/SHA256Managed.cs rename to Modules/hashlib/SHA256Managed.cs diff --git a/Src/Modules/hashlib/SHA384Managed.cs b/Modules/hashlib/SHA384Managed.cs similarity index 100% rename from Src/Modules/hashlib/SHA384Managed.cs rename to Modules/hashlib/SHA384Managed.cs diff --git a/Src/Modules/hashlib/SHA512Managed.cs b/Modules/hashlib/SHA512Managed.cs similarity index 100% rename from Src/Modules/hashlib/SHA512Managed.cs rename to Modules/hashlib/SHA512Managed.cs diff --git a/Src/Modules/hashlib/SHAConstants.cs b/Modules/hashlib/SHAConstants.cs similarity index 100% rename from Src/Modules/hashlib/SHAConstants.cs rename to Modules/hashlib/SHAConstants.cs diff --git a/Src/Modules/hashlib/_hashlib.cs b/Modules/hashlib/_hashlib.cs similarity index 100% rename from Src/Modules/hashlib/_hashlib.cs rename to Modules/hashlib/_hashlib.cs diff --git a/Src/Modules/hashlib/_md5.cs b/Modules/hashlib/_md5.cs similarity index 100% rename from Src/Modules/hashlib/_md5.cs rename to Modules/hashlib/_md5.cs diff --git a/Src/Modules/hashlib/_sha1.cs b/Modules/hashlib/_sha1.cs similarity index 100% rename from Src/Modules/hashlib/_sha1.cs rename to Modules/hashlib/_sha1.cs diff --git a/Src/Modules/hashlib/_sha256.cs b/Modules/hashlib/_sha256.cs similarity index 100% rename from Src/Modules/hashlib/_sha256.cs rename to Modules/hashlib/_sha256.cs diff --git a/Src/Modules/hashlib/_sha512.cs b/Modules/hashlib/_sha512.cs similarity index 100% rename from Src/Modules/hashlib/_sha512.cs rename to Modules/hashlib/_sha512.cs diff --git a/Src/Modules/marshal.cs b/Modules/marshal.cs similarity index 100% rename from Src/Modules/marshal.cs rename to Modules/marshal.cs diff --git a/Src/Modules/math.Generated.cs b/Modules/math.Generated.cs similarity index 100% rename from Src/Modules/math.Generated.cs rename to Modules/math.Generated.cs diff --git a/Src/Modules/math.cs b/Modules/math.cs similarity index 100% rename from Src/Modules/math.cs rename to Modules/math.cs diff --git a/Src/Modules/mmap.cs b/Modules/mmap.cs similarity index 100% rename from Src/Modules/mmap.cs rename to Modules/mmap.cs diff --git a/Src/Modules/msvcrt.cs b/Modules/msvcrt.cs similarity index 100% rename from Src/Modules/msvcrt.cs rename to Modules/msvcrt.cs diff --git a/Src/Modules/nt.cs b/Modules/nt.cs similarity index 100% rename from Src/Modules/nt.cs rename to Modules/nt.cs diff --git a/Src/Modules/policy.IronPython.Modules.config b/Modules/policy.IronPython.Modules.config similarity index 100% rename from Src/Modules/policy.IronPython.Modules.config rename to Modules/policy.IronPython.Modules.config diff --git a/Src/Modules/pwd.cs b/Modules/pwd.cs similarity index 100% rename from Src/Modules/pwd.cs rename to Modules/pwd.cs diff --git a/Src/Modules/pyexpat.cs b/Modules/pyexpat.cs similarity index 100% rename from Src/Modules/pyexpat.cs rename to Modules/pyexpat.cs diff --git a/Src/Modules/re.cs b/Modules/re.cs similarity index 100% rename from Src/Modules/re.cs rename to Modules/re.cs diff --git a/Src/Modules/resource.cs b/Modules/resource.cs similarity index 100% rename from Src/Modules/resource.cs rename to Modules/resource.cs diff --git a/Src/Modules/select.cs b/Modules/select.cs similarity index 100% rename from Src/Modules/select.cs rename to Modules/select.cs diff --git a/Src/Modules/signal.cs b/Modules/signal.cs similarity index 100% rename from Src/Modules/signal.cs rename to Modules/signal.cs diff --git a/Src/Modules/spwd.cs b/Modules/spwd.cs similarity index 100% rename from Src/Modules/spwd.cs rename to Modules/spwd.cs diff --git a/Src/Modules/time.cs b/Modules/time.cs similarity index 100% rename from Src/Modules/time.cs rename to Modules/time.cs diff --git a/Src/Modules/winreg.cs b/Modules/winreg.cs similarity index 100% rename from Src/Modules/winreg.cs rename to Modules/winreg.cs diff --git a/Src/Modules/winsound.cs b/Modules/winsound.cs similarity index 100% rename from Src/Modules/winsound.cs rename to Modules/winsound.cs diff --git a/Src/Modules/xxsubtype.cs b/Modules/xxsubtype.cs similarity index 100% rename from Src/Modules/xxsubtype.cs rename to Modules/xxsubtype.cs diff --git a/Src/Modules/zipimport.cs b/Modules/zipimport.cs similarity index 100% rename from Src/Modules/zipimport.cs rename to Modules/zipimport.cs diff --git a/Src/Modules/zlib/Compress.cs b/Modules/zlib/Compress.cs similarity index 100% rename from Src/Modules/zlib/Compress.cs rename to Modules/zlib/Compress.cs diff --git a/Src/Modules/zlib/Decompress.cs b/Modules/zlib/Decompress.cs similarity index 100% rename from Src/Modules/zlib/Decompress.cs rename to Modules/zlib/Decompress.cs diff --git a/Src/Modules/zlib/ZlibModule.cs b/Modules/zlib/ZlibModule.cs similarity index 100% rename from Src/Modules/zlib/ZlibModule.cs rename to Modules/zlib/ZlibModule.cs diff --git a/Src/Modules/zlib/zlib.net/Adler32.cs b/Modules/zlib/zlib.net/Adler32.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/Adler32.cs rename to Modules/zlib/zlib.net/Adler32.cs diff --git a/Src/Modules/zlib/zlib.net/Deflate.cs b/Modules/zlib/zlib.net/Deflate.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/Deflate.cs rename to Modules/zlib/zlib.net/Deflate.cs diff --git a/Src/Modules/zlib/zlib.net/InfBlocks.cs b/Modules/zlib/zlib.net/InfBlocks.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/InfBlocks.cs rename to Modules/zlib/zlib.net/InfBlocks.cs diff --git a/Src/Modules/zlib/zlib.net/InfCodes.cs b/Modules/zlib/zlib.net/InfCodes.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/InfCodes.cs rename to Modules/zlib/zlib.net/InfCodes.cs diff --git a/Src/Modules/zlib/zlib.net/InfTree.cs b/Modules/zlib/zlib.net/InfTree.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/InfTree.cs rename to Modules/zlib/zlib.net/InfTree.cs diff --git a/Src/Modules/zlib/zlib.net/Inflate.cs b/Modules/zlib/zlib.net/Inflate.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/Inflate.cs rename to Modules/zlib/zlib.net/Inflate.cs diff --git a/Src/Modules/zlib/zlib.net/StaticTree.cs b/Modules/zlib/zlib.net/StaticTree.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/StaticTree.cs rename to Modules/zlib/zlib.net/StaticTree.cs diff --git a/Src/Modules/zlib/zlib.net/Tree.cs b/Modules/zlib/zlib.net/Tree.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/Tree.cs rename to Modules/zlib/zlib.net/Tree.cs diff --git a/Src/Modules/zlib/zlib.net/ZStream.cs b/Modules/zlib/zlib.net/ZStream.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/ZStream.cs rename to Modules/zlib/zlib.net/ZStream.cs diff --git a/Src/Modules/zlib/zlib.net/ZStreamException.cs b/Modules/zlib/zlib.net/ZStreamException.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/ZStreamException.cs rename to Modules/zlib/zlib.net/ZStreamException.cs diff --git a/Src/Modules/zlib/zlib.net/Zlib.cs b/Modules/zlib/zlib.net/Zlib.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/Zlib.cs rename to Modules/zlib/zlib.net/Zlib.cs diff --git a/Src/Modules/zlib/zlib.net/history.txt b/Modules/zlib/zlib.net/history.txt similarity index 100% rename from Src/Modules/zlib/zlib.net/history.txt rename to Modules/zlib/zlib.net/history.txt diff --git a/Src/Modules/zlib/zlib.net/license.txt b/Modules/zlib/zlib.net/license.txt similarity index 100% rename from Src/Modules/zlib/zlib.net/license.txt rename to Modules/zlib/zlib.net/license.txt diff --git a/Src/Modules/zlib/zlib.net/readme.txt b/Modules/zlib/zlib.net/readme.txt similarity index 100% rename from Src/Modules/zlib/zlib.net/readme.txt rename to Modules/zlib/zlib.net/readme.txt diff --git a/Src/SQLite/Connection.cs b/SQLite/Connection.cs similarity index 100% rename from Src/SQLite/Connection.cs rename to SQLite/Connection.cs diff --git a/Src/SQLite/Contants.cs b/SQLite/Contants.cs similarity index 100% rename from Src/SQLite/Contants.cs rename to SQLite/Contants.cs diff --git a/Src/SQLite/Cursor.cs b/SQLite/Cursor.cs similarity index 100% rename from Src/SQLite/Cursor.cs rename to SQLite/Cursor.cs diff --git a/Src/SQLite/Exceptions.cs b/SQLite/Exceptions.cs similarity index 100% rename from Src/SQLite/Exceptions.cs rename to SQLite/Exceptions.cs diff --git a/Src/SQLite/Extensions.cs b/SQLite/Extensions.cs similarity index 100% rename from Src/SQLite/Extensions.cs rename to SQLite/Extensions.cs diff --git a/Src/SQLite/IronPython.SQLite.csproj b/SQLite/IronPython.SQLite.csproj similarity index 100% rename from Src/SQLite/IronPython.SQLite.csproj rename to SQLite/IronPython.SQLite.csproj diff --git a/Src/SQLite/Properties/AssemblyInfo.cs b/SQLite/Properties/AssemblyInfo.cs similarity index 100% rename from Src/SQLite/Properties/AssemblyInfo.cs rename to SQLite/Properties/AssemblyInfo.cs diff --git a/Src/SQLite/Row.cs b/SQLite/Row.cs similarity index 100% rename from Src/SQLite/Row.cs rename to SQLite/Row.cs diff --git a/Src/SQLite/Statement.cs b/SQLite/Statement.cs similarity index 100% rename from Src/SQLite/Statement.cs rename to SQLite/Statement.cs diff --git a/Src/SQLite/Util.cs b/SQLite/Util.cs similarity index 100% rename from Src/SQLite/Util.cs rename to SQLite/Util.cs diff --git a/Src/SQLite/_sqlite.cs b/SQLite/_sqlite.cs similarity index 100% rename from Src/SQLite/_sqlite.cs rename to SQLite/_sqlite.cs diff --git a/Src/SQLite/c#sqlite/.editorconfig b/SQLite/c#sqlite/.editorconfig similarity index 100% rename from Src/SQLite/c#sqlite/.editorconfig rename to SQLite/c#sqlite/.editorconfig diff --git a/Src/SQLite/c#sqlite/BtreeInt_h.cs b/SQLite/c#sqlite/BtreeInt_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/BtreeInt_h.cs rename to SQLite/c#sqlite/BtreeInt_h.cs diff --git a/Src/SQLite/c#sqlite/Btree_h.cs b/SQLite/c#sqlite/Btree_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/Btree_h.cs rename to SQLite/c#sqlite/Btree_h.cs diff --git a/Src/SQLite/c#sqlite/Delegates.cs b/SQLite/c#sqlite/Delegates.cs similarity index 100% rename from Src/SQLite/c#sqlite/Delegates.cs rename to SQLite/c#sqlite/Delegates.cs diff --git a/Src/SQLite/c#sqlite/Hash_h.cs b/SQLite/c#sqlite/Hash_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/Hash_h.cs rename to SQLite/c#sqlite/Hash_h.cs diff --git a/Src/SQLite/c#sqlite/VdbeInt_h.cs b/SQLite/c#sqlite/VdbeInt_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/VdbeInt_h.cs rename to SQLite/c#sqlite/VdbeInt_h.cs diff --git a/Src/SQLite/c#sqlite/Vdbe_h.cs b/SQLite/c#sqlite/Vdbe_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/Vdbe_h.cs rename to SQLite/c#sqlite/Vdbe_h.cs diff --git a/Src/SQLite/c#sqlite/_Custom.cs b/SQLite/c#sqlite/_Custom.cs similarity index 100% rename from Src/SQLite/c#sqlite/_Custom.cs rename to SQLite/c#sqlite/_Custom.cs diff --git a/Src/SQLite/c#sqlite/alter_c.cs b/SQLite/c#sqlite/alter_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/alter_c.cs rename to SQLite/c#sqlite/alter_c.cs diff --git a/Src/SQLite/c#sqlite/analyze_c.cs b/SQLite/c#sqlite/analyze_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/analyze_c.cs rename to SQLite/c#sqlite/analyze_c.cs diff --git a/Src/SQLite/c#sqlite/attach_c.cs b/SQLite/c#sqlite/attach_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/attach_c.cs rename to SQLite/c#sqlite/attach_c.cs diff --git a/Src/SQLite/c#sqlite/auth_c.cs b/SQLite/c#sqlite/auth_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/auth_c.cs rename to SQLite/c#sqlite/auth_c.cs diff --git a/Src/SQLite/c#sqlite/backup_c.cs b/SQLite/c#sqlite/backup_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/backup_c.cs rename to SQLite/c#sqlite/backup_c.cs diff --git a/Src/SQLite/c#sqlite/bitvec_c.cs b/SQLite/c#sqlite/bitvec_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/bitvec_c.cs rename to SQLite/c#sqlite/bitvec_c.cs diff --git a/Src/SQLite/c#sqlite/btmutex_c.cs b/SQLite/c#sqlite/btmutex_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/btmutex_c.cs rename to SQLite/c#sqlite/btmutex_c.cs diff --git a/Src/SQLite/c#sqlite/btree_c.cs b/SQLite/c#sqlite/btree_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/btree_c.cs rename to SQLite/c#sqlite/btree_c.cs diff --git a/Src/SQLite/c#sqlite/build_c.cs b/SQLite/c#sqlite/build_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/build_c.cs rename to SQLite/c#sqlite/build_c.cs diff --git a/Src/SQLite/c#sqlite/callback_c.cs b/SQLite/c#sqlite/callback_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/callback_c.cs rename to SQLite/c#sqlite/callback_c.cs diff --git a/Src/SQLite/c#sqlite/complete_c.cs b/SQLite/c#sqlite/complete_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/complete_c.cs rename to SQLite/c#sqlite/complete_c.cs diff --git a/Src/SQLite/c#sqlite/crypto.cs b/SQLite/c#sqlite/crypto.cs similarity index 100% rename from Src/SQLite/c#sqlite/crypto.cs rename to SQLite/c#sqlite/crypto.cs diff --git a/Src/SQLite/c#sqlite/ctime_c.cs b/SQLite/c#sqlite/ctime_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/ctime_c.cs rename to SQLite/c#sqlite/ctime_c.cs diff --git a/Src/SQLite/c#sqlite/date_c.cs b/SQLite/c#sqlite/date_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/date_c.cs rename to SQLite/c#sqlite/date_c.cs diff --git a/Src/SQLite/c#sqlite/delete_c.cs b/SQLite/c#sqlite/delete_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/delete_c.cs rename to SQLite/c#sqlite/delete_c.cs diff --git a/Src/SQLite/c#sqlite/expr_c.cs b/SQLite/c#sqlite/expr_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/expr_c.cs rename to SQLite/c#sqlite/expr_c.cs diff --git a/Src/SQLite/c#sqlite/fault_c.cs b/SQLite/c#sqlite/fault_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/fault_c.cs rename to SQLite/c#sqlite/fault_c.cs diff --git a/Src/SQLite/c#sqlite/fkey_c.cs b/SQLite/c#sqlite/fkey_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/fkey_c.cs rename to SQLite/c#sqlite/fkey_c.cs diff --git a/Src/SQLite/c#sqlite/func_c.cs b/SQLite/c#sqlite/func_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/func_c.cs rename to SQLite/c#sqlite/func_c.cs diff --git a/Src/SQLite/c#sqlite/global_c.cs b/SQLite/c#sqlite/global_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/global_c.cs rename to SQLite/c#sqlite/global_c.cs diff --git a/Src/SQLite/c#sqlite/hash_c.cs b/SQLite/c#sqlite/hash_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/hash_c.cs rename to SQLite/c#sqlite/hash_c.cs diff --git a/Src/SQLite/c#sqlite/hwtime_c.cs b/SQLite/c#sqlite/hwtime_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/hwtime_c.cs rename to SQLite/c#sqlite/hwtime_c.cs diff --git a/Src/SQLite/c#sqlite/insert_c.cs b/SQLite/c#sqlite/insert_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/insert_c.cs rename to SQLite/c#sqlite/insert_c.cs diff --git a/Src/SQLite/c#sqlite/journal_c.cs b/SQLite/c#sqlite/journal_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/journal_c.cs rename to SQLite/c#sqlite/journal_c.cs diff --git a/Src/SQLite/c#sqlite/keywordhash_h.cs b/SQLite/c#sqlite/keywordhash_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/keywordhash_h.cs rename to SQLite/c#sqlite/keywordhash_h.cs diff --git a/Src/SQLite/c#sqlite/legacy_c.cs b/SQLite/c#sqlite/legacy_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/legacy_c.cs rename to SQLite/c#sqlite/legacy_c.cs diff --git a/Src/SQLite/c#sqlite/loadext_c.cs b/SQLite/c#sqlite/loadext_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/loadext_c.cs rename to SQLite/c#sqlite/loadext_c.cs diff --git a/Src/SQLite/c#sqlite/main_c.cs b/SQLite/c#sqlite/main_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/main_c.cs rename to SQLite/c#sqlite/main_c.cs diff --git a/Src/SQLite/c#sqlite/malloc_c.cs b/SQLite/c#sqlite/malloc_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/malloc_c.cs rename to SQLite/c#sqlite/malloc_c.cs diff --git a/Src/SQLite/c#sqlite/mem_Pool.cs b/SQLite/c#sqlite/mem_Pool.cs similarity index 100% rename from Src/SQLite/c#sqlite/mem_Pool.cs rename to SQLite/c#sqlite/mem_Pool.cs diff --git a/Src/SQLite/c#sqlite/memjournal_c.cs b/SQLite/c#sqlite/memjournal_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/memjournal_c.cs rename to SQLite/c#sqlite/memjournal_c.cs diff --git a/Src/SQLite/c#sqlite/mutex_c.cs b/SQLite/c#sqlite/mutex_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/mutex_c.cs rename to SQLite/c#sqlite/mutex_c.cs diff --git a/Src/SQLite/c#sqlite/mutex_h.cs b/SQLite/c#sqlite/mutex_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/mutex_h.cs rename to SQLite/c#sqlite/mutex_h.cs diff --git a/Src/SQLite/c#sqlite/mutex_noop_c.cs b/SQLite/c#sqlite/mutex_noop_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/mutex_noop_c.cs rename to SQLite/c#sqlite/mutex_noop_c.cs diff --git a/Src/SQLite/c#sqlite/mutex_w32.cs b/SQLite/c#sqlite/mutex_w32.cs similarity index 100% rename from Src/SQLite/c#sqlite/mutex_w32.cs rename to SQLite/c#sqlite/mutex_w32.cs diff --git a/Src/SQLite/c#sqlite/notify_c.cs b/SQLite/c#sqlite/notify_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/notify_c.cs rename to SQLite/c#sqlite/notify_c.cs diff --git a/Src/SQLite/c#sqlite/opcodes_c.cs b/SQLite/c#sqlite/opcodes_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/opcodes_c.cs rename to SQLite/c#sqlite/opcodes_c.cs diff --git a/Src/SQLite/c#sqlite/opcodes_h.cs b/SQLite/c#sqlite/opcodes_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/opcodes_h.cs rename to SQLite/c#sqlite/opcodes_h.cs diff --git a/Src/SQLite/c#sqlite/os_c.cs b/SQLite/c#sqlite/os_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/os_c.cs rename to SQLite/c#sqlite/os_c.cs diff --git a/Src/SQLite/c#sqlite/os_common_h.cs b/SQLite/c#sqlite/os_common_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/os_common_h.cs rename to SQLite/c#sqlite/os_common_h.cs diff --git a/Src/SQLite/c#sqlite/os_h.cs b/SQLite/c#sqlite/os_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/os_h.cs rename to SQLite/c#sqlite/os_h.cs diff --git a/Src/SQLite/c#sqlite/os_win_c.cs b/SQLite/c#sqlite/os_win_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/os_win_c.cs rename to SQLite/c#sqlite/os_win_c.cs diff --git a/Src/SQLite/c#sqlite/pager_c.cs b/SQLite/c#sqlite/pager_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/pager_c.cs rename to SQLite/c#sqlite/pager_c.cs diff --git a/Src/SQLite/c#sqlite/pager_h.cs b/SQLite/c#sqlite/pager_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/pager_h.cs rename to SQLite/c#sqlite/pager_h.cs diff --git a/Src/SQLite/c#sqlite/parse_c.cs b/SQLite/c#sqlite/parse_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/parse_c.cs rename to SQLite/c#sqlite/parse_c.cs diff --git a/Src/SQLite/c#sqlite/parse_h.cs b/SQLite/c#sqlite/parse_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/parse_h.cs rename to SQLite/c#sqlite/parse_h.cs diff --git a/Src/SQLite/c#sqlite/pcache1_c.cs b/SQLite/c#sqlite/pcache1_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/pcache1_c.cs rename to SQLite/c#sqlite/pcache1_c.cs diff --git a/Src/SQLite/c#sqlite/pcache_c.cs b/SQLite/c#sqlite/pcache_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/pcache_c.cs rename to SQLite/c#sqlite/pcache_c.cs diff --git a/Src/SQLite/c#sqlite/pcache_h.cs b/SQLite/c#sqlite/pcache_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/pcache_h.cs rename to SQLite/c#sqlite/pcache_h.cs diff --git a/Src/SQLite/c#sqlite/pragma_c.cs b/SQLite/c#sqlite/pragma_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/pragma_c.cs rename to SQLite/c#sqlite/pragma_c.cs diff --git a/Src/SQLite/c#sqlite/prepare_c.cs b/SQLite/c#sqlite/prepare_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/prepare_c.cs rename to SQLite/c#sqlite/prepare_c.cs diff --git a/Src/SQLite/c#sqlite/printf_c.cs b/SQLite/c#sqlite/printf_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/printf_c.cs rename to SQLite/c#sqlite/printf_c.cs diff --git a/Src/SQLite/c#sqlite/random_c.cs b/SQLite/c#sqlite/random_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/random_c.cs rename to SQLite/c#sqlite/random_c.cs diff --git a/Src/SQLite/c#sqlite/resolve_c.cs b/SQLite/c#sqlite/resolve_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/resolve_c.cs rename to SQLite/c#sqlite/resolve_c.cs diff --git a/Src/SQLite/c#sqlite/rowset_c.cs b/SQLite/c#sqlite/rowset_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/rowset_c.cs rename to SQLite/c#sqlite/rowset_c.cs diff --git a/Src/SQLite/c#sqlite/select_c.cs b/SQLite/c#sqlite/select_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/select_c.cs rename to SQLite/c#sqlite/select_c.cs diff --git a/Src/SQLite/c#sqlite/sqlite3_h.cs b/SQLite/c#sqlite/sqlite3_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/sqlite3_h.cs rename to SQLite/c#sqlite/sqlite3_h.cs diff --git a/Src/SQLite/c#sqlite/sqliteInt_h.cs b/SQLite/c#sqlite/sqliteInt_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/sqliteInt_h.cs rename to SQLite/c#sqlite/sqliteInt_h.cs diff --git a/Src/SQLite/c#sqlite/sqliteLimit_h.cs b/SQLite/c#sqlite/sqliteLimit_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/sqliteLimit_h.cs rename to SQLite/c#sqlite/sqliteLimit_h.cs diff --git a/Src/SQLite/c#sqlite/status_c.cs b/SQLite/c#sqlite/status_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/status_c.cs rename to SQLite/c#sqlite/status_c.cs diff --git a/Src/SQLite/c#sqlite/table_c.cs b/SQLite/c#sqlite/table_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/table_c.cs rename to SQLite/c#sqlite/table_c.cs diff --git a/Src/SQLite/c#sqlite/tokenize_c.cs b/SQLite/c#sqlite/tokenize_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/tokenize_c.cs rename to SQLite/c#sqlite/tokenize_c.cs diff --git a/Src/SQLite/c#sqlite/trigger_c.cs b/SQLite/c#sqlite/trigger_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/trigger_c.cs rename to SQLite/c#sqlite/trigger_c.cs diff --git a/Src/SQLite/c#sqlite/update_c.cs b/SQLite/c#sqlite/update_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/update_c.cs rename to SQLite/c#sqlite/update_c.cs diff --git a/Src/SQLite/c#sqlite/utf_c.cs b/SQLite/c#sqlite/utf_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/utf_c.cs rename to SQLite/c#sqlite/utf_c.cs diff --git a/Src/SQLite/c#sqlite/util_c.cs b/SQLite/c#sqlite/util_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/util_c.cs rename to SQLite/c#sqlite/util_c.cs diff --git a/Src/SQLite/c#sqlite/vacuum_c.cs b/SQLite/c#sqlite/vacuum_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/vacuum_c.cs rename to SQLite/c#sqlite/vacuum_c.cs diff --git a/Src/SQLite/c#sqlite/vdbe_c.cs b/SQLite/c#sqlite/vdbe_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/vdbe_c.cs rename to SQLite/c#sqlite/vdbe_c.cs diff --git a/Src/SQLite/c#sqlite/vdbeapi_c.cs b/SQLite/c#sqlite/vdbeapi_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/vdbeapi_c.cs rename to SQLite/c#sqlite/vdbeapi_c.cs diff --git a/Src/SQLite/c#sqlite/vdbeaux_c.cs b/SQLite/c#sqlite/vdbeaux_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/vdbeaux_c.cs rename to SQLite/c#sqlite/vdbeaux_c.cs diff --git a/Src/SQLite/c#sqlite/vdbeblob_c.cs b/SQLite/c#sqlite/vdbeblob_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/vdbeblob_c.cs rename to SQLite/c#sqlite/vdbeblob_c.cs diff --git a/Src/SQLite/c#sqlite/vdbemem_c.cs b/SQLite/c#sqlite/vdbemem_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/vdbemem_c.cs rename to SQLite/c#sqlite/vdbemem_c.cs diff --git a/Src/SQLite/c#sqlite/vdbetrace_c.cs b/SQLite/c#sqlite/vdbetrace_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/vdbetrace_c.cs rename to SQLite/c#sqlite/vdbetrace_c.cs diff --git a/Src/SQLite/c#sqlite/vtab_c.cs b/SQLite/c#sqlite/vtab_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/vtab_c.cs rename to SQLite/c#sqlite/vtab_c.cs diff --git a/Src/SQLite/c#sqlite/wal_c.cs b/SQLite/c#sqlite/wal_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/wal_c.cs rename to SQLite/c#sqlite/wal_c.cs diff --git a/Src/SQLite/c#sqlite/wal_h.cs b/SQLite/c#sqlite/wal_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/wal_h.cs rename to SQLite/c#sqlite/wal_h.cs diff --git a/Src/SQLite/c#sqlite/walker_c.cs b/SQLite/c#sqlite/walker_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/walker_c.cs rename to SQLite/c#sqlite/walker_c.cs diff --git a/Src/SQLite/c#sqlite/where_c.cs b/SQLite/c#sqlite/where_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/where_c.cs rename to SQLite/c#sqlite/where_c.cs diff --git a/Src/Scripts/CompareDirs.py b/Scripts/CompareDirs.py similarity index 100% rename from Src/Scripts/CompareDirs.py rename to Scripts/CompareDirs.py diff --git a/Src/Scripts/Enter-IronPythonEnvironment.ps1 b/Scripts/Enter-IronPythonEnvironment.ps1 similarity index 100% rename from Src/Scripts/Enter-IronPythonEnvironment.ps1 rename to Scripts/Enter-IronPythonEnvironment.ps1 diff --git a/Src/Scripts/Install-IronPython.ps1 b/Scripts/Install-IronPython.ps1 old mode 100755 new mode 100644 similarity index 100% rename from Src/Scripts/Install-IronPython.ps1 rename to Scripts/Install-IronPython.ps1 diff --git a/Src/Scripts/clean.py b/Scripts/clean.py similarity index 100% rename from Src/Scripts/clean.py rename to Scripts/clean.py diff --git a/Src/Scripts/copyrights.py b/Scripts/copyrights.py similarity index 100% rename from Src/Scripts/copyrights.py rename to Scripts/copyrights.py diff --git a/Src/Scripts/generate.py b/Scripts/generate.py old mode 100755 new mode 100644 similarity index 100% rename from Src/Scripts/generate.py rename to Scripts/generate.py diff --git a/Src/Scripts/generate_UncollectableCompilationMode.py b/Scripts/generate_UncollectableCompilationMode.py similarity index 100% rename from Src/Scripts/generate_UncollectableCompilationMode.py rename to Scripts/generate_UncollectableCompilationMode.py diff --git a/Src/Scripts/generate_alltypes.py b/Scripts/generate_alltypes.py similarity index 100% rename from Src/Scripts/generate_alltypes.py rename to Scripts/generate_alltypes.py diff --git a/Src/Scripts/generate_calls.py b/Scripts/generate_calls.py similarity index 100% rename from Src/Scripts/generate_calls.py rename to Scripts/generate_calls.py diff --git a/Src/Scripts/generate_casts.py b/Scripts/generate_casts.py similarity index 100% rename from Src/Scripts/generate_casts.py rename to Scripts/generate_casts.py diff --git a/Src/Scripts/generate_comdispatch.py b/Scripts/generate_comdispatch.py similarity index 100% rename from Src/Scripts/generate_comdispatch.py rename to Scripts/generate_comdispatch.py diff --git a/Src/Scripts/generate_dict_views.py b/Scripts/generate_dict_views.py similarity index 100% rename from Src/Scripts/generate_dict_views.py rename to Scripts/generate_dict_views.py diff --git a/Src/Scripts/generate_dynamic_instructions.py b/Scripts/generate_dynamic_instructions.py similarity index 100% rename from Src/Scripts/generate_dynamic_instructions.py rename to Scripts/generate_dynamic_instructions.py diff --git a/Src/Scripts/generate_dynsites.py b/Scripts/generate_dynsites.py similarity index 100% rename from Src/Scripts/generate_dynsites.py rename to Scripts/generate_dynsites.py diff --git a/Src/Scripts/generate_encoding_aliases.py b/Scripts/generate_encoding_aliases.py similarity index 100% rename from Src/Scripts/generate_encoding_aliases.py rename to Scripts/generate_encoding_aliases.py diff --git a/Src/Scripts/generate_exception_factory.py b/Scripts/generate_exception_factory.py similarity index 100% rename from Src/Scripts/generate_exception_factory.py rename to Scripts/generate_exception_factory.py diff --git a/Src/Scripts/generate_exceptions.py b/Scripts/generate_exceptions.py similarity index 100% rename from Src/Scripts/generate_exceptions.py rename to Scripts/generate_exceptions.py diff --git a/Src/Scripts/generate_indicestest.py b/Scripts/generate_indicestest.py similarity index 100% rename from Src/Scripts/generate_indicestest.py rename to Scripts/generate_indicestest.py diff --git a/Src/Scripts/generate_math.py b/Scripts/generate_math.py similarity index 100% rename from Src/Scripts/generate_math.py rename to Scripts/generate_math.py diff --git a/Src/Scripts/generate_ops.py b/Scripts/generate_ops.py old mode 100755 new mode 100644 similarity index 100% rename from Src/Scripts/generate_ops.py rename to Scripts/generate_ops.py diff --git a/Src/Scripts/generate_os_codes.py b/Scripts/generate_os_codes.py similarity index 100% rename from Src/Scripts/generate_os_codes.py rename to Scripts/generate_os_codes.py diff --git a/Src/Scripts/generate_reflected_calls.py b/Scripts/generate_reflected_calls.py similarity index 100% rename from Src/Scripts/generate_reflected_calls.py rename to Scripts/generate_reflected_calls.py diff --git a/Src/Scripts/generate_set.py b/Scripts/generate_set.py similarity index 100% rename from Src/Scripts/generate_set.py rename to Scripts/generate_set.py diff --git a/Src/Scripts/generate_tuples.py b/Scripts/generate_tuples.py similarity index 100% rename from Src/Scripts/generate_tuples.py rename to Scripts/generate_tuples.py diff --git a/Src/Scripts/generate_typecache.py b/Scripts/generate_typecache.py similarity index 100% rename from Src/Scripts/generate_typecache.py rename to Scripts/generate_typecache.py diff --git a/Src/Scripts/generate_walker.py b/Scripts/generate_walker.py similarity index 100% rename from Src/Scripts/generate_walker.py rename to Scripts/generate_walker.py diff --git a/Src/Scripts/ipcom.ps1 b/Scripts/ipcom.ps1 similarity index 100% rename from Src/Scripts/ipcom.ps1 rename to Scripts/ipcom.ps1 diff --git a/Src/Scripts/make_meta1.py b/Scripts/make_meta1.py similarity index 100% rename from Src/Scripts/make_meta1.py rename to Scripts/make_meta1.py diff --git a/Src/Scripts/radix_generator.py b/Scripts/radix_generator.py similarity index 100% rename from Src/Scripts/radix_generator.py rename to Scripts/radix_generator.py diff --git a/Src/Scripts/run_compiled.py b/Scripts/run_compiled.py similarity index 100% rename from Src/Scripts/run_compiled.py rename to Scripts/run_compiled.py diff --git a/Src/Scripts/run_interactive.py b/Scripts/run_interactive.py similarity index 100% rename from Src/Scripts/run_interactive.py rename to Scripts/run_interactive.py diff --git a/Src/Scripts/smtpmailer.py b/Scripts/smtpmailer.py similarity index 100% rename from Src/Scripts/smtpmailer.py rename to Scripts/smtpmailer.py diff --git a/Src/Scripts/test_builder.py b/Scripts/test_builder.py similarity index 100% rename from Src/Scripts/test_builder.py rename to Scripts/test_builder.py diff --git a/Src/Scripts/test_cgcheck.py b/Scripts/test_cgcheck.py similarity index 100% rename from Src/Scripts/test_cgcheck.py rename to Scripts/test_cgcheck.py diff --git a/Src/Scripts/test_parrot.py b/Scripts/test_parrot.py similarity index 100% rename from Src/Scripts/test_parrot.py rename to Scripts/test_parrot.py diff --git a/Src/Scripts/test_pystone.py b/Scripts/test_pystone.py similarity index 100% rename from Src/Scripts/test_pystone.py rename to Scripts/test_pystone.py diff --git a/Src/StdLib/.gitattributes b/StdLib/.gitattributes similarity index 100% rename from Src/StdLib/.gitattributes rename to StdLib/.gitattributes diff --git a/Src/StdLib/Lib/__future__.py b/StdLib/Lib/__future__.py similarity index 100% rename from Src/StdLib/Lib/__future__.py rename to StdLib/Lib/__future__.py diff --git a/Src/StdLib/Lib/__phello__.foo.py b/StdLib/Lib/__phello__.foo.py similarity index 100% rename from Src/StdLib/Lib/__phello__.foo.py rename to StdLib/Lib/__phello__.foo.py diff --git a/Src/StdLib/Lib/_bootlocale.py b/StdLib/Lib/_bootlocale.py similarity index 100% rename from Src/StdLib/Lib/_bootlocale.py rename to StdLib/Lib/_bootlocale.py diff --git a/Src/StdLib/Lib/_collections_abc.py b/StdLib/Lib/_collections_abc.py similarity index 100% rename from Src/StdLib/Lib/_collections_abc.py rename to StdLib/Lib/_collections_abc.py diff --git a/Src/StdLib/Lib/_compat_pickle.py b/StdLib/Lib/_compat_pickle.py similarity index 100% rename from Src/StdLib/Lib/_compat_pickle.py rename to StdLib/Lib/_compat_pickle.py diff --git a/Src/StdLib/Lib/_dummy_thread.py b/StdLib/Lib/_dummy_thread.py similarity index 100% rename from Src/StdLib/Lib/_dummy_thread.py rename to StdLib/Lib/_dummy_thread.py diff --git a/Src/StdLib/Lib/_markupbase.py b/StdLib/Lib/_markupbase.py similarity index 100% rename from Src/StdLib/Lib/_markupbase.py rename to StdLib/Lib/_markupbase.py diff --git a/Src/StdLib/Lib/_osx_support.py b/StdLib/Lib/_osx_support.py similarity index 100% rename from Src/StdLib/Lib/_osx_support.py rename to StdLib/Lib/_osx_support.py diff --git a/Src/StdLib/Lib/_pyio.py b/StdLib/Lib/_pyio.py similarity index 100% rename from Src/StdLib/Lib/_pyio.py rename to StdLib/Lib/_pyio.py diff --git a/Src/StdLib/Lib/_sitebuiltins.py b/StdLib/Lib/_sitebuiltins.py similarity index 100% rename from Src/StdLib/Lib/_sitebuiltins.py rename to StdLib/Lib/_sitebuiltins.py diff --git a/Src/StdLib/Lib/_strptime.py b/StdLib/Lib/_strptime.py similarity index 100% rename from Src/StdLib/Lib/_strptime.py rename to StdLib/Lib/_strptime.py diff --git a/Src/StdLib/Lib/_threading_local.py b/StdLib/Lib/_threading_local.py similarity index 100% rename from Src/StdLib/Lib/_threading_local.py rename to StdLib/Lib/_threading_local.py diff --git a/Src/StdLib/Lib/_weakrefset.py b/StdLib/Lib/_weakrefset.py similarity index 100% rename from Src/StdLib/Lib/_weakrefset.py rename to StdLib/Lib/_weakrefset.py diff --git a/Src/StdLib/Lib/abc.py b/StdLib/Lib/abc.py similarity index 100% rename from Src/StdLib/Lib/abc.py rename to StdLib/Lib/abc.py diff --git a/Src/StdLib/Lib/aifc.py b/StdLib/Lib/aifc.py similarity index 100% rename from Src/StdLib/Lib/aifc.py rename to StdLib/Lib/aifc.py diff --git a/Src/StdLib/Lib/antigravity.py b/StdLib/Lib/antigravity.py similarity index 100% rename from Src/StdLib/Lib/antigravity.py rename to StdLib/Lib/antigravity.py diff --git a/Src/StdLib/Lib/argparse.py b/StdLib/Lib/argparse.py similarity index 100% rename from Src/StdLib/Lib/argparse.py rename to StdLib/Lib/argparse.py diff --git a/Src/StdLib/Lib/ast.py b/StdLib/Lib/ast.py similarity index 100% rename from Src/StdLib/Lib/ast.py rename to StdLib/Lib/ast.py diff --git a/Src/StdLib/Lib/asynchat.py b/StdLib/Lib/asynchat.py similarity index 100% rename from Src/StdLib/Lib/asynchat.py rename to StdLib/Lib/asynchat.py diff --git a/Src/StdLib/Lib/asyncio/__init__.py b/StdLib/Lib/asyncio/__init__.py similarity index 100% rename from Src/StdLib/Lib/asyncio/__init__.py rename to StdLib/Lib/asyncio/__init__.py diff --git a/Src/StdLib/Lib/asyncio/base_events.py b/StdLib/Lib/asyncio/base_events.py similarity index 100% rename from Src/StdLib/Lib/asyncio/base_events.py rename to StdLib/Lib/asyncio/base_events.py diff --git a/Src/StdLib/Lib/asyncio/base_subprocess.py b/StdLib/Lib/asyncio/base_subprocess.py similarity index 100% rename from Src/StdLib/Lib/asyncio/base_subprocess.py rename to StdLib/Lib/asyncio/base_subprocess.py diff --git a/Src/StdLib/Lib/asyncio/compat.py b/StdLib/Lib/asyncio/compat.py similarity index 100% rename from Src/StdLib/Lib/asyncio/compat.py rename to StdLib/Lib/asyncio/compat.py diff --git a/Src/StdLib/Lib/asyncio/constants.py b/StdLib/Lib/asyncio/constants.py similarity index 100% rename from Src/StdLib/Lib/asyncio/constants.py rename to StdLib/Lib/asyncio/constants.py diff --git a/Src/StdLib/Lib/asyncio/coroutines.py b/StdLib/Lib/asyncio/coroutines.py similarity index 100% rename from Src/StdLib/Lib/asyncio/coroutines.py rename to StdLib/Lib/asyncio/coroutines.py diff --git a/Src/StdLib/Lib/asyncio/events.py b/StdLib/Lib/asyncio/events.py similarity index 100% rename from Src/StdLib/Lib/asyncio/events.py rename to StdLib/Lib/asyncio/events.py diff --git a/Src/StdLib/Lib/asyncio/futures.py b/StdLib/Lib/asyncio/futures.py similarity index 100% rename from Src/StdLib/Lib/asyncio/futures.py rename to StdLib/Lib/asyncio/futures.py diff --git a/Src/StdLib/Lib/asyncio/locks.py b/StdLib/Lib/asyncio/locks.py similarity index 100% rename from Src/StdLib/Lib/asyncio/locks.py rename to StdLib/Lib/asyncio/locks.py diff --git a/Src/StdLib/Lib/asyncio/log.py b/StdLib/Lib/asyncio/log.py similarity index 100% rename from Src/StdLib/Lib/asyncio/log.py rename to StdLib/Lib/asyncio/log.py diff --git a/Src/StdLib/Lib/asyncio/proactor_events.py b/StdLib/Lib/asyncio/proactor_events.py similarity index 100% rename from Src/StdLib/Lib/asyncio/proactor_events.py rename to StdLib/Lib/asyncio/proactor_events.py diff --git a/Src/StdLib/Lib/asyncio/protocols.py b/StdLib/Lib/asyncio/protocols.py similarity index 100% rename from Src/StdLib/Lib/asyncio/protocols.py rename to StdLib/Lib/asyncio/protocols.py diff --git a/Src/StdLib/Lib/asyncio/queues.py b/StdLib/Lib/asyncio/queues.py similarity index 100% rename from Src/StdLib/Lib/asyncio/queues.py rename to StdLib/Lib/asyncio/queues.py diff --git a/Src/StdLib/Lib/asyncio/selector_events.py b/StdLib/Lib/asyncio/selector_events.py similarity index 100% rename from Src/StdLib/Lib/asyncio/selector_events.py rename to StdLib/Lib/asyncio/selector_events.py diff --git a/Src/StdLib/Lib/asyncio/sslproto.py b/StdLib/Lib/asyncio/sslproto.py similarity index 100% rename from Src/StdLib/Lib/asyncio/sslproto.py rename to StdLib/Lib/asyncio/sslproto.py diff --git a/Src/StdLib/Lib/asyncio/streams.py b/StdLib/Lib/asyncio/streams.py similarity index 100% rename from Src/StdLib/Lib/asyncio/streams.py rename to StdLib/Lib/asyncio/streams.py diff --git a/Src/StdLib/Lib/asyncio/subprocess.py b/StdLib/Lib/asyncio/subprocess.py similarity index 100% rename from Src/StdLib/Lib/asyncio/subprocess.py rename to StdLib/Lib/asyncio/subprocess.py diff --git a/Src/StdLib/Lib/asyncio/tasks.py b/StdLib/Lib/asyncio/tasks.py similarity index 100% rename from Src/StdLib/Lib/asyncio/tasks.py rename to StdLib/Lib/asyncio/tasks.py diff --git a/Src/StdLib/Lib/asyncio/test_utils.py b/StdLib/Lib/asyncio/test_utils.py similarity index 100% rename from Src/StdLib/Lib/asyncio/test_utils.py rename to StdLib/Lib/asyncio/test_utils.py diff --git a/Src/StdLib/Lib/asyncio/transports.py b/StdLib/Lib/asyncio/transports.py similarity index 100% rename from Src/StdLib/Lib/asyncio/transports.py rename to StdLib/Lib/asyncio/transports.py diff --git a/Src/StdLib/Lib/asyncio/unix_events.py b/StdLib/Lib/asyncio/unix_events.py similarity index 100% rename from Src/StdLib/Lib/asyncio/unix_events.py rename to StdLib/Lib/asyncio/unix_events.py diff --git a/Src/StdLib/Lib/asyncio/windows_events.py b/StdLib/Lib/asyncio/windows_events.py similarity index 100% rename from Src/StdLib/Lib/asyncio/windows_events.py rename to StdLib/Lib/asyncio/windows_events.py diff --git a/Src/StdLib/Lib/asyncio/windows_utils.py b/StdLib/Lib/asyncio/windows_utils.py similarity index 100% rename from Src/StdLib/Lib/asyncio/windows_utils.py rename to StdLib/Lib/asyncio/windows_utils.py diff --git a/Src/StdLib/Lib/asyncore.py b/StdLib/Lib/asyncore.py similarity index 100% rename from Src/StdLib/Lib/asyncore.py rename to StdLib/Lib/asyncore.py diff --git a/Src/StdLib/Lib/base64.py b/StdLib/Lib/base64.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/base64.py rename to StdLib/Lib/base64.py diff --git a/Src/StdLib/Lib/bdb.py b/StdLib/Lib/bdb.py similarity index 100% rename from Src/StdLib/Lib/bdb.py rename to StdLib/Lib/bdb.py diff --git a/Src/StdLib/Lib/binhex.py b/StdLib/Lib/binhex.py similarity index 100% rename from Src/StdLib/Lib/binhex.py rename to StdLib/Lib/binhex.py diff --git a/Src/StdLib/Lib/bisect.py b/StdLib/Lib/bisect.py similarity index 100% rename from Src/StdLib/Lib/bisect.py rename to StdLib/Lib/bisect.py diff --git a/Src/StdLib/Lib/bz2.py b/StdLib/Lib/bz2.py similarity index 100% rename from Src/StdLib/Lib/bz2.py rename to StdLib/Lib/bz2.py diff --git a/Src/StdLib/Lib/cProfile.py b/StdLib/Lib/cProfile.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/cProfile.py rename to StdLib/Lib/cProfile.py diff --git a/Src/StdLib/Lib/calendar.py b/StdLib/Lib/calendar.py similarity index 100% rename from Src/StdLib/Lib/calendar.py rename to StdLib/Lib/calendar.py diff --git a/Src/StdLib/Lib/cgi.py b/StdLib/Lib/cgi.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/cgi.py rename to StdLib/Lib/cgi.py diff --git a/Src/StdLib/Lib/cgitb.py b/StdLib/Lib/cgitb.py similarity index 100% rename from Src/StdLib/Lib/cgitb.py rename to StdLib/Lib/cgitb.py diff --git a/Src/StdLib/Lib/chunk.py b/StdLib/Lib/chunk.py similarity index 100% rename from Src/StdLib/Lib/chunk.py rename to StdLib/Lib/chunk.py diff --git a/Src/StdLib/Lib/clrtype.py b/StdLib/Lib/clrtype.py similarity index 100% rename from Src/StdLib/Lib/clrtype.py rename to StdLib/Lib/clrtype.py diff --git a/Src/StdLib/Lib/cmd.py b/StdLib/Lib/cmd.py similarity index 100% rename from Src/StdLib/Lib/cmd.py rename to StdLib/Lib/cmd.py diff --git a/Src/StdLib/Lib/code.py b/StdLib/Lib/code.py similarity index 100% rename from Src/StdLib/Lib/code.py rename to StdLib/Lib/code.py diff --git a/Src/StdLib/Lib/codecs.py b/StdLib/Lib/codecs.py similarity index 100% rename from Src/StdLib/Lib/codecs.py rename to StdLib/Lib/codecs.py diff --git a/Src/StdLib/Lib/codeop.py b/StdLib/Lib/codeop.py similarity index 100% rename from Src/StdLib/Lib/codeop.py rename to StdLib/Lib/codeop.py diff --git a/Src/StdLib/Lib/collections/__init__.py b/StdLib/Lib/collections/__init__.py similarity index 100% rename from Src/StdLib/Lib/collections/__init__.py rename to StdLib/Lib/collections/__init__.py diff --git a/Src/StdLib/Lib/collections/__main__.py b/StdLib/Lib/collections/__main__.py similarity index 100% rename from Src/StdLib/Lib/collections/__main__.py rename to StdLib/Lib/collections/__main__.py diff --git a/Src/StdLib/Lib/collections/abc.py b/StdLib/Lib/collections/abc.py similarity index 100% rename from Src/StdLib/Lib/collections/abc.py rename to StdLib/Lib/collections/abc.py diff --git a/Src/StdLib/Lib/colorsys.py b/StdLib/Lib/colorsys.py similarity index 100% rename from Src/StdLib/Lib/colorsys.py rename to StdLib/Lib/colorsys.py diff --git a/Src/StdLib/Lib/compileall.py b/StdLib/Lib/compileall.py similarity index 100% rename from Src/StdLib/Lib/compileall.py rename to StdLib/Lib/compileall.py diff --git a/Src/StdLib/Lib/concurrent/__init__.py b/StdLib/Lib/concurrent/__init__.py similarity index 100% rename from Src/StdLib/Lib/concurrent/__init__.py rename to StdLib/Lib/concurrent/__init__.py diff --git a/Src/StdLib/Lib/concurrent/futures/__init__.py b/StdLib/Lib/concurrent/futures/__init__.py similarity index 100% rename from Src/StdLib/Lib/concurrent/futures/__init__.py rename to StdLib/Lib/concurrent/futures/__init__.py diff --git a/Src/StdLib/Lib/concurrent/futures/_base.py b/StdLib/Lib/concurrent/futures/_base.py similarity index 100% rename from Src/StdLib/Lib/concurrent/futures/_base.py rename to StdLib/Lib/concurrent/futures/_base.py diff --git a/Src/StdLib/Lib/concurrent/futures/process.py b/StdLib/Lib/concurrent/futures/process.py similarity index 100% rename from Src/StdLib/Lib/concurrent/futures/process.py rename to StdLib/Lib/concurrent/futures/process.py diff --git a/Src/StdLib/Lib/concurrent/futures/thread.py b/StdLib/Lib/concurrent/futures/thread.py similarity index 100% rename from Src/StdLib/Lib/concurrent/futures/thread.py rename to StdLib/Lib/concurrent/futures/thread.py diff --git a/Src/StdLib/Lib/configparser.py b/StdLib/Lib/configparser.py similarity index 100% rename from Src/StdLib/Lib/configparser.py rename to StdLib/Lib/configparser.py diff --git a/Src/StdLib/Lib/contextlib.py b/StdLib/Lib/contextlib.py similarity index 100% rename from Src/StdLib/Lib/contextlib.py rename to StdLib/Lib/contextlib.py diff --git a/Src/StdLib/Lib/copy.py b/StdLib/Lib/copy.py similarity index 100% rename from Src/StdLib/Lib/copy.py rename to StdLib/Lib/copy.py diff --git a/Src/StdLib/Lib/copyreg.py b/StdLib/Lib/copyreg.py similarity index 100% rename from Src/StdLib/Lib/copyreg.py rename to StdLib/Lib/copyreg.py diff --git a/Src/StdLib/Lib/crypt.py b/StdLib/Lib/crypt.py similarity index 100% rename from Src/StdLib/Lib/crypt.py rename to StdLib/Lib/crypt.py diff --git a/Src/StdLib/Lib/csv.py b/StdLib/Lib/csv.py similarity index 100% rename from Src/StdLib/Lib/csv.py rename to StdLib/Lib/csv.py diff --git a/Src/StdLib/Lib/ctypes/__init__.py b/StdLib/Lib/ctypes/__init__.py similarity index 100% rename from Src/StdLib/Lib/ctypes/__init__.py rename to StdLib/Lib/ctypes/__init__.py diff --git a/Src/StdLib/Lib/ctypes/_endian.py b/StdLib/Lib/ctypes/_endian.py similarity index 100% rename from Src/StdLib/Lib/ctypes/_endian.py rename to StdLib/Lib/ctypes/_endian.py diff --git a/Src/StdLib/Lib/ctypes/macholib/README.ctypes b/StdLib/Lib/ctypes/macholib/README.ctypes similarity index 100% rename from Src/StdLib/Lib/ctypes/macholib/README.ctypes rename to StdLib/Lib/ctypes/macholib/README.ctypes diff --git a/Src/StdLib/Lib/ctypes/macholib/__init__.py b/StdLib/Lib/ctypes/macholib/__init__.py similarity index 100% rename from Src/StdLib/Lib/ctypes/macholib/__init__.py rename to StdLib/Lib/ctypes/macholib/__init__.py diff --git a/Src/StdLib/Lib/ctypes/macholib/dyld.py b/StdLib/Lib/ctypes/macholib/dyld.py similarity index 100% rename from Src/StdLib/Lib/ctypes/macholib/dyld.py rename to StdLib/Lib/ctypes/macholib/dyld.py diff --git a/Src/StdLib/Lib/ctypes/macholib/dylib.py b/StdLib/Lib/ctypes/macholib/dylib.py similarity index 100% rename from Src/StdLib/Lib/ctypes/macholib/dylib.py rename to StdLib/Lib/ctypes/macholib/dylib.py diff --git a/Src/StdLib/Lib/ctypes/macholib/fetch_macholib b/StdLib/Lib/ctypes/macholib/fetch_macholib old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/ctypes/macholib/fetch_macholib rename to StdLib/Lib/ctypes/macholib/fetch_macholib diff --git a/Src/StdLib/Lib/ctypes/macholib/fetch_macholib.bat b/StdLib/Lib/ctypes/macholib/fetch_macholib.bat similarity index 100% rename from Src/StdLib/Lib/ctypes/macholib/fetch_macholib.bat rename to StdLib/Lib/ctypes/macholib/fetch_macholib.bat diff --git a/Src/StdLib/Lib/ctypes/macholib/framework.py b/StdLib/Lib/ctypes/macholib/framework.py similarity index 100% rename from Src/StdLib/Lib/ctypes/macholib/framework.py rename to StdLib/Lib/ctypes/macholib/framework.py diff --git a/Src/StdLib/Lib/ctypes/test/__init__.py b/StdLib/Lib/ctypes/test/__init__.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/__init__.py rename to StdLib/Lib/ctypes/test/__init__.py diff --git a/Src/StdLib/Lib/ctypes/test/__main__.py b/StdLib/Lib/ctypes/test/__main__.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/__main__.py rename to StdLib/Lib/ctypes/test/__main__.py diff --git a/Src/StdLib/Lib/ctypes/test/test_anon.py b/StdLib/Lib/ctypes/test/test_anon.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_anon.py rename to StdLib/Lib/ctypes/test/test_anon.py diff --git a/Src/StdLib/Lib/ctypes/test/test_array_in_pointer.py b/StdLib/Lib/ctypes/test/test_array_in_pointer.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_array_in_pointer.py rename to StdLib/Lib/ctypes/test/test_array_in_pointer.py diff --git a/Src/StdLib/Lib/ctypes/test/test_arrays.py b/StdLib/Lib/ctypes/test/test_arrays.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_arrays.py rename to StdLib/Lib/ctypes/test/test_arrays.py diff --git a/Src/StdLib/Lib/ctypes/test/test_as_parameter.py b/StdLib/Lib/ctypes/test/test_as_parameter.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_as_parameter.py rename to StdLib/Lib/ctypes/test/test_as_parameter.py diff --git a/Src/StdLib/Lib/ctypes/test/test_bitfields.py b/StdLib/Lib/ctypes/test/test_bitfields.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_bitfields.py rename to StdLib/Lib/ctypes/test/test_bitfields.py diff --git a/Src/StdLib/Lib/ctypes/test/test_buffers.py b/StdLib/Lib/ctypes/test/test_buffers.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_buffers.py rename to StdLib/Lib/ctypes/test/test_buffers.py diff --git a/Src/StdLib/Lib/ctypes/test/test_bytes.py b/StdLib/Lib/ctypes/test/test_bytes.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_bytes.py rename to StdLib/Lib/ctypes/test/test_bytes.py diff --git a/Src/StdLib/Lib/ctypes/test/test_byteswap.py b/StdLib/Lib/ctypes/test/test_byteswap.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_byteswap.py rename to StdLib/Lib/ctypes/test/test_byteswap.py diff --git a/Src/StdLib/Lib/ctypes/test/test_callbacks.py b/StdLib/Lib/ctypes/test/test_callbacks.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_callbacks.py rename to StdLib/Lib/ctypes/test/test_callbacks.py diff --git a/Src/StdLib/Lib/ctypes/test/test_cast.py b/StdLib/Lib/ctypes/test/test_cast.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_cast.py rename to StdLib/Lib/ctypes/test/test_cast.py diff --git a/Src/StdLib/Lib/ctypes/test/test_cfuncs.py b/StdLib/Lib/ctypes/test/test_cfuncs.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_cfuncs.py rename to StdLib/Lib/ctypes/test/test_cfuncs.py diff --git a/Src/StdLib/Lib/ctypes/test/test_checkretval.py b/StdLib/Lib/ctypes/test/test_checkretval.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_checkretval.py rename to StdLib/Lib/ctypes/test/test_checkretval.py diff --git a/Src/StdLib/Lib/ctypes/test/test_delattr.py b/StdLib/Lib/ctypes/test/test_delattr.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_delattr.py rename to StdLib/Lib/ctypes/test/test_delattr.py diff --git a/Src/StdLib/Lib/ctypes/test/test_errno.py b/StdLib/Lib/ctypes/test/test_errno.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_errno.py rename to StdLib/Lib/ctypes/test/test_errno.py diff --git a/Src/StdLib/Lib/ctypes/test/test_find.py b/StdLib/Lib/ctypes/test/test_find.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_find.py rename to StdLib/Lib/ctypes/test/test_find.py diff --git a/Src/StdLib/Lib/ctypes/test/test_frombuffer.py b/StdLib/Lib/ctypes/test/test_frombuffer.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_frombuffer.py rename to StdLib/Lib/ctypes/test/test_frombuffer.py diff --git a/Src/StdLib/Lib/ctypes/test/test_funcptr.py b/StdLib/Lib/ctypes/test/test_funcptr.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_funcptr.py rename to StdLib/Lib/ctypes/test/test_funcptr.py diff --git a/Src/StdLib/Lib/ctypes/test/test_functions.py b/StdLib/Lib/ctypes/test/test_functions.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_functions.py rename to StdLib/Lib/ctypes/test/test_functions.py diff --git a/Src/StdLib/Lib/ctypes/test/test_incomplete.py b/StdLib/Lib/ctypes/test/test_incomplete.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_incomplete.py rename to StdLib/Lib/ctypes/test/test_incomplete.py diff --git a/Src/StdLib/Lib/ctypes/test/test_init.py b/StdLib/Lib/ctypes/test/test_init.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_init.py rename to StdLib/Lib/ctypes/test/test_init.py diff --git a/Src/StdLib/Lib/ctypes/test/test_internals.py b/StdLib/Lib/ctypes/test/test_internals.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_internals.py rename to StdLib/Lib/ctypes/test/test_internals.py diff --git a/Src/StdLib/Lib/ctypes/test/test_keeprefs.py b/StdLib/Lib/ctypes/test/test_keeprefs.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_keeprefs.py rename to StdLib/Lib/ctypes/test/test_keeprefs.py diff --git a/Src/StdLib/Lib/ctypes/test/test_libc.py b/StdLib/Lib/ctypes/test/test_libc.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_libc.py rename to StdLib/Lib/ctypes/test/test_libc.py diff --git a/Src/StdLib/Lib/ctypes/test/test_loading.py b/StdLib/Lib/ctypes/test/test_loading.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_loading.py rename to StdLib/Lib/ctypes/test/test_loading.py diff --git a/Src/StdLib/Lib/ctypes/test/test_macholib.py b/StdLib/Lib/ctypes/test/test_macholib.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_macholib.py rename to StdLib/Lib/ctypes/test/test_macholib.py diff --git a/Src/StdLib/Lib/ctypes/test/test_memfunctions.py b/StdLib/Lib/ctypes/test/test_memfunctions.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_memfunctions.py rename to StdLib/Lib/ctypes/test/test_memfunctions.py diff --git a/Src/StdLib/Lib/ctypes/test/test_numbers.py b/StdLib/Lib/ctypes/test/test_numbers.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_numbers.py rename to StdLib/Lib/ctypes/test/test_numbers.py diff --git a/Src/StdLib/Lib/ctypes/test/test_objects.py b/StdLib/Lib/ctypes/test/test_objects.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_objects.py rename to StdLib/Lib/ctypes/test/test_objects.py diff --git a/Src/StdLib/Lib/ctypes/test/test_parameters.py b/StdLib/Lib/ctypes/test/test_parameters.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_parameters.py rename to StdLib/Lib/ctypes/test/test_parameters.py diff --git a/Src/StdLib/Lib/ctypes/test/test_pep3118.py b/StdLib/Lib/ctypes/test/test_pep3118.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_pep3118.py rename to StdLib/Lib/ctypes/test/test_pep3118.py diff --git a/Src/StdLib/Lib/ctypes/test/test_pickling.py b/StdLib/Lib/ctypes/test/test_pickling.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_pickling.py rename to StdLib/Lib/ctypes/test/test_pickling.py diff --git a/Src/StdLib/Lib/ctypes/test/test_pointers.py b/StdLib/Lib/ctypes/test/test_pointers.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_pointers.py rename to StdLib/Lib/ctypes/test/test_pointers.py diff --git a/Src/StdLib/Lib/ctypes/test/test_prototypes.py b/StdLib/Lib/ctypes/test/test_prototypes.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_prototypes.py rename to StdLib/Lib/ctypes/test/test_prototypes.py diff --git a/Src/StdLib/Lib/ctypes/test/test_python_api.py b/StdLib/Lib/ctypes/test/test_python_api.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_python_api.py rename to StdLib/Lib/ctypes/test/test_python_api.py diff --git a/Src/StdLib/Lib/ctypes/test/test_random_things.py b/StdLib/Lib/ctypes/test/test_random_things.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_random_things.py rename to StdLib/Lib/ctypes/test/test_random_things.py diff --git a/Src/StdLib/Lib/ctypes/test/test_refcounts.py b/StdLib/Lib/ctypes/test/test_refcounts.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_refcounts.py rename to StdLib/Lib/ctypes/test/test_refcounts.py diff --git a/Src/StdLib/Lib/ctypes/test/test_repr.py b/StdLib/Lib/ctypes/test/test_repr.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_repr.py rename to StdLib/Lib/ctypes/test/test_repr.py diff --git a/Src/StdLib/Lib/ctypes/test/test_returnfuncptrs.py b/StdLib/Lib/ctypes/test/test_returnfuncptrs.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_returnfuncptrs.py rename to StdLib/Lib/ctypes/test/test_returnfuncptrs.py diff --git a/Src/StdLib/Lib/ctypes/test/test_simplesubclasses.py b/StdLib/Lib/ctypes/test/test_simplesubclasses.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_simplesubclasses.py rename to StdLib/Lib/ctypes/test/test_simplesubclasses.py diff --git a/Src/StdLib/Lib/ctypes/test/test_sizes.py b/StdLib/Lib/ctypes/test/test_sizes.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_sizes.py rename to StdLib/Lib/ctypes/test/test_sizes.py diff --git a/Src/StdLib/Lib/ctypes/test/test_slicing.py b/StdLib/Lib/ctypes/test/test_slicing.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_slicing.py rename to StdLib/Lib/ctypes/test/test_slicing.py diff --git a/Src/StdLib/Lib/ctypes/test/test_stringptr.py b/StdLib/Lib/ctypes/test/test_stringptr.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_stringptr.py rename to StdLib/Lib/ctypes/test/test_stringptr.py diff --git a/Src/StdLib/Lib/ctypes/test/test_strings.py b/StdLib/Lib/ctypes/test/test_strings.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_strings.py rename to StdLib/Lib/ctypes/test/test_strings.py diff --git a/Src/StdLib/Lib/ctypes/test/test_struct_fields.py b/StdLib/Lib/ctypes/test/test_struct_fields.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_struct_fields.py rename to StdLib/Lib/ctypes/test/test_struct_fields.py diff --git a/Src/StdLib/Lib/ctypes/test/test_structures.py b/StdLib/Lib/ctypes/test/test_structures.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_structures.py rename to StdLib/Lib/ctypes/test/test_structures.py diff --git a/Src/StdLib/Lib/ctypes/test/test_unaligned_structures.py b/StdLib/Lib/ctypes/test/test_unaligned_structures.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_unaligned_structures.py rename to StdLib/Lib/ctypes/test/test_unaligned_structures.py diff --git a/Src/StdLib/Lib/ctypes/test/test_unicode.py b/StdLib/Lib/ctypes/test/test_unicode.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_unicode.py rename to StdLib/Lib/ctypes/test/test_unicode.py diff --git a/Src/StdLib/Lib/ctypes/test/test_values.py b/StdLib/Lib/ctypes/test/test_values.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_values.py rename to StdLib/Lib/ctypes/test/test_values.py diff --git a/Src/StdLib/Lib/ctypes/test/test_varsize_struct.py b/StdLib/Lib/ctypes/test/test_varsize_struct.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_varsize_struct.py rename to StdLib/Lib/ctypes/test/test_varsize_struct.py diff --git a/Src/StdLib/Lib/ctypes/test/test_win32.py b/StdLib/Lib/ctypes/test/test_win32.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_win32.py rename to StdLib/Lib/ctypes/test/test_win32.py diff --git a/Src/StdLib/Lib/ctypes/test/test_wintypes.py b/StdLib/Lib/ctypes/test/test_wintypes.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_wintypes.py rename to StdLib/Lib/ctypes/test/test_wintypes.py diff --git a/Src/StdLib/Lib/ctypes/util.py b/StdLib/Lib/ctypes/util.py similarity index 100% rename from Src/StdLib/Lib/ctypes/util.py rename to StdLib/Lib/ctypes/util.py diff --git a/Src/StdLib/Lib/ctypes/wintypes.py b/StdLib/Lib/ctypes/wintypes.py similarity index 100% rename from Src/StdLib/Lib/ctypes/wintypes.py rename to StdLib/Lib/ctypes/wintypes.py diff --git a/Src/StdLib/Lib/curses/__init__.py b/StdLib/Lib/curses/__init__.py similarity index 100% rename from Src/StdLib/Lib/curses/__init__.py rename to StdLib/Lib/curses/__init__.py diff --git a/Src/StdLib/Lib/curses/ascii.py b/StdLib/Lib/curses/ascii.py similarity index 100% rename from Src/StdLib/Lib/curses/ascii.py rename to StdLib/Lib/curses/ascii.py diff --git a/Src/StdLib/Lib/curses/has_key.py b/StdLib/Lib/curses/has_key.py similarity index 100% rename from Src/StdLib/Lib/curses/has_key.py rename to StdLib/Lib/curses/has_key.py diff --git a/Src/StdLib/Lib/curses/panel.py b/StdLib/Lib/curses/panel.py similarity index 100% rename from Src/StdLib/Lib/curses/panel.py rename to StdLib/Lib/curses/panel.py diff --git a/Src/StdLib/Lib/curses/textpad.py b/StdLib/Lib/curses/textpad.py similarity index 100% rename from Src/StdLib/Lib/curses/textpad.py rename to StdLib/Lib/curses/textpad.py diff --git a/Src/StdLib/Lib/datetime.py b/StdLib/Lib/datetime.py similarity index 100% rename from Src/StdLib/Lib/datetime.py rename to StdLib/Lib/datetime.py diff --git a/Src/StdLib/Lib/dbm/__init__.py b/StdLib/Lib/dbm/__init__.py similarity index 100% rename from Src/StdLib/Lib/dbm/__init__.py rename to StdLib/Lib/dbm/__init__.py diff --git a/Src/StdLib/Lib/dbm/dumb.py b/StdLib/Lib/dbm/dumb.py similarity index 100% rename from Src/StdLib/Lib/dbm/dumb.py rename to StdLib/Lib/dbm/dumb.py diff --git a/Src/StdLib/Lib/dbm/gnu.py b/StdLib/Lib/dbm/gnu.py similarity index 100% rename from Src/StdLib/Lib/dbm/gnu.py rename to StdLib/Lib/dbm/gnu.py diff --git a/Src/StdLib/Lib/dbm/ndbm.py b/StdLib/Lib/dbm/ndbm.py similarity index 100% rename from Src/StdLib/Lib/dbm/ndbm.py rename to StdLib/Lib/dbm/ndbm.py diff --git a/Src/StdLib/Lib/decimal.py b/StdLib/Lib/decimal.py similarity index 100% rename from Src/StdLib/Lib/decimal.py rename to StdLib/Lib/decimal.py diff --git a/Src/StdLib/Lib/difflib.py b/StdLib/Lib/difflib.py similarity index 100% rename from Src/StdLib/Lib/difflib.py rename to StdLib/Lib/difflib.py diff --git a/Src/StdLib/Lib/dis.py b/StdLib/Lib/dis.py similarity index 100% rename from Src/StdLib/Lib/dis.py rename to StdLib/Lib/dis.py diff --git a/Src/StdLib/Lib/distutils/README b/StdLib/Lib/distutils/README similarity index 100% rename from Src/StdLib/Lib/distutils/README rename to StdLib/Lib/distutils/README diff --git a/Src/StdLib/Lib/distutils/__init__.py b/StdLib/Lib/distutils/__init__.py similarity index 100% rename from Src/StdLib/Lib/distutils/__init__.py rename to StdLib/Lib/distutils/__init__.py diff --git a/Src/StdLib/Lib/distutils/archive_util.py b/StdLib/Lib/distutils/archive_util.py similarity index 100% rename from Src/StdLib/Lib/distutils/archive_util.py rename to StdLib/Lib/distutils/archive_util.py diff --git a/Src/StdLib/Lib/distutils/bcppcompiler.py b/StdLib/Lib/distutils/bcppcompiler.py similarity index 100% rename from Src/StdLib/Lib/distutils/bcppcompiler.py rename to StdLib/Lib/distutils/bcppcompiler.py diff --git a/Src/StdLib/Lib/distutils/ccompiler.py b/StdLib/Lib/distutils/ccompiler.py similarity index 100% rename from Src/StdLib/Lib/distutils/ccompiler.py rename to StdLib/Lib/distutils/ccompiler.py diff --git a/Src/StdLib/Lib/distutils/cmd.py b/StdLib/Lib/distutils/cmd.py similarity index 100% rename from Src/StdLib/Lib/distutils/cmd.py rename to StdLib/Lib/distutils/cmd.py diff --git a/Src/StdLib/Lib/distutils/command/__init__.py b/StdLib/Lib/distutils/command/__init__.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/__init__.py rename to StdLib/Lib/distutils/command/__init__.py diff --git a/Src/StdLib/Lib/distutils/command/bdist.py b/StdLib/Lib/distutils/command/bdist.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/bdist.py rename to StdLib/Lib/distutils/command/bdist.py diff --git a/Src/StdLib/Lib/distutils/command/bdist_dumb.py b/StdLib/Lib/distutils/command/bdist_dumb.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/bdist_dumb.py rename to StdLib/Lib/distutils/command/bdist_dumb.py diff --git a/Src/StdLib/Lib/distutils/command/bdist_msi.py b/StdLib/Lib/distutils/command/bdist_msi.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/bdist_msi.py rename to StdLib/Lib/distutils/command/bdist_msi.py diff --git a/Src/StdLib/Lib/distutils/command/bdist_rpm.py b/StdLib/Lib/distutils/command/bdist_rpm.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/bdist_rpm.py rename to StdLib/Lib/distutils/command/bdist_rpm.py diff --git a/Src/StdLib/Lib/distutils/command/bdist_wininst.py b/StdLib/Lib/distutils/command/bdist_wininst.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/bdist_wininst.py rename to StdLib/Lib/distutils/command/bdist_wininst.py diff --git a/Src/StdLib/Lib/distutils/command/build.py b/StdLib/Lib/distutils/command/build.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/build.py rename to StdLib/Lib/distutils/command/build.py diff --git a/Src/StdLib/Lib/distutils/command/build_clib.py b/StdLib/Lib/distutils/command/build_clib.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/build_clib.py rename to StdLib/Lib/distutils/command/build_clib.py diff --git a/Src/StdLib/Lib/distutils/command/build_ext.py b/StdLib/Lib/distutils/command/build_ext.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/build_ext.py rename to StdLib/Lib/distutils/command/build_ext.py diff --git a/Src/StdLib/Lib/distutils/command/build_py.py b/StdLib/Lib/distutils/command/build_py.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/build_py.py rename to StdLib/Lib/distutils/command/build_py.py diff --git a/Src/StdLib/Lib/distutils/command/build_scripts.py b/StdLib/Lib/distutils/command/build_scripts.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/build_scripts.py rename to StdLib/Lib/distutils/command/build_scripts.py diff --git a/Src/StdLib/Lib/distutils/command/check.py b/StdLib/Lib/distutils/command/check.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/check.py rename to StdLib/Lib/distutils/command/check.py diff --git a/Src/StdLib/Lib/distutils/command/clean.py b/StdLib/Lib/distutils/command/clean.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/clean.py rename to StdLib/Lib/distutils/command/clean.py diff --git a/Src/StdLib/Lib/distutils/command/command_template b/StdLib/Lib/distutils/command/command_template similarity index 100% rename from Src/StdLib/Lib/distutils/command/command_template rename to StdLib/Lib/distutils/command/command_template diff --git a/Src/StdLib/Lib/distutils/command/config.py b/StdLib/Lib/distutils/command/config.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/config.py rename to StdLib/Lib/distutils/command/config.py diff --git a/Src/StdLib/Lib/distutils/command/install.py b/StdLib/Lib/distutils/command/install.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/install.py rename to StdLib/Lib/distutils/command/install.py diff --git a/Src/StdLib/Lib/distutils/command/install_data.py b/StdLib/Lib/distutils/command/install_data.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/install_data.py rename to StdLib/Lib/distutils/command/install_data.py diff --git a/Src/StdLib/Lib/distutils/command/install_egg_info.py b/StdLib/Lib/distutils/command/install_egg_info.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/install_egg_info.py rename to StdLib/Lib/distutils/command/install_egg_info.py diff --git a/Src/StdLib/Lib/distutils/command/install_headers.py b/StdLib/Lib/distutils/command/install_headers.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/install_headers.py rename to StdLib/Lib/distutils/command/install_headers.py diff --git a/Src/StdLib/Lib/distutils/command/install_lib.py b/StdLib/Lib/distutils/command/install_lib.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/install_lib.py rename to StdLib/Lib/distutils/command/install_lib.py diff --git a/Src/StdLib/Lib/distutils/command/install_scripts.py b/StdLib/Lib/distutils/command/install_scripts.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/install_scripts.py rename to StdLib/Lib/distutils/command/install_scripts.py diff --git a/Src/StdLib/Lib/distutils/command/register.py b/StdLib/Lib/distutils/command/register.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/register.py rename to StdLib/Lib/distutils/command/register.py diff --git a/Src/StdLib/Lib/distutils/command/sdist.py b/StdLib/Lib/distutils/command/sdist.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/sdist.py rename to StdLib/Lib/distutils/command/sdist.py diff --git a/Src/StdLib/Lib/distutils/command/upload.py b/StdLib/Lib/distutils/command/upload.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/upload.py rename to StdLib/Lib/distutils/command/upload.py diff --git a/Src/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe b/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe similarity index 100% rename from Src/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe rename to StdLib/Lib/distutils/command/wininst-10.0-amd64.exe diff --git a/Src/StdLib/Lib/distutils/command/wininst-10.0.exe b/StdLib/Lib/distutils/command/wininst-10.0.exe similarity index 100% rename from Src/StdLib/Lib/distutils/command/wininst-10.0.exe rename to StdLib/Lib/distutils/command/wininst-10.0.exe diff --git a/Src/StdLib/Lib/distutils/command/wininst-6.0.exe b/StdLib/Lib/distutils/command/wininst-6.0.exe similarity index 100% rename from Src/StdLib/Lib/distutils/command/wininst-6.0.exe rename to StdLib/Lib/distutils/command/wininst-6.0.exe diff --git a/Src/StdLib/Lib/distutils/command/wininst-7.1.exe b/StdLib/Lib/distutils/command/wininst-7.1.exe similarity index 100% rename from Src/StdLib/Lib/distutils/command/wininst-7.1.exe rename to StdLib/Lib/distutils/command/wininst-7.1.exe diff --git a/Src/StdLib/Lib/distutils/command/wininst-8.0.exe b/StdLib/Lib/distutils/command/wininst-8.0.exe similarity index 100% rename from Src/StdLib/Lib/distutils/command/wininst-8.0.exe rename to StdLib/Lib/distutils/command/wininst-8.0.exe diff --git a/Src/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe b/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe similarity index 100% rename from Src/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe rename to StdLib/Lib/distutils/command/wininst-9.0-amd64.exe diff --git a/Src/StdLib/Lib/distutils/command/wininst-9.0.exe b/StdLib/Lib/distutils/command/wininst-9.0.exe similarity index 100% rename from Src/StdLib/Lib/distutils/command/wininst-9.0.exe rename to StdLib/Lib/distutils/command/wininst-9.0.exe diff --git a/Src/StdLib/Lib/distutils/config.py b/StdLib/Lib/distutils/config.py similarity index 100% rename from Src/StdLib/Lib/distutils/config.py rename to StdLib/Lib/distutils/config.py diff --git a/Src/StdLib/Lib/distutils/core.py b/StdLib/Lib/distutils/core.py similarity index 100% rename from Src/StdLib/Lib/distutils/core.py rename to StdLib/Lib/distutils/core.py diff --git a/Src/StdLib/Lib/distutils/cygwinccompiler.py b/StdLib/Lib/distutils/cygwinccompiler.py similarity index 100% rename from Src/StdLib/Lib/distutils/cygwinccompiler.py rename to StdLib/Lib/distutils/cygwinccompiler.py diff --git a/Src/StdLib/Lib/distutils/debug.py b/StdLib/Lib/distutils/debug.py similarity index 100% rename from Src/StdLib/Lib/distutils/debug.py rename to StdLib/Lib/distutils/debug.py diff --git a/Src/StdLib/Lib/distutils/dep_util.py b/StdLib/Lib/distutils/dep_util.py similarity index 100% rename from Src/StdLib/Lib/distutils/dep_util.py rename to StdLib/Lib/distutils/dep_util.py diff --git a/Src/StdLib/Lib/distutils/dir_util.py b/StdLib/Lib/distutils/dir_util.py similarity index 100% rename from Src/StdLib/Lib/distutils/dir_util.py rename to StdLib/Lib/distutils/dir_util.py diff --git a/Src/StdLib/Lib/distutils/dist.py b/StdLib/Lib/distutils/dist.py similarity index 100% rename from Src/StdLib/Lib/distutils/dist.py rename to StdLib/Lib/distutils/dist.py diff --git a/Src/StdLib/Lib/distutils/errors.py b/StdLib/Lib/distutils/errors.py similarity index 100% rename from Src/StdLib/Lib/distutils/errors.py rename to StdLib/Lib/distutils/errors.py diff --git a/Src/StdLib/Lib/distutils/extension.py b/StdLib/Lib/distutils/extension.py similarity index 100% rename from Src/StdLib/Lib/distutils/extension.py rename to StdLib/Lib/distutils/extension.py diff --git a/Src/StdLib/Lib/distutils/fancy_getopt.py b/StdLib/Lib/distutils/fancy_getopt.py similarity index 100% rename from Src/StdLib/Lib/distutils/fancy_getopt.py rename to StdLib/Lib/distutils/fancy_getopt.py diff --git a/Src/StdLib/Lib/distutils/file_util.py b/StdLib/Lib/distutils/file_util.py similarity index 100% rename from Src/StdLib/Lib/distutils/file_util.py rename to StdLib/Lib/distutils/file_util.py diff --git a/Src/StdLib/Lib/distutils/filelist.py b/StdLib/Lib/distutils/filelist.py similarity index 100% rename from Src/StdLib/Lib/distutils/filelist.py rename to StdLib/Lib/distutils/filelist.py diff --git a/Src/StdLib/Lib/distutils/log.py b/StdLib/Lib/distutils/log.py similarity index 100% rename from Src/StdLib/Lib/distutils/log.py rename to StdLib/Lib/distutils/log.py diff --git a/Src/StdLib/Lib/distutils/msvc9compiler.py b/StdLib/Lib/distutils/msvc9compiler.py similarity index 100% rename from Src/StdLib/Lib/distutils/msvc9compiler.py rename to StdLib/Lib/distutils/msvc9compiler.py diff --git a/Src/StdLib/Lib/distutils/msvccompiler.py b/StdLib/Lib/distutils/msvccompiler.py similarity index 100% rename from Src/StdLib/Lib/distutils/msvccompiler.py rename to StdLib/Lib/distutils/msvccompiler.py diff --git a/Src/StdLib/Lib/distutils/spawn.py b/StdLib/Lib/distutils/spawn.py similarity index 100% rename from Src/StdLib/Lib/distutils/spawn.py rename to StdLib/Lib/distutils/spawn.py diff --git a/Src/StdLib/Lib/distutils/sysconfig.py b/StdLib/Lib/distutils/sysconfig.py similarity index 100% rename from Src/StdLib/Lib/distutils/sysconfig.py rename to StdLib/Lib/distutils/sysconfig.py diff --git a/Src/StdLib/Lib/distutils/tests/Setup.sample b/StdLib/Lib/distutils/tests/Setup.sample similarity index 100% rename from Src/StdLib/Lib/distutils/tests/Setup.sample rename to StdLib/Lib/distutils/tests/Setup.sample diff --git a/Src/StdLib/Lib/distutils/tests/__init__.py b/StdLib/Lib/distutils/tests/__init__.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/__init__.py rename to StdLib/Lib/distutils/tests/__init__.py diff --git a/Src/StdLib/Lib/distutils/tests/support.py b/StdLib/Lib/distutils/tests/support.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/support.py rename to StdLib/Lib/distutils/tests/support.py diff --git a/Src/StdLib/Lib/distutils/tests/test_archive_util.py b/StdLib/Lib/distutils/tests/test_archive_util.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_archive_util.py rename to StdLib/Lib/distutils/tests/test_archive_util.py diff --git a/Src/StdLib/Lib/distutils/tests/test_bdist.py b/StdLib/Lib/distutils/tests/test_bdist.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_bdist.py rename to StdLib/Lib/distutils/tests/test_bdist.py diff --git a/Src/StdLib/Lib/distutils/tests/test_bdist_dumb.py b/StdLib/Lib/distutils/tests/test_bdist_dumb.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_bdist_dumb.py rename to StdLib/Lib/distutils/tests/test_bdist_dumb.py diff --git a/Src/StdLib/Lib/distutils/tests/test_bdist_msi.py b/StdLib/Lib/distutils/tests/test_bdist_msi.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_bdist_msi.py rename to StdLib/Lib/distutils/tests/test_bdist_msi.py diff --git a/Src/StdLib/Lib/distutils/tests/test_bdist_rpm.py b/StdLib/Lib/distutils/tests/test_bdist_rpm.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_bdist_rpm.py rename to StdLib/Lib/distutils/tests/test_bdist_rpm.py diff --git a/Src/StdLib/Lib/distutils/tests/test_bdist_wininst.py b/StdLib/Lib/distutils/tests/test_bdist_wininst.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_bdist_wininst.py rename to StdLib/Lib/distutils/tests/test_bdist_wininst.py diff --git a/Src/StdLib/Lib/distutils/tests/test_build.py b/StdLib/Lib/distutils/tests/test_build.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_build.py rename to StdLib/Lib/distutils/tests/test_build.py diff --git a/Src/StdLib/Lib/distutils/tests/test_build_clib.py b/StdLib/Lib/distutils/tests/test_build_clib.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_build_clib.py rename to StdLib/Lib/distutils/tests/test_build_clib.py diff --git a/Src/StdLib/Lib/distutils/tests/test_build_ext.py b/StdLib/Lib/distutils/tests/test_build_ext.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_build_ext.py rename to StdLib/Lib/distutils/tests/test_build_ext.py diff --git a/Src/StdLib/Lib/distutils/tests/test_build_py.py b/StdLib/Lib/distutils/tests/test_build_py.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_build_py.py rename to StdLib/Lib/distutils/tests/test_build_py.py diff --git a/Src/StdLib/Lib/distutils/tests/test_build_scripts.py b/StdLib/Lib/distutils/tests/test_build_scripts.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_build_scripts.py rename to StdLib/Lib/distutils/tests/test_build_scripts.py diff --git a/Src/StdLib/Lib/distutils/tests/test_check.py b/StdLib/Lib/distutils/tests/test_check.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_check.py rename to StdLib/Lib/distutils/tests/test_check.py diff --git a/Src/StdLib/Lib/distutils/tests/test_clean.py b/StdLib/Lib/distutils/tests/test_clean.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_clean.py rename to StdLib/Lib/distutils/tests/test_clean.py diff --git a/Src/StdLib/Lib/distutils/tests/test_cmd.py b/StdLib/Lib/distutils/tests/test_cmd.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_cmd.py rename to StdLib/Lib/distutils/tests/test_cmd.py diff --git a/Src/StdLib/Lib/distutils/tests/test_config.py b/StdLib/Lib/distutils/tests/test_config.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_config.py rename to StdLib/Lib/distutils/tests/test_config.py diff --git a/Src/StdLib/Lib/distutils/tests/test_config_cmd.py b/StdLib/Lib/distutils/tests/test_config_cmd.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_config_cmd.py rename to StdLib/Lib/distutils/tests/test_config_cmd.py diff --git a/Src/StdLib/Lib/distutils/tests/test_core.py b/StdLib/Lib/distutils/tests/test_core.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_core.py rename to StdLib/Lib/distutils/tests/test_core.py diff --git a/Src/StdLib/Lib/distutils/tests/test_cygwinccompiler.py b/StdLib/Lib/distutils/tests/test_cygwinccompiler.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_cygwinccompiler.py rename to StdLib/Lib/distutils/tests/test_cygwinccompiler.py diff --git a/Src/StdLib/Lib/distutils/tests/test_dep_util.py b/StdLib/Lib/distutils/tests/test_dep_util.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_dep_util.py rename to StdLib/Lib/distutils/tests/test_dep_util.py diff --git a/Src/StdLib/Lib/distutils/tests/test_dir_util.py b/StdLib/Lib/distutils/tests/test_dir_util.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_dir_util.py rename to StdLib/Lib/distutils/tests/test_dir_util.py diff --git a/Src/StdLib/Lib/distutils/tests/test_dist.py b/StdLib/Lib/distutils/tests/test_dist.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_dist.py rename to StdLib/Lib/distutils/tests/test_dist.py diff --git a/Src/StdLib/Lib/distutils/tests/test_extension.py b/StdLib/Lib/distutils/tests/test_extension.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_extension.py rename to StdLib/Lib/distutils/tests/test_extension.py diff --git a/Src/StdLib/Lib/distutils/tests/test_file_util.py b/StdLib/Lib/distutils/tests/test_file_util.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_file_util.py rename to StdLib/Lib/distutils/tests/test_file_util.py diff --git a/Src/StdLib/Lib/distutils/tests/test_filelist.py b/StdLib/Lib/distutils/tests/test_filelist.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_filelist.py rename to StdLib/Lib/distutils/tests/test_filelist.py diff --git a/Src/StdLib/Lib/distutils/tests/test_install.py b/StdLib/Lib/distutils/tests/test_install.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_install.py rename to StdLib/Lib/distutils/tests/test_install.py diff --git a/Src/StdLib/Lib/distutils/tests/test_install_data.py b/StdLib/Lib/distutils/tests/test_install_data.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_install_data.py rename to StdLib/Lib/distutils/tests/test_install_data.py diff --git a/Src/StdLib/Lib/distutils/tests/test_install_headers.py b/StdLib/Lib/distutils/tests/test_install_headers.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_install_headers.py rename to StdLib/Lib/distutils/tests/test_install_headers.py diff --git a/Src/StdLib/Lib/distutils/tests/test_install_lib.py b/StdLib/Lib/distutils/tests/test_install_lib.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_install_lib.py rename to StdLib/Lib/distutils/tests/test_install_lib.py diff --git a/Src/StdLib/Lib/distutils/tests/test_install_scripts.py b/StdLib/Lib/distutils/tests/test_install_scripts.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_install_scripts.py rename to StdLib/Lib/distutils/tests/test_install_scripts.py diff --git a/Src/StdLib/Lib/distutils/tests/test_log.py b/StdLib/Lib/distutils/tests/test_log.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_log.py rename to StdLib/Lib/distutils/tests/test_log.py diff --git a/Src/StdLib/Lib/distutils/tests/test_msvc9compiler.py b/StdLib/Lib/distutils/tests/test_msvc9compiler.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_msvc9compiler.py rename to StdLib/Lib/distutils/tests/test_msvc9compiler.py diff --git a/Src/StdLib/Lib/distutils/tests/test_register.py b/StdLib/Lib/distutils/tests/test_register.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_register.py rename to StdLib/Lib/distutils/tests/test_register.py diff --git a/Src/StdLib/Lib/distutils/tests/test_sdist.py b/StdLib/Lib/distutils/tests/test_sdist.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_sdist.py rename to StdLib/Lib/distutils/tests/test_sdist.py diff --git a/Src/StdLib/Lib/distutils/tests/test_spawn.py b/StdLib/Lib/distutils/tests/test_spawn.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_spawn.py rename to StdLib/Lib/distutils/tests/test_spawn.py diff --git a/Src/StdLib/Lib/distutils/tests/test_sysconfig.py b/StdLib/Lib/distutils/tests/test_sysconfig.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_sysconfig.py rename to StdLib/Lib/distutils/tests/test_sysconfig.py diff --git a/Src/StdLib/Lib/distutils/tests/test_text_file.py b/StdLib/Lib/distutils/tests/test_text_file.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_text_file.py rename to StdLib/Lib/distutils/tests/test_text_file.py diff --git a/Src/StdLib/Lib/distutils/tests/test_unixccompiler.py b/StdLib/Lib/distutils/tests/test_unixccompiler.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_unixccompiler.py rename to StdLib/Lib/distutils/tests/test_unixccompiler.py diff --git a/Src/StdLib/Lib/distutils/tests/test_upload.py b/StdLib/Lib/distutils/tests/test_upload.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_upload.py rename to StdLib/Lib/distutils/tests/test_upload.py diff --git a/Src/StdLib/Lib/distutils/tests/test_util.py b/StdLib/Lib/distutils/tests/test_util.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_util.py rename to StdLib/Lib/distutils/tests/test_util.py diff --git a/Src/StdLib/Lib/distutils/tests/test_version.py b/StdLib/Lib/distutils/tests/test_version.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_version.py rename to StdLib/Lib/distutils/tests/test_version.py diff --git a/Src/StdLib/Lib/distutils/tests/test_versionpredicate.py b/StdLib/Lib/distutils/tests/test_versionpredicate.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_versionpredicate.py rename to StdLib/Lib/distutils/tests/test_versionpredicate.py diff --git a/Src/StdLib/Lib/distutils/text_file.py b/StdLib/Lib/distutils/text_file.py similarity index 100% rename from Src/StdLib/Lib/distutils/text_file.py rename to StdLib/Lib/distutils/text_file.py diff --git a/Src/StdLib/Lib/distutils/unixccompiler.py b/StdLib/Lib/distutils/unixccompiler.py similarity index 100% rename from Src/StdLib/Lib/distutils/unixccompiler.py rename to StdLib/Lib/distutils/unixccompiler.py diff --git a/Src/StdLib/Lib/distutils/util.py b/StdLib/Lib/distutils/util.py similarity index 100% rename from Src/StdLib/Lib/distutils/util.py rename to StdLib/Lib/distutils/util.py diff --git a/Src/StdLib/Lib/distutils/version.py b/StdLib/Lib/distutils/version.py similarity index 100% rename from Src/StdLib/Lib/distutils/version.py rename to StdLib/Lib/distutils/version.py diff --git a/Src/StdLib/Lib/distutils/versionpredicate.py b/StdLib/Lib/distutils/versionpredicate.py similarity index 100% rename from Src/StdLib/Lib/distutils/versionpredicate.py rename to StdLib/Lib/distutils/versionpredicate.py diff --git a/Src/StdLib/Lib/doctest.py b/StdLib/Lib/doctest.py similarity index 100% rename from Src/StdLib/Lib/doctest.py rename to StdLib/Lib/doctest.py diff --git a/Src/StdLib/Lib/dummy_threading.py b/StdLib/Lib/dummy_threading.py similarity index 100% rename from Src/StdLib/Lib/dummy_threading.py rename to StdLib/Lib/dummy_threading.py diff --git a/Src/StdLib/Lib/email/__init__.py b/StdLib/Lib/email/__init__.py similarity index 100% rename from Src/StdLib/Lib/email/__init__.py rename to StdLib/Lib/email/__init__.py diff --git a/Src/StdLib/Lib/email/_encoded_words.py b/StdLib/Lib/email/_encoded_words.py similarity index 100% rename from Src/StdLib/Lib/email/_encoded_words.py rename to StdLib/Lib/email/_encoded_words.py diff --git a/Src/StdLib/Lib/email/_header_value_parser.py b/StdLib/Lib/email/_header_value_parser.py similarity index 100% rename from Src/StdLib/Lib/email/_header_value_parser.py rename to StdLib/Lib/email/_header_value_parser.py diff --git a/Src/StdLib/Lib/email/_parseaddr.py b/StdLib/Lib/email/_parseaddr.py similarity index 100% rename from Src/StdLib/Lib/email/_parseaddr.py rename to StdLib/Lib/email/_parseaddr.py diff --git a/Src/StdLib/Lib/email/_policybase.py b/StdLib/Lib/email/_policybase.py similarity index 100% rename from Src/StdLib/Lib/email/_policybase.py rename to StdLib/Lib/email/_policybase.py diff --git a/Src/StdLib/Lib/email/architecture.rst b/StdLib/Lib/email/architecture.rst similarity index 100% rename from Src/StdLib/Lib/email/architecture.rst rename to StdLib/Lib/email/architecture.rst diff --git a/Src/StdLib/Lib/email/base64mime.py b/StdLib/Lib/email/base64mime.py similarity index 100% rename from Src/StdLib/Lib/email/base64mime.py rename to StdLib/Lib/email/base64mime.py diff --git a/Src/StdLib/Lib/email/charset.py b/StdLib/Lib/email/charset.py similarity index 100% rename from Src/StdLib/Lib/email/charset.py rename to StdLib/Lib/email/charset.py diff --git a/Src/StdLib/Lib/email/contentmanager.py b/StdLib/Lib/email/contentmanager.py similarity index 100% rename from Src/StdLib/Lib/email/contentmanager.py rename to StdLib/Lib/email/contentmanager.py diff --git a/Src/StdLib/Lib/email/encoders.py b/StdLib/Lib/email/encoders.py similarity index 100% rename from Src/StdLib/Lib/email/encoders.py rename to StdLib/Lib/email/encoders.py diff --git a/Src/StdLib/Lib/email/errors.py b/StdLib/Lib/email/errors.py similarity index 100% rename from Src/StdLib/Lib/email/errors.py rename to StdLib/Lib/email/errors.py diff --git a/Src/StdLib/Lib/email/feedparser.py b/StdLib/Lib/email/feedparser.py similarity index 100% rename from Src/StdLib/Lib/email/feedparser.py rename to StdLib/Lib/email/feedparser.py diff --git a/Src/StdLib/Lib/email/generator.py b/StdLib/Lib/email/generator.py similarity index 100% rename from Src/StdLib/Lib/email/generator.py rename to StdLib/Lib/email/generator.py diff --git a/Src/StdLib/Lib/email/header.py b/StdLib/Lib/email/header.py similarity index 100% rename from Src/StdLib/Lib/email/header.py rename to StdLib/Lib/email/header.py diff --git a/Src/StdLib/Lib/email/headerregistry.py b/StdLib/Lib/email/headerregistry.py similarity index 100% rename from Src/StdLib/Lib/email/headerregistry.py rename to StdLib/Lib/email/headerregistry.py diff --git a/Src/StdLib/Lib/email/iterators.py b/StdLib/Lib/email/iterators.py similarity index 100% rename from Src/StdLib/Lib/email/iterators.py rename to StdLib/Lib/email/iterators.py diff --git a/Src/StdLib/Lib/email/message.py b/StdLib/Lib/email/message.py similarity index 100% rename from Src/StdLib/Lib/email/message.py rename to StdLib/Lib/email/message.py diff --git a/Src/StdLib/Lib/email/mime/__init__.py b/StdLib/Lib/email/mime/__init__.py similarity index 100% rename from Src/StdLib/Lib/email/mime/__init__.py rename to StdLib/Lib/email/mime/__init__.py diff --git a/Src/StdLib/Lib/email/mime/application.py b/StdLib/Lib/email/mime/application.py similarity index 100% rename from Src/StdLib/Lib/email/mime/application.py rename to StdLib/Lib/email/mime/application.py diff --git a/Src/StdLib/Lib/email/mime/audio.py b/StdLib/Lib/email/mime/audio.py similarity index 100% rename from Src/StdLib/Lib/email/mime/audio.py rename to StdLib/Lib/email/mime/audio.py diff --git a/Src/StdLib/Lib/email/mime/base.py b/StdLib/Lib/email/mime/base.py similarity index 100% rename from Src/StdLib/Lib/email/mime/base.py rename to StdLib/Lib/email/mime/base.py diff --git a/Src/StdLib/Lib/email/mime/image.py b/StdLib/Lib/email/mime/image.py similarity index 100% rename from Src/StdLib/Lib/email/mime/image.py rename to StdLib/Lib/email/mime/image.py diff --git a/Src/StdLib/Lib/email/mime/message.py b/StdLib/Lib/email/mime/message.py similarity index 100% rename from Src/StdLib/Lib/email/mime/message.py rename to StdLib/Lib/email/mime/message.py diff --git a/Src/StdLib/Lib/email/mime/multipart.py b/StdLib/Lib/email/mime/multipart.py similarity index 100% rename from Src/StdLib/Lib/email/mime/multipart.py rename to StdLib/Lib/email/mime/multipart.py diff --git a/Src/StdLib/Lib/email/mime/nonmultipart.py b/StdLib/Lib/email/mime/nonmultipart.py similarity index 100% rename from Src/StdLib/Lib/email/mime/nonmultipart.py rename to StdLib/Lib/email/mime/nonmultipart.py diff --git a/Src/StdLib/Lib/email/mime/text.py b/StdLib/Lib/email/mime/text.py similarity index 100% rename from Src/StdLib/Lib/email/mime/text.py rename to StdLib/Lib/email/mime/text.py diff --git a/Src/StdLib/Lib/email/parser.py b/StdLib/Lib/email/parser.py similarity index 100% rename from Src/StdLib/Lib/email/parser.py rename to StdLib/Lib/email/parser.py diff --git a/Src/StdLib/Lib/email/policy.py b/StdLib/Lib/email/policy.py similarity index 100% rename from Src/StdLib/Lib/email/policy.py rename to StdLib/Lib/email/policy.py diff --git a/Src/StdLib/Lib/email/quoprimime.py b/StdLib/Lib/email/quoprimime.py similarity index 100% rename from Src/StdLib/Lib/email/quoprimime.py rename to StdLib/Lib/email/quoprimime.py diff --git a/Src/StdLib/Lib/email/utils.py b/StdLib/Lib/email/utils.py similarity index 100% rename from Src/StdLib/Lib/email/utils.py rename to StdLib/Lib/email/utils.py diff --git a/Src/StdLib/Lib/encodings/__init__.py b/StdLib/Lib/encodings/__init__.py similarity index 100% rename from Src/StdLib/Lib/encodings/__init__.py rename to StdLib/Lib/encodings/__init__.py diff --git a/Src/StdLib/Lib/encodings/aliases.py b/StdLib/Lib/encodings/aliases.py similarity index 100% rename from Src/StdLib/Lib/encodings/aliases.py rename to StdLib/Lib/encodings/aliases.py diff --git a/Src/StdLib/Lib/encodings/ascii.py b/StdLib/Lib/encodings/ascii.py similarity index 100% rename from Src/StdLib/Lib/encodings/ascii.py rename to StdLib/Lib/encodings/ascii.py diff --git a/Src/StdLib/Lib/encodings/base64_codec.py b/StdLib/Lib/encodings/base64_codec.py similarity index 100% rename from Src/StdLib/Lib/encodings/base64_codec.py rename to StdLib/Lib/encodings/base64_codec.py diff --git a/Src/StdLib/Lib/encodings/big5.py b/StdLib/Lib/encodings/big5.py similarity index 100% rename from Src/StdLib/Lib/encodings/big5.py rename to StdLib/Lib/encodings/big5.py diff --git a/Src/StdLib/Lib/encodings/big5hkscs.py b/StdLib/Lib/encodings/big5hkscs.py similarity index 100% rename from Src/StdLib/Lib/encodings/big5hkscs.py rename to StdLib/Lib/encodings/big5hkscs.py diff --git a/Src/StdLib/Lib/encodings/bz2_codec.py b/StdLib/Lib/encodings/bz2_codec.py similarity index 100% rename from Src/StdLib/Lib/encodings/bz2_codec.py rename to StdLib/Lib/encodings/bz2_codec.py diff --git a/Src/StdLib/Lib/encodings/charmap.py b/StdLib/Lib/encodings/charmap.py similarity index 100% rename from Src/StdLib/Lib/encodings/charmap.py rename to StdLib/Lib/encodings/charmap.py diff --git a/Src/StdLib/Lib/encodings/cp037.py b/StdLib/Lib/encodings/cp037.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp037.py rename to StdLib/Lib/encodings/cp037.py diff --git a/Src/StdLib/Lib/encodings/cp1006.py b/StdLib/Lib/encodings/cp1006.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1006.py rename to StdLib/Lib/encodings/cp1006.py diff --git a/Src/StdLib/Lib/encodings/cp1026.py b/StdLib/Lib/encodings/cp1026.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1026.py rename to StdLib/Lib/encodings/cp1026.py diff --git a/Src/StdLib/Lib/encodings/cp1125.py b/StdLib/Lib/encodings/cp1125.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1125.py rename to StdLib/Lib/encodings/cp1125.py diff --git a/Src/StdLib/Lib/encodings/cp1140.py b/StdLib/Lib/encodings/cp1140.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1140.py rename to StdLib/Lib/encodings/cp1140.py diff --git a/Src/StdLib/Lib/encodings/cp1250.py b/StdLib/Lib/encodings/cp1250.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1250.py rename to StdLib/Lib/encodings/cp1250.py diff --git a/Src/StdLib/Lib/encodings/cp1251.py b/StdLib/Lib/encodings/cp1251.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1251.py rename to StdLib/Lib/encodings/cp1251.py diff --git a/Src/StdLib/Lib/encodings/cp1252.py b/StdLib/Lib/encodings/cp1252.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1252.py rename to StdLib/Lib/encodings/cp1252.py diff --git a/Src/StdLib/Lib/encodings/cp1253.py b/StdLib/Lib/encodings/cp1253.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1253.py rename to StdLib/Lib/encodings/cp1253.py diff --git a/Src/StdLib/Lib/encodings/cp1254.py b/StdLib/Lib/encodings/cp1254.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1254.py rename to StdLib/Lib/encodings/cp1254.py diff --git a/Src/StdLib/Lib/encodings/cp1255.py b/StdLib/Lib/encodings/cp1255.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1255.py rename to StdLib/Lib/encodings/cp1255.py diff --git a/Src/StdLib/Lib/encodings/cp1256.py b/StdLib/Lib/encodings/cp1256.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1256.py rename to StdLib/Lib/encodings/cp1256.py diff --git a/Src/StdLib/Lib/encodings/cp1257.py b/StdLib/Lib/encodings/cp1257.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1257.py rename to StdLib/Lib/encodings/cp1257.py diff --git a/Src/StdLib/Lib/encodings/cp1258.py b/StdLib/Lib/encodings/cp1258.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1258.py rename to StdLib/Lib/encodings/cp1258.py diff --git a/Src/StdLib/Lib/encodings/cp273.py b/StdLib/Lib/encodings/cp273.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp273.py rename to StdLib/Lib/encodings/cp273.py diff --git a/Src/StdLib/Lib/encodings/cp424.py b/StdLib/Lib/encodings/cp424.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp424.py rename to StdLib/Lib/encodings/cp424.py diff --git a/Src/StdLib/Lib/encodings/cp437.py b/StdLib/Lib/encodings/cp437.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp437.py rename to StdLib/Lib/encodings/cp437.py diff --git a/Src/StdLib/Lib/encodings/cp500.py b/StdLib/Lib/encodings/cp500.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp500.py rename to StdLib/Lib/encodings/cp500.py diff --git a/Src/StdLib/Lib/encodings/cp65001.py b/StdLib/Lib/encodings/cp65001.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp65001.py rename to StdLib/Lib/encodings/cp65001.py diff --git a/Src/StdLib/Lib/encodings/cp720.py b/StdLib/Lib/encodings/cp720.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp720.py rename to StdLib/Lib/encodings/cp720.py diff --git a/Src/StdLib/Lib/encodings/cp737.py b/StdLib/Lib/encodings/cp737.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp737.py rename to StdLib/Lib/encodings/cp737.py diff --git a/Src/StdLib/Lib/encodings/cp775.py b/StdLib/Lib/encodings/cp775.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp775.py rename to StdLib/Lib/encodings/cp775.py diff --git a/Src/StdLib/Lib/encodings/cp850.py b/StdLib/Lib/encodings/cp850.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp850.py rename to StdLib/Lib/encodings/cp850.py diff --git a/Src/StdLib/Lib/encodings/cp852.py b/StdLib/Lib/encodings/cp852.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp852.py rename to StdLib/Lib/encodings/cp852.py diff --git a/Src/StdLib/Lib/encodings/cp855.py b/StdLib/Lib/encodings/cp855.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp855.py rename to StdLib/Lib/encodings/cp855.py diff --git a/Src/StdLib/Lib/encodings/cp856.py b/StdLib/Lib/encodings/cp856.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp856.py rename to StdLib/Lib/encodings/cp856.py diff --git a/Src/StdLib/Lib/encodings/cp857.py b/StdLib/Lib/encodings/cp857.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp857.py rename to StdLib/Lib/encodings/cp857.py diff --git a/Src/StdLib/Lib/encodings/cp858.py b/StdLib/Lib/encodings/cp858.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp858.py rename to StdLib/Lib/encodings/cp858.py diff --git a/Src/StdLib/Lib/encodings/cp860.py b/StdLib/Lib/encodings/cp860.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp860.py rename to StdLib/Lib/encodings/cp860.py diff --git a/Src/StdLib/Lib/encodings/cp861.py b/StdLib/Lib/encodings/cp861.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp861.py rename to StdLib/Lib/encodings/cp861.py diff --git a/Src/StdLib/Lib/encodings/cp862.py b/StdLib/Lib/encodings/cp862.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp862.py rename to StdLib/Lib/encodings/cp862.py diff --git a/Src/StdLib/Lib/encodings/cp863.py b/StdLib/Lib/encodings/cp863.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp863.py rename to StdLib/Lib/encodings/cp863.py diff --git a/Src/StdLib/Lib/encodings/cp864.py b/StdLib/Lib/encodings/cp864.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp864.py rename to StdLib/Lib/encodings/cp864.py diff --git a/Src/StdLib/Lib/encodings/cp865.py b/StdLib/Lib/encodings/cp865.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp865.py rename to StdLib/Lib/encodings/cp865.py diff --git a/Src/StdLib/Lib/encodings/cp866.py b/StdLib/Lib/encodings/cp866.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp866.py rename to StdLib/Lib/encodings/cp866.py diff --git a/Src/StdLib/Lib/encodings/cp869.py b/StdLib/Lib/encodings/cp869.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp869.py rename to StdLib/Lib/encodings/cp869.py diff --git a/Src/StdLib/Lib/encodings/cp874.py b/StdLib/Lib/encodings/cp874.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp874.py rename to StdLib/Lib/encodings/cp874.py diff --git a/Src/StdLib/Lib/encodings/cp875.py b/StdLib/Lib/encodings/cp875.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp875.py rename to StdLib/Lib/encodings/cp875.py diff --git a/Src/StdLib/Lib/encodings/cp932.py b/StdLib/Lib/encodings/cp932.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp932.py rename to StdLib/Lib/encodings/cp932.py diff --git a/Src/StdLib/Lib/encodings/cp949.py b/StdLib/Lib/encodings/cp949.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp949.py rename to StdLib/Lib/encodings/cp949.py diff --git a/Src/StdLib/Lib/encodings/cp950.py b/StdLib/Lib/encodings/cp950.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp950.py rename to StdLib/Lib/encodings/cp950.py diff --git a/Src/StdLib/Lib/encodings/euc_jis_2004.py b/StdLib/Lib/encodings/euc_jis_2004.py similarity index 100% rename from Src/StdLib/Lib/encodings/euc_jis_2004.py rename to StdLib/Lib/encodings/euc_jis_2004.py diff --git a/Src/StdLib/Lib/encodings/euc_jisx0213.py b/StdLib/Lib/encodings/euc_jisx0213.py similarity index 100% rename from Src/StdLib/Lib/encodings/euc_jisx0213.py rename to StdLib/Lib/encodings/euc_jisx0213.py diff --git a/Src/StdLib/Lib/encodings/euc_jp.py b/StdLib/Lib/encodings/euc_jp.py similarity index 100% rename from Src/StdLib/Lib/encodings/euc_jp.py rename to StdLib/Lib/encodings/euc_jp.py diff --git a/Src/StdLib/Lib/encodings/euc_kr.py b/StdLib/Lib/encodings/euc_kr.py similarity index 100% rename from Src/StdLib/Lib/encodings/euc_kr.py rename to StdLib/Lib/encodings/euc_kr.py diff --git a/Src/StdLib/Lib/encodings/gb18030.py b/StdLib/Lib/encodings/gb18030.py similarity index 100% rename from Src/StdLib/Lib/encodings/gb18030.py rename to StdLib/Lib/encodings/gb18030.py diff --git a/Src/StdLib/Lib/encodings/gb2312.py b/StdLib/Lib/encodings/gb2312.py similarity index 100% rename from Src/StdLib/Lib/encodings/gb2312.py rename to StdLib/Lib/encodings/gb2312.py diff --git a/Src/StdLib/Lib/encodings/gbk.py b/StdLib/Lib/encodings/gbk.py similarity index 100% rename from Src/StdLib/Lib/encodings/gbk.py rename to StdLib/Lib/encodings/gbk.py diff --git a/Src/StdLib/Lib/encodings/hex_codec.py b/StdLib/Lib/encodings/hex_codec.py similarity index 100% rename from Src/StdLib/Lib/encodings/hex_codec.py rename to StdLib/Lib/encodings/hex_codec.py diff --git a/Src/StdLib/Lib/encodings/hp_roman8.py b/StdLib/Lib/encodings/hp_roman8.py similarity index 100% rename from Src/StdLib/Lib/encodings/hp_roman8.py rename to StdLib/Lib/encodings/hp_roman8.py diff --git a/Src/StdLib/Lib/encodings/hz.py b/StdLib/Lib/encodings/hz.py similarity index 100% rename from Src/StdLib/Lib/encodings/hz.py rename to StdLib/Lib/encodings/hz.py diff --git a/Src/StdLib/Lib/encodings/idna.py b/StdLib/Lib/encodings/idna.py similarity index 100% rename from Src/StdLib/Lib/encodings/idna.py rename to StdLib/Lib/encodings/idna.py diff --git a/Src/StdLib/Lib/encodings/iso2022_jp.py b/StdLib/Lib/encodings/iso2022_jp.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso2022_jp.py rename to StdLib/Lib/encodings/iso2022_jp.py diff --git a/Src/StdLib/Lib/encodings/iso2022_jp_1.py b/StdLib/Lib/encodings/iso2022_jp_1.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso2022_jp_1.py rename to StdLib/Lib/encodings/iso2022_jp_1.py diff --git a/Src/StdLib/Lib/encodings/iso2022_jp_2.py b/StdLib/Lib/encodings/iso2022_jp_2.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso2022_jp_2.py rename to StdLib/Lib/encodings/iso2022_jp_2.py diff --git a/Src/StdLib/Lib/encodings/iso2022_jp_2004.py b/StdLib/Lib/encodings/iso2022_jp_2004.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso2022_jp_2004.py rename to StdLib/Lib/encodings/iso2022_jp_2004.py diff --git a/Src/StdLib/Lib/encodings/iso2022_jp_3.py b/StdLib/Lib/encodings/iso2022_jp_3.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso2022_jp_3.py rename to StdLib/Lib/encodings/iso2022_jp_3.py diff --git a/Src/StdLib/Lib/encodings/iso2022_jp_ext.py b/StdLib/Lib/encodings/iso2022_jp_ext.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso2022_jp_ext.py rename to StdLib/Lib/encodings/iso2022_jp_ext.py diff --git a/Src/StdLib/Lib/encodings/iso2022_kr.py b/StdLib/Lib/encodings/iso2022_kr.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso2022_kr.py rename to StdLib/Lib/encodings/iso2022_kr.py diff --git a/Src/StdLib/Lib/encodings/iso8859_1.py b/StdLib/Lib/encodings/iso8859_1.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_1.py rename to StdLib/Lib/encodings/iso8859_1.py diff --git a/Src/StdLib/Lib/encodings/iso8859_10.py b/StdLib/Lib/encodings/iso8859_10.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_10.py rename to StdLib/Lib/encodings/iso8859_10.py diff --git a/Src/StdLib/Lib/encodings/iso8859_11.py b/StdLib/Lib/encodings/iso8859_11.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_11.py rename to StdLib/Lib/encodings/iso8859_11.py diff --git a/Src/StdLib/Lib/encodings/iso8859_13.py b/StdLib/Lib/encodings/iso8859_13.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_13.py rename to StdLib/Lib/encodings/iso8859_13.py diff --git a/Src/StdLib/Lib/encodings/iso8859_14.py b/StdLib/Lib/encodings/iso8859_14.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_14.py rename to StdLib/Lib/encodings/iso8859_14.py diff --git a/Src/StdLib/Lib/encodings/iso8859_15.py b/StdLib/Lib/encodings/iso8859_15.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_15.py rename to StdLib/Lib/encodings/iso8859_15.py diff --git a/Src/StdLib/Lib/encodings/iso8859_16.py b/StdLib/Lib/encodings/iso8859_16.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_16.py rename to StdLib/Lib/encodings/iso8859_16.py diff --git a/Src/StdLib/Lib/encodings/iso8859_2.py b/StdLib/Lib/encodings/iso8859_2.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_2.py rename to StdLib/Lib/encodings/iso8859_2.py diff --git a/Src/StdLib/Lib/encodings/iso8859_3.py b/StdLib/Lib/encodings/iso8859_3.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_3.py rename to StdLib/Lib/encodings/iso8859_3.py diff --git a/Src/StdLib/Lib/encodings/iso8859_4.py b/StdLib/Lib/encodings/iso8859_4.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_4.py rename to StdLib/Lib/encodings/iso8859_4.py diff --git a/Src/StdLib/Lib/encodings/iso8859_5.py b/StdLib/Lib/encodings/iso8859_5.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_5.py rename to StdLib/Lib/encodings/iso8859_5.py diff --git a/Src/StdLib/Lib/encodings/iso8859_6.py b/StdLib/Lib/encodings/iso8859_6.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_6.py rename to StdLib/Lib/encodings/iso8859_6.py diff --git a/Src/StdLib/Lib/encodings/iso8859_7.py b/StdLib/Lib/encodings/iso8859_7.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_7.py rename to StdLib/Lib/encodings/iso8859_7.py diff --git a/Src/StdLib/Lib/encodings/iso8859_8.py b/StdLib/Lib/encodings/iso8859_8.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_8.py rename to StdLib/Lib/encodings/iso8859_8.py diff --git a/Src/StdLib/Lib/encodings/iso8859_9.py b/StdLib/Lib/encodings/iso8859_9.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_9.py rename to StdLib/Lib/encodings/iso8859_9.py diff --git a/Src/StdLib/Lib/encodings/johab.py b/StdLib/Lib/encodings/johab.py similarity index 100% rename from Src/StdLib/Lib/encodings/johab.py rename to StdLib/Lib/encodings/johab.py diff --git a/Src/StdLib/Lib/encodings/koi8_r.py b/StdLib/Lib/encodings/koi8_r.py similarity index 100% rename from Src/StdLib/Lib/encodings/koi8_r.py rename to StdLib/Lib/encodings/koi8_r.py diff --git a/Src/StdLib/Lib/encodings/koi8_u.py b/StdLib/Lib/encodings/koi8_u.py similarity index 100% rename from Src/StdLib/Lib/encodings/koi8_u.py rename to StdLib/Lib/encodings/koi8_u.py diff --git a/Src/StdLib/Lib/encodings/latin_1.py b/StdLib/Lib/encodings/latin_1.py similarity index 100% rename from Src/StdLib/Lib/encodings/latin_1.py rename to StdLib/Lib/encodings/latin_1.py diff --git a/Src/StdLib/Lib/encodings/mac_arabic.py b/StdLib/Lib/encodings/mac_arabic.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_arabic.py rename to StdLib/Lib/encodings/mac_arabic.py diff --git a/Src/StdLib/Lib/encodings/mac_centeuro.py b/StdLib/Lib/encodings/mac_centeuro.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_centeuro.py rename to StdLib/Lib/encodings/mac_centeuro.py diff --git a/Src/StdLib/Lib/encodings/mac_croatian.py b/StdLib/Lib/encodings/mac_croatian.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_croatian.py rename to StdLib/Lib/encodings/mac_croatian.py diff --git a/Src/StdLib/Lib/encodings/mac_cyrillic.py b/StdLib/Lib/encodings/mac_cyrillic.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_cyrillic.py rename to StdLib/Lib/encodings/mac_cyrillic.py diff --git a/Src/StdLib/Lib/encodings/mac_farsi.py b/StdLib/Lib/encodings/mac_farsi.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_farsi.py rename to StdLib/Lib/encodings/mac_farsi.py diff --git a/Src/StdLib/Lib/encodings/mac_greek.py b/StdLib/Lib/encodings/mac_greek.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_greek.py rename to StdLib/Lib/encodings/mac_greek.py diff --git a/Src/StdLib/Lib/encodings/mac_iceland.py b/StdLib/Lib/encodings/mac_iceland.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_iceland.py rename to StdLib/Lib/encodings/mac_iceland.py diff --git a/Src/StdLib/Lib/encodings/mac_latin2.py b/StdLib/Lib/encodings/mac_latin2.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_latin2.py rename to StdLib/Lib/encodings/mac_latin2.py diff --git a/Src/StdLib/Lib/encodings/mac_roman.py b/StdLib/Lib/encodings/mac_roman.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_roman.py rename to StdLib/Lib/encodings/mac_roman.py diff --git a/Src/StdLib/Lib/encodings/mac_romanian.py b/StdLib/Lib/encodings/mac_romanian.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_romanian.py rename to StdLib/Lib/encodings/mac_romanian.py diff --git a/Src/StdLib/Lib/encodings/mac_turkish.py b/StdLib/Lib/encodings/mac_turkish.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_turkish.py rename to StdLib/Lib/encodings/mac_turkish.py diff --git a/Src/StdLib/Lib/encodings/mbcs.py b/StdLib/Lib/encodings/mbcs.py similarity index 100% rename from Src/StdLib/Lib/encodings/mbcs.py rename to StdLib/Lib/encodings/mbcs.py diff --git a/Src/StdLib/Lib/encodings/palmos.py b/StdLib/Lib/encodings/palmos.py similarity index 100% rename from Src/StdLib/Lib/encodings/palmos.py rename to StdLib/Lib/encodings/palmos.py diff --git a/Src/StdLib/Lib/encodings/ptcp154.py b/StdLib/Lib/encodings/ptcp154.py similarity index 100% rename from Src/StdLib/Lib/encodings/ptcp154.py rename to StdLib/Lib/encodings/ptcp154.py diff --git a/Src/StdLib/Lib/encodings/punycode.py b/StdLib/Lib/encodings/punycode.py similarity index 100% rename from Src/StdLib/Lib/encodings/punycode.py rename to StdLib/Lib/encodings/punycode.py diff --git a/Src/StdLib/Lib/encodings/quopri_codec.py b/StdLib/Lib/encodings/quopri_codec.py similarity index 100% rename from Src/StdLib/Lib/encodings/quopri_codec.py rename to StdLib/Lib/encodings/quopri_codec.py diff --git a/Src/StdLib/Lib/encodings/raw_unicode_escape.py b/StdLib/Lib/encodings/raw_unicode_escape.py similarity index 100% rename from Src/StdLib/Lib/encodings/raw_unicode_escape.py rename to StdLib/Lib/encodings/raw_unicode_escape.py diff --git a/Src/StdLib/Lib/encodings/rot_13.py b/StdLib/Lib/encodings/rot_13.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/encodings/rot_13.py rename to StdLib/Lib/encodings/rot_13.py diff --git a/Src/StdLib/Lib/encodings/shift_jis.py b/StdLib/Lib/encodings/shift_jis.py similarity index 100% rename from Src/StdLib/Lib/encodings/shift_jis.py rename to StdLib/Lib/encodings/shift_jis.py diff --git a/Src/StdLib/Lib/encodings/shift_jis_2004.py b/StdLib/Lib/encodings/shift_jis_2004.py similarity index 100% rename from Src/StdLib/Lib/encodings/shift_jis_2004.py rename to StdLib/Lib/encodings/shift_jis_2004.py diff --git a/Src/StdLib/Lib/encodings/shift_jisx0213.py b/StdLib/Lib/encodings/shift_jisx0213.py similarity index 100% rename from Src/StdLib/Lib/encodings/shift_jisx0213.py rename to StdLib/Lib/encodings/shift_jisx0213.py diff --git a/Src/StdLib/Lib/encodings/tis_620.py b/StdLib/Lib/encodings/tis_620.py similarity index 100% rename from Src/StdLib/Lib/encodings/tis_620.py rename to StdLib/Lib/encodings/tis_620.py diff --git a/Src/StdLib/Lib/encodings/undefined.py b/StdLib/Lib/encodings/undefined.py similarity index 100% rename from Src/StdLib/Lib/encodings/undefined.py rename to StdLib/Lib/encodings/undefined.py diff --git a/Src/StdLib/Lib/encodings/unicode_escape.py b/StdLib/Lib/encodings/unicode_escape.py similarity index 100% rename from Src/StdLib/Lib/encodings/unicode_escape.py rename to StdLib/Lib/encodings/unicode_escape.py diff --git a/Src/StdLib/Lib/encodings/unicode_internal.py b/StdLib/Lib/encodings/unicode_internal.py similarity index 100% rename from Src/StdLib/Lib/encodings/unicode_internal.py rename to StdLib/Lib/encodings/unicode_internal.py diff --git a/Src/StdLib/Lib/encodings/utf_16.py b/StdLib/Lib/encodings/utf_16.py similarity index 100% rename from Src/StdLib/Lib/encodings/utf_16.py rename to StdLib/Lib/encodings/utf_16.py diff --git a/Src/StdLib/Lib/encodings/utf_16_be.py b/StdLib/Lib/encodings/utf_16_be.py similarity index 100% rename from Src/StdLib/Lib/encodings/utf_16_be.py rename to StdLib/Lib/encodings/utf_16_be.py diff --git a/Src/StdLib/Lib/encodings/utf_16_le.py b/StdLib/Lib/encodings/utf_16_le.py similarity index 100% rename from Src/StdLib/Lib/encodings/utf_16_le.py rename to StdLib/Lib/encodings/utf_16_le.py diff --git a/Src/StdLib/Lib/encodings/utf_32.py b/StdLib/Lib/encodings/utf_32.py similarity index 100% rename from Src/StdLib/Lib/encodings/utf_32.py rename to StdLib/Lib/encodings/utf_32.py diff --git a/Src/StdLib/Lib/encodings/utf_32_be.py b/StdLib/Lib/encodings/utf_32_be.py similarity index 100% rename from Src/StdLib/Lib/encodings/utf_32_be.py rename to StdLib/Lib/encodings/utf_32_be.py diff --git a/Src/StdLib/Lib/encodings/utf_32_le.py b/StdLib/Lib/encodings/utf_32_le.py similarity index 100% rename from Src/StdLib/Lib/encodings/utf_32_le.py rename to StdLib/Lib/encodings/utf_32_le.py diff --git a/Src/StdLib/Lib/encodings/utf_7.py b/StdLib/Lib/encodings/utf_7.py similarity index 100% rename from Src/StdLib/Lib/encodings/utf_7.py rename to StdLib/Lib/encodings/utf_7.py diff --git a/Src/StdLib/Lib/encodings/utf_8.py b/StdLib/Lib/encodings/utf_8.py similarity index 100% rename from Src/StdLib/Lib/encodings/utf_8.py rename to StdLib/Lib/encodings/utf_8.py diff --git a/Src/StdLib/Lib/encodings/utf_8_sig.py b/StdLib/Lib/encodings/utf_8_sig.py similarity index 100% rename from Src/StdLib/Lib/encodings/utf_8_sig.py rename to StdLib/Lib/encodings/utf_8_sig.py diff --git a/Src/StdLib/Lib/encodings/uu_codec.py b/StdLib/Lib/encodings/uu_codec.py similarity index 100% rename from Src/StdLib/Lib/encodings/uu_codec.py rename to StdLib/Lib/encodings/uu_codec.py diff --git a/Src/StdLib/Lib/encodings/zlib_codec.py b/StdLib/Lib/encodings/zlib_codec.py similarity index 100% rename from Src/StdLib/Lib/encodings/zlib_codec.py rename to StdLib/Lib/encodings/zlib_codec.py diff --git a/Src/StdLib/Lib/ensurepip/__init__.py b/StdLib/Lib/ensurepip/__init__.py similarity index 100% rename from Src/StdLib/Lib/ensurepip/__init__.py rename to StdLib/Lib/ensurepip/__init__.py diff --git a/Src/StdLib/Lib/ensurepip/__main__.py b/StdLib/Lib/ensurepip/__main__.py similarity index 100% rename from Src/StdLib/Lib/ensurepip/__main__.py rename to StdLib/Lib/ensurepip/__main__.py diff --git a/Src/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl b/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl similarity index 100% rename from Src/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl rename to StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl diff --git a/Src/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl b/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl similarity index 100% rename from Src/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl rename to StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl diff --git a/Src/StdLib/Lib/ensurepip/_uninstall.py b/StdLib/Lib/ensurepip/_uninstall.py similarity index 100% rename from Src/StdLib/Lib/ensurepip/_uninstall.py rename to StdLib/Lib/ensurepip/_uninstall.py diff --git a/Src/StdLib/Lib/enum.py b/StdLib/Lib/enum.py similarity index 100% rename from Src/StdLib/Lib/enum.py rename to StdLib/Lib/enum.py diff --git a/Src/StdLib/Lib/filecmp.py b/StdLib/Lib/filecmp.py similarity index 100% rename from Src/StdLib/Lib/filecmp.py rename to StdLib/Lib/filecmp.py diff --git a/Src/StdLib/Lib/fileinput.py b/StdLib/Lib/fileinput.py similarity index 100% rename from Src/StdLib/Lib/fileinput.py rename to StdLib/Lib/fileinput.py diff --git a/Src/StdLib/Lib/fnmatch.py b/StdLib/Lib/fnmatch.py similarity index 100% rename from Src/StdLib/Lib/fnmatch.py rename to StdLib/Lib/fnmatch.py diff --git a/Src/StdLib/Lib/formatter.py b/StdLib/Lib/formatter.py similarity index 100% rename from Src/StdLib/Lib/formatter.py rename to StdLib/Lib/formatter.py diff --git a/Src/StdLib/Lib/fractions.py b/StdLib/Lib/fractions.py similarity index 100% rename from Src/StdLib/Lib/fractions.py rename to StdLib/Lib/fractions.py diff --git a/Src/StdLib/Lib/ftplib.py b/StdLib/Lib/ftplib.py similarity index 100% rename from Src/StdLib/Lib/ftplib.py rename to StdLib/Lib/ftplib.py diff --git a/Src/StdLib/Lib/functools.py b/StdLib/Lib/functools.py similarity index 100% rename from Src/StdLib/Lib/functools.py rename to StdLib/Lib/functools.py diff --git a/Src/StdLib/Lib/genericpath.py b/StdLib/Lib/genericpath.py similarity index 100% rename from Src/StdLib/Lib/genericpath.py rename to StdLib/Lib/genericpath.py diff --git a/Src/StdLib/Lib/getopt.py b/StdLib/Lib/getopt.py similarity index 100% rename from Src/StdLib/Lib/getopt.py rename to StdLib/Lib/getopt.py diff --git a/Src/StdLib/Lib/getpass.py b/StdLib/Lib/getpass.py similarity index 100% rename from Src/StdLib/Lib/getpass.py rename to StdLib/Lib/getpass.py diff --git a/Src/StdLib/Lib/gettext.py b/StdLib/Lib/gettext.py similarity index 100% rename from Src/StdLib/Lib/gettext.py rename to StdLib/Lib/gettext.py diff --git a/Src/StdLib/Lib/glob.py b/StdLib/Lib/glob.py similarity index 100% rename from Src/StdLib/Lib/glob.py rename to StdLib/Lib/glob.py diff --git a/Src/StdLib/Lib/gzip.py b/StdLib/Lib/gzip.py similarity index 100% rename from Src/StdLib/Lib/gzip.py rename to StdLib/Lib/gzip.py diff --git a/Src/StdLib/Lib/hashlib.py b/StdLib/Lib/hashlib.py similarity index 100% rename from Src/StdLib/Lib/hashlib.py rename to StdLib/Lib/hashlib.py diff --git a/Src/StdLib/Lib/heapq.py b/StdLib/Lib/heapq.py similarity index 100% rename from Src/StdLib/Lib/heapq.py rename to StdLib/Lib/heapq.py diff --git a/Src/StdLib/Lib/hmac.py b/StdLib/Lib/hmac.py similarity index 100% rename from Src/StdLib/Lib/hmac.py rename to StdLib/Lib/hmac.py diff --git a/Src/StdLib/Lib/html/__init__.py b/StdLib/Lib/html/__init__.py similarity index 100% rename from Src/StdLib/Lib/html/__init__.py rename to StdLib/Lib/html/__init__.py diff --git a/Src/StdLib/Lib/html/entities.py b/StdLib/Lib/html/entities.py similarity index 100% rename from Src/StdLib/Lib/html/entities.py rename to StdLib/Lib/html/entities.py diff --git a/Src/StdLib/Lib/html/parser.py b/StdLib/Lib/html/parser.py similarity index 100% rename from Src/StdLib/Lib/html/parser.py rename to StdLib/Lib/html/parser.py diff --git a/Src/StdLib/Lib/http/__init__.py b/StdLib/Lib/http/__init__.py similarity index 100% rename from Src/StdLib/Lib/http/__init__.py rename to StdLib/Lib/http/__init__.py diff --git a/Src/StdLib/Lib/http/client.py b/StdLib/Lib/http/client.py similarity index 100% rename from Src/StdLib/Lib/http/client.py rename to StdLib/Lib/http/client.py diff --git a/Src/StdLib/Lib/http/cookiejar.py b/StdLib/Lib/http/cookiejar.py similarity index 100% rename from Src/StdLib/Lib/http/cookiejar.py rename to StdLib/Lib/http/cookiejar.py diff --git a/Src/StdLib/Lib/http/cookies.py b/StdLib/Lib/http/cookies.py similarity index 100% rename from Src/StdLib/Lib/http/cookies.py rename to StdLib/Lib/http/cookies.py diff --git a/Src/StdLib/Lib/http/server.py b/StdLib/Lib/http/server.py similarity index 100% rename from Src/StdLib/Lib/http/server.py rename to StdLib/Lib/http/server.py diff --git a/Src/StdLib/Lib/idlelib/AutoComplete.py b/StdLib/Lib/idlelib/AutoComplete.py similarity index 100% rename from Src/StdLib/Lib/idlelib/AutoComplete.py rename to StdLib/Lib/idlelib/AutoComplete.py diff --git a/Src/StdLib/Lib/idlelib/AutoCompleteWindow.py b/StdLib/Lib/idlelib/AutoCompleteWindow.py similarity index 100% rename from Src/StdLib/Lib/idlelib/AutoCompleteWindow.py rename to StdLib/Lib/idlelib/AutoCompleteWindow.py diff --git a/Src/StdLib/Lib/idlelib/AutoExpand.py b/StdLib/Lib/idlelib/AutoExpand.py similarity index 100% rename from Src/StdLib/Lib/idlelib/AutoExpand.py rename to StdLib/Lib/idlelib/AutoExpand.py diff --git a/Src/StdLib/Lib/idlelib/Bindings.py b/StdLib/Lib/idlelib/Bindings.py similarity index 100% rename from Src/StdLib/Lib/idlelib/Bindings.py rename to StdLib/Lib/idlelib/Bindings.py diff --git a/Src/StdLib/Lib/idlelib/CREDITS.txt b/StdLib/Lib/idlelib/CREDITS.txt similarity index 100% rename from Src/StdLib/Lib/idlelib/CREDITS.txt rename to StdLib/Lib/idlelib/CREDITS.txt diff --git a/Src/StdLib/Lib/idlelib/CallTipWindow.py b/StdLib/Lib/idlelib/CallTipWindow.py similarity index 100% rename from Src/StdLib/Lib/idlelib/CallTipWindow.py rename to StdLib/Lib/idlelib/CallTipWindow.py diff --git a/Src/StdLib/Lib/idlelib/CallTips.py b/StdLib/Lib/idlelib/CallTips.py similarity index 100% rename from Src/StdLib/Lib/idlelib/CallTips.py rename to StdLib/Lib/idlelib/CallTips.py diff --git a/Src/StdLib/Lib/idlelib/ChangeLog b/StdLib/Lib/idlelib/ChangeLog similarity index 100% rename from Src/StdLib/Lib/idlelib/ChangeLog rename to StdLib/Lib/idlelib/ChangeLog diff --git a/Src/StdLib/Lib/idlelib/ClassBrowser.py b/StdLib/Lib/idlelib/ClassBrowser.py similarity index 100% rename from Src/StdLib/Lib/idlelib/ClassBrowser.py rename to StdLib/Lib/idlelib/ClassBrowser.py diff --git a/Src/StdLib/Lib/idlelib/CodeContext.py b/StdLib/Lib/idlelib/CodeContext.py similarity index 100% rename from Src/StdLib/Lib/idlelib/CodeContext.py rename to StdLib/Lib/idlelib/CodeContext.py diff --git a/Src/StdLib/Lib/idlelib/ColorDelegator.py b/StdLib/Lib/idlelib/ColorDelegator.py similarity index 100% rename from Src/StdLib/Lib/idlelib/ColorDelegator.py rename to StdLib/Lib/idlelib/ColorDelegator.py diff --git a/Src/StdLib/Lib/idlelib/Debugger.py b/StdLib/Lib/idlelib/Debugger.py similarity index 100% rename from Src/StdLib/Lib/idlelib/Debugger.py rename to StdLib/Lib/idlelib/Debugger.py diff --git a/Src/StdLib/Lib/idlelib/Delegator.py b/StdLib/Lib/idlelib/Delegator.py similarity index 100% rename from Src/StdLib/Lib/idlelib/Delegator.py rename to StdLib/Lib/idlelib/Delegator.py diff --git a/Src/StdLib/Lib/idlelib/EditorWindow.py b/StdLib/Lib/idlelib/EditorWindow.py similarity index 100% rename from Src/StdLib/Lib/idlelib/EditorWindow.py rename to StdLib/Lib/idlelib/EditorWindow.py diff --git a/Src/StdLib/Lib/idlelib/FileList.py b/StdLib/Lib/idlelib/FileList.py similarity index 100% rename from Src/StdLib/Lib/idlelib/FileList.py rename to StdLib/Lib/idlelib/FileList.py diff --git a/Src/StdLib/Lib/idlelib/FormatParagraph.py b/StdLib/Lib/idlelib/FormatParagraph.py similarity index 100% rename from Src/StdLib/Lib/idlelib/FormatParagraph.py rename to StdLib/Lib/idlelib/FormatParagraph.py diff --git a/Src/StdLib/Lib/idlelib/GrepDialog.py b/StdLib/Lib/idlelib/GrepDialog.py similarity index 100% rename from Src/StdLib/Lib/idlelib/GrepDialog.py rename to StdLib/Lib/idlelib/GrepDialog.py diff --git a/Src/StdLib/Lib/idlelib/HISTORY.txt b/StdLib/Lib/idlelib/HISTORY.txt similarity index 100% rename from Src/StdLib/Lib/idlelib/HISTORY.txt rename to StdLib/Lib/idlelib/HISTORY.txt diff --git a/Src/StdLib/Lib/idlelib/HyperParser.py b/StdLib/Lib/idlelib/HyperParser.py similarity index 100% rename from Src/StdLib/Lib/idlelib/HyperParser.py rename to StdLib/Lib/idlelib/HyperParser.py diff --git a/Src/StdLib/Lib/idlelib/IOBinding.py b/StdLib/Lib/idlelib/IOBinding.py similarity index 100% rename from Src/StdLib/Lib/idlelib/IOBinding.py rename to StdLib/Lib/idlelib/IOBinding.py diff --git a/Src/StdLib/Lib/idlelib/Icons/folder.gif b/StdLib/Lib/idlelib/Icons/folder.gif similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/folder.gif rename to StdLib/Lib/idlelib/Icons/folder.gif diff --git a/Src/StdLib/Lib/idlelib/Icons/idle.icns b/StdLib/Lib/idlelib/Icons/idle.icns similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/idle.icns rename to StdLib/Lib/idlelib/Icons/idle.icns diff --git a/Src/StdLib/Lib/idlelib/Icons/idle.ico b/StdLib/Lib/idlelib/Icons/idle.ico similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/idle.ico rename to StdLib/Lib/idlelib/Icons/idle.ico diff --git a/Src/StdLib/Lib/idlelib/Icons/idle_16.gif b/StdLib/Lib/idlelib/Icons/idle_16.gif similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/idle_16.gif rename to StdLib/Lib/idlelib/Icons/idle_16.gif diff --git a/Src/StdLib/Lib/idlelib/Icons/idle_16.png b/StdLib/Lib/idlelib/Icons/idle_16.png similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/idle_16.png rename to StdLib/Lib/idlelib/Icons/idle_16.png diff --git a/Src/StdLib/Lib/idlelib/Icons/idle_32.gif b/StdLib/Lib/idlelib/Icons/idle_32.gif similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/idle_32.gif rename to StdLib/Lib/idlelib/Icons/idle_32.gif diff --git a/Src/StdLib/Lib/idlelib/Icons/idle_32.png b/StdLib/Lib/idlelib/Icons/idle_32.png similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/idle_32.png rename to StdLib/Lib/idlelib/Icons/idle_32.png diff --git a/Src/StdLib/Lib/idlelib/Icons/idle_48.gif b/StdLib/Lib/idlelib/Icons/idle_48.gif similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/idle_48.gif rename to StdLib/Lib/idlelib/Icons/idle_48.gif diff --git a/Src/StdLib/Lib/idlelib/Icons/idle_48.png b/StdLib/Lib/idlelib/Icons/idle_48.png similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/idle_48.png rename to StdLib/Lib/idlelib/Icons/idle_48.png diff --git a/Src/StdLib/Lib/idlelib/Icons/minusnode.gif b/StdLib/Lib/idlelib/Icons/minusnode.gif similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/minusnode.gif rename to StdLib/Lib/idlelib/Icons/minusnode.gif diff --git a/Src/StdLib/Lib/idlelib/Icons/openfolder.gif b/StdLib/Lib/idlelib/Icons/openfolder.gif similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/openfolder.gif rename to StdLib/Lib/idlelib/Icons/openfolder.gif diff --git a/Src/StdLib/Lib/idlelib/Icons/plusnode.gif b/StdLib/Lib/idlelib/Icons/plusnode.gif similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/plusnode.gif rename to StdLib/Lib/idlelib/Icons/plusnode.gif diff --git a/Src/StdLib/Lib/idlelib/Icons/python.gif b/StdLib/Lib/idlelib/Icons/python.gif similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/python.gif rename to StdLib/Lib/idlelib/Icons/python.gif diff --git a/Src/StdLib/Lib/idlelib/Icons/tk.gif b/StdLib/Lib/idlelib/Icons/tk.gif similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/tk.gif rename to StdLib/Lib/idlelib/Icons/tk.gif diff --git a/Src/StdLib/Lib/idlelib/IdleHistory.py b/StdLib/Lib/idlelib/IdleHistory.py similarity index 100% rename from Src/StdLib/Lib/idlelib/IdleHistory.py rename to StdLib/Lib/idlelib/IdleHistory.py diff --git a/Src/StdLib/Lib/idlelib/MultiCall.py b/StdLib/Lib/idlelib/MultiCall.py similarity index 100% rename from Src/StdLib/Lib/idlelib/MultiCall.py rename to StdLib/Lib/idlelib/MultiCall.py diff --git a/Src/StdLib/Lib/idlelib/MultiStatusBar.py b/StdLib/Lib/idlelib/MultiStatusBar.py similarity index 100% rename from Src/StdLib/Lib/idlelib/MultiStatusBar.py rename to StdLib/Lib/idlelib/MultiStatusBar.py diff --git a/Src/StdLib/Lib/idlelib/NEWS.txt b/StdLib/Lib/idlelib/NEWS.txt similarity index 100% rename from Src/StdLib/Lib/idlelib/NEWS.txt rename to StdLib/Lib/idlelib/NEWS.txt diff --git a/Src/StdLib/Lib/idlelib/ObjectBrowser.py b/StdLib/Lib/idlelib/ObjectBrowser.py similarity index 100% rename from Src/StdLib/Lib/idlelib/ObjectBrowser.py rename to StdLib/Lib/idlelib/ObjectBrowser.py diff --git a/Src/StdLib/Lib/idlelib/OutputWindow.py b/StdLib/Lib/idlelib/OutputWindow.py similarity index 100% rename from Src/StdLib/Lib/idlelib/OutputWindow.py rename to StdLib/Lib/idlelib/OutputWindow.py diff --git a/Src/StdLib/Lib/idlelib/ParenMatch.py b/StdLib/Lib/idlelib/ParenMatch.py similarity index 100% rename from Src/StdLib/Lib/idlelib/ParenMatch.py rename to StdLib/Lib/idlelib/ParenMatch.py diff --git a/Src/StdLib/Lib/idlelib/PathBrowser.py b/StdLib/Lib/idlelib/PathBrowser.py similarity index 100% rename from Src/StdLib/Lib/idlelib/PathBrowser.py rename to StdLib/Lib/idlelib/PathBrowser.py diff --git a/Src/StdLib/Lib/idlelib/Percolator.py b/StdLib/Lib/idlelib/Percolator.py similarity index 100% rename from Src/StdLib/Lib/idlelib/Percolator.py rename to StdLib/Lib/idlelib/Percolator.py diff --git a/Src/StdLib/Lib/idlelib/PyParse.py b/StdLib/Lib/idlelib/PyParse.py similarity index 100% rename from Src/StdLib/Lib/idlelib/PyParse.py rename to StdLib/Lib/idlelib/PyParse.py diff --git a/Src/StdLib/Lib/idlelib/PyShell.py b/StdLib/Lib/idlelib/PyShell.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/idlelib/PyShell.py rename to StdLib/Lib/idlelib/PyShell.py diff --git a/Src/StdLib/Lib/idlelib/README.txt b/StdLib/Lib/idlelib/README.txt similarity index 100% rename from Src/StdLib/Lib/idlelib/README.txt rename to StdLib/Lib/idlelib/README.txt diff --git a/Src/StdLib/Lib/idlelib/RemoteDebugger.py b/StdLib/Lib/idlelib/RemoteDebugger.py similarity index 100% rename from Src/StdLib/Lib/idlelib/RemoteDebugger.py rename to StdLib/Lib/idlelib/RemoteDebugger.py diff --git a/Src/StdLib/Lib/idlelib/RemoteObjectBrowser.py b/StdLib/Lib/idlelib/RemoteObjectBrowser.py similarity index 100% rename from Src/StdLib/Lib/idlelib/RemoteObjectBrowser.py rename to StdLib/Lib/idlelib/RemoteObjectBrowser.py diff --git a/Src/StdLib/Lib/idlelib/ReplaceDialog.py b/StdLib/Lib/idlelib/ReplaceDialog.py similarity index 100% rename from Src/StdLib/Lib/idlelib/ReplaceDialog.py rename to StdLib/Lib/idlelib/ReplaceDialog.py diff --git a/Src/StdLib/Lib/idlelib/RstripExtension.py b/StdLib/Lib/idlelib/RstripExtension.py similarity index 100% rename from Src/StdLib/Lib/idlelib/RstripExtension.py rename to StdLib/Lib/idlelib/RstripExtension.py diff --git a/Src/StdLib/Lib/idlelib/ScriptBinding.py b/StdLib/Lib/idlelib/ScriptBinding.py similarity index 100% rename from Src/StdLib/Lib/idlelib/ScriptBinding.py rename to StdLib/Lib/idlelib/ScriptBinding.py diff --git a/Src/StdLib/Lib/idlelib/ScrolledList.py b/StdLib/Lib/idlelib/ScrolledList.py similarity index 100% rename from Src/StdLib/Lib/idlelib/ScrolledList.py rename to StdLib/Lib/idlelib/ScrolledList.py diff --git a/Src/StdLib/Lib/idlelib/SearchDialog.py b/StdLib/Lib/idlelib/SearchDialog.py similarity index 100% rename from Src/StdLib/Lib/idlelib/SearchDialog.py rename to StdLib/Lib/idlelib/SearchDialog.py diff --git a/Src/StdLib/Lib/idlelib/SearchDialogBase.py b/StdLib/Lib/idlelib/SearchDialogBase.py similarity index 100% rename from Src/StdLib/Lib/idlelib/SearchDialogBase.py rename to StdLib/Lib/idlelib/SearchDialogBase.py diff --git a/Src/StdLib/Lib/idlelib/SearchEngine.py b/StdLib/Lib/idlelib/SearchEngine.py similarity index 100% rename from Src/StdLib/Lib/idlelib/SearchEngine.py rename to StdLib/Lib/idlelib/SearchEngine.py diff --git a/Src/StdLib/Lib/idlelib/StackViewer.py b/StdLib/Lib/idlelib/StackViewer.py similarity index 100% rename from Src/StdLib/Lib/idlelib/StackViewer.py rename to StdLib/Lib/idlelib/StackViewer.py diff --git a/Src/StdLib/Lib/idlelib/TODO.txt b/StdLib/Lib/idlelib/TODO.txt similarity index 100% rename from Src/StdLib/Lib/idlelib/TODO.txt rename to StdLib/Lib/idlelib/TODO.txt diff --git a/Src/StdLib/Lib/idlelib/ToolTip.py b/StdLib/Lib/idlelib/ToolTip.py similarity index 100% rename from Src/StdLib/Lib/idlelib/ToolTip.py rename to StdLib/Lib/idlelib/ToolTip.py diff --git a/Src/StdLib/Lib/idlelib/TreeWidget.py b/StdLib/Lib/idlelib/TreeWidget.py similarity index 100% rename from Src/StdLib/Lib/idlelib/TreeWidget.py rename to StdLib/Lib/idlelib/TreeWidget.py diff --git a/Src/StdLib/Lib/idlelib/UndoDelegator.py b/StdLib/Lib/idlelib/UndoDelegator.py similarity index 100% rename from Src/StdLib/Lib/idlelib/UndoDelegator.py rename to StdLib/Lib/idlelib/UndoDelegator.py diff --git a/Src/StdLib/Lib/idlelib/WidgetRedirector.py b/StdLib/Lib/idlelib/WidgetRedirector.py similarity index 100% rename from Src/StdLib/Lib/idlelib/WidgetRedirector.py rename to StdLib/Lib/idlelib/WidgetRedirector.py diff --git a/Src/StdLib/Lib/idlelib/WindowList.py b/StdLib/Lib/idlelib/WindowList.py similarity index 100% rename from Src/StdLib/Lib/idlelib/WindowList.py rename to StdLib/Lib/idlelib/WindowList.py diff --git a/Src/StdLib/Lib/idlelib/ZoomHeight.py b/StdLib/Lib/idlelib/ZoomHeight.py similarity index 100% rename from Src/StdLib/Lib/idlelib/ZoomHeight.py rename to StdLib/Lib/idlelib/ZoomHeight.py diff --git a/Src/StdLib/Lib/idlelib/__init__.py b/StdLib/Lib/idlelib/__init__.py similarity index 100% rename from Src/StdLib/Lib/idlelib/__init__.py rename to StdLib/Lib/idlelib/__init__.py diff --git a/Src/StdLib/Lib/idlelib/__main__.py b/StdLib/Lib/idlelib/__main__.py similarity index 100% rename from Src/StdLib/Lib/idlelib/__main__.py rename to StdLib/Lib/idlelib/__main__.py diff --git a/Src/StdLib/Lib/idlelib/aboutDialog.py b/StdLib/Lib/idlelib/aboutDialog.py similarity index 100% rename from Src/StdLib/Lib/idlelib/aboutDialog.py rename to StdLib/Lib/idlelib/aboutDialog.py diff --git a/Src/StdLib/Lib/idlelib/config-extensions.def b/StdLib/Lib/idlelib/config-extensions.def similarity index 100% rename from Src/StdLib/Lib/idlelib/config-extensions.def rename to StdLib/Lib/idlelib/config-extensions.def diff --git a/Src/StdLib/Lib/idlelib/config-highlight.def b/StdLib/Lib/idlelib/config-highlight.def similarity index 100% rename from Src/StdLib/Lib/idlelib/config-highlight.def rename to StdLib/Lib/idlelib/config-highlight.def diff --git a/Src/StdLib/Lib/idlelib/config-keys.def b/StdLib/Lib/idlelib/config-keys.def similarity index 100% rename from Src/StdLib/Lib/idlelib/config-keys.def rename to StdLib/Lib/idlelib/config-keys.def diff --git a/Src/StdLib/Lib/idlelib/config-main.def b/StdLib/Lib/idlelib/config-main.def similarity index 100% rename from Src/StdLib/Lib/idlelib/config-main.def rename to StdLib/Lib/idlelib/config-main.def diff --git a/Src/StdLib/Lib/idlelib/configDialog.py b/StdLib/Lib/idlelib/configDialog.py similarity index 100% rename from Src/StdLib/Lib/idlelib/configDialog.py rename to StdLib/Lib/idlelib/configDialog.py diff --git a/Src/StdLib/Lib/idlelib/configHandler.py b/StdLib/Lib/idlelib/configHandler.py similarity index 100% rename from Src/StdLib/Lib/idlelib/configHandler.py rename to StdLib/Lib/idlelib/configHandler.py diff --git a/Src/StdLib/Lib/idlelib/configHelpSourceEdit.py b/StdLib/Lib/idlelib/configHelpSourceEdit.py similarity index 100% rename from Src/StdLib/Lib/idlelib/configHelpSourceEdit.py rename to StdLib/Lib/idlelib/configHelpSourceEdit.py diff --git a/Src/StdLib/Lib/idlelib/configSectionNameDialog.py b/StdLib/Lib/idlelib/configSectionNameDialog.py similarity index 100% rename from Src/StdLib/Lib/idlelib/configSectionNameDialog.py rename to StdLib/Lib/idlelib/configSectionNameDialog.py diff --git a/Src/StdLib/Lib/idlelib/dynOptionMenuWidget.py b/StdLib/Lib/idlelib/dynOptionMenuWidget.py similarity index 100% rename from Src/StdLib/Lib/idlelib/dynOptionMenuWidget.py rename to StdLib/Lib/idlelib/dynOptionMenuWidget.py diff --git a/Src/StdLib/Lib/idlelib/extend.txt b/StdLib/Lib/idlelib/extend.txt similarity index 100% rename from Src/StdLib/Lib/idlelib/extend.txt rename to StdLib/Lib/idlelib/extend.txt diff --git a/Src/StdLib/Lib/idlelib/help.html b/StdLib/Lib/idlelib/help.html similarity index 100% rename from Src/StdLib/Lib/idlelib/help.html rename to StdLib/Lib/idlelib/help.html diff --git a/Src/StdLib/Lib/idlelib/help.py b/StdLib/Lib/idlelib/help.py similarity index 100% rename from Src/StdLib/Lib/idlelib/help.py rename to StdLib/Lib/idlelib/help.py diff --git a/Src/StdLib/Lib/idlelib/help.txt b/StdLib/Lib/idlelib/help.txt similarity index 100% rename from Src/StdLib/Lib/idlelib/help.txt rename to StdLib/Lib/idlelib/help.txt diff --git a/Src/StdLib/Lib/idlelib/idle.bat b/StdLib/Lib/idlelib/idle.bat old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/idlelib/idle.bat rename to StdLib/Lib/idlelib/idle.bat diff --git a/Src/StdLib/Lib/idlelib/idle.py b/StdLib/Lib/idlelib/idle.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle.py rename to StdLib/Lib/idlelib/idle.py diff --git a/Src/StdLib/Lib/idlelib/idle.pyw b/StdLib/Lib/idlelib/idle.pyw similarity index 100% rename from Src/StdLib/Lib/idlelib/idle.pyw rename to StdLib/Lib/idlelib/idle.pyw diff --git a/Src/StdLib/Lib/idlelib/idle_test/README.txt b/StdLib/Lib/idlelib/idle_test/README.txt similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/README.txt rename to StdLib/Lib/idlelib/idle_test/README.txt diff --git a/Src/StdLib/Lib/idlelib/idle_test/__init__.py b/StdLib/Lib/idlelib/idle_test/__init__.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/__init__.py rename to StdLib/Lib/idlelib/idle_test/__init__.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/htest.py b/StdLib/Lib/idlelib/idle_test/htest.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/htest.py rename to StdLib/Lib/idlelib/idle_test/htest.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/mock_idle.py b/StdLib/Lib/idlelib/idle_test/mock_idle.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/mock_idle.py rename to StdLib/Lib/idlelib/idle_test/mock_idle.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/mock_tk.py b/StdLib/Lib/idlelib/idle_test/mock_tk.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/mock_tk.py rename to StdLib/Lib/idlelib/idle_test/mock_tk.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_autocomplete.py b/StdLib/Lib/idlelib/idle_test/test_autocomplete.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_autocomplete.py rename to StdLib/Lib/idlelib/idle_test/test_autocomplete.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_autoexpand.py b/StdLib/Lib/idlelib/idle_test/test_autoexpand.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_autoexpand.py rename to StdLib/Lib/idlelib/idle_test/test_autoexpand.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_calltips.py b/StdLib/Lib/idlelib/idle_test/test_calltips.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_calltips.py rename to StdLib/Lib/idlelib/idle_test/test_calltips.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_config_name.py b/StdLib/Lib/idlelib/idle_test/test_config_name.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_config_name.py rename to StdLib/Lib/idlelib/idle_test/test_config_name.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_configdialog.py b/StdLib/Lib/idlelib/idle_test/test_configdialog.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_configdialog.py rename to StdLib/Lib/idlelib/idle_test/test_configdialog.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_delegator.py b/StdLib/Lib/idlelib/idle_test/test_delegator.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_delegator.py rename to StdLib/Lib/idlelib/idle_test/test_delegator.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_editor.py b/StdLib/Lib/idlelib/idle_test/test_editor.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_editor.py rename to StdLib/Lib/idlelib/idle_test/test_editor.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py b/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py rename to StdLib/Lib/idlelib/idle_test/test_formatparagraph.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_grep.py b/StdLib/Lib/idlelib/idle_test/test_grep.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_grep.py rename to StdLib/Lib/idlelib/idle_test/test_grep.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_hyperparser.py b/StdLib/Lib/idlelib/idle_test/test_hyperparser.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_hyperparser.py rename to StdLib/Lib/idlelib/idle_test/test_hyperparser.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_idlehistory.py b/StdLib/Lib/idlelib/idle_test/test_idlehistory.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_idlehistory.py rename to StdLib/Lib/idlelib/idle_test/test_idlehistory.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_io.py b/StdLib/Lib/idlelib/idle_test/test_io.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_io.py rename to StdLib/Lib/idlelib/idle_test/test_io.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_parenmatch.py b/StdLib/Lib/idlelib/idle_test/test_parenmatch.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_parenmatch.py rename to StdLib/Lib/idlelib/idle_test/test_parenmatch.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py b/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py rename to StdLib/Lib/idlelib/idle_test/test_pathbrowser.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_rstrip.py b/StdLib/Lib/idlelib/idle_test/test_rstrip.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_rstrip.py rename to StdLib/Lib/idlelib/idle_test/test_rstrip.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py b/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py rename to StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_searchengine.py b/StdLib/Lib/idlelib/idle_test/test_searchengine.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_searchengine.py rename to StdLib/Lib/idlelib/idle_test/test_searchengine.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_text.py b/StdLib/Lib/idlelib/idle_test/test_text.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_text.py rename to StdLib/Lib/idlelib/idle_test/test_text.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_textview.py b/StdLib/Lib/idlelib/idle_test/test_textview.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_textview.py rename to StdLib/Lib/idlelib/idle_test/test_textview.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_warning.py b/StdLib/Lib/idlelib/idle_test/test_warning.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_warning.py rename to StdLib/Lib/idlelib/idle_test/test_warning.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_widgetredir.py b/StdLib/Lib/idlelib/idle_test/test_widgetredir.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_widgetredir.py rename to StdLib/Lib/idlelib/idle_test/test_widgetredir.py diff --git a/Src/StdLib/Lib/idlelib/idlever.py b/StdLib/Lib/idlelib/idlever.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idlever.py rename to StdLib/Lib/idlelib/idlever.py diff --git a/Src/StdLib/Lib/idlelib/keybindingDialog.py b/StdLib/Lib/idlelib/keybindingDialog.py similarity index 100% rename from Src/StdLib/Lib/idlelib/keybindingDialog.py rename to StdLib/Lib/idlelib/keybindingDialog.py diff --git a/Src/StdLib/Lib/idlelib/macosxSupport.py b/StdLib/Lib/idlelib/macosxSupport.py similarity index 100% rename from Src/StdLib/Lib/idlelib/macosxSupport.py rename to StdLib/Lib/idlelib/macosxSupport.py diff --git a/Src/StdLib/Lib/idlelib/rpc.py b/StdLib/Lib/idlelib/rpc.py similarity index 100% rename from Src/StdLib/Lib/idlelib/rpc.py rename to StdLib/Lib/idlelib/rpc.py diff --git a/Src/StdLib/Lib/idlelib/run.py b/StdLib/Lib/idlelib/run.py similarity index 100% rename from Src/StdLib/Lib/idlelib/run.py rename to StdLib/Lib/idlelib/run.py diff --git a/Src/StdLib/Lib/idlelib/tabbedpages.py b/StdLib/Lib/idlelib/tabbedpages.py similarity index 100% rename from Src/StdLib/Lib/idlelib/tabbedpages.py rename to StdLib/Lib/idlelib/tabbedpages.py diff --git a/Src/StdLib/Lib/idlelib/textView.py b/StdLib/Lib/idlelib/textView.py similarity index 100% rename from Src/StdLib/Lib/idlelib/textView.py rename to StdLib/Lib/idlelib/textView.py diff --git a/Src/StdLib/Lib/imaplib.py b/StdLib/Lib/imaplib.py similarity index 100% rename from Src/StdLib/Lib/imaplib.py rename to StdLib/Lib/imaplib.py diff --git a/Src/StdLib/Lib/imghdr.py b/StdLib/Lib/imghdr.py similarity index 100% rename from Src/StdLib/Lib/imghdr.py rename to StdLib/Lib/imghdr.py diff --git a/Src/StdLib/Lib/imp.py b/StdLib/Lib/imp.py similarity index 100% rename from Src/StdLib/Lib/imp.py rename to StdLib/Lib/imp.py diff --git a/Src/StdLib/Lib/importlib/__init__.py b/StdLib/Lib/importlib/__init__.py similarity index 100% rename from Src/StdLib/Lib/importlib/__init__.py rename to StdLib/Lib/importlib/__init__.py diff --git a/Src/StdLib/Lib/importlib/_bootstrap.py b/StdLib/Lib/importlib/_bootstrap.py similarity index 100% rename from Src/StdLib/Lib/importlib/_bootstrap.py rename to StdLib/Lib/importlib/_bootstrap.py diff --git a/Src/StdLib/Lib/importlib/abc.py b/StdLib/Lib/importlib/abc.py similarity index 100% rename from Src/StdLib/Lib/importlib/abc.py rename to StdLib/Lib/importlib/abc.py diff --git a/Src/StdLib/Lib/importlib/machinery.py b/StdLib/Lib/importlib/machinery.py similarity index 100% rename from Src/StdLib/Lib/importlib/machinery.py rename to StdLib/Lib/importlib/machinery.py diff --git a/Src/StdLib/Lib/importlib/util.py b/StdLib/Lib/importlib/util.py similarity index 100% rename from Src/StdLib/Lib/importlib/util.py rename to StdLib/Lib/importlib/util.py diff --git a/Src/StdLib/Lib/inspect.py b/StdLib/Lib/inspect.py similarity index 100% rename from Src/StdLib/Lib/inspect.py rename to StdLib/Lib/inspect.py diff --git a/Src/StdLib/Lib/io.py b/StdLib/Lib/io.py similarity index 100% rename from Src/StdLib/Lib/io.py rename to StdLib/Lib/io.py diff --git a/Src/StdLib/Lib/ipaddress.py b/StdLib/Lib/ipaddress.py similarity index 100% rename from Src/StdLib/Lib/ipaddress.py rename to StdLib/Lib/ipaddress.py diff --git a/Src/StdLib/Lib/json/__init__.py b/StdLib/Lib/json/__init__.py similarity index 100% rename from Src/StdLib/Lib/json/__init__.py rename to StdLib/Lib/json/__init__.py diff --git a/Src/StdLib/Lib/json/decoder.py b/StdLib/Lib/json/decoder.py similarity index 100% rename from Src/StdLib/Lib/json/decoder.py rename to StdLib/Lib/json/decoder.py diff --git a/Src/StdLib/Lib/json/encoder.py b/StdLib/Lib/json/encoder.py similarity index 100% rename from Src/StdLib/Lib/json/encoder.py rename to StdLib/Lib/json/encoder.py diff --git a/Src/StdLib/Lib/json/scanner.py b/StdLib/Lib/json/scanner.py similarity index 100% rename from Src/StdLib/Lib/json/scanner.py rename to StdLib/Lib/json/scanner.py diff --git a/Src/StdLib/Lib/json/tool.py b/StdLib/Lib/json/tool.py similarity index 100% rename from Src/StdLib/Lib/json/tool.py rename to StdLib/Lib/json/tool.py diff --git a/Src/StdLib/Lib/keyword.py b/StdLib/Lib/keyword.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/keyword.py rename to StdLib/Lib/keyword.py diff --git a/Src/StdLib/Lib/lib2to3/Grammar.txt b/StdLib/Lib/lib2to3/Grammar.txt similarity index 100% rename from Src/StdLib/Lib/lib2to3/Grammar.txt rename to StdLib/Lib/lib2to3/Grammar.txt diff --git a/Src/StdLib/Lib/lib2to3/PatternGrammar.txt b/StdLib/Lib/lib2to3/PatternGrammar.txt similarity index 100% rename from Src/StdLib/Lib/lib2to3/PatternGrammar.txt rename to StdLib/Lib/lib2to3/PatternGrammar.txt diff --git a/Src/StdLib/Lib/lib2to3/__init__.py b/StdLib/Lib/lib2to3/__init__.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/__init__.py rename to StdLib/Lib/lib2to3/__init__.py diff --git a/Src/StdLib/Lib/lib2to3/__main__.py b/StdLib/Lib/lib2to3/__main__.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/__main__.py rename to StdLib/Lib/lib2to3/__main__.py diff --git a/Src/StdLib/Lib/lib2to3/btm_matcher.py b/StdLib/Lib/lib2to3/btm_matcher.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/btm_matcher.py rename to StdLib/Lib/lib2to3/btm_matcher.py diff --git a/Src/StdLib/Lib/lib2to3/btm_utils.py b/StdLib/Lib/lib2to3/btm_utils.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/btm_utils.py rename to StdLib/Lib/lib2to3/btm_utils.py diff --git a/Src/StdLib/Lib/lib2to3/fixer_base.py b/StdLib/Lib/lib2to3/fixer_base.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixer_base.py rename to StdLib/Lib/lib2to3/fixer_base.py diff --git a/Src/StdLib/Lib/lib2to3/fixer_util.py b/StdLib/Lib/lib2to3/fixer_util.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixer_util.py rename to StdLib/Lib/lib2to3/fixer_util.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/__init__.py b/StdLib/Lib/lib2to3/fixes/__init__.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/__init__.py rename to StdLib/Lib/lib2to3/fixes/__init__.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_apply.py b/StdLib/Lib/lib2to3/fixes/fix_apply.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_apply.py rename to StdLib/Lib/lib2to3/fixes/fix_apply.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_asserts.py b/StdLib/Lib/lib2to3/fixes/fix_asserts.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_asserts.py rename to StdLib/Lib/lib2to3/fixes/fix_asserts.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_basestring.py b/StdLib/Lib/lib2to3/fixes/fix_basestring.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_basestring.py rename to StdLib/Lib/lib2to3/fixes/fix_basestring.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_buffer.py b/StdLib/Lib/lib2to3/fixes/fix_buffer.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_buffer.py rename to StdLib/Lib/lib2to3/fixes/fix_buffer.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_callable.py b/StdLib/Lib/lib2to3/fixes/fix_callable.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_callable.py rename to StdLib/Lib/lib2to3/fixes/fix_callable.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_dict.py b/StdLib/Lib/lib2to3/fixes/fix_dict.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_dict.py rename to StdLib/Lib/lib2to3/fixes/fix_dict.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_except.py b/StdLib/Lib/lib2to3/fixes/fix_except.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_except.py rename to StdLib/Lib/lib2to3/fixes/fix_except.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_exec.py b/StdLib/Lib/lib2to3/fixes/fix_exec.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_exec.py rename to StdLib/Lib/lib2to3/fixes/fix_exec.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_execfile.py b/StdLib/Lib/lib2to3/fixes/fix_execfile.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_execfile.py rename to StdLib/Lib/lib2to3/fixes/fix_execfile.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py b/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py rename to StdLib/Lib/lib2to3/fixes/fix_exitfunc.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_filter.py b/StdLib/Lib/lib2to3/fixes/fix_filter.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_filter.py rename to StdLib/Lib/lib2to3/fixes/fix_filter.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py b/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py rename to StdLib/Lib/lib2to3/fixes/fix_funcattrs.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_future.py b/StdLib/Lib/lib2to3/fixes/fix_future.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_future.py rename to StdLib/Lib/lib2to3/fixes/fix_future.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py b/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py rename to StdLib/Lib/lib2to3/fixes/fix_getcwdu.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_has_key.py b/StdLib/Lib/lib2to3/fixes/fix_has_key.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_has_key.py rename to StdLib/Lib/lib2to3/fixes/fix_has_key.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_idioms.py b/StdLib/Lib/lib2to3/fixes/fix_idioms.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_idioms.py rename to StdLib/Lib/lib2to3/fixes/fix_idioms.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_import.py b/StdLib/Lib/lib2to3/fixes/fix_import.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_import.py rename to StdLib/Lib/lib2to3/fixes/fix_import.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_imports.py b/StdLib/Lib/lib2to3/fixes/fix_imports.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_imports.py rename to StdLib/Lib/lib2to3/fixes/fix_imports.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_imports2.py b/StdLib/Lib/lib2to3/fixes/fix_imports2.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_imports2.py rename to StdLib/Lib/lib2to3/fixes/fix_imports2.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_input.py b/StdLib/Lib/lib2to3/fixes/fix_input.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_input.py rename to StdLib/Lib/lib2to3/fixes/fix_input.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_intern.py b/StdLib/Lib/lib2to3/fixes/fix_intern.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_intern.py rename to StdLib/Lib/lib2to3/fixes/fix_intern.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_isinstance.py b/StdLib/Lib/lib2to3/fixes/fix_isinstance.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_isinstance.py rename to StdLib/Lib/lib2to3/fixes/fix_isinstance.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_itertools.py b/StdLib/Lib/lib2to3/fixes/fix_itertools.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_itertools.py rename to StdLib/Lib/lib2to3/fixes/fix_itertools.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py b/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py rename to StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_long.py b/StdLib/Lib/lib2to3/fixes/fix_long.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_long.py rename to StdLib/Lib/lib2to3/fixes/fix_long.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_map.py b/StdLib/Lib/lib2to3/fixes/fix_map.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_map.py rename to StdLib/Lib/lib2to3/fixes/fix_map.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_metaclass.py b/StdLib/Lib/lib2to3/fixes/fix_metaclass.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_metaclass.py rename to StdLib/Lib/lib2to3/fixes/fix_metaclass.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py b/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py rename to StdLib/Lib/lib2to3/fixes/fix_methodattrs.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_ne.py b/StdLib/Lib/lib2to3/fixes/fix_ne.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_ne.py rename to StdLib/Lib/lib2to3/fixes/fix_ne.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_next.py b/StdLib/Lib/lib2to3/fixes/fix_next.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_next.py rename to StdLib/Lib/lib2to3/fixes/fix_next.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_nonzero.py b/StdLib/Lib/lib2to3/fixes/fix_nonzero.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_nonzero.py rename to StdLib/Lib/lib2to3/fixes/fix_nonzero.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_numliterals.py b/StdLib/Lib/lib2to3/fixes/fix_numliterals.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_numliterals.py rename to StdLib/Lib/lib2to3/fixes/fix_numliterals.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_operator.py b/StdLib/Lib/lib2to3/fixes/fix_operator.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_operator.py rename to StdLib/Lib/lib2to3/fixes/fix_operator.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_paren.py b/StdLib/Lib/lib2to3/fixes/fix_paren.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_paren.py rename to StdLib/Lib/lib2to3/fixes/fix_paren.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_print.py b/StdLib/Lib/lib2to3/fixes/fix_print.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_print.py rename to StdLib/Lib/lib2to3/fixes/fix_print.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_raise.py b/StdLib/Lib/lib2to3/fixes/fix_raise.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_raise.py rename to StdLib/Lib/lib2to3/fixes/fix_raise.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_raw_input.py b/StdLib/Lib/lib2to3/fixes/fix_raw_input.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_raw_input.py rename to StdLib/Lib/lib2to3/fixes/fix_raw_input.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_reduce.py b/StdLib/Lib/lib2to3/fixes/fix_reduce.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_reduce.py rename to StdLib/Lib/lib2to3/fixes/fix_reduce.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_reload.py b/StdLib/Lib/lib2to3/fixes/fix_reload.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_reload.py rename to StdLib/Lib/lib2to3/fixes/fix_reload.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_renames.py b/StdLib/Lib/lib2to3/fixes/fix_renames.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_renames.py rename to StdLib/Lib/lib2to3/fixes/fix_renames.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_repr.py b/StdLib/Lib/lib2to3/fixes/fix_repr.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_repr.py rename to StdLib/Lib/lib2to3/fixes/fix_repr.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_set_literal.py b/StdLib/Lib/lib2to3/fixes/fix_set_literal.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_set_literal.py rename to StdLib/Lib/lib2to3/fixes/fix_set_literal.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_standarderror.py b/StdLib/Lib/lib2to3/fixes/fix_standarderror.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_standarderror.py rename to StdLib/Lib/lib2to3/fixes/fix_standarderror.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py b/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py rename to StdLib/Lib/lib2to3/fixes/fix_sys_exc.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_throw.py b/StdLib/Lib/lib2to3/fixes/fix_throw.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_throw.py rename to StdLib/Lib/lib2to3/fixes/fix_throw.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py b/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py rename to StdLib/Lib/lib2to3/fixes/fix_tuple_params.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_types.py b/StdLib/Lib/lib2to3/fixes/fix_types.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_types.py rename to StdLib/Lib/lib2to3/fixes/fix_types.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_unicode.py b/StdLib/Lib/lib2to3/fixes/fix_unicode.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_unicode.py rename to StdLib/Lib/lib2to3/fixes/fix_unicode.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_urllib.py b/StdLib/Lib/lib2to3/fixes/fix_urllib.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_urllib.py rename to StdLib/Lib/lib2to3/fixes/fix_urllib.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py b/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py rename to StdLib/Lib/lib2to3/fixes/fix_ws_comma.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_xrange.py b/StdLib/Lib/lib2to3/fixes/fix_xrange.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_xrange.py rename to StdLib/Lib/lib2to3/fixes/fix_xrange.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py b/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py rename to StdLib/Lib/lib2to3/fixes/fix_xreadlines.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_zip.py b/StdLib/Lib/lib2to3/fixes/fix_zip.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_zip.py rename to StdLib/Lib/lib2to3/fixes/fix_zip.py diff --git a/Src/StdLib/Lib/lib2to3/main.py b/StdLib/Lib/lib2to3/main.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/main.py rename to StdLib/Lib/lib2to3/main.py diff --git a/Src/StdLib/Lib/lib2to3/patcomp.py b/StdLib/Lib/lib2to3/patcomp.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/patcomp.py rename to StdLib/Lib/lib2to3/patcomp.py diff --git a/Src/StdLib/Lib/lib2to3/pgen2/__init__.py b/StdLib/Lib/lib2to3/pgen2/__init__.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/pgen2/__init__.py rename to StdLib/Lib/lib2to3/pgen2/__init__.py diff --git a/Src/StdLib/Lib/lib2to3/pgen2/conv.py b/StdLib/Lib/lib2to3/pgen2/conv.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/pgen2/conv.py rename to StdLib/Lib/lib2to3/pgen2/conv.py diff --git a/Src/StdLib/Lib/lib2to3/pgen2/driver.py b/StdLib/Lib/lib2to3/pgen2/driver.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/pgen2/driver.py rename to StdLib/Lib/lib2to3/pgen2/driver.py diff --git a/Src/StdLib/Lib/lib2to3/pgen2/grammar.py b/StdLib/Lib/lib2to3/pgen2/grammar.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/pgen2/grammar.py rename to StdLib/Lib/lib2to3/pgen2/grammar.py diff --git a/Src/StdLib/Lib/lib2to3/pgen2/literals.py b/StdLib/Lib/lib2to3/pgen2/literals.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/pgen2/literals.py rename to StdLib/Lib/lib2to3/pgen2/literals.py diff --git a/Src/StdLib/Lib/lib2to3/pgen2/parse.py b/StdLib/Lib/lib2to3/pgen2/parse.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/pgen2/parse.py rename to StdLib/Lib/lib2to3/pgen2/parse.py diff --git a/Src/StdLib/Lib/lib2to3/pgen2/pgen.py b/StdLib/Lib/lib2to3/pgen2/pgen.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/pgen2/pgen.py rename to StdLib/Lib/lib2to3/pgen2/pgen.py diff --git a/Src/StdLib/Lib/lib2to3/pgen2/token.py b/StdLib/Lib/lib2to3/pgen2/token.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/lib2to3/pgen2/token.py rename to StdLib/Lib/lib2to3/pgen2/token.py diff --git a/Src/StdLib/Lib/lib2to3/pgen2/tokenize.py b/StdLib/Lib/lib2to3/pgen2/tokenize.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/pgen2/tokenize.py rename to StdLib/Lib/lib2to3/pgen2/tokenize.py diff --git a/Src/StdLib/Lib/lib2to3/pygram.py b/StdLib/Lib/lib2to3/pygram.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/pygram.py rename to StdLib/Lib/lib2to3/pygram.py diff --git a/Src/StdLib/Lib/lib2to3/pytree.py b/StdLib/Lib/lib2to3/pytree.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/pytree.py rename to StdLib/Lib/lib2to3/pytree.py diff --git a/Src/StdLib/Lib/lib2to3/refactor.py b/StdLib/Lib/lib2to3/refactor.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/refactor.py rename to StdLib/Lib/lib2to3/refactor.py diff --git a/Src/StdLib/Lib/lib2to3/tests/__init__.py b/StdLib/Lib/lib2to3/tests/__init__.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/__init__.py rename to StdLib/Lib/lib2to3/tests/__init__.py diff --git a/Src/StdLib/Lib/lib2to3/tests/__main__.py b/StdLib/Lib/lib2to3/tests/__main__.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/__main__.py rename to StdLib/Lib/lib2to3/tests/__main__.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/README b/StdLib/Lib/lib2to3/tests/data/README similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/README rename to StdLib/Lib/lib2to3/tests/data/README diff --git a/Src/StdLib/Lib/lib2to3/tests/data/bom.py b/StdLib/Lib/lib2to3/tests/data/bom.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/bom.py rename to StdLib/Lib/lib2to3/tests/data/bom.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/crlf.py b/StdLib/Lib/lib2to3/tests/data/crlf.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/crlf.py rename to StdLib/Lib/lib2to3/tests/data/crlf.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/different_encoding.py b/StdLib/Lib/lib2to3/tests/data/different_encoding.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/different_encoding.py rename to StdLib/Lib/lib2to3/tests/data/different_encoding.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/false_encoding.py b/StdLib/Lib/lib2to3/tests/data/false_encoding.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/false_encoding.py rename to StdLib/Lib/lib2to3/tests/data/false_encoding.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py b/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py rename to StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py b/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py rename to StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py b/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py rename to StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py b/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py rename to StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py b/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py rename to StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py b/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py rename to StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py b/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py rename to StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py b/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py rename to StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py b/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py rename to StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py b/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py rename to StdLib/Lib/lib2to3/tests/data/infinite_recursion.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py b/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py rename to StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py b/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py rename to StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py diff --git a/Src/StdLib/Lib/lib2to3/tests/pytree_idempotency.py b/StdLib/Lib/lib2to3/tests/pytree_idempotency.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/pytree_idempotency.py rename to StdLib/Lib/lib2to3/tests/pytree_idempotency.py diff --git a/Src/StdLib/Lib/lib2to3/tests/support.py b/StdLib/Lib/lib2to3/tests/support.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/support.py rename to StdLib/Lib/lib2to3/tests/support.py diff --git a/Src/StdLib/Lib/lib2to3/tests/test_all_fixers.py b/StdLib/Lib/lib2to3/tests/test_all_fixers.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/test_all_fixers.py rename to StdLib/Lib/lib2to3/tests/test_all_fixers.py diff --git a/Src/StdLib/Lib/lib2to3/tests/test_fixers.py b/StdLib/Lib/lib2to3/tests/test_fixers.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/test_fixers.py rename to StdLib/Lib/lib2to3/tests/test_fixers.py diff --git a/Src/StdLib/Lib/lib2to3/tests/test_main.py b/StdLib/Lib/lib2to3/tests/test_main.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/test_main.py rename to StdLib/Lib/lib2to3/tests/test_main.py diff --git a/Src/StdLib/Lib/lib2to3/tests/test_parser.py b/StdLib/Lib/lib2to3/tests/test_parser.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/test_parser.py rename to StdLib/Lib/lib2to3/tests/test_parser.py diff --git a/Src/StdLib/Lib/lib2to3/tests/test_pytree.py b/StdLib/Lib/lib2to3/tests/test_pytree.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/test_pytree.py rename to StdLib/Lib/lib2to3/tests/test_pytree.py diff --git a/Src/StdLib/Lib/lib2to3/tests/test_refactor.py b/StdLib/Lib/lib2to3/tests/test_refactor.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/test_refactor.py rename to StdLib/Lib/lib2to3/tests/test_refactor.py diff --git a/Src/StdLib/Lib/lib2to3/tests/test_util.py b/StdLib/Lib/lib2to3/tests/test_util.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/test_util.py rename to StdLib/Lib/lib2to3/tests/test_util.py diff --git a/Src/StdLib/Lib/linecache.py b/StdLib/Lib/linecache.py similarity index 100% rename from Src/StdLib/Lib/linecache.py rename to StdLib/Lib/linecache.py diff --git a/Src/StdLib/Lib/locale.py b/StdLib/Lib/locale.py similarity index 100% rename from Src/StdLib/Lib/locale.py rename to StdLib/Lib/locale.py diff --git a/Src/StdLib/Lib/logging/__init__.py b/StdLib/Lib/logging/__init__.py similarity index 100% rename from Src/StdLib/Lib/logging/__init__.py rename to StdLib/Lib/logging/__init__.py diff --git a/Src/StdLib/Lib/logging/config.py b/StdLib/Lib/logging/config.py similarity index 100% rename from Src/StdLib/Lib/logging/config.py rename to StdLib/Lib/logging/config.py diff --git a/Src/StdLib/Lib/logging/handlers.py b/StdLib/Lib/logging/handlers.py similarity index 100% rename from Src/StdLib/Lib/logging/handlers.py rename to StdLib/Lib/logging/handlers.py diff --git a/Src/StdLib/Lib/lzma.py b/StdLib/Lib/lzma.py similarity index 100% rename from Src/StdLib/Lib/lzma.py rename to StdLib/Lib/lzma.py diff --git a/Src/StdLib/Lib/macpath.py b/StdLib/Lib/macpath.py similarity index 100% rename from Src/StdLib/Lib/macpath.py rename to StdLib/Lib/macpath.py diff --git a/Src/StdLib/Lib/macurl2path.py b/StdLib/Lib/macurl2path.py similarity index 100% rename from Src/StdLib/Lib/macurl2path.py rename to StdLib/Lib/macurl2path.py diff --git a/Src/StdLib/Lib/mailbox.py b/StdLib/Lib/mailbox.py similarity index 100% rename from Src/StdLib/Lib/mailbox.py rename to StdLib/Lib/mailbox.py diff --git a/Src/StdLib/Lib/mailcap.py b/StdLib/Lib/mailcap.py similarity index 100% rename from Src/StdLib/Lib/mailcap.py rename to StdLib/Lib/mailcap.py diff --git a/Src/StdLib/Lib/mimetypes.py b/StdLib/Lib/mimetypes.py similarity index 100% rename from Src/StdLib/Lib/mimetypes.py rename to StdLib/Lib/mimetypes.py diff --git a/Src/StdLib/Lib/modulefinder.py b/StdLib/Lib/modulefinder.py similarity index 100% rename from Src/StdLib/Lib/modulefinder.py rename to StdLib/Lib/modulefinder.py diff --git a/Src/StdLib/Lib/msilib/__init__.py b/StdLib/Lib/msilib/__init__.py similarity index 100% rename from Src/StdLib/Lib/msilib/__init__.py rename to StdLib/Lib/msilib/__init__.py diff --git a/Src/StdLib/Lib/msilib/schema.py b/StdLib/Lib/msilib/schema.py similarity index 100% rename from Src/StdLib/Lib/msilib/schema.py rename to StdLib/Lib/msilib/schema.py diff --git a/Src/StdLib/Lib/msilib/sequence.py b/StdLib/Lib/msilib/sequence.py similarity index 100% rename from Src/StdLib/Lib/msilib/sequence.py rename to StdLib/Lib/msilib/sequence.py diff --git a/Src/StdLib/Lib/msilib/text.py b/StdLib/Lib/msilib/text.py similarity index 100% rename from Src/StdLib/Lib/msilib/text.py rename to StdLib/Lib/msilib/text.py diff --git a/Src/StdLib/Lib/multiprocessing/__init__.py b/StdLib/Lib/multiprocessing/__init__.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/__init__.py rename to StdLib/Lib/multiprocessing/__init__.py diff --git a/Src/StdLib/Lib/multiprocessing/connection.py b/StdLib/Lib/multiprocessing/connection.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/connection.py rename to StdLib/Lib/multiprocessing/connection.py diff --git a/Src/StdLib/Lib/multiprocessing/context.py b/StdLib/Lib/multiprocessing/context.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/context.py rename to StdLib/Lib/multiprocessing/context.py diff --git a/Src/StdLib/Lib/multiprocessing/dummy/__init__.py b/StdLib/Lib/multiprocessing/dummy/__init__.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/dummy/__init__.py rename to StdLib/Lib/multiprocessing/dummy/__init__.py diff --git a/Src/StdLib/Lib/multiprocessing/dummy/connection.py b/StdLib/Lib/multiprocessing/dummy/connection.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/dummy/connection.py rename to StdLib/Lib/multiprocessing/dummy/connection.py diff --git a/Src/StdLib/Lib/multiprocessing/forkserver.py b/StdLib/Lib/multiprocessing/forkserver.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/forkserver.py rename to StdLib/Lib/multiprocessing/forkserver.py diff --git a/Src/StdLib/Lib/multiprocessing/heap.py b/StdLib/Lib/multiprocessing/heap.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/heap.py rename to StdLib/Lib/multiprocessing/heap.py diff --git a/Src/StdLib/Lib/multiprocessing/managers.py b/StdLib/Lib/multiprocessing/managers.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/managers.py rename to StdLib/Lib/multiprocessing/managers.py diff --git a/Src/StdLib/Lib/multiprocessing/pool.py b/StdLib/Lib/multiprocessing/pool.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/pool.py rename to StdLib/Lib/multiprocessing/pool.py diff --git a/Src/StdLib/Lib/multiprocessing/popen_fork.py b/StdLib/Lib/multiprocessing/popen_fork.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/popen_fork.py rename to StdLib/Lib/multiprocessing/popen_fork.py diff --git a/Src/StdLib/Lib/multiprocessing/popen_forkserver.py b/StdLib/Lib/multiprocessing/popen_forkserver.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/popen_forkserver.py rename to StdLib/Lib/multiprocessing/popen_forkserver.py diff --git a/Src/StdLib/Lib/multiprocessing/popen_spawn_posix.py b/StdLib/Lib/multiprocessing/popen_spawn_posix.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/popen_spawn_posix.py rename to StdLib/Lib/multiprocessing/popen_spawn_posix.py diff --git a/Src/StdLib/Lib/multiprocessing/popen_spawn_win32.py b/StdLib/Lib/multiprocessing/popen_spawn_win32.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/popen_spawn_win32.py rename to StdLib/Lib/multiprocessing/popen_spawn_win32.py diff --git a/Src/StdLib/Lib/multiprocessing/process.py b/StdLib/Lib/multiprocessing/process.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/process.py rename to StdLib/Lib/multiprocessing/process.py diff --git a/Src/StdLib/Lib/multiprocessing/queues.py b/StdLib/Lib/multiprocessing/queues.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/queues.py rename to StdLib/Lib/multiprocessing/queues.py diff --git a/Src/StdLib/Lib/multiprocessing/reduction.py b/StdLib/Lib/multiprocessing/reduction.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/reduction.py rename to StdLib/Lib/multiprocessing/reduction.py diff --git a/Src/StdLib/Lib/multiprocessing/resource_sharer.py b/StdLib/Lib/multiprocessing/resource_sharer.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/resource_sharer.py rename to StdLib/Lib/multiprocessing/resource_sharer.py diff --git a/Src/StdLib/Lib/multiprocessing/semaphore_tracker.py b/StdLib/Lib/multiprocessing/semaphore_tracker.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/semaphore_tracker.py rename to StdLib/Lib/multiprocessing/semaphore_tracker.py diff --git a/Src/StdLib/Lib/multiprocessing/sharedctypes.py b/StdLib/Lib/multiprocessing/sharedctypes.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/sharedctypes.py rename to StdLib/Lib/multiprocessing/sharedctypes.py diff --git a/Src/StdLib/Lib/multiprocessing/spawn.py b/StdLib/Lib/multiprocessing/spawn.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/spawn.py rename to StdLib/Lib/multiprocessing/spawn.py diff --git a/Src/StdLib/Lib/multiprocessing/synchronize.py b/StdLib/Lib/multiprocessing/synchronize.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/synchronize.py rename to StdLib/Lib/multiprocessing/synchronize.py diff --git a/Src/StdLib/Lib/multiprocessing/util.py b/StdLib/Lib/multiprocessing/util.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/util.py rename to StdLib/Lib/multiprocessing/util.py diff --git a/Src/StdLib/Lib/netrc.py b/StdLib/Lib/netrc.py similarity index 100% rename from Src/StdLib/Lib/netrc.py rename to StdLib/Lib/netrc.py diff --git a/Src/StdLib/Lib/nntplib.py b/StdLib/Lib/nntplib.py similarity index 100% rename from Src/StdLib/Lib/nntplib.py rename to StdLib/Lib/nntplib.py diff --git a/Src/StdLib/Lib/ntpath.py b/StdLib/Lib/ntpath.py similarity index 100% rename from Src/StdLib/Lib/ntpath.py rename to StdLib/Lib/ntpath.py diff --git a/Src/StdLib/Lib/nturl2path.py b/StdLib/Lib/nturl2path.py similarity index 100% rename from Src/StdLib/Lib/nturl2path.py rename to StdLib/Lib/nturl2path.py diff --git a/Src/StdLib/Lib/numbers.py b/StdLib/Lib/numbers.py similarity index 100% rename from Src/StdLib/Lib/numbers.py rename to StdLib/Lib/numbers.py diff --git a/Src/StdLib/Lib/opcode.py b/StdLib/Lib/opcode.py similarity index 100% rename from Src/StdLib/Lib/opcode.py rename to StdLib/Lib/opcode.py diff --git a/Src/StdLib/Lib/operator.py b/StdLib/Lib/operator.py similarity index 100% rename from Src/StdLib/Lib/operator.py rename to StdLib/Lib/operator.py diff --git a/Src/StdLib/Lib/optparse.py b/StdLib/Lib/optparse.py similarity index 100% rename from Src/StdLib/Lib/optparse.py rename to StdLib/Lib/optparse.py diff --git a/Src/StdLib/Lib/os.py b/StdLib/Lib/os.py similarity index 100% rename from Src/StdLib/Lib/os.py rename to StdLib/Lib/os.py diff --git a/Src/StdLib/Lib/pathlib.py b/StdLib/Lib/pathlib.py similarity index 100% rename from Src/StdLib/Lib/pathlib.py rename to StdLib/Lib/pathlib.py diff --git a/Src/StdLib/Lib/pdb.py b/StdLib/Lib/pdb.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/pdb.py rename to StdLib/Lib/pdb.py diff --git a/Src/StdLib/Lib/pickle.py b/StdLib/Lib/pickle.py similarity index 100% rename from Src/StdLib/Lib/pickle.py rename to StdLib/Lib/pickle.py diff --git a/Src/StdLib/Lib/pickletools.py b/StdLib/Lib/pickletools.py similarity index 100% rename from Src/StdLib/Lib/pickletools.py rename to StdLib/Lib/pickletools.py diff --git a/Src/StdLib/Lib/pipes.py b/StdLib/Lib/pipes.py similarity index 100% rename from Src/StdLib/Lib/pipes.py rename to StdLib/Lib/pipes.py diff --git a/Src/StdLib/Lib/pkgutil.py b/StdLib/Lib/pkgutil.py similarity index 100% rename from Src/StdLib/Lib/pkgutil.py rename to StdLib/Lib/pkgutil.py diff --git a/Src/StdLib/Lib/platform.py b/StdLib/Lib/platform.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/platform.py rename to StdLib/Lib/platform.py diff --git a/Src/StdLib/Lib/plistlib.py b/StdLib/Lib/plistlib.py similarity index 100% rename from Src/StdLib/Lib/plistlib.py rename to StdLib/Lib/plistlib.py diff --git a/Src/StdLib/Lib/poplib.py b/StdLib/Lib/poplib.py similarity index 100% rename from Src/StdLib/Lib/poplib.py rename to StdLib/Lib/poplib.py diff --git a/Src/StdLib/Lib/posixpath.py b/StdLib/Lib/posixpath.py similarity index 100% rename from Src/StdLib/Lib/posixpath.py rename to StdLib/Lib/posixpath.py diff --git a/Src/StdLib/Lib/pprint.py b/StdLib/Lib/pprint.py similarity index 100% rename from Src/StdLib/Lib/pprint.py rename to StdLib/Lib/pprint.py diff --git a/Src/StdLib/Lib/profile.py b/StdLib/Lib/profile.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/profile.py rename to StdLib/Lib/profile.py diff --git a/Src/StdLib/Lib/pstats.py b/StdLib/Lib/pstats.py similarity index 100% rename from Src/StdLib/Lib/pstats.py rename to StdLib/Lib/pstats.py diff --git a/Src/StdLib/Lib/pty.py b/StdLib/Lib/pty.py similarity index 100% rename from Src/StdLib/Lib/pty.py rename to StdLib/Lib/pty.py diff --git a/Src/StdLib/Lib/py_compile.py b/StdLib/Lib/py_compile.py similarity index 100% rename from Src/StdLib/Lib/py_compile.py rename to StdLib/Lib/py_compile.py diff --git a/Src/StdLib/Lib/pyclbr.py b/StdLib/Lib/pyclbr.py similarity index 100% rename from Src/StdLib/Lib/pyclbr.py rename to StdLib/Lib/pyclbr.py diff --git a/Src/StdLib/Lib/pydoc.py b/StdLib/Lib/pydoc.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/pydoc.py rename to StdLib/Lib/pydoc.py diff --git a/Src/StdLib/Lib/pydoc_data/__init__.py b/StdLib/Lib/pydoc_data/__init__.py similarity index 100% rename from Src/StdLib/Lib/pydoc_data/__init__.py rename to StdLib/Lib/pydoc_data/__init__.py diff --git a/Src/StdLib/Lib/pydoc_data/_pydoc.css b/StdLib/Lib/pydoc_data/_pydoc.css similarity index 100% rename from Src/StdLib/Lib/pydoc_data/_pydoc.css rename to StdLib/Lib/pydoc_data/_pydoc.css diff --git a/Src/StdLib/Lib/pydoc_data/topics.py b/StdLib/Lib/pydoc_data/topics.py similarity index 100% rename from Src/StdLib/Lib/pydoc_data/topics.py rename to StdLib/Lib/pydoc_data/topics.py diff --git a/Src/StdLib/Lib/queue.py b/StdLib/Lib/queue.py similarity index 100% rename from Src/StdLib/Lib/queue.py rename to StdLib/Lib/queue.py diff --git a/Src/StdLib/Lib/quopri.py b/StdLib/Lib/quopri.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/quopri.py rename to StdLib/Lib/quopri.py diff --git a/Src/StdLib/Lib/random.py b/StdLib/Lib/random.py similarity index 100% rename from Src/StdLib/Lib/random.py rename to StdLib/Lib/random.py diff --git a/Src/StdLib/Lib/re.py b/StdLib/Lib/re.py similarity index 100% rename from Src/StdLib/Lib/re.py rename to StdLib/Lib/re.py diff --git a/Src/StdLib/Lib/reprlib.py b/StdLib/Lib/reprlib.py similarity index 100% rename from Src/StdLib/Lib/reprlib.py rename to StdLib/Lib/reprlib.py diff --git a/Src/StdLib/Lib/rlcompleter.py b/StdLib/Lib/rlcompleter.py similarity index 100% rename from Src/StdLib/Lib/rlcompleter.py rename to StdLib/Lib/rlcompleter.py diff --git a/Src/StdLib/Lib/runpy.py b/StdLib/Lib/runpy.py similarity index 100% rename from Src/StdLib/Lib/runpy.py rename to StdLib/Lib/runpy.py diff --git a/Src/StdLib/Lib/sched.py b/StdLib/Lib/sched.py similarity index 100% rename from Src/StdLib/Lib/sched.py rename to StdLib/Lib/sched.py diff --git a/Src/StdLib/Lib/selectors.py b/StdLib/Lib/selectors.py similarity index 100% rename from Src/StdLib/Lib/selectors.py rename to StdLib/Lib/selectors.py diff --git a/Src/StdLib/Lib/shelve.py b/StdLib/Lib/shelve.py similarity index 100% rename from Src/StdLib/Lib/shelve.py rename to StdLib/Lib/shelve.py diff --git a/Src/StdLib/Lib/shlex.py b/StdLib/Lib/shlex.py similarity index 100% rename from Src/StdLib/Lib/shlex.py rename to StdLib/Lib/shlex.py diff --git a/Src/StdLib/Lib/shutil.py b/StdLib/Lib/shutil.py similarity index 100% rename from Src/StdLib/Lib/shutil.py rename to StdLib/Lib/shutil.py diff --git a/Src/StdLib/Lib/site-packages/README b/StdLib/Lib/site-packages/README similarity index 100% rename from Src/StdLib/Lib/site-packages/README rename to StdLib/Lib/site-packages/README diff --git a/Src/StdLib/Lib/site.py b/StdLib/Lib/site.py similarity index 100% rename from Src/StdLib/Lib/site.py rename to StdLib/Lib/site.py diff --git a/Src/StdLib/Lib/smtpd.py b/StdLib/Lib/smtpd.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/smtpd.py rename to StdLib/Lib/smtpd.py diff --git a/Src/StdLib/Lib/smtplib.py b/StdLib/Lib/smtplib.py similarity index 100% rename from Src/StdLib/Lib/smtplib.py rename to StdLib/Lib/smtplib.py diff --git a/Src/StdLib/Lib/sndhdr.py b/StdLib/Lib/sndhdr.py similarity index 100% rename from Src/StdLib/Lib/sndhdr.py rename to StdLib/Lib/sndhdr.py diff --git a/Src/StdLib/Lib/socket.py b/StdLib/Lib/socket.py similarity index 100% rename from Src/StdLib/Lib/socket.py rename to StdLib/Lib/socket.py diff --git a/Src/StdLib/Lib/socketserver.py b/StdLib/Lib/socketserver.py similarity index 100% rename from Src/StdLib/Lib/socketserver.py rename to StdLib/Lib/socketserver.py diff --git a/Src/StdLib/Lib/sqlite3/__init__.py b/StdLib/Lib/sqlite3/__init__.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/__init__.py rename to StdLib/Lib/sqlite3/__init__.py diff --git a/Src/StdLib/Lib/sqlite3/dbapi2.py b/StdLib/Lib/sqlite3/dbapi2.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/dbapi2.py rename to StdLib/Lib/sqlite3/dbapi2.py diff --git a/Src/StdLib/Lib/sqlite3/dump.py b/StdLib/Lib/sqlite3/dump.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/dump.py rename to StdLib/Lib/sqlite3/dump.py diff --git a/Src/StdLib/Lib/sqlite3/test/__init__.py b/StdLib/Lib/sqlite3/test/__init__.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/test/__init__.py rename to StdLib/Lib/sqlite3/test/__init__.py diff --git a/Src/StdLib/Lib/sqlite3/test/dbapi.py b/StdLib/Lib/sqlite3/test/dbapi.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/test/dbapi.py rename to StdLib/Lib/sqlite3/test/dbapi.py diff --git a/Src/StdLib/Lib/sqlite3/test/dump.py b/StdLib/Lib/sqlite3/test/dump.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/test/dump.py rename to StdLib/Lib/sqlite3/test/dump.py diff --git a/Src/StdLib/Lib/sqlite3/test/factory.py b/StdLib/Lib/sqlite3/test/factory.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/test/factory.py rename to StdLib/Lib/sqlite3/test/factory.py diff --git a/Src/StdLib/Lib/sqlite3/test/hooks.py b/StdLib/Lib/sqlite3/test/hooks.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/test/hooks.py rename to StdLib/Lib/sqlite3/test/hooks.py diff --git a/Src/StdLib/Lib/sqlite3/test/regression.py b/StdLib/Lib/sqlite3/test/regression.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/test/regression.py rename to StdLib/Lib/sqlite3/test/regression.py diff --git a/Src/StdLib/Lib/sqlite3/test/transactions.py b/StdLib/Lib/sqlite3/test/transactions.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/test/transactions.py rename to StdLib/Lib/sqlite3/test/transactions.py diff --git a/Src/StdLib/Lib/sqlite3/test/types.py b/StdLib/Lib/sqlite3/test/types.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/test/types.py rename to StdLib/Lib/sqlite3/test/types.py diff --git a/Src/StdLib/Lib/sqlite3/test/userfunctions.py b/StdLib/Lib/sqlite3/test/userfunctions.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/test/userfunctions.py rename to StdLib/Lib/sqlite3/test/userfunctions.py diff --git a/Src/StdLib/Lib/sre_compile.py b/StdLib/Lib/sre_compile.py similarity index 100% rename from Src/StdLib/Lib/sre_compile.py rename to StdLib/Lib/sre_compile.py diff --git a/Src/StdLib/Lib/sre_constants.py b/StdLib/Lib/sre_constants.py similarity index 100% rename from Src/StdLib/Lib/sre_constants.py rename to StdLib/Lib/sre_constants.py diff --git a/Src/StdLib/Lib/sre_parse.py b/StdLib/Lib/sre_parse.py similarity index 100% rename from Src/StdLib/Lib/sre_parse.py rename to StdLib/Lib/sre_parse.py diff --git a/Src/StdLib/Lib/ssl.py b/StdLib/Lib/ssl.py similarity index 100% rename from Src/StdLib/Lib/ssl.py rename to StdLib/Lib/ssl.py diff --git a/Src/StdLib/Lib/stat.py b/StdLib/Lib/stat.py similarity index 100% rename from Src/StdLib/Lib/stat.py rename to StdLib/Lib/stat.py diff --git a/Src/StdLib/Lib/statistics.py b/StdLib/Lib/statistics.py similarity index 100% rename from Src/StdLib/Lib/statistics.py rename to StdLib/Lib/statistics.py diff --git a/Src/StdLib/Lib/string.py b/StdLib/Lib/string.py similarity index 100% rename from Src/StdLib/Lib/string.py rename to StdLib/Lib/string.py diff --git a/Src/StdLib/Lib/stringprep.py b/StdLib/Lib/stringprep.py similarity index 100% rename from Src/StdLib/Lib/stringprep.py rename to StdLib/Lib/stringprep.py diff --git a/Src/StdLib/Lib/struct.py b/StdLib/Lib/struct.py similarity index 100% rename from Src/StdLib/Lib/struct.py rename to StdLib/Lib/struct.py diff --git a/Src/StdLib/Lib/subprocess.py b/StdLib/Lib/subprocess.py similarity index 100% rename from Src/StdLib/Lib/subprocess.py rename to StdLib/Lib/subprocess.py diff --git a/Src/StdLib/Lib/sunau.py b/StdLib/Lib/sunau.py similarity index 100% rename from Src/StdLib/Lib/sunau.py rename to StdLib/Lib/sunau.py diff --git a/Src/StdLib/Lib/symbol.py b/StdLib/Lib/symbol.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/symbol.py rename to StdLib/Lib/symbol.py diff --git a/Src/StdLib/Lib/symtable.py b/StdLib/Lib/symtable.py similarity index 100% rename from Src/StdLib/Lib/symtable.py rename to StdLib/Lib/symtable.py diff --git a/Src/StdLib/Lib/sysconfig.py b/StdLib/Lib/sysconfig.py similarity index 100% rename from Src/StdLib/Lib/sysconfig.py rename to StdLib/Lib/sysconfig.py diff --git a/Src/StdLib/Lib/tabnanny.py b/StdLib/Lib/tabnanny.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/tabnanny.py rename to StdLib/Lib/tabnanny.py diff --git a/Src/StdLib/Lib/tarfile.py b/StdLib/Lib/tarfile.py similarity index 100% rename from Src/StdLib/Lib/tarfile.py rename to StdLib/Lib/tarfile.py diff --git a/Src/StdLib/Lib/telnetlib.py b/StdLib/Lib/telnetlib.py similarity index 100% rename from Src/StdLib/Lib/telnetlib.py rename to StdLib/Lib/telnetlib.py diff --git a/Src/StdLib/Lib/tempfile.py b/StdLib/Lib/tempfile.py similarity index 100% rename from Src/StdLib/Lib/tempfile.py rename to StdLib/Lib/tempfile.py diff --git a/Src/StdLib/Lib/test/185test.db b/StdLib/Lib/test/185test.db similarity index 100% rename from Src/StdLib/Lib/test/185test.db rename to StdLib/Lib/test/185test.db diff --git a/Src/StdLib/Lib/test/Sine-1000Hz-300ms.aif b/StdLib/Lib/test/Sine-1000Hz-300ms.aif similarity index 100% rename from Src/StdLib/Lib/test/Sine-1000Hz-300ms.aif rename to StdLib/Lib/test/Sine-1000Hz-300ms.aif diff --git a/Src/StdLib/Lib/test/__init__.py b/StdLib/Lib/test/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/__init__.py rename to StdLib/Lib/test/__init__.py diff --git a/Src/StdLib/Lib/test/__main__.py b/StdLib/Lib/test/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/__main__.py rename to StdLib/Lib/test/__main__.py diff --git a/Src/StdLib/Lib/test/_test_multiprocessing.py b/StdLib/Lib/test/_test_multiprocessing.py similarity index 100% rename from Src/StdLib/Lib/test/_test_multiprocessing.py rename to StdLib/Lib/test/_test_multiprocessing.py diff --git a/Src/StdLib/Lib/test/audiodata/pluck-alaw.aifc b/StdLib/Lib/test/audiodata/pluck-alaw.aifc similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-alaw.aifc rename to StdLib/Lib/test/audiodata/pluck-alaw.aifc diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm16.aiff b/StdLib/Lib/test/audiodata/pluck-pcm16.aiff similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm16.aiff rename to StdLib/Lib/test/audiodata/pluck-pcm16.aiff diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm16.au b/StdLib/Lib/test/audiodata/pluck-pcm16.au similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm16.au rename to StdLib/Lib/test/audiodata/pluck-pcm16.au diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm16.wav b/StdLib/Lib/test/audiodata/pluck-pcm16.wav similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm16.wav rename to StdLib/Lib/test/audiodata/pluck-pcm16.wav diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm24.aiff b/StdLib/Lib/test/audiodata/pluck-pcm24.aiff similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm24.aiff rename to StdLib/Lib/test/audiodata/pluck-pcm24.aiff diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm24.au b/StdLib/Lib/test/audiodata/pluck-pcm24.au similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm24.au rename to StdLib/Lib/test/audiodata/pluck-pcm24.au diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm24.wav b/StdLib/Lib/test/audiodata/pluck-pcm24.wav similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm24.wav rename to StdLib/Lib/test/audiodata/pluck-pcm24.wav diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm32.aiff b/StdLib/Lib/test/audiodata/pluck-pcm32.aiff similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm32.aiff rename to StdLib/Lib/test/audiodata/pluck-pcm32.aiff diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm32.au b/StdLib/Lib/test/audiodata/pluck-pcm32.au similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm32.au rename to StdLib/Lib/test/audiodata/pluck-pcm32.au diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm32.wav b/StdLib/Lib/test/audiodata/pluck-pcm32.wav similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm32.wav rename to StdLib/Lib/test/audiodata/pluck-pcm32.wav diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm8.aiff b/StdLib/Lib/test/audiodata/pluck-pcm8.aiff similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm8.aiff rename to StdLib/Lib/test/audiodata/pluck-pcm8.aiff diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm8.au b/StdLib/Lib/test/audiodata/pluck-pcm8.au similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm8.au rename to StdLib/Lib/test/audiodata/pluck-pcm8.au diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm8.wav b/StdLib/Lib/test/audiodata/pluck-pcm8.wav similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm8.wav rename to StdLib/Lib/test/audiodata/pluck-pcm8.wav diff --git a/Src/StdLib/Lib/test/audiodata/pluck-ulaw.aifc b/StdLib/Lib/test/audiodata/pluck-ulaw.aifc similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-ulaw.aifc rename to StdLib/Lib/test/audiodata/pluck-ulaw.aifc diff --git a/Src/StdLib/Lib/test/audiodata/pluck-ulaw.au b/StdLib/Lib/test/audiodata/pluck-ulaw.au similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-ulaw.au rename to StdLib/Lib/test/audiodata/pluck-ulaw.au diff --git a/Src/StdLib/Lib/test/audiotest.au b/StdLib/Lib/test/audiotest.au similarity index 100% rename from Src/StdLib/Lib/test/audiotest.au rename to StdLib/Lib/test/audiotest.au diff --git a/Src/StdLib/Lib/test/audiotests.py b/StdLib/Lib/test/audiotests.py similarity index 100% rename from Src/StdLib/Lib/test/audiotests.py rename to StdLib/Lib/test/audiotests.py diff --git a/Src/StdLib/Lib/test/autotest.py b/StdLib/Lib/test/autotest.py similarity index 100% rename from Src/StdLib/Lib/test/autotest.py rename to StdLib/Lib/test/autotest.py diff --git a/Src/StdLib/Lib/test/bad_coding.py b/StdLib/Lib/test/bad_coding.py similarity index 100% rename from Src/StdLib/Lib/test/bad_coding.py rename to StdLib/Lib/test/bad_coding.py diff --git a/Src/StdLib/Lib/test/bad_coding2.py b/StdLib/Lib/test/bad_coding2.py similarity index 100% rename from Src/StdLib/Lib/test/bad_coding2.py rename to StdLib/Lib/test/bad_coding2.py diff --git a/Src/StdLib/Lib/test/badcert.pem b/StdLib/Lib/test/badcert.pem similarity index 100% rename from Src/StdLib/Lib/test/badcert.pem rename to StdLib/Lib/test/badcert.pem diff --git a/Src/StdLib/Lib/test/badkey.pem b/StdLib/Lib/test/badkey.pem similarity index 100% rename from Src/StdLib/Lib/test/badkey.pem rename to StdLib/Lib/test/badkey.pem diff --git a/Src/StdLib/Lib/test/badsyntax_3131.py b/StdLib/Lib/test/badsyntax_3131.py similarity index 100% rename from Src/StdLib/Lib/test/badsyntax_3131.py rename to StdLib/Lib/test/badsyntax_3131.py diff --git a/Src/StdLib/Lib/test/badsyntax_future10.py b/StdLib/Lib/test/badsyntax_future10.py similarity index 100% rename from Src/StdLib/Lib/test/badsyntax_future10.py rename to StdLib/Lib/test/badsyntax_future10.py diff --git a/Src/StdLib/Lib/test/badsyntax_future3.py b/StdLib/Lib/test/badsyntax_future3.py similarity index 100% rename from Src/StdLib/Lib/test/badsyntax_future3.py rename to StdLib/Lib/test/badsyntax_future3.py diff --git a/Src/StdLib/Lib/test/badsyntax_future4.py b/StdLib/Lib/test/badsyntax_future4.py similarity index 100% rename from Src/StdLib/Lib/test/badsyntax_future4.py rename to StdLib/Lib/test/badsyntax_future4.py diff --git a/Src/StdLib/Lib/test/badsyntax_future5.py b/StdLib/Lib/test/badsyntax_future5.py similarity index 100% rename from Src/StdLib/Lib/test/badsyntax_future5.py rename to StdLib/Lib/test/badsyntax_future5.py diff --git a/Src/StdLib/Lib/test/badsyntax_future6.py b/StdLib/Lib/test/badsyntax_future6.py similarity index 100% rename from Src/StdLib/Lib/test/badsyntax_future6.py rename to StdLib/Lib/test/badsyntax_future6.py diff --git a/Src/StdLib/Lib/test/badsyntax_future7.py b/StdLib/Lib/test/badsyntax_future7.py similarity index 100% rename from Src/StdLib/Lib/test/badsyntax_future7.py rename to StdLib/Lib/test/badsyntax_future7.py diff --git a/Src/StdLib/Lib/test/badsyntax_future8.py b/StdLib/Lib/test/badsyntax_future8.py similarity index 100% rename from Src/StdLib/Lib/test/badsyntax_future8.py rename to StdLib/Lib/test/badsyntax_future8.py diff --git a/Src/StdLib/Lib/test/badsyntax_future9.py b/StdLib/Lib/test/badsyntax_future9.py similarity index 100% rename from Src/StdLib/Lib/test/badsyntax_future9.py rename to StdLib/Lib/test/badsyntax_future9.py diff --git a/Src/StdLib/Lib/test/badsyntax_pep3120.py b/StdLib/Lib/test/badsyntax_pep3120.py similarity index 100% rename from Src/StdLib/Lib/test/badsyntax_pep3120.py rename to StdLib/Lib/test/badsyntax_pep3120.py diff --git a/Src/StdLib/Lib/test/buffer_tests.py b/StdLib/Lib/test/buffer_tests.py similarity index 100% rename from Src/StdLib/Lib/test/buffer_tests.py rename to StdLib/Lib/test/buffer_tests.py diff --git a/Src/StdLib/Lib/test/bytecode_helper.py b/StdLib/Lib/test/bytecode_helper.py similarity index 100% rename from Src/StdLib/Lib/test/bytecode_helper.py rename to StdLib/Lib/test/bytecode_helper.py diff --git a/Src/StdLib/Lib/test/capath/0e4015b9.0 b/StdLib/Lib/test/capath/0e4015b9.0 similarity index 100% rename from Src/StdLib/Lib/test/capath/0e4015b9.0 rename to StdLib/Lib/test/capath/0e4015b9.0 diff --git a/Src/StdLib/Lib/test/capath/4e1295a3.0 b/StdLib/Lib/test/capath/4e1295a3.0 similarity index 100% rename from Src/StdLib/Lib/test/capath/4e1295a3.0 rename to StdLib/Lib/test/capath/4e1295a3.0 diff --git a/Src/StdLib/Lib/test/capath/5ed36f99.0 b/StdLib/Lib/test/capath/5ed36f99.0 similarity index 100% rename from Src/StdLib/Lib/test/capath/5ed36f99.0 rename to StdLib/Lib/test/capath/5ed36f99.0 diff --git a/Src/StdLib/Lib/test/capath/6e88d7b8.0 b/StdLib/Lib/test/capath/6e88d7b8.0 similarity index 100% rename from Src/StdLib/Lib/test/capath/6e88d7b8.0 rename to StdLib/Lib/test/capath/6e88d7b8.0 diff --git a/Src/StdLib/Lib/test/capath/99d0fa06.0 b/StdLib/Lib/test/capath/99d0fa06.0 similarity index 100% rename from Src/StdLib/Lib/test/capath/99d0fa06.0 rename to StdLib/Lib/test/capath/99d0fa06.0 diff --git a/Src/StdLib/Lib/test/capath/ce7b8643.0 b/StdLib/Lib/test/capath/ce7b8643.0 similarity index 100% rename from Src/StdLib/Lib/test/capath/ce7b8643.0 rename to StdLib/Lib/test/capath/ce7b8643.0 diff --git a/Src/StdLib/Lib/test/cfgparser.1 b/StdLib/Lib/test/cfgparser.1 similarity index 100% rename from Src/StdLib/Lib/test/cfgparser.1 rename to StdLib/Lib/test/cfgparser.1 diff --git a/Src/StdLib/Lib/test/cfgparser.2 b/StdLib/Lib/test/cfgparser.2 similarity index 100% rename from Src/StdLib/Lib/test/cfgparser.2 rename to StdLib/Lib/test/cfgparser.2 diff --git a/Src/StdLib/Lib/test/cfgparser.3 b/StdLib/Lib/test/cfgparser.3 similarity index 100% rename from Src/StdLib/Lib/test/cfgparser.3 rename to StdLib/Lib/test/cfgparser.3 diff --git a/Src/StdLib/Lib/test/check_soundcard.vbs b/StdLib/Lib/test/check_soundcard.vbs similarity index 100% rename from Src/StdLib/Lib/test/check_soundcard.vbs rename to StdLib/Lib/test/check_soundcard.vbs diff --git a/Src/StdLib/Lib/test/cjkencodings/big5-utf8.txt b/StdLib/Lib/test/cjkencodings/big5-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/big5-utf8.txt rename to StdLib/Lib/test/cjkencodings/big5-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/big5.txt b/StdLib/Lib/test/cjkencodings/big5.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/big5.txt rename to StdLib/Lib/test/cjkencodings/big5.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt b/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt rename to StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/big5hkscs.txt b/StdLib/Lib/test/cjkencodings/big5hkscs.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/big5hkscs.txt rename to StdLib/Lib/test/cjkencodings/big5hkscs.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/cp949-utf8.txt b/StdLib/Lib/test/cjkencodings/cp949-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/cp949-utf8.txt rename to StdLib/Lib/test/cjkencodings/cp949-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/cp949.txt b/StdLib/Lib/test/cjkencodings/cp949.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/cp949.txt rename to StdLib/Lib/test/cjkencodings/cp949.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt b/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt rename to StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt b/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt rename to StdLib/Lib/test/cjkencodings/euc_jisx0213.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt b/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt rename to StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/euc_jp.txt b/StdLib/Lib/test/cjkencodings/euc_jp.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/euc_jp.txt rename to StdLib/Lib/test/cjkencodings/euc_jp.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt b/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt rename to StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/euc_kr.txt b/StdLib/Lib/test/cjkencodings/euc_kr.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/euc_kr.txt rename to StdLib/Lib/test/cjkencodings/euc_kr.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt b/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt rename to StdLib/Lib/test/cjkencodings/gb18030-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/gb18030.txt b/StdLib/Lib/test/cjkencodings/gb18030.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/gb18030.txt rename to StdLib/Lib/test/cjkencodings/gb18030.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt b/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt rename to StdLib/Lib/test/cjkencodings/gb2312-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/gb2312.txt b/StdLib/Lib/test/cjkencodings/gb2312.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/gb2312.txt rename to StdLib/Lib/test/cjkencodings/gb2312.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/gbk-utf8.txt b/StdLib/Lib/test/cjkencodings/gbk-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/gbk-utf8.txt rename to StdLib/Lib/test/cjkencodings/gbk-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/gbk.txt b/StdLib/Lib/test/cjkencodings/gbk.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/gbk.txt rename to StdLib/Lib/test/cjkencodings/gbk.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/hz-utf8.txt b/StdLib/Lib/test/cjkencodings/hz-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/hz-utf8.txt rename to StdLib/Lib/test/cjkencodings/hz-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/hz.txt b/StdLib/Lib/test/cjkencodings/hz.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/hz.txt rename to StdLib/Lib/test/cjkencodings/hz.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt b/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt rename to StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/iso2022_jp.txt b/StdLib/Lib/test/cjkencodings/iso2022_jp.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/iso2022_jp.txt rename to StdLib/Lib/test/cjkencodings/iso2022_jp.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt b/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt rename to StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/iso2022_kr.txt b/StdLib/Lib/test/cjkencodings/iso2022_kr.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/iso2022_kr.txt rename to StdLib/Lib/test/cjkencodings/iso2022_kr.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/johab-utf8.txt b/StdLib/Lib/test/cjkencodings/johab-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/johab-utf8.txt rename to StdLib/Lib/test/cjkencodings/johab-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/johab.txt b/StdLib/Lib/test/cjkencodings/johab.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/johab.txt rename to StdLib/Lib/test/cjkencodings/johab.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt b/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt rename to StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/shift_jis.txt b/StdLib/Lib/test/cjkencodings/shift_jis.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/shift_jis.txt rename to StdLib/Lib/test/cjkencodings/shift_jis.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt b/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt rename to StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt b/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt rename to StdLib/Lib/test/cjkencodings/shift_jisx0213.txt diff --git a/Src/StdLib/Lib/test/cmath_testcases.txt b/StdLib/Lib/test/cmath_testcases.txt similarity index 100% rename from Src/StdLib/Lib/test/cmath_testcases.txt rename to StdLib/Lib/test/cmath_testcases.txt diff --git a/Src/StdLib/Lib/test/coding20731.py b/StdLib/Lib/test/coding20731.py similarity index 100% rename from Src/StdLib/Lib/test/coding20731.py rename to StdLib/Lib/test/coding20731.py diff --git a/Src/StdLib/Lib/test/crashers/README b/StdLib/Lib/test/crashers/README similarity index 100% rename from Src/StdLib/Lib/test/crashers/README rename to StdLib/Lib/test/crashers/README diff --git a/Src/StdLib/Lib/test/crashers/bogus_code_obj.py b/StdLib/Lib/test/crashers/bogus_code_obj.py similarity index 100% rename from Src/StdLib/Lib/test/crashers/bogus_code_obj.py rename to StdLib/Lib/test/crashers/bogus_code_obj.py diff --git a/Src/StdLib/Lib/test/crashers/gc_inspection.py b/StdLib/Lib/test/crashers/gc_inspection.py similarity index 100% rename from Src/StdLib/Lib/test/crashers/gc_inspection.py rename to StdLib/Lib/test/crashers/gc_inspection.py diff --git a/Src/StdLib/Lib/test/crashers/infinite_loop_re.py b/StdLib/Lib/test/crashers/infinite_loop_re.py similarity index 100% rename from Src/StdLib/Lib/test/crashers/infinite_loop_re.py rename to StdLib/Lib/test/crashers/infinite_loop_re.py diff --git a/Src/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py b/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py similarity index 100% rename from Src/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py rename to StdLib/Lib/test/crashers/mutation_inside_cyclegc.py diff --git a/Src/StdLib/Lib/test/crashers/recursive_call.py b/StdLib/Lib/test/crashers/recursive_call.py similarity index 100% rename from Src/StdLib/Lib/test/crashers/recursive_call.py rename to StdLib/Lib/test/crashers/recursive_call.py diff --git a/Src/StdLib/Lib/test/crashers/trace_at_recursion_limit.py b/StdLib/Lib/test/crashers/trace_at_recursion_limit.py similarity index 100% rename from Src/StdLib/Lib/test/crashers/trace_at_recursion_limit.py rename to StdLib/Lib/test/crashers/trace_at_recursion_limit.py diff --git a/Src/StdLib/Lib/test/crashers/underlying_dict.py b/StdLib/Lib/test/crashers/underlying_dict.py similarity index 100% rename from Src/StdLib/Lib/test/crashers/underlying_dict.py rename to StdLib/Lib/test/crashers/underlying_dict.py diff --git a/Src/StdLib/Lib/test/curses_tests.py b/StdLib/Lib/test/curses_tests.py similarity index 100% rename from Src/StdLib/Lib/test/curses_tests.py rename to StdLib/Lib/test/curses_tests.py diff --git a/Src/StdLib/Lib/test/data/README b/StdLib/Lib/test/data/README similarity index 100% rename from Src/StdLib/Lib/test/data/README rename to StdLib/Lib/test/data/README diff --git a/Src/StdLib/Lib/test/datetimetester.py b/StdLib/Lib/test/datetimetester.py similarity index 100% rename from Src/StdLib/Lib/test/datetimetester.py rename to StdLib/Lib/test/datetimetester.py diff --git a/Src/StdLib/Lib/test/decimaltestdata/abs.decTest b/StdLib/Lib/test/decimaltestdata/abs.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/abs.decTest rename to StdLib/Lib/test/decimaltestdata/abs.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/add.decTest b/StdLib/Lib/test/decimaltestdata/add.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/add.decTest rename to StdLib/Lib/test/decimaltestdata/add.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/and.decTest b/StdLib/Lib/test/decimaltestdata/and.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/and.decTest rename to StdLib/Lib/test/decimaltestdata/and.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/base.decTest b/StdLib/Lib/test/decimaltestdata/base.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/base.decTest rename to StdLib/Lib/test/decimaltestdata/base.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/clamp.decTest b/StdLib/Lib/test/decimaltestdata/clamp.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/clamp.decTest rename to StdLib/Lib/test/decimaltestdata/clamp.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/class.decTest b/StdLib/Lib/test/decimaltestdata/class.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/class.decTest rename to StdLib/Lib/test/decimaltestdata/class.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/compare.decTest b/StdLib/Lib/test/decimaltestdata/compare.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/compare.decTest rename to StdLib/Lib/test/decimaltestdata/compare.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/comparetotal.decTest b/StdLib/Lib/test/decimaltestdata/comparetotal.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/comparetotal.decTest rename to StdLib/Lib/test/decimaltestdata/comparetotal.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest b/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest rename to StdLib/Lib/test/decimaltestdata/comparetotmag.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/copy.decTest b/StdLib/Lib/test/decimaltestdata/copy.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/copy.decTest rename to StdLib/Lib/test/decimaltestdata/copy.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/copyabs.decTest b/StdLib/Lib/test/decimaltestdata/copyabs.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/copyabs.decTest rename to StdLib/Lib/test/decimaltestdata/copyabs.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/copynegate.decTest b/StdLib/Lib/test/decimaltestdata/copynegate.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/copynegate.decTest rename to StdLib/Lib/test/decimaltestdata/copynegate.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/copysign.decTest b/StdLib/Lib/test/decimaltestdata/copysign.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/copysign.decTest rename to StdLib/Lib/test/decimaltestdata/copysign.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddAbs.decTest b/StdLib/Lib/test/decimaltestdata/ddAbs.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddAbs.decTest rename to StdLib/Lib/test/decimaltestdata/ddAbs.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddAdd.decTest b/StdLib/Lib/test/decimaltestdata/ddAdd.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddAdd.decTest rename to StdLib/Lib/test/decimaltestdata/ddAdd.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddAnd.decTest b/StdLib/Lib/test/decimaltestdata/ddAnd.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddAnd.decTest rename to StdLib/Lib/test/decimaltestdata/ddAnd.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddBase.decTest b/StdLib/Lib/test/decimaltestdata/ddBase.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddBase.decTest rename to StdLib/Lib/test/decimaltestdata/ddBase.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest b/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest rename to StdLib/Lib/test/decimaltestdata/ddCanonical.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddClass.decTest b/StdLib/Lib/test/decimaltestdata/ddClass.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddClass.decTest rename to StdLib/Lib/test/decimaltestdata/ddClass.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddCompare.decTest b/StdLib/Lib/test/decimaltestdata/ddCompare.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddCompare.decTest rename to StdLib/Lib/test/decimaltestdata/ddCompare.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest b/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest rename to StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest b/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest rename to StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest b/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest rename to StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddCopy.decTest b/StdLib/Lib/test/decimaltestdata/ddCopy.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddCopy.decTest rename to StdLib/Lib/test/decimaltestdata/ddCopy.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest b/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest rename to StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest b/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest rename to StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest b/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest rename to StdLib/Lib/test/decimaltestdata/ddCopySign.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddDivide.decTest b/StdLib/Lib/test/decimaltestdata/ddDivide.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddDivide.decTest rename to StdLib/Lib/test/decimaltestdata/ddDivide.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest b/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest rename to StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddEncode.decTest b/StdLib/Lib/test/decimaltestdata/ddEncode.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddEncode.decTest rename to StdLib/Lib/test/decimaltestdata/ddEncode.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddFMA.decTest b/StdLib/Lib/test/decimaltestdata/ddFMA.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddFMA.decTest rename to StdLib/Lib/test/decimaltestdata/ddFMA.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddInvert.decTest b/StdLib/Lib/test/decimaltestdata/ddInvert.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddInvert.decTest rename to StdLib/Lib/test/decimaltestdata/ddInvert.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddLogB.decTest b/StdLib/Lib/test/decimaltestdata/ddLogB.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddLogB.decTest rename to StdLib/Lib/test/decimaltestdata/ddLogB.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddMax.decTest b/StdLib/Lib/test/decimaltestdata/ddMax.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddMax.decTest rename to StdLib/Lib/test/decimaltestdata/ddMax.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest b/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest rename to StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddMin.decTest b/StdLib/Lib/test/decimaltestdata/ddMin.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddMin.decTest rename to StdLib/Lib/test/decimaltestdata/ddMin.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest b/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest rename to StdLib/Lib/test/decimaltestdata/ddMinMag.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddMinus.decTest b/StdLib/Lib/test/decimaltestdata/ddMinus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddMinus.decTest rename to StdLib/Lib/test/decimaltestdata/ddMinus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest b/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest rename to StdLib/Lib/test/decimaltestdata/ddMultiply.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest b/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest rename to StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest b/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest rename to StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest b/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest rename to StdLib/Lib/test/decimaltestdata/ddNextToward.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddOr.decTest b/StdLib/Lib/test/decimaltestdata/ddOr.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddOr.decTest rename to StdLib/Lib/test/decimaltestdata/ddOr.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddPlus.decTest b/StdLib/Lib/test/decimaltestdata/ddPlus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddPlus.decTest rename to StdLib/Lib/test/decimaltestdata/ddPlus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest b/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest rename to StdLib/Lib/test/decimaltestdata/ddQuantize.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddReduce.decTest b/StdLib/Lib/test/decimaltestdata/ddReduce.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddReduce.decTest rename to StdLib/Lib/test/decimaltestdata/ddReduce.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest b/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest rename to StdLib/Lib/test/decimaltestdata/ddRemainder.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest b/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest rename to StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddRotate.decTest b/StdLib/Lib/test/decimaltestdata/ddRotate.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddRotate.decTest rename to StdLib/Lib/test/decimaltestdata/ddRotate.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest b/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest rename to StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest b/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest rename to StdLib/Lib/test/decimaltestdata/ddScaleB.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddShift.decTest b/StdLib/Lib/test/decimaltestdata/ddShift.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddShift.decTest rename to StdLib/Lib/test/decimaltestdata/ddShift.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest b/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest rename to StdLib/Lib/test/decimaltestdata/ddSubtract.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest b/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest rename to StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddXor.decTest b/StdLib/Lib/test/decimaltestdata/ddXor.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddXor.decTest rename to StdLib/Lib/test/decimaltestdata/ddXor.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/decDouble.decTest b/StdLib/Lib/test/decimaltestdata/decDouble.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/decDouble.decTest rename to StdLib/Lib/test/decimaltestdata/decDouble.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/decQuad.decTest b/StdLib/Lib/test/decimaltestdata/decQuad.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/decQuad.decTest rename to StdLib/Lib/test/decimaltestdata/decQuad.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/decSingle.decTest b/StdLib/Lib/test/decimaltestdata/decSingle.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/decSingle.decTest rename to StdLib/Lib/test/decimaltestdata/decSingle.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/divide.decTest b/StdLib/Lib/test/decimaltestdata/divide.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/divide.decTest rename to StdLib/Lib/test/decimaltestdata/divide.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/divideint.decTest b/StdLib/Lib/test/decimaltestdata/divideint.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/divideint.decTest rename to StdLib/Lib/test/decimaltestdata/divideint.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqAbs.decTest b/StdLib/Lib/test/decimaltestdata/dqAbs.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqAbs.decTest rename to StdLib/Lib/test/decimaltestdata/dqAbs.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqAdd.decTest b/StdLib/Lib/test/decimaltestdata/dqAdd.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqAdd.decTest rename to StdLib/Lib/test/decimaltestdata/dqAdd.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqAnd.decTest b/StdLib/Lib/test/decimaltestdata/dqAnd.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqAnd.decTest rename to StdLib/Lib/test/decimaltestdata/dqAnd.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqBase.decTest b/StdLib/Lib/test/decimaltestdata/dqBase.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqBase.decTest rename to StdLib/Lib/test/decimaltestdata/dqBase.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest b/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest rename to StdLib/Lib/test/decimaltestdata/dqCanonical.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqClass.decTest b/StdLib/Lib/test/decimaltestdata/dqClass.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqClass.decTest rename to StdLib/Lib/test/decimaltestdata/dqClass.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqCompare.decTest b/StdLib/Lib/test/decimaltestdata/dqCompare.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqCompare.decTest rename to StdLib/Lib/test/decimaltestdata/dqCompare.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest b/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest rename to StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest b/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest rename to StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest b/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest rename to StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqCopy.decTest b/StdLib/Lib/test/decimaltestdata/dqCopy.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqCopy.decTest rename to StdLib/Lib/test/decimaltestdata/dqCopy.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest b/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest rename to StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest b/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest rename to StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest b/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest rename to StdLib/Lib/test/decimaltestdata/dqCopySign.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqDivide.decTest b/StdLib/Lib/test/decimaltestdata/dqDivide.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqDivide.decTest rename to StdLib/Lib/test/decimaltestdata/dqDivide.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest b/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest rename to StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqEncode.decTest b/StdLib/Lib/test/decimaltestdata/dqEncode.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqEncode.decTest rename to StdLib/Lib/test/decimaltestdata/dqEncode.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqFMA.decTest b/StdLib/Lib/test/decimaltestdata/dqFMA.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqFMA.decTest rename to StdLib/Lib/test/decimaltestdata/dqFMA.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqInvert.decTest b/StdLib/Lib/test/decimaltestdata/dqInvert.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqInvert.decTest rename to StdLib/Lib/test/decimaltestdata/dqInvert.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqLogB.decTest b/StdLib/Lib/test/decimaltestdata/dqLogB.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqLogB.decTest rename to StdLib/Lib/test/decimaltestdata/dqLogB.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqMax.decTest b/StdLib/Lib/test/decimaltestdata/dqMax.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqMax.decTest rename to StdLib/Lib/test/decimaltestdata/dqMax.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest b/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest rename to StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqMin.decTest b/StdLib/Lib/test/decimaltestdata/dqMin.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqMin.decTest rename to StdLib/Lib/test/decimaltestdata/dqMin.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest b/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest rename to StdLib/Lib/test/decimaltestdata/dqMinMag.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqMinus.decTest b/StdLib/Lib/test/decimaltestdata/dqMinus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqMinus.decTest rename to StdLib/Lib/test/decimaltestdata/dqMinus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest b/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest rename to StdLib/Lib/test/decimaltestdata/dqMultiply.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest b/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest rename to StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest b/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest rename to StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest b/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest rename to StdLib/Lib/test/decimaltestdata/dqNextToward.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqOr.decTest b/StdLib/Lib/test/decimaltestdata/dqOr.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqOr.decTest rename to StdLib/Lib/test/decimaltestdata/dqOr.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqPlus.decTest b/StdLib/Lib/test/decimaltestdata/dqPlus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqPlus.decTest rename to StdLib/Lib/test/decimaltestdata/dqPlus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest b/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest rename to StdLib/Lib/test/decimaltestdata/dqQuantize.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqReduce.decTest b/StdLib/Lib/test/decimaltestdata/dqReduce.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqReduce.decTest rename to StdLib/Lib/test/decimaltestdata/dqReduce.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest b/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest rename to StdLib/Lib/test/decimaltestdata/dqRemainder.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest b/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest rename to StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqRotate.decTest b/StdLib/Lib/test/decimaltestdata/dqRotate.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqRotate.decTest rename to StdLib/Lib/test/decimaltestdata/dqRotate.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest b/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest rename to StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest b/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest rename to StdLib/Lib/test/decimaltestdata/dqScaleB.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqShift.decTest b/StdLib/Lib/test/decimaltestdata/dqShift.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqShift.decTest rename to StdLib/Lib/test/decimaltestdata/dqShift.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest b/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest rename to StdLib/Lib/test/decimaltestdata/dqSubtract.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest b/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest rename to StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqXor.decTest b/StdLib/Lib/test/decimaltestdata/dqXor.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqXor.decTest rename to StdLib/Lib/test/decimaltestdata/dqXor.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dsBase.decTest b/StdLib/Lib/test/decimaltestdata/dsBase.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dsBase.decTest rename to StdLib/Lib/test/decimaltestdata/dsBase.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dsEncode.decTest b/StdLib/Lib/test/decimaltestdata/dsEncode.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dsEncode.decTest rename to StdLib/Lib/test/decimaltestdata/dsEncode.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/exp.decTest b/StdLib/Lib/test/decimaltestdata/exp.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/exp.decTest rename to StdLib/Lib/test/decimaltestdata/exp.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/extra.decTest b/StdLib/Lib/test/decimaltestdata/extra.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/extra.decTest rename to StdLib/Lib/test/decimaltestdata/extra.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/fma.decTest b/StdLib/Lib/test/decimaltestdata/fma.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/fma.decTest rename to StdLib/Lib/test/decimaltestdata/fma.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/inexact.decTest b/StdLib/Lib/test/decimaltestdata/inexact.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/inexact.decTest rename to StdLib/Lib/test/decimaltestdata/inexact.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/invert.decTest b/StdLib/Lib/test/decimaltestdata/invert.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/invert.decTest rename to StdLib/Lib/test/decimaltestdata/invert.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ln.decTest b/StdLib/Lib/test/decimaltestdata/ln.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ln.decTest rename to StdLib/Lib/test/decimaltestdata/ln.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/log10.decTest b/StdLib/Lib/test/decimaltestdata/log10.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/log10.decTest rename to StdLib/Lib/test/decimaltestdata/log10.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/logb.decTest b/StdLib/Lib/test/decimaltestdata/logb.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/logb.decTest rename to StdLib/Lib/test/decimaltestdata/logb.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/max.decTest b/StdLib/Lib/test/decimaltestdata/max.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/max.decTest rename to StdLib/Lib/test/decimaltestdata/max.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/maxmag.decTest b/StdLib/Lib/test/decimaltestdata/maxmag.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/maxmag.decTest rename to StdLib/Lib/test/decimaltestdata/maxmag.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/min.decTest b/StdLib/Lib/test/decimaltestdata/min.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/min.decTest rename to StdLib/Lib/test/decimaltestdata/min.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/minmag.decTest b/StdLib/Lib/test/decimaltestdata/minmag.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/minmag.decTest rename to StdLib/Lib/test/decimaltestdata/minmag.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/minus.decTest b/StdLib/Lib/test/decimaltestdata/minus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/minus.decTest rename to StdLib/Lib/test/decimaltestdata/minus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/multiply.decTest b/StdLib/Lib/test/decimaltestdata/multiply.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/multiply.decTest rename to StdLib/Lib/test/decimaltestdata/multiply.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/nextminus.decTest b/StdLib/Lib/test/decimaltestdata/nextminus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/nextminus.decTest rename to StdLib/Lib/test/decimaltestdata/nextminus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/nextplus.decTest b/StdLib/Lib/test/decimaltestdata/nextplus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/nextplus.decTest rename to StdLib/Lib/test/decimaltestdata/nextplus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/nexttoward.decTest b/StdLib/Lib/test/decimaltestdata/nexttoward.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/nexttoward.decTest rename to StdLib/Lib/test/decimaltestdata/nexttoward.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/or.decTest b/StdLib/Lib/test/decimaltestdata/or.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/or.decTest rename to StdLib/Lib/test/decimaltestdata/or.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/plus.decTest b/StdLib/Lib/test/decimaltestdata/plus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/plus.decTest rename to StdLib/Lib/test/decimaltestdata/plus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/power.decTest b/StdLib/Lib/test/decimaltestdata/power.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/power.decTest rename to StdLib/Lib/test/decimaltestdata/power.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/powersqrt.decTest b/StdLib/Lib/test/decimaltestdata/powersqrt.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/powersqrt.decTest rename to StdLib/Lib/test/decimaltestdata/powersqrt.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/quantize.decTest b/StdLib/Lib/test/decimaltestdata/quantize.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/quantize.decTest rename to StdLib/Lib/test/decimaltestdata/quantize.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/randomBound32.decTest b/StdLib/Lib/test/decimaltestdata/randomBound32.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/randomBound32.decTest rename to StdLib/Lib/test/decimaltestdata/randomBound32.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/randoms.decTest b/StdLib/Lib/test/decimaltestdata/randoms.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/randoms.decTest rename to StdLib/Lib/test/decimaltestdata/randoms.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/reduce.decTest b/StdLib/Lib/test/decimaltestdata/reduce.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/reduce.decTest rename to StdLib/Lib/test/decimaltestdata/reduce.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/remainder.decTest b/StdLib/Lib/test/decimaltestdata/remainder.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/remainder.decTest rename to StdLib/Lib/test/decimaltestdata/remainder.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/remainderNear.decTest b/StdLib/Lib/test/decimaltestdata/remainderNear.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/remainderNear.decTest rename to StdLib/Lib/test/decimaltestdata/remainderNear.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/rescale.decTest b/StdLib/Lib/test/decimaltestdata/rescale.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/rescale.decTest rename to StdLib/Lib/test/decimaltestdata/rescale.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/rotate.decTest b/StdLib/Lib/test/decimaltestdata/rotate.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/rotate.decTest rename to StdLib/Lib/test/decimaltestdata/rotate.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/rounding.decTest b/StdLib/Lib/test/decimaltestdata/rounding.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/rounding.decTest rename to StdLib/Lib/test/decimaltestdata/rounding.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/samequantum.decTest b/StdLib/Lib/test/decimaltestdata/samequantum.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/samequantum.decTest rename to StdLib/Lib/test/decimaltestdata/samequantum.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/scaleb.decTest b/StdLib/Lib/test/decimaltestdata/scaleb.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/scaleb.decTest rename to StdLib/Lib/test/decimaltestdata/scaleb.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/shift.decTest b/StdLib/Lib/test/decimaltestdata/shift.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/shift.decTest rename to StdLib/Lib/test/decimaltestdata/shift.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/squareroot.decTest b/StdLib/Lib/test/decimaltestdata/squareroot.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/squareroot.decTest rename to StdLib/Lib/test/decimaltestdata/squareroot.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/subtract.decTest b/StdLib/Lib/test/decimaltestdata/subtract.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/subtract.decTest rename to StdLib/Lib/test/decimaltestdata/subtract.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/testall.decTest b/StdLib/Lib/test/decimaltestdata/testall.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/testall.decTest rename to StdLib/Lib/test/decimaltestdata/testall.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/tointegral.decTest b/StdLib/Lib/test/decimaltestdata/tointegral.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/tointegral.decTest rename to StdLib/Lib/test/decimaltestdata/tointegral.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/tointegralx.decTest b/StdLib/Lib/test/decimaltestdata/tointegralx.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/tointegralx.decTest rename to StdLib/Lib/test/decimaltestdata/tointegralx.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/xor.decTest b/StdLib/Lib/test/decimaltestdata/xor.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/xor.decTest rename to StdLib/Lib/test/decimaltestdata/xor.decTest diff --git a/Src/StdLib/Lib/test/dh1024.pem b/StdLib/Lib/test/dh1024.pem similarity index 100% rename from Src/StdLib/Lib/test/dh1024.pem rename to StdLib/Lib/test/dh1024.pem diff --git a/Src/StdLib/Lib/test/dis_module.py b/StdLib/Lib/test/dis_module.py similarity index 100% rename from Src/StdLib/Lib/test/dis_module.py rename to StdLib/Lib/test/dis_module.py diff --git a/Src/StdLib/Lib/test/doctest_aliases.py b/StdLib/Lib/test/doctest_aliases.py similarity index 100% rename from Src/StdLib/Lib/test/doctest_aliases.py rename to StdLib/Lib/test/doctest_aliases.py diff --git a/Src/StdLib/Lib/test/double_const.py b/StdLib/Lib/test/double_const.py similarity index 100% rename from Src/StdLib/Lib/test/double_const.py rename to StdLib/Lib/test/double_const.py diff --git a/Src/StdLib/Lib/test/empty.vbs b/StdLib/Lib/test/empty.vbs similarity index 100% rename from Src/StdLib/Lib/test/empty.vbs rename to StdLib/Lib/test/empty.vbs diff --git a/Src/StdLib/Lib/test/encoded_modules/__init__.py b/StdLib/Lib/test/encoded_modules/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/encoded_modules/__init__.py rename to StdLib/Lib/test/encoded_modules/__init__.py diff --git a/Src/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py b/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py similarity index 100% rename from Src/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py rename to StdLib/Lib/test/encoded_modules/module_iso_8859_1.py diff --git a/Src/StdLib/Lib/test/encoded_modules/module_koi8_r.py b/StdLib/Lib/test/encoded_modules/module_koi8_r.py similarity index 100% rename from Src/StdLib/Lib/test/encoded_modules/module_koi8_r.py rename to StdLib/Lib/test/encoded_modules/module_koi8_r.py diff --git a/Src/StdLib/Lib/test/exception_hierarchy.txt b/StdLib/Lib/test/exception_hierarchy.txt similarity index 100% rename from Src/StdLib/Lib/test/exception_hierarchy.txt rename to StdLib/Lib/test/exception_hierarchy.txt diff --git a/Src/StdLib/Lib/test/final_a.py b/StdLib/Lib/test/final_a.py similarity index 100% rename from Src/StdLib/Lib/test/final_a.py rename to StdLib/Lib/test/final_a.py diff --git a/Src/StdLib/Lib/test/final_b.py b/StdLib/Lib/test/final_b.py similarity index 100% rename from Src/StdLib/Lib/test/final_b.py rename to StdLib/Lib/test/final_b.py diff --git a/Src/StdLib/Lib/test/floating_points.txt b/StdLib/Lib/test/floating_points.txt similarity index 100% rename from Src/StdLib/Lib/test/floating_points.txt rename to StdLib/Lib/test/floating_points.txt diff --git a/Src/StdLib/Lib/test/fork_wait.py b/StdLib/Lib/test/fork_wait.py similarity index 100% rename from Src/StdLib/Lib/test/fork_wait.py rename to StdLib/Lib/test/fork_wait.py diff --git a/Src/StdLib/Lib/test/formatfloat_testcases.txt b/StdLib/Lib/test/formatfloat_testcases.txt similarity index 100% rename from Src/StdLib/Lib/test/formatfloat_testcases.txt rename to StdLib/Lib/test/formatfloat_testcases.txt diff --git a/Src/StdLib/Lib/test/future_test1.py b/StdLib/Lib/test/future_test1.py similarity index 100% rename from Src/StdLib/Lib/test/future_test1.py rename to StdLib/Lib/test/future_test1.py diff --git a/Src/StdLib/Lib/test/future_test2.py b/StdLib/Lib/test/future_test2.py similarity index 100% rename from Src/StdLib/Lib/test/future_test2.py rename to StdLib/Lib/test/future_test2.py diff --git a/Src/StdLib/Lib/test/gdb_sample.py b/StdLib/Lib/test/gdb_sample.py similarity index 100% rename from Src/StdLib/Lib/test/gdb_sample.py rename to StdLib/Lib/test/gdb_sample.py diff --git a/Src/StdLib/Lib/test/ieee754.txt b/StdLib/Lib/test/ieee754.txt similarity index 100% rename from Src/StdLib/Lib/test/ieee754.txt rename to StdLib/Lib/test/ieee754.txt diff --git a/Src/StdLib/Lib/test/imghdrdata/python.bmp b/StdLib/Lib/test/imghdrdata/python.bmp similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.bmp rename to StdLib/Lib/test/imghdrdata/python.bmp diff --git a/Src/StdLib/Lib/test/imghdrdata/python.gif b/StdLib/Lib/test/imghdrdata/python.gif similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.gif rename to StdLib/Lib/test/imghdrdata/python.gif diff --git a/Src/StdLib/Lib/test/imghdrdata/python.jpg b/StdLib/Lib/test/imghdrdata/python.jpg similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.jpg rename to StdLib/Lib/test/imghdrdata/python.jpg diff --git a/Src/StdLib/Lib/test/imghdrdata/python.pbm b/StdLib/Lib/test/imghdrdata/python.pbm similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.pbm rename to StdLib/Lib/test/imghdrdata/python.pbm diff --git a/Src/StdLib/Lib/test/imghdrdata/python.pgm b/StdLib/Lib/test/imghdrdata/python.pgm similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.pgm rename to StdLib/Lib/test/imghdrdata/python.pgm diff --git a/Src/StdLib/Lib/test/imghdrdata/python.png b/StdLib/Lib/test/imghdrdata/python.png similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.png rename to StdLib/Lib/test/imghdrdata/python.png diff --git a/Src/StdLib/Lib/test/imghdrdata/python.ppm b/StdLib/Lib/test/imghdrdata/python.ppm similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.ppm rename to StdLib/Lib/test/imghdrdata/python.ppm diff --git a/Src/StdLib/Lib/test/imghdrdata/python.ras b/StdLib/Lib/test/imghdrdata/python.ras similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.ras rename to StdLib/Lib/test/imghdrdata/python.ras diff --git a/Src/StdLib/Lib/test/imghdrdata/python.sgi b/StdLib/Lib/test/imghdrdata/python.sgi similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.sgi rename to StdLib/Lib/test/imghdrdata/python.sgi diff --git a/Src/StdLib/Lib/test/imghdrdata/python.tiff b/StdLib/Lib/test/imghdrdata/python.tiff similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.tiff rename to StdLib/Lib/test/imghdrdata/python.tiff diff --git a/Src/StdLib/Lib/test/imghdrdata/python.xbm b/StdLib/Lib/test/imghdrdata/python.xbm similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.xbm rename to StdLib/Lib/test/imghdrdata/python.xbm diff --git a/Src/StdLib/Lib/test/inspect_fodder.py b/StdLib/Lib/test/inspect_fodder.py similarity index 100% rename from Src/StdLib/Lib/test/inspect_fodder.py rename to StdLib/Lib/test/inspect_fodder.py diff --git a/Src/StdLib/Lib/test/inspect_fodder2.py b/StdLib/Lib/test/inspect_fodder2.py similarity index 100% rename from Src/StdLib/Lib/test/inspect_fodder2.py rename to StdLib/Lib/test/inspect_fodder2.py diff --git a/Src/StdLib/Lib/test/keycert.passwd.pem b/StdLib/Lib/test/keycert.passwd.pem similarity index 100% rename from Src/StdLib/Lib/test/keycert.passwd.pem rename to StdLib/Lib/test/keycert.passwd.pem diff --git a/Src/StdLib/Lib/test/keycert.pem b/StdLib/Lib/test/keycert.pem similarity index 100% rename from Src/StdLib/Lib/test/keycert.pem rename to StdLib/Lib/test/keycert.pem diff --git a/Src/StdLib/Lib/test/keycert2.pem b/StdLib/Lib/test/keycert2.pem similarity index 100% rename from Src/StdLib/Lib/test/keycert2.pem rename to StdLib/Lib/test/keycert2.pem diff --git a/Src/StdLib/Lib/test/keycert3.pem b/StdLib/Lib/test/keycert3.pem similarity index 100% rename from Src/StdLib/Lib/test/keycert3.pem rename to StdLib/Lib/test/keycert3.pem diff --git a/Src/StdLib/Lib/test/keycert4.pem b/StdLib/Lib/test/keycert4.pem similarity index 100% rename from Src/StdLib/Lib/test/keycert4.pem rename to StdLib/Lib/test/keycert4.pem diff --git a/Src/StdLib/Lib/test/leakers/README.txt b/StdLib/Lib/test/leakers/README.txt similarity index 100% rename from Src/StdLib/Lib/test/leakers/README.txt rename to StdLib/Lib/test/leakers/README.txt diff --git a/Src/StdLib/Lib/test/leakers/__init__.py b/StdLib/Lib/test/leakers/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/leakers/__init__.py rename to StdLib/Lib/test/leakers/__init__.py diff --git a/Src/StdLib/Lib/test/leakers/test_ctypes.py b/StdLib/Lib/test/leakers/test_ctypes.py similarity index 100% rename from Src/StdLib/Lib/test/leakers/test_ctypes.py rename to StdLib/Lib/test/leakers/test_ctypes.py diff --git a/Src/StdLib/Lib/test/leakers/test_selftype.py b/StdLib/Lib/test/leakers/test_selftype.py similarity index 100% rename from Src/StdLib/Lib/test/leakers/test_selftype.py rename to StdLib/Lib/test/leakers/test_selftype.py diff --git a/Src/StdLib/Lib/test/list_tests.py b/StdLib/Lib/test/list_tests.py similarity index 100% rename from Src/StdLib/Lib/test/list_tests.py rename to StdLib/Lib/test/list_tests.py diff --git a/Src/StdLib/Lib/test/lock_tests.py b/StdLib/Lib/test/lock_tests.py similarity index 100% rename from Src/StdLib/Lib/test/lock_tests.py rename to StdLib/Lib/test/lock_tests.py diff --git a/Src/StdLib/Lib/test/mailcap.txt b/StdLib/Lib/test/mailcap.txt similarity index 100% rename from Src/StdLib/Lib/test/mailcap.txt rename to StdLib/Lib/test/mailcap.txt diff --git a/Src/StdLib/Lib/test/make_ssl_certs.py b/StdLib/Lib/test/make_ssl_certs.py similarity index 100% rename from Src/StdLib/Lib/test/make_ssl_certs.py rename to StdLib/Lib/test/make_ssl_certs.py diff --git a/Src/StdLib/Lib/test/mapping_tests.py b/StdLib/Lib/test/mapping_tests.py similarity index 100% rename from Src/StdLib/Lib/test/mapping_tests.py rename to StdLib/Lib/test/mapping_tests.py diff --git a/Src/StdLib/Lib/test/math_testcases.txt b/StdLib/Lib/test/math_testcases.txt similarity index 100% rename from Src/StdLib/Lib/test/math_testcases.txt rename to StdLib/Lib/test/math_testcases.txt diff --git a/Src/StdLib/Lib/test/memory_watchdog.py b/StdLib/Lib/test/memory_watchdog.py similarity index 100% rename from Src/StdLib/Lib/test/memory_watchdog.py rename to StdLib/Lib/test/memory_watchdog.py diff --git a/Src/StdLib/Lib/test/mime.types b/StdLib/Lib/test/mime.types similarity index 100% rename from Src/StdLib/Lib/test/mime.types rename to StdLib/Lib/test/mime.types diff --git a/Src/StdLib/Lib/test/mock_socket.py b/StdLib/Lib/test/mock_socket.py similarity index 100% rename from Src/StdLib/Lib/test/mock_socket.py rename to StdLib/Lib/test/mock_socket.py diff --git a/Src/StdLib/Lib/test/mod_generics_cache.py b/StdLib/Lib/test/mod_generics_cache.py similarity index 100% rename from Src/StdLib/Lib/test/mod_generics_cache.py rename to StdLib/Lib/test/mod_generics_cache.py diff --git a/Src/StdLib/Lib/test/mp_fork_bomb.py b/StdLib/Lib/test/mp_fork_bomb.py similarity index 100% rename from Src/StdLib/Lib/test/mp_fork_bomb.py rename to StdLib/Lib/test/mp_fork_bomb.py diff --git a/Src/StdLib/Lib/test/multibytecodec_support.py b/StdLib/Lib/test/multibytecodec_support.py similarity index 100% rename from Src/StdLib/Lib/test/multibytecodec_support.py rename to StdLib/Lib/test/multibytecodec_support.py diff --git a/Src/StdLib/Lib/test/nokia.pem b/StdLib/Lib/test/nokia.pem similarity index 100% rename from Src/StdLib/Lib/test/nokia.pem rename to StdLib/Lib/test/nokia.pem diff --git a/Src/StdLib/Lib/test/nullbytecert.pem b/StdLib/Lib/test/nullbytecert.pem similarity index 100% rename from Src/StdLib/Lib/test/nullbytecert.pem rename to StdLib/Lib/test/nullbytecert.pem diff --git a/Src/StdLib/Lib/test/nullcert.pem b/StdLib/Lib/test/nullcert.pem similarity index 100% rename from Src/StdLib/Lib/test/nullcert.pem rename to StdLib/Lib/test/nullcert.pem diff --git a/Src/StdLib/Lib/test/outstanding_bugs.py b/StdLib/Lib/test/outstanding_bugs.py similarity index 100% rename from Src/StdLib/Lib/test/outstanding_bugs.py rename to StdLib/Lib/test/outstanding_bugs.py diff --git a/Src/StdLib/Lib/test/pickletester.py b/StdLib/Lib/test/pickletester.py similarity index 100% rename from Src/StdLib/Lib/test/pickletester.py rename to StdLib/Lib/test/pickletester.py diff --git a/Src/StdLib/Lib/test/profilee.py b/StdLib/Lib/test/profilee.py similarity index 100% rename from Src/StdLib/Lib/test/profilee.py rename to StdLib/Lib/test/profilee.py diff --git a/Src/StdLib/Lib/test/pstats.pck b/StdLib/Lib/test/pstats.pck similarity index 100% rename from Src/StdLib/Lib/test/pstats.pck rename to StdLib/Lib/test/pstats.pck diff --git a/Src/StdLib/Lib/test/pycacert.pem b/StdLib/Lib/test/pycacert.pem similarity index 100% rename from Src/StdLib/Lib/test/pycacert.pem rename to StdLib/Lib/test/pycacert.pem diff --git a/Src/StdLib/Lib/test/pycakey.pem b/StdLib/Lib/test/pycakey.pem similarity index 100% rename from Src/StdLib/Lib/test/pycakey.pem rename to StdLib/Lib/test/pycakey.pem diff --git a/Src/StdLib/Lib/test/pyclbr_input.py b/StdLib/Lib/test/pyclbr_input.py similarity index 100% rename from Src/StdLib/Lib/test/pyclbr_input.py rename to StdLib/Lib/test/pyclbr_input.py diff --git a/Src/StdLib/Lib/test/pydoc_mod.py b/StdLib/Lib/test/pydoc_mod.py similarity index 100% rename from Src/StdLib/Lib/test/pydoc_mod.py rename to StdLib/Lib/test/pydoc_mod.py diff --git a/Src/StdLib/Lib/test/pydocfodder.py b/StdLib/Lib/test/pydocfodder.py similarity index 100% rename from Src/StdLib/Lib/test/pydocfodder.py rename to StdLib/Lib/test/pydocfodder.py diff --git a/Src/StdLib/Lib/test/pystone.py b/StdLib/Lib/test/pystone.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/test/pystone.py rename to StdLib/Lib/test/pystone.py diff --git a/Src/StdLib/Lib/test/randv2_32.pck b/StdLib/Lib/test/randv2_32.pck similarity index 100% rename from Src/StdLib/Lib/test/randv2_32.pck rename to StdLib/Lib/test/randv2_32.pck diff --git a/Src/StdLib/Lib/test/randv2_64.pck b/StdLib/Lib/test/randv2_64.pck similarity index 100% rename from Src/StdLib/Lib/test/randv2_64.pck rename to StdLib/Lib/test/randv2_64.pck diff --git a/Src/StdLib/Lib/test/randv3.pck b/StdLib/Lib/test/randv3.pck similarity index 100% rename from Src/StdLib/Lib/test/randv3.pck rename to StdLib/Lib/test/randv3.pck diff --git a/Src/StdLib/Lib/test/re_tests.py b/StdLib/Lib/test/re_tests.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/test/re_tests.py rename to StdLib/Lib/test/re_tests.py diff --git a/Src/StdLib/Lib/test/regrtest.py b/StdLib/Lib/test/regrtest.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/test/regrtest.py rename to StdLib/Lib/test/regrtest.py diff --git a/Src/StdLib/Lib/test/relimport.py b/StdLib/Lib/test/relimport.py similarity index 100% rename from Src/StdLib/Lib/test/relimport.py rename to StdLib/Lib/test/relimport.py diff --git a/Src/StdLib/Lib/test/reperf.py b/StdLib/Lib/test/reperf.py similarity index 100% rename from Src/StdLib/Lib/test/reperf.py rename to StdLib/Lib/test/reperf.py diff --git a/Src/StdLib/Lib/test/revocation.crl b/StdLib/Lib/test/revocation.crl similarity index 100% rename from Src/StdLib/Lib/test/revocation.crl rename to StdLib/Lib/test/revocation.crl diff --git a/Src/StdLib/Lib/test/sample_doctest.py b/StdLib/Lib/test/sample_doctest.py similarity index 100% rename from Src/StdLib/Lib/test/sample_doctest.py rename to StdLib/Lib/test/sample_doctest.py diff --git a/Src/StdLib/Lib/test/sample_doctest_no_docstrings.py b/StdLib/Lib/test/sample_doctest_no_docstrings.py similarity index 100% rename from Src/StdLib/Lib/test/sample_doctest_no_docstrings.py rename to StdLib/Lib/test/sample_doctest_no_docstrings.py diff --git a/Src/StdLib/Lib/test/sample_doctest_no_doctests.py b/StdLib/Lib/test/sample_doctest_no_doctests.py similarity index 100% rename from Src/StdLib/Lib/test/sample_doctest_no_doctests.py rename to StdLib/Lib/test/sample_doctest_no_doctests.py diff --git a/Src/StdLib/Lib/test/script_helper.py b/StdLib/Lib/test/script_helper.py similarity index 100% rename from Src/StdLib/Lib/test/script_helper.py rename to StdLib/Lib/test/script_helper.py diff --git a/Src/StdLib/Lib/test/selfsigned_pythontestdotnet.pem b/StdLib/Lib/test/selfsigned_pythontestdotnet.pem similarity index 100% rename from Src/StdLib/Lib/test/selfsigned_pythontestdotnet.pem rename to StdLib/Lib/test/selfsigned_pythontestdotnet.pem diff --git a/Src/StdLib/Lib/test/seq_tests.py b/StdLib/Lib/test/seq_tests.py similarity index 100% rename from Src/StdLib/Lib/test/seq_tests.py rename to StdLib/Lib/test/seq_tests.py diff --git a/Src/StdLib/Lib/test/sgml_input.html b/StdLib/Lib/test/sgml_input.html similarity index 100% rename from Src/StdLib/Lib/test/sgml_input.html rename to StdLib/Lib/test/sgml_input.html diff --git a/Src/StdLib/Lib/test/sha256.pem b/StdLib/Lib/test/sha256.pem similarity index 100% rename from Src/StdLib/Lib/test/sha256.pem rename to StdLib/Lib/test/sha256.pem diff --git a/Src/StdLib/Lib/test/sndhdrdata/README b/StdLib/Lib/test/sndhdrdata/README similarity index 100% rename from Src/StdLib/Lib/test/sndhdrdata/README rename to StdLib/Lib/test/sndhdrdata/README diff --git a/Src/StdLib/Lib/test/sndhdrdata/sndhdr.8svx b/StdLib/Lib/test/sndhdrdata/sndhdr.8svx similarity index 100% rename from Src/StdLib/Lib/test/sndhdrdata/sndhdr.8svx rename to StdLib/Lib/test/sndhdrdata/sndhdr.8svx diff --git a/Src/StdLib/Lib/test/sndhdrdata/sndhdr.aifc b/StdLib/Lib/test/sndhdrdata/sndhdr.aifc similarity index 100% rename from Src/StdLib/Lib/test/sndhdrdata/sndhdr.aifc rename to StdLib/Lib/test/sndhdrdata/sndhdr.aifc diff --git a/Src/StdLib/Lib/test/sndhdrdata/sndhdr.aiff b/StdLib/Lib/test/sndhdrdata/sndhdr.aiff similarity index 100% rename from Src/StdLib/Lib/test/sndhdrdata/sndhdr.aiff rename to StdLib/Lib/test/sndhdrdata/sndhdr.aiff diff --git a/Src/StdLib/Lib/test/sndhdrdata/sndhdr.au b/StdLib/Lib/test/sndhdrdata/sndhdr.au similarity index 100% rename from Src/StdLib/Lib/test/sndhdrdata/sndhdr.au rename to StdLib/Lib/test/sndhdrdata/sndhdr.au diff --git a/Src/StdLib/Lib/test/sndhdrdata/sndhdr.hcom b/StdLib/Lib/test/sndhdrdata/sndhdr.hcom similarity index 100% rename from Src/StdLib/Lib/test/sndhdrdata/sndhdr.hcom rename to StdLib/Lib/test/sndhdrdata/sndhdr.hcom diff --git a/Src/StdLib/Lib/test/sndhdrdata/sndhdr.sndt b/StdLib/Lib/test/sndhdrdata/sndhdr.sndt similarity index 100% rename from Src/StdLib/Lib/test/sndhdrdata/sndhdr.sndt rename to StdLib/Lib/test/sndhdrdata/sndhdr.sndt diff --git a/Src/StdLib/Lib/test/sndhdrdata/sndhdr.voc b/StdLib/Lib/test/sndhdrdata/sndhdr.voc similarity index 100% rename from Src/StdLib/Lib/test/sndhdrdata/sndhdr.voc rename to StdLib/Lib/test/sndhdrdata/sndhdr.voc diff --git a/Src/StdLib/Lib/test/sndhdrdata/sndhdr.wav b/StdLib/Lib/test/sndhdrdata/sndhdr.wav similarity index 100% rename from Src/StdLib/Lib/test/sndhdrdata/sndhdr.wav rename to StdLib/Lib/test/sndhdrdata/sndhdr.wav diff --git a/Src/StdLib/Lib/test/sortperf.py b/StdLib/Lib/test/sortperf.py similarity index 100% rename from Src/StdLib/Lib/test/sortperf.py rename to StdLib/Lib/test/sortperf.py diff --git a/Src/StdLib/Lib/test/ssl_cert.pem b/StdLib/Lib/test/ssl_cert.pem similarity index 100% rename from Src/StdLib/Lib/test/ssl_cert.pem rename to StdLib/Lib/test/ssl_cert.pem diff --git a/Src/StdLib/Lib/test/ssl_key.passwd.pem b/StdLib/Lib/test/ssl_key.passwd.pem similarity index 100% rename from Src/StdLib/Lib/test/ssl_key.passwd.pem rename to StdLib/Lib/test/ssl_key.passwd.pem diff --git a/Src/StdLib/Lib/test/ssl_key.pem b/StdLib/Lib/test/ssl_key.pem similarity index 100% rename from Src/StdLib/Lib/test/ssl_key.pem rename to StdLib/Lib/test/ssl_key.pem diff --git a/Src/StdLib/Lib/test/ssl_servers.py b/StdLib/Lib/test/ssl_servers.py similarity index 100% rename from Src/StdLib/Lib/test/ssl_servers.py rename to StdLib/Lib/test/ssl_servers.py diff --git a/Src/StdLib/Lib/test/ssltests.py b/StdLib/Lib/test/ssltests.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/test/ssltests.py rename to StdLib/Lib/test/ssltests.py diff --git a/Src/StdLib/Lib/test/string_tests.py b/StdLib/Lib/test/string_tests.py similarity index 100% rename from Src/StdLib/Lib/test/string_tests.py rename to StdLib/Lib/test/string_tests.py diff --git a/Src/StdLib/Lib/test/subprocessdata/fd_status.py b/StdLib/Lib/test/subprocessdata/fd_status.py similarity index 100% rename from Src/StdLib/Lib/test/subprocessdata/fd_status.py rename to StdLib/Lib/test/subprocessdata/fd_status.py diff --git a/Src/StdLib/Lib/test/subprocessdata/input_reader.py b/StdLib/Lib/test/subprocessdata/input_reader.py similarity index 100% rename from Src/StdLib/Lib/test/subprocessdata/input_reader.py rename to StdLib/Lib/test/subprocessdata/input_reader.py diff --git a/Src/StdLib/Lib/test/subprocessdata/qcat.py b/StdLib/Lib/test/subprocessdata/qcat.py similarity index 100% rename from Src/StdLib/Lib/test/subprocessdata/qcat.py rename to StdLib/Lib/test/subprocessdata/qcat.py diff --git a/Src/StdLib/Lib/test/subprocessdata/qgrep.py b/StdLib/Lib/test/subprocessdata/qgrep.py similarity index 100% rename from Src/StdLib/Lib/test/subprocessdata/qgrep.py rename to StdLib/Lib/test/subprocessdata/qgrep.py diff --git a/Src/StdLib/Lib/test/subprocessdata/sigchild_ignore.py b/StdLib/Lib/test/subprocessdata/sigchild_ignore.py similarity index 100% rename from Src/StdLib/Lib/test/subprocessdata/sigchild_ignore.py rename to StdLib/Lib/test/subprocessdata/sigchild_ignore.py diff --git a/Src/StdLib/Lib/test/support/__init__.py b/StdLib/Lib/test/support/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/support/__init__.py rename to StdLib/Lib/test/support/__init__.py diff --git a/Src/StdLib/Lib/test/talos-2019-0758.pem b/StdLib/Lib/test/talos-2019-0758.pem similarity index 100% rename from Src/StdLib/Lib/test/talos-2019-0758.pem rename to StdLib/Lib/test/talos-2019-0758.pem diff --git a/Src/StdLib/Lib/test/test___all__.py b/StdLib/Lib/test/test___all__.py similarity index 100% rename from Src/StdLib/Lib/test/test___all__.py rename to StdLib/Lib/test/test___all__.py diff --git a/Src/StdLib/Lib/test/test___future__.py b/StdLib/Lib/test/test___future__.py similarity index 100% rename from Src/StdLib/Lib/test/test___future__.py rename to StdLib/Lib/test/test___future__.py diff --git a/Src/StdLib/Lib/test/test__locale.py b/StdLib/Lib/test/test__locale.py similarity index 100% rename from Src/StdLib/Lib/test/test__locale.py rename to StdLib/Lib/test/test__locale.py diff --git a/Src/StdLib/Lib/test/test__opcode.py b/StdLib/Lib/test/test__opcode.py similarity index 100% rename from Src/StdLib/Lib/test/test__opcode.py rename to StdLib/Lib/test/test__opcode.py diff --git a/Src/StdLib/Lib/test/test__osx_support.py b/StdLib/Lib/test/test__osx_support.py similarity index 100% rename from Src/StdLib/Lib/test/test__osx_support.py rename to StdLib/Lib/test/test__osx_support.py diff --git a/Src/StdLib/Lib/test/test_abc.py b/StdLib/Lib/test/test_abc.py similarity index 100% rename from Src/StdLib/Lib/test/test_abc.py rename to StdLib/Lib/test/test_abc.py diff --git a/Src/StdLib/Lib/test/test_abstract_numbers.py b/StdLib/Lib/test/test_abstract_numbers.py similarity index 100% rename from Src/StdLib/Lib/test/test_abstract_numbers.py rename to StdLib/Lib/test/test_abstract_numbers.py diff --git a/Src/StdLib/Lib/test/test_aifc.py b/StdLib/Lib/test/test_aifc.py similarity index 100% rename from Src/StdLib/Lib/test/test_aifc.py rename to StdLib/Lib/test/test_aifc.py diff --git a/Src/StdLib/Lib/test/test_argparse.py b/StdLib/Lib/test/test_argparse.py similarity index 100% rename from Src/StdLib/Lib/test/test_argparse.py rename to StdLib/Lib/test/test_argparse.py diff --git a/Src/StdLib/Lib/test/test_array.py b/StdLib/Lib/test/test_array.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/test/test_array.py rename to StdLib/Lib/test/test_array.py diff --git a/Src/StdLib/Lib/test/test_ast.py b/StdLib/Lib/test/test_ast.py similarity index 100% rename from Src/StdLib/Lib/test/test_ast.py rename to StdLib/Lib/test/test_ast.py diff --git a/Src/StdLib/Lib/test/test_asynchat.py b/StdLib/Lib/test/test_asynchat.py similarity index 100% rename from Src/StdLib/Lib/test/test_asynchat.py rename to StdLib/Lib/test/test_asynchat.py diff --git a/Src/StdLib/Lib/test/test_asyncio/__init__.py b/StdLib/Lib/test/test_asyncio/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/__init__.py rename to StdLib/Lib/test/test_asyncio/__init__.py diff --git a/Src/StdLib/Lib/test/test_asyncio/__main__.py b/StdLib/Lib/test/test_asyncio/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/__main__.py rename to StdLib/Lib/test/test_asyncio/__main__.py diff --git a/Src/StdLib/Lib/test/test_asyncio/echo.py b/StdLib/Lib/test/test_asyncio/echo.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/echo.py rename to StdLib/Lib/test/test_asyncio/echo.py diff --git a/Src/StdLib/Lib/test/test_asyncio/echo2.py b/StdLib/Lib/test/test_asyncio/echo2.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/echo2.py rename to StdLib/Lib/test/test_asyncio/echo2.py diff --git a/Src/StdLib/Lib/test/test_asyncio/echo3.py b/StdLib/Lib/test/test_asyncio/echo3.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/echo3.py rename to StdLib/Lib/test/test_asyncio/echo3.py diff --git a/Src/StdLib/Lib/test/test_asyncio/keycert3.pem b/StdLib/Lib/test/test_asyncio/keycert3.pem similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/keycert3.pem rename to StdLib/Lib/test/test_asyncio/keycert3.pem diff --git a/Src/StdLib/Lib/test/test_asyncio/pycacert.pem b/StdLib/Lib/test/test_asyncio/pycacert.pem similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/pycacert.pem rename to StdLib/Lib/test/test_asyncio/pycacert.pem diff --git a/Src/StdLib/Lib/test/test_asyncio/ssl_cert.pem b/StdLib/Lib/test/test_asyncio/ssl_cert.pem similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/ssl_cert.pem rename to StdLib/Lib/test/test_asyncio/ssl_cert.pem diff --git a/Src/StdLib/Lib/test/test_asyncio/ssl_key.pem b/StdLib/Lib/test/test_asyncio/ssl_key.pem similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/ssl_key.pem rename to StdLib/Lib/test/test_asyncio/ssl_key.pem diff --git a/Src/StdLib/Lib/test/test_asyncio/test_base_events.py b/StdLib/Lib/test/test_asyncio/test_base_events.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_base_events.py rename to StdLib/Lib/test/test_asyncio/test_base_events.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_events.py b/StdLib/Lib/test/test_asyncio/test_events.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_events.py rename to StdLib/Lib/test/test_asyncio/test_events.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_futures.py b/StdLib/Lib/test/test_asyncio/test_futures.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_futures.py rename to StdLib/Lib/test/test_asyncio/test_futures.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_locks.py b/StdLib/Lib/test/test_asyncio/test_locks.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_locks.py rename to StdLib/Lib/test/test_asyncio/test_locks.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_proactor_events.py b/StdLib/Lib/test/test_asyncio/test_proactor_events.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_proactor_events.py rename to StdLib/Lib/test/test_asyncio/test_proactor_events.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_queues.py b/StdLib/Lib/test/test_asyncio/test_queues.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_queues.py rename to StdLib/Lib/test/test_asyncio/test_queues.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_selector_events.py b/StdLib/Lib/test/test_asyncio/test_selector_events.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_selector_events.py rename to StdLib/Lib/test/test_asyncio/test_selector_events.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_sslproto.py b/StdLib/Lib/test/test_asyncio/test_sslproto.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_sslproto.py rename to StdLib/Lib/test/test_asyncio/test_sslproto.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_streams.py b/StdLib/Lib/test/test_asyncio/test_streams.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_streams.py rename to StdLib/Lib/test/test_asyncio/test_streams.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_subprocess.py b/StdLib/Lib/test/test_asyncio/test_subprocess.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_subprocess.py rename to StdLib/Lib/test/test_asyncio/test_subprocess.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_tasks.py b/StdLib/Lib/test/test_asyncio/test_tasks.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_tasks.py rename to StdLib/Lib/test/test_asyncio/test_tasks.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_transports.py b/StdLib/Lib/test/test_asyncio/test_transports.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_transports.py rename to StdLib/Lib/test/test_asyncio/test_transports.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_unix_events.py b/StdLib/Lib/test/test_asyncio/test_unix_events.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_unix_events.py rename to StdLib/Lib/test/test_asyncio/test_unix_events.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_windows_events.py b/StdLib/Lib/test/test_asyncio/test_windows_events.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_windows_events.py rename to StdLib/Lib/test/test_asyncio/test_windows_events.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_windows_utils.py b/StdLib/Lib/test/test_asyncio/test_windows_utils.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_windows_utils.py rename to StdLib/Lib/test/test_asyncio/test_windows_utils.py diff --git a/Src/StdLib/Lib/test/test_asyncore.py b/StdLib/Lib/test/test_asyncore.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncore.py rename to StdLib/Lib/test/test_asyncore.py diff --git a/Src/StdLib/Lib/test/test_atexit.py b/StdLib/Lib/test/test_atexit.py similarity index 100% rename from Src/StdLib/Lib/test/test_atexit.py rename to StdLib/Lib/test/test_atexit.py diff --git a/Src/StdLib/Lib/test/test_audioop.py b/StdLib/Lib/test/test_audioop.py similarity index 100% rename from Src/StdLib/Lib/test/test_audioop.py rename to StdLib/Lib/test/test_audioop.py diff --git a/Src/StdLib/Lib/test/test_augassign.py b/StdLib/Lib/test/test_augassign.py similarity index 100% rename from Src/StdLib/Lib/test/test_augassign.py rename to StdLib/Lib/test/test_augassign.py diff --git a/Src/StdLib/Lib/test/test_base64.py b/StdLib/Lib/test/test_base64.py similarity index 100% rename from Src/StdLib/Lib/test/test_base64.py rename to StdLib/Lib/test/test_base64.py diff --git a/Src/StdLib/Lib/test/test_bigaddrspace.py b/StdLib/Lib/test/test_bigaddrspace.py similarity index 100% rename from Src/StdLib/Lib/test/test_bigaddrspace.py rename to StdLib/Lib/test/test_bigaddrspace.py diff --git a/Src/StdLib/Lib/test/test_bigmem.py b/StdLib/Lib/test/test_bigmem.py similarity index 100% rename from Src/StdLib/Lib/test/test_bigmem.py rename to StdLib/Lib/test/test_bigmem.py diff --git a/Src/StdLib/Lib/test/test_binascii.py b/StdLib/Lib/test/test_binascii.py similarity index 100% rename from Src/StdLib/Lib/test/test_binascii.py rename to StdLib/Lib/test/test_binascii.py diff --git a/Src/StdLib/Lib/test/test_binhex.py b/StdLib/Lib/test/test_binhex.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/test/test_binhex.py rename to StdLib/Lib/test/test_binhex.py diff --git a/Src/StdLib/Lib/test/test_binop.py b/StdLib/Lib/test/test_binop.py similarity index 100% rename from Src/StdLib/Lib/test/test_binop.py rename to StdLib/Lib/test/test_binop.py diff --git a/Src/StdLib/Lib/test/test_bisect.py b/StdLib/Lib/test/test_bisect.py similarity index 100% rename from Src/StdLib/Lib/test/test_bisect.py rename to StdLib/Lib/test/test_bisect.py diff --git a/Src/StdLib/Lib/test/test_bool.py b/StdLib/Lib/test/test_bool.py similarity index 100% rename from Src/StdLib/Lib/test/test_bool.py rename to StdLib/Lib/test/test_bool.py diff --git a/Src/StdLib/Lib/test/test_buffer.py b/StdLib/Lib/test/test_buffer.py similarity index 100% rename from Src/StdLib/Lib/test/test_buffer.py rename to StdLib/Lib/test/test_buffer.py diff --git a/Src/StdLib/Lib/test/test_bufio.py b/StdLib/Lib/test/test_bufio.py similarity index 100% rename from Src/StdLib/Lib/test/test_bufio.py rename to StdLib/Lib/test/test_bufio.py diff --git a/Src/StdLib/Lib/test/test_builtin.py b/StdLib/Lib/test/test_builtin.py similarity index 100% rename from Src/StdLib/Lib/test/test_builtin.py rename to StdLib/Lib/test/test_builtin.py diff --git a/Src/StdLib/Lib/test/test_bytes.py b/StdLib/Lib/test/test_bytes.py similarity index 100% rename from Src/StdLib/Lib/test/test_bytes.py rename to StdLib/Lib/test/test_bytes.py diff --git a/Src/StdLib/Lib/test/test_bz2.py b/StdLib/Lib/test/test_bz2.py similarity index 100% rename from Src/StdLib/Lib/test/test_bz2.py rename to StdLib/Lib/test/test_bz2.py diff --git a/Src/StdLib/Lib/test/test_calendar.py b/StdLib/Lib/test/test_calendar.py similarity index 100% rename from Src/StdLib/Lib/test/test_calendar.py rename to StdLib/Lib/test/test_calendar.py diff --git a/Src/StdLib/Lib/test/test_call.py b/StdLib/Lib/test/test_call.py similarity index 100% rename from Src/StdLib/Lib/test/test_call.py rename to StdLib/Lib/test/test_call.py diff --git a/Src/StdLib/Lib/test/test_capi.py b/StdLib/Lib/test/test_capi.py similarity index 100% rename from Src/StdLib/Lib/test/test_capi.py rename to StdLib/Lib/test/test_capi.py diff --git a/Src/StdLib/Lib/test/test_cgi.py b/StdLib/Lib/test/test_cgi.py similarity index 100% rename from Src/StdLib/Lib/test/test_cgi.py rename to StdLib/Lib/test/test_cgi.py diff --git a/Src/StdLib/Lib/test/test_cgitb.py b/StdLib/Lib/test/test_cgitb.py similarity index 100% rename from Src/StdLib/Lib/test/test_cgitb.py rename to StdLib/Lib/test/test_cgitb.py diff --git a/Src/StdLib/Lib/test/test_charmapcodec.py b/StdLib/Lib/test/test_charmapcodec.py similarity index 100% rename from Src/StdLib/Lib/test/test_charmapcodec.py rename to StdLib/Lib/test/test_charmapcodec.py diff --git a/Src/StdLib/Lib/test/test_class.py b/StdLib/Lib/test/test_class.py similarity index 100% rename from Src/StdLib/Lib/test/test_class.py rename to StdLib/Lib/test/test_class.py diff --git a/Src/StdLib/Lib/test/test_cmath.py b/StdLib/Lib/test/test_cmath.py similarity index 100% rename from Src/StdLib/Lib/test/test_cmath.py rename to StdLib/Lib/test/test_cmath.py diff --git a/Src/StdLib/Lib/test/test_cmd.py b/StdLib/Lib/test/test_cmd.py similarity index 100% rename from Src/StdLib/Lib/test/test_cmd.py rename to StdLib/Lib/test/test_cmd.py diff --git a/Src/StdLib/Lib/test/test_cmd_line.py b/StdLib/Lib/test/test_cmd_line.py similarity index 100% rename from Src/StdLib/Lib/test/test_cmd_line.py rename to StdLib/Lib/test/test_cmd_line.py diff --git a/Src/StdLib/Lib/test/test_cmd_line_script.py b/StdLib/Lib/test/test_cmd_line_script.py similarity index 100% rename from Src/StdLib/Lib/test/test_cmd_line_script.py rename to StdLib/Lib/test/test_cmd_line_script.py diff --git a/Src/StdLib/Lib/test/test_code.py b/StdLib/Lib/test/test_code.py similarity index 100% rename from Src/StdLib/Lib/test/test_code.py rename to StdLib/Lib/test/test_code.py diff --git a/Src/StdLib/Lib/test/test_code_module.py b/StdLib/Lib/test/test_code_module.py similarity index 100% rename from Src/StdLib/Lib/test/test_code_module.py rename to StdLib/Lib/test/test_code_module.py diff --git a/Src/StdLib/Lib/test/test_codeccallbacks.py b/StdLib/Lib/test/test_codeccallbacks.py similarity index 100% rename from Src/StdLib/Lib/test/test_codeccallbacks.py rename to StdLib/Lib/test/test_codeccallbacks.py diff --git a/Src/StdLib/Lib/test/test_codecencodings_cn.py b/StdLib/Lib/test/test_codecencodings_cn.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecencodings_cn.py rename to StdLib/Lib/test/test_codecencodings_cn.py diff --git a/Src/StdLib/Lib/test/test_codecencodings_hk.py b/StdLib/Lib/test/test_codecencodings_hk.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecencodings_hk.py rename to StdLib/Lib/test/test_codecencodings_hk.py diff --git a/Src/StdLib/Lib/test/test_codecencodings_iso2022.py b/StdLib/Lib/test/test_codecencodings_iso2022.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecencodings_iso2022.py rename to StdLib/Lib/test/test_codecencodings_iso2022.py diff --git a/Src/StdLib/Lib/test/test_codecencodings_jp.py b/StdLib/Lib/test/test_codecencodings_jp.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecencodings_jp.py rename to StdLib/Lib/test/test_codecencodings_jp.py diff --git a/Src/StdLib/Lib/test/test_codecencodings_kr.py b/StdLib/Lib/test/test_codecencodings_kr.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecencodings_kr.py rename to StdLib/Lib/test/test_codecencodings_kr.py diff --git a/Src/StdLib/Lib/test/test_codecencodings_tw.py b/StdLib/Lib/test/test_codecencodings_tw.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecencodings_tw.py rename to StdLib/Lib/test/test_codecencodings_tw.py diff --git a/Src/StdLib/Lib/test/test_codecmaps_cn.py b/StdLib/Lib/test/test_codecmaps_cn.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecmaps_cn.py rename to StdLib/Lib/test/test_codecmaps_cn.py diff --git a/Src/StdLib/Lib/test/test_codecmaps_hk.py b/StdLib/Lib/test/test_codecmaps_hk.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecmaps_hk.py rename to StdLib/Lib/test/test_codecmaps_hk.py diff --git a/Src/StdLib/Lib/test/test_codecmaps_jp.py b/StdLib/Lib/test/test_codecmaps_jp.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecmaps_jp.py rename to StdLib/Lib/test/test_codecmaps_jp.py diff --git a/Src/StdLib/Lib/test/test_codecmaps_kr.py b/StdLib/Lib/test/test_codecmaps_kr.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecmaps_kr.py rename to StdLib/Lib/test/test_codecmaps_kr.py diff --git a/Src/StdLib/Lib/test/test_codecmaps_tw.py b/StdLib/Lib/test/test_codecmaps_tw.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecmaps_tw.py rename to StdLib/Lib/test/test_codecmaps_tw.py diff --git a/Src/StdLib/Lib/test/test_codecs.py b/StdLib/Lib/test/test_codecs.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecs.py rename to StdLib/Lib/test/test_codecs.py diff --git a/Src/StdLib/Lib/test/test_codeop.py b/StdLib/Lib/test/test_codeop.py similarity index 100% rename from Src/StdLib/Lib/test/test_codeop.py rename to StdLib/Lib/test/test_codeop.py diff --git a/Src/StdLib/Lib/test/test_collections.py b/StdLib/Lib/test/test_collections.py similarity index 100% rename from Src/StdLib/Lib/test/test_collections.py rename to StdLib/Lib/test/test_collections.py diff --git a/Src/StdLib/Lib/test/test_colorsys.py b/StdLib/Lib/test/test_colorsys.py similarity index 100% rename from Src/StdLib/Lib/test/test_colorsys.py rename to StdLib/Lib/test/test_colorsys.py diff --git a/Src/StdLib/Lib/test/test_compare.py b/StdLib/Lib/test/test_compare.py similarity index 100% rename from Src/StdLib/Lib/test/test_compare.py rename to StdLib/Lib/test/test_compare.py diff --git a/Src/StdLib/Lib/test/test_compile.py b/StdLib/Lib/test/test_compile.py similarity index 100% rename from Src/StdLib/Lib/test/test_compile.py rename to StdLib/Lib/test/test_compile.py diff --git a/Src/StdLib/Lib/test/test_compileall.py b/StdLib/Lib/test/test_compileall.py similarity index 100% rename from Src/StdLib/Lib/test/test_compileall.py rename to StdLib/Lib/test/test_compileall.py diff --git a/Src/StdLib/Lib/test/test_complex.py b/StdLib/Lib/test/test_complex.py similarity index 100% rename from Src/StdLib/Lib/test/test_complex.py rename to StdLib/Lib/test/test_complex.py diff --git a/Src/StdLib/Lib/test/test_concurrent_futures.py b/StdLib/Lib/test/test_concurrent_futures.py similarity index 100% rename from Src/StdLib/Lib/test/test_concurrent_futures.py rename to StdLib/Lib/test/test_concurrent_futures.py diff --git a/Src/StdLib/Lib/test/test_configparser.py b/StdLib/Lib/test/test_configparser.py similarity index 100% rename from Src/StdLib/Lib/test/test_configparser.py rename to StdLib/Lib/test/test_configparser.py diff --git a/Src/StdLib/Lib/test/test_contains.py b/StdLib/Lib/test/test_contains.py similarity index 100% rename from Src/StdLib/Lib/test/test_contains.py rename to StdLib/Lib/test/test_contains.py diff --git a/Src/StdLib/Lib/test/test_contextlib.py b/StdLib/Lib/test/test_contextlib.py similarity index 100% rename from Src/StdLib/Lib/test/test_contextlib.py rename to StdLib/Lib/test/test_contextlib.py diff --git a/Src/StdLib/Lib/test/test_copy.py b/StdLib/Lib/test/test_copy.py similarity index 100% rename from Src/StdLib/Lib/test/test_copy.py rename to StdLib/Lib/test/test_copy.py diff --git a/Src/StdLib/Lib/test/test_copyreg.py b/StdLib/Lib/test/test_copyreg.py similarity index 100% rename from Src/StdLib/Lib/test/test_copyreg.py rename to StdLib/Lib/test/test_copyreg.py diff --git a/Src/StdLib/Lib/test/test_cprofile.py b/StdLib/Lib/test/test_cprofile.py similarity index 100% rename from Src/StdLib/Lib/test/test_cprofile.py rename to StdLib/Lib/test/test_cprofile.py diff --git a/Src/StdLib/Lib/test/test_crashers.py b/StdLib/Lib/test/test_crashers.py similarity index 100% rename from Src/StdLib/Lib/test/test_crashers.py rename to StdLib/Lib/test/test_crashers.py diff --git a/Src/StdLib/Lib/test/test_crypt.py b/StdLib/Lib/test/test_crypt.py similarity index 100% rename from Src/StdLib/Lib/test/test_crypt.py rename to StdLib/Lib/test/test_crypt.py diff --git a/Src/StdLib/Lib/test/test_csv.py b/StdLib/Lib/test/test_csv.py similarity index 100% rename from Src/StdLib/Lib/test/test_csv.py rename to StdLib/Lib/test/test_csv.py diff --git a/Src/StdLib/Lib/test/test_ctypes.py b/StdLib/Lib/test/test_ctypes.py similarity index 100% rename from Src/StdLib/Lib/test/test_ctypes.py rename to StdLib/Lib/test/test_ctypes.py diff --git a/Src/StdLib/Lib/test/test_curses.py b/StdLib/Lib/test/test_curses.py similarity index 100% rename from Src/StdLib/Lib/test/test_curses.py rename to StdLib/Lib/test/test_curses.py diff --git a/Src/StdLib/Lib/test/test_datetime.py b/StdLib/Lib/test/test_datetime.py similarity index 100% rename from Src/StdLib/Lib/test/test_datetime.py rename to StdLib/Lib/test/test_datetime.py diff --git a/Src/StdLib/Lib/test/test_dbm.py b/StdLib/Lib/test/test_dbm.py similarity index 100% rename from Src/StdLib/Lib/test/test_dbm.py rename to StdLib/Lib/test/test_dbm.py diff --git a/Src/StdLib/Lib/test/test_dbm_dumb.py b/StdLib/Lib/test/test_dbm_dumb.py similarity index 100% rename from Src/StdLib/Lib/test/test_dbm_dumb.py rename to StdLib/Lib/test/test_dbm_dumb.py diff --git a/Src/StdLib/Lib/test/test_dbm_gnu.py b/StdLib/Lib/test/test_dbm_gnu.py similarity index 100% rename from Src/StdLib/Lib/test/test_dbm_gnu.py rename to StdLib/Lib/test/test_dbm_gnu.py diff --git a/Src/StdLib/Lib/test/test_dbm_ndbm.py b/StdLib/Lib/test/test_dbm_ndbm.py similarity index 100% rename from Src/StdLib/Lib/test/test_dbm_ndbm.py rename to StdLib/Lib/test/test_dbm_ndbm.py diff --git a/Src/StdLib/Lib/test/test_decimal.py b/StdLib/Lib/test/test_decimal.py similarity index 100% rename from Src/StdLib/Lib/test/test_decimal.py rename to StdLib/Lib/test/test_decimal.py diff --git a/Src/StdLib/Lib/test/test_decorators.py b/StdLib/Lib/test/test_decorators.py similarity index 100% rename from Src/StdLib/Lib/test/test_decorators.py rename to StdLib/Lib/test/test_decorators.py diff --git a/Src/StdLib/Lib/test/test_defaultdict.py b/StdLib/Lib/test/test_defaultdict.py similarity index 100% rename from Src/StdLib/Lib/test/test_defaultdict.py rename to StdLib/Lib/test/test_defaultdict.py diff --git a/Src/StdLib/Lib/test/test_deque.py b/StdLib/Lib/test/test_deque.py similarity index 100% rename from Src/StdLib/Lib/test/test_deque.py rename to StdLib/Lib/test/test_deque.py diff --git a/Src/StdLib/Lib/test/test_descr.py b/StdLib/Lib/test/test_descr.py similarity index 100% rename from Src/StdLib/Lib/test/test_descr.py rename to StdLib/Lib/test/test_descr.py diff --git a/Src/StdLib/Lib/test/test_descrtut.py b/StdLib/Lib/test/test_descrtut.py similarity index 100% rename from Src/StdLib/Lib/test/test_descrtut.py rename to StdLib/Lib/test/test_descrtut.py diff --git a/Src/StdLib/Lib/test/test_devpoll.py b/StdLib/Lib/test/test_devpoll.py similarity index 100% rename from Src/StdLib/Lib/test/test_devpoll.py rename to StdLib/Lib/test/test_devpoll.py diff --git a/Src/StdLib/Lib/test/test_dict.py b/StdLib/Lib/test/test_dict.py similarity index 100% rename from Src/StdLib/Lib/test/test_dict.py rename to StdLib/Lib/test/test_dict.py diff --git a/Src/StdLib/Lib/test/test_dictcomps.py b/StdLib/Lib/test/test_dictcomps.py similarity index 100% rename from Src/StdLib/Lib/test/test_dictcomps.py rename to StdLib/Lib/test/test_dictcomps.py diff --git a/Src/StdLib/Lib/test/test_dictviews.py b/StdLib/Lib/test/test_dictviews.py similarity index 100% rename from Src/StdLib/Lib/test/test_dictviews.py rename to StdLib/Lib/test/test_dictviews.py diff --git a/Src/StdLib/Lib/test/test_difflib.py b/StdLib/Lib/test/test_difflib.py similarity index 100% rename from Src/StdLib/Lib/test/test_difflib.py rename to StdLib/Lib/test/test_difflib.py diff --git a/Src/StdLib/Lib/test/test_difflib_expect.html b/StdLib/Lib/test/test_difflib_expect.html similarity index 100% rename from Src/StdLib/Lib/test/test_difflib_expect.html rename to StdLib/Lib/test/test_difflib_expect.html diff --git a/Src/StdLib/Lib/test/test_dis.py b/StdLib/Lib/test/test_dis.py similarity index 100% rename from Src/StdLib/Lib/test/test_dis.py rename to StdLib/Lib/test/test_dis.py diff --git a/Src/StdLib/Lib/test/test_distutils.py b/StdLib/Lib/test/test_distutils.py similarity index 100% rename from Src/StdLib/Lib/test/test_distutils.py rename to StdLib/Lib/test/test_distutils.py diff --git a/Src/StdLib/Lib/test/test_doctest.py b/StdLib/Lib/test/test_doctest.py similarity index 100% rename from Src/StdLib/Lib/test/test_doctest.py rename to StdLib/Lib/test/test_doctest.py diff --git a/Src/StdLib/Lib/test/test_doctest.txt b/StdLib/Lib/test/test_doctest.txt similarity index 100% rename from Src/StdLib/Lib/test/test_doctest.txt rename to StdLib/Lib/test/test_doctest.txt diff --git a/Src/StdLib/Lib/test/test_doctest2.py b/StdLib/Lib/test/test_doctest2.py similarity index 100% rename from Src/StdLib/Lib/test/test_doctest2.py rename to StdLib/Lib/test/test_doctest2.py diff --git a/Src/StdLib/Lib/test/test_doctest2.txt b/StdLib/Lib/test/test_doctest2.txt similarity index 100% rename from Src/StdLib/Lib/test/test_doctest2.txt rename to StdLib/Lib/test/test_doctest2.txt diff --git a/Src/StdLib/Lib/test/test_doctest3.txt b/StdLib/Lib/test/test_doctest3.txt similarity index 100% rename from Src/StdLib/Lib/test/test_doctest3.txt rename to StdLib/Lib/test/test_doctest3.txt diff --git a/Src/StdLib/Lib/test/test_doctest4.txt b/StdLib/Lib/test/test_doctest4.txt similarity index 100% rename from Src/StdLib/Lib/test/test_doctest4.txt rename to StdLib/Lib/test/test_doctest4.txt diff --git a/Src/StdLib/Lib/test/test_docxmlrpc.py b/StdLib/Lib/test/test_docxmlrpc.py similarity index 100% rename from Src/StdLib/Lib/test/test_docxmlrpc.py rename to StdLib/Lib/test/test_docxmlrpc.py diff --git a/Src/StdLib/Lib/test/test_dummy_thread.py b/StdLib/Lib/test/test_dummy_thread.py similarity index 100% rename from Src/StdLib/Lib/test/test_dummy_thread.py rename to StdLib/Lib/test/test_dummy_thread.py diff --git a/Src/StdLib/Lib/test/test_dummy_threading.py b/StdLib/Lib/test/test_dummy_threading.py similarity index 100% rename from Src/StdLib/Lib/test/test_dummy_threading.py rename to StdLib/Lib/test/test_dummy_threading.py diff --git a/Src/StdLib/Lib/test/test_dynamic.py b/StdLib/Lib/test/test_dynamic.py similarity index 100% rename from Src/StdLib/Lib/test/test_dynamic.py rename to StdLib/Lib/test/test_dynamic.py diff --git a/Src/StdLib/Lib/test/test_dynamicclassattribute.py b/StdLib/Lib/test/test_dynamicclassattribute.py similarity index 100% rename from Src/StdLib/Lib/test/test_dynamicclassattribute.py rename to StdLib/Lib/test/test_dynamicclassattribute.py diff --git a/Src/StdLib/Lib/test/test_email/__init__.py b/StdLib/Lib/test/test_email/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/__init__.py rename to StdLib/Lib/test/test_email/__init__.py diff --git a/Src/StdLib/Lib/test/test_email/__main__.py b/StdLib/Lib/test/test_email/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/__main__.py rename to StdLib/Lib/test/test_email/__main__.py diff --git a/Src/StdLib/Lib/test/test_email/data/PyBanner048.gif b/StdLib/Lib/test/test_email/data/PyBanner048.gif similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/PyBanner048.gif rename to StdLib/Lib/test/test_email/data/PyBanner048.gif diff --git a/Src/StdLib/Lib/test/test_email/data/audiotest.au b/StdLib/Lib/test/test_email/data/audiotest.au similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/audiotest.au rename to StdLib/Lib/test/test_email/data/audiotest.au diff --git a/Src/StdLib/Lib/test/test_email/data/msg_01.txt b/StdLib/Lib/test/test_email/data/msg_01.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_01.txt rename to StdLib/Lib/test/test_email/data/msg_01.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_02.txt b/StdLib/Lib/test/test_email/data/msg_02.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_02.txt rename to StdLib/Lib/test/test_email/data/msg_02.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_03.txt b/StdLib/Lib/test/test_email/data/msg_03.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_03.txt rename to StdLib/Lib/test/test_email/data/msg_03.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_04.txt b/StdLib/Lib/test/test_email/data/msg_04.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_04.txt rename to StdLib/Lib/test/test_email/data/msg_04.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_05.txt b/StdLib/Lib/test/test_email/data/msg_05.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_05.txt rename to StdLib/Lib/test/test_email/data/msg_05.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_06.txt b/StdLib/Lib/test/test_email/data/msg_06.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_06.txt rename to StdLib/Lib/test/test_email/data/msg_06.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_07.txt b/StdLib/Lib/test/test_email/data/msg_07.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_07.txt rename to StdLib/Lib/test/test_email/data/msg_07.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_08.txt b/StdLib/Lib/test/test_email/data/msg_08.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_08.txt rename to StdLib/Lib/test/test_email/data/msg_08.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_09.txt b/StdLib/Lib/test/test_email/data/msg_09.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_09.txt rename to StdLib/Lib/test/test_email/data/msg_09.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_10.txt b/StdLib/Lib/test/test_email/data/msg_10.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_10.txt rename to StdLib/Lib/test/test_email/data/msg_10.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_11.txt b/StdLib/Lib/test/test_email/data/msg_11.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_11.txt rename to StdLib/Lib/test/test_email/data/msg_11.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_12.txt b/StdLib/Lib/test/test_email/data/msg_12.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_12.txt rename to StdLib/Lib/test/test_email/data/msg_12.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_12a.txt b/StdLib/Lib/test/test_email/data/msg_12a.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_12a.txt rename to StdLib/Lib/test/test_email/data/msg_12a.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_13.txt b/StdLib/Lib/test/test_email/data/msg_13.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_13.txt rename to StdLib/Lib/test/test_email/data/msg_13.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_14.txt b/StdLib/Lib/test/test_email/data/msg_14.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_14.txt rename to StdLib/Lib/test/test_email/data/msg_14.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_15.txt b/StdLib/Lib/test/test_email/data/msg_15.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_15.txt rename to StdLib/Lib/test/test_email/data/msg_15.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_16.txt b/StdLib/Lib/test/test_email/data/msg_16.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_16.txt rename to StdLib/Lib/test/test_email/data/msg_16.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_17.txt b/StdLib/Lib/test/test_email/data/msg_17.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_17.txt rename to StdLib/Lib/test/test_email/data/msg_17.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_18.txt b/StdLib/Lib/test/test_email/data/msg_18.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_18.txt rename to StdLib/Lib/test/test_email/data/msg_18.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_19.txt b/StdLib/Lib/test/test_email/data/msg_19.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_19.txt rename to StdLib/Lib/test/test_email/data/msg_19.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_20.txt b/StdLib/Lib/test/test_email/data/msg_20.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_20.txt rename to StdLib/Lib/test/test_email/data/msg_20.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_21.txt b/StdLib/Lib/test/test_email/data/msg_21.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_21.txt rename to StdLib/Lib/test/test_email/data/msg_21.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_22.txt b/StdLib/Lib/test/test_email/data/msg_22.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_22.txt rename to StdLib/Lib/test/test_email/data/msg_22.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_23.txt b/StdLib/Lib/test/test_email/data/msg_23.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_23.txt rename to StdLib/Lib/test/test_email/data/msg_23.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_24.txt b/StdLib/Lib/test/test_email/data/msg_24.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_24.txt rename to StdLib/Lib/test/test_email/data/msg_24.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_25.txt b/StdLib/Lib/test/test_email/data/msg_25.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_25.txt rename to StdLib/Lib/test/test_email/data/msg_25.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_26.txt b/StdLib/Lib/test/test_email/data/msg_26.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_26.txt rename to StdLib/Lib/test/test_email/data/msg_26.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_27.txt b/StdLib/Lib/test/test_email/data/msg_27.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_27.txt rename to StdLib/Lib/test/test_email/data/msg_27.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_28.txt b/StdLib/Lib/test/test_email/data/msg_28.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_28.txt rename to StdLib/Lib/test/test_email/data/msg_28.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_29.txt b/StdLib/Lib/test/test_email/data/msg_29.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_29.txt rename to StdLib/Lib/test/test_email/data/msg_29.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_30.txt b/StdLib/Lib/test/test_email/data/msg_30.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_30.txt rename to StdLib/Lib/test/test_email/data/msg_30.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_31.txt b/StdLib/Lib/test/test_email/data/msg_31.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_31.txt rename to StdLib/Lib/test/test_email/data/msg_31.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_32.txt b/StdLib/Lib/test/test_email/data/msg_32.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_32.txt rename to StdLib/Lib/test/test_email/data/msg_32.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_33.txt b/StdLib/Lib/test/test_email/data/msg_33.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_33.txt rename to StdLib/Lib/test/test_email/data/msg_33.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_34.txt b/StdLib/Lib/test/test_email/data/msg_34.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_34.txt rename to StdLib/Lib/test/test_email/data/msg_34.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_35.txt b/StdLib/Lib/test/test_email/data/msg_35.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_35.txt rename to StdLib/Lib/test/test_email/data/msg_35.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_36.txt b/StdLib/Lib/test/test_email/data/msg_36.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_36.txt rename to StdLib/Lib/test/test_email/data/msg_36.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_37.txt b/StdLib/Lib/test/test_email/data/msg_37.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_37.txt rename to StdLib/Lib/test/test_email/data/msg_37.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_38.txt b/StdLib/Lib/test/test_email/data/msg_38.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_38.txt rename to StdLib/Lib/test/test_email/data/msg_38.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_39.txt b/StdLib/Lib/test/test_email/data/msg_39.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_39.txt rename to StdLib/Lib/test/test_email/data/msg_39.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_40.txt b/StdLib/Lib/test/test_email/data/msg_40.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_40.txt rename to StdLib/Lib/test/test_email/data/msg_40.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_41.txt b/StdLib/Lib/test/test_email/data/msg_41.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_41.txt rename to StdLib/Lib/test/test_email/data/msg_41.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_42.txt b/StdLib/Lib/test/test_email/data/msg_42.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_42.txt rename to StdLib/Lib/test/test_email/data/msg_42.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_43.txt b/StdLib/Lib/test/test_email/data/msg_43.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_43.txt rename to StdLib/Lib/test/test_email/data/msg_43.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_44.txt b/StdLib/Lib/test/test_email/data/msg_44.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_44.txt rename to StdLib/Lib/test/test_email/data/msg_44.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_45.txt b/StdLib/Lib/test/test_email/data/msg_45.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_45.txt rename to StdLib/Lib/test/test_email/data/msg_45.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_46.txt b/StdLib/Lib/test/test_email/data/msg_46.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_46.txt rename to StdLib/Lib/test/test_email/data/msg_46.txt diff --git a/Src/StdLib/Lib/test/test_email/test__encoded_words.py b/StdLib/Lib/test/test_email/test__encoded_words.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test__encoded_words.py rename to StdLib/Lib/test/test_email/test__encoded_words.py diff --git a/Src/StdLib/Lib/test/test_email/test__header_value_parser.py b/StdLib/Lib/test/test_email/test__header_value_parser.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test__header_value_parser.py rename to StdLib/Lib/test/test_email/test__header_value_parser.py diff --git a/Src/StdLib/Lib/test/test_email/test_asian_codecs.py b/StdLib/Lib/test/test_email/test_asian_codecs.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_asian_codecs.py rename to StdLib/Lib/test/test_email/test_asian_codecs.py diff --git a/Src/StdLib/Lib/test/test_email/test_contentmanager.py b/StdLib/Lib/test/test_email/test_contentmanager.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_contentmanager.py rename to StdLib/Lib/test/test_email/test_contentmanager.py diff --git a/Src/StdLib/Lib/test/test_email/test_defect_handling.py b/StdLib/Lib/test/test_email/test_defect_handling.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_defect_handling.py rename to StdLib/Lib/test/test_email/test_defect_handling.py diff --git a/Src/StdLib/Lib/test/test_email/test_email.py b/StdLib/Lib/test/test_email/test_email.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_email.py rename to StdLib/Lib/test/test_email/test_email.py diff --git a/Src/StdLib/Lib/test/test_email/test_generator.py b/StdLib/Lib/test/test_email/test_generator.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_generator.py rename to StdLib/Lib/test/test_email/test_generator.py diff --git a/Src/StdLib/Lib/test/test_email/test_headerregistry.py b/StdLib/Lib/test/test_email/test_headerregistry.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_headerregistry.py rename to StdLib/Lib/test/test_email/test_headerregistry.py diff --git a/Src/StdLib/Lib/test/test_email/test_inversion.py b/StdLib/Lib/test/test_email/test_inversion.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_inversion.py rename to StdLib/Lib/test/test_email/test_inversion.py diff --git a/Src/StdLib/Lib/test/test_email/test_message.py b/StdLib/Lib/test/test_email/test_message.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_message.py rename to StdLib/Lib/test/test_email/test_message.py diff --git a/Src/StdLib/Lib/test/test_email/test_parser.py b/StdLib/Lib/test/test_email/test_parser.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_parser.py rename to StdLib/Lib/test/test_email/test_parser.py diff --git a/Src/StdLib/Lib/test/test_email/test_pickleable.py b/StdLib/Lib/test/test_email/test_pickleable.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_pickleable.py rename to StdLib/Lib/test/test_email/test_pickleable.py diff --git a/Src/StdLib/Lib/test/test_email/test_policy.py b/StdLib/Lib/test/test_email/test_policy.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_policy.py rename to StdLib/Lib/test/test_email/test_policy.py diff --git a/Src/StdLib/Lib/test/test_email/test_utils.py b/StdLib/Lib/test/test_email/test_utils.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_utils.py rename to StdLib/Lib/test/test_email/test_utils.py diff --git a/Src/StdLib/Lib/test/test_email/torture_test.py b/StdLib/Lib/test/test_email/torture_test.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/torture_test.py rename to StdLib/Lib/test/test_email/torture_test.py diff --git a/Src/StdLib/Lib/test/test_ensurepip.py b/StdLib/Lib/test/test_ensurepip.py similarity index 100% rename from Src/StdLib/Lib/test/test_ensurepip.py rename to StdLib/Lib/test/test_ensurepip.py diff --git a/Src/StdLib/Lib/test/test_enum.py b/StdLib/Lib/test/test_enum.py similarity index 100% rename from Src/StdLib/Lib/test/test_enum.py rename to StdLib/Lib/test/test_enum.py diff --git a/Src/StdLib/Lib/test/test_enumerate.py b/StdLib/Lib/test/test_enumerate.py similarity index 100% rename from Src/StdLib/Lib/test/test_enumerate.py rename to StdLib/Lib/test/test_enumerate.py diff --git a/Src/StdLib/Lib/test/test_eof.py b/StdLib/Lib/test/test_eof.py similarity index 100% rename from Src/StdLib/Lib/test/test_eof.py rename to StdLib/Lib/test/test_eof.py diff --git a/Src/StdLib/Lib/test/test_epoll.py b/StdLib/Lib/test/test_epoll.py similarity index 100% rename from Src/StdLib/Lib/test/test_epoll.py rename to StdLib/Lib/test/test_epoll.py diff --git a/Src/StdLib/Lib/test/test_errno.py b/StdLib/Lib/test/test_errno.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/test/test_errno.py rename to StdLib/Lib/test/test_errno.py diff --git a/Src/StdLib/Lib/test/test_exception_variations.py b/StdLib/Lib/test/test_exception_variations.py similarity index 100% rename from Src/StdLib/Lib/test/test_exception_variations.py rename to StdLib/Lib/test/test_exception_variations.py diff --git a/Src/StdLib/Lib/test/test_exceptions.py b/StdLib/Lib/test/test_exceptions.py similarity index 100% rename from Src/StdLib/Lib/test/test_exceptions.py rename to StdLib/Lib/test/test_exceptions.py diff --git a/Src/StdLib/Lib/test/test_extcall.py b/StdLib/Lib/test/test_extcall.py similarity index 100% rename from Src/StdLib/Lib/test/test_extcall.py rename to StdLib/Lib/test/test_extcall.py diff --git a/Src/StdLib/Lib/test/test_faulthandler.py b/StdLib/Lib/test/test_faulthandler.py similarity index 100% rename from Src/StdLib/Lib/test/test_faulthandler.py rename to StdLib/Lib/test/test_faulthandler.py diff --git a/Src/StdLib/Lib/test/test_fcntl.py b/StdLib/Lib/test/test_fcntl.py similarity index 100% rename from Src/StdLib/Lib/test/test_fcntl.py rename to StdLib/Lib/test/test_fcntl.py diff --git a/Src/StdLib/Lib/test/test_file.py b/StdLib/Lib/test/test_file.py similarity index 100% rename from Src/StdLib/Lib/test/test_file.py rename to StdLib/Lib/test/test_file.py diff --git a/Src/StdLib/Lib/test/test_file_eintr.py b/StdLib/Lib/test/test_file_eintr.py similarity index 100% rename from Src/StdLib/Lib/test/test_file_eintr.py rename to StdLib/Lib/test/test_file_eintr.py diff --git a/Src/StdLib/Lib/test/test_filecmp.py b/StdLib/Lib/test/test_filecmp.py similarity index 100% rename from Src/StdLib/Lib/test/test_filecmp.py rename to StdLib/Lib/test/test_filecmp.py diff --git a/Src/StdLib/Lib/test/test_fileinput.py b/StdLib/Lib/test/test_fileinput.py similarity index 100% rename from Src/StdLib/Lib/test/test_fileinput.py rename to StdLib/Lib/test/test_fileinput.py diff --git a/Src/StdLib/Lib/test/test_fileio.py b/StdLib/Lib/test/test_fileio.py similarity index 100% rename from Src/StdLib/Lib/test/test_fileio.py rename to StdLib/Lib/test/test_fileio.py diff --git a/Src/StdLib/Lib/test/test_finalization.py b/StdLib/Lib/test/test_finalization.py similarity index 100% rename from Src/StdLib/Lib/test/test_finalization.py rename to StdLib/Lib/test/test_finalization.py diff --git a/Src/StdLib/Lib/test/test_float.py b/StdLib/Lib/test/test_float.py similarity index 100% rename from Src/StdLib/Lib/test/test_float.py rename to StdLib/Lib/test/test_float.py diff --git a/Src/StdLib/Lib/test/test_flufl.py b/StdLib/Lib/test/test_flufl.py similarity index 100% rename from Src/StdLib/Lib/test/test_flufl.py rename to StdLib/Lib/test/test_flufl.py diff --git a/Src/StdLib/Lib/test/test_fnmatch.py b/StdLib/Lib/test/test_fnmatch.py similarity index 100% rename from Src/StdLib/Lib/test/test_fnmatch.py rename to StdLib/Lib/test/test_fnmatch.py diff --git a/Src/StdLib/Lib/test/test_fork1.py b/StdLib/Lib/test/test_fork1.py similarity index 100% rename from Src/StdLib/Lib/test/test_fork1.py rename to StdLib/Lib/test/test_fork1.py diff --git a/Src/StdLib/Lib/test/test_format.py b/StdLib/Lib/test/test_format.py similarity index 100% rename from Src/StdLib/Lib/test/test_format.py rename to StdLib/Lib/test/test_format.py diff --git a/Src/StdLib/Lib/test/test_fractions.py b/StdLib/Lib/test/test_fractions.py similarity index 100% rename from Src/StdLib/Lib/test/test_fractions.py rename to StdLib/Lib/test/test_fractions.py diff --git a/Src/StdLib/Lib/test/test_frame.py b/StdLib/Lib/test/test_frame.py similarity index 100% rename from Src/StdLib/Lib/test/test_frame.py rename to StdLib/Lib/test/test_frame.py diff --git a/Src/StdLib/Lib/test/test_fstring.py b/StdLib/Lib/test/test_fstring.py similarity index 100% rename from Src/StdLib/Lib/test/test_fstring.py rename to StdLib/Lib/test/test_fstring.py diff --git a/Src/StdLib/Lib/test/test_ftplib.py b/StdLib/Lib/test/test_ftplib.py similarity index 100% rename from Src/StdLib/Lib/test/test_ftplib.py rename to StdLib/Lib/test/test_ftplib.py diff --git a/Src/StdLib/Lib/test/test_funcattrs.py b/StdLib/Lib/test/test_funcattrs.py similarity index 100% rename from Src/StdLib/Lib/test/test_funcattrs.py rename to StdLib/Lib/test/test_funcattrs.py diff --git a/Src/StdLib/Lib/test/test_functools.py b/StdLib/Lib/test/test_functools.py similarity index 100% rename from Src/StdLib/Lib/test/test_functools.py rename to StdLib/Lib/test/test_functools.py diff --git a/Src/StdLib/Lib/test/test_future.py b/StdLib/Lib/test/test_future.py similarity index 100% rename from Src/StdLib/Lib/test/test_future.py rename to StdLib/Lib/test/test_future.py diff --git a/Src/StdLib/Lib/test/test_future3.py b/StdLib/Lib/test/test_future3.py similarity index 100% rename from Src/StdLib/Lib/test/test_future3.py rename to StdLib/Lib/test/test_future3.py diff --git a/Src/StdLib/Lib/test/test_future4.py b/StdLib/Lib/test/test_future4.py similarity index 100% rename from Src/StdLib/Lib/test/test_future4.py rename to StdLib/Lib/test/test_future4.py diff --git a/Src/StdLib/Lib/test/test_future5.py b/StdLib/Lib/test/test_future5.py similarity index 100% rename from Src/StdLib/Lib/test/test_future5.py rename to StdLib/Lib/test/test_future5.py diff --git a/Src/StdLib/Lib/test/test_gc.py b/StdLib/Lib/test/test_gc.py similarity index 100% rename from Src/StdLib/Lib/test/test_gc.py rename to StdLib/Lib/test/test_gc.py diff --git a/Src/StdLib/Lib/test/test_gdb.py b/StdLib/Lib/test/test_gdb.py similarity index 100% rename from Src/StdLib/Lib/test/test_gdb.py rename to StdLib/Lib/test/test_gdb.py diff --git a/Src/StdLib/Lib/test/test_generators.py b/StdLib/Lib/test/test_generators.py similarity index 100% rename from Src/StdLib/Lib/test/test_generators.py rename to StdLib/Lib/test/test_generators.py diff --git a/Src/StdLib/Lib/test/test_genericpath.py b/StdLib/Lib/test/test_genericpath.py similarity index 100% rename from Src/StdLib/Lib/test/test_genericpath.py rename to StdLib/Lib/test/test_genericpath.py diff --git a/Src/StdLib/Lib/test/test_genexps.py b/StdLib/Lib/test/test_genexps.py similarity index 100% rename from Src/StdLib/Lib/test/test_genexps.py rename to StdLib/Lib/test/test_genexps.py diff --git a/Src/StdLib/Lib/test/test_getargs2.py b/StdLib/Lib/test/test_getargs2.py similarity index 100% rename from Src/StdLib/Lib/test/test_getargs2.py rename to StdLib/Lib/test/test_getargs2.py diff --git a/Src/StdLib/Lib/test/test_getopt.py b/StdLib/Lib/test/test_getopt.py similarity index 100% rename from Src/StdLib/Lib/test/test_getopt.py rename to StdLib/Lib/test/test_getopt.py diff --git a/Src/StdLib/Lib/test/test_getpass.py b/StdLib/Lib/test/test_getpass.py similarity index 100% rename from Src/StdLib/Lib/test/test_getpass.py rename to StdLib/Lib/test/test_getpass.py diff --git a/Src/StdLib/Lib/test/test_gettext.py b/StdLib/Lib/test/test_gettext.py similarity index 100% rename from Src/StdLib/Lib/test/test_gettext.py rename to StdLib/Lib/test/test_gettext.py diff --git a/Src/StdLib/Lib/test/test_glob.py b/StdLib/Lib/test/test_glob.py similarity index 100% rename from Src/StdLib/Lib/test/test_glob.py rename to StdLib/Lib/test/test_glob.py diff --git a/Src/StdLib/Lib/test/test_global.py b/StdLib/Lib/test/test_global.py similarity index 100% rename from Src/StdLib/Lib/test/test_global.py rename to StdLib/Lib/test/test_global.py diff --git a/Src/StdLib/Lib/test/test_grammar.py b/StdLib/Lib/test/test_grammar.py similarity index 100% rename from Src/StdLib/Lib/test/test_grammar.py rename to StdLib/Lib/test/test_grammar.py diff --git a/Src/StdLib/Lib/test/test_grp.py b/StdLib/Lib/test/test_grp.py similarity index 100% rename from Src/StdLib/Lib/test/test_grp.py rename to StdLib/Lib/test/test_grp.py diff --git a/Src/StdLib/Lib/test/test_gzip.py b/StdLib/Lib/test/test_gzip.py similarity index 100% rename from Src/StdLib/Lib/test/test_gzip.py rename to StdLib/Lib/test/test_gzip.py diff --git a/Src/StdLib/Lib/test/test_hash.py b/StdLib/Lib/test/test_hash.py similarity index 100% rename from Src/StdLib/Lib/test/test_hash.py rename to StdLib/Lib/test/test_hash.py diff --git a/Src/StdLib/Lib/test/test_hashlib.py b/StdLib/Lib/test/test_hashlib.py similarity index 100% rename from Src/StdLib/Lib/test/test_hashlib.py rename to StdLib/Lib/test/test_hashlib.py diff --git a/Src/StdLib/Lib/test/test_heapq.py b/StdLib/Lib/test/test_heapq.py similarity index 100% rename from Src/StdLib/Lib/test/test_heapq.py rename to StdLib/Lib/test/test_heapq.py diff --git a/Src/StdLib/Lib/test/test_hmac.py b/StdLib/Lib/test/test_hmac.py similarity index 100% rename from Src/StdLib/Lib/test/test_hmac.py rename to StdLib/Lib/test/test_hmac.py diff --git a/Src/StdLib/Lib/test/test_html.py b/StdLib/Lib/test/test_html.py similarity index 100% rename from Src/StdLib/Lib/test/test_html.py rename to StdLib/Lib/test/test_html.py diff --git a/Src/StdLib/Lib/test/test_htmlparser.py b/StdLib/Lib/test/test_htmlparser.py similarity index 100% rename from Src/StdLib/Lib/test/test_htmlparser.py rename to StdLib/Lib/test/test_htmlparser.py diff --git a/Src/StdLib/Lib/test/test_http_cookiejar.py b/StdLib/Lib/test/test_http_cookiejar.py similarity index 100% rename from Src/StdLib/Lib/test/test_http_cookiejar.py rename to StdLib/Lib/test/test_http_cookiejar.py diff --git a/Src/StdLib/Lib/test/test_http_cookies.py b/StdLib/Lib/test/test_http_cookies.py similarity index 100% rename from Src/StdLib/Lib/test/test_http_cookies.py rename to StdLib/Lib/test/test_http_cookies.py diff --git a/Src/StdLib/Lib/test/test_httplib.py b/StdLib/Lib/test/test_httplib.py similarity index 100% rename from Src/StdLib/Lib/test/test_httplib.py rename to StdLib/Lib/test/test_httplib.py diff --git a/Src/StdLib/Lib/test/test_httpservers.py b/StdLib/Lib/test/test_httpservers.py similarity index 100% rename from Src/StdLib/Lib/test/test_httpservers.py rename to StdLib/Lib/test/test_httpservers.py diff --git a/Src/StdLib/Lib/test/test_idle.py b/StdLib/Lib/test/test_idle.py similarity index 100% rename from Src/StdLib/Lib/test/test_idle.py rename to StdLib/Lib/test/test_idle.py diff --git a/Src/StdLib/Lib/test/test_imaplib.py b/StdLib/Lib/test/test_imaplib.py similarity index 100% rename from Src/StdLib/Lib/test/test_imaplib.py rename to StdLib/Lib/test/test_imaplib.py diff --git a/Src/StdLib/Lib/test/test_imghdr.py b/StdLib/Lib/test/test_imghdr.py similarity index 100% rename from Src/StdLib/Lib/test/test_imghdr.py rename to StdLib/Lib/test/test_imghdr.py diff --git a/Src/StdLib/Lib/test/test_imp.py b/StdLib/Lib/test/test_imp.py similarity index 100% rename from Src/StdLib/Lib/test/test_imp.py rename to StdLib/Lib/test/test_imp.py diff --git a/Src/StdLib/Lib/test/test_import.py b/StdLib/Lib/test/test_import.py similarity index 100% rename from Src/StdLib/Lib/test/test_import.py rename to StdLib/Lib/test/test_import.py diff --git a/Src/StdLib/Lib/test/test_importlib/__init__.py b/StdLib/Lib/test/test_importlib/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/__init__.py rename to StdLib/Lib/test/test_importlib/__init__.py diff --git a/Src/StdLib/Lib/test/test_importlib/__main__.py b/StdLib/Lib/test/test_importlib/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/__main__.py rename to StdLib/Lib/test/test_importlib/__main__.py diff --git a/Src/StdLib/Lib/test/test_importlib/abc.py b/StdLib/Lib/test/test_importlib/abc.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/abc.py rename to StdLib/Lib/test/test_importlib/abc.py diff --git a/Src/StdLib/Lib/test/test_importlib/builtin/__init__.py b/StdLib/Lib/test/test_importlib/builtin/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/builtin/__init__.py rename to StdLib/Lib/test/test_importlib/builtin/__init__.py diff --git a/Src/StdLib/Lib/test/test_importlib/builtin/__main__.py b/StdLib/Lib/test/test_importlib/builtin/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/builtin/__main__.py rename to StdLib/Lib/test/test_importlib/builtin/__main__.py diff --git a/Src/StdLib/Lib/test/test_importlib/builtin/test_finder.py b/StdLib/Lib/test/test_importlib/builtin/test_finder.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/builtin/test_finder.py rename to StdLib/Lib/test/test_importlib/builtin/test_finder.py diff --git a/Src/StdLib/Lib/test/test_importlib/builtin/test_loader.py b/StdLib/Lib/test/test_importlib/builtin/test_loader.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/builtin/test_loader.py rename to StdLib/Lib/test/test_importlib/builtin/test_loader.py diff --git a/Src/StdLib/Lib/test/test_importlib/builtin/util.py b/StdLib/Lib/test/test_importlib/builtin/util.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/builtin/util.py rename to StdLib/Lib/test/test_importlib/builtin/util.py diff --git a/Src/StdLib/Lib/test/test_importlib/extension/__init__.py b/StdLib/Lib/test/test_importlib/extension/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/extension/__init__.py rename to StdLib/Lib/test/test_importlib/extension/__init__.py diff --git a/Src/StdLib/Lib/test/test_importlib/extension/__main__.py b/StdLib/Lib/test/test_importlib/extension/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/extension/__main__.py rename to StdLib/Lib/test/test_importlib/extension/__main__.py diff --git a/Src/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py b/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py rename to StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py diff --git a/Src/StdLib/Lib/test/test_importlib/extension/test_finder.py b/StdLib/Lib/test/test_importlib/extension/test_finder.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/extension/test_finder.py rename to StdLib/Lib/test/test_importlib/extension/test_finder.py diff --git a/Src/StdLib/Lib/test/test_importlib/extension/test_loader.py b/StdLib/Lib/test/test_importlib/extension/test_loader.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/extension/test_loader.py rename to StdLib/Lib/test/test_importlib/extension/test_loader.py diff --git a/Src/StdLib/Lib/test/test_importlib/extension/test_path_hook.py b/StdLib/Lib/test/test_importlib/extension/test_path_hook.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/extension/test_path_hook.py rename to StdLib/Lib/test/test_importlib/extension/test_path_hook.py diff --git a/Src/StdLib/Lib/test/test_importlib/extension/util.py b/StdLib/Lib/test/test_importlib/extension/util.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/extension/util.py rename to StdLib/Lib/test/test_importlib/extension/util.py diff --git a/Src/StdLib/Lib/test/test_importlib/frozen/__init__.py b/StdLib/Lib/test/test_importlib/frozen/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/frozen/__init__.py rename to StdLib/Lib/test/test_importlib/frozen/__init__.py diff --git a/Src/StdLib/Lib/test/test_importlib/frozen/__main__.py b/StdLib/Lib/test/test_importlib/frozen/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/frozen/__main__.py rename to StdLib/Lib/test/test_importlib/frozen/__main__.py diff --git a/Src/StdLib/Lib/test/test_importlib/frozen/test_finder.py b/StdLib/Lib/test/test_importlib/frozen/test_finder.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/frozen/test_finder.py rename to StdLib/Lib/test/test_importlib/frozen/test_finder.py diff --git a/Src/StdLib/Lib/test/test_importlib/frozen/test_loader.py b/StdLib/Lib/test/test_importlib/frozen/test_loader.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/frozen/test_loader.py rename to StdLib/Lib/test/test_importlib/frozen/test_loader.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/__init__.py b/StdLib/Lib/test/test_importlib/import_/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/__init__.py rename to StdLib/Lib/test/test_importlib/import_/__init__.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/__main__.py b/StdLib/Lib/test/test_importlib/import_/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/__main__.py rename to StdLib/Lib/test/test_importlib/import_/__main__.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/test___loader__.py b/StdLib/Lib/test/test_importlib/import_/test___loader__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/test___loader__.py rename to StdLib/Lib/test/test_importlib/import_/test___loader__.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/test___package__.py b/StdLib/Lib/test/test_importlib/import_/test___package__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/test___package__.py rename to StdLib/Lib/test/test_importlib/import_/test___package__.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/test_api.py b/StdLib/Lib/test/test_importlib/import_/test_api.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/test_api.py rename to StdLib/Lib/test/test_importlib/import_/test_api.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/test_caching.py b/StdLib/Lib/test/test_importlib/import_/test_caching.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/test_caching.py rename to StdLib/Lib/test/test_importlib/import_/test_caching.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/test_fromlist.py b/StdLib/Lib/test/test_importlib/import_/test_fromlist.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/test_fromlist.py rename to StdLib/Lib/test/test_importlib/import_/test_fromlist.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/test_meta_path.py b/StdLib/Lib/test/test_importlib/import_/test_meta_path.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/test_meta_path.py rename to StdLib/Lib/test/test_importlib/import_/test_meta_path.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/test_packages.py b/StdLib/Lib/test/test_importlib/import_/test_packages.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/test_packages.py rename to StdLib/Lib/test/test_importlib/import_/test_packages.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/test_path.py b/StdLib/Lib/test/test_importlib/import_/test_path.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/test_path.py rename to StdLib/Lib/test/test_importlib/import_/test_path.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py b/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py rename to StdLib/Lib/test/test_importlib/import_/test_relative_imports.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/util.py b/StdLib/Lib/test/test_importlib/import_/util.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/util.py rename to StdLib/Lib/test/test_importlib/import_/util.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py b/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py rename to StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py b/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py rename to StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip b/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip rename to StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py b/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py rename to StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty b/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty rename to StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip b/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip rename to StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py b/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py rename to StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py b/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py rename to StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py b/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py rename to StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py b/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py rename to StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py b/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py rename to StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py b/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py rename to StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py b/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py rename to StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip b/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip rename to StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip diff --git a/Src/StdLib/Lib/test/test_importlib/regrtest.py b/StdLib/Lib/test/test_importlib/regrtest.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/regrtest.py rename to StdLib/Lib/test/test_importlib/regrtest.py diff --git a/Src/StdLib/Lib/test/test_importlib/source/__init__.py b/StdLib/Lib/test/test_importlib/source/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/source/__init__.py rename to StdLib/Lib/test/test_importlib/source/__init__.py diff --git a/Src/StdLib/Lib/test/test_importlib/source/__main__.py b/StdLib/Lib/test/test_importlib/source/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/source/__main__.py rename to StdLib/Lib/test/test_importlib/source/__main__.py diff --git a/Src/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py b/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py rename to StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py diff --git a/Src/StdLib/Lib/test/test_importlib/source/test_file_loader.py b/StdLib/Lib/test/test_importlib/source/test_file_loader.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/source/test_file_loader.py rename to StdLib/Lib/test/test_importlib/source/test_file_loader.py diff --git a/Src/StdLib/Lib/test/test_importlib/source/test_finder.py b/StdLib/Lib/test/test_importlib/source/test_finder.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/source/test_finder.py rename to StdLib/Lib/test/test_importlib/source/test_finder.py diff --git a/Src/StdLib/Lib/test/test_importlib/source/test_path_hook.py b/StdLib/Lib/test/test_importlib/source/test_path_hook.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/source/test_path_hook.py rename to StdLib/Lib/test/test_importlib/source/test_path_hook.py diff --git a/Src/StdLib/Lib/test/test_importlib/source/test_source_encoding.py b/StdLib/Lib/test/test_importlib/source/test_source_encoding.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/source/test_source_encoding.py rename to StdLib/Lib/test/test_importlib/source/test_source_encoding.py diff --git a/Src/StdLib/Lib/test/test_importlib/source/util.py b/StdLib/Lib/test/test_importlib/source/util.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/source/util.py rename to StdLib/Lib/test/test_importlib/source/util.py diff --git a/Src/StdLib/Lib/test/test_importlib/test_abc.py b/StdLib/Lib/test/test_importlib/test_abc.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/test_abc.py rename to StdLib/Lib/test/test_importlib/test_abc.py diff --git a/Src/StdLib/Lib/test/test_importlib/test_api.py b/StdLib/Lib/test/test_importlib/test_api.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/test_api.py rename to StdLib/Lib/test/test_importlib/test_api.py diff --git a/Src/StdLib/Lib/test/test_importlib/test_locks.py b/StdLib/Lib/test/test_importlib/test_locks.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/test_locks.py rename to StdLib/Lib/test/test_importlib/test_locks.py diff --git a/Src/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py b/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py rename to StdLib/Lib/test/test_importlib/test_namespace_pkgs.py diff --git a/Src/StdLib/Lib/test/test_importlib/test_spec.py b/StdLib/Lib/test/test_importlib/test_spec.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/test_spec.py rename to StdLib/Lib/test/test_importlib/test_spec.py diff --git a/Src/StdLib/Lib/test/test_importlib/test_util.py b/StdLib/Lib/test/test_importlib/test_util.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/test_util.py rename to StdLib/Lib/test/test_importlib/test_util.py diff --git a/Src/StdLib/Lib/test/test_importlib/test_windows.py b/StdLib/Lib/test/test_importlib/test_windows.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/test_windows.py rename to StdLib/Lib/test/test_importlib/test_windows.py diff --git a/Src/StdLib/Lib/test/test_importlib/util.py b/StdLib/Lib/test/test_importlib/util.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/util.py rename to StdLib/Lib/test/test_importlib/util.py diff --git a/Src/StdLib/Lib/test/test_index.py b/StdLib/Lib/test/test_index.py similarity index 100% rename from Src/StdLib/Lib/test/test_index.py rename to StdLib/Lib/test/test_index.py diff --git a/Src/StdLib/Lib/test/test_inspect.py b/StdLib/Lib/test/test_inspect.py similarity index 100% rename from Src/StdLib/Lib/test/test_inspect.py rename to StdLib/Lib/test/test_inspect.py diff --git a/Src/StdLib/Lib/test/test_int.py b/StdLib/Lib/test/test_int.py similarity index 100% rename from Src/StdLib/Lib/test/test_int.py rename to StdLib/Lib/test/test_int.py diff --git a/Src/StdLib/Lib/test/test_int_literal.py b/StdLib/Lib/test/test_int_literal.py similarity index 100% rename from Src/StdLib/Lib/test/test_int_literal.py rename to StdLib/Lib/test/test_int_literal.py diff --git a/Src/StdLib/Lib/test/test_io.py b/StdLib/Lib/test/test_io.py similarity index 100% rename from Src/StdLib/Lib/test/test_io.py rename to StdLib/Lib/test/test_io.py diff --git a/Src/StdLib/Lib/test/test_ioctl.py b/StdLib/Lib/test/test_ioctl.py similarity index 100% rename from Src/StdLib/Lib/test/test_ioctl.py rename to StdLib/Lib/test/test_ioctl.py diff --git a/Src/StdLib/Lib/test/test_ipaddress.py b/StdLib/Lib/test/test_ipaddress.py similarity index 100% rename from Src/StdLib/Lib/test/test_ipaddress.py rename to StdLib/Lib/test/test_ipaddress.py diff --git a/Src/StdLib/Lib/test/test_isinstance.py b/StdLib/Lib/test/test_isinstance.py similarity index 100% rename from Src/StdLib/Lib/test/test_isinstance.py rename to StdLib/Lib/test/test_isinstance.py diff --git a/Src/StdLib/Lib/test/test_iter.py b/StdLib/Lib/test/test_iter.py similarity index 100% rename from Src/StdLib/Lib/test/test_iter.py rename to StdLib/Lib/test/test_iter.py diff --git a/Src/StdLib/Lib/test/test_iterlen.py b/StdLib/Lib/test/test_iterlen.py similarity index 100% rename from Src/StdLib/Lib/test/test_iterlen.py rename to StdLib/Lib/test/test_iterlen.py diff --git a/Src/StdLib/Lib/test/test_itertools.py b/StdLib/Lib/test/test_itertools.py similarity index 100% rename from Src/StdLib/Lib/test/test_itertools.py rename to StdLib/Lib/test/test_itertools.py diff --git a/Src/StdLib/Lib/test/test_json/__init__.py b/StdLib/Lib/test/test_json/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/__init__.py rename to StdLib/Lib/test/test_json/__init__.py diff --git a/Src/StdLib/Lib/test/test_json/__main__.py b/StdLib/Lib/test/test_json/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/__main__.py rename to StdLib/Lib/test/test_json/__main__.py diff --git a/Src/StdLib/Lib/test/test_json/test_decode.py b/StdLib/Lib/test/test_json/test_decode.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_decode.py rename to StdLib/Lib/test/test_json/test_decode.py diff --git a/Src/StdLib/Lib/test/test_json/test_default.py b/StdLib/Lib/test/test_json/test_default.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_default.py rename to StdLib/Lib/test/test_json/test_default.py diff --git a/Src/StdLib/Lib/test/test_json/test_dump.py b/StdLib/Lib/test/test_json/test_dump.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_dump.py rename to StdLib/Lib/test/test_json/test_dump.py diff --git a/Src/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py b/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py rename to StdLib/Lib/test/test_json/test_encode_basestring_ascii.py diff --git a/Src/StdLib/Lib/test/test_json/test_enum.py b/StdLib/Lib/test/test_json/test_enum.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_enum.py rename to StdLib/Lib/test/test_json/test_enum.py diff --git a/Src/StdLib/Lib/test/test_json/test_fail.py b/StdLib/Lib/test/test_json/test_fail.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_fail.py rename to StdLib/Lib/test/test_json/test_fail.py diff --git a/Src/StdLib/Lib/test/test_json/test_float.py b/StdLib/Lib/test/test_json/test_float.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_float.py rename to StdLib/Lib/test/test_json/test_float.py diff --git a/Src/StdLib/Lib/test/test_json/test_indent.py b/StdLib/Lib/test/test_json/test_indent.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_indent.py rename to StdLib/Lib/test/test_json/test_indent.py diff --git a/Src/StdLib/Lib/test/test_json/test_pass1.py b/StdLib/Lib/test/test_json/test_pass1.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_pass1.py rename to StdLib/Lib/test/test_json/test_pass1.py diff --git a/Src/StdLib/Lib/test/test_json/test_pass2.py b/StdLib/Lib/test/test_json/test_pass2.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_pass2.py rename to StdLib/Lib/test/test_json/test_pass2.py diff --git a/Src/StdLib/Lib/test/test_json/test_pass3.py b/StdLib/Lib/test/test_json/test_pass3.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_pass3.py rename to StdLib/Lib/test/test_json/test_pass3.py diff --git a/Src/StdLib/Lib/test/test_json/test_recursion.py b/StdLib/Lib/test/test_json/test_recursion.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_recursion.py rename to StdLib/Lib/test/test_json/test_recursion.py diff --git a/Src/StdLib/Lib/test/test_json/test_scanstring.py b/StdLib/Lib/test/test_json/test_scanstring.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_scanstring.py rename to StdLib/Lib/test/test_json/test_scanstring.py diff --git a/Src/StdLib/Lib/test/test_json/test_separators.py b/StdLib/Lib/test/test_json/test_separators.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_separators.py rename to StdLib/Lib/test/test_json/test_separators.py diff --git a/Src/StdLib/Lib/test/test_json/test_speedups.py b/StdLib/Lib/test/test_json/test_speedups.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_speedups.py rename to StdLib/Lib/test/test_json/test_speedups.py diff --git a/Src/StdLib/Lib/test/test_json/test_tool.py b/StdLib/Lib/test/test_json/test_tool.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_tool.py rename to StdLib/Lib/test/test_json/test_tool.py diff --git a/Src/StdLib/Lib/test/test_json/test_unicode.py b/StdLib/Lib/test/test_json/test_unicode.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_unicode.py rename to StdLib/Lib/test/test_json/test_unicode.py diff --git a/Src/StdLib/Lib/test/test_keyword.py b/StdLib/Lib/test/test_keyword.py similarity index 100% rename from Src/StdLib/Lib/test/test_keyword.py rename to StdLib/Lib/test/test_keyword.py diff --git a/Src/StdLib/Lib/test/test_keywordonlyarg.py b/StdLib/Lib/test/test_keywordonlyarg.py similarity index 100% rename from Src/StdLib/Lib/test/test_keywordonlyarg.py rename to StdLib/Lib/test/test_keywordonlyarg.py diff --git a/Src/StdLib/Lib/test/test_kqueue.py b/StdLib/Lib/test/test_kqueue.py similarity index 100% rename from Src/StdLib/Lib/test/test_kqueue.py rename to StdLib/Lib/test/test_kqueue.py diff --git a/Src/StdLib/Lib/test/test_largefile.py b/StdLib/Lib/test/test_largefile.py similarity index 100% rename from Src/StdLib/Lib/test/test_largefile.py rename to StdLib/Lib/test/test_largefile.py diff --git a/Src/StdLib/Lib/test/test_lib2to3.py b/StdLib/Lib/test/test_lib2to3.py similarity index 100% rename from Src/StdLib/Lib/test/test_lib2to3.py rename to StdLib/Lib/test/test_lib2to3.py diff --git a/Src/StdLib/Lib/test/test_linecache.py b/StdLib/Lib/test/test_linecache.py similarity index 100% rename from Src/StdLib/Lib/test/test_linecache.py rename to StdLib/Lib/test/test_linecache.py diff --git a/Src/StdLib/Lib/test/test_list.py b/StdLib/Lib/test/test_list.py similarity index 100% rename from Src/StdLib/Lib/test/test_list.py rename to StdLib/Lib/test/test_list.py diff --git a/Src/StdLib/Lib/test/test_listcomps.py b/StdLib/Lib/test/test_listcomps.py similarity index 100% rename from Src/StdLib/Lib/test/test_listcomps.py rename to StdLib/Lib/test/test_listcomps.py diff --git a/Src/StdLib/Lib/test/test_locale.py b/StdLib/Lib/test/test_locale.py similarity index 100% rename from Src/StdLib/Lib/test/test_locale.py rename to StdLib/Lib/test/test_locale.py diff --git a/Src/StdLib/Lib/test/test_logging.py b/StdLib/Lib/test/test_logging.py similarity index 100% rename from Src/StdLib/Lib/test/test_logging.py rename to StdLib/Lib/test/test_logging.py diff --git a/Src/StdLib/Lib/test/test_long.py b/StdLib/Lib/test/test_long.py similarity index 100% rename from Src/StdLib/Lib/test/test_long.py rename to StdLib/Lib/test/test_long.py diff --git a/Src/StdLib/Lib/test/test_longexp.py b/StdLib/Lib/test/test_longexp.py similarity index 100% rename from Src/StdLib/Lib/test/test_longexp.py rename to StdLib/Lib/test/test_longexp.py diff --git a/Src/StdLib/Lib/test/test_lzma.py b/StdLib/Lib/test/test_lzma.py similarity index 100% rename from Src/StdLib/Lib/test/test_lzma.py rename to StdLib/Lib/test/test_lzma.py diff --git a/Src/StdLib/Lib/test/test_macpath.py b/StdLib/Lib/test/test_macpath.py similarity index 100% rename from Src/StdLib/Lib/test/test_macpath.py rename to StdLib/Lib/test/test_macpath.py diff --git a/Src/StdLib/Lib/test/test_macurl2path.py b/StdLib/Lib/test/test_macurl2path.py similarity index 100% rename from Src/StdLib/Lib/test/test_macurl2path.py rename to StdLib/Lib/test/test_macurl2path.py diff --git a/Src/StdLib/Lib/test/test_mailbox.py b/StdLib/Lib/test/test_mailbox.py similarity index 100% rename from Src/StdLib/Lib/test/test_mailbox.py rename to StdLib/Lib/test/test_mailbox.py diff --git a/Src/StdLib/Lib/test/test_mailcap.py b/StdLib/Lib/test/test_mailcap.py similarity index 100% rename from Src/StdLib/Lib/test/test_mailcap.py rename to StdLib/Lib/test/test_mailcap.py diff --git a/Src/StdLib/Lib/test/test_marshal.py b/StdLib/Lib/test/test_marshal.py similarity index 100% rename from Src/StdLib/Lib/test/test_marshal.py rename to StdLib/Lib/test/test_marshal.py diff --git a/Src/StdLib/Lib/test/test_math.py b/StdLib/Lib/test/test_math.py similarity index 100% rename from Src/StdLib/Lib/test/test_math.py rename to StdLib/Lib/test/test_math.py diff --git a/Src/StdLib/Lib/test/test_memoryio.py b/StdLib/Lib/test/test_memoryio.py similarity index 100% rename from Src/StdLib/Lib/test/test_memoryio.py rename to StdLib/Lib/test/test_memoryio.py diff --git a/Src/StdLib/Lib/test/test_memoryview.py b/StdLib/Lib/test/test_memoryview.py similarity index 100% rename from Src/StdLib/Lib/test/test_memoryview.py rename to StdLib/Lib/test/test_memoryview.py diff --git a/Src/StdLib/Lib/test/test_metaclass.py b/StdLib/Lib/test/test_metaclass.py similarity index 100% rename from Src/StdLib/Lib/test/test_metaclass.py rename to StdLib/Lib/test/test_metaclass.py diff --git a/Src/StdLib/Lib/test/test_mimetypes.py b/StdLib/Lib/test/test_mimetypes.py similarity index 100% rename from Src/StdLib/Lib/test/test_mimetypes.py rename to StdLib/Lib/test/test_mimetypes.py diff --git a/Src/StdLib/Lib/test/test_minidom.py b/StdLib/Lib/test/test_minidom.py similarity index 100% rename from Src/StdLib/Lib/test/test_minidom.py rename to StdLib/Lib/test/test_minidom.py diff --git a/Src/StdLib/Lib/test/test_mmap.py b/StdLib/Lib/test/test_mmap.py similarity index 100% rename from Src/StdLib/Lib/test/test_mmap.py rename to StdLib/Lib/test/test_mmap.py diff --git a/Src/StdLib/Lib/test/test_module.py b/StdLib/Lib/test/test_module.py similarity index 100% rename from Src/StdLib/Lib/test/test_module.py rename to StdLib/Lib/test/test_module.py diff --git a/Src/StdLib/Lib/test/test_modulefinder.py b/StdLib/Lib/test/test_modulefinder.py similarity index 100% rename from Src/StdLib/Lib/test/test_modulefinder.py rename to StdLib/Lib/test/test_modulefinder.py diff --git a/Src/StdLib/Lib/test/test_msilib.py b/StdLib/Lib/test/test_msilib.py similarity index 100% rename from Src/StdLib/Lib/test/test_msilib.py rename to StdLib/Lib/test/test_msilib.py diff --git a/Src/StdLib/Lib/test/test_multibytecodec.py b/StdLib/Lib/test/test_multibytecodec.py similarity index 100% rename from Src/StdLib/Lib/test/test_multibytecodec.py rename to StdLib/Lib/test/test_multibytecodec.py diff --git a/Src/StdLib/Lib/test/test_multiprocessing_fork.py b/StdLib/Lib/test/test_multiprocessing_fork.py similarity index 100% rename from Src/StdLib/Lib/test/test_multiprocessing_fork.py rename to StdLib/Lib/test/test_multiprocessing_fork.py diff --git a/Src/StdLib/Lib/test/test_multiprocessing_forkserver.py b/StdLib/Lib/test/test_multiprocessing_forkserver.py similarity index 100% rename from Src/StdLib/Lib/test/test_multiprocessing_forkserver.py rename to StdLib/Lib/test/test_multiprocessing_forkserver.py diff --git a/Src/StdLib/Lib/test/test_multiprocessing_main_handling.py b/StdLib/Lib/test/test_multiprocessing_main_handling.py similarity index 100% rename from Src/StdLib/Lib/test/test_multiprocessing_main_handling.py rename to StdLib/Lib/test/test_multiprocessing_main_handling.py diff --git a/Src/StdLib/Lib/test/test_multiprocessing_spawn.py b/StdLib/Lib/test/test_multiprocessing_spawn.py similarity index 100% rename from Src/StdLib/Lib/test/test_multiprocessing_spawn.py rename to StdLib/Lib/test/test_multiprocessing_spawn.py diff --git a/Src/StdLib/Lib/test/test_netrc.py b/StdLib/Lib/test/test_netrc.py similarity index 100% rename from Src/StdLib/Lib/test/test_netrc.py rename to StdLib/Lib/test/test_netrc.py diff --git a/Src/StdLib/Lib/test/test_nis.py b/StdLib/Lib/test/test_nis.py similarity index 100% rename from Src/StdLib/Lib/test/test_nis.py rename to StdLib/Lib/test/test_nis.py diff --git a/Src/StdLib/Lib/test/test_nntplib.py b/StdLib/Lib/test/test_nntplib.py similarity index 100% rename from Src/StdLib/Lib/test/test_nntplib.py rename to StdLib/Lib/test/test_nntplib.py diff --git a/Src/StdLib/Lib/test/test_normalization.py b/StdLib/Lib/test/test_normalization.py similarity index 100% rename from Src/StdLib/Lib/test/test_normalization.py rename to StdLib/Lib/test/test_normalization.py diff --git a/Src/StdLib/Lib/test/test_ntpath.py b/StdLib/Lib/test/test_ntpath.py similarity index 100% rename from Src/StdLib/Lib/test/test_ntpath.py rename to StdLib/Lib/test/test_ntpath.py diff --git a/Src/StdLib/Lib/test/test_numeric_tower.py b/StdLib/Lib/test/test_numeric_tower.py similarity index 100% rename from Src/StdLib/Lib/test/test_numeric_tower.py rename to StdLib/Lib/test/test_numeric_tower.py diff --git a/Src/StdLib/Lib/test/test_opcodes.py b/StdLib/Lib/test/test_opcodes.py similarity index 100% rename from Src/StdLib/Lib/test/test_opcodes.py rename to StdLib/Lib/test/test_opcodes.py diff --git a/Src/StdLib/Lib/test/test_openpty.py b/StdLib/Lib/test/test_openpty.py similarity index 100% rename from Src/StdLib/Lib/test/test_openpty.py rename to StdLib/Lib/test/test_openpty.py diff --git a/Src/StdLib/Lib/test/test_operator.py b/StdLib/Lib/test/test_operator.py similarity index 100% rename from Src/StdLib/Lib/test/test_operator.py rename to StdLib/Lib/test/test_operator.py diff --git a/Src/StdLib/Lib/test/test_optparse.py b/StdLib/Lib/test/test_optparse.py similarity index 100% rename from Src/StdLib/Lib/test/test_optparse.py rename to StdLib/Lib/test/test_optparse.py diff --git a/Src/StdLib/Lib/test/test_ordered_dict.py b/StdLib/Lib/test/test_ordered_dict.py similarity index 100% rename from Src/StdLib/Lib/test/test_ordered_dict.py rename to StdLib/Lib/test/test_ordered_dict.py diff --git a/Src/StdLib/Lib/test/test_os.py b/StdLib/Lib/test/test_os.py similarity index 100% rename from Src/StdLib/Lib/test/test_os.py rename to StdLib/Lib/test/test_os.py diff --git a/Src/StdLib/Lib/test/test_ossaudiodev.py b/StdLib/Lib/test/test_ossaudiodev.py similarity index 100% rename from Src/StdLib/Lib/test/test_ossaudiodev.py rename to StdLib/Lib/test/test_ossaudiodev.py diff --git a/Src/StdLib/Lib/test/test_osx_env.py b/StdLib/Lib/test/test_osx_env.py similarity index 100% rename from Src/StdLib/Lib/test/test_osx_env.py rename to StdLib/Lib/test/test_osx_env.py diff --git a/Src/StdLib/Lib/test/test_parser.py b/StdLib/Lib/test/test_parser.py similarity index 100% rename from Src/StdLib/Lib/test/test_parser.py rename to StdLib/Lib/test/test_parser.py diff --git a/Src/StdLib/Lib/test/test_pathlib.py b/StdLib/Lib/test/test_pathlib.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/test/test_pathlib.py rename to StdLib/Lib/test/test_pathlib.py diff --git a/Src/StdLib/Lib/test/test_pdb.py b/StdLib/Lib/test/test_pdb.py similarity index 100% rename from Src/StdLib/Lib/test/test_pdb.py rename to StdLib/Lib/test/test_pdb.py diff --git a/Src/StdLib/Lib/test/test_peepholer.py b/StdLib/Lib/test/test_peepholer.py similarity index 100% rename from Src/StdLib/Lib/test/test_peepholer.py rename to StdLib/Lib/test/test_peepholer.py diff --git a/Src/StdLib/Lib/test/test_pep247.py b/StdLib/Lib/test/test_pep247.py similarity index 100% rename from Src/StdLib/Lib/test/test_pep247.py rename to StdLib/Lib/test/test_pep247.py diff --git a/Src/StdLib/Lib/test/test_pep277.py b/StdLib/Lib/test/test_pep277.py similarity index 100% rename from Src/StdLib/Lib/test/test_pep277.py rename to StdLib/Lib/test/test_pep277.py diff --git a/Src/StdLib/Lib/test/test_pep292.py b/StdLib/Lib/test/test_pep292.py similarity index 100% rename from Src/StdLib/Lib/test/test_pep292.py rename to StdLib/Lib/test/test_pep292.py diff --git a/Src/StdLib/Lib/test/test_pep3120.py b/StdLib/Lib/test/test_pep3120.py similarity index 100% rename from Src/StdLib/Lib/test/test_pep3120.py rename to StdLib/Lib/test/test_pep3120.py diff --git a/Src/StdLib/Lib/test/test_pep3131.py b/StdLib/Lib/test/test_pep3131.py similarity index 100% rename from Src/StdLib/Lib/test/test_pep3131.py rename to StdLib/Lib/test/test_pep3131.py diff --git a/Src/StdLib/Lib/test/test_pep3151.py b/StdLib/Lib/test/test_pep3151.py similarity index 100% rename from Src/StdLib/Lib/test/test_pep3151.py rename to StdLib/Lib/test/test_pep3151.py diff --git a/Src/StdLib/Lib/test/test_pep352.py b/StdLib/Lib/test/test_pep352.py similarity index 100% rename from Src/StdLib/Lib/test/test_pep352.py rename to StdLib/Lib/test/test_pep352.py diff --git a/Src/StdLib/Lib/test/test_pep380.py b/StdLib/Lib/test/test_pep380.py similarity index 100% rename from Src/StdLib/Lib/test/test_pep380.py rename to StdLib/Lib/test/test_pep380.py diff --git a/Src/StdLib/Lib/test/test_pep479.py b/StdLib/Lib/test/test_pep479.py similarity index 100% rename from Src/StdLib/Lib/test/test_pep479.py rename to StdLib/Lib/test/test_pep479.py diff --git a/Src/StdLib/Lib/test/test_pickle.py b/StdLib/Lib/test/test_pickle.py similarity index 100% rename from Src/StdLib/Lib/test/test_pickle.py rename to StdLib/Lib/test/test_pickle.py diff --git a/Src/StdLib/Lib/test/test_pickletools.py b/StdLib/Lib/test/test_pickletools.py similarity index 100% rename from Src/StdLib/Lib/test/test_pickletools.py rename to StdLib/Lib/test/test_pickletools.py diff --git a/Src/StdLib/Lib/test/test_pipes.py b/StdLib/Lib/test/test_pipes.py similarity index 100% rename from Src/StdLib/Lib/test/test_pipes.py rename to StdLib/Lib/test/test_pipes.py diff --git a/Src/StdLib/Lib/test/test_pkg.py b/StdLib/Lib/test/test_pkg.py similarity index 100% rename from Src/StdLib/Lib/test/test_pkg.py rename to StdLib/Lib/test/test_pkg.py diff --git a/Src/StdLib/Lib/test/test_pkgimport.py b/StdLib/Lib/test/test_pkgimport.py similarity index 100% rename from Src/StdLib/Lib/test/test_pkgimport.py rename to StdLib/Lib/test/test_pkgimport.py diff --git a/Src/StdLib/Lib/test/test_pkgutil.py b/StdLib/Lib/test/test_pkgutil.py similarity index 100% rename from Src/StdLib/Lib/test/test_pkgutil.py rename to StdLib/Lib/test/test_pkgutil.py diff --git a/Src/StdLib/Lib/test/test_platform.py b/StdLib/Lib/test/test_platform.py similarity index 100% rename from Src/StdLib/Lib/test/test_platform.py rename to StdLib/Lib/test/test_platform.py diff --git a/Src/StdLib/Lib/test/test_plistlib.py b/StdLib/Lib/test/test_plistlib.py similarity index 100% rename from Src/StdLib/Lib/test/test_plistlib.py rename to StdLib/Lib/test/test_plistlib.py diff --git a/Src/StdLib/Lib/test/test_poll.py b/StdLib/Lib/test/test_poll.py similarity index 100% rename from Src/StdLib/Lib/test/test_poll.py rename to StdLib/Lib/test/test_poll.py diff --git a/Src/StdLib/Lib/test/test_popen.py b/StdLib/Lib/test/test_popen.py similarity index 100% rename from Src/StdLib/Lib/test/test_popen.py rename to StdLib/Lib/test/test_popen.py diff --git a/Src/StdLib/Lib/test/test_poplib.py b/StdLib/Lib/test/test_poplib.py similarity index 100% rename from Src/StdLib/Lib/test/test_poplib.py rename to StdLib/Lib/test/test_poplib.py diff --git a/Src/StdLib/Lib/test/test_posix.py b/StdLib/Lib/test/test_posix.py similarity index 100% rename from Src/StdLib/Lib/test/test_posix.py rename to StdLib/Lib/test/test_posix.py diff --git a/Src/StdLib/Lib/test/test_posixpath.py b/StdLib/Lib/test/test_posixpath.py similarity index 100% rename from Src/StdLib/Lib/test/test_posixpath.py rename to StdLib/Lib/test/test_posixpath.py diff --git a/Src/StdLib/Lib/test/test_pow.py b/StdLib/Lib/test/test_pow.py similarity index 100% rename from Src/StdLib/Lib/test/test_pow.py rename to StdLib/Lib/test/test_pow.py diff --git a/Src/StdLib/Lib/test/test_pprint.py b/StdLib/Lib/test/test_pprint.py similarity index 100% rename from Src/StdLib/Lib/test/test_pprint.py rename to StdLib/Lib/test/test_pprint.py diff --git a/Src/StdLib/Lib/test/test_print.py b/StdLib/Lib/test/test_print.py similarity index 100% rename from Src/StdLib/Lib/test/test_print.py rename to StdLib/Lib/test/test_print.py diff --git a/Src/StdLib/Lib/test/test_profile.py b/StdLib/Lib/test/test_profile.py similarity index 100% rename from Src/StdLib/Lib/test/test_profile.py rename to StdLib/Lib/test/test_profile.py diff --git a/Src/StdLib/Lib/test/test_property.py b/StdLib/Lib/test/test_property.py similarity index 100% rename from Src/StdLib/Lib/test/test_property.py rename to StdLib/Lib/test/test_property.py diff --git a/Src/StdLib/Lib/test/test_pstats.py b/StdLib/Lib/test/test_pstats.py similarity index 100% rename from Src/StdLib/Lib/test/test_pstats.py rename to StdLib/Lib/test/test_pstats.py diff --git a/Src/StdLib/Lib/test/test_pty.py b/StdLib/Lib/test/test_pty.py similarity index 100% rename from Src/StdLib/Lib/test/test_pty.py rename to StdLib/Lib/test/test_pty.py diff --git a/Src/StdLib/Lib/test/test_pulldom.py b/StdLib/Lib/test/test_pulldom.py similarity index 100% rename from Src/StdLib/Lib/test/test_pulldom.py rename to StdLib/Lib/test/test_pulldom.py diff --git a/Src/StdLib/Lib/test/test_pwd.py b/StdLib/Lib/test/test_pwd.py similarity index 100% rename from Src/StdLib/Lib/test/test_pwd.py rename to StdLib/Lib/test/test_pwd.py diff --git a/Src/StdLib/Lib/test/test_py_compile.py b/StdLib/Lib/test/test_py_compile.py similarity index 100% rename from Src/StdLib/Lib/test/test_py_compile.py rename to StdLib/Lib/test/test_py_compile.py diff --git a/Src/StdLib/Lib/test/test_pyclbr.py b/StdLib/Lib/test/test_pyclbr.py similarity index 100% rename from Src/StdLib/Lib/test/test_pyclbr.py rename to StdLib/Lib/test/test_pyclbr.py diff --git a/Src/StdLib/Lib/test/test_pydoc.py b/StdLib/Lib/test/test_pydoc.py similarity index 100% rename from Src/StdLib/Lib/test/test_pydoc.py rename to StdLib/Lib/test/test_pydoc.py diff --git a/Src/StdLib/Lib/test/test_pyexpat.py b/StdLib/Lib/test/test_pyexpat.py similarity index 100% rename from Src/StdLib/Lib/test/test_pyexpat.py rename to StdLib/Lib/test/test_pyexpat.py diff --git a/Src/StdLib/Lib/test/test_queue.py b/StdLib/Lib/test/test_queue.py similarity index 100% rename from Src/StdLib/Lib/test/test_queue.py rename to StdLib/Lib/test/test_queue.py diff --git a/Src/StdLib/Lib/test/test_quopri.py b/StdLib/Lib/test/test_quopri.py similarity index 100% rename from Src/StdLib/Lib/test/test_quopri.py rename to StdLib/Lib/test/test_quopri.py diff --git a/Src/StdLib/Lib/test/test_raise.py b/StdLib/Lib/test/test_raise.py similarity index 100% rename from Src/StdLib/Lib/test/test_raise.py rename to StdLib/Lib/test/test_raise.py diff --git a/Src/StdLib/Lib/test/test_random.py b/StdLib/Lib/test/test_random.py similarity index 100% rename from Src/StdLib/Lib/test/test_random.py rename to StdLib/Lib/test/test_random.py diff --git a/Src/StdLib/Lib/test/test_range.py b/StdLib/Lib/test/test_range.py similarity index 100% rename from Src/StdLib/Lib/test/test_range.py rename to StdLib/Lib/test/test_range.py diff --git a/Src/StdLib/Lib/test/test_re.py b/StdLib/Lib/test/test_re.py similarity index 100% rename from Src/StdLib/Lib/test/test_re.py rename to StdLib/Lib/test/test_re.py diff --git a/Src/StdLib/Lib/test/test_readline.py b/StdLib/Lib/test/test_readline.py similarity index 100% rename from Src/StdLib/Lib/test/test_readline.py rename to StdLib/Lib/test/test_readline.py diff --git a/Src/StdLib/Lib/test/test_regrtest.py b/StdLib/Lib/test/test_regrtest.py similarity index 100% rename from Src/StdLib/Lib/test/test_regrtest.py rename to StdLib/Lib/test/test_regrtest.py diff --git a/Src/StdLib/Lib/test/test_reprlib.py b/StdLib/Lib/test/test_reprlib.py similarity index 100% rename from Src/StdLib/Lib/test/test_reprlib.py rename to StdLib/Lib/test/test_reprlib.py diff --git a/Src/StdLib/Lib/test/test_resource.py b/StdLib/Lib/test/test_resource.py similarity index 100% rename from Src/StdLib/Lib/test/test_resource.py rename to StdLib/Lib/test/test_resource.py diff --git a/Src/StdLib/Lib/test/test_richcmp.py b/StdLib/Lib/test/test_richcmp.py similarity index 100% rename from Src/StdLib/Lib/test/test_richcmp.py rename to StdLib/Lib/test/test_richcmp.py diff --git a/Src/StdLib/Lib/test/test_rlcompleter.py b/StdLib/Lib/test/test_rlcompleter.py similarity index 100% rename from Src/StdLib/Lib/test/test_rlcompleter.py rename to StdLib/Lib/test/test_rlcompleter.py diff --git a/Src/StdLib/Lib/test/test_robotparser.py b/StdLib/Lib/test/test_robotparser.py similarity index 100% rename from Src/StdLib/Lib/test/test_robotparser.py rename to StdLib/Lib/test/test_robotparser.py diff --git a/Src/StdLib/Lib/test/test_runpy.py b/StdLib/Lib/test/test_runpy.py similarity index 100% rename from Src/StdLib/Lib/test/test_runpy.py rename to StdLib/Lib/test/test_runpy.py diff --git a/Src/StdLib/Lib/test/test_sax.py b/StdLib/Lib/test/test_sax.py similarity index 100% rename from Src/StdLib/Lib/test/test_sax.py rename to StdLib/Lib/test/test_sax.py diff --git a/Src/StdLib/Lib/test/test_sched.py b/StdLib/Lib/test/test_sched.py similarity index 100% rename from Src/StdLib/Lib/test/test_sched.py rename to StdLib/Lib/test/test_sched.py diff --git a/Src/StdLib/Lib/test/test_scope.py b/StdLib/Lib/test/test_scope.py similarity index 100% rename from Src/StdLib/Lib/test/test_scope.py rename to StdLib/Lib/test/test_scope.py diff --git a/Src/StdLib/Lib/test/test_script_helper.py b/StdLib/Lib/test/test_script_helper.py similarity index 100% rename from Src/StdLib/Lib/test/test_script_helper.py rename to StdLib/Lib/test/test_script_helper.py diff --git a/Src/StdLib/Lib/test/test_select.py b/StdLib/Lib/test/test_select.py similarity index 100% rename from Src/StdLib/Lib/test/test_select.py rename to StdLib/Lib/test/test_select.py diff --git a/Src/StdLib/Lib/test/test_selectors.py b/StdLib/Lib/test/test_selectors.py similarity index 100% rename from Src/StdLib/Lib/test/test_selectors.py rename to StdLib/Lib/test/test_selectors.py diff --git a/Src/StdLib/Lib/test/test_set.py b/StdLib/Lib/test/test_set.py similarity index 100% rename from Src/StdLib/Lib/test/test_set.py rename to StdLib/Lib/test/test_set.py diff --git a/Src/StdLib/Lib/test/test_setcomps.py b/StdLib/Lib/test/test_setcomps.py similarity index 100% rename from Src/StdLib/Lib/test/test_setcomps.py rename to StdLib/Lib/test/test_setcomps.py diff --git a/Src/StdLib/Lib/test/test_shelve.py b/StdLib/Lib/test/test_shelve.py similarity index 100% rename from Src/StdLib/Lib/test/test_shelve.py rename to StdLib/Lib/test/test_shelve.py diff --git a/Src/StdLib/Lib/test/test_shlex.py b/StdLib/Lib/test/test_shlex.py similarity index 100% rename from Src/StdLib/Lib/test/test_shlex.py rename to StdLib/Lib/test/test_shlex.py diff --git a/Src/StdLib/Lib/test/test_shutil.py b/StdLib/Lib/test/test_shutil.py similarity index 100% rename from Src/StdLib/Lib/test/test_shutil.py rename to StdLib/Lib/test/test_shutil.py diff --git a/Src/StdLib/Lib/test/test_signal.py b/StdLib/Lib/test/test_signal.py similarity index 100% rename from Src/StdLib/Lib/test/test_signal.py rename to StdLib/Lib/test/test_signal.py diff --git a/Src/StdLib/Lib/test/test_site.py b/StdLib/Lib/test/test_site.py similarity index 100% rename from Src/StdLib/Lib/test/test_site.py rename to StdLib/Lib/test/test_site.py diff --git a/Src/StdLib/Lib/test/test_slice.py b/StdLib/Lib/test/test_slice.py similarity index 100% rename from Src/StdLib/Lib/test/test_slice.py rename to StdLib/Lib/test/test_slice.py diff --git a/Src/StdLib/Lib/test/test_smtpd.py b/StdLib/Lib/test/test_smtpd.py similarity index 100% rename from Src/StdLib/Lib/test/test_smtpd.py rename to StdLib/Lib/test/test_smtpd.py diff --git a/Src/StdLib/Lib/test/test_smtplib.py b/StdLib/Lib/test/test_smtplib.py similarity index 100% rename from Src/StdLib/Lib/test/test_smtplib.py rename to StdLib/Lib/test/test_smtplib.py diff --git a/Src/StdLib/Lib/test/test_smtpnet.py b/StdLib/Lib/test/test_smtpnet.py similarity index 100% rename from Src/StdLib/Lib/test/test_smtpnet.py rename to StdLib/Lib/test/test_smtpnet.py diff --git a/Src/StdLib/Lib/test/test_sndhdr.py b/StdLib/Lib/test/test_sndhdr.py similarity index 100% rename from Src/StdLib/Lib/test/test_sndhdr.py rename to StdLib/Lib/test/test_sndhdr.py diff --git a/Src/StdLib/Lib/test/test_socket.py b/StdLib/Lib/test/test_socket.py similarity index 100% rename from Src/StdLib/Lib/test/test_socket.py rename to StdLib/Lib/test/test_socket.py diff --git a/Src/StdLib/Lib/test/test_socketserver.py b/StdLib/Lib/test/test_socketserver.py similarity index 100% rename from Src/StdLib/Lib/test/test_socketserver.py rename to StdLib/Lib/test/test_socketserver.py diff --git a/Src/StdLib/Lib/test/test_sort.py b/StdLib/Lib/test/test_sort.py similarity index 100% rename from Src/StdLib/Lib/test/test_sort.py rename to StdLib/Lib/test/test_sort.py diff --git a/Src/StdLib/Lib/test/test_source_encoding.py b/StdLib/Lib/test/test_source_encoding.py similarity index 100% rename from Src/StdLib/Lib/test/test_source_encoding.py rename to StdLib/Lib/test/test_source_encoding.py diff --git a/Src/StdLib/Lib/test/test_spwd.py b/StdLib/Lib/test/test_spwd.py similarity index 100% rename from Src/StdLib/Lib/test/test_spwd.py rename to StdLib/Lib/test/test_spwd.py diff --git a/Src/StdLib/Lib/test/test_sqlite.py b/StdLib/Lib/test/test_sqlite.py similarity index 100% rename from Src/StdLib/Lib/test/test_sqlite.py rename to StdLib/Lib/test/test_sqlite.py diff --git a/Src/StdLib/Lib/test/test_ssl.py b/StdLib/Lib/test/test_ssl.py similarity index 100% rename from Src/StdLib/Lib/test/test_ssl.py rename to StdLib/Lib/test/test_ssl.py diff --git a/Src/StdLib/Lib/test/test_startfile.py b/StdLib/Lib/test/test_startfile.py similarity index 100% rename from Src/StdLib/Lib/test/test_startfile.py rename to StdLib/Lib/test/test_startfile.py diff --git a/Src/StdLib/Lib/test/test_stat.py b/StdLib/Lib/test/test_stat.py similarity index 100% rename from Src/StdLib/Lib/test/test_stat.py rename to StdLib/Lib/test/test_stat.py diff --git a/Src/StdLib/Lib/test/test_statistics.py b/StdLib/Lib/test/test_statistics.py similarity index 100% rename from Src/StdLib/Lib/test/test_statistics.py rename to StdLib/Lib/test/test_statistics.py diff --git a/Src/StdLib/Lib/test/test_strftime.py b/StdLib/Lib/test/test_strftime.py similarity index 100% rename from Src/StdLib/Lib/test/test_strftime.py rename to StdLib/Lib/test/test_strftime.py diff --git a/Src/StdLib/Lib/test/test_string.py b/StdLib/Lib/test/test_string.py similarity index 100% rename from Src/StdLib/Lib/test/test_string.py rename to StdLib/Lib/test/test_string.py diff --git a/Src/StdLib/Lib/test/test_stringprep.py b/StdLib/Lib/test/test_stringprep.py similarity index 100% rename from Src/StdLib/Lib/test/test_stringprep.py rename to StdLib/Lib/test/test_stringprep.py diff --git a/Src/StdLib/Lib/test/test_strlit.py b/StdLib/Lib/test/test_strlit.py similarity index 100% rename from Src/StdLib/Lib/test/test_strlit.py rename to StdLib/Lib/test/test_strlit.py diff --git a/Src/StdLib/Lib/test/test_strptime.py b/StdLib/Lib/test/test_strptime.py similarity index 100% rename from Src/StdLib/Lib/test/test_strptime.py rename to StdLib/Lib/test/test_strptime.py diff --git a/Src/StdLib/Lib/test/test_strtod.py b/StdLib/Lib/test/test_strtod.py similarity index 100% rename from Src/StdLib/Lib/test/test_strtod.py rename to StdLib/Lib/test/test_strtod.py diff --git a/Src/StdLib/Lib/test/test_struct.py b/StdLib/Lib/test/test_struct.py similarity index 100% rename from Src/StdLib/Lib/test/test_struct.py rename to StdLib/Lib/test/test_struct.py diff --git a/Src/StdLib/Lib/test/test_structmembers.py b/StdLib/Lib/test/test_structmembers.py similarity index 100% rename from Src/StdLib/Lib/test/test_structmembers.py rename to StdLib/Lib/test/test_structmembers.py diff --git a/Src/StdLib/Lib/test/test_structseq.py b/StdLib/Lib/test/test_structseq.py similarity index 100% rename from Src/StdLib/Lib/test/test_structseq.py rename to StdLib/Lib/test/test_structseq.py diff --git a/Src/StdLib/Lib/test/test_subprocess.py b/StdLib/Lib/test/test_subprocess.py similarity index 100% rename from Src/StdLib/Lib/test/test_subprocess.py rename to StdLib/Lib/test/test_subprocess.py diff --git a/Src/StdLib/Lib/test/test_sunau.py b/StdLib/Lib/test/test_sunau.py similarity index 100% rename from Src/StdLib/Lib/test/test_sunau.py rename to StdLib/Lib/test/test_sunau.py diff --git a/Src/StdLib/Lib/test/test_sundry.py b/StdLib/Lib/test/test_sundry.py similarity index 100% rename from Src/StdLib/Lib/test/test_sundry.py rename to StdLib/Lib/test/test_sundry.py diff --git a/Src/StdLib/Lib/test/test_super.py b/StdLib/Lib/test/test_super.py similarity index 100% rename from Src/StdLib/Lib/test/test_super.py rename to StdLib/Lib/test/test_super.py diff --git a/Src/StdLib/Lib/test/test_support.py b/StdLib/Lib/test/test_support.py similarity index 100% rename from Src/StdLib/Lib/test/test_support.py rename to StdLib/Lib/test/test_support.py diff --git a/Src/StdLib/Lib/test/test_symtable.py b/StdLib/Lib/test/test_symtable.py similarity index 100% rename from Src/StdLib/Lib/test/test_symtable.py rename to StdLib/Lib/test/test_symtable.py diff --git a/Src/StdLib/Lib/test/test_syntax.py b/StdLib/Lib/test/test_syntax.py similarity index 100% rename from Src/StdLib/Lib/test/test_syntax.py rename to StdLib/Lib/test/test_syntax.py diff --git a/Src/StdLib/Lib/test/test_sys.py b/StdLib/Lib/test/test_sys.py similarity index 100% rename from Src/StdLib/Lib/test/test_sys.py rename to StdLib/Lib/test/test_sys.py diff --git a/Src/StdLib/Lib/test/test_sys_setprofile.py b/StdLib/Lib/test/test_sys_setprofile.py similarity index 100% rename from Src/StdLib/Lib/test/test_sys_setprofile.py rename to StdLib/Lib/test/test_sys_setprofile.py diff --git a/Src/StdLib/Lib/test/test_sys_settrace.py b/StdLib/Lib/test/test_sys_settrace.py similarity index 100% rename from Src/StdLib/Lib/test/test_sys_settrace.py rename to StdLib/Lib/test/test_sys_settrace.py diff --git a/Src/StdLib/Lib/test/test_sysconfig.py b/StdLib/Lib/test/test_sysconfig.py similarity index 100% rename from Src/StdLib/Lib/test/test_sysconfig.py rename to StdLib/Lib/test/test_sysconfig.py diff --git a/Src/StdLib/Lib/test/test_syslog.py b/StdLib/Lib/test/test_syslog.py similarity index 100% rename from Src/StdLib/Lib/test/test_syslog.py rename to StdLib/Lib/test/test_syslog.py diff --git a/Src/StdLib/Lib/test/test_tarfile.py b/StdLib/Lib/test/test_tarfile.py similarity index 100% rename from Src/StdLib/Lib/test/test_tarfile.py rename to StdLib/Lib/test/test_tarfile.py diff --git a/Src/StdLib/Lib/test/test_tcl.py b/StdLib/Lib/test/test_tcl.py similarity index 100% rename from Src/StdLib/Lib/test/test_tcl.py rename to StdLib/Lib/test/test_tcl.py diff --git a/Src/StdLib/Lib/test/test_telnetlib.py b/StdLib/Lib/test/test_telnetlib.py similarity index 100% rename from Src/StdLib/Lib/test/test_telnetlib.py rename to StdLib/Lib/test/test_telnetlib.py diff --git a/Src/StdLib/Lib/test/test_tempfile.py b/StdLib/Lib/test/test_tempfile.py similarity index 100% rename from Src/StdLib/Lib/test/test_tempfile.py rename to StdLib/Lib/test/test_tempfile.py diff --git a/Src/StdLib/Lib/test/test_textwrap.py b/StdLib/Lib/test/test_textwrap.py similarity index 100% rename from Src/StdLib/Lib/test/test_textwrap.py rename to StdLib/Lib/test/test_textwrap.py diff --git a/Src/StdLib/Lib/test/test_thread.py b/StdLib/Lib/test/test_thread.py similarity index 100% rename from Src/StdLib/Lib/test/test_thread.py rename to StdLib/Lib/test/test_thread.py diff --git a/Src/StdLib/Lib/test/test_threaded_import.py b/StdLib/Lib/test/test_threaded_import.py similarity index 100% rename from Src/StdLib/Lib/test/test_threaded_import.py rename to StdLib/Lib/test/test_threaded_import.py diff --git a/Src/StdLib/Lib/test/test_threadedtempfile.py b/StdLib/Lib/test/test_threadedtempfile.py similarity index 100% rename from Src/StdLib/Lib/test/test_threadedtempfile.py rename to StdLib/Lib/test/test_threadedtempfile.py diff --git a/Src/StdLib/Lib/test/test_threading.py b/StdLib/Lib/test/test_threading.py similarity index 100% rename from Src/StdLib/Lib/test/test_threading.py rename to StdLib/Lib/test/test_threading.py diff --git a/Src/StdLib/Lib/test/test_threading_local.py b/StdLib/Lib/test/test_threading_local.py similarity index 100% rename from Src/StdLib/Lib/test/test_threading_local.py rename to StdLib/Lib/test/test_threading_local.py diff --git a/Src/StdLib/Lib/test/test_threadsignals.py b/StdLib/Lib/test/test_threadsignals.py similarity index 100% rename from Src/StdLib/Lib/test/test_threadsignals.py rename to StdLib/Lib/test/test_threadsignals.py diff --git a/Src/StdLib/Lib/test/test_time.py b/StdLib/Lib/test/test_time.py similarity index 100% rename from Src/StdLib/Lib/test/test_time.py rename to StdLib/Lib/test/test_time.py diff --git a/Src/StdLib/Lib/test/test_timeit.py b/StdLib/Lib/test/test_timeit.py similarity index 100% rename from Src/StdLib/Lib/test/test_timeit.py rename to StdLib/Lib/test/test_timeit.py diff --git a/Src/StdLib/Lib/test/test_timeout.py b/StdLib/Lib/test/test_timeout.py similarity index 100% rename from Src/StdLib/Lib/test/test_timeout.py rename to StdLib/Lib/test/test_timeout.py diff --git a/Src/StdLib/Lib/test/test_tk.py b/StdLib/Lib/test/test_tk.py similarity index 100% rename from Src/StdLib/Lib/test/test_tk.py rename to StdLib/Lib/test/test_tk.py diff --git a/Src/StdLib/Lib/test/test_tokenize.py b/StdLib/Lib/test/test_tokenize.py similarity index 100% rename from Src/StdLib/Lib/test/test_tokenize.py rename to StdLib/Lib/test/test_tokenize.py diff --git a/Src/StdLib/Lib/test/test_tools/__init__.py b/StdLib/Lib/test/test_tools/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_tools/__init__.py rename to StdLib/Lib/test/test_tools/__init__.py diff --git a/Src/StdLib/Lib/test/test_tools/__main__.py b/StdLib/Lib/test/test_tools/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/test_tools/__main__.py rename to StdLib/Lib/test/test_tools/__main__.py diff --git a/Src/StdLib/Lib/test/test_tools/test_gprof2html.py b/StdLib/Lib/test/test_tools/test_gprof2html.py similarity index 100% rename from Src/StdLib/Lib/test/test_tools/test_gprof2html.py rename to StdLib/Lib/test/test_tools/test_gprof2html.py diff --git a/Src/StdLib/Lib/test/test_tools/test_md5sum.py b/StdLib/Lib/test/test_tools/test_md5sum.py similarity index 100% rename from Src/StdLib/Lib/test/test_tools/test_md5sum.py rename to StdLib/Lib/test/test_tools/test_md5sum.py diff --git a/Src/StdLib/Lib/test/test_tools/test_pdeps.py b/StdLib/Lib/test/test_tools/test_pdeps.py similarity index 100% rename from Src/StdLib/Lib/test/test_tools/test_pdeps.py rename to StdLib/Lib/test/test_tools/test_pdeps.py diff --git a/Src/StdLib/Lib/test/test_tools/test_pindent.py b/StdLib/Lib/test/test_tools/test_pindent.py similarity index 100% rename from Src/StdLib/Lib/test/test_tools/test_pindent.py rename to StdLib/Lib/test/test_tools/test_pindent.py diff --git a/Src/StdLib/Lib/test/test_tools/test_reindent.py b/StdLib/Lib/test/test_tools/test_reindent.py similarity index 100% rename from Src/StdLib/Lib/test/test_tools/test_reindent.py rename to StdLib/Lib/test/test_tools/test_reindent.py diff --git a/Src/StdLib/Lib/test/test_tools/test_sundry.py b/StdLib/Lib/test/test_tools/test_sundry.py similarity index 100% rename from Src/StdLib/Lib/test/test_tools/test_sundry.py rename to StdLib/Lib/test/test_tools/test_sundry.py diff --git a/Src/StdLib/Lib/test/test_tools/test_unparse.py b/StdLib/Lib/test/test_tools/test_unparse.py similarity index 100% rename from Src/StdLib/Lib/test/test_tools/test_unparse.py rename to StdLib/Lib/test/test_tools/test_unparse.py diff --git a/Src/StdLib/Lib/test/test_trace.py b/StdLib/Lib/test/test_trace.py similarity index 100% rename from Src/StdLib/Lib/test/test_trace.py rename to StdLib/Lib/test/test_trace.py diff --git a/Src/StdLib/Lib/test/test_traceback.py b/StdLib/Lib/test/test_traceback.py similarity index 100% rename from Src/StdLib/Lib/test/test_traceback.py rename to StdLib/Lib/test/test_traceback.py diff --git a/Src/StdLib/Lib/test/test_tracemalloc.py b/StdLib/Lib/test/test_tracemalloc.py similarity index 100% rename from Src/StdLib/Lib/test/test_tracemalloc.py rename to StdLib/Lib/test/test_tracemalloc.py diff --git a/Src/StdLib/Lib/test/test_ttk_guionly.py b/StdLib/Lib/test/test_ttk_guionly.py similarity index 100% rename from Src/StdLib/Lib/test/test_ttk_guionly.py rename to StdLib/Lib/test/test_ttk_guionly.py diff --git a/Src/StdLib/Lib/test/test_ttk_textonly.py b/StdLib/Lib/test/test_ttk_textonly.py similarity index 100% rename from Src/StdLib/Lib/test/test_ttk_textonly.py rename to StdLib/Lib/test/test_ttk_textonly.py diff --git a/Src/StdLib/Lib/test/test_tuple.py b/StdLib/Lib/test/test_tuple.py similarity index 100% rename from Src/StdLib/Lib/test/test_tuple.py rename to StdLib/Lib/test/test_tuple.py diff --git a/Src/StdLib/Lib/test/test_typechecks.py b/StdLib/Lib/test/test_typechecks.py similarity index 100% rename from Src/StdLib/Lib/test/test_typechecks.py rename to StdLib/Lib/test/test_typechecks.py diff --git a/Src/StdLib/Lib/test/test_types.py b/StdLib/Lib/test/test_types.py similarity index 100% rename from Src/StdLib/Lib/test/test_types.py rename to StdLib/Lib/test/test_types.py diff --git a/Src/StdLib/Lib/test/test_typing.py b/StdLib/Lib/test/test_typing.py similarity index 100% rename from Src/StdLib/Lib/test/test_typing.py rename to StdLib/Lib/test/test_typing.py diff --git a/Src/StdLib/Lib/test/test_ucn.py b/StdLib/Lib/test/test_ucn.py similarity index 100% rename from Src/StdLib/Lib/test/test_ucn.py rename to StdLib/Lib/test/test_ucn.py diff --git a/Src/StdLib/Lib/test/test_unary.py b/StdLib/Lib/test/test_unary.py similarity index 100% rename from Src/StdLib/Lib/test/test_unary.py rename to StdLib/Lib/test/test_unary.py diff --git a/Src/StdLib/Lib/test/test_unicode.py b/StdLib/Lib/test/test_unicode.py similarity index 100% rename from Src/StdLib/Lib/test/test_unicode.py rename to StdLib/Lib/test/test_unicode.py diff --git a/Src/StdLib/Lib/test/test_unicode_file.py b/StdLib/Lib/test/test_unicode_file.py similarity index 100% rename from Src/StdLib/Lib/test/test_unicode_file.py rename to StdLib/Lib/test/test_unicode_file.py diff --git a/Src/StdLib/Lib/test/test_unicodedata.py b/StdLib/Lib/test/test_unicodedata.py similarity index 100% rename from Src/StdLib/Lib/test/test_unicodedata.py rename to StdLib/Lib/test/test_unicodedata.py diff --git a/Src/StdLib/Lib/test/test_unittest.py b/StdLib/Lib/test/test_unittest.py similarity index 100% rename from Src/StdLib/Lib/test/test_unittest.py rename to StdLib/Lib/test/test_unittest.py diff --git a/Src/StdLib/Lib/test/test_univnewlines.py b/StdLib/Lib/test/test_univnewlines.py similarity index 100% rename from Src/StdLib/Lib/test/test_univnewlines.py rename to StdLib/Lib/test/test_univnewlines.py diff --git a/Src/StdLib/Lib/test/test_unpack.py b/StdLib/Lib/test/test_unpack.py similarity index 100% rename from Src/StdLib/Lib/test/test_unpack.py rename to StdLib/Lib/test/test_unpack.py diff --git a/Src/StdLib/Lib/test/test_unpack_ex.py b/StdLib/Lib/test/test_unpack_ex.py similarity index 100% rename from Src/StdLib/Lib/test/test_unpack_ex.py rename to StdLib/Lib/test/test_unpack_ex.py diff --git a/Src/StdLib/Lib/test/test_urllib.py b/StdLib/Lib/test/test_urllib.py similarity index 100% rename from Src/StdLib/Lib/test/test_urllib.py rename to StdLib/Lib/test/test_urllib.py diff --git a/Src/StdLib/Lib/test/test_urllib2.py b/StdLib/Lib/test/test_urllib2.py similarity index 100% rename from Src/StdLib/Lib/test/test_urllib2.py rename to StdLib/Lib/test/test_urllib2.py diff --git a/Src/StdLib/Lib/test/test_urllib2_localnet.py b/StdLib/Lib/test/test_urllib2_localnet.py similarity index 100% rename from Src/StdLib/Lib/test/test_urllib2_localnet.py rename to StdLib/Lib/test/test_urllib2_localnet.py diff --git a/Src/StdLib/Lib/test/test_urllib2net.py b/StdLib/Lib/test/test_urllib2net.py similarity index 100% rename from Src/StdLib/Lib/test/test_urllib2net.py rename to StdLib/Lib/test/test_urllib2net.py diff --git a/Src/StdLib/Lib/test/test_urllib_response.py b/StdLib/Lib/test/test_urllib_response.py similarity index 100% rename from Src/StdLib/Lib/test/test_urllib_response.py rename to StdLib/Lib/test/test_urllib_response.py diff --git a/Src/StdLib/Lib/test/test_urllibnet.py b/StdLib/Lib/test/test_urllibnet.py similarity index 100% rename from Src/StdLib/Lib/test/test_urllibnet.py rename to StdLib/Lib/test/test_urllibnet.py diff --git a/Src/StdLib/Lib/test/test_urlparse.py b/StdLib/Lib/test/test_urlparse.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/test/test_urlparse.py rename to StdLib/Lib/test/test_urlparse.py diff --git a/Src/StdLib/Lib/test/test_userdict.py b/StdLib/Lib/test/test_userdict.py similarity index 100% rename from Src/StdLib/Lib/test/test_userdict.py rename to StdLib/Lib/test/test_userdict.py diff --git a/Src/StdLib/Lib/test/test_userlist.py b/StdLib/Lib/test/test_userlist.py similarity index 100% rename from Src/StdLib/Lib/test/test_userlist.py rename to StdLib/Lib/test/test_userlist.py diff --git a/Src/StdLib/Lib/test/test_userstring.py b/StdLib/Lib/test/test_userstring.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/test/test_userstring.py rename to StdLib/Lib/test/test_userstring.py diff --git a/Src/StdLib/Lib/test/test_utf8_mode.py b/StdLib/Lib/test/test_utf8_mode.py similarity index 100% rename from Src/StdLib/Lib/test/test_utf8_mode.py rename to StdLib/Lib/test/test_utf8_mode.py diff --git a/Src/StdLib/Lib/test/test_uu.py b/StdLib/Lib/test/test_uu.py similarity index 100% rename from Src/StdLib/Lib/test/test_uu.py rename to StdLib/Lib/test/test_uu.py diff --git a/Src/StdLib/Lib/test/test_uuid.py b/StdLib/Lib/test/test_uuid.py similarity index 100% rename from Src/StdLib/Lib/test/test_uuid.py rename to StdLib/Lib/test/test_uuid.py diff --git a/Src/StdLib/Lib/test/test_venv.py b/StdLib/Lib/test/test_venv.py similarity index 100% rename from Src/StdLib/Lib/test/test_venv.py rename to StdLib/Lib/test/test_venv.py diff --git a/Src/StdLib/Lib/test/test_wait3.py b/StdLib/Lib/test/test_wait3.py similarity index 100% rename from Src/StdLib/Lib/test/test_wait3.py rename to StdLib/Lib/test/test_wait3.py diff --git a/Src/StdLib/Lib/test/test_wait4.py b/StdLib/Lib/test/test_wait4.py similarity index 100% rename from Src/StdLib/Lib/test/test_wait4.py rename to StdLib/Lib/test/test_wait4.py diff --git a/Src/StdLib/Lib/test/test_warnings.py b/StdLib/Lib/test/test_warnings.py similarity index 100% rename from Src/StdLib/Lib/test/test_warnings.py rename to StdLib/Lib/test/test_warnings.py diff --git a/Src/StdLib/Lib/test/test_wave.py b/StdLib/Lib/test/test_wave.py similarity index 100% rename from Src/StdLib/Lib/test/test_wave.py rename to StdLib/Lib/test/test_wave.py diff --git a/Src/StdLib/Lib/test/test_weakref.py b/StdLib/Lib/test/test_weakref.py similarity index 100% rename from Src/StdLib/Lib/test/test_weakref.py rename to StdLib/Lib/test/test_weakref.py diff --git a/Src/StdLib/Lib/test/test_weakset.py b/StdLib/Lib/test/test_weakset.py similarity index 100% rename from Src/StdLib/Lib/test/test_weakset.py rename to StdLib/Lib/test/test_weakset.py diff --git a/Src/StdLib/Lib/test/test_webbrowser.py b/StdLib/Lib/test/test_webbrowser.py similarity index 100% rename from Src/StdLib/Lib/test/test_webbrowser.py rename to StdLib/Lib/test/test_webbrowser.py diff --git a/Src/StdLib/Lib/test/test_winreg.py b/StdLib/Lib/test/test_winreg.py similarity index 100% rename from Src/StdLib/Lib/test/test_winreg.py rename to StdLib/Lib/test/test_winreg.py diff --git a/Src/StdLib/Lib/test/test_winsound.py b/StdLib/Lib/test/test_winsound.py similarity index 100% rename from Src/StdLib/Lib/test/test_winsound.py rename to StdLib/Lib/test/test_winsound.py diff --git a/Src/StdLib/Lib/test/test_with.py b/StdLib/Lib/test/test_with.py similarity index 100% rename from Src/StdLib/Lib/test/test_with.py rename to StdLib/Lib/test/test_with.py diff --git a/Src/StdLib/Lib/test/test_wsgiref.py b/StdLib/Lib/test/test_wsgiref.py similarity index 100% rename from Src/StdLib/Lib/test/test_wsgiref.py rename to StdLib/Lib/test/test_wsgiref.py diff --git a/Src/StdLib/Lib/test/test_xdrlib.py b/StdLib/Lib/test/test_xdrlib.py similarity index 100% rename from Src/StdLib/Lib/test/test_xdrlib.py rename to StdLib/Lib/test/test_xdrlib.py diff --git a/Src/StdLib/Lib/test/test_xml_dom_minicompat.py b/StdLib/Lib/test/test_xml_dom_minicompat.py similarity index 100% rename from Src/StdLib/Lib/test/test_xml_dom_minicompat.py rename to StdLib/Lib/test/test_xml_dom_minicompat.py diff --git a/Src/StdLib/Lib/test/test_xml_etree.py b/StdLib/Lib/test/test_xml_etree.py similarity index 100% rename from Src/StdLib/Lib/test/test_xml_etree.py rename to StdLib/Lib/test/test_xml_etree.py diff --git a/Src/StdLib/Lib/test/test_xml_etree_c.py b/StdLib/Lib/test/test_xml_etree_c.py similarity index 100% rename from Src/StdLib/Lib/test/test_xml_etree_c.py rename to StdLib/Lib/test/test_xml_etree_c.py diff --git a/Src/StdLib/Lib/test/test_xmlrpc.py b/StdLib/Lib/test/test_xmlrpc.py similarity index 100% rename from Src/StdLib/Lib/test/test_xmlrpc.py rename to StdLib/Lib/test/test_xmlrpc.py diff --git a/Src/StdLib/Lib/test/test_xmlrpc_net.py b/StdLib/Lib/test/test_xmlrpc_net.py similarity index 100% rename from Src/StdLib/Lib/test/test_xmlrpc_net.py rename to StdLib/Lib/test/test_xmlrpc_net.py diff --git a/Src/StdLib/Lib/test/test_zipfile.py b/StdLib/Lib/test/test_zipfile.py similarity index 100% rename from Src/StdLib/Lib/test/test_zipfile.py rename to StdLib/Lib/test/test_zipfile.py diff --git a/Src/StdLib/Lib/test/test_zipfile64.py b/StdLib/Lib/test/test_zipfile64.py similarity index 100% rename from Src/StdLib/Lib/test/test_zipfile64.py rename to StdLib/Lib/test/test_zipfile64.py diff --git a/Src/StdLib/Lib/test/test_zipimport.py b/StdLib/Lib/test/test_zipimport.py similarity index 100% rename from Src/StdLib/Lib/test/test_zipimport.py rename to StdLib/Lib/test/test_zipimport.py diff --git a/Src/StdLib/Lib/test/test_zipimport_support.py b/StdLib/Lib/test/test_zipimport_support.py similarity index 100% rename from Src/StdLib/Lib/test/test_zipimport_support.py rename to StdLib/Lib/test/test_zipimport_support.py diff --git a/Src/StdLib/Lib/test/test_zlib.py b/StdLib/Lib/test/test_zlib.py similarity index 100% rename from Src/StdLib/Lib/test/test_zlib.py rename to StdLib/Lib/test/test_zlib.py diff --git a/Src/StdLib/Lib/test/testcodec.py b/StdLib/Lib/test/testcodec.py similarity index 100% rename from Src/StdLib/Lib/test/testcodec.py rename to StdLib/Lib/test/testcodec.py diff --git a/Src/StdLib/Lib/test/testtar.tar b/StdLib/Lib/test/testtar.tar similarity index 100% rename from Src/StdLib/Lib/test/testtar.tar rename to StdLib/Lib/test/testtar.tar diff --git a/Src/StdLib/Lib/test/tf_inherit_check.py b/StdLib/Lib/test/tf_inherit_check.py similarity index 100% rename from Src/StdLib/Lib/test/tf_inherit_check.py rename to StdLib/Lib/test/tf_inherit_check.py diff --git a/Src/StdLib/Lib/test/threaded_import_hangers.py b/StdLib/Lib/test/threaded_import_hangers.py similarity index 100% rename from Src/StdLib/Lib/test/threaded_import_hangers.py rename to StdLib/Lib/test/threaded_import_hangers.py diff --git a/Src/StdLib/Lib/test/time_hashlib.py b/StdLib/Lib/test/time_hashlib.py similarity index 100% rename from Src/StdLib/Lib/test/time_hashlib.py rename to StdLib/Lib/test/time_hashlib.py diff --git a/Src/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt b/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt similarity index 100% rename from Src/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt rename to StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt diff --git a/Src/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt b/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt similarity index 100% rename from Src/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt rename to StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt diff --git a/Src/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt b/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt similarity index 100% rename from Src/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt rename to StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt diff --git a/Src/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt b/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt similarity index 100% rename from Src/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt rename to StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt diff --git a/Src/StdLib/Lib/test/tokenize_tests.txt b/StdLib/Lib/test/tokenize_tests.txt similarity index 100% rename from Src/StdLib/Lib/test/tokenize_tests.txt rename to StdLib/Lib/test/tokenize_tests.txt diff --git a/Src/StdLib/Lib/test/tracedmodules/__init__.py b/StdLib/Lib/test/tracedmodules/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/tracedmodules/__init__.py rename to StdLib/Lib/test/tracedmodules/__init__.py diff --git a/Src/StdLib/Lib/test/tracedmodules/testmod.py b/StdLib/Lib/test/tracedmodules/testmod.py similarity index 100% rename from Src/StdLib/Lib/test/tracedmodules/testmod.py rename to StdLib/Lib/test/tracedmodules/testmod.py diff --git a/Src/StdLib/Lib/test/warning_tests.py b/StdLib/Lib/test/warning_tests.py similarity index 100% rename from Src/StdLib/Lib/test/warning_tests.py rename to StdLib/Lib/test/warning_tests.py diff --git a/Src/StdLib/Lib/test/win_console_handler.py b/StdLib/Lib/test/win_console_handler.py similarity index 100% rename from Src/StdLib/Lib/test/win_console_handler.py rename to StdLib/Lib/test/win_console_handler.py diff --git a/Src/StdLib/Lib/test/xmltestdata/simple-ns.xml b/StdLib/Lib/test/xmltestdata/simple-ns.xml similarity index 100% rename from Src/StdLib/Lib/test/xmltestdata/simple-ns.xml rename to StdLib/Lib/test/xmltestdata/simple-ns.xml diff --git a/Src/StdLib/Lib/test/xmltestdata/simple.xml b/StdLib/Lib/test/xmltestdata/simple.xml similarity index 100% rename from Src/StdLib/Lib/test/xmltestdata/simple.xml rename to StdLib/Lib/test/xmltestdata/simple.xml diff --git a/Src/StdLib/Lib/test/xmltestdata/test.xml b/StdLib/Lib/test/xmltestdata/test.xml similarity index 100% rename from Src/StdLib/Lib/test/xmltestdata/test.xml rename to StdLib/Lib/test/xmltestdata/test.xml diff --git a/Src/StdLib/Lib/test/xmltestdata/test.xml.out b/StdLib/Lib/test/xmltestdata/test.xml.out similarity index 100% rename from Src/StdLib/Lib/test/xmltestdata/test.xml.out rename to StdLib/Lib/test/xmltestdata/test.xml.out diff --git a/Src/StdLib/Lib/test/xmltests.py b/StdLib/Lib/test/xmltests.py similarity index 100% rename from Src/StdLib/Lib/test/xmltests.py rename to StdLib/Lib/test/xmltests.py diff --git a/Src/StdLib/Lib/test/zip_cp437_header.zip b/StdLib/Lib/test/zip_cp437_header.zip similarity index 100% rename from Src/StdLib/Lib/test/zip_cp437_header.zip rename to StdLib/Lib/test/zip_cp437_header.zip diff --git a/Src/StdLib/Lib/test/zipdir.zip b/StdLib/Lib/test/zipdir.zip similarity index 100% rename from Src/StdLib/Lib/test/zipdir.zip rename to StdLib/Lib/test/zipdir.zip diff --git a/Src/StdLib/Lib/textwrap.py b/StdLib/Lib/textwrap.py similarity index 100% rename from Src/StdLib/Lib/textwrap.py rename to StdLib/Lib/textwrap.py diff --git a/Src/StdLib/Lib/this.py b/StdLib/Lib/this.py similarity index 100% rename from Src/StdLib/Lib/this.py rename to StdLib/Lib/this.py diff --git a/Src/StdLib/Lib/threading.py b/StdLib/Lib/threading.py similarity index 100% rename from Src/StdLib/Lib/threading.py rename to StdLib/Lib/threading.py diff --git a/Src/StdLib/Lib/timeit.py b/StdLib/Lib/timeit.py similarity index 100% rename from Src/StdLib/Lib/timeit.py rename to StdLib/Lib/timeit.py diff --git a/Src/StdLib/Lib/tkinter/__init__.py b/StdLib/Lib/tkinter/__init__.py similarity index 100% rename from Src/StdLib/Lib/tkinter/__init__.py rename to StdLib/Lib/tkinter/__init__.py diff --git a/Src/StdLib/Lib/tkinter/__main__.py b/StdLib/Lib/tkinter/__main__.py similarity index 100% rename from Src/StdLib/Lib/tkinter/__main__.py rename to StdLib/Lib/tkinter/__main__.py diff --git a/Src/StdLib/Lib/tkinter/_fix.py b/StdLib/Lib/tkinter/_fix.py similarity index 100% rename from Src/StdLib/Lib/tkinter/_fix.py rename to StdLib/Lib/tkinter/_fix.py diff --git a/Src/StdLib/Lib/tkinter/colorchooser.py b/StdLib/Lib/tkinter/colorchooser.py similarity index 100% rename from Src/StdLib/Lib/tkinter/colorchooser.py rename to StdLib/Lib/tkinter/colorchooser.py diff --git a/Src/StdLib/Lib/tkinter/commondialog.py b/StdLib/Lib/tkinter/commondialog.py similarity index 100% rename from Src/StdLib/Lib/tkinter/commondialog.py rename to StdLib/Lib/tkinter/commondialog.py diff --git a/Src/StdLib/Lib/tkinter/constants.py b/StdLib/Lib/tkinter/constants.py similarity index 100% rename from Src/StdLib/Lib/tkinter/constants.py rename to StdLib/Lib/tkinter/constants.py diff --git a/Src/StdLib/Lib/tkinter/dialog.py b/StdLib/Lib/tkinter/dialog.py similarity index 100% rename from Src/StdLib/Lib/tkinter/dialog.py rename to StdLib/Lib/tkinter/dialog.py diff --git a/Src/StdLib/Lib/tkinter/dnd.py b/StdLib/Lib/tkinter/dnd.py similarity index 100% rename from Src/StdLib/Lib/tkinter/dnd.py rename to StdLib/Lib/tkinter/dnd.py diff --git a/Src/StdLib/Lib/tkinter/filedialog.py b/StdLib/Lib/tkinter/filedialog.py similarity index 100% rename from Src/StdLib/Lib/tkinter/filedialog.py rename to StdLib/Lib/tkinter/filedialog.py diff --git a/Src/StdLib/Lib/tkinter/font.py b/StdLib/Lib/tkinter/font.py similarity index 100% rename from Src/StdLib/Lib/tkinter/font.py rename to StdLib/Lib/tkinter/font.py diff --git a/Src/StdLib/Lib/tkinter/messagebox.py b/StdLib/Lib/tkinter/messagebox.py similarity index 100% rename from Src/StdLib/Lib/tkinter/messagebox.py rename to StdLib/Lib/tkinter/messagebox.py diff --git a/Src/StdLib/Lib/tkinter/scrolledtext.py b/StdLib/Lib/tkinter/scrolledtext.py similarity index 100% rename from Src/StdLib/Lib/tkinter/scrolledtext.py rename to StdLib/Lib/tkinter/scrolledtext.py diff --git a/Src/StdLib/Lib/tkinter/simpledialog.py b/StdLib/Lib/tkinter/simpledialog.py similarity index 100% rename from Src/StdLib/Lib/tkinter/simpledialog.py rename to StdLib/Lib/tkinter/simpledialog.py diff --git a/Src/StdLib/Lib/tkinter/test/README b/StdLib/Lib/tkinter/test/README similarity index 100% rename from Src/StdLib/Lib/tkinter/test/README rename to StdLib/Lib/tkinter/test/README diff --git a/Src/StdLib/Lib/tkinter/test/__init__.py b/StdLib/Lib/tkinter/test/__init__.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/__init__.py rename to StdLib/Lib/tkinter/test/__init__.py diff --git a/Src/StdLib/Lib/tkinter/test/runtktests.py b/StdLib/Lib/tkinter/test/runtktests.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/runtktests.py rename to StdLib/Lib/tkinter/test/runtktests.py diff --git a/Src/StdLib/Lib/tkinter/test/support.py b/StdLib/Lib/tkinter/test/support.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/support.py rename to StdLib/Lib/tkinter/test/support.py diff --git a/Src/StdLib/Lib/tkinter/test/test_tkinter/__init__.py b/StdLib/Lib/tkinter/test/test_tkinter/__init__.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_tkinter/__init__.py rename to StdLib/Lib/tkinter/test/test_tkinter/__init__.py diff --git a/Src/StdLib/Lib/tkinter/test/test_tkinter/test_font.py b/StdLib/Lib/tkinter/test/test_tkinter/test_font.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_tkinter/test_font.py rename to StdLib/Lib/tkinter/test/test_tkinter/test_font.py diff --git a/Src/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py b/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py rename to StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py diff --git a/Src/StdLib/Lib/tkinter/test/test_tkinter/test_images.py b/StdLib/Lib/tkinter/test/test_tkinter/test_images.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_tkinter/test_images.py rename to StdLib/Lib/tkinter/test/test_tkinter/test_images.py diff --git a/Src/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py b/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py rename to StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py diff --git a/Src/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py b/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py rename to StdLib/Lib/tkinter/test/test_tkinter/test_misc.py diff --git a/Src/StdLib/Lib/tkinter/test/test_tkinter/test_text.py b/StdLib/Lib/tkinter/test/test_tkinter/test_text.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_tkinter/test_text.py rename to StdLib/Lib/tkinter/test/test_tkinter/test_text.py diff --git a/Src/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py b/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py rename to StdLib/Lib/tkinter/test/test_tkinter/test_variables.py diff --git a/Src/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py b/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py rename to StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py diff --git a/Src/StdLib/Lib/tkinter/test/test_ttk/__init__.py b/StdLib/Lib/tkinter/test/test_ttk/__init__.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_ttk/__init__.py rename to StdLib/Lib/tkinter/test/test_ttk/__init__.py diff --git a/Src/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py b/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py rename to StdLib/Lib/tkinter/test/test_ttk/test_extensions.py diff --git a/Src/StdLib/Lib/tkinter/test/test_ttk/test_functions.py b/StdLib/Lib/tkinter/test/test_ttk/test_functions.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_ttk/test_functions.py rename to StdLib/Lib/tkinter/test/test_ttk/test_functions.py diff --git a/Src/StdLib/Lib/tkinter/test/test_ttk/test_style.py b/StdLib/Lib/tkinter/test/test_ttk/test_style.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_ttk/test_style.py rename to StdLib/Lib/tkinter/test/test_ttk/test_style.py diff --git a/Src/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py b/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py rename to StdLib/Lib/tkinter/test/test_ttk/test_widgets.py diff --git a/Src/StdLib/Lib/tkinter/test/widget_tests.py b/StdLib/Lib/tkinter/test/widget_tests.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/widget_tests.py rename to StdLib/Lib/tkinter/test/widget_tests.py diff --git a/Src/StdLib/Lib/tkinter/tix.py b/StdLib/Lib/tkinter/tix.py similarity index 100% rename from Src/StdLib/Lib/tkinter/tix.py rename to StdLib/Lib/tkinter/tix.py diff --git a/Src/StdLib/Lib/tkinter/ttk.py b/StdLib/Lib/tkinter/ttk.py similarity index 100% rename from Src/StdLib/Lib/tkinter/ttk.py rename to StdLib/Lib/tkinter/ttk.py diff --git a/Src/StdLib/Lib/token.py b/StdLib/Lib/token.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/token.py rename to StdLib/Lib/token.py diff --git a/Src/StdLib/Lib/tokenize.py b/StdLib/Lib/tokenize.py similarity index 100% rename from Src/StdLib/Lib/tokenize.py rename to StdLib/Lib/tokenize.py diff --git a/Src/StdLib/Lib/trace.py b/StdLib/Lib/trace.py similarity index 100% rename from Src/StdLib/Lib/trace.py rename to StdLib/Lib/trace.py diff --git a/Src/StdLib/Lib/traceback.py b/StdLib/Lib/traceback.py similarity index 100% rename from Src/StdLib/Lib/traceback.py rename to StdLib/Lib/traceback.py diff --git a/Src/StdLib/Lib/tracemalloc.py b/StdLib/Lib/tracemalloc.py similarity index 100% rename from Src/StdLib/Lib/tracemalloc.py rename to StdLib/Lib/tracemalloc.py diff --git a/Src/StdLib/Lib/tty.py b/StdLib/Lib/tty.py similarity index 100% rename from Src/StdLib/Lib/tty.py rename to StdLib/Lib/tty.py diff --git a/Src/StdLib/Lib/turtle.py b/StdLib/Lib/turtle.py similarity index 100% rename from Src/StdLib/Lib/turtle.py rename to StdLib/Lib/turtle.py diff --git a/Src/StdLib/Lib/turtledemo/__init__.py b/StdLib/Lib/turtledemo/__init__.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/__init__.py rename to StdLib/Lib/turtledemo/__init__.py diff --git a/Src/StdLib/Lib/turtledemo/__main__.py b/StdLib/Lib/turtledemo/__main__.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/turtledemo/__main__.py rename to StdLib/Lib/turtledemo/__main__.py diff --git a/Src/StdLib/Lib/turtledemo/bytedesign.py b/StdLib/Lib/turtledemo/bytedesign.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/bytedesign.py rename to StdLib/Lib/turtledemo/bytedesign.py diff --git a/Src/StdLib/Lib/turtledemo/chaos.py b/StdLib/Lib/turtledemo/chaos.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/chaos.py rename to StdLib/Lib/turtledemo/chaos.py diff --git a/Src/StdLib/Lib/turtledemo/clock.py b/StdLib/Lib/turtledemo/clock.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/clock.py rename to StdLib/Lib/turtledemo/clock.py diff --git a/Src/StdLib/Lib/turtledemo/colormixer.py b/StdLib/Lib/turtledemo/colormixer.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/colormixer.py rename to StdLib/Lib/turtledemo/colormixer.py diff --git a/Src/StdLib/Lib/turtledemo/forest.py b/StdLib/Lib/turtledemo/forest.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/forest.py rename to StdLib/Lib/turtledemo/forest.py diff --git a/Src/StdLib/Lib/turtledemo/fractalcurves.py b/StdLib/Lib/turtledemo/fractalcurves.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/fractalcurves.py rename to StdLib/Lib/turtledemo/fractalcurves.py diff --git a/Src/StdLib/Lib/turtledemo/lindenmayer.py b/StdLib/Lib/turtledemo/lindenmayer.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/lindenmayer.py rename to StdLib/Lib/turtledemo/lindenmayer.py diff --git a/Src/StdLib/Lib/turtledemo/minimal_hanoi.py b/StdLib/Lib/turtledemo/minimal_hanoi.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/minimal_hanoi.py rename to StdLib/Lib/turtledemo/minimal_hanoi.py diff --git a/Src/StdLib/Lib/turtledemo/nim.py b/StdLib/Lib/turtledemo/nim.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/nim.py rename to StdLib/Lib/turtledemo/nim.py diff --git a/Src/StdLib/Lib/turtledemo/paint.py b/StdLib/Lib/turtledemo/paint.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/paint.py rename to StdLib/Lib/turtledemo/paint.py diff --git a/Src/StdLib/Lib/turtledemo/peace.py b/StdLib/Lib/turtledemo/peace.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/peace.py rename to StdLib/Lib/turtledemo/peace.py diff --git a/Src/StdLib/Lib/turtledemo/penrose.py b/StdLib/Lib/turtledemo/penrose.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/penrose.py rename to StdLib/Lib/turtledemo/penrose.py diff --git a/Src/StdLib/Lib/turtledemo/planet_and_moon.py b/StdLib/Lib/turtledemo/planet_and_moon.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/planet_and_moon.py rename to StdLib/Lib/turtledemo/planet_and_moon.py diff --git a/Src/StdLib/Lib/turtledemo/round_dance.py b/StdLib/Lib/turtledemo/round_dance.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/round_dance.py rename to StdLib/Lib/turtledemo/round_dance.py diff --git a/Src/StdLib/Lib/turtledemo/tree.py b/StdLib/Lib/turtledemo/tree.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/tree.py rename to StdLib/Lib/turtledemo/tree.py diff --git a/Src/StdLib/Lib/turtledemo/turtle.cfg b/StdLib/Lib/turtledemo/turtle.cfg similarity index 100% rename from Src/StdLib/Lib/turtledemo/turtle.cfg rename to StdLib/Lib/turtledemo/turtle.cfg diff --git a/Src/StdLib/Lib/turtledemo/two_canvases.py b/StdLib/Lib/turtledemo/two_canvases.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/two_canvases.py rename to StdLib/Lib/turtledemo/two_canvases.py diff --git a/Src/StdLib/Lib/turtledemo/wikipedia.py b/StdLib/Lib/turtledemo/wikipedia.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/wikipedia.py rename to StdLib/Lib/turtledemo/wikipedia.py diff --git a/Src/StdLib/Lib/turtledemo/yinyang.py b/StdLib/Lib/turtledemo/yinyang.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/yinyang.py rename to StdLib/Lib/turtledemo/yinyang.py diff --git a/Src/StdLib/Lib/types.py b/StdLib/Lib/types.py similarity index 100% rename from Src/StdLib/Lib/types.py rename to StdLib/Lib/types.py diff --git a/Src/StdLib/Lib/typing.py b/StdLib/Lib/typing.py similarity index 100% rename from Src/StdLib/Lib/typing.py rename to StdLib/Lib/typing.py diff --git a/Src/StdLib/Lib/unittest/__init__.py b/StdLib/Lib/unittest/__init__.py similarity index 100% rename from Src/StdLib/Lib/unittest/__init__.py rename to StdLib/Lib/unittest/__init__.py diff --git a/Src/StdLib/Lib/unittest/__main__.py b/StdLib/Lib/unittest/__main__.py similarity index 100% rename from Src/StdLib/Lib/unittest/__main__.py rename to StdLib/Lib/unittest/__main__.py diff --git a/Src/StdLib/Lib/unittest/case.py b/StdLib/Lib/unittest/case.py similarity index 100% rename from Src/StdLib/Lib/unittest/case.py rename to StdLib/Lib/unittest/case.py diff --git a/Src/StdLib/Lib/unittest/loader.py b/StdLib/Lib/unittest/loader.py similarity index 100% rename from Src/StdLib/Lib/unittest/loader.py rename to StdLib/Lib/unittest/loader.py diff --git a/Src/StdLib/Lib/unittest/main.py b/StdLib/Lib/unittest/main.py similarity index 100% rename from Src/StdLib/Lib/unittest/main.py rename to StdLib/Lib/unittest/main.py diff --git a/Src/StdLib/Lib/unittest/mock.py b/StdLib/Lib/unittest/mock.py similarity index 100% rename from Src/StdLib/Lib/unittest/mock.py rename to StdLib/Lib/unittest/mock.py diff --git a/Src/StdLib/Lib/unittest/result.py b/StdLib/Lib/unittest/result.py similarity index 100% rename from Src/StdLib/Lib/unittest/result.py rename to StdLib/Lib/unittest/result.py diff --git a/Src/StdLib/Lib/unittest/runner.py b/StdLib/Lib/unittest/runner.py similarity index 100% rename from Src/StdLib/Lib/unittest/runner.py rename to StdLib/Lib/unittest/runner.py diff --git a/Src/StdLib/Lib/unittest/signals.py b/StdLib/Lib/unittest/signals.py similarity index 100% rename from Src/StdLib/Lib/unittest/signals.py rename to StdLib/Lib/unittest/signals.py diff --git a/Src/StdLib/Lib/unittest/suite.py b/StdLib/Lib/unittest/suite.py similarity index 100% rename from Src/StdLib/Lib/unittest/suite.py rename to StdLib/Lib/unittest/suite.py diff --git a/Src/StdLib/Lib/unittest/test/__init__.py b/StdLib/Lib/unittest/test/__init__.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/__init__.py rename to StdLib/Lib/unittest/test/__init__.py diff --git a/Src/StdLib/Lib/unittest/test/__main__.py b/StdLib/Lib/unittest/test/__main__.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/__main__.py rename to StdLib/Lib/unittest/test/__main__.py diff --git a/Src/StdLib/Lib/unittest/test/_test_warnings.py b/StdLib/Lib/unittest/test/_test_warnings.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/_test_warnings.py rename to StdLib/Lib/unittest/test/_test_warnings.py diff --git a/Src/StdLib/Lib/unittest/test/dummy.py b/StdLib/Lib/unittest/test/dummy.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/dummy.py rename to StdLib/Lib/unittest/test/dummy.py diff --git a/Src/StdLib/Lib/unittest/test/support.py b/StdLib/Lib/unittest/test/support.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/support.py rename to StdLib/Lib/unittest/test/support.py diff --git a/Src/StdLib/Lib/unittest/test/test_assertions.py b/StdLib/Lib/unittest/test/test_assertions.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_assertions.py rename to StdLib/Lib/unittest/test/test_assertions.py diff --git a/Src/StdLib/Lib/unittest/test/test_break.py b/StdLib/Lib/unittest/test/test_break.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_break.py rename to StdLib/Lib/unittest/test/test_break.py diff --git a/Src/StdLib/Lib/unittest/test/test_case.py b/StdLib/Lib/unittest/test/test_case.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_case.py rename to StdLib/Lib/unittest/test/test_case.py diff --git a/Src/StdLib/Lib/unittest/test/test_discovery.py b/StdLib/Lib/unittest/test/test_discovery.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_discovery.py rename to StdLib/Lib/unittest/test/test_discovery.py diff --git a/Src/StdLib/Lib/unittest/test/test_functiontestcase.py b/StdLib/Lib/unittest/test/test_functiontestcase.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_functiontestcase.py rename to StdLib/Lib/unittest/test/test_functiontestcase.py diff --git a/Src/StdLib/Lib/unittest/test/test_loader.py b/StdLib/Lib/unittest/test/test_loader.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_loader.py rename to StdLib/Lib/unittest/test/test_loader.py diff --git a/Src/StdLib/Lib/unittest/test/test_program.py b/StdLib/Lib/unittest/test/test_program.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_program.py rename to StdLib/Lib/unittest/test/test_program.py diff --git a/Src/StdLib/Lib/unittest/test/test_result.py b/StdLib/Lib/unittest/test/test_result.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_result.py rename to StdLib/Lib/unittest/test/test_result.py diff --git a/Src/StdLib/Lib/unittest/test/test_runner.py b/StdLib/Lib/unittest/test/test_runner.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_runner.py rename to StdLib/Lib/unittest/test/test_runner.py diff --git a/Src/StdLib/Lib/unittest/test/test_setups.py b/StdLib/Lib/unittest/test/test_setups.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_setups.py rename to StdLib/Lib/unittest/test/test_setups.py diff --git a/Src/StdLib/Lib/unittest/test/test_skipping.py b/StdLib/Lib/unittest/test/test_skipping.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_skipping.py rename to StdLib/Lib/unittest/test/test_skipping.py diff --git a/Src/StdLib/Lib/unittest/test/test_suite.py b/StdLib/Lib/unittest/test/test_suite.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_suite.py rename to StdLib/Lib/unittest/test/test_suite.py diff --git a/Src/StdLib/Lib/unittest/test/testmock/__init__.py b/StdLib/Lib/unittest/test/testmock/__init__.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/testmock/__init__.py rename to StdLib/Lib/unittest/test/testmock/__init__.py diff --git a/Src/StdLib/Lib/unittest/test/testmock/__main__.py b/StdLib/Lib/unittest/test/testmock/__main__.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/testmock/__main__.py rename to StdLib/Lib/unittest/test/testmock/__main__.py diff --git a/Src/StdLib/Lib/unittest/test/testmock/support.py b/StdLib/Lib/unittest/test/testmock/support.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/testmock/support.py rename to StdLib/Lib/unittest/test/testmock/support.py diff --git a/Src/StdLib/Lib/unittest/test/testmock/testcallable.py b/StdLib/Lib/unittest/test/testmock/testcallable.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/testmock/testcallable.py rename to StdLib/Lib/unittest/test/testmock/testcallable.py diff --git a/Src/StdLib/Lib/unittest/test/testmock/testhelpers.py b/StdLib/Lib/unittest/test/testmock/testhelpers.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/testmock/testhelpers.py rename to StdLib/Lib/unittest/test/testmock/testhelpers.py diff --git a/Src/StdLib/Lib/unittest/test/testmock/testmagicmethods.py b/StdLib/Lib/unittest/test/testmock/testmagicmethods.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/testmock/testmagicmethods.py rename to StdLib/Lib/unittest/test/testmock/testmagicmethods.py diff --git a/Src/StdLib/Lib/unittest/test/testmock/testmock.py b/StdLib/Lib/unittest/test/testmock/testmock.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/testmock/testmock.py rename to StdLib/Lib/unittest/test/testmock/testmock.py diff --git a/Src/StdLib/Lib/unittest/test/testmock/testpatch.py b/StdLib/Lib/unittest/test/testmock/testpatch.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/testmock/testpatch.py rename to StdLib/Lib/unittest/test/testmock/testpatch.py diff --git a/Src/StdLib/Lib/unittest/test/testmock/testsentinel.py b/StdLib/Lib/unittest/test/testmock/testsentinel.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/testmock/testsentinel.py rename to StdLib/Lib/unittest/test/testmock/testsentinel.py diff --git a/Src/StdLib/Lib/unittest/test/testmock/testwith.py b/StdLib/Lib/unittest/test/testmock/testwith.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/testmock/testwith.py rename to StdLib/Lib/unittest/test/testmock/testwith.py diff --git a/Src/StdLib/Lib/unittest/util.py b/StdLib/Lib/unittest/util.py similarity index 100% rename from Src/StdLib/Lib/unittest/util.py rename to StdLib/Lib/unittest/util.py diff --git a/Src/StdLib/Lib/urllib/__init__.py b/StdLib/Lib/urllib/__init__.py similarity index 100% rename from Src/StdLib/Lib/urllib/__init__.py rename to StdLib/Lib/urllib/__init__.py diff --git a/Src/StdLib/Lib/urllib/error.py b/StdLib/Lib/urllib/error.py similarity index 100% rename from Src/StdLib/Lib/urllib/error.py rename to StdLib/Lib/urllib/error.py diff --git a/Src/StdLib/Lib/urllib/parse.py b/StdLib/Lib/urllib/parse.py similarity index 100% rename from Src/StdLib/Lib/urllib/parse.py rename to StdLib/Lib/urllib/parse.py diff --git a/Src/StdLib/Lib/urllib/request.py b/StdLib/Lib/urllib/request.py similarity index 100% rename from Src/StdLib/Lib/urllib/request.py rename to StdLib/Lib/urllib/request.py diff --git a/Src/StdLib/Lib/urllib/response.py b/StdLib/Lib/urllib/response.py similarity index 100% rename from Src/StdLib/Lib/urllib/response.py rename to StdLib/Lib/urllib/response.py diff --git a/Src/StdLib/Lib/urllib/robotparser.py b/StdLib/Lib/urllib/robotparser.py similarity index 100% rename from Src/StdLib/Lib/urllib/robotparser.py rename to StdLib/Lib/urllib/robotparser.py diff --git a/Src/StdLib/Lib/uu.py b/StdLib/Lib/uu.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/uu.py rename to StdLib/Lib/uu.py diff --git a/Src/StdLib/Lib/uuid.py b/StdLib/Lib/uuid.py similarity index 100% rename from Src/StdLib/Lib/uuid.py rename to StdLib/Lib/uuid.py diff --git a/Src/StdLib/Lib/venv/__init__.py b/StdLib/Lib/venv/__init__.py similarity index 100% rename from Src/StdLib/Lib/venv/__init__.py rename to StdLib/Lib/venv/__init__.py diff --git a/Src/StdLib/Lib/venv/__main__.py b/StdLib/Lib/venv/__main__.py similarity index 100% rename from Src/StdLib/Lib/venv/__main__.py rename to StdLib/Lib/venv/__main__.py diff --git a/Src/StdLib/Lib/venv/scripts/nt/Activate.ps1 b/StdLib/Lib/venv/scripts/nt/Activate.ps1 similarity index 100% rename from Src/StdLib/Lib/venv/scripts/nt/Activate.ps1 rename to StdLib/Lib/venv/scripts/nt/Activate.ps1 diff --git a/Src/StdLib/Lib/venv/scripts/nt/activate.bat b/StdLib/Lib/venv/scripts/nt/activate.bat similarity index 100% rename from Src/StdLib/Lib/venv/scripts/nt/activate.bat rename to StdLib/Lib/venv/scripts/nt/activate.bat diff --git a/Src/StdLib/Lib/venv/scripts/nt/deactivate.bat b/StdLib/Lib/venv/scripts/nt/deactivate.bat similarity index 100% rename from Src/StdLib/Lib/venv/scripts/nt/deactivate.bat rename to StdLib/Lib/venv/scripts/nt/deactivate.bat diff --git a/Src/StdLib/Lib/venv/scripts/posix/activate b/StdLib/Lib/venv/scripts/posix/activate similarity index 100% rename from Src/StdLib/Lib/venv/scripts/posix/activate rename to StdLib/Lib/venv/scripts/posix/activate diff --git a/Src/StdLib/Lib/venv/scripts/posix/activate.csh b/StdLib/Lib/venv/scripts/posix/activate.csh similarity index 100% rename from Src/StdLib/Lib/venv/scripts/posix/activate.csh rename to StdLib/Lib/venv/scripts/posix/activate.csh diff --git a/Src/StdLib/Lib/venv/scripts/posix/activate.fish b/StdLib/Lib/venv/scripts/posix/activate.fish similarity index 100% rename from Src/StdLib/Lib/venv/scripts/posix/activate.fish rename to StdLib/Lib/venv/scripts/posix/activate.fish diff --git a/Src/StdLib/Lib/warnings.py b/StdLib/Lib/warnings.py similarity index 100% rename from Src/StdLib/Lib/warnings.py rename to StdLib/Lib/warnings.py diff --git a/Src/StdLib/Lib/wave.py b/StdLib/Lib/wave.py similarity index 100% rename from Src/StdLib/Lib/wave.py rename to StdLib/Lib/wave.py diff --git a/Src/StdLib/Lib/weakref.py b/StdLib/Lib/weakref.py similarity index 100% rename from Src/StdLib/Lib/weakref.py rename to StdLib/Lib/weakref.py diff --git a/Src/StdLib/Lib/webbrowser.py b/StdLib/Lib/webbrowser.py similarity index 100% rename from Src/StdLib/Lib/webbrowser.py rename to StdLib/Lib/webbrowser.py diff --git a/Src/StdLib/Lib/wpf.py b/StdLib/Lib/wpf.py similarity index 100% rename from Src/StdLib/Lib/wpf.py rename to StdLib/Lib/wpf.py diff --git a/Src/StdLib/Lib/wsgiref/__init__.py b/StdLib/Lib/wsgiref/__init__.py similarity index 100% rename from Src/StdLib/Lib/wsgiref/__init__.py rename to StdLib/Lib/wsgiref/__init__.py diff --git a/Src/StdLib/Lib/wsgiref/handlers.py b/StdLib/Lib/wsgiref/handlers.py similarity index 100% rename from Src/StdLib/Lib/wsgiref/handlers.py rename to StdLib/Lib/wsgiref/handlers.py diff --git a/Src/StdLib/Lib/wsgiref/headers.py b/StdLib/Lib/wsgiref/headers.py similarity index 100% rename from Src/StdLib/Lib/wsgiref/headers.py rename to StdLib/Lib/wsgiref/headers.py diff --git a/Src/StdLib/Lib/wsgiref/simple_server.py b/StdLib/Lib/wsgiref/simple_server.py similarity index 100% rename from Src/StdLib/Lib/wsgiref/simple_server.py rename to StdLib/Lib/wsgiref/simple_server.py diff --git a/Src/StdLib/Lib/wsgiref/util.py b/StdLib/Lib/wsgiref/util.py similarity index 100% rename from Src/StdLib/Lib/wsgiref/util.py rename to StdLib/Lib/wsgiref/util.py diff --git a/Src/StdLib/Lib/wsgiref/validate.py b/StdLib/Lib/wsgiref/validate.py similarity index 100% rename from Src/StdLib/Lib/wsgiref/validate.py rename to StdLib/Lib/wsgiref/validate.py diff --git a/Src/StdLib/Lib/xdrlib.py b/StdLib/Lib/xdrlib.py similarity index 100% rename from Src/StdLib/Lib/xdrlib.py rename to StdLib/Lib/xdrlib.py diff --git a/Src/StdLib/Lib/xml/__init__.py b/StdLib/Lib/xml/__init__.py similarity index 100% rename from Src/StdLib/Lib/xml/__init__.py rename to StdLib/Lib/xml/__init__.py diff --git a/Src/StdLib/Lib/xml/dom/NodeFilter.py b/StdLib/Lib/xml/dom/NodeFilter.py similarity index 100% rename from Src/StdLib/Lib/xml/dom/NodeFilter.py rename to StdLib/Lib/xml/dom/NodeFilter.py diff --git a/Src/StdLib/Lib/xml/dom/__init__.py b/StdLib/Lib/xml/dom/__init__.py similarity index 100% rename from Src/StdLib/Lib/xml/dom/__init__.py rename to StdLib/Lib/xml/dom/__init__.py diff --git a/Src/StdLib/Lib/xml/dom/domreg.py b/StdLib/Lib/xml/dom/domreg.py similarity index 100% rename from Src/StdLib/Lib/xml/dom/domreg.py rename to StdLib/Lib/xml/dom/domreg.py diff --git a/Src/StdLib/Lib/xml/dom/expatbuilder.py b/StdLib/Lib/xml/dom/expatbuilder.py similarity index 100% rename from Src/StdLib/Lib/xml/dom/expatbuilder.py rename to StdLib/Lib/xml/dom/expatbuilder.py diff --git a/Src/StdLib/Lib/xml/dom/minicompat.py b/StdLib/Lib/xml/dom/minicompat.py similarity index 100% rename from Src/StdLib/Lib/xml/dom/minicompat.py rename to StdLib/Lib/xml/dom/minicompat.py diff --git a/Src/StdLib/Lib/xml/dom/minidom.py b/StdLib/Lib/xml/dom/minidom.py similarity index 100% rename from Src/StdLib/Lib/xml/dom/minidom.py rename to StdLib/Lib/xml/dom/minidom.py diff --git a/Src/StdLib/Lib/xml/dom/pulldom.py b/StdLib/Lib/xml/dom/pulldom.py similarity index 100% rename from Src/StdLib/Lib/xml/dom/pulldom.py rename to StdLib/Lib/xml/dom/pulldom.py diff --git a/Src/StdLib/Lib/xml/dom/xmlbuilder.py b/StdLib/Lib/xml/dom/xmlbuilder.py similarity index 100% rename from Src/StdLib/Lib/xml/dom/xmlbuilder.py rename to StdLib/Lib/xml/dom/xmlbuilder.py diff --git a/Src/StdLib/Lib/xml/etree/ElementInclude.py b/StdLib/Lib/xml/etree/ElementInclude.py similarity index 100% rename from Src/StdLib/Lib/xml/etree/ElementInclude.py rename to StdLib/Lib/xml/etree/ElementInclude.py diff --git a/Src/StdLib/Lib/xml/etree/ElementPath.py b/StdLib/Lib/xml/etree/ElementPath.py similarity index 100% rename from Src/StdLib/Lib/xml/etree/ElementPath.py rename to StdLib/Lib/xml/etree/ElementPath.py diff --git a/Src/StdLib/Lib/xml/etree/ElementTree.py b/StdLib/Lib/xml/etree/ElementTree.py similarity index 100% rename from Src/StdLib/Lib/xml/etree/ElementTree.py rename to StdLib/Lib/xml/etree/ElementTree.py diff --git a/Src/StdLib/Lib/xml/etree/__init__.py b/StdLib/Lib/xml/etree/__init__.py similarity index 100% rename from Src/StdLib/Lib/xml/etree/__init__.py rename to StdLib/Lib/xml/etree/__init__.py diff --git a/Src/StdLib/Lib/xml/etree/cElementTree.py b/StdLib/Lib/xml/etree/cElementTree.py similarity index 100% rename from Src/StdLib/Lib/xml/etree/cElementTree.py rename to StdLib/Lib/xml/etree/cElementTree.py diff --git a/Src/StdLib/Lib/xml/parsers/__init__.py b/StdLib/Lib/xml/parsers/__init__.py similarity index 100% rename from Src/StdLib/Lib/xml/parsers/__init__.py rename to StdLib/Lib/xml/parsers/__init__.py diff --git a/Src/StdLib/Lib/xml/parsers/expat.py b/StdLib/Lib/xml/parsers/expat.py similarity index 100% rename from Src/StdLib/Lib/xml/parsers/expat.py rename to StdLib/Lib/xml/parsers/expat.py diff --git a/Src/StdLib/Lib/xml/sax/__init__.py b/StdLib/Lib/xml/sax/__init__.py similarity index 100% rename from Src/StdLib/Lib/xml/sax/__init__.py rename to StdLib/Lib/xml/sax/__init__.py diff --git a/Src/StdLib/Lib/xml/sax/_exceptions.py b/StdLib/Lib/xml/sax/_exceptions.py similarity index 100% rename from Src/StdLib/Lib/xml/sax/_exceptions.py rename to StdLib/Lib/xml/sax/_exceptions.py diff --git a/Src/StdLib/Lib/xml/sax/expatreader.py b/StdLib/Lib/xml/sax/expatreader.py similarity index 100% rename from Src/StdLib/Lib/xml/sax/expatreader.py rename to StdLib/Lib/xml/sax/expatreader.py diff --git a/Src/StdLib/Lib/xml/sax/handler.py b/StdLib/Lib/xml/sax/handler.py similarity index 100% rename from Src/StdLib/Lib/xml/sax/handler.py rename to StdLib/Lib/xml/sax/handler.py diff --git a/Src/StdLib/Lib/xml/sax/saxutils.py b/StdLib/Lib/xml/sax/saxutils.py similarity index 100% rename from Src/StdLib/Lib/xml/sax/saxutils.py rename to StdLib/Lib/xml/sax/saxutils.py diff --git a/Src/StdLib/Lib/xml/sax/xmlreader.py b/StdLib/Lib/xml/sax/xmlreader.py similarity index 100% rename from Src/StdLib/Lib/xml/sax/xmlreader.py rename to StdLib/Lib/xml/sax/xmlreader.py diff --git a/Src/StdLib/Lib/xmlrpc/__init__.py b/StdLib/Lib/xmlrpc/__init__.py similarity index 100% rename from Src/StdLib/Lib/xmlrpc/__init__.py rename to StdLib/Lib/xmlrpc/__init__.py diff --git a/Src/StdLib/Lib/xmlrpc/client.py b/StdLib/Lib/xmlrpc/client.py similarity index 100% rename from Src/StdLib/Lib/xmlrpc/client.py rename to StdLib/Lib/xmlrpc/client.py diff --git a/Src/StdLib/Lib/xmlrpc/server.py b/StdLib/Lib/xmlrpc/server.py similarity index 100% rename from Src/StdLib/Lib/xmlrpc/server.py rename to StdLib/Lib/xmlrpc/server.py diff --git a/Src/StdLib/Lib/zipfile.py b/StdLib/Lib/zipfile.py similarity index 100% rename from Src/StdLib/Lib/zipfile.py rename to StdLib/Lib/zipfile.py diff --git a/Src/StdLib/StdLib.License.txt b/StdLib/StdLib.License.txt similarity index 100% rename from Src/StdLib/StdLib.License.txt rename to StdLib/StdLib.License.txt diff --git a/Src/StdLib/StdLib.pyproj b/StdLib/StdLib.pyproj similarity index 100% rename from Src/StdLib/StdLib.pyproj rename to StdLib/StdLib.pyproj diff --git a/Src/StdLib/stdlib-upgrade.txt b/StdLib/stdlib-upgrade.txt similarity index 100% rename from Src/StdLib/stdlib-upgrade.txt rename to StdLib/stdlib-upgrade.txt diff --git a/Src/StdLib/update-stdlib.cmd b/StdLib/update-stdlib.cmd similarity index 100% rename from Src/StdLib/update-stdlib.cmd rename to StdLib/update-stdlib.cmd diff --git a/Src/StdLib/update-stdlib.sh b/StdLib/update-stdlib.sh old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/update-stdlib.sh rename to StdLib/update-stdlib.sh diff --git a/Src/Tests/AssemblyInfo.cs b/Tests/AssemblyInfo.cs similarity index 100% rename from Src/Tests/AssemblyInfo.cs rename to Tests/AssemblyInfo.cs diff --git a/Src/Tests/AttrInjectorTest.cs b/Tests/AttrInjectorTest.cs similarity index 100% rename from Src/Tests/AttrInjectorTest.cs rename to Tests/AttrInjectorTest.cs diff --git a/Src/Tests/BindTest.cs b/Tests/BindTest.cs similarity index 100% rename from Src/Tests/BindTest.cs rename to Tests/BindTest.cs diff --git a/Src/Tests/BinderTest.cs b/Tests/BinderTest.cs similarity index 100% rename from Src/Tests/BinderTest.cs rename to Tests/BinderTest.cs diff --git a/Src/Tests/Cases/CPythonCases.cs b/Tests/Cases/CPythonCases.cs similarity index 100% rename from Src/Tests/Cases/CPythonCases.cs rename to Tests/Cases/CPythonCases.cs diff --git a/Src/Tests/Cases/CPythonCasesManifest.ini b/Tests/Cases/CPythonCasesManifest.ini similarity index 100% rename from Src/Tests/Cases/CPythonCasesManifest.ini rename to Tests/Cases/CPythonCasesManifest.ini diff --git a/Src/Tests/Cases/CaseExecuter.cs b/Tests/Cases/CaseExecuter.cs similarity index 100% rename from Src/Tests/Cases/CaseExecuter.cs rename to Tests/Cases/CaseExecuter.cs diff --git a/Src/Tests/Cases/CaseGenerator.cs b/Tests/Cases/CaseGenerator.cs similarity index 100% rename from Src/Tests/Cases/CaseGenerator.cs rename to Tests/Cases/CaseGenerator.cs diff --git a/Src/Tests/Cases/CommonCases.cs b/Tests/Cases/CommonCases.cs similarity index 100% rename from Src/Tests/Cases/CommonCases.cs rename to Tests/Cases/CommonCases.cs diff --git a/Src/Tests/Cases/IronPythonCases.cs b/Tests/Cases/IronPythonCases.cs similarity index 100% rename from Src/Tests/Cases/IronPythonCases.cs rename to Tests/Cases/IronPythonCases.cs diff --git a/Src/Tests/Cases/IronPythonCasesManifest.ini b/Tests/Cases/IronPythonCasesManifest.ini similarity index 100% rename from Src/Tests/Cases/IronPythonCasesManifest.ini rename to Tests/Cases/IronPythonCasesManifest.ini diff --git a/Src/Tests/ClrType.cs b/Tests/ClrType.cs similarity index 100% rename from Src/Tests/ClrType.cs rename to Tests/ClrType.cs diff --git a/Src/Tests/Cmplx.cs b/Tests/Cmplx.cs similarity index 100% rename from Src/Tests/Cmplx.cs rename to Tests/Cmplx.cs diff --git a/Src/Tests/Conversions.cs b/Tests/Conversions.cs similarity index 100% rename from Src/Tests/Conversions.cs rename to Tests/Conversions.cs diff --git a/Src/Tests/DeTest.cs b/Tests/DeTest.cs similarity index 100% rename from Src/Tests/DeTest.cs rename to Tests/DeTest.cs diff --git a/Src/Tests/DelegateTest.cs b/Tests/DelegateTest.cs similarity index 100% rename from Src/Tests/DelegateTest.cs rename to Tests/DelegateTest.cs diff --git a/Src/Tests/DynamicRegressions.cs b/Tests/DynamicRegressions.cs similarity index 100% rename from Src/Tests/DynamicRegressions.cs rename to Tests/DynamicRegressions.cs diff --git a/Src/Tests/EncodingTest.cs b/Tests/EncodingTest.cs similarity index 100% rename from Src/Tests/EncodingTest.cs rename to Tests/EncodingTest.cs diff --git a/Src/Tests/EngineTest.cs b/Tests/EngineTest.cs similarity index 100% rename from Src/Tests/EngineTest.cs rename to Tests/EngineTest.cs diff --git a/Src/Tests/Enums.cs b/Tests/Enums.cs similarity index 100% rename from Src/Tests/Enums.cs rename to Tests/Enums.cs diff --git a/Src/Tests/Events.cs b/Tests/Events.cs similarity index 100% rename from Src/Tests/Events.cs rename to Tests/Events.cs diff --git a/Src/Tests/ExceptionConverter.cs b/Tests/ExceptionConverter.cs similarity index 100% rename from Src/Tests/ExceptionConverter.cs rename to Tests/ExceptionConverter.cs diff --git a/Src/Tests/Exceptions.cs b/Tests/Exceptions.cs similarity index 100% rename from Src/Tests/Exceptions.cs rename to Tests/Exceptions.cs diff --git a/Src/Tests/Explicit.cs b/Tests/Explicit.cs similarity index 100% rename from Src/Tests/Explicit.cs rename to Tests/Explicit.cs diff --git a/Src/Tests/ExtensionMethodTest.cs b/Tests/ExtensionMethodTest.cs similarity index 100% rename from Src/Tests/ExtensionMethodTest.cs rename to Tests/ExtensionMethodTest.cs diff --git a/Src/Tests/GenMeth.cs b/Tests/GenMeth.cs similarity index 100% rename from Src/Tests/GenMeth.cs rename to Tests/GenMeth.cs diff --git a/Src/Tests/Indexable.cs b/Tests/Indexable.cs similarity index 100% rename from Src/Tests/Indexable.cs rename to Tests/Indexable.cs diff --git a/Src/Tests/InheritTest.cs b/Tests/InheritTest.cs similarity index 100% rename from Src/Tests/InheritTest.cs rename to Tests/InheritTest.cs diff --git a/Src/Tests/IntegerTest.cs b/Tests/IntegerTest.cs similarity index 100% rename from Src/Tests/IntegerTest.cs rename to Tests/IntegerTest.cs diff --git a/Src/Tests/IronMath.cs b/Tests/IronMath.cs similarity index 100% rename from Src/Tests/IronMath.cs rename to Tests/IronMath.cs diff --git a/Src/Tests/IronPython.Tests.csproj b/Tests/IronPython.Tests.csproj similarity index 100% rename from Src/Tests/IronPython.Tests.csproj rename to Tests/IronPython.Tests.csproj diff --git a/Src/Tests/LoadTest.cs b/Tests/LoadTest.cs similarity index 100% rename from Src/Tests/LoadTest.cs rename to Tests/LoadTest.cs diff --git a/Src/Tests/MemberMappingTests.cs b/Tests/MemberMappingTests.cs similarity index 100% rename from Src/Tests/MemberMappingTests.cs rename to Tests/MemberMappingTests.cs diff --git a/Src/Tests/MemberOverloadTest.cs b/Tests/MemberOverloadTest.cs similarity index 100% rename from Src/Tests/MemberOverloadTest.cs rename to Tests/MemberOverloadTest.cs diff --git a/Src/Tests/MethodParametersStubs.cs b/Tests/MethodParametersStubs.cs similarity index 100% rename from Src/Tests/MethodParametersStubs.cs rename to Tests/MethodParametersStubs.cs diff --git a/Src/Tests/NestedClass.cs b/Tests/NestedClass.cs similarity index 100% rename from Src/Tests/NestedClass.cs rename to Tests/NestedClass.cs diff --git a/Src/Tests/NullableTest.cs b/Tests/NullableTest.cs similarity index 100% rename from Src/Tests/NullableTest.cs rename to Tests/NullableTest.cs diff --git a/Src/Tests/OperatorTest.cs b/Tests/OperatorTest.cs similarity index 100% rename from Src/Tests/OperatorTest.cs rename to Tests/OperatorTest.cs diff --git a/Src/Tests/ProtocolTest.cs b/Tests/ProtocolTest.cs similarity index 100% rename from Src/Tests/ProtocolTest.cs rename to Tests/ProtocolTest.cs diff --git a/Src/Tests/StaticTest.cs b/Tests/StaticTest.cs similarity index 100% rename from Src/Tests/StaticTest.cs rename to Tests/StaticTest.cs diff --git a/Src/Tests/Stress/Engine.cs b/Tests/Stress/Engine.cs similarity index 100% rename from Src/Tests/Stress/Engine.cs rename to Tests/Stress/Engine.cs diff --git a/Src/Tests/StringDictionaryStorage.cs b/Tests/StringDictionaryStorage.cs similarity index 100% rename from Src/Tests/StringDictionaryStorage.cs rename to Tests/StringDictionaryStorage.cs diff --git a/Src/Tests/TestBuiltinModule.cs b/Tests/TestBuiltinModule.cs similarity index 100% rename from Src/Tests/TestBuiltinModule.cs rename to Tests/TestBuiltinModule.cs diff --git a/Src/Tests/TypeDescriptor.cs b/Tests/TypeDescriptor.cs similarity index 100% rename from Src/Tests/TypeDescriptor.cs rename to Tests/TypeDescriptor.cs diff --git a/Src/Tests/Util/IniParser.cs b/Tests/Util/IniParser.cs similarity index 100% rename from Src/Tests/Util/IniParser.cs rename to Tests/Util/IniParser.cs diff --git a/Src/Tests/Util/TestManifest.cs b/Tests/Util/TestManifest.cs similarity index 100% rename from Src/Tests/Util/TestManifest.cs rename to Tests/Util/TestManifest.cs diff --git a/Src/Wpf/DynamicXamlReader.cs b/Wpf/DynamicXamlReader.cs similarity index 100% rename from Src/Wpf/DynamicXamlReader.cs rename to Wpf/DynamicXamlReader.cs diff --git a/Src/Wpf/IronPython.Wpf.csproj b/Wpf/IronPython.Wpf.csproj similarity index 100% rename from Src/Wpf/IronPython.Wpf.csproj rename to Wpf/IronPython.Wpf.csproj diff --git a/Src/Wpf/Properties/AssemblyInfo.cs b/Wpf/Properties/AssemblyInfo.cs similarity index 100% rename from Src/Wpf/Properties/AssemblyInfo.cs rename to Wpf/Properties/AssemblyInfo.cs diff --git a/Src/Wpf/_wpf.cs b/Wpf/_wpf.cs similarity index 100% rename from Src/Wpf/_wpf.cs rename to Wpf/_wpf.cs From 18dd588701c31be7fba3ae7192042df0bacb01c6 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 17:08:26 +0000 Subject: [PATCH 11/84] Removed submodule DLR --- .gitmodules | 4 ---- DLR | 1 - 2 files changed, 5 deletions(-) delete mode 100644 .gitmodules delete mode 160000 DLR diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index c5aaa65cd..000000000 --- a/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "DLR"] - path = DLR - url = https://github.com/IronLanguages/dlr - branch = main \ No newline at end of file diff --git a/DLR b/DLR deleted file mode 160000 index fe26cf45d..000000000 --- a/DLR +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fe26cf45d383be65a56f0d4b964644eff89e01a8 From e7e538c1624c73ab9c7e6e16f9ab58fe7649cadb Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 17:08:54 +0000 Subject: [PATCH 12/84] Revert "Simplify root directory" This reverts commit 7e38e2d03077bb5ba7e8aada08409842c0048c0c. --- IronPython.sln | 28 +++++++++--------- App.Debug.config => Src/App.Debug.config | 0 App.Release.config => Src/App.Release.config | 0 {CTypes => Src/CTypes}/Makefile | 0 {CTypes => Src/CTypes}/_ctypes_test.c | 0 {CTypes => Src/CTypes}/_ctypes_test.sln | 0 {CTypes => Src/CTypes}/_ctypes_test.vcxproj | 0 .../CompilerServices}/AssemblyResolver.cs | 0 .../CompilerServices}/Config.cs | 0 .../CompilerServices}/ConsoleOps.cs | 0 .../IronPython.CompilerServices.csproj | 4 +-- .../CompilerServices}/Program.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../CompilerServices}/README.md | 0 .../IronPython.Console.Host.csproj | 0 .../Console.Host}/IronPythonWindow.cs | 0 .../Console.Host}/Properties/AssemblyInfo.cs | 0 {Console.Host => Src/Console.Host}/ipyw.ico | Bin {Console => Src/Console}/Console.cs | 0 .../Console}/IronPython.Console.csproj | 0 .../Console}/Properties/AssemblyInfo.cs | 0 {Console => Src/Console}/app.manifest | 0 {Console => Src/Console}/ipy-mono.sh | 0 {Console => Src/Console}/ipy.ico | Bin {Console => Src/Console}/ipy.sh | 0 .../Console}/runtimeconfig.template.json | 0 .../IronPython.Console32.Host.csproj | 4 +-- .../Console32}/IronPython.Console32.csproj | 0 .../IronPython}/Compiler/Ast/AndExpression.cs | 0 .../Compiler/Ast/AnnotatedAssignStatement.cs | 0 .../Compiler/Ast/AssertStatement.cs | 0 .../Compiler/Ast/AssignmentStatement.cs | 0 .../IronPython}/Compiler/Ast/AstMethods.cs | 0 .../Compiler/Ast/AsyncStatement.cs | 0 .../Compiler/Ast/AugmentedAssignStatement.cs | 0 .../Ast/BinaryExpression.Generated.cs | 0 .../Compiler/Ast/BinaryExpression.cs | 0 .../Compiler/Ast/BreakStatement.cs | 0 .../Compiler/Ast/CallExpression.cs | 0 .../Compiler/Ast/ClassDefinition.cs | 0 .../IronPython}/Compiler/Ast/Comprehension.cs | 0 .../Compiler/Ast/ComprehensionFor.cs | 0 .../Compiler/Ast/ComprehensionIf.cs | 0 .../Compiler/Ast/ConditionalExpression.cs | 0 .../Compiler/Ast/ConstantExpression.cs | 0 .../Compiler/Ast/ContinueStatement.cs | 0 .../IronPython}/Compiler/Ast/DelStatement.cs | 0 .../Compiler/Ast/DictionaryExpression.cs | 0 .../IronPython}/Compiler/Ast/DottedName.cs | 0 .../Compiler/Ast/DynamicConvertExpression.cs | 0 .../Ast/DynamicGetMemberExpression.cs | 0 .../Compiler/Ast/EmptyStatement.cs | 0 .../Compiler/Ast/ErrorExpression.cs | 0 .../IronPython}/Compiler/Ast/Expression.cs | 0 .../Compiler/Ast/ExpressionStatement.cs | 0 .../IronPython}/Compiler/Ast/FlowChecker.cs | 0 .../IronPython}/Compiler/Ast/ForStatement.cs | 0 .../Compiler/Ast/FormattedValueExpression.cs | 0 .../Compiler/Ast/FromImportStatement.cs | 0 .../Compiler/Ast/FunctionDefinition.cs | 0 .../Compiler/Ast/GeneratorExpression.cs | 0 .../Ast/GetGlobalContextExpression.cs | 0 .../GetParentContextFromFunctionExpression.cs | 0 .../Compiler/Ast/GlobalStatement.cs | 0 .../Compiler/Ast/ILoopStatement.cs | 0 .../IronPython}/Compiler/Ast/IfStatement.cs | 0 .../Compiler/Ast/IfStatementTest.cs | 0 .../Compiler/Ast/ImportStatement.cs | 0 .../Compiler/Ast/IndexExpression.cs | 0 .../Compiler/Ast/JoinedStringExpression.cs | 0 .../IronPython}/Compiler/Ast/Keyword.cs | 0 .../Compiler/Ast/LambdaExpression.cs | 0 .../Compiler/Ast/ListExpression.cs | 0 .../Compiler/Ast/MemberExpression.cs | 0 .../IronPython}/Compiler/Ast/ModuleName.cs | 0 .../Compiler/Ast/NameExpression.cs | 0 .../IronPython}/Compiler/Ast/Node.cs | 0 .../Compiler/Ast/NonlocalStatement.cs | 0 .../IronPython}/Compiler/Ast/OrExpression.cs | 0 .../IronPython}/Compiler/Ast/Parameter.cs | 0 .../Compiler/Ast/ParenthesisExpression.cs | 0 .../IronPython}/Compiler/Ast/PythonAst.cs | 0 .../Compiler/Ast/PythonConstantExpression.cs | 0 .../Compiler/Ast/PythonNameBinder.cs | 0 .../Compiler/Ast/PythonReference.cs | 0 .../Compiler/Ast/PythonVariable.cs | 0 .../Compiler/Ast/PythonWalker.Generated.cs | 0 .../Compiler/Ast/RaiseStatement.cs | 0 .../Compiler/Ast/RelativeModuleName.cs | 0 .../Compiler/Ast/ReturnStatement.cs | 0 .../Compiler/Ast/ScopeStatement.cs | 0 .../Compiler/Ast/SequenceExpression.cs | 0 .../Compiler/Ast/SerializedScopeStatement.cs | 0 .../IronPython}/Compiler/Ast/SetExpression.cs | 0 .../Compiler/Ast/SliceExpression.cs | 0 .../Compiler/Ast/StarredExpression.cs | 0 .../IronPython}/Compiler/Ast/Statement.cs | 0 .../Compiler/Ast/SuiteStatement.cs | 0 .../IronPython}/Compiler/Ast/TryStatement.cs | 0 .../Compiler/Ast/TupleExpression.cs | 0 .../Compiler/Ast/UnaryExpression.cs | 0 .../IronPython}/Compiler/Ast/VariableKind.cs | 0 .../Compiler/Ast/WhileStatement.cs | 0 .../IronPython}/Compiler/Ast/WithStatement.cs | 0 .../Compiler/Ast/YieldExpression.cs | 0 .../Compiler/Ast/YieldFromExpression.cs | 0 .../IronPython}/Compiler/ClosureExpression.cs | 0 .../IronPython}/Compiler/ClosureInfo.cs | 0 .../Compiler/CollectableCompilationMode.cs | 0 .../IronPython}/Compiler/CompilationMode.cs | 0 .../IronPython}/Compiler/GeneratorRewriter.cs | 0 .../IronPython}/Compiler/LazyCode.cs | 0 .../Compiler/LookupCompilationMode.cs | 0 .../IronPython}/Compiler/OnDiskScriptCode.cs | 0 .../IronPython}/Compiler/Parser.cs | 0 .../IronPython}/Compiler/PythonCallTargets.cs | 0 .../Compiler/PythonCompilerOptions.cs | 0 .../Compiler/PythonDynamicExpression.cs | 0 .../IronPython}/Compiler/PythonGlobal.cs | 0 .../PythonGlobalVariableExpression.cs | 0 .../IronPython}/Compiler/PythonOperator.cs | 0 .../Compiler/PythonSavableScriptCode.cs | 0 .../IronPython}/Compiler/PythonScriptCode.cs | 0 .../Compiler/ReducableDynamicExpression.cs | 0 .../Compiler/RunnableScriptCode.cs | 0 .../IronPython}/Compiler/RuntimeScriptCode.cs | 0 .../Compiler/ToDiskCompilationMode.cs | 0 .../IronPython}/Compiler/Token.cs | 0 .../Compiler/TokenKind.Generated.cs | 0 .../Compiler/Tokenizer.Generated.cs | 0 .../IronPython}/Compiler/Tokenizer.cs | 0 .../UncollectableCompilationMode.Generated.cs | 0 .../Compiler/UncollectableCompilationMode.cs | 0 .../IronPython}/FakeInteropServices.cs | 0 .../IronPython}/Hosting/Python.cs | 0 .../Hosting/PythonCodeDomCodeGen.cs | 0 .../IronPython}/Hosting/PythonCommandLine.cs | 0 .../Hosting/PythonConsoleOptions.cs | 0 .../Hosting/PythonOptionsParser.cs | 0 .../IronPython}/Hosting/PythonService.cs | 0 .../Interop/Windows/Interop.Libraries.cs | 0 .../Windows/Kernel32/Interop.GetWindowsExW.cs | 0 .../Kernel32/Interop.OSVERSIONINFOEX.cs | 0 .../Windows/NtDll/Interop.RtlGetVersion.cs | 0 .../Windows/Ucrtbase/Interop.strerror.cs | 0 .../IronPython}/IronPython.csproj | 4 +-- .../IronPython}/Lib/iptest/__init__.py | 0 .../IronPython}/Lib/iptest/cominterop_util.py | 0 .../IronPython}/Lib/iptest/console_util.py | 0 .../IronPython}/Lib/iptest/file_util.py | 0 .../IronPython}/Lib/iptest/ipunittest.py | 0 .../IronPython}/Lib/iptest/misc_util.py | 0 .../IronPython}/Lib/iptest/process_util.py | 0 .../IronPython}/Lib/iptest/runner.py | 0 .../IronPython}/Lib/iptest/test_env.py | 0 .../IronPython}/Lib/iptest/type_util.py | 0 .../IronPython}/Modules/Builtin.Generated.cs | 0 .../IronPython}/Modules/Builtin.cs | 0 .../IronPython}/Modules/_ast.cs | 0 .../IronPython}/Modules/_fileio.cs | 0 .../IronPython}/Modules/_imp.cs | 0 {IronPython => Src/IronPython}/Modules/_io.cs | 0 .../IronPython}/Modules/_io/BytesIO.cs | 0 .../IronPython}/Modules/_io/StringIO.cs | 0 .../IronPython}/Modules/_locale.cs | 0 {IronPython => Src/IronPython}/Modules/sys.cs | 0 .../IronPython}/Modules/unicodedata.cs | 0 .../Modules/unicodedata/CaseFolding.txt | 0 .../unicodedata/EastAsianWidth-3.2.0.txt | 0 .../Modules/unicodedata/EastAsianWidth.txt | 0 .../unicodedata/IPyUnicodeData-3.2.0.txt.gz | Bin .../Modules/unicodedata/IPyUnicodeData.txt.gz | Bin .../Modules/unicodedata/NameAliases.txt | 0 .../Modules/unicodedata/UnicodeData-3.2.0.txt | 0 .../Modules/unicodedata/UnicodeData.txt | 0 .../Modules/unicodedata/genunicodedata.py | 0 .../Modules/unicodedata/license.txt | 0 .../IronPython}/Properties/AssemblyInfo.cs | 0 .../IronPython}/Resources.Designer.cs | 0 {IronPython => Src/IronPython}/Resources.resx | 0 .../IronPython}/Runtime/ArrayData.cs | 0 .../Binding/BinaryRetTypeBinder.Generated.cs | 0 .../Runtime/Binding/BinaryRetTypeBinder.cs | 0 .../IronPython}/Runtime/Binding/Binders.cs | 0 .../Runtime/Binding/BindingHelpers.cs | 0 .../Runtime/Binding/BindingWarnings.cs | 0 .../Binding/CompatibilityInvokeBinder.cs | 0 .../Runtime/Binding/ConditionalBuilder.cs | 0 .../Runtime/Binding/ContextArgBuilder.cs | 0 .../Runtime/Binding/ConversionBinder.cs | 0 .../Runtime/Binding/CreateFallbackBinder.cs | 0 .../Runtime/Binding/FastBindResult.cs | 0 .../Runtime/Binding/FastGetBase.cs | 0 .../Runtime/Binding/FastSetBase.cs | 0 .../Runtime/Binding/IComConvertible.cs | 0 .../Runtime/Binding/IFastGettable.cs | 0 .../Runtime/Binding/IFastInvokable.cs | 0 .../Runtime/Binding/IFastSettable.cs | 0 .../Runtime/Binding/IPythonConvertible.cs | 0 .../Runtime/Binding/IPythonExpandable.cs | 0 .../Runtime/Binding/IPythonGetable.cs | 0 .../Runtime/Binding/IPythonInvokable.cs | 0 .../Runtime/Binding/IPythonOperable.cs | 0 .../Runtime/Binding/IPythonSite.cs | 0 .../Runtime/Binding/MetaBuiltinFunction.cs | 0 .../Binding/MetaBuiltinMethodDescriptor.cs | 0 .../IronPython}/Runtime/Binding/MetaMethod.cs | 0 .../Runtime/Binding/MetaPythonFunction.cs | 0 .../Runtime/Binding/MetaPythonObject.cs | 0 .../Runtime/Binding/MetaPythonType.Calls.cs | 0 .../Runtime/Binding/MetaPythonType.Members.cs | 0 .../Runtime/Binding/MetaPythonType.cs | 0 .../Runtime/Binding/MetaUserObject.Members.cs | 0 .../Runtime/Binding/MetaUserObject.cs | 0 .../Binding/PythonBinaryOperationBinder.cs | 0 .../Runtime/Binding/PythonBinder.Create.cs | 0 .../Runtime/Binding/PythonBinder.cs | 0 .../Binding/PythonDeleteIndexBinder.cs | 0 .../Binding/PythonDeleteMemberBinder.cs | 0 .../Binding/PythonDeleteSliceBinder.cs | 0 .../Runtime/Binding/PythonExtensionBinder.cs | 0 .../Runtime/Binding/PythonGetIndexBinder.cs | 0 .../Runtime/Binding/PythonGetMemberBinder.cs | 0 .../Runtime/Binding/PythonGetSliceBinder.cs | 0 .../Runtime/Binding/PythonIndexType.cs | 0 .../Runtime/Binding/PythonInvokeBinder.cs | 0 .../Runtime/Binding/PythonOperationBinder.cs | 0 .../Runtime/Binding/PythonOperationKind.cs | 0 .../Runtime/Binding/PythonOverloadResolver.cs | 0 .../Binding/PythonProtocol.Operations.cs | 0 .../Runtime/Binding/PythonProtocol.cs | 0 .../Runtime/Binding/PythonSetIndexBinder.cs | 0 .../Runtime/Binding/PythonSetMemberBinder.cs | 0 .../Runtime/Binding/PythonSetSliceBinder.cs | 0 .../Binding/PythonUnaryOperationBinder.cs | 0 .../Binding/SiteLocalStorageBuilder.cs | 0 .../Runtime/Binding/SlotOrFunction.cs | 0 .../Runtime/Binding/WarningInfo.cs | 0 .../IronPython}/Runtime/BufferProtocol.cs | 0 .../Runtime/BuiltinPythonModule.cs | 0 .../Runtime/BuiltinsDictionaryStorage.cs | 0 .../IronPython}/Runtime/ByteArray.cs | 0 .../IronPython}/Runtime/ByteArrayIterator.cs | 0 .../IronPython}/Runtime/Bytes.cs | 0 .../IronPython}/Runtime/BytesIterator.cs | 0 .../IronPython}/Runtime/BytesLikeAttribute.cs | 0 .../Runtime/ClassMethodAttribute.cs | 0 .../Runtime/ClassMethodDescriptor.cs | 0 .../IronPython}/Runtime/ClrModule.cs | 0 .../IronPython}/Runtime/CodeContext.cs | 0 .../Runtime/CollectionDebugView.cs | 0 .../Runtime/CommonDictionaryStorage.cs | 0 .../IronPython}/Runtime/CompareUtil.cs | 0 .../IronPython}/Runtime/CompileFlags.cs | 0 .../IronPython}/Runtime/CompiledLoader.cs | 0 .../Runtime/ConstantDictionaryStorage.cs | 0 .../IronPython}/Runtime/ConversionWrappers.cs | 0 .../IronPython}/Runtime/Converter.cs | 0 .../Runtime/CustomDictionaryStorage.cs | 0 .../Runtime/DebuggerDictionaryStorage.cs | 0 .../IronPython}/Runtime/DefaultContext.cs | 0 .../IronPython}/Runtime/Descriptors.cs | 0 .../IronPython}/Runtime/DictionaryOps.cs | 0 .../IronPython}/Runtime/DictionaryStorage.cs | 0 .../Runtime/DictionaryTypeInfoAttribute.cs | 0 .../DontMapGetMemberNamesToDirAttribute.cs | 0 .../DontMapICollectionToLenAttribute.cs | 0 ...MapIDisposableToContextManagerAttribute.cs | 0 .../DontMapIEnumerableToContainsAttribute.cs | 0 .../DontMapIEnumerableToIterAttribute.cs | 0 .../Runtime/EmptyDictionaryStorage.cs | 0 .../IronPython}/Runtime/Enumerate.cs | 0 .../IronPython}/Runtime/ErrorCodes.cs | 0 .../AssertionException.Generated.cs | 0 .../Exceptions/AttributeErrorException.cs | 0 .../BlockingIOException.Generated.cs | 0 .../BrokenPipeException.Generated.cs | 0 .../Exceptions/BufferException.Generated.cs | 0 .../BytesWarningException.Generated.cs | 0 .../ChildProcessException.Generated.cs | 0 .../ConnectionAbortedException.Generated.cs | 0 .../ConnectionException.Generated.cs | 0 .../ConnectionRefusedException.Generated.cs | 0 .../ConnectionResetException.Generated.cs | 0 .../DeprecationWarningException.Generated.cs | 0 .../FileExistsException.Generated.cs | 0 .../FloatingPointException.Generated.cs | 0 .../FutureWarningException.Generated.cs | 0 .../Exceptions/GeneratorExitException.cs | 0 .../Exceptions/ImportException.Generated.cs | 0 .../ImportWarningException.Generated.cs | 0 .../Exceptions/IndentationException.cs | 0 .../InterruptedException.Generated.cs | 0 .../IsADirectoryException.Generated.cs | 0 .../Exceptions/LookupException.Generated.cs | 0 .../Exceptions/ModuleNotFoundException.cs | 0 .../NotADirectoryException.Generated.cs | 0 .../Exceptions/OSException.Generated.cs | 0 ...ngDeprecationWarningException.Generated.cs | 0 .../ProcessLookupException.Generated.cs | 0 .../Runtime/Exceptions/PythonException.cs | 0 .../PythonExceptions.BaseException.cs | 0 .../Exceptions/PythonExceptions.Generated.cs | 0 .../Runtime/Exceptions/PythonExceptions.cs | 0 .../RecursionException.Generated.cs | 0 .../ReferenceException.Generated.cs | 0 .../ResourceWarningException.Generated.cs | 0 .../Exceptions/RuntimeException.Generated.cs | 0 .../RuntimeWarningException.Generated.cs | 0 .../StopAsyncIterationException.Generated.cs | 0 .../StopIterationException.Generated.cs | 0 .../SyntaxWarningException.Generated.cs | 0 .../Runtime/Exceptions/SystemExitException.cs | 0 .../Runtime/Exceptions/TabException.cs | 0 .../Runtime/Exceptions/TraceBack.cs | 0 .../Runtime/Exceptions/TypeErrorException.cs | 0 .../Exceptions/UnicodeException.Generated.cs | 0 .../UnicodeTranslateException.Generated.cs | 0 .../UnicodeWarningException.Generated.cs | 0 .../UserWarningException.Generated.cs | 0 .../Runtime/Exceptions/ValueErrorException.cs | 0 .../IronPython}/Runtime/ExtensionMethodSet.cs | 0 .../IronPython}/Runtime/Filter.cs | 0 .../IronPython}/Runtime/FormattingHelper.cs | 0 .../IronPython}/Runtime/FunctionAttributes.cs | 0 .../IronPython}/Runtime/FunctionCode.cs | 0 .../IronPython}/Runtime/Generator.cs | 0 .../Runtime/GlobalDictionaryStorage.cs | 0 .../IronPython}/Runtime/IParameterSequence.cs | 0 .../IronPython}/Runtime/Implementation.cs | 0 .../IronPython}/Runtime/Importer.cs | 0 .../IronPython}/Runtime/Index.cs | 0 .../InstancedModuleDictionaryStorage.cs | 0 .../IronPython}/Runtime/Interfaces.cs | 0 .../IronPython}/Runtime/KwCallInfo.cs | 0 .../IronPython}/Runtime/LiteralParser.cs | 0 {IronPython => Src/IronPython}/Runtime/Map.cs | 0 .../Runtime/MaybeNotImplementedAttribute.cs | 0 .../Runtime/MemoryStreamContentProvider.cs | 0 .../IronPython}/Runtime/MemoryView.cs | 0 .../IronPython}/Runtime/Method.Generated.cs | 0 .../IronPython}/Runtime/Method.cs | 0 .../IronPython}/Runtime/MissingParameter.cs | 0 .../IronPython}/Runtime/ModuleContext.cs | 0 .../Runtime/ModuleDictionaryStorage.cs | 0 .../IronPython}/Runtime/ModuleGlobalCache.cs | 0 .../IronPython}/Runtime/ModuleLoader.cs | 0 .../IronPython}/Runtime/ModuleOptions.cs | 0 .../IronPython}/Runtime/NameType.cs | 0 .../IronPython}/Runtime/NewStringFormatter.cs | 0 .../Runtime/ObjectAttributesAdapter.cs | 0 .../IronPython}/Runtime/ObjectDebugView.cs | 0 .../Runtime/Operations/ArrayOps.cs | 0 .../Runtime/Operations/BigIntegerOps.cs | 0 .../IronPython}/Runtime/Operations/BoolOps.cs | 0 .../IronPython}/Runtime/Operations/ByteOps.cs | 0 .../IronPython}/Runtime/Operations/CharOps.cs | 0 .../IronPython}/Runtime/Operations/ComOps.cs | 0 .../Runtime/Operations/ComplexOps.cs | 0 .../Operations/CustomTypeDescHelpers.cs | 0 .../Runtime/Operations/DBNullOps.cs | 0 .../Runtime/Operations/DateTimeOps.cs | 0 .../Runtime/Operations/DecimalOps.cs | 0 .../Runtime/Operations/DelegateOps.cs | 0 .../Runtime/Operations/DictionaryOfTOps.cs | 0 .../IronPython}/Runtime/Operations/EnumOps.cs | 0 .../Runtime/Operations/FloatOps.Generated.cs | 0 .../Runtime/Operations/FloatOps.cs | 0 .../Runtime/Operations/IListOfByteOps.cs | 0 .../Runtime/Operations/InstanceOps.cs | 0 .../Runtime/Operations/IntOps.Generated.cs | 0 .../IronPython}/Runtime/Operations/IntOps.cs | 0 .../Runtime/Operations/IntPtrOps.cs | 0 .../Runtime/Operations/ListOfTOps.cs | 0 .../Runtime/Operations/MarshalOps.cs | 0 .../Runtime/Operations/NamespaceTrackerOps.cs | 0 .../Runtime/Operations/ObjectOps.cs | 0 .../Runtime/Operations/PythonCalls.cs | 0 .../Runtime/Operations/PythonOps.Generated.cs | 0 .../Runtime/Operations/PythonOps.cs | 0 .../Runtime/Operations/PythonTypeOps.cs | 0 .../Runtime/Operations/StringOps.Generated.cs | 0 .../Runtime/Operations/StringOps.cs | 0 .../Runtime/Operations/TypeGroupOps.cs | 0 .../Runtime/Operations/TypeTrackerOps.cs | 0 .../Runtime/Operations/UIntPtrOps.cs | 0 .../Runtime/Operations/UserTypeOps.cs | 0 .../IronPython}/Runtime/OutputWriter.cs | 0 .../IronPython}/Runtime/PlatformsAttribute.cs | 0 .../IronPython}/Runtime/Profiler.cs | 0 .../Runtime/PythonContext.Generated.cs | 0 .../IronPython}/Runtime/PythonContext.cs | 0 .../IronPython}/Runtime/PythonDictionary.cs | 0 .../Runtime/PythonDocumentationProvider.cs | 0 .../Runtime/PythonDynamicStackFrame.cs | 0 .../IronPython}/Runtime/PythonEncoding.cs | 0 .../IronPython}/Runtime/PythonFileManager.cs | 0 .../Runtime/PythonFunction.Generated.cs | 0 .../IronPython}/Runtime/PythonFunction.cs | 0 .../Runtime/PythonHiddenAttribute.cs | 0 .../Runtime/PythonHiddenBaseClassAttribute.cs | 0 .../IronPython}/Runtime/PythonList.cs | 0 .../IronPython}/Runtime/PythonModule.cs | 0 .../Runtime/PythonModuleAttribute.cs | 0 .../IronPython}/Runtime/PythonNarrowing.cs | 0 .../IronPython}/Runtime/PythonOptions.cs | 0 .../IronPython}/Runtime/PythonRange.cs | 0 .../Runtime/PythonScopeExtension.cs | 0 .../IronPython}/Runtime/PythonStrIterator.cs | 0 .../Runtime/PythonTracebackListener.cs | 0 .../IronPython}/Runtime/PythonTuple.cs | 0 .../Runtime/PythonTypeAttribute.cs | 0 .../IronPython}/Runtime/Reversed.cs | 0 .../RuntimeVariablesDictionaryStorage.cs | 0 .../Runtime/ScopeDictionaryStorage.cs | 0 .../Runtime/SequenceTypeInfoAttribute.cs | 0 {IronPython => Src/IronPython}/Runtime/Set.cs | 0 .../IronPython}/Runtime/SetStorage.cs | 0 .../IronPython}/Runtime/SimpleNamespace.cs | 0 .../IronPython}/Runtime/SiteLocalStorage.cs | 0 .../IronPython}/Runtime/Slice.cs | 0 .../Runtime/StringDictionaryStorage.cs | 0 .../IronPython}/Runtime/StringFormatSpec.cs | 0 .../IronPython}/Runtime/StringFormatter.cs | 0 .../IronPython}/Runtime/Super.cs | 0 .../IronPython}/Runtime/Symbols.Generated.cs | 0 .../IronPython}/Runtime/ThrowingErrorSink.cs | 0 .../IronPython}/Runtime/TypecodeOps.cs | 0 .../Runtime/Types/BuiltinFunction.cs | 0 .../Types/BuiltinFunctionOverloadMapper.cs | 0 .../Runtime/Types/BuiltinMethodDescriptor.cs | 0 .../Runtime/Types/CachedNewTypeInfo.cs | 0 .../Runtime/Types/ConstructorFunction.cs | 0 .../Runtime/Types/CustomAttributeTracker.cs | 0 .../Types/CustomInstanceDictionaryStorage.cs | 0 .../IronPython}/Runtime/Types/DocBuilder.cs | 0 .../Runtime/Types/DynamicBaseTypeAttribute.cs | 0 .../Runtime/Types/DynamicHelpers.cs | 0 .../IronPython}/Runtime/Types/EmptyType.cs | 0 .../Runtime/Types/ExtensionPropertyInfo.cs | 0 .../IronPython}/Runtime/Types/FunctionType.cs | 0 .../Runtime/Types/IPythonObject.cs | 0 .../Runtime/Types/InstanceCreator.cs | 0 .../IronPython}/Runtime/Types/MappingProxy.cs | 0 .../IronPython}/Runtime/Types/Mro.cs | 0 .../Runtime/Types/NameConverter.cs | 0 .../IronPython}/Runtime/Types/NewTypeInfo.cs | 0 .../IronPython}/Runtime/Types/NewTypeMaker.cs | 0 .../Runtime/Types/OperatorMapping.cs | 0 .../Runtime/Types/ParameterInfoWrapper.cs | 0 .../Runtime/Types/PythonAssemblyOps.cs | 0 .../Runtime/Types/PythonSiteCache.cs | 0 .../Runtime/Types/PythonType.Generated.cs | 0 .../IronPython}/Runtime/Types/PythonType.cs | 0 .../Runtime/Types/PythonTypeDataSlot.cs | 0 .../Runtime/Types/PythonTypeDictSlot.cs | 0 .../Runtime/Types/PythonTypeInfo.Generated.cs | 0 .../Runtime/Types/PythonTypeInfo.cs | 0 .../Runtime/Types/PythonTypeSlot.cs | 0 .../Runtime/Types/PythonTypeTypeSlot.cs | 0 .../Types/PythonTypeUserDescriptorSlot.cs | 0 .../Runtime/Types/PythonTypeWeakRefSlot.cs | 0 .../Runtime/Types/ReflectedEvent.cs | 0 .../Types/ReflectedExtensionProperty.cs | 0 .../Runtime/Types/ReflectedField.cs | 0 .../Runtime/Types/ReflectedGetterSetter.cs | 0 .../Runtime/Types/ReflectedIndexer.cs | 0 .../Runtime/Types/ReflectedProperty.cs | 0 .../Runtime/Types/ReflectedSlotProperty.cs | 0 .../Runtime/Types/ResolvedMember.cs | 0 .../Runtime/Types/SlotFieldAttribute.cs | 0 .../Types/StaticUnderlyingSystemType.cs | 0 .../Runtime/Types/TypeCache.Generated.cs | 0 .../Runtime/UnboundNameException.cs | 0 .../IronPython}/Runtime/WeakRef.cs | 0 .../Runtime/WrapperDescriptorAttribute.cs | 0 .../IronPython}/Runtime/WrapperDictionary.cs | 0 {IronPython => Src/IronPython}/Runtime/Zip.cs | 0 .../IronPython}/SerializationStubs.cs | 0 .../IronPython}/StringExtensions.cs | 0 .../IronPython}/SystemRuntimeVersioning.cs | 0 .../IronPython}/policy.IronPython.config | 0 .../Modules}/IronPython.Modules.csproj | 4 +-- {Modules => Src/Modules}/IterTools.cs | 0 {Modules => Src/Modules}/ModuleOps.cs | 0 {Modules => Src/Modules}/NtSignalState.cs | 0 .../Modules}/Properties/AssemblyInfo.cs | 0 .../Modules}/ResourceMetaPathImporter.cs | 0 {Modules => Src/Modules}/SimpleSignalState.cs | 0 {Modules => Src/Modules}/_bisect.cs | 0 {Modules => Src/Modules}/_codecs.cs | 0 {Modules => Src/Modules}/_codecs_cn.cs | 0 {Modules => Src/Modules}/_collections.cs | 0 {Modules => Src/Modules}/_csv.cs | 0 {Modules => Src/Modules}/_ctypes/Array.cs | 0 {Modules => Src/Modules}/_ctypes/ArrayType.cs | 0 {Modules => Src/Modules}/_ctypes/CData.cs | 0 {Modules => Src/Modules}/_ctypes/CFuncPtr.cs | 0 .../Modules}/_ctypes/CFuncPtrType.cs | 0 .../Modules}/_ctypes/Extensions.cs | 0 {Modules => Src/Modules}/_ctypes/Field.cs | 0 .../Modules}/_ctypes/INativeType.cs | 0 .../Modules}/_ctypes/LocalOrArg.cs | 0 .../Modules}/_ctypes/MarshalCleanup.cs | 0 .../Modules}/_ctypes/MemoryHolder.cs | 0 .../Modules}/_ctypes/NativeArgument.cs | 0 .../Modules}/_ctypes/NativeFunctions.cs | 0 {Modules => Src/Modules}/_ctypes/Pointer.cs | 0 .../Modules}/_ctypes/PointerType.cs | 0 .../Modules}/_ctypes/SimpleCData.cs | 0 .../Modules}/_ctypes/SimpleType.cs | 0 .../Modules}/_ctypes/SimpleTypeKind.cs | 0 .../Modules}/_ctypes/StructType.cs | 0 {Modules => Src/Modules}/_ctypes/Structure.cs | 0 {Modules => Src/Modules}/_ctypes/Union.cs | 0 {Modules => Src/Modules}/_ctypes/UnionType.cs | 0 {Modules => Src/Modules}/_ctypes/_ctypes.cs | 0 {Modules => Src/Modules}/_ctypes_test.cs | 0 {Modules => Src/Modules}/_datetime.cs | 0 {Modules => Src/Modules}/_functools.cs | 0 {Modules => Src/Modules}/_heapq.cs | 0 {Modules => Src/Modules}/_multibytecodec.cs | 0 {Modules => Src/Modules}/_multiprocessing.cs | 0 {Modules => Src/Modules}/_opcode.cs | 0 {Modules => Src/Modules}/_operator.cs | 0 {Modules => Src/Modules}/_overlapped.cs | 0 {Modules => Src/Modules}/_pickle.cs | 0 {Modules => Src/Modules}/_posixsubprocess.cs | 0 {Modules => Src/Modules}/_random.RandomGen.cs | 0 {Modules => Src/Modules}/_random.cs | 0 {Modules => Src/Modules}/_socket.cs | 0 {Modules => Src/Modules}/_sre.cs | 0 {Modules => Src/Modules}/_ssl.cs | 0 {Modules => Src/Modules}/_string.cs | 0 {Modules => Src/Modules}/_struct.cs | 0 {Modules => Src/Modules}/_sysconfigdata.cs | 0 {Modules => Src/Modules}/_thread.cs | 0 {Modules => Src/Modules}/_warnings.cs | 0 .../Modules}/_weakref.Generated.cs | 0 {Modules => Src/Modules}/_weakref.cs | 0 {Modules => Src/Modules}/_winapi.cs | 0 {Modules => Src/Modules}/array.cs | 0 {Modules => Src/Modules}/atexit.cs | 0 {Modules => Src/Modules}/audioop.cs | 0 {Modules => Src/Modules}/binascii.cs | 0 {Modules => Src/Modules}/bz2/BZ2Compressor.cs | 0 .../Modules}/bz2/BZ2Decompressor.cs | 0 {Modules => Src/Modules}/bz2/BZ2Module.cs | 0 .../bz2/dotnetzip/BZip2/BZip2Compressor.cs | 0 .../bz2/dotnetzip/BZip2/BZip2InputStream.cs | 0 .../bz2/dotnetzip/BZip2/BZip2OutputStream.cs | 0 .../Modules}/bz2/dotnetzip/BZip2/BitWriter.cs | 0 .../Modules}/bz2/dotnetzip/BZip2/CRC32.cs | 0 .../BZip2/ParallelBZip2OutputStream.cs | 0 .../Modules}/bz2/dotnetzip/BZip2/Rand.cs | 0 .../Modules}/bz2/dotnetzip/source.txt | 0 {Modules => Src/Modules}/cmath.cs | 0 {Modules => Src/Modules}/errno.cs | 0 {Modules => Src/Modules}/faulthandler.cs | 0 {Modules => Src/Modules}/fcntl.cs | 0 {Modules => Src/Modules}/gc.cs | 0 {Modules => Src/Modules}/grp.cs | 0 .../hashlib/MD5CryptoServiceProvider.cs | 0 .../hashlib/SHA1CryptoServiceProvider.cs | 0 {Modules => Src/Modules}/hashlib/SHA224.cs | 0 .../Modules}/hashlib/SHA224Managed.cs | 0 .../Modules}/hashlib/SHA256Managed.cs | 0 .../Modules}/hashlib/SHA384Managed.cs | 0 .../Modules}/hashlib/SHA512Managed.cs | 0 .../Modules}/hashlib/SHAConstants.cs | 0 {Modules => Src/Modules}/hashlib/_hashlib.cs | 0 {Modules => Src/Modules}/hashlib/_md5.cs | 0 {Modules => Src/Modules}/hashlib/_sha1.cs | 0 {Modules => Src/Modules}/hashlib/_sha256.cs | 0 {Modules => Src/Modules}/hashlib/_sha512.cs | 0 {Modules => Src/Modules}/marshal.cs | 0 {Modules => Src/Modules}/math.Generated.cs | 0 {Modules => Src/Modules}/math.cs | 0 {Modules => Src/Modules}/mmap.cs | 0 {Modules => Src/Modules}/msvcrt.cs | 0 {Modules => Src/Modules}/nt.cs | 0 .../Modules}/policy.IronPython.Modules.config | 0 {Modules => Src/Modules}/pwd.cs | 0 {Modules => Src/Modules}/pyexpat.cs | 0 {Modules => Src/Modules}/re.cs | 0 {Modules => Src/Modules}/resource.cs | 0 {Modules => Src/Modules}/select.cs | 0 {Modules => Src/Modules}/signal.cs | 0 {Modules => Src/Modules}/spwd.cs | 0 {Modules => Src/Modules}/time.cs | 0 {Modules => Src/Modules}/winreg.cs | 0 {Modules => Src/Modules}/winsound.cs | 0 {Modules => Src/Modules}/xxsubtype.cs | 0 {Modules => Src/Modules}/zipimport.cs | 0 {Modules => Src/Modules}/zlib/Compress.cs | 0 {Modules => Src/Modules}/zlib/Decompress.cs | 0 {Modules => Src/Modules}/zlib/ZlibModule.cs | 0 .../Modules}/zlib/zlib.net/Adler32.cs | 0 .../Modules}/zlib/zlib.net/Deflate.cs | 0 .../Modules}/zlib/zlib.net/InfBlocks.cs | 0 .../Modules}/zlib/zlib.net/InfCodes.cs | 0 .../Modules}/zlib/zlib.net/InfTree.cs | 0 .../Modules}/zlib/zlib.net/Inflate.cs | 0 .../Modules}/zlib/zlib.net/StaticTree.cs | 0 .../Modules}/zlib/zlib.net/Tree.cs | 0 .../Modules}/zlib/zlib.net/ZStream.cs | 0 .../zlib/zlib.net/ZStreamException.cs | 0 .../Modules}/zlib/zlib.net/Zlib.cs | 0 .../Modules}/zlib/zlib.net/history.txt | 0 .../Modules}/zlib/zlib.net/license.txt | 0 .../Modules}/zlib/zlib.net/readme.txt | 0 {IronPython => Src}/README.md | 0 {SQLite => Src/SQLite}/Connection.cs | 0 {SQLite => Src/SQLite}/Contants.cs | 0 {SQLite => Src/SQLite}/Cursor.cs | 0 {SQLite => Src/SQLite}/Exceptions.cs | 0 {SQLite => Src/SQLite}/Extensions.cs | 0 .../SQLite}/IronPython.SQLite.csproj | 0 .../SQLite}/Properties/AssemblyInfo.cs | 0 {SQLite => Src/SQLite}/Row.cs | 0 {SQLite => Src/SQLite}/Statement.cs | 0 {SQLite => Src/SQLite}/Util.cs | 0 {SQLite => Src/SQLite}/_sqlite.cs | 0 {SQLite => Src/SQLite}/c#sqlite/.editorconfig | 0 {SQLite => Src/SQLite}/c#sqlite/BtreeInt_h.cs | 0 {SQLite => Src/SQLite}/c#sqlite/Btree_h.cs | 0 {SQLite => Src/SQLite}/c#sqlite/Delegates.cs | 0 {SQLite => Src/SQLite}/c#sqlite/Hash_h.cs | 0 {SQLite => Src/SQLite}/c#sqlite/VdbeInt_h.cs | 0 {SQLite => Src/SQLite}/c#sqlite/Vdbe_h.cs | 0 {SQLite => Src/SQLite}/c#sqlite/_Custom.cs | 0 {SQLite => Src/SQLite}/c#sqlite/alter_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/analyze_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/attach_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/auth_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/backup_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/bitvec_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/btmutex_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/btree_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/build_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/callback_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/complete_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/crypto.cs | 0 {SQLite => Src/SQLite}/c#sqlite/ctime_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/date_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/delete_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/expr_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/fault_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/fkey_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/func_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/global_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/hash_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/hwtime_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/insert_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/journal_c.cs | 0 .../SQLite}/c#sqlite/keywordhash_h.cs | 0 {SQLite => Src/SQLite}/c#sqlite/legacy_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/loadext_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/main_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/malloc_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/mem_Pool.cs | 0 .../SQLite}/c#sqlite/memjournal_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/mutex_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/mutex_h.cs | 0 .../SQLite}/c#sqlite/mutex_noop_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/mutex_w32.cs | 0 {SQLite => Src/SQLite}/c#sqlite/notify_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/opcodes_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/opcodes_h.cs | 0 {SQLite => Src/SQLite}/c#sqlite/os_c.cs | 0 .../SQLite}/c#sqlite/os_common_h.cs | 0 {SQLite => Src/SQLite}/c#sqlite/os_h.cs | 0 {SQLite => Src/SQLite}/c#sqlite/os_win_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/pager_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/pager_h.cs | 0 {SQLite => Src/SQLite}/c#sqlite/parse_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/parse_h.cs | 0 {SQLite => Src/SQLite}/c#sqlite/pcache1_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/pcache_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/pcache_h.cs | 0 {SQLite => Src/SQLite}/c#sqlite/pragma_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/prepare_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/printf_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/random_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/resolve_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/rowset_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/select_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/sqlite3_h.cs | 0 .../SQLite}/c#sqlite/sqliteInt_h.cs | 0 .../SQLite}/c#sqlite/sqliteLimit_h.cs | 0 {SQLite => Src/SQLite}/c#sqlite/status_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/table_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/tokenize_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/trigger_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/update_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/utf_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/util_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/vacuum_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/vdbe_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/vdbeapi_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/vdbeaux_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/vdbeblob_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/vdbemem_c.cs | 0 .../SQLite}/c#sqlite/vdbetrace_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/vtab_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/wal_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/wal_h.cs | 0 {SQLite => Src/SQLite}/c#sqlite/walker_c.cs | 0 {SQLite => Src/SQLite}/c#sqlite/where_c.cs | 0 {Scripts => Src/Scripts}/CompareDirs.py | 0 .../Scripts}/Enter-IronPythonEnvironment.ps1 | 0 .../Scripts}/Install-IronPython.ps1 | 0 {Scripts => Src/Scripts}/clean.py | 0 {Scripts => Src/Scripts}/copyrights.py | 0 {Scripts => Src/Scripts}/generate.py | 0 .../generate_UncollectableCompilationMode.py | 0 {Scripts => Src/Scripts}/generate_alltypes.py | 0 {Scripts => Src/Scripts}/generate_calls.py | 0 {Scripts => Src/Scripts}/generate_casts.py | 0 .../Scripts}/generate_comdispatch.py | 0 .../Scripts}/generate_dict_views.py | 0 .../Scripts}/generate_dynamic_instructions.py | 0 {Scripts => Src/Scripts}/generate_dynsites.py | 0 .../Scripts}/generate_encoding_aliases.py | 0 .../Scripts}/generate_exception_factory.py | 0 .../Scripts}/generate_exceptions.py | 0 .../Scripts}/generate_indicestest.py | 0 {Scripts => Src/Scripts}/generate_math.py | 0 {Scripts => Src/Scripts}/generate_ops.py | 0 {Scripts => Src/Scripts}/generate_os_codes.py | 0 .../Scripts}/generate_reflected_calls.py | 0 {Scripts => Src/Scripts}/generate_set.py | 0 {Scripts => Src/Scripts}/generate_tuples.py | 0 .../Scripts}/generate_typecache.py | 0 {Scripts => Src/Scripts}/generate_walker.py | 0 {Scripts => Src/Scripts}/ipcom.ps1 | 0 {Scripts => Src/Scripts}/make_meta1.py | 0 {Scripts => Src/Scripts}/radix_generator.py | 0 {Scripts => Src/Scripts}/run_compiled.py | 0 {Scripts => Src/Scripts}/run_interactive.py | 0 {Scripts => Src/Scripts}/smtpmailer.py | 0 {Scripts => Src/Scripts}/test_builder.py | 0 {Scripts => Src/Scripts}/test_cgcheck.py | 0 {Scripts => Src/Scripts}/test_parrot.py | 0 {Scripts => Src/Scripts}/test_pystone.py | 0 {StdLib => Src/StdLib}/.gitattributes | 0 {StdLib => Src/StdLib}/Lib/__future__.py | 0 {StdLib => Src/StdLib}/Lib/__phello__.foo.py | 0 {StdLib => Src/StdLib}/Lib/_bootlocale.py | 0 .../StdLib}/Lib/_collections_abc.py | 0 {StdLib => Src/StdLib}/Lib/_compat_pickle.py | 0 {StdLib => Src/StdLib}/Lib/_dummy_thread.py | 0 {StdLib => Src/StdLib}/Lib/_markupbase.py | 0 {StdLib => Src/StdLib}/Lib/_osx_support.py | 0 {StdLib => Src/StdLib}/Lib/_pyio.py | 0 {StdLib => Src/StdLib}/Lib/_sitebuiltins.py | 0 {StdLib => Src/StdLib}/Lib/_strptime.py | 0 .../StdLib}/Lib/_threading_local.py | 0 {StdLib => Src/StdLib}/Lib/_weakrefset.py | 0 {StdLib => Src/StdLib}/Lib/abc.py | 0 {StdLib => Src/StdLib}/Lib/aifc.py | 0 {StdLib => Src/StdLib}/Lib/antigravity.py | 0 {StdLib => Src/StdLib}/Lib/argparse.py | 0 {StdLib => Src/StdLib}/Lib/ast.py | 0 {StdLib => Src/StdLib}/Lib/asynchat.py | 0 .../StdLib}/Lib/asyncio/__init__.py | 0 .../StdLib}/Lib/asyncio/base_events.py | 0 .../StdLib}/Lib/asyncio/base_subprocess.py | 0 {StdLib => Src/StdLib}/Lib/asyncio/compat.py | 0 .../StdLib}/Lib/asyncio/constants.py | 0 .../StdLib}/Lib/asyncio/coroutines.py | 0 {StdLib => Src/StdLib}/Lib/asyncio/events.py | 0 {StdLib => Src/StdLib}/Lib/asyncio/futures.py | 0 {StdLib => Src/StdLib}/Lib/asyncio/locks.py | 0 {StdLib => Src/StdLib}/Lib/asyncio/log.py | 0 .../StdLib}/Lib/asyncio/proactor_events.py | 0 .../StdLib}/Lib/asyncio/protocols.py | 0 {StdLib => Src/StdLib}/Lib/asyncio/queues.py | 0 .../StdLib}/Lib/asyncio/selector_events.py | 0 .../StdLib}/Lib/asyncio/sslproto.py | 0 {StdLib => Src/StdLib}/Lib/asyncio/streams.py | 0 .../StdLib}/Lib/asyncio/subprocess.py | 0 {StdLib => Src/StdLib}/Lib/asyncio/tasks.py | 0 .../StdLib}/Lib/asyncio/test_utils.py | 0 .../StdLib}/Lib/asyncio/transports.py | 0 .../StdLib}/Lib/asyncio/unix_events.py | 0 .../StdLib}/Lib/asyncio/windows_events.py | 0 .../StdLib}/Lib/asyncio/windows_utils.py | 0 {StdLib => Src/StdLib}/Lib/asyncore.py | 0 {StdLib => Src/StdLib}/Lib/base64.py | 0 {StdLib => Src/StdLib}/Lib/bdb.py | 0 {StdLib => Src/StdLib}/Lib/binhex.py | 0 {StdLib => Src/StdLib}/Lib/bisect.py | 0 {StdLib => Src/StdLib}/Lib/bz2.py | 0 {StdLib => Src/StdLib}/Lib/cProfile.py | 0 {StdLib => Src/StdLib}/Lib/calendar.py | 0 {StdLib => Src/StdLib}/Lib/cgi.py | 0 {StdLib => Src/StdLib}/Lib/cgitb.py | 0 {StdLib => Src/StdLib}/Lib/chunk.py | 0 {StdLib => Src/StdLib}/Lib/clrtype.py | 0 {StdLib => Src/StdLib}/Lib/cmd.py | 0 {StdLib => Src/StdLib}/Lib/code.py | 0 {StdLib => Src/StdLib}/Lib/codecs.py | 0 {StdLib => Src/StdLib}/Lib/codeop.py | 0 .../StdLib}/Lib/collections/__init__.py | 0 .../StdLib}/Lib/collections/__main__.py | 0 {StdLib => Src/StdLib}/Lib/collections/abc.py | 0 {StdLib => Src/StdLib}/Lib/colorsys.py | 0 {StdLib => Src/StdLib}/Lib/compileall.py | 0 .../StdLib}/Lib/concurrent/__init__.py | 0 .../Lib/concurrent/futures/__init__.py | 0 .../StdLib}/Lib/concurrent/futures/_base.py | 0 .../StdLib}/Lib/concurrent/futures/process.py | 0 .../StdLib}/Lib/concurrent/futures/thread.py | 0 {StdLib => Src/StdLib}/Lib/configparser.py | 0 {StdLib => Src/StdLib}/Lib/contextlib.py | 0 {StdLib => Src/StdLib}/Lib/copy.py | 0 {StdLib => Src/StdLib}/Lib/copyreg.py | 0 {StdLib => Src/StdLib}/Lib/crypt.py | 0 {StdLib => Src/StdLib}/Lib/csv.py | 0 {StdLib => Src/StdLib}/Lib/ctypes/__init__.py | 0 {StdLib => Src/StdLib}/Lib/ctypes/_endian.py | 0 .../StdLib}/Lib/ctypes/macholib/README.ctypes | 0 .../StdLib}/Lib/ctypes/macholib/__init__.py | 0 .../StdLib}/Lib/ctypes/macholib/dyld.py | 0 .../StdLib}/Lib/ctypes/macholib/dylib.py | 0 .../Lib/ctypes/macholib/fetch_macholib | 0 .../Lib/ctypes/macholib/fetch_macholib.bat | 0 .../StdLib}/Lib/ctypes/macholib/framework.py | 0 .../StdLib}/Lib/ctypes/test/__init__.py | 0 .../StdLib}/Lib/ctypes/test/__main__.py | 0 .../StdLib}/Lib/ctypes/test/test_anon.py | 0 .../Lib/ctypes/test/test_array_in_pointer.py | 0 .../StdLib}/Lib/ctypes/test/test_arrays.py | 0 .../Lib/ctypes/test/test_as_parameter.py | 0 .../StdLib}/Lib/ctypes/test/test_bitfields.py | 0 .../StdLib}/Lib/ctypes/test/test_buffers.py | 0 .../StdLib}/Lib/ctypes/test/test_bytes.py | 0 .../StdLib}/Lib/ctypes/test/test_byteswap.py | 0 .../StdLib}/Lib/ctypes/test/test_callbacks.py | 0 .../StdLib}/Lib/ctypes/test/test_cast.py | 0 .../StdLib}/Lib/ctypes/test/test_cfuncs.py | 0 .../Lib/ctypes/test/test_checkretval.py | 0 .../StdLib}/Lib/ctypes/test/test_delattr.py | 0 .../StdLib}/Lib/ctypes/test/test_errno.py | 0 .../StdLib}/Lib/ctypes/test/test_find.py | 0 .../Lib/ctypes/test/test_frombuffer.py | 0 .../StdLib}/Lib/ctypes/test/test_funcptr.py | 0 .../StdLib}/Lib/ctypes/test/test_functions.py | 0 .../Lib/ctypes/test/test_incomplete.py | 0 .../StdLib}/Lib/ctypes/test/test_init.py | 0 .../StdLib}/Lib/ctypes/test/test_internals.py | 0 .../StdLib}/Lib/ctypes/test/test_keeprefs.py | 0 .../StdLib}/Lib/ctypes/test/test_libc.py | 0 .../StdLib}/Lib/ctypes/test/test_loading.py | 0 .../StdLib}/Lib/ctypes/test/test_macholib.py | 0 .../Lib/ctypes/test/test_memfunctions.py | 0 .../StdLib}/Lib/ctypes/test/test_numbers.py | 0 .../StdLib}/Lib/ctypes/test/test_objects.py | 0 .../Lib/ctypes/test/test_parameters.py | 0 .../StdLib}/Lib/ctypes/test/test_pep3118.py | 0 .../StdLib}/Lib/ctypes/test/test_pickling.py | 0 .../StdLib}/Lib/ctypes/test/test_pointers.py | 0 .../Lib/ctypes/test/test_prototypes.py | 0 .../Lib/ctypes/test/test_python_api.py | 0 .../Lib/ctypes/test/test_random_things.py | 0 .../StdLib}/Lib/ctypes/test/test_refcounts.py | 0 .../StdLib}/Lib/ctypes/test/test_repr.py | 0 .../Lib/ctypes/test/test_returnfuncptrs.py | 0 .../Lib/ctypes/test/test_simplesubclasses.py | 0 .../StdLib}/Lib/ctypes/test/test_sizes.py | 0 .../StdLib}/Lib/ctypes/test/test_slicing.py | 0 .../StdLib}/Lib/ctypes/test/test_stringptr.py | 0 .../StdLib}/Lib/ctypes/test/test_strings.py | 0 .../Lib/ctypes/test/test_struct_fields.py | 0 .../Lib/ctypes/test/test_structures.py | 0 .../ctypes/test/test_unaligned_structures.py | 0 .../StdLib}/Lib/ctypes/test/test_unicode.py | 0 .../StdLib}/Lib/ctypes/test/test_values.py | 0 .../Lib/ctypes/test/test_varsize_struct.py | 0 .../StdLib}/Lib/ctypes/test/test_win32.py | 0 .../StdLib}/Lib/ctypes/test/test_wintypes.py | 0 {StdLib => Src/StdLib}/Lib/ctypes/util.py | 0 {StdLib => Src/StdLib}/Lib/ctypes/wintypes.py | 0 {StdLib => Src/StdLib}/Lib/curses/__init__.py | 0 {StdLib => Src/StdLib}/Lib/curses/ascii.py | 0 {StdLib => Src/StdLib}/Lib/curses/has_key.py | 0 {StdLib => Src/StdLib}/Lib/curses/panel.py | 0 {StdLib => Src/StdLib}/Lib/curses/textpad.py | 0 {StdLib => Src/StdLib}/Lib/datetime.py | 0 {StdLib => Src/StdLib}/Lib/dbm/__init__.py | 0 {StdLib => Src/StdLib}/Lib/dbm/dumb.py | 0 {StdLib => Src/StdLib}/Lib/dbm/gnu.py | 0 {StdLib => Src/StdLib}/Lib/dbm/ndbm.py | 0 {StdLib => Src/StdLib}/Lib/decimal.py | 0 {StdLib => Src/StdLib}/Lib/difflib.py | 0 {StdLib => Src/StdLib}/Lib/dis.py | 0 {StdLib => Src/StdLib}/Lib/distutils/README | 0 .../StdLib}/Lib/distutils/__init__.py | 0 .../StdLib}/Lib/distutils/archive_util.py | 0 .../StdLib}/Lib/distutils/bcppcompiler.py | 0 .../StdLib}/Lib/distutils/ccompiler.py | 0 {StdLib => Src/StdLib}/Lib/distutils/cmd.py | 0 .../StdLib}/Lib/distutils/command/__init__.py | 0 .../StdLib}/Lib/distutils/command/bdist.py | 0 .../Lib/distutils/command/bdist_dumb.py | 0 .../Lib/distutils/command/bdist_msi.py | 0 .../Lib/distutils/command/bdist_rpm.py | 0 .../Lib/distutils/command/bdist_wininst.py | 0 .../StdLib}/Lib/distutils/command/build.py | 0 .../Lib/distutils/command/build_clib.py | 0 .../Lib/distutils/command/build_ext.py | 0 .../StdLib}/Lib/distutils/command/build_py.py | 0 .../Lib/distutils/command/build_scripts.py | 0 .../StdLib}/Lib/distutils/command/check.py | 0 .../StdLib}/Lib/distutils/command/clean.py | 0 .../Lib/distutils/command/command_template | 0 .../StdLib}/Lib/distutils/command/config.py | 0 .../StdLib}/Lib/distutils/command/install.py | 0 .../Lib/distutils/command/install_data.py | 0 .../Lib/distutils/command/install_egg_info.py | 0 .../Lib/distutils/command/install_headers.py | 0 .../Lib/distutils/command/install_lib.py | 0 .../Lib/distutils/command/install_scripts.py | 0 .../StdLib}/Lib/distutils/command/register.py | 0 .../StdLib}/Lib/distutils/command/sdist.py | 0 .../StdLib}/Lib/distutils/command/upload.py | 0 .../distutils/command/wininst-10.0-amd64.exe | Bin .../Lib/distutils/command/wininst-10.0.exe | Bin .../Lib/distutils/command/wininst-6.0.exe | Bin .../Lib/distutils/command/wininst-7.1.exe | Bin .../Lib/distutils/command/wininst-8.0.exe | Bin .../distutils/command/wininst-9.0-amd64.exe | Bin .../Lib/distutils/command/wininst-9.0.exe | Bin .../StdLib}/Lib/distutils/config.py | 0 {StdLib => Src/StdLib}/Lib/distutils/core.py | 0 .../StdLib}/Lib/distutils/cygwinccompiler.py | 0 {StdLib => Src/StdLib}/Lib/distutils/debug.py | 0 .../StdLib}/Lib/distutils/dep_util.py | 0 .../StdLib}/Lib/distutils/dir_util.py | 0 {StdLib => Src/StdLib}/Lib/distutils/dist.py | 0 .../StdLib}/Lib/distutils/errors.py | 0 .../StdLib}/Lib/distutils/extension.py | 0 .../StdLib}/Lib/distutils/fancy_getopt.py | 0 .../StdLib}/Lib/distutils/file_util.py | 0 .../StdLib}/Lib/distutils/filelist.py | 0 {StdLib => Src/StdLib}/Lib/distutils/log.py | 0 .../StdLib}/Lib/distutils/msvc9compiler.py | 0 .../StdLib}/Lib/distutils/msvccompiler.py | 0 {StdLib => Src/StdLib}/Lib/distutils/spawn.py | 0 .../StdLib}/Lib/distutils/sysconfig.py | 0 .../StdLib}/Lib/distutils/tests/Setup.sample | 0 .../StdLib}/Lib/distutils/tests/__init__.py | 0 .../StdLib}/Lib/distutils/tests/support.py | 0 .../Lib/distutils/tests/test_archive_util.py | 0 .../StdLib}/Lib/distutils/tests/test_bdist.py | 0 .../Lib/distutils/tests/test_bdist_dumb.py | 0 .../Lib/distutils/tests/test_bdist_msi.py | 0 .../Lib/distutils/tests/test_bdist_rpm.py | 0 .../Lib/distutils/tests/test_bdist_wininst.py | 0 .../StdLib}/Lib/distutils/tests/test_build.py | 0 .../Lib/distutils/tests/test_build_clib.py | 0 .../Lib/distutils/tests/test_build_ext.py | 0 .../Lib/distutils/tests/test_build_py.py | 0 .../Lib/distutils/tests/test_build_scripts.py | 0 .../StdLib}/Lib/distutils/tests/test_check.py | 0 .../StdLib}/Lib/distutils/tests/test_clean.py | 0 .../StdLib}/Lib/distutils/tests/test_cmd.py | 0 .../Lib/distutils/tests/test_config.py | 0 .../Lib/distutils/tests/test_config_cmd.py | 0 .../StdLib}/Lib/distutils/tests/test_core.py | 0 .../distutils/tests/test_cygwinccompiler.py | 0 .../Lib/distutils/tests/test_dep_util.py | 0 .../Lib/distutils/tests/test_dir_util.py | 0 .../StdLib}/Lib/distutils/tests/test_dist.py | 0 .../Lib/distutils/tests/test_extension.py | 0 .../Lib/distutils/tests/test_file_util.py | 0 .../Lib/distutils/tests/test_filelist.py | 0 .../Lib/distutils/tests/test_install.py | 0 .../Lib/distutils/tests/test_install_data.py | 0 .../distutils/tests/test_install_headers.py | 0 .../Lib/distutils/tests/test_install_lib.py | 0 .../distutils/tests/test_install_scripts.py | 0 .../StdLib}/Lib/distutils/tests/test_log.py | 0 .../Lib/distutils/tests/test_msvc9compiler.py | 0 .../Lib/distutils/tests/test_register.py | 0 .../StdLib}/Lib/distutils/tests/test_sdist.py | 0 .../StdLib}/Lib/distutils/tests/test_spawn.py | 0 .../Lib/distutils/tests/test_sysconfig.py | 0 .../Lib/distutils/tests/test_text_file.py | 0 .../Lib/distutils/tests/test_unixccompiler.py | 0 .../Lib/distutils/tests/test_upload.py | 0 .../StdLib}/Lib/distutils/tests/test_util.py | 0 .../Lib/distutils/tests/test_version.py | 0 .../distutils/tests/test_versionpredicate.py | 0 .../StdLib}/Lib/distutils/text_file.py | 0 .../StdLib}/Lib/distutils/unixccompiler.py | 0 {StdLib => Src/StdLib}/Lib/distutils/util.py | 0 .../StdLib}/Lib/distutils/version.py | 0 .../StdLib}/Lib/distutils/versionpredicate.py | 0 {StdLib => Src/StdLib}/Lib/doctest.py | 0 {StdLib => Src/StdLib}/Lib/dummy_threading.py | 0 {StdLib => Src/StdLib}/Lib/email/__init__.py | 0 .../StdLib}/Lib/email/_encoded_words.py | 0 .../StdLib}/Lib/email/_header_value_parser.py | 0 .../StdLib}/Lib/email/_parseaddr.py | 0 .../StdLib}/Lib/email/_policybase.py | 0 .../StdLib}/Lib/email/architecture.rst | 0 .../StdLib}/Lib/email/base64mime.py | 0 {StdLib => Src/StdLib}/Lib/email/charset.py | 0 .../StdLib}/Lib/email/contentmanager.py | 0 {StdLib => Src/StdLib}/Lib/email/encoders.py | 0 {StdLib => Src/StdLib}/Lib/email/errors.py | 0 .../StdLib}/Lib/email/feedparser.py | 0 {StdLib => Src/StdLib}/Lib/email/generator.py | 0 {StdLib => Src/StdLib}/Lib/email/header.py | 0 .../StdLib}/Lib/email/headerregistry.py | 0 {StdLib => Src/StdLib}/Lib/email/iterators.py | 0 {StdLib => Src/StdLib}/Lib/email/message.py | 0 .../StdLib}/Lib/email/mime/__init__.py | 0 .../StdLib}/Lib/email/mime/application.py | 0 .../StdLib}/Lib/email/mime/audio.py | 0 {StdLib => Src/StdLib}/Lib/email/mime/base.py | 0 .../StdLib}/Lib/email/mime/image.py | 0 .../StdLib}/Lib/email/mime/message.py | 0 .../StdLib}/Lib/email/mime/multipart.py | 0 .../StdLib}/Lib/email/mime/nonmultipart.py | 0 {StdLib => Src/StdLib}/Lib/email/mime/text.py | 0 {StdLib => Src/StdLib}/Lib/email/parser.py | 0 {StdLib => Src/StdLib}/Lib/email/policy.py | 0 .../StdLib}/Lib/email/quoprimime.py | 0 {StdLib => Src/StdLib}/Lib/email/utils.py | 0 .../StdLib}/Lib/encodings/__init__.py | 0 .../StdLib}/Lib/encodings/aliases.py | 0 {StdLib => Src/StdLib}/Lib/encodings/ascii.py | 0 .../StdLib}/Lib/encodings/base64_codec.py | 0 {StdLib => Src/StdLib}/Lib/encodings/big5.py | 0 .../StdLib}/Lib/encodings/big5hkscs.py | 0 .../StdLib}/Lib/encodings/bz2_codec.py | 0 .../StdLib}/Lib/encodings/charmap.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp037.py | 0 .../StdLib}/Lib/encodings/cp1006.py | 0 .../StdLib}/Lib/encodings/cp1026.py | 0 .../StdLib}/Lib/encodings/cp1125.py | 0 .../StdLib}/Lib/encodings/cp1140.py | 0 .../StdLib}/Lib/encodings/cp1250.py | 0 .../StdLib}/Lib/encodings/cp1251.py | 0 .../StdLib}/Lib/encodings/cp1252.py | 0 .../StdLib}/Lib/encodings/cp1253.py | 0 .../StdLib}/Lib/encodings/cp1254.py | 0 .../StdLib}/Lib/encodings/cp1255.py | 0 .../StdLib}/Lib/encodings/cp1256.py | 0 .../StdLib}/Lib/encodings/cp1257.py | 0 .../StdLib}/Lib/encodings/cp1258.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp273.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp424.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp437.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp500.py | 0 .../StdLib}/Lib/encodings/cp65001.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp720.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp737.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp775.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp850.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp852.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp855.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp856.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp857.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp858.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp860.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp861.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp862.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp863.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp864.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp865.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp866.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp869.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp874.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp875.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp932.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp949.py | 0 {StdLib => Src/StdLib}/Lib/encodings/cp950.py | 0 .../StdLib}/Lib/encodings/euc_jis_2004.py | 0 .../StdLib}/Lib/encodings/euc_jisx0213.py | 0 .../StdLib}/Lib/encodings/euc_jp.py | 0 .../StdLib}/Lib/encodings/euc_kr.py | 0 .../StdLib}/Lib/encodings/gb18030.py | 0 .../StdLib}/Lib/encodings/gb2312.py | 0 {StdLib => Src/StdLib}/Lib/encodings/gbk.py | 0 .../StdLib}/Lib/encodings/hex_codec.py | 0 .../StdLib}/Lib/encodings/hp_roman8.py | 0 {StdLib => Src/StdLib}/Lib/encodings/hz.py | 0 {StdLib => Src/StdLib}/Lib/encodings/idna.py | 0 .../StdLib}/Lib/encodings/iso2022_jp.py | 0 .../StdLib}/Lib/encodings/iso2022_jp_1.py | 0 .../StdLib}/Lib/encodings/iso2022_jp_2.py | 0 .../StdLib}/Lib/encodings/iso2022_jp_2004.py | 0 .../StdLib}/Lib/encodings/iso2022_jp_3.py | 0 .../StdLib}/Lib/encodings/iso2022_jp_ext.py | 0 .../StdLib}/Lib/encodings/iso2022_kr.py | 0 .../StdLib}/Lib/encodings/iso8859_1.py | 0 .../StdLib}/Lib/encodings/iso8859_10.py | 0 .../StdLib}/Lib/encodings/iso8859_11.py | 0 .../StdLib}/Lib/encodings/iso8859_13.py | 0 .../StdLib}/Lib/encodings/iso8859_14.py | 0 .../StdLib}/Lib/encodings/iso8859_15.py | 0 .../StdLib}/Lib/encodings/iso8859_16.py | 0 .../StdLib}/Lib/encodings/iso8859_2.py | 0 .../StdLib}/Lib/encodings/iso8859_3.py | 0 .../StdLib}/Lib/encodings/iso8859_4.py | 0 .../StdLib}/Lib/encodings/iso8859_5.py | 0 .../StdLib}/Lib/encodings/iso8859_6.py | 0 .../StdLib}/Lib/encodings/iso8859_7.py | 0 .../StdLib}/Lib/encodings/iso8859_8.py | 0 .../StdLib}/Lib/encodings/iso8859_9.py | 0 {StdLib => Src/StdLib}/Lib/encodings/johab.py | 0 .../StdLib}/Lib/encodings/koi8_r.py | 0 .../StdLib}/Lib/encodings/koi8_u.py | 0 .../StdLib}/Lib/encodings/latin_1.py | 0 .../StdLib}/Lib/encodings/mac_arabic.py | 0 .../StdLib}/Lib/encodings/mac_centeuro.py | 0 .../StdLib}/Lib/encodings/mac_croatian.py | 0 .../StdLib}/Lib/encodings/mac_cyrillic.py | 0 .../StdLib}/Lib/encodings/mac_farsi.py | 0 .../StdLib}/Lib/encodings/mac_greek.py | 0 .../StdLib}/Lib/encodings/mac_iceland.py | 0 .../StdLib}/Lib/encodings/mac_latin2.py | 0 .../StdLib}/Lib/encodings/mac_roman.py | 0 .../StdLib}/Lib/encodings/mac_romanian.py | 0 .../StdLib}/Lib/encodings/mac_turkish.py | 0 {StdLib => Src/StdLib}/Lib/encodings/mbcs.py | 0 .../StdLib}/Lib/encodings/palmos.py | 0 .../StdLib}/Lib/encodings/ptcp154.py | 0 .../StdLib}/Lib/encodings/punycode.py | 0 .../StdLib}/Lib/encodings/quopri_codec.py | 0 .../Lib/encodings/raw_unicode_escape.py | 0 .../StdLib}/Lib/encodings/rot_13.py | 0 .../StdLib}/Lib/encodings/shift_jis.py | 0 .../StdLib}/Lib/encodings/shift_jis_2004.py | 0 .../StdLib}/Lib/encodings/shift_jisx0213.py | 0 .../StdLib}/Lib/encodings/tis_620.py | 0 .../StdLib}/Lib/encodings/undefined.py | 0 .../StdLib}/Lib/encodings/unicode_escape.py | 0 .../StdLib}/Lib/encodings/unicode_internal.py | 0 .../StdLib}/Lib/encodings/utf_16.py | 0 .../StdLib}/Lib/encodings/utf_16_be.py | 0 .../StdLib}/Lib/encodings/utf_16_le.py | 0 .../StdLib}/Lib/encodings/utf_32.py | 0 .../StdLib}/Lib/encodings/utf_32_be.py | 0 .../StdLib}/Lib/encodings/utf_32_le.py | 0 {StdLib => Src/StdLib}/Lib/encodings/utf_7.py | 0 {StdLib => Src/StdLib}/Lib/encodings/utf_8.py | 0 .../StdLib}/Lib/encodings/utf_8_sig.py | 0 .../StdLib}/Lib/encodings/uu_codec.py | 0 .../StdLib}/Lib/encodings/zlib_codec.py | 0 .../StdLib}/Lib/ensurepip/__init__.py | 0 .../StdLib}/Lib/ensurepip/__main__.py | 0 .../_bundled/pip-18.1-py2.py3-none-any.whl | Bin .../setuptools-40.6.2-py2.py3-none-any.whl | Bin .../StdLib}/Lib/ensurepip/_uninstall.py | 0 {StdLib => Src/StdLib}/Lib/enum.py | 0 {StdLib => Src/StdLib}/Lib/filecmp.py | 0 {StdLib => Src/StdLib}/Lib/fileinput.py | 0 {StdLib => Src/StdLib}/Lib/fnmatch.py | 0 {StdLib => Src/StdLib}/Lib/formatter.py | 0 {StdLib => Src/StdLib}/Lib/fractions.py | 0 {StdLib => Src/StdLib}/Lib/ftplib.py | 0 {StdLib => Src/StdLib}/Lib/functools.py | 0 {StdLib => Src/StdLib}/Lib/genericpath.py | 0 {StdLib => Src/StdLib}/Lib/getopt.py | 0 {StdLib => Src/StdLib}/Lib/getpass.py | 0 {StdLib => Src/StdLib}/Lib/gettext.py | 0 {StdLib => Src/StdLib}/Lib/glob.py | 0 {StdLib => Src/StdLib}/Lib/gzip.py | 0 {StdLib => Src/StdLib}/Lib/hashlib.py | 0 {StdLib => Src/StdLib}/Lib/heapq.py | 0 {StdLib => Src/StdLib}/Lib/hmac.py | 0 {StdLib => Src/StdLib}/Lib/html/__init__.py | 0 {StdLib => Src/StdLib}/Lib/html/entities.py | 0 {StdLib => Src/StdLib}/Lib/html/parser.py | 0 {StdLib => Src/StdLib}/Lib/http/__init__.py | 0 {StdLib => Src/StdLib}/Lib/http/client.py | 0 {StdLib => Src/StdLib}/Lib/http/cookiejar.py | 0 {StdLib => Src/StdLib}/Lib/http/cookies.py | 0 {StdLib => Src/StdLib}/Lib/http/server.py | 0 .../StdLib}/Lib/idlelib/AutoComplete.py | 0 .../StdLib}/Lib/idlelib/AutoCompleteWindow.py | 0 .../StdLib}/Lib/idlelib/AutoExpand.py | 0 .../StdLib}/Lib/idlelib/Bindings.py | 0 .../StdLib}/Lib/idlelib/CREDITS.txt | 0 .../StdLib}/Lib/idlelib/CallTipWindow.py | 0 .../StdLib}/Lib/idlelib/CallTips.py | 0 {StdLib => Src/StdLib}/Lib/idlelib/ChangeLog | 0 .../StdLib}/Lib/idlelib/ClassBrowser.py | 0 .../StdLib}/Lib/idlelib/CodeContext.py | 0 .../StdLib}/Lib/idlelib/ColorDelegator.py | 0 .../StdLib}/Lib/idlelib/Debugger.py | 0 .../StdLib}/Lib/idlelib/Delegator.py | 0 .../StdLib}/Lib/idlelib/EditorWindow.py | 0 .../StdLib}/Lib/idlelib/FileList.py | 0 .../StdLib}/Lib/idlelib/FormatParagraph.py | 0 .../StdLib}/Lib/idlelib/GrepDialog.py | 0 .../StdLib}/Lib/idlelib/HISTORY.txt | 0 .../StdLib}/Lib/idlelib/HyperParser.py | 0 .../StdLib}/Lib/idlelib/IOBinding.py | 0 .../StdLib}/Lib/idlelib/Icons/folder.gif | Bin .../StdLib}/Lib/idlelib/Icons/idle.icns | Bin .../StdLib}/Lib/idlelib/Icons/idle.ico | Bin .../StdLib}/Lib/idlelib/Icons/idle_16.gif | Bin .../StdLib}/Lib/idlelib/Icons/idle_16.png | Bin .../StdLib}/Lib/idlelib/Icons/idle_32.gif | Bin .../StdLib}/Lib/idlelib/Icons/idle_32.png | Bin .../StdLib}/Lib/idlelib/Icons/idle_48.gif | Bin .../StdLib}/Lib/idlelib/Icons/idle_48.png | Bin .../StdLib}/Lib/idlelib/Icons/minusnode.gif | Bin .../StdLib}/Lib/idlelib/Icons/openfolder.gif | Bin .../StdLib}/Lib/idlelib/Icons/plusnode.gif | Bin .../StdLib}/Lib/idlelib/Icons/python.gif | Bin .../StdLib}/Lib/idlelib/Icons/tk.gif | Bin .../StdLib}/Lib/idlelib/IdleHistory.py | 0 .../StdLib}/Lib/idlelib/MultiCall.py | 0 .../StdLib}/Lib/idlelib/MultiStatusBar.py | 0 {StdLib => Src/StdLib}/Lib/idlelib/NEWS.txt | 0 .../StdLib}/Lib/idlelib/ObjectBrowser.py | 0 .../StdLib}/Lib/idlelib/OutputWindow.py | 0 .../StdLib}/Lib/idlelib/ParenMatch.py | 0 .../StdLib}/Lib/idlelib/PathBrowser.py | 0 .../StdLib}/Lib/idlelib/Percolator.py | 0 {StdLib => Src/StdLib}/Lib/idlelib/PyParse.py | 0 {StdLib => Src/StdLib}/Lib/idlelib/PyShell.py | 0 {StdLib => Src/StdLib}/Lib/idlelib/README.txt | 0 .../StdLib}/Lib/idlelib/RemoteDebugger.py | 0 .../Lib/idlelib/RemoteObjectBrowser.py | 0 .../StdLib}/Lib/idlelib/ReplaceDialog.py | 0 .../StdLib}/Lib/idlelib/RstripExtension.py | 0 .../StdLib}/Lib/idlelib/ScriptBinding.py | 0 .../StdLib}/Lib/idlelib/ScrolledList.py | 0 .../StdLib}/Lib/idlelib/SearchDialog.py | 0 .../StdLib}/Lib/idlelib/SearchDialogBase.py | 0 .../StdLib}/Lib/idlelib/SearchEngine.py | 0 .../StdLib}/Lib/idlelib/StackViewer.py | 0 {StdLib => Src/StdLib}/Lib/idlelib/TODO.txt | 0 {StdLib => Src/StdLib}/Lib/idlelib/ToolTip.py | 0 .../StdLib}/Lib/idlelib/TreeWidget.py | 0 .../StdLib}/Lib/idlelib/UndoDelegator.py | 0 .../StdLib}/Lib/idlelib/WidgetRedirector.py | 0 .../StdLib}/Lib/idlelib/WindowList.py | 0 .../StdLib}/Lib/idlelib/ZoomHeight.py | 0 .../StdLib}/Lib/idlelib/__init__.py | 0 .../StdLib}/Lib/idlelib/__main__.py | 0 .../StdLib}/Lib/idlelib/aboutDialog.py | 0 .../StdLib}/Lib/idlelib/config-extensions.def | 0 .../StdLib}/Lib/idlelib/config-highlight.def | 0 .../StdLib}/Lib/idlelib/config-keys.def | 0 .../StdLib}/Lib/idlelib/config-main.def | 0 .../StdLib}/Lib/idlelib/configDialog.py | 0 .../StdLib}/Lib/idlelib/configHandler.py | 0 .../Lib/idlelib/configHelpSourceEdit.py | 0 .../Lib/idlelib/configSectionNameDialog.py | 0 .../Lib/idlelib/dynOptionMenuWidget.py | 0 {StdLib => Src/StdLib}/Lib/idlelib/extend.txt | 0 {StdLib => Src/StdLib}/Lib/idlelib/help.html | 0 {StdLib => Src/StdLib}/Lib/idlelib/help.py | 0 {StdLib => Src/StdLib}/Lib/idlelib/help.txt | 0 {StdLib => Src/StdLib}/Lib/idlelib/idle.bat | 0 {StdLib => Src/StdLib}/Lib/idlelib/idle.py | 0 {StdLib => Src/StdLib}/Lib/idlelib/idle.pyw | 0 .../StdLib}/Lib/idlelib/idle_test/README.txt | 0 .../StdLib}/Lib/idlelib/idle_test/__init__.py | 0 .../StdLib}/Lib/idlelib/idle_test/htest.py | 0 .../Lib/idlelib/idle_test/mock_idle.py | 0 .../StdLib}/Lib/idlelib/idle_test/mock_tk.py | 0 .../idlelib/idle_test/test_autocomplete.py | 0 .../Lib/idlelib/idle_test/test_autoexpand.py | 0 .../Lib/idlelib/idle_test/test_calltips.py | 0 .../Lib/idlelib/idle_test/test_config_name.py | 0 .../idlelib/idle_test/test_configdialog.py | 0 .../Lib/idlelib/idle_test/test_delegator.py | 0 .../Lib/idlelib/idle_test/test_editor.py | 0 .../idlelib/idle_test/test_formatparagraph.py | 0 .../Lib/idlelib/idle_test/test_grep.py | 0 .../Lib/idlelib/idle_test/test_hyperparser.py | 0 .../Lib/idlelib/idle_test/test_idlehistory.py | 0 .../StdLib}/Lib/idlelib/idle_test/test_io.py | 0 .../Lib/idlelib/idle_test/test_parenmatch.py | 0 .../Lib/idlelib/idle_test/test_pathbrowser.py | 0 .../Lib/idlelib/idle_test/test_rstrip.py | 0 .../idle_test/test_searchdialogbase.py | 0 .../idlelib/idle_test/test_searchengine.py | 0 .../Lib/idlelib/idle_test/test_text.py | 0 .../Lib/idlelib/idle_test/test_textview.py | 0 .../Lib/idlelib/idle_test/test_warning.py | 0 .../Lib/idlelib/idle_test/test_widgetredir.py | 0 {StdLib => Src/StdLib}/Lib/idlelib/idlever.py | 0 .../StdLib}/Lib/idlelib/keybindingDialog.py | 0 .../StdLib}/Lib/idlelib/macosxSupport.py | 0 {StdLib => Src/StdLib}/Lib/idlelib/rpc.py | 0 {StdLib => Src/StdLib}/Lib/idlelib/run.py | 0 .../StdLib}/Lib/idlelib/tabbedpages.py | 0 .../StdLib}/Lib/idlelib/textView.py | 0 {StdLib => Src/StdLib}/Lib/imaplib.py | 0 {StdLib => Src/StdLib}/Lib/imghdr.py | 0 {StdLib => Src/StdLib}/Lib/imp.py | 0 .../StdLib}/Lib/importlib/__init__.py | 0 .../StdLib}/Lib/importlib/_bootstrap.py | 0 {StdLib => Src/StdLib}/Lib/importlib/abc.py | 0 .../StdLib}/Lib/importlib/machinery.py | 0 {StdLib => Src/StdLib}/Lib/importlib/util.py | 0 {StdLib => Src/StdLib}/Lib/inspect.py | 0 {StdLib => Src/StdLib}/Lib/io.py | 0 {StdLib => Src/StdLib}/Lib/ipaddress.py | 0 {StdLib => Src/StdLib}/Lib/json/__init__.py | 0 {StdLib => Src/StdLib}/Lib/json/decoder.py | 0 {StdLib => Src/StdLib}/Lib/json/encoder.py | 0 {StdLib => Src/StdLib}/Lib/json/scanner.py | 0 {StdLib => Src/StdLib}/Lib/json/tool.py | 0 {StdLib => Src/StdLib}/Lib/keyword.py | 0 .../StdLib}/Lib/lib2to3/Grammar.txt | 0 .../StdLib}/Lib/lib2to3/PatternGrammar.txt | 0 .../StdLib}/Lib/lib2to3/__init__.py | 0 .../StdLib}/Lib/lib2to3/__main__.py | 0 .../StdLib}/Lib/lib2to3/btm_matcher.py | 0 .../StdLib}/Lib/lib2to3/btm_utils.py | 0 .../StdLib}/Lib/lib2to3/fixer_base.py | 0 .../StdLib}/Lib/lib2to3/fixer_util.py | 0 .../StdLib}/Lib/lib2to3/fixes/__init__.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_apply.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_asserts.py | 0 .../Lib/lib2to3/fixes/fix_basestring.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_buffer.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_callable.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_dict.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_except.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_exec.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_execfile.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_exitfunc.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_filter.py | 0 .../Lib/lib2to3/fixes/fix_funcattrs.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_future.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_getcwdu.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_has_key.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_idioms.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_import.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_imports.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_imports2.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_input.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_intern.py | 0 .../Lib/lib2to3/fixes/fix_isinstance.py | 0 .../Lib/lib2to3/fixes/fix_itertools.py | 0 .../lib2to3/fixes/fix_itertools_imports.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_long.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_map.py | 0 .../Lib/lib2to3/fixes/fix_metaclass.py | 0 .../Lib/lib2to3/fixes/fix_methodattrs.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_ne.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_next.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_nonzero.py | 0 .../Lib/lib2to3/fixes/fix_numliterals.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_operator.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_paren.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_print.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_raise.py | 0 .../Lib/lib2to3/fixes/fix_raw_input.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_reduce.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_reload.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_renames.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_repr.py | 0 .../Lib/lib2to3/fixes/fix_set_literal.py | 0 .../Lib/lib2to3/fixes/fix_standarderror.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_sys_exc.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_throw.py | 0 .../Lib/lib2to3/fixes/fix_tuple_params.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_types.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_unicode.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_urllib.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_ws_comma.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_xrange.py | 0 .../Lib/lib2to3/fixes/fix_xreadlines.py | 0 .../StdLib}/Lib/lib2to3/fixes/fix_zip.py | 0 {StdLib => Src/StdLib}/Lib/lib2to3/main.py | 0 {StdLib => Src/StdLib}/Lib/lib2to3/patcomp.py | 0 .../StdLib}/Lib/lib2to3/pgen2/__init__.py | 0 .../StdLib}/Lib/lib2to3/pgen2/conv.py | 0 .../StdLib}/Lib/lib2to3/pgen2/driver.py | 0 .../StdLib}/Lib/lib2to3/pgen2/grammar.py | 0 .../StdLib}/Lib/lib2to3/pgen2/literals.py | 0 .../StdLib}/Lib/lib2to3/pgen2/parse.py | 0 .../StdLib}/Lib/lib2to3/pgen2/pgen.py | 0 .../StdLib}/Lib/lib2to3/pgen2/token.py | 0 .../StdLib}/Lib/lib2to3/pgen2/tokenize.py | 0 {StdLib => Src/StdLib}/Lib/lib2to3/pygram.py | 0 {StdLib => Src/StdLib}/Lib/lib2to3/pytree.py | 0 .../StdLib}/Lib/lib2to3/refactor.py | 0 .../StdLib}/Lib/lib2to3/tests/__init__.py | 0 .../StdLib}/Lib/lib2to3/tests/__main__.py | 0 .../StdLib}/Lib/lib2to3/tests/data/README | 0 .../StdLib}/Lib/lib2to3/tests/data/bom.py | 0 .../StdLib}/Lib/lib2to3/tests/data/crlf.py | 0 .../lib2to3/tests/data/different_encoding.py | 0 .../Lib/lib2to3/tests/data/false_encoding.py | 0 .../lib2to3/tests/data/fixers/bad_order.py | 0 .../tests/data/fixers/myfixes/__init__.py | 0 .../tests/data/fixers/myfixes/fix_explicit.py | 0 .../tests/data/fixers/myfixes/fix_first.py | 0 .../tests/data/fixers/myfixes/fix_last.py | 0 .../tests/data/fixers/myfixes/fix_parrot.py | 0 .../tests/data/fixers/myfixes/fix_preorder.py | 0 .../lib2to3/tests/data/fixers/no_fixer_cls.py | 0 .../tests/data/fixers/parrot_example.py | 0 .../lib2to3/tests/data/infinite_recursion.py | 0 .../lib2to3/tests/data/py2_test_grammar.py | 0 .../lib2to3/tests/data/py3_test_grammar.py | 0 .../Lib/lib2to3/tests/pytree_idempotency.py | 0 .../StdLib}/Lib/lib2to3/tests/support.py | 0 .../Lib/lib2to3/tests/test_all_fixers.py | 0 .../StdLib}/Lib/lib2to3/tests/test_fixers.py | 0 .../StdLib}/Lib/lib2to3/tests/test_main.py | 0 .../StdLib}/Lib/lib2to3/tests/test_parser.py | 0 .../StdLib}/Lib/lib2to3/tests/test_pytree.py | 0 .../Lib/lib2to3/tests/test_refactor.py | 0 .../StdLib}/Lib/lib2to3/tests/test_util.py | 0 {StdLib => Src/StdLib}/Lib/linecache.py | 0 {StdLib => Src/StdLib}/Lib/locale.py | 0 .../StdLib}/Lib/logging/__init__.py | 0 {StdLib => Src/StdLib}/Lib/logging/config.py | 0 .../StdLib}/Lib/logging/handlers.py | 0 {StdLib => Src/StdLib}/Lib/lzma.py | 0 {StdLib => Src/StdLib}/Lib/macpath.py | 0 {StdLib => Src/StdLib}/Lib/macurl2path.py | 0 {StdLib => Src/StdLib}/Lib/mailbox.py | 0 {StdLib => Src/StdLib}/Lib/mailcap.py | 0 {StdLib => Src/StdLib}/Lib/mimetypes.py | 0 {StdLib => Src/StdLib}/Lib/modulefinder.py | 0 {StdLib => Src/StdLib}/Lib/msilib/__init__.py | 0 {StdLib => Src/StdLib}/Lib/msilib/schema.py | 0 {StdLib => Src/StdLib}/Lib/msilib/sequence.py | 0 {StdLib => Src/StdLib}/Lib/msilib/text.py | 0 .../StdLib}/Lib/multiprocessing/__init__.py | 0 .../StdLib}/Lib/multiprocessing/connection.py | 0 .../StdLib}/Lib/multiprocessing/context.py | 0 .../Lib/multiprocessing/dummy/__init__.py | 0 .../Lib/multiprocessing/dummy/connection.py | 0 .../StdLib}/Lib/multiprocessing/forkserver.py | 0 .../StdLib}/Lib/multiprocessing/heap.py | 0 .../StdLib}/Lib/multiprocessing/managers.py | 0 .../StdLib}/Lib/multiprocessing/pool.py | 0 .../StdLib}/Lib/multiprocessing/popen_fork.py | 0 .../Lib/multiprocessing/popen_forkserver.py | 0 .../Lib/multiprocessing/popen_spawn_posix.py | 0 .../Lib/multiprocessing/popen_spawn_win32.py | 0 .../StdLib}/Lib/multiprocessing/process.py | 0 .../StdLib}/Lib/multiprocessing/queues.py | 0 .../StdLib}/Lib/multiprocessing/reduction.py | 0 .../Lib/multiprocessing/resource_sharer.py | 0 .../Lib/multiprocessing/semaphore_tracker.py | 0 .../Lib/multiprocessing/sharedctypes.py | 0 .../StdLib}/Lib/multiprocessing/spawn.py | 0 .../Lib/multiprocessing/synchronize.py | 0 .../StdLib}/Lib/multiprocessing/util.py | 0 {StdLib => Src/StdLib}/Lib/netrc.py | 0 {StdLib => Src/StdLib}/Lib/nntplib.py | 0 {StdLib => Src/StdLib}/Lib/ntpath.py | 0 {StdLib => Src/StdLib}/Lib/nturl2path.py | 0 {StdLib => Src/StdLib}/Lib/numbers.py | 0 {StdLib => Src/StdLib}/Lib/opcode.py | 0 {StdLib => Src/StdLib}/Lib/operator.py | 0 {StdLib => Src/StdLib}/Lib/optparse.py | 0 {StdLib => Src/StdLib}/Lib/os.py | 0 {StdLib => Src/StdLib}/Lib/pathlib.py | 0 {StdLib => Src/StdLib}/Lib/pdb.py | 0 {StdLib => Src/StdLib}/Lib/pickle.py | 0 {StdLib => Src/StdLib}/Lib/pickletools.py | 0 {StdLib => Src/StdLib}/Lib/pipes.py | 0 {StdLib => Src/StdLib}/Lib/pkgutil.py | 0 {StdLib => Src/StdLib}/Lib/platform.py | 0 {StdLib => Src/StdLib}/Lib/plistlib.py | 0 {StdLib => Src/StdLib}/Lib/poplib.py | 0 {StdLib => Src/StdLib}/Lib/posixpath.py | 0 {StdLib => Src/StdLib}/Lib/pprint.py | 0 {StdLib => Src/StdLib}/Lib/profile.py | 0 {StdLib => Src/StdLib}/Lib/pstats.py | 0 {StdLib => Src/StdLib}/Lib/pty.py | 0 {StdLib => Src/StdLib}/Lib/py_compile.py | 0 {StdLib => Src/StdLib}/Lib/pyclbr.py | 0 {StdLib => Src/StdLib}/Lib/pydoc.py | 0 .../StdLib}/Lib/pydoc_data/__init__.py | 0 .../StdLib}/Lib/pydoc_data/_pydoc.css | 0 .../StdLib}/Lib/pydoc_data/topics.py | 0 {StdLib => Src/StdLib}/Lib/queue.py | 0 {StdLib => Src/StdLib}/Lib/quopri.py | 0 {StdLib => Src/StdLib}/Lib/random.py | 0 {StdLib => Src/StdLib}/Lib/re.py | 0 {StdLib => Src/StdLib}/Lib/reprlib.py | 0 {StdLib => Src/StdLib}/Lib/rlcompleter.py | 0 {StdLib => Src/StdLib}/Lib/runpy.py | 0 {StdLib => Src/StdLib}/Lib/sched.py | 0 {StdLib => Src/StdLib}/Lib/selectors.py | 0 {StdLib => Src/StdLib}/Lib/shelve.py | 0 {StdLib => Src/StdLib}/Lib/shlex.py | 0 {StdLib => Src/StdLib}/Lib/shutil.py | 0 .../StdLib}/Lib/site-packages/README | 0 {StdLib => Src/StdLib}/Lib/site.py | 0 {StdLib => Src/StdLib}/Lib/smtpd.py | 0 {StdLib => Src/StdLib}/Lib/smtplib.py | 0 {StdLib => Src/StdLib}/Lib/sndhdr.py | 0 {StdLib => Src/StdLib}/Lib/socket.py | 0 {StdLib => Src/StdLib}/Lib/socketserver.py | 0 .../StdLib}/Lib/sqlite3/__init__.py | 0 {StdLib => Src/StdLib}/Lib/sqlite3/dbapi2.py | 0 {StdLib => Src/StdLib}/Lib/sqlite3/dump.py | 0 .../StdLib}/Lib/sqlite3/test/__init__.py | 0 .../StdLib}/Lib/sqlite3/test/dbapi.py | 0 .../StdLib}/Lib/sqlite3/test/dump.py | 0 .../StdLib}/Lib/sqlite3/test/factory.py | 0 .../StdLib}/Lib/sqlite3/test/hooks.py | 0 .../StdLib}/Lib/sqlite3/test/regression.py | 0 .../StdLib}/Lib/sqlite3/test/transactions.py | 0 .../StdLib}/Lib/sqlite3/test/types.py | 0 .../StdLib}/Lib/sqlite3/test/userfunctions.py | 0 {StdLib => Src/StdLib}/Lib/sre_compile.py | 0 {StdLib => Src/StdLib}/Lib/sre_constants.py | 0 {StdLib => Src/StdLib}/Lib/sre_parse.py | 0 {StdLib => Src/StdLib}/Lib/ssl.py | 0 {StdLib => Src/StdLib}/Lib/stat.py | 0 {StdLib => Src/StdLib}/Lib/statistics.py | 0 {StdLib => Src/StdLib}/Lib/string.py | 0 {StdLib => Src/StdLib}/Lib/stringprep.py | 0 {StdLib => Src/StdLib}/Lib/struct.py | 0 {StdLib => Src/StdLib}/Lib/subprocess.py | 0 {StdLib => Src/StdLib}/Lib/sunau.py | 0 {StdLib => Src/StdLib}/Lib/symbol.py | 0 {StdLib => Src/StdLib}/Lib/symtable.py | 0 {StdLib => Src/StdLib}/Lib/sysconfig.py | 0 {StdLib => Src/StdLib}/Lib/tabnanny.py | 0 {StdLib => Src/StdLib}/Lib/tarfile.py | 0 {StdLib => Src/StdLib}/Lib/telnetlib.py | 0 {StdLib => Src/StdLib}/Lib/tempfile.py | 0 {StdLib => Src/StdLib}/Lib/test/185test.db | Bin .../StdLib}/Lib/test/Sine-1000Hz-300ms.aif | Bin {StdLib => Src/StdLib}/Lib/test/__init__.py | 0 {StdLib => Src/StdLib}/Lib/test/__main__.py | 0 .../StdLib}/Lib/test/_test_multiprocessing.py | 0 .../Lib/test/audiodata/pluck-alaw.aifc | Bin .../Lib/test/audiodata/pluck-pcm16.aiff | Bin .../StdLib}/Lib/test/audiodata/pluck-pcm16.au | Bin .../Lib/test/audiodata/pluck-pcm16.wav | Bin .../Lib/test/audiodata/pluck-pcm24.aiff | Bin .../StdLib}/Lib/test/audiodata/pluck-pcm24.au | Bin .../Lib/test/audiodata/pluck-pcm24.wav | Bin .../Lib/test/audiodata/pluck-pcm32.aiff | Bin .../StdLib}/Lib/test/audiodata/pluck-pcm32.au | Bin .../Lib/test/audiodata/pluck-pcm32.wav | Bin .../Lib/test/audiodata/pluck-pcm8.aiff | Bin .../StdLib}/Lib/test/audiodata/pluck-pcm8.au | Bin .../StdLib}/Lib/test/audiodata/pluck-pcm8.wav | Bin .../Lib/test/audiodata/pluck-ulaw.aifc | Bin .../StdLib}/Lib/test/audiodata/pluck-ulaw.au | Bin {StdLib => Src/StdLib}/Lib/test/audiotest.au | Bin {StdLib => Src/StdLib}/Lib/test/audiotests.py | 0 {StdLib => Src/StdLib}/Lib/test/autotest.py | 0 {StdLib => Src/StdLib}/Lib/test/bad_coding.py | 0 .../StdLib}/Lib/test/bad_coding2.py | 0 {StdLib => Src/StdLib}/Lib/test/badcert.pem | 0 {StdLib => Src/StdLib}/Lib/test/badkey.pem | 0 .../StdLib}/Lib/test/badsyntax_3131.py | 0 .../StdLib}/Lib/test/badsyntax_future10.py | 0 .../StdLib}/Lib/test/badsyntax_future3.py | 0 .../StdLib}/Lib/test/badsyntax_future4.py | 0 .../StdLib}/Lib/test/badsyntax_future5.py | 0 .../StdLib}/Lib/test/badsyntax_future6.py | 0 .../StdLib}/Lib/test/badsyntax_future7.py | 0 .../StdLib}/Lib/test/badsyntax_future8.py | 0 .../StdLib}/Lib/test/badsyntax_future9.py | 0 .../StdLib}/Lib/test/badsyntax_pep3120.py | 0 .../StdLib}/Lib/test/buffer_tests.py | 0 .../StdLib}/Lib/test/bytecode_helper.py | 0 .../StdLib}/Lib/test/capath/0e4015b9.0 | 0 .../StdLib}/Lib/test/capath/4e1295a3.0 | 0 .../StdLib}/Lib/test/capath/5ed36f99.0 | 0 .../StdLib}/Lib/test/capath/6e88d7b8.0 | 0 .../StdLib}/Lib/test/capath/99d0fa06.0 | 0 .../StdLib}/Lib/test/capath/ce7b8643.0 | 0 {StdLib => Src/StdLib}/Lib/test/cfgparser.1 | 0 {StdLib => Src/StdLib}/Lib/test/cfgparser.2 | 0 {StdLib => Src/StdLib}/Lib/test/cfgparser.3 | 0 .../StdLib}/Lib/test/check_soundcard.vbs | 0 .../Lib/test/cjkencodings/big5-utf8.txt | 0 .../StdLib}/Lib/test/cjkencodings/big5.txt | 0 .../Lib/test/cjkencodings/big5hkscs-utf8.txt | 0 .../Lib/test/cjkencodings/big5hkscs.txt | 0 .../Lib/test/cjkencodings/cp949-utf8.txt | 0 .../StdLib}/Lib/test/cjkencodings/cp949.txt | 0 .../test/cjkencodings/euc_jisx0213-utf8.txt | 0 .../Lib/test/cjkencodings/euc_jisx0213.txt | 0 .../Lib/test/cjkencodings/euc_jp-utf8.txt | 0 .../StdLib}/Lib/test/cjkencodings/euc_jp.txt | 0 .../Lib/test/cjkencodings/euc_kr-utf8.txt | 0 .../StdLib}/Lib/test/cjkencodings/euc_kr.txt | 0 .../Lib/test/cjkencodings/gb18030-utf8.txt | 0 .../StdLib}/Lib/test/cjkencodings/gb18030.txt | 0 .../Lib/test/cjkencodings/gb2312-utf8.txt | 0 .../StdLib}/Lib/test/cjkencodings/gb2312.txt | 0 .../Lib/test/cjkencodings/gbk-utf8.txt | 0 .../StdLib}/Lib/test/cjkencodings/gbk.txt | 0 .../StdLib}/Lib/test/cjkencodings/hz-utf8.txt | 0 .../StdLib}/Lib/test/cjkencodings/hz.txt | 0 .../Lib/test/cjkencodings/iso2022_jp-utf8.txt | 0 .../Lib/test/cjkencodings/iso2022_jp.txt | 0 .../Lib/test/cjkencodings/iso2022_kr-utf8.txt | 0 .../Lib/test/cjkencodings/iso2022_kr.txt | 0 .../Lib/test/cjkencodings/johab-utf8.txt | 0 .../StdLib}/Lib/test/cjkencodings/johab.txt | 0 .../Lib/test/cjkencodings/shift_jis-utf8.txt | 0 .../Lib/test/cjkencodings/shift_jis.txt | 0 .../test/cjkencodings/shift_jisx0213-utf8.txt | 0 .../Lib/test/cjkencodings/shift_jisx0213.txt | 0 .../StdLib}/Lib/test/cmath_testcases.txt | 0 .../StdLib}/Lib/test/coding20731.py | 0 .../StdLib}/Lib/test/crashers/README | 0 .../Lib/test/crashers/bogus_code_obj.py | 0 .../Lib/test/crashers/gc_inspection.py | 0 .../Lib/test/crashers/infinite_loop_re.py | 0 .../test/crashers/mutation_inside_cyclegc.py | 0 .../Lib/test/crashers/recursive_call.py | 0 .../test/crashers/trace_at_recursion_limit.py | 0 .../Lib/test/crashers/underlying_dict.py | 0 .../StdLib}/Lib/test/curses_tests.py | 0 {StdLib => Src/StdLib}/Lib/test/data/README | 0 .../StdLib}/Lib/test/datetimetester.py | 0 .../Lib/test/decimaltestdata/abs.decTest | 0 .../Lib/test/decimaltestdata/add.decTest | 0 .../Lib/test/decimaltestdata/and.decTest | 0 .../Lib/test/decimaltestdata/base.decTest | 0 .../Lib/test/decimaltestdata/clamp.decTest | 0 .../Lib/test/decimaltestdata/class.decTest | 0 .../Lib/test/decimaltestdata/compare.decTest | 0 .../test/decimaltestdata/comparetotal.decTest | 0 .../decimaltestdata/comparetotmag.decTest | 0 .../Lib/test/decimaltestdata/copy.decTest | 0 .../Lib/test/decimaltestdata/copyabs.decTest | 0 .../test/decimaltestdata/copynegate.decTest | 0 .../Lib/test/decimaltestdata/copysign.decTest | 0 .../Lib/test/decimaltestdata/ddAbs.decTest | 0 .../Lib/test/decimaltestdata/ddAdd.decTest | 0 .../Lib/test/decimaltestdata/ddAnd.decTest | 0 .../Lib/test/decimaltestdata/ddBase.decTest | 0 .../test/decimaltestdata/ddCanonical.decTest | 0 .../Lib/test/decimaltestdata/ddClass.decTest | 0 .../test/decimaltestdata/ddCompare.decTest | 0 .../test/decimaltestdata/ddCompareSig.decTest | 0 .../decimaltestdata/ddCompareTotal.decTest | 0 .../decimaltestdata/ddCompareTotalMag.decTest | 0 .../Lib/test/decimaltestdata/ddCopy.decTest | 0 .../test/decimaltestdata/ddCopyAbs.decTest | 0 .../test/decimaltestdata/ddCopyNegate.decTest | 0 .../test/decimaltestdata/ddCopySign.decTest | 0 .../Lib/test/decimaltestdata/ddDivide.decTest | 0 .../test/decimaltestdata/ddDivideInt.decTest | 0 .../Lib/test/decimaltestdata/ddEncode.decTest | 0 .../Lib/test/decimaltestdata/ddFMA.decTest | 0 .../Lib/test/decimaltestdata/ddInvert.decTest | 0 .../Lib/test/decimaltestdata/ddLogB.decTest | 0 .../Lib/test/decimaltestdata/ddMax.decTest | 0 .../Lib/test/decimaltestdata/ddMaxMag.decTest | 0 .../Lib/test/decimaltestdata/ddMin.decTest | 0 .../Lib/test/decimaltestdata/ddMinMag.decTest | 0 .../Lib/test/decimaltestdata/ddMinus.decTest | 0 .../test/decimaltestdata/ddMultiply.decTest | 0 .../test/decimaltestdata/ddNextMinus.decTest | 0 .../test/decimaltestdata/ddNextPlus.decTest | 0 .../test/decimaltestdata/ddNextToward.decTest | 0 .../Lib/test/decimaltestdata/ddOr.decTest | 0 .../Lib/test/decimaltestdata/ddPlus.decTest | 0 .../test/decimaltestdata/ddQuantize.decTest | 0 .../Lib/test/decimaltestdata/ddReduce.decTest | 0 .../test/decimaltestdata/ddRemainder.decTest | 0 .../decimaltestdata/ddRemainderNear.decTest | 0 .../Lib/test/decimaltestdata/ddRotate.decTest | 0 .../decimaltestdata/ddSameQuantum.decTest | 0 .../Lib/test/decimaltestdata/ddScaleB.decTest | 0 .../Lib/test/decimaltestdata/ddShift.decTest | 0 .../test/decimaltestdata/ddSubtract.decTest | 0 .../test/decimaltestdata/ddToIntegral.decTest | 0 .../Lib/test/decimaltestdata/ddXor.decTest | 0 .../test/decimaltestdata/decDouble.decTest | 0 .../Lib/test/decimaltestdata/decQuad.decTest | 0 .../test/decimaltestdata/decSingle.decTest | 0 .../Lib/test/decimaltestdata/divide.decTest | 0 .../test/decimaltestdata/divideint.decTest | 0 .../Lib/test/decimaltestdata/dqAbs.decTest | 0 .../Lib/test/decimaltestdata/dqAdd.decTest | 0 .../Lib/test/decimaltestdata/dqAnd.decTest | 0 .../Lib/test/decimaltestdata/dqBase.decTest | 0 .../test/decimaltestdata/dqCanonical.decTest | 0 .../Lib/test/decimaltestdata/dqClass.decTest | 0 .../test/decimaltestdata/dqCompare.decTest | 0 .../test/decimaltestdata/dqCompareSig.decTest | 0 .../decimaltestdata/dqCompareTotal.decTest | 0 .../decimaltestdata/dqCompareTotalMag.decTest | 0 .../Lib/test/decimaltestdata/dqCopy.decTest | 0 .../test/decimaltestdata/dqCopyAbs.decTest | 0 .../test/decimaltestdata/dqCopyNegate.decTest | 0 .../test/decimaltestdata/dqCopySign.decTest | 0 .../Lib/test/decimaltestdata/dqDivide.decTest | 0 .../test/decimaltestdata/dqDivideInt.decTest | 0 .../Lib/test/decimaltestdata/dqEncode.decTest | 0 .../Lib/test/decimaltestdata/dqFMA.decTest | 0 .../Lib/test/decimaltestdata/dqInvert.decTest | 0 .../Lib/test/decimaltestdata/dqLogB.decTest | 0 .../Lib/test/decimaltestdata/dqMax.decTest | 0 .../Lib/test/decimaltestdata/dqMaxMag.decTest | 0 .../Lib/test/decimaltestdata/dqMin.decTest | 0 .../Lib/test/decimaltestdata/dqMinMag.decTest | 0 .../Lib/test/decimaltestdata/dqMinus.decTest | 0 .../test/decimaltestdata/dqMultiply.decTest | 0 .../test/decimaltestdata/dqNextMinus.decTest | 0 .../test/decimaltestdata/dqNextPlus.decTest | 0 .../test/decimaltestdata/dqNextToward.decTest | 0 .../Lib/test/decimaltestdata/dqOr.decTest | 0 .../Lib/test/decimaltestdata/dqPlus.decTest | 0 .../test/decimaltestdata/dqQuantize.decTest | 0 .../Lib/test/decimaltestdata/dqReduce.decTest | 0 .../test/decimaltestdata/dqRemainder.decTest | 0 .../decimaltestdata/dqRemainderNear.decTest | 0 .../Lib/test/decimaltestdata/dqRotate.decTest | 0 .../decimaltestdata/dqSameQuantum.decTest | 0 .../Lib/test/decimaltestdata/dqScaleB.decTest | 0 .../Lib/test/decimaltestdata/dqShift.decTest | 0 .../test/decimaltestdata/dqSubtract.decTest | 0 .../test/decimaltestdata/dqToIntegral.decTest | 0 .../Lib/test/decimaltestdata/dqXor.decTest | 0 .../Lib/test/decimaltestdata/dsBase.decTest | 0 .../Lib/test/decimaltestdata/dsEncode.decTest | 0 .../Lib/test/decimaltestdata/exp.decTest | 0 .../Lib/test/decimaltestdata/extra.decTest | 0 .../Lib/test/decimaltestdata/fma.decTest | 0 .../Lib/test/decimaltestdata/inexact.decTest | 0 .../Lib/test/decimaltestdata/invert.decTest | 0 .../Lib/test/decimaltestdata/ln.decTest | 0 .../Lib/test/decimaltestdata/log10.decTest | 0 .../Lib/test/decimaltestdata/logb.decTest | 0 .../Lib/test/decimaltestdata/max.decTest | 0 .../Lib/test/decimaltestdata/maxmag.decTest | 0 .../Lib/test/decimaltestdata/min.decTest | 0 .../Lib/test/decimaltestdata/minmag.decTest | 0 .../Lib/test/decimaltestdata/minus.decTest | 0 .../Lib/test/decimaltestdata/multiply.decTest | 0 .../test/decimaltestdata/nextminus.decTest | 0 .../Lib/test/decimaltestdata/nextplus.decTest | 0 .../test/decimaltestdata/nexttoward.decTest | 0 .../Lib/test/decimaltestdata/or.decTest | 0 .../Lib/test/decimaltestdata/plus.decTest | 0 .../Lib/test/decimaltestdata/power.decTest | 0 .../test/decimaltestdata/powersqrt.decTest | 0 .../Lib/test/decimaltestdata/quantize.decTest | 0 .../decimaltestdata/randomBound32.decTest | 0 .../Lib/test/decimaltestdata/randoms.decTest | 0 .../Lib/test/decimaltestdata/reduce.decTest | 0 .../test/decimaltestdata/remainder.decTest | 0 .../decimaltestdata/remainderNear.decTest | 0 .../Lib/test/decimaltestdata/rescale.decTest | 0 .../Lib/test/decimaltestdata/rotate.decTest | 0 .../Lib/test/decimaltestdata/rounding.decTest | 0 .../test/decimaltestdata/samequantum.decTest | 0 .../Lib/test/decimaltestdata/scaleb.decTest | 0 .../Lib/test/decimaltestdata/shift.decTest | 0 .../test/decimaltestdata/squareroot.decTest | 0 .../Lib/test/decimaltestdata/subtract.decTest | 0 .../Lib/test/decimaltestdata/testall.decTest | 0 .../test/decimaltestdata/tointegral.decTest | 0 .../test/decimaltestdata/tointegralx.decTest | 0 .../Lib/test/decimaltestdata/xor.decTest | 0 {StdLib => Src/StdLib}/Lib/test/dh1024.pem | 0 {StdLib => Src/StdLib}/Lib/test/dis_module.py | 0 .../StdLib}/Lib/test/doctest_aliases.py | 0 .../StdLib}/Lib/test/double_const.py | 0 {StdLib => Src/StdLib}/Lib/test/empty.vbs | 0 .../Lib/test/encoded_modules/__init__.py | 0 .../test/encoded_modules/module_iso_8859_1.py | 0 .../Lib/test/encoded_modules/module_koi8_r.py | 0 .../StdLib}/Lib/test/exception_hierarchy.txt | 0 {StdLib => Src/StdLib}/Lib/test/final_a.py | 0 {StdLib => Src/StdLib}/Lib/test/final_b.py | 0 .../StdLib}/Lib/test/floating_points.txt | 0 {StdLib => Src/StdLib}/Lib/test/fork_wait.py | 0 .../Lib/test/formatfloat_testcases.txt | 0 .../StdLib}/Lib/test/future_test1.py | 0 .../StdLib}/Lib/test/future_test2.py | 0 {StdLib => Src/StdLib}/Lib/test/gdb_sample.py | 0 {StdLib => Src/StdLib}/Lib/test/ieee754.txt | 0 .../StdLib}/Lib/test/imghdrdata/python.bmp | Bin .../StdLib}/Lib/test/imghdrdata/python.gif | Bin .../StdLib}/Lib/test/imghdrdata/python.jpg | Bin .../StdLib}/Lib/test/imghdrdata/python.pbm | 0 .../StdLib}/Lib/test/imghdrdata/python.pgm | Bin .../StdLib}/Lib/test/imghdrdata/python.png | Bin .../StdLib}/Lib/test/imghdrdata/python.ppm | Bin .../StdLib}/Lib/test/imghdrdata/python.ras | Bin .../StdLib}/Lib/test/imghdrdata/python.sgi | Bin .../StdLib}/Lib/test/imghdrdata/python.tiff | Bin .../StdLib}/Lib/test/imghdrdata/python.xbm | 0 .../StdLib}/Lib/test/inspect_fodder.py | 0 .../StdLib}/Lib/test/inspect_fodder2.py | 0 .../StdLib}/Lib/test/keycert.passwd.pem | 0 {StdLib => Src/StdLib}/Lib/test/keycert.pem | 0 {StdLib => Src/StdLib}/Lib/test/keycert2.pem | 0 {StdLib => Src/StdLib}/Lib/test/keycert3.pem | 0 {StdLib => Src/StdLib}/Lib/test/keycert4.pem | 0 .../StdLib}/Lib/test/leakers/README.txt | 0 .../StdLib}/Lib/test/leakers/__init__.py | 0 .../StdLib}/Lib/test/leakers/test_ctypes.py | 0 .../StdLib}/Lib/test/leakers/test_selftype.py | 0 {StdLib => Src/StdLib}/Lib/test/list_tests.py | 0 {StdLib => Src/StdLib}/Lib/test/lock_tests.py | 0 {StdLib => Src/StdLib}/Lib/test/mailcap.txt | 0 .../StdLib}/Lib/test/make_ssl_certs.py | 0 .../StdLib}/Lib/test/mapping_tests.py | 0 .../StdLib}/Lib/test/math_testcases.txt | 0 .../StdLib}/Lib/test/memory_watchdog.py | 0 {StdLib => Src/StdLib}/Lib/test/mime.types | 0 .../StdLib}/Lib/test/mock_socket.py | 0 .../StdLib}/Lib/test/mod_generics_cache.py | 0 .../StdLib}/Lib/test/mp_fork_bomb.py | 0 .../Lib/test/multibytecodec_support.py | 0 {StdLib => Src/StdLib}/Lib/test/nokia.pem | 0 .../StdLib}/Lib/test/nullbytecert.pem | 0 {StdLib => Src/StdLib}/Lib/test/nullcert.pem | 0 .../StdLib}/Lib/test/outstanding_bugs.py | 0 .../StdLib}/Lib/test/pickletester.py | 0 {StdLib => Src/StdLib}/Lib/test/profilee.py | 0 {StdLib => Src/StdLib}/Lib/test/pstats.pck | Bin {StdLib => Src/StdLib}/Lib/test/pycacert.pem | 0 {StdLib => Src/StdLib}/Lib/test/pycakey.pem | 0 .../StdLib}/Lib/test/pyclbr_input.py | 0 {StdLib => Src/StdLib}/Lib/test/pydoc_mod.py | 0 .../StdLib}/Lib/test/pydocfodder.py | 0 {StdLib => Src/StdLib}/Lib/test/pystone.py | 0 {StdLib => Src/StdLib}/Lib/test/randv2_32.pck | 0 {StdLib => Src/StdLib}/Lib/test/randv2_64.pck | 0 {StdLib => Src/StdLib}/Lib/test/randv3.pck | 0 {StdLib => Src/StdLib}/Lib/test/re_tests.py | 0 {StdLib => Src/StdLib}/Lib/test/regrtest.py | 0 {StdLib => Src/StdLib}/Lib/test/relimport.py | 0 {StdLib => Src/StdLib}/Lib/test/reperf.py | 0 .../StdLib}/Lib/test/revocation.crl | 0 .../StdLib}/Lib/test/sample_doctest.py | 0 .../Lib/test/sample_doctest_no_docstrings.py | 0 .../Lib/test/sample_doctest_no_doctests.py | 0 .../StdLib}/Lib/test/script_helper.py | 0 .../Lib/test/selfsigned_pythontestdotnet.pem | 0 {StdLib => Src/StdLib}/Lib/test/seq_tests.py | 0 .../StdLib}/Lib/test/sgml_input.html | 0 {StdLib => Src/StdLib}/Lib/test/sha256.pem | 0 .../StdLib}/Lib/test/sndhdrdata/README | 0 .../StdLib}/Lib/test/sndhdrdata/sndhdr.8svx | Bin .../StdLib}/Lib/test/sndhdrdata/sndhdr.aifc | Bin .../StdLib}/Lib/test/sndhdrdata/sndhdr.aiff | Bin .../StdLib}/Lib/test/sndhdrdata/sndhdr.au | Bin .../StdLib}/Lib/test/sndhdrdata/sndhdr.hcom | Bin .../StdLib}/Lib/test/sndhdrdata/sndhdr.sndt | Bin .../StdLib}/Lib/test/sndhdrdata/sndhdr.voc | Bin .../StdLib}/Lib/test/sndhdrdata/sndhdr.wav | Bin {StdLib => Src/StdLib}/Lib/test/sortperf.py | 0 {StdLib => Src/StdLib}/Lib/test/ssl_cert.pem | 0 .../StdLib}/Lib/test/ssl_key.passwd.pem | 0 {StdLib => Src/StdLib}/Lib/test/ssl_key.pem | 0 .../StdLib}/Lib/test/ssl_servers.py | 0 {StdLib => Src/StdLib}/Lib/test/ssltests.py | 0 .../StdLib}/Lib/test/string_tests.py | 0 .../Lib/test/subprocessdata/fd_status.py | 0 .../Lib/test/subprocessdata/input_reader.py | 0 .../StdLib}/Lib/test/subprocessdata/qcat.py | 0 .../StdLib}/Lib/test/subprocessdata/qgrep.py | 0 .../test/subprocessdata/sigchild_ignore.py | 0 .../StdLib}/Lib/test/support/__init__.py | 0 .../StdLib}/Lib/test/talos-2019-0758.pem | 0 .../StdLib}/Lib/test/test___all__.py | 0 .../StdLib}/Lib/test/test___future__.py | 0 .../StdLib}/Lib/test/test__locale.py | 0 .../StdLib}/Lib/test/test__opcode.py | 0 .../StdLib}/Lib/test/test__osx_support.py | 0 {StdLib => Src/StdLib}/Lib/test/test_abc.py | 0 .../StdLib}/Lib/test/test_abstract_numbers.py | 0 {StdLib => Src/StdLib}/Lib/test/test_aifc.py | 0 .../StdLib}/Lib/test/test_argparse.py | 0 {StdLib => Src/StdLib}/Lib/test/test_array.py | 0 {StdLib => Src/StdLib}/Lib/test/test_ast.py | 0 .../StdLib}/Lib/test/test_asynchat.py | 0 .../StdLib}/Lib/test/test_asyncio/__init__.py | 0 .../StdLib}/Lib/test/test_asyncio/__main__.py | 0 .../StdLib}/Lib/test/test_asyncio/echo.py | 0 .../StdLib}/Lib/test/test_asyncio/echo2.py | 0 .../StdLib}/Lib/test/test_asyncio/echo3.py | 0 .../Lib/test/test_asyncio/keycert3.pem | 0 .../Lib/test/test_asyncio/pycacert.pem | 0 .../Lib/test/test_asyncio/ssl_cert.pem | 0 .../StdLib}/Lib/test/test_asyncio/ssl_key.pem | 0 .../Lib/test/test_asyncio/test_base_events.py | 0 .../Lib/test/test_asyncio/test_events.py | 0 .../Lib/test/test_asyncio/test_futures.py | 0 .../Lib/test/test_asyncio/test_locks.py | 0 .../test/test_asyncio/test_proactor_events.py | 0 .../Lib/test/test_asyncio/test_queues.py | 0 .../test/test_asyncio/test_selector_events.py | 0 .../Lib/test/test_asyncio/test_sslproto.py | 0 .../Lib/test/test_asyncio/test_streams.py | 0 .../Lib/test/test_asyncio/test_subprocess.py | 0 .../Lib/test/test_asyncio/test_tasks.py | 0 .../Lib/test/test_asyncio/test_transports.py | 0 .../Lib/test/test_asyncio/test_unix_events.py | 0 .../test/test_asyncio/test_windows_events.py | 0 .../test/test_asyncio/test_windows_utils.py | 0 .../StdLib}/Lib/test/test_asyncore.py | 0 .../StdLib}/Lib/test/test_atexit.py | 0 .../StdLib}/Lib/test/test_audioop.py | 0 .../StdLib}/Lib/test/test_augassign.py | 0 .../StdLib}/Lib/test/test_base64.py | 0 .../StdLib}/Lib/test/test_bigaddrspace.py | 0 .../StdLib}/Lib/test/test_bigmem.py | 0 .../StdLib}/Lib/test/test_binascii.py | 0 .../StdLib}/Lib/test/test_binhex.py | 0 {StdLib => Src/StdLib}/Lib/test/test_binop.py | 0 .../StdLib}/Lib/test/test_bisect.py | 0 {StdLib => Src/StdLib}/Lib/test/test_bool.py | 0 .../StdLib}/Lib/test/test_buffer.py | 0 {StdLib => Src/StdLib}/Lib/test/test_bufio.py | 0 .../StdLib}/Lib/test/test_builtin.py | 0 {StdLib => Src/StdLib}/Lib/test/test_bytes.py | 0 {StdLib => Src/StdLib}/Lib/test/test_bz2.py | 0 .../StdLib}/Lib/test/test_calendar.py | 0 {StdLib => Src/StdLib}/Lib/test/test_call.py | 0 {StdLib => Src/StdLib}/Lib/test/test_capi.py | 0 {StdLib => Src/StdLib}/Lib/test/test_cgi.py | 0 {StdLib => Src/StdLib}/Lib/test/test_cgitb.py | 0 .../StdLib}/Lib/test/test_charmapcodec.py | 0 {StdLib => Src/StdLib}/Lib/test/test_class.py | 0 {StdLib => Src/StdLib}/Lib/test/test_cmath.py | 0 {StdLib => Src/StdLib}/Lib/test/test_cmd.py | 0 .../StdLib}/Lib/test/test_cmd_line.py | 0 .../StdLib}/Lib/test/test_cmd_line_script.py | 0 {StdLib => Src/StdLib}/Lib/test/test_code.py | 0 .../StdLib}/Lib/test/test_code_module.py | 0 .../StdLib}/Lib/test/test_codeccallbacks.py | 0 .../Lib/test/test_codecencodings_cn.py | 0 .../Lib/test/test_codecencodings_hk.py | 0 .../Lib/test/test_codecencodings_iso2022.py | 0 .../Lib/test/test_codecencodings_jp.py | 0 .../Lib/test/test_codecencodings_kr.py | 0 .../Lib/test/test_codecencodings_tw.py | 0 .../StdLib}/Lib/test/test_codecmaps_cn.py | 0 .../StdLib}/Lib/test/test_codecmaps_hk.py | 0 .../StdLib}/Lib/test/test_codecmaps_jp.py | 0 .../StdLib}/Lib/test/test_codecmaps_kr.py | 0 .../StdLib}/Lib/test/test_codecmaps_tw.py | 0 .../StdLib}/Lib/test/test_codecs.py | 0 .../StdLib}/Lib/test/test_codeop.py | 0 .../StdLib}/Lib/test/test_collections.py | 0 .../StdLib}/Lib/test/test_colorsys.py | 0 .../StdLib}/Lib/test/test_compare.py | 0 .../StdLib}/Lib/test/test_compile.py | 0 .../StdLib}/Lib/test/test_compileall.py | 0 .../StdLib}/Lib/test/test_complex.py | 0 .../Lib/test/test_concurrent_futures.py | 0 .../StdLib}/Lib/test/test_configparser.py | 0 .../StdLib}/Lib/test/test_contains.py | 0 .../StdLib}/Lib/test/test_contextlib.py | 0 {StdLib => Src/StdLib}/Lib/test/test_copy.py | 0 .../StdLib}/Lib/test/test_copyreg.py | 0 .../StdLib}/Lib/test/test_cprofile.py | 0 .../StdLib}/Lib/test/test_crashers.py | 0 {StdLib => Src/StdLib}/Lib/test/test_crypt.py | 0 {StdLib => Src/StdLib}/Lib/test/test_csv.py | 0 .../StdLib}/Lib/test/test_ctypes.py | 0 .../StdLib}/Lib/test/test_curses.py | 0 .../StdLib}/Lib/test/test_datetime.py | 0 {StdLib => Src/StdLib}/Lib/test/test_dbm.py | 0 .../StdLib}/Lib/test/test_dbm_dumb.py | 0 .../StdLib}/Lib/test/test_dbm_gnu.py | 0 .../StdLib}/Lib/test/test_dbm_ndbm.py | 0 .../StdLib}/Lib/test/test_decimal.py | 0 .../StdLib}/Lib/test/test_decorators.py | 0 .../StdLib}/Lib/test/test_defaultdict.py | 0 {StdLib => Src/StdLib}/Lib/test/test_deque.py | 0 {StdLib => Src/StdLib}/Lib/test/test_descr.py | 0 .../StdLib}/Lib/test/test_descrtut.py | 0 .../StdLib}/Lib/test/test_devpoll.py | 0 {StdLib => Src/StdLib}/Lib/test/test_dict.py | 0 .../StdLib}/Lib/test/test_dictcomps.py | 0 .../StdLib}/Lib/test/test_dictviews.py | 0 .../StdLib}/Lib/test/test_difflib.py | 0 .../StdLib}/Lib/test/test_difflib_expect.html | 0 {StdLib => Src/StdLib}/Lib/test/test_dis.py | 0 .../StdLib}/Lib/test/test_distutils.py | 0 .../StdLib}/Lib/test/test_doctest.py | 0 .../StdLib}/Lib/test/test_doctest.txt | 0 .../StdLib}/Lib/test/test_doctest2.py | 0 .../StdLib}/Lib/test/test_doctest2.txt | 0 .../StdLib}/Lib/test/test_doctest3.txt | 0 .../StdLib}/Lib/test/test_doctest4.txt | 0 .../StdLib}/Lib/test/test_docxmlrpc.py | 0 .../StdLib}/Lib/test/test_dummy_thread.py | 0 .../StdLib}/Lib/test/test_dummy_threading.py | 0 .../StdLib}/Lib/test/test_dynamic.py | 0 .../Lib/test/test_dynamicclassattribute.py | 0 .../StdLib}/Lib/test/test_email/__init__.py | 0 .../StdLib}/Lib/test/test_email/__main__.py | 0 .../Lib/test/test_email/data/PyBanner048.gif | Bin .../Lib/test/test_email/data/audiotest.au | Bin .../Lib/test/test_email/data/msg_01.txt | 0 .../Lib/test/test_email/data/msg_02.txt | 0 .../Lib/test/test_email/data/msg_03.txt | 0 .../Lib/test/test_email/data/msg_04.txt | 0 .../Lib/test/test_email/data/msg_05.txt | 0 .../Lib/test/test_email/data/msg_06.txt | 0 .../Lib/test/test_email/data/msg_07.txt | 0 .../Lib/test/test_email/data/msg_08.txt | 0 .../Lib/test/test_email/data/msg_09.txt | 0 .../Lib/test/test_email/data/msg_10.txt | 0 .../Lib/test/test_email/data/msg_11.txt | 0 .../Lib/test/test_email/data/msg_12.txt | 0 .../Lib/test/test_email/data/msg_12a.txt | 0 .../Lib/test/test_email/data/msg_13.txt | 0 .../Lib/test/test_email/data/msg_14.txt | 0 .../Lib/test/test_email/data/msg_15.txt | 0 .../Lib/test/test_email/data/msg_16.txt | 0 .../Lib/test/test_email/data/msg_17.txt | 0 .../Lib/test/test_email/data/msg_18.txt | 0 .../Lib/test/test_email/data/msg_19.txt | 0 .../Lib/test/test_email/data/msg_20.txt | 0 .../Lib/test/test_email/data/msg_21.txt | 0 .../Lib/test/test_email/data/msg_22.txt | 0 .../Lib/test/test_email/data/msg_23.txt | 0 .../Lib/test/test_email/data/msg_24.txt | 0 .../Lib/test/test_email/data/msg_25.txt | 0 .../Lib/test/test_email/data/msg_26.txt | 0 .../Lib/test/test_email/data/msg_27.txt | 0 .../Lib/test/test_email/data/msg_28.txt | 0 .../Lib/test/test_email/data/msg_29.txt | 0 .../Lib/test/test_email/data/msg_30.txt | 0 .../Lib/test/test_email/data/msg_31.txt | 0 .../Lib/test/test_email/data/msg_32.txt | 0 .../Lib/test/test_email/data/msg_33.txt | 0 .../Lib/test/test_email/data/msg_34.txt | 0 .../Lib/test/test_email/data/msg_35.txt | 0 .../Lib/test/test_email/data/msg_36.txt | 0 .../Lib/test/test_email/data/msg_37.txt | 0 .../Lib/test/test_email/data/msg_38.txt | 0 .../Lib/test/test_email/data/msg_39.txt | 0 .../Lib/test/test_email/data/msg_40.txt | 0 .../Lib/test/test_email/data/msg_41.txt | 0 .../Lib/test/test_email/data/msg_42.txt | 0 .../Lib/test/test_email/data/msg_43.txt | 0 .../Lib/test/test_email/data/msg_44.txt | 0 .../Lib/test/test_email/data/msg_45.txt | 0 .../Lib/test/test_email/data/msg_46.txt | 0 .../test/test_email/test__encoded_words.py | 0 .../test_email/test__header_value_parser.py | 0 .../Lib/test/test_email/test_asian_codecs.py | 0 .../test/test_email/test_contentmanager.py | 0 .../test/test_email/test_defect_handling.py | 0 .../StdLib}/Lib/test/test_email/test_email.py | 0 .../Lib/test/test_email/test_generator.py | 0 .../test/test_email/test_headerregistry.py | 0 .../Lib/test/test_email/test_inversion.py | 0 .../Lib/test/test_email/test_message.py | 0 .../Lib/test/test_email/test_parser.py | 0 .../Lib/test/test_email/test_pickleable.py | 0 .../Lib/test/test_email/test_policy.py | 0 .../StdLib}/Lib/test/test_email/test_utils.py | 0 .../Lib/test/test_email/torture_test.py | 0 .../StdLib}/Lib/test/test_ensurepip.py | 0 {StdLib => Src/StdLib}/Lib/test/test_enum.py | 0 .../StdLib}/Lib/test/test_enumerate.py | 0 {StdLib => Src/StdLib}/Lib/test/test_eof.py | 0 {StdLib => Src/StdLib}/Lib/test/test_epoll.py | 0 {StdLib => Src/StdLib}/Lib/test/test_errno.py | 0 .../Lib/test/test_exception_variations.py | 0 .../StdLib}/Lib/test/test_exceptions.py | 0 .../StdLib}/Lib/test/test_extcall.py | 0 .../StdLib}/Lib/test/test_faulthandler.py | 0 {StdLib => Src/StdLib}/Lib/test/test_fcntl.py | 0 {StdLib => Src/StdLib}/Lib/test/test_file.py | 0 .../StdLib}/Lib/test/test_file_eintr.py | 0 .../StdLib}/Lib/test/test_filecmp.py | 0 .../StdLib}/Lib/test/test_fileinput.py | 0 .../StdLib}/Lib/test/test_fileio.py | 0 .../StdLib}/Lib/test/test_finalization.py | 0 {StdLib => Src/StdLib}/Lib/test/test_float.py | 0 {StdLib => Src/StdLib}/Lib/test/test_flufl.py | 0 .../StdLib}/Lib/test/test_fnmatch.py | 0 {StdLib => Src/StdLib}/Lib/test/test_fork1.py | 0 .../StdLib}/Lib/test/test_format.py | 0 .../StdLib}/Lib/test/test_fractions.py | 0 {StdLib => Src/StdLib}/Lib/test/test_frame.py | 0 .../StdLib}/Lib/test/test_fstring.py | 0 .../StdLib}/Lib/test/test_ftplib.py | 0 .../StdLib}/Lib/test/test_funcattrs.py | 0 .../StdLib}/Lib/test/test_functools.py | 0 .../StdLib}/Lib/test/test_future.py | 0 .../StdLib}/Lib/test/test_future3.py | 0 .../StdLib}/Lib/test/test_future4.py | 0 .../StdLib}/Lib/test/test_future5.py | 0 {StdLib => Src/StdLib}/Lib/test/test_gc.py | 0 {StdLib => Src/StdLib}/Lib/test/test_gdb.py | 0 .../StdLib}/Lib/test/test_generators.py | 0 .../StdLib}/Lib/test/test_genericpath.py | 0 .../StdLib}/Lib/test/test_genexps.py | 0 .../StdLib}/Lib/test/test_getargs2.py | 0 .../StdLib}/Lib/test/test_getopt.py | 0 .../StdLib}/Lib/test/test_getpass.py | 0 .../StdLib}/Lib/test/test_gettext.py | 0 {StdLib => Src/StdLib}/Lib/test/test_glob.py | 0 .../StdLib}/Lib/test/test_global.py | 0 .../StdLib}/Lib/test/test_grammar.py | 0 {StdLib => Src/StdLib}/Lib/test/test_grp.py | 0 {StdLib => Src/StdLib}/Lib/test/test_gzip.py | 0 {StdLib => Src/StdLib}/Lib/test/test_hash.py | 0 .../StdLib}/Lib/test/test_hashlib.py | 0 {StdLib => Src/StdLib}/Lib/test/test_heapq.py | 0 {StdLib => Src/StdLib}/Lib/test/test_hmac.py | 0 {StdLib => Src/StdLib}/Lib/test/test_html.py | 0 .../StdLib}/Lib/test/test_htmlparser.py | 0 .../StdLib}/Lib/test/test_http_cookiejar.py | 0 .../StdLib}/Lib/test/test_http_cookies.py | 0 .../StdLib}/Lib/test/test_httplib.py | 0 .../StdLib}/Lib/test/test_httpservers.py | 0 {StdLib => Src/StdLib}/Lib/test/test_idle.py | 0 .../StdLib}/Lib/test/test_imaplib.py | 0 .../StdLib}/Lib/test/test_imghdr.py | 0 {StdLib => Src/StdLib}/Lib/test/test_imp.py | 0 .../StdLib}/Lib/test/test_import.py | 0 .../Lib/test/test_importlib/__init__.py | 0 .../Lib/test/test_importlib/__main__.py | 0 .../StdLib}/Lib/test/test_importlib/abc.py | 0 .../test/test_importlib/builtin/__init__.py | 0 .../test/test_importlib/builtin/__main__.py | 0 .../test_importlib/builtin/test_finder.py | 0 .../test_importlib/builtin/test_loader.py | 0 .../Lib/test/test_importlib/builtin/util.py | 0 .../test/test_importlib/extension/__init__.py | 0 .../test/test_importlib/extension/__main__.py | 0 .../extension/test_case_sensitivity.py | 0 .../test_importlib/extension/test_finder.py | 0 .../test_importlib/extension/test_loader.py | 0 .../extension/test_path_hook.py | 0 .../Lib/test/test_importlib/extension/util.py | 0 .../test/test_importlib/frozen/__init__.py | 0 .../test/test_importlib/frozen/__main__.py | 0 .../test/test_importlib/frozen/test_finder.py | 0 .../test/test_importlib/frozen/test_loader.py | 0 .../test/test_importlib/import_/__init__.py | 0 .../test/test_importlib/import_/__main__.py | 0 .../test_importlib/import_/test___loader__.py | 0 .../import_/test___package__.py | 0 .../test/test_importlib/import_/test_api.py | 0 .../test_importlib/import_/test_caching.py | 0 .../test_importlib/import_/test_fromlist.py | 0 .../test_importlib/import_/test_meta_path.py | 0 .../test_importlib/import_/test_packages.py | 0 .../test/test_importlib/import_/test_path.py | 0 .../import_/test_relative_imports.py | 0 .../Lib/test/test_importlib/import_/util.py | 0 .../namespace_pkgs/both_portions/foo/one.py | 0 .../namespace_pkgs/both_portions/foo/two.py | 0 .../namespace_pkgs/missing_directory.zip | Bin .../module_and_namespace_package/a_test.py | 0 .../module_and_namespace_package/a_test/empty | 0 .../namespace_pkgs/nested_portion1.zip | Bin .../not_a_namespace_pkg/foo/__init__.py | 0 .../not_a_namespace_pkg/foo/one.py | 0 .../namespace_pkgs/portion1/foo/one.py | 0 .../namespace_pkgs/portion2/foo/two.py | 0 .../project1/parent/child/one.py | 0 .../project2/parent/child/two.py | 0 .../project3/parent/child/three.py | 0 .../namespace_pkgs/top_level_portion1.zip | Bin .../Lib/test/test_importlib/regrtest.py | 0 .../test/test_importlib/source/__init__.py | 0 .../test/test_importlib/source/__main__.py | 0 .../source/test_case_sensitivity.py | 0 .../test_importlib/source/test_file_loader.py | 0 .../test/test_importlib/source/test_finder.py | 0 .../test_importlib/source/test_path_hook.py | 0 .../source/test_source_encoding.py | 0 .../Lib/test/test_importlib/source/util.py | 0 .../Lib/test/test_importlib/test_abc.py | 0 .../Lib/test/test_importlib/test_api.py | 0 .../Lib/test/test_importlib/test_locks.py | 0 .../test_importlib/test_namespace_pkgs.py | 0 .../Lib/test/test_importlib/test_spec.py | 0 .../Lib/test/test_importlib/test_util.py | 0 .../Lib/test/test_importlib/test_windows.py | 0 .../StdLib}/Lib/test/test_importlib/util.py | 0 {StdLib => Src/StdLib}/Lib/test/test_index.py | 0 .../StdLib}/Lib/test/test_inspect.py | 0 {StdLib => Src/StdLib}/Lib/test/test_int.py | 0 .../StdLib}/Lib/test/test_int_literal.py | 0 {StdLib => Src/StdLib}/Lib/test/test_io.py | 0 {StdLib => Src/StdLib}/Lib/test/test_ioctl.py | 0 .../StdLib}/Lib/test/test_ipaddress.py | 0 .../StdLib}/Lib/test/test_isinstance.py | 0 {StdLib => Src/StdLib}/Lib/test/test_iter.py | 0 .../StdLib}/Lib/test/test_iterlen.py | 0 .../StdLib}/Lib/test/test_itertools.py | 0 .../StdLib}/Lib/test/test_json/__init__.py | 0 .../StdLib}/Lib/test/test_json/__main__.py | 0 .../StdLib}/Lib/test/test_json/test_decode.py | 0 .../Lib/test/test_json/test_default.py | 0 .../StdLib}/Lib/test/test_json/test_dump.py | 0 .../test_json/test_encode_basestring_ascii.py | 0 .../StdLib}/Lib/test/test_json/test_enum.py | 0 .../StdLib}/Lib/test/test_json/test_fail.py | 0 .../StdLib}/Lib/test/test_json/test_float.py | 0 .../StdLib}/Lib/test/test_json/test_indent.py | 0 .../StdLib}/Lib/test/test_json/test_pass1.py | 0 .../StdLib}/Lib/test/test_json/test_pass2.py | 0 .../StdLib}/Lib/test/test_json/test_pass3.py | 0 .../Lib/test/test_json/test_recursion.py | 0 .../Lib/test/test_json/test_scanstring.py | 0 .../Lib/test/test_json/test_separators.py | 0 .../Lib/test/test_json/test_speedups.py | 0 .../StdLib}/Lib/test/test_json/test_tool.py | 0 .../Lib/test/test_json/test_unicode.py | 0 .../StdLib}/Lib/test/test_keyword.py | 0 .../StdLib}/Lib/test/test_keywordonlyarg.py | 0 .../StdLib}/Lib/test/test_kqueue.py | 0 .../StdLib}/Lib/test/test_largefile.py | 0 .../StdLib}/Lib/test/test_lib2to3.py | 0 .../StdLib}/Lib/test/test_linecache.py | 0 {StdLib => Src/StdLib}/Lib/test/test_list.py | 0 .../StdLib}/Lib/test/test_listcomps.py | 0 .../StdLib}/Lib/test/test_locale.py | 0 .../StdLib}/Lib/test/test_logging.py | 0 {StdLib => Src/StdLib}/Lib/test/test_long.py | 0 .../StdLib}/Lib/test/test_longexp.py | 0 {StdLib => Src/StdLib}/Lib/test/test_lzma.py | 0 .../StdLib}/Lib/test/test_macpath.py | 0 .../StdLib}/Lib/test/test_macurl2path.py | 0 .../StdLib}/Lib/test/test_mailbox.py | 0 .../StdLib}/Lib/test/test_mailcap.py | 0 .../StdLib}/Lib/test/test_marshal.py | 0 {StdLib => Src/StdLib}/Lib/test/test_math.py | 0 .../StdLib}/Lib/test/test_memoryio.py | 0 .../StdLib}/Lib/test/test_memoryview.py | 0 .../StdLib}/Lib/test/test_metaclass.py | 0 .../StdLib}/Lib/test/test_mimetypes.py | 0 .../StdLib}/Lib/test/test_minidom.py | 0 {StdLib => Src/StdLib}/Lib/test/test_mmap.py | 0 .../StdLib}/Lib/test/test_module.py | 0 .../StdLib}/Lib/test/test_modulefinder.py | 0 .../StdLib}/Lib/test/test_msilib.py | 0 .../StdLib}/Lib/test/test_multibytecodec.py | 0 .../Lib/test/test_multiprocessing_fork.py | 0 .../test/test_multiprocessing_forkserver.py | 0 .../test_multiprocessing_main_handling.py | 0 .../Lib/test/test_multiprocessing_spawn.py | 0 {StdLib => Src/StdLib}/Lib/test/test_netrc.py | 0 {StdLib => Src/StdLib}/Lib/test/test_nis.py | 0 .../StdLib}/Lib/test/test_nntplib.py | 0 .../StdLib}/Lib/test/test_normalization.py | 0 .../StdLib}/Lib/test/test_ntpath.py | 0 .../StdLib}/Lib/test/test_numeric_tower.py | 0 .../StdLib}/Lib/test/test_opcodes.py | 0 .../StdLib}/Lib/test/test_openpty.py | 0 .../StdLib}/Lib/test/test_operator.py | 0 .../StdLib}/Lib/test/test_optparse.py | 0 .../StdLib}/Lib/test/test_ordered_dict.py | 0 {StdLib => Src/StdLib}/Lib/test/test_os.py | 0 .../StdLib}/Lib/test/test_ossaudiodev.py | 0 .../StdLib}/Lib/test/test_osx_env.py | 0 .../StdLib}/Lib/test/test_parser.py | 0 .../StdLib}/Lib/test/test_pathlib.py | 0 {StdLib => Src/StdLib}/Lib/test/test_pdb.py | 0 .../StdLib}/Lib/test/test_peepholer.py | 0 .../StdLib}/Lib/test/test_pep247.py | 0 .../StdLib}/Lib/test/test_pep277.py | 0 .../StdLib}/Lib/test/test_pep292.py | 0 .../StdLib}/Lib/test/test_pep3120.py | 0 .../StdLib}/Lib/test/test_pep3131.py | 0 .../StdLib}/Lib/test/test_pep3151.py | 0 .../StdLib}/Lib/test/test_pep352.py | 0 .../StdLib}/Lib/test/test_pep380.py | 0 .../StdLib}/Lib/test/test_pep479.py | 0 .../StdLib}/Lib/test/test_pickle.py | 0 .../StdLib}/Lib/test/test_pickletools.py | 0 {StdLib => Src/StdLib}/Lib/test/test_pipes.py | 0 {StdLib => Src/StdLib}/Lib/test/test_pkg.py | 0 .../StdLib}/Lib/test/test_pkgimport.py | 0 .../StdLib}/Lib/test/test_pkgutil.py | 0 .../StdLib}/Lib/test/test_platform.py | 0 .../StdLib}/Lib/test/test_plistlib.py | 0 {StdLib => Src/StdLib}/Lib/test/test_poll.py | 0 {StdLib => Src/StdLib}/Lib/test/test_popen.py | 0 .../StdLib}/Lib/test/test_poplib.py | 0 {StdLib => Src/StdLib}/Lib/test/test_posix.py | 0 .../StdLib}/Lib/test/test_posixpath.py | 0 {StdLib => Src/StdLib}/Lib/test/test_pow.py | 0 .../StdLib}/Lib/test/test_pprint.py | 0 {StdLib => Src/StdLib}/Lib/test/test_print.py | 0 .../StdLib}/Lib/test/test_profile.py | 0 .../StdLib}/Lib/test/test_property.py | 0 .../StdLib}/Lib/test/test_pstats.py | 0 {StdLib => Src/StdLib}/Lib/test/test_pty.py | 0 .../StdLib}/Lib/test/test_pulldom.py | 0 {StdLib => Src/StdLib}/Lib/test/test_pwd.py | 0 .../StdLib}/Lib/test/test_py_compile.py | 0 .../StdLib}/Lib/test/test_pyclbr.py | 0 {StdLib => Src/StdLib}/Lib/test/test_pydoc.py | 0 .../StdLib}/Lib/test/test_pyexpat.py | 0 {StdLib => Src/StdLib}/Lib/test/test_queue.py | 0 .../StdLib}/Lib/test/test_quopri.py | 0 {StdLib => Src/StdLib}/Lib/test/test_raise.py | 0 .../StdLib}/Lib/test/test_random.py | 0 {StdLib => Src/StdLib}/Lib/test/test_range.py | 0 {StdLib => Src/StdLib}/Lib/test/test_re.py | 0 .../StdLib}/Lib/test/test_readline.py | 0 .../StdLib}/Lib/test/test_regrtest.py | 0 .../StdLib}/Lib/test/test_reprlib.py | 0 .../StdLib}/Lib/test/test_resource.py | 0 .../StdLib}/Lib/test/test_richcmp.py | 0 .../StdLib}/Lib/test/test_rlcompleter.py | 0 .../StdLib}/Lib/test/test_robotparser.py | 0 {StdLib => Src/StdLib}/Lib/test/test_runpy.py | 0 {StdLib => Src/StdLib}/Lib/test/test_sax.py | 0 {StdLib => Src/StdLib}/Lib/test/test_sched.py | 0 {StdLib => Src/StdLib}/Lib/test/test_scope.py | 0 .../StdLib}/Lib/test/test_script_helper.py | 0 .../StdLib}/Lib/test/test_select.py | 0 .../StdLib}/Lib/test/test_selectors.py | 0 {StdLib => Src/StdLib}/Lib/test/test_set.py | 0 .../StdLib}/Lib/test/test_setcomps.py | 0 .../StdLib}/Lib/test/test_shelve.py | 0 {StdLib => Src/StdLib}/Lib/test/test_shlex.py | 0 .../StdLib}/Lib/test/test_shutil.py | 0 .../StdLib}/Lib/test/test_signal.py | 0 {StdLib => Src/StdLib}/Lib/test/test_site.py | 0 {StdLib => Src/StdLib}/Lib/test/test_slice.py | 0 {StdLib => Src/StdLib}/Lib/test/test_smtpd.py | 0 .../StdLib}/Lib/test/test_smtplib.py | 0 .../StdLib}/Lib/test/test_smtpnet.py | 0 .../StdLib}/Lib/test/test_sndhdr.py | 0 .../StdLib}/Lib/test/test_socket.py | 0 .../StdLib}/Lib/test/test_socketserver.py | 0 {StdLib => Src/StdLib}/Lib/test/test_sort.py | 0 .../StdLib}/Lib/test/test_source_encoding.py | 0 {StdLib => Src/StdLib}/Lib/test/test_spwd.py | 0 .../StdLib}/Lib/test/test_sqlite.py | 0 {StdLib => Src/StdLib}/Lib/test/test_ssl.py | 0 .../StdLib}/Lib/test/test_startfile.py | 0 {StdLib => Src/StdLib}/Lib/test/test_stat.py | 0 .../StdLib}/Lib/test/test_statistics.py | 0 .../StdLib}/Lib/test/test_strftime.py | 0 .../StdLib}/Lib/test/test_string.py | 0 .../StdLib}/Lib/test/test_stringprep.py | 0 .../StdLib}/Lib/test/test_strlit.py | 0 .../StdLib}/Lib/test/test_strptime.py | 0 .../StdLib}/Lib/test/test_strtod.py | 0 .../StdLib}/Lib/test/test_struct.py | 0 .../StdLib}/Lib/test/test_structmembers.py | 0 .../StdLib}/Lib/test/test_structseq.py | 0 .../StdLib}/Lib/test/test_subprocess.py | 0 {StdLib => Src/StdLib}/Lib/test/test_sunau.py | 0 .../StdLib}/Lib/test/test_sundry.py | 0 {StdLib => Src/StdLib}/Lib/test/test_super.py | 0 .../StdLib}/Lib/test/test_support.py | 0 .../StdLib}/Lib/test/test_symtable.py | 0 .../StdLib}/Lib/test/test_syntax.py | 0 {StdLib => Src/StdLib}/Lib/test/test_sys.py | 0 .../StdLib}/Lib/test/test_sys_setprofile.py | 0 .../StdLib}/Lib/test/test_sys_settrace.py | 0 .../StdLib}/Lib/test/test_sysconfig.py | 0 .../StdLib}/Lib/test/test_syslog.py | 0 .../StdLib}/Lib/test/test_tarfile.py | 0 {StdLib => Src/StdLib}/Lib/test/test_tcl.py | 0 .../StdLib}/Lib/test/test_telnetlib.py | 0 .../StdLib}/Lib/test/test_tempfile.py | 0 .../StdLib}/Lib/test/test_textwrap.py | 0 .../StdLib}/Lib/test/test_thread.py | 0 .../StdLib}/Lib/test/test_threaded_import.py | 0 .../StdLib}/Lib/test/test_threadedtempfile.py | 0 .../StdLib}/Lib/test/test_threading.py | 0 .../StdLib}/Lib/test/test_threading_local.py | 0 .../StdLib}/Lib/test/test_threadsignals.py | 0 {StdLib => Src/StdLib}/Lib/test/test_time.py | 0 .../StdLib}/Lib/test/test_timeit.py | 0 .../StdLib}/Lib/test/test_timeout.py | 0 {StdLib => Src/StdLib}/Lib/test/test_tk.py | 0 .../StdLib}/Lib/test/test_tokenize.py | 0 .../StdLib}/Lib/test/test_tools/__init__.py | 0 .../StdLib}/Lib/test/test_tools/__main__.py | 0 .../Lib/test/test_tools/test_gprof2html.py | 0 .../Lib/test/test_tools/test_md5sum.py | 0 .../StdLib}/Lib/test/test_tools/test_pdeps.py | 0 .../Lib/test/test_tools/test_pindent.py | 0 .../Lib/test/test_tools/test_reindent.py | 0 .../Lib/test/test_tools/test_sundry.py | 0 .../Lib/test/test_tools/test_unparse.py | 0 {StdLib => Src/StdLib}/Lib/test/test_trace.py | 0 .../StdLib}/Lib/test/test_traceback.py | 0 .../StdLib}/Lib/test/test_tracemalloc.py | 0 .../StdLib}/Lib/test/test_ttk_guionly.py | 0 .../StdLib}/Lib/test/test_ttk_textonly.py | 0 {StdLib => Src/StdLib}/Lib/test/test_tuple.py | 0 .../StdLib}/Lib/test/test_typechecks.py | 0 {StdLib => Src/StdLib}/Lib/test/test_types.py | 0 .../StdLib}/Lib/test/test_typing.py | 0 {StdLib => Src/StdLib}/Lib/test/test_ucn.py | 0 {StdLib => Src/StdLib}/Lib/test/test_unary.py | 0 .../StdLib}/Lib/test/test_unicode.py | 0 .../StdLib}/Lib/test/test_unicode_file.py | 0 .../StdLib}/Lib/test/test_unicodedata.py | 0 .../StdLib}/Lib/test/test_unittest.py | 0 .../StdLib}/Lib/test/test_univnewlines.py | 0 .../StdLib}/Lib/test/test_unpack.py | 0 .../StdLib}/Lib/test/test_unpack_ex.py | 0 .../StdLib}/Lib/test/test_urllib.py | 0 .../StdLib}/Lib/test/test_urllib2.py | 0 .../StdLib}/Lib/test/test_urllib2_localnet.py | 0 .../StdLib}/Lib/test/test_urllib2net.py | 0 .../StdLib}/Lib/test/test_urllib_response.py | 0 .../StdLib}/Lib/test/test_urllibnet.py | 0 .../StdLib}/Lib/test/test_urlparse.py | 0 .../StdLib}/Lib/test/test_userdict.py | 0 .../StdLib}/Lib/test/test_userlist.py | 0 .../StdLib}/Lib/test/test_userstring.py | 0 .../StdLib}/Lib/test/test_utf8_mode.py | 0 {StdLib => Src/StdLib}/Lib/test/test_uu.py | 0 {StdLib => Src/StdLib}/Lib/test/test_uuid.py | 0 {StdLib => Src/StdLib}/Lib/test/test_venv.py | 0 {StdLib => Src/StdLib}/Lib/test/test_wait3.py | 0 {StdLib => Src/StdLib}/Lib/test/test_wait4.py | 0 .../StdLib}/Lib/test/test_warnings.py | 0 {StdLib => Src/StdLib}/Lib/test/test_wave.py | 0 .../StdLib}/Lib/test/test_weakref.py | 0 .../StdLib}/Lib/test/test_weakset.py | 0 .../StdLib}/Lib/test/test_webbrowser.py | 0 .../StdLib}/Lib/test/test_winreg.py | 0 .../StdLib}/Lib/test/test_winsound.py | 0 {StdLib => Src/StdLib}/Lib/test/test_with.py | 0 .../StdLib}/Lib/test/test_wsgiref.py | 0 .../StdLib}/Lib/test/test_xdrlib.py | 0 .../Lib/test/test_xml_dom_minicompat.py | 0 .../StdLib}/Lib/test/test_xml_etree.py | 0 .../StdLib}/Lib/test/test_xml_etree_c.py | 0 .../StdLib}/Lib/test/test_xmlrpc.py | 0 .../StdLib}/Lib/test/test_xmlrpc_net.py | 0 .../StdLib}/Lib/test/test_zipfile.py | 0 .../StdLib}/Lib/test/test_zipfile64.py | 0 .../StdLib}/Lib/test/test_zipimport.py | 0 .../Lib/test/test_zipimport_support.py | 0 {StdLib => Src/StdLib}/Lib/test/test_zlib.py | 0 {StdLib => Src/StdLib}/Lib/test/testcodec.py | 0 {StdLib => Src/StdLib}/Lib/test/testtar.tar | Bin .../StdLib}/Lib/test/tf_inherit_check.py | 0 .../Lib/test/threaded_import_hangers.py | 0 .../StdLib}/Lib/test/time_hashlib.py | 0 ...-latin1-coding-cookie-and-utf8-bom-sig.txt | 0 ...no-coding-cookie-and-utf8-bom-sig-only.txt | 0 ...utf8-coding-cookie-and-no-utf8-bom-sig.txt | 0 ...ts-utf8-coding-cookie-and-utf8-bom-sig.txt | 0 .../StdLib}/Lib/test/tokenize_tests.txt | 0 .../Lib/test/tracedmodules/__init__.py | 0 .../StdLib}/Lib/test/tracedmodules/testmod.py | 0 .../StdLib}/Lib/test/warning_tests.py | 0 .../StdLib}/Lib/test/win_console_handler.py | 0 .../Lib/test/xmltestdata/simple-ns.xml | 0 .../StdLib}/Lib/test/xmltestdata/simple.xml | 0 .../StdLib}/Lib/test/xmltestdata/test.xml | 0 .../StdLib}/Lib/test/xmltestdata/test.xml.out | 0 {StdLib => Src/StdLib}/Lib/test/xmltests.py | 0 .../StdLib}/Lib/test/zip_cp437_header.zip | Bin {StdLib => Src/StdLib}/Lib/test/zipdir.zip | Bin {StdLib => Src/StdLib}/Lib/textwrap.py | 0 {StdLib => Src/StdLib}/Lib/this.py | 0 {StdLib => Src/StdLib}/Lib/threading.py | 0 {StdLib => Src/StdLib}/Lib/timeit.py | 0 .../StdLib}/Lib/tkinter/__init__.py | 0 .../StdLib}/Lib/tkinter/__main__.py | 0 {StdLib => Src/StdLib}/Lib/tkinter/_fix.py | 0 .../StdLib}/Lib/tkinter/colorchooser.py | 0 .../StdLib}/Lib/tkinter/commondialog.py | 0 .../StdLib}/Lib/tkinter/constants.py | 0 {StdLib => Src/StdLib}/Lib/tkinter/dialog.py | 0 {StdLib => Src/StdLib}/Lib/tkinter/dnd.py | 0 .../StdLib}/Lib/tkinter/filedialog.py | 0 {StdLib => Src/StdLib}/Lib/tkinter/font.py | 0 .../StdLib}/Lib/tkinter/messagebox.py | 0 .../StdLib}/Lib/tkinter/scrolledtext.py | 0 .../StdLib}/Lib/tkinter/simpledialog.py | 0 .../StdLib}/Lib/tkinter/test/README | 0 .../StdLib}/Lib/tkinter/test/__init__.py | 0 .../StdLib}/Lib/tkinter/test/runtktests.py | 0 .../StdLib}/Lib/tkinter/test/support.py | 0 .../Lib/tkinter/test/test_tkinter/__init__.py | 0 .../tkinter/test/test_tkinter/test_font.py | 0 .../test_tkinter/test_geometry_managers.py | 0 .../tkinter/test/test_tkinter/test_images.py | 0 .../tkinter/test/test_tkinter/test_loadtk.py | 0 .../tkinter/test/test_tkinter/test_misc.py | 0 .../tkinter/test/test_tkinter/test_text.py | 0 .../test/test_tkinter/test_variables.py | 0 .../tkinter/test/test_tkinter/test_widgets.py | 0 .../Lib/tkinter/test/test_ttk/__init__.py | 0 .../tkinter/test/test_ttk/test_extensions.py | 0 .../tkinter/test/test_ttk/test_functions.py | 0 .../Lib/tkinter/test/test_ttk/test_style.py | 0 .../Lib/tkinter/test/test_ttk/test_widgets.py | 0 .../StdLib}/Lib/tkinter/test/widget_tests.py | 0 {StdLib => Src/StdLib}/Lib/tkinter/tix.py | 0 {StdLib => Src/StdLib}/Lib/tkinter/ttk.py | 0 {StdLib => Src/StdLib}/Lib/token.py | 0 {StdLib => Src/StdLib}/Lib/tokenize.py | 0 {StdLib => Src/StdLib}/Lib/trace.py | 0 {StdLib => Src/StdLib}/Lib/traceback.py | 0 {StdLib => Src/StdLib}/Lib/tracemalloc.py | 0 {StdLib => Src/StdLib}/Lib/tty.py | 0 {StdLib => Src/StdLib}/Lib/turtle.py | 0 .../StdLib}/Lib/turtledemo/__init__.py | 0 .../StdLib}/Lib/turtledemo/__main__.py | 0 .../StdLib}/Lib/turtledemo/bytedesign.py | 0 .../StdLib}/Lib/turtledemo/chaos.py | 0 .../StdLib}/Lib/turtledemo/clock.py | 0 .../StdLib}/Lib/turtledemo/colormixer.py | 0 .../StdLib}/Lib/turtledemo/forest.py | 0 .../StdLib}/Lib/turtledemo/fractalcurves.py | 0 .../StdLib}/Lib/turtledemo/lindenmayer.py | 0 .../StdLib}/Lib/turtledemo/minimal_hanoi.py | 0 {StdLib => Src/StdLib}/Lib/turtledemo/nim.py | 0 .../StdLib}/Lib/turtledemo/paint.py | 0 .../StdLib}/Lib/turtledemo/peace.py | 0 .../StdLib}/Lib/turtledemo/penrose.py | 0 .../StdLib}/Lib/turtledemo/planet_and_moon.py | 0 .../StdLib}/Lib/turtledemo/round_dance.py | 0 {StdLib => Src/StdLib}/Lib/turtledemo/tree.py | 0 .../StdLib}/Lib/turtledemo/turtle.cfg | 0 .../StdLib}/Lib/turtledemo/two_canvases.py | 0 .../StdLib}/Lib/turtledemo/wikipedia.py | 0 .../StdLib}/Lib/turtledemo/yinyang.py | 0 {StdLib => Src/StdLib}/Lib/types.py | 0 {StdLib => Src/StdLib}/Lib/typing.py | 0 .../StdLib}/Lib/unittest/__init__.py | 0 .../StdLib}/Lib/unittest/__main__.py | 0 {StdLib => Src/StdLib}/Lib/unittest/case.py | 0 {StdLib => Src/StdLib}/Lib/unittest/loader.py | 0 {StdLib => Src/StdLib}/Lib/unittest/main.py | 0 {StdLib => Src/StdLib}/Lib/unittest/mock.py | 0 {StdLib => Src/StdLib}/Lib/unittest/result.py | 0 {StdLib => Src/StdLib}/Lib/unittest/runner.py | 0 .../StdLib}/Lib/unittest/signals.py | 0 {StdLib => Src/StdLib}/Lib/unittest/suite.py | 0 .../StdLib}/Lib/unittest/test/__init__.py | 0 .../StdLib}/Lib/unittest/test/__main__.py | 0 .../Lib/unittest/test/_test_warnings.py | 0 .../StdLib}/Lib/unittest/test/dummy.py | 0 .../StdLib}/Lib/unittest/test/support.py | 0 .../Lib/unittest/test/test_assertions.py | 0 .../StdLib}/Lib/unittest/test/test_break.py | 0 .../StdLib}/Lib/unittest/test/test_case.py | 0 .../Lib/unittest/test/test_discovery.py | 0 .../unittest/test/test_functiontestcase.py | 0 .../StdLib}/Lib/unittest/test/test_loader.py | 0 .../StdLib}/Lib/unittest/test/test_program.py | 0 .../StdLib}/Lib/unittest/test/test_result.py | 0 .../StdLib}/Lib/unittest/test/test_runner.py | 0 .../StdLib}/Lib/unittest/test/test_setups.py | 0 .../Lib/unittest/test/test_skipping.py | 0 .../StdLib}/Lib/unittest/test/test_suite.py | 0 .../Lib/unittest/test/testmock/__init__.py | 0 .../Lib/unittest/test/testmock/__main__.py | 0 .../Lib/unittest/test/testmock/support.py | 0 .../unittest/test/testmock/testcallable.py | 0 .../Lib/unittest/test/testmock/testhelpers.py | 0 .../test/testmock/testmagicmethods.py | 0 .../Lib/unittest/test/testmock/testmock.py | 0 .../Lib/unittest/test/testmock/testpatch.py | 0 .../unittest/test/testmock/testsentinel.py | 0 .../Lib/unittest/test/testmock/testwith.py | 0 {StdLib => Src/StdLib}/Lib/unittest/util.py | 0 {StdLib => Src/StdLib}/Lib/urllib/__init__.py | 0 {StdLib => Src/StdLib}/Lib/urllib/error.py | 0 {StdLib => Src/StdLib}/Lib/urllib/parse.py | 0 {StdLib => Src/StdLib}/Lib/urllib/request.py | 0 {StdLib => Src/StdLib}/Lib/urllib/response.py | 0 .../StdLib}/Lib/urllib/robotparser.py | 0 {StdLib => Src/StdLib}/Lib/uu.py | 0 {StdLib => Src/StdLib}/Lib/uuid.py | 0 {StdLib => Src/StdLib}/Lib/venv/__init__.py | 0 {StdLib => Src/StdLib}/Lib/venv/__main__.py | 0 .../StdLib}/Lib/venv/scripts/nt/Activate.ps1 | 0 .../StdLib}/Lib/venv/scripts/nt/activate.bat | 0 .../Lib/venv/scripts/nt/deactivate.bat | 0 .../StdLib}/Lib/venv/scripts/posix/activate | 0 .../Lib/venv/scripts/posix/activate.csh | 0 .../Lib/venv/scripts/posix/activate.fish | 0 {StdLib => Src/StdLib}/Lib/warnings.py | 0 {StdLib => Src/StdLib}/Lib/wave.py | 0 {StdLib => Src/StdLib}/Lib/weakref.py | 0 {StdLib => Src/StdLib}/Lib/webbrowser.py | 0 {StdLib => Src/StdLib}/Lib/wpf.py | 0 .../StdLib}/Lib/wsgiref/__init__.py | 0 .../StdLib}/Lib/wsgiref/handlers.py | 0 {StdLib => Src/StdLib}/Lib/wsgiref/headers.py | 0 .../StdLib}/Lib/wsgiref/simple_server.py | 0 {StdLib => Src/StdLib}/Lib/wsgiref/util.py | 0 .../StdLib}/Lib/wsgiref/validate.py | 0 {StdLib => Src/StdLib}/Lib/xdrlib.py | 0 {StdLib => Src/StdLib}/Lib/xml/__init__.py | 0 .../StdLib}/Lib/xml/dom/NodeFilter.py | 0 .../StdLib}/Lib/xml/dom/__init__.py | 0 {StdLib => Src/StdLib}/Lib/xml/dom/domreg.py | 0 .../StdLib}/Lib/xml/dom/expatbuilder.py | 0 .../StdLib}/Lib/xml/dom/minicompat.py | 0 {StdLib => Src/StdLib}/Lib/xml/dom/minidom.py | 0 {StdLib => Src/StdLib}/Lib/xml/dom/pulldom.py | 0 .../StdLib}/Lib/xml/dom/xmlbuilder.py | 0 .../StdLib}/Lib/xml/etree/ElementInclude.py | 0 .../StdLib}/Lib/xml/etree/ElementPath.py | 0 .../StdLib}/Lib/xml/etree/ElementTree.py | 0 .../StdLib}/Lib/xml/etree/__init__.py | 0 .../StdLib}/Lib/xml/etree/cElementTree.py | 0 .../StdLib}/Lib/xml/parsers/__init__.py | 0 .../StdLib}/Lib/xml/parsers/expat.py | 0 .../StdLib}/Lib/xml/sax/__init__.py | 0 .../StdLib}/Lib/xml/sax/_exceptions.py | 0 .../StdLib}/Lib/xml/sax/expatreader.py | 0 {StdLib => Src/StdLib}/Lib/xml/sax/handler.py | 0 .../StdLib}/Lib/xml/sax/saxutils.py | 0 .../StdLib}/Lib/xml/sax/xmlreader.py | 0 {StdLib => Src/StdLib}/Lib/xmlrpc/__init__.py | 0 {StdLib => Src/StdLib}/Lib/xmlrpc/client.py | 0 {StdLib => Src/StdLib}/Lib/xmlrpc/server.py | 0 {StdLib => Src/StdLib}/Lib/zipfile.py | 0 {StdLib => Src/StdLib}/StdLib.License.txt | 0 {StdLib => Src/StdLib}/StdLib.pyproj | 0 {StdLib => Src/StdLib}/stdlib-upgrade.txt | 0 {StdLib => Src/StdLib}/update-stdlib.cmd | 0 {StdLib => Src/StdLib}/update-stdlib.sh | 0 {Tests => Src/Tests}/AssemblyInfo.cs | 0 {Tests => Src/Tests}/AttrInjectorTest.cs | 0 {Tests => Src/Tests}/BindTest.cs | 0 {Tests => Src/Tests}/BinderTest.cs | 0 {Tests => Src/Tests}/Cases/CPythonCases.cs | 0 .../Tests}/Cases/CPythonCasesManifest.ini | 0 {Tests => Src/Tests}/Cases/CaseExecuter.cs | 0 {Tests => Src/Tests}/Cases/CaseGenerator.cs | 0 {Tests => Src/Tests}/Cases/CommonCases.cs | 0 {Tests => Src/Tests}/Cases/IronPythonCases.cs | 0 .../Tests}/Cases/IronPythonCasesManifest.ini | 0 {Tests => Src/Tests}/ClrType.cs | 0 {Tests => Src/Tests}/Cmplx.cs | 0 {Tests => Src/Tests}/Conversions.cs | 0 {Tests => Src/Tests}/DeTest.cs | 0 {Tests => Src/Tests}/DelegateTest.cs | 0 {Tests => Src/Tests}/DynamicRegressions.cs | 0 {Tests => Src/Tests}/EncodingTest.cs | 0 {Tests => Src/Tests}/EngineTest.cs | 0 {Tests => Src/Tests}/Enums.cs | 0 {Tests => Src/Tests}/Events.cs | 0 {Tests => Src/Tests}/ExceptionConverter.cs | 0 {Tests => Src/Tests}/Exceptions.cs | 0 {Tests => Src/Tests}/Explicit.cs | 0 {Tests => Src/Tests}/ExtensionMethodTest.cs | 0 {Tests => Src/Tests}/GenMeth.cs | 0 {Tests => Src/Tests}/Indexable.cs | 0 {Tests => Src/Tests}/InheritTest.cs | 0 {Tests => Src/Tests}/IntegerTest.cs | 0 {Tests => Src/Tests}/IronMath.cs | 0 {Tests => Src/Tests}/IronPython.Tests.csproj | 0 {Tests => Src/Tests}/LoadTest.cs | 0 {Tests => Src/Tests}/MemberMappingTests.cs | 0 {Tests => Src/Tests}/MemberOverloadTest.cs | 0 {Tests => Src/Tests}/MethodParametersStubs.cs | 0 {Tests => Src/Tests}/NestedClass.cs | 0 {Tests => Src/Tests}/NullableTest.cs | 0 {Tests => Src/Tests}/OperatorTest.cs | 0 {Tests => Src/Tests}/ProtocolTest.cs | 0 {Tests => Src/Tests}/StaticTest.cs | 0 {Tests => Src/Tests}/Stress/Engine.cs | 0 .../Tests}/StringDictionaryStorage.cs | 0 {Tests => Src/Tests}/TestBuiltinModule.cs | 0 {Tests => Src/Tests}/TypeDescriptor.cs | 0 {Tests => Src/Tests}/Util/IniParser.cs | 0 {Tests => Src/Tests}/Util/TestManifest.cs | 0 {Wpf => Src/Wpf}/DynamicXamlReader.cs | 0 {Wpf => Src/Wpf}/IronPython.Wpf.csproj | 0 {Wpf => Src/Wpf}/Properties/AssemblyInfo.cs | 0 {Wpf => Src/Wpf}/_wpf.cs | 0 2686 files changed, 22 insertions(+), 22 deletions(-) rename App.Debug.config => Src/App.Debug.config (100%) rename App.Release.config => Src/App.Release.config (100%) rename {CTypes => Src/CTypes}/Makefile (100%) rename {CTypes => Src/CTypes}/_ctypes_test.c (100%) rename {CTypes => Src/CTypes}/_ctypes_test.sln (100%) rename {CTypes => Src/CTypes}/_ctypes_test.vcxproj (100%) rename {CompilerServices => Src/CompilerServices}/AssemblyResolver.cs (100%) rename {CompilerServices => Src/CompilerServices}/Config.cs (100%) rename {CompilerServices => Src/CompilerServices}/ConsoleOps.cs (100%) rename {CompilerServices => Src/CompilerServices}/IronPython.CompilerServices.csproj (84%) rename {CompilerServices => Src/CompilerServices}/Program.cs (100%) rename {CompilerServices => Src/CompilerServices}/Properties/AssemblyInfo.cs (100%) rename {CompilerServices => Src/CompilerServices}/README.md (100%) rename {Console.Host => Src/Console.Host}/IronPython.Console.Host.csproj (100%) rename {Console.Host => Src/Console.Host}/IronPythonWindow.cs (100%) rename {Console.Host => Src/Console.Host}/Properties/AssemblyInfo.cs (100%) rename {Console.Host => Src/Console.Host}/ipyw.ico (100%) rename {Console => Src/Console}/Console.cs (100%) rename {Console => Src/Console}/IronPython.Console.csproj (100%) rename {Console => Src/Console}/Properties/AssemblyInfo.cs (100%) rename {Console => Src/Console}/app.manifest (100%) rename {Console => Src/Console}/ipy-mono.sh (100%) rename {Console => Src/Console}/ipy.ico (100%) rename {Console => Src/Console}/ipy.sh (100%) rename {Console => Src/Console}/runtimeconfig.template.json (100%) rename {Console32.Host => Src/Console32.Host}/IronPython.Console32.Host.csproj (79%) rename {Console32 => Src/Console32}/IronPython.Console32.csproj (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/AndExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/AnnotatedAssignStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/AssertStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/AssignmentStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/AstMethods.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/AsyncStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/AugmentedAssignStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/BinaryExpression.Generated.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/BinaryExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/BreakStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/CallExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/ClassDefinition.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/Comprehension.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/ComprehensionFor.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/ComprehensionIf.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/ConditionalExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/ConstantExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/ContinueStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/DelStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/DictionaryExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/DottedName.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/DynamicConvertExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/DynamicGetMemberExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/EmptyStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/ErrorExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/Expression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/ExpressionStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/FlowChecker.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/ForStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/FormattedValueExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/FromImportStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/FunctionDefinition.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/GeneratorExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/GetGlobalContextExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/GetParentContextFromFunctionExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/GlobalStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/ILoopStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/IfStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/IfStatementTest.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/ImportStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/IndexExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/JoinedStringExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/Keyword.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/LambdaExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/ListExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/MemberExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/ModuleName.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/NameExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/Node.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/NonlocalStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/OrExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/Parameter.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/ParenthesisExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/PythonAst.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/PythonConstantExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/PythonNameBinder.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/PythonReference.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/PythonVariable.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/PythonWalker.Generated.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/RaiseStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/RelativeModuleName.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/ReturnStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/ScopeStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/SequenceExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/SerializedScopeStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/SetExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/SliceExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/StarredExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/Statement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/SuiteStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/TryStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/TupleExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/UnaryExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/VariableKind.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/WhileStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/WithStatement.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/YieldExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Ast/YieldFromExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/ClosureExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/ClosureInfo.cs (100%) rename {IronPython => Src/IronPython}/Compiler/CollectableCompilationMode.cs (100%) rename {IronPython => Src/IronPython}/Compiler/CompilationMode.cs (100%) rename {IronPython => Src/IronPython}/Compiler/GeneratorRewriter.cs (100%) rename {IronPython => Src/IronPython}/Compiler/LazyCode.cs (100%) rename {IronPython => Src/IronPython}/Compiler/LookupCompilationMode.cs (100%) rename {IronPython => Src/IronPython}/Compiler/OnDiskScriptCode.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Parser.cs (100%) rename {IronPython => Src/IronPython}/Compiler/PythonCallTargets.cs (100%) rename {IronPython => Src/IronPython}/Compiler/PythonCompilerOptions.cs (100%) rename {IronPython => Src/IronPython}/Compiler/PythonDynamicExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/PythonGlobal.cs (100%) rename {IronPython => Src/IronPython}/Compiler/PythonGlobalVariableExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/PythonOperator.cs (100%) rename {IronPython => Src/IronPython}/Compiler/PythonSavableScriptCode.cs (100%) rename {IronPython => Src/IronPython}/Compiler/PythonScriptCode.cs (100%) rename {IronPython => Src/IronPython}/Compiler/ReducableDynamicExpression.cs (100%) rename {IronPython => Src/IronPython}/Compiler/RunnableScriptCode.cs (100%) rename {IronPython => Src/IronPython}/Compiler/RuntimeScriptCode.cs (100%) rename {IronPython => Src/IronPython}/Compiler/ToDiskCompilationMode.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Token.cs (100%) rename {IronPython => Src/IronPython}/Compiler/TokenKind.Generated.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Tokenizer.Generated.cs (100%) rename {IronPython => Src/IronPython}/Compiler/Tokenizer.cs (100%) rename {IronPython => Src/IronPython}/Compiler/UncollectableCompilationMode.Generated.cs (100%) rename {IronPython => Src/IronPython}/Compiler/UncollectableCompilationMode.cs (100%) rename {IronPython => Src/IronPython}/FakeInteropServices.cs (100%) rename {IronPython => Src/IronPython}/Hosting/Python.cs (100%) rename {IronPython => Src/IronPython}/Hosting/PythonCodeDomCodeGen.cs (100%) rename {IronPython => Src/IronPython}/Hosting/PythonCommandLine.cs (100%) rename {IronPython => Src/IronPython}/Hosting/PythonConsoleOptions.cs (100%) rename {IronPython => Src/IronPython}/Hosting/PythonOptionsParser.cs (100%) rename {IronPython => Src/IronPython}/Hosting/PythonService.cs (100%) rename {IronPython => Src/IronPython}/Interop/Windows/Interop.Libraries.cs (100%) rename {IronPython => Src/IronPython}/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs (100%) rename {IronPython => Src/IronPython}/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs (100%) rename {IronPython => Src/IronPython}/Interop/Windows/NtDll/Interop.RtlGetVersion.cs (100%) rename {IronPython => Src/IronPython}/Interop/Windows/Ucrtbase/Interop.strerror.cs (100%) rename {IronPython => Src/IronPython}/IronPython.csproj (94%) rename {IronPython => Src/IronPython}/Lib/iptest/__init__.py (100%) rename {IronPython => Src/IronPython}/Lib/iptest/cominterop_util.py (100%) rename {IronPython => Src/IronPython}/Lib/iptest/console_util.py (100%) rename {IronPython => Src/IronPython}/Lib/iptest/file_util.py (100%) rename {IronPython => Src/IronPython}/Lib/iptest/ipunittest.py (100%) rename {IronPython => Src/IronPython}/Lib/iptest/misc_util.py (100%) rename {IronPython => Src/IronPython}/Lib/iptest/process_util.py (100%) rename {IronPython => Src/IronPython}/Lib/iptest/runner.py (100%) rename {IronPython => Src/IronPython}/Lib/iptest/test_env.py (100%) rename {IronPython => Src/IronPython}/Lib/iptest/type_util.py (100%) rename {IronPython => Src/IronPython}/Modules/Builtin.Generated.cs (100%) rename {IronPython => Src/IronPython}/Modules/Builtin.cs (100%) rename {IronPython => Src/IronPython}/Modules/_ast.cs (100%) mode change 100644 => 100755 rename {IronPython => Src/IronPython}/Modules/_fileio.cs (100%) rename {IronPython => Src/IronPython}/Modules/_imp.cs (100%) rename {IronPython => Src/IronPython}/Modules/_io.cs (100%) rename {IronPython => Src/IronPython}/Modules/_io/BytesIO.cs (100%) rename {IronPython => Src/IronPython}/Modules/_io/StringIO.cs (100%) rename {IronPython => Src/IronPython}/Modules/_locale.cs (100%) rename {IronPython => Src/IronPython}/Modules/sys.cs (100%) rename {IronPython => Src/IronPython}/Modules/unicodedata.cs (100%) rename {IronPython => Src/IronPython}/Modules/unicodedata/CaseFolding.txt (100%) rename {IronPython => Src/IronPython}/Modules/unicodedata/EastAsianWidth-3.2.0.txt (100%) rename {IronPython => Src/IronPython}/Modules/unicodedata/EastAsianWidth.txt (100%) rename {IronPython => Src/IronPython}/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz (100%) rename {IronPython => Src/IronPython}/Modules/unicodedata/IPyUnicodeData.txt.gz (100%) rename {IronPython => Src/IronPython}/Modules/unicodedata/NameAliases.txt (100%) rename {IronPython => Src/IronPython}/Modules/unicodedata/UnicodeData-3.2.0.txt (100%) rename {IronPython => Src/IronPython}/Modules/unicodedata/UnicodeData.txt (100%) rename {IronPython => Src/IronPython}/Modules/unicodedata/genunicodedata.py (100%) rename {IronPython => Src/IronPython}/Modules/unicodedata/license.txt (100%) rename {IronPython => Src/IronPython}/Properties/AssemblyInfo.cs (100%) rename {IronPython => Src/IronPython}/Resources.Designer.cs (100%) rename {IronPython => Src/IronPython}/Resources.resx (100%) rename {IronPython => Src/IronPython}/Runtime/ArrayData.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/BinaryRetTypeBinder.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/BinaryRetTypeBinder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/Binders.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/BindingHelpers.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/BindingWarnings.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/CompatibilityInvokeBinder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/ConditionalBuilder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/ContextArgBuilder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/ConversionBinder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/CreateFallbackBinder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/FastBindResult.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/FastGetBase.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/FastSetBase.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/IComConvertible.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/IFastGettable.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/IFastInvokable.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/IFastSettable.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/IPythonConvertible.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/IPythonExpandable.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/IPythonGetable.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/IPythonInvokable.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/IPythonOperable.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/IPythonSite.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/MetaBuiltinFunction.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/MetaBuiltinMethodDescriptor.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/MetaMethod.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/MetaPythonFunction.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/MetaPythonObject.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/MetaPythonType.Calls.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/MetaPythonType.Members.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/MetaPythonType.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/MetaUserObject.Members.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/MetaUserObject.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/PythonBinaryOperationBinder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/PythonBinder.Create.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/PythonBinder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/PythonDeleteIndexBinder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/PythonDeleteMemberBinder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/PythonDeleteSliceBinder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/PythonExtensionBinder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/PythonGetIndexBinder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/PythonGetMemberBinder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/PythonGetSliceBinder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/PythonIndexType.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/PythonInvokeBinder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/PythonOperationBinder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/PythonOperationKind.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/PythonOverloadResolver.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/PythonProtocol.Operations.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/PythonProtocol.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/PythonSetIndexBinder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/PythonSetMemberBinder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/PythonSetSliceBinder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/PythonUnaryOperationBinder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/SiteLocalStorageBuilder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/SlotOrFunction.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Binding/WarningInfo.cs (100%) rename {IronPython => Src/IronPython}/Runtime/BufferProtocol.cs (100%) rename {IronPython => Src/IronPython}/Runtime/BuiltinPythonModule.cs (100%) rename {IronPython => Src/IronPython}/Runtime/BuiltinsDictionaryStorage.cs (100%) rename {IronPython => Src/IronPython}/Runtime/ByteArray.cs (100%) rename {IronPython => Src/IronPython}/Runtime/ByteArrayIterator.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Bytes.cs (100%) rename {IronPython => Src/IronPython}/Runtime/BytesIterator.cs (100%) rename {IronPython => Src/IronPython}/Runtime/BytesLikeAttribute.cs (100%) rename {IronPython => Src/IronPython}/Runtime/ClassMethodAttribute.cs (100%) rename {IronPython => Src/IronPython}/Runtime/ClassMethodDescriptor.cs (100%) rename {IronPython => Src/IronPython}/Runtime/ClrModule.cs (100%) rename {IronPython => Src/IronPython}/Runtime/CodeContext.cs (100%) rename {IronPython => Src/IronPython}/Runtime/CollectionDebugView.cs (100%) rename {IronPython => Src/IronPython}/Runtime/CommonDictionaryStorage.cs (100%) rename {IronPython => Src/IronPython}/Runtime/CompareUtil.cs (100%) rename {IronPython => Src/IronPython}/Runtime/CompileFlags.cs (100%) rename {IronPython => Src/IronPython}/Runtime/CompiledLoader.cs (100%) rename {IronPython => Src/IronPython}/Runtime/ConstantDictionaryStorage.cs (100%) rename {IronPython => Src/IronPython}/Runtime/ConversionWrappers.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Converter.cs (100%) rename {IronPython => Src/IronPython}/Runtime/CustomDictionaryStorage.cs (100%) rename {IronPython => Src/IronPython}/Runtime/DebuggerDictionaryStorage.cs (100%) rename {IronPython => Src/IronPython}/Runtime/DefaultContext.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Descriptors.cs (100%) rename {IronPython => Src/IronPython}/Runtime/DictionaryOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/DictionaryStorage.cs (100%) rename {IronPython => Src/IronPython}/Runtime/DictionaryTypeInfoAttribute.cs (100%) rename {IronPython => Src/IronPython}/Runtime/DontMapGetMemberNamesToDirAttribute.cs (100%) rename {IronPython => Src/IronPython}/Runtime/DontMapICollectionToLenAttribute.cs (100%) rename {IronPython => Src/IronPython}/Runtime/DontMapIDisposableToContextManagerAttribute.cs (100%) rename {IronPython => Src/IronPython}/Runtime/DontMapIEnumerableToContainsAttribute.cs (100%) rename {IronPython => Src/IronPython}/Runtime/DontMapIEnumerableToIterAttribute.cs (100%) rename {IronPython => Src/IronPython}/Runtime/EmptyDictionaryStorage.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Enumerate.cs (100%) rename {IronPython => Src/IronPython}/Runtime/ErrorCodes.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/AssertionException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/AttributeErrorException.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/BlockingIOException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/BrokenPipeException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/BufferException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/BytesWarningException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/ChildProcessException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/ConnectionAbortedException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/ConnectionException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/ConnectionRefusedException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/ConnectionResetException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/DeprecationWarningException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/FileExistsException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/FloatingPointException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/FutureWarningException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/GeneratorExitException.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/ImportException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/ImportWarningException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/IndentationException.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/InterruptedException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/IsADirectoryException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/LookupException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/ModuleNotFoundException.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/NotADirectoryException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/OSException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/ProcessLookupException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/PythonException.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/PythonExceptions.BaseException.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/PythonExceptions.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/PythonExceptions.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/RecursionException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/ReferenceException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/ResourceWarningException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/RuntimeException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/RuntimeWarningException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/StopAsyncIterationException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/StopIterationException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/SyntaxWarningException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/SystemExitException.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/TabException.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/TraceBack.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/TypeErrorException.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/UnicodeException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/UnicodeTranslateException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/UnicodeWarningException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/UserWarningException.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Exceptions/ValueErrorException.cs (100%) rename {IronPython => Src/IronPython}/Runtime/ExtensionMethodSet.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Filter.cs (100%) rename {IronPython => Src/IronPython}/Runtime/FormattingHelper.cs (100%) rename {IronPython => Src/IronPython}/Runtime/FunctionAttributes.cs (100%) rename {IronPython => Src/IronPython}/Runtime/FunctionCode.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Generator.cs (100%) rename {IronPython => Src/IronPython}/Runtime/GlobalDictionaryStorage.cs (100%) rename {IronPython => Src/IronPython}/Runtime/IParameterSequence.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Implementation.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Importer.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Index.cs (100%) rename {IronPython => Src/IronPython}/Runtime/InstancedModuleDictionaryStorage.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Interfaces.cs (100%) rename {IronPython => Src/IronPython}/Runtime/KwCallInfo.cs (100%) rename {IronPython => Src/IronPython}/Runtime/LiteralParser.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Map.cs (100%) rename {IronPython => Src/IronPython}/Runtime/MaybeNotImplementedAttribute.cs (100%) rename {IronPython => Src/IronPython}/Runtime/MemoryStreamContentProvider.cs (100%) rename {IronPython => Src/IronPython}/Runtime/MemoryView.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Method.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Method.cs (100%) rename {IronPython => Src/IronPython}/Runtime/MissingParameter.cs (100%) rename {IronPython => Src/IronPython}/Runtime/ModuleContext.cs (100%) rename {IronPython => Src/IronPython}/Runtime/ModuleDictionaryStorage.cs (100%) rename {IronPython => Src/IronPython}/Runtime/ModuleGlobalCache.cs (100%) rename {IronPython => Src/IronPython}/Runtime/ModuleLoader.cs (100%) rename {IronPython => Src/IronPython}/Runtime/ModuleOptions.cs (100%) rename {IronPython => Src/IronPython}/Runtime/NameType.cs (100%) rename {IronPython => Src/IronPython}/Runtime/NewStringFormatter.cs (100%) rename {IronPython => Src/IronPython}/Runtime/ObjectAttributesAdapter.cs (100%) rename {IronPython => Src/IronPython}/Runtime/ObjectDebugView.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/ArrayOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/BigIntegerOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/BoolOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/ByteOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/CharOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/ComOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/ComplexOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/CustomTypeDescHelpers.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/DBNullOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/DateTimeOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/DecimalOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/DelegateOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/DictionaryOfTOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/EnumOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/FloatOps.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/FloatOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/IListOfByteOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/InstanceOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/IntOps.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/IntOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/IntPtrOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/ListOfTOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/MarshalOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/NamespaceTrackerOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/ObjectOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/PythonCalls.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/PythonOps.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/PythonOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/PythonTypeOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/StringOps.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/StringOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/TypeGroupOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/TypeTrackerOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/UIntPtrOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Operations/UserTypeOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/OutputWriter.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PlatformsAttribute.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Profiler.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PythonContext.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PythonContext.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PythonDictionary.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PythonDocumentationProvider.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PythonDynamicStackFrame.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PythonEncoding.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PythonFileManager.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PythonFunction.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PythonFunction.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PythonHiddenAttribute.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PythonHiddenBaseClassAttribute.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PythonList.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PythonModule.cs (100%) mode change 100644 => 100755 rename {IronPython => Src/IronPython}/Runtime/PythonModuleAttribute.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PythonNarrowing.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PythonOptions.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PythonRange.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PythonScopeExtension.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PythonStrIterator.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PythonTracebackListener.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PythonTuple.cs (100%) rename {IronPython => Src/IronPython}/Runtime/PythonTypeAttribute.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Reversed.cs (100%) rename {IronPython => Src/IronPython}/Runtime/RuntimeVariablesDictionaryStorage.cs (100%) rename {IronPython => Src/IronPython}/Runtime/ScopeDictionaryStorage.cs (100%) rename {IronPython => Src/IronPython}/Runtime/SequenceTypeInfoAttribute.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Set.cs (100%) rename {IronPython => Src/IronPython}/Runtime/SetStorage.cs (100%) rename {IronPython => Src/IronPython}/Runtime/SimpleNamespace.cs (100%) rename {IronPython => Src/IronPython}/Runtime/SiteLocalStorage.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Slice.cs (100%) rename {IronPython => Src/IronPython}/Runtime/StringDictionaryStorage.cs (100%) rename {IronPython => Src/IronPython}/Runtime/StringFormatSpec.cs (100%) rename {IronPython => Src/IronPython}/Runtime/StringFormatter.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Super.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Symbols.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/ThrowingErrorSink.cs (100%) rename {IronPython => Src/IronPython}/Runtime/TypecodeOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/BuiltinFunction.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/BuiltinFunctionOverloadMapper.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/BuiltinMethodDescriptor.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/CachedNewTypeInfo.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/ConstructorFunction.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/CustomAttributeTracker.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/CustomInstanceDictionaryStorage.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/DocBuilder.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/DynamicBaseTypeAttribute.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/DynamicHelpers.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/EmptyType.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/ExtensionPropertyInfo.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/FunctionType.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/IPythonObject.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/InstanceCreator.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/MappingProxy.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/Mro.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/NameConverter.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/NewTypeInfo.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/NewTypeMaker.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/OperatorMapping.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/ParameterInfoWrapper.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/PythonAssemblyOps.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/PythonSiteCache.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/PythonType.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/PythonType.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/PythonTypeDataSlot.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/PythonTypeDictSlot.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/PythonTypeInfo.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/PythonTypeInfo.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/PythonTypeSlot.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/PythonTypeTypeSlot.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/PythonTypeUserDescriptorSlot.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/PythonTypeWeakRefSlot.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/ReflectedEvent.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/ReflectedExtensionProperty.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/ReflectedField.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/ReflectedGetterSetter.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/ReflectedIndexer.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/ReflectedProperty.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/ReflectedSlotProperty.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/ResolvedMember.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/SlotFieldAttribute.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/StaticUnderlyingSystemType.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Types/TypeCache.Generated.cs (100%) rename {IronPython => Src/IronPython}/Runtime/UnboundNameException.cs (100%) rename {IronPython => Src/IronPython}/Runtime/WeakRef.cs (100%) rename {IronPython => Src/IronPython}/Runtime/WrapperDescriptorAttribute.cs (100%) rename {IronPython => Src/IronPython}/Runtime/WrapperDictionary.cs (100%) rename {IronPython => Src/IronPython}/Runtime/Zip.cs (100%) rename {IronPython => Src/IronPython}/SerializationStubs.cs (100%) rename {IronPython => Src/IronPython}/StringExtensions.cs (100%) rename {IronPython => Src/IronPython}/SystemRuntimeVersioning.cs (100%) rename {IronPython => Src/IronPython}/policy.IronPython.config (100%) rename {Modules => Src/Modules}/IronPython.Modules.csproj (89%) rename {Modules => Src/Modules}/IterTools.cs (100%) rename {Modules => Src/Modules}/ModuleOps.cs (100%) rename {Modules => Src/Modules}/NtSignalState.cs (100%) rename {Modules => Src/Modules}/Properties/AssemblyInfo.cs (100%) rename {Modules => Src/Modules}/ResourceMetaPathImporter.cs (100%) rename {Modules => Src/Modules}/SimpleSignalState.cs (100%) rename {Modules => Src/Modules}/_bisect.cs (100%) rename {Modules => Src/Modules}/_codecs.cs (100%) rename {Modules => Src/Modules}/_codecs_cn.cs (100%) rename {Modules => Src/Modules}/_collections.cs (100%) rename {Modules => Src/Modules}/_csv.cs (100%) rename {Modules => Src/Modules}/_ctypes/Array.cs (100%) rename {Modules => Src/Modules}/_ctypes/ArrayType.cs (100%) rename {Modules => Src/Modules}/_ctypes/CData.cs (100%) rename {Modules => Src/Modules}/_ctypes/CFuncPtr.cs (100%) rename {Modules => Src/Modules}/_ctypes/CFuncPtrType.cs (100%) rename {Modules => Src/Modules}/_ctypes/Extensions.cs (100%) rename {Modules => Src/Modules}/_ctypes/Field.cs (100%) rename {Modules => Src/Modules}/_ctypes/INativeType.cs (100%) rename {Modules => Src/Modules}/_ctypes/LocalOrArg.cs (100%) rename {Modules => Src/Modules}/_ctypes/MarshalCleanup.cs (100%) rename {Modules => Src/Modules}/_ctypes/MemoryHolder.cs (100%) rename {Modules => Src/Modules}/_ctypes/NativeArgument.cs (100%) rename {Modules => Src/Modules}/_ctypes/NativeFunctions.cs (100%) rename {Modules => Src/Modules}/_ctypes/Pointer.cs (100%) rename {Modules => Src/Modules}/_ctypes/PointerType.cs (100%) rename {Modules => Src/Modules}/_ctypes/SimpleCData.cs (100%) rename {Modules => Src/Modules}/_ctypes/SimpleType.cs (100%) rename {Modules => Src/Modules}/_ctypes/SimpleTypeKind.cs (100%) rename {Modules => Src/Modules}/_ctypes/StructType.cs (100%) rename {Modules => Src/Modules}/_ctypes/Structure.cs (100%) rename {Modules => Src/Modules}/_ctypes/Union.cs (100%) rename {Modules => Src/Modules}/_ctypes/UnionType.cs (100%) rename {Modules => Src/Modules}/_ctypes/_ctypes.cs (100%) rename {Modules => Src/Modules}/_ctypes_test.cs (100%) rename {Modules => Src/Modules}/_datetime.cs (100%) rename {Modules => Src/Modules}/_functools.cs (100%) rename {Modules => Src/Modules}/_heapq.cs (100%) rename {Modules => Src/Modules}/_multibytecodec.cs (100%) rename {Modules => Src/Modules}/_multiprocessing.cs (100%) rename {Modules => Src/Modules}/_opcode.cs (100%) rename {Modules => Src/Modules}/_operator.cs (100%) rename {Modules => Src/Modules}/_overlapped.cs (100%) rename {Modules => Src/Modules}/_pickle.cs (100%) rename {Modules => Src/Modules}/_posixsubprocess.cs (100%) rename {Modules => Src/Modules}/_random.RandomGen.cs (100%) rename {Modules => Src/Modules}/_random.cs (100%) rename {Modules => Src/Modules}/_socket.cs (100%) rename {Modules => Src/Modules}/_sre.cs (100%) rename {Modules => Src/Modules}/_ssl.cs (100%) rename {Modules => Src/Modules}/_string.cs (100%) rename {Modules => Src/Modules}/_struct.cs (100%) rename {Modules => Src/Modules}/_sysconfigdata.cs (100%) rename {Modules => Src/Modules}/_thread.cs (100%) rename {Modules => Src/Modules}/_warnings.cs (100%) rename {Modules => Src/Modules}/_weakref.Generated.cs (100%) rename {Modules => Src/Modules}/_weakref.cs (100%) rename {Modules => Src/Modules}/_winapi.cs (100%) rename {Modules => Src/Modules}/array.cs (100%) rename {Modules => Src/Modules}/atexit.cs (100%) rename {Modules => Src/Modules}/audioop.cs (100%) rename {Modules => Src/Modules}/binascii.cs (100%) rename {Modules => Src/Modules}/bz2/BZ2Compressor.cs (100%) rename {Modules => Src/Modules}/bz2/BZ2Decompressor.cs (100%) rename {Modules => Src/Modules}/bz2/BZ2Module.cs (100%) rename {Modules => Src/Modules}/bz2/dotnetzip/BZip2/BZip2Compressor.cs (100%) rename {Modules => Src/Modules}/bz2/dotnetzip/BZip2/BZip2InputStream.cs (100%) rename {Modules => Src/Modules}/bz2/dotnetzip/BZip2/BZip2OutputStream.cs (100%) rename {Modules => Src/Modules}/bz2/dotnetzip/BZip2/BitWriter.cs (100%) rename {Modules => Src/Modules}/bz2/dotnetzip/BZip2/CRC32.cs (100%) rename {Modules => Src/Modules}/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs (100%) rename {Modules => Src/Modules}/bz2/dotnetzip/BZip2/Rand.cs (100%) rename {Modules => Src/Modules}/bz2/dotnetzip/source.txt (100%) rename {Modules => Src/Modules}/cmath.cs (100%) rename {Modules => Src/Modules}/errno.cs (100%) rename {Modules => Src/Modules}/faulthandler.cs (100%) rename {Modules => Src/Modules}/fcntl.cs (100%) rename {Modules => Src/Modules}/gc.cs (100%) rename {Modules => Src/Modules}/grp.cs (100%) rename {Modules => Src/Modules}/hashlib/MD5CryptoServiceProvider.cs (100%) rename {Modules => Src/Modules}/hashlib/SHA1CryptoServiceProvider.cs (100%) rename {Modules => Src/Modules}/hashlib/SHA224.cs (100%) rename {Modules => Src/Modules}/hashlib/SHA224Managed.cs (100%) rename {Modules => Src/Modules}/hashlib/SHA256Managed.cs (100%) rename {Modules => Src/Modules}/hashlib/SHA384Managed.cs (100%) rename {Modules => Src/Modules}/hashlib/SHA512Managed.cs (100%) rename {Modules => Src/Modules}/hashlib/SHAConstants.cs (100%) rename {Modules => Src/Modules}/hashlib/_hashlib.cs (100%) rename {Modules => Src/Modules}/hashlib/_md5.cs (100%) rename {Modules => Src/Modules}/hashlib/_sha1.cs (100%) rename {Modules => Src/Modules}/hashlib/_sha256.cs (100%) rename {Modules => Src/Modules}/hashlib/_sha512.cs (100%) rename {Modules => Src/Modules}/marshal.cs (100%) rename {Modules => Src/Modules}/math.Generated.cs (100%) rename {Modules => Src/Modules}/math.cs (100%) rename {Modules => Src/Modules}/mmap.cs (100%) rename {Modules => Src/Modules}/msvcrt.cs (100%) rename {Modules => Src/Modules}/nt.cs (100%) rename {Modules => Src/Modules}/policy.IronPython.Modules.config (100%) rename {Modules => Src/Modules}/pwd.cs (100%) rename {Modules => Src/Modules}/pyexpat.cs (100%) rename {Modules => Src/Modules}/re.cs (100%) rename {Modules => Src/Modules}/resource.cs (100%) rename {Modules => Src/Modules}/select.cs (100%) rename {Modules => Src/Modules}/signal.cs (100%) rename {Modules => Src/Modules}/spwd.cs (100%) rename {Modules => Src/Modules}/time.cs (100%) rename {Modules => Src/Modules}/winreg.cs (100%) rename {Modules => Src/Modules}/winsound.cs (100%) rename {Modules => Src/Modules}/xxsubtype.cs (100%) rename {Modules => Src/Modules}/zipimport.cs (100%) rename {Modules => Src/Modules}/zlib/Compress.cs (100%) rename {Modules => Src/Modules}/zlib/Decompress.cs (100%) rename {Modules => Src/Modules}/zlib/ZlibModule.cs (100%) rename {Modules => Src/Modules}/zlib/zlib.net/Adler32.cs (100%) rename {Modules => Src/Modules}/zlib/zlib.net/Deflate.cs (100%) rename {Modules => Src/Modules}/zlib/zlib.net/InfBlocks.cs (100%) rename {Modules => Src/Modules}/zlib/zlib.net/InfCodes.cs (100%) rename {Modules => Src/Modules}/zlib/zlib.net/InfTree.cs (100%) rename {Modules => Src/Modules}/zlib/zlib.net/Inflate.cs (100%) rename {Modules => Src/Modules}/zlib/zlib.net/StaticTree.cs (100%) rename {Modules => Src/Modules}/zlib/zlib.net/Tree.cs (100%) rename {Modules => Src/Modules}/zlib/zlib.net/ZStream.cs (100%) rename {Modules => Src/Modules}/zlib/zlib.net/ZStreamException.cs (100%) rename {Modules => Src/Modules}/zlib/zlib.net/Zlib.cs (100%) rename {Modules => Src/Modules}/zlib/zlib.net/history.txt (100%) rename {Modules => Src/Modules}/zlib/zlib.net/license.txt (100%) rename {Modules => Src/Modules}/zlib/zlib.net/readme.txt (100%) rename {IronPython => Src}/README.md (100%) rename {SQLite => Src/SQLite}/Connection.cs (100%) rename {SQLite => Src/SQLite}/Contants.cs (100%) rename {SQLite => Src/SQLite}/Cursor.cs (100%) rename {SQLite => Src/SQLite}/Exceptions.cs (100%) rename {SQLite => Src/SQLite}/Extensions.cs (100%) rename {SQLite => Src/SQLite}/IronPython.SQLite.csproj (100%) rename {SQLite => Src/SQLite}/Properties/AssemblyInfo.cs (100%) rename {SQLite => Src/SQLite}/Row.cs (100%) rename {SQLite => Src/SQLite}/Statement.cs (100%) rename {SQLite => Src/SQLite}/Util.cs (100%) rename {SQLite => Src/SQLite}/_sqlite.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/.editorconfig (100%) rename {SQLite => Src/SQLite}/c#sqlite/BtreeInt_h.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/Btree_h.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/Delegates.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/Hash_h.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/VdbeInt_h.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/Vdbe_h.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/_Custom.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/alter_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/analyze_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/attach_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/auth_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/backup_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/bitvec_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/btmutex_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/btree_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/build_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/callback_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/complete_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/crypto.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/ctime_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/date_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/delete_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/expr_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/fault_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/fkey_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/func_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/global_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/hash_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/hwtime_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/insert_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/journal_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/keywordhash_h.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/legacy_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/loadext_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/main_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/malloc_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/mem_Pool.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/memjournal_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/mutex_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/mutex_h.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/mutex_noop_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/mutex_w32.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/notify_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/opcodes_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/opcodes_h.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/os_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/os_common_h.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/os_h.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/os_win_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/pager_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/pager_h.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/parse_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/parse_h.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/pcache1_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/pcache_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/pcache_h.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/pragma_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/prepare_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/printf_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/random_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/resolve_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/rowset_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/select_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/sqlite3_h.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/sqliteInt_h.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/sqliteLimit_h.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/status_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/table_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/tokenize_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/trigger_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/update_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/utf_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/util_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/vacuum_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/vdbe_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/vdbeapi_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/vdbeaux_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/vdbeblob_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/vdbemem_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/vdbetrace_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/vtab_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/wal_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/wal_h.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/walker_c.cs (100%) rename {SQLite => Src/SQLite}/c#sqlite/where_c.cs (100%) rename {Scripts => Src/Scripts}/CompareDirs.py (100%) rename {Scripts => Src/Scripts}/Enter-IronPythonEnvironment.ps1 (100%) rename {Scripts => Src/Scripts}/Install-IronPython.ps1 (100%) mode change 100644 => 100755 rename {Scripts => Src/Scripts}/clean.py (100%) rename {Scripts => Src/Scripts}/copyrights.py (100%) rename {Scripts => Src/Scripts}/generate.py (100%) mode change 100644 => 100755 rename {Scripts => Src/Scripts}/generate_UncollectableCompilationMode.py (100%) rename {Scripts => Src/Scripts}/generate_alltypes.py (100%) rename {Scripts => Src/Scripts}/generate_calls.py (100%) rename {Scripts => Src/Scripts}/generate_casts.py (100%) rename {Scripts => Src/Scripts}/generate_comdispatch.py (100%) rename {Scripts => Src/Scripts}/generate_dict_views.py (100%) rename {Scripts => Src/Scripts}/generate_dynamic_instructions.py (100%) rename {Scripts => Src/Scripts}/generate_dynsites.py (100%) rename {Scripts => Src/Scripts}/generate_encoding_aliases.py (100%) rename {Scripts => Src/Scripts}/generate_exception_factory.py (100%) rename {Scripts => Src/Scripts}/generate_exceptions.py (100%) rename {Scripts => Src/Scripts}/generate_indicestest.py (100%) rename {Scripts => Src/Scripts}/generate_math.py (100%) rename {Scripts => Src/Scripts}/generate_ops.py (100%) mode change 100644 => 100755 rename {Scripts => Src/Scripts}/generate_os_codes.py (100%) rename {Scripts => Src/Scripts}/generate_reflected_calls.py (100%) rename {Scripts => Src/Scripts}/generate_set.py (100%) rename {Scripts => Src/Scripts}/generate_tuples.py (100%) rename {Scripts => Src/Scripts}/generate_typecache.py (100%) rename {Scripts => Src/Scripts}/generate_walker.py (100%) rename {Scripts => Src/Scripts}/ipcom.ps1 (100%) rename {Scripts => Src/Scripts}/make_meta1.py (100%) rename {Scripts => Src/Scripts}/radix_generator.py (100%) rename {Scripts => Src/Scripts}/run_compiled.py (100%) rename {Scripts => Src/Scripts}/run_interactive.py (100%) rename {Scripts => Src/Scripts}/smtpmailer.py (100%) rename {Scripts => Src/Scripts}/test_builder.py (100%) rename {Scripts => Src/Scripts}/test_cgcheck.py (100%) rename {Scripts => Src/Scripts}/test_parrot.py (100%) rename {Scripts => Src/Scripts}/test_pystone.py (100%) rename {StdLib => Src/StdLib}/.gitattributes (100%) rename {StdLib => Src/StdLib}/Lib/__future__.py (100%) rename {StdLib => Src/StdLib}/Lib/__phello__.foo.py (100%) rename {StdLib => Src/StdLib}/Lib/_bootlocale.py (100%) rename {StdLib => Src/StdLib}/Lib/_collections_abc.py (100%) rename {StdLib => Src/StdLib}/Lib/_compat_pickle.py (100%) rename {StdLib => Src/StdLib}/Lib/_dummy_thread.py (100%) rename {StdLib => Src/StdLib}/Lib/_markupbase.py (100%) rename {StdLib => Src/StdLib}/Lib/_osx_support.py (100%) rename {StdLib => Src/StdLib}/Lib/_pyio.py (100%) rename {StdLib => Src/StdLib}/Lib/_sitebuiltins.py (100%) rename {StdLib => Src/StdLib}/Lib/_strptime.py (100%) rename {StdLib => Src/StdLib}/Lib/_threading_local.py (100%) rename {StdLib => Src/StdLib}/Lib/_weakrefset.py (100%) rename {StdLib => Src/StdLib}/Lib/abc.py (100%) rename {StdLib => Src/StdLib}/Lib/aifc.py (100%) rename {StdLib => Src/StdLib}/Lib/antigravity.py (100%) rename {StdLib => Src/StdLib}/Lib/argparse.py (100%) rename {StdLib => Src/StdLib}/Lib/ast.py (100%) rename {StdLib => Src/StdLib}/Lib/asynchat.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/base_events.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/base_subprocess.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/compat.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/constants.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/coroutines.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/events.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/futures.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/locks.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/log.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/proactor_events.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/protocols.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/queues.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/selector_events.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/sslproto.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/streams.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/subprocess.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/tasks.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/test_utils.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/transports.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/unix_events.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/windows_events.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncio/windows_utils.py (100%) rename {StdLib => Src/StdLib}/Lib/asyncore.py (100%) rename {StdLib => Src/StdLib}/Lib/base64.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/bdb.py (100%) rename {StdLib => Src/StdLib}/Lib/binhex.py (100%) rename {StdLib => Src/StdLib}/Lib/bisect.py (100%) rename {StdLib => Src/StdLib}/Lib/bz2.py (100%) rename {StdLib => Src/StdLib}/Lib/cProfile.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/calendar.py (100%) rename {StdLib => Src/StdLib}/Lib/cgi.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/cgitb.py (100%) rename {StdLib => Src/StdLib}/Lib/chunk.py (100%) rename {StdLib => Src/StdLib}/Lib/clrtype.py (100%) rename {StdLib => Src/StdLib}/Lib/cmd.py (100%) rename {StdLib => Src/StdLib}/Lib/code.py (100%) rename {StdLib => Src/StdLib}/Lib/codecs.py (100%) rename {StdLib => Src/StdLib}/Lib/codeop.py (100%) rename {StdLib => Src/StdLib}/Lib/collections/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/collections/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/collections/abc.py (100%) rename {StdLib => Src/StdLib}/Lib/colorsys.py (100%) rename {StdLib => Src/StdLib}/Lib/compileall.py (100%) rename {StdLib => Src/StdLib}/Lib/concurrent/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/concurrent/futures/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/concurrent/futures/_base.py (100%) rename {StdLib => Src/StdLib}/Lib/concurrent/futures/process.py (100%) rename {StdLib => Src/StdLib}/Lib/concurrent/futures/thread.py (100%) rename {StdLib => Src/StdLib}/Lib/configparser.py (100%) rename {StdLib => Src/StdLib}/Lib/contextlib.py (100%) rename {StdLib => Src/StdLib}/Lib/copy.py (100%) rename {StdLib => Src/StdLib}/Lib/copyreg.py (100%) rename {StdLib => Src/StdLib}/Lib/crypt.py (100%) rename {StdLib => Src/StdLib}/Lib/csv.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/_endian.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/macholib/README.ctypes (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/macholib/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/macholib/dyld.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/macholib/dylib.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/macholib/fetch_macholib (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/ctypes/macholib/fetch_macholib.bat (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/macholib/framework.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_anon.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_array_in_pointer.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_arrays.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_as_parameter.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_bitfields.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_buffers.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_bytes.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_byteswap.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_callbacks.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_cast.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_cfuncs.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_checkretval.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_delattr.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_errno.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_find.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_frombuffer.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_funcptr.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_functions.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_incomplete.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_init.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_internals.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_keeprefs.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_libc.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_loading.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_macholib.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_memfunctions.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_numbers.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_objects.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_parameters.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_pep3118.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_pickling.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_pointers.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_prototypes.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_python_api.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_random_things.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_refcounts.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_repr.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_returnfuncptrs.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_simplesubclasses.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_sizes.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_slicing.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_stringptr.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_strings.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_struct_fields.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_structures.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_unaligned_structures.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_unicode.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_values.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_varsize_struct.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_win32.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/test/test_wintypes.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/util.py (100%) rename {StdLib => Src/StdLib}/Lib/ctypes/wintypes.py (100%) rename {StdLib => Src/StdLib}/Lib/curses/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/curses/ascii.py (100%) rename {StdLib => Src/StdLib}/Lib/curses/has_key.py (100%) rename {StdLib => Src/StdLib}/Lib/curses/panel.py (100%) rename {StdLib => Src/StdLib}/Lib/curses/textpad.py (100%) rename {StdLib => Src/StdLib}/Lib/datetime.py (100%) rename {StdLib => Src/StdLib}/Lib/dbm/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/dbm/dumb.py (100%) rename {StdLib => Src/StdLib}/Lib/dbm/gnu.py (100%) rename {StdLib => Src/StdLib}/Lib/dbm/ndbm.py (100%) rename {StdLib => Src/StdLib}/Lib/decimal.py (100%) rename {StdLib => Src/StdLib}/Lib/difflib.py (100%) rename {StdLib => Src/StdLib}/Lib/dis.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/README (100%) rename {StdLib => Src/StdLib}/Lib/distutils/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/archive_util.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/bcppcompiler.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/ccompiler.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/cmd.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/bdist.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/bdist_dumb.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/bdist_msi.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/bdist_rpm.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/bdist_wininst.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/build.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/build_clib.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/build_ext.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/build_py.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/build_scripts.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/check.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/clean.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/command_template (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/config.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/install.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/install_data.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/install_egg_info.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/install_headers.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/install_lib.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/install_scripts.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/register.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/sdist.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/upload.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/wininst-10.0-amd64.exe (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/wininst-10.0.exe (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/wininst-6.0.exe (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/wininst-7.1.exe (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/wininst-8.0.exe (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/wininst-9.0-amd64.exe (100%) rename {StdLib => Src/StdLib}/Lib/distutils/command/wininst-9.0.exe (100%) rename {StdLib => Src/StdLib}/Lib/distutils/config.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/core.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/cygwinccompiler.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/debug.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/dep_util.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/dir_util.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/dist.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/errors.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/extension.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/fancy_getopt.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/file_util.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/filelist.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/log.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/msvc9compiler.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/msvccompiler.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/spawn.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/sysconfig.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/Setup.sample (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/support.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_archive_util.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_bdist.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_bdist_dumb.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_bdist_msi.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_bdist_rpm.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_bdist_wininst.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_build.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_build_clib.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_build_ext.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_build_py.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_build_scripts.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_check.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_clean.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_cmd.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_config.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_config_cmd.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_core.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_cygwinccompiler.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_dep_util.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_dir_util.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_dist.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_extension.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_file_util.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_filelist.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_install.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_install_data.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_install_headers.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_install_lib.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_install_scripts.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_log.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_msvc9compiler.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_register.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_sdist.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_spawn.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_sysconfig.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_text_file.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_unixccompiler.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_upload.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_util.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_version.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/tests/test_versionpredicate.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/text_file.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/unixccompiler.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/util.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/version.py (100%) rename {StdLib => Src/StdLib}/Lib/distutils/versionpredicate.py (100%) rename {StdLib => Src/StdLib}/Lib/doctest.py (100%) rename {StdLib => Src/StdLib}/Lib/dummy_threading.py (100%) rename {StdLib => Src/StdLib}/Lib/email/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/email/_encoded_words.py (100%) rename {StdLib => Src/StdLib}/Lib/email/_header_value_parser.py (100%) rename {StdLib => Src/StdLib}/Lib/email/_parseaddr.py (100%) rename {StdLib => Src/StdLib}/Lib/email/_policybase.py (100%) rename {StdLib => Src/StdLib}/Lib/email/architecture.rst (100%) rename {StdLib => Src/StdLib}/Lib/email/base64mime.py (100%) rename {StdLib => Src/StdLib}/Lib/email/charset.py (100%) rename {StdLib => Src/StdLib}/Lib/email/contentmanager.py (100%) rename {StdLib => Src/StdLib}/Lib/email/encoders.py (100%) rename {StdLib => Src/StdLib}/Lib/email/errors.py (100%) rename {StdLib => Src/StdLib}/Lib/email/feedparser.py (100%) rename {StdLib => Src/StdLib}/Lib/email/generator.py (100%) rename {StdLib => Src/StdLib}/Lib/email/header.py (100%) rename {StdLib => Src/StdLib}/Lib/email/headerregistry.py (100%) rename {StdLib => Src/StdLib}/Lib/email/iterators.py (100%) rename {StdLib => Src/StdLib}/Lib/email/message.py (100%) rename {StdLib => Src/StdLib}/Lib/email/mime/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/email/mime/application.py (100%) rename {StdLib => Src/StdLib}/Lib/email/mime/audio.py (100%) rename {StdLib => Src/StdLib}/Lib/email/mime/base.py (100%) rename {StdLib => Src/StdLib}/Lib/email/mime/image.py (100%) rename {StdLib => Src/StdLib}/Lib/email/mime/message.py (100%) rename {StdLib => Src/StdLib}/Lib/email/mime/multipart.py (100%) rename {StdLib => Src/StdLib}/Lib/email/mime/nonmultipart.py (100%) rename {StdLib => Src/StdLib}/Lib/email/mime/text.py (100%) rename {StdLib => Src/StdLib}/Lib/email/parser.py (100%) rename {StdLib => Src/StdLib}/Lib/email/policy.py (100%) rename {StdLib => Src/StdLib}/Lib/email/quoprimime.py (100%) rename {StdLib => Src/StdLib}/Lib/email/utils.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/aliases.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/ascii.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/base64_codec.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/big5.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/big5hkscs.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/bz2_codec.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/charmap.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp037.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp1006.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp1026.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp1125.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp1140.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp1250.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp1251.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp1252.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp1253.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp1254.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp1255.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp1256.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp1257.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp1258.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp273.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp424.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp437.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp500.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp65001.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp720.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp737.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp775.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp850.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp852.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp855.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp856.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp857.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp858.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp860.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp861.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp862.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp863.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp864.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp865.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp866.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp869.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp874.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp875.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp932.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp949.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/cp950.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/euc_jis_2004.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/euc_jisx0213.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/euc_jp.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/euc_kr.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/gb18030.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/gb2312.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/gbk.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/hex_codec.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/hp_roman8.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/hz.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/idna.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso2022_jp.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso2022_jp_1.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso2022_jp_2.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso2022_jp_2004.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso2022_jp_3.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso2022_jp_ext.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso2022_kr.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso8859_1.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso8859_10.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso8859_11.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso8859_13.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso8859_14.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso8859_15.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso8859_16.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso8859_2.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso8859_3.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso8859_4.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso8859_5.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso8859_6.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso8859_7.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso8859_8.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/iso8859_9.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/johab.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/koi8_r.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/koi8_u.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/latin_1.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/mac_arabic.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/mac_centeuro.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/mac_croatian.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/mac_cyrillic.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/mac_farsi.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/mac_greek.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/mac_iceland.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/mac_latin2.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/mac_roman.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/mac_romanian.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/mac_turkish.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/mbcs.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/palmos.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/ptcp154.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/punycode.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/quopri_codec.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/raw_unicode_escape.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/rot_13.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/encodings/shift_jis.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/shift_jis_2004.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/shift_jisx0213.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/tis_620.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/undefined.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/unicode_escape.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/unicode_internal.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/utf_16.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/utf_16_be.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/utf_16_le.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/utf_32.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/utf_32_be.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/utf_32_le.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/utf_7.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/utf_8.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/utf_8_sig.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/uu_codec.py (100%) rename {StdLib => Src/StdLib}/Lib/encodings/zlib_codec.py (100%) rename {StdLib => Src/StdLib}/Lib/ensurepip/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/ensurepip/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl (100%) rename {StdLib => Src/StdLib}/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl (100%) rename {StdLib => Src/StdLib}/Lib/ensurepip/_uninstall.py (100%) rename {StdLib => Src/StdLib}/Lib/enum.py (100%) rename {StdLib => Src/StdLib}/Lib/filecmp.py (100%) rename {StdLib => Src/StdLib}/Lib/fileinput.py (100%) rename {StdLib => Src/StdLib}/Lib/fnmatch.py (100%) rename {StdLib => Src/StdLib}/Lib/formatter.py (100%) rename {StdLib => Src/StdLib}/Lib/fractions.py (100%) rename {StdLib => Src/StdLib}/Lib/ftplib.py (100%) rename {StdLib => Src/StdLib}/Lib/functools.py (100%) rename {StdLib => Src/StdLib}/Lib/genericpath.py (100%) rename {StdLib => Src/StdLib}/Lib/getopt.py (100%) rename {StdLib => Src/StdLib}/Lib/getpass.py (100%) rename {StdLib => Src/StdLib}/Lib/gettext.py (100%) rename {StdLib => Src/StdLib}/Lib/glob.py (100%) rename {StdLib => Src/StdLib}/Lib/gzip.py (100%) rename {StdLib => Src/StdLib}/Lib/hashlib.py (100%) rename {StdLib => Src/StdLib}/Lib/heapq.py (100%) rename {StdLib => Src/StdLib}/Lib/hmac.py (100%) rename {StdLib => Src/StdLib}/Lib/html/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/html/entities.py (100%) rename {StdLib => Src/StdLib}/Lib/html/parser.py (100%) rename {StdLib => Src/StdLib}/Lib/http/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/http/client.py (100%) rename {StdLib => Src/StdLib}/Lib/http/cookiejar.py (100%) rename {StdLib => Src/StdLib}/Lib/http/cookies.py (100%) rename {StdLib => Src/StdLib}/Lib/http/server.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/AutoComplete.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/AutoCompleteWindow.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/AutoExpand.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/Bindings.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/CREDITS.txt (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/CallTipWindow.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/CallTips.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/ChangeLog (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/ClassBrowser.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/CodeContext.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/ColorDelegator.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/Debugger.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/Delegator.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/EditorWindow.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/FileList.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/FormatParagraph.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/GrepDialog.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/HISTORY.txt (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/HyperParser.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/IOBinding.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/Icons/folder.gif (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/Icons/idle.icns (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/Icons/idle.ico (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/Icons/idle_16.gif (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/Icons/idle_16.png (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/Icons/idle_32.gif (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/Icons/idle_32.png (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/Icons/idle_48.gif (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/Icons/idle_48.png (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/Icons/minusnode.gif (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/Icons/openfolder.gif (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/Icons/plusnode.gif (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/Icons/python.gif (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/Icons/tk.gif (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/IdleHistory.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/MultiCall.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/MultiStatusBar.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/NEWS.txt (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/ObjectBrowser.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/OutputWindow.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/ParenMatch.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/PathBrowser.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/Percolator.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/PyParse.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/PyShell.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/idlelib/README.txt (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/RemoteDebugger.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/RemoteObjectBrowser.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/ReplaceDialog.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/RstripExtension.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/ScriptBinding.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/ScrolledList.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/SearchDialog.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/SearchDialogBase.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/SearchEngine.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/StackViewer.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/TODO.txt (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/ToolTip.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/TreeWidget.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/UndoDelegator.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/WidgetRedirector.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/WindowList.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/ZoomHeight.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/aboutDialog.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/config-extensions.def (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/config-highlight.def (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/config-keys.def (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/config-main.def (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/configDialog.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/configHandler.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/configHelpSourceEdit.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/configSectionNameDialog.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/dynOptionMenuWidget.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/extend.txt (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/help.html (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/help.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/help.txt (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle.bat (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/idlelib/idle.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle.pyw (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/README.txt (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/htest.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/mock_idle.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/mock_tk.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/test_autocomplete.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/test_autoexpand.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/test_calltips.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/test_config_name.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/test_configdialog.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/test_delegator.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/test_editor.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/test_formatparagraph.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/test_grep.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/test_hyperparser.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/test_idlehistory.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/test_io.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/test_parenmatch.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/test_pathbrowser.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/test_rstrip.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/test_searchdialogbase.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/test_searchengine.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/test_text.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/test_textview.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/test_warning.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idle_test/test_widgetredir.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/idlever.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/keybindingDialog.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/macosxSupport.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/rpc.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/run.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/tabbedpages.py (100%) rename {StdLib => Src/StdLib}/Lib/idlelib/textView.py (100%) rename {StdLib => Src/StdLib}/Lib/imaplib.py (100%) rename {StdLib => Src/StdLib}/Lib/imghdr.py (100%) rename {StdLib => Src/StdLib}/Lib/imp.py (100%) rename {StdLib => Src/StdLib}/Lib/importlib/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/importlib/_bootstrap.py (100%) rename {StdLib => Src/StdLib}/Lib/importlib/abc.py (100%) rename {StdLib => Src/StdLib}/Lib/importlib/machinery.py (100%) rename {StdLib => Src/StdLib}/Lib/importlib/util.py (100%) rename {StdLib => Src/StdLib}/Lib/inspect.py (100%) rename {StdLib => Src/StdLib}/Lib/io.py (100%) rename {StdLib => Src/StdLib}/Lib/ipaddress.py (100%) rename {StdLib => Src/StdLib}/Lib/json/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/json/decoder.py (100%) rename {StdLib => Src/StdLib}/Lib/json/encoder.py (100%) rename {StdLib => Src/StdLib}/Lib/json/scanner.py (100%) rename {StdLib => Src/StdLib}/Lib/json/tool.py (100%) rename {StdLib => Src/StdLib}/Lib/keyword.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/lib2to3/Grammar.txt (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/PatternGrammar.txt (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/btm_matcher.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/btm_utils.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixer_base.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixer_util.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_apply.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_asserts.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_basestring.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_buffer.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_callable.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_dict.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_except.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_exec.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_execfile.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_exitfunc.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_filter.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_funcattrs.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_future.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_getcwdu.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_has_key.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_idioms.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_import.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_imports.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_imports2.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_input.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_intern.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_isinstance.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_itertools.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_itertools_imports.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_long.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_map.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_metaclass.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_methodattrs.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_ne.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_next.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_nonzero.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_numliterals.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_operator.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_paren.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_print.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_raise.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_raw_input.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_reduce.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_reload.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_renames.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_repr.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_set_literal.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_standarderror.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_sys_exc.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_throw.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_tuple_params.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_types.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_unicode.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_urllib.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_ws_comma.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_xrange.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_xreadlines.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/fixes/fix_zip.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/main.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/patcomp.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/pgen2/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/pgen2/conv.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/pgen2/driver.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/pgen2/grammar.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/pgen2/literals.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/pgen2/parse.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/pgen2/pgen.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/pgen2/token.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/lib2to3/pgen2/tokenize.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/pygram.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/pytree.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/refactor.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/data/README (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/data/bom.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/data/crlf.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/data/different_encoding.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/data/false_encoding.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/data/fixers/bad_order.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/data/fixers/parrot_example.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/data/infinite_recursion.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/data/py2_test_grammar.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/data/py3_test_grammar.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/pytree_idempotency.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/support.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/test_all_fixers.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/test_fixers.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/test_main.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/test_parser.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/test_pytree.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/test_refactor.py (100%) rename {StdLib => Src/StdLib}/Lib/lib2to3/tests/test_util.py (100%) rename {StdLib => Src/StdLib}/Lib/linecache.py (100%) rename {StdLib => Src/StdLib}/Lib/locale.py (100%) rename {StdLib => Src/StdLib}/Lib/logging/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/logging/config.py (100%) rename {StdLib => Src/StdLib}/Lib/logging/handlers.py (100%) rename {StdLib => Src/StdLib}/Lib/lzma.py (100%) rename {StdLib => Src/StdLib}/Lib/macpath.py (100%) rename {StdLib => Src/StdLib}/Lib/macurl2path.py (100%) rename {StdLib => Src/StdLib}/Lib/mailbox.py (100%) rename {StdLib => Src/StdLib}/Lib/mailcap.py (100%) rename {StdLib => Src/StdLib}/Lib/mimetypes.py (100%) rename {StdLib => Src/StdLib}/Lib/modulefinder.py (100%) rename {StdLib => Src/StdLib}/Lib/msilib/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/msilib/schema.py (100%) rename {StdLib => Src/StdLib}/Lib/msilib/sequence.py (100%) rename {StdLib => Src/StdLib}/Lib/msilib/text.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/connection.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/context.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/dummy/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/dummy/connection.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/forkserver.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/heap.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/managers.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/pool.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/popen_fork.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/popen_forkserver.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/popen_spawn_posix.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/popen_spawn_win32.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/process.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/queues.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/reduction.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/resource_sharer.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/semaphore_tracker.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/sharedctypes.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/spawn.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/synchronize.py (100%) rename {StdLib => Src/StdLib}/Lib/multiprocessing/util.py (100%) rename {StdLib => Src/StdLib}/Lib/netrc.py (100%) rename {StdLib => Src/StdLib}/Lib/nntplib.py (100%) rename {StdLib => Src/StdLib}/Lib/ntpath.py (100%) rename {StdLib => Src/StdLib}/Lib/nturl2path.py (100%) rename {StdLib => Src/StdLib}/Lib/numbers.py (100%) rename {StdLib => Src/StdLib}/Lib/opcode.py (100%) rename {StdLib => Src/StdLib}/Lib/operator.py (100%) rename {StdLib => Src/StdLib}/Lib/optparse.py (100%) rename {StdLib => Src/StdLib}/Lib/os.py (100%) rename {StdLib => Src/StdLib}/Lib/pathlib.py (100%) rename {StdLib => Src/StdLib}/Lib/pdb.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/pickle.py (100%) rename {StdLib => Src/StdLib}/Lib/pickletools.py (100%) rename {StdLib => Src/StdLib}/Lib/pipes.py (100%) rename {StdLib => Src/StdLib}/Lib/pkgutil.py (100%) rename {StdLib => Src/StdLib}/Lib/platform.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/plistlib.py (100%) rename {StdLib => Src/StdLib}/Lib/poplib.py (100%) rename {StdLib => Src/StdLib}/Lib/posixpath.py (100%) rename {StdLib => Src/StdLib}/Lib/pprint.py (100%) rename {StdLib => Src/StdLib}/Lib/profile.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/pstats.py (100%) rename {StdLib => Src/StdLib}/Lib/pty.py (100%) rename {StdLib => Src/StdLib}/Lib/py_compile.py (100%) rename {StdLib => Src/StdLib}/Lib/pyclbr.py (100%) rename {StdLib => Src/StdLib}/Lib/pydoc.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/pydoc_data/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/pydoc_data/_pydoc.css (100%) rename {StdLib => Src/StdLib}/Lib/pydoc_data/topics.py (100%) rename {StdLib => Src/StdLib}/Lib/queue.py (100%) rename {StdLib => Src/StdLib}/Lib/quopri.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/random.py (100%) rename {StdLib => Src/StdLib}/Lib/re.py (100%) rename {StdLib => Src/StdLib}/Lib/reprlib.py (100%) rename {StdLib => Src/StdLib}/Lib/rlcompleter.py (100%) rename {StdLib => Src/StdLib}/Lib/runpy.py (100%) rename {StdLib => Src/StdLib}/Lib/sched.py (100%) rename {StdLib => Src/StdLib}/Lib/selectors.py (100%) rename {StdLib => Src/StdLib}/Lib/shelve.py (100%) rename {StdLib => Src/StdLib}/Lib/shlex.py (100%) rename {StdLib => Src/StdLib}/Lib/shutil.py (100%) rename {StdLib => Src/StdLib}/Lib/site-packages/README (100%) rename {StdLib => Src/StdLib}/Lib/site.py (100%) rename {StdLib => Src/StdLib}/Lib/smtpd.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/smtplib.py (100%) rename {StdLib => Src/StdLib}/Lib/sndhdr.py (100%) rename {StdLib => Src/StdLib}/Lib/socket.py (100%) rename {StdLib => Src/StdLib}/Lib/socketserver.py (100%) rename {StdLib => Src/StdLib}/Lib/sqlite3/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/sqlite3/dbapi2.py (100%) rename {StdLib => Src/StdLib}/Lib/sqlite3/dump.py (100%) rename {StdLib => Src/StdLib}/Lib/sqlite3/test/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/sqlite3/test/dbapi.py (100%) rename {StdLib => Src/StdLib}/Lib/sqlite3/test/dump.py (100%) rename {StdLib => Src/StdLib}/Lib/sqlite3/test/factory.py (100%) rename {StdLib => Src/StdLib}/Lib/sqlite3/test/hooks.py (100%) rename {StdLib => Src/StdLib}/Lib/sqlite3/test/regression.py (100%) rename {StdLib => Src/StdLib}/Lib/sqlite3/test/transactions.py (100%) rename {StdLib => Src/StdLib}/Lib/sqlite3/test/types.py (100%) rename {StdLib => Src/StdLib}/Lib/sqlite3/test/userfunctions.py (100%) rename {StdLib => Src/StdLib}/Lib/sre_compile.py (100%) rename {StdLib => Src/StdLib}/Lib/sre_constants.py (100%) rename {StdLib => Src/StdLib}/Lib/sre_parse.py (100%) rename {StdLib => Src/StdLib}/Lib/ssl.py (100%) rename {StdLib => Src/StdLib}/Lib/stat.py (100%) rename {StdLib => Src/StdLib}/Lib/statistics.py (100%) rename {StdLib => Src/StdLib}/Lib/string.py (100%) rename {StdLib => Src/StdLib}/Lib/stringprep.py (100%) rename {StdLib => Src/StdLib}/Lib/struct.py (100%) rename {StdLib => Src/StdLib}/Lib/subprocess.py (100%) rename {StdLib => Src/StdLib}/Lib/sunau.py (100%) rename {StdLib => Src/StdLib}/Lib/symbol.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/symtable.py (100%) rename {StdLib => Src/StdLib}/Lib/sysconfig.py (100%) rename {StdLib => Src/StdLib}/Lib/tabnanny.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/tarfile.py (100%) rename {StdLib => Src/StdLib}/Lib/telnetlib.py (100%) rename {StdLib => Src/StdLib}/Lib/tempfile.py (100%) rename {StdLib => Src/StdLib}/Lib/test/185test.db (100%) rename {StdLib => Src/StdLib}/Lib/test/Sine-1000Hz-300ms.aif (100%) rename {StdLib => Src/StdLib}/Lib/test/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/_test_multiprocessing.py (100%) rename {StdLib => Src/StdLib}/Lib/test/audiodata/pluck-alaw.aifc (100%) rename {StdLib => Src/StdLib}/Lib/test/audiodata/pluck-pcm16.aiff (100%) rename {StdLib => Src/StdLib}/Lib/test/audiodata/pluck-pcm16.au (100%) rename {StdLib => Src/StdLib}/Lib/test/audiodata/pluck-pcm16.wav (100%) rename {StdLib => Src/StdLib}/Lib/test/audiodata/pluck-pcm24.aiff (100%) rename {StdLib => Src/StdLib}/Lib/test/audiodata/pluck-pcm24.au (100%) rename {StdLib => Src/StdLib}/Lib/test/audiodata/pluck-pcm24.wav (100%) rename {StdLib => Src/StdLib}/Lib/test/audiodata/pluck-pcm32.aiff (100%) rename {StdLib => Src/StdLib}/Lib/test/audiodata/pluck-pcm32.au (100%) rename {StdLib => Src/StdLib}/Lib/test/audiodata/pluck-pcm32.wav (100%) rename {StdLib => Src/StdLib}/Lib/test/audiodata/pluck-pcm8.aiff (100%) rename {StdLib => Src/StdLib}/Lib/test/audiodata/pluck-pcm8.au (100%) rename {StdLib => Src/StdLib}/Lib/test/audiodata/pluck-pcm8.wav (100%) rename {StdLib => Src/StdLib}/Lib/test/audiodata/pluck-ulaw.aifc (100%) rename {StdLib => Src/StdLib}/Lib/test/audiodata/pluck-ulaw.au (100%) rename {StdLib => Src/StdLib}/Lib/test/audiotest.au (100%) rename {StdLib => Src/StdLib}/Lib/test/audiotests.py (100%) rename {StdLib => Src/StdLib}/Lib/test/autotest.py (100%) rename {StdLib => Src/StdLib}/Lib/test/bad_coding.py (100%) rename {StdLib => Src/StdLib}/Lib/test/bad_coding2.py (100%) rename {StdLib => Src/StdLib}/Lib/test/badcert.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/badkey.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/badsyntax_3131.py (100%) rename {StdLib => Src/StdLib}/Lib/test/badsyntax_future10.py (100%) rename {StdLib => Src/StdLib}/Lib/test/badsyntax_future3.py (100%) rename {StdLib => Src/StdLib}/Lib/test/badsyntax_future4.py (100%) rename {StdLib => Src/StdLib}/Lib/test/badsyntax_future5.py (100%) rename {StdLib => Src/StdLib}/Lib/test/badsyntax_future6.py (100%) rename {StdLib => Src/StdLib}/Lib/test/badsyntax_future7.py (100%) rename {StdLib => Src/StdLib}/Lib/test/badsyntax_future8.py (100%) rename {StdLib => Src/StdLib}/Lib/test/badsyntax_future9.py (100%) rename {StdLib => Src/StdLib}/Lib/test/badsyntax_pep3120.py (100%) rename {StdLib => Src/StdLib}/Lib/test/buffer_tests.py (100%) rename {StdLib => Src/StdLib}/Lib/test/bytecode_helper.py (100%) rename {StdLib => Src/StdLib}/Lib/test/capath/0e4015b9.0 (100%) rename {StdLib => Src/StdLib}/Lib/test/capath/4e1295a3.0 (100%) rename {StdLib => Src/StdLib}/Lib/test/capath/5ed36f99.0 (100%) rename {StdLib => Src/StdLib}/Lib/test/capath/6e88d7b8.0 (100%) rename {StdLib => Src/StdLib}/Lib/test/capath/99d0fa06.0 (100%) rename {StdLib => Src/StdLib}/Lib/test/capath/ce7b8643.0 (100%) rename {StdLib => Src/StdLib}/Lib/test/cfgparser.1 (100%) rename {StdLib => Src/StdLib}/Lib/test/cfgparser.2 (100%) rename {StdLib => Src/StdLib}/Lib/test/cfgparser.3 (100%) rename {StdLib => Src/StdLib}/Lib/test/check_soundcard.vbs (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/big5-utf8.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/big5.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/big5hkscs-utf8.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/big5hkscs.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/cp949-utf8.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/cp949.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/euc_jisx0213-utf8.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/euc_jisx0213.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/euc_jp-utf8.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/euc_jp.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/euc_kr-utf8.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/euc_kr.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/gb18030-utf8.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/gb18030.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/gb2312-utf8.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/gb2312.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/gbk-utf8.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/gbk.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/hz-utf8.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/hz.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/iso2022_jp-utf8.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/iso2022_jp.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/iso2022_kr-utf8.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/iso2022_kr.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/johab-utf8.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/johab.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/shift_jis-utf8.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/shift_jis.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/shift_jisx0213-utf8.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cjkencodings/shift_jisx0213.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/cmath_testcases.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/coding20731.py (100%) rename {StdLib => Src/StdLib}/Lib/test/crashers/README (100%) rename {StdLib => Src/StdLib}/Lib/test/crashers/bogus_code_obj.py (100%) rename {StdLib => Src/StdLib}/Lib/test/crashers/gc_inspection.py (100%) rename {StdLib => Src/StdLib}/Lib/test/crashers/infinite_loop_re.py (100%) rename {StdLib => Src/StdLib}/Lib/test/crashers/mutation_inside_cyclegc.py (100%) rename {StdLib => Src/StdLib}/Lib/test/crashers/recursive_call.py (100%) rename {StdLib => Src/StdLib}/Lib/test/crashers/trace_at_recursion_limit.py (100%) rename {StdLib => Src/StdLib}/Lib/test/crashers/underlying_dict.py (100%) rename {StdLib => Src/StdLib}/Lib/test/curses_tests.py (100%) rename {StdLib => Src/StdLib}/Lib/test/data/README (100%) rename {StdLib => Src/StdLib}/Lib/test/datetimetester.py (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/abs.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/add.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/and.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/base.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/clamp.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/class.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/compare.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/comparetotal.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/comparetotmag.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/copy.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/copyabs.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/copynegate.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/copysign.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddAbs.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddAdd.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddAnd.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddBase.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddCanonical.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddClass.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddCompare.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddCompareSig.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddCompareTotal.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddCompareTotalMag.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddCopy.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddCopyAbs.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddCopyNegate.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddCopySign.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddDivide.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddDivideInt.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddEncode.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddFMA.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddInvert.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddLogB.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddMax.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddMaxMag.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddMin.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddMinMag.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddMinus.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddMultiply.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddNextMinus.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddNextPlus.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddNextToward.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddOr.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddPlus.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddQuantize.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddReduce.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddRemainder.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddRemainderNear.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddRotate.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddSameQuantum.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddScaleB.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddShift.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddSubtract.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddToIntegral.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ddXor.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/decDouble.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/decQuad.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/decSingle.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/divide.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/divideint.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqAbs.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqAdd.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqAnd.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqBase.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqCanonical.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqClass.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqCompare.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqCompareSig.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqCompareTotal.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqCompareTotalMag.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqCopy.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqCopyAbs.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqCopyNegate.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqCopySign.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqDivide.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqDivideInt.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqEncode.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqFMA.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqInvert.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqLogB.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqMax.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqMaxMag.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqMin.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqMinMag.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqMinus.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqMultiply.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqNextMinus.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqNextPlus.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqNextToward.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqOr.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqPlus.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqQuantize.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqReduce.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqRemainder.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqRemainderNear.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqRotate.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqSameQuantum.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqScaleB.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqShift.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqSubtract.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqToIntegral.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dqXor.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dsBase.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/dsEncode.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/exp.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/extra.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/fma.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/inexact.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/invert.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/ln.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/log10.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/logb.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/max.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/maxmag.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/min.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/minmag.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/minus.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/multiply.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/nextminus.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/nextplus.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/nexttoward.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/or.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/plus.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/power.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/powersqrt.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/quantize.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/randomBound32.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/randoms.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/reduce.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/remainder.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/remainderNear.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/rescale.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/rotate.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/rounding.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/samequantum.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/scaleb.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/shift.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/squareroot.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/subtract.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/testall.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/tointegral.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/tointegralx.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/decimaltestdata/xor.decTest (100%) rename {StdLib => Src/StdLib}/Lib/test/dh1024.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/dis_module.py (100%) rename {StdLib => Src/StdLib}/Lib/test/doctest_aliases.py (100%) rename {StdLib => Src/StdLib}/Lib/test/double_const.py (100%) rename {StdLib => Src/StdLib}/Lib/test/empty.vbs (100%) rename {StdLib => Src/StdLib}/Lib/test/encoded_modules/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/encoded_modules/module_iso_8859_1.py (100%) rename {StdLib => Src/StdLib}/Lib/test/encoded_modules/module_koi8_r.py (100%) rename {StdLib => Src/StdLib}/Lib/test/exception_hierarchy.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/final_a.py (100%) rename {StdLib => Src/StdLib}/Lib/test/final_b.py (100%) rename {StdLib => Src/StdLib}/Lib/test/floating_points.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/fork_wait.py (100%) rename {StdLib => Src/StdLib}/Lib/test/formatfloat_testcases.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/future_test1.py (100%) rename {StdLib => Src/StdLib}/Lib/test/future_test2.py (100%) rename {StdLib => Src/StdLib}/Lib/test/gdb_sample.py (100%) rename {StdLib => Src/StdLib}/Lib/test/ieee754.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/imghdrdata/python.bmp (100%) rename {StdLib => Src/StdLib}/Lib/test/imghdrdata/python.gif (100%) rename {StdLib => Src/StdLib}/Lib/test/imghdrdata/python.jpg (100%) rename {StdLib => Src/StdLib}/Lib/test/imghdrdata/python.pbm (100%) rename {StdLib => Src/StdLib}/Lib/test/imghdrdata/python.pgm (100%) rename {StdLib => Src/StdLib}/Lib/test/imghdrdata/python.png (100%) rename {StdLib => Src/StdLib}/Lib/test/imghdrdata/python.ppm (100%) rename {StdLib => Src/StdLib}/Lib/test/imghdrdata/python.ras (100%) rename {StdLib => Src/StdLib}/Lib/test/imghdrdata/python.sgi (100%) rename {StdLib => Src/StdLib}/Lib/test/imghdrdata/python.tiff (100%) rename {StdLib => Src/StdLib}/Lib/test/imghdrdata/python.xbm (100%) rename {StdLib => Src/StdLib}/Lib/test/inspect_fodder.py (100%) rename {StdLib => Src/StdLib}/Lib/test/inspect_fodder2.py (100%) rename {StdLib => Src/StdLib}/Lib/test/keycert.passwd.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/keycert.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/keycert2.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/keycert3.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/keycert4.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/leakers/README.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/leakers/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/leakers/test_ctypes.py (100%) rename {StdLib => Src/StdLib}/Lib/test/leakers/test_selftype.py (100%) rename {StdLib => Src/StdLib}/Lib/test/list_tests.py (100%) rename {StdLib => Src/StdLib}/Lib/test/lock_tests.py (100%) rename {StdLib => Src/StdLib}/Lib/test/mailcap.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/make_ssl_certs.py (100%) rename {StdLib => Src/StdLib}/Lib/test/mapping_tests.py (100%) rename {StdLib => Src/StdLib}/Lib/test/math_testcases.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/memory_watchdog.py (100%) rename {StdLib => Src/StdLib}/Lib/test/mime.types (100%) rename {StdLib => Src/StdLib}/Lib/test/mock_socket.py (100%) rename {StdLib => Src/StdLib}/Lib/test/mod_generics_cache.py (100%) rename {StdLib => Src/StdLib}/Lib/test/mp_fork_bomb.py (100%) rename {StdLib => Src/StdLib}/Lib/test/multibytecodec_support.py (100%) rename {StdLib => Src/StdLib}/Lib/test/nokia.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/nullbytecert.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/nullcert.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/outstanding_bugs.py (100%) rename {StdLib => Src/StdLib}/Lib/test/pickletester.py (100%) rename {StdLib => Src/StdLib}/Lib/test/profilee.py (100%) rename {StdLib => Src/StdLib}/Lib/test/pstats.pck (100%) rename {StdLib => Src/StdLib}/Lib/test/pycacert.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/pycakey.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/pyclbr_input.py (100%) rename {StdLib => Src/StdLib}/Lib/test/pydoc_mod.py (100%) rename {StdLib => Src/StdLib}/Lib/test/pydocfodder.py (100%) rename {StdLib => Src/StdLib}/Lib/test/pystone.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/test/randv2_32.pck (100%) rename {StdLib => Src/StdLib}/Lib/test/randv2_64.pck (100%) rename {StdLib => Src/StdLib}/Lib/test/randv3.pck (100%) rename {StdLib => Src/StdLib}/Lib/test/re_tests.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/test/regrtest.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/test/relimport.py (100%) rename {StdLib => Src/StdLib}/Lib/test/reperf.py (100%) rename {StdLib => Src/StdLib}/Lib/test/revocation.crl (100%) rename {StdLib => Src/StdLib}/Lib/test/sample_doctest.py (100%) rename {StdLib => Src/StdLib}/Lib/test/sample_doctest_no_docstrings.py (100%) rename {StdLib => Src/StdLib}/Lib/test/sample_doctest_no_doctests.py (100%) rename {StdLib => Src/StdLib}/Lib/test/script_helper.py (100%) rename {StdLib => Src/StdLib}/Lib/test/selfsigned_pythontestdotnet.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/seq_tests.py (100%) rename {StdLib => Src/StdLib}/Lib/test/sgml_input.html (100%) rename {StdLib => Src/StdLib}/Lib/test/sha256.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/sndhdrdata/README (100%) rename {StdLib => Src/StdLib}/Lib/test/sndhdrdata/sndhdr.8svx (100%) rename {StdLib => Src/StdLib}/Lib/test/sndhdrdata/sndhdr.aifc (100%) rename {StdLib => Src/StdLib}/Lib/test/sndhdrdata/sndhdr.aiff (100%) rename {StdLib => Src/StdLib}/Lib/test/sndhdrdata/sndhdr.au (100%) rename {StdLib => Src/StdLib}/Lib/test/sndhdrdata/sndhdr.hcom (100%) rename {StdLib => Src/StdLib}/Lib/test/sndhdrdata/sndhdr.sndt (100%) rename {StdLib => Src/StdLib}/Lib/test/sndhdrdata/sndhdr.voc (100%) rename {StdLib => Src/StdLib}/Lib/test/sndhdrdata/sndhdr.wav (100%) rename {StdLib => Src/StdLib}/Lib/test/sortperf.py (100%) rename {StdLib => Src/StdLib}/Lib/test/ssl_cert.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/ssl_key.passwd.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/ssl_key.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/ssl_servers.py (100%) rename {StdLib => Src/StdLib}/Lib/test/ssltests.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/test/string_tests.py (100%) rename {StdLib => Src/StdLib}/Lib/test/subprocessdata/fd_status.py (100%) rename {StdLib => Src/StdLib}/Lib/test/subprocessdata/input_reader.py (100%) rename {StdLib => Src/StdLib}/Lib/test/subprocessdata/qcat.py (100%) rename {StdLib => Src/StdLib}/Lib/test/subprocessdata/qgrep.py (100%) rename {StdLib => Src/StdLib}/Lib/test/subprocessdata/sigchild_ignore.py (100%) rename {StdLib => Src/StdLib}/Lib/test/support/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/talos-2019-0758.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/test___all__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test___future__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test__locale.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test__opcode.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test__osx_support.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_abc.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_abstract_numbers.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_aifc.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_argparse.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_array.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/test/test_ast.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asynchat.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/echo.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/echo2.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/echo3.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/keycert3.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/pycacert.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/ssl_cert.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/ssl_key.pem (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/test_base_events.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/test_events.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/test_futures.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/test_locks.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/test_proactor_events.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/test_queues.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/test_selector_events.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/test_sslproto.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/test_streams.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/test_subprocess.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/test_tasks.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/test_transports.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/test_unix_events.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/test_windows_events.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncio/test_windows_utils.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_asyncore.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_atexit.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_audioop.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_augassign.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_base64.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_bigaddrspace.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_bigmem.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_binascii.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_binhex.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/test/test_binop.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_bisect.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_bool.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_buffer.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_bufio.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_builtin.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_bytes.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_bz2.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_calendar.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_call.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_capi.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_cgi.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_cgitb.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_charmapcodec.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_class.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_cmath.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_cmd.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_cmd_line.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_cmd_line_script.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_code.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_code_module.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_codeccallbacks.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_codecencodings_cn.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_codecencodings_hk.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_codecencodings_iso2022.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_codecencodings_jp.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_codecencodings_kr.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_codecencodings_tw.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_codecmaps_cn.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_codecmaps_hk.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_codecmaps_jp.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_codecmaps_kr.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_codecmaps_tw.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_codecs.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_codeop.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_collections.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_colorsys.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_compare.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_compile.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_compileall.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_complex.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_concurrent_futures.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_configparser.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_contains.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_contextlib.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_copy.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_copyreg.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_cprofile.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_crashers.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_crypt.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_csv.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_ctypes.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_curses.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_datetime.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_dbm.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_dbm_dumb.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_dbm_gnu.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_dbm_ndbm.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_decimal.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_decorators.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_defaultdict.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_deque.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_descr.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_descrtut.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_devpoll.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_dict.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_dictcomps.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_dictviews.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_difflib.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_difflib_expect.html (100%) rename {StdLib => Src/StdLib}/Lib/test/test_dis.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_distutils.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_doctest.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_doctest.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_doctest2.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_doctest2.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_doctest3.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_doctest4.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_docxmlrpc.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_dummy_thread.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_dummy_threading.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_dynamic.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_dynamicclassattribute.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/PyBanner048.gif (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/audiotest.au (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_01.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_02.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_03.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_04.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_05.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_06.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_07.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_08.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_09.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_10.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_11.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_12.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_12a.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_13.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_14.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_15.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_16.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_17.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_18.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_19.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_20.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_21.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_22.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_23.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_24.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_25.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_26.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_27.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_28.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_29.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_30.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_31.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_32.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_33.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_34.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_35.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_36.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_37.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_38.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_39.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_40.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_41.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_42.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_43.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_44.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_45.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/data/msg_46.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/test__encoded_words.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/test__header_value_parser.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/test_asian_codecs.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/test_contentmanager.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/test_defect_handling.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/test_email.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/test_generator.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/test_headerregistry.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/test_inversion.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/test_message.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/test_parser.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/test_pickleable.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/test_policy.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/test_utils.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_email/torture_test.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_ensurepip.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_enum.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_enumerate.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_eof.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_epoll.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_errno.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/test/test_exception_variations.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_exceptions.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_extcall.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_faulthandler.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_fcntl.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_file.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_file_eintr.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_filecmp.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_fileinput.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_fileio.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_finalization.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_float.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_flufl.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_fnmatch.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_fork1.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_format.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_fractions.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_frame.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_fstring.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_ftplib.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_funcattrs.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_functools.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_future.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_future3.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_future4.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_future5.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_gc.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_gdb.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_generators.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_genericpath.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_genexps.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_getargs2.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_getopt.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_getpass.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_gettext.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_glob.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_global.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_grammar.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_grp.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_gzip.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_hash.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_hashlib.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_heapq.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_hmac.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_html.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_htmlparser.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_http_cookiejar.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_http_cookies.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_httplib.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_httpservers.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_idle.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_imaplib.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_imghdr.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_imp.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_import.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/abc.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/builtin/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/builtin/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/builtin/test_finder.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/builtin/test_loader.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/builtin/util.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/extension/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/extension/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/extension/test_case_sensitivity.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/extension/test_finder.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/extension/test_loader.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/extension/test_path_hook.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/extension/util.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/frozen/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/frozen/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/frozen/test_finder.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/frozen/test_loader.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/import_/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/import_/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/import_/test___loader__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/import_/test___package__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/import_/test_api.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/import_/test_caching.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/import_/test_fromlist.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/import_/test_meta_path.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/import_/test_packages.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/import_/test_path.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/import_/test_relative_imports.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/import_/util.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/regrtest.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/source/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/source/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/source/test_case_sensitivity.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/source/test_file_loader.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/source/test_finder.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/source/test_path_hook.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/source/test_source_encoding.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/source/util.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/test_abc.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/test_api.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/test_locks.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/test_namespace_pkgs.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/test_spec.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/test_util.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/test_windows.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_importlib/util.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_index.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_inspect.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_int.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_int_literal.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_io.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_ioctl.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_ipaddress.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_isinstance.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_iter.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_iterlen.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_itertools.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_json/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_json/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_json/test_decode.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_json/test_default.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_json/test_dump.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_json/test_encode_basestring_ascii.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_json/test_enum.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_json/test_fail.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_json/test_float.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_json/test_indent.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_json/test_pass1.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_json/test_pass2.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_json/test_pass3.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_json/test_recursion.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_json/test_scanstring.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_json/test_separators.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_json/test_speedups.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_json/test_tool.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_json/test_unicode.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_keyword.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_keywordonlyarg.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_kqueue.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_largefile.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_lib2to3.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_linecache.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_list.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_listcomps.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_locale.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_logging.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_long.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_longexp.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_lzma.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_macpath.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_macurl2path.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_mailbox.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_mailcap.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_marshal.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_math.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_memoryio.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_memoryview.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_metaclass.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_mimetypes.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_minidom.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_mmap.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_module.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_modulefinder.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_msilib.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_multibytecodec.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_multiprocessing_fork.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_multiprocessing_forkserver.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_multiprocessing_main_handling.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_multiprocessing_spawn.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_netrc.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_nis.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_nntplib.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_normalization.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_ntpath.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_numeric_tower.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_opcodes.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_openpty.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_operator.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_optparse.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_ordered_dict.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_os.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_ossaudiodev.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_osx_env.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_parser.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pathlib.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/test/test_pdb.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_peepholer.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pep247.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pep277.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pep292.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pep3120.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pep3131.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pep3151.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pep352.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pep380.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pep479.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pickle.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pickletools.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pipes.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pkg.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pkgimport.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pkgutil.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_platform.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_plistlib.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_poll.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_popen.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_poplib.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_posix.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_posixpath.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pow.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pprint.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_print.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_profile.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_property.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pstats.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pty.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pulldom.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pwd.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_py_compile.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pyclbr.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pydoc.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_pyexpat.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_queue.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_quopri.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_raise.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_random.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_range.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_re.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_readline.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_regrtest.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_reprlib.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_resource.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_richcmp.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_rlcompleter.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_robotparser.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_runpy.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_sax.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_sched.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_scope.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_script_helper.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_select.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_selectors.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_set.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_setcomps.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_shelve.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_shlex.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_shutil.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_signal.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_site.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_slice.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_smtpd.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_smtplib.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_smtpnet.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_sndhdr.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_socket.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_socketserver.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_sort.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_source_encoding.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_spwd.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_sqlite.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_ssl.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_startfile.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_stat.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_statistics.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_strftime.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_string.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_stringprep.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_strlit.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_strptime.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_strtod.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_struct.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_structmembers.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_structseq.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_subprocess.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_sunau.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_sundry.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_super.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_support.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_symtable.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_syntax.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_sys.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_sys_setprofile.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_sys_settrace.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_sysconfig.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_syslog.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_tarfile.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_tcl.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_telnetlib.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_tempfile.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_textwrap.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_thread.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_threaded_import.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_threadedtempfile.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_threading.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_threading_local.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_threadsignals.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_time.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_timeit.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_timeout.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_tk.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_tokenize.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_tools/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_tools/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_tools/test_gprof2html.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_tools/test_md5sum.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_tools/test_pdeps.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_tools/test_pindent.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_tools/test_reindent.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_tools/test_sundry.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_tools/test_unparse.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_trace.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_traceback.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_tracemalloc.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_ttk_guionly.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_ttk_textonly.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_tuple.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_typechecks.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_types.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_typing.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_ucn.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_unary.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_unicode.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_unicode_file.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_unicodedata.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_unittest.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_univnewlines.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_unpack.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_unpack_ex.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_urllib.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_urllib2.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_urllib2_localnet.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_urllib2net.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_urllib_response.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_urllibnet.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_urlparse.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/test/test_userdict.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_userlist.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_userstring.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/test/test_utf8_mode.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_uu.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_uuid.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_venv.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_wait3.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_wait4.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_warnings.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_wave.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_weakref.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_weakset.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_webbrowser.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_winreg.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_winsound.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_with.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_wsgiref.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_xdrlib.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_xml_dom_minicompat.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_xml_etree.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_xml_etree_c.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_xmlrpc.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_xmlrpc_net.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_zipfile.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_zipfile64.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_zipimport.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_zipimport_support.py (100%) rename {StdLib => Src/StdLib}/Lib/test/test_zlib.py (100%) rename {StdLib => Src/StdLib}/Lib/test/testcodec.py (100%) rename {StdLib => Src/StdLib}/Lib/test/testtar.tar (100%) rename {StdLib => Src/StdLib}/Lib/test/tf_inherit_check.py (100%) rename {StdLib => Src/StdLib}/Lib/test/threaded_import_hangers.py (100%) rename {StdLib => Src/StdLib}/Lib/test/time_hashlib.py (100%) rename {StdLib => Src/StdLib}/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/tokenize_tests.txt (100%) rename {StdLib => Src/StdLib}/Lib/test/tracedmodules/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/test/tracedmodules/testmod.py (100%) rename {StdLib => Src/StdLib}/Lib/test/warning_tests.py (100%) rename {StdLib => Src/StdLib}/Lib/test/win_console_handler.py (100%) rename {StdLib => Src/StdLib}/Lib/test/xmltestdata/simple-ns.xml (100%) rename {StdLib => Src/StdLib}/Lib/test/xmltestdata/simple.xml (100%) rename {StdLib => Src/StdLib}/Lib/test/xmltestdata/test.xml (100%) rename {StdLib => Src/StdLib}/Lib/test/xmltestdata/test.xml.out (100%) rename {StdLib => Src/StdLib}/Lib/test/xmltests.py (100%) rename {StdLib => Src/StdLib}/Lib/test/zip_cp437_header.zip (100%) rename {StdLib => Src/StdLib}/Lib/test/zipdir.zip (100%) rename {StdLib => Src/StdLib}/Lib/textwrap.py (100%) rename {StdLib => Src/StdLib}/Lib/this.py (100%) rename {StdLib => Src/StdLib}/Lib/threading.py (100%) rename {StdLib => Src/StdLib}/Lib/timeit.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/_fix.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/colorchooser.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/commondialog.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/constants.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/dialog.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/dnd.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/filedialog.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/font.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/messagebox.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/scrolledtext.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/simpledialog.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/test/README (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/test/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/test/runtktests.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/test/support.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/test/test_tkinter/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/test/test_tkinter/test_font.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/test/test_tkinter/test_geometry_managers.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/test/test_tkinter/test_images.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/test/test_tkinter/test_loadtk.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/test/test_tkinter/test_misc.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/test/test_tkinter/test_text.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/test/test_tkinter/test_variables.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/test/test_tkinter/test_widgets.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/test/test_ttk/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/test/test_ttk/test_extensions.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/test/test_ttk/test_functions.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/test/test_ttk/test_style.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/test/test_ttk/test_widgets.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/test/widget_tests.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/tix.py (100%) rename {StdLib => Src/StdLib}/Lib/tkinter/ttk.py (100%) rename {StdLib => Src/StdLib}/Lib/token.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/tokenize.py (100%) rename {StdLib => Src/StdLib}/Lib/trace.py (100%) rename {StdLib => Src/StdLib}/Lib/traceback.py (100%) rename {StdLib => Src/StdLib}/Lib/tracemalloc.py (100%) rename {StdLib => Src/StdLib}/Lib/tty.py (100%) rename {StdLib => Src/StdLib}/Lib/turtle.py (100%) rename {StdLib => Src/StdLib}/Lib/turtledemo/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/turtledemo/__main__.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/turtledemo/bytedesign.py (100%) rename {StdLib => Src/StdLib}/Lib/turtledemo/chaos.py (100%) rename {StdLib => Src/StdLib}/Lib/turtledemo/clock.py (100%) rename {StdLib => Src/StdLib}/Lib/turtledemo/colormixer.py (100%) rename {StdLib => Src/StdLib}/Lib/turtledemo/forest.py (100%) rename {StdLib => Src/StdLib}/Lib/turtledemo/fractalcurves.py (100%) rename {StdLib => Src/StdLib}/Lib/turtledemo/lindenmayer.py (100%) rename {StdLib => Src/StdLib}/Lib/turtledemo/minimal_hanoi.py (100%) rename {StdLib => Src/StdLib}/Lib/turtledemo/nim.py (100%) rename {StdLib => Src/StdLib}/Lib/turtledemo/paint.py (100%) rename {StdLib => Src/StdLib}/Lib/turtledemo/peace.py (100%) rename {StdLib => Src/StdLib}/Lib/turtledemo/penrose.py (100%) rename {StdLib => Src/StdLib}/Lib/turtledemo/planet_and_moon.py (100%) rename {StdLib => Src/StdLib}/Lib/turtledemo/round_dance.py (100%) rename {StdLib => Src/StdLib}/Lib/turtledemo/tree.py (100%) rename {StdLib => Src/StdLib}/Lib/turtledemo/turtle.cfg (100%) rename {StdLib => Src/StdLib}/Lib/turtledemo/two_canvases.py (100%) rename {StdLib => Src/StdLib}/Lib/turtledemo/wikipedia.py (100%) rename {StdLib => Src/StdLib}/Lib/turtledemo/yinyang.py (100%) rename {StdLib => Src/StdLib}/Lib/types.py (100%) rename {StdLib => Src/StdLib}/Lib/typing.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/case.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/loader.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/main.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/mock.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/result.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/runner.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/signals.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/suite.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/_test_warnings.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/dummy.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/support.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/test_assertions.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/test_break.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/test_case.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/test_discovery.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/test_functiontestcase.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/test_loader.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/test_program.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/test_result.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/test_runner.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/test_setups.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/test_skipping.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/test_suite.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/testmock/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/testmock/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/testmock/support.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/testmock/testcallable.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/testmock/testhelpers.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/testmock/testmagicmethods.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/testmock/testmock.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/testmock/testpatch.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/testmock/testsentinel.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/test/testmock/testwith.py (100%) rename {StdLib => Src/StdLib}/Lib/unittest/util.py (100%) rename {StdLib => Src/StdLib}/Lib/urllib/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/urllib/error.py (100%) rename {StdLib => Src/StdLib}/Lib/urllib/parse.py (100%) rename {StdLib => Src/StdLib}/Lib/urllib/request.py (100%) rename {StdLib => Src/StdLib}/Lib/urllib/response.py (100%) rename {StdLib => Src/StdLib}/Lib/urllib/robotparser.py (100%) rename {StdLib => Src/StdLib}/Lib/uu.py (100%) mode change 100644 => 100755 rename {StdLib => Src/StdLib}/Lib/uuid.py (100%) rename {StdLib => Src/StdLib}/Lib/venv/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/venv/__main__.py (100%) rename {StdLib => Src/StdLib}/Lib/venv/scripts/nt/Activate.ps1 (100%) rename {StdLib => Src/StdLib}/Lib/venv/scripts/nt/activate.bat (100%) rename {StdLib => Src/StdLib}/Lib/venv/scripts/nt/deactivate.bat (100%) rename {StdLib => Src/StdLib}/Lib/venv/scripts/posix/activate (100%) rename {StdLib => Src/StdLib}/Lib/venv/scripts/posix/activate.csh (100%) rename {StdLib => Src/StdLib}/Lib/venv/scripts/posix/activate.fish (100%) rename {StdLib => Src/StdLib}/Lib/warnings.py (100%) rename {StdLib => Src/StdLib}/Lib/wave.py (100%) rename {StdLib => Src/StdLib}/Lib/weakref.py (100%) rename {StdLib => Src/StdLib}/Lib/webbrowser.py (100%) rename {StdLib => Src/StdLib}/Lib/wpf.py (100%) rename {StdLib => Src/StdLib}/Lib/wsgiref/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/wsgiref/handlers.py (100%) rename {StdLib => Src/StdLib}/Lib/wsgiref/headers.py (100%) rename {StdLib => Src/StdLib}/Lib/wsgiref/simple_server.py (100%) rename {StdLib => Src/StdLib}/Lib/wsgiref/util.py (100%) rename {StdLib => Src/StdLib}/Lib/wsgiref/validate.py (100%) rename {StdLib => Src/StdLib}/Lib/xdrlib.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/dom/NodeFilter.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/dom/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/dom/domreg.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/dom/expatbuilder.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/dom/minicompat.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/dom/minidom.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/dom/pulldom.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/dom/xmlbuilder.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/etree/ElementInclude.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/etree/ElementPath.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/etree/ElementTree.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/etree/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/etree/cElementTree.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/parsers/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/parsers/expat.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/sax/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/sax/_exceptions.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/sax/expatreader.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/sax/handler.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/sax/saxutils.py (100%) rename {StdLib => Src/StdLib}/Lib/xml/sax/xmlreader.py (100%) rename {StdLib => Src/StdLib}/Lib/xmlrpc/__init__.py (100%) rename {StdLib => Src/StdLib}/Lib/xmlrpc/client.py (100%) rename {StdLib => Src/StdLib}/Lib/xmlrpc/server.py (100%) rename {StdLib => Src/StdLib}/Lib/zipfile.py (100%) rename {StdLib => Src/StdLib}/StdLib.License.txt (100%) rename {StdLib => Src/StdLib}/StdLib.pyproj (100%) rename {StdLib => Src/StdLib}/stdlib-upgrade.txt (100%) rename {StdLib => Src/StdLib}/update-stdlib.cmd (100%) rename {StdLib => Src/StdLib}/update-stdlib.sh (100%) mode change 100644 => 100755 rename {Tests => Src/Tests}/AssemblyInfo.cs (100%) rename {Tests => Src/Tests}/AttrInjectorTest.cs (100%) rename {Tests => Src/Tests}/BindTest.cs (100%) rename {Tests => Src/Tests}/BinderTest.cs (100%) rename {Tests => Src/Tests}/Cases/CPythonCases.cs (100%) rename {Tests => Src/Tests}/Cases/CPythonCasesManifest.ini (100%) rename {Tests => Src/Tests}/Cases/CaseExecuter.cs (100%) rename {Tests => Src/Tests}/Cases/CaseGenerator.cs (100%) rename {Tests => Src/Tests}/Cases/CommonCases.cs (100%) rename {Tests => Src/Tests}/Cases/IronPythonCases.cs (100%) rename {Tests => Src/Tests}/Cases/IronPythonCasesManifest.ini (100%) rename {Tests => Src/Tests}/ClrType.cs (100%) rename {Tests => Src/Tests}/Cmplx.cs (100%) rename {Tests => Src/Tests}/Conversions.cs (100%) rename {Tests => Src/Tests}/DeTest.cs (100%) rename {Tests => Src/Tests}/DelegateTest.cs (100%) rename {Tests => Src/Tests}/DynamicRegressions.cs (100%) rename {Tests => Src/Tests}/EncodingTest.cs (100%) rename {Tests => Src/Tests}/EngineTest.cs (100%) rename {Tests => Src/Tests}/Enums.cs (100%) rename {Tests => Src/Tests}/Events.cs (100%) rename {Tests => Src/Tests}/ExceptionConverter.cs (100%) rename {Tests => Src/Tests}/Exceptions.cs (100%) rename {Tests => Src/Tests}/Explicit.cs (100%) rename {Tests => Src/Tests}/ExtensionMethodTest.cs (100%) rename {Tests => Src/Tests}/GenMeth.cs (100%) rename {Tests => Src/Tests}/Indexable.cs (100%) rename {Tests => Src/Tests}/InheritTest.cs (100%) rename {Tests => Src/Tests}/IntegerTest.cs (100%) rename {Tests => Src/Tests}/IronMath.cs (100%) rename {Tests => Src/Tests}/IronPython.Tests.csproj (100%) rename {Tests => Src/Tests}/LoadTest.cs (100%) rename {Tests => Src/Tests}/MemberMappingTests.cs (100%) rename {Tests => Src/Tests}/MemberOverloadTest.cs (100%) rename {Tests => Src/Tests}/MethodParametersStubs.cs (100%) rename {Tests => Src/Tests}/NestedClass.cs (100%) rename {Tests => Src/Tests}/NullableTest.cs (100%) rename {Tests => Src/Tests}/OperatorTest.cs (100%) rename {Tests => Src/Tests}/ProtocolTest.cs (100%) rename {Tests => Src/Tests}/StaticTest.cs (100%) rename {Tests => Src/Tests}/Stress/Engine.cs (100%) rename {Tests => Src/Tests}/StringDictionaryStorage.cs (100%) rename {Tests => Src/Tests}/TestBuiltinModule.cs (100%) rename {Tests => Src/Tests}/TypeDescriptor.cs (100%) rename {Tests => Src/Tests}/Util/IniParser.cs (100%) rename {Tests => Src/Tests}/Util/TestManifest.cs (100%) rename {Wpf => Src/Wpf}/DynamicXamlReader.cs (100%) rename {Wpf => Src/Wpf}/IronPython.Wpf.csproj (100%) rename {Wpf => Src/Wpf}/Properties/AssemblyInfo.cs (100%) rename {Wpf => Src/Wpf}/_wpf.cs (100%) diff --git a/IronPython.sln b/IronPython.sln index fe48235e5..9d9ace479 100644 --- a/IronPython.sln +++ b/IronPython.sln @@ -3,17 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.9.34714.143 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython", "IronPython\IronPython.csproj", "{95289EA9-5778-489D-AB48-F81F2CE2DA32}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython", "Src\IronPython\IronPython.csproj", "{95289EA9-5778-489D-AB48-F81F2CE2DA32}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Modules", "Modules\IronPython.Modules.csproj", "{155CE436-1669-4A48-8095-410F2430237F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Modules", "Src\Modules\IronPython.Modules.csproj", "{155CE436-1669-4A48-8095-410F2430237F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Wpf", "Wpf\IronPython.Wpf.csproj", "{65E997B7-E99B-4C83-B29E-9951429BB293}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Wpf", "Src\Wpf\IronPython.Wpf.csproj", "{65E997B7-E99B-4C83-B29E-9951429BB293}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console", "Console\IronPython.Console.csproj", "{811AC32C-11F3-4ED8-92A7-A7E39C2BB704}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console", "Src\Console\IronPython.Console.csproj", "{811AC32C-11F3-4ED8-92A7-A7E39C2BB704}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Tests", "Tests\IronPython.Tests.csproj", "{B6B42537-07F8-4F6C-A99A-B155CAEB124E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Tests", "Src\Tests\IronPython.Tests.csproj", "{B6B42537-07F8-4F6C-A99A-B155CAEB124E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console.Host", "Console.Host\IronPython.Console.Host.csproj", "{81DA19C7-4FEC-47E7-981B-D9310D549F95}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console.Host", "Src\Console.Host\IronPython.Console.Host.csproj", "{81DA19C7-4FEC-47E7-981B-D9310D549F95}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3A14D070-628F-44EF-92DD-47C8BE5C33CD}" ProjectSection(SolutionItems) = preProject @@ -45,19 +45,19 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{17737ACB Build\Tasks.Targets = Build\Tasks.Targets EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.CompilerServices", "CompilerServices\IronPython.CompilerServices.csproj", "{3DFB096E-AC09-4E7A-9288-7F7C33C288C7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.CompilerServices", "Src\CompilerServices\IronPython.CompilerServices.csproj", "{3DFB096E-AC09-4E7A-9288-7F7C33C288C7}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DLR", "DLR", "{AC38EFB1-820D-4E90-BF40-BEF3AC825542}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Dynamic", "DLR\Src\Microsoft.Dynamic\Microsoft.Dynamic.csproj", "{EB66B766-6354-4208-A3D4-AACBDCB5C3B3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Dynamic", "Src\DLR\Src\Microsoft.Dynamic\Microsoft.Dynamic.csproj", "{EB66B766-6354-4208-A3D4-AACBDCB5C3B3}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Scripting", "DLR\Src\Microsoft.Scripting\Microsoft.Scripting.csproj", "{02FF0909-F5AD-48CF-A86A-345E721B7E40}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Scripting", "Src\DLR\Src\Microsoft.Scripting\Microsoft.Scripting.csproj", "{02FF0909-F5AD-48CF-A86A-345E721B7E40}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Scripting.Metadata", "DLR\Src\Microsoft.Scripting.Metadata\Microsoft.Scripting.Metadata.csproj", "{ACDD9B9E-8FE6-439C-9521-1CCBA47F6143}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Scripting.Metadata", "Src\DLR\Src\Microsoft.Scripting.Metadata\Microsoft.Scripting.Metadata.csproj", "{ACDD9B9E-8FE6-439C-9521-1CCBA47F6143}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{60836ADE-CAB7-4587-B6FB-8C4FEB872752}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClrAssembly", "DLR\Tests\ClrAssembly\ClrAssembly.csproj", "{BEE737B9-18D5-48D9-8672-9A896213C98B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClrAssembly", "Src\DLR\Tests\ClrAssembly\ClrAssembly.csproj", "{BEE737B9-18D5-48D9-8672-9A896213C98B}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Package", "Package", "{CE610DDE-D1DB-44D8-BAE9-BAAB00DA98F0}" EndProject @@ -67,7 +67,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nuget", "nuget", "{EE77D917 Package\nuget\IronPython.StdLib.nuspec = Package\nuget\IronPython.StdLib.nuspec EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32", "Console32\IronPython.Console32.csproj", "{AD21022F-E7C1-4B74-97C1-0A0E48EFF992}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32", "Src\Console32\IronPython.Console32.csproj", "{AD21022F-E7C1-4B74-97C1-0A0E48EFF992}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "choco", "choco", "{EA550FD8-2241-4131-8292-619D009E0199}" ProjectSection(SolutionItems) = preProject @@ -100,11 +100,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "msi", "msi", "{450F93D5-DF0 Package\msi\Version.wxi = Package\msi\Version.wxi EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32.Host", "Console32.Host\IronPython.Console32.Host.csproj", "{8F177DC2-9822-45BD-AB05-1F40FCA86168}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32.Host", "Src\Console32.Host\IronPython.Console32.Host.csproj", "{8F177DC2-9822-45BD-AB05-1F40FCA86168}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronPython.DiagnosticAnalyzer", "DiagnosticAnalyzer\IronPython.DiagnosticAnalyzer.csproj", "{2DFE89D7-0C39-44E9-94CD-496CC985DFC3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronPython.SQLite", "SQLite\IronPython.SQLite.csproj", "{2F1071BF-891C-42A3-8A82-6B8A168BDE64}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronPython.SQLite", "Src\SQLite\IronPython.SQLite.csproj", "{2F1071BF-891C-42A3-8A82-6B8A168BDE64}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/App.Debug.config b/Src/App.Debug.config similarity index 100% rename from App.Debug.config rename to Src/App.Debug.config diff --git a/App.Release.config b/Src/App.Release.config similarity index 100% rename from App.Release.config rename to Src/App.Release.config diff --git a/CTypes/Makefile b/Src/CTypes/Makefile similarity index 100% rename from CTypes/Makefile rename to Src/CTypes/Makefile diff --git a/CTypes/_ctypes_test.c b/Src/CTypes/_ctypes_test.c similarity index 100% rename from CTypes/_ctypes_test.c rename to Src/CTypes/_ctypes_test.c diff --git a/CTypes/_ctypes_test.sln b/Src/CTypes/_ctypes_test.sln similarity index 100% rename from CTypes/_ctypes_test.sln rename to Src/CTypes/_ctypes_test.sln diff --git a/CTypes/_ctypes_test.vcxproj b/Src/CTypes/_ctypes_test.vcxproj similarity index 100% rename from CTypes/_ctypes_test.vcxproj rename to Src/CTypes/_ctypes_test.vcxproj diff --git a/CompilerServices/AssemblyResolver.cs b/Src/CompilerServices/AssemblyResolver.cs similarity index 100% rename from CompilerServices/AssemblyResolver.cs rename to Src/CompilerServices/AssemblyResolver.cs diff --git a/CompilerServices/Config.cs b/Src/CompilerServices/Config.cs similarity index 100% rename from CompilerServices/Config.cs rename to Src/CompilerServices/Config.cs diff --git a/CompilerServices/ConsoleOps.cs b/Src/CompilerServices/ConsoleOps.cs similarity index 100% rename from CompilerServices/ConsoleOps.cs rename to Src/CompilerServices/ConsoleOps.cs diff --git a/CompilerServices/IronPython.CompilerServices.csproj b/Src/CompilerServices/IronPython.CompilerServices.csproj similarity index 84% rename from CompilerServices/IronPython.CompilerServices.csproj rename to Src/CompilerServices/IronPython.CompilerServices.csproj index d10a7b092..ffa1d0cb4 100644 --- a/CompilerServices/IronPython.CompilerServices.csproj +++ b/Src/CompilerServices/IronPython.CompilerServices.csproj @@ -15,12 +15,12 @@ - + - ..\Utils\References\IKVM\IKVM.Reflection.dll + ..\..\Util\References\IKVM\IKVM.Reflection.dll diff --git a/CompilerServices/Program.cs b/Src/CompilerServices/Program.cs similarity index 100% rename from CompilerServices/Program.cs rename to Src/CompilerServices/Program.cs diff --git a/CompilerServices/Properties/AssemblyInfo.cs b/Src/CompilerServices/Properties/AssemblyInfo.cs similarity index 100% rename from CompilerServices/Properties/AssemblyInfo.cs rename to Src/CompilerServices/Properties/AssemblyInfo.cs diff --git a/CompilerServices/README.md b/Src/CompilerServices/README.md similarity index 100% rename from CompilerServices/README.md rename to Src/CompilerServices/README.md diff --git a/Console.Host/IronPython.Console.Host.csproj b/Src/Console.Host/IronPython.Console.Host.csproj similarity index 100% rename from Console.Host/IronPython.Console.Host.csproj rename to Src/Console.Host/IronPython.Console.Host.csproj diff --git a/Console.Host/IronPythonWindow.cs b/Src/Console.Host/IronPythonWindow.cs similarity index 100% rename from Console.Host/IronPythonWindow.cs rename to Src/Console.Host/IronPythonWindow.cs diff --git a/Console.Host/Properties/AssemblyInfo.cs b/Src/Console.Host/Properties/AssemblyInfo.cs similarity index 100% rename from Console.Host/Properties/AssemblyInfo.cs rename to Src/Console.Host/Properties/AssemblyInfo.cs diff --git a/Console.Host/ipyw.ico b/Src/Console.Host/ipyw.ico similarity index 100% rename from Console.Host/ipyw.ico rename to Src/Console.Host/ipyw.ico diff --git a/Console/Console.cs b/Src/Console/Console.cs similarity index 100% rename from Console/Console.cs rename to Src/Console/Console.cs diff --git a/Console/IronPython.Console.csproj b/Src/Console/IronPython.Console.csproj similarity index 100% rename from Console/IronPython.Console.csproj rename to Src/Console/IronPython.Console.csproj diff --git a/Console/Properties/AssemblyInfo.cs b/Src/Console/Properties/AssemblyInfo.cs similarity index 100% rename from Console/Properties/AssemblyInfo.cs rename to Src/Console/Properties/AssemblyInfo.cs diff --git a/Console/app.manifest b/Src/Console/app.manifest similarity index 100% rename from Console/app.manifest rename to Src/Console/app.manifest diff --git a/Console/ipy-mono.sh b/Src/Console/ipy-mono.sh similarity index 100% rename from Console/ipy-mono.sh rename to Src/Console/ipy-mono.sh diff --git a/Console/ipy.ico b/Src/Console/ipy.ico similarity index 100% rename from Console/ipy.ico rename to Src/Console/ipy.ico diff --git a/Console/ipy.sh b/Src/Console/ipy.sh similarity index 100% rename from Console/ipy.sh rename to Src/Console/ipy.sh diff --git a/Console/runtimeconfig.template.json b/Src/Console/runtimeconfig.template.json similarity index 100% rename from Console/runtimeconfig.template.json rename to Src/Console/runtimeconfig.template.json diff --git a/Console32.Host/IronPython.Console32.Host.csproj b/Src/Console32.Host/IronPython.Console32.Host.csproj similarity index 79% rename from Console32.Host/IronPython.Console32.Host.csproj rename to Src/Console32.Host/IronPython.Console32.Host.csproj index ea150a3e0..0ed23ee55 100644 --- a/Console32.Host/IronPython.Console32.Host.csproj +++ b/Src/Console32.Host/IronPython.Console32.Host.csproj @@ -19,8 +19,8 @@ - - + + diff --git a/Console32/IronPython.Console32.csproj b/Src/Console32/IronPython.Console32.csproj similarity index 100% rename from Console32/IronPython.Console32.csproj rename to Src/Console32/IronPython.Console32.csproj diff --git a/IronPython/Compiler/Ast/AndExpression.cs b/Src/IronPython/Compiler/Ast/AndExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/AndExpression.cs rename to Src/IronPython/Compiler/Ast/AndExpression.cs diff --git a/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs b/Src/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/AnnotatedAssignStatement.cs rename to Src/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs diff --git a/IronPython/Compiler/Ast/AssertStatement.cs b/Src/IronPython/Compiler/Ast/AssertStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/AssertStatement.cs rename to Src/IronPython/Compiler/Ast/AssertStatement.cs diff --git a/IronPython/Compiler/Ast/AssignmentStatement.cs b/Src/IronPython/Compiler/Ast/AssignmentStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/AssignmentStatement.cs rename to Src/IronPython/Compiler/Ast/AssignmentStatement.cs diff --git a/IronPython/Compiler/Ast/AstMethods.cs b/Src/IronPython/Compiler/Ast/AstMethods.cs similarity index 100% rename from IronPython/Compiler/Ast/AstMethods.cs rename to Src/IronPython/Compiler/Ast/AstMethods.cs diff --git a/IronPython/Compiler/Ast/AsyncStatement.cs b/Src/IronPython/Compiler/Ast/AsyncStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/AsyncStatement.cs rename to Src/IronPython/Compiler/Ast/AsyncStatement.cs diff --git a/IronPython/Compiler/Ast/AugmentedAssignStatement.cs b/Src/IronPython/Compiler/Ast/AugmentedAssignStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/AugmentedAssignStatement.cs rename to Src/IronPython/Compiler/Ast/AugmentedAssignStatement.cs diff --git a/IronPython/Compiler/Ast/BinaryExpression.Generated.cs b/Src/IronPython/Compiler/Ast/BinaryExpression.Generated.cs similarity index 100% rename from IronPython/Compiler/Ast/BinaryExpression.Generated.cs rename to Src/IronPython/Compiler/Ast/BinaryExpression.Generated.cs diff --git a/IronPython/Compiler/Ast/BinaryExpression.cs b/Src/IronPython/Compiler/Ast/BinaryExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/BinaryExpression.cs rename to Src/IronPython/Compiler/Ast/BinaryExpression.cs diff --git a/IronPython/Compiler/Ast/BreakStatement.cs b/Src/IronPython/Compiler/Ast/BreakStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/BreakStatement.cs rename to Src/IronPython/Compiler/Ast/BreakStatement.cs diff --git a/IronPython/Compiler/Ast/CallExpression.cs b/Src/IronPython/Compiler/Ast/CallExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/CallExpression.cs rename to Src/IronPython/Compiler/Ast/CallExpression.cs diff --git a/IronPython/Compiler/Ast/ClassDefinition.cs b/Src/IronPython/Compiler/Ast/ClassDefinition.cs similarity index 100% rename from IronPython/Compiler/Ast/ClassDefinition.cs rename to Src/IronPython/Compiler/Ast/ClassDefinition.cs diff --git a/IronPython/Compiler/Ast/Comprehension.cs b/Src/IronPython/Compiler/Ast/Comprehension.cs similarity index 100% rename from IronPython/Compiler/Ast/Comprehension.cs rename to Src/IronPython/Compiler/Ast/Comprehension.cs diff --git a/IronPython/Compiler/Ast/ComprehensionFor.cs b/Src/IronPython/Compiler/Ast/ComprehensionFor.cs similarity index 100% rename from IronPython/Compiler/Ast/ComprehensionFor.cs rename to Src/IronPython/Compiler/Ast/ComprehensionFor.cs diff --git a/IronPython/Compiler/Ast/ComprehensionIf.cs b/Src/IronPython/Compiler/Ast/ComprehensionIf.cs similarity index 100% rename from IronPython/Compiler/Ast/ComprehensionIf.cs rename to Src/IronPython/Compiler/Ast/ComprehensionIf.cs diff --git a/IronPython/Compiler/Ast/ConditionalExpression.cs b/Src/IronPython/Compiler/Ast/ConditionalExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/ConditionalExpression.cs rename to Src/IronPython/Compiler/Ast/ConditionalExpression.cs diff --git a/IronPython/Compiler/Ast/ConstantExpression.cs b/Src/IronPython/Compiler/Ast/ConstantExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/ConstantExpression.cs rename to Src/IronPython/Compiler/Ast/ConstantExpression.cs diff --git a/IronPython/Compiler/Ast/ContinueStatement.cs b/Src/IronPython/Compiler/Ast/ContinueStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/ContinueStatement.cs rename to Src/IronPython/Compiler/Ast/ContinueStatement.cs diff --git a/IronPython/Compiler/Ast/DelStatement.cs b/Src/IronPython/Compiler/Ast/DelStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/DelStatement.cs rename to Src/IronPython/Compiler/Ast/DelStatement.cs diff --git a/IronPython/Compiler/Ast/DictionaryExpression.cs b/Src/IronPython/Compiler/Ast/DictionaryExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/DictionaryExpression.cs rename to Src/IronPython/Compiler/Ast/DictionaryExpression.cs diff --git a/IronPython/Compiler/Ast/DottedName.cs b/Src/IronPython/Compiler/Ast/DottedName.cs similarity index 100% rename from IronPython/Compiler/Ast/DottedName.cs rename to Src/IronPython/Compiler/Ast/DottedName.cs diff --git a/IronPython/Compiler/Ast/DynamicConvertExpression.cs b/Src/IronPython/Compiler/Ast/DynamicConvertExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/DynamicConvertExpression.cs rename to Src/IronPython/Compiler/Ast/DynamicConvertExpression.cs diff --git a/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs b/Src/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/DynamicGetMemberExpression.cs rename to Src/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs diff --git a/IronPython/Compiler/Ast/EmptyStatement.cs b/Src/IronPython/Compiler/Ast/EmptyStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/EmptyStatement.cs rename to Src/IronPython/Compiler/Ast/EmptyStatement.cs diff --git a/IronPython/Compiler/Ast/ErrorExpression.cs b/Src/IronPython/Compiler/Ast/ErrorExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/ErrorExpression.cs rename to Src/IronPython/Compiler/Ast/ErrorExpression.cs diff --git a/IronPython/Compiler/Ast/Expression.cs b/Src/IronPython/Compiler/Ast/Expression.cs similarity index 100% rename from IronPython/Compiler/Ast/Expression.cs rename to Src/IronPython/Compiler/Ast/Expression.cs diff --git a/IronPython/Compiler/Ast/ExpressionStatement.cs b/Src/IronPython/Compiler/Ast/ExpressionStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/ExpressionStatement.cs rename to Src/IronPython/Compiler/Ast/ExpressionStatement.cs diff --git a/IronPython/Compiler/Ast/FlowChecker.cs b/Src/IronPython/Compiler/Ast/FlowChecker.cs similarity index 100% rename from IronPython/Compiler/Ast/FlowChecker.cs rename to Src/IronPython/Compiler/Ast/FlowChecker.cs diff --git a/IronPython/Compiler/Ast/ForStatement.cs b/Src/IronPython/Compiler/Ast/ForStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/ForStatement.cs rename to Src/IronPython/Compiler/Ast/ForStatement.cs diff --git a/IronPython/Compiler/Ast/FormattedValueExpression.cs b/Src/IronPython/Compiler/Ast/FormattedValueExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/FormattedValueExpression.cs rename to Src/IronPython/Compiler/Ast/FormattedValueExpression.cs diff --git a/IronPython/Compiler/Ast/FromImportStatement.cs b/Src/IronPython/Compiler/Ast/FromImportStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/FromImportStatement.cs rename to Src/IronPython/Compiler/Ast/FromImportStatement.cs diff --git a/IronPython/Compiler/Ast/FunctionDefinition.cs b/Src/IronPython/Compiler/Ast/FunctionDefinition.cs similarity index 100% rename from IronPython/Compiler/Ast/FunctionDefinition.cs rename to Src/IronPython/Compiler/Ast/FunctionDefinition.cs diff --git a/IronPython/Compiler/Ast/GeneratorExpression.cs b/Src/IronPython/Compiler/Ast/GeneratorExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/GeneratorExpression.cs rename to Src/IronPython/Compiler/Ast/GeneratorExpression.cs diff --git a/IronPython/Compiler/Ast/GetGlobalContextExpression.cs b/Src/IronPython/Compiler/Ast/GetGlobalContextExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/GetGlobalContextExpression.cs rename to Src/IronPython/Compiler/Ast/GetGlobalContextExpression.cs diff --git a/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs b/Src/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs rename to Src/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs diff --git a/IronPython/Compiler/Ast/GlobalStatement.cs b/Src/IronPython/Compiler/Ast/GlobalStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/GlobalStatement.cs rename to Src/IronPython/Compiler/Ast/GlobalStatement.cs diff --git a/IronPython/Compiler/Ast/ILoopStatement.cs b/Src/IronPython/Compiler/Ast/ILoopStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/ILoopStatement.cs rename to Src/IronPython/Compiler/Ast/ILoopStatement.cs diff --git a/IronPython/Compiler/Ast/IfStatement.cs b/Src/IronPython/Compiler/Ast/IfStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/IfStatement.cs rename to Src/IronPython/Compiler/Ast/IfStatement.cs diff --git a/IronPython/Compiler/Ast/IfStatementTest.cs b/Src/IronPython/Compiler/Ast/IfStatementTest.cs similarity index 100% rename from IronPython/Compiler/Ast/IfStatementTest.cs rename to Src/IronPython/Compiler/Ast/IfStatementTest.cs diff --git a/IronPython/Compiler/Ast/ImportStatement.cs b/Src/IronPython/Compiler/Ast/ImportStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/ImportStatement.cs rename to Src/IronPython/Compiler/Ast/ImportStatement.cs diff --git a/IronPython/Compiler/Ast/IndexExpression.cs b/Src/IronPython/Compiler/Ast/IndexExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/IndexExpression.cs rename to Src/IronPython/Compiler/Ast/IndexExpression.cs diff --git a/IronPython/Compiler/Ast/JoinedStringExpression.cs b/Src/IronPython/Compiler/Ast/JoinedStringExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/JoinedStringExpression.cs rename to Src/IronPython/Compiler/Ast/JoinedStringExpression.cs diff --git a/IronPython/Compiler/Ast/Keyword.cs b/Src/IronPython/Compiler/Ast/Keyword.cs similarity index 100% rename from IronPython/Compiler/Ast/Keyword.cs rename to Src/IronPython/Compiler/Ast/Keyword.cs diff --git a/IronPython/Compiler/Ast/LambdaExpression.cs b/Src/IronPython/Compiler/Ast/LambdaExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/LambdaExpression.cs rename to Src/IronPython/Compiler/Ast/LambdaExpression.cs diff --git a/IronPython/Compiler/Ast/ListExpression.cs b/Src/IronPython/Compiler/Ast/ListExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/ListExpression.cs rename to Src/IronPython/Compiler/Ast/ListExpression.cs diff --git a/IronPython/Compiler/Ast/MemberExpression.cs b/Src/IronPython/Compiler/Ast/MemberExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/MemberExpression.cs rename to Src/IronPython/Compiler/Ast/MemberExpression.cs diff --git a/IronPython/Compiler/Ast/ModuleName.cs b/Src/IronPython/Compiler/Ast/ModuleName.cs similarity index 100% rename from IronPython/Compiler/Ast/ModuleName.cs rename to Src/IronPython/Compiler/Ast/ModuleName.cs diff --git a/IronPython/Compiler/Ast/NameExpression.cs b/Src/IronPython/Compiler/Ast/NameExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/NameExpression.cs rename to Src/IronPython/Compiler/Ast/NameExpression.cs diff --git a/IronPython/Compiler/Ast/Node.cs b/Src/IronPython/Compiler/Ast/Node.cs similarity index 100% rename from IronPython/Compiler/Ast/Node.cs rename to Src/IronPython/Compiler/Ast/Node.cs diff --git a/IronPython/Compiler/Ast/NonlocalStatement.cs b/Src/IronPython/Compiler/Ast/NonlocalStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/NonlocalStatement.cs rename to Src/IronPython/Compiler/Ast/NonlocalStatement.cs diff --git a/IronPython/Compiler/Ast/OrExpression.cs b/Src/IronPython/Compiler/Ast/OrExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/OrExpression.cs rename to Src/IronPython/Compiler/Ast/OrExpression.cs diff --git a/IronPython/Compiler/Ast/Parameter.cs b/Src/IronPython/Compiler/Ast/Parameter.cs similarity index 100% rename from IronPython/Compiler/Ast/Parameter.cs rename to Src/IronPython/Compiler/Ast/Parameter.cs diff --git a/IronPython/Compiler/Ast/ParenthesisExpression.cs b/Src/IronPython/Compiler/Ast/ParenthesisExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/ParenthesisExpression.cs rename to Src/IronPython/Compiler/Ast/ParenthesisExpression.cs diff --git a/IronPython/Compiler/Ast/PythonAst.cs b/Src/IronPython/Compiler/Ast/PythonAst.cs similarity index 100% rename from IronPython/Compiler/Ast/PythonAst.cs rename to Src/IronPython/Compiler/Ast/PythonAst.cs diff --git a/IronPython/Compiler/Ast/PythonConstantExpression.cs b/Src/IronPython/Compiler/Ast/PythonConstantExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/PythonConstantExpression.cs rename to Src/IronPython/Compiler/Ast/PythonConstantExpression.cs diff --git a/IronPython/Compiler/Ast/PythonNameBinder.cs b/Src/IronPython/Compiler/Ast/PythonNameBinder.cs similarity index 100% rename from IronPython/Compiler/Ast/PythonNameBinder.cs rename to Src/IronPython/Compiler/Ast/PythonNameBinder.cs diff --git a/IronPython/Compiler/Ast/PythonReference.cs b/Src/IronPython/Compiler/Ast/PythonReference.cs similarity index 100% rename from IronPython/Compiler/Ast/PythonReference.cs rename to Src/IronPython/Compiler/Ast/PythonReference.cs diff --git a/IronPython/Compiler/Ast/PythonVariable.cs b/Src/IronPython/Compiler/Ast/PythonVariable.cs similarity index 100% rename from IronPython/Compiler/Ast/PythonVariable.cs rename to Src/IronPython/Compiler/Ast/PythonVariable.cs diff --git a/IronPython/Compiler/Ast/PythonWalker.Generated.cs b/Src/IronPython/Compiler/Ast/PythonWalker.Generated.cs similarity index 100% rename from IronPython/Compiler/Ast/PythonWalker.Generated.cs rename to Src/IronPython/Compiler/Ast/PythonWalker.Generated.cs diff --git a/IronPython/Compiler/Ast/RaiseStatement.cs b/Src/IronPython/Compiler/Ast/RaiseStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/RaiseStatement.cs rename to Src/IronPython/Compiler/Ast/RaiseStatement.cs diff --git a/IronPython/Compiler/Ast/RelativeModuleName.cs b/Src/IronPython/Compiler/Ast/RelativeModuleName.cs similarity index 100% rename from IronPython/Compiler/Ast/RelativeModuleName.cs rename to Src/IronPython/Compiler/Ast/RelativeModuleName.cs diff --git a/IronPython/Compiler/Ast/ReturnStatement.cs b/Src/IronPython/Compiler/Ast/ReturnStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/ReturnStatement.cs rename to Src/IronPython/Compiler/Ast/ReturnStatement.cs diff --git a/IronPython/Compiler/Ast/ScopeStatement.cs b/Src/IronPython/Compiler/Ast/ScopeStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/ScopeStatement.cs rename to Src/IronPython/Compiler/Ast/ScopeStatement.cs diff --git a/IronPython/Compiler/Ast/SequenceExpression.cs b/Src/IronPython/Compiler/Ast/SequenceExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/SequenceExpression.cs rename to Src/IronPython/Compiler/Ast/SequenceExpression.cs diff --git a/IronPython/Compiler/Ast/SerializedScopeStatement.cs b/Src/IronPython/Compiler/Ast/SerializedScopeStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/SerializedScopeStatement.cs rename to Src/IronPython/Compiler/Ast/SerializedScopeStatement.cs diff --git a/IronPython/Compiler/Ast/SetExpression.cs b/Src/IronPython/Compiler/Ast/SetExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/SetExpression.cs rename to Src/IronPython/Compiler/Ast/SetExpression.cs diff --git a/IronPython/Compiler/Ast/SliceExpression.cs b/Src/IronPython/Compiler/Ast/SliceExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/SliceExpression.cs rename to Src/IronPython/Compiler/Ast/SliceExpression.cs diff --git a/IronPython/Compiler/Ast/StarredExpression.cs b/Src/IronPython/Compiler/Ast/StarredExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/StarredExpression.cs rename to Src/IronPython/Compiler/Ast/StarredExpression.cs diff --git a/IronPython/Compiler/Ast/Statement.cs b/Src/IronPython/Compiler/Ast/Statement.cs similarity index 100% rename from IronPython/Compiler/Ast/Statement.cs rename to Src/IronPython/Compiler/Ast/Statement.cs diff --git a/IronPython/Compiler/Ast/SuiteStatement.cs b/Src/IronPython/Compiler/Ast/SuiteStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/SuiteStatement.cs rename to Src/IronPython/Compiler/Ast/SuiteStatement.cs diff --git a/IronPython/Compiler/Ast/TryStatement.cs b/Src/IronPython/Compiler/Ast/TryStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/TryStatement.cs rename to Src/IronPython/Compiler/Ast/TryStatement.cs diff --git a/IronPython/Compiler/Ast/TupleExpression.cs b/Src/IronPython/Compiler/Ast/TupleExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/TupleExpression.cs rename to Src/IronPython/Compiler/Ast/TupleExpression.cs diff --git a/IronPython/Compiler/Ast/UnaryExpression.cs b/Src/IronPython/Compiler/Ast/UnaryExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/UnaryExpression.cs rename to Src/IronPython/Compiler/Ast/UnaryExpression.cs diff --git a/IronPython/Compiler/Ast/VariableKind.cs b/Src/IronPython/Compiler/Ast/VariableKind.cs similarity index 100% rename from IronPython/Compiler/Ast/VariableKind.cs rename to Src/IronPython/Compiler/Ast/VariableKind.cs diff --git a/IronPython/Compiler/Ast/WhileStatement.cs b/Src/IronPython/Compiler/Ast/WhileStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/WhileStatement.cs rename to Src/IronPython/Compiler/Ast/WhileStatement.cs diff --git a/IronPython/Compiler/Ast/WithStatement.cs b/Src/IronPython/Compiler/Ast/WithStatement.cs similarity index 100% rename from IronPython/Compiler/Ast/WithStatement.cs rename to Src/IronPython/Compiler/Ast/WithStatement.cs diff --git a/IronPython/Compiler/Ast/YieldExpression.cs b/Src/IronPython/Compiler/Ast/YieldExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/YieldExpression.cs rename to Src/IronPython/Compiler/Ast/YieldExpression.cs diff --git a/IronPython/Compiler/Ast/YieldFromExpression.cs b/Src/IronPython/Compiler/Ast/YieldFromExpression.cs similarity index 100% rename from IronPython/Compiler/Ast/YieldFromExpression.cs rename to Src/IronPython/Compiler/Ast/YieldFromExpression.cs diff --git a/IronPython/Compiler/ClosureExpression.cs b/Src/IronPython/Compiler/ClosureExpression.cs similarity index 100% rename from IronPython/Compiler/ClosureExpression.cs rename to Src/IronPython/Compiler/ClosureExpression.cs diff --git a/IronPython/Compiler/ClosureInfo.cs b/Src/IronPython/Compiler/ClosureInfo.cs similarity index 100% rename from IronPython/Compiler/ClosureInfo.cs rename to Src/IronPython/Compiler/ClosureInfo.cs diff --git a/IronPython/Compiler/CollectableCompilationMode.cs b/Src/IronPython/Compiler/CollectableCompilationMode.cs similarity index 100% rename from IronPython/Compiler/CollectableCompilationMode.cs rename to Src/IronPython/Compiler/CollectableCompilationMode.cs diff --git a/IronPython/Compiler/CompilationMode.cs b/Src/IronPython/Compiler/CompilationMode.cs similarity index 100% rename from IronPython/Compiler/CompilationMode.cs rename to Src/IronPython/Compiler/CompilationMode.cs diff --git a/IronPython/Compiler/GeneratorRewriter.cs b/Src/IronPython/Compiler/GeneratorRewriter.cs similarity index 100% rename from IronPython/Compiler/GeneratorRewriter.cs rename to Src/IronPython/Compiler/GeneratorRewriter.cs diff --git a/IronPython/Compiler/LazyCode.cs b/Src/IronPython/Compiler/LazyCode.cs similarity index 100% rename from IronPython/Compiler/LazyCode.cs rename to Src/IronPython/Compiler/LazyCode.cs diff --git a/IronPython/Compiler/LookupCompilationMode.cs b/Src/IronPython/Compiler/LookupCompilationMode.cs similarity index 100% rename from IronPython/Compiler/LookupCompilationMode.cs rename to Src/IronPython/Compiler/LookupCompilationMode.cs diff --git a/IronPython/Compiler/OnDiskScriptCode.cs b/Src/IronPython/Compiler/OnDiskScriptCode.cs similarity index 100% rename from IronPython/Compiler/OnDiskScriptCode.cs rename to Src/IronPython/Compiler/OnDiskScriptCode.cs diff --git a/IronPython/Compiler/Parser.cs b/Src/IronPython/Compiler/Parser.cs similarity index 100% rename from IronPython/Compiler/Parser.cs rename to Src/IronPython/Compiler/Parser.cs diff --git a/IronPython/Compiler/PythonCallTargets.cs b/Src/IronPython/Compiler/PythonCallTargets.cs similarity index 100% rename from IronPython/Compiler/PythonCallTargets.cs rename to Src/IronPython/Compiler/PythonCallTargets.cs diff --git a/IronPython/Compiler/PythonCompilerOptions.cs b/Src/IronPython/Compiler/PythonCompilerOptions.cs similarity index 100% rename from IronPython/Compiler/PythonCompilerOptions.cs rename to Src/IronPython/Compiler/PythonCompilerOptions.cs diff --git a/IronPython/Compiler/PythonDynamicExpression.cs b/Src/IronPython/Compiler/PythonDynamicExpression.cs similarity index 100% rename from IronPython/Compiler/PythonDynamicExpression.cs rename to Src/IronPython/Compiler/PythonDynamicExpression.cs diff --git a/IronPython/Compiler/PythonGlobal.cs b/Src/IronPython/Compiler/PythonGlobal.cs similarity index 100% rename from IronPython/Compiler/PythonGlobal.cs rename to Src/IronPython/Compiler/PythonGlobal.cs diff --git a/IronPython/Compiler/PythonGlobalVariableExpression.cs b/Src/IronPython/Compiler/PythonGlobalVariableExpression.cs similarity index 100% rename from IronPython/Compiler/PythonGlobalVariableExpression.cs rename to Src/IronPython/Compiler/PythonGlobalVariableExpression.cs diff --git a/IronPython/Compiler/PythonOperator.cs b/Src/IronPython/Compiler/PythonOperator.cs similarity index 100% rename from IronPython/Compiler/PythonOperator.cs rename to Src/IronPython/Compiler/PythonOperator.cs diff --git a/IronPython/Compiler/PythonSavableScriptCode.cs b/Src/IronPython/Compiler/PythonSavableScriptCode.cs similarity index 100% rename from IronPython/Compiler/PythonSavableScriptCode.cs rename to Src/IronPython/Compiler/PythonSavableScriptCode.cs diff --git a/IronPython/Compiler/PythonScriptCode.cs b/Src/IronPython/Compiler/PythonScriptCode.cs similarity index 100% rename from IronPython/Compiler/PythonScriptCode.cs rename to Src/IronPython/Compiler/PythonScriptCode.cs diff --git a/IronPython/Compiler/ReducableDynamicExpression.cs b/Src/IronPython/Compiler/ReducableDynamicExpression.cs similarity index 100% rename from IronPython/Compiler/ReducableDynamicExpression.cs rename to Src/IronPython/Compiler/ReducableDynamicExpression.cs diff --git a/IronPython/Compiler/RunnableScriptCode.cs b/Src/IronPython/Compiler/RunnableScriptCode.cs similarity index 100% rename from IronPython/Compiler/RunnableScriptCode.cs rename to Src/IronPython/Compiler/RunnableScriptCode.cs diff --git a/IronPython/Compiler/RuntimeScriptCode.cs b/Src/IronPython/Compiler/RuntimeScriptCode.cs similarity index 100% rename from IronPython/Compiler/RuntimeScriptCode.cs rename to Src/IronPython/Compiler/RuntimeScriptCode.cs diff --git a/IronPython/Compiler/ToDiskCompilationMode.cs b/Src/IronPython/Compiler/ToDiskCompilationMode.cs similarity index 100% rename from IronPython/Compiler/ToDiskCompilationMode.cs rename to Src/IronPython/Compiler/ToDiskCompilationMode.cs diff --git a/IronPython/Compiler/Token.cs b/Src/IronPython/Compiler/Token.cs similarity index 100% rename from IronPython/Compiler/Token.cs rename to Src/IronPython/Compiler/Token.cs diff --git a/IronPython/Compiler/TokenKind.Generated.cs b/Src/IronPython/Compiler/TokenKind.Generated.cs similarity index 100% rename from IronPython/Compiler/TokenKind.Generated.cs rename to Src/IronPython/Compiler/TokenKind.Generated.cs diff --git a/IronPython/Compiler/Tokenizer.Generated.cs b/Src/IronPython/Compiler/Tokenizer.Generated.cs similarity index 100% rename from IronPython/Compiler/Tokenizer.Generated.cs rename to Src/IronPython/Compiler/Tokenizer.Generated.cs diff --git a/IronPython/Compiler/Tokenizer.cs b/Src/IronPython/Compiler/Tokenizer.cs similarity index 100% rename from IronPython/Compiler/Tokenizer.cs rename to Src/IronPython/Compiler/Tokenizer.cs diff --git a/IronPython/Compiler/UncollectableCompilationMode.Generated.cs b/Src/IronPython/Compiler/UncollectableCompilationMode.Generated.cs similarity index 100% rename from IronPython/Compiler/UncollectableCompilationMode.Generated.cs rename to Src/IronPython/Compiler/UncollectableCompilationMode.Generated.cs diff --git a/IronPython/Compiler/UncollectableCompilationMode.cs b/Src/IronPython/Compiler/UncollectableCompilationMode.cs similarity index 100% rename from IronPython/Compiler/UncollectableCompilationMode.cs rename to Src/IronPython/Compiler/UncollectableCompilationMode.cs diff --git a/IronPython/FakeInteropServices.cs b/Src/IronPython/FakeInteropServices.cs similarity index 100% rename from IronPython/FakeInteropServices.cs rename to Src/IronPython/FakeInteropServices.cs diff --git a/IronPython/Hosting/Python.cs b/Src/IronPython/Hosting/Python.cs similarity index 100% rename from IronPython/Hosting/Python.cs rename to Src/IronPython/Hosting/Python.cs diff --git a/IronPython/Hosting/PythonCodeDomCodeGen.cs b/Src/IronPython/Hosting/PythonCodeDomCodeGen.cs similarity index 100% rename from IronPython/Hosting/PythonCodeDomCodeGen.cs rename to Src/IronPython/Hosting/PythonCodeDomCodeGen.cs diff --git a/IronPython/Hosting/PythonCommandLine.cs b/Src/IronPython/Hosting/PythonCommandLine.cs similarity index 100% rename from IronPython/Hosting/PythonCommandLine.cs rename to Src/IronPython/Hosting/PythonCommandLine.cs diff --git a/IronPython/Hosting/PythonConsoleOptions.cs b/Src/IronPython/Hosting/PythonConsoleOptions.cs similarity index 100% rename from IronPython/Hosting/PythonConsoleOptions.cs rename to Src/IronPython/Hosting/PythonConsoleOptions.cs diff --git a/IronPython/Hosting/PythonOptionsParser.cs b/Src/IronPython/Hosting/PythonOptionsParser.cs similarity index 100% rename from IronPython/Hosting/PythonOptionsParser.cs rename to Src/IronPython/Hosting/PythonOptionsParser.cs diff --git a/IronPython/Hosting/PythonService.cs b/Src/IronPython/Hosting/PythonService.cs similarity index 100% rename from IronPython/Hosting/PythonService.cs rename to Src/IronPython/Hosting/PythonService.cs diff --git a/IronPython/Interop/Windows/Interop.Libraries.cs b/Src/IronPython/Interop/Windows/Interop.Libraries.cs similarity index 100% rename from IronPython/Interop/Windows/Interop.Libraries.cs rename to Src/IronPython/Interop/Windows/Interop.Libraries.cs diff --git a/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs b/Src/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs similarity index 100% rename from IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs rename to Src/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs diff --git a/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs b/Src/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs similarity index 100% rename from IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs rename to Src/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs diff --git a/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs b/Src/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs similarity index 100% rename from IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs rename to Src/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs diff --git a/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs b/Src/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs similarity index 100% rename from IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs rename to Src/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs diff --git a/IronPython/IronPython.csproj b/Src/IronPython/IronPython.csproj similarity index 94% rename from IronPython/IronPython.csproj rename to Src/IronPython/IronPython.csproj index 68483bd1e..4af3f1695 100644 --- a/IronPython/IronPython.csproj +++ b/Src/IronPython/IronPython.csproj @@ -23,7 +23,7 @@ True - ..\Utils\References\Mono.Posix.dll + ..\..\Utils\References\Mono.Posix.dll @@ -58,7 +58,7 @@ - + false Analyzer diff --git a/IronPython/Lib/iptest/__init__.py b/Src/IronPython/Lib/iptest/__init__.py similarity index 100% rename from IronPython/Lib/iptest/__init__.py rename to Src/IronPython/Lib/iptest/__init__.py diff --git a/IronPython/Lib/iptest/cominterop_util.py b/Src/IronPython/Lib/iptest/cominterop_util.py similarity index 100% rename from IronPython/Lib/iptest/cominterop_util.py rename to Src/IronPython/Lib/iptest/cominterop_util.py diff --git a/IronPython/Lib/iptest/console_util.py b/Src/IronPython/Lib/iptest/console_util.py similarity index 100% rename from IronPython/Lib/iptest/console_util.py rename to Src/IronPython/Lib/iptest/console_util.py diff --git a/IronPython/Lib/iptest/file_util.py b/Src/IronPython/Lib/iptest/file_util.py similarity index 100% rename from IronPython/Lib/iptest/file_util.py rename to Src/IronPython/Lib/iptest/file_util.py diff --git a/IronPython/Lib/iptest/ipunittest.py b/Src/IronPython/Lib/iptest/ipunittest.py similarity index 100% rename from IronPython/Lib/iptest/ipunittest.py rename to Src/IronPython/Lib/iptest/ipunittest.py diff --git a/IronPython/Lib/iptest/misc_util.py b/Src/IronPython/Lib/iptest/misc_util.py similarity index 100% rename from IronPython/Lib/iptest/misc_util.py rename to Src/IronPython/Lib/iptest/misc_util.py diff --git a/IronPython/Lib/iptest/process_util.py b/Src/IronPython/Lib/iptest/process_util.py similarity index 100% rename from IronPython/Lib/iptest/process_util.py rename to Src/IronPython/Lib/iptest/process_util.py diff --git a/IronPython/Lib/iptest/runner.py b/Src/IronPython/Lib/iptest/runner.py similarity index 100% rename from IronPython/Lib/iptest/runner.py rename to Src/IronPython/Lib/iptest/runner.py diff --git a/IronPython/Lib/iptest/test_env.py b/Src/IronPython/Lib/iptest/test_env.py similarity index 100% rename from IronPython/Lib/iptest/test_env.py rename to Src/IronPython/Lib/iptest/test_env.py diff --git a/IronPython/Lib/iptest/type_util.py b/Src/IronPython/Lib/iptest/type_util.py similarity index 100% rename from IronPython/Lib/iptest/type_util.py rename to Src/IronPython/Lib/iptest/type_util.py diff --git a/IronPython/Modules/Builtin.Generated.cs b/Src/IronPython/Modules/Builtin.Generated.cs similarity index 100% rename from IronPython/Modules/Builtin.Generated.cs rename to Src/IronPython/Modules/Builtin.Generated.cs diff --git a/IronPython/Modules/Builtin.cs b/Src/IronPython/Modules/Builtin.cs similarity index 100% rename from IronPython/Modules/Builtin.cs rename to Src/IronPython/Modules/Builtin.cs diff --git a/IronPython/Modules/_ast.cs b/Src/IronPython/Modules/_ast.cs old mode 100644 new mode 100755 similarity index 100% rename from IronPython/Modules/_ast.cs rename to Src/IronPython/Modules/_ast.cs diff --git a/IronPython/Modules/_fileio.cs b/Src/IronPython/Modules/_fileio.cs similarity index 100% rename from IronPython/Modules/_fileio.cs rename to Src/IronPython/Modules/_fileio.cs diff --git a/IronPython/Modules/_imp.cs b/Src/IronPython/Modules/_imp.cs similarity index 100% rename from IronPython/Modules/_imp.cs rename to Src/IronPython/Modules/_imp.cs diff --git a/IronPython/Modules/_io.cs b/Src/IronPython/Modules/_io.cs similarity index 100% rename from IronPython/Modules/_io.cs rename to Src/IronPython/Modules/_io.cs diff --git a/IronPython/Modules/_io/BytesIO.cs b/Src/IronPython/Modules/_io/BytesIO.cs similarity index 100% rename from IronPython/Modules/_io/BytesIO.cs rename to Src/IronPython/Modules/_io/BytesIO.cs diff --git a/IronPython/Modules/_io/StringIO.cs b/Src/IronPython/Modules/_io/StringIO.cs similarity index 100% rename from IronPython/Modules/_io/StringIO.cs rename to Src/IronPython/Modules/_io/StringIO.cs diff --git a/IronPython/Modules/_locale.cs b/Src/IronPython/Modules/_locale.cs similarity index 100% rename from IronPython/Modules/_locale.cs rename to Src/IronPython/Modules/_locale.cs diff --git a/IronPython/Modules/sys.cs b/Src/IronPython/Modules/sys.cs similarity index 100% rename from IronPython/Modules/sys.cs rename to Src/IronPython/Modules/sys.cs diff --git a/IronPython/Modules/unicodedata.cs b/Src/IronPython/Modules/unicodedata.cs similarity index 100% rename from IronPython/Modules/unicodedata.cs rename to Src/IronPython/Modules/unicodedata.cs diff --git a/IronPython/Modules/unicodedata/CaseFolding.txt b/Src/IronPython/Modules/unicodedata/CaseFolding.txt similarity index 100% rename from IronPython/Modules/unicodedata/CaseFolding.txt rename to Src/IronPython/Modules/unicodedata/CaseFolding.txt diff --git a/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt b/Src/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt similarity index 100% rename from IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt rename to Src/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt diff --git a/IronPython/Modules/unicodedata/EastAsianWidth.txt b/Src/IronPython/Modules/unicodedata/EastAsianWidth.txt similarity index 100% rename from IronPython/Modules/unicodedata/EastAsianWidth.txt rename to Src/IronPython/Modules/unicodedata/EastAsianWidth.txt diff --git a/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz b/Src/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz similarity index 100% rename from IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz rename to Src/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz diff --git a/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz b/Src/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz similarity index 100% rename from IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz rename to Src/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz diff --git a/IronPython/Modules/unicodedata/NameAliases.txt b/Src/IronPython/Modules/unicodedata/NameAliases.txt similarity index 100% rename from IronPython/Modules/unicodedata/NameAliases.txt rename to Src/IronPython/Modules/unicodedata/NameAliases.txt diff --git a/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt b/Src/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt similarity index 100% rename from IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt rename to Src/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt diff --git a/IronPython/Modules/unicodedata/UnicodeData.txt b/Src/IronPython/Modules/unicodedata/UnicodeData.txt similarity index 100% rename from IronPython/Modules/unicodedata/UnicodeData.txt rename to Src/IronPython/Modules/unicodedata/UnicodeData.txt diff --git a/IronPython/Modules/unicodedata/genunicodedata.py b/Src/IronPython/Modules/unicodedata/genunicodedata.py similarity index 100% rename from IronPython/Modules/unicodedata/genunicodedata.py rename to Src/IronPython/Modules/unicodedata/genunicodedata.py diff --git a/IronPython/Modules/unicodedata/license.txt b/Src/IronPython/Modules/unicodedata/license.txt similarity index 100% rename from IronPython/Modules/unicodedata/license.txt rename to Src/IronPython/Modules/unicodedata/license.txt diff --git a/IronPython/Properties/AssemblyInfo.cs b/Src/IronPython/Properties/AssemblyInfo.cs similarity index 100% rename from IronPython/Properties/AssemblyInfo.cs rename to Src/IronPython/Properties/AssemblyInfo.cs diff --git a/IronPython/Resources.Designer.cs b/Src/IronPython/Resources.Designer.cs similarity index 100% rename from IronPython/Resources.Designer.cs rename to Src/IronPython/Resources.Designer.cs diff --git a/IronPython/Resources.resx b/Src/IronPython/Resources.resx similarity index 100% rename from IronPython/Resources.resx rename to Src/IronPython/Resources.resx diff --git a/IronPython/Runtime/ArrayData.cs b/Src/IronPython/Runtime/ArrayData.cs similarity index 100% rename from IronPython/Runtime/ArrayData.cs rename to Src/IronPython/Runtime/ArrayData.cs diff --git a/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs b/Src/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs similarity index 100% rename from IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs rename to Src/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs diff --git a/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs b/Src/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs similarity index 100% rename from IronPython/Runtime/Binding/BinaryRetTypeBinder.cs rename to Src/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs diff --git a/IronPython/Runtime/Binding/Binders.cs b/Src/IronPython/Runtime/Binding/Binders.cs similarity index 100% rename from IronPython/Runtime/Binding/Binders.cs rename to Src/IronPython/Runtime/Binding/Binders.cs diff --git a/IronPython/Runtime/Binding/BindingHelpers.cs b/Src/IronPython/Runtime/Binding/BindingHelpers.cs similarity index 100% rename from IronPython/Runtime/Binding/BindingHelpers.cs rename to Src/IronPython/Runtime/Binding/BindingHelpers.cs diff --git a/IronPython/Runtime/Binding/BindingWarnings.cs b/Src/IronPython/Runtime/Binding/BindingWarnings.cs similarity index 100% rename from IronPython/Runtime/Binding/BindingWarnings.cs rename to Src/IronPython/Runtime/Binding/BindingWarnings.cs diff --git a/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs b/Src/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs similarity index 100% rename from IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs rename to Src/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs diff --git a/IronPython/Runtime/Binding/ConditionalBuilder.cs b/Src/IronPython/Runtime/Binding/ConditionalBuilder.cs similarity index 100% rename from IronPython/Runtime/Binding/ConditionalBuilder.cs rename to Src/IronPython/Runtime/Binding/ConditionalBuilder.cs diff --git a/IronPython/Runtime/Binding/ContextArgBuilder.cs b/Src/IronPython/Runtime/Binding/ContextArgBuilder.cs similarity index 100% rename from IronPython/Runtime/Binding/ContextArgBuilder.cs rename to Src/IronPython/Runtime/Binding/ContextArgBuilder.cs diff --git a/IronPython/Runtime/Binding/ConversionBinder.cs b/Src/IronPython/Runtime/Binding/ConversionBinder.cs similarity index 100% rename from IronPython/Runtime/Binding/ConversionBinder.cs rename to Src/IronPython/Runtime/Binding/ConversionBinder.cs diff --git a/IronPython/Runtime/Binding/CreateFallbackBinder.cs b/Src/IronPython/Runtime/Binding/CreateFallbackBinder.cs similarity index 100% rename from IronPython/Runtime/Binding/CreateFallbackBinder.cs rename to Src/IronPython/Runtime/Binding/CreateFallbackBinder.cs diff --git a/IronPython/Runtime/Binding/FastBindResult.cs b/Src/IronPython/Runtime/Binding/FastBindResult.cs similarity index 100% rename from IronPython/Runtime/Binding/FastBindResult.cs rename to Src/IronPython/Runtime/Binding/FastBindResult.cs diff --git a/IronPython/Runtime/Binding/FastGetBase.cs b/Src/IronPython/Runtime/Binding/FastGetBase.cs similarity index 100% rename from IronPython/Runtime/Binding/FastGetBase.cs rename to Src/IronPython/Runtime/Binding/FastGetBase.cs diff --git a/IronPython/Runtime/Binding/FastSetBase.cs b/Src/IronPython/Runtime/Binding/FastSetBase.cs similarity index 100% rename from IronPython/Runtime/Binding/FastSetBase.cs rename to Src/IronPython/Runtime/Binding/FastSetBase.cs diff --git a/IronPython/Runtime/Binding/IComConvertible.cs b/Src/IronPython/Runtime/Binding/IComConvertible.cs similarity index 100% rename from IronPython/Runtime/Binding/IComConvertible.cs rename to Src/IronPython/Runtime/Binding/IComConvertible.cs diff --git a/IronPython/Runtime/Binding/IFastGettable.cs b/Src/IronPython/Runtime/Binding/IFastGettable.cs similarity index 100% rename from IronPython/Runtime/Binding/IFastGettable.cs rename to Src/IronPython/Runtime/Binding/IFastGettable.cs diff --git a/IronPython/Runtime/Binding/IFastInvokable.cs b/Src/IronPython/Runtime/Binding/IFastInvokable.cs similarity index 100% rename from IronPython/Runtime/Binding/IFastInvokable.cs rename to Src/IronPython/Runtime/Binding/IFastInvokable.cs diff --git a/IronPython/Runtime/Binding/IFastSettable.cs b/Src/IronPython/Runtime/Binding/IFastSettable.cs similarity index 100% rename from IronPython/Runtime/Binding/IFastSettable.cs rename to Src/IronPython/Runtime/Binding/IFastSettable.cs diff --git a/IronPython/Runtime/Binding/IPythonConvertible.cs b/Src/IronPython/Runtime/Binding/IPythonConvertible.cs similarity index 100% rename from IronPython/Runtime/Binding/IPythonConvertible.cs rename to Src/IronPython/Runtime/Binding/IPythonConvertible.cs diff --git a/IronPython/Runtime/Binding/IPythonExpandable.cs b/Src/IronPython/Runtime/Binding/IPythonExpandable.cs similarity index 100% rename from IronPython/Runtime/Binding/IPythonExpandable.cs rename to Src/IronPython/Runtime/Binding/IPythonExpandable.cs diff --git a/IronPython/Runtime/Binding/IPythonGetable.cs b/Src/IronPython/Runtime/Binding/IPythonGetable.cs similarity index 100% rename from IronPython/Runtime/Binding/IPythonGetable.cs rename to Src/IronPython/Runtime/Binding/IPythonGetable.cs diff --git a/IronPython/Runtime/Binding/IPythonInvokable.cs b/Src/IronPython/Runtime/Binding/IPythonInvokable.cs similarity index 100% rename from IronPython/Runtime/Binding/IPythonInvokable.cs rename to Src/IronPython/Runtime/Binding/IPythonInvokable.cs diff --git a/IronPython/Runtime/Binding/IPythonOperable.cs b/Src/IronPython/Runtime/Binding/IPythonOperable.cs similarity index 100% rename from IronPython/Runtime/Binding/IPythonOperable.cs rename to Src/IronPython/Runtime/Binding/IPythonOperable.cs diff --git a/IronPython/Runtime/Binding/IPythonSite.cs b/Src/IronPython/Runtime/Binding/IPythonSite.cs similarity index 100% rename from IronPython/Runtime/Binding/IPythonSite.cs rename to Src/IronPython/Runtime/Binding/IPythonSite.cs diff --git a/IronPython/Runtime/Binding/MetaBuiltinFunction.cs b/Src/IronPython/Runtime/Binding/MetaBuiltinFunction.cs similarity index 100% rename from IronPython/Runtime/Binding/MetaBuiltinFunction.cs rename to Src/IronPython/Runtime/Binding/MetaBuiltinFunction.cs diff --git a/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs b/Src/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs similarity index 100% rename from IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs rename to Src/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs diff --git a/IronPython/Runtime/Binding/MetaMethod.cs b/Src/IronPython/Runtime/Binding/MetaMethod.cs similarity index 100% rename from IronPython/Runtime/Binding/MetaMethod.cs rename to Src/IronPython/Runtime/Binding/MetaMethod.cs diff --git a/IronPython/Runtime/Binding/MetaPythonFunction.cs b/Src/IronPython/Runtime/Binding/MetaPythonFunction.cs similarity index 100% rename from IronPython/Runtime/Binding/MetaPythonFunction.cs rename to Src/IronPython/Runtime/Binding/MetaPythonFunction.cs diff --git a/IronPython/Runtime/Binding/MetaPythonObject.cs b/Src/IronPython/Runtime/Binding/MetaPythonObject.cs similarity index 100% rename from IronPython/Runtime/Binding/MetaPythonObject.cs rename to Src/IronPython/Runtime/Binding/MetaPythonObject.cs diff --git a/IronPython/Runtime/Binding/MetaPythonType.Calls.cs b/Src/IronPython/Runtime/Binding/MetaPythonType.Calls.cs similarity index 100% rename from IronPython/Runtime/Binding/MetaPythonType.Calls.cs rename to Src/IronPython/Runtime/Binding/MetaPythonType.Calls.cs diff --git a/IronPython/Runtime/Binding/MetaPythonType.Members.cs b/Src/IronPython/Runtime/Binding/MetaPythonType.Members.cs similarity index 100% rename from IronPython/Runtime/Binding/MetaPythonType.Members.cs rename to Src/IronPython/Runtime/Binding/MetaPythonType.Members.cs diff --git a/IronPython/Runtime/Binding/MetaPythonType.cs b/Src/IronPython/Runtime/Binding/MetaPythonType.cs similarity index 100% rename from IronPython/Runtime/Binding/MetaPythonType.cs rename to Src/IronPython/Runtime/Binding/MetaPythonType.cs diff --git a/IronPython/Runtime/Binding/MetaUserObject.Members.cs b/Src/IronPython/Runtime/Binding/MetaUserObject.Members.cs similarity index 100% rename from IronPython/Runtime/Binding/MetaUserObject.Members.cs rename to Src/IronPython/Runtime/Binding/MetaUserObject.Members.cs diff --git a/IronPython/Runtime/Binding/MetaUserObject.cs b/Src/IronPython/Runtime/Binding/MetaUserObject.cs similarity index 100% rename from IronPython/Runtime/Binding/MetaUserObject.cs rename to Src/IronPython/Runtime/Binding/MetaUserObject.cs diff --git a/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs b/Src/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs similarity index 100% rename from IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs rename to Src/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs diff --git a/IronPython/Runtime/Binding/PythonBinder.Create.cs b/Src/IronPython/Runtime/Binding/PythonBinder.Create.cs similarity index 100% rename from IronPython/Runtime/Binding/PythonBinder.Create.cs rename to Src/IronPython/Runtime/Binding/PythonBinder.Create.cs diff --git a/IronPython/Runtime/Binding/PythonBinder.cs b/Src/IronPython/Runtime/Binding/PythonBinder.cs similarity index 100% rename from IronPython/Runtime/Binding/PythonBinder.cs rename to Src/IronPython/Runtime/Binding/PythonBinder.cs diff --git a/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs b/Src/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs similarity index 100% rename from IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs rename to Src/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs diff --git a/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs b/Src/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs similarity index 100% rename from IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs rename to Src/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs diff --git a/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs b/Src/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs similarity index 100% rename from IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs rename to Src/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs diff --git a/IronPython/Runtime/Binding/PythonExtensionBinder.cs b/Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs similarity index 100% rename from IronPython/Runtime/Binding/PythonExtensionBinder.cs rename to Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs diff --git a/IronPython/Runtime/Binding/PythonGetIndexBinder.cs b/Src/IronPython/Runtime/Binding/PythonGetIndexBinder.cs similarity index 100% rename from IronPython/Runtime/Binding/PythonGetIndexBinder.cs rename to Src/IronPython/Runtime/Binding/PythonGetIndexBinder.cs diff --git a/IronPython/Runtime/Binding/PythonGetMemberBinder.cs b/Src/IronPython/Runtime/Binding/PythonGetMemberBinder.cs similarity index 100% rename from IronPython/Runtime/Binding/PythonGetMemberBinder.cs rename to Src/IronPython/Runtime/Binding/PythonGetMemberBinder.cs diff --git a/IronPython/Runtime/Binding/PythonGetSliceBinder.cs b/Src/IronPython/Runtime/Binding/PythonGetSliceBinder.cs similarity index 100% rename from IronPython/Runtime/Binding/PythonGetSliceBinder.cs rename to Src/IronPython/Runtime/Binding/PythonGetSliceBinder.cs diff --git a/IronPython/Runtime/Binding/PythonIndexType.cs b/Src/IronPython/Runtime/Binding/PythonIndexType.cs similarity index 100% rename from IronPython/Runtime/Binding/PythonIndexType.cs rename to Src/IronPython/Runtime/Binding/PythonIndexType.cs diff --git a/IronPython/Runtime/Binding/PythonInvokeBinder.cs b/Src/IronPython/Runtime/Binding/PythonInvokeBinder.cs similarity index 100% rename from IronPython/Runtime/Binding/PythonInvokeBinder.cs rename to Src/IronPython/Runtime/Binding/PythonInvokeBinder.cs diff --git a/IronPython/Runtime/Binding/PythonOperationBinder.cs b/Src/IronPython/Runtime/Binding/PythonOperationBinder.cs similarity index 100% rename from IronPython/Runtime/Binding/PythonOperationBinder.cs rename to Src/IronPython/Runtime/Binding/PythonOperationBinder.cs diff --git a/IronPython/Runtime/Binding/PythonOperationKind.cs b/Src/IronPython/Runtime/Binding/PythonOperationKind.cs similarity index 100% rename from IronPython/Runtime/Binding/PythonOperationKind.cs rename to Src/IronPython/Runtime/Binding/PythonOperationKind.cs diff --git a/IronPython/Runtime/Binding/PythonOverloadResolver.cs b/Src/IronPython/Runtime/Binding/PythonOverloadResolver.cs similarity index 100% rename from IronPython/Runtime/Binding/PythonOverloadResolver.cs rename to Src/IronPython/Runtime/Binding/PythonOverloadResolver.cs diff --git a/IronPython/Runtime/Binding/PythonProtocol.Operations.cs b/Src/IronPython/Runtime/Binding/PythonProtocol.Operations.cs similarity index 100% rename from IronPython/Runtime/Binding/PythonProtocol.Operations.cs rename to Src/IronPython/Runtime/Binding/PythonProtocol.Operations.cs diff --git a/IronPython/Runtime/Binding/PythonProtocol.cs b/Src/IronPython/Runtime/Binding/PythonProtocol.cs similarity index 100% rename from IronPython/Runtime/Binding/PythonProtocol.cs rename to Src/IronPython/Runtime/Binding/PythonProtocol.cs diff --git a/IronPython/Runtime/Binding/PythonSetIndexBinder.cs b/Src/IronPython/Runtime/Binding/PythonSetIndexBinder.cs similarity index 100% rename from IronPython/Runtime/Binding/PythonSetIndexBinder.cs rename to Src/IronPython/Runtime/Binding/PythonSetIndexBinder.cs diff --git a/IronPython/Runtime/Binding/PythonSetMemberBinder.cs b/Src/IronPython/Runtime/Binding/PythonSetMemberBinder.cs similarity index 100% rename from IronPython/Runtime/Binding/PythonSetMemberBinder.cs rename to Src/IronPython/Runtime/Binding/PythonSetMemberBinder.cs diff --git a/IronPython/Runtime/Binding/PythonSetSliceBinder.cs b/Src/IronPython/Runtime/Binding/PythonSetSliceBinder.cs similarity index 100% rename from IronPython/Runtime/Binding/PythonSetSliceBinder.cs rename to Src/IronPython/Runtime/Binding/PythonSetSliceBinder.cs diff --git a/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs b/Src/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs similarity index 100% rename from IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs rename to Src/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs diff --git a/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs b/Src/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs similarity index 100% rename from IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs rename to Src/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs diff --git a/IronPython/Runtime/Binding/SlotOrFunction.cs b/Src/IronPython/Runtime/Binding/SlotOrFunction.cs similarity index 100% rename from IronPython/Runtime/Binding/SlotOrFunction.cs rename to Src/IronPython/Runtime/Binding/SlotOrFunction.cs diff --git a/IronPython/Runtime/Binding/WarningInfo.cs b/Src/IronPython/Runtime/Binding/WarningInfo.cs similarity index 100% rename from IronPython/Runtime/Binding/WarningInfo.cs rename to Src/IronPython/Runtime/Binding/WarningInfo.cs diff --git a/IronPython/Runtime/BufferProtocol.cs b/Src/IronPython/Runtime/BufferProtocol.cs similarity index 100% rename from IronPython/Runtime/BufferProtocol.cs rename to Src/IronPython/Runtime/BufferProtocol.cs diff --git a/IronPython/Runtime/BuiltinPythonModule.cs b/Src/IronPython/Runtime/BuiltinPythonModule.cs similarity index 100% rename from IronPython/Runtime/BuiltinPythonModule.cs rename to Src/IronPython/Runtime/BuiltinPythonModule.cs diff --git a/IronPython/Runtime/BuiltinsDictionaryStorage.cs b/Src/IronPython/Runtime/BuiltinsDictionaryStorage.cs similarity index 100% rename from IronPython/Runtime/BuiltinsDictionaryStorage.cs rename to Src/IronPython/Runtime/BuiltinsDictionaryStorage.cs diff --git a/IronPython/Runtime/ByteArray.cs b/Src/IronPython/Runtime/ByteArray.cs similarity index 100% rename from IronPython/Runtime/ByteArray.cs rename to Src/IronPython/Runtime/ByteArray.cs diff --git a/IronPython/Runtime/ByteArrayIterator.cs b/Src/IronPython/Runtime/ByteArrayIterator.cs similarity index 100% rename from IronPython/Runtime/ByteArrayIterator.cs rename to Src/IronPython/Runtime/ByteArrayIterator.cs diff --git a/IronPython/Runtime/Bytes.cs b/Src/IronPython/Runtime/Bytes.cs similarity index 100% rename from IronPython/Runtime/Bytes.cs rename to Src/IronPython/Runtime/Bytes.cs diff --git a/IronPython/Runtime/BytesIterator.cs b/Src/IronPython/Runtime/BytesIterator.cs similarity index 100% rename from IronPython/Runtime/BytesIterator.cs rename to Src/IronPython/Runtime/BytesIterator.cs diff --git a/IronPython/Runtime/BytesLikeAttribute.cs b/Src/IronPython/Runtime/BytesLikeAttribute.cs similarity index 100% rename from IronPython/Runtime/BytesLikeAttribute.cs rename to Src/IronPython/Runtime/BytesLikeAttribute.cs diff --git a/IronPython/Runtime/ClassMethodAttribute.cs b/Src/IronPython/Runtime/ClassMethodAttribute.cs similarity index 100% rename from IronPython/Runtime/ClassMethodAttribute.cs rename to Src/IronPython/Runtime/ClassMethodAttribute.cs diff --git a/IronPython/Runtime/ClassMethodDescriptor.cs b/Src/IronPython/Runtime/ClassMethodDescriptor.cs similarity index 100% rename from IronPython/Runtime/ClassMethodDescriptor.cs rename to Src/IronPython/Runtime/ClassMethodDescriptor.cs diff --git a/IronPython/Runtime/ClrModule.cs b/Src/IronPython/Runtime/ClrModule.cs similarity index 100% rename from IronPython/Runtime/ClrModule.cs rename to Src/IronPython/Runtime/ClrModule.cs diff --git a/IronPython/Runtime/CodeContext.cs b/Src/IronPython/Runtime/CodeContext.cs similarity index 100% rename from IronPython/Runtime/CodeContext.cs rename to Src/IronPython/Runtime/CodeContext.cs diff --git a/IronPython/Runtime/CollectionDebugView.cs b/Src/IronPython/Runtime/CollectionDebugView.cs similarity index 100% rename from IronPython/Runtime/CollectionDebugView.cs rename to Src/IronPython/Runtime/CollectionDebugView.cs diff --git a/IronPython/Runtime/CommonDictionaryStorage.cs b/Src/IronPython/Runtime/CommonDictionaryStorage.cs similarity index 100% rename from IronPython/Runtime/CommonDictionaryStorage.cs rename to Src/IronPython/Runtime/CommonDictionaryStorage.cs diff --git a/IronPython/Runtime/CompareUtil.cs b/Src/IronPython/Runtime/CompareUtil.cs similarity index 100% rename from IronPython/Runtime/CompareUtil.cs rename to Src/IronPython/Runtime/CompareUtil.cs diff --git a/IronPython/Runtime/CompileFlags.cs b/Src/IronPython/Runtime/CompileFlags.cs similarity index 100% rename from IronPython/Runtime/CompileFlags.cs rename to Src/IronPython/Runtime/CompileFlags.cs diff --git a/IronPython/Runtime/CompiledLoader.cs b/Src/IronPython/Runtime/CompiledLoader.cs similarity index 100% rename from IronPython/Runtime/CompiledLoader.cs rename to Src/IronPython/Runtime/CompiledLoader.cs diff --git a/IronPython/Runtime/ConstantDictionaryStorage.cs b/Src/IronPython/Runtime/ConstantDictionaryStorage.cs similarity index 100% rename from IronPython/Runtime/ConstantDictionaryStorage.cs rename to Src/IronPython/Runtime/ConstantDictionaryStorage.cs diff --git a/IronPython/Runtime/ConversionWrappers.cs b/Src/IronPython/Runtime/ConversionWrappers.cs similarity index 100% rename from IronPython/Runtime/ConversionWrappers.cs rename to Src/IronPython/Runtime/ConversionWrappers.cs diff --git a/IronPython/Runtime/Converter.cs b/Src/IronPython/Runtime/Converter.cs similarity index 100% rename from IronPython/Runtime/Converter.cs rename to Src/IronPython/Runtime/Converter.cs diff --git a/IronPython/Runtime/CustomDictionaryStorage.cs b/Src/IronPython/Runtime/CustomDictionaryStorage.cs similarity index 100% rename from IronPython/Runtime/CustomDictionaryStorage.cs rename to Src/IronPython/Runtime/CustomDictionaryStorage.cs diff --git a/IronPython/Runtime/DebuggerDictionaryStorage.cs b/Src/IronPython/Runtime/DebuggerDictionaryStorage.cs similarity index 100% rename from IronPython/Runtime/DebuggerDictionaryStorage.cs rename to Src/IronPython/Runtime/DebuggerDictionaryStorage.cs diff --git a/IronPython/Runtime/DefaultContext.cs b/Src/IronPython/Runtime/DefaultContext.cs similarity index 100% rename from IronPython/Runtime/DefaultContext.cs rename to Src/IronPython/Runtime/DefaultContext.cs diff --git a/IronPython/Runtime/Descriptors.cs b/Src/IronPython/Runtime/Descriptors.cs similarity index 100% rename from IronPython/Runtime/Descriptors.cs rename to Src/IronPython/Runtime/Descriptors.cs diff --git a/IronPython/Runtime/DictionaryOps.cs b/Src/IronPython/Runtime/DictionaryOps.cs similarity index 100% rename from IronPython/Runtime/DictionaryOps.cs rename to Src/IronPython/Runtime/DictionaryOps.cs diff --git a/IronPython/Runtime/DictionaryStorage.cs b/Src/IronPython/Runtime/DictionaryStorage.cs similarity index 100% rename from IronPython/Runtime/DictionaryStorage.cs rename to Src/IronPython/Runtime/DictionaryStorage.cs diff --git a/IronPython/Runtime/DictionaryTypeInfoAttribute.cs b/Src/IronPython/Runtime/DictionaryTypeInfoAttribute.cs similarity index 100% rename from IronPython/Runtime/DictionaryTypeInfoAttribute.cs rename to Src/IronPython/Runtime/DictionaryTypeInfoAttribute.cs diff --git a/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs b/Src/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs similarity index 100% rename from IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs rename to Src/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs diff --git a/IronPython/Runtime/DontMapICollectionToLenAttribute.cs b/Src/IronPython/Runtime/DontMapICollectionToLenAttribute.cs similarity index 100% rename from IronPython/Runtime/DontMapICollectionToLenAttribute.cs rename to Src/IronPython/Runtime/DontMapICollectionToLenAttribute.cs diff --git a/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs b/Src/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs similarity index 100% rename from IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs rename to Src/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs diff --git a/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs b/Src/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs similarity index 100% rename from IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs rename to Src/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs diff --git a/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs b/Src/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs similarity index 100% rename from IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs rename to Src/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs diff --git a/IronPython/Runtime/EmptyDictionaryStorage.cs b/Src/IronPython/Runtime/EmptyDictionaryStorage.cs similarity index 100% rename from IronPython/Runtime/EmptyDictionaryStorage.cs rename to Src/IronPython/Runtime/EmptyDictionaryStorage.cs diff --git a/IronPython/Runtime/Enumerate.cs b/Src/IronPython/Runtime/Enumerate.cs similarity index 100% rename from IronPython/Runtime/Enumerate.cs rename to Src/IronPython/Runtime/Enumerate.cs diff --git a/IronPython/Runtime/ErrorCodes.cs b/Src/IronPython/Runtime/ErrorCodes.cs similarity index 100% rename from IronPython/Runtime/ErrorCodes.cs rename to Src/IronPython/Runtime/ErrorCodes.cs diff --git a/IronPython/Runtime/Exceptions/AssertionException.Generated.cs b/Src/IronPython/Runtime/Exceptions/AssertionException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/AssertionException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/AssertionException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/AttributeErrorException.cs b/Src/IronPython/Runtime/Exceptions/AttributeErrorException.cs similarity index 100% rename from IronPython/Runtime/Exceptions/AttributeErrorException.cs rename to Src/IronPython/Runtime/Exceptions/AttributeErrorException.cs diff --git a/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs b/Src/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs b/Src/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/BufferException.Generated.cs b/Src/IronPython/Runtime/Exceptions/BufferException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/BufferException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/BufferException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs b/Src/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs b/Src/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs b/Src/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs b/Src/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/ConnectionException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs b/Src/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs b/Src/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs b/Src/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs b/Src/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/FileExistsException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs b/Src/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs b/Src/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/GeneratorExitException.cs b/Src/IronPython/Runtime/Exceptions/GeneratorExitException.cs similarity index 100% rename from IronPython/Runtime/Exceptions/GeneratorExitException.cs rename to Src/IronPython/Runtime/Exceptions/GeneratorExitException.cs diff --git a/IronPython/Runtime/Exceptions/ImportException.Generated.cs b/Src/IronPython/Runtime/Exceptions/ImportException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/ImportException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/ImportException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs b/Src/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/IndentationException.cs b/Src/IronPython/Runtime/Exceptions/IndentationException.cs similarity index 100% rename from IronPython/Runtime/Exceptions/IndentationException.cs rename to Src/IronPython/Runtime/Exceptions/IndentationException.cs diff --git a/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs b/Src/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/InterruptedException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs b/Src/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/LookupException.Generated.cs b/Src/IronPython/Runtime/Exceptions/LookupException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/LookupException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/LookupException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs b/Src/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs similarity index 100% rename from IronPython/Runtime/Exceptions/ModuleNotFoundException.cs rename to Src/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs diff --git a/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs b/Src/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/OSException.Generated.cs b/Src/IronPython/Runtime/Exceptions/OSException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/OSException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/OSException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs b/Src/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs b/Src/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/PythonException.cs b/Src/IronPython/Runtime/Exceptions/PythonException.cs similarity index 100% rename from IronPython/Runtime/Exceptions/PythonException.cs rename to Src/IronPython/Runtime/Exceptions/PythonException.cs diff --git a/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs b/Src/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs similarity index 100% rename from IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs rename to Src/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs diff --git a/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs b/Src/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs rename to Src/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs diff --git a/IronPython/Runtime/Exceptions/PythonExceptions.cs b/Src/IronPython/Runtime/Exceptions/PythonExceptions.cs similarity index 100% rename from IronPython/Runtime/Exceptions/PythonExceptions.cs rename to Src/IronPython/Runtime/Exceptions/PythonExceptions.cs diff --git a/IronPython/Runtime/Exceptions/RecursionException.Generated.cs b/Src/IronPython/Runtime/Exceptions/RecursionException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/RecursionException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/RecursionException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs b/Src/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/ReferenceException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs b/Src/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs b/Src/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/RuntimeException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs b/Src/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs b/Src/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs b/Src/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/StopIterationException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs b/Src/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/SystemExitException.cs b/Src/IronPython/Runtime/Exceptions/SystemExitException.cs similarity index 100% rename from IronPython/Runtime/Exceptions/SystemExitException.cs rename to Src/IronPython/Runtime/Exceptions/SystemExitException.cs diff --git a/IronPython/Runtime/Exceptions/TabException.cs b/Src/IronPython/Runtime/Exceptions/TabException.cs similarity index 100% rename from IronPython/Runtime/Exceptions/TabException.cs rename to Src/IronPython/Runtime/Exceptions/TabException.cs diff --git a/IronPython/Runtime/Exceptions/TraceBack.cs b/Src/IronPython/Runtime/Exceptions/TraceBack.cs similarity index 100% rename from IronPython/Runtime/Exceptions/TraceBack.cs rename to Src/IronPython/Runtime/Exceptions/TraceBack.cs diff --git a/IronPython/Runtime/Exceptions/TypeErrorException.cs b/Src/IronPython/Runtime/Exceptions/TypeErrorException.cs similarity index 100% rename from IronPython/Runtime/Exceptions/TypeErrorException.cs rename to Src/IronPython/Runtime/Exceptions/TypeErrorException.cs diff --git a/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs b/Src/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/UnicodeException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs b/Src/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs b/Src/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs b/Src/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs similarity index 100% rename from IronPython/Runtime/Exceptions/UserWarningException.Generated.cs rename to Src/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs diff --git a/IronPython/Runtime/Exceptions/ValueErrorException.cs b/Src/IronPython/Runtime/Exceptions/ValueErrorException.cs similarity index 100% rename from IronPython/Runtime/Exceptions/ValueErrorException.cs rename to Src/IronPython/Runtime/Exceptions/ValueErrorException.cs diff --git a/IronPython/Runtime/ExtensionMethodSet.cs b/Src/IronPython/Runtime/ExtensionMethodSet.cs similarity index 100% rename from IronPython/Runtime/ExtensionMethodSet.cs rename to Src/IronPython/Runtime/ExtensionMethodSet.cs diff --git a/IronPython/Runtime/Filter.cs b/Src/IronPython/Runtime/Filter.cs similarity index 100% rename from IronPython/Runtime/Filter.cs rename to Src/IronPython/Runtime/Filter.cs diff --git a/IronPython/Runtime/FormattingHelper.cs b/Src/IronPython/Runtime/FormattingHelper.cs similarity index 100% rename from IronPython/Runtime/FormattingHelper.cs rename to Src/IronPython/Runtime/FormattingHelper.cs diff --git a/IronPython/Runtime/FunctionAttributes.cs b/Src/IronPython/Runtime/FunctionAttributes.cs similarity index 100% rename from IronPython/Runtime/FunctionAttributes.cs rename to Src/IronPython/Runtime/FunctionAttributes.cs diff --git a/IronPython/Runtime/FunctionCode.cs b/Src/IronPython/Runtime/FunctionCode.cs similarity index 100% rename from IronPython/Runtime/FunctionCode.cs rename to Src/IronPython/Runtime/FunctionCode.cs diff --git a/IronPython/Runtime/Generator.cs b/Src/IronPython/Runtime/Generator.cs similarity index 100% rename from IronPython/Runtime/Generator.cs rename to Src/IronPython/Runtime/Generator.cs diff --git a/IronPython/Runtime/GlobalDictionaryStorage.cs b/Src/IronPython/Runtime/GlobalDictionaryStorage.cs similarity index 100% rename from IronPython/Runtime/GlobalDictionaryStorage.cs rename to Src/IronPython/Runtime/GlobalDictionaryStorage.cs diff --git a/IronPython/Runtime/IParameterSequence.cs b/Src/IronPython/Runtime/IParameterSequence.cs similarity index 100% rename from IronPython/Runtime/IParameterSequence.cs rename to Src/IronPython/Runtime/IParameterSequence.cs diff --git a/IronPython/Runtime/Implementation.cs b/Src/IronPython/Runtime/Implementation.cs similarity index 100% rename from IronPython/Runtime/Implementation.cs rename to Src/IronPython/Runtime/Implementation.cs diff --git a/IronPython/Runtime/Importer.cs b/Src/IronPython/Runtime/Importer.cs similarity index 100% rename from IronPython/Runtime/Importer.cs rename to Src/IronPython/Runtime/Importer.cs diff --git a/IronPython/Runtime/Index.cs b/Src/IronPython/Runtime/Index.cs similarity index 100% rename from IronPython/Runtime/Index.cs rename to Src/IronPython/Runtime/Index.cs diff --git a/IronPython/Runtime/InstancedModuleDictionaryStorage.cs b/Src/IronPython/Runtime/InstancedModuleDictionaryStorage.cs similarity index 100% rename from IronPython/Runtime/InstancedModuleDictionaryStorage.cs rename to Src/IronPython/Runtime/InstancedModuleDictionaryStorage.cs diff --git a/IronPython/Runtime/Interfaces.cs b/Src/IronPython/Runtime/Interfaces.cs similarity index 100% rename from IronPython/Runtime/Interfaces.cs rename to Src/IronPython/Runtime/Interfaces.cs diff --git a/IronPython/Runtime/KwCallInfo.cs b/Src/IronPython/Runtime/KwCallInfo.cs similarity index 100% rename from IronPython/Runtime/KwCallInfo.cs rename to Src/IronPython/Runtime/KwCallInfo.cs diff --git a/IronPython/Runtime/LiteralParser.cs b/Src/IronPython/Runtime/LiteralParser.cs similarity index 100% rename from IronPython/Runtime/LiteralParser.cs rename to Src/IronPython/Runtime/LiteralParser.cs diff --git a/IronPython/Runtime/Map.cs b/Src/IronPython/Runtime/Map.cs similarity index 100% rename from IronPython/Runtime/Map.cs rename to Src/IronPython/Runtime/Map.cs diff --git a/IronPython/Runtime/MaybeNotImplementedAttribute.cs b/Src/IronPython/Runtime/MaybeNotImplementedAttribute.cs similarity index 100% rename from IronPython/Runtime/MaybeNotImplementedAttribute.cs rename to Src/IronPython/Runtime/MaybeNotImplementedAttribute.cs diff --git a/IronPython/Runtime/MemoryStreamContentProvider.cs b/Src/IronPython/Runtime/MemoryStreamContentProvider.cs similarity index 100% rename from IronPython/Runtime/MemoryStreamContentProvider.cs rename to Src/IronPython/Runtime/MemoryStreamContentProvider.cs diff --git a/IronPython/Runtime/MemoryView.cs b/Src/IronPython/Runtime/MemoryView.cs similarity index 100% rename from IronPython/Runtime/MemoryView.cs rename to Src/IronPython/Runtime/MemoryView.cs diff --git a/IronPython/Runtime/Method.Generated.cs b/Src/IronPython/Runtime/Method.Generated.cs similarity index 100% rename from IronPython/Runtime/Method.Generated.cs rename to Src/IronPython/Runtime/Method.Generated.cs diff --git a/IronPython/Runtime/Method.cs b/Src/IronPython/Runtime/Method.cs similarity index 100% rename from IronPython/Runtime/Method.cs rename to Src/IronPython/Runtime/Method.cs diff --git a/IronPython/Runtime/MissingParameter.cs b/Src/IronPython/Runtime/MissingParameter.cs similarity index 100% rename from IronPython/Runtime/MissingParameter.cs rename to Src/IronPython/Runtime/MissingParameter.cs diff --git a/IronPython/Runtime/ModuleContext.cs b/Src/IronPython/Runtime/ModuleContext.cs similarity index 100% rename from IronPython/Runtime/ModuleContext.cs rename to Src/IronPython/Runtime/ModuleContext.cs diff --git a/IronPython/Runtime/ModuleDictionaryStorage.cs b/Src/IronPython/Runtime/ModuleDictionaryStorage.cs similarity index 100% rename from IronPython/Runtime/ModuleDictionaryStorage.cs rename to Src/IronPython/Runtime/ModuleDictionaryStorage.cs diff --git a/IronPython/Runtime/ModuleGlobalCache.cs b/Src/IronPython/Runtime/ModuleGlobalCache.cs similarity index 100% rename from IronPython/Runtime/ModuleGlobalCache.cs rename to Src/IronPython/Runtime/ModuleGlobalCache.cs diff --git a/IronPython/Runtime/ModuleLoader.cs b/Src/IronPython/Runtime/ModuleLoader.cs similarity index 100% rename from IronPython/Runtime/ModuleLoader.cs rename to Src/IronPython/Runtime/ModuleLoader.cs diff --git a/IronPython/Runtime/ModuleOptions.cs b/Src/IronPython/Runtime/ModuleOptions.cs similarity index 100% rename from IronPython/Runtime/ModuleOptions.cs rename to Src/IronPython/Runtime/ModuleOptions.cs diff --git a/IronPython/Runtime/NameType.cs b/Src/IronPython/Runtime/NameType.cs similarity index 100% rename from IronPython/Runtime/NameType.cs rename to Src/IronPython/Runtime/NameType.cs diff --git a/IronPython/Runtime/NewStringFormatter.cs b/Src/IronPython/Runtime/NewStringFormatter.cs similarity index 100% rename from IronPython/Runtime/NewStringFormatter.cs rename to Src/IronPython/Runtime/NewStringFormatter.cs diff --git a/IronPython/Runtime/ObjectAttributesAdapter.cs b/Src/IronPython/Runtime/ObjectAttributesAdapter.cs similarity index 100% rename from IronPython/Runtime/ObjectAttributesAdapter.cs rename to Src/IronPython/Runtime/ObjectAttributesAdapter.cs diff --git a/IronPython/Runtime/ObjectDebugView.cs b/Src/IronPython/Runtime/ObjectDebugView.cs similarity index 100% rename from IronPython/Runtime/ObjectDebugView.cs rename to Src/IronPython/Runtime/ObjectDebugView.cs diff --git a/IronPython/Runtime/Operations/ArrayOps.cs b/Src/IronPython/Runtime/Operations/ArrayOps.cs similarity index 100% rename from IronPython/Runtime/Operations/ArrayOps.cs rename to Src/IronPython/Runtime/Operations/ArrayOps.cs diff --git a/IronPython/Runtime/Operations/BigIntegerOps.cs b/Src/IronPython/Runtime/Operations/BigIntegerOps.cs similarity index 100% rename from IronPython/Runtime/Operations/BigIntegerOps.cs rename to Src/IronPython/Runtime/Operations/BigIntegerOps.cs diff --git a/IronPython/Runtime/Operations/BoolOps.cs b/Src/IronPython/Runtime/Operations/BoolOps.cs similarity index 100% rename from IronPython/Runtime/Operations/BoolOps.cs rename to Src/IronPython/Runtime/Operations/BoolOps.cs diff --git a/IronPython/Runtime/Operations/ByteOps.cs b/Src/IronPython/Runtime/Operations/ByteOps.cs similarity index 100% rename from IronPython/Runtime/Operations/ByteOps.cs rename to Src/IronPython/Runtime/Operations/ByteOps.cs diff --git a/IronPython/Runtime/Operations/CharOps.cs b/Src/IronPython/Runtime/Operations/CharOps.cs similarity index 100% rename from IronPython/Runtime/Operations/CharOps.cs rename to Src/IronPython/Runtime/Operations/CharOps.cs diff --git a/IronPython/Runtime/Operations/ComOps.cs b/Src/IronPython/Runtime/Operations/ComOps.cs similarity index 100% rename from IronPython/Runtime/Operations/ComOps.cs rename to Src/IronPython/Runtime/Operations/ComOps.cs diff --git a/IronPython/Runtime/Operations/ComplexOps.cs b/Src/IronPython/Runtime/Operations/ComplexOps.cs similarity index 100% rename from IronPython/Runtime/Operations/ComplexOps.cs rename to Src/IronPython/Runtime/Operations/ComplexOps.cs diff --git a/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs b/Src/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs similarity index 100% rename from IronPython/Runtime/Operations/CustomTypeDescHelpers.cs rename to Src/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs diff --git a/IronPython/Runtime/Operations/DBNullOps.cs b/Src/IronPython/Runtime/Operations/DBNullOps.cs similarity index 100% rename from IronPython/Runtime/Operations/DBNullOps.cs rename to Src/IronPython/Runtime/Operations/DBNullOps.cs diff --git a/IronPython/Runtime/Operations/DateTimeOps.cs b/Src/IronPython/Runtime/Operations/DateTimeOps.cs similarity index 100% rename from IronPython/Runtime/Operations/DateTimeOps.cs rename to Src/IronPython/Runtime/Operations/DateTimeOps.cs diff --git a/IronPython/Runtime/Operations/DecimalOps.cs b/Src/IronPython/Runtime/Operations/DecimalOps.cs similarity index 100% rename from IronPython/Runtime/Operations/DecimalOps.cs rename to Src/IronPython/Runtime/Operations/DecimalOps.cs diff --git a/IronPython/Runtime/Operations/DelegateOps.cs b/Src/IronPython/Runtime/Operations/DelegateOps.cs similarity index 100% rename from IronPython/Runtime/Operations/DelegateOps.cs rename to Src/IronPython/Runtime/Operations/DelegateOps.cs diff --git a/IronPython/Runtime/Operations/DictionaryOfTOps.cs b/Src/IronPython/Runtime/Operations/DictionaryOfTOps.cs similarity index 100% rename from IronPython/Runtime/Operations/DictionaryOfTOps.cs rename to Src/IronPython/Runtime/Operations/DictionaryOfTOps.cs diff --git a/IronPython/Runtime/Operations/EnumOps.cs b/Src/IronPython/Runtime/Operations/EnumOps.cs similarity index 100% rename from IronPython/Runtime/Operations/EnumOps.cs rename to Src/IronPython/Runtime/Operations/EnumOps.cs diff --git a/IronPython/Runtime/Operations/FloatOps.Generated.cs b/Src/IronPython/Runtime/Operations/FloatOps.Generated.cs similarity index 100% rename from IronPython/Runtime/Operations/FloatOps.Generated.cs rename to Src/IronPython/Runtime/Operations/FloatOps.Generated.cs diff --git a/IronPython/Runtime/Operations/FloatOps.cs b/Src/IronPython/Runtime/Operations/FloatOps.cs similarity index 100% rename from IronPython/Runtime/Operations/FloatOps.cs rename to Src/IronPython/Runtime/Operations/FloatOps.cs diff --git a/IronPython/Runtime/Operations/IListOfByteOps.cs b/Src/IronPython/Runtime/Operations/IListOfByteOps.cs similarity index 100% rename from IronPython/Runtime/Operations/IListOfByteOps.cs rename to Src/IronPython/Runtime/Operations/IListOfByteOps.cs diff --git a/IronPython/Runtime/Operations/InstanceOps.cs b/Src/IronPython/Runtime/Operations/InstanceOps.cs similarity index 100% rename from IronPython/Runtime/Operations/InstanceOps.cs rename to Src/IronPython/Runtime/Operations/InstanceOps.cs diff --git a/IronPython/Runtime/Operations/IntOps.Generated.cs b/Src/IronPython/Runtime/Operations/IntOps.Generated.cs similarity index 100% rename from IronPython/Runtime/Operations/IntOps.Generated.cs rename to Src/IronPython/Runtime/Operations/IntOps.Generated.cs diff --git a/IronPython/Runtime/Operations/IntOps.cs b/Src/IronPython/Runtime/Operations/IntOps.cs similarity index 100% rename from IronPython/Runtime/Operations/IntOps.cs rename to Src/IronPython/Runtime/Operations/IntOps.cs diff --git a/IronPython/Runtime/Operations/IntPtrOps.cs b/Src/IronPython/Runtime/Operations/IntPtrOps.cs similarity index 100% rename from IronPython/Runtime/Operations/IntPtrOps.cs rename to Src/IronPython/Runtime/Operations/IntPtrOps.cs diff --git a/IronPython/Runtime/Operations/ListOfTOps.cs b/Src/IronPython/Runtime/Operations/ListOfTOps.cs similarity index 100% rename from IronPython/Runtime/Operations/ListOfTOps.cs rename to Src/IronPython/Runtime/Operations/ListOfTOps.cs diff --git a/IronPython/Runtime/Operations/MarshalOps.cs b/Src/IronPython/Runtime/Operations/MarshalOps.cs similarity index 100% rename from IronPython/Runtime/Operations/MarshalOps.cs rename to Src/IronPython/Runtime/Operations/MarshalOps.cs diff --git a/IronPython/Runtime/Operations/NamespaceTrackerOps.cs b/Src/IronPython/Runtime/Operations/NamespaceTrackerOps.cs similarity index 100% rename from IronPython/Runtime/Operations/NamespaceTrackerOps.cs rename to Src/IronPython/Runtime/Operations/NamespaceTrackerOps.cs diff --git a/IronPython/Runtime/Operations/ObjectOps.cs b/Src/IronPython/Runtime/Operations/ObjectOps.cs similarity index 100% rename from IronPython/Runtime/Operations/ObjectOps.cs rename to Src/IronPython/Runtime/Operations/ObjectOps.cs diff --git a/IronPython/Runtime/Operations/PythonCalls.cs b/Src/IronPython/Runtime/Operations/PythonCalls.cs similarity index 100% rename from IronPython/Runtime/Operations/PythonCalls.cs rename to Src/IronPython/Runtime/Operations/PythonCalls.cs diff --git a/IronPython/Runtime/Operations/PythonOps.Generated.cs b/Src/IronPython/Runtime/Operations/PythonOps.Generated.cs similarity index 100% rename from IronPython/Runtime/Operations/PythonOps.Generated.cs rename to Src/IronPython/Runtime/Operations/PythonOps.Generated.cs diff --git a/IronPython/Runtime/Operations/PythonOps.cs b/Src/IronPython/Runtime/Operations/PythonOps.cs similarity index 100% rename from IronPython/Runtime/Operations/PythonOps.cs rename to Src/IronPython/Runtime/Operations/PythonOps.cs diff --git a/IronPython/Runtime/Operations/PythonTypeOps.cs b/Src/IronPython/Runtime/Operations/PythonTypeOps.cs similarity index 100% rename from IronPython/Runtime/Operations/PythonTypeOps.cs rename to Src/IronPython/Runtime/Operations/PythonTypeOps.cs diff --git a/IronPython/Runtime/Operations/StringOps.Generated.cs b/Src/IronPython/Runtime/Operations/StringOps.Generated.cs similarity index 100% rename from IronPython/Runtime/Operations/StringOps.Generated.cs rename to Src/IronPython/Runtime/Operations/StringOps.Generated.cs diff --git a/IronPython/Runtime/Operations/StringOps.cs b/Src/IronPython/Runtime/Operations/StringOps.cs similarity index 100% rename from IronPython/Runtime/Operations/StringOps.cs rename to Src/IronPython/Runtime/Operations/StringOps.cs diff --git a/IronPython/Runtime/Operations/TypeGroupOps.cs b/Src/IronPython/Runtime/Operations/TypeGroupOps.cs similarity index 100% rename from IronPython/Runtime/Operations/TypeGroupOps.cs rename to Src/IronPython/Runtime/Operations/TypeGroupOps.cs diff --git a/IronPython/Runtime/Operations/TypeTrackerOps.cs b/Src/IronPython/Runtime/Operations/TypeTrackerOps.cs similarity index 100% rename from IronPython/Runtime/Operations/TypeTrackerOps.cs rename to Src/IronPython/Runtime/Operations/TypeTrackerOps.cs diff --git a/IronPython/Runtime/Operations/UIntPtrOps.cs b/Src/IronPython/Runtime/Operations/UIntPtrOps.cs similarity index 100% rename from IronPython/Runtime/Operations/UIntPtrOps.cs rename to Src/IronPython/Runtime/Operations/UIntPtrOps.cs diff --git a/IronPython/Runtime/Operations/UserTypeOps.cs b/Src/IronPython/Runtime/Operations/UserTypeOps.cs similarity index 100% rename from IronPython/Runtime/Operations/UserTypeOps.cs rename to Src/IronPython/Runtime/Operations/UserTypeOps.cs diff --git a/IronPython/Runtime/OutputWriter.cs b/Src/IronPython/Runtime/OutputWriter.cs similarity index 100% rename from IronPython/Runtime/OutputWriter.cs rename to Src/IronPython/Runtime/OutputWriter.cs diff --git a/IronPython/Runtime/PlatformsAttribute.cs b/Src/IronPython/Runtime/PlatformsAttribute.cs similarity index 100% rename from IronPython/Runtime/PlatformsAttribute.cs rename to Src/IronPython/Runtime/PlatformsAttribute.cs diff --git a/IronPython/Runtime/Profiler.cs b/Src/IronPython/Runtime/Profiler.cs similarity index 100% rename from IronPython/Runtime/Profiler.cs rename to Src/IronPython/Runtime/Profiler.cs diff --git a/IronPython/Runtime/PythonContext.Generated.cs b/Src/IronPython/Runtime/PythonContext.Generated.cs similarity index 100% rename from IronPython/Runtime/PythonContext.Generated.cs rename to Src/IronPython/Runtime/PythonContext.Generated.cs diff --git a/IronPython/Runtime/PythonContext.cs b/Src/IronPython/Runtime/PythonContext.cs similarity index 100% rename from IronPython/Runtime/PythonContext.cs rename to Src/IronPython/Runtime/PythonContext.cs diff --git a/IronPython/Runtime/PythonDictionary.cs b/Src/IronPython/Runtime/PythonDictionary.cs similarity index 100% rename from IronPython/Runtime/PythonDictionary.cs rename to Src/IronPython/Runtime/PythonDictionary.cs diff --git a/IronPython/Runtime/PythonDocumentationProvider.cs b/Src/IronPython/Runtime/PythonDocumentationProvider.cs similarity index 100% rename from IronPython/Runtime/PythonDocumentationProvider.cs rename to Src/IronPython/Runtime/PythonDocumentationProvider.cs diff --git a/IronPython/Runtime/PythonDynamicStackFrame.cs b/Src/IronPython/Runtime/PythonDynamicStackFrame.cs similarity index 100% rename from IronPython/Runtime/PythonDynamicStackFrame.cs rename to Src/IronPython/Runtime/PythonDynamicStackFrame.cs diff --git a/IronPython/Runtime/PythonEncoding.cs b/Src/IronPython/Runtime/PythonEncoding.cs similarity index 100% rename from IronPython/Runtime/PythonEncoding.cs rename to Src/IronPython/Runtime/PythonEncoding.cs diff --git a/IronPython/Runtime/PythonFileManager.cs b/Src/IronPython/Runtime/PythonFileManager.cs similarity index 100% rename from IronPython/Runtime/PythonFileManager.cs rename to Src/IronPython/Runtime/PythonFileManager.cs diff --git a/IronPython/Runtime/PythonFunction.Generated.cs b/Src/IronPython/Runtime/PythonFunction.Generated.cs similarity index 100% rename from IronPython/Runtime/PythonFunction.Generated.cs rename to Src/IronPython/Runtime/PythonFunction.Generated.cs diff --git a/IronPython/Runtime/PythonFunction.cs b/Src/IronPython/Runtime/PythonFunction.cs similarity index 100% rename from IronPython/Runtime/PythonFunction.cs rename to Src/IronPython/Runtime/PythonFunction.cs diff --git a/IronPython/Runtime/PythonHiddenAttribute.cs b/Src/IronPython/Runtime/PythonHiddenAttribute.cs similarity index 100% rename from IronPython/Runtime/PythonHiddenAttribute.cs rename to Src/IronPython/Runtime/PythonHiddenAttribute.cs diff --git a/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs b/Src/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs similarity index 100% rename from IronPython/Runtime/PythonHiddenBaseClassAttribute.cs rename to Src/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs diff --git a/IronPython/Runtime/PythonList.cs b/Src/IronPython/Runtime/PythonList.cs similarity index 100% rename from IronPython/Runtime/PythonList.cs rename to Src/IronPython/Runtime/PythonList.cs diff --git a/IronPython/Runtime/PythonModule.cs b/Src/IronPython/Runtime/PythonModule.cs old mode 100644 new mode 100755 similarity index 100% rename from IronPython/Runtime/PythonModule.cs rename to Src/IronPython/Runtime/PythonModule.cs diff --git a/IronPython/Runtime/PythonModuleAttribute.cs b/Src/IronPython/Runtime/PythonModuleAttribute.cs similarity index 100% rename from IronPython/Runtime/PythonModuleAttribute.cs rename to Src/IronPython/Runtime/PythonModuleAttribute.cs diff --git a/IronPython/Runtime/PythonNarrowing.cs b/Src/IronPython/Runtime/PythonNarrowing.cs similarity index 100% rename from IronPython/Runtime/PythonNarrowing.cs rename to Src/IronPython/Runtime/PythonNarrowing.cs diff --git a/IronPython/Runtime/PythonOptions.cs b/Src/IronPython/Runtime/PythonOptions.cs similarity index 100% rename from IronPython/Runtime/PythonOptions.cs rename to Src/IronPython/Runtime/PythonOptions.cs diff --git a/IronPython/Runtime/PythonRange.cs b/Src/IronPython/Runtime/PythonRange.cs similarity index 100% rename from IronPython/Runtime/PythonRange.cs rename to Src/IronPython/Runtime/PythonRange.cs diff --git a/IronPython/Runtime/PythonScopeExtension.cs b/Src/IronPython/Runtime/PythonScopeExtension.cs similarity index 100% rename from IronPython/Runtime/PythonScopeExtension.cs rename to Src/IronPython/Runtime/PythonScopeExtension.cs diff --git a/IronPython/Runtime/PythonStrIterator.cs b/Src/IronPython/Runtime/PythonStrIterator.cs similarity index 100% rename from IronPython/Runtime/PythonStrIterator.cs rename to Src/IronPython/Runtime/PythonStrIterator.cs diff --git a/IronPython/Runtime/PythonTracebackListener.cs b/Src/IronPython/Runtime/PythonTracebackListener.cs similarity index 100% rename from IronPython/Runtime/PythonTracebackListener.cs rename to Src/IronPython/Runtime/PythonTracebackListener.cs diff --git a/IronPython/Runtime/PythonTuple.cs b/Src/IronPython/Runtime/PythonTuple.cs similarity index 100% rename from IronPython/Runtime/PythonTuple.cs rename to Src/IronPython/Runtime/PythonTuple.cs diff --git a/IronPython/Runtime/PythonTypeAttribute.cs b/Src/IronPython/Runtime/PythonTypeAttribute.cs similarity index 100% rename from IronPython/Runtime/PythonTypeAttribute.cs rename to Src/IronPython/Runtime/PythonTypeAttribute.cs diff --git a/IronPython/Runtime/Reversed.cs b/Src/IronPython/Runtime/Reversed.cs similarity index 100% rename from IronPython/Runtime/Reversed.cs rename to Src/IronPython/Runtime/Reversed.cs diff --git a/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs b/Src/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs similarity index 100% rename from IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs rename to Src/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs diff --git a/IronPython/Runtime/ScopeDictionaryStorage.cs b/Src/IronPython/Runtime/ScopeDictionaryStorage.cs similarity index 100% rename from IronPython/Runtime/ScopeDictionaryStorage.cs rename to Src/IronPython/Runtime/ScopeDictionaryStorage.cs diff --git a/IronPython/Runtime/SequenceTypeInfoAttribute.cs b/Src/IronPython/Runtime/SequenceTypeInfoAttribute.cs similarity index 100% rename from IronPython/Runtime/SequenceTypeInfoAttribute.cs rename to Src/IronPython/Runtime/SequenceTypeInfoAttribute.cs diff --git a/IronPython/Runtime/Set.cs b/Src/IronPython/Runtime/Set.cs similarity index 100% rename from IronPython/Runtime/Set.cs rename to Src/IronPython/Runtime/Set.cs diff --git a/IronPython/Runtime/SetStorage.cs b/Src/IronPython/Runtime/SetStorage.cs similarity index 100% rename from IronPython/Runtime/SetStorage.cs rename to Src/IronPython/Runtime/SetStorage.cs diff --git a/IronPython/Runtime/SimpleNamespace.cs b/Src/IronPython/Runtime/SimpleNamespace.cs similarity index 100% rename from IronPython/Runtime/SimpleNamespace.cs rename to Src/IronPython/Runtime/SimpleNamespace.cs diff --git a/IronPython/Runtime/SiteLocalStorage.cs b/Src/IronPython/Runtime/SiteLocalStorage.cs similarity index 100% rename from IronPython/Runtime/SiteLocalStorage.cs rename to Src/IronPython/Runtime/SiteLocalStorage.cs diff --git a/IronPython/Runtime/Slice.cs b/Src/IronPython/Runtime/Slice.cs similarity index 100% rename from IronPython/Runtime/Slice.cs rename to Src/IronPython/Runtime/Slice.cs diff --git a/IronPython/Runtime/StringDictionaryStorage.cs b/Src/IronPython/Runtime/StringDictionaryStorage.cs similarity index 100% rename from IronPython/Runtime/StringDictionaryStorage.cs rename to Src/IronPython/Runtime/StringDictionaryStorage.cs diff --git a/IronPython/Runtime/StringFormatSpec.cs b/Src/IronPython/Runtime/StringFormatSpec.cs similarity index 100% rename from IronPython/Runtime/StringFormatSpec.cs rename to Src/IronPython/Runtime/StringFormatSpec.cs diff --git a/IronPython/Runtime/StringFormatter.cs b/Src/IronPython/Runtime/StringFormatter.cs similarity index 100% rename from IronPython/Runtime/StringFormatter.cs rename to Src/IronPython/Runtime/StringFormatter.cs diff --git a/IronPython/Runtime/Super.cs b/Src/IronPython/Runtime/Super.cs similarity index 100% rename from IronPython/Runtime/Super.cs rename to Src/IronPython/Runtime/Super.cs diff --git a/IronPython/Runtime/Symbols.Generated.cs b/Src/IronPython/Runtime/Symbols.Generated.cs similarity index 100% rename from IronPython/Runtime/Symbols.Generated.cs rename to Src/IronPython/Runtime/Symbols.Generated.cs diff --git a/IronPython/Runtime/ThrowingErrorSink.cs b/Src/IronPython/Runtime/ThrowingErrorSink.cs similarity index 100% rename from IronPython/Runtime/ThrowingErrorSink.cs rename to Src/IronPython/Runtime/ThrowingErrorSink.cs diff --git a/IronPython/Runtime/TypecodeOps.cs b/Src/IronPython/Runtime/TypecodeOps.cs similarity index 100% rename from IronPython/Runtime/TypecodeOps.cs rename to Src/IronPython/Runtime/TypecodeOps.cs diff --git a/IronPython/Runtime/Types/BuiltinFunction.cs b/Src/IronPython/Runtime/Types/BuiltinFunction.cs similarity index 100% rename from IronPython/Runtime/Types/BuiltinFunction.cs rename to Src/IronPython/Runtime/Types/BuiltinFunction.cs diff --git a/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs b/Src/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs similarity index 100% rename from IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs rename to Src/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs diff --git a/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs b/Src/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs similarity index 100% rename from IronPython/Runtime/Types/BuiltinMethodDescriptor.cs rename to Src/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs diff --git a/IronPython/Runtime/Types/CachedNewTypeInfo.cs b/Src/IronPython/Runtime/Types/CachedNewTypeInfo.cs similarity index 100% rename from IronPython/Runtime/Types/CachedNewTypeInfo.cs rename to Src/IronPython/Runtime/Types/CachedNewTypeInfo.cs diff --git a/IronPython/Runtime/Types/ConstructorFunction.cs b/Src/IronPython/Runtime/Types/ConstructorFunction.cs similarity index 100% rename from IronPython/Runtime/Types/ConstructorFunction.cs rename to Src/IronPython/Runtime/Types/ConstructorFunction.cs diff --git a/IronPython/Runtime/Types/CustomAttributeTracker.cs b/Src/IronPython/Runtime/Types/CustomAttributeTracker.cs similarity index 100% rename from IronPython/Runtime/Types/CustomAttributeTracker.cs rename to Src/IronPython/Runtime/Types/CustomAttributeTracker.cs diff --git a/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs b/Src/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs similarity index 100% rename from IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs rename to Src/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs diff --git a/IronPython/Runtime/Types/DocBuilder.cs b/Src/IronPython/Runtime/Types/DocBuilder.cs similarity index 100% rename from IronPython/Runtime/Types/DocBuilder.cs rename to Src/IronPython/Runtime/Types/DocBuilder.cs diff --git a/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs b/Src/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs similarity index 100% rename from IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs rename to Src/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs diff --git a/IronPython/Runtime/Types/DynamicHelpers.cs b/Src/IronPython/Runtime/Types/DynamicHelpers.cs similarity index 100% rename from IronPython/Runtime/Types/DynamicHelpers.cs rename to Src/IronPython/Runtime/Types/DynamicHelpers.cs diff --git a/IronPython/Runtime/Types/EmptyType.cs b/Src/IronPython/Runtime/Types/EmptyType.cs similarity index 100% rename from IronPython/Runtime/Types/EmptyType.cs rename to Src/IronPython/Runtime/Types/EmptyType.cs diff --git a/IronPython/Runtime/Types/ExtensionPropertyInfo.cs b/Src/IronPython/Runtime/Types/ExtensionPropertyInfo.cs similarity index 100% rename from IronPython/Runtime/Types/ExtensionPropertyInfo.cs rename to Src/IronPython/Runtime/Types/ExtensionPropertyInfo.cs diff --git a/IronPython/Runtime/Types/FunctionType.cs b/Src/IronPython/Runtime/Types/FunctionType.cs similarity index 100% rename from IronPython/Runtime/Types/FunctionType.cs rename to Src/IronPython/Runtime/Types/FunctionType.cs diff --git a/IronPython/Runtime/Types/IPythonObject.cs b/Src/IronPython/Runtime/Types/IPythonObject.cs similarity index 100% rename from IronPython/Runtime/Types/IPythonObject.cs rename to Src/IronPython/Runtime/Types/IPythonObject.cs diff --git a/IronPython/Runtime/Types/InstanceCreator.cs b/Src/IronPython/Runtime/Types/InstanceCreator.cs similarity index 100% rename from IronPython/Runtime/Types/InstanceCreator.cs rename to Src/IronPython/Runtime/Types/InstanceCreator.cs diff --git a/IronPython/Runtime/Types/MappingProxy.cs b/Src/IronPython/Runtime/Types/MappingProxy.cs similarity index 100% rename from IronPython/Runtime/Types/MappingProxy.cs rename to Src/IronPython/Runtime/Types/MappingProxy.cs diff --git a/IronPython/Runtime/Types/Mro.cs b/Src/IronPython/Runtime/Types/Mro.cs similarity index 100% rename from IronPython/Runtime/Types/Mro.cs rename to Src/IronPython/Runtime/Types/Mro.cs diff --git a/IronPython/Runtime/Types/NameConverter.cs b/Src/IronPython/Runtime/Types/NameConverter.cs similarity index 100% rename from IronPython/Runtime/Types/NameConverter.cs rename to Src/IronPython/Runtime/Types/NameConverter.cs diff --git a/IronPython/Runtime/Types/NewTypeInfo.cs b/Src/IronPython/Runtime/Types/NewTypeInfo.cs similarity index 100% rename from IronPython/Runtime/Types/NewTypeInfo.cs rename to Src/IronPython/Runtime/Types/NewTypeInfo.cs diff --git a/IronPython/Runtime/Types/NewTypeMaker.cs b/Src/IronPython/Runtime/Types/NewTypeMaker.cs similarity index 100% rename from IronPython/Runtime/Types/NewTypeMaker.cs rename to Src/IronPython/Runtime/Types/NewTypeMaker.cs diff --git a/IronPython/Runtime/Types/OperatorMapping.cs b/Src/IronPython/Runtime/Types/OperatorMapping.cs similarity index 100% rename from IronPython/Runtime/Types/OperatorMapping.cs rename to Src/IronPython/Runtime/Types/OperatorMapping.cs diff --git a/IronPython/Runtime/Types/ParameterInfoWrapper.cs b/Src/IronPython/Runtime/Types/ParameterInfoWrapper.cs similarity index 100% rename from IronPython/Runtime/Types/ParameterInfoWrapper.cs rename to Src/IronPython/Runtime/Types/ParameterInfoWrapper.cs diff --git a/IronPython/Runtime/Types/PythonAssemblyOps.cs b/Src/IronPython/Runtime/Types/PythonAssemblyOps.cs similarity index 100% rename from IronPython/Runtime/Types/PythonAssemblyOps.cs rename to Src/IronPython/Runtime/Types/PythonAssemblyOps.cs diff --git a/IronPython/Runtime/Types/PythonSiteCache.cs b/Src/IronPython/Runtime/Types/PythonSiteCache.cs similarity index 100% rename from IronPython/Runtime/Types/PythonSiteCache.cs rename to Src/IronPython/Runtime/Types/PythonSiteCache.cs diff --git a/IronPython/Runtime/Types/PythonType.Generated.cs b/Src/IronPython/Runtime/Types/PythonType.Generated.cs similarity index 100% rename from IronPython/Runtime/Types/PythonType.Generated.cs rename to Src/IronPython/Runtime/Types/PythonType.Generated.cs diff --git a/IronPython/Runtime/Types/PythonType.cs b/Src/IronPython/Runtime/Types/PythonType.cs similarity index 100% rename from IronPython/Runtime/Types/PythonType.cs rename to Src/IronPython/Runtime/Types/PythonType.cs diff --git a/IronPython/Runtime/Types/PythonTypeDataSlot.cs b/Src/IronPython/Runtime/Types/PythonTypeDataSlot.cs similarity index 100% rename from IronPython/Runtime/Types/PythonTypeDataSlot.cs rename to Src/IronPython/Runtime/Types/PythonTypeDataSlot.cs diff --git a/IronPython/Runtime/Types/PythonTypeDictSlot.cs b/Src/IronPython/Runtime/Types/PythonTypeDictSlot.cs similarity index 100% rename from IronPython/Runtime/Types/PythonTypeDictSlot.cs rename to Src/IronPython/Runtime/Types/PythonTypeDictSlot.cs diff --git a/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs b/Src/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs similarity index 100% rename from IronPython/Runtime/Types/PythonTypeInfo.Generated.cs rename to Src/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs diff --git a/IronPython/Runtime/Types/PythonTypeInfo.cs b/Src/IronPython/Runtime/Types/PythonTypeInfo.cs similarity index 100% rename from IronPython/Runtime/Types/PythonTypeInfo.cs rename to Src/IronPython/Runtime/Types/PythonTypeInfo.cs diff --git a/IronPython/Runtime/Types/PythonTypeSlot.cs b/Src/IronPython/Runtime/Types/PythonTypeSlot.cs similarity index 100% rename from IronPython/Runtime/Types/PythonTypeSlot.cs rename to Src/IronPython/Runtime/Types/PythonTypeSlot.cs diff --git a/IronPython/Runtime/Types/PythonTypeTypeSlot.cs b/Src/IronPython/Runtime/Types/PythonTypeTypeSlot.cs similarity index 100% rename from IronPython/Runtime/Types/PythonTypeTypeSlot.cs rename to Src/IronPython/Runtime/Types/PythonTypeTypeSlot.cs diff --git a/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs b/Src/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs similarity index 100% rename from IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs rename to Src/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs diff --git a/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs b/Src/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs similarity index 100% rename from IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs rename to Src/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs diff --git a/IronPython/Runtime/Types/ReflectedEvent.cs b/Src/IronPython/Runtime/Types/ReflectedEvent.cs similarity index 100% rename from IronPython/Runtime/Types/ReflectedEvent.cs rename to Src/IronPython/Runtime/Types/ReflectedEvent.cs diff --git a/IronPython/Runtime/Types/ReflectedExtensionProperty.cs b/Src/IronPython/Runtime/Types/ReflectedExtensionProperty.cs similarity index 100% rename from IronPython/Runtime/Types/ReflectedExtensionProperty.cs rename to Src/IronPython/Runtime/Types/ReflectedExtensionProperty.cs diff --git a/IronPython/Runtime/Types/ReflectedField.cs b/Src/IronPython/Runtime/Types/ReflectedField.cs similarity index 100% rename from IronPython/Runtime/Types/ReflectedField.cs rename to Src/IronPython/Runtime/Types/ReflectedField.cs diff --git a/IronPython/Runtime/Types/ReflectedGetterSetter.cs b/Src/IronPython/Runtime/Types/ReflectedGetterSetter.cs similarity index 100% rename from IronPython/Runtime/Types/ReflectedGetterSetter.cs rename to Src/IronPython/Runtime/Types/ReflectedGetterSetter.cs diff --git a/IronPython/Runtime/Types/ReflectedIndexer.cs b/Src/IronPython/Runtime/Types/ReflectedIndexer.cs similarity index 100% rename from IronPython/Runtime/Types/ReflectedIndexer.cs rename to Src/IronPython/Runtime/Types/ReflectedIndexer.cs diff --git a/IronPython/Runtime/Types/ReflectedProperty.cs b/Src/IronPython/Runtime/Types/ReflectedProperty.cs similarity index 100% rename from IronPython/Runtime/Types/ReflectedProperty.cs rename to Src/IronPython/Runtime/Types/ReflectedProperty.cs diff --git a/IronPython/Runtime/Types/ReflectedSlotProperty.cs b/Src/IronPython/Runtime/Types/ReflectedSlotProperty.cs similarity index 100% rename from IronPython/Runtime/Types/ReflectedSlotProperty.cs rename to Src/IronPython/Runtime/Types/ReflectedSlotProperty.cs diff --git a/IronPython/Runtime/Types/ResolvedMember.cs b/Src/IronPython/Runtime/Types/ResolvedMember.cs similarity index 100% rename from IronPython/Runtime/Types/ResolvedMember.cs rename to Src/IronPython/Runtime/Types/ResolvedMember.cs diff --git a/IronPython/Runtime/Types/SlotFieldAttribute.cs b/Src/IronPython/Runtime/Types/SlotFieldAttribute.cs similarity index 100% rename from IronPython/Runtime/Types/SlotFieldAttribute.cs rename to Src/IronPython/Runtime/Types/SlotFieldAttribute.cs diff --git a/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs b/Src/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs similarity index 100% rename from IronPython/Runtime/Types/StaticUnderlyingSystemType.cs rename to Src/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs diff --git a/IronPython/Runtime/Types/TypeCache.Generated.cs b/Src/IronPython/Runtime/Types/TypeCache.Generated.cs similarity index 100% rename from IronPython/Runtime/Types/TypeCache.Generated.cs rename to Src/IronPython/Runtime/Types/TypeCache.Generated.cs diff --git a/IronPython/Runtime/UnboundNameException.cs b/Src/IronPython/Runtime/UnboundNameException.cs similarity index 100% rename from IronPython/Runtime/UnboundNameException.cs rename to Src/IronPython/Runtime/UnboundNameException.cs diff --git a/IronPython/Runtime/WeakRef.cs b/Src/IronPython/Runtime/WeakRef.cs similarity index 100% rename from IronPython/Runtime/WeakRef.cs rename to Src/IronPython/Runtime/WeakRef.cs diff --git a/IronPython/Runtime/WrapperDescriptorAttribute.cs b/Src/IronPython/Runtime/WrapperDescriptorAttribute.cs similarity index 100% rename from IronPython/Runtime/WrapperDescriptorAttribute.cs rename to Src/IronPython/Runtime/WrapperDescriptorAttribute.cs diff --git a/IronPython/Runtime/WrapperDictionary.cs b/Src/IronPython/Runtime/WrapperDictionary.cs similarity index 100% rename from IronPython/Runtime/WrapperDictionary.cs rename to Src/IronPython/Runtime/WrapperDictionary.cs diff --git a/IronPython/Runtime/Zip.cs b/Src/IronPython/Runtime/Zip.cs similarity index 100% rename from IronPython/Runtime/Zip.cs rename to Src/IronPython/Runtime/Zip.cs diff --git a/IronPython/SerializationStubs.cs b/Src/IronPython/SerializationStubs.cs similarity index 100% rename from IronPython/SerializationStubs.cs rename to Src/IronPython/SerializationStubs.cs diff --git a/IronPython/StringExtensions.cs b/Src/IronPython/StringExtensions.cs similarity index 100% rename from IronPython/StringExtensions.cs rename to Src/IronPython/StringExtensions.cs diff --git a/IronPython/SystemRuntimeVersioning.cs b/Src/IronPython/SystemRuntimeVersioning.cs similarity index 100% rename from IronPython/SystemRuntimeVersioning.cs rename to Src/IronPython/SystemRuntimeVersioning.cs diff --git a/IronPython/policy.IronPython.config b/Src/IronPython/policy.IronPython.config similarity index 100% rename from IronPython/policy.IronPython.config rename to Src/IronPython/policy.IronPython.config diff --git a/Modules/IronPython.Modules.csproj b/Src/Modules/IronPython.Modules.csproj similarity index 89% rename from Modules/IronPython.Modules.csproj rename to Src/Modules/IronPython.Modules.csproj index 2463bf256..0f54dd0d0 100644 --- a/Modules/IronPython.Modules.csproj +++ b/Src/Modules/IronPython.Modules.csproj @@ -10,7 +10,7 @@ True - ..\Utils\References\Mono.Posix.dll + ..\..\Utils\References\Mono.Posix.dll @@ -26,7 +26,7 @@ - + false Analyzer diff --git a/Modules/IterTools.cs b/Src/Modules/IterTools.cs similarity index 100% rename from Modules/IterTools.cs rename to Src/Modules/IterTools.cs diff --git a/Modules/ModuleOps.cs b/Src/Modules/ModuleOps.cs similarity index 100% rename from Modules/ModuleOps.cs rename to Src/Modules/ModuleOps.cs diff --git a/Modules/NtSignalState.cs b/Src/Modules/NtSignalState.cs similarity index 100% rename from Modules/NtSignalState.cs rename to Src/Modules/NtSignalState.cs diff --git a/Modules/Properties/AssemblyInfo.cs b/Src/Modules/Properties/AssemblyInfo.cs similarity index 100% rename from Modules/Properties/AssemblyInfo.cs rename to Src/Modules/Properties/AssemblyInfo.cs diff --git a/Modules/ResourceMetaPathImporter.cs b/Src/Modules/ResourceMetaPathImporter.cs similarity index 100% rename from Modules/ResourceMetaPathImporter.cs rename to Src/Modules/ResourceMetaPathImporter.cs diff --git a/Modules/SimpleSignalState.cs b/Src/Modules/SimpleSignalState.cs similarity index 100% rename from Modules/SimpleSignalState.cs rename to Src/Modules/SimpleSignalState.cs diff --git a/Modules/_bisect.cs b/Src/Modules/_bisect.cs similarity index 100% rename from Modules/_bisect.cs rename to Src/Modules/_bisect.cs diff --git a/Modules/_codecs.cs b/Src/Modules/_codecs.cs similarity index 100% rename from Modules/_codecs.cs rename to Src/Modules/_codecs.cs diff --git a/Modules/_codecs_cn.cs b/Src/Modules/_codecs_cn.cs similarity index 100% rename from Modules/_codecs_cn.cs rename to Src/Modules/_codecs_cn.cs diff --git a/Modules/_collections.cs b/Src/Modules/_collections.cs similarity index 100% rename from Modules/_collections.cs rename to Src/Modules/_collections.cs diff --git a/Modules/_csv.cs b/Src/Modules/_csv.cs similarity index 100% rename from Modules/_csv.cs rename to Src/Modules/_csv.cs diff --git a/Modules/_ctypes/Array.cs b/Src/Modules/_ctypes/Array.cs similarity index 100% rename from Modules/_ctypes/Array.cs rename to Src/Modules/_ctypes/Array.cs diff --git a/Modules/_ctypes/ArrayType.cs b/Src/Modules/_ctypes/ArrayType.cs similarity index 100% rename from Modules/_ctypes/ArrayType.cs rename to Src/Modules/_ctypes/ArrayType.cs diff --git a/Modules/_ctypes/CData.cs b/Src/Modules/_ctypes/CData.cs similarity index 100% rename from Modules/_ctypes/CData.cs rename to Src/Modules/_ctypes/CData.cs diff --git a/Modules/_ctypes/CFuncPtr.cs b/Src/Modules/_ctypes/CFuncPtr.cs similarity index 100% rename from Modules/_ctypes/CFuncPtr.cs rename to Src/Modules/_ctypes/CFuncPtr.cs diff --git a/Modules/_ctypes/CFuncPtrType.cs b/Src/Modules/_ctypes/CFuncPtrType.cs similarity index 100% rename from Modules/_ctypes/CFuncPtrType.cs rename to Src/Modules/_ctypes/CFuncPtrType.cs diff --git a/Modules/_ctypes/Extensions.cs b/Src/Modules/_ctypes/Extensions.cs similarity index 100% rename from Modules/_ctypes/Extensions.cs rename to Src/Modules/_ctypes/Extensions.cs diff --git a/Modules/_ctypes/Field.cs b/Src/Modules/_ctypes/Field.cs similarity index 100% rename from Modules/_ctypes/Field.cs rename to Src/Modules/_ctypes/Field.cs diff --git a/Modules/_ctypes/INativeType.cs b/Src/Modules/_ctypes/INativeType.cs similarity index 100% rename from Modules/_ctypes/INativeType.cs rename to Src/Modules/_ctypes/INativeType.cs diff --git a/Modules/_ctypes/LocalOrArg.cs b/Src/Modules/_ctypes/LocalOrArg.cs similarity index 100% rename from Modules/_ctypes/LocalOrArg.cs rename to Src/Modules/_ctypes/LocalOrArg.cs diff --git a/Modules/_ctypes/MarshalCleanup.cs b/Src/Modules/_ctypes/MarshalCleanup.cs similarity index 100% rename from Modules/_ctypes/MarshalCleanup.cs rename to Src/Modules/_ctypes/MarshalCleanup.cs diff --git a/Modules/_ctypes/MemoryHolder.cs b/Src/Modules/_ctypes/MemoryHolder.cs similarity index 100% rename from Modules/_ctypes/MemoryHolder.cs rename to Src/Modules/_ctypes/MemoryHolder.cs diff --git a/Modules/_ctypes/NativeArgument.cs b/Src/Modules/_ctypes/NativeArgument.cs similarity index 100% rename from Modules/_ctypes/NativeArgument.cs rename to Src/Modules/_ctypes/NativeArgument.cs diff --git a/Modules/_ctypes/NativeFunctions.cs b/Src/Modules/_ctypes/NativeFunctions.cs similarity index 100% rename from Modules/_ctypes/NativeFunctions.cs rename to Src/Modules/_ctypes/NativeFunctions.cs diff --git a/Modules/_ctypes/Pointer.cs b/Src/Modules/_ctypes/Pointer.cs similarity index 100% rename from Modules/_ctypes/Pointer.cs rename to Src/Modules/_ctypes/Pointer.cs diff --git a/Modules/_ctypes/PointerType.cs b/Src/Modules/_ctypes/PointerType.cs similarity index 100% rename from Modules/_ctypes/PointerType.cs rename to Src/Modules/_ctypes/PointerType.cs diff --git a/Modules/_ctypes/SimpleCData.cs b/Src/Modules/_ctypes/SimpleCData.cs similarity index 100% rename from Modules/_ctypes/SimpleCData.cs rename to Src/Modules/_ctypes/SimpleCData.cs diff --git a/Modules/_ctypes/SimpleType.cs b/Src/Modules/_ctypes/SimpleType.cs similarity index 100% rename from Modules/_ctypes/SimpleType.cs rename to Src/Modules/_ctypes/SimpleType.cs diff --git a/Modules/_ctypes/SimpleTypeKind.cs b/Src/Modules/_ctypes/SimpleTypeKind.cs similarity index 100% rename from Modules/_ctypes/SimpleTypeKind.cs rename to Src/Modules/_ctypes/SimpleTypeKind.cs diff --git a/Modules/_ctypes/StructType.cs b/Src/Modules/_ctypes/StructType.cs similarity index 100% rename from Modules/_ctypes/StructType.cs rename to Src/Modules/_ctypes/StructType.cs diff --git a/Modules/_ctypes/Structure.cs b/Src/Modules/_ctypes/Structure.cs similarity index 100% rename from Modules/_ctypes/Structure.cs rename to Src/Modules/_ctypes/Structure.cs diff --git a/Modules/_ctypes/Union.cs b/Src/Modules/_ctypes/Union.cs similarity index 100% rename from Modules/_ctypes/Union.cs rename to Src/Modules/_ctypes/Union.cs diff --git a/Modules/_ctypes/UnionType.cs b/Src/Modules/_ctypes/UnionType.cs similarity index 100% rename from Modules/_ctypes/UnionType.cs rename to Src/Modules/_ctypes/UnionType.cs diff --git a/Modules/_ctypes/_ctypes.cs b/Src/Modules/_ctypes/_ctypes.cs similarity index 100% rename from Modules/_ctypes/_ctypes.cs rename to Src/Modules/_ctypes/_ctypes.cs diff --git a/Modules/_ctypes_test.cs b/Src/Modules/_ctypes_test.cs similarity index 100% rename from Modules/_ctypes_test.cs rename to Src/Modules/_ctypes_test.cs diff --git a/Modules/_datetime.cs b/Src/Modules/_datetime.cs similarity index 100% rename from Modules/_datetime.cs rename to Src/Modules/_datetime.cs diff --git a/Modules/_functools.cs b/Src/Modules/_functools.cs similarity index 100% rename from Modules/_functools.cs rename to Src/Modules/_functools.cs diff --git a/Modules/_heapq.cs b/Src/Modules/_heapq.cs similarity index 100% rename from Modules/_heapq.cs rename to Src/Modules/_heapq.cs diff --git a/Modules/_multibytecodec.cs b/Src/Modules/_multibytecodec.cs similarity index 100% rename from Modules/_multibytecodec.cs rename to Src/Modules/_multibytecodec.cs diff --git a/Modules/_multiprocessing.cs b/Src/Modules/_multiprocessing.cs similarity index 100% rename from Modules/_multiprocessing.cs rename to Src/Modules/_multiprocessing.cs diff --git a/Modules/_opcode.cs b/Src/Modules/_opcode.cs similarity index 100% rename from Modules/_opcode.cs rename to Src/Modules/_opcode.cs diff --git a/Modules/_operator.cs b/Src/Modules/_operator.cs similarity index 100% rename from Modules/_operator.cs rename to Src/Modules/_operator.cs diff --git a/Modules/_overlapped.cs b/Src/Modules/_overlapped.cs similarity index 100% rename from Modules/_overlapped.cs rename to Src/Modules/_overlapped.cs diff --git a/Modules/_pickle.cs b/Src/Modules/_pickle.cs similarity index 100% rename from Modules/_pickle.cs rename to Src/Modules/_pickle.cs diff --git a/Modules/_posixsubprocess.cs b/Src/Modules/_posixsubprocess.cs similarity index 100% rename from Modules/_posixsubprocess.cs rename to Src/Modules/_posixsubprocess.cs diff --git a/Modules/_random.RandomGen.cs b/Src/Modules/_random.RandomGen.cs similarity index 100% rename from Modules/_random.RandomGen.cs rename to Src/Modules/_random.RandomGen.cs diff --git a/Modules/_random.cs b/Src/Modules/_random.cs similarity index 100% rename from Modules/_random.cs rename to Src/Modules/_random.cs diff --git a/Modules/_socket.cs b/Src/Modules/_socket.cs similarity index 100% rename from Modules/_socket.cs rename to Src/Modules/_socket.cs diff --git a/Modules/_sre.cs b/Src/Modules/_sre.cs similarity index 100% rename from Modules/_sre.cs rename to Src/Modules/_sre.cs diff --git a/Modules/_ssl.cs b/Src/Modules/_ssl.cs similarity index 100% rename from Modules/_ssl.cs rename to Src/Modules/_ssl.cs diff --git a/Modules/_string.cs b/Src/Modules/_string.cs similarity index 100% rename from Modules/_string.cs rename to Src/Modules/_string.cs diff --git a/Modules/_struct.cs b/Src/Modules/_struct.cs similarity index 100% rename from Modules/_struct.cs rename to Src/Modules/_struct.cs diff --git a/Modules/_sysconfigdata.cs b/Src/Modules/_sysconfigdata.cs similarity index 100% rename from Modules/_sysconfigdata.cs rename to Src/Modules/_sysconfigdata.cs diff --git a/Modules/_thread.cs b/Src/Modules/_thread.cs similarity index 100% rename from Modules/_thread.cs rename to Src/Modules/_thread.cs diff --git a/Modules/_warnings.cs b/Src/Modules/_warnings.cs similarity index 100% rename from Modules/_warnings.cs rename to Src/Modules/_warnings.cs diff --git a/Modules/_weakref.Generated.cs b/Src/Modules/_weakref.Generated.cs similarity index 100% rename from Modules/_weakref.Generated.cs rename to Src/Modules/_weakref.Generated.cs diff --git a/Modules/_weakref.cs b/Src/Modules/_weakref.cs similarity index 100% rename from Modules/_weakref.cs rename to Src/Modules/_weakref.cs diff --git a/Modules/_winapi.cs b/Src/Modules/_winapi.cs similarity index 100% rename from Modules/_winapi.cs rename to Src/Modules/_winapi.cs diff --git a/Modules/array.cs b/Src/Modules/array.cs similarity index 100% rename from Modules/array.cs rename to Src/Modules/array.cs diff --git a/Modules/atexit.cs b/Src/Modules/atexit.cs similarity index 100% rename from Modules/atexit.cs rename to Src/Modules/atexit.cs diff --git a/Modules/audioop.cs b/Src/Modules/audioop.cs similarity index 100% rename from Modules/audioop.cs rename to Src/Modules/audioop.cs diff --git a/Modules/binascii.cs b/Src/Modules/binascii.cs similarity index 100% rename from Modules/binascii.cs rename to Src/Modules/binascii.cs diff --git a/Modules/bz2/BZ2Compressor.cs b/Src/Modules/bz2/BZ2Compressor.cs similarity index 100% rename from Modules/bz2/BZ2Compressor.cs rename to Src/Modules/bz2/BZ2Compressor.cs diff --git a/Modules/bz2/BZ2Decompressor.cs b/Src/Modules/bz2/BZ2Decompressor.cs similarity index 100% rename from Modules/bz2/BZ2Decompressor.cs rename to Src/Modules/bz2/BZ2Decompressor.cs diff --git a/Modules/bz2/BZ2Module.cs b/Src/Modules/bz2/BZ2Module.cs similarity index 100% rename from Modules/bz2/BZ2Module.cs rename to Src/Modules/bz2/BZ2Module.cs diff --git a/Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs b/Src/Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs similarity index 100% rename from Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs rename to Src/Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs diff --git a/Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs b/Src/Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs similarity index 100% rename from Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs rename to Src/Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs diff --git a/Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs b/Src/Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs similarity index 100% rename from Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs rename to Src/Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs diff --git a/Modules/bz2/dotnetzip/BZip2/BitWriter.cs b/Src/Modules/bz2/dotnetzip/BZip2/BitWriter.cs similarity index 100% rename from Modules/bz2/dotnetzip/BZip2/BitWriter.cs rename to Src/Modules/bz2/dotnetzip/BZip2/BitWriter.cs diff --git a/Modules/bz2/dotnetzip/BZip2/CRC32.cs b/Src/Modules/bz2/dotnetzip/BZip2/CRC32.cs similarity index 100% rename from Modules/bz2/dotnetzip/BZip2/CRC32.cs rename to Src/Modules/bz2/dotnetzip/BZip2/CRC32.cs diff --git a/Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs b/Src/Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs similarity index 100% rename from Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs rename to Src/Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs diff --git a/Modules/bz2/dotnetzip/BZip2/Rand.cs b/Src/Modules/bz2/dotnetzip/BZip2/Rand.cs similarity index 100% rename from Modules/bz2/dotnetzip/BZip2/Rand.cs rename to Src/Modules/bz2/dotnetzip/BZip2/Rand.cs diff --git a/Modules/bz2/dotnetzip/source.txt b/Src/Modules/bz2/dotnetzip/source.txt similarity index 100% rename from Modules/bz2/dotnetzip/source.txt rename to Src/Modules/bz2/dotnetzip/source.txt diff --git a/Modules/cmath.cs b/Src/Modules/cmath.cs similarity index 100% rename from Modules/cmath.cs rename to Src/Modules/cmath.cs diff --git a/Modules/errno.cs b/Src/Modules/errno.cs similarity index 100% rename from Modules/errno.cs rename to Src/Modules/errno.cs diff --git a/Modules/faulthandler.cs b/Src/Modules/faulthandler.cs similarity index 100% rename from Modules/faulthandler.cs rename to Src/Modules/faulthandler.cs diff --git a/Modules/fcntl.cs b/Src/Modules/fcntl.cs similarity index 100% rename from Modules/fcntl.cs rename to Src/Modules/fcntl.cs diff --git a/Modules/gc.cs b/Src/Modules/gc.cs similarity index 100% rename from Modules/gc.cs rename to Src/Modules/gc.cs diff --git a/Modules/grp.cs b/Src/Modules/grp.cs similarity index 100% rename from Modules/grp.cs rename to Src/Modules/grp.cs diff --git a/Modules/hashlib/MD5CryptoServiceProvider.cs b/Src/Modules/hashlib/MD5CryptoServiceProvider.cs similarity index 100% rename from Modules/hashlib/MD5CryptoServiceProvider.cs rename to Src/Modules/hashlib/MD5CryptoServiceProvider.cs diff --git a/Modules/hashlib/SHA1CryptoServiceProvider.cs b/Src/Modules/hashlib/SHA1CryptoServiceProvider.cs similarity index 100% rename from Modules/hashlib/SHA1CryptoServiceProvider.cs rename to Src/Modules/hashlib/SHA1CryptoServiceProvider.cs diff --git a/Modules/hashlib/SHA224.cs b/Src/Modules/hashlib/SHA224.cs similarity index 100% rename from Modules/hashlib/SHA224.cs rename to Src/Modules/hashlib/SHA224.cs diff --git a/Modules/hashlib/SHA224Managed.cs b/Src/Modules/hashlib/SHA224Managed.cs similarity index 100% rename from Modules/hashlib/SHA224Managed.cs rename to Src/Modules/hashlib/SHA224Managed.cs diff --git a/Modules/hashlib/SHA256Managed.cs b/Src/Modules/hashlib/SHA256Managed.cs similarity index 100% rename from Modules/hashlib/SHA256Managed.cs rename to Src/Modules/hashlib/SHA256Managed.cs diff --git a/Modules/hashlib/SHA384Managed.cs b/Src/Modules/hashlib/SHA384Managed.cs similarity index 100% rename from Modules/hashlib/SHA384Managed.cs rename to Src/Modules/hashlib/SHA384Managed.cs diff --git a/Modules/hashlib/SHA512Managed.cs b/Src/Modules/hashlib/SHA512Managed.cs similarity index 100% rename from Modules/hashlib/SHA512Managed.cs rename to Src/Modules/hashlib/SHA512Managed.cs diff --git a/Modules/hashlib/SHAConstants.cs b/Src/Modules/hashlib/SHAConstants.cs similarity index 100% rename from Modules/hashlib/SHAConstants.cs rename to Src/Modules/hashlib/SHAConstants.cs diff --git a/Modules/hashlib/_hashlib.cs b/Src/Modules/hashlib/_hashlib.cs similarity index 100% rename from Modules/hashlib/_hashlib.cs rename to Src/Modules/hashlib/_hashlib.cs diff --git a/Modules/hashlib/_md5.cs b/Src/Modules/hashlib/_md5.cs similarity index 100% rename from Modules/hashlib/_md5.cs rename to Src/Modules/hashlib/_md5.cs diff --git a/Modules/hashlib/_sha1.cs b/Src/Modules/hashlib/_sha1.cs similarity index 100% rename from Modules/hashlib/_sha1.cs rename to Src/Modules/hashlib/_sha1.cs diff --git a/Modules/hashlib/_sha256.cs b/Src/Modules/hashlib/_sha256.cs similarity index 100% rename from Modules/hashlib/_sha256.cs rename to Src/Modules/hashlib/_sha256.cs diff --git a/Modules/hashlib/_sha512.cs b/Src/Modules/hashlib/_sha512.cs similarity index 100% rename from Modules/hashlib/_sha512.cs rename to Src/Modules/hashlib/_sha512.cs diff --git a/Modules/marshal.cs b/Src/Modules/marshal.cs similarity index 100% rename from Modules/marshal.cs rename to Src/Modules/marshal.cs diff --git a/Modules/math.Generated.cs b/Src/Modules/math.Generated.cs similarity index 100% rename from Modules/math.Generated.cs rename to Src/Modules/math.Generated.cs diff --git a/Modules/math.cs b/Src/Modules/math.cs similarity index 100% rename from Modules/math.cs rename to Src/Modules/math.cs diff --git a/Modules/mmap.cs b/Src/Modules/mmap.cs similarity index 100% rename from Modules/mmap.cs rename to Src/Modules/mmap.cs diff --git a/Modules/msvcrt.cs b/Src/Modules/msvcrt.cs similarity index 100% rename from Modules/msvcrt.cs rename to Src/Modules/msvcrt.cs diff --git a/Modules/nt.cs b/Src/Modules/nt.cs similarity index 100% rename from Modules/nt.cs rename to Src/Modules/nt.cs diff --git a/Modules/policy.IronPython.Modules.config b/Src/Modules/policy.IronPython.Modules.config similarity index 100% rename from Modules/policy.IronPython.Modules.config rename to Src/Modules/policy.IronPython.Modules.config diff --git a/Modules/pwd.cs b/Src/Modules/pwd.cs similarity index 100% rename from Modules/pwd.cs rename to Src/Modules/pwd.cs diff --git a/Modules/pyexpat.cs b/Src/Modules/pyexpat.cs similarity index 100% rename from Modules/pyexpat.cs rename to Src/Modules/pyexpat.cs diff --git a/Modules/re.cs b/Src/Modules/re.cs similarity index 100% rename from Modules/re.cs rename to Src/Modules/re.cs diff --git a/Modules/resource.cs b/Src/Modules/resource.cs similarity index 100% rename from Modules/resource.cs rename to Src/Modules/resource.cs diff --git a/Modules/select.cs b/Src/Modules/select.cs similarity index 100% rename from Modules/select.cs rename to Src/Modules/select.cs diff --git a/Modules/signal.cs b/Src/Modules/signal.cs similarity index 100% rename from Modules/signal.cs rename to Src/Modules/signal.cs diff --git a/Modules/spwd.cs b/Src/Modules/spwd.cs similarity index 100% rename from Modules/spwd.cs rename to Src/Modules/spwd.cs diff --git a/Modules/time.cs b/Src/Modules/time.cs similarity index 100% rename from Modules/time.cs rename to Src/Modules/time.cs diff --git a/Modules/winreg.cs b/Src/Modules/winreg.cs similarity index 100% rename from Modules/winreg.cs rename to Src/Modules/winreg.cs diff --git a/Modules/winsound.cs b/Src/Modules/winsound.cs similarity index 100% rename from Modules/winsound.cs rename to Src/Modules/winsound.cs diff --git a/Modules/xxsubtype.cs b/Src/Modules/xxsubtype.cs similarity index 100% rename from Modules/xxsubtype.cs rename to Src/Modules/xxsubtype.cs diff --git a/Modules/zipimport.cs b/Src/Modules/zipimport.cs similarity index 100% rename from Modules/zipimport.cs rename to Src/Modules/zipimport.cs diff --git a/Modules/zlib/Compress.cs b/Src/Modules/zlib/Compress.cs similarity index 100% rename from Modules/zlib/Compress.cs rename to Src/Modules/zlib/Compress.cs diff --git a/Modules/zlib/Decompress.cs b/Src/Modules/zlib/Decompress.cs similarity index 100% rename from Modules/zlib/Decompress.cs rename to Src/Modules/zlib/Decompress.cs diff --git a/Modules/zlib/ZlibModule.cs b/Src/Modules/zlib/ZlibModule.cs similarity index 100% rename from Modules/zlib/ZlibModule.cs rename to Src/Modules/zlib/ZlibModule.cs diff --git a/Modules/zlib/zlib.net/Adler32.cs b/Src/Modules/zlib/zlib.net/Adler32.cs similarity index 100% rename from Modules/zlib/zlib.net/Adler32.cs rename to Src/Modules/zlib/zlib.net/Adler32.cs diff --git a/Modules/zlib/zlib.net/Deflate.cs b/Src/Modules/zlib/zlib.net/Deflate.cs similarity index 100% rename from Modules/zlib/zlib.net/Deflate.cs rename to Src/Modules/zlib/zlib.net/Deflate.cs diff --git a/Modules/zlib/zlib.net/InfBlocks.cs b/Src/Modules/zlib/zlib.net/InfBlocks.cs similarity index 100% rename from Modules/zlib/zlib.net/InfBlocks.cs rename to Src/Modules/zlib/zlib.net/InfBlocks.cs diff --git a/Modules/zlib/zlib.net/InfCodes.cs b/Src/Modules/zlib/zlib.net/InfCodes.cs similarity index 100% rename from Modules/zlib/zlib.net/InfCodes.cs rename to Src/Modules/zlib/zlib.net/InfCodes.cs diff --git a/Modules/zlib/zlib.net/InfTree.cs b/Src/Modules/zlib/zlib.net/InfTree.cs similarity index 100% rename from Modules/zlib/zlib.net/InfTree.cs rename to Src/Modules/zlib/zlib.net/InfTree.cs diff --git a/Modules/zlib/zlib.net/Inflate.cs b/Src/Modules/zlib/zlib.net/Inflate.cs similarity index 100% rename from Modules/zlib/zlib.net/Inflate.cs rename to Src/Modules/zlib/zlib.net/Inflate.cs diff --git a/Modules/zlib/zlib.net/StaticTree.cs b/Src/Modules/zlib/zlib.net/StaticTree.cs similarity index 100% rename from Modules/zlib/zlib.net/StaticTree.cs rename to Src/Modules/zlib/zlib.net/StaticTree.cs diff --git a/Modules/zlib/zlib.net/Tree.cs b/Src/Modules/zlib/zlib.net/Tree.cs similarity index 100% rename from Modules/zlib/zlib.net/Tree.cs rename to Src/Modules/zlib/zlib.net/Tree.cs diff --git a/Modules/zlib/zlib.net/ZStream.cs b/Src/Modules/zlib/zlib.net/ZStream.cs similarity index 100% rename from Modules/zlib/zlib.net/ZStream.cs rename to Src/Modules/zlib/zlib.net/ZStream.cs diff --git a/Modules/zlib/zlib.net/ZStreamException.cs b/Src/Modules/zlib/zlib.net/ZStreamException.cs similarity index 100% rename from Modules/zlib/zlib.net/ZStreamException.cs rename to Src/Modules/zlib/zlib.net/ZStreamException.cs diff --git a/Modules/zlib/zlib.net/Zlib.cs b/Src/Modules/zlib/zlib.net/Zlib.cs similarity index 100% rename from Modules/zlib/zlib.net/Zlib.cs rename to Src/Modules/zlib/zlib.net/Zlib.cs diff --git a/Modules/zlib/zlib.net/history.txt b/Src/Modules/zlib/zlib.net/history.txt similarity index 100% rename from Modules/zlib/zlib.net/history.txt rename to Src/Modules/zlib/zlib.net/history.txt diff --git a/Modules/zlib/zlib.net/license.txt b/Src/Modules/zlib/zlib.net/license.txt similarity index 100% rename from Modules/zlib/zlib.net/license.txt rename to Src/Modules/zlib/zlib.net/license.txt diff --git a/Modules/zlib/zlib.net/readme.txt b/Src/Modules/zlib/zlib.net/readme.txt similarity index 100% rename from Modules/zlib/zlib.net/readme.txt rename to Src/Modules/zlib/zlib.net/readme.txt diff --git a/IronPython/README.md b/Src/README.md similarity index 100% rename from IronPython/README.md rename to Src/README.md diff --git a/SQLite/Connection.cs b/Src/SQLite/Connection.cs similarity index 100% rename from SQLite/Connection.cs rename to Src/SQLite/Connection.cs diff --git a/SQLite/Contants.cs b/Src/SQLite/Contants.cs similarity index 100% rename from SQLite/Contants.cs rename to Src/SQLite/Contants.cs diff --git a/SQLite/Cursor.cs b/Src/SQLite/Cursor.cs similarity index 100% rename from SQLite/Cursor.cs rename to Src/SQLite/Cursor.cs diff --git a/SQLite/Exceptions.cs b/Src/SQLite/Exceptions.cs similarity index 100% rename from SQLite/Exceptions.cs rename to Src/SQLite/Exceptions.cs diff --git a/SQLite/Extensions.cs b/Src/SQLite/Extensions.cs similarity index 100% rename from SQLite/Extensions.cs rename to Src/SQLite/Extensions.cs diff --git a/SQLite/IronPython.SQLite.csproj b/Src/SQLite/IronPython.SQLite.csproj similarity index 100% rename from SQLite/IronPython.SQLite.csproj rename to Src/SQLite/IronPython.SQLite.csproj diff --git a/SQLite/Properties/AssemblyInfo.cs b/Src/SQLite/Properties/AssemblyInfo.cs similarity index 100% rename from SQLite/Properties/AssemblyInfo.cs rename to Src/SQLite/Properties/AssemblyInfo.cs diff --git a/SQLite/Row.cs b/Src/SQLite/Row.cs similarity index 100% rename from SQLite/Row.cs rename to Src/SQLite/Row.cs diff --git a/SQLite/Statement.cs b/Src/SQLite/Statement.cs similarity index 100% rename from SQLite/Statement.cs rename to Src/SQLite/Statement.cs diff --git a/SQLite/Util.cs b/Src/SQLite/Util.cs similarity index 100% rename from SQLite/Util.cs rename to Src/SQLite/Util.cs diff --git a/SQLite/_sqlite.cs b/Src/SQLite/_sqlite.cs similarity index 100% rename from SQLite/_sqlite.cs rename to Src/SQLite/_sqlite.cs diff --git a/SQLite/c#sqlite/.editorconfig b/Src/SQLite/c#sqlite/.editorconfig similarity index 100% rename from SQLite/c#sqlite/.editorconfig rename to Src/SQLite/c#sqlite/.editorconfig diff --git a/SQLite/c#sqlite/BtreeInt_h.cs b/Src/SQLite/c#sqlite/BtreeInt_h.cs similarity index 100% rename from SQLite/c#sqlite/BtreeInt_h.cs rename to Src/SQLite/c#sqlite/BtreeInt_h.cs diff --git a/SQLite/c#sqlite/Btree_h.cs b/Src/SQLite/c#sqlite/Btree_h.cs similarity index 100% rename from SQLite/c#sqlite/Btree_h.cs rename to Src/SQLite/c#sqlite/Btree_h.cs diff --git a/SQLite/c#sqlite/Delegates.cs b/Src/SQLite/c#sqlite/Delegates.cs similarity index 100% rename from SQLite/c#sqlite/Delegates.cs rename to Src/SQLite/c#sqlite/Delegates.cs diff --git a/SQLite/c#sqlite/Hash_h.cs b/Src/SQLite/c#sqlite/Hash_h.cs similarity index 100% rename from SQLite/c#sqlite/Hash_h.cs rename to Src/SQLite/c#sqlite/Hash_h.cs diff --git a/SQLite/c#sqlite/VdbeInt_h.cs b/Src/SQLite/c#sqlite/VdbeInt_h.cs similarity index 100% rename from SQLite/c#sqlite/VdbeInt_h.cs rename to Src/SQLite/c#sqlite/VdbeInt_h.cs diff --git a/SQLite/c#sqlite/Vdbe_h.cs b/Src/SQLite/c#sqlite/Vdbe_h.cs similarity index 100% rename from SQLite/c#sqlite/Vdbe_h.cs rename to Src/SQLite/c#sqlite/Vdbe_h.cs diff --git a/SQLite/c#sqlite/_Custom.cs b/Src/SQLite/c#sqlite/_Custom.cs similarity index 100% rename from SQLite/c#sqlite/_Custom.cs rename to Src/SQLite/c#sqlite/_Custom.cs diff --git a/SQLite/c#sqlite/alter_c.cs b/Src/SQLite/c#sqlite/alter_c.cs similarity index 100% rename from SQLite/c#sqlite/alter_c.cs rename to Src/SQLite/c#sqlite/alter_c.cs diff --git a/SQLite/c#sqlite/analyze_c.cs b/Src/SQLite/c#sqlite/analyze_c.cs similarity index 100% rename from SQLite/c#sqlite/analyze_c.cs rename to Src/SQLite/c#sqlite/analyze_c.cs diff --git a/SQLite/c#sqlite/attach_c.cs b/Src/SQLite/c#sqlite/attach_c.cs similarity index 100% rename from SQLite/c#sqlite/attach_c.cs rename to Src/SQLite/c#sqlite/attach_c.cs diff --git a/SQLite/c#sqlite/auth_c.cs b/Src/SQLite/c#sqlite/auth_c.cs similarity index 100% rename from SQLite/c#sqlite/auth_c.cs rename to Src/SQLite/c#sqlite/auth_c.cs diff --git a/SQLite/c#sqlite/backup_c.cs b/Src/SQLite/c#sqlite/backup_c.cs similarity index 100% rename from SQLite/c#sqlite/backup_c.cs rename to Src/SQLite/c#sqlite/backup_c.cs diff --git a/SQLite/c#sqlite/bitvec_c.cs b/Src/SQLite/c#sqlite/bitvec_c.cs similarity index 100% rename from SQLite/c#sqlite/bitvec_c.cs rename to Src/SQLite/c#sqlite/bitvec_c.cs diff --git a/SQLite/c#sqlite/btmutex_c.cs b/Src/SQLite/c#sqlite/btmutex_c.cs similarity index 100% rename from SQLite/c#sqlite/btmutex_c.cs rename to Src/SQLite/c#sqlite/btmutex_c.cs diff --git a/SQLite/c#sqlite/btree_c.cs b/Src/SQLite/c#sqlite/btree_c.cs similarity index 100% rename from SQLite/c#sqlite/btree_c.cs rename to Src/SQLite/c#sqlite/btree_c.cs diff --git a/SQLite/c#sqlite/build_c.cs b/Src/SQLite/c#sqlite/build_c.cs similarity index 100% rename from SQLite/c#sqlite/build_c.cs rename to Src/SQLite/c#sqlite/build_c.cs diff --git a/SQLite/c#sqlite/callback_c.cs b/Src/SQLite/c#sqlite/callback_c.cs similarity index 100% rename from SQLite/c#sqlite/callback_c.cs rename to Src/SQLite/c#sqlite/callback_c.cs diff --git a/SQLite/c#sqlite/complete_c.cs b/Src/SQLite/c#sqlite/complete_c.cs similarity index 100% rename from SQLite/c#sqlite/complete_c.cs rename to Src/SQLite/c#sqlite/complete_c.cs diff --git a/SQLite/c#sqlite/crypto.cs b/Src/SQLite/c#sqlite/crypto.cs similarity index 100% rename from SQLite/c#sqlite/crypto.cs rename to Src/SQLite/c#sqlite/crypto.cs diff --git a/SQLite/c#sqlite/ctime_c.cs b/Src/SQLite/c#sqlite/ctime_c.cs similarity index 100% rename from SQLite/c#sqlite/ctime_c.cs rename to Src/SQLite/c#sqlite/ctime_c.cs diff --git a/SQLite/c#sqlite/date_c.cs b/Src/SQLite/c#sqlite/date_c.cs similarity index 100% rename from SQLite/c#sqlite/date_c.cs rename to Src/SQLite/c#sqlite/date_c.cs diff --git a/SQLite/c#sqlite/delete_c.cs b/Src/SQLite/c#sqlite/delete_c.cs similarity index 100% rename from SQLite/c#sqlite/delete_c.cs rename to Src/SQLite/c#sqlite/delete_c.cs diff --git a/SQLite/c#sqlite/expr_c.cs b/Src/SQLite/c#sqlite/expr_c.cs similarity index 100% rename from SQLite/c#sqlite/expr_c.cs rename to Src/SQLite/c#sqlite/expr_c.cs diff --git a/SQLite/c#sqlite/fault_c.cs b/Src/SQLite/c#sqlite/fault_c.cs similarity index 100% rename from SQLite/c#sqlite/fault_c.cs rename to Src/SQLite/c#sqlite/fault_c.cs diff --git a/SQLite/c#sqlite/fkey_c.cs b/Src/SQLite/c#sqlite/fkey_c.cs similarity index 100% rename from SQLite/c#sqlite/fkey_c.cs rename to Src/SQLite/c#sqlite/fkey_c.cs diff --git a/SQLite/c#sqlite/func_c.cs b/Src/SQLite/c#sqlite/func_c.cs similarity index 100% rename from SQLite/c#sqlite/func_c.cs rename to Src/SQLite/c#sqlite/func_c.cs diff --git a/SQLite/c#sqlite/global_c.cs b/Src/SQLite/c#sqlite/global_c.cs similarity index 100% rename from SQLite/c#sqlite/global_c.cs rename to Src/SQLite/c#sqlite/global_c.cs diff --git a/SQLite/c#sqlite/hash_c.cs b/Src/SQLite/c#sqlite/hash_c.cs similarity index 100% rename from SQLite/c#sqlite/hash_c.cs rename to Src/SQLite/c#sqlite/hash_c.cs diff --git a/SQLite/c#sqlite/hwtime_c.cs b/Src/SQLite/c#sqlite/hwtime_c.cs similarity index 100% rename from SQLite/c#sqlite/hwtime_c.cs rename to Src/SQLite/c#sqlite/hwtime_c.cs diff --git a/SQLite/c#sqlite/insert_c.cs b/Src/SQLite/c#sqlite/insert_c.cs similarity index 100% rename from SQLite/c#sqlite/insert_c.cs rename to Src/SQLite/c#sqlite/insert_c.cs diff --git a/SQLite/c#sqlite/journal_c.cs b/Src/SQLite/c#sqlite/journal_c.cs similarity index 100% rename from SQLite/c#sqlite/journal_c.cs rename to Src/SQLite/c#sqlite/journal_c.cs diff --git a/SQLite/c#sqlite/keywordhash_h.cs b/Src/SQLite/c#sqlite/keywordhash_h.cs similarity index 100% rename from SQLite/c#sqlite/keywordhash_h.cs rename to Src/SQLite/c#sqlite/keywordhash_h.cs diff --git a/SQLite/c#sqlite/legacy_c.cs b/Src/SQLite/c#sqlite/legacy_c.cs similarity index 100% rename from SQLite/c#sqlite/legacy_c.cs rename to Src/SQLite/c#sqlite/legacy_c.cs diff --git a/SQLite/c#sqlite/loadext_c.cs b/Src/SQLite/c#sqlite/loadext_c.cs similarity index 100% rename from SQLite/c#sqlite/loadext_c.cs rename to Src/SQLite/c#sqlite/loadext_c.cs diff --git a/SQLite/c#sqlite/main_c.cs b/Src/SQLite/c#sqlite/main_c.cs similarity index 100% rename from SQLite/c#sqlite/main_c.cs rename to Src/SQLite/c#sqlite/main_c.cs diff --git a/SQLite/c#sqlite/malloc_c.cs b/Src/SQLite/c#sqlite/malloc_c.cs similarity index 100% rename from SQLite/c#sqlite/malloc_c.cs rename to Src/SQLite/c#sqlite/malloc_c.cs diff --git a/SQLite/c#sqlite/mem_Pool.cs b/Src/SQLite/c#sqlite/mem_Pool.cs similarity index 100% rename from SQLite/c#sqlite/mem_Pool.cs rename to Src/SQLite/c#sqlite/mem_Pool.cs diff --git a/SQLite/c#sqlite/memjournal_c.cs b/Src/SQLite/c#sqlite/memjournal_c.cs similarity index 100% rename from SQLite/c#sqlite/memjournal_c.cs rename to Src/SQLite/c#sqlite/memjournal_c.cs diff --git a/SQLite/c#sqlite/mutex_c.cs b/Src/SQLite/c#sqlite/mutex_c.cs similarity index 100% rename from SQLite/c#sqlite/mutex_c.cs rename to Src/SQLite/c#sqlite/mutex_c.cs diff --git a/SQLite/c#sqlite/mutex_h.cs b/Src/SQLite/c#sqlite/mutex_h.cs similarity index 100% rename from SQLite/c#sqlite/mutex_h.cs rename to Src/SQLite/c#sqlite/mutex_h.cs diff --git a/SQLite/c#sqlite/mutex_noop_c.cs b/Src/SQLite/c#sqlite/mutex_noop_c.cs similarity index 100% rename from SQLite/c#sqlite/mutex_noop_c.cs rename to Src/SQLite/c#sqlite/mutex_noop_c.cs diff --git a/SQLite/c#sqlite/mutex_w32.cs b/Src/SQLite/c#sqlite/mutex_w32.cs similarity index 100% rename from SQLite/c#sqlite/mutex_w32.cs rename to Src/SQLite/c#sqlite/mutex_w32.cs diff --git a/SQLite/c#sqlite/notify_c.cs b/Src/SQLite/c#sqlite/notify_c.cs similarity index 100% rename from SQLite/c#sqlite/notify_c.cs rename to Src/SQLite/c#sqlite/notify_c.cs diff --git a/SQLite/c#sqlite/opcodes_c.cs b/Src/SQLite/c#sqlite/opcodes_c.cs similarity index 100% rename from SQLite/c#sqlite/opcodes_c.cs rename to Src/SQLite/c#sqlite/opcodes_c.cs diff --git a/SQLite/c#sqlite/opcodes_h.cs b/Src/SQLite/c#sqlite/opcodes_h.cs similarity index 100% rename from SQLite/c#sqlite/opcodes_h.cs rename to Src/SQLite/c#sqlite/opcodes_h.cs diff --git a/SQLite/c#sqlite/os_c.cs b/Src/SQLite/c#sqlite/os_c.cs similarity index 100% rename from SQLite/c#sqlite/os_c.cs rename to Src/SQLite/c#sqlite/os_c.cs diff --git a/SQLite/c#sqlite/os_common_h.cs b/Src/SQLite/c#sqlite/os_common_h.cs similarity index 100% rename from SQLite/c#sqlite/os_common_h.cs rename to Src/SQLite/c#sqlite/os_common_h.cs diff --git a/SQLite/c#sqlite/os_h.cs b/Src/SQLite/c#sqlite/os_h.cs similarity index 100% rename from SQLite/c#sqlite/os_h.cs rename to Src/SQLite/c#sqlite/os_h.cs diff --git a/SQLite/c#sqlite/os_win_c.cs b/Src/SQLite/c#sqlite/os_win_c.cs similarity index 100% rename from SQLite/c#sqlite/os_win_c.cs rename to Src/SQLite/c#sqlite/os_win_c.cs diff --git a/SQLite/c#sqlite/pager_c.cs b/Src/SQLite/c#sqlite/pager_c.cs similarity index 100% rename from SQLite/c#sqlite/pager_c.cs rename to Src/SQLite/c#sqlite/pager_c.cs diff --git a/SQLite/c#sqlite/pager_h.cs b/Src/SQLite/c#sqlite/pager_h.cs similarity index 100% rename from SQLite/c#sqlite/pager_h.cs rename to Src/SQLite/c#sqlite/pager_h.cs diff --git a/SQLite/c#sqlite/parse_c.cs b/Src/SQLite/c#sqlite/parse_c.cs similarity index 100% rename from SQLite/c#sqlite/parse_c.cs rename to Src/SQLite/c#sqlite/parse_c.cs diff --git a/SQLite/c#sqlite/parse_h.cs b/Src/SQLite/c#sqlite/parse_h.cs similarity index 100% rename from SQLite/c#sqlite/parse_h.cs rename to Src/SQLite/c#sqlite/parse_h.cs diff --git a/SQLite/c#sqlite/pcache1_c.cs b/Src/SQLite/c#sqlite/pcache1_c.cs similarity index 100% rename from SQLite/c#sqlite/pcache1_c.cs rename to Src/SQLite/c#sqlite/pcache1_c.cs diff --git a/SQLite/c#sqlite/pcache_c.cs b/Src/SQLite/c#sqlite/pcache_c.cs similarity index 100% rename from SQLite/c#sqlite/pcache_c.cs rename to Src/SQLite/c#sqlite/pcache_c.cs diff --git a/SQLite/c#sqlite/pcache_h.cs b/Src/SQLite/c#sqlite/pcache_h.cs similarity index 100% rename from SQLite/c#sqlite/pcache_h.cs rename to Src/SQLite/c#sqlite/pcache_h.cs diff --git a/SQLite/c#sqlite/pragma_c.cs b/Src/SQLite/c#sqlite/pragma_c.cs similarity index 100% rename from SQLite/c#sqlite/pragma_c.cs rename to Src/SQLite/c#sqlite/pragma_c.cs diff --git a/SQLite/c#sqlite/prepare_c.cs b/Src/SQLite/c#sqlite/prepare_c.cs similarity index 100% rename from SQLite/c#sqlite/prepare_c.cs rename to Src/SQLite/c#sqlite/prepare_c.cs diff --git a/SQLite/c#sqlite/printf_c.cs b/Src/SQLite/c#sqlite/printf_c.cs similarity index 100% rename from SQLite/c#sqlite/printf_c.cs rename to Src/SQLite/c#sqlite/printf_c.cs diff --git a/SQLite/c#sqlite/random_c.cs b/Src/SQLite/c#sqlite/random_c.cs similarity index 100% rename from SQLite/c#sqlite/random_c.cs rename to Src/SQLite/c#sqlite/random_c.cs diff --git a/SQLite/c#sqlite/resolve_c.cs b/Src/SQLite/c#sqlite/resolve_c.cs similarity index 100% rename from SQLite/c#sqlite/resolve_c.cs rename to Src/SQLite/c#sqlite/resolve_c.cs diff --git a/SQLite/c#sqlite/rowset_c.cs b/Src/SQLite/c#sqlite/rowset_c.cs similarity index 100% rename from SQLite/c#sqlite/rowset_c.cs rename to Src/SQLite/c#sqlite/rowset_c.cs diff --git a/SQLite/c#sqlite/select_c.cs b/Src/SQLite/c#sqlite/select_c.cs similarity index 100% rename from SQLite/c#sqlite/select_c.cs rename to Src/SQLite/c#sqlite/select_c.cs diff --git a/SQLite/c#sqlite/sqlite3_h.cs b/Src/SQLite/c#sqlite/sqlite3_h.cs similarity index 100% rename from SQLite/c#sqlite/sqlite3_h.cs rename to Src/SQLite/c#sqlite/sqlite3_h.cs diff --git a/SQLite/c#sqlite/sqliteInt_h.cs b/Src/SQLite/c#sqlite/sqliteInt_h.cs similarity index 100% rename from SQLite/c#sqlite/sqliteInt_h.cs rename to Src/SQLite/c#sqlite/sqliteInt_h.cs diff --git a/SQLite/c#sqlite/sqliteLimit_h.cs b/Src/SQLite/c#sqlite/sqliteLimit_h.cs similarity index 100% rename from SQLite/c#sqlite/sqliteLimit_h.cs rename to Src/SQLite/c#sqlite/sqliteLimit_h.cs diff --git a/SQLite/c#sqlite/status_c.cs b/Src/SQLite/c#sqlite/status_c.cs similarity index 100% rename from SQLite/c#sqlite/status_c.cs rename to Src/SQLite/c#sqlite/status_c.cs diff --git a/SQLite/c#sqlite/table_c.cs b/Src/SQLite/c#sqlite/table_c.cs similarity index 100% rename from SQLite/c#sqlite/table_c.cs rename to Src/SQLite/c#sqlite/table_c.cs diff --git a/SQLite/c#sqlite/tokenize_c.cs b/Src/SQLite/c#sqlite/tokenize_c.cs similarity index 100% rename from SQLite/c#sqlite/tokenize_c.cs rename to Src/SQLite/c#sqlite/tokenize_c.cs diff --git a/SQLite/c#sqlite/trigger_c.cs b/Src/SQLite/c#sqlite/trigger_c.cs similarity index 100% rename from SQLite/c#sqlite/trigger_c.cs rename to Src/SQLite/c#sqlite/trigger_c.cs diff --git a/SQLite/c#sqlite/update_c.cs b/Src/SQLite/c#sqlite/update_c.cs similarity index 100% rename from SQLite/c#sqlite/update_c.cs rename to Src/SQLite/c#sqlite/update_c.cs diff --git a/SQLite/c#sqlite/utf_c.cs b/Src/SQLite/c#sqlite/utf_c.cs similarity index 100% rename from SQLite/c#sqlite/utf_c.cs rename to Src/SQLite/c#sqlite/utf_c.cs diff --git a/SQLite/c#sqlite/util_c.cs b/Src/SQLite/c#sqlite/util_c.cs similarity index 100% rename from SQLite/c#sqlite/util_c.cs rename to Src/SQLite/c#sqlite/util_c.cs diff --git a/SQLite/c#sqlite/vacuum_c.cs b/Src/SQLite/c#sqlite/vacuum_c.cs similarity index 100% rename from SQLite/c#sqlite/vacuum_c.cs rename to Src/SQLite/c#sqlite/vacuum_c.cs diff --git a/SQLite/c#sqlite/vdbe_c.cs b/Src/SQLite/c#sqlite/vdbe_c.cs similarity index 100% rename from SQLite/c#sqlite/vdbe_c.cs rename to Src/SQLite/c#sqlite/vdbe_c.cs diff --git a/SQLite/c#sqlite/vdbeapi_c.cs b/Src/SQLite/c#sqlite/vdbeapi_c.cs similarity index 100% rename from SQLite/c#sqlite/vdbeapi_c.cs rename to Src/SQLite/c#sqlite/vdbeapi_c.cs diff --git a/SQLite/c#sqlite/vdbeaux_c.cs b/Src/SQLite/c#sqlite/vdbeaux_c.cs similarity index 100% rename from SQLite/c#sqlite/vdbeaux_c.cs rename to Src/SQLite/c#sqlite/vdbeaux_c.cs diff --git a/SQLite/c#sqlite/vdbeblob_c.cs b/Src/SQLite/c#sqlite/vdbeblob_c.cs similarity index 100% rename from SQLite/c#sqlite/vdbeblob_c.cs rename to Src/SQLite/c#sqlite/vdbeblob_c.cs diff --git a/SQLite/c#sqlite/vdbemem_c.cs b/Src/SQLite/c#sqlite/vdbemem_c.cs similarity index 100% rename from SQLite/c#sqlite/vdbemem_c.cs rename to Src/SQLite/c#sqlite/vdbemem_c.cs diff --git a/SQLite/c#sqlite/vdbetrace_c.cs b/Src/SQLite/c#sqlite/vdbetrace_c.cs similarity index 100% rename from SQLite/c#sqlite/vdbetrace_c.cs rename to Src/SQLite/c#sqlite/vdbetrace_c.cs diff --git a/SQLite/c#sqlite/vtab_c.cs b/Src/SQLite/c#sqlite/vtab_c.cs similarity index 100% rename from SQLite/c#sqlite/vtab_c.cs rename to Src/SQLite/c#sqlite/vtab_c.cs diff --git a/SQLite/c#sqlite/wal_c.cs b/Src/SQLite/c#sqlite/wal_c.cs similarity index 100% rename from SQLite/c#sqlite/wal_c.cs rename to Src/SQLite/c#sqlite/wal_c.cs diff --git a/SQLite/c#sqlite/wal_h.cs b/Src/SQLite/c#sqlite/wal_h.cs similarity index 100% rename from SQLite/c#sqlite/wal_h.cs rename to Src/SQLite/c#sqlite/wal_h.cs diff --git a/SQLite/c#sqlite/walker_c.cs b/Src/SQLite/c#sqlite/walker_c.cs similarity index 100% rename from SQLite/c#sqlite/walker_c.cs rename to Src/SQLite/c#sqlite/walker_c.cs diff --git a/SQLite/c#sqlite/where_c.cs b/Src/SQLite/c#sqlite/where_c.cs similarity index 100% rename from SQLite/c#sqlite/where_c.cs rename to Src/SQLite/c#sqlite/where_c.cs diff --git a/Scripts/CompareDirs.py b/Src/Scripts/CompareDirs.py similarity index 100% rename from Scripts/CompareDirs.py rename to Src/Scripts/CompareDirs.py diff --git a/Scripts/Enter-IronPythonEnvironment.ps1 b/Src/Scripts/Enter-IronPythonEnvironment.ps1 similarity index 100% rename from Scripts/Enter-IronPythonEnvironment.ps1 rename to Src/Scripts/Enter-IronPythonEnvironment.ps1 diff --git a/Scripts/Install-IronPython.ps1 b/Src/Scripts/Install-IronPython.ps1 old mode 100644 new mode 100755 similarity index 100% rename from Scripts/Install-IronPython.ps1 rename to Src/Scripts/Install-IronPython.ps1 diff --git a/Scripts/clean.py b/Src/Scripts/clean.py similarity index 100% rename from Scripts/clean.py rename to Src/Scripts/clean.py diff --git a/Scripts/copyrights.py b/Src/Scripts/copyrights.py similarity index 100% rename from Scripts/copyrights.py rename to Src/Scripts/copyrights.py diff --git a/Scripts/generate.py b/Src/Scripts/generate.py old mode 100644 new mode 100755 similarity index 100% rename from Scripts/generate.py rename to Src/Scripts/generate.py diff --git a/Scripts/generate_UncollectableCompilationMode.py b/Src/Scripts/generate_UncollectableCompilationMode.py similarity index 100% rename from Scripts/generate_UncollectableCompilationMode.py rename to Src/Scripts/generate_UncollectableCompilationMode.py diff --git a/Scripts/generate_alltypes.py b/Src/Scripts/generate_alltypes.py similarity index 100% rename from Scripts/generate_alltypes.py rename to Src/Scripts/generate_alltypes.py diff --git a/Scripts/generate_calls.py b/Src/Scripts/generate_calls.py similarity index 100% rename from Scripts/generate_calls.py rename to Src/Scripts/generate_calls.py diff --git a/Scripts/generate_casts.py b/Src/Scripts/generate_casts.py similarity index 100% rename from Scripts/generate_casts.py rename to Src/Scripts/generate_casts.py diff --git a/Scripts/generate_comdispatch.py b/Src/Scripts/generate_comdispatch.py similarity index 100% rename from Scripts/generate_comdispatch.py rename to Src/Scripts/generate_comdispatch.py diff --git a/Scripts/generate_dict_views.py b/Src/Scripts/generate_dict_views.py similarity index 100% rename from Scripts/generate_dict_views.py rename to Src/Scripts/generate_dict_views.py diff --git a/Scripts/generate_dynamic_instructions.py b/Src/Scripts/generate_dynamic_instructions.py similarity index 100% rename from Scripts/generate_dynamic_instructions.py rename to Src/Scripts/generate_dynamic_instructions.py diff --git a/Scripts/generate_dynsites.py b/Src/Scripts/generate_dynsites.py similarity index 100% rename from Scripts/generate_dynsites.py rename to Src/Scripts/generate_dynsites.py diff --git a/Scripts/generate_encoding_aliases.py b/Src/Scripts/generate_encoding_aliases.py similarity index 100% rename from Scripts/generate_encoding_aliases.py rename to Src/Scripts/generate_encoding_aliases.py diff --git a/Scripts/generate_exception_factory.py b/Src/Scripts/generate_exception_factory.py similarity index 100% rename from Scripts/generate_exception_factory.py rename to Src/Scripts/generate_exception_factory.py diff --git a/Scripts/generate_exceptions.py b/Src/Scripts/generate_exceptions.py similarity index 100% rename from Scripts/generate_exceptions.py rename to Src/Scripts/generate_exceptions.py diff --git a/Scripts/generate_indicestest.py b/Src/Scripts/generate_indicestest.py similarity index 100% rename from Scripts/generate_indicestest.py rename to Src/Scripts/generate_indicestest.py diff --git a/Scripts/generate_math.py b/Src/Scripts/generate_math.py similarity index 100% rename from Scripts/generate_math.py rename to Src/Scripts/generate_math.py diff --git a/Scripts/generate_ops.py b/Src/Scripts/generate_ops.py old mode 100644 new mode 100755 similarity index 100% rename from Scripts/generate_ops.py rename to Src/Scripts/generate_ops.py diff --git a/Scripts/generate_os_codes.py b/Src/Scripts/generate_os_codes.py similarity index 100% rename from Scripts/generate_os_codes.py rename to Src/Scripts/generate_os_codes.py diff --git a/Scripts/generate_reflected_calls.py b/Src/Scripts/generate_reflected_calls.py similarity index 100% rename from Scripts/generate_reflected_calls.py rename to Src/Scripts/generate_reflected_calls.py diff --git a/Scripts/generate_set.py b/Src/Scripts/generate_set.py similarity index 100% rename from Scripts/generate_set.py rename to Src/Scripts/generate_set.py diff --git a/Scripts/generate_tuples.py b/Src/Scripts/generate_tuples.py similarity index 100% rename from Scripts/generate_tuples.py rename to Src/Scripts/generate_tuples.py diff --git a/Scripts/generate_typecache.py b/Src/Scripts/generate_typecache.py similarity index 100% rename from Scripts/generate_typecache.py rename to Src/Scripts/generate_typecache.py diff --git a/Scripts/generate_walker.py b/Src/Scripts/generate_walker.py similarity index 100% rename from Scripts/generate_walker.py rename to Src/Scripts/generate_walker.py diff --git a/Scripts/ipcom.ps1 b/Src/Scripts/ipcom.ps1 similarity index 100% rename from Scripts/ipcom.ps1 rename to Src/Scripts/ipcom.ps1 diff --git a/Scripts/make_meta1.py b/Src/Scripts/make_meta1.py similarity index 100% rename from Scripts/make_meta1.py rename to Src/Scripts/make_meta1.py diff --git a/Scripts/radix_generator.py b/Src/Scripts/radix_generator.py similarity index 100% rename from Scripts/radix_generator.py rename to Src/Scripts/radix_generator.py diff --git a/Scripts/run_compiled.py b/Src/Scripts/run_compiled.py similarity index 100% rename from Scripts/run_compiled.py rename to Src/Scripts/run_compiled.py diff --git a/Scripts/run_interactive.py b/Src/Scripts/run_interactive.py similarity index 100% rename from Scripts/run_interactive.py rename to Src/Scripts/run_interactive.py diff --git a/Scripts/smtpmailer.py b/Src/Scripts/smtpmailer.py similarity index 100% rename from Scripts/smtpmailer.py rename to Src/Scripts/smtpmailer.py diff --git a/Scripts/test_builder.py b/Src/Scripts/test_builder.py similarity index 100% rename from Scripts/test_builder.py rename to Src/Scripts/test_builder.py diff --git a/Scripts/test_cgcheck.py b/Src/Scripts/test_cgcheck.py similarity index 100% rename from Scripts/test_cgcheck.py rename to Src/Scripts/test_cgcheck.py diff --git a/Scripts/test_parrot.py b/Src/Scripts/test_parrot.py similarity index 100% rename from Scripts/test_parrot.py rename to Src/Scripts/test_parrot.py diff --git a/Scripts/test_pystone.py b/Src/Scripts/test_pystone.py similarity index 100% rename from Scripts/test_pystone.py rename to Src/Scripts/test_pystone.py diff --git a/StdLib/.gitattributes b/Src/StdLib/.gitattributes similarity index 100% rename from StdLib/.gitattributes rename to Src/StdLib/.gitattributes diff --git a/StdLib/Lib/__future__.py b/Src/StdLib/Lib/__future__.py similarity index 100% rename from StdLib/Lib/__future__.py rename to Src/StdLib/Lib/__future__.py diff --git a/StdLib/Lib/__phello__.foo.py b/Src/StdLib/Lib/__phello__.foo.py similarity index 100% rename from StdLib/Lib/__phello__.foo.py rename to Src/StdLib/Lib/__phello__.foo.py diff --git a/StdLib/Lib/_bootlocale.py b/Src/StdLib/Lib/_bootlocale.py similarity index 100% rename from StdLib/Lib/_bootlocale.py rename to Src/StdLib/Lib/_bootlocale.py diff --git a/StdLib/Lib/_collections_abc.py b/Src/StdLib/Lib/_collections_abc.py similarity index 100% rename from StdLib/Lib/_collections_abc.py rename to Src/StdLib/Lib/_collections_abc.py diff --git a/StdLib/Lib/_compat_pickle.py b/Src/StdLib/Lib/_compat_pickle.py similarity index 100% rename from StdLib/Lib/_compat_pickle.py rename to Src/StdLib/Lib/_compat_pickle.py diff --git a/StdLib/Lib/_dummy_thread.py b/Src/StdLib/Lib/_dummy_thread.py similarity index 100% rename from StdLib/Lib/_dummy_thread.py rename to Src/StdLib/Lib/_dummy_thread.py diff --git a/StdLib/Lib/_markupbase.py b/Src/StdLib/Lib/_markupbase.py similarity index 100% rename from StdLib/Lib/_markupbase.py rename to Src/StdLib/Lib/_markupbase.py diff --git a/StdLib/Lib/_osx_support.py b/Src/StdLib/Lib/_osx_support.py similarity index 100% rename from StdLib/Lib/_osx_support.py rename to Src/StdLib/Lib/_osx_support.py diff --git a/StdLib/Lib/_pyio.py b/Src/StdLib/Lib/_pyio.py similarity index 100% rename from StdLib/Lib/_pyio.py rename to Src/StdLib/Lib/_pyio.py diff --git a/StdLib/Lib/_sitebuiltins.py b/Src/StdLib/Lib/_sitebuiltins.py similarity index 100% rename from StdLib/Lib/_sitebuiltins.py rename to Src/StdLib/Lib/_sitebuiltins.py diff --git a/StdLib/Lib/_strptime.py b/Src/StdLib/Lib/_strptime.py similarity index 100% rename from StdLib/Lib/_strptime.py rename to Src/StdLib/Lib/_strptime.py diff --git a/StdLib/Lib/_threading_local.py b/Src/StdLib/Lib/_threading_local.py similarity index 100% rename from StdLib/Lib/_threading_local.py rename to Src/StdLib/Lib/_threading_local.py diff --git a/StdLib/Lib/_weakrefset.py b/Src/StdLib/Lib/_weakrefset.py similarity index 100% rename from StdLib/Lib/_weakrefset.py rename to Src/StdLib/Lib/_weakrefset.py diff --git a/StdLib/Lib/abc.py b/Src/StdLib/Lib/abc.py similarity index 100% rename from StdLib/Lib/abc.py rename to Src/StdLib/Lib/abc.py diff --git a/StdLib/Lib/aifc.py b/Src/StdLib/Lib/aifc.py similarity index 100% rename from StdLib/Lib/aifc.py rename to Src/StdLib/Lib/aifc.py diff --git a/StdLib/Lib/antigravity.py b/Src/StdLib/Lib/antigravity.py similarity index 100% rename from StdLib/Lib/antigravity.py rename to Src/StdLib/Lib/antigravity.py diff --git a/StdLib/Lib/argparse.py b/Src/StdLib/Lib/argparse.py similarity index 100% rename from StdLib/Lib/argparse.py rename to Src/StdLib/Lib/argparse.py diff --git a/StdLib/Lib/ast.py b/Src/StdLib/Lib/ast.py similarity index 100% rename from StdLib/Lib/ast.py rename to Src/StdLib/Lib/ast.py diff --git a/StdLib/Lib/asynchat.py b/Src/StdLib/Lib/asynchat.py similarity index 100% rename from StdLib/Lib/asynchat.py rename to Src/StdLib/Lib/asynchat.py diff --git a/StdLib/Lib/asyncio/__init__.py b/Src/StdLib/Lib/asyncio/__init__.py similarity index 100% rename from StdLib/Lib/asyncio/__init__.py rename to Src/StdLib/Lib/asyncio/__init__.py diff --git a/StdLib/Lib/asyncio/base_events.py b/Src/StdLib/Lib/asyncio/base_events.py similarity index 100% rename from StdLib/Lib/asyncio/base_events.py rename to Src/StdLib/Lib/asyncio/base_events.py diff --git a/StdLib/Lib/asyncio/base_subprocess.py b/Src/StdLib/Lib/asyncio/base_subprocess.py similarity index 100% rename from StdLib/Lib/asyncio/base_subprocess.py rename to Src/StdLib/Lib/asyncio/base_subprocess.py diff --git a/StdLib/Lib/asyncio/compat.py b/Src/StdLib/Lib/asyncio/compat.py similarity index 100% rename from StdLib/Lib/asyncio/compat.py rename to Src/StdLib/Lib/asyncio/compat.py diff --git a/StdLib/Lib/asyncio/constants.py b/Src/StdLib/Lib/asyncio/constants.py similarity index 100% rename from StdLib/Lib/asyncio/constants.py rename to Src/StdLib/Lib/asyncio/constants.py diff --git a/StdLib/Lib/asyncio/coroutines.py b/Src/StdLib/Lib/asyncio/coroutines.py similarity index 100% rename from StdLib/Lib/asyncio/coroutines.py rename to Src/StdLib/Lib/asyncio/coroutines.py diff --git a/StdLib/Lib/asyncio/events.py b/Src/StdLib/Lib/asyncio/events.py similarity index 100% rename from StdLib/Lib/asyncio/events.py rename to Src/StdLib/Lib/asyncio/events.py diff --git a/StdLib/Lib/asyncio/futures.py b/Src/StdLib/Lib/asyncio/futures.py similarity index 100% rename from StdLib/Lib/asyncio/futures.py rename to Src/StdLib/Lib/asyncio/futures.py diff --git a/StdLib/Lib/asyncio/locks.py b/Src/StdLib/Lib/asyncio/locks.py similarity index 100% rename from StdLib/Lib/asyncio/locks.py rename to Src/StdLib/Lib/asyncio/locks.py diff --git a/StdLib/Lib/asyncio/log.py b/Src/StdLib/Lib/asyncio/log.py similarity index 100% rename from StdLib/Lib/asyncio/log.py rename to Src/StdLib/Lib/asyncio/log.py diff --git a/StdLib/Lib/asyncio/proactor_events.py b/Src/StdLib/Lib/asyncio/proactor_events.py similarity index 100% rename from StdLib/Lib/asyncio/proactor_events.py rename to Src/StdLib/Lib/asyncio/proactor_events.py diff --git a/StdLib/Lib/asyncio/protocols.py b/Src/StdLib/Lib/asyncio/protocols.py similarity index 100% rename from StdLib/Lib/asyncio/protocols.py rename to Src/StdLib/Lib/asyncio/protocols.py diff --git a/StdLib/Lib/asyncio/queues.py b/Src/StdLib/Lib/asyncio/queues.py similarity index 100% rename from StdLib/Lib/asyncio/queues.py rename to Src/StdLib/Lib/asyncio/queues.py diff --git a/StdLib/Lib/asyncio/selector_events.py b/Src/StdLib/Lib/asyncio/selector_events.py similarity index 100% rename from StdLib/Lib/asyncio/selector_events.py rename to Src/StdLib/Lib/asyncio/selector_events.py diff --git a/StdLib/Lib/asyncio/sslproto.py b/Src/StdLib/Lib/asyncio/sslproto.py similarity index 100% rename from StdLib/Lib/asyncio/sslproto.py rename to Src/StdLib/Lib/asyncio/sslproto.py diff --git a/StdLib/Lib/asyncio/streams.py b/Src/StdLib/Lib/asyncio/streams.py similarity index 100% rename from StdLib/Lib/asyncio/streams.py rename to Src/StdLib/Lib/asyncio/streams.py diff --git a/StdLib/Lib/asyncio/subprocess.py b/Src/StdLib/Lib/asyncio/subprocess.py similarity index 100% rename from StdLib/Lib/asyncio/subprocess.py rename to Src/StdLib/Lib/asyncio/subprocess.py diff --git a/StdLib/Lib/asyncio/tasks.py b/Src/StdLib/Lib/asyncio/tasks.py similarity index 100% rename from StdLib/Lib/asyncio/tasks.py rename to Src/StdLib/Lib/asyncio/tasks.py diff --git a/StdLib/Lib/asyncio/test_utils.py b/Src/StdLib/Lib/asyncio/test_utils.py similarity index 100% rename from StdLib/Lib/asyncio/test_utils.py rename to Src/StdLib/Lib/asyncio/test_utils.py diff --git a/StdLib/Lib/asyncio/transports.py b/Src/StdLib/Lib/asyncio/transports.py similarity index 100% rename from StdLib/Lib/asyncio/transports.py rename to Src/StdLib/Lib/asyncio/transports.py diff --git a/StdLib/Lib/asyncio/unix_events.py b/Src/StdLib/Lib/asyncio/unix_events.py similarity index 100% rename from StdLib/Lib/asyncio/unix_events.py rename to Src/StdLib/Lib/asyncio/unix_events.py diff --git a/StdLib/Lib/asyncio/windows_events.py b/Src/StdLib/Lib/asyncio/windows_events.py similarity index 100% rename from StdLib/Lib/asyncio/windows_events.py rename to Src/StdLib/Lib/asyncio/windows_events.py diff --git a/StdLib/Lib/asyncio/windows_utils.py b/Src/StdLib/Lib/asyncio/windows_utils.py similarity index 100% rename from StdLib/Lib/asyncio/windows_utils.py rename to Src/StdLib/Lib/asyncio/windows_utils.py diff --git a/StdLib/Lib/asyncore.py b/Src/StdLib/Lib/asyncore.py similarity index 100% rename from StdLib/Lib/asyncore.py rename to Src/StdLib/Lib/asyncore.py diff --git a/StdLib/Lib/base64.py b/Src/StdLib/Lib/base64.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/base64.py rename to Src/StdLib/Lib/base64.py diff --git a/StdLib/Lib/bdb.py b/Src/StdLib/Lib/bdb.py similarity index 100% rename from StdLib/Lib/bdb.py rename to Src/StdLib/Lib/bdb.py diff --git a/StdLib/Lib/binhex.py b/Src/StdLib/Lib/binhex.py similarity index 100% rename from StdLib/Lib/binhex.py rename to Src/StdLib/Lib/binhex.py diff --git a/StdLib/Lib/bisect.py b/Src/StdLib/Lib/bisect.py similarity index 100% rename from StdLib/Lib/bisect.py rename to Src/StdLib/Lib/bisect.py diff --git a/StdLib/Lib/bz2.py b/Src/StdLib/Lib/bz2.py similarity index 100% rename from StdLib/Lib/bz2.py rename to Src/StdLib/Lib/bz2.py diff --git a/StdLib/Lib/cProfile.py b/Src/StdLib/Lib/cProfile.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/cProfile.py rename to Src/StdLib/Lib/cProfile.py diff --git a/StdLib/Lib/calendar.py b/Src/StdLib/Lib/calendar.py similarity index 100% rename from StdLib/Lib/calendar.py rename to Src/StdLib/Lib/calendar.py diff --git a/StdLib/Lib/cgi.py b/Src/StdLib/Lib/cgi.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/cgi.py rename to Src/StdLib/Lib/cgi.py diff --git a/StdLib/Lib/cgitb.py b/Src/StdLib/Lib/cgitb.py similarity index 100% rename from StdLib/Lib/cgitb.py rename to Src/StdLib/Lib/cgitb.py diff --git a/StdLib/Lib/chunk.py b/Src/StdLib/Lib/chunk.py similarity index 100% rename from StdLib/Lib/chunk.py rename to Src/StdLib/Lib/chunk.py diff --git a/StdLib/Lib/clrtype.py b/Src/StdLib/Lib/clrtype.py similarity index 100% rename from StdLib/Lib/clrtype.py rename to Src/StdLib/Lib/clrtype.py diff --git a/StdLib/Lib/cmd.py b/Src/StdLib/Lib/cmd.py similarity index 100% rename from StdLib/Lib/cmd.py rename to Src/StdLib/Lib/cmd.py diff --git a/StdLib/Lib/code.py b/Src/StdLib/Lib/code.py similarity index 100% rename from StdLib/Lib/code.py rename to Src/StdLib/Lib/code.py diff --git a/StdLib/Lib/codecs.py b/Src/StdLib/Lib/codecs.py similarity index 100% rename from StdLib/Lib/codecs.py rename to Src/StdLib/Lib/codecs.py diff --git a/StdLib/Lib/codeop.py b/Src/StdLib/Lib/codeop.py similarity index 100% rename from StdLib/Lib/codeop.py rename to Src/StdLib/Lib/codeop.py diff --git a/StdLib/Lib/collections/__init__.py b/Src/StdLib/Lib/collections/__init__.py similarity index 100% rename from StdLib/Lib/collections/__init__.py rename to Src/StdLib/Lib/collections/__init__.py diff --git a/StdLib/Lib/collections/__main__.py b/Src/StdLib/Lib/collections/__main__.py similarity index 100% rename from StdLib/Lib/collections/__main__.py rename to Src/StdLib/Lib/collections/__main__.py diff --git a/StdLib/Lib/collections/abc.py b/Src/StdLib/Lib/collections/abc.py similarity index 100% rename from StdLib/Lib/collections/abc.py rename to Src/StdLib/Lib/collections/abc.py diff --git a/StdLib/Lib/colorsys.py b/Src/StdLib/Lib/colorsys.py similarity index 100% rename from StdLib/Lib/colorsys.py rename to Src/StdLib/Lib/colorsys.py diff --git a/StdLib/Lib/compileall.py b/Src/StdLib/Lib/compileall.py similarity index 100% rename from StdLib/Lib/compileall.py rename to Src/StdLib/Lib/compileall.py diff --git a/StdLib/Lib/concurrent/__init__.py b/Src/StdLib/Lib/concurrent/__init__.py similarity index 100% rename from StdLib/Lib/concurrent/__init__.py rename to Src/StdLib/Lib/concurrent/__init__.py diff --git a/StdLib/Lib/concurrent/futures/__init__.py b/Src/StdLib/Lib/concurrent/futures/__init__.py similarity index 100% rename from StdLib/Lib/concurrent/futures/__init__.py rename to Src/StdLib/Lib/concurrent/futures/__init__.py diff --git a/StdLib/Lib/concurrent/futures/_base.py b/Src/StdLib/Lib/concurrent/futures/_base.py similarity index 100% rename from StdLib/Lib/concurrent/futures/_base.py rename to Src/StdLib/Lib/concurrent/futures/_base.py diff --git a/StdLib/Lib/concurrent/futures/process.py b/Src/StdLib/Lib/concurrent/futures/process.py similarity index 100% rename from StdLib/Lib/concurrent/futures/process.py rename to Src/StdLib/Lib/concurrent/futures/process.py diff --git a/StdLib/Lib/concurrent/futures/thread.py b/Src/StdLib/Lib/concurrent/futures/thread.py similarity index 100% rename from StdLib/Lib/concurrent/futures/thread.py rename to Src/StdLib/Lib/concurrent/futures/thread.py diff --git a/StdLib/Lib/configparser.py b/Src/StdLib/Lib/configparser.py similarity index 100% rename from StdLib/Lib/configparser.py rename to Src/StdLib/Lib/configparser.py diff --git a/StdLib/Lib/contextlib.py b/Src/StdLib/Lib/contextlib.py similarity index 100% rename from StdLib/Lib/contextlib.py rename to Src/StdLib/Lib/contextlib.py diff --git a/StdLib/Lib/copy.py b/Src/StdLib/Lib/copy.py similarity index 100% rename from StdLib/Lib/copy.py rename to Src/StdLib/Lib/copy.py diff --git a/StdLib/Lib/copyreg.py b/Src/StdLib/Lib/copyreg.py similarity index 100% rename from StdLib/Lib/copyreg.py rename to Src/StdLib/Lib/copyreg.py diff --git a/StdLib/Lib/crypt.py b/Src/StdLib/Lib/crypt.py similarity index 100% rename from StdLib/Lib/crypt.py rename to Src/StdLib/Lib/crypt.py diff --git a/StdLib/Lib/csv.py b/Src/StdLib/Lib/csv.py similarity index 100% rename from StdLib/Lib/csv.py rename to Src/StdLib/Lib/csv.py diff --git a/StdLib/Lib/ctypes/__init__.py b/Src/StdLib/Lib/ctypes/__init__.py similarity index 100% rename from StdLib/Lib/ctypes/__init__.py rename to Src/StdLib/Lib/ctypes/__init__.py diff --git a/StdLib/Lib/ctypes/_endian.py b/Src/StdLib/Lib/ctypes/_endian.py similarity index 100% rename from StdLib/Lib/ctypes/_endian.py rename to Src/StdLib/Lib/ctypes/_endian.py diff --git a/StdLib/Lib/ctypes/macholib/README.ctypes b/Src/StdLib/Lib/ctypes/macholib/README.ctypes similarity index 100% rename from StdLib/Lib/ctypes/macholib/README.ctypes rename to Src/StdLib/Lib/ctypes/macholib/README.ctypes diff --git a/StdLib/Lib/ctypes/macholib/__init__.py b/Src/StdLib/Lib/ctypes/macholib/__init__.py similarity index 100% rename from StdLib/Lib/ctypes/macholib/__init__.py rename to Src/StdLib/Lib/ctypes/macholib/__init__.py diff --git a/StdLib/Lib/ctypes/macholib/dyld.py b/Src/StdLib/Lib/ctypes/macholib/dyld.py similarity index 100% rename from StdLib/Lib/ctypes/macholib/dyld.py rename to Src/StdLib/Lib/ctypes/macholib/dyld.py diff --git a/StdLib/Lib/ctypes/macholib/dylib.py b/Src/StdLib/Lib/ctypes/macholib/dylib.py similarity index 100% rename from StdLib/Lib/ctypes/macholib/dylib.py rename to Src/StdLib/Lib/ctypes/macholib/dylib.py diff --git a/StdLib/Lib/ctypes/macholib/fetch_macholib b/Src/StdLib/Lib/ctypes/macholib/fetch_macholib old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/ctypes/macholib/fetch_macholib rename to Src/StdLib/Lib/ctypes/macholib/fetch_macholib diff --git a/StdLib/Lib/ctypes/macholib/fetch_macholib.bat b/Src/StdLib/Lib/ctypes/macholib/fetch_macholib.bat similarity index 100% rename from StdLib/Lib/ctypes/macholib/fetch_macholib.bat rename to Src/StdLib/Lib/ctypes/macholib/fetch_macholib.bat diff --git a/StdLib/Lib/ctypes/macholib/framework.py b/Src/StdLib/Lib/ctypes/macholib/framework.py similarity index 100% rename from StdLib/Lib/ctypes/macholib/framework.py rename to Src/StdLib/Lib/ctypes/macholib/framework.py diff --git a/StdLib/Lib/ctypes/test/__init__.py b/Src/StdLib/Lib/ctypes/test/__init__.py similarity index 100% rename from StdLib/Lib/ctypes/test/__init__.py rename to Src/StdLib/Lib/ctypes/test/__init__.py diff --git a/StdLib/Lib/ctypes/test/__main__.py b/Src/StdLib/Lib/ctypes/test/__main__.py similarity index 100% rename from StdLib/Lib/ctypes/test/__main__.py rename to Src/StdLib/Lib/ctypes/test/__main__.py diff --git a/StdLib/Lib/ctypes/test/test_anon.py b/Src/StdLib/Lib/ctypes/test/test_anon.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_anon.py rename to Src/StdLib/Lib/ctypes/test/test_anon.py diff --git a/StdLib/Lib/ctypes/test/test_array_in_pointer.py b/Src/StdLib/Lib/ctypes/test/test_array_in_pointer.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_array_in_pointer.py rename to Src/StdLib/Lib/ctypes/test/test_array_in_pointer.py diff --git a/StdLib/Lib/ctypes/test/test_arrays.py b/Src/StdLib/Lib/ctypes/test/test_arrays.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_arrays.py rename to Src/StdLib/Lib/ctypes/test/test_arrays.py diff --git a/StdLib/Lib/ctypes/test/test_as_parameter.py b/Src/StdLib/Lib/ctypes/test/test_as_parameter.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_as_parameter.py rename to Src/StdLib/Lib/ctypes/test/test_as_parameter.py diff --git a/StdLib/Lib/ctypes/test/test_bitfields.py b/Src/StdLib/Lib/ctypes/test/test_bitfields.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_bitfields.py rename to Src/StdLib/Lib/ctypes/test/test_bitfields.py diff --git a/StdLib/Lib/ctypes/test/test_buffers.py b/Src/StdLib/Lib/ctypes/test/test_buffers.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_buffers.py rename to Src/StdLib/Lib/ctypes/test/test_buffers.py diff --git a/StdLib/Lib/ctypes/test/test_bytes.py b/Src/StdLib/Lib/ctypes/test/test_bytes.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_bytes.py rename to Src/StdLib/Lib/ctypes/test/test_bytes.py diff --git a/StdLib/Lib/ctypes/test/test_byteswap.py b/Src/StdLib/Lib/ctypes/test/test_byteswap.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_byteswap.py rename to Src/StdLib/Lib/ctypes/test/test_byteswap.py diff --git a/StdLib/Lib/ctypes/test/test_callbacks.py b/Src/StdLib/Lib/ctypes/test/test_callbacks.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_callbacks.py rename to Src/StdLib/Lib/ctypes/test/test_callbacks.py diff --git a/StdLib/Lib/ctypes/test/test_cast.py b/Src/StdLib/Lib/ctypes/test/test_cast.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_cast.py rename to Src/StdLib/Lib/ctypes/test/test_cast.py diff --git a/StdLib/Lib/ctypes/test/test_cfuncs.py b/Src/StdLib/Lib/ctypes/test/test_cfuncs.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_cfuncs.py rename to Src/StdLib/Lib/ctypes/test/test_cfuncs.py diff --git a/StdLib/Lib/ctypes/test/test_checkretval.py b/Src/StdLib/Lib/ctypes/test/test_checkretval.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_checkretval.py rename to Src/StdLib/Lib/ctypes/test/test_checkretval.py diff --git a/StdLib/Lib/ctypes/test/test_delattr.py b/Src/StdLib/Lib/ctypes/test/test_delattr.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_delattr.py rename to Src/StdLib/Lib/ctypes/test/test_delattr.py diff --git a/StdLib/Lib/ctypes/test/test_errno.py b/Src/StdLib/Lib/ctypes/test/test_errno.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_errno.py rename to Src/StdLib/Lib/ctypes/test/test_errno.py diff --git a/StdLib/Lib/ctypes/test/test_find.py b/Src/StdLib/Lib/ctypes/test/test_find.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_find.py rename to Src/StdLib/Lib/ctypes/test/test_find.py diff --git a/StdLib/Lib/ctypes/test/test_frombuffer.py b/Src/StdLib/Lib/ctypes/test/test_frombuffer.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_frombuffer.py rename to Src/StdLib/Lib/ctypes/test/test_frombuffer.py diff --git a/StdLib/Lib/ctypes/test/test_funcptr.py b/Src/StdLib/Lib/ctypes/test/test_funcptr.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_funcptr.py rename to Src/StdLib/Lib/ctypes/test/test_funcptr.py diff --git a/StdLib/Lib/ctypes/test/test_functions.py b/Src/StdLib/Lib/ctypes/test/test_functions.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_functions.py rename to Src/StdLib/Lib/ctypes/test/test_functions.py diff --git a/StdLib/Lib/ctypes/test/test_incomplete.py b/Src/StdLib/Lib/ctypes/test/test_incomplete.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_incomplete.py rename to Src/StdLib/Lib/ctypes/test/test_incomplete.py diff --git a/StdLib/Lib/ctypes/test/test_init.py b/Src/StdLib/Lib/ctypes/test/test_init.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_init.py rename to Src/StdLib/Lib/ctypes/test/test_init.py diff --git a/StdLib/Lib/ctypes/test/test_internals.py b/Src/StdLib/Lib/ctypes/test/test_internals.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_internals.py rename to Src/StdLib/Lib/ctypes/test/test_internals.py diff --git a/StdLib/Lib/ctypes/test/test_keeprefs.py b/Src/StdLib/Lib/ctypes/test/test_keeprefs.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_keeprefs.py rename to Src/StdLib/Lib/ctypes/test/test_keeprefs.py diff --git a/StdLib/Lib/ctypes/test/test_libc.py b/Src/StdLib/Lib/ctypes/test/test_libc.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_libc.py rename to Src/StdLib/Lib/ctypes/test/test_libc.py diff --git a/StdLib/Lib/ctypes/test/test_loading.py b/Src/StdLib/Lib/ctypes/test/test_loading.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_loading.py rename to Src/StdLib/Lib/ctypes/test/test_loading.py diff --git a/StdLib/Lib/ctypes/test/test_macholib.py b/Src/StdLib/Lib/ctypes/test/test_macholib.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_macholib.py rename to Src/StdLib/Lib/ctypes/test/test_macholib.py diff --git a/StdLib/Lib/ctypes/test/test_memfunctions.py b/Src/StdLib/Lib/ctypes/test/test_memfunctions.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_memfunctions.py rename to Src/StdLib/Lib/ctypes/test/test_memfunctions.py diff --git a/StdLib/Lib/ctypes/test/test_numbers.py b/Src/StdLib/Lib/ctypes/test/test_numbers.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_numbers.py rename to Src/StdLib/Lib/ctypes/test/test_numbers.py diff --git a/StdLib/Lib/ctypes/test/test_objects.py b/Src/StdLib/Lib/ctypes/test/test_objects.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_objects.py rename to Src/StdLib/Lib/ctypes/test/test_objects.py diff --git a/StdLib/Lib/ctypes/test/test_parameters.py b/Src/StdLib/Lib/ctypes/test/test_parameters.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_parameters.py rename to Src/StdLib/Lib/ctypes/test/test_parameters.py diff --git a/StdLib/Lib/ctypes/test/test_pep3118.py b/Src/StdLib/Lib/ctypes/test/test_pep3118.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_pep3118.py rename to Src/StdLib/Lib/ctypes/test/test_pep3118.py diff --git a/StdLib/Lib/ctypes/test/test_pickling.py b/Src/StdLib/Lib/ctypes/test/test_pickling.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_pickling.py rename to Src/StdLib/Lib/ctypes/test/test_pickling.py diff --git a/StdLib/Lib/ctypes/test/test_pointers.py b/Src/StdLib/Lib/ctypes/test/test_pointers.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_pointers.py rename to Src/StdLib/Lib/ctypes/test/test_pointers.py diff --git a/StdLib/Lib/ctypes/test/test_prototypes.py b/Src/StdLib/Lib/ctypes/test/test_prototypes.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_prototypes.py rename to Src/StdLib/Lib/ctypes/test/test_prototypes.py diff --git a/StdLib/Lib/ctypes/test/test_python_api.py b/Src/StdLib/Lib/ctypes/test/test_python_api.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_python_api.py rename to Src/StdLib/Lib/ctypes/test/test_python_api.py diff --git a/StdLib/Lib/ctypes/test/test_random_things.py b/Src/StdLib/Lib/ctypes/test/test_random_things.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_random_things.py rename to Src/StdLib/Lib/ctypes/test/test_random_things.py diff --git a/StdLib/Lib/ctypes/test/test_refcounts.py b/Src/StdLib/Lib/ctypes/test/test_refcounts.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_refcounts.py rename to Src/StdLib/Lib/ctypes/test/test_refcounts.py diff --git a/StdLib/Lib/ctypes/test/test_repr.py b/Src/StdLib/Lib/ctypes/test/test_repr.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_repr.py rename to Src/StdLib/Lib/ctypes/test/test_repr.py diff --git a/StdLib/Lib/ctypes/test/test_returnfuncptrs.py b/Src/StdLib/Lib/ctypes/test/test_returnfuncptrs.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_returnfuncptrs.py rename to Src/StdLib/Lib/ctypes/test/test_returnfuncptrs.py diff --git a/StdLib/Lib/ctypes/test/test_simplesubclasses.py b/Src/StdLib/Lib/ctypes/test/test_simplesubclasses.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_simplesubclasses.py rename to Src/StdLib/Lib/ctypes/test/test_simplesubclasses.py diff --git a/StdLib/Lib/ctypes/test/test_sizes.py b/Src/StdLib/Lib/ctypes/test/test_sizes.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_sizes.py rename to Src/StdLib/Lib/ctypes/test/test_sizes.py diff --git a/StdLib/Lib/ctypes/test/test_slicing.py b/Src/StdLib/Lib/ctypes/test/test_slicing.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_slicing.py rename to Src/StdLib/Lib/ctypes/test/test_slicing.py diff --git a/StdLib/Lib/ctypes/test/test_stringptr.py b/Src/StdLib/Lib/ctypes/test/test_stringptr.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_stringptr.py rename to Src/StdLib/Lib/ctypes/test/test_stringptr.py diff --git a/StdLib/Lib/ctypes/test/test_strings.py b/Src/StdLib/Lib/ctypes/test/test_strings.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_strings.py rename to Src/StdLib/Lib/ctypes/test/test_strings.py diff --git a/StdLib/Lib/ctypes/test/test_struct_fields.py b/Src/StdLib/Lib/ctypes/test/test_struct_fields.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_struct_fields.py rename to Src/StdLib/Lib/ctypes/test/test_struct_fields.py diff --git a/StdLib/Lib/ctypes/test/test_structures.py b/Src/StdLib/Lib/ctypes/test/test_structures.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_structures.py rename to Src/StdLib/Lib/ctypes/test/test_structures.py diff --git a/StdLib/Lib/ctypes/test/test_unaligned_structures.py b/Src/StdLib/Lib/ctypes/test/test_unaligned_structures.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_unaligned_structures.py rename to Src/StdLib/Lib/ctypes/test/test_unaligned_structures.py diff --git a/StdLib/Lib/ctypes/test/test_unicode.py b/Src/StdLib/Lib/ctypes/test/test_unicode.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_unicode.py rename to Src/StdLib/Lib/ctypes/test/test_unicode.py diff --git a/StdLib/Lib/ctypes/test/test_values.py b/Src/StdLib/Lib/ctypes/test/test_values.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_values.py rename to Src/StdLib/Lib/ctypes/test/test_values.py diff --git a/StdLib/Lib/ctypes/test/test_varsize_struct.py b/Src/StdLib/Lib/ctypes/test/test_varsize_struct.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_varsize_struct.py rename to Src/StdLib/Lib/ctypes/test/test_varsize_struct.py diff --git a/StdLib/Lib/ctypes/test/test_win32.py b/Src/StdLib/Lib/ctypes/test/test_win32.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_win32.py rename to Src/StdLib/Lib/ctypes/test/test_win32.py diff --git a/StdLib/Lib/ctypes/test/test_wintypes.py b/Src/StdLib/Lib/ctypes/test/test_wintypes.py similarity index 100% rename from StdLib/Lib/ctypes/test/test_wintypes.py rename to Src/StdLib/Lib/ctypes/test/test_wintypes.py diff --git a/StdLib/Lib/ctypes/util.py b/Src/StdLib/Lib/ctypes/util.py similarity index 100% rename from StdLib/Lib/ctypes/util.py rename to Src/StdLib/Lib/ctypes/util.py diff --git a/StdLib/Lib/ctypes/wintypes.py b/Src/StdLib/Lib/ctypes/wintypes.py similarity index 100% rename from StdLib/Lib/ctypes/wintypes.py rename to Src/StdLib/Lib/ctypes/wintypes.py diff --git a/StdLib/Lib/curses/__init__.py b/Src/StdLib/Lib/curses/__init__.py similarity index 100% rename from StdLib/Lib/curses/__init__.py rename to Src/StdLib/Lib/curses/__init__.py diff --git a/StdLib/Lib/curses/ascii.py b/Src/StdLib/Lib/curses/ascii.py similarity index 100% rename from StdLib/Lib/curses/ascii.py rename to Src/StdLib/Lib/curses/ascii.py diff --git a/StdLib/Lib/curses/has_key.py b/Src/StdLib/Lib/curses/has_key.py similarity index 100% rename from StdLib/Lib/curses/has_key.py rename to Src/StdLib/Lib/curses/has_key.py diff --git a/StdLib/Lib/curses/panel.py b/Src/StdLib/Lib/curses/panel.py similarity index 100% rename from StdLib/Lib/curses/panel.py rename to Src/StdLib/Lib/curses/panel.py diff --git a/StdLib/Lib/curses/textpad.py b/Src/StdLib/Lib/curses/textpad.py similarity index 100% rename from StdLib/Lib/curses/textpad.py rename to Src/StdLib/Lib/curses/textpad.py diff --git a/StdLib/Lib/datetime.py b/Src/StdLib/Lib/datetime.py similarity index 100% rename from StdLib/Lib/datetime.py rename to Src/StdLib/Lib/datetime.py diff --git a/StdLib/Lib/dbm/__init__.py b/Src/StdLib/Lib/dbm/__init__.py similarity index 100% rename from StdLib/Lib/dbm/__init__.py rename to Src/StdLib/Lib/dbm/__init__.py diff --git a/StdLib/Lib/dbm/dumb.py b/Src/StdLib/Lib/dbm/dumb.py similarity index 100% rename from StdLib/Lib/dbm/dumb.py rename to Src/StdLib/Lib/dbm/dumb.py diff --git a/StdLib/Lib/dbm/gnu.py b/Src/StdLib/Lib/dbm/gnu.py similarity index 100% rename from StdLib/Lib/dbm/gnu.py rename to Src/StdLib/Lib/dbm/gnu.py diff --git a/StdLib/Lib/dbm/ndbm.py b/Src/StdLib/Lib/dbm/ndbm.py similarity index 100% rename from StdLib/Lib/dbm/ndbm.py rename to Src/StdLib/Lib/dbm/ndbm.py diff --git a/StdLib/Lib/decimal.py b/Src/StdLib/Lib/decimal.py similarity index 100% rename from StdLib/Lib/decimal.py rename to Src/StdLib/Lib/decimal.py diff --git a/StdLib/Lib/difflib.py b/Src/StdLib/Lib/difflib.py similarity index 100% rename from StdLib/Lib/difflib.py rename to Src/StdLib/Lib/difflib.py diff --git a/StdLib/Lib/dis.py b/Src/StdLib/Lib/dis.py similarity index 100% rename from StdLib/Lib/dis.py rename to Src/StdLib/Lib/dis.py diff --git a/StdLib/Lib/distutils/README b/Src/StdLib/Lib/distutils/README similarity index 100% rename from StdLib/Lib/distutils/README rename to Src/StdLib/Lib/distutils/README diff --git a/StdLib/Lib/distutils/__init__.py b/Src/StdLib/Lib/distutils/__init__.py similarity index 100% rename from StdLib/Lib/distutils/__init__.py rename to Src/StdLib/Lib/distutils/__init__.py diff --git a/StdLib/Lib/distutils/archive_util.py b/Src/StdLib/Lib/distutils/archive_util.py similarity index 100% rename from StdLib/Lib/distutils/archive_util.py rename to Src/StdLib/Lib/distutils/archive_util.py diff --git a/StdLib/Lib/distutils/bcppcompiler.py b/Src/StdLib/Lib/distutils/bcppcompiler.py similarity index 100% rename from StdLib/Lib/distutils/bcppcompiler.py rename to Src/StdLib/Lib/distutils/bcppcompiler.py diff --git a/StdLib/Lib/distutils/ccompiler.py b/Src/StdLib/Lib/distutils/ccompiler.py similarity index 100% rename from StdLib/Lib/distutils/ccompiler.py rename to Src/StdLib/Lib/distutils/ccompiler.py diff --git a/StdLib/Lib/distutils/cmd.py b/Src/StdLib/Lib/distutils/cmd.py similarity index 100% rename from StdLib/Lib/distutils/cmd.py rename to Src/StdLib/Lib/distutils/cmd.py diff --git a/StdLib/Lib/distutils/command/__init__.py b/Src/StdLib/Lib/distutils/command/__init__.py similarity index 100% rename from StdLib/Lib/distutils/command/__init__.py rename to Src/StdLib/Lib/distutils/command/__init__.py diff --git a/StdLib/Lib/distutils/command/bdist.py b/Src/StdLib/Lib/distutils/command/bdist.py similarity index 100% rename from StdLib/Lib/distutils/command/bdist.py rename to Src/StdLib/Lib/distutils/command/bdist.py diff --git a/StdLib/Lib/distutils/command/bdist_dumb.py b/Src/StdLib/Lib/distutils/command/bdist_dumb.py similarity index 100% rename from StdLib/Lib/distutils/command/bdist_dumb.py rename to Src/StdLib/Lib/distutils/command/bdist_dumb.py diff --git a/StdLib/Lib/distutils/command/bdist_msi.py b/Src/StdLib/Lib/distutils/command/bdist_msi.py similarity index 100% rename from StdLib/Lib/distutils/command/bdist_msi.py rename to Src/StdLib/Lib/distutils/command/bdist_msi.py diff --git a/StdLib/Lib/distutils/command/bdist_rpm.py b/Src/StdLib/Lib/distutils/command/bdist_rpm.py similarity index 100% rename from StdLib/Lib/distutils/command/bdist_rpm.py rename to Src/StdLib/Lib/distutils/command/bdist_rpm.py diff --git a/StdLib/Lib/distutils/command/bdist_wininst.py b/Src/StdLib/Lib/distutils/command/bdist_wininst.py similarity index 100% rename from StdLib/Lib/distutils/command/bdist_wininst.py rename to Src/StdLib/Lib/distutils/command/bdist_wininst.py diff --git a/StdLib/Lib/distutils/command/build.py b/Src/StdLib/Lib/distutils/command/build.py similarity index 100% rename from StdLib/Lib/distutils/command/build.py rename to Src/StdLib/Lib/distutils/command/build.py diff --git a/StdLib/Lib/distutils/command/build_clib.py b/Src/StdLib/Lib/distutils/command/build_clib.py similarity index 100% rename from StdLib/Lib/distutils/command/build_clib.py rename to Src/StdLib/Lib/distutils/command/build_clib.py diff --git a/StdLib/Lib/distutils/command/build_ext.py b/Src/StdLib/Lib/distutils/command/build_ext.py similarity index 100% rename from StdLib/Lib/distutils/command/build_ext.py rename to Src/StdLib/Lib/distutils/command/build_ext.py diff --git a/StdLib/Lib/distutils/command/build_py.py b/Src/StdLib/Lib/distutils/command/build_py.py similarity index 100% rename from StdLib/Lib/distutils/command/build_py.py rename to Src/StdLib/Lib/distutils/command/build_py.py diff --git a/StdLib/Lib/distutils/command/build_scripts.py b/Src/StdLib/Lib/distutils/command/build_scripts.py similarity index 100% rename from StdLib/Lib/distutils/command/build_scripts.py rename to Src/StdLib/Lib/distutils/command/build_scripts.py diff --git a/StdLib/Lib/distutils/command/check.py b/Src/StdLib/Lib/distutils/command/check.py similarity index 100% rename from StdLib/Lib/distutils/command/check.py rename to Src/StdLib/Lib/distutils/command/check.py diff --git a/StdLib/Lib/distutils/command/clean.py b/Src/StdLib/Lib/distutils/command/clean.py similarity index 100% rename from StdLib/Lib/distutils/command/clean.py rename to Src/StdLib/Lib/distutils/command/clean.py diff --git a/StdLib/Lib/distutils/command/command_template b/Src/StdLib/Lib/distutils/command/command_template similarity index 100% rename from StdLib/Lib/distutils/command/command_template rename to Src/StdLib/Lib/distutils/command/command_template diff --git a/StdLib/Lib/distutils/command/config.py b/Src/StdLib/Lib/distutils/command/config.py similarity index 100% rename from StdLib/Lib/distutils/command/config.py rename to Src/StdLib/Lib/distutils/command/config.py diff --git a/StdLib/Lib/distutils/command/install.py b/Src/StdLib/Lib/distutils/command/install.py similarity index 100% rename from StdLib/Lib/distutils/command/install.py rename to Src/StdLib/Lib/distutils/command/install.py diff --git a/StdLib/Lib/distutils/command/install_data.py b/Src/StdLib/Lib/distutils/command/install_data.py similarity index 100% rename from StdLib/Lib/distutils/command/install_data.py rename to Src/StdLib/Lib/distutils/command/install_data.py diff --git a/StdLib/Lib/distutils/command/install_egg_info.py b/Src/StdLib/Lib/distutils/command/install_egg_info.py similarity index 100% rename from StdLib/Lib/distutils/command/install_egg_info.py rename to Src/StdLib/Lib/distutils/command/install_egg_info.py diff --git a/StdLib/Lib/distutils/command/install_headers.py b/Src/StdLib/Lib/distutils/command/install_headers.py similarity index 100% rename from StdLib/Lib/distutils/command/install_headers.py rename to Src/StdLib/Lib/distutils/command/install_headers.py diff --git a/StdLib/Lib/distutils/command/install_lib.py b/Src/StdLib/Lib/distutils/command/install_lib.py similarity index 100% rename from StdLib/Lib/distutils/command/install_lib.py rename to Src/StdLib/Lib/distutils/command/install_lib.py diff --git a/StdLib/Lib/distutils/command/install_scripts.py b/Src/StdLib/Lib/distutils/command/install_scripts.py similarity index 100% rename from StdLib/Lib/distutils/command/install_scripts.py rename to Src/StdLib/Lib/distutils/command/install_scripts.py diff --git a/StdLib/Lib/distutils/command/register.py b/Src/StdLib/Lib/distutils/command/register.py similarity index 100% rename from StdLib/Lib/distutils/command/register.py rename to Src/StdLib/Lib/distutils/command/register.py diff --git a/StdLib/Lib/distutils/command/sdist.py b/Src/StdLib/Lib/distutils/command/sdist.py similarity index 100% rename from StdLib/Lib/distutils/command/sdist.py rename to Src/StdLib/Lib/distutils/command/sdist.py diff --git a/StdLib/Lib/distutils/command/upload.py b/Src/StdLib/Lib/distutils/command/upload.py similarity index 100% rename from StdLib/Lib/distutils/command/upload.py rename to Src/StdLib/Lib/distutils/command/upload.py diff --git a/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe b/Src/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe similarity index 100% rename from StdLib/Lib/distutils/command/wininst-10.0-amd64.exe rename to Src/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe diff --git a/StdLib/Lib/distutils/command/wininst-10.0.exe b/Src/StdLib/Lib/distutils/command/wininst-10.0.exe similarity index 100% rename from StdLib/Lib/distutils/command/wininst-10.0.exe rename to Src/StdLib/Lib/distutils/command/wininst-10.0.exe diff --git a/StdLib/Lib/distutils/command/wininst-6.0.exe b/Src/StdLib/Lib/distutils/command/wininst-6.0.exe similarity index 100% rename from StdLib/Lib/distutils/command/wininst-6.0.exe rename to Src/StdLib/Lib/distutils/command/wininst-6.0.exe diff --git a/StdLib/Lib/distutils/command/wininst-7.1.exe b/Src/StdLib/Lib/distutils/command/wininst-7.1.exe similarity index 100% rename from StdLib/Lib/distutils/command/wininst-7.1.exe rename to Src/StdLib/Lib/distutils/command/wininst-7.1.exe diff --git a/StdLib/Lib/distutils/command/wininst-8.0.exe b/Src/StdLib/Lib/distutils/command/wininst-8.0.exe similarity index 100% rename from StdLib/Lib/distutils/command/wininst-8.0.exe rename to Src/StdLib/Lib/distutils/command/wininst-8.0.exe diff --git a/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe b/Src/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe similarity index 100% rename from StdLib/Lib/distutils/command/wininst-9.0-amd64.exe rename to Src/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe diff --git a/StdLib/Lib/distutils/command/wininst-9.0.exe b/Src/StdLib/Lib/distutils/command/wininst-9.0.exe similarity index 100% rename from StdLib/Lib/distutils/command/wininst-9.0.exe rename to Src/StdLib/Lib/distutils/command/wininst-9.0.exe diff --git a/StdLib/Lib/distutils/config.py b/Src/StdLib/Lib/distutils/config.py similarity index 100% rename from StdLib/Lib/distutils/config.py rename to Src/StdLib/Lib/distutils/config.py diff --git a/StdLib/Lib/distutils/core.py b/Src/StdLib/Lib/distutils/core.py similarity index 100% rename from StdLib/Lib/distutils/core.py rename to Src/StdLib/Lib/distutils/core.py diff --git a/StdLib/Lib/distutils/cygwinccompiler.py b/Src/StdLib/Lib/distutils/cygwinccompiler.py similarity index 100% rename from StdLib/Lib/distutils/cygwinccompiler.py rename to Src/StdLib/Lib/distutils/cygwinccompiler.py diff --git a/StdLib/Lib/distutils/debug.py b/Src/StdLib/Lib/distutils/debug.py similarity index 100% rename from StdLib/Lib/distutils/debug.py rename to Src/StdLib/Lib/distutils/debug.py diff --git a/StdLib/Lib/distutils/dep_util.py b/Src/StdLib/Lib/distutils/dep_util.py similarity index 100% rename from StdLib/Lib/distutils/dep_util.py rename to Src/StdLib/Lib/distutils/dep_util.py diff --git a/StdLib/Lib/distutils/dir_util.py b/Src/StdLib/Lib/distutils/dir_util.py similarity index 100% rename from StdLib/Lib/distutils/dir_util.py rename to Src/StdLib/Lib/distutils/dir_util.py diff --git a/StdLib/Lib/distutils/dist.py b/Src/StdLib/Lib/distutils/dist.py similarity index 100% rename from StdLib/Lib/distutils/dist.py rename to Src/StdLib/Lib/distutils/dist.py diff --git a/StdLib/Lib/distutils/errors.py b/Src/StdLib/Lib/distutils/errors.py similarity index 100% rename from StdLib/Lib/distutils/errors.py rename to Src/StdLib/Lib/distutils/errors.py diff --git a/StdLib/Lib/distutils/extension.py b/Src/StdLib/Lib/distutils/extension.py similarity index 100% rename from StdLib/Lib/distutils/extension.py rename to Src/StdLib/Lib/distutils/extension.py diff --git a/StdLib/Lib/distutils/fancy_getopt.py b/Src/StdLib/Lib/distutils/fancy_getopt.py similarity index 100% rename from StdLib/Lib/distutils/fancy_getopt.py rename to Src/StdLib/Lib/distutils/fancy_getopt.py diff --git a/StdLib/Lib/distutils/file_util.py b/Src/StdLib/Lib/distutils/file_util.py similarity index 100% rename from StdLib/Lib/distutils/file_util.py rename to Src/StdLib/Lib/distutils/file_util.py diff --git a/StdLib/Lib/distutils/filelist.py b/Src/StdLib/Lib/distutils/filelist.py similarity index 100% rename from StdLib/Lib/distutils/filelist.py rename to Src/StdLib/Lib/distutils/filelist.py diff --git a/StdLib/Lib/distutils/log.py b/Src/StdLib/Lib/distutils/log.py similarity index 100% rename from StdLib/Lib/distutils/log.py rename to Src/StdLib/Lib/distutils/log.py diff --git a/StdLib/Lib/distutils/msvc9compiler.py b/Src/StdLib/Lib/distutils/msvc9compiler.py similarity index 100% rename from StdLib/Lib/distutils/msvc9compiler.py rename to Src/StdLib/Lib/distutils/msvc9compiler.py diff --git a/StdLib/Lib/distutils/msvccompiler.py b/Src/StdLib/Lib/distutils/msvccompiler.py similarity index 100% rename from StdLib/Lib/distutils/msvccompiler.py rename to Src/StdLib/Lib/distutils/msvccompiler.py diff --git a/StdLib/Lib/distutils/spawn.py b/Src/StdLib/Lib/distutils/spawn.py similarity index 100% rename from StdLib/Lib/distutils/spawn.py rename to Src/StdLib/Lib/distutils/spawn.py diff --git a/StdLib/Lib/distutils/sysconfig.py b/Src/StdLib/Lib/distutils/sysconfig.py similarity index 100% rename from StdLib/Lib/distutils/sysconfig.py rename to Src/StdLib/Lib/distutils/sysconfig.py diff --git a/StdLib/Lib/distutils/tests/Setup.sample b/Src/StdLib/Lib/distutils/tests/Setup.sample similarity index 100% rename from StdLib/Lib/distutils/tests/Setup.sample rename to Src/StdLib/Lib/distutils/tests/Setup.sample diff --git a/StdLib/Lib/distutils/tests/__init__.py b/Src/StdLib/Lib/distutils/tests/__init__.py similarity index 100% rename from StdLib/Lib/distutils/tests/__init__.py rename to Src/StdLib/Lib/distutils/tests/__init__.py diff --git a/StdLib/Lib/distutils/tests/support.py b/Src/StdLib/Lib/distutils/tests/support.py similarity index 100% rename from StdLib/Lib/distutils/tests/support.py rename to Src/StdLib/Lib/distutils/tests/support.py diff --git a/StdLib/Lib/distutils/tests/test_archive_util.py b/Src/StdLib/Lib/distutils/tests/test_archive_util.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_archive_util.py rename to Src/StdLib/Lib/distutils/tests/test_archive_util.py diff --git a/StdLib/Lib/distutils/tests/test_bdist.py b/Src/StdLib/Lib/distutils/tests/test_bdist.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_bdist.py rename to Src/StdLib/Lib/distutils/tests/test_bdist.py diff --git a/StdLib/Lib/distutils/tests/test_bdist_dumb.py b/Src/StdLib/Lib/distutils/tests/test_bdist_dumb.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_bdist_dumb.py rename to Src/StdLib/Lib/distutils/tests/test_bdist_dumb.py diff --git a/StdLib/Lib/distutils/tests/test_bdist_msi.py b/Src/StdLib/Lib/distutils/tests/test_bdist_msi.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_bdist_msi.py rename to Src/StdLib/Lib/distutils/tests/test_bdist_msi.py diff --git a/StdLib/Lib/distutils/tests/test_bdist_rpm.py b/Src/StdLib/Lib/distutils/tests/test_bdist_rpm.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_bdist_rpm.py rename to Src/StdLib/Lib/distutils/tests/test_bdist_rpm.py diff --git a/StdLib/Lib/distutils/tests/test_bdist_wininst.py b/Src/StdLib/Lib/distutils/tests/test_bdist_wininst.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_bdist_wininst.py rename to Src/StdLib/Lib/distutils/tests/test_bdist_wininst.py diff --git a/StdLib/Lib/distutils/tests/test_build.py b/Src/StdLib/Lib/distutils/tests/test_build.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_build.py rename to Src/StdLib/Lib/distutils/tests/test_build.py diff --git a/StdLib/Lib/distutils/tests/test_build_clib.py b/Src/StdLib/Lib/distutils/tests/test_build_clib.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_build_clib.py rename to Src/StdLib/Lib/distutils/tests/test_build_clib.py diff --git a/StdLib/Lib/distutils/tests/test_build_ext.py b/Src/StdLib/Lib/distutils/tests/test_build_ext.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_build_ext.py rename to Src/StdLib/Lib/distutils/tests/test_build_ext.py diff --git a/StdLib/Lib/distutils/tests/test_build_py.py b/Src/StdLib/Lib/distutils/tests/test_build_py.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_build_py.py rename to Src/StdLib/Lib/distutils/tests/test_build_py.py diff --git a/StdLib/Lib/distutils/tests/test_build_scripts.py b/Src/StdLib/Lib/distutils/tests/test_build_scripts.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_build_scripts.py rename to Src/StdLib/Lib/distutils/tests/test_build_scripts.py diff --git a/StdLib/Lib/distutils/tests/test_check.py b/Src/StdLib/Lib/distutils/tests/test_check.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_check.py rename to Src/StdLib/Lib/distutils/tests/test_check.py diff --git a/StdLib/Lib/distutils/tests/test_clean.py b/Src/StdLib/Lib/distutils/tests/test_clean.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_clean.py rename to Src/StdLib/Lib/distutils/tests/test_clean.py diff --git a/StdLib/Lib/distutils/tests/test_cmd.py b/Src/StdLib/Lib/distutils/tests/test_cmd.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_cmd.py rename to Src/StdLib/Lib/distutils/tests/test_cmd.py diff --git a/StdLib/Lib/distutils/tests/test_config.py b/Src/StdLib/Lib/distutils/tests/test_config.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_config.py rename to Src/StdLib/Lib/distutils/tests/test_config.py diff --git a/StdLib/Lib/distutils/tests/test_config_cmd.py b/Src/StdLib/Lib/distutils/tests/test_config_cmd.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_config_cmd.py rename to Src/StdLib/Lib/distutils/tests/test_config_cmd.py diff --git a/StdLib/Lib/distutils/tests/test_core.py b/Src/StdLib/Lib/distutils/tests/test_core.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_core.py rename to Src/StdLib/Lib/distutils/tests/test_core.py diff --git a/StdLib/Lib/distutils/tests/test_cygwinccompiler.py b/Src/StdLib/Lib/distutils/tests/test_cygwinccompiler.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_cygwinccompiler.py rename to Src/StdLib/Lib/distutils/tests/test_cygwinccompiler.py diff --git a/StdLib/Lib/distutils/tests/test_dep_util.py b/Src/StdLib/Lib/distutils/tests/test_dep_util.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_dep_util.py rename to Src/StdLib/Lib/distutils/tests/test_dep_util.py diff --git a/StdLib/Lib/distutils/tests/test_dir_util.py b/Src/StdLib/Lib/distutils/tests/test_dir_util.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_dir_util.py rename to Src/StdLib/Lib/distutils/tests/test_dir_util.py diff --git a/StdLib/Lib/distutils/tests/test_dist.py b/Src/StdLib/Lib/distutils/tests/test_dist.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_dist.py rename to Src/StdLib/Lib/distutils/tests/test_dist.py diff --git a/StdLib/Lib/distutils/tests/test_extension.py b/Src/StdLib/Lib/distutils/tests/test_extension.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_extension.py rename to Src/StdLib/Lib/distutils/tests/test_extension.py diff --git a/StdLib/Lib/distutils/tests/test_file_util.py b/Src/StdLib/Lib/distutils/tests/test_file_util.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_file_util.py rename to Src/StdLib/Lib/distutils/tests/test_file_util.py diff --git a/StdLib/Lib/distutils/tests/test_filelist.py b/Src/StdLib/Lib/distutils/tests/test_filelist.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_filelist.py rename to Src/StdLib/Lib/distutils/tests/test_filelist.py diff --git a/StdLib/Lib/distutils/tests/test_install.py b/Src/StdLib/Lib/distutils/tests/test_install.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_install.py rename to Src/StdLib/Lib/distutils/tests/test_install.py diff --git a/StdLib/Lib/distutils/tests/test_install_data.py b/Src/StdLib/Lib/distutils/tests/test_install_data.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_install_data.py rename to Src/StdLib/Lib/distutils/tests/test_install_data.py diff --git a/StdLib/Lib/distutils/tests/test_install_headers.py b/Src/StdLib/Lib/distutils/tests/test_install_headers.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_install_headers.py rename to Src/StdLib/Lib/distutils/tests/test_install_headers.py diff --git a/StdLib/Lib/distutils/tests/test_install_lib.py b/Src/StdLib/Lib/distutils/tests/test_install_lib.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_install_lib.py rename to Src/StdLib/Lib/distutils/tests/test_install_lib.py diff --git a/StdLib/Lib/distutils/tests/test_install_scripts.py b/Src/StdLib/Lib/distutils/tests/test_install_scripts.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_install_scripts.py rename to Src/StdLib/Lib/distutils/tests/test_install_scripts.py diff --git a/StdLib/Lib/distutils/tests/test_log.py b/Src/StdLib/Lib/distutils/tests/test_log.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_log.py rename to Src/StdLib/Lib/distutils/tests/test_log.py diff --git a/StdLib/Lib/distutils/tests/test_msvc9compiler.py b/Src/StdLib/Lib/distutils/tests/test_msvc9compiler.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_msvc9compiler.py rename to Src/StdLib/Lib/distutils/tests/test_msvc9compiler.py diff --git a/StdLib/Lib/distutils/tests/test_register.py b/Src/StdLib/Lib/distutils/tests/test_register.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_register.py rename to Src/StdLib/Lib/distutils/tests/test_register.py diff --git a/StdLib/Lib/distutils/tests/test_sdist.py b/Src/StdLib/Lib/distutils/tests/test_sdist.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_sdist.py rename to Src/StdLib/Lib/distutils/tests/test_sdist.py diff --git a/StdLib/Lib/distutils/tests/test_spawn.py b/Src/StdLib/Lib/distutils/tests/test_spawn.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_spawn.py rename to Src/StdLib/Lib/distutils/tests/test_spawn.py diff --git a/StdLib/Lib/distutils/tests/test_sysconfig.py b/Src/StdLib/Lib/distutils/tests/test_sysconfig.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_sysconfig.py rename to Src/StdLib/Lib/distutils/tests/test_sysconfig.py diff --git a/StdLib/Lib/distutils/tests/test_text_file.py b/Src/StdLib/Lib/distutils/tests/test_text_file.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_text_file.py rename to Src/StdLib/Lib/distutils/tests/test_text_file.py diff --git a/StdLib/Lib/distutils/tests/test_unixccompiler.py b/Src/StdLib/Lib/distutils/tests/test_unixccompiler.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_unixccompiler.py rename to Src/StdLib/Lib/distutils/tests/test_unixccompiler.py diff --git a/StdLib/Lib/distutils/tests/test_upload.py b/Src/StdLib/Lib/distutils/tests/test_upload.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_upload.py rename to Src/StdLib/Lib/distutils/tests/test_upload.py diff --git a/StdLib/Lib/distutils/tests/test_util.py b/Src/StdLib/Lib/distutils/tests/test_util.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_util.py rename to Src/StdLib/Lib/distutils/tests/test_util.py diff --git a/StdLib/Lib/distutils/tests/test_version.py b/Src/StdLib/Lib/distutils/tests/test_version.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_version.py rename to Src/StdLib/Lib/distutils/tests/test_version.py diff --git a/StdLib/Lib/distutils/tests/test_versionpredicate.py b/Src/StdLib/Lib/distutils/tests/test_versionpredicate.py similarity index 100% rename from StdLib/Lib/distutils/tests/test_versionpredicate.py rename to Src/StdLib/Lib/distutils/tests/test_versionpredicate.py diff --git a/StdLib/Lib/distutils/text_file.py b/Src/StdLib/Lib/distutils/text_file.py similarity index 100% rename from StdLib/Lib/distutils/text_file.py rename to Src/StdLib/Lib/distutils/text_file.py diff --git a/StdLib/Lib/distutils/unixccompiler.py b/Src/StdLib/Lib/distutils/unixccompiler.py similarity index 100% rename from StdLib/Lib/distutils/unixccompiler.py rename to Src/StdLib/Lib/distutils/unixccompiler.py diff --git a/StdLib/Lib/distutils/util.py b/Src/StdLib/Lib/distutils/util.py similarity index 100% rename from StdLib/Lib/distutils/util.py rename to Src/StdLib/Lib/distutils/util.py diff --git a/StdLib/Lib/distutils/version.py b/Src/StdLib/Lib/distutils/version.py similarity index 100% rename from StdLib/Lib/distutils/version.py rename to Src/StdLib/Lib/distutils/version.py diff --git a/StdLib/Lib/distutils/versionpredicate.py b/Src/StdLib/Lib/distutils/versionpredicate.py similarity index 100% rename from StdLib/Lib/distutils/versionpredicate.py rename to Src/StdLib/Lib/distutils/versionpredicate.py diff --git a/StdLib/Lib/doctest.py b/Src/StdLib/Lib/doctest.py similarity index 100% rename from StdLib/Lib/doctest.py rename to Src/StdLib/Lib/doctest.py diff --git a/StdLib/Lib/dummy_threading.py b/Src/StdLib/Lib/dummy_threading.py similarity index 100% rename from StdLib/Lib/dummy_threading.py rename to Src/StdLib/Lib/dummy_threading.py diff --git a/StdLib/Lib/email/__init__.py b/Src/StdLib/Lib/email/__init__.py similarity index 100% rename from StdLib/Lib/email/__init__.py rename to Src/StdLib/Lib/email/__init__.py diff --git a/StdLib/Lib/email/_encoded_words.py b/Src/StdLib/Lib/email/_encoded_words.py similarity index 100% rename from StdLib/Lib/email/_encoded_words.py rename to Src/StdLib/Lib/email/_encoded_words.py diff --git a/StdLib/Lib/email/_header_value_parser.py b/Src/StdLib/Lib/email/_header_value_parser.py similarity index 100% rename from StdLib/Lib/email/_header_value_parser.py rename to Src/StdLib/Lib/email/_header_value_parser.py diff --git a/StdLib/Lib/email/_parseaddr.py b/Src/StdLib/Lib/email/_parseaddr.py similarity index 100% rename from StdLib/Lib/email/_parseaddr.py rename to Src/StdLib/Lib/email/_parseaddr.py diff --git a/StdLib/Lib/email/_policybase.py b/Src/StdLib/Lib/email/_policybase.py similarity index 100% rename from StdLib/Lib/email/_policybase.py rename to Src/StdLib/Lib/email/_policybase.py diff --git a/StdLib/Lib/email/architecture.rst b/Src/StdLib/Lib/email/architecture.rst similarity index 100% rename from StdLib/Lib/email/architecture.rst rename to Src/StdLib/Lib/email/architecture.rst diff --git a/StdLib/Lib/email/base64mime.py b/Src/StdLib/Lib/email/base64mime.py similarity index 100% rename from StdLib/Lib/email/base64mime.py rename to Src/StdLib/Lib/email/base64mime.py diff --git a/StdLib/Lib/email/charset.py b/Src/StdLib/Lib/email/charset.py similarity index 100% rename from StdLib/Lib/email/charset.py rename to Src/StdLib/Lib/email/charset.py diff --git a/StdLib/Lib/email/contentmanager.py b/Src/StdLib/Lib/email/contentmanager.py similarity index 100% rename from StdLib/Lib/email/contentmanager.py rename to Src/StdLib/Lib/email/contentmanager.py diff --git a/StdLib/Lib/email/encoders.py b/Src/StdLib/Lib/email/encoders.py similarity index 100% rename from StdLib/Lib/email/encoders.py rename to Src/StdLib/Lib/email/encoders.py diff --git a/StdLib/Lib/email/errors.py b/Src/StdLib/Lib/email/errors.py similarity index 100% rename from StdLib/Lib/email/errors.py rename to Src/StdLib/Lib/email/errors.py diff --git a/StdLib/Lib/email/feedparser.py b/Src/StdLib/Lib/email/feedparser.py similarity index 100% rename from StdLib/Lib/email/feedparser.py rename to Src/StdLib/Lib/email/feedparser.py diff --git a/StdLib/Lib/email/generator.py b/Src/StdLib/Lib/email/generator.py similarity index 100% rename from StdLib/Lib/email/generator.py rename to Src/StdLib/Lib/email/generator.py diff --git a/StdLib/Lib/email/header.py b/Src/StdLib/Lib/email/header.py similarity index 100% rename from StdLib/Lib/email/header.py rename to Src/StdLib/Lib/email/header.py diff --git a/StdLib/Lib/email/headerregistry.py b/Src/StdLib/Lib/email/headerregistry.py similarity index 100% rename from StdLib/Lib/email/headerregistry.py rename to Src/StdLib/Lib/email/headerregistry.py diff --git a/StdLib/Lib/email/iterators.py b/Src/StdLib/Lib/email/iterators.py similarity index 100% rename from StdLib/Lib/email/iterators.py rename to Src/StdLib/Lib/email/iterators.py diff --git a/StdLib/Lib/email/message.py b/Src/StdLib/Lib/email/message.py similarity index 100% rename from StdLib/Lib/email/message.py rename to Src/StdLib/Lib/email/message.py diff --git a/StdLib/Lib/email/mime/__init__.py b/Src/StdLib/Lib/email/mime/__init__.py similarity index 100% rename from StdLib/Lib/email/mime/__init__.py rename to Src/StdLib/Lib/email/mime/__init__.py diff --git a/StdLib/Lib/email/mime/application.py b/Src/StdLib/Lib/email/mime/application.py similarity index 100% rename from StdLib/Lib/email/mime/application.py rename to Src/StdLib/Lib/email/mime/application.py diff --git a/StdLib/Lib/email/mime/audio.py b/Src/StdLib/Lib/email/mime/audio.py similarity index 100% rename from StdLib/Lib/email/mime/audio.py rename to Src/StdLib/Lib/email/mime/audio.py diff --git a/StdLib/Lib/email/mime/base.py b/Src/StdLib/Lib/email/mime/base.py similarity index 100% rename from StdLib/Lib/email/mime/base.py rename to Src/StdLib/Lib/email/mime/base.py diff --git a/StdLib/Lib/email/mime/image.py b/Src/StdLib/Lib/email/mime/image.py similarity index 100% rename from StdLib/Lib/email/mime/image.py rename to Src/StdLib/Lib/email/mime/image.py diff --git a/StdLib/Lib/email/mime/message.py b/Src/StdLib/Lib/email/mime/message.py similarity index 100% rename from StdLib/Lib/email/mime/message.py rename to Src/StdLib/Lib/email/mime/message.py diff --git a/StdLib/Lib/email/mime/multipart.py b/Src/StdLib/Lib/email/mime/multipart.py similarity index 100% rename from StdLib/Lib/email/mime/multipart.py rename to Src/StdLib/Lib/email/mime/multipart.py diff --git a/StdLib/Lib/email/mime/nonmultipart.py b/Src/StdLib/Lib/email/mime/nonmultipart.py similarity index 100% rename from StdLib/Lib/email/mime/nonmultipart.py rename to Src/StdLib/Lib/email/mime/nonmultipart.py diff --git a/StdLib/Lib/email/mime/text.py b/Src/StdLib/Lib/email/mime/text.py similarity index 100% rename from StdLib/Lib/email/mime/text.py rename to Src/StdLib/Lib/email/mime/text.py diff --git a/StdLib/Lib/email/parser.py b/Src/StdLib/Lib/email/parser.py similarity index 100% rename from StdLib/Lib/email/parser.py rename to Src/StdLib/Lib/email/parser.py diff --git a/StdLib/Lib/email/policy.py b/Src/StdLib/Lib/email/policy.py similarity index 100% rename from StdLib/Lib/email/policy.py rename to Src/StdLib/Lib/email/policy.py diff --git a/StdLib/Lib/email/quoprimime.py b/Src/StdLib/Lib/email/quoprimime.py similarity index 100% rename from StdLib/Lib/email/quoprimime.py rename to Src/StdLib/Lib/email/quoprimime.py diff --git a/StdLib/Lib/email/utils.py b/Src/StdLib/Lib/email/utils.py similarity index 100% rename from StdLib/Lib/email/utils.py rename to Src/StdLib/Lib/email/utils.py diff --git a/StdLib/Lib/encodings/__init__.py b/Src/StdLib/Lib/encodings/__init__.py similarity index 100% rename from StdLib/Lib/encodings/__init__.py rename to Src/StdLib/Lib/encodings/__init__.py diff --git a/StdLib/Lib/encodings/aliases.py b/Src/StdLib/Lib/encodings/aliases.py similarity index 100% rename from StdLib/Lib/encodings/aliases.py rename to Src/StdLib/Lib/encodings/aliases.py diff --git a/StdLib/Lib/encodings/ascii.py b/Src/StdLib/Lib/encodings/ascii.py similarity index 100% rename from StdLib/Lib/encodings/ascii.py rename to Src/StdLib/Lib/encodings/ascii.py diff --git a/StdLib/Lib/encodings/base64_codec.py b/Src/StdLib/Lib/encodings/base64_codec.py similarity index 100% rename from StdLib/Lib/encodings/base64_codec.py rename to Src/StdLib/Lib/encodings/base64_codec.py diff --git a/StdLib/Lib/encodings/big5.py b/Src/StdLib/Lib/encodings/big5.py similarity index 100% rename from StdLib/Lib/encodings/big5.py rename to Src/StdLib/Lib/encodings/big5.py diff --git a/StdLib/Lib/encodings/big5hkscs.py b/Src/StdLib/Lib/encodings/big5hkscs.py similarity index 100% rename from StdLib/Lib/encodings/big5hkscs.py rename to Src/StdLib/Lib/encodings/big5hkscs.py diff --git a/StdLib/Lib/encodings/bz2_codec.py b/Src/StdLib/Lib/encodings/bz2_codec.py similarity index 100% rename from StdLib/Lib/encodings/bz2_codec.py rename to Src/StdLib/Lib/encodings/bz2_codec.py diff --git a/StdLib/Lib/encodings/charmap.py b/Src/StdLib/Lib/encodings/charmap.py similarity index 100% rename from StdLib/Lib/encodings/charmap.py rename to Src/StdLib/Lib/encodings/charmap.py diff --git a/StdLib/Lib/encodings/cp037.py b/Src/StdLib/Lib/encodings/cp037.py similarity index 100% rename from StdLib/Lib/encodings/cp037.py rename to Src/StdLib/Lib/encodings/cp037.py diff --git a/StdLib/Lib/encodings/cp1006.py b/Src/StdLib/Lib/encodings/cp1006.py similarity index 100% rename from StdLib/Lib/encodings/cp1006.py rename to Src/StdLib/Lib/encodings/cp1006.py diff --git a/StdLib/Lib/encodings/cp1026.py b/Src/StdLib/Lib/encodings/cp1026.py similarity index 100% rename from StdLib/Lib/encodings/cp1026.py rename to Src/StdLib/Lib/encodings/cp1026.py diff --git a/StdLib/Lib/encodings/cp1125.py b/Src/StdLib/Lib/encodings/cp1125.py similarity index 100% rename from StdLib/Lib/encodings/cp1125.py rename to Src/StdLib/Lib/encodings/cp1125.py diff --git a/StdLib/Lib/encodings/cp1140.py b/Src/StdLib/Lib/encodings/cp1140.py similarity index 100% rename from StdLib/Lib/encodings/cp1140.py rename to Src/StdLib/Lib/encodings/cp1140.py diff --git a/StdLib/Lib/encodings/cp1250.py b/Src/StdLib/Lib/encodings/cp1250.py similarity index 100% rename from StdLib/Lib/encodings/cp1250.py rename to Src/StdLib/Lib/encodings/cp1250.py diff --git a/StdLib/Lib/encodings/cp1251.py b/Src/StdLib/Lib/encodings/cp1251.py similarity index 100% rename from StdLib/Lib/encodings/cp1251.py rename to Src/StdLib/Lib/encodings/cp1251.py diff --git a/StdLib/Lib/encodings/cp1252.py b/Src/StdLib/Lib/encodings/cp1252.py similarity index 100% rename from StdLib/Lib/encodings/cp1252.py rename to Src/StdLib/Lib/encodings/cp1252.py diff --git a/StdLib/Lib/encodings/cp1253.py b/Src/StdLib/Lib/encodings/cp1253.py similarity index 100% rename from StdLib/Lib/encodings/cp1253.py rename to Src/StdLib/Lib/encodings/cp1253.py diff --git a/StdLib/Lib/encodings/cp1254.py b/Src/StdLib/Lib/encodings/cp1254.py similarity index 100% rename from StdLib/Lib/encodings/cp1254.py rename to Src/StdLib/Lib/encodings/cp1254.py diff --git a/StdLib/Lib/encodings/cp1255.py b/Src/StdLib/Lib/encodings/cp1255.py similarity index 100% rename from StdLib/Lib/encodings/cp1255.py rename to Src/StdLib/Lib/encodings/cp1255.py diff --git a/StdLib/Lib/encodings/cp1256.py b/Src/StdLib/Lib/encodings/cp1256.py similarity index 100% rename from StdLib/Lib/encodings/cp1256.py rename to Src/StdLib/Lib/encodings/cp1256.py diff --git a/StdLib/Lib/encodings/cp1257.py b/Src/StdLib/Lib/encodings/cp1257.py similarity index 100% rename from StdLib/Lib/encodings/cp1257.py rename to Src/StdLib/Lib/encodings/cp1257.py diff --git a/StdLib/Lib/encodings/cp1258.py b/Src/StdLib/Lib/encodings/cp1258.py similarity index 100% rename from StdLib/Lib/encodings/cp1258.py rename to Src/StdLib/Lib/encodings/cp1258.py diff --git a/StdLib/Lib/encodings/cp273.py b/Src/StdLib/Lib/encodings/cp273.py similarity index 100% rename from StdLib/Lib/encodings/cp273.py rename to Src/StdLib/Lib/encodings/cp273.py diff --git a/StdLib/Lib/encodings/cp424.py b/Src/StdLib/Lib/encodings/cp424.py similarity index 100% rename from StdLib/Lib/encodings/cp424.py rename to Src/StdLib/Lib/encodings/cp424.py diff --git a/StdLib/Lib/encodings/cp437.py b/Src/StdLib/Lib/encodings/cp437.py similarity index 100% rename from StdLib/Lib/encodings/cp437.py rename to Src/StdLib/Lib/encodings/cp437.py diff --git a/StdLib/Lib/encodings/cp500.py b/Src/StdLib/Lib/encodings/cp500.py similarity index 100% rename from StdLib/Lib/encodings/cp500.py rename to Src/StdLib/Lib/encodings/cp500.py diff --git a/StdLib/Lib/encodings/cp65001.py b/Src/StdLib/Lib/encodings/cp65001.py similarity index 100% rename from StdLib/Lib/encodings/cp65001.py rename to Src/StdLib/Lib/encodings/cp65001.py diff --git a/StdLib/Lib/encodings/cp720.py b/Src/StdLib/Lib/encodings/cp720.py similarity index 100% rename from StdLib/Lib/encodings/cp720.py rename to Src/StdLib/Lib/encodings/cp720.py diff --git a/StdLib/Lib/encodings/cp737.py b/Src/StdLib/Lib/encodings/cp737.py similarity index 100% rename from StdLib/Lib/encodings/cp737.py rename to Src/StdLib/Lib/encodings/cp737.py diff --git a/StdLib/Lib/encodings/cp775.py b/Src/StdLib/Lib/encodings/cp775.py similarity index 100% rename from StdLib/Lib/encodings/cp775.py rename to Src/StdLib/Lib/encodings/cp775.py diff --git a/StdLib/Lib/encodings/cp850.py b/Src/StdLib/Lib/encodings/cp850.py similarity index 100% rename from StdLib/Lib/encodings/cp850.py rename to Src/StdLib/Lib/encodings/cp850.py diff --git a/StdLib/Lib/encodings/cp852.py b/Src/StdLib/Lib/encodings/cp852.py similarity index 100% rename from StdLib/Lib/encodings/cp852.py rename to Src/StdLib/Lib/encodings/cp852.py diff --git a/StdLib/Lib/encodings/cp855.py b/Src/StdLib/Lib/encodings/cp855.py similarity index 100% rename from StdLib/Lib/encodings/cp855.py rename to Src/StdLib/Lib/encodings/cp855.py diff --git a/StdLib/Lib/encodings/cp856.py b/Src/StdLib/Lib/encodings/cp856.py similarity index 100% rename from StdLib/Lib/encodings/cp856.py rename to Src/StdLib/Lib/encodings/cp856.py diff --git a/StdLib/Lib/encodings/cp857.py b/Src/StdLib/Lib/encodings/cp857.py similarity index 100% rename from StdLib/Lib/encodings/cp857.py rename to Src/StdLib/Lib/encodings/cp857.py diff --git a/StdLib/Lib/encodings/cp858.py b/Src/StdLib/Lib/encodings/cp858.py similarity index 100% rename from StdLib/Lib/encodings/cp858.py rename to Src/StdLib/Lib/encodings/cp858.py diff --git a/StdLib/Lib/encodings/cp860.py b/Src/StdLib/Lib/encodings/cp860.py similarity index 100% rename from StdLib/Lib/encodings/cp860.py rename to Src/StdLib/Lib/encodings/cp860.py diff --git a/StdLib/Lib/encodings/cp861.py b/Src/StdLib/Lib/encodings/cp861.py similarity index 100% rename from StdLib/Lib/encodings/cp861.py rename to Src/StdLib/Lib/encodings/cp861.py diff --git a/StdLib/Lib/encodings/cp862.py b/Src/StdLib/Lib/encodings/cp862.py similarity index 100% rename from StdLib/Lib/encodings/cp862.py rename to Src/StdLib/Lib/encodings/cp862.py diff --git a/StdLib/Lib/encodings/cp863.py b/Src/StdLib/Lib/encodings/cp863.py similarity index 100% rename from StdLib/Lib/encodings/cp863.py rename to Src/StdLib/Lib/encodings/cp863.py diff --git a/StdLib/Lib/encodings/cp864.py b/Src/StdLib/Lib/encodings/cp864.py similarity index 100% rename from StdLib/Lib/encodings/cp864.py rename to Src/StdLib/Lib/encodings/cp864.py diff --git a/StdLib/Lib/encodings/cp865.py b/Src/StdLib/Lib/encodings/cp865.py similarity index 100% rename from StdLib/Lib/encodings/cp865.py rename to Src/StdLib/Lib/encodings/cp865.py diff --git a/StdLib/Lib/encodings/cp866.py b/Src/StdLib/Lib/encodings/cp866.py similarity index 100% rename from StdLib/Lib/encodings/cp866.py rename to Src/StdLib/Lib/encodings/cp866.py diff --git a/StdLib/Lib/encodings/cp869.py b/Src/StdLib/Lib/encodings/cp869.py similarity index 100% rename from StdLib/Lib/encodings/cp869.py rename to Src/StdLib/Lib/encodings/cp869.py diff --git a/StdLib/Lib/encodings/cp874.py b/Src/StdLib/Lib/encodings/cp874.py similarity index 100% rename from StdLib/Lib/encodings/cp874.py rename to Src/StdLib/Lib/encodings/cp874.py diff --git a/StdLib/Lib/encodings/cp875.py b/Src/StdLib/Lib/encodings/cp875.py similarity index 100% rename from StdLib/Lib/encodings/cp875.py rename to Src/StdLib/Lib/encodings/cp875.py diff --git a/StdLib/Lib/encodings/cp932.py b/Src/StdLib/Lib/encodings/cp932.py similarity index 100% rename from StdLib/Lib/encodings/cp932.py rename to Src/StdLib/Lib/encodings/cp932.py diff --git a/StdLib/Lib/encodings/cp949.py b/Src/StdLib/Lib/encodings/cp949.py similarity index 100% rename from StdLib/Lib/encodings/cp949.py rename to Src/StdLib/Lib/encodings/cp949.py diff --git a/StdLib/Lib/encodings/cp950.py b/Src/StdLib/Lib/encodings/cp950.py similarity index 100% rename from StdLib/Lib/encodings/cp950.py rename to Src/StdLib/Lib/encodings/cp950.py diff --git a/StdLib/Lib/encodings/euc_jis_2004.py b/Src/StdLib/Lib/encodings/euc_jis_2004.py similarity index 100% rename from StdLib/Lib/encodings/euc_jis_2004.py rename to Src/StdLib/Lib/encodings/euc_jis_2004.py diff --git a/StdLib/Lib/encodings/euc_jisx0213.py b/Src/StdLib/Lib/encodings/euc_jisx0213.py similarity index 100% rename from StdLib/Lib/encodings/euc_jisx0213.py rename to Src/StdLib/Lib/encodings/euc_jisx0213.py diff --git a/StdLib/Lib/encodings/euc_jp.py b/Src/StdLib/Lib/encodings/euc_jp.py similarity index 100% rename from StdLib/Lib/encodings/euc_jp.py rename to Src/StdLib/Lib/encodings/euc_jp.py diff --git a/StdLib/Lib/encodings/euc_kr.py b/Src/StdLib/Lib/encodings/euc_kr.py similarity index 100% rename from StdLib/Lib/encodings/euc_kr.py rename to Src/StdLib/Lib/encodings/euc_kr.py diff --git a/StdLib/Lib/encodings/gb18030.py b/Src/StdLib/Lib/encodings/gb18030.py similarity index 100% rename from StdLib/Lib/encodings/gb18030.py rename to Src/StdLib/Lib/encodings/gb18030.py diff --git a/StdLib/Lib/encodings/gb2312.py b/Src/StdLib/Lib/encodings/gb2312.py similarity index 100% rename from StdLib/Lib/encodings/gb2312.py rename to Src/StdLib/Lib/encodings/gb2312.py diff --git a/StdLib/Lib/encodings/gbk.py b/Src/StdLib/Lib/encodings/gbk.py similarity index 100% rename from StdLib/Lib/encodings/gbk.py rename to Src/StdLib/Lib/encodings/gbk.py diff --git a/StdLib/Lib/encodings/hex_codec.py b/Src/StdLib/Lib/encodings/hex_codec.py similarity index 100% rename from StdLib/Lib/encodings/hex_codec.py rename to Src/StdLib/Lib/encodings/hex_codec.py diff --git a/StdLib/Lib/encodings/hp_roman8.py b/Src/StdLib/Lib/encodings/hp_roman8.py similarity index 100% rename from StdLib/Lib/encodings/hp_roman8.py rename to Src/StdLib/Lib/encodings/hp_roman8.py diff --git a/StdLib/Lib/encodings/hz.py b/Src/StdLib/Lib/encodings/hz.py similarity index 100% rename from StdLib/Lib/encodings/hz.py rename to Src/StdLib/Lib/encodings/hz.py diff --git a/StdLib/Lib/encodings/idna.py b/Src/StdLib/Lib/encodings/idna.py similarity index 100% rename from StdLib/Lib/encodings/idna.py rename to Src/StdLib/Lib/encodings/idna.py diff --git a/StdLib/Lib/encodings/iso2022_jp.py b/Src/StdLib/Lib/encodings/iso2022_jp.py similarity index 100% rename from StdLib/Lib/encodings/iso2022_jp.py rename to Src/StdLib/Lib/encodings/iso2022_jp.py diff --git a/StdLib/Lib/encodings/iso2022_jp_1.py b/Src/StdLib/Lib/encodings/iso2022_jp_1.py similarity index 100% rename from StdLib/Lib/encodings/iso2022_jp_1.py rename to Src/StdLib/Lib/encodings/iso2022_jp_1.py diff --git a/StdLib/Lib/encodings/iso2022_jp_2.py b/Src/StdLib/Lib/encodings/iso2022_jp_2.py similarity index 100% rename from StdLib/Lib/encodings/iso2022_jp_2.py rename to Src/StdLib/Lib/encodings/iso2022_jp_2.py diff --git a/StdLib/Lib/encodings/iso2022_jp_2004.py b/Src/StdLib/Lib/encodings/iso2022_jp_2004.py similarity index 100% rename from StdLib/Lib/encodings/iso2022_jp_2004.py rename to Src/StdLib/Lib/encodings/iso2022_jp_2004.py diff --git a/StdLib/Lib/encodings/iso2022_jp_3.py b/Src/StdLib/Lib/encodings/iso2022_jp_3.py similarity index 100% rename from StdLib/Lib/encodings/iso2022_jp_3.py rename to Src/StdLib/Lib/encodings/iso2022_jp_3.py diff --git a/StdLib/Lib/encodings/iso2022_jp_ext.py b/Src/StdLib/Lib/encodings/iso2022_jp_ext.py similarity index 100% rename from StdLib/Lib/encodings/iso2022_jp_ext.py rename to Src/StdLib/Lib/encodings/iso2022_jp_ext.py diff --git a/StdLib/Lib/encodings/iso2022_kr.py b/Src/StdLib/Lib/encodings/iso2022_kr.py similarity index 100% rename from StdLib/Lib/encodings/iso2022_kr.py rename to Src/StdLib/Lib/encodings/iso2022_kr.py diff --git a/StdLib/Lib/encodings/iso8859_1.py b/Src/StdLib/Lib/encodings/iso8859_1.py similarity index 100% rename from StdLib/Lib/encodings/iso8859_1.py rename to Src/StdLib/Lib/encodings/iso8859_1.py diff --git a/StdLib/Lib/encodings/iso8859_10.py b/Src/StdLib/Lib/encodings/iso8859_10.py similarity index 100% rename from StdLib/Lib/encodings/iso8859_10.py rename to Src/StdLib/Lib/encodings/iso8859_10.py diff --git a/StdLib/Lib/encodings/iso8859_11.py b/Src/StdLib/Lib/encodings/iso8859_11.py similarity index 100% rename from StdLib/Lib/encodings/iso8859_11.py rename to Src/StdLib/Lib/encodings/iso8859_11.py diff --git a/StdLib/Lib/encodings/iso8859_13.py b/Src/StdLib/Lib/encodings/iso8859_13.py similarity index 100% rename from StdLib/Lib/encodings/iso8859_13.py rename to Src/StdLib/Lib/encodings/iso8859_13.py diff --git a/StdLib/Lib/encodings/iso8859_14.py b/Src/StdLib/Lib/encodings/iso8859_14.py similarity index 100% rename from StdLib/Lib/encodings/iso8859_14.py rename to Src/StdLib/Lib/encodings/iso8859_14.py diff --git a/StdLib/Lib/encodings/iso8859_15.py b/Src/StdLib/Lib/encodings/iso8859_15.py similarity index 100% rename from StdLib/Lib/encodings/iso8859_15.py rename to Src/StdLib/Lib/encodings/iso8859_15.py diff --git a/StdLib/Lib/encodings/iso8859_16.py b/Src/StdLib/Lib/encodings/iso8859_16.py similarity index 100% rename from StdLib/Lib/encodings/iso8859_16.py rename to Src/StdLib/Lib/encodings/iso8859_16.py diff --git a/StdLib/Lib/encodings/iso8859_2.py b/Src/StdLib/Lib/encodings/iso8859_2.py similarity index 100% rename from StdLib/Lib/encodings/iso8859_2.py rename to Src/StdLib/Lib/encodings/iso8859_2.py diff --git a/StdLib/Lib/encodings/iso8859_3.py b/Src/StdLib/Lib/encodings/iso8859_3.py similarity index 100% rename from StdLib/Lib/encodings/iso8859_3.py rename to Src/StdLib/Lib/encodings/iso8859_3.py diff --git a/StdLib/Lib/encodings/iso8859_4.py b/Src/StdLib/Lib/encodings/iso8859_4.py similarity index 100% rename from StdLib/Lib/encodings/iso8859_4.py rename to Src/StdLib/Lib/encodings/iso8859_4.py diff --git a/StdLib/Lib/encodings/iso8859_5.py b/Src/StdLib/Lib/encodings/iso8859_5.py similarity index 100% rename from StdLib/Lib/encodings/iso8859_5.py rename to Src/StdLib/Lib/encodings/iso8859_5.py diff --git a/StdLib/Lib/encodings/iso8859_6.py b/Src/StdLib/Lib/encodings/iso8859_6.py similarity index 100% rename from StdLib/Lib/encodings/iso8859_6.py rename to Src/StdLib/Lib/encodings/iso8859_6.py diff --git a/StdLib/Lib/encodings/iso8859_7.py b/Src/StdLib/Lib/encodings/iso8859_7.py similarity index 100% rename from StdLib/Lib/encodings/iso8859_7.py rename to Src/StdLib/Lib/encodings/iso8859_7.py diff --git a/StdLib/Lib/encodings/iso8859_8.py b/Src/StdLib/Lib/encodings/iso8859_8.py similarity index 100% rename from StdLib/Lib/encodings/iso8859_8.py rename to Src/StdLib/Lib/encodings/iso8859_8.py diff --git a/StdLib/Lib/encodings/iso8859_9.py b/Src/StdLib/Lib/encodings/iso8859_9.py similarity index 100% rename from StdLib/Lib/encodings/iso8859_9.py rename to Src/StdLib/Lib/encodings/iso8859_9.py diff --git a/StdLib/Lib/encodings/johab.py b/Src/StdLib/Lib/encodings/johab.py similarity index 100% rename from StdLib/Lib/encodings/johab.py rename to Src/StdLib/Lib/encodings/johab.py diff --git a/StdLib/Lib/encodings/koi8_r.py b/Src/StdLib/Lib/encodings/koi8_r.py similarity index 100% rename from StdLib/Lib/encodings/koi8_r.py rename to Src/StdLib/Lib/encodings/koi8_r.py diff --git a/StdLib/Lib/encodings/koi8_u.py b/Src/StdLib/Lib/encodings/koi8_u.py similarity index 100% rename from StdLib/Lib/encodings/koi8_u.py rename to Src/StdLib/Lib/encodings/koi8_u.py diff --git a/StdLib/Lib/encodings/latin_1.py b/Src/StdLib/Lib/encodings/latin_1.py similarity index 100% rename from StdLib/Lib/encodings/latin_1.py rename to Src/StdLib/Lib/encodings/latin_1.py diff --git a/StdLib/Lib/encodings/mac_arabic.py b/Src/StdLib/Lib/encodings/mac_arabic.py similarity index 100% rename from StdLib/Lib/encodings/mac_arabic.py rename to Src/StdLib/Lib/encodings/mac_arabic.py diff --git a/StdLib/Lib/encodings/mac_centeuro.py b/Src/StdLib/Lib/encodings/mac_centeuro.py similarity index 100% rename from StdLib/Lib/encodings/mac_centeuro.py rename to Src/StdLib/Lib/encodings/mac_centeuro.py diff --git a/StdLib/Lib/encodings/mac_croatian.py b/Src/StdLib/Lib/encodings/mac_croatian.py similarity index 100% rename from StdLib/Lib/encodings/mac_croatian.py rename to Src/StdLib/Lib/encodings/mac_croatian.py diff --git a/StdLib/Lib/encodings/mac_cyrillic.py b/Src/StdLib/Lib/encodings/mac_cyrillic.py similarity index 100% rename from StdLib/Lib/encodings/mac_cyrillic.py rename to Src/StdLib/Lib/encodings/mac_cyrillic.py diff --git a/StdLib/Lib/encodings/mac_farsi.py b/Src/StdLib/Lib/encodings/mac_farsi.py similarity index 100% rename from StdLib/Lib/encodings/mac_farsi.py rename to Src/StdLib/Lib/encodings/mac_farsi.py diff --git a/StdLib/Lib/encodings/mac_greek.py b/Src/StdLib/Lib/encodings/mac_greek.py similarity index 100% rename from StdLib/Lib/encodings/mac_greek.py rename to Src/StdLib/Lib/encodings/mac_greek.py diff --git a/StdLib/Lib/encodings/mac_iceland.py b/Src/StdLib/Lib/encodings/mac_iceland.py similarity index 100% rename from StdLib/Lib/encodings/mac_iceland.py rename to Src/StdLib/Lib/encodings/mac_iceland.py diff --git a/StdLib/Lib/encodings/mac_latin2.py b/Src/StdLib/Lib/encodings/mac_latin2.py similarity index 100% rename from StdLib/Lib/encodings/mac_latin2.py rename to Src/StdLib/Lib/encodings/mac_latin2.py diff --git a/StdLib/Lib/encodings/mac_roman.py b/Src/StdLib/Lib/encodings/mac_roman.py similarity index 100% rename from StdLib/Lib/encodings/mac_roman.py rename to Src/StdLib/Lib/encodings/mac_roman.py diff --git a/StdLib/Lib/encodings/mac_romanian.py b/Src/StdLib/Lib/encodings/mac_romanian.py similarity index 100% rename from StdLib/Lib/encodings/mac_romanian.py rename to Src/StdLib/Lib/encodings/mac_romanian.py diff --git a/StdLib/Lib/encodings/mac_turkish.py b/Src/StdLib/Lib/encodings/mac_turkish.py similarity index 100% rename from StdLib/Lib/encodings/mac_turkish.py rename to Src/StdLib/Lib/encodings/mac_turkish.py diff --git a/StdLib/Lib/encodings/mbcs.py b/Src/StdLib/Lib/encodings/mbcs.py similarity index 100% rename from StdLib/Lib/encodings/mbcs.py rename to Src/StdLib/Lib/encodings/mbcs.py diff --git a/StdLib/Lib/encodings/palmos.py b/Src/StdLib/Lib/encodings/palmos.py similarity index 100% rename from StdLib/Lib/encodings/palmos.py rename to Src/StdLib/Lib/encodings/palmos.py diff --git a/StdLib/Lib/encodings/ptcp154.py b/Src/StdLib/Lib/encodings/ptcp154.py similarity index 100% rename from StdLib/Lib/encodings/ptcp154.py rename to Src/StdLib/Lib/encodings/ptcp154.py diff --git a/StdLib/Lib/encodings/punycode.py b/Src/StdLib/Lib/encodings/punycode.py similarity index 100% rename from StdLib/Lib/encodings/punycode.py rename to Src/StdLib/Lib/encodings/punycode.py diff --git a/StdLib/Lib/encodings/quopri_codec.py b/Src/StdLib/Lib/encodings/quopri_codec.py similarity index 100% rename from StdLib/Lib/encodings/quopri_codec.py rename to Src/StdLib/Lib/encodings/quopri_codec.py diff --git a/StdLib/Lib/encodings/raw_unicode_escape.py b/Src/StdLib/Lib/encodings/raw_unicode_escape.py similarity index 100% rename from StdLib/Lib/encodings/raw_unicode_escape.py rename to Src/StdLib/Lib/encodings/raw_unicode_escape.py diff --git a/StdLib/Lib/encodings/rot_13.py b/Src/StdLib/Lib/encodings/rot_13.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/encodings/rot_13.py rename to Src/StdLib/Lib/encodings/rot_13.py diff --git a/StdLib/Lib/encodings/shift_jis.py b/Src/StdLib/Lib/encodings/shift_jis.py similarity index 100% rename from StdLib/Lib/encodings/shift_jis.py rename to Src/StdLib/Lib/encodings/shift_jis.py diff --git a/StdLib/Lib/encodings/shift_jis_2004.py b/Src/StdLib/Lib/encodings/shift_jis_2004.py similarity index 100% rename from StdLib/Lib/encodings/shift_jis_2004.py rename to Src/StdLib/Lib/encodings/shift_jis_2004.py diff --git a/StdLib/Lib/encodings/shift_jisx0213.py b/Src/StdLib/Lib/encodings/shift_jisx0213.py similarity index 100% rename from StdLib/Lib/encodings/shift_jisx0213.py rename to Src/StdLib/Lib/encodings/shift_jisx0213.py diff --git a/StdLib/Lib/encodings/tis_620.py b/Src/StdLib/Lib/encodings/tis_620.py similarity index 100% rename from StdLib/Lib/encodings/tis_620.py rename to Src/StdLib/Lib/encodings/tis_620.py diff --git a/StdLib/Lib/encodings/undefined.py b/Src/StdLib/Lib/encodings/undefined.py similarity index 100% rename from StdLib/Lib/encodings/undefined.py rename to Src/StdLib/Lib/encodings/undefined.py diff --git a/StdLib/Lib/encodings/unicode_escape.py b/Src/StdLib/Lib/encodings/unicode_escape.py similarity index 100% rename from StdLib/Lib/encodings/unicode_escape.py rename to Src/StdLib/Lib/encodings/unicode_escape.py diff --git a/StdLib/Lib/encodings/unicode_internal.py b/Src/StdLib/Lib/encodings/unicode_internal.py similarity index 100% rename from StdLib/Lib/encodings/unicode_internal.py rename to Src/StdLib/Lib/encodings/unicode_internal.py diff --git a/StdLib/Lib/encodings/utf_16.py b/Src/StdLib/Lib/encodings/utf_16.py similarity index 100% rename from StdLib/Lib/encodings/utf_16.py rename to Src/StdLib/Lib/encodings/utf_16.py diff --git a/StdLib/Lib/encodings/utf_16_be.py b/Src/StdLib/Lib/encodings/utf_16_be.py similarity index 100% rename from StdLib/Lib/encodings/utf_16_be.py rename to Src/StdLib/Lib/encodings/utf_16_be.py diff --git a/StdLib/Lib/encodings/utf_16_le.py b/Src/StdLib/Lib/encodings/utf_16_le.py similarity index 100% rename from StdLib/Lib/encodings/utf_16_le.py rename to Src/StdLib/Lib/encodings/utf_16_le.py diff --git a/StdLib/Lib/encodings/utf_32.py b/Src/StdLib/Lib/encodings/utf_32.py similarity index 100% rename from StdLib/Lib/encodings/utf_32.py rename to Src/StdLib/Lib/encodings/utf_32.py diff --git a/StdLib/Lib/encodings/utf_32_be.py b/Src/StdLib/Lib/encodings/utf_32_be.py similarity index 100% rename from StdLib/Lib/encodings/utf_32_be.py rename to Src/StdLib/Lib/encodings/utf_32_be.py diff --git a/StdLib/Lib/encodings/utf_32_le.py b/Src/StdLib/Lib/encodings/utf_32_le.py similarity index 100% rename from StdLib/Lib/encodings/utf_32_le.py rename to Src/StdLib/Lib/encodings/utf_32_le.py diff --git a/StdLib/Lib/encodings/utf_7.py b/Src/StdLib/Lib/encodings/utf_7.py similarity index 100% rename from StdLib/Lib/encodings/utf_7.py rename to Src/StdLib/Lib/encodings/utf_7.py diff --git a/StdLib/Lib/encodings/utf_8.py b/Src/StdLib/Lib/encodings/utf_8.py similarity index 100% rename from StdLib/Lib/encodings/utf_8.py rename to Src/StdLib/Lib/encodings/utf_8.py diff --git a/StdLib/Lib/encodings/utf_8_sig.py b/Src/StdLib/Lib/encodings/utf_8_sig.py similarity index 100% rename from StdLib/Lib/encodings/utf_8_sig.py rename to Src/StdLib/Lib/encodings/utf_8_sig.py diff --git a/StdLib/Lib/encodings/uu_codec.py b/Src/StdLib/Lib/encodings/uu_codec.py similarity index 100% rename from StdLib/Lib/encodings/uu_codec.py rename to Src/StdLib/Lib/encodings/uu_codec.py diff --git a/StdLib/Lib/encodings/zlib_codec.py b/Src/StdLib/Lib/encodings/zlib_codec.py similarity index 100% rename from StdLib/Lib/encodings/zlib_codec.py rename to Src/StdLib/Lib/encodings/zlib_codec.py diff --git a/StdLib/Lib/ensurepip/__init__.py b/Src/StdLib/Lib/ensurepip/__init__.py similarity index 100% rename from StdLib/Lib/ensurepip/__init__.py rename to Src/StdLib/Lib/ensurepip/__init__.py diff --git a/StdLib/Lib/ensurepip/__main__.py b/Src/StdLib/Lib/ensurepip/__main__.py similarity index 100% rename from StdLib/Lib/ensurepip/__main__.py rename to Src/StdLib/Lib/ensurepip/__main__.py diff --git a/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl b/Src/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl similarity index 100% rename from StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl rename to Src/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl diff --git a/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl b/Src/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl similarity index 100% rename from StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl rename to Src/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl diff --git a/StdLib/Lib/ensurepip/_uninstall.py b/Src/StdLib/Lib/ensurepip/_uninstall.py similarity index 100% rename from StdLib/Lib/ensurepip/_uninstall.py rename to Src/StdLib/Lib/ensurepip/_uninstall.py diff --git a/StdLib/Lib/enum.py b/Src/StdLib/Lib/enum.py similarity index 100% rename from StdLib/Lib/enum.py rename to Src/StdLib/Lib/enum.py diff --git a/StdLib/Lib/filecmp.py b/Src/StdLib/Lib/filecmp.py similarity index 100% rename from StdLib/Lib/filecmp.py rename to Src/StdLib/Lib/filecmp.py diff --git a/StdLib/Lib/fileinput.py b/Src/StdLib/Lib/fileinput.py similarity index 100% rename from StdLib/Lib/fileinput.py rename to Src/StdLib/Lib/fileinput.py diff --git a/StdLib/Lib/fnmatch.py b/Src/StdLib/Lib/fnmatch.py similarity index 100% rename from StdLib/Lib/fnmatch.py rename to Src/StdLib/Lib/fnmatch.py diff --git a/StdLib/Lib/formatter.py b/Src/StdLib/Lib/formatter.py similarity index 100% rename from StdLib/Lib/formatter.py rename to Src/StdLib/Lib/formatter.py diff --git a/StdLib/Lib/fractions.py b/Src/StdLib/Lib/fractions.py similarity index 100% rename from StdLib/Lib/fractions.py rename to Src/StdLib/Lib/fractions.py diff --git a/StdLib/Lib/ftplib.py b/Src/StdLib/Lib/ftplib.py similarity index 100% rename from StdLib/Lib/ftplib.py rename to Src/StdLib/Lib/ftplib.py diff --git a/StdLib/Lib/functools.py b/Src/StdLib/Lib/functools.py similarity index 100% rename from StdLib/Lib/functools.py rename to Src/StdLib/Lib/functools.py diff --git a/StdLib/Lib/genericpath.py b/Src/StdLib/Lib/genericpath.py similarity index 100% rename from StdLib/Lib/genericpath.py rename to Src/StdLib/Lib/genericpath.py diff --git a/StdLib/Lib/getopt.py b/Src/StdLib/Lib/getopt.py similarity index 100% rename from StdLib/Lib/getopt.py rename to Src/StdLib/Lib/getopt.py diff --git a/StdLib/Lib/getpass.py b/Src/StdLib/Lib/getpass.py similarity index 100% rename from StdLib/Lib/getpass.py rename to Src/StdLib/Lib/getpass.py diff --git a/StdLib/Lib/gettext.py b/Src/StdLib/Lib/gettext.py similarity index 100% rename from StdLib/Lib/gettext.py rename to Src/StdLib/Lib/gettext.py diff --git a/StdLib/Lib/glob.py b/Src/StdLib/Lib/glob.py similarity index 100% rename from StdLib/Lib/glob.py rename to Src/StdLib/Lib/glob.py diff --git a/StdLib/Lib/gzip.py b/Src/StdLib/Lib/gzip.py similarity index 100% rename from StdLib/Lib/gzip.py rename to Src/StdLib/Lib/gzip.py diff --git a/StdLib/Lib/hashlib.py b/Src/StdLib/Lib/hashlib.py similarity index 100% rename from StdLib/Lib/hashlib.py rename to Src/StdLib/Lib/hashlib.py diff --git a/StdLib/Lib/heapq.py b/Src/StdLib/Lib/heapq.py similarity index 100% rename from StdLib/Lib/heapq.py rename to Src/StdLib/Lib/heapq.py diff --git a/StdLib/Lib/hmac.py b/Src/StdLib/Lib/hmac.py similarity index 100% rename from StdLib/Lib/hmac.py rename to Src/StdLib/Lib/hmac.py diff --git a/StdLib/Lib/html/__init__.py b/Src/StdLib/Lib/html/__init__.py similarity index 100% rename from StdLib/Lib/html/__init__.py rename to Src/StdLib/Lib/html/__init__.py diff --git a/StdLib/Lib/html/entities.py b/Src/StdLib/Lib/html/entities.py similarity index 100% rename from StdLib/Lib/html/entities.py rename to Src/StdLib/Lib/html/entities.py diff --git a/StdLib/Lib/html/parser.py b/Src/StdLib/Lib/html/parser.py similarity index 100% rename from StdLib/Lib/html/parser.py rename to Src/StdLib/Lib/html/parser.py diff --git a/StdLib/Lib/http/__init__.py b/Src/StdLib/Lib/http/__init__.py similarity index 100% rename from StdLib/Lib/http/__init__.py rename to Src/StdLib/Lib/http/__init__.py diff --git a/StdLib/Lib/http/client.py b/Src/StdLib/Lib/http/client.py similarity index 100% rename from StdLib/Lib/http/client.py rename to Src/StdLib/Lib/http/client.py diff --git a/StdLib/Lib/http/cookiejar.py b/Src/StdLib/Lib/http/cookiejar.py similarity index 100% rename from StdLib/Lib/http/cookiejar.py rename to Src/StdLib/Lib/http/cookiejar.py diff --git a/StdLib/Lib/http/cookies.py b/Src/StdLib/Lib/http/cookies.py similarity index 100% rename from StdLib/Lib/http/cookies.py rename to Src/StdLib/Lib/http/cookies.py diff --git a/StdLib/Lib/http/server.py b/Src/StdLib/Lib/http/server.py similarity index 100% rename from StdLib/Lib/http/server.py rename to Src/StdLib/Lib/http/server.py diff --git a/StdLib/Lib/idlelib/AutoComplete.py b/Src/StdLib/Lib/idlelib/AutoComplete.py similarity index 100% rename from StdLib/Lib/idlelib/AutoComplete.py rename to Src/StdLib/Lib/idlelib/AutoComplete.py diff --git a/StdLib/Lib/idlelib/AutoCompleteWindow.py b/Src/StdLib/Lib/idlelib/AutoCompleteWindow.py similarity index 100% rename from StdLib/Lib/idlelib/AutoCompleteWindow.py rename to Src/StdLib/Lib/idlelib/AutoCompleteWindow.py diff --git a/StdLib/Lib/idlelib/AutoExpand.py b/Src/StdLib/Lib/idlelib/AutoExpand.py similarity index 100% rename from StdLib/Lib/idlelib/AutoExpand.py rename to Src/StdLib/Lib/idlelib/AutoExpand.py diff --git a/StdLib/Lib/idlelib/Bindings.py b/Src/StdLib/Lib/idlelib/Bindings.py similarity index 100% rename from StdLib/Lib/idlelib/Bindings.py rename to Src/StdLib/Lib/idlelib/Bindings.py diff --git a/StdLib/Lib/idlelib/CREDITS.txt b/Src/StdLib/Lib/idlelib/CREDITS.txt similarity index 100% rename from StdLib/Lib/idlelib/CREDITS.txt rename to Src/StdLib/Lib/idlelib/CREDITS.txt diff --git a/StdLib/Lib/idlelib/CallTipWindow.py b/Src/StdLib/Lib/idlelib/CallTipWindow.py similarity index 100% rename from StdLib/Lib/idlelib/CallTipWindow.py rename to Src/StdLib/Lib/idlelib/CallTipWindow.py diff --git a/StdLib/Lib/idlelib/CallTips.py b/Src/StdLib/Lib/idlelib/CallTips.py similarity index 100% rename from StdLib/Lib/idlelib/CallTips.py rename to Src/StdLib/Lib/idlelib/CallTips.py diff --git a/StdLib/Lib/idlelib/ChangeLog b/Src/StdLib/Lib/idlelib/ChangeLog similarity index 100% rename from StdLib/Lib/idlelib/ChangeLog rename to Src/StdLib/Lib/idlelib/ChangeLog diff --git a/StdLib/Lib/idlelib/ClassBrowser.py b/Src/StdLib/Lib/idlelib/ClassBrowser.py similarity index 100% rename from StdLib/Lib/idlelib/ClassBrowser.py rename to Src/StdLib/Lib/idlelib/ClassBrowser.py diff --git a/StdLib/Lib/idlelib/CodeContext.py b/Src/StdLib/Lib/idlelib/CodeContext.py similarity index 100% rename from StdLib/Lib/idlelib/CodeContext.py rename to Src/StdLib/Lib/idlelib/CodeContext.py diff --git a/StdLib/Lib/idlelib/ColorDelegator.py b/Src/StdLib/Lib/idlelib/ColorDelegator.py similarity index 100% rename from StdLib/Lib/idlelib/ColorDelegator.py rename to Src/StdLib/Lib/idlelib/ColorDelegator.py diff --git a/StdLib/Lib/idlelib/Debugger.py b/Src/StdLib/Lib/idlelib/Debugger.py similarity index 100% rename from StdLib/Lib/idlelib/Debugger.py rename to Src/StdLib/Lib/idlelib/Debugger.py diff --git a/StdLib/Lib/idlelib/Delegator.py b/Src/StdLib/Lib/idlelib/Delegator.py similarity index 100% rename from StdLib/Lib/idlelib/Delegator.py rename to Src/StdLib/Lib/idlelib/Delegator.py diff --git a/StdLib/Lib/idlelib/EditorWindow.py b/Src/StdLib/Lib/idlelib/EditorWindow.py similarity index 100% rename from StdLib/Lib/idlelib/EditorWindow.py rename to Src/StdLib/Lib/idlelib/EditorWindow.py diff --git a/StdLib/Lib/idlelib/FileList.py b/Src/StdLib/Lib/idlelib/FileList.py similarity index 100% rename from StdLib/Lib/idlelib/FileList.py rename to Src/StdLib/Lib/idlelib/FileList.py diff --git a/StdLib/Lib/idlelib/FormatParagraph.py b/Src/StdLib/Lib/idlelib/FormatParagraph.py similarity index 100% rename from StdLib/Lib/idlelib/FormatParagraph.py rename to Src/StdLib/Lib/idlelib/FormatParagraph.py diff --git a/StdLib/Lib/idlelib/GrepDialog.py b/Src/StdLib/Lib/idlelib/GrepDialog.py similarity index 100% rename from StdLib/Lib/idlelib/GrepDialog.py rename to Src/StdLib/Lib/idlelib/GrepDialog.py diff --git a/StdLib/Lib/idlelib/HISTORY.txt b/Src/StdLib/Lib/idlelib/HISTORY.txt similarity index 100% rename from StdLib/Lib/idlelib/HISTORY.txt rename to Src/StdLib/Lib/idlelib/HISTORY.txt diff --git a/StdLib/Lib/idlelib/HyperParser.py b/Src/StdLib/Lib/idlelib/HyperParser.py similarity index 100% rename from StdLib/Lib/idlelib/HyperParser.py rename to Src/StdLib/Lib/idlelib/HyperParser.py diff --git a/StdLib/Lib/idlelib/IOBinding.py b/Src/StdLib/Lib/idlelib/IOBinding.py similarity index 100% rename from StdLib/Lib/idlelib/IOBinding.py rename to Src/StdLib/Lib/idlelib/IOBinding.py diff --git a/StdLib/Lib/idlelib/Icons/folder.gif b/Src/StdLib/Lib/idlelib/Icons/folder.gif similarity index 100% rename from StdLib/Lib/idlelib/Icons/folder.gif rename to Src/StdLib/Lib/idlelib/Icons/folder.gif diff --git a/StdLib/Lib/idlelib/Icons/idle.icns b/Src/StdLib/Lib/idlelib/Icons/idle.icns similarity index 100% rename from StdLib/Lib/idlelib/Icons/idle.icns rename to Src/StdLib/Lib/idlelib/Icons/idle.icns diff --git a/StdLib/Lib/idlelib/Icons/idle.ico b/Src/StdLib/Lib/idlelib/Icons/idle.ico similarity index 100% rename from StdLib/Lib/idlelib/Icons/idle.ico rename to Src/StdLib/Lib/idlelib/Icons/idle.ico diff --git a/StdLib/Lib/idlelib/Icons/idle_16.gif b/Src/StdLib/Lib/idlelib/Icons/idle_16.gif similarity index 100% rename from StdLib/Lib/idlelib/Icons/idle_16.gif rename to Src/StdLib/Lib/idlelib/Icons/idle_16.gif diff --git a/StdLib/Lib/idlelib/Icons/idle_16.png b/Src/StdLib/Lib/idlelib/Icons/idle_16.png similarity index 100% rename from StdLib/Lib/idlelib/Icons/idle_16.png rename to Src/StdLib/Lib/idlelib/Icons/idle_16.png diff --git a/StdLib/Lib/idlelib/Icons/idle_32.gif b/Src/StdLib/Lib/idlelib/Icons/idle_32.gif similarity index 100% rename from StdLib/Lib/idlelib/Icons/idle_32.gif rename to Src/StdLib/Lib/idlelib/Icons/idle_32.gif diff --git a/StdLib/Lib/idlelib/Icons/idle_32.png b/Src/StdLib/Lib/idlelib/Icons/idle_32.png similarity index 100% rename from StdLib/Lib/idlelib/Icons/idle_32.png rename to Src/StdLib/Lib/idlelib/Icons/idle_32.png diff --git a/StdLib/Lib/idlelib/Icons/idle_48.gif b/Src/StdLib/Lib/idlelib/Icons/idle_48.gif similarity index 100% rename from StdLib/Lib/idlelib/Icons/idle_48.gif rename to Src/StdLib/Lib/idlelib/Icons/idle_48.gif diff --git a/StdLib/Lib/idlelib/Icons/idle_48.png b/Src/StdLib/Lib/idlelib/Icons/idle_48.png similarity index 100% rename from StdLib/Lib/idlelib/Icons/idle_48.png rename to Src/StdLib/Lib/idlelib/Icons/idle_48.png diff --git a/StdLib/Lib/idlelib/Icons/minusnode.gif b/Src/StdLib/Lib/idlelib/Icons/minusnode.gif similarity index 100% rename from StdLib/Lib/idlelib/Icons/minusnode.gif rename to Src/StdLib/Lib/idlelib/Icons/minusnode.gif diff --git a/StdLib/Lib/idlelib/Icons/openfolder.gif b/Src/StdLib/Lib/idlelib/Icons/openfolder.gif similarity index 100% rename from StdLib/Lib/idlelib/Icons/openfolder.gif rename to Src/StdLib/Lib/idlelib/Icons/openfolder.gif diff --git a/StdLib/Lib/idlelib/Icons/plusnode.gif b/Src/StdLib/Lib/idlelib/Icons/plusnode.gif similarity index 100% rename from StdLib/Lib/idlelib/Icons/plusnode.gif rename to Src/StdLib/Lib/idlelib/Icons/plusnode.gif diff --git a/StdLib/Lib/idlelib/Icons/python.gif b/Src/StdLib/Lib/idlelib/Icons/python.gif similarity index 100% rename from StdLib/Lib/idlelib/Icons/python.gif rename to Src/StdLib/Lib/idlelib/Icons/python.gif diff --git a/StdLib/Lib/idlelib/Icons/tk.gif b/Src/StdLib/Lib/idlelib/Icons/tk.gif similarity index 100% rename from StdLib/Lib/idlelib/Icons/tk.gif rename to Src/StdLib/Lib/idlelib/Icons/tk.gif diff --git a/StdLib/Lib/idlelib/IdleHistory.py b/Src/StdLib/Lib/idlelib/IdleHistory.py similarity index 100% rename from StdLib/Lib/idlelib/IdleHistory.py rename to Src/StdLib/Lib/idlelib/IdleHistory.py diff --git a/StdLib/Lib/idlelib/MultiCall.py b/Src/StdLib/Lib/idlelib/MultiCall.py similarity index 100% rename from StdLib/Lib/idlelib/MultiCall.py rename to Src/StdLib/Lib/idlelib/MultiCall.py diff --git a/StdLib/Lib/idlelib/MultiStatusBar.py b/Src/StdLib/Lib/idlelib/MultiStatusBar.py similarity index 100% rename from StdLib/Lib/idlelib/MultiStatusBar.py rename to Src/StdLib/Lib/idlelib/MultiStatusBar.py diff --git a/StdLib/Lib/idlelib/NEWS.txt b/Src/StdLib/Lib/idlelib/NEWS.txt similarity index 100% rename from StdLib/Lib/idlelib/NEWS.txt rename to Src/StdLib/Lib/idlelib/NEWS.txt diff --git a/StdLib/Lib/idlelib/ObjectBrowser.py b/Src/StdLib/Lib/idlelib/ObjectBrowser.py similarity index 100% rename from StdLib/Lib/idlelib/ObjectBrowser.py rename to Src/StdLib/Lib/idlelib/ObjectBrowser.py diff --git a/StdLib/Lib/idlelib/OutputWindow.py b/Src/StdLib/Lib/idlelib/OutputWindow.py similarity index 100% rename from StdLib/Lib/idlelib/OutputWindow.py rename to Src/StdLib/Lib/idlelib/OutputWindow.py diff --git a/StdLib/Lib/idlelib/ParenMatch.py b/Src/StdLib/Lib/idlelib/ParenMatch.py similarity index 100% rename from StdLib/Lib/idlelib/ParenMatch.py rename to Src/StdLib/Lib/idlelib/ParenMatch.py diff --git a/StdLib/Lib/idlelib/PathBrowser.py b/Src/StdLib/Lib/idlelib/PathBrowser.py similarity index 100% rename from StdLib/Lib/idlelib/PathBrowser.py rename to Src/StdLib/Lib/idlelib/PathBrowser.py diff --git a/StdLib/Lib/idlelib/Percolator.py b/Src/StdLib/Lib/idlelib/Percolator.py similarity index 100% rename from StdLib/Lib/idlelib/Percolator.py rename to Src/StdLib/Lib/idlelib/Percolator.py diff --git a/StdLib/Lib/idlelib/PyParse.py b/Src/StdLib/Lib/idlelib/PyParse.py similarity index 100% rename from StdLib/Lib/idlelib/PyParse.py rename to Src/StdLib/Lib/idlelib/PyParse.py diff --git a/StdLib/Lib/idlelib/PyShell.py b/Src/StdLib/Lib/idlelib/PyShell.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/idlelib/PyShell.py rename to Src/StdLib/Lib/idlelib/PyShell.py diff --git a/StdLib/Lib/idlelib/README.txt b/Src/StdLib/Lib/idlelib/README.txt similarity index 100% rename from StdLib/Lib/idlelib/README.txt rename to Src/StdLib/Lib/idlelib/README.txt diff --git a/StdLib/Lib/idlelib/RemoteDebugger.py b/Src/StdLib/Lib/idlelib/RemoteDebugger.py similarity index 100% rename from StdLib/Lib/idlelib/RemoteDebugger.py rename to Src/StdLib/Lib/idlelib/RemoteDebugger.py diff --git a/StdLib/Lib/idlelib/RemoteObjectBrowser.py b/Src/StdLib/Lib/idlelib/RemoteObjectBrowser.py similarity index 100% rename from StdLib/Lib/idlelib/RemoteObjectBrowser.py rename to Src/StdLib/Lib/idlelib/RemoteObjectBrowser.py diff --git a/StdLib/Lib/idlelib/ReplaceDialog.py b/Src/StdLib/Lib/idlelib/ReplaceDialog.py similarity index 100% rename from StdLib/Lib/idlelib/ReplaceDialog.py rename to Src/StdLib/Lib/idlelib/ReplaceDialog.py diff --git a/StdLib/Lib/idlelib/RstripExtension.py b/Src/StdLib/Lib/idlelib/RstripExtension.py similarity index 100% rename from StdLib/Lib/idlelib/RstripExtension.py rename to Src/StdLib/Lib/idlelib/RstripExtension.py diff --git a/StdLib/Lib/idlelib/ScriptBinding.py b/Src/StdLib/Lib/idlelib/ScriptBinding.py similarity index 100% rename from StdLib/Lib/idlelib/ScriptBinding.py rename to Src/StdLib/Lib/idlelib/ScriptBinding.py diff --git a/StdLib/Lib/idlelib/ScrolledList.py b/Src/StdLib/Lib/idlelib/ScrolledList.py similarity index 100% rename from StdLib/Lib/idlelib/ScrolledList.py rename to Src/StdLib/Lib/idlelib/ScrolledList.py diff --git a/StdLib/Lib/idlelib/SearchDialog.py b/Src/StdLib/Lib/idlelib/SearchDialog.py similarity index 100% rename from StdLib/Lib/idlelib/SearchDialog.py rename to Src/StdLib/Lib/idlelib/SearchDialog.py diff --git a/StdLib/Lib/idlelib/SearchDialogBase.py b/Src/StdLib/Lib/idlelib/SearchDialogBase.py similarity index 100% rename from StdLib/Lib/idlelib/SearchDialogBase.py rename to Src/StdLib/Lib/idlelib/SearchDialogBase.py diff --git a/StdLib/Lib/idlelib/SearchEngine.py b/Src/StdLib/Lib/idlelib/SearchEngine.py similarity index 100% rename from StdLib/Lib/idlelib/SearchEngine.py rename to Src/StdLib/Lib/idlelib/SearchEngine.py diff --git a/StdLib/Lib/idlelib/StackViewer.py b/Src/StdLib/Lib/idlelib/StackViewer.py similarity index 100% rename from StdLib/Lib/idlelib/StackViewer.py rename to Src/StdLib/Lib/idlelib/StackViewer.py diff --git a/StdLib/Lib/idlelib/TODO.txt b/Src/StdLib/Lib/idlelib/TODO.txt similarity index 100% rename from StdLib/Lib/idlelib/TODO.txt rename to Src/StdLib/Lib/idlelib/TODO.txt diff --git a/StdLib/Lib/idlelib/ToolTip.py b/Src/StdLib/Lib/idlelib/ToolTip.py similarity index 100% rename from StdLib/Lib/idlelib/ToolTip.py rename to Src/StdLib/Lib/idlelib/ToolTip.py diff --git a/StdLib/Lib/idlelib/TreeWidget.py b/Src/StdLib/Lib/idlelib/TreeWidget.py similarity index 100% rename from StdLib/Lib/idlelib/TreeWidget.py rename to Src/StdLib/Lib/idlelib/TreeWidget.py diff --git a/StdLib/Lib/idlelib/UndoDelegator.py b/Src/StdLib/Lib/idlelib/UndoDelegator.py similarity index 100% rename from StdLib/Lib/idlelib/UndoDelegator.py rename to Src/StdLib/Lib/idlelib/UndoDelegator.py diff --git a/StdLib/Lib/idlelib/WidgetRedirector.py b/Src/StdLib/Lib/idlelib/WidgetRedirector.py similarity index 100% rename from StdLib/Lib/idlelib/WidgetRedirector.py rename to Src/StdLib/Lib/idlelib/WidgetRedirector.py diff --git a/StdLib/Lib/idlelib/WindowList.py b/Src/StdLib/Lib/idlelib/WindowList.py similarity index 100% rename from StdLib/Lib/idlelib/WindowList.py rename to Src/StdLib/Lib/idlelib/WindowList.py diff --git a/StdLib/Lib/idlelib/ZoomHeight.py b/Src/StdLib/Lib/idlelib/ZoomHeight.py similarity index 100% rename from StdLib/Lib/idlelib/ZoomHeight.py rename to Src/StdLib/Lib/idlelib/ZoomHeight.py diff --git a/StdLib/Lib/idlelib/__init__.py b/Src/StdLib/Lib/idlelib/__init__.py similarity index 100% rename from StdLib/Lib/idlelib/__init__.py rename to Src/StdLib/Lib/idlelib/__init__.py diff --git a/StdLib/Lib/idlelib/__main__.py b/Src/StdLib/Lib/idlelib/__main__.py similarity index 100% rename from StdLib/Lib/idlelib/__main__.py rename to Src/StdLib/Lib/idlelib/__main__.py diff --git a/StdLib/Lib/idlelib/aboutDialog.py b/Src/StdLib/Lib/idlelib/aboutDialog.py similarity index 100% rename from StdLib/Lib/idlelib/aboutDialog.py rename to Src/StdLib/Lib/idlelib/aboutDialog.py diff --git a/StdLib/Lib/idlelib/config-extensions.def b/Src/StdLib/Lib/idlelib/config-extensions.def similarity index 100% rename from StdLib/Lib/idlelib/config-extensions.def rename to Src/StdLib/Lib/idlelib/config-extensions.def diff --git a/StdLib/Lib/idlelib/config-highlight.def b/Src/StdLib/Lib/idlelib/config-highlight.def similarity index 100% rename from StdLib/Lib/idlelib/config-highlight.def rename to Src/StdLib/Lib/idlelib/config-highlight.def diff --git a/StdLib/Lib/idlelib/config-keys.def b/Src/StdLib/Lib/idlelib/config-keys.def similarity index 100% rename from StdLib/Lib/idlelib/config-keys.def rename to Src/StdLib/Lib/idlelib/config-keys.def diff --git a/StdLib/Lib/idlelib/config-main.def b/Src/StdLib/Lib/idlelib/config-main.def similarity index 100% rename from StdLib/Lib/idlelib/config-main.def rename to Src/StdLib/Lib/idlelib/config-main.def diff --git a/StdLib/Lib/idlelib/configDialog.py b/Src/StdLib/Lib/idlelib/configDialog.py similarity index 100% rename from StdLib/Lib/idlelib/configDialog.py rename to Src/StdLib/Lib/idlelib/configDialog.py diff --git a/StdLib/Lib/idlelib/configHandler.py b/Src/StdLib/Lib/idlelib/configHandler.py similarity index 100% rename from StdLib/Lib/idlelib/configHandler.py rename to Src/StdLib/Lib/idlelib/configHandler.py diff --git a/StdLib/Lib/idlelib/configHelpSourceEdit.py b/Src/StdLib/Lib/idlelib/configHelpSourceEdit.py similarity index 100% rename from StdLib/Lib/idlelib/configHelpSourceEdit.py rename to Src/StdLib/Lib/idlelib/configHelpSourceEdit.py diff --git a/StdLib/Lib/idlelib/configSectionNameDialog.py b/Src/StdLib/Lib/idlelib/configSectionNameDialog.py similarity index 100% rename from StdLib/Lib/idlelib/configSectionNameDialog.py rename to Src/StdLib/Lib/idlelib/configSectionNameDialog.py diff --git a/StdLib/Lib/idlelib/dynOptionMenuWidget.py b/Src/StdLib/Lib/idlelib/dynOptionMenuWidget.py similarity index 100% rename from StdLib/Lib/idlelib/dynOptionMenuWidget.py rename to Src/StdLib/Lib/idlelib/dynOptionMenuWidget.py diff --git a/StdLib/Lib/idlelib/extend.txt b/Src/StdLib/Lib/idlelib/extend.txt similarity index 100% rename from StdLib/Lib/idlelib/extend.txt rename to Src/StdLib/Lib/idlelib/extend.txt diff --git a/StdLib/Lib/idlelib/help.html b/Src/StdLib/Lib/idlelib/help.html similarity index 100% rename from StdLib/Lib/idlelib/help.html rename to Src/StdLib/Lib/idlelib/help.html diff --git a/StdLib/Lib/idlelib/help.py b/Src/StdLib/Lib/idlelib/help.py similarity index 100% rename from StdLib/Lib/idlelib/help.py rename to Src/StdLib/Lib/idlelib/help.py diff --git a/StdLib/Lib/idlelib/help.txt b/Src/StdLib/Lib/idlelib/help.txt similarity index 100% rename from StdLib/Lib/idlelib/help.txt rename to Src/StdLib/Lib/idlelib/help.txt diff --git a/StdLib/Lib/idlelib/idle.bat b/Src/StdLib/Lib/idlelib/idle.bat old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/idlelib/idle.bat rename to Src/StdLib/Lib/idlelib/idle.bat diff --git a/StdLib/Lib/idlelib/idle.py b/Src/StdLib/Lib/idlelib/idle.py similarity index 100% rename from StdLib/Lib/idlelib/idle.py rename to Src/StdLib/Lib/idlelib/idle.py diff --git a/StdLib/Lib/idlelib/idle.pyw b/Src/StdLib/Lib/idlelib/idle.pyw similarity index 100% rename from StdLib/Lib/idlelib/idle.pyw rename to Src/StdLib/Lib/idlelib/idle.pyw diff --git a/StdLib/Lib/idlelib/idle_test/README.txt b/Src/StdLib/Lib/idlelib/idle_test/README.txt similarity index 100% rename from StdLib/Lib/idlelib/idle_test/README.txt rename to Src/StdLib/Lib/idlelib/idle_test/README.txt diff --git a/StdLib/Lib/idlelib/idle_test/__init__.py b/Src/StdLib/Lib/idlelib/idle_test/__init__.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/__init__.py rename to Src/StdLib/Lib/idlelib/idle_test/__init__.py diff --git a/StdLib/Lib/idlelib/idle_test/htest.py b/Src/StdLib/Lib/idlelib/idle_test/htest.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/htest.py rename to Src/StdLib/Lib/idlelib/idle_test/htest.py diff --git a/StdLib/Lib/idlelib/idle_test/mock_idle.py b/Src/StdLib/Lib/idlelib/idle_test/mock_idle.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/mock_idle.py rename to Src/StdLib/Lib/idlelib/idle_test/mock_idle.py diff --git a/StdLib/Lib/idlelib/idle_test/mock_tk.py b/Src/StdLib/Lib/idlelib/idle_test/mock_tk.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/mock_tk.py rename to Src/StdLib/Lib/idlelib/idle_test/mock_tk.py diff --git a/StdLib/Lib/idlelib/idle_test/test_autocomplete.py b/Src/StdLib/Lib/idlelib/idle_test/test_autocomplete.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/test_autocomplete.py rename to Src/StdLib/Lib/idlelib/idle_test/test_autocomplete.py diff --git a/StdLib/Lib/idlelib/idle_test/test_autoexpand.py b/Src/StdLib/Lib/idlelib/idle_test/test_autoexpand.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/test_autoexpand.py rename to Src/StdLib/Lib/idlelib/idle_test/test_autoexpand.py diff --git a/StdLib/Lib/idlelib/idle_test/test_calltips.py b/Src/StdLib/Lib/idlelib/idle_test/test_calltips.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/test_calltips.py rename to Src/StdLib/Lib/idlelib/idle_test/test_calltips.py diff --git a/StdLib/Lib/idlelib/idle_test/test_config_name.py b/Src/StdLib/Lib/idlelib/idle_test/test_config_name.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/test_config_name.py rename to Src/StdLib/Lib/idlelib/idle_test/test_config_name.py diff --git a/StdLib/Lib/idlelib/idle_test/test_configdialog.py b/Src/StdLib/Lib/idlelib/idle_test/test_configdialog.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/test_configdialog.py rename to Src/StdLib/Lib/idlelib/idle_test/test_configdialog.py diff --git a/StdLib/Lib/idlelib/idle_test/test_delegator.py b/Src/StdLib/Lib/idlelib/idle_test/test_delegator.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/test_delegator.py rename to Src/StdLib/Lib/idlelib/idle_test/test_delegator.py diff --git a/StdLib/Lib/idlelib/idle_test/test_editor.py b/Src/StdLib/Lib/idlelib/idle_test/test_editor.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/test_editor.py rename to Src/StdLib/Lib/idlelib/idle_test/test_editor.py diff --git a/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py b/Src/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/test_formatparagraph.py rename to Src/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py diff --git a/StdLib/Lib/idlelib/idle_test/test_grep.py b/Src/StdLib/Lib/idlelib/idle_test/test_grep.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/test_grep.py rename to Src/StdLib/Lib/idlelib/idle_test/test_grep.py diff --git a/StdLib/Lib/idlelib/idle_test/test_hyperparser.py b/Src/StdLib/Lib/idlelib/idle_test/test_hyperparser.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/test_hyperparser.py rename to Src/StdLib/Lib/idlelib/idle_test/test_hyperparser.py diff --git a/StdLib/Lib/idlelib/idle_test/test_idlehistory.py b/Src/StdLib/Lib/idlelib/idle_test/test_idlehistory.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/test_idlehistory.py rename to Src/StdLib/Lib/idlelib/idle_test/test_idlehistory.py diff --git a/StdLib/Lib/idlelib/idle_test/test_io.py b/Src/StdLib/Lib/idlelib/idle_test/test_io.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/test_io.py rename to Src/StdLib/Lib/idlelib/idle_test/test_io.py diff --git a/StdLib/Lib/idlelib/idle_test/test_parenmatch.py b/Src/StdLib/Lib/idlelib/idle_test/test_parenmatch.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/test_parenmatch.py rename to Src/StdLib/Lib/idlelib/idle_test/test_parenmatch.py diff --git a/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py b/Src/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/test_pathbrowser.py rename to Src/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py diff --git a/StdLib/Lib/idlelib/idle_test/test_rstrip.py b/Src/StdLib/Lib/idlelib/idle_test/test_rstrip.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/test_rstrip.py rename to Src/StdLib/Lib/idlelib/idle_test/test_rstrip.py diff --git a/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py b/Src/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py rename to Src/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py diff --git a/StdLib/Lib/idlelib/idle_test/test_searchengine.py b/Src/StdLib/Lib/idlelib/idle_test/test_searchengine.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/test_searchengine.py rename to Src/StdLib/Lib/idlelib/idle_test/test_searchengine.py diff --git a/StdLib/Lib/idlelib/idle_test/test_text.py b/Src/StdLib/Lib/idlelib/idle_test/test_text.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/test_text.py rename to Src/StdLib/Lib/idlelib/idle_test/test_text.py diff --git a/StdLib/Lib/idlelib/idle_test/test_textview.py b/Src/StdLib/Lib/idlelib/idle_test/test_textview.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/test_textview.py rename to Src/StdLib/Lib/idlelib/idle_test/test_textview.py diff --git a/StdLib/Lib/idlelib/idle_test/test_warning.py b/Src/StdLib/Lib/idlelib/idle_test/test_warning.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/test_warning.py rename to Src/StdLib/Lib/idlelib/idle_test/test_warning.py diff --git a/StdLib/Lib/idlelib/idle_test/test_widgetredir.py b/Src/StdLib/Lib/idlelib/idle_test/test_widgetredir.py similarity index 100% rename from StdLib/Lib/idlelib/idle_test/test_widgetredir.py rename to Src/StdLib/Lib/idlelib/idle_test/test_widgetredir.py diff --git a/StdLib/Lib/idlelib/idlever.py b/Src/StdLib/Lib/idlelib/idlever.py similarity index 100% rename from StdLib/Lib/idlelib/idlever.py rename to Src/StdLib/Lib/idlelib/idlever.py diff --git a/StdLib/Lib/idlelib/keybindingDialog.py b/Src/StdLib/Lib/idlelib/keybindingDialog.py similarity index 100% rename from StdLib/Lib/idlelib/keybindingDialog.py rename to Src/StdLib/Lib/idlelib/keybindingDialog.py diff --git a/StdLib/Lib/idlelib/macosxSupport.py b/Src/StdLib/Lib/idlelib/macosxSupport.py similarity index 100% rename from StdLib/Lib/idlelib/macosxSupport.py rename to Src/StdLib/Lib/idlelib/macosxSupport.py diff --git a/StdLib/Lib/idlelib/rpc.py b/Src/StdLib/Lib/idlelib/rpc.py similarity index 100% rename from StdLib/Lib/idlelib/rpc.py rename to Src/StdLib/Lib/idlelib/rpc.py diff --git a/StdLib/Lib/idlelib/run.py b/Src/StdLib/Lib/idlelib/run.py similarity index 100% rename from StdLib/Lib/idlelib/run.py rename to Src/StdLib/Lib/idlelib/run.py diff --git a/StdLib/Lib/idlelib/tabbedpages.py b/Src/StdLib/Lib/idlelib/tabbedpages.py similarity index 100% rename from StdLib/Lib/idlelib/tabbedpages.py rename to Src/StdLib/Lib/idlelib/tabbedpages.py diff --git a/StdLib/Lib/idlelib/textView.py b/Src/StdLib/Lib/idlelib/textView.py similarity index 100% rename from StdLib/Lib/idlelib/textView.py rename to Src/StdLib/Lib/idlelib/textView.py diff --git a/StdLib/Lib/imaplib.py b/Src/StdLib/Lib/imaplib.py similarity index 100% rename from StdLib/Lib/imaplib.py rename to Src/StdLib/Lib/imaplib.py diff --git a/StdLib/Lib/imghdr.py b/Src/StdLib/Lib/imghdr.py similarity index 100% rename from StdLib/Lib/imghdr.py rename to Src/StdLib/Lib/imghdr.py diff --git a/StdLib/Lib/imp.py b/Src/StdLib/Lib/imp.py similarity index 100% rename from StdLib/Lib/imp.py rename to Src/StdLib/Lib/imp.py diff --git a/StdLib/Lib/importlib/__init__.py b/Src/StdLib/Lib/importlib/__init__.py similarity index 100% rename from StdLib/Lib/importlib/__init__.py rename to Src/StdLib/Lib/importlib/__init__.py diff --git a/StdLib/Lib/importlib/_bootstrap.py b/Src/StdLib/Lib/importlib/_bootstrap.py similarity index 100% rename from StdLib/Lib/importlib/_bootstrap.py rename to Src/StdLib/Lib/importlib/_bootstrap.py diff --git a/StdLib/Lib/importlib/abc.py b/Src/StdLib/Lib/importlib/abc.py similarity index 100% rename from StdLib/Lib/importlib/abc.py rename to Src/StdLib/Lib/importlib/abc.py diff --git a/StdLib/Lib/importlib/machinery.py b/Src/StdLib/Lib/importlib/machinery.py similarity index 100% rename from StdLib/Lib/importlib/machinery.py rename to Src/StdLib/Lib/importlib/machinery.py diff --git a/StdLib/Lib/importlib/util.py b/Src/StdLib/Lib/importlib/util.py similarity index 100% rename from StdLib/Lib/importlib/util.py rename to Src/StdLib/Lib/importlib/util.py diff --git a/StdLib/Lib/inspect.py b/Src/StdLib/Lib/inspect.py similarity index 100% rename from StdLib/Lib/inspect.py rename to Src/StdLib/Lib/inspect.py diff --git a/StdLib/Lib/io.py b/Src/StdLib/Lib/io.py similarity index 100% rename from StdLib/Lib/io.py rename to Src/StdLib/Lib/io.py diff --git a/StdLib/Lib/ipaddress.py b/Src/StdLib/Lib/ipaddress.py similarity index 100% rename from StdLib/Lib/ipaddress.py rename to Src/StdLib/Lib/ipaddress.py diff --git a/StdLib/Lib/json/__init__.py b/Src/StdLib/Lib/json/__init__.py similarity index 100% rename from StdLib/Lib/json/__init__.py rename to Src/StdLib/Lib/json/__init__.py diff --git a/StdLib/Lib/json/decoder.py b/Src/StdLib/Lib/json/decoder.py similarity index 100% rename from StdLib/Lib/json/decoder.py rename to Src/StdLib/Lib/json/decoder.py diff --git a/StdLib/Lib/json/encoder.py b/Src/StdLib/Lib/json/encoder.py similarity index 100% rename from StdLib/Lib/json/encoder.py rename to Src/StdLib/Lib/json/encoder.py diff --git a/StdLib/Lib/json/scanner.py b/Src/StdLib/Lib/json/scanner.py similarity index 100% rename from StdLib/Lib/json/scanner.py rename to Src/StdLib/Lib/json/scanner.py diff --git a/StdLib/Lib/json/tool.py b/Src/StdLib/Lib/json/tool.py similarity index 100% rename from StdLib/Lib/json/tool.py rename to Src/StdLib/Lib/json/tool.py diff --git a/StdLib/Lib/keyword.py b/Src/StdLib/Lib/keyword.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/keyword.py rename to Src/StdLib/Lib/keyword.py diff --git a/StdLib/Lib/lib2to3/Grammar.txt b/Src/StdLib/Lib/lib2to3/Grammar.txt similarity index 100% rename from StdLib/Lib/lib2to3/Grammar.txt rename to Src/StdLib/Lib/lib2to3/Grammar.txt diff --git a/StdLib/Lib/lib2to3/PatternGrammar.txt b/Src/StdLib/Lib/lib2to3/PatternGrammar.txt similarity index 100% rename from StdLib/Lib/lib2to3/PatternGrammar.txt rename to Src/StdLib/Lib/lib2to3/PatternGrammar.txt diff --git a/StdLib/Lib/lib2to3/__init__.py b/Src/StdLib/Lib/lib2to3/__init__.py similarity index 100% rename from StdLib/Lib/lib2to3/__init__.py rename to Src/StdLib/Lib/lib2to3/__init__.py diff --git a/StdLib/Lib/lib2to3/__main__.py b/Src/StdLib/Lib/lib2to3/__main__.py similarity index 100% rename from StdLib/Lib/lib2to3/__main__.py rename to Src/StdLib/Lib/lib2to3/__main__.py diff --git a/StdLib/Lib/lib2to3/btm_matcher.py b/Src/StdLib/Lib/lib2to3/btm_matcher.py similarity index 100% rename from StdLib/Lib/lib2to3/btm_matcher.py rename to Src/StdLib/Lib/lib2to3/btm_matcher.py diff --git a/StdLib/Lib/lib2to3/btm_utils.py b/Src/StdLib/Lib/lib2to3/btm_utils.py similarity index 100% rename from StdLib/Lib/lib2to3/btm_utils.py rename to Src/StdLib/Lib/lib2to3/btm_utils.py diff --git a/StdLib/Lib/lib2to3/fixer_base.py b/Src/StdLib/Lib/lib2to3/fixer_base.py similarity index 100% rename from StdLib/Lib/lib2to3/fixer_base.py rename to Src/StdLib/Lib/lib2to3/fixer_base.py diff --git a/StdLib/Lib/lib2to3/fixer_util.py b/Src/StdLib/Lib/lib2to3/fixer_util.py similarity index 100% rename from StdLib/Lib/lib2to3/fixer_util.py rename to Src/StdLib/Lib/lib2to3/fixer_util.py diff --git a/StdLib/Lib/lib2to3/fixes/__init__.py b/Src/StdLib/Lib/lib2to3/fixes/__init__.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/__init__.py rename to Src/StdLib/Lib/lib2to3/fixes/__init__.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_apply.py b/Src/StdLib/Lib/lib2to3/fixes/fix_apply.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_apply.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_apply.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_asserts.py b/Src/StdLib/Lib/lib2to3/fixes/fix_asserts.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_asserts.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_asserts.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_basestring.py b/Src/StdLib/Lib/lib2to3/fixes/fix_basestring.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_basestring.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_basestring.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_buffer.py b/Src/StdLib/Lib/lib2to3/fixes/fix_buffer.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_buffer.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_buffer.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_callable.py b/Src/StdLib/Lib/lib2to3/fixes/fix_callable.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_callable.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_callable.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_dict.py b/Src/StdLib/Lib/lib2to3/fixes/fix_dict.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_dict.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_dict.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_except.py b/Src/StdLib/Lib/lib2to3/fixes/fix_except.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_except.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_except.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_exec.py b/Src/StdLib/Lib/lib2to3/fixes/fix_exec.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_exec.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_exec.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_execfile.py b/Src/StdLib/Lib/lib2to3/fixes/fix_execfile.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_execfile.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_execfile.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py b/Src/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_exitfunc.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_filter.py b/Src/StdLib/Lib/lib2to3/fixes/fix_filter.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_filter.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_filter.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py b/Src/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_funcattrs.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_future.py b/Src/StdLib/Lib/lib2to3/fixes/fix_future.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_future.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_future.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py b/Src/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_getcwdu.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_has_key.py b/Src/StdLib/Lib/lib2to3/fixes/fix_has_key.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_has_key.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_has_key.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_idioms.py b/Src/StdLib/Lib/lib2to3/fixes/fix_idioms.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_idioms.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_idioms.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_import.py b/Src/StdLib/Lib/lib2to3/fixes/fix_import.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_import.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_import.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_imports.py b/Src/StdLib/Lib/lib2to3/fixes/fix_imports.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_imports.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_imports.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_imports2.py b/Src/StdLib/Lib/lib2to3/fixes/fix_imports2.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_imports2.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_imports2.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_input.py b/Src/StdLib/Lib/lib2to3/fixes/fix_input.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_input.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_input.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_intern.py b/Src/StdLib/Lib/lib2to3/fixes/fix_intern.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_intern.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_intern.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_isinstance.py b/Src/StdLib/Lib/lib2to3/fixes/fix_isinstance.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_isinstance.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_isinstance.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_itertools.py b/Src/StdLib/Lib/lib2to3/fixes/fix_itertools.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_itertools.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_itertools.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py b/Src/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_long.py b/Src/StdLib/Lib/lib2to3/fixes/fix_long.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_long.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_long.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_map.py b/Src/StdLib/Lib/lib2to3/fixes/fix_map.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_map.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_map.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_metaclass.py b/Src/StdLib/Lib/lib2to3/fixes/fix_metaclass.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_metaclass.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_metaclass.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py b/Src/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_methodattrs.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_ne.py b/Src/StdLib/Lib/lib2to3/fixes/fix_ne.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_ne.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_ne.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_next.py b/Src/StdLib/Lib/lib2to3/fixes/fix_next.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_next.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_next.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_nonzero.py b/Src/StdLib/Lib/lib2to3/fixes/fix_nonzero.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_nonzero.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_nonzero.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_numliterals.py b/Src/StdLib/Lib/lib2to3/fixes/fix_numliterals.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_numliterals.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_numliterals.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_operator.py b/Src/StdLib/Lib/lib2to3/fixes/fix_operator.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_operator.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_operator.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_paren.py b/Src/StdLib/Lib/lib2to3/fixes/fix_paren.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_paren.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_paren.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_print.py b/Src/StdLib/Lib/lib2to3/fixes/fix_print.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_print.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_print.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_raise.py b/Src/StdLib/Lib/lib2to3/fixes/fix_raise.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_raise.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_raise.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_raw_input.py b/Src/StdLib/Lib/lib2to3/fixes/fix_raw_input.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_raw_input.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_raw_input.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_reduce.py b/Src/StdLib/Lib/lib2to3/fixes/fix_reduce.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_reduce.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_reduce.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_reload.py b/Src/StdLib/Lib/lib2to3/fixes/fix_reload.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_reload.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_reload.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_renames.py b/Src/StdLib/Lib/lib2to3/fixes/fix_renames.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_renames.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_renames.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_repr.py b/Src/StdLib/Lib/lib2to3/fixes/fix_repr.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_repr.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_repr.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_set_literal.py b/Src/StdLib/Lib/lib2to3/fixes/fix_set_literal.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_set_literal.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_set_literal.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_standarderror.py b/Src/StdLib/Lib/lib2to3/fixes/fix_standarderror.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_standarderror.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_standarderror.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py b/Src/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_sys_exc.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_throw.py b/Src/StdLib/Lib/lib2to3/fixes/fix_throw.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_throw.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_throw.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py b/Src/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_tuple_params.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_types.py b/Src/StdLib/Lib/lib2to3/fixes/fix_types.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_types.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_types.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_unicode.py b/Src/StdLib/Lib/lib2to3/fixes/fix_unicode.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_unicode.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_unicode.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_urllib.py b/Src/StdLib/Lib/lib2to3/fixes/fix_urllib.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_urllib.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_urllib.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py b/Src/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_ws_comma.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_xrange.py b/Src/StdLib/Lib/lib2to3/fixes/fix_xrange.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_xrange.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_xrange.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py b/Src/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_xreadlines.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py diff --git a/StdLib/Lib/lib2to3/fixes/fix_zip.py b/Src/StdLib/Lib/lib2to3/fixes/fix_zip.py similarity index 100% rename from StdLib/Lib/lib2to3/fixes/fix_zip.py rename to Src/StdLib/Lib/lib2to3/fixes/fix_zip.py diff --git a/StdLib/Lib/lib2to3/main.py b/Src/StdLib/Lib/lib2to3/main.py similarity index 100% rename from StdLib/Lib/lib2to3/main.py rename to Src/StdLib/Lib/lib2to3/main.py diff --git a/StdLib/Lib/lib2to3/patcomp.py b/Src/StdLib/Lib/lib2to3/patcomp.py similarity index 100% rename from StdLib/Lib/lib2to3/patcomp.py rename to Src/StdLib/Lib/lib2to3/patcomp.py diff --git a/StdLib/Lib/lib2to3/pgen2/__init__.py b/Src/StdLib/Lib/lib2to3/pgen2/__init__.py similarity index 100% rename from StdLib/Lib/lib2to3/pgen2/__init__.py rename to Src/StdLib/Lib/lib2to3/pgen2/__init__.py diff --git a/StdLib/Lib/lib2to3/pgen2/conv.py b/Src/StdLib/Lib/lib2to3/pgen2/conv.py similarity index 100% rename from StdLib/Lib/lib2to3/pgen2/conv.py rename to Src/StdLib/Lib/lib2to3/pgen2/conv.py diff --git a/StdLib/Lib/lib2to3/pgen2/driver.py b/Src/StdLib/Lib/lib2to3/pgen2/driver.py similarity index 100% rename from StdLib/Lib/lib2to3/pgen2/driver.py rename to Src/StdLib/Lib/lib2to3/pgen2/driver.py diff --git a/StdLib/Lib/lib2to3/pgen2/grammar.py b/Src/StdLib/Lib/lib2to3/pgen2/grammar.py similarity index 100% rename from StdLib/Lib/lib2to3/pgen2/grammar.py rename to Src/StdLib/Lib/lib2to3/pgen2/grammar.py diff --git a/StdLib/Lib/lib2to3/pgen2/literals.py b/Src/StdLib/Lib/lib2to3/pgen2/literals.py similarity index 100% rename from StdLib/Lib/lib2to3/pgen2/literals.py rename to Src/StdLib/Lib/lib2to3/pgen2/literals.py diff --git a/StdLib/Lib/lib2to3/pgen2/parse.py b/Src/StdLib/Lib/lib2to3/pgen2/parse.py similarity index 100% rename from StdLib/Lib/lib2to3/pgen2/parse.py rename to Src/StdLib/Lib/lib2to3/pgen2/parse.py diff --git a/StdLib/Lib/lib2to3/pgen2/pgen.py b/Src/StdLib/Lib/lib2to3/pgen2/pgen.py similarity index 100% rename from StdLib/Lib/lib2to3/pgen2/pgen.py rename to Src/StdLib/Lib/lib2to3/pgen2/pgen.py diff --git a/StdLib/Lib/lib2to3/pgen2/token.py b/Src/StdLib/Lib/lib2to3/pgen2/token.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/lib2to3/pgen2/token.py rename to Src/StdLib/Lib/lib2to3/pgen2/token.py diff --git a/StdLib/Lib/lib2to3/pgen2/tokenize.py b/Src/StdLib/Lib/lib2to3/pgen2/tokenize.py similarity index 100% rename from StdLib/Lib/lib2to3/pgen2/tokenize.py rename to Src/StdLib/Lib/lib2to3/pgen2/tokenize.py diff --git a/StdLib/Lib/lib2to3/pygram.py b/Src/StdLib/Lib/lib2to3/pygram.py similarity index 100% rename from StdLib/Lib/lib2to3/pygram.py rename to Src/StdLib/Lib/lib2to3/pygram.py diff --git a/StdLib/Lib/lib2to3/pytree.py b/Src/StdLib/Lib/lib2to3/pytree.py similarity index 100% rename from StdLib/Lib/lib2to3/pytree.py rename to Src/StdLib/Lib/lib2to3/pytree.py diff --git a/StdLib/Lib/lib2to3/refactor.py b/Src/StdLib/Lib/lib2to3/refactor.py similarity index 100% rename from StdLib/Lib/lib2to3/refactor.py rename to Src/StdLib/Lib/lib2to3/refactor.py diff --git a/StdLib/Lib/lib2to3/tests/__init__.py b/Src/StdLib/Lib/lib2to3/tests/__init__.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/__init__.py rename to Src/StdLib/Lib/lib2to3/tests/__init__.py diff --git a/StdLib/Lib/lib2to3/tests/__main__.py b/Src/StdLib/Lib/lib2to3/tests/__main__.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/__main__.py rename to Src/StdLib/Lib/lib2to3/tests/__main__.py diff --git a/StdLib/Lib/lib2to3/tests/data/README b/Src/StdLib/Lib/lib2to3/tests/data/README similarity index 100% rename from StdLib/Lib/lib2to3/tests/data/README rename to Src/StdLib/Lib/lib2to3/tests/data/README diff --git a/StdLib/Lib/lib2to3/tests/data/bom.py b/Src/StdLib/Lib/lib2to3/tests/data/bom.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/data/bom.py rename to Src/StdLib/Lib/lib2to3/tests/data/bom.py diff --git a/StdLib/Lib/lib2to3/tests/data/crlf.py b/Src/StdLib/Lib/lib2to3/tests/data/crlf.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/data/crlf.py rename to Src/StdLib/Lib/lib2to3/tests/data/crlf.py diff --git a/StdLib/Lib/lib2to3/tests/data/different_encoding.py b/Src/StdLib/Lib/lib2to3/tests/data/different_encoding.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/data/different_encoding.py rename to Src/StdLib/Lib/lib2to3/tests/data/different_encoding.py diff --git a/StdLib/Lib/lib2to3/tests/data/false_encoding.py b/Src/StdLib/Lib/lib2to3/tests/data/false_encoding.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/data/false_encoding.py rename to Src/StdLib/Lib/lib2to3/tests/data/false_encoding.py diff --git a/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py b/Src/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py rename to Src/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py diff --git a/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py b/Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py rename to Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py diff --git a/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py b/Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py rename to Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py diff --git a/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py b/Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py rename to Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py diff --git a/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py b/Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py rename to Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py diff --git a/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py b/Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py rename to Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py diff --git a/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py b/Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py rename to Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py diff --git a/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py b/Src/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py rename to Src/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py diff --git a/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py b/Src/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py rename to Src/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py diff --git a/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py b/Src/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/data/infinite_recursion.py rename to Src/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py diff --git a/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py b/Src/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py rename to Src/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py diff --git a/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py b/Src/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py rename to Src/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py diff --git a/StdLib/Lib/lib2to3/tests/pytree_idempotency.py b/Src/StdLib/Lib/lib2to3/tests/pytree_idempotency.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/lib2to3/tests/pytree_idempotency.py rename to Src/StdLib/Lib/lib2to3/tests/pytree_idempotency.py diff --git a/StdLib/Lib/lib2to3/tests/support.py b/Src/StdLib/Lib/lib2to3/tests/support.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/support.py rename to Src/StdLib/Lib/lib2to3/tests/support.py diff --git a/StdLib/Lib/lib2to3/tests/test_all_fixers.py b/Src/StdLib/Lib/lib2to3/tests/test_all_fixers.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/test_all_fixers.py rename to Src/StdLib/Lib/lib2to3/tests/test_all_fixers.py diff --git a/StdLib/Lib/lib2to3/tests/test_fixers.py b/Src/StdLib/Lib/lib2to3/tests/test_fixers.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/test_fixers.py rename to Src/StdLib/Lib/lib2to3/tests/test_fixers.py diff --git a/StdLib/Lib/lib2to3/tests/test_main.py b/Src/StdLib/Lib/lib2to3/tests/test_main.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/test_main.py rename to Src/StdLib/Lib/lib2to3/tests/test_main.py diff --git a/StdLib/Lib/lib2to3/tests/test_parser.py b/Src/StdLib/Lib/lib2to3/tests/test_parser.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/test_parser.py rename to Src/StdLib/Lib/lib2to3/tests/test_parser.py diff --git a/StdLib/Lib/lib2to3/tests/test_pytree.py b/Src/StdLib/Lib/lib2to3/tests/test_pytree.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/test_pytree.py rename to Src/StdLib/Lib/lib2to3/tests/test_pytree.py diff --git a/StdLib/Lib/lib2to3/tests/test_refactor.py b/Src/StdLib/Lib/lib2to3/tests/test_refactor.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/test_refactor.py rename to Src/StdLib/Lib/lib2to3/tests/test_refactor.py diff --git a/StdLib/Lib/lib2to3/tests/test_util.py b/Src/StdLib/Lib/lib2to3/tests/test_util.py similarity index 100% rename from StdLib/Lib/lib2to3/tests/test_util.py rename to Src/StdLib/Lib/lib2to3/tests/test_util.py diff --git a/StdLib/Lib/linecache.py b/Src/StdLib/Lib/linecache.py similarity index 100% rename from StdLib/Lib/linecache.py rename to Src/StdLib/Lib/linecache.py diff --git a/StdLib/Lib/locale.py b/Src/StdLib/Lib/locale.py similarity index 100% rename from StdLib/Lib/locale.py rename to Src/StdLib/Lib/locale.py diff --git a/StdLib/Lib/logging/__init__.py b/Src/StdLib/Lib/logging/__init__.py similarity index 100% rename from StdLib/Lib/logging/__init__.py rename to Src/StdLib/Lib/logging/__init__.py diff --git a/StdLib/Lib/logging/config.py b/Src/StdLib/Lib/logging/config.py similarity index 100% rename from StdLib/Lib/logging/config.py rename to Src/StdLib/Lib/logging/config.py diff --git a/StdLib/Lib/logging/handlers.py b/Src/StdLib/Lib/logging/handlers.py similarity index 100% rename from StdLib/Lib/logging/handlers.py rename to Src/StdLib/Lib/logging/handlers.py diff --git a/StdLib/Lib/lzma.py b/Src/StdLib/Lib/lzma.py similarity index 100% rename from StdLib/Lib/lzma.py rename to Src/StdLib/Lib/lzma.py diff --git a/StdLib/Lib/macpath.py b/Src/StdLib/Lib/macpath.py similarity index 100% rename from StdLib/Lib/macpath.py rename to Src/StdLib/Lib/macpath.py diff --git a/StdLib/Lib/macurl2path.py b/Src/StdLib/Lib/macurl2path.py similarity index 100% rename from StdLib/Lib/macurl2path.py rename to Src/StdLib/Lib/macurl2path.py diff --git a/StdLib/Lib/mailbox.py b/Src/StdLib/Lib/mailbox.py similarity index 100% rename from StdLib/Lib/mailbox.py rename to Src/StdLib/Lib/mailbox.py diff --git a/StdLib/Lib/mailcap.py b/Src/StdLib/Lib/mailcap.py similarity index 100% rename from StdLib/Lib/mailcap.py rename to Src/StdLib/Lib/mailcap.py diff --git a/StdLib/Lib/mimetypes.py b/Src/StdLib/Lib/mimetypes.py similarity index 100% rename from StdLib/Lib/mimetypes.py rename to Src/StdLib/Lib/mimetypes.py diff --git a/StdLib/Lib/modulefinder.py b/Src/StdLib/Lib/modulefinder.py similarity index 100% rename from StdLib/Lib/modulefinder.py rename to Src/StdLib/Lib/modulefinder.py diff --git a/StdLib/Lib/msilib/__init__.py b/Src/StdLib/Lib/msilib/__init__.py similarity index 100% rename from StdLib/Lib/msilib/__init__.py rename to Src/StdLib/Lib/msilib/__init__.py diff --git a/StdLib/Lib/msilib/schema.py b/Src/StdLib/Lib/msilib/schema.py similarity index 100% rename from StdLib/Lib/msilib/schema.py rename to Src/StdLib/Lib/msilib/schema.py diff --git a/StdLib/Lib/msilib/sequence.py b/Src/StdLib/Lib/msilib/sequence.py similarity index 100% rename from StdLib/Lib/msilib/sequence.py rename to Src/StdLib/Lib/msilib/sequence.py diff --git a/StdLib/Lib/msilib/text.py b/Src/StdLib/Lib/msilib/text.py similarity index 100% rename from StdLib/Lib/msilib/text.py rename to Src/StdLib/Lib/msilib/text.py diff --git a/StdLib/Lib/multiprocessing/__init__.py b/Src/StdLib/Lib/multiprocessing/__init__.py similarity index 100% rename from StdLib/Lib/multiprocessing/__init__.py rename to Src/StdLib/Lib/multiprocessing/__init__.py diff --git a/StdLib/Lib/multiprocessing/connection.py b/Src/StdLib/Lib/multiprocessing/connection.py similarity index 100% rename from StdLib/Lib/multiprocessing/connection.py rename to Src/StdLib/Lib/multiprocessing/connection.py diff --git a/StdLib/Lib/multiprocessing/context.py b/Src/StdLib/Lib/multiprocessing/context.py similarity index 100% rename from StdLib/Lib/multiprocessing/context.py rename to Src/StdLib/Lib/multiprocessing/context.py diff --git a/StdLib/Lib/multiprocessing/dummy/__init__.py b/Src/StdLib/Lib/multiprocessing/dummy/__init__.py similarity index 100% rename from StdLib/Lib/multiprocessing/dummy/__init__.py rename to Src/StdLib/Lib/multiprocessing/dummy/__init__.py diff --git a/StdLib/Lib/multiprocessing/dummy/connection.py b/Src/StdLib/Lib/multiprocessing/dummy/connection.py similarity index 100% rename from StdLib/Lib/multiprocessing/dummy/connection.py rename to Src/StdLib/Lib/multiprocessing/dummy/connection.py diff --git a/StdLib/Lib/multiprocessing/forkserver.py b/Src/StdLib/Lib/multiprocessing/forkserver.py similarity index 100% rename from StdLib/Lib/multiprocessing/forkserver.py rename to Src/StdLib/Lib/multiprocessing/forkserver.py diff --git a/StdLib/Lib/multiprocessing/heap.py b/Src/StdLib/Lib/multiprocessing/heap.py similarity index 100% rename from StdLib/Lib/multiprocessing/heap.py rename to Src/StdLib/Lib/multiprocessing/heap.py diff --git a/StdLib/Lib/multiprocessing/managers.py b/Src/StdLib/Lib/multiprocessing/managers.py similarity index 100% rename from StdLib/Lib/multiprocessing/managers.py rename to Src/StdLib/Lib/multiprocessing/managers.py diff --git a/StdLib/Lib/multiprocessing/pool.py b/Src/StdLib/Lib/multiprocessing/pool.py similarity index 100% rename from StdLib/Lib/multiprocessing/pool.py rename to Src/StdLib/Lib/multiprocessing/pool.py diff --git a/StdLib/Lib/multiprocessing/popen_fork.py b/Src/StdLib/Lib/multiprocessing/popen_fork.py similarity index 100% rename from StdLib/Lib/multiprocessing/popen_fork.py rename to Src/StdLib/Lib/multiprocessing/popen_fork.py diff --git a/StdLib/Lib/multiprocessing/popen_forkserver.py b/Src/StdLib/Lib/multiprocessing/popen_forkserver.py similarity index 100% rename from StdLib/Lib/multiprocessing/popen_forkserver.py rename to Src/StdLib/Lib/multiprocessing/popen_forkserver.py diff --git a/StdLib/Lib/multiprocessing/popen_spawn_posix.py b/Src/StdLib/Lib/multiprocessing/popen_spawn_posix.py similarity index 100% rename from StdLib/Lib/multiprocessing/popen_spawn_posix.py rename to Src/StdLib/Lib/multiprocessing/popen_spawn_posix.py diff --git a/StdLib/Lib/multiprocessing/popen_spawn_win32.py b/Src/StdLib/Lib/multiprocessing/popen_spawn_win32.py similarity index 100% rename from StdLib/Lib/multiprocessing/popen_spawn_win32.py rename to Src/StdLib/Lib/multiprocessing/popen_spawn_win32.py diff --git a/StdLib/Lib/multiprocessing/process.py b/Src/StdLib/Lib/multiprocessing/process.py similarity index 100% rename from StdLib/Lib/multiprocessing/process.py rename to Src/StdLib/Lib/multiprocessing/process.py diff --git a/StdLib/Lib/multiprocessing/queues.py b/Src/StdLib/Lib/multiprocessing/queues.py similarity index 100% rename from StdLib/Lib/multiprocessing/queues.py rename to Src/StdLib/Lib/multiprocessing/queues.py diff --git a/StdLib/Lib/multiprocessing/reduction.py b/Src/StdLib/Lib/multiprocessing/reduction.py similarity index 100% rename from StdLib/Lib/multiprocessing/reduction.py rename to Src/StdLib/Lib/multiprocessing/reduction.py diff --git a/StdLib/Lib/multiprocessing/resource_sharer.py b/Src/StdLib/Lib/multiprocessing/resource_sharer.py similarity index 100% rename from StdLib/Lib/multiprocessing/resource_sharer.py rename to Src/StdLib/Lib/multiprocessing/resource_sharer.py diff --git a/StdLib/Lib/multiprocessing/semaphore_tracker.py b/Src/StdLib/Lib/multiprocessing/semaphore_tracker.py similarity index 100% rename from StdLib/Lib/multiprocessing/semaphore_tracker.py rename to Src/StdLib/Lib/multiprocessing/semaphore_tracker.py diff --git a/StdLib/Lib/multiprocessing/sharedctypes.py b/Src/StdLib/Lib/multiprocessing/sharedctypes.py similarity index 100% rename from StdLib/Lib/multiprocessing/sharedctypes.py rename to Src/StdLib/Lib/multiprocessing/sharedctypes.py diff --git a/StdLib/Lib/multiprocessing/spawn.py b/Src/StdLib/Lib/multiprocessing/spawn.py similarity index 100% rename from StdLib/Lib/multiprocessing/spawn.py rename to Src/StdLib/Lib/multiprocessing/spawn.py diff --git a/StdLib/Lib/multiprocessing/synchronize.py b/Src/StdLib/Lib/multiprocessing/synchronize.py similarity index 100% rename from StdLib/Lib/multiprocessing/synchronize.py rename to Src/StdLib/Lib/multiprocessing/synchronize.py diff --git a/StdLib/Lib/multiprocessing/util.py b/Src/StdLib/Lib/multiprocessing/util.py similarity index 100% rename from StdLib/Lib/multiprocessing/util.py rename to Src/StdLib/Lib/multiprocessing/util.py diff --git a/StdLib/Lib/netrc.py b/Src/StdLib/Lib/netrc.py similarity index 100% rename from StdLib/Lib/netrc.py rename to Src/StdLib/Lib/netrc.py diff --git a/StdLib/Lib/nntplib.py b/Src/StdLib/Lib/nntplib.py similarity index 100% rename from StdLib/Lib/nntplib.py rename to Src/StdLib/Lib/nntplib.py diff --git a/StdLib/Lib/ntpath.py b/Src/StdLib/Lib/ntpath.py similarity index 100% rename from StdLib/Lib/ntpath.py rename to Src/StdLib/Lib/ntpath.py diff --git a/StdLib/Lib/nturl2path.py b/Src/StdLib/Lib/nturl2path.py similarity index 100% rename from StdLib/Lib/nturl2path.py rename to Src/StdLib/Lib/nturl2path.py diff --git a/StdLib/Lib/numbers.py b/Src/StdLib/Lib/numbers.py similarity index 100% rename from StdLib/Lib/numbers.py rename to Src/StdLib/Lib/numbers.py diff --git a/StdLib/Lib/opcode.py b/Src/StdLib/Lib/opcode.py similarity index 100% rename from StdLib/Lib/opcode.py rename to Src/StdLib/Lib/opcode.py diff --git a/StdLib/Lib/operator.py b/Src/StdLib/Lib/operator.py similarity index 100% rename from StdLib/Lib/operator.py rename to Src/StdLib/Lib/operator.py diff --git a/StdLib/Lib/optparse.py b/Src/StdLib/Lib/optparse.py similarity index 100% rename from StdLib/Lib/optparse.py rename to Src/StdLib/Lib/optparse.py diff --git a/StdLib/Lib/os.py b/Src/StdLib/Lib/os.py similarity index 100% rename from StdLib/Lib/os.py rename to Src/StdLib/Lib/os.py diff --git a/StdLib/Lib/pathlib.py b/Src/StdLib/Lib/pathlib.py similarity index 100% rename from StdLib/Lib/pathlib.py rename to Src/StdLib/Lib/pathlib.py diff --git a/StdLib/Lib/pdb.py b/Src/StdLib/Lib/pdb.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/pdb.py rename to Src/StdLib/Lib/pdb.py diff --git a/StdLib/Lib/pickle.py b/Src/StdLib/Lib/pickle.py similarity index 100% rename from StdLib/Lib/pickle.py rename to Src/StdLib/Lib/pickle.py diff --git a/StdLib/Lib/pickletools.py b/Src/StdLib/Lib/pickletools.py similarity index 100% rename from StdLib/Lib/pickletools.py rename to Src/StdLib/Lib/pickletools.py diff --git a/StdLib/Lib/pipes.py b/Src/StdLib/Lib/pipes.py similarity index 100% rename from StdLib/Lib/pipes.py rename to Src/StdLib/Lib/pipes.py diff --git a/StdLib/Lib/pkgutil.py b/Src/StdLib/Lib/pkgutil.py similarity index 100% rename from StdLib/Lib/pkgutil.py rename to Src/StdLib/Lib/pkgutil.py diff --git a/StdLib/Lib/platform.py b/Src/StdLib/Lib/platform.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/platform.py rename to Src/StdLib/Lib/platform.py diff --git a/StdLib/Lib/plistlib.py b/Src/StdLib/Lib/plistlib.py similarity index 100% rename from StdLib/Lib/plistlib.py rename to Src/StdLib/Lib/plistlib.py diff --git a/StdLib/Lib/poplib.py b/Src/StdLib/Lib/poplib.py similarity index 100% rename from StdLib/Lib/poplib.py rename to Src/StdLib/Lib/poplib.py diff --git a/StdLib/Lib/posixpath.py b/Src/StdLib/Lib/posixpath.py similarity index 100% rename from StdLib/Lib/posixpath.py rename to Src/StdLib/Lib/posixpath.py diff --git a/StdLib/Lib/pprint.py b/Src/StdLib/Lib/pprint.py similarity index 100% rename from StdLib/Lib/pprint.py rename to Src/StdLib/Lib/pprint.py diff --git a/StdLib/Lib/profile.py b/Src/StdLib/Lib/profile.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/profile.py rename to Src/StdLib/Lib/profile.py diff --git a/StdLib/Lib/pstats.py b/Src/StdLib/Lib/pstats.py similarity index 100% rename from StdLib/Lib/pstats.py rename to Src/StdLib/Lib/pstats.py diff --git a/StdLib/Lib/pty.py b/Src/StdLib/Lib/pty.py similarity index 100% rename from StdLib/Lib/pty.py rename to Src/StdLib/Lib/pty.py diff --git a/StdLib/Lib/py_compile.py b/Src/StdLib/Lib/py_compile.py similarity index 100% rename from StdLib/Lib/py_compile.py rename to Src/StdLib/Lib/py_compile.py diff --git a/StdLib/Lib/pyclbr.py b/Src/StdLib/Lib/pyclbr.py similarity index 100% rename from StdLib/Lib/pyclbr.py rename to Src/StdLib/Lib/pyclbr.py diff --git a/StdLib/Lib/pydoc.py b/Src/StdLib/Lib/pydoc.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/pydoc.py rename to Src/StdLib/Lib/pydoc.py diff --git a/StdLib/Lib/pydoc_data/__init__.py b/Src/StdLib/Lib/pydoc_data/__init__.py similarity index 100% rename from StdLib/Lib/pydoc_data/__init__.py rename to Src/StdLib/Lib/pydoc_data/__init__.py diff --git a/StdLib/Lib/pydoc_data/_pydoc.css b/Src/StdLib/Lib/pydoc_data/_pydoc.css similarity index 100% rename from StdLib/Lib/pydoc_data/_pydoc.css rename to Src/StdLib/Lib/pydoc_data/_pydoc.css diff --git a/StdLib/Lib/pydoc_data/topics.py b/Src/StdLib/Lib/pydoc_data/topics.py similarity index 100% rename from StdLib/Lib/pydoc_data/topics.py rename to Src/StdLib/Lib/pydoc_data/topics.py diff --git a/StdLib/Lib/queue.py b/Src/StdLib/Lib/queue.py similarity index 100% rename from StdLib/Lib/queue.py rename to Src/StdLib/Lib/queue.py diff --git a/StdLib/Lib/quopri.py b/Src/StdLib/Lib/quopri.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/quopri.py rename to Src/StdLib/Lib/quopri.py diff --git a/StdLib/Lib/random.py b/Src/StdLib/Lib/random.py similarity index 100% rename from StdLib/Lib/random.py rename to Src/StdLib/Lib/random.py diff --git a/StdLib/Lib/re.py b/Src/StdLib/Lib/re.py similarity index 100% rename from StdLib/Lib/re.py rename to Src/StdLib/Lib/re.py diff --git a/StdLib/Lib/reprlib.py b/Src/StdLib/Lib/reprlib.py similarity index 100% rename from StdLib/Lib/reprlib.py rename to Src/StdLib/Lib/reprlib.py diff --git a/StdLib/Lib/rlcompleter.py b/Src/StdLib/Lib/rlcompleter.py similarity index 100% rename from StdLib/Lib/rlcompleter.py rename to Src/StdLib/Lib/rlcompleter.py diff --git a/StdLib/Lib/runpy.py b/Src/StdLib/Lib/runpy.py similarity index 100% rename from StdLib/Lib/runpy.py rename to Src/StdLib/Lib/runpy.py diff --git a/StdLib/Lib/sched.py b/Src/StdLib/Lib/sched.py similarity index 100% rename from StdLib/Lib/sched.py rename to Src/StdLib/Lib/sched.py diff --git a/StdLib/Lib/selectors.py b/Src/StdLib/Lib/selectors.py similarity index 100% rename from StdLib/Lib/selectors.py rename to Src/StdLib/Lib/selectors.py diff --git a/StdLib/Lib/shelve.py b/Src/StdLib/Lib/shelve.py similarity index 100% rename from StdLib/Lib/shelve.py rename to Src/StdLib/Lib/shelve.py diff --git a/StdLib/Lib/shlex.py b/Src/StdLib/Lib/shlex.py similarity index 100% rename from StdLib/Lib/shlex.py rename to Src/StdLib/Lib/shlex.py diff --git a/StdLib/Lib/shutil.py b/Src/StdLib/Lib/shutil.py similarity index 100% rename from StdLib/Lib/shutil.py rename to Src/StdLib/Lib/shutil.py diff --git a/StdLib/Lib/site-packages/README b/Src/StdLib/Lib/site-packages/README similarity index 100% rename from StdLib/Lib/site-packages/README rename to Src/StdLib/Lib/site-packages/README diff --git a/StdLib/Lib/site.py b/Src/StdLib/Lib/site.py similarity index 100% rename from StdLib/Lib/site.py rename to Src/StdLib/Lib/site.py diff --git a/StdLib/Lib/smtpd.py b/Src/StdLib/Lib/smtpd.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/smtpd.py rename to Src/StdLib/Lib/smtpd.py diff --git a/StdLib/Lib/smtplib.py b/Src/StdLib/Lib/smtplib.py similarity index 100% rename from StdLib/Lib/smtplib.py rename to Src/StdLib/Lib/smtplib.py diff --git a/StdLib/Lib/sndhdr.py b/Src/StdLib/Lib/sndhdr.py similarity index 100% rename from StdLib/Lib/sndhdr.py rename to Src/StdLib/Lib/sndhdr.py diff --git a/StdLib/Lib/socket.py b/Src/StdLib/Lib/socket.py similarity index 100% rename from StdLib/Lib/socket.py rename to Src/StdLib/Lib/socket.py diff --git a/StdLib/Lib/socketserver.py b/Src/StdLib/Lib/socketserver.py similarity index 100% rename from StdLib/Lib/socketserver.py rename to Src/StdLib/Lib/socketserver.py diff --git a/StdLib/Lib/sqlite3/__init__.py b/Src/StdLib/Lib/sqlite3/__init__.py similarity index 100% rename from StdLib/Lib/sqlite3/__init__.py rename to Src/StdLib/Lib/sqlite3/__init__.py diff --git a/StdLib/Lib/sqlite3/dbapi2.py b/Src/StdLib/Lib/sqlite3/dbapi2.py similarity index 100% rename from StdLib/Lib/sqlite3/dbapi2.py rename to Src/StdLib/Lib/sqlite3/dbapi2.py diff --git a/StdLib/Lib/sqlite3/dump.py b/Src/StdLib/Lib/sqlite3/dump.py similarity index 100% rename from StdLib/Lib/sqlite3/dump.py rename to Src/StdLib/Lib/sqlite3/dump.py diff --git a/StdLib/Lib/sqlite3/test/__init__.py b/Src/StdLib/Lib/sqlite3/test/__init__.py similarity index 100% rename from StdLib/Lib/sqlite3/test/__init__.py rename to Src/StdLib/Lib/sqlite3/test/__init__.py diff --git a/StdLib/Lib/sqlite3/test/dbapi.py b/Src/StdLib/Lib/sqlite3/test/dbapi.py similarity index 100% rename from StdLib/Lib/sqlite3/test/dbapi.py rename to Src/StdLib/Lib/sqlite3/test/dbapi.py diff --git a/StdLib/Lib/sqlite3/test/dump.py b/Src/StdLib/Lib/sqlite3/test/dump.py similarity index 100% rename from StdLib/Lib/sqlite3/test/dump.py rename to Src/StdLib/Lib/sqlite3/test/dump.py diff --git a/StdLib/Lib/sqlite3/test/factory.py b/Src/StdLib/Lib/sqlite3/test/factory.py similarity index 100% rename from StdLib/Lib/sqlite3/test/factory.py rename to Src/StdLib/Lib/sqlite3/test/factory.py diff --git a/StdLib/Lib/sqlite3/test/hooks.py b/Src/StdLib/Lib/sqlite3/test/hooks.py similarity index 100% rename from StdLib/Lib/sqlite3/test/hooks.py rename to Src/StdLib/Lib/sqlite3/test/hooks.py diff --git a/StdLib/Lib/sqlite3/test/regression.py b/Src/StdLib/Lib/sqlite3/test/regression.py similarity index 100% rename from StdLib/Lib/sqlite3/test/regression.py rename to Src/StdLib/Lib/sqlite3/test/regression.py diff --git a/StdLib/Lib/sqlite3/test/transactions.py b/Src/StdLib/Lib/sqlite3/test/transactions.py similarity index 100% rename from StdLib/Lib/sqlite3/test/transactions.py rename to Src/StdLib/Lib/sqlite3/test/transactions.py diff --git a/StdLib/Lib/sqlite3/test/types.py b/Src/StdLib/Lib/sqlite3/test/types.py similarity index 100% rename from StdLib/Lib/sqlite3/test/types.py rename to Src/StdLib/Lib/sqlite3/test/types.py diff --git a/StdLib/Lib/sqlite3/test/userfunctions.py b/Src/StdLib/Lib/sqlite3/test/userfunctions.py similarity index 100% rename from StdLib/Lib/sqlite3/test/userfunctions.py rename to Src/StdLib/Lib/sqlite3/test/userfunctions.py diff --git a/StdLib/Lib/sre_compile.py b/Src/StdLib/Lib/sre_compile.py similarity index 100% rename from StdLib/Lib/sre_compile.py rename to Src/StdLib/Lib/sre_compile.py diff --git a/StdLib/Lib/sre_constants.py b/Src/StdLib/Lib/sre_constants.py similarity index 100% rename from StdLib/Lib/sre_constants.py rename to Src/StdLib/Lib/sre_constants.py diff --git a/StdLib/Lib/sre_parse.py b/Src/StdLib/Lib/sre_parse.py similarity index 100% rename from StdLib/Lib/sre_parse.py rename to Src/StdLib/Lib/sre_parse.py diff --git a/StdLib/Lib/ssl.py b/Src/StdLib/Lib/ssl.py similarity index 100% rename from StdLib/Lib/ssl.py rename to Src/StdLib/Lib/ssl.py diff --git a/StdLib/Lib/stat.py b/Src/StdLib/Lib/stat.py similarity index 100% rename from StdLib/Lib/stat.py rename to Src/StdLib/Lib/stat.py diff --git a/StdLib/Lib/statistics.py b/Src/StdLib/Lib/statistics.py similarity index 100% rename from StdLib/Lib/statistics.py rename to Src/StdLib/Lib/statistics.py diff --git a/StdLib/Lib/string.py b/Src/StdLib/Lib/string.py similarity index 100% rename from StdLib/Lib/string.py rename to Src/StdLib/Lib/string.py diff --git a/StdLib/Lib/stringprep.py b/Src/StdLib/Lib/stringprep.py similarity index 100% rename from StdLib/Lib/stringprep.py rename to Src/StdLib/Lib/stringprep.py diff --git a/StdLib/Lib/struct.py b/Src/StdLib/Lib/struct.py similarity index 100% rename from StdLib/Lib/struct.py rename to Src/StdLib/Lib/struct.py diff --git a/StdLib/Lib/subprocess.py b/Src/StdLib/Lib/subprocess.py similarity index 100% rename from StdLib/Lib/subprocess.py rename to Src/StdLib/Lib/subprocess.py diff --git a/StdLib/Lib/sunau.py b/Src/StdLib/Lib/sunau.py similarity index 100% rename from StdLib/Lib/sunau.py rename to Src/StdLib/Lib/sunau.py diff --git a/StdLib/Lib/symbol.py b/Src/StdLib/Lib/symbol.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/symbol.py rename to Src/StdLib/Lib/symbol.py diff --git a/StdLib/Lib/symtable.py b/Src/StdLib/Lib/symtable.py similarity index 100% rename from StdLib/Lib/symtable.py rename to Src/StdLib/Lib/symtable.py diff --git a/StdLib/Lib/sysconfig.py b/Src/StdLib/Lib/sysconfig.py similarity index 100% rename from StdLib/Lib/sysconfig.py rename to Src/StdLib/Lib/sysconfig.py diff --git a/StdLib/Lib/tabnanny.py b/Src/StdLib/Lib/tabnanny.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/tabnanny.py rename to Src/StdLib/Lib/tabnanny.py diff --git a/StdLib/Lib/tarfile.py b/Src/StdLib/Lib/tarfile.py similarity index 100% rename from StdLib/Lib/tarfile.py rename to Src/StdLib/Lib/tarfile.py diff --git a/StdLib/Lib/telnetlib.py b/Src/StdLib/Lib/telnetlib.py similarity index 100% rename from StdLib/Lib/telnetlib.py rename to Src/StdLib/Lib/telnetlib.py diff --git a/StdLib/Lib/tempfile.py b/Src/StdLib/Lib/tempfile.py similarity index 100% rename from StdLib/Lib/tempfile.py rename to Src/StdLib/Lib/tempfile.py diff --git a/StdLib/Lib/test/185test.db b/Src/StdLib/Lib/test/185test.db similarity index 100% rename from StdLib/Lib/test/185test.db rename to Src/StdLib/Lib/test/185test.db diff --git a/StdLib/Lib/test/Sine-1000Hz-300ms.aif b/Src/StdLib/Lib/test/Sine-1000Hz-300ms.aif similarity index 100% rename from StdLib/Lib/test/Sine-1000Hz-300ms.aif rename to Src/StdLib/Lib/test/Sine-1000Hz-300ms.aif diff --git a/StdLib/Lib/test/__init__.py b/Src/StdLib/Lib/test/__init__.py similarity index 100% rename from StdLib/Lib/test/__init__.py rename to Src/StdLib/Lib/test/__init__.py diff --git a/StdLib/Lib/test/__main__.py b/Src/StdLib/Lib/test/__main__.py similarity index 100% rename from StdLib/Lib/test/__main__.py rename to Src/StdLib/Lib/test/__main__.py diff --git a/StdLib/Lib/test/_test_multiprocessing.py b/Src/StdLib/Lib/test/_test_multiprocessing.py similarity index 100% rename from StdLib/Lib/test/_test_multiprocessing.py rename to Src/StdLib/Lib/test/_test_multiprocessing.py diff --git a/StdLib/Lib/test/audiodata/pluck-alaw.aifc b/Src/StdLib/Lib/test/audiodata/pluck-alaw.aifc similarity index 100% rename from StdLib/Lib/test/audiodata/pluck-alaw.aifc rename to Src/StdLib/Lib/test/audiodata/pluck-alaw.aifc diff --git a/StdLib/Lib/test/audiodata/pluck-pcm16.aiff b/Src/StdLib/Lib/test/audiodata/pluck-pcm16.aiff similarity index 100% rename from StdLib/Lib/test/audiodata/pluck-pcm16.aiff rename to Src/StdLib/Lib/test/audiodata/pluck-pcm16.aiff diff --git a/StdLib/Lib/test/audiodata/pluck-pcm16.au b/Src/StdLib/Lib/test/audiodata/pluck-pcm16.au similarity index 100% rename from StdLib/Lib/test/audiodata/pluck-pcm16.au rename to Src/StdLib/Lib/test/audiodata/pluck-pcm16.au diff --git a/StdLib/Lib/test/audiodata/pluck-pcm16.wav b/Src/StdLib/Lib/test/audiodata/pluck-pcm16.wav similarity index 100% rename from StdLib/Lib/test/audiodata/pluck-pcm16.wav rename to Src/StdLib/Lib/test/audiodata/pluck-pcm16.wav diff --git a/StdLib/Lib/test/audiodata/pluck-pcm24.aiff b/Src/StdLib/Lib/test/audiodata/pluck-pcm24.aiff similarity index 100% rename from StdLib/Lib/test/audiodata/pluck-pcm24.aiff rename to Src/StdLib/Lib/test/audiodata/pluck-pcm24.aiff diff --git a/StdLib/Lib/test/audiodata/pluck-pcm24.au b/Src/StdLib/Lib/test/audiodata/pluck-pcm24.au similarity index 100% rename from StdLib/Lib/test/audiodata/pluck-pcm24.au rename to Src/StdLib/Lib/test/audiodata/pluck-pcm24.au diff --git a/StdLib/Lib/test/audiodata/pluck-pcm24.wav b/Src/StdLib/Lib/test/audiodata/pluck-pcm24.wav similarity index 100% rename from StdLib/Lib/test/audiodata/pluck-pcm24.wav rename to Src/StdLib/Lib/test/audiodata/pluck-pcm24.wav diff --git a/StdLib/Lib/test/audiodata/pluck-pcm32.aiff b/Src/StdLib/Lib/test/audiodata/pluck-pcm32.aiff similarity index 100% rename from StdLib/Lib/test/audiodata/pluck-pcm32.aiff rename to Src/StdLib/Lib/test/audiodata/pluck-pcm32.aiff diff --git a/StdLib/Lib/test/audiodata/pluck-pcm32.au b/Src/StdLib/Lib/test/audiodata/pluck-pcm32.au similarity index 100% rename from StdLib/Lib/test/audiodata/pluck-pcm32.au rename to Src/StdLib/Lib/test/audiodata/pluck-pcm32.au diff --git a/StdLib/Lib/test/audiodata/pluck-pcm32.wav b/Src/StdLib/Lib/test/audiodata/pluck-pcm32.wav similarity index 100% rename from StdLib/Lib/test/audiodata/pluck-pcm32.wav rename to Src/StdLib/Lib/test/audiodata/pluck-pcm32.wav diff --git a/StdLib/Lib/test/audiodata/pluck-pcm8.aiff b/Src/StdLib/Lib/test/audiodata/pluck-pcm8.aiff similarity index 100% rename from StdLib/Lib/test/audiodata/pluck-pcm8.aiff rename to Src/StdLib/Lib/test/audiodata/pluck-pcm8.aiff diff --git a/StdLib/Lib/test/audiodata/pluck-pcm8.au b/Src/StdLib/Lib/test/audiodata/pluck-pcm8.au similarity index 100% rename from StdLib/Lib/test/audiodata/pluck-pcm8.au rename to Src/StdLib/Lib/test/audiodata/pluck-pcm8.au diff --git a/StdLib/Lib/test/audiodata/pluck-pcm8.wav b/Src/StdLib/Lib/test/audiodata/pluck-pcm8.wav similarity index 100% rename from StdLib/Lib/test/audiodata/pluck-pcm8.wav rename to Src/StdLib/Lib/test/audiodata/pluck-pcm8.wav diff --git a/StdLib/Lib/test/audiodata/pluck-ulaw.aifc b/Src/StdLib/Lib/test/audiodata/pluck-ulaw.aifc similarity index 100% rename from StdLib/Lib/test/audiodata/pluck-ulaw.aifc rename to Src/StdLib/Lib/test/audiodata/pluck-ulaw.aifc diff --git a/StdLib/Lib/test/audiodata/pluck-ulaw.au b/Src/StdLib/Lib/test/audiodata/pluck-ulaw.au similarity index 100% rename from StdLib/Lib/test/audiodata/pluck-ulaw.au rename to Src/StdLib/Lib/test/audiodata/pluck-ulaw.au diff --git a/StdLib/Lib/test/audiotest.au b/Src/StdLib/Lib/test/audiotest.au similarity index 100% rename from StdLib/Lib/test/audiotest.au rename to Src/StdLib/Lib/test/audiotest.au diff --git a/StdLib/Lib/test/audiotests.py b/Src/StdLib/Lib/test/audiotests.py similarity index 100% rename from StdLib/Lib/test/audiotests.py rename to Src/StdLib/Lib/test/audiotests.py diff --git a/StdLib/Lib/test/autotest.py b/Src/StdLib/Lib/test/autotest.py similarity index 100% rename from StdLib/Lib/test/autotest.py rename to Src/StdLib/Lib/test/autotest.py diff --git a/StdLib/Lib/test/bad_coding.py b/Src/StdLib/Lib/test/bad_coding.py similarity index 100% rename from StdLib/Lib/test/bad_coding.py rename to Src/StdLib/Lib/test/bad_coding.py diff --git a/StdLib/Lib/test/bad_coding2.py b/Src/StdLib/Lib/test/bad_coding2.py similarity index 100% rename from StdLib/Lib/test/bad_coding2.py rename to Src/StdLib/Lib/test/bad_coding2.py diff --git a/StdLib/Lib/test/badcert.pem b/Src/StdLib/Lib/test/badcert.pem similarity index 100% rename from StdLib/Lib/test/badcert.pem rename to Src/StdLib/Lib/test/badcert.pem diff --git a/StdLib/Lib/test/badkey.pem b/Src/StdLib/Lib/test/badkey.pem similarity index 100% rename from StdLib/Lib/test/badkey.pem rename to Src/StdLib/Lib/test/badkey.pem diff --git a/StdLib/Lib/test/badsyntax_3131.py b/Src/StdLib/Lib/test/badsyntax_3131.py similarity index 100% rename from StdLib/Lib/test/badsyntax_3131.py rename to Src/StdLib/Lib/test/badsyntax_3131.py diff --git a/StdLib/Lib/test/badsyntax_future10.py b/Src/StdLib/Lib/test/badsyntax_future10.py similarity index 100% rename from StdLib/Lib/test/badsyntax_future10.py rename to Src/StdLib/Lib/test/badsyntax_future10.py diff --git a/StdLib/Lib/test/badsyntax_future3.py b/Src/StdLib/Lib/test/badsyntax_future3.py similarity index 100% rename from StdLib/Lib/test/badsyntax_future3.py rename to Src/StdLib/Lib/test/badsyntax_future3.py diff --git a/StdLib/Lib/test/badsyntax_future4.py b/Src/StdLib/Lib/test/badsyntax_future4.py similarity index 100% rename from StdLib/Lib/test/badsyntax_future4.py rename to Src/StdLib/Lib/test/badsyntax_future4.py diff --git a/StdLib/Lib/test/badsyntax_future5.py b/Src/StdLib/Lib/test/badsyntax_future5.py similarity index 100% rename from StdLib/Lib/test/badsyntax_future5.py rename to Src/StdLib/Lib/test/badsyntax_future5.py diff --git a/StdLib/Lib/test/badsyntax_future6.py b/Src/StdLib/Lib/test/badsyntax_future6.py similarity index 100% rename from StdLib/Lib/test/badsyntax_future6.py rename to Src/StdLib/Lib/test/badsyntax_future6.py diff --git a/StdLib/Lib/test/badsyntax_future7.py b/Src/StdLib/Lib/test/badsyntax_future7.py similarity index 100% rename from StdLib/Lib/test/badsyntax_future7.py rename to Src/StdLib/Lib/test/badsyntax_future7.py diff --git a/StdLib/Lib/test/badsyntax_future8.py b/Src/StdLib/Lib/test/badsyntax_future8.py similarity index 100% rename from StdLib/Lib/test/badsyntax_future8.py rename to Src/StdLib/Lib/test/badsyntax_future8.py diff --git a/StdLib/Lib/test/badsyntax_future9.py b/Src/StdLib/Lib/test/badsyntax_future9.py similarity index 100% rename from StdLib/Lib/test/badsyntax_future9.py rename to Src/StdLib/Lib/test/badsyntax_future9.py diff --git a/StdLib/Lib/test/badsyntax_pep3120.py b/Src/StdLib/Lib/test/badsyntax_pep3120.py similarity index 100% rename from StdLib/Lib/test/badsyntax_pep3120.py rename to Src/StdLib/Lib/test/badsyntax_pep3120.py diff --git a/StdLib/Lib/test/buffer_tests.py b/Src/StdLib/Lib/test/buffer_tests.py similarity index 100% rename from StdLib/Lib/test/buffer_tests.py rename to Src/StdLib/Lib/test/buffer_tests.py diff --git a/StdLib/Lib/test/bytecode_helper.py b/Src/StdLib/Lib/test/bytecode_helper.py similarity index 100% rename from StdLib/Lib/test/bytecode_helper.py rename to Src/StdLib/Lib/test/bytecode_helper.py diff --git a/StdLib/Lib/test/capath/0e4015b9.0 b/Src/StdLib/Lib/test/capath/0e4015b9.0 similarity index 100% rename from StdLib/Lib/test/capath/0e4015b9.0 rename to Src/StdLib/Lib/test/capath/0e4015b9.0 diff --git a/StdLib/Lib/test/capath/4e1295a3.0 b/Src/StdLib/Lib/test/capath/4e1295a3.0 similarity index 100% rename from StdLib/Lib/test/capath/4e1295a3.0 rename to Src/StdLib/Lib/test/capath/4e1295a3.0 diff --git a/StdLib/Lib/test/capath/5ed36f99.0 b/Src/StdLib/Lib/test/capath/5ed36f99.0 similarity index 100% rename from StdLib/Lib/test/capath/5ed36f99.0 rename to Src/StdLib/Lib/test/capath/5ed36f99.0 diff --git a/StdLib/Lib/test/capath/6e88d7b8.0 b/Src/StdLib/Lib/test/capath/6e88d7b8.0 similarity index 100% rename from StdLib/Lib/test/capath/6e88d7b8.0 rename to Src/StdLib/Lib/test/capath/6e88d7b8.0 diff --git a/StdLib/Lib/test/capath/99d0fa06.0 b/Src/StdLib/Lib/test/capath/99d0fa06.0 similarity index 100% rename from StdLib/Lib/test/capath/99d0fa06.0 rename to Src/StdLib/Lib/test/capath/99d0fa06.0 diff --git a/StdLib/Lib/test/capath/ce7b8643.0 b/Src/StdLib/Lib/test/capath/ce7b8643.0 similarity index 100% rename from StdLib/Lib/test/capath/ce7b8643.0 rename to Src/StdLib/Lib/test/capath/ce7b8643.0 diff --git a/StdLib/Lib/test/cfgparser.1 b/Src/StdLib/Lib/test/cfgparser.1 similarity index 100% rename from StdLib/Lib/test/cfgparser.1 rename to Src/StdLib/Lib/test/cfgparser.1 diff --git a/StdLib/Lib/test/cfgparser.2 b/Src/StdLib/Lib/test/cfgparser.2 similarity index 100% rename from StdLib/Lib/test/cfgparser.2 rename to Src/StdLib/Lib/test/cfgparser.2 diff --git a/StdLib/Lib/test/cfgparser.3 b/Src/StdLib/Lib/test/cfgparser.3 similarity index 100% rename from StdLib/Lib/test/cfgparser.3 rename to Src/StdLib/Lib/test/cfgparser.3 diff --git a/StdLib/Lib/test/check_soundcard.vbs b/Src/StdLib/Lib/test/check_soundcard.vbs similarity index 100% rename from StdLib/Lib/test/check_soundcard.vbs rename to Src/StdLib/Lib/test/check_soundcard.vbs diff --git a/StdLib/Lib/test/cjkencodings/big5-utf8.txt b/Src/StdLib/Lib/test/cjkencodings/big5-utf8.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/big5-utf8.txt rename to Src/StdLib/Lib/test/cjkencodings/big5-utf8.txt diff --git a/StdLib/Lib/test/cjkencodings/big5.txt b/Src/StdLib/Lib/test/cjkencodings/big5.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/big5.txt rename to Src/StdLib/Lib/test/cjkencodings/big5.txt diff --git a/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt b/Src/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt rename to Src/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt diff --git a/StdLib/Lib/test/cjkencodings/big5hkscs.txt b/Src/StdLib/Lib/test/cjkencodings/big5hkscs.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/big5hkscs.txt rename to Src/StdLib/Lib/test/cjkencodings/big5hkscs.txt diff --git a/StdLib/Lib/test/cjkencodings/cp949-utf8.txt b/Src/StdLib/Lib/test/cjkencodings/cp949-utf8.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/cp949-utf8.txt rename to Src/StdLib/Lib/test/cjkencodings/cp949-utf8.txt diff --git a/StdLib/Lib/test/cjkencodings/cp949.txt b/Src/StdLib/Lib/test/cjkencodings/cp949.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/cp949.txt rename to Src/StdLib/Lib/test/cjkencodings/cp949.txt diff --git a/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt b/Src/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt rename to Src/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt diff --git a/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt b/Src/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/euc_jisx0213.txt rename to Src/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt diff --git a/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt b/Src/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt rename to Src/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt diff --git a/StdLib/Lib/test/cjkencodings/euc_jp.txt b/Src/StdLib/Lib/test/cjkencodings/euc_jp.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/euc_jp.txt rename to Src/StdLib/Lib/test/cjkencodings/euc_jp.txt diff --git a/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt b/Src/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt rename to Src/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt diff --git a/StdLib/Lib/test/cjkencodings/euc_kr.txt b/Src/StdLib/Lib/test/cjkencodings/euc_kr.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/euc_kr.txt rename to Src/StdLib/Lib/test/cjkencodings/euc_kr.txt diff --git a/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt b/Src/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/gb18030-utf8.txt rename to Src/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt diff --git a/StdLib/Lib/test/cjkencodings/gb18030.txt b/Src/StdLib/Lib/test/cjkencodings/gb18030.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/gb18030.txt rename to Src/StdLib/Lib/test/cjkencodings/gb18030.txt diff --git a/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt b/Src/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/gb2312-utf8.txt rename to Src/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt diff --git a/StdLib/Lib/test/cjkencodings/gb2312.txt b/Src/StdLib/Lib/test/cjkencodings/gb2312.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/gb2312.txt rename to Src/StdLib/Lib/test/cjkencodings/gb2312.txt diff --git a/StdLib/Lib/test/cjkencodings/gbk-utf8.txt b/Src/StdLib/Lib/test/cjkencodings/gbk-utf8.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/gbk-utf8.txt rename to Src/StdLib/Lib/test/cjkencodings/gbk-utf8.txt diff --git a/StdLib/Lib/test/cjkencodings/gbk.txt b/Src/StdLib/Lib/test/cjkencodings/gbk.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/gbk.txt rename to Src/StdLib/Lib/test/cjkencodings/gbk.txt diff --git a/StdLib/Lib/test/cjkencodings/hz-utf8.txt b/Src/StdLib/Lib/test/cjkencodings/hz-utf8.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/hz-utf8.txt rename to Src/StdLib/Lib/test/cjkencodings/hz-utf8.txt diff --git a/StdLib/Lib/test/cjkencodings/hz.txt b/Src/StdLib/Lib/test/cjkencodings/hz.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/hz.txt rename to Src/StdLib/Lib/test/cjkencodings/hz.txt diff --git a/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt b/Src/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt rename to Src/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt diff --git a/StdLib/Lib/test/cjkencodings/iso2022_jp.txt b/Src/StdLib/Lib/test/cjkencodings/iso2022_jp.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/iso2022_jp.txt rename to Src/StdLib/Lib/test/cjkencodings/iso2022_jp.txt diff --git a/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt b/Src/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt rename to Src/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt diff --git a/StdLib/Lib/test/cjkencodings/iso2022_kr.txt b/Src/StdLib/Lib/test/cjkencodings/iso2022_kr.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/iso2022_kr.txt rename to Src/StdLib/Lib/test/cjkencodings/iso2022_kr.txt diff --git a/StdLib/Lib/test/cjkencodings/johab-utf8.txt b/Src/StdLib/Lib/test/cjkencodings/johab-utf8.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/johab-utf8.txt rename to Src/StdLib/Lib/test/cjkencodings/johab-utf8.txt diff --git a/StdLib/Lib/test/cjkencodings/johab.txt b/Src/StdLib/Lib/test/cjkencodings/johab.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/johab.txt rename to Src/StdLib/Lib/test/cjkencodings/johab.txt diff --git a/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt b/Src/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt rename to Src/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt diff --git a/StdLib/Lib/test/cjkencodings/shift_jis.txt b/Src/StdLib/Lib/test/cjkencodings/shift_jis.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/shift_jis.txt rename to Src/StdLib/Lib/test/cjkencodings/shift_jis.txt diff --git a/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt b/Src/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt rename to Src/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt diff --git a/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt b/Src/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt similarity index 100% rename from StdLib/Lib/test/cjkencodings/shift_jisx0213.txt rename to Src/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt diff --git a/StdLib/Lib/test/cmath_testcases.txt b/Src/StdLib/Lib/test/cmath_testcases.txt similarity index 100% rename from StdLib/Lib/test/cmath_testcases.txt rename to Src/StdLib/Lib/test/cmath_testcases.txt diff --git a/StdLib/Lib/test/coding20731.py b/Src/StdLib/Lib/test/coding20731.py similarity index 100% rename from StdLib/Lib/test/coding20731.py rename to Src/StdLib/Lib/test/coding20731.py diff --git a/StdLib/Lib/test/crashers/README b/Src/StdLib/Lib/test/crashers/README similarity index 100% rename from StdLib/Lib/test/crashers/README rename to Src/StdLib/Lib/test/crashers/README diff --git a/StdLib/Lib/test/crashers/bogus_code_obj.py b/Src/StdLib/Lib/test/crashers/bogus_code_obj.py similarity index 100% rename from StdLib/Lib/test/crashers/bogus_code_obj.py rename to Src/StdLib/Lib/test/crashers/bogus_code_obj.py diff --git a/StdLib/Lib/test/crashers/gc_inspection.py b/Src/StdLib/Lib/test/crashers/gc_inspection.py similarity index 100% rename from StdLib/Lib/test/crashers/gc_inspection.py rename to Src/StdLib/Lib/test/crashers/gc_inspection.py diff --git a/StdLib/Lib/test/crashers/infinite_loop_re.py b/Src/StdLib/Lib/test/crashers/infinite_loop_re.py similarity index 100% rename from StdLib/Lib/test/crashers/infinite_loop_re.py rename to Src/StdLib/Lib/test/crashers/infinite_loop_re.py diff --git a/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py b/Src/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py similarity index 100% rename from StdLib/Lib/test/crashers/mutation_inside_cyclegc.py rename to Src/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py diff --git a/StdLib/Lib/test/crashers/recursive_call.py b/Src/StdLib/Lib/test/crashers/recursive_call.py similarity index 100% rename from StdLib/Lib/test/crashers/recursive_call.py rename to Src/StdLib/Lib/test/crashers/recursive_call.py diff --git a/StdLib/Lib/test/crashers/trace_at_recursion_limit.py b/Src/StdLib/Lib/test/crashers/trace_at_recursion_limit.py similarity index 100% rename from StdLib/Lib/test/crashers/trace_at_recursion_limit.py rename to Src/StdLib/Lib/test/crashers/trace_at_recursion_limit.py diff --git a/StdLib/Lib/test/crashers/underlying_dict.py b/Src/StdLib/Lib/test/crashers/underlying_dict.py similarity index 100% rename from StdLib/Lib/test/crashers/underlying_dict.py rename to Src/StdLib/Lib/test/crashers/underlying_dict.py diff --git a/StdLib/Lib/test/curses_tests.py b/Src/StdLib/Lib/test/curses_tests.py similarity index 100% rename from StdLib/Lib/test/curses_tests.py rename to Src/StdLib/Lib/test/curses_tests.py diff --git a/StdLib/Lib/test/data/README b/Src/StdLib/Lib/test/data/README similarity index 100% rename from StdLib/Lib/test/data/README rename to Src/StdLib/Lib/test/data/README diff --git a/StdLib/Lib/test/datetimetester.py b/Src/StdLib/Lib/test/datetimetester.py similarity index 100% rename from StdLib/Lib/test/datetimetester.py rename to Src/StdLib/Lib/test/datetimetester.py diff --git a/StdLib/Lib/test/decimaltestdata/abs.decTest b/Src/StdLib/Lib/test/decimaltestdata/abs.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/abs.decTest rename to Src/StdLib/Lib/test/decimaltestdata/abs.decTest diff --git a/StdLib/Lib/test/decimaltestdata/add.decTest b/Src/StdLib/Lib/test/decimaltestdata/add.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/add.decTest rename to Src/StdLib/Lib/test/decimaltestdata/add.decTest diff --git a/StdLib/Lib/test/decimaltestdata/and.decTest b/Src/StdLib/Lib/test/decimaltestdata/and.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/and.decTest rename to Src/StdLib/Lib/test/decimaltestdata/and.decTest diff --git a/StdLib/Lib/test/decimaltestdata/base.decTest b/Src/StdLib/Lib/test/decimaltestdata/base.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/base.decTest rename to Src/StdLib/Lib/test/decimaltestdata/base.decTest diff --git a/StdLib/Lib/test/decimaltestdata/clamp.decTest b/Src/StdLib/Lib/test/decimaltestdata/clamp.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/clamp.decTest rename to Src/StdLib/Lib/test/decimaltestdata/clamp.decTest diff --git a/StdLib/Lib/test/decimaltestdata/class.decTest b/Src/StdLib/Lib/test/decimaltestdata/class.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/class.decTest rename to Src/StdLib/Lib/test/decimaltestdata/class.decTest diff --git a/StdLib/Lib/test/decimaltestdata/compare.decTest b/Src/StdLib/Lib/test/decimaltestdata/compare.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/compare.decTest rename to Src/StdLib/Lib/test/decimaltestdata/compare.decTest diff --git a/StdLib/Lib/test/decimaltestdata/comparetotal.decTest b/Src/StdLib/Lib/test/decimaltestdata/comparetotal.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/comparetotal.decTest rename to Src/StdLib/Lib/test/decimaltestdata/comparetotal.decTest diff --git a/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest b/Src/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/comparetotmag.decTest rename to Src/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest diff --git a/StdLib/Lib/test/decimaltestdata/copy.decTest b/Src/StdLib/Lib/test/decimaltestdata/copy.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/copy.decTest rename to Src/StdLib/Lib/test/decimaltestdata/copy.decTest diff --git a/StdLib/Lib/test/decimaltestdata/copyabs.decTest b/Src/StdLib/Lib/test/decimaltestdata/copyabs.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/copyabs.decTest rename to Src/StdLib/Lib/test/decimaltestdata/copyabs.decTest diff --git a/StdLib/Lib/test/decimaltestdata/copynegate.decTest b/Src/StdLib/Lib/test/decimaltestdata/copynegate.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/copynegate.decTest rename to Src/StdLib/Lib/test/decimaltestdata/copynegate.decTest diff --git a/StdLib/Lib/test/decimaltestdata/copysign.decTest b/Src/StdLib/Lib/test/decimaltestdata/copysign.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/copysign.decTest rename to Src/StdLib/Lib/test/decimaltestdata/copysign.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddAbs.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddAbs.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddAbs.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddAbs.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddAdd.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddAdd.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddAdd.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddAdd.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddAnd.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddAnd.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddAnd.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddAnd.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddBase.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddBase.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddBase.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddBase.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddCanonical.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddClass.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddClass.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddClass.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddClass.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddCompare.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddCompare.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddCompare.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddCompare.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddCopy.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddCopy.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddCopy.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddCopy.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddCopySign.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddDivide.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddDivide.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddDivide.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddDivide.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddEncode.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddEncode.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddEncode.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddEncode.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddFMA.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddFMA.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddFMA.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddFMA.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddInvert.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddInvert.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddInvert.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddInvert.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddLogB.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddLogB.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddLogB.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddLogB.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddMax.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddMax.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddMax.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddMax.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddMin.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddMin.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddMin.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddMin.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddMinMag.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddMinus.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddMinus.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddMinus.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddMinus.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddMultiply.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddNextToward.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddOr.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddOr.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddOr.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddOr.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddPlus.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddPlus.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddPlus.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddPlus.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddQuantize.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddReduce.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddReduce.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddReduce.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddReduce.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddRemainder.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddRotate.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddRotate.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddRotate.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddRotate.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddScaleB.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddShift.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddShift.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddShift.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddShift.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddSubtract.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ddXor.decTest b/Src/StdLib/Lib/test/decimaltestdata/ddXor.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ddXor.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ddXor.decTest diff --git a/StdLib/Lib/test/decimaltestdata/decDouble.decTest b/Src/StdLib/Lib/test/decimaltestdata/decDouble.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/decDouble.decTest rename to Src/StdLib/Lib/test/decimaltestdata/decDouble.decTest diff --git a/StdLib/Lib/test/decimaltestdata/decQuad.decTest b/Src/StdLib/Lib/test/decimaltestdata/decQuad.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/decQuad.decTest rename to Src/StdLib/Lib/test/decimaltestdata/decQuad.decTest diff --git a/StdLib/Lib/test/decimaltestdata/decSingle.decTest b/Src/StdLib/Lib/test/decimaltestdata/decSingle.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/decSingle.decTest rename to Src/StdLib/Lib/test/decimaltestdata/decSingle.decTest diff --git a/StdLib/Lib/test/decimaltestdata/divide.decTest b/Src/StdLib/Lib/test/decimaltestdata/divide.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/divide.decTest rename to Src/StdLib/Lib/test/decimaltestdata/divide.decTest diff --git a/StdLib/Lib/test/decimaltestdata/divideint.decTest b/Src/StdLib/Lib/test/decimaltestdata/divideint.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/divideint.decTest rename to Src/StdLib/Lib/test/decimaltestdata/divideint.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqAbs.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqAbs.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqAbs.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqAbs.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqAdd.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqAdd.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqAdd.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqAdd.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqAnd.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqAnd.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqAnd.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqAnd.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqBase.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqBase.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqBase.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqBase.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqCanonical.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqClass.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqClass.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqClass.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqClass.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqCompare.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqCompare.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqCompare.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqCompare.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqCopy.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqCopy.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqCopy.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqCopy.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqCopySign.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqDivide.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqDivide.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqDivide.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqDivide.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqEncode.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqEncode.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqEncode.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqEncode.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqFMA.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqFMA.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqFMA.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqFMA.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqInvert.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqInvert.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqInvert.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqInvert.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqLogB.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqLogB.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqLogB.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqLogB.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqMax.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqMax.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqMax.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqMax.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqMin.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqMin.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqMin.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqMin.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqMinMag.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqMinus.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqMinus.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqMinus.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqMinus.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqMultiply.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqNextToward.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqOr.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqOr.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqOr.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqOr.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqPlus.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqPlus.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqPlus.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqPlus.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqQuantize.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqReduce.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqReduce.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqReduce.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqReduce.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqRemainder.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqRotate.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqRotate.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqRotate.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqRotate.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqScaleB.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqShift.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqShift.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqShift.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqShift.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqSubtract.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dqXor.decTest b/Src/StdLib/Lib/test/decimaltestdata/dqXor.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dqXor.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dqXor.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dsBase.decTest b/Src/StdLib/Lib/test/decimaltestdata/dsBase.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dsBase.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dsBase.decTest diff --git a/StdLib/Lib/test/decimaltestdata/dsEncode.decTest b/Src/StdLib/Lib/test/decimaltestdata/dsEncode.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/dsEncode.decTest rename to Src/StdLib/Lib/test/decimaltestdata/dsEncode.decTest diff --git a/StdLib/Lib/test/decimaltestdata/exp.decTest b/Src/StdLib/Lib/test/decimaltestdata/exp.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/exp.decTest rename to Src/StdLib/Lib/test/decimaltestdata/exp.decTest diff --git a/StdLib/Lib/test/decimaltestdata/extra.decTest b/Src/StdLib/Lib/test/decimaltestdata/extra.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/extra.decTest rename to Src/StdLib/Lib/test/decimaltestdata/extra.decTest diff --git a/StdLib/Lib/test/decimaltestdata/fma.decTest b/Src/StdLib/Lib/test/decimaltestdata/fma.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/fma.decTest rename to Src/StdLib/Lib/test/decimaltestdata/fma.decTest diff --git a/StdLib/Lib/test/decimaltestdata/inexact.decTest b/Src/StdLib/Lib/test/decimaltestdata/inexact.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/inexact.decTest rename to Src/StdLib/Lib/test/decimaltestdata/inexact.decTest diff --git a/StdLib/Lib/test/decimaltestdata/invert.decTest b/Src/StdLib/Lib/test/decimaltestdata/invert.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/invert.decTest rename to Src/StdLib/Lib/test/decimaltestdata/invert.decTest diff --git a/StdLib/Lib/test/decimaltestdata/ln.decTest b/Src/StdLib/Lib/test/decimaltestdata/ln.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/ln.decTest rename to Src/StdLib/Lib/test/decimaltestdata/ln.decTest diff --git a/StdLib/Lib/test/decimaltestdata/log10.decTest b/Src/StdLib/Lib/test/decimaltestdata/log10.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/log10.decTest rename to Src/StdLib/Lib/test/decimaltestdata/log10.decTest diff --git a/StdLib/Lib/test/decimaltestdata/logb.decTest b/Src/StdLib/Lib/test/decimaltestdata/logb.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/logb.decTest rename to Src/StdLib/Lib/test/decimaltestdata/logb.decTest diff --git a/StdLib/Lib/test/decimaltestdata/max.decTest b/Src/StdLib/Lib/test/decimaltestdata/max.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/max.decTest rename to Src/StdLib/Lib/test/decimaltestdata/max.decTest diff --git a/StdLib/Lib/test/decimaltestdata/maxmag.decTest b/Src/StdLib/Lib/test/decimaltestdata/maxmag.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/maxmag.decTest rename to Src/StdLib/Lib/test/decimaltestdata/maxmag.decTest diff --git a/StdLib/Lib/test/decimaltestdata/min.decTest b/Src/StdLib/Lib/test/decimaltestdata/min.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/min.decTest rename to Src/StdLib/Lib/test/decimaltestdata/min.decTest diff --git a/StdLib/Lib/test/decimaltestdata/minmag.decTest b/Src/StdLib/Lib/test/decimaltestdata/minmag.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/minmag.decTest rename to Src/StdLib/Lib/test/decimaltestdata/minmag.decTest diff --git a/StdLib/Lib/test/decimaltestdata/minus.decTest b/Src/StdLib/Lib/test/decimaltestdata/minus.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/minus.decTest rename to Src/StdLib/Lib/test/decimaltestdata/minus.decTest diff --git a/StdLib/Lib/test/decimaltestdata/multiply.decTest b/Src/StdLib/Lib/test/decimaltestdata/multiply.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/multiply.decTest rename to Src/StdLib/Lib/test/decimaltestdata/multiply.decTest diff --git a/StdLib/Lib/test/decimaltestdata/nextminus.decTest b/Src/StdLib/Lib/test/decimaltestdata/nextminus.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/nextminus.decTest rename to Src/StdLib/Lib/test/decimaltestdata/nextminus.decTest diff --git a/StdLib/Lib/test/decimaltestdata/nextplus.decTest b/Src/StdLib/Lib/test/decimaltestdata/nextplus.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/nextplus.decTest rename to Src/StdLib/Lib/test/decimaltestdata/nextplus.decTest diff --git a/StdLib/Lib/test/decimaltestdata/nexttoward.decTest b/Src/StdLib/Lib/test/decimaltestdata/nexttoward.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/nexttoward.decTest rename to Src/StdLib/Lib/test/decimaltestdata/nexttoward.decTest diff --git a/StdLib/Lib/test/decimaltestdata/or.decTest b/Src/StdLib/Lib/test/decimaltestdata/or.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/or.decTest rename to Src/StdLib/Lib/test/decimaltestdata/or.decTest diff --git a/StdLib/Lib/test/decimaltestdata/plus.decTest b/Src/StdLib/Lib/test/decimaltestdata/plus.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/plus.decTest rename to Src/StdLib/Lib/test/decimaltestdata/plus.decTest diff --git a/StdLib/Lib/test/decimaltestdata/power.decTest b/Src/StdLib/Lib/test/decimaltestdata/power.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/power.decTest rename to Src/StdLib/Lib/test/decimaltestdata/power.decTest diff --git a/StdLib/Lib/test/decimaltestdata/powersqrt.decTest b/Src/StdLib/Lib/test/decimaltestdata/powersqrt.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/powersqrt.decTest rename to Src/StdLib/Lib/test/decimaltestdata/powersqrt.decTest diff --git a/StdLib/Lib/test/decimaltestdata/quantize.decTest b/Src/StdLib/Lib/test/decimaltestdata/quantize.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/quantize.decTest rename to Src/StdLib/Lib/test/decimaltestdata/quantize.decTest diff --git a/StdLib/Lib/test/decimaltestdata/randomBound32.decTest b/Src/StdLib/Lib/test/decimaltestdata/randomBound32.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/randomBound32.decTest rename to Src/StdLib/Lib/test/decimaltestdata/randomBound32.decTest diff --git a/StdLib/Lib/test/decimaltestdata/randoms.decTest b/Src/StdLib/Lib/test/decimaltestdata/randoms.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/randoms.decTest rename to Src/StdLib/Lib/test/decimaltestdata/randoms.decTest diff --git a/StdLib/Lib/test/decimaltestdata/reduce.decTest b/Src/StdLib/Lib/test/decimaltestdata/reduce.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/reduce.decTest rename to Src/StdLib/Lib/test/decimaltestdata/reduce.decTest diff --git a/StdLib/Lib/test/decimaltestdata/remainder.decTest b/Src/StdLib/Lib/test/decimaltestdata/remainder.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/remainder.decTest rename to Src/StdLib/Lib/test/decimaltestdata/remainder.decTest diff --git a/StdLib/Lib/test/decimaltestdata/remainderNear.decTest b/Src/StdLib/Lib/test/decimaltestdata/remainderNear.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/remainderNear.decTest rename to Src/StdLib/Lib/test/decimaltestdata/remainderNear.decTest diff --git a/StdLib/Lib/test/decimaltestdata/rescale.decTest b/Src/StdLib/Lib/test/decimaltestdata/rescale.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/rescale.decTest rename to Src/StdLib/Lib/test/decimaltestdata/rescale.decTest diff --git a/StdLib/Lib/test/decimaltestdata/rotate.decTest b/Src/StdLib/Lib/test/decimaltestdata/rotate.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/rotate.decTest rename to Src/StdLib/Lib/test/decimaltestdata/rotate.decTest diff --git a/StdLib/Lib/test/decimaltestdata/rounding.decTest b/Src/StdLib/Lib/test/decimaltestdata/rounding.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/rounding.decTest rename to Src/StdLib/Lib/test/decimaltestdata/rounding.decTest diff --git a/StdLib/Lib/test/decimaltestdata/samequantum.decTest b/Src/StdLib/Lib/test/decimaltestdata/samequantum.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/samequantum.decTest rename to Src/StdLib/Lib/test/decimaltestdata/samequantum.decTest diff --git a/StdLib/Lib/test/decimaltestdata/scaleb.decTest b/Src/StdLib/Lib/test/decimaltestdata/scaleb.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/scaleb.decTest rename to Src/StdLib/Lib/test/decimaltestdata/scaleb.decTest diff --git a/StdLib/Lib/test/decimaltestdata/shift.decTest b/Src/StdLib/Lib/test/decimaltestdata/shift.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/shift.decTest rename to Src/StdLib/Lib/test/decimaltestdata/shift.decTest diff --git a/StdLib/Lib/test/decimaltestdata/squareroot.decTest b/Src/StdLib/Lib/test/decimaltestdata/squareroot.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/squareroot.decTest rename to Src/StdLib/Lib/test/decimaltestdata/squareroot.decTest diff --git a/StdLib/Lib/test/decimaltestdata/subtract.decTest b/Src/StdLib/Lib/test/decimaltestdata/subtract.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/subtract.decTest rename to Src/StdLib/Lib/test/decimaltestdata/subtract.decTest diff --git a/StdLib/Lib/test/decimaltestdata/testall.decTest b/Src/StdLib/Lib/test/decimaltestdata/testall.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/testall.decTest rename to Src/StdLib/Lib/test/decimaltestdata/testall.decTest diff --git a/StdLib/Lib/test/decimaltestdata/tointegral.decTest b/Src/StdLib/Lib/test/decimaltestdata/tointegral.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/tointegral.decTest rename to Src/StdLib/Lib/test/decimaltestdata/tointegral.decTest diff --git a/StdLib/Lib/test/decimaltestdata/tointegralx.decTest b/Src/StdLib/Lib/test/decimaltestdata/tointegralx.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/tointegralx.decTest rename to Src/StdLib/Lib/test/decimaltestdata/tointegralx.decTest diff --git a/StdLib/Lib/test/decimaltestdata/xor.decTest b/Src/StdLib/Lib/test/decimaltestdata/xor.decTest similarity index 100% rename from StdLib/Lib/test/decimaltestdata/xor.decTest rename to Src/StdLib/Lib/test/decimaltestdata/xor.decTest diff --git a/StdLib/Lib/test/dh1024.pem b/Src/StdLib/Lib/test/dh1024.pem similarity index 100% rename from StdLib/Lib/test/dh1024.pem rename to Src/StdLib/Lib/test/dh1024.pem diff --git a/StdLib/Lib/test/dis_module.py b/Src/StdLib/Lib/test/dis_module.py similarity index 100% rename from StdLib/Lib/test/dis_module.py rename to Src/StdLib/Lib/test/dis_module.py diff --git a/StdLib/Lib/test/doctest_aliases.py b/Src/StdLib/Lib/test/doctest_aliases.py similarity index 100% rename from StdLib/Lib/test/doctest_aliases.py rename to Src/StdLib/Lib/test/doctest_aliases.py diff --git a/StdLib/Lib/test/double_const.py b/Src/StdLib/Lib/test/double_const.py similarity index 100% rename from StdLib/Lib/test/double_const.py rename to Src/StdLib/Lib/test/double_const.py diff --git a/StdLib/Lib/test/empty.vbs b/Src/StdLib/Lib/test/empty.vbs similarity index 100% rename from StdLib/Lib/test/empty.vbs rename to Src/StdLib/Lib/test/empty.vbs diff --git a/StdLib/Lib/test/encoded_modules/__init__.py b/Src/StdLib/Lib/test/encoded_modules/__init__.py similarity index 100% rename from StdLib/Lib/test/encoded_modules/__init__.py rename to Src/StdLib/Lib/test/encoded_modules/__init__.py diff --git a/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py b/Src/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py similarity index 100% rename from StdLib/Lib/test/encoded_modules/module_iso_8859_1.py rename to Src/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py diff --git a/StdLib/Lib/test/encoded_modules/module_koi8_r.py b/Src/StdLib/Lib/test/encoded_modules/module_koi8_r.py similarity index 100% rename from StdLib/Lib/test/encoded_modules/module_koi8_r.py rename to Src/StdLib/Lib/test/encoded_modules/module_koi8_r.py diff --git a/StdLib/Lib/test/exception_hierarchy.txt b/Src/StdLib/Lib/test/exception_hierarchy.txt similarity index 100% rename from StdLib/Lib/test/exception_hierarchy.txt rename to Src/StdLib/Lib/test/exception_hierarchy.txt diff --git a/StdLib/Lib/test/final_a.py b/Src/StdLib/Lib/test/final_a.py similarity index 100% rename from StdLib/Lib/test/final_a.py rename to Src/StdLib/Lib/test/final_a.py diff --git a/StdLib/Lib/test/final_b.py b/Src/StdLib/Lib/test/final_b.py similarity index 100% rename from StdLib/Lib/test/final_b.py rename to Src/StdLib/Lib/test/final_b.py diff --git a/StdLib/Lib/test/floating_points.txt b/Src/StdLib/Lib/test/floating_points.txt similarity index 100% rename from StdLib/Lib/test/floating_points.txt rename to Src/StdLib/Lib/test/floating_points.txt diff --git a/StdLib/Lib/test/fork_wait.py b/Src/StdLib/Lib/test/fork_wait.py similarity index 100% rename from StdLib/Lib/test/fork_wait.py rename to Src/StdLib/Lib/test/fork_wait.py diff --git a/StdLib/Lib/test/formatfloat_testcases.txt b/Src/StdLib/Lib/test/formatfloat_testcases.txt similarity index 100% rename from StdLib/Lib/test/formatfloat_testcases.txt rename to Src/StdLib/Lib/test/formatfloat_testcases.txt diff --git a/StdLib/Lib/test/future_test1.py b/Src/StdLib/Lib/test/future_test1.py similarity index 100% rename from StdLib/Lib/test/future_test1.py rename to Src/StdLib/Lib/test/future_test1.py diff --git a/StdLib/Lib/test/future_test2.py b/Src/StdLib/Lib/test/future_test2.py similarity index 100% rename from StdLib/Lib/test/future_test2.py rename to Src/StdLib/Lib/test/future_test2.py diff --git a/StdLib/Lib/test/gdb_sample.py b/Src/StdLib/Lib/test/gdb_sample.py similarity index 100% rename from StdLib/Lib/test/gdb_sample.py rename to Src/StdLib/Lib/test/gdb_sample.py diff --git a/StdLib/Lib/test/ieee754.txt b/Src/StdLib/Lib/test/ieee754.txt similarity index 100% rename from StdLib/Lib/test/ieee754.txt rename to Src/StdLib/Lib/test/ieee754.txt diff --git a/StdLib/Lib/test/imghdrdata/python.bmp b/Src/StdLib/Lib/test/imghdrdata/python.bmp similarity index 100% rename from StdLib/Lib/test/imghdrdata/python.bmp rename to Src/StdLib/Lib/test/imghdrdata/python.bmp diff --git a/StdLib/Lib/test/imghdrdata/python.gif b/Src/StdLib/Lib/test/imghdrdata/python.gif similarity index 100% rename from StdLib/Lib/test/imghdrdata/python.gif rename to Src/StdLib/Lib/test/imghdrdata/python.gif diff --git a/StdLib/Lib/test/imghdrdata/python.jpg b/Src/StdLib/Lib/test/imghdrdata/python.jpg similarity index 100% rename from StdLib/Lib/test/imghdrdata/python.jpg rename to Src/StdLib/Lib/test/imghdrdata/python.jpg diff --git a/StdLib/Lib/test/imghdrdata/python.pbm b/Src/StdLib/Lib/test/imghdrdata/python.pbm similarity index 100% rename from StdLib/Lib/test/imghdrdata/python.pbm rename to Src/StdLib/Lib/test/imghdrdata/python.pbm diff --git a/StdLib/Lib/test/imghdrdata/python.pgm b/Src/StdLib/Lib/test/imghdrdata/python.pgm similarity index 100% rename from StdLib/Lib/test/imghdrdata/python.pgm rename to Src/StdLib/Lib/test/imghdrdata/python.pgm diff --git a/StdLib/Lib/test/imghdrdata/python.png b/Src/StdLib/Lib/test/imghdrdata/python.png similarity index 100% rename from StdLib/Lib/test/imghdrdata/python.png rename to Src/StdLib/Lib/test/imghdrdata/python.png diff --git a/StdLib/Lib/test/imghdrdata/python.ppm b/Src/StdLib/Lib/test/imghdrdata/python.ppm similarity index 100% rename from StdLib/Lib/test/imghdrdata/python.ppm rename to Src/StdLib/Lib/test/imghdrdata/python.ppm diff --git a/StdLib/Lib/test/imghdrdata/python.ras b/Src/StdLib/Lib/test/imghdrdata/python.ras similarity index 100% rename from StdLib/Lib/test/imghdrdata/python.ras rename to Src/StdLib/Lib/test/imghdrdata/python.ras diff --git a/StdLib/Lib/test/imghdrdata/python.sgi b/Src/StdLib/Lib/test/imghdrdata/python.sgi similarity index 100% rename from StdLib/Lib/test/imghdrdata/python.sgi rename to Src/StdLib/Lib/test/imghdrdata/python.sgi diff --git a/StdLib/Lib/test/imghdrdata/python.tiff b/Src/StdLib/Lib/test/imghdrdata/python.tiff similarity index 100% rename from StdLib/Lib/test/imghdrdata/python.tiff rename to Src/StdLib/Lib/test/imghdrdata/python.tiff diff --git a/StdLib/Lib/test/imghdrdata/python.xbm b/Src/StdLib/Lib/test/imghdrdata/python.xbm similarity index 100% rename from StdLib/Lib/test/imghdrdata/python.xbm rename to Src/StdLib/Lib/test/imghdrdata/python.xbm diff --git a/StdLib/Lib/test/inspect_fodder.py b/Src/StdLib/Lib/test/inspect_fodder.py similarity index 100% rename from StdLib/Lib/test/inspect_fodder.py rename to Src/StdLib/Lib/test/inspect_fodder.py diff --git a/StdLib/Lib/test/inspect_fodder2.py b/Src/StdLib/Lib/test/inspect_fodder2.py similarity index 100% rename from StdLib/Lib/test/inspect_fodder2.py rename to Src/StdLib/Lib/test/inspect_fodder2.py diff --git a/StdLib/Lib/test/keycert.passwd.pem b/Src/StdLib/Lib/test/keycert.passwd.pem similarity index 100% rename from StdLib/Lib/test/keycert.passwd.pem rename to Src/StdLib/Lib/test/keycert.passwd.pem diff --git a/StdLib/Lib/test/keycert.pem b/Src/StdLib/Lib/test/keycert.pem similarity index 100% rename from StdLib/Lib/test/keycert.pem rename to Src/StdLib/Lib/test/keycert.pem diff --git a/StdLib/Lib/test/keycert2.pem b/Src/StdLib/Lib/test/keycert2.pem similarity index 100% rename from StdLib/Lib/test/keycert2.pem rename to Src/StdLib/Lib/test/keycert2.pem diff --git a/StdLib/Lib/test/keycert3.pem b/Src/StdLib/Lib/test/keycert3.pem similarity index 100% rename from StdLib/Lib/test/keycert3.pem rename to Src/StdLib/Lib/test/keycert3.pem diff --git a/StdLib/Lib/test/keycert4.pem b/Src/StdLib/Lib/test/keycert4.pem similarity index 100% rename from StdLib/Lib/test/keycert4.pem rename to Src/StdLib/Lib/test/keycert4.pem diff --git a/StdLib/Lib/test/leakers/README.txt b/Src/StdLib/Lib/test/leakers/README.txt similarity index 100% rename from StdLib/Lib/test/leakers/README.txt rename to Src/StdLib/Lib/test/leakers/README.txt diff --git a/StdLib/Lib/test/leakers/__init__.py b/Src/StdLib/Lib/test/leakers/__init__.py similarity index 100% rename from StdLib/Lib/test/leakers/__init__.py rename to Src/StdLib/Lib/test/leakers/__init__.py diff --git a/StdLib/Lib/test/leakers/test_ctypes.py b/Src/StdLib/Lib/test/leakers/test_ctypes.py similarity index 100% rename from StdLib/Lib/test/leakers/test_ctypes.py rename to Src/StdLib/Lib/test/leakers/test_ctypes.py diff --git a/StdLib/Lib/test/leakers/test_selftype.py b/Src/StdLib/Lib/test/leakers/test_selftype.py similarity index 100% rename from StdLib/Lib/test/leakers/test_selftype.py rename to Src/StdLib/Lib/test/leakers/test_selftype.py diff --git a/StdLib/Lib/test/list_tests.py b/Src/StdLib/Lib/test/list_tests.py similarity index 100% rename from StdLib/Lib/test/list_tests.py rename to Src/StdLib/Lib/test/list_tests.py diff --git a/StdLib/Lib/test/lock_tests.py b/Src/StdLib/Lib/test/lock_tests.py similarity index 100% rename from StdLib/Lib/test/lock_tests.py rename to Src/StdLib/Lib/test/lock_tests.py diff --git a/StdLib/Lib/test/mailcap.txt b/Src/StdLib/Lib/test/mailcap.txt similarity index 100% rename from StdLib/Lib/test/mailcap.txt rename to Src/StdLib/Lib/test/mailcap.txt diff --git a/StdLib/Lib/test/make_ssl_certs.py b/Src/StdLib/Lib/test/make_ssl_certs.py similarity index 100% rename from StdLib/Lib/test/make_ssl_certs.py rename to Src/StdLib/Lib/test/make_ssl_certs.py diff --git a/StdLib/Lib/test/mapping_tests.py b/Src/StdLib/Lib/test/mapping_tests.py similarity index 100% rename from StdLib/Lib/test/mapping_tests.py rename to Src/StdLib/Lib/test/mapping_tests.py diff --git a/StdLib/Lib/test/math_testcases.txt b/Src/StdLib/Lib/test/math_testcases.txt similarity index 100% rename from StdLib/Lib/test/math_testcases.txt rename to Src/StdLib/Lib/test/math_testcases.txt diff --git a/StdLib/Lib/test/memory_watchdog.py b/Src/StdLib/Lib/test/memory_watchdog.py similarity index 100% rename from StdLib/Lib/test/memory_watchdog.py rename to Src/StdLib/Lib/test/memory_watchdog.py diff --git a/StdLib/Lib/test/mime.types b/Src/StdLib/Lib/test/mime.types similarity index 100% rename from StdLib/Lib/test/mime.types rename to Src/StdLib/Lib/test/mime.types diff --git a/StdLib/Lib/test/mock_socket.py b/Src/StdLib/Lib/test/mock_socket.py similarity index 100% rename from StdLib/Lib/test/mock_socket.py rename to Src/StdLib/Lib/test/mock_socket.py diff --git a/StdLib/Lib/test/mod_generics_cache.py b/Src/StdLib/Lib/test/mod_generics_cache.py similarity index 100% rename from StdLib/Lib/test/mod_generics_cache.py rename to Src/StdLib/Lib/test/mod_generics_cache.py diff --git a/StdLib/Lib/test/mp_fork_bomb.py b/Src/StdLib/Lib/test/mp_fork_bomb.py similarity index 100% rename from StdLib/Lib/test/mp_fork_bomb.py rename to Src/StdLib/Lib/test/mp_fork_bomb.py diff --git a/StdLib/Lib/test/multibytecodec_support.py b/Src/StdLib/Lib/test/multibytecodec_support.py similarity index 100% rename from StdLib/Lib/test/multibytecodec_support.py rename to Src/StdLib/Lib/test/multibytecodec_support.py diff --git a/StdLib/Lib/test/nokia.pem b/Src/StdLib/Lib/test/nokia.pem similarity index 100% rename from StdLib/Lib/test/nokia.pem rename to Src/StdLib/Lib/test/nokia.pem diff --git a/StdLib/Lib/test/nullbytecert.pem b/Src/StdLib/Lib/test/nullbytecert.pem similarity index 100% rename from StdLib/Lib/test/nullbytecert.pem rename to Src/StdLib/Lib/test/nullbytecert.pem diff --git a/StdLib/Lib/test/nullcert.pem b/Src/StdLib/Lib/test/nullcert.pem similarity index 100% rename from StdLib/Lib/test/nullcert.pem rename to Src/StdLib/Lib/test/nullcert.pem diff --git a/StdLib/Lib/test/outstanding_bugs.py b/Src/StdLib/Lib/test/outstanding_bugs.py similarity index 100% rename from StdLib/Lib/test/outstanding_bugs.py rename to Src/StdLib/Lib/test/outstanding_bugs.py diff --git a/StdLib/Lib/test/pickletester.py b/Src/StdLib/Lib/test/pickletester.py similarity index 100% rename from StdLib/Lib/test/pickletester.py rename to Src/StdLib/Lib/test/pickletester.py diff --git a/StdLib/Lib/test/profilee.py b/Src/StdLib/Lib/test/profilee.py similarity index 100% rename from StdLib/Lib/test/profilee.py rename to Src/StdLib/Lib/test/profilee.py diff --git a/StdLib/Lib/test/pstats.pck b/Src/StdLib/Lib/test/pstats.pck similarity index 100% rename from StdLib/Lib/test/pstats.pck rename to Src/StdLib/Lib/test/pstats.pck diff --git a/StdLib/Lib/test/pycacert.pem b/Src/StdLib/Lib/test/pycacert.pem similarity index 100% rename from StdLib/Lib/test/pycacert.pem rename to Src/StdLib/Lib/test/pycacert.pem diff --git a/StdLib/Lib/test/pycakey.pem b/Src/StdLib/Lib/test/pycakey.pem similarity index 100% rename from StdLib/Lib/test/pycakey.pem rename to Src/StdLib/Lib/test/pycakey.pem diff --git a/StdLib/Lib/test/pyclbr_input.py b/Src/StdLib/Lib/test/pyclbr_input.py similarity index 100% rename from StdLib/Lib/test/pyclbr_input.py rename to Src/StdLib/Lib/test/pyclbr_input.py diff --git a/StdLib/Lib/test/pydoc_mod.py b/Src/StdLib/Lib/test/pydoc_mod.py similarity index 100% rename from StdLib/Lib/test/pydoc_mod.py rename to Src/StdLib/Lib/test/pydoc_mod.py diff --git a/StdLib/Lib/test/pydocfodder.py b/Src/StdLib/Lib/test/pydocfodder.py similarity index 100% rename from StdLib/Lib/test/pydocfodder.py rename to Src/StdLib/Lib/test/pydocfodder.py diff --git a/StdLib/Lib/test/pystone.py b/Src/StdLib/Lib/test/pystone.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/test/pystone.py rename to Src/StdLib/Lib/test/pystone.py diff --git a/StdLib/Lib/test/randv2_32.pck b/Src/StdLib/Lib/test/randv2_32.pck similarity index 100% rename from StdLib/Lib/test/randv2_32.pck rename to Src/StdLib/Lib/test/randv2_32.pck diff --git a/StdLib/Lib/test/randv2_64.pck b/Src/StdLib/Lib/test/randv2_64.pck similarity index 100% rename from StdLib/Lib/test/randv2_64.pck rename to Src/StdLib/Lib/test/randv2_64.pck diff --git a/StdLib/Lib/test/randv3.pck b/Src/StdLib/Lib/test/randv3.pck similarity index 100% rename from StdLib/Lib/test/randv3.pck rename to Src/StdLib/Lib/test/randv3.pck diff --git a/StdLib/Lib/test/re_tests.py b/Src/StdLib/Lib/test/re_tests.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/test/re_tests.py rename to Src/StdLib/Lib/test/re_tests.py diff --git a/StdLib/Lib/test/regrtest.py b/Src/StdLib/Lib/test/regrtest.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/test/regrtest.py rename to Src/StdLib/Lib/test/regrtest.py diff --git a/StdLib/Lib/test/relimport.py b/Src/StdLib/Lib/test/relimport.py similarity index 100% rename from StdLib/Lib/test/relimport.py rename to Src/StdLib/Lib/test/relimport.py diff --git a/StdLib/Lib/test/reperf.py b/Src/StdLib/Lib/test/reperf.py similarity index 100% rename from StdLib/Lib/test/reperf.py rename to Src/StdLib/Lib/test/reperf.py diff --git a/StdLib/Lib/test/revocation.crl b/Src/StdLib/Lib/test/revocation.crl similarity index 100% rename from StdLib/Lib/test/revocation.crl rename to Src/StdLib/Lib/test/revocation.crl diff --git a/StdLib/Lib/test/sample_doctest.py b/Src/StdLib/Lib/test/sample_doctest.py similarity index 100% rename from StdLib/Lib/test/sample_doctest.py rename to Src/StdLib/Lib/test/sample_doctest.py diff --git a/StdLib/Lib/test/sample_doctest_no_docstrings.py b/Src/StdLib/Lib/test/sample_doctest_no_docstrings.py similarity index 100% rename from StdLib/Lib/test/sample_doctest_no_docstrings.py rename to Src/StdLib/Lib/test/sample_doctest_no_docstrings.py diff --git a/StdLib/Lib/test/sample_doctest_no_doctests.py b/Src/StdLib/Lib/test/sample_doctest_no_doctests.py similarity index 100% rename from StdLib/Lib/test/sample_doctest_no_doctests.py rename to Src/StdLib/Lib/test/sample_doctest_no_doctests.py diff --git a/StdLib/Lib/test/script_helper.py b/Src/StdLib/Lib/test/script_helper.py similarity index 100% rename from StdLib/Lib/test/script_helper.py rename to Src/StdLib/Lib/test/script_helper.py diff --git a/StdLib/Lib/test/selfsigned_pythontestdotnet.pem b/Src/StdLib/Lib/test/selfsigned_pythontestdotnet.pem similarity index 100% rename from StdLib/Lib/test/selfsigned_pythontestdotnet.pem rename to Src/StdLib/Lib/test/selfsigned_pythontestdotnet.pem diff --git a/StdLib/Lib/test/seq_tests.py b/Src/StdLib/Lib/test/seq_tests.py similarity index 100% rename from StdLib/Lib/test/seq_tests.py rename to Src/StdLib/Lib/test/seq_tests.py diff --git a/StdLib/Lib/test/sgml_input.html b/Src/StdLib/Lib/test/sgml_input.html similarity index 100% rename from StdLib/Lib/test/sgml_input.html rename to Src/StdLib/Lib/test/sgml_input.html diff --git a/StdLib/Lib/test/sha256.pem b/Src/StdLib/Lib/test/sha256.pem similarity index 100% rename from StdLib/Lib/test/sha256.pem rename to Src/StdLib/Lib/test/sha256.pem diff --git a/StdLib/Lib/test/sndhdrdata/README b/Src/StdLib/Lib/test/sndhdrdata/README similarity index 100% rename from StdLib/Lib/test/sndhdrdata/README rename to Src/StdLib/Lib/test/sndhdrdata/README diff --git a/StdLib/Lib/test/sndhdrdata/sndhdr.8svx b/Src/StdLib/Lib/test/sndhdrdata/sndhdr.8svx similarity index 100% rename from StdLib/Lib/test/sndhdrdata/sndhdr.8svx rename to Src/StdLib/Lib/test/sndhdrdata/sndhdr.8svx diff --git a/StdLib/Lib/test/sndhdrdata/sndhdr.aifc b/Src/StdLib/Lib/test/sndhdrdata/sndhdr.aifc similarity index 100% rename from StdLib/Lib/test/sndhdrdata/sndhdr.aifc rename to Src/StdLib/Lib/test/sndhdrdata/sndhdr.aifc diff --git a/StdLib/Lib/test/sndhdrdata/sndhdr.aiff b/Src/StdLib/Lib/test/sndhdrdata/sndhdr.aiff similarity index 100% rename from StdLib/Lib/test/sndhdrdata/sndhdr.aiff rename to Src/StdLib/Lib/test/sndhdrdata/sndhdr.aiff diff --git a/StdLib/Lib/test/sndhdrdata/sndhdr.au b/Src/StdLib/Lib/test/sndhdrdata/sndhdr.au similarity index 100% rename from StdLib/Lib/test/sndhdrdata/sndhdr.au rename to Src/StdLib/Lib/test/sndhdrdata/sndhdr.au diff --git a/StdLib/Lib/test/sndhdrdata/sndhdr.hcom b/Src/StdLib/Lib/test/sndhdrdata/sndhdr.hcom similarity index 100% rename from StdLib/Lib/test/sndhdrdata/sndhdr.hcom rename to Src/StdLib/Lib/test/sndhdrdata/sndhdr.hcom diff --git a/StdLib/Lib/test/sndhdrdata/sndhdr.sndt b/Src/StdLib/Lib/test/sndhdrdata/sndhdr.sndt similarity index 100% rename from StdLib/Lib/test/sndhdrdata/sndhdr.sndt rename to Src/StdLib/Lib/test/sndhdrdata/sndhdr.sndt diff --git a/StdLib/Lib/test/sndhdrdata/sndhdr.voc b/Src/StdLib/Lib/test/sndhdrdata/sndhdr.voc similarity index 100% rename from StdLib/Lib/test/sndhdrdata/sndhdr.voc rename to Src/StdLib/Lib/test/sndhdrdata/sndhdr.voc diff --git a/StdLib/Lib/test/sndhdrdata/sndhdr.wav b/Src/StdLib/Lib/test/sndhdrdata/sndhdr.wav similarity index 100% rename from StdLib/Lib/test/sndhdrdata/sndhdr.wav rename to Src/StdLib/Lib/test/sndhdrdata/sndhdr.wav diff --git a/StdLib/Lib/test/sortperf.py b/Src/StdLib/Lib/test/sortperf.py similarity index 100% rename from StdLib/Lib/test/sortperf.py rename to Src/StdLib/Lib/test/sortperf.py diff --git a/StdLib/Lib/test/ssl_cert.pem b/Src/StdLib/Lib/test/ssl_cert.pem similarity index 100% rename from StdLib/Lib/test/ssl_cert.pem rename to Src/StdLib/Lib/test/ssl_cert.pem diff --git a/StdLib/Lib/test/ssl_key.passwd.pem b/Src/StdLib/Lib/test/ssl_key.passwd.pem similarity index 100% rename from StdLib/Lib/test/ssl_key.passwd.pem rename to Src/StdLib/Lib/test/ssl_key.passwd.pem diff --git a/StdLib/Lib/test/ssl_key.pem b/Src/StdLib/Lib/test/ssl_key.pem similarity index 100% rename from StdLib/Lib/test/ssl_key.pem rename to Src/StdLib/Lib/test/ssl_key.pem diff --git a/StdLib/Lib/test/ssl_servers.py b/Src/StdLib/Lib/test/ssl_servers.py similarity index 100% rename from StdLib/Lib/test/ssl_servers.py rename to Src/StdLib/Lib/test/ssl_servers.py diff --git a/StdLib/Lib/test/ssltests.py b/Src/StdLib/Lib/test/ssltests.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/test/ssltests.py rename to Src/StdLib/Lib/test/ssltests.py diff --git a/StdLib/Lib/test/string_tests.py b/Src/StdLib/Lib/test/string_tests.py similarity index 100% rename from StdLib/Lib/test/string_tests.py rename to Src/StdLib/Lib/test/string_tests.py diff --git a/StdLib/Lib/test/subprocessdata/fd_status.py b/Src/StdLib/Lib/test/subprocessdata/fd_status.py similarity index 100% rename from StdLib/Lib/test/subprocessdata/fd_status.py rename to Src/StdLib/Lib/test/subprocessdata/fd_status.py diff --git a/StdLib/Lib/test/subprocessdata/input_reader.py b/Src/StdLib/Lib/test/subprocessdata/input_reader.py similarity index 100% rename from StdLib/Lib/test/subprocessdata/input_reader.py rename to Src/StdLib/Lib/test/subprocessdata/input_reader.py diff --git a/StdLib/Lib/test/subprocessdata/qcat.py b/Src/StdLib/Lib/test/subprocessdata/qcat.py similarity index 100% rename from StdLib/Lib/test/subprocessdata/qcat.py rename to Src/StdLib/Lib/test/subprocessdata/qcat.py diff --git a/StdLib/Lib/test/subprocessdata/qgrep.py b/Src/StdLib/Lib/test/subprocessdata/qgrep.py similarity index 100% rename from StdLib/Lib/test/subprocessdata/qgrep.py rename to Src/StdLib/Lib/test/subprocessdata/qgrep.py diff --git a/StdLib/Lib/test/subprocessdata/sigchild_ignore.py b/Src/StdLib/Lib/test/subprocessdata/sigchild_ignore.py similarity index 100% rename from StdLib/Lib/test/subprocessdata/sigchild_ignore.py rename to Src/StdLib/Lib/test/subprocessdata/sigchild_ignore.py diff --git a/StdLib/Lib/test/support/__init__.py b/Src/StdLib/Lib/test/support/__init__.py similarity index 100% rename from StdLib/Lib/test/support/__init__.py rename to Src/StdLib/Lib/test/support/__init__.py diff --git a/StdLib/Lib/test/talos-2019-0758.pem b/Src/StdLib/Lib/test/talos-2019-0758.pem similarity index 100% rename from StdLib/Lib/test/talos-2019-0758.pem rename to Src/StdLib/Lib/test/talos-2019-0758.pem diff --git a/StdLib/Lib/test/test___all__.py b/Src/StdLib/Lib/test/test___all__.py similarity index 100% rename from StdLib/Lib/test/test___all__.py rename to Src/StdLib/Lib/test/test___all__.py diff --git a/StdLib/Lib/test/test___future__.py b/Src/StdLib/Lib/test/test___future__.py similarity index 100% rename from StdLib/Lib/test/test___future__.py rename to Src/StdLib/Lib/test/test___future__.py diff --git a/StdLib/Lib/test/test__locale.py b/Src/StdLib/Lib/test/test__locale.py similarity index 100% rename from StdLib/Lib/test/test__locale.py rename to Src/StdLib/Lib/test/test__locale.py diff --git a/StdLib/Lib/test/test__opcode.py b/Src/StdLib/Lib/test/test__opcode.py similarity index 100% rename from StdLib/Lib/test/test__opcode.py rename to Src/StdLib/Lib/test/test__opcode.py diff --git a/StdLib/Lib/test/test__osx_support.py b/Src/StdLib/Lib/test/test__osx_support.py similarity index 100% rename from StdLib/Lib/test/test__osx_support.py rename to Src/StdLib/Lib/test/test__osx_support.py diff --git a/StdLib/Lib/test/test_abc.py b/Src/StdLib/Lib/test/test_abc.py similarity index 100% rename from StdLib/Lib/test/test_abc.py rename to Src/StdLib/Lib/test/test_abc.py diff --git a/StdLib/Lib/test/test_abstract_numbers.py b/Src/StdLib/Lib/test/test_abstract_numbers.py similarity index 100% rename from StdLib/Lib/test/test_abstract_numbers.py rename to Src/StdLib/Lib/test/test_abstract_numbers.py diff --git a/StdLib/Lib/test/test_aifc.py b/Src/StdLib/Lib/test/test_aifc.py similarity index 100% rename from StdLib/Lib/test/test_aifc.py rename to Src/StdLib/Lib/test/test_aifc.py diff --git a/StdLib/Lib/test/test_argparse.py b/Src/StdLib/Lib/test/test_argparse.py similarity index 100% rename from StdLib/Lib/test/test_argparse.py rename to Src/StdLib/Lib/test/test_argparse.py diff --git a/StdLib/Lib/test/test_array.py b/Src/StdLib/Lib/test/test_array.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/test/test_array.py rename to Src/StdLib/Lib/test/test_array.py diff --git a/StdLib/Lib/test/test_ast.py b/Src/StdLib/Lib/test/test_ast.py similarity index 100% rename from StdLib/Lib/test/test_ast.py rename to Src/StdLib/Lib/test/test_ast.py diff --git a/StdLib/Lib/test/test_asynchat.py b/Src/StdLib/Lib/test/test_asynchat.py similarity index 100% rename from StdLib/Lib/test/test_asynchat.py rename to Src/StdLib/Lib/test/test_asynchat.py diff --git a/StdLib/Lib/test/test_asyncio/__init__.py b/Src/StdLib/Lib/test/test_asyncio/__init__.py similarity index 100% rename from StdLib/Lib/test/test_asyncio/__init__.py rename to Src/StdLib/Lib/test/test_asyncio/__init__.py diff --git a/StdLib/Lib/test/test_asyncio/__main__.py b/Src/StdLib/Lib/test/test_asyncio/__main__.py similarity index 100% rename from StdLib/Lib/test/test_asyncio/__main__.py rename to Src/StdLib/Lib/test/test_asyncio/__main__.py diff --git a/StdLib/Lib/test/test_asyncio/echo.py b/Src/StdLib/Lib/test/test_asyncio/echo.py similarity index 100% rename from StdLib/Lib/test/test_asyncio/echo.py rename to Src/StdLib/Lib/test/test_asyncio/echo.py diff --git a/StdLib/Lib/test/test_asyncio/echo2.py b/Src/StdLib/Lib/test/test_asyncio/echo2.py similarity index 100% rename from StdLib/Lib/test/test_asyncio/echo2.py rename to Src/StdLib/Lib/test/test_asyncio/echo2.py diff --git a/StdLib/Lib/test/test_asyncio/echo3.py b/Src/StdLib/Lib/test/test_asyncio/echo3.py similarity index 100% rename from StdLib/Lib/test/test_asyncio/echo3.py rename to Src/StdLib/Lib/test/test_asyncio/echo3.py diff --git a/StdLib/Lib/test/test_asyncio/keycert3.pem b/Src/StdLib/Lib/test/test_asyncio/keycert3.pem similarity index 100% rename from StdLib/Lib/test/test_asyncio/keycert3.pem rename to Src/StdLib/Lib/test/test_asyncio/keycert3.pem diff --git a/StdLib/Lib/test/test_asyncio/pycacert.pem b/Src/StdLib/Lib/test/test_asyncio/pycacert.pem similarity index 100% rename from StdLib/Lib/test/test_asyncio/pycacert.pem rename to Src/StdLib/Lib/test/test_asyncio/pycacert.pem diff --git a/StdLib/Lib/test/test_asyncio/ssl_cert.pem b/Src/StdLib/Lib/test/test_asyncio/ssl_cert.pem similarity index 100% rename from StdLib/Lib/test/test_asyncio/ssl_cert.pem rename to Src/StdLib/Lib/test/test_asyncio/ssl_cert.pem diff --git a/StdLib/Lib/test/test_asyncio/ssl_key.pem b/Src/StdLib/Lib/test/test_asyncio/ssl_key.pem similarity index 100% rename from StdLib/Lib/test/test_asyncio/ssl_key.pem rename to Src/StdLib/Lib/test/test_asyncio/ssl_key.pem diff --git a/StdLib/Lib/test/test_asyncio/test_base_events.py b/Src/StdLib/Lib/test/test_asyncio/test_base_events.py similarity index 100% rename from StdLib/Lib/test/test_asyncio/test_base_events.py rename to Src/StdLib/Lib/test/test_asyncio/test_base_events.py diff --git a/StdLib/Lib/test/test_asyncio/test_events.py b/Src/StdLib/Lib/test/test_asyncio/test_events.py similarity index 100% rename from StdLib/Lib/test/test_asyncio/test_events.py rename to Src/StdLib/Lib/test/test_asyncio/test_events.py diff --git a/StdLib/Lib/test/test_asyncio/test_futures.py b/Src/StdLib/Lib/test/test_asyncio/test_futures.py similarity index 100% rename from StdLib/Lib/test/test_asyncio/test_futures.py rename to Src/StdLib/Lib/test/test_asyncio/test_futures.py diff --git a/StdLib/Lib/test/test_asyncio/test_locks.py b/Src/StdLib/Lib/test/test_asyncio/test_locks.py similarity index 100% rename from StdLib/Lib/test/test_asyncio/test_locks.py rename to Src/StdLib/Lib/test/test_asyncio/test_locks.py diff --git a/StdLib/Lib/test/test_asyncio/test_proactor_events.py b/Src/StdLib/Lib/test/test_asyncio/test_proactor_events.py similarity index 100% rename from StdLib/Lib/test/test_asyncio/test_proactor_events.py rename to Src/StdLib/Lib/test/test_asyncio/test_proactor_events.py diff --git a/StdLib/Lib/test/test_asyncio/test_queues.py b/Src/StdLib/Lib/test/test_asyncio/test_queues.py similarity index 100% rename from StdLib/Lib/test/test_asyncio/test_queues.py rename to Src/StdLib/Lib/test/test_asyncio/test_queues.py diff --git a/StdLib/Lib/test/test_asyncio/test_selector_events.py b/Src/StdLib/Lib/test/test_asyncio/test_selector_events.py similarity index 100% rename from StdLib/Lib/test/test_asyncio/test_selector_events.py rename to Src/StdLib/Lib/test/test_asyncio/test_selector_events.py diff --git a/StdLib/Lib/test/test_asyncio/test_sslproto.py b/Src/StdLib/Lib/test/test_asyncio/test_sslproto.py similarity index 100% rename from StdLib/Lib/test/test_asyncio/test_sslproto.py rename to Src/StdLib/Lib/test/test_asyncio/test_sslproto.py diff --git a/StdLib/Lib/test/test_asyncio/test_streams.py b/Src/StdLib/Lib/test/test_asyncio/test_streams.py similarity index 100% rename from StdLib/Lib/test/test_asyncio/test_streams.py rename to Src/StdLib/Lib/test/test_asyncio/test_streams.py diff --git a/StdLib/Lib/test/test_asyncio/test_subprocess.py b/Src/StdLib/Lib/test/test_asyncio/test_subprocess.py similarity index 100% rename from StdLib/Lib/test/test_asyncio/test_subprocess.py rename to Src/StdLib/Lib/test/test_asyncio/test_subprocess.py diff --git a/StdLib/Lib/test/test_asyncio/test_tasks.py b/Src/StdLib/Lib/test/test_asyncio/test_tasks.py similarity index 100% rename from StdLib/Lib/test/test_asyncio/test_tasks.py rename to Src/StdLib/Lib/test/test_asyncio/test_tasks.py diff --git a/StdLib/Lib/test/test_asyncio/test_transports.py b/Src/StdLib/Lib/test/test_asyncio/test_transports.py similarity index 100% rename from StdLib/Lib/test/test_asyncio/test_transports.py rename to Src/StdLib/Lib/test/test_asyncio/test_transports.py diff --git a/StdLib/Lib/test/test_asyncio/test_unix_events.py b/Src/StdLib/Lib/test/test_asyncio/test_unix_events.py similarity index 100% rename from StdLib/Lib/test/test_asyncio/test_unix_events.py rename to Src/StdLib/Lib/test/test_asyncio/test_unix_events.py diff --git a/StdLib/Lib/test/test_asyncio/test_windows_events.py b/Src/StdLib/Lib/test/test_asyncio/test_windows_events.py similarity index 100% rename from StdLib/Lib/test/test_asyncio/test_windows_events.py rename to Src/StdLib/Lib/test/test_asyncio/test_windows_events.py diff --git a/StdLib/Lib/test/test_asyncio/test_windows_utils.py b/Src/StdLib/Lib/test/test_asyncio/test_windows_utils.py similarity index 100% rename from StdLib/Lib/test/test_asyncio/test_windows_utils.py rename to Src/StdLib/Lib/test/test_asyncio/test_windows_utils.py diff --git a/StdLib/Lib/test/test_asyncore.py b/Src/StdLib/Lib/test/test_asyncore.py similarity index 100% rename from StdLib/Lib/test/test_asyncore.py rename to Src/StdLib/Lib/test/test_asyncore.py diff --git a/StdLib/Lib/test/test_atexit.py b/Src/StdLib/Lib/test/test_atexit.py similarity index 100% rename from StdLib/Lib/test/test_atexit.py rename to Src/StdLib/Lib/test/test_atexit.py diff --git a/StdLib/Lib/test/test_audioop.py b/Src/StdLib/Lib/test/test_audioop.py similarity index 100% rename from StdLib/Lib/test/test_audioop.py rename to Src/StdLib/Lib/test/test_audioop.py diff --git a/StdLib/Lib/test/test_augassign.py b/Src/StdLib/Lib/test/test_augassign.py similarity index 100% rename from StdLib/Lib/test/test_augassign.py rename to Src/StdLib/Lib/test/test_augassign.py diff --git a/StdLib/Lib/test/test_base64.py b/Src/StdLib/Lib/test/test_base64.py similarity index 100% rename from StdLib/Lib/test/test_base64.py rename to Src/StdLib/Lib/test/test_base64.py diff --git a/StdLib/Lib/test/test_bigaddrspace.py b/Src/StdLib/Lib/test/test_bigaddrspace.py similarity index 100% rename from StdLib/Lib/test/test_bigaddrspace.py rename to Src/StdLib/Lib/test/test_bigaddrspace.py diff --git a/StdLib/Lib/test/test_bigmem.py b/Src/StdLib/Lib/test/test_bigmem.py similarity index 100% rename from StdLib/Lib/test/test_bigmem.py rename to Src/StdLib/Lib/test/test_bigmem.py diff --git a/StdLib/Lib/test/test_binascii.py b/Src/StdLib/Lib/test/test_binascii.py similarity index 100% rename from StdLib/Lib/test/test_binascii.py rename to Src/StdLib/Lib/test/test_binascii.py diff --git a/StdLib/Lib/test/test_binhex.py b/Src/StdLib/Lib/test/test_binhex.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/test/test_binhex.py rename to Src/StdLib/Lib/test/test_binhex.py diff --git a/StdLib/Lib/test/test_binop.py b/Src/StdLib/Lib/test/test_binop.py similarity index 100% rename from StdLib/Lib/test/test_binop.py rename to Src/StdLib/Lib/test/test_binop.py diff --git a/StdLib/Lib/test/test_bisect.py b/Src/StdLib/Lib/test/test_bisect.py similarity index 100% rename from StdLib/Lib/test/test_bisect.py rename to Src/StdLib/Lib/test/test_bisect.py diff --git a/StdLib/Lib/test/test_bool.py b/Src/StdLib/Lib/test/test_bool.py similarity index 100% rename from StdLib/Lib/test/test_bool.py rename to Src/StdLib/Lib/test/test_bool.py diff --git a/StdLib/Lib/test/test_buffer.py b/Src/StdLib/Lib/test/test_buffer.py similarity index 100% rename from StdLib/Lib/test/test_buffer.py rename to Src/StdLib/Lib/test/test_buffer.py diff --git a/StdLib/Lib/test/test_bufio.py b/Src/StdLib/Lib/test/test_bufio.py similarity index 100% rename from StdLib/Lib/test/test_bufio.py rename to Src/StdLib/Lib/test/test_bufio.py diff --git a/StdLib/Lib/test/test_builtin.py b/Src/StdLib/Lib/test/test_builtin.py similarity index 100% rename from StdLib/Lib/test/test_builtin.py rename to Src/StdLib/Lib/test/test_builtin.py diff --git a/StdLib/Lib/test/test_bytes.py b/Src/StdLib/Lib/test/test_bytes.py similarity index 100% rename from StdLib/Lib/test/test_bytes.py rename to Src/StdLib/Lib/test/test_bytes.py diff --git a/StdLib/Lib/test/test_bz2.py b/Src/StdLib/Lib/test/test_bz2.py similarity index 100% rename from StdLib/Lib/test/test_bz2.py rename to Src/StdLib/Lib/test/test_bz2.py diff --git a/StdLib/Lib/test/test_calendar.py b/Src/StdLib/Lib/test/test_calendar.py similarity index 100% rename from StdLib/Lib/test/test_calendar.py rename to Src/StdLib/Lib/test/test_calendar.py diff --git a/StdLib/Lib/test/test_call.py b/Src/StdLib/Lib/test/test_call.py similarity index 100% rename from StdLib/Lib/test/test_call.py rename to Src/StdLib/Lib/test/test_call.py diff --git a/StdLib/Lib/test/test_capi.py b/Src/StdLib/Lib/test/test_capi.py similarity index 100% rename from StdLib/Lib/test/test_capi.py rename to Src/StdLib/Lib/test/test_capi.py diff --git a/StdLib/Lib/test/test_cgi.py b/Src/StdLib/Lib/test/test_cgi.py similarity index 100% rename from StdLib/Lib/test/test_cgi.py rename to Src/StdLib/Lib/test/test_cgi.py diff --git a/StdLib/Lib/test/test_cgitb.py b/Src/StdLib/Lib/test/test_cgitb.py similarity index 100% rename from StdLib/Lib/test/test_cgitb.py rename to Src/StdLib/Lib/test/test_cgitb.py diff --git a/StdLib/Lib/test/test_charmapcodec.py b/Src/StdLib/Lib/test/test_charmapcodec.py similarity index 100% rename from StdLib/Lib/test/test_charmapcodec.py rename to Src/StdLib/Lib/test/test_charmapcodec.py diff --git a/StdLib/Lib/test/test_class.py b/Src/StdLib/Lib/test/test_class.py similarity index 100% rename from StdLib/Lib/test/test_class.py rename to Src/StdLib/Lib/test/test_class.py diff --git a/StdLib/Lib/test/test_cmath.py b/Src/StdLib/Lib/test/test_cmath.py similarity index 100% rename from StdLib/Lib/test/test_cmath.py rename to Src/StdLib/Lib/test/test_cmath.py diff --git a/StdLib/Lib/test/test_cmd.py b/Src/StdLib/Lib/test/test_cmd.py similarity index 100% rename from StdLib/Lib/test/test_cmd.py rename to Src/StdLib/Lib/test/test_cmd.py diff --git a/StdLib/Lib/test/test_cmd_line.py b/Src/StdLib/Lib/test/test_cmd_line.py similarity index 100% rename from StdLib/Lib/test/test_cmd_line.py rename to Src/StdLib/Lib/test/test_cmd_line.py diff --git a/StdLib/Lib/test/test_cmd_line_script.py b/Src/StdLib/Lib/test/test_cmd_line_script.py similarity index 100% rename from StdLib/Lib/test/test_cmd_line_script.py rename to Src/StdLib/Lib/test/test_cmd_line_script.py diff --git a/StdLib/Lib/test/test_code.py b/Src/StdLib/Lib/test/test_code.py similarity index 100% rename from StdLib/Lib/test/test_code.py rename to Src/StdLib/Lib/test/test_code.py diff --git a/StdLib/Lib/test/test_code_module.py b/Src/StdLib/Lib/test/test_code_module.py similarity index 100% rename from StdLib/Lib/test/test_code_module.py rename to Src/StdLib/Lib/test/test_code_module.py diff --git a/StdLib/Lib/test/test_codeccallbacks.py b/Src/StdLib/Lib/test/test_codeccallbacks.py similarity index 100% rename from StdLib/Lib/test/test_codeccallbacks.py rename to Src/StdLib/Lib/test/test_codeccallbacks.py diff --git a/StdLib/Lib/test/test_codecencodings_cn.py b/Src/StdLib/Lib/test/test_codecencodings_cn.py similarity index 100% rename from StdLib/Lib/test/test_codecencodings_cn.py rename to Src/StdLib/Lib/test/test_codecencodings_cn.py diff --git a/StdLib/Lib/test/test_codecencodings_hk.py b/Src/StdLib/Lib/test/test_codecencodings_hk.py similarity index 100% rename from StdLib/Lib/test/test_codecencodings_hk.py rename to Src/StdLib/Lib/test/test_codecencodings_hk.py diff --git a/StdLib/Lib/test/test_codecencodings_iso2022.py b/Src/StdLib/Lib/test/test_codecencodings_iso2022.py similarity index 100% rename from StdLib/Lib/test/test_codecencodings_iso2022.py rename to Src/StdLib/Lib/test/test_codecencodings_iso2022.py diff --git a/StdLib/Lib/test/test_codecencodings_jp.py b/Src/StdLib/Lib/test/test_codecencodings_jp.py similarity index 100% rename from StdLib/Lib/test/test_codecencodings_jp.py rename to Src/StdLib/Lib/test/test_codecencodings_jp.py diff --git a/StdLib/Lib/test/test_codecencodings_kr.py b/Src/StdLib/Lib/test/test_codecencodings_kr.py similarity index 100% rename from StdLib/Lib/test/test_codecencodings_kr.py rename to Src/StdLib/Lib/test/test_codecencodings_kr.py diff --git a/StdLib/Lib/test/test_codecencodings_tw.py b/Src/StdLib/Lib/test/test_codecencodings_tw.py similarity index 100% rename from StdLib/Lib/test/test_codecencodings_tw.py rename to Src/StdLib/Lib/test/test_codecencodings_tw.py diff --git a/StdLib/Lib/test/test_codecmaps_cn.py b/Src/StdLib/Lib/test/test_codecmaps_cn.py similarity index 100% rename from StdLib/Lib/test/test_codecmaps_cn.py rename to Src/StdLib/Lib/test/test_codecmaps_cn.py diff --git a/StdLib/Lib/test/test_codecmaps_hk.py b/Src/StdLib/Lib/test/test_codecmaps_hk.py similarity index 100% rename from StdLib/Lib/test/test_codecmaps_hk.py rename to Src/StdLib/Lib/test/test_codecmaps_hk.py diff --git a/StdLib/Lib/test/test_codecmaps_jp.py b/Src/StdLib/Lib/test/test_codecmaps_jp.py similarity index 100% rename from StdLib/Lib/test/test_codecmaps_jp.py rename to Src/StdLib/Lib/test/test_codecmaps_jp.py diff --git a/StdLib/Lib/test/test_codecmaps_kr.py b/Src/StdLib/Lib/test/test_codecmaps_kr.py similarity index 100% rename from StdLib/Lib/test/test_codecmaps_kr.py rename to Src/StdLib/Lib/test/test_codecmaps_kr.py diff --git a/StdLib/Lib/test/test_codecmaps_tw.py b/Src/StdLib/Lib/test/test_codecmaps_tw.py similarity index 100% rename from StdLib/Lib/test/test_codecmaps_tw.py rename to Src/StdLib/Lib/test/test_codecmaps_tw.py diff --git a/StdLib/Lib/test/test_codecs.py b/Src/StdLib/Lib/test/test_codecs.py similarity index 100% rename from StdLib/Lib/test/test_codecs.py rename to Src/StdLib/Lib/test/test_codecs.py diff --git a/StdLib/Lib/test/test_codeop.py b/Src/StdLib/Lib/test/test_codeop.py similarity index 100% rename from StdLib/Lib/test/test_codeop.py rename to Src/StdLib/Lib/test/test_codeop.py diff --git a/StdLib/Lib/test/test_collections.py b/Src/StdLib/Lib/test/test_collections.py similarity index 100% rename from StdLib/Lib/test/test_collections.py rename to Src/StdLib/Lib/test/test_collections.py diff --git a/StdLib/Lib/test/test_colorsys.py b/Src/StdLib/Lib/test/test_colorsys.py similarity index 100% rename from StdLib/Lib/test/test_colorsys.py rename to Src/StdLib/Lib/test/test_colorsys.py diff --git a/StdLib/Lib/test/test_compare.py b/Src/StdLib/Lib/test/test_compare.py similarity index 100% rename from StdLib/Lib/test/test_compare.py rename to Src/StdLib/Lib/test/test_compare.py diff --git a/StdLib/Lib/test/test_compile.py b/Src/StdLib/Lib/test/test_compile.py similarity index 100% rename from StdLib/Lib/test/test_compile.py rename to Src/StdLib/Lib/test/test_compile.py diff --git a/StdLib/Lib/test/test_compileall.py b/Src/StdLib/Lib/test/test_compileall.py similarity index 100% rename from StdLib/Lib/test/test_compileall.py rename to Src/StdLib/Lib/test/test_compileall.py diff --git a/StdLib/Lib/test/test_complex.py b/Src/StdLib/Lib/test/test_complex.py similarity index 100% rename from StdLib/Lib/test/test_complex.py rename to Src/StdLib/Lib/test/test_complex.py diff --git a/StdLib/Lib/test/test_concurrent_futures.py b/Src/StdLib/Lib/test/test_concurrent_futures.py similarity index 100% rename from StdLib/Lib/test/test_concurrent_futures.py rename to Src/StdLib/Lib/test/test_concurrent_futures.py diff --git a/StdLib/Lib/test/test_configparser.py b/Src/StdLib/Lib/test/test_configparser.py similarity index 100% rename from StdLib/Lib/test/test_configparser.py rename to Src/StdLib/Lib/test/test_configparser.py diff --git a/StdLib/Lib/test/test_contains.py b/Src/StdLib/Lib/test/test_contains.py similarity index 100% rename from StdLib/Lib/test/test_contains.py rename to Src/StdLib/Lib/test/test_contains.py diff --git a/StdLib/Lib/test/test_contextlib.py b/Src/StdLib/Lib/test/test_contextlib.py similarity index 100% rename from StdLib/Lib/test/test_contextlib.py rename to Src/StdLib/Lib/test/test_contextlib.py diff --git a/StdLib/Lib/test/test_copy.py b/Src/StdLib/Lib/test/test_copy.py similarity index 100% rename from StdLib/Lib/test/test_copy.py rename to Src/StdLib/Lib/test/test_copy.py diff --git a/StdLib/Lib/test/test_copyreg.py b/Src/StdLib/Lib/test/test_copyreg.py similarity index 100% rename from StdLib/Lib/test/test_copyreg.py rename to Src/StdLib/Lib/test/test_copyreg.py diff --git a/StdLib/Lib/test/test_cprofile.py b/Src/StdLib/Lib/test/test_cprofile.py similarity index 100% rename from StdLib/Lib/test/test_cprofile.py rename to Src/StdLib/Lib/test/test_cprofile.py diff --git a/StdLib/Lib/test/test_crashers.py b/Src/StdLib/Lib/test/test_crashers.py similarity index 100% rename from StdLib/Lib/test/test_crashers.py rename to Src/StdLib/Lib/test/test_crashers.py diff --git a/StdLib/Lib/test/test_crypt.py b/Src/StdLib/Lib/test/test_crypt.py similarity index 100% rename from StdLib/Lib/test/test_crypt.py rename to Src/StdLib/Lib/test/test_crypt.py diff --git a/StdLib/Lib/test/test_csv.py b/Src/StdLib/Lib/test/test_csv.py similarity index 100% rename from StdLib/Lib/test/test_csv.py rename to Src/StdLib/Lib/test/test_csv.py diff --git a/StdLib/Lib/test/test_ctypes.py b/Src/StdLib/Lib/test/test_ctypes.py similarity index 100% rename from StdLib/Lib/test/test_ctypes.py rename to Src/StdLib/Lib/test/test_ctypes.py diff --git a/StdLib/Lib/test/test_curses.py b/Src/StdLib/Lib/test/test_curses.py similarity index 100% rename from StdLib/Lib/test/test_curses.py rename to Src/StdLib/Lib/test/test_curses.py diff --git a/StdLib/Lib/test/test_datetime.py b/Src/StdLib/Lib/test/test_datetime.py similarity index 100% rename from StdLib/Lib/test/test_datetime.py rename to Src/StdLib/Lib/test/test_datetime.py diff --git a/StdLib/Lib/test/test_dbm.py b/Src/StdLib/Lib/test/test_dbm.py similarity index 100% rename from StdLib/Lib/test/test_dbm.py rename to Src/StdLib/Lib/test/test_dbm.py diff --git a/StdLib/Lib/test/test_dbm_dumb.py b/Src/StdLib/Lib/test/test_dbm_dumb.py similarity index 100% rename from StdLib/Lib/test/test_dbm_dumb.py rename to Src/StdLib/Lib/test/test_dbm_dumb.py diff --git a/StdLib/Lib/test/test_dbm_gnu.py b/Src/StdLib/Lib/test/test_dbm_gnu.py similarity index 100% rename from StdLib/Lib/test/test_dbm_gnu.py rename to Src/StdLib/Lib/test/test_dbm_gnu.py diff --git a/StdLib/Lib/test/test_dbm_ndbm.py b/Src/StdLib/Lib/test/test_dbm_ndbm.py similarity index 100% rename from StdLib/Lib/test/test_dbm_ndbm.py rename to Src/StdLib/Lib/test/test_dbm_ndbm.py diff --git a/StdLib/Lib/test/test_decimal.py b/Src/StdLib/Lib/test/test_decimal.py similarity index 100% rename from StdLib/Lib/test/test_decimal.py rename to Src/StdLib/Lib/test/test_decimal.py diff --git a/StdLib/Lib/test/test_decorators.py b/Src/StdLib/Lib/test/test_decorators.py similarity index 100% rename from StdLib/Lib/test/test_decorators.py rename to Src/StdLib/Lib/test/test_decorators.py diff --git a/StdLib/Lib/test/test_defaultdict.py b/Src/StdLib/Lib/test/test_defaultdict.py similarity index 100% rename from StdLib/Lib/test/test_defaultdict.py rename to Src/StdLib/Lib/test/test_defaultdict.py diff --git a/StdLib/Lib/test/test_deque.py b/Src/StdLib/Lib/test/test_deque.py similarity index 100% rename from StdLib/Lib/test/test_deque.py rename to Src/StdLib/Lib/test/test_deque.py diff --git a/StdLib/Lib/test/test_descr.py b/Src/StdLib/Lib/test/test_descr.py similarity index 100% rename from StdLib/Lib/test/test_descr.py rename to Src/StdLib/Lib/test/test_descr.py diff --git a/StdLib/Lib/test/test_descrtut.py b/Src/StdLib/Lib/test/test_descrtut.py similarity index 100% rename from StdLib/Lib/test/test_descrtut.py rename to Src/StdLib/Lib/test/test_descrtut.py diff --git a/StdLib/Lib/test/test_devpoll.py b/Src/StdLib/Lib/test/test_devpoll.py similarity index 100% rename from StdLib/Lib/test/test_devpoll.py rename to Src/StdLib/Lib/test/test_devpoll.py diff --git a/StdLib/Lib/test/test_dict.py b/Src/StdLib/Lib/test/test_dict.py similarity index 100% rename from StdLib/Lib/test/test_dict.py rename to Src/StdLib/Lib/test/test_dict.py diff --git a/StdLib/Lib/test/test_dictcomps.py b/Src/StdLib/Lib/test/test_dictcomps.py similarity index 100% rename from StdLib/Lib/test/test_dictcomps.py rename to Src/StdLib/Lib/test/test_dictcomps.py diff --git a/StdLib/Lib/test/test_dictviews.py b/Src/StdLib/Lib/test/test_dictviews.py similarity index 100% rename from StdLib/Lib/test/test_dictviews.py rename to Src/StdLib/Lib/test/test_dictviews.py diff --git a/StdLib/Lib/test/test_difflib.py b/Src/StdLib/Lib/test/test_difflib.py similarity index 100% rename from StdLib/Lib/test/test_difflib.py rename to Src/StdLib/Lib/test/test_difflib.py diff --git a/StdLib/Lib/test/test_difflib_expect.html b/Src/StdLib/Lib/test/test_difflib_expect.html similarity index 100% rename from StdLib/Lib/test/test_difflib_expect.html rename to Src/StdLib/Lib/test/test_difflib_expect.html diff --git a/StdLib/Lib/test/test_dis.py b/Src/StdLib/Lib/test/test_dis.py similarity index 100% rename from StdLib/Lib/test/test_dis.py rename to Src/StdLib/Lib/test/test_dis.py diff --git a/StdLib/Lib/test/test_distutils.py b/Src/StdLib/Lib/test/test_distutils.py similarity index 100% rename from StdLib/Lib/test/test_distutils.py rename to Src/StdLib/Lib/test/test_distutils.py diff --git a/StdLib/Lib/test/test_doctest.py b/Src/StdLib/Lib/test/test_doctest.py similarity index 100% rename from StdLib/Lib/test/test_doctest.py rename to Src/StdLib/Lib/test/test_doctest.py diff --git a/StdLib/Lib/test/test_doctest.txt b/Src/StdLib/Lib/test/test_doctest.txt similarity index 100% rename from StdLib/Lib/test/test_doctest.txt rename to Src/StdLib/Lib/test/test_doctest.txt diff --git a/StdLib/Lib/test/test_doctest2.py b/Src/StdLib/Lib/test/test_doctest2.py similarity index 100% rename from StdLib/Lib/test/test_doctest2.py rename to Src/StdLib/Lib/test/test_doctest2.py diff --git a/StdLib/Lib/test/test_doctest2.txt b/Src/StdLib/Lib/test/test_doctest2.txt similarity index 100% rename from StdLib/Lib/test/test_doctest2.txt rename to Src/StdLib/Lib/test/test_doctest2.txt diff --git a/StdLib/Lib/test/test_doctest3.txt b/Src/StdLib/Lib/test/test_doctest3.txt similarity index 100% rename from StdLib/Lib/test/test_doctest3.txt rename to Src/StdLib/Lib/test/test_doctest3.txt diff --git a/StdLib/Lib/test/test_doctest4.txt b/Src/StdLib/Lib/test/test_doctest4.txt similarity index 100% rename from StdLib/Lib/test/test_doctest4.txt rename to Src/StdLib/Lib/test/test_doctest4.txt diff --git a/StdLib/Lib/test/test_docxmlrpc.py b/Src/StdLib/Lib/test/test_docxmlrpc.py similarity index 100% rename from StdLib/Lib/test/test_docxmlrpc.py rename to Src/StdLib/Lib/test/test_docxmlrpc.py diff --git a/StdLib/Lib/test/test_dummy_thread.py b/Src/StdLib/Lib/test/test_dummy_thread.py similarity index 100% rename from StdLib/Lib/test/test_dummy_thread.py rename to Src/StdLib/Lib/test/test_dummy_thread.py diff --git a/StdLib/Lib/test/test_dummy_threading.py b/Src/StdLib/Lib/test/test_dummy_threading.py similarity index 100% rename from StdLib/Lib/test/test_dummy_threading.py rename to Src/StdLib/Lib/test/test_dummy_threading.py diff --git a/StdLib/Lib/test/test_dynamic.py b/Src/StdLib/Lib/test/test_dynamic.py similarity index 100% rename from StdLib/Lib/test/test_dynamic.py rename to Src/StdLib/Lib/test/test_dynamic.py diff --git a/StdLib/Lib/test/test_dynamicclassattribute.py b/Src/StdLib/Lib/test/test_dynamicclassattribute.py similarity index 100% rename from StdLib/Lib/test/test_dynamicclassattribute.py rename to Src/StdLib/Lib/test/test_dynamicclassattribute.py diff --git a/StdLib/Lib/test/test_email/__init__.py b/Src/StdLib/Lib/test/test_email/__init__.py similarity index 100% rename from StdLib/Lib/test/test_email/__init__.py rename to Src/StdLib/Lib/test/test_email/__init__.py diff --git a/StdLib/Lib/test/test_email/__main__.py b/Src/StdLib/Lib/test/test_email/__main__.py similarity index 100% rename from StdLib/Lib/test/test_email/__main__.py rename to Src/StdLib/Lib/test/test_email/__main__.py diff --git a/StdLib/Lib/test/test_email/data/PyBanner048.gif b/Src/StdLib/Lib/test/test_email/data/PyBanner048.gif similarity index 100% rename from StdLib/Lib/test/test_email/data/PyBanner048.gif rename to Src/StdLib/Lib/test/test_email/data/PyBanner048.gif diff --git a/StdLib/Lib/test/test_email/data/audiotest.au b/Src/StdLib/Lib/test/test_email/data/audiotest.au similarity index 100% rename from StdLib/Lib/test/test_email/data/audiotest.au rename to Src/StdLib/Lib/test/test_email/data/audiotest.au diff --git a/StdLib/Lib/test/test_email/data/msg_01.txt b/Src/StdLib/Lib/test/test_email/data/msg_01.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_01.txt rename to Src/StdLib/Lib/test/test_email/data/msg_01.txt diff --git a/StdLib/Lib/test/test_email/data/msg_02.txt b/Src/StdLib/Lib/test/test_email/data/msg_02.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_02.txt rename to Src/StdLib/Lib/test/test_email/data/msg_02.txt diff --git a/StdLib/Lib/test/test_email/data/msg_03.txt b/Src/StdLib/Lib/test/test_email/data/msg_03.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_03.txt rename to Src/StdLib/Lib/test/test_email/data/msg_03.txt diff --git a/StdLib/Lib/test/test_email/data/msg_04.txt b/Src/StdLib/Lib/test/test_email/data/msg_04.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_04.txt rename to Src/StdLib/Lib/test/test_email/data/msg_04.txt diff --git a/StdLib/Lib/test/test_email/data/msg_05.txt b/Src/StdLib/Lib/test/test_email/data/msg_05.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_05.txt rename to Src/StdLib/Lib/test/test_email/data/msg_05.txt diff --git a/StdLib/Lib/test/test_email/data/msg_06.txt b/Src/StdLib/Lib/test/test_email/data/msg_06.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_06.txt rename to Src/StdLib/Lib/test/test_email/data/msg_06.txt diff --git a/StdLib/Lib/test/test_email/data/msg_07.txt b/Src/StdLib/Lib/test/test_email/data/msg_07.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_07.txt rename to Src/StdLib/Lib/test/test_email/data/msg_07.txt diff --git a/StdLib/Lib/test/test_email/data/msg_08.txt b/Src/StdLib/Lib/test/test_email/data/msg_08.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_08.txt rename to Src/StdLib/Lib/test/test_email/data/msg_08.txt diff --git a/StdLib/Lib/test/test_email/data/msg_09.txt b/Src/StdLib/Lib/test/test_email/data/msg_09.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_09.txt rename to Src/StdLib/Lib/test/test_email/data/msg_09.txt diff --git a/StdLib/Lib/test/test_email/data/msg_10.txt b/Src/StdLib/Lib/test/test_email/data/msg_10.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_10.txt rename to Src/StdLib/Lib/test/test_email/data/msg_10.txt diff --git a/StdLib/Lib/test/test_email/data/msg_11.txt b/Src/StdLib/Lib/test/test_email/data/msg_11.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_11.txt rename to Src/StdLib/Lib/test/test_email/data/msg_11.txt diff --git a/StdLib/Lib/test/test_email/data/msg_12.txt b/Src/StdLib/Lib/test/test_email/data/msg_12.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_12.txt rename to Src/StdLib/Lib/test/test_email/data/msg_12.txt diff --git a/StdLib/Lib/test/test_email/data/msg_12a.txt b/Src/StdLib/Lib/test/test_email/data/msg_12a.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_12a.txt rename to Src/StdLib/Lib/test/test_email/data/msg_12a.txt diff --git a/StdLib/Lib/test/test_email/data/msg_13.txt b/Src/StdLib/Lib/test/test_email/data/msg_13.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_13.txt rename to Src/StdLib/Lib/test/test_email/data/msg_13.txt diff --git a/StdLib/Lib/test/test_email/data/msg_14.txt b/Src/StdLib/Lib/test/test_email/data/msg_14.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_14.txt rename to Src/StdLib/Lib/test/test_email/data/msg_14.txt diff --git a/StdLib/Lib/test/test_email/data/msg_15.txt b/Src/StdLib/Lib/test/test_email/data/msg_15.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_15.txt rename to Src/StdLib/Lib/test/test_email/data/msg_15.txt diff --git a/StdLib/Lib/test/test_email/data/msg_16.txt b/Src/StdLib/Lib/test/test_email/data/msg_16.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_16.txt rename to Src/StdLib/Lib/test/test_email/data/msg_16.txt diff --git a/StdLib/Lib/test/test_email/data/msg_17.txt b/Src/StdLib/Lib/test/test_email/data/msg_17.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_17.txt rename to Src/StdLib/Lib/test/test_email/data/msg_17.txt diff --git a/StdLib/Lib/test/test_email/data/msg_18.txt b/Src/StdLib/Lib/test/test_email/data/msg_18.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_18.txt rename to Src/StdLib/Lib/test/test_email/data/msg_18.txt diff --git a/StdLib/Lib/test/test_email/data/msg_19.txt b/Src/StdLib/Lib/test/test_email/data/msg_19.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_19.txt rename to Src/StdLib/Lib/test/test_email/data/msg_19.txt diff --git a/StdLib/Lib/test/test_email/data/msg_20.txt b/Src/StdLib/Lib/test/test_email/data/msg_20.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_20.txt rename to Src/StdLib/Lib/test/test_email/data/msg_20.txt diff --git a/StdLib/Lib/test/test_email/data/msg_21.txt b/Src/StdLib/Lib/test/test_email/data/msg_21.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_21.txt rename to Src/StdLib/Lib/test/test_email/data/msg_21.txt diff --git a/StdLib/Lib/test/test_email/data/msg_22.txt b/Src/StdLib/Lib/test/test_email/data/msg_22.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_22.txt rename to Src/StdLib/Lib/test/test_email/data/msg_22.txt diff --git a/StdLib/Lib/test/test_email/data/msg_23.txt b/Src/StdLib/Lib/test/test_email/data/msg_23.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_23.txt rename to Src/StdLib/Lib/test/test_email/data/msg_23.txt diff --git a/StdLib/Lib/test/test_email/data/msg_24.txt b/Src/StdLib/Lib/test/test_email/data/msg_24.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_24.txt rename to Src/StdLib/Lib/test/test_email/data/msg_24.txt diff --git a/StdLib/Lib/test/test_email/data/msg_25.txt b/Src/StdLib/Lib/test/test_email/data/msg_25.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_25.txt rename to Src/StdLib/Lib/test/test_email/data/msg_25.txt diff --git a/StdLib/Lib/test/test_email/data/msg_26.txt b/Src/StdLib/Lib/test/test_email/data/msg_26.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_26.txt rename to Src/StdLib/Lib/test/test_email/data/msg_26.txt diff --git a/StdLib/Lib/test/test_email/data/msg_27.txt b/Src/StdLib/Lib/test/test_email/data/msg_27.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_27.txt rename to Src/StdLib/Lib/test/test_email/data/msg_27.txt diff --git a/StdLib/Lib/test/test_email/data/msg_28.txt b/Src/StdLib/Lib/test/test_email/data/msg_28.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_28.txt rename to Src/StdLib/Lib/test/test_email/data/msg_28.txt diff --git a/StdLib/Lib/test/test_email/data/msg_29.txt b/Src/StdLib/Lib/test/test_email/data/msg_29.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_29.txt rename to Src/StdLib/Lib/test/test_email/data/msg_29.txt diff --git a/StdLib/Lib/test/test_email/data/msg_30.txt b/Src/StdLib/Lib/test/test_email/data/msg_30.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_30.txt rename to Src/StdLib/Lib/test/test_email/data/msg_30.txt diff --git a/StdLib/Lib/test/test_email/data/msg_31.txt b/Src/StdLib/Lib/test/test_email/data/msg_31.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_31.txt rename to Src/StdLib/Lib/test/test_email/data/msg_31.txt diff --git a/StdLib/Lib/test/test_email/data/msg_32.txt b/Src/StdLib/Lib/test/test_email/data/msg_32.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_32.txt rename to Src/StdLib/Lib/test/test_email/data/msg_32.txt diff --git a/StdLib/Lib/test/test_email/data/msg_33.txt b/Src/StdLib/Lib/test/test_email/data/msg_33.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_33.txt rename to Src/StdLib/Lib/test/test_email/data/msg_33.txt diff --git a/StdLib/Lib/test/test_email/data/msg_34.txt b/Src/StdLib/Lib/test/test_email/data/msg_34.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_34.txt rename to Src/StdLib/Lib/test/test_email/data/msg_34.txt diff --git a/StdLib/Lib/test/test_email/data/msg_35.txt b/Src/StdLib/Lib/test/test_email/data/msg_35.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_35.txt rename to Src/StdLib/Lib/test/test_email/data/msg_35.txt diff --git a/StdLib/Lib/test/test_email/data/msg_36.txt b/Src/StdLib/Lib/test/test_email/data/msg_36.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_36.txt rename to Src/StdLib/Lib/test/test_email/data/msg_36.txt diff --git a/StdLib/Lib/test/test_email/data/msg_37.txt b/Src/StdLib/Lib/test/test_email/data/msg_37.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_37.txt rename to Src/StdLib/Lib/test/test_email/data/msg_37.txt diff --git a/StdLib/Lib/test/test_email/data/msg_38.txt b/Src/StdLib/Lib/test/test_email/data/msg_38.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_38.txt rename to Src/StdLib/Lib/test/test_email/data/msg_38.txt diff --git a/StdLib/Lib/test/test_email/data/msg_39.txt b/Src/StdLib/Lib/test/test_email/data/msg_39.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_39.txt rename to Src/StdLib/Lib/test/test_email/data/msg_39.txt diff --git a/StdLib/Lib/test/test_email/data/msg_40.txt b/Src/StdLib/Lib/test/test_email/data/msg_40.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_40.txt rename to Src/StdLib/Lib/test/test_email/data/msg_40.txt diff --git a/StdLib/Lib/test/test_email/data/msg_41.txt b/Src/StdLib/Lib/test/test_email/data/msg_41.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_41.txt rename to Src/StdLib/Lib/test/test_email/data/msg_41.txt diff --git a/StdLib/Lib/test/test_email/data/msg_42.txt b/Src/StdLib/Lib/test/test_email/data/msg_42.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_42.txt rename to Src/StdLib/Lib/test/test_email/data/msg_42.txt diff --git a/StdLib/Lib/test/test_email/data/msg_43.txt b/Src/StdLib/Lib/test/test_email/data/msg_43.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_43.txt rename to Src/StdLib/Lib/test/test_email/data/msg_43.txt diff --git a/StdLib/Lib/test/test_email/data/msg_44.txt b/Src/StdLib/Lib/test/test_email/data/msg_44.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_44.txt rename to Src/StdLib/Lib/test/test_email/data/msg_44.txt diff --git a/StdLib/Lib/test/test_email/data/msg_45.txt b/Src/StdLib/Lib/test/test_email/data/msg_45.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_45.txt rename to Src/StdLib/Lib/test/test_email/data/msg_45.txt diff --git a/StdLib/Lib/test/test_email/data/msg_46.txt b/Src/StdLib/Lib/test/test_email/data/msg_46.txt similarity index 100% rename from StdLib/Lib/test/test_email/data/msg_46.txt rename to Src/StdLib/Lib/test/test_email/data/msg_46.txt diff --git a/StdLib/Lib/test/test_email/test__encoded_words.py b/Src/StdLib/Lib/test/test_email/test__encoded_words.py similarity index 100% rename from StdLib/Lib/test/test_email/test__encoded_words.py rename to Src/StdLib/Lib/test/test_email/test__encoded_words.py diff --git a/StdLib/Lib/test/test_email/test__header_value_parser.py b/Src/StdLib/Lib/test/test_email/test__header_value_parser.py similarity index 100% rename from StdLib/Lib/test/test_email/test__header_value_parser.py rename to Src/StdLib/Lib/test/test_email/test__header_value_parser.py diff --git a/StdLib/Lib/test/test_email/test_asian_codecs.py b/Src/StdLib/Lib/test/test_email/test_asian_codecs.py similarity index 100% rename from StdLib/Lib/test/test_email/test_asian_codecs.py rename to Src/StdLib/Lib/test/test_email/test_asian_codecs.py diff --git a/StdLib/Lib/test/test_email/test_contentmanager.py b/Src/StdLib/Lib/test/test_email/test_contentmanager.py similarity index 100% rename from StdLib/Lib/test/test_email/test_contentmanager.py rename to Src/StdLib/Lib/test/test_email/test_contentmanager.py diff --git a/StdLib/Lib/test/test_email/test_defect_handling.py b/Src/StdLib/Lib/test/test_email/test_defect_handling.py similarity index 100% rename from StdLib/Lib/test/test_email/test_defect_handling.py rename to Src/StdLib/Lib/test/test_email/test_defect_handling.py diff --git a/StdLib/Lib/test/test_email/test_email.py b/Src/StdLib/Lib/test/test_email/test_email.py similarity index 100% rename from StdLib/Lib/test/test_email/test_email.py rename to Src/StdLib/Lib/test/test_email/test_email.py diff --git a/StdLib/Lib/test/test_email/test_generator.py b/Src/StdLib/Lib/test/test_email/test_generator.py similarity index 100% rename from StdLib/Lib/test/test_email/test_generator.py rename to Src/StdLib/Lib/test/test_email/test_generator.py diff --git a/StdLib/Lib/test/test_email/test_headerregistry.py b/Src/StdLib/Lib/test/test_email/test_headerregistry.py similarity index 100% rename from StdLib/Lib/test/test_email/test_headerregistry.py rename to Src/StdLib/Lib/test/test_email/test_headerregistry.py diff --git a/StdLib/Lib/test/test_email/test_inversion.py b/Src/StdLib/Lib/test/test_email/test_inversion.py similarity index 100% rename from StdLib/Lib/test/test_email/test_inversion.py rename to Src/StdLib/Lib/test/test_email/test_inversion.py diff --git a/StdLib/Lib/test/test_email/test_message.py b/Src/StdLib/Lib/test/test_email/test_message.py similarity index 100% rename from StdLib/Lib/test/test_email/test_message.py rename to Src/StdLib/Lib/test/test_email/test_message.py diff --git a/StdLib/Lib/test/test_email/test_parser.py b/Src/StdLib/Lib/test/test_email/test_parser.py similarity index 100% rename from StdLib/Lib/test/test_email/test_parser.py rename to Src/StdLib/Lib/test/test_email/test_parser.py diff --git a/StdLib/Lib/test/test_email/test_pickleable.py b/Src/StdLib/Lib/test/test_email/test_pickleable.py similarity index 100% rename from StdLib/Lib/test/test_email/test_pickleable.py rename to Src/StdLib/Lib/test/test_email/test_pickleable.py diff --git a/StdLib/Lib/test/test_email/test_policy.py b/Src/StdLib/Lib/test/test_email/test_policy.py similarity index 100% rename from StdLib/Lib/test/test_email/test_policy.py rename to Src/StdLib/Lib/test/test_email/test_policy.py diff --git a/StdLib/Lib/test/test_email/test_utils.py b/Src/StdLib/Lib/test/test_email/test_utils.py similarity index 100% rename from StdLib/Lib/test/test_email/test_utils.py rename to Src/StdLib/Lib/test/test_email/test_utils.py diff --git a/StdLib/Lib/test/test_email/torture_test.py b/Src/StdLib/Lib/test/test_email/torture_test.py similarity index 100% rename from StdLib/Lib/test/test_email/torture_test.py rename to Src/StdLib/Lib/test/test_email/torture_test.py diff --git a/StdLib/Lib/test/test_ensurepip.py b/Src/StdLib/Lib/test/test_ensurepip.py similarity index 100% rename from StdLib/Lib/test/test_ensurepip.py rename to Src/StdLib/Lib/test/test_ensurepip.py diff --git a/StdLib/Lib/test/test_enum.py b/Src/StdLib/Lib/test/test_enum.py similarity index 100% rename from StdLib/Lib/test/test_enum.py rename to Src/StdLib/Lib/test/test_enum.py diff --git a/StdLib/Lib/test/test_enumerate.py b/Src/StdLib/Lib/test/test_enumerate.py similarity index 100% rename from StdLib/Lib/test/test_enumerate.py rename to Src/StdLib/Lib/test/test_enumerate.py diff --git a/StdLib/Lib/test/test_eof.py b/Src/StdLib/Lib/test/test_eof.py similarity index 100% rename from StdLib/Lib/test/test_eof.py rename to Src/StdLib/Lib/test/test_eof.py diff --git a/StdLib/Lib/test/test_epoll.py b/Src/StdLib/Lib/test/test_epoll.py similarity index 100% rename from StdLib/Lib/test/test_epoll.py rename to Src/StdLib/Lib/test/test_epoll.py diff --git a/StdLib/Lib/test/test_errno.py b/Src/StdLib/Lib/test/test_errno.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/test/test_errno.py rename to Src/StdLib/Lib/test/test_errno.py diff --git a/StdLib/Lib/test/test_exception_variations.py b/Src/StdLib/Lib/test/test_exception_variations.py similarity index 100% rename from StdLib/Lib/test/test_exception_variations.py rename to Src/StdLib/Lib/test/test_exception_variations.py diff --git a/StdLib/Lib/test/test_exceptions.py b/Src/StdLib/Lib/test/test_exceptions.py similarity index 100% rename from StdLib/Lib/test/test_exceptions.py rename to Src/StdLib/Lib/test/test_exceptions.py diff --git a/StdLib/Lib/test/test_extcall.py b/Src/StdLib/Lib/test/test_extcall.py similarity index 100% rename from StdLib/Lib/test/test_extcall.py rename to Src/StdLib/Lib/test/test_extcall.py diff --git a/StdLib/Lib/test/test_faulthandler.py b/Src/StdLib/Lib/test/test_faulthandler.py similarity index 100% rename from StdLib/Lib/test/test_faulthandler.py rename to Src/StdLib/Lib/test/test_faulthandler.py diff --git a/StdLib/Lib/test/test_fcntl.py b/Src/StdLib/Lib/test/test_fcntl.py similarity index 100% rename from StdLib/Lib/test/test_fcntl.py rename to Src/StdLib/Lib/test/test_fcntl.py diff --git a/StdLib/Lib/test/test_file.py b/Src/StdLib/Lib/test/test_file.py similarity index 100% rename from StdLib/Lib/test/test_file.py rename to Src/StdLib/Lib/test/test_file.py diff --git a/StdLib/Lib/test/test_file_eintr.py b/Src/StdLib/Lib/test/test_file_eintr.py similarity index 100% rename from StdLib/Lib/test/test_file_eintr.py rename to Src/StdLib/Lib/test/test_file_eintr.py diff --git a/StdLib/Lib/test/test_filecmp.py b/Src/StdLib/Lib/test/test_filecmp.py similarity index 100% rename from StdLib/Lib/test/test_filecmp.py rename to Src/StdLib/Lib/test/test_filecmp.py diff --git a/StdLib/Lib/test/test_fileinput.py b/Src/StdLib/Lib/test/test_fileinput.py similarity index 100% rename from StdLib/Lib/test/test_fileinput.py rename to Src/StdLib/Lib/test/test_fileinput.py diff --git a/StdLib/Lib/test/test_fileio.py b/Src/StdLib/Lib/test/test_fileio.py similarity index 100% rename from StdLib/Lib/test/test_fileio.py rename to Src/StdLib/Lib/test/test_fileio.py diff --git a/StdLib/Lib/test/test_finalization.py b/Src/StdLib/Lib/test/test_finalization.py similarity index 100% rename from StdLib/Lib/test/test_finalization.py rename to Src/StdLib/Lib/test/test_finalization.py diff --git a/StdLib/Lib/test/test_float.py b/Src/StdLib/Lib/test/test_float.py similarity index 100% rename from StdLib/Lib/test/test_float.py rename to Src/StdLib/Lib/test/test_float.py diff --git a/StdLib/Lib/test/test_flufl.py b/Src/StdLib/Lib/test/test_flufl.py similarity index 100% rename from StdLib/Lib/test/test_flufl.py rename to Src/StdLib/Lib/test/test_flufl.py diff --git a/StdLib/Lib/test/test_fnmatch.py b/Src/StdLib/Lib/test/test_fnmatch.py similarity index 100% rename from StdLib/Lib/test/test_fnmatch.py rename to Src/StdLib/Lib/test/test_fnmatch.py diff --git a/StdLib/Lib/test/test_fork1.py b/Src/StdLib/Lib/test/test_fork1.py similarity index 100% rename from StdLib/Lib/test/test_fork1.py rename to Src/StdLib/Lib/test/test_fork1.py diff --git a/StdLib/Lib/test/test_format.py b/Src/StdLib/Lib/test/test_format.py similarity index 100% rename from StdLib/Lib/test/test_format.py rename to Src/StdLib/Lib/test/test_format.py diff --git a/StdLib/Lib/test/test_fractions.py b/Src/StdLib/Lib/test/test_fractions.py similarity index 100% rename from StdLib/Lib/test/test_fractions.py rename to Src/StdLib/Lib/test/test_fractions.py diff --git a/StdLib/Lib/test/test_frame.py b/Src/StdLib/Lib/test/test_frame.py similarity index 100% rename from StdLib/Lib/test/test_frame.py rename to Src/StdLib/Lib/test/test_frame.py diff --git a/StdLib/Lib/test/test_fstring.py b/Src/StdLib/Lib/test/test_fstring.py similarity index 100% rename from StdLib/Lib/test/test_fstring.py rename to Src/StdLib/Lib/test/test_fstring.py diff --git a/StdLib/Lib/test/test_ftplib.py b/Src/StdLib/Lib/test/test_ftplib.py similarity index 100% rename from StdLib/Lib/test/test_ftplib.py rename to Src/StdLib/Lib/test/test_ftplib.py diff --git a/StdLib/Lib/test/test_funcattrs.py b/Src/StdLib/Lib/test/test_funcattrs.py similarity index 100% rename from StdLib/Lib/test/test_funcattrs.py rename to Src/StdLib/Lib/test/test_funcattrs.py diff --git a/StdLib/Lib/test/test_functools.py b/Src/StdLib/Lib/test/test_functools.py similarity index 100% rename from StdLib/Lib/test/test_functools.py rename to Src/StdLib/Lib/test/test_functools.py diff --git a/StdLib/Lib/test/test_future.py b/Src/StdLib/Lib/test/test_future.py similarity index 100% rename from StdLib/Lib/test/test_future.py rename to Src/StdLib/Lib/test/test_future.py diff --git a/StdLib/Lib/test/test_future3.py b/Src/StdLib/Lib/test/test_future3.py similarity index 100% rename from StdLib/Lib/test/test_future3.py rename to Src/StdLib/Lib/test/test_future3.py diff --git a/StdLib/Lib/test/test_future4.py b/Src/StdLib/Lib/test/test_future4.py similarity index 100% rename from StdLib/Lib/test/test_future4.py rename to Src/StdLib/Lib/test/test_future4.py diff --git a/StdLib/Lib/test/test_future5.py b/Src/StdLib/Lib/test/test_future5.py similarity index 100% rename from StdLib/Lib/test/test_future5.py rename to Src/StdLib/Lib/test/test_future5.py diff --git a/StdLib/Lib/test/test_gc.py b/Src/StdLib/Lib/test/test_gc.py similarity index 100% rename from StdLib/Lib/test/test_gc.py rename to Src/StdLib/Lib/test/test_gc.py diff --git a/StdLib/Lib/test/test_gdb.py b/Src/StdLib/Lib/test/test_gdb.py similarity index 100% rename from StdLib/Lib/test/test_gdb.py rename to Src/StdLib/Lib/test/test_gdb.py diff --git a/StdLib/Lib/test/test_generators.py b/Src/StdLib/Lib/test/test_generators.py similarity index 100% rename from StdLib/Lib/test/test_generators.py rename to Src/StdLib/Lib/test/test_generators.py diff --git a/StdLib/Lib/test/test_genericpath.py b/Src/StdLib/Lib/test/test_genericpath.py similarity index 100% rename from StdLib/Lib/test/test_genericpath.py rename to Src/StdLib/Lib/test/test_genericpath.py diff --git a/StdLib/Lib/test/test_genexps.py b/Src/StdLib/Lib/test/test_genexps.py similarity index 100% rename from StdLib/Lib/test/test_genexps.py rename to Src/StdLib/Lib/test/test_genexps.py diff --git a/StdLib/Lib/test/test_getargs2.py b/Src/StdLib/Lib/test/test_getargs2.py similarity index 100% rename from StdLib/Lib/test/test_getargs2.py rename to Src/StdLib/Lib/test/test_getargs2.py diff --git a/StdLib/Lib/test/test_getopt.py b/Src/StdLib/Lib/test/test_getopt.py similarity index 100% rename from StdLib/Lib/test/test_getopt.py rename to Src/StdLib/Lib/test/test_getopt.py diff --git a/StdLib/Lib/test/test_getpass.py b/Src/StdLib/Lib/test/test_getpass.py similarity index 100% rename from StdLib/Lib/test/test_getpass.py rename to Src/StdLib/Lib/test/test_getpass.py diff --git a/StdLib/Lib/test/test_gettext.py b/Src/StdLib/Lib/test/test_gettext.py similarity index 100% rename from StdLib/Lib/test/test_gettext.py rename to Src/StdLib/Lib/test/test_gettext.py diff --git a/StdLib/Lib/test/test_glob.py b/Src/StdLib/Lib/test/test_glob.py similarity index 100% rename from StdLib/Lib/test/test_glob.py rename to Src/StdLib/Lib/test/test_glob.py diff --git a/StdLib/Lib/test/test_global.py b/Src/StdLib/Lib/test/test_global.py similarity index 100% rename from StdLib/Lib/test/test_global.py rename to Src/StdLib/Lib/test/test_global.py diff --git a/StdLib/Lib/test/test_grammar.py b/Src/StdLib/Lib/test/test_grammar.py similarity index 100% rename from StdLib/Lib/test/test_grammar.py rename to Src/StdLib/Lib/test/test_grammar.py diff --git a/StdLib/Lib/test/test_grp.py b/Src/StdLib/Lib/test/test_grp.py similarity index 100% rename from StdLib/Lib/test/test_grp.py rename to Src/StdLib/Lib/test/test_grp.py diff --git a/StdLib/Lib/test/test_gzip.py b/Src/StdLib/Lib/test/test_gzip.py similarity index 100% rename from StdLib/Lib/test/test_gzip.py rename to Src/StdLib/Lib/test/test_gzip.py diff --git a/StdLib/Lib/test/test_hash.py b/Src/StdLib/Lib/test/test_hash.py similarity index 100% rename from StdLib/Lib/test/test_hash.py rename to Src/StdLib/Lib/test/test_hash.py diff --git a/StdLib/Lib/test/test_hashlib.py b/Src/StdLib/Lib/test/test_hashlib.py similarity index 100% rename from StdLib/Lib/test/test_hashlib.py rename to Src/StdLib/Lib/test/test_hashlib.py diff --git a/StdLib/Lib/test/test_heapq.py b/Src/StdLib/Lib/test/test_heapq.py similarity index 100% rename from StdLib/Lib/test/test_heapq.py rename to Src/StdLib/Lib/test/test_heapq.py diff --git a/StdLib/Lib/test/test_hmac.py b/Src/StdLib/Lib/test/test_hmac.py similarity index 100% rename from StdLib/Lib/test/test_hmac.py rename to Src/StdLib/Lib/test/test_hmac.py diff --git a/StdLib/Lib/test/test_html.py b/Src/StdLib/Lib/test/test_html.py similarity index 100% rename from StdLib/Lib/test/test_html.py rename to Src/StdLib/Lib/test/test_html.py diff --git a/StdLib/Lib/test/test_htmlparser.py b/Src/StdLib/Lib/test/test_htmlparser.py similarity index 100% rename from StdLib/Lib/test/test_htmlparser.py rename to Src/StdLib/Lib/test/test_htmlparser.py diff --git a/StdLib/Lib/test/test_http_cookiejar.py b/Src/StdLib/Lib/test/test_http_cookiejar.py similarity index 100% rename from StdLib/Lib/test/test_http_cookiejar.py rename to Src/StdLib/Lib/test/test_http_cookiejar.py diff --git a/StdLib/Lib/test/test_http_cookies.py b/Src/StdLib/Lib/test/test_http_cookies.py similarity index 100% rename from StdLib/Lib/test/test_http_cookies.py rename to Src/StdLib/Lib/test/test_http_cookies.py diff --git a/StdLib/Lib/test/test_httplib.py b/Src/StdLib/Lib/test/test_httplib.py similarity index 100% rename from StdLib/Lib/test/test_httplib.py rename to Src/StdLib/Lib/test/test_httplib.py diff --git a/StdLib/Lib/test/test_httpservers.py b/Src/StdLib/Lib/test/test_httpservers.py similarity index 100% rename from StdLib/Lib/test/test_httpservers.py rename to Src/StdLib/Lib/test/test_httpservers.py diff --git a/StdLib/Lib/test/test_idle.py b/Src/StdLib/Lib/test/test_idle.py similarity index 100% rename from StdLib/Lib/test/test_idle.py rename to Src/StdLib/Lib/test/test_idle.py diff --git a/StdLib/Lib/test/test_imaplib.py b/Src/StdLib/Lib/test/test_imaplib.py similarity index 100% rename from StdLib/Lib/test/test_imaplib.py rename to Src/StdLib/Lib/test/test_imaplib.py diff --git a/StdLib/Lib/test/test_imghdr.py b/Src/StdLib/Lib/test/test_imghdr.py similarity index 100% rename from StdLib/Lib/test/test_imghdr.py rename to Src/StdLib/Lib/test/test_imghdr.py diff --git a/StdLib/Lib/test/test_imp.py b/Src/StdLib/Lib/test/test_imp.py similarity index 100% rename from StdLib/Lib/test/test_imp.py rename to Src/StdLib/Lib/test/test_imp.py diff --git a/StdLib/Lib/test/test_import.py b/Src/StdLib/Lib/test/test_import.py similarity index 100% rename from StdLib/Lib/test/test_import.py rename to Src/StdLib/Lib/test/test_import.py diff --git a/StdLib/Lib/test/test_importlib/__init__.py b/Src/StdLib/Lib/test/test_importlib/__init__.py similarity index 100% rename from StdLib/Lib/test/test_importlib/__init__.py rename to Src/StdLib/Lib/test/test_importlib/__init__.py diff --git a/StdLib/Lib/test/test_importlib/__main__.py b/Src/StdLib/Lib/test/test_importlib/__main__.py similarity index 100% rename from StdLib/Lib/test/test_importlib/__main__.py rename to Src/StdLib/Lib/test/test_importlib/__main__.py diff --git a/StdLib/Lib/test/test_importlib/abc.py b/Src/StdLib/Lib/test/test_importlib/abc.py similarity index 100% rename from StdLib/Lib/test/test_importlib/abc.py rename to Src/StdLib/Lib/test/test_importlib/abc.py diff --git a/StdLib/Lib/test/test_importlib/builtin/__init__.py b/Src/StdLib/Lib/test/test_importlib/builtin/__init__.py similarity index 100% rename from StdLib/Lib/test/test_importlib/builtin/__init__.py rename to Src/StdLib/Lib/test/test_importlib/builtin/__init__.py diff --git a/StdLib/Lib/test/test_importlib/builtin/__main__.py b/Src/StdLib/Lib/test/test_importlib/builtin/__main__.py similarity index 100% rename from StdLib/Lib/test/test_importlib/builtin/__main__.py rename to Src/StdLib/Lib/test/test_importlib/builtin/__main__.py diff --git a/StdLib/Lib/test/test_importlib/builtin/test_finder.py b/Src/StdLib/Lib/test/test_importlib/builtin/test_finder.py similarity index 100% rename from StdLib/Lib/test/test_importlib/builtin/test_finder.py rename to Src/StdLib/Lib/test/test_importlib/builtin/test_finder.py diff --git a/StdLib/Lib/test/test_importlib/builtin/test_loader.py b/Src/StdLib/Lib/test/test_importlib/builtin/test_loader.py similarity index 100% rename from StdLib/Lib/test/test_importlib/builtin/test_loader.py rename to Src/StdLib/Lib/test/test_importlib/builtin/test_loader.py diff --git a/StdLib/Lib/test/test_importlib/builtin/util.py b/Src/StdLib/Lib/test/test_importlib/builtin/util.py similarity index 100% rename from StdLib/Lib/test/test_importlib/builtin/util.py rename to Src/StdLib/Lib/test/test_importlib/builtin/util.py diff --git a/StdLib/Lib/test/test_importlib/extension/__init__.py b/Src/StdLib/Lib/test/test_importlib/extension/__init__.py similarity index 100% rename from StdLib/Lib/test/test_importlib/extension/__init__.py rename to Src/StdLib/Lib/test/test_importlib/extension/__init__.py diff --git a/StdLib/Lib/test/test_importlib/extension/__main__.py b/Src/StdLib/Lib/test/test_importlib/extension/__main__.py similarity index 100% rename from StdLib/Lib/test/test_importlib/extension/__main__.py rename to Src/StdLib/Lib/test/test_importlib/extension/__main__.py diff --git a/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py b/Src/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py similarity index 100% rename from StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py rename to Src/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py diff --git a/StdLib/Lib/test/test_importlib/extension/test_finder.py b/Src/StdLib/Lib/test/test_importlib/extension/test_finder.py similarity index 100% rename from StdLib/Lib/test/test_importlib/extension/test_finder.py rename to Src/StdLib/Lib/test/test_importlib/extension/test_finder.py diff --git a/StdLib/Lib/test/test_importlib/extension/test_loader.py b/Src/StdLib/Lib/test/test_importlib/extension/test_loader.py similarity index 100% rename from StdLib/Lib/test/test_importlib/extension/test_loader.py rename to Src/StdLib/Lib/test/test_importlib/extension/test_loader.py diff --git a/StdLib/Lib/test/test_importlib/extension/test_path_hook.py b/Src/StdLib/Lib/test/test_importlib/extension/test_path_hook.py similarity index 100% rename from StdLib/Lib/test/test_importlib/extension/test_path_hook.py rename to Src/StdLib/Lib/test/test_importlib/extension/test_path_hook.py diff --git a/StdLib/Lib/test/test_importlib/extension/util.py b/Src/StdLib/Lib/test/test_importlib/extension/util.py similarity index 100% rename from StdLib/Lib/test/test_importlib/extension/util.py rename to Src/StdLib/Lib/test/test_importlib/extension/util.py diff --git a/StdLib/Lib/test/test_importlib/frozen/__init__.py b/Src/StdLib/Lib/test/test_importlib/frozen/__init__.py similarity index 100% rename from StdLib/Lib/test/test_importlib/frozen/__init__.py rename to Src/StdLib/Lib/test/test_importlib/frozen/__init__.py diff --git a/StdLib/Lib/test/test_importlib/frozen/__main__.py b/Src/StdLib/Lib/test/test_importlib/frozen/__main__.py similarity index 100% rename from StdLib/Lib/test/test_importlib/frozen/__main__.py rename to Src/StdLib/Lib/test/test_importlib/frozen/__main__.py diff --git a/StdLib/Lib/test/test_importlib/frozen/test_finder.py b/Src/StdLib/Lib/test/test_importlib/frozen/test_finder.py similarity index 100% rename from StdLib/Lib/test/test_importlib/frozen/test_finder.py rename to Src/StdLib/Lib/test/test_importlib/frozen/test_finder.py diff --git a/StdLib/Lib/test/test_importlib/frozen/test_loader.py b/Src/StdLib/Lib/test/test_importlib/frozen/test_loader.py similarity index 100% rename from StdLib/Lib/test/test_importlib/frozen/test_loader.py rename to Src/StdLib/Lib/test/test_importlib/frozen/test_loader.py diff --git a/StdLib/Lib/test/test_importlib/import_/__init__.py b/Src/StdLib/Lib/test/test_importlib/import_/__init__.py similarity index 100% rename from StdLib/Lib/test/test_importlib/import_/__init__.py rename to Src/StdLib/Lib/test/test_importlib/import_/__init__.py diff --git a/StdLib/Lib/test/test_importlib/import_/__main__.py b/Src/StdLib/Lib/test/test_importlib/import_/__main__.py similarity index 100% rename from StdLib/Lib/test/test_importlib/import_/__main__.py rename to Src/StdLib/Lib/test/test_importlib/import_/__main__.py diff --git a/StdLib/Lib/test/test_importlib/import_/test___loader__.py b/Src/StdLib/Lib/test/test_importlib/import_/test___loader__.py similarity index 100% rename from StdLib/Lib/test/test_importlib/import_/test___loader__.py rename to Src/StdLib/Lib/test/test_importlib/import_/test___loader__.py diff --git a/StdLib/Lib/test/test_importlib/import_/test___package__.py b/Src/StdLib/Lib/test/test_importlib/import_/test___package__.py similarity index 100% rename from StdLib/Lib/test/test_importlib/import_/test___package__.py rename to Src/StdLib/Lib/test/test_importlib/import_/test___package__.py diff --git a/StdLib/Lib/test/test_importlib/import_/test_api.py b/Src/StdLib/Lib/test/test_importlib/import_/test_api.py similarity index 100% rename from StdLib/Lib/test/test_importlib/import_/test_api.py rename to Src/StdLib/Lib/test/test_importlib/import_/test_api.py diff --git a/StdLib/Lib/test/test_importlib/import_/test_caching.py b/Src/StdLib/Lib/test/test_importlib/import_/test_caching.py similarity index 100% rename from StdLib/Lib/test/test_importlib/import_/test_caching.py rename to Src/StdLib/Lib/test/test_importlib/import_/test_caching.py diff --git a/StdLib/Lib/test/test_importlib/import_/test_fromlist.py b/Src/StdLib/Lib/test/test_importlib/import_/test_fromlist.py similarity index 100% rename from StdLib/Lib/test/test_importlib/import_/test_fromlist.py rename to Src/StdLib/Lib/test/test_importlib/import_/test_fromlist.py diff --git a/StdLib/Lib/test/test_importlib/import_/test_meta_path.py b/Src/StdLib/Lib/test/test_importlib/import_/test_meta_path.py similarity index 100% rename from StdLib/Lib/test/test_importlib/import_/test_meta_path.py rename to Src/StdLib/Lib/test/test_importlib/import_/test_meta_path.py diff --git a/StdLib/Lib/test/test_importlib/import_/test_packages.py b/Src/StdLib/Lib/test/test_importlib/import_/test_packages.py similarity index 100% rename from StdLib/Lib/test/test_importlib/import_/test_packages.py rename to Src/StdLib/Lib/test/test_importlib/import_/test_packages.py diff --git a/StdLib/Lib/test/test_importlib/import_/test_path.py b/Src/StdLib/Lib/test/test_importlib/import_/test_path.py similarity index 100% rename from StdLib/Lib/test/test_importlib/import_/test_path.py rename to Src/StdLib/Lib/test/test_importlib/import_/test_path.py diff --git a/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py b/Src/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py similarity index 100% rename from StdLib/Lib/test/test_importlib/import_/test_relative_imports.py rename to Src/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py diff --git a/StdLib/Lib/test/test_importlib/import_/util.py b/Src/StdLib/Lib/test/test_importlib/import_/util.py similarity index 100% rename from StdLib/Lib/test/test_importlib/import_/util.py rename to Src/StdLib/Lib/test/test_importlib/import_/util.py diff --git a/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py b/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py similarity index 100% rename from StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py rename to Src/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py diff --git a/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py b/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py similarity index 100% rename from StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py rename to Src/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py diff --git a/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip b/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip similarity index 100% rename from StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip rename to Src/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip diff --git a/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py b/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py similarity index 100% rename from StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py rename to Src/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py diff --git a/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty b/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty similarity index 100% rename from StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty rename to Src/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty diff --git a/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip b/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip similarity index 100% rename from StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip rename to Src/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip diff --git a/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py b/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py similarity index 100% rename from StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py rename to Src/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py diff --git a/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py b/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py similarity index 100% rename from StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py rename to Src/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py diff --git a/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py b/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py similarity index 100% rename from StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py rename to Src/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py diff --git a/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py b/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py similarity index 100% rename from StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py rename to Src/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py diff --git a/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py b/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py similarity index 100% rename from StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py rename to Src/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py diff --git a/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py b/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py similarity index 100% rename from StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py rename to Src/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py diff --git a/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py b/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py similarity index 100% rename from StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py rename to Src/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py diff --git a/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip b/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip similarity index 100% rename from StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip rename to Src/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip diff --git a/StdLib/Lib/test/test_importlib/regrtest.py b/Src/StdLib/Lib/test/test_importlib/regrtest.py similarity index 100% rename from StdLib/Lib/test/test_importlib/regrtest.py rename to Src/StdLib/Lib/test/test_importlib/regrtest.py diff --git a/StdLib/Lib/test/test_importlib/source/__init__.py b/Src/StdLib/Lib/test/test_importlib/source/__init__.py similarity index 100% rename from StdLib/Lib/test/test_importlib/source/__init__.py rename to Src/StdLib/Lib/test/test_importlib/source/__init__.py diff --git a/StdLib/Lib/test/test_importlib/source/__main__.py b/Src/StdLib/Lib/test/test_importlib/source/__main__.py similarity index 100% rename from StdLib/Lib/test/test_importlib/source/__main__.py rename to Src/StdLib/Lib/test/test_importlib/source/__main__.py diff --git a/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py b/Src/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py similarity index 100% rename from StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py rename to Src/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py diff --git a/StdLib/Lib/test/test_importlib/source/test_file_loader.py b/Src/StdLib/Lib/test/test_importlib/source/test_file_loader.py similarity index 100% rename from StdLib/Lib/test/test_importlib/source/test_file_loader.py rename to Src/StdLib/Lib/test/test_importlib/source/test_file_loader.py diff --git a/StdLib/Lib/test/test_importlib/source/test_finder.py b/Src/StdLib/Lib/test/test_importlib/source/test_finder.py similarity index 100% rename from StdLib/Lib/test/test_importlib/source/test_finder.py rename to Src/StdLib/Lib/test/test_importlib/source/test_finder.py diff --git a/StdLib/Lib/test/test_importlib/source/test_path_hook.py b/Src/StdLib/Lib/test/test_importlib/source/test_path_hook.py similarity index 100% rename from StdLib/Lib/test/test_importlib/source/test_path_hook.py rename to Src/StdLib/Lib/test/test_importlib/source/test_path_hook.py diff --git a/StdLib/Lib/test/test_importlib/source/test_source_encoding.py b/Src/StdLib/Lib/test/test_importlib/source/test_source_encoding.py similarity index 100% rename from StdLib/Lib/test/test_importlib/source/test_source_encoding.py rename to Src/StdLib/Lib/test/test_importlib/source/test_source_encoding.py diff --git a/StdLib/Lib/test/test_importlib/source/util.py b/Src/StdLib/Lib/test/test_importlib/source/util.py similarity index 100% rename from StdLib/Lib/test/test_importlib/source/util.py rename to Src/StdLib/Lib/test/test_importlib/source/util.py diff --git a/StdLib/Lib/test/test_importlib/test_abc.py b/Src/StdLib/Lib/test/test_importlib/test_abc.py similarity index 100% rename from StdLib/Lib/test/test_importlib/test_abc.py rename to Src/StdLib/Lib/test/test_importlib/test_abc.py diff --git a/StdLib/Lib/test/test_importlib/test_api.py b/Src/StdLib/Lib/test/test_importlib/test_api.py similarity index 100% rename from StdLib/Lib/test/test_importlib/test_api.py rename to Src/StdLib/Lib/test/test_importlib/test_api.py diff --git a/StdLib/Lib/test/test_importlib/test_locks.py b/Src/StdLib/Lib/test/test_importlib/test_locks.py similarity index 100% rename from StdLib/Lib/test/test_importlib/test_locks.py rename to Src/StdLib/Lib/test/test_importlib/test_locks.py diff --git a/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py b/Src/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py similarity index 100% rename from StdLib/Lib/test/test_importlib/test_namespace_pkgs.py rename to Src/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py diff --git a/StdLib/Lib/test/test_importlib/test_spec.py b/Src/StdLib/Lib/test/test_importlib/test_spec.py similarity index 100% rename from StdLib/Lib/test/test_importlib/test_spec.py rename to Src/StdLib/Lib/test/test_importlib/test_spec.py diff --git a/StdLib/Lib/test/test_importlib/test_util.py b/Src/StdLib/Lib/test/test_importlib/test_util.py similarity index 100% rename from StdLib/Lib/test/test_importlib/test_util.py rename to Src/StdLib/Lib/test/test_importlib/test_util.py diff --git a/StdLib/Lib/test/test_importlib/test_windows.py b/Src/StdLib/Lib/test/test_importlib/test_windows.py similarity index 100% rename from StdLib/Lib/test/test_importlib/test_windows.py rename to Src/StdLib/Lib/test/test_importlib/test_windows.py diff --git a/StdLib/Lib/test/test_importlib/util.py b/Src/StdLib/Lib/test/test_importlib/util.py similarity index 100% rename from StdLib/Lib/test/test_importlib/util.py rename to Src/StdLib/Lib/test/test_importlib/util.py diff --git a/StdLib/Lib/test/test_index.py b/Src/StdLib/Lib/test/test_index.py similarity index 100% rename from StdLib/Lib/test/test_index.py rename to Src/StdLib/Lib/test/test_index.py diff --git a/StdLib/Lib/test/test_inspect.py b/Src/StdLib/Lib/test/test_inspect.py similarity index 100% rename from StdLib/Lib/test/test_inspect.py rename to Src/StdLib/Lib/test/test_inspect.py diff --git a/StdLib/Lib/test/test_int.py b/Src/StdLib/Lib/test/test_int.py similarity index 100% rename from StdLib/Lib/test/test_int.py rename to Src/StdLib/Lib/test/test_int.py diff --git a/StdLib/Lib/test/test_int_literal.py b/Src/StdLib/Lib/test/test_int_literal.py similarity index 100% rename from StdLib/Lib/test/test_int_literal.py rename to Src/StdLib/Lib/test/test_int_literal.py diff --git a/StdLib/Lib/test/test_io.py b/Src/StdLib/Lib/test/test_io.py similarity index 100% rename from StdLib/Lib/test/test_io.py rename to Src/StdLib/Lib/test/test_io.py diff --git a/StdLib/Lib/test/test_ioctl.py b/Src/StdLib/Lib/test/test_ioctl.py similarity index 100% rename from StdLib/Lib/test/test_ioctl.py rename to Src/StdLib/Lib/test/test_ioctl.py diff --git a/StdLib/Lib/test/test_ipaddress.py b/Src/StdLib/Lib/test/test_ipaddress.py similarity index 100% rename from StdLib/Lib/test/test_ipaddress.py rename to Src/StdLib/Lib/test/test_ipaddress.py diff --git a/StdLib/Lib/test/test_isinstance.py b/Src/StdLib/Lib/test/test_isinstance.py similarity index 100% rename from StdLib/Lib/test/test_isinstance.py rename to Src/StdLib/Lib/test/test_isinstance.py diff --git a/StdLib/Lib/test/test_iter.py b/Src/StdLib/Lib/test/test_iter.py similarity index 100% rename from StdLib/Lib/test/test_iter.py rename to Src/StdLib/Lib/test/test_iter.py diff --git a/StdLib/Lib/test/test_iterlen.py b/Src/StdLib/Lib/test/test_iterlen.py similarity index 100% rename from StdLib/Lib/test/test_iterlen.py rename to Src/StdLib/Lib/test/test_iterlen.py diff --git a/StdLib/Lib/test/test_itertools.py b/Src/StdLib/Lib/test/test_itertools.py similarity index 100% rename from StdLib/Lib/test/test_itertools.py rename to Src/StdLib/Lib/test/test_itertools.py diff --git a/StdLib/Lib/test/test_json/__init__.py b/Src/StdLib/Lib/test/test_json/__init__.py similarity index 100% rename from StdLib/Lib/test/test_json/__init__.py rename to Src/StdLib/Lib/test/test_json/__init__.py diff --git a/StdLib/Lib/test/test_json/__main__.py b/Src/StdLib/Lib/test/test_json/__main__.py similarity index 100% rename from StdLib/Lib/test/test_json/__main__.py rename to Src/StdLib/Lib/test/test_json/__main__.py diff --git a/StdLib/Lib/test/test_json/test_decode.py b/Src/StdLib/Lib/test/test_json/test_decode.py similarity index 100% rename from StdLib/Lib/test/test_json/test_decode.py rename to Src/StdLib/Lib/test/test_json/test_decode.py diff --git a/StdLib/Lib/test/test_json/test_default.py b/Src/StdLib/Lib/test/test_json/test_default.py similarity index 100% rename from StdLib/Lib/test/test_json/test_default.py rename to Src/StdLib/Lib/test/test_json/test_default.py diff --git a/StdLib/Lib/test/test_json/test_dump.py b/Src/StdLib/Lib/test/test_json/test_dump.py similarity index 100% rename from StdLib/Lib/test/test_json/test_dump.py rename to Src/StdLib/Lib/test/test_json/test_dump.py diff --git a/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py b/Src/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py similarity index 100% rename from StdLib/Lib/test/test_json/test_encode_basestring_ascii.py rename to Src/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py diff --git a/StdLib/Lib/test/test_json/test_enum.py b/Src/StdLib/Lib/test/test_json/test_enum.py similarity index 100% rename from StdLib/Lib/test/test_json/test_enum.py rename to Src/StdLib/Lib/test/test_json/test_enum.py diff --git a/StdLib/Lib/test/test_json/test_fail.py b/Src/StdLib/Lib/test/test_json/test_fail.py similarity index 100% rename from StdLib/Lib/test/test_json/test_fail.py rename to Src/StdLib/Lib/test/test_json/test_fail.py diff --git a/StdLib/Lib/test/test_json/test_float.py b/Src/StdLib/Lib/test/test_json/test_float.py similarity index 100% rename from StdLib/Lib/test/test_json/test_float.py rename to Src/StdLib/Lib/test/test_json/test_float.py diff --git a/StdLib/Lib/test/test_json/test_indent.py b/Src/StdLib/Lib/test/test_json/test_indent.py similarity index 100% rename from StdLib/Lib/test/test_json/test_indent.py rename to Src/StdLib/Lib/test/test_json/test_indent.py diff --git a/StdLib/Lib/test/test_json/test_pass1.py b/Src/StdLib/Lib/test/test_json/test_pass1.py similarity index 100% rename from StdLib/Lib/test/test_json/test_pass1.py rename to Src/StdLib/Lib/test/test_json/test_pass1.py diff --git a/StdLib/Lib/test/test_json/test_pass2.py b/Src/StdLib/Lib/test/test_json/test_pass2.py similarity index 100% rename from StdLib/Lib/test/test_json/test_pass2.py rename to Src/StdLib/Lib/test/test_json/test_pass2.py diff --git a/StdLib/Lib/test/test_json/test_pass3.py b/Src/StdLib/Lib/test/test_json/test_pass3.py similarity index 100% rename from StdLib/Lib/test/test_json/test_pass3.py rename to Src/StdLib/Lib/test/test_json/test_pass3.py diff --git a/StdLib/Lib/test/test_json/test_recursion.py b/Src/StdLib/Lib/test/test_json/test_recursion.py similarity index 100% rename from StdLib/Lib/test/test_json/test_recursion.py rename to Src/StdLib/Lib/test/test_json/test_recursion.py diff --git a/StdLib/Lib/test/test_json/test_scanstring.py b/Src/StdLib/Lib/test/test_json/test_scanstring.py similarity index 100% rename from StdLib/Lib/test/test_json/test_scanstring.py rename to Src/StdLib/Lib/test/test_json/test_scanstring.py diff --git a/StdLib/Lib/test/test_json/test_separators.py b/Src/StdLib/Lib/test/test_json/test_separators.py similarity index 100% rename from StdLib/Lib/test/test_json/test_separators.py rename to Src/StdLib/Lib/test/test_json/test_separators.py diff --git a/StdLib/Lib/test/test_json/test_speedups.py b/Src/StdLib/Lib/test/test_json/test_speedups.py similarity index 100% rename from StdLib/Lib/test/test_json/test_speedups.py rename to Src/StdLib/Lib/test/test_json/test_speedups.py diff --git a/StdLib/Lib/test/test_json/test_tool.py b/Src/StdLib/Lib/test/test_json/test_tool.py similarity index 100% rename from StdLib/Lib/test/test_json/test_tool.py rename to Src/StdLib/Lib/test/test_json/test_tool.py diff --git a/StdLib/Lib/test/test_json/test_unicode.py b/Src/StdLib/Lib/test/test_json/test_unicode.py similarity index 100% rename from StdLib/Lib/test/test_json/test_unicode.py rename to Src/StdLib/Lib/test/test_json/test_unicode.py diff --git a/StdLib/Lib/test/test_keyword.py b/Src/StdLib/Lib/test/test_keyword.py similarity index 100% rename from StdLib/Lib/test/test_keyword.py rename to Src/StdLib/Lib/test/test_keyword.py diff --git a/StdLib/Lib/test/test_keywordonlyarg.py b/Src/StdLib/Lib/test/test_keywordonlyarg.py similarity index 100% rename from StdLib/Lib/test/test_keywordonlyarg.py rename to Src/StdLib/Lib/test/test_keywordonlyarg.py diff --git a/StdLib/Lib/test/test_kqueue.py b/Src/StdLib/Lib/test/test_kqueue.py similarity index 100% rename from StdLib/Lib/test/test_kqueue.py rename to Src/StdLib/Lib/test/test_kqueue.py diff --git a/StdLib/Lib/test/test_largefile.py b/Src/StdLib/Lib/test/test_largefile.py similarity index 100% rename from StdLib/Lib/test/test_largefile.py rename to Src/StdLib/Lib/test/test_largefile.py diff --git a/StdLib/Lib/test/test_lib2to3.py b/Src/StdLib/Lib/test/test_lib2to3.py similarity index 100% rename from StdLib/Lib/test/test_lib2to3.py rename to Src/StdLib/Lib/test/test_lib2to3.py diff --git a/StdLib/Lib/test/test_linecache.py b/Src/StdLib/Lib/test/test_linecache.py similarity index 100% rename from StdLib/Lib/test/test_linecache.py rename to Src/StdLib/Lib/test/test_linecache.py diff --git a/StdLib/Lib/test/test_list.py b/Src/StdLib/Lib/test/test_list.py similarity index 100% rename from StdLib/Lib/test/test_list.py rename to Src/StdLib/Lib/test/test_list.py diff --git a/StdLib/Lib/test/test_listcomps.py b/Src/StdLib/Lib/test/test_listcomps.py similarity index 100% rename from StdLib/Lib/test/test_listcomps.py rename to Src/StdLib/Lib/test/test_listcomps.py diff --git a/StdLib/Lib/test/test_locale.py b/Src/StdLib/Lib/test/test_locale.py similarity index 100% rename from StdLib/Lib/test/test_locale.py rename to Src/StdLib/Lib/test/test_locale.py diff --git a/StdLib/Lib/test/test_logging.py b/Src/StdLib/Lib/test/test_logging.py similarity index 100% rename from StdLib/Lib/test/test_logging.py rename to Src/StdLib/Lib/test/test_logging.py diff --git a/StdLib/Lib/test/test_long.py b/Src/StdLib/Lib/test/test_long.py similarity index 100% rename from StdLib/Lib/test/test_long.py rename to Src/StdLib/Lib/test/test_long.py diff --git a/StdLib/Lib/test/test_longexp.py b/Src/StdLib/Lib/test/test_longexp.py similarity index 100% rename from StdLib/Lib/test/test_longexp.py rename to Src/StdLib/Lib/test/test_longexp.py diff --git a/StdLib/Lib/test/test_lzma.py b/Src/StdLib/Lib/test/test_lzma.py similarity index 100% rename from StdLib/Lib/test/test_lzma.py rename to Src/StdLib/Lib/test/test_lzma.py diff --git a/StdLib/Lib/test/test_macpath.py b/Src/StdLib/Lib/test/test_macpath.py similarity index 100% rename from StdLib/Lib/test/test_macpath.py rename to Src/StdLib/Lib/test/test_macpath.py diff --git a/StdLib/Lib/test/test_macurl2path.py b/Src/StdLib/Lib/test/test_macurl2path.py similarity index 100% rename from StdLib/Lib/test/test_macurl2path.py rename to Src/StdLib/Lib/test/test_macurl2path.py diff --git a/StdLib/Lib/test/test_mailbox.py b/Src/StdLib/Lib/test/test_mailbox.py similarity index 100% rename from StdLib/Lib/test/test_mailbox.py rename to Src/StdLib/Lib/test/test_mailbox.py diff --git a/StdLib/Lib/test/test_mailcap.py b/Src/StdLib/Lib/test/test_mailcap.py similarity index 100% rename from StdLib/Lib/test/test_mailcap.py rename to Src/StdLib/Lib/test/test_mailcap.py diff --git a/StdLib/Lib/test/test_marshal.py b/Src/StdLib/Lib/test/test_marshal.py similarity index 100% rename from StdLib/Lib/test/test_marshal.py rename to Src/StdLib/Lib/test/test_marshal.py diff --git a/StdLib/Lib/test/test_math.py b/Src/StdLib/Lib/test/test_math.py similarity index 100% rename from StdLib/Lib/test/test_math.py rename to Src/StdLib/Lib/test/test_math.py diff --git a/StdLib/Lib/test/test_memoryio.py b/Src/StdLib/Lib/test/test_memoryio.py similarity index 100% rename from StdLib/Lib/test/test_memoryio.py rename to Src/StdLib/Lib/test/test_memoryio.py diff --git a/StdLib/Lib/test/test_memoryview.py b/Src/StdLib/Lib/test/test_memoryview.py similarity index 100% rename from StdLib/Lib/test/test_memoryview.py rename to Src/StdLib/Lib/test/test_memoryview.py diff --git a/StdLib/Lib/test/test_metaclass.py b/Src/StdLib/Lib/test/test_metaclass.py similarity index 100% rename from StdLib/Lib/test/test_metaclass.py rename to Src/StdLib/Lib/test/test_metaclass.py diff --git a/StdLib/Lib/test/test_mimetypes.py b/Src/StdLib/Lib/test/test_mimetypes.py similarity index 100% rename from StdLib/Lib/test/test_mimetypes.py rename to Src/StdLib/Lib/test/test_mimetypes.py diff --git a/StdLib/Lib/test/test_minidom.py b/Src/StdLib/Lib/test/test_minidom.py similarity index 100% rename from StdLib/Lib/test/test_minidom.py rename to Src/StdLib/Lib/test/test_minidom.py diff --git a/StdLib/Lib/test/test_mmap.py b/Src/StdLib/Lib/test/test_mmap.py similarity index 100% rename from StdLib/Lib/test/test_mmap.py rename to Src/StdLib/Lib/test/test_mmap.py diff --git a/StdLib/Lib/test/test_module.py b/Src/StdLib/Lib/test/test_module.py similarity index 100% rename from StdLib/Lib/test/test_module.py rename to Src/StdLib/Lib/test/test_module.py diff --git a/StdLib/Lib/test/test_modulefinder.py b/Src/StdLib/Lib/test/test_modulefinder.py similarity index 100% rename from StdLib/Lib/test/test_modulefinder.py rename to Src/StdLib/Lib/test/test_modulefinder.py diff --git a/StdLib/Lib/test/test_msilib.py b/Src/StdLib/Lib/test/test_msilib.py similarity index 100% rename from StdLib/Lib/test/test_msilib.py rename to Src/StdLib/Lib/test/test_msilib.py diff --git a/StdLib/Lib/test/test_multibytecodec.py b/Src/StdLib/Lib/test/test_multibytecodec.py similarity index 100% rename from StdLib/Lib/test/test_multibytecodec.py rename to Src/StdLib/Lib/test/test_multibytecodec.py diff --git a/StdLib/Lib/test/test_multiprocessing_fork.py b/Src/StdLib/Lib/test/test_multiprocessing_fork.py similarity index 100% rename from StdLib/Lib/test/test_multiprocessing_fork.py rename to Src/StdLib/Lib/test/test_multiprocessing_fork.py diff --git a/StdLib/Lib/test/test_multiprocessing_forkserver.py b/Src/StdLib/Lib/test/test_multiprocessing_forkserver.py similarity index 100% rename from StdLib/Lib/test/test_multiprocessing_forkserver.py rename to Src/StdLib/Lib/test/test_multiprocessing_forkserver.py diff --git a/StdLib/Lib/test/test_multiprocessing_main_handling.py b/Src/StdLib/Lib/test/test_multiprocessing_main_handling.py similarity index 100% rename from StdLib/Lib/test/test_multiprocessing_main_handling.py rename to Src/StdLib/Lib/test/test_multiprocessing_main_handling.py diff --git a/StdLib/Lib/test/test_multiprocessing_spawn.py b/Src/StdLib/Lib/test/test_multiprocessing_spawn.py similarity index 100% rename from StdLib/Lib/test/test_multiprocessing_spawn.py rename to Src/StdLib/Lib/test/test_multiprocessing_spawn.py diff --git a/StdLib/Lib/test/test_netrc.py b/Src/StdLib/Lib/test/test_netrc.py similarity index 100% rename from StdLib/Lib/test/test_netrc.py rename to Src/StdLib/Lib/test/test_netrc.py diff --git a/StdLib/Lib/test/test_nis.py b/Src/StdLib/Lib/test/test_nis.py similarity index 100% rename from StdLib/Lib/test/test_nis.py rename to Src/StdLib/Lib/test/test_nis.py diff --git a/StdLib/Lib/test/test_nntplib.py b/Src/StdLib/Lib/test/test_nntplib.py similarity index 100% rename from StdLib/Lib/test/test_nntplib.py rename to Src/StdLib/Lib/test/test_nntplib.py diff --git a/StdLib/Lib/test/test_normalization.py b/Src/StdLib/Lib/test/test_normalization.py similarity index 100% rename from StdLib/Lib/test/test_normalization.py rename to Src/StdLib/Lib/test/test_normalization.py diff --git a/StdLib/Lib/test/test_ntpath.py b/Src/StdLib/Lib/test/test_ntpath.py similarity index 100% rename from StdLib/Lib/test/test_ntpath.py rename to Src/StdLib/Lib/test/test_ntpath.py diff --git a/StdLib/Lib/test/test_numeric_tower.py b/Src/StdLib/Lib/test/test_numeric_tower.py similarity index 100% rename from StdLib/Lib/test/test_numeric_tower.py rename to Src/StdLib/Lib/test/test_numeric_tower.py diff --git a/StdLib/Lib/test/test_opcodes.py b/Src/StdLib/Lib/test/test_opcodes.py similarity index 100% rename from StdLib/Lib/test/test_opcodes.py rename to Src/StdLib/Lib/test/test_opcodes.py diff --git a/StdLib/Lib/test/test_openpty.py b/Src/StdLib/Lib/test/test_openpty.py similarity index 100% rename from StdLib/Lib/test/test_openpty.py rename to Src/StdLib/Lib/test/test_openpty.py diff --git a/StdLib/Lib/test/test_operator.py b/Src/StdLib/Lib/test/test_operator.py similarity index 100% rename from StdLib/Lib/test/test_operator.py rename to Src/StdLib/Lib/test/test_operator.py diff --git a/StdLib/Lib/test/test_optparse.py b/Src/StdLib/Lib/test/test_optparse.py similarity index 100% rename from StdLib/Lib/test/test_optparse.py rename to Src/StdLib/Lib/test/test_optparse.py diff --git a/StdLib/Lib/test/test_ordered_dict.py b/Src/StdLib/Lib/test/test_ordered_dict.py similarity index 100% rename from StdLib/Lib/test/test_ordered_dict.py rename to Src/StdLib/Lib/test/test_ordered_dict.py diff --git a/StdLib/Lib/test/test_os.py b/Src/StdLib/Lib/test/test_os.py similarity index 100% rename from StdLib/Lib/test/test_os.py rename to Src/StdLib/Lib/test/test_os.py diff --git a/StdLib/Lib/test/test_ossaudiodev.py b/Src/StdLib/Lib/test/test_ossaudiodev.py similarity index 100% rename from StdLib/Lib/test/test_ossaudiodev.py rename to Src/StdLib/Lib/test/test_ossaudiodev.py diff --git a/StdLib/Lib/test/test_osx_env.py b/Src/StdLib/Lib/test/test_osx_env.py similarity index 100% rename from StdLib/Lib/test/test_osx_env.py rename to Src/StdLib/Lib/test/test_osx_env.py diff --git a/StdLib/Lib/test/test_parser.py b/Src/StdLib/Lib/test/test_parser.py similarity index 100% rename from StdLib/Lib/test/test_parser.py rename to Src/StdLib/Lib/test/test_parser.py diff --git a/StdLib/Lib/test/test_pathlib.py b/Src/StdLib/Lib/test/test_pathlib.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/test/test_pathlib.py rename to Src/StdLib/Lib/test/test_pathlib.py diff --git a/StdLib/Lib/test/test_pdb.py b/Src/StdLib/Lib/test/test_pdb.py similarity index 100% rename from StdLib/Lib/test/test_pdb.py rename to Src/StdLib/Lib/test/test_pdb.py diff --git a/StdLib/Lib/test/test_peepholer.py b/Src/StdLib/Lib/test/test_peepholer.py similarity index 100% rename from StdLib/Lib/test/test_peepholer.py rename to Src/StdLib/Lib/test/test_peepholer.py diff --git a/StdLib/Lib/test/test_pep247.py b/Src/StdLib/Lib/test/test_pep247.py similarity index 100% rename from StdLib/Lib/test/test_pep247.py rename to Src/StdLib/Lib/test/test_pep247.py diff --git a/StdLib/Lib/test/test_pep277.py b/Src/StdLib/Lib/test/test_pep277.py similarity index 100% rename from StdLib/Lib/test/test_pep277.py rename to Src/StdLib/Lib/test/test_pep277.py diff --git a/StdLib/Lib/test/test_pep292.py b/Src/StdLib/Lib/test/test_pep292.py similarity index 100% rename from StdLib/Lib/test/test_pep292.py rename to Src/StdLib/Lib/test/test_pep292.py diff --git a/StdLib/Lib/test/test_pep3120.py b/Src/StdLib/Lib/test/test_pep3120.py similarity index 100% rename from StdLib/Lib/test/test_pep3120.py rename to Src/StdLib/Lib/test/test_pep3120.py diff --git a/StdLib/Lib/test/test_pep3131.py b/Src/StdLib/Lib/test/test_pep3131.py similarity index 100% rename from StdLib/Lib/test/test_pep3131.py rename to Src/StdLib/Lib/test/test_pep3131.py diff --git a/StdLib/Lib/test/test_pep3151.py b/Src/StdLib/Lib/test/test_pep3151.py similarity index 100% rename from StdLib/Lib/test/test_pep3151.py rename to Src/StdLib/Lib/test/test_pep3151.py diff --git a/StdLib/Lib/test/test_pep352.py b/Src/StdLib/Lib/test/test_pep352.py similarity index 100% rename from StdLib/Lib/test/test_pep352.py rename to Src/StdLib/Lib/test/test_pep352.py diff --git a/StdLib/Lib/test/test_pep380.py b/Src/StdLib/Lib/test/test_pep380.py similarity index 100% rename from StdLib/Lib/test/test_pep380.py rename to Src/StdLib/Lib/test/test_pep380.py diff --git a/StdLib/Lib/test/test_pep479.py b/Src/StdLib/Lib/test/test_pep479.py similarity index 100% rename from StdLib/Lib/test/test_pep479.py rename to Src/StdLib/Lib/test/test_pep479.py diff --git a/StdLib/Lib/test/test_pickle.py b/Src/StdLib/Lib/test/test_pickle.py similarity index 100% rename from StdLib/Lib/test/test_pickle.py rename to Src/StdLib/Lib/test/test_pickle.py diff --git a/StdLib/Lib/test/test_pickletools.py b/Src/StdLib/Lib/test/test_pickletools.py similarity index 100% rename from StdLib/Lib/test/test_pickletools.py rename to Src/StdLib/Lib/test/test_pickletools.py diff --git a/StdLib/Lib/test/test_pipes.py b/Src/StdLib/Lib/test/test_pipes.py similarity index 100% rename from StdLib/Lib/test/test_pipes.py rename to Src/StdLib/Lib/test/test_pipes.py diff --git a/StdLib/Lib/test/test_pkg.py b/Src/StdLib/Lib/test/test_pkg.py similarity index 100% rename from StdLib/Lib/test/test_pkg.py rename to Src/StdLib/Lib/test/test_pkg.py diff --git a/StdLib/Lib/test/test_pkgimport.py b/Src/StdLib/Lib/test/test_pkgimport.py similarity index 100% rename from StdLib/Lib/test/test_pkgimport.py rename to Src/StdLib/Lib/test/test_pkgimport.py diff --git a/StdLib/Lib/test/test_pkgutil.py b/Src/StdLib/Lib/test/test_pkgutil.py similarity index 100% rename from StdLib/Lib/test/test_pkgutil.py rename to Src/StdLib/Lib/test/test_pkgutil.py diff --git a/StdLib/Lib/test/test_platform.py b/Src/StdLib/Lib/test/test_platform.py similarity index 100% rename from StdLib/Lib/test/test_platform.py rename to Src/StdLib/Lib/test/test_platform.py diff --git a/StdLib/Lib/test/test_plistlib.py b/Src/StdLib/Lib/test/test_plistlib.py similarity index 100% rename from StdLib/Lib/test/test_plistlib.py rename to Src/StdLib/Lib/test/test_plistlib.py diff --git a/StdLib/Lib/test/test_poll.py b/Src/StdLib/Lib/test/test_poll.py similarity index 100% rename from StdLib/Lib/test/test_poll.py rename to Src/StdLib/Lib/test/test_poll.py diff --git a/StdLib/Lib/test/test_popen.py b/Src/StdLib/Lib/test/test_popen.py similarity index 100% rename from StdLib/Lib/test/test_popen.py rename to Src/StdLib/Lib/test/test_popen.py diff --git a/StdLib/Lib/test/test_poplib.py b/Src/StdLib/Lib/test/test_poplib.py similarity index 100% rename from StdLib/Lib/test/test_poplib.py rename to Src/StdLib/Lib/test/test_poplib.py diff --git a/StdLib/Lib/test/test_posix.py b/Src/StdLib/Lib/test/test_posix.py similarity index 100% rename from StdLib/Lib/test/test_posix.py rename to Src/StdLib/Lib/test/test_posix.py diff --git a/StdLib/Lib/test/test_posixpath.py b/Src/StdLib/Lib/test/test_posixpath.py similarity index 100% rename from StdLib/Lib/test/test_posixpath.py rename to Src/StdLib/Lib/test/test_posixpath.py diff --git a/StdLib/Lib/test/test_pow.py b/Src/StdLib/Lib/test/test_pow.py similarity index 100% rename from StdLib/Lib/test/test_pow.py rename to Src/StdLib/Lib/test/test_pow.py diff --git a/StdLib/Lib/test/test_pprint.py b/Src/StdLib/Lib/test/test_pprint.py similarity index 100% rename from StdLib/Lib/test/test_pprint.py rename to Src/StdLib/Lib/test/test_pprint.py diff --git a/StdLib/Lib/test/test_print.py b/Src/StdLib/Lib/test/test_print.py similarity index 100% rename from StdLib/Lib/test/test_print.py rename to Src/StdLib/Lib/test/test_print.py diff --git a/StdLib/Lib/test/test_profile.py b/Src/StdLib/Lib/test/test_profile.py similarity index 100% rename from StdLib/Lib/test/test_profile.py rename to Src/StdLib/Lib/test/test_profile.py diff --git a/StdLib/Lib/test/test_property.py b/Src/StdLib/Lib/test/test_property.py similarity index 100% rename from StdLib/Lib/test/test_property.py rename to Src/StdLib/Lib/test/test_property.py diff --git a/StdLib/Lib/test/test_pstats.py b/Src/StdLib/Lib/test/test_pstats.py similarity index 100% rename from StdLib/Lib/test/test_pstats.py rename to Src/StdLib/Lib/test/test_pstats.py diff --git a/StdLib/Lib/test/test_pty.py b/Src/StdLib/Lib/test/test_pty.py similarity index 100% rename from StdLib/Lib/test/test_pty.py rename to Src/StdLib/Lib/test/test_pty.py diff --git a/StdLib/Lib/test/test_pulldom.py b/Src/StdLib/Lib/test/test_pulldom.py similarity index 100% rename from StdLib/Lib/test/test_pulldom.py rename to Src/StdLib/Lib/test/test_pulldom.py diff --git a/StdLib/Lib/test/test_pwd.py b/Src/StdLib/Lib/test/test_pwd.py similarity index 100% rename from StdLib/Lib/test/test_pwd.py rename to Src/StdLib/Lib/test/test_pwd.py diff --git a/StdLib/Lib/test/test_py_compile.py b/Src/StdLib/Lib/test/test_py_compile.py similarity index 100% rename from StdLib/Lib/test/test_py_compile.py rename to Src/StdLib/Lib/test/test_py_compile.py diff --git a/StdLib/Lib/test/test_pyclbr.py b/Src/StdLib/Lib/test/test_pyclbr.py similarity index 100% rename from StdLib/Lib/test/test_pyclbr.py rename to Src/StdLib/Lib/test/test_pyclbr.py diff --git a/StdLib/Lib/test/test_pydoc.py b/Src/StdLib/Lib/test/test_pydoc.py similarity index 100% rename from StdLib/Lib/test/test_pydoc.py rename to Src/StdLib/Lib/test/test_pydoc.py diff --git a/StdLib/Lib/test/test_pyexpat.py b/Src/StdLib/Lib/test/test_pyexpat.py similarity index 100% rename from StdLib/Lib/test/test_pyexpat.py rename to Src/StdLib/Lib/test/test_pyexpat.py diff --git a/StdLib/Lib/test/test_queue.py b/Src/StdLib/Lib/test/test_queue.py similarity index 100% rename from StdLib/Lib/test/test_queue.py rename to Src/StdLib/Lib/test/test_queue.py diff --git a/StdLib/Lib/test/test_quopri.py b/Src/StdLib/Lib/test/test_quopri.py similarity index 100% rename from StdLib/Lib/test/test_quopri.py rename to Src/StdLib/Lib/test/test_quopri.py diff --git a/StdLib/Lib/test/test_raise.py b/Src/StdLib/Lib/test/test_raise.py similarity index 100% rename from StdLib/Lib/test/test_raise.py rename to Src/StdLib/Lib/test/test_raise.py diff --git a/StdLib/Lib/test/test_random.py b/Src/StdLib/Lib/test/test_random.py similarity index 100% rename from StdLib/Lib/test/test_random.py rename to Src/StdLib/Lib/test/test_random.py diff --git a/StdLib/Lib/test/test_range.py b/Src/StdLib/Lib/test/test_range.py similarity index 100% rename from StdLib/Lib/test/test_range.py rename to Src/StdLib/Lib/test/test_range.py diff --git a/StdLib/Lib/test/test_re.py b/Src/StdLib/Lib/test/test_re.py similarity index 100% rename from StdLib/Lib/test/test_re.py rename to Src/StdLib/Lib/test/test_re.py diff --git a/StdLib/Lib/test/test_readline.py b/Src/StdLib/Lib/test/test_readline.py similarity index 100% rename from StdLib/Lib/test/test_readline.py rename to Src/StdLib/Lib/test/test_readline.py diff --git a/StdLib/Lib/test/test_regrtest.py b/Src/StdLib/Lib/test/test_regrtest.py similarity index 100% rename from StdLib/Lib/test/test_regrtest.py rename to Src/StdLib/Lib/test/test_regrtest.py diff --git a/StdLib/Lib/test/test_reprlib.py b/Src/StdLib/Lib/test/test_reprlib.py similarity index 100% rename from StdLib/Lib/test/test_reprlib.py rename to Src/StdLib/Lib/test/test_reprlib.py diff --git a/StdLib/Lib/test/test_resource.py b/Src/StdLib/Lib/test/test_resource.py similarity index 100% rename from StdLib/Lib/test/test_resource.py rename to Src/StdLib/Lib/test/test_resource.py diff --git a/StdLib/Lib/test/test_richcmp.py b/Src/StdLib/Lib/test/test_richcmp.py similarity index 100% rename from StdLib/Lib/test/test_richcmp.py rename to Src/StdLib/Lib/test/test_richcmp.py diff --git a/StdLib/Lib/test/test_rlcompleter.py b/Src/StdLib/Lib/test/test_rlcompleter.py similarity index 100% rename from StdLib/Lib/test/test_rlcompleter.py rename to Src/StdLib/Lib/test/test_rlcompleter.py diff --git a/StdLib/Lib/test/test_robotparser.py b/Src/StdLib/Lib/test/test_robotparser.py similarity index 100% rename from StdLib/Lib/test/test_robotparser.py rename to Src/StdLib/Lib/test/test_robotparser.py diff --git a/StdLib/Lib/test/test_runpy.py b/Src/StdLib/Lib/test/test_runpy.py similarity index 100% rename from StdLib/Lib/test/test_runpy.py rename to Src/StdLib/Lib/test/test_runpy.py diff --git a/StdLib/Lib/test/test_sax.py b/Src/StdLib/Lib/test/test_sax.py similarity index 100% rename from StdLib/Lib/test/test_sax.py rename to Src/StdLib/Lib/test/test_sax.py diff --git a/StdLib/Lib/test/test_sched.py b/Src/StdLib/Lib/test/test_sched.py similarity index 100% rename from StdLib/Lib/test/test_sched.py rename to Src/StdLib/Lib/test/test_sched.py diff --git a/StdLib/Lib/test/test_scope.py b/Src/StdLib/Lib/test/test_scope.py similarity index 100% rename from StdLib/Lib/test/test_scope.py rename to Src/StdLib/Lib/test/test_scope.py diff --git a/StdLib/Lib/test/test_script_helper.py b/Src/StdLib/Lib/test/test_script_helper.py similarity index 100% rename from StdLib/Lib/test/test_script_helper.py rename to Src/StdLib/Lib/test/test_script_helper.py diff --git a/StdLib/Lib/test/test_select.py b/Src/StdLib/Lib/test/test_select.py similarity index 100% rename from StdLib/Lib/test/test_select.py rename to Src/StdLib/Lib/test/test_select.py diff --git a/StdLib/Lib/test/test_selectors.py b/Src/StdLib/Lib/test/test_selectors.py similarity index 100% rename from StdLib/Lib/test/test_selectors.py rename to Src/StdLib/Lib/test/test_selectors.py diff --git a/StdLib/Lib/test/test_set.py b/Src/StdLib/Lib/test/test_set.py similarity index 100% rename from StdLib/Lib/test/test_set.py rename to Src/StdLib/Lib/test/test_set.py diff --git a/StdLib/Lib/test/test_setcomps.py b/Src/StdLib/Lib/test/test_setcomps.py similarity index 100% rename from StdLib/Lib/test/test_setcomps.py rename to Src/StdLib/Lib/test/test_setcomps.py diff --git a/StdLib/Lib/test/test_shelve.py b/Src/StdLib/Lib/test/test_shelve.py similarity index 100% rename from StdLib/Lib/test/test_shelve.py rename to Src/StdLib/Lib/test/test_shelve.py diff --git a/StdLib/Lib/test/test_shlex.py b/Src/StdLib/Lib/test/test_shlex.py similarity index 100% rename from StdLib/Lib/test/test_shlex.py rename to Src/StdLib/Lib/test/test_shlex.py diff --git a/StdLib/Lib/test/test_shutil.py b/Src/StdLib/Lib/test/test_shutil.py similarity index 100% rename from StdLib/Lib/test/test_shutil.py rename to Src/StdLib/Lib/test/test_shutil.py diff --git a/StdLib/Lib/test/test_signal.py b/Src/StdLib/Lib/test/test_signal.py similarity index 100% rename from StdLib/Lib/test/test_signal.py rename to Src/StdLib/Lib/test/test_signal.py diff --git a/StdLib/Lib/test/test_site.py b/Src/StdLib/Lib/test/test_site.py similarity index 100% rename from StdLib/Lib/test/test_site.py rename to Src/StdLib/Lib/test/test_site.py diff --git a/StdLib/Lib/test/test_slice.py b/Src/StdLib/Lib/test/test_slice.py similarity index 100% rename from StdLib/Lib/test/test_slice.py rename to Src/StdLib/Lib/test/test_slice.py diff --git a/StdLib/Lib/test/test_smtpd.py b/Src/StdLib/Lib/test/test_smtpd.py similarity index 100% rename from StdLib/Lib/test/test_smtpd.py rename to Src/StdLib/Lib/test/test_smtpd.py diff --git a/StdLib/Lib/test/test_smtplib.py b/Src/StdLib/Lib/test/test_smtplib.py similarity index 100% rename from StdLib/Lib/test/test_smtplib.py rename to Src/StdLib/Lib/test/test_smtplib.py diff --git a/StdLib/Lib/test/test_smtpnet.py b/Src/StdLib/Lib/test/test_smtpnet.py similarity index 100% rename from StdLib/Lib/test/test_smtpnet.py rename to Src/StdLib/Lib/test/test_smtpnet.py diff --git a/StdLib/Lib/test/test_sndhdr.py b/Src/StdLib/Lib/test/test_sndhdr.py similarity index 100% rename from StdLib/Lib/test/test_sndhdr.py rename to Src/StdLib/Lib/test/test_sndhdr.py diff --git a/StdLib/Lib/test/test_socket.py b/Src/StdLib/Lib/test/test_socket.py similarity index 100% rename from StdLib/Lib/test/test_socket.py rename to Src/StdLib/Lib/test/test_socket.py diff --git a/StdLib/Lib/test/test_socketserver.py b/Src/StdLib/Lib/test/test_socketserver.py similarity index 100% rename from StdLib/Lib/test/test_socketserver.py rename to Src/StdLib/Lib/test/test_socketserver.py diff --git a/StdLib/Lib/test/test_sort.py b/Src/StdLib/Lib/test/test_sort.py similarity index 100% rename from StdLib/Lib/test/test_sort.py rename to Src/StdLib/Lib/test/test_sort.py diff --git a/StdLib/Lib/test/test_source_encoding.py b/Src/StdLib/Lib/test/test_source_encoding.py similarity index 100% rename from StdLib/Lib/test/test_source_encoding.py rename to Src/StdLib/Lib/test/test_source_encoding.py diff --git a/StdLib/Lib/test/test_spwd.py b/Src/StdLib/Lib/test/test_spwd.py similarity index 100% rename from StdLib/Lib/test/test_spwd.py rename to Src/StdLib/Lib/test/test_spwd.py diff --git a/StdLib/Lib/test/test_sqlite.py b/Src/StdLib/Lib/test/test_sqlite.py similarity index 100% rename from StdLib/Lib/test/test_sqlite.py rename to Src/StdLib/Lib/test/test_sqlite.py diff --git a/StdLib/Lib/test/test_ssl.py b/Src/StdLib/Lib/test/test_ssl.py similarity index 100% rename from StdLib/Lib/test/test_ssl.py rename to Src/StdLib/Lib/test/test_ssl.py diff --git a/StdLib/Lib/test/test_startfile.py b/Src/StdLib/Lib/test/test_startfile.py similarity index 100% rename from StdLib/Lib/test/test_startfile.py rename to Src/StdLib/Lib/test/test_startfile.py diff --git a/StdLib/Lib/test/test_stat.py b/Src/StdLib/Lib/test/test_stat.py similarity index 100% rename from StdLib/Lib/test/test_stat.py rename to Src/StdLib/Lib/test/test_stat.py diff --git a/StdLib/Lib/test/test_statistics.py b/Src/StdLib/Lib/test/test_statistics.py similarity index 100% rename from StdLib/Lib/test/test_statistics.py rename to Src/StdLib/Lib/test/test_statistics.py diff --git a/StdLib/Lib/test/test_strftime.py b/Src/StdLib/Lib/test/test_strftime.py similarity index 100% rename from StdLib/Lib/test/test_strftime.py rename to Src/StdLib/Lib/test/test_strftime.py diff --git a/StdLib/Lib/test/test_string.py b/Src/StdLib/Lib/test/test_string.py similarity index 100% rename from StdLib/Lib/test/test_string.py rename to Src/StdLib/Lib/test/test_string.py diff --git a/StdLib/Lib/test/test_stringprep.py b/Src/StdLib/Lib/test/test_stringprep.py similarity index 100% rename from StdLib/Lib/test/test_stringprep.py rename to Src/StdLib/Lib/test/test_stringprep.py diff --git a/StdLib/Lib/test/test_strlit.py b/Src/StdLib/Lib/test/test_strlit.py similarity index 100% rename from StdLib/Lib/test/test_strlit.py rename to Src/StdLib/Lib/test/test_strlit.py diff --git a/StdLib/Lib/test/test_strptime.py b/Src/StdLib/Lib/test/test_strptime.py similarity index 100% rename from StdLib/Lib/test/test_strptime.py rename to Src/StdLib/Lib/test/test_strptime.py diff --git a/StdLib/Lib/test/test_strtod.py b/Src/StdLib/Lib/test/test_strtod.py similarity index 100% rename from StdLib/Lib/test/test_strtod.py rename to Src/StdLib/Lib/test/test_strtod.py diff --git a/StdLib/Lib/test/test_struct.py b/Src/StdLib/Lib/test/test_struct.py similarity index 100% rename from StdLib/Lib/test/test_struct.py rename to Src/StdLib/Lib/test/test_struct.py diff --git a/StdLib/Lib/test/test_structmembers.py b/Src/StdLib/Lib/test/test_structmembers.py similarity index 100% rename from StdLib/Lib/test/test_structmembers.py rename to Src/StdLib/Lib/test/test_structmembers.py diff --git a/StdLib/Lib/test/test_structseq.py b/Src/StdLib/Lib/test/test_structseq.py similarity index 100% rename from StdLib/Lib/test/test_structseq.py rename to Src/StdLib/Lib/test/test_structseq.py diff --git a/StdLib/Lib/test/test_subprocess.py b/Src/StdLib/Lib/test/test_subprocess.py similarity index 100% rename from StdLib/Lib/test/test_subprocess.py rename to Src/StdLib/Lib/test/test_subprocess.py diff --git a/StdLib/Lib/test/test_sunau.py b/Src/StdLib/Lib/test/test_sunau.py similarity index 100% rename from StdLib/Lib/test/test_sunau.py rename to Src/StdLib/Lib/test/test_sunau.py diff --git a/StdLib/Lib/test/test_sundry.py b/Src/StdLib/Lib/test/test_sundry.py similarity index 100% rename from StdLib/Lib/test/test_sundry.py rename to Src/StdLib/Lib/test/test_sundry.py diff --git a/StdLib/Lib/test/test_super.py b/Src/StdLib/Lib/test/test_super.py similarity index 100% rename from StdLib/Lib/test/test_super.py rename to Src/StdLib/Lib/test/test_super.py diff --git a/StdLib/Lib/test/test_support.py b/Src/StdLib/Lib/test/test_support.py similarity index 100% rename from StdLib/Lib/test/test_support.py rename to Src/StdLib/Lib/test/test_support.py diff --git a/StdLib/Lib/test/test_symtable.py b/Src/StdLib/Lib/test/test_symtable.py similarity index 100% rename from StdLib/Lib/test/test_symtable.py rename to Src/StdLib/Lib/test/test_symtable.py diff --git a/StdLib/Lib/test/test_syntax.py b/Src/StdLib/Lib/test/test_syntax.py similarity index 100% rename from StdLib/Lib/test/test_syntax.py rename to Src/StdLib/Lib/test/test_syntax.py diff --git a/StdLib/Lib/test/test_sys.py b/Src/StdLib/Lib/test/test_sys.py similarity index 100% rename from StdLib/Lib/test/test_sys.py rename to Src/StdLib/Lib/test/test_sys.py diff --git a/StdLib/Lib/test/test_sys_setprofile.py b/Src/StdLib/Lib/test/test_sys_setprofile.py similarity index 100% rename from StdLib/Lib/test/test_sys_setprofile.py rename to Src/StdLib/Lib/test/test_sys_setprofile.py diff --git a/StdLib/Lib/test/test_sys_settrace.py b/Src/StdLib/Lib/test/test_sys_settrace.py similarity index 100% rename from StdLib/Lib/test/test_sys_settrace.py rename to Src/StdLib/Lib/test/test_sys_settrace.py diff --git a/StdLib/Lib/test/test_sysconfig.py b/Src/StdLib/Lib/test/test_sysconfig.py similarity index 100% rename from StdLib/Lib/test/test_sysconfig.py rename to Src/StdLib/Lib/test/test_sysconfig.py diff --git a/StdLib/Lib/test/test_syslog.py b/Src/StdLib/Lib/test/test_syslog.py similarity index 100% rename from StdLib/Lib/test/test_syslog.py rename to Src/StdLib/Lib/test/test_syslog.py diff --git a/StdLib/Lib/test/test_tarfile.py b/Src/StdLib/Lib/test/test_tarfile.py similarity index 100% rename from StdLib/Lib/test/test_tarfile.py rename to Src/StdLib/Lib/test/test_tarfile.py diff --git a/StdLib/Lib/test/test_tcl.py b/Src/StdLib/Lib/test/test_tcl.py similarity index 100% rename from StdLib/Lib/test/test_tcl.py rename to Src/StdLib/Lib/test/test_tcl.py diff --git a/StdLib/Lib/test/test_telnetlib.py b/Src/StdLib/Lib/test/test_telnetlib.py similarity index 100% rename from StdLib/Lib/test/test_telnetlib.py rename to Src/StdLib/Lib/test/test_telnetlib.py diff --git a/StdLib/Lib/test/test_tempfile.py b/Src/StdLib/Lib/test/test_tempfile.py similarity index 100% rename from StdLib/Lib/test/test_tempfile.py rename to Src/StdLib/Lib/test/test_tempfile.py diff --git a/StdLib/Lib/test/test_textwrap.py b/Src/StdLib/Lib/test/test_textwrap.py similarity index 100% rename from StdLib/Lib/test/test_textwrap.py rename to Src/StdLib/Lib/test/test_textwrap.py diff --git a/StdLib/Lib/test/test_thread.py b/Src/StdLib/Lib/test/test_thread.py similarity index 100% rename from StdLib/Lib/test/test_thread.py rename to Src/StdLib/Lib/test/test_thread.py diff --git a/StdLib/Lib/test/test_threaded_import.py b/Src/StdLib/Lib/test/test_threaded_import.py similarity index 100% rename from StdLib/Lib/test/test_threaded_import.py rename to Src/StdLib/Lib/test/test_threaded_import.py diff --git a/StdLib/Lib/test/test_threadedtempfile.py b/Src/StdLib/Lib/test/test_threadedtempfile.py similarity index 100% rename from StdLib/Lib/test/test_threadedtempfile.py rename to Src/StdLib/Lib/test/test_threadedtempfile.py diff --git a/StdLib/Lib/test/test_threading.py b/Src/StdLib/Lib/test/test_threading.py similarity index 100% rename from StdLib/Lib/test/test_threading.py rename to Src/StdLib/Lib/test/test_threading.py diff --git a/StdLib/Lib/test/test_threading_local.py b/Src/StdLib/Lib/test/test_threading_local.py similarity index 100% rename from StdLib/Lib/test/test_threading_local.py rename to Src/StdLib/Lib/test/test_threading_local.py diff --git a/StdLib/Lib/test/test_threadsignals.py b/Src/StdLib/Lib/test/test_threadsignals.py similarity index 100% rename from StdLib/Lib/test/test_threadsignals.py rename to Src/StdLib/Lib/test/test_threadsignals.py diff --git a/StdLib/Lib/test/test_time.py b/Src/StdLib/Lib/test/test_time.py similarity index 100% rename from StdLib/Lib/test/test_time.py rename to Src/StdLib/Lib/test/test_time.py diff --git a/StdLib/Lib/test/test_timeit.py b/Src/StdLib/Lib/test/test_timeit.py similarity index 100% rename from StdLib/Lib/test/test_timeit.py rename to Src/StdLib/Lib/test/test_timeit.py diff --git a/StdLib/Lib/test/test_timeout.py b/Src/StdLib/Lib/test/test_timeout.py similarity index 100% rename from StdLib/Lib/test/test_timeout.py rename to Src/StdLib/Lib/test/test_timeout.py diff --git a/StdLib/Lib/test/test_tk.py b/Src/StdLib/Lib/test/test_tk.py similarity index 100% rename from StdLib/Lib/test/test_tk.py rename to Src/StdLib/Lib/test/test_tk.py diff --git a/StdLib/Lib/test/test_tokenize.py b/Src/StdLib/Lib/test/test_tokenize.py similarity index 100% rename from StdLib/Lib/test/test_tokenize.py rename to Src/StdLib/Lib/test/test_tokenize.py diff --git a/StdLib/Lib/test/test_tools/__init__.py b/Src/StdLib/Lib/test/test_tools/__init__.py similarity index 100% rename from StdLib/Lib/test/test_tools/__init__.py rename to Src/StdLib/Lib/test/test_tools/__init__.py diff --git a/StdLib/Lib/test/test_tools/__main__.py b/Src/StdLib/Lib/test/test_tools/__main__.py similarity index 100% rename from StdLib/Lib/test/test_tools/__main__.py rename to Src/StdLib/Lib/test/test_tools/__main__.py diff --git a/StdLib/Lib/test/test_tools/test_gprof2html.py b/Src/StdLib/Lib/test/test_tools/test_gprof2html.py similarity index 100% rename from StdLib/Lib/test/test_tools/test_gprof2html.py rename to Src/StdLib/Lib/test/test_tools/test_gprof2html.py diff --git a/StdLib/Lib/test/test_tools/test_md5sum.py b/Src/StdLib/Lib/test/test_tools/test_md5sum.py similarity index 100% rename from StdLib/Lib/test/test_tools/test_md5sum.py rename to Src/StdLib/Lib/test/test_tools/test_md5sum.py diff --git a/StdLib/Lib/test/test_tools/test_pdeps.py b/Src/StdLib/Lib/test/test_tools/test_pdeps.py similarity index 100% rename from StdLib/Lib/test/test_tools/test_pdeps.py rename to Src/StdLib/Lib/test/test_tools/test_pdeps.py diff --git a/StdLib/Lib/test/test_tools/test_pindent.py b/Src/StdLib/Lib/test/test_tools/test_pindent.py similarity index 100% rename from StdLib/Lib/test/test_tools/test_pindent.py rename to Src/StdLib/Lib/test/test_tools/test_pindent.py diff --git a/StdLib/Lib/test/test_tools/test_reindent.py b/Src/StdLib/Lib/test/test_tools/test_reindent.py similarity index 100% rename from StdLib/Lib/test/test_tools/test_reindent.py rename to Src/StdLib/Lib/test/test_tools/test_reindent.py diff --git a/StdLib/Lib/test/test_tools/test_sundry.py b/Src/StdLib/Lib/test/test_tools/test_sundry.py similarity index 100% rename from StdLib/Lib/test/test_tools/test_sundry.py rename to Src/StdLib/Lib/test/test_tools/test_sundry.py diff --git a/StdLib/Lib/test/test_tools/test_unparse.py b/Src/StdLib/Lib/test/test_tools/test_unparse.py similarity index 100% rename from StdLib/Lib/test/test_tools/test_unparse.py rename to Src/StdLib/Lib/test/test_tools/test_unparse.py diff --git a/StdLib/Lib/test/test_trace.py b/Src/StdLib/Lib/test/test_trace.py similarity index 100% rename from StdLib/Lib/test/test_trace.py rename to Src/StdLib/Lib/test/test_trace.py diff --git a/StdLib/Lib/test/test_traceback.py b/Src/StdLib/Lib/test/test_traceback.py similarity index 100% rename from StdLib/Lib/test/test_traceback.py rename to Src/StdLib/Lib/test/test_traceback.py diff --git a/StdLib/Lib/test/test_tracemalloc.py b/Src/StdLib/Lib/test/test_tracemalloc.py similarity index 100% rename from StdLib/Lib/test/test_tracemalloc.py rename to Src/StdLib/Lib/test/test_tracemalloc.py diff --git a/StdLib/Lib/test/test_ttk_guionly.py b/Src/StdLib/Lib/test/test_ttk_guionly.py similarity index 100% rename from StdLib/Lib/test/test_ttk_guionly.py rename to Src/StdLib/Lib/test/test_ttk_guionly.py diff --git a/StdLib/Lib/test/test_ttk_textonly.py b/Src/StdLib/Lib/test/test_ttk_textonly.py similarity index 100% rename from StdLib/Lib/test/test_ttk_textonly.py rename to Src/StdLib/Lib/test/test_ttk_textonly.py diff --git a/StdLib/Lib/test/test_tuple.py b/Src/StdLib/Lib/test/test_tuple.py similarity index 100% rename from StdLib/Lib/test/test_tuple.py rename to Src/StdLib/Lib/test/test_tuple.py diff --git a/StdLib/Lib/test/test_typechecks.py b/Src/StdLib/Lib/test/test_typechecks.py similarity index 100% rename from StdLib/Lib/test/test_typechecks.py rename to Src/StdLib/Lib/test/test_typechecks.py diff --git a/StdLib/Lib/test/test_types.py b/Src/StdLib/Lib/test/test_types.py similarity index 100% rename from StdLib/Lib/test/test_types.py rename to Src/StdLib/Lib/test/test_types.py diff --git a/StdLib/Lib/test/test_typing.py b/Src/StdLib/Lib/test/test_typing.py similarity index 100% rename from StdLib/Lib/test/test_typing.py rename to Src/StdLib/Lib/test/test_typing.py diff --git a/StdLib/Lib/test/test_ucn.py b/Src/StdLib/Lib/test/test_ucn.py similarity index 100% rename from StdLib/Lib/test/test_ucn.py rename to Src/StdLib/Lib/test/test_ucn.py diff --git a/StdLib/Lib/test/test_unary.py b/Src/StdLib/Lib/test/test_unary.py similarity index 100% rename from StdLib/Lib/test/test_unary.py rename to Src/StdLib/Lib/test/test_unary.py diff --git a/StdLib/Lib/test/test_unicode.py b/Src/StdLib/Lib/test/test_unicode.py similarity index 100% rename from StdLib/Lib/test/test_unicode.py rename to Src/StdLib/Lib/test/test_unicode.py diff --git a/StdLib/Lib/test/test_unicode_file.py b/Src/StdLib/Lib/test/test_unicode_file.py similarity index 100% rename from StdLib/Lib/test/test_unicode_file.py rename to Src/StdLib/Lib/test/test_unicode_file.py diff --git a/StdLib/Lib/test/test_unicodedata.py b/Src/StdLib/Lib/test/test_unicodedata.py similarity index 100% rename from StdLib/Lib/test/test_unicodedata.py rename to Src/StdLib/Lib/test/test_unicodedata.py diff --git a/StdLib/Lib/test/test_unittest.py b/Src/StdLib/Lib/test/test_unittest.py similarity index 100% rename from StdLib/Lib/test/test_unittest.py rename to Src/StdLib/Lib/test/test_unittest.py diff --git a/StdLib/Lib/test/test_univnewlines.py b/Src/StdLib/Lib/test/test_univnewlines.py similarity index 100% rename from StdLib/Lib/test/test_univnewlines.py rename to Src/StdLib/Lib/test/test_univnewlines.py diff --git a/StdLib/Lib/test/test_unpack.py b/Src/StdLib/Lib/test/test_unpack.py similarity index 100% rename from StdLib/Lib/test/test_unpack.py rename to Src/StdLib/Lib/test/test_unpack.py diff --git a/StdLib/Lib/test/test_unpack_ex.py b/Src/StdLib/Lib/test/test_unpack_ex.py similarity index 100% rename from StdLib/Lib/test/test_unpack_ex.py rename to Src/StdLib/Lib/test/test_unpack_ex.py diff --git a/StdLib/Lib/test/test_urllib.py b/Src/StdLib/Lib/test/test_urllib.py similarity index 100% rename from StdLib/Lib/test/test_urllib.py rename to Src/StdLib/Lib/test/test_urllib.py diff --git a/StdLib/Lib/test/test_urllib2.py b/Src/StdLib/Lib/test/test_urllib2.py similarity index 100% rename from StdLib/Lib/test/test_urllib2.py rename to Src/StdLib/Lib/test/test_urllib2.py diff --git a/StdLib/Lib/test/test_urllib2_localnet.py b/Src/StdLib/Lib/test/test_urllib2_localnet.py similarity index 100% rename from StdLib/Lib/test/test_urllib2_localnet.py rename to Src/StdLib/Lib/test/test_urllib2_localnet.py diff --git a/StdLib/Lib/test/test_urllib2net.py b/Src/StdLib/Lib/test/test_urllib2net.py similarity index 100% rename from StdLib/Lib/test/test_urllib2net.py rename to Src/StdLib/Lib/test/test_urllib2net.py diff --git a/StdLib/Lib/test/test_urllib_response.py b/Src/StdLib/Lib/test/test_urllib_response.py similarity index 100% rename from StdLib/Lib/test/test_urllib_response.py rename to Src/StdLib/Lib/test/test_urllib_response.py diff --git a/StdLib/Lib/test/test_urllibnet.py b/Src/StdLib/Lib/test/test_urllibnet.py similarity index 100% rename from StdLib/Lib/test/test_urllibnet.py rename to Src/StdLib/Lib/test/test_urllibnet.py diff --git a/StdLib/Lib/test/test_urlparse.py b/Src/StdLib/Lib/test/test_urlparse.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/test/test_urlparse.py rename to Src/StdLib/Lib/test/test_urlparse.py diff --git a/StdLib/Lib/test/test_userdict.py b/Src/StdLib/Lib/test/test_userdict.py similarity index 100% rename from StdLib/Lib/test/test_userdict.py rename to Src/StdLib/Lib/test/test_userdict.py diff --git a/StdLib/Lib/test/test_userlist.py b/Src/StdLib/Lib/test/test_userlist.py similarity index 100% rename from StdLib/Lib/test/test_userlist.py rename to Src/StdLib/Lib/test/test_userlist.py diff --git a/StdLib/Lib/test/test_userstring.py b/Src/StdLib/Lib/test/test_userstring.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/test/test_userstring.py rename to Src/StdLib/Lib/test/test_userstring.py diff --git a/StdLib/Lib/test/test_utf8_mode.py b/Src/StdLib/Lib/test/test_utf8_mode.py similarity index 100% rename from StdLib/Lib/test/test_utf8_mode.py rename to Src/StdLib/Lib/test/test_utf8_mode.py diff --git a/StdLib/Lib/test/test_uu.py b/Src/StdLib/Lib/test/test_uu.py similarity index 100% rename from StdLib/Lib/test/test_uu.py rename to Src/StdLib/Lib/test/test_uu.py diff --git a/StdLib/Lib/test/test_uuid.py b/Src/StdLib/Lib/test/test_uuid.py similarity index 100% rename from StdLib/Lib/test/test_uuid.py rename to Src/StdLib/Lib/test/test_uuid.py diff --git a/StdLib/Lib/test/test_venv.py b/Src/StdLib/Lib/test/test_venv.py similarity index 100% rename from StdLib/Lib/test/test_venv.py rename to Src/StdLib/Lib/test/test_venv.py diff --git a/StdLib/Lib/test/test_wait3.py b/Src/StdLib/Lib/test/test_wait3.py similarity index 100% rename from StdLib/Lib/test/test_wait3.py rename to Src/StdLib/Lib/test/test_wait3.py diff --git a/StdLib/Lib/test/test_wait4.py b/Src/StdLib/Lib/test/test_wait4.py similarity index 100% rename from StdLib/Lib/test/test_wait4.py rename to Src/StdLib/Lib/test/test_wait4.py diff --git a/StdLib/Lib/test/test_warnings.py b/Src/StdLib/Lib/test/test_warnings.py similarity index 100% rename from StdLib/Lib/test/test_warnings.py rename to Src/StdLib/Lib/test/test_warnings.py diff --git a/StdLib/Lib/test/test_wave.py b/Src/StdLib/Lib/test/test_wave.py similarity index 100% rename from StdLib/Lib/test/test_wave.py rename to Src/StdLib/Lib/test/test_wave.py diff --git a/StdLib/Lib/test/test_weakref.py b/Src/StdLib/Lib/test/test_weakref.py similarity index 100% rename from StdLib/Lib/test/test_weakref.py rename to Src/StdLib/Lib/test/test_weakref.py diff --git a/StdLib/Lib/test/test_weakset.py b/Src/StdLib/Lib/test/test_weakset.py similarity index 100% rename from StdLib/Lib/test/test_weakset.py rename to Src/StdLib/Lib/test/test_weakset.py diff --git a/StdLib/Lib/test/test_webbrowser.py b/Src/StdLib/Lib/test/test_webbrowser.py similarity index 100% rename from StdLib/Lib/test/test_webbrowser.py rename to Src/StdLib/Lib/test/test_webbrowser.py diff --git a/StdLib/Lib/test/test_winreg.py b/Src/StdLib/Lib/test/test_winreg.py similarity index 100% rename from StdLib/Lib/test/test_winreg.py rename to Src/StdLib/Lib/test/test_winreg.py diff --git a/StdLib/Lib/test/test_winsound.py b/Src/StdLib/Lib/test/test_winsound.py similarity index 100% rename from StdLib/Lib/test/test_winsound.py rename to Src/StdLib/Lib/test/test_winsound.py diff --git a/StdLib/Lib/test/test_with.py b/Src/StdLib/Lib/test/test_with.py similarity index 100% rename from StdLib/Lib/test/test_with.py rename to Src/StdLib/Lib/test/test_with.py diff --git a/StdLib/Lib/test/test_wsgiref.py b/Src/StdLib/Lib/test/test_wsgiref.py similarity index 100% rename from StdLib/Lib/test/test_wsgiref.py rename to Src/StdLib/Lib/test/test_wsgiref.py diff --git a/StdLib/Lib/test/test_xdrlib.py b/Src/StdLib/Lib/test/test_xdrlib.py similarity index 100% rename from StdLib/Lib/test/test_xdrlib.py rename to Src/StdLib/Lib/test/test_xdrlib.py diff --git a/StdLib/Lib/test/test_xml_dom_minicompat.py b/Src/StdLib/Lib/test/test_xml_dom_minicompat.py similarity index 100% rename from StdLib/Lib/test/test_xml_dom_minicompat.py rename to Src/StdLib/Lib/test/test_xml_dom_minicompat.py diff --git a/StdLib/Lib/test/test_xml_etree.py b/Src/StdLib/Lib/test/test_xml_etree.py similarity index 100% rename from StdLib/Lib/test/test_xml_etree.py rename to Src/StdLib/Lib/test/test_xml_etree.py diff --git a/StdLib/Lib/test/test_xml_etree_c.py b/Src/StdLib/Lib/test/test_xml_etree_c.py similarity index 100% rename from StdLib/Lib/test/test_xml_etree_c.py rename to Src/StdLib/Lib/test/test_xml_etree_c.py diff --git a/StdLib/Lib/test/test_xmlrpc.py b/Src/StdLib/Lib/test/test_xmlrpc.py similarity index 100% rename from StdLib/Lib/test/test_xmlrpc.py rename to Src/StdLib/Lib/test/test_xmlrpc.py diff --git a/StdLib/Lib/test/test_xmlrpc_net.py b/Src/StdLib/Lib/test/test_xmlrpc_net.py similarity index 100% rename from StdLib/Lib/test/test_xmlrpc_net.py rename to Src/StdLib/Lib/test/test_xmlrpc_net.py diff --git a/StdLib/Lib/test/test_zipfile.py b/Src/StdLib/Lib/test/test_zipfile.py similarity index 100% rename from StdLib/Lib/test/test_zipfile.py rename to Src/StdLib/Lib/test/test_zipfile.py diff --git a/StdLib/Lib/test/test_zipfile64.py b/Src/StdLib/Lib/test/test_zipfile64.py similarity index 100% rename from StdLib/Lib/test/test_zipfile64.py rename to Src/StdLib/Lib/test/test_zipfile64.py diff --git a/StdLib/Lib/test/test_zipimport.py b/Src/StdLib/Lib/test/test_zipimport.py similarity index 100% rename from StdLib/Lib/test/test_zipimport.py rename to Src/StdLib/Lib/test/test_zipimport.py diff --git a/StdLib/Lib/test/test_zipimport_support.py b/Src/StdLib/Lib/test/test_zipimport_support.py similarity index 100% rename from StdLib/Lib/test/test_zipimport_support.py rename to Src/StdLib/Lib/test/test_zipimport_support.py diff --git a/StdLib/Lib/test/test_zlib.py b/Src/StdLib/Lib/test/test_zlib.py similarity index 100% rename from StdLib/Lib/test/test_zlib.py rename to Src/StdLib/Lib/test/test_zlib.py diff --git a/StdLib/Lib/test/testcodec.py b/Src/StdLib/Lib/test/testcodec.py similarity index 100% rename from StdLib/Lib/test/testcodec.py rename to Src/StdLib/Lib/test/testcodec.py diff --git a/StdLib/Lib/test/testtar.tar b/Src/StdLib/Lib/test/testtar.tar similarity index 100% rename from StdLib/Lib/test/testtar.tar rename to Src/StdLib/Lib/test/testtar.tar diff --git a/StdLib/Lib/test/tf_inherit_check.py b/Src/StdLib/Lib/test/tf_inherit_check.py similarity index 100% rename from StdLib/Lib/test/tf_inherit_check.py rename to Src/StdLib/Lib/test/tf_inherit_check.py diff --git a/StdLib/Lib/test/threaded_import_hangers.py b/Src/StdLib/Lib/test/threaded_import_hangers.py similarity index 100% rename from StdLib/Lib/test/threaded_import_hangers.py rename to Src/StdLib/Lib/test/threaded_import_hangers.py diff --git a/StdLib/Lib/test/time_hashlib.py b/Src/StdLib/Lib/test/time_hashlib.py similarity index 100% rename from StdLib/Lib/test/time_hashlib.py rename to Src/StdLib/Lib/test/time_hashlib.py diff --git a/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt b/Src/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt similarity index 100% rename from StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt rename to Src/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt diff --git a/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt b/Src/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt similarity index 100% rename from StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt rename to Src/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt diff --git a/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt b/Src/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt similarity index 100% rename from StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt rename to Src/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt diff --git a/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt b/Src/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt similarity index 100% rename from StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt rename to Src/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt diff --git a/StdLib/Lib/test/tokenize_tests.txt b/Src/StdLib/Lib/test/tokenize_tests.txt similarity index 100% rename from StdLib/Lib/test/tokenize_tests.txt rename to Src/StdLib/Lib/test/tokenize_tests.txt diff --git a/StdLib/Lib/test/tracedmodules/__init__.py b/Src/StdLib/Lib/test/tracedmodules/__init__.py similarity index 100% rename from StdLib/Lib/test/tracedmodules/__init__.py rename to Src/StdLib/Lib/test/tracedmodules/__init__.py diff --git a/StdLib/Lib/test/tracedmodules/testmod.py b/Src/StdLib/Lib/test/tracedmodules/testmod.py similarity index 100% rename from StdLib/Lib/test/tracedmodules/testmod.py rename to Src/StdLib/Lib/test/tracedmodules/testmod.py diff --git a/StdLib/Lib/test/warning_tests.py b/Src/StdLib/Lib/test/warning_tests.py similarity index 100% rename from StdLib/Lib/test/warning_tests.py rename to Src/StdLib/Lib/test/warning_tests.py diff --git a/StdLib/Lib/test/win_console_handler.py b/Src/StdLib/Lib/test/win_console_handler.py similarity index 100% rename from StdLib/Lib/test/win_console_handler.py rename to Src/StdLib/Lib/test/win_console_handler.py diff --git a/StdLib/Lib/test/xmltestdata/simple-ns.xml b/Src/StdLib/Lib/test/xmltestdata/simple-ns.xml similarity index 100% rename from StdLib/Lib/test/xmltestdata/simple-ns.xml rename to Src/StdLib/Lib/test/xmltestdata/simple-ns.xml diff --git a/StdLib/Lib/test/xmltestdata/simple.xml b/Src/StdLib/Lib/test/xmltestdata/simple.xml similarity index 100% rename from StdLib/Lib/test/xmltestdata/simple.xml rename to Src/StdLib/Lib/test/xmltestdata/simple.xml diff --git a/StdLib/Lib/test/xmltestdata/test.xml b/Src/StdLib/Lib/test/xmltestdata/test.xml similarity index 100% rename from StdLib/Lib/test/xmltestdata/test.xml rename to Src/StdLib/Lib/test/xmltestdata/test.xml diff --git a/StdLib/Lib/test/xmltestdata/test.xml.out b/Src/StdLib/Lib/test/xmltestdata/test.xml.out similarity index 100% rename from StdLib/Lib/test/xmltestdata/test.xml.out rename to Src/StdLib/Lib/test/xmltestdata/test.xml.out diff --git a/StdLib/Lib/test/xmltests.py b/Src/StdLib/Lib/test/xmltests.py similarity index 100% rename from StdLib/Lib/test/xmltests.py rename to Src/StdLib/Lib/test/xmltests.py diff --git a/StdLib/Lib/test/zip_cp437_header.zip b/Src/StdLib/Lib/test/zip_cp437_header.zip similarity index 100% rename from StdLib/Lib/test/zip_cp437_header.zip rename to Src/StdLib/Lib/test/zip_cp437_header.zip diff --git a/StdLib/Lib/test/zipdir.zip b/Src/StdLib/Lib/test/zipdir.zip similarity index 100% rename from StdLib/Lib/test/zipdir.zip rename to Src/StdLib/Lib/test/zipdir.zip diff --git a/StdLib/Lib/textwrap.py b/Src/StdLib/Lib/textwrap.py similarity index 100% rename from StdLib/Lib/textwrap.py rename to Src/StdLib/Lib/textwrap.py diff --git a/StdLib/Lib/this.py b/Src/StdLib/Lib/this.py similarity index 100% rename from StdLib/Lib/this.py rename to Src/StdLib/Lib/this.py diff --git a/StdLib/Lib/threading.py b/Src/StdLib/Lib/threading.py similarity index 100% rename from StdLib/Lib/threading.py rename to Src/StdLib/Lib/threading.py diff --git a/StdLib/Lib/timeit.py b/Src/StdLib/Lib/timeit.py similarity index 100% rename from StdLib/Lib/timeit.py rename to Src/StdLib/Lib/timeit.py diff --git a/StdLib/Lib/tkinter/__init__.py b/Src/StdLib/Lib/tkinter/__init__.py similarity index 100% rename from StdLib/Lib/tkinter/__init__.py rename to Src/StdLib/Lib/tkinter/__init__.py diff --git a/StdLib/Lib/tkinter/__main__.py b/Src/StdLib/Lib/tkinter/__main__.py similarity index 100% rename from StdLib/Lib/tkinter/__main__.py rename to Src/StdLib/Lib/tkinter/__main__.py diff --git a/StdLib/Lib/tkinter/_fix.py b/Src/StdLib/Lib/tkinter/_fix.py similarity index 100% rename from StdLib/Lib/tkinter/_fix.py rename to Src/StdLib/Lib/tkinter/_fix.py diff --git a/StdLib/Lib/tkinter/colorchooser.py b/Src/StdLib/Lib/tkinter/colorchooser.py similarity index 100% rename from StdLib/Lib/tkinter/colorchooser.py rename to Src/StdLib/Lib/tkinter/colorchooser.py diff --git a/StdLib/Lib/tkinter/commondialog.py b/Src/StdLib/Lib/tkinter/commondialog.py similarity index 100% rename from StdLib/Lib/tkinter/commondialog.py rename to Src/StdLib/Lib/tkinter/commondialog.py diff --git a/StdLib/Lib/tkinter/constants.py b/Src/StdLib/Lib/tkinter/constants.py similarity index 100% rename from StdLib/Lib/tkinter/constants.py rename to Src/StdLib/Lib/tkinter/constants.py diff --git a/StdLib/Lib/tkinter/dialog.py b/Src/StdLib/Lib/tkinter/dialog.py similarity index 100% rename from StdLib/Lib/tkinter/dialog.py rename to Src/StdLib/Lib/tkinter/dialog.py diff --git a/StdLib/Lib/tkinter/dnd.py b/Src/StdLib/Lib/tkinter/dnd.py similarity index 100% rename from StdLib/Lib/tkinter/dnd.py rename to Src/StdLib/Lib/tkinter/dnd.py diff --git a/StdLib/Lib/tkinter/filedialog.py b/Src/StdLib/Lib/tkinter/filedialog.py similarity index 100% rename from StdLib/Lib/tkinter/filedialog.py rename to Src/StdLib/Lib/tkinter/filedialog.py diff --git a/StdLib/Lib/tkinter/font.py b/Src/StdLib/Lib/tkinter/font.py similarity index 100% rename from StdLib/Lib/tkinter/font.py rename to Src/StdLib/Lib/tkinter/font.py diff --git a/StdLib/Lib/tkinter/messagebox.py b/Src/StdLib/Lib/tkinter/messagebox.py similarity index 100% rename from StdLib/Lib/tkinter/messagebox.py rename to Src/StdLib/Lib/tkinter/messagebox.py diff --git a/StdLib/Lib/tkinter/scrolledtext.py b/Src/StdLib/Lib/tkinter/scrolledtext.py similarity index 100% rename from StdLib/Lib/tkinter/scrolledtext.py rename to Src/StdLib/Lib/tkinter/scrolledtext.py diff --git a/StdLib/Lib/tkinter/simpledialog.py b/Src/StdLib/Lib/tkinter/simpledialog.py similarity index 100% rename from StdLib/Lib/tkinter/simpledialog.py rename to Src/StdLib/Lib/tkinter/simpledialog.py diff --git a/StdLib/Lib/tkinter/test/README b/Src/StdLib/Lib/tkinter/test/README similarity index 100% rename from StdLib/Lib/tkinter/test/README rename to Src/StdLib/Lib/tkinter/test/README diff --git a/StdLib/Lib/tkinter/test/__init__.py b/Src/StdLib/Lib/tkinter/test/__init__.py similarity index 100% rename from StdLib/Lib/tkinter/test/__init__.py rename to Src/StdLib/Lib/tkinter/test/__init__.py diff --git a/StdLib/Lib/tkinter/test/runtktests.py b/Src/StdLib/Lib/tkinter/test/runtktests.py similarity index 100% rename from StdLib/Lib/tkinter/test/runtktests.py rename to Src/StdLib/Lib/tkinter/test/runtktests.py diff --git a/StdLib/Lib/tkinter/test/support.py b/Src/StdLib/Lib/tkinter/test/support.py similarity index 100% rename from StdLib/Lib/tkinter/test/support.py rename to Src/StdLib/Lib/tkinter/test/support.py diff --git a/StdLib/Lib/tkinter/test/test_tkinter/__init__.py b/Src/StdLib/Lib/tkinter/test/test_tkinter/__init__.py similarity index 100% rename from StdLib/Lib/tkinter/test/test_tkinter/__init__.py rename to Src/StdLib/Lib/tkinter/test/test_tkinter/__init__.py diff --git a/StdLib/Lib/tkinter/test/test_tkinter/test_font.py b/Src/StdLib/Lib/tkinter/test/test_tkinter/test_font.py similarity index 100% rename from StdLib/Lib/tkinter/test/test_tkinter/test_font.py rename to Src/StdLib/Lib/tkinter/test/test_tkinter/test_font.py diff --git a/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py b/Src/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py similarity index 100% rename from StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py rename to Src/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py diff --git a/StdLib/Lib/tkinter/test/test_tkinter/test_images.py b/Src/StdLib/Lib/tkinter/test/test_tkinter/test_images.py similarity index 100% rename from StdLib/Lib/tkinter/test/test_tkinter/test_images.py rename to Src/StdLib/Lib/tkinter/test/test_tkinter/test_images.py diff --git a/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py b/Src/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py similarity index 100% rename from StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py rename to Src/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py diff --git a/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py b/Src/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py similarity index 100% rename from StdLib/Lib/tkinter/test/test_tkinter/test_misc.py rename to Src/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py diff --git a/StdLib/Lib/tkinter/test/test_tkinter/test_text.py b/Src/StdLib/Lib/tkinter/test/test_tkinter/test_text.py similarity index 100% rename from StdLib/Lib/tkinter/test/test_tkinter/test_text.py rename to Src/StdLib/Lib/tkinter/test/test_tkinter/test_text.py diff --git a/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py b/Src/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py similarity index 100% rename from StdLib/Lib/tkinter/test/test_tkinter/test_variables.py rename to Src/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py diff --git a/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py b/Src/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py similarity index 100% rename from StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py rename to Src/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py diff --git a/StdLib/Lib/tkinter/test/test_ttk/__init__.py b/Src/StdLib/Lib/tkinter/test/test_ttk/__init__.py similarity index 100% rename from StdLib/Lib/tkinter/test/test_ttk/__init__.py rename to Src/StdLib/Lib/tkinter/test/test_ttk/__init__.py diff --git a/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py b/Src/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py similarity index 100% rename from StdLib/Lib/tkinter/test/test_ttk/test_extensions.py rename to Src/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py diff --git a/StdLib/Lib/tkinter/test/test_ttk/test_functions.py b/Src/StdLib/Lib/tkinter/test/test_ttk/test_functions.py similarity index 100% rename from StdLib/Lib/tkinter/test/test_ttk/test_functions.py rename to Src/StdLib/Lib/tkinter/test/test_ttk/test_functions.py diff --git a/StdLib/Lib/tkinter/test/test_ttk/test_style.py b/Src/StdLib/Lib/tkinter/test/test_ttk/test_style.py similarity index 100% rename from StdLib/Lib/tkinter/test/test_ttk/test_style.py rename to Src/StdLib/Lib/tkinter/test/test_ttk/test_style.py diff --git a/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py b/Src/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py similarity index 100% rename from StdLib/Lib/tkinter/test/test_ttk/test_widgets.py rename to Src/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py diff --git a/StdLib/Lib/tkinter/test/widget_tests.py b/Src/StdLib/Lib/tkinter/test/widget_tests.py similarity index 100% rename from StdLib/Lib/tkinter/test/widget_tests.py rename to Src/StdLib/Lib/tkinter/test/widget_tests.py diff --git a/StdLib/Lib/tkinter/tix.py b/Src/StdLib/Lib/tkinter/tix.py similarity index 100% rename from StdLib/Lib/tkinter/tix.py rename to Src/StdLib/Lib/tkinter/tix.py diff --git a/StdLib/Lib/tkinter/ttk.py b/Src/StdLib/Lib/tkinter/ttk.py similarity index 100% rename from StdLib/Lib/tkinter/ttk.py rename to Src/StdLib/Lib/tkinter/ttk.py diff --git a/StdLib/Lib/token.py b/Src/StdLib/Lib/token.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/token.py rename to Src/StdLib/Lib/token.py diff --git a/StdLib/Lib/tokenize.py b/Src/StdLib/Lib/tokenize.py similarity index 100% rename from StdLib/Lib/tokenize.py rename to Src/StdLib/Lib/tokenize.py diff --git a/StdLib/Lib/trace.py b/Src/StdLib/Lib/trace.py similarity index 100% rename from StdLib/Lib/trace.py rename to Src/StdLib/Lib/trace.py diff --git a/StdLib/Lib/traceback.py b/Src/StdLib/Lib/traceback.py similarity index 100% rename from StdLib/Lib/traceback.py rename to Src/StdLib/Lib/traceback.py diff --git a/StdLib/Lib/tracemalloc.py b/Src/StdLib/Lib/tracemalloc.py similarity index 100% rename from StdLib/Lib/tracemalloc.py rename to Src/StdLib/Lib/tracemalloc.py diff --git a/StdLib/Lib/tty.py b/Src/StdLib/Lib/tty.py similarity index 100% rename from StdLib/Lib/tty.py rename to Src/StdLib/Lib/tty.py diff --git a/StdLib/Lib/turtle.py b/Src/StdLib/Lib/turtle.py similarity index 100% rename from StdLib/Lib/turtle.py rename to Src/StdLib/Lib/turtle.py diff --git a/StdLib/Lib/turtledemo/__init__.py b/Src/StdLib/Lib/turtledemo/__init__.py similarity index 100% rename from StdLib/Lib/turtledemo/__init__.py rename to Src/StdLib/Lib/turtledemo/__init__.py diff --git a/StdLib/Lib/turtledemo/__main__.py b/Src/StdLib/Lib/turtledemo/__main__.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/turtledemo/__main__.py rename to Src/StdLib/Lib/turtledemo/__main__.py diff --git a/StdLib/Lib/turtledemo/bytedesign.py b/Src/StdLib/Lib/turtledemo/bytedesign.py similarity index 100% rename from StdLib/Lib/turtledemo/bytedesign.py rename to Src/StdLib/Lib/turtledemo/bytedesign.py diff --git a/StdLib/Lib/turtledemo/chaos.py b/Src/StdLib/Lib/turtledemo/chaos.py similarity index 100% rename from StdLib/Lib/turtledemo/chaos.py rename to Src/StdLib/Lib/turtledemo/chaos.py diff --git a/StdLib/Lib/turtledemo/clock.py b/Src/StdLib/Lib/turtledemo/clock.py similarity index 100% rename from StdLib/Lib/turtledemo/clock.py rename to Src/StdLib/Lib/turtledemo/clock.py diff --git a/StdLib/Lib/turtledemo/colormixer.py b/Src/StdLib/Lib/turtledemo/colormixer.py similarity index 100% rename from StdLib/Lib/turtledemo/colormixer.py rename to Src/StdLib/Lib/turtledemo/colormixer.py diff --git a/StdLib/Lib/turtledemo/forest.py b/Src/StdLib/Lib/turtledemo/forest.py similarity index 100% rename from StdLib/Lib/turtledemo/forest.py rename to Src/StdLib/Lib/turtledemo/forest.py diff --git a/StdLib/Lib/turtledemo/fractalcurves.py b/Src/StdLib/Lib/turtledemo/fractalcurves.py similarity index 100% rename from StdLib/Lib/turtledemo/fractalcurves.py rename to Src/StdLib/Lib/turtledemo/fractalcurves.py diff --git a/StdLib/Lib/turtledemo/lindenmayer.py b/Src/StdLib/Lib/turtledemo/lindenmayer.py similarity index 100% rename from StdLib/Lib/turtledemo/lindenmayer.py rename to Src/StdLib/Lib/turtledemo/lindenmayer.py diff --git a/StdLib/Lib/turtledemo/minimal_hanoi.py b/Src/StdLib/Lib/turtledemo/minimal_hanoi.py similarity index 100% rename from StdLib/Lib/turtledemo/minimal_hanoi.py rename to Src/StdLib/Lib/turtledemo/minimal_hanoi.py diff --git a/StdLib/Lib/turtledemo/nim.py b/Src/StdLib/Lib/turtledemo/nim.py similarity index 100% rename from StdLib/Lib/turtledemo/nim.py rename to Src/StdLib/Lib/turtledemo/nim.py diff --git a/StdLib/Lib/turtledemo/paint.py b/Src/StdLib/Lib/turtledemo/paint.py similarity index 100% rename from StdLib/Lib/turtledemo/paint.py rename to Src/StdLib/Lib/turtledemo/paint.py diff --git a/StdLib/Lib/turtledemo/peace.py b/Src/StdLib/Lib/turtledemo/peace.py similarity index 100% rename from StdLib/Lib/turtledemo/peace.py rename to Src/StdLib/Lib/turtledemo/peace.py diff --git a/StdLib/Lib/turtledemo/penrose.py b/Src/StdLib/Lib/turtledemo/penrose.py similarity index 100% rename from StdLib/Lib/turtledemo/penrose.py rename to Src/StdLib/Lib/turtledemo/penrose.py diff --git a/StdLib/Lib/turtledemo/planet_and_moon.py b/Src/StdLib/Lib/turtledemo/planet_and_moon.py similarity index 100% rename from StdLib/Lib/turtledemo/planet_and_moon.py rename to Src/StdLib/Lib/turtledemo/planet_and_moon.py diff --git a/StdLib/Lib/turtledemo/round_dance.py b/Src/StdLib/Lib/turtledemo/round_dance.py similarity index 100% rename from StdLib/Lib/turtledemo/round_dance.py rename to Src/StdLib/Lib/turtledemo/round_dance.py diff --git a/StdLib/Lib/turtledemo/tree.py b/Src/StdLib/Lib/turtledemo/tree.py similarity index 100% rename from StdLib/Lib/turtledemo/tree.py rename to Src/StdLib/Lib/turtledemo/tree.py diff --git a/StdLib/Lib/turtledemo/turtle.cfg b/Src/StdLib/Lib/turtledemo/turtle.cfg similarity index 100% rename from StdLib/Lib/turtledemo/turtle.cfg rename to Src/StdLib/Lib/turtledemo/turtle.cfg diff --git a/StdLib/Lib/turtledemo/two_canvases.py b/Src/StdLib/Lib/turtledemo/two_canvases.py similarity index 100% rename from StdLib/Lib/turtledemo/two_canvases.py rename to Src/StdLib/Lib/turtledemo/two_canvases.py diff --git a/StdLib/Lib/turtledemo/wikipedia.py b/Src/StdLib/Lib/turtledemo/wikipedia.py similarity index 100% rename from StdLib/Lib/turtledemo/wikipedia.py rename to Src/StdLib/Lib/turtledemo/wikipedia.py diff --git a/StdLib/Lib/turtledemo/yinyang.py b/Src/StdLib/Lib/turtledemo/yinyang.py similarity index 100% rename from StdLib/Lib/turtledemo/yinyang.py rename to Src/StdLib/Lib/turtledemo/yinyang.py diff --git a/StdLib/Lib/types.py b/Src/StdLib/Lib/types.py similarity index 100% rename from StdLib/Lib/types.py rename to Src/StdLib/Lib/types.py diff --git a/StdLib/Lib/typing.py b/Src/StdLib/Lib/typing.py similarity index 100% rename from StdLib/Lib/typing.py rename to Src/StdLib/Lib/typing.py diff --git a/StdLib/Lib/unittest/__init__.py b/Src/StdLib/Lib/unittest/__init__.py similarity index 100% rename from StdLib/Lib/unittest/__init__.py rename to Src/StdLib/Lib/unittest/__init__.py diff --git a/StdLib/Lib/unittest/__main__.py b/Src/StdLib/Lib/unittest/__main__.py similarity index 100% rename from StdLib/Lib/unittest/__main__.py rename to Src/StdLib/Lib/unittest/__main__.py diff --git a/StdLib/Lib/unittest/case.py b/Src/StdLib/Lib/unittest/case.py similarity index 100% rename from StdLib/Lib/unittest/case.py rename to Src/StdLib/Lib/unittest/case.py diff --git a/StdLib/Lib/unittest/loader.py b/Src/StdLib/Lib/unittest/loader.py similarity index 100% rename from StdLib/Lib/unittest/loader.py rename to Src/StdLib/Lib/unittest/loader.py diff --git a/StdLib/Lib/unittest/main.py b/Src/StdLib/Lib/unittest/main.py similarity index 100% rename from StdLib/Lib/unittest/main.py rename to Src/StdLib/Lib/unittest/main.py diff --git a/StdLib/Lib/unittest/mock.py b/Src/StdLib/Lib/unittest/mock.py similarity index 100% rename from StdLib/Lib/unittest/mock.py rename to Src/StdLib/Lib/unittest/mock.py diff --git a/StdLib/Lib/unittest/result.py b/Src/StdLib/Lib/unittest/result.py similarity index 100% rename from StdLib/Lib/unittest/result.py rename to Src/StdLib/Lib/unittest/result.py diff --git a/StdLib/Lib/unittest/runner.py b/Src/StdLib/Lib/unittest/runner.py similarity index 100% rename from StdLib/Lib/unittest/runner.py rename to Src/StdLib/Lib/unittest/runner.py diff --git a/StdLib/Lib/unittest/signals.py b/Src/StdLib/Lib/unittest/signals.py similarity index 100% rename from StdLib/Lib/unittest/signals.py rename to Src/StdLib/Lib/unittest/signals.py diff --git a/StdLib/Lib/unittest/suite.py b/Src/StdLib/Lib/unittest/suite.py similarity index 100% rename from StdLib/Lib/unittest/suite.py rename to Src/StdLib/Lib/unittest/suite.py diff --git a/StdLib/Lib/unittest/test/__init__.py b/Src/StdLib/Lib/unittest/test/__init__.py similarity index 100% rename from StdLib/Lib/unittest/test/__init__.py rename to Src/StdLib/Lib/unittest/test/__init__.py diff --git a/StdLib/Lib/unittest/test/__main__.py b/Src/StdLib/Lib/unittest/test/__main__.py similarity index 100% rename from StdLib/Lib/unittest/test/__main__.py rename to Src/StdLib/Lib/unittest/test/__main__.py diff --git a/StdLib/Lib/unittest/test/_test_warnings.py b/Src/StdLib/Lib/unittest/test/_test_warnings.py similarity index 100% rename from StdLib/Lib/unittest/test/_test_warnings.py rename to Src/StdLib/Lib/unittest/test/_test_warnings.py diff --git a/StdLib/Lib/unittest/test/dummy.py b/Src/StdLib/Lib/unittest/test/dummy.py similarity index 100% rename from StdLib/Lib/unittest/test/dummy.py rename to Src/StdLib/Lib/unittest/test/dummy.py diff --git a/StdLib/Lib/unittest/test/support.py b/Src/StdLib/Lib/unittest/test/support.py similarity index 100% rename from StdLib/Lib/unittest/test/support.py rename to Src/StdLib/Lib/unittest/test/support.py diff --git a/StdLib/Lib/unittest/test/test_assertions.py b/Src/StdLib/Lib/unittest/test/test_assertions.py similarity index 100% rename from StdLib/Lib/unittest/test/test_assertions.py rename to Src/StdLib/Lib/unittest/test/test_assertions.py diff --git a/StdLib/Lib/unittest/test/test_break.py b/Src/StdLib/Lib/unittest/test/test_break.py similarity index 100% rename from StdLib/Lib/unittest/test/test_break.py rename to Src/StdLib/Lib/unittest/test/test_break.py diff --git a/StdLib/Lib/unittest/test/test_case.py b/Src/StdLib/Lib/unittest/test/test_case.py similarity index 100% rename from StdLib/Lib/unittest/test/test_case.py rename to Src/StdLib/Lib/unittest/test/test_case.py diff --git a/StdLib/Lib/unittest/test/test_discovery.py b/Src/StdLib/Lib/unittest/test/test_discovery.py similarity index 100% rename from StdLib/Lib/unittest/test/test_discovery.py rename to Src/StdLib/Lib/unittest/test/test_discovery.py diff --git a/StdLib/Lib/unittest/test/test_functiontestcase.py b/Src/StdLib/Lib/unittest/test/test_functiontestcase.py similarity index 100% rename from StdLib/Lib/unittest/test/test_functiontestcase.py rename to Src/StdLib/Lib/unittest/test/test_functiontestcase.py diff --git a/StdLib/Lib/unittest/test/test_loader.py b/Src/StdLib/Lib/unittest/test/test_loader.py similarity index 100% rename from StdLib/Lib/unittest/test/test_loader.py rename to Src/StdLib/Lib/unittest/test/test_loader.py diff --git a/StdLib/Lib/unittest/test/test_program.py b/Src/StdLib/Lib/unittest/test/test_program.py similarity index 100% rename from StdLib/Lib/unittest/test/test_program.py rename to Src/StdLib/Lib/unittest/test/test_program.py diff --git a/StdLib/Lib/unittest/test/test_result.py b/Src/StdLib/Lib/unittest/test/test_result.py similarity index 100% rename from StdLib/Lib/unittest/test/test_result.py rename to Src/StdLib/Lib/unittest/test/test_result.py diff --git a/StdLib/Lib/unittest/test/test_runner.py b/Src/StdLib/Lib/unittest/test/test_runner.py similarity index 100% rename from StdLib/Lib/unittest/test/test_runner.py rename to Src/StdLib/Lib/unittest/test/test_runner.py diff --git a/StdLib/Lib/unittest/test/test_setups.py b/Src/StdLib/Lib/unittest/test/test_setups.py similarity index 100% rename from StdLib/Lib/unittest/test/test_setups.py rename to Src/StdLib/Lib/unittest/test/test_setups.py diff --git a/StdLib/Lib/unittest/test/test_skipping.py b/Src/StdLib/Lib/unittest/test/test_skipping.py similarity index 100% rename from StdLib/Lib/unittest/test/test_skipping.py rename to Src/StdLib/Lib/unittest/test/test_skipping.py diff --git a/StdLib/Lib/unittest/test/test_suite.py b/Src/StdLib/Lib/unittest/test/test_suite.py similarity index 100% rename from StdLib/Lib/unittest/test/test_suite.py rename to Src/StdLib/Lib/unittest/test/test_suite.py diff --git a/StdLib/Lib/unittest/test/testmock/__init__.py b/Src/StdLib/Lib/unittest/test/testmock/__init__.py similarity index 100% rename from StdLib/Lib/unittest/test/testmock/__init__.py rename to Src/StdLib/Lib/unittest/test/testmock/__init__.py diff --git a/StdLib/Lib/unittest/test/testmock/__main__.py b/Src/StdLib/Lib/unittest/test/testmock/__main__.py similarity index 100% rename from StdLib/Lib/unittest/test/testmock/__main__.py rename to Src/StdLib/Lib/unittest/test/testmock/__main__.py diff --git a/StdLib/Lib/unittest/test/testmock/support.py b/Src/StdLib/Lib/unittest/test/testmock/support.py similarity index 100% rename from StdLib/Lib/unittest/test/testmock/support.py rename to Src/StdLib/Lib/unittest/test/testmock/support.py diff --git a/StdLib/Lib/unittest/test/testmock/testcallable.py b/Src/StdLib/Lib/unittest/test/testmock/testcallable.py similarity index 100% rename from StdLib/Lib/unittest/test/testmock/testcallable.py rename to Src/StdLib/Lib/unittest/test/testmock/testcallable.py diff --git a/StdLib/Lib/unittest/test/testmock/testhelpers.py b/Src/StdLib/Lib/unittest/test/testmock/testhelpers.py similarity index 100% rename from StdLib/Lib/unittest/test/testmock/testhelpers.py rename to Src/StdLib/Lib/unittest/test/testmock/testhelpers.py diff --git a/StdLib/Lib/unittest/test/testmock/testmagicmethods.py b/Src/StdLib/Lib/unittest/test/testmock/testmagicmethods.py similarity index 100% rename from StdLib/Lib/unittest/test/testmock/testmagicmethods.py rename to Src/StdLib/Lib/unittest/test/testmock/testmagicmethods.py diff --git a/StdLib/Lib/unittest/test/testmock/testmock.py b/Src/StdLib/Lib/unittest/test/testmock/testmock.py similarity index 100% rename from StdLib/Lib/unittest/test/testmock/testmock.py rename to Src/StdLib/Lib/unittest/test/testmock/testmock.py diff --git a/StdLib/Lib/unittest/test/testmock/testpatch.py b/Src/StdLib/Lib/unittest/test/testmock/testpatch.py similarity index 100% rename from StdLib/Lib/unittest/test/testmock/testpatch.py rename to Src/StdLib/Lib/unittest/test/testmock/testpatch.py diff --git a/StdLib/Lib/unittest/test/testmock/testsentinel.py b/Src/StdLib/Lib/unittest/test/testmock/testsentinel.py similarity index 100% rename from StdLib/Lib/unittest/test/testmock/testsentinel.py rename to Src/StdLib/Lib/unittest/test/testmock/testsentinel.py diff --git a/StdLib/Lib/unittest/test/testmock/testwith.py b/Src/StdLib/Lib/unittest/test/testmock/testwith.py similarity index 100% rename from StdLib/Lib/unittest/test/testmock/testwith.py rename to Src/StdLib/Lib/unittest/test/testmock/testwith.py diff --git a/StdLib/Lib/unittest/util.py b/Src/StdLib/Lib/unittest/util.py similarity index 100% rename from StdLib/Lib/unittest/util.py rename to Src/StdLib/Lib/unittest/util.py diff --git a/StdLib/Lib/urllib/__init__.py b/Src/StdLib/Lib/urllib/__init__.py similarity index 100% rename from StdLib/Lib/urllib/__init__.py rename to Src/StdLib/Lib/urllib/__init__.py diff --git a/StdLib/Lib/urllib/error.py b/Src/StdLib/Lib/urllib/error.py similarity index 100% rename from StdLib/Lib/urllib/error.py rename to Src/StdLib/Lib/urllib/error.py diff --git a/StdLib/Lib/urllib/parse.py b/Src/StdLib/Lib/urllib/parse.py similarity index 100% rename from StdLib/Lib/urllib/parse.py rename to Src/StdLib/Lib/urllib/parse.py diff --git a/StdLib/Lib/urllib/request.py b/Src/StdLib/Lib/urllib/request.py similarity index 100% rename from StdLib/Lib/urllib/request.py rename to Src/StdLib/Lib/urllib/request.py diff --git a/StdLib/Lib/urllib/response.py b/Src/StdLib/Lib/urllib/response.py similarity index 100% rename from StdLib/Lib/urllib/response.py rename to Src/StdLib/Lib/urllib/response.py diff --git a/StdLib/Lib/urllib/robotparser.py b/Src/StdLib/Lib/urllib/robotparser.py similarity index 100% rename from StdLib/Lib/urllib/robotparser.py rename to Src/StdLib/Lib/urllib/robotparser.py diff --git a/StdLib/Lib/uu.py b/Src/StdLib/Lib/uu.py old mode 100644 new mode 100755 similarity index 100% rename from StdLib/Lib/uu.py rename to Src/StdLib/Lib/uu.py diff --git a/StdLib/Lib/uuid.py b/Src/StdLib/Lib/uuid.py similarity index 100% rename from StdLib/Lib/uuid.py rename to Src/StdLib/Lib/uuid.py diff --git a/StdLib/Lib/venv/__init__.py b/Src/StdLib/Lib/venv/__init__.py similarity index 100% rename from StdLib/Lib/venv/__init__.py rename to Src/StdLib/Lib/venv/__init__.py diff --git a/StdLib/Lib/venv/__main__.py b/Src/StdLib/Lib/venv/__main__.py similarity index 100% rename from StdLib/Lib/venv/__main__.py rename to Src/StdLib/Lib/venv/__main__.py diff --git a/StdLib/Lib/venv/scripts/nt/Activate.ps1 b/Src/StdLib/Lib/venv/scripts/nt/Activate.ps1 similarity index 100% rename from StdLib/Lib/venv/scripts/nt/Activate.ps1 rename to Src/StdLib/Lib/venv/scripts/nt/Activate.ps1 diff --git a/StdLib/Lib/venv/scripts/nt/activate.bat b/Src/StdLib/Lib/venv/scripts/nt/activate.bat similarity index 100% rename from StdLib/Lib/venv/scripts/nt/activate.bat rename to Src/StdLib/Lib/venv/scripts/nt/activate.bat diff --git a/StdLib/Lib/venv/scripts/nt/deactivate.bat b/Src/StdLib/Lib/venv/scripts/nt/deactivate.bat similarity index 100% rename from StdLib/Lib/venv/scripts/nt/deactivate.bat rename to Src/StdLib/Lib/venv/scripts/nt/deactivate.bat diff --git a/StdLib/Lib/venv/scripts/posix/activate b/Src/StdLib/Lib/venv/scripts/posix/activate similarity index 100% rename from StdLib/Lib/venv/scripts/posix/activate rename to Src/StdLib/Lib/venv/scripts/posix/activate diff --git a/StdLib/Lib/venv/scripts/posix/activate.csh b/Src/StdLib/Lib/venv/scripts/posix/activate.csh similarity index 100% rename from StdLib/Lib/venv/scripts/posix/activate.csh rename to Src/StdLib/Lib/venv/scripts/posix/activate.csh diff --git a/StdLib/Lib/venv/scripts/posix/activate.fish b/Src/StdLib/Lib/venv/scripts/posix/activate.fish similarity index 100% rename from StdLib/Lib/venv/scripts/posix/activate.fish rename to Src/StdLib/Lib/venv/scripts/posix/activate.fish diff --git a/StdLib/Lib/warnings.py b/Src/StdLib/Lib/warnings.py similarity index 100% rename from StdLib/Lib/warnings.py rename to Src/StdLib/Lib/warnings.py diff --git a/StdLib/Lib/wave.py b/Src/StdLib/Lib/wave.py similarity index 100% rename from StdLib/Lib/wave.py rename to Src/StdLib/Lib/wave.py diff --git a/StdLib/Lib/weakref.py b/Src/StdLib/Lib/weakref.py similarity index 100% rename from StdLib/Lib/weakref.py rename to Src/StdLib/Lib/weakref.py diff --git a/StdLib/Lib/webbrowser.py b/Src/StdLib/Lib/webbrowser.py similarity index 100% rename from StdLib/Lib/webbrowser.py rename to Src/StdLib/Lib/webbrowser.py diff --git a/StdLib/Lib/wpf.py b/Src/StdLib/Lib/wpf.py similarity index 100% rename from StdLib/Lib/wpf.py rename to Src/StdLib/Lib/wpf.py diff --git a/StdLib/Lib/wsgiref/__init__.py b/Src/StdLib/Lib/wsgiref/__init__.py similarity index 100% rename from StdLib/Lib/wsgiref/__init__.py rename to Src/StdLib/Lib/wsgiref/__init__.py diff --git a/StdLib/Lib/wsgiref/handlers.py b/Src/StdLib/Lib/wsgiref/handlers.py similarity index 100% rename from StdLib/Lib/wsgiref/handlers.py rename to Src/StdLib/Lib/wsgiref/handlers.py diff --git a/StdLib/Lib/wsgiref/headers.py b/Src/StdLib/Lib/wsgiref/headers.py similarity index 100% rename from StdLib/Lib/wsgiref/headers.py rename to Src/StdLib/Lib/wsgiref/headers.py diff --git a/StdLib/Lib/wsgiref/simple_server.py b/Src/StdLib/Lib/wsgiref/simple_server.py similarity index 100% rename from StdLib/Lib/wsgiref/simple_server.py rename to Src/StdLib/Lib/wsgiref/simple_server.py diff --git a/StdLib/Lib/wsgiref/util.py b/Src/StdLib/Lib/wsgiref/util.py similarity index 100% rename from StdLib/Lib/wsgiref/util.py rename to Src/StdLib/Lib/wsgiref/util.py diff --git a/StdLib/Lib/wsgiref/validate.py b/Src/StdLib/Lib/wsgiref/validate.py similarity index 100% rename from StdLib/Lib/wsgiref/validate.py rename to Src/StdLib/Lib/wsgiref/validate.py diff --git a/StdLib/Lib/xdrlib.py b/Src/StdLib/Lib/xdrlib.py similarity index 100% rename from StdLib/Lib/xdrlib.py rename to Src/StdLib/Lib/xdrlib.py diff --git a/StdLib/Lib/xml/__init__.py b/Src/StdLib/Lib/xml/__init__.py similarity index 100% rename from StdLib/Lib/xml/__init__.py rename to Src/StdLib/Lib/xml/__init__.py diff --git a/StdLib/Lib/xml/dom/NodeFilter.py b/Src/StdLib/Lib/xml/dom/NodeFilter.py similarity index 100% rename from StdLib/Lib/xml/dom/NodeFilter.py rename to Src/StdLib/Lib/xml/dom/NodeFilter.py diff --git a/StdLib/Lib/xml/dom/__init__.py b/Src/StdLib/Lib/xml/dom/__init__.py similarity index 100% rename from StdLib/Lib/xml/dom/__init__.py rename to Src/StdLib/Lib/xml/dom/__init__.py diff --git a/StdLib/Lib/xml/dom/domreg.py b/Src/StdLib/Lib/xml/dom/domreg.py similarity index 100% rename from StdLib/Lib/xml/dom/domreg.py rename to Src/StdLib/Lib/xml/dom/domreg.py diff --git a/StdLib/Lib/xml/dom/expatbuilder.py b/Src/StdLib/Lib/xml/dom/expatbuilder.py similarity index 100% rename from StdLib/Lib/xml/dom/expatbuilder.py rename to Src/StdLib/Lib/xml/dom/expatbuilder.py diff --git a/StdLib/Lib/xml/dom/minicompat.py b/Src/StdLib/Lib/xml/dom/minicompat.py similarity index 100% rename from StdLib/Lib/xml/dom/minicompat.py rename to Src/StdLib/Lib/xml/dom/minicompat.py diff --git a/StdLib/Lib/xml/dom/minidom.py b/Src/StdLib/Lib/xml/dom/minidom.py similarity index 100% rename from StdLib/Lib/xml/dom/minidom.py rename to Src/StdLib/Lib/xml/dom/minidom.py diff --git a/StdLib/Lib/xml/dom/pulldom.py b/Src/StdLib/Lib/xml/dom/pulldom.py similarity index 100% rename from StdLib/Lib/xml/dom/pulldom.py rename to Src/StdLib/Lib/xml/dom/pulldom.py diff --git a/StdLib/Lib/xml/dom/xmlbuilder.py b/Src/StdLib/Lib/xml/dom/xmlbuilder.py similarity index 100% rename from StdLib/Lib/xml/dom/xmlbuilder.py rename to Src/StdLib/Lib/xml/dom/xmlbuilder.py diff --git a/StdLib/Lib/xml/etree/ElementInclude.py b/Src/StdLib/Lib/xml/etree/ElementInclude.py similarity index 100% rename from StdLib/Lib/xml/etree/ElementInclude.py rename to Src/StdLib/Lib/xml/etree/ElementInclude.py diff --git a/StdLib/Lib/xml/etree/ElementPath.py b/Src/StdLib/Lib/xml/etree/ElementPath.py similarity index 100% rename from StdLib/Lib/xml/etree/ElementPath.py rename to Src/StdLib/Lib/xml/etree/ElementPath.py diff --git a/StdLib/Lib/xml/etree/ElementTree.py b/Src/StdLib/Lib/xml/etree/ElementTree.py similarity index 100% rename from StdLib/Lib/xml/etree/ElementTree.py rename to Src/StdLib/Lib/xml/etree/ElementTree.py diff --git a/StdLib/Lib/xml/etree/__init__.py b/Src/StdLib/Lib/xml/etree/__init__.py similarity index 100% rename from StdLib/Lib/xml/etree/__init__.py rename to Src/StdLib/Lib/xml/etree/__init__.py diff --git a/StdLib/Lib/xml/etree/cElementTree.py b/Src/StdLib/Lib/xml/etree/cElementTree.py similarity index 100% rename from StdLib/Lib/xml/etree/cElementTree.py rename to Src/StdLib/Lib/xml/etree/cElementTree.py diff --git a/StdLib/Lib/xml/parsers/__init__.py b/Src/StdLib/Lib/xml/parsers/__init__.py similarity index 100% rename from StdLib/Lib/xml/parsers/__init__.py rename to Src/StdLib/Lib/xml/parsers/__init__.py diff --git a/StdLib/Lib/xml/parsers/expat.py b/Src/StdLib/Lib/xml/parsers/expat.py similarity index 100% rename from StdLib/Lib/xml/parsers/expat.py rename to Src/StdLib/Lib/xml/parsers/expat.py diff --git a/StdLib/Lib/xml/sax/__init__.py b/Src/StdLib/Lib/xml/sax/__init__.py similarity index 100% rename from StdLib/Lib/xml/sax/__init__.py rename to Src/StdLib/Lib/xml/sax/__init__.py diff --git a/StdLib/Lib/xml/sax/_exceptions.py b/Src/StdLib/Lib/xml/sax/_exceptions.py similarity index 100% rename from StdLib/Lib/xml/sax/_exceptions.py rename to Src/StdLib/Lib/xml/sax/_exceptions.py diff --git a/StdLib/Lib/xml/sax/expatreader.py b/Src/StdLib/Lib/xml/sax/expatreader.py similarity index 100% rename from StdLib/Lib/xml/sax/expatreader.py rename to Src/StdLib/Lib/xml/sax/expatreader.py diff --git a/StdLib/Lib/xml/sax/handler.py b/Src/StdLib/Lib/xml/sax/handler.py similarity index 100% rename from StdLib/Lib/xml/sax/handler.py rename to Src/StdLib/Lib/xml/sax/handler.py diff --git a/StdLib/Lib/xml/sax/saxutils.py b/Src/StdLib/Lib/xml/sax/saxutils.py similarity index 100% rename from StdLib/Lib/xml/sax/saxutils.py rename to Src/StdLib/Lib/xml/sax/saxutils.py diff --git a/StdLib/Lib/xml/sax/xmlreader.py b/Src/StdLib/Lib/xml/sax/xmlreader.py similarity index 100% rename from StdLib/Lib/xml/sax/xmlreader.py rename to Src/StdLib/Lib/xml/sax/xmlreader.py diff --git a/StdLib/Lib/xmlrpc/__init__.py b/Src/StdLib/Lib/xmlrpc/__init__.py similarity index 100% rename from StdLib/Lib/xmlrpc/__init__.py rename to Src/StdLib/Lib/xmlrpc/__init__.py diff --git a/StdLib/Lib/xmlrpc/client.py b/Src/StdLib/Lib/xmlrpc/client.py similarity index 100% rename from StdLib/Lib/xmlrpc/client.py rename to Src/StdLib/Lib/xmlrpc/client.py diff --git a/StdLib/Lib/xmlrpc/server.py b/Src/StdLib/Lib/xmlrpc/server.py similarity index 100% rename from StdLib/Lib/xmlrpc/server.py rename to Src/StdLib/Lib/xmlrpc/server.py diff --git a/StdLib/Lib/zipfile.py b/Src/StdLib/Lib/zipfile.py similarity index 100% rename from StdLib/Lib/zipfile.py rename to Src/StdLib/Lib/zipfile.py diff --git a/StdLib/StdLib.License.txt b/Src/StdLib/StdLib.License.txt similarity index 100% rename from StdLib/StdLib.License.txt rename to Src/StdLib/StdLib.License.txt diff --git a/StdLib/StdLib.pyproj b/Src/StdLib/StdLib.pyproj similarity index 100% rename from StdLib/StdLib.pyproj rename to Src/StdLib/StdLib.pyproj diff --git a/StdLib/stdlib-upgrade.txt b/Src/StdLib/stdlib-upgrade.txt similarity index 100% rename from StdLib/stdlib-upgrade.txt rename to Src/StdLib/stdlib-upgrade.txt diff --git a/StdLib/update-stdlib.cmd b/Src/StdLib/update-stdlib.cmd similarity index 100% rename from StdLib/update-stdlib.cmd rename to Src/StdLib/update-stdlib.cmd diff --git a/StdLib/update-stdlib.sh b/Src/StdLib/update-stdlib.sh old mode 100644 new mode 100755 similarity index 100% rename from StdLib/update-stdlib.sh rename to Src/StdLib/update-stdlib.sh diff --git a/Tests/AssemblyInfo.cs b/Src/Tests/AssemblyInfo.cs similarity index 100% rename from Tests/AssemblyInfo.cs rename to Src/Tests/AssemblyInfo.cs diff --git a/Tests/AttrInjectorTest.cs b/Src/Tests/AttrInjectorTest.cs similarity index 100% rename from Tests/AttrInjectorTest.cs rename to Src/Tests/AttrInjectorTest.cs diff --git a/Tests/BindTest.cs b/Src/Tests/BindTest.cs similarity index 100% rename from Tests/BindTest.cs rename to Src/Tests/BindTest.cs diff --git a/Tests/BinderTest.cs b/Src/Tests/BinderTest.cs similarity index 100% rename from Tests/BinderTest.cs rename to Src/Tests/BinderTest.cs diff --git a/Tests/Cases/CPythonCases.cs b/Src/Tests/Cases/CPythonCases.cs similarity index 100% rename from Tests/Cases/CPythonCases.cs rename to Src/Tests/Cases/CPythonCases.cs diff --git a/Tests/Cases/CPythonCasesManifest.ini b/Src/Tests/Cases/CPythonCasesManifest.ini similarity index 100% rename from Tests/Cases/CPythonCasesManifest.ini rename to Src/Tests/Cases/CPythonCasesManifest.ini diff --git a/Tests/Cases/CaseExecuter.cs b/Src/Tests/Cases/CaseExecuter.cs similarity index 100% rename from Tests/Cases/CaseExecuter.cs rename to Src/Tests/Cases/CaseExecuter.cs diff --git a/Tests/Cases/CaseGenerator.cs b/Src/Tests/Cases/CaseGenerator.cs similarity index 100% rename from Tests/Cases/CaseGenerator.cs rename to Src/Tests/Cases/CaseGenerator.cs diff --git a/Tests/Cases/CommonCases.cs b/Src/Tests/Cases/CommonCases.cs similarity index 100% rename from Tests/Cases/CommonCases.cs rename to Src/Tests/Cases/CommonCases.cs diff --git a/Tests/Cases/IronPythonCases.cs b/Src/Tests/Cases/IronPythonCases.cs similarity index 100% rename from Tests/Cases/IronPythonCases.cs rename to Src/Tests/Cases/IronPythonCases.cs diff --git a/Tests/Cases/IronPythonCasesManifest.ini b/Src/Tests/Cases/IronPythonCasesManifest.ini similarity index 100% rename from Tests/Cases/IronPythonCasesManifest.ini rename to Src/Tests/Cases/IronPythonCasesManifest.ini diff --git a/Tests/ClrType.cs b/Src/Tests/ClrType.cs similarity index 100% rename from Tests/ClrType.cs rename to Src/Tests/ClrType.cs diff --git a/Tests/Cmplx.cs b/Src/Tests/Cmplx.cs similarity index 100% rename from Tests/Cmplx.cs rename to Src/Tests/Cmplx.cs diff --git a/Tests/Conversions.cs b/Src/Tests/Conversions.cs similarity index 100% rename from Tests/Conversions.cs rename to Src/Tests/Conversions.cs diff --git a/Tests/DeTest.cs b/Src/Tests/DeTest.cs similarity index 100% rename from Tests/DeTest.cs rename to Src/Tests/DeTest.cs diff --git a/Tests/DelegateTest.cs b/Src/Tests/DelegateTest.cs similarity index 100% rename from Tests/DelegateTest.cs rename to Src/Tests/DelegateTest.cs diff --git a/Tests/DynamicRegressions.cs b/Src/Tests/DynamicRegressions.cs similarity index 100% rename from Tests/DynamicRegressions.cs rename to Src/Tests/DynamicRegressions.cs diff --git a/Tests/EncodingTest.cs b/Src/Tests/EncodingTest.cs similarity index 100% rename from Tests/EncodingTest.cs rename to Src/Tests/EncodingTest.cs diff --git a/Tests/EngineTest.cs b/Src/Tests/EngineTest.cs similarity index 100% rename from Tests/EngineTest.cs rename to Src/Tests/EngineTest.cs diff --git a/Tests/Enums.cs b/Src/Tests/Enums.cs similarity index 100% rename from Tests/Enums.cs rename to Src/Tests/Enums.cs diff --git a/Tests/Events.cs b/Src/Tests/Events.cs similarity index 100% rename from Tests/Events.cs rename to Src/Tests/Events.cs diff --git a/Tests/ExceptionConverter.cs b/Src/Tests/ExceptionConverter.cs similarity index 100% rename from Tests/ExceptionConverter.cs rename to Src/Tests/ExceptionConverter.cs diff --git a/Tests/Exceptions.cs b/Src/Tests/Exceptions.cs similarity index 100% rename from Tests/Exceptions.cs rename to Src/Tests/Exceptions.cs diff --git a/Tests/Explicit.cs b/Src/Tests/Explicit.cs similarity index 100% rename from Tests/Explicit.cs rename to Src/Tests/Explicit.cs diff --git a/Tests/ExtensionMethodTest.cs b/Src/Tests/ExtensionMethodTest.cs similarity index 100% rename from Tests/ExtensionMethodTest.cs rename to Src/Tests/ExtensionMethodTest.cs diff --git a/Tests/GenMeth.cs b/Src/Tests/GenMeth.cs similarity index 100% rename from Tests/GenMeth.cs rename to Src/Tests/GenMeth.cs diff --git a/Tests/Indexable.cs b/Src/Tests/Indexable.cs similarity index 100% rename from Tests/Indexable.cs rename to Src/Tests/Indexable.cs diff --git a/Tests/InheritTest.cs b/Src/Tests/InheritTest.cs similarity index 100% rename from Tests/InheritTest.cs rename to Src/Tests/InheritTest.cs diff --git a/Tests/IntegerTest.cs b/Src/Tests/IntegerTest.cs similarity index 100% rename from Tests/IntegerTest.cs rename to Src/Tests/IntegerTest.cs diff --git a/Tests/IronMath.cs b/Src/Tests/IronMath.cs similarity index 100% rename from Tests/IronMath.cs rename to Src/Tests/IronMath.cs diff --git a/Tests/IronPython.Tests.csproj b/Src/Tests/IronPython.Tests.csproj similarity index 100% rename from Tests/IronPython.Tests.csproj rename to Src/Tests/IronPython.Tests.csproj diff --git a/Tests/LoadTest.cs b/Src/Tests/LoadTest.cs similarity index 100% rename from Tests/LoadTest.cs rename to Src/Tests/LoadTest.cs diff --git a/Tests/MemberMappingTests.cs b/Src/Tests/MemberMappingTests.cs similarity index 100% rename from Tests/MemberMappingTests.cs rename to Src/Tests/MemberMappingTests.cs diff --git a/Tests/MemberOverloadTest.cs b/Src/Tests/MemberOverloadTest.cs similarity index 100% rename from Tests/MemberOverloadTest.cs rename to Src/Tests/MemberOverloadTest.cs diff --git a/Tests/MethodParametersStubs.cs b/Src/Tests/MethodParametersStubs.cs similarity index 100% rename from Tests/MethodParametersStubs.cs rename to Src/Tests/MethodParametersStubs.cs diff --git a/Tests/NestedClass.cs b/Src/Tests/NestedClass.cs similarity index 100% rename from Tests/NestedClass.cs rename to Src/Tests/NestedClass.cs diff --git a/Tests/NullableTest.cs b/Src/Tests/NullableTest.cs similarity index 100% rename from Tests/NullableTest.cs rename to Src/Tests/NullableTest.cs diff --git a/Tests/OperatorTest.cs b/Src/Tests/OperatorTest.cs similarity index 100% rename from Tests/OperatorTest.cs rename to Src/Tests/OperatorTest.cs diff --git a/Tests/ProtocolTest.cs b/Src/Tests/ProtocolTest.cs similarity index 100% rename from Tests/ProtocolTest.cs rename to Src/Tests/ProtocolTest.cs diff --git a/Tests/StaticTest.cs b/Src/Tests/StaticTest.cs similarity index 100% rename from Tests/StaticTest.cs rename to Src/Tests/StaticTest.cs diff --git a/Tests/Stress/Engine.cs b/Src/Tests/Stress/Engine.cs similarity index 100% rename from Tests/Stress/Engine.cs rename to Src/Tests/Stress/Engine.cs diff --git a/Tests/StringDictionaryStorage.cs b/Src/Tests/StringDictionaryStorage.cs similarity index 100% rename from Tests/StringDictionaryStorage.cs rename to Src/Tests/StringDictionaryStorage.cs diff --git a/Tests/TestBuiltinModule.cs b/Src/Tests/TestBuiltinModule.cs similarity index 100% rename from Tests/TestBuiltinModule.cs rename to Src/Tests/TestBuiltinModule.cs diff --git a/Tests/TypeDescriptor.cs b/Src/Tests/TypeDescriptor.cs similarity index 100% rename from Tests/TypeDescriptor.cs rename to Src/Tests/TypeDescriptor.cs diff --git a/Tests/Util/IniParser.cs b/Src/Tests/Util/IniParser.cs similarity index 100% rename from Tests/Util/IniParser.cs rename to Src/Tests/Util/IniParser.cs diff --git a/Tests/Util/TestManifest.cs b/Src/Tests/Util/TestManifest.cs similarity index 100% rename from Tests/Util/TestManifest.cs rename to Src/Tests/Util/TestManifest.cs diff --git a/Wpf/DynamicXamlReader.cs b/Src/Wpf/DynamicXamlReader.cs similarity index 100% rename from Wpf/DynamicXamlReader.cs rename to Src/Wpf/DynamicXamlReader.cs diff --git a/Wpf/IronPython.Wpf.csproj b/Src/Wpf/IronPython.Wpf.csproj similarity index 100% rename from Wpf/IronPython.Wpf.csproj rename to Src/Wpf/IronPython.Wpf.csproj diff --git a/Wpf/Properties/AssemblyInfo.cs b/Src/Wpf/Properties/AssemblyInfo.cs similarity index 100% rename from Wpf/Properties/AssemblyInfo.cs rename to Src/Wpf/Properties/AssemblyInfo.cs diff --git a/Wpf/_wpf.cs b/Src/Wpf/_wpf.cs similarity index 100% rename from Wpf/_wpf.cs rename to Src/Wpf/_wpf.cs From d851d71284b0aceb6deb787bcd3be746dc83b53f Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 17:09:37 +0000 Subject: [PATCH 13/84] Add DLR submodule This reverts commit a2c85dcd1fc816f58a7df3cdd087e24eab86d01d. --- .gitmodules | 4 ++++ Src/DLR | 1 + 2 files changed, 5 insertions(+) create mode 100644 .gitmodules create mode 160000 Src/DLR diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..5cd8e15d8 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "Src/DLR"] + path = Src/DLR + url = https://github.com/IronLanguages/dlr + branch = main diff --git a/Src/DLR b/Src/DLR new file mode 160000 index 000000000..fe26cf45d --- /dev/null +++ b/Src/DLR @@ -0,0 +1 @@ +Subproject commit fe26cf45d383be65a56f0d4b964644eff89e01a8 From a428c0d16573f5eb1cf99021ab31a005a1202096 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 17:18:03 +0000 Subject: [PATCH 14/84] Rename directories step 1 --- Package/deb/ipy | 1 - Package/deb/ipy3 | 1 - {Src => Src.GetRenamed}/App.Debug.config | 0 {Src => Src.GetRenamed}/App.Release.config | 0 {Src => Src.GetRenamed}/CTypes/Makefile | 0 {Src => Src.GetRenamed}/CTypes/_ctypes_test.c | 0 {Src => Src.GetRenamed}/CTypes/_ctypes_test.sln | 0 {Src => Src.GetRenamed}/CTypes/_ctypes_test.vcxproj | 0 .../CompilerServices/AssemblyResolver.cs | 0 {Src => Src.GetRenamed}/CompilerServices/Config.cs | 0 .../CompilerServices/ConsoleOps.cs | 0 .../IronPython.CompilerServices.csproj | 0 {Src => Src.GetRenamed}/CompilerServices/Program.cs | 0 .../CompilerServices/Properties/AssemblyInfo.cs | 0 {Src => Src.GetRenamed}/CompilerServices/README.md | 0 .../Console.Host/IronPython.Console.Host.csproj | 0 .../Console.Host/IronPythonWindow.cs | 0 .../Console.Host/Properties/AssemblyInfo.cs | 0 {Src => Src.GetRenamed}/Console.Host/ipyw.ico | Bin {Src => Src.GetRenamed}/Console/Console.cs | 0 .../Console/IronPython.Console.csproj | 0 .../Console/Properties/AssemblyInfo.cs | 0 {Src => Src.GetRenamed}/Console/app.manifest | 0 {Src => Src.GetRenamed}/Console/ipy-mono.sh | 0 {Src => Src.GetRenamed}/Console/ipy.ico | Bin {Src => Src.GetRenamed}/Console/ipy.sh | 0 .../Console/runtimeconfig.template.json | 0 .../Console32.Host/IronPython.Console32.Host.csproj | 0 .../Console32/IronPython.Console32.csproj | 0 .../DiagnosticAnalyzer}/Analyzer.cs | 0 .../DiagnosticAnalyzer}/Directory.Build.props | 0 .../IronPython.DiagnosticAnalyzer.csproj | 0 .../IronPython/Compiler/Ast/AndExpression.cs | 0 .../Compiler/Ast/AnnotatedAssignStatement.cs | 0 .../IronPython/Compiler/Ast/AssertStatement.cs | 0 .../IronPython/Compiler/Ast/AssignmentStatement.cs | 0 .../IronPython/Compiler/Ast/AstMethods.cs | 0 .../IronPython/Compiler/Ast/AsyncStatement.cs | 0 .../Compiler/Ast/AugmentedAssignStatement.cs | 0 .../Compiler/Ast/BinaryExpression.Generated.cs | 0 .../IronPython/Compiler/Ast/BinaryExpression.cs | 0 .../IronPython/Compiler/Ast/BreakStatement.cs | 0 .../IronPython/Compiler/Ast/CallExpression.cs | 0 .../IronPython/Compiler/Ast/ClassDefinition.cs | 0 .../IronPython/Compiler/Ast/Comprehension.cs | 0 .../IronPython/Compiler/Ast/ComprehensionFor.cs | 0 .../IronPython/Compiler/Ast/ComprehensionIf.cs | 0 .../Compiler/Ast/ConditionalExpression.cs | 0 .../IronPython/Compiler/Ast/ConstantExpression.cs | 0 .../IronPython/Compiler/Ast/ContinueStatement.cs | 0 .../IronPython/Compiler/Ast/DelStatement.cs | 0 .../IronPython/Compiler/Ast/DictionaryExpression.cs | 0 .../IronPython/Compiler/Ast/DottedName.cs | 0 .../Compiler/Ast/DynamicConvertExpression.cs | 0 .../Compiler/Ast/DynamicGetMemberExpression.cs | 0 .../IronPython/Compiler/Ast/EmptyStatement.cs | 0 .../IronPython/Compiler/Ast/ErrorExpression.cs | 0 .../IronPython/Compiler/Ast/Expression.cs | 0 .../IronPython/Compiler/Ast/ExpressionStatement.cs | 0 .../IronPython/Compiler/Ast/FlowChecker.cs | 0 .../IronPython/Compiler/Ast/ForStatement.cs | 0 .../Compiler/Ast/FormattedValueExpression.cs | 0 .../IronPython/Compiler/Ast/FromImportStatement.cs | 0 .../IronPython/Compiler/Ast/FunctionDefinition.cs | 0 .../IronPython/Compiler/Ast/GeneratorExpression.cs | 0 .../Compiler/Ast/GetGlobalContextExpression.cs | 0 .../Ast/GetParentContextFromFunctionExpression.cs | 0 .../IronPython/Compiler/Ast/GlobalStatement.cs | 0 .../IronPython/Compiler/Ast/ILoopStatement.cs | 0 .../IronPython/Compiler/Ast/IfStatement.cs | 0 .../IronPython/Compiler/Ast/IfStatementTest.cs | 0 .../IronPython/Compiler/Ast/ImportStatement.cs | 0 .../IronPython/Compiler/Ast/IndexExpression.cs | 0 .../Compiler/Ast/JoinedStringExpression.cs | 0 .../IronPython/Compiler/Ast/Keyword.cs | 0 .../IronPython/Compiler/Ast/LambdaExpression.cs | 0 .../IronPython/Compiler/Ast/ListExpression.cs | 0 .../IronPython/Compiler/Ast/MemberExpression.cs | 0 .../IronPython/Compiler/Ast/ModuleName.cs | 0 .../IronPython/Compiler/Ast/NameExpression.cs | 0 .../IronPython/Compiler/Ast/Node.cs | 0 .../IronPython/Compiler/Ast/NonlocalStatement.cs | 0 .../IronPython/Compiler/Ast/OrExpression.cs | 0 .../IronPython/Compiler/Ast/Parameter.cs | 0 .../Compiler/Ast/ParenthesisExpression.cs | 0 .../IronPython/Compiler/Ast/PythonAst.cs | 0 .../Compiler/Ast/PythonConstantExpression.cs | 0 .../IronPython/Compiler/Ast/PythonNameBinder.cs | 0 .../IronPython/Compiler/Ast/PythonReference.cs | 0 .../IronPython/Compiler/Ast/PythonVariable.cs | 0 .../Compiler/Ast/PythonWalker.Generated.cs | 0 .../IronPython/Compiler/Ast/RaiseStatement.cs | 0 .../IronPython/Compiler/Ast/RelativeModuleName.cs | 0 .../IronPython/Compiler/Ast/ReturnStatement.cs | 0 .../IronPython/Compiler/Ast/ScopeStatement.cs | 0 .../IronPython/Compiler/Ast/SequenceExpression.cs | 0 .../Compiler/Ast/SerializedScopeStatement.cs | 0 .../IronPython/Compiler/Ast/SetExpression.cs | 0 .../IronPython/Compiler/Ast/SliceExpression.cs | 0 .../IronPython/Compiler/Ast/StarredExpression.cs | 0 .../IronPython/Compiler/Ast/Statement.cs | 0 .../IronPython/Compiler/Ast/SuiteStatement.cs | 0 .../IronPython/Compiler/Ast/TryStatement.cs | 0 .../IronPython/Compiler/Ast/TupleExpression.cs | 0 .../IronPython/Compiler/Ast/UnaryExpression.cs | 0 .../IronPython/Compiler/Ast/VariableKind.cs | 0 .../IronPython/Compiler/Ast/WhileStatement.cs | 0 .../IronPython/Compiler/Ast/WithStatement.cs | 0 .../IronPython/Compiler/Ast/YieldExpression.cs | 0 .../IronPython/Compiler/Ast/YieldFromExpression.cs | 0 .../IronPython/Compiler/ClosureExpression.cs | 0 .../IronPython/Compiler/ClosureInfo.cs | 0 .../Compiler/CollectableCompilationMode.cs | 0 .../IronPython/Compiler/CompilationMode.cs | 0 .../IronPython/Compiler/GeneratorRewriter.cs | 0 .../IronPython/Compiler/LazyCode.cs | 0 .../IronPython/Compiler/LookupCompilationMode.cs | 0 .../IronPython/Compiler/OnDiskScriptCode.cs | 0 .../IronPython/Compiler/Parser.cs | 0 .../IronPython/Compiler/PythonCallTargets.cs | 0 .../IronPython/Compiler/PythonCompilerOptions.cs | 0 .../IronPython/Compiler/PythonDynamicExpression.cs | 0 .../IronPython/Compiler/PythonGlobal.cs | 0 .../Compiler/PythonGlobalVariableExpression.cs | 0 .../IronPython/Compiler/PythonOperator.cs | 0 .../IronPython/Compiler/PythonSavableScriptCode.cs | 0 .../IronPython/Compiler/PythonScriptCode.cs | 0 .../Compiler/ReducableDynamicExpression.cs | 0 .../IronPython/Compiler/RunnableScriptCode.cs | 0 .../IronPython/Compiler/RuntimeScriptCode.cs | 0 .../IronPython/Compiler/ToDiskCompilationMode.cs | 0 .../IronPython/Compiler/Token.cs | 0 .../IronPython/Compiler/TokenKind.Generated.cs | 0 .../IronPython/Compiler/Tokenizer.Generated.cs | 0 .../IronPython/Compiler/Tokenizer.cs | 0 .../UncollectableCompilationMode.Generated.cs | 0 .../Compiler/UncollectableCompilationMode.cs | 0 .../IronPython/FakeInteropServices.cs | 0 .../IronPython/Hosting/Python.cs | 0 .../IronPython/Hosting/PythonCodeDomCodeGen.cs | 0 .../IronPython/Hosting/PythonCommandLine.cs | 0 .../IronPython/Hosting/PythonConsoleOptions.cs | 0 .../IronPython/Hosting/PythonOptionsParser.cs | 0 .../IronPython/Hosting/PythonService.cs | 0 .../IronPython/Interop/Windows/Interop.Libraries.cs | 0 .../Windows/Kernel32/Interop.GetWindowsExW.cs | 0 .../Windows/Kernel32/Interop.OSVERSIONINFOEX.cs | 0 .../Interop/Windows/NtDll/Interop.RtlGetVersion.cs | 0 .../Interop/Windows/Ucrtbase/Interop.strerror.cs | 0 .../IronPython/IronPython.csproj | 0 .../IronPython/Lib/iptest/__init__.py | 0 .../IronPython/Lib/iptest/cominterop_util.py | 0 .../IronPython/Lib/iptest/console_util.py | 0 .../IronPython/Lib/iptest/file_util.py | 0 .../IronPython/Lib/iptest/ipunittest.py | 0 .../IronPython/Lib/iptest/misc_util.py | 0 .../IronPython/Lib/iptest/process_util.py | 0 .../IronPython/Lib/iptest/runner.py | 0 .../IronPython/Lib/iptest/test_env.py | 0 .../IronPython/Lib/iptest/type_util.py | 0 .../IronPython/Modules/Builtin.Generated.cs | 0 .../IronPython/Modules/Builtin.cs | 0 {Src => Src.GetRenamed}/IronPython/Modules/_ast.cs | 0 .../IronPython/Modules/_fileio.cs | 0 {Src => Src.GetRenamed}/IronPython/Modules/_imp.cs | 0 {Src => Src.GetRenamed}/IronPython/Modules/_io.cs | 0 .../IronPython/Modules/_io/BytesIO.cs | 0 .../IronPython/Modules/_io/StringIO.cs | 0 .../IronPython/Modules/_locale.cs | 0 {Src => Src.GetRenamed}/IronPython/Modules/sys.cs | 0 .../IronPython/Modules/unicodedata.cs | 0 .../IronPython/Modules/unicodedata/CaseFolding.txt | 0 .../Modules/unicodedata/EastAsianWidth-3.2.0.txt | 0 .../Modules/unicodedata/EastAsianWidth.txt | 0 .../Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz | Bin .../Modules/unicodedata/IPyUnicodeData.txt.gz | Bin .../IronPython/Modules/unicodedata/NameAliases.txt | 0 .../Modules/unicodedata/UnicodeData-3.2.0.txt | 0 .../IronPython/Modules/unicodedata/UnicodeData.txt | 0 .../Modules/unicodedata/genunicodedata.py | 0 .../IronPython/Modules/unicodedata/license.txt | 0 .../IronPython/Properties/AssemblyInfo.cs | 0 .../IronPython/Resources.Designer.cs | 0 {Src => Src.GetRenamed}/IronPython/Resources.resx | 0 .../IronPython/Runtime/ArrayData.cs | 0 .../Binding/BinaryRetTypeBinder.Generated.cs | 0 .../Runtime/Binding/BinaryRetTypeBinder.cs | 0 .../IronPython/Runtime/Binding/Binders.cs | 0 .../IronPython/Runtime/Binding/BindingHelpers.cs | 0 .../IronPython/Runtime/Binding/BindingWarnings.cs | 0 .../Runtime/Binding/CompatibilityInvokeBinder.cs | 0 .../Runtime/Binding/ConditionalBuilder.cs | 0 .../IronPython/Runtime/Binding/ContextArgBuilder.cs | 0 .../IronPython/Runtime/Binding/ConversionBinder.cs | 0 .../Runtime/Binding/CreateFallbackBinder.cs | 0 .../IronPython/Runtime/Binding/FastBindResult.cs | 0 .../IronPython/Runtime/Binding/FastGetBase.cs | 0 .../IronPython/Runtime/Binding/FastSetBase.cs | 0 .../IronPython/Runtime/Binding/IComConvertible.cs | 0 .../IronPython/Runtime/Binding/IFastGettable.cs | 0 .../IronPython/Runtime/Binding/IFastInvokable.cs | 0 .../IronPython/Runtime/Binding/IFastSettable.cs | 0 .../Runtime/Binding/IPythonConvertible.cs | 0 .../IronPython/Runtime/Binding/IPythonExpandable.cs | 0 .../IronPython/Runtime/Binding/IPythonGetable.cs | 0 .../IronPython/Runtime/Binding/IPythonInvokable.cs | 0 .../IronPython/Runtime/Binding/IPythonOperable.cs | 0 .../IronPython/Runtime/Binding/IPythonSite.cs | 0 .../Runtime/Binding/MetaBuiltinFunction.cs | 0 .../Runtime/Binding/MetaBuiltinMethodDescriptor.cs | 0 .../IronPython/Runtime/Binding/MetaMethod.cs | 0 .../Runtime/Binding/MetaPythonFunction.cs | 0 .../IronPython/Runtime/Binding/MetaPythonObject.cs | 0 .../Runtime/Binding/MetaPythonType.Calls.cs | 0 .../Runtime/Binding/MetaPythonType.Members.cs | 0 .../IronPython/Runtime/Binding/MetaPythonType.cs | 0 .../Runtime/Binding/MetaUserObject.Members.cs | 0 .../IronPython/Runtime/Binding/MetaUserObject.cs | 0 .../Runtime/Binding/PythonBinaryOperationBinder.cs | 0 .../Runtime/Binding/PythonBinder.Create.cs | 0 .../IronPython/Runtime/Binding/PythonBinder.cs | 0 .../Runtime/Binding/PythonDeleteIndexBinder.cs | 0 .../Runtime/Binding/PythonDeleteMemberBinder.cs | 0 .../Runtime/Binding/PythonDeleteSliceBinder.cs | 0 .../Runtime/Binding/PythonExtensionBinder.cs | 0 .../Runtime/Binding/PythonGetIndexBinder.cs | 0 .../Runtime/Binding/PythonGetMemberBinder.cs | 0 .../Runtime/Binding/PythonGetSliceBinder.cs | 0 .../IronPython/Runtime/Binding/PythonIndexType.cs | 0 .../Runtime/Binding/PythonInvokeBinder.cs | 0 .../Runtime/Binding/PythonOperationBinder.cs | 0 .../Runtime/Binding/PythonOperationKind.cs | 0 .../Runtime/Binding/PythonOverloadResolver.cs | 0 .../Runtime/Binding/PythonProtocol.Operations.cs | 0 .../IronPython/Runtime/Binding/PythonProtocol.cs | 0 .../Runtime/Binding/PythonSetIndexBinder.cs | 0 .../Runtime/Binding/PythonSetMemberBinder.cs | 0 .../Runtime/Binding/PythonSetSliceBinder.cs | 0 .../Runtime/Binding/PythonUnaryOperationBinder.cs | 0 .../Runtime/Binding/SiteLocalStorageBuilder.cs | 0 .../IronPython/Runtime/Binding/SlotOrFunction.cs | 0 .../IronPython/Runtime/Binding/WarningInfo.cs | 0 .../IronPython/Runtime/BufferProtocol.cs | 0 .../IronPython/Runtime/BuiltinPythonModule.cs | 0 .../IronPython/Runtime/BuiltinsDictionaryStorage.cs | 0 .../IronPython/Runtime/ByteArray.cs | 0 .../IronPython/Runtime/ByteArrayIterator.cs | 0 {Src => Src.GetRenamed}/IronPython/Runtime/Bytes.cs | 0 .../IronPython/Runtime/BytesIterator.cs | 0 .../IronPython/Runtime/BytesLikeAttribute.cs | 0 .../IronPython/Runtime/ClassMethodAttribute.cs | 0 .../IronPython/Runtime/ClassMethodDescriptor.cs | 0 .../IronPython/Runtime/ClrModule.cs | 0 .../IronPython/Runtime/CodeContext.cs | 0 .../IronPython/Runtime/CollectionDebugView.cs | 0 .../IronPython/Runtime/CommonDictionaryStorage.cs | 0 .../IronPython/Runtime/CompareUtil.cs | 0 .../IronPython/Runtime/CompileFlags.cs | 0 .../IronPython/Runtime/CompiledLoader.cs | 0 .../IronPython/Runtime/ConstantDictionaryStorage.cs | 0 .../IronPython/Runtime/ConversionWrappers.cs | 0 .../IronPython/Runtime/Converter.cs | 0 .../IronPython/Runtime/CustomDictionaryStorage.cs | 0 .../IronPython/Runtime/DebuggerDictionaryStorage.cs | 0 .../IronPython/Runtime/DefaultContext.cs | 0 .../IronPython/Runtime/Descriptors.cs | 0 .../IronPython/Runtime/DictionaryOps.cs | 0 .../IronPython/Runtime/DictionaryStorage.cs | 0 .../Runtime/DictionaryTypeInfoAttribute.cs | 0 .../Runtime/DontMapGetMemberNamesToDirAttribute.cs | 0 .../Runtime/DontMapICollectionToLenAttribute.cs | 0 .../DontMapIDisposableToContextManagerAttribute.cs | 0 .../DontMapIEnumerableToContainsAttribute.cs | 0 .../Runtime/DontMapIEnumerableToIterAttribute.cs | 0 .../IronPython/Runtime/EmptyDictionaryStorage.cs | 0 .../IronPython/Runtime/Enumerate.cs | 0 .../IronPython/Runtime/ErrorCodes.cs | 0 .../Exceptions/AssertionException.Generated.cs | 0 .../Runtime/Exceptions/AttributeErrorException.cs | 0 .../Exceptions/BlockingIOException.Generated.cs | 0 .../Exceptions/BrokenPipeException.Generated.cs | 0 .../Runtime/Exceptions/BufferException.Generated.cs | 0 .../Exceptions/BytesWarningException.Generated.cs | 0 .../Exceptions/ChildProcessException.Generated.cs | 0 .../ConnectionAbortedException.Generated.cs | 0 .../Exceptions/ConnectionException.Generated.cs | 0 .../ConnectionRefusedException.Generated.cs | 0 .../ConnectionResetException.Generated.cs | 0 .../DeprecationWarningException.Generated.cs | 0 .../Exceptions/FileExistsException.Generated.cs | 0 .../Exceptions/FloatingPointException.Generated.cs | 0 .../Exceptions/FutureWarningException.Generated.cs | 0 .../Runtime/Exceptions/GeneratorExitException.cs | 0 .../Runtime/Exceptions/ImportException.Generated.cs | 0 .../Exceptions/ImportWarningException.Generated.cs | 0 .../Runtime/Exceptions/IndentationException.cs | 0 .../Exceptions/InterruptedException.Generated.cs | 0 .../Exceptions/IsADirectoryException.Generated.cs | 0 .../Runtime/Exceptions/LookupException.Generated.cs | 0 .../Runtime/Exceptions/ModuleNotFoundException.cs | 0 .../Exceptions/NotADirectoryException.Generated.cs | 0 .../Runtime/Exceptions/OSException.Generated.cs | 0 .../PendingDeprecationWarningException.Generated.cs | 0 .../Exceptions/ProcessLookupException.Generated.cs | 0 .../Runtime/Exceptions/PythonException.cs | 0 .../Exceptions/PythonExceptions.BaseException.cs | 0 .../Exceptions/PythonExceptions.Generated.cs | 0 .../Runtime/Exceptions/PythonExceptions.cs | 0 .../Exceptions/RecursionException.Generated.cs | 0 .../Exceptions/ReferenceException.Generated.cs | 0 .../ResourceWarningException.Generated.cs | 0 .../Exceptions/RuntimeException.Generated.cs | 0 .../Exceptions/RuntimeWarningException.Generated.cs | 0 .../StopAsyncIterationException.Generated.cs | 0 .../Exceptions/StopIterationException.Generated.cs | 0 .../Exceptions/SyntaxWarningException.Generated.cs | 0 .../Runtime/Exceptions/SystemExitException.cs | 0 .../IronPython/Runtime/Exceptions/TabException.cs | 0 .../IronPython/Runtime/Exceptions/TraceBack.cs | 0 .../Runtime/Exceptions/TypeErrorException.cs | 0 .../Exceptions/UnicodeException.Generated.cs | 0 .../UnicodeTranslateException.Generated.cs | 0 .../Exceptions/UnicodeWarningException.Generated.cs | 0 .../Exceptions/UserWarningException.Generated.cs | 0 .../Runtime/Exceptions/ValueErrorException.cs | 0 .../IronPython/Runtime/ExtensionMethodSet.cs | 0 .../IronPython/Runtime/Filter.cs | 0 .../IronPython/Runtime/FormattingHelper.cs | 0 .../IronPython/Runtime/FunctionAttributes.cs | 0 .../IronPython/Runtime/FunctionCode.cs | 0 .../IronPython/Runtime/Generator.cs | 0 .../IronPython/Runtime/GlobalDictionaryStorage.cs | 0 .../IronPython/Runtime/IParameterSequence.cs | 0 .../IronPython/Runtime/Implementation.cs | 0 .../IronPython/Runtime/Importer.cs | 0 {Src => Src.GetRenamed}/IronPython/Runtime/Index.cs | 0 .../Runtime/InstancedModuleDictionaryStorage.cs | 0 .../IronPython/Runtime/Interfaces.cs | 0 .../IronPython/Runtime/KwCallInfo.cs | 0 .../IronPython/Runtime/LiteralParser.cs | 0 {Src => Src.GetRenamed}/IronPython/Runtime/Map.cs | 0 .../Runtime/MaybeNotImplementedAttribute.cs | 0 .../Runtime/MemoryStreamContentProvider.cs | 0 .../IronPython/Runtime/MemoryView.cs | 0 .../IronPython/Runtime/Method.Generated.cs | 0 .../IronPython/Runtime/Method.cs | 0 .../IronPython/Runtime/MissingParameter.cs | 0 .../IronPython/Runtime/ModuleContext.cs | 0 .../IronPython/Runtime/ModuleDictionaryStorage.cs | 0 .../IronPython/Runtime/ModuleGlobalCache.cs | 0 .../IronPython/Runtime/ModuleLoader.cs | 0 .../IronPython/Runtime/ModuleOptions.cs | 0 .../IronPython/Runtime/NameType.cs | 0 .../IronPython/Runtime/NewStringFormatter.cs | 0 .../IronPython/Runtime/ObjectAttributesAdapter.cs | 0 .../IronPython/Runtime/ObjectDebugView.cs | 0 .../IronPython/Runtime/Operations/ArrayOps.cs | 0 .../IronPython/Runtime/Operations/BigIntegerOps.cs | 0 .../IronPython/Runtime/Operations/BoolOps.cs | 0 .../IronPython/Runtime/Operations/ByteOps.cs | 0 .../IronPython/Runtime/Operations/CharOps.cs | 0 .../IronPython/Runtime/Operations/ComOps.cs | 0 .../IronPython/Runtime/Operations/ComplexOps.cs | 0 .../Runtime/Operations/CustomTypeDescHelpers.cs | 0 .../IronPython/Runtime/Operations/DBNullOps.cs | 0 .../IronPython/Runtime/Operations/DateTimeOps.cs | 0 .../IronPython/Runtime/Operations/DecimalOps.cs | 0 .../IronPython/Runtime/Operations/DelegateOps.cs | 0 .../Runtime/Operations/DictionaryOfTOps.cs | 0 .../IronPython/Runtime/Operations/EnumOps.cs | 0 .../Runtime/Operations/FloatOps.Generated.cs | 0 .../IronPython/Runtime/Operations/FloatOps.cs | 0 .../IronPython/Runtime/Operations/IListOfByteOps.cs | 0 .../IronPython/Runtime/Operations/InstanceOps.cs | 0 .../Runtime/Operations/IntOps.Generated.cs | 0 .../IronPython/Runtime/Operations/IntOps.cs | 0 .../IronPython/Runtime/Operations/IntPtrOps.cs | 0 .../IronPython/Runtime/Operations/ListOfTOps.cs | 0 .../IronPython/Runtime/Operations/MarshalOps.cs | 0 .../Runtime/Operations/NamespaceTrackerOps.cs | 0 .../IronPython/Runtime/Operations/ObjectOps.cs | 0 .../IronPython/Runtime/Operations/PythonCalls.cs | 0 .../Runtime/Operations/PythonOps.Generated.cs | 0 .../IronPython/Runtime/Operations/PythonOps.cs | 0 .../IronPython/Runtime/Operations/PythonTypeOps.cs | 0 .../Runtime/Operations/StringOps.Generated.cs | 0 .../IronPython/Runtime/Operations/StringOps.cs | 0 .../IronPython/Runtime/Operations/TypeGroupOps.cs | 0 .../IronPython/Runtime/Operations/TypeTrackerOps.cs | 0 .../IronPython/Runtime/Operations/UIntPtrOps.cs | 0 .../IronPython/Runtime/Operations/UserTypeOps.cs | 0 .../IronPython/Runtime/OutputWriter.cs | 0 .../IronPython/Runtime/PlatformsAttribute.cs | 0 .../IronPython/Runtime/Profiler.cs | 0 .../IronPython/Runtime/PythonContext.Generated.cs | 0 .../IronPython/Runtime/PythonContext.cs | 0 .../IronPython/Runtime/PythonDictionary.cs | 0 .../Runtime/PythonDocumentationProvider.cs | 0 .../IronPython/Runtime/PythonDynamicStackFrame.cs | 0 .../IronPython/Runtime/PythonEncoding.cs | 0 .../IronPython/Runtime/PythonFileManager.cs | 0 .../IronPython/Runtime/PythonFunction.Generated.cs | 0 .../IronPython/Runtime/PythonFunction.cs | 0 .../IronPython/Runtime/PythonHiddenAttribute.cs | 0 .../Runtime/PythonHiddenBaseClassAttribute.cs | 0 .../IronPython/Runtime/PythonList.cs | 0 .../IronPython/Runtime/PythonModule.cs | 0 .../IronPython/Runtime/PythonModuleAttribute.cs | 0 .../IronPython/Runtime/PythonNarrowing.cs | 0 .../IronPython/Runtime/PythonOptions.cs | 0 .../IronPython/Runtime/PythonRange.cs | 0 .../IronPython/Runtime/PythonScopeExtension.cs | 0 .../IronPython/Runtime/PythonStrIterator.cs | 0 .../IronPython/Runtime/PythonTracebackListener.cs | 0 .../IronPython/Runtime/PythonTuple.cs | 0 .../IronPython/Runtime/PythonTypeAttribute.cs | 0 .../IronPython/Runtime/Reversed.cs | 0 .../Runtime/RuntimeVariablesDictionaryStorage.cs | 0 .../IronPython/Runtime/ScopeDictionaryStorage.cs | 0 .../IronPython/Runtime/SequenceTypeInfoAttribute.cs | 0 {Src => Src.GetRenamed}/IronPython/Runtime/Set.cs | 0 .../IronPython/Runtime/SetStorage.cs | 0 .../IronPython/Runtime/SimpleNamespace.cs | 0 .../IronPython/Runtime/SiteLocalStorage.cs | 0 {Src => Src.GetRenamed}/IronPython/Runtime/Slice.cs | 0 .../IronPython/Runtime/StringDictionaryStorage.cs | 0 .../IronPython/Runtime/StringFormatSpec.cs | 0 .../IronPython/Runtime/StringFormatter.cs | 0 {Src => Src.GetRenamed}/IronPython/Runtime/Super.cs | 0 .../IronPython/Runtime/Symbols.Generated.cs | 0 .../IronPython/Runtime/ThrowingErrorSink.cs | 0 .../IronPython/Runtime/TypecodeOps.cs | 0 .../IronPython/Runtime/Types/BuiltinFunction.cs | 0 .../Runtime/Types/BuiltinFunctionOverloadMapper.cs | 0 .../Runtime/Types/BuiltinMethodDescriptor.cs | 0 .../IronPython/Runtime/Types/CachedNewTypeInfo.cs | 0 .../IronPython/Runtime/Types/ConstructorFunction.cs | 0 .../Runtime/Types/CustomAttributeTracker.cs | 0 .../Types/CustomInstanceDictionaryStorage.cs | 0 .../IronPython/Runtime/Types/DocBuilder.cs | 0 .../Runtime/Types/DynamicBaseTypeAttribute.cs | 0 .../IronPython/Runtime/Types/DynamicHelpers.cs | 0 .../IronPython/Runtime/Types/EmptyType.cs | 0 .../Runtime/Types/ExtensionPropertyInfo.cs | 0 .../IronPython/Runtime/Types/FunctionType.cs | 0 .../IronPython/Runtime/Types/IPythonObject.cs | 0 .../IronPython/Runtime/Types/InstanceCreator.cs | 0 .../IronPython/Runtime/Types/MappingProxy.cs | 0 .../IronPython/Runtime/Types/Mro.cs | 0 .../IronPython/Runtime/Types/NameConverter.cs | 0 .../IronPython/Runtime/Types/NewTypeInfo.cs | 0 .../IronPython/Runtime/Types/NewTypeMaker.cs | 0 .../IronPython/Runtime/Types/OperatorMapping.cs | 0 .../Runtime/Types/ParameterInfoWrapper.cs | 0 .../IronPython/Runtime/Types/PythonAssemblyOps.cs | 0 .../IronPython/Runtime/Types/PythonSiteCache.cs | 0 .../Runtime/Types/PythonType.Generated.cs | 0 .../IronPython/Runtime/Types/PythonType.cs | 0 .../IronPython/Runtime/Types/PythonTypeDataSlot.cs | 0 .../IronPython/Runtime/Types/PythonTypeDictSlot.cs | 0 .../Runtime/Types/PythonTypeInfo.Generated.cs | 0 .../IronPython/Runtime/Types/PythonTypeInfo.cs | 0 .../IronPython/Runtime/Types/PythonTypeSlot.cs | 0 .../IronPython/Runtime/Types/PythonTypeTypeSlot.cs | 0 .../Runtime/Types/PythonTypeUserDescriptorSlot.cs | 0 .../Runtime/Types/PythonTypeWeakRefSlot.cs | 0 .../IronPython/Runtime/Types/ReflectedEvent.cs | 0 .../Runtime/Types/ReflectedExtensionProperty.cs | 0 .../IronPython/Runtime/Types/ReflectedField.cs | 0 .../Runtime/Types/ReflectedGetterSetter.cs | 0 .../IronPython/Runtime/Types/ReflectedIndexer.cs | 0 .../IronPython/Runtime/Types/ReflectedProperty.cs | 0 .../Runtime/Types/ReflectedSlotProperty.cs | 0 .../IronPython/Runtime/Types/ResolvedMember.cs | 0 .../IronPython/Runtime/Types/SlotFieldAttribute.cs | 0 .../Runtime/Types/StaticUnderlyingSystemType.cs | 0 .../IronPython/Runtime/Types/TypeCache.Generated.cs | 0 .../IronPython/Runtime/UnboundNameException.cs | 0 .../IronPython/Runtime/WeakRef.cs | 0 .../Runtime/WrapperDescriptorAttribute.cs | 0 .../IronPython/Runtime/WrapperDictionary.cs | 0 {Src => Src.GetRenamed}/IronPython/Runtime/Zip.cs | 0 .../IronPython/SerializationStubs.cs | 0 .../IronPython/StringExtensions.cs | 0 .../IronPython/SystemRuntimeVersioning.cs | 0 .../IronPython/policy.IronPython.config | 0 .../Modules/IronPython.Modules.csproj | 0 {Src => Src.GetRenamed}/Modules/IterTools.cs | 0 {Src => Src.GetRenamed}/Modules/ModuleOps.cs | 0 {Src => Src.GetRenamed}/Modules/NtSignalState.cs | 0 .../Modules/Properties/AssemblyInfo.cs | 0 .../Modules/ResourceMetaPathImporter.cs | 0 .../Modules/SimpleSignalState.cs | 0 {Src => Src.GetRenamed}/Modules/_bisect.cs | 0 {Src => Src.GetRenamed}/Modules/_codecs.cs | 0 {Src => Src.GetRenamed}/Modules/_codecs_cn.cs | 0 {Src => Src.GetRenamed}/Modules/_collections.cs | 0 {Src => Src.GetRenamed}/Modules/_csv.cs | 0 {Src => Src.GetRenamed}/Modules/_ctypes/Array.cs | 0 .../Modules/_ctypes/ArrayType.cs | 0 {Src => Src.GetRenamed}/Modules/_ctypes/CData.cs | 0 {Src => Src.GetRenamed}/Modules/_ctypes/CFuncPtr.cs | 0 .../Modules/_ctypes/CFuncPtrType.cs | 0 .../Modules/_ctypes/Extensions.cs | 0 {Src => Src.GetRenamed}/Modules/_ctypes/Field.cs | 0 .../Modules/_ctypes/INativeType.cs | 0 .../Modules/_ctypes/LocalOrArg.cs | 0 .../Modules/_ctypes/MarshalCleanup.cs | 0 .../Modules/_ctypes/MemoryHolder.cs | 0 .../Modules/_ctypes/NativeArgument.cs | 0 .../Modules/_ctypes/NativeFunctions.cs | 0 {Src => Src.GetRenamed}/Modules/_ctypes/Pointer.cs | 0 .../Modules/_ctypes/PointerType.cs | 0 .../Modules/_ctypes/SimpleCData.cs | 0 .../Modules/_ctypes/SimpleType.cs | 0 .../Modules/_ctypes/SimpleTypeKind.cs | 0 .../Modules/_ctypes/StructType.cs | 0 .../Modules/_ctypes/Structure.cs | 0 {Src => Src.GetRenamed}/Modules/_ctypes/Union.cs | 0 .../Modules/_ctypes/UnionType.cs | 0 {Src => Src.GetRenamed}/Modules/_ctypes/_ctypes.cs | 0 {Src => Src.GetRenamed}/Modules/_ctypes_test.cs | 0 {Src => Src.GetRenamed}/Modules/_datetime.cs | 0 {Src => Src.GetRenamed}/Modules/_functools.cs | 0 {Src => Src.GetRenamed}/Modules/_heapq.cs | 0 {Src => Src.GetRenamed}/Modules/_multibytecodec.cs | 0 {Src => Src.GetRenamed}/Modules/_multiprocessing.cs | 0 {Src => Src.GetRenamed}/Modules/_opcode.cs | 0 {Src => Src.GetRenamed}/Modules/_operator.cs | 0 {Src => Src.GetRenamed}/Modules/_overlapped.cs | 0 {Src => Src.GetRenamed}/Modules/_pickle.cs | 0 {Src => Src.GetRenamed}/Modules/_posixsubprocess.cs | 0 .../Modules/_random.RandomGen.cs | 0 {Src => Src.GetRenamed}/Modules/_random.cs | 0 {Src => Src.GetRenamed}/Modules/_socket.cs | 0 {Src => Src.GetRenamed}/Modules/_sre.cs | 0 {Src => Src.GetRenamed}/Modules/_ssl.cs | 0 {Src => Src.GetRenamed}/Modules/_string.cs | 0 {Src => Src.GetRenamed}/Modules/_struct.cs | 0 {Src => Src.GetRenamed}/Modules/_sysconfigdata.cs | 0 {Src => Src.GetRenamed}/Modules/_thread.cs | 0 {Src => Src.GetRenamed}/Modules/_warnings.cs | 0 .../Modules/_weakref.Generated.cs | 0 {Src => Src.GetRenamed}/Modules/_weakref.cs | 0 {Src => Src.GetRenamed}/Modules/_winapi.cs | 0 {Src => Src.GetRenamed}/Modules/array.cs | 0 {Src => Src.GetRenamed}/Modules/atexit.cs | 0 {Src => Src.GetRenamed}/Modules/audioop.cs | 0 {Src => Src.GetRenamed}/Modules/binascii.cs | 0 .../Modules/bz2/BZ2Compressor.cs | 0 .../Modules/bz2/BZ2Decompressor.cs | 0 {Src => Src.GetRenamed}/Modules/bz2/BZ2Module.cs | 0 .../Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs | 0 .../Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs | 0 .../bz2/dotnetzip/BZip2/BZip2OutputStream.cs | 0 .../Modules/bz2/dotnetzip/BZip2/BitWriter.cs | 0 .../Modules/bz2/dotnetzip/BZip2/CRC32.cs | 0 .../dotnetzip/BZip2/ParallelBZip2OutputStream.cs | 0 .../Modules/bz2/dotnetzip/BZip2/Rand.cs | 0 .../Modules/bz2/dotnetzip/source.txt | 0 {Src => Src.GetRenamed}/Modules/cmath.cs | 0 {Src => Src.GetRenamed}/Modules/errno.cs | 0 {Src => Src.GetRenamed}/Modules/faulthandler.cs | 0 {Src => Src.GetRenamed}/Modules/fcntl.cs | 0 {Src => Src.GetRenamed}/Modules/gc.cs | 0 {Src => Src.GetRenamed}/Modules/grp.cs | 0 .../Modules/hashlib/MD5CryptoServiceProvider.cs | 0 .../Modules/hashlib/SHA1CryptoServiceProvider.cs | 0 {Src => Src.GetRenamed}/Modules/hashlib/SHA224.cs | 0 .../Modules/hashlib/SHA224Managed.cs | 0 .../Modules/hashlib/SHA256Managed.cs | 0 .../Modules/hashlib/SHA384Managed.cs | 0 .../Modules/hashlib/SHA512Managed.cs | 0 .../Modules/hashlib/SHAConstants.cs | 0 {Src => Src.GetRenamed}/Modules/hashlib/_hashlib.cs | 0 {Src => Src.GetRenamed}/Modules/hashlib/_md5.cs | 0 {Src => Src.GetRenamed}/Modules/hashlib/_sha1.cs | 0 {Src => Src.GetRenamed}/Modules/hashlib/_sha256.cs | 0 {Src => Src.GetRenamed}/Modules/hashlib/_sha512.cs | 0 {Src => Src.GetRenamed}/Modules/marshal.cs | 0 {Src => Src.GetRenamed}/Modules/math.Generated.cs | 0 {Src => Src.GetRenamed}/Modules/math.cs | 0 {Src => Src.GetRenamed}/Modules/mmap.cs | 0 {Src => Src.GetRenamed}/Modules/msvcrt.cs | 0 {Src => Src.GetRenamed}/Modules/nt.cs | 0 .../Modules/policy.IronPython.Modules.config | 0 {Src => Src.GetRenamed}/Modules/pwd.cs | 0 {Src => Src.GetRenamed}/Modules/pyexpat.cs | 0 {Src => Src.GetRenamed}/Modules/re.cs | 0 {Src => Src.GetRenamed}/Modules/resource.cs | 0 {Src => Src.GetRenamed}/Modules/select.cs | 0 {Src => Src.GetRenamed}/Modules/signal.cs | 0 {Src => Src.GetRenamed}/Modules/spwd.cs | 0 {Src => Src.GetRenamed}/Modules/time.cs | 0 {Src => Src.GetRenamed}/Modules/winreg.cs | 0 {Src => Src.GetRenamed}/Modules/winsound.cs | 0 {Src => Src.GetRenamed}/Modules/xxsubtype.cs | 0 {Src => Src.GetRenamed}/Modules/zipimport.cs | 0 {Src => Src.GetRenamed}/Modules/zlib/Compress.cs | 0 {Src => Src.GetRenamed}/Modules/zlib/Decompress.cs | 0 {Src => Src.GetRenamed}/Modules/zlib/ZlibModule.cs | 0 .../Modules/zlib/zlib.net/Adler32.cs | 0 .../Modules/zlib/zlib.net/Deflate.cs | 0 .../Modules/zlib/zlib.net/InfBlocks.cs | 0 .../Modules/zlib/zlib.net/InfCodes.cs | 0 .../Modules/zlib/zlib.net/InfTree.cs | 0 .../Modules/zlib/zlib.net/Inflate.cs | 0 .../Modules/zlib/zlib.net/StaticTree.cs | 0 .../Modules/zlib/zlib.net/Tree.cs | 0 .../Modules/zlib/zlib.net/ZStream.cs | 0 .../Modules/zlib/zlib.net/ZStreamException.cs | 0 .../Modules/zlib/zlib.net/Zlib.cs | 0 .../Modules/zlib/zlib.net/history.txt | 0 .../Modules/zlib/zlib.net/license.txt | 0 .../Modules/zlib/zlib.net/readme.txt | 0 {Src => Src.GetRenamed}/README.md | 0 {Src => Src.GetRenamed}/SQLite/Connection.cs | 0 {Src => Src.GetRenamed}/SQLite/Contants.cs | 0 {Src => Src.GetRenamed}/SQLite/Cursor.cs | 0 {Src => Src.GetRenamed}/SQLite/Exceptions.cs | 0 {Src => Src.GetRenamed}/SQLite/Extensions.cs | 0 .../SQLite/IronPython.SQLite.csproj | 0 .../SQLite/Properties/AssemblyInfo.cs | 0 {Src => Src.GetRenamed}/SQLite/Row.cs | 0 {Src => Src.GetRenamed}/SQLite/Statement.cs | 0 {Src => Src.GetRenamed}/SQLite/Util.cs | 0 {Src => Src.GetRenamed}/SQLite/_sqlite.cs | 0 .../SQLite/c#sqlite/.editorconfig | 0 .../SQLite/c#sqlite/BtreeInt_h.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/Btree_h.cs | 0 .../SQLite/c#sqlite/Delegates.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/Hash_h.cs | 0 .../SQLite/c#sqlite/VdbeInt_h.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/Vdbe_h.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/_Custom.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/alter_c.cs | 0 .../SQLite/c#sqlite/analyze_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/attach_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/auth_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/backup_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/bitvec_c.cs | 0 .../SQLite/c#sqlite/btmutex_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/btree_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/build_c.cs | 0 .../SQLite/c#sqlite/callback_c.cs | 0 .../SQLite/c#sqlite/complete_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/crypto.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/ctime_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/date_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/delete_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/expr_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/fault_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/fkey_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/func_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/global_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/hash_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/hwtime_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/insert_c.cs | 0 .../SQLite/c#sqlite/journal_c.cs | 0 .../SQLite/c#sqlite/keywordhash_h.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/legacy_c.cs | 0 .../SQLite/c#sqlite/loadext_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/main_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/malloc_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/mem_Pool.cs | 0 .../SQLite/c#sqlite/memjournal_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/mutex_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/mutex_h.cs | 0 .../SQLite/c#sqlite/mutex_noop_c.cs | 0 .../SQLite/c#sqlite/mutex_w32.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/notify_c.cs | 0 .../SQLite/c#sqlite/opcodes_c.cs | 0 .../SQLite/c#sqlite/opcodes_h.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/os_c.cs | 0 .../SQLite/c#sqlite/os_common_h.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/os_h.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/os_win_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/pager_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/pager_h.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/parse_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/parse_h.cs | 0 .../SQLite/c#sqlite/pcache1_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/pcache_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/pcache_h.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/pragma_c.cs | 0 .../SQLite/c#sqlite/prepare_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/printf_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/random_c.cs | 0 .../SQLite/c#sqlite/resolve_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/rowset_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/select_c.cs | 0 .../SQLite/c#sqlite/sqlite3_h.cs | 0 .../SQLite/c#sqlite/sqliteInt_h.cs | 0 .../SQLite/c#sqlite/sqliteLimit_h.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/status_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/table_c.cs | 0 .../SQLite/c#sqlite/tokenize_c.cs | 0 .../SQLite/c#sqlite/trigger_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/update_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/utf_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/util_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/vacuum_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/vdbe_c.cs | 0 .../SQLite/c#sqlite/vdbeapi_c.cs | 0 .../SQLite/c#sqlite/vdbeaux_c.cs | 0 .../SQLite/c#sqlite/vdbeblob_c.cs | 0 .../SQLite/c#sqlite/vdbemem_c.cs | 0 .../SQLite/c#sqlite/vdbetrace_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/vtab_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/wal_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/wal_h.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/walker_c.cs | 0 {Src => Src.GetRenamed}/SQLite/c#sqlite/where_c.cs | 0 {Src => Src.GetRenamed}/Scripts/CompareDirs.py | 0 .../Scripts/Enter-IronPythonEnvironment.ps1 | 0 .../Scripts/Install-IronPython.ps1 | 0 {Src => Src.GetRenamed}/Scripts/clean.py | 0 {Src => Src.GetRenamed}/Scripts/copyrights.py | 0 {Src => Src.GetRenamed}/Scripts/generate.py | 0 .../generate_UncollectableCompilationMode.py | 0 .../Scripts/generate_alltypes.py | 0 {Src => Src.GetRenamed}/Scripts/generate_calls.py | 0 {Src => Src.GetRenamed}/Scripts/generate_casts.py | 0 .../Scripts/generate_comdispatch.py | 0 .../Scripts/generate_dict_views.py | 0 .../Scripts/generate_dynamic_instructions.py | 0 .../Scripts/generate_dynsites.py | 0 .../Scripts/generate_encoding_aliases.py | 0 .../Scripts/generate_exception_factory.py | 0 .../Scripts/generate_exceptions.py | 0 .../Scripts/generate_indicestest.py | 0 {Src => Src.GetRenamed}/Scripts/generate_math.py | 0 {Src => Src.GetRenamed}/Scripts/generate_ops.py | 0 .../Scripts/generate_os_codes.py | 0 .../Scripts/generate_reflected_calls.py | 0 {Src => Src.GetRenamed}/Scripts/generate_set.py | 0 {Src => Src.GetRenamed}/Scripts/generate_tuples.py | 0 .../Scripts/generate_typecache.py | 0 {Src => Src.GetRenamed}/Scripts/generate_walker.py | 0 {Src => Src.GetRenamed}/Scripts/ipcom.ps1 | 0 {Src => Src.GetRenamed}/Scripts/make_meta1.py | 0 {Src => Src.GetRenamed}/Scripts/radix_generator.py | 0 {Src => Src.GetRenamed}/Scripts/run_compiled.py | 0 {Src => Src.GetRenamed}/Scripts/run_interactive.py | 0 {Src => Src.GetRenamed}/Scripts/smtpmailer.py | 0 {Src => Src.GetRenamed}/Scripts/test_builder.py | 0 {Src => Src.GetRenamed}/Scripts/test_cgcheck.py | 0 {Src => Src.GetRenamed}/Scripts/test_parrot.py | 0 {Src => Src.GetRenamed}/Scripts/test_pystone.py | 0 {Src => Src.GetRenamed}/StdLib/.gitattributes | 0 {Src => Src.GetRenamed}/StdLib/Lib/__future__.py | 0 .../StdLib/Lib/__phello__.foo.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/_bootlocale.py | 0 .../StdLib/Lib/_collections_abc.py | 0 .../StdLib/Lib/_compat_pickle.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/_dummy_thread.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/_markupbase.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/_osx_support.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/_pyio.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/_sitebuiltins.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/_strptime.py | 0 .../StdLib/Lib/_threading_local.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/_weakrefset.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/abc.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/aifc.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/antigravity.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/argparse.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/ast.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/asynchat.py | 0 .../StdLib/Lib/asyncio/__init__.py | 0 .../StdLib/Lib/asyncio/base_events.py | 0 .../StdLib/Lib/asyncio/base_subprocess.py | 0 .../StdLib/Lib/asyncio/compat.py | 0 .../StdLib/Lib/asyncio/constants.py | 0 .../StdLib/Lib/asyncio/coroutines.py | 0 .../StdLib/Lib/asyncio/events.py | 0 .../StdLib/Lib/asyncio/futures.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/asyncio/locks.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/asyncio/log.py | 0 .../StdLib/Lib/asyncio/proactor_events.py | 0 .../StdLib/Lib/asyncio/protocols.py | 0 .../StdLib/Lib/asyncio/queues.py | 0 .../StdLib/Lib/asyncio/selector_events.py | 0 .../StdLib/Lib/asyncio/sslproto.py | 0 .../StdLib/Lib/asyncio/streams.py | 0 .../StdLib/Lib/asyncio/subprocess.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/asyncio/tasks.py | 0 .../StdLib/Lib/asyncio/test_utils.py | 0 .../StdLib/Lib/asyncio/transports.py | 0 .../StdLib/Lib/asyncio/unix_events.py | 0 .../StdLib/Lib/asyncio/windows_events.py | 0 .../StdLib/Lib/asyncio/windows_utils.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/asyncore.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/base64.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/bdb.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/binhex.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/bisect.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/bz2.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/cProfile.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/calendar.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/cgi.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/cgitb.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/chunk.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/clrtype.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/cmd.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/code.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/codecs.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/codeop.py | 0 .../StdLib/Lib/collections/__init__.py | 0 .../StdLib/Lib/collections/__main__.py | 0 .../StdLib/Lib/collections/abc.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/colorsys.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/compileall.py | 0 .../StdLib/Lib/concurrent/__init__.py | 0 .../StdLib/Lib/concurrent/futures/__init__.py | 0 .../StdLib/Lib/concurrent/futures/_base.py | 0 .../StdLib/Lib/concurrent/futures/process.py | 0 .../StdLib/Lib/concurrent/futures/thread.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/configparser.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/contextlib.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/copy.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/copyreg.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/crypt.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/csv.py | 0 .../StdLib/Lib/ctypes/__init__.py | 0 .../StdLib/Lib/ctypes/_endian.py | 0 .../StdLib/Lib/ctypes/macholib/README.ctypes | 0 .../StdLib/Lib/ctypes/macholib/__init__.py | 0 .../StdLib/Lib/ctypes/macholib/dyld.py | 0 .../StdLib/Lib/ctypes/macholib/dylib.py | 0 .../StdLib/Lib/ctypes/macholib/fetch_macholib | 0 .../StdLib/Lib/ctypes/macholib/fetch_macholib.bat | 0 .../StdLib/Lib/ctypes/macholib/framework.py | 0 .../StdLib/Lib/ctypes/test/__init__.py | 0 .../StdLib/Lib/ctypes/test/__main__.py | 0 .../StdLib/Lib/ctypes/test/test_anon.py | 0 .../StdLib/Lib/ctypes/test/test_array_in_pointer.py | 0 .../StdLib/Lib/ctypes/test/test_arrays.py | 0 .../StdLib/Lib/ctypes/test/test_as_parameter.py | 0 .../StdLib/Lib/ctypes/test/test_bitfields.py | 0 .../StdLib/Lib/ctypes/test/test_buffers.py | 0 .../StdLib/Lib/ctypes/test/test_bytes.py | 0 .../StdLib/Lib/ctypes/test/test_byteswap.py | 0 .../StdLib/Lib/ctypes/test/test_callbacks.py | 0 .../StdLib/Lib/ctypes/test/test_cast.py | 0 .../StdLib/Lib/ctypes/test/test_cfuncs.py | 0 .../StdLib/Lib/ctypes/test/test_checkretval.py | 0 .../StdLib/Lib/ctypes/test/test_delattr.py | 0 .../StdLib/Lib/ctypes/test/test_errno.py | 0 .../StdLib/Lib/ctypes/test/test_find.py | 0 .../StdLib/Lib/ctypes/test/test_frombuffer.py | 0 .../StdLib/Lib/ctypes/test/test_funcptr.py | 0 .../StdLib/Lib/ctypes/test/test_functions.py | 0 .../StdLib/Lib/ctypes/test/test_incomplete.py | 0 .../StdLib/Lib/ctypes/test/test_init.py | 0 .../StdLib/Lib/ctypes/test/test_internals.py | 0 .../StdLib/Lib/ctypes/test/test_keeprefs.py | 0 .../StdLib/Lib/ctypes/test/test_libc.py | 0 .../StdLib/Lib/ctypes/test/test_loading.py | 0 .../StdLib/Lib/ctypes/test/test_macholib.py | 0 .../StdLib/Lib/ctypes/test/test_memfunctions.py | 0 .../StdLib/Lib/ctypes/test/test_numbers.py | 0 .../StdLib/Lib/ctypes/test/test_objects.py | 0 .../StdLib/Lib/ctypes/test/test_parameters.py | 0 .../StdLib/Lib/ctypes/test/test_pep3118.py | 0 .../StdLib/Lib/ctypes/test/test_pickling.py | 0 .../StdLib/Lib/ctypes/test/test_pointers.py | 0 .../StdLib/Lib/ctypes/test/test_prototypes.py | 0 .../StdLib/Lib/ctypes/test/test_python_api.py | 0 .../StdLib/Lib/ctypes/test/test_random_things.py | 0 .../StdLib/Lib/ctypes/test/test_refcounts.py | 0 .../StdLib/Lib/ctypes/test/test_repr.py | 0 .../StdLib/Lib/ctypes/test/test_returnfuncptrs.py | 0 .../StdLib/Lib/ctypes/test/test_simplesubclasses.py | 0 .../StdLib/Lib/ctypes/test/test_sizes.py | 0 .../StdLib/Lib/ctypes/test/test_slicing.py | 0 .../StdLib/Lib/ctypes/test/test_stringptr.py | 0 .../StdLib/Lib/ctypes/test/test_strings.py | 0 .../StdLib/Lib/ctypes/test/test_struct_fields.py | 0 .../StdLib/Lib/ctypes/test/test_structures.py | 0 .../Lib/ctypes/test/test_unaligned_structures.py | 0 .../StdLib/Lib/ctypes/test/test_unicode.py | 0 .../StdLib/Lib/ctypes/test/test_values.py | 0 .../StdLib/Lib/ctypes/test/test_varsize_struct.py | 0 .../StdLib/Lib/ctypes/test/test_win32.py | 0 .../StdLib/Lib/ctypes/test/test_wintypes.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/ctypes/util.py | 0 .../StdLib/Lib/ctypes/wintypes.py | 0 .../StdLib/Lib/curses/__init__.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/curses/ascii.py | 0 .../StdLib/Lib/curses/has_key.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/curses/panel.py | 0 .../StdLib/Lib/curses/textpad.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/datetime.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/dbm/__init__.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/dbm/dumb.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/dbm/gnu.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/dbm/ndbm.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/decimal.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/difflib.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/dis.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/distutils/README | 0 .../StdLib/Lib/distutils/__init__.py | 0 .../StdLib/Lib/distutils/archive_util.py | 0 .../StdLib/Lib/distutils/bcppcompiler.py | 0 .../StdLib/Lib/distutils/ccompiler.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/distutils/cmd.py | 0 .../StdLib/Lib/distutils/command/__init__.py | 0 .../StdLib/Lib/distutils/command/bdist.py | 0 .../StdLib/Lib/distutils/command/bdist_dumb.py | 0 .../StdLib/Lib/distutils/command/bdist_msi.py | 0 .../StdLib/Lib/distutils/command/bdist_rpm.py | 0 .../StdLib/Lib/distutils/command/bdist_wininst.py | 0 .../StdLib/Lib/distutils/command/build.py | 0 .../StdLib/Lib/distutils/command/build_clib.py | 0 .../StdLib/Lib/distutils/command/build_ext.py | 0 .../StdLib/Lib/distutils/command/build_py.py | 0 .../StdLib/Lib/distutils/command/build_scripts.py | 0 .../StdLib/Lib/distutils/command/check.py | 0 .../StdLib/Lib/distutils/command/clean.py | 0 .../StdLib/Lib/distutils/command/command_template | 0 .../StdLib/Lib/distutils/command/config.py | 0 .../StdLib/Lib/distutils/command/install.py | 0 .../StdLib/Lib/distutils/command/install_data.py | 0 .../Lib/distutils/command/install_egg_info.py | 0 .../StdLib/Lib/distutils/command/install_headers.py | 0 .../StdLib/Lib/distutils/command/install_lib.py | 0 .../StdLib/Lib/distutils/command/install_scripts.py | 0 .../StdLib/Lib/distutils/command/register.py | 0 .../StdLib/Lib/distutils/command/sdist.py | 0 .../StdLib/Lib/distutils/command/upload.py | 0 .../Lib/distutils/command/wininst-10.0-amd64.exe | Bin .../StdLib/Lib/distutils/command/wininst-10.0.exe | Bin .../StdLib/Lib/distutils/command/wininst-6.0.exe | Bin .../StdLib/Lib/distutils/command/wininst-7.1.exe | Bin .../StdLib/Lib/distutils/command/wininst-8.0.exe | Bin .../Lib/distutils/command/wininst-9.0-amd64.exe | Bin .../StdLib/Lib/distutils/command/wininst-9.0.exe | Bin .../StdLib/Lib/distutils/config.py | 0 .../StdLib/Lib/distutils/core.py | 0 .../StdLib/Lib/distutils/cygwinccompiler.py | 0 .../StdLib/Lib/distutils/debug.py | 0 .../StdLib/Lib/distutils/dep_util.py | 0 .../StdLib/Lib/distutils/dir_util.py | 0 .../StdLib/Lib/distutils/dist.py | 0 .../StdLib/Lib/distutils/errors.py | 0 .../StdLib/Lib/distutils/extension.py | 0 .../StdLib/Lib/distutils/fancy_getopt.py | 0 .../StdLib/Lib/distutils/file_util.py | 0 .../StdLib/Lib/distutils/filelist.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/distutils/log.py | 0 .../StdLib/Lib/distutils/msvc9compiler.py | 0 .../StdLib/Lib/distutils/msvccompiler.py | 0 .../StdLib/Lib/distutils/spawn.py | 0 .../StdLib/Lib/distutils/sysconfig.py | 0 .../StdLib/Lib/distutils/tests/Setup.sample | 0 .../StdLib/Lib/distutils/tests/__init__.py | 0 .../StdLib/Lib/distutils/tests/support.py | 0 .../StdLib/Lib/distutils/tests/test_archive_util.py | 0 .../StdLib/Lib/distutils/tests/test_bdist.py | 0 .../StdLib/Lib/distutils/tests/test_bdist_dumb.py | 0 .../StdLib/Lib/distutils/tests/test_bdist_msi.py | 0 .../StdLib/Lib/distutils/tests/test_bdist_rpm.py | 0 .../Lib/distutils/tests/test_bdist_wininst.py | 0 .../StdLib/Lib/distutils/tests/test_build.py | 0 .../StdLib/Lib/distutils/tests/test_build_clib.py | 0 .../StdLib/Lib/distutils/tests/test_build_ext.py | 0 .../StdLib/Lib/distutils/tests/test_build_py.py | 0 .../Lib/distutils/tests/test_build_scripts.py | 0 .../StdLib/Lib/distutils/tests/test_check.py | 0 .../StdLib/Lib/distutils/tests/test_clean.py | 0 .../StdLib/Lib/distutils/tests/test_cmd.py | 0 .../StdLib/Lib/distutils/tests/test_config.py | 0 .../StdLib/Lib/distutils/tests/test_config_cmd.py | 0 .../StdLib/Lib/distutils/tests/test_core.py | 0 .../Lib/distutils/tests/test_cygwinccompiler.py | 0 .../StdLib/Lib/distutils/tests/test_dep_util.py | 0 .../StdLib/Lib/distutils/tests/test_dir_util.py | 0 .../StdLib/Lib/distutils/tests/test_dist.py | 0 .../StdLib/Lib/distutils/tests/test_extension.py | 0 .../StdLib/Lib/distutils/tests/test_file_util.py | 0 .../StdLib/Lib/distutils/tests/test_filelist.py | 0 .../StdLib/Lib/distutils/tests/test_install.py | 0 .../StdLib/Lib/distutils/tests/test_install_data.py | 0 .../Lib/distutils/tests/test_install_headers.py | 0 .../StdLib/Lib/distutils/tests/test_install_lib.py | 0 .../Lib/distutils/tests/test_install_scripts.py | 0 .../StdLib/Lib/distutils/tests/test_log.py | 0 .../Lib/distutils/tests/test_msvc9compiler.py | 0 .../StdLib/Lib/distutils/tests/test_register.py | 0 .../StdLib/Lib/distutils/tests/test_sdist.py | 0 .../StdLib/Lib/distutils/tests/test_spawn.py | 0 .../StdLib/Lib/distutils/tests/test_sysconfig.py | 0 .../StdLib/Lib/distutils/tests/test_text_file.py | 0 .../Lib/distutils/tests/test_unixccompiler.py | 0 .../StdLib/Lib/distutils/tests/test_upload.py | 0 .../StdLib/Lib/distutils/tests/test_util.py | 0 .../StdLib/Lib/distutils/tests/test_version.py | 0 .../Lib/distutils/tests/test_versionpredicate.py | 0 .../StdLib/Lib/distutils/text_file.py | 0 .../StdLib/Lib/distutils/unixccompiler.py | 0 .../StdLib/Lib/distutils/util.py | 0 .../StdLib/Lib/distutils/version.py | 0 .../StdLib/Lib/distutils/versionpredicate.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/doctest.py | 0 .../StdLib/Lib/dummy_threading.py | 0 .../StdLib/Lib/email/__init__.py | 0 .../StdLib/Lib/email/_encoded_words.py | 0 .../StdLib/Lib/email/_header_value_parser.py | 0 .../StdLib/Lib/email/_parseaddr.py | 0 .../StdLib/Lib/email/_policybase.py | 0 .../StdLib/Lib/email/architecture.rst | 0 .../StdLib/Lib/email/base64mime.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/email/charset.py | 0 .../StdLib/Lib/email/contentmanager.py | 0 .../StdLib/Lib/email/encoders.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/email/errors.py | 0 .../StdLib/Lib/email/feedparser.py | 0 .../StdLib/Lib/email/generator.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/email/header.py | 0 .../StdLib/Lib/email/headerregistry.py | 0 .../StdLib/Lib/email/iterators.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/email/message.py | 0 .../StdLib/Lib/email/mime}/__init__.py | 0 .../StdLib/Lib/email/mime/application.py | 0 .../StdLib/Lib/email/mime/audio.py | 0 .../StdLib/Lib/email/mime/base.py | 0 .../StdLib/Lib/email/mime/image.py | 0 .../StdLib/Lib/email/mime/message.py | 0 .../StdLib/Lib/email/mime/multipart.py | 0 .../StdLib/Lib/email/mime/nonmultipart.py | 0 .../StdLib/Lib/email/mime/text.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/email/parser.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/email/policy.py | 0 .../StdLib/Lib/email/quoprimime.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/email/utils.py | 0 .../StdLib/Lib/encodings/__init__.py | 0 .../StdLib/Lib/encodings/aliases.py | 0 .../StdLib/Lib/encodings/ascii.py | 0 .../StdLib/Lib/encodings/base64_codec.py | 0 .../StdLib/Lib/encodings/big5.py | 0 .../StdLib/Lib/encodings/big5hkscs.py | 0 .../StdLib/Lib/encodings/bz2_codec.py | 0 .../StdLib/Lib/encodings/charmap.py | 0 .../StdLib/Lib/encodings/cp037.py | 0 .../StdLib/Lib/encodings/cp1006.py | 0 .../StdLib/Lib/encodings/cp1026.py | 0 .../StdLib/Lib/encodings/cp1125.py | 0 .../StdLib/Lib/encodings/cp1140.py | 0 .../StdLib/Lib/encodings/cp1250.py | 0 .../StdLib/Lib/encodings/cp1251.py | 0 .../StdLib/Lib/encodings/cp1252.py | 0 .../StdLib/Lib/encodings/cp1253.py | 0 .../StdLib/Lib/encodings/cp1254.py | 0 .../StdLib/Lib/encodings/cp1255.py | 0 .../StdLib/Lib/encodings/cp1256.py | 0 .../StdLib/Lib/encodings/cp1257.py | 0 .../StdLib/Lib/encodings/cp1258.py | 0 .../StdLib/Lib/encodings/cp273.py | 0 .../StdLib/Lib/encodings/cp424.py | 0 .../StdLib/Lib/encodings/cp437.py | 0 .../StdLib/Lib/encodings/cp500.py | 0 .../StdLib/Lib/encodings/cp65001.py | 0 .../StdLib/Lib/encodings/cp720.py | 0 .../StdLib/Lib/encodings/cp737.py | 0 .../StdLib/Lib/encodings/cp775.py | 0 .../StdLib/Lib/encodings/cp850.py | 0 .../StdLib/Lib/encodings/cp852.py | 0 .../StdLib/Lib/encodings/cp855.py | 0 .../StdLib/Lib/encodings/cp856.py | 0 .../StdLib/Lib/encodings/cp857.py | 0 .../StdLib/Lib/encodings/cp858.py | 0 .../StdLib/Lib/encodings/cp860.py | 0 .../StdLib/Lib/encodings/cp861.py | 0 .../StdLib/Lib/encodings/cp862.py | 0 .../StdLib/Lib/encodings/cp863.py | 0 .../StdLib/Lib/encodings/cp864.py | 0 .../StdLib/Lib/encodings/cp865.py | 0 .../StdLib/Lib/encodings/cp866.py | 0 .../StdLib/Lib/encodings/cp869.py | 0 .../StdLib/Lib/encodings/cp874.py | 0 .../StdLib/Lib/encodings/cp875.py | 0 .../StdLib/Lib/encodings/cp932.py | 0 .../StdLib/Lib/encodings/cp949.py | 0 .../StdLib/Lib/encodings/cp950.py | 0 .../StdLib/Lib/encodings/euc_jis_2004.py | 0 .../StdLib/Lib/encodings/euc_jisx0213.py | 0 .../StdLib/Lib/encodings/euc_jp.py | 0 .../StdLib/Lib/encodings/euc_kr.py | 0 .../StdLib/Lib/encodings/gb18030.py | 0 .../StdLib/Lib/encodings/gb2312.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/encodings/gbk.py | 0 .../StdLib/Lib/encodings/hex_codec.py | 0 .../StdLib/Lib/encodings/hp_roman8.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/encodings/hz.py | 0 .../StdLib/Lib/encodings/idna.py | 0 .../StdLib/Lib/encodings/iso2022_jp.py | 0 .../StdLib/Lib/encodings/iso2022_jp_1.py | 0 .../StdLib/Lib/encodings/iso2022_jp_2.py | 0 .../StdLib/Lib/encodings/iso2022_jp_2004.py | 0 .../StdLib/Lib/encodings/iso2022_jp_3.py | 0 .../StdLib/Lib/encodings/iso2022_jp_ext.py | 0 .../StdLib/Lib/encodings/iso2022_kr.py | 0 .../StdLib/Lib/encodings/iso8859_1.py | 0 .../StdLib/Lib/encodings/iso8859_10.py | 0 .../StdLib/Lib/encodings/iso8859_11.py | 0 .../StdLib/Lib/encodings/iso8859_13.py | 0 .../StdLib/Lib/encodings/iso8859_14.py | 0 .../StdLib/Lib/encodings/iso8859_15.py | 0 .../StdLib/Lib/encodings/iso8859_16.py | 0 .../StdLib/Lib/encodings/iso8859_2.py | 0 .../StdLib/Lib/encodings/iso8859_3.py | 0 .../StdLib/Lib/encodings/iso8859_4.py | 0 .../StdLib/Lib/encodings/iso8859_5.py | 0 .../StdLib/Lib/encodings/iso8859_6.py | 0 .../StdLib/Lib/encodings/iso8859_7.py | 0 .../StdLib/Lib/encodings/iso8859_8.py | 0 .../StdLib/Lib/encodings/iso8859_9.py | 0 .../StdLib/Lib/encodings/johab.py | 0 .../StdLib/Lib/encodings/koi8_r.py | 0 .../StdLib/Lib/encodings/koi8_u.py | 0 .../StdLib/Lib/encodings/latin_1.py | 0 .../StdLib/Lib/encodings/mac_arabic.py | 0 .../StdLib/Lib/encodings/mac_centeuro.py | 0 .../StdLib/Lib/encodings/mac_croatian.py | 0 .../StdLib/Lib/encodings/mac_cyrillic.py | 0 .../StdLib/Lib/encodings/mac_farsi.py | 0 .../StdLib/Lib/encodings/mac_greek.py | 0 .../StdLib/Lib/encodings/mac_iceland.py | 0 .../StdLib/Lib/encodings/mac_latin2.py | 0 .../StdLib/Lib/encodings/mac_roman.py | 0 .../StdLib/Lib/encodings/mac_romanian.py | 0 .../StdLib/Lib/encodings/mac_turkish.py | 0 .../StdLib/Lib/encodings/mbcs.py | 0 .../StdLib/Lib/encodings/palmos.py | 0 .../StdLib/Lib/encodings/ptcp154.py | 0 .../StdLib/Lib/encodings/punycode.py | 0 .../StdLib/Lib/encodings/quopri_codec.py | 0 .../StdLib/Lib/encodings/raw_unicode_escape.py | 0 .../StdLib/Lib/encodings/rot_13.py | 0 .../StdLib/Lib/encodings/shift_jis.py | 0 .../StdLib/Lib/encodings/shift_jis_2004.py | 0 .../StdLib/Lib/encodings/shift_jisx0213.py | 0 .../StdLib/Lib/encodings/tis_620.py | 0 .../StdLib/Lib/encodings/undefined.py | 0 .../StdLib/Lib/encodings/unicode_escape.py | 0 .../StdLib/Lib/encodings/unicode_internal.py | 0 .../StdLib/Lib/encodings/utf_16.py | 0 .../StdLib/Lib/encodings/utf_16_be.py | 0 .../StdLib/Lib/encodings/utf_16_le.py | 0 .../StdLib/Lib/encodings/utf_32.py | 0 .../StdLib/Lib/encodings/utf_32_be.py | 0 .../StdLib/Lib/encodings/utf_32_le.py | 0 .../StdLib/Lib/encodings/utf_7.py | 0 .../StdLib/Lib/encodings/utf_8.py | 0 .../StdLib/Lib/encodings/utf_8_sig.py | 0 .../StdLib/Lib/encodings/uu_codec.py | 0 .../StdLib/Lib/encodings/zlib_codec.py | 0 .../StdLib/Lib/ensurepip/__init__.py | 0 .../StdLib/Lib/ensurepip/__main__.py | 0 .../_bundled/pip-18.1-py2.py3-none-any.whl | Bin .../_bundled/setuptools-40.6.2-py2.py3-none-any.whl | Bin .../StdLib/Lib/ensurepip/_uninstall.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/enum.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/filecmp.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/fileinput.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/fnmatch.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/formatter.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/fractions.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/ftplib.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/functools.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/genericpath.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/getopt.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/getpass.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/gettext.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/glob.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/gzip.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/hashlib.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/heapq.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/hmac.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/html/__init__.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/html/entities.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/html/parser.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/http/__init__.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/http/client.py | 0 .../StdLib/Lib/http/cookiejar.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/http/cookies.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/http/server.py | 0 .../StdLib/Lib/idlelib/AutoComplete.py | 0 .../StdLib/Lib/idlelib/AutoCompleteWindow.py | 0 .../StdLib/Lib/idlelib/AutoExpand.py | 0 .../StdLib/Lib/idlelib/Bindings.py | 0 .../StdLib/Lib/idlelib/CREDITS.txt | 0 .../StdLib/Lib/idlelib/CallTipWindow.py | 0 .../StdLib/Lib/idlelib/CallTips.py | 0 .../StdLib/Lib/idlelib/ChangeLog | 0 .../StdLib/Lib/idlelib/ClassBrowser.py | 0 .../StdLib/Lib/idlelib/CodeContext.py | 0 .../StdLib/Lib/idlelib/ColorDelegator.py | 0 .../StdLib/Lib/idlelib/Debugger.py | 0 .../StdLib/Lib/idlelib/Delegator.py | 0 .../StdLib/Lib/idlelib/EditorWindow.py | 0 .../StdLib/Lib/idlelib/FileList.py | 0 .../StdLib/Lib/idlelib/FormatParagraph.py | 0 .../StdLib/Lib/idlelib/GrepDialog.py | 0 .../StdLib/Lib/idlelib/HISTORY.txt | 0 .../StdLib/Lib/idlelib/HyperParser.py | 0 .../StdLib/Lib/idlelib/IOBinding.py | 0 .../StdLib/Lib/idlelib/Icons/folder.gif | Bin .../StdLib/Lib/idlelib/Icons/idle.icns | Bin .../StdLib/Lib/idlelib/Icons/idle.ico | Bin .../StdLib/Lib/idlelib/Icons/idle_16.gif | Bin .../StdLib/Lib/idlelib/Icons/idle_16.png | Bin .../StdLib/Lib/idlelib/Icons/idle_32.gif | Bin .../StdLib/Lib/idlelib/Icons/idle_32.png | Bin .../StdLib/Lib/idlelib/Icons/idle_48.gif | Bin .../StdLib/Lib/idlelib/Icons/idle_48.png | Bin .../StdLib/Lib/idlelib/Icons/minusnode.gif | Bin .../StdLib/Lib/idlelib/Icons/openfolder.gif | Bin .../StdLib/Lib/idlelib/Icons/plusnode.gif | Bin .../StdLib/Lib/idlelib/Icons/python.gif | Bin .../StdLib/Lib/idlelib/Icons/tk.gif | Bin .../StdLib/Lib/idlelib/IdleHistory.py | 0 .../StdLib/Lib/idlelib/MultiCall.py | 0 .../StdLib/Lib/idlelib/MultiStatusBar.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/idlelib/NEWS.txt | 0 .../StdLib/Lib/idlelib/ObjectBrowser.py | 0 .../StdLib/Lib/idlelib/OutputWindow.py | 0 .../StdLib/Lib/idlelib/ParenMatch.py | 0 .../StdLib/Lib/idlelib/PathBrowser.py | 0 .../StdLib/Lib/idlelib/Percolator.py | 0 .../StdLib/Lib/idlelib/PyParse.py | 0 .../StdLib/Lib/idlelib/PyShell.py | 0 .../StdLib/Lib/idlelib/README.txt | 0 .../StdLib/Lib/idlelib/RemoteDebugger.py | 0 .../StdLib/Lib/idlelib/RemoteObjectBrowser.py | 0 .../StdLib/Lib/idlelib/ReplaceDialog.py | 0 .../StdLib/Lib/idlelib/RstripExtension.py | 0 .../StdLib/Lib/idlelib/ScriptBinding.py | 0 .../StdLib/Lib/idlelib/ScrolledList.py | 0 .../StdLib/Lib/idlelib/SearchDialog.py | 0 .../StdLib/Lib/idlelib/SearchDialogBase.py | 0 .../StdLib/Lib/idlelib/SearchEngine.py | 0 .../StdLib/Lib/idlelib/StackViewer.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/idlelib/TODO.txt | 0 .../StdLib/Lib/idlelib/ToolTip.py | 0 .../StdLib/Lib/idlelib/TreeWidget.py | 0 .../StdLib/Lib/idlelib/UndoDelegator.py | 0 .../StdLib/Lib/idlelib/WidgetRedirector.py | 0 .../StdLib/Lib/idlelib/WindowList.py | 0 .../StdLib/Lib/idlelib/ZoomHeight.py | 0 .../StdLib/Lib/idlelib/__init__.py | 0 .../StdLib/Lib/idlelib/__main__.py | 0 .../StdLib/Lib/idlelib/aboutDialog.py | 0 .../StdLib/Lib/idlelib/config-extensions.def | 0 .../StdLib/Lib/idlelib/config-highlight.def | 0 .../StdLib/Lib/idlelib/config-keys.def | 0 .../StdLib/Lib/idlelib/config-main.def | 0 .../StdLib/Lib/idlelib/configDialog.py | 0 .../StdLib/Lib/idlelib/configHandler.py | 0 .../StdLib/Lib/idlelib/configHelpSourceEdit.py | 0 .../StdLib/Lib/idlelib/configSectionNameDialog.py | 0 .../StdLib/Lib/idlelib/dynOptionMenuWidget.py | 0 .../StdLib/Lib/idlelib/extend.txt | 0 .../StdLib/Lib/idlelib/help.html | 0 {Src => Src.GetRenamed}/StdLib/Lib/idlelib/help.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/idlelib/help.txt | 0 {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle.bat | 0 {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle.pyw | 0 .../StdLib/Lib/idlelib/idle_test/README.txt | 0 .../StdLib/Lib/idlelib/idle_test/__init__.py | 0 .../StdLib/Lib/idlelib/idle_test/htest.py | 0 .../StdLib/Lib/idlelib/idle_test/mock_idle.py | 0 .../StdLib/Lib/idlelib/idle_test/mock_tk.py | 0 .../Lib/idlelib/idle_test/test_autocomplete.py | 0 .../StdLib/Lib/idlelib/idle_test/test_autoexpand.py | 0 .../StdLib/Lib/idlelib/idle_test/test_calltips.py | 0 .../Lib/idlelib/idle_test/test_config_name.py | 0 .../Lib/idlelib/idle_test/test_configdialog.py | 0 .../StdLib/Lib/idlelib/idle_test/test_delegator.py | 0 .../StdLib/Lib/idlelib/idle_test/test_editor.py | 0 .../Lib/idlelib/idle_test/test_formatparagraph.py | 0 .../StdLib/Lib/idlelib/idle_test/test_grep.py | 0 .../Lib/idlelib/idle_test/test_hyperparser.py | 0 .../Lib/idlelib/idle_test/test_idlehistory.py | 0 .../StdLib/Lib/idlelib/idle_test/test_io.py | 0 .../StdLib/Lib/idlelib/idle_test/test_parenmatch.py | 0 .../Lib/idlelib/idle_test/test_pathbrowser.py | 0 .../StdLib/Lib/idlelib/idle_test/test_rstrip.py | 0 .../Lib/idlelib/idle_test/test_searchdialogbase.py | 0 .../Lib/idlelib/idle_test/test_searchengine.py | 0 .../StdLib/Lib/idlelib/idle_test/test_text.py | 0 .../StdLib/Lib/idlelib/idle_test/test_textview.py | 0 .../StdLib/Lib/idlelib/idle_test/test_warning.py | 0 .../Lib/idlelib/idle_test/test_widgetredir.py | 0 .../StdLib/Lib/idlelib/idlever.py | 0 .../StdLib/Lib/idlelib/keybindingDialog.py | 0 .../StdLib/Lib/idlelib/macosxSupport.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/idlelib/rpc.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/idlelib/run.py | 0 .../StdLib/Lib/idlelib/tabbedpages.py | 0 .../StdLib/Lib/idlelib/textView.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/imaplib.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/imghdr.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/imp.py | 0 .../StdLib/Lib/importlib/__init__.py | 0 .../StdLib/Lib/importlib/_bootstrap.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/importlib/abc.py | 0 .../StdLib/Lib/importlib/machinery.py | 0 .../StdLib/Lib/importlib/util.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/inspect.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/io.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/ipaddress.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/json/__init__.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/json/decoder.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/json/encoder.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/json/scanner.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/json/tool.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/keyword.py | 0 .../StdLib/Lib/lib2to3/Grammar.txt | 0 .../StdLib/Lib/lib2to3/PatternGrammar.txt | 0 .../StdLib/Lib/lib2to3/__init__.py | 0 .../StdLib/Lib/lib2to3/__main__.py | 0 .../StdLib/Lib/lib2to3/btm_matcher.py | 0 .../StdLib/Lib/lib2to3/btm_utils.py | 0 .../StdLib/Lib/lib2to3/fixer_base.py | 0 .../StdLib/Lib/lib2to3/fixer_util.py | 0 .../StdLib/Lib/lib2to3/fixes/__init__.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_apply.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_asserts.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_basestring.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_buffer.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_callable.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_dict.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_except.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_exec.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_execfile.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_exitfunc.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_filter.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_funcattrs.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_future.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_getcwdu.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_has_key.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_idioms.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_import.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_imports.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_imports2.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_input.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_intern.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_isinstance.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_itertools.py | 0 .../Lib/lib2to3/fixes/fix_itertools_imports.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_long.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_map.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_metaclass.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_methodattrs.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_ne.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_next.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_nonzero.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_numliterals.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_operator.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_paren.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_print.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_raise.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_raw_input.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_reduce.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_reload.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_renames.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_repr.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_set_literal.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_standarderror.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_sys_exc.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_throw.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_tuple_params.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_types.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_unicode.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_urllib.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_ws_comma.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_xrange.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_xreadlines.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_zip.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/main.py | 0 .../StdLib/Lib/lib2to3/patcomp.py | 0 .../StdLib/Lib/lib2to3/pgen2/__init__.py | 0 .../StdLib/Lib/lib2to3/pgen2/conv.py | 0 .../StdLib/Lib/lib2to3/pgen2/driver.py | 0 .../StdLib/Lib/lib2to3/pgen2/grammar.py | 0 .../StdLib/Lib/lib2to3/pgen2/literals.py | 0 .../StdLib/Lib/lib2to3/pgen2/parse.py | 0 .../StdLib/Lib/lib2to3/pgen2/pgen.py | 0 .../StdLib/Lib/lib2to3/pgen2/token.py | 0 .../StdLib/Lib/lib2to3/pgen2/tokenize.py | 0 .../StdLib/Lib/lib2to3/pygram.py | 0 .../StdLib/Lib/lib2to3/pytree.py | 0 .../StdLib/Lib/lib2to3/refactor.py | 0 .../StdLib/Lib/lib2to3/tests/__init__.py | 0 .../StdLib/Lib/lib2to3/tests/__main__.py | 0 .../StdLib/Lib/lib2to3/tests/data/README | 0 .../StdLib/Lib/lib2to3/tests/data/bom.py | 0 .../StdLib/Lib/lib2to3/tests/data/crlf.py | 0 .../Lib/lib2to3/tests/data/different_encoding.py | 0 .../StdLib/Lib/lib2to3/tests/data/false_encoding.py | 0 .../Lib/lib2to3/tests/data/fixers/bad_order.py | 0 .../lib2to3/tests/data/fixers/myfixes}/__init__.py | 0 .../tests/data/fixers/myfixes/fix_explicit.py | 0 .../lib2to3/tests/data/fixers/myfixes/fix_first.py | 0 .../lib2to3/tests/data/fixers/myfixes/fix_last.py | 0 .../lib2to3/tests/data/fixers/myfixes/fix_parrot.py | 0 .../tests/data/fixers/myfixes/fix_preorder.py | 0 .../Lib/lib2to3/tests/data/fixers/no_fixer_cls.py | 0 .../Lib/lib2to3/tests/data/fixers/parrot_example.py | 0 .../Lib/lib2to3/tests/data/infinite_recursion.py | 0 .../Lib/lib2to3/tests/data/py2_test_grammar.py | 0 .../Lib/lib2to3/tests/data/py3_test_grammar.py | 0 .../StdLib/Lib/lib2to3/tests/pytree_idempotency.py | 0 .../StdLib/Lib/lib2to3/tests/support.py | 0 .../StdLib/Lib/lib2to3/tests/test_all_fixers.py | 0 .../StdLib/Lib/lib2to3/tests/test_fixers.py | 0 .../StdLib/Lib/lib2to3/tests/test_main.py | 0 .../StdLib/Lib/lib2to3/tests/test_parser.py | 0 .../StdLib/Lib/lib2to3/tests/test_pytree.py | 0 .../StdLib/Lib/lib2to3/tests/test_refactor.py | 0 .../StdLib/Lib/lib2to3/tests/test_util.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/linecache.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/locale.py | 0 .../StdLib/Lib/logging/__init__.py | 0 .../StdLib/Lib/logging/config.py | 0 .../StdLib/Lib/logging/handlers.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/lzma.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/macpath.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/macurl2path.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/mailbox.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/mailcap.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/mimetypes.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/modulefinder.py | 0 .../StdLib/Lib/msilib/__init__.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/msilib/schema.py | 0 .../StdLib/Lib/msilib/sequence.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/msilib/text.py | 0 .../StdLib/Lib/multiprocessing/__init__.py | 0 .../StdLib/Lib/multiprocessing/connection.py | 0 .../StdLib/Lib/multiprocessing/context.py | 0 .../StdLib/Lib/multiprocessing/dummy/__init__.py | 0 .../StdLib/Lib/multiprocessing/dummy/connection.py | 0 .../StdLib/Lib/multiprocessing/forkserver.py | 0 .../StdLib/Lib/multiprocessing/heap.py | 0 .../StdLib/Lib/multiprocessing/managers.py | 0 .../StdLib/Lib/multiprocessing/pool.py | 0 .../StdLib/Lib/multiprocessing/popen_fork.py | 0 .../StdLib/Lib/multiprocessing/popen_forkserver.py | 0 .../StdLib/Lib/multiprocessing/popen_spawn_posix.py | 0 .../StdLib/Lib/multiprocessing/popen_spawn_win32.py | 0 .../StdLib/Lib/multiprocessing/process.py | 0 .../StdLib/Lib/multiprocessing/queues.py | 0 .../StdLib/Lib/multiprocessing/reduction.py | 0 .../StdLib/Lib/multiprocessing/resource_sharer.py | 0 .../StdLib/Lib/multiprocessing/semaphore_tracker.py | 0 .../StdLib/Lib/multiprocessing/sharedctypes.py | 0 .../StdLib/Lib/multiprocessing/spawn.py | 0 .../StdLib/Lib/multiprocessing/synchronize.py | 0 .../StdLib/Lib/multiprocessing/util.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/netrc.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/nntplib.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/ntpath.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/nturl2path.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/numbers.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/opcode.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/operator.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/optparse.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/os.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/pathlib.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/pdb.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/pickle.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/pickletools.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/pipes.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/pkgutil.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/platform.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/plistlib.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/poplib.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/posixpath.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/pprint.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/profile.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/pstats.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/pty.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/py_compile.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/pyclbr.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/pydoc.py | 0 .../StdLib/Lib/pydoc_data}/__init__.py | 0 .../StdLib/Lib/pydoc_data/_pydoc.css | 0 .../StdLib/Lib/pydoc_data/topics.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/queue.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/quopri.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/random.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/re.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/reprlib.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/rlcompleter.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/runpy.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/sched.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/selectors.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/shelve.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/shlex.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/shutil.py | 0 .../StdLib/Lib/site-packages/README | 0 {Src => Src.GetRenamed}/StdLib/Lib/site.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/smtpd.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/smtplib.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/sndhdr.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/socket.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/socketserver.py | 0 .../StdLib/Lib/sqlite3/__init__.py | 0 .../StdLib/Lib/sqlite3/dbapi2.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/sqlite3/dump.py | 0 .../StdLib/Lib/sqlite3/test}/__init__.py | 0 .../StdLib/Lib/sqlite3/test/dbapi.py | 0 .../StdLib/Lib/sqlite3/test/dump.py | 0 .../StdLib/Lib/sqlite3/test/factory.py | 0 .../StdLib/Lib/sqlite3/test/hooks.py | 0 .../StdLib/Lib/sqlite3/test/regression.py | 0 .../StdLib/Lib/sqlite3/test/transactions.py | 0 .../StdLib/Lib/sqlite3/test/types.py | 0 .../StdLib/Lib/sqlite3/test/userfunctions.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/sre_compile.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/sre_constants.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/sre_parse.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/ssl.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/stat.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/statistics.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/string.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/stringprep.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/struct.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/subprocess.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/sunau.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/symbol.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/symtable.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/sysconfig.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/tabnanny.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/tarfile.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/telnetlib.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/tempfile.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/185test.db | Bin .../StdLib/Lib/test/Sine-1000Hz-300ms.aif | Bin {Src => Src.GetRenamed}/StdLib/Lib/test/__init__.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/__main__.py | 0 .../StdLib/Lib/test/_test_multiprocessing.py | 0 .../StdLib/Lib/test/audiodata/pluck-alaw.aifc | Bin .../StdLib/Lib/test/audiodata/pluck-pcm16.aiff | Bin .../StdLib/Lib/test/audiodata/pluck-pcm16.au | Bin .../StdLib/Lib/test/audiodata/pluck-pcm16.wav | Bin .../StdLib/Lib/test/audiodata/pluck-pcm24.aiff | Bin .../StdLib/Lib/test/audiodata/pluck-pcm24.au | Bin .../StdLib/Lib/test/audiodata/pluck-pcm24.wav | Bin .../StdLib/Lib/test/audiodata/pluck-pcm32.aiff | Bin .../StdLib/Lib/test/audiodata/pluck-pcm32.au | Bin .../StdLib/Lib/test/audiodata/pluck-pcm32.wav | Bin .../StdLib/Lib/test/audiodata/pluck-pcm8.aiff | Bin .../StdLib/Lib/test/audiodata/pluck-pcm8.au | Bin .../StdLib/Lib/test/audiodata/pluck-pcm8.wav | Bin .../StdLib/Lib/test/audiodata/pluck-ulaw.aifc | Bin .../StdLib/Lib/test/audiodata/pluck-ulaw.au | Bin .../StdLib/Lib/test/audiotest.au | Bin .../StdLib/Lib/test/audiotests.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/autotest.py | 0 .../StdLib/Lib/test/bad_coding.py | 0 .../StdLib/Lib/test/bad_coding2.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/badcert.pem | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/badkey.pem | 0 .../StdLib/Lib/test/badsyntax_3131.py | 0 .../StdLib/Lib/test/badsyntax_future10.py | 0 .../StdLib/Lib/test/badsyntax_future3.py | 0 .../StdLib/Lib/test/badsyntax_future4.py | 0 .../StdLib/Lib/test/badsyntax_future5.py | 0 .../StdLib/Lib/test/badsyntax_future6.py | 0 .../StdLib/Lib/test/badsyntax_future7.py | 0 .../StdLib/Lib/test/badsyntax_future8.py | 0 .../StdLib/Lib/test/badsyntax_future9.py | 0 .../StdLib/Lib/test/badsyntax_pep3120.py | 0 .../StdLib/Lib/test/buffer_tests.py | 0 .../StdLib/Lib/test/bytecode_helper.py | 0 .../StdLib/Lib/test/capath/0e4015b9.0 | 0 .../StdLib/Lib/test/capath/4e1295a3.0 | 0 .../StdLib/Lib/test/capath/5ed36f99.0 | 0 .../StdLib/Lib/test/capath/6e88d7b8.0 | 0 .../StdLib/Lib/test/capath/99d0fa06.0 | 0 .../StdLib/Lib/test/capath/ce7b8643.0 | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/cfgparser.1 | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/cfgparser.2 | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/cfgparser.3 | 0 .../StdLib/Lib/test/check_soundcard.vbs | 0 .../StdLib/Lib/test/cjkencodings/big5-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/big5.txt | 0 .../StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/big5hkscs.txt | 0 .../StdLib/Lib/test/cjkencodings/cp949-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/cp949.txt | 0 .../Lib/test/cjkencodings/euc_jisx0213-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/euc_jisx0213.txt | 0 .../StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/euc_jp.txt | 0 .../StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/euc_kr.txt | 0 .../StdLib/Lib/test/cjkencodings/gb18030-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/gb18030.txt | 0 .../StdLib/Lib/test/cjkencodings/gb2312-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/gb2312.txt | 0 .../StdLib/Lib/test/cjkencodings/gbk-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/gbk.txt | 0 .../StdLib/Lib/test/cjkencodings/hz-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/hz.txt | 0 .../Lib/test/cjkencodings/iso2022_jp-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/iso2022_jp.txt | 0 .../Lib/test/cjkencodings/iso2022_kr-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/iso2022_kr.txt | 0 .../StdLib/Lib/test/cjkencodings/johab-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/johab.txt | 0 .../StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/shift_jis.txt | 0 .../Lib/test/cjkencodings/shift_jisx0213-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/shift_jisx0213.txt | 0 .../StdLib/Lib/test/cmath_testcases.txt | 0 .../StdLib/Lib/test/coding20731.py | 0 .../StdLib/Lib/test/crashers/README | 0 .../StdLib/Lib/test/crashers/bogus_code_obj.py | 0 .../StdLib/Lib/test/crashers/gc_inspection.py | 0 .../StdLib/Lib/test/crashers/infinite_loop_re.py | 0 .../Lib/test/crashers/mutation_inside_cyclegc.py | 0 .../StdLib/Lib/test/crashers/recursive_call.py | 0 .../Lib/test/crashers/trace_at_recursion_limit.py | 0 .../StdLib/Lib/test/crashers/underlying_dict.py | 0 .../StdLib/Lib/test/curses_tests.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/data/README | 0 .../StdLib/Lib/test/datetimetester.py | 0 .../StdLib/Lib/test/decimaltestdata/abs.decTest | 0 .../StdLib/Lib/test/decimaltestdata/add.decTest | 0 .../StdLib/Lib/test/decimaltestdata/and.decTest | 0 .../StdLib/Lib/test/decimaltestdata/base.decTest | 0 .../StdLib/Lib/test/decimaltestdata/clamp.decTest | 0 .../StdLib/Lib/test/decimaltestdata/class.decTest | 0 .../StdLib/Lib/test/decimaltestdata/compare.decTest | 0 .../Lib/test/decimaltestdata/comparetotal.decTest | 0 .../Lib/test/decimaltestdata/comparetotmag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/copy.decTest | 0 .../StdLib/Lib/test/decimaltestdata/copyabs.decTest | 0 .../Lib/test/decimaltestdata/copynegate.decTest | 0 .../Lib/test/decimaltestdata/copysign.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddAbs.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddAdd.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddAnd.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddBase.decTest | 0 .../Lib/test/decimaltestdata/ddCanonical.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddClass.decTest | 0 .../Lib/test/decimaltestdata/ddCompare.decTest | 0 .../Lib/test/decimaltestdata/ddCompareSig.decTest | 0 .../Lib/test/decimaltestdata/ddCompareTotal.decTest | 0 .../test/decimaltestdata/ddCompareTotalMag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddCopy.decTest | 0 .../Lib/test/decimaltestdata/ddCopyAbs.decTest | 0 .../Lib/test/decimaltestdata/ddCopyNegate.decTest | 0 .../Lib/test/decimaltestdata/ddCopySign.decTest | 0 .../Lib/test/decimaltestdata/ddDivide.decTest | 0 .../Lib/test/decimaltestdata/ddDivideInt.decTest | 0 .../Lib/test/decimaltestdata/ddEncode.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddFMA.decTest | 0 .../Lib/test/decimaltestdata/ddInvert.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddLogB.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddMax.decTest | 0 .../Lib/test/decimaltestdata/ddMaxMag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddMin.decTest | 0 .../Lib/test/decimaltestdata/ddMinMag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddMinus.decTest | 0 .../Lib/test/decimaltestdata/ddMultiply.decTest | 0 .../Lib/test/decimaltestdata/ddNextMinus.decTest | 0 .../Lib/test/decimaltestdata/ddNextPlus.decTest | 0 .../Lib/test/decimaltestdata/ddNextToward.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddOr.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddPlus.decTest | 0 .../Lib/test/decimaltestdata/ddQuantize.decTest | 0 .../Lib/test/decimaltestdata/ddReduce.decTest | 0 .../Lib/test/decimaltestdata/ddRemainder.decTest | 0 .../test/decimaltestdata/ddRemainderNear.decTest | 0 .../Lib/test/decimaltestdata/ddRotate.decTest | 0 .../Lib/test/decimaltestdata/ddSameQuantum.decTest | 0 .../Lib/test/decimaltestdata/ddScaleB.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddShift.decTest | 0 .../Lib/test/decimaltestdata/ddSubtract.decTest | 0 .../Lib/test/decimaltestdata/ddToIntegral.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddXor.decTest | 0 .../Lib/test/decimaltestdata/decDouble.decTest | 0 .../StdLib/Lib/test/decimaltestdata/decQuad.decTest | 0 .../Lib/test/decimaltestdata/decSingle.decTest | 0 .../StdLib/Lib/test/decimaltestdata/divide.decTest | 0 .../Lib/test/decimaltestdata/divideint.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqAbs.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqAdd.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqAnd.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqBase.decTest | 0 .../Lib/test/decimaltestdata/dqCanonical.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqClass.decTest | 0 .../Lib/test/decimaltestdata/dqCompare.decTest | 0 .../Lib/test/decimaltestdata/dqCompareSig.decTest | 0 .../Lib/test/decimaltestdata/dqCompareTotal.decTest | 0 .../test/decimaltestdata/dqCompareTotalMag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqCopy.decTest | 0 .../Lib/test/decimaltestdata/dqCopyAbs.decTest | 0 .../Lib/test/decimaltestdata/dqCopyNegate.decTest | 0 .../Lib/test/decimaltestdata/dqCopySign.decTest | 0 .../Lib/test/decimaltestdata/dqDivide.decTest | 0 .../Lib/test/decimaltestdata/dqDivideInt.decTest | 0 .../Lib/test/decimaltestdata/dqEncode.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqFMA.decTest | 0 .../Lib/test/decimaltestdata/dqInvert.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqLogB.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqMax.decTest | 0 .../Lib/test/decimaltestdata/dqMaxMag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqMin.decTest | 0 .../Lib/test/decimaltestdata/dqMinMag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqMinus.decTest | 0 .../Lib/test/decimaltestdata/dqMultiply.decTest | 0 .../Lib/test/decimaltestdata/dqNextMinus.decTest | 0 .../Lib/test/decimaltestdata/dqNextPlus.decTest | 0 .../Lib/test/decimaltestdata/dqNextToward.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqOr.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqPlus.decTest | 0 .../Lib/test/decimaltestdata/dqQuantize.decTest | 0 .../Lib/test/decimaltestdata/dqReduce.decTest | 0 .../Lib/test/decimaltestdata/dqRemainder.decTest | 0 .../test/decimaltestdata/dqRemainderNear.decTest | 0 .../Lib/test/decimaltestdata/dqRotate.decTest | 0 .../Lib/test/decimaltestdata/dqSameQuantum.decTest | 0 .../Lib/test/decimaltestdata/dqScaleB.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqShift.decTest | 0 .../Lib/test/decimaltestdata/dqSubtract.decTest | 0 .../Lib/test/decimaltestdata/dqToIntegral.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqXor.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dsBase.decTest | 0 .../Lib/test/decimaltestdata/dsEncode.decTest | 0 .../StdLib/Lib/test/decimaltestdata/exp.decTest | 0 .../StdLib/Lib/test/decimaltestdata/extra.decTest | 0 .../StdLib/Lib/test/decimaltestdata/fma.decTest | 0 .../StdLib/Lib/test/decimaltestdata/inexact.decTest | 0 .../StdLib/Lib/test/decimaltestdata/invert.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ln.decTest | 0 .../StdLib/Lib/test/decimaltestdata/log10.decTest | 0 .../StdLib/Lib/test/decimaltestdata/logb.decTest | 0 .../StdLib/Lib/test/decimaltestdata/max.decTest | 0 .../StdLib/Lib/test/decimaltestdata/maxmag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/min.decTest | 0 .../StdLib/Lib/test/decimaltestdata/minmag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/minus.decTest | 0 .../Lib/test/decimaltestdata/multiply.decTest | 0 .../Lib/test/decimaltestdata/nextminus.decTest | 0 .../Lib/test/decimaltestdata/nextplus.decTest | 0 .../Lib/test/decimaltestdata/nexttoward.decTest | 0 .../StdLib/Lib/test/decimaltestdata/or.decTest | 0 .../StdLib/Lib/test/decimaltestdata/plus.decTest | 0 .../StdLib/Lib/test/decimaltestdata/power.decTest | 0 .../Lib/test/decimaltestdata/powersqrt.decTest | 0 .../Lib/test/decimaltestdata/quantize.decTest | 0 .../Lib/test/decimaltestdata/randomBound32.decTest | 0 .../StdLib/Lib/test/decimaltestdata/randoms.decTest | 0 .../StdLib/Lib/test/decimaltestdata/reduce.decTest | 0 .../Lib/test/decimaltestdata/remainder.decTest | 0 .../Lib/test/decimaltestdata/remainderNear.decTest | 0 .../StdLib/Lib/test/decimaltestdata/rescale.decTest | 0 .../StdLib/Lib/test/decimaltestdata/rotate.decTest | 0 .../Lib/test/decimaltestdata/rounding.decTest | 0 .../Lib/test/decimaltestdata/samequantum.decTest | 0 .../StdLib/Lib/test/decimaltestdata/scaleb.decTest | 0 .../StdLib/Lib/test/decimaltestdata/shift.decTest | 0 .../Lib/test/decimaltestdata/squareroot.decTest | 0 .../Lib/test/decimaltestdata/subtract.decTest | 0 .../StdLib/Lib/test/decimaltestdata/testall.decTest | 0 .../Lib/test/decimaltestdata/tointegral.decTest | 0 .../Lib/test/decimaltestdata/tointegralx.decTest | 0 .../StdLib/Lib/test/decimaltestdata/xor.decTest | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/dh1024.pem | 0 .../StdLib/Lib/test/dis_module.py | 0 .../StdLib/Lib/test/doctest_aliases.py | 0 .../StdLib/Lib/test/double_const.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/empty.vbs | 0 .../StdLib/Lib/test/encoded_modules/__init__.py | 0 .../Lib/test/encoded_modules/module_iso_8859_1.py | 0 .../Lib/test/encoded_modules/module_koi8_r.py | 0 .../StdLib/Lib/test/exception_hierarchy.txt | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/final_a.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/final_b.py | 0 .../StdLib/Lib/test/floating_points.txt | 0 .../StdLib/Lib/test/fork_wait.py | 0 .../StdLib/Lib/test/formatfloat_testcases.txt | 0 .../StdLib/Lib/test/future_test1.py | 0 .../StdLib/Lib/test/future_test2.py | 0 .../StdLib/Lib/test/gdb_sample.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/ieee754.txt | 0 .../StdLib/Lib/test/imghdrdata/python.bmp | Bin .../StdLib/Lib/test/imghdrdata/python.gif | Bin .../StdLib/Lib/test/imghdrdata/python.jpg | Bin .../StdLib/Lib/test/imghdrdata/python.pbm | 0 .../StdLib/Lib/test/imghdrdata/python.pgm | Bin .../StdLib/Lib/test/imghdrdata/python.png | Bin .../StdLib/Lib/test/imghdrdata/python.ppm | Bin .../StdLib/Lib/test/imghdrdata/python.ras | Bin .../StdLib/Lib/test/imghdrdata/python.sgi | Bin .../StdLib/Lib/test/imghdrdata/python.tiff | Bin .../StdLib/Lib/test/imghdrdata/python.xbm | 0 .../StdLib/Lib/test/inspect_fodder.py | 0 .../StdLib/Lib/test/inspect_fodder2.py | 0 .../StdLib/Lib/test/keycert.passwd.pem | 0 .../StdLib/Lib/test}/keycert.pem | 0 .../StdLib/Lib/test/keycert2.pem | 0 .../StdLib/Lib/test/keycert3.pem | 0 .../StdLib/Lib/test/keycert4.pem | 0 .../StdLib/Lib/test/leakers/README.txt | 0 .../StdLib/Lib/test/leakers}/__init__.py | 0 .../StdLib/Lib/test/leakers/test_ctypes.py | 0 .../StdLib/Lib/test/leakers/test_selftype.py | 0 .../StdLib/Lib/test/list_tests.py | 0 .../StdLib/Lib/test/lock_tests.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/mailcap.txt | 0 .../StdLib/Lib/test/make_ssl_certs.py | 0 .../StdLib/Lib/test/mapping_tests.py | 0 .../StdLib/Lib/test/math_testcases.txt | 0 .../StdLib/Lib/test/memory_watchdog.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/mime.types | 0 .../StdLib/Lib/test/mock_socket.py | 0 .../StdLib/Lib/test/mod_generics_cache.py | 0 .../StdLib/Lib/test/mp_fork_bomb.py | 0 .../StdLib/Lib/test/multibytecodec_support.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/nokia.pem | 0 .../StdLib/Lib/test/nullbytecert.pem | 0 .../StdLib/Lib/test/nullcert.pem | 0 .../StdLib/Lib/test/outstanding_bugs.py | 0 .../StdLib/Lib/test/pickletester.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/profilee.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/pstats.pck | Bin .../StdLib/Lib/test/pycacert.pem | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/pycakey.pem | 0 .../StdLib/Lib/test/pyclbr_input.py | 0 .../StdLib/Lib/test/pydoc_mod.py | 0 .../StdLib/Lib/test/pydocfodder.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/pystone.py | 0 .../StdLib/Lib/test/randv2_32.pck | 0 .../StdLib/Lib/test/randv2_64.pck | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/randv3.pck | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/re_tests.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/regrtest.py | 0 .../StdLib/Lib/test/relimport.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/reperf.py | 0 .../StdLib/Lib/test/revocation.crl | 0 .../StdLib/Lib/test/sample_doctest.py | 0 .../StdLib/Lib/test/sample_doctest_no_docstrings.py | 0 .../StdLib/Lib/test/sample_doctest_no_doctests.py | 0 .../StdLib/Lib/test/script_helper.py | 0 .../StdLib/Lib/test/selfsigned_pythontestdotnet.pem | 0 .../StdLib/Lib/test/seq_tests.py | 0 .../StdLib/Lib/test/sgml_input.html | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/sha256.pem | 0 .../StdLib/Lib/test/sndhdrdata/README | 0 .../StdLib/Lib/test/sndhdrdata/sndhdr.8svx | Bin .../StdLib/Lib/test/sndhdrdata/sndhdr.aifc | Bin .../StdLib/Lib/test/sndhdrdata/sndhdr.aiff | Bin .../StdLib/Lib/test/sndhdrdata/sndhdr.au | Bin .../StdLib/Lib/test/sndhdrdata/sndhdr.hcom | Bin .../StdLib/Lib/test/sndhdrdata/sndhdr.sndt | Bin .../StdLib/Lib/test/sndhdrdata/sndhdr.voc | Bin .../StdLib/Lib/test/sndhdrdata/sndhdr.wav | Bin {Src => Src.GetRenamed}/StdLib/Lib/test/sortperf.py | 0 .../StdLib/Lib/test/ssl_cert.pem | 0 .../StdLib/Lib/test/ssl_key.passwd.pem | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/ssl_key.pem | 0 .../StdLib/Lib/test/ssl_servers.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/ssltests.py | 0 .../StdLib/Lib/test/string_tests.py | 0 .../StdLib/Lib/test/subprocessdata/fd_status.py | 0 .../StdLib/Lib/test/subprocessdata/input_reader.py | 0 .../StdLib/Lib/test/subprocessdata/qcat.py | 0 .../StdLib/Lib/test/subprocessdata/qgrep.py | 0 .../Lib/test/subprocessdata/sigchild_ignore.py | 0 .../StdLib/Lib/test/support/__init__.py | 0 .../StdLib/Lib/test/talos-2019-0758.pem | 0 .../StdLib/Lib/test/test___all__.py | 0 .../StdLib/Lib/test/test___future__.py | 0 .../StdLib/Lib/test/test__locale.py | 0 .../StdLib/Lib/test/test__opcode.py | 0 .../StdLib/Lib/test/test__osx_support.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_abc.py | 0 .../StdLib/Lib/test/test_abstract_numbers.py | 0 .../StdLib/Lib/test/test_aifc.py | 0 .../StdLib/Lib/test/test_argparse.py | 0 .../StdLib/Lib/test/test_array.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_ast.py | 0 .../StdLib/Lib/test/test_asynchat.py | 0 .../StdLib/Lib/test/test_asyncio/__init__.py | 0 .../StdLib/Lib/test/test_asyncio/__main__.py | 0 .../StdLib/Lib/test/test_asyncio/echo.py | 0 .../StdLib/Lib/test/test_asyncio/echo2.py | 0 .../StdLib/Lib/test/test_asyncio/echo3.py | 0 .../StdLib/Lib/test/test_asyncio/keycert3.pem | 0 .../StdLib/Lib/test/test_asyncio/pycacert.pem | 0 .../StdLib/Lib/test/test_asyncio/ssl_cert.pem | 0 .../StdLib/Lib/test/test_asyncio/ssl_key.pem | 0 .../Lib/test/test_asyncio/test_base_events.py | 0 .../StdLib/Lib/test/test_asyncio/test_events.py | 0 .../StdLib/Lib/test/test_asyncio/test_futures.py | 0 .../StdLib/Lib/test/test_asyncio/test_locks.py | 0 .../Lib/test/test_asyncio/test_proactor_events.py | 0 .../StdLib/Lib/test/test_asyncio/test_queues.py | 0 .../Lib/test/test_asyncio/test_selector_events.py | 0 .../StdLib/Lib/test/test_asyncio/test_sslproto.py | 0 .../StdLib/Lib/test/test_asyncio/test_streams.py | 0 .../StdLib/Lib/test/test_asyncio/test_subprocess.py | 0 .../StdLib/Lib/test/test_asyncio/test_tasks.py | 0 .../StdLib/Lib/test/test_asyncio/test_transports.py | 0 .../Lib/test/test_asyncio/test_unix_events.py | 0 .../Lib/test/test_asyncio/test_windows_events.py | 0 .../Lib/test/test_asyncio/test_windows_utils.py | 0 .../StdLib/Lib/test/test_asyncore.py | 0 .../StdLib/Lib/test/test_atexit.py | 0 .../StdLib/Lib/test/test_audioop.py | 0 .../StdLib/Lib/test/test_augassign.py | 0 .../StdLib/Lib/test/test_base64.py | 0 .../StdLib/Lib/test/test_bigaddrspace.py | 0 .../StdLib/Lib/test/test_bigmem.py | 0 .../StdLib/Lib/test/test_binascii.py | 0 .../StdLib/Lib/test/test_binhex.py | 0 .../StdLib/Lib/test/test_binop.py | 0 .../StdLib/Lib/test/test_bisect.py | 0 .../StdLib/Lib/test/test_bool.py | 0 .../StdLib/Lib/test/test_buffer.py | 0 .../StdLib/Lib/test/test_bufio.py | 0 .../StdLib/Lib/test/test_builtin.py | 0 .../StdLib/Lib/test/test_bytes.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_bz2.py | 0 .../StdLib/Lib/test/test_calendar.py | 0 .../StdLib/Lib/test/test_call.py | 0 .../StdLib/Lib/test/test_capi.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_cgi.py | 0 .../StdLib/Lib/test/test_cgitb.py | 0 .../StdLib/Lib/test/test_charmapcodec.py | 0 .../StdLib/Lib/test/test_class.py | 0 .../StdLib/Lib/test/test_cmath.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_cmd.py | 0 .../StdLib/Lib/test/test_cmd_line.py | 0 .../StdLib/Lib/test/test_cmd_line_script.py | 0 .../StdLib/Lib/test/test_code.py | 0 .../StdLib/Lib/test/test_code_module.py | 0 .../StdLib/Lib/test/test_codeccallbacks.py | 0 .../StdLib/Lib/test/test_codecencodings_cn.py | 0 .../StdLib/Lib/test/test_codecencodings_hk.py | 0 .../StdLib/Lib/test/test_codecencodings_iso2022.py | 0 .../StdLib/Lib/test/test_codecencodings_jp.py | 0 .../StdLib/Lib/test/test_codecencodings_kr.py | 0 .../StdLib/Lib/test/test_codecencodings_tw.py | 0 .../StdLib/Lib/test/test_codecmaps_cn.py | 0 .../StdLib/Lib/test/test_codecmaps_hk.py | 0 .../StdLib/Lib/test/test_codecmaps_jp.py | 0 .../StdLib/Lib/test/test_codecmaps_kr.py | 0 .../StdLib/Lib/test/test_codecmaps_tw.py | 0 .../StdLib/Lib/test/test_codecs.py | 0 .../StdLib/Lib/test/test_codeop.py | 0 .../StdLib/Lib/test/test_collections.py | 0 .../StdLib/Lib/test/test_colorsys.py | 0 .../StdLib/Lib/test/test_compare.py | 0 .../StdLib/Lib/test/test_compile.py | 0 .../StdLib/Lib/test/test_compileall.py | 0 .../StdLib/Lib/test/test_complex.py | 0 .../StdLib/Lib/test/test_concurrent_futures.py | 0 .../StdLib/Lib/test/test_configparser.py | 0 .../StdLib/Lib/test/test_contains.py | 0 .../StdLib/Lib/test/test_contextlib.py | 0 .../StdLib/Lib/test/test_copy.py | 0 .../StdLib/Lib/test/test_copyreg.py | 0 .../StdLib/Lib/test/test_cprofile.py | 0 .../StdLib/Lib/test/test_crashers.py | 0 .../StdLib/Lib/test/test_crypt.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_csv.py | 0 .../StdLib/Lib/test/test_ctypes.py | 0 .../StdLib/Lib/test/test_curses.py | 0 .../StdLib/Lib/test/test_datetime.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_dbm.py | 0 .../StdLib/Lib/test/test_dbm_dumb.py | 0 .../StdLib/Lib/test/test_dbm_gnu.py | 0 .../StdLib/Lib/test/test_dbm_ndbm.py | 0 .../StdLib/Lib/test/test_decimal.py | 0 .../StdLib/Lib/test/test_decorators.py | 0 .../StdLib/Lib/test/test_defaultdict.py | 0 .../StdLib/Lib/test/test_deque.py | 0 .../StdLib/Lib/test/test_descr.py | 0 .../StdLib/Lib/test/test_descrtut.py | 0 .../StdLib/Lib/test/test_devpoll.py | 0 .../StdLib/Lib/test/test_dict.py | 0 .../StdLib/Lib/test/test_dictcomps.py | 0 .../StdLib/Lib/test/test_dictviews.py | 0 .../StdLib/Lib/test/test_difflib.py | 0 .../StdLib/Lib/test/test_difflib_expect.html | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_dis.py | 0 .../StdLib/Lib/test/test_distutils.py | 0 .../StdLib/Lib/test/test_doctest.py | 0 .../StdLib/Lib/test/test_doctest.txt | 0 .../StdLib/Lib/test/test_doctest2.py | 0 .../StdLib/Lib/test/test_doctest2.txt | 0 .../StdLib/Lib/test/test_doctest3.txt | 0 .../StdLib/Lib/test/test_doctest4.txt | 0 .../StdLib/Lib/test/test_docxmlrpc.py | 0 .../StdLib/Lib/test/test_dummy_thread.py | 0 .../StdLib/Lib/test/test_dummy_threading.py | 0 .../StdLib/Lib/test/test_dynamic.py | 0 .../StdLib/Lib/test/test_dynamicclassattribute.py | 0 .../StdLib/Lib/test/test_email/__init__.py | 0 .../StdLib/Lib/test/test_email/__main__.py | 0 .../StdLib/Lib/test/test_email/data/PyBanner048.gif | Bin .../StdLib/Lib/test/test_email/data/audiotest.au | Bin .../StdLib/Lib/test/test_email/data/msg_01.txt | 0 .../StdLib/Lib/test/test_email/data/msg_02.txt | 0 .../StdLib/Lib/test/test_email/data/msg_03.txt | 0 .../StdLib/Lib/test/test_email/data/msg_04.txt | 0 .../StdLib/Lib/test/test_email/data/msg_05.txt | 0 .../StdLib/Lib/test/test_email/data/msg_06.txt | 0 .../StdLib/Lib/test/test_email/data/msg_07.txt | 0 .../StdLib/Lib/test/test_email/data/msg_08.txt | 0 .../StdLib/Lib/test/test_email/data/msg_09.txt | 0 .../StdLib/Lib/test/test_email/data/msg_10.txt | 0 .../StdLib/Lib/test/test_email/data/msg_11.txt | 0 .../StdLib/Lib/test/test_email/data/msg_12.txt | 0 .../StdLib/Lib/test/test_email/data/msg_12a.txt | 0 .../StdLib/Lib/test/test_email/data/msg_13.txt | 0 .../StdLib/Lib/test/test_email/data/msg_14.txt | 0 .../StdLib/Lib/test/test_email/data/msg_15.txt | 0 .../StdLib/Lib/test/test_email/data/msg_16.txt | 0 .../StdLib/Lib/test/test_email/data/msg_17.txt | 0 .../StdLib/Lib/test/test_email/data/msg_18.txt | 0 .../StdLib/Lib/test/test_email/data/msg_19.txt | 0 .../StdLib/Lib/test/test_email/data/msg_20.txt | 0 .../StdLib/Lib/test/test_email/data/msg_21.txt | 0 .../StdLib/Lib/test/test_email/data/msg_22.txt | 0 .../StdLib/Lib/test/test_email/data/msg_23.txt | 0 .../StdLib/Lib/test/test_email/data/msg_24.txt | 0 .../StdLib/Lib/test/test_email/data/msg_25.txt | 0 .../StdLib/Lib/test/test_email/data/msg_26.txt | 0 .../StdLib/Lib/test/test_email/data/msg_27.txt | 0 .../StdLib/Lib/test/test_email/data/msg_28.txt | 0 .../StdLib/Lib/test/test_email/data/msg_29.txt | 0 .../StdLib/Lib/test/test_email/data/msg_30.txt | 0 .../StdLib/Lib/test/test_email/data/msg_31.txt | 0 .../StdLib/Lib/test/test_email/data/msg_32.txt | 0 .../StdLib/Lib/test/test_email/data/msg_33.txt | 0 .../StdLib/Lib/test/test_email/data/msg_34.txt | 0 .../StdLib/Lib/test/test_email/data/msg_35.txt | 0 .../StdLib/Lib/test/test_email/data/msg_36.txt | 0 .../StdLib/Lib/test/test_email/data/msg_37.txt | 0 .../StdLib/Lib/test/test_email/data/msg_38.txt | 0 .../StdLib/Lib/test/test_email/data/msg_39.txt | 0 .../StdLib/Lib/test/test_email/data/msg_40.txt | 0 .../StdLib/Lib/test/test_email/data/msg_41.txt | 0 .../StdLib/Lib/test/test_email/data/msg_42.txt | 0 .../StdLib/Lib/test/test_email/data/msg_43.txt | 0 .../StdLib/Lib/test/test_email/data/msg_44.txt | 0 .../StdLib/Lib/test/test_email/data/msg_45.txt | 0 .../StdLib/Lib/test/test_email/data/msg_46.txt | 0 .../Lib/test/test_email/test__encoded_words.py | 0 .../test/test_email/test__header_value_parser.py | 0 .../StdLib/Lib/test/test_email/test_asian_codecs.py | 0 .../Lib/test/test_email/test_contentmanager.py | 0 .../Lib/test/test_email/test_defect_handling.py | 0 .../StdLib/Lib/test/test_email/test_email.py | 0 .../StdLib/Lib/test/test_email/test_generator.py | 0 .../Lib/test/test_email/test_headerregistry.py | 0 .../StdLib/Lib/test/test_email/test_inversion.py | 0 .../StdLib/Lib/test/test_email/test_message.py | 0 .../StdLib/Lib/test/test_email/test_parser.py | 0 .../StdLib/Lib/test/test_email/test_pickleable.py | 0 .../StdLib/Lib/test/test_email/test_policy.py | 0 .../StdLib/Lib/test/test_email/test_utils.py | 0 .../StdLib/Lib/test/test_email/torture_test.py | 0 .../StdLib/Lib/test/test_ensurepip.py | 0 .../StdLib/Lib/test/test_enum.py | 0 .../StdLib/Lib/test/test_enumerate.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_eof.py | 0 .../StdLib/Lib/test/test_epoll.py | 0 .../StdLib/Lib/test/test_errno.py | 0 .../StdLib/Lib/test/test_exception_variations.py | 0 .../StdLib/Lib/test/test_exceptions.py | 0 .../StdLib/Lib/test/test_extcall.py | 0 .../StdLib/Lib/test/test_faulthandler.py | 0 .../StdLib/Lib/test/test_fcntl.py | 0 .../StdLib/Lib/test/test_file.py | 0 .../StdLib/Lib/test/test_file_eintr.py | 0 .../StdLib/Lib/test/test_filecmp.py | 0 .../StdLib/Lib/test/test_fileinput.py | 0 .../StdLib/Lib/test/test_fileio.py | 0 .../StdLib/Lib/test/test_finalization.py | 0 .../StdLib/Lib/test/test_float.py | 0 .../StdLib/Lib/test/test_flufl.py | 0 .../StdLib/Lib/test/test_fnmatch.py | 0 .../StdLib/Lib/test/test_fork1.py | 0 .../StdLib/Lib/test/test_format.py | 0 .../StdLib/Lib/test/test_fractions.py | 0 .../StdLib/Lib/test/test_frame.py | 0 .../StdLib/Lib/test/test_fstring.py | 0 .../StdLib/Lib/test/test_ftplib.py | 0 .../StdLib/Lib/test/test_funcattrs.py | 0 .../StdLib/Lib/test/test_functools.py | 0 .../StdLib/Lib/test/test_future.py | 0 .../StdLib/Lib/test/test_future3.py | 0 .../StdLib/Lib/test/test_future4.py | 0 .../StdLib/Lib/test/test_future5.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_gc.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_gdb.py | 0 .../StdLib/Lib/test/test_generators.py | 0 .../StdLib/Lib/test/test_genericpath.py | 0 .../StdLib/Lib/test/test_genexps.py | 0 .../StdLib/Lib/test/test_getargs2.py | 0 .../StdLib/Lib/test/test_getopt.py | 0 .../StdLib/Lib/test/test_getpass.py | 0 .../StdLib/Lib/test/test_gettext.py | 0 .../StdLib/Lib/test/test_glob.py | 0 .../StdLib/Lib/test/test_global.py | 0 .../StdLib/Lib/test/test_grammar.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_grp.py | 0 .../StdLib/Lib/test/test_gzip.py | 0 .../StdLib/Lib/test/test_hash.py | 0 .../StdLib/Lib/test/test_hashlib.py | 0 .../StdLib/Lib/test/test_heapq.py | 0 .../StdLib/Lib/test/test_hmac.py | 0 .../StdLib/Lib/test/test_html.py | 0 .../StdLib/Lib/test/test_htmlparser.py | 0 .../StdLib/Lib/test/test_http_cookiejar.py | 0 .../StdLib/Lib/test/test_http_cookies.py | 0 .../StdLib/Lib/test/test_httplib.py | 0 .../StdLib/Lib/test/test_httpservers.py | 0 .../StdLib/Lib/test/test_idle.py | 0 .../StdLib/Lib/test/test_imaplib.py | 0 .../StdLib/Lib/test/test_imghdr.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_imp.py | 0 .../StdLib/Lib/test/test_import.py | 0 .../StdLib/Lib/test/test_importlib/__init__.py | 0 .../StdLib/Lib/test/test_importlib/__main__.py | 0 .../StdLib/Lib/test/test_importlib/abc.py | 0 .../Lib/test/test_importlib/builtin/__init__.py | 0 .../Lib/test/test_importlib/builtin/__main__.py | 0 .../Lib/test/test_importlib/builtin/test_finder.py | 0 .../Lib/test/test_importlib/builtin/test_loader.py | 0 .../StdLib/Lib/test/test_importlib/builtin/util.py | 0 .../Lib/test/test_importlib/extension/__init__.py | 0 .../Lib/test/test_importlib/extension/__main__.py | 0 .../extension/test_case_sensitivity.py | 0 .../test/test_importlib/extension/test_finder.py | 0 .../test/test_importlib/extension/test_loader.py | 0 .../test/test_importlib/extension/test_path_hook.py | 0 .../Lib/test/test_importlib/extension/util.py | 0 .../Lib/test/test_importlib/frozen/__init__.py | 0 .../Lib/test/test_importlib/frozen/__main__.py | 0 .../Lib/test/test_importlib/frozen/test_finder.py | 0 .../Lib/test/test_importlib/frozen/test_loader.py | 0 .../Lib/test/test_importlib/import_/__init__.py | 0 .../Lib/test/test_importlib/import_/__main__.py | 0 .../test/test_importlib/import_/test___loader__.py | 0 .../test/test_importlib/import_/test___package__.py | 0 .../Lib/test/test_importlib/import_/test_api.py | 0 .../Lib/test/test_importlib/import_/test_caching.py | 0 .../test/test_importlib/import_/test_fromlist.py | 0 .../test/test_importlib/import_/test_meta_path.py | 0 .../test/test_importlib/import_/test_packages.py | 0 .../Lib/test/test_importlib/import_/test_path.py | 0 .../test_importlib/import_/test_relative_imports.py | 0 .../StdLib/Lib/test/test_importlib/import_/util.py | 0 .../namespace_pkgs/both_portions/foo/one.py | 0 .../namespace_pkgs/both_portions/foo/two.py | 0 .../namespace_pkgs/missing_directory.zip | Bin .../module_and_namespace_package/a_test.py | 0 .../module_and_namespace_package/a_test/empty | 0 .../namespace_pkgs/nested_portion1.zip | Bin .../not_a_namespace_pkg/foo}/__init__.py | 0 .../namespace_pkgs/not_a_namespace_pkg/foo/one.py | 0 .../namespace_pkgs/portion1/foo/one.py | 0 .../namespace_pkgs/portion2/foo/two.py | 0 .../namespace_pkgs/project1/parent/child/one.py | 0 .../namespace_pkgs/project2/parent/child/two.py | 0 .../namespace_pkgs/project3/parent/child/three.py | 0 .../namespace_pkgs/top_level_portion1.zip | Bin .../StdLib/Lib/test/test_importlib/regrtest.py | 0 .../Lib/test/test_importlib/source/__init__.py | 0 .../Lib/test/test_importlib/source/__main__.py | 0 .../test_importlib/source/test_case_sensitivity.py | 0 .../test/test_importlib/source/test_file_loader.py | 0 .../Lib/test/test_importlib/source/test_finder.py | 0 .../test/test_importlib/source/test_path_hook.py | 0 .../test_importlib/source/test_source_encoding.py | 0 .../StdLib/Lib/test/test_importlib/source/util.py | 0 .../StdLib/Lib/test/test_importlib/test_abc.py | 0 .../StdLib/Lib/test/test_importlib/test_api.py | 0 .../StdLib/Lib/test/test_importlib/test_locks.py | 0 .../Lib/test/test_importlib/test_namespace_pkgs.py | 0 .../StdLib/Lib/test/test_importlib/test_spec.py | 0 .../StdLib/Lib/test/test_importlib/test_util.py | 0 .../StdLib/Lib/test/test_importlib/test_windows.py | 0 .../StdLib/Lib/test/test_importlib/util.py | 0 .../StdLib/Lib/test/test_index.py | 0 .../StdLib/Lib/test/test_inspect.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_int.py | 0 .../StdLib/Lib/test/test_int_literal.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_io.py | 0 .../StdLib/Lib/test/test_ioctl.py | 0 .../StdLib/Lib/test/test_ipaddress.py | 0 .../StdLib/Lib/test/test_isinstance.py | 0 .../StdLib/Lib/test/test_iter.py | 0 .../StdLib/Lib/test/test_iterlen.py | 0 .../StdLib/Lib/test/test_itertools.py | 0 .../StdLib/Lib/test/test_json/__init__.py | 0 .../StdLib/Lib/test/test_json/__main__.py | 0 .../StdLib/Lib/test/test_json/test_decode.py | 0 .../StdLib/Lib/test/test_json/test_default.py | 0 .../StdLib/Lib/test/test_json/test_dump.py | 0 .../test/test_json/test_encode_basestring_ascii.py | 0 .../StdLib/Lib/test/test_json/test_enum.py | 0 .../StdLib/Lib/test/test_json/test_fail.py | 0 .../StdLib/Lib/test/test_json/test_float.py | 0 .../StdLib/Lib/test/test_json/test_indent.py | 0 .../StdLib/Lib/test/test_json/test_pass1.py | 0 .../StdLib/Lib/test/test_json/test_pass2.py | 0 .../StdLib/Lib/test/test_json/test_pass3.py | 0 .../StdLib/Lib/test/test_json/test_recursion.py | 0 .../StdLib/Lib/test/test_json/test_scanstring.py | 0 .../StdLib/Lib/test/test_json/test_separators.py | 0 .../StdLib/Lib/test/test_json/test_speedups.py | 0 .../StdLib/Lib/test/test_json/test_tool.py | 0 .../StdLib/Lib/test/test_json/test_unicode.py | 0 .../StdLib/Lib/test/test_keyword.py | 0 .../StdLib/Lib/test/test_keywordonlyarg.py | 0 .../StdLib/Lib/test/test_kqueue.py | 0 .../StdLib/Lib/test/test_largefile.py | 0 .../StdLib/Lib/test/test_lib2to3.py | 0 .../StdLib/Lib/test/test_linecache.py | 0 .../StdLib/Lib/test/test_list.py | 0 .../StdLib/Lib/test/test_listcomps.py | 0 .../StdLib/Lib/test/test_locale.py | 0 .../StdLib/Lib/test/test_logging.py | 0 .../StdLib/Lib/test/test_long.py | 0 .../StdLib/Lib/test/test_longexp.py | 0 .../StdLib/Lib/test/test_lzma.py | 0 .../StdLib/Lib/test/test_macpath.py | 0 .../StdLib/Lib/test/test_macurl2path.py | 0 .../StdLib/Lib/test/test_mailbox.py | 0 .../StdLib/Lib/test/test_mailcap.py | 0 .../StdLib/Lib/test/test_marshal.py | 0 .../StdLib/Lib/test/test_math.py | 0 .../StdLib/Lib/test/test_memoryio.py | 0 .../StdLib/Lib/test/test_memoryview.py | 0 .../StdLib/Lib/test/test_metaclass.py | 0 .../StdLib/Lib/test/test_mimetypes.py | 0 .../StdLib/Lib/test/test_minidom.py | 0 .../StdLib/Lib/test/test_mmap.py | 0 .../StdLib/Lib/test/test_module.py | 0 .../StdLib/Lib/test/test_modulefinder.py | 0 .../StdLib/Lib/test/test_msilib.py | 0 .../StdLib/Lib/test/test_multibytecodec.py | 0 .../StdLib/Lib/test/test_multiprocessing_fork.py | 0 .../Lib/test/test_multiprocessing_forkserver.py | 0 .../Lib/test/test_multiprocessing_main_handling.py | 0 .../StdLib/Lib/test/test_multiprocessing_spawn.py | 0 .../StdLib/Lib/test/test_netrc.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_nis.py | 0 .../StdLib/Lib/test/test_nntplib.py | 0 .../StdLib/Lib/test/test_normalization.py | 0 .../StdLib/Lib/test/test_ntpath.py | 0 .../StdLib/Lib/test/test_numeric_tower.py | 0 .../StdLib/Lib/test/test_opcodes.py | 0 .../StdLib/Lib/test/test_openpty.py | 0 .../StdLib/Lib/test/test_operator.py | 0 .../StdLib/Lib/test/test_optparse.py | 0 .../StdLib/Lib/test/test_ordered_dict.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_os.py | 0 .../StdLib/Lib/test/test_ossaudiodev.py | 0 .../StdLib/Lib/test/test_osx_env.py | 0 .../StdLib/Lib/test/test_parser.py | 0 .../StdLib/Lib/test/test_pathlib.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_pdb.py | 0 .../StdLib/Lib/test/test_peepholer.py | 0 .../StdLib/Lib/test/test_pep247.py | 0 .../StdLib/Lib/test/test_pep277.py | 0 .../StdLib/Lib/test/test_pep292.py | 0 .../StdLib/Lib/test/test_pep3120.py | 0 .../StdLib/Lib/test/test_pep3131.py | 0 .../StdLib/Lib/test/test_pep3151.py | 0 .../StdLib/Lib/test/test_pep352.py | 0 .../StdLib/Lib/test/test_pep380.py | 0 .../StdLib/Lib/test/test_pep479.py | 0 .../StdLib/Lib/test/test_pickle.py | 0 .../StdLib/Lib/test/test_pickletools.py | 0 .../StdLib/Lib/test/test_pipes.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_pkg.py | 0 .../StdLib/Lib/test/test_pkgimport.py | 0 .../StdLib/Lib/test/test_pkgutil.py | 0 .../StdLib/Lib/test/test_platform.py | 0 .../StdLib/Lib/test/test_plistlib.py | 0 .../StdLib/Lib/test/test_poll.py | 0 .../StdLib/Lib/test/test_popen.py | 0 .../StdLib/Lib/test/test_poplib.py | 0 .../StdLib/Lib/test/test_posix.py | 0 .../StdLib/Lib/test/test_posixpath.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_pow.py | 0 .../StdLib/Lib/test/test_pprint.py | 0 .../StdLib/Lib/test/test_print.py | 0 .../StdLib/Lib/test/test_profile.py | 0 .../StdLib/Lib/test/test_property.py | 0 .../StdLib/Lib/test/test_pstats.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_pty.py | 0 .../StdLib/Lib/test/test_pulldom.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_pwd.py | 0 .../StdLib/Lib/test/test_py_compile.py | 0 .../StdLib/Lib/test/test_pyclbr.py | 0 .../StdLib/Lib/test/test_pydoc.py | 0 .../StdLib/Lib/test/test_pyexpat.py | 0 .../StdLib/Lib/test/test_queue.py | 0 .../StdLib/Lib/test/test_quopri.py | 0 .../StdLib/Lib/test/test_raise.py | 0 .../StdLib/Lib/test/test_random.py | 0 .../StdLib/Lib/test/test_range.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_re.py | 0 .../StdLib/Lib/test/test_readline.py | 0 .../StdLib/Lib/test/test_regrtest.py | 0 .../StdLib/Lib/test/test_reprlib.py | 0 .../StdLib/Lib/test/test_resource.py | 0 .../StdLib/Lib/test/test_richcmp.py | 0 .../StdLib/Lib/test/test_rlcompleter.py | 0 .../StdLib/Lib/test/test_robotparser.py | 0 .../StdLib/Lib/test/test_runpy.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_sax.py | 0 .../StdLib/Lib/test/test_sched.py | 0 .../StdLib/Lib/test/test_scope.py | 0 .../StdLib/Lib/test/test_script_helper.py | 0 .../StdLib/Lib/test/test_select.py | 0 .../StdLib/Lib/test/test_selectors.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_set.py | 0 .../StdLib/Lib/test/test_setcomps.py | 0 .../StdLib/Lib/test/test_shelve.py | 0 .../StdLib/Lib/test/test_shlex.py | 0 .../StdLib/Lib/test/test_shutil.py | 0 .../StdLib/Lib/test/test_signal.py | 0 .../StdLib/Lib/test/test_site.py | 0 .../StdLib/Lib/test/test_slice.py | 0 .../StdLib/Lib/test/test_smtpd.py | 0 .../StdLib/Lib/test/test_smtplib.py | 0 .../StdLib/Lib/test/test_smtpnet.py | 0 .../StdLib/Lib/test/test_sndhdr.py | 0 .../StdLib/Lib/test/test_socket.py | 0 .../StdLib/Lib/test/test_socketserver.py | 0 .../StdLib/Lib/test/test_sort.py | 0 .../StdLib/Lib/test/test_source_encoding.py | 0 .../StdLib/Lib/test/test_spwd.py | 0 .../StdLib/Lib/test/test_sqlite.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_ssl.py | 0 .../StdLib/Lib/test/test_startfile.py | 0 .../StdLib/Lib/test/test_stat.py | 0 .../StdLib/Lib/test/test_statistics.py | 0 .../StdLib/Lib/test/test_strftime.py | 0 .../StdLib/Lib/test/test_string.py | 0 .../StdLib/Lib/test/test_stringprep.py | 0 .../StdLib/Lib/test/test_strlit.py | 0 .../StdLib/Lib/test/test_strptime.py | 0 .../StdLib/Lib/test/test_strtod.py | 0 .../StdLib/Lib/test/test_struct.py | 0 .../StdLib/Lib/test/test_structmembers.py | 0 .../StdLib/Lib/test/test_structseq.py | 0 .../StdLib/Lib/test/test_subprocess.py | 0 .../StdLib/Lib/test/test_sunau.py | 0 .../StdLib/Lib/test/test_sundry.py | 0 .../StdLib/Lib/test/test_super.py | 0 .../StdLib/Lib/test/test_support.py | 0 .../StdLib/Lib/test/test_symtable.py | 0 .../StdLib/Lib/test/test_syntax.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_sys.py | 0 .../StdLib/Lib/test/test_sys_setprofile.py | 0 .../StdLib/Lib/test/test_sys_settrace.py | 0 .../StdLib/Lib/test/test_sysconfig.py | 0 .../StdLib/Lib/test/test_syslog.py | 0 .../StdLib/Lib/test/test_tarfile.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_tcl.py | 0 .../StdLib/Lib/test/test_telnetlib.py | 0 .../StdLib/Lib/test/test_tempfile.py | 0 .../StdLib/Lib/test/test_textwrap.py | 0 .../StdLib/Lib/test/test_thread.py | 0 .../StdLib/Lib/test/test_threaded_import.py | 0 .../StdLib/Lib/test/test_threadedtempfile.py | 0 .../StdLib/Lib/test/test_threading.py | 0 .../StdLib/Lib/test/test_threading_local.py | 0 .../StdLib/Lib/test/test_threadsignals.py | 0 .../StdLib/Lib/test/test_time.py | 0 .../StdLib/Lib/test/test_timeit.py | 0 .../StdLib/Lib/test/test_timeout.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_tk.py | 0 .../StdLib/Lib/test/test_tokenize.py | 0 .../StdLib/Lib/test/test_tools/__init__.py | 0 .../StdLib/Lib/test/test_tools/__main__.py | 0 .../StdLib/Lib/test/test_tools/test_gprof2html.py | 0 .../StdLib/Lib/test/test_tools/test_md5sum.py | 0 .../StdLib/Lib/test/test_tools/test_pdeps.py | 0 .../StdLib/Lib/test/test_tools/test_pindent.py | 0 .../StdLib/Lib/test/test_tools/test_reindent.py | 0 .../StdLib/Lib/test/test_tools/test_sundry.py | 0 .../StdLib/Lib/test/test_tools/test_unparse.py | 0 .../StdLib/Lib/test/test_trace.py | 0 .../StdLib/Lib/test/test_traceback.py | 0 .../StdLib/Lib/test/test_tracemalloc.py | 0 .../StdLib/Lib/test/test_ttk_guionly.py | 0 .../StdLib/Lib/test/test_ttk_textonly.py | 0 .../StdLib/Lib/test/test_tuple.py | 0 .../StdLib/Lib/test/test_typechecks.py | 0 .../StdLib/Lib/test/test_types.py | 0 .../StdLib/Lib/test/test_typing.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_ucn.py | 0 .../StdLib/Lib/test/test_unary.py | 0 .../StdLib/Lib/test/test_unicode.py | 0 .../StdLib/Lib/test/test_unicode_file.py | 0 .../StdLib/Lib/test/test_unicodedata.py | 0 .../StdLib/Lib/test/test_unittest.py | 0 .../StdLib/Lib/test/test_univnewlines.py | 0 .../StdLib/Lib/test/test_unpack.py | 0 .../StdLib/Lib/test/test_unpack_ex.py | 0 .../StdLib/Lib/test/test_urllib.py | 0 .../StdLib/Lib/test/test_urllib2.py | 0 .../StdLib/Lib/test/test_urllib2_localnet.py | 0 .../StdLib/Lib/test/test_urllib2net.py | 0 .../StdLib/Lib/test/test_urllib_response.py | 0 .../StdLib/Lib/test/test_urllibnet.py | 0 .../StdLib/Lib/test/test_urlparse.py | 0 .../StdLib/Lib/test/test_userdict.py | 0 .../StdLib/Lib/test/test_userlist.py | 0 .../StdLib/Lib/test/test_userstring.py | 0 .../StdLib/Lib/test/test_utf8_mode.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/test_uu.py | 0 .../StdLib/Lib/test/test_uuid.py | 0 .../StdLib/Lib/test/test_venv.py | 0 .../StdLib/Lib/test/test_wait3.py | 0 .../StdLib/Lib/test/test_wait4.py | 0 .../StdLib/Lib/test/test_warnings.py | 0 .../StdLib/Lib/test/test_wave.py | 0 .../StdLib/Lib/test/test_weakref.py | 0 .../StdLib/Lib/test/test_weakset.py | 0 .../StdLib/Lib/test/test_webbrowser.py | 0 .../StdLib/Lib/test/test_winreg.py | 0 .../StdLib/Lib/test/test_winsound.py | 0 .../StdLib/Lib/test/test_with.py | 0 .../StdLib/Lib/test/test_wsgiref.py | 0 .../StdLib/Lib/test/test_xdrlib.py | 0 .../StdLib/Lib/test/test_xml_dom_minicompat.py | 0 .../StdLib/Lib/test/test_xml_etree.py | 0 .../StdLib/Lib/test/test_xml_etree_c.py | 0 .../StdLib/Lib/test/test_xmlrpc.py | 0 .../StdLib/Lib/test/test_xmlrpc_net.py | 0 .../StdLib/Lib/test/test_zipfile.py | 0 .../StdLib/Lib/test/test_zipfile64.py | 0 .../StdLib/Lib/test/test_zipimport.py | 0 .../StdLib/Lib/test/test_zipimport_support.py | 0 .../StdLib/Lib/test/test_zlib.py | 0 .../StdLib/Lib/test/testcodec.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/testtar.tar | Bin .../StdLib/Lib/test/tf_inherit_check.py | 0 .../StdLib/Lib/test/threaded_import_hangers.py | 0 .../StdLib/Lib/test/time_hashlib.py | 0 ..._tests-latin1-coding-cookie-and-utf8-bom-sig.txt | 0 ...tests-no-coding-cookie-and-utf8-bom-sig-only.txt | 0 ...tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt | 0 ...ze_tests-utf8-coding-cookie-and-utf8-bom-sig.txt | 0 .../StdLib/Lib/test/tokenize_tests.txt | 0 .../StdLib/Lib/test/tracedmodules/__init__.py | 0 .../StdLib/Lib/test/tracedmodules/testmod.py | 0 .../StdLib/Lib/test/warning_tests.py | 0 .../StdLib/Lib/test/win_console_handler.py | 0 .../StdLib/Lib/test/xmltestdata/simple-ns.xml | 0 .../StdLib/Lib/test/xmltestdata/simple.xml | 0 .../StdLib/Lib/test/xmltestdata/test.xml | 0 .../StdLib/Lib/test/xmltestdata/test.xml.out | 0 {Src => Src.GetRenamed}/StdLib/Lib/test/xmltests.py | 0 .../StdLib/Lib/test/zip_cp437_header.zip | Bin {Src => Src.GetRenamed}/StdLib/Lib/test/zipdir.zip | Bin {Src => Src.GetRenamed}/StdLib/Lib/textwrap.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/this.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/threading.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/timeit.py | 0 .../StdLib/Lib/tkinter/__init__.py | 0 .../StdLib/Lib/tkinter/__main__.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/tkinter/_fix.py | 0 .../StdLib/Lib/tkinter/colorchooser.py | 0 .../StdLib/Lib/tkinter/commondialog.py | 0 .../StdLib/Lib/tkinter/constants.py | 0 .../StdLib/Lib/tkinter/dialog.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/tkinter/dnd.py | 0 .../StdLib/Lib/tkinter/filedialog.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/tkinter/font.py | 0 .../StdLib/Lib/tkinter/messagebox.py | 0 .../StdLib/Lib/tkinter/scrolledtext.py | 0 .../StdLib/Lib/tkinter/simpledialog.py | 0 .../StdLib/Lib/tkinter/test/README | 0 .../StdLib/Lib/tkinter/test}/__init__.py | 0 .../StdLib/Lib/tkinter/test/runtktests.py | 0 .../StdLib/Lib/tkinter/test/support.py | 0 .../Lib/tkinter/test/test_tkinter}/__init__.py | 0 .../Lib/tkinter/test/test_tkinter/test_font.py | 0 .../test/test_tkinter/test_geometry_managers.py | 0 .../Lib/tkinter/test/test_tkinter/test_images.py | 0 .../Lib/tkinter/test/test_tkinter/test_loadtk.py | 0 .../Lib/tkinter/test/test_tkinter/test_misc.py | 0 .../Lib/tkinter/test/test_tkinter/test_text.py | 0 .../Lib/tkinter/test/test_tkinter/test_variables.py | 0 .../Lib/tkinter/test/test_tkinter/test_widgets.py | 0 .../StdLib/Lib/tkinter/test/test_ttk}/__init__.py | 0 .../Lib/tkinter/test/test_ttk/test_extensions.py | 0 .../Lib/tkinter/test/test_ttk/test_functions.py | 0 .../StdLib/Lib/tkinter/test/test_ttk/test_style.py | 0 .../Lib/tkinter/test/test_ttk/test_widgets.py | 0 .../StdLib/Lib/tkinter/test/widget_tests.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/tkinter/tix.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/tkinter/ttk.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/token.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/tokenize.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/trace.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/traceback.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/tracemalloc.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/tty.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/turtle.py | 0 .../StdLib/Lib/turtledemo/__init__.py | 0 .../StdLib/Lib/turtledemo/__main__.py | 0 .../StdLib/Lib/turtledemo/bytedesign.py | 0 .../StdLib/Lib/turtledemo/chaos.py | 0 .../StdLib/Lib/turtledemo/clock.py | 0 .../StdLib/Lib/turtledemo/colormixer.py | 0 .../StdLib/Lib/turtledemo/forest.py | 0 .../StdLib/Lib/turtledemo/fractalcurves.py | 0 .../StdLib/Lib/turtledemo/lindenmayer.py | 0 .../StdLib/Lib/turtledemo/minimal_hanoi.py | 0 .../StdLib/Lib/turtledemo/nim.py | 0 .../StdLib/Lib/turtledemo/paint.py | 0 .../StdLib/Lib/turtledemo/peace.py | 0 .../StdLib/Lib/turtledemo/penrose.py | 0 .../StdLib/Lib/turtledemo/planet_and_moon.py | 0 .../StdLib/Lib/turtledemo/round_dance.py | 0 .../StdLib/Lib/turtledemo/tree.py | 0 .../StdLib/Lib/turtledemo/turtle.cfg | 0 .../StdLib/Lib/turtledemo/two_canvases.py | 0 .../StdLib/Lib/turtledemo/wikipedia.py | 0 .../StdLib/Lib/turtledemo/yinyang.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/types.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/typing.py | 0 .../StdLib/Lib/unittest/__init__.py | 0 .../StdLib/Lib/unittest/__main__.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/unittest/case.py | 0 .../StdLib/Lib/unittest/loader.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/unittest/main.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/unittest/mock.py | 0 .../StdLib/Lib/unittest/result.py | 0 .../StdLib/Lib/unittest/runner.py | 0 .../StdLib/Lib/unittest/signals.py | 0 .../StdLib/Lib/unittest/suite.py | 0 .../StdLib/Lib/unittest/test/__init__.py | 0 .../StdLib/Lib/unittest/test/__main__.py | 0 .../StdLib/Lib/unittest/test/_test_warnings.py | 0 .../StdLib/Lib/unittest/test/dummy.py | 0 .../StdLib/Lib/unittest/test/support.py | 0 .../StdLib/Lib/unittest/test/test_assertions.py | 0 .../StdLib/Lib/unittest/test/test_break.py | 0 .../StdLib/Lib/unittest/test/test_case.py | 0 .../StdLib/Lib/unittest/test/test_discovery.py | 0 .../Lib/unittest/test/test_functiontestcase.py | 0 .../StdLib/Lib/unittest/test/test_loader.py | 0 .../StdLib/Lib/unittest/test/test_program.py | 0 .../StdLib/Lib/unittest/test/test_result.py | 0 .../StdLib/Lib/unittest/test/test_runner.py | 0 .../StdLib/Lib/unittest/test/test_setups.py | 0 .../StdLib/Lib/unittest/test/test_skipping.py | 0 .../StdLib/Lib/unittest/test/test_suite.py | 0 .../StdLib/Lib/unittest/test/testmock/__init__.py | 0 .../StdLib/Lib/unittest/test/testmock/__main__.py | 0 .../StdLib/Lib/unittest/test/testmock/support.py | 0 .../Lib/unittest/test/testmock/testcallable.py | 0 .../Lib/unittest/test/testmock/testhelpers.py | 0 .../Lib/unittest/test/testmock/testmagicmethods.py | 0 .../StdLib/Lib/unittest/test/testmock/testmock.py | 0 .../StdLib/Lib/unittest/test/testmock/testpatch.py | 0 .../Lib/unittest/test/testmock/testsentinel.py | 0 .../StdLib/Lib/unittest/test/testmock/testwith.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/unittest/util.py | 0 .../StdLib/Lib/urllib}/__init__.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/urllib/error.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/urllib/parse.py | 0 .../StdLib/Lib/urllib/request.py | 0 .../StdLib/Lib/urllib/response.py | 0 .../StdLib/Lib/urllib/robotparser.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/uu.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/uuid.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/venv/__init__.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/venv/__main__.py | 0 .../StdLib/Lib/venv/scripts/nt/Activate.ps1 | 0 .../StdLib/Lib/venv/scripts/nt/activate.bat | 0 .../StdLib/Lib/venv/scripts/nt/deactivate.bat | 0 .../StdLib/Lib/venv/scripts/posix/activate | 0 .../StdLib/Lib/venv/scripts/posix/activate.csh | 0 .../StdLib/Lib/venv/scripts/posix/activate.fish | 0 {Src => Src.GetRenamed}/StdLib/Lib/warnings.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/wave.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/weakref.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/webbrowser.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/wpf.py | 0 .../StdLib/Lib/wsgiref/__init__.py | 0 .../StdLib/Lib/wsgiref/handlers.py | 0 .../StdLib/Lib/wsgiref/headers.py | 0 .../StdLib/Lib/wsgiref/simple_server.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/wsgiref/util.py | 0 .../StdLib/Lib/wsgiref/validate.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/xdrlib.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/xml/__init__.py | 0 .../StdLib/Lib/xml/dom/NodeFilter.py | 0 .../StdLib/Lib/xml/dom/__init__.py | 0 .../StdLib/Lib/xml/dom/domreg.py | 0 .../StdLib/Lib/xml/dom/expatbuilder.py | 0 .../StdLib/Lib/xml/dom/minicompat.py | 0 .../StdLib/Lib/xml/dom/minidom.py | 0 .../StdLib/Lib/xml/dom/pulldom.py | 0 .../StdLib/Lib/xml/dom/xmlbuilder.py | 0 .../StdLib/Lib/xml/etree/ElementInclude.py | 0 .../StdLib/Lib/xml/etree/ElementPath.py | 0 .../StdLib/Lib/xml/etree/ElementTree.py | 0 .../StdLib/Lib/xml/etree/__init__.py | 0 .../StdLib/Lib/xml/etree/cElementTree.py | 0 .../StdLib/Lib/xml/parsers/__init__.py | 0 .../StdLib/Lib/xml/parsers/expat.py | 0 .../StdLib/Lib/xml/sax/__init__.py | 0 .../StdLib/Lib/xml/sax/_exceptions.py | 0 .../StdLib/Lib/xml/sax/expatreader.py | 0 .../StdLib/Lib/xml/sax/handler.py | 0 .../StdLib/Lib/xml/sax/saxutils.py | 0 .../StdLib/Lib/xml/sax/xmlreader.py | 0 .../StdLib/Lib/xmlrpc/__init__.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/xmlrpc/client.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/xmlrpc/server.py | 0 {Src => Src.GetRenamed}/StdLib/Lib/zipfile.py | 0 {Src => Src.GetRenamed}/StdLib/StdLib.License.txt | 0 {Src => Src.GetRenamed}/StdLib/StdLib.pyproj | 0 {Src => Src.GetRenamed}/StdLib/stdlib-upgrade.txt | 0 {Src => Src.GetRenamed}/StdLib/update-stdlib.cmd | 0 {Src => Src.GetRenamed}/StdLib/update-stdlib.sh | 0 {Src => Src.GetRenamed}/Tests/AssemblyInfo.cs | 0 {Src => Src.GetRenamed}/Tests/AttrInjectorTest.cs | 0 {Src => Src.GetRenamed}/Tests/BindTest.cs | 0 {Src => Src.GetRenamed}/Tests/BinderTest.cs | 0 {Src => Src.GetRenamed}/Tests/Cases/CPythonCases.cs | 0 .../Tests/Cases/CPythonCasesManifest.ini | 0 {Src => Src.GetRenamed}/Tests/Cases/CaseExecuter.cs | 0 .../Tests/Cases/CaseGenerator.cs | 0 {Src => Src.GetRenamed}/Tests/Cases/CommonCases.cs | 0 .../Tests/Cases/IronPythonCases.cs | 0 .../Tests/Cases/IronPythonCasesManifest.ini | 0 {Src => Src.GetRenamed}/Tests/ClrType.cs | 0 {Src => Src.GetRenamed}/Tests/Cmplx.cs | 0 {Src => Src.GetRenamed}/Tests/Conversions.cs | 0 {Src => Src.GetRenamed}/Tests/DeTest.cs | 0 {Src => Src.GetRenamed}/Tests/DelegateTest.cs | 0 {Src => Src.GetRenamed}/Tests/DynamicRegressions.cs | 0 {Src => Src.GetRenamed}/Tests/EncodingTest.cs | 0 {Src => Src.GetRenamed}/Tests/EngineTest.cs | 0 {Src => Src.GetRenamed}/Tests/Enums.cs | 0 {Src => Src.GetRenamed}/Tests/Events.cs | 0 {Src => Src.GetRenamed}/Tests/ExceptionConverter.cs | 0 {Src => Src.GetRenamed}/Tests/Exceptions.cs | 0 {Src => Src.GetRenamed}/Tests/Explicit.cs | 0 .../Tests/ExtensionMethodTest.cs | 0 {Src => Src.GetRenamed}/Tests/GenMeth.cs | 0 {Src => Src.GetRenamed}/Tests/Indexable.cs | 0 {Src => Src.GetRenamed}/Tests/InheritTest.cs | 0 {Src => Src.GetRenamed}/Tests/IntegerTest.cs | 0 {Src => Src.GetRenamed}/Tests/IronMath.cs | 0 .../Tests/IronPython.Tests.csproj | 0 {Src => Src.GetRenamed}/Tests/LoadTest.cs | 0 {Src => Src.GetRenamed}/Tests/MemberMappingTests.cs | 0 {Src => Src.GetRenamed}/Tests/MemberOverloadTest.cs | 0 .../Tests/MethodParametersStubs.cs | 0 {Src => Src.GetRenamed}/Tests/NestedClass.cs | 0 {Src => Src.GetRenamed}/Tests/NullableTest.cs | 0 {Src => Src.GetRenamed}/Tests/OperatorTest.cs | 0 {Src => Src.GetRenamed}/Tests/ProtocolTest.cs | 0 {Src => Src.GetRenamed}/Tests/StaticTest.cs | 0 {Src => Src.GetRenamed}/Tests/Stress/Engine.cs | 0 .../Tests/StringDictionaryStorage.cs | 0 {Src => Src.GetRenamed}/Tests/TestBuiltinModule.cs | 0 {Src => Src.GetRenamed}/Tests/TypeDescriptor.cs | 0 {Src => Src.GetRenamed}/Tests/Util/IniParser.cs | 0 {Src => Src.GetRenamed}/Tests/Util/TestManifest.cs | 0 {Src => Src.GetRenamed}/Wpf/DynamicXamlReader.cs | 0 {Src => Src.GetRenamed}/Wpf/IronPython.Wpf.csproj | 0 .../Wpf/Properties/AssemblyInfo.cs | 0 {Src => Src.GetRenamed}/Wpf/_wpf.cs | 0 Src/DLR | 1 - {Utils => Utils.GetRenamed}/NuGet/nuget.exe | Bin .../References/IKVM/IKVM.Reflection.License.txt | 0 .../References/IKVM/IKVM.Reflection.dll | Bin .../References/Mono.Posix.dll | Bin {Documentation => docs}/building.md | 0 .../differences-from-c-python.md | 0 {Documentation => docs}/feature-symbols.md | 0 {Documentation => docs}/getting-the-sources.md | 0 {Documentation => docs}/installing.md | 0 {Documentation => docs}/logo.png | Bin {Documentation => docs}/logo.svg | 0 {Documentation => docs}/modifying-the-sources.md | 0 {Documentation => docs}/package-compatibility.md | 0 {Documentation => docs}/upgrading-from-ipy2.md | 0 {Build => eng}/After.targets | 0 {Build => eng}/Key.snk | Bin {Build => eng}/Tasks.Targets | 0 {Package => eng}/choco/Choco.Packaging.targets | 0 {Package => eng}/choco/IronPython.nuspec | 0 {Package => eng}/choco/README.md | 0 .../distutils/command/wininst-10.0-amd64.exe.ignore | 0 .../lib/distutils/command/wininst-10.0.exe.ignore | 0 .../lib/distutils/command/wininst-6.0.exe.ignore | 0 .../lib/distutils/command/wininst-7.1.exe.ignore | 0 .../lib/distutils/command/wininst-8.0.exe.ignore | 0 .../distutils/command/wininst-9.0-amd64.exe.ignore | 0 .../lib/distutils/command/wininst-9.0.exe.ignore | 0 {Package => eng}/choco/tools/VERIFICATION.txt | 0 {Package => eng}/deb/DEBIAN/control | 0 {Package => eng}/deb/Deb.Packaging.targets | 0 eng/deb/ipy | 1 + eng/deb/ipy3 | 1 + {Package => eng}/deb/ipy3.4 | 0 .../dotnettool/DotnetTool.Packaging.targets | 0 .../dotnettool/IronPython.Console.csproj | 0 {Package => eng}/dotnettool/README.md | 0 .../dotnettool/runtimeconfig.template.json | 0 {Package => eng}/msi/Dlr.wxs | 0 {Package => eng}/msi/IronPython.Installer.wixproj | 0 {Package => eng}/msi/IronPython.wxs | 0 {Package => eng}/msi/License.rtf | 0 {Package => eng}/msi/Msi.Packaging.targets | 0 {Package => eng}/msi/Product.wxs | 0 {Package => eng}/msi/Version.wxi | 0 {Package => eng}/msi/banner.bmp | Bin {Package => eng}/msi/ironpython.bmp | Bin {Build => eng}/net462.props | 0 {Build => eng}/net6.0-windows.props | 0 {Build => eng}/net6.0.props | 0 {Build => eng}/net8.0-windows.props | 0 {Build => eng}/net8.0.props | 0 {Build => eng}/net9.0-windows.props | 0 {Build => eng}/net9.0.props | 0 {Build => eng}/netcoreapp2.1.props | 0 {Build => eng}/netcoreapp3.1.props | 0 {Build => eng}/netstandard2.0.props | 0 {Package => eng}/nuget/IronPython.StdLib.nuspec | 0 {Package => eng}/nuget/IronPython.nuspec | 0 {Package => eng}/nuget/NuGet.Packaging.csproj | 0 {Package => eng}/nuget/NuGet.Packaging.targets | 0 {Package => eng}/nuget/README.md | 0 {Package => eng}/pkg/Pkg.Packaging.targets | 0 {Package => eng}/pkg/dos2unix.sh | 0 {Build => eng}/steps.yml | 0 {Package => eng}/zip/README.md | 0 {Package => eng}/zip/Zip.Packaging.targets | 0 {PythonTests => tests}/IndicesTest.py | 0 {PythonTests => tests}/Inputs/RemoteConsole.py | 0 {PythonTests => tests}/Inputs/UseCLI.py | 0 {PythonTests => tests}/Inputs/exit.py | 0 {PythonTests => tests}/Inputs/exitFuncRaises.py | 0 {PythonTests => tests}/Inputs/exitFuncRuns.py | 0 {PythonTests => tests}/Inputs/raise.py | 0 {PythonTests => tests}/Inputs/simpleCommand.py | 0 {PythonTests => tests}/Inputs/syntaxError.py | 0 .../Inputs/uninitializedGlobal.py | 0 {PythonTests => tests}/Modes/ConsoleFlags.ps1 | 0 {PythonTests => tests}/Modes/ConsoleHelp.Debug.out | 0 .../Modes/ConsoleHelp.Release.out | 0 {PythonTests => tests}/RunAgainstCpy.py | 0 .../Tools/baselines/__builtin__.log | 0 {PythonTests => tests}/Tools/baselines/_codecs.log | 0 .../Tools/baselines/_collections.log | 0 {PythonTests => tests}/Tools/baselines/_sre.log | 0 {PythonTests => tests}/Tools/baselines/_struct.log | 0 .../Tools/baselines/_subprocess.log | 0 {PythonTests => tests}/Tools/baselines/_weakref.log | 0 {PythonTests => tests}/Tools/baselines/_winreg.log | 0 {PythonTests => tests}/Tools/baselines/array.log | 0 {PythonTests => tests}/Tools/baselines/cPickle.log | 0 .../Tools/baselines/cStringIO.log | 0 {PythonTests => tests}/Tools/baselines/copy_reg.log | 0 {PythonTests => tests}/Tools/baselines/datetime.log | 0 {PythonTests => tests}/Tools/baselines/gc.log | 0 .../Tools/baselines/itertools.log | 0 {PythonTests => tests}/Tools/baselines/math.log | 0 {PythonTests => tests}/Tools/baselines/mmap.log | 0 {PythonTests => tests}/Tools/baselines/msvcrt.log | 0 {PythonTests => tests}/Tools/baselines/nt.log | 0 {PythonTests => tests}/Tools/baselines/select.log | 0 {PythonTests => tests}/Tools/baselines/signal.log | 0 {PythonTests => tests}/Tools/baselines/sys.log | 0 {PythonTests => tests}/Tools/baselines/thread.log | 0 {PythonTests => tests}/Tools/baselines/time.log | 0 .../Tools/baselines/types_only.log | 0 .../Tools/baselines/xxsubtype.log | 0 {PythonTests => tests}/Tools/check/_functools.log | 0 {PythonTests => tests}/Tools/cleantests.py | 0 {PythonTests => tests}/Tools/clr_helpers.py | 0 {PythonTests => tests}/Tools/cmodule.py | 0 {PythonTests => tests}/Tools/cpy_tests.py | 0 {PythonTests => tests}/Tools/logmodule.py | 0 {PythonTests => tests}/Tools/modulediff.py | 0 {PythonTests => tests}/Tools/stdmodules.py | 0 {PythonTests => tests}/_ctypes_test_linux32.pyd | Bin {PythonTests => tests}/_ctypes_test_linux64.pyd | Bin {PythonTests => tests}/_ctypes_test_win32.pyd | Bin {PythonTests => tests}/_ctypes_test_win64.pyd | Bin {PythonTests => tests}/badil.py | 0 {PythonTests => tests}/c1.cs | 0 {PythonTests => tests}/c2.cs | 0 {PythonTests => tests}/c3.cs | 0 {PythonTests => tests}/c4.cs | 0 {PythonTests => tests}/check_result.bat | 0 {PythonTests => tests}/compat/common.py | 0 {PythonTests => tests}/compat/rulediff.py | 0 {PythonTests => tests}/compat/runsbs.py | 0 {PythonTests => tests}/compat/sbs_builtin.py | 0 {PythonTests => tests}/compat/sbs_class_compare.py | 0 .../compat/sbs_exceptions}/__init__.py | 0 .../compat/sbs_exceptions/define.py | 0 .../compat/sbs_exceptions/for_loop.py | 0 .../compat/sbs_exceptions/if_false.py | 0 .../compat/sbs_exceptions/if_true.py | 0 .../compat/sbs_exceptions/shared.py | 0 .../compat/sbs_exceptions/try_else.py | 0 .../compat/sbs_exceptions/try_except1.py | 0 .../compat/sbs_exceptions/try_except2.py | 0 .../compat/sbs_exceptions/try_except3.py | 0 .../compat/sbs_exceptions/try_finally1.py | 0 .../compat/sbs_exceptions/try_finally2.py | 0 .../compat/sbs_exceptions/try_finally3.py | 0 .../compat/sbs_exceptions/while_loop.py | 0 {PythonTests => tests}/compat/sbs_func_args.py | 0 {PythonTests => tests}/compat/sbs_library.cs | 0 {PythonTests => tests}/compat/sbs_newtype.py | 0 {PythonTests => tests}/compat/sbs_parse_string.py | 0 {PythonTests => tests}/compat/sbs_simple_compare.py | 0 {PythonTests => tests}/compat/sbs_simple_ops.py | 0 {PythonTests => tests}/compat/sbs_true_division.py | 0 {PythonTests => tests}/compat/sbs_typeop.py | 0 {PythonTests => tests}/compat/testdata.py | 0 {PythonTests => tests}/custombuiltins.py | 0 {PythonTests => tests}/debugging/__init__.py | 0 .../debugging/mdbg_tool/__init__.py | 0 .../debugging/pdb_mod/__init__.py | 0 {PythonTests => tests}/debugging/vs/__init__.py | 0 {PythonTests => tests}/dllsite.py | 0 {PythonTests => tests}/dummy_module.py | 0 .../dynamic_sanity/dynamic_runner.bat | 0 .../dynamic_sanity/dynamic_sanity.cs | 0 {PythonTests => tests}/dynamic_sanity/mock.py | 0 .../encoded_files/bad_encoding_name.py | 0 .../encoded_files/bad_latin1_bom.py | 0 .../encoded_files/bad_latin1_bom_decl.py | 0 .../encoded_files/bad_latin1_nbsp.py | 0 .../encoded_files/bad_latin1_nodecl.py | 0 .../encoded_files/bad_utf8_bom_decl.py | 0 {PythonTests => tests}/encoded_files/cp1019.py | 0 {PythonTests => tests}/encoded_files/cp11334_bad.py | 0 {PythonTests => tests}/encoded_files/cp11334_ok.py | 0 {PythonTests => tests}/encoded_files/cp20472.py | 0 .../encoded_files/ok_encoding_nonascii.py | 0 .../encoded_files/ok_encoding_whitespace.py | 0 {PythonTests => tests}/file_with_BOM.txt | 2 +- {PythonTests => tests}/file_without_BOM.txt | 2 +- {PythonTests => tests}/functions/test_signatures.py | 0 {PythonTests => tests}/gen_stdlib_test.py | 0 {PythonTests => tests}/gh129.zip | Bin {PythonTests => tests}/harness.py | 0 .../hosting/editor_svcs/test_errorlistener.py | 0 .../hosting/editor_svcs/test_tokencategorizer.py | 0 .../import_extant/_vendor}/__init__.py | 0 .../import_extant/_vendor/packaging}/__init__.py | 0 .../import_extant/_vendor/packaging/_structures.py | 0 .../import_extant/_vendor/packaging/version.py | 0 .../import_extant/extern/__init__.py | 0 {PythonTests => tests}/interop/__init__.py | 0 .../interop/com/apps/MultiOffice.py | 0 {PythonTests => tests}/interop/com/apps/adodb.py | 0 {PythonTests => tests}/interop/com/apps/excel.py | 0 {PythonTests => tests}/interop/com/apps/scriptpw.py | 0 {PythonTests => tests}/interop/com/apps/word.py | 0 .../interop/com/compat/__init__.py | 0 {PythonTests => tests}/interop/com/compat/hw.py | 0 .../interop/com/compat/hw_client.py | 0 .../interop/com/dlrcomlib/DispEvents.py | 0 .../interop/com/dlrcomlib/InOutParams.py | 0 .../interop/com/dlrcomlib/MultipleParams.py | 0 .../interop/com/dlrcomlib/OptionalParams.py | 0 .../interop/com/dlrcomlib/OutParams.py | 0 .../interop/com/dlrcomlib/ReturnValues.py | 0 .../interop/com/dlrcomlib/SimpleErrors.py | 0 .../interop/com/dlrcomlib/__init__.py | 0 .../interop/com/dlrcomlib/dlrcomserver.py | 0 .../interop/com/dlrcomlib/paramsinretval.py | 0 .../interop/com/dlrcomlib/properties.py | 0 .../interop/com/dlrcomlib/pytraits/__init__.py | 0 .../interop/com/dlrcomlib/pytraits/method.py | 0 .../interop/com/dlrcomlib/pytraits/obj.py | 0 .../interop/com/dlrcomlib/pytraits/prop.py | 0 .../interop/com/dlrcomlib/typelib.py | 0 .../interop/net/derivation/test_ctor_override.py | 0 .../interop/net/derivation/test_event_override.py | 0 .../interop/net/derivation/test_method_override.py | 0 .../interop/net/derivation/test_method_signature.py | 0 .../net/derivation/test_property_override.py | 0 .../interop/net/derivation/test_simplederive.py | 0 .../interop/net/derivation/test_special_method.py | 0 .../interop/net/dynamic/test_dynamic_regressions.py | 0 .../interop/net/event/test_delegate.py | 0 .../interop/net/event/test_event.py | 0 .../interop/net/field/test_field_misc.py | 0 .../interop/net/field/test_fields_inside_enum.py | 0 .../interop/net/field/test_initonly_fields.py | 0 .../interop/net/field/test_instance_fields.py | 0 .../interop/net/field/test_literal_fields.py | 0 .../interop/net/field/test_static_fields.py | 0 .../interop/net/loadorder/module.py | 0 {PythonTests => tests}/interop/net/loadorder/t1a.py | 0 {PythonTests => tests}/interop/net/loadorder/t1b.py | 0 {PythonTests => tests}/interop/net/loadorder/t1c.py | 0 {PythonTests => tests}/interop/net/loadorder/t1d.py | 0 {PythonTests => tests}/interop/net/loadorder/t2a.py | 0 {PythonTests => tests}/interop/net/loadorder/t2b.py | 0 {PythonTests => tests}/interop/net/loadorder/t2c.py | 0 {PythonTests => tests}/interop/net/loadorder/t2d.py | 0 {PythonTests => tests}/interop/net/loadorder/t2e.py | 0 {PythonTests => tests}/interop/net/loadorder/t2f.py | 0 {PythonTests => tests}/interop/net/loadorder/t2g.py | 0 {PythonTests => tests}/interop/net/loadorder/t2h.py | 0 {PythonTests => tests}/interop/net/loadorder/t3a.py | 0 {PythonTests => tests}/interop/net/loadorder/t3b.py | 0 .../interop/net/loadorder/t3c0.py | 0 .../interop/net/loadorder/t3c1.py | 0 .../interop/net/loadorder/t3c2.py | 0 {PythonTests => tests}/interop/net/loadorder/t3d.py | 0 {PythonTests => tests}/interop/net/loadorder/t3e.py | 0 {PythonTests => tests}/interop/net/loadorder/t3f.py | 0 .../interop/net/loadorder/t3g1.py | 0 .../interop/net/loadorder/t3g2.py | 0 {PythonTests => tests}/interop/net/loadorder/t3h.py | 0 {PythonTests => tests}/interop/net/loadorder/t3i.py | 0 {PythonTests => tests}/interop/net/loadorder/t4a.py | 0 {PythonTests => tests}/interop/net/loadorder/t4b.py | 0 {PythonTests => tests}/interop/net/loadorder/t4c.py | 0 {PythonTests => tests}/interop/net/loadorder/t5a.py | 0 {PythonTests => tests}/interop/net/loadorder/t5b.py | 0 .../interop/net/loadorder/t5c1.py | 0 .../interop/net/loadorder/t5c2.py | 0 {PythonTests => tests}/interop/net/loadorder/t6.py | 0 {PythonTests => tests}/interop/net/loadorder/t7a.py | 0 {PythonTests => tests}/interop/net/loadorder/t7b.py | 0 {PythonTests => tests}/interop/net/loadorder/t7c.py | 0 {PythonTests => tests}/interop/net/loadorder/t7d.py | 0 {PythonTests => tests}/interop/net/loadorder/t7e.py | 0 {PythonTests => tests}/interop/net/loadorder/t7f.py | 0 .../interop/net/method/test_arguments.py | 0 .../interop/net/method/test_op_explicit.py | 0 .../interop/net/method/test_op_implicit.py | 0 .../interop/net/method/test_operators.py | 0 .../interop/net/method/test_returnvalue.py | 0 .../interop/net/property/test_indexercs.py | 0 .../interop/net/property/test_indexervb.py | 0 .../interop/net/property/test_property.py | 0 .../interop/net/test_accessibility.py | 0 .../interop/net/test_dynamicobjectmodel.py | 0 .../interop/net/test_loadorder.py | 0 .../interop/net/type/test___clrtype.py | 0 .../interop/net/type/test_assembly.py | 0 .../interop/net/type/test_clr_array.py | 0 .../interop/net/type/test_ctor.py | 0 .../interop/net/type/test_defaultmember.py | 0 .../interop/net/type/test_reachtype.py | 0 .../interop/net/versions/test_four_dot_zero.py | 0 {PythonTests => tests}/modules/__init__.py | 0 .../modules/io_related/test__bytesio.py | 0 .../modules/io_related/test__fileio.py | 0 .../modules/io_related/test_binascii.py | 0 .../modules/io_related/test_cPickle.py | 0 .../modules/io_related/test_codecs.py | 0 .../modules/io_related/test_copyreg.py | 0 .../modules/io_related/test_fd.py | 0 .../modules/io_related/test_io_StringIO.py | 0 .../modules/io_related/test_marshal.py | 0 .../modules/io_related/test_re.py | 0 {PythonTests => tests}/modules/misc/test__opcode.py | 0 {PythonTests => tests}/modules/misc/test__random.py | 0 {PythonTests => tests}/modules/misc/test__sha256.py | 0 {PythonTests => tests}/modules/misc/test__sha512.py | 0 .../modules/misc/test__warnings.py | 0 .../modules/misc/test__weakref.py | 0 {PythonTests => tests}/modules/misc/test_ctypes.py | 0 .../modules/misc/test_datetime.py | 0 {PythonTests => tests}/modules/misc/test_math.py | 0 .../modules/misc/test_operator.py | 0 .../modules/misc/test_system_namespaces.py | 0 {PythonTests => tests}/modules/misc/test_zlib.py | 0 .../modules/network_related/__init__.py | 0 .../modules/network_related}/keycert.pem | 0 .../modules/network_related/test__socket.py | 0 .../modules/network_related/test__ssl.py | 0 .../modules/system_related/__init__.py | 0 .../modules/system_related/test__locale.py | 0 .../modules/system_related/test_errno.py | 0 .../modules/system_related/test_gc.py | 0 .../modules/system_related/test_nt.py | 0 .../modules/system_related/test_os.py | 0 .../modules/system_related/test_resource.py | 0 .../modules/system_related/test_resource_stdlib.py | 0 .../modules/system_related/test_signal.py | 0 .../modules/system_related/test_sys.py | 0 .../modules/system_related/test_sys_getframe.py | 0 .../modules/system_related/test_thread.py | 0 .../modules/system_related/test_time.py | 0 .../modules/type_related/__init__.py | 0 .../modules/type_related/test__struct.py | 0 .../modules/type_related/test_array.py | 0 .../type_related/test_bitfields_ctypes_stdlib.py | 0 .../modules/type_related/test_ctypes.py | 0 .../modules/type_related/test_types.py | 0 {PythonTests => tests}/perf_micro_calls.py | 0 {PythonTests => tests}/pickles/cp18666.pickle | 0 {PythonTests => tests}/plans/debugging.html | 0 .../plans/debugging.mdbg_tool.html | 0 {PythonTests => tests}/plans/debugging.pdb_mod.html | 0 {PythonTests => tests}/plans/debugging.vs.html | 0 .../plans/generic_plan_template.py | 0 .../plans/interop.net.derivation.html | 0 .../interop.net.derivation.test_ctor_override.html | 0 .../interop.net.derivation.test_event_override.html | 0 ...interop.net.derivation.test_method_override.html | 0 ...nterop.net.derivation.test_method_signature.html | 0 ...terop.net.derivation.test_property_override.html | 0 .../interop.net.derivation.test_simplederive.html | 0 .../interop.net.derivation.test_special_method.html | 0 {PythonTests => tests}/plans/interop.net.event.html | 0 .../plans/interop.net.event.test_delegate.html | 0 .../plans/interop.net.event.test_event.html | 0 {PythonTests => tests}/plans/interop.net.field.html | 0 .../plans/interop.net.field.test_field_misc.html | 0 .../interop.net.field.test_fields_inside_enum.html | 0 {PythonTests => tests}/plans/interop.net.html | 0 .../plans/interop.net.insert_csharp.html | 0 .../plans/interop.net.method.html | 0 .../plans/interop.net.method.test_arguments.html | 0 .../plans/interop.net.method.test_op_explicit.html | 0 .../plans/interop.net.method.test_op_implicit.html | 0 .../plans/interop.net.method.test_operators.html | 0 .../plans/interop.net.method.test_returnvalue.html | 0 .../plans/interop.net.property.html | 0 .../plans/interop.net.property.test_indexercs.html | 0 .../plans/interop.net.property.test_indexervb.html | 0 .../plans/interop.net.property.test_property.html | 0 .../plans/interop.net.test_accessibility.html | 0 .../plans/interop.net.test_dynamicobjectmodel.html | 0 .../plans/interop.net.test_loadorder.html | 0 {PythonTests => tests}/plans/interop.net.type.html | 0 .../plans/interop.net.type.test_assembly.html | 0 .../plans/interop.net.type.test_clr_array.html | 0 .../plans/interop.net.type.test_ctor.html | 0 .../plans/interop.net.type.test_defaultmember.html | 0 .../plans/interop.net.type.test_reachtype.html | 0 {PythonTests => tests}/pretest.py | 0 {PythonTests => tests}/pyc/console_hw.py | 0 {PythonTests => tests}/pyc/console_hw_args.py | 0 {PythonTests => tests}/pyc/other_hw.py | 0 .../StdLib/Lib/urllib => tests/pyc/pkg}/__init__.py | 0 {PythonTests => tests}/pyc/pkg/a.py | 0 {PythonTests => tests}/pyc/pkg/b.py | 0 {PythonTests => tests}/pyc/pycpkgtest.py | 0 {PythonTests => tests}/pyc/stdmodules_ok.ps1 | 0 {PythonTests => tests}/pyc/test_pyc.ps1 | 0 {PythonTests => tests}/pyc/winforms_hw.py | 0 {PythonTests => tests}/run.py | 0 {PythonTests => tests}/run_transformed.bat | 0 {PythonTests => tests}/sample.txt.gz | Bin .../specialcontext/Consoleless.ps1 | 0 .../specialcontext/verify_ipyw.py | 0 {PythonTests => tests}/stress/__init__.py | 0 {PythonTests => tests}/stress/bigimport1_test.py | 0 {PythonTests => tests}/test_array.py | 0 {PythonTests => tests}/test_assert.py | 0 {PythonTests => tests}/test_ast.py | 0 {PythonTests => tests}/test_attr.py | 0 {PythonTests => tests}/test_attribute_customize.py | 0 {PythonTests => tests}/test_attrinjector.py | 0 {PythonTests => tests}/test_bigint.py | 0 {PythonTests => tests}/test_bool.py | 0 {PythonTests => tests}/test_builtin_stdlib.py | 0 {PythonTests => tests}/test_builtinfunc.py | 0 {PythonTests => tests}/test_bytes.py | 0 {PythonTests => tests}/test_bz2.py | 0 {PythonTests => tests}/test_bz2_stdlib.py | 0 {PythonTests => tests}/test_class.py | 0 {PythonTests => tests}/test_class_stdlib.py | 0 {PythonTests => tests}/test_cliclass.py | 0 {PythonTests => tests}/test_closure.py | 0 {PythonTests => tests}/test_clrexception.py | 0 {PythonTests => tests}/test_clrload.py | 0 {PythonTests => tests}/test_clrload2.py | 0 {PythonTests => tests}/test_clrnuminterop.py | 0 {PythonTests => tests}/test_clrtype.py | 0 {PythonTests => tests}/test_clruse.py | 0 .../test_codeccallbacks_stdlib.py | 0 {PythonTests => tests}/test_codecs.py | 0 {PythonTests => tests}/test_codecs_stdlib.py | 0 {PythonTests => tests}/test_compiler.py | 0 {PythonTests => tests}/test_complex.py | 0 {PythonTests => tests}/test_complex_stdlib.py | 0 {PythonTests => tests}/test_conditional.py | 0 {PythonTests => tests}/test_data.gz | Bin {PythonTests => tests}/test_datetime.py | 0 {PythonTests => tests}/test_datetime_stdlib.py | 0 {PythonTests => tests}/test_decimal.py | 0 {PythonTests => tests}/test_decorator.py | 0 {PythonTests => tests}/test_delegate.py | 0 {PythonTests => tests}/test_deque.py | 0 {PythonTests => tests}/test_descr_stdlib.py | 0 {PythonTests => tests}/test_dict.py | 0 {PythonTests => tests}/test_dict_stdlib.py | 0 {PythonTests => tests}/test_dictcomp.py | 0 {PythonTests => tests}/test_dllsite.py | 0 {PythonTests => tests}/test_dlrkwarg.py | 0 {PythonTests => tests}/test_doc.py | 0 {PythonTests => tests}/test_enum.py | 0 {PythonTests => tests}/test_exceptions.py | 0 {PythonTests => tests}/test_exceptions_generated.py | 0 {PythonTests => tests}/test_excinfo.py | 0 {PythonTests => tests}/test_exec.py | 0 {PythonTests => tests}/test_file.py | 0 {PythonTests => tests}/test_float_stdlib.py | 0 {PythonTests => tests}/test_formatting.py | 0 {PythonTests => tests}/test_function.py | 0 {PythonTests => tests}/test_functools_stdlib.py | 0 {PythonTests => tests}/test_fuzz_parser.py | 0 {PythonTests => tests}/test_generator.py | 0 {PythonTests => tests}/test_generator_throw.py | 0 {PythonTests => tests}/test_genericmeth.py | 0 {PythonTests => tests}/test_hash.py | 0 {PythonTests => tests}/test_help.py | 0 {PythonTests => tests}/test_httplib_stdlib.py | 0 {PythonTests => tests}/test_imp.py | 0 {PythonTests => tests}/test_importext.py | 0 {PythonTests => tests}/test_importpkg.py | 0 {PythonTests => tests}/test_in.py | 0 {PythonTests => tests}/test_index.py | 0 {PythonTests => tests}/test_inheritance.py | 0 {PythonTests => tests}/test_int.py | 0 {PythonTests => tests}/test_interactive.py | 0 {PythonTests => tests}/test_io.py | 0 {PythonTests => tests}/test_io_stdlib.py | 0 {PythonTests => tests}/test_ipyc.py | 0 {PythonTests => tests}/test_ipye.py | 0 {PythonTests => tests}/test_ironmath.py | 0 {PythonTests => tests}/test_is.py | 0 {PythonTests => tests}/test_isinstance.py | 0 {PythonTests => tests}/test_isinstance2.py | 0 {PythonTests => tests}/test_iterator.py | 0 {PythonTests => tests}/test_iteratorlength.py | 0 {PythonTests => tests}/test_itertools_stdlib.py | 0 {PythonTests => tests}/test_json.py | 0 {PythonTests => tests}/test_kwarg.py | 0 {PythonTests => tests}/test_list.py | 0 {PythonTests => tests}/test_listcomp.py | 0 {PythonTests => tests}/test_long_stdlib.py | 0 {PythonTests => tests}/test_memory.py | 0 {PythonTests => tests}/test_memoryio_stdlib.py | 0 {PythonTests => tests}/test_memoryview.py | 0 {PythonTests => tests}/test_metaclass.py | 0 {PythonTests => tests}/test_methodbinder1.py | 0 {PythonTests => tests}/test_methodbinder2.py | 0 {PythonTests => tests}/test_methoddispatch.py | 0 {PythonTests => tests}/test_missing.py | 0 {PythonTests => tests}/test_namebinding.py | 0 {PythonTests => tests}/test_nonetype.py | 0 {PythonTests => tests}/test_nonlocal.py | 0 {PythonTests => tests}/test_number.py | 0 {PythonTests => tests}/test_numberhash.py | 0 {PythonTests => tests}/test_numtypes.py | 0 {PythonTests => tests}/test_pep380_stdlib.py | 0 {PythonTests => tests}/test_peverify.py | 0 {PythonTests => tests}/test_pow.py | 0 {PythonTests => tests}/test_privateBinding.py | 0 {PythonTests => tests}/test_property.py | 0 {PythonTests => tests}/test_protected.py | 0 {PythonTests => tests}/test_pyexpat.py | 0 {PythonTests => tests}/test_python25.py | 0 {PythonTests => tests}/test_python26.py | 0 {PythonTests => tests}/test_range.py | 0 {PythonTests => tests}/test_re_stdlib.py | 0 {PythonTests => tests}/test_regressions.py | 0 {PythonTests => tests}/test_regressions_compiled.py | 0 {PythonTests => tests}/test_sax_stdlib.py | 0 {PythonTests => tests}/test_scope_stdlib.py | 0 {PythonTests => tests}/test_set.py | 0 {PythonTests => tests}/test_setcomp.py | 0 {PythonTests => tests}/test_shutil.py | 0 {PythonTests => tests}/test_slice.py | 0 {PythonTests => tests}/test_slots.py | 0 {PythonTests => tests}/test_socket_stdlib.py | 0 {PythonTests => tests}/test_specialcontext.py | 0 {PythonTests => tests}/test_sqlite3_stdlib.py | 0 {PythonTests => tests}/test_ssl_stdlib.py | 0 {PythonTests => tests}/test_statics.py | 0 {PythonTests => tests}/test_stdconsole.py | 0 {PythonTests => tests}/test_stdmodules.py | 0 {PythonTests => tests}/test_str.py | 0 {PythonTests => tests}/test_str_bytes.py | 0 {PythonTests => tests}/test_strformat.py | 0 {PythonTests => tests}/test_struct.py | 0 {PythonTests => tests}/test_struct_stdlib.py | 0 {PythonTests => tests}/test_struct_threadsafe.py | 0 {PythonTests => tests}/test_super.py | 0 {PythonTests => tests}/test_superconsole.py | 0 {PythonTests => tests}/test_surrogateescape.py | 0 .../test_surrogateescape_pythonfuture.py | 0 {PythonTests => tests}/test_surrogatepass.py | 0 {PythonTests => tests}/test_syntax.py | 0 {PythonTests => tests}/test_sys_stdlib.py | 0 {PythonTests => tests}/test_system_timers.py | 0 {PythonTests => tests}/test_tcf.py | 0 {PythonTests => tests}/test_threadsafety.py | 0 {PythonTests => tests}/test_time_stdlib.py | 0 {PythonTests => tests}/test_traceback.py | 0 {PythonTests => tests}/test_tuple.py | 0 {PythonTests => tests}/test_types_stdlib.py | 0 {PythonTests => tests}/test_typing_stdlib.py | 0 {PythonTests => tests}/test_unicode.py | 0 {PythonTests => tests}/test_unicode_stdlib.py | 0 {PythonTests => tests}/test_unpack.py | 0 {PythonTests => tests}/test_utf8_mode_stdlib.py | 0 {PythonTests => tests}/test_weakref.py | 0 {PythonTests => tests}/test_weakset_stdlib.py | 0 {PythonTests => tests}/test_winforms.py | 0 {PythonTests => tests}/test_with.py | 0 {PythonTests => tests}/test_zipimport.py | 0 {PythonTests => tests}/testpkg1/__init__.py | 0 {PythonTests => tests}/testpkg1/mod1.py | 0 {PythonTests => tests}/timeit.py | 0 {PythonTests => tests}/toimport.py | 0 {PythonTests => tests}/transform.py | 0 3243 files changed, 4 insertions(+), 5 deletions(-) delete mode 120000 Package/deb/ipy delete mode 120000 Package/deb/ipy3 rename {Src => Src.GetRenamed}/App.Debug.config (100%) rename {Src => Src.GetRenamed}/App.Release.config (100%) rename {Src => Src.GetRenamed}/CTypes/Makefile (100%) rename {Src => Src.GetRenamed}/CTypes/_ctypes_test.c (100%) rename {Src => Src.GetRenamed}/CTypes/_ctypes_test.sln (100%) rename {Src => Src.GetRenamed}/CTypes/_ctypes_test.vcxproj (100%) rename {Src => Src.GetRenamed}/CompilerServices/AssemblyResolver.cs (100%) rename {Src => Src.GetRenamed}/CompilerServices/Config.cs (100%) rename {Src => Src.GetRenamed}/CompilerServices/ConsoleOps.cs (100%) rename {Src => Src.GetRenamed}/CompilerServices/IronPython.CompilerServices.csproj (100%) rename {Src => Src.GetRenamed}/CompilerServices/Program.cs (100%) rename {Src => Src.GetRenamed}/CompilerServices/Properties/AssemblyInfo.cs (100%) rename {Src => Src.GetRenamed}/CompilerServices/README.md (100%) rename {Src => Src.GetRenamed}/Console.Host/IronPython.Console.Host.csproj (100%) rename {Src => Src.GetRenamed}/Console.Host/IronPythonWindow.cs (100%) rename {Src => Src.GetRenamed}/Console.Host/Properties/AssemblyInfo.cs (100%) rename {Src => Src.GetRenamed}/Console.Host/ipyw.ico (100%) rename {Src => Src.GetRenamed}/Console/Console.cs (100%) rename {Src => Src.GetRenamed}/Console/IronPython.Console.csproj (100%) rename {Src => Src.GetRenamed}/Console/Properties/AssemblyInfo.cs (100%) rename {Src => Src.GetRenamed}/Console/app.manifest (100%) rename {Src => Src.GetRenamed}/Console/ipy-mono.sh (100%) rename {Src => Src.GetRenamed}/Console/ipy.ico (100%) rename {Src => Src.GetRenamed}/Console/ipy.sh (100%) rename {Src => Src.GetRenamed}/Console/runtimeconfig.template.json (100%) rename {Src => Src.GetRenamed}/Console32.Host/IronPython.Console32.Host.csproj (100%) rename {Src => Src.GetRenamed}/Console32/IronPython.Console32.csproj (100%) rename {DiagnosticAnalyzer => Src.GetRenamed/DiagnosticAnalyzer}/Analyzer.cs (100%) rename {DiagnosticAnalyzer => Src.GetRenamed/DiagnosticAnalyzer}/Directory.Build.props (100%) rename {DiagnosticAnalyzer => Src.GetRenamed/DiagnosticAnalyzer}/IronPython.DiagnosticAnalyzer.csproj (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/AndExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/AssertStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/AssignmentStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/AstMethods.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/AsyncStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/AugmentedAssignStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/BinaryExpression.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/BinaryExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/BreakStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/CallExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/ClassDefinition.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/Comprehension.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/ComprehensionFor.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/ComprehensionIf.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/ConditionalExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/ConstantExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/ContinueStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/DelStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/DictionaryExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/DottedName.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/DynamicConvertExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/EmptyStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/ErrorExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/Expression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/ExpressionStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/FlowChecker.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/ForStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/FormattedValueExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/FromImportStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/FunctionDefinition.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/GeneratorExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/GetGlobalContextExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/GlobalStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/ILoopStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/IfStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/IfStatementTest.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/ImportStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/IndexExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/JoinedStringExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/Keyword.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/LambdaExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/ListExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/MemberExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/ModuleName.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/NameExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/Node.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/NonlocalStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/OrExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/Parameter.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/ParenthesisExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/PythonAst.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/PythonConstantExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/PythonNameBinder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/PythonReference.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/PythonVariable.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/PythonWalker.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/RaiseStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/RelativeModuleName.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/ReturnStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/ScopeStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/SequenceExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/SerializedScopeStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/SetExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/SliceExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/StarredExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/Statement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/SuiteStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/TryStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/TupleExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/UnaryExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/VariableKind.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/WhileStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/WithStatement.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/YieldExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Ast/YieldFromExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/ClosureExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/ClosureInfo.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/CollectableCompilationMode.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/CompilationMode.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/GeneratorRewriter.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/LazyCode.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/LookupCompilationMode.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/OnDiskScriptCode.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Parser.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/PythonCallTargets.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/PythonCompilerOptions.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/PythonDynamicExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/PythonGlobal.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/PythonGlobalVariableExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/PythonOperator.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/PythonSavableScriptCode.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/PythonScriptCode.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/ReducableDynamicExpression.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/RunnableScriptCode.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/RuntimeScriptCode.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/ToDiskCompilationMode.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Token.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/TokenKind.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Tokenizer.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/Tokenizer.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/UncollectableCompilationMode.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Compiler/UncollectableCompilationMode.cs (100%) rename {Src => Src.GetRenamed}/IronPython/FakeInteropServices.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Hosting/Python.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Hosting/PythonCodeDomCodeGen.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Hosting/PythonCommandLine.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Hosting/PythonConsoleOptions.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Hosting/PythonOptionsParser.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Hosting/PythonService.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Interop/Windows/Interop.Libraries.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs (100%) rename {Src => Src.GetRenamed}/IronPython/IronPython.csproj (100%) rename {Src => Src.GetRenamed}/IronPython/Lib/iptest/__init__.py (100%) rename {Src => Src.GetRenamed}/IronPython/Lib/iptest/cominterop_util.py (100%) rename {Src => Src.GetRenamed}/IronPython/Lib/iptest/console_util.py (100%) rename {Src => Src.GetRenamed}/IronPython/Lib/iptest/file_util.py (100%) rename {Src => Src.GetRenamed}/IronPython/Lib/iptest/ipunittest.py (100%) rename {Src => Src.GetRenamed}/IronPython/Lib/iptest/misc_util.py (100%) rename {Src => Src.GetRenamed}/IronPython/Lib/iptest/process_util.py (100%) rename {Src => Src.GetRenamed}/IronPython/Lib/iptest/runner.py (100%) rename {Src => Src.GetRenamed}/IronPython/Lib/iptest/test_env.py (100%) rename {Src => Src.GetRenamed}/IronPython/Lib/iptest/type_util.py (100%) rename {Src => Src.GetRenamed}/IronPython/Modules/Builtin.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Modules/Builtin.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Modules/_ast.cs (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/IronPython/Modules/_fileio.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Modules/_imp.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Modules/_io.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Modules/_io/BytesIO.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Modules/_io/StringIO.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Modules/_locale.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Modules/sys.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Modules/unicodedata.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Modules/unicodedata/CaseFolding.txt (100%) rename {Src => Src.GetRenamed}/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt (100%) rename {Src => Src.GetRenamed}/IronPython/Modules/unicodedata/EastAsianWidth.txt (100%) rename {Src => Src.GetRenamed}/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz (100%) rename {Src => Src.GetRenamed}/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz (100%) rename {Src => Src.GetRenamed}/IronPython/Modules/unicodedata/NameAliases.txt (100%) rename {Src => Src.GetRenamed}/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt (100%) rename {Src => Src.GetRenamed}/IronPython/Modules/unicodedata/UnicodeData.txt (100%) rename {Src => Src.GetRenamed}/IronPython/Modules/unicodedata/genunicodedata.py (100%) rename {Src => Src.GetRenamed}/IronPython/Modules/unicodedata/license.txt (100%) rename {Src => Src.GetRenamed}/IronPython/Properties/AssemblyInfo.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Resources.Designer.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Resources.resx (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/ArrayData.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/Binders.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/BindingHelpers.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/BindingWarnings.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/ConditionalBuilder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/ContextArgBuilder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/ConversionBinder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/CreateFallbackBinder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/FastBindResult.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/FastGetBase.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/FastSetBase.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/IComConvertible.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/IFastGettable.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/IFastInvokable.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/IFastSettable.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/IPythonConvertible.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/IPythonExpandable.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/IPythonGetable.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/IPythonInvokable.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/IPythonOperable.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/IPythonSite.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/MetaBuiltinFunction.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/MetaMethod.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/MetaPythonFunction.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/MetaPythonObject.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/MetaPythonType.Calls.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/MetaPythonType.Members.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/MetaPythonType.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/MetaUserObject.Members.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/MetaUserObject.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/PythonBinder.Create.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/PythonBinder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/PythonExtensionBinder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/PythonGetIndexBinder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/PythonGetMemberBinder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/PythonGetSliceBinder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/PythonIndexType.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/PythonInvokeBinder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/PythonOperationBinder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/PythonOperationKind.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/PythonOverloadResolver.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/PythonProtocol.Operations.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/PythonProtocol.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/PythonSetIndexBinder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/PythonSetMemberBinder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/PythonSetSliceBinder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/SlotOrFunction.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Binding/WarningInfo.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/BufferProtocol.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/BuiltinPythonModule.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/BuiltinsDictionaryStorage.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/ByteArray.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/ByteArrayIterator.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Bytes.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/BytesIterator.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/BytesLikeAttribute.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/ClassMethodAttribute.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/ClassMethodDescriptor.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/ClrModule.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/CodeContext.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/CollectionDebugView.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/CommonDictionaryStorage.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/CompareUtil.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/CompileFlags.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/CompiledLoader.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/ConstantDictionaryStorage.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/ConversionWrappers.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Converter.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/CustomDictionaryStorage.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/DebuggerDictionaryStorage.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/DefaultContext.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Descriptors.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/DictionaryOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/DictionaryStorage.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/DictionaryTypeInfoAttribute.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/DontMapICollectionToLenAttribute.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/EmptyDictionaryStorage.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Enumerate.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/ErrorCodes.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/AssertionException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/AttributeErrorException.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/BufferException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/GeneratorExitException.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/ImportException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/IndentationException.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/LookupException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/OSException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/PythonException.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/PythonExceptions.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/RecursionException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/SystemExitException.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/TabException.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/TraceBack.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/TypeErrorException.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Exceptions/ValueErrorException.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/ExtensionMethodSet.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Filter.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/FormattingHelper.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/FunctionAttributes.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/FunctionCode.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Generator.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/GlobalDictionaryStorage.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/IParameterSequence.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Implementation.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Importer.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Index.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/InstancedModuleDictionaryStorage.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Interfaces.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/KwCallInfo.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/LiteralParser.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Map.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/MaybeNotImplementedAttribute.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/MemoryStreamContentProvider.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/MemoryView.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Method.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Method.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/MissingParameter.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/ModuleContext.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/ModuleDictionaryStorage.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/ModuleGlobalCache.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/ModuleLoader.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/ModuleOptions.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/NameType.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/NewStringFormatter.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/ObjectAttributesAdapter.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/ObjectDebugView.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/ArrayOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/BigIntegerOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/BoolOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/ByteOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/CharOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/ComOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/ComplexOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/DBNullOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/DateTimeOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/DecimalOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/DelegateOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/DictionaryOfTOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/EnumOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/FloatOps.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/FloatOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/IListOfByteOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/InstanceOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/IntOps.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/IntOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/IntPtrOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/ListOfTOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/MarshalOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/NamespaceTrackerOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/ObjectOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/PythonCalls.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/PythonOps.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/PythonOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/PythonTypeOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/StringOps.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/StringOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/TypeGroupOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/TypeTrackerOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/UIntPtrOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Operations/UserTypeOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/OutputWriter.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PlatformsAttribute.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Profiler.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonContext.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonContext.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonDictionary.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonDocumentationProvider.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonDynamicStackFrame.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonEncoding.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonFileManager.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonFunction.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonFunction.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonHiddenAttribute.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonList.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonModule.cs (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonModuleAttribute.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonNarrowing.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonOptions.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonRange.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonScopeExtension.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonStrIterator.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonTracebackListener.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonTuple.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/PythonTypeAttribute.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Reversed.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/ScopeDictionaryStorage.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/SequenceTypeInfoAttribute.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Set.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/SetStorage.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/SimpleNamespace.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/SiteLocalStorage.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Slice.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/StringDictionaryStorage.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/StringFormatSpec.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/StringFormatter.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Super.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Symbols.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/ThrowingErrorSink.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/TypecodeOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/BuiltinFunction.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/CachedNewTypeInfo.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/ConstructorFunction.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/CustomAttributeTracker.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/DocBuilder.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/DynamicHelpers.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/EmptyType.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/ExtensionPropertyInfo.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/FunctionType.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/IPythonObject.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/InstanceCreator.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/MappingProxy.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/Mro.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/NameConverter.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/NewTypeInfo.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/NewTypeMaker.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/OperatorMapping.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/ParameterInfoWrapper.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/PythonAssemblyOps.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/PythonSiteCache.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/PythonType.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/PythonType.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/PythonTypeDataSlot.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/PythonTypeDictSlot.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/PythonTypeInfo.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/PythonTypeSlot.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/PythonTypeTypeSlot.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/ReflectedEvent.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/ReflectedExtensionProperty.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/ReflectedField.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/ReflectedGetterSetter.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/ReflectedIndexer.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/ReflectedProperty.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/ReflectedSlotProperty.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/ResolvedMember.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/SlotFieldAttribute.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Types/TypeCache.Generated.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/UnboundNameException.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/WeakRef.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/WrapperDescriptorAttribute.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/WrapperDictionary.cs (100%) rename {Src => Src.GetRenamed}/IronPython/Runtime/Zip.cs (100%) rename {Src => Src.GetRenamed}/IronPython/SerializationStubs.cs (100%) rename {Src => Src.GetRenamed}/IronPython/StringExtensions.cs (100%) rename {Src => Src.GetRenamed}/IronPython/SystemRuntimeVersioning.cs (100%) rename {Src => Src.GetRenamed}/IronPython/policy.IronPython.config (100%) rename {Src => Src.GetRenamed}/Modules/IronPython.Modules.csproj (100%) rename {Src => Src.GetRenamed}/Modules/IterTools.cs (100%) rename {Src => Src.GetRenamed}/Modules/ModuleOps.cs (100%) rename {Src => Src.GetRenamed}/Modules/NtSignalState.cs (100%) rename {Src => Src.GetRenamed}/Modules/Properties/AssemblyInfo.cs (100%) rename {Src => Src.GetRenamed}/Modules/ResourceMetaPathImporter.cs (100%) rename {Src => Src.GetRenamed}/Modules/SimpleSignalState.cs (100%) rename {Src => Src.GetRenamed}/Modules/_bisect.cs (100%) rename {Src => Src.GetRenamed}/Modules/_codecs.cs (100%) rename {Src => Src.GetRenamed}/Modules/_codecs_cn.cs (100%) rename {Src => Src.GetRenamed}/Modules/_collections.cs (100%) rename {Src => Src.GetRenamed}/Modules/_csv.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/Array.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/ArrayType.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/CData.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/CFuncPtr.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/CFuncPtrType.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/Extensions.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/Field.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/INativeType.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/LocalOrArg.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/MarshalCleanup.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/MemoryHolder.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/NativeArgument.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/NativeFunctions.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/Pointer.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/PointerType.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/SimpleCData.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/SimpleType.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/SimpleTypeKind.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/StructType.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/Structure.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/Union.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/UnionType.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes/_ctypes.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ctypes_test.cs (100%) rename {Src => Src.GetRenamed}/Modules/_datetime.cs (100%) rename {Src => Src.GetRenamed}/Modules/_functools.cs (100%) rename {Src => Src.GetRenamed}/Modules/_heapq.cs (100%) rename {Src => Src.GetRenamed}/Modules/_multibytecodec.cs (100%) rename {Src => Src.GetRenamed}/Modules/_multiprocessing.cs (100%) rename {Src => Src.GetRenamed}/Modules/_opcode.cs (100%) rename {Src => Src.GetRenamed}/Modules/_operator.cs (100%) rename {Src => Src.GetRenamed}/Modules/_overlapped.cs (100%) rename {Src => Src.GetRenamed}/Modules/_pickle.cs (100%) rename {Src => Src.GetRenamed}/Modules/_posixsubprocess.cs (100%) rename {Src => Src.GetRenamed}/Modules/_random.RandomGen.cs (100%) rename {Src => Src.GetRenamed}/Modules/_random.cs (100%) rename {Src => Src.GetRenamed}/Modules/_socket.cs (100%) rename {Src => Src.GetRenamed}/Modules/_sre.cs (100%) rename {Src => Src.GetRenamed}/Modules/_ssl.cs (100%) rename {Src => Src.GetRenamed}/Modules/_string.cs (100%) rename {Src => Src.GetRenamed}/Modules/_struct.cs (100%) rename {Src => Src.GetRenamed}/Modules/_sysconfigdata.cs (100%) rename {Src => Src.GetRenamed}/Modules/_thread.cs (100%) rename {Src => Src.GetRenamed}/Modules/_warnings.cs (100%) rename {Src => Src.GetRenamed}/Modules/_weakref.Generated.cs (100%) rename {Src => Src.GetRenamed}/Modules/_weakref.cs (100%) rename {Src => Src.GetRenamed}/Modules/_winapi.cs (100%) rename {Src => Src.GetRenamed}/Modules/array.cs (100%) rename {Src => Src.GetRenamed}/Modules/atexit.cs (100%) rename {Src => Src.GetRenamed}/Modules/audioop.cs (100%) rename {Src => Src.GetRenamed}/Modules/binascii.cs (100%) rename {Src => Src.GetRenamed}/Modules/bz2/BZ2Compressor.cs (100%) rename {Src => Src.GetRenamed}/Modules/bz2/BZ2Decompressor.cs (100%) rename {Src => Src.GetRenamed}/Modules/bz2/BZ2Module.cs (100%) rename {Src => Src.GetRenamed}/Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs (100%) rename {Src => Src.GetRenamed}/Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs (100%) rename {Src => Src.GetRenamed}/Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs (100%) rename {Src => Src.GetRenamed}/Modules/bz2/dotnetzip/BZip2/BitWriter.cs (100%) rename {Src => Src.GetRenamed}/Modules/bz2/dotnetzip/BZip2/CRC32.cs (100%) rename {Src => Src.GetRenamed}/Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs (100%) rename {Src => Src.GetRenamed}/Modules/bz2/dotnetzip/BZip2/Rand.cs (100%) rename {Src => Src.GetRenamed}/Modules/bz2/dotnetzip/source.txt (100%) rename {Src => Src.GetRenamed}/Modules/cmath.cs (100%) rename {Src => Src.GetRenamed}/Modules/errno.cs (100%) rename {Src => Src.GetRenamed}/Modules/faulthandler.cs (100%) rename {Src => Src.GetRenamed}/Modules/fcntl.cs (100%) rename {Src => Src.GetRenamed}/Modules/gc.cs (100%) rename {Src => Src.GetRenamed}/Modules/grp.cs (100%) rename {Src => Src.GetRenamed}/Modules/hashlib/MD5CryptoServiceProvider.cs (100%) rename {Src => Src.GetRenamed}/Modules/hashlib/SHA1CryptoServiceProvider.cs (100%) rename {Src => Src.GetRenamed}/Modules/hashlib/SHA224.cs (100%) rename {Src => Src.GetRenamed}/Modules/hashlib/SHA224Managed.cs (100%) rename {Src => Src.GetRenamed}/Modules/hashlib/SHA256Managed.cs (100%) rename {Src => Src.GetRenamed}/Modules/hashlib/SHA384Managed.cs (100%) rename {Src => Src.GetRenamed}/Modules/hashlib/SHA512Managed.cs (100%) rename {Src => Src.GetRenamed}/Modules/hashlib/SHAConstants.cs (100%) rename {Src => Src.GetRenamed}/Modules/hashlib/_hashlib.cs (100%) rename {Src => Src.GetRenamed}/Modules/hashlib/_md5.cs (100%) rename {Src => Src.GetRenamed}/Modules/hashlib/_sha1.cs (100%) rename {Src => Src.GetRenamed}/Modules/hashlib/_sha256.cs (100%) rename {Src => Src.GetRenamed}/Modules/hashlib/_sha512.cs (100%) rename {Src => Src.GetRenamed}/Modules/marshal.cs (100%) rename {Src => Src.GetRenamed}/Modules/math.Generated.cs (100%) rename {Src => Src.GetRenamed}/Modules/math.cs (100%) rename {Src => Src.GetRenamed}/Modules/mmap.cs (100%) rename {Src => Src.GetRenamed}/Modules/msvcrt.cs (100%) rename {Src => Src.GetRenamed}/Modules/nt.cs (100%) rename {Src => Src.GetRenamed}/Modules/policy.IronPython.Modules.config (100%) rename {Src => Src.GetRenamed}/Modules/pwd.cs (100%) rename {Src => Src.GetRenamed}/Modules/pyexpat.cs (100%) rename {Src => Src.GetRenamed}/Modules/re.cs (100%) rename {Src => Src.GetRenamed}/Modules/resource.cs (100%) rename {Src => Src.GetRenamed}/Modules/select.cs (100%) rename {Src => Src.GetRenamed}/Modules/signal.cs (100%) rename {Src => Src.GetRenamed}/Modules/spwd.cs (100%) rename {Src => Src.GetRenamed}/Modules/time.cs (100%) rename {Src => Src.GetRenamed}/Modules/winreg.cs (100%) rename {Src => Src.GetRenamed}/Modules/winsound.cs (100%) rename {Src => Src.GetRenamed}/Modules/xxsubtype.cs (100%) rename {Src => Src.GetRenamed}/Modules/zipimport.cs (100%) rename {Src => Src.GetRenamed}/Modules/zlib/Compress.cs (100%) rename {Src => Src.GetRenamed}/Modules/zlib/Decompress.cs (100%) rename {Src => Src.GetRenamed}/Modules/zlib/ZlibModule.cs (100%) rename {Src => Src.GetRenamed}/Modules/zlib/zlib.net/Adler32.cs (100%) rename {Src => Src.GetRenamed}/Modules/zlib/zlib.net/Deflate.cs (100%) rename {Src => Src.GetRenamed}/Modules/zlib/zlib.net/InfBlocks.cs (100%) rename {Src => Src.GetRenamed}/Modules/zlib/zlib.net/InfCodes.cs (100%) rename {Src => Src.GetRenamed}/Modules/zlib/zlib.net/InfTree.cs (100%) rename {Src => Src.GetRenamed}/Modules/zlib/zlib.net/Inflate.cs (100%) rename {Src => Src.GetRenamed}/Modules/zlib/zlib.net/StaticTree.cs (100%) rename {Src => Src.GetRenamed}/Modules/zlib/zlib.net/Tree.cs (100%) rename {Src => Src.GetRenamed}/Modules/zlib/zlib.net/ZStream.cs (100%) rename {Src => Src.GetRenamed}/Modules/zlib/zlib.net/ZStreamException.cs (100%) rename {Src => Src.GetRenamed}/Modules/zlib/zlib.net/Zlib.cs (100%) rename {Src => Src.GetRenamed}/Modules/zlib/zlib.net/history.txt (100%) rename {Src => Src.GetRenamed}/Modules/zlib/zlib.net/license.txt (100%) rename {Src => Src.GetRenamed}/Modules/zlib/zlib.net/readme.txt (100%) rename {Src => Src.GetRenamed}/README.md (100%) rename {Src => Src.GetRenamed}/SQLite/Connection.cs (100%) rename {Src => Src.GetRenamed}/SQLite/Contants.cs (100%) rename {Src => Src.GetRenamed}/SQLite/Cursor.cs (100%) rename {Src => Src.GetRenamed}/SQLite/Exceptions.cs (100%) rename {Src => Src.GetRenamed}/SQLite/Extensions.cs (100%) rename {Src => Src.GetRenamed}/SQLite/IronPython.SQLite.csproj (100%) rename {Src => Src.GetRenamed}/SQLite/Properties/AssemblyInfo.cs (100%) rename {Src => Src.GetRenamed}/SQLite/Row.cs (100%) rename {Src => Src.GetRenamed}/SQLite/Statement.cs (100%) rename {Src => Src.GetRenamed}/SQLite/Util.cs (100%) rename {Src => Src.GetRenamed}/SQLite/_sqlite.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/.editorconfig (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/BtreeInt_h.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/Btree_h.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/Delegates.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/Hash_h.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/VdbeInt_h.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/Vdbe_h.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/_Custom.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/alter_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/analyze_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/attach_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/auth_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/backup_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/bitvec_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/btmutex_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/btree_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/build_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/callback_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/complete_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/crypto.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/ctime_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/date_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/delete_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/expr_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/fault_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/fkey_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/func_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/global_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/hash_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/hwtime_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/insert_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/journal_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/keywordhash_h.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/legacy_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/loadext_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/main_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/malloc_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/mem_Pool.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/memjournal_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/mutex_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/mutex_h.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/mutex_noop_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/mutex_w32.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/notify_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/opcodes_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/opcodes_h.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/os_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/os_common_h.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/os_h.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/os_win_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/pager_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/pager_h.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/parse_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/parse_h.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/pcache1_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/pcache_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/pcache_h.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/pragma_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/prepare_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/printf_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/random_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/resolve_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/rowset_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/select_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/sqlite3_h.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/sqliteInt_h.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/sqliteLimit_h.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/status_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/table_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/tokenize_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/trigger_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/update_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/utf_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/util_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/vacuum_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/vdbe_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/vdbeapi_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/vdbeaux_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/vdbeblob_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/vdbemem_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/vdbetrace_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/vtab_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/wal_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/wal_h.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/walker_c.cs (100%) rename {Src => Src.GetRenamed}/SQLite/c#sqlite/where_c.cs (100%) rename {Src => Src.GetRenamed}/Scripts/CompareDirs.py (100%) rename {Src => Src.GetRenamed}/Scripts/Enter-IronPythonEnvironment.ps1 (100%) rename {Src => Src.GetRenamed}/Scripts/Install-IronPython.ps1 (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/Scripts/clean.py (100%) rename {Src => Src.GetRenamed}/Scripts/copyrights.py (100%) rename {Src => Src.GetRenamed}/Scripts/generate.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/Scripts/generate_UncollectableCompilationMode.py (100%) rename {Src => Src.GetRenamed}/Scripts/generate_alltypes.py (100%) rename {Src => Src.GetRenamed}/Scripts/generate_calls.py (100%) rename {Src => Src.GetRenamed}/Scripts/generate_casts.py (100%) rename {Src => Src.GetRenamed}/Scripts/generate_comdispatch.py (100%) rename {Src => Src.GetRenamed}/Scripts/generate_dict_views.py (100%) rename {Src => Src.GetRenamed}/Scripts/generate_dynamic_instructions.py (100%) rename {Src => Src.GetRenamed}/Scripts/generate_dynsites.py (100%) rename {Src => Src.GetRenamed}/Scripts/generate_encoding_aliases.py (100%) rename {Src => Src.GetRenamed}/Scripts/generate_exception_factory.py (100%) rename {Src => Src.GetRenamed}/Scripts/generate_exceptions.py (100%) rename {Src => Src.GetRenamed}/Scripts/generate_indicestest.py (100%) rename {Src => Src.GetRenamed}/Scripts/generate_math.py (100%) rename {Src => Src.GetRenamed}/Scripts/generate_ops.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/Scripts/generate_os_codes.py (100%) rename {Src => Src.GetRenamed}/Scripts/generate_reflected_calls.py (100%) rename {Src => Src.GetRenamed}/Scripts/generate_set.py (100%) rename {Src => Src.GetRenamed}/Scripts/generate_tuples.py (100%) rename {Src => Src.GetRenamed}/Scripts/generate_typecache.py (100%) rename {Src => Src.GetRenamed}/Scripts/generate_walker.py (100%) rename {Src => Src.GetRenamed}/Scripts/ipcom.ps1 (100%) rename {Src => Src.GetRenamed}/Scripts/make_meta1.py (100%) rename {Src => Src.GetRenamed}/Scripts/radix_generator.py (100%) rename {Src => Src.GetRenamed}/Scripts/run_compiled.py (100%) rename {Src => Src.GetRenamed}/Scripts/run_interactive.py (100%) rename {Src => Src.GetRenamed}/Scripts/smtpmailer.py (100%) rename {Src => Src.GetRenamed}/Scripts/test_builder.py (100%) rename {Src => Src.GetRenamed}/Scripts/test_cgcheck.py (100%) rename {Src => Src.GetRenamed}/Scripts/test_parrot.py (100%) rename {Src => Src.GetRenamed}/Scripts/test_pystone.py (100%) rename {Src => Src.GetRenamed}/StdLib/.gitattributes (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/__future__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/__phello__.foo.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/_bootlocale.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/_collections_abc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/_compat_pickle.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/_dummy_thread.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/_markupbase.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/_osx_support.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/_pyio.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/_sitebuiltins.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/_strptime.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/_threading_local.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/_weakrefset.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/abc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/aifc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/antigravity.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/argparse.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ast.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asynchat.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/base_events.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/base_subprocess.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/compat.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/constants.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/coroutines.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/events.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/futures.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/locks.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/log.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/proactor_events.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/protocols.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/queues.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/selector_events.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/sslproto.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/streams.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/subprocess.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/tasks.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/test_utils.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/transports.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/unix_events.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/windows_events.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncio/windows_utils.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/asyncore.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/base64.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/bdb.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/binhex.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/bisect.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/bz2.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/cProfile.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/calendar.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/cgi.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/cgitb.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/chunk.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/clrtype.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/cmd.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/code.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/codecs.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/codeop.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/collections/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/collections/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/collections/abc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/colorsys.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/compileall.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/concurrent/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/concurrent/futures/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/concurrent/futures/_base.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/concurrent/futures/process.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/concurrent/futures/thread.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/configparser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/contextlib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/copy.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/copyreg.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/crypt.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/csv.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/_endian.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/macholib/README.ctypes (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/macholib/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/macholib/dyld.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/macholib/dylib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/macholib/fetch_macholib (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/macholib/fetch_macholib.bat (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/macholib/framework.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_anon.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_array_in_pointer.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_arrays.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_as_parameter.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_bitfields.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_buffers.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_bytes.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_byteswap.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_callbacks.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_cast.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_cfuncs.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_checkretval.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_delattr.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_errno.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_find.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_frombuffer.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_funcptr.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_functions.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_incomplete.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_init.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_internals.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_keeprefs.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_libc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_loading.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_macholib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_memfunctions.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_numbers.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_objects.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_parameters.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_pep3118.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_pickling.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_pointers.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_prototypes.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_python_api.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_random_things.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_refcounts.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_repr.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_returnfuncptrs.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_simplesubclasses.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_sizes.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_slicing.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_stringptr.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_strings.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_struct_fields.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_structures.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_unaligned_structures.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_unicode.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_values.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_varsize_struct.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_win32.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/test/test_wintypes.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ctypes/wintypes.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/curses/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/curses/ascii.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/curses/has_key.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/curses/panel.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/curses/textpad.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/datetime.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/dbm/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/dbm/dumb.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/dbm/gnu.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/dbm/ndbm.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/decimal.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/difflib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/dis.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/README (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/archive_util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/bcppcompiler.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/ccompiler.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/cmd.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/bdist.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/bdist_dumb.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/bdist_msi.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/bdist_rpm.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/bdist_wininst.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/build.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/build_clib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/build_ext.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/build_py.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/build_scripts.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/check.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/clean.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/command_template (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/config.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/install.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/install_data.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/install_egg_info.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/install_headers.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/install_lib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/install_scripts.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/register.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/sdist.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/upload.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/wininst-10.0.exe (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/wininst-6.0.exe (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/wininst-7.1.exe (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/wininst-8.0.exe (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/command/wininst-9.0.exe (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/config.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/core.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/cygwinccompiler.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/debug.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/dep_util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/dir_util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/dist.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/errors.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/extension.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/fancy_getopt.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/file_util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/filelist.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/log.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/msvc9compiler.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/msvccompiler.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/spawn.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/sysconfig.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/Setup.sample (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/support.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_archive_util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_bdist.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_bdist_dumb.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_bdist_msi.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_bdist_rpm.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_bdist_wininst.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_build.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_build_clib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_build_ext.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_build_py.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_build_scripts.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_check.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_clean.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_cmd.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_config.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_config_cmd.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_core.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_cygwinccompiler.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_dep_util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_dir_util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_dist.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_extension.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_file_util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_filelist.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_install.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_install_data.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_install_headers.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_install_lib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_install_scripts.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_log.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_msvc9compiler.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_register.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_sdist.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_spawn.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_sysconfig.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_text_file.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_unixccompiler.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_upload.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_version.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/tests/test_versionpredicate.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/text_file.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/unixccompiler.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/version.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/distutils/versionpredicate.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/doctest.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/dummy_threading.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/_encoded_words.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/_header_value_parser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/_parseaddr.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/_policybase.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/architecture.rst (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/base64mime.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/charset.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/contentmanager.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/encoders.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/errors.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/feedparser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/generator.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/header.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/headerregistry.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/iterators.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/message.py (100%) rename {PythonTests/compat/sbs_exceptions => Src.GetRenamed/StdLib/Lib/email/mime}/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/mime/application.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/mime/audio.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/mime/base.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/mime/image.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/mime/message.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/mime/multipart.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/mime/nonmultipart.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/mime/text.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/parser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/policy.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/quoprimime.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/email/utils.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/aliases.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/ascii.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/base64_codec.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/big5.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/big5hkscs.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/bz2_codec.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/charmap.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp037.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp1006.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp1026.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp1125.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp1140.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp1250.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp1251.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp1252.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp1253.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp1254.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp1255.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp1256.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp1257.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp1258.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp273.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp424.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp437.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp500.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp65001.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp720.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp737.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp775.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp850.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp852.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp855.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp856.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp857.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp858.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp860.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp861.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp862.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp863.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp864.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp865.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp866.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp869.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp874.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp875.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp932.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp949.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/cp950.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/euc_jis_2004.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/euc_jisx0213.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/euc_jp.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/euc_kr.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/gb18030.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/gb2312.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/gbk.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/hex_codec.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/hp_roman8.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/hz.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/idna.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso2022_jp.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso2022_jp_1.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso2022_jp_2.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso2022_jp_2004.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso2022_jp_3.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso2022_jp_ext.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso2022_kr.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso8859_1.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso8859_10.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso8859_11.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso8859_13.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso8859_14.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso8859_15.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso8859_16.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso8859_2.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso8859_3.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso8859_4.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso8859_5.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso8859_6.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso8859_7.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso8859_8.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/iso8859_9.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/johab.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/koi8_r.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/koi8_u.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/latin_1.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/mac_arabic.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/mac_centeuro.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/mac_croatian.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/mac_cyrillic.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/mac_farsi.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/mac_greek.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/mac_iceland.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/mac_latin2.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/mac_roman.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/mac_romanian.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/mac_turkish.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/mbcs.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/palmos.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/ptcp154.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/punycode.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/quopri_codec.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/raw_unicode_escape.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/rot_13.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/shift_jis.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/shift_jis_2004.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/shift_jisx0213.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/tis_620.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/undefined.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/unicode_escape.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/unicode_internal.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/utf_16.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/utf_16_be.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/utf_16_le.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/utf_32.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/utf_32_be.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/utf_32_le.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/utf_7.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/utf_8.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/utf_8_sig.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/uu_codec.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/encodings/zlib_codec.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ensurepip/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ensurepip/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ensurepip/_uninstall.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/enum.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/filecmp.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/fileinput.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/fnmatch.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/formatter.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/fractions.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ftplib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/functools.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/genericpath.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/getopt.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/getpass.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/gettext.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/glob.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/gzip.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/hashlib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/heapq.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/hmac.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/html/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/html/entities.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/html/parser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/http/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/http/client.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/http/cookiejar.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/http/cookies.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/http/server.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/AutoComplete.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/AutoCompleteWindow.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/AutoExpand.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/Bindings.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/CREDITS.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/CallTipWindow.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/CallTips.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/ChangeLog (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/ClassBrowser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/CodeContext.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/ColorDelegator.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/Debugger.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/Delegator.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/EditorWindow.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/FileList.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/FormatParagraph.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/GrepDialog.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/HISTORY.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/HyperParser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/IOBinding.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/Icons/folder.gif (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/Icons/idle.icns (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/Icons/idle.ico (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/Icons/idle_16.gif (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/Icons/idle_16.png (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/Icons/idle_32.gif (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/Icons/idle_32.png (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/Icons/idle_48.gif (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/Icons/idle_48.png (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/Icons/minusnode.gif (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/Icons/openfolder.gif (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/Icons/plusnode.gif (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/Icons/python.gif (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/Icons/tk.gif (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/IdleHistory.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/MultiCall.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/MultiStatusBar.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/NEWS.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/ObjectBrowser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/OutputWindow.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/ParenMatch.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/PathBrowser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/Percolator.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/PyParse.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/PyShell.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/README.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/RemoteDebugger.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/RemoteObjectBrowser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/ReplaceDialog.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/RstripExtension.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/ScriptBinding.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/ScrolledList.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/SearchDialog.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/SearchDialogBase.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/SearchEngine.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/StackViewer.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/TODO.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/ToolTip.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/TreeWidget.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/UndoDelegator.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/WidgetRedirector.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/WindowList.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/ZoomHeight.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/aboutDialog.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/config-extensions.def (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/config-highlight.def (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/config-keys.def (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/config-main.def (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/configDialog.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/configHandler.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/configHelpSourceEdit.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/configSectionNameDialog.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/dynOptionMenuWidget.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/extend.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/help.html (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/help.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/help.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle.bat (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle.pyw (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/README.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/htest.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/mock_idle.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/mock_tk.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/test_autocomplete.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/test_autoexpand.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/test_calltips.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/test_config_name.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/test_configdialog.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/test_delegator.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/test_editor.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/test_grep.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/test_hyperparser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/test_idlehistory.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/test_io.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/test_parenmatch.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/test_rstrip.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/test_searchengine.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/test_text.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/test_textview.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/test_warning.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idle_test/test_widgetredir.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/idlever.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/keybindingDialog.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/macosxSupport.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/rpc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/run.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/tabbedpages.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/idlelib/textView.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/imaplib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/imghdr.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/imp.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/importlib/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/importlib/_bootstrap.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/importlib/abc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/importlib/machinery.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/importlib/util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/inspect.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/io.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ipaddress.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/json/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/json/decoder.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/json/encoder.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/json/scanner.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/json/tool.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/keyword.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/Grammar.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/PatternGrammar.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/btm_matcher.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/btm_utils.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixer_base.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixer_util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_apply.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_asserts.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_basestring.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_buffer.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_callable.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_dict.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_except.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_exec.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_execfile.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_filter.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_future.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_has_key.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_idioms.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_import.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_imports.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_imports2.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_input.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_intern.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_isinstance.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_itertools.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_long.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_map.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_metaclass.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_ne.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_next.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_nonzero.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_numliterals.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_operator.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_paren.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_print.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_raise.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_raw_input.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_reduce.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_reload.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_renames.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_repr.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_set_literal.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_standarderror.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_throw.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_types.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_unicode.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_urllib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_xrange.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/fixes/fix_zip.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/main.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/patcomp.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/pgen2/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/pgen2/conv.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/pgen2/driver.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/pgen2/grammar.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/pgen2/literals.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/pgen2/parse.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/pgen2/pgen.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/pgen2/token.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/pgen2/tokenize.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/pygram.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/pytree.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/refactor.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/data/README (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/data/bom.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/data/crlf.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/data/different_encoding.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/data/false_encoding.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py (100%) rename {PythonTests/import_extant/_vendor => Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes}/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/pytree_idempotency.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/support.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/test_all_fixers.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/test_fixers.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/test_main.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/test_parser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/test_pytree.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/test_refactor.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lib2to3/tests/test_util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/linecache.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/locale.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/logging/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/logging/config.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/logging/handlers.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/lzma.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/macpath.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/macurl2path.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/mailbox.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/mailcap.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/mimetypes.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/modulefinder.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/msilib/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/msilib/schema.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/msilib/sequence.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/msilib/text.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/connection.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/context.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/dummy/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/dummy/connection.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/forkserver.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/heap.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/managers.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/pool.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/popen_fork.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/popen_forkserver.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/popen_spawn_posix.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/popen_spawn_win32.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/process.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/queues.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/reduction.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/resource_sharer.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/semaphore_tracker.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/sharedctypes.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/spawn.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/synchronize.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/multiprocessing/util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/netrc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/nntplib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ntpath.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/nturl2path.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/numbers.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/opcode.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/operator.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/optparse.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/os.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/pathlib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/pdb.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/pickle.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/pickletools.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/pipes.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/pkgutil.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/platform.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/plistlib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/poplib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/posixpath.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/pprint.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/profile.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/pstats.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/pty.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/py_compile.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/pyclbr.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/pydoc.py (100%) mode change 100755 => 100644 rename {PythonTests/import_extant/_vendor/packaging => Src.GetRenamed/StdLib/Lib/pydoc_data}/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/pydoc_data/_pydoc.css (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/pydoc_data/topics.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/queue.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/quopri.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/random.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/re.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/reprlib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/rlcompleter.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/runpy.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/sched.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/selectors.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/shelve.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/shlex.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/shutil.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/site-packages/README (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/site.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/smtpd.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/smtplib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/sndhdr.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/socket.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/socketserver.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/sqlite3/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/sqlite3/dbapi2.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/sqlite3/dump.py (100%) rename {PythonTests/pyc/pkg => Src.GetRenamed/StdLib/Lib/sqlite3/test}/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/sqlite3/test/dbapi.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/sqlite3/test/dump.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/sqlite3/test/factory.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/sqlite3/test/hooks.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/sqlite3/test/regression.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/sqlite3/test/transactions.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/sqlite3/test/types.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/sqlite3/test/userfunctions.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/sre_compile.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/sre_constants.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/sre_parse.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/ssl.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/stat.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/statistics.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/string.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/stringprep.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/struct.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/subprocess.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/sunau.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/symbol.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/symtable.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/sysconfig.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tabnanny.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/tarfile.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/telnetlib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tempfile.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/185test.db (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/Sine-1000Hz-300ms.aif (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/_test_multiprocessing.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/audiodata/pluck-alaw.aifc (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/audiodata/pluck-pcm16.aiff (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/audiodata/pluck-pcm16.au (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/audiodata/pluck-pcm16.wav (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/audiodata/pluck-pcm24.aiff (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/audiodata/pluck-pcm24.au (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/audiodata/pluck-pcm24.wav (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/audiodata/pluck-pcm32.aiff (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/audiodata/pluck-pcm32.au (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/audiodata/pluck-pcm32.wav (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/audiodata/pluck-pcm8.aiff (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/audiodata/pluck-pcm8.au (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/audiodata/pluck-pcm8.wav (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/audiodata/pluck-ulaw.aifc (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/audiodata/pluck-ulaw.au (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/audiotest.au (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/audiotests.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/autotest.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/bad_coding.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/bad_coding2.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/badcert.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/badkey.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/badsyntax_3131.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/badsyntax_future10.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/badsyntax_future3.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/badsyntax_future4.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/badsyntax_future5.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/badsyntax_future6.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/badsyntax_future7.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/badsyntax_future8.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/badsyntax_future9.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/badsyntax_pep3120.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/buffer_tests.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/bytecode_helper.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/capath/0e4015b9.0 (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/capath/4e1295a3.0 (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/capath/5ed36f99.0 (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/capath/6e88d7b8.0 (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/capath/99d0fa06.0 (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/capath/ce7b8643.0 (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cfgparser.1 (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cfgparser.2 (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cfgparser.3 (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/check_soundcard.vbs (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/big5-utf8.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/big5.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/big5hkscs.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/cp949-utf8.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/cp949.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/euc_jp.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/euc_kr.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/gb18030.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/gb2312.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/gbk-utf8.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/gbk.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/hz-utf8.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/hz.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/iso2022_jp.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/iso2022_kr.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/johab-utf8.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/johab.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/shift_jis.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/cmath_testcases.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/coding20731.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/crashers/README (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/crashers/bogus_code_obj.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/crashers/gc_inspection.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/crashers/infinite_loop_re.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/crashers/recursive_call.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/crashers/trace_at_recursion_limit.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/crashers/underlying_dict.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/curses_tests.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/data/README (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/datetimetester.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/abs.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/add.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/and.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/base.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/clamp.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/class.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/compare.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/comparetotal.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/copy.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/copyabs.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/copynegate.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/copysign.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddAbs.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddAdd.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddAnd.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddBase.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddClass.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddCompare.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddCopy.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddDivide.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddEncode.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddFMA.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddInvert.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddLogB.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddMax.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddMin.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddMinus.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddOr.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddPlus.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddReduce.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddRotate.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddShift.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ddXor.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/decDouble.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/decQuad.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/decSingle.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/divide.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/divideint.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqAbs.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqAdd.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqAnd.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqBase.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqClass.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqCompare.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqCopy.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqDivide.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqEncode.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqFMA.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqInvert.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqLogB.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqMax.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqMin.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqMinus.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqOr.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqPlus.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqReduce.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqRotate.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqShift.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dqXor.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dsBase.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/dsEncode.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/exp.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/extra.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/fma.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/inexact.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/invert.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/ln.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/log10.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/logb.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/max.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/maxmag.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/min.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/minmag.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/minus.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/multiply.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/nextminus.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/nextplus.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/nexttoward.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/or.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/plus.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/power.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/powersqrt.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/quantize.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/randomBound32.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/randoms.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/reduce.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/remainder.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/remainderNear.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/rescale.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/rotate.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/rounding.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/samequantum.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/scaleb.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/shift.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/squareroot.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/subtract.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/testall.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/tointegral.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/tointegralx.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/decimaltestdata/xor.decTest (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/dh1024.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/dis_module.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/doctest_aliases.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/double_const.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/empty.vbs (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/encoded_modules/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/encoded_modules/module_koi8_r.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/exception_hierarchy.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/final_a.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/final_b.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/floating_points.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/fork_wait.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/formatfloat_testcases.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/future_test1.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/future_test2.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/gdb_sample.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/ieee754.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/imghdrdata/python.bmp (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/imghdrdata/python.gif (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/imghdrdata/python.jpg (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/imghdrdata/python.pbm (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/imghdrdata/python.pgm (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/imghdrdata/python.png (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/imghdrdata/python.ppm (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/imghdrdata/python.ras (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/imghdrdata/python.sgi (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/imghdrdata/python.tiff (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/imghdrdata/python.xbm (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/inspect_fodder.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/inspect_fodder2.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/keycert.passwd.pem (100%) rename {PythonTests/modules/network_related => Src.GetRenamed/StdLib/Lib/test}/keycert.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/keycert2.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/keycert3.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/keycert4.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/leakers/README.txt (100%) rename {Src/StdLib/Lib/email/mime => Src.GetRenamed/StdLib/Lib/test/leakers}/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/leakers/test_ctypes.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/leakers/test_selftype.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/list_tests.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/lock_tests.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/mailcap.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/make_ssl_certs.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/mapping_tests.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/math_testcases.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/memory_watchdog.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/mime.types (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/mock_socket.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/mod_generics_cache.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/mp_fork_bomb.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/multibytecodec_support.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/nokia.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/nullbytecert.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/nullcert.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/outstanding_bugs.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/pickletester.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/profilee.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/pstats.pck (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/pycacert.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/pycakey.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/pyclbr_input.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/pydoc_mod.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/pydocfodder.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/pystone.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/test/randv2_32.pck (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/randv2_64.pck (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/randv3.pck (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/re_tests.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/test/regrtest.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/test/relimport.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/reperf.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/revocation.crl (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/sample_doctest.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/sample_doctest_no_docstrings.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/sample_doctest_no_doctests.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/script_helper.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/selfsigned_pythontestdotnet.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/seq_tests.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/sgml_input.html (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/sha256.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/sndhdrdata/README (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/sndhdrdata/sndhdr.8svx (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/sndhdrdata/sndhdr.aifc (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/sndhdrdata/sndhdr.aiff (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/sndhdrdata/sndhdr.au (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/sndhdrdata/sndhdr.hcom (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/sndhdrdata/sndhdr.sndt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/sndhdrdata/sndhdr.voc (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/sndhdrdata/sndhdr.wav (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/sortperf.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/ssl_cert.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/ssl_key.passwd.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/ssl_key.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/ssl_servers.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/ssltests.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/test/string_tests.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/subprocessdata/fd_status.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/subprocessdata/input_reader.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/subprocessdata/qcat.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/subprocessdata/qgrep.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/subprocessdata/sigchild_ignore.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/support/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/talos-2019-0758.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test___all__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test___future__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test__locale.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test__opcode.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test__osx_support.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_abc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_abstract_numbers.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_aifc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_argparse.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_array.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_ast.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asynchat.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/echo.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/echo2.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/echo3.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/keycert3.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/pycacert.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/ssl_cert.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/ssl_key.pem (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/test_base_events.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/test_events.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/test_futures.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/test_locks.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/test_proactor_events.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/test_queues.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/test_selector_events.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/test_sslproto.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/test_streams.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/test_subprocess.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/test_tasks.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/test_transports.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/test_unix_events.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/test_windows_events.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncio/test_windows_utils.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_asyncore.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_atexit.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_audioop.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_augassign.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_base64.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_bigaddrspace.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_bigmem.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_binascii.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_binhex.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_binop.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_bisect.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_bool.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_buffer.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_bufio.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_builtin.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_bytes.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_bz2.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_calendar.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_call.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_capi.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_cgi.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_cgitb.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_charmapcodec.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_class.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_cmath.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_cmd.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_cmd_line.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_cmd_line_script.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_code.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_code_module.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_codeccallbacks.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_codecencodings_cn.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_codecencodings_hk.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_codecencodings_iso2022.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_codecencodings_jp.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_codecencodings_kr.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_codecencodings_tw.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_codecmaps_cn.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_codecmaps_hk.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_codecmaps_jp.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_codecmaps_kr.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_codecmaps_tw.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_codecs.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_codeop.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_collections.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_colorsys.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_compare.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_compile.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_compileall.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_complex.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_concurrent_futures.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_configparser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_contains.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_contextlib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_copy.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_copyreg.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_cprofile.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_crashers.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_crypt.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_csv.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_ctypes.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_curses.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_datetime.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_dbm.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_dbm_dumb.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_dbm_gnu.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_dbm_ndbm.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_decimal.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_decorators.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_defaultdict.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_deque.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_descr.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_descrtut.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_devpoll.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_dict.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_dictcomps.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_dictviews.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_difflib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_difflib_expect.html (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_dis.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_distutils.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_doctest.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_doctest.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_doctest2.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_doctest2.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_doctest3.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_doctest4.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_docxmlrpc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_dummy_thread.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_dummy_threading.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_dynamic.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_dynamicclassattribute.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/PyBanner048.gif (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/audiotest.au (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_01.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_02.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_03.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_04.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_05.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_06.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_07.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_08.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_09.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_10.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_11.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_12.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_12a.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_13.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_14.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_15.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_16.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_17.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_18.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_19.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_20.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_21.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_22.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_23.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_24.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_25.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_26.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_27.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_28.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_29.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_30.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_31.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_32.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_33.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_34.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_35.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_36.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_37.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_38.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_39.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_40.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_41.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_42.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_43.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_44.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_45.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/data/msg_46.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/test__encoded_words.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/test__header_value_parser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/test_asian_codecs.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/test_contentmanager.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/test_defect_handling.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/test_email.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/test_generator.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/test_headerregistry.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/test_inversion.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/test_message.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/test_parser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/test_pickleable.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/test_policy.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/test_utils.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_email/torture_test.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_ensurepip.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_enum.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_enumerate.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_eof.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_epoll.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_errno.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_exception_variations.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_exceptions.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_extcall.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_faulthandler.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_fcntl.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_file.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_file_eintr.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_filecmp.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_fileinput.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_fileio.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_finalization.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_float.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_flufl.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_fnmatch.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_fork1.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_format.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_fractions.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_frame.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_fstring.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_ftplib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_funcattrs.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_functools.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_future.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_future3.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_future4.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_future5.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_gc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_gdb.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_generators.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_genericpath.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_genexps.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_getargs2.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_getopt.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_getpass.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_gettext.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_glob.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_global.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_grammar.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_grp.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_gzip.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_hash.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_hashlib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_heapq.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_hmac.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_html.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_htmlparser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_http_cookiejar.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_http_cookies.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_httplib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_httpservers.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_idle.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_imaplib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_imghdr.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_imp.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_import.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/abc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/builtin/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/builtin/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/builtin/test_finder.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/builtin/test_loader.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/builtin/util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/extension/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/extension/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/extension/test_finder.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/extension/test_loader.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/extension/test_path_hook.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/extension/util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/frozen/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/frozen/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/frozen/test_finder.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/frozen/test_loader.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/import_/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/import_/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/import_/test___loader__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/import_/test___package__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/import_/test_api.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/import_/test_caching.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/import_/test_fromlist.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/import_/test_meta_path.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/import_/test_packages.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/import_/test_path.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/import_/util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip (100%) rename {Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes => Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo}/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/regrtest.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/source/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/source/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/source/test_file_loader.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/source/test_finder.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/source/test_path_hook.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/source/test_source_encoding.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/source/util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/test_abc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/test_api.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/test_locks.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/test_spec.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/test_util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/test_windows.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_importlib/util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_index.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_inspect.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_int.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_int_literal.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_io.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_ioctl.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_ipaddress.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_isinstance.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_iter.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_iterlen.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_itertools.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_json/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_json/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_json/test_decode.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_json/test_default.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_json/test_dump.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_json/test_enum.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_json/test_fail.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_json/test_float.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_json/test_indent.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_json/test_pass1.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_json/test_pass2.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_json/test_pass3.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_json/test_recursion.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_json/test_scanstring.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_json/test_separators.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_json/test_speedups.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_json/test_tool.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_json/test_unicode.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_keyword.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_keywordonlyarg.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_kqueue.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_largefile.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_lib2to3.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_linecache.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_list.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_listcomps.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_locale.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_logging.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_long.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_longexp.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_lzma.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_macpath.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_macurl2path.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_mailbox.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_mailcap.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_marshal.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_math.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_memoryio.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_memoryview.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_metaclass.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_mimetypes.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_minidom.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_mmap.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_module.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_modulefinder.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_msilib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_multibytecodec.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_multiprocessing_fork.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_multiprocessing_forkserver.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_multiprocessing_main_handling.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_multiprocessing_spawn.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_netrc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_nis.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_nntplib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_normalization.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_ntpath.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_numeric_tower.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_opcodes.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_openpty.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_operator.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_optparse.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_ordered_dict.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_os.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_ossaudiodev.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_osx_env.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_parser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pathlib.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pdb.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_peepholer.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pep247.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pep277.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pep292.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pep3120.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pep3131.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pep3151.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pep352.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pep380.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pep479.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pickle.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pickletools.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pipes.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pkg.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pkgimport.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pkgutil.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_platform.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_plistlib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_poll.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_popen.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_poplib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_posix.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_posixpath.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pow.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pprint.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_print.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_profile.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_property.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pstats.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pty.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pulldom.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pwd.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_py_compile.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pyclbr.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pydoc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_pyexpat.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_queue.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_quopri.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_raise.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_random.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_range.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_re.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_readline.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_regrtest.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_reprlib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_resource.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_richcmp.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_rlcompleter.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_robotparser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_runpy.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_sax.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_sched.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_scope.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_script_helper.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_select.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_selectors.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_set.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_setcomps.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_shelve.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_shlex.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_shutil.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_signal.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_site.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_slice.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_smtpd.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_smtplib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_smtpnet.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_sndhdr.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_socket.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_socketserver.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_sort.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_source_encoding.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_spwd.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_sqlite.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_ssl.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_startfile.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_stat.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_statistics.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_strftime.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_string.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_stringprep.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_strlit.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_strptime.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_strtod.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_struct.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_structmembers.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_structseq.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_subprocess.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_sunau.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_sundry.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_super.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_support.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_symtable.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_syntax.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_sys.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_sys_setprofile.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_sys_settrace.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_sysconfig.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_syslog.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_tarfile.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_tcl.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_telnetlib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_tempfile.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_textwrap.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_thread.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_threaded_import.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_threadedtempfile.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_threading.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_threading_local.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_threadsignals.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_time.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_timeit.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_timeout.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_tk.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_tokenize.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_tools/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_tools/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_tools/test_gprof2html.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_tools/test_md5sum.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_tools/test_pdeps.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_tools/test_pindent.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_tools/test_reindent.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_tools/test_sundry.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_tools/test_unparse.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_trace.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_traceback.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_tracemalloc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_ttk_guionly.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_ttk_textonly.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_tuple.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_typechecks.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_types.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_typing.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_ucn.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_unary.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_unicode.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_unicode_file.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_unicodedata.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_unittest.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_univnewlines.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_unpack.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_unpack_ex.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_urllib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_urllib2.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_urllib2_localnet.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_urllib2net.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_urllib_response.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_urllibnet.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_urlparse.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_userdict.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_userlist.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_userstring.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_utf8_mode.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_uu.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_uuid.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_venv.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_wait3.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_wait4.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_warnings.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_wave.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_weakref.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_weakset.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_webbrowser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_winreg.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_winsound.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_with.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_wsgiref.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_xdrlib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_xml_dom_minicompat.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_xml_etree.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_xml_etree_c.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_xmlrpc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_xmlrpc_net.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_zipfile.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_zipfile64.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_zipimport.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_zipimport_support.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/test_zlib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/testcodec.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/testtar.tar (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/tf_inherit_check.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/threaded_import_hangers.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/time_hashlib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/tokenize_tests.txt (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/tracedmodules/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/tracedmodules/testmod.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/warning_tests.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/win_console_handler.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/xmltestdata/simple-ns.xml (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/xmltestdata/simple.xml (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/xmltestdata/test.xml (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/xmltestdata/test.xml.out (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/xmltests.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/zip_cp437_header.zip (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/test/zipdir.zip (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/textwrap.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/this.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/threading.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/timeit.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/_fix.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/colorchooser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/commondialog.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/constants.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/dialog.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/dnd.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/filedialog.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/font.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/messagebox.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/scrolledtext.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/simpledialog.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/test/README (100%) rename {Src/StdLib/Lib/pydoc_data => Src.GetRenamed/StdLib/Lib/tkinter/test}/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/test/runtktests.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/test/support.py (100%) rename {Src/StdLib/Lib/sqlite3/test => Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter}/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/test/test_tkinter/test_font.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/test/test_tkinter/test_images.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/test/test_tkinter/test_text.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py (100%) rename {Src/StdLib/Lib/test/leakers => Src.GetRenamed/StdLib/Lib/tkinter/test/test_ttk}/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/test/test_ttk/test_functions.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/test/test_ttk/test_style.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/test/widget_tests.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/tix.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tkinter/ttk.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/token.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/tokenize.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/trace.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/traceback.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tracemalloc.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/tty.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/turtle.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/turtledemo/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/turtledemo/__main__.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/turtledemo/bytedesign.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/turtledemo/chaos.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/turtledemo/clock.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/turtledemo/colormixer.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/turtledemo/forest.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/turtledemo/fractalcurves.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/turtledemo/lindenmayer.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/turtledemo/minimal_hanoi.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/turtledemo/nim.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/turtledemo/paint.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/turtledemo/peace.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/turtledemo/penrose.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/turtledemo/planet_and_moon.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/turtledemo/round_dance.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/turtledemo/tree.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/turtledemo/turtle.cfg (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/turtledemo/two_canvases.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/turtledemo/wikipedia.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/turtledemo/yinyang.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/types.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/typing.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/case.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/loader.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/main.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/mock.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/result.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/runner.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/signals.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/suite.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/_test_warnings.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/dummy.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/support.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/test_assertions.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/test_break.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/test_case.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/test_discovery.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/test_functiontestcase.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/test_loader.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/test_program.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/test_result.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/test_runner.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/test_setups.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/test_skipping.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/test_suite.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/testmock/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/testmock/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/testmock/support.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/testmock/testcallable.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/testmock/testhelpers.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/testmock/testmagicmethods.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/testmock/testmock.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/testmock/testpatch.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/testmock/testsentinel.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/test/testmock/testwith.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/unittest/util.py (100%) rename {Src/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo => Src.GetRenamed/StdLib/Lib/urllib}/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/urllib/error.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/urllib/parse.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/urllib/request.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/urllib/response.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/urllib/robotparser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/uu.py (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/StdLib/Lib/uuid.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/venv/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/venv/__main__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/venv/scripts/nt/Activate.ps1 (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/venv/scripts/nt/activate.bat (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/venv/scripts/nt/deactivate.bat (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/venv/scripts/posix/activate (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/venv/scripts/posix/activate.csh (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/venv/scripts/posix/activate.fish (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/warnings.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/wave.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/weakref.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/webbrowser.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/wpf.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/wsgiref/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/wsgiref/handlers.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/wsgiref/headers.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/wsgiref/simple_server.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/wsgiref/util.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/wsgiref/validate.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xdrlib.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/dom/NodeFilter.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/dom/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/dom/domreg.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/dom/expatbuilder.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/dom/minicompat.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/dom/minidom.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/dom/pulldom.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/dom/xmlbuilder.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/etree/ElementInclude.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/etree/ElementPath.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/etree/ElementTree.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/etree/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/etree/cElementTree.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/parsers/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/parsers/expat.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/sax/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/sax/_exceptions.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/sax/expatreader.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/sax/handler.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/sax/saxutils.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xml/sax/xmlreader.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xmlrpc/__init__.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xmlrpc/client.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/xmlrpc/server.py (100%) rename {Src => Src.GetRenamed}/StdLib/Lib/zipfile.py (100%) rename {Src => Src.GetRenamed}/StdLib/StdLib.License.txt (100%) rename {Src => Src.GetRenamed}/StdLib/StdLib.pyproj (100%) rename {Src => Src.GetRenamed}/StdLib/stdlib-upgrade.txt (100%) rename {Src => Src.GetRenamed}/StdLib/update-stdlib.cmd (100%) rename {Src => Src.GetRenamed}/StdLib/update-stdlib.sh (100%) mode change 100755 => 100644 rename {Src => Src.GetRenamed}/Tests/AssemblyInfo.cs (100%) rename {Src => Src.GetRenamed}/Tests/AttrInjectorTest.cs (100%) rename {Src => Src.GetRenamed}/Tests/BindTest.cs (100%) rename {Src => Src.GetRenamed}/Tests/BinderTest.cs (100%) rename {Src => Src.GetRenamed}/Tests/Cases/CPythonCases.cs (100%) rename {Src => Src.GetRenamed}/Tests/Cases/CPythonCasesManifest.ini (100%) rename {Src => Src.GetRenamed}/Tests/Cases/CaseExecuter.cs (100%) rename {Src => Src.GetRenamed}/Tests/Cases/CaseGenerator.cs (100%) rename {Src => Src.GetRenamed}/Tests/Cases/CommonCases.cs (100%) rename {Src => Src.GetRenamed}/Tests/Cases/IronPythonCases.cs (100%) rename {Src => Src.GetRenamed}/Tests/Cases/IronPythonCasesManifest.ini (100%) rename {Src => Src.GetRenamed}/Tests/ClrType.cs (100%) rename {Src => Src.GetRenamed}/Tests/Cmplx.cs (100%) rename {Src => Src.GetRenamed}/Tests/Conversions.cs (100%) rename {Src => Src.GetRenamed}/Tests/DeTest.cs (100%) rename {Src => Src.GetRenamed}/Tests/DelegateTest.cs (100%) rename {Src => Src.GetRenamed}/Tests/DynamicRegressions.cs (100%) rename {Src => Src.GetRenamed}/Tests/EncodingTest.cs (100%) rename {Src => Src.GetRenamed}/Tests/EngineTest.cs (100%) rename {Src => Src.GetRenamed}/Tests/Enums.cs (100%) rename {Src => Src.GetRenamed}/Tests/Events.cs (100%) rename {Src => Src.GetRenamed}/Tests/ExceptionConverter.cs (100%) rename {Src => Src.GetRenamed}/Tests/Exceptions.cs (100%) rename {Src => Src.GetRenamed}/Tests/Explicit.cs (100%) rename {Src => Src.GetRenamed}/Tests/ExtensionMethodTest.cs (100%) rename {Src => Src.GetRenamed}/Tests/GenMeth.cs (100%) rename {Src => Src.GetRenamed}/Tests/Indexable.cs (100%) rename {Src => Src.GetRenamed}/Tests/InheritTest.cs (100%) rename {Src => Src.GetRenamed}/Tests/IntegerTest.cs (100%) rename {Src => Src.GetRenamed}/Tests/IronMath.cs (100%) rename {Src => Src.GetRenamed}/Tests/IronPython.Tests.csproj (100%) rename {Src => Src.GetRenamed}/Tests/LoadTest.cs (100%) rename {Src => Src.GetRenamed}/Tests/MemberMappingTests.cs (100%) rename {Src => Src.GetRenamed}/Tests/MemberOverloadTest.cs (100%) rename {Src => Src.GetRenamed}/Tests/MethodParametersStubs.cs (100%) rename {Src => Src.GetRenamed}/Tests/NestedClass.cs (100%) rename {Src => Src.GetRenamed}/Tests/NullableTest.cs (100%) rename {Src => Src.GetRenamed}/Tests/OperatorTest.cs (100%) rename {Src => Src.GetRenamed}/Tests/ProtocolTest.cs (100%) rename {Src => Src.GetRenamed}/Tests/StaticTest.cs (100%) rename {Src => Src.GetRenamed}/Tests/Stress/Engine.cs (100%) rename {Src => Src.GetRenamed}/Tests/StringDictionaryStorage.cs (100%) rename {Src => Src.GetRenamed}/Tests/TestBuiltinModule.cs (100%) rename {Src => Src.GetRenamed}/Tests/TypeDescriptor.cs (100%) rename {Src => Src.GetRenamed}/Tests/Util/IniParser.cs (100%) rename {Src => Src.GetRenamed}/Tests/Util/TestManifest.cs (100%) rename {Src => Src.GetRenamed}/Wpf/DynamicXamlReader.cs (100%) rename {Src => Src.GetRenamed}/Wpf/IronPython.Wpf.csproj (100%) rename {Src => Src.GetRenamed}/Wpf/Properties/AssemblyInfo.cs (100%) rename {Src => Src.GetRenamed}/Wpf/_wpf.cs (100%) delete mode 160000 Src/DLR rename {Utils => Utils.GetRenamed}/NuGet/nuget.exe (100%) rename {Utils => Utils.GetRenamed}/References/IKVM/IKVM.Reflection.License.txt (100%) rename {Utils => Utils.GetRenamed}/References/IKVM/IKVM.Reflection.dll (100%) rename {Utils => Utils.GetRenamed}/References/Mono.Posix.dll (100%) rename {Documentation => docs}/building.md (100%) rename {Documentation => docs}/differences-from-c-python.md (100%) rename {Documentation => docs}/feature-symbols.md (100%) rename {Documentation => docs}/getting-the-sources.md (100%) rename {Documentation => docs}/installing.md (100%) rename {Documentation => docs}/logo.png (100%) rename {Documentation => docs}/logo.svg (100%) rename {Documentation => docs}/modifying-the-sources.md (100%) rename {Documentation => docs}/package-compatibility.md (100%) rename {Documentation => docs}/upgrading-from-ipy2.md (100%) rename {Build => eng}/After.targets (100%) rename {Build => eng}/Key.snk (100%) rename {Build => eng}/Tasks.Targets (100%) rename {Package => eng}/choco/Choco.Packaging.targets (100%) rename {Package => eng}/choco/IronPython.nuspec (100%) rename {Package => eng}/choco/README.md (100%) rename {Package => eng}/choco/ignores/lib/distutils/command/wininst-10.0-amd64.exe.ignore (100%) rename {Package => eng}/choco/ignores/lib/distutils/command/wininst-10.0.exe.ignore (100%) rename {Package => eng}/choco/ignores/lib/distutils/command/wininst-6.0.exe.ignore (100%) rename {Package => eng}/choco/ignores/lib/distutils/command/wininst-7.1.exe.ignore (100%) rename {Package => eng}/choco/ignores/lib/distutils/command/wininst-8.0.exe.ignore (100%) rename {Package => eng}/choco/ignores/lib/distutils/command/wininst-9.0-amd64.exe.ignore (100%) rename {Package => eng}/choco/ignores/lib/distutils/command/wininst-9.0.exe.ignore (100%) rename {Package => eng}/choco/tools/VERIFICATION.txt (100%) rename {Package => eng}/deb/DEBIAN/control (100%) rename {Package => eng}/deb/Deb.Packaging.targets (100%) create mode 100644 eng/deb/ipy create mode 100644 eng/deb/ipy3 rename {Package => eng}/deb/ipy3.4 (100%) mode change 100755 => 100644 rename {Package => eng}/dotnettool/DotnetTool.Packaging.targets (100%) rename {Package => eng}/dotnettool/IronPython.Console.csproj (100%) rename {Package => eng}/dotnettool/README.md (100%) rename {Package => eng}/dotnettool/runtimeconfig.template.json (100%) rename {Package => eng}/msi/Dlr.wxs (100%) rename {Package => eng}/msi/IronPython.Installer.wixproj (100%) rename {Package => eng}/msi/IronPython.wxs (100%) rename {Package => eng}/msi/License.rtf (100%) rename {Package => eng}/msi/Msi.Packaging.targets (100%) rename {Package => eng}/msi/Product.wxs (100%) rename {Package => eng}/msi/Version.wxi (100%) rename {Package => eng}/msi/banner.bmp (100%) rename {Package => eng}/msi/ironpython.bmp (100%) rename {Build => eng}/net462.props (100%) rename {Build => eng}/net6.0-windows.props (100%) rename {Build => eng}/net6.0.props (100%) rename {Build => eng}/net8.0-windows.props (100%) rename {Build => eng}/net8.0.props (100%) rename {Build => eng}/net9.0-windows.props (100%) rename {Build => eng}/net9.0.props (100%) rename {Build => eng}/netcoreapp2.1.props (100%) rename {Build => eng}/netcoreapp3.1.props (100%) rename {Build => eng}/netstandard2.0.props (100%) rename {Package => eng}/nuget/IronPython.StdLib.nuspec (100%) rename {Package => eng}/nuget/IronPython.nuspec (100%) rename {Package => eng}/nuget/NuGet.Packaging.csproj (100%) rename {Package => eng}/nuget/NuGet.Packaging.targets (100%) rename {Package => eng}/nuget/README.md (100%) rename {Package => eng}/pkg/Pkg.Packaging.targets (100%) rename {Package => eng}/pkg/dos2unix.sh (100%) mode change 100755 => 100644 rename {Build => eng}/steps.yml (100%) rename {Package => eng}/zip/README.md (100%) rename {Package => eng}/zip/Zip.Packaging.targets (100%) rename {PythonTests => tests}/IndicesTest.py (100%) rename {PythonTests => tests}/Inputs/RemoteConsole.py (100%) rename {PythonTests => tests}/Inputs/UseCLI.py (100%) rename {PythonTests => tests}/Inputs/exit.py (100%) rename {PythonTests => tests}/Inputs/exitFuncRaises.py (100%) rename {PythonTests => tests}/Inputs/exitFuncRuns.py (100%) rename {PythonTests => tests}/Inputs/raise.py (100%) rename {PythonTests => tests}/Inputs/simpleCommand.py (100%) rename {PythonTests => tests}/Inputs/syntaxError.py (100%) rename {PythonTests => tests}/Inputs/uninitializedGlobal.py (100%) rename {PythonTests => tests}/Modes/ConsoleFlags.ps1 (100%) rename {PythonTests => tests}/Modes/ConsoleHelp.Debug.out (100%) rename {PythonTests => tests}/Modes/ConsoleHelp.Release.out (100%) rename {PythonTests => tests}/RunAgainstCpy.py (100%) rename {PythonTests => tests}/Tools/baselines/__builtin__.log (100%) rename {PythonTests => tests}/Tools/baselines/_codecs.log (100%) rename {PythonTests => tests}/Tools/baselines/_collections.log (100%) rename {PythonTests => tests}/Tools/baselines/_sre.log (100%) rename {PythonTests => tests}/Tools/baselines/_struct.log (100%) rename {PythonTests => tests}/Tools/baselines/_subprocess.log (100%) rename {PythonTests => tests}/Tools/baselines/_weakref.log (100%) rename {PythonTests => tests}/Tools/baselines/_winreg.log (100%) rename {PythonTests => tests}/Tools/baselines/array.log (100%) rename {PythonTests => tests}/Tools/baselines/cPickle.log (100%) rename {PythonTests => tests}/Tools/baselines/cStringIO.log (100%) rename {PythonTests => tests}/Tools/baselines/copy_reg.log (100%) rename {PythonTests => tests}/Tools/baselines/datetime.log (100%) rename {PythonTests => tests}/Tools/baselines/gc.log (100%) rename {PythonTests => tests}/Tools/baselines/itertools.log (100%) rename {PythonTests => tests}/Tools/baselines/math.log (100%) rename {PythonTests => tests}/Tools/baselines/mmap.log (100%) rename {PythonTests => tests}/Tools/baselines/msvcrt.log (100%) rename {PythonTests => tests}/Tools/baselines/nt.log (100%) rename {PythonTests => tests}/Tools/baselines/select.log (100%) rename {PythonTests => tests}/Tools/baselines/signal.log (100%) rename {PythonTests => tests}/Tools/baselines/sys.log (100%) rename {PythonTests => tests}/Tools/baselines/thread.log (100%) rename {PythonTests => tests}/Tools/baselines/time.log (100%) rename {PythonTests => tests}/Tools/baselines/types_only.log (100%) rename {PythonTests => tests}/Tools/baselines/xxsubtype.log (100%) rename {PythonTests => tests}/Tools/check/_functools.log (100%) rename {PythonTests => tests}/Tools/cleantests.py (100%) rename {PythonTests => tests}/Tools/clr_helpers.py (100%) rename {PythonTests => tests}/Tools/cmodule.py (100%) rename {PythonTests => tests}/Tools/cpy_tests.py (100%) rename {PythonTests => tests}/Tools/logmodule.py (100%) rename {PythonTests => tests}/Tools/modulediff.py (100%) rename {PythonTests => tests}/Tools/stdmodules.py (100%) rename {PythonTests => tests}/_ctypes_test_linux32.pyd (100%) rename {PythonTests => tests}/_ctypes_test_linux64.pyd (100%) rename {PythonTests => tests}/_ctypes_test_win32.pyd (100%) rename {PythonTests => tests}/_ctypes_test_win64.pyd (100%) rename {PythonTests => tests}/badil.py (100%) rename {PythonTests => tests}/c1.cs (100%) rename {PythonTests => tests}/c2.cs (100%) rename {PythonTests => tests}/c3.cs (100%) rename {PythonTests => tests}/c4.cs (100%) rename {PythonTests => tests}/check_result.bat (100%) rename {PythonTests => tests}/compat/common.py (100%) rename {PythonTests => tests}/compat/rulediff.py (100%) rename {PythonTests => tests}/compat/runsbs.py (100%) rename {PythonTests => tests}/compat/sbs_builtin.py (100%) rename {PythonTests => tests}/compat/sbs_class_compare.py (100%) rename {Src/StdLib/Lib/tkinter/test => tests/compat/sbs_exceptions}/__init__.py (100%) rename {PythonTests => tests}/compat/sbs_exceptions/define.py (100%) rename {PythonTests => tests}/compat/sbs_exceptions/for_loop.py (100%) rename {PythonTests => tests}/compat/sbs_exceptions/if_false.py (100%) rename {PythonTests => tests}/compat/sbs_exceptions/if_true.py (100%) rename {PythonTests => tests}/compat/sbs_exceptions/shared.py (100%) rename {PythonTests => tests}/compat/sbs_exceptions/try_else.py (100%) rename {PythonTests => tests}/compat/sbs_exceptions/try_except1.py (100%) rename {PythonTests => tests}/compat/sbs_exceptions/try_except2.py (100%) rename {PythonTests => tests}/compat/sbs_exceptions/try_except3.py (100%) rename {PythonTests => tests}/compat/sbs_exceptions/try_finally1.py (100%) rename {PythonTests => tests}/compat/sbs_exceptions/try_finally2.py (100%) rename {PythonTests => tests}/compat/sbs_exceptions/try_finally3.py (100%) rename {PythonTests => tests}/compat/sbs_exceptions/while_loop.py (100%) rename {PythonTests => tests}/compat/sbs_func_args.py (100%) rename {PythonTests => tests}/compat/sbs_library.cs (100%) rename {PythonTests => tests}/compat/sbs_newtype.py (100%) rename {PythonTests => tests}/compat/sbs_parse_string.py (100%) rename {PythonTests => tests}/compat/sbs_simple_compare.py (100%) rename {PythonTests => tests}/compat/sbs_simple_ops.py (100%) rename {PythonTests => tests}/compat/sbs_true_division.py (100%) rename {PythonTests => tests}/compat/sbs_typeop.py (100%) rename {PythonTests => tests}/compat/testdata.py (100%) rename {PythonTests => tests}/custombuiltins.py (100%) rename {PythonTests => tests}/debugging/__init__.py (100%) rename {PythonTests => tests}/debugging/mdbg_tool/__init__.py (100%) rename {PythonTests => tests}/debugging/pdb_mod/__init__.py (100%) rename {PythonTests => tests}/debugging/vs/__init__.py (100%) rename {PythonTests => tests}/dllsite.py (100%) rename {PythonTests => tests}/dummy_module.py (100%) rename {PythonTests => tests}/dynamic_sanity/dynamic_runner.bat (100%) rename {PythonTests => tests}/dynamic_sanity/dynamic_sanity.cs (100%) rename {PythonTests => tests}/dynamic_sanity/mock.py (100%) rename {PythonTests => tests}/encoded_files/bad_encoding_name.py (100%) rename {PythonTests => tests}/encoded_files/bad_latin1_bom.py (100%) rename {PythonTests => tests}/encoded_files/bad_latin1_bom_decl.py (100%) rename {PythonTests => tests}/encoded_files/bad_latin1_nbsp.py (100%) rename {PythonTests => tests}/encoded_files/bad_latin1_nodecl.py (100%) rename {PythonTests => tests}/encoded_files/bad_utf8_bom_decl.py (100%) rename {PythonTests => tests}/encoded_files/cp1019.py (100%) rename {PythonTests => tests}/encoded_files/cp11334_bad.py (100%) rename {PythonTests => tests}/encoded_files/cp11334_ok.py (100%) rename {PythonTests => tests}/encoded_files/cp20472.py (100%) rename {PythonTests => tests}/encoded_files/ok_encoding_nonascii.py (100%) rename {PythonTests => tests}/encoded_files/ok_encoding_whitespace.py (100%) rename {PythonTests => tests}/file_with_BOM.txt (88%) rename {PythonTests => tests}/file_without_BOM.txt (83%) rename {PythonTests => tests}/functions/test_signatures.py (100%) rename {PythonTests => tests}/gen_stdlib_test.py (100%) rename {PythonTests => tests}/gh129.zip (100%) rename {PythonTests => tests}/harness.py (100%) rename {PythonTests => tests}/hosting/editor_svcs/test_errorlistener.py (100%) rename {PythonTests => tests}/hosting/editor_svcs/test_tokencategorizer.py (100%) rename {Src/StdLib/Lib/tkinter/test/test_tkinter => tests/import_extant/_vendor}/__init__.py (100%) rename {Src/StdLib/Lib/tkinter/test/test_ttk => tests/import_extant/_vendor/packaging}/__init__.py (100%) rename {PythonTests => tests}/import_extant/_vendor/packaging/_structures.py (100%) rename {PythonTests => tests}/import_extant/_vendor/packaging/version.py (100%) rename {PythonTests => tests}/import_extant/extern/__init__.py (100%) rename {PythonTests => tests}/interop/__init__.py (100%) rename {PythonTests => tests}/interop/com/apps/MultiOffice.py (100%) rename {PythonTests => tests}/interop/com/apps/adodb.py (100%) rename {PythonTests => tests}/interop/com/apps/excel.py (100%) rename {PythonTests => tests}/interop/com/apps/scriptpw.py (100%) rename {PythonTests => tests}/interop/com/apps/word.py (100%) rename {PythonTests => tests}/interop/com/compat/__init__.py (100%) rename {PythonTests => tests}/interop/com/compat/hw.py (100%) rename {PythonTests => tests}/interop/com/compat/hw_client.py (100%) rename {PythonTests => tests}/interop/com/dlrcomlib/DispEvents.py (100%) rename {PythonTests => tests}/interop/com/dlrcomlib/InOutParams.py (100%) rename {PythonTests => tests}/interop/com/dlrcomlib/MultipleParams.py (100%) rename {PythonTests => tests}/interop/com/dlrcomlib/OptionalParams.py (100%) rename {PythonTests => tests}/interop/com/dlrcomlib/OutParams.py (100%) rename {PythonTests => tests}/interop/com/dlrcomlib/ReturnValues.py (100%) rename {PythonTests => tests}/interop/com/dlrcomlib/SimpleErrors.py (100%) rename {PythonTests => tests}/interop/com/dlrcomlib/__init__.py (100%) rename {PythonTests => tests}/interop/com/dlrcomlib/dlrcomserver.py (100%) rename {PythonTests => tests}/interop/com/dlrcomlib/paramsinretval.py (100%) rename {PythonTests => tests}/interop/com/dlrcomlib/properties.py (100%) rename {PythonTests => tests}/interop/com/dlrcomlib/pytraits/__init__.py (100%) rename {PythonTests => tests}/interop/com/dlrcomlib/pytraits/method.py (100%) rename {PythonTests => tests}/interop/com/dlrcomlib/pytraits/obj.py (100%) rename {PythonTests => tests}/interop/com/dlrcomlib/pytraits/prop.py (100%) rename {PythonTests => tests}/interop/com/dlrcomlib/typelib.py (100%) rename {PythonTests => tests}/interop/net/derivation/test_ctor_override.py (100%) rename {PythonTests => tests}/interop/net/derivation/test_event_override.py (100%) rename {PythonTests => tests}/interop/net/derivation/test_method_override.py (100%) rename {PythonTests => tests}/interop/net/derivation/test_method_signature.py (100%) rename {PythonTests => tests}/interop/net/derivation/test_property_override.py (100%) rename {PythonTests => tests}/interop/net/derivation/test_simplederive.py (100%) rename {PythonTests => tests}/interop/net/derivation/test_special_method.py (100%) rename {PythonTests => tests}/interop/net/dynamic/test_dynamic_regressions.py (100%) rename {PythonTests => tests}/interop/net/event/test_delegate.py (100%) rename {PythonTests => tests}/interop/net/event/test_event.py (100%) rename {PythonTests => tests}/interop/net/field/test_field_misc.py (100%) rename {PythonTests => tests}/interop/net/field/test_fields_inside_enum.py (100%) rename {PythonTests => tests}/interop/net/field/test_initonly_fields.py (100%) rename {PythonTests => tests}/interop/net/field/test_instance_fields.py (100%) rename {PythonTests => tests}/interop/net/field/test_literal_fields.py (100%) rename {PythonTests => tests}/interop/net/field/test_static_fields.py (100%) rename {PythonTests => tests}/interop/net/loadorder/module.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t1a.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t1b.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t1c.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t1d.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t2a.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t2b.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t2c.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t2d.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t2e.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t2f.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t2g.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t2h.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t3a.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t3b.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t3c0.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t3c1.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t3c2.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t3d.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t3e.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t3f.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t3g1.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t3g2.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t3h.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t3i.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t4a.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t4b.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t4c.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t5a.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t5b.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t5c1.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t5c2.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t6.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t7a.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t7b.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t7c.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t7d.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t7e.py (100%) rename {PythonTests => tests}/interop/net/loadorder/t7f.py (100%) rename {PythonTests => tests}/interop/net/method/test_arguments.py (100%) rename {PythonTests => tests}/interop/net/method/test_op_explicit.py (100%) rename {PythonTests => tests}/interop/net/method/test_op_implicit.py (100%) rename {PythonTests => tests}/interop/net/method/test_operators.py (100%) rename {PythonTests => tests}/interop/net/method/test_returnvalue.py (100%) rename {PythonTests => tests}/interop/net/property/test_indexercs.py (100%) rename {PythonTests => tests}/interop/net/property/test_indexervb.py (100%) rename {PythonTests => tests}/interop/net/property/test_property.py (100%) rename {PythonTests => tests}/interop/net/test_accessibility.py (100%) rename {PythonTests => tests}/interop/net/test_dynamicobjectmodel.py (100%) rename {PythonTests => tests}/interop/net/test_loadorder.py (100%) rename {PythonTests => tests}/interop/net/type/test___clrtype.py (100%) rename {PythonTests => tests}/interop/net/type/test_assembly.py (100%) rename {PythonTests => tests}/interop/net/type/test_clr_array.py (100%) rename {PythonTests => tests}/interop/net/type/test_ctor.py (100%) rename {PythonTests => tests}/interop/net/type/test_defaultmember.py (100%) rename {PythonTests => tests}/interop/net/type/test_reachtype.py (100%) rename {PythonTests => tests}/interop/net/versions/test_four_dot_zero.py (100%) rename {PythonTests => tests}/modules/__init__.py (100%) rename {PythonTests => tests}/modules/io_related/test__bytesio.py (100%) rename {PythonTests => tests}/modules/io_related/test__fileio.py (100%) rename {PythonTests => tests}/modules/io_related/test_binascii.py (100%) rename {PythonTests => tests}/modules/io_related/test_cPickle.py (100%) rename {PythonTests => tests}/modules/io_related/test_codecs.py (100%) rename {PythonTests => tests}/modules/io_related/test_copyreg.py (100%) rename {PythonTests => tests}/modules/io_related/test_fd.py (100%) rename {PythonTests => tests}/modules/io_related/test_io_StringIO.py (100%) rename {PythonTests => tests}/modules/io_related/test_marshal.py (100%) rename {PythonTests => tests}/modules/io_related/test_re.py (100%) rename {PythonTests => tests}/modules/misc/test__opcode.py (100%) rename {PythonTests => tests}/modules/misc/test__random.py (100%) rename {PythonTests => tests}/modules/misc/test__sha256.py (100%) rename {PythonTests => tests}/modules/misc/test__sha512.py (100%) rename {PythonTests => tests}/modules/misc/test__warnings.py (100%) rename {PythonTests => tests}/modules/misc/test__weakref.py (100%) rename {PythonTests => tests}/modules/misc/test_ctypes.py (100%) rename {PythonTests => tests}/modules/misc/test_datetime.py (100%) rename {PythonTests => tests}/modules/misc/test_math.py (100%) rename {PythonTests => tests}/modules/misc/test_operator.py (100%) rename {PythonTests => tests}/modules/misc/test_system_namespaces.py (100%) rename {PythonTests => tests}/modules/misc/test_zlib.py (100%) rename {PythonTests => tests}/modules/network_related/__init__.py (100%) rename {Src/StdLib/Lib/test => tests/modules/network_related}/keycert.pem (100%) rename {PythonTests => tests}/modules/network_related/test__socket.py (100%) rename {PythonTests => tests}/modules/network_related/test__ssl.py (100%) rename {PythonTests => tests}/modules/system_related/__init__.py (100%) rename {PythonTests => tests}/modules/system_related/test__locale.py (100%) rename {PythonTests => tests}/modules/system_related/test_errno.py (100%) rename {PythonTests => tests}/modules/system_related/test_gc.py (100%) rename {PythonTests => tests}/modules/system_related/test_nt.py (100%) rename {PythonTests => tests}/modules/system_related/test_os.py (100%) rename {PythonTests => tests}/modules/system_related/test_resource.py (100%) rename {PythonTests => tests}/modules/system_related/test_resource_stdlib.py (100%) rename {PythonTests => tests}/modules/system_related/test_signal.py (100%) rename {PythonTests => tests}/modules/system_related/test_sys.py (100%) rename {PythonTests => tests}/modules/system_related/test_sys_getframe.py (100%) rename {PythonTests => tests}/modules/system_related/test_thread.py (100%) rename {PythonTests => tests}/modules/system_related/test_time.py (100%) rename {PythonTests => tests}/modules/type_related/__init__.py (100%) rename {PythonTests => tests}/modules/type_related/test__struct.py (100%) rename {PythonTests => tests}/modules/type_related/test_array.py (100%) rename {PythonTests => tests}/modules/type_related/test_bitfields_ctypes_stdlib.py (100%) rename {PythonTests => tests}/modules/type_related/test_ctypes.py (100%) rename {PythonTests => tests}/modules/type_related/test_types.py (100%) rename {PythonTests => tests}/perf_micro_calls.py (100%) rename {PythonTests => tests}/pickles/cp18666.pickle (100%) rename {PythonTests => tests}/plans/debugging.html (100%) rename {PythonTests => tests}/plans/debugging.mdbg_tool.html (100%) rename {PythonTests => tests}/plans/debugging.pdb_mod.html (100%) rename {PythonTests => tests}/plans/debugging.vs.html (100%) rename {PythonTests => tests}/plans/generic_plan_template.py (100%) rename {PythonTests => tests}/plans/interop.net.derivation.html (100%) rename {PythonTests => tests}/plans/interop.net.derivation.test_ctor_override.html (100%) rename {PythonTests => tests}/plans/interop.net.derivation.test_event_override.html (100%) rename {PythonTests => tests}/plans/interop.net.derivation.test_method_override.html (100%) rename {PythonTests => tests}/plans/interop.net.derivation.test_method_signature.html (100%) rename {PythonTests => tests}/plans/interop.net.derivation.test_property_override.html (100%) rename {PythonTests => tests}/plans/interop.net.derivation.test_simplederive.html (100%) rename {PythonTests => tests}/plans/interop.net.derivation.test_special_method.html (100%) rename {PythonTests => tests}/plans/interop.net.event.html (100%) rename {PythonTests => tests}/plans/interop.net.event.test_delegate.html (100%) rename {PythonTests => tests}/plans/interop.net.event.test_event.html (100%) rename {PythonTests => tests}/plans/interop.net.field.html (100%) rename {PythonTests => tests}/plans/interop.net.field.test_field_misc.html (100%) rename {PythonTests => tests}/plans/interop.net.field.test_fields_inside_enum.html (100%) rename {PythonTests => tests}/plans/interop.net.html (100%) rename {PythonTests => tests}/plans/interop.net.insert_csharp.html (100%) rename {PythonTests => tests}/plans/interop.net.method.html (100%) rename {PythonTests => tests}/plans/interop.net.method.test_arguments.html (100%) rename {PythonTests => tests}/plans/interop.net.method.test_op_explicit.html (100%) rename {PythonTests => tests}/plans/interop.net.method.test_op_implicit.html (100%) rename {PythonTests => tests}/plans/interop.net.method.test_operators.html (100%) rename {PythonTests => tests}/plans/interop.net.method.test_returnvalue.html (100%) rename {PythonTests => tests}/plans/interop.net.property.html (100%) rename {PythonTests => tests}/plans/interop.net.property.test_indexercs.html (100%) rename {PythonTests => tests}/plans/interop.net.property.test_indexervb.html (100%) rename {PythonTests => tests}/plans/interop.net.property.test_property.html (100%) rename {PythonTests => tests}/plans/interop.net.test_accessibility.html (100%) rename {PythonTests => tests}/plans/interop.net.test_dynamicobjectmodel.html (100%) rename {PythonTests => tests}/plans/interop.net.test_loadorder.html (100%) rename {PythonTests => tests}/plans/interop.net.type.html (100%) rename {PythonTests => tests}/plans/interop.net.type.test_assembly.html (100%) rename {PythonTests => tests}/plans/interop.net.type.test_clr_array.html (100%) rename {PythonTests => tests}/plans/interop.net.type.test_ctor.html (100%) rename {PythonTests => tests}/plans/interop.net.type.test_defaultmember.html (100%) rename {PythonTests => tests}/plans/interop.net.type.test_reachtype.html (100%) rename {PythonTests => tests}/pretest.py (100%) rename {PythonTests => tests}/pyc/console_hw.py (100%) rename {PythonTests => tests}/pyc/console_hw_args.py (100%) rename {PythonTests => tests}/pyc/other_hw.py (100%) rename {Src/StdLib/Lib/urllib => tests/pyc/pkg}/__init__.py (100%) rename {PythonTests => tests}/pyc/pkg/a.py (100%) rename {PythonTests => tests}/pyc/pkg/b.py (100%) rename {PythonTests => tests}/pyc/pycpkgtest.py (100%) rename {PythonTests => tests}/pyc/stdmodules_ok.ps1 (100%) rename {PythonTests => tests}/pyc/test_pyc.ps1 (100%) rename {PythonTests => tests}/pyc/winforms_hw.py (100%) rename {PythonTests => tests}/run.py (100%) rename {PythonTests => tests}/run_transformed.bat (100%) rename {PythonTests => tests}/sample.txt.gz (100%) rename {PythonTests => tests}/specialcontext/Consoleless.ps1 (100%) rename {PythonTests => tests}/specialcontext/verify_ipyw.py (100%) rename {PythonTests => tests}/stress/__init__.py (100%) rename {PythonTests => tests}/stress/bigimport1_test.py (100%) rename {PythonTests => tests}/test_array.py (100%) rename {PythonTests => tests}/test_assert.py (100%) rename {PythonTests => tests}/test_ast.py (100%) rename {PythonTests => tests}/test_attr.py (100%) rename {PythonTests => tests}/test_attribute_customize.py (100%) rename {PythonTests => tests}/test_attrinjector.py (100%) rename {PythonTests => tests}/test_bigint.py (100%) rename {PythonTests => tests}/test_bool.py (100%) rename {PythonTests => tests}/test_builtin_stdlib.py (100%) rename {PythonTests => tests}/test_builtinfunc.py (100%) rename {PythonTests => tests}/test_bytes.py (100%) rename {PythonTests => tests}/test_bz2.py (100%) rename {PythonTests => tests}/test_bz2_stdlib.py (100%) rename {PythonTests => tests}/test_class.py (100%) rename {PythonTests => tests}/test_class_stdlib.py (100%) rename {PythonTests => tests}/test_cliclass.py (100%) rename {PythonTests => tests}/test_closure.py (100%) rename {PythonTests => tests}/test_clrexception.py (100%) rename {PythonTests => tests}/test_clrload.py (100%) rename {PythonTests => tests}/test_clrload2.py (100%) rename {PythonTests => tests}/test_clrnuminterop.py (100%) rename {PythonTests => tests}/test_clrtype.py (100%) rename {PythonTests => tests}/test_clruse.py (100%) rename {PythonTests => tests}/test_codeccallbacks_stdlib.py (100%) rename {PythonTests => tests}/test_codecs.py (100%) rename {PythonTests => tests}/test_codecs_stdlib.py (100%) rename {PythonTests => tests}/test_compiler.py (100%) rename {PythonTests => tests}/test_complex.py (100%) rename {PythonTests => tests}/test_complex_stdlib.py (100%) rename {PythonTests => tests}/test_conditional.py (100%) rename {PythonTests => tests}/test_data.gz (100%) rename {PythonTests => tests}/test_datetime.py (100%) rename {PythonTests => tests}/test_datetime_stdlib.py (100%) rename {PythonTests => tests}/test_decimal.py (100%) rename {PythonTests => tests}/test_decorator.py (100%) rename {PythonTests => tests}/test_delegate.py (100%) rename {PythonTests => tests}/test_deque.py (100%) rename {PythonTests => tests}/test_descr_stdlib.py (100%) rename {PythonTests => tests}/test_dict.py (100%) rename {PythonTests => tests}/test_dict_stdlib.py (100%) rename {PythonTests => tests}/test_dictcomp.py (100%) rename {PythonTests => tests}/test_dllsite.py (100%) rename {PythonTests => tests}/test_dlrkwarg.py (100%) rename {PythonTests => tests}/test_doc.py (100%) rename {PythonTests => tests}/test_enum.py (100%) rename {PythonTests => tests}/test_exceptions.py (100%) rename {PythonTests => tests}/test_exceptions_generated.py (100%) rename {PythonTests => tests}/test_excinfo.py (100%) rename {PythonTests => tests}/test_exec.py (100%) rename {PythonTests => tests}/test_file.py (100%) rename {PythonTests => tests}/test_float_stdlib.py (100%) rename {PythonTests => tests}/test_formatting.py (100%) rename {PythonTests => tests}/test_function.py (100%) rename {PythonTests => tests}/test_functools_stdlib.py (100%) rename {PythonTests => tests}/test_fuzz_parser.py (100%) rename {PythonTests => tests}/test_generator.py (100%) rename {PythonTests => tests}/test_generator_throw.py (100%) rename {PythonTests => tests}/test_genericmeth.py (100%) rename {PythonTests => tests}/test_hash.py (100%) rename {PythonTests => tests}/test_help.py (100%) rename {PythonTests => tests}/test_httplib_stdlib.py (100%) rename {PythonTests => tests}/test_imp.py (100%) rename {PythonTests => tests}/test_importext.py (100%) rename {PythonTests => tests}/test_importpkg.py (100%) rename {PythonTests => tests}/test_in.py (100%) rename {PythonTests => tests}/test_index.py (100%) rename {PythonTests => tests}/test_inheritance.py (100%) rename {PythonTests => tests}/test_int.py (100%) rename {PythonTests => tests}/test_interactive.py (100%) rename {PythonTests => tests}/test_io.py (100%) rename {PythonTests => tests}/test_io_stdlib.py (100%) rename {PythonTests => tests}/test_ipyc.py (100%) rename {PythonTests => tests}/test_ipye.py (100%) rename {PythonTests => tests}/test_ironmath.py (100%) rename {PythonTests => tests}/test_is.py (100%) rename {PythonTests => tests}/test_isinstance.py (100%) rename {PythonTests => tests}/test_isinstance2.py (100%) rename {PythonTests => tests}/test_iterator.py (100%) rename {PythonTests => tests}/test_iteratorlength.py (100%) rename {PythonTests => tests}/test_itertools_stdlib.py (100%) rename {PythonTests => tests}/test_json.py (100%) rename {PythonTests => tests}/test_kwarg.py (100%) rename {PythonTests => tests}/test_list.py (100%) rename {PythonTests => tests}/test_listcomp.py (100%) rename {PythonTests => tests}/test_long_stdlib.py (100%) rename {PythonTests => tests}/test_memory.py (100%) rename {PythonTests => tests}/test_memoryio_stdlib.py (100%) rename {PythonTests => tests}/test_memoryview.py (100%) rename {PythonTests => tests}/test_metaclass.py (100%) rename {PythonTests => tests}/test_methodbinder1.py (100%) rename {PythonTests => tests}/test_methodbinder2.py (100%) rename {PythonTests => tests}/test_methoddispatch.py (100%) rename {PythonTests => tests}/test_missing.py (100%) rename {PythonTests => tests}/test_namebinding.py (100%) rename {PythonTests => tests}/test_nonetype.py (100%) rename {PythonTests => tests}/test_nonlocal.py (100%) rename {PythonTests => tests}/test_number.py (100%) rename {PythonTests => tests}/test_numberhash.py (100%) rename {PythonTests => tests}/test_numtypes.py (100%) rename {PythonTests => tests}/test_pep380_stdlib.py (100%) rename {PythonTests => tests}/test_peverify.py (100%) rename {PythonTests => tests}/test_pow.py (100%) rename {PythonTests => tests}/test_privateBinding.py (100%) rename {PythonTests => tests}/test_property.py (100%) rename {PythonTests => tests}/test_protected.py (100%) rename {PythonTests => tests}/test_pyexpat.py (100%) rename {PythonTests => tests}/test_python25.py (100%) rename {PythonTests => tests}/test_python26.py (100%) rename {PythonTests => tests}/test_range.py (100%) rename {PythonTests => tests}/test_re_stdlib.py (100%) rename {PythonTests => tests}/test_regressions.py (100%) rename {PythonTests => tests}/test_regressions_compiled.py (100%) rename {PythonTests => tests}/test_sax_stdlib.py (100%) rename {PythonTests => tests}/test_scope_stdlib.py (100%) rename {PythonTests => tests}/test_set.py (100%) rename {PythonTests => tests}/test_setcomp.py (100%) rename {PythonTests => tests}/test_shutil.py (100%) rename {PythonTests => tests}/test_slice.py (100%) rename {PythonTests => tests}/test_slots.py (100%) rename {PythonTests => tests}/test_socket_stdlib.py (100%) rename {PythonTests => tests}/test_specialcontext.py (100%) rename {PythonTests => tests}/test_sqlite3_stdlib.py (100%) rename {PythonTests => tests}/test_ssl_stdlib.py (100%) rename {PythonTests => tests}/test_statics.py (100%) rename {PythonTests => tests}/test_stdconsole.py (100%) rename {PythonTests => tests}/test_stdmodules.py (100%) rename {PythonTests => tests}/test_str.py (100%) rename {PythonTests => tests}/test_str_bytes.py (100%) rename {PythonTests => tests}/test_strformat.py (100%) rename {PythonTests => tests}/test_struct.py (100%) rename {PythonTests => tests}/test_struct_stdlib.py (100%) rename {PythonTests => tests}/test_struct_threadsafe.py (100%) rename {PythonTests => tests}/test_super.py (100%) rename {PythonTests => tests}/test_superconsole.py (100%) rename {PythonTests => tests}/test_surrogateescape.py (100%) rename {PythonTests => tests}/test_surrogateescape_pythonfuture.py (100%) rename {PythonTests => tests}/test_surrogatepass.py (100%) rename {PythonTests => tests}/test_syntax.py (100%) rename {PythonTests => tests}/test_sys_stdlib.py (100%) rename {PythonTests => tests}/test_system_timers.py (100%) rename {PythonTests => tests}/test_tcf.py (100%) rename {PythonTests => tests}/test_threadsafety.py (100%) rename {PythonTests => tests}/test_time_stdlib.py (100%) rename {PythonTests => tests}/test_traceback.py (100%) rename {PythonTests => tests}/test_tuple.py (100%) rename {PythonTests => tests}/test_types_stdlib.py (100%) rename {PythonTests => tests}/test_typing_stdlib.py (100%) rename {PythonTests => tests}/test_unicode.py (100%) rename {PythonTests => tests}/test_unicode_stdlib.py (100%) rename {PythonTests => tests}/test_unpack.py (100%) rename {PythonTests => tests}/test_utf8_mode_stdlib.py (100%) rename {PythonTests => tests}/test_weakref.py (100%) rename {PythonTests => tests}/test_weakset_stdlib.py (100%) rename {PythonTests => tests}/test_winforms.py (100%) rename {PythonTests => tests}/test_with.py (100%) rename {PythonTests => tests}/test_zipimport.py (100%) rename {PythonTests => tests}/testpkg1/__init__.py (100%) rename {PythonTests => tests}/testpkg1/mod1.py (100%) rename {PythonTests => tests}/timeit.py (100%) rename {PythonTests => tests}/toimport.py (100%) rename {PythonTests => tests}/transform.py (100%) diff --git a/Package/deb/ipy b/Package/deb/ipy deleted file mode 120000 index e2e8195a3..000000000 --- a/Package/deb/ipy +++ /dev/null @@ -1 +0,0 @@ -ipy3.4 \ No newline at end of file diff --git a/Package/deb/ipy3 b/Package/deb/ipy3 deleted file mode 120000 index e2e8195a3..000000000 --- a/Package/deb/ipy3 +++ /dev/null @@ -1 +0,0 @@ -ipy3.4 \ No newline at end of file diff --git a/Src/App.Debug.config b/Src.GetRenamed/App.Debug.config similarity index 100% rename from Src/App.Debug.config rename to Src.GetRenamed/App.Debug.config diff --git a/Src/App.Release.config b/Src.GetRenamed/App.Release.config similarity index 100% rename from Src/App.Release.config rename to Src.GetRenamed/App.Release.config diff --git a/Src/CTypes/Makefile b/Src.GetRenamed/CTypes/Makefile similarity index 100% rename from Src/CTypes/Makefile rename to Src.GetRenamed/CTypes/Makefile diff --git a/Src/CTypes/_ctypes_test.c b/Src.GetRenamed/CTypes/_ctypes_test.c similarity index 100% rename from Src/CTypes/_ctypes_test.c rename to Src.GetRenamed/CTypes/_ctypes_test.c diff --git a/Src/CTypes/_ctypes_test.sln b/Src.GetRenamed/CTypes/_ctypes_test.sln similarity index 100% rename from Src/CTypes/_ctypes_test.sln rename to Src.GetRenamed/CTypes/_ctypes_test.sln diff --git a/Src/CTypes/_ctypes_test.vcxproj b/Src.GetRenamed/CTypes/_ctypes_test.vcxproj similarity index 100% rename from Src/CTypes/_ctypes_test.vcxproj rename to Src.GetRenamed/CTypes/_ctypes_test.vcxproj diff --git a/Src/CompilerServices/AssemblyResolver.cs b/Src.GetRenamed/CompilerServices/AssemblyResolver.cs similarity index 100% rename from Src/CompilerServices/AssemblyResolver.cs rename to Src.GetRenamed/CompilerServices/AssemblyResolver.cs diff --git a/Src/CompilerServices/Config.cs b/Src.GetRenamed/CompilerServices/Config.cs similarity index 100% rename from Src/CompilerServices/Config.cs rename to Src.GetRenamed/CompilerServices/Config.cs diff --git a/Src/CompilerServices/ConsoleOps.cs b/Src.GetRenamed/CompilerServices/ConsoleOps.cs similarity index 100% rename from Src/CompilerServices/ConsoleOps.cs rename to Src.GetRenamed/CompilerServices/ConsoleOps.cs diff --git a/Src/CompilerServices/IronPython.CompilerServices.csproj b/Src.GetRenamed/CompilerServices/IronPython.CompilerServices.csproj similarity index 100% rename from Src/CompilerServices/IronPython.CompilerServices.csproj rename to Src.GetRenamed/CompilerServices/IronPython.CompilerServices.csproj diff --git a/Src/CompilerServices/Program.cs b/Src.GetRenamed/CompilerServices/Program.cs similarity index 100% rename from Src/CompilerServices/Program.cs rename to Src.GetRenamed/CompilerServices/Program.cs diff --git a/Src/CompilerServices/Properties/AssemblyInfo.cs b/Src.GetRenamed/CompilerServices/Properties/AssemblyInfo.cs similarity index 100% rename from Src/CompilerServices/Properties/AssemblyInfo.cs rename to Src.GetRenamed/CompilerServices/Properties/AssemblyInfo.cs diff --git a/Src/CompilerServices/README.md b/Src.GetRenamed/CompilerServices/README.md similarity index 100% rename from Src/CompilerServices/README.md rename to Src.GetRenamed/CompilerServices/README.md diff --git a/Src/Console.Host/IronPython.Console.Host.csproj b/Src.GetRenamed/Console.Host/IronPython.Console.Host.csproj similarity index 100% rename from Src/Console.Host/IronPython.Console.Host.csproj rename to Src.GetRenamed/Console.Host/IronPython.Console.Host.csproj diff --git a/Src/Console.Host/IronPythonWindow.cs b/Src.GetRenamed/Console.Host/IronPythonWindow.cs similarity index 100% rename from Src/Console.Host/IronPythonWindow.cs rename to Src.GetRenamed/Console.Host/IronPythonWindow.cs diff --git a/Src/Console.Host/Properties/AssemblyInfo.cs b/Src.GetRenamed/Console.Host/Properties/AssemblyInfo.cs similarity index 100% rename from Src/Console.Host/Properties/AssemblyInfo.cs rename to Src.GetRenamed/Console.Host/Properties/AssemblyInfo.cs diff --git a/Src/Console.Host/ipyw.ico b/Src.GetRenamed/Console.Host/ipyw.ico similarity index 100% rename from Src/Console.Host/ipyw.ico rename to Src.GetRenamed/Console.Host/ipyw.ico diff --git a/Src/Console/Console.cs b/Src.GetRenamed/Console/Console.cs similarity index 100% rename from Src/Console/Console.cs rename to Src.GetRenamed/Console/Console.cs diff --git a/Src/Console/IronPython.Console.csproj b/Src.GetRenamed/Console/IronPython.Console.csproj similarity index 100% rename from Src/Console/IronPython.Console.csproj rename to Src.GetRenamed/Console/IronPython.Console.csproj diff --git a/Src/Console/Properties/AssemblyInfo.cs b/Src.GetRenamed/Console/Properties/AssemblyInfo.cs similarity index 100% rename from Src/Console/Properties/AssemblyInfo.cs rename to Src.GetRenamed/Console/Properties/AssemblyInfo.cs diff --git a/Src/Console/app.manifest b/Src.GetRenamed/Console/app.manifest similarity index 100% rename from Src/Console/app.manifest rename to Src.GetRenamed/Console/app.manifest diff --git a/Src/Console/ipy-mono.sh b/Src.GetRenamed/Console/ipy-mono.sh similarity index 100% rename from Src/Console/ipy-mono.sh rename to Src.GetRenamed/Console/ipy-mono.sh diff --git a/Src/Console/ipy.ico b/Src.GetRenamed/Console/ipy.ico similarity index 100% rename from Src/Console/ipy.ico rename to Src.GetRenamed/Console/ipy.ico diff --git a/Src/Console/ipy.sh b/Src.GetRenamed/Console/ipy.sh similarity index 100% rename from Src/Console/ipy.sh rename to Src.GetRenamed/Console/ipy.sh diff --git a/Src/Console/runtimeconfig.template.json b/Src.GetRenamed/Console/runtimeconfig.template.json similarity index 100% rename from Src/Console/runtimeconfig.template.json rename to Src.GetRenamed/Console/runtimeconfig.template.json diff --git a/Src/Console32.Host/IronPython.Console32.Host.csproj b/Src.GetRenamed/Console32.Host/IronPython.Console32.Host.csproj similarity index 100% rename from Src/Console32.Host/IronPython.Console32.Host.csproj rename to Src.GetRenamed/Console32.Host/IronPython.Console32.Host.csproj diff --git a/Src/Console32/IronPython.Console32.csproj b/Src.GetRenamed/Console32/IronPython.Console32.csproj similarity index 100% rename from Src/Console32/IronPython.Console32.csproj rename to Src.GetRenamed/Console32/IronPython.Console32.csproj diff --git a/DiagnosticAnalyzer/Analyzer.cs b/Src.GetRenamed/DiagnosticAnalyzer/Analyzer.cs similarity index 100% rename from DiagnosticAnalyzer/Analyzer.cs rename to Src.GetRenamed/DiagnosticAnalyzer/Analyzer.cs diff --git a/DiagnosticAnalyzer/Directory.Build.props b/Src.GetRenamed/DiagnosticAnalyzer/Directory.Build.props similarity index 100% rename from DiagnosticAnalyzer/Directory.Build.props rename to Src.GetRenamed/DiagnosticAnalyzer/Directory.Build.props diff --git a/DiagnosticAnalyzer/IronPython.DiagnosticAnalyzer.csproj b/Src.GetRenamed/DiagnosticAnalyzer/IronPython.DiagnosticAnalyzer.csproj similarity index 100% rename from DiagnosticAnalyzer/IronPython.DiagnosticAnalyzer.csproj rename to Src.GetRenamed/DiagnosticAnalyzer/IronPython.DiagnosticAnalyzer.csproj diff --git a/Src/IronPython/Compiler/Ast/AndExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/AndExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/AndExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/AndExpression.cs diff --git a/Src/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs diff --git a/Src/IronPython/Compiler/Ast/AssertStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/AssertStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/AssertStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/AssertStatement.cs diff --git a/Src/IronPython/Compiler/Ast/AssignmentStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/AssignmentStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/AssignmentStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/AssignmentStatement.cs diff --git a/Src/IronPython/Compiler/Ast/AstMethods.cs b/Src.GetRenamed/IronPython/Compiler/Ast/AstMethods.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/AstMethods.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/AstMethods.cs diff --git a/Src/IronPython/Compiler/Ast/AsyncStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/AsyncStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/AsyncStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/AsyncStatement.cs diff --git a/Src/IronPython/Compiler/Ast/AugmentedAssignStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/AugmentedAssignStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/AugmentedAssignStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/AugmentedAssignStatement.cs diff --git a/Src/IronPython/Compiler/Ast/BinaryExpression.Generated.cs b/Src.GetRenamed/IronPython/Compiler/Ast/BinaryExpression.Generated.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/BinaryExpression.Generated.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/BinaryExpression.Generated.cs diff --git a/Src/IronPython/Compiler/Ast/BinaryExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/BinaryExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/BinaryExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/BinaryExpression.cs diff --git a/Src/IronPython/Compiler/Ast/BreakStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/BreakStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/BreakStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/BreakStatement.cs diff --git a/Src/IronPython/Compiler/Ast/CallExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/CallExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/CallExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/CallExpression.cs diff --git a/Src/IronPython/Compiler/Ast/ClassDefinition.cs b/Src.GetRenamed/IronPython/Compiler/Ast/ClassDefinition.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ClassDefinition.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/ClassDefinition.cs diff --git a/Src/IronPython/Compiler/Ast/Comprehension.cs b/Src.GetRenamed/IronPython/Compiler/Ast/Comprehension.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/Comprehension.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/Comprehension.cs diff --git a/Src/IronPython/Compiler/Ast/ComprehensionFor.cs b/Src.GetRenamed/IronPython/Compiler/Ast/ComprehensionFor.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ComprehensionFor.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/ComprehensionFor.cs diff --git a/Src/IronPython/Compiler/Ast/ComprehensionIf.cs b/Src.GetRenamed/IronPython/Compiler/Ast/ComprehensionIf.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ComprehensionIf.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/ComprehensionIf.cs diff --git a/Src/IronPython/Compiler/Ast/ConditionalExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/ConditionalExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ConditionalExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/ConditionalExpression.cs diff --git a/Src/IronPython/Compiler/Ast/ConstantExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/ConstantExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ConstantExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/ConstantExpression.cs diff --git a/Src/IronPython/Compiler/Ast/ContinueStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/ContinueStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ContinueStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/ContinueStatement.cs diff --git a/Src/IronPython/Compiler/Ast/DelStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/DelStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/DelStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/DelStatement.cs diff --git a/Src/IronPython/Compiler/Ast/DictionaryExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/DictionaryExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/DictionaryExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/DictionaryExpression.cs diff --git a/Src/IronPython/Compiler/Ast/DottedName.cs b/Src.GetRenamed/IronPython/Compiler/Ast/DottedName.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/DottedName.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/DottedName.cs diff --git a/Src/IronPython/Compiler/Ast/DynamicConvertExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/DynamicConvertExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/DynamicConvertExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/DynamicConvertExpression.cs diff --git a/Src/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs diff --git a/Src/IronPython/Compiler/Ast/EmptyStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/EmptyStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/EmptyStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/EmptyStatement.cs diff --git a/Src/IronPython/Compiler/Ast/ErrorExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/ErrorExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ErrorExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/ErrorExpression.cs diff --git a/Src/IronPython/Compiler/Ast/Expression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/Expression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/Expression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/Expression.cs diff --git a/Src/IronPython/Compiler/Ast/ExpressionStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/ExpressionStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ExpressionStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/ExpressionStatement.cs diff --git a/Src/IronPython/Compiler/Ast/FlowChecker.cs b/Src.GetRenamed/IronPython/Compiler/Ast/FlowChecker.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/FlowChecker.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/FlowChecker.cs diff --git a/Src/IronPython/Compiler/Ast/ForStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/ForStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ForStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/ForStatement.cs diff --git a/Src/IronPython/Compiler/Ast/FormattedValueExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/FormattedValueExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/FormattedValueExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/FormattedValueExpression.cs diff --git a/Src/IronPython/Compiler/Ast/FromImportStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/FromImportStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/FromImportStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/FromImportStatement.cs diff --git a/Src/IronPython/Compiler/Ast/FunctionDefinition.cs b/Src.GetRenamed/IronPython/Compiler/Ast/FunctionDefinition.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/FunctionDefinition.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/FunctionDefinition.cs diff --git a/Src/IronPython/Compiler/Ast/GeneratorExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/GeneratorExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/GeneratorExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/GeneratorExpression.cs diff --git a/Src/IronPython/Compiler/Ast/GetGlobalContextExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/GetGlobalContextExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/GetGlobalContextExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/GetGlobalContextExpression.cs diff --git a/Src/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs diff --git a/Src/IronPython/Compiler/Ast/GlobalStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/GlobalStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/GlobalStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/GlobalStatement.cs diff --git a/Src/IronPython/Compiler/Ast/ILoopStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/ILoopStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ILoopStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/ILoopStatement.cs diff --git a/Src/IronPython/Compiler/Ast/IfStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/IfStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/IfStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/IfStatement.cs diff --git a/Src/IronPython/Compiler/Ast/IfStatementTest.cs b/Src.GetRenamed/IronPython/Compiler/Ast/IfStatementTest.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/IfStatementTest.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/IfStatementTest.cs diff --git a/Src/IronPython/Compiler/Ast/ImportStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/ImportStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ImportStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/ImportStatement.cs diff --git a/Src/IronPython/Compiler/Ast/IndexExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/IndexExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/IndexExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/IndexExpression.cs diff --git a/Src/IronPython/Compiler/Ast/JoinedStringExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/JoinedStringExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/JoinedStringExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/JoinedStringExpression.cs diff --git a/Src/IronPython/Compiler/Ast/Keyword.cs b/Src.GetRenamed/IronPython/Compiler/Ast/Keyword.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/Keyword.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/Keyword.cs diff --git a/Src/IronPython/Compiler/Ast/LambdaExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/LambdaExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/LambdaExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/LambdaExpression.cs diff --git a/Src/IronPython/Compiler/Ast/ListExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/ListExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ListExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/ListExpression.cs diff --git a/Src/IronPython/Compiler/Ast/MemberExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/MemberExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/MemberExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/MemberExpression.cs diff --git a/Src/IronPython/Compiler/Ast/ModuleName.cs b/Src.GetRenamed/IronPython/Compiler/Ast/ModuleName.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ModuleName.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/ModuleName.cs diff --git a/Src/IronPython/Compiler/Ast/NameExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/NameExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/NameExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/NameExpression.cs diff --git a/Src/IronPython/Compiler/Ast/Node.cs b/Src.GetRenamed/IronPython/Compiler/Ast/Node.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/Node.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/Node.cs diff --git a/Src/IronPython/Compiler/Ast/NonlocalStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/NonlocalStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/NonlocalStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/NonlocalStatement.cs diff --git a/Src/IronPython/Compiler/Ast/OrExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/OrExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/OrExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/OrExpression.cs diff --git a/Src/IronPython/Compiler/Ast/Parameter.cs b/Src.GetRenamed/IronPython/Compiler/Ast/Parameter.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/Parameter.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/Parameter.cs diff --git a/Src/IronPython/Compiler/Ast/ParenthesisExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/ParenthesisExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ParenthesisExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/ParenthesisExpression.cs diff --git a/Src/IronPython/Compiler/Ast/PythonAst.cs b/Src.GetRenamed/IronPython/Compiler/Ast/PythonAst.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/PythonAst.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/PythonAst.cs diff --git a/Src/IronPython/Compiler/Ast/PythonConstantExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/PythonConstantExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/PythonConstantExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/PythonConstantExpression.cs diff --git a/Src/IronPython/Compiler/Ast/PythonNameBinder.cs b/Src.GetRenamed/IronPython/Compiler/Ast/PythonNameBinder.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/PythonNameBinder.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/PythonNameBinder.cs diff --git a/Src/IronPython/Compiler/Ast/PythonReference.cs b/Src.GetRenamed/IronPython/Compiler/Ast/PythonReference.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/PythonReference.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/PythonReference.cs diff --git a/Src/IronPython/Compiler/Ast/PythonVariable.cs b/Src.GetRenamed/IronPython/Compiler/Ast/PythonVariable.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/PythonVariable.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/PythonVariable.cs diff --git a/Src/IronPython/Compiler/Ast/PythonWalker.Generated.cs b/Src.GetRenamed/IronPython/Compiler/Ast/PythonWalker.Generated.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/PythonWalker.Generated.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/PythonWalker.Generated.cs diff --git a/Src/IronPython/Compiler/Ast/RaiseStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/RaiseStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/RaiseStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/RaiseStatement.cs diff --git a/Src/IronPython/Compiler/Ast/RelativeModuleName.cs b/Src.GetRenamed/IronPython/Compiler/Ast/RelativeModuleName.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/RelativeModuleName.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/RelativeModuleName.cs diff --git a/Src/IronPython/Compiler/Ast/ReturnStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/ReturnStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ReturnStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/ReturnStatement.cs diff --git a/Src/IronPython/Compiler/Ast/ScopeStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/ScopeStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/ScopeStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/ScopeStatement.cs diff --git a/Src/IronPython/Compiler/Ast/SequenceExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/SequenceExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/SequenceExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/SequenceExpression.cs diff --git a/Src/IronPython/Compiler/Ast/SerializedScopeStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/SerializedScopeStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/SerializedScopeStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/SerializedScopeStatement.cs diff --git a/Src/IronPython/Compiler/Ast/SetExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/SetExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/SetExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/SetExpression.cs diff --git a/Src/IronPython/Compiler/Ast/SliceExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/SliceExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/SliceExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/SliceExpression.cs diff --git a/Src/IronPython/Compiler/Ast/StarredExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/StarredExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/StarredExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/StarredExpression.cs diff --git a/Src/IronPython/Compiler/Ast/Statement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/Statement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/Statement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/Statement.cs diff --git a/Src/IronPython/Compiler/Ast/SuiteStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/SuiteStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/SuiteStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/SuiteStatement.cs diff --git a/Src/IronPython/Compiler/Ast/TryStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/TryStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/TryStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/TryStatement.cs diff --git a/Src/IronPython/Compiler/Ast/TupleExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/TupleExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/TupleExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/TupleExpression.cs diff --git a/Src/IronPython/Compiler/Ast/UnaryExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/UnaryExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/UnaryExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/UnaryExpression.cs diff --git a/Src/IronPython/Compiler/Ast/VariableKind.cs b/Src.GetRenamed/IronPython/Compiler/Ast/VariableKind.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/VariableKind.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/VariableKind.cs diff --git a/Src/IronPython/Compiler/Ast/WhileStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/WhileStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/WhileStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/WhileStatement.cs diff --git a/Src/IronPython/Compiler/Ast/WithStatement.cs b/Src.GetRenamed/IronPython/Compiler/Ast/WithStatement.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/WithStatement.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/WithStatement.cs diff --git a/Src/IronPython/Compiler/Ast/YieldExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/YieldExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/YieldExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/YieldExpression.cs diff --git a/Src/IronPython/Compiler/Ast/YieldFromExpression.cs b/Src.GetRenamed/IronPython/Compiler/Ast/YieldFromExpression.cs similarity index 100% rename from Src/IronPython/Compiler/Ast/YieldFromExpression.cs rename to Src.GetRenamed/IronPython/Compiler/Ast/YieldFromExpression.cs diff --git a/Src/IronPython/Compiler/ClosureExpression.cs b/Src.GetRenamed/IronPython/Compiler/ClosureExpression.cs similarity index 100% rename from Src/IronPython/Compiler/ClosureExpression.cs rename to Src.GetRenamed/IronPython/Compiler/ClosureExpression.cs diff --git a/Src/IronPython/Compiler/ClosureInfo.cs b/Src.GetRenamed/IronPython/Compiler/ClosureInfo.cs similarity index 100% rename from Src/IronPython/Compiler/ClosureInfo.cs rename to Src.GetRenamed/IronPython/Compiler/ClosureInfo.cs diff --git a/Src/IronPython/Compiler/CollectableCompilationMode.cs b/Src.GetRenamed/IronPython/Compiler/CollectableCompilationMode.cs similarity index 100% rename from Src/IronPython/Compiler/CollectableCompilationMode.cs rename to Src.GetRenamed/IronPython/Compiler/CollectableCompilationMode.cs diff --git a/Src/IronPython/Compiler/CompilationMode.cs b/Src.GetRenamed/IronPython/Compiler/CompilationMode.cs similarity index 100% rename from Src/IronPython/Compiler/CompilationMode.cs rename to Src.GetRenamed/IronPython/Compiler/CompilationMode.cs diff --git a/Src/IronPython/Compiler/GeneratorRewriter.cs b/Src.GetRenamed/IronPython/Compiler/GeneratorRewriter.cs similarity index 100% rename from Src/IronPython/Compiler/GeneratorRewriter.cs rename to Src.GetRenamed/IronPython/Compiler/GeneratorRewriter.cs diff --git a/Src/IronPython/Compiler/LazyCode.cs b/Src.GetRenamed/IronPython/Compiler/LazyCode.cs similarity index 100% rename from Src/IronPython/Compiler/LazyCode.cs rename to Src.GetRenamed/IronPython/Compiler/LazyCode.cs diff --git a/Src/IronPython/Compiler/LookupCompilationMode.cs b/Src.GetRenamed/IronPython/Compiler/LookupCompilationMode.cs similarity index 100% rename from Src/IronPython/Compiler/LookupCompilationMode.cs rename to Src.GetRenamed/IronPython/Compiler/LookupCompilationMode.cs diff --git a/Src/IronPython/Compiler/OnDiskScriptCode.cs b/Src.GetRenamed/IronPython/Compiler/OnDiskScriptCode.cs similarity index 100% rename from Src/IronPython/Compiler/OnDiskScriptCode.cs rename to Src.GetRenamed/IronPython/Compiler/OnDiskScriptCode.cs diff --git a/Src/IronPython/Compiler/Parser.cs b/Src.GetRenamed/IronPython/Compiler/Parser.cs similarity index 100% rename from Src/IronPython/Compiler/Parser.cs rename to Src.GetRenamed/IronPython/Compiler/Parser.cs diff --git a/Src/IronPython/Compiler/PythonCallTargets.cs b/Src.GetRenamed/IronPython/Compiler/PythonCallTargets.cs similarity index 100% rename from Src/IronPython/Compiler/PythonCallTargets.cs rename to Src.GetRenamed/IronPython/Compiler/PythonCallTargets.cs diff --git a/Src/IronPython/Compiler/PythonCompilerOptions.cs b/Src.GetRenamed/IronPython/Compiler/PythonCompilerOptions.cs similarity index 100% rename from Src/IronPython/Compiler/PythonCompilerOptions.cs rename to Src.GetRenamed/IronPython/Compiler/PythonCompilerOptions.cs diff --git a/Src/IronPython/Compiler/PythonDynamicExpression.cs b/Src.GetRenamed/IronPython/Compiler/PythonDynamicExpression.cs similarity index 100% rename from Src/IronPython/Compiler/PythonDynamicExpression.cs rename to Src.GetRenamed/IronPython/Compiler/PythonDynamicExpression.cs diff --git a/Src/IronPython/Compiler/PythonGlobal.cs b/Src.GetRenamed/IronPython/Compiler/PythonGlobal.cs similarity index 100% rename from Src/IronPython/Compiler/PythonGlobal.cs rename to Src.GetRenamed/IronPython/Compiler/PythonGlobal.cs diff --git a/Src/IronPython/Compiler/PythonGlobalVariableExpression.cs b/Src.GetRenamed/IronPython/Compiler/PythonGlobalVariableExpression.cs similarity index 100% rename from Src/IronPython/Compiler/PythonGlobalVariableExpression.cs rename to Src.GetRenamed/IronPython/Compiler/PythonGlobalVariableExpression.cs diff --git a/Src/IronPython/Compiler/PythonOperator.cs b/Src.GetRenamed/IronPython/Compiler/PythonOperator.cs similarity index 100% rename from Src/IronPython/Compiler/PythonOperator.cs rename to Src.GetRenamed/IronPython/Compiler/PythonOperator.cs diff --git a/Src/IronPython/Compiler/PythonSavableScriptCode.cs b/Src.GetRenamed/IronPython/Compiler/PythonSavableScriptCode.cs similarity index 100% rename from Src/IronPython/Compiler/PythonSavableScriptCode.cs rename to Src.GetRenamed/IronPython/Compiler/PythonSavableScriptCode.cs diff --git a/Src/IronPython/Compiler/PythonScriptCode.cs b/Src.GetRenamed/IronPython/Compiler/PythonScriptCode.cs similarity index 100% rename from Src/IronPython/Compiler/PythonScriptCode.cs rename to Src.GetRenamed/IronPython/Compiler/PythonScriptCode.cs diff --git a/Src/IronPython/Compiler/ReducableDynamicExpression.cs b/Src.GetRenamed/IronPython/Compiler/ReducableDynamicExpression.cs similarity index 100% rename from Src/IronPython/Compiler/ReducableDynamicExpression.cs rename to Src.GetRenamed/IronPython/Compiler/ReducableDynamicExpression.cs diff --git a/Src/IronPython/Compiler/RunnableScriptCode.cs b/Src.GetRenamed/IronPython/Compiler/RunnableScriptCode.cs similarity index 100% rename from Src/IronPython/Compiler/RunnableScriptCode.cs rename to Src.GetRenamed/IronPython/Compiler/RunnableScriptCode.cs diff --git a/Src/IronPython/Compiler/RuntimeScriptCode.cs b/Src.GetRenamed/IronPython/Compiler/RuntimeScriptCode.cs similarity index 100% rename from Src/IronPython/Compiler/RuntimeScriptCode.cs rename to Src.GetRenamed/IronPython/Compiler/RuntimeScriptCode.cs diff --git a/Src/IronPython/Compiler/ToDiskCompilationMode.cs b/Src.GetRenamed/IronPython/Compiler/ToDiskCompilationMode.cs similarity index 100% rename from Src/IronPython/Compiler/ToDiskCompilationMode.cs rename to Src.GetRenamed/IronPython/Compiler/ToDiskCompilationMode.cs diff --git a/Src/IronPython/Compiler/Token.cs b/Src.GetRenamed/IronPython/Compiler/Token.cs similarity index 100% rename from Src/IronPython/Compiler/Token.cs rename to Src.GetRenamed/IronPython/Compiler/Token.cs diff --git a/Src/IronPython/Compiler/TokenKind.Generated.cs b/Src.GetRenamed/IronPython/Compiler/TokenKind.Generated.cs similarity index 100% rename from Src/IronPython/Compiler/TokenKind.Generated.cs rename to Src.GetRenamed/IronPython/Compiler/TokenKind.Generated.cs diff --git a/Src/IronPython/Compiler/Tokenizer.Generated.cs b/Src.GetRenamed/IronPython/Compiler/Tokenizer.Generated.cs similarity index 100% rename from Src/IronPython/Compiler/Tokenizer.Generated.cs rename to Src.GetRenamed/IronPython/Compiler/Tokenizer.Generated.cs diff --git a/Src/IronPython/Compiler/Tokenizer.cs b/Src.GetRenamed/IronPython/Compiler/Tokenizer.cs similarity index 100% rename from Src/IronPython/Compiler/Tokenizer.cs rename to Src.GetRenamed/IronPython/Compiler/Tokenizer.cs diff --git a/Src/IronPython/Compiler/UncollectableCompilationMode.Generated.cs b/Src.GetRenamed/IronPython/Compiler/UncollectableCompilationMode.Generated.cs similarity index 100% rename from Src/IronPython/Compiler/UncollectableCompilationMode.Generated.cs rename to Src.GetRenamed/IronPython/Compiler/UncollectableCompilationMode.Generated.cs diff --git a/Src/IronPython/Compiler/UncollectableCompilationMode.cs b/Src.GetRenamed/IronPython/Compiler/UncollectableCompilationMode.cs similarity index 100% rename from Src/IronPython/Compiler/UncollectableCompilationMode.cs rename to Src.GetRenamed/IronPython/Compiler/UncollectableCompilationMode.cs diff --git a/Src/IronPython/FakeInteropServices.cs b/Src.GetRenamed/IronPython/FakeInteropServices.cs similarity index 100% rename from Src/IronPython/FakeInteropServices.cs rename to Src.GetRenamed/IronPython/FakeInteropServices.cs diff --git a/Src/IronPython/Hosting/Python.cs b/Src.GetRenamed/IronPython/Hosting/Python.cs similarity index 100% rename from Src/IronPython/Hosting/Python.cs rename to Src.GetRenamed/IronPython/Hosting/Python.cs diff --git a/Src/IronPython/Hosting/PythonCodeDomCodeGen.cs b/Src.GetRenamed/IronPython/Hosting/PythonCodeDomCodeGen.cs similarity index 100% rename from Src/IronPython/Hosting/PythonCodeDomCodeGen.cs rename to Src.GetRenamed/IronPython/Hosting/PythonCodeDomCodeGen.cs diff --git a/Src/IronPython/Hosting/PythonCommandLine.cs b/Src.GetRenamed/IronPython/Hosting/PythonCommandLine.cs similarity index 100% rename from Src/IronPython/Hosting/PythonCommandLine.cs rename to Src.GetRenamed/IronPython/Hosting/PythonCommandLine.cs diff --git a/Src/IronPython/Hosting/PythonConsoleOptions.cs b/Src.GetRenamed/IronPython/Hosting/PythonConsoleOptions.cs similarity index 100% rename from Src/IronPython/Hosting/PythonConsoleOptions.cs rename to Src.GetRenamed/IronPython/Hosting/PythonConsoleOptions.cs diff --git a/Src/IronPython/Hosting/PythonOptionsParser.cs b/Src.GetRenamed/IronPython/Hosting/PythonOptionsParser.cs similarity index 100% rename from Src/IronPython/Hosting/PythonOptionsParser.cs rename to Src.GetRenamed/IronPython/Hosting/PythonOptionsParser.cs diff --git a/Src/IronPython/Hosting/PythonService.cs b/Src.GetRenamed/IronPython/Hosting/PythonService.cs similarity index 100% rename from Src/IronPython/Hosting/PythonService.cs rename to Src.GetRenamed/IronPython/Hosting/PythonService.cs diff --git a/Src/IronPython/Interop/Windows/Interop.Libraries.cs b/Src.GetRenamed/IronPython/Interop/Windows/Interop.Libraries.cs similarity index 100% rename from Src/IronPython/Interop/Windows/Interop.Libraries.cs rename to Src.GetRenamed/IronPython/Interop/Windows/Interop.Libraries.cs diff --git a/Src/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs b/Src.GetRenamed/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs similarity index 100% rename from Src/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs rename to Src.GetRenamed/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs diff --git a/Src/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs b/Src.GetRenamed/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs similarity index 100% rename from Src/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs rename to Src.GetRenamed/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs diff --git a/Src/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs b/Src.GetRenamed/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs similarity index 100% rename from Src/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs rename to Src.GetRenamed/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs diff --git a/Src/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs b/Src.GetRenamed/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs similarity index 100% rename from Src/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs rename to Src.GetRenamed/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs diff --git a/Src/IronPython/IronPython.csproj b/Src.GetRenamed/IronPython/IronPython.csproj similarity index 100% rename from Src/IronPython/IronPython.csproj rename to Src.GetRenamed/IronPython/IronPython.csproj diff --git a/Src/IronPython/Lib/iptest/__init__.py b/Src.GetRenamed/IronPython/Lib/iptest/__init__.py similarity index 100% rename from Src/IronPython/Lib/iptest/__init__.py rename to Src.GetRenamed/IronPython/Lib/iptest/__init__.py diff --git a/Src/IronPython/Lib/iptest/cominterop_util.py b/Src.GetRenamed/IronPython/Lib/iptest/cominterop_util.py similarity index 100% rename from Src/IronPython/Lib/iptest/cominterop_util.py rename to Src.GetRenamed/IronPython/Lib/iptest/cominterop_util.py diff --git a/Src/IronPython/Lib/iptest/console_util.py b/Src.GetRenamed/IronPython/Lib/iptest/console_util.py similarity index 100% rename from Src/IronPython/Lib/iptest/console_util.py rename to Src.GetRenamed/IronPython/Lib/iptest/console_util.py diff --git a/Src/IronPython/Lib/iptest/file_util.py b/Src.GetRenamed/IronPython/Lib/iptest/file_util.py similarity index 100% rename from Src/IronPython/Lib/iptest/file_util.py rename to Src.GetRenamed/IronPython/Lib/iptest/file_util.py diff --git a/Src/IronPython/Lib/iptest/ipunittest.py b/Src.GetRenamed/IronPython/Lib/iptest/ipunittest.py similarity index 100% rename from Src/IronPython/Lib/iptest/ipunittest.py rename to Src.GetRenamed/IronPython/Lib/iptest/ipunittest.py diff --git a/Src/IronPython/Lib/iptest/misc_util.py b/Src.GetRenamed/IronPython/Lib/iptest/misc_util.py similarity index 100% rename from Src/IronPython/Lib/iptest/misc_util.py rename to Src.GetRenamed/IronPython/Lib/iptest/misc_util.py diff --git a/Src/IronPython/Lib/iptest/process_util.py b/Src.GetRenamed/IronPython/Lib/iptest/process_util.py similarity index 100% rename from Src/IronPython/Lib/iptest/process_util.py rename to Src.GetRenamed/IronPython/Lib/iptest/process_util.py diff --git a/Src/IronPython/Lib/iptest/runner.py b/Src.GetRenamed/IronPython/Lib/iptest/runner.py similarity index 100% rename from Src/IronPython/Lib/iptest/runner.py rename to Src.GetRenamed/IronPython/Lib/iptest/runner.py diff --git a/Src/IronPython/Lib/iptest/test_env.py b/Src.GetRenamed/IronPython/Lib/iptest/test_env.py similarity index 100% rename from Src/IronPython/Lib/iptest/test_env.py rename to Src.GetRenamed/IronPython/Lib/iptest/test_env.py diff --git a/Src/IronPython/Lib/iptest/type_util.py b/Src.GetRenamed/IronPython/Lib/iptest/type_util.py similarity index 100% rename from Src/IronPython/Lib/iptest/type_util.py rename to Src.GetRenamed/IronPython/Lib/iptest/type_util.py diff --git a/Src/IronPython/Modules/Builtin.Generated.cs b/Src.GetRenamed/IronPython/Modules/Builtin.Generated.cs similarity index 100% rename from Src/IronPython/Modules/Builtin.Generated.cs rename to Src.GetRenamed/IronPython/Modules/Builtin.Generated.cs diff --git a/Src/IronPython/Modules/Builtin.cs b/Src.GetRenamed/IronPython/Modules/Builtin.cs similarity index 100% rename from Src/IronPython/Modules/Builtin.cs rename to Src.GetRenamed/IronPython/Modules/Builtin.cs diff --git a/Src/IronPython/Modules/_ast.cs b/Src.GetRenamed/IronPython/Modules/_ast.cs old mode 100755 new mode 100644 similarity index 100% rename from Src/IronPython/Modules/_ast.cs rename to Src.GetRenamed/IronPython/Modules/_ast.cs diff --git a/Src/IronPython/Modules/_fileio.cs b/Src.GetRenamed/IronPython/Modules/_fileio.cs similarity index 100% rename from Src/IronPython/Modules/_fileio.cs rename to Src.GetRenamed/IronPython/Modules/_fileio.cs diff --git a/Src/IronPython/Modules/_imp.cs b/Src.GetRenamed/IronPython/Modules/_imp.cs similarity index 100% rename from Src/IronPython/Modules/_imp.cs rename to Src.GetRenamed/IronPython/Modules/_imp.cs diff --git a/Src/IronPython/Modules/_io.cs b/Src.GetRenamed/IronPython/Modules/_io.cs similarity index 100% rename from Src/IronPython/Modules/_io.cs rename to Src.GetRenamed/IronPython/Modules/_io.cs diff --git a/Src/IronPython/Modules/_io/BytesIO.cs b/Src.GetRenamed/IronPython/Modules/_io/BytesIO.cs similarity index 100% rename from Src/IronPython/Modules/_io/BytesIO.cs rename to Src.GetRenamed/IronPython/Modules/_io/BytesIO.cs diff --git a/Src/IronPython/Modules/_io/StringIO.cs b/Src.GetRenamed/IronPython/Modules/_io/StringIO.cs similarity index 100% rename from Src/IronPython/Modules/_io/StringIO.cs rename to Src.GetRenamed/IronPython/Modules/_io/StringIO.cs diff --git a/Src/IronPython/Modules/_locale.cs b/Src.GetRenamed/IronPython/Modules/_locale.cs similarity index 100% rename from Src/IronPython/Modules/_locale.cs rename to Src.GetRenamed/IronPython/Modules/_locale.cs diff --git a/Src/IronPython/Modules/sys.cs b/Src.GetRenamed/IronPython/Modules/sys.cs similarity index 100% rename from Src/IronPython/Modules/sys.cs rename to Src.GetRenamed/IronPython/Modules/sys.cs diff --git a/Src/IronPython/Modules/unicodedata.cs b/Src.GetRenamed/IronPython/Modules/unicodedata.cs similarity index 100% rename from Src/IronPython/Modules/unicodedata.cs rename to Src.GetRenamed/IronPython/Modules/unicodedata.cs diff --git a/Src/IronPython/Modules/unicodedata/CaseFolding.txt b/Src.GetRenamed/IronPython/Modules/unicodedata/CaseFolding.txt similarity index 100% rename from Src/IronPython/Modules/unicodedata/CaseFolding.txt rename to Src.GetRenamed/IronPython/Modules/unicodedata/CaseFolding.txt diff --git a/Src/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt b/Src.GetRenamed/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt similarity index 100% rename from Src/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt rename to Src.GetRenamed/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt diff --git a/Src/IronPython/Modules/unicodedata/EastAsianWidth.txt b/Src.GetRenamed/IronPython/Modules/unicodedata/EastAsianWidth.txt similarity index 100% rename from Src/IronPython/Modules/unicodedata/EastAsianWidth.txt rename to Src.GetRenamed/IronPython/Modules/unicodedata/EastAsianWidth.txt diff --git a/Src/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz b/Src.GetRenamed/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz similarity index 100% rename from Src/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz rename to Src.GetRenamed/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz diff --git a/Src/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz b/Src.GetRenamed/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz similarity index 100% rename from Src/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz rename to Src.GetRenamed/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz diff --git a/Src/IronPython/Modules/unicodedata/NameAliases.txt b/Src.GetRenamed/IronPython/Modules/unicodedata/NameAliases.txt similarity index 100% rename from Src/IronPython/Modules/unicodedata/NameAliases.txt rename to Src.GetRenamed/IronPython/Modules/unicodedata/NameAliases.txt diff --git a/Src/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt b/Src.GetRenamed/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt similarity index 100% rename from Src/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt rename to Src.GetRenamed/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt diff --git a/Src/IronPython/Modules/unicodedata/UnicodeData.txt b/Src.GetRenamed/IronPython/Modules/unicodedata/UnicodeData.txt similarity index 100% rename from Src/IronPython/Modules/unicodedata/UnicodeData.txt rename to Src.GetRenamed/IronPython/Modules/unicodedata/UnicodeData.txt diff --git a/Src/IronPython/Modules/unicodedata/genunicodedata.py b/Src.GetRenamed/IronPython/Modules/unicodedata/genunicodedata.py similarity index 100% rename from Src/IronPython/Modules/unicodedata/genunicodedata.py rename to Src.GetRenamed/IronPython/Modules/unicodedata/genunicodedata.py diff --git a/Src/IronPython/Modules/unicodedata/license.txt b/Src.GetRenamed/IronPython/Modules/unicodedata/license.txt similarity index 100% rename from Src/IronPython/Modules/unicodedata/license.txt rename to Src.GetRenamed/IronPython/Modules/unicodedata/license.txt diff --git a/Src/IronPython/Properties/AssemblyInfo.cs b/Src.GetRenamed/IronPython/Properties/AssemblyInfo.cs similarity index 100% rename from Src/IronPython/Properties/AssemblyInfo.cs rename to Src.GetRenamed/IronPython/Properties/AssemblyInfo.cs diff --git a/Src/IronPython/Resources.Designer.cs b/Src.GetRenamed/IronPython/Resources.Designer.cs similarity index 100% rename from Src/IronPython/Resources.Designer.cs rename to Src.GetRenamed/IronPython/Resources.Designer.cs diff --git a/Src/IronPython/Resources.resx b/Src.GetRenamed/IronPython/Resources.resx similarity index 100% rename from Src/IronPython/Resources.resx rename to Src.GetRenamed/IronPython/Resources.resx diff --git a/Src/IronPython/Runtime/ArrayData.cs b/Src.GetRenamed/IronPython/Runtime/ArrayData.cs similarity index 100% rename from Src/IronPython/Runtime/ArrayData.cs rename to Src.GetRenamed/IronPython/Runtime/ArrayData.cs diff --git a/Src/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs diff --git a/Src/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs diff --git a/Src/IronPython/Runtime/Binding/Binders.cs b/Src.GetRenamed/IronPython/Runtime/Binding/Binders.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/Binders.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/Binders.cs diff --git a/Src/IronPython/Runtime/Binding/BindingHelpers.cs b/Src.GetRenamed/IronPython/Runtime/Binding/BindingHelpers.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/BindingHelpers.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/BindingHelpers.cs diff --git a/Src/IronPython/Runtime/Binding/BindingWarnings.cs b/Src.GetRenamed/IronPython/Runtime/Binding/BindingWarnings.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/BindingWarnings.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/BindingWarnings.cs diff --git a/Src/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs diff --git a/Src/IronPython/Runtime/Binding/ConditionalBuilder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/ConditionalBuilder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/ConditionalBuilder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/ConditionalBuilder.cs diff --git a/Src/IronPython/Runtime/Binding/ContextArgBuilder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/ContextArgBuilder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/ContextArgBuilder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/ContextArgBuilder.cs diff --git a/Src/IronPython/Runtime/Binding/ConversionBinder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/ConversionBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/ConversionBinder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/ConversionBinder.cs diff --git a/Src/IronPython/Runtime/Binding/CreateFallbackBinder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/CreateFallbackBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/CreateFallbackBinder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/CreateFallbackBinder.cs diff --git a/Src/IronPython/Runtime/Binding/FastBindResult.cs b/Src.GetRenamed/IronPython/Runtime/Binding/FastBindResult.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/FastBindResult.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/FastBindResult.cs diff --git a/Src/IronPython/Runtime/Binding/FastGetBase.cs b/Src.GetRenamed/IronPython/Runtime/Binding/FastGetBase.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/FastGetBase.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/FastGetBase.cs diff --git a/Src/IronPython/Runtime/Binding/FastSetBase.cs b/Src.GetRenamed/IronPython/Runtime/Binding/FastSetBase.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/FastSetBase.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/FastSetBase.cs diff --git a/Src/IronPython/Runtime/Binding/IComConvertible.cs b/Src.GetRenamed/IronPython/Runtime/Binding/IComConvertible.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/IComConvertible.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/IComConvertible.cs diff --git a/Src/IronPython/Runtime/Binding/IFastGettable.cs b/Src.GetRenamed/IronPython/Runtime/Binding/IFastGettable.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/IFastGettable.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/IFastGettable.cs diff --git a/Src/IronPython/Runtime/Binding/IFastInvokable.cs b/Src.GetRenamed/IronPython/Runtime/Binding/IFastInvokable.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/IFastInvokable.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/IFastInvokable.cs diff --git a/Src/IronPython/Runtime/Binding/IFastSettable.cs b/Src.GetRenamed/IronPython/Runtime/Binding/IFastSettable.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/IFastSettable.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/IFastSettable.cs diff --git a/Src/IronPython/Runtime/Binding/IPythonConvertible.cs b/Src.GetRenamed/IronPython/Runtime/Binding/IPythonConvertible.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/IPythonConvertible.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/IPythonConvertible.cs diff --git a/Src/IronPython/Runtime/Binding/IPythonExpandable.cs b/Src.GetRenamed/IronPython/Runtime/Binding/IPythonExpandable.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/IPythonExpandable.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/IPythonExpandable.cs diff --git a/Src/IronPython/Runtime/Binding/IPythonGetable.cs b/Src.GetRenamed/IronPython/Runtime/Binding/IPythonGetable.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/IPythonGetable.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/IPythonGetable.cs diff --git a/Src/IronPython/Runtime/Binding/IPythonInvokable.cs b/Src.GetRenamed/IronPython/Runtime/Binding/IPythonInvokable.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/IPythonInvokable.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/IPythonInvokable.cs diff --git a/Src/IronPython/Runtime/Binding/IPythonOperable.cs b/Src.GetRenamed/IronPython/Runtime/Binding/IPythonOperable.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/IPythonOperable.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/IPythonOperable.cs diff --git a/Src/IronPython/Runtime/Binding/IPythonSite.cs b/Src.GetRenamed/IronPython/Runtime/Binding/IPythonSite.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/IPythonSite.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/IPythonSite.cs diff --git a/Src/IronPython/Runtime/Binding/MetaBuiltinFunction.cs b/Src.GetRenamed/IronPython/Runtime/Binding/MetaBuiltinFunction.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/MetaBuiltinFunction.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/MetaBuiltinFunction.cs diff --git a/Src/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs b/Src.GetRenamed/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs diff --git a/Src/IronPython/Runtime/Binding/MetaMethod.cs b/Src.GetRenamed/IronPython/Runtime/Binding/MetaMethod.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/MetaMethod.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/MetaMethod.cs diff --git a/Src/IronPython/Runtime/Binding/MetaPythonFunction.cs b/Src.GetRenamed/IronPython/Runtime/Binding/MetaPythonFunction.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/MetaPythonFunction.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/MetaPythonFunction.cs diff --git a/Src/IronPython/Runtime/Binding/MetaPythonObject.cs b/Src.GetRenamed/IronPython/Runtime/Binding/MetaPythonObject.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/MetaPythonObject.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/MetaPythonObject.cs diff --git a/Src/IronPython/Runtime/Binding/MetaPythonType.Calls.cs b/Src.GetRenamed/IronPython/Runtime/Binding/MetaPythonType.Calls.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/MetaPythonType.Calls.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/MetaPythonType.Calls.cs diff --git a/Src/IronPython/Runtime/Binding/MetaPythonType.Members.cs b/Src.GetRenamed/IronPython/Runtime/Binding/MetaPythonType.Members.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/MetaPythonType.Members.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/MetaPythonType.Members.cs diff --git a/Src/IronPython/Runtime/Binding/MetaPythonType.cs b/Src.GetRenamed/IronPython/Runtime/Binding/MetaPythonType.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/MetaPythonType.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/MetaPythonType.cs diff --git a/Src/IronPython/Runtime/Binding/MetaUserObject.Members.cs b/Src.GetRenamed/IronPython/Runtime/Binding/MetaUserObject.Members.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/MetaUserObject.Members.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/MetaUserObject.Members.cs diff --git a/Src/IronPython/Runtime/Binding/MetaUserObject.cs b/Src.GetRenamed/IronPython/Runtime/Binding/MetaUserObject.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/MetaUserObject.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/MetaUserObject.cs diff --git a/Src/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonBinder.Create.cs b/Src.GetRenamed/IronPython/Runtime/Binding/PythonBinder.Create.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonBinder.Create.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/PythonBinder.Create.cs diff --git a/Src/IronPython/Runtime/Binding/PythonBinder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/PythonBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonBinder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/PythonBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/PythonExtensionBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/PythonExtensionBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonGetIndexBinder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/PythonGetIndexBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonGetIndexBinder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/PythonGetIndexBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonGetMemberBinder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/PythonGetMemberBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonGetMemberBinder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/PythonGetMemberBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonGetSliceBinder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/PythonGetSliceBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonGetSliceBinder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/PythonGetSliceBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonIndexType.cs b/Src.GetRenamed/IronPython/Runtime/Binding/PythonIndexType.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonIndexType.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/PythonIndexType.cs diff --git a/Src/IronPython/Runtime/Binding/PythonInvokeBinder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/PythonInvokeBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonInvokeBinder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/PythonInvokeBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonOperationBinder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/PythonOperationBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonOperationBinder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/PythonOperationBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonOperationKind.cs b/Src.GetRenamed/IronPython/Runtime/Binding/PythonOperationKind.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonOperationKind.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/PythonOperationKind.cs diff --git a/Src/IronPython/Runtime/Binding/PythonOverloadResolver.cs b/Src.GetRenamed/IronPython/Runtime/Binding/PythonOverloadResolver.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonOverloadResolver.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/PythonOverloadResolver.cs diff --git a/Src/IronPython/Runtime/Binding/PythonProtocol.Operations.cs b/Src.GetRenamed/IronPython/Runtime/Binding/PythonProtocol.Operations.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonProtocol.Operations.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/PythonProtocol.Operations.cs diff --git a/Src/IronPython/Runtime/Binding/PythonProtocol.cs b/Src.GetRenamed/IronPython/Runtime/Binding/PythonProtocol.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonProtocol.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/PythonProtocol.cs diff --git a/Src/IronPython/Runtime/Binding/PythonSetIndexBinder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/PythonSetIndexBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonSetIndexBinder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/PythonSetIndexBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonSetMemberBinder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/PythonSetMemberBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonSetMemberBinder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/PythonSetMemberBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonSetSliceBinder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/PythonSetSliceBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonSetSliceBinder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/PythonSetSliceBinder.cs diff --git a/Src/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs diff --git a/Src/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs b/Src.GetRenamed/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs diff --git a/Src/IronPython/Runtime/Binding/SlotOrFunction.cs b/Src.GetRenamed/IronPython/Runtime/Binding/SlotOrFunction.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/SlotOrFunction.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/SlotOrFunction.cs diff --git a/Src/IronPython/Runtime/Binding/WarningInfo.cs b/Src.GetRenamed/IronPython/Runtime/Binding/WarningInfo.cs similarity index 100% rename from Src/IronPython/Runtime/Binding/WarningInfo.cs rename to Src.GetRenamed/IronPython/Runtime/Binding/WarningInfo.cs diff --git a/Src/IronPython/Runtime/BufferProtocol.cs b/Src.GetRenamed/IronPython/Runtime/BufferProtocol.cs similarity index 100% rename from Src/IronPython/Runtime/BufferProtocol.cs rename to Src.GetRenamed/IronPython/Runtime/BufferProtocol.cs diff --git a/Src/IronPython/Runtime/BuiltinPythonModule.cs b/Src.GetRenamed/IronPython/Runtime/BuiltinPythonModule.cs similarity index 100% rename from Src/IronPython/Runtime/BuiltinPythonModule.cs rename to Src.GetRenamed/IronPython/Runtime/BuiltinPythonModule.cs diff --git a/Src/IronPython/Runtime/BuiltinsDictionaryStorage.cs b/Src.GetRenamed/IronPython/Runtime/BuiltinsDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/BuiltinsDictionaryStorage.cs rename to Src.GetRenamed/IronPython/Runtime/BuiltinsDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/ByteArray.cs b/Src.GetRenamed/IronPython/Runtime/ByteArray.cs similarity index 100% rename from Src/IronPython/Runtime/ByteArray.cs rename to Src.GetRenamed/IronPython/Runtime/ByteArray.cs diff --git a/Src/IronPython/Runtime/ByteArrayIterator.cs b/Src.GetRenamed/IronPython/Runtime/ByteArrayIterator.cs similarity index 100% rename from Src/IronPython/Runtime/ByteArrayIterator.cs rename to Src.GetRenamed/IronPython/Runtime/ByteArrayIterator.cs diff --git a/Src/IronPython/Runtime/Bytes.cs b/Src.GetRenamed/IronPython/Runtime/Bytes.cs similarity index 100% rename from Src/IronPython/Runtime/Bytes.cs rename to Src.GetRenamed/IronPython/Runtime/Bytes.cs diff --git a/Src/IronPython/Runtime/BytesIterator.cs b/Src.GetRenamed/IronPython/Runtime/BytesIterator.cs similarity index 100% rename from Src/IronPython/Runtime/BytesIterator.cs rename to Src.GetRenamed/IronPython/Runtime/BytesIterator.cs diff --git a/Src/IronPython/Runtime/BytesLikeAttribute.cs b/Src.GetRenamed/IronPython/Runtime/BytesLikeAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/BytesLikeAttribute.cs rename to Src.GetRenamed/IronPython/Runtime/BytesLikeAttribute.cs diff --git a/Src/IronPython/Runtime/ClassMethodAttribute.cs b/Src.GetRenamed/IronPython/Runtime/ClassMethodAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/ClassMethodAttribute.cs rename to Src.GetRenamed/IronPython/Runtime/ClassMethodAttribute.cs diff --git a/Src/IronPython/Runtime/ClassMethodDescriptor.cs b/Src.GetRenamed/IronPython/Runtime/ClassMethodDescriptor.cs similarity index 100% rename from Src/IronPython/Runtime/ClassMethodDescriptor.cs rename to Src.GetRenamed/IronPython/Runtime/ClassMethodDescriptor.cs diff --git a/Src/IronPython/Runtime/ClrModule.cs b/Src.GetRenamed/IronPython/Runtime/ClrModule.cs similarity index 100% rename from Src/IronPython/Runtime/ClrModule.cs rename to Src.GetRenamed/IronPython/Runtime/ClrModule.cs diff --git a/Src/IronPython/Runtime/CodeContext.cs b/Src.GetRenamed/IronPython/Runtime/CodeContext.cs similarity index 100% rename from Src/IronPython/Runtime/CodeContext.cs rename to Src.GetRenamed/IronPython/Runtime/CodeContext.cs diff --git a/Src/IronPython/Runtime/CollectionDebugView.cs b/Src.GetRenamed/IronPython/Runtime/CollectionDebugView.cs similarity index 100% rename from Src/IronPython/Runtime/CollectionDebugView.cs rename to Src.GetRenamed/IronPython/Runtime/CollectionDebugView.cs diff --git a/Src/IronPython/Runtime/CommonDictionaryStorage.cs b/Src.GetRenamed/IronPython/Runtime/CommonDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/CommonDictionaryStorage.cs rename to Src.GetRenamed/IronPython/Runtime/CommonDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/CompareUtil.cs b/Src.GetRenamed/IronPython/Runtime/CompareUtil.cs similarity index 100% rename from Src/IronPython/Runtime/CompareUtil.cs rename to Src.GetRenamed/IronPython/Runtime/CompareUtil.cs diff --git a/Src/IronPython/Runtime/CompileFlags.cs b/Src.GetRenamed/IronPython/Runtime/CompileFlags.cs similarity index 100% rename from Src/IronPython/Runtime/CompileFlags.cs rename to Src.GetRenamed/IronPython/Runtime/CompileFlags.cs diff --git a/Src/IronPython/Runtime/CompiledLoader.cs b/Src.GetRenamed/IronPython/Runtime/CompiledLoader.cs similarity index 100% rename from Src/IronPython/Runtime/CompiledLoader.cs rename to Src.GetRenamed/IronPython/Runtime/CompiledLoader.cs diff --git a/Src/IronPython/Runtime/ConstantDictionaryStorage.cs b/Src.GetRenamed/IronPython/Runtime/ConstantDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/ConstantDictionaryStorage.cs rename to Src.GetRenamed/IronPython/Runtime/ConstantDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/ConversionWrappers.cs b/Src.GetRenamed/IronPython/Runtime/ConversionWrappers.cs similarity index 100% rename from Src/IronPython/Runtime/ConversionWrappers.cs rename to Src.GetRenamed/IronPython/Runtime/ConversionWrappers.cs diff --git a/Src/IronPython/Runtime/Converter.cs b/Src.GetRenamed/IronPython/Runtime/Converter.cs similarity index 100% rename from Src/IronPython/Runtime/Converter.cs rename to Src.GetRenamed/IronPython/Runtime/Converter.cs diff --git a/Src/IronPython/Runtime/CustomDictionaryStorage.cs b/Src.GetRenamed/IronPython/Runtime/CustomDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/CustomDictionaryStorage.cs rename to Src.GetRenamed/IronPython/Runtime/CustomDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/DebuggerDictionaryStorage.cs b/Src.GetRenamed/IronPython/Runtime/DebuggerDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/DebuggerDictionaryStorage.cs rename to Src.GetRenamed/IronPython/Runtime/DebuggerDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/DefaultContext.cs b/Src.GetRenamed/IronPython/Runtime/DefaultContext.cs similarity index 100% rename from Src/IronPython/Runtime/DefaultContext.cs rename to Src.GetRenamed/IronPython/Runtime/DefaultContext.cs diff --git a/Src/IronPython/Runtime/Descriptors.cs b/Src.GetRenamed/IronPython/Runtime/Descriptors.cs similarity index 100% rename from Src/IronPython/Runtime/Descriptors.cs rename to Src.GetRenamed/IronPython/Runtime/Descriptors.cs diff --git a/Src/IronPython/Runtime/DictionaryOps.cs b/Src.GetRenamed/IronPython/Runtime/DictionaryOps.cs similarity index 100% rename from Src/IronPython/Runtime/DictionaryOps.cs rename to Src.GetRenamed/IronPython/Runtime/DictionaryOps.cs diff --git a/Src/IronPython/Runtime/DictionaryStorage.cs b/Src.GetRenamed/IronPython/Runtime/DictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/DictionaryStorage.cs rename to Src.GetRenamed/IronPython/Runtime/DictionaryStorage.cs diff --git a/Src/IronPython/Runtime/DictionaryTypeInfoAttribute.cs b/Src.GetRenamed/IronPython/Runtime/DictionaryTypeInfoAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/DictionaryTypeInfoAttribute.cs rename to Src.GetRenamed/IronPython/Runtime/DictionaryTypeInfoAttribute.cs diff --git a/Src/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs b/Src.GetRenamed/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs rename to Src.GetRenamed/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs diff --git a/Src/IronPython/Runtime/DontMapICollectionToLenAttribute.cs b/Src.GetRenamed/IronPython/Runtime/DontMapICollectionToLenAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/DontMapICollectionToLenAttribute.cs rename to Src.GetRenamed/IronPython/Runtime/DontMapICollectionToLenAttribute.cs diff --git a/Src/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs b/Src.GetRenamed/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs rename to Src.GetRenamed/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs diff --git a/Src/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs b/Src.GetRenamed/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs rename to Src.GetRenamed/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs diff --git a/Src/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs b/Src.GetRenamed/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs rename to Src.GetRenamed/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs diff --git a/Src/IronPython/Runtime/EmptyDictionaryStorage.cs b/Src.GetRenamed/IronPython/Runtime/EmptyDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/EmptyDictionaryStorage.cs rename to Src.GetRenamed/IronPython/Runtime/EmptyDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/Enumerate.cs b/Src.GetRenamed/IronPython/Runtime/Enumerate.cs similarity index 100% rename from Src/IronPython/Runtime/Enumerate.cs rename to Src.GetRenamed/IronPython/Runtime/Enumerate.cs diff --git a/Src/IronPython/Runtime/ErrorCodes.cs b/Src.GetRenamed/IronPython/Runtime/ErrorCodes.cs similarity index 100% rename from Src/IronPython/Runtime/ErrorCodes.cs rename to Src.GetRenamed/IronPython/Runtime/ErrorCodes.cs diff --git a/Src/IronPython/Runtime/Exceptions/AssertionException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/AssertionException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/AssertionException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/AssertionException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/AttributeErrorException.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/AttributeErrorException.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/AttributeErrorException.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/AttributeErrorException.cs diff --git a/Src/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/BufferException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/BufferException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/BufferException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/BufferException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/GeneratorExitException.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/GeneratorExitException.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/GeneratorExitException.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/GeneratorExitException.cs diff --git a/Src/IronPython/Runtime/Exceptions/ImportException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/ImportException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ImportException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/ImportException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/IndentationException.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/IndentationException.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/IndentationException.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/IndentationException.cs diff --git a/Src/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/LookupException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/LookupException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/LookupException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/LookupException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs diff --git a/Src/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/OSException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/OSException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/OSException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/OSException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/PythonException.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/PythonException.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/PythonException.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/PythonException.cs diff --git a/Src/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs diff --git a/Src/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/PythonExceptions.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/PythonExceptions.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/PythonExceptions.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/PythonExceptions.cs diff --git a/Src/IronPython/Runtime/Exceptions/RecursionException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/RecursionException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/RecursionException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/RecursionException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/SystemExitException.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/SystemExitException.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/SystemExitException.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/SystemExitException.cs diff --git a/Src/IronPython/Runtime/Exceptions/TabException.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/TabException.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/TabException.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/TabException.cs diff --git a/Src/IronPython/Runtime/Exceptions/TraceBack.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/TraceBack.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/TraceBack.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/TraceBack.cs diff --git a/Src/IronPython/Runtime/Exceptions/TypeErrorException.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/TypeErrorException.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/TypeErrorException.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/TypeErrorException.cs diff --git a/Src/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs diff --git a/Src/IronPython/Runtime/Exceptions/ValueErrorException.cs b/Src.GetRenamed/IronPython/Runtime/Exceptions/ValueErrorException.cs similarity index 100% rename from Src/IronPython/Runtime/Exceptions/ValueErrorException.cs rename to Src.GetRenamed/IronPython/Runtime/Exceptions/ValueErrorException.cs diff --git a/Src/IronPython/Runtime/ExtensionMethodSet.cs b/Src.GetRenamed/IronPython/Runtime/ExtensionMethodSet.cs similarity index 100% rename from Src/IronPython/Runtime/ExtensionMethodSet.cs rename to Src.GetRenamed/IronPython/Runtime/ExtensionMethodSet.cs diff --git a/Src/IronPython/Runtime/Filter.cs b/Src.GetRenamed/IronPython/Runtime/Filter.cs similarity index 100% rename from Src/IronPython/Runtime/Filter.cs rename to Src.GetRenamed/IronPython/Runtime/Filter.cs diff --git a/Src/IronPython/Runtime/FormattingHelper.cs b/Src.GetRenamed/IronPython/Runtime/FormattingHelper.cs similarity index 100% rename from Src/IronPython/Runtime/FormattingHelper.cs rename to Src.GetRenamed/IronPython/Runtime/FormattingHelper.cs diff --git a/Src/IronPython/Runtime/FunctionAttributes.cs b/Src.GetRenamed/IronPython/Runtime/FunctionAttributes.cs similarity index 100% rename from Src/IronPython/Runtime/FunctionAttributes.cs rename to Src.GetRenamed/IronPython/Runtime/FunctionAttributes.cs diff --git a/Src/IronPython/Runtime/FunctionCode.cs b/Src.GetRenamed/IronPython/Runtime/FunctionCode.cs similarity index 100% rename from Src/IronPython/Runtime/FunctionCode.cs rename to Src.GetRenamed/IronPython/Runtime/FunctionCode.cs diff --git a/Src/IronPython/Runtime/Generator.cs b/Src.GetRenamed/IronPython/Runtime/Generator.cs similarity index 100% rename from Src/IronPython/Runtime/Generator.cs rename to Src.GetRenamed/IronPython/Runtime/Generator.cs diff --git a/Src/IronPython/Runtime/GlobalDictionaryStorage.cs b/Src.GetRenamed/IronPython/Runtime/GlobalDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/GlobalDictionaryStorage.cs rename to Src.GetRenamed/IronPython/Runtime/GlobalDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/IParameterSequence.cs b/Src.GetRenamed/IronPython/Runtime/IParameterSequence.cs similarity index 100% rename from Src/IronPython/Runtime/IParameterSequence.cs rename to Src.GetRenamed/IronPython/Runtime/IParameterSequence.cs diff --git a/Src/IronPython/Runtime/Implementation.cs b/Src.GetRenamed/IronPython/Runtime/Implementation.cs similarity index 100% rename from Src/IronPython/Runtime/Implementation.cs rename to Src.GetRenamed/IronPython/Runtime/Implementation.cs diff --git a/Src/IronPython/Runtime/Importer.cs b/Src.GetRenamed/IronPython/Runtime/Importer.cs similarity index 100% rename from Src/IronPython/Runtime/Importer.cs rename to Src.GetRenamed/IronPython/Runtime/Importer.cs diff --git a/Src/IronPython/Runtime/Index.cs b/Src.GetRenamed/IronPython/Runtime/Index.cs similarity index 100% rename from Src/IronPython/Runtime/Index.cs rename to Src.GetRenamed/IronPython/Runtime/Index.cs diff --git a/Src/IronPython/Runtime/InstancedModuleDictionaryStorage.cs b/Src.GetRenamed/IronPython/Runtime/InstancedModuleDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/InstancedModuleDictionaryStorage.cs rename to Src.GetRenamed/IronPython/Runtime/InstancedModuleDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/Interfaces.cs b/Src.GetRenamed/IronPython/Runtime/Interfaces.cs similarity index 100% rename from Src/IronPython/Runtime/Interfaces.cs rename to Src.GetRenamed/IronPython/Runtime/Interfaces.cs diff --git a/Src/IronPython/Runtime/KwCallInfo.cs b/Src.GetRenamed/IronPython/Runtime/KwCallInfo.cs similarity index 100% rename from Src/IronPython/Runtime/KwCallInfo.cs rename to Src.GetRenamed/IronPython/Runtime/KwCallInfo.cs diff --git a/Src/IronPython/Runtime/LiteralParser.cs b/Src.GetRenamed/IronPython/Runtime/LiteralParser.cs similarity index 100% rename from Src/IronPython/Runtime/LiteralParser.cs rename to Src.GetRenamed/IronPython/Runtime/LiteralParser.cs diff --git a/Src/IronPython/Runtime/Map.cs b/Src.GetRenamed/IronPython/Runtime/Map.cs similarity index 100% rename from Src/IronPython/Runtime/Map.cs rename to Src.GetRenamed/IronPython/Runtime/Map.cs diff --git a/Src/IronPython/Runtime/MaybeNotImplementedAttribute.cs b/Src.GetRenamed/IronPython/Runtime/MaybeNotImplementedAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/MaybeNotImplementedAttribute.cs rename to Src.GetRenamed/IronPython/Runtime/MaybeNotImplementedAttribute.cs diff --git a/Src/IronPython/Runtime/MemoryStreamContentProvider.cs b/Src.GetRenamed/IronPython/Runtime/MemoryStreamContentProvider.cs similarity index 100% rename from Src/IronPython/Runtime/MemoryStreamContentProvider.cs rename to Src.GetRenamed/IronPython/Runtime/MemoryStreamContentProvider.cs diff --git a/Src/IronPython/Runtime/MemoryView.cs b/Src.GetRenamed/IronPython/Runtime/MemoryView.cs similarity index 100% rename from Src/IronPython/Runtime/MemoryView.cs rename to Src.GetRenamed/IronPython/Runtime/MemoryView.cs diff --git a/Src/IronPython/Runtime/Method.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Method.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Method.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Method.Generated.cs diff --git a/Src/IronPython/Runtime/Method.cs b/Src.GetRenamed/IronPython/Runtime/Method.cs similarity index 100% rename from Src/IronPython/Runtime/Method.cs rename to Src.GetRenamed/IronPython/Runtime/Method.cs diff --git a/Src/IronPython/Runtime/MissingParameter.cs b/Src.GetRenamed/IronPython/Runtime/MissingParameter.cs similarity index 100% rename from Src/IronPython/Runtime/MissingParameter.cs rename to Src.GetRenamed/IronPython/Runtime/MissingParameter.cs diff --git a/Src/IronPython/Runtime/ModuleContext.cs b/Src.GetRenamed/IronPython/Runtime/ModuleContext.cs similarity index 100% rename from Src/IronPython/Runtime/ModuleContext.cs rename to Src.GetRenamed/IronPython/Runtime/ModuleContext.cs diff --git a/Src/IronPython/Runtime/ModuleDictionaryStorage.cs b/Src.GetRenamed/IronPython/Runtime/ModuleDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/ModuleDictionaryStorage.cs rename to Src.GetRenamed/IronPython/Runtime/ModuleDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/ModuleGlobalCache.cs b/Src.GetRenamed/IronPython/Runtime/ModuleGlobalCache.cs similarity index 100% rename from Src/IronPython/Runtime/ModuleGlobalCache.cs rename to Src.GetRenamed/IronPython/Runtime/ModuleGlobalCache.cs diff --git a/Src/IronPython/Runtime/ModuleLoader.cs b/Src.GetRenamed/IronPython/Runtime/ModuleLoader.cs similarity index 100% rename from Src/IronPython/Runtime/ModuleLoader.cs rename to Src.GetRenamed/IronPython/Runtime/ModuleLoader.cs diff --git a/Src/IronPython/Runtime/ModuleOptions.cs b/Src.GetRenamed/IronPython/Runtime/ModuleOptions.cs similarity index 100% rename from Src/IronPython/Runtime/ModuleOptions.cs rename to Src.GetRenamed/IronPython/Runtime/ModuleOptions.cs diff --git a/Src/IronPython/Runtime/NameType.cs b/Src.GetRenamed/IronPython/Runtime/NameType.cs similarity index 100% rename from Src/IronPython/Runtime/NameType.cs rename to Src.GetRenamed/IronPython/Runtime/NameType.cs diff --git a/Src/IronPython/Runtime/NewStringFormatter.cs b/Src.GetRenamed/IronPython/Runtime/NewStringFormatter.cs similarity index 100% rename from Src/IronPython/Runtime/NewStringFormatter.cs rename to Src.GetRenamed/IronPython/Runtime/NewStringFormatter.cs diff --git a/Src/IronPython/Runtime/ObjectAttributesAdapter.cs b/Src.GetRenamed/IronPython/Runtime/ObjectAttributesAdapter.cs similarity index 100% rename from Src/IronPython/Runtime/ObjectAttributesAdapter.cs rename to Src.GetRenamed/IronPython/Runtime/ObjectAttributesAdapter.cs diff --git a/Src/IronPython/Runtime/ObjectDebugView.cs b/Src.GetRenamed/IronPython/Runtime/ObjectDebugView.cs similarity index 100% rename from Src/IronPython/Runtime/ObjectDebugView.cs rename to Src.GetRenamed/IronPython/Runtime/ObjectDebugView.cs diff --git a/Src/IronPython/Runtime/Operations/ArrayOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/ArrayOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/ArrayOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/ArrayOps.cs diff --git a/Src/IronPython/Runtime/Operations/BigIntegerOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/BigIntegerOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/BigIntegerOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/BigIntegerOps.cs diff --git a/Src/IronPython/Runtime/Operations/BoolOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/BoolOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/BoolOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/BoolOps.cs diff --git a/Src/IronPython/Runtime/Operations/ByteOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/ByteOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/ByteOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/ByteOps.cs diff --git a/Src/IronPython/Runtime/Operations/CharOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/CharOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/CharOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/CharOps.cs diff --git a/Src/IronPython/Runtime/Operations/ComOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/ComOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/ComOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/ComOps.cs diff --git a/Src/IronPython/Runtime/Operations/ComplexOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/ComplexOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/ComplexOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/ComplexOps.cs diff --git a/Src/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs b/Src.GetRenamed/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs diff --git a/Src/IronPython/Runtime/Operations/DBNullOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/DBNullOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/DBNullOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/DBNullOps.cs diff --git a/Src/IronPython/Runtime/Operations/DateTimeOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/DateTimeOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/DateTimeOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/DateTimeOps.cs diff --git a/Src/IronPython/Runtime/Operations/DecimalOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/DecimalOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/DecimalOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/DecimalOps.cs diff --git a/Src/IronPython/Runtime/Operations/DelegateOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/DelegateOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/DelegateOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/DelegateOps.cs diff --git a/Src/IronPython/Runtime/Operations/DictionaryOfTOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/DictionaryOfTOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/DictionaryOfTOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/DictionaryOfTOps.cs diff --git a/Src/IronPython/Runtime/Operations/EnumOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/EnumOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/EnumOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/EnumOps.cs diff --git a/Src/IronPython/Runtime/Operations/FloatOps.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Operations/FloatOps.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/FloatOps.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/FloatOps.Generated.cs diff --git a/Src/IronPython/Runtime/Operations/FloatOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/FloatOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/FloatOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/FloatOps.cs diff --git a/Src/IronPython/Runtime/Operations/IListOfByteOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/IListOfByteOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/IListOfByteOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/IListOfByteOps.cs diff --git a/Src/IronPython/Runtime/Operations/InstanceOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/InstanceOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/InstanceOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/InstanceOps.cs diff --git a/Src/IronPython/Runtime/Operations/IntOps.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Operations/IntOps.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/IntOps.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/IntOps.Generated.cs diff --git a/Src/IronPython/Runtime/Operations/IntOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/IntOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/IntOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/IntOps.cs diff --git a/Src/IronPython/Runtime/Operations/IntPtrOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/IntPtrOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/IntPtrOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/IntPtrOps.cs diff --git a/Src/IronPython/Runtime/Operations/ListOfTOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/ListOfTOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/ListOfTOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/ListOfTOps.cs diff --git a/Src/IronPython/Runtime/Operations/MarshalOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/MarshalOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/MarshalOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/MarshalOps.cs diff --git a/Src/IronPython/Runtime/Operations/NamespaceTrackerOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/NamespaceTrackerOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/NamespaceTrackerOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/NamespaceTrackerOps.cs diff --git a/Src/IronPython/Runtime/Operations/ObjectOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/ObjectOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/ObjectOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/ObjectOps.cs diff --git a/Src/IronPython/Runtime/Operations/PythonCalls.cs b/Src.GetRenamed/IronPython/Runtime/Operations/PythonCalls.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/PythonCalls.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/PythonCalls.cs diff --git a/Src/IronPython/Runtime/Operations/PythonOps.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Operations/PythonOps.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/PythonOps.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/PythonOps.Generated.cs diff --git a/Src/IronPython/Runtime/Operations/PythonOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/PythonOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/PythonOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/PythonOps.cs diff --git a/Src/IronPython/Runtime/Operations/PythonTypeOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/PythonTypeOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/PythonTypeOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/PythonTypeOps.cs diff --git a/Src/IronPython/Runtime/Operations/StringOps.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Operations/StringOps.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/StringOps.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/StringOps.Generated.cs diff --git a/Src/IronPython/Runtime/Operations/StringOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/StringOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/StringOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/StringOps.cs diff --git a/Src/IronPython/Runtime/Operations/TypeGroupOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/TypeGroupOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/TypeGroupOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/TypeGroupOps.cs diff --git a/Src/IronPython/Runtime/Operations/TypeTrackerOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/TypeTrackerOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/TypeTrackerOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/TypeTrackerOps.cs diff --git a/Src/IronPython/Runtime/Operations/UIntPtrOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/UIntPtrOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/UIntPtrOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/UIntPtrOps.cs diff --git a/Src/IronPython/Runtime/Operations/UserTypeOps.cs b/Src.GetRenamed/IronPython/Runtime/Operations/UserTypeOps.cs similarity index 100% rename from Src/IronPython/Runtime/Operations/UserTypeOps.cs rename to Src.GetRenamed/IronPython/Runtime/Operations/UserTypeOps.cs diff --git a/Src/IronPython/Runtime/OutputWriter.cs b/Src.GetRenamed/IronPython/Runtime/OutputWriter.cs similarity index 100% rename from Src/IronPython/Runtime/OutputWriter.cs rename to Src.GetRenamed/IronPython/Runtime/OutputWriter.cs diff --git a/Src/IronPython/Runtime/PlatformsAttribute.cs b/Src.GetRenamed/IronPython/Runtime/PlatformsAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/PlatformsAttribute.cs rename to Src.GetRenamed/IronPython/Runtime/PlatformsAttribute.cs diff --git a/Src/IronPython/Runtime/Profiler.cs b/Src.GetRenamed/IronPython/Runtime/Profiler.cs similarity index 100% rename from Src/IronPython/Runtime/Profiler.cs rename to Src.GetRenamed/IronPython/Runtime/Profiler.cs diff --git a/Src/IronPython/Runtime/PythonContext.Generated.cs b/Src.GetRenamed/IronPython/Runtime/PythonContext.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/PythonContext.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/PythonContext.Generated.cs diff --git a/Src/IronPython/Runtime/PythonContext.cs b/Src.GetRenamed/IronPython/Runtime/PythonContext.cs similarity index 100% rename from Src/IronPython/Runtime/PythonContext.cs rename to Src.GetRenamed/IronPython/Runtime/PythonContext.cs diff --git a/Src/IronPython/Runtime/PythonDictionary.cs b/Src.GetRenamed/IronPython/Runtime/PythonDictionary.cs similarity index 100% rename from Src/IronPython/Runtime/PythonDictionary.cs rename to Src.GetRenamed/IronPython/Runtime/PythonDictionary.cs diff --git a/Src/IronPython/Runtime/PythonDocumentationProvider.cs b/Src.GetRenamed/IronPython/Runtime/PythonDocumentationProvider.cs similarity index 100% rename from Src/IronPython/Runtime/PythonDocumentationProvider.cs rename to Src.GetRenamed/IronPython/Runtime/PythonDocumentationProvider.cs diff --git a/Src/IronPython/Runtime/PythonDynamicStackFrame.cs b/Src.GetRenamed/IronPython/Runtime/PythonDynamicStackFrame.cs similarity index 100% rename from Src/IronPython/Runtime/PythonDynamicStackFrame.cs rename to Src.GetRenamed/IronPython/Runtime/PythonDynamicStackFrame.cs diff --git a/Src/IronPython/Runtime/PythonEncoding.cs b/Src.GetRenamed/IronPython/Runtime/PythonEncoding.cs similarity index 100% rename from Src/IronPython/Runtime/PythonEncoding.cs rename to Src.GetRenamed/IronPython/Runtime/PythonEncoding.cs diff --git a/Src/IronPython/Runtime/PythonFileManager.cs b/Src.GetRenamed/IronPython/Runtime/PythonFileManager.cs similarity index 100% rename from Src/IronPython/Runtime/PythonFileManager.cs rename to Src.GetRenamed/IronPython/Runtime/PythonFileManager.cs diff --git a/Src/IronPython/Runtime/PythonFunction.Generated.cs b/Src.GetRenamed/IronPython/Runtime/PythonFunction.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/PythonFunction.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/PythonFunction.Generated.cs diff --git a/Src/IronPython/Runtime/PythonFunction.cs b/Src.GetRenamed/IronPython/Runtime/PythonFunction.cs similarity index 100% rename from Src/IronPython/Runtime/PythonFunction.cs rename to Src.GetRenamed/IronPython/Runtime/PythonFunction.cs diff --git a/Src/IronPython/Runtime/PythonHiddenAttribute.cs b/Src.GetRenamed/IronPython/Runtime/PythonHiddenAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/PythonHiddenAttribute.cs rename to Src.GetRenamed/IronPython/Runtime/PythonHiddenAttribute.cs diff --git a/Src/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs b/Src.GetRenamed/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs rename to Src.GetRenamed/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs diff --git a/Src/IronPython/Runtime/PythonList.cs b/Src.GetRenamed/IronPython/Runtime/PythonList.cs similarity index 100% rename from Src/IronPython/Runtime/PythonList.cs rename to Src.GetRenamed/IronPython/Runtime/PythonList.cs diff --git a/Src/IronPython/Runtime/PythonModule.cs b/Src.GetRenamed/IronPython/Runtime/PythonModule.cs old mode 100755 new mode 100644 similarity index 100% rename from Src/IronPython/Runtime/PythonModule.cs rename to Src.GetRenamed/IronPython/Runtime/PythonModule.cs diff --git a/Src/IronPython/Runtime/PythonModuleAttribute.cs b/Src.GetRenamed/IronPython/Runtime/PythonModuleAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/PythonModuleAttribute.cs rename to Src.GetRenamed/IronPython/Runtime/PythonModuleAttribute.cs diff --git a/Src/IronPython/Runtime/PythonNarrowing.cs b/Src.GetRenamed/IronPython/Runtime/PythonNarrowing.cs similarity index 100% rename from Src/IronPython/Runtime/PythonNarrowing.cs rename to Src.GetRenamed/IronPython/Runtime/PythonNarrowing.cs diff --git a/Src/IronPython/Runtime/PythonOptions.cs b/Src.GetRenamed/IronPython/Runtime/PythonOptions.cs similarity index 100% rename from Src/IronPython/Runtime/PythonOptions.cs rename to Src.GetRenamed/IronPython/Runtime/PythonOptions.cs diff --git a/Src/IronPython/Runtime/PythonRange.cs b/Src.GetRenamed/IronPython/Runtime/PythonRange.cs similarity index 100% rename from Src/IronPython/Runtime/PythonRange.cs rename to Src.GetRenamed/IronPython/Runtime/PythonRange.cs diff --git a/Src/IronPython/Runtime/PythonScopeExtension.cs b/Src.GetRenamed/IronPython/Runtime/PythonScopeExtension.cs similarity index 100% rename from Src/IronPython/Runtime/PythonScopeExtension.cs rename to Src.GetRenamed/IronPython/Runtime/PythonScopeExtension.cs diff --git a/Src/IronPython/Runtime/PythonStrIterator.cs b/Src.GetRenamed/IronPython/Runtime/PythonStrIterator.cs similarity index 100% rename from Src/IronPython/Runtime/PythonStrIterator.cs rename to Src.GetRenamed/IronPython/Runtime/PythonStrIterator.cs diff --git a/Src/IronPython/Runtime/PythonTracebackListener.cs b/Src.GetRenamed/IronPython/Runtime/PythonTracebackListener.cs similarity index 100% rename from Src/IronPython/Runtime/PythonTracebackListener.cs rename to Src.GetRenamed/IronPython/Runtime/PythonTracebackListener.cs diff --git a/Src/IronPython/Runtime/PythonTuple.cs b/Src.GetRenamed/IronPython/Runtime/PythonTuple.cs similarity index 100% rename from Src/IronPython/Runtime/PythonTuple.cs rename to Src.GetRenamed/IronPython/Runtime/PythonTuple.cs diff --git a/Src/IronPython/Runtime/PythonTypeAttribute.cs b/Src.GetRenamed/IronPython/Runtime/PythonTypeAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/PythonTypeAttribute.cs rename to Src.GetRenamed/IronPython/Runtime/PythonTypeAttribute.cs diff --git a/Src/IronPython/Runtime/Reversed.cs b/Src.GetRenamed/IronPython/Runtime/Reversed.cs similarity index 100% rename from Src/IronPython/Runtime/Reversed.cs rename to Src.GetRenamed/IronPython/Runtime/Reversed.cs diff --git a/Src/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs b/Src.GetRenamed/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs rename to Src.GetRenamed/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/ScopeDictionaryStorage.cs b/Src.GetRenamed/IronPython/Runtime/ScopeDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/ScopeDictionaryStorage.cs rename to Src.GetRenamed/IronPython/Runtime/ScopeDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/SequenceTypeInfoAttribute.cs b/Src.GetRenamed/IronPython/Runtime/SequenceTypeInfoAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/SequenceTypeInfoAttribute.cs rename to Src.GetRenamed/IronPython/Runtime/SequenceTypeInfoAttribute.cs diff --git a/Src/IronPython/Runtime/Set.cs b/Src.GetRenamed/IronPython/Runtime/Set.cs similarity index 100% rename from Src/IronPython/Runtime/Set.cs rename to Src.GetRenamed/IronPython/Runtime/Set.cs diff --git a/Src/IronPython/Runtime/SetStorage.cs b/Src.GetRenamed/IronPython/Runtime/SetStorage.cs similarity index 100% rename from Src/IronPython/Runtime/SetStorage.cs rename to Src.GetRenamed/IronPython/Runtime/SetStorage.cs diff --git a/Src/IronPython/Runtime/SimpleNamespace.cs b/Src.GetRenamed/IronPython/Runtime/SimpleNamespace.cs similarity index 100% rename from Src/IronPython/Runtime/SimpleNamespace.cs rename to Src.GetRenamed/IronPython/Runtime/SimpleNamespace.cs diff --git a/Src/IronPython/Runtime/SiteLocalStorage.cs b/Src.GetRenamed/IronPython/Runtime/SiteLocalStorage.cs similarity index 100% rename from Src/IronPython/Runtime/SiteLocalStorage.cs rename to Src.GetRenamed/IronPython/Runtime/SiteLocalStorage.cs diff --git a/Src/IronPython/Runtime/Slice.cs b/Src.GetRenamed/IronPython/Runtime/Slice.cs similarity index 100% rename from Src/IronPython/Runtime/Slice.cs rename to Src.GetRenamed/IronPython/Runtime/Slice.cs diff --git a/Src/IronPython/Runtime/StringDictionaryStorage.cs b/Src.GetRenamed/IronPython/Runtime/StringDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/StringDictionaryStorage.cs rename to Src.GetRenamed/IronPython/Runtime/StringDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/StringFormatSpec.cs b/Src.GetRenamed/IronPython/Runtime/StringFormatSpec.cs similarity index 100% rename from Src/IronPython/Runtime/StringFormatSpec.cs rename to Src.GetRenamed/IronPython/Runtime/StringFormatSpec.cs diff --git a/Src/IronPython/Runtime/StringFormatter.cs b/Src.GetRenamed/IronPython/Runtime/StringFormatter.cs similarity index 100% rename from Src/IronPython/Runtime/StringFormatter.cs rename to Src.GetRenamed/IronPython/Runtime/StringFormatter.cs diff --git a/Src/IronPython/Runtime/Super.cs b/Src.GetRenamed/IronPython/Runtime/Super.cs similarity index 100% rename from Src/IronPython/Runtime/Super.cs rename to Src.GetRenamed/IronPython/Runtime/Super.cs diff --git a/Src/IronPython/Runtime/Symbols.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Symbols.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Symbols.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Symbols.Generated.cs diff --git a/Src/IronPython/Runtime/ThrowingErrorSink.cs b/Src.GetRenamed/IronPython/Runtime/ThrowingErrorSink.cs similarity index 100% rename from Src/IronPython/Runtime/ThrowingErrorSink.cs rename to Src.GetRenamed/IronPython/Runtime/ThrowingErrorSink.cs diff --git a/Src/IronPython/Runtime/TypecodeOps.cs b/Src.GetRenamed/IronPython/Runtime/TypecodeOps.cs similarity index 100% rename from Src/IronPython/Runtime/TypecodeOps.cs rename to Src.GetRenamed/IronPython/Runtime/TypecodeOps.cs diff --git a/Src/IronPython/Runtime/Types/BuiltinFunction.cs b/Src.GetRenamed/IronPython/Runtime/Types/BuiltinFunction.cs similarity index 100% rename from Src/IronPython/Runtime/Types/BuiltinFunction.cs rename to Src.GetRenamed/IronPython/Runtime/Types/BuiltinFunction.cs diff --git a/Src/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs b/Src.GetRenamed/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs similarity index 100% rename from Src/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs rename to Src.GetRenamed/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs diff --git a/Src/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs b/Src.GetRenamed/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs similarity index 100% rename from Src/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs rename to Src.GetRenamed/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs diff --git a/Src/IronPython/Runtime/Types/CachedNewTypeInfo.cs b/Src.GetRenamed/IronPython/Runtime/Types/CachedNewTypeInfo.cs similarity index 100% rename from Src/IronPython/Runtime/Types/CachedNewTypeInfo.cs rename to Src.GetRenamed/IronPython/Runtime/Types/CachedNewTypeInfo.cs diff --git a/Src/IronPython/Runtime/Types/ConstructorFunction.cs b/Src.GetRenamed/IronPython/Runtime/Types/ConstructorFunction.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ConstructorFunction.cs rename to Src.GetRenamed/IronPython/Runtime/Types/ConstructorFunction.cs diff --git a/Src/IronPython/Runtime/Types/CustomAttributeTracker.cs b/Src.GetRenamed/IronPython/Runtime/Types/CustomAttributeTracker.cs similarity index 100% rename from Src/IronPython/Runtime/Types/CustomAttributeTracker.cs rename to Src.GetRenamed/IronPython/Runtime/Types/CustomAttributeTracker.cs diff --git a/Src/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs b/Src.GetRenamed/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs similarity index 100% rename from Src/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs rename to Src.GetRenamed/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs diff --git a/Src/IronPython/Runtime/Types/DocBuilder.cs b/Src.GetRenamed/IronPython/Runtime/Types/DocBuilder.cs similarity index 100% rename from Src/IronPython/Runtime/Types/DocBuilder.cs rename to Src.GetRenamed/IronPython/Runtime/Types/DocBuilder.cs diff --git a/Src/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs b/Src.GetRenamed/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs rename to Src.GetRenamed/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs diff --git a/Src/IronPython/Runtime/Types/DynamicHelpers.cs b/Src.GetRenamed/IronPython/Runtime/Types/DynamicHelpers.cs similarity index 100% rename from Src/IronPython/Runtime/Types/DynamicHelpers.cs rename to Src.GetRenamed/IronPython/Runtime/Types/DynamicHelpers.cs diff --git a/Src/IronPython/Runtime/Types/EmptyType.cs b/Src.GetRenamed/IronPython/Runtime/Types/EmptyType.cs similarity index 100% rename from Src/IronPython/Runtime/Types/EmptyType.cs rename to Src.GetRenamed/IronPython/Runtime/Types/EmptyType.cs diff --git a/Src/IronPython/Runtime/Types/ExtensionPropertyInfo.cs b/Src.GetRenamed/IronPython/Runtime/Types/ExtensionPropertyInfo.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ExtensionPropertyInfo.cs rename to Src.GetRenamed/IronPython/Runtime/Types/ExtensionPropertyInfo.cs diff --git a/Src/IronPython/Runtime/Types/FunctionType.cs b/Src.GetRenamed/IronPython/Runtime/Types/FunctionType.cs similarity index 100% rename from Src/IronPython/Runtime/Types/FunctionType.cs rename to Src.GetRenamed/IronPython/Runtime/Types/FunctionType.cs diff --git a/Src/IronPython/Runtime/Types/IPythonObject.cs b/Src.GetRenamed/IronPython/Runtime/Types/IPythonObject.cs similarity index 100% rename from Src/IronPython/Runtime/Types/IPythonObject.cs rename to Src.GetRenamed/IronPython/Runtime/Types/IPythonObject.cs diff --git a/Src/IronPython/Runtime/Types/InstanceCreator.cs b/Src.GetRenamed/IronPython/Runtime/Types/InstanceCreator.cs similarity index 100% rename from Src/IronPython/Runtime/Types/InstanceCreator.cs rename to Src.GetRenamed/IronPython/Runtime/Types/InstanceCreator.cs diff --git a/Src/IronPython/Runtime/Types/MappingProxy.cs b/Src.GetRenamed/IronPython/Runtime/Types/MappingProxy.cs similarity index 100% rename from Src/IronPython/Runtime/Types/MappingProxy.cs rename to Src.GetRenamed/IronPython/Runtime/Types/MappingProxy.cs diff --git a/Src/IronPython/Runtime/Types/Mro.cs b/Src.GetRenamed/IronPython/Runtime/Types/Mro.cs similarity index 100% rename from Src/IronPython/Runtime/Types/Mro.cs rename to Src.GetRenamed/IronPython/Runtime/Types/Mro.cs diff --git a/Src/IronPython/Runtime/Types/NameConverter.cs b/Src.GetRenamed/IronPython/Runtime/Types/NameConverter.cs similarity index 100% rename from Src/IronPython/Runtime/Types/NameConverter.cs rename to Src.GetRenamed/IronPython/Runtime/Types/NameConverter.cs diff --git a/Src/IronPython/Runtime/Types/NewTypeInfo.cs b/Src.GetRenamed/IronPython/Runtime/Types/NewTypeInfo.cs similarity index 100% rename from Src/IronPython/Runtime/Types/NewTypeInfo.cs rename to Src.GetRenamed/IronPython/Runtime/Types/NewTypeInfo.cs diff --git a/Src/IronPython/Runtime/Types/NewTypeMaker.cs b/Src.GetRenamed/IronPython/Runtime/Types/NewTypeMaker.cs similarity index 100% rename from Src/IronPython/Runtime/Types/NewTypeMaker.cs rename to Src.GetRenamed/IronPython/Runtime/Types/NewTypeMaker.cs diff --git a/Src/IronPython/Runtime/Types/OperatorMapping.cs b/Src.GetRenamed/IronPython/Runtime/Types/OperatorMapping.cs similarity index 100% rename from Src/IronPython/Runtime/Types/OperatorMapping.cs rename to Src.GetRenamed/IronPython/Runtime/Types/OperatorMapping.cs diff --git a/Src/IronPython/Runtime/Types/ParameterInfoWrapper.cs b/Src.GetRenamed/IronPython/Runtime/Types/ParameterInfoWrapper.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ParameterInfoWrapper.cs rename to Src.GetRenamed/IronPython/Runtime/Types/ParameterInfoWrapper.cs diff --git a/Src/IronPython/Runtime/Types/PythonAssemblyOps.cs b/Src.GetRenamed/IronPython/Runtime/Types/PythonAssemblyOps.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonAssemblyOps.cs rename to Src.GetRenamed/IronPython/Runtime/Types/PythonAssemblyOps.cs diff --git a/Src/IronPython/Runtime/Types/PythonSiteCache.cs b/Src.GetRenamed/IronPython/Runtime/Types/PythonSiteCache.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonSiteCache.cs rename to Src.GetRenamed/IronPython/Runtime/Types/PythonSiteCache.cs diff --git a/Src/IronPython/Runtime/Types/PythonType.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Types/PythonType.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonType.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Types/PythonType.Generated.cs diff --git a/Src/IronPython/Runtime/Types/PythonType.cs b/Src.GetRenamed/IronPython/Runtime/Types/PythonType.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonType.cs rename to Src.GetRenamed/IronPython/Runtime/Types/PythonType.cs diff --git a/Src/IronPython/Runtime/Types/PythonTypeDataSlot.cs b/Src.GetRenamed/IronPython/Runtime/Types/PythonTypeDataSlot.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonTypeDataSlot.cs rename to Src.GetRenamed/IronPython/Runtime/Types/PythonTypeDataSlot.cs diff --git a/Src/IronPython/Runtime/Types/PythonTypeDictSlot.cs b/Src.GetRenamed/IronPython/Runtime/Types/PythonTypeDictSlot.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonTypeDictSlot.cs rename to Src.GetRenamed/IronPython/Runtime/Types/PythonTypeDictSlot.cs diff --git a/Src/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs diff --git a/Src/IronPython/Runtime/Types/PythonTypeInfo.cs b/Src.GetRenamed/IronPython/Runtime/Types/PythonTypeInfo.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonTypeInfo.cs rename to Src.GetRenamed/IronPython/Runtime/Types/PythonTypeInfo.cs diff --git a/Src/IronPython/Runtime/Types/PythonTypeSlot.cs b/Src.GetRenamed/IronPython/Runtime/Types/PythonTypeSlot.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonTypeSlot.cs rename to Src.GetRenamed/IronPython/Runtime/Types/PythonTypeSlot.cs diff --git a/Src/IronPython/Runtime/Types/PythonTypeTypeSlot.cs b/Src.GetRenamed/IronPython/Runtime/Types/PythonTypeTypeSlot.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonTypeTypeSlot.cs rename to Src.GetRenamed/IronPython/Runtime/Types/PythonTypeTypeSlot.cs diff --git a/Src/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs b/Src.GetRenamed/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs rename to Src.GetRenamed/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs diff --git a/Src/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs b/Src.GetRenamed/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs similarity index 100% rename from Src/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs rename to Src.GetRenamed/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs diff --git a/Src/IronPython/Runtime/Types/ReflectedEvent.cs b/Src.GetRenamed/IronPython/Runtime/Types/ReflectedEvent.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ReflectedEvent.cs rename to Src.GetRenamed/IronPython/Runtime/Types/ReflectedEvent.cs diff --git a/Src/IronPython/Runtime/Types/ReflectedExtensionProperty.cs b/Src.GetRenamed/IronPython/Runtime/Types/ReflectedExtensionProperty.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ReflectedExtensionProperty.cs rename to Src.GetRenamed/IronPython/Runtime/Types/ReflectedExtensionProperty.cs diff --git a/Src/IronPython/Runtime/Types/ReflectedField.cs b/Src.GetRenamed/IronPython/Runtime/Types/ReflectedField.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ReflectedField.cs rename to Src.GetRenamed/IronPython/Runtime/Types/ReflectedField.cs diff --git a/Src/IronPython/Runtime/Types/ReflectedGetterSetter.cs b/Src.GetRenamed/IronPython/Runtime/Types/ReflectedGetterSetter.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ReflectedGetterSetter.cs rename to Src.GetRenamed/IronPython/Runtime/Types/ReflectedGetterSetter.cs diff --git a/Src/IronPython/Runtime/Types/ReflectedIndexer.cs b/Src.GetRenamed/IronPython/Runtime/Types/ReflectedIndexer.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ReflectedIndexer.cs rename to Src.GetRenamed/IronPython/Runtime/Types/ReflectedIndexer.cs diff --git a/Src/IronPython/Runtime/Types/ReflectedProperty.cs b/Src.GetRenamed/IronPython/Runtime/Types/ReflectedProperty.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ReflectedProperty.cs rename to Src.GetRenamed/IronPython/Runtime/Types/ReflectedProperty.cs diff --git a/Src/IronPython/Runtime/Types/ReflectedSlotProperty.cs b/Src.GetRenamed/IronPython/Runtime/Types/ReflectedSlotProperty.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ReflectedSlotProperty.cs rename to Src.GetRenamed/IronPython/Runtime/Types/ReflectedSlotProperty.cs diff --git a/Src/IronPython/Runtime/Types/ResolvedMember.cs b/Src.GetRenamed/IronPython/Runtime/Types/ResolvedMember.cs similarity index 100% rename from Src/IronPython/Runtime/Types/ResolvedMember.cs rename to Src.GetRenamed/IronPython/Runtime/Types/ResolvedMember.cs diff --git a/Src/IronPython/Runtime/Types/SlotFieldAttribute.cs b/Src.GetRenamed/IronPython/Runtime/Types/SlotFieldAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/Types/SlotFieldAttribute.cs rename to Src.GetRenamed/IronPython/Runtime/Types/SlotFieldAttribute.cs diff --git a/Src/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs b/Src.GetRenamed/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs similarity index 100% rename from Src/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs rename to Src.GetRenamed/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs diff --git a/Src/IronPython/Runtime/Types/TypeCache.Generated.cs b/Src.GetRenamed/IronPython/Runtime/Types/TypeCache.Generated.cs similarity index 100% rename from Src/IronPython/Runtime/Types/TypeCache.Generated.cs rename to Src.GetRenamed/IronPython/Runtime/Types/TypeCache.Generated.cs diff --git a/Src/IronPython/Runtime/UnboundNameException.cs b/Src.GetRenamed/IronPython/Runtime/UnboundNameException.cs similarity index 100% rename from Src/IronPython/Runtime/UnboundNameException.cs rename to Src.GetRenamed/IronPython/Runtime/UnboundNameException.cs diff --git a/Src/IronPython/Runtime/WeakRef.cs b/Src.GetRenamed/IronPython/Runtime/WeakRef.cs similarity index 100% rename from Src/IronPython/Runtime/WeakRef.cs rename to Src.GetRenamed/IronPython/Runtime/WeakRef.cs diff --git a/Src/IronPython/Runtime/WrapperDescriptorAttribute.cs b/Src.GetRenamed/IronPython/Runtime/WrapperDescriptorAttribute.cs similarity index 100% rename from Src/IronPython/Runtime/WrapperDescriptorAttribute.cs rename to Src.GetRenamed/IronPython/Runtime/WrapperDescriptorAttribute.cs diff --git a/Src/IronPython/Runtime/WrapperDictionary.cs b/Src.GetRenamed/IronPython/Runtime/WrapperDictionary.cs similarity index 100% rename from Src/IronPython/Runtime/WrapperDictionary.cs rename to Src.GetRenamed/IronPython/Runtime/WrapperDictionary.cs diff --git a/Src/IronPython/Runtime/Zip.cs b/Src.GetRenamed/IronPython/Runtime/Zip.cs similarity index 100% rename from Src/IronPython/Runtime/Zip.cs rename to Src.GetRenamed/IronPython/Runtime/Zip.cs diff --git a/Src/IronPython/SerializationStubs.cs b/Src.GetRenamed/IronPython/SerializationStubs.cs similarity index 100% rename from Src/IronPython/SerializationStubs.cs rename to Src.GetRenamed/IronPython/SerializationStubs.cs diff --git a/Src/IronPython/StringExtensions.cs b/Src.GetRenamed/IronPython/StringExtensions.cs similarity index 100% rename from Src/IronPython/StringExtensions.cs rename to Src.GetRenamed/IronPython/StringExtensions.cs diff --git a/Src/IronPython/SystemRuntimeVersioning.cs b/Src.GetRenamed/IronPython/SystemRuntimeVersioning.cs similarity index 100% rename from Src/IronPython/SystemRuntimeVersioning.cs rename to Src.GetRenamed/IronPython/SystemRuntimeVersioning.cs diff --git a/Src/IronPython/policy.IronPython.config b/Src.GetRenamed/IronPython/policy.IronPython.config similarity index 100% rename from Src/IronPython/policy.IronPython.config rename to Src.GetRenamed/IronPython/policy.IronPython.config diff --git a/Src/Modules/IronPython.Modules.csproj b/Src.GetRenamed/Modules/IronPython.Modules.csproj similarity index 100% rename from Src/Modules/IronPython.Modules.csproj rename to Src.GetRenamed/Modules/IronPython.Modules.csproj diff --git a/Src/Modules/IterTools.cs b/Src.GetRenamed/Modules/IterTools.cs similarity index 100% rename from Src/Modules/IterTools.cs rename to Src.GetRenamed/Modules/IterTools.cs diff --git a/Src/Modules/ModuleOps.cs b/Src.GetRenamed/Modules/ModuleOps.cs similarity index 100% rename from Src/Modules/ModuleOps.cs rename to Src.GetRenamed/Modules/ModuleOps.cs diff --git a/Src/Modules/NtSignalState.cs b/Src.GetRenamed/Modules/NtSignalState.cs similarity index 100% rename from Src/Modules/NtSignalState.cs rename to Src.GetRenamed/Modules/NtSignalState.cs diff --git a/Src/Modules/Properties/AssemblyInfo.cs b/Src.GetRenamed/Modules/Properties/AssemblyInfo.cs similarity index 100% rename from Src/Modules/Properties/AssemblyInfo.cs rename to Src.GetRenamed/Modules/Properties/AssemblyInfo.cs diff --git a/Src/Modules/ResourceMetaPathImporter.cs b/Src.GetRenamed/Modules/ResourceMetaPathImporter.cs similarity index 100% rename from Src/Modules/ResourceMetaPathImporter.cs rename to Src.GetRenamed/Modules/ResourceMetaPathImporter.cs diff --git a/Src/Modules/SimpleSignalState.cs b/Src.GetRenamed/Modules/SimpleSignalState.cs similarity index 100% rename from Src/Modules/SimpleSignalState.cs rename to Src.GetRenamed/Modules/SimpleSignalState.cs diff --git a/Src/Modules/_bisect.cs b/Src.GetRenamed/Modules/_bisect.cs similarity index 100% rename from Src/Modules/_bisect.cs rename to Src.GetRenamed/Modules/_bisect.cs diff --git a/Src/Modules/_codecs.cs b/Src.GetRenamed/Modules/_codecs.cs similarity index 100% rename from Src/Modules/_codecs.cs rename to Src.GetRenamed/Modules/_codecs.cs diff --git a/Src/Modules/_codecs_cn.cs b/Src.GetRenamed/Modules/_codecs_cn.cs similarity index 100% rename from Src/Modules/_codecs_cn.cs rename to Src.GetRenamed/Modules/_codecs_cn.cs diff --git a/Src/Modules/_collections.cs b/Src.GetRenamed/Modules/_collections.cs similarity index 100% rename from Src/Modules/_collections.cs rename to Src.GetRenamed/Modules/_collections.cs diff --git a/Src/Modules/_csv.cs b/Src.GetRenamed/Modules/_csv.cs similarity index 100% rename from Src/Modules/_csv.cs rename to Src.GetRenamed/Modules/_csv.cs diff --git a/Src/Modules/_ctypes/Array.cs b/Src.GetRenamed/Modules/_ctypes/Array.cs similarity index 100% rename from Src/Modules/_ctypes/Array.cs rename to Src.GetRenamed/Modules/_ctypes/Array.cs diff --git a/Src/Modules/_ctypes/ArrayType.cs b/Src.GetRenamed/Modules/_ctypes/ArrayType.cs similarity index 100% rename from Src/Modules/_ctypes/ArrayType.cs rename to Src.GetRenamed/Modules/_ctypes/ArrayType.cs diff --git a/Src/Modules/_ctypes/CData.cs b/Src.GetRenamed/Modules/_ctypes/CData.cs similarity index 100% rename from Src/Modules/_ctypes/CData.cs rename to Src.GetRenamed/Modules/_ctypes/CData.cs diff --git a/Src/Modules/_ctypes/CFuncPtr.cs b/Src.GetRenamed/Modules/_ctypes/CFuncPtr.cs similarity index 100% rename from Src/Modules/_ctypes/CFuncPtr.cs rename to Src.GetRenamed/Modules/_ctypes/CFuncPtr.cs diff --git a/Src/Modules/_ctypes/CFuncPtrType.cs b/Src.GetRenamed/Modules/_ctypes/CFuncPtrType.cs similarity index 100% rename from Src/Modules/_ctypes/CFuncPtrType.cs rename to Src.GetRenamed/Modules/_ctypes/CFuncPtrType.cs diff --git a/Src/Modules/_ctypes/Extensions.cs b/Src.GetRenamed/Modules/_ctypes/Extensions.cs similarity index 100% rename from Src/Modules/_ctypes/Extensions.cs rename to Src.GetRenamed/Modules/_ctypes/Extensions.cs diff --git a/Src/Modules/_ctypes/Field.cs b/Src.GetRenamed/Modules/_ctypes/Field.cs similarity index 100% rename from Src/Modules/_ctypes/Field.cs rename to Src.GetRenamed/Modules/_ctypes/Field.cs diff --git a/Src/Modules/_ctypes/INativeType.cs b/Src.GetRenamed/Modules/_ctypes/INativeType.cs similarity index 100% rename from Src/Modules/_ctypes/INativeType.cs rename to Src.GetRenamed/Modules/_ctypes/INativeType.cs diff --git a/Src/Modules/_ctypes/LocalOrArg.cs b/Src.GetRenamed/Modules/_ctypes/LocalOrArg.cs similarity index 100% rename from Src/Modules/_ctypes/LocalOrArg.cs rename to Src.GetRenamed/Modules/_ctypes/LocalOrArg.cs diff --git a/Src/Modules/_ctypes/MarshalCleanup.cs b/Src.GetRenamed/Modules/_ctypes/MarshalCleanup.cs similarity index 100% rename from Src/Modules/_ctypes/MarshalCleanup.cs rename to Src.GetRenamed/Modules/_ctypes/MarshalCleanup.cs diff --git a/Src/Modules/_ctypes/MemoryHolder.cs b/Src.GetRenamed/Modules/_ctypes/MemoryHolder.cs similarity index 100% rename from Src/Modules/_ctypes/MemoryHolder.cs rename to Src.GetRenamed/Modules/_ctypes/MemoryHolder.cs diff --git a/Src/Modules/_ctypes/NativeArgument.cs b/Src.GetRenamed/Modules/_ctypes/NativeArgument.cs similarity index 100% rename from Src/Modules/_ctypes/NativeArgument.cs rename to Src.GetRenamed/Modules/_ctypes/NativeArgument.cs diff --git a/Src/Modules/_ctypes/NativeFunctions.cs b/Src.GetRenamed/Modules/_ctypes/NativeFunctions.cs similarity index 100% rename from Src/Modules/_ctypes/NativeFunctions.cs rename to Src.GetRenamed/Modules/_ctypes/NativeFunctions.cs diff --git a/Src/Modules/_ctypes/Pointer.cs b/Src.GetRenamed/Modules/_ctypes/Pointer.cs similarity index 100% rename from Src/Modules/_ctypes/Pointer.cs rename to Src.GetRenamed/Modules/_ctypes/Pointer.cs diff --git a/Src/Modules/_ctypes/PointerType.cs b/Src.GetRenamed/Modules/_ctypes/PointerType.cs similarity index 100% rename from Src/Modules/_ctypes/PointerType.cs rename to Src.GetRenamed/Modules/_ctypes/PointerType.cs diff --git a/Src/Modules/_ctypes/SimpleCData.cs b/Src.GetRenamed/Modules/_ctypes/SimpleCData.cs similarity index 100% rename from Src/Modules/_ctypes/SimpleCData.cs rename to Src.GetRenamed/Modules/_ctypes/SimpleCData.cs diff --git a/Src/Modules/_ctypes/SimpleType.cs b/Src.GetRenamed/Modules/_ctypes/SimpleType.cs similarity index 100% rename from Src/Modules/_ctypes/SimpleType.cs rename to Src.GetRenamed/Modules/_ctypes/SimpleType.cs diff --git a/Src/Modules/_ctypes/SimpleTypeKind.cs b/Src.GetRenamed/Modules/_ctypes/SimpleTypeKind.cs similarity index 100% rename from Src/Modules/_ctypes/SimpleTypeKind.cs rename to Src.GetRenamed/Modules/_ctypes/SimpleTypeKind.cs diff --git a/Src/Modules/_ctypes/StructType.cs b/Src.GetRenamed/Modules/_ctypes/StructType.cs similarity index 100% rename from Src/Modules/_ctypes/StructType.cs rename to Src.GetRenamed/Modules/_ctypes/StructType.cs diff --git a/Src/Modules/_ctypes/Structure.cs b/Src.GetRenamed/Modules/_ctypes/Structure.cs similarity index 100% rename from Src/Modules/_ctypes/Structure.cs rename to Src.GetRenamed/Modules/_ctypes/Structure.cs diff --git a/Src/Modules/_ctypes/Union.cs b/Src.GetRenamed/Modules/_ctypes/Union.cs similarity index 100% rename from Src/Modules/_ctypes/Union.cs rename to Src.GetRenamed/Modules/_ctypes/Union.cs diff --git a/Src/Modules/_ctypes/UnionType.cs b/Src.GetRenamed/Modules/_ctypes/UnionType.cs similarity index 100% rename from Src/Modules/_ctypes/UnionType.cs rename to Src.GetRenamed/Modules/_ctypes/UnionType.cs diff --git a/Src/Modules/_ctypes/_ctypes.cs b/Src.GetRenamed/Modules/_ctypes/_ctypes.cs similarity index 100% rename from Src/Modules/_ctypes/_ctypes.cs rename to Src.GetRenamed/Modules/_ctypes/_ctypes.cs diff --git a/Src/Modules/_ctypes_test.cs b/Src.GetRenamed/Modules/_ctypes_test.cs similarity index 100% rename from Src/Modules/_ctypes_test.cs rename to Src.GetRenamed/Modules/_ctypes_test.cs diff --git a/Src/Modules/_datetime.cs b/Src.GetRenamed/Modules/_datetime.cs similarity index 100% rename from Src/Modules/_datetime.cs rename to Src.GetRenamed/Modules/_datetime.cs diff --git a/Src/Modules/_functools.cs b/Src.GetRenamed/Modules/_functools.cs similarity index 100% rename from Src/Modules/_functools.cs rename to Src.GetRenamed/Modules/_functools.cs diff --git a/Src/Modules/_heapq.cs b/Src.GetRenamed/Modules/_heapq.cs similarity index 100% rename from Src/Modules/_heapq.cs rename to Src.GetRenamed/Modules/_heapq.cs diff --git a/Src/Modules/_multibytecodec.cs b/Src.GetRenamed/Modules/_multibytecodec.cs similarity index 100% rename from Src/Modules/_multibytecodec.cs rename to Src.GetRenamed/Modules/_multibytecodec.cs diff --git a/Src/Modules/_multiprocessing.cs b/Src.GetRenamed/Modules/_multiprocessing.cs similarity index 100% rename from Src/Modules/_multiprocessing.cs rename to Src.GetRenamed/Modules/_multiprocessing.cs diff --git a/Src/Modules/_opcode.cs b/Src.GetRenamed/Modules/_opcode.cs similarity index 100% rename from Src/Modules/_opcode.cs rename to Src.GetRenamed/Modules/_opcode.cs diff --git a/Src/Modules/_operator.cs b/Src.GetRenamed/Modules/_operator.cs similarity index 100% rename from Src/Modules/_operator.cs rename to Src.GetRenamed/Modules/_operator.cs diff --git a/Src/Modules/_overlapped.cs b/Src.GetRenamed/Modules/_overlapped.cs similarity index 100% rename from Src/Modules/_overlapped.cs rename to Src.GetRenamed/Modules/_overlapped.cs diff --git a/Src/Modules/_pickle.cs b/Src.GetRenamed/Modules/_pickle.cs similarity index 100% rename from Src/Modules/_pickle.cs rename to Src.GetRenamed/Modules/_pickle.cs diff --git a/Src/Modules/_posixsubprocess.cs b/Src.GetRenamed/Modules/_posixsubprocess.cs similarity index 100% rename from Src/Modules/_posixsubprocess.cs rename to Src.GetRenamed/Modules/_posixsubprocess.cs diff --git a/Src/Modules/_random.RandomGen.cs b/Src.GetRenamed/Modules/_random.RandomGen.cs similarity index 100% rename from Src/Modules/_random.RandomGen.cs rename to Src.GetRenamed/Modules/_random.RandomGen.cs diff --git a/Src/Modules/_random.cs b/Src.GetRenamed/Modules/_random.cs similarity index 100% rename from Src/Modules/_random.cs rename to Src.GetRenamed/Modules/_random.cs diff --git a/Src/Modules/_socket.cs b/Src.GetRenamed/Modules/_socket.cs similarity index 100% rename from Src/Modules/_socket.cs rename to Src.GetRenamed/Modules/_socket.cs diff --git a/Src/Modules/_sre.cs b/Src.GetRenamed/Modules/_sre.cs similarity index 100% rename from Src/Modules/_sre.cs rename to Src.GetRenamed/Modules/_sre.cs diff --git a/Src/Modules/_ssl.cs b/Src.GetRenamed/Modules/_ssl.cs similarity index 100% rename from Src/Modules/_ssl.cs rename to Src.GetRenamed/Modules/_ssl.cs diff --git a/Src/Modules/_string.cs b/Src.GetRenamed/Modules/_string.cs similarity index 100% rename from Src/Modules/_string.cs rename to Src.GetRenamed/Modules/_string.cs diff --git a/Src/Modules/_struct.cs b/Src.GetRenamed/Modules/_struct.cs similarity index 100% rename from Src/Modules/_struct.cs rename to Src.GetRenamed/Modules/_struct.cs diff --git a/Src/Modules/_sysconfigdata.cs b/Src.GetRenamed/Modules/_sysconfigdata.cs similarity index 100% rename from Src/Modules/_sysconfigdata.cs rename to Src.GetRenamed/Modules/_sysconfigdata.cs diff --git a/Src/Modules/_thread.cs b/Src.GetRenamed/Modules/_thread.cs similarity index 100% rename from Src/Modules/_thread.cs rename to Src.GetRenamed/Modules/_thread.cs diff --git a/Src/Modules/_warnings.cs b/Src.GetRenamed/Modules/_warnings.cs similarity index 100% rename from Src/Modules/_warnings.cs rename to Src.GetRenamed/Modules/_warnings.cs diff --git a/Src/Modules/_weakref.Generated.cs b/Src.GetRenamed/Modules/_weakref.Generated.cs similarity index 100% rename from Src/Modules/_weakref.Generated.cs rename to Src.GetRenamed/Modules/_weakref.Generated.cs diff --git a/Src/Modules/_weakref.cs b/Src.GetRenamed/Modules/_weakref.cs similarity index 100% rename from Src/Modules/_weakref.cs rename to Src.GetRenamed/Modules/_weakref.cs diff --git a/Src/Modules/_winapi.cs b/Src.GetRenamed/Modules/_winapi.cs similarity index 100% rename from Src/Modules/_winapi.cs rename to Src.GetRenamed/Modules/_winapi.cs diff --git a/Src/Modules/array.cs b/Src.GetRenamed/Modules/array.cs similarity index 100% rename from Src/Modules/array.cs rename to Src.GetRenamed/Modules/array.cs diff --git a/Src/Modules/atexit.cs b/Src.GetRenamed/Modules/atexit.cs similarity index 100% rename from Src/Modules/atexit.cs rename to Src.GetRenamed/Modules/atexit.cs diff --git a/Src/Modules/audioop.cs b/Src.GetRenamed/Modules/audioop.cs similarity index 100% rename from Src/Modules/audioop.cs rename to Src.GetRenamed/Modules/audioop.cs diff --git a/Src/Modules/binascii.cs b/Src.GetRenamed/Modules/binascii.cs similarity index 100% rename from Src/Modules/binascii.cs rename to Src.GetRenamed/Modules/binascii.cs diff --git a/Src/Modules/bz2/BZ2Compressor.cs b/Src.GetRenamed/Modules/bz2/BZ2Compressor.cs similarity index 100% rename from Src/Modules/bz2/BZ2Compressor.cs rename to Src.GetRenamed/Modules/bz2/BZ2Compressor.cs diff --git a/Src/Modules/bz2/BZ2Decompressor.cs b/Src.GetRenamed/Modules/bz2/BZ2Decompressor.cs similarity index 100% rename from Src/Modules/bz2/BZ2Decompressor.cs rename to Src.GetRenamed/Modules/bz2/BZ2Decompressor.cs diff --git a/Src/Modules/bz2/BZ2Module.cs b/Src.GetRenamed/Modules/bz2/BZ2Module.cs similarity index 100% rename from Src/Modules/bz2/BZ2Module.cs rename to Src.GetRenamed/Modules/bz2/BZ2Module.cs diff --git a/Src/Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs b/Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs similarity index 100% rename from Src/Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs rename to Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs diff --git a/Src/Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs b/Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs similarity index 100% rename from Src/Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs rename to Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs diff --git a/Src/Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs b/Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs similarity index 100% rename from Src/Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs rename to Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs diff --git a/Src/Modules/bz2/dotnetzip/BZip2/BitWriter.cs b/Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/BitWriter.cs similarity index 100% rename from Src/Modules/bz2/dotnetzip/BZip2/BitWriter.cs rename to Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/BitWriter.cs diff --git a/Src/Modules/bz2/dotnetzip/BZip2/CRC32.cs b/Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/CRC32.cs similarity index 100% rename from Src/Modules/bz2/dotnetzip/BZip2/CRC32.cs rename to Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/CRC32.cs diff --git a/Src/Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs b/Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs similarity index 100% rename from Src/Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs rename to Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs diff --git a/Src/Modules/bz2/dotnetzip/BZip2/Rand.cs b/Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/Rand.cs similarity index 100% rename from Src/Modules/bz2/dotnetzip/BZip2/Rand.cs rename to Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/Rand.cs diff --git a/Src/Modules/bz2/dotnetzip/source.txt b/Src.GetRenamed/Modules/bz2/dotnetzip/source.txt similarity index 100% rename from Src/Modules/bz2/dotnetzip/source.txt rename to Src.GetRenamed/Modules/bz2/dotnetzip/source.txt diff --git a/Src/Modules/cmath.cs b/Src.GetRenamed/Modules/cmath.cs similarity index 100% rename from Src/Modules/cmath.cs rename to Src.GetRenamed/Modules/cmath.cs diff --git a/Src/Modules/errno.cs b/Src.GetRenamed/Modules/errno.cs similarity index 100% rename from Src/Modules/errno.cs rename to Src.GetRenamed/Modules/errno.cs diff --git a/Src/Modules/faulthandler.cs b/Src.GetRenamed/Modules/faulthandler.cs similarity index 100% rename from Src/Modules/faulthandler.cs rename to Src.GetRenamed/Modules/faulthandler.cs diff --git a/Src/Modules/fcntl.cs b/Src.GetRenamed/Modules/fcntl.cs similarity index 100% rename from Src/Modules/fcntl.cs rename to Src.GetRenamed/Modules/fcntl.cs diff --git a/Src/Modules/gc.cs b/Src.GetRenamed/Modules/gc.cs similarity index 100% rename from Src/Modules/gc.cs rename to Src.GetRenamed/Modules/gc.cs diff --git a/Src/Modules/grp.cs b/Src.GetRenamed/Modules/grp.cs similarity index 100% rename from Src/Modules/grp.cs rename to Src.GetRenamed/Modules/grp.cs diff --git a/Src/Modules/hashlib/MD5CryptoServiceProvider.cs b/Src.GetRenamed/Modules/hashlib/MD5CryptoServiceProvider.cs similarity index 100% rename from Src/Modules/hashlib/MD5CryptoServiceProvider.cs rename to Src.GetRenamed/Modules/hashlib/MD5CryptoServiceProvider.cs diff --git a/Src/Modules/hashlib/SHA1CryptoServiceProvider.cs b/Src.GetRenamed/Modules/hashlib/SHA1CryptoServiceProvider.cs similarity index 100% rename from Src/Modules/hashlib/SHA1CryptoServiceProvider.cs rename to Src.GetRenamed/Modules/hashlib/SHA1CryptoServiceProvider.cs diff --git a/Src/Modules/hashlib/SHA224.cs b/Src.GetRenamed/Modules/hashlib/SHA224.cs similarity index 100% rename from Src/Modules/hashlib/SHA224.cs rename to Src.GetRenamed/Modules/hashlib/SHA224.cs diff --git a/Src/Modules/hashlib/SHA224Managed.cs b/Src.GetRenamed/Modules/hashlib/SHA224Managed.cs similarity index 100% rename from Src/Modules/hashlib/SHA224Managed.cs rename to Src.GetRenamed/Modules/hashlib/SHA224Managed.cs diff --git a/Src/Modules/hashlib/SHA256Managed.cs b/Src.GetRenamed/Modules/hashlib/SHA256Managed.cs similarity index 100% rename from Src/Modules/hashlib/SHA256Managed.cs rename to Src.GetRenamed/Modules/hashlib/SHA256Managed.cs diff --git a/Src/Modules/hashlib/SHA384Managed.cs b/Src.GetRenamed/Modules/hashlib/SHA384Managed.cs similarity index 100% rename from Src/Modules/hashlib/SHA384Managed.cs rename to Src.GetRenamed/Modules/hashlib/SHA384Managed.cs diff --git a/Src/Modules/hashlib/SHA512Managed.cs b/Src.GetRenamed/Modules/hashlib/SHA512Managed.cs similarity index 100% rename from Src/Modules/hashlib/SHA512Managed.cs rename to Src.GetRenamed/Modules/hashlib/SHA512Managed.cs diff --git a/Src/Modules/hashlib/SHAConstants.cs b/Src.GetRenamed/Modules/hashlib/SHAConstants.cs similarity index 100% rename from Src/Modules/hashlib/SHAConstants.cs rename to Src.GetRenamed/Modules/hashlib/SHAConstants.cs diff --git a/Src/Modules/hashlib/_hashlib.cs b/Src.GetRenamed/Modules/hashlib/_hashlib.cs similarity index 100% rename from Src/Modules/hashlib/_hashlib.cs rename to Src.GetRenamed/Modules/hashlib/_hashlib.cs diff --git a/Src/Modules/hashlib/_md5.cs b/Src.GetRenamed/Modules/hashlib/_md5.cs similarity index 100% rename from Src/Modules/hashlib/_md5.cs rename to Src.GetRenamed/Modules/hashlib/_md5.cs diff --git a/Src/Modules/hashlib/_sha1.cs b/Src.GetRenamed/Modules/hashlib/_sha1.cs similarity index 100% rename from Src/Modules/hashlib/_sha1.cs rename to Src.GetRenamed/Modules/hashlib/_sha1.cs diff --git a/Src/Modules/hashlib/_sha256.cs b/Src.GetRenamed/Modules/hashlib/_sha256.cs similarity index 100% rename from Src/Modules/hashlib/_sha256.cs rename to Src.GetRenamed/Modules/hashlib/_sha256.cs diff --git a/Src/Modules/hashlib/_sha512.cs b/Src.GetRenamed/Modules/hashlib/_sha512.cs similarity index 100% rename from Src/Modules/hashlib/_sha512.cs rename to Src.GetRenamed/Modules/hashlib/_sha512.cs diff --git a/Src/Modules/marshal.cs b/Src.GetRenamed/Modules/marshal.cs similarity index 100% rename from Src/Modules/marshal.cs rename to Src.GetRenamed/Modules/marshal.cs diff --git a/Src/Modules/math.Generated.cs b/Src.GetRenamed/Modules/math.Generated.cs similarity index 100% rename from Src/Modules/math.Generated.cs rename to Src.GetRenamed/Modules/math.Generated.cs diff --git a/Src/Modules/math.cs b/Src.GetRenamed/Modules/math.cs similarity index 100% rename from Src/Modules/math.cs rename to Src.GetRenamed/Modules/math.cs diff --git a/Src/Modules/mmap.cs b/Src.GetRenamed/Modules/mmap.cs similarity index 100% rename from Src/Modules/mmap.cs rename to Src.GetRenamed/Modules/mmap.cs diff --git a/Src/Modules/msvcrt.cs b/Src.GetRenamed/Modules/msvcrt.cs similarity index 100% rename from Src/Modules/msvcrt.cs rename to Src.GetRenamed/Modules/msvcrt.cs diff --git a/Src/Modules/nt.cs b/Src.GetRenamed/Modules/nt.cs similarity index 100% rename from Src/Modules/nt.cs rename to Src.GetRenamed/Modules/nt.cs diff --git a/Src/Modules/policy.IronPython.Modules.config b/Src.GetRenamed/Modules/policy.IronPython.Modules.config similarity index 100% rename from Src/Modules/policy.IronPython.Modules.config rename to Src.GetRenamed/Modules/policy.IronPython.Modules.config diff --git a/Src/Modules/pwd.cs b/Src.GetRenamed/Modules/pwd.cs similarity index 100% rename from Src/Modules/pwd.cs rename to Src.GetRenamed/Modules/pwd.cs diff --git a/Src/Modules/pyexpat.cs b/Src.GetRenamed/Modules/pyexpat.cs similarity index 100% rename from Src/Modules/pyexpat.cs rename to Src.GetRenamed/Modules/pyexpat.cs diff --git a/Src/Modules/re.cs b/Src.GetRenamed/Modules/re.cs similarity index 100% rename from Src/Modules/re.cs rename to Src.GetRenamed/Modules/re.cs diff --git a/Src/Modules/resource.cs b/Src.GetRenamed/Modules/resource.cs similarity index 100% rename from Src/Modules/resource.cs rename to Src.GetRenamed/Modules/resource.cs diff --git a/Src/Modules/select.cs b/Src.GetRenamed/Modules/select.cs similarity index 100% rename from Src/Modules/select.cs rename to Src.GetRenamed/Modules/select.cs diff --git a/Src/Modules/signal.cs b/Src.GetRenamed/Modules/signal.cs similarity index 100% rename from Src/Modules/signal.cs rename to Src.GetRenamed/Modules/signal.cs diff --git a/Src/Modules/spwd.cs b/Src.GetRenamed/Modules/spwd.cs similarity index 100% rename from Src/Modules/spwd.cs rename to Src.GetRenamed/Modules/spwd.cs diff --git a/Src/Modules/time.cs b/Src.GetRenamed/Modules/time.cs similarity index 100% rename from Src/Modules/time.cs rename to Src.GetRenamed/Modules/time.cs diff --git a/Src/Modules/winreg.cs b/Src.GetRenamed/Modules/winreg.cs similarity index 100% rename from Src/Modules/winreg.cs rename to Src.GetRenamed/Modules/winreg.cs diff --git a/Src/Modules/winsound.cs b/Src.GetRenamed/Modules/winsound.cs similarity index 100% rename from Src/Modules/winsound.cs rename to Src.GetRenamed/Modules/winsound.cs diff --git a/Src/Modules/xxsubtype.cs b/Src.GetRenamed/Modules/xxsubtype.cs similarity index 100% rename from Src/Modules/xxsubtype.cs rename to Src.GetRenamed/Modules/xxsubtype.cs diff --git a/Src/Modules/zipimport.cs b/Src.GetRenamed/Modules/zipimport.cs similarity index 100% rename from Src/Modules/zipimport.cs rename to Src.GetRenamed/Modules/zipimport.cs diff --git a/Src/Modules/zlib/Compress.cs b/Src.GetRenamed/Modules/zlib/Compress.cs similarity index 100% rename from Src/Modules/zlib/Compress.cs rename to Src.GetRenamed/Modules/zlib/Compress.cs diff --git a/Src/Modules/zlib/Decompress.cs b/Src.GetRenamed/Modules/zlib/Decompress.cs similarity index 100% rename from Src/Modules/zlib/Decompress.cs rename to Src.GetRenamed/Modules/zlib/Decompress.cs diff --git a/Src/Modules/zlib/ZlibModule.cs b/Src.GetRenamed/Modules/zlib/ZlibModule.cs similarity index 100% rename from Src/Modules/zlib/ZlibModule.cs rename to Src.GetRenamed/Modules/zlib/ZlibModule.cs diff --git a/Src/Modules/zlib/zlib.net/Adler32.cs b/Src.GetRenamed/Modules/zlib/zlib.net/Adler32.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/Adler32.cs rename to Src.GetRenamed/Modules/zlib/zlib.net/Adler32.cs diff --git a/Src/Modules/zlib/zlib.net/Deflate.cs b/Src.GetRenamed/Modules/zlib/zlib.net/Deflate.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/Deflate.cs rename to Src.GetRenamed/Modules/zlib/zlib.net/Deflate.cs diff --git a/Src/Modules/zlib/zlib.net/InfBlocks.cs b/Src.GetRenamed/Modules/zlib/zlib.net/InfBlocks.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/InfBlocks.cs rename to Src.GetRenamed/Modules/zlib/zlib.net/InfBlocks.cs diff --git a/Src/Modules/zlib/zlib.net/InfCodes.cs b/Src.GetRenamed/Modules/zlib/zlib.net/InfCodes.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/InfCodes.cs rename to Src.GetRenamed/Modules/zlib/zlib.net/InfCodes.cs diff --git a/Src/Modules/zlib/zlib.net/InfTree.cs b/Src.GetRenamed/Modules/zlib/zlib.net/InfTree.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/InfTree.cs rename to Src.GetRenamed/Modules/zlib/zlib.net/InfTree.cs diff --git a/Src/Modules/zlib/zlib.net/Inflate.cs b/Src.GetRenamed/Modules/zlib/zlib.net/Inflate.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/Inflate.cs rename to Src.GetRenamed/Modules/zlib/zlib.net/Inflate.cs diff --git a/Src/Modules/zlib/zlib.net/StaticTree.cs b/Src.GetRenamed/Modules/zlib/zlib.net/StaticTree.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/StaticTree.cs rename to Src.GetRenamed/Modules/zlib/zlib.net/StaticTree.cs diff --git a/Src/Modules/zlib/zlib.net/Tree.cs b/Src.GetRenamed/Modules/zlib/zlib.net/Tree.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/Tree.cs rename to Src.GetRenamed/Modules/zlib/zlib.net/Tree.cs diff --git a/Src/Modules/zlib/zlib.net/ZStream.cs b/Src.GetRenamed/Modules/zlib/zlib.net/ZStream.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/ZStream.cs rename to Src.GetRenamed/Modules/zlib/zlib.net/ZStream.cs diff --git a/Src/Modules/zlib/zlib.net/ZStreamException.cs b/Src.GetRenamed/Modules/zlib/zlib.net/ZStreamException.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/ZStreamException.cs rename to Src.GetRenamed/Modules/zlib/zlib.net/ZStreamException.cs diff --git a/Src/Modules/zlib/zlib.net/Zlib.cs b/Src.GetRenamed/Modules/zlib/zlib.net/Zlib.cs similarity index 100% rename from Src/Modules/zlib/zlib.net/Zlib.cs rename to Src.GetRenamed/Modules/zlib/zlib.net/Zlib.cs diff --git a/Src/Modules/zlib/zlib.net/history.txt b/Src.GetRenamed/Modules/zlib/zlib.net/history.txt similarity index 100% rename from Src/Modules/zlib/zlib.net/history.txt rename to Src.GetRenamed/Modules/zlib/zlib.net/history.txt diff --git a/Src/Modules/zlib/zlib.net/license.txt b/Src.GetRenamed/Modules/zlib/zlib.net/license.txt similarity index 100% rename from Src/Modules/zlib/zlib.net/license.txt rename to Src.GetRenamed/Modules/zlib/zlib.net/license.txt diff --git a/Src/Modules/zlib/zlib.net/readme.txt b/Src.GetRenamed/Modules/zlib/zlib.net/readme.txt similarity index 100% rename from Src/Modules/zlib/zlib.net/readme.txt rename to Src.GetRenamed/Modules/zlib/zlib.net/readme.txt diff --git a/Src/README.md b/Src.GetRenamed/README.md similarity index 100% rename from Src/README.md rename to Src.GetRenamed/README.md diff --git a/Src/SQLite/Connection.cs b/Src.GetRenamed/SQLite/Connection.cs similarity index 100% rename from Src/SQLite/Connection.cs rename to Src.GetRenamed/SQLite/Connection.cs diff --git a/Src/SQLite/Contants.cs b/Src.GetRenamed/SQLite/Contants.cs similarity index 100% rename from Src/SQLite/Contants.cs rename to Src.GetRenamed/SQLite/Contants.cs diff --git a/Src/SQLite/Cursor.cs b/Src.GetRenamed/SQLite/Cursor.cs similarity index 100% rename from Src/SQLite/Cursor.cs rename to Src.GetRenamed/SQLite/Cursor.cs diff --git a/Src/SQLite/Exceptions.cs b/Src.GetRenamed/SQLite/Exceptions.cs similarity index 100% rename from Src/SQLite/Exceptions.cs rename to Src.GetRenamed/SQLite/Exceptions.cs diff --git a/Src/SQLite/Extensions.cs b/Src.GetRenamed/SQLite/Extensions.cs similarity index 100% rename from Src/SQLite/Extensions.cs rename to Src.GetRenamed/SQLite/Extensions.cs diff --git a/Src/SQLite/IronPython.SQLite.csproj b/Src.GetRenamed/SQLite/IronPython.SQLite.csproj similarity index 100% rename from Src/SQLite/IronPython.SQLite.csproj rename to Src.GetRenamed/SQLite/IronPython.SQLite.csproj diff --git a/Src/SQLite/Properties/AssemblyInfo.cs b/Src.GetRenamed/SQLite/Properties/AssemblyInfo.cs similarity index 100% rename from Src/SQLite/Properties/AssemblyInfo.cs rename to Src.GetRenamed/SQLite/Properties/AssemblyInfo.cs diff --git a/Src/SQLite/Row.cs b/Src.GetRenamed/SQLite/Row.cs similarity index 100% rename from Src/SQLite/Row.cs rename to Src.GetRenamed/SQLite/Row.cs diff --git a/Src/SQLite/Statement.cs b/Src.GetRenamed/SQLite/Statement.cs similarity index 100% rename from Src/SQLite/Statement.cs rename to Src.GetRenamed/SQLite/Statement.cs diff --git a/Src/SQLite/Util.cs b/Src.GetRenamed/SQLite/Util.cs similarity index 100% rename from Src/SQLite/Util.cs rename to Src.GetRenamed/SQLite/Util.cs diff --git a/Src/SQLite/_sqlite.cs b/Src.GetRenamed/SQLite/_sqlite.cs similarity index 100% rename from Src/SQLite/_sqlite.cs rename to Src.GetRenamed/SQLite/_sqlite.cs diff --git a/Src/SQLite/c#sqlite/.editorconfig b/Src.GetRenamed/SQLite/c#sqlite/.editorconfig similarity index 100% rename from Src/SQLite/c#sqlite/.editorconfig rename to Src.GetRenamed/SQLite/c#sqlite/.editorconfig diff --git a/Src/SQLite/c#sqlite/BtreeInt_h.cs b/Src.GetRenamed/SQLite/c#sqlite/BtreeInt_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/BtreeInt_h.cs rename to Src.GetRenamed/SQLite/c#sqlite/BtreeInt_h.cs diff --git a/Src/SQLite/c#sqlite/Btree_h.cs b/Src.GetRenamed/SQLite/c#sqlite/Btree_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/Btree_h.cs rename to Src.GetRenamed/SQLite/c#sqlite/Btree_h.cs diff --git a/Src/SQLite/c#sqlite/Delegates.cs b/Src.GetRenamed/SQLite/c#sqlite/Delegates.cs similarity index 100% rename from Src/SQLite/c#sqlite/Delegates.cs rename to Src.GetRenamed/SQLite/c#sqlite/Delegates.cs diff --git a/Src/SQLite/c#sqlite/Hash_h.cs b/Src.GetRenamed/SQLite/c#sqlite/Hash_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/Hash_h.cs rename to Src.GetRenamed/SQLite/c#sqlite/Hash_h.cs diff --git a/Src/SQLite/c#sqlite/VdbeInt_h.cs b/Src.GetRenamed/SQLite/c#sqlite/VdbeInt_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/VdbeInt_h.cs rename to Src.GetRenamed/SQLite/c#sqlite/VdbeInt_h.cs diff --git a/Src/SQLite/c#sqlite/Vdbe_h.cs b/Src.GetRenamed/SQLite/c#sqlite/Vdbe_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/Vdbe_h.cs rename to Src.GetRenamed/SQLite/c#sqlite/Vdbe_h.cs diff --git a/Src/SQLite/c#sqlite/_Custom.cs b/Src.GetRenamed/SQLite/c#sqlite/_Custom.cs similarity index 100% rename from Src/SQLite/c#sqlite/_Custom.cs rename to Src.GetRenamed/SQLite/c#sqlite/_Custom.cs diff --git a/Src/SQLite/c#sqlite/alter_c.cs b/Src.GetRenamed/SQLite/c#sqlite/alter_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/alter_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/alter_c.cs diff --git a/Src/SQLite/c#sqlite/analyze_c.cs b/Src.GetRenamed/SQLite/c#sqlite/analyze_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/analyze_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/analyze_c.cs diff --git a/Src/SQLite/c#sqlite/attach_c.cs b/Src.GetRenamed/SQLite/c#sqlite/attach_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/attach_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/attach_c.cs diff --git a/Src/SQLite/c#sqlite/auth_c.cs b/Src.GetRenamed/SQLite/c#sqlite/auth_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/auth_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/auth_c.cs diff --git a/Src/SQLite/c#sqlite/backup_c.cs b/Src.GetRenamed/SQLite/c#sqlite/backup_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/backup_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/backup_c.cs diff --git a/Src/SQLite/c#sqlite/bitvec_c.cs b/Src.GetRenamed/SQLite/c#sqlite/bitvec_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/bitvec_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/bitvec_c.cs diff --git a/Src/SQLite/c#sqlite/btmutex_c.cs b/Src.GetRenamed/SQLite/c#sqlite/btmutex_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/btmutex_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/btmutex_c.cs diff --git a/Src/SQLite/c#sqlite/btree_c.cs b/Src.GetRenamed/SQLite/c#sqlite/btree_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/btree_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/btree_c.cs diff --git a/Src/SQLite/c#sqlite/build_c.cs b/Src.GetRenamed/SQLite/c#sqlite/build_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/build_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/build_c.cs diff --git a/Src/SQLite/c#sqlite/callback_c.cs b/Src.GetRenamed/SQLite/c#sqlite/callback_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/callback_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/callback_c.cs diff --git a/Src/SQLite/c#sqlite/complete_c.cs b/Src.GetRenamed/SQLite/c#sqlite/complete_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/complete_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/complete_c.cs diff --git a/Src/SQLite/c#sqlite/crypto.cs b/Src.GetRenamed/SQLite/c#sqlite/crypto.cs similarity index 100% rename from Src/SQLite/c#sqlite/crypto.cs rename to Src.GetRenamed/SQLite/c#sqlite/crypto.cs diff --git a/Src/SQLite/c#sqlite/ctime_c.cs b/Src.GetRenamed/SQLite/c#sqlite/ctime_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/ctime_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/ctime_c.cs diff --git a/Src/SQLite/c#sqlite/date_c.cs b/Src.GetRenamed/SQLite/c#sqlite/date_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/date_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/date_c.cs diff --git a/Src/SQLite/c#sqlite/delete_c.cs b/Src.GetRenamed/SQLite/c#sqlite/delete_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/delete_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/delete_c.cs diff --git a/Src/SQLite/c#sqlite/expr_c.cs b/Src.GetRenamed/SQLite/c#sqlite/expr_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/expr_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/expr_c.cs diff --git a/Src/SQLite/c#sqlite/fault_c.cs b/Src.GetRenamed/SQLite/c#sqlite/fault_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/fault_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/fault_c.cs diff --git a/Src/SQLite/c#sqlite/fkey_c.cs b/Src.GetRenamed/SQLite/c#sqlite/fkey_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/fkey_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/fkey_c.cs diff --git a/Src/SQLite/c#sqlite/func_c.cs b/Src.GetRenamed/SQLite/c#sqlite/func_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/func_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/func_c.cs diff --git a/Src/SQLite/c#sqlite/global_c.cs b/Src.GetRenamed/SQLite/c#sqlite/global_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/global_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/global_c.cs diff --git a/Src/SQLite/c#sqlite/hash_c.cs b/Src.GetRenamed/SQLite/c#sqlite/hash_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/hash_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/hash_c.cs diff --git a/Src/SQLite/c#sqlite/hwtime_c.cs b/Src.GetRenamed/SQLite/c#sqlite/hwtime_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/hwtime_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/hwtime_c.cs diff --git a/Src/SQLite/c#sqlite/insert_c.cs b/Src.GetRenamed/SQLite/c#sqlite/insert_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/insert_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/insert_c.cs diff --git a/Src/SQLite/c#sqlite/journal_c.cs b/Src.GetRenamed/SQLite/c#sqlite/journal_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/journal_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/journal_c.cs diff --git a/Src/SQLite/c#sqlite/keywordhash_h.cs b/Src.GetRenamed/SQLite/c#sqlite/keywordhash_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/keywordhash_h.cs rename to Src.GetRenamed/SQLite/c#sqlite/keywordhash_h.cs diff --git a/Src/SQLite/c#sqlite/legacy_c.cs b/Src.GetRenamed/SQLite/c#sqlite/legacy_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/legacy_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/legacy_c.cs diff --git a/Src/SQLite/c#sqlite/loadext_c.cs b/Src.GetRenamed/SQLite/c#sqlite/loadext_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/loadext_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/loadext_c.cs diff --git a/Src/SQLite/c#sqlite/main_c.cs b/Src.GetRenamed/SQLite/c#sqlite/main_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/main_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/main_c.cs diff --git a/Src/SQLite/c#sqlite/malloc_c.cs b/Src.GetRenamed/SQLite/c#sqlite/malloc_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/malloc_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/malloc_c.cs diff --git a/Src/SQLite/c#sqlite/mem_Pool.cs b/Src.GetRenamed/SQLite/c#sqlite/mem_Pool.cs similarity index 100% rename from Src/SQLite/c#sqlite/mem_Pool.cs rename to Src.GetRenamed/SQLite/c#sqlite/mem_Pool.cs diff --git a/Src/SQLite/c#sqlite/memjournal_c.cs b/Src.GetRenamed/SQLite/c#sqlite/memjournal_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/memjournal_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/memjournal_c.cs diff --git a/Src/SQLite/c#sqlite/mutex_c.cs b/Src.GetRenamed/SQLite/c#sqlite/mutex_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/mutex_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/mutex_c.cs diff --git a/Src/SQLite/c#sqlite/mutex_h.cs b/Src.GetRenamed/SQLite/c#sqlite/mutex_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/mutex_h.cs rename to Src.GetRenamed/SQLite/c#sqlite/mutex_h.cs diff --git a/Src/SQLite/c#sqlite/mutex_noop_c.cs b/Src.GetRenamed/SQLite/c#sqlite/mutex_noop_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/mutex_noop_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/mutex_noop_c.cs diff --git a/Src/SQLite/c#sqlite/mutex_w32.cs b/Src.GetRenamed/SQLite/c#sqlite/mutex_w32.cs similarity index 100% rename from Src/SQLite/c#sqlite/mutex_w32.cs rename to Src.GetRenamed/SQLite/c#sqlite/mutex_w32.cs diff --git a/Src/SQLite/c#sqlite/notify_c.cs b/Src.GetRenamed/SQLite/c#sqlite/notify_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/notify_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/notify_c.cs diff --git a/Src/SQLite/c#sqlite/opcodes_c.cs b/Src.GetRenamed/SQLite/c#sqlite/opcodes_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/opcodes_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/opcodes_c.cs diff --git a/Src/SQLite/c#sqlite/opcodes_h.cs b/Src.GetRenamed/SQLite/c#sqlite/opcodes_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/opcodes_h.cs rename to Src.GetRenamed/SQLite/c#sqlite/opcodes_h.cs diff --git a/Src/SQLite/c#sqlite/os_c.cs b/Src.GetRenamed/SQLite/c#sqlite/os_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/os_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/os_c.cs diff --git a/Src/SQLite/c#sqlite/os_common_h.cs b/Src.GetRenamed/SQLite/c#sqlite/os_common_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/os_common_h.cs rename to Src.GetRenamed/SQLite/c#sqlite/os_common_h.cs diff --git a/Src/SQLite/c#sqlite/os_h.cs b/Src.GetRenamed/SQLite/c#sqlite/os_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/os_h.cs rename to Src.GetRenamed/SQLite/c#sqlite/os_h.cs diff --git a/Src/SQLite/c#sqlite/os_win_c.cs b/Src.GetRenamed/SQLite/c#sqlite/os_win_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/os_win_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/os_win_c.cs diff --git a/Src/SQLite/c#sqlite/pager_c.cs b/Src.GetRenamed/SQLite/c#sqlite/pager_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/pager_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/pager_c.cs diff --git a/Src/SQLite/c#sqlite/pager_h.cs b/Src.GetRenamed/SQLite/c#sqlite/pager_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/pager_h.cs rename to Src.GetRenamed/SQLite/c#sqlite/pager_h.cs diff --git a/Src/SQLite/c#sqlite/parse_c.cs b/Src.GetRenamed/SQLite/c#sqlite/parse_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/parse_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/parse_c.cs diff --git a/Src/SQLite/c#sqlite/parse_h.cs b/Src.GetRenamed/SQLite/c#sqlite/parse_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/parse_h.cs rename to Src.GetRenamed/SQLite/c#sqlite/parse_h.cs diff --git a/Src/SQLite/c#sqlite/pcache1_c.cs b/Src.GetRenamed/SQLite/c#sqlite/pcache1_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/pcache1_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/pcache1_c.cs diff --git a/Src/SQLite/c#sqlite/pcache_c.cs b/Src.GetRenamed/SQLite/c#sqlite/pcache_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/pcache_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/pcache_c.cs diff --git a/Src/SQLite/c#sqlite/pcache_h.cs b/Src.GetRenamed/SQLite/c#sqlite/pcache_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/pcache_h.cs rename to Src.GetRenamed/SQLite/c#sqlite/pcache_h.cs diff --git a/Src/SQLite/c#sqlite/pragma_c.cs b/Src.GetRenamed/SQLite/c#sqlite/pragma_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/pragma_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/pragma_c.cs diff --git a/Src/SQLite/c#sqlite/prepare_c.cs b/Src.GetRenamed/SQLite/c#sqlite/prepare_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/prepare_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/prepare_c.cs diff --git a/Src/SQLite/c#sqlite/printf_c.cs b/Src.GetRenamed/SQLite/c#sqlite/printf_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/printf_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/printf_c.cs diff --git a/Src/SQLite/c#sqlite/random_c.cs b/Src.GetRenamed/SQLite/c#sqlite/random_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/random_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/random_c.cs diff --git a/Src/SQLite/c#sqlite/resolve_c.cs b/Src.GetRenamed/SQLite/c#sqlite/resolve_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/resolve_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/resolve_c.cs diff --git a/Src/SQLite/c#sqlite/rowset_c.cs b/Src.GetRenamed/SQLite/c#sqlite/rowset_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/rowset_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/rowset_c.cs diff --git a/Src/SQLite/c#sqlite/select_c.cs b/Src.GetRenamed/SQLite/c#sqlite/select_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/select_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/select_c.cs diff --git a/Src/SQLite/c#sqlite/sqlite3_h.cs b/Src.GetRenamed/SQLite/c#sqlite/sqlite3_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/sqlite3_h.cs rename to Src.GetRenamed/SQLite/c#sqlite/sqlite3_h.cs diff --git a/Src/SQLite/c#sqlite/sqliteInt_h.cs b/Src.GetRenamed/SQLite/c#sqlite/sqliteInt_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/sqliteInt_h.cs rename to Src.GetRenamed/SQLite/c#sqlite/sqliteInt_h.cs diff --git a/Src/SQLite/c#sqlite/sqliteLimit_h.cs b/Src.GetRenamed/SQLite/c#sqlite/sqliteLimit_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/sqliteLimit_h.cs rename to Src.GetRenamed/SQLite/c#sqlite/sqliteLimit_h.cs diff --git a/Src/SQLite/c#sqlite/status_c.cs b/Src.GetRenamed/SQLite/c#sqlite/status_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/status_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/status_c.cs diff --git a/Src/SQLite/c#sqlite/table_c.cs b/Src.GetRenamed/SQLite/c#sqlite/table_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/table_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/table_c.cs diff --git a/Src/SQLite/c#sqlite/tokenize_c.cs b/Src.GetRenamed/SQLite/c#sqlite/tokenize_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/tokenize_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/tokenize_c.cs diff --git a/Src/SQLite/c#sqlite/trigger_c.cs b/Src.GetRenamed/SQLite/c#sqlite/trigger_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/trigger_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/trigger_c.cs diff --git a/Src/SQLite/c#sqlite/update_c.cs b/Src.GetRenamed/SQLite/c#sqlite/update_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/update_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/update_c.cs diff --git a/Src/SQLite/c#sqlite/utf_c.cs b/Src.GetRenamed/SQLite/c#sqlite/utf_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/utf_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/utf_c.cs diff --git a/Src/SQLite/c#sqlite/util_c.cs b/Src.GetRenamed/SQLite/c#sqlite/util_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/util_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/util_c.cs diff --git a/Src/SQLite/c#sqlite/vacuum_c.cs b/Src.GetRenamed/SQLite/c#sqlite/vacuum_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/vacuum_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/vacuum_c.cs diff --git a/Src/SQLite/c#sqlite/vdbe_c.cs b/Src.GetRenamed/SQLite/c#sqlite/vdbe_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/vdbe_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/vdbe_c.cs diff --git a/Src/SQLite/c#sqlite/vdbeapi_c.cs b/Src.GetRenamed/SQLite/c#sqlite/vdbeapi_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/vdbeapi_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/vdbeapi_c.cs diff --git a/Src/SQLite/c#sqlite/vdbeaux_c.cs b/Src.GetRenamed/SQLite/c#sqlite/vdbeaux_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/vdbeaux_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/vdbeaux_c.cs diff --git a/Src/SQLite/c#sqlite/vdbeblob_c.cs b/Src.GetRenamed/SQLite/c#sqlite/vdbeblob_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/vdbeblob_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/vdbeblob_c.cs diff --git a/Src/SQLite/c#sqlite/vdbemem_c.cs b/Src.GetRenamed/SQLite/c#sqlite/vdbemem_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/vdbemem_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/vdbemem_c.cs diff --git a/Src/SQLite/c#sqlite/vdbetrace_c.cs b/Src.GetRenamed/SQLite/c#sqlite/vdbetrace_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/vdbetrace_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/vdbetrace_c.cs diff --git a/Src/SQLite/c#sqlite/vtab_c.cs b/Src.GetRenamed/SQLite/c#sqlite/vtab_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/vtab_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/vtab_c.cs diff --git a/Src/SQLite/c#sqlite/wal_c.cs b/Src.GetRenamed/SQLite/c#sqlite/wal_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/wal_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/wal_c.cs diff --git a/Src/SQLite/c#sqlite/wal_h.cs b/Src.GetRenamed/SQLite/c#sqlite/wal_h.cs similarity index 100% rename from Src/SQLite/c#sqlite/wal_h.cs rename to Src.GetRenamed/SQLite/c#sqlite/wal_h.cs diff --git a/Src/SQLite/c#sqlite/walker_c.cs b/Src.GetRenamed/SQLite/c#sqlite/walker_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/walker_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/walker_c.cs diff --git a/Src/SQLite/c#sqlite/where_c.cs b/Src.GetRenamed/SQLite/c#sqlite/where_c.cs similarity index 100% rename from Src/SQLite/c#sqlite/where_c.cs rename to Src.GetRenamed/SQLite/c#sqlite/where_c.cs diff --git a/Src/Scripts/CompareDirs.py b/Src.GetRenamed/Scripts/CompareDirs.py similarity index 100% rename from Src/Scripts/CompareDirs.py rename to Src.GetRenamed/Scripts/CompareDirs.py diff --git a/Src/Scripts/Enter-IronPythonEnvironment.ps1 b/Src.GetRenamed/Scripts/Enter-IronPythonEnvironment.ps1 similarity index 100% rename from Src/Scripts/Enter-IronPythonEnvironment.ps1 rename to Src.GetRenamed/Scripts/Enter-IronPythonEnvironment.ps1 diff --git a/Src/Scripts/Install-IronPython.ps1 b/Src.GetRenamed/Scripts/Install-IronPython.ps1 old mode 100755 new mode 100644 similarity index 100% rename from Src/Scripts/Install-IronPython.ps1 rename to Src.GetRenamed/Scripts/Install-IronPython.ps1 diff --git a/Src/Scripts/clean.py b/Src.GetRenamed/Scripts/clean.py similarity index 100% rename from Src/Scripts/clean.py rename to Src.GetRenamed/Scripts/clean.py diff --git a/Src/Scripts/copyrights.py b/Src.GetRenamed/Scripts/copyrights.py similarity index 100% rename from Src/Scripts/copyrights.py rename to Src.GetRenamed/Scripts/copyrights.py diff --git a/Src/Scripts/generate.py b/Src.GetRenamed/Scripts/generate.py old mode 100755 new mode 100644 similarity index 100% rename from Src/Scripts/generate.py rename to Src.GetRenamed/Scripts/generate.py diff --git a/Src/Scripts/generate_UncollectableCompilationMode.py b/Src.GetRenamed/Scripts/generate_UncollectableCompilationMode.py similarity index 100% rename from Src/Scripts/generate_UncollectableCompilationMode.py rename to Src.GetRenamed/Scripts/generate_UncollectableCompilationMode.py diff --git a/Src/Scripts/generate_alltypes.py b/Src.GetRenamed/Scripts/generate_alltypes.py similarity index 100% rename from Src/Scripts/generate_alltypes.py rename to Src.GetRenamed/Scripts/generate_alltypes.py diff --git a/Src/Scripts/generate_calls.py b/Src.GetRenamed/Scripts/generate_calls.py similarity index 100% rename from Src/Scripts/generate_calls.py rename to Src.GetRenamed/Scripts/generate_calls.py diff --git a/Src/Scripts/generate_casts.py b/Src.GetRenamed/Scripts/generate_casts.py similarity index 100% rename from Src/Scripts/generate_casts.py rename to Src.GetRenamed/Scripts/generate_casts.py diff --git a/Src/Scripts/generate_comdispatch.py b/Src.GetRenamed/Scripts/generate_comdispatch.py similarity index 100% rename from Src/Scripts/generate_comdispatch.py rename to Src.GetRenamed/Scripts/generate_comdispatch.py diff --git a/Src/Scripts/generate_dict_views.py b/Src.GetRenamed/Scripts/generate_dict_views.py similarity index 100% rename from Src/Scripts/generate_dict_views.py rename to Src.GetRenamed/Scripts/generate_dict_views.py diff --git a/Src/Scripts/generate_dynamic_instructions.py b/Src.GetRenamed/Scripts/generate_dynamic_instructions.py similarity index 100% rename from Src/Scripts/generate_dynamic_instructions.py rename to Src.GetRenamed/Scripts/generate_dynamic_instructions.py diff --git a/Src/Scripts/generate_dynsites.py b/Src.GetRenamed/Scripts/generate_dynsites.py similarity index 100% rename from Src/Scripts/generate_dynsites.py rename to Src.GetRenamed/Scripts/generate_dynsites.py diff --git a/Src/Scripts/generate_encoding_aliases.py b/Src.GetRenamed/Scripts/generate_encoding_aliases.py similarity index 100% rename from Src/Scripts/generate_encoding_aliases.py rename to Src.GetRenamed/Scripts/generate_encoding_aliases.py diff --git a/Src/Scripts/generate_exception_factory.py b/Src.GetRenamed/Scripts/generate_exception_factory.py similarity index 100% rename from Src/Scripts/generate_exception_factory.py rename to Src.GetRenamed/Scripts/generate_exception_factory.py diff --git a/Src/Scripts/generate_exceptions.py b/Src.GetRenamed/Scripts/generate_exceptions.py similarity index 100% rename from Src/Scripts/generate_exceptions.py rename to Src.GetRenamed/Scripts/generate_exceptions.py diff --git a/Src/Scripts/generate_indicestest.py b/Src.GetRenamed/Scripts/generate_indicestest.py similarity index 100% rename from Src/Scripts/generate_indicestest.py rename to Src.GetRenamed/Scripts/generate_indicestest.py diff --git a/Src/Scripts/generate_math.py b/Src.GetRenamed/Scripts/generate_math.py similarity index 100% rename from Src/Scripts/generate_math.py rename to Src.GetRenamed/Scripts/generate_math.py diff --git a/Src/Scripts/generate_ops.py b/Src.GetRenamed/Scripts/generate_ops.py old mode 100755 new mode 100644 similarity index 100% rename from Src/Scripts/generate_ops.py rename to Src.GetRenamed/Scripts/generate_ops.py diff --git a/Src/Scripts/generate_os_codes.py b/Src.GetRenamed/Scripts/generate_os_codes.py similarity index 100% rename from Src/Scripts/generate_os_codes.py rename to Src.GetRenamed/Scripts/generate_os_codes.py diff --git a/Src/Scripts/generate_reflected_calls.py b/Src.GetRenamed/Scripts/generate_reflected_calls.py similarity index 100% rename from Src/Scripts/generate_reflected_calls.py rename to Src.GetRenamed/Scripts/generate_reflected_calls.py diff --git a/Src/Scripts/generate_set.py b/Src.GetRenamed/Scripts/generate_set.py similarity index 100% rename from Src/Scripts/generate_set.py rename to Src.GetRenamed/Scripts/generate_set.py diff --git a/Src/Scripts/generate_tuples.py b/Src.GetRenamed/Scripts/generate_tuples.py similarity index 100% rename from Src/Scripts/generate_tuples.py rename to Src.GetRenamed/Scripts/generate_tuples.py diff --git a/Src/Scripts/generate_typecache.py b/Src.GetRenamed/Scripts/generate_typecache.py similarity index 100% rename from Src/Scripts/generate_typecache.py rename to Src.GetRenamed/Scripts/generate_typecache.py diff --git a/Src/Scripts/generate_walker.py b/Src.GetRenamed/Scripts/generate_walker.py similarity index 100% rename from Src/Scripts/generate_walker.py rename to Src.GetRenamed/Scripts/generate_walker.py diff --git a/Src/Scripts/ipcom.ps1 b/Src.GetRenamed/Scripts/ipcom.ps1 similarity index 100% rename from Src/Scripts/ipcom.ps1 rename to Src.GetRenamed/Scripts/ipcom.ps1 diff --git a/Src/Scripts/make_meta1.py b/Src.GetRenamed/Scripts/make_meta1.py similarity index 100% rename from Src/Scripts/make_meta1.py rename to Src.GetRenamed/Scripts/make_meta1.py diff --git a/Src/Scripts/radix_generator.py b/Src.GetRenamed/Scripts/radix_generator.py similarity index 100% rename from Src/Scripts/radix_generator.py rename to Src.GetRenamed/Scripts/radix_generator.py diff --git a/Src/Scripts/run_compiled.py b/Src.GetRenamed/Scripts/run_compiled.py similarity index 100% rename from Src/Scripts/run_compiled.py rename to Src.GetRenamed/Scripts/run_compiled.py diff --git a/Src/Scripts/run_interactive.py b/Src.GetRenamed/Scripts/run_interactive.py similarity index 100% rename from Src/Scripts/run_interactive.py rename to Src.GetRenamed/Scripts/run_interactive.py diff --git a/Src/Scripts/smtpmailer.py b/Src.GetRenamed/Scripts/smtpmailer.py similarity index 100% rename from Src/Scripts/smtpmailer.py rename to Src.GetRenamed/Scripts/smtpmailer.py diff --git a/Src/Scripts/test_builder.py b/Src.GetRenamed/Scripts/test_builder.py similarity index 100% rename from Src/Scripts/test_builder.py rename to Src.GetRenamed/Scripts/test_builder.py diff --git a/Src/Scripts/test_cgcheck.py b/Src.GetRenamed/Scripts/test_cgcheck.py similarity index 100% rename from Src/Scripts/test_cgcheck.py rename to Src.GetRenamed/Scripts/test_cgcheck.py diff --git a/Src/Scripts/test_parrot.py b/Src.GetRenamed/Scripts/test_parrot.py similarity index 100% rename from Src/Scripts/test_parrot.py rename to Src.GetRenamed/Scripts/test_parrot.py diff --git a/Src/Scripts/test_pystone.py b/Src.GetRenamed/Scripts/test_pystone.py similarity index 100% rename from Src/Scripts/test_pystone.py rename to Src.GetRenamed/Scripts/test_pystone.py diff --git a/Src/StdLib/.gitattributes b/Src.GetRenamed/StdLib/.gitattributes similarity index 100% rename from Src/StdLib/.gitattributes rename to Src.GetRenamed/StdLib/.gitattributes diff --git a/Src/StdLib/Lib/__future__.py b/Src.GetRenamed/StdLib/Lib/__future__.py similarity index 100% rename from Src/StdLib/Lib/__future__.py rename to Src.GetRenamed/StdLib/Lib/__future__.py diff --git a/Src/StdLib/Lib/__phello__.foo.py b/Src.GetRenamed/StdLib/Lib/__phello__.foo.py similarity index 100% rename from Src/StdLib/Lib/__phello__.foo.py rename to Src.GetRenamed/StdLib/Lib/__phello__.foo.py diff --git a/Src/StdLib/Lib/_bootlocale.py b/Src.GetRenamed/StdLib/Lib/_bootlocale.py similarity index 100% rename from Src/StdLib/Lib/_bootlocale.py rename to Src.GetRenamed/StdLib/Lib/_bootlocale.py diff --git a/Src/StdLib/Lib/_collections_abc.py b/Src.GetRenamed/StdLib/Lib/_collections_abc.py similarity index 100% rename from Src/StdLib/Lib/_collections_abc.py rename to Src.GetRenamed/StdLib/Lib/_collections_abc.py diff --git a/Src/StdLib/Lib/_compat_pickle.py b/Src.GetRenamed/StdLib/Lib/_compat_pickle.py similarity index 100% rename from Src/StdLib/Lib/_compat_pickle.py rename to Src.GetRenamed/StdLib/Lib/_compat_pickle.py diff --git a/Src/StdLib/Lib/_dummy_thread.py b/Src.GetRenamed/StdLib/Lib/_dummy_thread.py similarity index 100% rename from Src/StdLib/Lib/_dummy_thread.py rename to Src.GetRenamed/StdLib/Lib/_dummy_thread.py diff --git a/Src/StdLib/Lib/_markupbase.py b/Src.GetRenamed/StdLib/Lib/_markupbase.py similarity index 100% rename from Src/StdLib/Lib/_markupbase.py rename to Src.GetRenamed/StdLib/Lib/_markupbase.py diff --git a/Src/StdLib/Lib/_osx_support.py b/Src.GetRenamed/StdLib/Lib/_osx_support.py similarity index 100% rename from Src/StdLib/Lib/_osx_support.py rename to Src.GetRenamed/StdLib/Lib/_osx_support.py diff --git a/Src/StdLib/Lib/_pyio.py b/Src.GetRenamed/StdLib/Lib/_pyio.py similarity index 100% rename from Src/StdLib/Lib/_pyio.py rename to Src.GetRenamed/StdLib/Lib/_pyio.py diff --git a/Src/StdLib/Lib/_sitebuiltins.py b/Src.GetRenamed/StdLib/Lib/_sitebuiltins.py similarity index 100% rename from Src/StdLib/Lib/_sitebuiltins.py rename to Src.GetRenamed/StdLib/Lib/_sitebuiltins.py diff --git a/Src/StdLib/Lib/_strptime.py b/Src.GetRenamed/StdLib/Lib/_strptime.py similarity index 100% rename from Src/StdLib/Lib/_strptime.py rename to Src.GetRenamed/StdLib/Lib/_strptime.py diff --git a/Src/StdLib/Lib/_threading_local.py b/Src.GetRenamed/StdLib/Lib/_threading_local.py similarity index 100% rename from Src/StdLib/Lib/_threading_local.py rename to Src.GetRenamed/StdLib/Lib/_threading_local.py diff --git a/Src/StdLib/Lib/_weakrefset.py b/Src.GetRenamed/StdLib/Lib/_weakrefset.py similarity index 100% rename from Src/StdLib/Lib/_weakrefset.py rename to Src.GetRenamed/StdLib/Lib/_weakrefset.py diff --git a/Src/StdLib/Lib/abc.py b/Src.GetRenamed/StdLib/Lib/abc.py similarity index 100% rename from Src/StdLib/Lib/abc.py rename to Src.GetRenamed/StdLib/Lib/abc.py diff --git a/Src/StdLib/Lib/aifc.py b/Src.GetRenamed/StdLib/Lib/aifc.py similarity index 100% rename from Src/StdLib/Lib/aifc.py rename to Src.GetRenamed/StdLib/Lib/aifc.py diff --git a/Src/StdLib/Lib/antigravity.py b/Src.GetRenamed/StdLib/Lib/antigravity.py similarity index 100% rename from Src/StdLib/Lib/antigravity.py rename to Src.GetRenamed/StdLib/Lib/antigravity.py diff --git a/Src/StdLib/Lib/argparse.py b/Src.GetRenamed/StdLib/Lib/argparse.py similarity index 100% rename from Src/StdLib/Lib/argparse.py rename to Src.GetRenamed/StdLib/Lib/argparse.py diff --git a/Src/StdLib/Lib/ast.py b/Src.GetRenamed/StdLib/Lib/ast.py similarity index 100% rename from Src/StdLib/Lib/ast.py rename to Src.GetRenamed/StdLib/Lib/ast.py diff --git a/Src/StdLib/Lib/asynchat.py b/Src.GetRenamed/StdLib/Lib/asynchat.py similarity index 100% rename from Src/StdLib/Lib/asynchat.py rename to Src.GetRenamed/StdLib/Lib/asynchat.py diff --git a/Src/StdLib/Lib/asyncio/__init__.py b/Src.GetRenamed/StdLib/Lib/asyncio/__init__.py similarity index 100% rename from Src/StdLib/Lib/asyncio/__init__.py rename to Src.GetRenamed/StdLib/Lib/asyncio/__init__.py diff --git a/Src/StdLib/Lib/asyncio/base_events.py b/Src.GetRenamed/StdLib/Lib/asyncio/base_events.py similarity index 100% rename from Src/StdLib/Lib/asyncio/base_events.py rename to Src.GetRenamed/StdLib/Lib/asyncio/base_events.py diff --git a/Src/StdLib/Lib/asyncio/base_subprocess.py b/Src.GetRenamed/StdLib/Lib/asyncio/base_subprocess.py similarity index 100% rename from Src/StdLib/Lib/asyncio/base_subprocess.py rename to Src.GetRenamed/StdLib/Lib/asyncio/base_subprocess.py diff --git a/Src/StdLib/Lib/asyncio/compat.py b/Src.GetRenamed/StdLib/Lib/asyncio/compat.py similarity index 100% rename from Src/StdLib/Lib/asyncio/compat.py rename to Src.GetRenamed/StdLib/Lib/asyncio/compat.py diff --git a/Src/StdLib/Lib/asyncio/constants.py b/Src.GetRenamed/StdLib/Lib/asyncio/constants.py similarity index 100% rename from Src/StdLib/Lib/asyncio/constants.py rename to Src.GetRenamed/StdLib/Lib/asyncio/constants.py diff --git a/Src/StdLib/Lib/asyncio/coroutines.py b/Src.GetRenamed/StdLib/Lib/asyncio/coroutines.py similarity index 100% rename from Src/StdLib/Lib/asyncio/coroutines.py rename to Src.GetRenamed/StdLib/Lib/asyncio/coroutines.py diff --git a/Src/StdLib/Lib/asyncio/events.py b/Src.GetRenamed/StdLib/Lib/asyncio/events.py similarity index 100% rename from Src/StdLib/Lib/asyncio/events.py rename to Src.GetRenamed/StdLib/Lib/asyncio/events.py diff --git a/Src/StdLib/Lib/asyncio/futures.py b/Src.GetRenamed/StdLib/Lib/asyncio/futures.py similarity index 100% rename from Src/StdLib/Lib/asyncio/futures.py rename to Src.GetRenamed/StdLib/Lib/asyncio/futures.py diff --git a/Src/StdLib/Lib/asyncio/locks.py b/Src.GetRenamed/StdLib/Lib/asyncio/locks.py similarity index 100% rename from Src/StdLib/Lib/asyncio/locks.py rename to Src.GetRenamed/StdLib/Lib/asyncio/locks.py diff --git a/Src/StdLib/Lib/asyncio/log.py b/Src.GetRenamed/StdLib/Lib/asyncio/log.py similarity index 100% rename from Src/StdLib/Lib/asyncio/log.py rename to Src.GetRenamed/StdLib/Lib/asyncio/log.py diff --git a/Src/StdLib/Lib/asyncio/proactor_events.py b/Src.GetRenamed/StdLib/Lib/asyncio/proactor_events.py similarity index 100% rename from Src/StdLib/Lib/asyncio/proactor_events.py rename to Src.GetRenamed/StdLib/Lib/asyncio/proactor_events.py diff --git a/Src/StdLib/Lib/asyncio/protocols.py b/Src.GetRenamed/StdLib/Lib/asyncio/protocols.py similarity index 100% rename from Src/StdLib/Lib/asyncio/protocols.py rename to Src.GetRenamed/StdLib/Lib/asyncio/protocols.py diff --git a/Src/StdLib/Lib/asyncio/queues.py b/Src.GetRenamed/StdLib/Lib/asyncio/queues.py similarity index 100% rename from Src/StdLib/Lib/asyncio/queues.py rename to Src.GetRenamed/StdLib/Lib/asyncio/queues.py diff --git a/Src/StdLib/Lib/asyncio/selector_events.py b/Src.GetRenamed/StdLib/Lib/asyncio/selector_events.py similarity index 100% rename from Src/StdLib/Lib/asyncio/selector_events.py rename to Src.GetRenamed/StdLib/Lib/asyncio/selector_events.py diff --git a/Src/StdLib/Lib/asyncio/sslproto.py b/Src.GetRenamed/StdLib/Lib/asyncio/sslproto.py similarity index 100% rename from Src/StdLib/Lib/asyncio/sslproto.py rename to Src.GetRenamed/StdLib/Lib/asyncio/sslproto.py diff --git a/Src/StdLib/Lib/asyncio/streams.py b/Src.GetRenamed/StdLib/Lib/asyncio/streams.py similarity index 100% rename from Src/StdLib/Lib/asyncio/streams.py rename to Src.GetRenamed/StdLib/Lib/asyncio/streams.py diff --git a/Src/StdLib/Lib/asyncio/subprocess.py b/Src.GetRenamed/StdLib/Lib/asyncio/subprocess.py similarity index 100% rename from Src/StdLib/Lib/asyncio/subprocess.py rename to Src.GetRenamed/StdLib/Lib/asyncio/subprocess.py diff --git a/Src/StdLib/Lib/asyncio/tasks.py b/Src.GetRenamed/StdLib/Lib/asyncio/tasks.py similarity index 100% rename from Src/StdLib/Lib/asyncio/tasks.py rename to Src.GetRenamed/StdLib/Lib/asyncio/tasks.py diff --git a/Src/StdLib/Lib/asyncio/test_utils.py b/Src.GetRenamed/StdLib/Lib/asyncio/test_utils.py similarity index 100% rename from Src/StdLib/Lib/asyncio/test_utils.py rename to Src.GetRenamed/StdLib/Lib/asyncio/test_utils.py diff --git a/Src/StdLib/Lib/asyncio/transports.py b/Src.GetRenamed/StdLib/Lib/asyncio/transports.py similarity index 100% rename from Src/StdLib/Lib/asyncio/transports.py rename to Src.GetRenamed/StdLib/Lib/asyncio/transports.py diff --git a/Src/StdLib/Lib/asyncio/unix_events.py b/Src.GetRenamed/StdLib/Lib/asyncio/unix_events.py similarity index 100% rename from Src/StdLib/Lib/asyncio/unix_events.py rename to Src.GetRenamed/StdLib/Lib/asyncio/unix_events.py diff --git a/Src/StdLib/Lib/asyncio/windows_events.py b/Src.GetRenamed/StdLib/Lib/asyncio/windows_events.py similarity index 100% rename from Src/StdLib/Lib/asyncio/windows_events.py rename to Src.GetRenamed/StdLib/Lib/asyncio/windows_events.py diff --git a/Src/StdLib/Lib/asyncio/windows_utils.py b/Src.GetRenamed/StdLib/Lib/asyncio/windows_utils.py similarity index 100% rename from Src/StdLib/Lib/asyncio/windows_utils.py rename to Src.GetRenamed/StdLib/Lib/asyncio/windows_utils.py diff --git a/Src/StdLib/Lib/asyncore.py b/Src.GetRenamed/StdLib/Lib/asyncore.py similarity index 100% rename from Src/StdLib/Lib/asyncore.py rename to Src.GetRenamed/StdLib/Lib/asyncore.py diff --git a/Src/StdLib/Lib/base64.py b/Src.GetRenamed/StdLib/Lib/base64.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/base64.py rename to Src.GetRenamed/StdLib/Lib/base64.py diff --git a/Src/StdLib/Lib/bdb.py b/Src.GetRenamed/StdLib/Lib/bdb.py similarity index 100% rename from Src/StdLib/Lib/bdb.py rename to Src.GetRenamed/StdLib/Lib/bdb.py diff --git a/Src/StdLib/Lib/binhex.py b/Src.GetRenamed/StdLib/Lib/binhex.py similarity index 100% rename from Src/StdLib/Lib/binhex.py rename to Src.GetRenamed/StdLib/Lib/binhex.py diff --git a/Src/StdLib/Lib/bisect.py b/Src.GetRenamed/StdLib/Lib/bisect.py similarity index 100% rename from Src/StdLib/Lib/bisect.py rename to Src.GetRenamed/StdLib/Lib/bisect.py diff --git a/Src/StdLib/Lib/bz2.py b/Src.GetRenamed/StdLib/Lib/bz2.py similarity index 100% rename from Src/StdLib/Lib/bz2.py rename to Src.GetRenamed/StdLib/Lib/bz2.py diff --git a/Src/StdLib/Lib/cProfile.py b/Src.GetRenamed/StdLib/Lib/cProfile.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/cProfile.py rename to Src.GetRenamed/StdLib/Lib/cProfile.py diff --git a/Src/StdLib/Lib/calendar.py b/Src.GetRenamed/StdLib/Lib/calendar.py similarity index 100% rename from Src/StdLib/Lib/calendar.py rename to Src.GetRenamed/StdLib/Lib/calendar.py diff --git a/Src/StdLib/Lib/cgi.py b/Src.GetRenamed/StdLib/Lib/cgi.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/cgi.py rename to Src.GetRenamed/StdLib/Lib/cgi.py diff --git a/Src/StdLib/Lib/cgitb.py b/Src.GetRenamed/StdLib/Lib/cgitb.py similarity index 100% rename from Src/StdLib/Lib/cgitb.py rename to Src.GetRenamed/StdLib/Lib/cgitb.py diff --git a/Src/StdLib/Lib/chunk.py b/Src.GetRenamed/StdLib/Lib/chunk.py similarity index 100% rename from Src/StdLib/Lib/chunk.py rename to Src.GetRenamed/StdLib/Lib/chunk.py diff --git a/Src/StdLib/Lib/clrtype.py b/Src.GetRenamed/StdLib/Lib/clrtype.py similarity index 100% rename from Src/StdLib/Lib/clrtype.py rename to Src.GetRenamed/StdLib/Lib/clrtype.py diff --git a/Src/StdLib/Lib/cmd.py b/Src.GetRenamed/StdLib/Lib/cmd.py similarity index 100% rename from Src/StdLib/Lib/cmd.py rename to Src.GetRenamed/StdLib/Lib/cmd.py diff --git a/Src/StdLib/Lib/code.py b/Src.GetRenamed/StdLib/Lib/code.py similarity index 100% rename from Src/StdLib/Lib/code.py rename to Src.GetRenamed/StdLib/Lib/code.py diff --git a/Src/StdLib/Lib/codecs.py b/Src.GetRenamed/StdLib/Lib/codecs.py similarity index 100% rename from Src/StdLib/Lib/codecs.py rename to Src.GetRenamed/StdLib/Lib/codecs.py diff --git a/Src/StdLib/Lib/codeop.py b/Src.GetRenamed/StdLib/Lib/codeop.py similarity index 100% rename from Src/StdLib/Lib/codeop.py rename to Src.GetRenamed/StdLib/Lib/codeop.py diff --git a/Src/StdLib/Lib/collections/__init__.py b/Src.GetRenamed/StdLib/Lib/collections/__init__.py similarity index 100% rename from Src/StdLib/Lib/collections/__init__.py rename to Src.GetRenamed/StdLib/Lib/collections/__init__.py diff --git a/Src/StdLib/Lib/collections/__main__.py b/Src.GetRenamed/StdLib/Lib/collections/__main__.py similarity index 100% rename from Src/StdLib/Lib/collections/__main__.py rename to Src.GetRenamed/StdLib/Lib/collections/__main__.py diff --git a/Src/StdLib/Lib/collections/abc.py b/Src.GetRenamed/StdLib/Lib/collections/abc.py similarity index 100% rename from Src/StdLib/Lib/collections/abc.py rename to Src.GetRenamed/StdLib/Lib/collections/abc.py diff --git a/Src/StdLib/Lib/colorsys.py b/Src.GetRenamed/StdLib/Lib/colorsys.py similarity index 100% rename from Src/StdLib/Lib/colorsys.py rename to Src.GetRenamed/StdLib/Lib/colorsys.py diff --git a/Src/StdLib/Lib/compileall.py b/Src.GetRenamed/StdLib/Lib/compileall.py similarity index 100% rename from Src/StdLib/Lib/compileall.py rename to Src.GetRenamed/StdLib/Lib/compileall.py diff --git a/Src/StdLib/Lib/concurrent/__init__.py b/Src.GetRenamed/StdLib/Lib/concurrent/__init__.py similarity index 100% rename from Src/StdLib/Lib/concurrent/__init__.py rename to Src.GetRenamed/StdLib/Lib/concurrent/__init__.py diff --git a/Src/StdLib/Lib/concurrent/futures/__init__.py b/Src.GetRenamed/StdLib/Lib/concurrent/futures/__init__.py similarity index 100% rename from Src/StdLib/Lib/concurrent/futures/__init__.py rename to Src.GetRenamed/StdLib/Lib/concurrent/futures/__init__.py diff --git a/Src/StdLib/Lib/concurrent/futures/_base.py b/Src.GetRenamed/StdLib/Lib/concurrent/futures/_base.py similarity index 100% rename from Src/StdLib/Lib/concurrent/futures/_base.py rename to Src.GetRenamed/StdLib/Lib/concurrent/futures/_base.py diff --git a/Src/StdLib/Lib/concurrent/futures/process.py b/Src.GetRenamed/StdLib/Lib/concurrent/futures/process.py similarity index 100% rename from Src/StdLib/Lib/concurrent/futures/process.py rename to Src.GetRenamed/StdLib/Lib/concurrent/futures/process.py diff --git a/Src/StdLib/Lib/concurrent/futures/thread.py b/Src.GetRenamed/StdLib/Lib/concurrent/futures/thread.py similarity index 100% rename from Src/StdLib/Lib/concurrent/futures/thread.py rename to Src.GetRenamed/StdLib/Lib/concurrent/futures/thread.py diff --git a/Src/StdLib/Lib/configparser.py b/Src.GetRenamed/StdLib/Lib/configparser.py similarity index 100% rename from Src/StdLib/Lib/configparser.py rename to Src.GetRenamed/StdLib/Lib/configparser.py diff --git a/Src/StdLib/Lib/contextlib.py b/Src.GetRenamed/StdLib/Lib/contextlib.py similarity index 100% rename from Src/StdLib/Lib/contextlib.py rename to Src.GetRenamed/StdLib/Lib/contextlib.py diff --git a/Src/StdLib/Lib/copy.py b/Src.GetRenamed/StdLib/Lib/copy.py similarity index 100% rename from Src/StdLib/Lib/copy.py rename to Src.GetRenamed/StdLib/Lib/copy.py diff --git a/Src/StdLib/Lib/copyreg.py b/Src.GetRenamed/StdLib/Lib/copyreg.py similarity index 100% rename from Src/StdLib/Lib/copyreg.py rename to Src.GetRenamed/StdLib/Lib/copyreg.py diff --git a/Src/StdLib/Lib/crypt.py b/Src.GetRenamed/StdLib/Lib/crypt.py similarity index 100% rename from Src/StdLib/Lib/crypt.py rename to Src.GetRenamed/StdLib/Lib/crypt.py diff --git a/Src/StdLib/Lib/csv.py b/Src.GetRenamed/StdLib/Lib/csv.py similarity index 100% rename from Src/StdLib/Lib/csv.py rename to Src.GetRenamed/StdLib/Lib/csv.py diff --git a/Src/StdLib/Lib/ctypes/__init__.py b/Src.GetRenamed/StdLib/Lib/ctypes/__init__.py similarity index 100% rename from Src/StdLib/Lib/ctypes/__init__.py rename to Src.GetRenamed/StdLib/Lib/ctypes/__init__.py diff --git a/Src/StdLib/Lib/ctypes/_endian.py b/Src.GetRenamed/StdLib/Lib/ctypes/_endian.py similarity index 100% rename from Src/StdLib/Lib/ctypes/_endian.py rename to Src.GetRenamed/StdLib/Lib/ctypes/_endian.py diff --git a/Src/StdLib/Lib/ctypes/macholib/README.ctypes b/Src.GetRenamed/StdLib/Lib/ctypes/macholib/README.ctypes similarity index 100% rename from Src/StdLib/Lib/ctypes/macholib/README.ctypes rename to Src.GetRenamed/StdLib/Lib/ctypes/macholib/README.ctypes diff --git a/Src/StdLib/Lib/ctypes/macholib/__init__.py b/Src.GetRenamed/StdLib/Lib/ctypes/macholib/__init__.py similarity index 100% rename from Src/StdLib/Lib/ctypes/macholib/__init__.py rename to Src.GetRenamed/StdLib/Lib/ctypes/macholib/__init__.py diff --git a/Src/StdLib/Lib/ctypes/macholib/dyld.py b/Src.GetRenamed/StdLib/Lib/ctypes/macholib/dyld.py similarity index 100% rename from Src/StdLib/Lib/ctypes/macholib/dyld.py rename to Src.GetRenamed/StdLib/Lib/ctypes/macholib/dyld.py diff --git a/Src/StdLib/Lib/ctypes/macholib/dylib.py b/Src.GetRenamed/StdLib/Lib/ctypes/macholib/dylib.py similarity index 100% rename from Src/StdLib/Lib/ctypes/macholib/dylib.py rename to Src.GetRenamed/StdLib/Lib/ctypes/macholib/dylib.py diff --git a/Src/StdLib/Lib/ctypes/macholib/fetch_macholib b/Src.GetRenamed/StdLib/Lib/ctypes/macholib/fetch_macholib old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/ctypes/macholib/fetch_macholib rename to Src.GetRenamed/StdLib/Lib/ctypes/macholib/fetch_macholib diff --git a/Src/StdLib/Lib/ctypes/macholib/fetch_macholib.bat b/Src.GetRenamed/StdLib/Lib/ctypes/macholib/fetch_macholib.bat similarity index 100% rename from Src/StdLib/Lib/ctypes/macholib/fetch_macholib.bat rename to Src.GetRenamed/StdLib/Lib/ctypes/macholib/fetch_macholib.bat diff --git a/Src/StdLib/Lib/ctypes/macholib/framework.py b/Src.GetRenamed/StdLib/Lib/ctypes/macholib/framework.py similarity index 100% rename from Src/StdLib/Lib/ctypes/macholib/framework.py rename to Src.GetRenamed/StdLib/Lib/ctypes/macholib/framework.py diff --git a/Src/StdLib/Lib/ctypes/test/__init__.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/__init__.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/__init__.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/__init__.py diff --git a/Src/StdLib/Lib/ctypes/test/__main__.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/__main__.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/__main__.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/__main__.py diff --git a/Src/StdLib/Lib/ctypes/test/test_anon.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_anon.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_anon.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_anon.py diff --git a/Src/StdLib/Lib/ctypes/test/test_array_in_pointer.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_array_in_pointer.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_array_in_pointer.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_array_in_pointer.py diff --git a/Src/StdLib/Lib/ctypes/test/test_arrays.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_arrays.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_arrays.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_arrays.py diff --git a/Src/StdLib/Lib/ctypes/test/test_as_parameter.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_as_parameter.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_as_parameter.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_as_parameter.py diff --git a/Src/StdLib/Lib/ctypes/test/test_bitfields.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_bitfields.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_bitfields.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_bitfields.py diff --git a/Src/StdLib/Lib/ctypes/test/test_buffers.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_buffers.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_buffers.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_buffers.py diff --git a/Src/StdLib/Lib/ctypes/test/test_bytes.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_bytes.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_bytes.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_bytes.py diff --git a/Src/StdLib/Lib/ctypes/test/test_byteswap.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_byteswap.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_byteswap.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_byteswap.py diff --git a/Src/StdLib/Lib/ctypes/test/test_callbacks.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_callbacks.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_callbacks.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_callbacks.py diff --git a/Src/StdLib/Lib/ctypes/test/test_cast.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_cast.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_cast.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_cast.py diff --git a/Src/StdLib/Lib/ctypes/test/test_cfuncs.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_cfuncs.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_cfuncs.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_cfuncs.py diff --git a/Src/StdLib/Lib/ctypes/test/test_checkretval.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_checkretval.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_checkretval.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_checkretval.py diff --git a/Src/StdLib/Lib/ctypes/test/test_delattr.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_delattr.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_delattr.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_delattr.py diff --git a/Src/StdLib/Lib/ctypes/test/test_errno.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_errno.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_errno.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_errno.py diff --git a/Src/StdLib/Lib/ctypes/test/test_find.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_find.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_find.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_find.py diff --git a/Src/StdLib/Lib/ctypes/test/test_frombuffer.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_frombuffer.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_frombuffer.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_frombuffer.py diff --git a/Src/StdLib/Lib/ctypes/test/test_funcptr.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_funcptr.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_funcptr.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_funcptr.py diff --git a/Src/StdLib/Lib/ctypes/test/test_functions.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_functions.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_functions.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_functions.py diff --git a/Src/StdLib/Lib/ctypes/test/test_incomplete.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_incomplete.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_incomplete.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_incomplete.py diff --git a/Src/StdLib/Lib/ctypes/test/test_init.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_init.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_init.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_init.py diff --git a/Src/StdLib/Lib/ctypes/test/test_internals.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_internals.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_internals.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_internals.py diff --git a/Src/StdLib/Lib/ctypes/test/test_keeprefs.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_keeprefs.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_keeprefs.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_keeprefs.py diff --git a/Src/StdLib/Lib/ctypes/test/test_libc.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_libc.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_libc.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_libc.py diff --git a/Src/StdLib/Lib/ctypes/test/test_loading.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_loading.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_loading.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_loading.py diff --git a/Src/StdLib/Lib/ctypes/test/test_macholib.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_macholib.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_macholib.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_macholib.py diff --git a/Src/StdLib/Lib/ctypes/test/test_memfunctions.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_memfunctions.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_memfunctions.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_memfunctions.py diff --git a/Src/StdLib/Lib/ctypes/test/test_numbers.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_numbers.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_numbers.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_numbers.py diff --git a/Src/StdLib/Lib/ctypes/test/test_objects.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_objects.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_objects.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_objects.py diff --git a/Src/StdLib/Lib/ctypes/test/test_parameters.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_parameters.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_parameters.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_parameters.py diff --git a/Src/StdLib/Lib/ctypes/test/test_pep3118.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_pep3118.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_pep3118.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_pep3118.py diff --git a/Src/StdLib/Lib/ctypes/test/test_pickling.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_pickling.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_pickling.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_pickling.py diff --git a/Src/StdLib/Lib/ctypes/test/test_pointers.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_pointers.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_pointers.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_pointers.py diff --git a/Src/StdLib/Lib/ctypes/test/test_prototypes.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_prototypes.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_prototypes.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_prototypes.py diff --git a/Src/StdLib/Lib/ctypes/test/test_python_api.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_python_api.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_python_api.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_python_api.py diff --git a/Src/StdLib/Lib/ctypes/test/test_random_things.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_random_things.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_random_things.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_random_things.py diff --git a/Src/StdLib/Lib/ctypes/test/test_refcounts.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_refcounts.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_refcounts.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_refcounts.py diff --git a/Src/StdLib/Lib/ctypes/test/test_repr.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_repr.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_repr.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_repr.py diff --git a/Src/StdLib/Lib/ctypes/test/test_returnfuncptrs.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_returnfuncptrs.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_returnfuncptrs.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_returnfuncptrs.py diff --git a/Src/StdLib/Lib/ctypes/test/test_simplesubclasses.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_simplesubclasses.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_simplesubclasses.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_simplesubclasses.py diff --git a/Src/StdLib/Lib/ctypes/test/test_sizes.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_sizes.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_sizes.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_sizes.py diff --git a/Src/StdLib/Lib/ctypes/test/test_slicing.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_slicing.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_slicing.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_slicing.py diff --git a/Src/StdLib/Lib/ctypes/test/test_stringptr.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_stringptr.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_stringptr.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_stringptr.py diff --git a/Src/StdLib/Lib/ctypes/test/test_strings.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_strings.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_strings.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_strings.py diff --git a/Src/StdLib/Lib/ctypes/test/test_struct_fields.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_struct_fields.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_struct_fields.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_struct_fields.py diff --git a/Src/StdLib/Lib/ctypes/test/test_structures.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_structures.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_structures.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_structures.py diff --git a/Src/StdLib/Lib/ctypes/test/test_unaligned_structures.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_unaligned_structures.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_unaligned_structures.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_unaligned_structures.py diff --git a/Src/StdLib/Lib/ctypes/test/test_unicode.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_unicode.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_unicode.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_unicode.py diff --git a/Src/StdLib/Lib/ctypes/test/test_values.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_values.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_values.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_values.py diff --git a/Src/StdLib/Lib/ctypes/test/test_varsize_struct.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_varsize_struct.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_varsize_struct.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_varsize_struct.py diff --git a/Src/StdLib/Lib/ctypes/test/test_win32.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_win32.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_win32.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_win32.py diff --git a/Src/StdLib/Lib/ctypes/test/test_wintypes.py b/Src.GetRenamed/StdLib/Lib/ctypes/test/test_wintypes.py similarity index 100% rename from Src/StdLib/Lib/ctypes/test/test_wintypes.py rename to Src.GetRenamed/StdLib/Lib/ctypes/test/test_wintypes.py diff --git a/Src/StdLib/Lib/ctypes/util.py b/Src.GetRenamed/StdLib/Lib/ctypes/util.py similarity index 100% rename from Src/StdLib/Lib/ctypes/util.py rename to Src.GetRenamed/StdLib/Lib/ctypes/util.py diff --git a/Src/StdLib/Lib/ctypes/wintypes.py b/Src.GetRenamed/StdLib/Lib/ctypes/wintypes.py similarity index 100% rename from Src/StdLib/Lib/ctypes/wintypes.py rename to Src.GetRenamed/StdLib/Lib/ctypes/wintypes.py diff --git a/Src/StdLib/Lib/curses/__init__.py b/Src.GetRenamed/StdLib/Lib/curses/__init__.py similarity index 100% rename from Src/StdLib/Lib/curses/__init__.py rename to Src.GetRenamed/StdLib/Lib/curses/__init__.py diff --git a/Src/StdLib/Lib/curses/ascii.py b/Src.GetRenamed/StdLib/Lib/curses/ascii.py similarity index 100% rename from Src/StdLib/Lib/curses/ascii.py rename to Src.GetRenamed/StdLib/Lib/curses/ascii.py diff --git a/Src/StdLib/Lib/curses/has_key.py b/Src.GetRenamed/StdLib/Lib/curses/has_key.py similarity index 100% rename from Src/StdLib/Lib/curses/has_key.py rename to Src.GetRenamed/StdLib/Lib/curses/has_key.py diff --git a/Src/StdLib/Lib/curses/panel.py b/Src.GetRenamed/StdLib/Lib/curses/panel.py similarity index 100% rename from Src/StdLib/Lib/curses/panel.py rename to Src.GetRenamed/StdLib/Lib/curses/panel.py diff --git a/Src/StdLib/Lib/curses/textpad.py b/Src.GetRenamed/StdLib/Lib/curses/textpad.py similarity index 100% rename from Src/StdLib/Lib/curses/textpad.py rename to Src.GetRenamed/StdLib/Lib/curses/textpad.py diff --git a/Src/StdLib/Lib/datetime.py b/Src.GetRenamed/StdLib/Lib/datetime.py similarity index 100% rename from Src/StdLib/Lib/datetime.py rename to Src.GetRenamed/StdLib/Lib/datetime.py diff --git a/Src/StdLib/Lib/dbm/__init__.py b/Src.GetRenamed/StdLib/Lib/dbm/__init__.py similarity index 100% rename from Src/StdLib/Lib/dbm/__init__.py rename to Src.GetRenamed/StdLib/Lib/dbm/__init__.py diff --git a/Src/StdLib/Lib/dbm/dumb.py b/Src.GetRenamed/StdLib/Lib/dbm/dumb.py similarity index 100% rename from Src/StdLib/Lib/dbm/dumb.py rename to Src.GetRenamed/StdLib/Lib/dbm/dumb.py diff --git a/Src/StdLib/Lib/dbm/gnu.py b/Src.GetRenamed/StdLib/Lib/dbm/gnu.py similarity index 100% rename from Src/StdLib/Lib/dbm/gnu.py rename to Src.GetRenamed/StdLib/Lib/dbm/gnu.py diff --git a/Src/StdLib/Lib/dbm/ndbm.py b/Src.GetRenamed/StdLib/Lib/dbm/ndbm.py similarity index 100% rename from Src/StdLib/Lib/dbm/ndbm.py rename to Src.GetRenamed/StdLib/Lib/dbm/ndbm.py diff --git a/Src/StdLib/Lib/decimal.py b/Src.GetRenamed/StdLib/Lib/decimal.py similarity index 100% rename from Src/StdLib/Lib/decimal.py rename to Src.GetRenamed/StdLib/Lib/decimal.py diff --git a/Src/StdLib/Lib/difflib.py b/Src.GetRenamed/StdLib/Lib/difflib.py similarity index 100% rename from Src/StdLib/Lib/difflib.py rename to Src.GetRenamed/StdLib/Lib/difflib.py diff --git a/Src/StdLib/Lib/dis.py b/Src.GetRenamed/StdLib/Lib/dis.py similarity index 100% rename from Src/StdLib/Lib/dis.py rename to Src.GetRenamed/StdLib/Lib/dis.py diff --git a/Src/StdLib/Lib/distutils/README b/Src.GetRenamed/StdLib/Lib/distutils/README similarity index 100% rename from Src/StdLib/Lib/distutils/README rename to Src.GetRenamed/StdLib/Lib/distutils/README diff --git a/Src/StdLib/Lib/distutils/__init__.py b/Src.GetRenamed/StdLib/Lib/distutils/__init__.py similarity index 100% rename from Src/StdLib/Lib/distutils/__init__.py rename to Src.GetRenamed/StdLib/Lib/distutils/__init__.py diff --git a/Src/StdLib/Lib/distutils/archive_util.py b/Src.GetRenamed/StdLib/Lib/distutils/archive_util.py similarity index 100% rename from Src/StdLib/Lib/distutils/archive_util.py rename to Src.GetRenamed/StdLib/Lib/distutils/archive_util.py diff --git a/Src/StdLib/Lib/distutils/bcppcompiler.py b/Src.GetRenamed/StdLib/Lib/distutils/bcppcompiler.py similarity index 100% rename from Src/StdLib/Lib/distutils/bcppcompiler.py rename to Src.GetRenamed/StdLib/Lib/distutils/bcppcompiler.py diff --git a/Src/StdLib/Lib/distutils/ccompiler.py b/Src.GetRenamed/StdLib/Lib/distutils/ccompiler.py similarity index 100% rename from Src/StdLib/Lib/distutils/ccompiler.py rename to Src.GetRenamed/StdLib/Lib/distutils/ccompiler.py diff --git a/Src/StdLib/Lib/distutils/cmd.py b/Src.GetRenamed/StdLib/Lib/distutils/cmd.py similarity index 100% rename from Src/StdLib/Lib/distutils/cmd.py rename to Src.GetRenamed/StdLib/Lib/distutils/cmd.py diff --git a/Src/StdLib/Lib/distutils/command/__init__.py b/Src.GetRenamed/StdLib/Lib/distutils/command/__init__.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/__init__.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/__init__.py diff --git a/Src/StdLib/Lib/distutils/command/bdist.py b/Src.GetRenamed/StdLib/Lib/distutils/command/bdist.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/bdist.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/bdist.py diff --git a/Src/StdLib/Lib/distutils/command/bdist_dumb.py b/Src.GetRenamed/StdLib/Lib/distutils/command/bdist_dumb.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/bdist_dumb.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/bdist_dumb.py diff --git a/Src/StdLib/Lib/distutils/command/bdist_msi.py b/Src.GetRenamed/StdLib/Lib/distutils/command/bdist_msi.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/bdist_msi.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/bdist_msi.py diff --git a/Src/StdLib/Lib/distutils/command/bdist_rpm.py b/Src.GetRenamed/StdLib/Lib/distutils/command/bdist_rpm.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/bdist_rpm.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/bdist_rpm.py diff --git a/Src/StdLib/Lib/distutils/command/bdist_wininst.py b/Src.GetRenamed/StdLib/Lib/distutils/command/bdist_wininst.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/bdist_wininst.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/bdist_wininst.py diff --git a/Src/StdLib/Lib/distutils/command/build.py b/Src.GetRenamed/StdLib/Lib/distutils/command/build.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/build.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/build.py diff --git a/Src/StdLib/Lib/distutils/command/build_clib.py b/Src.GetRenamed/StdLib/Lib/distutils/command/build_clib.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/build_clib.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/build_clib.py diff --git a/Src/StdLib/Lib/distutils/command/build_ext.py b/Src.GetRenamed/StdLib/Lib/distutils/command/build_ext.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/build_ext.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/build_ext.py diff --git a/Src/StdLib/Lib/distutils/command/build_py.py b/Src.GetRenamed/StdLib/Lib/distutils/command/build_py.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/build_py.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/build_py.py diff --git a/Src/StdLib/Lib/distutils/command/build_scripts.py b/Src.GetRenamed/StdLib/Lib/distutils/command/build_scripts.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/build_scripts.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/build_scripts.py diff --git a/Src/StdLib/Lib/distutils/command/check.py b/Src.GetRenamed/StdLib/Lib/distutils/command/check.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/check.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/check.py diff --git a/Src/StdLib/Lib/distutils/command/clean.py b/Src.GetRenamed/StdLib/Lib/distutils/command/clean.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/clean.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/clean.py diff --git a/Src/StdLib/Lib/distutils/command/command_template b/Src.GetRenamed/StdLib/Lib/distutils/command/command_template similarity index 100% rename from Src/StdLib/Lib/distutils/command/command_template rename to Src.GetRenamed/StdLib/Lib/distutils/command/command_template diff --git a/Src/StdLib/Lib/distutils/command/config.py b/Src.GetRenamed/StdLib/Lib/distutils/command/config.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/config.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/config.py diff --git a/Src/StdLib/Lib/distutils/command/install.py b/Src.GetRenamed/StdLib/Lib/distutils/command/install.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/install.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/install.py diff --git a/Src/StdLib/Lib/distutils/command/install_data.py b/Src.GetRenamed/StdLib/Lib/distutils/command/install_data.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/install_data.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/install_data.py diff --git a/Src/StdLib/Lib/distutils/command/install_egg_info.py b/Src.GetRenamed/StdLib/Lib/distutils/command/install_egg_info.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/install_egg_info.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/install_egg_info.py diff --git a/Src/StdLib/Lib/distutils/command/install_headers.py b/Src.GetRenamed/StdLib/Lib/distutils/command/install_headers.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/install_headers.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/install_headers.py diff --git a/Src/StdLib/Lib/distutils/command/install_lib.py b/Src.GetRenamed/StdLib/Lib/distutils/command/install_lib.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/install_lib.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/install_lib.py diff --git a/Src/StdLib/Lib/distutils/command/install_scripts.py b/Src.GetRenamed/StdLib/Lib/distutils/command/install_scripts.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/install_scripts.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/install_scripts.py diff --git a/Src/StdLib/Lib/distutils/command/register.py b/Src.GetRenamed/StdLib/Lib/distutils/command/register.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/register.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/register.py diff --git a/Src/StdLib/Lib/distutils/command/sdist.py b/Src.GetRenamed/StdLib/Lib/distutils/command/sdist.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/sdist.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/sdist.py diff --git a/Src/StdLib/Lib/distutils/command/upload.py b/Src.GetRenamed/StdLib/Lib/distutils/command/upload.py similarity index 100% rename from Src/StdLib/Lib/distutils/command/upload.py rename to Src.GetRenamed/StdLib/Lib/distutils/command/upload.py diff --git a/Src/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe b/Src.GetRenamed/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe similarity index 100% rename from Src/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe rename to Src.GetRenamed/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe diff --git a/Src/StdLib/Lib/distutils/command/wininst-10.0.exe b/Src.GetRenamed/StdLib/Lib/distutils/command/wininst-10.0.exe similarity index 100% rename from Src/StdLib/Lib/distutils/command/wininst-10.0.exe rename to Src.GetRenamed/StdLib/Lib/distutils/command/wininst-10.0.exe diff --git a/Src/StdLib/Lib/distutils/command/wininst-6.0.exe b/Src.GetRenamed/StdLib/Lib/distutils/command/wininst-6.0.exe similarity index 100% rename from Src/StdLib/Lib/distutils/command/wininst-6.0.exe rename to Src.GetRenamed/StdLib/Lib/distutils/command/wininst-6.0.exe diff --git a/Src/StdLib/Lib/distutils/command/wininst-7.1.exe b/Src.GetRenamed/StdLib/Lib/distutils/command/wininst-7.1.exe similarity index 100% rename from Src/StdLib/Lib/distutils/command/wininst-7.1.exe rename to Src.GetRenamed/StdLib/Lib/distutils/command/wininst-7.1.exe diff --git a/Src/StdLib/Lib/distutils/command/wininst-8.0.exe b/Src.GetRenamed/StdLib/Lib/distutils/command/wininst-8.0.exe similarity index 100% rename from Src/StdLib/Lib/distutils/command/wininst-8.0.exe rename to Src.GetRenamed/StdLib/Lib/distutils/command/wininst-8.0.exe diff --git a/Src/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe b/Src.GetRenamed/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe similarity index 100% rename from Src/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe rename to Src.GetRenamed/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe diff --git a/Src/StdLib/Lib/distutils/command/wininst-9.0.exe b/Src.GetRenamed/StdLib/Lib/distutils/command/wininst-9.0.exe similarity index 100% rename from Src/StdLib/Lib/distutils/command/wininst-9.0.exe rename to Src.GetRenamed/StdLib/Lib/distutils/command/wininst-9.0.exe diff --git a/Src/StdLib/Lib/distutils/config.py b/Src.GetRenamed/StdLib/Lib/distutils/config.py similarity index 100% rename from Src/StdLib/Lib/distutils/config.py rename to Src.GetRenamed/StdLib/Lib/distutils/config.py diff --git a/Src/StdLib/Lib/distutils/core.py b/Src.GetRenamed/StdLib/Lib/distutils/core.py similarity index 100% rename from Src/StdLib/Lib/distutils/core.py rename to Src.GetRenamed/StdLib/Lib/distutils/core.py diff --git a/Src/StdLib/Lib/distutils/cygwinccompiler.py b/Src.GetRenamed/StdLib/Lib/distutils/cygwinccompiler.py similarity index 100% rename from Src/StdLib/Lib/distutils/cygwinccompiler.py rename to Src.GetRenamed/StdLib/Lib/distutils/cygwinccompiler.py diff --git a/Src/StdLib/Lib/distutils/debug.py b/Src.GetRenamed/StdLib/Lib/distutils/debug.py similarity index 100% rename from Src/StdLib/Lib/distutils/debug.py rename to Src.GetRenamed/StdLib/Lib/distutils/debug.py diff --git a/Src/StdLib/Lib/distutils/dep_util.py b/Src.GetRenamed/StdLib/Lib/distutils/dep_util.py similarity index 100% rename from Src/StdLib/Lib/distutils/dep_util.py rename to Src.GetRenamed/StdLib/Lib/distutils/dep_util.py diff --git a/Src/StdLib/Lib/distutils/dir_util.py b/Src.GetRenamed/StdLib/Lib/distutils/dir_util.py similarity index 100% rename from Src/StdLib/Lib/distutils/dir_util.py rename to Src.GetRenamed/StdLib/Lib/distutils/dir_util.py diff --git a/Src/StdLib/Lib/distutils/dist.py b/Src.GetRenamed/StdLib/Lib/distutils/dist.py similarity index 100% rename from Src/StdLib/Lib/distutils/dist.py rename to Src.GetRenamed/StdLib/Lib/distutils/dist.py diff --git a/Src/StdLib/Lib/distutils/errors.py b/Src.GetRenamed/StdLib/Lib/distutils/errors.py similarity index 100% rename from Src/StdLib/Lib/distutils/errors.py rename to Src.GetRenamed/StdLib/Lib/distutils/errors.py diff --git a/Src/StdLib/Lib/distutils/extension.py b/Src.GetRenamed/StdLib/Lib/distutils/extension.py similarity index 100% rename from Src/StdLib/Lib/distutils/extension.py rename to Src.GetRenamed/StdLib/Lib/distutils/extension.py diff --git a/Src/StdLib/Lib/distutils/fancy_getopt.py b/Src.GetRenamed/StdLib/Lib/distutils/fancy_getopt.py similarity index 100% rename from Src/StdLib/Lib/distutils/fancy_getopt.py rename to Src.GetRenamed/StdLib/Lib/distutils/fancy_getopt.py diff --git a/Src/StdLib/Lib/distutils/file_util.py b/Src.GetRenamed/StdLib/Lib/distutils/file_util.py similarity index 100% rename from Src/StdLib/Lib/distutils/file_util.py rename to Src.GetRenamed/StdLib/Lib/distutils/file_util.py diff --git a/Src/StdLib/Lib/distutils/filelist.py b/Src.GetRenamed/StdLib/Lib/distutils/filelist.py similarity index 100% rename from Src/StdLib/Lib/distutils/filelist.py rename to Src.GetRenamed/StdLib/Lib/distutils/filelist.py diff --git a/Src/StdLib/Lib/distutils/log.py b/Src.GetRenamed/StdLib/Lib/distutils/log.py similarity index 100% rename from Src/StdLib/Lib/distutils/log.py rename to Src.GetRenamed/StdLib/Lib/distutils/log.py diff --git a/Src/StdLib/Lib/distutils/msvc9compiler.py b/Src.GetRenamed/StdLib/Lib/distutils/msvc9compiler.py similarity index 100% rename from Src/StdLib/Lib/distutils/msvc9compiler.py rename to Src.GetRenamed/StdLib/Lib/distutils/msvc9compiler.py diff --git a/Src/StdLib/Lib/distutils/msvccompiler.py b/Src.GetRenamed/StdLib/Lib/distutils/msvccompiler.py similarity index 100% rename from Src/StdLib/Lib/distutils/msvccompiler.py rename to Src.GetRenamed/StdLib/Lib/distutils/msvccompiler.py diff --git a/Src/StdLib/Lib/distutils/spawn.py b/Src.GetRenamed/StdLib/Lib/distutils/spawn.py similarity index 100% rename from Src/StdLib/Lib/distutils/spawn.py rename to Src.GetRenamed/StdLib/Lib/distutils/spawn.py diff --git a/Src/StdLib/Lib/distutils/sysconfig.py b/Src.GetRenamed/StdLib/Lib/distutils/sysconfig.py similarity index 100% rename from Src/StdLib/Lib/distutils/sysconfig.py rename to Src.GetRenamed/StdLib/Lib/distutils/sysconfig.py diff --git a/Src/StdLib/Lib/distutils/tests/Setup.sample b/Src.GetRenamed/StdLib/Lib/distutils/tests/Setup.sample similarity index 100% rename from Src/StdLib/Lib/distutils/tests/Setup.sample rename to Src.GetRenamed/StdLib/Lib/distutils/tests/Setup.sample diff --git a/Src/StdLib/Lib/distutils/tests/__init__.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/__init__.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/__init__.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/__init__.py diff --git a/Src/StdLib/Lib/distutils/tests/support.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/support.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/support.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/support.py diff --git a/Src/StdLib/Lib/distutils/tests/test_archive_util.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_archive_util.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_archive_util.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_archive_util.py diff --git a/Src/StdLib/Lib/distutils/tests/test_bdist.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_bdist.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_bdist.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_bdist.py diff --git a/Src/StdLib/Lib/distutils/tests/test_bdist_dumb.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_bdist_dumb.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_bdist_dumb.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_bdist_dumb.py diff --git a/Src/StdLib/Lib/distutils/tests/test_bdist_msi.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_bdist_msi.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_bdist_msi.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_bdist_msi.py diff --git a/Src/StdLib/Lib/distutils/tests/test_bdist_rpm.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_bdist_rpm.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_bdist_rpm.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_bdist_rpm.py diff --git a/Src/StdLib/Lib/distutils/tests/test_bdist_wininst.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_bdist_wininst.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_bdist_wininst.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_bdist_wininst.py diff --git a/Src/StdLib/Lib/distutils/tests/test_build.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_build.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_build.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_build.py diff --git a/Src/StdLib/Lib/distutils/tests/test_build_clib.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_build_clib.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_build_clib.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_build_clib.py diff --git a/Src/StdLib/Lib/distutils/tests/test_build_ext.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_build_ext.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_build_ext.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_build_ext.py diff --git a/Src/StdLib/Lib/distutils/tests/test_build_py.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_build_py.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_build_py.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_build_py.py diff --git a/Src/StdLib/Lib/distutils/tests/test_build_scripts.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_build_scripts.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_build_scripts.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_build_scripts.py diff --git a/Src/StdLib/Lib/distutils/tests/test_check.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_check.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_check.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_check.py diff --git a/Src/StdLib/Lib/distutils/tests/test_clean.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_clean.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_clean.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_clean.py diff --git a/Src/StdLib/Lib/distutils/tests/test_cmd.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_cmd.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_cmd.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_cmd.py diff --git a/Src/StdLib/Lib/distutils/tests/test_config.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_config.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_config.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_config.py diff --git a/Src/StdLib/Lib/distutils/tests/test_config_cmd.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_config_cmd.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_config_cmd.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_config_cmd.py diff --git a/Src/StdLib/Lib/distutils/tests/test_core.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_core.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_core.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_core.py diff --git a/Src/StdLib/Lib/distutils/tests/test_cygwinccompiler.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_cygwinccompiler.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_cygwinccompiler.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_cygwinccompiler.py diff --git a/Src/StdLib/Lib/distutils/tests/test_dep_util.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_dep_util.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_dep_util.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_dep_util.py diff --git a/Src/StdLib/Lib/distutils/tests/test_dir_util.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_dir_util.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_dir_util.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_dir_util.py diff --git a/Src/StdLib/Lib/distutils/tests/test_dist.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_dist.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_dist.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_dist.py diff --git a/Src/StdLib/Lib/distutils/tests/test_extension.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_extension.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_extension.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_extension.py diff --git a/Src/StdLib/Lib/distutils/tests/test_file_util.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_file_util.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_file_util.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_file_util.py diff --git a/Src/StdLib/Lib/distutils/tests/test_filelist.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_filelist.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_filelist.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_filelist.py diff --git a/Src/StdLib/Lib/distutils/tests/test_install.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_install.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_install.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_install.py diff --git a/Src/StdLib/Lib/distutils/tests/test_install_data.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_install_data.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_install_data.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_install_data.py diff --git a/Src/StdLib/Lib/distutils/tests/test_install_headers.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_install_headers.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_install_headers.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_install_headers.py diff --git a/Src/StdLib/Lib/distutils/tests/test_install_lib.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_install_lib.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_install_lib.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_install_lib.py diff --git a/Src/StdLib/Lib/distutils/tests/test_install_scripts.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_install_scripts.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_install_scripts.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_install_scripts.py diff --git a/Src/StdLib/Lib/distutils/tests/test_log.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_log.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_log.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_log.py diff --git a/Src/StdLib/Lib/distutils/tests/test_msvc9compiler.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_msvc9compiler.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_msvc9compiler.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_msvc9compiler.py diff --git a/Src/StdLib/Lib/distutils/tests/test_register.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_register.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_register.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_register.py diff --git a/Src/StdLib/Lib/distutils/tests/test_sdist.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_sdist.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_sdist.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_sdist.py diff --git a/Src/StdLib/Lib/distutils/tests/test_spawn.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_spawn.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_spawn.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_spawn.py diff --git a/Src/StdLib/Lib/distutils/tests/test_sysconfig.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_sysconfig.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_sysconfig.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_sysconfig.py diff --git a/Src/StdLib/Lib/distutils/tests/test_text_file.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_text_file.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_text_file.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_text_file.py diff --git a/Src/StdLib/Lib/distutils/tests/test_unixccompiler.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_unixccompiler.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_unixccompiler.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_unixccompiler.py diff --git a/Src/StdLib/Lib/distutils/tests/test_upload.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_upload.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_upload.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_upload.py diff --git a/Src/StdLib/Lib/distutils/tests/test_util.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_util.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_util.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_util.py diff --git a/Src/StdLib/Lib/distutils/tests/test_version.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_version.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_version.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_version.py diff --git a/Src/StdLib/Lib/distutils/tests/test_versionpredicate.py b/Src.GetRenamed/StdLib/Lib/distutils/tests/test_versionpredicate.py similarity index 100% rename from Src/StdLib/Lib/distutils/tests/test_versionpredicate.py rename to Src.GetRenamed/StdLib/Lib/distutils/tests/test_versionpredicate.py diff --git a/Src/StdLib/Lib/distutils/text_file.py b/Src.GetRenamed/StdLib/Lib/distutils/text_file.py similarity index 100% rename from Src/StdLib/Lib/distutils/text_file.py rename to Src.GetRenamed/StdLib/Lib/distutils/text_file.py diff --git a/Src/StdLib/Lib/distutils/unixccompiler.py b/Src.GetRenamed/StdLib/Lib/distutils/unixccompiler.py similarity index 100% rename from Src/StdLib/Lib/distutils/unixccompiler.py rename to Src.GetRenamed/StdLib/Lib/distutils/unixccompiler.py diff --git a/Src/StdLib/Lib/distutils/util.py b/Src.GetRenamed/StdLib/Lib/distutils/util.py similarity index 100% rename from Src/StdLib/Lib/distutils/util.py rename to Src.GetRenamed/StdLib/Lib/distutils/util.py diff --git a/Src/StdLib/Lib/distutils/version.py b/Src.GetRenamed/StdLib/Lib/distutils/version.py similarity index 100% rename from Src/StdLib/Lib/distutils/version.py rename to Src.GetRenamed/StdLib/Lib/distutils/version.py diff --git a/Src/StdLib/Lib/distutils/versionpredicate.py b/Src.GetRenamed/StdLib/Lib/distutils/versionpredicate.py similarity index 100% rename from Src/StdLib/Lib/distutils/versionpredicate.py rename to Src.GetRenamed/StdLib/Lib/distutils/versionpredicate.py diff --git a/Src/StdLib/Lib/doctest.py b/Src.GetRenamed/StdLib/Lib/doctest.py similarity index 100% rename from Src/StdLib/Lib/doctest.py rename to Src.GetRenamed/StdLib/Lib/doctest.py diff --git a/Src/StdLib/Lib/dummy_threading.py b/Src.GetRenamed/StdLib/Lib/dummy_threading.py similarity index 100% rename from Src/StdLib/Lib/dummy_threading.py rename to Src.GetRenamed/StdLib/Lib/dummy_threading.py diff --git a/Src/StdLib/Lib/email/__init__.py b/Src.GetRenamed/StdLib/Lib/email/__init__.py similarity index 100% rename from Src/StdLib/Lib/email/__init__.py rename to Src.GetRenamed/StdLib/Lib/email/__init__.py diff --git a/Src/StdLib/Lib/email/_encoded_words.py b/Src.GetRenamed/StdLib/Lib/email/_encoded_words.py similarity index 100% rename from Src/StdLib/Lib/email/_encoded_words.py rename to Src.GetRenamed/StdLib/Lib/email/_encoded_words.py diff --git a/Src/StdLib/Lib/email/_header_value_parser.py b/Src.GetRenamed/StdLib/Lib/email/_header_value_parser.py similarity index 100% rename from Src/StdLib/Lib/email/_header_value_parser.py rename to Src.GetRenamed/StdLib/Lib/email/_header_value_parser.py diff --git a/Src/StdLib/Lib/email/_parseaddr.py b/Src.GetRenamed/StdLib/Lib/email/_parseaddr.py similarity index 100% rename from Src/StdLib/Lib/email/_parseaddr.py rename to Src.GetRenamed/StdLib/Lib/email/_parseaddr.py diff --git a/Src/StdLib/Lib/email/_policybase.py b/Src.GetRenamed/StdLib/Lib/email/_policybase.py similarity index 100% rename from Src/StdLib/Lib/email/_policybase.py rename to Src.GetRenamed/StdLib/Lib/email/_policybase.py diff --git a/Src/StdLib/Lib/email/architecture.rst b/Src.GetRenamed/StdLib/Lib/email/architecture.rst similarity index 100% rename from Src/StdLib/Lib/email/architecture.rst rename to Src.GetRenamed/StdLib/Lib/email/architecture.rst diff --git a/Src/StdLib/Lib/email/base64mime.py b/Src.GetRenamed/StdLib/Lib/email/base64mime.py similarity index 100% rename from Src/StdLib/Lib/email/base64mime.py rename to Src.GetRenamed/StdLib/Lib/email/base64mime.py diff --git a/Src/StdLib/Lib/email/charset.py b/Src.GetRenamed/StdLib/Lib/email/charset.py similarity index 100% rename from Src/StdLib/Lib/email/charset.py rename to Src.GetRenamed/StdLib/Lib/email/charset.py diff --git a/Src/StdLib/Lib/email/contentmanager.py b/Src.GetRenamed/StdLib/Lib/email/contentmanager.py similarity index 100% rename from Src/StdLib/Lib/email/contentmanager.py rename to Src.GetRenamed/StdLib/Lib/email/contentmanager.py diff --git a/Src/StdLib/Lib/email/encoders.py b/Src.GetRenamed/StdLib/Lib/email/encoders.py similarity index 100% rename from Src/StdLib/Lib/email/encoders.py rename to Src.GetRenamed/StdLib/Lib/email/encoders.py diff --git a/Src/StdLib/Lib/email/errors.py b/Src.GetRenamed/StdLib/Lib/email/errors.py similarity index 100% rename from Src/StdLib/Lib/email/errors.py rename to Src.GetRenamed/StdLib/Lib/email/errors.py diff --git a/Src/StdLib/Lib/email/feedparser.py b/Src.GetRenamed/StdLib/Lib/email/feedparser.py similarity index 100% rename from Src/StdLib/Lib/email/feedparser.py rename to Src.GetRenamed/StdLib/Lib/email/feedparser.py diff --git a/Src/StdLib/Lib/email/generator.py b/Src.GetRenamed/StdLib/Lib/email/generator.py similarity index 100% rename from Src/StdLib/Lib/email/generator.py rename to Src.GetRenamed/StdLib/Lib/email/generator.py diff --git a/Src/StdLib/Lib/email/header.py b/Src.GetRenamed/StdLib/Lib/email/header.py similarity index 100% rename from Src/StdLib/Lib/email/header.py rename to Src.GetRenamed/StdLib/Lib/email/header.py diff --git a/Src/StdLib/Lib/email/headerregistry.py b/Src.GetRenamed/StdLib/Lib/email/headerregistry.py similarity index 100% rename from Src/StdLib/Lib/email/headerregistry.py rename to Src.GetRenamed/StdLib/Lib/email/headerregistry.py diff --git a/Src/StdLib/Lib/email/iterators.py b/Src.GetRenamed/StdLib/Lib/email/iterators.py similarity index 100% rename from Src/StdLib/Lib/email/iterators.py rename to Src.GetRenamed/StdLib/Lib/email/iterators.py diff --git a/Src/StdLib/Lib/email/message.py b/Src.GetRenamed/StdLib/Lib/email/message.py similarity index 100% rename from Src/StdLib/Lib/email/message.py rename to Src.GetRenamed/StdLib/Lib/email/message.py diff --git a/PythonTests/compat/sbs_exceptions/__init__.py b/Src.GetRenamed/StdLib/Lib/email/mime/__init__.py similarity index 100% rename from PythonTests/compat/sbs_exceptions/__init__.py rename to Src.GetRenamed/StdLib/Lib/email/mime/__init__.py diff --git a/Src/StdLib/Lib/email/mime/application.py b/Src.GetRenamed/StdLib/Lib/email/mime/application.py similarity index 100% rename from Src/StdLib/Lib/email/mime/application.py rename to Src.GetRenamed/StdLib/Lib/email/mime/application.py diff --git a/Src/StdLib/Lib/email/mime/audio.py b/Src.GetRenamed/StdLib/Lib/email/mime/audio.py similarity index 100% rename from Src/StdLib/Lib/email/mime/audio.py rename to Src.GetRenamed/StdLib/Lib/email/mime/audio.py diff --git a/Src/StdLib/Lib/email/mime/base.py b/Src.GetRenamed/StdLib/Lib/email/mime/base.py similarity index 100% rename from Src/StdLib/Lib/email/mime/base.py rename to Src.GetRenamed/StdLib/Lib/email/mime/base.py diff --git a/Src/StdLib/Lib/email/mime/image.py b/Src.GetRenamed/StdLib/Lib/email/mime/image.py similarity index 100% rename from Src/StdLib/Lib/email/mime/image.py rename to Src.GetRenamed/StdLib/Lib/email/mime/image.py diff --git a/Src/StdLib/Lib/email/mime/message.py b/Src.GetRenamed/StdLib/Lib/email/mime/message.py similarity index 100% rename from Src/StdLib/Lib/email/mime/message.py rename to Src.GetRenamed/StdLib/Lib/email/mime/message.py diff --git a/Src/StdLib/Lib/email/mime/multipart.py b/Src.GetRenamed/StdLib/Lib/email/mime/multipart.py similarity index 100% rename from Src/StdLib/Lib/email/mime/multipart.py rename to Src.GetRenamed/StdLib/Lib/email/mime/multipart.py diff --git a/Src/StdLib/Lib/email/mime/nonmultipart.py b/Src.GetRenamed/StdLib/Lib/email/mime/nonmultipart.py similarity index 100% rename from Src/StdLib/Lib/email/mime/nonmultipart.py rename to Src.GetRenamed/StdLib/Lib/email/mime/nonmultipart.py diff --git a/Src/StdLib/Lib/email/mime/text.py b/Src.GetRenamed/StdLib/Lib/email/mime/text.py similarity index 100% rename from Src/StdLib/Lib/email/mime/text.py rename to Src.GetRenamed/StdLib/Lib/email/mime/text.py diff --git a/Src/StdLib/Lib/email/parser.py b/Src.GetRenamed/StdLib/Lib/email/parser.py similarity index 100% rename from Src/StdLib/Lib/email/parser.py rename to Src.GetRenamed/StdLib/Lib/email/parser.py diff --git a/Src/StdLib/Lib/email/policy.py b/Src.GetRenamed/StdLib/Lib/email/policy.py similarity index 100% rename from Src/StdLib/Lib/email/policy.py rename to Src.GetRenamed/StdLib/Lib/email/policy.py diff --git a/Src/StdLib/Lib/email/quoprimime.py b/Src.GetRenamed/StdLib/Lib/email/quoprimime.py similarity index 100% rename from Src/StdLib/Lib/email/quoprimime.py rename to Src.GetRenamed/StdLib/Lib/email/quoprimime.py diff --git a/Src/StdLib/Lib/email/utils.py b/Src.GetRenamed/StdLib/Lib/email/utils.py similarity index 100% rename from Src/StdLib/Lib/email/utils.py rename to Src.GetRenamed/StdLib/Lib/email/utils.py diff --git a/Src/StdLib/Lib/encodings/__init__.py b/Src.GetRenamed/StdLib/Lib/encodings/__init__.py similarity index 100% rename from Src/StdLib/Lib/encodings/__init__.py rename to Src.GetRenamed/StdLib/Lib/encodings/__init__.py diff --git a/Src/StdLib/Lib/encodings/aliases.py b/Src.GetRenamed/StdLib/Lib/encodings/aliases.py similarity index 100% rename from Src/StdLib/Lib/encodings/aliases.py rename to Src.GetRenamed/StdLib/Lib/encodings/aliases.py diff --git a/Src/StdLib/Lib/encodings/ascii.py b/Src.GetRenamed/StdLib/Lib/encodings/ascii.py similarity index 100% rename from Src/StdLib/Lib/encodings/ascii.py rename to Src.GetRenamed/StdLib/Lib/encodings/ascii.py diff --git a/Src/StdLib/Lib/encodings/base64_codec.py b/Src.GetRenamed/StdLib/Lib/encodings/base64_codec.py similarity index 100% rename from Src/StdLib/Lib/encodings/base64_codec.py rename to Src.GetRenamed/StdLib/Lib/encodings/base64_codec.py diff --git a/Src/StdLib/Lib/encodings/big5.py b/Src.GetRenamed/StdLib/Lib/encodings/big5.py similarity index 100% rename from Src/StdLib/Lib/encodings/big5.py rename to Src.GetRenamed/StdLib/Lib/encodings/big5.py diff --git a/Src/StdLib/Lib/encodings/big5hkscs.py b/Src.GetRenamed/StdLib/Lib/encodings/big5hkscs.py similarity index 100% rename from Src/StdLib/Lib/encodings/big5hkscs.py rename to Src.GetRenamed/StdLib/Lib/encodings/big5hkscs.py diff --git a/Src/StdLib/Lib/encodings/bz2_codec.py b/Src.GetRenamed/StdLib/Lib/encodings/bz2_codec.py similarity index 100% rename from Src/StdLib/Lib/encodings/bz2_codec.py rename to Src.GetRenamed/StdLib/Lib/encodings/bz2_codec.py diff --git a/Src/StdLib/Lib/encodings/charmap.py b/Src.GetRenamed/StdLib/Lib/encodings/charmap.py similarity index 100% rename from Src/StdLib/Lib/encodings/charmap.py rename to Src.GetRenamed/StdLib/Lib/encodings/charmap.py diff --git a/Src/StdLib/Lib/encodings/cp037.py b/Src.GetRenamed/StdLib/Lib/encodings/cp037.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp037.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp037.py diff --git a/Src/StdLib/Lib/encodings/cp1006.py b/Src.GetRenamed/StdLib/Lib/encodings/cp1006.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1006.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp1006.py diff --git a/Src/StdLib/Lib/encodings/cp1026.py b/Src.GetRenamed/StdLib/Lib/encodings/cp1026.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1026.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp1026.py diff --git a/Src/StdLib/Lib/encodings/cp1125.py b/Src.GetRenamed/StdLib/Lib/encodings/cp1125.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1125.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp1125.py diff --git a/Src/StdLib/Lib/encodings/cp1140.py b/Src.GetRenamed/StdLib/Lib/encodings/cp1140.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1140.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp1140.py diff --git a/Src/StdLib/Lib/encodings/cp1250.py b/Src.GetRenamed/StdLib/Lib/encodings/cp1250.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1250.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp1250.py diff --git a/Src/StdLib/Lib/encodings/cp1251.py b/Src.GetRenamed/StdLib/Lib/encodings/cp1251.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1251.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp1251.py diff --git a/Src/StdLib/Lib/encodings/cp1252.py b/Src.GetRenamed/StdLib/Lib/encodings/cp1252.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1252.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp1252.py diff --git a/Src/StdLib/Lib/encodings/cp1253.py b/Src.GetRenamed/StdLib/Lib/encodings/cp1253.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1253.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp1253.py diff --git a/Src/StdLib/Lib/encodings/cp1254.py b/Src.GetRenamed/StdLib/Lib/encodings/cp1254.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1254.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp1254.py diff --git a/Src/StdLib/Lib/encodings/cp1255.py b/Src.GetRenamed/StdLib/Lib/encodings/cp1255.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1255.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp1255.py diff --git a/Src/StdLib/Lib/encodings/cp1256.py b/Src.GetRenamed/StdLib/Lib/encodings/cp1256.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1256.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp1256.py diff --git a/Src/StdLib/Lib/encodings/cp1257.py b/Src.GetRenamed/StdLib/Lib/encodings/cp1257.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1257.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp1257.py diff --git a/Src/StdLib/Lib/encodings/cp1258.py b/Src.GetRenamed/StdLib/Lib/encodings/cp1258.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp1258.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp1258.py diff --git a/Src/StdLib/Lib/encodings/cp273.py b/Src.GetRenamed/StdLib/Lib/encodings/cp273.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp273.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp273.py diff --git a/Src/StdLib/Lib/encodings/cp424.py b/Src.GetRenamed/StdLib/Lib/encodings/cp424.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp424.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp424.py diff --git a/Src/StdLib/Lib/encodings/cp437.py b/Src.GetRenamed/StdLib/Lib/encodings/cp437.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp437.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp437.py diff --git a/Src/StdLib/Lib/encodings/cp500.py b/Src.GetRenamed/StdLib/Lib/encodings/cp500.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp500.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp500.py diff --git a/Src/StdLib/Lib/encodings/cp65001.py b/Src.GetRenamed/StdLib/Lib/encodings/cp65001.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp65001.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp65001.py diff --git a/Src/StdLib/Lib/encodings/cp720.py b/Src.GetRenamed/StdLib/Lib/encodings/cp720.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp720.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp720.py diff --git a/Src/StdLib/Lib/encodings/cp737.py b/Src.GetRenamed/StdLib/Lib/encodings/cp737.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp737.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp737.py diff --git a/Src/StdLib/Lib/encodings/cp775.py b/Src.GetRenamed/StdLib/Lib/encodings/cp775.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp775.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp775.py diff --git a/Src/StdLib/Lib/encodings/cp850.py b/Src.GetRenamed/StdLib/Lib/encodings/cp850.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp850.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp850.py diff --git a/Src/StdLib/Lib/encodings/cp852.py b/Src.GetRenamed/StdLib/Lib/encodings/cp852.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp852.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp852.py diff --git a/Src/StdLib/Lib/encodings/cp855.py b/Src.GetRenamed/StdLib/Lib/encodings/cp855.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp855.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp855.py diff --git a/Src/StdLib/Lib/encodings/cp856.py b/Src.GetRenamed/StdLib/Lib/encodings/cp856.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp856.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp856.py diff --git a/Src/StdLib/Lib/encodings/cp857.py b/Src.GetRenamed/StdLib/Lib/encodings/cp857.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp857.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp857.py diff --git a/Src/StdLib/Lib/encodings/cp858.py b/Src.GetRenamed/StdLib/Lib/encodings/cp858.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp858.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp858.py diff --git a/Src/StdLib/Lib/encodings/cp860.py b/Src.GetRenamed/StdLib/Lib/encodings/cp860.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp860.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp860.py diff --git a/Src/StdLib/Lib/encodings/cp861.py b/Src.GetRenamed/StdLib/Lib/encodings/cp861.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp861.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp861.py diff --git a/Src/StdLib/Lib/encodings/cp862.py b/Src.GetRenamed/StdLib/Lib/encodings/cp862.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp862.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp862.py diff --git a/Src/StdLib/Lib/encodings/cp863.py b/Src.GetRenamed/StdLib/Lib/encodings/cp863.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp863.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp863.py diff --git a/Src/StdLib/Lib/encodings/cp864.py b/Src.GetRenamed/StdLib/Lib/encodings/cp864.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp864.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp864.py diff --git a/Src/StdLib/Lib/encodings/cp865.py b/Src.GetRenamed/StdLib/Lib/encodings/cp865.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp865.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp865.py diff --git a/Src/StdLib/Lib/encodings/cp866.py b/Src.GetRenamed/StdLib/Lib/encodings/cp866.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp866.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp866.py diff --git a/Src/StdLib/Lib/encodings/cp869.py b/Src.GetRenamed/StdLib/Lib/encodings/cp869.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp869.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp869.py diff --git a/Src/StdLib/Lib/encodings/cp874.py b/Src.GetRenamed/StdLib/Lib/encodings/cp874.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp874.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp874.py diff --git a/Src/StdLib/Lib/encodings/cp875.py b/Src.GetRenamed/StdLib/Lib/encodings/cp875.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp875.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp875.py diff --git a/Src/StdLib/Lib/encodings/cp932.py b/Src.GetRenamed/StdLib/Lib/encodings/cp932.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp932.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp932.py diff --git a/Src/StdLib/Lib/encodings/cp949.py b/Src.GetRenamed/StdLib/Lib/encodings/cp949.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp949.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp949.py diff --git a/Src/StdLib/Lib/encodings/cp950.py b/Src.GetRenamed/StdLib/Lib/encodings/cp950.py similarity index 100% rename from Src/StdLib/Lib/encodings/cp950.py rename to Src.GetRenamed/StdLib/Lib/encodings/cp950.py diff --git a/Src/StdLib/Lib/encodings/euc_jis_2004.py b/Src.GetRenamed/StdLib/Lib/encodings/euc_jis_2004.py similarity index 100% rename from Src/StdLib/Lib/encodings/euc_jis_2004.py rename to Src.GetRenamed/StdLib/Lib/encodings/euc_jis_2004.py diff --git a/Src/StdLib/Lib/encodings/euc_jisx0213.py b/Src.GetRenamed/StdLib/Lib/encodings/euc_jisx0213.py similarity index 100% rename from Src/StdLib/Lib/encodings/euc_jisx0213.py rename to Src.GetRenamed/StdLib/Lib/encodings/euc_jisx0213.py diff --git a/Src/StdLib/Lib/encodings/euc_jp.py b/Src.GetRenamed/StdLib/Lib/encodings/euc_jp.py similarity index 100% rename from Src/StdLib/Lib/encodings/euc_jp.py rename to Src.GetRenamed/StdLib/Lib/encodings/euc_jp.py diff --git a/Src/StdLib/Lib/encodings/euc_kr.py b/Src.GetRenamed/StdLib/Lib/encodings/euc_kr.py similarity index 100% rename from Src/StdLib/Lib/encodings/euc_kr.py rename to Src.GetRenamed/StdLib/Lib/encodings/euc_kr.py diff --git a/Src/StdLib/Lib/encodings/gb18030.py b/Src.GetRenamed/StdLib/Lib/encodings/gb18030.py similarity index 100% rename from Src/StdLib/Lib/encodings/gb18030.py rename to Src.GetRenamed/StdLib/Lib/encodings/gb18030.py diff --git a/Src/StdLib/Lib/encodings/gb2312.py b/Src.GetRenamed/StdLib/Lib/encodings/gb2312.py similarity index 100% rename from Src/StdLib/Lib/encodings/gb2312.py rename to Src.GetRenamed/StdLib/Lib/encodings/gb2312.py diff --git a/Src/StdLib/Lib/encodings/gbk.py b/Src.GetRenamed/StdLib/Lib/encodings/gbk.py similarity index 100% rename from Src/StdLib/Lib/encodings/gbk.py rename to Src.GetRenamed/StdLib/Lib/encodings/gbk.py diff --git a/Src/StdLib/Lib/encodings/hex_codec.py b/Src.GetRenamed/StdLib/Lib/encodings/hex_codec.py similarity index 100% rename from Src/StdLib/Lib/encodings/hex_codec.py rename to Src.GetRenamed/StdLib/Lib/encodings/hex_codec.py diff --git a/Src/StdLib/Lib/encodings/hp_roman8.py b/Src.GetRenamed/StdLib/Lib/encodings/hp_roman8.py similarity index 100% rename from Src/StdLib/Lib/encodings/hp_roman8.py rename to Src.GetRenamed/StdLib/Lib/encodings/hp_roman8.py diff --git a/Src/StdLib/Lib/encodings/hz.py b/Src.GetRenamed/StdLib/Lib/encodings/hz.py similarity index 100% rename from Src/StdLib/Lib/encodings/hz.py rename to Src.GetRenamed/StdLib/Lib/encodings/hz.py diff --git a/Src/StdLib/Lib/encodings/idna.py b/Src.GetRenamed/StdLib/Lib/encodings/idna.py similarity index 100% rename from Src/StdLib/Lib/encodings/idna.py rename to Src.GetRenamed/StdLib/Lib/encodings/idna.py diff --git a/Src/StdLib/Lib/encodings/iso2022_jp.py b/Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso2022_jp.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp.py diff --git a/Src/StdLib/Lib/encodings/iso2022_jp_1.py b/Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp_1.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso2022_jp_1.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp_1.py diff --git a/Src/StdLib/Lib/encodings/iso2022_jp_2.py b/Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp_2.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso2022_jp_2.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp_2.py diff --git a/Src/StdLib/Lib/encodings/iso2022_jp_2004.py b/Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp_2004.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso2022_jp_2004.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp_2004.py diff --git a/Src/StdLib/Lib/encodings/iso2022_jp_3.py b/Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp_3.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso2022_jp_3.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp_3.py diff --git a/Src/StdLib/Lib/encodings/iso2022_jp_ext.py b/Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp_ext.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso2022_jp_ext.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp_ext.py diff --git a/Src/StdLib/Lib/encodings/iso2022_kr.py b/Src.GetRenamed/StdLib/Lib/encodings/iso2022_kr.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso2022_kr.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso2022_kr.py diff --git a/Src/StdLib/Lib/encodings/iso8859_1.py b/Src.GetRenamed/StdLib/Lib/encodings/iso8859_1.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_1.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso8859_1.py diff --git a/Src/StdLib/Lib/encodings/iso8859_10.py b/Src.GetRenamed/StdLib/Lib/encodings/iso8859_10.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_10.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso8859_10.py diff --git a/Src/StdLib/Lib/encodings/iso8859_11.py b/Src.GetRenamed/StdLib/Lib/encodings/iso8859_11.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_11.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso8859_11.py diff --git a/Src/StdLib/Lib/encodings/iso8859_13.py b/Src.GetRenamed/StdLib/Lib/encodings/iso8859_13.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_13.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso8859_13.py diff --git a/Src/StdLib/Lib/encodings/iso8859_14.py b/Src.GetRenamed/StdLib/Lib/encodings/iso8859_14.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_14.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso8859_14.py diff --git a/Src/StdLib/Lib/encodings/iso8859_15.py b/Src.GetRenamed/StdLib/Lib/encodings/iso8859_15.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_15.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso8859_15.py diff --git a/Src/StdLib/Lib/encodings/iso8859_16.py b/Src.GetRenamed/StdLib/Lib/encodings/iso8859_16.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_16.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso8859_16.py diff --git a/Src/StdLib/Lib/encodings/iso8859_2.py b/Src.GetRenamed/StdLib/Lib/encodings/iso8859_2.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_2.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso8859_2.py diff --git a/Src/StdLib/Lib/encodings/iso8859_3.py b/Src.GetRenamed/StdLib/Lib/encodings/iso8859_3.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_3.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso8859_3.py diff --git a/Src/StdLib/Lib/encodings/iso8859_4.py b/Src.GetRenamed/StdLib/Lib/encodings/iso8859_4.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_4.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso8859_4.py diff --git a/Src/StdLib/Lib/encodings/iso8859_5.py b/Src.GetRenamed/StdLib/Lib/encodings/iso8859_5.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_5.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso8859_5.py diff --git a/Src/StdLib/Lib/encodings/iso8859_6.py b/Src.GetRenamed/StdLib/Lib/encodings/iso8859_6.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_6.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso8859_6.py diff --git a/Src/StdLib/Lib/encodings/iso8859_7.py b/Src.GetRenamed/StdLib/Lib/encodings/iso8859_7.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_7.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso8859_7.py diff --git a/Src/StdLib/Lib/encodings/iso8859_8.py b/Src.GetRenamed/StdLib/Lib/encodings/iso8859_8.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_8.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso8859_8.py diff --git a/Src/StdLib/Lib/encodings/iso8859_9.py b/Src.GetRenamed/StdLib/Lib/encodings/iso8859_9.py similarity index 100% rename from Src/StdLib/Lib/encodings/iso8859_9.py rename to Src.GetRenamed/StdLib/Lib/encodings/iso8859_9.py diff --git a/Src/StdLib/Lib/encodings/johab.py b/Src.GetRenamed/StdLib/Lib/encodings/johab.py similarity index 100% rename from Src/StdLib/Lib/encodings/johab.py rename to Src.GetRenamed/StdLib/Lib/encodings/johab.py diff --git a/Src/StdLib/Lib/encodings/koi8_r.py b/Src.GetRenamed/StdLib/Lib/encodings/koi8_r.py similarity index 100% rename from Src/StdLib/Lib/encodings/koi8_r.py rename to Src.GetRenamed/StdLib/Lib/encodings/koi8_r.py diff --git a/Src/StdLib/Lib/encodings/koi8_u.py b/Src.GetRenamed/StdLib/Lib/encodings/koi8_u.py similarity index 100% rename from Src/StdLib/Lib/encodings/koi8_u.py rename to Src.GetRenamed/StdLib/Lib/encodings/koi8_u.py diff --git a/Src/StdLib/Lib/encodings/latin_1.py b/Src.GetRenamed/StdLib/Lib/encodings/latin_1.py similarity index 100% rename from Src/StdLib/Lib/encodings/latin_1.py rename to Src.GetRenamed/StdLib/Lib/encodings/latin_1.py diff --git a/Src/StdLib/Lib/encodings/mac_arabic.py b/Src.GetRenamed/StdLib/Lib/encodings/mac_arabic.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_arabic.py rename to Src.GetRenamed/StdLib/Lib/encodings/mac_arabic.py diff --git a/Src/StdLib/Lib/encodings/mac_centeuro.py b/Src.GetRenamed/StdLib/Lib/encodings/mac_centeuro.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_centeuro.py rename to Src.GetRenamed/StdLib/Lib/encodings/mac_centeuro.py diff --git a/Src/StdLib/Lib/encodings/mac_croatian.py b/Src.GetRenamed/StdLib/Lib/encodings/mac_croatian.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_croatian.py rename to Src.GetRenamed/StdLib/Lib/encodings/mac_croatian.py diff --git a/Src/StdLib/Lib/encodings/mac_cyrillic.py b/Src.GetRenamed/StdLib/Lib/encodings/mac_cyrillic.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_cyrillic.py rename to Src.GetRenamed/StdLib/Lib/encodings/mac_cyrillic.py diff --git a/Src/StdLib/Lib/encodings/mac_farsi.py b/Src.GetRenamed/StdLib/Lib/encodings/mac_farsi.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_farsi.py rename to Src.GetRenamed/StdLib/Lib/encodings/mac_farsi.py diff --git a/Src/StdLib/Lib/encodings/mac_greek.py b/Src.GetRenamed/StdLib/Lib/encodings/mac_greek.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_greek.py rename to Src.GetRenamed/StdLib/Lib/encodings/mac_greek.py diff --git a/Src/StdLib/Lib/encodings/mac_iceland.py b/Src.GetRenamed/StdLib/Lib/encodings/mac_iceland.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_iceland.py rename to Src.GetRenamed/StdLib/Lib/encodings/mac_iceland.py diff --git a/Src/StdLib/Lib/encodings/mac_latin2.py b/Src.GetRenamed/StdLib/Lib/encodings/mac_latin2.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_latin2.py rename to Src.GetRenamed/StdLib/Lib/encodings/mac_latin2.py diff --git a/Src/StdLib/Lib/encodings/mac_roman.py b/Src.GetRenamed/StdLib/Lib/encodings/mac_roman.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_roman.py rename to Src.GetRenamed/StdLib/Lib/encodings/mac_roman.py diff --git a/Src/StdLib/Lib/encodings/mac_romanian.py b/Src.GetRenamed/StdLib/Lib/encodings/mac_romanian.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_romanian.py rename to Src.GetRenamed/StdLib/Lib/encodings/mac_romanian.py diff --git a/Src/StdLib/Lib/encodings/mac_turkish.py b/Src.GetRenamed/StdLib/Lib/encodings/mac_turkish.py similarity index 100% rename from Src/StdLib/Lib/encodings/mac_turkish.py rename to Src.GetRenamed/StdLib/Lib/encodings/mac_turkish.py diff --git a/Src/StdLib/Lib/encodings/mbcs.py b/Src.GetRenamed/StdLib/Lib/encodings/mbcs.py similarity index 100% rename from Src/StdLib/Lib/encodings/mbcs.py rename to Src.GetRenamed/StdLib/Lib/encodings/mbcs.py diff --git a/Src/StdLib/Lib/encodings/palmos.py b/Src.GetRenamed/StdLib/Lib/encodings/palmos.py similarity index 100% rename from Src/StdLib/Lib/encodings/palmos.py rename to Src.GetRenamed/StdLib/Lib/encodings/palmos.py diff --git a/Src/StdLib/Lib/encodings/ptcp154.py b/Src.GetRenamed/StdLib/Lib/encodings/ptcp154.py similarity index 100% rename from Src/StdLib/Lib/encodings/ptcp154.py rename to Src.GetRenamed/StdLib/Lib/encodings/ptcp154.py diff --git a/Src/StdLib/Lib/encodings/punycode.py b/Src.GetRenamed/StdLib/Lib/encodings/punycode.py similarity index 100% rename from Src/StdLib/Lib/encodings/punycode.py rename to Src.GetRenamed/StdLib/Lib/encodings/punycode.py diff --git a/Src/StdLib/Lib/encodings/quopri_codec.py b/Src.GetRenamed/StdLib/Lib/encodings/quopri_codec.py similarity index 100% rename from Src/StdLib/Lib/encodings/quopri_codec.py rename to Src.GetRenamed/StdLib/Lib/encodings/quopri_codec.py diff --git a/Src/StdLib/Lib/encodings/raw_unicode_escape.py b/Src.GetRenamed/StdLib/Lib/encodings/raw_unicode_escape.py similarity index 100% rename from Src/StdLib/Lib/encodings/raw_unicode_escape.py rename to Src.GetRenamed/StdLib/Lib/encodings/raw_unicode_escape.py diff --git a/Src/StdLib/Lib/encodings/rot_13.py b/Src.GetRenamed/StdLib/Lib/encodings/rot_13.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/encodings/rot_13.py rename to Src.GetRenamed/StdLib/Lib/encodings/rot_13.py diff --git a/Src/StdLib/Lib/encodings/shift_jis.py b/Src.GetRenamed/StdLib/Lib/encodings/shift_jis.py similarity index 100% rename from Src/StdLib/Lib/encodings/shift_jis.py rename to Src.GetRenamed/StdLib/Lib/encodings/shift_jis.py diff --git a/Src/StdLib/Lib/encodings/shift_jis_2004.py b/Src.GetRenamed/StdLib/Lib/encodings/shift_jis_2004.py similarity index 100% rename from Src/StdLib/Lib/encodings/shift_jis_2004.py rename to Src.GetRenamed/StdLib/Lib/encodings/shift_jis_2004.py diff --git a/Src/StdLib/Lib/encodings/shift_jisx0213.py b/Src.GetRenamed/StdLib/Lib/encodings/shift_jisx0213.py similarity index 100% rename from Src/StdLib/Lib/encodings/shift_jisx0213.py rename to Src.GetRenamed/StdLib/Lib/encodings/shift_jisx0213.py diff --git a/Src/StdLib/Lib/encodings/tis_620.py b/Src.GetRenamed/StdLib/Lib/encodings/tis_620.py similarity index 100% rename from Src/StdLib/Lib/encodings/tis_620.py rename to Src.GetRenamed/StdLib/Lib/encodings/tis_620.py diff --git a/Src/StdLib/Lib/encodings/undefined.py b/Src.GetRenamed/StdLib/Lib/encodings/undefined.py similarity index 100% rename from Src/StdLib/Lib/encodings/undefined.py rename to Src.GetRenamed/StdLib/Lib/encodings/undefined.py diff --git a/Src/StdLib/Lib/encodings/unicode_escape.py b/Src.GetRenamed/StdLib/Lib/encodings/unicode_escape.py similarity index 100% rename from Src/StdLib/Lib/encodings/unicode_escape.py rename to Src.GetRenamed/StdLib/Lib/encodings/unicode_escape.py diff --git a/Src/StdLib/Lib/encodings/unicode_internal.py b/Src.GetRenamed/StdLib/Lib/encodings/unicode_internal.py similarity index 100% rename from Src/StdLib/Lib/encodings/unicode_internal.py rename to Src.GetRenamed/StdLib/Lib/encodings/unicode_internal.py diff --git a/Src/StdLib/Lib/encodings/utf_16.py b/Src.GetRenamed/StdLib/Lib/encodings/utf_16.py similarity index 100% rename from Src/StdLib/Lib/encodings/utf_16.py rename to Src.GetRenamed/StdLib/Lib/encodings/utf_16.py diff --git a/Src/StdLib/Lib/encodings/utf_16_be.py b/Src.GetRenamed/StdLib/Lib/encodings/utf_16_be.py similarity index 100% rename from Src/StdLib/Lib/encodings/utf_16_be.py rename to Src.GetRenamed/StdLib/Lib/encodings/utf_16_be.py diff --git a/Src/StdLib/Lib/encodings/utf_16_le.py b/Src.GetRenamed/StdLib/Lib/encodings/utf_16_le.py similarity index 100% rename from Src/StdLib/Lib/encodings/utf_16_le.py rename to Src.GetRenamed/StdLib/Lib/encodings/utf_16_le.py diff --git a/Src/StdLib/Lib/encodings/utf_32.py b/Src.GetRenamed/StdLib/Lib/encodings/utf_32.py similarity index 100% rename from Src/StdLib/Lib/encodings/utf_32.py rename to Src.GetRenamed/StdLib/Lib/encodings/utf_32.py diff --git a/Src/StdLib/Lib/encodings/utf_32_be.py b/Src.GetRenamed/StdLib/Lib/encodings/utf_32_be.py similarity index 100% rename from Src/StdLib/Lib/encodings/utf_32_be.py rename to Src.GetRenamed/StdLib/Lib/encodings/utf_32_be.py diff --git a/Src/StdLib/Lib/encodings/utf_32_le.py b/Src.GetRenamed/StdLib/Lib/encodings/utf_32_le.py similarity index 100% rename from Src/StdLib/Lib/encodings/utf_32_le.py rename to Src.GetRenamed/StdLib/Lib/encodings/utf_32_le.py diff --git a/Src/StdLib/Lib/encodings/utf_7.py b/Src.GetRenamed/StdLib/Lib/encodings/utf_7.py similarity index 100% rename from Src/StdLib/Lib/encodings/utf_7.py rename to Src.GetRenamed/StdLib/Lib/encodings/utf_7.py diff --git a/Src/StdLib/Lib/encodings/utf_8.py b/Src.GetRenamed/StdLib/Lib/encodings/utf_8.py similarity index 100% rename from Src/StdLib/Lib/encodings/utf_8.py rename to Src.GetRenamed/StdLib/Lib/encodings/utf_8.py diff --git a/Src/StdLib/Lib/encodings/utf_8_sig.py b/Src.GetRenamed/StdLib/Lib/encodings/utf_8_sig.py similarity index 100% rename from Src/StdLib/Lib/encodings/utf_8_sig.py rename to Src.GetRenamed/StdLib/Lib/encodings/utf_8_sig.py diff --git a/Src/StdLib/Lib/encodings/uu_codec.py b/Src.GetRenamed/StdLib/Lib/encodings/uu_codec.py similarity index 100% rename from Src/StdLib/Lib/encodings/uu_codec.py rename to Src.GetRenamed/StdLib/Lib/encodings/uu_codec.py diff --git a/Src/StdLib/Lib/encodings/zlib_codec.py b/Src.GetRenamed/StdLib/Lib/encodings/zlib_codec.py similarity index 100% rename from Src/StdLib/Lib/encodings/zlib_codec.py rename to Src.GetRenamed/StdLib/Lib/encodings/zlib_codec.py diff --git a/Src/StdLib/Lib/ensurepip/__init__.py b/Src.GetRenamed/StdLib/Lib/ensurepip/__init__.py similarity index 100% rename from Src/StdLib/Lib/ensurepip/__init__.py rename to Src.GetRenamed/StdLib/Lib/ensurepip/__init__.py diff --git a/Src/StdLib/Lib/ensurepip/__main__.py b/Src.GetRenamed/StdLib/Lib/ensurepip/__main__.py similarity index 100% rename from Src/StdLib/Lib/ensurepip/__main__.py rename to Src.GetRenamed/StdLib/Lib/ensurepip/__main__.py diff --git a/Src/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl b/Src.GetRenamed/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl similarity index 100% rename from Src/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl rename to Src.GetRenamed/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl diff --git a/Src/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl b/Src.GetRenamed/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl similarity index 100% rename from Src/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl rename to Src.GetRenamed/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl diff --git a/Src/StdLib/Lib/ensurepip/_uninstall.py b/Src.GetRenamed/StdLib/Lib/ensurepip/_uninstall.py similarity index 100% rename from Src/StdLib/Lib/ensurepip/_uninstall.py rename to Src.GetRenamed/StdLib/Lib/ensurepip/_uninstall.py diff --git a/Src/StdLib/Lib/enum.py b/Src.GetRenamed/StdLib/Lib/enum.py similarity index 100% rename from Src/StdLib/Lib/enum.py rename to Src.GetRenamed/StdLib/Lib/enum.py diff --git a/Src/StdLib/Lib/filecmp.py b/Src.GetRenamed/StdLib/Lib/filecmp.py similarity index 100% rename from Src/StdLib/Lib/filecmp.py rename to Src.GetRenamed/StdLib/Lib/filecmp.py diff --git a/Src/StdLib/Lib/fileinput.py b/Src.GetRenamed/StdLib/Lib/fileinput.py similarity index 100% rename from Src/StdLib/Lib/fileinput.py rename to Src.GetRenamed/StdLib/Lib/fileinput.py diff --git a/Src/StdLib/Lib/fnmatch.py b/Src.GetRenamed/StdLib/Lib/fnmatch.py similarity index 100% rename from Src/StdLib/Lib/fnmatch.py rename to Src.GetRenamed/StdLib/Lib/fnmatch.py diff --git a/Src/StdLib/Lib/formatter.py b/Src.GetRenamed/StdLib/Lib/formatter.py similarity index 100% rename from Src/StdLib/Lib/formatter.py rename to Src.GetRenamed/StdLib/Lib/formatter.py diff --git a/Src/StdLib/Lib/fractions.py b/Src.GetRenamed/StdLib/Lib/fractions.py similarity index 100% rename from Src/StdLib/Lib/fractions.py rename to Src.GetRenamed/StdLib/Lib/fractions.py diff --git a/Src/StdLib/Lib/ftplib.py b/Src.GetRenamed/StdLib/Lib/ftplib.py similarity index 100% rename from Src/StdLib/Lib/ftplib.py rename to Src.GetRenamed/StdLib/Lib/ftplib.py diff --git a/Src/StdLib/Lib/functools.py b/Src.GetRenamed/StdLib/Lib/functools.py similarity index 100% rename from Src/StdLib/Lib/functools.py rename to Src.GetRenamed/StdLib/Lib/functools.py diff --git a/Src/StdLib/Lib/genericpath.py b/Src.GetRenamed/StdLib/Lib/genericpath.py similarity index 100% rename from Src/StdLib/Lib/genericpath.py rename to Src.GetRenamed/StdLib/Lib/genericpath.py diff --git a/Src/StdLib/Lib/getopt.py b/Src.GetRenamed/StdLib/Lib/getopt.py similarity index 100% rename from Src/StdLib/Lib/getopt.py rename to Src.GetRenamed/StdLib/Lib/getopt.py diff --git a/Src/StdLib/Lib/getpass.py b/Src.GetRenamed/StdLib/Lib/getpass.py similarity index 100% rename from Src/StdLib/Lib/getpass.py rename to Src.GetRenamed/StdLib/Lib/getpass.py diff --git a/Src/StdLib/Lib/gettext.py b/Src.GetRenamed/StdLib/Lib/gettext.py similarity index 100% rename from Src/StdLib/Lib/gettext.py rename to Src.GetRenamed/StdLib/Lib/gettext.py diff --git a/Src/StdLib/Lib/glob.py b/Src.GetRenamed/StdLib/Lib/glob.py similarity index 100% rename from Src/StdLib/Lib/glob.py rename to Src.GetRenamed/StdLib/Lib/glob.py diff --git a/Src/StdLib/Lib/gzip.py b/Src.GetRenamed/StdLib/Lib/gzip.py similarity index 100% rename from Src/StdLib/Lib/gzip.py rename to Src.GetRenamed/StdLib/Lib/gzip.py diff --git a/Src/StdLib/Lib/hashlib.py b/Src.GetRenamed/StdLib/Lib/hashlib.py similarity index 100% rename from Src/StdLib/Lib/hashlib.py rename to Src.GetRenamed/StdLib/Lib/hashlib.py diff --git a/Src/StdLib/Lib/heapq.py b/Src.GetRenamed/StdLib/Lib/heapq.py similarity index 100% rename from Src/StdLib/Lib/heapq.py rename to Src.GetRenamed/StdLib/Lib/heapq.py diff --git a/Src/StdLib/Lib/hmac.py b/Src.GetRenamed/StdLib/Lib/hmac.py similarity index 100% rename from Src/StdLib/Lib/hmac.py rename to Src.GetRenamed/StdLib/Lib/hmac.py diff --git a/Src/StdLib/Lib/html/__init__.py b/Src.GetRenamed/StdLib/Lib/html/__init__.py similarity index 100% rename from Src/StdLib/Lib/html/__init__.py rename to Src.GetRenamed/StdLib/Lib/html/__init__.py diff --git a/Src/StdLib/Lib/html/entities.py b/Src.GetRenamed/StdLib/Lib/html/entities.py similarity index 100% rename from Src/StdLib/Lib/html/entities.py rename to Src.GetRenamed/StdLib/Lib/html/entities.py diff --git a/Src/StdLib/Lib/html/parser.py b/Src.GetRenamed/StdLib/Lib/html/parser.py similarity index 100% rename from Src/StdLib/Lib/html/parser.py rename to Src.GetRenamed/StdLib/Lib/html/parser.py diff --git a/Src/StdLib/Lib/http/__init__.py b/Src.GetRenamed/StdLib/Lib/http/__init__.py similarity index 100% rename from Src/StdLib/Lib/http/__init__.py rename to Src.GetRenamed/StdLib/Lib/http/__init__.py diff --git a/Src/StdLib/Lib/http/client.py b/Src.GetRenamed/StdLib/Lib/http/client.py similarity index 100% rename from Src/StdLib/Lib/http/client.py rename to Src.GetRenamed/StdLib/Lib/http/client.py diff --git a/Src/StdLib/Lib/http/cookiejar.py b/Src.GetRenamed/StdLib/Lib/http/cookiejar.py similarity index 100% rename from Src/StdLib/Lib/http/cookiejar.py rename to Src.GetRenamed/StdLib/Lib/http/cookiejar.py diff --git a/Src/StdLib/Lib/http/cookies.py b/Src.GetRenamed/StdLib/Lib/http/cookies.py similarity index 100% rename from Src/StdLib/Lib/http/cookies.py rename to Src.GetRenamed/StdLib/Lib/http/cookies.py diff --git a/Src/StdLib/Lib/http/server.py b/Src.GetRenamed/StdLib/Lib/http/server.py similarity index 100% rename from Src/StdLib/Lib/http/server.py rename to Src.GetRenamed/StdLib/Lib/http/server.py diff --git a/Src/StdLib/Lib/idlelib/AutoComplete.py b/Src.GetRenamed/StdLib/Lib/idlelib/AutoComplete.py similarity index 100% rename from Src/StdLib/Lib/idlelib/AutoComplete.py rename to Src.GetRenamed/StdLib/Lib/idlelib/AutoComplete.py diff --git a/Src/StdLib/Lib/idlelib/AutoCompleteWindow.py b/Src.GetRenamed/StdLib/Lib/idlelib/AutoCompleteWindow.py similarity index 100% rename from Src/StdLib/Lib/idlelib/AutoCompleteWindow.py rename to Src.GetRenamed/StdLib/Lib/idlelib/AutoCompleteWindow.py diff --git a/Src/StdLib/Lib/idlelib/AutoExpand.py b/Src.GetRenamed/StdLib/Lib/idlelib/AutoExpand.py similarity index 100% rename from Src/StdLib/Lib/idlelib/AutoExpand.py rename to Src.GetRenamed/StdLib/Lib/idlelib/AutoExpand.py diff --git a/Src/StdLib/Lib/idlelib/Bindings.py b/Src.GetRenamed/StdLib/Lib/idlelib/Bindings.py similarity index 100% rename from Src/StdLib/Lib/idlelib/Bindings.py rename to Src.GetRenamed/StdLib/Lib/idlelib/Bindings.py diff --git a/Src/StdLib/Lib/idlelib/CREDITS.txt b/Src.GetRenamed/StdLib/Lib/idlelib/CREDITS.txt similarity index 100% rename from Src/StdLib/Lib/idlelib/CREDITS.txt rename to Src.GetRenamed/StdLib/Lib/idlelib/CREDITS.txt diff --git a/Src/StdLib/Lib/idlelib/CallTipWindow.py b/Src.GetRenamed/StdLib/Lib/idlelib/CallTipWindow.py similarity index 100% rename from Src/StdLib/Lib/idlelib/CallTipWindow.py rename to Src.GetRenamed/StdLib/Lib/idlelib/CallTipWindow.py diff --git a/Src/StdLib/Lib/idlelib/CallTips.py b/Src.GetRenamed/StdLib/Lib/idlelib/CallTips.py similarity index 100% rename from Src/StdLib/Lib/idlelib/CallTips.py rename to Src.GetRenamed/StdLib/Lib/idlelib/CallTips.py diff --git a/Src/StdLib/Lib/idlelib/ChangeLog b/Src.GetRenamed/StdLib/Lib/idlelib/ChangeLog similarity index 100% rename from Src/StdLib/Lib/idlelib/ChangeLog rename to Src.GetRenamed/StdLib/Lib/idlelib/ChangeLog diff --git a/Src/StdLib/Lib/idlelib/ClassBrowser.py b/Src.GetRenamed/StdLib/Lib/idlelib/ClassBrowser.py similarity index 100% rename from Src/StdLib/Lib/idlelib/ClassBrowser.py rename to Src.GetRenamed/StdLib/Lib/idlelib/ClassBrowser.py diff --git a/Src/StdLib/Lib/idlelib/CodeContext.py b/Src.GetRenamed/StdLib/Lib/idlelib/CodeContext.py similarity index 100% rename from Src/StdLib/Lib/idlelib/CodeContext.py rename to Src.GetRenamed/StdLib/Lib/idlelib/CodeContext.py diff --git a/Src/StdLib/Lib/idlelib/ColorDelegator.py b/Src.GetRenamed/StdLib/Lib/idlelib/ColorDelegator.py similarity index 100% rename from Src/StdLib/Lib/idlelib/ColorDelegator.py rename to Src.GetRenamed/StdLib/Lib/idlelib/ColorDelegator.py diff --git a/Src/StdLib/Lib/idlelib/Debugger.py b/Src.GetRenamed/StdLib/Lib/idlelib/Debugger.py similarity index 100% rename from Src/StdLib/Lib/idlelib/Debugger.py rename to Src.GetRenamed/StdLib/Lib/idlelib/Debugger.py diff --git a/Src/StdLib/Lib/idlelib/Delegator.py b/Src.GetRenamed/StdLib/Lib/idlelib/Delegator.py similarity index 100% rename from Src/StdLib/Lib/idlelib/Delegator.py rename to Src.GetRenamed/StdLib/Lib/idlelib/Delegator.py diff --git a/Src/StdLib/Lib/idlelib/EditorWindow.py b/Src.GetRenamed/StdLib/Lib/idlelib/EditorWindow.py similarity index 100% rename from Src/StdLib/Lib/idlelib/EditorWindow.py rename to Src.GetRenamed/StdLib/Lib/idlelib/EditorWindow.py diff --git a/Src/StdLib/Lib/idlelib/FileList.py b/Src.GetRenamed/StdLib/Lib/idlelib/FileList.py similarity index 100% rename from Src/StdLib/Lib/idlelib/FileList.py rename to Src.GetRenamed/StdLib/Lib/idlelib/FileList.py diff --git a/Src/StdLib/Lib/idlelib/FormatParagraph.py b/Src.GetRenamed/StdLib/Lib/idlelib/FormatParagraph.py similarity index 100% rename from Src/StdLib/Lib/idlelib/FormatParagraph.py rename to Src.GetRenamed/StdLib/Lib/idlelib/FormatParagraph.py diff --git a/Src/StdLib/Lib/idlelib/GrepDialog.py b/Src.GetRenamed/StdLib/Lib/idlelib/GrepDialog.py similarity index 100% rename from Src/StdLib/Lib/idlelib/GrepDialog.py rename to Src.GetRenamed/StdLib/Lib/idlelib/GrepDialog.py diff --git a/Src/StdLib/Lib/idlelib/HISTORY.txt b/Src.GetRenamed/StdLib/Lib/idlelib/HISTORY.txt similarity index 100% rename from Src/StdLib/Lib/idlelib/HISTORY.txt rename to Src.GetRenamed/StdLib/Lib/idlelib/HISTORY.txt diff --git a/Src/StdLib/Lib/idlelib/HyperParser.py b/Src.GetRenamed/StdLib/Lib/idlelib/HyperParser.py similarity index 100% rename from Src/StdLib/Lib/idlelib/HyperParser.py rename to Src.GetRenamed/StdLib/Lib/idlelib/HyperParser.py diff --git a/Src/StdLib/Lib/idlelib/IOBinding.py b/Src.GetRenamed/StdLib/Lib/idlelib/IOBinding.py similarity index 100% rename from Src/StdLib/Lib/idlelib/IOBinding.py rename to Src.GetRenamed/StdLib/Lib/idlelib/IOBinding.py diff --git a/Src/StdLib/Lib/idlelib/Icons/folder.gif b/Src.GetRenamed/StdLib/Lib/idlelib/Icons/folder.gif similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/folder.gif rename to Src.GetRenamed/StdLib/Lib/idlelib/Icons/folder.gif diff --git a/Src/StdLib/Lib/idlelib/Icons/idle.icns b/Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle.icns similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/idle.icns rename to Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle.icns diff --git a/Src/StdLib/Lib/idlelib/Icons/idle.ico b/Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle.ico similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/idle.ico rename to Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle.ico diff --git a/Src/StdLib/Lib/idlelib/Icons/idle_16.gif b/Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_16.gif similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/idle_16.gif rename to Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_16.gif diff --git a/Src/StdLib/Lib/idlelib/Icons/idle_16.png b/Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_16.png similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/idle_16.png rename to Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_16.png diff --git a/Src/StdLib/Lib/idlelib/Icons/idle_32.gif b/Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_32.gif similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/idle_32.gif rename to Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_32.gif diff --git a/Src/StdLib/Lib/idlelib/Icons/idle_32.png b/Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_32.png similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/idle_32.png rename to Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_32.png diff --git a/Src/StdLib/Lib/idlelib/Icons/idle_48.gif b/Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_48.gif similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/idle_48.gif rename to Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_48.gif diff --git a/Src/StdLib/Lib/idlelib/Icons/idle_48.png b/Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_48.png similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/idle_48.png rename to Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_48.png diff --git a/Src/StdLib/Lib/idlelib/Icons/minusnode.gif b/Src.GetRenamed/StdLib/Lib/idlelib/Icons/minusnode.gif similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/minusnode.gif rename to Src.GetRenamed/StdLib/Lib/idlelib/Icons/minusnode.gif diff --git a/Src/StdLib/Lib/idlelib/Icons/openfolder.gif b/Src.GetRenamed/StdLib/Lib/idlelib/Icons/openfolder.gif similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/openfolder.gif rename to Src.GetRenamed/StdLib/Lib/idlelib/Icons/openfolder.gif diff --git a/Src/StdLib/Lib/idlelib/Icons/plusnode.gif b/Src.GetRenamed/StdLib/Lib/idlelib/Icons/plusnode.gif similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/plusnode.gif rename to Src.GetRenamed/StdLib/Lib/idlelib/Icons/plusnode.gif diff --git a/Src/StdLib/Lib/idlelib/Icons/python.gif b/Src.GetRenamed/StdLib/Lib/idlelib/Icons/python.gif similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/python.gif rename to Src.GetRenamed/StdLib/Lib/idlelib/Icons/python.gif diff --git a/Src/StdLib/Lib/idlelib/Icons/tk.gif b/Src.GetRenamed/StdLib/Lib/idlelib/Icons/tk.gif similarity index 100% rename from Src/StdLib/Lib/idlelib/Icons/tk.gif rename to Src.GetRenamed/StdLib/Lib/idlelib/Icons/tk.gif diff --git a/Src/StdLib/Lib/idlelib/IdleHistory.py b/Src.GetRenamed/StdLib/Lib/idlelib/IdleHistory.py similarity index 100% rename from Src/StdLib/Lib/idlelib/IdleHistory.py rename to Src.GetRenamed/StdLib/Lib/idlelib/IdleHistory.py diff --git a/Src/StdLib/Lib/idlelib/MultiCall.py b/Src.GetRenamed/StdLib/Lib/idlelib/MultiCall.py similarity index 100% rename from Src/StdLib/Lib/idlelib/MultiCall.py rename to Src.GetRenamed/StdLib/Lib/idlelib/MultiCall.py diff --git a/Src/StdLib/Lib/idlelib/MultiStatusBar.py b/Src.GetRenamed/StdLib/Lib/idlelib/MultiStatusBar.py similarity index 100% rename from Src/StdLib/Lib/idlelib/MultiStatusBar.py rename to Src.GetRenamed/StdLib/Lib/idlelib/MultiStatusBar.py diff --git a/Src/StdLib/Lib/idlelib/NEWS.txt b/Src.GetRenamed/StdLib/Lib/idlelib/NEWS.txt similarity index 100% rename from Src/StdLib/Lib/idlelib/NEWS.txt rename to Src.GetRenamed/StdLib/Lib/idlelib/NEWS.txt diff --git a/Src/StdLib/Lib/idlelib/ObjectBrowser.py b/Src.GetRenamed/StdLib/Lib/idlelib/ObjectBrowser.py similarity index 100% rename from Src/StdLib/Lib/idlelib/ObjectBrowser.py rename to Src.GetRenamed/StdLib/Lib/idlelib/ObjectBrowser.py diff --git a/Src/StdLib/Lib/idlelib/OutputWindow.py b/Src.GetRenamed/StdLib/Lib/idlelib/OutputWindow.py similarity index 100% rename from Src/StdLib/Lib/idlelib/OutputWindow.py rename to Src.GetRenamed/StdLib/Lib/idlelib/OutputWindow.py diff --git a/Src/StdLib/Lib/idlelib/ParenMatch.py b/Src.GetRenamed/StdLib/Lib/idlelib/ParenMatch.py similarity index 100% rename from Src/StdLib/Lib/idlelib/ParenMatch.py rename to Src.GetRenamed/StdLib/Lib/idlelib/ParenMatch.py diff --git a/Src/StdLib/Lib/idlelib/PathBrowser.py b/Src.GetRenamed/StdLib/Lib/idlelib/PathBrowser.py similarity index 100% rename from Src/StdLib/Lib/idlelib/PathBrowser.py rename to Src.GetRenamed/StdLib/Lib/idlelib/PathBrowser.py diff --git a/Src/StdLib/Lib/idlelib/Percolator.py b/Src.GetRenamed/StdLib/Lib/idlelib/Percolator.py similarity index 100% rename from Src/StdLib/Lib/idlelib/Percolator.py rename to Src.GetRenamed/StdLib/Lib/idlelib/Percolator.py diff --git a/Src/StdLib/Lib/idlelib/PyParse.py b/Src.GetRenamed/StdLib/Lib/idlelib/PyParse.py similarity index 100% rename from Src/StdLib/Lib/idlelib/PyParse.py rename to Src.GetRenamed/StdLib/Lib/idlelib/PyParse.py diff --git a/Src/StdLib/Lib/idlelib/PyShell.py b/Src.GetRenamed/StdLib/Lib/idlelib/PyShell.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/idlelib/PyShell.py rename to Src.GetRenamed/StdLib/Lib/idlelib/PyShell.py diff --git a/Src/StdLib/Lib/idlelib/README.txt b/Src.GetRenamed/StdLib/Lib/idlelib/README.txt similarity index 100% rename from Src/StdLib/Lib/idlelib/README.txt rename to Src.GetRenamed/StdLib/Lib/idlelib/README.txt diff --git a/Src/StdLib/Lib/idlelib/RemoteDebugger.py b/Src.GetRenamed/StdLib/Lib/idlelib/RemoteDebugger.py similarity index 100% rename from Src/StdLib/Lib/idlelib/RemoteDebugger.py rename to Src.GetRenamed/StdLib/Lib/idlelib/RemoteDebugger.py diff --git a/Src/StdLib/Lib/idlelib/RemoteObjectBrowser.py b/Src.GetRenamed/StdLib/Lib/idlelib/RemoteObjectBrowser.py similarity index 100% rename from Src/StdLib/Lib/idlelib/RemoteObjectBrowser.py rename to Src.GetRenamed/StdLib/Lib/idlelib/RemoteObjectBrowser.py diff --git a/Src/StdLib/Lib/idlelib/ReplaceDialog.py b/Src.GetRenamed/StdLib/Lib/idlelib/ReplaceDialog.py similarity index 100% rename from Src/StdLib/Lib/idlelib/ReplaceDialog.py rename to Src.GetRenamed/StdLib/Lib/idlelib/ReplaceDialog.py diff --git a/Src/StdLib/Lib/idlelib/RstripExtension.py b/Src.GetRenamed/StdLib/Lib/idlelib/RstripExtension.py similarity index 100% rename from Src/StdLib/Lib/idlelib/RstripExtension.py rename to Src.GetRenamed/StdLib/Lib/idlelib/RstripExtension.py diff --git a/Src/StdLib/Lib/idlelib/ScriptBinding.py b/Src.GetRenamed/StdLib/Lib/idlelib/ScriptBinding.py similarity index 100% rename from Src/StdLib/Lib/idlelib/ScriptBinding.py rename to Src.GetRenamed/StdLib/Lib/idlelib/ScriptBinding.py diff --git a/Src/StdLib/Lib/idlelib/ScrolledList.py b/Src.GetRenamed/StdLib/Lib/idlelib/ScrolledList.py similarity index 100% rename from Src/StdLib/Lib/idlelib/ScrolledList.py rename to Src.GetRenamed/StdLib/Lib/idlelib/ScrolledList.py diff --git a/Src/StdLib/Lib/idlelib/SearchDialog.py b/Src.GetRenamed/StdLib/Lib/idlelib/SearchDialog.py similarity index 100% rename from Src/StdLib/Lib/idlelib/SearchDialog.py rename to Src.GetRenamed/StdLib/Lib/idlelib/SearchDialog.py diff --git a/Src/StdLib/Lib/idlelib/SearchDialogBase.py b/Src.GetRenamed/StdLib/Lib/idlelib/SearchDialogBase.py similarity index 100% rename from Src/StdLib/Lib/idlelib/SearchDialogBase.py rename to Src.GetRenamed/StdLib/Lib/idlelib/SearchDialogBase.py diff --git a/Src/StdLib/Lib/idlelib/SearchEngine.py b/Src.GetRenamed/StdLib/Lib/idlelib/SearchEngine.py similarity index 100% rename from Src/StdLib/Lib/idlelib/SearchEngine.py rename to Src.GetRenamed/StdLib/Lib/idlelib/SearchEngine.py diff --git a/Src/StdLib/Lib/idlelib/StackViewer.py b/Src.GetRenamed/StdLib/Lib/idlelib/StackViewer.py similarity index 100% rename from Src/StdLib/Lib/idlelib/StackViewer.py rename to Src.GetRenamed/StdLib/Lib/idlelib/StackViewer.py diff --git a/Src/StdLib/Lib/idlelib/TODO.txt b/Src.GetRenamed/StdLib/Lib/idlelib/TODO.txt similarity index 100% rename from Src/StdLib/Lib/idlelib/TODO.txt rename to Src.GetRenamed/StdLib/Lib/idlelib/TODO.txt diff --git a/Src/StdLib/Lib/idlelib/ToolTip.py b/Src.GetRenamed/StdLib/Lib/idlelib/ToolTip.py similarity index 100% rename from Src/StdLib/Lib/idlelib/ToolTip.py rename to Src.GetRenamed/StdLib/Lib/idlelib/ToolTip.py diff --git a/Src/StdLib/Lib/idlelib/TreeWidget.py b/Src.GetRenamed/StdLib/Lib/idlelib/TreeWidget.py similarity index 100% rename from Src/StdLib/Lib/idlelib/TreeWidget.py rename to Src.GetRenamed/StdLib/Lib/idlelib/TreeWidget.py diff --git a/Src/StdLib/Lib/idlelib/UndoDelegator.py b/Src.GetRenamed/StdLib/Lib/idlelib/UndoDelegator.py similarity index 100% rename from Src/StdLib/Lib/idlelib/UndoDelegator.py rename to Src.GetRenamed/StdLib/Lib/idlelib/UndoDelegator.py diff --git a/Src/StdLib/Lib/idlelib/WidgetRedirector.py b/Src.GetRenamed/StdLib/Lib/idlelib/WidgetRedirector.py similarity index 100% rename from Src/StdLib/Lib/idlelib/WidgetRedirector.py rename to Src.GetRenamed/StdLib/Lib/idlelib/WidgetRedirector.py diff --git a/Src/StdLib/Lib/idlelib/WindowList.py b/Src.GetRenamed/StdLib/Lib/idlelib/WindowList.py similarity index 100% rename from Src/StdLib/Lib/idlelib/WindowList.py rename to Src.GetRenamed/StdLib/Lib/idlelib/WindowList.py diff --git a/Src/StdLib/Lib/idlelib/ZoomHeight.py b/Src.GetRenamed/StdLib/Lib/idlelib/ZoomHeight.py similarity index 100% rename from Src/StdLib/Lib/idlelib/ZoomHeight.py rename to Src.GetRenamed/StdLib/Lib/idlelib/ZoomHeight.py diff --git a/Src/StdLib/Lib/idlelib/__init__.py b/Src.GetRenamed/StdLib/Lib/idlelib/__init__.py similarity index 100% rename from Src/StdLib/Lib/idlelib/__init__.py rename to Src.GetRenamed/StdLib/Lib/idlelib/__init__.py diff --git a/Src/StdLib/Lib/idlelib/__main__.py b/Src.GetRenamed/StdLib/Lib/idlelib/__main__.py similarity index 100% rename from Src/StdLib/Lib/idlelib/__main__.py rename to Src.GetRenamed/StdLib/Lib/idlelib/__main__.py diff --git a/Src/StdLib/Lib/idlelib/aboutDialog.py b/Src.GetRenamed/StdLib/Lib/idlelib/aboutDialog.py similarity index 100% rename from Src/StdLib/Lib/idlelib/aboutDialog.py rename to Src.GetRenamed/StdLib/Lib/idlelib/aboutDialog.py diff --git a/Src/StdLib/Lib/idlelib/config-extensions.def b/Src.GetRenamed/StdLib/Lib/idlelib/config-extensions.def similarity index 100% rename from Src/StdLib/Lib/idlelib/config-extensions.def rename to Src.GetRenamed/StdLib/Lib/idlelib/config-extensions.def diff --git a/Src/StdLib/Lib/idlelib/config-highlight.def b/Src.GetRenamed/StdLib/Lib/idlelib/config-highlight.def similarity index 100% rename from Src/StdLib/Lib/idlelib/config-highlight.def rename to Src.GetRenamed/StdLib/Lib/idlelib/config-highlight.def diff --git a/Src/StdLib/Lib/idlelib/config-keys.def b/Src.GetRenamed/StdLib/Lib/idlelib/config-keys.def similarity index 100% rename from Src/StdLib/Lib/idlelib/config-keys.def rename to Src.GetRenamed/StdLib/Lib/idlelib/config-keys.def diff --git a/Src/StdLib/Lib/idlelib/config-main.def b/Src.GetRenamed/StdLib/Lib/idlelib/config-main.def similarity index 100% rename from Src/StdLib/Lib/idlelib/config-main.def rename to Src.GetRenamed/StdLib/Lib/idlelib/config-main.def diff --git a/Src/StdLib/Lib/idlelib/configDialog.py b/Src.GetRenamed/StdLib/Lib/idlelib/configDialog.py similarity index 100% rename from Src/StdLib/Lib/idlelib/configDialog.py rename to Src.GetRenamed/StdLib/Lib/idlelib/configDialog.py diff --git a/Src/StdLib/Lib/idlelib/configHandler.py b/Src.GetRenamed/StdLib/Lib/idlelib/configHandler.py similarity index 100% rename from Src/StdLib/Lib/idlelib/configHandler.py rename to Src.GetRenamed/StdLib/Lib/idlelib/configHandler.py diff --git a/Src/StdLib/Lib/idlelib/configHelpSourceEdit.py b/Src.GetRenamed/StdLib/Lib/idlelib/configHelpSourceEdit.py similarity index 100% rename from Src/StdLib/Lib/idlelib/configHelpSourceEdit.py rename to Src.GetRenamed/StdLib/Lib/idlelib/configHelpSourceEdit.py diff --git a/Src/StdLib/Lib/idlelib/configSectionNameDialog.py b/Src.GetRenamed/StdLib/Lib/idlelib/configSectionNameDialog.py similarity index 100% rename from Src/StdLib/Lib/idlelib/configSectionNameDialog.py rename to Src.GetRenamed/StdLib/Lib/idlelib/configSectionNameDialog.py diff --git a/Src/StdLib/Lib/idlelib/dynOptionMenuWidget.py b/Src.GetRenamed/StdLib/Lib/idlelib/dynOptionMenuWidget.py similarity index 100% rename from Src/StdLib/Lib/idlelib/dynOptionMenuWidget.py rename to Src.GetRenamed/StdLib/Lib/idlelib/dynOptionMenuWidget.py diff --git a/Src/StdLib/Lib/idlelib/extend.txt b/Src.GetRenamed/StdLib/Lib/idlelib/extend.txt similarity index 100% rename from Src/StdLib/Lib/idlelib/extend.txt rename to Src.GetRenamed/StdLib/Lib/idlelib/extend.txt diff --git a/Src/StdLib/Lib/idlelib/help.html b/Src.GetRenamed/StdLib/Lib/idlelib/help.html similarity index 100% rename from Src/StdLib/Lib/idlelib/help.html rename to Src.GetRenamed/StdLib/Lib/idlelib/help.html diff --git a/Src/StdLib/Lib/idlelib/help.py b/Src.GetRenamed/StdLib/Lib/idlelib/help.py similarity index 100% rename from Src/StdLib/Lib/idlelib/help.py rename to Src.GetRenamed/StdLib/Lib/idlelib/help.py diff --git a/Src/StdLib/Lib/idlelib/help.txt b/Src.GetRenamed/StdLib/Lib/idlelib/help.txt similarity index 100% rename from Src/StdLib/Lib/idlelib/help.txt rename to Src.GetRenamed/StdLib/Lib/idlelib/help.txt diff --git a/Src/StdLib/Lib/idlelib/idle.bat b/Src.GetRenamed/StdLib/Lib/idlelib/idle.bat old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/idlelib/idle.bat rename to Src.GetRenamed/StdLib/Lib/idlelib/idle.bat diff --git a/Src/StdLib/Lib/idlelib/idle.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle.py diff --git a/Src/StdLib/Lib/idlelib/idle.pyw b/Src.GetRenamed/StdLib/Lib/idlelib/idle.pyw similarity index 100% rename from Src/StdLib/Lib/idlelib/idle.pyw rename to Src.GetRenamed/StdLib/Lib/idlelib/idle.pyw diff --git a/Src/StdLib/Lib/idlelib/idle_test/README.txt b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/README.txt similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/README.txt rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/README.txt diff --git a/Src/StdLib/Lib/idlelib/idle_test/__init__.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/__init__.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/__init__.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/__init__.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/htest.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/htest.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/htest.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/htest.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/mock_idle.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/mock_idle.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/mock_idle.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/mock_idle.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/mock_tk.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/mock_tk.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/mock_tk.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/mock_tk.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_autocomplete.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_autocomplete.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_autocomplete.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_autocomplete.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_autoexpand.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_autoexpand.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_autoexpand.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_autoexpand.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_calltips.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_calltips.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_calltips.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_calltips.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_config_name.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_config_name.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_config_name.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_config_name.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_configdialog.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_configdialog.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_configdialog.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_configdialog.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_delegator.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_delegator.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_delegator.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_delegator.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_editor.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_editor.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_editor.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_editor.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_grep.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_grep.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_grep.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_grep.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_hyperparser.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_hyperparser.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_hyperparser.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_hyperparser.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_idlehistory.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_idlehistory.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_idlehistory.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_idlehistory.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_io.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_io.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_io.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_io.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_parenmatch.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_parenmatch.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_parenmatch.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_parenmatch.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_rstrip.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_rstrip.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_rstrip.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_rstrip.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_searchengine.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_searchengine.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_searchengine.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_searchengine.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_text.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_text.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_text.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_text.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_textview.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_textview.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_textview.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_textview.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_warning.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_warning.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_warning.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_warning.py diff --git a/Src/StdLib/Lib/idlelib/idle_test/test_widgetredir.py b/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_widgetredir.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idle_test/test_widgetredir.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_widgetredir.py diff --git a/Src/StdLib/Lib/idlelib/idlever.py b/Src.GetRenamed/StdLib/Lib/idlelib/idlever.py similarity index 100% rename from Src/StdLib/Lib/idlelib/idlever.py rename to Src.GetRenamed/StdLib/Lib/idlelib/idlever.py diff --git a/Src/StdLib/Lib/idlelib/keybindingDialog.py b/Src.GetRenamed/StdLib/Lib/idlelib/keybindingDialog.py similarity index 100% rename from Src/StdLib/Lib/idlelib/keybindingDialog.py rename to Src.GetRenamed/StdLib/Lib/idlelib/keybindingDialog.py diff --git a/Src/StdLib/Lib/idlelib/macosxSupport.py b/Src.GetRenamed/StdLib/Lib/idlelib/macosxSupport.py similarity index 100% rename from Src/StdLib/Lib/idlelib/macosxSupport.py rename to Src.GetRenamed/StdLib/Lib/idlelib/macosxSupport.py diff --git a/Src/StdLib/Lib/idlelib/rpc.py b/Src.GetRenamed/StdLib/Lib/idlelib/rpc.py similarity index 100% rename from Src/StdLib/Lib/idlelib/rpc.py rename to Src.GetRenamed/StdLib/Lib/idlelib/rpc.py diff --git a/Src/StdLib/Lib/idlelib/run.py b/Src.GetRenamed/StdLib/Lib/idlelib/run.py similarity index 100% rename from Src/StdLib/Lib/idlelib/run.py rename to Src.GetRenamed/StdLib/Lib/idlelib/run.py diff --git a/Src/StdLib/Lib/idlelib/tabbedpages.py b/Src.GetRenamed/StdLib/Lib/idlelib/tabbedpages.py similarity index 100% rename from Src/StdLib/Lib/idlelib/tabbedpages.py rename to Src.GetRenamed/StdLib/Lib/idlelib/tabbedpages.py diff --git a/Src/StdLib/Lib/idlelib/textView.py b/Src.GetRenamed/StdLib/Lib/idlelib/textView.py similarity index 100% rename from Src/StdLib/Lib/idlelib/textView.py rename to Src.GetRenamed/StdLib/Lib/idlelib/textView.py diff --git a/Src/StdLib/Lib/imaplib.py b/Src.GetRenamed/StdLib/Lib/imaplib.py similarity index 100% rename from Src/StdLib/Lib/imaplib.py rename to Src.GetRenamed/StdLib/Lib/imaplib.py diff --git a/Src/StdLib/Lib/imghdr.py b/Src.GetRenamed/StdLib/Lib/imghdr.py similarity index 100% rename from Src/StdLib/Lib/imghdr.py rename to Src.GetRenamed/StdLib/Lib/imghdr.py diff --git a/Src/StdLib/Lib/imp.py b/Src.GetRenamed/StdLib/Lib/imp.py similarity index 100% rename from Src/StdLib/Lib/imp.py rename to Src.GetRenamed/StdLib/Lib/imp.py diff --git a/Src/StdLib/Lib/importlib/__init__.py b/Src.GetRenamed/StdLib/Lib/importlib/__init__.py similarity index 100% rename from Src/StdLib/Lib/importlib/__init__.py rename to Src.GetRenamed/StdLib/Lib/importlib/__init__.py diff --git a/Src/StdLib/Lib/importlib/_bootstrap.py b/Src.GetRenamed/StdLib/Lib/importlib/_bootstrap.py similarity index 100% rename from Src/StdLib/Lib/importlib/_bootstrap.py rename to Src.GetRenamed/StdLib/Lib/importlib/_bootstrap.py diff --git a/Src/StdLib/Lib/importlib/abc.py b/Src.GetRenamed/StdLib/Lib/importlib/abc.py similarity index 100% rename from Src/StdLib/Lib/importlib/abc.py rename to Src.GetRenamed/StdLib/Lib/importlib/abc.py diff --git a/Src/StdLib/Lib/importlib/machinery.py b/Src.GetRenamed/StdLib/Lib/importlib/machinery.py similarity index 100% rename from Src/StdLib/Lib/importlib/machinery.py rename to Src.GetRenamed/StdLib/Lib/importlib/machinery.py diff --git a/Src/StdLib/Lib/importlib/util.py b/Src.GetRenamed/StdLib/Lib/importlib/util.py similarity index 100% rename from Src/StdLib/Lib/importlib/util.py rename to Src.GetRenamed/StdLib/Lib/importlib/util.py diff --git a/Src/StdLib/Lib/inspect.py b/Src.GetRenamed/StdLib/Lib/inspect.py similarity index 100% rename from Src/StdLib/Lib/inspect.py rename to Src.GetRenamed/StdLib/Lib/inspect.py diff --git a/Src/StdLib/Lib/io.py b/Src.GetRenamed/StdLib/Lib/io.py similarity index 100% rename from Src/StdLib/Lib/io.py rename to Src.GetRenamed/StdLib/Lib/io.py diff --git a/Src/StdLib/Lib/ipaddress.py b/Src.GetRenamed/StdLib/Lib/ipaddress.py similarity index 100% rename from Src/StdLib/Lib/ipaddress.py rename to Src.GetRenamed/StdLib/Lib/ipaddress.py diff --git a/Src/StdLib/Lib/json/__init__.py b/Src.GetRenamed/StdLib/Lib/json/__init__.py similarity index 100% rename from Src/StdLib/Lib/json/__init__.py rename to Src.GetRenamed/StdLib/Lib/json/__init__.py diff --git a/Src/StdLib/Lib/json/decoder.py b/Src.GetRenamed/StdLib/Lib/json/decoder.py similarity index 100% rename from Src/StdLib/Lib/json/decoder.py rename to Src.GetRenamed/StdLib/Lib/json/decoder.py diff --git a/Src/StdLib/Lib/json/encoder.py b/Src.GetRenamed/StdLib/Lib/json/encoder.py similarity index 100% rename from Src/StdLib/Lib/json/encoder.py rename to Src.GetRenamed/StdLib/Lib/json/encoder.py diff --git a/Src/StdLib/Lib/json/scanner.py b/Src.GetRenamed/StdLib/Lib/json/scanner.py similarity index 100% rename from Src/StdLib/Lib/json/scanner.py rename to Src.GetRenamed/StdLib/Lib/json/scanner.py diff --git a/Src/StdLib/Lib/json/tool.py b/Src.GetRenamed/StdLib/Lib/json/tool.py similarity index 100% rename from Src/StdLib/Lib/json/tool.py rename to Src.GetRenamed/StdLib/Lib/json/tool.py diff --git a/Src/StdLib/Lib/keyword.py b/Src.GetRenamed/StdLib/Lib/keyword.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/keyword.py rename to Src.GetRenamed/StdLib/Lib/keyword.py diff --git a/Src/StdLib/Lib/lib2to3/Grammar.txt b/Src.GetRenamed/StdLib/Lib/lib2to3/Grammar.txt similarity index 100% rename from Src/StdLib/Lib/lib2to3/Grammar.txt rename to Src.GetRenamed/StdLib/Lib/lib2to3/Grammar.txt diff --git a/Src/StdLib/Lib/lib2to3/PatternGrammar.txt b/Src.GetRenamed/StdLib/Lib/lib2to3/PatternGrammar.txt similarity index 100% rename from Src/StdLib/Lib/lib2to3/PatternGrammar.txt rename to Src.GetRenamed/StdLib/Lib/lib2to3/PatternGrammar.txt diff --git a/Src/StdLib/Lib/lib2to3/__init__.py b/Src.GetRenamed/StdLib/Lib/lib2to3/__init__.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/__init__.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/__init__.py diff --git a/Src/StdLib/Lib/lib2to3/__main__.py b/Src.GetRenamed/StdLib/Lib/lib2to3/__main__.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/__main__.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/__main__.py diff --git a/Src/StdLib/Lib/lib2to3/btm_matcher.py b/Src.GetRenamed/StdLib/Lib/lib2to3/btm_matcher.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/btm_matcher.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/btm_matcher.py diff --git a/Src/StdLib/Lib/lib2to3/btm_utils.py b/Src.GetRenamed/StdLib/Lib/lib2to3/btm_utils.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/btm_utils.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/btm_utils.py diff --git a/Src/StdLib/Lib/lib2to3/fixer_base.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixer_base.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixer_base.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixer_base.py diff --git a/Src/StdLib/Lib/lib2to3/fixer_util.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixer_util.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixer_util.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixer_util.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/__init__.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/__init__.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/__init__.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/__init__.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_apply.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_apply.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_apply.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_apply.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_asserts.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_asserts.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_asserts.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_asserts.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_basestring.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_basestring.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_basestring.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_basestring.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_buffer.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_buffer.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_buffer.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_buffer.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_callable.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_callable.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_callable.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_callable.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_dict.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_dict.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_dict.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_dict.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_except.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_except.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_except.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_except.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_exec.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_exec.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_exec.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_exec.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_execfile.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_execfile.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_execfile.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_execfile.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_filter.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_filter.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_filter.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_filter.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_future.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_future.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_future.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_future.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_has_key.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_has_key.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_has_key.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_has_key.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_idioms.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_idioms.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_idioms.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_idioms.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_import.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_import.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_import.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_import.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_imports.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_imports.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_imports.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_imports.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_imports2.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_imports2.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_imports2.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_imports2.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_input.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_input.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_input.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_input.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_intern.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_intern.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_intern.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_intern.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_isinstance.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_isinstance.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_isinstance.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_isinstance.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_itertools.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_itertools.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_itertools.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_itertools.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_long.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_long.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_long.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_long.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_map.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_map.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_map.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_map.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_metaclass.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_metaclass.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_metaclass.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_metaclass.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_ne.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_ne.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_ne.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_ne.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_next.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_next.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_next.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_next.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_nonzero.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_nonzero.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_nonzero.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_nonzero.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_numliterals.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_numliterals.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_numliterals.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_numliterals.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_operator.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_operator.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_operator.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_operator.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_paren.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_paren.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_paren.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_paren.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_print.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_print.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_print.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_print.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_raise.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_raise.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_raise.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_raise.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_raw_input.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_raw_input.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_raw_input.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_raw_input.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_reduce.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_reduce.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_reduce.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_reduce.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_reload.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_reload.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_reload.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_reload.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_renames.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_renames.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_renames.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_renames.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_repr.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_repr.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_repr.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_repr.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_set_literal.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_set_literal.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_set_literal.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_set_literal.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_standarderror.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_standarderror.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_standarderror.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_standarderror.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_throw.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_throw.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_throw.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_throw.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_types.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_types.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_types.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_types.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_unicode.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_unicode.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_unicode.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_unicode.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_urllib.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_urllib.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_urllib.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_urllib.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_xrange.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_xrange.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_xrange.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_xrange.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py diff --git a/Src/StdLib/Lib/lib2to3/fixes/fix_zip.py b/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_zip.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/fixes/fix_zip.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_zip.py diff --git a/Src/StdLib/Lib/lib2to3/main.py b/Src.GetRenamed/StdLib/Lib/lib2to3/main.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/main.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/main.py diff --git a/Src/StdLib/Lib/lib2to3/patcomp.py b/Src.GetRenamed/StdLib/Lib/lib2to3/patcomp.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/patcomp.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/patcomp.py diff --git a/Src/StdLib/Lib/lib2to3/pgen2/__init__.py b/Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/__init__.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/pgen2/__init__.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/__init__.py diff --git a/Src/StdLib/Lib/lib2to3/pgen2/conv.py b/Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/conv.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/pgen2/conv.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/conv.py diff --git a/Src/StdLib/Lib/lib2to3/pgen2/driver.py b/Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/driver.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/pgen2/driver.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/driver.py diff --git a/Src/StdLib/Lib/lib2to3/pgen2/grammar.py b/Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/grammar.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/pgen2/grammar.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/grammar.py diff --git a/Src/StdLib/Lib/lib2to3/pgen2/literals.py b/Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/literals.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/pgen2/literals.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/literals.py diff --git a/Src/StdLib/Lib/lib2to3/pgen2/parse.py b/Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/parse.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/pgen2/parse.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/parse.py diff --git a/Src/StdLib/Lib/lib2to3/pgen2/pgen.py b/Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/pgen.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/pgen2/pgen.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/pgen.py diff --git a/Src/StdLib/Lib/lib2to3/pgen2/token.py b/Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/token.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/lib2to3/pgen2/token.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/token.py diff --git a/Src/StdLib/Lib/lib2to3/pgen2/tokenize.py b/Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/tokenize.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/pgen2/tokenize.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/tokenize.py diff --git a/Src/StdLib/Lib/lib2to3/pygram.py b/Src.GetRenamed/StdLib/Lib/lib2to3/pygram.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/pygram.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/pygram.py diff --git a/Src/StdLib/Lib/lib2to3/pytree.py b/Src.GetRenamed/StdLib/Lib/lib2to3/pytree.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/pytree.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/pytree.py diff --git a/Src/StdLib/Lib/lib2to3/refactor.py b/Src.GetRenamed/StdLib/Lib/lib2to3/refactor.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/refactor.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/refactor.py diff --git a/Src/StdLib/Lib/lib2to3/tests/__init__.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/__init__.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/__init__.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/__init__.py diff --git a/Src/StdLib/Lib/lib2to3/tests/__main__.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/__main__.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/__main__.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/__main__.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/README b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/README similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/README rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/README diff --git a/Src/StdLib/Lib/lib2to3/tests/data/bom.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/bom.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/bom.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/bom.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/crlf.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/crlf.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/crlf.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/crlf.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/different_encoding.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/different_encoding.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/different_encoding.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/different_encoding.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/false_encoding.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/false_encoding.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/false_encoding.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/false_encoding.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py diff --git a/PythonTests/import_extant/_vendor/__init__.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py similarity index 100% rename from PythonTests/import_extant/_vendor/__init__.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py diff --git a/Src/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py diff --git a/Src/StdLib/Lib/lib2to3/tests/pytree_idempotency.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/pytree_idempotency.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/pytree_idempotency.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/pytree_idempotency.py diff --git a/Src/StdLib/Lib/lib2to3/tests/support.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/support.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/support.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/support.py diff --git a/Src/StdLib/Lib/lib2to3/tests/test_all_fixers.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_all_fixers.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/test_all_fixers.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_all_fixers.py diff --git a/Src/StdLib/Lib/lib2to3/tests/test_fixers.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_fixers.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/test_fixers.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_fixers.py diff --git a/Src/StdLib/Lib/lib2to3/tests/test_main.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_main.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/test_main.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_main.py diff --git a/Src/StdLib/Lib/lib2to3/tests/test_parser.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_parser.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/test_parser.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_parser.py diff --git a/Src/StdLib/Lib/lib2to3/tests/test_pytree.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_pytree.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/test_pytree.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_pytree.py diff --git a/Src/StdLib/Lib/lib2to3/tests/test_refactor.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_refactor.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/test_refactor.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_refactor.py diff --git a/Src/StdLib/Lib/lib2to3/tests/test_util.py b/Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_util.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/test_util.py rename to Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_util.py diff --git a/Src/StdLib/Lib/linecache.py b/Src.GetRenamed/StdLib/Lib/linecache.py similarity index 100% rename from Src/StdLib/Lib/linecache.py rename to Src.GetRenamed/StdLib/Lib/linecache.py diff --git a/Src/StdLib/Lib/locale.py b/Src.GetRenamed/StdLib/Lib/locale.py similarity index 100% rename from Src/StdLib/Lib/locale.py rename to Src.GetRenamed/StdLib/Lib/locale.py diff --git a/Src/StdLib/Lib/logging/__init__.py b/Src.GetRenamed/StdLib/Lib/logging/__init__.py similarity index 100% rename from Src/StdLib/Lib/logging/__init__.py rename to Src.GetRenamed/StdLib/Lib/logging/__init__.py diff --git a/Src/StdLib/Lib/logging/config.py b/Src.GetRenamed/StdLib/Lib/logging/config.py similarity index 100% rename from Src/StdLib/Lib/logging/config.py rename to Src.GetRenamed/StdLib/Lib/logging/config.py diff --git a/Src/StdLib/Lib/logging/handlers.py b/Src.GetRenamed/StdLib/Lib/logging/handlers.py similarity index 100% rename from Src/StdLib/Lib/logging/handlers.py rename to Src.GetRenamed/StdLib/Lib/logging/handlers.py diff --git a/Src/StdLib/Lib/lzma.py b/Src.GetRenamed/StdLib/Lib/lzma.py similarity index 100% rename from Src/StdLib/Lib/lzma.py rename to Src.GetRenamed/StdLib/Lib/lzma.py diff --git a/Src/StdLib/Lib/macpath.py b/Src.GetRenamed/StdLib/Lib/macpath.py similarity index 100% rename from Src/StdLib/Lib/macpath.py rename to Src.GetRenamed/StdLib/Lib/macpath.py diff --git a/Src/StdLib/Lib/macurl2path.py b/Src.GetRenamed/StdLib/Lib/macurl2path.py similarity index 100% rename from Src/StdLib/Lib/macurl2path.py rename to Src.GetRenamed/StdLib/Lib/macurl2path.py diff --git a/Src/StdLib/Lib/mailbox.py b/Src.GetRenamed/StdLib/Lib/mailbox.py similarity index 100% rename from Src/StdLib/Lib/mailbox.py rename to Src.GetRenamed/StdLib/Lib/mailbox.py diff --git a/Src/StdLib/Lib/mailcap.py b/Src.GetRenamed/StdLib/Lib/mailcap.py similarity index 100% rename from Src/StdLib/Lib/mailcap.py rename to Src.GetRenamed/StdLib/Lib/mailcap.py diff --git a/Src/StdLib/Lib/mimetypes.py b/Src.GetRenamed/StdLib/Lib/mimetypes.py similarity index 100% rename from Src/StdLib/Lib/mimetypes.py rename to Src.GetRenamed/StdLib/Lib/mimetypes.py diff --git a/Src/StdLib/Lib/modulefinder.py b/Src.GetRenamed/StdLib/Lib/modulefinder.py similarity index 100% rename from Src/StdLib/Lib/modulefinder.py rename to Src.GetRenamed/StdLib/Lib/modulefinder.py diff --git a/Src/StdLib/Lib/msilib/__init__.py b/Src.GetRenamed/StdLib/Lib/msilib/__init__.py similarity index 100% rename from Src/StdLib/Lib/msilib/__init__.py rename to Src.GetRenamed/StdLib/Lib/msilib/__init__.py diff --git a/Src/StdLib/Lib/msilib/schema.py b/Src.GetRenamed/StdLib/Lib/msilib/schema.py similarity index 100% rename from Src/StdLib/Lib/msilib/schema.py rename to Src.GetRenamed/StdLib/Lib/msilib/schema.py diff --git a/Src/StdLib/Lib/msilib/sequence.py b/Src.GetRenamed/StdLib/Lib/msilib/sequence.py similarity index 100% rename from Src/StdLib/Lib/msilib/sequence.py rename to Src.GetRenamed/StdLib/Lib/msilib/sequence.py diff --git a/Src/StdLib/Lib/msilib/text.py b/Src.GetRenamed/StdLib/Lib/msilib/text.py similarity index 100% rename from Src/StdLib/Lib/msilib/text.py rename to Src.GetRenamed/StdLib/Lib/msilib/text.py diff --git a/Src/StdLib/Lib/multiprocessing/__init__.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/__init__.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/__init__.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/__init__.py diff --git a/Src/StdLib/Lib/multiprocessing/connection.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/connection.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/connection.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/connection.py diff --git a/Src/StdLib/Lib/multiprocessing/context.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/context.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/context.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/context.py diff --git a/Src/StdLib/Lib/multiprocessing/dummy/__init__.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/dummy/__init__.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/dummy/__init__.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/dummy/__init__.py diff --git a/Src/StdLib/Lib/multiprocessing/dummy/connection.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/dummy/connection.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/dummy/connection.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/dummy/connection.py diff --git a/Src/StdLib/Lib/multiprocessing/forkserver.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/forkserver.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/forkserver.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/forkserver.py diff --git a/Src/StdLib/Lib/multiprocessing/heap.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/heap.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/heap.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/heap.py diff --git a/Src/StdLib/Lib/multiprocessing/managers.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/managers.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/managers.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/managers.py diff --git a/Src/StdLib/Lib/multiprocessing/pool.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/pool.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/pool.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/pool.py diff --git a/Src/StdLib/Lib/multiprocessing/popen_fork.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/popen_fork.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/popen_fork.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/popen_fork.py diff --git a/Src/StdLib/Lib/multiprocessing/popen_forkserver.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/popen_forkserver.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/popen_forkserver.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/popen_forkserver.py diff --git a/Src/StdLib/Lib/multiprocessing/popen_spawn_posix.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/popen_spawn_posix.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/popen_spawn_posix.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/popen_spawn_posix.py diff --git a/Src/StdLib/Lib/multiprocessing/popen_spawn_win32.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/popen_spawn_win32.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/popen_spawn_win32.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/popen_spawn_win32.py diff --git a/Src/StdLib/Lib/multiprocessing/process.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/process.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/process.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/process.py diff --git a/Src/StdLib/Lib/multiprocessing/queues.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/queues.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/queues.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/queues.py diff --git a/Src/StdLib/Lib/multiprocessing/reduction.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/reduction.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/reduction.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/reduction.py diff --git a/Src/StdLib/Lib/multiprocessing/resource_sharer.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/resource_sharer.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/resource_sharer.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/resource_sharer.py diff --git a/Src/StdLib/Lib/multiprocessing/semaphore_tracker.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/semaphore_tracker.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/semaphore_tracker.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/semaphore_tracker.py diff --git a/Src/StdLib/Lib/multiprocessing/sharedctypes.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/sharedctypes.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/sharedctypes.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/sharedctypes.py diff --git a/Src/StdLib/Lib/multiprocessing/spawn.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/spawn.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/spawn.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/spawn.py diff --git a/Src/StdLib/Lib/multiprocessing/synchronize.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/synchronize.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/synchronize.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/synchronize.py diff --git a/Src/StdLib/Lib/multiprocessing/util.py b/Src.GetRenamed/StdLib/Lib/multiprocessing/util.py similarity index 100% rename from Src/StdLib/Lib/multiprocessing/util.py rename to Src.GetRenamed/StdLib/Lib/multiprocessing/util.py diff --git a/Src/StdLib/Lib/netrc.py b/Src.GetRenamed/StdLib/Lib/netrc.py similarity index 100% rename from Src/StdLib/Lib/netrc.py rename to Src.GetRenamed/StdLib/Lib/netrc.py diff --git a/Src/StdLib/Lib/nntplib.py b/Src.GetRenamed/StdLib/Lib/nntplib.py similarity index 100% rename from Src/StdLib/Lib/nntplib.py rename to Src.GetRenamed/StdLib/Lib/nntplib.py diff --git a/Src/StdLib/Lib/ntpath.py b/Src.GetRenamed/StdLib/Lib/ntpath.py similarity index 100% rename from Src/StdLib/Lib/ntpath.py rename to Src.GetRenamed/StdLib/Lib/ntpath.py diff --git a/Src/StdLib/Lib/nturl2path.py b/Src.GetRenamed/StdLib/Lib/nturl2path.py similarity index 100% rename from Src/StdLib/Lib/nturl2path.py rename to Src.GetRenamed/StdLib/Lib/nturl2path.py diff --git a/Src/StdLib/Lib/numbers.py b/Src.GetRenamed/StdLib/Lib/numbers.py similarity index 100% rename from Src/StdLib/Lib/numbers.py rename to Src.GetRenamed/StdLib/Lib/numbers.py diff --git a/Src/StdLib/Lib/opcode.py b/Src.GetRenamed/StdLib/Lib/opcode.py similarity index 100% rename from Src/StdLib/Lib/opcode.py rename to Src.GetRenamed/StdLib/Lib/opcode.py diff --git a/Src/StdLib/Lib/operator.py b/Src.GetRenamed/StdLib/Lib/operator.py similarity index 100% rename from Src/StdLib/Lib/operator.py rename to Src.GetRenamed/StdLib/Lib/operator.py diff --git a/Src/StdLib/Lib/optparse.py b/Src.GetRenamed/StdLib/Lib/optparse.py similarity index 100% rename from Src/StdLib/Lib/optparse.py rename to Src.GetRenamed/StdLib/Lib/optparse.py diff --git a/Src/StdLib/Lib/os.py b/Src.GetRenamed/StdLib/Lib/os.py similarity index 100% rename from Src/StdLib/Lib/os.py rename to Src.GetRenamed/StdLib/Lib/os.py diff --git a/Src/StdLib/Lib/pathlib.py b/Src.GetRenamed/StdLib/Lib/pathlib.py similarity index 100% rename from Src/StdLib/Lib/pathlib.py rename to Src.GetRenamed/StdLib/Lib/pathlib.py diff --git a/Src/StdLib/Lib/pdb.py b/Src.GetRenamed/StdLib/Lib/pdb.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/pdb.py rename to Src.GetRenamed/StdLib/Lib/pdb.py diff --git a/Src/StdLib/Lib/pickle.py b/Src.GetRenamed/StdLib/Lib/pickle.py similarity index 100% rename from Src/StdLib/Lib/pickle.py rename to Src.GetRenamed/StdLib/Lib/pickle.py diff --git a/Src/StdLib/Lib/pickletools.py b/Src.GetRenamed/StdLib/Lib/pickletools.py similarity index 100% rename from Src/StdLib/Lib/pickletools.py rename to Src.GetRenamed/StdLib/Lib/pickletools.py diff --git a/Src/StdLib/Lib/pipes.py b/Src.GetRenamed/StdLib/Lib/pipes.py similarity index 100% rename from Src/StdLib/Lib/pipes.py rename to Src.GetRenamed/StdLib/Lib/pipes.py diff --git a/Src/StdLib/Lib/pkgutil.py b/Src.GetRenamed/StdLib/Lib/pkgutil.py similarity index 100% rename from Src/StdLib/Lib/pkgutil.py rename to Src.GetRenamed/StdLib/Lib/pkgutil.py diff --git a/Src/StdLib/Lib/platform.py b/Src.GetRenamed/StdLib/Lib/platform.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/platform.py rename to Src.GetRenamed/StdLib/Lib/platform.py diff --git a/Src/StdLib/Lib/plistlib.py b/Src.GetRenamed/StdLib/Lib/plistlib.py similarity index 100% rename from Src/StdLib/Lib/plistlib.py rename to Src.GetRenamed/StdLib/Lib/plistlib.py diff --git a/Src/StdLib/Lib/poplib.py b/Src.GetRenamed/StdLib/Lib/poplib.py similarity index 100% rename from Src/StdLib/Lib/poplib.py rename to Src.GetRenamed/StdLib/Lib/poplib.py diff --git a/Src/StdLib/Lib/posixpath.py b/Src.GetRenamed/StdLib/Lib/posixpath.py similarity index 100% rename from Src/StdLib/Lib/posixpath.py rename to Src.GetRenamed/StdLib/Lib/posixpath.py diff --git a/Src/StdLib/Lib/pprint.py b/Src.GetRenamed/StdLib/Lib/pprint.py similarity index 100% rename from Src/StdLib/Lib/pprint.py rename to Src.GetRenamed/StdLib/Lib/pprint.py diff --git a/Src/StdLib/Lib/profile.py b/Src.GetRenamed/StdLib/Lib/profile.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/profile.py rename to Src.GetRenamed/StdLib/Lib/profile.py diff --git a/Src/StdLib/Lib/pstats.py b/Src.GetRenamed/StdLib/Lib/pstats.py similarity index 100% rename from Src/StdLib/Lib/pstats.py rename to Src.GetRenamed/StdLib/Lib/pstats.py diff --git a/Src/StdLib/Lib/pty.py b/Src.GetRenamed/StdLib/Lib/pty.py similarity index 100% rename from Src/StdLib/Lib/pty.py rename to Src.GetRenamed/StdLib/Lib/pty.py diff --git a/Src/StdLib/Lib/py_compile.py b/Src.GetRenamed/StdLib/Lib/py_compile.py similarity index 100% rename from Src/StdLib/Lib/py_compile.py rename to Src.GetRenamed/StdLib/Lib/py_compile.py diff --git a/Src/StdLib/Lib/pyclbr.py b/Src.GetRenamed/StdLib/Lib/pyclbr.py similarity index 100% rename from Src/StdLib/Lib/pyclbr.py rename to Src.GetRenamed/StdLib/Lib/pyclbr.py diff --git a/Src/StdLib/Lib/pydoc.py b/Src.GetRenamed/StdLib/Lib/pydoc.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/pydoc.py rename to Src.GetRenamed/StdLib/Lib/pydoc.py diff --git a/PythonTests/import_extant/_vendor/packaging/__init__.py b/Src.GetRenamed/StdLib/Lib/pydoc_data/__init__.py similarity index 100% rename from PythonTests/import_extant/_vendor/packaging/__init__.py rename to Src.GetRenamed/StdLib/Lib/pydoc_data/__init__.py diff --git a/Src/StdLib/Lib/pydoc_data/_pydoc.css b/Src.GetRenamed/StdLib/Lib/pydoc_data/_pydoc.css similarity index 100% rename from Src/StdLib/Lib/pydoc_data/_pydoc.css rename to Src.GetRenamed/StdLib/Lib/pydoc_data/_pydoc.css diff --git a/Src/StdLib/Lib/pydoc_data/topics.py b/Src.GetRenamed/StdLib/Lib/pydoc_data/topics.py similarity index 100% rename from Src/StdLib/Lib/pydoc_data/topics.py rename to Src.GetRenamed/StdLib/Lib/pydoc_data/topics.py diff --git a/Src/StdLib/Lib/queue.py b/Src.GetRenamed/StdLib/Lib/queue.py similarity index 100% rename from Src/StdLib/Lib/queue.py rename to Src.GetRenamed/StdLib/Lib/queue.py diff --git a/Src/StdLib/Lib/quopri.py b/Src.GetRenamed/StdLib/Lib/quopri.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/quopri.py rename to Src.GetRenamed/StdLib/Lib/quopri.py diff --git a/Src/StdLib/Lib/random.py b/Src.GetRenamed/StdLib/Lib/random.py similarity index 100% rename from Src/StdLib/Lib/random.py rename to Src.GetRenamed/StdLib/Lib/random.py diff --git a/Src/StdLib/Lib/re.py b/Src.GetRenamed/StdLib/Lib/re.py similarity index 100% rename from Src/StdLib/Lib/re.py rename to Src.GetRenamed/StdLib/Lib/re.py diff --git a/Src/StdLib/Lib/reprlib.py b/Src.GetRenamed/StdLib/Lib/reprlib.py similarity index 100% rename from Src/StdLib/Lib/reprlib.py rename to Src.GetRenamed/StdLib/Lib/reprlib.py diff --git a/Src/StdLib/Lib/rlcompleter.py b/Src.GetRenamed/StdLib/Lib/rlcompleter.py similarity index 100% rename from Src/StdLib/Lib/rlcompleter.py rename to Src.GetRenamed/StdLib/Lib/rlcompleter.py diff --git a/Src/StdLib/Lib/runpy.py b/Src.GetRenamed/StdLib/Lib/runpy.py similarity index 100% rename from Src/StdLib/Lib/runpy.py rename to Src.GetRenamed/StdLib/Lib/runpy.py diff --git a/Src/StdLib/Lib/sched.py b/Src.GetRenamed/StdLib/Lib/sched.py similarity index 100% rename from Src/StdLib/Lib/sched.py rename to Src.GetRenamed/StdLib/Lib/sched.py diff --git a/Src/StdLib/Lib/selectors.py b/Src.GetRenamed/StdLib/Lib/selectors.py similarity index 100% rename from Src/StdLib/Lib/selectors.py rename to Src.GetRenamed/StdLib/Lib/selectors.py diff --git a/Src/StdLib/Lib/shelve.py b/Src.GetRenamed/StdLib/Lib/shelve.py similarity index 100% rename from Src/StdLib/Lib/shelve.py rename to Src.GetRenamed/StdLib/Lib/shelve.py diff --git a/Src/StdLib/Lib/shlex.py b/Src.GetRenamed/StdLib/Lib/shlex.py similarity index 100% rename from Src/StdLib/Lib/shlex.py rename to Src.GetRenamed/StdLib/Lib/shlex.py diff --git a/Src/StdLib/Lib/shutil.py b/Src.GetRenamed/StdLib/Lib/shutil.py similarity index 100% rename from Src/StdLib/Lib/shutil.py rename to Src.GetRenamed/StdLib/Lib/shutil.py diff --git a/Src/StdLib/Lib/site-packages/README b/Src.GetRenamed/StdLib/Lib/site-packages/README similarity index 100% rename from Src/StdLib/Lib/site-packages/README rename to Src.GetRenamed/StdLib/Lib/site-packages/README diff --git a/Src/StdLib/Lib/site.py b/Src.GetRenamed/StdLib/Lib/site.py similarity index 100% rename from Src/StdLib/Lib/site.py rename to Src.GetRenamed/StdLib/Lib/site.py diff --git a/Src/StdLib/Lib/smtpd.py b/Src.GetRenamed/StdLib/Lib/smtpd.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/smtpd.py rename to Src.GetRenamed/StdLib/Lib/smtpd.py diff --git a/Src/StdLib/Lib/smtplib.py b/Src.GetRenamed/StdLib/Lib/smtplib.py similarity index 100% rename from Src/StdLib/Lib/smtplib.py rename to Src.GetRenamed/StdLib/Lib/smtplib.py diff --git a/Src/StdLib/Lib/sndhdr.py b/Src.GetRenamed/StdLib/Lib/sndhdr.py similarity index 100% rename from Src/StdLib/Lib/sndhdr.py rename to Src.GetRenamed/StdLib/Lib/sndhdr.py diff --git a/Src/StdLib/Lib/socket.py b/Src.GetRenamed/StdLib/Lib/socket.py similarity index 100% rename from Src/StdLib/Lib/socket.py rename to Src.GetRenamed/StdLib/Lib/socket.py diff --git a/Src/StdLib/Lib/socketserver.py b/Src.GetRenamed/StdLib/Lib/socketserver.py similarity index 100% rename from Src/StdLib/Lib/socketserver.py rename to Src.GetRenamed/StdLib/Lib/socketserver.py diff --git a/Src/StdLib/Lib/sqlite3/__init__.py b/Src.GetRenamed/StdLib/Lib/sqlite3/__init__.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/__init__.py rename to Src.GetRenamed/StdLib/Lib/sqlite3/__init__.py diff --git a/Src/StdLib/Lib/sqlite3/dbapi2.py b/Src.GetRenamed/StdLib/Lib/sqlite3/dbapi2.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/dbapi2.py rename to Src.GetRenamed/StdLib/Lib/sqlite3/dbapi2.py diff --git a/Src/StdLib/Lib/sqlite3/dump.py b/Src.GetRenamed/StdLib/Lib/sqlite3/dump.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/dump.py rename to Src.GetRenamed/StdLib/Lib/sqlite3/dump.py diff --git a/PythonTests/pyc/pkg/__init__.py b/Src.GetRenamed/StdLib/Lib/sqlite3/test/__init__.py similarity index 100% rename from PythonTests/pyc/pkg/__init__.py rename to Src.GetRenamed/StdLib/Lib/sqlite3/test/__init__.py diff --git a/Src/StdLib/Lib/sqlite3/test/dbapi.py b/Src.GetRenamed/StdLib/Lib/sqlite3/test/dbapi.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/test/dbapi.py rename to Src.GetRenamed/StdLib/Lib/sqlite3/test/dbapi.py diff --git a/Src/StdLib/Lib/sqlite3/test/dump.py b/Src.GetRenamed/StdLib/Lib/sqlite3/test/dump.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/test/dump.py rename to Src.GetRenamed/StdLib/Lib/sqlite3/test/dump.py diff --git a/Src/StdLib/Lib/sqlite3/test/factory.py b/Src.GetRenamed/StdLib/Lib/sqlite3/test/factory.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/test/factory.py rename to Src.GetRenamed/StdLib/Lib/sqlite3/test/factory.py diff --git a/Src/StdLib/Lib/sqlite3/test/hooks.py b/Src.GetRenamed/StdLib/Lib/sqlite3/test/hooks.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/test/hooks.py rename to Src.GetRenamed/StdLib/Lib/sqlite3/test/hooks.py diff --git a/Src/StdLib/Lib/sqlite3/test/regression.py b/Src.GetRenamed/StdLib/Lib/sqlite3/test/regression.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/test/regression.py rename to Src.GetRenamed/StdLib/Lib/sqlite3/test/regression.py diff --git a/Src/StdLib/Lib/sqlite3/test/transactions.py b/Src.GetRenamed/StdLib/Lib/sqlite3/test/transactions.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/test/transactions.py rename to Src.GetRenamed/StdLib/Lib/sqlite3/test/transactions.py diff --git a/Src/StdLib/Lib/sqlite3/test/types.py b/Src.GetRenamed/StdLib/Lib/sqlite3/test/types.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/test/types.py rename to Src.GetRenamed/StdLib/Lib/sqlite3/test/types.py diff --git a/Src/StdLib/Lib/sqlite3/test/userfunctions.py b/Src.GetRenamed/StdLib/Lib/sqlite3/test/userfunctions.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/test/userfunctions.py rename to Src.GetRenamed/StdLib/Lib/sqlite3/test/userfunctions.py diff --git a/Src/StdLib/Lib/sre_compile.py b/Src.GetRenamed/StdLib/Lib/sre_compile.py similarity index 100% rename from Src/StdLib/Lib/sre_compile.py rename to Src.GetRenamed/StdLib/Lib/sre_compile.py diff --git a/Src/StdLib/Lib/sre_constants.py b/Src.GetRenamed/StdLib/Lib/sre_constants.py similarity index 100% rename from Src/StdLib/Lib/sre_constants.py rename to Src.GetRenamed/StdLib/Lib/sre_constants.py diff --git a/Src/StdLib/Lib/sre_parse.py b/Src.GetRenamed/StdLib/Lib/sre_parse.py similarity index 100% rename from Src/StdLib/Lib/sre_parse.py rename to Src.GetRenamed/StdLib/Lib/sre_parse.py diff --git a/Src/StdLib/Lib/ssl.py b/Src.GetRenamed/StdLib/Lib/ssl.py similarity index 100% rename from Src/StdLib/Lib/ssl.py rename to Src.GetRenamed/StdLib/Lib/ssl.py diff --git a/Src/StdLib/Lib/stat.py b/Src.GetRenamed/StdLib/Lib/stat.py similarity index 100% rename from Src/StdLib/Lib/stat.py rename to Src.GetRenamed/StdLib/Lib/stat.py diff --git a/Src/StdLib/Lib/statistics.py b/Src.GetRenamed/StdLib/Lib/statistics.py similarity index 100% rename from Src/StdLib/Lib/statistics.py rename to Src.GetRenamed/StdLib/Lib/statistics.py diff --git a/Src/StdLib/Lib/string.py b/Src.GetRenamed/StdLib/Lib/string.py similarity index 100% rename from Src/StdLib/Lib/string.py rename to Src.GetRenamed/StdLib/Lib/string.py diff --git a/Src/StdLib/Lib/stringprep.py b/Src.GetRenamed/StdLib/Lib/stringprep.py similarity index 100% rename from Src/StdLib/Lib/stringprep.py rename to Src.GetRenamed/StdLib/Lib/stringprep.py diff --git a/Src/StdLib/Lib/struct.py b/Src.GetRenamed/StdLib/Lib/struct.py similarity index 100% rename from Src/StdLib/Lib/struct.py rename to Src.GetRenamed/StdLib/Lib/struct.py diff --git a/Src/StdLib/Lib/subprocess.py b/Src.GetRenamed/StdLib/Lib/subprocess.py similarity index 100% rename from Src/StdLib/Lib/subprocess.py rename to Src.GetRenamed/StdLib/Lib/subprocess.py diff --git a/Src/StdLib/Lib/sunau.py b/Src.GetRenamed/StdLib/Lib/sunau.py similarity index 100% rename from Src/StdLib/Lib/sunau.py rename to Src.GetRenamed/StdLib/Lib/sunau.py diff --git a/Src/StdLib/Lib/symbol.py b/Src.GetRenamed/StdLib/Lib/symbol.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/symbol.py rename to Src.GetRenamed/StdLib/Lib/symbol.py diff --git a/Src/StdLib/Lib/symtable.py b/Src.GetRenamed/StdLib/Lib/symtable.py similarity index 100% rename from Src/StdLib/Lib/symtable.py rename to Src.GetRenamed/StdLib/Lib/symtable.py diff --git a/Src/StdLib/Lib/sysconfig.py b/Src.GetRenamed/StdLib/Lib/sysconfig.py similarity index 100% rename from Src/StdLib/Lib/sysconfig.py rename to Src.GetRenamed/StdLib/Lib/sysconfig.py diff --git a/Src/StdLib/Lib/tabnanny.py b/Src.GetRenamed/StdLib/Lib/tabnanny.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/tabnanny.py rename to Src.GetRenamed/StdLib/Lib/tabnanny.py diff --git a/Src/StdLib/Lib/tarfile.py b/Src.GetRenamed/StdLib/Lib/tarfile.py similarity index 100% rename from Src/StdLib/Lib/tarfile.py rename to Src.GetRenamed/StdLib/Lib/tarfile.py diff --git a/Src/StdLib/Lib/telnetlib.py b/Src.GetRenamed/StdLib/Lib/telnetlib.py similarity index 100% rename from Src/StdLib/Lib/telnetlib.py rename to Src.GetRenamed/StdLib/Lib/telnetlib.py diff --git a/Src/StdLib/Lib/tempfile.py b/Src.GetRenamed/StdLib/Lib/tempfile.py similarity index 100% rename from Src/StdLib/Lib/tempfile.py rename to Src.GetRenamed/StdLib/Lib/tempfile.py diff --git a/Src/StdLib/Lib/test/185test.db b/Src.GetRenamed/StdLib/Lib/test/185test.db similarity index 100% rename from Src/StdLib/Lib/test/185test.db rename to Src.GetRenamed/StdLib/Lib/test/185test.db diff --git a/Src/StdLib/Lib/test/Sine-1000Hz-300ms.aif b/Src.GetRenamed/StdLib/Lib/test/Sine-1000Hz-300ms.aif similarity index 100% rename from Src/StdLib/Lib/test/Sine-1000Hz-300ms.aif rename to Src.GetRenamed/StdLib/Lib/test/Sine-1000Hz-300ms.aif diff --git a/Src/StdLib/Lib/test/__init__.py b/Src.GetRenamed/StdLib/Lib/test/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/__init__.py rename to Src.GetRenamed/StdLib/Lib/test/__init__.py diff --git a/Src/StdLib/Lib/test/__main__.py b/Src.GetRenamed/StdLib/Lib/test/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/__main__.py rename to Src.GetRenamed/StdLib/Lib/test/__main__.py diff --git a/Src/StdLib/Lib/test/_test_multiprocessing.py b/Src.GetRenamed/StdLib/Lib/test/_test_multiprocessing.py similarity index 100% rename from Src/StdLib/Lib/test/_test_multiprocessing.py rename to Src.GetRenamed/StdLib/Lib/test/_test_multiprocessing.py diff --git a/Src/StdLib/Lib/test/audiodata/pluck-alaw.aifc b/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-alaw.aifc similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-alaw.aifc rename to Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-alaw.aifc diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm16.aiff b/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm16.aiff similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm16.aiff rename to Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm16.aiff diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm16.au b/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm16.au similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm16.au rename to Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm16.au diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm16.wav b/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm16.wav similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm16.wav rename to Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm16.wav diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm24.aiff b/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm24.aiff similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm24.aiff rename to Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm24.aiff diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm24.au b/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm24.au similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm24.au rename to Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm24.au diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm24.wav b/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm24.wav similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm24.wav rename to Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm24.wav diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm32.aiff b/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm32.aiff similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm32.aiff rename to Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm32.aiff diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm32.au b/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm32.au similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm32.au rename to Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm32.au diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm32.wav b/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm32.wav similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm32.wav rename to Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm32.wav diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm8.aiff b/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm8.aiff similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm8.aiff rename to Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm8.aiff diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm8.au b/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm8.au similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm8.au rename to Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm8.au diff --git a/Src/StdLib/Lib/test/audiodata/pluck-pcm8.wav b/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm8.wav similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-pcm8.wav rename to Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm8.wav diff --git a/Src/StdLib/Lib/test/audiodata/pluck-ulaw.aifc b/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-ulaw.aifc similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-ulaw.aifc rename to Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-ulaw.aifc diff --git a/Src/StdLib/Lib/test/audiodata/pluck-ulaw.au b/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-ulaw.au similarity index 100% rename from Src/StdLib/Lib/test/audiodata/pluck-ulaw.au rename to Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-ulaw.au diff --git a/Src/StdLib/Lib/test/audiotest.au b/Src.GetRenamed/StdLib/Lib/test/audiotest.au similarity index 100% rename from Src/StdLib/Lib/test/audiotest.au rename to Src.GetRenamed/StdLib/Lib/test/audiotest.au diff --git a/Src/StdLib/Lib/test/audiotests.py b/Src.GetRenamed/StdLib/Lib/test/audiotests.py similarity index 100% rename from Src/StdLib/Lib/test/audiotests.py rename to Src.GetRenamed/StdLib/Lib/test/audiotests.py diff --git a/Src/StdLib/Lib/test/autotest.py b/Src.GetRenamed/StdLib/Lib/test/autotest.py similarity index 100% rename from Src/StdLib/Lib/test/autotest.py rename to Src.GetRenamed/StdLib/Lib/test/autotest.py diff --git a/Src/StdLib/Lib/test/bad_coding.py b/Src.GetRenamed/StdLib/Lib/test/bad_coding.py similarity index 100% rename from Src/StdLib/Lib/test/bad_coding.py rename to Src.GetRenamed/StdLib/Lib/test/bad_coding.py diff --git a/Src/StdLib/Lib/test/bad_coding2.py b/Src.GetRenamed/StdLib/Lib/test/bad_coding2.py similarity index 100% rename from Src/StdLib/Lib/test/bad_coding2.py rename to Src.GetRenamed/StdLib/Lib/test/bad_coding2.py diff --git a/Src/StdLib/Lib/test/badcert.pem b/Src.GetRenamed/StdLib/Lib/test/badcert.pem similarity index 100% rename from Src/StdLib/Lib/test/badcert.pem rename to Src.GetRenamed/StdLib/Lib/test/badcert.pem diff --git a/Src/StdLib/Lib/test/badkey.pem b/Src.GetRenamed/StdLib/Lib/test/badkey.pem similarity index 100% rename from Src/StdLib/Lib/test/badkey.pem rename to Src.GetRenamed/StdLib/Lib/test/badkey.pem diff --git a/Src/StdLib/Lib/test/badsyntax_3131.py b/Src.GetRenamed/StdLib/Lib/test/badsyntax_3131.py similarity index 100% rename from Src/StdLib/Lib/test/badsyntax_3131.py rename to Src.GetRenamed/StdLib/Lib/test/badsyntax_3131.py diff --git a/Src/StdLib/Lib/test/badsyntax_future10.py b/Src.GetRenamed/StdLib/Lib/test/badsyntax_future10.py similarity index 100% rename from Src/StdLib/Lib/test/badsyntax_future10.py rename to Src.GetRenamed/StdLib/Lib/test/badsyntax_future10.py diff --git a/Src/StdLib/Lib/test/badsyntax_future3.py b/Src.GetRenamed/StdLib/Lib/test/badsyntax_future3.py similarity index 100% rename from Src/StdLib/Lib/test/badsyntax_future3.py rename to Src.GetRenamed/StdLib/Lib/test/badsyntax_future3.py diff --git a/Src/StdLib/Lib/test/badsyntax_future4.py b/Src.GetRenamed/StdLib/Lib/test/badsyntax_future4.py similarity index 100% rename from Src/StdLib/Lib/test/badsyntax_future4.py rename to Src.GetRenamed/StdLib/Lib/test/badsyntax_future4.py diff --git a/Src/StdLib/Lib/test/badsyntax_future5.py b/Src.GetRenamed/StdLib/Lib/test/badsyntax_future5.py similarity index 100% rename from Src/StdLib/Lib/test/badsyntax_future5.py rename to Src.GetRenamed/StdLib/Lib/test/badsyntax_future5.py diff --git a/Src/StdLib/Lib/test/badsyntax_future6.py b/Src.GetRenamed/StdLib/Lib/test/badsyntax_future6.py similarity index 100% rename from Src/StdLib/Lib/test/badsyntax_future6.py rename to Src.GetRenamed/StdLib/Lib/test/badsyntax_future6.py diff --git a/Src/StdLib/Lib/test/badsyntax_future7.py b/Src.GetRenamed/StdLib/Lib/test/badsyntax_future7.py similarity index 100% rename from Src/StdLib/Lib/test/badsyntax_future7.py rename to Src.GetRenamed/StdLib/Lib/test/badsyntax_future7.py diff --git a/Src/StdLib/Lib/test/badsyntax_future8.py b/Src.GetRenamed/StdLib/Lib/test/badsyntax_future8.py similarity index 100% rename from Src/StdLib/Lib/test/badsyntax_future8.py rename to Src.GetRenamed/StdLib/Lib/test/badsyntax_future8.py diff --git a/Src/StdLib/Lib/test/badsyntax_future9.py b/Src.GetRenamed/StdLib/Lib/test/badsyntax_future9.py similarity index 100% rename from Src/StdLib/Lib/test/badsyntax_future9.py rename to Src.GetRenamed/StdLib/Lib/test/badsyntax_future9.py diff --git a/Src/StdLib/Lib/test/badsyntax_pep3120.py b/Src.GetRenamed/StdLib/Lib/test/badsyntax_pep3120.py similarity index 100% rename from Src/StdLib/Lib/test/badsyntax_pep3120.py rename to Src.GetRenamed/StdLib/Lib/test/badsyntax_pep3120.py diff --git a/Src/StdLib/Lib/test/buffer_tests.py b/Src.GetRenamed/StdLib/Lib/test/buffer_tests.py similarity index 100% rename from Src/StdLib/Lib/test/buffer_tests.py rename to Src.GetRenamed/StdLib/Lib/test/buffer_tests.py diff --git a/Src/StdLib/Lib/test/bytecode_helper.py b/Src.GetRenamed/StdLib/Lib/test/bytecode_helper.py similarity index 100% rename from Src/StdLib/Lib/test/bytecode_helper.py rename to Src.GetRenamed/StdLib/Lib/test/bytecode_helper.py diff --git a/Src/StdLib/Lib/test/capath/0e4015b9.0 b/Src.GetRenamed/StdLib/Lib/test/capath/0e4015b9.0 similarity index 100% rename from Src/StdLib/Lib/test/capath/0e4015b9.0 rename to Src.GetRenamed/StdLib/Lib/test/capath/0e4015b9.0 diff --git a/Src/StdLib/Lib/test/capath/4e1295a3.0 b/Src.GetRenamed/StdLib/Lib/test/capath/4e1295a3.0 similarity index 100% rename from Src/StdLib/Lib/test/capath/4e1295a3.0 rename to Src.GetRenamed/StdLib/Lib/test/capath/4e1295a3.0 diff --git a/Src/StdLib/Lib/test/capath/5ed36f99.0 b/Src.GetRenamed/StdLib/Lib/test/capath/5ed36f99.0 similarity index 100% rename from Src/StdLib/Lib/test/capath/5ed36f99.0 rename to Src.GetRenamed/StdLib/Lib/test/capath/5ed36f99.0 diff --git a/Src/StdLib/Lib/test/capath/6e88d7b8.0 b/Src.GetRenamed/StdLib/Lib/test/capath/6e88d7b8.0 similarity index 100% rename from Src/StdLib/Lib/test/capath/6e88d7b8.0 rename to Src.GetRenamed/StdLib/Lib/test/capath/6e88d7b8.0 diff --git a/Src/StdLib/Lib/test/capath/99d0fa06.0 b/Src.GetRenamed/StdLib/Lib/test/capath/99d0fa06.0 similarity index 100% rename from Src/StdLib/Lib/test/capath/99d0fa06.0 rename to Src.GetRenamed/StdLib/Lib/test/capath/99d0fa06.0 diff --git a/Src/StdLib/Lib/test/capath/ce7b8643.0 b/Src.GetRenamed/StdLib/Lib/test/capath/ce7b8643.0 similarity index 100% rename from Src/StdLib/Lib/test/capath/ce7b8643.0 rename to Src.GetRenamed/StdLib/Lib/test/capath/ce7b8643.0 diff --git a/Src/StdLib/Lib/test/cfgparser.1 b/Src.GetRenamed/StdLib/Lib/test/cfgparser.1 similarity index 100% rename from Src/StdLib/Lib/test/cfgparser.1 rename to Src.GetRenamed/StdLib/Lib/test/cfgparser.1 diff --git a/Src/StdLib/Lib/test/cfgparser.2 b/Src.GetRenamed/StdLib/Lib/test/cfgparser.2 similarity index 100% rename from Src/StdLib/Lib/test/cfgparser.2 rename to Src.GetRenamed/StdLib/Lib/test/cfgparser.2 diff --git a/Src/StdLib/Lib/test/cfgparser.3 b/Src.GetRenamed/StdLib/Lib/test/cfgparser.3 similarity index 100% rename from Src/StdLib/Lib/test/cfgparser.3 rename to Src.GetRenamed/StdLib/Lib/test/cfgparser.3 diff --git a/Src/StdLib/Lib/test/check_soundcard.vbs b/Src.GetRenamed/StdLib/Lib/test/check_soundcard.vbs similarity index 100% rename from Src/StdLib/Lib/test/check_soundcard.vbs rename to Src.GetRenamed/StdLib/Lib/test/check_soundcard.vbs diff --git a/Src/StdLib/Lib/test/cjkencodings/big5-utf8.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/big5-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/big5-utf8.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/big5-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/big5.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/big5.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/big5.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/big5.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/big5hkscs.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/big5hkscs.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/big5hkscs.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/big5hkscs.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/cp949-utf8.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/cp949-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/cp949-utf8.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/cp949-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/cp949.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/cp949.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/cp949.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/cp949.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/euc_jp.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_jp.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/euc_jp.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_jp.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/euc_kr.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_kr.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/euc_kr.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_kr.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/gb18030.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/gb18030.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/gb18030.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/gb18030.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/gb2312.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/gb2312.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/gb2312.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/gb2312.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/gbk-utf8.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/gbk-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/gbk-utf8.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/gbk-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/gbk.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/gbk.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/gbk.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/gbk.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/hz-utf8.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/hz-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/hz-utf8.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/hz-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/hz.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/hz.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/hz.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/hz.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/iso2022_jp.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/iso2022_jp.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/iso2022_jp.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/iso2022_jp.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/iso2022_kr.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/iso2022_kr.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/iso2022_kr.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/iso2022_kr.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/johab-utf8.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/johab-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/johab-utf8.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/johab-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/johab.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/johab.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/johab.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/johab.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/shift_jis.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/shift_jis.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/shift_jis.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/shift_jis.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt diff --git a/Src/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt b/Src.GetRenamed/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt similarity index 100% rename from Src/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt rename to Src.GetRenamed/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt diff --git a/Src/StdLib/Lib/test/cmath_testcases.txt b/Src.GetRenamed/StdLib/Lib/test/cmath_testcases.txt similarity index 100% rename from Src/StdLib/Lib/test/cmath_testcases.txt rename to Src.GetRenamed/StdLib/Lib/test/cmath_testcases.txt diff --git a/Src/StdLib/Lib/test/coding20731.py b/Src.GetRenamed/StdLib/Lib/test/coding20731.py similarity index 100% rename from Src/StdLib/Lib/test/coding20731.py rename to Src.GetRenamed/StdLib/Lib/test/coding20731.py diff --git a/Src/StdLib/Lib/test/crashers/README b/Src.GetRenamed/StdLib/Lib/test/crashers/README similarity index 100% rename from Src/StdLib/Lib/test/crashers/README rename to Src.GetRenamed/StdLib/Lib/test/crashers/README diff --git a/Src/StdLib/Lib/test/crashers/bogus_code_obj.py b/Src.GetRenamed/StdLib/Lib/test/crashers/bogus_code_obj.py similarity index 100% rename from Src/StdLib/Lib/test/crashers/bogus_code_obj.py rename to Src.GetRenamed/StdLib/Lib/test/crashers/bogus_code_obj.py diff --git a/Src/StdLib/Lib/test/crashers/gc_inspection.py b/Src.GetRenamed/StdLib/Lib/test/crashers/gc_inspection.py similarity index 100% rename from Src/StdLib/Lib/test/crashers/gc_inspection.py rename to Src.GetRenamed/StdLib/Lib/test/crashers/gc_inspection.py diff --git a/Src/StdLib/Lib/test/crashers/infinite_loop_re.py b/Src.GetRenamed/StdLib/Lib/test/crashers/infinite_loop_re.py similarity index 100% rename from Src/StdLib/Lib/test/crashers/infinite_loop_re.py rename to Src.GetRenamed/StdLib/Lib/test/crashers/infinite_loop_re.py diff --git a/Src/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py b/Src.GetRenamed/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py similarity index 100% rename from Src/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py rename to Src.GetRenamed/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py diff --git a/Src/StdLib/Lib/test/crashers/recursive_call.py b/Src.GetRenamed/StdLib/Lib/test/crashers/recursive_call.py similarity index 100% rename from Src/StdLib/Lib/test/crashers/recursive_call.py rename to Src.GetRenamed/StdLib/Lib/test/crashers/recursive_call.py diff --git a/Src/StdLib/Lib/test/crashers/trace_at_recursion_limit.py b/Src.GetRenamed/StdLib/Lib/test/crashers/trace_at_recursion_limit.py similarity index 100% rename from Src/StdLib/Lib/test/crashers/trace_at_recursion_limit.py rename to Src.GetRenamed/StdLib/Lib/test/crashers/trace_at_recursion_limit.py diff --git a/Src/StdLib/Lib/test/crashers/underlying_dict.py b/Src.GetRenamed/StdLib/Lib/test/crashers/underlying_dict.py similarity index 100% rename from Src/StdLib/Lib/test/crashers/underlying_dict.py rename to Src.GetRenamed/StdLib/Lib/test/crashers/underlying_dict.py diff --git a/Src/StdLib/Lib/test/curses_tests.py b/Src.GetRenamed/StdLib/Lib/test/curses_tests.py similarity index 100% rename from Src/StdLib/Lib/test/curses_tests.py rename to Src.GetRenamed/StdLib/Lib/test/curses_tests.py diff --git a/Src/StdLib/Lib/test/data/README b/Src.GetRenamed/StdLib/Lib/test/data/README similarity index 100% rename from Src/StdLib/Lib/test/data/README rename to Src.GetRenamed/StdLib/Lib/test/data/README diff --git a/Src/StdLib/Lib/test/datetimetester.py b/Src.GetRenamed/StdLib/Lib/test/datetimetester.py similarity index 100% rename from Src/StdLib/Lib/test/datetimetester.py rename to Src.GetRenamed/StdLib/Lib/test/datetimetester.py diff --git a/Src/StdLib/Lib/test/decimaltestdata/abs.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/abs.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/abs.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/abs.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/add.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/add.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/add.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/add.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/and.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/and.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/and.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/and.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/base.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/base.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/base.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/base.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/clamp.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/clamp.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/clamp.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/clamp.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/class.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/class.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/class.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/class.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/compare.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/compare.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/compare.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/compare.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/comparetotal.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/comparetotal.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/comparetotal.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/comparetotal.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/copy.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/copy.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/copy.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/copy.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/copyabs.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/copyabs.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/copyabs.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/copyabs.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/copynegate.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/copynegate.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/copynegate.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/copynegate.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/copysign.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/copysign.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/copysign.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/copysign.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddAbs.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddAbs.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddAbs.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddAbs.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddAdd.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddAdd.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddAdd.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddAdd.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddAnd.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddAnd.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddAnd.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddAnd.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddBase.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddBase.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddBase.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddBase.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddClass.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddClass.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddClass.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddClass.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddCompare.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCompare.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddCompare.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCompare.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddCopy.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCopy.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddCopy.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCopy.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddDivide.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddDivide.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddDivide.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddDivide.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddEncode.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddEncode.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddEncode.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddEncode.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddFMA.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddFMA.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddFMA.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddFMA.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddInvert.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddInvert.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddInvert.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddInvert.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddLogB.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddLogB.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddLogB.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddLogB.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddMax.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMax.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddMax.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMax.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddMin.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMin.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddMin.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMin.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddMinus.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMinus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddMinus.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMinus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddOr.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddOr.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddOr.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddOr.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddPlus.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddPlus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddPlus.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddPlus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddReduce.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddReduce.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddReduce.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddReduce.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddRotate.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddRotate.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddRotate.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddRotate.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddShift.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddShift.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddShift.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddShift.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ddXor.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddXor.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ddXor.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddXor.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/decDouble.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/decDouble.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/decDouble.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/decDouble.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/decQuad.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/decQuad.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/decQuad.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/decQuad.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/decSingle.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/decSingle.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/decSingle.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/decSingle.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/divide.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/divide.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/divide.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/divide.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/divideint.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/divideint.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/divideint.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/divideint.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqAbs.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqAbs.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqAbs.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqAbs.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqAdd.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqAdd.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqAdd.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqAdd.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqAnd.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqAnd.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqAnd.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqAnd.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqBase.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqBase.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqBase.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqBase.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqClass.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqClass.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqClass.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqClass.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqCompare.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCompare.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqCompare.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCompare.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqCopy.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCopy.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqCopy.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCopy.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqDivide.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqDivide.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqDivide.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqDivide.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqEncode.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqEncode.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqEncode.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqEncode.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqFMA.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqFMA.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqFMA.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqFMA.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqInvert.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqInvert.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqInvert.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqInvert.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqLogB.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqLogB.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqLogB.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqLogB.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqMax.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMax.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqMax.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMax.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqMin.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMin.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqMin.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMin.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqMinus.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMinus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqMinus.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMinus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqOr.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqOr.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqOr.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqOr.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqPlus.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqPlus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqPlus.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqPlus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqReduce.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqReduce.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqReduce.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqReduce.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqRotate.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqRotate.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqRotate.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqRotate.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqShift.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqShift.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqShift.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqShift.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dqXor.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqXor.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dqXor.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqXor.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dsBase.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dsBase.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dsBase.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dsBase.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/dsEncode.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dsEncode.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/dsEncode.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dsEncode.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/exp.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/exp.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/exp.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/exp.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/extra.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/extra.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/extra.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/extra.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/fma.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/fma.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/fma.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/fma.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/inexact.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/inexact.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/inexact.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/inexact.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/invert.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/invert.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/invert.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/invert.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/ln.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ln.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/ln.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ln.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/log10.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/log10.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/log10.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/log10.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/logb.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/logb.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/logb.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/logb.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/max.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/max.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/max.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/max.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/maxmag.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/maxmag.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/maxmag.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/maxmag.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/min.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/min.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/min.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/min.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/minmag.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/minmag.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/minmag.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/minmag.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/minus.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/minus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/minus.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/minus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/multiply.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/multiply.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/multiply.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/multiply.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/nextminus.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/nextminus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/nextminus.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/nextminus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/nextplus.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/nextplus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/nextplus.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/nextplus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/nexttoward.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/nexttoward.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/nexttoward.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/nexttoward.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/or.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/or.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/or.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/or.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/plus.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/plus.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/plus.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/plus.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/power.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/power.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/power.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/power.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/powersqrt.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/powersqrt.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/powersqrt.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/powersqrt.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/quantize.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/quantize.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/quantize.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/quantize.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/randomBound32.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/randomBound32.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/randomBound32.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/randomBound32.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/randoms.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/randoms.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/randoms.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/randoms.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/reduce.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/reduce.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/reduce.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/reduce.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/remainder.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/remainder.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/remainder.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/remainder.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/remainderNear.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/remainderNear.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/remainderNear.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/remainderNear.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/rescale.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/rescale.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/rescale.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/rescale.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/rotate.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/rotate.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/rotate.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/rotate.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/rounding.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/rounding.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/rounding.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/rounding.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/samequantum.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/samequantum.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/samequantum.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/samequantum.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/scaleb.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/scaleb.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/scaleb.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/scaleb.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/shift.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/shift.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/shift.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/shift.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/squareroot.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/squareroot.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/squareroot.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/squareroot.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/subtract.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/subtract.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/subtract.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/subtract.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/testall.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/testall.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/testall.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/testall.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/tointegral.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/tointegral.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/tointegral.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/tointegral.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/tointegralx.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/tointegralx.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/tointegralx.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/tointegralx.decTest diff --git a/Src/StdLib/Lib/test/decimaltestdata/xor.decTest b/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/xor.decTest similarity index 100% rename from Src/StdLib/Lib/test/decimaltestdata/xor.decTest rename to Src.GetRenamed/StdLib/Lib/test/decimaltestdata/xor.decTest diff --git a/Src/StdLib/Lib/test/dh1024.pem b/Src.GetRenamed/StdLib/Lib/test/dh1024.pem similarity index 100% rename from Src/StdLib/Lib/test/dh1024.pem rename to Src.GetRenamed/StdLib/Lib/test/dh1024.pem diff --git a/Src/StdLib/Lib/test/dis_module.py b/Src.GetRenamed/StdLib/Lib/test/dis_module.py similarity index 100% rename from Src/StdLib/Lib/test/dis_module.py rename to Src.GetRenamed/StdLib/Lib/test/dis_module.py diff --git a/Src/StdLib/Lib/test/doctest_aliases.py b/Src.GetRenamed/StdLib/Lib/test/doctest_aliases.py similarity index 100% rename from Src/StdLib/Lib/test/doctest_aliases.py rename to Src.GetRenamed/StdLib/Lib/test/doctest_aliases.py diff --git a/Src/StdLib/Lib/test/double_const.py b/Src.GetRenamed/StdLib/Lib/test/double_const.py similarity index 100% rename from Src/StdLib/Lib/test/double_const.py rename to Src.GetRenamed/StdLib/Lib/test/double_const.py diff --git a/Src/StdLib/Lib/test/empty.vbs b/Src.GetRenamed/StdLib/Lib/test/empty.vbs similarity index 100% rename from Src/StdLib/Lib/test/empty.vbs rename to Src.GetRenamed/StdLib/Lib/test/empty.vbs diff --git a/Src/StdLib/Lib/test/encoded_modules/__init__.py b/Src.GetRenamed/StdLib/Lib/test/encoded_modules/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/encoded_modules/__init__.py rename to Src.GetRenamed/StdLib/Lib/test/encoded_modules/__init__.py diff --git a/Src/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py b/Src.GetRenamed/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py similarity index 100% rename from Src/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py rename to Src.GetRenamed/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py diff --git a/Src/StdLib/Lib/test/encoded_modules/module_koi8_r.py b/Src.GetRenamed/StdLib/Lib/test/encoded_modules/module_koi8_r.py similarity index 100% rename from Src/StdLib/Lib/test/encoded_modules/module_koi8_r.py rename to Src.GetRenamed/StdLib/Lib/test/encoded_modules/module_koi8_r.py diff --git a/Src/StdLib/Lib/test/exception_hierarchy.txt b/Src.GetRenamed/StdLib/Lib/test/exception_hierarchy.txt similarity index 100% rename from Src/StdLib/Lib/test/exception_hierarchy.txt rename to Src.GetRenamed/StdLib/Lib/test/exception_hierarchy.txt diff --git a/Src/StdLib/Lib/test/final_a.py b/Src.GetRenamed/StdLib/Lib/test/final_a.py similarity index 100% rename from Src/StdLib/Lib/test/final_a.py rename to Src.GetRenamed/StdLib/Lib/test/final_a.py diff --git a/Src/StdLib/Lib/test/final_b.py b/Src.GetRenamed/StdLib/Lib/test/final_b.py similarity index 100% rename from Src/StdLib/Lib/test/final_b.py rename to Src.GetRenamed/StdLib/Lib/test/final_b.py diff --git a/Src/StdLib/Lib/test/floating_points.txt b/Src.GetRenamed/StdLib/Lib/test/floating_points.txt similarity index 100% rename from Src/StdLib/Lib/test/floating_points.txt rename to Src.GetRenamed/StdLib/Lib/test/floating_points.txt diff --git a/Src/StdLib/Lib/test/fork_wait.py b/Src.GetRenamed/StdLib/Lib/test/fork_wait.py similarity index 100% rename from Src/StdLib/Lib/test/fork_wait.py rename to Src.GetRenamed/StdLib/Lib/test/fork_wait.py diff --git a/Src/StdLib/Lib/test/formatfloat_testcases.txt b/Src.GetRenamed/StdLib/Lib/test/formatfloat_testcases.txt similarity index 100% rename from Src/StdLib/Lib/test/formatfloat_testcases.txt rename to Src.GetRenamed/StdLib/Lib/test/formatfloat_testcases.txt diff --git a/Src/StdLib/Lib/test/future_test1.py b/Src.GetRenamed/StdLib/Lib/test/future_test1.py similarity index 100% rename from Src/StdLib/Lib/test/future_test1.py rename to Src.GetRenamed/StdLib/Lib/test/future_test1.py diff --git a/Src/StdLib/Lib/test/future_test2.py b/Src.GetRenamed/StdLib/Lib/test/future_test2.py similarity index 100% rename from Src/StdLib/Lib/test/future_test2.py rename to Src.GetRenamed/StdLib/Lib/test/future_test2.py diff --git a/Src/StdLib/Lib/test/gdb_sample.py b/Src.GetRenamed/StdLib/Lib/test/gdb_sample.py similarity index 100% rename from Src/StdLib/Lib/test/gdb_sample.py rename to Src.GetRenamed/StdLib/Lib/test/gdb_sample.py diff --git a/Src/StdLib/Lib/test/ieee754.txt b/Src.GetRenamed/StdLib/Lib/test/ieee754.txt similarity index 100% rename from Src/StdLib/Lib/test/ieee754.txt rename to Src.GetRenamed/StdLib/Lib/test/ieee754.txt diff --git a/Src/StdLib/Lib/test/imghdrdata/python.bmp b/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.bmp similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.bmp rename to Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.bmp diff --git a/Src/StdLib/Lib/test/imghdrdata/python.gif b/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.gif similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.gif rename to Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.gif diff --git a/Src/StdLib/Lib/test/imghdrdata/python.jpg b/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.jpg similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.jpg rename to Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.jpg diff --git a/Src/StdLib/Lib/test/imghdrdata/python.pbm b/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.pbm similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.pbm rename to Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.pbm diff --git a/Src/StdLib/Lib/test/imghdrdata/python.pgm b/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.pgm similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.pgm rename to Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.pgm diff --git a/Src/StdLib/Lib/test/imghdrdata/python.png b/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.png similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.png rename to Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.png diff --git a/Src/StdLib/Lib/test/imghdrdata/python.ppm b/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.ppm similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.ppm rename to Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.ppm diff --git a/Src/StdLib/Lib/test/imghdrdata/python.ras b/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.ras similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.ras rename to Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.ras diff --git a/Src/StdLib/Lib/test/imghdrdata/python.sgi b/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.sgi similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.sgi rename to Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.sgi diff --git a/Src/StdLib/Lib/test/imghdrdata/python.tiff b/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.tiff similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.tiff rename to Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.tiff diff --git a/Src/StdLib/Lib/test/imghdrdata/python.xbm b/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.xbm similarity index 100% rename from Src/StdLib/Lib/test/imghdrdata/python.xbm rename to Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.xbm diff --git a/Src/StdLib/Lib/test/inspect_fodder.py b/Src.GetRenamed/StdLib/Lib/test/inspect_fodder.py similarity index 100% rename from Src/StdLib/Lib/test/inspect_fodder.py rename to Src.GetRenamed/StdLib/Lib/test/inspect_fodder.py diff --git a/Src/StdLib/Lib/test/inspect_fodder2.py b/Src.GetRenamed/StdLib/Lib/test/inspect_fodder2.py similarity index 100% rename from Src/StdLib/Lib/test/inspect_fodder2.py rename to Src.GetRenamed/StdLib/Lib/test/inspect_fodder2.py diff --git a/Src/StdLib/Lib/test/keycert.passwd.pem b/Src.GetRenamed/StdLib/Lib/test/keycert.passwd.pem similarity index 100% rename from Src/StdLib/Lib/test/keycert.passwd.pem rename to Src.GetRenamed/StdLib/Lib/test/keycert.passwd.pem diff --git a/PythonTests/modules/network_related/keycert.pem b/Src.GetRenamed/StdLib/Lib/test/keycert.pem similarity index 100% rename from PythonTests/modules/network_related/keycert.pem rename to Src.GetRenamed/StdLib/Lib/test/keycert.pem diff --git a/Src/StdLib/Lib/test/keycert2.pem b/Src.GetRenamed/StdLib/Lib/test/keycert2.pem similarity index 100% rename from Src/StdLib/Lib/test/keycert2.pem rename to Src.GetRenamed/StdLib/Lib/test/keycert2.pem diff --git a/Src/StdLib/Lib/test/keycert3.pem b/Src.GetRenamed/StdLib/Lib/test/keycert3.pem similarity index 100% rename from Src/StdLib/Lib/test/keycert3.pem rename to Src.GetRenamed/StdLib/Lib/test/keycert3.pem diff --git a/Src/StdLib/Lib/test/keycert4.pem b/Src.GetRenamed/StdLib/Lib/test/keycert4.pem similarity index 100% rename from Src/StdLib/Lib/test/keycert4.pem rename to Src.GetRenamed/StdLib/Lib/test/keycert4.pem diff --git a/Src/StdLib/Lib/test/leakers/README.txt b/Src.GetRenamed/StdLib/Lib/test/leakers/README.txt similarity index 100% rename from Src/StdLib/Lib/test/leakers/README.txt rename to Src.GetRenamed/StdLib/Lib/test/leakers/README.txt diff --git a/Src/StdLib/Lib/email/mime/__init__.py b/Src.GetRenamed/StdLib/Lib/test/leakers/__init__.py similarity index 100% rename from Src/StdLib/Lib/email/mime/__init__.py rename to Src.GetRenamed/StdLib/Lib/test/leakers/__init__.py diff --git a/Src/StdLib/Lib/test/leakers/test_ctypes.py b/Src.GetRenamed/StdLib/Lib/test/leakers/test_ctypes.py similarity index 100% rename from Src/StdLib/Lib/test/leakers/test_ctypes.py rename to Src.GetRenamed/StdLib/Lib/test/leakers/test_ctypes.py diff --git a/Src/StdLib/Lib/test/leakers/test_selftype.py b/Src.GetRenamed/StdLib/Lib/test/leakers/test_selftype.py similarity index 100% rename from Src/StdLib/Lib/test/leakers/test_selftype.py rename to Src.GetRenamed/StdLib/Lib/test/leakers/test_selftype.py diff --git a/Src/StdLib/Lib/test/list_tests.py b/Src.GetRenamed/StdLib/Lib/test/list_tests.py similarity index 100% rename from Src/StdLib/Lib/test/list_tests.py rename to Src.GetRenamed/StdLib/Lib/test/list_tests.py diff --git a/Src/StdLib/Lib/test/lock_tests.py b/Src.GetRenamed/StdLib/Lib/test/lock_tests.py similarity index 100% rename from Src/StdLib/Lib/test/lock_tests.py rename to Src.GetRenamed/StdLib/Lib/test/lock_tests.py diff --git a/Src/StdLib/Lib/test/mailcap.txt b/Src.GetRenamed/StdLib/Lib/test/mailcap.txt similarity index 100% rename from Src/StdLib/Lib/test/mailcap.txt rename to Src.GetRenamed/StdLib/Lib/test/mailcap.txt diff --git a/Src/StdLib/Lib/test/make_ssl_certs.py b/Src.GetRenamed/StdLib/Lib/test/make_ssl_certs.py similarity index 100% rename from Src/StdLib/Lib/test/make_ssl_certs.py rename to Src.GetRenamed/StdLib/Lib/test/make_ssl_certs.py diff --git a/Src/StdLib/Lib/test/mapping_tests.py b/Src.GetRenamed/StdLib/Lib/test/mapping_tests.py similarity index 100% rename from Src/StdLib/Lib/test/mapping_tests.py rename to Src.GetRenamed/StdLib/Lib/test/mapping_tests.py diff --git a/Src/StdLib/Lib/test/math_testcases.txt b/Src.GetRenamed/StdLib/Lib/test/math_testcases.txt similarity index 100% rename from Src/StdLib/Lib/test/math_testcases.txt rename to Src.GetRenamed/StdLib/Lib/test/math_testcases.txt diff --git a/Src/StdLib/Lib/test/memory_watchdog.py b/Src.GetRenamed/StdLib/Lib/test/memory_watchdog.py similarity index 100% rename from Src/StdLib/Lib/test/memory_watchdog.py rename to Src.GetRenamed/StdLib/Lib/test/memory_watchdog.py diff --git a/Src/StdLib/Lib/test/mime.types b/Src.GetRenamed/StdLib/Lib/test/mime.types similarity index 100% rename from Src/StdLib/Lib/test/mime.types rename to Src.GetRenamed/StdLib/Lib/test/mime.types diff --git a/Src/StdLib/Lib/test/mock_socket.py b/Src.GetRenamed/StdLib/Lib/test/mock_socket.py similarity index 100% rename from Src/StdLib/Lib/test/mock_socket.py rename to Src.GetRenamed/StdLib/Lib/test/mock_socket.py diff --git a/Src/StdLib/Lib/test/mod_generics_cache.py b/Src.GetRenamed/StdLib/Lib/test/mod_generics_cache.py similarity index 100% rename from Src/StdLib/Lib/test/mod_generics_cache.py rename to Src.GetRenamed/StdLib/Lib/test/mod_generics_cache.py diff --git a/Src/StdLib/Lib/test/mp_fork_bomb.py b/Src.GetRenamed/StdLib/Lib/test/mp_fork_bomb.py similarity index 100% rename from Src/StdLib/Lib/test/mp_fork_bomb.py rename to Src.GetRenamed/StdLib/Lib/test/mp_fork_bomb.py diff --git a/Src/StdLib/Lib/test/multibytecodec_support.py b/Src.GetRenamed/StdLib/Lib/test/multibytecodec_support.py similarity index 100% rename from Src/StdLib/Lib/test/multibytecodec_support.py rename to Src.GetRenamed/StdLib/Lib/test/multibytecodec_support.py diff --git a/Src/StdLib/Lib/test/nokia.pem b/Src.GetRenamed/StdLib/Lib/test/nokia.pem similarity index 100% rename from Src/StdLib/Lib/test/nokia.pem rename to Src.GetRenamed/StdLib/Lib/test/nokia.pem diff --git a/Src/StdLib/Lib/test/nullbytecert.pem b/Src.GetRenamed/StdLib/Lib/test/nullbytecert.pem similarity index 100% rename from Src/StdLib/Lib/test/nullbytecert.pem rename to Src.GetRenamed/StdLib/Lib/test/nullbytecert.pem diff --git a/Src/StdLib/Lib/test/nullcert.pem b/Src.GetRenamed/StdLib/Lib/test/nullcert.pem similarity index 100% rename from Src/StdLib/Lib/test/nullcert.pem rename to Src.GetRenamed/StdLib/Lib/test/nullcert.pem diff --git a/Src/StdLib/Lib/test/outstanding_bugs.py b/Src.GetRenamed/StdLib/Lib/test/outstanding_bugs.py similarity index 100% rename from Src/StdLib/Lib/test/outstanding_bugs.py rename to Src.GetRenamed/StdLib/Lib/test/outstanding_bugs.py diff --git a/Src/StdLib/Lib/test/pickletester.py b/Src.GetRenamed/StdLib/Lib/test/pickletester.py similarity index 100% rename from Src/StdLib/Lib/test/pickletester.py rename to Src.GetRenamed/StdLib/Lib/test/pickletester.py diff --git a/Src/StdLib/Lib/test/profilee.py b/Src.GetRenamed/StdLib/Lib/test/profilee.py similarity index 100% rename from Src/StdLib/Lib/test/profilee.py rename to Src.GetRenamed/StdLib/Lib/test/profilee.py diff --git a/Src/StdLib/Lib/test/pstats.pck b/Src.GetRenamed/StdLib/Lib/test/pstats.pck similarity index 100% rename from Src/StdLib/Lib/test/pstats.pck rename to Src.GetRenamed/StdLib/Lib/test/pstats.pck diff --git a/Src/StdLib/Lib/test/pycacert.pem b/Src.GetRenamed/StdLib/Lib/test/pycacert.pem similarity index 100% rename from Src/StdLib/Lib/test/pycacert.pem rename to Src.GetRenamed/StdLib/Lib/test/pycacert.pem diff --git a/Src/StdLib/Lib/test/pycakey.pem b/Src.GetRenamed/StdLib/Lib/test/pycakey.pem similarity index 100% rename from Src/StdLib/Lib/test/pycakey.pem rename to Src.GetRenamed/StdLib/Lib/test/pycakey.pem diff --git a/Src/StdLib/Lib/test/pyclbr_input.py b/Src.GetRenamed/StdLib/Lib/test/pyclbr_input.py similarity index 100% rename from Src/StdLib/Lib/test/pyclbr_input.py rename to Src.GetRenamed/StdLib/Lib/test/pyclbr_input.py diff --git a/Src/StdLib/Lib/test/pydoc_mod.py b/Src.GetRenamed/StdLib/Lib/test/pydoc_mod.py similarity index 100% rename from Src/StdLib/Lib/test/pydoc_mod.py rename to Src.GetRenamed/StdLib/Lib/test/pydoc_mod.py diff --git a/Src/StdLib/Lib/test/pydocfodder.py b/Src.GetRenamed/StdLib/Lib/test/pydocfodder.py similarity index 100% rename from Src/StdLib/Lib/test/pydocfodder.py rename to Src.GetRenamed/StdLib/Lib/test/pydocfodder.py diff --git a/Src/StdLib/Lib/test/pystone.py b/Src.GetRenamed/StdLib/Lib/test/pystone.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/test/pystone.py rename to Src.GetRenamed/StdLib/Lib/test/pystone.py diff --git a/Src/StdLib/Lib/test/randv2_32.pck b/Src.GetRenamed/StdLib/Lib/test/randv2_32.pck similarity index 100% rename from Src/StdLib/Lib/test/randv2_32.pck rename to Src.GetRenamed/StdLib/Lib/test/randv2_32.pck diff --git a/Src/StdLib/Lib/test/randv2_64.pck b/Src.GetRenamed/StdLib/Lib/test/randv2_64.pck similarity index 100% rename from Src/StdLib/Lib/test/randv2_64.pck rename to Src.GetRenamed/StdLib/Lib/test/randv2_64.pck diff --git a/Src/StdLib/Lib/test/randv3.pck b/Src.GetRenamed/StdLib/Lib/test/randv3.pck similarity index 100% rename from Src/StdLib/Lib/test/randv3.pck rename to Src.GetRenamed/StdLib/Lib/test/randv3.pck diff --git a/Src/StdLib/Lib/test/re_tests.py b/Src.GetRenamed/StdLib/Lib/test/re_tests.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/test/re_tests.py rename to Src.GetRenamed/StdLib/Lib/test/re_tests.py diff --git a/Src/StdLib/Lib/test/regrtest.py b/Src.GetRenamed/StdLib/Lib/test/regrtest.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/test/regrtest.py rename to Src.GetRenamed/StdLib/Lib/test/regrtest.py diff --git a/Src/StdLib/Lib/test/relimport.py b/Src.GetRenamed/StdLib/Lib/test/relimport.py similarity index 100% rename from Src/StdLib/Lib/test/relimport.py rename to Src.GetRenamed/StdLib/Lib/test/relimport.py diff --git a/Src/StdLib/Lib/test/reperf.py b/Src.GetRenamed/StdLib/Lib/test/reperf.py similarity index 100% rename from Src/StdLib/Lib/test/reperf.py rename to Src.GetRenamed/StdLib/Lib/test/reperf.py diff --git a/Src/StdLib/Lib/test/revocation.crl b/Src.GetRenamed/StdLib/Lib/test/revocation.crl similarity index 100% rename from Src/StdLib/Lib/test/revocation.crl rename to Src.GetRenamed/StdLib/Lib/test/revocation.crl diff --git a/Src/StdLib/Lib/test/sample_doctest.py b/Src.GetRenamed/StdLib/Lib/test/sample_doctest.py similarity index 100% rename from Src/StdLib/Lib/test/sample_doctest.py rename to Src.GetRenamed/StdLib/Lib/test/sample_doctest.py diff --git a/Src/StdLib/Lib/test/sample_doctest_no_docstrings.py b/Src.GetRenamed/StdLib/Lib/test/sample_doctest_no_docstrings.py similarity index 100% rename from Src/StdLib/Lib/test/sample_doctest_no_docstrings.py rename to Src.GetRenamed/StdLib/Lib/test/sample_doctest_no_docstrings.py diff --git a/Src/StdLib/Lib/test/sample_doctest_no_doctests.py b/Src.GetRenamed/StdLib/Lib/test/sample_doctest_no_doctests.py similarity index 100% rename from Src/StdLib/Lib/test/sample_doctest_no_doctests.py rename to Src.GetRenamed/StdLib/Lib/test/sample_doctest_no_doctests.py diff --git a/Src/StdLib/Lib/test/script_helper.py b/Src.GetRenamed/StdLib/Lib/test/script_helper.py similarity index 100% rename from Src/StdLib/Lib/test/script_helper.py rename to Src.GetRenamed/StdLib/Lib/test/script_helper.py diff --git a/Src/StdLib/Lib/test/selfsigned_pythontestdotnet.pem b/Src.GetRenamed/StdLib/Lib/test/selfsigned_pythontestdotnet.pem similarity index 100% rename from Src/StdLib/Lib/test/selfsigned_pythontestdotnet.pem rename to Src.GetRenamed/StdLib/Lib/test/selfsigned_pythontestdotnet.pem diff --git a/Src/StdLib/Lib/test/seq_tests.py b/Src.GetRenamed/StdLib/Lib/test/seq_tests.py similarity index 100% rename from Src/StdLib/Lib/test/seq_tests.py rename to Src.GetRenamed/StdLib/Lib/test/seq_tests.py diff --git a/Src/StdLib/Lib/test/sgml_input.html b/Src.GetRenamed/StdLib/Lib/test/sgml_input.html similarity index 100% rename from Src/StdLib/Lib/test/sgml_input.html rename to Src.GetRenamed/StdLib/Lib/test/sgml_input.html diff --git a/Src/StdLib/Lib/test/sha256.pem b/Src.GetRenamed/StdLib/Lib/test/sha256.pem similarity index 100% rename from Src/StdLib/Lib/test/sha256.pem rename to Src.GetRenamed/StdLib/Lib/test/sha256.pem diff --git a/Src/StdLib/Lib/test/sndhdrdata/README b/Src.GetRenamed/StdLib/Lib/test/sndhdrdata/README similarity index 100% rename from Src/StdLib/Lib/test/sndhdrdata/README rename to Src.GetRenamed/StdLib/Lib/test/sndhdrdata/README diff --git a/Src/StdLib/Lib/test/sndhdrdata/sndhdr.8svx b/Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.8svx similarity index 100% rename from Src/StdLib/Lib/test/sndhdrdata/sndhdr.8svx rename to Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.8svx diff --git a/Src/StdLib/Lib/test/sndhdrdata/sndhdr.aifc b/Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.aifc similarity index 100% rename from Src/StdLib/Lib/test/sndhdrdata/sndhdr.aifc rename to Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.aifc diff --git a/Src/StdLib/Lib/test/sndhdrdata/sndhdr.aiff b/Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.aiff similarity index 100% rename from Src/StdLib/Lib/test/sndhdrdata/sndhdr.aiff rename to Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.aiff diff --git a/Src/StdLib/Lib/test/sndhdrdata/sndhdr.au b/Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.au similarity index 100% rename from Src/StdLib/Lib/test/sndhdrdata/sndhdr.au rename to Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.au diff --git a/Src/StdLib/Lib/test/sndhdrdata/sndhdr.hcom b/Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.hcom similarity index 100% rename from Src/StdLib/Lib/test/sndhdrdata/sndhdr.hcom rename to Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.hcom diff --git a/Src/StdLib/Lib/test/sndhdrdata/sndhdr.sndt b/Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.sndt similarity index 100% rename from Src/StdLib/Lib/test/sndhdrdata/sndhdr.sndt rename to Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.sndt diff --git a/Src/StdLib/Lib/test/sndhdrdata/sndhdr.voc b/Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.voc similarity index 100% rename from Src/StdLib/Lib/test/sndhdrdata/sndhdr.voc rename to Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.voc diff --git a/Src/StdLib/Lib/test/sndhdrdata/sndhdr.wav b/Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.wav similarity index 100% rename from Src/StdLib/Lib/test/sndhdrdata/sndhdr.wav rename to Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.wav diff --git a/Src/StdLib/Lib/test/sortperf.py b/Src.GetRenamed/StdLib/Lib/test/sortperf.py similarity index 100% rename from Src/StdLib/Lib/test/sortperf.py rename to Src.GetRenamed/StdLib/Lib/test/sortperf.py diff --git a/Src/StdLib/Lib/test/ssl_cert.pem b/Src.GetRenamed/StdLib/Lib/test/ssl_cert.pem similarity index 100% rename from Src/StdLib/Lib/test/ssl_cert.pem rename to Src.GetRenamed/StdLib/Lib/test/ssl_cert.pem diff --git a/Src/StdLib/Lib/test/ssl_key.passwd.pem b/Src.GetRenamed/StdLib/Lib/test/ssl_key.passwd.pem similarity index 100% rename from Src/StdLib/Lib/test/ssl_key.passwd.pem rename to Src.GetRenamed/StdLib/Lib/test/ssl_key.passwd.pem diff --git a/Src/StdLib/Lib/test/ssl_key.pem b/Src.GetRenamed/StdLib/Lib/test/ssl_key.pem similarity index 100% rename from Src/StdLib/Lib/test/ssl_key.pem rename to Src.GetRenamed/StdLib/Lib/test/ssl_key.pem diff --git a/Src/StdLib/Lib/test/ssl_servers.py b/Src.GetRenamed/StdLib/Lib/test/ssl_servers.py similarity index 100% rename from Src/StdLib/Lib/test/ssl_servers.py rename to Src.GetRenamed/StdLib/Lib/test/ssl_servers.py diff --git a/Src/StdLib/Lib/test/ssltests.py b/Src.GetRenamed/StdLib/Lib/test/ssltests.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/test/ssltests.py rename to Src.GetRenamed/StdLib/Lib/test/ssltests.py diff --git a/Src/StdLib/Lib/test/string_tests.py b/Src.GetRenamed/StdLib/Lib/test/string_tests.py similarity index 100% rename from Src/StdLib/Lib/test/string_tests.py rename to Src.GetRenamed/StdLib/Lib/test/string_tests.py diff --git a/Src/StdLib/Lib/test/subprocessdata/fd_status.py b/Src.GetRenamed/StdLib/Lib/test/subprocessdata/fd_status.py similarity index 100% rename from Src/StdLib/Lib/test/subprocessdata/fd_status.py rename to Src.GetRenamed/StdLib/Lib/test/subprocessdata/fd_status.py diff --git a/Src/StdLib/Lib/test/subprocessdata/input_reader.py b/Src.GetRenamed/StdLib/Lib/test/subprocessdata/input_reader.py similarity index 100% rename from Src/StdLib/Lib/test/subprocessdata/input_reader.py rename to Src.GetRenamed/StdLib/Lib/test/subprocessdata/input_reader.py diff --git a/Src/StdLib/Lib/test/subprocessdata/qcat.py b/Src.GetRenamed/StdLib/Lib/test/subprocessdata/qcat.py similarity index 100% rename from Src/StdLib/Lib/test/subprocessdata/qcat.py rename to Src.GetRenamed/StdLib/Lib/test/subprocessdata/qcat.py diff --git a/Src/StdLib/Lib/test/subprocessdata/qgrep.py b/Src.GetRenamed/StdLib/Lib/test/subprocessdata/qgrep.py similarity index 100% rename from Src/StdLib/Lib/test/subprocessdata/qgrep.py rename to Src.GetRenamed/StdLib/Lib/test/subprocessdata/qgrep.py diff --git a/Src/StdLib/Lib/test/subprocessdata/sigchild_ignore.py b/Src.GetRenamed/StdLib/Lib/test/subprocessdata/sigchild_ignore.py similarity index 100% rename from Src/StdLib/Lib/test/subprocessdata/sigchild_ignore.py rename to Src.GetRenamed/StdLib/Lib/test/subprocessdata/sigchild_ignore.py diff --git a/Src/StdLib/Lib/test/support/__init__.py b/Src.GetRenamed/StdLib/Lib/test/support/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/support/__init__.py rename to Src.GetRenamed/StdLib/Lib/test/support/__init__.py diff --git a/Src/StdLib/Lib/test/talos-2019-0758.pem b/Src.GetRenamed/StdLib/Lib/test/talos-2019-0758.pem similarity index 100% rename from Src/StdLib/Lib/test/talos-2019-0758.pem rename to Src.GetRenamed/StdLib/Lib/test/talos-2019-0758.pem diff --git a/Src/StdLib/Lib/test/test___all__.py b/Src.GetRenamed/StdLib/Lib/test/test___all__.py similarity index 100% rename from Src/StdLib/Lib/test/test___all__.py rename to Src.GetRenamed/StdLib/Lib/test/test___all__.py diff --git a/Src/StdLib/Lib/test/test___future__.py b/Src.GetRenamed/StdLib/Lib/test/test___future__.py similarity index 100% rename from Src/StdLib/Lib/test/test___future__.py rename to Src.GetRenamed/StdLib/Lib/test/test___future__.py diff --git a/Src/StdLib/Lib/test/test__locale.py b/Src.GetRenamed/StdLib/Lib/test/test__locale.py similarity index 100% rename from Src/StdLib/Lib/test/test__locale.py rename to Src.GetRenamed/StdLib/Lib/test/test__locale.py diff --git a/Src/StdLib/Lib/test/test__opcode.py b/Src.GetRenamed/StdLib/Lib/test/test__opcode.py similarity index 100% rename from Src/StdLib/Lib/test/test__opcode.py rename to Src.GetRenamed/StdLib/Lib/test/test__opcode.py diff --git a/Src/StdLib/Lib/test/test__osx_support.py b/Src.GetRenamed/StdLib/Lib/test/test__osx_support.py similarity index 100% rename from Src/StdLib/Lib/test/test__osx_support.py rename to Src.GetRenamed/StdLib/Lib/test/test__osx_support.py diff --git a/Src/StdLib/Lib/test/test_abc.py b/Src.GetRenamed/StdLib/Lib/test/test_abc.py similarity index 100% rename from Src/StdLib/Lib/test/test_abc.py rename to Src.GetRenamed/StdLib/Lib/test/test_abc.py diff --git a/Src/StdLib/Lib/test/test_abstract_numbers.py b/Src.GetRenamed/StdLib/Lib/test/test_abstract_numbers.py similarity index 100% rename from Src/StdLib/Lib/test/test_abstract_numbers.py rename to Src.GetRenamed/StdLib/Lib/test/test_abstract_numbers.py diff --git a/Src/StdLib/Lib/test/test_aifc.py b/Src.GetRenamed/StdLib/Lib/test/test_aifc.py similarity index 100% rename from Src/StdLib/Lib/test/test_aifc.py rename to Src.GetRenamed/StdLib/Lib/test/test_aifc.py diff --git a/Src/StdLib/Lib/test/test_argparse.py b/Src.GetRenamed/StdLib/Lib/test/test_argparse.py similarity index 100% rename from Src/StdLib/Lib/test/test_argparse.py rename to Src.GetRenamed/StdLib/Lib/test/test_argparse.py diff --git a/Src/StdLib/Lib/test/test_array.py b/Src.GetRenamed/StdLib/Lib/test/test_array.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/test/test_array.py rename to Src.GetRenamed/StdLib/Lib/test/test_array.py diff --git a/Src/StdLib/Lib/test/test_ast.py b/Src.GetRenamed/StdLib/Lib/test/test_ast.py similarity index 100% rename from Src/StdLib/Lib/test/test_ast.py rename to Src.GetRenamed/StdLib/Lib/test/test_ast.py diff --git a/Src/StdLib/Lib/test/test_asynchat.py b/Src.GetRenamed/StdLib/Lib/test/test_asynchat.py similarity index 100% rename from Src/StdLib/Lib/test/test_asynchat.py rename to Src.GetRenamed/StdLib/Lib/test/test_asynchat.py diff --git a/Src/StdLib/Lib/test/test_asyncio/__init__.py b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/__init__.py rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/__init__.py diff --git a/Src/StdLib/Lib/test/test_asyncio/__main__.py b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/__main__.py rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/__main__.py diff --git a/Src/StdLib/Lib/test/test_asyncio/echo.py b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/echo.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/echo.py rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/echo.py diff --git a/Src/StdLib/Lib/test/test_asyncio/echo2.py b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/echo2.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/echo2.py rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/echo2.py diff --git a/Src/StdLib/Lib/test/test_asyncio/echo3.py b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/echo3.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/echo3.py rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/echo3.py diff --git a/Src/StdLib/Lib/test/test_asyncio/keycert3.pem b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/keycert3.pem similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/keycert3.pem rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/keycert3.pem diff --git a/Src/StdLib/Lib/test/test_asyncio/pycacert.pem b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/pycacert.pem similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/pycacert.pem rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/pycacert.pem diff --git a/Src/StdLib/Lib/test/test_asyncio/ssl_cert.pem b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/ssl_cert.pem similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/ssl_cert.pem rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/ssl_cert.pem diff --git a/Src/StdLib/Lib/test/test_asyncio/ssl_key.pem b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/ssl_key.pem similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/ssl_key.pem rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/ssl_key.pem diff --git a/Src/StdLib/Lib/test/test_asyncio/test_base_events.py b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_base_events.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_base_events.py rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_base_events.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_events.py b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_events.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_events.py rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_events.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_futures.py b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_futures.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_futures.py rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_futures.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_locks.py b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_locks.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_locks.py rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_locks.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_proactor_events.py b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_proactor_events.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_proactor_events.py rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_proactor_events.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_queues.py b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_queues.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_queues.py rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_queues.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_selector_events.py b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_selector_events.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_selector_events.py rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_selector_events.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_sslproto.py b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_sslproto.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_sslproto.py rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_sslproto.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_streams.py b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_streams.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_streams.py rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_streams.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_subprocess.py b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_subprocess.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_subprocess.py rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_subprocess.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_tasks.py b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_tasks.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_tasks.py rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_tasks.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_transports.py b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_transports.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_transports.py rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_transports.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_unix_events.py b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_unix_events.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_unix_events.py rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_unix_events.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_windows_events.py b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_windows_events.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_windows_events.py rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_windows_events.py diff --git a/Src/StdLib/Lib/test/test_asyncio/test_windows_utils.py b/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_windows_utils.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncio/test_windows_utils.py rename to Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_windows_utils.py diff --git a/Src/StdLib/Lib/test/test_asyncore.py b/Src.GetRenamed/StdLib/Lib/test/test_asyncore.py similarity index 100% rename from Src/StdLib/Lib/test/test_asyncore.py rename to Src.GetRenamed/StdLib/Lib/test/test_asyncore.py diff --git a/Src/StdLib/Lib/test/test_atexit.py b/Src.GetRenamed/StdLib/Lib/test/test_atexit.py similarity index 100% rename from Src/StdLib/Lib/test/test_atexit.py rename to Src.GetRenamed/StdLib/Lib/test/test_atexit.py diff --git a/Src/StdLib/Lib/test/test_audioop.py b/Src.GetRenamed/StdLib/Lib/test/test_audioop.py similarity index 100% rename from Src/StdLib/Lib/test/test_audioop.py rename to Src.GetRenamed/StdLib/Lib/test/test_audioop.py diff --git a/Src/StdLib/Lib/test/test_augassign.py b/Src.GetRenamed/StdLib/Lib/test/test_augassign.py similarity index 100% rename from Src/StdLib/Lib/test/test_augassign.py rename to Src.GetRenamed/StdLib/Lib/test/test_augassign.py diff --git a/Src/StdLib/Lib/test/test_base64.py b/Src.GetRenamed/StdLib/Lib/test/test_base64.py similarity index 100% rename from Src/StdLib/Lib/test/test_base64.py rename to Src.GetRenamed/StdLib/Lib/test/test_base64.py diff --git a/Src/StdLib/Lib/test/test_bigaddrspace.py b/Src.GetRenamed/StdLib/Lib/test/test_bigaddrspace.py similarity index 100% rename from Src/StdLib/Lib/test/test_bigaddrspace.py rename to Src.GetRenamed/StdLib/Lib/test/test_bigaddrspace.py diff --git a/Src/StdLib/Lib/test/test_bigmem.py b/Src.GetRenamed/StdLib/Lib/test/test_bigmem.py similarity index 100% rename from Src/StdLib/Lib/test/test_bigmem.py rename to Src.GetRenamed/StdLib/Lib/test/test_bigmem.py diff --git a/Src/StdLib/Lib/test/test_binascii.py b/Src.GetRenamed/StdLib/Lib/test/test_binascii.py similarity index 100% rename from Src/StdLib/Lib/test/test_binascii.py rename to Src.GetRenamed/StdLib/Lib/test/test_binascii.py diff --git a/Src/StdLib/Lib/test/test_binhex.py b/Src.GetRenamed/StdLib/Lib/test/test_binhex.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/test/test_binhex.py rename to Src.GetRenamed/StdLib/Lib/test/test_binhex.py diff --git a/Src/StdLib/Lib/test/test_binop.py b/Src.GetRenamed/StdLib/Lib/test/test_binop.py similarity index 100% rename from Src/StdLib/Lib/test/test_binop.py rename to Src.GetRenamed/StdLib/Lib/test/test_binop.py diff --git a/Src/StdLib/Lib/test/test_bisect.py b/Src.GetRenamed/StdLib/Lib/test/test_bisect.py similarity index 100% rename from Src/StdLib/Lib/test/test_bisect.py rename to Src.GetRenamed/StdLib/Lib/test/test_bisect.py diff --git a/Src/StdLib/Lib/test/test_bool.py b/Src.GetRenamed/StdLib/Lib/test/test_bool.py similarity index 100% rename from Src/StdLib/Lib/test/test_bool.py rename to Src.GetRenamed/StdLib/Lib/test/test_bool.py diff --git a/Src/StdLib/Lib/test/test_buffer.py b/Src.GetRenamed/StdLib/Lib/test/test_buffer.py similarity index 100% rename from Src/StdLib/Lib/test/test_buffer.py rename to Src.GetRenamed/StdLib/Lib/test/test_buffer.py diff --git a/Src/StdLib/Lib/test/test_bufio.py b/Src.GetRenamed/StdLib/Lib/test/test_bufio.py similarity index 100% rename from Src/StdLib/Lib/test/test_bufio.py rename to Src.GetRenamed/StdLib/Lib/test/test_bufio.py diff --git a/Src/StdLib/Lib/test/test_builtin.py b/Src.GetRenamed/StdLib/Lib/test/test_builtin.py similarity index 100% rename from Src/StdLib/Lib/test/test_builtin.py rename to Src.GetRenamed/StdLib/Lib/test/test_builtin.py diff --git a/Src/StdLib/Lib/test/test_bytes.py b/Src.GetRenamed/StdLib/Lib/test/test_bytes.py similarity index 100% rename from Src/StdLib/Lib/test/test_bytes.py rename to Src.GetRenamed/StdLib/Lib/test/test_bytes.py diff --git a/Src/StdLib/Lib/test/test_bz2.py b/Src.GetRenamed/StdLib/Lib/test/test_bz2.py similarity index 100% rename from Src/StdLib/Lib/test/test_bz2.py rename to Src.GetRenamed/StdLib/Lib/test/test_bz2.py diff --git a/Src/StdLib/Lib/test/test_calendar.py b/Src.GetRenamed/StdLib/Lib/test/test_calendar.py similarity index 100% rename from Src/StdLib/Lib/test/test_calendar.py rename to Src.GetRenamed/StdLib/Lib/test/test_calendar.py diff --git a/Src/StdLib/Lib/test/test_call.py b/Src.GetRenamed/StdLib/Lib/test/test_call.py similarity index 100% rename from Src/StdLib/Lib/test/test_call.py rename to Src.GetRenamed/StdLib/Lib/test/test_call.py diff --git a/Src/StdLib/Lib/test/test_capi.py b/Src.GetRenamed/StdLib/Lib/test/test_capi.py similarity index 100% rename from Src/StdLib/Lib/test/test_capi.py rename to Src.GetRenamed/StdLib/Lib/test/test_capi.py diff --git a/Src/StdLib/Lib/test/test_cgi.py b/Src.GetRenamed/StdLib/Lib/test/test_cgi.py similarity index 100% rename from Src/StdLib/Lib/test/test_cgi.py rename to Src.GetRenamed/StdLib/Lib/test/test_cgi.py diff --git a/Src/StdLib/Lib/test/test_cgitb.py b/Src.GetRenamed/StdLib/Lib/test/test_cgitb.py similarity index 100% rename from Src/StdLib/Lib/test/test_cgitb.py rename to Src.GetRenamed/StdLib/Lib/test/test_cgitb.py diff --git a/Src/StdLib/Lib/test/test_charmapcodec.py b/Src.GetRenamed/StdLib/Lib/test/test_charmapcodec.py similarity index 100% rename from Src/StdLib/Lib/test/test_charmapcodec.py rename to Src.GetRenamed/StdLib/Lib/test/test_charmapcodec.py diff --git a/Src/StdLib/Lib/test/test_class.py b/Src.GetRenamed/StdLib/Lib/test/test_class.py similarity index 100% rename from Src/StdLib/Lib/test/test_class.py rename to Src.GetRenamed/StdLib/Lib/test/test_class.py diff --git a/Src/StdLib/Lib/test/test_cmath.py b/Src.GetRenamed/StdLib/Lib/test/test_cmath.py similarity index 100% rename from Src/StdLib/Lib/test/test_cmath.py rename to Src.GetRenamed/StdLib/Lib/test/test_cmath.py diff --git a/Src/StdLib/Lib/test/test_cmd.py b/Src.GetRenamed/StdLib/Lib/test/test_cmd.py similarity index 100% rename from Src/StdLib/Lib/test/test_cmd.py rename to Src.GetRenamed/StdLib/Lib/test/test_cmd.py diff --git a/Src/StdLib/Lib/test/test_cmd_line.py b/Src.GetRenamed/StdLib/Lib/test/test_cmd_line.py similarity index 100% rename from Src/StdLib/Lib/test/test_cmd_line.py rename to Src.GetRenamed/StdLib/Lib/test/test_cmd_line.py diff --git a/Src/StdLib/Lib/test/test_cmd_line_script.py b/Src.GetRenamed/StdLib/Lib/test/test_cmd_line_script.py similarity index 100% rename from Src/StdLib/Lib/test/test_cmd_line_script.py rename to Src.GetRenamed/StdLib/Lib/test/test_cmd_line_script.py diff --git a/Src/StdLib/Lib/test/test_code.py b/Src.GetRenamed/StdLib/Lib/test/test_code.py similarity index 100% rename from Src/StdLib/Lib/test/test_code.py rename to Src.GetRenamed/StdLib/Lib/test/test_code.py diff --git a/Src/StdLib/Lib/test/test_code_module.py b/Src.GetRenamed/StdLib/Lib/test/test_code_module.py similarity index 100% rename from Src/StdLib/Lib/test/test_code_module.py rename to Src.GetRenamed/StdLib/Lib/test/test_code_module.py diff --git a/Src/StdLib/Lib/test/test_codeccallbacks.py b/Src.GetRenamed/StdLib/Lib/test/test_codeccallbacks.py similarity index 100% rename from Src/StdLib/Lib/test/test_codeccallbacks.py rename to Src.GetRenamed/StdLib/Lib/test/test_codeccallbacks.py diff --git a/Src/StdLib/Lib/test/test_codecencodings_cn.py b/Src.GetRenamed/StdLib/Lib/test/test_codecencodings_cn.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecencodings_cn.py rename to Src.GetRenamed/StdLib/Lib/test/test_codecencodings_cn.py diff --git a/Src/StdLib/Lib/test/test_codecencodings_hk.py b/Src.GetRenamed/StdLib/Lib/test/test_codecencodings_hk.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecencodings_hk.py rename to Src.GetRenamed/StdLib/Lib/test/test_codecencodings_hk.py diff --git a/Src/StdLib/Lib/test/test_codecencodings_iso2022.py b/Src.GetRenamed/StdLib/Lib/test/test_codecencodings_iso2022.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecencodings_iso2022.py rename to Src.GetRenamed/StdLib/Lib/test/test_codecencodings_iso2022.py diff --git a/Src/StdLib/Lib/test/test_codecencodings_jp.py b/Src.GetRenamed/StdLib/Lib/test/test_codecencodings_jp.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecencodings_jp.py rename to Src.GetRenamed/StdLib/Lib/test/test_codecencodings_jp.py diff --git a/Src/StdLib/Lib/test/test_codecencodings_kr.py b/Src.GetRenamed/StdLib/Lib/test/test_codecencodings_kr.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecencodings_kr.py rename to Src.GetRenamed/StdLib/Lib/test/test_codecencodings_kr.py diff --git a/Src/StdLib/Lib/test/test_codecencodings_tw.py b/Src.GetRenamed/StdLib/Lib/test/test_codecencodings_tw.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecencodings_tw.py rename to Src.GetRenamed/StdLib/Lib/test/test_codecencodings_tw.py diff --git a/Src/StdLib/Lib/test/test_codecmaps_cn.py b/Src.GetRenamed/StdLib/Lib/test/test_codecmaps_cn.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecmaps_cn.py rename to Src.GetRenamed/StdLib/Lib/test/test_codecmaps_cn.py diff --git a/Src/StdLib/Lib/test/test_codecmaps_hk.py b/Src.GetRenamed/StdLib/Lib/test/test_codecmaps_hk.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecmaps_hk.py rename to Src.GetRenamed/StdLib/Lib/test/test_codecmaps_hk.py diff --git a/Src/StdLib/Lib/test/test_codecmaps_jp.py b/Src.GetRenamed/StdLib/Lib/test/test_codecmaps_jp.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecmaps_jp.py rename to Src.GetRenamed/StdLib/Lib/test/test_codecmaps_jp.py diff --git a/Src/StdLib/Lib/test/test_codecmaps_kr.py b/Src.GetRenamed/StdLib/Lib/test/test_codecmaps_kr.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecmaps_kr.py rename to Src.GetRenamed/StdLib/Lib/test/test_codecmaps_kr.py diff --git a/Src/StdLib/Lib/test/test_codecmaps_tw.py b/Src.GetRenamed/StdLib/Lib/test/test_codecmaps_tw.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecmaps_tw.py rename to Src.GetRenamed/StdLib/Lib/test/test_codecmaps_tw.py diff --git a/Src/StdLib/Lib/test/test_codecs.py b/Src.GetRenamed/StdLib/Lib/test/test_codecs.py similarity index 100% rename from Src/StdLib/Lib/test/test_codecs.py rename to Src.GetRenamed/StdLib/Lib/test/test_codecs.py diff --git a/Src/StdLib/Lib/test/test_codeop.py b/Src.GetRenamed/StdLib/Lib/test/test_codeop.py similarity index 100% rename from Src/StdLib/Lib/test/test_codeop.py rename to Src.GetRenamed/StdLib/Lib/test/test_codeop.py diff --git a/Src/StdLib/Lib/test/test_collections.py b/Src.GetRenamed/StdLib/Lib/test/test_collections.py similarity index 100% rename from Src/StdLib/Lib/test/test_collections.py rename to Src.GetRenamed/StdLib/Lib/test/test_collections.py diff --git a/Src/StdLib/Lib/test/test_colorsys.py b/Src.GetRenamed/StdLib/Lib/test/test_colorsys.py similarity index 100% rename from Src/StdLib/Lib/test/test_colorsys.py rename to Src.GetRenamed/StdLib/Lib/test/test_colorsys.py diff --git a/Src/StdLib/Lib/test/test_compare.py b/Src.GetRenamed/StdLib/Lib/test/test_compare.py similarity index 100% rename from Src/StdLib/Lib/test/test_compare.py rename to Src.GetRenamed/StdLib/Lib/test/test_compare.py diff --git a/Src/StdLib/Lib/test/test_compile.py b/Src.GetRenamed/StdLib/Lib/test/test_compile.py similarity index 100% rename from Src/StdLib/Lib/test/test_compile.py rename to Src.GetRenamed/StdLib/Lib/test/test_compile.py diff --git a/Src/StdLib/Lib/test/test_compileall.py b/Src.GetRenamed/StdLib/Lib/test/test_compileall.py similarity index 100% rename from Src/StdLib/Lib/test/test_compileall.py rename to Src.GetRenamed/StdLib/Lib/test/test_compileall.py diff --git a/Src/StdLib/Lib/test/test_complex.py b/Src.GetRenamed/StdLib/Lib/test/test_complex.py similarity index 100% rename from Src/StdLib/Lib/test/test_complex.py rename to Src.GetRenamed/StdLib/Lib/test/test_complex.py diff --git a/Src/StdLib/Lib/test/test_concurrent_futures.py b/Src.GetRenamed/StdLib/Lib/test/test_concurrent_futures.py similarity index 100% rename from Src/StdLib/Lib/test/test_concurrent_futures.py rename to Src.GetRenamed/StdLib/Lib/test/test_concurrent_futures.py diff --git a/Src/StdLib/Lib/test/test_configparser.py b/Src.GetRenamed/StdLib/Lib/test/test_configparser.py similarity index 100% rename from Src/StdLib/Lib/test/test_configparser.py rename to Src.GetRenamed/StdLib/Lib/test/test_configparser.py diff --git a/Src/StdLib/Lib/test/test_contains.py b/Src.GetRenamed/StdLib/Lib/test/test_contains.py similarity index 100% rename from Src/StdLib/Lib/test/test_contains.py rename to Src.GetRenamed/StdLib/Lib/test/test_contains.py diff --git a/Src/StdLib/Lib/test/test_contextlib.py b/Src.GetRenamed/StdLib/Lib/test/test_contextlib.py similarity index 100% rename from Src/StdLib/Lib/test/test_contextlib.py rename to Src.GetRenamed/StdLib/Lib/test/test_contextlib.py diff --git a/Src/StdLib/Lib/test/test_copy.py b/Src.GetRenamed/StdLib/Lib/test/test_copy.py similarity index 100% rename from Src/StdLib/Lib/test/test_copy.py rename to Src.GetRenamed/StdLib/Lib/test/test_copy.py diff --git a/Src/StdLib/Lib/test/test_copyreg.py b/Src.GetRenamed/StdLib/Lib/test/test_copyreg.py similarity index 100% rename from Src/StdLib/Lib/test/test_copyreg.py rename to Src.GetRenamed/StdLib/Lib/test/test_copyreg.py diff --git a/Src/StdLib/Lib/test/test_cprofile.py b/Src.GetRenamed/StdLib/Lib/test/test_cprofile.py similarity index 100% rename from Src/StdLib/Lib/test/test_cprofile.py rename to Src.GetRenamed/StdLib/Lib/test/test_cprofile.py diff --git a/Src/StdLib/Lib/test/test_crashers.py b/Src.GetRenamed/StdLib/Lib/test/test_crashers.py similarity index 100% rename from Src/StdLib/Lib/test/test_crashers.py rename to Src.GetRenamed/StdLib/Lib/test/test_crashers.py diff --git a/Src/StdLib/Lib/test/test_crypt.py b/Src.GetRenamed/StdLib/Lib/test/test_crypt.py similarity index 100% rename from Src/StdLib/Lib/test/test_crypt.py rename to Src.GetRenamed/StdLib/Lib/test/test_crypt.py diff --git a/Src/StdLib/Lib/test/test_csv.py b/Src.GetRenamed/StdLib/Lib/test/test_csv.py similarity index 100% rename from Src/StdLib/Lib/test/test_csv.py rename to Src.GetRenamed/StdLib/Lib/test/test_csv.py diff --git a/Src/StdLib/Lib/test/test_ctypes.py b/Src.GetRenamed/StdLib/Lib/test/test_ctypes.py similarity index 100% rename from Src/StdLib/Lib/test/test_ctypes.py rename to Src.GetRenamed/StdLib/Lib/test/test_ctypes.py diff --git a/Src/StdLib/Lib/test/test_curses.py b/Src.GetRenamed/StdLib/Lib/test/test_curses.py similarity index 100% rename from Src/StdLib/Lib/test/test_curses.py rename to Src.GetRenamed/StdLib/Lib/test/test_curses.py diff --git a/Src/StdLib/Lib/test/test_datetime.py b/Src.GetRenamed/StdLib/Lib/test/test_datetime.py similarity index 100% rename from Src/StdLib/Lib/test/test_datetime.py rename to Src.GetRenamed/StdLib/Lib/test/test_datetime.py diff --git a/Src/StdLib/Lib/test/test_dbm.py b/Src.GetRenamed/StdLib/Lib/test/test_dbm.py similarity index 100% rename from Src/StdLib/Lib/test/test_dbm.py rename to Src.GetRenamed/StdLib/Lib/test/test_dbm.py diff --git a/Src/StdLib/Lib/test/test_dbm_dumb.py b/Src.GetRenamed/StdLib/Lib/test/test_dbm_dumb.py similarity index 100% rename from Src/StdLib/Lib/test/test_dbm_dumb.py rename to Src.GetRenamed/StdLib/Lib/test/test_dbm_dumb.py diff --git a/Src/StdLib/Lib/test/test_dbm_gnu.py b/Src.GetRenamed/StdLib/Lib/test/test_dbm_gnu.py similarity index 100% rename from Src/StdLib/Lib/test/test_dbm_gnu.py rename to Src.GetRenamed/StdLib/Lib/test/test_dbm_gnu.py diff --git a/Src/StdLib/Lib/test/test_dbm_ndbm.py b/Src.GetRenamed/StdLib/Lib/test/test_dbm_ndbm.py similarity index 100% rename from Src/StdLib/Lib/test/test_dbm_ndbm.py rename to Src.GetRenamed/StdLib/Lib/test/test_dbm_ndbm.py diff --git a/Src/StdLib/Lib/test/test_decimal.py b/Src.GetRenamed/StdLib/Lib/test/test_decimal.py similarity index 100% rename from Src/StdLib/Lib/test/test_decimal.py rename to Src.GetRenamed/StdLib/Lib/test/test_decimal.py diff --git a/Src/StdLib/Lib/test/test_decorators.py b/Src.GetRenamed/StdLib/Lib/test/test_decorators.py similarity index 100% rename from Src/StdLib/Lib/test/test_decorators.py rename to Src.GetRenamed/StdLib/Lib/test/test_decorators.py diff --git a/Src/StdLib/Lib/test/test_defaultdict.py b/Src.GetRenamed/StdLib/Lib/test/test_defaultdict.py similarity index 100% rename from Src/StdLib/Lib/test/test_defaultdict.py rename to Src.GetRenamed/StdLib/Lib/test/test_defaultdict.py diff --git a/Src/StdLib/Lib/test/test_deque.py b/Src.GetRenamed/StdLib/Lib/test/test_deque.py similarity index 100% rename from Src/StdLib/Lib/test/test_deque.py rename to Src.GetRenamed/StdLib/Lib/test/test_deque.py diff --git a/Src/StdLib/Lib/test/test_descr.py b/Src.GetRenamed/StdLib/Lib/test/test_descr.py similarity index 100% rename from Src/StdLib/Lib/test/test_descr.py rename to Src.GetRenamed/StdLib/Lib/test/test_descr.py diff --git a/Src/StdLib/Lib/test/test_descrtut.py b/Src.GetRenamed/StdLib/Lib/test/test_descrtut.py similarity index 100% rename from Src/StdLib/Lib/test/test_descrtut.py rename to Src.GetRenamed/StdLib/Lib/test/test_descrtut.py diff --git a/Src/StdLib/Lib/test/test_devpoll.py b/Src.GetRenamed/StdLib/Lib/test/test_devpoll.py similarity index 100% rename from Src/StdLib/Lib/test/test_devpoll.py rename to Src.GetRenamed/StdLib/Lib/test/test_devpoll.py diff --git a/Src/StdLib/Lib/test/test_dict.py b/Src.GetRenamed/StdLib/Lib/test/test_dict.py similarity index 100% rename from Src/StdLib/Lib/test/test_dict.py rename to Src.GetRenamed/StdLib/Lib/test/test_dict.py diff --git a/Src/StdLib/Lib/test/test_dictcomps.py b/Src.GetRenamed/StdLib/Lib/test/test_dictcomps.py similarity index 100% rename from Src/StdLib/Lib/test/test_dictcomps.py rename to Src.GetRenamed/StdLib/Lib/test/test_dictcomps.py diff --git a/Src/StdLib/Lib/test/test_dictviews.py b/Src.GetRenamed/StdLib/Lib/test/test_dictviews.py similarity index 100% rename from Src/StdLib/Lib/test/test_dictviews.py rename to Src.GetRenamed/StdLib/Lib/test/test_dictviews.py diff --git a/Src/StdLib/Lib/test/test_difflib.py b/Src.GetRenamed/StdLib/Lib/test/test_difflib.py similarity index 100% rename from Src/StdLib/Lib/test/test_difflib.py rename to Src.GetRenamed/StdLib/Lib/test/test_difflib.py diff --git a/Src/StdLib/Lib/test/test_difflib_expect.html b/Src.GetRenamed/StdLib/Lib/test/test_difflib_expect.html similarity index 100% rename from Src/StdLib/Lib/test/test_difflib_expect.html rename to Src.GetRenamed/StdLib/Lib/test/test_difflib_expect.html diff --git a/Src/StdLib/Lib/test/test_dis.py b/Src.GetRenamed/StdLib/Lib/test/test_dis.py similarity index 100% rename from Src/StdLib/Lib/test/test_dis.py rename to Src.GetRenamed/StdLib/Lib/test/test_dis.py diff --git a/Src/StdLib/Lib/test/test_distutils.py b/Src.GetRenamed/StdLib/Lib/test/test_distutils.py similarity index 100% rename from Src/StdLib/Lib/test/test_distutils.py rename to Src.GetRenamed/StdLib/Lib/test/test_distutils.py diff --git a/Src/StdLib/Lib/test/test_doctest.py b/Src.GetRenamed/StdLib/Lib/test/test_doctest.py similarity index 100% rename from Src/StdLib/Lib/test/test_doctest.py rename to Src.GetRenamed/StdLib/Lib/test/test_doctest.py diff --git a/Src/StdLib/Lib/test/test_doctest.txt b/Src.GetRenamed/StdLib/Lib/test/test_doctest.txt similarity index 100% rename from Src/StdLib/Lib/test/test_doctest.txt rename to Src.GetRenamed/StdLib/Lib/test/test_doctest.txt diff --git a/Src/StdLib/Lib/test/test_doctest2.py b/Src.GetRenamed/StdLib/Lib/test/test_doctest2.py similarity index 100% rename from Src/StdLib/Lib/test/test_doctest2.py rename to Src.GetRenamed/StdLib/Lib/test/test_doctest2.py diff --git a/Src/StdLib/Lib/test/test_doctest2.txt b/Src.GetRenamed/StdLib/Lib/test/test_doctest2.txt similarity index 100% rename from Src/StdLib/Lib/test/test_doctest2.txt rename to Src.GetRenamed/StdLib/Lib/test/test_doctest2.txt diff --git a/Src/StdLib/Lib/test/test_doctest3.txt b/Src.GetRenamed/StdLib/Lib/test/test_doctest3.txt similarity index 100% rename from Src/StdLib/Lib/test/test_doctest3.txt rename to Src.GetRenamed/StdLib/Lib/test/test_doctest3.txt diff --git a/Src/StdLib/Lib/test/test_doctest4.txt b/Src.GetRenamed/StdLib/Lib/test/test_doctest4.txt similarity index 100% rename from Src/StdLib/Lib/test/test_doctest4.txt rename to Src.GetRenamed/StdLib/Lib/test/test_doctest4.txt diff --git a/Src/StdLib/Lib/test/test_docxmlrpc.py b/Src.GetRenamed/StdLib/Lib/test/test_docxmlrpc.py similarity index 100% rename from Src/StdLib/Lib/test/test_docxmlrpc.py rename to Src.GetRenamed/StdLib/Lib/test/test_docxmlrpc.py diff --git a/Src/StdLib/Lib/test/test_dummy_thread.py b/Src.GetRenamed/StdLib/Lib/test/test_dummy_thread.py similarity index 100% rename from Src/StdLib/Lib/test/test_dummy_thread.py rename to Src.GetRenamed/StdLib/Lib/test/test_dummy_thread.py diff --git a/Src/StdLib/Lib/test/test_dummy_threading.py b/Src.GetRenamed/StdLib/Lib/test/test_dummy_threading.py similarity index 100% rename from Src/StdLib/Lib/test/test_dummy_threading.py rename to Src.GetRenamed/StdLib/Lib/test/test_dummy_threading.py diff --git a/Src/StdLib/Lib/test/test_dynamic.py b/Src.GetRenamed/StdLib/Lib/test/test_dynamic.py similarity index 100% rename from Src/StdLib/Lib/test/test_dynamic.py rename to Src.GetRenamed/StdLib/Lib/test/test_dynamic.py diff --git a/Src/StdLib/Lib/test/test_dynamicclassattribute.py b/Src.GetRenamed/StdLib/Lib/test/test_dynamicclassattribute.py similarity index 100% rename from Src/StdLib/Lib/test/test_dynamicclassattribute.py rename to Src.GetRenamed/StdLib/Lib/test/test_dynamicclassattribute.py diff --git a/Src/StdLib/Lib/test/test_email/__init__.py b/Src.GetRenamed/StdLib/Lib/test/test_email/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/__init__.py rename to Src.GetRenamed/StdLib/Lib/test/test_email/__init__.py diff --git a/Src/StdLib/Lib/test/test_email/__main__.py b/Src.GetRenamed/StdLib/Lib/test/test_email/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/__main__.py rename to Src.GetRenamed/StdLib/Lib/test/test_email/__main__.py diff --git a/Src/StdLib/Lib/test/test_email/data/PyBanner048.gif b/Src.GetRenamed/StdLib/Lib/test/test_email/data/PyBanner048.gif similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/PyBanner048.gif rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/PyBanner048.gif diff --git a/Src/StdLib/Lib/test/test_email/data/audiotest.au b/Src.GetRenamed/StdLib/Lib/test/test_email/data/audiotest.au similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/audiotest.au rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/audiotest.au diff --git a/Src/StdLib/Lib/test/test_email/data/msg_01.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_01.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_01.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_01.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_02.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_02.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_02.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_02.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_03.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_03.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_03.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_03.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_04.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_04.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_04.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_04.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_05.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_05.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_05.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_05.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_06.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_06.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_06.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_06.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_07.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_07.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_07.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_07.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_08.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_08.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_08.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_08.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_09.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_09.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_09.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_09.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_10.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_10.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_10.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_10.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_11.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_11.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_11.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_11.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_12.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_12.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_12.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_12.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_12a.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_12a.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_12a.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_12a.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_13.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_13.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_13.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_13.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_14.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_14.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_14.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_14.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_15.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_15.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_15.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_15.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_16.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_16.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_16.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_16.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_17.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_17.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_17.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_17.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_18.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_18.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_18.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_18.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_19.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_19.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_19.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_19.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_20.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_20.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_20.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_20.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_21.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_21.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_21.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_21.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_22.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_22.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_22.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_22.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_23.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_23.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_23.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_23.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_24.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_24.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_24.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_24.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_25.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_25.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_25.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_25.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_26.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_26.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_26.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_26.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_27.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_27.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_27.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_27.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_28.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_28.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_28.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_28.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_29.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_29.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_29.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_29.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_30.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_30.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_30.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_30.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_31.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_31.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_31.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_31.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_32.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_32.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_32.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_32.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_33.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_33.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_33.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_33.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_34.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_34.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_34.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_34.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_35.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_35.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_35.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_35.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_36.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_36.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_36.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_36.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_37.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_37.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_37.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_37.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_38.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_38.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_38.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_38.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_39.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_39.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_39.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_39.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_40.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_40.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_40.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_40.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_41.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_41.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_41.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_41.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_42.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_42.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_42.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_42.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_43.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_43.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_43.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_43.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_44.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_44.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_44.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_44.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_45.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_45.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_45.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_45.txt diff --git a/Src/StdLib/Lib/test/test_email/data/msg_46.txt b/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_46.txt similarity index 100% rename from Src/StdLib/Lib/test/test_email/data/msg_46.txt rename to Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_46.txt diff --git a/Src/StdLib/Lib/test/test_email/test__encoded_words.py b/Src.GetRenamed/StdLib/Lib/test/test_email/test__encoded_words.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test__encoded_words.py rename to Src.GetRenamed/StdLib/Lib/test/test_email/test__encoded_words.py diff --git a/Src/StdLib/Lib/test/test_email/test__header_value_parser.py b/Src.GetRenamed/StdLib/Lib/test/test_email/test__header_value_parser.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test__header_value_parser.py rename to Src.GetRenamed/StdLib/Lib/test/test_email/test__header_value_parser.py diff --git a/Src/StdLib/Lib/test/test_email/test_asian_codecs.py b/Src.GetRenamed/StdLib/Lib/test/test_email/test_asian_codecs.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_asian_codecs.py rename to Src.GetRenamed/StdLib/Lib/test/test_email/test_asian_codecs.py diff --git a/Src/StdLib/Lib/test/test_email/test_contentmanager.py b/Src.GetRenamed/StdLib/Lib/test/test_email/test_contentmanager.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_contentmanager.py rename to Src.GetRenamed/StdLib/Lib/test/test_email/test_contentmanager.py diff --git a/Src/StdLib/Lib/test/test_email/test_defect_handling.py b/Src.GetRenamed/StdLib/Lib/test/test_email/test_defect_handling.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_defect_handling.py rename to Src.GetRenamed/StdLib/Lib/test/test_email/test_defect_handling.py diff --git a/Src/StdLib/Lib/test/test_email/test_email.py b/Src.GetRenamed/StdLib/Lib/test/test_email/test_email.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_email.py rename to Src.GetRenamed/StdLib/Lib/test/test_email/test_email.py diff --git a/Src/StdLib/Lib/test/test_email/test_generator.py b/Src.GetRenamed/StdLib/Lib/test/test_email/test_generator.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_generator.py rename to Src.GetRenamed/StdLib/Lib/test/test_email/test_generator.py diff --git a/Src/StdLib/Lib/test/test_email/test_headerregistry.py b/Src.GetRenamed/StdLib/Lib/test/test_email/test_headerregistry.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_headerregistry.py rename to Src.GetRenamed/StdLib/Lib/test/test_email/test_headerregistry.py diff --git a/Src/StdLib/Lib/test/test_email/test_inversion.py b/Src.GetRenamed/StdLib/Lib/test/test_email/test_inversion.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_inversion.py rename to Src.GetRenamed/StdLib/Lib/test/test_email/test_inversion.py diff --git a/Src/StdLib/Lib/test/test_email/test_message.py b/Src.GetRenamed/StdLib/Lib/test/test_email/test_message.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_message.py rename to Src.GetRenamed/StdLib/Lib/test/test_email/test_message.py diff --git a/Src/StdLib/Lib/test/test_email/test_parser.py b/Src.GetRenamed/StdLib/Lib/test/test_email/test_parser.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_parser.py rename to Src.GetRenamed/StdLib/Lib/test/test_email/test_parser.py diff --git a/Src/StdLib/Lib/test/test_email/test_pickleable.py b/Src.GetRenamed/StdLib/Lib/test/test_email/test_pickleable.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_pickleable.py rename to Src.GetRenamed/StdLib/Lib/test/test_email/test_pickleable.py diff --git a/Src/StdLib/Lib/test/test_email/test_policy.py b/Src.GetRenamed/StdLib/Lib/test/test_email/test_policy.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_policy.py rename to Src.GetRenamed/StdLib/Lib/test/test_email/test_policy.py diff --git a/Src/StdLib/Lib/test/test_email/test_utils.py b/Src.GetRenamed/StdLib/Lib/test/test_email/test_utils.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/test_utils.py rename to Src.GetRenamed/StdLib/Lib/test/test_email/test_utils.py diff --git a/Src/StdLib/Lib/test/test_email/torture_test.py b/Src.GetRenamed/StdLib/Lib/test/test_email/torture_test.py similarity index 100% rename from Src/StdLib/Lib/test/test_email/torture_test.py rename to Src.GetRenamed/StdLib/Lib/test/test_email/torture_test.py diff --git a/Src/StdLib/Lib/test/test_ensurepip.py b/Src.GetRenamed/StdLib/Lib/test/test_ensurepip.py similarity index 100% rename from Src/StdLib/Lib/test/test_ensurepip.py rename to Src.GetRenamed/StdLib/Lib/test/test_ensurepip.py diff --git a/Src/StdLib/Lib/test/test_enum.py b/Src.GetRenamed/StdLib/Lib/test/test_enum.py similarity index 100% rename from Src/StdLib/Lib/test/test_enum.py rename to Src.GetRenamed/StdLib/Lib/test/test_enum.py diff --git a/Src/StdLib/Lib/test/test_enumerate.py b/Src.GetRenamed/StdLib/Lib/test/test_enumerate.py similarity index 100% rename from Src/StdLib/Lib/test/test_enumerate.py rename to Src.GetRenamed/StdLib/Lib/test/test_enumerate.py diff --git a/Src/StdLib/Lib/test/test_eof.py b/Src.GetRenamed/StdLib/Lib/test/test_eof.py similarity index 100% rename from Src/StdLib/Lib/test/test_eof.py rename to Src.GetRenamed/StdLib/Lib/test/test_eof.py diff --git a/Src/StdLib/Lib/test/test_epoll.py b/Src.GetRenamed/StdLib/Lib/test/test_epoll.py similarity index 100% rename from Src/StdLib/Lib/test/test_epoll.py rename to Src.GetRenamed/StdLib/Lib/test/test_epoll.py diff --git a/Src/StdLib/Lib/test/test_errno.py b/Src.GetRenamed/StdLib/Lib/test/test_errno.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/test/test_errno.py rename to Src.GetRenamed/StdLib/Lib/test/test_errno.py diff --git a/Src/StdLib/Lib/test/test_exception_variations.py b/Src.GetRenamed/StdLib/Lib/test/test_exception_variations.py similarity index 100% rename from Src/StdLib/Lib/test/test_exception_variations.py rename to Src.GetRenamed/StdLib/Lib/test/test_exception_variations.py diff --git a/Src/StdLib/Lib/test/test_exceptions.py b/Src.GetRenamed/StdLib/Lib/test/test_exceptions.py similarity index 100% rename from Src/StdLib/Lib/test/test_exceptions.py rename to Src.GetRenamed/StdLib/Lib/test/test_exceptions.py diff --git a/Src/StdLib/Lib/test/test_extcall.py b/Src.GetRenamed/StdLib/Lib/test/test_extcall.py similarity index 100% rename from Src/StdLib/Lib/test/test_extcall.py rename to Src.GetRenamed/StdLib/Lib/test/test_extcall.py diff --git a/Src/StdLib/Lib/test/test_faulthandler.py b/Src.GetRenamed/StdLib/Lib/test/test_faulthandler.py similarity index 100% rename from Src/StdLib/Lib/test/test_faulthandler.py rename to Src.GetRenamed/StdLib/Lib/test/test_faulthandler.py diff --git a/Src/StdLib/Lib/test/test_fcntl.py b/Src.GetRenamed/StdLib/Lib/test/test_fcntl.py similarity index 100% rename from Src/StdLib/Lib/test/test_fcntl.py rename to Src.GetRenamed/StdLib/Lib/test/test_fcntl.py diff --git a/Src/StdLib/Lib/test/test_file.py b/Src.GetRenamed/StdLib/Lib/test/test_file.py similarity index 100% rename from Src/StdLib/Lib/test/test_file.py rename to Src.GetRenamed/StdLib/Lib/test/test_file.py diff --git a/Src/StdLib/Lib/test/test_file_eintr.py b/Src.GetRenamed/StdLib/Lib/test/test_file_eintr.py similarity index 100% rename from Src/StdLib/Lib/test/test_file_eintr.py rename to Src.GetRenamed/StdLib/Lib/test/test_file_eintr.py diff --git a/Src/StdLib/Lib/test/test_filecmp.py b/Src.GetRenamed/StdLib/Lib/test/test_filecmp.py similarity index 100% rename from Src/StdLib/Lib/test/test_filecmp.py rename to Src.GetRenamed/StdLib/Lib/test/test_filecmp.py diff --git a/Src/StdLib/Lib/test/test_fileinput.py b/Src.GetRenamed/StdLib/Lib/test/test_fileinput.py similarity index 100% rename from Src/StdLib/Lib/test/test_fileinput.py rename to Src.GetRenamed/StdLib/Lib/test/test_fileinput.py diff --git a/Src/StdLib/Lib/test/test_fileio.py b/Src.GetRenamed/StdLib/Lib/test/test_fileio.py similarity index 100% rename from Src/StdLib/Lib/test/test_fileio.py rename to Src.GetRenamed/StdLib/Lib/test/test_fileio.py diff --git a/Src/StdLib/Lib/test/test_finalization.py b/Src.GetRenamed/StdLib/Lib/test/test_finalization.py similarity index 100% rename from Src/StdLib/Lib/test/test_finalization.py rename to Src.GetRenamed/StdLib/Lib/test/test_finalization.py diff --git a/Src/StdLib/Lib/test/test_float.py b/Src.GetRenamed/StdLib/Lib/test/test_float.py similarity index 100% rename from Src/StdLib/Lib/test/test_float.py rename to Src.GetRenamed/StdLib/Lib/test/test_float.py diff --git a/Src/StdLib/Lib/test/test_flufl.py b/Src.GetRenamed/StdLib/Lib/test/test_flufl.py similarity index 100% rename from Src/StdLib/Lib/test/test_flufl.py rename to Src.GetRenamed/StdLib/Lib/test/test_flufl.py diff --git a/Src/StdLib/Lib/test/test_fnmatch.py b/Src.GetRenamed/StdLib/Lib/test/test_fnmatch.py similarity index 100% rename from Src/StdLib/Lib/test/test_fnmatch.py rename to Src.GetRenamed/StdLib/Lib/test/test_fnmatch.py diff --git a/Src/StdLib/Lib/test/test_fork1.py b/Src.GetRenamed/StdLib/Lib/test/test_fork1.py similarity index 100% rename from Src/StdLib/Lib/test/test_fork1.py rename to Src.GetRenamed/StdLib/Lib/test/test_fork1.py diff --git a/Src/StdLib/Lib/test/test_format.py b/Src.GetRenamed/StdLib/Lib/test/test_format.py similarity index 100% rename from Src/StdLib/Lib/test/test_format.py rename to Src.GetRenamed/StdLib/Lib/test/test_format.py diff --git a/Src/StdLib/Lib/test/test_fractions.py b/Src.GetRenamed/StdLib/Lib/test/test_fractions.py similarity index 100% rename from Src/StdLib/Lib/test/test_fractions.py rename to Src.GetRenamed/StdLib/Lib/test/test_fractions.py diff --git a/Src/StdLib/Lib/test/test_frame.py b/Src.GetRenamed/StdLib/Lib/test/test_frame.py similarity index 100% rename from Src/StdLib/Lib/test/test_frame.py rename to Src.GetRenamed/StdLib/Lib/test/test_frame.py diff --git a/Src/StdLib/Lib/test/test_fstring.py b/Src.GetRenamed/StdLib/Lib/test/test_fstring.py similarity index 100% rename from Src/StdLib/Lib/test/test_fstring.py rename to Src.GetRenamed/StdLib/Lib/test/test_fstring.py diff --git a/Src/StdLib/Lib/test/test_ftplib.py b/Src.GetRenamed/StdLib/Lib/test/test_ftplib.py similarity index 100% rename from Src/StdLib/Lib/test/test_ftplib.py rename to Src.GetRenamed/StdLib/Lib/test/test_ftplib.py diff --git a/Src/StdLib/Lib/test/test_funcattrs.py b/Src.GetRenamed/StdLib/Lib/test/test_funcattrs.py similarity index 100% rename from Src/StdLib/Lib/test/test_funcattrs.py rename to Src.GetRenamed/StdLib/Lib/test/test_funcattrs.py diff --git a/Src/StdLib/Lib/test/test_functools.py b/Src.GetRenamed/StdLib/Lib/test/test_functools.py similarity index 100% rename from Src/StdLib/Lib/test/test_functools.py rename to Src.GetRenamed/StdLib/Lib/test/test_functools.py diff --git a/Src/StdLib/Lib/test/test_future.py b/Src.GetRenamed/StdLib/Lib/test/test_future.py similarity index 100% rename from Src/StdLib/Lib/test/test_future.py rename to Src.GetRenamed/StdLib/Lib/test/test_future.py diff --git a/Src/StdLib/Lib/test/test_future3.py b/Src.GetRenamed/StdLib/Lib/test/test_future3.py similarity index 100% rename from Src/StdLib/Lib/test/test_future3.py rename to Src.GetRenamed/StdLib/Lib/test/test_future3.py diff --git a/Src/StdLib/Lib/test/test_future4.py b/Src.GetRenamed/StdLib/Lib/test/test_future4.py similarity index 100% rename from Src/StdLib/Lib/test/test_future4.py rename to Src.GetRenamed/StdLib/Lib/test/test_future4.py diff --git a/Src/StdLib/Lib/test/test_future5.py b/Src.GetRenamed/StdLib/Lib/test/test_future5.py similarity index 100% rename from Src/StdLib/Lib/test/test_future5.py rename to Src.GetRenamed/StdLib/Lib/test/test_future5.py diff --git a/Src/StdLib/Lib/test/test_gc.py b/Src.GetRenamed/StdLib/Lib/test/test_gc.py similarity index 100% rename from Src/StdLib/Lib/test/test_gc.py rename to Src.GetRenamed/StdLib/Lib/test/test_gc.py diff --git a/Src/StdLib/Lib/test/test_gdb.py b/Src.GetRenamed/StdLib/Lib/test/test_gdb.py similarity index 100% rename from Src/StdLib/Lib/test/test_gdb.py rename to Src.GetRenamed/StdLib/Lib/test/test_gdb.py diff --git a/Src/StdLib/Lib/test/test_generators.py b/Src.GetRenamed/StdLib/Lib/test/test_generators.py similarity index 100% rename from Src/StdLib/Lib/test/test_generators.py rename to Src.GetRenamed/StdLib/Lib/test/test_generators.py diff --git a/Src/StdLib/Lib/test/test_genericpath.py b/Src.GetRenamed/StdLib/Lib/test/test_genericpath.py similarity index 100% rename from Src/StdLib/Lib/test/test_genericpath.py rename to Src.GetRenamed/StdLib/Lib/test/test_genericpath.py diff --git a/Src/StdLib/Lib/test/test_genexps.py b/Src.GetRenamed/StdLib/Lib/test/test_genexps.py similarity index 100% rename from Src/StdLib/Lib/test/test_genexps.py rename to Src.GetRenamed/StdLib/Lib/test/test_genexps.py diff --git a/Src/StdLib/Lib/test/test_getargs2.py b/Src.GetRenamed/StdLib/Lib/test/test_getargs2.py similarity index 100% rename from Src/StdLib/Lib/test/test_getargs2.py rename to Src.GetRenamed/StdLib/Lib/test/test_getargs2.py diff --git a/Src/StdLib/Lib/test/test_getopt.py b/Src.GetRenamed/StdLib/Lib/test/test_getopt.py similarity index 100% rename from Src/StdLib/Lib/test/test_getopt.py rename to Src.GetRenamed/StdLib/Lib/test/test_getopt.py diff --git a/Src/StdLib/Lib/test/test_getpass.py b/Src.GetRenamed/StdLib/Lib/test/test_getpass.py similarity index 100% rename from Src/StdLib/Lib/test/test_getpass.py rename to Src.GetRenamed/StdLib/Lib/test/test_getpass.py diff --git a/Src/StdLib/Lib/test/test_gettext.py b/Src.GetRenamed/StdLib/Lib/test/test_gettext.py similarity index 100% rename from Src/StdLib/Lib/test/test_gettext.py rename to Src.GetRenamed/StdLib/Lib/test/test_gettext.py diff --git a/Src/StdLib/Lib/test/test_glob.py b/Src.GetRenamed/StdLib/Lib/test/test_glob.py similarity index 100% rename from Src/StdLib/Lib/test/test_glob.py rename to Src.GetRenamed/StdLib/Lib/test/test_glob.py diff --git a/Src/StdLib/Lib/test/test_global.py b/Src.GetRenamed/StdLib/Lib/test/test_global.py similarity index 100% rename from Src/StdLib/Lib/test/test_global.py rename to Src.GetRenamed/StdLib/Lib/test/test_global.py diff --git a/Src/StdLib/Lib/test/test_grammar.py b/Src.GetRenamed/StdLib/Lib/test/test_grammar.py similarity index 100% rename from Src/StdLib/Lib/test/test_grammar.py rename to Src.GetRenamed/StdLib/Lib/test/test_grammar.py diff --git a/Src/StdLib/Lib/test/test_grp.py b/Src.GetRenamed/StdLib/Lib/test/test_grp.py similarity index 100% rename from Src/StdLib/Lib/test/test_grp.py rename to Src.GetRenamed/StdLib/Lib/test/test_grp.py diff --git a/Src/StdLib/Lib/test/test_gzip.py b/Src.GetRenamed/StdLib/Lib/test/test_gzip.py similarity index 100% rename from Src/StdLib/Lib/test/test_gzip.py rename to Src.GetRenamed/StdLib/Lib/test/test_gzip.py diff --git a/Src/StdLib/Lib/test/test_hash.py b/Src.GetRenamed/StdLib/Lib/test/test_hash.py similarity index 100% rename from Src/StdLib/Lib/test/test_hash.py rename to Src.GetRenamed/StdLib/Lib/test/test_hash.py diff --git a/Src/StdLib/Lib/test/test_hashlib.py b/Src.GetRenamed/StdLib/Lib/test/test_hashlib.py similarity index 100% rename from Src/StdLib/Lib/test/test_hashlib.py rename to Src.GetRenamed/StdLib/Lib/test/test_hashlib.py diff --git a/Src/StdLib/Lib/test/test_heapq.py b/Src.GetRenamed/StdLib/Lib/test/test_heapq.py similarity index 100% rename from Src/StdLib/Lib/test/test_heapq.py rename to Src.GetRenamed/StdLib/Lib/test/test_heapq.py diff --git a/Src/StdLib/Lib/test/test_hmac.py b/Src.GetRenamed/StdLib/Lib/test/test_hmac.py similarity index 100% rename from Src/StdLib/Lib/test/test_hmac.py rename to Src.GetRenamed/StdLib/Lib/test/test_hmac.py diff --git a/Src/StdLib/Lib/test/test_html.py b/Src.GetRenamed/StdLib/Lib/test/test_html.py similarity index 100% rename from Src/StdLib/Lib/test/test_html.py rename to Src.GetRenamed/StdLib/Lib/test/test_html.py diff --git a/Src/StdLib/Lib/test/test_htmlparser.py b/Src.GetRenamed/StdLib/Lib/test/test_htmlparser.py similarity index 100% rename from Src/StdLib/Lib/test/test_htmlparser.py rename to Src.GetRenamed/StdLib/Lib/test/test_htmlparser.py diff --git a/Src/StdLib/Lib/test/test_http_cookiejar.py b/Src.GetRenamed/StdLib/Lib/test/test_http_cookiejar.py similarity index 100% rename from Src/StdLib/Lib/test/test_http_cookiejar.py rename to Src.GetRenamed/StdLib/Lib/test/test_http_cookiejar.py diff --git a/Src/StdLib/Lib/test/test_http_cookies.py b/Src.GetRenamed/StdLib/Lib/test/test_http_cookies.py similarity index 100% rename from Src/StdLib/Lib/test/test_http_cookies.py rename to Src.GetRenamed/StdLib/Lib/test/test_http_cookies.py diff --git a/Src/StdLib/Lib/test/test_httplib.py b/Src.GetRenamed/StdLib/Lib/test/test_httplib.py similarity index 100% rename from Src/StdLib/Lib/test/test_httplib.py rename to Src.GetRenamed/StdLib/Lib/test/test_httplib.py diff --git a/Src/StdLib/Lib/test/test_httpservers.py b/Src.GetRenamed/StdLib/Lib/test/test_httpservers.py similarity index 100% rename from Src/StdLib/Lib/test/test_httpservers.py rename to Src.GetRenamed/StdLib/Lib/test/test_httpservers.py diff --git a/Src/StdLib/Lib/test/test_idle.py b/Src.GetRenamed/StdLib/Lib/test/test_idle.py similarity index 100% rename from Src/StdLib/Lib/test/test_idle.py rename to Src.GetRenamed/StdLib/Lib/test/test_idle.py diff --git a/Src/StdLib/Lib/test/test_imaplib.py b/Src.GetRenamed/StdLib/Lib/test/test_imaplib.py similarity index 100% rename from Src/StdLib/Lib/test/test_imaplib.py rename to Src.GetRenamed/StdLib/Lib/test/test_imaplib.py diff --git a/Src/StdLib/Lib/test/test_imghdr.py b/Src.GetRenamed/StdLib/Lib/test/test_imghdr.py similarity index 100% rename from Src/StdLib/Lib/test/test_imghdr.py rename to Src.GetRenamed/StdLib/Lib/test/test_imghdr.py diff --git a/Src/StdLib/Lib/test/test_imp.py b/Src.GetRenamed/StdLib/Lib/test/test_imp.py similarity index 100% rename from Src/StdLib/Lib/test/test_imp.py rename to Src.GetRenamed/StdLib/Lib/test/test_imp.py diff --git a/Src/StdLib/Lib/test/test_import.py b/Src.GetRenamed/StdLib/Lib/test/test_import.py similarity index 100% rename from Src/StdLib/Lib/test/test_import.py rename to Src.GetRenamed/StdLib/Lib/test/test_import.py diff --git a/Src/StdLib/Lib/test/test_importlib/__init__.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/__init__.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/__init__.py diff --git a/Src/StdLib/Lib/test/test_importlib/__main__.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/__main__.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/__main__.py diff --git a/Src/StdLib/Lib/test/test_importlib/abc.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/abc.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/abc.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/abc.py diff --git a/Src/StdLib/Lib/test/test_importlib/builtin/__init__.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/builtin/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/builtin/__init__.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/builtin/__init__.py diff --git a/Src/StdLib/Lib/test/test_importlib/builtin/__main__.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/builtin/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/builtin/__main__.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/builtin/__main__.py diff --git a/Src/StdLib/Lib/test/test_importlib/builtin/test_finder.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/builtin/test_finder.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/builtin/test_finder.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/builtin/test_finder.py diff --git a/Src/StdLib/Lib/test/test_importlib/builtin/test_loader.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/builtin/test_loader.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/builtin/test_loader.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/builtin/test_loader.py diff --git a/Src/StdLib/Lib/test/test_importlib/builtin/util.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/builtin/util.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/builtin/util.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/builtin/util.py diff --git a/Src/StdLib/Lib/test/test_importlib/extension/__init__.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/extension/__init__.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/__init__.py diff --git a/Src/StdLib/Lib/test/test_importlib/extension/__main__.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/extension/__main__.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/__main__.py diff --git a/Src/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py diff --git a/Src/StdLib/Lib/test/test_importlib/extension/test_finder.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/test_finder.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/extension/test_finder.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/test_finder.py diff --git a/Src/StdLib/Lib/test/test_importlib/extension/test_loader.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/test_loader.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/extension/test_loader.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/test_loader.py diff --git a/Src/StdLib/Lib/test/test_importlib/extension/test_path_hook.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/test_path_hook.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/extension/test_path_hook.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/test_path_hook.py diff --git a/Src/StdLib/Lib/test/test_importlib/extension/util.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/util.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/extension/util.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/util.py diff --git a/Src/StdLib/Lib/test/test_importlib/frozen/__init__.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/frozen/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/frozen/__init__.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/frozen/__init__.py diff --git a/Src/StdLib/Lib/test/test_importlib/frozen/__main__.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/frozen/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/frozen/__main__.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/frozen/__main__.py diff --git a/Src/StdLib/Lib/test/test_importlib/frozen/test_finder.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/frozen/test_finder.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/frozen/test_finder.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/frozen/test_finder.py diff --git a/Src/StdLib/Lib/test/test_importlib/frozen/test_loader.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/frozen/test_loader.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/frozen/test_loader.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/frozen/test_loader.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/__init__.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/__init__.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/__init__.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/__main__.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/__main__.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/__main__.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/test___loader__.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test___loader__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/test___loader__.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test___loader__.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/test___package__.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test___package__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/test___package__.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test___package__.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/test_api.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_api.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/test_api.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_api.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/test_caching.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_caching.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/test_caching.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_caching.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/test_fromlist.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_fromlist.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/test_fromlist.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_fromlist.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/test_meta_path.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_meta_path.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/test_meta_path.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_meta_path.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/test_packages.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_packages.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/test_packages.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_packages.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/test_path.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_path.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/test_path.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_path.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py diff --git a/Src/StdLib/Lib/test/test_importlib/import_/util.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/util.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/import_/util.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/util.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip b/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty b/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip b/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip diff --git a/Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py similarity index 100% rename from Src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip b/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip diff --git a/Src/StdLib/Lib/test/test_importlib/regrtest.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/regrtest.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/regrtest.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/regrtest.py diff --git a/Src/StdLib/Lib/test/test_importlib/source/__init__.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/source/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/source/__init__.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/source/__init__.py diff --git a/Src/StdLib/Lib/test/test_importlib/source/__main__.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/source/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/source/__main__.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/source/__main__.py diff --git a/Src/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py diff --git a/Src/StdLib/Lib/test/test_importlib/source/test_file_loader.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/source/test_file_loader.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/source/test_file_loader.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/source/test_file_loader.py diff --git a/Src/StdLib/Lib/test/test_importlib/source/test_finder.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/source/test_finder.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/source/test_finder.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/source/test_finder.py diff --git a/Src/StdLib/Lib/test/test_importlib/source/test_path_hook.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/source/test_path_hook.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/source/test_path_hook.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/source/test_path_hook.py diff --git a/Src/StdLib/Lib/test/test_importlib/source/test_source_encoding.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/source/test_source_encoding.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/source/test_source_encoding.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/source/test_source_encoding.py diff --git a/Src/StdLib/Lib/test/test_importlib/source/util.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/source/util.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/source/util.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/source/util.py diff --git a/Src/StdLib/Lib/test/test_importlib/test_abc.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/test_abc.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/test_abc.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/test_abc.py diff --git a/Src/StdLib/Lib/test/test_importlib/test_api.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/test_api.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/test_api.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/test_api.py diff --git a/Src/StdLib/Lib/test/test_importlib/test_locks.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/test_locks.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/test_locks.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/test_locks.py diff --git a/Src/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py diff --git a/Src/StdLib/Lib/test/test_importlib/test_spec.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/test_spec.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/test_spec.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/test_spec.py diff --git a/Src/StdLib/Lib/test/test_importlib/test_util.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/test_util.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/test_util.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/test_util.py diff --git a/Src/StdLib/Lib/test/test_importlib/test_windows.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/test_windows.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/test_windows.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/test_windows.py diff --git a/Src/StdLib/Lib/test/test_importlib/util.py b/Src.GetRenamed/StdLib/Lib/test/test_importlib/util.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/util.py rename to Src.GetRenamed/StdLib/Lib/test/test_importlib/util.py diff --git a/Src/StdLib/Lib/test/test_index.py b/Src.GetRenamed/StdLib/Lib/test/test_index.py similarity index 100% rename from Src/StdLib/Lib/test/test_index.py rename to Src.GetRenamed/StdLib/Lib/test/test_index.py diff --git a/Src/StdLib/Lib/test/test_inspect.py b/Src.GetRenamed/StdLib/Lib/test/test_inspect.py similarity index 100% rename from Src/StdLib/Lib/test/test_inspect.py rename to Src.GetRenamed/StdLib/Lib/test/test_inspect.py diff --git a/Src/StdLib/Lib/test/test_int.py b/Src.GetRenamed/StdLib/Lib/test/test_int.py similarity index 100% rename from Src/StdLib/Lib/test/test_int.py rename to Src.GetRenamed/StdLib/Lib/test/test_int.py diff --git a/Src/StdLib/Lib/test/test_int_literal.py b/Src.GetRenamed/StdLib/Lib/test/test_int_literal.py similarity index 100% rename from Src/StdLib/Lib/test/test_int_literal.py rename to Src.GetRenamed/StdLib/Lib/test/test_int_literal.py diff --git a/Src/StdLib/Lib/test/test_io.py b/Src.GetRenamed/StdLib/Lib/test/test_io.py similarity index 100% rename from Src/StdLib/Lib/test/test_io.py rename to Src.GetRenamed/StdLib/Lib/test/test_io.py diff --git a/Src/StdLib/Lib/test/test_ioctl.py b/Src.GetRenamed/StdLib/Lib/test/test_ioctl.py similarity index 100% rename from Src/StdLib/Lib/test/test_ioctl.py rename to Src.GetRenamed/StdLib/Lib/test/test_ioctl.py diff --git a/Src/StdLib/Lib/test/test_ipaddress.py b/Src.GetRenamed/StdLib/Lib/test/test_ipaddress.py similarity index 100% rename from Src/StdLib/Lib/test/test_ipaddress.py rename to Src.GetRenamed/StdLib/Lib/test/test_ipaddress.py diff --git a/Src/StdLib/Lib/test/test_isinstance.py b/Src.GetRenamed/StdLib/Lib/test/test_isinstance.py similarity index 100% rename from Src/StdLib/Lib/test/test_isinstance.py rename to Src.GetRenamed/StdLib/Lib/test/test_isinstance.py diff --git a/Src/StdLib/Lib/test/test_iter.py b/Src.GetRenamed/StdLib/Lib/test/test_iter.py similarity index 100% rename from Src/StdLib/Lib/test/test_iter.py rename to Src.GetRenamed/StdLib/Lib/test/test_iter.py diff --git a/Src/StdLib/Lib/test/test_iterlen.py b/Src.GetRenamed/StdLib/Lib/test/test_iterlen.py similarity index 100% rename from Src/StdLib/Lib/test/test_iterlen.py rename to Src.GetRenamed/StdLib/Lib/test/test_iterlen.py diff --git a/Src/StdLib/Lib/test/test_itertools.py b/Src.GetRenamed/StdLib/Lib/test/test_itertools.py similarity index 100% rename from Src/StdLib/Lib/test/test_itertools.py rename to Src.GetRenamed/StdLib/Lib/test/test_itertools.py diff --git a/Src/StdLib/Lib/test/test_json/__init__.py b/Src.GetRenamed/StdLib/Lib/test/test_json/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/__init__.py rename to Src.GetRenamed/StdLib/Lib/test/test_json/__init__.py diff --git a/Src/StdLib/Lib/test/test_json/__main__.py b/Src.GetRenamed/StdLib/Lib/test/test_json/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/__main__.py rename to Src.GetRenamed/StdLib/Lib/test/test_json/__main__.py diff --git a/Src/StdLib/Lib/test/test_json/test_decode.py b/Src.GetRenamed/StdLib/Lib/test/test_json/test_decode.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_decode.py rename to Src.GetRenamed/StdLib/Lib/test/test_json/test_decode.py diff --git a/Src/StdLib/Lib/test/test_json/test_default.py b/Src.GetRenamed/StdLib/Lib/test/test_json/test_default.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_default.py rename to Src.GetRenamed/StdLib/Lib/test/test_json/test_default.py diff --git a/Src/StdLib/Lib/test/test_json/test_dump.py b/Src.GetRenamed/StdLib/Lib/test/test_json/test_dump.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_dump.py rename to Src.GetRenamed/StdLib/Lib/test/test_json/test_dump.py diff --git a/Src/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py b/Src.GetRenamed/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py rename to Src.GetRenamed/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py diff --git a/Src/StdLib/Lib/test/test_json/test_enum.py b/Src.GetRenamed/StdLib/Lib/test/test_json/test_enum.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_enum.py rename to Src.GetRenamed/StdLib/Lib/test/test_json/test_enum.py diff --git a/Src/StdLib/Lib/test/test_json/test_fail.py b/Src.GetRenamed/StdLib/Lib/test/test_json/test_fail.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_fail.py rename to Src.GetRenamed/StdLib/Lib/test/test_json/test_fail.py diff --git a/Src/StdLib/Lib/test/test_json/test_float.py b/Src.GetRenamed/StdLib/Lib/test/test_json/test_float.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_float.py rename to Src.GetRenamed/StdLib/Lib/test/test_json/test_float.py diff --git a/Src/StdLib/Lib/test/test_json/test_indent.py b/Src.GetRenamed/StdLib/Lib/test/test_json/test_indent.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_indent.py rename to Src.GetRenamed/StdLib/Lib/test/test_json/test_indent.py diff --git a/Src/StdLib/Lib/test/test_json/test_pass1.py b/Src.GetRenamed/StdLib/Lib/test/test_json/test_pass1.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_pass1.py rename to Src.GetRenamed/StdLib/Lib/test/test_json/test_pass1.py diff --git a/Src/StdLib/Lib/test/test_json/test_pass2.py b/Src.GetRenamed/StdLib/Lib/test/test_json/test_pass2.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_pass2.py rename to Src.GetRenamed/StdLib/Lib/test/test_json/test_pass2.py diff --git a/Src/StdLib/Lib/test/test_json/test_pass3.py b/Src.GetRenamed/StdLib/Lib/test/test_json/test_pass3.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_pass3.py rename to Src.GetRenamed/StdLib/Lib/test/test_json/test_pass3.py diff --git a/Src/StdLib/Lib/test/test_json/test_recursion.py b/Src.GetRenamed/StdLib/Lib/test/test_json/test_recursion.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_recursion.py rename to Src.GetRenamed/StdLib/Lib/test/test_json/test_recursion.py diff --git a/Src/StdLib/Lib/test/test_json/test_scanstring.py b/Src.GetRenamed/StdLib/Lib/test/test_json/test_scanstring.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_scanstring.py rename to Src.GetRenamed/StdLib/Lib/test/test_json/test_scanstring.py diff --git a/Src/StdLib/Lib/test/test_json/test_separators.py b/Src.GetRenamed/StdLib/Lib/test/test_json/test_separators.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_separators.py rename to Src.GetRenamed/StdLib/Lib/test/test_json/test_separators.py diff --git a/Src/StdLib/Lib/test/test_json/test_speedups.py b/Src.GetRenamed/StdLib/Lib/test/test_json/test_speedups.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_speedups.py rename to Src.GetRenamed/StdLib/Lib/test/test_json/test_speedups.py diff --git a/Src/StdLib/Lib/test/test_json/test_tool.py b/Src.GetRenamed/StdLib/Lib/test/test_json/test_tool.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_tool.py rename to Src.GetRenamed/StdLib/Lib/test/test_json/test_tool.py diff --git a/Src/StdLib/Lib/test/test_json/test_unicode.py b/Src.GetRenamed/StdLib/Lib/test/test_json/test_unicode.py similarity index 100% rename from Src/StdLib/Lib/test/test_json/test_unicode.py rename to Src.GetRenamed/StdLib/Lib/test/test_json/test_unicode.py diff --git a/Src/StdLib/Lib/test/test_keyword.py b/Src.GetRenamed/StdLib/Lib/test/test_keyword.py similarity index 100% rename from Src/StdLib/Lib/test/test_keyword.py rename to Src.GetRenamed/StdLib/Lib/test/test_keyword.py diff --git a/Src/StdLib/Lib/test/test_keywordonlyarg.py b/Src.GetRenamed/StdLib/Lib/test/test_keywordonlyarg.py similarity index 100% rename from Src/StdLib/Lib/test/test_keywordonlyarg.py rename to Src.GetRenamed/StdLib/Lib/test/test_keywordonlyarg.py diff --git a/Src/StdLib/Lib/test/test_kqueue.py b/Src.GetRenamed/StdLib/Lib/test/test_kqueue.py similarity index 100% rename from Src/StdLib/Lib/test/test_kqueue.py rename to Src.GetRenamed/StdLib/Lib/test/test_kqueue.py diff --git a/Src/StdLib/Lib/test/test_largefile.py b/Src.GetRenamed/StdLib/Lib/test/test_largefile.py similarity index 100% rename from Src/StdLib/Lib/test/test_largefile.py rename to Src.GetRenamed/StdLib/Lib/test/test_largefile.py diff --git a/Src/StdLib/Lib/test/test_lib2to3.py b/Src.GetRenamed/StdLib/Lib/test/test_lib2to3.py similarity index 100% rename from Src/StdLib/Lib/test/test_lib2to3.py rename to Src.GetRenamed/StdLib/Lib/test/test_lib2to3.py diff --git a/Src/StdLib/Lib/test/test_linecache.py b/Src.GetRenamed/StdLib/Lib/test/test_linecache.py similarity index 100% rename from Src/StdLib/Lib/test/test_linecache.py rename to Src.GetRenamed/StdLib/Lib/test/test_linecache.py diff --git a/Src/StdLib/Lib/test/test_list.py b/Src.GetRenamed/StdLib/Lib/test/test_list.py similarity index 100% rename from Src/StdLib/Lib/test/test_list.py rename to Src.GetRenamed/StdLib/Lib/test/test_list.py diff --git a/Src/StdLib/Lib/test/test_listcomps.py b/Src.GetRenamed/StdLib/Lib/test/test_listcomps.py similarity index 100% rename from Src/StdLib/Lib/test/test_listcomps.py rename to Src.GetRenamed/StdLib/Lib/test/test_listcomps.py diff --git a/Src/StdLib/Lib/test/test_locale.py b/Src.GetRenamed/StdLib/Lib/test/test_locale.py similarity index 100% rename from Src/StdLib/Lib/test/test_locale.py rename to Src.GetRenamed/StdLib/Lib/test/test_locale.py diff --git a/Src/StdLib/Lib/test/test_logging.py b/Src.GetRenamed/StdLib/Lib/test/test_logging.py similarity index 100% rename from Src/StdLib/Lib/test/test_logging.py rename to Src.GetRenamed/StdLib/Lib/test/test_logging.py diff --git a/Src/StdLib/Lib/test/test_long.py b/Src.GetRenamed/StdLib/Lib/test/test_long.py similarity index 100% rename from Src/StdLib/Lib/test/test_long.py rename to Src.GetRenamed/StdLib/Lib/test/test_long.py diff --git a/Src/StdLib/Lib/test/test_longexp.py b/Src.GetRenamed/StdLib/Lib/test/test_longexp.py similarity index 100% rename from Src/StdLib/Lib/test/test_longexp.py rename to Src.GetRenamed/StdLib/Lib/test/test_longexp.py diff --git a/Src/StdLib/Lib/test/test_lzma.py b/Src.GetRenamed/StdLib/Lib/test/test_lzma.py similarity index 100% rename from Src/StdLib/Lib/test/test_lzma.py rename to Src.GetRenamed/StdLib/Lib/test/test_lzma.py diff --git a/Src/StdLib/Lib/test/test_macpath.py b/Src.GetRenamed/StdLib/Lib/test/test_macpath.py similarity index 100% rename from Src/StdLib/Lib/test/test_macpath.py rename to Src.GetRenamed/StdLib/Lib/test/test_macpath.py diff --git a/Src/StdLib/Lib/test/test_macurl2path.py b/Src.GetRenamed/StdLib/Lib/test/test_macurl2path.py similarity index 100% rename from Src/StdLib/Lib/test/test_macurl2path.py rename to Src.GetRenamed/StdLib/Lib/test/test_macurl2path.py diff --git a/Src/StdLib/Lib/test/test_mailbox.py b/Src.GetRenamed/StdLib/Lib/test/test_mailbox.py similarity index 100% rename from Src/StdLib/Lib/test/test_mailbox.py rename to Src.GetRenamed/StdLib/Lib/test/test_mailbox.py diff --git a/Src/StdLib/Lib/test/test_mailcap.py b/Src.GetRenamed/StdLib/Lib/test/test_mailcap.py similarity index 100% rename from Src/StdLib/Lib/test/test_mailcap.py rename to Src.GetRenamed/StdLib/Lib/test/test_mailcap.py diff --git a/Src/StdLib/Lib/test/test_marshal.py b/Src.GetRenamed/StdLib/Lib/test/test_marshal.py similarity index 100% rename from Src/StdLib/Lib/test/test_marshal.py rename to Src.GetRenamed/StdLib/Lib/test/test_marshal.py diff --git a/Src/StdLib/Lib/test/test_math.py b/Src.GetRenamed/StdLib/Lib/test/test_math.py similarity index 100% rename from Src/StdLib/Lib/test/test_math.py rename to Src.GetRenamed/StdLib/Lib/test/test_math.py diff --git a/Src/StdLib/Lib/test/test_memoryio.py b/Src.GetRenamed/StdLib/Lib/test/test_memoryio.py similarity index 100% rename from Src/StdLib/Lib/test/test_memoryio.py rename to Src.GetRenamed/StdLib/Lib/test/test_memoryio.py diff --git a/Src/StdLib/Lib/test/test_memoryview.py b/Src.GetRenamed/StdLib/Lib/test/test_memoryview.py similarity index 100% rename from Src/StdLib/Lib/test/test_memoryview.py rename to Src.GetRenamed/StdLib/Lib/test/test_memoryview.py diff --git a/Src/StdLib/Lib/test/test_metaclass.py b/Src.GetRenamed/StdLib/Lib/test/test_metaclass.py similarity index 100% rename from Src/StdLib/Lib/test/test_metaclass.py rename to Src.GetRenamed/StdLib/Lib/test/test_metaclass.py diff --git a/Src/StdLib/Lib/test/test_mimetypes.py b/Src.GetRenamed/StdLib/Lib/test/test_mimetypes.py similarity index 100% rename from Src/StdLib/Lib/test/test_mimetypes.py rename to Src.GetRenamed/StdLib/Lib/test/test_mimetypes.py diff --git a/Src/StdLib/Lib/test/test_minidom.py b/Src.GetRenamed/StdLib/Lib/test/test_minidom.py similarity index 100% rename from Src/StdLib/Lib/test/test_minidom.py rename to Src.GetRenamed/StdLib/Lib/test/test_minidom.py diff --git a/Src/StdLib/Lib/test/test_mmap.py b/Src.GetRenamed/StdLib/Lib/test/test_mmap.py similarity index 100% rename from Src/StdLib/Lib/test/test_mmap.py rename to Src.GetRenamed/StdLib/Lib/test/test_mmap.py diff --git a/Src/StdLib/Lib/test/test_module.py b/Src.GetRenamed/StdLib/Lib/test/test_module.py similarity index 100% rename from Src/StdLib/Lib/test/test_module.py rename to Src.GetRenamed/StdLib/Lib/test/test_module.py diff --git a/Src/StdLib/Lib/test/test_modulefinder.py b/Src.GetRenamed/StdLib/Lib/test/test_modulefinder.py similarity index 100% rename from Src/StdLib/Lib/test/test_modulefinder.py rename to Src.GetRenamed/StdLib/Lib/test/test_modulefinder.py diff --git a/Src/StdLib/Lib/test/test_msilib.py b/Src.GetRenamed/StdLib/Lib/test/test_msilib.py similarity index 100% rename from Src/StdLib/Lib/test/test_msilib.py rename to Src.GetRenamed/StdLib/Lib/test/test_msilib.py diff --git a/Src/StdLib/Lib/test/test_multibytecodec.py b/Src.GetRenamed/StdLib/Lib/test/test_multibytecodec.py similarity index 100% rename from Src/StdLib/Lib/test/test_multibytecodec.py rename to Src.GetRenamed/StdLib/Lib/test/test_multibytecodec.py diff --git a/Src/StdLib/Lib/test/test_multiprocessing_fork.py b/Src.GetRenamed/StdLib/Lib/test/test_multiprocessing_fork.py similarity index 100% rename from Src/StdLib/Lib/test/test_multiprocessing_fork.py rename to Src.GetRenamed/StdLib/Lib/test/test_multiprocessing_fork.py diff --git a/Src/StdLib/Lib/test/test_multiprocessing_forkserver.py b/Src.GetRenamed/StdLib/Lib/test/test_multiprocessing_forkserver.py similarity index 100% rename from Src/StdLib/Lib/test/test_multiprocessing_forkserver.py rename to Src.GetRenamed/StdLib/Lib/test/test_multiprocessing_forkserver.py diff --git a/Src/StdLib/Lib/test/test_multiprocessing_main_handling.py b/Src.GetRenamed/StdLib/Lib/test/test_multiprocessing_main_handling.py similarity index 100% rename from Src/StdLib/Lib/test/test_multiprocessing_main_handling.py rename to Src.GetRenamed/StdLib/Lib/test/test_multiprocessing_main_handling.py diff --git a/Src/StdLib/Lib/test/test_multiprocessing_spawn.py b/Src.GetRenamed/StdLib/Lib/test/test_multiprocessing_spawn.py similarity index 100% rename from Src/StdLib/Lib/test/test_multiprocessing_spawn.py rename to Src.GetRenamed/StdLib/Lib/test/test_multiprocessing_spawn.py diff --git a/Src/StdLib/Lib/test/test_netrc.py b/Src.GetRenamed/StdLib/Lib/test/test_netrc.py similarity index 100% rename from Src/StdLib/Lib/test/test_netrc.py rename to Src.GetRenamed/StdLib/Lib/test/test_netrc.py diff --git a/Src/StdLib/Lib/test/test_nis.py b/Src.GetRenamed/StdLib/Lib/test/test_nis.py similarity index 100% rename from Src/StdLib/Lib/test/test_nis.py rename to Src.GetRenamed/StdLib/Lib/test/test_nis.py diff --git a/Src/StdLib/Lib/test/test_nntplib.py b/Src.GetRenamed/StdLib/Lib/test/test_nntplib.py similarity index 100% rename from Src/StdLib/Lib/test/test_nntplib.py rename to Src.GetRenamed/StdLib/Lib/test/test_nntplib.py diff --git a/Src/StdLib/Lib/test/test_normalization.py b/Src.GetRenamed/StdLib/Lib/test/test_normalization.py similarity index 100% rename from Src/StdLib/Lib/test/test_normalization.py rename to Src.GetRenamed/StdLib/Lib/test/test_normalization.py diff --git a/Src/StdLib/Lib/test/test_ntpath.py b/Src.GetRenamed/StdLib/Lib/test/test_ntpath.py similarity index 100% rename from Src/StdLib/Lib/test/test_ntpath.py rename to Src.GetRenamed/StdLib/Lib/test/test_ntpath.py diff --git a/Src/StdLib/Lib/test/test_numeric_tower.py b/Src.GetRenamed/StdLib/Lib/test/test_numeric_tower.py similarity index 100% rename from Src/StdLib/Lib/test/test_numeric_tower.py rename to Src.GetRenamed/StdLib/Lib/test/test_numeric_tower.py diff --git a/Src/StdLib/Lib/test/test_opcodes.py b/Src.GetRenamed/StdLib/Lib/test/test_opcodes.py similarity index 100% rename from Src/StdLib/Lib/test/test_opcodes.py rename to Src.GetRenamed/StdLib/Lib/test/test_opcodes.py diff --git a/Src/StdLib/Lib/test/test_openpty.py b/Src.GetRenamed/StdLib/Lib/test/test_openpty.py similarity index 100% rename from Src/StdLib/Lib/test/test_openpty.py rename to Src.GetRenamed/StdLib/Lib/test/test_openpty.py diff --git a/Src/StdLib/Lib/test/test_operator.py b/Src.GetRenamed/StdLib/Lib/test/test_operator.py similarity index 100% rename from Src/StdLib/Lib/test/test_operator.py rename to Src.GetRenamed/StdLib/Lib/test/test_operator.py diff --git a/Src/StdLib/Lib/test/test_optparse.py b/Src.GetRenamed/StdLib/Lib/test/test_optparse.py similarity index 100% rename from Src/StdLib/Lib/test/test_optparse.py rename to Src.GetRenamed/StdLib/Lib/test/test_optparse.py diff --git a/Src/StdLib/Lib/test/test_ordered_dict.py b/Src.GetRenamed/StdLib/Lib/test/test_ordered_dict.py similarity index 100% rename from Src/StdLib/Lib/test/test_ordered_dict.py rename to Src.GetRenamed/StdLib/Lib/test/test_ordered_dict.py diff --git a/Src/StdLib/Lib/test/test_os.py b/Src.GetRenamed/StdLib/Lib/test/test_os.py similarity index 100% rename from Src/StdLib/Lib/test/test_os.py rename to Src.GetRenamed/StdLib/Lib/test/test_os.py diff --git a/Src/StdLib/Lib/test/test_ossaudiodev.py b/Src.GetRenamed/StdLib/Lib/test/test_ossaudiodev.py similarity index 100% rename from Src/StdLib/Lib/test/test_ossaudiodev.py rename to Src.GetRenamed/StdLib/Lib/test/test_ossaudiodev.py diff --git a/Src/StdLib/Lib/test/test_osx_env.py b/Src.GetRenamed/StdLib/Lib/test/test_osx_env.py similarity index 100% rename from Src/StdLib/Lib/test/test_osx_env.py rename to Src.GetRenamed/StdLib/Lib/test/test_osx_env.py diff --git a/Src/StdLib/Lib/test/test_parser.py b/Src.GetRenamed/StdLib/Lib/test/test_parser.py similarity index 100% rename from Src/StdLib/Lib/test/test_parser.py rename to Src.GetRenamed/StdLib/Lib/test/test_parser.py diff --git a/Src/StdLib/Lib/test/test_pathlib.py b/Src.GetRenamed/StdLib/Lib/test/test_pathlib.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/test/test_pathlib.py rename to Src.GetRenamed/StdLib/Lib/test/test_pathlib.py diff --git a/Src/StdLib/Lib/test/test_pdb.py b/Src.GetRenamed/StdLib/Lib/test/test_pdb.py similarity index 100% rename from Src/StdLib/Lib/test/test_pdb.py rename to Src.GetRenamed/StdLib/Lib/test/test_pdb.py diff --git a/Src/StdLib/Lib/test/test_peepholer.py b/Src.GetRenamed/StdLib/Lib/test/test_peepholer.py similarity index 100% rename from Src/StdLib/Lib/test/test_peepholer.py rename to Src.GetRenamed/StdLib/Lib/test/test_peepholer.py diff --git a/Src/StdLib/Lib/test/test_pep247.py b/Src.GetRenamed/StdLib/Lib/test/test_pep247.py similarity index 100% rename from Src/StdLib/Lib/test/test_pep247.py rename to Src.GetRenamed/StdLib/Lib/test/test_pep247.py diff --git a/Src/StdLib/Lib/test/test_pep277.py b/Src.GetRenamed/StdLib/Lib/test/test_pep277.py similarity index 100% rename from Src/StdLib/Lib/test/test_pep277.py rename to Src.GetRenamed/StdLib/Lib/test/test_pep277.py diff --git a/Src/StdLib/Lib/test/test_pep292.py b/Src.GetRenamed/StdLib/Lib/test/test_pep292.py similarity index 100% rename from Src/StdLib/Lib/test/test_pep292.py rename to Src.GetRenamed/StdLib/Lib/test/test_pep292.py diff --git a/Src/StdLib/Lib/test/test_pep3120.py b/Src.GetRenamed/StdLib/Lib/test/test_pep3120.py similarity index 100% rename from Src/StdLib/Lib/test/test_pep3120.py rename to Src.GetRenamed/StdLib/Lib/test/test_pep3120.py diff --git a/Src/StdLib/Lib/test/test_pep3131.py b/Src.GetRenamed/StdLib/Lib/test/test_pep3131.py similarity index 100% rename from Src/StdLib/Lib/test/test_pep3131.py rename to Src.GetRenamed/StdLib/Lib/test/test_pep3131.py diff --git a/Src/StdLib/Lib/test/test_pep3151.py b/Src.GetRenamed/StdLib/Lib/test/test_pep3151.py similarity index 100% rename from Src/StdLib/Lib/test/test_pep3151.py rename to Src.GetRenamed/StdLib/Lib/test/test_pep3151.py diff --git a/Src/StdLib/Lib/test/test_pep352.py b/Src.GetRenamed/StdLib/Lib/test/test_pep352.py similarity index 100% rename from Src/StdLib/Lib/test/test_pep352.py rename to Src.GetRenamed/StdLib/Lib/test/test_pep352.py diff --git a/Src/StdLib/Lib/test/test_pep380.py b/Src.GetRenamed/StdLib/Lib/test/test_pep380.py similarity index 100% rename from Src/StdLib/Lib/test/test_pep380.py rename to Src.GetRenamed/StdLib/Lib/test/test_pep380.py diff --git a/Src/StdLib/Lib/test/test_pep479.py b/Src.GetRenamed/StdLib/Lib/test/test_pep479.py similarity index 100% rename from Src/StdLib/Lib/test/test_pep479.py rename to Src.GetRenamed/StdLib/Lib/test/test_pep479.py diff --git a/Src/StdLib/Lib/test/test_pickle.py b/Src.GetRenamed/StdLib/Lib/test/test_pickle.py similarity index 100% rename from Src/StdLib/Lib/test/test_pickle.py rename to Src.GetRenamed/StdLib/Lib/test/test_pickle.py diff --git a/Src/StdLib/Lib/test/test_pickletools.py b/Src.GetRenamed/StdLib/Lib/test/test_pickletools.py similarity index 100% rename from Src/StdLib/Lib/test/test_pickletools.py rename to Src.GetRenamed/StdLib/Lib/test/test_pickletools.py diff --git a/Src/StdLib/Lib/test/test_pipes.py b/Src.GetRenamed/StdLib/Lib/test/test_pipes.py similarity index 100% rename from Src/StdLib/Lib/test/test_pipes.py rename to Src.GetRenamed/StdLib/Lib/test/test_pipes.py diff --git a/Src/StdLib/Lib/test/test_pkg.py b/Src.GetRenamed/StdLib/Lib/test/test_pkg.py similarity index 100% rename from Src/StdLib/Lib/test/test_pkg.py rename to Src.GetRenamed/StdLib/Lib/test/test_pkg.py diff --git a/Src/StdLib/Lib/test/test_pkgimport.py b/Src.GetRenamed/StdLib/Lib/test/test_pkgimport.py similarity index 100% rename from Src/StdLib/Lib/test/test_pkgimport.py rename to Src.GetRenamed/StdLib/Lib/test/test_pkgimport.py diff --git a/Src/StdLib/Lib/test/test_pkgutil.py b/Src.GetRenamed/StdLib/Lib/test/test_pkgutil.py similarity index 100% rename from Src/StdLib/Lib/test/test_pkgutil.py rename to Src.GetRenamed/StdLib/Lib/test/test_pkgutil.py diff --git a/Src/StdLib/Lib/test/test_platform.py b/Src.GetRenamed/StdLib/Lib/test/test_platform.py similarity index 100% rename from Src/StdLib/Lib/test/test_platform.py rename to Src.GetRenamed/StdLib/Lib/test/test_platform.py diff --git a/Src/StdLib/Lib/test/test_plistlib.py b/Src.GetRenamed/StdLib/Lib/test/test_plistlib.py similarity index 100% rename from Src/StdLib/Lib/test/test_plistlib.py rename to Src.GetRenamed/StdLib/Lib/test/test_plistlib.py diff --git a/Src/StdLib/Lib/test/test_poll.py b/Src.GetRenamed/StdLib/Lib/test/test_poll.py similarity index 100% rename from Src/StdLib/Lib/test/test_poll.py rename to Src.GetRenamed/StdLib/Lib/test/test_poll.py diff --git a/Src/StdLib/Lib/test/test_popen.py b/Src.GetRenamed/StdLib/Lib/test/test_popen.py similarity index 100% rename from Src/StdLib/Lib/test/test_popen.py rename to Src.GetRenamed/StdLib/Lib/test/test_popen.py diff --git a/Src/StdLib/Lib/test/test_poplib.py b/Src.GetRenamed/StdLib/Lib/test/test_poplib.py similarity index 100% rename from Src/StdLib/Lib/test/test_poplib.py rename to Src.GetRenamed/StdLib/Lib/test/test_poplib.py diff --git a/Src/StdLib/Lib/test/test_posix.py b/Src.GetRenamed/StdLib/Lib/test/test_posix.py similarity index 100% rename from Src/StdLib/Lib/test/test_posix.py rename to Src.GetRenamed/StdLib/Lib/test/test_posix.py diff --git a/Src/StdLib/Lib/test/test_posixpath.py b/Src.GetRenamed/StdLib/Lib/test/test_posixpath.py similarity index 100% rename from Src/StdLib/Lib/test/test_posixpath.py rename to Src.GetRenamed/StdLib/Lib/test/test_posixpath.py diff --git a/Src/StdLib/Lib/test/test_pow.py b/Src.GetRenamed/StdLib/Lib/test/test_pow.py similarity index 100% rename from Src/StdLib/Lib/test/test_pow.py rename to Src.GetRenamed/StdLib/Lib/test/test_pow.py diff --git a/Src/StdLib/Lib/test/test_pprint.py b/Src.GetRenamed/StdLib/Lib/test/test_pprint.py similarity index 100% rename from Src/StdLib/Lib/test/test_pprint.py rename to Src.GetRenamed/StdLib/Lib/test/test_pprint.py diff --git a/Src/StdLib/Lib/test/test_print.py b/Src.GetRenamed/StdLib/Lib/test/test_print.py similarity index 100% rename from Src/StdLib/Lib/test/test_print.py rename to Src.GetRenamed/StdLib/Lib/test/test_print.py diff --git a/Src/StdLib/Lib/test/test_profile.py b/Src.GetRenamed/StdLib/Lib/test/test_profile.py similarity index 100% rename from Src/StdLib/Lib/test/test_profile.py rename to Src.GetRenamed/StdLib/Lib/test/test_profile.py diff --git a/Src/StdLib/Lib/test/test_property.py b/Src.GetRenamed/StdLib/Lib/test/test_property.py similarity index 100% rename from Src/StdLib/Lib/test/test_property.py rename to Src.GetRenamed/StdLib/Lib/test/test_property.py diff --git a/Src/StdLib/Lib/test/test_pstats.py b/Src.GetRenamed/StdLib/Lib/test/test_pstats.py similarity index 100% rename from Src/StdLib/Lib/test/test_pstats.py rename to Src.GetRenamed/StdLib/Lib/test/test_pstats.py diff --git a/Src/StdLib/Lib/test/test_pty.py b/Src.GetRenamed/StdLib/Lib/test/test_pty.py similarity index 100% rename from Src/StdLib/Lib/test/test_pty.py rename to Src.GetRenamed/StdLib/Lib/test/test_pty.py diff --git a/Src/StdLib/Lib/test/test_pulldom.py b/Src.GetRenamed/StdLib/Lib/test/test_pulldom.py similarity index 100% rename from Src/StdLib/Lib/test/test_pulldom.py rename to Src.GetRenamed/StdLib/Lib/test/test_pulldom.py diff --git a/Src/StdLib/Lib/test/test_pwd.py b/Src.GetRenamed/StdLib/Lib/test/test_pwd.py similarity index 100% rename from Src/StdLib/Lib/test/test_pwd.py rename to Src.GetRenamed/StdLib/Lib/test/test_pwd.py diff --git a/Src/StdLib/Lib/test/test_py_compile.py b/Src.GetRenamed/StdLib/Lib/test/test_py_compile.py similarity index 100% rename from Src/StdLib/Lib/test/test_py_compile.py rename to Src.GetRenamed/StdLib/Lib/test/test_py_compile.py diff --git a/Src/StdLib/Lib/test/test_pyclbr.py b/Src.GetRenamed/StdLib/Lib/test/test_pyclbr.py similarity index 100% rename from Src/StdLib/Lib/test/test_pyclbr.py rename to Src.GetRenamed/StdLib/Lib/test/test_pyclbr.py diff --git a/Src/StdLib/Lib/test/test_pydoc.py b/Src.GetRenamed/StdLib/Lib/test/test_pydoc.py similarity index 100% rename from Src/StdLib/Lib/test/test_pydoc.py rename to Src.GetRenamed/StdLib/Lib/test/test_pydoc.py diff --git a/Src/StdLib/Lib/test/test_pyexpat.py b/Src.GetRenamed/StdLib/Lib/test/test_pyexpat.py similarity index 100% rename from Src/StdLib/Lib/test/test_pyexpat.py rename to Src.GetRenamed/StdLib/Lib/test/test_pyexpat.py diff --git a/Src/StdLib/Lib/test/test_queue.py b/Src.GetRenamed/StdLib/Lib/test/test_queue.py similarity index 100% rename from Src/StdLib/Lib/test/test_queue.py rename to Src.GetRenamed/StdLib/Lib/test/test_queue.py diff --git a/Src/StdLib/Lib/test/test_quopri.py b/Src.GetRenamed/StdLib/Lib/test/test_quopri.py similarity index 100% rename from Src/StdLib/Lib/test/test_quopri.py rename to Src.GetRenamed/StdLib/Lib/test/test_quopri.py diff --git a/Src/StdLib/Lib/test/test_raise.py b/Src.GetRenamed/StdLib/Lib/test/test_raise.py similarity index 100% rename from Src/StdLib/Lib/test/test_raise.py rename to Src.GetRenamed/StdLib/Lib/test/test_raise.py diff --git a/Src/StdLib/Lib/test/test_random.py b/Src.GetRenamed/StdLib/Lib/test/test_random.py similarity index 100% rename from Src/StdLib/Lib/test/test_random.py rename to Src.GetRenamed/StdLib/Lib/test/test_random.py diff --git a/Src/StdLib/Lib/test/test_range.py b/Src.GetRenamed/StdLib/Lib/test/test_range.py similarity index 100% rename from Src/StdLib/Lib/test/test_range.py rename to Src.GetRenamed/StdLib/Lib/test/test_range.py diff --git a/Src/StdLib/Lib/test/test_re.py b/Src.GetRenamed/StdLib/Lib/test/test_re.py similarity index 100% rename from Src/StdLib/Lib/test/test_re.py rename to Src.GetRenamed/StdLib/Lib/test/test_re.py diff --git a/Src/StdLib/Lib/test/test_readline.py b/Src.GetRenamed/StdLib/Lib/test/test_readline.py similarity index 100% rename from Src/StdLib/Lib/test/test_readline.py rename to Src.GetRenamed/StdLib/Lib/test/test_readline.py diff --git a/Src/StdLib/Lib/test/test_regrtest.py b/Src.GetRenamed/StdLib/Lib/test/test_regrtest.py similarity index 100% rename from Src/StdLib/Lib/test/test_regrtest.py rename to Src.GetRenamed/StdLib/Lib/test/test_regrtest.py diff --git a/Src/StdLib/Lib/test/test_reprlib.py b/Src.GetRenamed/StdLib/Lib/test/test_reprlib.py similarity index 100% rename from Src/StdLib/Lib/test/test_reprlib.py rename to Src.GetRenamed/StdLib/Lib/test/test_reprlib.py diff --git a/Src/StdLib/Lib/test/test_resource.py b/Src.GetRenamed/StdLib/Lib/test/test_resource.py similarity index 100% rename from Src/StdLib/Lib/test/test_resource.py rename to Src.GetRenamed/StdLib/Lib/test/test_resource.py diff --git a/Src/StdLib/Lib/test/test_richcmp.py b/Src.GetRenamed/StdLib/Lib/test/test_richcmp.py similarity index 100% rename from Src/StdLib/Lib/test/test_richcmp.py rename to Src.GetRenamed/StdLib/Lib/test/test_richcmp.py diff --git a/Src/StdLib/Lib/test/test_rlcompleter.py b/Src.GetRenamed/StdLib/Lib/test/test_rlcompleter.py similarity index 100% rename from Src/StdLib/Lib/test/test_rlcompleter.py rename to Src.GetRenamed/StdLib/Lib/test/test_rlcompleter.py diff --git a/Src/StdLib/Lib/test/test_robotparser.py b/Src.GetRenamed/StdLib/Lib/test/test_robotparser.py similarity index 100% rename from Src/StdLib/Lib/test/test_robotparser.py rename to Src.GetRenamed/StdLib/Lib/test/test_robotparser.py diff --git a/Src/StdLib/Lib/test/test_runpy.py b/Src.GetRenamed/StdLib/Lib/test/test_runpy.py similarity index 100% rename from Src/StdLib/Lib/test/test_runpy.py rename to Src.GetRenamed/StdLib/Lib/test/test_runpy.py diff --git a/Src/StdLib/Lib/test/test_sax.py b/Src.GetRenamed/StdLib/Lib/test/test_sax.py similarity index 100% rename from Src/StdLib/Lib/test/test_sax.py rename to Src.GetRenamed/StdLib/Lib/test/test_sax.py diff --git a/Src/StdLib/Lib/test/test_sched.py b/Src.GetRenamed/StdLib/Lib/test/test_sched.py similarity index 100% rename from Src/StdLib/Lib/test/test_sched.py rename to Src.GetRenamed/StdLib/Lib/test/test_sched.py diff --git a/Src/StdLib/Lib/test/test_scope.py b/Src.GetRenamed/StdLib/Lib/test/test_scope.py similarity index 100% rename from Src/StdLib/Lib/test/test_scope.py rename to Src.GetRenamed/StdLib/Lib/test/test_scope.py diff --git a/Src/StdLib/Lib/test/test_script_helper.py b/Src.GetRenamed/StdLib/Lib/test/test_script_helper.py similarity index 100% rename from Src/StdLib/Lib/test/test_script_helper.py rename to Src.GetRenamed/StdLib/Lib/test/test_script_helper.py diff --git a/Src/StdLib/Lib/test/test_select.py b/Src.GetRenamed/StdLib/Lib/test/test_select.py similarity index 100% rename from Src/StdLib/Lib/test/test_select.py rename to Src.GetRenamed/StdLib/Lib/test/test_select.py diff --git a/Src/StdLib/Lib/test/test_selectors.py b/Src.GetRenamed/StdLib/Lib/test/test_selectors.py similarity index 100% rename from Src/StdLib/Lib/test/test_selectors.py rename to Src.GetRenamed/StdLib/Lib/test/test_selectors.py diff --git a/Src/StdLib/Lib/test/test_set.py b/Src.GetRenamed/StdLib/Lib/test/test_set.py similarity index 100% rename from Src/StdLib/Lib/test/test_set.py rename to Src.GetRenamed/StdLib/Lib/test/test_set.py diff --git a/Src/StdLib/Lib/test/test_setcomps.py b/Src.GetRenamed/StdLib/Lib/test/test_setcomps.py similarity index 100% rename from Src/StdLib/Lib/test/test_setcomps.py rename to Src.GetRenamed/StdLib/Lib/test/test_setcomps.py diff --git a/Src/StdLib/Lib/test/test_shelve.py b/Src.GetRenamed/StdLib/Lib/test/test_shelve.py similarity index 100% rename from Src/StdLib/Lib/test/test_shelve.py rename to Src.GetRenamed/StdLib/Lib/test/test_shelve.py diff --git a/Src/StdLib/Lib/test/test_shlex.py b/Src.GetRenamed/StdLib/Lib/test/test_shlex.py similarity index 100% rename from Src/StdLib/Lib/test/test_shlex.py rename to Src.GetRenamed/StdLib/Lib/test/test_shlex.py diff --git a/Src/StdLib/Lib/test/test_shutil.py b/Src.GetRenamed/StdLib/Lib/test/test_shutil.py similarity index 100% rename from Src/StdLib/Lib/test/test_shutil.py rename to Src.GetRenamed/StdLib/Lib/test/test_shutil.py diff --git a/Src/StdLib/Lib/test/test_signal.py b/Src.GetRenamed/StdLib/Lib/test/test_signal.py similarity index 100% rename from Src/StdLib/Lib/test/test_signal.py rename to Src.GetRenamed/StdLib/Lib/test/test_signal.py diff --git a/Src/StdLib/Lib/test/test_site.py b/Src.GetRenamed/StdLib/Lib/test/test_site.py similarity index 100% rename from Src/StdLib/Lib/test/test_site.py rename to Src.GetRenamed/StdLib/Lib/test/test_site.py diff --git a/Src/StdLib/Lib/test/test_slice.py b/Src.GetRenamed/StdLib/Lib/test/test_slice.py similarity index 100% rename from Src/StdLib/Lib/test/test_slice.py rename to Src.GetRenamed/StdLib/Lib/test/test_slice.py diff --git a/Src/StdLib/Lib/test/test_smtpd.py b/Src.GetRenamed/StdLib/Lib/test/test_smtpd.py similarity index 100% rename from Src/StdLib/Lib/test/test_smtpd.py rename to Src.GetRenamed/StdLib/Lib/test/test_smtpd.py diff --git a/Src/StdLib/Lib/test/test_smtplib.py b/Src.GetRenamed/StdLib/Lib/test/test_smtplib.py similarity index 100% rename from Src/StdLib/Lib/test/test_smtplib.py rename to Src.GetRenamed/StdLib/Lib/test/test_smtplib.py diff --git a/Src/StdLib/Lib/test/test_smtpnet.py b/Src.GetRenamed/StdLib/Lib/test/test_smtpnet.py similarity index 100% rename from Src/StdLib/Lib/test/test_smtpnet.py rename to Src.GetRenamed/StdLib/Lib/test/test_smtpnet.py diff --git a/Src/StdLib/Lib/test/test_sndhdr.py b/Src.GetRenamed/StdLib/Lib/test/test_sndhdr.py similarity index 100% rename from Src/StdLib/Lib/test/test_sndhdr.py rename to Src.GetRenamed/StdLib/Lib/test/test_sndhdr.py diff --git a/Src/StdLib/Lib/test/test_socket.py b/Src.GetRenamed/StdLib/Lib/test/test_socket.py similarity index 100% rename from Src/StdLib/Lib/test/test_socket.py rename to Src.GetRenamed/StdLib/Lib/test/test_socket.py diff --git a/Src/StdLib/Lib/test/test_socketserver.py b/Src.GetRenamed/StdLib/Lib/test/test_socketserver.py similarity index 100% rename from Src/StdLib/Lib/test/test_socketserver.py rename to Src.GetRenamed/StdLib/Lib/test/test_socketserver.py diff --git a/Src/StdLib/Lib/test/test_sort.py b/Src.GetRenamed/StdLib/Lib/test/test_sort.py similarity index 100% rename from Src/StdLib/Lib/test/test_sort.py rename to Src.GetRenamed/StdLib/Lib/test/test_sort.py diff --git a/Src/StdLib/Lib/test/test_source_encoding.py b/Src.GetRenamed/StdLib/Lib/test/test_source_encoding.py similarity index 100% rename from Src/StdLib/Lib/test/test_source_encoding.py rename to Src.GetRenamed/StdLib/Lib/test/test_source_encoding.py diff --git a/Src/StdLib/Lib/test/test_spwd.py b/Src.GetRenamed/StdLib/Lib/test/test_spwd.py similarity index 100% rename from Src/StdLib/Lib/test/test_spwd.py rename to Src.GetRenamed/StdLib/Lib/test/test_spwd.py diff --git a/Src/StdLib/Lib/test/test_sqlite.py b/Src.GetRenamed/StdLib/Lib/test/test_sqlite.py similarity index 100% rename from Src/StdLib/Lib/test/test_sqlite.py rename to Src.GetRenamed/StdLib/Lib/test/test_sqlite.py diff --git a/Src/StdLib/Lib/test/test_ssl.py b/Src.GetRenamed/StdLib/Lib/test/test_ssl.py similarity index 100% rename from Src/StdLib/Lib/test/test_ssl.py rename to Src.GetRenamed/StdLib/Lib/test/test_ssl.py diff --git a/Src/StdLib/Lib/test/test_startfile.py b/Src.GetRenamed/StdLib/Lib/test/test_startfile.py similarity index 100% rename from Src/StdLib/Lib/test/test_startfile.py rename to Src.GetRenamed/StdLib/Lib/test/test_startfile.py diff --git a/Src/StdLib/Lib/test/test_stat.py b/Src.GetRenamed/StdLib/Lib/test/test_stat.py similarity index 100% rename from Src/StdLib/Lib/test/test_stat.py rename to Src.GetRenamed/StdLib/Lib/test/test_stat.py diff --git a/Src/StdLib/Lib/test/test_statistics.py b/Src.GetRenamed/StdLib/Lib/test/test_statistics.py similarity index 100% rename from Src/StdLib/Lib/test/test_statistics.py rename to Src.GetRenamed/StdLib/Lib/test/test_statistics.py diff --git a/Src/StdLib/Lib/test/test_strftime.py b/Src.GetRenamed/StdLib/Lib/test/test_strftime.py similarity index 100% rename from Src/StdLib/Lib/test/test_strftime.py rename to Src.GetRenamed/StdLib/Lib/test/test_strftime.py diff --git a/Src/StdLib/Lib/test/test_string.py b/Src.GetRenamed/StdLib/Lib/test/test_string.py similarity index 100% rename from Src/StdLib/Lib/test/test_string.py rename to Src.GetRenamed/StdLib/Lib/test/test_string.py diff --git a/Src/StdLib/Lib/test/test_stringprep.py b/Src.GetRenamed/StdLib/Lib/test/test_stringprep.py similarity index 100% rename from Src/StdLib/Lib/test/test_stringprep.py rename to Src.GetRenamed/StdLib/Lib/test/test_stringprep.py diff --git a/Src/StdLib/Lib/test/test_strlit.py b/Src.GetRenamed/StdLib/Lib/test/test_strlit.py similarity index 100% rename from Src/StdLib/Lib/test/test_strlit.py rename to Src.GetRenamed/StdLib/Lib/test/test_strlit.py diff --git a/Src/StdLib/Lib/test/test_strptime.py b/Src.GetRenamed/StdLib/Lib/test/test_strptime.py similarity index 100% rename from Src/StdLib/Lib/test/test_strptime.py rename to Src.GetRenamed/StdLib/Lib/test/test_strptime.py diff --git a/Src/StdLib/Lib/test/test_strtod.py b/Src.GetRenamed/StdLib/Lib/test/test_strtod.py similarity index 100% rename from Src/StdLib/Lib/test/test_strtod.py rename to Src.GetRenamed/StdLib/Lib/test/test_strtod.py diff --git a/Src/StdLib/Lib/test/test_struct.py b/Src.GetRenamed/StdLib/Lib/test/test_struct.py similarity index 100% rename from Src/StdLib/Lib/test/test_struct.py rename to Src.GetRenamed/StdLib/Lib/test/test_struct.py diff --git a/Src/StdLib/Lib/test/test_structmembers.py b/Src.GetRenamed/StdLib/Lib/test/test_structmembers.py similarity index 100% rename from Src/StdLib/Lib/test/test_structmembers.py rename to Src.GetRenamed/StdLib/Lib/test/test_structmembers.py diff --git a/Src/StdLib/Lib/test/test_structseq.py b/Src.GetRenamed/StdLib/Lib/test/test_structseq.py similarity index 100% rename from Src/StdLib/Lib/test/test_structseq.py rename to Src.GetRenamed/StdLib/Lib/test/test_structseq.py diff --git a/Src/StdLib/Lib/test/test_subprocess.py b/Src.GetRenamed/StdLib/Lib/test/test_subprocess.py similarity index 100% rename from Src/StdLib/Lib/test/test_subprocess.py rename to Src.GetRenamed/StdLib/Lib/test/test_subprocess.py diff --git a/Src/StdLib/Lib/test/test_sunau.py b/Src.GetRenamed/StdLib/Lib/test/test_sunau.py similarity index 100% rename from Src/StdLib/Lib/test/test_sunau.py rename to Src.GetRenamed/StdLib/Lib/test/test_sunau.py diff --git a/Src/StdLib/Lib/test/test_sundry.py b/Src.GetRenamed/StdLib/Lib/test/test_sundry.py similarity index 100% rename from Src/StdLib/Lib/test/test_sundry.py rename to Src.GetRenamed/StdLib/Lib/test/test_sundry.py diff --git a/Src/StdLib/Lib/test/test_super.py b/Src.GetRenamed/StdLib/Lib/test/test_super.py similarity index 100% rename from Src/StdLib/Lib/test/test_super.py rename to Src.GetRenamed/StdLib/Lib/test/test_super.py diff --git a/Src/StdLib/Lib/test/test_support.py b/Src.GetRenamed/StdLib/Lib/test/test_support.py similarity index 100% rename from Src/StdLib/Lib/test/test_support.py rename to Src.GetRenamed/StdLib/Lib/test/test_support.py diff --git a/Src/StdLib/Lib/test/test_symtable.py b/Src.GetRenamed/StdLib/Lib/test/test_symtable.py similarity index 100% rename from Src/StdLib/Lib/test/test_symtable.py rename to Src.GetRenamed/StdLib/Lib/test/test_symtable.py diff --git a/Src/StdLib/Lib/test/test_syntax.py b/Src.GetRenamed/StdLib/Lib/test/test_syntax.py similarity index 100% rename from Src/StdLib/Lib/test/test_syntax.py rename to Src.GetRenamed/StdLib/Lib/test/test_syntax.py diff --git a/Src/StdLib/Lib/test/test_sys.py b/Src.GetRenamed/StdLib/Lib/test/test_sys.py similarity index 100% rename from Src/StdLib/Lib/test/test_sys.py rename to Src.GetRenamed/StdLib/Lib/test/test_sys.py diff --git a/Src/StdLib/Lib/test/test_sys_setprofile.py b/Src.GetRenamed/StdLib/Lib/test/test_sys_setprofile.py similarity index 100% rename from Src/StdLib/Lib/test/test_sys_setprofile.py rename to Src.GetRenamed/StdLib/Lib/test/test_sys_setprofile.py diff --git a/Src/StdLib/Lib/test/test_sys_settrace.py b/Src.GetRenamed/StdLib/Lib/test/test_sys_settrace.py similarity index 100% rename from Src/StdLib/Lib/test/test_sys_settrace.py rename to Src.GetRenamed/StdLib/Lib/test/test_sys_settrace.py diff --git a/Src/StdLib/Lib/test/test_sysconfig.py b/Src.GetRenamed/StdLib/Lib/test/test_sysconfig.py similarity index 100% rename from Src/StdLib/Lib/test/test_sysconfig.py rename to Src.GetRenamed/StdLib/Lib/test/test_sysconfig.py diff --git a/Src/StdLib/Lib/test/test_syslog.py b/Src.GetRenamed/StdLib/Lib/test/test_syslog.py similarity index 100% rename from Src/StdLib/Lib/test/test_syslog.py rename to Src.GetRenamed/StdLib/Lib/test/test_syslog.py diff --git a/Src/StdLib/Lib/test/test_tarfile.py b/Src.GetRenamed/StdLib/Lib/test/test_tarfile.py similarity index 100% rename from Src/StdLib/Lib/test/test_tarfile.py rename to Src.GetRenamed/StdLib/Lib/test/test_tarfile.py diff --git a/Src/StdLib/Lib/test/test_tcl.py b/Src.GetRenamed/StdLib/Lib/test/test_tcl.py similarity index 100% rename from Src/StdLib/Lib/test/test_tcl.py rename to Src.GetRenamed/StdLib/Lib/test/test_tcl.py diff --git a/Src/StdLib/Lib/test/test_telnetlib.py b/Src.GetRenamed/StdLib/Lib/test/test_telnetlib.py similarity index 100% rename from Src/StdLib/Lib/test/test_telnetlib.py rename to Src.GetRenamed/StdLib/Lib/test/test_telnetlib.py diff --git a/Src/StdLib/Lib/test/test_tempfile.py b/Src.GetRenamed/StdLib/Lib/test/test_tempfile.py similarity index 100% rename from Src/StdLib/Lib/test/test_tempfile.py rename to Src.GetRenamed/StdLib/Lib/test/test_tempfile.py diff --git a/Src/StdLib/Lib/test/test_textwrap.py b/Src.GetRenamed/StdLib/Lib/test/test_textwrap.py similarity index 100% rename from Src/StdLib/Lib/test/test_textwrap.py rename to Src.GetRenamed/StdLib/Lib/test/test_textwrap.py diff --git a/Src/StdLib/Lib/test/test_thread.py b/Src.GetRenamed/StdLib/Lib/test/test_thread.py similarity index 100% rename from Src/StdLib/Lib/test/test_thread.py rename to Src.GetRenamed/StdLib/Lib/test/test_thread.py diff --git a/Src/StdLib/Lib/test/test_threaded_import.py b/Src.GetRenamed/StdLib/Lib/test/test_threaded_import.py similarity index 100% rename from Src/StdLib/Lib/test/test_threaded_import.py rename to Src.GetRenamed/StdLib/Lib/test/test_threaded_import.py diff --git a/Src/StdLib/Lib/test/test_threadedtempfile.py b/Src.GetRenamed/StdLib/Lib/test/test_threadedtempfile.py similarity index 100% rename from Src/StdLib/Lib/test/test_threadedtempfile.py rename to Src.GetRenamed/StdLib/Lib/test/test_threadedtempfile.py diff --git a/Src/StdLib/Lib/test/test_threading.py b/Src.GetRenamed/StdLib/Lib/test/test_threading.py similarity index 100% rename from Src/StdLib/Lib/test/test_threading.py rename to Src.GetRenamed/StdLib/Lib/test/test_threading.py diff --git a/Src/StdLib/Lib/test/test_threading_local.py b/Src.GetRenamed/StdLib/Lib/test/test_threading_local.py similarity index 100% rename from Src/StdLib/Lib/test/test_threading_local.py rename to Src.GetRenamed/StdLib/Lib/test/test_threading_local.py diff --git a/Src/StdLib/Lib/test/test_threadsignals.py b/Src.GetRenamed/StdLib/Lib/test/test_threadsignals.py similarity index 100% rename from Src/StdLib/Lib/test/test_threadsignals.py rename to Src.GetRenamed/StdLib/Lib/test/test_threadsignals.py diff --git a/Src/StdLib/Lib/test/test_time.py b/Src.GetRenamed/StdLib/Lib/test/test_time.py similarity index 100% rename from Src/StdLib/Lib/test/test_time.py rename to Src.GetRenamed/StdLib/Lib/test/test_time.py diff --git a/Src/StdLib/Lib/test/test_timeit.py b/Src.GetRenamed/StdLib/Lib/test/test_timeit.py similarity index 100% rename from Src/StdLib/Lib/test/test_timeit.py rename to Src.GetRenamed/StdLib/Lib/test/test_timeit.py diff --git a/Src/StdLib/Lib/test/test_timeout.py b/Src.GetRenamed/StdLib/Lib/test/test_timeout.py similarity index 100% rename from Src/StdLib/Lib/test/test_timeout.py rename to Src.GetRenamed/StdLib/Lib/test/test_timeout.py diff --git a/Src/StdLib/Lib/test/test_tk.py b/Src.GetRenamed/StdLib/Lib/test/test_tk.py similarity index 100% rename from Src/StdLib/Lib/test/test_tk.py rename to Src.GetRenamed/StdLib/Lib/test/test_tk.py diff --git a/Src/StdLib/Lib/test/test_tokenize.py b/Src.GetRenamed/StdLib/Lib/test/test_tokenize.py similarity index 100% rename from Src/StdLib/Lib/test/test_tokenize.py rename to Src.GetRenamed/StdLib/Lib/test/test_tokenize.py diff --git a/Src/StdLib/Lib/test/test_tools/__init__.py b/Src.GetRenamed/StdLib/Lib/test/test_tools/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_tools/__init__.py rename to Src.GetRenamed/StdLib/Lib/test/test_tools/__init__.py diff --git a/Src/StdLib/Lib/test/test_tools/__main__.py b/Src.GetRenamed/StdLib/Lib/test/test_tools/__main__.py similarity index 100% rename from Src/StdLib/Lib/test/test_tools/__main__.py rename to Src.GetRenamed/StdLib/Lib/test/test_tools/__main__.py diff --git a/Src/StdLib/Lib/test/test_tools/test_gprof2html.py b/Src.GetRenamed/StdLib/Lib/test/test_tools/test_gprof2html.py similarity index 100% rename from Src/StdLib/Lib/test/test_tools/test_gprof2html.py rename to Src.GetRenamed/StdLib/Lib/test/test_tools/test_gprof2html.py diff --git a/Src/StdLib/Lib/test/test_tools/test_md5sum.py b/Src.GetRenamed/StdLib/Lib/test/test_tools/test_md5sum.py similarity index 100% rename from Src/StdLib/Lib/test/test_tools/test_md5sum.py rename to Src.GetRenamed/StdLib/Lib/test/test_tools/test_md5sum.py diff --git a/Src/StdLib/Lib/test/test_tools/test_pdeps.py b/Src.GetRenamed/StdLib/Lib/test/test_tools/test_pdeps.py similarity index 100% rename from Src/StdLib/Lib/test/test_tools/test_pdeps.py rename to Src.GetRenamed/StdLib/Lib/test/test_tools/test_pdeps.py diff --git a/Src/StdLib/Lib/test/test_tools/test_pindent.py b/Src.GetRenamed/StdLib/Lib/test/test_tools/test_pindent.py similarity index 100% rename from Src/StdLib/Lib/test/test_tools/test_pindent.py rename to Src.GetRenamed/StdLib/Lib/test/test_tools/test_pindent.py diff --git a/Src/StdLib/Lib/test/test_tools/test_reindent.py b/Src.GetRenamed/StdLib/Lib/test/test_tools/test_reindent.py similarity index 100% rename from Src/StdLib/Lib/test/test_tools/test_reindent.py rename to Src.GetRenamed/StdLib/Lib/test/test_tools/test_reindent.py diff --git a/Src/StdLib/Lib/test/test_tools/test_sundry.py b/Src.GetRenamed/StdLib/Lib/test/test_tools/test_sundry.py similarity index 100% rename from Src/StdLib/Lib/test/test_tools/test_sundry.py rename to Src.GetRenamed/StdLib/Lib/test/test_tools/test_sundry.py diff --git a/Src/StdLib/Lib/test/test_tools/test_unparse.py b/Src.GetRenamed/StdLib/Lib/test/test_tools/test_unparse.py similarity index 100% rename from Src/StdLib/Lib/test/test_tools/test_unparse.py rename to Src.GetRenamed/StdLib/Lib/test/test_tools/test_unparse.py diff --git a/Src/StdLib/Lib/test/test_trace.py b/Src.GetRenamed/StdLib/Lib/test/test_trace.py similarity index 100% rename from Src/StdLib/Lib/test/test_trace.py rename to Src.GetRenamed/StdLib/Lib/test/test_trace.py diff --git a/Src/StdLib/Lib/test/test_traceback.py b/Src.GetRenamed/StdLib/Lib/test/test_traceback.py similarity index 100% rename from Src/StdLib/Lib/test/test_traceback.py rename to Src.GetRenamed/StdLib/Lib/test/test_traceback.py diff --git a/Src/StdLib/Lib/test/test_tracemalloc.py b/Src.GetRenamed/StdLib/Lib/test/test_tracemalloc.py similarity index 100% rename from Src/StdLib/Lib/test/test_tracemalloc.py rename to Src.GetRenamed/StdLib/Lib/test/test_tracemalloc.py diff --git a/Src/StdLib/Lib/test/test_ttk_guionly.py b/Src.GetRenamed/StdLib/Lib/test/test_ttk_guionly.py similarity index 100% rename from Src/StdLib/Lib/test/test_ttk_guionly.py rename to Src.GetRenamed/StdLib/Lib/test/test_ttk_guionly.py diff --git a/Src/StdLib/Lib/test/test_ttk_textonly.py b/Src.GetRenamed/StdLib/Lib/test/test_ttk_textonly.py similarity index 100% rename from Src/StdLib/Lib/test/test_ttk_textonly.py rename to Src.GetRenamed/StdLib/Lib/test/test_ttk_textonly.py diff --git a/Src/StdLib/Lib/test/test_tuple.py b/Src.GetRenamed/StdLib/Lib/test/test_tuple.py similarity index 100% rename from Src/StdLib/Lib/test/test_tuple.py rename to Src.GetRenamed/StdLib/Lib/test/test_tuple.py diff --git a/Src/StdLib/Lib/test/test_typechecks.py b/Src.GetRenamed/StdLib/Lib/test/test_typechecks.py similarity index 100% rename from Src/StdLib/Lib/test/test_typechecks.py rename to Src.GetRenamed/StdLib/Lib/test/test_typechecks.py diff --git a/Src/StdLib/Lib/test/test_types.py b/Src.GetRenamed/StdLib/Lib/test/test_types.py similarity index 100% rename from Src/StdLib/Lib/test/test_types.py rename to Src.GetRenamed/StdLib/Lib/test/test_types.py diff --git a/Src/StdLib/Lib/test/test_typing.py b/Src.GetRenamed/StdLib/Lib/test/test_typing.py similarity index 100% rename from Src/StdLib/Lib/test/test_typing.py rename to Src.GetRenamed/StdLib/Lib/test/test_typing.py diff --git a/Src/StdLib/Lib/test/test_ucn.py b/Src.GetRenamed/StdLib/Lib/test/test_ucn.py similarity index 100% rename from Src/StdLib/Lib/test/test_ucn.py rename to Src.GetRenamed/StdLib/Lib/test/test_ucn.py diff --git a/Src/StdLib/Lib/test/test_unary.py b/Src.GetRenamed/StdLib/Lib/test/test_unary.py similarity index 100% rename from Src/StdLib/Lib/test/test_unary.py rename to Src.GetRenamed/StdLib/Lib/test/test_unary.py diff --git a/Src/StdLib/Lib/test/test_unicode.py b/Src.GetRenamed/StdLib/Lib/test/test_unicode.py similarity index 100% rename from Src/StdLib/Lib/test/test_unicode.py rename to Src.GetRenamed/StdLib/Lib/test/test_unicode.py diff --git a/Src/StdLib/Lib/test/test_unicode_file.py b/Src.GetRenamed/StdLib/Lib/test/test_unicode_file.py similarity index 100% rename from Src/StdLib/Lib/test/test_unicode_file.py rename to Src.GetRenamed/StdLib/Lib/test/test_unicode_file.py diff --git a/Src/StdLib/Lib/test/test_unicodedata.py b/Src.GetRenamed/StdLib/Lib/test/test_unicodedata.py similarity index 100% rename from Src/StdLib/Lib/test/test_unicodedata.py rename to Src.GetRenamed/StdLib/Lib/test/test_unicodedata.py diff --git a/Src/StdLib/Lib/test/test_unittest.py b/Src.GetRenamed/StdLib/Lib/test/test_unittest.py similarity index 100% rename from Src/StdLib/Lib/test/test_unittest.py rename to Src.GetRenamed/StdLib/Lib/test/test_unittest.py diff --git a/Src/StdLib/Lib/test/test_univnewlines.py b/Src.GetRenamed/StdLib/Lib/test/test_univnewlines.py similarity index 100% rename from Src/StdLib/Lib/test/test_univnewlines.py rename to Src.GetRenamed/StdLib/Lib/test/test_univnewlines.py diff --git a/Src/StdLib/Lib/test/test_unpack.py b/Src.GetRenamed/StdLib/Lib/test/test_unpack.py similarity index 100% rename from Src/StdLib/Lib/test/test_unpack.py rename to Src.GetRenamed/StdLib/Lib/test/test_unpack.py diff --git a/Src/StdLib/Lib/test/test_unpack_ex.py b/Src.GetRenamed/StdLib/Lib/test/test_unpack_ex.py similarity index 100% rename from Src/StdLib/Lib/test/test_unpack_ex.py rename to Src.GetRenamed/StdLib/Lib/test/test_unpack_ex.py diff --git a/Src/StdLib/Lib/test/test_urllib.py b/Src.GetRenamed/StdLib/Lib/test/test_urllib.py similarity index 100% rename from Src/StdLib/Lib/test/test_urllib.py rename to Src.GetRenamed/StdLib/Lib/test/test_urllib.py diff --git a/Src/StdLib/Lib/test/test_urllib2.py b/Src.GetRenamed/StdLib/Lib/test/test_urllib2.py similarity index 100% rename from Src/StdLib/Lib/test/test_urllib2.py rename to Src.GetRenamed/StdLib/Lib/test/test_urllib2.py diff --git a/Src/StdLib/Lib/test/test_urllib2_localnet.py b/Src.GetRenamed/StdLib/Lib/test/test_urllib2_localnet.py similarity index 100% rename from Src/StdLib/Lib/test/test_urllib2_localnet.py rename to Src.GetRenamed/StdLib/Lib/test/test_urllib2_localnet.py diff --git a/Src/StdLib/Lib/test/test_urllib2net.py b/Src.GetRenamed/StdLib/Lib/test/test_urllib2net.py similarity index 100% rename from Src/StdLib/Lib/test/test_urllib2net.py rename to Src.GetRenamed/StdLib/Lib/test/test_urllib2net.py diff --git a/Src/StdLib/Lib/test/test_urllib_response.py b/Src.GetRenamed/StdLib/Lib/test/test_urllib_response.py similarity index 100% rename from Src/StdLib/Lib/test/test_urllib_response.py rename to Src.GetRenamed/StdLib/Lib/test/test_urllib_response.py diff --git a/Src/StdLib/Lib/test/test_urllibnet.py b/Src.GetRenamed/StdLib/Lib/test/test_urllibnet.py similarity index 100% rename from Src/StdLib/Lib/test/test_urllibnet.py rename to Src.GetRenamed/StdLib/Lib/test/test_urllibnet.py diff --git a/Src/StdLib/Lib/test/test_urlparse.py b/Src.GetRenamed/StdLib/Lib/test/test_urlparse.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/test/test_urlparse.py rename to Src.GetRenamed/StdLib/Lib/test/test_urlparse.py diff --git a/Src/StdLib/Lib/test/test_userdict.py b/Src.GetRenamed/StdLib/Lib/test/test_userdict.py similarity index 100% rename from Src/StdLib/Lib/test/test_userdict.py rename to Src.GetRenamed/StdLib/Lib/test/test_userdict.py diff --git a/Src/StdLib/Lib/test/test_userlist.py b/Src.GetRenamed/StdLib/Lib/test/test_userlist.py similarity index 100% rename from Src/StdLib/Lib/test/test_userlist.py rename to Src.GetRenamed/StdLib/Lib/test/test_userlist.py diff --git a/Src/StdLib/Lib/test/test_userstring.py b/Src.GetRenamed/StdLib/Lib/test/test_userstring.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/test/test_userstring.py rename to Src.GetRenamed/StdLib/Lib/test/test_userstring.py diff --git a/Src/StdLib/Lib/test/test_utf8_mode.py b/Src.GetRenamed/StdLib/Lib/test/test_utf8_mode.py similarity index 100% rename from Src/StdLib/Lib/test/test_utf8_mode.py rename to Src.GetRenamed/StdLib/Lib/test/test_utf8_mode.py diff --git a/Src/StdLib/Lib/test/test_uu.py b/Src.GetRenamed/StdLib/Lib/test/test_uu.py similarity index 100% rename from Src/StdLib/Lib/test/test_uu.py rename to Src.GetRenamed/StdLib/Lib/test/test_uu.py diff --git a/Src/StdLib/Lib/test/test_uuid.py b/Src.GetRenamed/StdLib/Lib/test/test_uuid.py similarity index 100% rename from Src/StdLib/Lib/test/test_uuid.py rename to Src.GetRenamed/StdLib/Lib/test/test_uuid.py diff --git a/Src/StdLib/Lib/test/test_venv.py b/Src.GetRenamed/StdLib/Lib/test/test_venv.py similarity index 100% rename from Src/StdLib/Lib/test/test_venv.py rename to Src.GetRenamed/StdLib/Lib/test/test_venv.py diff --git a/Src/StdLib/Lib/test/test_wait3.py b/Src.GetRenamed/StdLib/Lib/test/test_wait3.py similarity index 100% rename from Src/StdLib/Lib/test/test_wait3.py rename to Src.GetRenamed/StdLib/Lib/test/test_wait3.py diff --git a/Src/StdLib/Lib/test/test_wait4.py b/Src.GetRenamed/StdLib/Lib/test/test_wait4.py similarity index 100% rename from Src/StdLib/Lib/test/test_wait4.py rename to Src.GetRenamed/StdLib/Lib/test/test_wait4.py diff --git a/Src/StdLib/Lib/test/test_warnings.py b/Src.GetRenamed/StdLib/Lib/test/test_warnings.py similarity index 100% rename from Src/StdLib/Lib/test/test_warnings.py rename to Src.GetRenamed/StdLib/Lib/test/test_warnings.py diff --git a/Src/StdLib/Lib/test/test_wave.py b/Src.GetRenamed/StdLib/Lib/test/test_wave.py similarity index 100% rename from Src/StdLib/Lib/test/test_wave.py rename to Src.GetRenamed/StdLib/Lib/test/test_wave.py diff --git a/Src/StdLib/Lib/test/test_weakref.py b/Src.GetRenamed/StdLib/Lib/test/test_weakref.py similarity index 100% rename from Src/StdLib/Lib/test/test_weakref.py rename to Src.GetRenamed/StdLib/Lib/test/test_weakref.py diff --git a/Src/StdLib/Lib/test/test_weakset.py b/Src.GetRenamed/StdLib/Lib/test/test_weakset.py similarity index 100% rename from Src/StdLib/Lib/test/test_weakset.py rename to Src.GetRenamed/StdLib/Lib/test/test_weakset.py diff --git a/Src/StdLib/Lib/test/test_webbrowser.py b/Src.GetRenamed/StdLib/Lib/test/test_webbrowser.py similarity index 100% rename from Src/StdLib/Lib/test/test_webbrowser.py rename to Src.GetRenamed/StdLib/Lib/test/test_webbrowser.py diff --git a/Src/StdLib/Lib/test/test_winreg.py b/Src.GetRenamed/StdLib/Lib/test/test_winreg.py similarity index 100% rename from Src/StdLib/Lib/test/test_winreg.py rename to Src.GetRenamed/StdLib/Lib/test/test_winreg.py diff --git a/Src/StdLib/Lib/test/test_winsound.py b/Src.GetRenamed/StdLib/Lib/test/test_winsound.py similarity index 100% rename from Src/StdLib/Lib/test/test_winsound.py rename to Src.GetRenamed/StdLib/Lib/test/test_winsound.py diff --git a/Src/StdLib/Lib/test/test_with.py b/Src.GetRenamed/StdLib/Lib/test/test_with.py similarity index 100% rename from Src/StdLib/Lib/test/test_with.py rename to Src.GetRenamed/StdLib/Lib/test/test_with.py diff --git a/Src/StdLib/Lib/test/test_wsgiref.py b/Src.GetRenamed/StdLib/Lib/test/test_wsgiref.py similarity index 100% rename from Src/StdLib/Lib/test/test_wsgiref.py rename to Src.GetRenamed/StdLib/Lib/test/test_wsgiref.py diff --git a/Src/StdLib/Lib/test/test_xdrlib.py b/Src.GetRenamed/StdLib/Lib/test/test_xdrlib.py similarity index 100% rename from Src/StdLib/Lib/test/test_xdrlib.py rename to Src.GetRenamed/StdLib/Lib/test/test_xdrlib.py diff --git a/Src/StdLib/Lib/test/test_xml_dom_minicompat.py b/Src.GetRenamed/StdLib/Lib/test/test_xml_dom_minicompat.py similarity index 100% rename from Src/StdLib/Lib/test/test_xml_dom_minicompat.py rename to Src.GetRenamed/StdLib/Lib/test/test_xml_dom_minicompat.py diff --git a/Src/StdLib/Lib/test/test_xml_etree.py b/Src.GetRenamed/StdLib/Lib/test/test_xml_etree.py similarity index 100% rename from Src/StdLib/Lib/test/test_xml_etree.py rename to Src.GetRenamed/StdLib/Lib/test/test_xml_etree.py diff --git a/Src/StdLib/Lib/test/test_xml_etree_c.py b/Src.GetRenamed/StdLib/Lib/test/test_xml_etree_c.py similarity index 100% rename from Src/StdLib/Lib/test/test_xml_etree_c.py rename to Src.GetRenamed/StdLib/Lib/test/test_xml_etree_c.py diff --git a/Src/StdLib/Lib/test/test_xmlrpc.py b/Src.GetRenamed/StdLib/Lib/test/test_xmlrpc.py similarity index 100% rename from Src/StdLib/Lib/test/test_xmlrpc.py rename to Src.GetRenamed/StdLib/Lib/test/test_xmlrpc.py diff --git a/Src/StdLib/Lib/test/test_xmlrpc_net.py b/Src.GetRenamed/StdLib/Lib/test/test_xmlrpc_net.py similarity index 100% rename from Src/StdLib/Lib/test/test_xmlrpc_net.py rename to Src.GetRenamed/StdLib/Lib/test/test_xmlrpc_net.py diff --git a/Src/StdLib/Lib/test/test_zipfile.py b/Src.GetRenamed/StdLib/Lib/test/test_zipfile.py similarity index 100% rename from Src/StdLib/Lib/test/test_zipfile.py rename to Src.GetRenamed/StdLib/Lib/test/test_zipfile.py diff --git a/Src/StdLib/Lib/test/test_zipfile64.py b/Src.GetRenamed/StdLib/Lib/test/test_zipfile64.py similarity index 100% rename from Src/StdLib/Lib/test/test_zipfile64.py rename to Src.GetRenamed/StdLib/Lib/test/test_zipfile64.py diff --git a/Src/StdLib/Lib/test/test_zipimport.py b/Src.GetRenamed/StdLib/Lib/test/test_zipimport.py similarity index 100% rename from Src/StdLib/Lib/test/test_zipimport.py rename to Src.GetRenamed/StdLib/Lib/test/test_zipimport.py diff --git a/Src/StdLib/Lib/test/test_zipimport_support.py b/Src.GetRenamed/StdLib/Lib/test/test_zipimport_support.py similarity index 100% rename from Src/StdLib/Lib/test/test_zipimport_support.py rename to Src.GetRenamed/StdLib/Lib/test/test_zipimport_support.py diff --git a/Src/StdLib/Lib/test/test_zlib.py b/Src.GetRenamed/StdLib/Lib/test/test_zlib.py similarity index 100% rename from Src/StdLib/Lib/test/test_zlib.py rename to Src.GetRenamed/StdLib/Lib/test/test_zlib.py diff --git a/Src/StdLib/Lib/test/testcodec.py b/Src.GetRenamed/StdLib/Lib/test/testcodec.py similarity index 100% rename from Src/StdLib/Lib/test/testcodec.py rename to Src.GetRenamed/StdLib/Lib/test/testcodec.py diff --git a/Src/StdLib/Lib/test/testtar.tar b/Src.GetRenamed/StdLib/Lib/test/testtar.tar similarity index 100% rename from Src/StdLib/Lib/test/testtar.tar rename to Src.GetRenamed/StdLib/Lib/test/testtar.tar diff --git a/Src/StdLib/Lib/test/tf_inherit_check.py b/Src.GetRenamed/StdLib/Lib/test/tf_inherit_check.py similarity index 100% rename from Src/StdLib/Lib/test/tf_inherit_check.py rename to Src.GetRenamed/StdLib/Lib/test/tf_inherit_check.py diff --git a/Src/StdLib/Lib/test/threaded_import_hangers.py b/Src.GetRenamed/StdLib/Lib/test/threaded_import_hangers.py similarity index 100% rename from Src/StdLib/Lib/test/threaded_import_hangers.py rename to Src.GetRenamed/StdLib/Lib/test/threaded_import_hangers.py diff --git a/Src/StdLib/Lib/test/time_hashlib.py b/Src.GetRenamed/StdLib/Lib/test/time_hashlib.py similarity index 100% rename from Src/StdLib/Lib/test/time_hashlib.py rename to Src.GetRenamed/StdLib/Lib/test/time_hashlib.py diff --git a/Src/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt b/Src.GetRenamed/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt similarity index 100% rename from Src/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt rename to Src.GetRenamed/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt diff --git a/Src/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt b/Src.GetRenamed/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt similarity index 100% rename from Src/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt rename to Src.GetRenamed/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt diff --git a/Src/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt b/Src.GetRenamed/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt similarity index 100% rename from Src/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt rename to Src.GetRenamed/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt diff --git a/Src/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt b/Src.GetRenamed/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt similarity index 100% rename from Src/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt rename to Src.GetRenamed/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt diff --git a/Src/StdLib/Lib/test/tokenize_tests.txt b/Src.GetRenamed/StdLib/Lib/test/tokenize_tests.txt similarity index 100% rename from Src/StdLib/Lib/test/tokenize_tests.txt rename to Src.GetRenamed/StdLib/Lib/test/tokenize_tests.txt diff --git a/Src/StdLib/Lib/test/tracedmodules/__init__.py b/Src.GetRenamed/StdLib/Lib/test/tracedmodules/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/tracedmodules/__init__.py rename to Src.GetRenamed/StdLib/Lib/test/tracedmodules/__init__.py diff --git a/Src/StdLib/Lib/test/tracedmodules/testmod.py b/Src.GetRenamed/StdLib/Lib/test/tracedmodules/testmod.py similarity index 100% rename from Src/StdLib/Lib/test/tracedmodules/testmod.py rename to Src.GetRenamed/StdLib/Lib/test/tracedmodules/testmod.py diff --git a/Src/StdLib/Lib/test/warning_tests.py b/Src.GetRenamed/StdLib/Lib/test/warning_tests.py similarity index 100% rename from Src/StdLib/Lib/test/warning_tests.py rename to Src.GetRenamed/StdLib/Lib/test/warning_tests.py diff --git a/Src/StdLib/Lib/test/win_console_handler.py b/Src.GetRenamed/StdLib/Lib/test/win_console_handler.py similarity index 100% rename from Src/StdLib/Lib/test/win_console_handler.py rename to Src.GetRenamed/StdLib/Lib/test/win_console_handler.py diff --git a/Src/StdLib/Lib/test/xmltestdata/simple-ns.xml b/Src.GetRenamed/StdLib/Lib/test/xmltestdata/simple-ns.xml similarity index 100% rename from Src/StdLib/Lib/test/xmltestdata/simple-ns.xml rename to Src.GetRenamed/StdLib/Lib/test/xmltestdata/simple-ns.xml diff --git a/Src/StdLib/Lib/test/xmltestdata/simple.xml b/Src.GetRenamed/StdLib/Lib/test/xmltestdata/simple.xml similarity index 100% rename from Src/StdLib/Lib/test/xmltestdata/simple.xml rename to Src.GetRenamed/StdLib/Lib/test/xmltestdata/simple.xml diff --git a/Src/StdLib/Lib/test/xmltestdata/test.xml b/Src.GetRenamed/StdLib/Lib/test/xmltestdata/test.xml similarity index 100% rename from Src/StdLib/Lib/test/xmltestdata/test.xml rename to Src.GetRenamed/StdLib/Lib/test/xmltestdata/test.xml diff --git a/Src/StdLib/Lib/test/xmltestdata/test.xml.out b/Src.GetRenamed/StdLib/Lib/test/xmltestdata/test.xml.out similarity index 100% rename from Src/StdLib/Lib/test/xmltestdata/test.xml.out rename to Src.GetRenamed/StdLib/Lib/test/xmltestdata/test.xml.out diff --git a/Src/StdLib/Lib/test/xmltests.py b/Src.GetRenamed/StdLib/Lib/test/xmltests.py similarity index 100% rename from Src/StdLib/Lib/test/xmltests.py rename to Src.GetRenamed/StdLib/Lib/test/xmltests.py diff --git a/Src/StdLib/Lib/test/zip_cp437_header.zip b/Src.GetRenamed/StdLib/Lib/test/zip_cp437_header.zip similarity index 100% rename from Src/StdLib/Lib/test/zip_cp437_header.zip rename to Src.GetRenamed/StdLib/Lib/test/zip_cp437_header.zip diff --git a/Src/StdLib/Lib/test/zipdir.zip b/Src.GetRenamed/StdLib/Lib/test/zipdir.zip similarity index 100% rename from Src/StdLib/Lib/test/zipdir.zip rename to Src.GetRenamed/StdLib/Lib/test/zipdir.zip diff --git a/Src/StdLib/Lib/textwrap.py b/Src.GetRenamed/StdLib/Lib/textwrap.py similarity index 100% rename from Src/StdLib/Lib/textwrap.py rename to Src.GetRenamed/StdLib/Lib/textwrap.py diff --git a/Src/StdLib/Lib/this.py b/Src.GetRenamed/StdLib/Lib/this.py similarity index 100% rename from Src/StdLib/Lib/this.py rename to Src.GetRenamed/StdLib/Lib/this.py diff --git a/Src/StdLib/Lib/threading.py b/Src.GetRenamed/StdLib/Lib/threading.py similarity index 100% rename from Src/StdLib/Lib/threading.py rename to Src.GetRenamed/StdLib/Lib/threading.py diff --git a/Src/StdLib/Lib/timeit.py b/Src.GetRenamed/StdLib/Lib/timeit.py similarity index 100% rename from Src/StdLib/Lib/timeit.py rename to Src.GetRenamed/StdLib/Lib/timeit.py diff --git a/Src/StdLib/Lib/tkinter/__init__.py b/Src.GetRenamed/StdLib/Lib/tkinter/__init__.py similarity index 100% rename from Src/StdLib/Lib/tkinter/__init__.py rename to Src.GetRenamed/StdLib/Lib/tkinter/__init__.py diff --git a/Src/StdLib/Lib/tkinter/__main__.py b/Src.GetRenamed/StdLib/Lib/tkinter/__main__.py similarity index 100% rename from Src/StdLib/Lib/tkinter/__main__.py rename to Src.GetRenamed/StdLib/Lib/tkinter/__main__.py diff --git a/Src/StdLib/Lib/tkinter/_fix.py b/Src.GetRenamed/StdLib/Lib/tkinter/_fix.py similarity index 100% rename from Src/StdLib/Lib/tkinter/_fix.py rename to Src.GetRenamed/StdLib/Lib/tkinter/_fix.py diff --git a/Src/StdLib/Lib/tkinter/colorchooser.py b/Src.GetRenamed/StdLib/Lib/tkinter/colorchooser.py similarity index 100% rename from Src/StdLib/Lib/tkinter/colorchooser.py rename to Src.GetRenamed/StdLib/Lib/tkinter/colorchooser.py diff --git a/Src/StdLib/Lib/tkinter/commondialog.py b/Src.GetRenamed/StdLib/Lib/tkinter/commondialog.py similarity index 100% rename from Src/StdLib/Lib/tkinter/commondialog.py rename to Src.GetRenamed/StdLib/Lib/tkinter/commondialog.py diff --git a/Src/StdLib/Lib/tkinter/constants.py b/Src.GetRenamed/StdLib/Lib/tkinter/constants.py similarity index 100% rename from Src/StdLib/Lib/tkinter/constants.py rename to Src.GetRenamed/StdLib/Lib/tkinter/constants.py diff --git a/Src/StdLib/Lib/tkinter/dialog.py b/Src.GetRenamed/StdLib/Lib/tkinter/dialog.py similarity index 100% rename from Src/StdLib/Lib/tkinter/dialog.py rename to Src.GetRenamed/StdLib/Lib/tkinter/dialog.py diff --git a/Src/StdLib/Lib/tkinter/dnd.py b/Src.GetRenamed/StdLib/Lib/tkinter/dnd.py similarity index 100% rename from Src/StdLib/Lib/tkinter/dnd.py rename to Src.GetRenamed/StdLib/Lib/tkinter/dnd.py diff --git a/Src/StdLib/Lib/tkinter/filedialog.py b/Src.GetRenamed/StdLib/Lib/tkinter/filedialog.py similarity index 100% rename from Src/StdLib/Lib/tkinter/filedialog.py rename to Src.GetRenamed/StdLib/Lib/tkinter/filedialog.py diff --git a/Src/StdLib/Lib/tkinter/font.py b/Src.GetRenamed/StdLib/Lib/tkinter/font.py similarity index 100% rename from Src/StdLib/Lib/tkinter/font.py rename to Src.GetRenamed/StdLib/Lib/tkinter/font.py diff --git a/Src/StdLib/Lib/tkinter/messagebox.py b/Src.GetRenamed/StdLib/Lib/tkinter/messagebox.py similarity index 100% rename from Src/StdLib/Lib/tkinter/messagebox.py rename to Src.GetRenamed/StdLib/Lib/tkinter/messagebox.py diff --git a/Src/StdLib/Lib/tkinter/scrolledtext.py b/Src.GetRenamed/StdLib/Lib/tkinter/scrolledtext.py similarity index 100% rename from Src/StdLib/Lib/tkinter/scrolledtext.py rename to Src.GetRenamed/StdLib/Lib/tkinter/scrolledtext.py diff --git a/Src/StdLib/Lib/tkinter/simpledialog.py b/Src.GetRenamed/StdLib/Lib/tkinter/simpledialog.py similarity index 100% rename from Src/StdLib/Lib/tkinter/simpledialog.py rename to Src.GetRenamed/StdLib/Lib/tkinter/simpledialog.py diff --git a/Src/StdLib/Lib/tkinter/test/README b/Src.GetRenamed/StdLib/Lib/tkinter/test/README similarity index 100% rename from Src/StdLib/Lib/tkinter/test/README rename to Src.GetRenamed/StdLib/Lib/tkinter/test/README diff --git a/Src/StdLib/Lib/pydoc_data/__init__.py b/Src.GetRenamed/StdLib/Lib/tkinter/test/__init__.py similarity index 100% rename from Src/StdLib/Lib/pydoc_data/__init__.py rename to Src.GetRenamed/StdLib/Lib/tkinter/test/__init__.py diff --git a/Src/StdLib/Lib/tkinter/test/runtktests.py b/Src.GetRenamed/StdLib/Lib/tkinter/test/runtktests.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/runtktests.py rename to Src.GetRenamed/StdLib/Lib/tkinter/test/runtktests.py diff --git a/Src/StdLib/Lib/tkinter/test/support.py b/Src.GetRenamed/StdLib/Lib/tkinter/test/support.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/support.py rename to Src.GetRenamed/StdLib/Lib/tkinter/test/support.py diff --git a/Src/StdLib/Lib/sqlite3/test/__init__.py b/Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/__init__.py similarity index 100% rename from Src/StdLib/Lib/sqlite3/test/__init__.py rename to Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/__init__.py diff --git a/Src/StdLib/Lib/tkinter/test/test_tkinter/test_font.py b/Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_font.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_tkinter/test_font.py rename to Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_font.py diff --git a/Src/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py b/Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py rename to Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py diff --git a/Src/StdLib/Lib/tkinter/test/test_tkinter/test_images.py b/Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_images.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_tkinter/test_images.py rename to Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_images.py diff --git a/Src/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py b/Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py rename to Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py diff --git a/Src/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py b/Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py rename to Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py diff --git a/Src/StdLib/Lib/tkinter/test/test_tkinter/test_text.py b/Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_text.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_tkinter/test_text.py rename to Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_text.py diff --git a/Src/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py b/Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py rename to Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py diff --git a/Src/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py b/Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py rename to Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py diff --git a/Src/StdLib/Lib/test/leakers/__init__.py b/Src.GetRenamed/StdLib/Lib/tkinter/test/test_ttk/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/leakers/__init__.py rename to Src.GetRenamed/StdLib/Lib/tkinter/test/test_ttk/__init__.py diff --git a/Src/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py b/Src.GetRenamed/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py rename to Src.GetRenamed/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py diff --git a/Src/StdLib/Lib/tkinter/test/test_ttk/test_functions.py b/Src.GetRenamed/StdLib/Lib/tkinter/test/test_ttk/test_functions.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_ttk/test_functions.py rename to Src.GetRenamed/StdLib/Lib/tkinter/test/test_ttk/test_functions.py diff --git a/Src/StdLib/Lib/tkinter/test/test_ttk/test_style.py b/Src.GetRenamed/StdLib/Lib/tkinter/test/test_ttk/test_style.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_ttk/test_style.py rename to Src.GetRenamed/StdLib/Lib/tkinter/test/test_ttk/test_style.py diff --git a/Src/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py b/Src.GetRenamed/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py rename to Src.GetRenamed/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py diff --git a/Src/StdLib/Lib/tkinter/test/widget_tests.py b/Src.GetRenamed/StdLib/Lib/tkinter/test/widget_tests.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/widget_tests.py rename to Src.GetRenamed/StdLib/Lib/tkinter/test/widget_tests.py diff --git a/Src/StdLib/Lib/tkinter/tix.py b/Src.GetRenamed/StdLib/Lib/tkinter/tix.py similarity index 100% rename from Src/StdLib/Lib/tkinter/tix.py rename to Src.GetRenamed/StdLib/Lib/tkinter/tix.py diff --git a/Src/StdLib/Lib/tkinter/ttk.py b/Src.GetRenamed/StdLib/Lib/tkinter/ttk.py similarity index 100% rename from Src/StdLib/Lib/tkinter/ttk.py rename to Src.GetRenamed/StdLib/Lib/tkinter/ttk.py diff --git a/Src/StdLib/Lib/token.py b/Src.GetRenamed/StdLib/Lib/token.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/token.py rename to Src.GetRenamed/StdLib/Lib/token.py diff --git a/Src/StdLib/Lib/tokenize.py b/Src.GetRenamed/StdLib/Lib/tokenize.py similarity index 100% rename from Src/StdLib/Lib/tokenize.py rename to Src.GetRenamed/StdLib/Lib/tokenize.py diff --git a/Src/StdLib/Lib/trace.py b/Src.GetRenamed/StdLib/Lib/trace.py similarity index 100% rename from Src/StdLib/Lib/trace.py rename to Src.GetRenamed/StdLib/Lib/trace.py diff --git a/Src/StdLib/Lib/traceback.py b/Src.GetRenamed/StdLib/Lib/traceback.py similarity index 100% rename from Src/StdLib/Lib/traceback.py rename to Src.GetRenamed/StdLib/Lib/traceback.py diff --git a/Src/StdLib/Lib/tracemalloc.py b/Src.GetRenamed/StdLib/Lib/tracemalloc.py similarity index 100% rename from Src/StdLib/Lib/tracemalloc.py rename to Src.GetRenamed/StdLib/Lib/tracemalloc.py diff --git a/Src/StdLib/Lib/tty.py b/Src.GetRenamed/StdLib/Lib/tty.py similarity index 100% rename from Src/StdLib/Lib/tty.py rename to Src.GetRenamed/StdLib/Lib/tty.py diff --git a/Src/StdLib/Lib/turtle.py b/Src.GetRenamed/StdLib/Lib/turtle.py similarity index 100% rename from Src/StdLib/Lib/turtle.py rename to Src.GetRenamed/StdLib/Lib/turtle.py diff --git a/Src/StdLib/Lib/turtledemo/__init__.py b/Src.GetRenamed/StdLib/Lib/turtledemo/__init__.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/__init__.py rename to Src.GetRenamed/StdLib/Lib/turtledemo/__init__.py diff --git a/Src/StdLib/Lib/turtledemo/__main__.py b/Src.GetRenamed/StdLib/Lib/turtledemo/__main__.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/turtledemo/__main__.py rename to Src.GetRenamed/StdLib/Lib/turtledemo/__main__.py diff --git a/Src/StdLib/Lib/turtledemo/bytedesign.py b/Src.GetRenamed/StdLib/Lib/turtledemo/bytedesign.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/bytedesign.py rename to Src.GetRenamed/StdLib/Lib/turtledemo/bytedesign.py diff --git a/Src/StdLib/Lib/turtledemo/chaos.py b/Src.GetRenamed/StdLib/Lib/turtledemo/chaos.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/chaos.py rename to Src.GetRenamed/StdLib/Lib/turtledemo/chaos.py diff --git a/Src/StdLib/Lib/turtledemo/clock.py b/Src.GetRenamed/StdLib/Lib/turtledemo/clock.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/clock.py rename to Src.GetRenamed/StdLib/Lib/turtledemo/clock.py diff --git a/Src/StdLib/Lib/turtledemo/colormixer.py b/Src.GetRenamed/StdLib/Lib/turtledemo/colormixer.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/colormixer.py rename to Src.GetRenamed/StdLib/Lib/turtledemo/colormixer.py diff --git a/Src/StdLib/Lib/turtledemo/forest.py b/Src.GetRenamed/StdLib/Lib/turtledemo/forest.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/forest.py rename to Src.GetRenamed/StdLib/Lib/turtledemo/forest.py diff --git a/Src/StdLib/Lib/turtledemo/fractalcurves.py b/Src.GetRenamed/StdLib/Lib/turtledemo/fractalcurves.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/fractalcurves.py rename to Src.GetRenamed/StdLib/Lib/turtledemo/fractalcurves.py diff --git a/Src/StdLib/Lib/turtledemo/lindenmayer.py b/Src.GetRenamed/StdLib/Lib/turtledemo/lindenmayer.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/lindenmayer.py rename to Src.GetRenamed/StdLib/Lib/turtledemo/lindenmayer.py diff --git a/Src/StdLib/Lib/turtledemo/minimal_hanoi.py b/Src.GetRenamed/StdLib/Lib/turtledemo/minimal_hanoi.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/minimal_hanoi.py rename to Src.GetRenamed/StdLib/Lib/turtledemo/minimal_hanoi.py diff --git a/Src/StdLib/Lib/turtledemo/nim.py b/Src.GetRenamed/StdLib/Lib/turtledemo/nim.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/nim.py rename to Src.GetRenamed/StdLib/Lib/turtledemo/nim.py diff --git a/Src/StdLib/Lib/turtledemo/paint.py b/Src.GetRenamed/StdLib/Lib/turtledemo/paint.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/paint.py rename to Src.GetRenamed/StdLib/Lib/turtledemo/paint.py diff --git a/Src/StdLib/Lib/turtledemo/peace.py b/Src.GetRenamed/StdLib/Lib/turtledemo/peace.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/peace.py rename to Src.GetRenamed/StdLib/Lib/turtledemo/peace.py diff --git a/Src/StdLib/Lib/turtledemo/penrose.py b/Src.GetRenamed/StdLib/Lib/turtledemo/penrose.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/penrose.py rename to Src.GetRenamed/StdLib/Lib/turtledemo/penrose.py diff --git a/Src/StdLib/Lib/turtledemo/planet_and_moon.py b/Src.GetRenamed/StdLib/Lib/turtledemo/planet_and_moon.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/planet_and_moon.py rename to Src.GetRenamed/StdLib/Lib/turtledemo/planet_and_moon.py diff --git a/Src/StdLib/Lib/turtledemo/round_dance.py b/Src.GetRenamed/StdLib/Lib/turtledemo/round_dance.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/round_dance.py rename to Src.GetRenamed/StdLib/Lib/turtledemo/round_dance.py diff --git a/Src/StdLib/Lib/turtledemo/tree.py b/Src.GetRenamed/StdLib/Lib/turtledemo/tree.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/tree.py rename to Src.GetRenamed/StdLib/Lib/turtledemo/tree.py diff --git a/Src/StdLib/Lib/turtledemo/turtle.cfg b/Src.GetRenamed/StdLib/Lib/turtledemo/turtle.cfg similarity index 100% rename from Src/StdLib/Lib/turtledemo/turtle.cfg rename to Src.GetRenamed/StdLib/Lib/turtledemo/turtle.cfg diff --git a/Src/StdLib/Lib/turtledemo/two_canvases.py b/Src.GetRenamed/StdLib/Lib/turtledemo/two_canvases.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/two_canvases.py rename to Src.GetRenamed/StdLib/Lib/turtledemo/two_canvases.py diff --git a/Src/StdLib/Lib/turtledemo/wikipedia.py b/Src.GetRenamed/StdLib/Lib/turtledemo/wikipedia.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/wikipedia.py rename to Src.GetRenamed/StdLib/Lib/turtledemo/wikipedia.py diff --git a/Src/StdLib/Lib/turtledemo/yinyang.py b/Src.GetRenamed/StdLib/Lib/turtledemo/yinyang.py similarity index 100% rename from Src/StdLib/Lib/turtledemo/yinyang.py rename to Src.GetRenamed/StdLib/Lib/turtledemo/yinyang.py diff --git a/Src/StdLib/Lib/types.py b/Src.GetRenamed/StdLib/Lib/types.py similarity index 100% rename from Src/StdLib/Lib/types.py rename to Src.GetRenamed/StdLib/Lib/types.py diff --git a/Src/StdLib/Lib/typing.py b/Src.GetRenamed/StdLib/Lib/typing.py similarity index 100% rename from Src/StdLib/Lib/typing.py rename to Src.GetRenamed/StdLib/Lib/typing.py diff --git a/Src/StdLib/Lib/unittest/__init__.py b/Src.GetRenamed/StdLib/Lib/unittest/__init__.py similarity index 100% rename from Src/StdLib/Lib/unittest/__init__.py rename to Src.GetRenamed/StdLib/Lib/unittest/__init__.py diff --git a/Src/StdLib/Lib/unittest/__main__.py b/Src.GetRenamed/StdLib/Lib/unittest/__main__.py similarity index 100% rename from Src/StdLib/Lib/unittest/__main__.py rename to Src.GetRenamed/StdLib/Lib/unittest/__main__.py diff --git a/Src/StdLib/Lib/unittest/case.py b/Src.GetRenamed/StdLib/Lib/unittest/case.py similarity index 100% rename from Src/StdLib/Lib/unittest/case.py rename to Src.GetRenamed/StdLib/Lib/unittest/case.py diff --git a/Src/StdLib/Lib/unittest/loader.py b/Src.GetRenamed/StdLib/Lib/unittest/loader.py similarity index 100% rename from Src/StdLib/Lib/unittest/loader.py rename to Src.GetRenamed/StdLib/Lib/unittest/loader.py diff --git a/Src/StdLib/Lib/unittest/main.py b/Src.GetRenamed/StdLib/Lib/unittest/main.py similarity index 100% rename from Src/StdLib/Lib/unittest/main.py rename to Src.GetRenamed/StdLib/Lib/unittest/main.py diff --git a/Src/StdLib/Lib/unittest/mock.py b/Src.GetRenamed/StdLib/Lib/unittest/mock.py similarity index 100% rename from Src/StdLib/Lib/unittest/mock.py rename to Src.GetRenamed/StdLib/Lib/unittest/mock.py diff --git a/Src/StdLib/Lib/unittest/result.py b/Src.GetRenamed/StdLib/Lib/unittest/result.py similarity index 100% rename from Src/StdLib/Lib/unittest/result.py rename to Src.GetRenamed/StdLib/Lib/unittest/result.py diff --git a/Src/StdLib/Lib/unittest/runner.py b/Src.GetRenamed/StdLib/Lib/unittest/runner.py similarity index 100% rename from Src/StdLib/Lib/unittest/runner.py rename to Src.GetRenamed/StdLib/Lib/unittest/runner.py diff --git a/Src/StdLib/Lib/unittest/signals.py b/Src.GetRenamed/StdLib/Lib/unittest/signals.py similarity index 100% rename from Src/StdLib/Lib/unittest/signals.py rename to Src.GetRenamed/StdLib/Lib/unittest/signals.py diff --git a/Src/StdLib/Lib/unittest/suite.py b/Src.GetRenamed/StdLib/Lib/unittest/suite.py similarity index 100% rename from Src/StdLib/Lib/unittest/suite.py rename to Src.GetRenamed/StdLib/Lib/unittest/suite.py diff --git a/Src/StdLib/Lib/unittest/test/__init__.py b/Src.GetRenamed/StdLib/Lib/unittest/test/__init__.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/__init__.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/__init__.py diff --git a/Src/StdLib/Lib/unittest/test/__main__.py b/Src.GetRenamed/StdLib/Lib/unittest/test/__main__.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/__main__.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/__main__.py diff --git a/Src/StdLib/Lib/unittest/test/_test_warnings.py b/Src.GetRenamed/StdLib/Lib/unittest/test/_test_warnings.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/_test_warnings.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/_test_warnings.py diff --git a/Src/StdLib/Lib/unittest/test/dummy.py b/Src.GetRenamed/StdLib/Lib/unittest/test/dummy.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/dummy.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/dummy.py diff --git a/Src/StdLib/Lib/unittest/test/support.py b/Src.GetRenamed/StdLib/Lib/unittest/test/support.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/support.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/support.py diff --git a/Src/StdLib/Lib/unittest/test/test_assertions.py b/Src.GetRenamed/StdLib/Lib/unittest/test/test_assertions.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_assertions.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/test_assertions.py diff --git a/Src/StdLib/Lib/unittest/test/test_break.py b/Src.GetRenamed/StdLib/Lib/unittest/test/test_break.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_break.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/test_break.py diff --git a/Src/StdLib/Lib/unittest/test/test_case.py b/Src.GetRenamed/StdLib/Lib/unittest/test/test_case.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_case.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/test_case.py diff --git a/Src/StdLib/Lib/unittest/test/test_discovery.py b/Src.GetRenamed/StdLib/Lib/unittest/test/test_discovery.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_discovery.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/test_discovery.py diff --git a/Src/StdLib/Lib/unittest/test/test_functiontestcase.py b/Src.GetRenamed/StdLib/Lib/unittest/test/test_functiontestcase.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_functiontestcase.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/test_functiontestcase.py diff --git a/Src/StdLib/Lib/unittest/test/test_loader.py b/Src.GetRenamed/StdLib/Lib/unittest/test/test_loader.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_loader.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/test_loader.py diff --git a/Src/StdLib/Lib/unittest/test/test_program.py b/Src.GetRenamed/StdLib/Lib/unittest/test/test_program.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_program.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/test_program.py diff --git a/Src/StdLib/Lib/unittest/test/test_result.py b/Src.GetRenamed/StdLib/Lib/unittest/test/test_result.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_result.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/test_result.py diff --git a/Src/StdLib/Lib/unittest/test/test_runner.py b/Src.GetRenamed/StdLib/Lib/unittest/test/test_runner.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_runner.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/test_runner.py diff --git a/Src/StdLib/Lib/unittest/test/test_setups.py b/Src.GetRenamed/StdLib/Lib/unittest/test/test_setups.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_setups.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/test_setups.py diff --git a/Src/StdLib/Lib/unittest/test/test_skipping.py b/Src.GetRenamed/StdLib/Lib/unittest/test/test_skipping.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_skipping.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/test_skipping.py diff --git a/Src/StdLib/Lib/unittest/test/test_suite.py b/Src.GetRenamed/StdLib/Lib/unittest/test/test_suite.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/test_suite.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/test_suite.py diff --git a/Src/StdLib/Lib/unittest/test/testmock/__init__.py b/Src.GetRenamed/StdLib/Lib/unittest/test/testmock/__init__.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/testmock/__init__.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/testmock/__init__.py diff --git a/Src/StdLib/Lib/unittest/test/testmock/__main__.py b/Src.GetRenamed/StdLib/Lib/unittest/test/testmock/__main__.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/testmock/__main__.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/testmock/__main__.py diff --git a/Src/StdLib/Lib/unittest/test/testmock/support.py b/Src.GetRenamed/StdLib/Lib/unittest/test/testmock/support.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/testmock/support.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/testmock/support.py diff --git a/Src/StdLib/Lib/unittest/test/testmock/testcallable.py b/Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testcallable.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/testmock/testcallable.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testcallable.py diff --git a/Src/StdLib/Lib/unittest/test/testmock/testhelpers.py b/Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testhelpers.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/testmock/testhelpers.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testhelpers.py diff --git a/Src/StdLib/Lib/unittest/test/testmock/testmagicmethods.py b/Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testmagicmethods.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/testmock/testmagicmethods.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testmagicmethods.py diff --git a/Src/StdLib/Lib/unittest/test/testmock/testmock.py b/Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testmock.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/testmock/testmock.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testmock.py diff --git a/Src/StdLib/Lib/unittest/test/testmock/testpatch.py b/Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testpatch.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/testmock/testpatch.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testpatch.py diff --git a/Src/StdLib/Lib/unittest/test/testmock/testsentinel.py b/Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testsentinel.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/testmock/testsentinel.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testsentinel.py diff --git a/Src/StdLib/Lib/unittest/test/testmock/testwith.py b/Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testwith.py similarity index 100% rename from Src/StdLib/Lib/unittest/test/testmock/testwith.py rename to Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testwith.py diff --git a/Src/StdLib/Lib/unittest/util.py b/Src.GetRenamed/StdLib/Lib/unittest/util.py similarity index 100% rename from Src/StdLib/Lib/unittest/util.py rename to Src.GetRenamed/StdLib/Lib/unittest/util.py diff --git a/Src/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py b/Src.GetRenamed/StdLib/Lib/urllib/__init__.py similarity index 100% rename from Src/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py rename to Src.GetRenamed/StdLib/Lib/urllib/__init__.py diff --git a/Src/StdLib/Lib/urllib/error.py b/Src.GetRenamed/StdLib/Lib/urllib/error.py similarity index 100% rename from Src/StdLib/Lib/urllib/error.py rename to Src.GetRenamed/StdLib/Lib/urllib/error.py diff --git a/Src/StdLib/Lib/urllib/parse.py b/Src.GetRenamed/StdLib/Lib/urllib/parse.py similarity index 100% rename from Src/StdLib/Lib/urllib/parse.py rename to Src.GetRenamed/StdLib/Lib/urllib/parse.py diff --git a/Src/StdLib/Lib/urllib/request.py b/Src.GetRenamed/StdLib/Lib/urllib/request.py similarity index 100% rename from Src/StdLib/Lib/urllib/request.py rename to Src.GetRenamed/StdLib/Lib/urllib/request.py diff --git a/Src/StdLib/Lib/urllib/response.py b/Src.GetRenamed/StdLib/Lib/urllib/response.py similarity index 100% rename from Src/StdLib/Lib/urllib/response.py rename to Src.GetRenamed/StdLib/Lib/urllib/response.py diff --git a/Src/StdLib/Lib/urllib/robotparser.py b/Src.GetRenamed/StdLib/Lib/urllib/robotparser.py similarity index 100% rename from Src/StdLib/Lib/urllib/robotparser.py rename to Src.GetRenamed/StdLib/Lib/urllib/robotparser.py diff --git a/Src/StdLib/Lib/uu.py b/Src.GetRenamed/StdLib/Lib/uu.py old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/Lib/uu.py rename to Src.GetRenamed/StdLib/Lib/uu.py diff --git a/Src/StdLib/Lib/uuid.py b/Src.GetRenamed/StdLib/Lib/uuid.py similarity index 100% rename from Src/StdLib/Lib/uuid.py rename to Src.GetRenamed/StdLib/Lib/uuid.py diff --git a/Src/StdLib/Lib/venv/__init__.py b/Src.GetRenamed/StdLib/Lib/venv/__init__.py similarity index 100% rename from Src/StdLib/Lib/venv/__init__.py rename to Src.GetRenamed/StdLib/Lib/venv/__init__.py diff --git a/Src/StdLib/Lib/venv/__main__.py b/Src.GetRenamed/StdLib/Lib/venv/__main__.py similarity index 100% rename from Src/StdLib/Lib/venv/__main__.py rename to Src.GetRenamed/StdLib/Lib/venv/__main__.py diff --git a/Src/StdLib/Lib/venv/scripts/nt/Activate.ps1 b/Src.GetRenamed/StdLib/Lib/venv/scripts/nt/Activate.ps1 similarity index 100% rename from Src/StdLib/Lib/venv/scripts/nt/Activate.ps1 rename to Src.GetRenamed/StdLib/Lib/venv/scripts/nt/Activate.ps1 diff --git a/Src/StdLib/Lib/venv/scripts/nt/activate.bat b/Src.GetRenamed/StdLib/Lib/venv/scripts/nt/activate.bat similarity index 100% rename from Src/StdLib/Lib/venv/scripts/nt/activate.bat rename to Src.GetRenamed/StdLib/Lib/venv/scripts/nt/activate.bat diff --git a/Src/StdLib/Lib/venv/scripts/nt/deactivate.bat b/Src.GetRenamed/StdLib/Lib/venv/scripts/nt/deactivate.bat similarity index 100% rename from Src/StdLib/Lib/venv/scripts/nt/deactivate.bat rename to Src.GetRenamed/StdLib/Lib/venv/scripts/nt/deactivate.bat diff --git a/Src/StdLib/Lib/venv/scripts/posix/activate b/Src.GetRenamed/StdLib/Lib/venv/scripts/posix/activate similarity index 100% rename from Src/StdLib/Lib/venv/scripts/posix/activate rename to Src.GetRenamed/StdLib/Lib/venv/scripts/posix/activate diff --git a/Src/StdLib/Lib/venv/scripts/posix/activate.csh b/Src.GetRenamed/StdLib/Lib/venv/scripts/posix/activate.csh similarity index 100% rename from Src/StdLib/Lib/venv/scripts/posix/activate.csh rename to Src.GetRenamed/StdLib/Lib/venv/scripts/posix/activate.csh diff --git a/Src/StdLib/Lib/venv/scripts/posix/activate.fish b/Src.GetRenamed/StdLib/Lib/venv/scripts/posix/activate.fish similarity index 100% rename from Src/StdLib/Lib/venv/scripts/posix/activate.fish rename to Src.GetRenamed/StdLib/Lib/venv/scripts/posix/activate.fish diff --git a/Src/StdLib/Lib/warnings.py b/Src.GetRenamed/StdLib/Lib/warnings.py similarity index 100% rename from Src/StdLib/Lib/warnings.py rename to Src.GetRenamed/StdLib/Lib/warnings.py diff --git a/Src/StdLib/Lib/wave.py b/Src.GetRenamed/StdLib/Lib/wave.py similarity index 100% rename from Src/StdLib/Lib/wave.py rename to Src.GetRenamed/StdLib/Lib/wave.py diff --git a/Src/StdLib/Lib/weakref.py b/Src.GetRenamed/StdLib/Lib/weakref.py similarity index 100% rename from Src/StdLib/Lib/weakref.py rename to Src.GetRenamed/StdLib/Lib/weakref.py diff --git a/Src/StdLib/Lib/webbrowser.py b/Src.GetRenamed/StdLib/Lib/webbrowser.py similarity index 100% rename from Src/StdLib/Lib/webbrowser.py rename to Src.GetRenamed/StdLib/Lib/webbrowser.py diff --git a/Src/StdLib/Lib/wpf.py b/Src.GetRenamed/StdLib/Lib/wpf.py similarity index 100% rename from Src/StdLib/Lib/wpf.py rename to Src.GetRenamed/StdLib/Lib/wpf.py diff --git a/Src/StdLib/Lib/wsgiref/__init__.py b/Src.GetRenamed/StdLib/Lib/wsgiref/__init__.py similarity index 100% rename from Src/StdLib/Lib/wsgiref/__init__.py rename to Src.GetRenamed/StdLib/Lib/wsgiref/__init__.py diff --git a/Src/StdLib/Lib/wsgiref/handlers.py b/Src.GetRenamed/StdLib/Lib/wsgiref/handlers.py similarity index 100% rename from Src/StdLib/Lib/wsgiref/handlers.py rename to Src.GetRenamed/StdLib/Lib/wsgiref/handlers.py diff --git a/Src/StdLib/Lib/wsgiref/headers.py b/Src.GetRenamed/StdLib/Lib/wsgiref/headers.py similarity index 100% rename from Src/StdLib/Lib/wsgiref/headers.py rename to Src.GetRenamed/StdLib/Lib/wsgiref/headers.py diff --git a/Src/StdLib/Lib/wsgiref/simple_server.py b/Src.GetRenamed/StdLib/Lib/wsgiref/simple_server.py similarity index 100% rename from Src/StdLib/Lib/wsgiref/simple_server.py rename to Src.GetRenamed/StdLib/Lib/wsgiref/simple_server.py diff --git a/Src/StdLib/Lib/wsgiref/util.py b/Src.GetRenamed/StdLib/Lib/wsgiref/util.py similarity index 100% rename from Src/StdLib/Lib/wsgiref/util.py rename to Src.GetRenamed/StdLib/Lib/wsgiref/util.py diff --git a/Src/StdLib/Lib/wsgiref/validate.py b/Src.GetRenamed/StdLib/Lib/wsgiref/validate.py similarity index 100% rename from Src/StdLib/Lib/wsgiref/validate.py rename to Src.GetRenamed/StdLib/Lib/wsgiref/validate.py diff --git a/Src/StdLib/Lib/xdrlib.py b/Src.GetRenamed/StdLib/Lib/xdrlib.py similarity index 100% rename from Src/StdLib/Lib/xdrlib.py rename to Src.GetRenamed/StdLib/Lib/xdrlib.py diff --git a/Src/StdLib/Lib/xml/__init__.py b/Src.GetRenamed/StdLib/Lib/xml/__init__.py similarity index 100% rename from Src/StdLib/Lib/xml/__init__.py rename to Src.GetRenamed/StdLib/Lib/xml/__init__.py diff --git a/Src/StdLib/Lib/xml/dom/NodeFilter.py b/Src.GetRenamed/StdLib/Lib/xml/dom/NodeFilter.py similarity index 100% rename from Src/StdLib/Lib/xml/dom/NodeFilter.py rename to Src.GetRenamed/StdLib/Lib/xml/dom/NodeFilter.py diff --git a/Src/StdLib/Lib/xml/dom/__init__.py b/Src.GetRenamed/StdLib/Lib/xml/dom/__init__.py similarity index 100% rename from Src/StdLib/Lib/xml/dom/__init__.py rename to Src.GetRenamed/StdLib/Lib/xml/dom/__init__.py diff --git a/Src/StdLib/Lib/xml/dom/domreg.py b/Src.GetRenamed/StdLib/Lib/xml/dom/domreg.py similarity index 100% rename from Src/StdLib/Lib/xml/dom/domreg.py rename to Src.GetRenamed/StdLib/Lib/xml/dom/domreg.py diff --git a/Src/StdLib/Lib/xml/dom/expatbuilder.py b/Src.GetRenamed/StdLib/Lib/xml/dom/expatbuilder.py similarity index 100% rename from Src/StdLib/Lib/xml/dom/expatbuilder.py rename to Src.GetRenamed/StdLib/Lib/xml/dom/expatbuilder.py diff --git a/Src/StdLib/Lib/xml/dom/minicompat.py b/Src.GetRenamed/StdLib/Lib/xml/dom/minicompat.py similarity index 100% rename from Src/StdLib/Lib/xml/dom/minicompat.py rename to Src.GetRenamed/StdLib/Lib/xml/dom/minicompat.py diff --git a/Src/StdLib/Lib/xml/dom/minidom.py b/Src.GetRenamed/StdLib/Lib/xml/dom/minidom.py similarity index 100% rename from Src/StdLib/Lib/xml/dom/minidom.py rename to Src.GetRenamed/StdLib/Lib/xml/dom/minidom.py diff --git a/Src/StdLib/Lib/xml/dom/pulldom.py b/Src.GetRenamed/StdLib/Lib/xml/dom/pulldom.py similarity index 100% rename from Src/StdLib/Lib/xml/dom/pulldom.py rename to Src.GetRenamed/StdLib/Lib/xml/dom/pulldom.py diff --git a/Src/StdLib/Lib/xml/dom/xmlbuilder.py b/Src.GetRenamed/StdLib/Lib/xml/dom/xmlbuilder.py similarity index 100% rename from Src/StdLib/Lib/xml/dom/xmlbuilder.py rename to Src.GetRenamed/StdLib/Lib/xml/dom/xmlbuilder.py diff --git a/Src/StdLib/Lib/xml/etree/ElementInclude.py b/Src.GetRenamed/StdLib/Lib/xml/etree/ElementInclude.py similarity index 100% rename from Src/StdLib/Lib/xml/etree/ElementInclude.py rename to Src.GetRenamed/StdLib/Lib/xml/etree/ElementInclude.py diff --git a/Src/StdLib/Lib/xml/etree/ElementPath.py b/Src.GetRenamed/StdLib/Lib/xml/etree/ElementPath.py similarity index 100% rename from Src/StdLib/Lib/xml/etree/ElementPath.py rename to Src.GetRenamed/StdLib/Lib/xml/etree/ElementPath.py diff --git a/Src/StdLib/Lib/xml/etree/ElementTree.py b/Src.GetRenamed/StdLib/Lib/xml/etree/ElementTree.py similarity index 100% rename from Src/StdLib/Lib/xml/etree/ElementTree.py rename to Src.GetRenamed/StdLib/Lib/xml/etree/ElementTree.py diff --git a/Src/StdLib/Lib/xml/etree/__init__.py b/Src.GetRenamed/StdLib/Lib/xml/etree/__init__.py similarity index 100% rename from Src/StdLib/Lib/xml/etree/__init__.py rename to Src.GetRenamed/StdLib/Lib/xml/etree/__init__.py diff --git a/Src/StdLib/Lib/xml/etree/cElementTree.py b/Src.GetRenamed/StdLib/Lib/xml/etree/cElementTree.py similarity index 100% rename from Src/StdLib/Lib/xml/etree/cElementTree.py rename to Src.GetRenamed/StdLib/Lib/xml/etree/cElementTree.py diff --git a/Src/StdLib/Lib/xml/parsers/__init__.py b/Src.GetRenamed/StdLib/Lib/xml/parsers/__init__.py similarity index 100% rename from Src/StdLib/Lib/xml/parsers/__init__.py rename to Src.GetRenamed/StdLib/Lib/xml/parsers/__init__.py diff --git a/Src/StdLib/Lib/xml/parsers/expat.py b/Src.GetRenamed/StdLib/Lib/xml/parsers/expat.py similarity index 100% rename from Src/StdLib/Lib/xml/parsers/expat.py rename to Src.GetRenamed/StdLib/Lib/xml/parsers/expat.py diff --git a/Src/StdLib/Lib/xml/sax/__init__.py b/Src.GetRenamed/StdLib/Lib/xml/sax/__init__.py similarity index 100% rename from Src/StdLib/Lib/xml/sax/__init__.py rename to Src.GetRenamed/StdLib/Lib/xml/sax/__init__.py diff --git a/Src/StdLib/Lib/xml/sax/_exceptions.py b/Src.GetRenamed/StdLib/Lib/xml/sax/_exceptions.py similarity index 100% rename from Src/StdLib/Lib/xml/sax/_exceptions.py rename to Src.GetRenamed/StdLib/Lib/xml/sax/_exceptions.py diff --git a/Src/StdLib/Lib/xml/sax/expatreader.py b/Src.GetRenamed/StdLib/Lib/xml/sax/expatreader.py similarity index 100% rename from Src/StdLib/Lib/xml/sax/expatreader.py rename to Src.GetRenamed/StdLib/Lib/xml/sax/expatreader.py diff --git a/Src/StdLib/Lib/xml/sax/handler.py b/Src.GetRenamed/StdLib/Lib/xml/sax/handler.py similarity index 100% rename from Src/StdLib/Lib/xml/sax/handler.py rename to Src.GetRenamed/StdLib/Lib/xml/sax/handler.py diff --git a/Src/StdLib/Lib/xml/sax/saxutils.py b/Src.GetRenamed/StdLib/Lib/xml/sax/saxutils.py similarity index 100% rename from Src/StdLib/Lib/xml/sax/saxutils.py rename to Src.GetRenamed/StdLib/Lib/xml/sax/saxutils.py diff --git a/Src/StdLib/Lib/xml/sax/xmlreader.py b/Src.GetRenamed/StdLib/Lib/xml/sax/xmlreader.py similarity index 100% rename from Src/StdLib/Lib/xml/sax/xmlreader.py rename to Src.GetRenamed/StdLib/Lib/xml/sax/xmlreader.py diff --git a/Src/StdLib/Lib/xmlrpc/__init__.py b/Src.GetRenamed/StdLib/Lib/xmlrpc/__init__.py similarity index 100% rename from Src/StdLib/Lib/xmlrpc/__init__.py rename to Src.GetRenamed/StdLib/Lib/xmlrpc/__init__.py diff --git a/Src/StdLib/Lib/xmlrpc/client.py b/Src.GetRenamed/StdLib/Lib/xmlrpc/client.py similarity index 100% rename from Src/StdLib/Lib/xmlrpc/client.py rename to Src.GetRenamed/StdLib/Lib/xmlrpc/client.py diff --git a/Src/StdLib/Lib/xmlrpc/server.py b/Src.GetRenamed/StdLib/Lib/xmlrpc/server.py similarity index 100% rename from Src/StdLib/Lib/xmlrpc/server.py rename to Src.GetRenamed/StdLib/Lib/xmlrpc/server.py diff --git a/Src/StdLib/Lib/zipfile.py b/Src.GetRenamed/StdLib/Lib/zipfile.py similarity index 100% rename from Src/StdLib/Lib/zipfile.py rename to Src.GetRenamed/StdLib/Lib/zipfile.py diff --git a/Src/StdLib/StdLib.License.txt b/Src.GetRenamed/StdLib/StdLib.License.txt similarity index 100% rename from Src/StdLib/StdLib.License.txt rename to Src.GetRenamed/StdLib/StdLib.License.txt diff --git a/Src/StdLib/StdLib.pyproj b/Src.GetRenamed/StdLib/StdLib.pyproj similarity index 100% rename from Src/StdLib/StdLib.pyproj rename to Src.GetRenamed/StdLib/StdLib.pyproj diff --git a/Src/StdLib/stdlib-upgrade.txt b/Src.GetRenamed/StdLib/stdlib-upgrade.txt similarity index 100% rename from Src/StdLib/stdlib-upgrade.txt rename to Src.GetRenamed/StdLib/stdlib-upgrade.txt diff --git a/Src/StdLib/update-stdlib.cmd b/Src.GetRenamed/StdLib/update-stdlib.cmd similarity index 100% rename from Src/StdLib/update-stdlib.cmd rename to Src.GetRenamed/StdLib/update-stdlib.cmd diff --git a/Src/StdLib/update-stdlib.sh b/Src.GetRenamed/StdLib/update-stdlib.sh old mode 100755 new mode 100644 similarity index 100% rename from Src/StdLib/update-stdlib.sh rename to Src.GetRenamed/StdLib/update-stdlib.sh diff --git a/Src/Tests/AssemblyInfo.cs b/Src.GetRenamed/Tests/AssemblyInfo.cs similarity index 100% rename from Src/Tests/AssemblyInfo.cs rename to Src.GetRenamed/Tests/AssemblyInfo.cs diff --git a/Src/Tests/AttrInjectorTest.cs b/Src.GetRenamed/Tests/AttrInjectorTest.cs similarity index 100% rename from Src/Tests/AttrInjectorTest.cs rename to Src.GetRenamed/Tests/AttrInjectorTest.cs diff --git a/Src/Tests/BindTest.cs b/Src.GetRenamed/Tests/BindTest.cs similarity index 100% rename from Src/Tests/BindTest.cs rename to Src.GetRenamed/Tests/BindTest.cs diff --git a/Src/Tests/BinderTest.cs b/Src.GetRenamed/Tests/BinderTest.cs similarity index 100% rename from Src/Tests/BinderTest.cs rename to Src.GetRenamed/Tests/BinderTest.cs diff --git a/Src/Tests/Cases/CPythonCases.cs b/Src.GetRenamed/Tests/Cases/CPythonCases.cs similarity index 100% rename from Src/Tests/Cases/CPythonCases.cs rename to Src.GetRenamed/Tests/Cases/CPythonCases.cs diff --git a/Src/Tests/Cases/CPythonCasesManifest.ini b/Src.GetRenamed/Tests/Cases/CPythonCasesManifest.ini similarity index 100% rename from Src/Tests/Cases/CPythonCasesManifest.ini rename to Src.GetRenamed/Tests/Cases/CPythonCasesManifest.ini diff --git a/Src/Tests/Cases/CaseExecuter.cs b/Src.GetRenamed/Tests/Cases/CaseExecuter.cs similarity index 100% rename from Src/Tests/Cases/CaseExecuter.cs rename to Src.GetRenamed/Tests/Cases/CaseExecuter.cs diff --git a/Src/Tests/Cases/CaseGenerator.cs b/Src.GetRenamed/Tests/Cases/CaseGenerator.cs similarity index 100% rename from Src/Tests/Cases/CaseGenerator.cs rename to Src.GetRenamed/Tests/Cases/CaseGenerator.cs diff --git a/Src/Tests/Cases/CommonCases.cs b/Src.GetRenamed/Tests/Cases/CommonCases.cs similarity index 100% rename from Src/Tests/Cases/CommonCases.cs rename to Src.GetRenamed/Tests/Cases/CommonCases.cs diff --git a/Src/Tests/Cases/IronPythonCases.cs b/Src.GetRenamed/Tests/Cases/IronPythonCases.cs similarity index 100% rename from Src/Tests/Cases/IronPythonCases.cs rename to Src.GetRenamed/Tests/Cases/IronPythonCases.cs diff --git a/Src/Tests/Cases/IronPythonCasesManifest.ini b/Src.GetRenamed/Tests/Cases/IronPythonCasesManifest.ini similarity index 100% rename from Src/Tests/Cases/IronPythonCasesManifest.ini rename to Src.GetRenamed/Tests/Cases/IronPythonCasesManifest.ini diff --git a/Src/Tests/ClrType.cs b/Src.GetRenamed/Tests/ClrType.cs similarity index 100% rename from Src/Tests/ClrType.cs rename to Src.GetRenamed/Tests/ClrType.cs diff --git a/Src/Tests/Cmplx.cs b/Src.GetRenamed/Tests/Cmplx.cs similarity index 100% rename from Src/Tests/Cmplx.cs rename to Src.GetRenamed/Tests/Cmplx.cs diff --git a/Src/Tests/Conversions.cs b/Src.GetRenamed/Tests/Conversions.cs similarity index 100% rename from Src/Tests/Conversions.cs rename to Src.GetRenamed/Tests/Conversions.cs diff --git a/Src/Tests/DeTest.cs b/Src.GetRenamed/Tests/DeTest.cs similarity index 100% rename from Src/Tests/DeTest.cs rename to Src.GetRenamed/Tests/DeTest.cs diff --git a/Src/Tests/DelegateTest.cs b/Src.GetRenamed/Tests/DelegateTest.cs similarity index 100% rename from Src/Tests/DelegateTest.cs rename to Src.GetRenamed/Tests/DelegateTest.cs diff --git a/Src/Tests/DynamicRegressions.cs b/Src.GetRenamed/Tests/DynamicRegressions.cs similarity index 100% rename from Src/Tests/DynamicRegressions.cs rename to Src.GetRenamed/Tests/DynamicRegressions.cs diff --git a/Src/Tests/EncodingTest.cs b/Src.GetRenamed/Tests/EncodingTest.cs similarity index 100% rename from Src/Tests/EncodingTest.cs rename to Src.GetRenamed/Tests/EncodingTest.cs diff --git a/Src/Tests/EngineTest.cs b/Src.GetRenamed/Tests/EngineTest.cs similarity index 100% rename from Src/Tests/EngineTest.cs rename to Src.GetRenamed/Tests/EngineTest.cs diff --git a/Src/Tests/Enums.cs b/Src.GetRenamed/Tests/Enums.cs similarity index 100% rename from Src/Tests/Enums.cs rename to Src.GetRenamed/Tests/Enums.cs diff --git a/Src/Tests/Events.cs b/Src.GetRenamed/Tests/Events.cs similarity index 100% rename from Src/Tests/Events.cs rename to Src.GetRenamed/Tests/Events.cs diff --git a/Src/Tests/ExceptionConverter.cs b/Src.GetRenamed/Tests/ExceptionConverter.cs similarity index 100% rename from Src/Tests/ExceptionConverter.cs rename to Src.GetRenamed/Tests/ExceptionConverter.cs diff --git a/Src/Tests/Exceptions.cs b/Src.GetRenamed/Tests/Exceptions.cs similarity index 100% rename from Src/Tests/Exceptions.cs rename to Src.GetRenamed/Tests/Exceptions.cs diff --git a/Src/Tests/Explicit.cs b/Src.GetRenamed/Tests/Explicit.cs similarity index 100% rename from Src/Tests/Explicit.cs rename to Src.GetRenamed/Tests/Explicit.cs diff --git a/Src/Tests/ExtensionMethodTest.cs b/Src.GetRenamed/Tests/ExtensionMethodTest.cs similarity index 100% rename from Src/Tests/ExtensionMethodTest.cs rename to Src.GetRenamed/Tests/ExtensionMethodTest.cs diff --git a/Src/Tests/GenMeth.cs b/Src.GetRenamed/Tests/GenMeth.cs similarity index 100% rename from Src/Tests/GenMeth.cs rename to Src.GetRenamed/Tests/GenMeth.cs diff --git a/Src/Tests/Indexable.cs b/Src.GetRenamed/Tests/Indexable.cs similarity index 100% rename from Src/Tests/Indexable.cs rename to Src.GetRenamed/Tests/Indexable.cs diff --git a/Src/Tests/InheritTest.cs b/Src.GetRenamed/Tests/InheritTest.cs similarity index 100% rename from Src/Tests/InheritTest.cs rename to Src.GetRenamed/Tests/InheritTest.cs diff --git a/Src/Tests/IntegerTest.cs b/Src.GetRenamed/Tests/IntegerTest.cs similarity index 100% rename from Src/Tests/IntegerTest.cs rename to Src.GetRenamed/Tests/IntegerTest.cs diff --git a/Src/Tests/IronMath.cs b/Src.GetRenamed/Tests/IronMath.cs similarity index 100% rename from Src/Tests/IronMath.cs rename to Src.GetRenamed/Tests/IronMath.cs diff --git a/Src/Tests/IronPython.Tests.csproj b/Src.GetRenamed/Tests/IronPython.Tests.csproj similarity index 100% rename from Src/Tests/IronPython.Tests.csproj rename to Src.GetRenamed/Tests/IronPython.Tests.csproj diff --git a/Src/Tests/LoadTest.cs b/Src.GetRenamed/Tests/LoadTest.cs similarity index 100% rename from Src/Tests/LoadTest.cs rename to Src.GetRenamed/Tests/LoadTest.cs diff --git a/Src/Tests/MemberMappingTests.cs b/Src.GetRenamed/Tests/MemberMappingTests.cs similarity index 100% rename from Src/Tests/MemberMappingTests.cs rename to Src.GetRenamed/Tests/MemberMappingTests.cs diff --git a/Src/Tests/MemberOverloadTest.cs b/Src.GetRenamed/Tests/MemberOverloadTest.cs similarity index 100% rename from Src/Tests/MemberOverloadTest.cs rename to Src.GetRenamed/Tests/MemberOverloadTest.cs diff --git a/Src/Tests/MethodParametersStubs.cs b/Src.GetRenamed/Tests/MethodParametersStubs.cs similarity index 100% rename from Src/Tests/MethodParametersStubs.cs rename to Src.GetRenamed/Tests/MethodParametersStubs.cs diff --git a/Src/Tests/NestedClass.cs b/Src.GetRenamed/Tests/NestedClass.cs similarity index 100% rename from Src/Tests/NestedClass.cs rename to Src.GetRenamed/Tests/NestedClass.cs diff --git a/Src/Tests/NullableTest.cs b/Src.GetRenamed/Tests/NullableTest.cs similarity index 100% rename from Src/Tests/NullableTest.cs rename to Src.GetRenamed/Tests/NullableTest.cs diff --git a/Src/Tests/OperatorTest.cs b/Src.GetRenamed/Tests/OperatorTest.cs similarity index 100% rename from Src/Tests/OperatorTest.cs rename to Src.GetRenamed/Tests/OperatorTest.cs diff --git a/Src/Tests/ProtocolTest.cs b/Src.GetRenamed/Tests/ProtocolTest.cs similarity index 100% rename from Src/Tests/ProtocolTest.cs rename to Src.GetRenamed/Tests/ProtocolTest.cs diff --git a/Src/Tests/StaticTest.cs b/Src.GetRenamed/Tests/StaticTest.cs similarity index 100% rename from Src/Tests/StaticTest.cs rename to Src.GetRenamed/Tests/StaticTest.cs diff --git a/Src/Tests/Stress/Engine.cs b/Src.GetRenamed/Tests/Stress/Engine.cs similarity index 100% rename from Src/Tests/Stress/Engine.cs rename to Src.GetRenamed/Tests/Stress/Engine.cs diff --git a/Src/Tests/StringDictionaryStorage.cs b/Src.GetRenamed/Tests/StringDictionaryStorage.cs similarity index 100% rename from Src/Tests/StringDictionaryStorage.cs rename to Src.GetRenamed/Tests/StringDictionaryStorage.cs diff --git a/Src/Tests/TestBuiltinModule.cs b/Src.GetRenamed/Tests/TestBuiltinModule.cs similarity index 100% rename from Src/Tests/TestBuiltinModule.cs rename to Src.GetRenamed/Tests/TestBuiltinModule.cs diff --git a/Src/Tests/TypeDescriptor.cs b/Src.GetRenamed/Tests/TypeDescriptor.cs similarity index 100% rename from Src/Tests/TypeDescriptor.cs rename to Src.GetRenamed/Tests/TypeDescriptor.cs diff --git a/Src/Tests/Util/IniParser.cs b/Src.GetRenamed/Tests/Util/IniParser.cs similarity index 100% rename from Src/Tests/Util/IniParser.cs rename to Src.GetRenamed/Tests/Util/IniParser.cs diff --git a/Src/Tests/Util/TestManifest.cs b/Src.GetRenamed/Tests/Util/TestManifest.cs similarity index 100% rename from Src/Tests/Util/TestManifest.cs rename to Src.GetRenamed/Tests/Util/TestManifest.cs diff --git a/Src/Wpf/DynamicXamlReader.cs b/Src.GetRenamed/Wpf/DynamicXamlReader.cs similarity index 100% rename from Src/Wpf/DynamicXamlReader.cs rename to Src.GetRenamed/Wpf/DynamicXamlReader.cs diff --git a/Src/Wpf/IronPython.Wpf.csproj b/Src.GetRenamed/Wpf/IronPython.Wpf.csproj similarity index 100% rename from Src/Wpf/IronPython.Wpf.csproj rename to Src.GetRenamed/Wpf/IronPython.Wpf.csproj diff --git a/Src/Wpf/Properties/AssemblyInfo.cs b/Src.GetRenamed/Wpf/Properties/AssemblyInfo.cs similarity index 100% rename from Src/Wpf/Properties/AssemblyInfo.cs rename to Src.GetRenamed/Wpf/Properties/AssemblyInfo.cs diff --git a/Src/Wpf/_wpf.cs b/Src.GetRenamed/Wpf/_wpf.cs similarity index 100% rename from Src/Wpf/_wpf.cs rename to Src.GetRenamed/Wpf/_wpf.cs diff --git a/Src/DLR b/Src/DLR deleted file mode 160000 index fe26cf45d..000000000 --- a/Src/DLR +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fe26cf45d383be65a56f0d4b964644eff89e01a8 diff --git a/Utils/NuGet/nuget.exe b/Utils.GetRenamed/NuGet/nuget.exe similarity index 100% rename from Utils/NuGet/nuget.exe rename to Utils.GetRenamed/NuGet/nuget.exe diff --git a/Utils/References/IKVM/IKVM.Reflection.License.txt b/Utils.GetRenamed/References/IKVM/IKVM.Reflection.License.txt similarity index 100% rename from Utils/References/IKVM/IKVM.Reflection.License.txt rename to Utils.GetRenamed/References/IKVM/IKVM.Reflection.License.txt diff --git a/Utils/References/IKVM/IKVM.Reflection.dll b/Utils.GetRenamed/References/IKVM/IKVM.Reflection.dll similarity index 100% rename from Utils/References/IKVM/IKVM.Reflection.dll rename to Utils.GetRenamed/References/IKVM/IKVM.Reflection.dll diff --git a/Utils/References/Mono.Posix.dll b/Utils.GetRenamed/References/Mono.Posix.dll similarity index 100% rename from Utils/References/Mono.Posix.dll rename to Utils.GetRenamed/References/Mono.Posix.dll diff --git a/Documentation/building.md b/docs/building.md similarity index 100% rename from Documentation/building.md rename to docs/building.md diff --git a/Documentation/differences-from-c-python.md b/docs/differences-from-c-python.md similarity index 100% rename from Documentation/differences-from-c-python.md rename to docs/differences-from-c-python.md diff --git a/Documentation/feature-symbols.md b/docs/feature-symbols.md similarity index 100% rename from Documentation/feature-symbols.md rename to docs/feature-symbols.md diff --git a/Documentation/getting-the-sources.md b/docs/getting-the-sources.md similarity index 100% rename from Documentation/getting-the-sources.md rename to docs/getting-the-sources.md diff --git a/Documentation/installing.md b/docs/installing.md similarity index 100% rename from Documentation/installing.md rename to docs/installing.md diff --git a/Documentation/logo.png b/docs/logo.png similarity index 100% rename from Documentation/logo.png rename to docs/logo.png diff --git a/Documentation/logo.svg b/docs/logo.svg similarity index 100% rename from Documentation/logo.svg rename to docs/logo.svg diff --git a/Documentation/modifying-the-sources.md b/docs/modifying-the-sources.md similarity index 100% rename from Documentation/modifying-the-sources.md rename to docs/modifying-the-sources.md diff --git a/Documentation/package-compatibility.md b/docs/package-compatibility.md similarity index 100% rename from Documentation/package-compatibility.md rename to docs/package-compatibility.md diff --git a/Documentation/upgrading-from-ipy2.md b/docs/upgrading-from-ipy2.md similarity index 100% rename from Documentation/upgrading-from-ipy2.md rename to docs/upgrading-from-ipy2.md diff --git a/Build/After.targets b/eng/After.targets similarity index 100% rename from Build/After.targets rename to eng/After.targets diff --git a/Build/Key.snk b/eng/Key.snk similarity index 100% rename from Build/Key.snk rename to eng/Key.snk diff --git a/Build/Tasks.Targets b/eng/Tasks.Targets similarity index 100% rename from Build/Tasks.Targets rename to eng/Tasks.Targets diff --git a/Package/choco/Choco.Packaging.targets b/eng/choco/Choco.Packaging.targets similarity index 100% rename from Package/choco/Choco.Packaging.targets rename to eng/choco/Choco.Packaging.targets diff --git a/Package/choco/IronPython.nuspec b/eng/choco/IronPython.nuspec similarity index 100% rename from Package/choco/IronPython.nuspec rename to eng/choco/IronPython.nuspec diff --git a/Package/choco/README.md b/eng/choco/README.md similarity index 100% rename from Package/choco/README.md rename to eng/choco/README.md diff --git a/Package/choco/ignores/lib/distutils/command/wininst-10.0-amd64.exe.ignore b/eng/choco/ignores/lib/distutils/command/wininst-10.0-amd64.exe.ignore similarity index 100% rename from Package/choco/ignores/lib/distutils/command/wininst-10.0-amd64.exe.ignore rename to eng/choco/ignores/lib/distutils/command/wininst-10.0-amd64.exe.ignore diff --git a/Package/choco/ignores/lib/distutils/command/wininst-10.0.exe.ignore b/eng/choco/ignores/lib/distutils/command/wininst-10.0.exe.ignore similarity index 100% rename from Package/choco/ignores/lib/distutils/command/wininst-10.0.exe.ignore rename to eng/choco/ignores/lib/distutils/command/wininst-10.0.exe.ignore diff --git a/Package/choco/ignores/lib/distutils/command/wininst-6.0.exe.ignore b/eng/choco/ignores/lib/distutils/command/wininst-6.0.exe.ignore similarity index 100% rename from Package/choco/ignores/lib/distutils/command/wininst-6.0.exe.ignore rename to eng/choco/ignores/lib/distutils/command/wininst-6.0.exe.ignore diff --git a/Package/choco/ignores/lib/distutils/command/wininst-7.1.exe.ignore b/eng/choco/ignores/lib/distutils/command/wininst-7.1.exe.ignore similarity index 100% rename from Package/choco/ignores/lib/distutils/command/wininst-7.1.exe.ignore rename to eng/choco/ignores/lib/distutils/command/wininst-7.1.exe.ignore diff --git a/Package/choco/ignores/lib/distutils/command/wininst-8.0.exe.ignore b/eng/choco/ignores/lib/distutils/command/wininst-8.0.exe.ignore similarity index 100% rename from Package/choco/ignores/lib/distutils/command/wininst-8.0.exe.ignore rename to eng/choco/ignores/lib/distutils/command/wininst-8.0.exe.ignore diff --git a/Package/choco/ignores/lib/distutils/command/wininst-9.0-amd64.exe.ignore b/eng/choco/ignores/lib/distutils/command/wininst-9.0-amd64.exe.ignore similarity index 100% rename from Package/choco/ignores/lib/distutils/command/wininst-9.0-amd64.exe.ignore rename to eng/choco/ignores/lib/distutils/command/wininst-9.0-amd64.exe.ignore diff --git a/Package/choco/ignores/lib/distutils/command/wininst-9.0.exe.ignore b/eng/choco/ignores/lib/distutils/command/wininst-9.0.exe.ignore similarity index 100% rename from Package/choco/ignores/lib/distutils/command/wininst-9.0.exe.ignore rename to eng/choco/ignores/lib/distutils/command/wininst-9.0.exe.ignore diff --git a/Package/choco/tools/VERIFICATION.txt b/eng/choco/tools/VERIFICATION.txt similarity index 100% rename from Package/choco/tools/VERIFICATION.txt rename to eng/choco/tools/VERIFICATION.txt diff --git a/Package/deb/DEBIAN/control b/eng/deb/DEBIAN/control similarity index 100% rename from Package/deb/DEBIAN/control rename to eng/deb/DEBIAN/control diff --git a/Package/deb/Deb.Packaging.targets b/eng/deb/Deb.Packaging.targets similarity index 100% rename from Package/deb/Deb.Packaging.targets rename to eng/deb/Deb.Packaging.targets diff --git a/eng/deb/ipy b/eng/deb/ipy new file mode 100644 index 000000000..e2e8195a3 --- /dev/null +++ b/eng/deb/ipy @@ -0,0 +1 @@ +ipy3.4 \ No newline at end of file diff --git a/eng/deb/ipy3 b/eng/deb/ipy3 new file mode 100644 index 000000000..e2e8195a3 --- /dev/null +++ b/eng/deb/ipy3 @@ -0,0 +1 @@ +ipy3.4 \ No newline at end of file diff --git a/Package/deb/ipy3.4 b/eng/deb/ipy3.4 old mode 100755 new mode 100644 similarity index 100% rename from Package/deb/ipy3.4 rename to eng/deb/ipy3.4 diff --git a/Package/dotnettool/DotnetTool.Packaging.targets b/eng/dotnettool/DotnetTool.Packaging.targets similarity index 100% rename from Package/dotnettool/DotnetTool.Packaging.targets rename to eng/dotnettool/DotnetTool.Packaging.targets diff --git a/Package/dotnettool/IronPython.Console.csproj b/eng/dotnettool/IronPython.Console.csproj similarity index 100% rename from Package/dotnettool/IronPython.Console.csproj rename to eng/dotnettool/IronPython.Console.csproj diff --git a/Package/dotnettool/README.md b/eng/dotnettool/README.md similarity index 100% rename from Package/dotnettool/README.md rename to eng/dotnettool/README.md diff --git a/Package/dotnettool/runtimeconfig.template.json b/eng/dotnettool/runtimeconfig.template.json similarity index 100% rename from Package/dotnettool/runtimeconfig.template.json rename to eng/dotnettool/runtimeconfig.template.json diff --git a/Package/msi/Dlr.wxs b/eng/msi/Dlr.wxs similarity index 100% rename from Package/msi/Dlr.wxs rename to eng/msi/Dlr.wxs diff --git a/Package/msi/IronPython.Installer.wixproj b/eng/msi/IronPython.Installer.wixproj similarity index 100% rename from Package/msi/IronPython.Installer.wixproj rename to eng/msi/IronPython.Installer.wixproj diff --git a/Package/msi/IronPython.wxs b/eng/msi/IronPython.wxs similarity index 100% rename from Package/msi/IronPython.wxs rename to eng/msi/IronPython.wxs diff --git a/Package/msi/License.rtf b/eng/msi/License.rtf similarity index 100% rename from Package/msi/License.rtf rename to eng/msi/License.rtf diff --git a/Package/msi/Msi.Packaging.targets b/eng/msi/Msi.Packaging.targets similarity index 100% rename from Package/msi/Msi.Packaging.targets rename to eng/msi/Msi.Packaging.targets diff --git a/Package/msi/Product.wxs b/eng/msi/Product.wxs similarity index 100% rename from Package/msi/Product.wxs rename to eng/msi/Product.wxs diff --git a/Package/msi/Version.wxi b/eng/msi/Version.wxi similarity index 100% rename from Package/msi/Version.wxi rename to eng/msi/Version.wxi diff --git a/Package/msi/banner.bmp b/eng/msi/banner.bmp similarity index 100% rename from Package/msi/banner.bmp rename to eng/msi/banner.bmp diff --git a/Package/msi/ironpython.bmp b/eng/msi/ironpython.bmp similarity index 100% rename from Package/msi/ironpython.bmp rename to eng/msi/ironpython.bmp diff --git a/Build/net462.props b/eng/net462.props similarity index 100% rename from Build/net462.props rename to eng/net462.props diff --git a/Build/net6.0-windows.props b/eng/net6.0-windows.props similarity index 100% rename from Build/net6.0-windows.props rename to eng/net6.0-windows.props diff --git a/Build/net6.0.props b/eng/net6.0.props similarity index 100% rename from Build/net6.0.props rename to eng/net6.0.props diff --git a/Build/net8.0-windows.props b/eng/net8.0-windows.props similarity index 100% rename from Build/net8.0-windows.props rename to eng/net8.0-windows.props diff --git a/Build/net8.0.props b/eng/net8.0.props similarity index 100% rename from Build/net8.0.props rename to eng/net8.0.props diff --git a/Build/net9.0-windows.props b/eng/net9.0-windows.props similarity index 100% rename from Build/net9.0-windows.props rename to eng/net9.0-windows.props diff --git a/Build/net9.0.props b/eng/net9.0.props similarity index 100% rename from Build/net9.0.props rename to eng/net9.0.props diff --git a/Build/netcoreapp2.1.props b/eng/netcoreapp2.1.props similarity index 100% rename from Build/netcoreapp2.1.props rename to eng/netcoreapp2.1.props diff --git a/Build/netcoreapp3.1.props b/eng/netcoreapp3.1.props similarity index 100% rename from Build/netcoreapp3.1.props rename to eng/netcoreapp3.1.props diff --git a/Build/netstandard2.0.props b/eng/netstandard2.0.props similarity index 100% rename from Build/netstandard2.0.props rename to eng/netstandard2.0.props diff --git a/Package/nuget/IronPython.StdLib.nuspec b/eng/nuget/IronPython.StdLib.nuspec similarity index 100% rename from Package/nuget/IronPython.StdLib.nuspec rename to eng/nuget/IronPython.StdLib.nuspec diff --git a/Package/nuget/IronPython.nuspec b/eng/nuget/IronPython.nuspec similarity index 100% rename from Package/nuget/IronPython.nuspec rename to eng/nuget/IronPython.nuspec diff --git a/Package/nuget/NuGet.Packaging.csproj b/eng/nuget/NuGet.Packaging.csproj similarity index 100% rename from Package/nuget/NuGet.Packaging.csproj rename to eng/nuget/NuGet.Packaging.csproj diff --git a/Package/nuget/NuGet.Packaging.targets b/eng/nuget/NuGet.Packaging.targets similarity index 100% rename from Package/nuget/NuGet.Packaging.targets rename to eng/nuget/NuGet.Packaging.targets diff --git a/Package/nuget/README.md b/eng/nuget/README.md similarity index 100% rename from Package/nuget/README.md rename to eng/nuget/README.md diff --git a/Package/pkg/Pkg.Packaging.targets b/eng/pkg/Pkg.Packaging.targets similarity index 100% rename from Package/pkg/Pkg.Packaging.targets rename to eng/pkg/Pkg.Packaging.targets diff --git a/Package/pkg/dos2unix.sh b/eng/pkg/dos2unix.sh old mode 100755 new mode 100644 similarity index 100% rename from Package/pkg/dos2unix.sh rename to eng/pkg/dos2unix.sh diff --git a/Build/steps.yml b/eng/steps.yml similarity index 100% rename from Build/steps.yml rename to eng/steps.yml diff --git a/Package/zip/README.md b/eng/zip/README.md similarity index 100% rename from Package/zip/README.md rename to eng/zip/README.md diff --git a/Package/zip/Zip.Packaging.targets b/eng/zip/Zip.Packaging.targets similarity index 100% rename from Package/zip/Zip.Packaging.targets rename to eng/zip/Zip.Packaging.targets diff --git a/PythonTests/IndicesTest.py b/tests/IndicesTest.py similarity index 100% rename from PythonTests/IndicesTest.py rename to tests/IndicesTest.py diff --git a/PythonTests/Inputs/RemoteConsole.py b/tests/Inputs/RemoteConsole.py similarity index 100% rename from PythonTests/Inputs/RemoteConsole.py rename to tests/Inputs/RemoteConsole.py diff --git a/PythonTests/Inputs/UseCLI.py b/tests/Inputs/UseCLI.py similarity index 100% rename from PythonTests/Inputs/UseCLI.py rename to tests/Inputs/UseCLI.py diff --git a/PythonTests/Inputs/exit.py b/tests/Inputs/exit.py similarity index 100% rename from PythonTests/Inputs/exit.py rename to tests/Inputs/exit.py diff --git a/PythonTests/Inputs/exitFuncRaises.py b/tests/Inputs/exitFuncRaises.py similarity index 100% rename from PythonTests/Inputs/exitFuncRaises.py rename to tests/Inputs/exitFuncRaises.py diff --git a/PythonTests/Inputs/exitFuncRuns.py b/tests/Inputs/exitFuncRuns.py similarity index 100% rename from PythonTests/Inputs/exitFuncRuns.py rename to tests/Inputs/exitFuncRuns.py diff --git a/PythonTests/Inputs/raise.py b/tests/Inputs/raise.py similarity index 100% rename from PythonTests/Inputs/raise.py rename to tests/Inputs/raise.py diff --git a/PythonTests/Inputs/simpleCommand.py b/tests/Inputs/simpleCommand.py similarity index 100% rename from PythonTests/Inputs/simpleCommand.py rename to tests/Inputs/simpleCommand.py diff --git a/PythonTests/Inputs/syntaxError.py b/tests/Inputs/syntaxError.py similarity index 100% rename from PythonTests/Inputs/syntaxError.py rename to tests/Inputs/syntaxError.py diff --git a/PythonTests/Inputs/uninitializedGlobal.py b/tests/Inputs/uninitializedGlobal.py similarity index 100% rename from PythonTests/Inputs/uninitializedGlobal.py rename to tests/Inputs/uninitializedGlobal.py diff --git a/PythonTests/Modes/ConsoleFlags.ps1 b/tests/Modes/ConsoleFlags.ps1 similarity index 100% rename from PythonTests/Modes/ConsoleFlags.ps1 rename to tests/Modes/ConsoleFlags.ps1 diff --git a/PythonTests/Modes/ConsoleHelp.Debug.out b/tests/Modes/ConsoleHelp.Debug.out similarity index 100% rename from PythonTests/Modes/ConsoleHelp.Debug.out rename to tests/Modes/ConsoleHelp.Debug.out diff --git a/PythonTests/Modes/ConsoleHelp.Release.out b/tests/Modes/ConsoleHelp.Release.out similarity index 100% rename from PythonTests/Modes/ConsoleHelp.Release.out rename to tests/Modes/ConsoleHelp.Release.out diff --git a/PythonTests/RunAgainstCpy.py b/tests/RunAgainstCpy.py similarity index 100% rename from PythonTests/RunAgainstCpy.py rename to tests/RunAgainstCpy.py diff --git a/PythonTests/Tools/baselines/__builtin__.log b/tests/Tools/baselines/__builtin__.log similarity index 100% rename from PythonTests/Tools/baselines/__builtin__.log rename to tests/Tools/baselines/__builtin__.log diff --git a/PythonTests/Tools/baselines/_codecs.log b/tests/Tools/baselines/_codecs.log similarity index 100% rename from PythonTests/Tools/baselines/_codecs.log rename to tests/Tools/baselines/_codecs.log diff --git a/PythonTests/Tools/baselines/_collections.log b/tests/Tools/baselines/_collections.log similarity index 100% rename from PythonTests/Tools/baselines/_collections.log rename to tests/Tools/baselines/_collections.log diff --git a/PythonTests/Tools/baselines/_sre.log b/tests/Tools/baselines/_sre.log similarity index 100% rename from PythonTests/Tools/baselines/_sre.log rename to tests/Tools/baselines/_sre.log diff --git a/PythonTests/Tools/baselines/_struct.log b/tests/Tools/baselines/_struct.log similarity index 100% rename from PythonTests/Tools/baselines/_struct.log rename to tests/Tools/baselines/_struct.log diff --git a/PythonTests/Tools/baselines/_subprocess.log b/tests/Tools/baselines/_subprocess.log similarity index 100% rename from PythonTests/Tools/baselines/_subprocess.log rename to tests/Tools/baselines/_subprocess.log diff --git a/PythonTests/Tools/baselines/_weakref.log b/tests/Tools/baselines/_weakref.log similarity index 100% rename from PythonTests/Tools/baselines/_weakref.log rename to tests/Tools/baselines/_weakref.log diff --git a/PythonTests/Tools/baselines/_winreg.log b/tests/Tools/baselines/_winreg.log similarity index 100% rename from PythonTests/Tools/baselines/_winreg.log rename to tests/Tools/baselines/_winreg.log diff --git a/PythonTests/Tools/baselines/array.log b/tests/Tools/baselines/array.log similarity index 100% rename from PythonTests/Tools/baselines/array.log rename to tests/Tools/baselines/array.log diff --git a/PythonTests/Tools/baselines/cPickle.log b/tests/Tools/baselines/cPickle.log similarity index 100% rename from PythonTests/Tools/baselines/cPickle.log rename to tests/Tools/baselines/cPickle.log diff --git a/PythonTests/Tools/baselines/cStringIO.log b/tests/Tools/baselines/cStringIO.log similarity index 100% rename from PythonTests/Tools/baselines/cStringIO.log rename to tests/Tools/baselines/cStringIO.log diff --git a/PythonTests/Tools/baselines/copy_reg.log b/tests/Tools/baselines/copy_reg.log similarity index 100% rename from PythonTests/Tools/baselines/copy_reg.log rename to tests/Tools/baselines/copy_reg.log diff --git a/PythonTests/Tools/baselines/datetime.log b/tests/Tools/baselines/datetime.log similarity index 100% rename from PythonTests/Tools/baselines/datetime.log rename to tests/Tools/baselines/datetime.log diff --git a/PythonTests/Tools/baselines/gc.log b/tests/Tools/baselines/gc.log similarity index 100% rename from PythonTests/Tools/baselines/gc.log rename to tests/Tools/baselines/gc.log diff --git a/PythonTests/Tools/baselines/itertools.log b/tests/Tools/baselines/itertools.log similarity index 100% rename from PythonTests/Tools/baselines/itertools.log rename to tests/Tools/baselines/itertools.log diff --git a/PythonTests/Tools/baselines/math.log b/tests/Tools/baselines/math.log similarity index 100% rename from PythonTests/Tools/baselines/math.log rename to tests/Tools/baselines/math.log diff --git a/PythonTests/Tools/baselines/mmap.log b/tests/Tools/baselines/mmap.log similarity index 100% rename from PythonTests/Tools/baselines/mmap.log rename to tests/Tools/baselines/mmap.log diff --git a/PythonTests/Tools/baselines/msvcrt.log b/tests/Tools/baselines/msvcrt.log similarity index 100% rename from PythonTests/Tools/baselines/msvcrt.log rename to tests/Tools/baselines/msvcrt.log diff --git a/PythonTests/Tools/baselines/nt.log b/tests/Tools/baselines/nt.log similarity index 100% rename from PythonTests/Tools/baselines/nt.log rename to tests/Tools/baselines/nt.log diff --git a/PythonTests/Tools/baselines/select.log b/tests/Tools/baselines/select.log similarity index 100% rename from PythonTests/Tools/baselines/select.log rename to tests/Tools/baselines/select.log diff --git a/PythonTests/Tools/baselines/signal.log b/tests/Tools/baselines/signal.log similarity index 100% rename from PythonTests/Tools/baselines/signal.log rename to tests/Tools/baselines/signal.log diff --git a/PythonTests/Tools/baselines/sys.log b/tests/Tools/baselines/sys.log similarity index 100% rename from PythonTests/Tools/baselines/sys.log rename to tests/Tools/baselines/sys.log diff --git a/PythonTests/Tools/baselines/thread.log b/tests/Tools/baselines/thread.log similarity index 100% rename from PythonTests/Tools/baselines/thread.log rename to tests/Tools/baselines/thread.log diff --git a/PythonTests/Tools/baselines/time.log b/tests/Tools/baselines/time.log similarity index 100% rename from PythonTests/Tools/baselines/time.log rename to tests/Tools/baselines/time.log diff --git a/PythonTests/Tools/baselines/types_only.log b/tests/Tools/baselines/types_only.log similarity index 100% rename from PythonTests/Tools/baselines/types_only.log rename to tests/Tools/baselines/types_only.log diff --git a/PythonTests/Tools/baselines/xxsubtype.log b/tests/Tools/baselines/xxsubtype.log similarity index 100% rename from PythonTests/Tools/baselines/xxsubtype.log rename to tests/Tools/baselines/xxsubtype.log diff --git a/PythonTests/Tools/check/_functools.log b/tests/Tools/check/_functools.log similarity index 100% rename from PythonTests/Tools/check/_functools.log rename to tests/Tools/check/_functools.log diff --git a/PythonTests/Tools/cleantests.py b/tests/Tools/cleantests.py similarity index 100% rename from PythonTests/Tools/cleantests.py rename to tests/Tools/cleantests.py diff --git a/PythonTests/Tools/clr_helpers.py b/tests/Tools/clr_helpers.py similarity index 100% rename from PythonTests/Tools/clr_helpers.py rename to tests/Tools/clr_helpers.py diff --git a/PythonTests/Tools/cmodule.py b/tests/Tools/cmodule.py similarity index 100% rename from PythonTests/Tools/cmodule.py rename to tests/Tools/cmodule.py diff --git a/PythonTests/Tools/cpy_tests.py b/tests/Tools/cpy_tests.py similarity index 100% rename from PythonTests/Tools/cpy_tests.py rename to tests/Tools/cpy_tests.py diff --git a/PythonTests/Tools/logmodule.py b/tests/Tools/logmodule.py similarity index 100% rename from PythonTests/Tools/logmodule.py rename to tests/Tools/logmodule.py diff --git a/PythonTests/Tools/modulediff.py b/tests/Tools/modulediff.py similarity index 100% rename from PythonTests/Tools/modulediff.py rename to tests/Tools/modulediff.py diff --git a/PythonTests/Tools/stdmodules.py b/tests/Tools/stdmodules.py similarity index 100% rename from PythonTests/Tools/stdmodules.py rename to tests/Tools/stdmodules.py diff --git a/PythonTests/_ctypes_test_linux32.pyd b/tests/_ctypes_test_linux32.pyd similarity index 100% rename from PythonTests/_ctypes_test_linux32.pyd rename to tests/_ctypes_test_linux32.pyd diff --git a/PythonTests/_ctypes_test_linux64.pyd b/tests/_ctypes_test_linux64.pyd similarity index 100% rename from PythonTests/_ctypes_test_linux64.pyd rename to tests/_ctypes_test_linux64.pyd diff --git a/PythonTests/_ctypes_test_win32.pyd b/tests/_ctypes_test_win32.pyd similarity index 100% rename from PythonTests/_ctypes_test_win32.pyd rename to tests/_ctypes_test_win32.pyd diff --git a/PythonTests/_ctypes_test_win64.pyd b/tests/_ctypes_test_win64.pyd similarity index 100% rename from PythonTests/_ctypes_test_win64.pyd rename to tests/_ctypes_test_win64.pyd diff --git a/PythonTests/badil.py b/tests/badil.py similarity index 100% rename from PythonTests/badil.py rename to tests/badil.py diff --git a/PythonTests/c1.cs b/tests/c1.cs similarity index 100% rename from PythonTests/c1.cs rename to tests/c1.cs diff --git a/PythonTests/c2.cs b/tests/c2.cs similarity index 100% rename from PythonTests/c2.cs rename to tests/c2.cs diff --git a/PythonTests/c3.cs b/tests/c3.cs similarity index 100% rename from PythonTests/c3.cs rename to tests/c3.cs diff --git a/PythonTests/c4.cs b/tests/c4.cs similarity index 100% rename from PythonTests/c4.cs rename to tests/c4.cs diff --git a/PythonTests/check_result.bat b/tests/check_result.bat similarity index 100% rename from PythonTests/check_result.bat rename to tests/check_result.bat diff --git a/PythonTests/compat/common.py b/tests/compat/common.py similarity index 100% rename from PythonTests/compat/common.py rename to tests/compat/common.py diff --git a/PythonTests/compat/rulediff.py b/tests/compat/rulediff.py similarity index 100% rename from PythonTests/compat/rulediff.py rename to tests/compat/rulediff.py diff --git a/PythonTests/compat/runsbs.py b/tests/compat/runsbs.py similarity index 100% rename from PythonTests/compat/runsbs.py rename to tests/compat/runsbs.py diff --git a/PythonTests/compat/sbs_builtin.py b/tests/compat/sbs_builtin.py similarity index 100% rename from PythonTests/compat/sbs_builtin.py rename to tests/compat/sbs_builtin.py diff --git a/PythonTests/compat/sbs_class_compare.py b/tests/compat/sbs_class_compare.py similarity index 100% rename from PythonTests/compat/sbs_class_compare.py rename to tests/compat/sbs_class_compare.py diff --git a/Src/StdLib/Lib/tkinter/test/__init__.py b/tests/compat/sbs_exceptions/__init__.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/__init__.py rename to tests/compat/sbs_exceptions/__init__.py diff --git a/PythonTests/compat/sbs_exceptions/define.py b/tests/compat/sbs_exceptions/define.py similarity index 100% rename from PythonTests/compat/sbs_exceptions/define.py rename to tests/compat/sbs_exceptions/define.py diff --git a/PythonTests/compat/sbs_exceptions/for_loop.py b/tests/compat/sbs_exceptions/for_loop.py similarity index 100% rename from PythonTests/compat/sbs_exceptions/for_loop.py rename to tests/compat/sbs_exceptions/for_loop.py diff --git a/PythonTests/compat/sbs_exceptions/if_false.py b/tests/compat/sbs_exceptions/if_false.py similarity index 100% rename from PythonTests/compat/sbs_exceptions/if_false.py rename to tests/compat/sbs_exceptions/if_false.py diff --git a/PythonTests/compat/sbs_exceptions/if_true.py b/tests/compat/sbs_exceptions/if_true.py similarity index 100% rename from PythonTests/compat/sbs_exceptions/if_true.py rename to tests/compat/sbs_exceptions/if_true.py diff --git a/PythonTests/compat/sbs_exceptions/shared.py b/tests/compat/sbs_exceptions/shared.py similarity index 100% rename from PythonTests/compat/sbs_exceptions/shared.py rename to tests/compat/sbs_exceptions/shared.py diff --git a/PythonTests/compat/sbs_exceptions/try_else.py b/tests/compat/sbs_exceptions/try_else.py similarity index 100% rename from PythonTests/compat/sbs_exceptions/try_else.py rename to tests/compat/sbs_exceptions/try_else.py diff --git a/PythonTests/compat/sbs_exceptions/try_except1.py b/tests/compat/sbs_exceptions/try_except1.py similarity index 100% rename from PythonTests/compat/sbs_exceptions/try_except1.py rename to tests/compat/sbs_exceptions/try_except1.py diff --git a/PythonTests/compat/sbs_exceptions/try_except2.py b/tests/compat/sbs_exceptions/try_except2.py similarity index 100% rename from PythonTests/compat/sbs_exceptions/try_except2.py rename to tests/compat/sbs_exceptions/try_except2.py diff --git a/PythonTests/compat/sbs_exceptions/try_except3.py b/tests/compat/sbs_exceptions/try_except3.py similarity index 100% rename from PythonTests/compat/sbs_exceptions/try_except3.py rename to tests/compat/sbs_exceptions/try_except3.py diff --git a/PythonTests/compat/sbs_exceptions/try_finally1.py b/tests/compat/sbs_exceptions/try_finally1.py similarity index 100% rename from PythonTests/compat/sbs_exceptions/try_finally1.py rename to tests/compat/sbs_exceptions/try_finally1.py diff --git a/PythonTests/compat/sbs_exceptions/try_finally2.py b/tests/compat/sbs_exceptions/try_finally2.py similarity index 100% rename from PythonTests/compat/sbs_exceptions/try_finally2.py rename to tests/compat/sbs_exceptions/try_finally2.py diff --git a/PythonTests/compat/sbs_exceptions/try_finally3.py b/tests/compat/sbs_exceptions/try_finally3.py similarity index 100% rename from PythonTests/compat/sbs_exceptions/try_finally3.py rename to tests/compat/sbs_exceptions/try_finally3.py diff --git a/PythonTests/compat/sbs_exceptions/while_loop.py b/tests/compat/sbs_exceptions/while_loop.py similarity index 100% rename from PythonTests/compat/sbs_exceptions/while_loop.py rename to tests/compat/sbs_exceptions/while_loop.py diff --git a/PythonTests/compat/sbs_func_args.py b/tests/compat/sbs_func_args.py similarity index 100% rename from PythonTests/compat/sbs_func_args.py rename to tests/compat/sbs_func_args.py diff --git a/PythonTests/compat/sbs_library.cs b/tests/compat/sbs_library.cs similarity index 100% rename from PythonTests/compat/sbs_library.cs rename to tests/compat/sbs_library.cs diff --git a/PythonTests/compat/sbs_newtype.py b/tests/compat/sbs_newtype.py similarity index 100% rename from PythonTests/compat/sbs_newtype.py rename to tests/compat/sbs_newtype.py diff --git a/PythonTests/compat/sbs_parse_string.py b/tests/compat/sbs_parse_string.py similarity index 100% rename from PythonTests/compat/sbs_parse_string.py rename to tests/compat/sbs_parse_string.py diff --git a/PythonTests/compat/sbs_simple_compare.py b/tests/compat/sbs_simple_compare.py similarity index 100% rename from PythonTests/compat/sbs_simple_compare.py rename to tests/compat/sbs_simple_compare.py diff --git a/PythonTests/compat/sbs_simple_ops.py b/tests/compat/sbs_simple_ops.py similarity index 100% rename from PythonTests/compat/sbs_simple_ops.py rename to tests/compat/sbs_simple_ops.py diff --git a/PythonTests/compat/sbs_true_division.py b/tests/compat/sbs_true_division.py similarity index 100% rename from PythonTests/compat/sbs_true_division.py rename to tests/compat/sbs_true_division.py diff --git a/PythonTests/compat/sbs_typeop.py b/tests/compat/sbs_typeop.py similarity index 100% rename from PythonTests/compat/sbs_typeop.py rename to tests/compat/sbs_typeop.py diff --git a/PythonTests/compat/testdata.py b/tests/compat/testdata.py similarity index 100% rename from PythonTests/compat/testdata.py rename to tests/compat/testdata.py diff --git a/PythonTests/custombuiltins.py b/tests/custombuiltins.py similarity index 100% rename from PythonTests/custombuiltins.py rename to tests/custombuiltins.py diff --git a/PythonTests/debugging/__init__.py b/tests/debugging/__init__.py similarity index 100% rename from PythonTests/debugging/__init__.py rename to tests/debugging/__init__.py diff --git a/PythonTests/debugging/mdbg_tool/__init__.py b/tests/debugging/mdbg_tool/__init__.py similarity index 100% rename from PythonTests/debugging/mdbg_tool/__init__.py rename to tests/debugging/mdbg_tool/__init__.py diff --git a/PythonTests/debugging/pdb_mod/__init__.py b/tests/debugging/pdb_mod/__init__.py similarity index 100% rename from PythonTests/debugging/pdb_mod/__init__.py rename to tests/debugging/pdb_mod/__init__.py diff --git a/PythonTests/debugging/vs/__init__.py b/tests/debugging/vs/__init__.py similarity index 100% rename from PythonTests/debugging/vs/__init__.py rename to tests/debugging/vs/__init__.py diff --git a/PythonTests/dllsite.py b/tests/dllsite.py similarity index 100% rename from PythonTests/dllsite.py rename to tests/dllsite.py diff --git a/PythonTests/dummy_module.py b/tests/dummy_module.py similarity index 100% rename from PythonTests/dummy_module.py rename to tests/dummy_module.py diff --git a/PythonTests/dynamic_sanity/dynamic_runner.bat b/tests/dynamic_sanity/dynamic_runner.bat similarity index 100% rename from PythonTests/dynamic_sanity/dynamic_runner.bat rename to tests/dynamic_sanity/dynamic_runner.bat diff --git a/PythonTests/dynamic_sanity/dynamic_sanity.cs b/tests/dynamic_sanity/dynamic_sanity.cs similarity index 100% rename from PythonTests/dynamic_sanity/dynamic_sanity.cs rename to tests/dynamic_sanity/dynamic_sanity.cs diff --git a/PythonTests/dynamic_sanity/mock.py b/tests/dynamic_sanity/mock.py similarity index 100% rename from PythonTests/dynamic_sanity/mock.py rename to tests/dynamic_sanity/mock.py diff --git a/PythonTests/encoded_files/bad_encoding_name.py b/tests/encoded_files/bad_encoding_name.py similarity index 100% rename from PythonTests/encoded_files/bad_encoding_name.py rename to tests/encoded_files/bad_encoding_name.py diff --git a/PythonTests/encoded_files/bad_latin1_bom.py b/tests/encoded_files/bad_latin1_bom.py similarity index 100% rename from PythonTests/encoded_files/bad_latin1_bom.py rename to tests/encoded_files/bad_latin1_bom.py diff --git a/PythonTests/encoded_files/bad_latin1_bom_decl.py b/tests/encoded_files/bad_latin1_bom_decl.py similarity index 100% rename from PythonTests/encoded_files/bad_latin1_bom_decl.py rename to tests/encoded_files/bad_latin1_bom_decl.py diff --git a/PythonTests/encoded_files/bad_latin1_nbsp.py b/tests/encoded_files/bad_latin1_nbsp.py similarity index 100% rename from PythonTests/encoded_files/bad_latin1_nbsp.py rename to tests/encoded_files/bad_latin1_nbsp.py diff --git a/PythonTests/encoded_files/bad_latin1_nodecl.py b/tests/encoded_files/bad_latin1_nodecl.py similarity index 100% rename from PythonTests/encoded_files/bad_latin1_nodecl.py rename to tests/encoded_files/bad_latin1_nodecl.py diff --git a/PythonTests/encoded_files/bad_utf8_bom_decl.py b/tests/encoded_files/bad_utf8_bom_decl.py similarity index 100% rename from PythonTests/encoded_files/bad_utf8_bom_decl.py rename to tests/encoded_files/bad_utf8_bom_decl.py diff --git a/PythonTests/encoded_files/cp1019.py b/tests/encoded_files/cp1019.py similarity index 100% rename from PythonTests/encoded_files/cp1019.py rename to tests/encoded_files/cp1019.py diff --git a/PythonTests/encoded_files/cp11334_bad.py b/tests/encoded_files/cp11334_bad.py similarity index 100% rename from PythonTests/encoded_files/cp11334_bad.py rename to tests/encoded_files/cp11334_bad.py diff --git a/PythonTests/encoded_files/cp11334_ok.py b/tests/encoded_files/cp11334_ok.py similarity index 100% rename from PythonTests/encoded_files/cp11334_ok.py rename to tests/encoded_files/cp11334_ok.py diff --git a/PythonTests/encoded_files/cp20472.py b/tests/encoded_files/cp20472.py similarity index 100% rename from PythonTests/encoded_files/cp20472.py rename to tests/encoded_files/cp20472.py diff --git a/PythonTests/encoded_files/ok_encoding_nonascii.py b/tests/encoded_files/ok_encoding_nonascii.py similarity index 100% rename from PythonTests/encoded_files/ok_encoding_nonascii.py rename to tests/encoded_files/ok_encoding_nonascii.py diff --git a/PythonTests/encoded_files/ok_encoding_whitespace.py b/tests/encoded_files/ok_encoding_whitespace.py similarity index 100% rename from PythonTests/encoded_files/ok_encoding_whitespace.py rename to tests/encoded_files/ok_encoding_whitespace.py diff --git a/PythonTests/file_with_BOM.txt b/tests/file_with_BOM.txt similarity index 88% rename from PythonTests/file_with_BOM.txt rename to tests/file_with_BOM.txt index e451428cd..41bc4eb86 100644 --- a/PythonTests/file_with_BOM.txt +++ b/tests/file_with_BOM.txt @@ -1 +1 @@ -BÓM +BÓM diff --git a/PythonTests/file_without_BOM.txt b/tests/file_without_BOM.txt similarity index 83% rename from PythonTests/file_without_BOM.txt rename to tests/file_without_BOM.txt index cae98f32b..5835e0bf5 100644 --- a/PythonTests/file_without_BOM.txt +++ b/tests/file_without_BOM.txt @@ -1 +1 @@ -BÓM +BÓM diff --git a/PythonTests/functions/test_signatures.py b/tests/functions/test_signatures.py similarity index 100% rename from PythonTests/functions/test_signatures.py rename to tests/functions/test_signatures.py diff --git a/PythonTests/gen_stdlib_test.py b/tests/gen_stdlib_test.py similarity index 100% rename from PythonTests/gen_stdlib_test.py rename to tests/gen_stdlib_test.py diff --git a/PythonTests/gh129.zip b/tests/gh129.zip similarity index 100% rename from PythonTests/gh129.zip rename to tests/gh129.zip diff --git a/PythonTests/harness.py b/tests/harness.py similarity index 100% rename from PythonTests/harness.py rename to tests/harness.py diff --git a/PythonTests/hosting/editor_svcs/test_errorlistener.py b/tests/hosting/editor_svcs/test_errorlistener.py similarity index 100% rename from PythonTests/hosting/editor_svcs/test_errorlistener.py rename to tests/hosting/editor_svcs/test_errorlistener.py diff --git a/PythonTests/hosting/editor_svcs/test_tokencategorizer.py b/tests/hosting/editor_svcs/test_tokencategorizer.py similarity index 100% rename from PythonTests/hosting/editor_svcs/test_tokencategorizer.py rename to tests/hosting/editor_svcs/test_tokencategorizer.py diff --git a/Src/StdLib/Lib/tkinter/test/test_tkinter/__init__.py b/tests/import_extant/_vendor/__init__.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_tkinter/__init__.py rename to tests/import_extant/_vendor/__init__.py diff --git a/Src/StdLib/Lib/tkinter/test/test_ttk/__init__.py b/tests/import_extant/_vendor/packaging/__init__.py similarity index 100% rename from Src/StdLib/Lib/tkinter/test/test_ttk/__init__.py rename to tests/import_extant/_vendor/packaging/__init__.py diff --git a/PythonTests/import_extant/_vendor/packaging/_structures.py b/tests/import_extant/_vendor/packaging/_structures.py similarity index 100% rename from PythonTests/import_extant/_vendor/packaging/_structures.py rename to tests/import_extant/_vendor/packaging/_structures.py diff --git a/PythonTests/import_extant/_vendor/packaging/version.py b/tests/import_extant/_vendor/packaging/version.py similarity index 100% rename from PythonTests/import_extant/_vendor/packaging/version.py rename to tests/import_extant/_vendor/packaging/version.py diff --git a/PythonTests/import_extant/extern/__init__.py b/tests/import_extant/extern/__init__.py similarity index 100% rename from PythonTests/import_extant/extern/__init__.py rename to tests/import_extant/extern/__init__.py diff --git a/PythonTests/interop/__init__.py b/tests/interop/__init__.py similarity index 100% rename from PythonTests/interop/__init__.py rename to tests/interop/__init__.py diff --git a/PythonTests/interop/com/apps/MultiOffice.py b/tests/interop/com/apps/MultiOffice.py similarity index 100% rename from PythonTests/interop/com/apps/MultiOffice.py rename to tests/interop/com/apps/MultiOffice.py diff --git a/PythonTests/interop/com/apps/adodb.py b/tests/interop/com/apps/adodb.py similarity index 100% rename from PythonTests/interop/com/apps/adodb.py rename to tests/interop/com/apps/adodb.py diff --git a/PythonTests/interop/com/apps/excel.py b/tests/interop/com/apps/excel.py similarity index 100% rename from PythonTests/interop/com/apps/excel.py rename to tests/interop/com/apps/excel.py diff --git a/PythonTests/interop/com/apps/scriptpw.py b/tests/interop/com/apps/scriptpw.py similarity index 100% rename from PythonTests/interop/com/apps/scriptpw.py rename to tests/interop/com/apps/scriptpw.py diff --git a/PythonTests/interop/com/apps/word.py b/tests/interop/com/apps/word.py similarity index 100% rename from PythonTests/interop/com/apps/word.py rename to tests/interop/com/apps/word.py diff --git a/PythonTests/interop/com/compat/__init__.py b/tests/interop/com/compat/__init__.py similarity index 100% rename from PythonTests/interop/com/compat/__init__.py rename to tests/interop/com/compat/__init__.py diff --git a/PythonTests/interop/com/compat/hw.py b/tests/interop/com/compat/hw.py similarity index 100% rename from PythonTests/interop/com/compat/hw.py rename to tests/interop/com/compat/hw.py diff --git a/PythonTests/interop/com/compat/hw_client.py b/tests/interop/com/compat/hw_client.py similarity index 100% rename from PythonTests/interop/com/compat/hw_client.py rename to tests/interop/com/compat/hw_client.py diff --git a/PythonTests/interop/com/dlrcomlib/DispEvents.py b/tests/interop/com/dlrcomlib/DispEvents.py similarity index 100% rename from PythonTests/interop/com/dlrcomlib/DispEvents.py rename to tests/interop/com/dlrcomlib/DispEvents.py diff --git a/PythonTests/interop/com/dlrcomlib/InOutParams.py b/tests/interop/com/dlrcomlib/InOutParams.py similarity index 100% rename from PythonTests/interop/com/dlrcomlib/InOutParams.py rename to tests/interop/com/dlrcomlib/InOutParams.py diff --git a/PythonTests/interop/com/dlrcomlib/MultipleParams.py b/tests/interop/com/dlrcomlib/MultipleParams.py similarity index 100% rename from PythonTests/interop/com/dlrcomlib/MultipleParams.py rename to tests/interop/com/dlrcomlib/MultipleParams.py diff --git a/PythonTests/interop/com/dlrcomlib/OptionalParams.py b/tests/interop/com/dlrcomlib/OptionalParams.py similarity index 100% rename from PythonTests/interop/com/dlrcomlib/OptionalParams.py rename to tests/interop/com/dlrcomlib/OptionalParams.py diff --git a/PythonTests/interop/com/dlrcomlib/OutParams.py b/tests/interop/com/dlrcomlib/OutParams.py similarity index 100% rename from PythonTests/interop/com/dlrcomlib/OutParams.py rename to tests/interop/com/dlrcomlib/OutParams.py diff --git a/PythonTests/interop/com/dlrcomlib/ReturnValues.py b/tests/interop/com/dlrcomlib/ReturnValues.py similarity index 100% rename from PythonTests/interop/com/dlrcomlib/ReturnValues.py rename to tests/interop/com/dlrcomlib/ReturnValues.py diff --git a/PythonTests/interop/com/dlrcomlib/SimpleErrors.py b/tests/interop/com/dlrcomlib/SimpleErrors.py similarity index 100% rename from PythonTests/interop/com/dlrcomlib/SimpleErrors.py rename to tests/interop/com/dlrcomlib/SimpleErrors.py diff --git a/PythonTests/interop/com/dlrcomlib/__init__.py b/tests/interop/com/dlrcomlib/__init__.py similarity index 100% rename from PythonTests/interop/com/dlrcomlib/__init__.py rename to tests/interop/com/dlrcomlib/__init__.py diff --git a/PythonTests/interop/com/dlrcomlib/dlrcomserver.py b/tests/interop/com/dlrcomlib/dlrcomserver.py similarity index 100% rename from PythonTests/interop/com/dlrcomlib/dlrcomserver.py rename to tests/interop/com/dlrcomlib/dlrcomserver.py diff --git a/PythonTests/interop/com/dlrcomlib/paramsinretval.py b/tests/interop/com/dlrcomlib/paramsinretval.py similarity index 100% rename from PythonTests/interop/com/dlrcomlib/paramsinretval.py rename to tests/interop/com/dlrcomlib/paramsinretval.py diff --git a/PythonTests/interop/com/dlrcomlib/properties.py b/tests/interop/com/dlrcomlib/properties.py similarity index 100% rename from PythonTests/interop/com/dlrcomlib/properties.py rename to tests/interop/com/dlrcomlib/properties.py diff --git a/PythonTests/interop/com/dlrcomlib/pytraits/__init__.py b/tests/interop/com/dlrcomlib/pytraits/__init__.py similarity index 100% rename from PythonTests/interop/com/dlrcomlib/pytraits/__init__.py rename to tests/interop/com/dlrcomlib/pytraits/__init__.py diff --git a/PythonTests/interop/com/dlrcomlib/pytraits/method.py b/tests/interop/com/dlrcomlib/pytraits/method.py similarity index 100% rename from PythonTests/interop/com/dlrcomlib/pytraits/method.py rename to tests/interop/com/dlrcomlib/pytraits/method.py diff --git a/PythonTests/interop/com/dlrcomlib/pytraits/obj.py b/tests/interop/com/dlrcomlib/pytraits/obj.py similarity index 100% rename from PythonTests/interop/com/dlrcomlib/pytraits/obj.py rename to tests/interop/com/dlrcomlib/pytraits/obj.py diff --git a/PythonTests/interop/com/dlrcomlib/pytraits/prop.py b/tests/interop/com/dlrcomlib/pytraits/prop.py similarity index 100% rename from PythonTests/interop/com/dlrcomlib/pytraits/prop.py rename to tests/interop/com/dlrcomlib/pytraits/prop.py diff --git a/PythonTests/interop/com/dlrcomlib/typelib.py b/tests/interop/com/dlrcomlib/typelib.py similarity index 100% rename from PythonTests/interop/com/dlrcomlib/typelib.py rename to tests/interop/com/dlrcomlib/typelib.py diff --git a/PythonTests/interop/net/derivation/test_ctor_override.py b/tests/interop/net/derivation/test_ctor_override.py similarity index 100% rename from PythonTests/interop/net/derivation/test_ctor_override.py rename to tests/interop/net/derivation/test_ctor_override.py diff --git a/PythonTests/interop/net/derivation/test_event_override.py b/tests/interop/net/derivation/test_event_override.py similarity index 100% rename from PythonTests/interop/net/derivation/test_event_override.py rename to tests/interop/net/derivation/test_event_override.py diff --git a/PythonTests/interop/net/derivation/test_method_override.py b/tests/interop/net/derivation/test_method_override.py similarity index 100% rename from PythonTests/interop/net/derivation/test_method_override.py rename to tests/interop/net/derivation/test_method_override.py diff --git a/PythonTests/interop/net/derivation/test_method_signature.py b/tests/interop/net/derivation/test_method_signature.py similarity index 100% rename from PythonTests/interop/net/derivation/test_method_signature.py rename to tests/interop/net/derivation/test_method_signature.py diff --git a/PythonTests/interop/net/derivation/test_property_override.py b/tests/interop/net/derivation/test_property_override.py similarity index 100% rename from PythonTests/interop/net/derivation/test_property_override.py rename to tests/interop/net/derivation/test_property_override.py diff --git a/PythonTests/interop/net/derivation/test_simplederive.py b/tests/interop/net/derivation/test_simplederive.py similarity index 100% rename from PythonTests/interop/net/derivation/test_simplederive.py rename to tests/interop/net/derivation/test_simplederive.py diff --git a/PythonTests/interop/net/derivation/test_special_method.py b/tests/interop/net/derivation/test_special_method.py similarity index 100% rename from PythonTests/interop/net/derivation/test_special_method.py rename to tests/interop/net/derivation/test_special_method.py diff --git a/PythonTests/interop/net/dynamic/test_dynamic_regressions.py b/tests/interop/net/dynamic/test_dynamic_regressions.py similarity index 100% rename from PythonTests/interop/net/dynamic/test_dynamic_regressions.py rename to tests/interop/net/dynamic/test_dynamic_regressions.py diff --git a/PythonTests/interop/net/event/test_delegate.py b/tests/interop/net/event/test_delegate.py similarity index 100% rename from PythonTests/interop/net/event/test_delegate.py rename to tests/interop/net/event/test_delegate.py diff --git a/PythonTests/interop/net/event/test_event.py b/tests/interop/net/event/test_event.py similarity index 100% rename from PythonTests/interop/net/event/test_event.py rename to tests/interop/net/event/test_event.py diff --git a/PythonTests/interop/net/field/test_field_misc.py b/tests/interop/net/field/test_field_misc.py similarity index 100% rename from PythonTests/interop/net/field/test_field_misc.py rename to tests/interop/net/field/test_field_misc.py diff --git a/PythonTests/interop/net/field/test_fields_inside_enum.py b/tests/interop/net/field/test_fields_inside_enum.py similarity index 100% rename from PythonTests/interop/net/field/test_fields_inside_enum.py rename to tests/interop/net/field/test_fields_inside_enum.py diff --git a/PythonTests/interop/net/field/test_initonly_fields.py b/tests/interop/net/field/test_initonly_fields.py similarity index 100% rename from PythonTests/interop/net/field/test_initonly_fields.py rename to tests/interop/net/field/test_initonly_fields.py diff --git a/PythonTests/interop/net/field/test_instance_fields.py b/tests/interop/net/field/test_instance_fields.py similarity index 100% rename from PythonTests/interop/net/field/test_instance_fields.py rename to tests/interop/net/field/test_instance_fields.py diff --git a/PythonTests/interop/net/field/test_literal_fields.py b/tests/interop/net/field/test_literal_fields.py similarity index 100% rename from PythonTests/interop/net/field/test_literal_fields.py rename to tests/interop/net/field/test_literal_fields.py diff --git a/PythonTests/interop/net/field/test_static_fields.py b/tests/interop/net/field/test_static_fields.py similarity index 100% rename from PythonTests/interop/net/field/test_static_fields.py rename to tests/interop/net/field/test_static_fields.py diff --git a/PythonTests/interop/net/loadorder/module.py b/tests/interop/net/loadorder/module.py similarity index 100% rename from PythonTests/interop/net/loadorder/module.py rename to tests/interop/net/loadorder/module.py diff --git a/PythonTests/interop/net/loadorder/t1a.py b/tests/interop/net/loadorder/t1a.py similarity index 100% rename from PythonTests/interop/net/loadorder/t1a.py rename to tests/interop/net/loadorder/t1a.py diff --git a/PythonTests/interop/net/loadorder/t1b.py b/tests/interop/net/loadorder/t1b.py similarity index 100% rename from PythonTests/interop/net/loadorder/t1b.py rename to tests/interop/net/loadorder/t1b.py diff --git a/PythonTests/interop/net/loadorder/t1c.py b/tests/interop/net/loadorder/t1c.py similarity index 100% rename from PythonTests/interop/net/loadorder/t1c.py rename to tests/interop/net/loadorder/t1c.py diff --git a/PythonTests/interop/net/loadorder/t1d.py b/tests/interop/net/loadorder/t1d.py similarity index 100% rename from PythonTests/interop/net/loadorder/t1d.py rename to tests/interop/net/loadorder/t1d.py diff --git a/PythonTests/interop/net/loadorder/t2a.py b/tests/interop/net/loadorder/t2a.py similarity index 100% rename from PythonTests/interop/net/loadorder/t2a.py rename to tests/interop/net/loadorder/t2a.py diff --git a/PythonTests/interop/net/loadorder/t2b.py b/tests/interop/net/loadorder/t2b.py similarity index 100% rename from PythonTests/interop/net/loadorder/t2b.py rename to tests/interop/net/loadorder/t2b.py diff --git a/PythonTests/interop/net/loadorder/t2c.py b/tests/interop/net/loadorder/t2c.py similarity index 100% rename from PythonTests/interop/net/loadorder/t2c.py rename to tests/interop/net/loadorder/t2c.py diff --git a/PythonTests/interop/net/loadorder/t2d.py b/tests/interop/net/loadorder/t2d.py similarity index 100% rename from PythonTests/interop/net/loadorder/t2d.py rename to tests/interop/net/loadorder/t2d.py diff --git a/PythonTests/interop/net/loadorder/t2e.py b/tests/interop/net/loadorder/t2e.py similarity index 100% rename from PythonTests/interop/net/loadorder/t2e.py rename to tests/interop/net/loadorder/t2e.py diff --git a/PythonTests/interop/net/loadorder/t2f.py b/tests/interop/net/loadorder/t2f.py similarity index 100% rename from PythonTests/interop/net/loadorder/t2f.py rename to tests/interop/net/loadorder/t2f.py diff --git a/PythonTests/interop/net/loadorder/t2g.py b/tests/interop/net/loadorder/t2g.py similarity index 100% rename from PythonTests/interop/net/loadorder/t2g.py rename to tests/interop/net/loadorder/t2g.py diff --git a/PythonTests/interop/net/loadorder/t2h.py b/tests/interop/net/loadorder/t2h.py similarity index 100% rename from PythonTests/interop/net/loadorder/t2h.py rename to tests/interop/net/loadorder/t2h.py diff --git a/PythonTests/interop/net/loadorder/t3a.py b/tests/interop/net/loadorder/t3a.py similarity index 100% rename from PythonTests/interop/net/loadorder/t3a.py rename to tests/interop/net/loadorder/t3a.py diff --git a/PythonTests/interop/net/loadorder/t3b.py b/tests/interop/net/loadorder/t3b.py similarity index 100% rename from PythonTests/interop/net/loadorder/t3b.py rename to tests/interop/net/loadorder/t3b.py diff --git a/PythonTests/interop/net/loadorder/t3c0.py b/tests/interop/net/loadorder/t3c0.py similarity index 100% rename from PythonTests/interop/net/loadorder/t3c0.py rename to tests/interop/net/loadorder/t3c0.py diff --git a/PythonTests/interop/net/loadorder/t3c1.py b/tests/interop/net/loadorder/t3c1.py similarity index 100% rename from PythonTests/interop/net/loadorder/t3c1.py rename to tests/interop/net/loadorder/t3c1.py diff --git a/PythonTests/interop/net/loadorder/t3c2.py b/tests/interop/net/loadorder/t3c2.py similarity index 100% rename from PythonTests/interop/net/loadorder/t3c2.py rename to tests/interop/net/loadorder/t3c2.py diff --git a/PythonTests/interop/net/loadorder/t3d.py b/tests/interop/net/loadorder/t3d.py similarity index 100% rename from PythonTests/interop/net/loadorder/t3d.py rename to tests/interop/net/loadorder/t3d.py diff --git a/PythonTests/interop/net/loadorder/t3e.py b/tests/interop/net/loadorder/t3e.py similarity index 100% rename from PythonTests/interop/net/loadorder/t3e.py rename to tests/interop/net/loadorder/t3e.py diff --git a/PythonTests/interop/net/loadorder/t3f.py b/tests/interop/net/loadorder/t3f.py similarity index 100% rename from PythonTests/interop/net/loadorder/t3f.py rename to tests/interop/net/loadorder/t3f.py diff --git a/PythonTests/interop/net/loadorder/t3g1.py b/tests/interop/net/loadorder/t3g1.py similarity index 100% rename from PythonTests/interop/net/loadorder/t3g1.py rename to tests/interop/net/loadorder/t3g1.py diff --git a/PythonTests/interop/net/loadorder/t3g2.py b/tests/interop/net/loadorder/t3g2.py similarity index 100% rename from PythonTests/interop/net/loadorder/t3g2.py rename to tests/interop/net/loadorder/t3g2.py diff --git a/PythonTests/interop/net/loadorder/t3h.py b/tests/interop/net/loadorder/t3h.py similarity index 100% rename from PythonTests/interop/net/loadorder/t3h.py rename to tests/interop/net/loadorder/t3h.py diff --git a/PythonTests/interop/net/loadorder/t3i.py b/tests/interop/net/loadorder/t3i.py similarity index 100% rename from PythonTests/interop/net/loadorder/t3i.py rename to tests/interop/net/loadorder/t3i.py diff --git a/PythonTests/interop/net/loadorder/t4a.py b/tests/interop/net/loadorder/t4a.py similarity index 100% rename from PythonTests/interop/net/loadorder/t4a.py rename to tests/interop/net/loadorder/t4a.py diff --git a/PythonTests/interop/net/loadorder/t4b.py b/tests/interop/net/loadorder/t4b.py similarity index 100% rename from PythonTests/interop/net/loadorder/t4b.py rename to tests/interop/net/loadorder/t4b.py diff --git a/PythonTests/interop/net/loadorder/t4c.py b/tests/interop/net/loadorder/t4c.py similarity index 100% rename from PythonTests/interop/net/loadorder/t4c.py rename to tests/interop/net/loadorder/t4c.py diff --git a/PythonTests/interop/net/loadorder/t5a.py b/tests/interop/net/loadorder/t5a.py similarity index 100% rename from PythonTests/interop/net/loadorder/t5a.py rename to tests/interop/net/loadorder/t5a.py diff --git a/PythonTests/interop/net/loadorder/t5b.py b/tests/interop/net/loadorder/t5b.py similarity index 100% rename from PythonTests/interop/net/loadorder/t5b.py rename to tests/interop/net/loadorder/t5b.py diff --git a/PythonTests/interop/net/loadorder/t5c1.py b/tests/interop/net/loadorder/t5c1.py similarity index 100% rename from PythonTests/interop/net/loadorder/t5c1.py rename to tests/interop/net/loadorder/t5c1.py diff --git a/PythonTests/interop/net/loadorder/t5c2.py b/tests/interop/net/loadorder/t5c2.py similarity index 100% rename from PythonTests/interop/net/loadorder/t5c2.py rename to tests/interop/net/loadorder/t5c2.py diff --git a/PythonTests/interop/net/loadorder/t6.py b/tests/interop/net/loadorder/t6.py similarity index 100% rename from PythonTests/interop/net/loadorder/t6.py rename to tests/interop/net/loadorder/t6.py diff --git a/PythonTests/interop/net/loadorder/t7a.py b/tests/interop/net/loadorder/t7a.py similarity index 100% rename from PythonTests/interop/net/loadorder/t7a.py rename to tests/interop/net/loadorder/t7a.py diff --git a/PythonTests/interop/net/loadorder/t7b.py b/tests/interop/net/loadorder/t7b.py similarity index 100% rename from PythonTests/interop/net/loadorder/t7b.py rename to tests/interop/net/loadorder/t7b.py diff --git a/PythonTests/interop/net/loadorder/t7c.py b/tests/interop/net/loadorder/t7c.py similarity index 100% rename from PythonTests/interop/net/loadorder/t7c.py rename to tests/interop/net/loadorder/t7c.py diff --git a/PythonTests/interop/net/loadorder/t7d.py b/tests/interop/net/loadorder/t7d.py similarity index 100% rename from PythonTests/interop/net/loadorder/t7d.py rename to tests/interop/net/loadorder/t7d.py diff --git a/PythonTests/interop/net/loadorder/t7e.py b/tests/interop/net/loadorder/t7e.py similarity index 100% rename from PythonTests/interop/net/loadorder/t7e.py rename to tests/interop/net/loadorder/t7e.py diff --git a/PythonTests/interop/net/loadorder/t7f.py b/tests/interop/net/loadorder/t7f.py similarity index 100% rename from PythonTests/interop/net/loadorder/t7f.py rename to tests/interop/net/loadorder/t7f.py diff --git a/PythonTests/interop/net/method/test_arguments.py b/tests/interop/net/method/test_arguments.py similarity index 100% rename from PythonTests/interop/net/method/test_arguments.py rename to tests/interop/net/method/test_arguments.py diff --git a/PythonTests/interop/net/method/test_op_explicit.py b/tests/interop/net/method/test_op_explicit.py similarity index 100% rename from PythonTests/interop/net/method/test_op_explicit.py rename to tests/interop/net/method/test_op_explicit.py diff --git a/PythonTests/interop/net/method/test_op_implicit.py b/tests/interop/net/method/test_op_implicit.py similarity index 100% rename from PythonTests/interop/net/method/test_op_implicit.py rename to tests/interop/net/method/test_op_implicit.py diff --git a/PythonTests/interop/net/method/test_operators.py b/tests/interop/net/method/test_operators.py similarity index 100% rename from PythonTests/interop/net/method/test_operators.py rename to tests/interop/net/method/test_operators.py diff --git a/PythonTests/interop/net/method/test_returnvalue.py b/tests/interop/net/method/test_returnvalue.py similarity index 100% rename from PythonTests/interop/net/method/test_returnvalue.py rename to tests/interop/net/method/test_returnvalue.py diff --git a/PythonTests/interop/net/property/test_indexercs.py b/tests/interop/net/property/test_indexercs.py similarity index 100% rename from PythonTests/interop/net/property/test_indexercs.py rename to tests/interop/net/property/test_indexercs.py diff --git a/PythonTests/interop/net/property/test_indexervb.py b/tests/interop/net/property/test_indexervb.py similarity index 100% rename from PythonTests/interop/net/property/test_indexervb.py rename to tests/interop/net/property/test_indexervb.py diff --git a/PythonTests/interop/net/property/test_property.py b/tests/interop/net/property/test_property.py similarity index 100% rename from PythonTests/interop/net/property/test_property.py rename to tests/interop/net/property/test_property.py diff --git a/PythonTests/interop/net/test_accessibility.py b/tests/interop/net/test_accessibility.py similarity index 100% rename from PythonTests/interop/net/test_accessibility.py rename to tests/interop/net/test_accessibility.py diff --git a/PythonTests/interop/net/test_dynamicobjectmodel.py b/tests/interop/net/test_dynamicobjectmodel.py similarity index 100% rename from PythonTests/interop/net/test_dynamicobjectmodel.py rename to tests/interop/net/test_dynamicobjectmodel.py diff --git a/PythonTests/interop/net/test_loadorder.py b/tests/interop/net/test_loadorder.py similarity index 100% rename from PythonTests/interop/net/test_loadorder.py rename to tests/interop/net/test_loadorder.py diff --git a/PythonTests/interop/net/type/test___clrtype.py b/tests/interop/net/type/test___clrtype.py similarity index 100% rename from PythonTests/interop/net/type/test___clrtype.py rename to tests/interop/net/type/test___clrtype.py diff --git a/PythonTests/interop/net/type/test_assembly.py b/tests/interop/net/type/test_assembly.py similarity index 100% rename from PythonTests/interop/net/type/test_assembly.py rename to tests/interop/net/type/test_assembly.py diff --git a/PythonTests/interop/net/type/test_clr_array.py b/tests/interop/net/type/test_clr_array.py similarity index 100% rename from PythonTests/interop/net/type/test_clr_array.py rename to tests/interop/net/type/test_clr_array.py diff --git a/PythonTests/interop/net/type/test_ctor.py b/tests/interop/net/type/test_ctor.py similarity index 100% rename from PythonTests/interop/net/type/test_ctor.py rename to tests/interop/net/type/test_ctor.py diff --git a/PythonTests/interop/net/type/test_defaultmember.py b/tests/interop/net/type/test_defaultmember.py similarity index 100% rename from PythonTests/interop/net/type/test_defaultmember.py rename to tests/interop/net/type/test_defaultmember.py diff --git a/PythonTests/interop/net/type/test_reachtype.py b/tests/interop/net/type/test_reachtype.py similarity index 100% rename from PythonTests/interop/net/type/test_reachtype.py rename to tests/interop/net/type/test_reachtype.py diff --git a/PythonTests/interop/net/versions/test_four_dot_zero.py b/tests/interop/net/versions/test_four_dot_zero.py similarity index 100% rename from PythonTests/interop/net/versions/test_four_dot_zero.py rename to tests/interop/net/versions/test_four_dot_zero.py diff --git a/PythonTests/modules/__init__.py b/tests/modules/__init__.py similarity index 100% rename from PythonTests/modules/__init__.py rename to tests/modules/__init__.py diff --git a/PythonTests/modules/io_related/test__bytesio.py b/tests/modules/io_related/test__bytesio.py similarity index 100% rename from PythonTests/modules/io_related/test__bytesio.py rename to tests/modules/io_related/test__bytesio.py diff --git a/PythonTests/modules/io_related/test__fileio.py b/tests/modules/io_related/test__fileio.py similarity index 100% rename from PythonTests/modules/io_related/test__fileio.py rename to tests/modules/io_related/test__fileio.py diff --git a/PythonTests/modules/io_related/test_binascii.py b/tests/modules/io_related/test_binascii.py similarity index 100% rename from PythonTests/modules/io_related/test_binascii.py rename to tests/modules/io_related/test_binascii.py diff --git a/PythonTests/modules/io_related/test_cPickle.py b/tests/modules/io_related/test_cPickle.py similarity index 100% rename from PythonTests/modules/io_related/test_cPickle.py rename to tests/modules/io_related/test_cPickle.py diff --git a/PythonTests/modules/io_related/test_codecs.py b/tests/modules/io_related/test_codecs.py similarity index 100% rename from PythonTests/modules/io_related/test_codecs.py rename to tests/modules/io_related/test_codecs.py diff --git a/PythonTests/modules/io_related/test_copyreg.py b/tests/modules/io_related/test_copyreg.py similarity index 100% rename from PythonTests/modules/io_related/test_copyreg.py rename to tests/modules/io_related/test_copyreg.py diff --git a/PythonTests/modules/io_related/test_fd.py b/tests/modules/io_related/test_fd.py similarity index 100% rename from PythonTests/modules/io_related/test_fd.py rename to tests/modules/io_related/test_fd.py diff --git a/PythonTests/modules/io_related/test_io_StringIO.py b/tests/modules/io_related/test_io_StringIO.py similarity index 100% rename from PythonTests/modules/io_related/test_io_StringIO.py rename to tests/modules/io_related/test_io_StringIO.py diff --git a/PythonTests/modules/io_related/test_marshal.py b/tests/modules/io_related/test_marshal.py similarity index 100% rename from PythonTests/modules/io_related/test_marshal.py rename to tests/modules/io_related/test_marshal.py diff --git a/PythonTests/modules/io_related/test_re.py b/tests/modules/io_related/test_re.py similarity index 100% rename from PythonTests/modules/io_related/test_re.py rename to tests/modules/io_related/test_re.py diff --git a/PythonTests/modules/misc/test__opcode.py b/tests/modules/misc/test__opcode.py similarity index 100% rename from PythonTests/modules/misc/test__opcode.py rename to tests/modules/misc/test__opcode.py diff --git a/PythonTests/modules/misc/test__random.py b/tests/modules/misc/test__random.py similarity index 100% rename from PythonTests/modules/misc/test__random.py rename to tests/modules/misc/test__random.py diff --git a/PythonTests/modules/misc/test__sha256.py b/tests/modules/misc/test__sha256.py similarity index 100% rename from PythonTests/modules/misc/test__sha256.py rename to tests/modules/misc/test__sha256.py diff --git a/PythonTests/modules/misc/test__sha512.py b/tests/modules/misc/test__sha512.py similarity index 100% rename from PythonTests/modules/misc/test__sha512.py rename to tests/modules/misc/test__sha512.py diff --git a/PythonTests/modules/misc/test__warnings.py b/tests/modules/misc/test__warnings.py similarity index 100% rename from PythonTests/modules/misc/test__warnings.py rename to tests/modules/misc/test__warnings.py diff --git a/PythonTests/modules/misc/test__weakref.py b/tests/modules/misc/test__weakref.py similarity index 100% rename from PythonTests/modules/misc/test__weakref.py rename to tests/modules/misc/test__weakref.py diff --git a/PythonTests/modules/misc/test_ctypes.py b/tests/modules/misc/test_ctypes.py similarity index 100% rename from PythonTests/modules/misc/test_ctypes.py rename to tests/modules/misc/test_ctypes.py diff --git a/PythonTests/modules/misc/test_datetime.py b/tests/modules/misc/test_datetime.py similarity index 100% rename from PythonTests/modules/misc/test_datetime.py rename to tests/modules/misc/test_datetime.py diff --git a/PythonTests/modules/misc/test_math.py b/tests/modules/misc/test_math.py similarity index 100% rename from PythonTests/modules/misc/test_math.py rename to tests/modules/misc/test_math.py diff --git a/PythonTests/modules/misc/test_operator.py b/tests/modules/misc/test_operator.py similarity index 100% rename from PythonTests/modules/misc/test_operator.py rename to tests/modules/misc/test_operator.py diff --git a/PythonTests/modules/misc/test_system_namespaces.py b/tests/modules/misc/test_system_namespaces.py similarity index 100% rename from PythonTests/modules/misc/test_system_namespaces.py rename to tests/modules/misc/test_system_namespaces.py diff --git a/PythonTests/modules/misc/test_zlib.py b/tests/modules/misc/test_zlib.py similarity index 100% rename from PythonTests/modules/misc/test_zlib.py rename to tests/modules/misc/test_zlib.py diff --git a/PythonTests/modules/network_related/__init__.py b/tests/modules/network_related/__init__.py similarity index 100% rename from PythonTests/modules/network_related/__init__.py rename to tests/modules/network_related/__init__.py diff --git a/Src/StdLib/Lib/test/keycert.pem b/tests/modules/network_related/keycert.pem similarity index 100% rename from Src/StdLib/Lib/test/keycert.pem rename to tests/modules/network_related/keycert.pem diff --git a/PythonTests/modules/network_related/test__socket.py b/tests/modules/network_related/test__socket.py similarity index 100% rename from PythonTests/modules/network_related/test__socket.py rename to tests/modules/network_related/test__socket.py diff --git a/PythonTests/modules/network_related/test__ssl.py b/tests/modules/network_related/test__ssl.py similarity index 100% rename from PythonTests/modules/network_related/test__ssl.py rename to tests/modules/network_related/test__ssl.py diff --git a/PythonTests/modules/system_related/__init__.py b/tests/modules/system_related/__init__.py similarity index 100% rename from PythonTests/modules/system_related/__init__.py rename to tests/modules/system_related/__init__.py diff --git a/PythonTests/modules/system_related/test__locale.py b/tests/modules/system_related/test__locale.py similarity index 100% rename from PythonTests/modules/system_related/test__locale.py rename to tests/modules/system_related/test__locale.py diff --git a/PythonTests/modules/system_related/test_errno.py b/tests/modules/system_related/test_errno.py similarity index 100% rename from PythonTests/modules/system_related/test_errno.py rename to tests/modules/system_related/test_errno.py diff --git a/PythonTests/modules/system_related/test_gc.py b/tests/modules/system_related/test_gc.py similarity index 100% rename from PythonTests/modules/system_related/test_gc.py rename to tests/modules/system_related/test_gc.py diff --git a/PythonTests/modules/system_related/test_nt.py b/tests/modules/system_related/test_nt.py similarity index 100% rename from PythonTests/modules/system_related/test_nt.py rename to tests/modules/system_related/test_nt.py diff --git a/PythonTests/modules/system_related/test_os.py b/tests/modules/system_related/test_os.py similarity index 100% rename from PythonTests/modules/system_related/test_os.py rename to tests/modules/system_related/test_os.py diff --git a/PythonTests/modules/system_related/test_resource.py b/tests/modules/system_related/test_resource.py similarity index 100% rename from PythonTests/modules/system_related/test_resource.py rename to tests/modules/system_related/test_resource.py diff --git a/PythonTests/modules/system_related/test_resource_stdlib.py b/tests/modules/system_related/test_resource_stdlib.py similarity index 100% rename from PythonTests/modules/system_related/test_resource_stdlib.py rename to tests/modules/system_related/test_resource_stdlib.py diff --git a/PythonTests/modules/system_related/test_signal.py b/tests/modules/system_related/test_signal.py similarity index 100% rename from PythonTests/modules/system_related/test_signal.py rename to tests/modules/system_related/test_signal.py diff --git a/PythonTests/modules/system_related/test_sys.py b/tests/modules/system_related/test_sys.py similarity index 100% rename from PythonTests/modules/system_related/test_sys.py rename to tests/modules/system_related/test_sys.py diff --git a/PythonTests/modules/system_related/test_sys_getframe.py b/tests/modules/system_related/test_sys_getframe.py similarity index 100% rename from PythonTests/modules/system_related/test_sys_getframe.py rename to tests/modules/system_related/test_sys_getframe.py diff --git a/PythonTests/modules/system_related/test_thread.py b/tests/modules/system_related/test_thread.py similarity index 100% rename from PythonTests/modules/system_related/test_thread.py rename to tests/modules/system_related/test_thread.py diff --git a/PythonTests/modules/system_related/test_time.py b/tests/modules/system_related/test_time.py similarity index 100% rename from PythonTests/modules/system_related/test_time.py rename to tests/modules/system_related/test_time.py diff --git a/PythonTests/modules/type_related/__init__.py b/tests/modules/type_related/__init__.py similarity index 100% rename from PythonTests/modules/type_related/__init__.py rename to tests/modules/type_related/__init__.py diff --git a/PythonTests/modules/type_related/test__struct.py b/tests/modules/type_related/test__struct.py similarity index 100% rename from PythonTests/modules/type_related/test__struct.py rename to tests/modules/type_related/test__struct.py diff --git a/PythonTests/modules/type_related/test_array.py b/tests/modules/type_related/test_array.py similarity index 100% rename from PythonTests/modules/type_related/test_array.py rename to tests/modules/type_related/test_array.py diff --git a/PythonTests/modules/type_related/test_bitfields_ctypes_stdlib.py b/tests/modules/type_related/test_bitfields_ctypes_stdlib.py similarity index 100% rename from PythonTests/modules/type_related/test_bitfields_ctypes_stdlib.py rename to tests/modules/type_related/test_bitfields_ctypes_stdlib.py diff --git a/PythonTests/modules/type_related/test_ctypes.py b/tests/modules/type_related/test_ctypes.py similarity index 100% rename from PythonTests/modules/type_related/test_ctypes.py rename to tests/modules/type_related/test_ctypes.py diff --git a/PythonTests/modules/type_related/test_types.py b/tests/modules/type_related/test_types.py similarity index 100% rename from PythonTests/modules/type_related/test_types.py rename to tests/modules/type_related/test_types.py diff --git a/PythonTests/perf_micro_calls.py b/tests/perf_micro_calls.py similarity index 100% rename from PythonTests/perf_micro_calls.py rename to tests/perf_micro_calls.py diff --git a/PythonTests/pickles/cp18666.pickle b/tests/pickles/cp18666.pickle similarity index 100% rename from PythonTests/pickles/cp18666.pickle rename to tests/pickles/cp18666.pickle diff --git a/PythonTests/plans/debugging.html b/tests/plans/debugging.html similarity index 100% rename from PythonTests/plans/debugging.html rename to tests/plans/debugging.html diff --git a/PythonTests/plans/debugging.mdbg_tool.html b/tests/plans/debugging.mdbg_tool.html similarity index 100% rename from PythonTests/plans/debugging.mdbg_tool.html rename to tests/plans/debugging.mdbg_tool.html diff --git a/PythonTests/plans/debugging.pdb_mod.html b/tests/plans/debugging.pdb_mod.html similarity index 100% rename from PythonTests/plans/debugging.pdb_mod.html rename to tests/plans/debugging.pdb_mod.html diff --git a/PythonTests/plans/debugging.vs.html b/tests/plans/debugging.vs.html similarity index 100% rename from PythonTests/plans/debugging.vs.html rename to tests/plans/debugging.vs.html diff --git a/PythonTests/plans/generic_plan_template.py b/tests/plans/generic_plan_template.py similarity index 100% rename from PythonTests/plans/generic_plan_template.py rename to tests/plans/generic_plan_template.py diff --git a/PythonTests/plans/interop.net.derivation.html b/tests/plans/interop.net.derivation.html similarity index 100% rename from PythonTests/plans/interop.net.derivation.html rename to tests/plans/interop.net.derivation.html diff --git a/PythonTests/plans/interop.net.derivation.test_ctor_override.html b/tests/plans/interop.net.derivation.test_ctor_override.html similarity index 100% rename from PythonTests/plans/interop.net.derivation.test_ctor_override.html rename to tests/plans/interop.net.derivation.test_ctor_override.html diff --git a/PythonTests/plans/interop.net.derivation.test_event_override.html b/tests/plans/interop.net.derivation.test_event_override.html similarity index 100% rename from PythonTests/plans/interop.net.derivation.test_event_override.html rename to tests/plans/interop.net.derivation.test_event_override.html diff --git a/PythonTests/plans/interop.net.derivation.test_method_override.html b/tests/plans/interop.net.derivation.test_method_override.html similarity index 100% rename from PythonTests/plans/interop.net.derivation.test_method_override.html rename to tests/plans/interop.net.derivation.test_method_override.html diff --git a/PythonTests/plans/interop.net.derivation.test_method_signature.html b/tests/plans/interop.net.derivation.test_method_signature.html similarity index 100% rename from PythonTests/plans/interop.net.derivation.test_method_signature.html rename to tests/plans/interop.net.derivation.test_method_signature.html diff --git a/PythonTests/plans/interop.net.derivation.test_property_override.html b/tests/plans/interop.net.derivation.test_property_override.html similarity index 100% rename from PythonTests/plans/interop.net.derivation.test_property_override.html rename to tests/plans/interop.net.derivation.test_property_override.html diff --git a/PythonTests/plans/interop.net.derivation.test_simplederive.html b/tests/plans/interop.net.derivation.test_simplederive.html similarity index 100% rename from PythonTests/plans/interop.net.derivation.test_simplederive.html rename to tests/plans/interop.net.derivation.test_simplederive.html diff --git a/PythonTests/plans/interop.net.derivation.test_special_method.html b/tests/plans/interop.net.derivation.test_special_method.html similarity index 100% rename from PythonTests/plans/interop.net.derivation.test_special_method.html rename to tests/plans/interop.net.derivation.test_special_method.html diff --git a/PythonTests/plans/interop.net.event.html b/tests/plans/interop.net.event.html similarity index 100% rename from PythonTests/plans/interop.net.event.html rename to tests/plans/interop.net.event.html diff --git a/PythonTests/plans/interop.net.event.test_delegate.html b/tests/plans/interop.net.event.test_delegate.html similarity index 100% rename from PythonTests/plans/interop.net.event.test_delegate.html rename to tests/plans/interop.net.event.test_delegate.html diff --git a/PythonTests/plans/interop.net.event.test_event.html b/tests/plans/interop.net.event.test_event.html similarity index 100% rename from PythonTests/plans/interop.net.event.test_event.html rename to tests/plans/interop.net.event.test_event.html diff --git a/PythonTests/plans/interop.net.field.html b/tests/plans/interop.net.field.html similarity index 100% rename from PythonTests/plans/interop.net.field.html rename to tests/plans/interop.net.field.html diff --git a/PythonTests/plans/interop.net.field.test_field_misc.html b/tests/plans/interop.net.field.test_field_misc.html similarity index 100% rename from PythonTests/plans/interop.net.field.test_field_misc.html rename to tests/plans/interop.net.field.test_field_misc.html diff --git a/PythonTests/plans/interop.net.field.test_fields_inside_enum.html b/tests/plans/interop.net.field.test_fields_inside_enum.html similarity index 100% rename from PythonTests/plans/interop.net.field.test_fields_inside_enum.html rename to tests/plans/interop.net.field.test_fields_inside_enum.html diff --git a/PythonTests/plans/interop.net.html b/tests/plans/interop.net.html similarity index 100% rename from PythonTests/plans/interop.net.html rename to tests/plans/interop.net.html diff --git a/PythonTests/plans/interop.net.insert_csharp.html b/tests/plans/interop.net.insert_csharp.html similarity index 100% rename from PythonTests/plans/interop.net.insert_csharp.html rename to tests/plans/interop.net.insert_csharp.html diff --git a/PythonTests/plans/interop.net.method.html b/tests/plans/interop.net.method.html similarity index 100% rename from PythonTests/plans/interop.net.method.html rename to tests/plans/interop.net.method.html diff --git a/PythonTests/plans/interop.net.method.test_arguments.html b/tests/plans/interop.net.method.test_arguments.html similarity index 100% rename from PythonTests/plans/interop.net.method.test_arguments.html rename to tests/plans/interop.net.method.test_arguments.html diff --git a/PythonTests/plans/interop.net.method.test_op_explicit.html b/tests/plans/interop.net.method.test_op_explicit.html similarity index 100% rename from PythonTests/plans/interop.net.method.test_op_explicit.html rename to tests/plans/interop.net.method.test_op_explicit.html diff --git a/PythonTests/plans/interop.net.method.test_op_implicit.html b/tests/plans/interop.net.method.test_op_implicit.html similarity index 100% rename from PythonTests/plans/interop.net.method.test_op_implicit.html rename to tests/plans/interop.net.method.test_op_implicit.html diff --git a/PythonTests/plans/interop.net.method.test_operators.html b/tests/plans/interop.net.method.test_operators.html similarity index 100% rename from PythonTests/plans/interop.net.method.test_operators.html rename to tests/plans/interop.net.method.test_operators.html diff --git a/PythonTests/plans/interop.net.method.test_returnvalue.html b/tests/plans/interop.net.method.test_returnvalue.html similarity index 100% rename from PythonTests/plans/interop.net.method.test_returnvalue.html rename to tests/plans/interop.net.method.test_returnvalue.html diff --git a/PythonTests/plans/interop.net.property.html b/tests/plans/interop.net.property.html similarity index 100% rename from PythonTests/plans/interop.net.property.html rename to tests/plans/interop.net.property.html diff --git a/PythonTests/plans/interop.net.property.test_indexercs.html b/tests/plans/interop.net.property.test_indexercs.html similarity index 100% rename from PythonTests/plans/interop.net.property.test_indexercs.html rename to tests/plans/interop.net.property.test_indexercs.html diff --git a/PythonTests/plans/interop.net.property.test_indexervb.html b/tests/plans/interop.net.property.test_indexervb.html similarity index 100% rename from PythonTests/plans/interop.net.property.test_indexervb.html rename to tests/plans/interop.net.property.test_indexervb.html diff --git a/PythonTests/plans/interop.net.property.test_property.html b/tests/plans/interop.net.property.test_property.html similarity index 100% rename from PythonTests/plans/interop.net.property.test_property.html rename to tests/plans/interop.net.property.test_property.html diff --git a/PythonTests/plans/interop.net.test_accessibility.html b/tests/plans/interop.net.test_accessibility.html similarity index 100% rename from PythonTests/plans/interop.net.test_accessibility.html rename to tests/plans/interop.net.test_accessibility.html diff --git a/PythonTests/plans/interop.net.test_dynamicobjectmodel.html b/tests/plans/interop.net.test_dynamicobjectmodel.html similarity index 100% rename from PythonTests/plans/interop.net.test_dynamicobjectmodel.html rename to tests/plans/interop.net.test_dynamicobjectmodel.html diff --git a/PythonTests/plans/interop.net.test_loadorder.html b/tests/plans/interop.net.test_loadorder.html similarity index 100% rename from PythonTests/plans/interop.net.test_loadorder.html rename to tests/plans/interop.net.test_loadorder.html diff --git a/PythonTests/plans/interop.net.type.html b/tests/plans/interop.net.type.html similarity index 100% rename from PythonTests/plans/interop.net.type.html rename to tests/plans/interop.net.type.html diff --git a/PythonTests/plans/interop.net.type.test_assembly.html b/tests/plans/interop.net.type.test_assembly.html similarity index 100% rename from PythonTests/plans/interop.net.type.test_assembly.html rename to tests/plans/interop.net.type.test_assembly.html diff --git a/PythonTests/plans/interop.net.type.test_clr_array.html b/tests/plans/interop.net.type.test_clr_array.html similarity index 100% rename from PythonTests/plans/interop.net.type.test_clr_array.html rename to tests/plans/interop.net.type.test_clr_array.html diff --git a/PythonTests/plans/interop.net.type.test_ctor.html b/tests/plans/interop.net.type.test_ctor.html similarity index 100% rename from PythonTests/plans/interop.net.type.test_ctor.html rename to tests/plans/interop.net.type.test_ctor.html diff --git a/PythonTests/plans/interop.net.type.test_defaultmember.html b/tests/plans/interop.net.type.test_defaultmember.html similarity index 100% rename from PythonTests/plans/interop.net.type.test_defaultmember.html rename to tests/plans/interop.net.type.test_defaultmember.html diff --git a/PythonTests/plans/interop.net.type.test_reachtype.html b/tests/plans/interop.net.type.test_reachtype.html similarity index 100% rename from PythonTests/plans/interop.net.type.test_reachtype.html rename to tests/plans/interop.net.type.test_reachtype.html diff --git a/PythonTests/pretest.py b/tests/pretest.py similarity index 100% rename from PythonTests/pretest.py rename to tests/pretest.py diff --git a/PythonTests/pyc/console_hw.py b/tests/pyc/console_hw.py similarity index 100% rename from PythonTests/pyc/console_hw.py rename to tests/pyc/console_hw.py diff --git a/PythonTests/pyc/console_hw_args.py b/tests/pyc/console_hw_args.py similarity index 100% rename from PythonTests/pyc/console_hw_args.py rename to tests/pyc/console_hw_args.py diff --git a/PythonTests/pyc/other_hw.py b/tests/pyc/other_hw.py similarity index 100% rename from PythonTests/pyc/other_hw.py rename to tests/pyc/other_hw.py diff --git a/Src/StdLib/Lib/urllib/__init__.py b/tests/pyc/pkg/__init__.py similarity index 100% rename from Src/StdLib/Lib/urllib/__init__.py rename to tests/pyc/pkg/__init__.py diff --git a/PythonTests/pyc/pkg/a.py b/tests/pyc/pkg/a.py similarity index 100% rename from PythonTests/pyc/pkg/a.py rename to tests/pyc/pkg/a.py diff --git a/PythonTests/pyc/pkg/b.py b/tests/pyc/pkg/b.py similarity index 100% rename from PythonTests/pyc/pkg/b.py rename to tests/pyc/pkg/b.py diff --git a/PythonTests/pyc/pycpkgtest.py b/tests/pyc/pycpkgtest.py similarity index 100% rename from PythonTests/pyc/pycpkgtest.py rename to tests/pyc/pycpkgtest.py diff --git a/PythonTests/pyc/stdmodules_ok.ps1 b/tests/pyc/stdmodules_ok.ps1 similarity index 100% rename from PythonTests/pyc/stdmodules_ok.ps1 rename to tests/pyc/stdmodules_ok.ps1 diff --git a/PythonTests/pyc/test_pyc.ps1 b/tests/pyc/test_pyc.ps1 similarity index 100% rename from PythonTests/pyc/test_pyc.ps1 rename to tests/pyc/test_pyc.ps1 diff --git a/PythonTests/pyc/winforms_hw.py b/tests/pyc/winforms_hw.py similarity index 100% rename from PythonTests/pyc/winforms_hw.py rename to tests/pyc/winforms_hw.py diff --git a/PythonTests/run.py b/tests/run.py similarity index 100% rename from PythonTests/run.py rename to tests/run.py diff --git a/PythonTests/run_transformed.bat b/tests/run_transformed.bat similarity index 100% rename from PythonTests/run_transformed.bat rename to tests/run_transformed.bat diff --git a/PythonTests/sample.txt.gz b/tests/sample.txt.gz similarity index 100% rename from PythonTests/sample.txt.gz rename to tests/sample.txt.gz diff --git a/PythonTests/specialcontext/Consoleless.ps1 b/tests/specialcontext/Consoleless.ps1 similarity index 100% rename from PythonTests/specialcontext/Consoleless.ps1 rename to tests/specialcontext/Consoleless.ps1 diff --git a/PythonTests/specialcontext/verify_ipyw.py b/tests/specialcontext/verify_ipyw.py similarity index 100% rename from PythonTests/specialcontext/verify_ipyw.py rename to tests/specialcontext/verify_ipyw.py diff --git a/PythonTests/stress/__init__.py b/tests/stress/__init__.py similarity index 100% rename from PythonTests/stress/__init__.py rename to tests/stress/__init__.py diff --git a/PythonTests/stress/bigimport1_test.py b/tests/stress/bigimport1_test.py similarity index 100% rename from PythonTests/stress/bigimport1_test.py rename to tests/stress/bigimport1_test.py diff --git a/PythonTests/test_array.py b/tests/test_array.py similarity index 100% rename from PythonTests/test_array.py rename to tests/test_array.py diff --git a/PythonTests/test_assert.py b/tests/test_assert.py similarity index 100% rename from PythonTests/test_assert.py rename to tests/test_assert.py diff --git a/PythonTests/test_ast.py b/tests/test_ast.py similarity index 100% rename from PythonTests/test_ast.py rename to tests/test_ast.py diff --git a/PythonTests/test_attr.py b/tests/test_attr.py similarity index 100% rename from PythonTests/test_attr.py rename to tests/test_attr.py diff --git a/PythonTests/test_attribute_customize.py b/tests/test_attribute_customize.py similarity index 100% rename from PythonTests/test_attribute_customize.py rename to tests/test_attribute_customize.py diff --git a/PythonTests/test_attrinjector.py b/tests/test_attrinjector.py similarity index 100% rename from PythonTests/test_attrinjector.py rename to tests/test_attrinjector.py diff --git a/PythonTests/test_bigint.py b/tests/test_bigint.py similarity index 100% rename from PythonTests/test_bigint.py rename to tests/test_bigint.py diff --git a/PythonTests/test_bool.py b/tests/test_bool.py similarity index 100% rename from PythonTests/test_bool.py rename to tests/test_bool.py diff --git a/PythonTests/test_builtin_stdlib.py b/tests/test_builtin_stdlib.py similarity index 100% rename from PythonTests/test_builtin_stdlib.py rename to tests/test_builtin_stdlib.py diff --git a/PythonTests/test_builtinfunc.py b/tests/test_builtinfunc.py similarity index 100% rename from PythonTests/test_builtinfunc.py rename to tests/test_builtinfunc.py diff --git a/PythonTests/test_bytes.py b/tests/test_bytes.py similarity index 100% rename from PythonTests/test_bytes.py rename to tests/test_bytes.py diff --git a/PythonTests/test_bz2.py b/tests/test_bz2.py similarity index 100% rename from PythonTests/test_bz2.py rename to tests/test_bz2.py diff --git a/PythonTests/test_bz2_stdlib.py b/tests/test_bz2_stdlib.py similarity index 100% rename from PythonTests/test_bz2_stdlib.py rename to tests/test_bz2_stdlib.py diff --git a/PythonTests/test_class.py b/tests/test_class.py similarity index 100% rename from PythonTests/test_class.py rename to tests/test_class.py diff --git a/PythonTests/test_class_stdlib.py b/tests/test_class_stdlib.py similarity index 100% rename from PythonTests/test_class_stdlib.py rename to tests/test_class_stdlib.py diff --git a/PythonTests/test_cliclass.py b/tests/test_cliclass.py similarity index 100% rename from PythonTests/test_cliclass.py rename to tests/test_cliclass.py diff --git a/PythonTests/test_closure.py b/tests/test_closure.py similarity index 100% rename from PythonTests/test_closure.py rename to tests/test_closure.py diff --git a/PythonTests/test_clrexception.py b/tests/test_clrexception.py similarity index 100% rename from PythonTests/test_clrexception.py rename to tests/test_clrexception.py diff --git a/PythonTests/test_clrload.py b/tests/test_clrload.py similarity index 100% rename from PythonTests/test_clrload.py rename to tests/test_clrload.py diff --git a/PythonTests/test_clrload2.py b/tests/test_clrload2.py similarity index 100% rename from PythonTests/test_clrload2.py rename to tests/test_clrload2.py diff --git a/PythonTests/test_clrnuminterop.py b/tests/test_clrnuminterop.py similarity index 100% rename from PythonTests/test_clrnuminterop.py rename to tests/test_clrnuminterop.py diff --git a/PythonTests/test_clrtype.py b/tests/test_clrtype.py similarity index 100% rename from PythonTests/test_clrtype.py rename to tests/test_clrtype.py diff --git a/PythonTests/test_clruse.py b/tests/test_clruse.py similarity index 100% rename from PythonTests/test_clruse.py rename to tests/test_clruse.py diff --git a/PythonTests/test_codeccallbacks_stdlib.py b/tests/test_codeccallbacks_stdlib.py similarity index 100% rename from PythonTests/test_codeccallbacks_stdlib.py rename to tests/test_codeccallbacks_stdlib.py diff --git a/PythonTests/test_codecs.py b/tests/test_codecs.py similarity index 100% rename from PythonTests/test_codecs.py rename to tests/test_codecs.py diff --git a/PythonTests/test_codecs_stdlib.py b/tests/test_codecs_stdlib.py similarity index 100% rename from PythonTests/test_codecs_stdlib.py rename to tests/test_codecs_stdlib.py diff --git a/PythonTests/test_compiler.py b/tests/test_compiler.py similarity index 100% rename from PythonTests/test_compiler.py rename to tests/test_compiler.py diff --git a/PythonTests/test_complex.py b/tests/test_complex.py similarity index 100% rename from PythonTests/test_complex.py rename to tests/test_complex.py diff --git a/PythonTests/test_complex_stdlib.py b/tests/test_complex_stdlib.py similarity index 100% rename from PythonTests/test_complex_stdlib.py rename to tests/test_complex_stdlib.py diff --git a/PythonTests/test_conditional.py b/tests/test_conditional.py similarity index 100% rename from PythonTests/test_conditional.py rename to tests/test_conditional.py diff --git a/PythonTests/test_data.gz b/tests/test_data.gz similarity index 100% rename from PythonTests/test_data.gz rename to tests/test_data.gz diff --git a/PythonTests/test_datetime.py b/tests/test_datetime.py similarity index 100% rename from PythonTests/test_datetime.py rename to tests/test_datetime.py diff --git a/PythonTests/test_datetime_stdlib.py b/tests/test_datetime_stdlib.py similarity index 100% rename from PythonTests/test_datetime_stdlib.py rename to tests/test_datetime_stdlib.py diff --git a/PythonTests/test_decimal.py b/tests/test_decimal.py similarity index 100% rename from PythonTests/test_decimal.py rename to tests/test_decimal.py diff --git a/PythonTests/test_decorator.py b/tests/test_decorator.py similarity index 100% rename from PythonTests/test_decorator.py rename to tests/test_decorator.py diff --git a/PythonTests/test_delegate.py b/tests/test_delegate.py similarity index 100% rename from PythonTests/test_delegate.py rename to tests/test_delegate.py diff --git a/PythonTests/test_deque.py b/tests/test_deque.py similarity index 100% rename from PythonTests/test_deque.py rename to tests/test_deque.py diff --git a/PythonTests/test_descr_stdlib.py b/tests/test_descr_stdlib.py similarity index 100% rename from PythonTests/test_descr_stdlib.py rename to tests/test_descr_stdlib.py diff --git a/PythonTests/test_dict.py b/tests/test_dict.py similarity index 100% rename from PythonTests/test_dict.py rename to tests/test_dict.py diff --git a/PythonTests/test_dict_stdlib.py b/tests/test_dict_stdlib.py similarity index 100% rename from PythonTests/test_dict_stdlib.py rename to tests/test_dict_stdlib.py diff --git a/PythonTests/test_dictcomp.py b/tests/test_dictcomp.py similarity index 100% rename from PythonTests/test_dictcomp.py rename to tests/test_dictcomp.py diff --git a/PythonTests/test_dllsite.py b/tests/test_dllsite.py similarity index 100% rename from PythonTests/test_dllsite.py rename to tests/test_dllsite.py diff --git a/PythonTests/test_dlrkwarg.py b/tests/test_dlrkwarg.py similarity index 100% rename from PythonTests/test_dlrkwarg.py rename to tests/test_dlrkwarg.py diff --git a/PythonTests/test_doc.py b/tests/test_doc.py similarity index 100% rename from PythonTests/test_doc.py rename to tests/test_doc.py diff --git a/PythonTests/test_enum.py b/tests/test_enum.py similarity index 100% rename from PythonTests/test_enum.py rename to tests/test_enum.py diff --git a/PythonTests/test_exceptions.py b/tests/test_exceptions.py similarity index 100% rename from PythonTests/test_exceptions.py rename to tests/test_exceptions.py diff --git a/PythonTests/test_exceptions_generated.py b/tests/test_exceptions_generated.py similarity index 100% rename from PythonTests/test_exceptions_generated.py rename to tests/test_exceptions_generated.py diff --git a/PythonTests/test_excinfo.py b/tests/test_excinfo.py similarity index 100% rename from PythonTests/test_excinfo.py rename to tests/test_excinfo.py diff --git a/PythonTests/test_exec.py b/tests/test_exec.py similarity index 100% rename from PythonTests/test_exec.py rename to tests/test_exec.py diff --git a/PythonTests/test_file.py b/tests/test_file.py similarity index 100% rename from PythonTests/test_file.py rename to tests/test_file.py diff --git a/PythonTests/test_float_stdlib.py b/tests/test_float_stdlib.py similarity index 100% rename from PythonTests/test_float_stdlib.py rename to tests/test_float_stdlib.py diff --git a/PythonTests/test_formatting.py b/tests/test_formatting.py similarity index 100% rename from PythonTests/test_formatting.py rename to tests/test_formatting.py diff --git a/PythonTests/test_function.py b/tests/test_function.py similarity index 100% rename from PythonTests/test_function.py rename to tests/test_function.py diff --git a/PythonTests/test_functools_stdlib.py b/tests/test_functools_stdlib.py similarity index 100% rename from PythonTests/test_functools_stdlib.py rename to tests/test_functools_stdlib.py diff --git a/PythonTests/test_fuzz_parser.py b/tests/test_fuzz_parser.py similarity index 100% rename from PythonTests/test_fuzz_parser.py rename to tests/test_fuzz_parser.py diff --git a/PythonTests/test_generator.py b/tests/test_generator.py similarity index 100% rename from PythonTests/test_generator.py rename to tests/test_generator.py diff --git a/PythonTests/test_generator_throw.py b/tests/test_generator_throw.py similarity index 100% rename from PythonTests/test_generator_throw.py rename to tests/test_generator_throw.py diff --git a/PythonTests/test_genericmeth.py b/tests/test_genericmeth.py similarity index 100% rename from PythonTests/test_genericmeth.py rename to tests/test_genericmeth.py diff --git a/PythonTests/test_hash.py b/tests/test_hash.py similarity index 100% rename from PythonTests/test_hash.py rename to tests/test_hash.py diff --git a/PythonTests/test_help.py b/tests/test_help.py similarity index 100% rename from PythonTests/test_help.py rename to tests/test_help.py diff --git a/PythonTests/test_httplib_stdlib.py b/tests/test_httplib_stdlib.py similarity index 100% rename from PythonTests/test_httplib_stdlib.py rename to tests/test_httplib_stdlib.py diff --git a/PythonTests/test_imp.py b/tests/test_imp.py similarity index 100% rename from PythonTests/test_imp.py rename to tests/test_imp.py diff --git a/PythonTests/test_importext.py b/tests/test_importext.py similarity index 100% rename from PythonTests/test_importext.py rename to tests/test_importext.py diff --git a/PythonTests/test_importpkg.py b/tests/test_importpkg.py similarity index 100% rename from PythonTests/test_importpkg.py rename to tests/test_importpkg.py diff --git a/PythonTests/test_in.py b/tests/test_in.py similarity index 100% rename from PythonTests/test_in.py rename to tests/test_in.py diff --git a/PythonTests/test_index.py b/tests/test_index.py similarity index 100% rename from PythonTests/test_index.py rename to tests/test_index.py diff --git a/PythonTests/test_inheritance.py b/tests/test_inheritance.py similarity index 100% rename from PythonTests/test_inheritance.py rename to tests/test_inheritance.py diff --git a/PythonTests/test_int.py b/tests/test_int.py similarity index 100% rename from PythonTests/test_int.py rename to tests/test_int.py diff --git a/PythonTests/test_interactive.py b/tests/test_interactive.py similarity index 100% rename from PythonTests/test_interactive.py rename to tests/test_interactive.py diff --git a/PythonTests/test_io.py b/tests/test_io.py similarity index 100% rename from PythonTests/test_io.py rename to tests/test_io.py diff --git a/PythonTests/test_io_stdlib.py b/tests/test_io_stdlib.py similarity index 100% rename from PythonTests/test_io_stdlib.py rename to tests/test_io_stdlib.py diff --git a/PythonTests/test_ipyc.py b/tests/test_ipyc.py similarity index 100% rename from PythonTests/test_ipyc.py rename to tests/test_ipyc.py diff --git a/PythonTests/test_ipye.py b/tests/test_ipye.py similarity index 100% rename from PythonTests/test_ipye.py rename to tests/test_ipye.py diff --git a/PythonTests/test_ironmath.py b/tests/test_ironmath.py similarity index 100% rename from PythonTests/test_ironmath.py rename to tests/test_ironmath.py diff --git a/PythonTests/test_is.py b/tests/test_is.py similarity index 100% rename from PythonTests/test_is.py rename to tests/test_is.py diff --git a/PythonTests/test_isinstance.py b/tests/test_isinstance.py similarity index 100% rename from PythonTests/test_isinstance.py rename to tests/test_isinstance.py diff --git a/PythonTests/test_isinstance2.py b/tests/test_isinstance2.py similarity index 100% rename from PythonTests/test_isinstance2.py rename to tests/test_isinstance2.py diff --git a/PythonTests/test_iterator.py b/tests/test_iterator.py similarity index 100% rename from PythonTests/test_iterator.py rename to tests/test_iterator.py diff --git a/PythonTests/test_iteratorlength.py b/tests/test_iteratorlength.py similarity index 100% rename from PythonTests/test_iteratorlength.py rename to tests/test_iteratorlength.py diff --git a/PythonTests/test_itertools_stdlib.py b/tests/test_itertools_stdlib.py similarity index 100% rename from PythonTests/test_itertools_stdlib.py rename to tests/test_itertools_stdlib.py diff --git a/PythonTests/test_json.py b/tests/test_json.py similarity index 100% rename from PythonTests/test_json.py rename to tests/test_json.py diff --git a/PythonTests/test_kwarg.py b/tests/test_kwarg.py similarity index 100% rename from PythonTests/test_kwarg.py rename to tests/test_kwarg.py diff --git a/PythonTests/test_list.py b/tests/test_list.py similarity index 100% rename from PythonTests/test_list.py rename to tests/test_list.py diff --git a/PythonTests/test_listcomp.py b/tests/test_listcomp.py similarity index 100% rename from PythonTests/test_listcomp.py rename to tests/test_listcomp.py diff --git a/PythonTests/test_long_stdlib.py b/tests/test_long_stdlib.py similarity index 100% rename from PythonTests/test_long_stdlib.py rename to tests/test_long_stdlib.py diff --git a/PythonTests/test_memory.py b/tests/test_memory.py similarity index 100% rename from PythonTests/test_memory.py rename to tests/test_memory.py diff --git a/PythonTests/test_memoryio_stdlib.py b/tests/test_memoryio_stdlib.py similarity index 100% rename from PythonTests/test_memoryio_stdlib.py rename to tests/test_memoryio_stdlib.py diff --git a/PythonTests/test_memoryview.py b/tests/test_memoryview.py similarity index 100% rename from PythonTests/test_memoryview.py rename to tests/test_memoryview.py diff --git a/PythonTests/test_metaclass.py b/tests/test_metaclass.py similarity index 100% rename from PythonTests/test_metaclass.py rename to tests/test_metaclass.py diff --git a/PythonTests/test_methodbinder1.py b/tests/test_methodbinder1.py similarity index 100% rename from PythonTests/test_methodbinder1.py rename to tests/test_methodbinder1.py diff --git a/PythonTests/test_methodbinder2.py b/tests/test_methodbinder2.py similarity index 100% rename from PythonTests/test_methodbinder2.py rename to tests/test_methodbinder2.py diff --git a/PythonTests/test_methoddispatch.py b/tests/test_methoddispatch.py similarity index 100% rename from PythonTests/test_methoddispatch.py rename to tests/test_methoddispatch.py diff --git a/PythonTests/test_missing.py b/tests/test_missing.py similarity index 100% rename from PythonTests/test_missing.py rename to tests/test_missing.py diff --git a/PythonTests/test_namebinding.py b/tests/test_namebinding.py similarity index 100% rename from PythonTests/test_namebinding.py rename to tests/test_namebinding.py diff --git a/PythonTests/test_nonetype.py b/tests/test_nonetype.py similarity index 100% rename from PythonTests/test_nonetype.py rename to tests/test_nonetype.py diff --git a/PythonTests/test_nonlocal.py b/tests/test_nonlocal.py similarity index 100% rename from PythonTests/test_nonlocal.py rename to tests/test_nonlocal.py diff --git a/PythonTests/test_number.py b/tests/test_number.py similarity index 100% rename from PythonTests/test_number.py rename to tests/test_number.py diff --git a/PythonTests/test_numberhash.py b/tests/test_numberhash.py similarity index 100% rename from PythonTests/test_numberhash.py rename to tests/test_numberhash.py diff --git a/PythonTests/test_numtypes.py b/tests/test_numtypes.py similarity index 100% rename from PythonTests/test_numtypes.py rename to tests/test_numtypes.py diff --git a/PythonTests/test_pep380_stdlib.py b/tests/test_pep380_stdlib.py similarity index 100% rename from PythonTests/test_pep380_stdlib.py rename to tests/test_pep380_stdlib.py diff --git a/PythonTests/test_peverify.py b/tests/test_peverify.py similarity index 100% rename from PythonTests/test_peverify.py rename to tests/test_peverify.py diff --git a/PythonTests/test_pow.py b/tests/test_pow.py similarity index 100% rename from PythonTests/test_pow.py rename to tests/test_pow.py diff --git a/PythonTests/test_privateBinding.py b/tests/test_privateBinding.py similarity index 100% rename from PythonTests/test_privateBinding.py rename to tests/test_privateBinding.py diff --git a/PythonTests/test_property.py b/tests/test_property.py similarity index 100% rename from PythonTests/test_property.py rename to tests/test_property.py diff --git a/PythonTests/test_protected.py b/tests/test_protected.py similarity index 100% rename from PythonTests/test_protected.py rename to tests/test_protected.py diff --git a/PythonTests/test_pyexpat.py b/tests/test_pyexpat.py similarity index 100% rename from PythonTests/test_pyexpat.py rename to tests/test_pyexpat.py diff --git a/PythonTests/test_python25.py b/tests/test_python25.py similarity index 100% rename from PythonTests/test_python25.py rename to tests/test_python25.py diff --git a/PythonTests/test_python26.py b/tests/test_python26.py similarity index 100% rename from PythonTests/test_python26.py rename to tests/test_python26.py diff --git a/PythonTests/test_range.py b/tests/test_range.py similarity index 100% rename from PythonTests/test_range.py rename to tests/test_range.py diff --git a/PythonTests/test_re_stdlib.py b/tests/test_re_stdlib.py similarity index 100% rename from PythonTests/test_re_stdlib.py rename to tests/test_re_stdlib.py diff --git a/PythonTests/test_regressions.py b/tests/test_regressions.py similarity index 100% rename from PythonTests/test_regressions.py rename to tests/test_regressions.py diff --git a/PythonTests/test_regressions_compiled.py b/tests/test_regressions_compiled.py similarity index 100% rename from PythonTests/test_regressions_compiled.py rename to tests/test_regressions_compiled.py diff --git a/PythonTests/test_sax_stdlib.py b/tests/test_sax_stdlib.py similarity index 100% rename from PythonTests/test_sax_stdlib.py rename to tests/test_sax_stdlib.py diff --git a/PythonTests/test_scope_stdlib.py b/tests/test_scope_stdlib.py similarity index 100% rename from PythonTests/test_scope_stdlib.py rename to tests/test_scope_stdlib.py diff --git a/PythonTests/test_set.py b/tests/test_set.py similarity index 100% rename from PythonTests/test_set.py rename to tests/test_set.py diff --git a/PythonTests/test_setcomp.py b/tests/test_setcomp.py similarity index 100% rename from PythonTests/test_setcomp.py rename to tests/test_setcomp.py diff --git a/PythonTests/test_shutil.py b/tests/test_shutil.py similarity index 100% rename from PythonTests/test_shutil.py rename to tests/test_shutil.py diff --git a/PythonTests/test_slice.py b/tests/test_slice.py similarity index 100% rename from PythonTests/test_slice.py rename to tests/test_slice.py diff --git a/PythonTests/test_slots.py b/tests/test_slots.py similarity index 100% rename from PythonTests/test_slots.py rename to tests/test_slots.py diff --git a/PythonTests/test_socket_stdlib.py b/tests/test_socket_stdlib.py similarity index 100% rename from PythonTests/test_socket_stdlib.py rename to tests/test_socket_stdlib.py diff --git a/PythonTests/test_specialcontext.py b/tests/test_specialcontext.py similarity index 100% rename from PythonTests/test_specialcontext.py rename to tests/test_specialcontext.py diff --git a/PythonTests/test_sqlite3_stdlib.py b/tests/test_sqlite3_stdlib.py similarity index 100% rename from PythonTests/test_sqlite3_stdlib.py rename to tests/test_sqlite3_stdlib.py diff --git a/PythonTests/test_ssl_stdlib.py b/tests/test_ssl_stdlib.py similarity index 100% rename from PythonTests/test_ssl_stdlib.py rename to tests/test_ssl_stdlib.py diff --git a/PythonTests/test_statics.py b/tests/test_statics.py similarity index 100% rename from PythonTests/test_statics.py rename to tests/test_statics.py diff --git a/PythonTests/test_stdconsole.py b/tests/test_stdconsole.py similarity index 100% rename from PythonTests/test_stdconsole.py rename to tests/test_stdconsole.py diff --git a/PythonTests/test_stdmodules.py b/tests/test_stdmodules.py similarity index 100% rename from PythonTests/test_stdmodules.py rename to tests/test_stdmodules.py diff --git a/PythonTests/test_str.py b/tests/test_str.py similarity index 100% rename from PythonTests/test_str.py rename to tests/test_str.py diff --git a/PythonTests/test_str_bytes.py b/tests/test_str_bytes.py similarity index 100% rename from PythonTests/test_str_bytes.py rename to tests/test_str_bytes.py diff --git a/PythonTests/test_strformat.py b/tests/test_strformat.py similarity index 100% rename from PythonTests/test_strformat.py rename to tests/test_strformat.py diff --git a/PythonTests/test_struct.py b/tests/test_struct.py similarity index 100% rename from PythonTests/test_struct.py rename to tests/test_struct.py diff --git a/PythonTests/test_struct_stdlib.py b/tests/test_struct_stdlib.py similarity index 100% rename from PythonTests/test_struct_stdlib.py rename to tests/test_struct_stdlib.py diff --git a/PythonTests/test_struct_threadsafe.py b/tests/test_struct_threadsafe.py similarity index 100% rename from PythonTests/test_struct_threadsafe.py rename to tests/test_struct_threadsafe.py diff --git a/PythonTests/test_super.py b/tests/test_super.py similarity index 100% rename from PythonTests/test_super.py rename to tests/test_super.py diff --git a/PythonTests/test_superconsole.py b/tests/test_superconsole.py similarity index 100% rename from PythonTests/test_superconsole.py rename to tests/test_superconsole.py diff --git a/PythonTests/test_surrogateescape.py b/tests/test_surrogateescape.py similarity index 100% rename from PythonTests/test_surrogateescape.py rename to tests/test_surrogateescape.py diff --git a/PythonTests/test_surrogateescape_pythonfuture.py b/tests/test_surrogateescape_pythonfuture.py similarity index 100% rename from PythonTests/test_surrogateescape_pythonfuture.py rename to tests/test_surrogateescape_pythonfuture.py diff --git a/PythonTests/test_surrogatepass.py b/tests/test_surrogatepass.py similarity index 100% rename from PythonTests/test_surrogatepass.py rename to tests/test_surrogatepass.py diff --git a/PythonTests/test_syntax.py b/tests/test_syntax.py similarity index 100% rename from PythonTests/test_syntax.py rename to tests/test_syntax.py diff --git a/PythonTests/test_sys_stdlib.py b/tests/test_sys_stdlib.py similarity index 100% rename from PythonTests/test_sys_stdlib.py rename to tests/test_sys_stdlib.py diff --git a/PythonTests/test_system_timers.py b/tests/test_system_timers.py similarity index 100% rename from PythonTests/test_system_timers.py rename to tests/test_system_timers.py diff --git a/PythonTests/test_tcf.py b/tests/test_tcf.py similarity index 100% rename from PythonTests/test_tcf.py rename to tests/test_tcf.py diff --git a/PythonTests/test_threadsafety.py b/tests/test_threadsafety.py similarity index 100% rename from PythonTests/test_threadsafety.py rename to tests/test_threadsafety.py diff --git a/PythonTests/test_time_stdlib.py b/tests/test_time_stdlib.py similarity index 100% rename from PythonTests/test_time_stdlib.py rename to tests/test_time_stdlib.py diff --git a/PythonTests/test_traceback.py b/tests/test_traceback.py similarity index 100% rename from PythonTests/test_traceback.py rename to tests/test_traceback.py diff --git a/PythonTests/test_tuple.py b/tests/test_tuple.py similarity index 100% rename from PythonTests/test_tuple.py rename to tests/test_tuple.py diff --git a/PythonTests/test_types_stdlib.py b/tests/test_types_stdlib.py similarity index 100% rename from PythonTests/test_types_stdlib.py rename to tests/test_types_stdlib.py diff --git a/PythonTests/test_typing_stdlib.py b/tests/test_typing_stdlib.py similarity index 100% rename from PythonTests/test_typing_stdlib.py rename to tests/test_typing_stdlib.py diff --git a/PythonTests/test_unicode.py b/tests/test_unicode.py similarity index 100% rename from PythonTests/test_unicode.py rename to tests/test_unicode.py diff --git a/PythonTests/test_unicode_stdlib.py b/tests/test_unicode_stdlib.py similarity index 100% rename from PythonTests/test_unicode_stdlib.py rename to tests/test_unicode_stdlib.py diff --git a/PythonTests/test_unpack.py b/tests/test_unpack.py similarity index 100% rename from PythonTests/test_unpack.py rename to tests/test_unpack.py diff --git a/PythonTests/test_utf8_mode_stdlib.py b/tests/test_utf8_mode_stdlib.py similarity index 100% rename from PythonTests/test_utf8_mode_stdlib.py rename to tests/test_utf8_mode_stdlib.py diff --git a/PythonTests/test_weakref.py b/tests/test_weakref.py similarity index 100% rename from PythonTests/test_weakref.py rename to tests/test_weakref.py diff --git a/PythonTests/test_weakset_stdlib.py b/tests/test_weakset_stdlib.py similarity index 100% rename from PythonTests/test_weakset_stdlib.py rename to tests/test_weakset_stdlib.py diff --git a/PythonTests/test_winforms.py b/tests/test_winforms.py similarity index 100% rename from PythonTests/test_winforms.py rename to tests/test_winforms.py diff --git a/PythonTests/test_with.py b/tests/test_with.py similarity index 100% rename from PythonTests/test_with.py rename to tests/test_with.py diff --git a/PythonTests/test_zipimport.py b/tests/test_zipimport.py similarity index 100% rename from PythonTests/test_zipimport.py rename to tests/test_zipimport.py diff --git a/PythonTests/testpkg1/__init__.py b/tests/testpkg1/__init__.py similarity index 100% rename from PythonTests/testpkg1/__init__.py rename to tests/testpkg1/__init__.py diff --git a/PythonTests/testpkg1/mod1.py b/tests/testpkg1/mod1.py similarity index 100% rename from PythonTests/testpkg1/mod1.py rename to tests/testpkg1/mod1.py diff --git a/PythonTests/timeit.py b/tests/timeit.py similarity index 100% rename from PythonTests/timeit.py rename to tests/timeit.py diff --git a/PythonTests/toimport.py b/tests/toimport.py similarity index 100% rename from PythonTests/toimport.py rename to tests/toimport.py diff --git a/PythonTests/transform.py b/tests/transform.py similarity index 100% rename from PythonTests/transform.py rename to tests/transform.py From 571f43a3646172b374290315a02dcb4260b3c52d Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 17:18:59 +0000 Subject: [PATCH 15/84] Rename `GetRenamed` directories --- {Src.GetRenamed => src}/App.Debug.config | 0 {Src.GetRenamed => src}/App.Release.config | 0 {Src.GetRenamed => src}/CTypes/Makefile | 0 {Src.GetRenamed => src}/CTypes/_ctypes_test.c | 0 {Src.GetRenamed => src}/CTypes/_ctypes_test.sln | 0 {Src.GetRenamed => src}/CTypes/_ctypes_test.vcxproj | 0 .../CompilerServices/AssemblyResolver.cs | 0 {Src.GetRenamed => src}/CompilerServices/Config.cs | 0 .../CompilerServices/ConsoleOps.cs | 0 .../IronPython.CompilerServices.csproj | 0 {Src.GetRenamed => src}/CompilerServices/Program.cs | 0 .../CompilerServices/Properties/AssemblyInfo.cs | 0 {Src.GetRenamed => src}/CompilerServices/README.md | 0 .../Console.Host/IronPython.Console.Host.csproj | 0 .../Console.Host/IronPythonWindow.cs | 0 .../Console.Host/Properties/AssemblyInfo.cs | 0 {Src.GetRenamed => src}/Console.Host/ipyw.ico | Bin {Src.GetRenamed => src}/Console/Console.cs | 0 .../Console/IronPython.Console.csproj | 0 .../Console/Properties/AssemblyInfo.cs | 0 {Src.GetRenamed => src}/Console/app.manifest | 0 {Src.GetRenamed => src}/Console/ipy-mono.sh | 0 {Src.GetRenamed => src}/Console/ipy.ico | Bin {Src.GetRenamed => src}/Console/ipy.sh | 0 .../Console/runtimeconfig.template.json | 0 .../Console32.Host/IronPython.Console32.Host.csproj | 0 .../Console32/IronPython.Console32.csproj | 0 .../DiagnosticAnalyzer/Analyzer.cs | 0 .../DiagnosticAnalyzer/Directory.Build.props | 0 .../IronPython.DiagnosticAnalyzer.csproj | 0 .../IronPython/Compiler/Ast/AndExpression.cs | 0 .../Compiler/Ast/AnnotatedAssignStatement.cs | 0 .../IronPython/Compiler/Ast/AssertStatement.cs | 0 .../IronPython/Compiler/Ast/AssignmentStatement.cs | 0 .../IronPython/Compiler/Ast/AstMethods.cs | 0 .../IronPython/Compiler/Ast/AsyncStatement.cs | 0 .../Compiler/Ast/AugmentedAssignStatement.cs | 0 .../Compiler/Ast/BinaryExpression.Generated.cs | 0 .../IronPython/Compiler/Ast/BinaryExpression.cs | 0 .../IronPython/Compiler/Ast/BreakStatement.cs | 0 .../IronPython/Compiler/Ast/CallExpression.cs | 0 .../IronPython/Compiler/Ast/ClassDefinition.cs | 0 .../IronPython/Compiler/Ast/Comprehension.cs | 0 .../IronPython/Compiler/Ast/ComprehensionFor.cs | 0 .../IronPython/Compiler/Ast/ComprehensionIf.cs | 0 .../Compiler/Ast/ConditionalExpression.cs | 0 .../IronPython/Compiler/Ast/ConstantExpression.cs | 0 .../IronPython/Compiler/Ast/ContinueStatement.cs | 0 .../IronPython/Compiler/Ast/DelStatement.cs | 0 .../IronPython/Compiler/Ast/DictionaryExpression.cs | 0 .../IronPython/Compiler/Ast/DottedName.cs | 0 .../Compiler/Ast/DynamicConvertExpression.cs | 0 .../Compiler/Ast/DynamicGetMemberExpression.cs | 0 .../IronPython/Compiler/Ast/EmptyStatement.cs | 0 .../IronPython/Compiler/Ast/ErrorExpression.cs | 0 .../IronPython/Compiler/Ast/Expression.cs | 0 .../IronPython/Compiler/Ast/ExpressionStatement.cs | 0 .../IronPython/Compiler/Ast/FlowChecker.cs | 0 .../IronPython/Compiler/Ast/ForStatement.cs | 0 .../Compiler/Ast/FormattedValueExpression.cs | 0 .../IronPython/Compiler/Ast/FromImportStatement.cs | 0 .../IronPython/Compiler/Ast/FunctionDefinition.cs | 0 .../IronPython/Compiler/Ast/GeneratorExpression.cs | 0 .../Compiler/Ast/GetGlobalContextExpression.cs | 0 .../Ast/GetParentContextFromFunctionExpression.cs | 0 .../IronPython/Compiler/Ast/GlobalStatement.cs | 0 .../IronPython/Compiler/Ast/ILoopStatement.cs | 0 .../IronPython/Compiler/Ast/IfStatement.cs | 0 .../IronPython/Compiler/Ast/IfStatementTest.cs | 0 .../IronPython/Compiler/Ast/ImportStatement.cs | 0 .../IronPython/Compiler/Ast/IndexExpression.cs | 0 .../Compiler/Ast/JoinedStringExpression.cs | 0 .../IronPython/Compiler/Ast/Keyword.cs | 0 .../IronPython/Compiler/Ast/LambdaExpression.cs | 0 .../IronPython/Compiler/Ast/ListExpression.cs | 0 .../IronPython/Compiler/Ast/MemberExpression.cs | 0 .../IronPython/Compiler/Ast/ModuleName.cs | 0 .../IronPython/Compiler/Ast/NameExpression.cs | 0 .../IronPython/Compiler/Ast/Node.cs | 0 .../IronPython/Compiler/Ast/NonlocalStatement.cs | 0 .../IronPython/Compiler/Ast/OrExpression.cs | 0 .../IronPython/Compiler/Ast/Parameter.cs | 0 .../Compiler/Ast/ParenthesisExpression.cs | 0 .../IronPython/Compiler/Ast/PythonAst.cs | 0 .../Compiler/Ast/PythonConstantExpression.cs | 0 .../IronPython/Compiler/Ast/PythonNameBinder.cs | 0 .../IronPython/Compiler/Ast/PythonReference.cs | 0 .../IronPython/Compiler/Ast/PythonVariable.cs | 0 .../Compiler/Ast/PythonWalker.Generated.cs | 0 .../IronPython/Compiler/Ast/RaiseStatement.cs | 0 .../IronPython/Compiler/Ast/RelativeModuleName.cs | 0 .../IronPython/Compiler/Ast/ReturnStatement.cs | 0 .../IronPython/Compiler/Ast/ScopeStatement.cs | 0 .../IronPython/Compiler/Ast/SequenceExpression.cs | 0 .../Compiler/Ast/SerializedScopeStatement.cs | 0 .../IronPython/Compiler/Ast/SetExpression.cs | 0 .../IronPython/Compiler/Ast/SliceExpression.cs | 0 .../IronPython/Compiler/Ast/StarredExpression.cs | 0 .../IronPython/Compiler/Ast/Statement.cs | 0 .../IronPython/Compiler/Ast/SuiteStatement.cs | 0 .../IronPython/Compiler/Ast/TryStatement.cs | 0 .../IronPython/Compiler/Ast/TupleExpression.cs | 0 .../IronPython/Compiler/Ast/UnaryExpression.cs | 0 .../IronPython/Compiler/Ast/VariableKind.cs | 0 .../IronPython/Compiler/Ast/WhileStatement.cs | 0 .../IronPython/Compiler/Ast/WithStatement.cs | 0 .../IronPython/Compiler/Ast/YieldExpression.cs | 0 .../IronPython/Compiler/Ast/YieldFromExpression.cs | 0 .../IronPython/Compiler/ClosureExpression.cs | 0 .../IronPython/Compiler/ClosureInfo.cs | 0 .../Compiler/CollectableCompilationMode.cs | 0 .../IronPython/Compiler/CompilationMode.cs | 0 .../IronPython/Compiler/GeneratorRewriter.cs | 0 .../IronPython/Compiler/LazyCode.cs | 0 .../IronPython/Compiler/LookupCompilationMode.cs | 0 .../IronPython/Compiler/OnDiskScriptCode.cs | 0 .../IronPython/Compiler/Parser.cs | 0 .../IronPython/Compiler/PythonCallTargets.cs | 0 .../IronPython/Compiler/PythonCompilerOptions.cs | 0 .../IronPython/Compiler/PythonDynamicExpression.cs | 0 .../IronPython/Compiler/PythonGlobal.cs | 0 .../Compiler/PythonGlobalVariableExpression.cs | 0 .../IronPython/Compiler/PythonOperator.cs | 0 .../IronPython/Compiler/PythonSavableScriptCode.cs | 0 .../IronPython/Compiler/PythonScriptCode.cs | 0 .../Compiler/ReducableDynamicExpression.cs | 0 .../IronPython/Compiler/RunnableScriptCode.cs | 0 .../IronPython/Compiler/RuntimeScriptCode.cs | 0 .../IronPython/Compiler/ToDiskCompilationMode.cs | 0 .../IronPython/Compiler/Token.cs | 0 .../IronPython/Compiler/TokenKind.Generated.cs | 0 .../IronPython/Compiler/Tokenizer.Generated.cs | 0 .../IronPython/Compiler/Tokenizer.cs | 0 .../UncollectableCompilationMode.Generated.cs | 0 .../Compiler/UncollectableCompilationMode.cs | 0 .../IronPython/FakeInteropServices.cs | 0 .../IronPython/Hosting/Python.cs | 0 .../IronPython/Hosting/PythonCodeDomCodeGen.cs | 0 .../IronPython/Hosting/PythonCommandLine.cs | 0 .../IronPython/Hosting/PythonConsoleOptions.cs | 0 .../IronPython/Hosting/PythonOptionsParser.cs | 0 .../IronPython/Hosting/PythonService.cs | 0 .../IronPython/Interop/Windows/Interop.Libraries.cs | 0 .../Windows/Kernel32/Interop.GetWindowsExW.cs | 0 .../Windows/Kernel32/Interop.OSVERSIONINFOEX.cs | 0 .../Interop/Windows/NtDll/Interop.RtlGetVersion.cs | 0 .../Interop/Windows/Ucrtbase/Interop.strerror.cs | 0 .../IronPython/IronPython.csproj | 0 .../IronPython/Lib/iptest/__init__.py | 0 .../IronPython/Lib/iptest/cominterop_util.py | 0 .../IronPython/Lib/iptest/console_util.py | 0 .../IronPython/Lib/iptest/file_util.py | 0 .../IronPython/Lib/iptest/ipunittest.py | 0 .../IronPython/Lib/iptest/misc_util.py | 0 .../IronPython/Lib/iptest/process_util.py | 0 .../IronPython/Lib/iptest/runner.py | 0 .../IronPython/Lib/iptest/test_env.py | 0 .../IronPython/Lib/iptest/type_util.py | 0 .../IronPython/Modules/Builtin.Generated.cs | 0 .../IronPython/Modules/Builtin.cs | 0 {Src.GetRenamed => src}/IronPython/Modules/_ast.cs | 0 .../IronPython/Modules/_fileio.cs | 0 {Src.GetRenamed => src}/IronPython/Modules/_imp.cs | 0 {Src.GetRenamed => src}/IronPython/Modules/_io.cs | 0 .../IronPython/Modules/_io/BytesIO.cs | 0 .../IronPython/Modules/_io/StringIO.cs | 0 .../IronPython/Modules/_locale.cs | 0 {Src.GetRenamed => src}/IronPython/Modules/sys.cs | 0 .../IronPython/Modules/unicodedata.cs | 0 .../IronPython/Modules/unicodedata/CaseFolding.txt | 0 .../Modules/unicodedata/EastAsianWidth-3.2.0.txt | 0 .../Modules/unicodedata/EastAsianWidth.txt | 0 .../Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz | Bin .../Modules/unicodedata/IPyUnicodeData.txt.gz | Bin .../IronPython/Modules/unicodedata/NameAliases.txt | 0 .../Modules/unicodedata/UnicodeData-3.2.0.txt | 0 .../IronPython/Modules/unicodedata/UnicodeData.txt | 0 .../Modules/unicodedata/genunicodedata.py | 0 .../IronPython/Modules/unicodedata/license.txt | 0 .../IronPython/Properties/AssemblyInfo.cs | 0 .../IronPython/Resources.Designer.cs | 0 {Src.GetRenamed => src}/IronPython/Resources.resx | 0 .../IronPython/Runtime/ArrayData.cs | 0 .../Binding/BinaryRetTypeBinder.Generated.cs | 0 .../Runtime/Binding/BinaryRetTypeBinder.cs | 0 .../IronPython/Runtime/Binding/Binders.cs | 0 .../IronPython/Runtime/Binding/BindingHelpers.cs | 0 .../IronPython/Runtime/Binding/BindingWarnings.cs | 0 .../Runtime/Binding/CompatibilityInvokeBinder.cs | 0 .../Runtime/Binding/ConditionalBuilder.cs | 0 .../IronPython/Runtime/Binding/ContextArgBuilder.cs | 0 .../IronPython/Runtime/Binding/ConversionBinder.cs | 0 .../Runtime/Binding/CreateFallbackBinder.cs | 0 .../IronPython/Runtime/Binding/FastBindResult.cs | 0 .../IronPython/Runtime/Binding/FastGetBase.cs | 0 .../IronPython/Runtime/Binding/FastSetBase.cs | 0 .../IronPython/Runtime/Binding/IComConvertible.cs | 0 .../IronPython/Runtime/Binding/IFastGettable.cs | 0 .../IronPython/Runtime/Binding/IFastInvokable.cs | 0 .../IronPython/Runtime/Binding/IFastSettable.cs | 0 .../Runtime/Binding/IPythonConvertible.cs | 0 .../IronPython/Runtime/Binding/IPythonExpandable.cs | 0 .../IronPython/Runtime/Binding/IPythonGetable.cs | 0 .../IronPython/Runtime/Binding/IPythonInvokable.cs | 0 .../IronPython/Runtime/Binding/IPythonOperable.cs | 0 .../IronPython/Runtime/Binding/IPythonSite.cs | 0 .../Runtime/Binding/MetaBuiltinFunction.cs | 0 .../Runtime/Binding/MetaBuiltinMethodDescriptor.cs | 0 .../IronPython/Runtime/Binding/MetaMethod.cs | 0 .../Runtime/Binding/MetaPythonFunction.cs | 0 .../IronPython/Runtime/Binding/MetaPythonObject.cs | 0 .../Runtime/Binding/MetaPythonType.Calls.cs | 0 .../Runtime/Binding/MetaPythonType.Members.cs | 0 .../IronPython/Runtime/Binding/MetaPythonType.cs | 0 .../Runtime/Binding/MetaUserObject.Members.cs | 0 .../IronPython/Runtime/Binding/MetaUserObject.cs | 0 .../Runtime/Binding/PythonBinaryOperationBinder.cs | 0 .../Runtime/Binding/PythonBinder.Create.cs | 0 .../IronPython/Runtime/Binding/PythonBinder.cs | 0 .../Runtime/Binding/PythonDeleteIndexBinder.cs | 0 .../Runtime/Binding/PythonDeleteMemberBinder.cs | 0 .../Runtime/Binding/PythonDeleteSliceBinder.cs | 0 .../Runtime/Binding/PythonExtensionBinder.cs | 0 .../Runtime/Binding/PythonGetIndexBinder.cs | 0 .../Runtime/Binding/PythonGetMemberBinder.cs | 0 .../Runtime/Binding/PythonGetSliceBinder.cs | 0 .../IronPython/Runtime/Binding/PythonIndexType.cs | 0 .../Runtime/Binding/PythonInvokeBinder.cs | 0 .../Runtime/Binding/PythonOperationBinder.cs | 0 .../Runtime/Binding/PythonOperationKind.cs | 0 .../Runtime/Binding/PythonOverloadResolver.cs | 0 .../Runtime/Binding/PythonProtocol.Operations.cs | 0 .../IronPython/Runtime/Binding/PythonProtocol.cs | 0 .../Runtime/Binding/PythonSetIndexBinder.cs | 0 .../Runtime/Binding/PythonSetMemberBinder.cs | 0 .../Runtime/Binding/PythonSetSliceBinder.cs | 0 .../Runtime/Binding/PythonUnaryOperationBinder.cs | 0 .../Runtime/Binding/SiteLocalStorageBuilder.cs | 0 .../IronPython/Runtime/Binding/SlotOrFunction.cs | 0 .../IronPython/Runtime/Binding/WarningInfo.cs | 0 .../IronPython/Runtime/BufferProtocol.cs | 0 .../IronPython/Runtime/BuiltinPythonModule.cs | 0 .../IronPython/Runtime/BuiltinsDictionaryStorage.cs | 0 .../IronPython/Runtime/ByteArray.cs | 0 .../IronPython/Runtime/ByteArrayIterator.cs | 0 {Src.GetRenamed => src}/IronPython/Runtime/Bytes.cs | 0 .../IronPython/Runtime/BytesIterator.cs | 0 .../IronPython/Runtime/BytesLikeAttribute.cs | 0 .../IronPython/Runtime/ClassMethodAttribute.cs | 0 .../IronPython/Runtime/ClassMethodDescriptor.cs | 0 .../IronPython/Runtime/ClrModule.cs | 0 .../IronPython/Runtime/CodeContext.cs | 0 .../IronPython/Runtime/CollectionDebugView.cs | 0 .../IronPython/Runtime/CommonDictionaryStorage.cs | 0 .../IronPython/Runtime/CompareUtil.cs | 0 .../IronPython/Runtime/CompileFlags.cs | 0 .../IronPython/Runtime/CompiledLoader.cs | 0 .../IronPython/Runtime/ConstantDictionaryStorage.cs | 0 .../IronPython/Runtime/ConversionWrappers.cs | 0 .../IronPython/Runtime/Converter.cs | 0 .../IronPython/Runtime/CustomDictionaryStorage.cs | 0 .../IronPython/Runtime/DebuggerDictionaryStorage.cs | 0 .../IronPython/Runtime/DefaultContext.cs | 0 .../IronPython/Runtime/Descriptors.cs | 0 .../IronPython/Runtime/DictionaryOps.cs | 0 .../IronPython/Runtime/DictionaryStorage.cs | 0 .../Runtime/DictionaryTypeInfoAttribute.cs | 0 .../Runtime/DontMapGetMemberNamesToDirAttribute.cs | 0 .../Runtime/DontMapICollectionToLenAttribute.cs | 0 .../DontMapIDisposableToContextManagerAttribute.cs | 0 .../DontMapIEnumerableToContainsAttribute.cs | 0 .../Runtime/DontMapIEnumerableToIterAttribute.cs | 0 .../IronPython/Runtime/EmptyDictionaryStorage.cs | 0 .../IronPython/Runtime/Enumerate.cs | 0 .../IronPython/Runtime/ErrorCodes.cs | 0 .../Exceptions/AssertionException.Generated.cs | 0 .../Runtime/Exceptions/AttributeErrorException.cs | 0 .../Exceptions/BlockingIOException.Generated.cs | 0 .../Exceptions/BrokenPipeException.Generated.cs | 0 .../Runtime/Exceptions/BufferException.Generated.cs | 0 .../Exceptions/BytesWarningException.Generated.cs | 0 .../Exceptions/ChildProcessException.Generated.cs | 0 .../ConnectionAbortedException.Generated.cs | 0 .../Exceptions/ConnectionException.Generated.cs | 0 .../ConnectionRefusedException.Generated.cs | 0 .../ConnectionResetException.Generated.cs | 0 .../DeprecationWarningException.Generated.cs | 0 .../Exceptions/FileExistsException.Generated.cs | 0 .../Exceptions/FloatingPointException.Generated.cs | 0 .../Exceptions/FutureWarningException.Generated.cs | 0 .../Runtime/Exceptions/GeneratorExitException.cs | 0 .../Runtime/Exceptions/ImportException.Generated.cs | 0 .../Exceptions/ImportWarningException.Generated.cs | 0 .../Runtime/Exceptions/IndentationException.cs | 0 .../Exceptions/InterruptedException.Generated.cs | 0 .../Exceptions/IsADirectoryException.Generated.cs | 0 .../Runtime/Exceptions/LookupException.Generated.cs | 0 .../Runtime/Exceptions/ModuleNotFoundException.cs | 0 .../Exceptions/NotADirectoryException.Generated.cs | 0 .../Runtime/Exceptions/OSException.Generated.cs | 0 .../PendingDeprecationWarningException.Generated.cs | 0 .../Exceptions/ProcessLookupException.Generated.cs | 0 .../Runtime/Exceptions/PythonException.cs | 0 .../Exceptions/PythonExceptions.BaseException.cs | 0 .../Exceptions/PythonExceptions.Generated.cs | 0 .../Runtime/Exceptions/PythonExceptions.cs | 0 .../Exceptions/RecursionException.Generated.cs | 0 .../Exceptions/ReferenceException.Generated.cs | 0 .../ResourceWarningException.Generated.cs | 0 .../Exceptions/RuntimeException.Generated.cs | 0 .../Exceptions/RuntimeWarningException.Generated.cs | 0 .../StopAsyncIterationException.Generated.cs | 0 .../Exceptions/StopIterationException.Generated.cs | 0 .../Exceptions/SyntaxWarningException.Generated.cs | 0 .../Runtime/Exceptions/SystemExitException.cs | 0 .../IronPython/Runtime/Exceptions/TabException.cs | 0 .../IronPython/Runtime/Exceptions/TraceBack.cs | 0 .../Runtime/Exceptions/TypeErrorException.cs | 0 .../Exceptions/UnicodeException.Generated.cs | 0 .../UnicodeTranslateException.Generated.cs | 0 .../Exceptions/UnicodeWarningException.Generated.cs | 0 .../Exceptions/UserWarningException.Generated.cs | 0 .../Runtime/Exceptions/ValueErrorException.cs | 0 .../IronPython/Runtime/ExtensionMethodSet.cs | 0 .../IronPython/Runtime/Filter.cs | 0 .../IronPython/Runtime/FormattingHelper.cs | 0 .../IronPython/Runtime/FunctionAttributes.cs | 0 .../IronPython/Runtime/FunctionCode.cs | 0 .../IronPython/Runtime/Generator.cs | 0 .../IronPython/Runtime/GlobalDictionaryStorage.cs | 0 .../IronPython/Runtime/IParameterSequence.cs | 0 .../IronPython/Runtime/Implementation.cs | 0 .../IronPython/Runtime/Importer.cs | 0 {Src.GetRenamed => src}/IronPython/Runtime/Index.cs | 0 .../Runtime/InstancedModuleDictionaryStorage.cs | 0 .../IronPython/Runtime/Interfaces.cs | 0 .../IronPython/Runtime/KwCallInfo.cs | 0 .../IronPython/Runtime/LiteralParser.cs | 0 {Src.GetRenamed => src}/IronPython/Runtime/Map.cs | 0 .../Runtime/MaybeNotImplementedAttribute.cs | 0 .../Runtime/MemoryStreamContentProvider.cs | 0 .../IronPython/Runtime/MemoryView.cs | 0 .../IronPython/Runtime/Method.Generated.cs | 0 .../IronPython/Runtime/Method.cs | 0 .../IronPython/Runtime/MissingParameter.cs | 0 .../IronPython/Runtime/ModuleContext.cs | 0 .../IronPython/Runtime/ModuleDictionaryStorage.cs | 0 .../IronPython/Runtime/ModuleGlobalCache.cs | 0 .../IronPython/Runtime/ModuleLoader.cs | 0 .../IronPython/Runtime/ModuleOptions.cs | 0 .../IronPython/Runtime/NameType.cs | 0 .../IronPython/Runtime/NewStringFormatter.cs | 0 .../IronPython/Runtime/ObjectAttributesAdapter.cs | 0 .../IronPython/Runtime/ObjectDebugView.cs | 0 .../IronPython/Runtime/Operations/ArrayOps.cs | 0 .../IronPython/Runtime/Operations/BigIntegerOps.cs | 0 .../IronPython/Runtime/Operations/BoolOps.cs | 0 .../IronPython/Runtime/Operations/ByteOps.cs | 0 .../IronPython/Runtime/Operations/CharOps.cs | 0 .../IronPython/Runtime/Operations/ComOps.cs | 0 .../IronPython/Runtime/Operations/ComplexOps.cs | 0 .../Runtime/Operations/CustomTypeDescHelpers.cs | 0 .../IronPython/Runtime/Operations/DBNullOps.cs | 0 .../IronPython/Runtime/Operations/DateTimeOps.cs | 0 .../IronPython/Runtime/Operations/DecimalOps.cs | 0 .../IronPython/Runtime/Operations/DelegateOps.cs | 0 .../Runtime/Operations/DictionaryOfTOps.cs | 0 .../IronPython/Runtime/Operations/EnumOps.cs | 0 .../Runtime/Operations/FloatOps.Generated.cs | 0 .../IronPython/Runtime/Operations/FloatOps.cs | 0 .../IronPython/Runtime/Operations/IListOfByteOps.cs | 0 .../IronPython/Runtime/Operations/InstanceOps.cs | 0 .../Runtime/Operations/IntOps.Generated.cs | 0 .../IronPython/Runtime/Operations/IntOps.cs | 0 .../IronPython/Runtime/Operations/IntPtrOps.cs | 0 .../IronPython/Runtime/Operations/ListOfTOps.cs | 0 .../IronPython/Runtime/Operations/MarshalOps.cs | 0 .../Runtime/Operations/NamespaceTrackerOps.cs | 0 .../IronPython/Runtime/Operations/ObjectOps.cs | 0 .../IronPython/Runtime/Operations/PythonCalls.cs | 0 .../Runtime/Operations/PythonOps.Generated.cs | 0 .../IronPython/Runtime/Operations/PythonOps.cs | 0 .../IronPython/Runtime/Operations/PythonTypeOps.cs | 0 .../Runtime/Operations/StringOps.Generated.cs | 0 .../IronPython/Runtime/Operations/StringOps.cs | 0 .../IronPython/Runtime/Operations/TypeGroupOps.cs | 0 .../IronPython/Runtime/Operations/TypeTrackerOps.cs | 0 .../IronPython/Runtime/Operations/UIntPtrOps.cs | 0 .../IronPython/Runtime/Operations/UserTypeOps.cs | 0 .../IronPython/Runtime/OutputWriter.cs | 0 .../IronPython/Runtime/PlatformsAttribute.cs | 0 .../IronPython/Runtime/Profiler.cs | 0 .../IronPython/Runtime/PythonContext.Generated.cs | 0 .../IronPython/Runtime/PythonContext.cs | 0 .../IronPython/Runtime/PythonDictionary.cs | 0 .../Runtime/PythonDocumentationProvider.cs | 0 .../IronPython/Runtime/PythonDynamicStackFrame.cs | 0 .../IronPython/Runtime/PythonEncoding.cs | 0 .../IronPython/Runtime/PythonFileManager.cs | 0 .../IronPython/Runtime/PythonFunction.Generated.cs | 0 .../IronPython/Runtime/PythonFunction.cs | 0 .../IronPython/Runtime/PythonHiddenAttribute.cs | 0 .../Runtime/PythonHiddenBaseClassAttribute.cs | 0 .../IronPython/Runtime/PythonList.cs | 0 .../IronPython/Runtime/PythonModule.cs | 0 .../IronPython/Runtime/PythonModuleAttribute.cs | 0 .../IronPython/Runtime/PythonNarrowing.cs | 0 .../IronPython/Runtime/PythonOptions.cs | 0 .../IronPython/Runtime/PythonRange.cs | 0 .../IronPython/Runtime/PythonScopeExtension.cs | 0 .../IronPython/Runtime/PythonStrIterator.cs | 0 .../IronPython/Runtime/PythonTracebackListener.cs | 0 .../IronPython/Runtime/PythonTuple.cs | 0 .../IronPython/Runtime/PythonTypeAttribute.cs | 0 .../IronPython/Runtime/Reversed.cs | 0 .../Runtime/RuntimeVariablesDictionaryStorage.cs | 0 .../IronPython/Runtime/ScopeDictionaryStorage.cs | 0 .../IronPython/Runtime/SequenceTypeInfoAttribute.cs | 0 {Src.GetRenamed => src}/IronPython/Runtime/Set.cs | 0 .../IronPython/Runtime/SetStorage.cs | 0 .../IronPython/Runtime/SimpleNamespace.cs | 0 .../IronPython/Runtime/SiteLocalStorage.cs | 0 {Src.GetRenamed => src}/IronPython/Runtime/Slice.cs | 0 .../IronPython/Runtime/StringDictionaryStorage.cs | 0 .../IronPython/Runtime/StringFormatSpec.cs | 0 .../IronPython/Runtime/StringFormatter.cs | 0 {Src.GetRenamed => src}/IronPython/Runtime/Super.cs | 0 .../IronPython/Runtime/Symbols.Generated.cs | 0 .../IronPython/Runtime/ThrowingErrorSink.cs | 0 .../IronPython/Runtime/TypecodeOps.cs | 0 .../IronPython/Runtime/Types/BuiltinFunction.cs | 0 .../Runtime/Types/BuiltinFunctionOverloadMapper.cs | 0 .../Runtime/Types/BuiltinMethodDescriptor.cs | 0 .../IronPython/Runtime/Types/CachedNewTypeInfo.cs | 0 .../IronPython/Runtime/Types/ConstructorFunction.cs | 0 .../Runtime/Types/CustomAttributeTracker.cs | 0 .../Types/CustomInstanceDictionaryStorage.cs | 0 .../IronPython/Runtime/Types/DocBuilder.cs | 0 .../Runtime/Types/DynamicBaseTypeAttribute.cs | 0 .../IronPython/Runtime/Types/DynamicHelpers.cs | 0 .../IronPython/Runtime/Types/EmptyType.cs | 0 .../Runtime/Types/ExtensionPropertyInfo.cs | 0 .../IronPython/Runtime/Types/FunctionType.cs | 0 .../IronPython/Runtime/Types/IPythonObject.cs | 0 .../IronPython/Runtime/Types/InstanceCreator.cs | 0 .../IronPython/Runtime/Types/MappingProxy.cs | 0 .../IronPython/Runtime/Types/Mro.cs | 0 .../IronPython/Runtime/Types/NameConverter.cs | 0 .../IronPython/Runtime/Types/NewTypeInfo.cs | 0 .../IronPython/Runtime/Types/NewTypeMaker.cs | 0 .../IronPython/Runtime/Types/OperatorMapping.cs | 0 .../Runtime/Types/ParameterInfoWrapper.cs | 0 .../IronPython/Runtime/Types/PythonAssemblyOps.cs | 0 .../IronPython/Runtime/Types/PythonSiteCache.cs | 0 .../Runtime/Types/PythonType.Generated.cs | 0 .../IronPython/Runtime/Types/PythonType.cs | 0 .../IronPython/Runtime/Types/PythonTypeDataSlot.cs | 0 .../IronPython/Runtime/Types/PythonTypeDictSlot.cs | 0 .../Runtime/Types/PythonTypeInfo.Generated.cs | 0 .../IronPython/Runtime/Types/PythonTypeInfo.cs | 0 .../IronPython/Runtime/Types/PythonTypeSlot.cs | 0 .../IronPython/Runtime/Types/PythonTypeTypeSlot.cs | 0 .../Runtime/Types/PythonTypeUserDescriptorSlot.cs | 0 .../Runtime/Types/PythonTypeWeakRefSlot.cs | 0 .../IronPython/Runtime/Types/ReflectedEvent.cs | 0 .../Runtime/Types/ReflectedExtensionProperty.cs | 0 .../IronPython/Runtime/Types/ReflectedField.cs | 0 .../Runtime/Types/ReflectedGetterSetter.cs | 0 .../IronPython/Runtime/Types/ReflectedIndexer.cs | 0 .../IronPython/Runtime/Types/ReflectedProperty.cs | 0 .../Runtime/Types/ReflectedSlotProperty.cs | 0 .../IronPython/Runtime/Types/ResolvedMember.cs | 0 .../IronPython/Runtime/Types/SlotFieldAttribute.cs | 0 .../Runtime/Types/StaticUnderlyingSystemType.cs | 0 .../IronPython/Runtime/Types/TypeCache.Generated.cs | 0 .../IronPython/Runtime/UnboundNameException.cs | 0 .../IronPython/Runtime/WeakRef.cs | 0 .../Runtime/WrapperDescriptorAttribute.cs | 0 .../IronPython/Runtime/WrapperDictionary.cs | 0 {Src.GetRenamed => src}/IronPython/Runtime/Zip.cs | 0 .../IronPython/SerializationStubs.cs | 0 .../IronPython/StringExtensions.cs | 0 .../IronPython/SystemRuntimeVersioning.cs | 0 .../IronPython/policy.IronPython.config | 0 .../Modules/IronPython.Modules.csproj | 0 {Src.GetRenamed => src}/Modules/IterTools.cs | 0 {Src.GetRenamed => src}/Modules/ModuleOps.cs | 0 {Src.GetRenamed => src}/Modules/NtSignalState.cs | 0 .../Modules/Properties/AssemblyInfo.cs | 0 .../Modules/ResourceMetaPathImporter.cs | 0 .../Modules/SimpleSignalState.cs | 0 {Src.GetRenamed => src}/Modules/_bisect.cs | 0 {Src.GetRenamed => src}/Modules/_codecs.cs | 0 {Src.GetRenamed => src}/Modules/_codecs_cn.cs | 0 {Src.GetRenamed => src}/Modules/_collections.cs | 0 {Src.GetRenamed => src}/Modules/_csv.cs | 0 {Src.GetRenamed => src}/Modules/_ctypes/Array.cs | 0 .../Modules/_ctypes/ArrayType.cs | 0 {Src.GetRenamed => src}/Modules/_ctypes/CData.cs | 0 {Src.GetRenamed => src}/Modules/_ctypes/CFuncPtr.cs | 0 .../Modules/_ctypes/CFuncPtrType.cs | 0 .../Modules/_ctypes/Extensions.cs | 0 {Src.GetRenamed => src}/Modules/_ctypes/Field.cs | 0 .../Modules/_ctypes/INativeType.cs | 0 .../Modules/_ctypes/LocalOrArg.cs | 0 .../Modules/_ctypes/MarshalCleanup.cs | 0 .../Modules/_ctypes/MemoryHolder.cs | 0 .../Modules/_ctypes/NativeArgument.cs | 0 .../Modules/_ctypes/NativeFunctions.cs | 0 {Src.GetRenamed => src}/Modules/_ctypes/Pointer.cs | 0 .../Modules/_ctypes/PointerType.cs | 0 .../Modules/_ctypes/SimpleCData.cs | 0 .../Modules/_ctypes/SimpleType.cs | 0 .../Modules/_ctypes/SimpleTypeKind.cs | 0 .../Modules/_ctypes/StructType.cs | 0 .../Modules/_ctypes/Structure.cs | 0 {Src.GetRenamed => src}/Modules/_ctypes/Union.cs | 0 .../Modules/_ctypes/UnionType.cs | 0 {Src.GetRenamed => src}/Modules/_ctypes/_ctypes.cs | 0 {Src.GetRenamed => src}/Modules/_ctypes_test.cs | 0 {Src.GetRenamed => src}/Modules/_datetime.cs | 0 {Src.GetRenamed => src}/Modules/_functools.cs | 0 {Src.GetRenamed => src}/Modules/_heapq.cs | 0 {Src.GetRenamed => src}/Modules/_multibytecodec.cs | 0 {Src.GetRenamed => src}/Modules/_multiprocessing.cs | 0 {Src.GetRenamed => src}/Modules/_opcode.cs | 0 {Src.GetRenamed => src}/Modules/_operator.cs | 0 {Src.GetRenamed => src}/Modules/_overlapped.cs | 0 {Src.GetRenamed => src}/Modules/_pickle.cs | 0 {Src.GetRenamed => src}/Modules/_posixsubprocess.cs | 0 .../Modules/_random.RandomGen.cs | 0 {Src.GetRenamed => src}/Modules/_random.cs | 0 {Src.GetRenamed => src}/Modules/_socket.cs | 0 {Src.GetRenamed => src}/Modules/_sre.cs | 0 {Src.GetRenamed => src}/Modules/_ssl.cs | 0 {Src.GetRenamed => src}/Modules/_string.cs | 0 {Src.GetRenamed => src}/Modules/_struct.cs | 0 {Src.GetRenamed => src}/Modules/_sysconfigdata.cs | 0 {Src.GetRenamed => src}/Modules/_thread.cs | 0 {Src.GetRenamed => src}/Modules/_warnings.cs | 0 .../Modules/_weakref.Generated.cs | 0 {Src.GetRenamed => src}/Modules/_weakref.cs | 0 {Src.GetRenamed => src}/Modules/_winapi.cs | 0 {Src.GetRenamed => src}/Modules/array.cs | 0 {Src.GetRenamed => src}/Modules/atexit.cs | 0 {Src.GetRenamed => src}/Modules/audioop.cs | 0 {Src.GetRenamed => src}/Modules/binascii.cs | 0 .../Modules/bz2/BZ2Compressor.cs | 0 .../Modules/bz2/BZ2Decompressor.cs | 0 {Src.GetRenamed => src}/Modules/bz2/BZ2Module.cs | 0 .../Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs | 0 .../Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs | 0 .../bz2/dotnetzip/BZip2/BZip2OutputStream.cs | 0 .../Modules/bz2/dotnetzip/BZip2/BitWriter.cs | 0 .../Modules/bz2/dotnetzip/BZip2/CRC32.cs | 0 .../dotnetzip/BZip2/ParallelBZip2OutputStream.cs | 0 .../Modules/bz2/dotnetzip/BZip2/Rand.cs | 0 .../Modules/bz2/dotnetzip/source.txt | 0 {Src.GetRenamed => src}/Modules/cmath.cs | 0 {Src.GetRenamed => src}/Modules/errno.cs | 0 {Src.GetRenamed => src}/Modules/faulthandler.cs | 0 {Src.GetRenamed => src}/Modules/fcntl.cs | 0 {Src.GetRenamed => src}/Modules/gc.cs | 0 {Src.GetRenamed => src}/Modules/grp.cs | 0 .../Modules/hashlib/MD5CryptoServiceProvider.cs | 0 .../Modules/hashlib/SHA1CryptoServiceProvider.cs | 0 {Src.GetRenamed => src}/Modules/hashlib/SHA224.cs | 0 .../Modules/hashlib/SHA224Managed.cs | 0 .../Modules/hashlib/SHA256Managed.cs | 0 .../Modules/hashlib/SHA384Managed.cs | 0 .../Modules/hashlib/SHA512Managed.cs | 0 .../Modules/hashlib/SHAConstants.cs | 0 {Src.GetRenamed => src}/Modules/hashlib/_hashlib.cs | 0 {Src.GetRenamed => src}/Modules/hashlib/_md5.cs | 0 {Src.GetRenamed => src}/Modules/hashlib/_sha1.cs | 0 {Src.GetRenamed => src}/Modules/hashlib/_sha256.cs | 0 {Src.GetRenamed => src}/Modules/hashlib/_sha512.cs | 0 {Src.GetRenamed => src}/Modules/marshal.cs | 0 {Src.GetRenamed => src}/Modules/math.Generated.cs | 0 {Src.GetRenamed => src}/Modules/math.cs | 0 {Src.GetRenamed => src}/Modules/mmap.cs | 0 {Src.GetRenamed => src}/Modules/msvcrt.cs | 0 {Src.GetRenamed => src}/Modules/nt.cs | 0 .../Modules/policy.IronPython.Modules.config | 0 {Src.GetRenamed => src}/Modules/pwd.cs | 0 {Src.GetRenamed => src}/Modules/pyexpat.cs | 0 {Src.GetRenamed => src}/Modules/re.cs | 0 {Src.GetRenamed => src}/Modules/resource.cs | 0 {Src.GetRenamed => src}/Modules/select.cs | 0 {Src.GetRenamed => src}/Modules/signal.cs | 0 {Src.GetRenamed => src}/Modules/spwd.cs | 0 {Src.GetRenamed => src}/Modules/time.cs | 0 {Src.GetRenamed => src}/Modules/winreg.cs | 0 {Src.GetRenamed => src}/Modules/winsound.cs | 0 {Src.GetRenamed => src}/Modules/xxsubtype.cs | 0 {Src.GetRenamed => src}/Modules/zipimport.cs | 0 {Src.GetRenamed => src}/Modules/zlib/Compress.cs | 0 {Src.GetRenamed => src}/Modules/zlib/Decompress.cs | 0 {Src.GetRenamed => src}/Modules/zlib/ZlibModule.cs | 0 .../Modules/zlib/zlib.net/Adler32.cs | 0 .../Modules/zlib/zlib.net/Deflate.cs | 0 .../Modules/zlib/zlib.net/InfBlocks.cs | 0 .../Modules/zlib/zlib.net/InfCodes.cs | 0 .../Modules/zlib/zlib.net/InfTree.cs | 0 .../Modules/zlib/zlib.net/Inflate.cs | 0 .../Modules/zlib/zlib.net/StaticTree.cs | 0 .../Modules/zlib/zlib.net/Tree.cs | 0 .../Modules/zlib/zlib.net/ZStream.cs | 0 .../Modules/zlib/zlib.net/ZStreamException.cs | 0 .../Modules/zlib/zlib.net/Zlib.cs | 0 .../Modules/zlib/zlib.net/history.txt | 0 .../Modules/zlib/zlib.net/license.txt | 0 .../Modules/zlib/zlib.net/readme.txt | 0 {Src.GetRenamed => src}/README.md | 0 {Src.GetRenamed => src}/SQLite/Connection.cs | 0 {Src.GetRenamed => src}/SQLite/Contants.cs | 0 {Src.GetRenamed => src}/SQLite/Cursor.cs | 0 {Src.GetRenamed => src}/SQLite/Exceptions.cs | 0 {Src.GetRenamed => src}/SQLite/Extensions.cs | 0 .../SQLite/IronPython.SQLite.csproj | 0 .../SQLite/Properties/AssemblyInfo.cs | 0 {Src.GetRenamed => src}/SQLite/Row.cs | 0 {Src.GetRenamed => src}/SQLite/Statement.cs | 0 {Src.GetRenamed => src}/SQLite/Util.cs | 0 {Src.GetRenamed => src}/SQLite/_sqlite.cs | 0 .../SQLite/c#sqlite/.editorconfig | 0 .../SQLite/c#sqlite/BtreeInt_h.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/Btree_h.cs | 0 .../SQLite/c#sqlite/Delegates.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/Hash_h.cs | 0 .../SQLite/c#sqlite/VdbeInt_h.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/Vdbe_h.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/_Custom.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/alter_c.cs | 0 .../SQLite/c#sqlite/analyze_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/attach_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/auth_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/backup_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/bitvec_c.cs | 0 .../SQLite/c#sqlite/btmutex_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/btree_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/build_c.cs | 0 .../SQLite/c#sqlite/callback_c.cs | 0 .../SQLite/c#sqlite/complete_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/crypto.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/ctime_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/date_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/delete_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/expr_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/fault_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/fkey_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/func_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/global_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/hash_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/hwtime_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/insert_c.cs | 0 .../SQLite/c#sqlite/journal_c.cs | 0 .../SQLite/c#sqlite/keywordhash_h.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/legacy_c.cs | 0 .../SQLite/c#sqlite/loadext_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/main_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/malloc_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/mem_Pool.cs | 0 .../SQLite/c#sqlite/memjournal_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/mutex_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/mutex_h.cs | 0 .../SQLite/c#sqlite/mutex_noop_c.cs | 0 .../SQLite/c#sqlite/mutex_w32.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/notify_c.cs | 0 .../SQLite/c#sqlite/opcodes_c.cs | 0 .../SQLite/c#sqlite/opcodes_h.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/os_c.cs | 0 .../SQLite/c#sqlite/os_common_h.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/os_h.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/os_win_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/pager_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/pager_h.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/parse_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/parse_h.cs | 0 .../SQLite/c#sqlite/pcache1_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/pcache_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/pcache_h.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/pragma_c.cs | 0 .../SQLite/c#sqlite/prepare_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/printf_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/random_c.cs | 0 .../SQLite/c#sqlite/resolve_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/rowset_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/select_c.cs | 0 .../SQLite/c#sqlite/sqlite3_h.cs | 0 .../SQLite/c#sqlite/sqliteInt_h.cs | 0 .../SQLite/c#sqlite/sqliteLimit_h.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/status_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/table_c.cs | 0 .../SQLite/c#sqlite/tokenize_c.cs | 0 .../SQLite/c#sqlite/trigger_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/update_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/utf_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/util_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/vacuum_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/vdbe_c.cs | 0 .../SQLite/c#sqlite/vdbeapi_c.cs | 0 .../SQLite/c#sqlite/vdbeaux_c.cs | 0 .../SQLite/c#sqlite/vdbeblob_c.cs | 0 .../SQLite/c#sqlite/vdbemem_c.cs | 0 .../SQLite/c#sqlite/vdbetrace_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/vtab_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/wal_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/wal_h.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/walker_c.cs | 0 {Src.GetRenamed => src}/SQLite/c#sqlite/where_c.cs | 0 {Src.GetRenamed => src}/Scripts/CompareDirs.py | 0 .../Scripts/Enter-IronPythonEnvironment.ps1 | 0 .../Scripts/Install-IronPython.ps1 | 0 {Src.GetRenamed => src}/Scripts/clean.py | 0 {Src.GetRenamed => src}/Scripts/copyrights.py | 0 {Src.GetRenamed => src}/Scripts/generate.py | 0 .../generate_UncollectableCompilationMode.py | 0 .../Scripts/generate_alltypes.py | 0 {Src.GetRenamed => src}/Scripts/generate_calls.py | 0 {Src.GetRenamed => src}/Scripts/generate_casts.py | 0 .../Scripts/generate_comdispatch.py | 0 .../Scripts/generate_dict_views.py | 0 .../Scripts/generate_dynamic_instructions.py | 0 .../Scripts/generate_dynsites.py | 0 .../Scripts/generate_encoding_aliases.py | 0 .../Scripts/generate_exception_factory.py | 0 .../Scripts/generate_exceptions.py | 0 .../Scripts/generate_indicestest.py | 0 {Src.GetRenamed => src}/Scripts/generate_math.py | 0 {Src.GetRenamed => src}/Scripts/generate_ops.py | 0 .../Scripts/generate_os_codes.py | 0 .../Scripts/generate_reflected_calls.py | 0 {Src.GetRenamed => src}/Scripts/generate_set.py | 0 {Src.GetRenamed => src}/Scripts/generate_tuples.py | 0 .../Scripts/generate_typecache.py | 0 {Src.GetRenamed => src}/Scripts/generate_walker.py | 0 {Src.GetRenamed => src}/Scripts/ipcom.ps1 | 0 {Src.GetRenamed => src}/Scripts/make_meta1.py | 0 {Src.GetRenamed => src}/Scripts/radix_generator.py | 0 {Src.GetRenamed => src}/Scripts/run_compiled.py | 0 {Src.GetRenamed => src}/Scripts/run_interactive.py | 0 {Src.GetRenamed => src}/Scripts/smtpmailer.py | 0 {Src.GetRenamed => src}/Scripts/test_builder.py | 0 {Src.GetRenamed => src}/Scripts/test_cgcheck.py | 0 {Src.GetRenamed => src}/Scripts/test_parrot.py | 0 {Src.GetRenamed => src}/Scripts/test_pystone.py | 0 {Src.GetRenamed => src}/StdLib/.gitattributes | 0 {Src.GetRenamed => src}/StdLib/Lib/__future__.py | 0 .../StdLib/Lib/__phello__.foo.py | 0 {Src.GetRenamed => src}/StdLib/Lib/_bootlocale.py | 0 .../StdLib/Lib/_collections_abc.py | 0 .../StdLib/Lib/_compat_pickle.py | 0 {Src.GetRenamed => src}/StdLib/Lib/_dummy_thread.py | 0 {Src.GetRenamed => src}/StdLib/Lib/_markupbase.py | 0 {Src.GetRenamed => src}/StdLib/Lib/_osx_support.py | 0 {Src.GetRenamed => src}/StdLib/Lib/_pyio.py | 0 {Src.GetRenamed => src}/StdLib/Lib/_sitebuiltins.py | 0 {Src.GetRenamed => src}/StdLib/Lib/_strptime.py | 0 .../StdLib/Lib/_threading_local.py | 0 {Src.GetRenamed => src}/StdLib/Lib/_weakrefset.py | 0 {Src.GetRenamed => src}/StdLib/Lib/abc.py | 0 {Src.GetRenamed => src}/StdLib/Lib/aifc.py | 0 {Src.GetRenamed => src}/StdLib/Lib/antigravity.py | 0 {Src.GetRenamed => src}/StdLib/Lib/argparse.py | 0 {Src.GetRenamed => src}/StdLib/Lib/ast.py | 0 {Src.GetRenamed => src}/StdLib/Lib/asynchat.py | 0 .../StdLib/Lib/asyncio/__init__.py | 0 .../StdLib/Lib/asyncio/base_events.py | 0 .../StdLib/Lib/asyncio/base_subprocess.py | 0 .../StdLib/Lib/asyncio/compat.py | 0 .../StdLib/Lib/asyncio/constants.py | 0 .../StdLib/Lib/asyncio/coroutines.py | 0 .../StdLib/Lib/asyncio/events.py | 0 .../StdLib/Lib/asyncio/futures.py | 0 {Src.GetRenamed => src}/StdLib/Lib/asyncio/locks.py | 0 {Src.GetRenamed => src}/StdLib/Lib/asyncio/log.py | 0 .../StdLib/Lib/asyncio/proactor_events.py | 0 .../StdLib/Lib/asyncio/protocols.py | 0 .../StdLib/Lib/asyncio/queues.py | 0 .../StdLib/Lib/asyncio/selector_events.py | 0 .../StdLib/Lib/asyncio/sslproto.py | 0 .../StdLib/Lib/asyncio/streams.py | 0 .../StdLib/Lib/asyncio/subprocess.py | 0 {Src.GetRenamed => src}/StdLib/Lib/asyncio/tasks.py | 0 .../StdLib/Lib/asyncio/test_utils.py | 0 .../StdLib/Lib/asyncio/transports.py | 0 .../StdLib/Lib/asyncio/unix_events.py | 0 .../StdLib/Lib/asyncio/windows_events.py | 0 .../StdLib/Lib/asyncio/windows_utils.py | 0 {Src.GetRenamed => src}/StdLib/Lib/asyncore.py | 0 {Src.GetRenamed => src}/StdLib/Lib/base64.py | 0 {Src.GetRenamed => src}/StdLib/Lib/bdb.py | 0 {Src.GetRenamed => src}/StdLib/Lib/binhex.py | 0 {Src.GetRenamed => src}/StdLib/Lib/bisect.py | 0 {Src.GetRenamed => src}/StdLib/Lib/bz2.py | 0 {Src.GetRenamed => src}/StdLib/Lib/cProfile.py | 0 {Src.GetRenamed => src}/StdLib/Lib/calendar.py | 0 {Src.GetRenamed => src}/StdLib/Lib/cgi.py | 0 {Src.GetRenamed => src}/StdLib/Lib/cgitb.py | 0 {Src.GetRenamed => src}/StdLib/Lib/chunk.py | 0 {Src.GetRenamed => src}/StdLib/Lib/clrtype.py | 0 {Src.GetRenamed => src}/StdLib/Lib/cmd.py | 0 {Src.GetRenamed => src}/StdLib/Lib/code.py | 0 {Src.GetRenamed => src}/StdLib/Lib/codecs.py | 0 {Src.GetRenamed => src}/StdLib/Lib/codeop.py | 0 .../StdLib/Lib/collections/__init__.py | 0 .../StdLib/Lib/collections/__main__.py | 0 .../StdLib/Lib/collections/abc.py | 0 {Src.GetRenamed => src}/StdLib/Lib/colorsys.py | 0 {Src.GetRenamed => src}/StdLib/Lib/compileall.py | 0 .../StdLib/Lib/concurrent/__init__.py | 0 .../StdLib/Lib/concurrent/futures/__init__.py | 0 .../StdLib/Lib/concurrent/futures/_base.py | 0 .../StdLib/Lib/concurrent/futures/process.py | 0 .../StdLib/Lib/concurrent/futures/thread.py | 0 {Src.GetRenamed => src}/StdLib/Lib/configparser.py | 0 {Src.GetRenamed => src}/StdLib/Lib/contextlib.py | 0 {Src.GetRenamed => src}/StdLib/Lib/copy.py | 0 {Src.GetRenamed => src}/StdLib/Lib/copyreg.py | 0 {Src.GetRenamed => src}/StdLib/Lib/crypt.py | 0 {Src.GetRenamed => src}/StdLib/Lib/csv.py | 0 .../StdLib/Lib/ctypes/__init__.py | 0 .../StdLib/Lib/ctypes/_endian.py | 0 .../StdLib/Lib/ctypes/macholib/README.ctypes | 0 .../StdLib/Lib/ctypes/macholib/__init__.py | 0 .../StdLib/Lib/ctypes/macholib/dyld.py | 0 .../StdLib/Lib/ctypes/macholib/dylib.py | 0 .../StdLib/Lib/ctypes/macholib/fetch_macholib | 0 .../StdLib/Lib/ctypes/macholib/fetch_macholib.bat | 0 .../StdLib/Lib/ctypes/macholib/framework.py | 0 .../StdLib/Lib/ctypes/test/__init__.py | 0 .../StdLib/Lib/ctypes/test/__main__.py | 0 .../StdLib/Lib/ctypes/test/test_anon.py | 0 .../StdLib/Lib/ctypes/test/test_array_in_pointer.py | 0 .../StdLib/Lib/ctypes/test/test_arrays.py | 0 .../StdLib/Lib/ctypes/test/test_as_parameter.py | 0 .../StdLib/Lib/ctypes/test/test_bitfields.py | 0 .../StdLib/Lib/ctypes/test/test_buffers.py | 0 .../StdLib/Lib/ctypes/test/test_bytes.py | 0 .../StdLib/Lib/ctypes/test/test_byteswap.py | 0 .../StdLib/Lib/ctypes/test/test_callbacks.py | 0 .../StdLib/Lib/ctypes/test/test_cast.py | 0 .../StdLib/Lib/ctypes/test/test_cfuncs.py | 0 .../StdLib/Lib/ctypes/test/test_checkretval.py | 0 .../StdLib/Lib/ctypes/test/test_delattr.py | 0 .../StdLib/Lib/ctypes/test/test_errno.py | 0 .../StdLib/Lib/ctypes/test/test_find.py | 0 .../StdLib/Lib/ctypes/test/test_frombuffer.py | 0 .../StdLib/Lib/ctypes/test/test_funcptr.py | 0 .../StdLib/Lib/ctypes/test/test_functions.py | 0 .../StdLib/Lib/ctypes/test/test_incomplete.py | 0 .../StdLib/Lib/ctypes/test/test_init.py | 0 .../StdLib/Lib/ctypes/test/test_internals.py | 0 .../StdLib/Lib/ctypes/test/test_keeprefs.py | 0 .../StdLib/Lib/ctypes/test/test_libc.py | 0 .../StdLib/Lib/ctypes/test/test_loading.py | 0 .../StdLib/Lib/ctypes/test/test_macholib.py | 0 .../StdLib/Lib/ctypes/test/test_memfunctions.py | 0 .../StdLib/Lib/ctypes/test/test_numbers.py | 0 .../StdLib/Lib/ctypes/test/test_objects.py | 0 .../StdLib/Lib/ctypes/test/test_parameters.py | 0 .../StdLib/Lib/ctypes/test/test_pep3118.py | 0 .../StdLib/Lib/ctypes/test/test_pickling.py | 0 .../StdLib/Lib/ctypes/test/test_pointers.py | 0 .../StdLib/Lib/ctypes/test/test_prototypes.py | 0 .../StdLib/Lib/ctypes/test/test_python_api.py | 0 .../StdLib/Lib/ctypes/test/test_random_things.py | 0 .../StdLib/Lib/ctypes/test/test_refcounts.py | 0 .../StdLib/Lib/ctypes/test/test_repr.py | 0 .../StdLib/Lib/ctypes/test/test_returnfuncptrs.py | 0 .../StdLib/Lib/ctypes/test/test_simplesubclasses.py | 0 .../StdLib/Lib/ctypes/test/test_sizes.py | 0 .../StdLib/Lib/ctypes/test/test_slicing.py | 0 .../StdLib/Lib/ctypes/test/test_stringptr.py | 0 .../StdLib/Lib/ctypes/test/test_strings.py | 0 .../StdLib/Lib/ctypes/test/test_struct_fields.py | 0 .../StdLib/Lib/ctypes/test/test_structures.py | 0 .../Lib/ctypes/test/test_unaligned_structures.py | 0 .../StdLib/Lib/ctypes/test/test_unicode.py | 0 .../StdLib/Lib/ctypes/test/test_values.py | 0 .../StdLib/Lib/ctypes/test/test_varsize_struct.py | 0 .../StdLib/Lib/ctypes/test/test_win32.py | 0 .../StdLib/Lib/ctypes/test/test_wintypes.py | 0 {Src.GetRenamed => src}/StdLib/Lib/ctypes/util.py | 0 .../StdLib/Lib/ctypes/wintypes.py | 0 .../StdLib/Lib/curses/__init__.py | 0 {Src.GetRenamed => src}/StdLib/Lib/curses/ascii.py | 0 .../StdLib/Lib/curses/has_key.py | 0 {Src.GetRenamed => src}/StdLib/Lib/curses/panel.py | 0 .../StdLib/Lib/curses/textpad.py | 0 {Src.GetRenamed => src}/StdLib/Lib/datetime.py | 0 {Src.GetRenamed => src}/StdLib/Lib/dbm/__init__.py | 0 {Src.GetRenamed => src}/StdLib/Lib/dbm/dumb.py | 0 {Src.GetRenamed => src}/StdLib/Lib/dbm/gnu.py | 0 {Src.GetRenamed => src}/StdLib/Lib/dbm/ndbm.py | 0 {Src.GetRenamed => src}/StdLib/Lib/decimal.py | 0 {Src.GetRenamed => src}/StdLib/Lib/difflib.py | 0 {Src.GetRenamed => src}/StdLib/Lib/dis.py | 0 {Src.GetRenamed => src}/StdLib/Lib/distutils/README | 0 .../StdLib/Lib/distutils/__init__.py | 0 .../StdLib/Lib/distutils/archive_util.py | 0 .../StdLib/Lib/distutils/bcppcompiler.py | 0 .../StdLib/Lib/distutils/ccompiler.py | 0 {Src.GetRenamed => src}/StdLib/Lib/distutils/cmd.py | 0 .../StdLib/Lib/distutils/command/__init__.py | 0 .../StdLib/Lib/distutils/command/bdist.py | 0 .../StdLib/Lib/distutils/command/bdist_dumb.py | 0 .../StdLib/Lib/distutils/command/bdist_msi.py | 0 .../StdLib/Lib/distutils/command/bdist_rpm.py | 0 .../StdLib/Lib/distutils/command/bdist_wininst.py | 0 .../StdLib/Lib/distutils/command/build.py | 0 .../StdLib/Lib/distutils/command/build_clib.py | 0 .../StdLib/Lib/distutils/command/build_ext.py | 0 .../StdLib/Lib/distutils/command/build_py.py | 0 .../StdLib/Lib/distutils/command/build_scripts.py | 0 .../StdLib/Lib/distutils/command/check.py | 0 .../StdLib/Lib/distutils/command/clean.py | 0 .../StdLib/Lib/distutils/command/command_template | 0 .../StdLib/Lib/distutils/command/config.py | 0 .../StdLib/Lib/distutils/command/install.py | 0 .../StdLib/Lib/distutils/command/install_data.py | 0 .../Lib/distutils/command/install_egg_info.py | 0 .../StdLib/Lib/distutils/command/install_headers.py | 0 .../StdLib/Lib/distutils/command/install_lib.py | 0 .../StdLib/Lib/distutils/command/install_scripts.py | 0 .../StdLib/Lib/distutils/command/register.py | 0 .../StdLib/Lib/distutils/command/sdist.py | 0 .../StdLib/Lib/distutils/command/upload.py | 0 .../Lib/distutils/command/wininst-10.0-amd64.exe | Bin .../StdLib/Lib/distutils/command/wininst-10.0.exe | Bin .../StdLib/Lib/distutils/command/wininst-6.0.exe | Bin .../StdLib/Lib/distutils/command/wininst-7.1.exe | Bin .../StdLib/Lib/distutils/command/wininst-8.0.exe | Bin .../Lib/distutils/command/wininst-9.0-amd64.exe | Bin .../StdLib/Lib/distutils/command/wininst-9.0.exe | Bin .../StdLib/Lib/distutils/config.py | 0 .../StdLib/Lib/distutils/core.py | 0 .../StdLib/Lib/distutils/cygwinccompiler.py | 0 .../StdLib/Lib/distutils/debug.py | 0 .../StdLib/Lib/distutils/dep_util.py | 0 .../StdLib/Lib/distutils/dir_util.py | 0 .../StdLib/Lib/distutils/dist.py | 0 .../StdLib/Lib/distutils/errors.py | 0 .../StdLib/Lib/distutils/extension.py | 0 .../StdLib/Lib/distutils/fancy_getopt.py | 0 .../StdLib/Lib/distutils/file_util.py | 0 .../StdLib/Lib/distutils/filelist.py | 0 {Src.GetRenamed => src}/StdLib/Lib/distutils/log.py | 0 .../StdLib/Lib/distutils/msvc9compiler.py | 0 .../StdLib/Lib/distutils/msvccompiler.py | 0 .../StdLib/Lib/distutils/spawn.py | 0 .../StdLib/Lib/distutils/sysconfig.py | 0 .../StdLib/Lib/distutils/tests/Setup.sample | 0 .../StdLib/Lib/distutils/tests/__init__.py | 0 .../StdLib/Lib/distutils/tests/support.py | 0 .../StdLib/Lib/distutils/tests/test_archive_util.py | 0 .../StdLib/Lib/distutils/tests/test_bdist.py | 0 .../StdLib/Lib/distutils/tests/test_bdist_dumb.py | 0 .../StdLib/Lib/distutils/tests/test_bdist_msi.py | 0 .../StdLib/Lib/distutils/tests/test_bdist_rpm.py | 0 .../Lib/distutils/tests/test_bdist_wininst.py | 0 .../StdLib/Lib/distutils/tests/test_build.py | 0 .../StdLib/Lib/distutils/tests/test_build_clib.py | 0 .../StdLib/Lib/distutils/tests/test_build_ext.py | 0 .../StdLib/Lib/distutils/tests/test_build_py.py | 0 .../Lib/distutils/tests/test_build_scripts.py | 0 .../StdLib/Lib/distutils/tests/test_check.py | 0 .../StdLib/Lib/distutils/tests/test_clean.py | 0 .../StdLib/Lib/distutils/tests/test_cmd.py | 0 .../StdLib/Lib/distutils/tests/test_config.py | 0 .../StdLib/Lib/distutils/tests/test_config_cmd.py | 0 .../StdLib/Lib/distutils/tests/test_core.py | 0 .../Lib/distutils/tests/test_cygwinccompiler.py | 0 .../StdLib/Lib/distutils/tests/test_dep_util.py | 0 .../StdLib/Lib/distutils/tests/test_dir_util.py | 0 .../StdLib/Lib/distutils/tests/test_dist.py | 0 .../StdLib/Lib/distutils/tests/test_extension.py | 0 .../StdLib/Lib/distutils/tests/test_file_util.py | 0 .../StdLib/Lib/distutils/tests/test_filelist.py | 0 .../StdLib/Lib/distutils/tests/test_install.py | 0 .../StdLib/Lib/distutils/tests/test_install_data.py | 0 .../Lib/distutils/tests/test_install_headers.py | 0 .../StdLib/Lib/distutils/tests/test_install_lib.py | 0 .../Lib/distutils/tests/test_install_scripts.py | 0 .../StdLib/Lib/distutils/tests/test_log.py | 0 .../Lib/distutils/tests/test_msvc9compiler.py | 0 .../StdLib/Lib/distutils/tests/test_register.py | 0 .../StdLib/Lib/distutils/tests/test_sdist.py | 0 .../StdLib/Lib/distutils/tests/test_spawn.py | 0 .../StdLib/Lib/distutils/tests/test_sysconfig.py | 0 .../StdLib/Lib/distutils/tests/test_text_file.py | 0 .../Lib/distutils/tests/test_unixccompiler.py | 0 .../StdLib/Lib/distutils/tests/test_upload.py | 0 .../StdLib/Lib/distutils/tests/test_util.py | 0 .../StdLib/Lib/distutils/tests/test_version.py | 0 .../Lib/distutils/tests/test_versionpredicate.py | 0 .../StdLib/Lib/distutils/text_file.py | 0 .../StdLib/Lib/distutils/unixccompiler.py | 0 .../StdLib/Lib/distutils/util.py | 0 .../StdLib/Lib/distutils/version.py | 0 .../StdLib/Lib/distutils/versionpredicate.py | 0 {Src.GetRenamed => src}/StdLib/Lib/doctest.py | 0 .../StdLib/Lib/dummy_threading.py | 0 .../StdLib/Lib/email/__init__.py | 0 .../StdLib/Lib/email/_encoded_words.py | 0 .../StdLib/Lib/email/_header_value_parser.py | 0 .../StdLib/Lib/email/_parseaddr.py | 0 .../StdLib/Lib/email/_policybase.py | 0 .../StdLib/Lib/email/architecture.rst | 0 .../StdLib/Lib/email/base64mime.py | 0 {Src.GetRenamed => src}/StdLib/Lib/email/charset.py | 0 .../StdLib/Lib/email/contentmanager.py | 0 .../StdLib/Lib/email/encoders.py | 0 {Src.GetRenamed => src}/StdLib/Lib/email/errors.py | 0 .../StdLib/Lib/email/feedparser.py | 0 .../StdLib/Lib/email/generator.py | 0 {Src.GetRenamed => src}/StdLib/Lib/email/header.py | 0 .../StdLib/Lib/email/headerregistry.py | 0 .../StdLib/Lib/email/iterators.py | 0 {Src.GetRenamed => src}/StdLib/Lib/email/message.py | 0 .../StdLib/Lib/email/mime/__init__.py | 0 .../StdLib/Lib/email/mime/application.py | 0 .../StdLib/Lib/email/mime/audio.py | 0 .../StdLib/Lib/email/mime/base.py | 0 .../StdLib/Lib/email/mime/image.py | 0 .../StdLib/Lib/email/mime/message.py | 0 .../StdLib/Lib/email/mime/multipart.py | 0 .../StdLib/Lib/email/mime/nonmultipart.py | 0 .../StdLib/Lib/email/mime/text.py | 0 {Src.GetRenamed => src}/StdLib/Lib/email/parser.py | 0 {Src.GetRenamed => src}/StdLib/Lib/email/policy.py | 0 .../StdLib/Lib/email/quoprimime.py | 0 {Src.GetRenamed => src}/StdLib/Lib/email/utils.py | 0 .../StdLib/Lib/encodings/__init__.py | 0 .../StdLib/Lib/encodings/aliases.py | 0 .../StdLib/Lib/encodings/ascii.py | 0 .../StdLib/Lib/encodings/base64_codec.py | 0 .../StdLib/Lib/encodings/big5.py | 0 .../StdLib/Lib/encodings/big5hkscs.py | 0 .../StdLib/Lib/encodings/bz2_codec.py | 0 .../StdLib/Lib/encodings/charmap.py | 0 .../StdLib/Lib/encodings/cp037.py | 0 .../StdLib/Lib/encodings/cp1006.py | 0 .../StdLib/Lib/encodings/cp1026.py | 0 .../StdLib/Lib/encodings/cp1125.py | 0 .../StdLib/Lib/encodings/cp1140.py | 0 .../StdLib/Lib/encodings/cp1250.py | 0 .../StdLib/Lib/encodings/cp1251.py | 0 .../StdLib/Lib/encodings/cp1252.py | 0 .../StdLib/Lib/encodings/cp1253.py | 0 .../StdLib/Lib/encodings/cp1254.py | 0 .../StdLib/Lib/encodings/cp1255.py | 0 .../StdLib/Lib/encodings/cp1256.py | 0 .../StdLib/Lib/encodings/cp1257.py | 0 .../StdLib/Lib/encodings/cp1258.py | 0 .../StdLib/Lib/encodings/cp273.py | 0 .../StdLib/Lib/encodings/cp424.py | 0 .../StdLib/Lib/encodings/cp437.py | 0 .../StdLib/Lib/encodings/cp500.py | 0 .../StdLib/Lib/encodings/cp65001.py | 0 .../StdLib/Lib/encodings/cp720.py | 0 .../StdLib/Lib/encodings/cp737.py | 0 .../StdLib/Lib/encodings/cp775.py | 0 .../StdLib/Lib/encodings/cp850.py | 0 .../StdLib/Lib/encodings/cp852.py | 0 .../StdLib/Lib/encodings/cp855.py | 0 .../StdLib/Lib/encodings/cp856.py | 0 .../StdLib/Lib/encodings/cp857.py | 0 .../StdLib/Lib/encodings/cp858.py | 0 .../StdLib/Lib/encodings/cp860.py | 0 .../StdLib/Lib/encodings/cp861.py | 0 .../StdLib/Lib/encodings/cp862.py | 0 .../StdLib/Lib/encodings/cp863.py | 0 .../StdLib/Lib/encodings/cp864.py | 0 .../StdLib/Lib/encodings/cp865.py | 0 .../StdLib/Lib/encodings/cp866.py | 0 .../StdLib/Lib/encodings/cp869.py | 0 .../StdLib/Lib/encodings/cp874.py | 0 .../StdLib/Lib/encodings/cp875.py | 0 .../StdLib/Lib/encodings/cp932.py | 0 .../StdLib/Lib/encodings/cp949.py | 0 .../StdLib/Lib/encodings/cp950.py | 0 .../StdLib/Lib/encodings/euc_jis_2004.py | 0 .../StdLib/Lib/encodings/euc_jisx0213.py | 0 .../StdLib/Lib/encodings/euc_jp.py | 0 .../StdLib/Lib/encodings/euc_kr.py | 0 .../StdLib/Lib/encodings/gb18030.py | 0 .../StdLib/Lib/encodings/gb2312.py | 0 {Src.GetRenamed => src}/StdLib/Lib/encodings/gbk.py | 0 .../StdLib/Lib/encodings/hex_codec.py | 0 .../StdLib/Lib/encodings/hp_roman8.py | 0 {Src.GetRenamed => src}/StdLib/Lib/encodings/hz.py | 0 .../StdLib/Lib/encodings/idna.py | 0 .../StdLib/Lib/encodings/iso2022_jp.py | 0 .../StdLib/Lib/encodings/iso2022_jp_1.py | 0 .../StdLib/Lib/encodings/iso2022_jp_2.py | 0 .../StdLib/Lib/encodings/iso2022_jp_2004.py | 0 .../StdLib/Lib/encodings/iso2022_jp_3.py | 0 .../StdLib/Lib/encodings/iso2022_jp_ext.py | 0 .../StdLib/Lib/encodings/iso2022_kr.py | 0 .../StdLib/Lib/encodings/iso8859_1.py | 0 .../StdLib/Lib/encodings/iso8859_10.py | 0 .../StdLib/Lib/encodings/iso8859_11.py | 0 .../StdLib/Lib/encodings/iso8859_13.py | 0 .../StdLib/Lib/encodings/iso8859_14.py | 0 .../StdLib/Lib/encodings/iso8859_15.py | 0 .../StdLib/Lib/encodings/iso8859_16.py | 0 .../StdLib/Lib/encodings/iso8859_2.py | 0 .../StdLib/Lib/encodings/iso8859_3.py | 0 .../StdLib/Lib/encodings/iso8859_4.py | 0 .../StdLib/Lib/encodings/iso8859_5.py | 0 .../StdLib/Lib/encodings/iso8859_6.py | 0 .../StdLib/Lib/encodings/iso8859_7.py | 0 .../StdLib/Lib/encodings/iso8859_8.py | 0 .../StdLib/Lib/encodings/iso8859_9.py | 0 .../StdLib/Lib/encodings/johab.py | 0 .../StdLib/Lib/encodings/koi8_r.py | 0 .../StdLib/Lib/encodings/koi8_u.py | 0 .../StdLib/Lib/encodings/latin_1.py | 0 .../StdLib/Lib/encodings/mac_arabic.py | 0 .../StdLib/Lib/encodings/mac_centeuro.py | 0 .../StdLib/Lib/encodings/mac_croatian.py | 0 .../StdLib/Lib/encodings/mac_cyrillic.py | 0 .../StdLib/Lib/encodings/mac_farsi.py | 0 .../StdLib/Lib/encodings/mac_greek.py | 0 .../StdLib/Lib/encodings/mac_iceland.py | 0 .../StdLib/Lib/encodings/mac_latin2.py | 0 .../StdLib/Lib/encodings/mac_roman.py | 0 .../StdLib/Lib/encodings/mac_romanian.py | 0 .../StdLib/Lib/encodings/mac_turkish.py | 0 .../StdLib/Lib/encodings/mbcs.py | 0 .../StdLib/Lib/encodings/palmos.py | 0 .../StdLib/Lib/encodings/ptcp154.py | 0 .../StdLib/Lib/encodings/punycode.py | 0 .../StdLib/Lib/encodings/quopri_codec.py | 0 .../StdLib/Lib/encodings/raw_unicode_escape.py | 0 .../StdLib/Lib/encodings/rot_13.py | 0 .../StdLib/Lib/encodings/shift_jis.py | 0 .../StdLib/Lib/encodings/shift_jis_2004.py | 0 .../StdLib/Lib/encodings/shift_jisx0213.py | 0 .../StdLib/Lib/encodings/tis_620.py | 0 .../StdLib/Lib/encodings/undefined.py | 0 .../StdLib/Lib/encodings/unicode_escape.py | 0 .../StdLib/Lib/encodings/unicode_internal.py | 0 .../StdLib/Lib/encodings/utf_16.py | 0 .../StdLib/Lib/encodings/utf_16_be.py | 0 .../StdLib/Lib/encodings/utf_16_le.py | 0 .../StdLib/Lib/encodings/utf_32.py | 0 .../StdLib/Lib/encodings/utf_32_be.py | 0 .../StdLib/Lib/encodings/utf_32_le.py | 0 .../StdLib/Lib/encodings/utf_7.py | 0 .../StdLib/Lib/encodings/utf_8.py | 0 .../StdLib/Lib/encodings/utf_8_sig.py | 0 .../StdLib/Lib/encodings/uu_codec.py | 0 .../StdLib/Lib/encodings/zlib_codec.py | 0 .../StdLib/Lib/ensurepip/__init__.py | 0 .../StdLib/Lib/ensurepip/__main__.py | 0 .../_bundled/pip-18.1-py2.py3-none-any.whl | Bin .../_bundled/setuptools-40.6.2-py2.py3-none-any.whl | Bin .../StdLib/Lib/ensurepip/_uninstall.py | 0 {Src.GetRenamed => src}/StdLib/Lib/enum.py | 0 {Src.GetRenamed => src}/StdLib/Lib/filecmp.py | 0 {Src.GetRenamed => src}/StdLib/Lib/fileinput.py | 0 {Src.GetRenamed => src}/StdLib/Lib/fnmatch.py | 0 {Src.GetRenamed => src}/StdLib/Lib/formatter.py | 0 {Src.GetRenamed => src}/StdLib/Lib/fractions.py | 0 {Src.GetRenamed => src}/StdLib/Lib/ftplib.py | 0 {Src.GetRenamed => src}/StdLib/Lib/functools.py | 0 {Src.GetRenamed => src}/StdLib/Lib/genericpath.py | 0 {Src.GetRenamed => src}/StdLib/Lib/getopt.py | 0 {Src.GetRenamed => src}/StdLib/Lib/getpass.py | 0 {Src.GetRenamed => src}/StdLib/Lib/gettext.py | 0 {Src.GetRenamed => src}/StdLib/Lib/glob.py | 0 {Src.GetRenamed => src}/StdLib/Lib/gzip.py | 0 {Src.GetRenamed => src}/StdLib/Lib/hashlib.py | 0 {Src.GetRenamed => src}/StdLib/Lib/heapq.py | 0 {Src.GetRenamed => src}/StdLib/Lib/hmac.py | 0 {Src.GetRenamed => src}/StdLib/Lib/html/__init__.py | 0 {Src.GetRenamed => src}/StdLib/Lib/html/entities.py | 0 {Src.GetRenamed => src}/StdLib/Lib/html/parser.py | 0 {Src.GetRenamed => src}/StdLib/Lib/http/__init__.py | 0 {Src.GetRenamed => src}/StdLib/Lib/http/client.py | 0 .../StdLib/Lib/http/cookiejar.py | 0 {Src.GetRenamed => src}/StdLib/Lib/http/cookies.py | 0 {Src.GetRenamed => src}/StdLib/Lib/http/server.py | 0 .../StdLib/Lib/idlelib/AutoComplete.py | 0 .../StdLib/Lib/idlelib/AutoCompleteWindow.py | 0 .../StdLib/Lib/idlelib/AutoExpand.py | 0 .../StdLib/Lib/idlelib/Bindings.py | 0 .../StdLib/Lib/idlelib/CREDITS.txt | 0 .../StdLib/Lib/idlelib/CallTipWindow.py | 0 .../StdLib/Lib/idlelib/CallTips.py | 0 .../StdLib/Lib/idlelib/ChangeLog | 0 .../StdLib/Lib/idlelib/ClassBrowser.py | 0 .../StdLib/Lib/idlelib/CodeContext.py | 0 .../StdLib/Lib/idlelib/ColorDelegator.py | 0 .../StdLib/Lib/idlelib/Debugger.py | 0 .../StdLib/Lib/idlelib/Delegator.py | 0 .../StdLib/Lib/idlelib/EditorWindow.py | 0 .../StdLib/Lib/idlelib/FileList.py | 0 .../StdLib/Lib/idlelib/FormatParagraph.py | 0 .../StdLib/Lib/idlelib/GrepDialog.py | 0 .../StdLib/Lib/idlelib/HISTORY.txt | 0 .../StdLib/Lib/idlelib/HyperParser.py | 0 .../StdLib/Lib/idlelib/IOBinding.py | 0 .../StdLib/Lib/idlelib/Icons/folder.gif | Bin .../StdLib/Lib/idlelib/Icons/idle.icns | Bin .../StdLib/Lib/idlelib/Icons/idle.ico | Bin .../StdLib/Lib/idlelib/Icons/idle_16.gif | Bin .../StdLib/Lib/idlelib/Icons/idle_16.png | Bin .../StdLib/Lib/idlelib/Icons/idle_32.gif | Bin .../StdLib/Lib/idlelib/Icons/idle_32.png | Bin .../StdLib/Lib/idlelib/Icons/idle_48.gif | Bin .../StdLib/Lib/idlelib/Icons/idle_48.png | Bin .../StdLib/Lib/idlelib/Icons/minusnode.gif | Bin .../StdLib/Lib/idlelib/Icons/openfolder.gif | Bin .../StdLib/Lib/idlelib/Icons/plusnode.gif | Bin .../StdLib/Lib/idlelib/Icons/python.gif | Bin .../StdLib/Lib/idlelib/Icons/tk.gif | Bin .../StdLib/Lib/idlelib/IdleHistory.py | 0 .../StdLib/Lib/idlelib/MultiCall.py | 0 .../StdLib/Lib/idlelib/MultiStatusBar.py | 0 {Src.GetRenamed => src}/StdLib/Lib/idlelib/NEWS.txt | 0 .../StdLib/Lib/idlelib/ObjectBrowser.py | 0 .../StdLib/Lib/idlelib/OutputWindow.py | 0 .../StdLib/Lib/idlelib/ParenMatch.py | 0 .../StdLib/Lib/idlelib/PathBrowser.py | 0 .../StdLib/Lib/idlelib/Percolator.py | 0 .../StdLib/Lib/idlelib/PyParse.py | 0 .../StdLib/Lib/idlelib/PyShell.py | 0 .../StdLib/Lib/idlelib/README.txt | 0 .../StdLib/Lib/idlelib/RemoteDebugger.py | 0 .../StdLib/Lib/idlelib/RemoteObjectBrowser.py | 0 .../StdLib/Lib/idlelib/ReplaceDialog.py | 0 .../StdLib/Lib/idlelib/RstripExtension.py | 0 .../StdLib/Lib/idlelib/ScriptBinding.py | 0 .../StdLib/Lib/idlelib/ScrolledList.py | 0 .../StdLib/Lib/idlelib/SearchDialog.py | 0 .../StdLib/Lib/idlelib/SearchDialogBase.py | 0 .../StdLib/Lib/idlelib/SearchEngine.py | 0 .../StdLib/Lib/idlelib/StackViewer.py | 0 {Src.GetRenamed => src}/StdLib/Lib/idlelib/TODO.txt | 0 .../StdLib/Lib/idlelib/ToolTip.py | 0 .../StdLib/Lib/idlelib/TreeWidget.py | 0 .../StdLib/Lib/idlelib/UndoDelegator.py | 0 .../StdLib/Lib/idlelib/WidgetRedirector.py | 0 .../StdLib/Lib/idlelib/WindowList.py | 0 .../StdLib/Lib/idlelib/ZoomHeight.py | 0 .../StdLib/Lib/idlelib/__init__.py | 0 .../StdLib/Lib/idlelib/__main__.py | 0 .../StdLib/Lib/idlelib/aboutDialog.py | 0 .../StdLib/Lib/idlelib/config-extensions.def | 0 .../StdLib/Lib/idlelib/config-highlight.def | 0 .../StdLib/Lib/idlelib/config-keys.def | 0 .../StdLib/Lib/idlelib/config-main.def | 0 .../StdLib/Lib/idlelib/configDialog.py | 0 .../StdLib/Lib/idlelib/configHandler.py | 0 .../StdLib/Lib/idlelib/configHelpSourceEdit.py | 0 .../StdLib/Lib/idlelib/configSectionNameDialog.py | 0 .../StdLib/Lib/idlelib/dynOptionMenuWidget.py | 0 .../StdLib/Lib/idlelib/extend.txt | 0 .../StdLib/Lib/idlelib/help.html | 0 {Src.GetRenamed => src}/StdLib/Lib/idlelib/help.py | 0 {Src.GetRenamed => src}/StdLib/Lib/idlelib/help.txt | 0 {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle.bat | 0 {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle.py | 0 {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle.pyw | 0 .../StdLib/Lib/idlelib/idle_test/README.txt | 0 .../StdLib/Lib/idlelib/idle_test/__init__.py | 0 .../StdLib/Lib/idlelib/idle_test/htest.py | 0 .../StdLib/Lib/idlelib/idle_test/mock_idle.py | 0 .../StdLib/Lib/idlelib/idle_test/mock_tk.py | 0 .../Lib/idlelib/idle_test/test_autocomplete.py | 0 .../StdLib/Lib/idlelib/idle_test/test_autoexpand.py | 0 .../StdLib/Lib/idlelib/idle_test/test_calltips.py | 0 .../Lib/idlelib/idle_test/test_config_name.py | 0 .../Lib/idlelib/idle_test/test_configdialog.py | 0 .../StdLib/Lib/idlelib/idle_test/test_delegator.py | 0 .../StdLib/Lib/idlelib/idle_test/test_editor.py | 0 .../Lib/idlelib/idle_test/test_formatparagraph.py | 0 .../StdLib/Lib/idlelib/idle_test/test_grep.py | 0 .../Lib/idlelib/idle_test/test_hyperparser.py | 0 .../Lib/idlelib/idle_test/test_idlehistory.py | 0 .../StdLib/Lib/idlelib/idle_test/test_io.py | 0 .../StdLib/Lib/idlelib/idle_test/test_parenmatch.py | 0 .../Lib/idlelib/idle_test/test_pathbrowser.py | 0 .../StdLib/Lib/idlelib/idle_test/test_rstrip.py | 0 .../Lib/idlelib/idle_test/test_searchdialogbase.py | 0 .../Lib/idlelib/idle_test/test_searchengine.py | 0 .../StdLib/Lib/idlelib/idle_test/test_text.py | 0 .../StdLib/Lib/idlelib/idle_test/test_textview.py | 0 .../StdLib/Lib/idlelib/idle_test/test_warning.py | 0 .../Lib/idlelib/idle_test/test_widgetredir.py | 0 .../StdLib/Lib/idlelib/idlever.py | 0 .../StdLib/Lib/idlelib/keybindingDialog.py | 0 .../StdLib/Lib/idlelib/macosxSupport.py | 0 {Src.GetRenamed => src}/StdLib/Lib/idlelib/rpc.py | 0 {Src.GetRenamed => src}/StdLib/Lib/idlelib/run.py | 0 .../StdLib/Lib/idlelib/tabbedpages.py | 0 .../StdLib/Lib/idlelib/textView.py | 0 {Src.GetRenamed => src}/StdLib/Lib/imaplib.py | 0 {Src.GetRenamed => src}/StdLib/Lib/imghdr.py | 0 {Src.GetRenamed => src}/StdLib/Lib/imp.py | 0 .../StdLib/Lib/importlib/__init__.py | 0 .../StdLib/Lib/importlib/_bootstrap.py | 0 {Src.GetRenamed => src}/StdLib/Lib/importlib/abc.py | 0 .../StdLib/Lib/importlib/machinery.py | 0 .../StdLib/Lib/importlib/util.py | 0 {Src.GetRenamed => src}/StdLib/Lib/inspect.py | 0 {Src.GetRenamed => src}/StdLib/Lib/io.py | 0 {Src.GetRenamed => src}/StdLib/Lib/ipaddress.py | 0 {Src.GetRenamed => src}/StdLib/Lib/json/__init__.py | 0 {Src.GetRenamed => src}/StdLib/Lib/json/decoder.py | 0 {Src.GetRenamed => src}/StdLib/Lib/json/encoder.py | 0 {Src.GetRenamed => src}/StdLib/Lib/json/scanner.py | 0 {Src.GetRenamed => src}/StdLib/Lib/json/tool.py | 0 {Src.GetRenamed => src}/StdLib/Lib/keyword.py | 0 .../StdLib/Lib/lib2to3/Grammar.txt | 0 .../StdLib/Lib/lib2to3/PatternGrammar.txt | 0 .../StdLib/Lib/lib2to3/__init__.py | 0 .../StdLib/Lib/lib2to3/__main__.py | 0 .../StdLib/Lib/lib2to3/btm_matcher.py | 0 .../StdLib/Lib/lib2to3/btm_utils.py | 0 .../StdLib/Lib/lib2to3/fixer_base.py | 0 .../StdLib/Lib/lib2to3/fixer_util.py | 0 .../StdLib/Lib/lib2to3/fixes/__init__.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_apply.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_asserts.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_basestring.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_buffer.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_callable.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_dict.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_except.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_exec.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_execfile.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_exitfunc.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_filter.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_funcattrs.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_future.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_getcwdu.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_has_key.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_idioms.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_import.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_imports.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_imports2.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_input.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_intern.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_isinstance.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_itertools.py | 0 .../Lib/lib2to3/fixes/fix_itertools_imports.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_long.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_map.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_metaclass.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_methodattrs.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_ne.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_next.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_nonzero.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_numliterals.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_operator.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_paren.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_print.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_raise.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_raw_input.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_reduce.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_reload.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_renames.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_repr.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_set_literal.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_standarderror.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_sys_exc.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_throw.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_tuple_params.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_types.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_unicode.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_urllib.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_ws_comma.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_xrange.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_xreadlines.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_zip.py | 0 {Src.GetRenamed => src}/StdLib/Lib/lib2to3/main.py | 0 .../StdLib/Lib/lib2to3/patcomp.py | 0 .../StdLib/Lib/lib2to3/pgen2/__init__.py | 0 .../StdLib/Lib/lib2to3/pgen2/conv.py | 0 .../StdLib/Lib/lib2to3/pgen2/driver.py | 0 .../StdLib/Lib/lib2to3/pgen2/grammar.py | 0 .../StdLib/Lib/lib2to3/pgen2/literals.py | 0 .../StdLib/Lib/lib2to3/pgen2/parse.py | 0 .../StdLib/Lib/lib2to3/pgen2/pgen.py | 0 .../StdLib/Lib/lib2to3/pgen2/token.py | 0 .../StdLib/Lib/lib2to3/pgen2/tokenize.py | 0 .../StdLib/Lib/lib2to3/pygram.py | 0 .../StdLib/Lib/lib2to3/pytree.py | 0 .../StdLib/Lib/lib2to3/refactor.py | 0 .../StdLib/Lib/lib2to3/tests/__init__.py | 0 .../StdLib/Lib/lib2to3/tests/__main__.py | 0 .../StdLib/Lib/lib2to3/tests/data/README | 0 .../StdLib/Lib/lib2to3/tests/data/bom.py | 0 .../StdLib/Lib/lib2to3/tests/data/crlf.py | 0 .../Lib/lib2to3/tests/data/different_encoding.py | 0 .../StdLib/Lib/lib2to3/tests/data/false_encoding.py | 0 .../Lib/lib2to3/tests/data/fixers/bad_order.py | 0 .../lib2to3/tests/data/fixers/myfixes/__init__.py | 0 .../tests/data/fixers/myfixes/fix_explicit.py | 0 .../lib2to3/tests/data/fixers/myfixes/fix_first.py | 0 .../lib2to3/tests/data/fixers/myfixes/fix_last.py | 0 .../lib2to3/tests/data/fixers/myfixes/fix_parrot.py | 0 .../tests/data/fixers/myfixes/fix_preorder.py | 0 .../Lib/lib2to3/tests/data/fixers/no_fixer_cls.py | 0 .../Lib/lib2to3/tests/data/fixers/parrot_example.py | 0 .../Lib/lib2to3/tests/data/infinite_recursion.py | 0 .../Lib/lib2to3/tests/data/py2_test_grammar.py | 0 .../Lib/lib2to3/tests/data/py3_test_grammar.py | 0 .../StdLib/Lib/lib2to3/tests/pytree_idempotency.py | 0 .../StdLib/Lib/lib2to3/tests/support.py | 0 .../StdLib/Lib/lib2to3/tests/test_all_fixers.py | 0 .../StdLib/Lib/lib2to3/tests/test_fixers.py | 0 .../StdLib/Lib/lib2to3/tests/test_main.py | 0 .../StdLib/Lib/lib2to3/tests/test_parser.py | 0 .../StdLib/Lib/lib2to3/tests/test_pytree.py | 0 .../StdLib/Lib/lib2to3/tests/test_refactor.py | 0 .../StdLib/Lib/lib2to3/tests/test_util.py | 0 {Src.GetRenamed => src}/StdLib/Lib/linecache.py | 0 {Src.GetRenamed => src}/StdLib/Lib/locale.py | 0 .../StdLib/Lib/logging/__init__.py | 0 .../StdLib/Lib/logging/config.py | 0 .../StdLib/Lib/logging/handlers.py | 0 {Src.GetRenamed => src}/StdLib/Lib/lzma.py | 0 {Src.GetRenamed => src}/StdLib/Lib/macpath.py | 0 {Src.GetRenamed => src}/StdLib/Lib/macurl2path.py | 0 {Src.GetRenamed => src}/StdLib/Lib/mailbox.py | 0 {Src.GetRenamed => src}/StdLib/Lib/mailcap.py | 0 {Src.GetRenamed => src}/StdLib/Lib/mimetypes.py | 0 {Src.GetRenamed => src}/StdLib/Lib/modulefinder.py | 0 .../StdLib/Lib/msilib/__init__.py | 0 {Src.GetRenamed => src}/StdLib/Lib/msilib/schema.py | 0 .../StdLib/Lib/msilib/sequence.py | 0 {Src.GetRenamed => src}/StdLib/Lib/msilib/text.py | 0 .../StdLib/Lib/multiprocessing/__init__.py | 0 .../StdLib/Lib/multiprocessing/connection.py | 0 .../StdLib/Lib/multiprocessing/context.py | 0 .../StdLib/Lib/multiprocessing/dummy/__init__.py | 0 .../StdLib/Lib/multiprocessing/dummy/connection.py | 0 .../StdLib/Lib/multiprocessing/forkserver.py | 0 .../StdLib/Lib/multiprocessing/heap.py | 0 .../StdLib/Lib/multiprocessing/managers.py | 0 .../StdLib/Lib/multiprocessing/pool.py | 0 .../StdLib/Lib/multiprocessing/popen_fork.py | 0 .../StdLib/Lib/multiprocessing/popen_forkserver.py | 0 .../StdLib/Lib/multiprocessing/popen_spawn_posix.py | 0 .../StdLib/Lib/multiprocessing/popen_spawn_win32.py | 0 .../StdLib/Lib/multiprocessing/process.py | 0 .../StdLib/Lib/multiprocessing/queues.py | 0 .../StdLib/Lib/multiprocessing/reduction.py | 0 .../StdLib/Lib/multiprocessing/resource_sharer.py | 0 .../StdLib/Lib/multiprocessing/semaphore_tracker.py | 0 .../StdLib/Lib/multiprocessing/sharedctypes.py | 0 .../StdLib/Lib/multiprocessing/spawn.py | 0 .../StdLib/Lib/multiprocessing/synchronize.py | 0 .../StdLib/Lib/multiprocessing/util.py | 0 {Src.GetRenamed => src}/StdLib/Lib/netrc.py | 0 {Src.GetRenamed => src}/StdLib/Lib/nntplib.py | 0 {Src.GetRenamed => src}/StdLib/Lib/ntpath.py | 0 {Src.GetRenamed => src}/StdLib/Lib/nturl2path.py | 0 {Src.GetRenamed => src}/StdLib/Lib/numbers.py | 0 {Src.GetRenamed => src}/StdLib/Lib/opcode.py | 0 {Src.GetRenamed => src}/StdLib/Lib/operator.py | 0 {Src.GetRenamed => src}/StdLib/Lib/optparse.py | 0 {Src.GetRenamed => src}/StdLib/Lib/os.py | 0 {Src.GetRenamed => src}/StdLib/Lib/pathlib.py | 0 {Src.GetRenamed => src}/StdLib/Lib/pdb.py | 0 {Src.GetRenamed => src}/StdLib/Lib/pickle.py | 0 {Src.GetRenamed => src}/StdLib/Lib/pickletools.py | 0 {Src.GetRenamed => src}/StdLib/Lib/pipes.py | 0 {Src.GetRenamed => src}/StdLib/Lib/pkgutil.py | 0 {Src.GetRenamed => src}/StdLib/Lib/platform.py | 0 {Src.GetRenamed => src}/StdLib/Lib/plistlib.py | 0 {Src.GetRenamed => src}/StdLib/Lib/poplib.py | 0 {Src.GetRenamed => src}/StdLib/Lib/posixpath.py | 0 {Src.GetRenamed => src}/StdLib/Lib/pprint.py | 0 {Src.GetRenamed => src}/StdLib/Lib/profile.py | 0 {Src.GetRenamed => src}/StdLib/Lib/pstats.py | 0 {Src.GetRenamed => src}/StdLib/Lib/pty.py | 0 {Src.GetRenamed => src}/StdLib/Lib/py_compile.py | 0 {Src.GetRenamed => src}/StdLib/Lib/pyclbr.py | 0 {Src.GetRenamed => src}/StdLib/Lib/pydoc.py | 0 .../StdLib/Lib/pydoc_data/__init__.py | 0 .../StdLib/Lib/pydoc_data/_pydoc.css | 0 .../StdLib/Lib/pydoc_data/topics.py | 0 {Src.GetRenamed => src}/StdLib/Lib/queue.py | 0 {Src.GetRenamed => src}/StdLib/Lib/quopri.py | 0 {Src.GetRenamed => src}/StdLib/Lib/random.py | 0 {Src.GetRenamed => src}/StdLib/Lib/re.py | 0 {Src.GetRenamed => src}/StdLib/Lib/reprlib.py | 0 {Src.GetRenamed => src}/StdLib/Lib/rlcompleter.py | 0 {Src.GetRenamed => src}/StdLib/Lib/runpy.py | 0 {Src.GetRenamed => src}/StdLib/Lib/sched.py | 0 {Src.GetRenamed => src}/StdLib/Lib/selectors.py | 0 {Src.GetRenamed => src}/StdLib/Lib/shelve.py | 0 {Src.GetRenamed => src}/StdLib/Lib/shlex.py | 0 {Src.GetRenamed => src}/StdLib/Lib/shutil.py | 0 .../StdLib/Lib/site-packages/README | 0 {Src.GetRenamed => src}/StdLib/Lib/site.py | 0 {Src.GetRenamed => src}/StdLib/Lib/smtpd.py | 0 {Src.GetRenamed => src}/StdLib/Lib/smtplib.py | 0 {Src.GetRenamed => src}/StdLib/Lib/sndhdr.py | 0 {Src.GetRenamed => src}/StdLib/Lib/socket.py | 0 {Src.GetRenamed => src}/StdLib/Lib/socketserver.py | 0 .../StdLib/Lib/sqlite3/__init__.py | 0 .../StdLib/Lib/sqlite3/dbapi2.py | 0 {Src.GetRenamed => src}/StdLib/Lib/sqlite3/dump.py | 0 .../StdLib/Lib/sqlite3/test/__init__.py | 0 .../StdLib/Lib/sqlite3/test/dbapi.py | 0 .../StdLib/Lib/sqlite3/test/dump.py | 0 .../StdLib/Lib/sqlite3/test/factory.py | 0 .../StdLib/Lib/sqlite3/test/hooks.py | 0 .../StdLib/Lib/sqlite3/test/regression.py | 0 .../StdLib/Lib/sqlite3/test/transactions.py | 0 .../StdLib/Lib/sqlite3/test/types.py | 0 .../StdLib/Lib/sqlite3/test/userfunctions.py | 0 {Src.GetRenamed => src}/StdLib/Lib/sre_compile.py | 0 {Src.GetRenamed => src}/StdLib/Lib/sre_constants.py | 0 {Src.GetRenamed => src}/StdLib/Lib/sre_parse.py | 0 {Src.GetRenamed => src}/StdLib/Lib/ssl.py | 0 {Src.GetRenamed => src}/StdLib/Lib/stat.py | 0 {Src.GetRenamed => src}/StdLib/Lib/statistics.py | 0 {Src.GetRenamed => src}/StdLib/Lib/string.py | 0 {Src.GetRenamed => src}/StdLib/Lib/stringprep.py | 0 {Src.GetRenamed => src}/StdLib/Lib/struct.py | 0 {Src.GetRenamed => src}/StdLib/Lib/subprocess.py | 0 {Src.GetRenamed => src}/StdLib/Lib/sunau.py | 0 {Src.GetRenamed => src}/StdLib/Lib/symbol.py | 0 {Src.GetRenamed => src}/StdLib/Lib/symtable.py | 0 {Src.GetRenamed => src}/StdLib/Lib/sysconfig.py | 0 {Src.GetRenamed => src}/StdLib/Lib/tabnanny.py | 0 {Src.GetRenamed => src}/StdLib/Lib/tarfile.py | 0 {Src.GetRenamed => src}/StdLib/Lib/telnetlib.py | 0 {Src.GetRenamed => src}/StdLib/Lib/tempfile.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/185test.db | Bin .../StdLib/Lib/test/Sine-1000Hz-300ms.aif | Bin {Src.GetRenamed => src}/StdLib/Lib/test/__init__.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/__main__.py | 0 .../StdLib/Lib/test/_test_multiprocessing.py | 0 .../StdLib/Lib/test/audiodata/pluck-alaw.aifc | Bin .../StdLib/Lib/test/audiodata/pluck-pcm16.aiff | Bin .../StdLib/Lib/test/audiodata/pluck-pcm16.au | Bin .../StdLib/Lib/test/audiodata/pluck-pcm16.wav | Bin .../StdLib/Lib/test/audiodata/pluck-pcm24.aiff | Bin .../StdLib/Lib/test/audiodata/pluck-pcm24.au | Bin .../StdLib/Lib/test/audiodata/pluck-pcm24.wav | Bin .../StdLib/Lib/test/audiodata/pluck-pcm32.aiff | Bin .../StdLib/Lib/test/audiodata/pluck-pcm32.au | Bin .../StdLib/Lib/test/audiodata/pluck-pcm32.wav | Bin .../StdLib/Lib/test/audiodata/pluck-pcm8.aiff | Bin .../StdLib/Lib/test/audiodata/pluck-pcm8.au | Bin .../StdLib/Lib/test/audiodata/pluck-pcm8.wav | Bin .../StdLib/Lib/test/audiodata/pluck-ulaw.aifc | Bin .../StdLib/Lib/test/audiodata/pluck-ulaw.au | Bin .../StdLib/Lib/test/audiotest.au | Bin .../StdLib/Lib/test/audiotests.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/autotest.py | 0 .../StdLib/Lib/test/bad_coding.py | 0 .../StdLib/Lib/test/bad_coding2.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/badcert.pem | 0 {Src.GetRenamed => src}/StdLib/Lib/test/badkey.pem | 0 .../StdLib/Lib/test/badsyntax_3131.py | 0 .../StdLib/Lib/test/badsyntax_future10.py | 0 .../StdLib/Lib/test/badsyntax_future3.py | 0 .../StdLib/Lib/test/badsyntax_future4.py | 0 .../StdLib/Lib/test/badsyntax_future5.py | 0 .../StdLib/Lib/test/badsyntax_future6.py | 0 .../StdLib/Lib/test/badsyntax_future7.py | 0 .../StdLib/Lib/test/badsyntax_future8.py | 0 .../StdLib/Lib/test/badsyntax_future9.py | 0 .../StdLib/Lib/test/badsyntax_pep3120.py | 0 .../StdLib/Lib/test/buffer_tests.py | 0 .../StdLib/Lib/test/bytecode_helper.py | 0 .../StdLib/Lib/test/capath/0e4015b9.0 | 0 .../StdLib/Lib/test/capath/4e1295a3.0 | 0 .../StdLib/Lib/test/capath/5ed36f99.0 | 0 .../StdLib/Lib/test/capath/6e88d7b8.0 | 0 .../StdLib/Lib/test/capath/99d0fa06.0 | 0 .../StdLib/Lib/test/capath/ce7b8643.0 | 0 {Src.GetRenamed => src}/StdLib/Lib/test/cfgparser.1 | 0 {Src.GetRenamed => src}/StdLib/Lib/test/cfgparser.2 | 0 {Src.GetRenamed => src}/StdLib/Lib/test/cfgparser.3 | 0 .../StdLib/Lib/test/check_soundcard.vbs | 0 .../StdLib/Lib/test/cjkencodings/big5-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/big5.txt | 0 .../StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/big5hkscs.txt | 0 .../StdLib/Lib/test/cjkencodings/cp949-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/cp949.txt | 0 .../Lib/test/cjkencodings/euc_jisx0213-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/euc_jisx0213.txt | 0 .../StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/euc_jp.txt | 0 .../StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/euc_kr.txt | 0 .../StdLib/Lib/test/cjkencodings/gb18030-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/gb18030.txt | 0 .../StdLib/Lib/test/cjkencodings/gb2312-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/gb2312.txt | 0 .../StdLib/Lib/test/cjkencodings/gbk-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/gbk.txt | 0 .../StdLib/Lib/test/cjkencodings/hz-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/hz.txt | 0 .../Lib/test/cjkencodings/iso2022_jp-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/iso2022_jp.txt | 0 .../Lib/test/cjkencodings/iso2022_kr-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/iso2022_kr.txt | 0 .../StdLib/Lib/test/cjkencodings/johab-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/johab.txt | 0 .../StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/shift_jis.txt | 0 .../Lib/test/cjkencodings/shift_jisx0213-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/shift_jisx0213.txt | 0 .../StdLib/Lib/test/cmath_testcases.txt | 0 .../StdLib/Lib/test/coding20731.py | 0 .../StdLib/Lib/test/crashers/README | 0 .../StdLib/Lib/test/crashers/bogus_code_obj.py | 0 .../StdLib/Lib/test/crashers/gc_inspection.py | 0 .../StdLib/Lib/test/crashers/infinite_loop_re.py | 0 .../Lib/test/crashers/mutation_inside_cyclegc.py | 0 .../StdLib/Lib/test/crashers/recursive_call.py | 0 .../Lib/test/crashers/trace_at_recursion_limit.py | 0 .../StdLib/Lib/test/crashers/underlying_dict.py | 0 .../StdLib/Lib/test/curses_tests.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/data/README | 0 .../StdLib/Lib/test/datetimetester.py | 0 .../StdLib/Lib/test/decimaltestdata/abs.decTest | 0 .../StdLib/Lib/test/decimaltestdata/add.decTest | 0 .../StdLib/Lib/test/decimaltestdata/and.decTest | 0 .../StdLib/Lib/test/decimaltestdata/base.decTest | 0 .../StdLib/Lib/test/decimaltestdata/clamp.decTest | 0 .../StdLib/Lib/test/decimaltestdata/class.decTest | 0 .../StdLib/Lib/test/decimaltestdata/compare.decTest | 0 .../Lib/test/decimaltestdata/comparetotal.decTest | 0 .../Lib/test/decimaltestdata/comparetotmag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/copy.decTest | 0 .../StdLib/Lib/test/decimaltestdata/copyabs.decTest | 0 .../Lib/test/decimaltestdata/copynegate.decTest | 0 .../Lib/test/decimaltestdata/copysign.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddAbs.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddAdd.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddAnd.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddBase.decTest | 0 .../Lib/test/decimaltestdata/ddCanonical.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddClass.decTest | 0 .../Lib/test/decimaltestdata/ddCompare.decTest | 0 .../Lib/test/decimaltestdata/ddCompareSig.decTest | 0 .../Lib/test/decimaltestdata/ddCompareTotal.decTest | 0 .../test/decimaltestdata/ddCompareTotalMag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddCopy.decTest | 0 .../Lib/test/decimaltestdata/ddCopyAbs.decTest | 0 .../Lib/test/decimaltestdata/ddCopyNegate.decTest | 0 .../Lib/test/decimaltestdata/ddCopySign.decTest | 0 .../Lib/test/decimaltestdata/ddDivide.decTest | 0 .../Lib/test/decimaltestdata/ddDivideInt.decTest | 0 .../Lib/test/decimaltestdata/ddEncode.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddFMA.decTest | 0 .../Lib/test/decimaltestdata/ddInvert.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddLogB.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddMax.decTest | 0 .../Lib/test/decimaltestdata/ddMaxMag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddMin.decTest | 0 .../Lib/test/decimaltestdata/ddMinMag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddMinus.decTest | 0 .../Lib/test/decimaltestdata/ddMultiply.decTest | 0 .../Lib/test/decimaltestdata/ddNextMinus.decTest | 0 .../Lib/test/decimaltestdata/ddNextPlus.decTest | 0 .../Lib/test/decimaltestdata/ddNextToward.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddOr.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddPlus.decTest | 0 .../Lib/test/decimaltestdata/ddQuantize.decTest | 0 .../Lib/test/decimaltestdata/ddReduce.decTest | 0 .../Lib/test/decimaltestdata/ddRemainder.decTest | 0 .../test/decimaltestdata/ddRemainderNear.decTest | 0 .../Lib/test/decimaltestdata/ddRotate.decTest | 0 .../Lib/test/decimaltestdata/ddSameQuantum.decTest | 0 .../Lib/test/decimaltestdata/ddScaleB.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddShift.decTest | 0 .../Lib/test/decimaltestdata/ddSubtract.decTest | 0 .../Lib/test/decimaltestdata/ddToIntegral.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddXor.decTest | 0 .../Lib/test/decimaltestdata/decDouble.decTest | 0 .../StdLib/Lib/test/decimaltestdata/decQuad.decTest | 0 .../Lib/test/decimaltestdata/decSingle.decTest | 0 .../StdLib/Lib/test/decimaltestdata/divide.decTest | 0 .../Lib/test/decimaltestdata/divideint.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqAbs.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqAdd.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqAnd.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqBase.decTest | 0 .../Lib/test/decimaltestdata/dqCanonical.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqClass.decTest | 0 .../Lib/test/decimaltestdata/dqCompare.decTest | 0 .../Lib/test/decimaltestdata/dqCompareSig.decTest | 0 .../Lib/test/decimaltestdata/dqCompareTotal.decTest | 0 .../test/decimaltestdata/dqCompareTotalMag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqCopy.decTest | 0 .../Lib/test/decimaltestdata/dqCopyAbs.decTest | 0 .../Lib/test/decimaltestdata/dqCopyNegate.decTest | 0 .../Lib/test/decimaltestdata/dqCopySign.decTest | 0 .../Lib/test/decimaltestdata/dqDivide.decTest | 0 .../Lib/test/decimaltestdata/dqDivideInt.decTest | 0 .../Lib/test/decimaltestdata/dqEncode.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqFMA.decTest | 0 .../Lib/test/decimaltestdata/dqInvert.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqLogB.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqMax.decTest | 0 .../Lib/test/decimaltestdata/dqMaxMag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqMin.decTest | 0 .../Lib/test/decimaltestdata/dqMinMag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqMinus.decTest | 0 .../Lib/test/decimaltestdata/dqMultiply.decTest | 0 .../Lib/test/decimaltestdata/dqNextMinus.decTest | 0 .../Lib/test/decimaltestdata/dqNextPlus.decTest | 0 .../Lib/test/decimaltestdata/dqNextToward.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqOr.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqPlus.decTest | 0 .../Lib/test/decimaltestdata/dqQuantize.decTest | 0 .../Lib/test/decimaltestdata/dqReduce.decTest | 0 .../Lib/test/decimaltestdata/dqRemainder.decTest | 0 .../test/decimaltestdata/dqRemainderNear.decTest | 0 .../Lib/test/decimaltestdata/dqRotate.decTest | 0 .../Lib/test/decimaltestdata/dqSameQuantum.decTest | 0 .../Lib/test/decimaltestdata/dqScaleB.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqShift.decTest | 0 .../Lib/test/decimaltestdata/dqSubtract.decTest | 0 .../Lib/test/decimaltestdata/dqToIntegral.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqXor.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dsBase.decTest | 0 .../Lib/test/decimaltestdata/dsEncode.decTest | 0 .../StdLib/Lib/test/decimaltestdata/exp.decTest | 0 .../StdLib/Lib/test/decimaltestdata/extra.decTest | 0 .../StdLib/Lib/test/decimaltestdata/fma.decTest | 0 .../StdLib/Lib/test/decimaltestdata/inexact.decTest | 0 .../StdLib/Lib/test/decimaltestdata/invert.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ln.decTest | 0 .../StdLib/Lib/test/decimaltestdata/log10.decTest | 0 .../StdLib/Lib/test/decimaltestdata/logb.decTest | 0 .../StdLib/Lib/test/decimaltestdata/max.decTest | 0 .../StdLib/Lib/test/decimaltestdata/maxmag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/min.decTest | 0 .../StdLib/Lib/test/decimaltestdata/minmag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/minus.decTest | 0 .../Lib/test/decimaltestdata/multiply.decTest | 0 .../Lib/test/decimaltestdata/nextminus.decTest | 0 .../Lib/test/decimaltestdata/nextplus.decTest | 0 .../Lib/test/decimaltestdata/nexttoward.decTest | 0 .../StdLib/Lib/test/decimaltestdata/or.decTest | 0 .../StdLib/Lib/test/decimaltestdata/plus.decTest | 0 .../StdLib/Lib/test/decimaltestdata/power.decTest | 0 .../Lib/test/decimaltestdata/powersqrt.decTest | 0 .../Lib/test/decimaltestdata/quantize.decTest | 0 .../Lib/test/decimaltestdata/randomBound32.decTest | 0 .../StdLib/Lib/test/decimaltestdata/randoms.decTest | 0 .../StdLib/Lib/test/decimaltestdata/reduce.decTest | 0 .../Lib/test/decimaltestdata/remainder.decTest | 0 .../Lib/test/decimaltestdata/remainderNear.decTest | 0 .../StdLib/Lib/test/decimaltestdata/rescale.decTest | 0 .../StdLib/Lib/test/decimaltestdata/rotate.decTest | 0 .../Lib/test/decimaltestdata/rounding.decTest | 0 .../Lib/test/decimaltestdata/samequantum.decTest | 0 .../StdLib/Lib/test/decimaltestdata/scaleb.decTest | 0 .../StdLib/Lib/test/decimaltestdata/shift.decTest | 0 .../Lib/test/decimaltestdata/squareroot.decTest | 0 .../Lib/test/decimaltestdata/subtract.decTest | 0 .../StdLib/Lib/test/decimaltestdata/testall.decTest | 0 .../Lib/test/decimaltestdata/tointegral.decTest | 0 .../Lib/test/decimaltestdata/tointegralx.decTest | 0 .../StdLib/Lib/test/decimaltestdata/xor.decTest | 0 {Src.GetRenamed => src}/StdLib/Lib/test/dh1024.pem | 0 .../StdLib/Lib/test/dis_module.py | 0 .../StdLib/Lib/test/doctest_aliases.py | 0 .../StdLib/Lib/test/double_const.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/empty.vbs | 0 .../StdLib/Lib/test/encoded_modules/__init__.py | 0 .../Lib/test/encoded_modules/module_iso_8859_1.py | 0 .../Lib/test/encoded_modules/module_koi8_r.py | 0 .../StdLib/Lib/test/exception_hierarchy.txt | 0 {Src.GetRenamed => src}/StdLib/Lib/test/final_a.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/final_b.py | 0 .../StdLib/Lib/test/floating_points.txt | 0 .../StdLib/Lib/test/fork_wait.py | 0 .../StdLib/Lib/test/formatfloat_testcases.txt | 0 .../StdLib/Lib/test/future_test1.py | 0 .../StdLib/Lib/test/future_test2.py | 0 .../StdLib/Lib/test/gdb_sample.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/ieee754.txt | 0 .../StdLib/Lib/test/imghdrdata/python.bmp | Bin .../StdLib/Lib/test/imghdrdata/python.gif | Bin .../StdLib/Lib/test/imghdrdata/python.jpg | Bin .../StdLib/Lib/test/imghdrdata/python.pbm | 0 .../StdLib/Lib/test/imghdrdata/python.pgm | Bin .../StdLib/Lib/test/imghdrdata/python.png | Bin .../StdLib/Lib/test/imghdrdata/python.ppm | Bin .../StdLib/Lib/test/imghdrdata/python.ras | Bin .../StdLib/Lib/test/imghdrdata/python.sgi | Bin .../StdLib/Lib/test/imghdrdata/python.tiff | Bin .../StdLib/Lib/test/imghdrdata/python.xbm | 0 .../StdLib/Lib/test/inspect_fodder.py | 0 .../StdLib/Lib/test/inspect_fodder2.py | 0 .../StdLib/Lib/test/keycert.passwd.pem | 0 {Src.GetRenamed => src}/StdLib/Lib/test/keycert.pem | 0 .../StdLib/Lib/test/keycert2.pem | 0 .../StdLib/Lib/test/keycert3.pem | 0 .../StdLib/Lib/test/keycert4.pem | 0 .../StdLib/Lib/test/leakers/README.txt | 0 .../StdLib/Lib/test/leakers/__init__.py | 0 .../StdLib/Lib/test/leakers/test_ctypes.py | 0 .../StdLib/Lib/test/leakers/test_selftype.py | 0 .../StdLib/Lib/test/list_tests.py | 0 .../StdLib/Lib/test/lock_tests.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/mailcap.txt | 0 .../StdLib/Lib/test/make_ssl_certs.py | 0 .../StdLib/Lib/test/mapping_tests.py | 0 .../StdLib/Lib/test/math_testcases.txt | 0 .../StdLib/Lib/test/memory_watchdog.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/mime.types | 0 .../StdLib/Lib/test/mock_socket.py | 0 .../StdLib/Lib/test/mod_generics_cache.py | 0 .../StdLib/Lib/test/mp_fork_bomb.py | 0 .../StdLib/Lib/test/multibytecodec_support.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/nokia.pem | 0 .../StdLib/Lib/test/nullbytecert.pem | 0 .../StdLib/Lib/test/nullcert.pem | 0 .../StdLib/Lib/test/outstanding_bugs.py | 0 .../StdLib/Lib/test/pickletester.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/profilee.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/pstats.pck | Bin .../StdLib/Lib/test/pycacert.pem | 0 {Src.GetRenamed => src}/StdLib/Lib/test/pycakey.pem | 0 .../StdLib/Lib/test/pyclbr_input.py | 0 .../StdLib/Lib/test/pydoc_mod.py | 0 .../StdLib/Lib/test/pydocfodder.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/pystone.py | 0 .../StdLib/Lib/test/randv2_32.pck | 0 .../StdLib/Lib/test/randv2_64.pck | 0 {Src.GetRenamed => src}/StdLib/Lib/test/randv3.pck | 0 {Src.GetRenamed => src}/StdLib/Lib/test/re_tests.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/regrtest.py | 0 .../StdLib/Lib/test/relimport.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/reperf.py | 0 .../StdLib/Lib/test/revocation.crl | 0 .../StdLib/Lib/test/sample_doctest.py | 0 .../StdLib/Lib/test/sample_doctest_no_docstrings.py | 0 .../StdLib/Lib/test/sample_doctest_no_doctests.py | 0 .../StdLib/Lib/test/script_helper.py | 0 .../StdLib/Lib/test/selfsigned_pythontestdotnet.pem | 0 .../StdLib/Lib/test/seq_tests.py | 0 .../StdLib/Lib/test/sgml_input.html | 0 {Src.GetRenamed => src}/StdLib/Lib/test/sha256.pem | 0 .../StdLib/Lib/test/sndhdrdata/README | 0 .../StdLib/Lib/test/sndhdrdata/sndhdr.8svx | Bin .../StdLib/Lib/test/sndhdrdata/sndhdr.aifc | Bin .../StdLib/Lib/test/sndhdrdata/sndhdr.aiff | Bin .../StdLib/Lib/test/sndhdrdata/sndhdr.au | Bin .../StdLib/Lib/test/sndhdrdata/sndhdr.hcom | Bin .../StdLib/Lib/test/sndhdrdata/sndhdr.sndt | Bin .../StdLib/Lib/test/sndhdrdata/sndhdr.voc | Bin .../StdLib/Lib/test/sndhdrdata/sndhdr.wav | Bin {Src.GetRenamed => src}/StdLib/Lib/test/sortperf.py | 0 .../StdLib/Lib/test/ssl_cert.pem | 0 .../StdLib/Lib/test/ssl_key.passwd.pem | 0 {Src.GetRenamed => src}/StdLib/Lib/test/ssl_key.pem | 0 .../StdLib/Lib/test/ssl_servers.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/ssltests.py | 0 .../StdLib/Lib/test/string_tests.py | 0 .../StdLib/Lib/test/subprocessdata/fd_status.py | 0 .../StdLib/Lib/test/subprocessdata/input_reader.py | 0 .../StdLib/Lib/test/subprocessdata/qcat.py | 0 .../StdLib/Lib/test/subprocessdata/qgrep.py | 0 .../Lib/test/subprocessdata/sigchild_ignore.py | 0 .../StdLib/Lib/test/support/__init__.py | 0 .../StdLib/Lib/test/talos-2019-0758.pem | 0 .../StdLib/Lib/test/test___all__.py | 0 .../StdLib/Lib/test/test___future__.py | 0 .../StdLib/Lib/test/test__locale.py | 0 .../StdLib/Lib/test/test__opcode.py | 0 .../StdLib/Lib/test/test__osx_support.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_abc.py | 0 .../StdLib/Lib/test/test_abstract_numbers.py | 0 .../StdLib/Lib/test/test_aifc.py | 0 .../StdLib/Lib/test/test_argparse.py | 0 .../StdLib/Lib/test/test_array.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_ast.py | 0 .../StdLib/Lib/test/test_asynchat.py | 0 .../StdLib/Lib/test/test_asyncio/__init__.py | 0 .../StdLib/Lib/test/test_asyncio/__main__.py | 0 .../StdLib/Lib/test/test_asyncio/echo.py | 0 .../StdLib/Lib/test/test_asyncio/echo2.py | 0 .../StdLib/Lib/test/test_asyncio/echo3.py | 0 .../StdLib/Lib/test/test_asyncio/keycert3.pem | 0 .../StdLib/Lib/test/test_asyncio/pycacert.pem | 0 .../StdLib/Lib/test/test_asyncio/ssl_cert.pem | 0 .../StdLib/Lib/test/test_asyncio/ssl_key.pem | 0 .../Lib/test/test_asyncio/test_base_events.py | 0 .../StdLib/Lib/test/test_asyncio/test_events.py | 0 .../StdLib/Lib/test/test_asyncio/test_futures.py | 0 .../StdLib/Lib/test/test_asyncio/test_locks.py | 0 .../Lib/test/test_asyncio/test_proactor_events.py | 0 .../StdLib/Lib/test/test_asyncio/test_queues.py | 0 .../Lib/test/test_asyncio/test_selector_events.py | 0 .../StdLib/Lib/test/test_asyncio/test_sslproto.py | 0 .../StdLib/Lib/test/test_asyncio/test_streams.py | 0 .../StdLib/Lib/test/test_asyncio/test_subprocess.py | 0 .../StdLib/Lib/test/test_asyncio/test_tasks.py | 0 .../StdLib/Lib/test/test_asyncio/test_transports.py | 0 .../Lib/test/test_asyncio/test_unix_events.py | 0 .../Lib/test/test_asyncio/test_windows_events.py | 0 .../Lib/test/test_asyncio/test_windows_utils.py | 0 .../StdLib/Lib/test/test_asyncore.py | 0 .../StdLib/Lib/test/test_atexit.py | 0 .../StdLib/Lib/test/test_audioop.py | 0 .../StdLib/Lib/test/test_augassign.py | 0 .../StdLib/Lib/test/test_base64.py | 0 .../StdLib/Lib/test/test_bigaddrspace.py | 0 .../StdLib/Lib/test/test_bigmem.py | 0 .../StdLib/Lib/test/test_binascii.py | 0 .../StdLib/Lib/test/test_binhex.py | 0 .../StdLib/Lib/test/test_binop.py | 0 .../StdLib/Lib/test/test_bisect.py | 0 .../StdLib/Lib/test/test_bool.py | 0 .../StdLib/Lib/test/test_buffer.py | 0 .../StdLib/Lib/test/test_bufio.py | 0 .../StdLib/Lib/test/test_builtin.py | 0 .../StdLib/Lib/test/test_bytes.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_bz2.py | 0 .../StdLib/Lib/test/test_calendar.py | 0 .../StdLib/Lib/test/test_call.py | 0 .../StdLib/Lib/test/test_capi.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_cgi.py | 0 .../StdLib/Lib/test/test_cgitb.py | 0 .../StdLib/Lib/test/test_charmapcodec.py | 0 .../StdLib/Lib/test/test_class.py | 0 .../StdLib/Lib/test/test_cmath.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_cmd.py | 0 .../StdLib/Lib/test/test_cmd_line.py | 0 .../StdLib/Lib/test/test_cmd_line_script.py | 0 .../StdLib/Lib/test/test_code.py | 0 .../StdLib/Lib/test/test_code_module.py | 0 .../StdLib/Lib/test/test_codeccallbacks.py | 0 .../StdLib/Lib/test/test_codecencodings_cn.py | 0 .../StdLib/Lib/test/test_codecencodings_hk.py | 0 .../StdLib/Lib/test/test_codecencodings_iso2022.py | 0 .../StdLib/Lib/test/test_codecencodings_jp.py | 0 .../StdLib/Lib/test/test_codecencodings_kr.py | 0 .../StdLib/Lib/test/test_codecencodings_tw.py | 0 .../StdLib/Lib/test/test_codecmaps_cn.py | 0 .../StdLib/Lib/test/test_codecmaps_hk.py | 0 .../StdLib/Lib/test/test_codecmaps_jp.py | 0 .../StdLib/Lib/test/test_codecmaps_kr.py | 0 .../StdLib/Lib/test/test_codecmaps_tw.py | 0 .../StdLib/Lib/test/test_codecs.py | 0 .../StdLib/Lib/test/test_codeop.py | 0 .../StdLib/Lib/test/test_collections.py | 0 .../StdLib/Lib/test/test_colorsys.py | 0 .../StdLib/Lib/test/test_compare.py | 0 .../StdLib/Lib/test/test_compile.py | 0 .../StdLib/Lib/test/test_compileall.py | 0 .../StdLib/Lib/test/test_complex.py | 0 .../StdLib/Lib/test/test_concurrent_futures.py | 0 .../StdLib/Lib/test/test_configparser.py | 0 .../StdLib/Lib/test/test_contains.py | 0 .../StdLib/Lib/test/test_contextlib.py | 0 .../StdLib/Lib/test/test_copy.py | 0 .../StdLib/Lib/test/test_copyreg.py | 0 .../StdLib/Lib/test/test_cprofile.py | 0 .../StdLib/Lib/test/test_crashers.py | 0 .../StdLib/Lib/test/test_crypt.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_csv.py | 0 .../StdLib/Lib/test/test_ctypes.py | 0 .../StdLib/Lib/test/test_curses.py | 0 .../StdLib/Lib/test/test_datetime.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_dbm.py | 0 .../StdLib/Lib/test/test_dbm_dumb.py | 0 .../StdLib/Lib/test/test_dbm_gnu.py | 0 .../StdLib/Lib/test/test_dbm_ndbm.py | 0 .../StdLib/Lib/test/test_decimal.py | 0 .../StdLib/Lib/test/test_decorators.py | 0 .../StdLib/Lib/test/test_defaultdict.py | 0 .../StdLib/Lib/test/test_deque.py | 0 .../StdLib/Lib/test/test_descr.py | 0 .../StdLib/Lib/test/test_descrtut.py | 0 .../StdLib/Lib/test/test_devpoll.py | 0 .../StdLib/Lib/test/test_dict.py | 0 .../StdLib/Lib/test/test_dictcomps.py | 0 .../StdLib/Lib/test/test_dictviews.py | 0 .../StdLib/Lib/test/test_difflib.py | 0 .../StdLib/Lib/test/test_difflib_expect.html | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_dis.py | 0 .../StdLib/Lib/test/test_distutils.py | 0 .../StdLib/Lib/test/test_doctest.py | 0 .../StdLib/Lib/test/test_doctest.txt | 0 .../StdLib/Lib/test/test_doctest2.py | 0 .../StdLib/Lib/test/test_doctest2.txt | 0 .../StdLib/Lib/test/test_doctest3.txt | 0 .../StdLib/Lib/test/test_doctest4.txt | 0 .../StdLib/Lib/test/test_docxmlrpc.py | 0 .../StdLib/Lib/test/test_dummy_thread.py | 0 .../StdLib/Lib/test/test_dummy_threading.py | 0 .../StdLib/Lib/test/test_dynamic.py | 0 .../StdLib/Lib/test/test_dynamicclassattribute.py | 0 .../StdLib/Lib/test/test_email/__init__.py | 0 .../StdLib/Lib/test/test_email/__main__.py | 0 .../StdLib/Lib/test/test_email/data/PyBanner048.gif | Bin .../StdLib/Lib/test/test_email/data/audiotest.au | Bin .../StdLib/Lib/test/test_email/data/msg_01.txt | 0 .../StdLib/Lib/test/test_email/data/msg_02.txt | 0 .../StdLib/Lib/test/test_email/data/msg_03.txt | 0 .../StdLib/Lib/test/test_email/data/msg_04.txt | 0 .../StdLib/Lib/test/test_email/data/msg_05.txt | 0 .../StdLib/Lib/test/test_email/data/msg_06.txt | 0 .../StdLib/Lib/test/test_email/data/msg_07.txt | 0 .../StdLib/Lib/test/test_email/data/msg_08.txt | 0 .../StdLib/Lib/test/test_email/data/msg_09.txt | 0 .../StdLib/Lib/test/test_email/data/msg_10.txt | 0 .../StdLib/Lib/test/test_email/data/msg_11.txt | 0 .../StdLib/Lib/test/test_email/data/msg_12.txt | 0 .../StdLib/Lib/test/test_email/data/msg_12a.txt | 0 .../StdLib/Lib/test/test_email/data/msg_13.txt | 0 .../StdLib/Lib/test/test_email/data/msg_14.txt | 0 .../StdLib/Lib/test/test_email/data/msg_15.txt | 0 .../StdLib/Lib/test/test_email/data/msg_16.txt | 0 .../StdLib/Lib/test/test_email/data/msg_17.txt | 0 .../StdLib/Lib/test/test_email/data/msg_18.txt | 0 .../StdLib/Lib/test/test_email/data/msg_19.txt | 0 .../StdLib/Lib/test/test_email/data/msg_20.txt | 0 .../StdLib/Lib/test/test_email/data/msg_21.txt | 0 .../StdLib/Lib/test/test_email/data/msg_22.txt | 0 .../StdLib/Lib/test/test_email/data/msg_23.txt | 0 .../StdLib/Lib/test/test_email/data/msg_24.txt | 0 .../StdLib/Lib/test/test_email/data/msg_25.txt | 0 .../StdLib/Lib/test/test_email/data/msg_26.txt | 0 .../StdLib/Lib/test/test_email/data/msg_27.txt | 0 .../StdLib/Lib/test/test_email/data/msg_28.txt | 0 .../StdLib/Lib/test/test_email/data/msg_29.txt | 0 .../StdLib/Lib/test/test_email/data/msg_30.txt | 0 .../StdLib/Lib/test/test_email/data/msg_31.txt | 0 .../StdLib/Lib/test/test_email/data/msg_32.txt | 0 .../StdLib/Lib/test/test_email/data/msg_33.txt | 0 .../StdLib/Lib/test/test_email/data/msg_34.txt | 0 .../StdLib/Lib/test/test_email/data/msg_35.txt | 0 .../StdLib/Lib/test/test_email/data/msg_36.txt | 0 .../StdLib/Lib/test/test_email/data/msg_37.txt | 0 .../StdLib/Lib/test/test_email/data/msg_38.txt | 0 .../StdLib/Lib/test/test_email/data/msg_39.txt | 0 .../StdLib/Lib/test/test_email/data/msg_40.txt | 0 .../StdLib/Lib/test/test_email/data/msg_41.txt | 0 .../StdLib/Lib/test/test_email/data/msg_42.txt | 0 .../StdLib/Lib/test/test_email/data/msg_43.txt | 0 .../StdLib/Lib/test/test_email/data/msg_44.txt | 0 .../StdLib/Lib/test/test_email/data/msg_45.txt | 0 .../StdLib/Lib/test/test_email/data/msg_46.txt | 0 .../Lib/test/test_email/test__encoded_words.py | 0 .../test/test_email/test__header_value_parser.py | 0 .../StdLib/Lib/test/test_email/test_asian_codecs.py | 0 .../Lib/test/test_email/test_contentmanager.py | 0 .../Lib/test/test_email/test_defect_handling.py | 0 .../StdLib/Lib/test/test_email/test_email.py | 0 .../StdLib/Lib/test/test_email/test_generator.py | 0 .../Lib/test/test_email/test_headerregistry.py | 0 .../StdLib/Lib/test/test_email/test_inversion.py | 0 .../StdLib/Lib/test/test_email/test_message.py | 0 .../StdLib/Lib/test/test_email/test_parser.py | 0 .../StdLib/Lib/test/test_email/test_pickleable.py | 0 .../StdLib/Lib/test/test_email/test_policy.py | 0 .../StdLib/Lib/test/test_email/test_utils.py | 0 .../StdLib/Lib/test/test_email/torture_test.py | 0 .../StdLib/Lib/test/test_ensurepip.py | 0 .../StdLib/Lib/test/test_enum.py | 0 .../StdLib/Lib/test/test_enumerate.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_eof.py | 0 .../StdLib/Lib/test/test_epoll.py | 0 .../StdLib/Lib/test/test_errno.py | 0 .../StdLib/Lib/test/test_exception_variations.py | 0 .../StdLib/Lib/test/test_exceptions.py | 0 .../StdLib/Lib/test/test_extcall.py | 0 .../StdLib/Lib/test/test_faulthandler.py | 0 .../StdLib/Lib/test/test_fcntl.py | 0 .../StdLib/Lib/test/test_file.py | 0 .../StdLib/Lib/test/test_file_eintr.py | 0 .../StdLib/Lib/test/test_filecmp.py | 0 .../StdLib/Lib/test/test_fileinput.py | 0 .../StdLib/Lib/test/test_fileio.py | 0 .../StdLib/Lib/test/test_finalization.py | 0 .../StdLib/Lib/test/test_float.py | 0 .../StdLib/Lib/test/test_flufl.py | 0 .../StdLib/Lib/test/test_fnmatch.py | 0 .../StdLib/Lib/test/test_fork1.py | 0 .../StdLib/Lib/test/test_format.py | 0 .../StdLib/Lib/test/test_fractions.py | 0 .../StdLib/Lib/test/test_frame.py | 0 .../StdLib/Lib/test/test_fstring.py | 0 .../StdLib/Lib/test/test_ftplib.py | 0 .../StdLib/Lib/test/test_funcattrs.py | 0 .../StdLib/Lib/test/test_functools.py | 0 .../StdLib/Lib/test/test_future.py | 0 .../StdLib/Lib/test/test_future3.py | 0 .../StdLib/Lib/test/test_future4.py | 0 .../StdLib/Lib/test/test_future5.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_gc.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_gdb.py | 0 .../StdLib/Lib/test/test_generators.py | 0 .../StdLib/Lib/test/test_genericpath.py | 0 .../StdLib/Lib/test/test_genexps.py | 0 .../StdLib/Lib/test/test_getargs2.py | 0 .../StdLib/Lib/test/test_getopt.py | 0 .../StdLib/Lib/test/test_getpass.py | 0 .../StdLib/Lib/test/test_gettext.py | 0 .../StdLib/Lib/test/test_glob.py | 0 .../StdLib/Lib/test/test_global.py | 0 .../StdLib/Lib/test/test_grammar.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_grp.py | 0 .../StdLib/Lib/test/test_gzip.py | 0 .../StdLib/Lib/test/test_hash.py | 0 .../StdLib/Lib/test/test_hashlib.py | 0 .../StdLib/Lib/test/test_heapq.py | 0 .../StdLib/Lib/test/test_hmac.py | 0 .../StdLib/Lib/test/test_html.py | 0 .../StdLib/Lib/test/test_htmlparser.py | 0 .../StdLib/Lib/test/test_http_cookiejar.py | 0 .../StdLib/Lib/test/test_http_cookies.py | 0 .../StdLib/Lib/test/test_httplib.py | 0 .../StdLib/Lib/test/test_httpservers.py | 0 .../StdLib/Lib/test/test_idle.py | 0 .../StdLib/Lib/test/test_imaplib.py | 0 .../StdLib/Lib/test/test_imghdr.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_imp.py | 0 .../StdLib/Lib/test/test_import.py | 0 .../StdLib/Lib/test/test_importlib/__init__.py | 0 .../StdLib/Lib/test/test_importlib/__main__.py | 0 .../StdLib/Lib/test/test_importlib/abc.py | 0 .../Lib/test/test_importlib/builtin/__init__.py | 0 .../Lib/test/test_importlib/builtin/__main__.py | 0 .../Lib/test/test_importlib/builtin/test_finder.py | 0 .../Lib/test/test_importlib/builtin/test_loader.py | 0 .../StdLib/Lib/test/test_importlib/builtin/util.py | 0 .../Lib/test/test_importlib/extension/__init__.py | 0 .../Lib/test/test_importlib/extension/__main__.py | 0 .../extension/test_case_sensitivity.py | 0 .../test/test_importlib/extension/test_finder.py | 0 .../test/test_importlib/extension/test_loader.py | 0 .../test/test_importlib/extension/test_path_hook.py | 0 .../Lib/test/test_importlib/extension/util.py | 0 .../Lib/test/test_importlib/frozen/__init__.py | 0 .../Lib/test/test_importlib/frozen/__main__.py | 0 .../Lib/test/test_importlib/frozen/test_finder.py | 0 .../Lib/test/test_importlib/frozen/test_loader.py | 0 .../Lib/test/test_importlib/import_/__init__.py | 0 .../Lib/test/test_importlib/import_/__main__.py | 0 .../test/test_importlib/import_/test___loader__.py | 0 .../test/test_importlib/import_/test___package__.py | 0 .../Lib/test/test_importlib/import_/test_api.py | 0 .../Lib/test/test_importlib/import_/test_caching.py | 0 .../test/test_importlib/import_/test_fromlist.py | 0 .../test/test_importlib/import_/test_meta_path.py | 0 .../test/test_importlib/import_/test_packages.py | 0 .../Lib/test/test_importlib/import_/test_path.py | 0 .../test_importlib/import_/test_relative_imports.py | 0 .../StdLib/Lib/test/test_importlib/import_/util.py | 0 .../namespace_pkgs/both_portions/foo/one.py | 0 .../namespace_pkgs/both_portions/foo/two.py | 0 .../namespace_pkgs/missing_directory.zip | Bin .../module_and_namespace_package/a_test.py | 0 .../module_and_namespace_package/a_test/empty | 0 .../namespace_pkgs/nested_portion1.zip | Bin .../not_a_namespace_pkg/foo/__init__.py | 0 .../namespace_pkgs/not_a_namespace_pkg/foo/one.py | 0 .../namespace_pkgs/portion1/foo/one.py | 0 .../namespace_pkgs/portion2/foo/two.py | 0 .../namespace_pkgs/project1/parent/child/one.py | 0 .../namespace_pkgs/project2/parent/child/two.py | 0 .../namespace_pkgs/project3/parent/child/three.py | 0 .../namespace_pkgs/top_level_portion1.zip | Bin .../StdLib/Lib/test/test_importlib/regrtest.py | 0 .../Lib/test/test_importlib/source/__init__.py | 0 .../Lib/test/test_importlib/source/__main__.py | 0 .../test_importlib/source/test_case_sensitivity.py | 0 .../test/test_importlib/source/test_file_loader.py | 0 .../Lib/test/test_importlib/source/test_finder.py | 0 .../test/test_importlib/source/test_path_hook.py | 0 .../test_importlib/source/test_source_encoding.py | 0 .../StdLib/Lib/test/test_importlib/source/util.py | 0 .../StdLib/Lib/test/test_importlib/test_abc.py | 0 .../StdLib/Lib/test/test_importlib/test_api.py | 0 .../StdLib/Lib/test/test_importlib/test_locks.py | 0 .../Lib/test/test_importlib/test_namespace_pkgs.py | 0 .../StdLib/Lib/test/test_importlib/test_spec.py | 0 .../StdLib/Lib/test/test_importlib/test_util.py | 0 .../StdLib/Lib/test/test_importlib/test_windows.py | 0 .../StdLib/Lib/test/test_importlib/util.py | 0 .../StdLib/Lib/test/test_index.py | 0 .../StdLib/Lib/test/test_inspect.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_int.py | 0 .../StdLib/Lib/test/test_int_literal.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_io.py | 0 .../StdLib/Lib/test/test_ioctl.py | 0 .../StdLib/Lib/test/test_ipaddress.py | 0 .../StdLib/Lib/test/test_isinstance.py | 0 .../StdLib/Lib/test/test_iter.py | 0 .../StdLib/Lib/test/test_iterlen.py | 0 .../StdLib/Lib/test/test_itertools.py | 0 .../StdLib/Lib/test/test_json/__init__.py | 0 .../StdLib/Lib/test/test_json/__main__.py | 0 .../StdLib/Lib/test/test_json/test_decode.py | 0 .../StdLib/Lib/test/test_json/test_default.py | 0 .../StdLib/Lib/test/test_json/test_dump.py | 0 .../test/test_json/test_encode_basestring_ascii.py | 0 .../StdLib/Lib/test/test_json/test_enum.py | 0 .../StdLib/Lib/test/test_json/test_fail.py | 0 .../StdLib/Lib/test/test_json/test_float.py | 0 .../StdLib/Lib/test/test_json/test_indent.py | 0 .../StdLib/Lib/test/test_json/test_pass1.py | 0 .../StdLib/Lib/test/test_json/test_pass2.py | 0 .../StdLib/Lib/test/test_json/test_pass3.py | 0 .../StdLib/Lib/test/test_json/test_recursion.py | 0 .../StdLib/Lib/test/test_json/test_scanstring.py | 0 .../StdLib/Lib/test/test_json/test_separators.py | 0 .../StdLib/Lib/test/test_json/test_speedups.py | 0 .../StdLib/Lib/test/test_json/test_tool.py | 0 .../StdLib/Lib/test/test_json/test_unicode.py | 0 .../StdLib/Lib/test/test_keyword.py | 0 .../StdLib/Lib/test/test_keywordonlyarg.py | 0 .../StdLib/Lib/test/test_kqueue.py | 0 .../StdLib/Lib/test/test_largefile.py | 0 .../StdLib/Lib/test/test_lib2to3.py | 0 .../StdLib/Lib/test/test_linecache.py | 0 .../StdLib/Lib/test/test_list.py | 0 .../StdLib/Lib/test/test_listcomps.py | 0 .../StdLib/Lib/test/test_locale.py | 0 .../StdLib/Lib/test/test_logging.py | 0 .../StdLib/Lib/test/test_long.py | 0 .../StdLib/Lib/test/test_longexp.py | 0 .../StdLib/Lib/test/test_lzma.py | 0 .../StdLib/Lib/test/test_macpath.py | 0 .../StdLib/Lib/test/test_macurl2path.py | 0 .../StdLib/Lib/test/test_mailbox.py | 0 .../StdLib/Lib/test/test_mailcap.py | 0 .../StdLib/Lib/test/test_marshal.py | 0 .../StdLib/Lib/test/test_math.py | 0 .../StdLib/Lib/test/test_memoryio.py | 0 .../StdLib/Lib/test/test_memoryview.py | 0 .../StdLib/Lib/test/test_metaclass.py | 0 .../StdLib/Lib/test/test_mimetypes.py | 0 .../StdLib/Lib/test/test_minidom.py | 0 .../StdLib/Lib/test/test_mmap.py | 0 .../StdLib/Lib/test/test_module.py | 0 .../StdLib/Lib/test/test_modulefinder.py | 0 .../StdLib/Lib/test/test_msilib.py | 0 .../StdLib/Lib/test/test_multibytecodec.py | 0 .../StdLib/Lib/test/test_multiprocessing_fork.py | 0 .../Lib/test/test_multiprocessing_forkserver.py | 0 .../Lib/test/test_multiprocessing_main_handling.py | 0 .../StdLib/Lib/test/test_multiprocessing_spawn.py | 0 .../StdLib/Lib/test/test_netrc.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_nis.py | 0 .../StdLib/Lib/test/test_nntplib.py | 0 .../StdLib/Lib/test/test_normalization.py | 0 .../StdLib/Lib/test/test_ntpath.py | 0 .../StdLib/Lib/test/test_numeric_tower.py | 0 .../StdLib/Lib/test/test_opcodes.py | 0 .../StdLib/Lib/test/test_openpty.py | 0 .../StdLib/Lib/test/test_operator.py | 0 .../StdLib/Lib/test/test_optparse.py | 0 .../StdLib/Lib/test/test_ordered_dict.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_os.py | 0 .../StdLib/Lib/test/test_ossaudiodev.py | 0 .../StdLib/Lib/test/test_osx_env.py | 0 .../StdLib/Lib/test/test_parser.py | 0 .../StdLib/Lib/test/test_pathlib.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_pdb.py | 0 .../StdLib/Lib/test/test_peepholer.py | 0 .../StdLib/Lib/test/test_pep247.py | 0 .../StdLib/Lib/test/test_pep277.py | 0 .../StdLib/Lib/test/test_pep292.py | 0 .../StdLib/Lib/test/test_pep3120.py | 0 .../StdLib/Lib/test/test_pep3131.py | 0 .../StdLib/Lib/test/test_pep3151.py | 0 .../StdLib/Lib/test/test_pep352.py | 0 .../StdLib/Lib/test/test_pep380.py | 0 .../StdLib/Lib/test/test_pep479.py | 0 .../StdLib/Lib/test/test_pickle.py | 0 .../StdLib/Lib/test/test_pickletools.py | 0 .../StdLib/Lib/test/test_pipes.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_pkg.py | 0 .../StdLib/Lib/test/test_pkgimport.py | 0 .../StdLib/Lib/test/test_pkgutil.py | 0 .../StdLib/Lib/test/test_platform.py | 0 .../StdLib/Lib/test/test_plistlib.py | 0 .../StdLib/Lib/test/test_poll.py | 0 .../StdLib/Lib/test/test_popen.py | 0 .../StdLib/Lib/test/test_poplib.py | 0 .../StdLib/Lib/test/test_posix.py | 0 .../StdLib/Lib/test/test_posixpath.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_pow.py | 0 .../StdLib/Lib/test/test_pprint.py | 0 .../StdLib/Lib/test/test_print.py | 0 .../StdLib/Lib/test/test_profile.py | 0 .../StdLib/Lib/test/test_property.py | 0 .../StdLib/Lib/test/test_pstats.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_pty.py | 0 .../StdLib/Lib/test/test_pulldom.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_pwd.py | 0 .../StdLib/Lib/test/test_py_compile.py | 0 .../StdLib/Lib/test/test_pyclbr.py | 0 .../StdLib/Lib/test/test_pydoc.py | 0 .../StdLib/Lib/test/test_pyexpat.py | 0 .../StdLib/Lib/test/test_queue.py | 0 .../StdLib/Lib/test/test_quopri.py | 0 .../StdLib/Lib/test/test_raise.py | 0 .../StdLib/Lib/test/test_random.py | 0 .../StdLib/Lib/test/test_range.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_re.py | 0 .../StdLib/Lib/test/test_readline.py | 0 .../StdLib/Lib/test/test_regrtest.py | 0 .../StdLib/Lib/test/test_reprlib.py | 0 .../StdLib/Lib/test/test_resource.py | 0 .../StdLib/Lib/test/test_richcmp.py | 0 .../StdLib/Lib/test/test_rlcompleter.py | 0 .../StdLib/Lib/test/test_robotparser.py | 0 .../StdLib/Lib/test/test_runpy.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_sax.py | 0 .../StdLib/Lib/test/test_sched.py | 0 .../StdLib/Lib/test/test_scope.py | 0 .../StdLib/Lib/test/test_script_helper.py | 0 .../StdLib/Lib/test/test_select.py | 0 .../StdLib/Lib/test/test_selectors.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_set.py | 0 .../StdLib/Lib/test/test_setcomps.py | 0 .../StdLib/Lib/test/test_shelve.py | 0 .../StdLib/Lib/test/test_shlex.py | 0 .../StdLib/Lib/test/test_shutil.py | 0 .../StdLib/Lib/test/test_signal.py | 0 .../StdLib/Lib/test/test_site.py | 0 .../StdLib/Lib/test/test_slice.py | 0 .../StdLib/Lib/test/test_smtpd.py | 0 .../StdLib/Lib/test/test_smtplib.py | 0 .../StdLib/Lib/test/test_smtpnet.py | 0 .../StdLib/Lib/test/test_sndhdr.py | 0 .../StdLib/Lib/test/test_socket.py | 0 .../StdLib/Lib/test/test_socketserver.py | 0 .../StdLib/Lib/test/test_sort.py | 0 .../StdLib/Lib/test/test_source_encoding.py | 0 .../StdLib/Lib/test/test_spwd.py | 0 .../StdLib/Lib/test/test_sqlite.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_ssl.py | 0 .../StdLib/Lib/test/test_startfile.py | 0 .../StdLib/Lib/test/test_stat.py | 0 .../StdLib/Lib/test/test_statistics.py | 0 .../StdLib/Lib/test/test_strftime.py | 0 .../StdLib/Lib/test/test_string.py | 0 .../StdLib/Lib/test/test_stringprep.py | 0 .../StdLib/Lib/test/test_strlit.py | 0 .../StdLib/Lib/test/test_strptime.py | 0 .../StdLib/Lib/test/test_strtod.py | 0 .../StdLib/Lib/test/test_struct.py | 0 .../StdLib/Lib/test/test_structmembers.py | 0 .../StdLib/Lib/test/test_structseq.py | 0 .../StdLib/Lib/test/test_subprocess.py | 0 .../StdLib/Lib/test/test_sunau.py | 0 .../StdLib/Lib/test/test_sundry.py | 0 .../StdLib/Lib/test/test_super.py | 0 .../StdLib/Lib/test/test_support.py | 0 .../StdLib/Lib/test/test_symtable.py | 0 .../StdLib/Lib/test/test_syntax.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_sys.py | 0 .../StdLib/Lib/test/test_sys_setprofile.py | 0 .../StdLib/Lib/test/test_sys_settrace.py | 0 .../StdLib/Lib/test/test_sysconfig.py | 0 .../StdLib/Lib/test/test_syslog.py | 0 .../StdLib/Lib/test/test_tarfile.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_tcl.py | 0 .../StdLib/Lib/test/test_telnetlib.py | 0 .../StdLib/Lib/test/test_tempfile.py | 0 .../StdLib/Lib/test/test_textwrap.py | 0 .../StdLib/Lib/test/test_thread.py | 0 .../StdLib/Lib/test/test_threaded_import.py | 0 .../StdLib/Lib/test/test_threadedtempfile.py | 0 .../StdLib/Lib/test/test_threading.py | 0 .../StdLib/Lib/test/test_threading_local.py | 0 .../StdLib/Lib/test/test_threadsignals.py | 0 .../StdLib/Lib/test/test_time.py | 0 .../StdLib/Lib/test/test_timeit.py | 0 .../StdLib/Lib/test/test_timeout.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_tk.py | 0 .../StdLib/Lib/test/test_tokenize.py | 0 .../StdLib/Lib/test/test_tools/__init__.py | 0 .../StdLib/Lib/test/test_tools/__main__.py | 0 .../StdLib/Lib/test/test_tools/test_gprof2html.py | 0 .../StdLib/Lib/test/test_tools/test_md5sum.py | 0 .../StdLib/Lib/test/test_tools/test_pdeps.py | 0 .../StdLib/Lib/test/test_tools/test_pindent.py | 0 .../StdLib/Lib/test/test_tools/test_reindent.py | 0 .../StdLib/Lib/test/test_tools/test_sundry.py | 0 .../StdLib/Lib/test/test_tools/test_unparse.py | 0 .../StdLib/Lib/test/test_trace.py | 0 .../StdLib/Lib/test/test_traceback.py | 0 .../StdLib/Lib/test/test_tracemalloc.py | 0 .../StdLib/Lib/test/test_ttk_guionly.py | 0 .../StdLib/Lib/test/test_ttk_textonly.py | 0 .../StdLib/Lib/test/test_tuple.py | 0 .../StdLib/Lib/test/test_typechecks.py | 0 .../StdLib/Lib/test/test_types.py | 0 .../StdLib/Lib/test/test_typing.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_ucn.py | 0 .../StdLib/Lib/test/test_unary.py | 0 .../StdLib/Lib/test/test_unicode.py | 0 .../StdLib/Lib/test/test_unicode_file.py | 0 .../StdLib/Lib/test/test_unicodedata.py | 0 .../StdLib/Lib/test/test_unittest.py | 0 .../StdLib/Lib/test/test_univnewlines.py | 0 .../StdLib/Lib/test/test_unpack.py | 0 .../StdLib/Lib/test/test_unpack_ex.py | 0 .../StdLib/Lib/test/test_urllib.py | 0 .../StdLib/Lib/test/test_urllib2.py | 0 .../StdLib/Lib/test/test_urllib2_localnet.py | 0 .../StdLib/Lib/test/test_urllib2net.py | 0 .../StdLib/Lib/test/test_urllib_response.py | 0 .../StdLib/Lib/test/test_urllibnet.py | 0 .../StdLib/Lib/test/test_urlparse.py | 0 .../StdLib/Lib/test/test_userdict.py | 0 .../StdLib/Lib/test/test_userlist.py | 0 .../StdLib/Lib/test/test_userstring.py | 0 .../StdLib/Lib/test/test_utf8_mode.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/test_uu.py | 0 .../StdLib/Lib/test/test_uuid.py | 0 .../StdLib/Lib/test/test_venv.py | 0 .../StdLib/Lib/test/test_wait3.py | 0 .../StdLib/Lib/test/test_wait4.py | 0 .../StdLib/Lib/test/test_warnings.py | 0 .../StdLib/Lib/test/test_wave.py | 0 .../StdLib/Lib/test/test_weakref.py | 0 .../StdLib/Lib/test/test_weakset.py | 0 .../StdLib/Lib/test/test_webbrowser.py | 0 .../StdLib/Lib/test/test_winreg.py | 0 .../StdLib/Lib/test/test_winsound.py | 0 .../StdLib/Lib/test/test_with.py | 0 .../StdLib/Lib/test/test_wsgiref.py | 0 .../StdLib/Lib/test/test_xdrlib.py | 0 .../StdLib/Lib/test/test_xml_dom_minicompat.py | 0 .../StdLib/Lib/test/test_xml_etree.py | 0 .../StdLib/Lib/test/test_xml_etree_c.py | 0 .../StdLib/Lib/test/test_xmlrpc.py | 0 .../StdLib/Lib/test/test_xmlrpc_net.py | 0 .../StdLib/Lib/test/test_zipfile.py | 0 .../StdLib/Lib/test/test_zipfile64.py | 0 .../StdLib/Lib/test/test_zipimport.py | 0 .../StdLib/Lib/test/test_zipimport_support.py | 0 .../StdLib/Lib/test/test_zlib.py | 0 .../StdLib/Lib/test/testcodec.py | 0 {Src.GetRenamed => src}/StdLib/Lib/test/testtar.tar | Bin .../StdLib/Lib/test/tf_inherit_check.py | 0 .../StdLib/Lib/test/threaded_import_hangers.py | 0 .../StdLib/Lib/test/time_hashlib.py | 0 ..._tests-latin1-coding-cookie-and-utf8-bom-sig.txt | 0 ...tests-no-coding-cookie-and-utf8-bom-sig-only.txt | 0 ...tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt | 0 ...ze_tests-utf8-coding-cookie-and-utf8-bom-sig.txt | 0 .../StdLib/Lib/test/tokenize_tests.txt | 0 .../StdLib/Lib/test/tracedmodules/__init__.py | 0 .../StdLib/Lib/test/tracedmodules/testmod.py | 0 .../StdLib/Lib/test/warning_tests.py | 0 .../StdLib/Lib/test/win_console_handler.py | 0 .../StdLib/Lib/test/xmltestdata/simple-ns.xml | 0 .../StdLib/Lib/test/xmltestdata/simple.xml | 0 .../StdLib/Lib/test/xmltestdata/test.xml | 0 .../StdLib/Lib/test/xmltestdata/test.xml.out | 0 {Src.GetRenamed => src}/StdLib/Lib/test/xmltests.py | 0 .../StdLib/Lib/test/zip_cp437_header.zip | Bin {Src.GetRenamed => src}/StdLib/Lib/test/zipdir.zip | Bin {Src.GetRenamed => src}/StdLib/Lib/textwrap.py | 0 {Src.GetRenamed => src}/StdLib/Lib/this.py | 0 {Src.GetRenamed => src}/StdLib/Lib/threading.py | 0 {Src.GetRenamed => src}/StdLib/Lib/timeit.py | 0 .../StdLib/Lib/tkinter/__init__.py | 0 .../StdLib/Lib/tkinter/__main__.py | 0 {Src.GetRenamed => src}/StdLib/Lib/tkinter/_fix.py | 0 .../StdLib/Lib/tkinter/colorchooser.py | 0 .../StdLib/Lib/tkinter/commondialog.py | 0 .../StdLib/Lib/tkinter/constants.py | 0 .../StdLib/Lib/tkinter/dialog.py | 0 {Src.GetRenamed => src}/StdLib/Lib/tkinter/dnd.py | 0 .../StdLib/Lib/tkinter/filedialog.py | 0 {Src.GetRenamed => src}/StdLib/Lib/tkinter/font.py | 0 .../StdLib/Lib/tkinter/messagebox.py | 0 .../StdLib/Lib/tkinter/scrolledtext.py | 0 .../StdLib/Lib/tkinter/simpledialog.py | 0 .../StdLib/Lib/tkinter/test/README | 0 .../StdLib/Lib/tkinter/test/__init__.py | 0 .../StdLib/Lib/tkinter/test/runtktests.py | 0 .../StdLib/Lib/tkinter/test/support.py | 0 .../Lib/tkinter/test/test_tkinter/__init__.py | 0 .../Lib/tkinter/test/test_tkinter/test_font.py | 0 .../test/test_tkinter/test_geometry_managers.py | 0 .../Lib/tkinter/test/test_tkinter/test_images.py | 0 .../Lib/tkinter/test/test_tkinter/test_loadtk.py | 0 .../Lib/tkinter/test/test_tkinter/test_misc.py | 0 .../Lib/tkinter/test/test_tkinter/test_text.py | 0 .../Lib/tkinter/test/test_tkinter/test_variables.py | 0 .../Lib/tkinter/test/test_tkinter/test_widgets.py | 0 .../StdLib/Lib/tkinter/test/test_ttk/__init__.py | 0 .../Lib/tkinter/test/test_ttk/test_extensions.py | 0 .../Lib/tkinter/test/test_ttk/test_functions.py | 0 .../StdLib/Lib/tkinter/test/test_ttk/test_style.py | 0 .../Lib/tkinter/test/test_ttk/test_widgets.py | 0 .../StdLib/Lib/tkinter/test/widget_tests.py | 0 {Src.GetRenamed => src}/StdLib/Lib/tkinter/tix.py | 0 {Src.GetRenamed => src}/StdLib/Lib/tkinter/ttk.py | 0 {Src.GetRenamed => src}/StdLib/Lib/token.py | 0 {Src.GetRenamed => src}/StdLib/Lib/tokenize.py | 0 {Src.GetRenamed => src}/StdLib/Lib/trace.py | 0 {Src.GetRenamed => src}/StdLib/Lib/traceback.py | 0 {Src.GetRenamed => src}/StdLib/Lib/tracemalloc.py | 0 {Src.GetRenamed => src}/StdLib/Lib/tty.py | 0 {Src.GetRenamed => src}/StdLib/Lib/turtle.py | 0 .../StdLib/Lib/turtledemo/__init__.py | 0 .../StdLib/Lib/turtledemo/__main__.py | 0 .../StdLib/Lib/turtledemo/bytedesign.py | 0 .../StdLib/Lib/turtledemo/chaos.py | 0 .../StdLib/Lib/turtledemo/clock.py | 0 .../StdLib/Lib/turtledemo/colormixer.py | 0 .../StdLib/Lib/turtledemo/forest.py | 0 .../StdLib/Lib/turtledemo/fractalcurves.py | 0 .../StdLib/Lib/turtledemo/lindenmayer.py | 0 .../StdLib/Lib/turtledemo/minimal_hanoi.py | 0 .../StdLib/Lib/turtledemo/nim.py | 0 .../StdLib/Lib/turtledemo/paint.py | 0 .../StdLib/Lib/turtledemo/peace.py | 0 .../StdLib/Lib/turtledemo/penrose.py | 0 .../StdLib/Lib/turtledemo/planet_and_moon.py | 0 .../StdLib/Lib/turtledemo/round_dance.py | 0 .../StdLib/Lib/turtledemo/tree.py | 0 .../StdLib/Lib/turtledemo/turtle.cfg | 0 .../StdLib/Lib/turtledemo/two_canvases.py | 0 .../StdLib/Lib/turtledemo/wikipedia.py | 0 .../StdLib/Lib/turtledemo/yinyang.py | 0 {Src.GetRenamed => src}/StdLib/Lib/types.py | 0 {Src.GetRenamed => src}/StdLib/Lib/typing.py | 0 .../StdLib/Lib/unittest/__init__.py | 0 .../StdLib/Lib/unittest/__main__.py | 0 {Src.GetRenamed => src}/StdLib/Lib/unittest/case.py | 0 .../StdLib/Lib/unittest/loader.py | 0 {Src.GetRenamed => src}/StdLib/Lib/unittest/main.py | 0 {Src.GetRenamed => src}/StdLib/Lib/unittest/mock.py | 0 .../StdLib/Lib/unittest/result.py | 0 .../StdLib/Lib/unittest/runner.py | 0 .../StdLib/Lib/unittest/signals.py | 0 .../StdLib/Lib/unittest/suite.py | 0 .../StdLib/Lib/unittest/test/__init__.py | 0 .../StdLib/Lib/unittest/test/__main__.py | 0 .../StdLib/Lib/unittest/test/_test_warnings.py | 0 .../StdLib/Lib/unittest/test/dummy.py | 0 .../StdLib/Lib/unittest/test/support.py | 0 .../StdLib/Lib/unittest/test/test_assertions.py | 0 .../StdLib/Lib/unittest/test/test_break.py | 0 .../StdLib/Lib/unittest/test/test_case.py | 0 .../StdLib/Lib/unittest/test/test_discovery.py | 0 .../Lib/unittest/test/test_functiontestcase.py | 0 .../StdLib/Lib/unittest/test/test_loader.py | 0 .../StdLib/Lib/unittest/test/test_program.py | 0 .../StdLib/Lib/unittest/test/test_result.py | 0 .../StdLib/Lib/unittest/test/test_runner.py | 0 .../StdLib/Lib/unittest/test/test_setups.py | 0 .../StdLib/Lib/unittest/test/test_skipping.py | 0 .../StdLib/Lib/unittest/test/test_suite.py | 0 .../StdLib/Lib/unittest/test/testmock/__init__.py | 0 .../StdLib/Lib/unittest/test/testmock/__main__.py | 0 .../StdLib/Lib/unittest/test/testmock/support.py | 0 .../Lib/unittest/test/testmock/testcallable.py | 0 .../Lib/unittest/test/testmock/testhelpers.py | 0 .../Lib/unittest/test/testmock/testmagicmethods.py | 0 .../StdLib/Lib/unittest/test/testmock/testmock.py | 0 .../StdLib/Lib/unittest/test/testmock/testpatch.py | 0 .../Lib/unittest/test/testmock/testsentinel.py | 0 .../StdLib/Lib/unittest/test/testmock/testwith.py | 0 {Src.GetRenamed => src}/StdLib/Lib/unittest/util.py | 0 .../StdLib/Lib/urllib/__init__.py | 0 {Src.GetRenamed => src}/StdLib/Lib/urllib/error.py | 0 {Src.GetRenamed => src}/StdLib/Lib/urllib/parse.py | 0 .../StdLib/Lib/urllib/request.py | 0 .../StdLib/Lib/urllib/response.py | 0 .../StdLib/Lib/urllib/robotparser.py | 0 {Src.GetRenamed => src}/StdLib/Lib/uu.py | 0 {Src.GetRenamed => src}/StdLib/Lib/uuid.py | 0 {Src.GetRenamed => src}/StdLib/Lib/venv/__init__.py | 0 {Src.GetRenamed => src}/StdLib/Lib/venv/__main__.py | 0 .../StdLib/Lib/venv/scripts/nt/Activate.ps1 | 0 .../StdLib/Lib/venv/scripts/nt/activate.bat | 0 .../StdLib/Lib/venv/scripts/nt/deactivate.bat | 0 .../StdLib/Lib/venv/scripts/posix/activate | 0 .../StdLib/Lib/venv/scripts/posix/activate.csh | 0 .../StdLib/Lib/venv/scripts/posix/activate.fish | 0 {Src.GetRenamed => src}/StdLib/Lib/warnings.py | 0 {Src.GetRenamed => src}/StdLib/Lib/wave.py | 0 {Src.GetRenamed => src}/StdLib/Lib/weakref.py | 0 {Src.GetRenamed => src}/StdLib/Lib/webbrowser.py | 0 {Src.GetRenamed => src}/StdLib/Lib/wpf.py | 0 .../StdLib/Lib/wsgiref/__init__.py | 0 .../StdLib/Lib/wsgiref/handlers.py | 0 .../StdLib/Lib/wsgiref/headers.py | 0 .../StdLib/Lib/wsgiref/simple_server.py | 0 {Src.GetRenamed => src}/StdLib/Lib/wsgiref/util.py | 0 .../StdLib/Lib/wsgiref/validate.py | 0 {Src.GetRenamed => src}/StdLib/Lib/xdrlib.py | 0 {Src.GetRenamed => src}/StdLib/Lib/xml/__init__.py | 0 .../StdLib/Lib/xml/dom/NodeFilter.py | 0 .../StdLib/Lib/xml/dom/__init__.py | 0 .../StdLib/Lib/xml/dom/domreg.py | 0 .../StdLib/Lib/xml/dom/expatbuilder.py | 0 .../StdLib/Lib/xml/dom/minicompat.py | 0 .../StdLib/Lib/xml/dom/minidom.py | 0 .../StdLib/Lib/xml/dom/pulldom.py | 0 .../StdLib/Lib/xml/dom/xmlbuilder.py | 0 .../StdLib/Lib/xml/etree/ElementInclude.py | 0 .../StdLib/Lib/xml/etree/ElementPath.py | 0 .../StdLib/Lib/xml/etree/ElementTree.py | 0 .../StdLib/Lib/xml/etree/__init__.py | 0 .../StdLib/Lib/xml/etree/cElementTree.py | 0 .../StdLib/Lib/xml/parsers/__init__.py | 0 .../StdLib/Lib/xml/parsers/expat.py | 0 .../StdLib/Lib/xml/sax/__init__.py | 0 .../StdLib/Lib/xml/sax/_exceptions.py | 0 .../StdLib/Lib/xml/sax/expatreader.py | 0 .../StdLib/Lib/xml/sax/handler.py | 0 .../StdLib/Lib/xml/sax/saxutils.py | 0 .../StdLib/Lib/xml/sax/xmlreader.py | 0 .../StdLib/Lib/xmlrpc/__init__.py | 0 {Src.GetRenamed => src}/StdLib/Lib/xmlrpc/client.py | 0 {Src.GetRenamed => src}/StdLib/Lib/xmlrpc/server.py | 0 {Src.GetRenamed => src}/StdLib/Lib/zipfile.py | 0 {Src.GetRenamed => src}/StdLib/StdLib.License.txt | 0 {Src.GetRenamed => src}/StdLib/StdLib.pyproj | 0 {Src.GetRenamed => src}/StdLib/stdlib-upgrade.txt | 0 {Src.GetRenamed => src}/StdLib/update-stdlib.cmd | 0 {Src.GetRenamed => src}/StdLib/update-stdlib.sh | 0 {Src.GetRenamed => src}/Tests/AssemblyInfo.cs | 0 {Src.GetRenamed => src}/Tests/AttrInjectorTest.cs | 0 {Src.GetRenamed => src}/Tests/BindTest.cs | 0 {Src.GetRenamed => src}/Tests/BinderTest.cs | 0 {Src.GetRenamed => src}/Tests/Cases/CPythonCases.cs | 0 .../Tests/Cases/CPythonCasesManifest.ini | 0 {Src.GetRenamed => src}/Tests/Cases/CaseExecuter.cs | 0 .../Tests/Cases/CaseGenerator.cs | 0 {Src.GetRenamed => src}/Tests/Cases/CommonCases.cs | 0 .../Tests/Cases/IronPythonCases.cs | 0 .../Tests/Cases/IronPythonCasesManifest.ini | 0 {Src.GetRenamed => src}/Tests/ClrType.cs | 0 {Src.GetRenamed => src}/Tests/Cmplx.cs | 0 {Src.GetRenamed => src}/Tests/Conversions.cs | 0 {Src.GetRenamed => src}/Tests/DeTest.cs | 0 {Src.GetRenamed => src}/Tests/DelegateTest.cs | 0 {Src.GetRenamed => src}/Tests/DynamicRegressions.cs | 0 {Src.GetRenamed => src}/Tests/EncodingTest.cs | 0 {Src.GetRenamed => src}/Tests/EngineTest.cs | 0 {Src.GetRenamed => src}/Tests/Enums.cs | 0 {Src.GetRenamed => src}/Tests/Events.cs | 0 {Src.GetRenamed => src}/Tests/ExceptionConverter.cs | 0 {Src.GetRenamed => src}/Tests/Exceptions.cs | 0 {Src.GetRenamed => src}/Tests/Explicit.cs | 0 .../Tests/ExtensionMethodTest.cs | 0 {Src.GetRenamed => src}/Tests/GenMeth.cs | 0 {Src.GetRenamed => src}/Tests/Indexable.cs | 0 {Src.GetRenamed => src}/Tests/InheritTest.cs | 0 {Src.GetRenamed => src}/Tests/IntegerTest.cs | 0 {Src.GetRenamed => src}/Tests/IronMath.cs | 0 .../Tests/IronPython.Tests.csproj | 0 {Src.GetRenamed => src}/Tests/LoadTest.cs | 0 {Src.GetRenamed => src}/Tests/MemberMappingTests.cs | 0 {Src.GetRenamed => src}/Tests/MemberOverloadTest.cs | 0 .../Tests/MethodParametersStubs.cs | 0 {Src.GetRenamed => src}/Tests/NestedClass.cs | 0 {Src.GetRenamed => src}/Tests/NullableTest.cs | 0 {Src.GetRenamed => src}/Tests/OperatorTest.cs | 0 {Src.GetRenamed => src}/Tests/ProtocolTest.cs | 0 {Src.GetRenamed => src}/Tests/StaticTest.cs | 0 {Src.GetRenamed => src}/Tests/Stress/Engine.cs | 0 .../Tests/StringDictionaryStorage.cs | 0 {Src.GetRenamed => src}/Tests/TestBuiltinModule.cs | 0 {Src.GetRenamed => src}/Tests/TypeDescriptor.cs | 0 {Src.GetRenamed => src}/Tests/Util/IniParser.cs | 0 {Src.GetRenamed => src}/Tests/Util/TestManifest.cs | 0 {Src.GetRenamed => src}/Wpf/DynamicXamlReader.cs | 0 {Src.GetRenamed => src}/Wpf/IronPython.Wpf.csproj | 0 .../Wpf/Properties/AssemblyInfo.cs | 0 {Src.GetRenamed => src}/Wpf/_wpf.cs | 0 {Utils.GetRenamed => utils}/NuGet/nuget.exe | Bin .../References/IKVM/IKVM.Reflection.License.txt | 0 .../References/IKVM/IKVM.Reflection.dll | Bin .../References/Mono.Posix.dll | Bin 2692 files changed, 0 insertions(+), 0 deletions(-) rename {Src.GetRenamed => src}/App.Debug.config (100%) rename {Src.GetRenamed => src}/App.Release.config (100%) rename {Src.GetRenamed => src}/CTypes/Makefile (100%) rename {Src.GetRenamed => src}/CTypes/_ctypes_test.c (100%) rename {Src.GetRenamed => src}/CTypes/_ctypes_test.sln (100%) rename {Src.GetRenamed => src}/CTypes/_ctypes_test.vcxproj (100%) rename {Src.GetRenamed => src}/CompilerServices/AssemblyResolver.cs (100%) rename {Src.GetRenamed => src}/CompilerServices/Config.cs (100%) rename {Src.GetRenamed => src}/CompilerServices/ConsoleOps.cs (100%) rename {Src.GetRenamed => src}/CompilerServices/IronPython.CompilerServices.csproj (100%) rename {Src.GetRenamed => src}/CompilerServices/Program.cs (100%) rename {Src.GetRenamed => src}/CompilerServices/Properties/AssemblyInfo.cs (100%) rename {Src.GetRenamed => src}/CompilerServices/README.md (100%) rename {Src.GetRenamed => src}/Console.Host/IronPython.Console.Host.csproj (100%) rename {Src.GetRenamed => src}/Console.Host/IronPythonWindow.cs (100%) rename {Src.GetRenamed => src}/Console.Host/Properties/AssemblyInfo.cs (100%) rename {Src.GetRenamed => src}/Console.Host/ipyw.ico (100%) rename {Src.GetRenamed => src}/Console/Console.cs (100%) rename {Src.GetRenamed => src}/Console/IronPython.Console.csproj (100%) rename {Src.GetRenamed => src}/Console/Properties/AssemblyInfo.cs (100%) rename {Src.GetRenamed => src}/Console/app.manifest (100%) rename {Src.GetRenamed => src}/Console/ipy-mono.sh (100%) rename {Src.GetRenamed => src}/Console/ipy.ico (100%) rename {Src.GetRenamed => src}/Console/ipy.sh (100%) rename {Src.GetRenamed => src}/Console/runtimeconfig.template.json (100%) rename {Src.GetRenamed => src}/Console32.Host/IronPython.Console32.Host.csproj (100%) rename {Src.GetRenamed => src}/Console32/IronPython.Console32.csproj (100%) rename {Src.GetRenamed => src}/DiagnosticAnalyzer/Analyzer.cs (100%) rename {Src.GetRenamed => src}/DiagnosticAnalyzer/Directory.Build.props (100%) rename {Src.GetRenamed => src}/DiagnosticAnalyzer/IronPython.DiagnosticAnalyzer.csproj (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/AndExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/AssertStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/AssignmentStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/AstMethods.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/AsyncStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/AugmentedAssignStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/BinaryExpression.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/BinaryExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/BreakStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/CallExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/ClassDefinition.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/Comprehension.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/ComprehensionFor.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/ComprehensionIf.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/ConditionalExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/ConstantExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/ContinueStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/DelStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/DictionaryExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/DottedName.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/DynamicConvertExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/EmptyStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/ErrorExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/Expression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/ExpressionStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/FlowChecker.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/ForStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/FormattedValueExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/FromImportStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/FunctionDefinition.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/GeneratorExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/GetGlobalContextExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/GlobalStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/ILoopStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/IfStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/IfStatementTest.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/ImportStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/IndexExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/JoinedStringExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/Keyword.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/LambdaExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/ListExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/MemberExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/ModuleName.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/NameExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/Node.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/NonlocalStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/OrExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/Parameter.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/ParenthesisExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/PythonAst.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/PythonConstantExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/PythonNameBinder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/PythonReference.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/PythonVariable.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/PythonWalker.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/RaiseStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/RelativeModuleName.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/ReturnStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/ScopeStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/SequenceExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/SerializedScopeStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/SetExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/SliceExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/StarredExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/Statement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/SuiteStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/TryStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/TupleExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/UnaryExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/VariableKind.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/WhileStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/WithStatement.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/YieldExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Ast/YieldFromExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/ClosureExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/ClosureInfo.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/CollectableCompilationMode.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/CompilationMode.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/GeneratorRewriter.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/LazyCode.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/LookupCompilationMode.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/OnDiskScriptCode.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Parser.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/PythonCallTargets.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/PythonCompilerOptions.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/PythonDynamicExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/PythonGlobal.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/PythonGlobalVariableExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/PythonOperator.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/PythonSavableScriptCode.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/PythonScriptCode.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/ReducableDynamicExpression.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/RunnableScriptCode.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/RuntimeScriptCode.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/ToDiskCompilationMode.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Token.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/TokenKind.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Tokenizer.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/Tokenizer.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/UncollectableCompilationMode.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Compiler/UncollectableCompilationMode.cs (100%) rename {Src.GetRenamed => src}/IronPython/FakeInteropServices.cs (100%) rename {Src.GetRenamed => src}/IronPython/Hosting/Python.cs (100%) rename {Src.GetRenamed => src}/IronPython/Hosting/PythonCodeDomCodeGen.cs (100%) rename {Src.GetRenamed => src}/IronPython/Hosting/PythonCommandLine.cs (100%) rename {Src.GetRenamed => src}/IronPython/Hosting/PythonConsoleOptions.cs (100%) rename {Src.GetRenamed => src}/IronPython/Hosting/PythonOptionsParser.cs (100%) rename {Src.GetRenamed => src}/IronPython/Hosting/PythonService.cs (100%) rename {Src.GetRenamed => src}/IronPython/Interop/Windows/Interop.Libraries.cs (100%) rename {Src.GetRenamed => src}/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs (100%) rename {Src.GetRenamed => src}/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs (100%) rename {Src.GetRenamed => src}/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs (100%) rename {Src.GetRenamed => src}/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs (100%) rename {Src.GetRenamed => src}/IronPython/IronPython.csproj (100%) rename {Src.GetRenamed => src}/IronPython/Lib/iptest/__init__.py (100%) rename {Src.GetRenamed => src}/IronPython/Lib/iptest/cominterop_util.py (100%) rename {Src.GetRenamed => src}/IronPython/Lib/iptest/console_util.py (100%) rename {Src.GetRenamed => src}/IronPython/Lib/iptest/file_util.py (100%) rename {Src.GetRenamed => src}/IronPython/Lib/iptest/ipunittest.py (100%) rename {Src.GetRenamed => src}/IronPython/Lib/iptest/misc_util.py (100%) rename {Src.GetRenamed => src}/IronPython/Lib/iptest/process_util.py (100%) rename {Src.GetRenamed => src}/IronPython/Lib/iptest/runner.py (100%) rename {Src.GetRenamed => src}/IronPython/Lib/iptest/test_env.py (100%) rename {Src.GetRenamed => src}/IronPython/Lib/iptest/type_util.py (100%) rename {Src.GetRenamed => src}/IronPython/Modules/Builtin.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Modules/Builtin.cs (100%) rename {Src.GetRenamed => src}/IronPython/Modules/_ast.cs (100%) rename {Src.GetRenamed => src}/IronPython/Modules/_fileio.cs (100%) rename {Src.GetRenamed => src}/IronPython/Modules/_imp.cs (100%) rename {Src.GetRenamed => src}/IronPython/Modules/_io.cs (100%) rename {Src.GetRenamed => src}/IronPython/Modules/_io/BytesIO.cs (100%) rename {Src.GetRenamed => src}/IronPython/Modules/_io/StringIO.cs (100%) rename {Src.GetRenamed => src}/IronPython/Modules/_locale.cs (100%) rename {Src.GetRenamed => src}/IronPython/Modules/sys.cs (100%) rename {Src.GetRenamed => src}/IronPython/Modules/unicodedata.cs (100%) rename {Src.GetRenamed => src}/IronPython/Modules/unicodedata/CaseFolding.txt (100%) rename {Src.GetRenamed => src}/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt (100%) rename {Src.GetRenamed => src}/IronPython/Modules/unicodedata/EastAsianWidth.txt (100%) rename {Src.GetRenamed => src}/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz (100%) rename {Src.GetRenamed => src}/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz (100%) rename {Src.GetRenamed => src}/IronPython/Modules/unicodedata/NameAliases.txt (100%) rename {Src.GetRenamed => src}/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt (100%) rename {Src.GetRenamed => src}/IronPython/Modules/unicodedata/UnicodeData.txt (100%) rename {Src.GetRenamed => src}/IronPython/Modules/unicodedata/genunicodedata.py (100%) rename {Src.GetRenamed => src}/IronPython/Modules/unicodedata/license.txt (100%) rename {Src.GetRenamed => src}/IronPython/Properties/AssemblyInfo.cs (100%) rename {Src.GetRenamed => src}/IronPython/Resources.Designer.cs (100%) rename {Src.GetRenamed => src}/IronPython/Resources.resx (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/ArrayData.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/Binders.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/BindingHelpers.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/BindingWarnings.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/ConditionalBuilder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/ContextArgBuilder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/ConversionBinder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/CreateFallbackBinder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/FastBindResult.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/FastGetBase.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/FastSetBase.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/IComConvertible.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/IFastGettable.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/IFastInvokable.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/IFastSettable.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/IPythonConvertible.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/IPythonExpandable.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/IPythonGetable.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/IPythonInvokable.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/IPythonOperable.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/IPythonSite.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/MetaBuiltinFunction.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/MetaMethod.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/MetaPythonFunction.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/MetaPythonObject.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/MetaPythonType.Calls.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/MetaPythonType.Members.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/MetaPythonType.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/MetaUserObject.Members.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/MetaUserObject.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/PythonBinder.Create.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/PythonBinder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/PythonExtensionBinder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/PythonGetIndexBinder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/PythonGetMemberBinder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/PythonGetSliceBinder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/PythonIndexType.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/PythonInvokeBinder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/PythonOperationBinder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/PythonOperationKind.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/PythonOverloadResolver.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/PythonProtocol.Operations.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/PythonProtocol.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/PythonSetIndexBinder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/PythonSetMemberBinder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/PythonSetSliceBinder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/SlotOrFunction.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Binding/WarningInfo.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/BufferProtocol.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/BuiltinPythonModule.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/BuiltinsDictionaryStorage.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/ByteArray.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/ByteArrayIterator.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Bytes.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/BytesIterator.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/BytesLikeAttribute.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/ClassMethodAttribute.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/ClassMethodDescriptor.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/ClrModule.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/CodeContext.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/CollectionDebugView.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/CommonDictionaryStorage.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/CompareUtil.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/CompileFlags.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/CompiledLoader.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/ConstantDictionaryStorage.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/ConversionWrappers.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Converter.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/CustomDictionaryStorage.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/DebuggerDictionaryStorage.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/DefaultContext.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Descriptors.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/DictionaryOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/DictionaryStorage.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/DictionaryTypeInfoAttribute.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/DontMapICollectionToLenAttribute.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/EmptyDictionaryStorage.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Enumerate.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/ErrorCodes.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/AssertionException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/AttributeErrorException.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/BufferException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/GeneratorExitException.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/ImportException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/IndentationException.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/LookupException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/OSException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/PythonException.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/PythonExceptions.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/RecursionException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/SystemExitException.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/TabException.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/TraceBack.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/TypeErrorException.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Exceptions/ValueErrorException.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/ExtensionMethodSet.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Filter.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/FormattingHelper.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/FunctionAttributes.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/FunctionCode.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Generator.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/GlobalDictionaryStorage.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/IParameterSequence.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Implementation.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Importer.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Index.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/InstancedModuleDictionaryStorage.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Interfaces.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/KwCallInfo.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/LiteralParser.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Map.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/MaybeNotImplementedAttribute.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/MemoryStreamContentProvider.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/MemoryView.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Method.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Method.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/MissingParameter.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/ModuleContext.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/ModuleDictionaryStorage.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/ModuleGlobalCache.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/ModuleLoader.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/ModuleOptions.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/NameType.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/NewStringFormatter.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/ObjectAttributesAdapter.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/ObjectDebugView.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/ArrayOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/BigIntegerOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/BoolOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/ByteOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/CharOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/ComOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/ComplexOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/DBNullOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/DateTimeOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/DecimalOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/DelegateOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/DictionaryOfTOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/EnumOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/FloatOps.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/FloatOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/IListOfByteOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/InstanceOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/IntOps.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/IntOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/IntPtrOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/ListOfTOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/MarshalOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/NamespaceTrackerOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/ObjectOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/PythonCalls.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/PythonOps.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/PythonOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/PythonTypeOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/StringOps.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/StringOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/TypeGroupOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/TypeTrackerOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/UIntPtrOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Operations/UserTypeOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/OutputWriter.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PlatformsAttribute.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Profiler.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonContext.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonContext.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonDictionary.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonDocumentationProvider.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonDynamicStackFrame.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonEncoding.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonFileManager.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonFunction.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonFunction.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonHiddenAttribute.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonList.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonModule.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonModuleAttribute.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonNarrowing.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonOptions.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonRange.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonScopeExtension.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonStrIterator.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonTracebackListener.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonTuple.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/PythonTypeAttribute.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Reversed.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/ScopeDictionaryStorage.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/SequenceTypeInfoAttribute.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Set.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/SetStorage.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/SimpleNamespace.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/SiteLocalStorage.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Slice.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/StringDictionaryStorage.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/StringFormatSpec.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/StringFormatter.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Super.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Symbols.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/ThrowingErrorSink.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/TypecodeOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/BuiltinFunction.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/CachedNewTypeInfo.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/ConstructorFunction.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/CustomAttributeTracker.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/DocBuilder.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/DynamicHelpers.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/EmptyType.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/ExtensionPropertyInfo.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/FunctionType.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/IPythonObject.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/InstanceCreator.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/MappingProxy.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/Mro.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/NameConverter.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/NewTypeInfo.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/NewTypeMaker.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/OperatorMapping.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/ParameterInfoWrapper.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/PythonAssemblyOps.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/PythonSiteCache.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/PythonType.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/PythonType.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/PythonTypeDataSlot.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/PythonTypeDictSlot.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/PythonTypeInfo.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/PythonTypeSlot.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/PythonTypeTypeSlot.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/ReflectedEvent.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/ReflectedExtensionProperty.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/ReflectedField.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/ReflectedGetterSetter.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/ReflectedIndexer.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/ReflectedProperty.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/ReflectedSlotProperty.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/ResolvedMember.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/SlotFieldAttribute.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Types/TypeCache.Generated.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/UnboundNameException.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/WeakRef.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/WrapperDescriptorAttribute.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/WrapperDictionary.cs (100%) rename {Src.GetRenamed => src}/IronPython/Runtime/Zip.cs (100%) rename {Src.GetRenamed => src}/IronPython/SerializationStubs.cs (100%) rename {Src.GetRenamed => src}/IronPython/StringExtensions.cs (100%) rename {Src.GetRenamed => src}/IronPython/SystemRuntimeVersioning.cs (100%) rename {Src.GetRenamed => src}/IronPython/policy.IronPython.config (100%) rename {Src.GetRenamed => src}/Modules/IronPython.Modules.csproj (100%) rename {Src.GetRenamed => src}/Modules/IterTools.cs (100%) rename {Src.GetRenamed => src}/Modules/ModuleOps.cs (100%) rename {Src.GetRenamed => src}/Modules/NtSignalState.cs (100%) rename {Src.GetRenamed => src}/Modules/Properties/AssemblyInfo.cs (100%) rename {Src.GetRenamed => src}/Modules/ResourceMetaPathImporter.cs (100%) rename {Src.GetRenamed => src}/Modules/SimpleSignalState.cs (100%) rename {Src.GetRenamed => src}/Modules/_bisect.cs (100%) rename {Src.GetRenamed => src}/Modules/_codecs.cs (100%) rename {Src.GetRenamed => src}/Modules/_codecs_cn.cs (100%) rename {Src.GetRenamed => src}/Modules/_collections.cs (100%) rename {Src.GetRenamed => src}/Modules/_csv.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/Array.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/ArrayType.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/CData.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/CFuncPtr.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/CFuncPtrType.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/Extensions.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/Field.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/INativeType.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/LocalOrArg.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/MarshalCleanup.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/MemoryHolder.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/NativeArgument.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/NativeFunctions.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/Pointer.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/PointerType.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/SimpleCData.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/SimpleType.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/SimpleTypeKind.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/StructType.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/Structure.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/Union.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/UnionType.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes/_ctypes.cs (100%) rename {Src.GetRenamed => src}/Modules/_ctypes_test.cs (100%) rename {Src.GetRenamed => src}/Modules/_datetime.cs (100%) rename {Src.GetRenamed => src}/Modules/_functools.cs (100%) rename {Src.GetRenamed => src}/Modules/_heapq.cs (100%) rename {Src.GetRenamed => src}/Modules/_multibytecodec.cs (100%) rename {Src.GetRenamed => src}/Modules/_multiprocessing.cs (100%) rename {Src.GetRenamed => src}/Modules/_opcode.cs (100%) rename {Src.GetRenamed => src}/Modules/_operator.cs (100%) rename {Src.GetRenamed => src}/Modules/_overlapped.cs (100%) rename {Src.GetRenamed => src}/Modules/_pickle.cs (100%) rename {Src.GetRenamed => src}/Modules/_posixsubprocess.cs (100%) rename {Src.GetRenamed => src}/Modules/_random.RandomGen.cs (100%) rename {Src.GetRenamed => src}/Modules/_random.cs (100%) rename {Src.GetRenamed => src}/Modules/_socket.cs (100%) rename {Src.GetRenamed => src}/Modules/_sre.cs (100%) rename {Src.GetRenamed => src}/Modules/_ssl.cs (100%) rename {Src.GetRenamed => src}/Modules/_string.cs (100%) rename {Src.GetRenamed => src}/Modules/_struct.cs (100%) rename {Src.GetRenamed => src}/Modules/_sysconfigdata.cs (100%) rename {Src.GetRenamed => src}/Modules/_thread.cs (100%) rename {Src.GetRenamed => src}/Modules/_warnings.cs (100%) rename {Src.GetRenamed => src}/Modules/_weakref.Generated.cs (100%) rename {Src.GetRenamed => src}/Modules/_weakref.cs (100%) rename {Src.GetRenamed => src}/Modules/_winapi.cs (100%) rename {Src.GetRenamed => src}/Modules/array.cs (100%) rename {Src.GetRenamed => src}/Modules/atexit.cs (100%) rename {Src.GetRenamed => src}/Modules/audioop.cs (100%) rename {Src.GetRenamed => src}/Modules/binascii.cs (100%) rename {Src.GetRenamed => src}/Modules/bz2/BZ2Compressor.cs (100%) rename {Src.GetRenamed => src}/Modules/bz2/BZ2Decompressor.cs (100%) rename {Src.GetRenamed => src}/Modules/bz2/BZ2Module.cs (100%) rename {Src.GetRenamed => src}/Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs (100%) rename {Src.GetRenamed => src}/Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs (100%) rename {Src.GetRenamed => src}/Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs (100%) rename {Src.GetRenamed => src}/Modules/bz2/dotnetzip/BZip2/BitWriter.cs (100%) rename {Src.GetRenamed => src}/Modules/bz2/dotnetzip/BZip2/CRC32.cs (100%) rename {Src.GetRenamed => src}/Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs (100%) rename {Src.GetRenamed => src}/Modules/bz2/dotnetzip/BZip2/Rand.cs (100%) rename {Src.GetRenamed => src}/Modules/bz2/dotnetzip/source.txt (100%) rename {Src.GetRenamed => src}/Modules/cmath.cs (100%) rename {Src.GetRenamed => src}/Modules/errno.cs (100%) rename {Src.GetRenamed => src}/Modules/faulthandler.cs (100%) rename {Src.GetRenamed => src}/Modules/fcntl.cs (100%) rename {Src.GetRenamed => src}/Modules/gc.cs (100%) rename {Src.GetRenamed => src}/Modules/grp.cs (100%) rename {Src.GetRenamed => src}/Modules/hashlib/MD5CryptoServiceProvider.cs (100%) rename {Src.GetRenamed => src}/Modules/hashlib/SHA1CryptoServiceProvider.cs (100%) rename {Src.GetRenamed => src}/Modules/hashlib/SHA224.cs (100%) rename {Src.GetRenamed => src}/Modules/hashlib/SHA224Managed.cs (100%) rename {Src.GetRenamed => src}/Modules/hashlib/SHA256Managed.cs (100%) rename {Src.GetRenamed => src}/Modules/hashlib/SHA384Managed.cs (100%) rename {Src.GetRenamed => src}/Modules/hashlib/SHA512Managed.cs (100%) rename {Src.GetRenamed => src}/Modules/hashlib/SHAConstants.cs (100%) rename {Src.GetRenamed => src}/Modules/hashlib/_hashlib.cs (100%) rename {Src.GetRenamed => src}/Modules/hashlib/_md5.cs (100%) rename {Src.GetRenamed => src}/Modules/hashlib/_sha1.cs (100%) rename {Src.GetRenamed => src}/Modules/hashlib/_sha256.cs (100%) rename {Src.GetRenamed => src}/Modules/hashlib/_sha512.cs (100%) rename {Src.GetRenamed => src}/Modules/marshal.cs (100%) rename {Src.GetRenamed => src}/Modules/math.Generated.cs (100%) rename {Src.GetRenamed => src}/Modules/math.cs (100%) rename {Src.GetRenamed => src}/Modules/mmap.cs (100%) rename {Src.GetRenamed => src}/Modules/msvcrt.cs (100%) rename {Src.GetRenamed => src}/Modules/nt.cs (100%) rename {Src.GetRenamed => src}/Modules/policy.IronPython.Modules.config (100%) rename {Src.GetRenamed => src}/Modules/pwd.cs (100%) rename {Src.GetRenamed => src}/Modules/pyexpat.cs (100%) rename {Src.GetRenamed => src}/Modules/re.cs (100%) rename {Src.GetRenamed => src}/Modules/resource.cs (100%) rename {Src.GetRenamed => src}/Modules/select.cs (100%) rename {Src.GetRenamed => src}/Modules/signal.cs (100%) rename {Src.GetRenamed => src}/Modules/spwd.cs (100%) rename {Src.GetRenamed => src}/Modules/time.cs (100%) rename {Src.GetRenamed => src}/Modules/winreg.cs (100%) rename {Src.GetRenamed => src}/Modules/winsound.cs (100%) rename {Src.GetRenamed => src}/Modules/xxsubtype.cs (100%) rename {Src.GetRenamed => src}/Modules/zipimport.cs (100%) rename {Src.GetRenamed => src}/Modules/zlib/Compress.cs (100%) rename {Src.GetRenamed => src}/Modules/zlib/Decompress.cs (100%) rename {Src.GetRenamed => src}/Modules/zlib/ZlibModule.cs (100%) rename {Src.GetRenamed => src}/Modules/zlib/zlib.net/Adler32.cs (100%) rename {Src.GetRenamed => src}/Modules/zlib/zlib.net/Deflate.cs (100%) rename {Src.GetRenamed => src}/Modules/zlib/zlib.net/InfBlocks.cs (100%) rename {Src.GetRenamed => src}/Modules/zlib/zlib.net/InfCodes.cs (100%) rename {Src.GetRenamed => src}/Modules/zlib/zlib.net/InfTree.cs (100%) rename {Src.GetRenamed => src}/Modules/zlib/zlib.net/Inflate.cs (100%) rename {Src.GetRenamed => src}/Modules/zlib/zlib.net/StaticTree.cs (100%) rename {Src.GetRenamed => src}/Modules/zlib/zlib.net/Tree.cs (100%) rename {Src.GetRenamed => src}/Modules/zlib/zlib.net/ZStream.cs (100%) rename {Src.GetRenamed => src}/Modules/zlib/zlib.net/ZStreamException.cs (100%) rename {Src.GetRenamed => src}/Modules/zlib/zlib.net/Zlib.cs (100%) rename {Src.GetRenamed => src}/Modules/zlib/zlib.net/history.txt (100%) rename {Src.GetRenamed => src}/Modules/zlib/zlib.net/license.txt (100%) rename {Src.GetRenamed => src}/Modules/zlib/zlib.net/readme.txt (100%) rename {Src.GetRenamed => src}/README.md (100%) rename {Src.GetRenamed => src}/SQLite/Connection.cs (100%) rename {Src.GetRenamed => src}/SQLite/Contants.cs (100%) rename {Src.GetRenamed => src}/SQLite/Cursor.cs (100%) rename {Src.GetRenamed => src}/SQLite/Exceptions.cs (100%) rename {Src.GetRenamed => src}/SQLite/Extensions.cs (100%) rename {Src.GetRenamed => src}/SQLite/IronPython.SQLite.csproj (100%) rename {Src.GetRenamed => src}/SQLite/Properties/AssemblyInfo.cs (100%) rename {Src.GetRenamed => src}/SQLite/Row.cs (100%) rename {Src.GetRenamed => src}/SQLite/Statement.cs (100%) rename {Src.GetRenamed => src}/SQLite/Util.cs (100%) rename {Src.GetRenamed => src}/SQLite/_sqlite.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/.editorconfig (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/BtreeInt_h.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/Btree_h.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/Delegates.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/Hash_h.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/VdbeInt_h.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/Vdbe_h.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/_Custom.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/alter_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/analyze_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/attach_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/auth_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/backup_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/bitvec_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/btmutex_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/btree_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/build_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/callback_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/complete_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/crypto.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/ctime_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/date_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/delete_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/expr_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/fault_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/fkey_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/func_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/global_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/hash_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/hwtime_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/insert_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/journal_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/keywordhash_h.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/legacy_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/loadext_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/main_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/malloc_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/mem_Pool.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/memjournal_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/mutex_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/mutex_h.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/mutex_noop_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/mutex_w32.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/notify_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/opcodes_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/opcodes_h.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/os_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/os_common_h.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/os_h.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/os_win_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/pager_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/pager_h.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/parse_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/parse_h.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/pcache1_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/pcache_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/pcache_h.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/pragma_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/prepare_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/printf_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/random_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/resolve_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/rowset_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/select_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/sqlite3_h.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/sqliteInt_h.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/sqliteLimit_h.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/status_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/table_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/tokenize_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/trigger_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/update_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/utf_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/util_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/vacuum_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/vdbe_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/vdbeapi_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/vdbeaux_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/vdbeblob_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/vdbemem_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/vdbetrace_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/vtab_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/wal_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/wal_h.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/walker_c.cs (100%) rename {Src.GetRenamed => src}/SQLite/c#sqlite/where_c.cs (100%) rename {Src.GetRenamed => src}/Scripts/CompareDirs.py (100%) rename {Src.GetRenamed => src}/Scripts/Enter-IronPythonEnvironment.ps1 (100%) rename {Src.GetRenamed => src}/Scripts/Install-IronPython.ps1 (100%) rename {Src.GetRenamed => src}/Scripts/clean.py (100%) rename {Src.GetRenamed => src}/Scripts/copyrights.py (100%) rename {Src.GetRenamed => src}/Scripts/generate.py (100%) rename {Src.GetRenamed => src}/Scripts/generate_UncollectableCompilationMode.py (100%) rename {Src.GetRenamed => src}/Scripts/generate_alltypes.py (100%) rename {Src.GetRenamed => src}/Scripts/generate_calls.py (100%) rename {Src.GetRenamed => src}/Scripts/generate_casts.py (100%) rename {Src.GetRenamed => src}/Scripts/generate_comdispatch.py (100%) rename {Src.GetRenamed => src}/Scripts/generate_dict_views.py (100%) rename {Src.GetRenamed => src}/Scripts/generate_dynamic_instructions.py (100%) rename {Src.GetRenamed => src}/Scripts/generate_dynsites.py (100%) rename {Src.GetRenamed => src}/Scripts/generate_encoding_aliases.py (100%) rename {Src.GetRenamed => src}/Scripts/generate_exception_factory.py (100%) rename {Src.GetRenamed => src}/Scripts/generate_exceptions.py (100%) rename {Src.GetRenamed => src}/Scripts/generate_indicestest.py (100%) rename {Src.GetRenamed => src}/Scripts/generate_math.py (100%) rename {Src.GetRenamed => src}/Scripts/generate_ops.py (100%) rename {Src.GetRenamed => src}/Scripts/generate_os_codes.py (100%) rename {Src.GetRenamed => src}/Scripts/generate_reflected_calls.py (100%) rename {Src.GetRenamed => src}/Scripts/generate_set.py (100%) rename {Src.GetRenamed => src}/Scripts/generate_tuples.py (100%) rename {Src.GetRenamed => src}/Scripts/generate_typecache.py (100%) rename {Src.GetRenamed => src}/Scripts/generate_walker.py (100%) rename {Src.GetRenamed => src}/Scripts/ipcom.ps1 (100%) rename {Src.GetRenamed => src}/Scripts/make_meta1.py (100%) rename {Src.GetRenamed => src}/Scripts/radix_generator.py (100%) rename {Src.GetRenamed => src}/Scripts/run_compiled.py (100%) rename {Src.GetRenamed => src}/Scripts/run_interactive.py (100%) rename {Src.GetRenamed => src}/Scripts/smtpmailer.py (100%) rename {Src.GetRenamed => src}/Scripts/test_builder.py (100%) rename {Src.GetRenamed => src}/Scripts/test_cgcheck.py (100%) rename {Src.GetRenamed => src}/Scripts/test_parrot.py (100%) rename {Src.GetRenamed => src}/Scripts/test_pystone.py (100%) rename {Src.GetRenamed => src}/StdLib/.gitattributes (100%) rename {Src.GetRenamed => src}/StdLib/Lib/__future__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/__phello__.foo.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/_bootlocale.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/_collections_abc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/_compat_pickle.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/_dummy_thread.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/_markupbase.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/_osx_support.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/_pyio.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/_sitebuiltins.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/_strptime.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/_threading_local.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/_weakrefset.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/abc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/aifc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/antigravity.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/argparse.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ast.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asynchat.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/base_events.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/base_subprocess.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/compat.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/constants.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/coroutines.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/events.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/futures.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/locks.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/log.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/proactor_events.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/protocols.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/queues.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/selector_events.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/sslproto.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/streams.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/subprocess.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/tasks.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/test_utils.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/transports.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/unix_events.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/windows_events.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncio/windows_utils.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/asyncore.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/base64.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/bdb.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/binhex.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/bisect.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/bz2.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/cProfile.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/calendar.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/cgi.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/cgitb.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/chunk.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/clrtype.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/cmd.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/code.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/codecs.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/codeop.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/collections/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/collections/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/collections/abc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/colorsys.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/compileall.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/concurrent/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/concurrent/futures/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/concurrent/futures/_base.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/concurrent/futures/process.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/concurrent/futures/thread.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/configparser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/contextlib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/copy.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/copyreg.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/crypt.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/csv.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/_endian.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/macholib/README.ctypes (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/macholib/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/macholib/dyld.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/macholib/dylib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/macholib/fetch_macholib (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/macholib/fetch_macholib.bat (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/macholib/framework.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_anon.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_array_in_pointer.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_arrays.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_as_parameter.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_bitfields.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_buffers.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_bytes.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_byteswap.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_callbacks.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_cast.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_cfuncs.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_checkretval.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_delattr.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_errno.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_find.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_frombuffer.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_funcptr.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_functions.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_incomplete.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_init.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_internals.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_keeprefs.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_libc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_loading.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_macholib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_memfunctions.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_numbers.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_objects.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_parameters.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_pep3118.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_pickling.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_pointers.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_prototypes.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_python_api.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_random_things.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_refcounts.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_repr.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_returnfuncptrs.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_simplesubclasses.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_sizes.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_slicing.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_stringptr.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_strings.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_struct_fields.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_structures.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_unaligned_structures.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_unicode.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_values.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_varsize_struct.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_win32.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/test/test_wintypes.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ctypes/wintypes.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/curses/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/curses/ascii.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/curses/has_key.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/curses/panel.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/curses/textpad.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/datetime.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/dbm/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/dbm/dumb.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/dbm/gnu.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/dbm/ndbm.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/decimal.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/difflib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/dis.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/README (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/archive_util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/bcppcompiler.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/ccompiler.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/cmd.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/bdist.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/bdist_dumb.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/bdist_msi.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/bdist_rpm.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/bdist_wininst.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/build.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/build_clib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/build_ext.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/build_py.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/build_scripts.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/check.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/clean.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/command_template (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/config.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/install.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/install_data.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/install_egg_info.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/install_headers.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/install_lib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/install_scripts.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/register.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/sdist.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/upload.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/wininst-10.0.exe (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/wininst-6.0.exe (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/wininst-7.1.exe (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/wininst-8.0.exe (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/command/wininst-9.0.exe (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/config.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/core.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/cygwinccompiler.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/debug.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/dep_util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/dir_util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/dist.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/errors.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/extension.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/fancy_getopt.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/file_util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/filelist.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/log.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/msvc9compiler.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/msvccompiler.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/spawn.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/sysconfig.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/Setup.sample (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/support.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_archive_util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_bdist.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_bdist_dumb.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_bdist_msi.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_bdist_rpm.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_bdist_wininst.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_build.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_build_clib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_build_ext.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_build_py.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_build_scripts.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_check.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_clean.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_cmd.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_config.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_config_cmd.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_core.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_cygwinccompiler.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_dep_util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_dir_util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_dist.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_extension.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_file_util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_filelist.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_install.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_install_data.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_install_headers.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_install_lib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_install_scripts.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_log.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_msvc9compiler.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_register.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_sdist.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_spawn.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_sysconfig.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_text_file.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_unixccompiler.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_upload.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_version.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/tests/test_versionpredicate.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/text_file.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/unixccompiler.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/version.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/distutils/versionpredicate.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/doctest.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/dummy_threading.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/_encoded_words.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/_header_value_parser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/_parseaddr.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/_policybase.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/architecture.rst (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/base64mime.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/charset.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/contentmanager.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/encoders.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/errors.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/feedparser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/generator.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/header.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/headerregistry.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/iterators.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/message.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/mime/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/mime/application.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/mime/audio.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/mime/base.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/mime/image.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/mime/message.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/mime/multipart.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/mime/nonmultipart.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/mime/text.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/parser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/policy.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/quoprimime.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/email/utils.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/aliases.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/ascii.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/base64_codec.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/big5.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/big5hkscs.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/bz2_codec.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/charmap.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp037.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp1006.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp1026.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp1125.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp1140.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp1250.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp1251.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp1252.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp1253.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp1254.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp1255.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp1256.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp1257.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp1258.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp273.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp424.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp437.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp500.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp65001.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp720.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp737.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp775.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp850.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp852.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp855.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp856.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp857.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp858.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp860.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp861.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp862.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp863.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp864.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp865.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp866.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp869.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp874.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp875.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp932.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp949.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/cp950.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/euc_jis_2004.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/euc_jisx0213.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/euc_jp.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/euc_kr.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/gb18030.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/gb2312.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/gbk.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/hex_codec.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/hp_roman8.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/hz.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/idna.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso2022_jp.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso2022_jp_1.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso2022_jp_2.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso2022_jp_2004.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso2022_jp_3.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso2022_jp_ext.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso2022_kr.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso8859_1.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso8859_10.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso8859_11.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso8859_13.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso8859_14.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso8859_15.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso8859_16.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso8859_2.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso8859_3.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso8859_4.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso8859_5.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso8859_6.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso8859_7.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso8859_8.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/iso8859_9.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/johab.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/koi8_r.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/koi8_u.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/latin_1.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/mac_arabic.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/mac_centeuro.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/mac_croatian.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/mac_cyrillic.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/mac_farsi.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/mac_greek.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/mac_iceland.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/mac_latin2.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/mac_roman.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/mac_romanian.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/mac_turkish.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/mbcs.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/palmos.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/ptcp154.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/punycode.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/quopri_codec.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/raw_unicode_escape.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/rot_13.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/shift_jis.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/shift_jis_2004.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/shift_jisx0213.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/tis_620.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/undefined.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/unicode_escape.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/unicode_internal.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/utf_16.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/utf_16_be.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/utf_16_le.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/utf_32.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/utf_32_be.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/utf_32_le.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/utf_7.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/utf_8.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/utf_8_sig.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/uu_codec.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/encodings/zlib_codec.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ensurepip/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ensurepip/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ensurepip/_uninstall.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/enum.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/filecmp.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/fileinput.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/fnmatch.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/formatter.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/fractions.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ftplib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/functools.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/genericpath.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/getopt.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/getpass.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/gettext.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/glob.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/gzip.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/hashlib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/heapq.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/hmac.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/html/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/html/entities.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/html/parser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/http/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/http/client.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/http/cookiejar.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/http/cookies.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/http/server.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/AutoComplete.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/AutoCompleteWindow.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/AutoExpand.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/Bindings.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/CREDITS.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/CallTipWindow.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/CallTips.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/ChangeLog (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/ClassBrowser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/CodeContext.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/ColorDelegator.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/Debugger.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/Delegator.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/EditorWindow.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/FileList.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/FormatParagraph.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/GrepDialog.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/HISTORY.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/HyperParser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/IOBinding.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/Icons/folder.gif (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/Icons/idle.icns (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/Icons/idle.ico (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/Icons/idle_16.gif (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/Icons/idle_16.png (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/Icons/idle_32.gif (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/Icons/idle_32.png (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/Icons/idle_48.gif (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/Icons/idle_48.png (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/Icons/minusnode.gif (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/Icons/openfolder.gif (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/Icons/plusnode.gif (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/Icons/python.gif (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/Icons/tk.gif (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/IdleHistory.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/MultiCall.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/MultiStatusBar.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/NEWS.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/ObjectBrowser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/OutputWindow.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/ParenMatch.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/PathBrowser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/Percolator.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/PyParse.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/PyShell.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/README.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/RemoteDebugger.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/RemoteObjectBrowser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/ReplaceDialog.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/RstripExtension.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/ScriptBinding.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/ScrolledList.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/SearchDialog.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/SearchDialogBase.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/SearchEngine.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/StackViewer.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/TODO.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/ToolTip.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/TreeWidget.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/UndoDelegator.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/WidgetRedirector.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/WindowList.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/ZoomHeight.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/aboutDialog.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/config-extensions.def (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/config-highlight.def (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/config-keys.def (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/config-main.def (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/configDialog.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/configHandler.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/configHelpSourceEdit.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/configSectionNameDialog.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/dynOptionMenuWidget.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/extend.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/help.html (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/help.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/help.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle.bat (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle.pyw (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/README.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/htest.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/mock_idle.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/mock_tk.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/test_autocomplete.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/test_autoexpand.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/test_calltips.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/test_config_name.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/test_configdialog.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/test_delegator.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/test_editor.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/test_grep.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/test_hyperparser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/test_idlehistory.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/test_io.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/test_parenmatch.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/test_rstrip.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/test_searchengine.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/test_text.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/test_textview.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/test_warning.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idle_test/test_widgetredir.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/idlever.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/keybindingDialog.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/macosxSupport.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/rpc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/run.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/tabbedpages.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/idlelib/textView.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/imaplib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/imghdr.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/imp.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/importlib/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/importlib/_bootstrap.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/importlib/abc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/importlib/machinery.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/importlib/util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/inspect.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/io.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ipaddress.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/json/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/json/decoder.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/json/encoder.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/json/scanner.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/json/tool.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/keyword.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/Grammar.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/PatternGrammar.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/btm_matcher.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/btm_utils.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixer_base.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixer_util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_apply.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_asserts.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_basestring.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_buffer.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_callable.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_dict.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_except.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_exec.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_execfile.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_filter.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_future.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_has_key.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_idioms.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_import.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_imports.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_imports2.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_input.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_intern.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_isinstance.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_itertools.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_long.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_map.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_metaclass.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_ne.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_next.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_nonzero.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_numliterals.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_operator.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_paren.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_print.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_raise.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_raw_input.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_reduce.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_reload.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_renames.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_repr.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_set_literal.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_standarderror.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_throw.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_types.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_unicode.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_urllib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_xrange.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/fixes/fix_zip.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/main.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/patcomp.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/pgen2/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/pgen2/conv.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/pgen2/driver.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/pgen2/grammar.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/pgen2/literals.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/pgen2/parse.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/pgen2/pgen.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/pgen2/token.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/pgen2/tokenize.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/pygram.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/pytree.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/refactor.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/data/README (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/data/bom.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/data/crlf.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/data/different_encoding.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/data/false_encoding.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/pytree_idempotency.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/support.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/test_all_fixers.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/test_fixers.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/test_main.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/test_parser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/test_pytree.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/test_refactor.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lib2to3/tests/test_util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/linecache.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/locale.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/logging/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/logging/config.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/logging/handlers.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/lzma.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/macpath.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/macurl2path.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/mailbox.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/mailcap.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/mimetypes.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/modulefinder.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/msilib/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/msilib/schema.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/msilib/sequence.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/msilib/text.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/connection.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/context.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/dummy/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/dummy/connection.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/forkserver.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/heap.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/managers.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/pool.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/popen_fork.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/popen_forkserver.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/popen_spawn_posix.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/popen_spawn_win32.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/process.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/queues.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/reduction.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/resource_sharer.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/semaphore_tracker.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/sharedctypes.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/spawn.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/synchronize.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/multiprocessing/util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/netrc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/nntplib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ntpath.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/nturl2path.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/numbers.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/opcode.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/operator.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/optparse.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/os.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/pathlib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/pdb.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/pickle.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/pickletools.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/pipes.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/pkgutil.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/platform.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/plistlib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/poplib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/posixpath.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/pprint.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/profile.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/pstats.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/pty.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/py_compile.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/pyclbr.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/pydoc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/pydoc_data/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/pydoc_data/_pydoc.css (100%) rename {Src.GetRenamed => src}/StdLib/Lib/pydoc_data/topics.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/queue.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/quopri.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/random.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/re.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/reprlib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/rlcompleter.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/runpy.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/sched.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/selectors.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/shelve.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/shlex.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/shutil.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/site-packages/README (100%) rename {Src.GetRenamed => src}/StdLib/Lib/site.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/smtpd.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/smtplib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/sndhdr.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/socket.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/socketserver.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/sqlite3/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/sqlite3/dbapi2.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/sqlite3/dump.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/sqlite3/test/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/sqlite3/test/dbapi.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/sqlite3/test/dump.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/sqlite3/test/factory.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/sqlite3/test/hooks.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/sqlite3/test/regression.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/sqlite3/test/transactions.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/sqlite3/test/types.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/sqlite3/test/userfunctions.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/sre_compile.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/sre_constants.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/sre_parse.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/ssl.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/stat.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/statistics.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/string.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/stringprep.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/struct.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/subprocess.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/sunau.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/symbol.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/symtable.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/sysconfig.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tabnanny.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tarfile.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/telnetlib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tempfile.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/185test.db (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/Sine-1000Hz-300ms.aif (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/_test_multiprocessing.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/audiodata/pluck-alaw.aifc (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/audiodata/pluck-pcm16.aiff (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/audiodata/pluck-pcm16.au (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/audiodata/pluck-pcm16.wav (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/audiodata/pluck-pcm24.aiff (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/audiodata/pluck-pcm24.au (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/audiodata/pluck-pcm24.wav (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/audiodata/pluck-pcm32.aiff (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/audiodata/pluck-pcm32.au (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/audiodata/pluck-pcm32.wav (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/audiodata/pluck-pcm8.aiff (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/audiodata/pluck-pcm8.au (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/audiodata/pluck-pcm8.wav (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/audiodata/pluck-ulaw.aifc (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/audiodata/pluck-ulaw.au (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/audiotest.au (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/audiotests.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/autotest.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/bad_coding.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/bad_coding2.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/badcert.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/badkey.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/badsyntax_3131.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/badsyntax_future10.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/badsyntax_future3.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/badsyntax_future4.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/badsyntax_future5.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/badsyntax_future6.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/badsyntax_future7.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/badsyntax_future8.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/badsyntax_future9.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/badsyntax_pep3120.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/buffer_tests.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/bytecode_helper.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/capath/0e4015b9.0 (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/capath/4e1295a3.0 (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/capath/5ed36f99.0 (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/capath/6e88d7b8.0 (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/capath/99d0fa06.0 (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/capath/ce7b8643.0 (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cfgparser.1 (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cfgparser.2 (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cfgparser.3 (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/check_soundcard.vbs (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/big5-utf8.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/big5.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/big5hkscs.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/cp949-utf8.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/cp949.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/euc_jp.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/euc_kr.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/gb18030.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/gb2312.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/gbk-utf8.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/gbk.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/hz-utf8.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/hz.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/iso2022_jp.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/iso2022_kr.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/johab-utf8.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/johab.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/shift_jis.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/cmath_testcases.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/coding20731.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/crashers/README (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/crashers/bogus_code_obj.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/crashers/gc_inspection.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/crashers/infinite_loop_re.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/crashers/recursive_call.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/crashers/trace_at_recursion_limit.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/crashers/underlying_dict.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/curses_tests.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/data/README (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/datetimetester.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/abs.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/add.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/and.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/base.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/clamp.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/class.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/compare.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/comparetotal.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/copy.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/copyabs.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/copynegate.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/copysign.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddAbs.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddAdd.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddAnd.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddBase.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddClass.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddCompare.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddCopy.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddDivide.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddEncode.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddFMA.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddInvert.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddLogB.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddMax.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddMin.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddMinus.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddOr.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddPlus.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddReduce.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddRotate.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddShift.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ddXor.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/decDouble.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/decQuad.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/decSingle.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/divide.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/divideint.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqAbs.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqAdd.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqAnd.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqBase.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqClass.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqCompare.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqCopy.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqDivide.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqEncode.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqFMA.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqInvert.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqLogB.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqMax.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqMin.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqMinus.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqOr.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqPlus.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqReduce.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqRotate.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqShift.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dqXor.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dsBase.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/dsEncode.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/exp.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/extra.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/fma.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/inexact.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/invert.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/ln.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/log10.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/logb.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/max.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/maxmag.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/min.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/minmag.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/minus.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/multiply.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/nextminus.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/nextplus.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/nexttoward.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/or.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/plus.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/power.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/powersqrt.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/quantize.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/randomBound32.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/randoms.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/reduce.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/remainder.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/remainderNear.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/rescale.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/rotate.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/rounding.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/samequantum.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/scaleb.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/shift.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/squareroot.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/subtract.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/testall.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/tointegral.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/tointegralx.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/decimaltestdata/xor.decTest (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/dh1024.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/dis_module.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/doctest_aliases.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/double_const.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/empty.vbs (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/encoded_modules/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/encoded_modules/module_koi8_r.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/exception_hierarchy.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/final_a.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/final_b.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/floating_points.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/fork_wait.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/formatfloat_testcases.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/future_test1.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/future_test2.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/gdb_sample.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/ieee754.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/imghdrdata/python.bmp (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/imghdrdata/python.gif (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/imghdrdata/python.jpg (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/imghdrdata/python.pbm (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/imghdrdata/python.pgm (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/imghdrdata/python.png (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/imghdrdata/python.ppm (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/imghdrdata/python.ras (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/imghdrdata/python.sgi (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/imghdrdata/python.tiff (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/imghdrdata/python.xbm (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/inspect_fodder.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/inspect_fodder2.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/keycert.passwd.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/keycert.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/keycert2.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/keycert3.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/keycert4.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/leakers/README.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/leakers/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/leakers/test_ctypes.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/leakers/test_selftype.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/list_tests.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/lock_tests.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/mailcap.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/make_ssl_certs.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/mapping_tests.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/math_testcases.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/memory_watchdog.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/mime.types (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/mock_socket.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/mod_generics_cache.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/mp_fork_bomb.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/multibytecodec_support.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/nokia.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/nullbytecert.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/nullcert.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/outstanding_bugs.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/pickletester.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/profilee.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/pstats.pck (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/pycacert.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/pycakey.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/pyclbr_input.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/pydoc_mod.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/pydocfodder.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/pystone.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/randv2_32.pck (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/randv2_64.pck (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/randv3.pck (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/re_tests.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/regrtest.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/relimport.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/reperf.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/revocation.crl (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/sample_doctest.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/sample_doctest_no_docstrings.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/sample_doctest_no_doctests.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/script_helper.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/selfsigned_pythontestdotnet.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/seq_tests.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/sgml_input.html (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/sha256.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/sndhdrdata/README (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/sndhdrdata/sndhdr.8svx (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/sndhdrdata/sndhdr.aifc (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/sndhdrdata/sndhdr.aiff (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/sndhdrdata/sndhdr.au (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/sndhdrdata/sndhdr.hcom (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/sndhdrdata/sndhdr.sndt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/sndhdrdata/sndhdr.voc (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/sndhdrdata/sndhdr.wav (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/sortperf.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/ssl_cert.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/ssl_key.passwd.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/ssl_key.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/ssl_servers.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/ssltests.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/string_tests.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/subprocessdata/fd_status.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/subprocessdata/input_reader.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/subprocessdata/qcat.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/subprocessdata/qgrep.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/subprocessdata/sigchild_ignore.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/support/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/talos-2019-0758.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test___all__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test___future__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test__locale.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test__opcode.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test__osx_support.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_abc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_abstract_numbers.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_aifc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_argparse.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_array.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_ast.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asynchat.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/echo.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/echo2.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/echo3.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/keycert3.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/pycacert.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/ssl_cert.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/ssl_key.pem (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/test_base_events.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/test_events.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/test_futures.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/test_locks.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/test_proactor_events.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/test_queues.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/test_selector_events.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/test_sslproto.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/test_streams.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/test_subprocess.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/test_tasks.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/test_transports.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/test_unix_events.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/test_windows_events.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncio/test_windows_utils.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_asyncore.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_atexit.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_audioop.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_augassign.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_base64.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_bigaddrspace.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_bigmem.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_binascii.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_binhex.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_binop.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_bisect.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_bool.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_buffer.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_bufio.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_builtin.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_bytes.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_bz2.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_calendar.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_call.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_capi.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_cgi.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_cgitb.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_charmapcodec.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_class.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_cmath.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_cmd.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_cmd_line.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_cmd_line_script.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_code.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_code_module.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_codeccallbacks.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_codecencodings_cn.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_codecencodings_hk.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_codecencodings_iso2022.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_codecencodings_jp.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_codecencodings_kr.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_codecencodings_tw.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_codecmaps_cn.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_codecmaps_hk.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_codecmaps_jp.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_codecmaps_kr.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_codecmaps_tw.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_codecs.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_codeop.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_collections.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_colorsys.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_compare.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_compile.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_compileall.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_complex.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_concurrent_futures.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_configparser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_contains.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_contextlib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_copy.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_copyreg.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_cprofile.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_crashers.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_crypt.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_csv.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_ctypes.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_curses.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_datetime.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_dbm.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_dbm_dumb.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_dbm_gnu.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_dbm_ndbm.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_decimal.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_decorators.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_defaultdict.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_deque.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_descr.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_descrtut.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_devpoll.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_dict.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_dictcomps.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_dictviews.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_difflib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_difflib_expect.html (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_dis.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_distutils.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_doctest.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_doctest.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_doctest2.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_doctest2.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_doctest3.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_doctest4.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_docxmlrpc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_dummy_thread.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_dummy_threading.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_dynamic.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_dynamicclassattribute.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/PyBanner048.gif (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/audiotest.au (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_01.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_02.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_03.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_04.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_05.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_06.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_07.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_08.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_09.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_10.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_11.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_12.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_12a.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_13.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_14.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_15.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_16.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_17.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_18.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_19.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_20.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_21.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_22.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_23.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_24.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_25.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_26.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_27.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_28.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_29.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_30.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_31.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_32.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_33.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_34.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_35.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_36.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_37.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_38.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_39.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_40.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_41.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_42.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_43.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_44.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_45.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/data/msg_46.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/test__encoded_words.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/test__header_value_parser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/test_asian_codecs.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/test_contentmanager.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/test_defect_handling.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/test_email.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/test_generator.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/test_headerregistry.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/test_inversion.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/test_message.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/test_parser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/test_pickleable.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/test_policy.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/test_utils.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_email/torture_test.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_ensurepip.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_enum.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_enumerate.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_eof.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_epoll.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_errno.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_exception_variations.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_exceptions.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_extcall.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_faulthandler.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_fcntl.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_file.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_file_eintr.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_filecmp.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_fileinput.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_fileio.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_finalization.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_float.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_flufl.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_fnmatch.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_fork1.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_format.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_fractions.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_frame.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_fstring.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_ftplib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_funcattrs.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_functools.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_future.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_future3.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_future4.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_future5.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_gc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_gdb.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_generators.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_genericpath.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_genexps.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_getargs2.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_getopt.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_getpass.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_gettext.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_glob.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_global.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_grammar.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_grp.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_gzip.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_hash.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_hashlib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_heapq.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_hmac.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_html.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_htmlparser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_http_cookiejar.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_http_cookies.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_httplib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_httpservers.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_idle.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_imaplib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_imghdr.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_imp.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_import.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/abc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/builtin/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/builtin/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/builtin/test_finder.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/builtin/test_loader.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/builtin/util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/extension/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/extension/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/extension/test_finder.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/extension/test_loader.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/extension/test_path_hook.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/extension/util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/frozen/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/frozen/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/frozen/test_finder.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/frozen/test_loader.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/import_/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/import_/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/import_/test___loader__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/import_/test___package__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/import_/test_api.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/import_/test_caching.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/import_/test_fromlist.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/import_/test_meta_path.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/import_/test_packages.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/import_/test_path.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/import_/util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/regrtest.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/source/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/source/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/source/test_file_loader.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/source/test_finder.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/source/test_path_hook.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/source/test_source_encoding.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/source/util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/test_abc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/test_api.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/test_locks.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/test_spec.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/test_util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/test_windows.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_importlib/util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_index.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_inspect.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_int.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_int_literal.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_io.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_ioctl.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_ipaddress.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_isinstance.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_iter.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_iterlen.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_itertools.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_json/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_json/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_json/test_decode.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_json/test_default.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_json/test_dump.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_json/test_enum.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_json/test_fail.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_json/test_float.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_json/test_indent.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_json/test_pass1.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_json/test_pass2.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_json/test_pass3.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_json/test_recursion.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_json/test_scanstring.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_json/test_separators.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_json/test_speedups.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_json/test_tool.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_json/test_unicode.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_keyword.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_keywordonlyarg.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_kqueue.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_largefile.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_lib2to3.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_linecache.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_list.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_listcomps.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_locale.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_logging.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_long.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_longexp.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_lzma.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_macpath.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_macurl2path.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_mailbox.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_mailcap.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_marshal.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_math.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_memoryio.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_memoryview.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_metaclass.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_mimetypes.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_minidom.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_mmap.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_module.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_modulefinder.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_msilib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_multibytecodec.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_multiprocessing_fork.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_multiprocessing_forkserver.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_multiprocessing_main_handling.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_multiprocessing_spawn.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_netrc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_nis.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_nntplib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_normalization.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_ntpath.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_numeric_tower.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_opcodes.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_openpty.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_operator.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_optparse.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_ordered_dict.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_os.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_ossaudiodev.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_osx_env.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_parser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pathlib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pdb.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_peepholer.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pep247.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pep277.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pep292.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pep3120.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pep3131.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pep3151.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pep352.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pep380.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pep479.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pickle.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pickletools.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pipes.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pkg.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pkgimport.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pkgutil.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_platform.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_plistlib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_poll.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_popen.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_poplib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_posix.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_posixpath.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pow.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pprint.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_print.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_profile.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_property.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pstats.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pty.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pulldom.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pwd.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_py_compile.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pyclbr.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pydoc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_pyexpat.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_queue.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_quopri.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_raise.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_random.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_range.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_re.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_readline.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_regrtest.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_reprlib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_resource.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_richcmp.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_rlcompleter.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_robotparser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_runpy.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_sax.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_sched.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_scope.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_script_helper.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_select.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_selectors.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_set.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_setcomps.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_shelve.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_shlex.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_shutil.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_signal.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_site.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_slice.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_smtpd.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_smtplib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_smtpnet.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_sndhdr.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_socket.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_socketserver.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_sort.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_source_encoding.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_spwd.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_sqlite.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_ssl.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_startfile.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_stat.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_statistics.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_strftime.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_string.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_stringprep.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_strlit.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_strptime.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_strtod.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_struct.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_structmembers.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_structseq.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_subprocess.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_sunau.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_sundry.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_super.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_support.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_symtable.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_syntax.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_sys.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_sys_setprofile.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_sys_settrace.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_sysconfig.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_syslog.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_tarfile.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_tcl.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_telnetlib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_tempfile.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_textwrap.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_thread.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_threaded_import.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_threadedtempfile.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_threading.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_threading_local.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_threadsignals.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_time.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_timeit.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_timeout.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_tk.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_tokenize.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_tools/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_tools/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_tools/test_gprof2html.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_tools/test_md5sum.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_tools/test_pdeps.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_tools/test_pindent.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_tools/test_reindent.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_tools/test_sundry.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_tools/test_unparse.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_trace.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_traceback.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_tracemalloc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_ttk_guionly.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_ttk_textonly.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_tuple.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_typechecks.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_types.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_typing.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_ucn.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_unary.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_unicode.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_unicode_file.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_unicodedata.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_unittest.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_univnewlines.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_unpack.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_unpack_ex.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_urllib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_urllib2.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_urllib2_localnet.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_urllib2net.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_urllib_response.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_urllibnet.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_urlparse.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_userdict.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_userlist.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_userstring.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_utf8_mode.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_uu.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_uuid.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_venv.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_wait3.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_wait4.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_warnings.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_wave.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_weakref.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_weakset.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_webbrowser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_winreg.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_winsound.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_with.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_wsgiref.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_xdrlib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_xml_dom_minicompat.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_xml_etree.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_xml_etree_c.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_xmlrpc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_xmlrpc_net.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_zipfile.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_zipfile64.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_zipimport.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_zipimport_support.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/test_zlib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/testcodec.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/testtar.tar (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/tf_inherit_check.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/threaded_import_hangers.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/time_hashlib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/tokenize_tests.txt (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/tracedmodules/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/tracedmodules/testmod.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/warning_tests.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/win_console_handler.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/xmltestdata/simple-ns.xml (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/xmltestdata/simple.xml (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/xmltestdata/test.xml (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/xmltestdata/test.xml.out (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/xmltests.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/zip_cp437_header.zip (100%) rename {Src.GetRenamed => src}/StdLib/Lib/test/zipdir.zip (100%) rename {Src.GetRenamed => src}/StdLib/Lib/textwrap.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/this.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/threading.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/timeit.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/_fix.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/colorchooser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/commondialog.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/constants.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/dialog.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/dnd.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/filedialog.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/font.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/messagebox.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/scrolledtext.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/simpledialog.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/test/README (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/test/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/test/runtktests.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/test/support.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/test/test_tkinter/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/test/test_tkinter/test_font.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/test/test_tkinter/test_images.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/test/test_tkinter/test_text.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/test/test_ttk/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/test/test_ttk/test_functions.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/test/test_ttk/test_style.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/test/widget_tests.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/tix.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tkinter/ttk.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/token.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tokenize.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/trace.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/traceback.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tracemalloc.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/tty.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtle.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtledemo/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtledemo/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtledemo/bytedesign.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtledemo/chaos.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtledemo/clock.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtledemo/colormixer.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtledemo/forest.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtledemo/fractalcurves.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtledemo/lindenmayer.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtledemo/minimal_hanoi.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtledemo/nim.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtledemo/paint.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtledemo/peace.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtledemo/penrose.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtledemo/planet_and_moon.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtledemo/round_dance.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtledemo/tree.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtledemo/turtle.cfg (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtledemo/two_canvases.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtledemo/wikipedia.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/turtledemo/yinyang.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/types.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/typing.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/case.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/loader.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/main.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/mock.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/result.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/runner.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/signals.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/suite.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/_test_warnings.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/dummy.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/support.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/test_assertions.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/test_break.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/test_case.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/test_discovery.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/test_functiontestcase.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/test_loader.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/test_program.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/test_result.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/test_runner.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/test_setups.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/test_skipping.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/test_suite.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/testmock/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/testmock/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/testmock/support.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/testmock/testcallable.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/testmock/testhelpers.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/testmock/testmagicmethods.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/testmock/testmock.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/testmock/testpatch.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/testmock/testsentinel.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/test/testmock/testwith.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/unittest/util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/urllib/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/urllib/error.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/urllib/parse.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/urllib/request.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/urllib/response.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/urllib/robotparser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/uu.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/uuid.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/venv/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/venv/__main__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/venv/scripts/nt/Activate.ps1 (100%) rename {Src.GetRenamed => src}/StdLib/Lib/venv/scripts/nt/activate.bat (100%) rename {Src.GetRenamed => src}/StdLib/Lib/venv/scripts/nt/deactivate.bat (100%) rename {Src.GetRenamed => src}/StdLib/Lib/venv/scripts/posix/activate (100%) rename {Src.GetRenamed => src}/StdLib/Lib/venv/scripts/posix/activate.csh (100%) rename {Src.GetRenamed => src}/StdLib/Lib/venv/scripts/posix/activate.fish (100%) rename {Src.GetRenamed => src}/StdLib/Lib/warnings.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/wave.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/weakref.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/webbrowser.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/wpf.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/wsgiref/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/wsgiref/handlers.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/wsgiref/headers.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/wsgiref/simple_server.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/wsgiref/util.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/wsgiref/validate.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xdrlib.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/dom/NodeFilter.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/dom/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/dom/domreg.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/dom/expatbuilder.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/dom/minicompat.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/dom/minidom.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/dom/pulldom.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/dom/xmlbuilder.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/etree/ElementInclude.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/etree/ElementPath.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/etree/ElementTree.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/etree/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/etree/cElementTree.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/parsers/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/parsers/expat.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/sax/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/sax/_exceptions.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/sax/expatreader.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/sax/handler.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/sax/saxutils.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xml/sax/xmlreader.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xmlrpc/__init__.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xmlrpc/client.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/xmlrpc/server.py (100%) rename {Src.GetRenamed => src}/StdLib/Lib/zipfile.py (100%) rename {Src.GetRenamed => src}/StdLib/StdLib.License.txt (100%) rename {Src.GetRenamed => src}/StdLib/StdLib.pyproj (100%) rename {Src.GetRenamed => src}/StdLib/stdlib-upgrade.txt (100%) rename {Src.GetRenamed => src}/StdLib/update-stdlib.cmd (100%) rename {Src.GetRenamed => src}/StdLib/update-stdlib.sh (100%) rename {Src.GetRenamed => src}/Tests/AssemblyInfo.cs (100%) rename {Src.GetRenamed => src}/Tests/AttrInjectorTest.cs (100%) rename {Src.GetRenamed => src}/Tests/BindTest.cs (100%) rename {Src.GetRenamed => src}/Tests/BinderTest.cs (100%) rename {Src.GetRenamed => src}/Tests/Cases/CPythonCases.cs (100%) rename {Src.GetRenamed => src}/Tests/Cases/CPythonCasesManifest.ini (100%) rename {Src.GetRenamed => src}/Tests/Cases/CaseExecuter.cs (100%) rename {Src.GetRenamed => src}/Tests/Cases/CaseGenerator.cs (100%) rename {Src.GetRenamed => src}/Tests/Cases/CommonCases.cs (100%) rename {Src.GetRenamed => src}/Tests/Cases/IronPythonCases.cs (100%) rename {Src.GetRenamed => src}/Tests/Cases/IronPythonCasesManifest.ini (100%) rename {Src.GetRenamed => src}/Tests/ClrType.cs (100%) rename {Src.GetRenamed => src}/Tests/Cmplx.cs (100%) rename {Src.GetRenamed => src}/Tests/Conversions.cs (100%) rename {Src.GetRenamed => src}/Tests/DeTest.cs (100%) rename {Src.GetRenamed => src}/Tests/DelegateTest.cs (100%) rename {Src.GetRenamed => src}/Tests/DynamicRegressions.cs (100%) rename {Src.GetRenamed => src}/Tests/EncodingTest.cs (100%) rename {Src.GetRenamed => src}/Tests/EngineTest.cs (100%) rename {Src.GetRenamed => src}/Tests/Enums.cs (100%) rename {Src.GetRenamed => src}/Tests/Events.cs (100%) rename {Src.GetRenamed => src}/Tests/ExceptionConverter.cs (100%) rename {Src.GetRenamed => src}/Tests/Exceptions.cs (100%) rename {Src.GetRenamed => src}/Tests/Explicit.cs (100%) rename {Src.GetRenamed => src}/Tests/ExtensionMethodTest.cs (100%) rename {Src.GetRenamed => src}/Tests/GenMeth.cs (100%) rename {Src.GetRenamed => src}/Tests/Indexable.cs (100%) rename {Src.GetRenamed => src}/Tests/InheritTest.cs (100%) rename {Src.GetRenamed => src}/Tests/IntegerTest.cs (100%) rename {Src.GetRenamed => src}/Tests/IronMath.cs (100%) rename {Src.GetRenamed => src}/Tests/IronPython.Tests.csproj (100%) rename {Src.GetRenamed => src}/Tests/LoadTest.cs (100%) rename {Src.GetRenamed => src}/Tests/MemberMappingTests.cs (100%) rename {Src.GetRenamed => src}/Tests/MemberOverloadTest.cs (100%) rename {Src.GetRenamed => src}/Tests/MethodParametersStubs.cs (100%) rename {Src.GetRenamed => src}/Tests/NestedClass.cs (100%) rename {Src.GetRenamed => src}/Tests/NullableTest.cs (100%) rename {Src.GetRenamed => src}/Tests/OperatorTest.cs (100%) rename {Src.GetRenamed => src}/Tests/ProtocolTest.cs (100%) rename {Src.GetRenamed => src}/Tests/StaticTest.cs (100%) rename {Src.GetRenamed => src}/Tests/Stress/Engine.cs (100%) rename {Src.GetRenamed => src}/Tests/StringDictionaryStorage.cs (100%) rename {Src.GetRenamed => src}/Tests/TestBuiltinModule.cs (100%) rename {Src.GetRenamed => src}/Tests/TypeDescriptor.cs (100%) rename {Src.GetRenamed => src}/Tests/Util/IniParser.cs (100%) rename {Src.GetRenamed => src}/Tests/Util/TestManifest.cs (100%) rename {Src.GetRenamed => src}/Wpf/DynamicXamlReader.cs (100%) rename {Src.GetRenamed => src}/Wpf/IronPython.Wpf.csproj (100%) rename {Src.GetRenamed => src}/Wpf/Properties/AssemblyInfo.cs (100%) rename {Src.GetRenamed => src}/Wpf/_wpf.cs (100%) rename {Utils.GetRenamed => utils}/NuGet/nuget.exe (100%) rename {Utils.GetRenamed => utils}/References/IKVM/IKVM.Reflection.License.txt (100%) rename {Utils.GetRenamed => utils}/References/IKVM/IKVM.Reflection.dll (100%) rename {Utils.GetRenamed => utils}/References/Mono.Posix.dll (100%) diff --git a/Src.GetRenamed/App.Debug.config b/src/App.Debug.config similarity index 100% rename from Src.GetRenamed/App.Debug.config rename to src/App.Debug.config diff --git a/Src.GetRenamed/App.Release.config b/src/App.Release.config similarity index 100% rename from Src.GetRenamed/App.Release.config rename to src/App.Release.config diff --git a/Src.GetRenamed/CTypes/Makefile b/src/CTypes/Makefile similarity index 100% rename from Src.GetRenamed/CTypes/Makefile rename to src/CTypes/Makefile diff --git a/Src.GetRenamed/CTypes/_ctypes_test.c b/src/CTypes/_ctypes_test.c similarity index 100% rename from Src.GetRenamed/CTypes/_ctypes_test.c rename to src/CTypes/_ctypes_test.c diff --git a/Src.GetRenamed/CTypes/_ctypes_test.sln b/src/CTypes/_ctypes_test.sln similarity index 100% rename from Src.GetRenamed/CTypes/_ctypes_test.sln rename to src/CTypes/_ctypes_test.sln diff --git a/Src.GetRenamed/CTypes/_ctypes_test.vcxproj b/src/CTypes/_ctypes_test.vcxproj similarity index 100% rename from Src.GetRenamed/CTypes/_ctypes_test.vcxproj rename to src/CTypes/_ctypes_test.vcxproj diff --git a/Src.GetRenamed/CompilerServices/AssemblyResolver.cs b/src/CompilerServices/AssemblyResolver.cs similarity index 100% rename from Src.GetRenamed/CompilerServices/AssemblyResolver.cs rename to src/CompilerServices/AssemblyResolver.cs diff --git a/Src.GetRenamed/CompilerServices/Config.cs b/src/CompilerServices/Config.cs similarity index 100% rename from Src.GetRenamed/CompilerServices/Config.cs rename to src/CompilerServices/Config.cs diff --git a/Src.GetRenamed/CompilerServices/ConsoleOps.cs b/src/CompilerServices/ConsoleOps.cs similarity index 100% rename from Src.GetRenamed/CompilerServices/ConsoleOps.cs rename to src/CompilerServices/ConsoleOps.cs diff --git a/Src.GetRenamed/CompilerServices/IronPython.CompilerServices.csproj b/src/CompilerServices/IronPython.CompilerServices.csproj similarity index 100% rename from Src.GetRenamed/CompilerServices/IronPython.CompilerServices.csproj rename to src/CompilerServices/IronPython.CompilerServices.csproj diff --git a/Src.GetRenamed/CompilerServices/Program.cs b/src/CompilerServices/Program.cs similarity index 100% rename from Src.GetRenamed/CompilerServices/Program.cs rename to src/CompilerServices/Program.cs diff --git a/Src.GetRenamed/CompilerServices/Properties/AssemblyInfo.cs b/src/CompilerServices/Properties/AssemblyInfo.cs similarity index 100% rename from Src.GetRenamed/CompilerServices/Properties/AssemblyInfo.cs rename to src/CompilerServices/Properties/AssemblyInfo.cs diff --git a/Src.GetRenamed/CompilerServices/README.md b/src/CompilerServices/README.md similarity index 100% rename from Src.GetRenamed/CompilerServices/README.md rename to src/CompilerServices/README.md diff --git a/Src.GetRenamed/Console.Host/IronPython.Console.Host.csproj b/src/Console.Host/IronPython.Console.Host.csproj similarity index 100% rename from Src.GetRenamed/Console.Host/IronPython.Console.Host.csproj rename to src/Console.Host/IronPython.Console.Host.csproj diff --git a/Src.GetRenamed/Console.Host/IronPythonWindow.cs b/src/Console.Host/IronPythonWindow.cs similarity index 100% rename from Src.GetRenamed/Console.Host/IronPythonWindow.cs rename to src/Console.Host/IronPythonWindow.cs diff --git a/Src.GetRenamed/Console.Host/Properties/AssemblyInfo.cs b/src/Console.Host/Properties/AssemblyInfo.cs similarity index 100% rename from Src.GetRenamed/Console.Host/Properties/AssemblyInfo.cs rename to src/Console.Host/Properties/AssemblyInfo.cs diff --git a/Src.GetRenamed/Console.Host/ipyw.ico b/src/Console.Host/ipyw.ico similarity index 100% rename from Src.GetRenamed/Console.Host/ipyw.ico rename to src/Console.Host/ipyw.ico diff --git a/Src.GetRenamed/Console/Console.cs b/src/Console/Console.cs similarity index 100% rename from Src.GetRenamed/Console/Console.cs rename to src/Console/Console.cs diff --git a/Src.GetRenamed/Console/IronPython.Console.csproj b/src/Console/IronPython.Console.csproj similarity index 100% rename from Src.GetRenamed/Console/IronPython.Console.csproj rename to src/Console/IronPython.Console.csproj diff --git a/Src.GetRenamed/Console/Properties/AssemblyInfo.cs b/src/Console/Properties/AssemblyInfo.cs similarity index 100% rename from Src.GetRenamed/Console/Properties/AssemblyInfo.cs rename to src/Console/Properties/AssemblyInfo.cs diff --git a/Src.GetRenamed/Console/app.manifest b/src/Console/app.manifest similarity index 100% rename from Src.GetRenamed/Console/app.manifest rename to src/Console/app.manifest diff --git a/Src.GetRenamed/Console/ipy-mono.sh b/src/Console/ipy-mono.sh similarity index 100% rename from Src.GetRenamed/Console/ipy-mono.sh rename to src/Console/ipy-mono.sh diff --git a/Src.GetRenamed/Console/ipy.ico b/src/Console/ipy.ico similarity index 100% rename from Src.GetRenamed/Console/ipy.ico rename to src/Console/ipy.ico diff --git a/Src.GetRenamed/Console/ipy.sh b/src/Console/ipy.sh similarity index 100% rename from Src.GetRenamed/Console/ipy.sh rename to src/Console/ipy.sh diff --git a/Src.GetRenamed/Console/runtimeconfig.template.json b/src/Console/runtimeconfig.template.json similarity index 100% rename from Src.GetRenamed/Console/runtimeconfig.template.json rename to src/Console/runtimeconfig.template.json diff --git a/Src.GetRenamed/Console32.Host/IronPython.Console32.Host.csproj b/src/Console32.Host/IronPython.Console32.Host.csproj similarity index 100% rename from Src.GetRenamed/Console32.Host/IronPython.Console32.Host.csproj rename to src/Console32.Host/IronPython.Console32.Host.csproj diff --git a/Src.GetRenamed/Console32/IronPython.Console32.csproj b/src/Console32/IronPython.Console32.csproj similarity index 100% rename from Src.GetRenamed/Console32/IronPython.Console32.csproj rename to src/Console32/IronPython.Console32.csproj diff --git a/Src.GetRenamed/DiagnosticAnalyzer/Analyzer.cs b/src/DiagnosticAnalyzer/Analyzer.cs similarity index 100% rename from Src.GetRenamed/DiagnosticAnalyzer/Analyzer.cs rename to src/DiagnosticAnalyzer/Analyzer.cs diff --git a/Src.GetRenamed/DiagnosticAnalyzer/Directory.Build.props b/src/DiagnosticAnalyzer/Directory.Build.props similarity index 100% rename from Src.GetRenamed/DiagnosticAnalyzer/Directory.Build.props rename to src/DiagnosticAnalyzer/Directory.Build.props diff --git a/Src.GetRenamed/DiagnosticAnalyzer/IronPython.DiagnosticAnalyzer.csproj b/src/DiagnosticAnalyzer/IronPython.DiagnosticAnalyzer.csproj similarity index 100% rename from Src.GetRenamed/DiagnosticAnalyzer/IronPython.DiagnosticAnalyzer.csproj rename to src/DiagnosticAnalyzer/IronPython.DiagnosticAnalyzer.csproj diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/AndExpression.cs b/src/IronPython/Compiler/Ast/AndExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/AndExpression.cs rename to src/IronPython/Compiler/Ast/AndExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs b/src/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs rename to src/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/AssertStatement.cs b/src/IronPython/Compiler/Ast/AssertStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/AssertStatement.cs rename to src/IronPython/Compiler/Ast/AssertStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/AssignmentStatement.cs b/src/IronPython/Compiler/Ast/AssignmentStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/AssignmentStatement.cs rename to src/IronPython/Compiler/Ast/AssignmentStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/AstMethods.cs b/src/IronPython/Compiler/Ast/AstMethods.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/AstMethods.cs rename to src/IronPython/Compiler/Ast/AstMethods.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/AsyncStatement.cs b/src/IronPython/Compiler/Ast/AsyncStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/AsyncStatement.cs rename to src/IronPython/Compiler/Ast/AsyncStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/AugmentedAssignStatement.cs b/src/IronPython/Compiler/Ast/AugmentedAssignStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/AugmentedAssignStatement.cs rename to src/IronPython/Compiler/Ast/AugmentedAssignStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/BinaryExpression.Generated.cs b/src/IronPython/Compiler/Ast/BinaryExpression.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/BinaryExpression.Generated.cs rename to src/IronPython/Compiler/Ast/BinaryExpression.Generated.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/BinaryExpression.cs b/src/IronPython/Compiler/Ast/BinaryExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/BinaryExpression.cs rename to src/IronPython/Compiler/Ast/BinaryExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/BreakStatement.cs b/src/IronPython/Compiler/Ast/BreakStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/BreakStatement.cs rename to src/IronPython/Compiler/Ast/BreakStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/CallExpression.cs b/src/IronPython/Compiler/Ast/CallExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/CallExpression.cs rename to src/IronPython/Compiler/Ast/CallExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/ClassDefinition.cs b/src/IronPython/Compiler/Ast/ClassDefinition.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/ClassDefinition.cs rename to src/IronPython/Compiler/Ast/ClassDefinition.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/Comprehension.cs b/src/IronPython/Compiler/Ast/Comprehension.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/Comprehension.cs rename to src/IronPython/Compiler/Ast/Comprehension.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/ComprehensionFor.cs b/src/IronPython/Compiler/Ast/ComprehensionFor.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/ComprehensionFor.cs rename to src/IronPython/Compiler/Ast/ComprehensionFor.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/ComprehensionIf.cs b/src/IronPython/Compiler/Ast/ComprehensionIf.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/ComprehensionIf.cs rename to src/IronPython/Compiler/Ast/ComprehensionIf.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/ConditionalExpression.cs b/src/IronPython/Compiler/Ast/ConditionalExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/ConditionalExpression.cs rename to src/IronPython/Compiler/Ast/ConditionalExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/ConstantExpression.cs b/src/IronPython/Compiler/Ast/ConstantExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/ConstantExpression.cs rename to src/IronPython/Compiler/Ast/ConstantExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/ContinueStatement.cs b/src/IronPython/Compiler/Ast/ContinueStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/ContinueStatement.cs rename to src/IronPython/Compiler/Ast/ContinueStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/DelStatement.cs b/src/IronPython/Compiler/Ast/DelStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/DelStatement.cs rename to src/IronPython/Compiler/Ast/DelStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/DictionaryExpression.cs b/src/IronPython/Compiler/Ast/DictionaryExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/DictionaryExpression.cs rename to src/IronPython/Compiler/Ast/DictionaryExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/DottedName.cs b/src/IronPython/Compiler/Ast/DottedName.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/DottedName.cs rename to src/IronPython/Compiler/Ast/DottedName.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/DynamicConvertExpression.cs b/src/IronPython/Compiler/Ast/DynamicConvertExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/DynamicConvertExpression.cs rename to src/IronPython/Compiler/Ast/DynamicConvertExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs b/src/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs rename to src/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/EmptyStatement.cs b/src/IronPython/Compiler/Ast/EmptyStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/EmptyStatement.cs rename to src/IronPython/Compiler/Ast/EmptyStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/ErrorExpression.cs b/src/IronPython/Compiler/Ast/ErrorExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/ErrorExpression.cs rename to src/IronPython/Compiler/Ast/ErrorExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/Expression.cs b/src/IronPython/Compiler/Ast/Expression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/Expression.cs rename to src/IronPython/Compiler/Ast/Expression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/ExpressionStatement.cs b/src/IronPython/Compiler/Ast/ExpressionStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/ExpressionStatement.cs rename to src/IronPython/Compiler/Ast/ExpressionStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/FlowChecker.cs b/src/IronPython/Compiler/Ast/FlowChecker.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/FlowChecker.cs rename to src/IronPython/Compiler/Ast/FlowChecker.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/ForStatement.cs b/src/IronPython/Compiler/Ast/ForStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/ForStatement.cs rename to src/IronPython/Compiler/Ast/ForStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/FormattedValueExpression.cs b/src/IronPython/Compiler/Ast/FormattedValueExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/FormattedValueExpression.cs rename to src/IronPython/Compiler/Ast/FormattedValueExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/FromImportStatement.cs b/src/IronPython/Compiler/Ast/FromImportStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/FromImportStatement.cs rename to src/IronPython/Compiler/Ast/FromImportStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/FunctionDefinition.cs b/src/IronPython/Compiler/Ast/FunctionDefinition.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/FunctionDefinition.cs rename to src/IronPython/Compiler/Ast/FunctionDefinition.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/GeneratorExpression.cs b/src/IronPython/Compiler/Ast/GeneratorExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/GeneratorExpression.cs rename to src/IronPython/Compiler/Ast/GeneratorExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/GetGlobalContextExpression.cs b/src/IronPython/Compiler/Ast/GetGlobalContextExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/GetGlobalContextExpression.cs rename to src/IronPython/Compiler/Ast/GetGlobalContextExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs b/src/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs rename to src/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/GlobalStatement.cs b/src/IronPython/Compiler/Ast/GlobalStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/GlobalStatement.cs rename to src/IronPython/Compiler/Ast/GlobalStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/ILoopStatement.cs b/src/IronPython/Compiler/Ast/ILoopStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/ILoopStatement.cs rename to src/IronPython/Compiler/Ast/ILoopStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/IfStatement.cs b/src/IronPython/Compiler/Ast/IfStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/IfStatement.cs rename to src/IronPython/Compiler/Ast/IfStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/IfStatementTest.cs b/src/IronPython/Compiler/Ast/IfStatementTest.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/IfStatementTest.cs rename to src/IronPython/Compiler/Ast/IfStatementTest.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/ImportStatement.cs b/src/IronPython/Compiler/Ast/ImportStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/ImportStatement.cs rename to src/IronPython/Compiler/Ast/ImportStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/IndexExpression.cs b/src/IronPython/Compiler/Ast/IndexExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/IndexExpression.cs rename to src/IronPython/Compiler/Ast/IndexExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/JoinedStringExpression.cs b/src/IronPython/Compiler/Ast/JoinedStringExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/JoinedStringExpression.cs rename to src/IronPython/Compiler/Ast/JoinedStringExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/Keyword.cs b/src/IronPython/Compiler/Ast/Keyword.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/Keyword.cs rename to src/IronPython/Compiler/Ast/Keyword.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/LambdaExpression.cs b/src/IronPython/Compiler/Ast/LambdaExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/LambdaExpression.cs rename to src/IronPython/Compiler/Ast/LambdaExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/ListExpression.cs b/src/IronPython/Compiler/Ast/ListExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/ListExpression.cs rename to src/IronPython/Compiler/Ast/ListExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/MemberExpression.cs b/src/IronPython/Compiler/Ast/MemberExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/MemberExpression.cs rename to src/IronPython/Compiler/Ast/MemberExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/ModuleName.cs b/src/IronPython/Compiler/Ast/ModuleName.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/ModuleName.cs rename to src/IronPython/Compiler/Ast/ModuleName.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/NameExpression.cs b/src/IronPython/Compiler/Ast/NameExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/NameExpression.cs rename to src/IronPython/Compiler/Ast/NameExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/Node.cs b/src/IronPython/Compiler/Ast/Node.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/Node.cs rename to src/IronPython/Compiler/Ast/Node.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/NonlocalStatement.cs b/src/IronPython/Compiler/Ast/NonlocalStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/NonlocalStatement.cs rename to src/IronPython/Compiler/Ast/NonlocalStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/OrExpression.cs b/src/IronPython/Compiler/Ast/OrExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/OrExpression.cs rename to src/IronPython/Compiler/Ast/OrExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/Parameter.cs b/src/IronPython/Compiler/Ast/Parameter.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/Parameter.cs rename to src/IronPython/Compiler/Ast/Parameter.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/ParenthesisExpression.cs b/src/IronPython/Compiler/Ast/ParenthesisExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/ParenthesisExpression.cs rename to src/IronPython/Compiler/Ast/ParenthesisExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/PythonAst.cs b/src/IronPython/Compiler/Ast/PythonAst.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/PythonAst.cs rename to src/IronPython/Compiler/Ast/PythonAst.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/PythonConstantExpression.cs b/src/IronPython/Compiler/Ast/PythonConstantExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/PythonConstantExpression.cs rename to src/IronPython/Compiler/Ast/PythonConstantExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/PythonNameBinder.cs b/src/IronPython/Compiler/Ast/PythonNameBinder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/PythonNameBinder.cs rename to src/IronPython/Compiler/Ast/PythonNameBinder.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/PythonReference.cs b/src/IronPython/Compiler/Ast/PythonReference.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/PythonReference.cs rename to src/IronPython/Compiler/Ast/PythonReference.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/PythonVariable.cs b/src/IronPython/Compiler/Ast/PythonVariable.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/PythonVariable.cs rename to src/IronPython/Compiler/Ast/PythonVariable.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/PythonWalker.Generated.cs b/src/IronPython/Compiler/Ast/PythonWalker.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/PythonWalker.Generated.cs rename to src/IronPython/Compiler/Ast/PythonWalker.Generated.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/RaiseStatement.cs b/src/IronPython/Compiler/Ast/RaiseStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/RaiseStatement.cs rename to src/IronPython/Compiler/Ast/RaiseStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/RelativeModuleName.cs b/src/IronPython/Compiler/Ast/RelativeModuleName.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/RelativeModuleName.cs rename to src/IronPython/Compiler/Ast/RelativeModuleName.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/ReturnStatement.cs b/src/IronPython/Compiler/Ast/ReturnStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/ReturnStatement.cs rename to src/IronPython/Compiler/Ast/ReturnStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/ScopeStatement.cs b/src/IronPython/Compiler/Ast/ScopeStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/ScopeStatement.cs rename to src/IronPython/Compiler/Ast/ScopeStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/SequenceExpression.cs b/src/IronPython/Compiler/Ast/SequenceExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/SequenceExpression.cs rename to src/IronPython/Compiler/Ast/SequenceExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/SerializedScopeStatement.cs b/src/IronPython/Compiler/Ast/SerializedScopeStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/SerializedScopeStatement.cs rename to src/IronPython/Compiler/Ast/SerializedScopeStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/SetExpression.cs b/src/IronPython/Compiler/Ast/SetExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/SetExpression.cs rename to src/IronPython/Compiler/Ast/SetExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/SliceExpression.cs b/src/IronPython/Compiler/Ast/SliceExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/SliceExpression.cs rename to src/IronPython/Compiler/Ast/SliceExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/StarredExpression.cs b/src/IronPython/Compiler/Ast/StarredExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/StarredExpression.cs rename to src/IronPython/Compiler/Ast/StarredExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/Statement.cs b/src/IronPython/Compiler/Ast/Statement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/Statement.cs rename to src/IronPython/Compiler/Ast/Statement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/SuiteStatement.cs b/src/IronPython/Compiler/Ast/SuiteStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/SuiteStatement.cs rename to src/IronPython/Compiler/Ast/SuiteStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/TryStatement.cs b/src/IronPython/Compiler/Ast/TryStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/TryStatement.cs rename to src/IronPython/Compiler/Ast/TryStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/TupleExpression.cs b/src/IronPython/Compiler/Ast/TupleExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/TupleExpression.cs rename to src/IronPython/Compiler/Ast/TupleExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/UnaryExpression.cs b/src/IronPython/Compiler/Ast/UnaryExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/UnaryExpression.cs rename to src/IronPython/Compiler/Ast/UnaryExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/VariableKind.cs b/src/IronPython/Compiler/Ast/VariableKind.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/VariableKind.cs rename to src/IronPython/Compiler/Ast/VariableKind.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/WhileStatement.cs b/src/IronPython/Compiler/Ast/WhileStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/WhileStatement.cs rename to src/IronPython/Compiler/Ast/WhileStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/WithStatement.cs b/src/IronPython/Compiler/Ast/WithStatement.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/WithStatement.cs rename to src/IronPython/Compiler/Ast/WithStatement.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/YieldExpression.cs b/src/IronPython/Compiler/Ast/YieldExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/YieldExpression.cs rename to src/IronPython/Compiler/Ast/YieldExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Ast/YieldFromExpression.cs b/src/IronPython/Compiler/Ast/YieldFromExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Ast/YieldFromExpression.cs rename to src/IronPython/Compiler/Ast/YieldFromExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/ClosureExpression.cs b/src/IronPython/Compiler/ClosureExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/ClosureExpression.cs rename to src/IronPython/Compiler/ClosureExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/ClosureInfo.cs b/src/IronPython/Compiler/ClosureInfo.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/ClosureInfo.cs rename to src/IronPython/Compiler/ClosureInfo.cs diff --git a/Src.GetRenamed/IronPython/Compiler/CollectableCompilationMode.cs b/src/IronPython/Compiler/CollectableCompilationMode.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/CollectableCompilationMode.cs rename to src/IronPython/Compiler/CollectableCompilationMode.cs diff --git a/Src.GetRenamed/IronPython/Compiler/CompilationMode.cs b/src/IronPython/Compiler/CompilationMode.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/CompilationMode.cs rename to src/IronPython/Compiler/CompilationMode.cs diff --git a/Src.GetRenamed/IronPython/Compiler/GeneratorRewriter.cs b/src/IronPython/Compiler/GeneratorRewriter.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/GeneratorRewriter.cs rename to src/IronPython/Compiler/GeneratorRewriter.cs diff --git a/Src.GetRenamed/IronPython/Compiler/LazyCode.cs b/src/IronPython/Compiler/LazyCode.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/LazyCode.cs rename to src/IronPython/Compiler/LazyCode.cs diff --git a/Src.GetRenamed/IronPython/Compiler/LookupCompilationMode.cs b/src/IronPython/Compiler/LookupCompilationMode.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/LookupCompilationMode.cs rename to src/IronPython/Compiler/LookupCompilationMode.cs diff --git a/Src.GetRenamed/IronPython/Compiler/OnDiskScriptCode.cs b/src/IronPython/Compiler/OnDiskScriptCode.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/OnDiskScriptCode.cs rename to src/IronPython/Compiler/OnDiskScriptCode.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Parser.cs b/src/IronPython/Compiler/Parser.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Parser.cs rename to src/IronPython/Compiler/Parser.cs diff --git a/Src.GetRenamed/IronPython/Compiler/PythonCallTargets.cs b/src/IronPython/Compiler/PythonCallTargets.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/PythonCallTargets.cs rename to src/IronPython/Compiler/PythonCallTargets.cs diff --git a/Src.GetRenamed/IronPython/Compiler/PythonCompilerOptions.cs b/src/IronPython/Compiler/PythonCompilerOptions.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/PythonCompilerOptions.cs rename to src/IronPython/Compiler/PythonCompilerOptions.cs diff --git a/Src.GetRenamed/IronPython/Compiler/PythonDynamicExpression.cs b/src/IronPython/Compiler/PythonDynamicExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/PythonDynamicExpression.cs rename to src/IronPython/Compiler/PythonDynamicExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/PythonGlobal.cs b/src/IronPython/Compiler/PythonGlobal.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/PythonGlobal.cs rename to src/IronPython/Compiler/PythonGlobal.cs diff --git a/Src.GetRenamed/IronPython/Compiler/PythonGlobalVariableExpression.cs b/src/IronPython/Compiler/PythonGlobalVariableExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/PythonGlobalVariableExpression.cs rename to src/IronPython/Compiler/PythonGlobalVariableExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/PythonOperator.cs b/src/IronPython/Compiler/PythonOperator.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/PythonOperator.cs rename to src/IronPython/Compiler/PythonOperator.cs diff --git a/Src.GetRenamed/IronPython/Compiler/PythonSavableScriptCode.cs b/src/IronPython/Compiler/PythonSavableScriptCode.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/PythonSavableScriptCode.cs rename to src/IronPython/Compiler/PythonSavableScriptCode.cs diff --git a/Src.GetRenamed/IronPython/Compiler/PythonScriptCode.cs b/src/IronPython/Compiler/PythonScriptCode.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/PythonScriptCode.cs rename to src/IronPython/Compiler/PythonScriptCode.cs diff --git a/Src.GetRenamed/IronPython/Compiler/ReducableDynamicExpression.cs b/src/IronPython/Compiler/ReducableDynamicExpression.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/ReducableDynamicExpression.cs rename to src/IronPython/Compiler/ReducableDynamicExpression.cs diff --git a/Src.GetRenamed/IronPython/Compiler/RunnableScriptCode.cs b/src/IronPython/Compiler/RunnableScriptCode.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/RunnableScriptCode.cs rename to src/IronPython/Compiler/RunnableScriptCode.cs diff --git a/Src.GetRenamed/IronPython/Compiler/RuntimeScriptCode.cs b/src/IronPython/Compiler/RuntimeScriptCode.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/RuntimeScriptCode.cs rename to src/IronPython/Compiler/RuntimeScriptCode.cs diff --git a/Src.GetRenamed/IronPython/Compiler/ToDiskCompilationMode.cs b/src/IronPython/Compiler/ToDiskCompilationMode.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/ToDiskCompilationMode.cs rename to src/IronPython/Compiler/ToDiskCompilationMode.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Token.cs b/src/IronPython/Compiler/Token.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Token.cs rename to src/IronPython/Compiler/Token.cs diff --git a/Src.GetRenamed/IronPython/Compiler/TokenKind.Generated.cs b/src/IronPython/Compiler/TokenKind.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/TokenKind.Generated.cs rename to src/IronPython/Compiler/TokenKind.Generated.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Tokenizer.Generated.cs b/src/IronPython/Compiler/Tokenizer.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Tokenizer.Generated.cs rename to src/IronPython/Compiler/Tokenizer.Generated.cs diff --git a/Src.GetRenamed/IronPython/Compiler/Tokenizer.cs b/src/IronPython/Compiler/Tokenizer.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/Tokenizer.cs rename to src/IronPython/Compiler/Tokenizer.cs diff --git a/Src.GetRenamed/IronPython/Compiler/UncollectableCompilationMode.Generated.cs b/src/IronPython/Compiler/UncollectableCompilationMode.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/UncollectableCompilationMode.Generated.cs rename to src/IronPython/Compiler/UncollectableCompilationMode.Generated.cs diff --git a/Src.GetRenamed/IronPython/Compiler/UncollectableCompilationMode.cs b/src/IronPython/Compiler/UncollectableCompilationMode.cs similarity index 100% rename from Src.GetRenamed/IronPython/Compiler/UncollectableCompilationMode.cs rename to src/IronPython/Compiler/UncollectableCompilationMode.cs diff --git a/Src.GetRenamed/IronPython/FakeInteropServices.cs b/src/IronPython/FakeInteropServices.cs similarity index 100% rename from Src.GetRenamed/IronPython/FakeInteropServices.cs rename to src/IronPython/FakeInteropServices.cs diff --git a/Src.GetRenamed/IronPython/Hosting/Python.cs b/src/IronPython/Hosting/Python.cs similarity index 100% rename from Src.GetRenamed/IronPython/Hosting/Python.cs rename to src/IronPython/Hosting/Python.cs diff --git a/Src.GetRenamed/IronPython/Hosting/PythonCodeDomCodeGen.cs b/src/IronPython/Hosting/PythonCodeDomCodeGen.cs similarity index 100% rename from Src.GetRenamed/IronPython/Hosting/PythonCodeDomCodeGen.cs rename to src/IronPython/Hosting/PythonCodeDomCodeGen.cs diff --git a/Src.GetRenamed/IronPython/Hosting/PythonCommandLine.cs b/src/IronPython/Hosting/PythonCommandLine.cs similarity index 100% rename from Src.GetRenamed/IronPython/Hosting/PythonCommandLine.cs rename to src/IronPython/Hosting/PythonCommandLine.cs diff --git a/Src.GetRenamed/IronPython/Hosting/PythonConsoleOptions.cs b/src/IronPython/Hosting/PythonConsoleOptions.cs similarity index 100% rename from Src.GetRenamed/IronPython/Hosting/PythonConsoleOptions.cs rename to src/IronPython/Hosting/PythonConsoleOptions.cs diff --git a/Src.GetRenamed/IronPython/Hosting/PythonOptionsParser.cs b/src/IronPython/Hosting/PythonOptionsParser.cs similarity index 100% rename from Src.GetRenamed/IronPython/Hosting/PythonOptionsParser.cs rename to src/IronPython/Hosting/PythonOptionsParser.cs diff --git a/Src.GetRenamed/IronPython/Hosting/PythonService.cs b/src/IronPython/Hosting/PythonService.cs similarity index 100% rename from Src.GetRenamed/IronPython/Hosting/PythonService.cs rename to src/IronPython/Hosting/PythonService.cs diff --git a/Src.GetRenamed/IronPython/Interop/Windows/Interop.Libraries.cs b/src/IronPython/Interop/Windows/Interop.Libraries.cs similarity index 100% rename from Src.GetRenamed/IronPython/Interop/Windows/Interop.Libraries.cs rename to src/IronPython/Interop/Windows/Interop.Libraries.cs diff --git a/Src.GetRenamed/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs b/src/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs similarity index 100% rename from Src.GetRenamed/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs rename to src/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs diff --git a/Src.GetRenamed/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs b/src/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs similarity index 100% rename from Src.GetRenamed/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs rename to src/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs diff --git a/Src.GetRenamed/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs b/src/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs similarity index 100% rename from Src.GetRenamed/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs rename to src/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs diff --git a/Src.GetRenamed/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs b/src/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs similarity index 100% rename from Src.GetRenamed/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs rename to src/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs diff --git a/Src.GetRenamed/IronPython/IronPython.csproj b/src/IronPython/IronPython.csproj similarity index 100% rename from Src.GetRenamed/IronPython/IronPython.csproj rename to src/IronPython/IronPython.csproj diff --git a/Src.GetRenamed/IronPython/Lib/iptest/__init__.py b/src/IronPython/Lib/iptest/__init__.py similarity index 100% rename from Src.GetRenamed/IronPython/Lib/iptest/__init__.py rename to src/IronPython/Lib/iptest/__init__.py diff --git a/Src.GetRenamed/IronPython/Lib/iptest/cominterop_util.py b/src/IronPython/Lib/iptest/cominterop_util.py similarity index 100% rename from Src.GetRenamed/IronPython/Lib/iptest/cominterop_util.py rename to src/IronPython/Lib/iptest/cominterop_util.py diff --git a/Src.GetRenamed/IronPython/Lib/iptest/console_util.py b/src/IronPython/Lib/iptest/console_util.py similarity index 100% rename from Src.GetRenamed/IronPython/Lib/iptest/console_util.py rename to src/IronPython/Lib/iptest/console_util.py diff --git a/Src.GetRenamed/IronPython/Lib/iptest/file_util.py b/src/IronPython/Lib/iptest/file_util.py similarity index 100% rename from Src.GetRenamed/IronPython/Lib/iptest/file_util.py rename to src/IronPython/Lib/iptest/file_util.py diff --git a/Src.GetRenamed/IronPython/Lib/iptest/ipunittest.py b/src/IronPython/Lib/iptest/ipunittest.py similarity index 100% rename from Src.GetRenamed/IronPython/Lib/iptest/ipunittest.py rename to src/IronPython/Lib/iptest/ipunittest.py diff --git a/Src.GetRenamed/IronPython/Lib/iptest/misc_util.py b/src/IronPython/Lib/iptest/misc_util.py similarity index 100% rename from Src.GetRenamed/IronPython/Lib/iptest/misc_util.py rename to src/IronPython/Lib/iptest/misc_util.py diff --git a/Src.GetRenamed/IronPython/Lib/iptest/process_util.py b/src/IronPython/Lib/iptest/process_util.py similarity index 100% rename from Src.GetRenamed/IronPython/Lib/iptest/process_util.py rename to src/IronPython/Lib/iptest/process_util.py diff --git a/Src.GetRenamed/IronPython/Lib/iptest/runner.py b/src/IronPython/Lib/iptest/runner.py similarity index 100% rename from Src.GetRenamed/IronPython/Lib/iptest/runner.py rename to src/IronPython/Lib/iptest/runner.py diff --git a/Src.GetRenamed/IronPython/Lib/iptest/test_env.py b/src/IronPython/Lib/iptest/test_env.py similarity index 100% rename from Src.GetRenamed/IronPython/Lib/iptest/test_env.py rename to src/IronPython/Lib/iptest/test_env.py diff --git a/Src.GetRenamed/IronPython/Lib/iptest/type_util.py b/src/IronPython/Lib/iptest/type_util.py similarity index 100% rename from Src.GetRenamed/IronPython/Lib/iptest/type_util.py rename to src/IronPython/Lib/iptest/type_util.py diff --git a/Src.GetRenamed/IronPython/Modules/Builtin.Generated.cs b/src/IronPython/Modules/Builtin.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Modules/Builtin.Generated.cs rename to src/IronPython/Modules/Builtin.Generated.cs diff --git a/Src.GetRenamed/IronPython/Modules/Builtin.cs b/src/IronPython/Modules/Builtin.cs similarity index 100% rename from Src.GetRenamed/IronPython/Modules/Builtin.cs rename to src/IronPython/Modules/Builtin.cs diff --git a/Src.GetRenamed/IronPython/Modules/_ast.cs b/src/IronPython/Modules/_ast.cs similarity index 100% rename from Src.GetRenamed/IronPython/Modules/_ast.cs rename to src/IronPython/Modules/_ast.cs diff --git a/Src.GetRenamed/IronPython/Modules/_fileio.cs b/src/IronPython/Modules/_fileio.cs similarity index 100% rename from Src.GetRenamed/IronPython/Modules/_fileio.cs rename to src/IronPython/Modules/_fileio.cs diff --git a/Src.GetRenamed/IronPython/Modules/_imp.cs b/src/IronPython/Modules/_imp.cs similarity index 100% rename from Src.GetRenamed/IronPython/Modules/_imp.cs rename to src/IronPython/Modules/_imp.cs diff --git a/Src.GetRenamed/IronPython/Modules/_io.cs b/src/IronPython/Modules/_io.cs similarity index 100% rename from Src.GetRenamed/IronPython/Modules/_io.cs rename to src/IronPython/Modules/_io.cs diff --git a/Src.GetRenamed/IronPython/Modules/_io/BytesIO.cs b/src/IronPython/Modules/_io/BytesIO.cs similarity index 100% rename from Src.GetRenamed/IronPython/Modules/_io/BytesIO.cs rename to src/IronPython/Modules/_io/BytesIO.cs diff --git a/Src.GetRenamed/IronPython/Modules/_io/StringIO.cs b/src/IronPython/Modules/_io/StringIO.cs similarity index 100% rename from Src.GetRenamed/IronPython/Modules/_io/StringIO.cs rename to src/IronPython/Modules/_io/StringIO.cs diff --git a/Src.GetRenamed/IronPython/Modules/_locale.cs b/src/IronPython/Modules/_locale.cs similarity index 100% rename from Src.GetRenamed/IronPython/Modules/_locale.cs rename to src/IronPython/Modules/_locale.cs diff --git a/Src.GetRenamed/IronPython/Modules/sys.cs b/src/IronPython/Modules/sys.cs similarity index 100% rename from Src.GetRenamed/IronPython/Modules/sys.cs rename to src/IronPython/Modules/sys.cs diff --git a/Src.GetRenamed/IronPython/Modules/unicodedata.cs b/src/IronPython/Modules/unicodedata.cs similarity index 100% rename from Src.GetRenamed/IronPython/Modules/unicodedata.cs rename to src/IronPython/Modules/unicodedata.cs diff --git a/Src.GetRenamed/IronPython/Modules/unicodedata/CaseFolding.txt b/src/IronPython/Modules/unicodedata/CaseFolding.txt similarity index 100% rename from Src.GetRenamed/IronPython/Modules/unicodedata/CaseFolding.txt rename to src/IronPython/Modules/unicodedata/CaseFolding.txt diff --git a/Src.GetRenamed/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt b/src/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt similarity index 100% rename from Src.GetRenamed/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt rename to src/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt diff --git a/Src.GetRenamed/IronPython/Modules/unicodedata/EastAsianWidth.txt b/src/IronPython/Modules/unicodedata/EastAsianWidth.txt similarity index 100% rename from Src.GetRenamed/IronPython/Modules/unicodedata/EastAsianWidth.txt rename to src/IronPython/Modules/unicodedata/EastAsianWidth.txt diff --git a/Src.GetRenamed/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz b/src/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz similarity index 100% rename from Src.GetRenamed/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz rename to src/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz diff --git a/Src.GetRenamed/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz b/src/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz similarity index 100% rename from Src.GetRenamed/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz rename to src/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz diff --git a/Src.GetRenamed/IronPython/Modules/unicodedata/NameAliases.txt b/src/IronPython/Modules/unicodedata/NameAliases.txt similarity index 100% rename from Src.GetRenamed/IronPython/Modules/unicodedata/NameAliases.txt rename to src/IronPython/Modules/unicodedata/NameAliases.txt diff --git a/Src.GetRenamed/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt b/src/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt similarity index 100% rename from Src.GetRenamed/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt rename to src/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt diff --git a/Src.GetRenamed/IronPython/Modules/unicodedata/UnicodeData.txt b/src/IronPython/Modules/unicodedata/UnicodeData.txt similarity index 100% rename from Src.GetRenamed/IronPython/Modules/unicodedata/UnicodeData.txt rename to src/IronPython/Modules/unicodedata/UnicodeData.txt diff --git a/Src.GetRenamed/IronPython/Modules/unicodedata/genunicodedata.py b/src/IronPython/Modules/unicodedata/genunicodedata.py similarity index 100% rename from Src.GetRenamed/IronPython/Modules/unicodedata/genunicodedata.py rename to src/IronPython/Modules/unicodedata/genunicodedata.py diff --git a/Src.GetRenamed/IronPython/Modules/unicodedata/license.txt b/src/IronPython/Modules/unicodedata/license.txt similarity index 100% rename from Src.GetRenamed/IronPython/Modules/unicodedata/license.txt rename to src/IronPython/Modules/unicodedata/license.txt diff --git a/Src.GetRenamed/IronPython/Properties/AssemblyInfo.cs b/src/IronPython/Properties/AssemblyInfo.cs similarity index 100% rename from Src.GetRenamed/IronPython/Properties/AssemblyInfo.cs rename to src/IronPython/Properties/AssemblyInfo.cs diff --git a/Src.GetRenamed/IronPython/Resources.Designer.cs b/src/IronPython/Resources.Designer.cs similarity index 100% rename from Src.GetRenamed/IronPython/Resources.Designer.cs rename to src/IronPython/Resources.Designer.cs diff --git a/Src.GetRenamed/IronPython/Resources.resx b/src/IronPython/Resources.resx similarity index 100% rename from Src.GetRenamed/IronPython/Resources.resx rename to src/IronPython/Resources.resx diff --git a/Src.GetRenamed/IronPython/Runtime/ArrayData.cs b/src/IronPython/Runtime/ArrayData.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/ArrayData.cs rename to src/IronPython/Runtime/ArrayData.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs b/src/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs rename to src/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs b/src/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs rename to src/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/Binders.cs b/src/IronPython/Runtime/Binding/Binders.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/Binders.cs rename to src/IronPython/Runtime/Binding/Binders.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/BindingHelpers.cs b/src/IronPython/Runtime/Binding/BindingHelpers.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/BindingHelpers.cs rename to src/IronPython/Runtime/Binding/BindingHelpers.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/BindingWarnings.cs b/src/IronPython/Runtime/Binding/BindingWarnings.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/BindingWarnings.cs rename to src/IronPython/Runtime/Binding/BindingWarnings.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs b/src/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs rename to src/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/ConditionalBuilder.cs b/src/IronPython/Runtime/Binding/ConditionalBuilder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/ConditionalBuilder.cs rename to src/IronPython/Runtime/Binding/ConditionalBuilder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/ContextArgBuilder.cs b/src/IronPython/Runtime/Binding/ContextArgBuilder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/ContextArgBuilder.cs rename to src/IronPython/Runtime/Binding/ContextArgBuilder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/ConversionBinder.cs b/src/IronPython/Runtime/Binding/ConversionBinder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/ConversionBinder.cs rename to src/IronPython/Runtime/Binding/ConversionBinder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/CreateFallbackBinder.cs b/src/IronPython/Runtime/Binding/CreateFallbackBinder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/CreateFallbackBinder.cs rename to src/IronPython/Runtime/Binding/CreateFallbackBinder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/FastBindResult.cs b/src/IronPython/Runtime/Binding/FastBindResult.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/FastBindResult.cs rename to src/IronPython/Runtime/Binding/FastBindResult.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/FastGetBase.cs b/src/IronPython/Runtime/Binding/FastGetBase.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/FastGetBase.cs rename to src/IronPython/Runtime/Binding/FastGetBase.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/FastSetBase.cs b/src/IronPython/Runtime/Binding/FastSetBase.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/FastSetBase.cs rename to src/IronPython/Runtime/Binding/FastSetBase.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/IComConvertible.cs b/src/IronPython/Runtime/Binding/IComConvertible.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/IComConvertible.cs rename to src/IronPython/Runtime/Binding/IComConvertible.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/IFastGettable.cs b/src/IronPython/Runtime/Binding/IFastGettable.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/IFastGettable.cs rename to src/IronPython/Runtime/Binding/IFastGettable.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/IFastInvokable.cs b/src/IronPython/Runtime/Binding/IFastInvokable.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/IFastInvokable.cs rename to src/IronPython/Runtime/Binding/IFastInvokable.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/IFastSettable.cs b/src/IronPython/Runtime/Binding/IFastSettable.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/IFastSettable.cs rename to src/IronPython/Runtime/Binding/IFastSettable.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/IPythonConvertible.cs b/src/IronPython/Runtime/Binding/IPythonConvertible.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/IPythonConvertible.cs rename to src/IronPython/Runtime/Binding/IPythonConvertible.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/IPythonExpandable.cs b/src/IronPython/Runtime/Binding/IPythonExpandable.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/IPythonExpandable.cs rename to src/IronPython/Runtime/Binding/IPythonExpandable.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/IPythonGetable.cs b/src/IronPython/Runtime/Binding/IPythonGetable.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/IPythonGetable.cs rename to src/IronPython/Runtime/Binding/IPythonGetable.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/IPythonInvokable.cs b/src/IronPython/Runtime/Binding/IPythonInvokable.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/IPythonInvokable.cs rename to src/IronPython/Runtime/Binding/IPythonInvokable.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/IPythonOperable.cs b/src/IronPython/Runtime/Binding/IPythonOperable.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/IPythonOperable.cs rename to src/IronPython/Runtime/Binding/IPythonOperable.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/IPythonSite.cs b/src/IronPython/Runtime/Binding/IPythonSite.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/IPythonSite.cs rename to src/IronPython/Runtime/Binding/IPythonSite.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/MetaBuiltinFunction.cs b/src/IronPython/Runtime/Binding/MetaBuiltinFunction.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/MetaBuiltinFunction.cs rename to src/IronPython/Runtime/Binding/MetaBuiltinFunction.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs b/src/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs rename to src/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/MetaMethod.cs b/src/IronPython/Runtime/Binding/MetaMethod.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/MetaMethod.cs rename to src/IronPython/Runtime/Binding/MetaMethod.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/MetaPythonFunction.cs b/src/IronPython/Runtime/Binding/MetaPythonFunction.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/MetaPythonFunction.cs rename to src/IronPython/Runtime/Binding/MetaPythonFunction.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/MetaPythonObject.cs b/src/IronPython/Runtime/Binding/MetaPythonObject.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/MetaPythonObject.cs rename to src/IronPython/Runtime/Binding/MetaPythonObject.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/MetaPythonType.Calls.cs b/src/IronPython/Runtime/Binding/MetaPythonType.Calls.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/MetaPythonType.Calls.cs rename to src/IronPython/Runtime/Binding/MetaPythonType.Calls.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/MetaPythonType.Members.cs b/src/IronPython/Runtime/Binding/MetaPythonType.Members.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/MetaPythonType.Members.cs rename to src/IronPython/Runtime/Binding/MetaPythonType.Members.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/MetaPythonType.cs b/src/IronPython/Runtime/Binding/MetaPythonType.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/MetaPythonType.cs rename to src/IronPython/Runtime/Binding/MetaPythonType.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/MetaUserObject.Members.cs b/src/IronPython/Runtime/Binding/MetaUserObject.Members.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/MetaUserObject.Members.cs rename to src/IronPython/Runtime/Binding/MetaUserObject.Members.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/MetaUserObject.cs b/src/IronPython/Runtime/Binding/MetaUserObject.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/MetaUserObject.cs rename to src/IronPython/Runtime/Binding/MetaUserObject.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs b/src/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs rename to src/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/PythonBinder.Create.cs b/src/IronPython/Runtime/Binding/PythonBinder.Create.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/PythonBinder.Create.cs rename to src/IronPython/Runtime/Binding/PythonBinder.Create.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/PythonBinder.cs b/src/IronPython/Runtime/Binding/PythonBinder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/PythonBinder.cs rename to src/IronPython/Runtime/Binding/PythonBinder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs b/src/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs rename to src/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs b/src/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs rename to src/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs b/src/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs rename to src/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/PythonExtensionBinder.cs b/src/IronPython/Runtime/Binding/PythonExtensionBinder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/PythonExtensionBinder.cs rename to src/IronPython/Runtime/Binding/PythonExtensionBinder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/PythonGetIndexBinder.cs b/src/IronPython/Runtime/Binding/PythonGetIndexBinder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/PythonGetIndexBinder.cs rename to src/IronPython/Runtime/Binding/PythonGetIndexBinder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/PythonGetMemberBinder.cs b/src/IronPython/Runtime/Binding/PythonGetMemberBinder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/PythonGetMemberBinder.cs rename to src/IronPython/Runtime/Binding/PythonGetMemberBinder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/PythonGetSliceBinder.cs b/src/IronPython/Runtime/Binding/PythonGetSliceBinder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/PythonGetSliceBinder.cs rename to src/IronPython/Runtime/Binding/PythonGetSliceBinder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/PythonIndexType.cs b/src/IronPython/Runtime/Binding/PythonIndexType.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/PythonIndexType.cs rename to src/IronPython/Runtime/Binding/PythonIndexType.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/PythonInvokeBinder.cs b/src/IronPython/Runtime/Binding/PythonInvokeBinder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/PythonInvokeBinder.cs rename to src/IronPython/Runtime/Binding/PythonInvokeBinder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/PythonOperationBinder.cs b/src/IronPython/Runtime/Binding/PythonOperationBinder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/PythonOperationBinder.cs rename to src/IronPython/Runtime/Binding/PythonOperationBinder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/PythonOperationKind.cs b/src/IronPython/Runtime/Binding/PythonOperationKind.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/PythonOperationKind.cs rename to src/IronPython/Runtime/Binding/PythonOperationKind.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/PythonOverloadResolver.cs b/src/IronPython/Runtime/Binding/PythonOverloadResolver.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/PythonOverloadResolver.cs rename to src/IronPython/Runtime/Binding/PythonOverloadResolver.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/PythonProtocol.Operations.cs b/src/IronPython/Runtime/Binding/PythonProtocol.Operations.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/PythonProtocol.Operations.cs rename to src/IronPython/Runtime/Binding/PythonProtocol.Operations.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/PythonProtocol.cs b/src/IronPython/Runtime/Binding/PythonProtocol.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/PythonProtocol.cs rename to src/IronPython/Runtime/Binding/PythonProtocol.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/PythonSetIndexBinder.cs b/src/IronPython/Runtime/Binding/PythonSetIndexBinder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/PythonSetIndexBinder.cs rename to src/IronPython/Runtime/Binding/PythonSetIndexBinder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/PythonSetMemberBinder.cs b/src/IronPython/Runtime/Binding/PythonSetMemberBinder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/PythonSetMemberBinder.cs rename to src/IronPython/Runtime/Binding/PythonSetMemberBinder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/PythonSetSliceBinder.cs b/src/IronPython/Runtime/Binding/PythonSetSliceBinder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/PythonSetSliceBinder.cs rename to src/IronPython/Runtime/Binding/PythonSetSliceBinder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs b/src/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs rename to src/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs b/src/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs rename to src/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/SlotOrFunction.cs b/src/IronPython/Runtime/Binding/SlotOrFunction.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/SlotOrFunction.cs rename to src/IronPython/Runtime/Binding/SlotOrFunction.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Binding/WarningInfo.cs b/src/IronPython/Runtime/Binding/WarningInfo.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Binding/WarningInfo.cs rename to src/IronPython/Runtime/Binding/WarningInfo.cs diff --git a/Src.GetRenamed/IronPython/Runtime/BufferProtocol.cs b/src/IronPython/Runtime/BufferProtocol.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/BufferProtocol.cs rename to src/IronPython/Runtime/BufferProtocol.cs diff --git a/Src.GetRenamed/IronPython/Runtime/BuiltinPythonModule.cs b/src/IronPython/Runtime/BuiltinPythonModule.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/BuiltinPythonModule.cs rename to src/IronPython/Runtime/BuiltinPythonModule.cs diff --git a/Src.GetRenamed/IronPython/Runtime/BuiltinsDictionaryStorage.cs b/src/IronPython/Runtime/BuiltinsDictionaryStorage.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/BuiltinsDictionaryStorage.cs rename to src/IronPython/Runtime/BuiltinsDictionaryStorage.cs diff --git a/Src.GetRenamed/IronPython/Runtime/ByteArray.cs b/src/IronPython/Runtime/ByteArray.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/ByteArray.cs rename to src/IronPython/Runtime/ByteArray.cs diff --git a/Src.GetRenamed/IronPython/Runtime/ByteArrayIterator.cs b/src/IronPython/Runtime/ByteArrayIterator.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/ByteArrayIterator.cs rename to src/IronPython/Runtime/ByteArrayIterator.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Bytes.cs b/src/IronPython/Runtime/Bytes.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Bytes.cs rename to src/IronPython/Runtime/Bytes.cs diff --git a/Src.GetRenamed/IronPython/Runtime/BytesIterator.cs b/src/IronPython/Runtime/BytesIterator.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/BytesIterator.cs rename to src/IronPython/Runtime/BytesIterator.cs diff --git a/Src.GetRenamed/IronPython/Runtime/BytesLikeAttribute.cs b/src/IronPython/Runtime/BytesLikeAttribute.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/BytesLikeAttribute.cs rename to src/IronPython/Runtime/BytesLikeAttribute.cs diff --git a/Src.GetRenamed/IronPython/Runtime/ClassMethodAttribute.cs b/src/IronPython/Runtime/ClassMethodAttribute.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/ClassMethodAttribute.cs rename to src/IronPython/Runtime/ClassMethodAttribute.cs diff --git a/Src.GetRenamed/IronPython/Runtime/ClassMethodDescriptor.cs b/src/IronPython/Runtime/ClassMethodDescriptor.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/ClassMethodDescriptor.cs rename to src/IronPython/Runtime/ClassMethodDescriptor.cs diff --git a/Src.GetRenamed/IronPython/Runtime/ClrModule.cs b/src/IronPython/Runtime/ClrModule.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/ClrModule.cs rename to src/IronPython/Runtime/ClrModule.cs diff --git a/Src.GetRenamed/IronPython/Runtime/CodeContext.cs b/src/IronPython/Runtime/CodeContext.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/CodeContext.cs rename to src/IronPython/Runtime/CodeContext.cs diff --git a/Src.GetRenamed/IronPython/Runtime/CollectionDebugView.cs b/src/IronPython/Runtime/CollectionDebugView.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/CollectionDebugView.cs rename to src/IronPython/Runtime/CollectionDebugView.cs diff --git a/Src.GetRenamed/IronPython/Runtime/CommonDictionaryStorage.cs b/src/IronPython/Runtime/CommonDictionaryStorage.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/CommonDictionaryStorage.cs rename to src/IronPython/Runtime/CommonDictionaryStorage.cs diff --git a/Src.GetRenamed/IronPython/Runtime/CompareUtil.cs b/src/IronPython/Runtime/CompareUtil.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/CompareUtil.cs rename to src/IronPython/Runtime/CompareUtil.cs diff --git a/Src.GetRenamed/IronPython/Runtime/CompileFlags.cs b/src/IronPython/Runtime/CompileFlags.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/CompileFlags.cs rename to src/IronPython/Runtime/CompileFlags.cs diff --git a/Src.GetRenamed/IronPython/Runtime/CompiledLoader.cs b/src/IronPython/Runtime/CompiledLoader.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/CompiledLoader.cs rename to src/IronPython/Runtime/CompiledLoader.cs diff --git a/Src.GetRenamed/IronPython/Runtime/ConstantDictionaryStorage.cs b/src/IronPython/Runtime/ConstantDictionaryStorage.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/ConstantDictionaryStorage.cs rename to src/IronPython/Runtime/ConstantDictionaryStorage.cs diff --git a/Src.GetRenamed/IronPython/Runtime/ConversionWrappers.cs b/src/IronPython/Runtime/ConversionWrappers.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/ConversionWrappers.cs rename to src/IronPython/Runtime/ConversionWrappers.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Converter.cs b/src/IronPython/Runtime/Converter.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Converter.cs rename to src/IronPython/Runtime/Converter.cs diff --git a/Src.GetRenamed/IronPython/Runtime/CustomDictionaryStorage.cs b/src/IronPython/Runtime/CustomDictionaryStorage.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/CustomDictionaryStorage.cs rename to src/IronPython/Runtime/CustomDictionaryStorage.cs diff --git a/Src.GetRenamed/IronPython/Runtime/DebuggerDictionaryStorage.cs b/src/IronPython/Runtime/DebuggerDictionaryStorage.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/DebuggerDictionaryStorage.cs rename to src/IronPython/Runtime/DebuggerDictionaryStorage.cs diff --git a/Src.GetRenamed/IronPython/Runtime/DefaultContext.cs b/src/IronPython/Runtime/DefaultContext.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/DefaultContext.cs rename to src/IronPython/Runtime/DefaultContext.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Descriptors.cs b/src/IronPython/Runtime/Descriptors.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Descriptors.cs rename to src/IronPython/Runtime/Descriptors.cs diff --git a/Src.GetRenamed/IronPython/Runtime/DictionaryOps.cs b/src/IronPython/Runtime/DictionaryOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/DictionaryOps.cs rename to src/IronPython/Runtime/DictionaryOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/DictionaryStorage.cs b/src/IronPython/Runtime/DictionaryStorage.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/DictionaryStorage.cs rename to src/IronPython/Runtime/DictionaryStorage.cs diff --git a/Src.GetRenamed/IronPython/Runtime/DictionaryTypeInfoAttribute.cs b/src/IronPython/Runtime/DictionaryTypeInfoAttribute.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/DictionaryTypeInfoAttribute.cs rename to src/IronPython/Runtime/DictionaryTypeInfoAttribute.cs diff --git a/Src.GetRenamed/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs b/src/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs rename to src/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs diff --git a/Src.GetRenamed/IronPython/Runtime/DontMapICollectionToLenAttribute.cs b/src/IronPython/Runtime/DontMapICollectionToLenAttribute.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/DontMapICollectionToLenAttribute.cs rename to src/IronPython/Runtime/DontMapICollectionToLenAttribute.cs diff --git a/Src.GetRenamed/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs b/src/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs rename to src/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs diff --git a/Src.GetRenamed/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs b/src/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs rename to src/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs diff --git a/Src.GetRenamed/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs b/src/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs rename to src/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs diff --git a/Src.GetRenamed/IronPython/Runtime/EmptyDictionaryStorage.cs b/src/IronPython/Runtime/EmptyDictionaryStorage.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/EmptyDictionaryStorage.cs rename to src/IronPython/Runtime/EmptyDictionaryStorage.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Enumerate.cs b/src/IronPython/Runtime/Enumerate.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Enumerate.cs rename to src/IronPython/Runtime/Enumerate.cs diff --git a/Src.GetRenamed/IronPython/Runtime/ErrorCodes.cs b/src/IronPython/Runtime/ErrorCodes.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/ErrorCodes.cs rename to src/IronPython/Runtime/ErrorCodes.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/AssertionException.Generated.cs b/src/IronPython/Runtime/Exceptions/AssertionException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/AssertionException.Generated.cs rename to src/IronPython/Runtime/Exceptions/AssertionException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/AttributeErrorException.cs b/src/IronPython/Runtime/Exceptions/AttributeErrorException.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/AttributeErrorException.cs rename to src/IronPython/Runtime/Exceptions/AttributeErrorException.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs b/src/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs rename to src/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs b/src/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs rename to src/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/BufferException.Generated.cs b/src/IronPython/Runtime/Exceptions/BufferException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/BufferException.Generated.cs rename to src/IronPython/Runtime/Exceptions/BufferException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs b/src/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs rename to src/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs b/src/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs rename to src/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs b/src/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs rename to src/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs b/src/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs rename to src/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs b/src/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs rename to src/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs b/src/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs rename to src/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs b/src/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs rename to src/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs b/src/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs rename to src/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs b/src/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs rename to src/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs b/src/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs rename to src/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/GeneratorExitException.cs b/src/IronPython/Runtime/Exceptions/GeneratorExitException.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/GeneratorExitException.cs rename to src/IronPython/Runtime/Exceptions/GeneratorExitException.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/ImportException.Generated.cs b/src/IronPython/Runtime/Exceptions/ImportException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/ImportException.Generated.cs rename to src/IronPython/Runtime/Exceptions/ImportException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs b/src/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs rename to src/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/IndentationException.cs b/src/IronPython/Runtime/Exceptions/IndentationException.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/IndentationException.cs rename to src/IronPython/Runtime/Exceptions/IndentationException.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs b/src/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs rename to src/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs b/src/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs rename to src/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/LookupException.Generated.cs b/src/IronPython/Runtime/Exceptions/LookupException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/LookupException.Generated.cs rename to src/IronPython/Runtime/Exceptions/LookupException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs b/src/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs rename to src/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs b/src/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs rename to src/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/OSException.Generated.cs b/src/IronPython/Runtime/Exceptions/OSException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/OSException.Generated.cs rename to src/IronPython/Runtime/Exceptions/OSException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs b/src/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs rename to src/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs b/src/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs rename to src/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/PythonException.cs b/src/IronPython/Runtime/Exceptions/PythonException.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/PythonException.cs rename to src/IronPython/Runtime/Exceptions/PythonException.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs b/src/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs rename to src/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs b/src/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs rename to src/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/PythonExceptions.cs b/src/IronPython/Runtime/Exceptions/PythonExceptions.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/PythonExceptions.cs rename to src/IronPython/Runtime/Exceptions/PythonExceptions.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/RecursionException.Generated.cs b/src/IronPython/Runtime/Exceptions/RecursionException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/RecursionException.Generated.cs rename to src/IronPython/Runtime/Exceptions/RecursionException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs b/src/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs rename to src/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs b/src/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs rename to src/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs b/src/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs rename to src/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs b/src/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs rename to src/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs b/src/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs rename to src/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs b/src/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs rename to src/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs b/src/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs rename to src/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/SystemExitException.cs b/src/IronPython/Runtime/Exceptions/SystemExitException.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/SystemExitException.cs rename to src/IronPython/Runtime/Exceptions/SystemExitException.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/TabException.cs b/src/IronPython/Runtime/Exceptions/TabException.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/TabException.cs rename to src/IronPython/Runtime/Exceptions/TabException.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/TraceBack.cs b/src/IronPython/Runtime/Exceptions/TraceBack.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/TraceBack.cs rename to src/IronPython/Runtime/Exceptions/TraceBack.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/TypeErrorException.cs b/src/IronPython/Runtime/Exceptions/TypeErrorException.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/TypeErrorException.cs rename to src/IronPython/Runtime/Exceptions/TypeErrorException.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs b/src/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs rename to src/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs b/src/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs rename to src/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs b/src/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs rename to src/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs b/src/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs rename to src/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Exceptions/ValueErrorException.cs b/src/IronPython/Runtime/Exceptions/ValueErrorException.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Exceptions/ValueErrorException.cs rename to src/IronPython/Runtime/Exceptions/ValueErrorException.cs diff --git a/Src.GetRenamed/IronPython/Runtime/ExtensionMethodSet.cs b/src/IronPython/Runtime/ExtensionMethodSet.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/ExtensionMethodSet.cs rename to src/IronPython/Runtime/ExtensionMethodSet.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Filter.cs b/src/IronPython/Runtime/Filter.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Filter.cs rename to src/IronPython/Runtime/Filter.cs diff --git a/Src.GetRenamed/IronPython/Runtime/FormattingHelper.cs b/src/IronPython/Runtime/FormattingHelper.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/FormattingHelper.cs rename to src/IronPython/Runtime/FormattingHelper.cs diff --git a/Src.GetRenamed/IronPython/Runtime/FunctionAttributes.cs b/src/IronPython/Runtime/FunctionAttributes.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/FunctionAttributes.cs rename to src/IronPython/Runtime/FunctionAttributes.cs diff --git a/Src.GetRenamed/IronPython/Runtime/FunctionCode.cs b/src/IronPython/Runtime/FunctionCode.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/FunctionCode.cs rename to src/IronPython/Runtime/FunctionCode.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Generator.cs b/src/IronPython/Runtime/Generator.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Generator.cs rename to src/IronPython/Runtime/Generator.cs diff --git a/Src.GetRenamed/IronPython/Runtime/GlobalDictionaryStorage.cs b/src/IronPython/Runtime/GlobalDictionaryStorage.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/GlobalDictionaryStorage.cs rename to src/IronPython/Runtime/GlobalDictionaryStorage.cs diff --git a/Src.GetRenamed/IronPython/Runtime/IParameterSequence.cs b/src/IronPython/Runtime/IParameterSequence.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/IParameterSequence.cs rename to src/IronPython/Runtime/IParameterSequence.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Implementation.cs b/src/IronPython/Runtime/Implementation.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Implementation.cs rename to src/IronPython/Runtime/Implementation.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Importer.cs b/src/IronPython/Runtime/Importer.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Importer.cs rename to src/IronPython/Runtime/Importer.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Index.cs b/src/IronPython/Runtime/Index.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Index.cs rename to src/IronPython/Runtime/Index.cs diff --git a/Src.GetRenamed/IronPython/Runtime/InstancedModuleDictionaryStorage.cs b/src/IronPython/Runtime/InstancedModuleDictionaryStorage.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/InstancedModuleDictionaryStorage.cs rename to src/IronPython/Runtime/InstancedModuleDictionaryStorage.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Interfaces.cs b/src/IronPython/Runtime/Interfaces.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Interfaces.cs rename to src/IronPython/Runtime/Interfaces.cs diff --git a/Src.GetRenamed/IronPython/Runtime/KwCallInfo.cs b/src/IronPython/Runtime/KwCallInfo.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/KwCallInfo.cs rename to src/IronPython/Runtime/KwCallInfo.cs diff --git a/Src.GetRenamed/IronPython/Runtime/LiteralParser.cs b/src/IronPython/Runtime/LiteralParser.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/LiteralParser.cs rename to src/IronPython/Runtime/LiteralParser.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Map.cs b/src/IronPython/Runtime/Map.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Map.cs rename to src/IronPython/Runtime/Map.cs diff --git a/Src.GetRenamed/IronPython/Runtime/MaybeNotImplementedAttribute.cs b/src/IronPython/Runtime/MaybeNotImplementedAttribute.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/MaybeNotImplementedAttribute.cs rename to src/IronPython/Runtime/MaybeNotImplementedAttribute.cs diff --git a/Src.GetRenamed/IronPython/Runtime/MemoryStreamContentProvider.cs b/src/IronPython/Runtime/MemoryStreamContentProvider.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/MemoryStreamContentProvider.cs rename to src/IronPython/Runtime/MemoryStreamContentProvider.cs diff --git a/Src.GetRenamed/IronPython/Runtime/MemoryView.cs b/src/IronPython/Runtime/MemoryView.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/MemoryView.cs rename to src/IronPython/Runtime/MemoryView.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Method.Generated.cs b/src/IronPython/Runtime/Method.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Method.Generated.cs rename to src/IronPython/Runtime/Method.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Method.cs b/src/IronPython/Runtime/Method.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Method.cs rename to src/IronPython/Runtime/Method.cs diff --git a/Src.GetRenamed/IronPython/Runtime/MissingParameter.cs b/src/IronPython/Runtime/MissingParameter.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/MissingParameter.cs rename to src/IronPython/Runtime/MissingParameter.cs diff --git a/Src.GetRenamed/IronPython/Runtime/ModuleContext.cs b/src/IronPython/Runtime/ModuleContext.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/ModuleContext.cs rename to src/IronPython/Runtime/ModuleContext.cs diff --git a/Src.GetRenamed/IronPython/Runtime/ModuleDictionaryStorage.cs b/src/IronPython/Runtime/ModuleDictionaryStorage.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/ModuleDictionaryStorage.cs rename to src/IronPython/Runtime/ModuleDictionaryStorage.cs diff --git a/Src.GetRenamed/IronPython/Runtime/ModuleGlobalCache.cs b/src/IronPython/Runtime/ModuleGlobalCache.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/ModuleGlobalCache.cs rename to src/IronPython/Runtime/ModuleGlobalCache.cs diff --git a/Src.GetRenamed/IronPython/Runtime/ModuleLoader.cs b/src/IronPython/Runtime/ModuleLoader.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/ModuleLoader.cs rename to src/IronPython/Runtime/ModuleLoader.cs diff --git a/Src.GetRenamed/IronPython/Runtime/ModuleOptions.cs b/src/IronPython/Runtime/ModuleOptions.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/ModuleOptions.cs rename to src/IronPython/Runtime/ModuleOptions.cs diff --git a/Src.GetRenamed/IronPython/Runtime/NameType.cs b/src/IronPython/Runtime/NameType.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/NameType.cs rename to src/IronPython/Runtime/NameType.cs diff --git a/Src.GetRenamed/IronPython/Runtime/NewStringFormatter.cs b/src/IronPython/Runtime/NewStringFormatter.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/NewStringFormatter.cs rename to src/IronPython/Runtime/NewStringFormatter.cs diff --git a/Src.GetRenamed/IronPython/Runtime/ObjectAttributesAdapter.cs b/src/IronPython/Runtime/ObjectAttributesAdapter.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/ObjectAttributesAdapter.cs rename to src/IronPython/Runtime/ObjectAttributesAdapter.cs diff --git a/Src.GetRenamed/IronPython/Runtime/ObjectDebugView.cs b/src/IronPython/Runtime/ObjectDebugView.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/ObjectDebugView.cs rename to src/IronPython/Runtime/ObjectDebugView.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/ArrayOps.cs b/src/IronPython/Runtime/Operations/ArrayOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/ArrayOps.cs rename to src/IronPython/Runtime/Operations/ArrayOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/BigIntegerOps.cs b/src/IronPython/Runtime/Operations/BigIntegerOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/BigIntegerOps.cs rename to src/IronPython/Runtime/Operations/BigIntegerOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/BoolOps.cs b/src/IronPython/Runtime/Operations/BoolOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/BoolOps.cs rename to src/IronPython/Runtime/Operations/BoolOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/ByteOps.cs b/src/IronPython/Runtime/Operations/ByteOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/ByteOps.cs rename to src/IronPython/Runtime/Operations/ByteOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/CharOps.cs b/src/IronPython/Runtime/Operations/CharOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/CharOps.cs rename to src/IronPython/Runtime/Operations/CharOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/ComOps.cs b/src/IronPython/Runtime/Operations/ComOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/ComOps.cs rename to src/IronPython/Runtime/Operations/ComOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/ComplexOps.cs b/src/IronPython/Runtime/Operations/ComplexOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/ComplexOps.cs rename to src/IronPython/Runtime/Operations/ComplexOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs b/src/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs rename to src/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/DBNullOps.cs b/src/IronPython/Runtime/Operations/DBNullOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/DBNullOps.cs rename to src/IronPython/Runtime/Operations/DBNullOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/DateTimeOps.cs b/src/IronPython/Runtime/Operations/DateTimeOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/DateTimeOps.cs rename to src/IronPython/Runtime/Operations/DateTimeOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/DecimalOps.cs b/src/IronPython/Runtime/Operations/DecimalOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/DecimalOps.cs rename to src/IronPython/Runtime/Operations/DecimalOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/DelegateOps.cs b/src/IronPython/Runtime/Operations/DelegateOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/DelegateOps.cs rename to src/IronPython/Runtime/Operations/DelegateOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/DictionaryOfTOps.cs b/src/IronPython/Runtime/Operations/DictionaryOfTOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/DictionaryOfTOps.cs rename to src/IronPython/Runtime/Operations/DictionaryOfTOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/EnumOps.cs b/src/IronPython/Runtime/Operations/EnumOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/EnumOps.cs rename to src/IronPython/Runtime/Operations/EnumOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/FloatOps.Generated.cs b/src/IronPython/Runtime/Operations/FloatOps.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/FloatOps.Generated.cs rename to src/IronPython/Runtime/Operations/FloatOps.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/FloatOps.cs b/src/IronPython/Runtime/Operations/FloatOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/FloatOps.cs rename to src/IronPython/Runtime/Operations/FloatOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/IListOfByteOps.cs b/src/IronPython/Runtime/Operations/IListOfByteOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/IListOfByteOps.cs rename to src/IronPython/Runtime/Operations/IListOfByteOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/InstanceOps.cs b/src/IronPython/Runtime/Operations/InstanceOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/InstanceOps.cs rename to src/IronPython/Runtime/Operations/InstanceOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/IntOps.Generated.cs b/src/IronPython/Runtime/Operations/IntOps.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/IntOps.Generated.cs rename to src/IronPython/Runtime/Operations/IntOps.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/IntOps.cs b/src/IronPython/Runtime/Operations/IntOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/IntOps.cs rename to src/IronPython/Runtime/Operations/IntOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/IntPtrOps.cs b/src/IronPython/Runtime/Operations/IntPtrOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/IntPtrOps.cs rename to src/IronPython/Runtime/Operations/IntPtrOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/ListOfTOps.cs b/src/IronPython/Runtime/Operations/ListOfTOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/ListOfTOps.cs rename to src/IronPython/Runtime/Operations/ListOfTOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/MarshalOps.cs b/src/IronPython/Runtime/Operations/MarshalOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/MarshalOps.cs rename to src/IronPython/Runtime/Operations/MarshalOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/NamespaceTrackerOps.cs b/src/IronPython/Runtime/Operations/NamespaceTrackerOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/NamespaceTrackerOps.cs rename to src/IronPython/Runtime/Operations/NamespaceTrackerOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/ObjectOps.cs b/src/IronPython/Runtime/Operations/ObjectOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/ObjectOps.cs rename to src/IronPython/Runtime/Operations/ObjectOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/PythonCalls.cs b/src/IronPython/Runtime/Operations/PythonCalls.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/PythonCalls.cs rename to src/IronPython/Runtime/Operations/PythonCalls.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/PythonOps.Generated.cs b/src/IronPython/Runtime/Operations/PythonOps.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/PythonOps.Generated.cs rename to src/IronPython/Runtime/Operations/PythonOps.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/PythonOps.cs b/src/IronPython/Runtime/Operations/PythonOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/PythonOps.cs rename to src/IronPython/Runtime/Operations/PythonOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/PythonTypeOps.cs b/src/IronPython/Runtime/Operations/PythonTypeOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/PythonTypeOps.cs rename to src/IronPython/Runtime/Operations/PythonTypeOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/StringOps.Generated.cs b/src/IronPython/Runtime/Operations/StringOps.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/StringOps.Generated.cs rename to src/IronPython/Runtime/Operations/StringOps.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/StringOps.cs b/src/IronPython/Runtime/Operations/StringOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/StringOps.cs rename to src/IronPython/Runtime/Operations/StringOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/TypeGroupOps.cs b/src/IronPython/Runtime/Operations/TypeGroupOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/TypeGroupOps.cs rename to src/IronPython/Runtime/Operations/TypeGroupOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/TypeTrackerOps.cs b/src/IronPython/Runtime/Operations/TypeTrackerOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/TypeTrackerOps.cs rename to src/IronPython/Runtime/Operations/TypeTrackerOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/UIntPtrOps.cs b/src/IronPython/Runtime/Operations/UIntPtrOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/UIntPtrOps.cs rename to src/IronPython/Runtime/Operations/UIntPtrOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Operations/UserTypeOps.cs b/src/IronPython/Runtime/Operations/UserTypeOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Operations/UserTypeOps.cs rename to src/IronPython/Runtime/Operations/UserTypeOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/OutputWriter.cs b/src/IronPython/Runtime/OutputWriter.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/OutputWriter.cs rename to src/IronPython/Runtime/OutputWriter.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PlatformsAttribute.cs b/src/IronPython/Runtime/PlatformsAttribute.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PlatformsAttribute.cs rename to src/IronPython/Runtime/PlatformsAttribute.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Profiler.cs b/src/IronPython/Runtime/Profiler.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Profiler.cs rename to src/IronPython/Runtime/Profiler.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonContext.Generated.cs b/src/IronPython/Runtime/PythonContext.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonContext.Generated.cs rename to src/IronPython/Runtime/PythonContext.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonContext.cs b/src/IronPython/Runtime/PythonContext.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonContext.cs rename to src/IronPython/Runtime/PythonContext.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonDictionary.cs b/src/IronPython/Runtime/PythonDictionary.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonDictionary.cs rename to src/IronPython/Runtime/PythonDictionary.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonDocumentationProvider.cs b/src/IronPython/Runtime/PythonDocumentationProvider.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonDocumentationProvider.cs rename to src/IronPython/Runtime/PythonDocumentationProvider.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonDynamicStackFrame.cs b/src/IronPython/Runtime/PythonDynamicStackFrame.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonDynamicStackFrame.cs rename to src/IronPython/Runtime/PythonDynamicStackFrame.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonEncoding.cs b/src/IronPython/Runtime/PythonEncoding.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonEncoding.cs rename to src/IronPython/Runtime/PythonEncoding.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonFileManager.cs b/src/IronPython/Runtime/PythonFileManager.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonFileManager.cs rename to src/IronPython/Runtime/PythonFileManager.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonFunction.Generated.cs b/src/IronPython/Runtime/PythonFunction.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonFunction.Generated.cs rename to src/IronPython/Runtime/PythonFunction.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonFunction.cs b/src/IronPython/Runtime/PythonFunction.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonFunction.cs rename to src/IronPython/Runtime/PythonFunction.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonHiddenAttribute.cs b/src/IronPython/Runtime/PythonHiddenAttribute.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonHiddenAttribute.cs rename to src/IronPython/Runtime/PythonHiddenAttribute.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs b/src/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs rename to src/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonList.cs b/src/IronPython/Runtime/PythonList.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonList.cs rename to src/IronPython/Runtime/PythonList.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonModule.cs b/src/IronPython/Runtime/PythonModule.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonModule.cs rename to src/IronPython/Runtime/PythonModule.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonModuleAttribute.cs b/src/IronPython/Runtime/PythonModuleAttribute.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonModuleAttribute.cs rename to src/IronPython/Runtime/PythonModuleAttribute.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonNarrowing.cs b/src/IronPython/Runtime/PythonNarrowing.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonNarrowing.cs rename to src/IronPython/Runtime/PythonNarrowing.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonOptions.cs b/src/IronPython/Runtime/PythonOptions.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonOptions.cs rename to src/IronPython/Runtime/PythonOptions.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonRange.cs b/src/IronPython/Runtime/PythonRange.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonRange.cs rename to src/IronPython/Runtime/PythonRange.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonScopeExtension.cs b/src/IronPython/Runtime/PythonScopeExtension.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonScopeExtension.cs rename to src/IronPython/Runtime/PythonScopeExtension.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonStrIterator.cs b/src/IronPython/Runtime/PythonStrIterator.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonStrIterator.cs rename to src/IronPython/Runtime/PythonStrIterator.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonTracebackListener.cs b/src/IronPython/Runtime/PythonTracebackListener.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonTracebackListener.cs rename to src/IronPython/Runtime/PythonTracebackListener.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonTuple.cs b/src/IronPython/Runtime/PythonTuple.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonTuple.cs rename to src/IronPython/Runtime/PythonTuple.cs diff --git a/Src.GetRenamed/IronPython/Runtime/PythonTypeAttribute.cs b/src/IronPython/Runtime/PythonTypeAttribute.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/PythonTypeAttribute.cs rename to src/IronPython/Runtime/PythonTypeAttribute.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Reversed.cs b/src/IronPython/Runtime/Reversed.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Reversed.cs rename to src/IronPython/Runtime/Reversed.cs diff --git a/Src.GetRenamed/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs b/src/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs rename to src/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs diff --git a/Src.GetRenamed/IronPython/Runtime/ScopeDictionaryStorage.cs b/src/IronPython/Runtime/ScopeDictionaryStorage.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/ScopeDictionaryStorage.cs rename to src/IronPython/Runtime/ScopeDictionaryStorage.cs diff --git a/Src.GetRenamed/IronPython/Runtime/SequenceTypeInfoAttribute.cs b/src/IronPython/Runtime/SequenceTypeInfoAttribute.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/SequenceTypeInfoAttribute.cs rename to src/IronPython/Runtime/SequenceTypeInfoAttribute.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Set.cs b/src/IronPython/Runtime/Set.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Set.cs rename to src/IronPython/Runtime/Set.cs diff --git a/Src.GetRenamed/IronPython/Runtime/SetStorage.cs b/src/IronPython/Runtime/SetStorage.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/SetStorage.cs rename to src/IronPython/Runtime/SetStorage.cs diff --git a/Src.GetRenamed/IronPython/Runtime/SimpleNamespace.cs b/src/IronPython/Runtime/SimpleNamespace.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/SimpleNamespace.cs rename to src/IronPython/Runtime/SimpleNamespace.cs diff --git a/Src.GetRenamed/IronPython/Runtime/SiteLocalStorage.cs b/src/IronPython/Runtime/SiteLocalStorage.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/SiteLocalStorage.cs rename to src/IronPython/Runtime/SiteLocalStorage.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Slice.cs b/src/IronPython/Runtime/Slice.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Slice.cs rename to src/IronPython/Runtime/Slice.cs diff --git a/Src.GetRenamed/IronPython/Runtime/StringDictionaryStorage.cs b/src/IronPython/Runtime/StringDictionaryStorage.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/StringDictionaryStorage.cs rename to src/IronPython/Runtime/StringDictionaryStorage.cs diff --git a/Src.GetRenamed/IronPython/Runtime/StringFormatSpec.cs b/src/IronPython/Runtime/StringFormatSpec.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/StringFormatSpec.cs rename to src/IronPython/Runtime/StringFormatSpec.cs diff --git a/Src.GetRenamed/IronPython/Runtime/StringFormatter.cs b/src/IronPython/Runtime/StringFormatter.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/StringFormatter.cs rename to src/IronPython/Runtime/StringFormatter.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Super.cs b/src/IronPython/Runtime/Super.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Super.cs rename to src/IronPython/Runtime/Super.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Symbols.Generated.cs b/src/IronPython/Runtime/Symbols.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Symbols.Generated.cs rename to src/IronPython/Runtime/Symbols.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/ThrowingErrorSink.cs b/src/IronPython/Runtime/ThrowingErrorSink.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/ThrowingErrorSink.cs rename to src/IronPython/Runtime/ThrowingErrorSink.cs diff --git a/Src.GetRenamed/IronPython/Runtime/TypecodeOps.cs b/src/IronPython/Runtime/TypecodeOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/TypecodeOps.cs rename to src/IronPython/Runtime/TypecodeOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/BuiltinFunction.cs b/src/IronPython/Runtime/Types/BuiltinFunction.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/BuiltinFunction.cs rename to src/IronPython/Runtime/Types/BuiltinFunction.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs b/src/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs rename to src/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs b/src/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs rename to src/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/CachedNewTypeInfo.cs b/src/IronPython/Runtime/Types/CachedNewTypeInfo.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/CachedNewTypeInfo.cs rename to src/IronPython/Runtime/Types/CachedNewTypeInfo.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/ConstructorFunction.cs b/src/IronPython/Runtime/Types/ConstructorFunction.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/ConstructorFunction.cs rename to src/IronPython/Runtime/Types/ConstructorFunction.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/CustomAttributeTracker.cs b/src/IronPython/Runtime/Types/CustomAttributeTracker.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/CustomAttributeTracker.cs rename to src/IronPython/Runtime/Types/CustomAttributeTracker.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs b/src/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs rename to src/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/DocBuilder.cs b/src/IronPython/Runtime/Types/DocBuilder.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/DocBuilder.cs rename to src/IronPython/Runtime/Types/DocBuilder.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs b/src/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs rename to src/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/DynamicHelpers.cs b/src/IronPython/Runtime/Types/DynamicHelpers.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/DynamicHelpers.cs rename to src/IronPython/Runtime/Types/DynamicHelpers.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/EmptyType.cs b/src/IronPython/Runtime/Types/EmptyType.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/EmptyType.cs rename to src/IronPython/Runtime/Types/EmptyType.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/ExtensionPropertyInfo.cs b/src/IronPython/Runtime/Types/ExtensionPropertyInfo.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/ExtensionPropertyInfo.cs rename to src/IronPython/Runtime/Types/ExtensionPropertyInfo.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/FunctionType.cs b/src/IronPython/Runtime/Types/FunctionType.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/FunctionType.cs rename to src/IronPython/Runtime/Types/FunctionType.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/IPythonObject.cs b/src/IronPython/Runtime/Types/IPythonObject.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/IPythonObject.cs rename to src/IronPython/Runtime/Types/IPythonObject.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/InstanceCreator.cs b/src/IronPython/Runtime/Types/InstanceCreator.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/InstanceCreator.cs rename to src/IronPython/Runtime/Types/InstanceCreator.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/MappingProxy.cs b/src/IronPython/Runtime/Types/MappingProxy.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/MappingProxy.cs rename to src/IronPython/Runtime/Types/MappingProxy.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/Mro.cs b/src/IronPython/Runtime/Types/Mro.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/Mro.cs rename to src/IronPython/Runtime/Types/Mro.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/NameConverter.cs b/src/IronPython/Runtime/Types/NameConverter.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/NameConverter.cs rename to src/IronPython/Runtime/Types/NameConverter.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/NewTypeInfo.cs b/src/IronPython/Runtime/Types/NewTypeInfo.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/NewTypeInfo.cs rename to src/IronPython/Runtime/Types/NewTypeInfo.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/NewTypeMaker.cs b/src/IronPython/Runtime/Types/NewTypeMaker.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/NewTypeMaker.cs rename to src/IronPython/Runtime/Types/NewTypeMaker.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/OperatorMapping.cs b/src/IronPython/Runtime/Types/OperatorMapping.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/OperatorMapping.cs rename to src/IronPython/Runtime/Types/OperatorMapping.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/ParameterInfoWrapper.cs b/src/IronPython/Runtime/Types/ParameterInfoWrapper.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/ParameterInfoWrapper.cs rename to src/IronPython/Runtime/Types/ParameterInfoWrapper.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/PythonAssemblyOps.cs b/src/IronPython/Runtime/Types/PythonAssemblyOps.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/PythonAssemblyOps.cs rename to src/IronPython/Runtime/Types/PythonAssemblyOps.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/PythonSiteCache.cs b/src/IronPython/Runtime/Types/PythonSiteCache.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/PythonSiteCache.cs rename to src/IronPython/Runtime/Types/PythonSiteCache.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/PythonType.Generated.cs b/src/IronPython/Runtime/Types/PythonType.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/PythonType.Generated.cs rename to src/IronPython/Runtime/Types/PythonType.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/PythonType.cs b/src/IronPython/Runtime/Types/PythonType.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/PythonType.cs rename to src/IronPython/Runtime/Types/PythonType.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/PythonTypeDataSlot.cs b/src/IronPython/Runtime/Types/PythonTypeDataSlot.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/PythonTypeDataSlot.cs rename to src/IronPython/Runtime/Types/PythonTypeDataSlot.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/PythonTypeDictSlot.cs b/src/IronPython/Runtime/Types/PythonTypeDictSlot.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/PythonTypeDictSlot.cs rename to src/IronPython/Runtime/Types/PythonTypeDictSlot.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs b/src/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs rename to src/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/PythonTypeInfo.cs b/src/IronPython/Runtime/Types/PythonTypeInfo.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/PythonTypeInfo.cs rename to src/IronPython/Runtime/Types/PythonTypeInfo.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/PythonTypeSlot.cs b/src/IronPython/Runtime/Types/PythonTypeSlot.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/PythonTypeSlot.cs rename to src/IronPython/Runtime/Types/PythonTypeSlot.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/PythonTypeTypeSlot.cs b/src/IronPython/Runtime/Types/PythonTypeTypeSlot.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/PythonTypeTypeSlot.cs rename to src/IronPython/Runtime/Types/PythonTypeTypeSlot.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs b/src/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs rename to src/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs b/src/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs rename to src/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/ReflectedEvent.cs b/src/IronPython/Runtime/Types/ReflectedEvent.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/ReflectedEvent.cs rename to src/IronPython/Runtime/Types/ReflectedEvent.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/ReflectedExtensionProperty.cs b/src/IronPython/Runtime/Types/ReflectedExtensionProperty.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/ReflectedExtensionProperty.cs rename to src/IronPython/Runtime/Types/ReflectedExtensionProperty.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/ReflectedField.cs b/src/IronPython/Runtime/Types/ReflectedField.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/ReflectedField.cs rename to src/IronPython/Runtime/Types/ReflectedField.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/ReflectedGetterSetter.cs b/src/IronPython/Runtime/Types/ReflectedGetterSetter.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/ReflectedGetterSetter.cs rename to src/IronPython/Runtime/Types/ReflectedGetterSetter.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/ReflectedIndexer.cs b/src/IronPython/Runtime/Types/ReflectedIndexer.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/ReflectedIndexer.cs rename to src/IronPython/Runtime/Types/ReflectedIndexer.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/ReflectedProperty.cs b/src/IronPython/Runtime/Types/ReflectedProperty.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/ReflectedProperty.cs rename to src/IronPython/Runtime/Types/ReflectedProperty.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/ReflectedSlotProperty.cs b/src/IronPython/Runtime/Types/ReflectedSlotProperty.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/ReflectedSlotProperty.cs rename to src/IronPython/Runtime/Types/ReflectedSlotProperty.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/ResolvedMember.cs b/src/IronPython/Runtime/Types/ResolvedMember.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/ResolvedMember.cs rename to src/IronPython/Runtime/Types/ResolvedMember.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/SlotFieldAttribute.cs b/src/IronPython/Runtime/Types/SlotFieldAttribute.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/SlotFieldAttribute.cs rename to src/IronPython/Runtime/Types/SlotFieldAttribute.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs b/src/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs rename to src/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Types/TypeCache.Generated.cs b/src/IronPython/Runtime/Types/TypeCache.Generated.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Types/TypeCache.Generated.cs rename to src/IronPython/Runtime/Types/TypeCache.Generated.cs diff --git a/Src.GetRenamed/IronPython/Runtime/UnboundNameException.cs b/src/IronPython/Runtime/UnboundNameException.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/UnboundNameException.cs rename to src/IronPython/Runtime/UnboundNameException.cs diff --git a/Src.GetRenamed/IronPython/Runtime/WeakRef.cs b/src/IronPython/Runtime/WeakRef.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/WeakRef.cs rename to src/IronPython/Runtime/WeakRef.cs diff --git a/Src.GetRenamed/IronPython/Runtime/WrapperDescriptorAttribute.cs b/src/IronPython/Runtime/WrapperDescriptorAttribute.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/WrapperDescriptorAttribute.cs rename to src/IronPython/Runtime/WrapperDescriptorAttribute.cs diff --git a/Src.GetRenamed/IronPython/Runtime/WrapperDictionary.cs b/src/IronPython/Runtime/WrapperDictionary.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/WrapperDictionary.cs rename to src/IronPython/Runtime/WrapperDictionary.cs diff --git a/Src.GetRenamed/IronPython/Runtime/Zip.cs b/src/IronPython/Runtime/Zip.cs similarity index 100% rename from Src.GetRenamed/IronPython/Runtime/Zip.cs rename to src/IronPython/Runtime/Zip.cs diff --git a/Src.GetRenamed/IronPython/SerializationStubs.cs b/src/IronPython/SerializationStubs.cs similarity index 100% rename from Src.GetRenamed/IronPython/SerializationStubs.cs rename to src/IronPython/SerializationStubs.cs diff --git a/Src.GetRenamed/IronPython/StringExtensions.cs b/src/IronPython/StringExtensions.cs similarity index 100% rename from Src.GetRenamed/IronPython/StringExtensions.cs rename to src/IronPython/StringExtensions.cs diff --git a/Src.GetRenamed/IronPython/SystemRuntimeVersioning.cs b/src/IronPython/SystemRuntimeVersioning.cs similarity index 100% rename from Src.GetRenamed/IronPython/SystemRuntimeVersioning.cs rename to src/IronPython/SystemRuntimeVersioning.cs diff --git a/Src.GetRenamed/IronPython/policy.IronPython.config b/src/IronPython/policy.IronPython.config similarity index 100% rename from Src.GetRenamed/IronPython/policy.IronPython.config rename to src/IronPython/policy.IronPython.config diff --git a/Src.GetRenamed/Modules/IronPython.Modules.csproj b/src/Modules/IronPython.Modules.csproj similarity index 100% rename from Src.GetRenamed/Modules/IronPython.Modules.csproj rename to src/Modules/IronPython.Modules.csproj diff --git a/Src.GetRenamed/Modules/IterTools.cs b/src/Modules/IterTools.cs similarity index 100% rename from Src.GetRenamed/Modules/IterTools.cs rename to src/Modules/IterTools.cs diff --git a/Src.GetRenamed/Modules/ModuleOps.cs b/src/Modules/ModuleOps.cs similarity index 100% rename from Src.GetRenamed/Modules/ModuleOps.cs rename to src/Modules/ModuleOps.cs diff --git a/Src.GetRenamed/Modules/NtSignalState.cs b/src/Modules/NtSignalState.cs similarity index 100% rename from Src.GetRenamed/Modules/NtSignalState.cs rename to src/Modules/NtSignalState.cs diff --git a/Src.GetRenamed/Modules/Properties/AssemblyInfo.cs b/src/Modules/Properties/AssemblyInfo.cs similarity index 100% rename from Src.GetRenamed/Modules/Properties/AssemblyInfo.cs rename to src/Modules/Properties/AssemblyInfo.cs diff --git a/Src.GetRenamed/Modules/ResourceMetaPathImporter.cs b/src/Modules/ResourceMetaPathImporter.cs similarity index 100% rename from Src.GetRenamed/Modules/ResourceMetaPathImporter.cs rename to src/Modules/ResourceMetaPathImporter.cs diff --git a/Src.GetRenamed/Modules/SimpleSignalState.cs b/src/Modules/SimpleSignalState.cs similarity index 100% rename from Src.GetRenamed/Modules/SimpleSignalState.cs rename to src/Modules/SimpleSignalState.cs diff --git a/Src.GetRenamed/Modules/_bisect.cs b/src/Modules/_bisect.cs similarity index 100% rename from Src.GetRenamed/Modules/_bisect.cs rename to src/Modules/_bisect.cs diff --git a/Src.GetRenamed/Modules/_codecs.cs b/src/Modules/_codecs.cs similarity index 100% rename from Src.GetRenamed/Modules/_codecs.cs rename to src/Modules/_codecs.cs diff --git a/Src.GetRenamed/Modules/_codecs_cn.cs b/src/Modules/_codecs_cn.cs similarity index 100% rename from Src.GetRenamed/Modules/_codecs_cn.cs rename to src/Modules/_codecs_cn.cs diff --git a/Src.GetRenamed/Modules/_collections.cs b/src/Modules/_collections.cs similarity index 100% rename from Src.GetRenamed/Modules/_collections.cs rename to src/Modules/_collections.cs diff --git a/Src.GetRenamed/Modules/_csv.cs b/src/Modules/_csv.cs similarity index 100% rename from Src.GetRenamed/Modules/_csv.cs rename to src/Modules/_csv.cs diff --git a/Src.GetRenamed/Modules/_ctypes/Array.cs b/src/Modules/_ctypes/Array.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/Array.cs rename to src/Modules/_ctypes/Array.cs diff --git a/Src.GetRenamed/Modules/_ctypes/ArrayType.cs b/src/Modules/_ctypes/ArrayType.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/ArrayType.cs rename to src/Modules/_ctypes/ArrayType.cs diff --git a/Src.GetRenamed/Modules/_ctypes/CData.cs b/src/Modules/_ctypes/CData.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/CData.cs rename to src/Modules/_ctypes/CData.cs diff --git a/Src.GetRenamed/Modules/_ctypes/CFuncPtr.cs b/src/Modules/_ctypes/CFuncPtr.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/CFuncPtr.cs rename to src/Modules/_ctypes/CFuncPtr.cs diff --git a/Src.GetRenamed/Modules/_ctypes/CFuncPtrType.cs b/src/Modules/_ctypes/CFuncPtrType.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/CFuncPtrType.cs rename to src/Modules/_ctypes/CFuncPtrType.cs diff --git a/Src.GetRenamed/Modules/_ctypes/Extensions.cs b/src/Modules/_ctypes/Extensions.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/Extensions.cs rename to src/Modules/_ctypes/Extensions.cs diff --git a/Src.GetRenamed/Modules/_ctypes/Field.cs b/src/Modules/_ctypes/Field.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/Field.cs rename to src/Modules/_ctypes/Field.cs diff --git a/Src.GetRenamed/Modules/_ctypes/INativeType.cs b/src/Modules/_ctypes/INativeType.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/INativeType.cs rename to src/Modules/_ctypes/INativeType.cs diff --git a/Src.GetRenamed/Modules/_ctypes/LocalOrArg.cs b/src/Modules/_ctypes/LocalOrArg.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/LocalOrArg.cs rename to src/Modules/_ctypes/LocalOrArg.cs diff --git a/Src.GetRenamed/Modules/_ctypes/MarshalCleanup.cs b/src/Modules/_ctypes/MarshalCleanup.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/MarshalCleanup.cs rename to src/Modules/_ctypes/MarshalCleanup.cs diff --git a/Src.GetRenamed/Modules/_ctypes/MemoryHolder.cs b/src/Modules/_ctypes/MemoryHolder.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/MemoryHolder.cs rename to src/Modules/_ctypes/MemoryHolder.cs diff --git a/Src.GetRenamed/Modules/_ctypes/NativeArgument.cs b/src/Modules/_ctypes/NativeArgument.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/NativeArgument.cs rename to src/Modules/_ctypes/NativeArgument.cs diff --git a/Src.GetRenamed/Modules/_ctypes/NativeFunctions.cs b/src/Modules/_ctypes/NativeFunctions.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/NativeFunctions.cs rename to src/Modules/_ctypes/NativeFunctions.cs diff --git a/Src.GetRenamed/Modules/_ctypes/Pointer.cs b/src/Modules/_ctypes/Pointer.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/Pointer.cs rename to src/Modules/_ctypes/Pointer.cs diff --git a/Src.GetRenamed/Modules/_ctypes/PointerType.cs b/src/Modules/_ctypes/PointerType.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/PointerType.cs rename to src/Modules/_ctypes/PointerType.cs diff --git a/Src.GetRenamed/Modules/_ctypes/SimpleCData.cs b/src/Modules/_ctypes/SimpleCData.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/SimpleCData.cs rename to src/Modules/_ctypes/SimpleCData.cs diff --git a/Src.GetRenamed/Modules/_ctypes/SimpleType.cs b/src/Modules/_ctypes/SimpleType.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/SimpleType.cs rename to src/Modules/_ctypes/SimpleType.cs diff --git a/Src.GetRenamed/Modules/_ctypes/SimpleTypeKind.cs b/src/Modules/_ctypes/SimpleTypeKind.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/SimpleTypeKind.cs rename to src/Modules/_ctypes/SimpleTypeKind.cs diff --git a/Src.GetRenamed/Modules/_ctypes/StructType.cs b/src/Modules/_ctypes/StructType.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/StructType.cs rename to src/Modules/_ctypes/StructType.cs diff --git a/Src.GetRenamed/Modules/_ctypes/Structure.cs b/src/Modules/_ctypes/Structure.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/Structure.cs rename to src/Modules/_ctypes/Structure.cs diff --git a/Src.GetRenamed/Modules/_ctypes/Union.cs b/src/Modules/_ctypes/Union.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/Union.cs rename to src/Modules/_ctypes/Union.cs diff --git a/Src.GetRenamed/Modules/_ctypes/UnionType.cs b/src/Modules/_ctypes/UnionType.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/UnionType.cs rename to src/Modules/_ctypes/UnionType.cs diff --git a/Src.GetRenamed/Modules/_ctypes/_ctypes.cs b/src/Modules/_ctypes/_ctypes.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes/_ctypes.cs rename to src/Modules/_ctypes/_ctypes.cs diff --git a/Src.GetRenamed/Modules/_ctypes_test.cs b/src/Modules/_ctypes_test.cs similarity index 100% rename from Src.GetRenamed/Modules/_ctypes_test.cs rename to src/Modules/_ctypes_test.cs diff --git a/Src.GetRenamed/Modules/_datetime.cs b/src/Modules/_datetime.cs similarity index 100% rename from Src.GetRenamed/Modules/_datetime.cs rename to src/Modules/_datetime.cs diff --git a/Src.GetRenamed/Modules/_functools.cs b/src/Modules/_functools.cs similarity index 100% rename from Src.GetRenamed/Modules/_functools.cs rename to src/Modules/_functools.cs diff --git a/Src.GetRenamed/Modules/_heapq.cs b/src/Modules/_heapq.cs similarity index 100% rename from Src.GetRenamed/Modules/_heapq.cs rename to src/Modules/_heapq.cs diff --git a/Src.GetRenamed/Modules/_multibytecodec.cs b/src/Modules/_multibytecodec.cs similarity index 100% rename from Src.GetRenamed/Modules/_multibytecodec.cs rename to src/Modules/_multibytecodec.cs diff --git a/Src.GetRenamed/Modules/_multiprocessing.cs b/src/Modules/_multiprocessing.cs similarity index 100% rename from Src.GetRenamed/Modules/_multiprocessing.cs rename to src/Modules/_multiprocessing.cs diff --git a/Src.GetRenamed/Modules/_opcode.cs b/src/Modules/_opcode.cs similarity index 100% rename from Src.GetRenamed/Modules/_opcode.cs rename to src/Modules/_opcode.cs diff --git a/Src.GetRenamed/Modules/_operator.cs b/src/Modules/_operator.cs similarity index 100% rename from Src.GetRenamed/Modules/_operator.cs rename to src/Modules/_operator.cs diff --git a/Src.GetRenamed/Modules/_overlapped.cs b/src/Modules/_overlapped.cs similarity index 100% rename from Src.GetRenamed/Modules/_overlapped.cs rename to src/Modules/_overlapped.cs diff --git a/Src.GetRenamed/Modules/_pickle.cs b/src/Modules/_pickle.cs similarity index 100% rename from Src.GetRenamed/Modules/_pickle.cs rename to src/Modules/_pickle.cs diff --git a/Src.GetRenamed/Modules/_posixsubprocess.cs b/src/Modules/_posixsubprocess.cs similarity index 100% rename from Src.GetRenamed/Modules/_posixsubprocess.cs rename to src/Modules/_posixsubprocess.cs diff --git a/Src.GetRenamed/Modules/_random.RandomGen.cs b/src/Modules/_random.RandomGen.cs similarity index 100% rename from Src.GetRenamed/Modules/_random.RandomGen.cs rename to src/Modules/_random.RandomGen.cs diff --git a/Src.GetRenamed/Modules/_random.cs b/src/Modules/_random.cs similarity index 100% rename from Src.GetRenamed/Modules/_random.cs rename to src/Modules/_random.cs diff --git a/Src.GetRenamed/Modules/_socket.cs b/src/Modules/_socket.cs similarity index 100% rename from Src.GetRenamed/Modules/_socket.cs rename to src/Modules/_socket.cs diff --git a/Src.GetRenamed/Modules/_sre.cs b/src/Modules/_sre.cs similarity index 100% rename from Src.GetRenamed/Modules/_sre.cs rename to src/Modules/_sre.cs diff --git a/Src.GetRenamed/Modules/_ssl.cs b/src/Modules/_ssl.cs similarity index 100% rename from Src.GetRenamed/Modules/_ssl.cs rename to src/Modules/_ssl.cs diff --git a/Src.GetRenamed/Modules/_string.cs b/src/Modules/_string.cs similarity index 100% rename from Src.GetRenamed/Modules/_string.cs rename to src/Modules/_string.cs diff --git a/Src.GetRenamed/Modules/_struct.cs b/src/Modules/_struct.cs similarity index 100% rename from Src.GetRenamed/Modules/_struct.cs rename to src/Modules/_struct.cs diff --git a/Src.GetRenamed/Modules/_sysconfigdata.cs b/src/Modules/_sysconfigdata.cs similarity index 100% rename from Src.GetRenamed/Modules/_sysconfigdata.cs rename to src/Modules/_sysconfigdata.cs diff --git a/Src.GetRenamed/Modules/_thread.cs b/src/Modules/_thread.cs similarity index 100% rename from Src.GetRenamed/Modules/_thread.cs rename to src/Modules/_thread.cs diff --git a/Src.GetRenamed/Modules/_warnings.cs b/src/Modules/_warnings.cs similarity index 100% rename from Src.GetRenamed/Modules/_warnings.cs rename to src/Modules/_warnings.cs diff --git a/Src.GetRenamed/Modules/_weakref.Generated.cs b/src/Modules/_weakref.Generated.cs similarity index 100% rename from Src.GetRenamed/Modules/_weakref.Generated.cs rename to src/Modules/_weakref.Generated.cs diff --git a/Src.GetRenamed/Modules/_weakref.cs b/src/Modules/_weakref.cs similarity index 100% rename from Src.GetRenamed/Modules/_weakref.cs rename to src/Modules/_weakref.cs diff --git a/Src.GetRenamed/Modules/_winapi.cs b/src/Modules/_winapi.cs similarity index 100% rename from Src.GetRenamed/Modules/_winapi.cs rename to src/Modules/_winapi.cs diff --git a/Src.GetRenamed/Modules/array.cs b/src/Modules/array.cs similarity index 100% rename from Src.GetRenamed/Modules/array.cs rename to src/Modules/array.cs diff --git a/Src.GetRenamed/Modules/atexit.cs b/src/Modules/atexit.cs similarity index 100% rename from Src.GetRenamed/Modules/atexit.cs rename to src/Modules/atexit.cs diff --git a/Src.GetRenamed/Modules/audioop.cs b/src/Modules/audioop.cs similarity index 100% rename from Src.GetRenamed/Modules/audioop.cs rename to src/Modules/audioop.cs diff --git a/Src.GetRenamed/Modules/binascii.cs b/src/Modules/binascii.cs similarity index 100% rename from Src.GetRenamed/Modules/binascii.cs rename to src/Modules/binascii.cs diff --git a/Src.GetRenamed/Modules/bz2/BZ2Compressor.cs b/src/Modules/bz2/BZ2Compressor.cs similarity index 100% rename from Src.GetRenamed/Modules/bz2/BZ2Compressor.cs rename to src/Modules/bz2/BZ2Compressor.cs diff --git a/Src.GetRenamed/Modules/bz2/BZ2Decompressor.cs b/src/Modules/bz2/BZ2Decompressor.cs similarity index 100% rename from Src.GetRenamed/Modules/bz2/BZ2Decompressor.cs rename to src/Modules/bz2/BZ2Decompressor.cs diff --git a/Src.GetRenamed/Modules/bz2/BZ2Module.cs b/src/Modules/bz2/BZ2Module.cs similarity index 100% rename from Src.GetRenamed/Modules/bz2/BZ2Module.cs rename to src/Modules/bz2/BZ2Module.cs diff --git a/Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs b/src/Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs similarity index 100% rename from Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs rename to src/Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs diff --git a/Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs b/src/Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs similarity index 100% rename from Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs rename to src/Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs diff --git a/Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs b/src/Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs similarity index 100% rename from Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs rename to src/Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs diff --git a/Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/BitWriter.cs b/src/Modules/bz2/dotnetzip/BZip2/BitWriter.cs similarity index 100% rename from Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/BitWriter.cs rename to src/Modules/bz2/dotnetzip/BZip2/BitWriter.cs diff --git a/Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/CRC32.cs b/src/Modules/bz2/dotnetzip/BZip2/CRC32.cs similarity index 100% rename from Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/CRC32.cs rename to src/Modules/bz2/dotnetzip/BZip2/CRC32.cs diff --git a/Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs b/src/Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs similarity index 100% rename from Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs rename to src/Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs diff --git a/Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/Rand.cs b/src/Modules/bz2/dotnetzip/BZip2/Rand.cs similarity index 100% rename from Src.GetRenamed/Modules/bz2/dotnetzip/BZip2/Rand.cs rename to src/Modules/bz2/dotnetzip/BZip2/Rand.cs diff --git a/Src.GetRenamed/Modules/bz2/dotnetzip/source.txt b/src/Modules/bz2/dotnetzip/source.txt similarity index 100% rename from Src.GetRenamed/Modules/bz2/dotnetzip/source.txt rename to src/Modules/bz2/dotnetzip/source.txt diff --git a/Src.GetRenamed/Modules/cmath.cs b/src/Modules/cmath.cs similarity index 100% rename from Src.GetRenamed/Modules/cmath.cs rename to src/Modules/cmath.cs diff --git a/Src.GetRenamed/Modules/errno.cs b/src/Modules/errno.cs similarity index 100% rename from Src.GetRenamed/Modules/errno.cs rename to src/Modules/errno.cs diff --git a/Src.GetRenamed/Modules/faulthandler.cs b/src/Modules/faulthandler.cs similarity index 100% rename from Src.GetRenamed/Modules/faulthandler.cs rename to src/Modules/faulthandler.cs diff --git a/Src.GetRenamed/Modules/fcntl.cs b/src/Modules/fcntl.cs similarity index 100% rename from Src.GetRenamed/Modules/fcntl.cs rename to src/Modules/fcntl.cs diff --git a/Src.GetRenamed/Modules/gc.cs b/src/Modules/gc.cs similarity index 100% rename from Src.GetRenamed/Modules/gc.cs rename to src/Modules/gc.cs diff --git a/Src.GetRenamed/Modules/grp.cs b/src/Modules/grp.cs similarity index 100% rename from Src.GetRenamed/Modules/grp.cs rename to src/Modules/grp.cs diff --git a/Src.GetRenamed/Modules/hashlib/MD5CryptoServiceProvider.cs b/src/Modules/hashlib/MD5CryptoServiceProvider.cs similarity index 100% rename from Src.GetRenamed/Modules/hashlib/MD5CryptoServiceProvider.cs rename to src/Modules/hashlib/MD5CryptoServiceProvider.cs diff --git a/Src.GetRenamed/Modules/hashlib/SHA1CryptoServiceProvider.cs b/src/Modules/hashlib/SHA1CryptoServiceProvider.cs similarity index 100% rename from Src.GetRenamed/Modules/hashlib/SHA1CryptoServiceProvider.cs rename to src/Modules/hashlib/SHA1CryptoServiceProvider.cs diff --git a/Src.GetRenamed/Modules/hashlib/SHA224.cs b/src/Modules/hashlib/SHA224.cs similarity index 100% rename from Src.GetRenamed/Modules/hashlib/SHA224.cs rename to src/Modules/hashlib/SHA224.cs diff --git a/Src.GetRenamed/Modules/hashlib/SHA224Managed.cs b/src/Modules/hashlib/SHA224Managed.cs similarity index 100% rename from Src.GetRenamed/Modules/hashlib/SHA224Managed.cs rename to src/Modules/hashlib/SHA224Managed.cs diff --git a/Src.GetRenamed/Modules/hashlib/SHA256Managed.cs b/src/Modules/hashlib/SHA256Managed.cs similarity index 100% rename from Src.GetRenamed/Modules/hashlib/SHA256Managed.cs rename to src/Modules/hashlib/SHA256Managed.cs diff --git a/Src.GetRenamed/Modules/hashlib/SHA384Managed.cs b/src/Modules/hashlib/SHA384Managed.cs similarity index 100% rename from Src.GetRenamed/Modules/hashlib/SHA384Managed.cs rename to src/Modules/hashlib/SHA384Managed.cs diff --git a/Src.GetRenamed/Modules/hashlib/SHA512Managed.cs b/src/Modules/hashlib/SHA512Managed.cs similarity index 100% rename from Src.GetRenamed/Modules/hashlib/SHA512Managed.cs rename to src/Modules/hashlib/SHA512Managed.cs diff --git a/Src.GetRenamed/Modules/hashlib/SHAConstants.cs b/src/Modules/hashlib/SHAConstants.cs similarity index 100% rename from Src.GetRenamed/Modules/hashlib/SHAConstants.cs rename to src/Modules/hashlib/SHAConstants.cs diff --git a/Src.GetRenamed/Modules/hashlib/_hashlib.cs b/src/Modules/hashlib/_hashlib.cs similarity index 100% rename from Src.GetRenamed/Modules/hashlib/_hashlib.cs rename to src/Modules/hashlib/_hashlib.cs diff --git a/Src.GetRenamed/Modules/hashlib/_md5.cs b/src/Modules/hashlib/_md5.cs similarity index 100% rename from Src.GetRenamed/Modules/hashlib/_md5.cs rename to src/Modules/hashlib/_md5.cs diff --git a/Src.GetRenamed/Modules/hashlib/_sha1.cs b/src/Modules/hashlib/_sha1.cs similarity index 100% rename from Src.GetRenamed/Modules/hashlib/_sha1.cs rename to src/Modules/hashlib/_sha1.cs diff --git a/Src.GetRenamed/Modules/hashlib/_sha256.cs b/src/Modules/hashlib/_sha256.cs similarity index 100% rename from Src.GetRenamed/Modules/hashlib/_sha256.cs rename to src/Modules/hashlib/_sha256.cs diff --git a/Src.GetRenamed/Modules/hashlib/_sha512.cs b/src/Modules/hashlib/_sha512.cs similarity index 100% rename from Src.GetRenamed/Modules/hashlib/_sha512.cs rename to src/Modules/hashlib/_sha512.cs diff --git a/Src.GetRenamed/Modules/marshal.cs b/src/Modules/marshal.cs similarity index 100% rename from Src.GetRenamed/Modules/marshal.cs rename to src/Modules/marshal.cs diff --git a/Src.GetRenamed/Modules/math.Generated.cs b/src/Modules/math.Generated.cs similarity index 100% rename from Src.GetRenamed/Modules/math.Generated.cs rename to src/Modules/math.Generated.cs diff --git a/Src.GetRenamed/Modules/math.cs b/src/Modules/math.cs similarity index 100% rename from Src.GetRenamed/Modules/math.cs rename to src/Modules/math.cs diff --git a/Src.GetRenamed/Modules/mmap.cs b/src/Modules/mmap.cs similarity index 100% rename from Src.GetRenamed/Modules/mmap.cs rename to src/Modules/mmap.cs diff --git a/Src.GetRenamed/Modules/msvcrt.cs b/src/Modules/msvcrt.cs similarity index 100% rename from Src.GetRenamed/Modules/msvcrt.cs rename to src/Modules/msvcrt.cs diff --git a/Src.GetRenamed/Modules/nt.cs b/src/Modules/nt.cs similarity index 100% rename from Src.GetRenamed/Modules/nt.cs rename to src/Modules/nt.cs diff --git a/Src.GetRenamed/Modules/policy.IronPython.Modules.config b/src/Modules/policy.IronPython.Modules.config similarity index 100% rename from Src.GetRenamed/Modules/policy.IronPython.Modules.config rename to src/Modules/policy.IronPython.Modules.config diff --git a/Src.GetRenamed/Modules/pwd.cs b/src/Modules/pwd.cs similarity index 100% rename from Src.GetRenamed/Modules/pwd.cs rename to src/Modules/pwd.cs diff --git a/Src.GetRenamed/Modules/pyexpat.cs b/src/Modules/pyexpat.cs similarity index 100% rename from Src.GetRenamed/Modules/pyexpat.cs rename to src/Modules/pyexpat.cs diff --git a/Src.GetRenamed/Modules/re.cs b/src/Modules/re.cs similarity index 100% rename from Src.GetRenamed/Modules/re.cs rename to src/Modules/re.cs diff --git a/Src.GetRenamed/Modules/resource.cs b/src/Modules/resource.cs similarity index 100% rename from Src.GetRenamed/Modules/resource.cs rename to src/Modules/resource.cs diff --git a/Src.GetRenamed/Modules/select.cs b/src/Modules/select.cs similarity index 100% rename from Src.GetRenamed/Modules/select.cs rename to src/Modules/select.cs diff --git a/Src.GetRenamed/Modules/signal.cs b/src/Modules/signal.cs similarity index 100% rename from Src.GetRenamed/Modules/signal.cs rename to src/Modules/signal.cs diff --git a/Src.GetRenamed/Modules/spwd.cs b/src/Modules/spwd.cs similarity index 100% rename from Src.GetRenamed/Modules/spwd.cs rename to src/Modules/spwd.cs diff --git a/Src.GetRenamed/Modules/time.cs b/src/Modules/time.cs similarity index 100% rename from Src.GetRenamed/Modules/time.cs rename to src/Modules/time.cs diff --git a/Src.GetRenamed/Modules/winreg.cs b/src/Modules/winreg.cs similarity index 100% rename from Src.GetRenamed/Modules/winreg.cs rename to src/Modules/winreg.cs diff --git a/Src.GetRenamed/Modules/winsound.cs b/src/Modules/winsound.cs similarity index 100% rename from Src.GetRenamed/Modules/winsound.cs rename to src/Modules/winsound.cs diff --git a/Src.GetRenamed/Modules/xxsubtype.cs b/src/Modules/xxsubtype.cs similarity index 100% rename from Src.GetRenamed/Modules/xxsubtype.cs rename to src/Modules/xxsubtype.cs diff --git a/Src.GetRenamed/Modules/zipimport.cs b/src/Modules/zipimport.cs similarity index 100% rename from Src.GetRenamed/Modules/zipimport.cs rename to src/Modules/zipimport.cs diff --git a/Src.GetRenamed/Modules/zlib/Compress.cs b/src/Modules/zlib/Compress.cs similarity index 100% rename from Src.GetRenamed/Modules/zlib/Compress.cs rename to src/Modules/zlib/Compress.cs diff --git a/Src.GetRenamed/Modules/zlib/Decompress.cs b/src/Modules/zlib/Decompress.cs similarity index 100% rename from Src.GetRenamed/Modules/zlib/Decompress.cs rename to src/Modules/zlib/Decompress.cs diff --git a/Src.GetRenamed/Modules/zlib/ZlibModule.cs b/src/Modules/zlib/ZlibModule.cs similarity index 100% rename from Src.GetRenamed/Modules/zlib/ZlibModule.cs rename to src/Modules/zlib/ZlibModule.cs diff --git a/Src.GetRenamed/Modules/zlib/zlib.net/Adler32.cs b/src/Modules/zlib/zlib.net/Adler32.cs similarity index 100% rename from Src.GetRenamed/Modules/zlib/zlib.net/Adler32.cs rename to src/Modules/zlib/zlib.net/Adler32.cs diff --git a/Src.GetRenamed/Modules/zlib/zlib.net/Deflate.cs b/src/Modules/zlib/zlib.net/Deflate.cs similarity index 100% rename from Src.GetRenamed/Modules/zlib/zlib.net/Deflate.cs rename to src/Modules/zlib/zlib.net/Deflate.cs diff --git a/Src.GetRenamed/Modules/zlib/zlib.net/InfBlocks.cs b/src/Modules/zlib/zlib.net/InfBlocks.cs similarity index 100% rename from Src.GetRenamed/Modules/zlib/zlib.net/InfBlocks.cs rename to src/Modules/zlib/zlib.net/InfBlocks.cs diff --git a/Src.GetRenamed/Modules/zlib/zlib.net/InfCodes.cs b/src/Modules/zlib/zlib.net/InfCodes.cs similarity index 100% rename from Src.GetRenamed/Modules/zlib/zlib.net/InfCodes.cs rename to src/Modules/zlib/zlib.net/InfCodes.cs diff --git a/Src.GetRenamed/Modules/zlib/zlib.net/InfTree.cs b/src/Modules/zlib/zlib.net/InfTree.cs similarity index 100% rename from Src.GetRenamed/Modules/zlib/zlib.net/InfTree.cs rename to src/Modules/zlib/zlib.net/InfTree.cs diff --git a/Src.GetRenamed/Modules/zlib/zlib.net/Inflate.cs b/src/Modules/zlib/zlib.net/Inflate.cs similarity index 100% rename from Src.GetRenamed/Modules/zlib/zlib.net/Inflate.cs rename to src/Modules/zlib/zlib.net/Inflate.cs diff --git a/Src.GetRenamed/Modules/zlib/zlib.net/StaticTree.cs b/src/Modules/zlib/zlib.net/StaticTree.cs similarity index 100% rename from Src.GetRenamed/Modules/zlib/zlib.net/StaticTree.cs rename to src/Modules/zlib/zlib.net/StaticTree.cs diff --git a/Src.GetRenamed/Modules/zlib/zlib.net/Tree.cs b/src/Modules/zlib/zlib.net/Tree.cs similarity index 100% rename from Src.GetRenamed/Modules/zlib/zlib.net/Tree.cs rename to src/Modules/zlib/zlib.net/Tree.cs diff --git a/Src.GetRenamed/Modules/zlib/zlib.net/ZStream.cs b/src/Modules/zlib/zlib.net/ZStream.cs similarity index 100% rename from Src.GetRenamed/Modules/zlib/zlib.net/ZStream.cs rename to src/Modules/zlib/zlib.net/ZStream.cs diff --git a/Src.GetRenamed/Modules/zlib/zlib.net/ZStreamException.cs b/src/Modules/zlib/zlib.net/ZStreamException.cs similarity index 100% rename from Src.GetRenamed/Modules/zlib/zlib.net/ZStreamException.cs rename to src/Modules/zlib/zlib.net/ZStreamException.cs diff --git a/Src.GetRenamed/Modules/zlib/zlib.net/Zlib.cs b/src/Modules/zlib/zlib.net/Zlib.cs similarity index 100% rename from Src.GetRenamed/Modules/zlib/zlib.net/Zlib.cs rename to src/Modules/zlib/zlib.net/Zlib.cs diff --git a/Src.GetRenamed/Modules/zlib/zlib.net/history.txt b/src/Modules/zlib/zlib.net/history.txt similarity index 100% rename from Src.GetRenamed/Modules/zlib/zlib.net/history.txt rename to src/Modules/zlib/zlib.net/history.txt diff --git a/Src.GetRenamed/Modules/zlib/zlib.net/license.txt b/src/Modules/zlib/zlib.net/license.txt similarity index 100% rename from Src.GetRenamed/Modules/zlib/zlib.net/license.txt rename to src/Modules/zlib/zlib.net/license.txt diff --git a/Src.GetRenamed/Modules/zlib/zlib.net/readme.txt b/src/Modules/zlib/zlib.net/readme.txt similarity index 100% rename from Src.GetRenamed/Modules/zlib/zlib.net/readme.txt rename to src/Modules/zlib/zlib.net/readme.txt diff --git a/Src.GetRenamed/README.md b/src/README.md similarity index 100% rename from Src.GetRenamed/README.md rename to src/README.md diff --git a/Src.GetRenamed/SQLite/Connection.cs b/src/SQLite/Connection.cs similarity index 100% rename from Src.GetRenamed/SQLite/Connection.cs rename to src/SQLite/Connection.cs diff --git a/Src.GetRenamed/SQLite/Contants.cs b/src/SQLite/Contants.cs similarity index 100% rename from Src.GetRenamed/SQLite/Contants.cs rename to src/SQLite/Contants.cs diff --git a/Src.GetRenamed/SQLite/Cursor.cs b/src/SQLite/Cursor.cs similarity index 100% rename from Src.GetRenamed/SQLite/Cursor.cs rename to src/SQLite/Cursor.cs diff --git a/Src.GetRenamed/SQLite/Exceptions.cs b/src/SQLite/Exceptions.cs similarity index 100% rename from Src.GetRenamed/SQLite/Exceptions.cs rename to src/SQLite/Exceptions.cs diff --git a/Src.GetRenamed/SQLite/Extensions.cs b/src/SQLite/Extensions.cs similarity index 100% rename from Src.GetRenamed/SQLite/Extensions.cs rename to src/SQLite/Extensions.cs diff --git a/Src.GetRenamed/SQLite/IronPython.SQLite.csproj b/src/SQLite/IronPython.SQLite.csproj similarity index 100% rename from Src.GetRenamed/SQLite/IronPython.SQLite.csproj rename to src/SQLite/IronPython.SQLite.csproj diff --git a/Src.GetRenamed/SQLite/Properties/AssemblyInfo.cs b/src/SQLite/Properties/AssemblyInfo.cs similarity index 100% rename from Src.GetRenamed/SQLite/Properties/AssemblyInfo.cs rename to src/SQLite/Properties/AssemblyInfo.cs diff --git a/Src.GetRenamed/SQLite/Row.cs b/src/SQLite/Row.cs similarity index 100% rename from Src.GetRenamed/SQLite/Row.cs rename to src/SQLite/Row.cs diff --git a/Src.GetRenamed/SQLite/Statement.cs b/src/SQLite/Statement.cs similarity index 100% rename from Src.GetRenamed/SQLite/Statement.cs rename to src/SQLite/Statement.cs diff --git a/Src.GetRenamed/SQLite/Util.cs b/src/SQLite/Util.cs similarity index 100% rename from Src.GetRenamed/SQLite/Util.cs rename to src/SQLite/Util.cs diff --git a/Src.GetRenamed/SQLite/_sqlite.cs b/src/SQLite/_sqlite.cs similarity index 100% rename from Src.GetRenamed/SQLite/_sqlite.cs rename to src/SQLite/_sqlite.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/.editorconfig b/src/SQLite/c#sqlite/.editorconfig similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/.editorconfig rename to src/SQLite/c#sqlite/.editorconfig diff --git a/Src.GetRenamed/SQLite/c#sqlite/BtreeInt_h.cs b/src/SQLite/c#sqlite/BtreeInt_h.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/BtreeInt_h.cs rename to src/SQLite/c#sqlite/BtreeInt_h.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/Btree_h.cs b/src/SQLite/c#sqlite/Btree_h.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/Btree_h.cs rename to src/SQLite/c#sqlite/Btree_h.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/Delegates.cs b/src/SQLite/c#sqlite/Delegates.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/Delegates.cs rename to src/SQLite/c#sqlite/Delegates.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/Hash_h.cs b/src/SQLite/c#sqlite/Hash_h.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/Hash_h.cs rename to src/SQLite/c#sqlite/Hash_h.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/VdbeInt_h.cs b/src/SQLite/c#sqlite/VdbeInt_h.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/VdbeInt_h.cs rename to src/SQLite/c#sqlite/VdbeInt_h.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/Vdbe_h.cs b/src/SQLite/c#sqlite/Vdbe_h.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/Vdbe_h.cs rename to src/SQLite/c#sqlite/Vdbe_h.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/_Custom.cs b/src/SQLite/c#sqlite/_Custom.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/_Custom.cs rename to src/SQLite/c#sqlite/_Custom.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/alter_c.cs b/src/SQLite/c#sqlite/alter_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/alter_c.cs rename to src/SQLite/c#sqlite/alter_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/analyze_c.cs b/src/SQLite/c#sqlite/analyze_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/analyze_c.cs rename to src/SQLite/c#sqlite/analyze_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/attach_c.cs b/src/SQLite/c#sqlite/attach_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/attach_c.cs rename to src/SQLite/c#sqlite/attach_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/auth_c.cs b/src/SQLite/c#sqlite/auth_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/auth_c.cs rename to src/SQLite/c#sqlite/auth_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/backup_c.cs b/src/SQLite/c#sqlite/backup_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/backup_c.cs rename to src/SQLite/c#sqlite/backup_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/bitvec_c.cs b/src/SQLite/c#sqlite/bitvec_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/bitvec_c.cs rename to src/SQLite/c#sqlite/bitvec_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/btmutex_c.cs b/src/SQLite/c#sqlite/btmutex_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/btmutex_c.cs rename to src/SQLite/c#sqlite/btmutex_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/btree_c.cs b/src/SQLite/c#sqlite/btree_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/btree_c.cs rename to src/SQLite/c#sqlite/btree_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/build_c.cs b/src/SQLite/c#sqlite/build_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/build_c.cs rename to src/SQLite/c#sqlite/build_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/callback_c.cs b/src/SQLite/c#sqlite/callback_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/callback_c.cs rename to src/SQLite/c#sqlite/callback_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/complete_c.cs b/src/SQLite/c#sqlite/complete_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/complete_c.cs rename to src/SQLite/c#sqlite/complete_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/crypto.cs b/src/SQLite/c#sqlite/crypto.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/crypto.cs rename to src/SQLite/c#sqlite/crypto.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/ctime_c.cs b/src/SQLite/c#sqlite/ctime_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/ctime_c.cs rename to src/SQLite/c#sqlite/ctime_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/date_c.cs b/src/SQLite/c#sqlite/date_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/date_c.cs rename to src/SQLite/c#sqlite/date_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/delete_c.cs b/src/SQLite/c#sqlite/delete_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/delete_c.cs rename to src/SQLite/c#sqlite/delete_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/expr_c.cs b/src/SQLite/c#sqlite/expr_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/expr_c.cs rename to src/SQLite/c#sqlite/expr_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/fault_c.cs b/src/SQLite/c#sqlite/fault_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/fault_c.cs rename to src/SQLite/c#sqlite/fault_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/fkey_c.cs b/src/SQLite/c#sqlite/fkey_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/fkey_c.cs rename to src/SQLite/c#sqlite/fkey_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/func_c.cs b/src/SQLite/c#sqlite/func_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/func_c.cs rename to src/SQLite/c#sqlite/func_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/global_c.cs b/src/SQLite/c#sqlite/global_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/global_c.cs rename to src/SQLite/c#sqlite/global_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/hash_c.cs b/src/SQLite/c#sqlite/hash_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/hash_c.cs rename to src/SQLite/c#sqlite/hash_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/hwtime_c.cs b/src/SQLite/c#sqlite/hwtime_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/hwtime_c.cs rename to src/SQLite/c#sqlite/hwtime_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/insert_c.cs b/src/SQLite/c#sqlite/insert_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/insert_c.cs rename to src/SQLite/c#sqlite/insert_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/journal_c.cs b/src/SQLite/c#sqlite/journal_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/journal_c.cs rename to src/SQLite/c#sqlite/journal_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/keywordhash_h.cs b/src/SQLite/c#sqlite/keywordhash_h.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/keywordhash_h.cs rename to src/SQLite/c#sqlite/keywordhash_h.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/legacy_c.cs b/src/SQLite/c#sqlite/legacy_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/legacy_c.cs rename to src/SQLite/c#sqlite/legacy_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/loadext_c.cs b/src/SQLite/c#sqlite/loadext_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/loadext_c.cs rename to src/SQLite/c#sqlite/loadext_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/main_c.cs b/src/SQLite/c#sqlite/main_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/main_c.cs rename to src/SQLite/c#sqlite/main_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/malloc_c.cs b/src/SQLite/c#sqlite/malloc_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/malloc_c.cs rename to src/SQLite/c#sqlite/malloc_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/mem_Pool.cs b/src/SQLite/c#sqlite/mem_Pool.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/mem_Pool.cs rename to src/SQLite/c#sqlite/mem_Pool.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/memjournal_c.cs b/src/SQLite/c#sqlite/memjournal_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/memjournal_c.cs rename to src/SQLite/c#sqlite/memjournal_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/mutex_c.cs b/src/SQLite/c#sqlite/mutex_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/mutex_c.cs rename to src/SQLite/c#sqlite/mutex_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/mutex_h.cs b/src/SQLite/c#sqlite/mutex_h.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/mutex_h.cs rename to src/SQLite/c#sqlite/mutex_h.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/mutex_noop_c.cs b/src/SQLite/c#sqlite/mutex_noop_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/mutex_noop_c.cs rename to src/SQLite/c#sqlite/mutex_noop_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/mutex_w32.cs b/src/SQLite/c#sqlite/mutex_w32.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/mutex_w32.cs rename to src/SQLite/c#sqlite/mutex_w32.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/notify_c.cs b/src/SQLite/c#sqlite/notify_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/notify_c.cs rename to src/SQLite/c#sqlite/notify_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/opcodes_c.cs b/src/SQLite/c#sqlite/opcodes_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/opcodes_c.cs rename to src/SQLite/c#sqlite/opcodes_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/opcodes_h.cs b/src/SQLite/c#sqlite/opcodes_h.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/opcodes_h.cs rename to src/SQLite/c#sqlite/opcodes_h.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/os_c.cs b/src/SQLite/c#sqlite/os_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/os_c.cs rename to src/SQLite/c#sqlite/os_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/os_common_h.cs b/src/SQLite/c#sqlite/os_common_h.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/os_common_h.cs rename to src/SQLite/c#sqlite/os_common_h.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/os_h.cs b/src/SQLite/c#sqlite/os_h.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/os_h.cs rename to src/SQLite/c#sqlite/os_h.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/os_win_c.cs b/src/SQLite/c#sqlite/os_win_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/os_win_c.cs rename to src/SQLite/c#sqlite/os_win_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/pager_c.cs b/src/SQLite/c#sqlite/pager_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/pager_c.cs rename to src/SQLite/c#sqlite/pager_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/pager_h.cs b/src/SQLite/c#sqlite/pager_h.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/pager_h.cs rename to src/SQLite/c#sqlite/pager_h.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/parse_c.cs b/src/SQLite/c#sqlite/parse_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/parse_c.cs rename to src/SQLite/c#sqlite/parse_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/parse_h.cs b/src/SQLite/c#sqlite/parse_h.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/parse_h.cs rename to src/SQLite/c#sqlite/parse_h.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/pcache1_c.cs b/src/SQLite/c#sqlite/pcache1_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/pcache1_c.cs rename to src/SQLite/c#sqlite/pcache1_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/pcache_c.cs b/src/SQLite/c#sqlite/pcache_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/pcache_c.cs rename to src/SQLite/c#sqlite/pcache_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/pcache_h.cs b/src/SQLite/c#sqlite/pcache_h.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/pcache_h.cs rename to src/SQLite/c#sqlite/pcache_h.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/pragma_c.cs b/src/SQLite/c#sqlite/pragma_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/pragma_c.cs rename to src/SQLite/c#sqlite/pragma_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/prepare_c.cs b/src/SQLite/c#sqlite/prepare_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/prepare_c.cs rename to src/SQLite/c#sqlite/prepare_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/printf_c.cs b/src/SQLite/c#sqlite/printf_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/printf_c.cs rename to src/SQLite/c#sqlite/printf_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/random_c.cs b/src/SQLite/c#sqlite/random_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/random_c.cs rename to src/SQLite/c#sqlite/random_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/resolve_c.cs b/src/SQLite/c#sqlite/resolve_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/resolve_c.cs rename to src/SQLite/c#sqlite/resolve_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/rowset_c.cs b/src/SQLite/c#sqlite/rowset_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/rowset_c.cs rename to src/SQLite/c#sqlite/rowset_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/select_c.cs b/src/SQLite/c#sqlite/select_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/select_c.cs rename to src/SQLite/c#sqlite/select_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/sqlite3_h.cs b/src/SQLite/c#sqlite/sqlite3_h.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/sqlite3_h.cs rename to src/SQLite/c#sqlite/sqlite3_h.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/sqliteInt_h.cs b/src/SQLite/c#sqlite/sqliteInt_h.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/sqliteInt_h.cs rename to src/SQLite/c#sqlite/sqliteInt_h.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/sqliteLimit_h.cs b/src/SQLite/c#sqlite/sqliteLimit_h.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/sqliteLimit_h.cs rename to src/SQLite/c#sqlite/sqliteLimit_h.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/status_c.cs b/src/SQLite/c#sqlite/status_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/status_c.cs rename to src/SQLite/c#sqlite/status_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/table_c.cs b/src/SQLite/c#sqlite/table_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/table_c.cs rename to src/SQLite/c#sqlite/table_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/tokenize_c.cs b/src/SQLite/c#sqlite/tokenize_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/tokenize_c.cs rename to src/SQLite/c#sqlite/tokenize_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/trigger_c.cs b/src/SQLite/c#sqlite/trigger_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/trigger_c.cs rename to src/SQLite/c#sqlite/trigger_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/update_c.cs b/src/SQLite/c#sqlite/update_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/update_c.cs rename to src/SQLite/c#sqlite/update_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/utf_c.cs b/src/SQLite/c#sqlite/utf_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/utf_c.cs rename to src/SQLite/c#sqlite/utf_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/util_c.cs b/src/SQLite/c#sqlite/util_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/util_c.cs rename to src/SQLite/c#sqlite/util_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/vacuum_c.cs b/src/SQLite/c#sqlite/vacuum_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/vacuum_c.cs rename to src/SQLite/c#sqlite/vacuum_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/vdbe_c.cs b/src/SQLite/c#sqlite/vdbe_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/vdbe_c.cs rename to src/SQLite/c#sqlite/vdbe_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/vdbeapi_c.cs b/src/SQLite/c#sqlite/vdbeapi_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/vdbeapi_c.cs rename to src/SQLite/c#sqlite/vdbeapi_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/vdbeaux_c.cs b/src/SQLite/c#sqlite/vdbeaux_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/vdbeaux_c.cs rename to src/SQLite/c#sqlite/vdbeaux_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/vdbeblob_c.cs b/src/SQLite/c#sqlite/vdbeblob_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/vdbeblob_c.cs rename to src/SQLite/c#sqlite/vdbeblob_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/vdbemem_c.cs b/src/SQLite/c#sqlite/vdbemem_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/vdbemem_c.cs rename to src/SQLite/c#sqlite/vdbemem_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/vdbetrace_c.cs b/src/SQLite/c#sqlite/vdbetrace_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/vdbetrace_c.cs rename to src/SQLite/c#sqlite/vdbetrace_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/vtab_c.cs b/src/SQLite/c#sqlite/vtab_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/vtab_c.cs rename to src/SQLite/c#sqlite/vtab_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/wal_c.cs b/src/SQLite/c#sqlite/wal_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/wal_c.cs rename to src/SQLite/c#sqlite/wal_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/wal_h.cs b/src/SQLite/c#sqlite/wal_h.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/wal_h.cs rename to src/SQLite/c#sqlite/wal_h.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/walker_c.cs b/src/SQLite/c#sqlite/walker_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/walker_c.cs rename to src/SQLite/c#sqlite/walker_c.cs diff --git a/Src.GetRenamed/SQLite/c#sqlite/where_c.cs b/src/SQLite/c#sqlite/where_c.cs similarity index 100% rename from Src.GetRenamed/SQLite/c#sqlite/where_c.cs rename to src/SQLite/c#sqlite/where_c.cs diff --git a/Src.GetRenamed/Scripts/CompareDirs.py b/src/Scripts/CompareDirs.py similarity index 100% rename from Src.GetRenamed/Scripts/CompareDirs.py rename to src/Scripts/CompareDirs.py diff --git a/Src.GetRenamed/Scripts/Enter-IronPythonEnvironment.ps1 b/src/Scripts/Enter-IronPythonEnvironment.ps1 similarity index 100% rename from Src.GetRenamed/Scripts/Enter-IronPythonEnvironment.ps1 rename to src/Scripts/Enter-IronPythonEnvironment.ps1 diff --git a/Src.GetRenamed/Scripts/Install-IronPython.ps1 b/src/Scripts/Install-IronPython.ps1 similarity index 100% rename from Src.GetRenamed/Scripts/Install-IronPython.ps1 rename to src/Scripts/Install-IronPython.ps1 diff --git a/Src.GetRenamed/Scripts/clean.py b/src/Scripts/clean.py similarity index 100% rename from Src.GetRenamed/Scripts/clean.py rename to src/Scripts/clean.py diff --git a/Src.GetRenamed/Scripts/copyrights.py b/src/Scripts/copyrights.py similarity index 100% rename from Src.GetRenamed/Scripts/copyrights.py rename to src/Scripts/copyrights.py diff --git a/Src.GetRenamed/Scripts/generate.py b/src/Scripts/generate.py similarity index 100% rename from Src.GetRenamed/Scripts/generate.py rename to src/Scripts/generate.py diff --git a/Src.GetRenamed/Scripts/generate_UncollectableCompilationMode.py b/src/Scripts/generate_UncollectableCompilationMode.py similarity index 100% rename from Src.GetRenamed/Scripts/generate_UncollectableCompilationMode.py rename to src/Scripts/generate_UncollectableCompilationMode.py diff --git a/Src.GetRenamed/Scripts/generate_alltypes.py b/src/Scripts/generate_alltypes.py similarity index 100% rename from Src.GetRenamed/Scripts/generate_alltypes.py rename to src/Scripts/generate_alltypes.py diff --git a/Src.GetRenamed/Scripts/generate_calls.py b/src/Scripts/generate_calls.py similarity index 100% rename from Src.GetRenamed/Scripts/generate_calls.py rename to src/Scripts/generate_calls.py diff --git a/Src.GetRenamed/Scripts/generate_casts.py b/src/Scripts/generate_casts.py similarity index 100% rename from Src.GetRenamed/Scripts/generate_casts.py rename to src/Scripts/generate_casts.py diff --git a/Src.GetRenamed/Scripts/generate_comdispatch.py b/src/Scripts/generate_comdispatch.py similarity index 100% rename from Src.GetRenamed/Scripts/generate_comdispatch.py rename to src/Scripts/generate_comdispatch.py diff --git a/Src.GetRenamed/Scripts/generate_dict_views.py b/src/Scripts/generate_dict_views.py similarity index 100% rename from Src.GetRenamed/Scripts/generate_dict_views.py rename to src/Scripts/generate_dict_views.py diff --git a/Src.GetRenamed/Scripts/generate_dynamic_instructions.py b/src/Scripts/generate_dynamic_instructions.py similarity index 100% rename from Src.GetRenamed/Scripts/generate_dynamic_instructions.py rename to src/Scripts/generate_dynamic_instructions.py diff --git a/Src.GetRenamed/Scripts/generate_dynsites.py b/src/Scripts/generate_dynsites.py similarity index 100% rename from Src.GetRenamed/Scripts/generate_dynsites.py rename to src/Scripts/generate_dynsites.py diff --git a/Src.GetRenamed/Scripts/generate_encoding_aliases.py b/src/Scripts/generate_encoding_aliases.py similarity index 100% rename from Src.GetRenamed/Scripts/generate_encoding_aliases.py rename to src/Scripts/generate_encoding_aliases.py diff --git a/Src.GetRenamed/Scripts/generate_exception_factory.py b/src/Scripts/generate_exception_factory.py similarity index 100% rename from Src.GetRenamed/Scripts/generate_exception_factory.py rename to src/Scripts/generate_exception_factory.py diff --git a/Src.GetRenamed/Scripts/generate_exceptions.py b/src/Scripts/generate_exceptions.py similarity index 100% rename from Src.GetRenamed/Scripts/generate_exceptions.py rename to src/Scripts/generate_exceptions.py diff --git a/Src.GetRenamed/Scripts/generate_indicestest.py b/src/Scripts/generate_indicestest.py similarity index 100% rename from Src.GetRenamed/Scripts/generate_indicestest.py rename to src/Scripts/generate_indicestest.py diff --git a/Src.GetRenamed/Scripts/generate_math.py b/src/Scripts/generate_math.py similarity index 100% rename from Src.GetRenamed/Scripts/generate_math.py rename to src/Scripts/generate_math.py diff --git a/Src.GetRenamed/Scripts/generate_ops.py b/src/Scripts/generate_ops.py similarity index 100% rename from Src.GetRenamed/Scripts/generate_ops.py rename to src/Scripts/generate_ops.py diff --git a/Src.GetRenamed/Scripts/generate_os_codes.py b/src/Scripts/generate_os_codes.py similarity index 100% rename from Src.GetRenamed/Scripts/generate_os_codes.py rename to src/Scripts/generate_os_codes.py diff --git a/Src.GetRenamed/Scripts/generate_reflected_calls.py b/src/Scripts/generate_reflected_calls.py similarity index 100% rename from Src.GetRenamed/Scripts/generate_reflected_calls.py rename to src/Scripts/generate_reflected_calls.py diff --git a/Src.GetRenamed/Scripts/generate_set.py b/src/Scripts/generate_set.py similarity index 100% rename from Src.GetRenamed/Scripts/generate_set.py rename to src/Scripts/generate_set.py diff --git a/Src.GetRenamed/Scripts/generate_tuples.py b/src/Scripts/generate_tuples.py similarity index 100% rename from Src.GetRenamed/Scripts/generate_tuples.py rename to src/Scripts/generate_tuples.py diff --git a/Src.GetRenamed/Scripts/generate_typecache.py b/src/Scripts/generate_typecache.py similarity index 100% rename from Src.GetRenamed/Scripts/generate_typecache.py rename to src/Scripts/generate_typecache.py diff --git a/Src.GetRenamed/Scripts/generate_walker.py b/src/Scripts/generate_walker.py similarity index 100% rename from Src.GetRenamed/Scripts/generate_walker.py rename to src/Scripts/generate_walker.py diff --git a/Src.GetRenamed/Scripts/ipcom.ps1 b/src/Scripts/ipcom.ps1 similarity index 100% rename from Src.GetRenamed/Scripts/ipcom.ps1 rename to src/Scripts/ipcom.ps1 diff --git a/Src.GetRenamed/Scripts/make_meta1.py b/src/Scripts/make_meta1.py similarity index 100% rename from Src.GetRenamed/Scripts/make_meta1.py rename to src/Scripts/make_meta1.py diff --git a/Src.GetRenamed/Scripts/radix_generator.py b/src/Scripts/radix_generator.py similarity index 100% rename from Src.GetRenamed/Scripts/radix_generator.py rename to src/Scripts/radix_generator.py diff --git a/Src.GetRenamed/Scripts/run_compiled.py b/src/Scripts/run_compiled.py similarity index 100% rename from Src.GetRenamed/Scripts/run_compiled.py rename to src/Scripts/run_compiled.py diff --git a/Src.GetRenamed/Scripts/run_interactive.py b/src/Scripts/run_interactive.py similarity index 100% rename from Src.GetRenamed/Scripts/run_interactive.py rename to src/Scripts/run_interactive.py diff --git a/Src.GetRenamed/Scripts/smtpmailer.py b/src/Scripts/smtpmailer.py similarity index 100% rename from Src.GetRenamed/Scripts/smtpmailer.py rename to src/Scripts/smtpmailer.py diff --git a/Src.GetRenamed/Scripts/test_builder.py b/src/Scripts/test_builder.py similarity index 100% rename from Src.GetRenamed/Scripts/test_builder.py rename to src/Scripts/test_builder.py diff --git a/Src.GetRenamed/Scripts/test_cgcheck.py b/src/Scripts/test_cgcheck.py similarity index 100% rename from Src.GetRenamed/Scripts/test_cgcheck.py rename to src/Scripts/test_cgcheck.py diff --git a/Src.GetRenamed/Scripts/test_parrot.py b/src/Scripts/test_parrot.py similarity index 100% rename from Src.GetRenamed/Scripts/test_parrot.py rename to src/Scripts/test_parrot.py diff --git a/Src.GetRenamed/Scripts/test_pystone.py b/src/Scripts/test_pystone.py similarity index 100% rename from Src.GetRenamed/Scripts/test_pystone.py rename to src/Scripts/test_pystone.py diff --git a/Src.GetRenamed/StdLib/.gitattributes b/src/StdLib/.gitattributes similarity index 100% rename from Src.GetRenamed/StdLib/.gitattributes rename to src/StdLib/.gitattributes diff --git a/Src.GetRenamed/StdLib/Lib/__future__.py b/src/StdLib/Lib/__future__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/__future__.py rename to src/StdLib/Lib/__future__.py diff --git a/Src.GetRenamed/StdLib/Lib/__phello__.foo.py b/src/StdLib/Lib/__phello__.foo.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/__phello__.foo.py rename to src/StdLib/Lib/__phello__.foo.py diff --git a/Src.GetRenamed/StdLib/Lib/_bootlocale.py b/src/StdLib/Lib/_bootlocale.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/_bootlocale.py rename to src/StdLib/Lib/_bootlocale.py diff --git a/Src.GetRenamed/StdLib/Lib/_collections_abc.py b/src/StdLib/Lib/_collections_abc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/_collections_abc.py rename to src/StdLib/Lib/_collections_abc.py diff --git a/Src.GetRenamed/StdLib/Lib/_compat_pickle.py b/src/StdLib/Lib/_compat_pickle.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/_compat_pickle.py rename to src/StdLib/Lib/_compat_pickle.py diff --git a/Src.GetRenamed/StdLib/Lib/_dummy_thread.py b/src/StdLib/Lib/_dummy_thread.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/_dummy_thread.py rename to src/StdLib/Lib/_dummy_thread.py diff --git a/Src.GetRenamed/StdLib/Lib/_markupbase.py b/src/StdLib/Lib/_markupbase.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/_markupbase.py rename to src/StdLib/Lib/_markupbase.py diff --git a/Src.GetRenamed/StdLib/Lib/_osx_support.py b/src/StdLib/Lib/_osx_support.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/_osx_support.py rename to src/StdLib/Lib/_osx_support.py diff --git a/Src.GetRenamed/StdLib/Lib/_pyio.py b/src/StdLib/Lib/_pyio.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/_pyio.py rename to src/StdLib/Lib/_pyio.py diff --git a/Src.GetRenamed/StdLib/Lib/_sitebuiltins.py b/src/StdLib/Lib/_sitebuiltins.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/_sitebuiltins.py rename to src/StdLib/Lib/_sitebuiltins.py diff --git a/Src.GetRenamed/StdLib/Lib/_strptime.py b/src/StdLib/Lib/_strptime.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/_strptime.py rename to src/StdLib/Lib/_strptime.py diff --git a/Src.GetRenamed/StdLib/Lib/_threading_local.py b/src/StdLib/Lib/_threading_local.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/_threading_local.py rename to src/StdLib/Lib/_threading_local.py diff --git a/Src.GetRenamed/StdLib/Lib/_weakrefset.py b/src/StdLib/Lib/_weakrefset.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/_weakrefset.py rename to src/StdLib/Lib/_weakrefset.py diff --git a/Src.GetRenamed/StdLib/Lib/abc.py b/src/StdLib/Lib/abc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/abc.py rename to src/StdLib/Lib/abc.py diff --git a/Src.GetRenamed/StdLib/Lib/aifc.py b/src/StdLib/Lib/aifc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/aifc.py rename to src/StdLib/Lib/aifc.py diff --git a/Src.GetRenamed/StdLib/Lib/antigravity.py b/src/StdLib/Lib/antigravity.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/antigravity.py rename to src/StdLib/Lib/antigravity.py diff --git a/Src.GetRenamed/StdLib/Lib/argparse.py b/src/StdLib/Lib/argparse.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/argparse.py rename to src/StdLib/Lib/argparse.py diff --git a/Src.GetRenamed/StdLib/Lib/ast.py b/src/StdLib/Lib/ast.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ast.py rename to src/StdLib/Lib/ast.py diff --git a/Src.GetRenamed/StdLib/Lib/asynchat.py b/src/StdLib/Lib/asynchat.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asynchat.py rename to src/StdLib/Lib/asynchat.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/__init__.py b/src/StdLib/Lib/asyncio/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/__init__.py rename to src/StdLib/Lib/asyncio/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/base_events.py b/src/StdLib/Lib/asyncio/base_events.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/base_events.py rename to src/StdLib/Lib/asyncio/base_events.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/base_subprocess.py b/src/StdLib/Lib/asyncio/base_subprocess.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/base_subprocess.py rename to src/StdLib/Lib/asyncio/base_subprocess.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/compat.py b/src/StdLib/Lib/asyncio/compat.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/compat.py rename to src/StdLib/Lib/asyncio/compat.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/constants.py b/src/StdLib/Lib/asyncio/constants.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/constants.py rename to src/StdLib/Lib/asyncio/constants.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/coroutines.py b/src/StdLib/Lib/asyncio/coroutines.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/coroutines.py rename to src/StdLib/Lib/asyncio/coroutines.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/events.py b/src/StdLib/Lib/asyncio/events.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/events.py rename to src/StdLib/Lib/asyncio/events.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/futures.py b/src/StdLib/Lib/asyncio/futures.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/futures.py rename to src/StdLib/Lib/asyncio/futures.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/locks.py b/src/StdLib/Lib/asyncio/locks.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/locks.py rename to src/StdLib/Lib/asyncio/locks.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/log.py b/src/StdLib/Lib/asyncio/log.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/log.py rename to src/StdLib/Lib/asyncio/log.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/proactor_events.py b/src/StdLib/Lib/asyncio/proactor_events.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/proactor_events.py rename to src/StdLib/Lib/asyncio/proactor_events.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/protocols.py b/src/StdLib/Lib/asyncio/protocols.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/protocols.py rename to src/StdLib/Lib/asyncio/protocols.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/queues.py b/src/StdLib/Lib/asyncio/queues.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/queues.py rename to src/StdLib/Lib/asyncio/queues.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/selector_events.py b/src/StdLib/Lib/asyncio/selector_events.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/selector_events.py rename to src/StdLib/Lib/asyncio/selector_events.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/sslproto.py b/src/StdLib/Lib/asyncio/sslproto.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/sslproto.py rename to src/StdLib/Lib/asyncio/sslproto.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/streams.py b/src/StdLib/Lib/asyncio/streams.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/streams.py rename to src/StdLib/Lib/asyncio/streams.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/subprocess.py b/src/StdLib/Lib/asyncio/subprocess.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/subprocess.py rename to src/StdLib/Lib/asyncio/subprocess.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/tasks.py b/src/StdLib/Lib/asyncio/tasks.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/tasks.py rename to src/StdLib/Lib/asyncio/tasks.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/test_utils.py b/src/StdLib/Lib/asyncio/test_utils.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/test_utils.py rename to src/StdLib/Lib/asyncio/test_utils.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/transports.py b/src/StdLib/Lib/asyncio/transports.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/transports.py rename to src/StdLib/Lib/asyncio/transports.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/unix_events.py b/src/StdLib/Lib/asyncio/unix_events.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/unix_events.py rename to src/StdLib/Lib/asyncio/unix_events.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/windows_events.py b/src/StdLib/Lib/asyncio/windows_events.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/windows_events.py rename to src/StdLib/Lib/asyncio/windows_events.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncio/windows_utils.py b/src/StdLib/Lib/asyncio/windows_utils.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncio/windows_utils.py rename to src/StdLib/Lib/asyncio/windows_utils.py diff --git a/Src.GetRenamed/StdLib/Lib/asyncore.py b/src/StdLib/Lib/asyncore.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/asyncore.py rename to src/StdLib/Lib/asyncore.py diff --git a/Src.GetRenamed/StdLib/Lib/base64.py b/src/StdLib/Lib/base64.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/base64.py rename to src/StdLib/Lib/base64.py diff --git a/Src.GetRenamed/StdLib/Lib/bdb.py b/src/StdLib/Lib/bdb.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/bdb.py rename to src/StdLib/Lib/bdb.py diff --git a/Src.GetRenamed/StdLib/Lib/binhex.py b/src/StdLib/Lib/binhex.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/binhex.py rename to src/StdLib/Lib/binhex.py diff --git a/Src.GetRenamed/StdLib/Lib/bisect.py b/src/StdLib/Lib/bisect.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/bisect.py rename to src/StdLib/Lib/bisect.py diff --git a/Src.GetRenamed/StdLib/Lib/bz2.py b/src/StdLib/Lib/bz2.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/bz2.py rename to src/StdLib/Lib/bz2.py diff --git a/Src.GetRenamed/StdLib/Lib/cProfile.py b/src/StdLib/Lib/cProfile.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/cProfile.py rename to src/StdLib/Lib/cProfile.py diff --git a/Src.GetRenamed/StdLib/Lib/calendar.py b/src/StdLib/Lib/calendar.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/calendar.py rename to src/StdLib/Lib/calendar.py diff --git a/Src.GetRenamed/StdLib/Lib/cgi.py b/src/StdLib/Lib/cgi.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/cgi.py rename to src/StdLib/Lib/cgi.py diff --git a/Src.GetRenamed/StdLib/Lib/cgitb.py b/src/StdLib/Lib/cgitb.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/cgitb.py rename to src/StdLib/Lib/cgitb.py diff --git a/Src.GetRenamed/StdLib/Lib/chunk.py b/src/StdLib/Lib/chunk.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/chunk.py rename to src/StdLib/Lib/chunk.py diff --git a/Src.GetRenamed/StdLib/Lib/clrtype.py b/src/StdLib/Lib/clrtype.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/clrtype.py rename to src/StdLib/Lib/clrtype.py diff --git a/Src.GetRenamed/StdLib/Lib/cmd.py b/src/StdLib/Lib/cmd.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/cmd.py rename to src/StdLib/Lib/cmd.py diff --git a/Src.GetRenamed/StdLib/Lib/code.py b/src/StdLib/Lib/code.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/code.py rename to src/StdLib/Lib/code.py diff --git a/Src.GetRenamed/StdLib/Lib/codecs.py b/src/StdLib/Lib/codecs.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/codecs.py rename to src/StdLib/Lib/codecs.py diff --git a/Src.GetRenamed/StdLib/Lib/codeop.py b/src/StdLib/Lib/codeop.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/codeop.py rename to src/StdLib/Lib/codeop.py diff --git a/Src.GetRenamed/StdLib/Lib/collections/__init__.py b/src/StdLib/Lib/collections/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/collections/__init__.py rename to src/StdLib/Lib/collections/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/collections/__main__.py b/src/StdLib/Lib/collections/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/collections/__main__.py rename to src/StdLib/Lib/collections/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/collections/abc.py b/src/StdLib/Lib/collections/abc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/collections/abc.py rename to src/StdLib/Lib/collections/abc.py diff --git a/Src.GetRenamed/StdLib/Lib/colorsys.py b/src/StdLib/Lib/colorsys.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/colorsys.py rename to src/StdLib/Lib/colorsys.py diff --git a/Src.GetRenamed/StdLib/Lib/compileall.py b/src/StdLib/Lib/compileall.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/compileall.py rename to src/StdLib/Lib/compileall.py diff --git a/Src.GetRenamed/StdLib/Lib/concurrent/__init__.py b/src/StdLib/Lib/concurrent/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/concurrent/__init__.py rename to src/StdLib/Lib/concurrent/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/concurrent/futures/__init__.py b/src/StdLib/Lib/concurrent/futures/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/concurrent/futures/__init__.py rename to src/StdLib/Lib/concurrent/futures/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/concurrent/futures/_base.py b/src/StdLib/Lib/concurrent/futures/_base.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/concurrent/futures/_base.py rename to src/StdLib/Lib/concurrent/futures/_base.py diff --git a/Src.GetRenamed/StdLib/Lib/concurrent/futures/process.py b/src/StdLib/Lib/concurrent/futures/process.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/concurrent/futures/process.py rename to src/StdLib/Lib/concurrent/futures/process.py diff --git a/Src.GetRenamed/StdLib/Lib/concurrent/futures/thread.py b/src/StdLib/Lib/concurrent/futures/thread.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/concurrent/futures/thread.py rename to src/StdLib/Lib/concurrent/futures/thread.py diff --git a/Src.GetRenamed/StdLib/Lib/configparser.py b/src/StdLib/Lib/configparser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/configparser.py rename to src/StdLib/Lib/configparser.py diff --git a/Src.GetRenamed/StdLib/Lib/contextlib.py b/src/StdLib/Lib/contextlib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/contextlib.py rename to src/StdLib/Lib/contextlib.py diff --git a/Src.GetRenamed/StdLib/Lib/copy.py b/src/StdLib/Lib/copy.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/copy.py rename to src/StdLib/Lib/copy.py diff --git a/Src.GetRenamed/StdLib/Lib/copyreg.py b/src/StdLib/Lib/copyreg.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/copyreg.py rename to src/StdLib/Lib/copyreg.py diff --git a/Src.GetRenamed/StdLib/Lib/crypt.py b/src/StdLib/Lib/crypt.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/crypt.py rename to src/StdLib/Lib/crypt.py diff --git a/Src.GetRenamed/StdLib/Lib/csv.py b/src/StdLib/Lib/csv.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/csv.py rename to src/StdLib/Lib/csv.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/__init__.py b/src/StdLib/Lib/ctypes/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/__init__.py rename to src/StdLib/Lib/ctypes/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/_endian.py b/src/StdLib/Lib/ctypes/_endian.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/_endian.py rename to src/StdLib/Lib/ctypes/_endian.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/macholib/README.ctypes b/src/StdLib/Lib/ctypes/macholib/README.ctypes similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/macholib/README.ctypes rename to src/StdLib/Lib/ctypes/macholib/README.ctypes diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/macholib/__init__.py b/src/StdLib/Lib/ctypes/macholib/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/macholib/__init__.py rename to src/StdLib/Lib/ctypes/macholib/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/macholib/dyld.py b/src/StdLib/Lib/ctypes/macholib/dyld.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/macholib/dyld.py rename to src/StdLib/Lib/ctypes/macholib/dyld.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/macholib/dylib.py b/src/StdLib/Lib/ctypes/macholib/dylib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/macholib/dylib.py rename to src/StdLib/Lib/ctypes/macholib/dylib.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/macholib/fetch_macholib b/src/StdLib/Lib/ctypes/macholib/fetch_macholib similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/macholib/fetch_macholib rename to src/StdLib/Lib/ctypes/macholib/fetch_macholib diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/macholib/fetch_macholib.bat b/src/StdLib/Lib/ctypes/macholib/fetch_macholib.bat similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/macholib/fetch_macholib.bat rename to src/StdLib/Lib/ctypes/macholib/fetch_macholib.bat diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/macholib/framework.py b/src/StdLib/Lib/ctypes/macholib/framework.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/macholib/framework.py rename to src/StdLib/Lib/ctypes/macholib/framework.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/__init__.py b/src/StdLib/Lib/ctypes/test/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/__init__.py rename to src/StdLib/Lib/ctypes/test/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/__main__.py b/src/StdLib/Lib/ctypes/test/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/__main__.py rename to src/StdLib/Lib/ctypes/test/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_anon.py b/src/StdLib/Lib/ctypes/test/test_anon.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_anon.py rename to src/StdLib/Lib/ctypes/test/test_anon.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_array_in_pointer.py b/src/StdLib/Lib/ctypes/test/test_array_in_pointer.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_array_in_pointer.py rename to src/StdLib/Lib/ctypes/test/test_array_in_pointer.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_arrays.py b/src/StdLib/Lib/ctypes/test/test_arrays.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_arrays.py rename to src/StdLib/Lib/ctypes/test/test_arrays.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_as_parameter.py b/src/StdLib/Lib/ctypes/test/test_as_parameter.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_as_parameter.py rename to src/StdLib/Lib/ctypes/test/test_as_parameter.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_bitfields.py b/src/StdLib/Lib/ctypes/test/test_bitfields.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_bitfields.py rename to src/StdLib/Lib/ctypes/test/test_bitfields.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_buffers.py b/src/StdLib/Lib/ctypes/test/test_buffers.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_buffers.py rename to src/StdLib/Lib/ctypes/test/test_buffers.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_bytes.py b/src/StdLib/Lib/ctypes/test/test_bytes.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_bytes.py rename to src/StdLib/Lib/ctypes/test/test_bytes.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_byteswap.py b/src/StdLib/Lib/ctypes/test/test_byteswap.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_byteswap.py rename to src/StdLib/Lib/ctypes/test/test_byteswap.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_callbacks.py b/src/StdLib/Lib/ctypes/test/test_callbacks.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_callbacks.py rename to src/StdLib/Lib/ctypes/test/test_callbacks.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_cast.py b/src/StdLib/Lib/ctypes/test/test_cast.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_cast.py rename to src/StdLib/Lib/ctypes/test/test_cast.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_cfuncs.py b/src/StdLib/Lib/ctypes/test/test_cfuncs.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_cfuncs.py rename to src/StdLib/Lib/ctypes/test/test_cfuncs.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_checkretval.py b/src/StdLib/Lib/ctypes/test/test_checkretval.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_checkretval.py rename to src/StdLib/Lib/ctypes/test/test_checkretval.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_delattr.py b/src/StdLib/Lib/ctypes/test/test_delattr.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_delattr.py rename to src/StdLib/Lib/ctypes/test/test_delattr.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_errno.py b/src/StdLib/Lib/ctypes/test/test_errno.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_errno.py rename to src/StdLib/Lib/ctypes/test/test_errno.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_find.py b/src/StdLib/Lib/ctypes/test/test_find.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_find.py rename to src/StdLib/Lib/ctypes/test/test_find.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_frombuffer.py b/src/StdLib/Lib/ctypes/test/test_frombuffer.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_frombuffer.py rename to src/StdLib/Lib/ctypes/test/test_frombuffer.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_funcptr.py b/src/StdLib/Lib/ctypes/test/test_funcptr.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_funcptr.py rename to src/StdLib/Lib/ctypes/test/test_funcptr.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_functions.py b/src/StdLib/Lib/ctypes/test/test_functions.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_functions.py rename to src/StdLib/Lib/ctypes/test/test_functions.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_incomplete.py b/src/StdLib/Lib/ctypes/test/test_incomplete.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_incomplete.py rename to src/StdLib/Lib/ctypes/test/test_incomplete.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_init.py b/src/StdLib/Lib/ctypes/test/test_init.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_init.py rename to src/StdLib/Lib/ctypes/test/test_init.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_internals.py b/src/StdLib/Lib/ctypes/test/test_internals.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_internals.py rename to src/StdLib/Lib/ctypes/test/test_internals.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_keeprefs.py b/src/StdLib/Lib/ctypes/test/test_keeprefs.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_keeprefs.py rename to src/StdLib/Lib/ctypes/test/test_keeprefs.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_libc.py b/src/StdLib/Lib/ctypes/test/test_libc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_libc.py rename to src/StdLib/Lib/ctypes/test/test_libc.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_loading.py b/src/StdLib/Lib/ctypes/test/test_loading.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_loading.py rename to src/StdLib/Lib/ctypes/test/test_loading.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_macholib.py b/src/StdLib/Lib/ctypes/test/test_macholib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_macholib.py rename to src/StdLib/Lib/ctypes/test/test_macholib.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_memfunctions.py b/src/StdLib/Lib/ctypes/test/test_memfunctions.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_memfunctions.py rename to src/StdLib/Lib/ctypes/test/test_memfunctions.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_numbers.py b/src/StdLib/Lib/ctypes/test/test_numbers.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_numbers.py rename to src/StdLib/Lib/ctypes/test/test_numbers.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_objects.py b/src/StdLib/Lib/ctypes/test/test_objects.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_objects.py rename to src/StdLib/Lib/ctypes/test/test_objects.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_parameters.py b/src/StdLib/Lib/ctypes/test/test_parameters.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_parameters.py rename to src/StdLib/Lib/ctypes/test/test_parameters.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_pep3118.py b/src/StdLib/Lib/ctypes/test/test_pep3118.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_pep3118.py rename to src/StdLib/Lib/ctypes/test/test_pep3118.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_pickling.py b/src/StdLib/Lib/ctypes/test/test_pickling.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_pickling.py rename to src/StdLib/Lib/ctypes/test/test_pickling.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_pointers.py b/src/StdLib/Lib/ctypes/test/test_pointers.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_pointers.py rename to src/StdLib/Lib/ctypes/test/test_pointers.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_prototypes.py b/src/StdLib/Lib/ctypes/test/test_prototypes.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_prototypes.py rename to src/StdLib/Lib/ctypes/test/test_prototypes.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_python_api.py b/src/StdLib/Lib/ctypes/test/test_python_api.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_python_api.py rename to src/StdLib/Lib/ctypes/test/test_python_api.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_random_things.py b/src/StdLib/Lib/ctypes/test/test_random_things.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_random_things.py rename to src/StdLib/Lib/ctypes/test/test_random_things.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_refcounts.py b/src/StdLib/Lib/ctypes/test/test_refcounts.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_refcounts.py rename to src/StdLib/Lib/ctypes/test/test_refcounts.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_repr.py b/src/StdLib/Lib/ctypes/test/test_repr.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_repr.py rename to src/StdLib/Lib/ctypes/test/test_repr.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_returnfuncptrs.py b/src/StdLib/Lib/ctypes/test/test_returnfuncptrs.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_returnfuncptrs.py rename to src/StdLib/Lib/ctypes/test/test_returnfuncptrs.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_simplesubclasses.py b/src/StdLib/Lib/ctypes/test/test_simplesubclasses.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_simplesubclasses.py rename to src/StdLib/Lib/ctypes/test/test_simplesubclasses.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_sizes.py b/src/StdLib/Lib/ctypes/test/test_sizes.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_sizes.py rename to src/StdLib/Lib/ctypes/test/test_sizes.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_slicing.py b/src/StdLib/Lib/ctypes/test/test_slicing.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_slicing.py rename to src/StdLib/Lib/ctypes/test/test_slicing.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_stringptr.py b/src/StdLib/Lib/ctypes/test/test_stringptr.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_stringptr.py rename to src/StdLib/Lib/ctypes/test/test_stringptr.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_strings.py b/src/StdLib/Lib/ctypes/test/test_strings.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_strings.py rename to src/StdLib/Lib/ctypes/test/test_strings.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_struct_fields.py b/src/StdLib/Lib/ctypes/test/test_struct_fields.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_struct_fields.py rename to src/StdLib/Lib/ctypes/test/test_struct_fields.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_structures.py b/src/StdLib/Lib/ctypes/test/test_structures.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_structures.py rename to src/StdLib/Lib/ctypes/test/test_structures.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_unaligned_structures.py b/src/StdLib/Lib/ctypes/test/test_unaligned_structures.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_unaligned_structures.py rename to src/StdLib/Lib/ctypes/test/test_unaligned_structures.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_unicode.py b/src/StdLib/Lib/ctypes/test/test_unicode.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_unicode.py rename to src/StdLib/Lib/ctypes/test/test_unicode.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_values.py b/src/StdLib/Lib/ctypes/test/test_values.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_values.py rename to src/StdLib/Lib/ctypes/test/test_values.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_varsize_struct.py b/src/StdLib/Lib/ctypes/test/test_varsize_struct.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_varsize_struct.py rename to src/StdLib/Lib/ctypes/test/test_varsize_struct.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_win32.py b/src/StdLib/Lib/ctypes/test/test_win32.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_win32.py rename to src/StdLib/Lib/ctypes/test/test_win32.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/test/test_wintypes.py b/src/StdLib/Lib/ctypes/test/test_wintypes.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/test/test_wintypes.py rename to src/StdLib/Lib/ctypes/test/test_wintypes.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/util.py b/src/StdLib/Lib/ctypes/util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/util.py rename to src/StdLib/Lib/ctypes/util.py diff --git a/Src.GetRenamed/StdLib/Lib/ctypes/wintypes.py b/src/StdLib/Lib/ctypes/wintypes.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ctypes/wintypes.py rename to src/StdLib/Lib/ctypes/wintypes.py diff --git a/Src.GetRenamed/StdLib/Lib/curses/__init__.py b/src/StdLib/Lib/curses/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/curses/__init__.py rename to src/StdLib/Lib/curses/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/curses/ascii.py b/src/StdLib/Lib/curses/ascii.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/curses/ascii.py rename to src/StdLib/Lib/curses/ascii.py diff --git a/Src.GetRenamed/StdLib/Lib/curses/has_key.py b/src/StdLib/Lib/curses/has_key.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/curses/has_key.py rename to src/StdLib/Lib/curses/has_key.py diff --git a/Src.GetRenamed/StdLib/Lib/curses/panel.py b/src/StdLib/Lib/curses/panel.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/curses/panel.py rename to src/StdLib/Lib/curses/panel.py diff --git a/Src.GetRenamed/StdLib/Lib/curses/textpad.py b/src/StdLib/Lib/curses/textpad.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/curses/textpad.py rename to src/StdLib/Lib/curses/textpad.py diff --git a/Src.GetRenamed/StdLib/Lib/datetime.py b/src/StdLib/Lib/datetime.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/datetime.py rename to src/StdLib/Lib/datetime.py diff --git a/Src.GetRenamed/StdLib/Lib/dbm/__init__.py b/src/StdLib/Lib/dbm/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/dbm/__init__.py rename to src/StdLib/Lib/dbm/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/dbm/dumb.py b/src/StdLib/Lib/dbm/dumb.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/dbm/dumb.py rename to src/StdLib/Lib/dbm/dumb.py diff --git a/Src.GetRenamed/StdLib/Lib/dbm/gnu.py b/src/StdLib/Lib/dbm/gnu.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/dbm/gnu.py rename to src/StdLib/Lib/dbm/gnu.py diff --git a/Src.GetRenamed/StdLib/Lib/dbm/ndbm.py b/src/StdLib/Lib/dbm/ndbm.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/dbm/ndbm.py rename to src/StdLib/Lib/dbm/ndbm.py diff --git a/Src.GetRenamed/StdLib/Lib/decimal.py b/src/StdLib/Lib/decimal.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/decimal.py rename to src/StdLib/Lib/decimal.py diff --git a/Src.GetRenamed/StdLib/Lib/difflib.py b/src/StdLib/Lib/difflib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/difflib.py rename to src/StdLib/Lib/difflib.py diff --git a/Src.GetRenamed/StdLib/Lib/dis.py b/src/StdLib/Lib/dis.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/dis.py rename to src/StdLib/Lib/dis.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/README b/src/StdLib/Lib/distutils/README similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/README rename to src/StdLib/Lib/distutils/README diff --git a/Src.GetRenamed/StdLib/Lib/distutils/__init__.py b/src/StdLib/Lib/distutils/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/__init__.py rename to src/StdLib/Lib/distutils/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/archive_util.py b/src/StdLib/Lib/distutils/archive_util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/archive_util.py rename to src/StdLib/Lib/distutils/archive_util.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/bcppcompiler.py b/src/StdLib/Lib/distutils/bcppcompiler.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/bcppcompiler.py rename to src/StdLib/Lib/distutils/bcppcompiler.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/ccompiler.py b/src/StdLib/Lib/distutils/ccompiler.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/ccompiler.py rename to src/StdLib/Lib/distutils/ccompiler.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/cmd.py b/src/StdLib/Lib/distutils/cmd.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/cmd.py rename to src/StdLib/Lib/distutils/cmd.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/__init__.py b/src/StdLib/Lib/distutils/command/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/__init__.py rename to src/StdLib/Lib/distutils/command/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/bdist.py b/src/StdLib/Lib/distutils/command/bdist.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/bdist.py rename to src/StdLib/Lib/distutils/command/bdist.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/bdist_dumb.py b/src/StdLib/Lib/distutils/command/bdist_dumb.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/bdist_dumb.py rename to src/StdLib/Lib/distutils/command/bdist_dumb.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/bdist_msi.py b/src/StdLib/Lib/distutils/command/bdist_msi.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/bdist_msi.py rename to src/StdLib/Lib/distutils/command/bdist_msi.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/bdist_rpm.py b/src/StdLib/Lib/distutils/command/bdist_rpm.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/bdist_rpm.py rename to src/StdLib/Lib/distutils/command/bdist_rpm.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/bdist_wininst.py b/src/StdLib/Lib/distutils/command/bdist_wininst.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/bdist_wininst.py rename to src/StdLib/Lib/distutils/command/bdist_wininst.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/build.py b/src/StdLib/Lib/distutils/command/build.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/build.py rename to src/StdLib/Lib/distutils/command/build.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/build_clib.py b/src/StdLib/Lib/distutils/command/build_clib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/build_clib.py rename to src/StdLib/Lib/distutils/command/build_clib.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/build_ext.py b/src/StdLib/Lib/distutils/command/build_ext.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/build_ext.py rename to src/StdLib/Lib/distutils/command/build_ext.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/build_py.py b/src/StdLib/Lib/distutils/command/build_py.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/build_py.py rename to src/StdLib/Lib/distutils/command/build_py.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/build_scripts.py b/src/StdLib/Lib/distutils/command/build_scripts.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/build_scripts.py rename to src/StdLib/Lib/distutils/command/build_scripts.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/check.py b/src/StdLib/Lib/distutils/command/check.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/check.py rename to src/StdLib/Lib/distutils/command/check.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/clean.py b/src/StdLib/Lib/distutils/command/clean.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/clean.py rename to src/StdLib/Lib/distutils/command/clean.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/command_template b/src/StdLib/Lib/distutils/command/command_template similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/command_template rename to src/StdLib/Lib/distutils/command/command_template diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/config.py b/src/StdLib/Lib/distutils/command/config.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/config.py rename to src/StdLib/Lib/distutils/command/config.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/install.py b/src/StdLib/Lib/distutils/command/install.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/install.py rename to src/StdLib/Lib/distutils/command/install.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/install_data.py b/src/StdLib/Lib/distutils/command/install_data.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/install_data.py rename to src/StdLib/Lib/distutils/command/install_data.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/install_egg_info.py b/src/StdLib/Lib/distutils/command/install_egg_info.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/install_egg_info.py rename to src/StdLib/Lib/distutils/command/install_egg_info.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/install_headers.py b/src/StdLib/Lib/distutils/command/install_headers.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/install_headers.py rename to src/StdLib/Lib/distutils/command/install_headers.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/install_lib.py b/src/StdLib/Lib/distutils/command/install_lib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/install_lib.py rename to src/StdLib/Lib/distutils/command/install_lib.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/install_scripts.py b/src/StdLib/Lib/distutils/command/install_scripts.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/install_scripts.py rename to src/StdLib/Lib/distutils/command/install_scripts.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/register.py b/src/StdLib/Lib/distutils/command/register.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/register.py rename to src/StdLib/Lib/distutils/command/register.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/sdist.py b/src/StdLib/Lib/distutils/command/sdist.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/sdist.py rename to src/StdLib/Lib/distutils/command/sdist.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/upload.py b/src/StdLib/Lib/distutils/command/upload.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/upload.py rename to src/StdLib/Lib/distutils/command/upload.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe b/src/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe rename to src/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/wininst-10.0.exe b/src/StdLib/Lib/distutils/command/wininst-10.0.exe similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/wininst-10.0.exe rename to src/StdLib/Lib/distutils/command/wininst-10.0.exe diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/wininst-6.0.exe b/src/StdLib/Lib/distutils/command/wininst-6.0.exe similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/wininst-6.0.exe rename to src/StdLib/Lib/distutils/command/wininst-6.0.exe diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/wininst-7.1.exe b/src/StdLib/Lib/distutils/command/wininst-7.1.exe similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/wininst-7.1.exe rename to src/StdLib/Lib/distutils/command/wininst-7.1.exe diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/wininst-8.0.exe b/src/StdLib/Lib/distutils/command/wininst-8.0.exe similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/wininst-8.0.exe rename to src/StdLib/Lib/distutils/command/wininst-8.0.exe diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe b/src/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe rename to src/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe diff --git a/Src.GetRenamed/StdLib/Lib/distutils/command/wininst-9.0.exe b/src/StdLib/Lib/distutils/command/wininst-9.0.exe similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/command/wininst-9.0.exe rename to src/StdLib/Lib/distutils/command/wininst-9.0.exe diff --git a/Src.GetRenamed/StdLib/Lib/distutils/config.py b/src/StdLib/Lib/distutils/config.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/config.py rename to src/StdLib/Lib/distutils/config.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/core.py b/src/StdLib/Lib/distutils/core.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/core.py rename to src/StdLib/Lib/distutils/core.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/cygwinccompiler.py b/src/StdLib/Lib/distutils/cygwinccompiler.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/cygwinccompiler.py rename to src/StdLib/Lib/distutils/cygwinccompiler.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/debug.py b/src/StdLib/Lib/distutils/debug.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/debug.py rename to src/StdLib/Lib/distutils/debug.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/dep_util.py b/src/StdLib/Lib/distutils/dep_util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/dep_util.py rename to src/StdLib/Lib/distutils/dep_util.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/dir_util.py b/src/StdLib/Lib/distutils/dir_util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/dir_util.py rename to src/StdLib/Lib/distutils/dir_util.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/dist.py b/src/StdLib/Lib/distutils/dist.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/dist.py rename to src/StdLib/Lib/distutils/dist.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/errors.py b/src/StdLib/Lib/distutils/errors.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/errors.py rename to src/StdLib/Lib/distutils/errors.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/extension.py b/src/StdLib/Lib/distutils/extension.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/extension.py rename to src/StdLib/Lib/distutils/extension.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/fancy_getopt.py b/src/StdLib/Lib/distutils/fancy_getopt.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/fancy_getopt.py rename to src/StdLib/Lib/distutils/fancy_getopt.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/file_util.py b/src/StdLib/Lib/distutils/file_util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/file_util.py rename to src/StdLib/Lib/distutils/file_util.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/filelist.py b/src/StdLib/Lib/distutils/filelist.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/filelist.py rename to src/StdLib/Lib/distutils/filelist.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/log.py b/src/StdLib/Lib/distutils/log.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/log.py rename to src/StdLib/Lib/distutils/log.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/msvc9compiler.py b/src/StdLib/Lib/distutils/msvc9compiler.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/msvc9compiler.py rename to src/StdLib/Lib/distutils/msvc9compiler.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/msvccompiler.py b/src/StdLib/Lib/distutils/msvccompiler.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/msvccompiler.py rename to src/StdLib/Lib/distutils/msvccompiler.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/spawn.py b/src/StdLib/Lib/distutils/spawn.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/spawn.py rename to src/StdLib/Lib/distutils/spawn.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/sysconfig.py b/src/StdLib/Lib/distutils/sysconfig.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/sysconfig.py rename to src/StdLib/Lib/distutils/sysconfig.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/Setup.sample b/src/StdLib/Lib/distutils/tests/Setup.sample similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/Setup.sample rename to src/StdLib/Lib/distutils/tests/Setup.sample diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/__init__.py b/src/StdLib/Lib/distutils/tests/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/__init__.py rename to src/StdLib/Lib/distutils/tests/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/support.py b/src/StdLib/Lib/distutils/tests/support.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/support.py rename to src/StdLib/Lib/distutils/tests/support.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_archive_util.py b/src/StdLib/Lib/distutils/tests/test_archive_util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_archive_util.py rename to src/StdLib/Lib/distutils/tests/test_archive_util.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_bdist.py b/src/StdLib/Lib/distutils/tests/test_bdist.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_bdist.py rename to src/StdLib/Lib/distutils/tests/test_bdist.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_bdist_dumb.py b/src/StdLib/Lib/distutils/tests/test_bdist_dumb.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_bdist_dumb.py rename to src/StdLib/Lib/distutils/tests/test_bdist_dumb.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_bdist_msi.py b/src/StdLib/Lib/distutils/tests/test_bdist_msi.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_bdist_msi.py rename to src/StdLib/Lib/distutils/tests/test_bdist_msi.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_bdist_rpm.py b/src/StdLib/Lib/distutils/tests/test_bdist_rpm.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_bdist_rpm.py rename to src/StdLib/Lib/distutils/tests/test_bdist_rpm.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_bdist_wininst.py b/src/StdLib/Lib/distutils/tests/test_bdist_wininst.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_bdist_wininst.py rename to src/StdLib/Lib/distutils/tests/test_bdist_wininst.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_build.py b/src/StdLib/Lib/distutils/tests/test_build.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_build.py rename to src/StdLib/Lib/distutils/tests/test_build.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_build_clib.py b/src/StdLib/Lib/distutils/tests/test_build_clib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_build_clib.py rename to src/StdLib/Lib/distutils/tests/test_build_clib.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_build_ext.py b/src/StdLib/Lib/distutils/tests/test_build_ext.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_build_ext.py rename to src/StdLib/Lib/distutils/tests/test_build_ext.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_build_py.py b/src/StdLib/Lib/distutils/tests/test_build_py.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_build_py.py rename to src/StdLib/Lib/distutils/tests/test_build_py.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_build_scripts.py b/src/StdLib/Lib/distutils/tests/test_build_scripts.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_build_scripts.py rename to src/StdLib/Lib/distutils/tests/test_build_scripts.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_check.py b/src/StdLib/Lib/distutils/tests/test_check.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_check.py rename to src/StdLib/Lib/distutils/tests/test_check.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_clean.py b/src/StdLib/Lib/distutils/tests/test_clean.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_clean.py rename to src/StdLib/Lib/distutils/tests/test_clean.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_cmd.py b/src/StdLib/Lib/distutils/tests/test_cmd.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_cmd.py rename to src/StdLib/Lib/distutils/tests/test_cmd.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_config.py b/src/StdLib/Lib/distutils/tests/test_config.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_config.py rename to src/StdLib/Lib/distutils/tests/test_config.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_config_cmd.py b/src/StdLib/Lib/distutils/tests/test_config_cmd.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_config_cmd.py rename to src/StdLib/Lib/distutils/tests/test_config_cmd.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_core.py b/src/StdLib/Lib/distutils/tests/test_core.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_core.py rename to src/StdLib/Lib/distutils/tests/test_core.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_cygwinccompiler.py b/src/StdLib/Lib/distutils/tests/test_cygwinccompiler.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_cygwinccompiler.py rename to src/StdLib/Lib/distutils/tests/test_cygwinccompiler.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_dep_util.py b/src/StdLib/Lib/distutils/tests/test_dep_util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_dep_util.py rename to src/StdLib/Lib/distutils/tests/test_dep_util.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_dir_util.py b/src/StdLib/Lib/distutils/tests/test_dir_util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_dir_util.py rename to src/StdLib/Lib/distutils/tests/test_dir_util.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_dist.py b/src/StdLib/Lib/distutils/tests/test_dist.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_dist.py rename to src/StdLib/Lib/distutils/tests/test_dist.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_extension.py b/src/StdLib/Lib/distutils/tests/test_extension.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_extension.py rename to src/StdLib/Lib/distutils/tests/test_extension.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_file_util.py b/src/StdLib/Lib/distutils/tests/test_file_util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_file_util.py rename to src/StdLib/Lib/distutils/tests/test_file_util.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_filelist.py b/src/StdLib/Lib/distutils/tests/test_filelist.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_filelist.py rename to src/StdLib/Lib/distutils/tests/test_filelist.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_install.py b/src/StdLib/Lib/distutils/tests/test_install.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_install.py rename to src/StdLib/Lib/distutils/tests/test_install.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_install_data.py b/src/StdLib/Lib/distutils/tests/test_install_data.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_install_data.py rename to src/StdLib/Lib/distutils/tests/test_install_data.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_install_headers.py b/src/StdLib/Lib/distutils/tests/test_install_headers.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_install_headers.py rename to src/StdLib/Lib/distutils/tests/test_install_headers.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_install_lib.py b/src/StdLib/Lib/distutils/tests/test_install_lib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_install_lib.py rename to src/StdLib/Lib/distutils/tests/test_install_lib.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_install_scripts.py b/src/StdLib/Lib/distutils/tests/test_install_scripts.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_install_scripts.py rename to src/StdLib/Lib/distutils/tests/test_install_scripts.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_log.py b/src/StdLib/Lib/distutils/tests/test_log.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_log.py rename to src/StdLib/Lib/distutils/tests/test_log.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_msvc9compiler.py b/src/StdLib/Lib/distutils/tests/test_msvc9compiler.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_msvc9compiler.py rename to src/StdLib/Lib/distutils/tests/test_msvc9compiler.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_register.py b/src/StdLib/Lib/distutils/tests/test_register.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_register.py rename to src/StdLib/Lib/distutils/tests/test_register.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_sdist.py b/src/StdLib/Lib/distutils/tests/test_sdist.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_sdist.py rename to src/StdLib/Lib/distutils/tests/test_sdist.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_spawn.py b/src/StdLib/Lib/distutils/tests/test_spawn.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_spawn.py rename to src/StdLib/Lib/distutils/tests/test_spawn.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_sysconfig.py b/src/StdLib/Lib/distutils/tests/test_sysconfig.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_sysconfig.py rename to src/StdLib/Lib/distutils/tests/test_sysconfig.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_text_file.py b/src/StdLib/Lib/distutils/tests/test_text_file.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_text_file.py rename to src/StdLib/Lib/distutils/tests/test_text_file.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_unixccompiler.py b/src/StdLib/Lib/distutils/tests/test_unixccompiler.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_unixccompiler.py rename to src/StdLib/Lib/distutils/tests/test_unixccompiler.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_upload.py b/src/StdLib/Lib/distutils/tests/test_upload.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_upload.py rename to src/StdLib/Lib/distutils/tests/test_upload.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_util.py b/src/StdLib/Lib/distutils/tests/test_util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_util.py rename to src/StdLib/Lib/distutils/tests/test_util.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_version.py b/src/StdLib/Lib/distutils/tests/test_version.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_version.py rename to src/StdLib/Lib/distutils/tests/test_version.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/tests/test_versionpredicate.py b/src/StdLib/Lib/distutils/tests/test_versionpredicate.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/tests/test_versionpredicate.py rename to src/StdLib/Lib/distutils/tests/test_versionpredicate.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/text_file.py b/src/StdLib/Lib/distutils/text_file.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/text_file.py rename to src/StdLib/Lib/distutils/text_file.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/unixccompiler.py b/src/StdLib/Lib/distutils/unixccompiler.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/unixccompiler.py rename to src/StdLib/Lib/distutils/unixccompiler.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/util.py b/src/StdLib/Lib/distutils/util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/util.py rename to src/StdLib/Lib/distutils/util.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/version.py b/src/StdLib/Lib/distutils/version.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/version.py rename to src/StdLib/Lib/distutils/version.py diff --git a/Src.GetRenamed/StdLib/Lib/distutils/versionpredicate.py b/src/StdLib/Lib/distutils/versionpredicate.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/distutils/versionpredicate.py rename to src/StdLib/Lib/distutils/versionpredicate.py diff --git a/Src.GetRenamed/StdLib/Lib/doctest.py b/src/StdLib/Lib/doctest.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/doctest.py rename to src/StdLib/Lib/doctest.py diff --git a/Src.GetRenamed/StdLib/Lib/dummy_threading.py b/src/StdLib/Lib/dummy_threading.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/dummy_threading.py rename to src/StdLib/Lib/dummy_threading.py diff --git a/Src.GetRenamed/StdLib/Lib/email/__init__.py b/src/StdLib/Lib/email/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/__init__.py rename to src/StdLib/Lib/email/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/email/_encoded_words.py b/src/StdLib/Lib/email/_encoded_words.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/_encoded_words.py rename to src/StdLib/Lib/email/_encoded_words.py diff --git a/Src.GetRenamed/StdLib/Lib/email/_header_value_parser.py b/src/StdLib/Lib/email/_header_value_parser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/_header_value_parser.py rename to src/StdLib/Lib/email/_header_value_parser.py diff --git a/Src.GetRenamed/StdLib/Lib/email/_parseaddr.py b/src/StdLib/Lib/email/_parseaddr.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/_parseaddr.py rename to src/StdLib/Lib/email/_parseaddr.py diff --git a/Src.GetRenamed/StdLib/Lib/email/_policybase.py b/src/StdLib/Lib/email/_policybase.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/_policybase.py rename to src/StdLib/Lib/email/_policybase.py diff --git a/Src.GetRenamed/StdLib/Lib/email/architecture.rst b/src/StdLib/Lib/email/architecture.rst similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/architecture.rst rename to src/StdLib/Lib/email/architecture.rst diff --git a/Src.GetRenamed/StdLib/Lib/email/base64mime.py b/src/StdLib/Lib/email/base64mime.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/base64mime.py rename to src/StdLib/Lib/email/base64mime.py diff --git a/Src.GetRenamed/StdLib/Lib/email/charset.py b/src/StdLib/Lib/email/charset.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/charset.py rename to src/StdLib/Lib/email/charset.py diff --git a/Src.GetRenamed/StdLib/Lib/email/contentmanager.py b/src/StdLib/Lib/email/contentmanager.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/contentmanager.py rename to src/StdLib/Lib/email/contentmanager.py diff --git a/Src.GetRenamed/StdLib/Lib/email/encoders.py b/src/StdLib/Lib/email/encoders.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/encoders.py rename to src/StdLib/Lib/email/encoders.py diff --git a/Src.GetRenamed/StdLib/Lib/email/errors.py b/src/StdLib/Lib/email/errors.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/errors.py rename to src/StdLib/Lib/email/errors.py diff --git a/Src.GetRenamed/StdLib/Lib/email/feedparser.py b/src/StdLib/Lib/email/feedparser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/feedparser.py rename to src/StdLib/Lib/email/feedparser.py diff --git a/Src.GetRenamed/StdLib/Lib/email/generator.py b/src/StdLib/Lib/email/generator.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/generator.py rename to src/StdLib/Lib/email/generator.py diff --git a/Src.GetRenamed/StdLib/Lib/email/header.py b/src/StdLib/Lib/email/header.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/header.py rename to src/StdLib/Lib/email/header.py diff --git a/Src.GetRenamed/StdLib/Lib/email/headerregistry.py b/src/StdLib/Lib/email/headerregistry.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/headerregistry.py rename to src/StdLib/Lib/email/headerregistry.py diff --git a/Src.GetRenamed/StdLib/Lib/email/iterators.py b/src/StdLib/Lib/email/iterators.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/iterators.py rename to src/StdLib/Lib/email/iterators.py diff --git a/Src.GetRenamed/StdLib/Lib/email/message.py b/src/StdLib/Lib/email/message.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/message.py rename to src/StdLib/Lib/email/message.py diff --git a/Src.GetRenamed/StdLib/Lib/email/mime/__init__.py b/src/StdLib/Lib/email/mime/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/mime/__init__.py rename to src/StdLib/Lib/email/mime/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/email/mime/application.py b/src/StdLib/Lib/email/mime/application.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/mime/application.py rename to src/StdLib/Lib/email/mime/application.py diff --git a/Src.GetRenamed/StdLib/Lib/email/mime/audio.py b/src/StdLib/Lib/email/mime/audio.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/mime/audio.py rename to src/StdLib/Lib/email/mime/audio.py diff --git a/Src.GetRenamed/StdLib/Lib/email/mime/base.py b/src/StdLib/Lib/email/mime/base.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/mime/base.py rename to src/StdLib/Lib/email/mime/base.py diff --git a/Src.GetRenamed/StdLib/Lib/email/mime/image.py b/src/StdLib/Lib/email/mime/image.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/mime/image.py rename to src/StdLib/Lib/email/mime/image.py diff --git a/Src.GetRenamed/StdLib/Lib/email/mime/message.py b/src/StdLib/Lib/email/mime/message.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/mime/message.py rename to src/StdLib/Lib/email/mime/message.py diff --git a/Src.GetRenamed/StdLib/Lib/email/mime/multipart.py b/src/StdLib/Lib/email/mime/multipart.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/mime/multipart.py rename to src/StdLib/Lib/email/mime/multipart.py diff --git a/Src.GetRenamed/StdLib/Lib/email/mime/nonmultipart.py b/src/StdLib/Lib/email/mime/nonmultipart.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/mime/nonmultipart.py rename to src/StdLib/Lib/email/mime/nonmultipart.py diff --git a/Src.GetRenamed/StdLib/Lib/email/mime/text.py b/src/StdLib/Lib/email/mime/text.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/mime/text.py rename to src/StdLib/Lib/email/mime/text.py diff --git a/Src.GetRenamed/StdLib/Lib/email/parser.py b/src/StdLib/Lib/email/parser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/parser.py rename to src/StdLib/Lib/email/parser.py diff --git a/Src.GetRenamed/StdLib/Lib/email/policy.py b/src/StdLib/Lib/email/policy.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/policy.py rename to src/StdLib/Lib/email/policy.py diff --git a/Src.GetRenamed/StdLib/Lib/email/quoprimime.py b/src/StdLib/Lib/email/quoprimime.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/quoprimime.py rename to src/StdLib/Lib/email/quoprimime.py diff --git a/Src.GetRenamed/StdLib/Lib/email/utils.py b/src/StdLib/Lib/email/utils.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/email/utils.py rename to src/StdLib/Lib/email/utils.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/__init__.py b/src/StdLib/Lib/encodings/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/__init__.py rename to src/StdLib/Lib/encodings/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/aliases.py b/src/StdLib/Lib/encodings/aliases.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/aliases.py rename to src/StdLib/Lib/encodings/aliases.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/ascii.py b/src/StdLib/Lib/encodings/ascii.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/ascii.py rename to src/StdLib/Lib/encodings/ascii.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/base64_codec.py b/src/StdLib/Lib/encodings/base64_codec.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/base64_codec.py rename to src/StdLib/Lib/encodings/base64_codec.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/big5.py b/src/StdLib/Lib/encodings/big5.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/big5.py rename to src/StdLib/Lib/encodings/big5.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/big5hkscs.py b/src/StdLib/Lib/encodings/big5hkscs.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/big5hkscs.py rename to src/StdLib/Lib/encodings/big5hkscs.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/bz2_codec.py b/src/StdLib/Lib/encodings/bz2_codec.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/bz2_codec.py rename to src/StdLib/Lib/encodings/bz2_codec.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/charmap.py b/src/StdLib/Lib/encodings/charmap.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/charmap.py rename to src/StdLib/Lib/encodings/charmap.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp037.py b/src/StdLib/Lib/encodings/cp037.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp037.py rename to src/StdLib/Lib/encodings/cp037.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp1006.py b/src/StdLib/Lib/encodings/cp1006.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp1006.py rename to src/StdLib/Lib/encodings/cp1006.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp1026.py b/src/StdLib/Lib/encodings/cp1026.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp1026.py rename to src/StdLib/Lib/encodings/cp1026.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp1125.py b/src/StdLib/Lib/encodings/cp1125.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp1125.py rename to src/StdLib/Lib/encodings/cp1125.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp1140.py b/src/StdLib/Lib/encodings/cp1140.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp1140.py rename to src/StdLib/Lib/encodings/cp1140.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp1250.py b/src/StdLib/Lib/encodings/cp1250.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp1250.py rename to src/StdLib/Lib/encodings/cp1250.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp1251.py b/src/StdLib/Lib/encodings/cp1251.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp1251.py rename to src/StdLib/Lib/encodings/cp1251.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp1252.py b/src/StdLib/Lib/encodings/cp1252.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp1252.py rename to src/StdLib/Lib/encodings/cp1252.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp1253.py b/src/StdLib/Lib/encodings/cp1253.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp1253.py rename to src/StdLib/Lib/encodings/cp1253.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp1254.py b/src/StdLib/Lib/encodings/cp1254.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp1254.py rename to src/StdLib/Lib/encodings/cp1254.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp1255.py b/src/StdLib/Lib/encodings/cp1255.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp1255.py rename to src/StdLib/Lib/encodings/cp1255.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp1256.py b/src/StdLib/Lib/encodings/cp1256.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp1256.py rename to src/StdLib/Lib/encodings/cp1256.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp1257.py b/src/StdLib/Lib/encodings/cp1257.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp1257.py rename to src/StdLib/Lib/encodings/cp1257.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp1258.py b/src/StdLib/Lib/encodings/cp1258.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp1258.py rename to src/StdLib/Lib/encodings/cp1258.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp273.py b/src/StdLib/Lib/encodings/cp273.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp273.py rename to src/StdLib/Lib/encodings/cp273.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp424.py b/src/StdLib/Lib/encodings/cp424.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp424.py rename to src/StdLib/Lib/encodings/cp424.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp437.py b/src/StdLib/Lib/encodings/cp437.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp437.py rename to src/StdLib/Lib/encodings/cp437.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp500.py b/src/StdLib/Lib/encodings/cp500.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp500.py rename to src/StdLib/Lib/encodings/cp500.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp65001.py b/src/StdLib/Lib/encodings/cp65001.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp65001.py rename to src/StdLib/Lib/encodings/cp65001.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp720.py b/src/StdLib/Lib/encodings/cp720.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp720.py rename to src/StdLib/Lib/encodings/cp720.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp737.py b/src/StdLib/Lib/encodings/cp737.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp737.py rename to src/StdLib/Lib/encodings/cp737.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp775.py b/src/StdLib/Lib/encodings/cp775.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp775.py rename to src/StdLib/Lib/encodings/cp775.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp850.py b/src/StdLib/Lib/encodings/cp850.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp850.py rename to src/StdLib/Lib/encodings/cp850.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp852.py b/src/StdLib/Lib/encodings/cp852.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp852.py rename to src/StdLib/Lib/encodings/cp852.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp855.py b/src/StdLib/Lib/encodings/cp855.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp855.py rename to src/StdLib/Lib/encodings/cp855.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp856.py b/src/StdLib/Lib/encodings/cp856.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp856.py rename to src/StdLib/Lib/encodings/cp856.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp857.py b/src/StdLib/Lib/encodings/cp857.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp857.py rename to src/StdLib/Lib/encodings/cp857.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp858.py b/src/StdLib/Lib/encodings/cp858.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp858.py rename to src/StdLib/Lib/encodings/cp858.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp860.py b/src/StdLib/Lib/encodings/cp860.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp860.py rename to src/StdLib/Lib/encodings/cp860.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp861.py b/src/StdLib/Lib/encodings/cp861.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp861.py rename to src/StdLib/Lib/encodings/cp861.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp862.py b/src/StdLib/Lib/encodings/cp862.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp862.py rename to src/StdLib/Lib/encodings/cp862.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp863.py b/src/StdLib/Lib/encodings/cp863.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp863.py rename to src/StdLib/Lib/encodings/cp863.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp864.py b/src/StdLib/Lib/encodings/cp864.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp864.py rename to src/StdLib/Lib/encodings/cp864.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp865.py b/src/StdLib/Lib/encodings/cp865.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp865.py rename to src/StdLib/Lib/encodings/cp865.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp866.py b/src/StdLib/Lib/encodings/cp866.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp866.py rename to src/StdLib/Lib/encodings/cp866.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp869.py b/src/StdLib/Lib/encodings/cp869.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp869.py rename to src/StdLib/Lib/encodings/cp869.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp874.py b/src/StdLib/Lib/encodings/cp874.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp874.py rename to src/StdLib/Lib/encodings/cp874.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp875.py b/src/StdLib/Lib/encodings/cp875.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp875.py rename to src/StdLib/Lib/encodings/cp875.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp932.py b/src/StdLib/Lib/encodings/cp932.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp932.py rename to src/StdLib/Lib/encodings/cp932.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp949.py b/src/StdLib/Lib/encodings/cp949.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp949.py rename to src/StdLib/Lib/encodings/cp949.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/cp950.py b/src/StdLib/Lib/encodings/cp950.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/cp950.py rename to src/StdLib/Lib/encodings/cp950.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/euc_jis_2004.py b/src/StdLib/Lib/encodings/euc_jis_2004.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/euc_jis_2004.py rename to src/StdLib/Lib/encodings/euc_jis_2004.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/euc_jisx0213.py b/src/StdLib/Lib/encodings/euc_jisx0213.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/euc_jisx0213.py rename to src/StdLib/Lib/encodings/euc_jisx0213.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/euc_jp.py b/src/StdLib/Lib/encodings/euc_jp.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/euc_jp.py rename to src/StdLib/Lib/encodings/euc_jp.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/euc_kr.py b/src/StdLib/Lib/encodings/euc_kr.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/euc_kr.py rename to src/StdLib/Lib/encodings/euc_kr.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/gb18030.py b/src/StdLib/Lib/encodings/gb18030.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/gb18030.py rename to src/StdLib/Lib/encodings/gb18030.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/gb2312.py b/src/StdLib/Lib/encodings/gb2312.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/gb2312.py rename to src/StdLib/Lib/encodings/gb2312.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/gbk.py b/src/StdLib/Lib/encodings/gbk.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/gbk.py rename to src/StdLib/Lib/encodings/gbk.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/hex_codec.py b/src/StdLib/Lib/encodings/hex_codec.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/hex_codec.py rename to src/StdLib/Lib/encodings/hex_codec.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/hp_roman8.py b/src/StdLib/Lib/encodings/hp_roman8.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/hp_roman8.py rename to src/StdLib/Lib/encodings/hp_roman8.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/hz.py b/src/StdLib/Lib/encodings/hz.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/hz.py rename to src/StdLib/Lib/encodings/hz.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/idna.py b/src/StdLib/Lib/encodings/idna.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/idna.py rename to src/StdLib/Lib/encodings/idna.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp.py b/src/StdLib/Lib/encodings/iso2022_jp.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp.py rename to src/StdLib/Lib/encodings/iso2022_jp.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp_1.py b/src/StdLib/Lib/encodings/iso2022_jp_1.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp_1.py rename to src/StdLib/Lib/encodings/iso2022_jp_1.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp_2.py b/src/StdLib/Lib/encodings/iso2022_jp_2.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp_2.py rename to src/StdLib/Lib/encodings/iso2022_jp_2.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp_2004.py b/src/StdLib/Lib/encodings/iso2022_jp_2004.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp_2004.py rename to src/StdLib/Lib/encodings/iso2022_jp_2004.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp_3.py b/src/StdLib/Lib/encodings/iso2022_jp_3.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp_3.py rename to src/StdLib/Lib/encodings/iso2022_jp_3.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp_ext.py b/src/StdLib/Lib/encodings/iso2022_jp_ext.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso2022_jp_ext.py rename to src/StdLib/Lib/encodings/iso2022_jp_ext.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso2022_kr.py b/src/StdLib/Lib/encodings/iso2022_kr.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso2022_kr.py rename to src/StdLib/Lib/encodings/iso2022_kr.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso8859_1.py b/src/StdLib/Lib/encodings/iso8859_1.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso8859_1.py rename to src/StdLib/Lib/encodings/iso8859_1.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso8859_10.py b/src/StdLib/Lib/encodings/iso8859_10.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso8859_10.py rename to src/StdLib/Lib/encodings/iso8859_10.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso8859_11.py b/src/StdLib/Lib/encodings/iso8859_11.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso8859_11.py rename to src/StdLib/Lib/encodings/iso8859_11.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso8859_13.py b/src/StdLib/Lib/encodings/iso8859_13.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso8859_13.py rename to src/StdLib/Lib/encodings/iso8859_13.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso8859_14.py b/src/StdLib/Lib/encodings/iso8859_14.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso8859_14.py rename to src/StdLib/Lib/encodings/iso8859_14.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso8859_15.py b/src/StdLib/Lib/encodings/iso8859_15.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso8859_15.py rename to src/StdLib/Lib/encodings/iso8859_15.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso8859_16.py b/src/StdLib/Lib/encodings/iso8859_16.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso8859_16.py rename to src/StdLib/Lib/encodings/iso8859_16.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso8859_2.py b/src/StdLib/Lib/encodings/iso8859_2.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso8859_2.py rename to src/StdLib/Lib/encodings/iso8859_2.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso8859_3.py b/src/StdLib/Lib/encodings/iso8859_3.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso8859_3.py rename to src/StdLib/Lib/encodings/iso8859_3.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso8859_4.py b/src/StdLib/Lib/encodings/iso8859_4.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso8859_4.py rename to src/StdLib/Lib/encodings/iso8859_4.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso8859_5.py b/src/StdLib/Lib/encodings/iso8859_5.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso8859_5.py rename to src/StdLib/Lib/encodings/iso8859_5.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso8859_6.py b/src/StdLib/Lib/encodings/iso8859_6.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso8859_6.py rename to src/StdLib/Lib/encodings/iso8859_6.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso8859_7.py b/src/StdLib/Lib/encodings/iso8859_7.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso8859_7.py rename to src/StdLib/Lib/encodings/iso8859_7.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso8859_8.py b/src/StdLib/Lib/encodings/iso8859_8.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso8859_8.py rename to src/StdLib/Lib/encodings/iso8859_8.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/iso8859_9.py b/src/StdLib/Lib/encodings/iso8859_9.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/iso8859_9.py rename to src/StdLib/Lib/encodings/iso8859_9.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/johab.py b/src/StdLib/Lib/encodings/johab.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/johab.py rename to src/StdLib/Lib/encodings/johab.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/koi8_r.py b/src/StdLib/Lib/encodings/koi8_r.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/koi8_r.py rename to src/StdLib/Lib/encodings/koi8_r.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/koi8_u.py b/src/StdLib/Lib/encodings/koi8_u.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/koi8_u.py rename to src/StdLib/Lib/encodings/koi8_u.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/latin_1.py b/src/StdLib/Lib/encodings/latin_1.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/latin_1.py rename to src/StdLib/Lib/encodings/latin_1.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/mac_arabic.py b/src/StdLib/Lib/encodings/mac_arabic.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/mac_arabic.py rename to src/StdLib/Lib/encodings/mac_arabic.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/mac_centeuro.py b/src/StdLib/Lib/encodings/mac_centeuro.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/mac_centeuro.py rename to src/StdLib/Lib/encodings/mac_centeuro.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/mac_croatian.py b/src/StdLib/Lib/encodings/mac_croatian.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/mac_croatian.py rename to src/StdLib/Lib/encodings/mac_croatian.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/mac_cyrillic.py b/src/StdLib/Lib/encodings/mac_cyrillic.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/mac_cyrillic.py rename to src/StdLib/Lib/encodings/mac_cyrillic.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/mac_farsi.py b/src/StdLib/Lib/encodings/mac_farsi.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/mac_farsi.py rename to src/StdLib/Lib/encodings/mac_farsi.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/mac_greek.py b/src/StdLib/Lib/encodings/mac_greek.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/mac_greek.py rename to src/StdLib/Lib/encodings/mac_greek.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/mac_iceland.py b/src/StdLib/Lib/encodings/mac_iceland.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/mac_iceland.py rename to src/StdLib/Lib/encodings/mac_iceland.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/mac_latin2.py b/src/StdLib/Lib/encodings/mac_latin2.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/mac_latin2.py rename to src/StdLib/Lib/encodings/mac_latin2.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/mac_roman.py b/src/StdLib/Lib/encodings/mac_roman.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/mac_roman.py rename to src/StdLib/Lib/encodings/mac_roman.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/mac_romanian.py b/src/StdLib/Lib/encodings/mac_romanian.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/mac_romanian.py rename to src/StdLib/Lib/encodings/mac_romanian.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/mac_turkish.py b/src/StdLib/Lib/encodings/mac_turkish.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/mac_turkish.py rename to src/StdLib/Lib/encodings/mac_turkish.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/mbcs.py b/src/StdLib/Lib/encodings/mbcs.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/mbcs.py rename to src/StdLib/Lib/encodings/mbcs.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/palmos.py b/src/StdLib/Lib/encodings/palmos.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/palmos.py rename to src/StdLib/Lib/encodings/palmos.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/ptcp154.py b/src/StdLib/Lib/encodings/ptcp154.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/ptcp154.py rename to src/StdLib/Lib/encodings/ptcp154.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/punycode.py b/src/StdLib/Lib/encodings/punycode.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/punycode.py rename to src/StdLib/Lib/encodings/punycode.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/quopri_codec.py b/src/StdLib/Lib/encodings/quopri_codec.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/quopri_codec.py rename to src/StdLib/Lib/encodings/quopri_codec.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/raw_unicode_escape.py b/src/StdLib/Lib/encodings/raw_unicode_escape.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/raw_unicode_escape.py rename to src/StdLib/Lib/encodings/raw_unicode_escape.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/rot_13.py b/src/StdLib/Lib/encodings/rot_13.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/rot_13.py rename to src/StdLib/Lib/encodings/rot_13.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/shift_jis.py b/src/StdLib/Lib/encodings/shift_jis.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/shift_jis.py rename to src/StdLib/Lib/encodings/shift_jis.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/shift_jis_2004.py b/src/StdLib/Lib/encodings/shift_jis_2004.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/shift_jis_2004.py rename to src/StdLib/Lib/encodings/shift_jis_2004.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/shift_jisx0213.py b/src/StdLib/Lib/encodings/shift_jisx0213.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/shift_jisx0213.py rename to src/StdLib/Lib/encodings/shift_jisx0213.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/tis_620.py b/src/StdLib/Lib/encodings/tis_620.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/tis_620.py rename to src/StdLib/Lib/encodings/tis_620.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/undefined.py b/src/StdLib/Lib/encodings/undefined.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/undefined.py rename to src/StdLib/Lib/encodings/undefined.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/unicode_escape.py b/src/StdLib/Lib/encodings/unicode_escape.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/unicode_escape.py rename to src/StdLib/Lib/encodings/unicode_escape.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/unicode_internal.py b/src/StdLib/Lib/encodings/unicode_internal.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/unicode_internal.py rename to src/StdLib/Lib/encodings/unicode_internal.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/utf_16.py b/src/StdLib/Lib/encodings/utf_16.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/utf_16.py rename to src/StdLib/Lib/encodings/utf_16.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/utf_16_be.py b/src/StdLib/Lib/encodings/utf_16_be.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/utf_16_be.py rename to src/StdLib/Lib/encodings/utf_16_be.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/utf_16_le.py b/src/StdLib/Lib/encodings/utf_16_le.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/utf_16_le.py rename to src/StdLib/Lib/encodings/utf_16_le.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/utf_32.py b/src/StdLib/Lib/encodings/utf_32.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/utf_32.py rename to src/StdLib/Lib/encodings/utf_32.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/utf_32_be.py b/src/StdLib/Lib/encodings/utf_32_be.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/utf_32_be.py rename to src/StdLib/Lib/encodings/utf_32_be.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/utf_32_le.py b/src/StdLib/Lib/encodings/utf_32_le.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/utf_32_le.py rename to src/StdLib/Lib/encodings/utf_32_le.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/utf_7.py b/src/StdLib/Lib/encodings/utf_7.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/utf_7.py rename to src/StdLib/Lib/encodings/utf_7.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/utf_8.py b/src/StdLib/Lib/encodings/utf_8.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/utf_8.py rename to src/StdLib/Lib/encodings/utf_8.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/utf_8_sig.py b/src/StdLib/Lib/encodings/utf_8_sig.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/utf_8_sig.py rename to src/StdLib/Lib/encodings/utf_8_sig.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/uu_codec.py b/src/StdLib/Lib/encodings/uu_codec.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/uu_codec.py rename to src/StdLib/Lib/encodings/uu_codec.py diff --git a/Src.GetRenamed/StdLib/Lib/encodings/zlib_codec.py b/src/StdLib/Lib/encodings/zlib_codec.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/encodings/zlib_codec.py rename to src/StdLib/Lib/encodings/zlib_codec.py diff --git a/Src.GetRenamed/StdLib/Lib/ensurepip/__init__.py b/src/StdLib/Lib/ensurepip/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ensurepip/__init__.py rename to src/StdLib/Lib/ensurepip/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/ensurepip/__main__.py b/src/StdLib/Lib/ensurepip/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ensurepip/__main__.py rename to src/StdLib/Lib/ensurepip/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl b/src/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl rename to src/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl diff --git a/Src.GetRenamed/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl b/src/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl rename to src/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl diff --git a/Src.GetRenamed/StdLib/Lib/ensurepip/_uninstall.py b/src/StdLib/Lib/ensurepip/_uninstall.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ensurepip/_uninstall.py rename to src/StdLib/Lib/ensurepip/_uninstall.py diff --git a/Src.GetRenamed/StdLib/Lib/enum.py b/src/StdLib/Lib/enum.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/enum.py rename to src/StdLib/Lib/enum.py diff --git a/Src.GetRenamed/StdLib/Lib/filecmp.py b/src/StdLib/Lib/filecmp.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/filecmp.py rename to src/StdLib/Lib/filecmp.py diff --git a/Src.GetRenamed/StdLib/Lib/fileinput.py b/src/StdLib/Lib/fileinput.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/fileinput.py rename to src/StdLib/Lib/fileinput.py diff --git a/Src.GetRenamed/StdLib/Lib/fnmatch.py b/src/StdLib/Lib/fnmatch.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/fnmatch.py rename to src/StdLib/Lib/fnmatch.py diff --git a/Src.GetRenamed/StdLib/Lib/formatter.py b/src/StdLib/Lib/formatter.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/formatter.py rename to src/StdLib/Lib/formatter.py diff --git a/Src.GetRenamed/StdLib/Lib/fractions.py b/src/StdLib/Lib/fractions.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/fractions.py rename to src/StdLib/Lib/fractions.py diff --git a/Src.GetRenamed/StdLib/Lib/ftplib.py b/src/StdLib/Lib/ftplib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ftplib.py rename to src/StdLib/Lib/ftplib.py diff --git a/Src.GetRenamed/StdLib/Lib/functools.py b/src/StdLib/Lib/functools.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/functools.py rename to src/StdLib/Lib/functools.py diff --git a/Src.GetRenamed/StdLib/Lib/genericpath.py b/src/StdLib/Lib/genericpath.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/genericpath.py rename to src/StdLib/Lib/genericpath.py diff --git a/Src.GetRenamed/StdLib/Lib/getopt.py b/src/StdLib/Lib/getopt.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/getopt.py rename to src/StdLib/Lib/getopt.py diff --git a/Src.GetRenamed/StdLib/Lib/getpass.py b/src/StdLib/Lib/getpass.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/getpass.py rename to src/StdLib/Lib/getpass.py diff --git a/Src.GetRenamed/StdLib/Lib/gettext.py b/src/StdLib/Lib/gettext.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/gettext.py rename to src/StdLib/Lib/gettext.py diff --git a/Src.GetRenamed/StdLib/Lib/glob.py b/src/StdLib/Lib/glob.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/glob.py rename to src/StdLib/Lib/glob.py diff --git a/Src.GetRenamed/StdLib/Lib/gzip.py b/src/StdLib/Lib/gzip.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/gzip.py rename to src/StdLib/Lib/gzip.py diff --git a/Src.GetRenamed/StdLib/Lib/hashlib.py b/src/StdLib/Lib/hashlib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/hashlib.py rename to src/StdLib/Lib/hashlib.py diff --git a/Src.GetRenamed/StdLib/Lib/heapq.py b/src/StdLib/Lib/heapq.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/heapq.py rename to src/StdLib/Lib/heapq.py diff --git a/Src.GetRenamed/StdLib/Lib/hmac.py b/src/StdLib/Lib/hmac.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/hmac.py rename to src/StdLib/Lib/hmac.py diff --git a/Src.GetRenamed/StdLib/Lib/html/__init__.py b/src/StdLib/Lib/html/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/html/__init__.py rename to src/StdLib/Lib/html/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/html/entities.py b/src/StdLib/Lib/html/entities.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/html/entities.py rename to src/StdLib/Lib/html/entities.py diff --git a/Src.GetRenamed/StdLib/Lib/html/parser.py b/src/StdLib/Lib/html/parser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/html/parser.py rename to src/StdLib/Lib/html/parser.py diff --git a/Src.GetRenamed/StdLib/Lib/http/__init__.py b/src/StdLib/Lib/http/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/http/__init__.py rename to src/StdLib/Lib/http/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/http/client.py b/src/StdLib/Lib/http/client.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/http/client.py rename to src/StdLib/Lib/http/client.py diff --git a/Src.GetRenamed/StdLib/Lib/http/cookiejar.py b/src/StdLib/Lib/http/cookiejar.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/http/cookiejar.py rename to src/StdLib/Lib/http/cookiejar.py diff --git a/Src.GetRenamed/StdLib/Lib/http/cookies.py b/src/StdLib/Lib/http/cookies.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/http/cookies.py rename to src/StdLib/Lib/http/cookies.py diff --git a/Src.GetRenamed/StdLib/Lib/http/server.py b/src/StdLib/Lib/http/server.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/http/server.py rename to src/StdLib/Lib/http/server.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/AutoComplete.py b/src/StdLib/Lib/idlelib/AutoComplete.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/AutoComplete.py rename to src/StdLib/Lib/idlelib/AutoComplete.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/AutoCompleteWindow.py b/src/StdLib/Lib/idlelib/AutoCompleteWindow.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/AutoCompleteWindow.py rename to src/StdLib/Lib/idlelib/AutoCompleteWindow.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/AutoExpand.py b/src/StdLib/Lib/idlelib/AutoExpand.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/AutoExpand.py rename to src/StdLib/Lib/idlelib/AutoExpand.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/Bindings.py b/src/StdLib/Lib/idlelib/Bindings.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/Bindings.py rename to src/StdLib/Lib/idlelib/Bindings.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/CREDITS.txt b/src/StdLib/Lib/idlelib/CREDITS.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/CREDITS.txt rename to src/StdLib/Lib/idlelib/CREDITS.txt diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/CallTipWindow.py b/src/StdLib/Lib/idlelib/CallTipWindow.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/CallTipWindow.py rename to src/StdLib/Lib/idlelib/CallTipWindow.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/CallTips.py b/src/StdLib/Lib/idlelib/CallTips.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/CallTips.py rename to src/StdLib/Lib/idlelib/CallTips.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/ChangeLog b/src/StdLib/Lib/idlelib/ChangeLog similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/ChangeLog rename to src/StdLib/Lib/idlelib/ChangeLog diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/ClassBrowser.py b/src/StdLib/Lib/idlelib/ClassBrowser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/ClassBrowser.py rename to src/StdLib/Lib/idlelib/ClassBrowser.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/CodeContext.py b/src/StdLib/Lib/idlelib/CodeContext.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/CodeContext.py rename to src/StdLib/Lib/idlelib/CodeContext.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/ColorDelegator.py b/src/StdLib/Lib/idlelib/ColorDelegator.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/ColorDelegator.py rename to src/StdLib/Lib/idlelib/ColorDelegator.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/Debugger.py b/src/StdLib/Lib/idlelib/Debugger.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/Debugger.py rename to src/StdLib/Lib/idlelib/Debugger.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/Delegator.py b/src/StdLib/Lib/idlelib/Delegator.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/Delegator.py rename to src/StdLib/Lib/idlelib/Delegator.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/EditorWindow.py b/src/StdLib/Lib/idlelib/EditorWindow.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/EditorWindow.py rename to src/StdLib/Lib/idlelib/EditorWindow.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/FileList.py b/src/StdLib/Lib/idlelib/FileList.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/FileList.py rename to src/StdLib/Lib/idlelib/FileList.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/FormatParagraph.py b/src/StdLib/Lib/idlelib/FormatParagraph.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/FormatParagraph.py rename to src/StdLib/Lib/idlelib/FormatParagraph.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/GrepDialog.py b/src/StdLib/Lib/idlelib/GrepDialog.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/GrepDialog.py rename to src/StdLib/Lib/idlelib/GrepDialog.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/HISTORY.txt b/src/StdLib/Lib/idlelib/HISTORY.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/HISTORY.txt rename to src/StdLib/Lib/idlelib/HISTORY.txt diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/HyperParser.py b/src/StdLib/Lib/idlelib/HyperParser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/HyperParser.py rename to src/StdLib/Lib/idlelib/HyperParser.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/IOBinding.py b/src/StdLib/Lib/idlelib/IOBinding.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/IOBinding.py rename to src/StdLib/Lib/idlelib/IOBinding.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/Icons/folder.gif b/src/StdLib/Lib/idlelib/Icons/folder.gif similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/Icons/folder.gif rename to src/StdLib/Lib/idlelib/Icons/folder.gif diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle.icns b/src/StdLib/Lib/idlelib/Icons/idle.icns similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle.icns rename to src/StdLib/Lib/idlelib/Icons/idle.icns diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle.ico b/src/StdLib/Lib/idlelib/Icons/idle.ico similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle.ico rename to src/StdLib/Lib/idlelib/Icons/idle.ico diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_16.gif b/src/StdLib/Lib/idlelib/Icons/idle_16.gif similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_16.gif rename to src/StdLib/Lib/idlelib/Icons/idle_16.gif diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_16.png b/src/StdLib/Lib/idlelib/Icons/idle_16.png similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_16.png rename to src/StdLib/Lib/idlelib/Icons/idle_16.png diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_32.gif b/src/StdLib/Lib/idlelib/Icons/idle_32.gif similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_32.gif rename to src/StdLib/Lib/idlelib/Icons/idle_32.gif diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_32.png b/src/StdLib/Lib/idlelib/Icons/idle_32.png similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_32.png rename to src/StdLib/Lib/idlelib/Icons/idle_32.png diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_48.gif b/src/StdLib/Lib/idlelib/Icons/idle_48.gif similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_48.gif rename to src/StdLib/Lib/idlelib/Icons/idle_48.gif diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_48.png b/src/StdLib/Lib/idlelib/Icons/idle_48.png similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/Icons/idle_48.png rename to src/StdLib/Lib/idlelib/Icons/idle_48.png diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/Icons/minusnode.gif b/src/StdLib/Lib/idlelib/Icons/minusnode.gif similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/Icons/minusnode.gif rename to src/StdLib/Lib/idlelib/Icons/minusnode.gif diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/Icons/openfolder.gif b/src/StdLib/Lib/idlelib/Icons/openfolder.gif similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/Icons/openfolder.gif rename to src/StdLib/Lib/idlelib/Icons/openfolder.gif diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/Icons/plusnode.gif b/src/StdLib/Lib/idlelib/Icons/plusnode.gif similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/Icons/plusnode.gif rename to src/StdLib/Lib/idlelib/Icons/plusnode.gif diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/Icons/python.gif b/src/StdLib/Lib/idlelib/Icons/python.gif similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/Icons/python.gif rename to src/StdLib/Lib/idlelib/Icons/python.gif diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/Icons/tk.gif b/src/StdLib/Lib/idlelib/Icons/tk.gif similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/Icons/tk.gif rename to src/StdLib/Lib/idlelib/Icons/tk.gif diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/IdleHistory.py b/src/StdLib/Lib/idlelib/IdleHistory.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/IdleHistory.py rename to src/StdLib/Lib/idlelib/IdleHistory.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/MultiCall.py b/src/StdLib/Lib/idlelib/MultiCall.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/MultiCall.py rename to src/StdLib/Lib/idlelib/MultiCall.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/MultiStatusBar.py b/src/StdLib/Lib/idlelib/MultiStatusBar.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/MultiStatusBar.py rename to src/StdLib/Lib/idlelib/MultiStatusBar.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/NEWS.txt b/src/StdLib/Lib/idlelib/NEWS.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/NEWS.txt rename to src/StdLib/Lib/idlelib/NEWS.txt diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/ObjectBrowser.py b/src/StdLib/Lib/idlelib/ObjectBrowser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/ObjectBrowser.py rename to src/StdLib/Lib/idlelib/ObjectBrowser.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/OutputWindow.py b/src/StdLib/Lib/idlelib/OutputWindow.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/OutputWindow.py rename to src/StdLib/Lib/idlelib/OutputWindow.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/ParenMatch.py b/src/StdLib/Lib/idlelib/ParenMatch.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/ParenMatch.py rename to src/StdLib/Lib/idlelib/ParenMatch.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/PathBrowser.py b/src/StdLib/Lib/idlelib/PathBrowser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/PathBrowser.py rename to src/StdLib/Lib/idlelib/PathBrowser.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/Percolator.py b/src/StdLib/Lib/idlelib/Percolator.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/Percolator.py rename to src/StdLib/Lib/idlelib/Percolator.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/PyParse.py b/src/StdLib/Lib/idlelib/PyParse.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/PyParse.py rename to src/StdLib/Lib/idlelib/PyParse.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/PyShell.py b/src/StdLib/Lib/idlelib/PyShell.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/PyShell.py rename to src/StdLib/Lib/idlelib/PyShell.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/README.txt b/src/StdLib/Lib/idlelib/README.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/README.txt rename to src/StdLib/Lib/idlelib/README.txt diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/RemoteDebugger.py b/src/StdLib/Lib/idlelib/RemoteDebugger.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/RemoteDebugger.py rename to src/StdLib/Lib/idlelib/RemoteDebugger.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/RemoteObjectBrowser.py b/src/StdLib/Lib/idlelib/RemoteObjectBrowser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/RemoteObjectBrowser.py rename to src/StdLib/Lib/idlelib/RemoteObjectBrowser.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/ReplaceDialog.py b/src/StdLib/Lib/idlelib/ReplaceDialog.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/ReplaceDialog.py rename to src/StdLib/Lib/idlelib/ReplaceDialog.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/RstripExtension.py b/src/StdLib/Lib/idlelib/RstripExtension.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/RstripExtension.py rename to src/StdLib/Lib/idlelib/RstripExtension.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/ScriptBinding.py b/src/StdLib/Lib/idlelib/ScriptBinding.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/ScriptBinding.py rename to src/StdLib/Lib/idlelib/ScriptBinding.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/ScrolledList.py b/src/StdLib/Lib/idlelib/ScrolledList.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/ScrolledList.py rename to src/StdLib/Lib/idlelib/ScrolledList.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/SearchDialog.py b/src/StdLib/Lib/idlelib/SearchDialog.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/SearchDialog.py rename to src/StdLib/Lib/idlelib/SearchDialog.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/SearchDialogBase.py b/src/StdLib/Lib/idlelib/SearchDialogBase.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/SearchDialogBase.py rename to src/StdLib/Lib/idlelib/SearchDialogBase.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/SearchEngine.py b/src/StdLib/Lib/idlelib/SearchEngine.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/SearchEngine.py rename to src/StdLib/Lib/idlelib/SearchEngine.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/StackViewer.py b/src/StdLib/Lib/idlelib/StackViewer.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/StackViewer.py rename to src/StdLib/Lib/idlelib/StackViewer.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/TODO.txt b/src/StdLib/Lib/idlelib/TODO.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/TODO.txt rename to src/StdLib/Lib/idlelib/TODO.txt diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/ToolTip.py b/src/StdLib/Lib/idlelib/ToolTip.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/ToolTip.py rename to src/StdLib/Lib/idlelib/ToolTip.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/TreeWidget.py b/src/StdLib/Lib/idlelib/TreeWidget.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/TreeWidget.py rename to src/StdLib/Lib/idlelib/TreeWidget.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/UndoDelegator.py b/src/StdLib/Lib/idlelib/UndoDelegator.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/UndoDelegator.py rename to src/StdLib/Lib/idlelib/UndoDelegator.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/WidgetRedirector.py b/src/StdLib/Lib/idlelib/WidgetRedirector.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/WidgetRedirector.py rename to src/StdLib/Lib/idlelib/WidgetRedirector.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/WindowList.py b/src/StdLib/Lib/idlelib/WindowList.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/WindowList.py rename to src/StdLib/Lib/idlelib/WindowList.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/ZoomHeight.py b/src/StdLib/Lib/idlelib/ZoomHeight.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/ZoomHeight.py rename to src/StdLib/Lib/idlelib/ZoomHeight.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/__init__.py b/src/StdLib/Lib/idlelib/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/__init__.py rename to src/StdLib/Lib/idlelib/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/__main__.py b/src/StdLib/Lib/idlelib/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/__main__.py rename to src/StdLib/Lib/idlelib/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/aboutDialog.py b/src/StdLib/Lib/idlelib/aboutDialog.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/aboutDialog.py rename to src/StdLib/Lib/idlelib/aboutDialog.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/config-extensions.def b/src/StdLib/Lib/idlelib/config-extensions.def similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/config-extensions.def rename to src/StdLib/Lib/idlelib/config-extensions.def diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/config-highlight.def b/src/StdLib/Lib/idlelib/config-highlight.def similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/config-highlight.def rename to src/StdLib/Lib/idlelib/config-highlight.def diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/config-keys.def b/src/StdLib/Lib/idlelib/config-keys.def similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/config-keys.def rename to src/StdLib/Lib/idlelib/config-keys.def diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/config-main.def b/src/StdLib/Lib/idlelib/config-main.def similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/config-main.def rename to src/StdLib/Lib/idlelib/config-main.def diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/configDialog.py b/src/StdLib/Lib/idlelib/configDialog.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/configDialog.py rename to src/StdLib/Lib/idlelib/configDialog.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/configHandler.py b/src/StdLib/Lib/idlelib/configHandler.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/configHandler.py rename to src/StdLib/Lib/idlelib/configHandler.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/configHelpSourceEdit.py b/src/StdLib/Lib/idlelib/configHelpSourceEdit.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/configHelpSourceEdit.py rename to src/StdLib/Lib/idlelib/configHelpSourceEdit.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/configSectionNameDialog.py b/src/StdLib/Lib/idlelib/configSectionNameDialog.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/configSectionNameDialog.py rename to src/StdLib/Lib/idlelib/configSectionNameDialog.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/dynOptionMenuWidget.py b/src/StdLib/Lib/idlelib/dynOptionMenuWidget.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/dynOptionMenuWidget.py rename to src/StdLib/Lib/idlelib/dynOptionMenuWidget.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/extend.txt b/src/StdLib/Lib/idlelib/extend.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/extend.txt rename to src/StdLib/Lib/idlelib/extend.txt diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/help.html b/src/StdLib/Lib/idlelib/help.html similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/help.html rename to src/StdLib/Lib/idlelib/help.html diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/help.py b/src/StdLib/Lib/idlelib/help.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/help.py rename to src/StdLib/Lib/idlelib/help.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/help.txt b/src/StdLib/Lib/idlelib/help.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/help.txt rename to src/StdLib/Lib/idlelib/help.txt diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle.bat b/src/StdLib/Lib/idlelib/idle.bat similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle.bat rename to src/StdLib/Lib/idlelib/idle.bat diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle.py b/src/StdLib/Lib/idlelib/idle.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle.py rename to src/StdLib/Lib/idlelib/idle.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle.pyw b/src/StdLib/Lib/idlelib/idle.pyw similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle.pyw rename to src/StdLib/Lib/idlelib/idle.pyw diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/README.txt b/src/StdLib/Lib/idlelib/idle_test/README.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/README.txt rename to src/StdLib/Lib/idlelib/idle_test/README.txt diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/__init__.py b/src/StdLib/Lib/idlelib/idle_test/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/__init__.py rename to src/StdLib/Lib/idlelib/idle_test/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/htest.py b/src/StdLib/Lib/idlelib/idle_test/htest.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/htest.py rename to src/StdLib/Lib/idlelib/idle_test/htest.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/mock_idle.py b/src/StdLib/Lib/idlelib/idle_test/mock_idle.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/mock_idle.py rename to src/StdLib/Lib/idlelib/idle_test/mock_idle.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/mock_tk.py b/src/StdLib/Lib/idlelib/idle_test/mock_tk.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/mock_tk.py rename to src/StdLib/Lib/idlelib/idle_test/mock_tk.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_autocomplete.py b/src/StdLib/Lib/idlelib/idle_test/test_autocomplete.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_autocomplete.py rename to src/StdLib/Lib/idlelib/idle_test/test_autocomplete.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_autoexpand.py b/src/StdLib/Lib/idlelib/idle_test/test_autoexpand.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_autoexpand.py rename to src/StdLib/Lib/idlelib/idle_test/test_autoexpand.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_calltips.py b/src/StdLib/Lib/idlelib/idle_test/test_calltips.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_calltips.py rename to src/StdLib/Lib/idlelib/idle_test/test_calltips.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_config_name.py b/src/StdLib/Lib/idlelib/idle_test/test_config_name.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_config_name.py rename to src/StdLib/Lib/idlelib/idle_test/test_config_name.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_configdialog.py b/src/StdLib/Lib/idlelib/idle_test/test_configdialog.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_configdialog.py rename to src/StdLib/Lib/idlelib/idle_test/test_configdialog.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_delegator.py b/src/StdLib/Lib/idlelib/idle_test/test_delegator.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_delegator.py rename to src/StdLib/Lib/idlelib/idle_test/test_delegator.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_editor.py b/src/StdLib/Lib/idlelib/idle_test/test_editor.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_editor.py rename to src/StdLib/Lib/idlelib/idle_test/test_editor.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py b/src/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py rename to src/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_grep.py b/src/StdLib/Lib/idlelib/idle_test/test_grep.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_grep.py rename to src/StdLib/Lib/idlelib/idle_test/test_grep.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_hyperparser.py b/src/StdLib/Lib/idlelib/idle_test/test_hyperparser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_hyperparser.py rename to src/StdLib/Lib/idlelib/idle_test/test_hyperparser.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_idlehistory.py b/src/StdLib/Lib/idlelib/idle_test/test_idlehistory.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_idlehistory.py rename to src/StdLib/Lib/idlelib/idle_test/test_idlehistory.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_io.py b/src/StdLib/Lib/idlelib/idle_test/test_io.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_io.py rename to src/StdLib/Lib/idlelib/idle_test/test_io.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_parenmatch.py b/src/StdLib/Lib/idlelib/idle_test/test_parenmatch.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_parenmatch.py rename to src/StdLib/Lib/idlelib/idle_test/test_parenmatch.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py b/src/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py rename to src/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_rstrip.py b/src/StdLib/Lib/idlelib/idle_test/test_rstrip.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_rstrip.py rename to src/StdLib/Lib/idlelib/idle_test/test_rstrip.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py b/src/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py rename to src/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_searchengine.py b/src/StdLib/Lib/idlelib/idle_test/test_searchengine.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_searchengine.py rename to src/StdLib/Lib/idlelib/idle_test/test_searchengine.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_text.py b/src/StdLib/Lib/idlelib/idle_test/test_text.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_text.py rename to src/StdLib/Lib/idlelib/idle_test/test_text.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_textview.py b/src/StdLib/Lib/idlelib/idle_test/test_textview.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_textview.py rename to src/StdLib/Lib/idlelib/idle_test/test_textview.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_warning.py b/src/StdLib/Lib/idlelib/idle_test/test_warning.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_warning.py rename to src/StdLib/Lib/idlelib/idle_test/test_warning.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_widgetredir.py b/src/StdLib/Lib/idlelib/idle_test/test_widgetredir.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idle_test/test_widgetredir.py rename to src/StdLib/Lib/idlelib/idle_test/test_widgetredir.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/idlever.py b/src/StdLib/Lib/idlelib/idlever.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/idlever.py rename to src/StdLib/Lib/idlelib/idlever.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/keybindingDialog.py b/src/StdLib/Lib/idlelib/keybindingDialog.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/keybindingDialog.py rename to src/StdLib/Lib/idlelib/keybindingDialog.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/macosxSupport.py b/src/StdLib/Lib/idlelib/macosxSupport.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/macosxSupport.py rename to src/StdLib/Lib/idlelib/macosxSupport.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/rpc.py b/src/StdLib/Lib/idlelib/rpc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/rpc.py rename to src/StdLib/Lib/idlelib/rpc.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/run.py b/src/StdLib/Lib/idlelib/run.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/run.py rename to src/StdLib/Lib/idlelib/run.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/tabbedpages.py b/src/StdLib/Lib/idlelib/tabbedpages.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/tabbedpages.py rename to src/StdLib/Lib/idlelib/tabbedpages.py diff --git a/Src.GetRenamed/StdLib/Lib/idlelib/textView.py b/src/StdLib/Lib/idlelib/textView.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/idlelib/textView.py rename to src/StdLib/Lib/idlelib/textView.py diff --git a/Src.GetRenamed/StdLib/Lib/imaplib.py b/src/StdLib/Lib/imaplib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/imaplib.py rename to src/StdLib/Lib/imaplib.py diff --git a/Src.GetRenamed/StdLib/Lib/imghdr.py b/src/StdLib/Lib/imghdr.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/imghdr.py rename to src/StdLib/Lib/imghdr.py diff --git a/Src.GetRenamed/StdLib/Lib/imp.py b/src/StdLib/Lib/imp.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/imp.py rename to src/StdLib/Lib/imp.py diff --git a/Src.GetRenamed/StdLib/Lib/importlib/__init__.py b/src/StdLib/Lib/importlib/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/importlib/__init__.py rename to src/StdLib/Lib/importlib/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/importlib/_bootstrap.py b/src/StdLib/Lib/importlib/_bootstrap.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/importlib/_bootstrap.py rename to src/StdLib/Lib/importlib/_bootstrap.py diff --git a/Src.GetRenamed/StdLib/Lib/importlib/abc.py b/src/StdLib/Lib/importlib/abc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/importlib/abc.py rename to src/StdLib/Lib/importlib/abc.py diff --git a/Src.GetRenamed/StdLib/Lib/importlib/machinery.py b/src/StdLib/Lib/importlib/machinery.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/importlib/machinery.py rename to src/StdLib/Lib/importlib/machinery.py diff --git a/Src.GetRenamed/StdLib/Lib/importlib/util.py b/src/StdLib/Lib/importlib/util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/importlib/util.py rename to src/StdLib/Lib/importlib/util.py diff --git a/Src.GetRenamed/StdLib/Lib/inspect.py b/src/StdLib/Lib/inspect.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/inspect.py rename to src/StdLib/Lib/inspect.py diff --git a/Src.GetRenamed/StdLib/Lib/io.py b/src/StdLib/Lib/io.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/io.py rename to src/StdLib/Lib/io.py diff --git a/Src.GetRenamed/StdLib/Lib/ipaddress.py b/src/StdLib/Lib/ipaddress.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ipaddress.py rename to src/StdLib/Lib/ipaddress.py diff --git a/Src.GetRenamed/StdLib/Lib/json/__init__.py b/src/StdLib/Lib/json/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/json/__init__.py rename to src/StdLib/Lib/json/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/json/decoder.py b/src/StdLib/Lib/json/decoder.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/json/decoder.py rename to src/StdLib/Lib/json/decoder.py diff --git a/Src.GetRenamed/StdLib/Lib/json/encoder.py b/src/StdLib/Lib/json/encoder.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/json/encoder.py rename to src/StdLib/Lib/json/encoder.py diff --git a/Src.GetRenamed/StdLib/Lib/json/scanner.py b/src/StdLib/Lib/json/scanner.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/json/scanner.py rename to src/StdLib/Lib/json/scanner.py diff --git a/Src.GetRenamed/StdLib/Lib/json/tool.py b/src/StdLib/Lib/json/tool.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/json/tool.py rename to src/StdLib/Lib/json/tool.py diff --git a/Src.GetRenamed/StdLib/Lib/keyword.py b/src/StdLib/Lib/keyword.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/keyword.py rename to src/StdLib/Lib/keyword.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/Grammar.txt b/src/StdLib/Lib/lib2to3/Grammar.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/Grammar.txt rename to src/StdLib/Lib/lib2to3/Grammar.txt diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/PatternGrammar.txt b/src/StdLib/Lib/lib2to3/PatternGrammar.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/PatternGrammar.txt rename to src/StdLib/Lib/lib2to3/PatternGrammar.txt diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/__init__.py b/src/StdLib/Lib/lib2to3/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/__init__.py rename to src/StdLib/Lib/lib2to3/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/__main__.py b/src/StdLib/Lib/lib2to3/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/__main__.py rename to src/StdLib/Lib/lib2to3/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/btm_matcher.py b/src/StdLib/Lib/lib2to3/btm_matcher.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/btm_matcher.py rename to src/StdLib/Lib/lib2to3/btm_matcher.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/btm_utils.py b/src/StdLib/Lib/lib2to3/btm_utils.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/btm_utils.py rename to src/StdLib/Lib/lib2to3/btm_utils.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixer_base.py b/src/StdLib/Lib/lib2to3/fixer_base.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixer_base.py rename to src/StdLib/Lib/lib2to3/fixer_base.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixer_util.py b/src/StdLib/Lib/lib2to3/fixer_util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixer_util.py rename to src/StdLib/Lib/lib2to3/fixer_util.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/__init__.py b/src/StdLib/Lib/lib2to3/fixes/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/__init__.py rename to src/StdLib/Lib/lib2to3/fixes/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_apply.py b/src/StdLib/Lib/lib2to3/fixes/fix_apply.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_apply.py rename to src/StdLib/Lib/lib2to3/fixes/fix_apply.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_asserts.py b/src/StdLib/Lib/lib2to3/fixes/fix_asserts.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_asserts.py rename to src/StdLib/Lib/lib2to3/fixes/fix_asserts.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_basestring.py b/src/StdLib/Lib/lib2to3/fixes/fix_basestring.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_basestring.py rename to src/StdLib/Lib/lib2to3/fixes/fix_basestring.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_buffer.py b/src/StdLib/Lib/lib2to3/fixes/fix_buffer.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_buffer.py rename to src/StdLib/Lib/lib2to3/fixes/fix_buffer.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_callable.py b/src/StdLib/Lib/lib2to3/fixes/fix_callable.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_callable.py rename to src/StdLib/Lib/lib2to3/fixes/fix_callable.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_dict.py b/src/StdLib/Lib/lib2to3/fixes/fix_dict.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_dict.py rename to src/StdLib/Lib/lib2to3/fixes/fix_dict.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_except.py b/src/StdLib/Lib/lib2to3/fixes/fix_except.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_except.py rename to src/StdLib/Lib/lib2to3/fixes/fix_except.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_exec.py b/src/StdLib/Lib/lib2to3/fixes/fix_exec.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_exec.py rename to src/StdLib/Lib/lib2to3/fixes/fix_exec.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_execfile.py b/src/StdLib/Lib/lib2to3/fixes/fix_execfile.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_execfile.py rename to src/StdLib/Lib/lib2to3/fixes/fix_execfile.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py b/src/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py rename to src/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_filter.py b/src/StdLib/Lib/lib2to3/fixes/fix_filter.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_filter.py rename to src/StdLib/Lib/lib2to3/fixes/fix_filter.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py b/src/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py rename to src/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_future.py b/src/StdLib/Lib/lib2to3/fixes/fix_future.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_future.py rename to src/StdLib/Lib/lib2to3/fixes/fix_future.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py b/src/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py rename to src/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_has_key.py b/src/StdLib/Lib/lib2to3/fixes/fix_has_key.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_has_key.py rename to src/StdLib/Lib/lib2to3/fixes/fix_has_key.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_idioms.py b/src/StdLib/Lib/lib2to3/fixes/fix_idioms.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_idioms.py rename to src/StdLib/Lib/lib2to3/fixes/fix_idioms.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_import.py b/src/StdLib/Lib/lib2to3/fixes/fix_import.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_import.py rename to src/StdLib/Lib/lib2to3/fixes/fix_import.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_imports.py b/src/StdLib/Lib/lib2to3/fixes/fix_imports.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_imports.py rename to src/StdLib/Lib/lib2to3/fixes/fix_imports.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_imports2.py b/src/StdLib/Lib/lib2to3/fixes/fix_imports2.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_imports2.py rename to src/StdLib/Lib/lib2to3/fixes/fix_imports2.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_input.py b/src/StdLib/Lib/lib2to3/fixes/fix_input.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_input.py rename to src/StdLib/Lib/lib2to3/fixes/fix_input.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_intern.py b/src/StdLib/Lib/lib2to3/fixes/fix_intern.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_intern.py rename to src/StdLib/Lib/lib2to3/fixes/fix_intern.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_isinstance.py b/src/StdLib/Lib/lib2to3/fixes/fix_isinstance.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_isinstance.py rename to src/StdLib/Lib/lib2to3/fixes/fix_isinstance.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_itertools.py b/src/StdLib/Lib/lib2to3/fixes/fix_itertools.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_itertools.py rename to src/StdLib/Lib/lib2to3/fixes/fix_itertools.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py b/src/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py rename to src/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_long.py b/src/StdLib/Lib/lib2to3/fixes/fix_long.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_long.py rename to src/StdLib/Lib/lib2to3/fixes/fix_long.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_map.py b/src/StdLib/Lib/lib2to3/fixes/fix_map.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_map.py rename to src/StdLib/Lib/lib2to3/fixes/fix_map.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_metaclass.py b/src/StdLib/Lib/lib2to3/fixes/fix_metaclass.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_metaclass.py rename to src/StdLib/Lib/lib2to3/fixes/fix_metaclass.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py b/src/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py rename to src/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_ne.py b/src/StdLib/Lib/lib2to3/fixes/fix_ne.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_ne.py rename to src/StdLib/Lib/lib2to3/fixes/fix_ne.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_next.py b/src/StdLib/Lib/lib2to3/fixes/fix_next.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_next.py rename to src/StdLib/Lib/lib2to3/fixes/fix_next.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_nonzero.py b/src/StdLib/Lib/lib2to3/fixes/fix_nonzero.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_nonzero.py rename to src/StdLib/Lib/lib2to3/fixes/fix_nonzero.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_numliterals.py b/src/StdLib/Lib/lib2to3/fixes/fix_numliterals.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_numliterals.py rename to src/StdLib/Lib/lib2to3/fixes/fix_numliterals.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_operator.py b/src/StdLib/Lib/lib2to3/fixes/fix_operator.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_operator.py rename to src/StdLib/Lib/lib2to3/fixes/fix_operator.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_paren.py b/src/StdLib/Lib/lib2to3/fixes/fix_paren.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_paren.py rename to src/StdLib/Lib/lib2to3/fixes/fix_paren.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_print.py b/src/StdLib/Lib/lib2to3/fixes/fix_print.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_print.py rename to src/StdLib/Lib/lib2to3/fixes/fix_print.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_raise.py b/src/StdLib/Lib/lib2to3/fixes/fix_raise.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_raise.py rename to src/StdLib/Lib/lib2to3/fixes/fix_raise.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_raw_input.py b/src/StdLib/Lib/lib2to3/fixes/fix_raw_input.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_raw_input.py rename to src/StdLib/Lib/lib2to3/fixes/fix_raw_input.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_reduce.py b/src/StdLib/Lib/lib2to3/fixes/fix_reduce.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_reduce.py rename to src/StdLib/Lib/lib2to3/fixes/fix_reduce.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_reload.py b/src/StdLib/Lib/lib2to3/fixes/fix_reload.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_reload.py rename to src/StdLib/Lib/lib2to3/fixes/fix_reload.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_renames.py b/src/StdLib/Lib/lib2to3/fixes/fix_renames.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_renames.py rename to src/StdLib/Lib/lib2to3/fixes/fix_renames.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_repr.py b/src/StdLib/Lib/lib2to3/fixes/fix_repr.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_repr.py rename to src/StdLib/Lib/lib2to3/fixes/fix_repr.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_set_literal.py b/src/StdLib/Lib/lib2to3/fixes/fix_set_literal.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_set_literal.py rename to src/StdLib/Lib/lib2to3/fixes/fix_set_literal.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_standarderror.py b/src/StdLib/Lib/lib2to3/fixes/fix_standarderror.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_standarderror.py rename to src/StdLib/Lib/lib2to3/fixes/fix_standarderror.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py b/src/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py rename to src/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_throw.py b/src/StdLib/Lib/lib2to3/fixes/fix_throw.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_throw.py rename to src/StdLib/Lib/lib2to3/fixes/fix_throw.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py b/src/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py rename to src/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_types.py b/src/StdLib/Lib/lib2to3/fixes/fix_types.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_types.py rename to src/StdLib/Lib/lib2to3/fixes/fix_types.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_unicode.py b/src/StdLib/Lib/lib2to3/fixes/fix_unicode.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_unicode.py rename to src/StdLib/Lib/lib2to3/fixes/fix_unicode.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_urllib.py b/src/StdLib/Lib/lib2to3/fixes/fix_urllib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_urllib.py rename to src/StdLib/Lib/lib2to3/fixes/fix_urllib.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py b/src/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py rename to src/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_xrange.py b/src/StdLib/Lib/lib2to3/fixes/fix_xrange.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_xrange.py rename to src/StdLib/Lib/lib2to3/fixes/fix_xrange.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py b/src/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py rename to src/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_zip.py b/src/StdLib/Lib/lib2to3/fixes/fix_zip.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/fixes/fix_zip.py rename to src/StdLib/Lib/lib2to3/fixes/fix_zip.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/main.py b/src/StdLib/Lib/lib2to3/main.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/main.py rename to src/StdLib/Lib/lib2to3/main.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/patcomp.py b/src/StdLib/Lib/lib2to3/patcomp.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/patcomp.py rename to src/StdLib/Lib/lib2to3/patcomp.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/__init__.py b/src/StdLib/Lib/lib2to3/pgen2/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/__init__.py rename to src/StdLib/Lib/lib2to3/pgen2/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/conv.py b/src/StdLib/Lib/lib2to3/pgen2/conv.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/conv.py rename to src/StdLib/Lib/lib2to3/pgen2/conv.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/driver.py b/src/StdLib/Lib/lib2to3/pgen2/driver.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/driver.py rename to src/StdLib/Lib/lib2to3/pgen2/driver.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/grammar.py b/src/StdLib/Lib/lib2to3/pgen2/grammar.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/grammar.py rename to src/StdLib/Lib/lib2to3/pgen2/grammar.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/literals.py b/src/StdLib/Lib/lib2to3/pgen2/literals.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/literals.py rename to src/StdLib/Lib/lib2to3/pgen2/literals.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/parse.py b/src/StdLib/Lib/lib2to3/pgen2/parse.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/parse.py rename to src/StdLib/Lib/lib2to3/pgen2/parse.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/pgen.py b/src/StdLib/Lib/lib2to3/pgen2/pgen.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/pgen.py rename to src/StdLib/Lib/lib2to3/pgen2/pgen.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/token.py b/src/StdLib/Lib/lib2to3/pgen2/token.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/token.py rename to src/StdLib/Lib/lib2to3/pgen2/token.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/tokenize.py b/src/StdLib/Lib/lib2to3/pgen2/tokenize.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/pgen2/tokenize.py rename to src/StdLib/Lib/lib2to3/pgen2/tokenize.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/pygram.py b/src/StdLib/Lib/lib2to3/pygram.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/pygram.py rename to src/StdLib/Lib/lib2to3/pygram.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/pytree.py b/src/StdLib/Lib/lib2to3/pytree.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/pytree.py rename to src/StdLib/Lib/lib2to3/pytree.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/refactor.py b/src/StdLib/Lib/lib2to3/refactor.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/refactor.py rename to src/StdLib/Lib/lib2to3/refactor.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/__init__.py b/src/StdLib/Lib/lib2to3/tests/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/__init__.py rename to src/StdLib/Lib/lib2to3/tests/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/__main__.py b/src/StdLib/Lib/lib2to3/tests/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/__main__.py rename to src/StdLib/Lib/lib2to3/tests/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/README b/src/StdLib/Lib/lib2to3/tests/data/README similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/README rename to src/StdLib/Lib/lib2to3/tests/data/README diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/bom.py b/src/StdLib/Lib/lib2to3/tests/data/bom.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/bom.py rename to src/StdLib/Lib/lib2to3/tests/data/bom.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/crlf.py b/src/StdLib/Lib/lib2to3/tests/data/crlf.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/crlf.py rename to src/StdLib/Lib/lib2to3/tests/data/crlf.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/different_encoding.py b/src/StdLib/Lib/lib2to3/tests/data/different_encoding.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/different_encoding.py rename to src/StdLib/Lib/lib2to3/tests/data/different_encoding.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/false_encoding.py b/src/StdLib/Lib/lib2to3/tests/data/false_encoding.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/false_encoding.py rename to src/StdLib/Lib/lib2to3/tests/data/false_encoding.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py b/src/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py rename to src/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py b/src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py rename to src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py b/src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py rename to src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py b/src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py rename to src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py b/src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py rename to src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py b/src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py rename to src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py b/src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py rename to src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py b/src/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py rename to src/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py b/src/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py rename to src/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py b/src/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py rename to src/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py b/src/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py rename to src/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py b/src/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py rename to src/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/pytree_idempotency.py b/src/StdLib/Lib/lib2to3/tests/pytree_idempotency.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/pytree_idempotency.py rename to src/StdLib/Lib/lib2to3/tests/pytree_idempotency.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/support.py b/src/StdLib/Lib/lib2to3/tests/support.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/support.py rename to src/StdLib/Lib/lib2to3/tests/support.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_all_fixers.py b/src/StdLib/Lib/lib2to3/tests/test_all_fixers.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_all_fixers.py rename to src/StdLib/Lib/lib2to3/tests/test_all_fixers.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_fixers.py b/src/StdLib/Lib/lib2to3/tests/test_fixers.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_fixers.py rename to src/StdLib/Lib/lib2to3/tests/test_fixers.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_main.py b/src/StdLib/Lib/lib2to3/tests/test_main.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_main.py rename to src/StdLib/Lib/lib2to3/tests/test_main.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_parser.py b/src/StdLib/Lib/lib2to3/tests/test_parser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_parser.py rename to src/StdLib/Lib/lib2to3/tests/test_parser.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_pytree.py b/src/StdLib/Lib/lib2to3/tests/test_pytree.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_pytree.py rename to src/StdLib/Lib/lib2to3/tests/test_pytree.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_refactor.py b/src/StdLib/Lib/lib2to3/tests/test_refactor.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_refactor.py rename to src/StdLib/Lib/lib2to3/tests/test_refactor.py diff --git a/Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_util.py b/src/StdLib/Lib/lib2to3/tests/test_util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lib2to3/tests/test_util.py rename to src/StdLib/Lib/lib2to3/tests/test_util.py diff --git a/Src.GetRenamed/StdLib/Lib/linecache.py b/src/StdLib/Lib/linecache.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/linecache.py rename to src/StdLib/Lib/linecache.py diff --git a/Src.GetRenamed/StdLib/Lib/locale.py b/src/StdLib/Lib/locale.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/locale.py rename to src/StdLib/Lib/locale.py diff --git a/Src.GetRenamed/StdLib/Lib/logging/__init__.py b/src/StdLib/Lib/logging/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/logging/__init__.py rename to src/StdLib/Lib/logging/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/logging/config.py b/src/StdLib/Lib/logging/config.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/logging/config.py rename to src/StdLib/Lib/logging/config.py diff --git a/Src.GetRenamed/StdLib/Lib/logging/handlers.py b/src/StdLib/Lib/logging/handlers.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/logging/handlers.py rename to src/StdLib/Lib/logging/handlers.py diff --git a/Src.GetRenamed/StdLib/Lib/lzma.py b/src/StdLib/Lib/lzma.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/lzma.py rename to src/StdLib/Lib/lzma.py diff --git a/Src.GetRenamed/StdLib/Lib/macpath.py b/src/StdLib/Lib/macpath.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/macpath.py rename to src/StdLib/Lib/macpath.py diff --git a/Src.GetRenamed/StdLib/Lib/macurl2path.py b/src/StdLib/Lib/macurl2path.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/macurl2path.py rename to src/StdLib/Lib/macurl2path.py diff --git a/Src.GetRenamed/StdLib/Lib/mailbox.py b/src/StdLib/Lib/mailbox.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/mailbox.py rename to src/StdLib/Lib/mailbox.py diff --git a/Src.GetRenamed/StdLib/Lib/mailcap.py b/src/StdLib/Lib/mailcap.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/mailcap.py rename to src/StdLib/Lib/mailcap.py diff --git a/Src.GetRenamed/StdLib/Lib/mimetypes.py b/src/StdLib/Lib/mimetypes.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/mimetypes.py rename to src/StdLib/Lib/mimetypes.py diff --git a/Src.GetRenamed/StdLib/Lib/modulefinder.py b/src/StdLib/Lib/modulefinder.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/modulefinder.py rename to src/StdLib/Lib/modulefinder.py diff --git a/Src.GetRenamed/StdLib/Lib/msilib/__init__.py b/src/StdLib/Lib/msilib/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/msilib/__init__.py rename to src/StdLib/Lib/msilib/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/msilib/schema.py b/src/StdLib/Lib/msilib/schema.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/msilib/schema.py rename to src/StdLib/Lib/msilib/schema.py diff --git a/Src.GetRenamed/StdLib/Lib/msilib/sequence.py b/src/StdLib/Lib/msilib/sequence.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/msilib/sequence.py rename to src/StdLib/Lib/msilib/sequence.py diff --git a/Src.GetRenamed/StdLib/Lib/msilib/text.py b/src/StdLib/Lib/msilib/text.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/msilib/text.py rename to src/StdLib/Lib/msilib/text.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/__init__.py b/src/StdLib/Lib/multiprocessing/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/__init__.py rename to src/StdLib/Lib/multiprocessing/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/connection.py b/src/StdLib/Lib/multiprocessing/connection.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/connection.py rename to src/StdLib/Lib/multiprocessing/connection.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/context.py b/src/StdLib/Lib/multiprocessing/context.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/context.py rename to src/StdLib/Lib/multiprocessing/context.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/dummy/__init__.py b/src/StdLib/Lib/multiprocessing/dummy/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/dummy/__init__.py rename to src/StdLib/Lib/multiprocessing/dummy/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/dummy/connection.py b/src/StdLib/Lib/multiprocessing/dummy/connection.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/dummy/connection.py rename to src/StdLib/Lib/multiprocessing/dummy/connection.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/forkserver.py b/src/StdLib/Lib/multiprocessing/forkserver.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/forkserver.py rename to src/StdLib/Lib/multiprocessing/forkserver.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/heap.py b/src/StdLib/Lib/multiprocessing/heap.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/heap.py rename to src/StdLib/Lib/multiprocessing/heap.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/managers.py b/src/StdLib/Lib/multiprocessing/managers.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/managers.py rename to src/StdLib/Lib/multiprocessing/managers.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/pool.py b/src/StdLib/Lib/multiprocessing/pool.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/pool.py rename to src/StdLib/Lib/multiprocessing/pool.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/popen_fork.py b/src/StdLib/Lib/multiprocessing/popen_fork.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/popen_fork.py rename to src/StdLib/Lib/multiprocessing/popen_fork.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/popen_forkserver.py b/src/StdLib/Lib/multiprocessing/popen_forkserver.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/popen_forkserver.py rename to src/StdLib/Lib/multiprocessing/popen_forkserver.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/popen_spawn_posix.py b/src/StdLib/Lib/multiprocessing/popen_spawn_posix.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/popen_spawn_posix.py rename to src/StdLib/Lib/multiprocessing/popen_spawn_posix.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/popen_spawn_win32.py b/src/StdLib/Lib/multiprocessing/popen_spawn_win32.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/popen_spawn_win32.py rename to src/StdLib/Lib/multiprocessing/popen_spawn_win32.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/process.py b/src/StdLib/Lib/multiprocessing/process.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/process.py rename to src/StdLib/Lib/multiprocessing/process.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/queues.py b/src/StdLib/Lib/multiprocessing/queues.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/queues.py rename to src/StdLib/Lib/multiprocessing/queues.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/reduction.py b/src/StdLib/Lib/multiprocessing/reduction.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/reduction.py rename to src/StdLib/Lib/multiprocessing/reduction.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/resource_sharer.py b/src/StdLib/Lib/multiprocessing/resource_sharer.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/resource_sharer.py rename to src/StdLib/Lib/multiprocessing/resource_sharer.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/semaphore_tracker.py b/src/StdLib/Lib/multiprocessing/semaphore_tracker.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/semaphore_tracker.py rename to src/StdLib/Lib/multiprocessing/semaphore_tracker.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/sharedctypes.py b/src/StdLib/Lib/multiprocessing/sharedctypes.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/sharedctypes.py rename to src/StdLib/Lib/multiprocessing/sharedctypes.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/spawn.py b/src/StdLib/Lib/multiprocessing/spawn.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/spawn.py rename to src/StdLib/Lib/multiprocessing/spawn.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/synchronize.py b/src/StdLib/Lib/multiprocessing/synchronize.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/synchronize.py rename to src/StdLib/Lib/multiprocessing/synchronize.py diff --git a/Src.GetRenamed/StdLib/Lib/multiprocessing/util.py b/src/StdLib/Lib/multiprocessing/util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/multiprocessing/util.py rename to src/StdLib/Lib/multiprocessing/util.py diff --git a/Src.GetRenamed/StdLib/Lib/netrc.py b/src/StdLib/Lib/netrc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/netrc.py rename to src/StdLib/Lib/netrc.py diff --git a/Src.GetRenamed/StdLib/Lib/nntplib.py b/src/StdLib/Lib/nntplib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/nntplib.py rename to src/StdLib/Lib/nntplib.py diff --git a/Src.GetRenamed/StdLib/Lib/ntpath.py b/src/StdLib/Lib/ntpath.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ntpath.py rename to src/StdLib/Lib/ntpath.py diff --git a/Src.GetRenamed/StdLib/Lib/nturl2path.py b/src/StdLib/Lib/nturl2path.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/nturl2path.py rename to src/StdLib/Lib/nturl2path.py diff --git a/Src.GetRenamed/StdLib/Lib/numbers.py b/src/StdLib/Lib/numbers.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/numbers.py rename to src/StdLib/Lib/numbers.py diff --git a/Src.GetRenamed/StdLib/Lib/opcode.py b/src/StdLib/Lib/opcode.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/opcode.py rename to src/StdLib/Lib/opcode.py diff --git a/Src.GetRenamed/StdLib/Lib/operator.py b/src/StdLib/Lib/operator.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/operator.py rename to src/StdLib/Lib/operator.py diff --git a/Src.GetRenamed/StdLib/Lib/optparse.py b/src/StdLib/Lib/optparse.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/optparse.py rename to src/StdLib/Lib/optparse.py diff --git a/Src.GetRenamed/StdLib/Lib/os.py b/src/StdLib/Lib/os.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/os.py rename to src/StdLib/Lib/os.py diff --git a/Src.GetRenamed/StdLib/Lib/pathlib.py b/src/StdLib/Lib/pathlib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/pathlib.py rename to src/StdLib/Lib/pathlib.py diff --git a/Src.GetRenamed/StdLib/Lib/pdb.py b/src/StdLib/Lib/pdb.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/pdb.py rename to src/StdLib/Lib/pdb.py diff --git a/Src.GetRenamed/StdLib/Lib/pickle.py b/src/StdLib/Lib/pickle.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/pickle.py rename to src/StdLib/Lib/pickle.py diff --git a/Src.GetRenamed/StdLib/Lib/pickletools.py b/src/StdLib/Lib/pickletools.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/pickletools.py rename to src/StdLib/Lib/pickletools.py diff --git a/Src.GetRenamed/StdLib/Lib/pipes.py b/src/StdLib/Lib/pipes.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/pipes.py rename to src/StdLib/Lib/pipes.py diff --git a/Src.GetRenamed/StdLib/Lib/pkgutil.py b/src/StdLib/Lib/pkgutil.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/pkgutil.py rename to src/StdLib/Lib/pkgutil.py diff --git a/Src.GetRenamed/StdLib/Lib/platform.py b/src/StdLib/Lib/platform.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/platform.py rename to src/StdLib/Lib/platform.py diff --git a/Src.GetRenamed/StdLib/Lib/plistlib.py b/src/StdLib/Lib/plistlib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/plistlib.py rename to src/StdLib/Lib/plistlib.py diff --git a/Src.GetRenamed/StdLib/Lib/poplib.py b/src/StdLib/Lib/poplib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/poplib.py rename to src/StdLib/Lib/poplib.py diff --git a/Src.GetRenamed/StdLib/Lib/posixpath.py b/src/StdLib/Lib/posixpath.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/posixpath.py rename to src/StdLib/Lib/posixpath.py diff --git a/Src.GetRenamed/StdLib/Lib/pprint.py b/src/StdLib/Lib/pprint.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/pprint.py rename to src/StdLib/Lib/pprint.py diff --git a/Src.GetRenamed/StdLib/Lib/profile.py b/src/StdLib/Lib/profile.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/profile.py rename to src/StdLib/Lib/profile.py diff --git a/Src.GetRenamed/StdLib/Lib/pstats.py b/src/StdLib/Lib/pstats.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/pstats.py rename to src/StdLib/Lib/pstats.py diff --git a/Src.GetRenamed/StdLib/Lib/pty.py b/src/StdLib/Lib/pty.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/pty.py rename to src/StdLib/Lib/pty.py diff --git a/Src.GetRenamed/StdLib/Lib/py_compile.py b/src/StdLib/Lib/py_compile.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/py_compile.py rename to src/StdLib/Lib/py_compile.py diff --git a/Src.GetRenamed/StdLib/Lib/pyclbr.py b/src/StdLib/Lib/pyclbr.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/pyclbr.py rename to src/StdLib/Lib/pyclbr.py diff --git a/Src.GetRenamed/StdLib/Lib/pydoc.py b/src/StdLib/Lib/pydoc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/pydoc.py rename to src/StdLib/Lib/pydoc.py diff --git a/Src.GetRenamed/StdLib/Lib/pydoc_data/__init__.py b/src/StdLib/Lib/pydoc_data/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/pydoc_data/__init__.py rename to src/StdLib/Lib/pydoc_data/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/pydoc_data/_pydoc.css b/src/StdLib/Lib/pydoc_data/_pydoc.css similarity index 100% rename from Src.GetRenamed/StdLib/Lib/pydoc_data/_pydoc.css rename to src/StdLib/Lib/pydoc_data/_pydoc.css diff --git a/Src.GetRenamed/StdLib/Lib/pydoc_data/topics.py b/src/StdLib/Lib/pydoc_data/topics.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/pydoc_data/topics.py rename to src/StdLib/Lib/pydoc_data/topics.py diff --git a/Src.GetRenamed/StdLib/Lib/queue.py b/src/StdLib/Lib/queue.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/queue.py rename to src/StdLib/Lib/queue.py diff --git a/Src.GetRenamed/StdLib/Lib/quopri.py b/src/StdLib/Lib/quopri.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/quopri.py rename to src/StdLib/Lib/quopri.py diff --git a/Src.GetRenamed/StdLib/Lib/random.py b/src/StdLib/Lib/random.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/random.py rename to src/StdLib/Lib/random.py diff --git a/Src.GetRenamed/StdLib/Lib/re.py b/src/StdLib/Lib/re.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/re.py rename to src/StdLib/Lib/re.py diff --git a/Src.GetRenamed/StdLib/Lib/reprlib.py b/src/StdLib/Lib/reprlib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/reprlib.py rename to src/StdLib/Lib/reprlib.py diff --git a/Src.GetRenamed/StdLib/Lib/rlcompleter.py b/src/StdLib/Lib/rlcompleter.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/rlcompleter.py rename to src/StdLib/Lib/rlcompleter.py diff --git a/Src.GetRenamed/StdLib/Lib/runpy.py b/src/StdLib/Lib/runpy.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/runpy.py rename to src/StdLib/Lib/runpy.py diff --git a/Src.GetRenamed/StdLib/Lib/sched.py b/src/StdLib/Lib/sched.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/sched.py rename to src/StdLib/Lib/sched.py diff --git a/Src.GetRenamed/StdLib/Lib/selectors.py b/src/StdLib/Lib/selectors.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/selectors.py rename to src/StdLib/Lib/selectors.py diff --git a/Src.GetRenamed/StdLib/Lib/shelve.py b/src/StdLib/Lib/shelve.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/shelve.py rename to src/StdLib/Lib/shelve.py diff --git a/Src.GetRenamed/StdLib/Lib/shlex.py b/src/StdLib/Lib/shlex.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/shlex.py rename to src/StdLib/Lib/shlex.py diff --git a/Src.GetRenamed/StdLib/Lib/shutil.py b/src/StdLib/Lib/shutil.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/shutil.py rename to src/StdLib/Lib/shutil.py diff --git a/Src.GetRenamed/StdLib/Lib/site-packages/README b/src/StdLib/Lib/site-packages/README similarity index 100% rename from Src.GetRenamed/StdLib/Lib/site-packages/README rename to src/StdLib/Lib/site-packages/README diff --git a/Src.GetRenamed/StdLib/Lib/site.py b/src/StdLib/Lib/site.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/site.py rename to src/StdLib/Lib/site.py diff --git a/Src.GetRenamed/StdLib/Lib/smtpd.py b/src/StdLib/Lib/smtpd.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/smtpd.py rename to src/StdLib/Lib/smtpd.py diff --git a/Src.GetRenamed/StdLib/Lib/smtplib.py b/src/StdLib/Lib/smtplib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/smtplib.py rename to src/StdLib/Lib/smtplib.py diff --git a/Src.GetRenamed/StdLib/Lib/sndhdr.py b/src/StdLib/Lib/sndhdr.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/sndhdr.py rename to src/StdLib/Lib/sndhdr.py diff --git a/Src.GetRenamed/StdLib/Lib/socket.py b/src/StdLib/Lib/socket.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/socket.py rename to src/StdLib/Lib/socket.py diff --git a/Src.GetRenamed/StdLib/Lib/socketserver.py b/src/StdLib/Lib/socketserver.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/socketserver.py rename to src/StdLib/Lib/socketserver.py diff --git a/Src.GetRenamed/StdLib/Lib/sqlite3/__init__.py b/src/StdLib/Lib/sqlite3/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/sqlite3/__init__.py rename to src/StdLib/Lib/sqlite3/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/sqlite3/dbapi2.py b/src/StdLib/Lib/sqlite3/dbapi2.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/sqlite3/dbapi2.py rename to src/StdLib/Lib/sqlite3/dbapi2.py diff --git a/Src.GetRenamed/StdLib/Lib/sqlite3/dump.py b/src/StdLib/Lib/sqlite3/dump.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/sqlite3/dump.py rename to src/StdLib/Lib/sqlite3/dump.py diff --git a/Src.GetRenamed/StdLib/Lib/sqlite3/test/__init__.py b/src/StdLib/Lib/sqlite3/test/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/sqlite3/test/__init__.py rename to src/StdLib/Lib/sqlite3/test/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/sqlite3/test/dbapi.py b/src/StdLib/Lib/sqlite3/test/dbapi.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/sqlite3/test/dbapi.py rename to src/StdLib/Lib/sqlite3/test/dbapi.py diff --git a/Src.GetRenamed/StdLib/Lib/sqlite3/test/dump.py b/src/StdLib/Lib/sqlite3/test/dump.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/sqlite3/test/dump.py rename to src/StdLib/Lib/sqlite3/test/dump.py diff --git a/Src.GetRenamed/StdLib/Lib/sqlite3/test/factory.py b/src/StdLib/Lib/sqlite3/test/factory.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/sqlite3/test/factory.py rename to src/StdLib/Lib/sqlite3/test/factory.py diff --git a/Src.GetRenamed/StdLib/Lib/sqlite3/test/hooks.py b/src/StdLib/Lib/sqlite3/test/hooks.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/sqlite3/test/hooks.py rename to src/StdLib/Lib/sqlite3/test/hooks.py diff --git a/Src.GetRenamed/StdLib/Lib/sqlite3/test/regression.py b/src/StdLib/Lib/sqlite3/test/regression.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/sqlite3/test/regression.py rename to src/StdLib/Lib/sqlite3/test/regression.py diff --git a/Src.GetRenamed/StdLib/Lib/sqlite3/test/transactions.py b/src/StdLib/Lib/sqlite3/test/transactions.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/sqlite3/test/transactions.py rename to src/StdLib/Lib/sqlite3/test/transactions.py diff --git a/Src.GetRenamed/StdLib/Lib/sqlite3/test/types.py b/src/StdLib/Lib/sqlite3/test/types.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/sqlite3/test/types.py rename to src/StdLib/Lib/sqlite3/test/types.py diff --git a/Src.GetRenamed/StdLib/Lib/sqlite3/test/userfunctions.py b/src/StdLib/Lib/sqlite3/test/userfunctions.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/sqlite3/test/userfunctions.py rename to src/StdLib/Lib/sqlite3/test/userfunctions.py diff --git a/Src.GetRenamed/StdLib/Lib/sre_compile.py b/src/StdLib/Lib/sre_compile.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/sre_compile.py rename to src/StdLib/Lib/sre_compile.py diff --git a/Src.GetRenamed/StdLib/Lib/sre_constants.py b/src/StdLib/Lib/sre_constants.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/sre_constants.py rename to src/StdLib/Lib/sre_constants.py diff --git a/Src.GetRenamed/StdLib/Lib/sre_parse.py b/src/StdLib/Lib/sre_parse.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/sre_parse.py rename to src/StdLib/Lib/sre_parse.py diff --git a/Src.GetRenamed/StdLib/Lib/ssl.py b/src/StdLib/Lib/ssl.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/ssl.py rename to src/StdLib/Lib/ssl.py diff --git a/Src.GetRenamed/StdLib/Lib/stat.py b/src/StdLib/Lib/stat.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/stat.py rename to src/StdLib/Lib/stat.py diff --git a/Src.GetRenamed/StdLib/Lib/statistics.py b/src/StdLib/Lib/statistics.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/statistics.py rename to src/StdLib/Lib/statistics.py diff --git a/Src.GetRenamed/StdLib/Lib/string.py b/src/StdLib/Lib/string.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/string.py rename to src/StdLib/Lib/string.py diff --git a/Src.GetRenamed/StdLib/Lib/stringprep.py b/src/StdLib/Lib/stringprep.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/stringprep.py rename to src/StdLib/Lib/stringprep.py diff --git a/Src.GetRenamed/StdLib/Lib/struct.py b/src/StdLib/Lib/struct.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/struct.py rename to src/StdLib/Lib/struct.py diff --git a/Src.GetRenamed/StdLib/Lib/subprocess.py b/src/StdLib/Lib/subprocess.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/subprocess.py rename to src/StdLib/Lib/subprocess.py diff --git a/Src.GetRenamed/StdLib/Lib/sunau.py b/src/StdLib/Lib/sunau.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/sunau.py rename to src/StdLib/Lib/sunau.py diff --git a/Src.GetRenamed/StdLib/Lib/symbol.py b/src/StdLib/Lib/symbol.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/symbol.py rename to src/StdLib/Lib/symbol.py diff --git a/Src.GetRenamed/StdLib/Lib/symtable.py b/src/StdLib/Lib/symtable.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/symtable.py rename to src/StdLib/Lib/symtable.py diff --git a/Src.GetRenamed/StdLib/Lib/sysconfig.py b/src/StdLib/Lib/sysconfig.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/sysconfig.py rename to src/StdLib/Lib/sysconfig.py diff --git a/Src.GetRenamed/StdLib/Lib/tabnanny.py b/src/StdLib/Lib/tabnanny.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tabnanny.py rename to src/StdLib/Lib/tabnanny.py diff --git a/Src.GetRenamed/StdLib/Lib/tarfile.py b/src/StdLib/Lib/tarfile.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tarfile.py rename to src/StdLib/Lib/tarfile.py diff --git a/Src.GetRenamed/StdLib/Lib/telnetlib.py b/src/StdLib/Lib/telnetlib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/telnetlib.py rename to src/StdLib/Lib/telnetlib.py diff --git a/Src.GetRenamed/StdLib/Lib/tempfile.py b/src/StdLib/Lib/tempfile.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tempfile.py rename to src/StdLib/Lib/tempfile.py diff --git a/Src.GetRenamed/StdLib/Lib/test/185test.db b/src/StdLib/Lib/test/185test.db similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/185test.db rename to src/StdLib/Lib/test/185test.db diff --git a/Src.GetRenamed/StdLib/Lib/test/Sine-1000Hz-300ms.aif b/src/StdLib/Lib/test/Sine-1000Hz-300ms.aif similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/Sine-1000Hz-300ms.aif rename to src/StdLib/Lib/test/Sine-1000Hz-300ms.aif diff --git a/Src.GetRenamed/StdLib/Lib/test/__init__.py b/src/StdLib/Lib/test/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/__init__.py rename to src/StdLib/Lib/test/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/__main__.py b/src/StdLib/Lib/test/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/__main__.py rename to src/StdLib/Lib/test/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/_test_multiprocessing.py b/src/StdLib/Lib/test/_test_multiprocessing.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/_test_multiprocessing.py rename to src/StdLib/Lib/test/_test_multiprocessing.py diff --git a/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-alaw.aifc b/src/StdLib/Lib/test/audiodata/pluck-alaw.aifc similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-alaw.aifc rename to src/StdLib/Lib/test/audiodata/pluck-alaw.aifc diff --git a/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm16.aiff b/src/StdLib/Lib/test/audiodata/pluck-pcm16.aiff similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm16.aiff rename to src/StdLib/Lib/test/audiodata/pluck-pcm16.aiff diff --git a/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm16.au b/src/StdLib/Lib/test/audiodata/pluck-pcm16.au similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm16.au rename to src/StdLib/Lib/test/audiodata/pluck-pcm16.au diff --git a/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm16.wav b/src/StdLib/Lib/test/audiodata/pluck-pcm16.wav similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm16.wav rename to src/StdLib/Lib/test/audiodata/pluck-pcm16.wav diff --git a/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm24.aiff b/src/StdLib/Lib/test/audiodata/pluck-pcm24.aiff similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm24.aiff rename to src/StdLib/Lib/test/audiodata/pluck-pcm24.aiff diff --git a/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm24.au b/src/StdLib/Lib/test/audiodata/pluck-pcm24.au similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm24.au rename to src/StdLib/Lib/test/audiodata/pluck-pcm24.au diff --git a/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm24.wav b/src/StdLib/Lib/test/audiodata/pluck-pcm24.wav similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm24.wav rename to src/StdLib/Lib/test/audiodata/pluck-pcm24.wav diff --git a/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm32.aiff b/src/StdLib/Lib/test/audiodata/pluck-pcm32.aiff similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm32.aiff rename to src/StdLib/Lib/test/audiodata/pluck-pcm32.aiff diff --git a/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm32.au b/src/StdLib/Lib/test/audiodata/pluck-pcm32.au similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm32.au rename to src/StdLib/Lib/test/audiodata/pluck-pcm32.au diff --git a/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm32.wav b/src/StdLib/Lib/test/audiodata/pluck-pcm32.wav similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm32.wav rename to src/StdLib/Lib/test/audiodata/pluck-pcm32.wav diff --git a/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm8.aiff b/src/StdLib/Lib/test/audiodata/pluck-pcm8.aiff similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm8.aiff rename to src/StdLib/Lib/test/audiodata/pluck-pcm8.aiff diff --git a/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm8.au b/src/StdLib/Lib/test/audiodata/pluck-pcm8.au similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm8.au rename to src/StdLib/Lib/test/audiodata/pluck-pcm8.au diff --git a/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm8.wav b/src/StdLib/Lib/test/audiodata/pluck-pcm8.wav similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-pcm8.wav rename to src/StdLib/Lib/test/audiodata/pluck-pcm8.wav diff --git a/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-ulaw.aifc b/src/StdLib/Lib/test/audiodata/pluck-ulaw.aifc similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-ulaw.aifc rename to src/StdLib/Lib/test/audiodata/pluck-ulaw.aifc diff --git a/Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-ulaw.au b/src/StdLib/Lib/test/audiodata/pluck-ulaw.au similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/audiodata/pluck-ulaw.au rename to src/StdLib/Lib/test/audiodata/pluck-ulaw.au diff --git a/Src.GetRenamed/StdLib/Lib/test/audiotest.au b/src/StdLib/Lib/test/audiotest.au similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/audiotest.au rename to src/StdLib/Lib/test/audiotest.au diff --git a/Src.GetRenamed/StdLib/Lib/test/audiotests.py b/src/StdLib/Lib/test/audiotests.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/audiotests.py rename to src/StdLib/Lib/test/audiotests.py diff --git a/Src.GetRenamed/StdLib/Lib/test/autotest.py b/src/StdLib/Lib/test/autotest.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/autotest.py rename to src/StdLib/Lib/test/autotest.py diff --git a/Src.GetRenamed/StdLib/Lib/test/bad_coding.py b/src/StdLib/Lib/test/bad_coding.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/bad_coding.py rename to src/StdLib/Lib/test/bad_coding.py diff --git a/Src.GetRenamed/StdLib/Lib/test/bad_coding2.py b/src/StdLib/Lib/test/bad_coding2.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/bad_coding2.py rename to src/StdLib/Lib/test/bad_coding2.py diff --git a/Src.GetRenamed/StdLib/Lib/test/badcert.pem b/src/StdLib/Lib/test/badcert.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/badcert.pem rename to src/StdLib/Lib/test/badcert.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/badkey.pem b/src/StdLib/Lib/test/badkey.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/badkey.pem rename to src/StdLib/Lib/test/badkey.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/badsyntax_3131.py b/src/StdLib/Lib/test/badsyntax_3131.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/badsyntax_3131.py rename to src/StdLib/Lib/test/badsyntax_3131.py diff --git a/Src.GetRenamed/StdLib/Lib/test/badsyntax_future10.py b/src/StdLib/Lib/test/badsyntax_future10.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/badsyntax_future10.py rename to src/StdLib/Lib/test/badsyntax_future10.py diff --git a/Src.GetRenamed/StdLib/Lib/test/badsyntax_future3.py b/src/StdLib/Lib/test/badsyntax_future3.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/badsyntax_future3.py rename to src/StdLib/Lib/test/badsyntax_future3.py diff --git a/Src.GetRenamed/StdLib/Lib/test/badsyntax_future4.py b/src/StdLib/Lib/test/badsyntax_future4.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/badsyntax_future4.py rename to src/StdLib/Lib/test/badsyntax_future4.py diff --git a/Src.GetRenamed/StdLib/Lib/test/badsyntax_future5.py b/src/StdLib/Lib/test/badsyntax_future5.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/badsyntax_future5.py rename to src/StdLib/Lib/test/badsyntax_future5.py diff --git a/Src.GetRenamed/StdLib/Lib/test/badsyntax_future6.py b/src/StdLib/Lib/test/badsyntax_future6.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/badsyntax_future6.py rename to src/StdLib/Lib/test/badsyntax_future6.py diff --git a/Src.GetRenamed/StdLib/Lib/test/badsyntax_future7.py b/src/StdLib/Lib/test/badsyntax_future7.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/badsyntax_future7.py rename to src/StdLib/Lib/test/badsyntax_future7.py diff --git a/Src.GetRenamed/StdLib/Lib/test/badsyntax_future8.py b/src/StdLib/Lib/test/badsyntax_future8.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/badsyntax_future8.py rename to src/StdLib/Lib/test/badsyntax_future8.py diff --git a/Src.GetRenamed/StdLib/Lib/test/badsyntax_future9.py b/src/StdLib/Lib/test/badsyntax_future9.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/badsyntax_future9.py rename to src/StdLib/Lib/test/badsyntax_future9.py diff --git a/Src.GetRenamed/StdLib/Lib/test/badsyntax_pep3120.py b/src/StdLib/Lib/test/badsyntax_pep3120.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/badsyntax_pep3120.py rename to src/StdLib/Lib/test/badsyntax_pep3120.py diff --git a/Src.GetRenamed/StdLib/Lib/test/buffer_tests.py b/src/StdLib/Lib/test/buffer_tests.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/buffer_tests.py rename to src/StdLib/Lib/test/buffer_tests.py diff --git a/Src.GetRenamed/StdLib/Lib/test/bytecode_helper.py b/src/StdLib/Lib/test/bytecode_helper.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/bytecode_helper.py rename to src/StdLib/Lib/test/bytecode_helper.py diff --git a/Src.GetRenamed/StdLib/Lib/test/capath/0e4015b9.0 b/src/StdLib/Lib/test/capath/0e4015b9.0 similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/capath/0e4015b9.0 rename to src/StdLib/Lib/test/capath/0e4015b9.0 diff --git a/Src.GetRenamed/StdLib/Lib/test/capath/4e1295a3.0 b/src/StdLib/Lib/test/capath/4e1295a3.0 similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/capath/4e1295a3.0 rename to src/StdLib/Lib/test/capath/4e1295a3.0 diff --git a/Src.GetRenamed/StdLib/Lib/test/capath/5ed36f99.0 b/src/StdLib/Lib/test/capath/5ed36f99.0 similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/capath/5ed36f99.0 rename to src/StdLib/Lib/test/capath/5ed36f99.0 diff --git a/Src.GetRenamed/StdLib/Lib/test/capath/6e88d7b8.0 b/src/StdLib/Lib/test/capath/6e88d7b8.0 similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/capath/6e88d7b8.0 rename to src/StdLib/Lib/test/capath/6e88d7b8.0 diff --git a/Src.GetRenamed/StdLib/Lib/test/capath/99d0fa06.0 b/src/StdLib/Lib/test/capath/99d0fa06.0 similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/capath/99d0fa06.0 rename to src/StdLib/Lib/test/capath/99d0fa06.0 diff --git a/Src.GetRenamed/StdLib/Lib/test/capath/ce7b8643.0 b/src/StdLib/Lib/test/capath/ce7b8643.0 similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/capath/ce7b8643.0 rename to src/StdLib/Lib/test/capath/ce7b8643.0 diff --git a/Src.GetRenamed/StdLib/Lib/test/cfgparser.1 b/src/StdLib/Lib/test/cfgparser.1 similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cfgparser.1 rename to src/StdLib/Lib/test/cfgparser.1 diff --git a/Src.GetRenamed/StdLib/Lib/test/cfgparser.2 b/src/StdLib/Lib/test/cfgparser.2 similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cfgparser.2 rename to src/StdLib/Lib/test/cfgparser.2 diff --git a/Src.GetRenamed/StdLib/Lib/test/cfgparser.3 b/src/StdLib/Lib/test/cfgparser.3 similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cfgparser.3 rename to src/StdLib/Lib/test/cfgparser.3 diff --git a/Src.GetRenamed/StdLib/Lib/test/check_soundcard.vbs b/src/StdLib/Lib/test/check_soundcard.vbs similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/check_soundcard.vbs rename to src/StdLib/Lib/test/check_soundcard.vbs diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/big5-utf8.txt b/src/StdLib/Lib/test/cjkencodings/big5-utf8.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/big5-utf8.txt rename to src/StdLib/Lib/test/cjkencodings/big5-utf8.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/big5.txt b/src/StdLib/Lib/test/cjkencodings/big5.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/big5.txt rename to src/StdLib/Lib/test/cjkencodings/big5.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt b/src/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt rename to src/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/big5hkscs.txt b/src/StdLib/Lib/test/cjkencodings/big5hkscs.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/big5hkscs.txt rename to src/StdLib/Lib/test/cjkencodings/big5hkscs.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/cp949-utf8.txt b/src/StdLib/Lib/test/cjkencodings/cp949-utf8.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/cp949-utf8.txt rename to src/StdLib/Lib/test/cjkencodings/cp949-utf8.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/cp949.txt b/src/StdLib/Lib/test/cjkencodings/cp949.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/cp949.txt rename to src/StdLib/Lib/test/cjkencodings/cp949.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt b/src/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt rename to src/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt b/src/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt rename to src/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt b/src/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt rename to src/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_jp.txt b/src/StdLib/Lib/test/cjkencodings/euc_jp.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_jp.txt rename to src/StdLib/Lib/test/cjkencodings/euc_jp.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt b/src/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt rename to src/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_kr.txt b/src/StdLib/Lib/test/cjkencodings/euc_kr.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/euc_kr.txt rename to src/StdLib/Lib/test/cjkencodings/euc_kr.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt b/src/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt rename to src/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/gb18030.txt b/src/StdLib/Lib/test/cjkencodings/gb18030.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/gb18030.txt rename to src/StdLib/Lib/test/cjkencodings/gb18030.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt b/src/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt rename to src/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/gb2312.txt b/src/StdLib/Lib/test/cjkencodings/gb2312.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/gb2312.txt rename to src/StdLib/Lib/test/cjkencodings/gb2312.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/gbk-utf8.txt b/src/StdLib/Lib/test/cjkencodings/gbk-utf8.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/gbk-utf8.txt rename to src/StdLib/Lib/test/cjkencodings/gbk-utf8.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/gbk.txt b/src/StdLib/Lib/test/cjkencodings/gbk.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/gbk.txt rename to src/StdLib/Lib/test/cjkencodings/gbk.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/hz-utf8.txt b/src/StdLib/Lib/test/cjkencodings/hz-utf8.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/hz-utf8.txt rename to src/StdLib/Lib/test/cjkencodings/hz-utf8.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/hz.txt b/src/StdLib/Lib/test/cjkencodings/hz.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/hz.txt rename to src/StdLib/Lib/test/cjkencodings/hz.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt b/src/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt rename to src/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/iso2022_jp.txt b/src/StdLib/Lib/test/cjkencodings/iso2022_jp.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/iso2022_jp.txt rename to src/StdLib/Lib/test/cjkencodings/iso2022_jp.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt b/src/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt rename to src/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/iso2022_kr.txt b/src/StdLib/Lib/test/cjkencodings/iso2022_kr.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/iso2022_kr.txt rename to src/StdLib/Lib/test/cjkencodings/iso2022_kr.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/johab-utf8.txt b/src/StdLib/Lib/test/cjkencodings/johab-utf8.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/johab-utf8.txt rename to src/StdLib/Lib/test/cjkencodings/johab-utf8.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/johab.txt b/src/StdLib/Lib/test/cjkencodings/johab.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/johab.txt rename to src/StdLib/Lib/test/cjkencodings/johab.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt b/src/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt rename to src/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/shift_jis.txt b/src/StdLib/Lib/test/cjkencodings/shift_jis.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/shift_jis.txt rename to src/StdLib/Lib/test/cjkencodings/shift_jis.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt b/src/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt rename to src/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt b/src/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt rename to src/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/cmath_testcases.txt b/src/StdLib/Lib/test/cmath_testcases.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/cmath_testcases.txt rename to src/StdLib/Lib/test/cmath_testcases.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/coding20731.py b/src/StdLib/Lib/test/coding20731.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/coding20731.py rename to src/StdLib/Lib/test/coding20731.py diff --git a/Src.GetRenamed/StdLib/Lib/test/crashers/README b/src/StdLib/Lib/test/crashers/README similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/crashers/README rename to src/StdLib/Lib/test/crashers/README diff --git a/Src.GetRenamed/StdLib/Lib/test/crashers/bogus_code_obj.py b/src/StdLib/Lib/test/crashers/bogus_code_obj.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/crashers/bogus_code_obj.py rename to src/StdLib/Lib/test/crashers/bogus_code_obj.py diff --git a/Src.GetRenamed/StdLib/Lib/test/crashers/gc_inspection.py b/src/StdLib/Lib/test/crashers/gc_inspection.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/crashers/gc_inspection.py rename to src/StdLib/Lib/test/crashers/gc_inspection.py diff --git a/Src.GetRenamed/StdLib/Lib/test/crashers/infinite_loop_re.py b/src/StdLib/Lib/test/crashers/infinite_loop_re.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/crashers/infinite_loop_re.py rename to src/StdLib/Lib/test/crashers/infinite_loop_re.py diff --git a/Src.GetRenamed/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py b/src/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py rename to src/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py diff --git a/Src.GetRenamed/StdLib/Lib/test/crashers/recursive_call.py b/src/StdLib/Lib/test/crashers/recursive_call.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/crashers/recursive_call.py rename to src/StdLib/Lib/test/crashers/recursive_call.py diff --git a/Src.GetRenamed/StdLib/Lib/test/crashers/trace_at_recursion_limit.py b/src/StdLib/Lib/test/crashers/trace_at_recursion_limit.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/crashers/trace_at_recursion_limit.py rename to src/StdLib/Lib/test/crashers/trace_at_recursion_limit.py diff --git a/Src.GetRenamed/StdLib/Lib/test/crashers/underlying_dict.py b/src/StdLib/Lib/test/crashers/underlying_dict.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/crashers/underlying_dict.py rename to src/StdLib/Lib/test/crashers/underlying_dict.py diff --git a/Src.GetRenamed/StdLib/Lib/test/curses_tests.py b/src/StdLib/Lib/test/curses_tests.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/curses_tests.py rename to src/StdLib/Lib/test/curses_tests.py diff --git a/Src.GetRenamed/StdLib/Lib/test/data/README b/src/StdLib/Lib/test/data/README similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/data/README rename to src/StdLib/Lib/test/data/README diff --git a/Src.GetRenamed/StdLib/Lib/test/datetimetester.py b/src/StdLib/Lib/test/datetimetester.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/datetimetester.py rename to src/StdLib/Lib/test/datetimetester.py diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/abs.decTest b/src/StdLib/Lib/test/decimaltestdata/abs.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/abs.decTest rename to src/StdLib/Lib/test/decimaltestdata/abs.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/add.decTest b/src/StdLib/Lib/test/decimaltestdata/add.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/add.decTest rename to src/StdLib/Lib/test/decimaltestdata/add.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/and.decTest b/src/StdLib/Lib/test/decimaltestdata/and.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/and.decTest rename to src/StdLib/Lib/test/decimaltestdata/and.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/base.decTest b/src/StdLib/Lib/test/decimaltestdata/base.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/base.decTest rename to src/StdLib/Lib/test/decimaltestdata/base.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/clamp.decTest b/src/StdLib/Lib/test/decimaltestdata/clamp.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/clamp.decTest rename to src/StdLib/Lib/test/decimaltestdata/clamp.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/class.decTest b/src/StdLib/Lib/test/decimaltestdata/class.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/class.decTest rename to src/StdLib/Lib/test/decimaltestdata/class.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/compare.decTest b/src/StdLib/Lib/test/decimaltestdata/compare.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/compare.decTest rename to src/StdLib/Lib/test/decimaltestdata/compare.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/comparetotal.decTest b/src/StdLib/Lib/test/decimaltestdata/comparetotal.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/comparetotal.decTest rename to src/StdLib/Lib/test/decimaltestdata/comparetotal.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest b/src/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest rename to src/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/copy.decTest b/src/StdLib/Lib/test/decimaltestdata/copy.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/copy.decTest rename to src/StdLib/Lib/test/decimaltestdata/copy.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/copyabs.decTest b/src/StdLib/Lib/test/decimaltestdata/copyabs.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/copyabs.decTest rename to src/StdLib/Lib/test/decimaltestdata/copyabs.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/copynegate.decTest b/src/StdLib/Lib/test/decimaltestdata/copynegate.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/copynegate.decTest rename to src/StdLib/Lib/test/decimaltestdata/copynegate.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/copysign.decTest b/src/StdLib/Lib/test/decimaltestdata/copysign.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/copysign.decTest rename to src/StdLib/Lib/test/decimaltestdata/copysign.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddAbs.decTest b/src/StdLib/Lib/test/decimaltestdata/ddAbs.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddAbs.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddAbs.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddAdd.decTest b/src/StdLib/Lib/test/decimaltestdata/ddAdd.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddAdd.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddAdd.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddAnd.decTest b/src/StdLib/Lib/test/decimaltestdata/ddAnd.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddAnd.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddAnd.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddBase.decTest b/src/StdLib/Lib/test/decimaltestdata/ddBase.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddBase.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddBase.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest b/src/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddClass.decTest b/src/StdLib/Lib/test/decimaltestdata/ddClass.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddClass.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddClass.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCompare.decTest b/src/StdLib/Lib/test/decimaltestdata/ddCompare.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCompare.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddCompare.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest b/src/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest b/src/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest b/src/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCopy.decTest b/src/StdLib/Lib/test/decimaltestdata/ddCopy.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCopy.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddCopy.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest b/src/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest b/src/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest b/src/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddDivide.decTest b/src/StdLib/Lib/test/decimaltestdata/ddDivide.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddDivide.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddDivide.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest b/src/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddEncode.decTest b/src/StdLib/Lib/test/decimaltestdata/ddEncode.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddEncode.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddEncode.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddFMA.decTest b/src/StdLib/Lib/test/decimaltestdata/ddFMA.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddFMA.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddFMA.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddInvert.decTest b/src/StdLib/Lib/test/decimaltestdata/ddInvert.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddInvert.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddInvert.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddLogB.decTest b/src/StdLib/Lib/test/decimaltestdata/ddLogB.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddLogB.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddLogB.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMax.decTest b/src/StdLib/Lib/test/decimaltestdata/ddMax.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMax.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddMax.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest b/src/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMin.decTest b/src/StdLib/Lib/test/decimaltestdata/ddMin.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMin.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddMin.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest b/src/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMinus.decTest b/src/StdLib/Lib/test/decimaltestdata/ddMinus.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMinus.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddMinus.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest b/src/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest b/src/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest b/src/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest b/src/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddOr.decTest b/src/StdLib/Lib/test/decimaltestdata/ddOr.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddOr.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddOr.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddPlus.decTest b/src/StdLib/Lib/test/decimaltestdata/ddPlus.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddPlus.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddPlus.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest b/src/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddReduce.decTest b/src/StdLib/Lib/test/decimaltestdata/ddReduce.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddReduce.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddReduce.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest b/src/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest b/src/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddRotate.decTest b/src/StdLib/Lib/test/decimaltestdata/ddRotate.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddRotate.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddRotate.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest b/src/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest b/src/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddShift.decTest b/src/StdLib/Lib/test/decimaltestdata/ddShift.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddShift.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddShift.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest b/src/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest b/src/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddXor.decTest b/src/StdLib/Lib/test/decimaltestdata/ddXor.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ddXor.decTest rename to src/StdLib/Lib/test/decimaltestdata/ddXor.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/decDouble.decTest b/src/StdLib/Lib/test/decimaltestdata/decDouble.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/decDouble.decTest rename to src/StdLib/Lib/test/decimaltestdata/decDouble.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/decQuad.decTest b/src/StdLib/Lib/test/decimaltestdata/decQuad.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/decQuad.decTest rename to src/StdLib/Lib/test/decimaltestdata/decQuad.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/decSingle.decTest b/src/StdLib/Lib/test/decimaltestdata/decSingle.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/decSingle.decTest rename to src/StdLib/Lib/test/decimaltestdata/decSingle.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/divide.decTest b/src/StdLib/Lib/test/decimaltestdata/divide.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/divide.decTest rename to src/StdLib/Lib/test/decimaltestdata/divide.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/divideint.decTest b/src/StdLib/Lib/test/decimaltestdata/divideint.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/divideint.decTest rename to src/StdLib/Lib/test/decimaltestdata/divideint.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqAbs.decTest b/src/StdLib/Lib/test/decimaltestdata/dqAbs.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqAbs.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqAbs.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqAdd.decTest b/src/StdLib/Lib/test/decimaltestdata/dqAdd.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqAdd.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqAdd.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqAnd.decTest b/src/StdLib/Lib/test/decimaltestdata/dqAnd.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqAnd.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqAnd.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqBase.decTest b/src/StdLib/Lib/test/decimaltestdata/dqBase.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqBase.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqBase.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest b/src/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqClass.decTest b/src/StdLib/Lib/test/decimaltestdata/dqClass.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqClass.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqClass.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCompare.decTest b/src/StdLib/Lib/test/decimaltestdata/dqCompare.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCompare.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqCompare.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest b/src/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest b/src/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest b/src/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCopy.decTest b/src/StdLib/Lib/test/decimaltestdata/dqCopy.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCopy.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqCopy.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest b/src/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest b/src/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest b/src/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqDivide.decTest b/src/StdLib/Lib/test/decimaltestdata/dqDivide.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqDivide.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqDivide.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest b/src/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqEncode.decTest b/src/StdLib/Lib/test/decimaltestdata/dqEncode.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqEncode.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqEncode.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqFMA.decTest b/src/StdLib/Lib/test/decimaltestdata/dqFMA.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqFMA.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqFMA.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqInvert.decTest b/src/StdLib/Lib/test/decimaltestdata/dqInvert.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqInvert.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqInvert.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqLogB.decTest b/src/StdLib/Lib/test/decimaltestdata/dqLogB.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqLogB.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqLogB.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMax.decTest b/src/StdLib/Lib/test/decimaltestdata/dqMax.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMax.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqMax.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest b/src/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMin.decTest b/src/StdLib/Lib/test/decimaltestdata/dqMin.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMin.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqMin.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest b/src/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMinus.decTest b/src/StdLib/Lib/test/decimaltestdata/dqMinus.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMinus.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqMinus.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest b/src/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest b/src/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest b/src/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest b/src/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqOr.decTest b/src/StdLib/Lib/test/decimaltestdata/dqOr.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqOr.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqOr.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqPlus.decTest b/src/StdLib/Lib/test/decimaltestdata/dqPlus.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqPlus.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqPlus.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest b/src/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqReduce.decTest b/src/StdLib/Lib/test/decimaltestdata/dqReduce.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqReduce.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqReduce.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest b/src/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest b/src/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqRotate.decTest b/src/StdLib/Lib/test/decimaltestdata/dqRotate.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqRotate.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqRotate.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest b/src/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest b/src/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqShift.decTest b/src/StdLib/Lib/test/decimaltestdata/dqShift.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqShift.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqShift.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest b/src/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest b/src/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqXor.decTest b/src/StdLib/Lib/test/decimaltestdata/dqXor.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dqXor.decTest rename to src/StdLib/Lib/test/decimaltestdata/dqXor.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dsBase.decTest b/src/StdLib/Lib/test/decimaltestdata/dsBase.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dsBase.decTest rename to src/StdLib/Lib/test/decimaltestdata/dsBase.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dsEncode.decTest b/src/StdLib/Lib/test/decimaltestdata/dsEncode.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/dsEncode.decTest rename to src/StdLib/Lib/test/decimaltestdata/dsEncode.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/exp.decTest b/src/StdLib/Lib/test/decimaltestdata/exp.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/exp.decTest rename to src/StdLib/Lib/test/decimaltestdata/exp.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/extra.decTest b/src/StdLib/Lib/test/decimaltestdata/extra.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/extra.decTest rename to src/StdLib/Lib/test/decimaltestdata/extra.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/fma.decTest b/src/StdLib/Lib/test/decimaltestdata/fma.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/fma.decTest rename to src/StdLib/Lib/test/decimaltestdata/fma.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/inexact.decTest b/src/StdLib/Lib/test/decimaltestdata/inexact.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/inexact.decTest rename to src/StdLib/Lib/test/decimaltestdata/inexact.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/invert.decTest b/src/StdLib/Lib/test/decimaltestdata/invert.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/invert.decTest rename to src/StdLib/Lib/test/decimaltestdata/invert.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ln.decTest b/src/StdLib/Lib/test/decimaltestdata/ln.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/ln.decTest rename to src/StdLib/Lib/test/decimaltestdata/ln.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/log10.decTest b/src/StdLib/Lib/test/decimaltestdata/log10.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/log10.decTest rename to src/StdLib/Lib/test/decimaltestdata/log10.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/logb.decTest b/src/StdLib/Lib/test/decimaltestdata/logb.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/logb.decTest rename to src/StdLib/Lib/test/decimaltestdata/logb.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/max.decTest b/src/StdLib/Lib/test/decimaltestdata/max.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/max.decTest rename to src/StdLib/Lib/test/decimaltestdata/max.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/maxmag.decTest b/src/StdLib/Lib/test/decimaltestdata/maxmag.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/maxmag.decTest rename to src/StdLib/Lib/test/decimaltestdata/maxmag.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/min.decTest b/src/StdLib/Lib/test/decimaltestdata/min.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/min.decTest rename to src/StdLib/Lib/test/decimaltestdata/min.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/minmag.decTest b/src/StdLib/Lib/test/decimaltestdata/minmag.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/minmag.decTest rename to src/StdLib/Lib/test/decimaltestdata/minmag.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/minus.decTest b/src/StdLib/Lib/test/decimaltestdata/minus.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/minus.decTest rename to src/StdLib/Lib/test/decimaltestdata/minus.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/multiply.decTest b/src/StdLib/Lib/test/decimaltestdata/multiply.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/multiply.decTest rename to src/StdLib/Lib/test/decimaltestdata/multiply.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/nextminus.decTest b/src/StdLib/Lib/test/decimaltestdata/nextminus.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/nextminus.decTest rename to src/StdLib/Lib/test/decimaltestdata/nextminus.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/nextplus.decTest b/src/StdLib/Lib/test/decimaltestdata/nextplus.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/nextplus.decTest rename to src/StdLib/Lib/test/decimaltestdata/nextplus.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/nexttoward.decTest b/src/StdLib/Lib/test/decimaltestdata/nexttoward.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/nexttoward.decTest rename to src/StdLib/Lib/test/decimaltestdata/nexttoward.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/or.decTest b/src/StdLib/Lib/test/decimaltestdata/or.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/or.decTest rename to src/StdLib/Lib/test/decimaltestdata/or.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/plus.decTest b/src/StdLib/Lib/test/decimaltestdata/plus.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/plus.decTest rename to src/StdLib/Lib/test/decimaltestdata/plus.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/power.decTest b/src/StdLib/Lib/test/decimaltestdata/power.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/power.decTest rename to src/StdLib/Lib/test/decimaltestdata/power.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/powersqrt.decTest b/src/StdLib/Lib/test/decimaltestdata/powersqrt.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/powersqrt.decTest rename to src/StdLib/Lib/test/decimaltestdata/powersqrt.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/quantize.decTest b/src/StdLib/Lib/test/decimaltestdata/quantize.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/quantize.decTest rename to src/StdLib/Lib/test/decimaltestdata/quantize.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/randomBound32.decTest b/src/StdLib/Lib/test/decimaltestdata/randomBound32.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/randomBound32.decTest rename to src/StdLib/Lib/test/decimaltestdata/randomBound32.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/randoms.decTest b/src/StdLib/Lib/test/decimaltestdata/randoms.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/randoms.decTest rename to src/StdLib/Lib/test/decimaltestdata/randoms.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/reduce.decTest b/src/StdLib/Lib/test/decimaltestdata/reduce.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/reduce.decTest rename to src/StdLib/Lib/test/decimaltestdata/reduce.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/remainder.decTest b/src/StdLib/Lib/test/decimaltestdata/remainder.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/remainder.decTest rename to src/StdLib/Lib/test/decimaltestdata/remainder.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/remainderNear.decTest b/src/StdLib/Lib/test/decimaltestdata/remainderNear.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/remainderNear.decTest rename to src/StdLib/Lib/test/decimaltestdata/remainderNear.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/rescale.decTest b/src/StdLib/Lib/test/decimaltestdata/rescale.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/rescale.decTest rename to src/StdLib/Lib/test/decimaltestdata/rescale.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/rotate.decTest b/src/StdLib/Lib/test/decimaltestdata/rotate.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/rotate.decTest rename to src/StdLib/Lib/test/decimaltestdata/rotate.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/rounding.decTest b/src/StdLib/Lib/test/decimaltestdata/rounding.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/rounding.decTest rename to src/StdLib/Lib/test/decimaltestdata/rounding.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/samequantum.decTest b/src/StdLib/Lib/test/decimaltestdata/samequantum.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/samequantum.decTest rename to src/StdLib/Lib/test/decimaltestdata/samequantum.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/scaleb.decTest b/src/StdLib/Lib/test/decimaltestdata/scaleb.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/scaleb.decTest rename to src/StdLib/Lib/test/decimaltestdata/scaleb.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/shift.decTest b/src/StdLib/Lib/test/decimaltestdata/shift.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/shift.decTest rename to src/StdLib/Lib/test/decimaltestdata/shift.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/squareroot.decTest b/src/StdLib/Lib/test/decimaltestdata/squareroot.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/squareroot.decTest rename to src/StdLib/Lib/test/decimaltestdata/squareroot.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/subtract.decTest b/src/StdLib/Lib/test/decimaltestdata/subtract.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/subtract.decTest rename to src/StdLib/Lib/test/decimaltestdata/subtract.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/testall.decTest b/src/StdLib/Lib/test/decimaltestdata/testall.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/testall.decTest rename to src/StdLib/Lib/test/decimaltestdata/testall.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/tointegral.decTest b/src/StdLib/Lib/test/decimaltestdata/tointegral.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/tointegral.decTest rename to src/StdLib/Lib/test/decimaltestdata/tointegral.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/tointegralx.decTest b/src/StdLib/Lib/test/decimaltestdata/tointegralx.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/tointegralx.decTest rename to src/StdLib/Lib/test/decimaltestdata/tointegralx.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/decimaltestdata/xor.decTest b/src/StdLib/Lib/test/decimaltestdata/xor.decTest similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/decimaltestdata/xor.decTest rename to src/StdLib/Lib/test/decimaltestdata/xor.decTest diff --git a/Src.GetRenamed/StdLib/Lib/test/dh1024.pem b/src/StdLib/Lib/test/dh1024.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/dh1024.pem rename to src/StdLib/Lib/test/dh1024.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/dis_module.py b/src/StdLib/Lib/test/dis_module.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/dis_module.py rename to src/StdLib/Lib/test/dis_module.py diff --git a/Src.GetRenamed/StdLib/Lib/test/doctest_aliases.py b/src/StdLib/Lib/test/doctest_aliases.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/doctest_aliases.py rename to src/StdLib/Lib/test/doctest_aliases.py diff --git a/Src.GetRenamed/StdLib/Lib/test/double_const.py b/src/StdLib/Lib/test/double_const.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/double_const.py rename to src/StdLib/Lib/test/double_const.py diff --git a/Src.GetRenamed/StdLib/Lib/test/empty.vbs b/src/StdLib/Lib/test/empty.vbs similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/empty.vbs rename to src/StdLib/Lib/test/empty.vbs diff --git a/Src.GetRenamed/StdLib/Lib/test/encoded_modules/__init__.py b/src/StdLib/Lib/test/encoded_modules/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/encoded_modules/__init__.py rename to src/StdLib/Lib/test/encoded_modules/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py b/src/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py rename to src/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py diff --git a/Src.GetRenamed/StdLib/Lib/test/encoded_modules/module_koi8_r.py b/src/StdLib/Lib/test/encoded_modules/module_koi8_r.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/encoded_modules/module_koi8_r.py rename to src/StdLib/Lib/test/encoded_modules/module_koi8_r.py diff --git a/Src.GetRenamed/StdLib/Lib/test/exception_hierarchy.txt b/src/StdLib/Lib/test/exception_hierarchy.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/exception_hierarchy.txt rename to src/StdLib/Lib/test/exception_hierarchy.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/final_a.py b/src/StdLib/Lib/test/final_a.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/final_a.py rename to src/StdLib/Lib/test/final_a.py diff --git a/Src.GetRenamed/StdLib/Lib/test/final_b.py b/src/StdLib/Lib/test/final_b.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/final_b.py rename to src/StdLib/Lib/test/final_b.py diff --git a/Src.GetRenamed/StdLib/Lib/test/floating_points.txt b/src/StdLib/Lib/test/floating_points.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/floating_points.txt rename to src/StdLib/Lib/test/floating_points.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/fork_wait.py b/src/StdLib/Lib/test/fork_wait.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/fork_wait.py rename to src/StdLib/Lib/test/fork_wait.py diff --git a/Src.GetRenamed/StdLib/Lib/test/formatfloat_testcases.txt b/src/StdLib/Lib/test/formatfloat_testcases.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/formatfloat_testcases.txt rename to src/StdLib/Lib/test/formatfloat_testcases.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/future_test1.py b/src/StdLib/Lib/test/future_test1.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/future_test1.py rename to src/StdLib/Lib/test/future_test1.py diff --git a/Src.GetRenamed/StdLib/Lib/test/future_test2.py b/src/StdLib/Lib/test/future_test2.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/future_test2.py rename to src/StdLib/Lib/test/future_test2.py diff --git a/Src.GetRenamed/StdLib/Lib/test/gdb_sample.py b/src/StdLib/Lib/test/gdb_sample.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/gdb_sample.py rename to src/StdLib/Lib/test/gdb_sample.py diff --git a/Src.GetRenamed/StdLib/Lib/test/ieee754.txt b/src/StdLib/Lib/test/ieee754.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/ieee754.txt rename to src/StdLib/Lib/test/ieee754.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.bmp b/src/StdLib/Lib/test/imghdrdata/python.bmp similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.bmp rename to src/StdLib/Lib/test/imghdrdata/python.bmp diff --git a/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.gif b/src/StdLib/Lib/test/imghdrdata/python.gif similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.gif rename to src/StdLib/Lib/test/imghdrdata/python.gif diff --git a/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.jpg b/src/StdLib/Lib/test/imghdrdata/python.jpg similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.jpg rename to src/StdLib/Lib/test/imghdrdata/python.jpg diff --git a/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.pbm b/src/StdLib/Lib/test/imghdrdata/python.pbm similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.pbm rename to src/StdLib/Lib/test/imghdrdata/python.pbm diff --git a/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.pgm b/src/StdLib/Lib/test/imghdrdata/python.pgm similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.pgm rename to src/StdLib/Lib/test/imghdrdata/python.pgm diff --git a/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.png b/src/StdLib/Lib/test/imghdrdata/python.png similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.png rename to src/StdLib/Lib/test/imghdrdata/python.png diff --git a/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.ppm b/src/StdLib/Lib/test/imghdrdata/python.ppm similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.ppm rename to src/StdLib/Lib/test/imghdrdata/python.ppm diff --git a/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.ras b/src/StdLib/Lib/test/imghdrdata/python.ras similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.ras rename to src/StdLib/Lib/test/imghdrdata/python.ras diff --git a/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.sgi b/src/StdLib/Lib/test/imghdrdata/python.sgi similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.sgi rename to src/StdLib/Lib/test/imghdrdata/python.sgi diff --git a/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.tiff b/src/StdLib/Lib/test/imghdrdata/python.tiff similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.tiff rename to src/StdLib/Lib/test/imghdrdata/python.tiff diff --git a/Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.xbm b/src/StdLib/Lib/test/imghdrdata/python.xbm similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/imghdrdata/python.xbm rename to src/StdLib/Lib/test/imghdrdata/python.xbm diff --git a/Src.GetRenamed/StdLib/Lib/test/inspect_fodder.py b/src/StdLib/Lib/test/inspect_fodder.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/inspect_fodder.py rename to src/StdLib/Lib/test/inspect_fodder.py diff --git a/Src.GetRenamed/StdLib/Lib/test/inspect_fodder2.py b/src/StdLib/Lib/test/inspect_fodder2.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/inspect_fodder2.py rename to src/StdLib/Lib/test/inspect_fodder2.py diff --git a/Src.GetRenamed/StdLib/Lib/test/keycert.passwd.pem b/src/StdLib/Lib/test/keycert.passwd.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/keycert.passwd.pem rename to src/StdLib/Lib/test/keycert.passwd.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/keycert.pem b/src/StdLib/Lib/test/keycert.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/keycert.pem rename to src/StdLib/Lib/test/keycert.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/keycert2.pem b/src/StdLib/Lib/test/keycert2.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/keycert2.pem rename to src/StdLib/Lib/test/keycert2.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/keycert3.pem b/src/StdLib/Lib/test/keycert3.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/keycert3.pem rename to src/StdLib/Lib/test/keycert3.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/keycert4.pem b/src/StdLib/Lib/test/keycert4.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/keycert4.pem rename to src/StdLib/Lib/test/keycert4.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/leakers/README.txt b/src/StdLib/Lib/test/leakers/README.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/leakers/README.txt rename to src/StdLib/Lib/test/leakers/README.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/leakers/__init__.py b/src/StdLib/Lib/test/leakers/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/leakers/__init__.py rename to src/StdLib/Lib/test/leakers/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/leakers/test_ctypes.py b/src/StdLib/Lib/test/leakers/test_ctypes.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/leakers/test_ctypes.py rename to src/StdLib/Lib/test/leakers/test_ctypes.py diff --git a/Src.GetRenamed/StdLib/Lib/test/leakers/test_selftype.py b/src/StdLib/Lib/test/leakers/test_selftype.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/leakers/test_selftype.py rename to src/StdLib/Lib/test/leakers/test_selftype.py diff --git a/Src.GetRenamed/StdLib/Lib/test/list_tests.py b/src/StdLib/Lib/test/list_tests.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/list_tests.py rename to src/StdLib/Lib/test/list_tests.py diff --git a/Src.GetRenamed/StdLib/Lib/test/lock_tests.py b/src/StdLib/Lib/test/lock_tests.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/lock_tests.py rename to src/StdLib/Lib/test/lock_tests.py diff --git a/Src.GetRenamed/StdLib/Lib/test/mailcap.txt b/src/StdLib/Lib/test/mailcap.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/mailcap.txt rename to src/StdLib/Lib/test/mailcap.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/make_ssl_certs.py b/src/StdLib/Lib/test/make_ssl_certs.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/make_ssl_certs.py rename to src/StdLib/Lib/test/make_ssl_certs.py diff --git a/Src.GetRenamed/StdLib/Lib/test/mapping_tests.py b/src/StdLib/Lib/test/mapping_tests.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/mapping_tests.py rename to src/StdLib/Lib/test/mapping_tests.py diff --git a/Src.GetRenamed/StdLib/Lib/test/math_testcases.txt b/src/StdLib/Lib/test/math_testcases.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/math_testcases.txt rename to src/StdLib/Lib/test/math_testcases.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/memory_watchdog.py b/src/StdLib/Lib/test/memory_watchdog.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/memory_watchdog.py rename to src/StdLib/Lib/test/memory_watchdog.py diff --git a/Src.GetRenamed/StdLib/Lib/test/mime.types b/src/StdLib/Lib/test/mime.types similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/mime.types rename to src/StdLib/Lib/test/mime.types diff --git a/Src.GetRenamed/StdLib/Lib/test/mock_socket.py b/src/StdLib/Lib/test/mock_socket.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/mock_socket.py rename to src/StdLib/Lib/test/mock_socket.py diff --git a/Src.GetRenamed/StdLib/Lib/test/mod_generics_cache.py b/src/StdLib/Lib/test/mod_generics_cache.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/mod_generics_cache.py rename to src/StdLib/Lib/test/mod_generics_cache.py diff --git a/Src.GetRenamed/StdLib/Lib/test/mp_fork_bomb.py b/src/StdLib/Lib/test/mp_fork_bomb.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/mp_fork_bomb.py rename to src/StdLib/Lib/test/mp_fork_bomb.py diff --git a/Src.GetRenamed/StdLib/Lib/test/multibytecodec_support.py b/src/StdLib/Lib/test/multibytecodec_support.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/multibytecodec_support.py rename to src/StdLib/Lib/test/multibytecodec_support.py diff --git a/Src.GetRenamed/StdLib/Lib/test/nokia.pem b/src/StdLib/Lib/test/nokia.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/nokia.pem rename to src/StdLib/Lib/test/nokia.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/nullbytecert.pem b/src/StdLib/Lib/test/nullbytecert.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/nullbytecert.pem rename to src/StdLib/Lib/test/nullbytecert.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/nullcert.pem b/src/StdLib/Lib/test/nullcert.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/nullcert.pem rename to src/StdLib/Lib/test/nullcert.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/outstanding_bugs.py b/src/StdLib/Lib/test/outstanding_bugs.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/outstanding_bugs.py rename to src/StdLib/Lib/test/outstanding_bugs.py diff --git a/Src.GetRenamed/StdLib/Lib/test/pickletester.py b/src/StdLib/Lib/test/pickletester.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/pickletester.py rename to src/StdLib/Lib/test/pickletester.py diff --git a/Src.GetRenamed/StdLib/Lib/test/profilee.py b/src/StdLib/Lib/test/profilee.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/profilee.py rename to src/StdLib/Lib/test/profilee.py diff --git a/Src.GetRenamed/StdLib/Lib/test/pstats.pck b/src/StdLib/Lib/test/pstats.pck similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/pstats.pck rename to src/StdLib/Lib/test/pstats.pck diff --git a/Src.GetRenamed/StdLib/Lib/test/pycacert.pem b/src/StdLib/Lib/test/pycacert.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/pycacert.pem rename to src/StdLib/Lib/test/pycacert.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/pycakey.pem b/src/StdLib/Lib/test/pycakey.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/pycakey.pem rename to src/StdLib/Lib/test/pycakey.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/pyclbr_input.py b/src/StdLib/Lib/test/pyclbr_input.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/pyclbr_input.py rename to src/StdLib/Lib/test/pyclbr_input.py diff --git a/Src.GetRenamed/StdLib/Lib/test/pydoc_mod.py b/src/StdLib/Lib/test/pydoc_mod.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/pydoc_mod.py rename to src/StdLib/Lib/test/pydoc_mod.py diff --git a/Src.GetRenamed/StdLib/Lib/test/pydocfodder.py b/src/StdLib/Lib/test/pydocfodder.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/pydocfodder.py rename to src/StdLib/Lib/test/pydocfodder.py diff --git a/Src.GetRenamed/StdLib/Lib/test/pystone.py b/src/StdLib/Lib/test/pystone.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/pystone.py rename to src/StdLib/Lib/test/pystone.py diff --git a/Src.GetRenamed/StdLib/Lib/test/randv2_32.pck b/src/StdLib/Lib/test/randv2_32.pck similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/randv2_32.pck rename to src/StdLib/Lib/test/randv2_32.pck diff --git a/Src.GetRenamed/StdLib/Lib/test/randv2_64.pck b/src/StdLib/Lib/test/randv2_64.pck similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/randv2_64.pck rename to src/StdLib/Lib/test/randv2_64.pck diff --git a/Src.GetRenamed/StdLib/Lib/test/randv3.pck b/src/StdLib/Lib/test/randv3.pck similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/randv3.pck rename to src/StdLib/Lib/test/randv3.pck diff --git a/Src.GetRenamed/StdLib/Lib/test/re_tests.py b/src/StdLib/Lib/test/re_tests.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/re_tests.py rename to src/StdLib/Lib/test/re_tests.py diff --git a/Src.GetRenamed/StdLib/Lib/test/regrtest.py b/src/StdLib/Lib/test/regrtest.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/regrtest.py rename to src/StdLib/Lib/test/regrtest.py diff --git a/Src.GetRenamed/StdLib/Lib/test/relimport.py b/src/StdLib/Lib/test/relimport.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/relimport.py rename to src/StdLib/Lib/test/relimport.py diff --git a/Src.GetRenamed/StdLib/Lib/test/reperf.py b/src/StdLib/Lib/test/reperf.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/reperf.py rename to src/StdLib/Lib/test/reperf.py diff --git a/Src.GetRenamed/StdLib/Lib/test/revocation.crl b/src/StdLib/Lib/test/revocation.crl similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/revocation.crl rename to src/StdLib/Lib/test/revocation.crl diff --git a/Src.GetRenamed/StdLib/Lib/test/sample_doctest.py b/src/StdLib/Lib/test/sample_doctest.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/sample_doctest.py rename to src/StdLib/Lib/test/sample_doctest.py diff --git a/Src.GetRenamed/StdLib/Lib/test/sample_doctest_no_docstrings.py b/src/StdLib/Lib/test/sample_doctest_no_docstrings.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/sample_doctest_no_docstrings.py rename to src/StdLib/Lib/test/sample_doctest_no_docstrings.py diff --git a/Src.GetRenamed/StdLib/Lib/test/sample_doctest_no_doctests.py b/src/StdLib/Lib/test/sample_doctest_no_doctests.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/sample_doctest_no_doctests.py rename to src/StdLib/Lib/test/sample_doctest_no_doctests.py diff --git a/Src.GetRenamed/StdLib/Lib/test/script_helper.py b/src/StdLib/Lib/test/script_helper.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/script_helper.py rename to src/StdLib/Lib/test/script_helper.py diff --git a/Src.GetRenamed/StdLib/Lib/test/selfsigned_pythontestdotnet.pem b/src/StdLib/Lib/test/selfsigned_pythontestdotnet.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/selfsigned_pythontestdotnet.pem rename to src/StdLib/Lib/test/selfsigned_pythontestdotnet.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/seq_tests.py b/src/StdLib/Lib/test/seq_tests.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/seq_tests.py rename to src/StdLib/Lib/test/seq_tests.py diff --git a/Src.GetRenamed/StdLib/Lib/test/sgml_input.html b/src/StdLib/Lib/test/sgml_input.html similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/sgml_input.html rename to src/StdLib/Lib/test/sgml_input.html diff --git a/Src.GetRenamed/StdLib/Lib/test/sha256.pem b/src/StdLib/Lib/test/sha256.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/sha256.pem rename to src/StdLib/Lib/test/sha256.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/sndhdrdata/README b/src/StdLib/Lib/test/sndhdrdata/README similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/sndhdrdata/README rename to src/StdLib/Lib/test/sndhdrdata/README diff --git a/Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.8svx b/src/StdLib/Lib/test/sndhdrdata/sndhdr.8svx similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.8svx rename to src/StdLib/Lib/test/sndhdrdata/sndhdr.8svx diff --git a/Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.aifc b/src/StdLib/Lib/test/sndhdrdata/sndhdr.aifc similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.aifc rename to src/StdLib/Lib/test/sndhdrdata/sndhdr.aifc diff --git a/Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.aiff b/src/StdLib/Lib/test/sndhdrdata/sndhdr.aiff similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.aiff rename to src/StdLib/Lib/test/sndhdrdata/sndhdr.aiff diff --git a/Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.au b/src/StdLib/Lib/test/sndhdrdata/sndhdr.au similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.au rename to src/StdLib/Lib/test/sndhdrdata/sndhdr.au diff --git a/Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.hcom b/src/StdLib/Lib/test/sndhdrdata/sndhdr.hcom similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.hcom rename to src/StdLib/Lib/test/sndhdrdata/sndhdr.hcom diff --git a/Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.sndt b/src/StdLib/Lib/test/sndhdrdata/sndhdr.sndt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.sndt rename to src/StdLib/Lib/test/sndhdrdata/sndhdr.sndt diff --git a/Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.voc b/src/StdLib/Lib/test/sndhdrdata/sndhdr.voc similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.voc rename to src/StdLib/Lib/test/sndhdrdata/sndhdr.voc diff --git a/Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.wav b/src/StdLib/Lib/test/sndhdrdata/sndhdr.wav similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/sndhdrdata/sndhdr.wav rename to src/StdLib/Lib/test/sndhdrdata/sndhdr.wav diff --git a/Src.GetRenamed/StdLib/Lib/test/sortperf.py b/src/StdLib/Lib/test/sortperf.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/sortperf.py rename to src/StdLib/Lib/test/sortperf.py diff --git a/Src.GetRenamed/StdLib/Lib/test/ssl_cert.pem b/src/StdLib/Lib/test/ssl_cert.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/ssl_cert.pem rename to src/StdLib/Lib/test/ssl_cert.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/ssl_key.passwd.pem b/src/StdLib/Lib/test/ssl_key.passwd.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/ssl_key.passwd.pem rename to src/StdLib/Lib/test/ssl_key.passwd.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/ssl_key.pem b/src/StdLib/Lib/test/ssl_key.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/ssl_key.pem rename to src/StdLib/Lib/test/ssl_key.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/ssl_servers.py b/src/StdLib/Lib/test/ssl_servers.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/ssl_servers.py rename to src/StdLib/Lib/test/ssl_servers.py diff --git a/Src.GetRenamed/StdLib/Lib/test/ssltests.py b/src/StdLib/Lib/test/ssltests.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/ssltests.py rename to src/StdLib/Lib/test/ssltests.py diff --git a/Src.GetRenamed/StdLib/Lib/test/string_tests.py b/src/StdLib/Lib/test/string_tests.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/string_tests.py rename to src/StdLib/Lib/test/string_tests.py diff --git a/Src.GetRenamed/StdLib/Lib/test/subprocessdata/fd_status.py b/src/StdLib/Lib/test/subprocessdata/fd_status.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/subprocessdata/fd_status.py rename to src/StdLib/Lib/test/subprocessdata/fd_status.py diff --git a/Src.GetRenamed/StdLib/Lib/test/subprocessdata/input_reader.py b/src/StdLib/Lib/test/subprocessdata/input_reader.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/subprocessdata/input_reader.py rename to src/StdLib/Lib/test/subprocessdata/input_reader.py diff --git a/Src.GetRenamed/StdLib/Lib/test/subprocessdata/qcat.py b/src/StdLib/Lib/test/subprocessdata/qcat.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/subprocessdata/qcat.py rename to src/StdLib/Lib/test/subprocessdata/qcat.py diff --git a/Src.GetRenamed/StdLib/Lib/test/subprocessdata/qgrep.py b/src/StdLib/Lib/test/subprocessdata/qgrep.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/subprocessdata/qgrep.py rename to src/StdLib/Lib/test/subprocessdata/qgrep.py diff --git a/Src.GetRenamed/StdLib/Lib/test/subprocessdata/sigchild_ignore.py b/src/StdLib/Lib/test/subprocessdata/sigchild_ignore.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/subprocessdata/sigchild_ignore.py rename to src/StdLib/Lib/test/subprocessdata/sigchild_ignore.py diff --git a/Src.GetRenamed/StdLib/Lib/test/support/__init__.py b/src/StdLib/Lib/test/support/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/support/__init__.py rename to src/StdLib/Lib/test/support/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/talos-2019-0758.pem b/src/StdLib/Lib/test/talos-2019-0758.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/talos-2019-0758.pem rename to src/StdLib/Lib/test/talos-2019-0758.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/test___all__.py b/src/StdLib/Lib/test/test___all__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test___all__.py rename to src/StdLib/Lib/test/test___all__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test___future__.py b/src/StdLib/Lib/test/test___future__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test___future__.py rename to src/StdLib/Lib/test/test___future__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test__locale.py b/src/StdLib/Lib/test/test__locale.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test__locale.py rename to src/StdLib/Lib/test/test__locale.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test__opcode.py b/src/StdLib/Lib/test/test__opcode.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test__opcode.py rename to src/StdLib/Lib/test/test__opcode.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test__osx_support.py b/src/StdLib/Lib/test/test__osx_support.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test__osx_support.py rename to src/StdLib/Lib/test/test__osx_support.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_abc.py b/src/StdLib/Lib/test/test_abc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_abc.py rename to src/StdLib/Lib/test/test_abc.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_abstract_numbers.py b/src/StdLib/Lib/test/test_abstract_numbers.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_abstract_numbers.py rename to src/StdLib/Lib/test/test_abstract_numbers.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_aifc.py b/src/StdLib/Lib/test/test_aifc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_aifc.py rename to src/StdLib/Lib/test/test_aifc.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_argparse.py b/src/StdLib/Lib/test/test_argparse.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_argparse.py rename to src/StdLib/Lib/test/test_argparse.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_array.py b/src/StdLib/Lib/test/test_array.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_array.py rename to src/StdLib/Lib/test/test_array.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_ast.py b/src/StdLib/Lib/test/test_ast.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_ast.py rename to src/StdLib/Lib/test/test_ast.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asynchat.py b/src/StdLib/Lib/test/test_asynchat.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asynchat.py rename to src/StdLib/Lib/test/test_asynchat.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/__init__.py b/src/StdLib/Lib/test/test_asyncio/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/__init__.py rename to src/StdLib/Lib/test/test_asyncio/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/__main__.py b/src/StdLib/Lib/test/test_asyncio/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/__main__.py rename to src/StdLib/Lib/test/test_asyncio/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/echo.py b/src/StdLib/Lib/test/test_asyncio/echo.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/echo.py rename to src/StdLib/Lib/test/test_asyncio/echo.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/echo2.py b/src/StdLib/Lib/test/test_asyncio/echo2.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/echo2.py rename to src/StdLib/Lib/test/test_asyncio/echo2.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/echo3.py b/src/StdLib/Lib/test/test_asyncio/echo3.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/echo3.py rename to src/StdLib/Lib/test/test_asyncio/echo3.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/keycert3.pem b/src/StdLib/Lib/test/test_asyncio/keycert3.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/keycert3.pem rename to src/StdLib/Lib/test/test_asyncio/keycert3.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/pycacert.pem b/src/StdLib/Lib/test/test_asyncio/pycacert.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/pycacert.pem rename to src/StdLib/Lib/test/test_asyncio/pycacert.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/ssl_cert.pem b/src/StdLib/Lib/test/test_asyncio/ssl_cert.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/ssl_cert.pem rename to src/StdLib/Lib/test/test_asyncio/ssl_cert.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/ssl_key.pem b/src/StdLib/Lib/test/test_asyncio/ssl_key.pem similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/ssl_key.pem rename to src/StdLib/Lib/test/test_asyncio/ssl_key.pem diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_base_events.py b/src/StdLib/Lib/test/test_asyncio/test_base_events.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_base_events.py rename to src/StdLib/Lib/test/test_asyncio/test_base_events.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_events.py b/src/StdLib/Lib/test/test_asyncio/test_events.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_events.py rename to src/StdLib/Lib/test/test_asyncio/test_events.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_futures.py b/src/StdLib/Lib/test/test_asyncio/test_futures.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_futures.py rename to src/StdLib/Lib/test/test_asyncio/test_futures.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_locks.py b/src/StdLib/Lib/test/test_asyncio/test_locks.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_locks.py rename to src/StdLib/Lib/test/test_asyncio/test_locks.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_proactor_events.py b/src/StdLib/Lib/test/test_asyncio/test_proactor_events.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_proactor_events.py rename to src/StdLib/Lib/test/test_asyncio/test_proactor_events.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_queues.py b/src/StdLib/Lib/test/test_asyncio/test_queues.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_queues.py rename to src/StdLib/Lib/test/test_asyncio/test_queues.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_selector_events.py b/src/StdLib/Lib/test/test_asyncio/test_selector_events.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_selector_events.py rename to src/StdLib/Lib/test/test_asyncio/test_selector_events.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_sslproto.py b/src/StdLib/Lib/test/test_asyncio/test_sslproto.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_sslproto.py rename to src/StdLib/Lib/test/test_asyncio/test_sslproto.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_streams.py b/src/StdLib/Lib/test/test_asyncio/test_streams.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_streams.py rename to src/StdLib/Lib/test/test_asyncio/test_streams.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_subprocess.py b/src/StdLib/Lib/test/test_asyncio/test_subprocess.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_subprocess.py rename to src/StdLib/Lib/test/test_asyncio/test_subprocess.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_tasks.py b/src/StdLib/Lib/test/test_asyncio/test_tasks.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_tasks.py rename to src/StdLib/Lib/test/test_asyncio/test_tasks.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_transports.py b/src/StdLib/Lib/test/test_asyncio/test_transports.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_transports.py rename to src/StdLib/Lib/test/test_asyncio/test_transports.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_unix_events.py b/src/StdLib/Lib/test/test_asyncio/test_unix_events.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_unix_events.py rename to src/StdLib/Lib/test/test_asyncio/test_unix_events.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_windows_events.py b/src/StdLib/Lib/test/test_asyncio/test_windows_events.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_windows_events.py rename to src/StdLib/Lib/test/test_asyncio/test_windows_events.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_windows_utils.py b/src/StdLib/Lib/test/test_asyncio/test_windows_utils.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncio/test_windows_utils.py rename to src/StdLib/Lib/test/test_asyncio/test_windows_utils.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_asyncore.py b/src/StdLib/Lib/test/test_asyncore.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_asyncore.py rename to src/StdLib/Lib/test/test_asyncore.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_atexit.py b/src/StdLib/Lib/test/test_atexit.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_atexit.py rename to src/StdLib/Lib/test/test_atexit.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_audioop.py b/src/StdLib/Lib/test/test_audioop.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_audioop.py rename to src/StdLib/Lib/test/test_audioop.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_augassign.py b/src/StdLib/Lib/test/test_augassign.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_augassign.py rename to src/StdLib/Lib/test/test_augassign.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_base64.py b/src/StdLib/Lib/test/test_base64.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_base64.py rename to src/StdLib/Lib/test/test_base64.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_bigaddrspace.py b/src/StdLib/Lib/test/test_bigaddrspace.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_bigaddrspace.py rename to src/StdLib/Lib/test/test_bigaddrspace.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_bigmem.py b/src/StdLib/Lib/test/test_bigmem.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_bigmem.py rename to src/StdLib/Lib/test/test_bigmem.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_binascii.py b/src/StdLib/Lib/test/test_binascii.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_binascii.py rename to src/StdLib/Lib/test/test_binascii.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_binhex.py b/src/StdLib/Lib/test/test_binhex.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_binhex.py rename to src/StdLib/Lib/test/test_binhex.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_binop.py b/src/StdLib/Lib/test/test_binop.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_binop.py rename to src/StdLib/Lib/test/test_binop.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_bisect.py b/src/StdLib/Lib/test/test_bisect.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_bisect.py rename to src/StdLib/Lib/test/test_bisect.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_bool.py b/src/StdLib/Lib/test/test_bool.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_bool.py rename to src/StdLib/Lib/test/test_bool.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_buffer.py b/src/StdLib/Lib/test/test_buffer.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_buffer.py rename to src/StdLib/Lib/test/test_buffer.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_bufio.py b/src/StdLib/Lib/test/test_bufio.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_bufio.py rename to src/StdLib/Lib/test/test_bufio.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_builtin.py b/src/StdLib/Lib/test/test_builtin.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_builtin.py rename to src/StdLib/Lib/test/test_builtin.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_bytes.py b/src/StdLib/Lib/test/test_bytes.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_bytes.py rename to src/StdLib/Lib/test/test_bytes.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_bz2.py b/src/StdLib/Lib/test/test_bz2.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_bz2.py rename to src/StdLib/Lib/test/test_bz2.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_calendar.py b/src/StdLib/Lib/test/test_calendar.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_calendar.py rename to src/StdLib/Lib/test/test_calendar.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_call.py b/src/StdLib/Lib/test/test_call.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_call.py rename to src/StdLib/Lib/test/test_call.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_capi.py b/src/StdLib/Lib/test/test_capi.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_capi.py rename to src/StdLib/Lib/test/test_capi.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_cgi.py b/src/StdLib/Lib/test/test_cgi.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_cgi.py rename to src/StdLib/Lib/test/test_cgi.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_cgitb.py b/src/StdLib/Lib/test/test_cgitb.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_cgitb.py rename to src/StdLib/Lib/test/test_cgitb.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_charmapcodec.py b/src/StdLib/Lib/test/test_charmapcodec.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_charmapcodec.py rename to src/StdLib/Lib/test/test_charmapcodec.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_class.py b/src/StdLib/Lib/test/test_class.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_class.py rename to src/StdLib/Lib/test/test_class.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_cmath.py b/src/StdLib/Lib/test/test_cmath.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_cmath.py rename to src/StdLib/Lib/test/test_cmath.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_cmd.py b/src/StdLib/Lib/test/test_cmd.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_cmd.py rename to src/StdLib/Lib/test/test_cmd.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_cmd_line.py b/src/StdLib/Lib/test/test_cmd_line.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_cmd_line.py rename to src/StdLib/Lib/test/test_cmd_line.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_cmd_line_script.py b/src/StdLib/Lib/test/test_cmd_line_script.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_cmd_line_script.py rename to src/StdLib/Lib/test/test_cmd_line_script.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_code.py b/src/StdLib/Lib/test/test_code.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_code.py rename to src/StdLib/Lib/test/test_code.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_code_module.py b/src/StdLib/Lib/test/test_code_module.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_code_module.py rename to src/StdLib/Lib/test/test_code_module.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_codeccallbacks.py b/src/StdLib/Lib/test/test_codeccallbacks.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_codeccallbacks.py rename to src/StdLib/Lib/test/test_codeccallbacks.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_codecencodings_cn.py b/src/StdLib/Lib/test/test_codecencodings_cn.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_codecencodings_cn.py rename to src/StdLib/Lib/test/test_codecencodings_cn.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_codecencodings_hk.py b/src/StdLib/Lib/test/test_codecencodings_hk.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_codecencodings_hk.py rename to src/StdLib/Lib/test/test_codecencodings_hk.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_codecencodings_iso2022.py b/src/StdLib/Lib/test/test_codecencodings_iso2022.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_codecencodings_iso2022.py rename to src/StdLib/Lib/test/test_codecencodings_iso2022.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_codecencodings_jp.py b/src/StdLib/Lib/test/test_codecencodings_jp.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_codecencodings_jp.py rename to src/StdLib/Lib/test/test_codecencodings_jp.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_codecencodings_kr.py b/src/StdLib/Lib/test/test_codecencodings_kr.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_codecencodings_kr.py rename to src/StdLib/Lib/test/test_codecencodings_kr.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_codecencodings_tw.py b/src/StdLib/Lib/test/test_codecencodings_tw.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_codecencodings_tw.py rename to src/StdLib/Lib/test/test_codecencodings_tw.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_codecmaps_cn.py b/src/StdLib/Lib/test/test_codecmaps_cn.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_codecmaps_cn.py rename to src/StdLib/Lib/test/test_codecmaps_cn.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_codecmaps_hk.py b/src/StdLib/Lib/test/test_codecmaps_hk.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_codecmaps_hk.py rename to src/StdLib/Lib/test/test_codecmaps_hk.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_codecmaps_jp.py b/src/StdLib/Lib/test/test_codecmaps_jp.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_codecmaps_jp.py rename to src/StdLib/Lib/test/test_codecmaps_jp.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_codecmaps_kr.py b/src/StdLib/Lib/test/test_codecmaps_kr.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_codecmaps_kr.py rename to src/StdLib/Lib/test/test_codecmaps_kr.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_codecmaps_tw.py b/src/StdLib/Lib/test/test_codecmaps_tw.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_codecmaps_tw.py rename to src/StdLib/Lib/test/test_codecmaps_tw.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_codecs.py b/src/StdLib/Lib/test/test_codecs.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_codecs.py rename to src/StdLib/Lib/test/test_codecs.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_codeop.py b/src/StdLib/Lib/test/test_codeop.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_codeop.py rename to src/StdLib/Lib/test/test_codeop.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_collections.py b/src/StdLib/Lib/test/test_collections.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_collections.py rename to src/StdLib/Lib/test/test_collections.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_colorsys.py b/src/StdLib/Lib/test/test_colorsys.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_colorsys.py rename to src/StdLib/Lib/test/test_colorsys.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_compare.py b/src/StdLib/Lib/test/test_compare.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_compare.py rename to src/StdLib/Lib/test/test_compare.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_compile.py b/src/StdLib/Lib/test/test_compile.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_compile.py rename to src/StdLib/Lib/test/test_compile.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_compileall.py b/src/StdLib/Lib/test/test_compileall.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_compileall.py rename to src/StdLib/Lib/test/test_compileall.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_complex.py b/src/StdLib/Lib/test/test_complex.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_complex.py rename to src/StdLib/Lib/test/test_complex.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_concurrent_futures.py b/src/StdLib/Lib/test/test_concurrent_futures.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_concurrent_futures.py rename to src/StdLib/Lib/test/test_concurrent_futures.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_configparser.py b/src/StdLib/Lib/test/test_configparser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_configparser.py rename to src/StdLib/Lib/test/test_configparser.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_contains.py b/src/StdLib/Lib/test/test_contains.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_contains.py rename to src/StdLib/Lib/test/test_contains.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_contextlib.py b/src/StdLib/Lib/test/test_contextlib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_contextlib.py rename to src/StdLib/Lib/test/test_contextlib.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_copy.py b/src/StdLib/Lib/test/test_copy.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_copy.py rename to src/StdLib/Lib/test/test_copy.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_copyreg.py b/src/StdLib/Lib/test/test_copyreg.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_copyreg.py rename to src/StdLib/Lib/test/test_copyreg.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_cprofile.py b/src/StdLib/Lib/test/test_cprofile.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_cprofile.py rename to src/StdLib/Lib/test/test_cprofile.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_crashers.py b/src/StdLib/Lib/test/test_crashers.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_crashers.py rename to src/StdLib/Lib/test/test_crashers.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_crypt.py b/src/StdLib/Lib/test/test_crypt.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_crypt.py rename to src/StdLib/Lib/test/test_crypt.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_csv.py b/src/StdLib/Lib/test/test_csv.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_csv.py rename to src/StdLib/Lib/test/test_csv.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_ctypes.py b/src/StdLib/Lib/test/test_ctypes.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_ctypes.py rename to src/StdLib/Lib/test/test_ctypes.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_curses.py b/src/StdLib/Lib/test/test_curses.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_curses.py rename to src/StdLib/Lib/test/test_curses.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_datetime.py b/src/StdLib/Lib/test/test_datetime.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_datetime.py rename to src/StdLib/Lib/test/test_datetime.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_dbm.py b/src/StdLib/Lib/test/test_dbm.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_dbm.py rename to src/StdLib/Lib/test/test_dbm.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_dbm_dumb.py b/src/StdLib/Lib/test/test_dbm_dumb.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_dbm_dumb.py rename to src/StdLib/Lib/test/test_dbm_dumb.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_dbm_gnu.py b/src/StdLib/Lib/test/test_dbm_gnu.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_dbm_gnu.py rename to src/StdLib/Lib/test/test_dbm_gnu.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_dbm_ndbm.py b/src/StdLib/Lib/test/test_dbm_ndbm.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_dbm_ndbm.py rename to src/StdLib/Lib/test/test_dbm_ndbm.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_decimal.py b/src/StdLib/Lib/test/test_decimal.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_decimal.py rename to src/StdLib/Lib/test/test_decimal.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_decorators.py b/src/StdLib/Lib/test/test_decorators.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_decorators.py rename to src/StdLib/Lib/test/test_decorators.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_defaultdict.py b/src/StdLib/Lib/test/test_defaultdict.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_defaultdict.py rename to src/StdLib/Lib/test/test_defaultdict.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_deque.py b/src/StdLib/Lib/test/test_deque.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_deque.py rename to src/StdLib/Lib/test/test_deque.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_descr.py b/src/StdLib/Lib/test/test_descr.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_descr.py rename to src/StdLib/Lib/test/test_descr.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_descrtut.py b/src/StdLib/Lib/test/test_descrtut.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_descrtut.py rename to src/StdLib/Lib/test/test_descrtut.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_devpoll.py b/src/StdLib/Lib/test/test_devpoll.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_devpoll.py rename to src/StdLib/Lib/test/test_devpoll.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_dict.py b/src/StdLib/Lib/test/test_dict.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_dict.py rename to src/StdLib/Lib/test/test_dict.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_dictcomps.py b/src/StdLib/Lib/test/test_dictcomps.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_dictcomps.py rename to src/StdLib/Lib/test/test_dictcomps.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_dictviews.py b/src/StdLib/Lib/test/test_dictviews.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_dictviews.py rename to src/StdLib/Lib/test/test_dictviews.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_difflib.py b/src/StdLib/Lib/test/test_difflib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_difflib.py rename to src/StdLib/Lib/test/test_difflib.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_difflib_expect.html b/src/StdLib/Lib/test/test_difflib_expect.html similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_difflib_expect.html rename to src/StdLib/Lib/test/test_difflib_expect.html diff --git a/Src.GetRenamed/StdLib/Lib/test/test_dis.py b/src/StdLib/Lib/test/test_dis.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_dis.py rename to src/StdLib/Lib/test/test_dis.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_distutils.py b/src/StdLib/Lib/test/test_distutils.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_distutils.py rename to src/StdLib/Lib/test/test_distutils.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_doctest.py b/src/StdLib/Lib/test/test_doctest.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_doctest.py rename to src/StdLib/Lib/test/test_doctest.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_doctest.txt b/src/StdLib/Lib/test/test_doctest.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_doctest.txt rename to src/StdLib/Lib/test/test_doctest.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_doctest2.py b/src/StdLib/Lib/test/test_doctest2.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_doctest2.py rename to src/StdLib/Lib/test/test_doctest2.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_doctest2.txt b/src/StdLib/Lib/test/test_doctest2.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_doctest2.txt rename to src/StdLib/Lib/test/test_doctest2.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_doctest3.txt b/src/StdLib/Lib/test/test_doctest3.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_doctest3.txt rename to src/StdLib/Lib/test/test_doctest3.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_doctest4.txt b/src/StdLib/Lib/test/test_doctest4.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_doctest4.txt rename to src/StdLib/Lib/test/test_doctest4.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_docxmlrpc.py b/src/StdLib/Lib/test/test_docxmlrpc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_docxmlrpc.py rename to src/StdLib/Lib/test/test_docxmlrpc.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_dummy_thread.py b/src/StdLib/Lib/test/test_dummy_thread.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_dummy_thread.py rename to src/StdLib/Lib/test/test_dummy_thread.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_dummy_threading.py b/src/StdLib/Lib/test/test_dummy_threading.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_dummy_threading.py rename to src/StdLib/Lib/test/test_dummy_threading.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_dynamic.py b/src/StdLib/Lib/test/test_dynamic.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_dynamic.py rename to src/StdLib/Lib/test/test_dynamic.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_dynamicclassattribute.py b/src/StdLib/Lib/test/test_dynamicclassattribute.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_dynamicclassattribute.py rename to src/StdLib/Lib/test/test_dynamicclassattribute.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/__init__.py b/src/StdLib/Lib/test/test_email/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/__init__.py rename to src/StdLib/Lib/test/test_email/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/__main__.py b/src/StdLib/Lib/test/test_email/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/__main__.py rename to src/StdLib/Lib/test/test_email/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/PyBanner048.gif b/src/StdLib/Lib/test/test_email/data/PyBanner048.gif similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/PyBanner048.gif rename to src/StdLib/Lib/test/test_email/data/PyBanner048.gif diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/audiotest.au b/src/StdLib/Lib/test/test_email/data/audiotest.au similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/audiotest.au rename to src/StdLib/Lib/test/test_email/data/audiotest.au diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_01.txt b/src/StdLib/Lib/test/test_email/data/msg_01.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_01.txt rename to src/StdLib/Lib/test/test_email/data/msg_01.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_02.txt b/src/StdLib/Lib/test/test_email/data/msg_02.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_02.txt rename to src/StdLib/Lib/test/test_email/data/msg_02.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_03.txt b/src/StdLib/Lib/test/test_email/data/msg_03.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_03.txt rename to src/StdLib/Lib/test/test_email/data/msg_03.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_04.txt b/src/StdLib/Lib/test/test_email/data/msg_04.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_04.txt rename to src/StdLib/Lib/test/test_email/data/msg_04.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_05.txt b/src/StdLib/Lib/test/test_email/data/msg_05.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_05.txt rename to src/StdLib/Lib/test/test_email/data/msg_05.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_06.txt b/src/StdLib/Lib/test/test_email/data/msg_06.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_06.txt rename to src/StdLib/Lib/test/test_email/data/msg_06.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_07.txt b/src/StdLib/Lib/test/test_email/data/msg_07.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_07.txt rename to src/StdLib/Lib/test/test_email/data/msg_07.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_08.txt b/src/StdLib/Lib/test/test_email/data/msg_08.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_08.txt rename to src/StdLib/Lib/test/test_email/data/msg_08.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_09.txt b/src/StdLib/Lib/test/test_email/data/msg_09.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_09.txt rename to src/StdLib/Lib/test/test_email/data/msg_09.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_10.txt b/src/StdLib/Lib/test/test_email/data/msg_10.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_10.txt rename to src/StdLib/Lib/test/test_email/data/msg_10.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_11.txt b/src/StdLib/Lib/test/test_email/data/msg_11.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_11.txt rename to src/StdLib/Lib/test/test_email/data/msg_11.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_12.txt b/src/StdLib/Lib/test/test_email/data/msg_12.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_12.txt rename to src/StdLib/Lib/test/test_email/data/msg_12.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_12a.txt b/src/StdLib/Lib/test/test_email/data/msg_12a.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_12a.txt rename to src/StdLib/Lib/test/test_email/data/msg_12a.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_13.txt b/src/StdLib/Lib/test/test_email/data/msg_13.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_13.txt rename to src/StdLib/Lib/test/test_email/data/msg_13.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_14.txt b/src/StdLib/Lib/test/test_email/data/msg_14.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_14.txt rename to src/StdLib/Lib/test/test_email/data/msg_14.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_15.txt b/src/StdLib/Lib/test/test_email/data/msg_15.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_15.txt rename to src/StdLib/Lib/test/test_email/data/msg_15.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_16.txt b/src/StdLib/Lib/test/test_email/data/msg_16.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_16.txt rename to src/StdLib/Lib/test/test_email/data/msg_16.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_17.txt b/src/StdLib/Lib/test/test_email/data/msg_17.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_17.txt rename to src/StdLib/Lib/test/test_email/data/msg_17.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_18.txt b/src/StdLib/Lib/test/test_email/data/msg_18.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_18.txt rename to src/StdLib/Lib/test/test_email/data/msg_18.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_19.txt b/src/StdLib/Lib/test/test_email/data/msg_19.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_19.txt rename to src/StdLib/Lib/test/test_email/data/msg_19.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_20.txt b/src/StdLib/Lib/test/test_email/data/msg_20.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_20.txt rename to src/StdLib/Lib/test/test_email/data/msg_20.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_21.txt b/src/StdLib/Lib/test/test_email/data/msg_21.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_21.txt rename to src/StdLib/Lib/test/test_email/data/msg_21.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_22.txt b/src/StdLib/Lib/test/test_email/data/msg_22.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_22.txt rename to src/StdLib/Lib/test/test_email/data/msg_22.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_23.txt b/src/StdLib/Lib/test/test_email/data/msg_23.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_23.txt rename to src/StdLib/Lib/test/test_email/data/msg_23.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_24.txt b/src/StdLib/Lib/test/test_email/data/msg_24.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_24.txt rename to src/StdLib/Lib/test/test_email/data/msg_24.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_25.txt b/src/StdLib/Lib/test/test_email/data/msg_25.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_25.txt rename to src/StdLib/Lib/test/test_email/data/msg_25.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_26.txt b/src/StdLib/Lib/test/test_email/data/msg_26.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_26.txt rename to src/StdLib/Lib/test/test_email/data/msg_26.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_27.txt b/src/StdLib/Lib/test/test_email/data/msg_27.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_27.txt rename to src/StdLib/Lib/test/test_email/data/msg_27.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_28.txt b/src/StdLib/Lib/test/test_email/data/msg_28.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_28.txt rename to src/StdLib/Lib/test/test_email/data/msg_28.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_29.txt b/src/StdLib/Lib/test/test_email/data/msg_29.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_29.txt rename to src/StdLib/Lib/test/test_email/data/msg_29.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_30.txt b/src/StdLib/Lib/test/test_email/data/msg_30.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_30.txt rename to src/StdLib/Lib/test/test_email/data/msg_30.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_31.txt b/src/StdLib/Lib/test/test_email/data/msg_31.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_31.txt rename to src/StdLib/Lib/test/test_email/data/msg_31.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_32.txt b/src/StdLib/Lib/test/test_email/data/msg_32.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_32.txt rename to src/StdLib/Lib/test/test_email/data/msg_32.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_33.txt b/src/StdLib/Lib/test/test_email/data/msg_33.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_33.txt rename to src/StdLib/Lib/test/test_email/data/msg_33.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_34.txt b/src/StdLib/Lib/test/test_email/data/msg_34.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_34.txt rename to src/StdLib/Lib/test/test_email/data/msg_34.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_35.txt b/src/StdLib/Lib/test/test_email/data/msg_35.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_35.txt rename to src/StdLib/Lib/test/test_email/data/msg_35.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_36.txt b/src/StdLib/Lib/test/test_email/data/msg_36.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_36.txt rename to src/StdLib/Lib/test/test_email/data/msg_36.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_37.txt b/src/StdLib/Lib/test/test_email/data/msg_37.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_37.txt rename to src/StdLib/Lib/test/test_email/data/msg_37.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_38.txt b/src/StdLib/Lib/test/test_email/data/msg_38.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_38.txt rename to src/StdLib/Lib/test/test_email/data/msg_38.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_39.txt b/src/StdLib/Lib/test/test_email/data/msg_39.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_39.txt rename to src/StdLib/Lib/test/test_email/data/msg_39.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_40.txt b/src/StdLib/Lib/test/test_email/data/msg_40.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_40.txt rename to src/StdLib/Lib/test/test_email/data/msg_40.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_41.txt b/src/StdLib/Lib/test/test_email/data/msg_41.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_41.txt rename to src/StdLib/Lib/test/test_email/data/msg_41.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_42.txt b/src/StdLib/Lib/test/test_email/data/msg_42.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_42.txt rename to src/StdLib/Lib/test/test_email/data/msg_42.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_43.txt b/src/StdLib/Lib/test/test_email/data/msg_43.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_43.txt rename to src/StdLib/Lib/test/test_email/data/msg_43.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_44.txt b/src/StdLib/Lib/test/test_email/data/msg_44.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_44.txt rename to src/StdLib/Lib/test/test_email/data/msg_44.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_45.txt b/src/StdLib/Lib/test/test_email/data/msg_45.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_45.txt rename to src/StdLib/Lib/test/test_email/data/msg_45.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_46.txt b/src/StdLib/Lib/test/test_email/data/msg_46.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/data/msg_46.txt rename to src/StdLib/Lib/test/test_email/data/msg_46.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/test__encoded_words.py b/src/StdLib/Lib/test/test_email/test__encoded_words.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/test__encoded_words.py rename to src/StdLib/Lib/test/test_email/test__encoded_words.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/test__header_value_parser.py b/src/StdLib/Lib/test/test_email/test__header_value_parser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/test__header_value_parser.py rename to src/StdLib/Lib/test/test_email/test__header_value_parser.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/test_asian_codecs.py b/src/StdLib/Lib/test/test_email/test_asian_codecs.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/test_asian_codecs.py rename to src/StdLib/Lib/test/test_email/test_asian_codecs.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/test_contentmanager.py b/src/StdLib/Lib/test/test_email/test_contentmanager.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/test_contentmanager.py rename to src/StdLib/Lib/test/test_email/test_contentmanager.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/test_defect_handling.py b/src/StdLib/Lib/test/test_email/test_defect_handling.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/test_defect_handling.py rename to src/StdLib/Lib/test/test_email/test_defect_handling.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/test_email.py b/src/StdLib/Lib/test/test_email/test_email.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/test_email.py rename to src/StdLib/Lib/test/test_email/test_email.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/test_generator.py b/src/StdLib/Lib/test/test_email/test_generator.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/test_generator.py rename to src/StdLib/Lib/test/test_email/test_generator.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/test_headerregistry.py b/src/StdLib/Lib/test/test_email/test_headerregistry.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/test_headerregistry.py rename to src/StdLib/Lib/test/test_email/test_headerregistry.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/test_inversion.py b/src/StdLib/Lib/test/test_email/test_inversion.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/test_inversion.py rename to src/StdLib/Lib/test/test_email/test_inversion.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/test_message.py b/src/StdLib/Lib/test/test_email/test_message.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/test_message.py rename to src/StdLib/Lib/test/test_email/test_message.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/test_parser.py b/src/StdLib/Lib/test/test_email/test_parser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/test_parser.py rename to src/StdLib/Lib/test/test_email/test_parser.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/test_pickleable.py b/src/StdLib/Lib/test/test_email/test_pickleable.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/test_pickleable.py rename to src/StdLib/Lib/test/test_email/test_pickleable.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/test_policy.py b/src/StdLib/Lib/test/test_email/test_policy.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/test_policy.py rename to src/StdLib/Lib/test/test_email/test_policy.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/test_utils.py b/src/StdLib/Lib/test/test_email/test_utils.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/test_utils.py rename to src/StdLib/Lib/test/test_email/test_utils.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_email/torture_test.py b/src/StdLib/Lib/test/test_email/torture_test.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_email/torture_test.py rename to src/StdLib/Lib/test/test_email/torture_test.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_ensurepip.py b/src/StdLib/Lib/test/test_ensurepip.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_ensurepip.py rename to src/StdLib/Lib/test/test_ensurepip.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_enum.py b/src/StdLib/Lib/test/test_enum.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_enum.py rename to src/StdLib/Lib/test/test_enum.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_enumerate.py b/src/StdLib/Lib/test/test_enumerate.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_enumerate.py rename to src/StdLib/Lib/test/test_enumerate.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_eof.py b/src/StdLib/Lib/test/test_eof.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_eof.py rename to src/StdLib/Lib/test/test_eof.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_epoll.py b/src/StdLib/Lib/test/test_epoll.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_epoll.py rename to src/StdLib/Lib/test/test_epoll.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_errno.py b/src/StdLib/Lib/test/test_errno.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_errno.py rename to src/StdLib/Lib/test/test_errno.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_exception_variations.py b/src/StdLib/Lib/test/test_exception_variations.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_exception_variations.py rename to src/StdLib/Lib/test/test_exception_variations.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_exceptions.py b/src/StdLib/Lib/test/test_exceptions.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_exceptions.py rename to src/StdLib/Lib/test/test_exceptions.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_extcall.py b/src/StdLib/Lib/test/test_extcall.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_extcall.py rename to src/StdLib/Lib/test/test_extcall.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_faulthandler.py b/src/StdLib/Lib/test/test_faulthandler.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_faulthandler.py rename to src/StdLib/Lib/test/test_faulthandler.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_fcntl.py b/src/StdLib/Lib/test/test_fcntl.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_fcntl.py rename to src/StdLib/Lib/test/test_fcntl.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_file.py b/src/StdLib/Lib/test/test_file.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_file.py rename to src/StdLib/Lib/test/test_file.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_file_eintr.py b/src/StdLib/Lib/test/test_file_eintr.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_file_eintr.py rename to src/StdLib/Lib/test/test_file_eintr.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_filecmp.py b/src/StdLib/Lib/test/test_filecmp.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_filecmp.py rename to src/StdLib/Lib/test/test_filecmp.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_fileinput.py b/src/StdLib/Lib/test/test_fileinput.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_fileinput.py rename to src/StdLib/Lib/test/test_fileinput.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_fileio.py b/src/StdLib/Lib/test/test_fileio.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_fileio.py rename to src/StdLib/Lib/test/test_fileio.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_finalization.py b/src/StdLib/Lib/test/test_finalization.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_finalization.py rename to src/StdLib/Lib/test/test_finalization.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_float.py b/src/StdLib/Lib/test/test_float.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_float.py rename to src/StdLib/Lib/test/test_float.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_flufl.py b/src/StdLib/Lib/test/test_flufl.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_flufl.py rename to src/StdLib/Lib/test/test_flufl.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_fnmatch.py b/src/StdLib/Lib/test/test_fnmatch.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_fnmatch.py rename to src/StdLib/Lib/test/test_fnmatch.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_fork1.py b/src/StdLib/Lib/test/test_fork1.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_fork1.py rename to src/StdLib/Lib/test/test_fork1.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_format.py b/src/StdLib/Lib/test/test_format.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_format.py rename to src/StdLib/Lib/test/test_format.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_fractions.py b/src/StdLib/Lib/test/test_fractions.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_fractions.py rename to src/StdLib/Lib/test/test_fractions.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_frame.py b/src/StdLib/Lib/test/test_frame.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_frame.py rename to src/StdLib/Lib/test/test_frame.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_fstring.py b/src/StdLib/Lib/test/test_fstring.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_fstring.py rename to src/StdLib/Lib/test/test_fstring.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_ftplib.py b/src/StdLib/Lib/test/test_ftplib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_ftplib.py rename to src/StdLib/Lib/test/test_ftplib.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_funcattrs.py b/src/StdLib/Lib/test/test_funcattrs.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_funcattrs.py rename to src/StdLib/Lib/test/test_funcattrs.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_functools.py b/src/StdLib/Lib/test/test_functools.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_functools.py rename to src/StdLib/Lib/test/test_functools.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_future.py b/src/StdLib/Lib/test/test_future.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_future.py rename to src/StdLib/Lib/test/test_future.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_future3.py b/src/StdLib/Lib/test/test_future3.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_future3.py rename to src/StdLib/Lib/test/test_future3.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_future4.py b/src/StdLib/Lib/test/test_future4.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_future4.py rename to src/StdLib/Lib/test/test_future4.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_future5.py b/src/StdLib/Lib/test/test_future5.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_future5.py rename to src/StdLib/Lib/test/test_future5.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_gc.py b/src/StdLib/Lib/test/test_gc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_gc.py rename to src/StdLib/Lib/test/test_gc.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_gdb.py b/src/StdLib/Lib/test/test_gdb.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_gdb.py rename to src/StdLib/Lib/test/test_gdb.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_generators.py b/src/StdLib/Lib/test/test_generators.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_generators.py rename to src/StdLib/Lib/test/test_generators.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_genericpath.py b/src/StdLib/Lib/test/test_genericpath.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_genericpath.py rename to src/StdLib/Lib/test/test_genericpath.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_genexps.py b/src/StdLib/Lib/test/test_genexps.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_genexps.py rename to src/StdLib/Lib/test/test_genexps.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_getargs2.py b/src/StdLib/Lib/test/test_getargs2.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_getargs2.py rename to src/StdLib/Lib/test/test_getargs2.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_getopt.py b/src/StdLib/Lib/test/test_getopt.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_getopt.py rename to src/StdLib/Lib/test/test_getopt.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_getpass.py b/src/StdLib/Lib/test/test_getpass.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_getpass.py rename to src/StdLib/Lib/test/test_getpass.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_gettext.py b/src/StdLib/Lib/test/test_gettext.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_gettext.py rename to src/StdLib/Lib/test/test_gettext.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_glob.py b/src/StdLib/Lib/test/test_glob.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_glob.py rename to src/StdLib/Lib/test/test_glob.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_global.py b/src/StdLib/Lib/test/test_global.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_global.py rename to src/StdLib/Lib/test/test_global.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_grammar.py b/src/StdLib/Lib/test/test_grammar.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_grammar.py rename to src/StdLib/Lib/test/test_grammar.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_grp.py b/src/StdLib/Lib/test/test_grp.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_grp.py rename to src/StdLib/Lib/test/test_grp.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_gzip.py b/src/StdLib/Lib/test/test_gzip.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_gzip.py rename to src/StdLib/Lib/test/test_gzip.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_hash.py b/src/StdLib/Lib/test/test_hash.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_hash.py rename to src/StdLib/Lib/test/test_hash.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_hashlib.py b/src/StdLib/Lib/test/test_hashlib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_hashlib.py rename to src/StdLib/Lib/test/test_hashlib.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_heapq.py b/src/StdLib/Lib/test/test_heapq.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_heapq.py rename to src/StdLib/Lib/test/test_heapq.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_hmac.py b/src/StdLib/Lib/test/test_hmac.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_hmac.py rename to src/StdLib/Lib/test/test_hmac.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_html.py b/src/StdLib/Lib/test/test_html.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_html.py rename to src/StdLib/Lib/test/test_html.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_htmlparser.py b/src/StdLib/Lib/test/test_htmlparser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_htmlparser.py rename to src/StdLib/Lib/test/test_htmlparser.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_http_cookiejar.py b/src/StdLib/Lib/test/test_http_cookiejar.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_http_cookiejar.py rename to src/StdLib/Lib/test/test_http_cookiejar.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_http_cookies.py b/src/StdLib/Lib/test/test_http_cookies.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_http_cookies.py rename to src/StdLib/Lib/test/test_http_cookies.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_httplib.py b/src/StdLib/Lib/test/test_httplib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_httplib.py rename to src/StdLib/Lib/test/test_httplib.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_httpservers.py b/src/StdLib/Lib/test/test_httpservers.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_httpservers.py rename to src/StdLib/Lib/test/test_httpservers.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_idle.py b/src/StdLib/Lib/test/test_idle.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_idle.py rename to src/StdLib/Lib/test/test_idle.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_imaplib.py b/src/StdLib/Lib/test/test_imaplib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_imaplib.py rename to src/StdLib/Lib/test/test_imaplib.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_imghdr.py b/src/StdLib/Lib/test/test_imghdr.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_imghdr.py rename to src/StdLib/Lib/test/test_imghdr.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_imp.py b/src/StdLib/Lib/test/test_imp.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_imp.py rename to src/StdLib/Lib/test/test_imp.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_import.py b/src/StdLib/Lib/test/test_import.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_import.py rename to src/StdLib/Lib/test/test_import.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/__init__.py b/src/StdLib/Lib/test/test_importlib/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/__init__.py rename to src/StdLib/Lib/test/test_importlib/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/__main__.py b/src/StdLib/Lib/test/test_importlib/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/__main__.py rename to src/StdLib/Lib/test/test_importlib/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/abc.py b/src/StdLib/Lib/test/test_importlib/abc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/abc.py rename to src/StdLib/Lib/test/test_importlib/abc.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/builtin/__init__.py b/src/StdLib/Lib/test/test_importlib/builtin/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/builtin/__init__.py rename to src/StdLib/Lib/test/test_importlib/builtin/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/builtin/__main__.py b/src/StdLib/Lib/test/test_importlib/builtin/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/builtin/__main__.py rename to src/StdLib/Lib/test/test_importlib/builtin/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/builtin/test_finder.py b/src/StdLib/Lib/test/test_importlib/builtin/test_finder.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/builtin/test_finder.py rename to src/StdLib/Lib/test/test_importlib/builtin/test_finder.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/builtin/test_loader.py b/src/StdLib/Lib/test/test_importlib/builtin/test_loader.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/builtin/test_loader.py rename to src/StdLib/Lib/test/test_importlib/builtin/test_loader.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/builtin/util.py b/src/StdLib/Lib/test/test_importlib/builtin/util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/builtin/util.py rename to src/StdLib/Lib/test/test_importlib/builtin/util.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/__init__.py b/src/StdLib/Lib/test/test_importlib/extension/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/__init__.py rename to src/StdLib/Lib/test/test_importlib/extension/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/__main__.py b/src/StdLib/Lib/test/test_importlib/extension/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/__main__.py rename to src/StdLib/Lib/test/test_importlib/extension/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py b/src/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py rename to src/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/test_finder.py b/src/StdLib/Lib/test/test_importlib/extension/test_finder.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/test_finder.py rename to src/StdLib/Lib/test/test_importlib/extension/test_finder.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/test_loader.py b/src/StdLib/Lib/test/test_importlib/extension/test_loader.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/test_loader.py rename to src/StdLib/Lib/test/test_importlib/extension/test_loader.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/test_path_hook.py b/src/StdLib/Lib/test/test_importlib/extension/test_path_hook.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/test_path_hook.py rename to src/StdLib/Lib/test/test_importlib/extension/test_path_hook.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/util.py b/src/StdLib/Lib/test/test_importlib/extension/util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/extension/util.py rename to src/StdLib/Lib/test/test_importlib/extension/util.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/frozen/__init__.py b/src/StdLib/Lib/test/test_importlib/frozen/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/frozen/__init__.py rename to src/StdLib/Lib/test/test_importlib/frozen/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/frozen/__main__.py b/src/StdLib/Lib/test/test_importlib/frozen/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/frozen/__main__.py rename to src/StdLib/Lib/test/test_importlib/frozen/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/frozen/test_finder.py b/src/StdLib/Lib/test/test_importlib/frozen/test_finder.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/frozen/test_finder.py rename to src/StdLib/Lib/test/test_importlib/frozen/test_finder.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/frozen/test_loader.py b/src/StdLib/Lib/test/test_importlib/frozen/test_loader.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/frozen/test_loader.py rename to src/StdLib/Lib/test/test_importlib/frozen/test_loader.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/__init__.py b/src/StdLib/Lib/test/test_importlib/import_/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/__init__.py rename to src/StdLib/Lib/test/test_importlib/import_/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/__main__.py b/src/StdLib/Lib/test/test_importlib/import_/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/__main__.py rename to src/StdLib/Lib/test/test_importlib/import_/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test___loader__.py b/src/StdLib/Lib/test/test_importlib/import_/test___loader__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test___loader__.py rename to src/StdLib/Lib/test/test_importlib/import_/test___loader__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test___package__.py b/src/StdLib/Lib/test/test_importlib/import_/test___package__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test___package__.py rename to src/StdLib/Lib/test/test_importlib/import_/test___package__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_api.py b/src/StdLib/Lib/test/test_importlib/import_/test_api.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_api.py rename to src/StdLib/Lib/test/test_importlib/import_/test_api.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_caching.py b/src/StdLib/Lib/test/test_importlib/import_/test_caching.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_caching.py rename to src/StdLib/Lib/test/test_importlib/import_/test_caching.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_fromlist.py b/src/StdLib/Lib/test/test_importlib/import_/test_fromlist.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_fromlist.py rename to src/StdLib/Lib/test/test_importlib/import_/test_fromlist.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_meta_path.py b/src/StdLib/Lib/test/test_importlib/import_/test_meta_path.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_meta_path.py rename to src/StdLib/Lib/test/test_importlib/import_/test_meta_path.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_packages.py b/src/StdLib/Lib/test/test_importlib/import_/test_packages.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_packages.py rename to src/StdLib/Lib/test/test_importlib/import_/test_packages.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_path.py b/src/StdLib/Lib/test/test_importlib/import_/test_path.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_path.py rename to src/StdLib/Lib/test/test_importlib/import_/test_path.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py b/src/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py rename to src/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/util.py b/src/StdLib/Lib/test/test_importlib/import_/util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/import_/util.py rename to src/StdLib/Lib/test/test_importlib/import_/util.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py b/src/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py rename to src/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py b/src/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py rename to src/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip b/src/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip rename to src/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py b/src/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py rename to src/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty b/src/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty rename to src/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip b/src/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip rename to src/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py b/src/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py rename to src/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py b/src/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py rename to src/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py b/src/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py rename to src/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py b/src/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py rename to src/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py b/src/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py rename to src/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py b/src/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py rename to src/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py b/src/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py rename to src/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip b/src/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip rename to src/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/regrtest.py b/src/StdLib/Lib/test/test_importlib/regrtest.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/regrtest.py rename to src/StdLib/Lib/test/test_importlib/regrtest.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/source/__init__.py b/src/StdLib/Lib/test/test_importlib/source/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/source/__init__.py rename to src/StdLib/Lib/test/test_importlib/source/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/source/__main__.py b/src/StdLib/Lib/test/test_importlib/source/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/source/__main__.py rename to src/StdLib/Lib/test/test_importlib/source/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py b/src/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py rename to src/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/source/test_file_loader.py b/src/StdLib/Lib/test/test_importlib/source/test_file_loader.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/source/test_file_loader.py rename to src/StdLib/Lib/test/test_importlib/source/test_file_loader.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/source/test_finder.py b/src/StdLib/Lib/test/test_importlib/source/test_finder.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/source/test_finder.py rename to src/StdLib/Lib/test/test_importlib/source/test_finder.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/source/test_path_hook.py b/src/StdLib/Lib/test/test_importlib/source/test_path_hook.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/source/test_path_hook.py rename to src/StdLib/Lib/test/test_importlib/source/test_path_hook.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/source/test_source_encoding.py b/src/StdLib/Lib/test/test_importlib/source/test_source_encoding.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/source/test_source_encoding.py rename to src/StdLib/Lib/test/test_importlib/source/test_source_encoding.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/source/util.py b/src/StdLib/Lib/test/test_importlib/source/util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/source/util.py rename to src/StdLib/Lib/test/test_importlib/source/util.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/test_abc.py b/src/StdLib/Lib/test/test_importlib/test_abc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/test_abc.py rename to src/StdLib/Lib/test/test_importlib/test_abc.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/test_api.py b/src/StdLib/Lib/test/test_importlib/test_api.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/test_api.py rename to src/StdLib/Lib/test/test_importlib/test_api.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/test_locks.py b/src/StdLib/Lib/test/test_importlib/test_locks.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/test_locks.py rename to src/StdLib/Lib/test/test_importlib/test_locks.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py b/src/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py rename to src/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/test_spec.py b/src/StdLib/Lib/test/test_importlib/test_spec.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/test_spec.py rename to src/StdLib/Lib/test/test_importlib/test_spec.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/test_util.py b/src/StdLib/Lib/test/test_importlib/test_util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/test_util.py rename to src/StdLib/Lib/test/test_importlib/test_util.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/test_windows.py b/src/StdLib/Lib/test/test_importlib/test_windows.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/test_windows.py rename to src/StdLib/Lib/test/test_importlib/test_windows.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_importlib/util.py b/src/StdLib/Lib/test/test_importlib/util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_importlib/util.py rename to src/StdLib/Lib/test/test_importlib/util.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_index.py b/src/StdLib/Lib/test/test_index.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_index.py rename to src/StdLib/Lib/test/test_index.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_inspect.py b/src/StdLib/Lib/test/test_inspect.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_inspect.py rename to src/StdLib/Lib/test/test_inspect.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_int.py b/src/StdLib/Lib/test/test_int.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_int.py rename to src/StdLib/Lib/test/test_int.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_int_literal.py b/src/StdLib/Lib/test/test_int_literal.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_int_literal.py rename to src/StdLib/Lib/test/test_int_literal.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_io.py b/src/StdLib/Lib/test/test_io.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_io.py rename to src/StdLib/Lib/test/test_io.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_ioctl.py b/src/StdLib/Lib/test/test_ioctl.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_ioctl.py rename to src/StdLib/Lib/test/test_ioctl.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_ipaddress.py b/src/StdLib/Lib/test/test_ipaddress.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_ipaddress.py rename to src/StdLib/Lib/test/test_ipaddress.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_isinstance.py b/src/StdLib/Lib/test/test_isinstance.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_isinstance.py rename to src/StdLib/Lib/test/test_isinstance.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_iter.py b/src/StdLib/Lib/test/test_iter.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_iter.py rename to src/StdLib/Lib/test/test_iter.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_iterlen.py b/src/StdLib/Lib/test/test_iterlen.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_iterlen.py rename to src/StdLib/Lib/test/test_iterlen.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_itertools.py b/src/StdLib/Lib/test/test_itertools.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_itertools.py rename to src/StdLib/Lib/test/test_itertools.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_json/__init__.py b/src/StdLib/Lib/test/test_json/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_json/__init__.py rename to src/StdLib/Lib/test/test_json/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_json/__main__.py b/src/StdLib/Lib/test/test_json/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_json/__main__.py rename to src/StdLib/Lib/test/test_json/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_json/test_decode.py b/src/StdLib/Lib/test/test_json/test_decode.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_json/test_decode.py rename to src/StdLib/Lib/test/test_json/test_decode.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_json/test_default.py b/src/StdLib/Lib/test/test_json/test_default.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_json/test_default.py rename to src/StdLib/Lib/test/test_json/test_default.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_json/test_dump.py b/src/StdLib/Lib/test/test_json/test_dump.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_json/test_dump.py rename to src/StdLib/Lib/test/test_json/test_dump.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py b/src/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py rename to src/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_json/test_enum.py b/src/StdLib/Lib/test/test_json/test_enum.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_json/test_enum.py rename to src/StdLib/Lib/test/test_json/test_enum.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_json/test_fail.py b/src/StdLib/Lib/test/test_json/test_fail.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_json/test_fail.py rename to src/StdLib/Lib/test/test_json/test_fail.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_json/test_float.py b/src/StdLib/Lib/test/test_json/test_float.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_json/test_float.py rename to src/StdLib/Lib/test/test_json/test_float.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_json/test_indent.py b/src/StdLib/Lib/test/test_json/test_indent.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_json/test_indent.py rename to src/StdLib/Lib/test/test_json/test_indent.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_json/test_pass1.py b/src/StdLib/Lib/test/test_json/test_pass1.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_json/test_pass1.py rename to src/StdLib/Lib/test/test_json/test_pass1.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_json/test_pass2.py b/src/StdLib/Lib/test/test_json/test_pass2.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_json/test_pass2.py rename to src/StdLib/Lib/test/test_json/test_pass2.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_json/test_pass3.py b/src/StdLib/Lib/test/test_json/test_pass3.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_json/test_pass3.py rename to src/StdLib/Lib/test/test_json/test_pass3.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_json/test_recursion.py b/src/StdLib/Lib/test/test_json/test_recursion.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_json/test_recursion.py rename to src/StdLib/Lib/test/test_json/test_recursion.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_json/test_scanstring.py b/src/StdLib/Lib/test/test_json/test_scanstring.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_json/test_scanstring.py rename to src/StdLib/Lib/test/test_json/test_scanstring.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_json/test_separators.py b/src/StdLib/Lib/test/test_json/test_separators.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_json/test_separators.py rename to src/StdLib/Lib/test/test_json/test_separators.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_json/test_speedups.py b/src/StdLib/Lib/test/test_json/test_speedups.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_json/test_speedups.py rename to src/StdLib/Lib/test/test_json/test_speedups.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_json/test_tool.py b/src/StdLib/Lib/test/test_json/test_tool.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_json/test_tool.py rename to src/StdLib/Lib/test/test_json/test_tool.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_json/test_unicode.py b/src/StdLib/Lib/test/test_json/test_unicode.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_json/test_unicode.py rename to src/StdLib/Lib/test/test_json/test_unicode.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_keyword.py b/src/StdLib/Lib/test/test_keyword.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_keyword.py rename to src/StdLib/Lib/test/test_keyword.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_keywordonlyarg.py b/src/StdLib/Lib/test/test_keywordonlyarg.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_keywordonlyarg.py rename to src/StdLib/Lib/test/test_keywordonlyarg.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_kqueue.py b/src/StdLib/Lib/test/test_kqueue.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_kqueue.py rename to src/StdLib/Lib/test/test_kqueue.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_largefile.py b/src/StdLib/Lib/test/test_largefile.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_largefile.py rename to src/StdLib/Lib/test/test_largefile.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_lib2to3.py b/src/StdLib/Lib/test/test_lib2to3.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_lib2to3.py rename to src/StdLib/Lib/test/test_lib2to3.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_linecache.py b/src/StdLib/Lib/test/test_linecache.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_linecache.py rename to src/StdLib/Lib/test/test_linecache.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_list.py b/src/StdLib/Lib/test/test_list.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_list.py rename to src/StdLib/Lib/test/test_list.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_listcomps.py b/src/StdLib/Lib/test/test_listcomps.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_listcomps.py rename to src/StdLib/Lib/test/test_listcomps.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_locale.py b/src/StdLib/Lib/test/test_locale.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_locale.py rename to src/StdLib/Lib/test/test_locale.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_logging.py b/src/StdLib/Lib/test/test_logging.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_logging.py rename to src/StdLib/Lib/test/test_logging.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_long.py b/src/StdLib/Lib/test/test_long.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_long.py rename to src/StdLib/Lib/test/test_long.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_longexp.py b/src/StdLib/Lib/test/test_longexp.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_longexp.py rename to src/StdLib/Lib/test/test_longexp.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_lzma.py b/src/StdLib/Lib/test/test_lzma.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_lzma.py rename to src/StdLib/Lib/test/test_lzma.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_macpath.py b/src/StdLib/Lib/test/test_macpath.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_macpath.py rename to src/StdLib/Lib/test/test_macpath.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_macurl2path.py b/src/StdLib/Lib/test/test_macurl2path.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_macurl2path.py rename to src/StdLib/Lib/test/test_macurl2path.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_mailbox.py b/src/StdLib/Lib/test/test_mailbox.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_mailbox.py rename to src/StdLib/Lib/test/test_mailbox.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_mailcap.py b/src/StdLib/Lib/test/test_mailcap.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_mailcap.py rename to src/StdLib/Lib/test/test_mailcap.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_marshal.py b/src/StdLib/Lib/test/test_marshal.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_marshal.py rename to src/StdLib/Lib/test/test_marshal.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_math.py b/src/StdLib/Lib/test/test_math.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_math.py rename to src/StdLib/Lib/test/test_math.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_memoryio.py b/src/StdLib/Lib/test/test_memoryio.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_memoryio.py rename to src/StdLib/Lib/test/test_memoryio.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_memoryview.py b/src/StdLib/Lib/test/test_memoryview.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_memoryview.py rename to src/StdLib/Lib/test/test_memoryview.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_metaclass.py b/src/StdLib/Lib/test/test_metaclass.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_metaclass.py rename to src/StdLib/Lib/test/test_metaclass.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_mimetypes.py b/src/StdLib/Lib/test/test_mimetypes.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_mimetypes.py rename to src/StdLib/Lib/test/test_mimetypes.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_minidom.py b/src/StdLib/Lib/test/test_minidom.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_minidom.py rename to src/StdLib/Lib/test/test_minidom.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_mmap.py b/src/StdLib/Lib/test/test_mmap.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_mmap.py rename to src/StdLib/Lib/test/test_mmap.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_module.py b/src/StdLib/Lib/test/test_module.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_module.py rename to src/StdLib/Lib/test/test_module.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_modulefinder.py b/src/StdLib/Lib/test/test_modulefinder.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_modulefinder.py rename to src/StdLib/Lib/test/test_modulefinder.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_msilib.py b/src/StdLib/Lib/test/test_msilib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_msilib.py rename to src/StdLib/Lib/test/test_msilib.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_multibytecodec.py b/src/StdLib/Lib/test/test_multibytecodec.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_multibytecodec.py rename to src/StdLib/Lib/test/test_multibytecodec.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_multiprocessing_fork.py b/src/StdLib/Lib/test/test_multiprocessing_fork.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_multiprocessing_fork.py rename to src/StdLib/Lib/test/test_multiprocessing_fork.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_multiprocessing_forkserver.py b/src/StdLib/Lib/test/test_multiprocessing_forkserver.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_multiprocessing_forkserver.py rename to src/StdLib/Lib/test/test_multiprocessing_forkserver.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_multiprocessing_main_handling.py b/src/StdLib/Lib/test/test_multiprocessing_main_handling.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_multiprocessing_main_handling.py rename to src/StdLib/Lib/test/test_multiprocessing_main_handling.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_multiprocessing_spawn.py b/src/StdLib/Lib/test/test_multiprocessing_spawn.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_multiprocessing_spawn.py rename to src/StdLib/Lib/test/test_multiprocessing_spawn.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_netrc.py b/src/StdLib/Lib/test/test_netrc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_netrc.py rename to src/StdLib/Lib/test/test_netrc.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_nis.py b/src/StdLib/Lib/test/test_nis.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_nis.py rename to src/StdLib/Lib/test/test_nis.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_nntplib.py b/src/StdLib/Lib/test/test_nntplib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_nntplib.py rename to src/StdLib/Lib/test/test_nntplib.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_normalization.py b/src/StdLib/Lib/test/test_normalization.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_normalization.py rename to src/StdLib/Lib/test/test_normalization.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_ntpath.py b/src/StdLib/Lib/test/test_ntpath.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_ntpath.py rename to src/StdLib/Lib/test/test_ntpath.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_numeric_tower.py b/src/StdLib/Lib/test/test_numeric_tower.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_numeric_tower.py rename to src/StdLib/Lib/test/test_numeric_tower.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_opcodes.py b/src/StdLib/Lib/test/test_opcodes.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_opcodes.py rename to src/StdLib/Lib/test/test_opcodes.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_openpty.py b/src/StdLib/Lib/test/test_openpty.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_openpty.py rename to src/StdLib/Lib/test/test_openpty.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_operator.py b/src/StdLib/Lib/test/test_operator.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_operator.py rename to src/StdLib/Lib/test/test_operator.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_optparse.py b/src/StdLib/Lib/test/test_optparse.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_optparse.py rename to src/StdLib/Lib/test/test_optparse.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_ordered_dict.py b/src/StdLib/Lib/test/test_ordered_dict.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_ordered_dict.py rename to src/StdLib/Lib/test/test_ordered_dict.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_os.py b/src/StdLib/Lib/test/test_os.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_os.py rename to src/StdLib/Lib/test/test_os.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_ossaudiodev.py b/src/StdLib/Lib/test/test_ossaudiodev.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_ossaudiodev.py rename to src/StdLib/Lib/test/test_ossaudiodev.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_osx_env.py b/src/StdLib/Lib/test/test_osx_env.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_osx_env.py rename to src/StdLib/Lib/test/test_osx_env.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_parser.py b/src/StdLib/Lib/test/test_parser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_parser.py rename to src/StdLib/Lib/test/test_parser.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pathlib.py b/src/StdLib/Lib/test/test_pathlib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pathlib.py rename to src/StdLib/Lib/test/test_pathlib.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pdb.py b/src/StdLib/Lib/test/test_pdb.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pdb.py rename to src/StdLib/Lib/test/test_pdb.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_peepholer.py b/src/StdLib/Lib/test/test_peepholer.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_peepholer.py rename to src/StdLib/Lib/test/test_peepholer.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pep247.py b/src/StdLib/Lib/test/test_pep247.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pep247.py rename to src/StdLib/Lib/test/test_pep247.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pep277.py b/src/StdLib/Lib/test/test_pep277.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pep277.py rename to src/StdLib/Lib/test/test_pep277.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pep292.py b/src/StdLib/Lib/test/test_pep292.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pep292.py rename to src/StdLib/Lib/test/test_pep292.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pep3120.py b/src/StdLib/Lib/test/test_pep3120.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pep3120.py rename to src/StdLib/Lib/test/test_pep3120.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pep3131.py b/src/StdLib/Lib/test/test_pep3131.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pep3131.py rename to src/StdLib/Lib/test/test_pep3131.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pep3151.py b/src/StdLib/Lib/test/test_pep3151.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pep3151.py rename to src/StdLib/Lib/test/test_pep3151.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pep352.py b/src/StdLib/Lib/test/test_pep352.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pep352.py rename to src/StdLib/Lib/test/test_pep352.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pep380.py b/src/StdLib/Lib/test/test_pep380.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pep380.py rename to src/StdLib/Lib/test/test_pep380.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pep479.py b/src/StdLib/Lib/test/test_pep479.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pep479.py rename to src/StdLib/Lib/test/test_pep479.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pickle.py b/src/StdLib/Lib/test/test_pickle.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pickle.py rename to src/StdLib/Lib/test/test_pickle.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pickletools.py b/src/StdLib/Lib/test/test_pickletools.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pickletools.py rename to src/StdLib/Lib/test/test_pickletools.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pipes.py b/src/StdLib/Lib/test/test_pipes.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pipes.py rename to src/StdLib/Lib/test/test_pipes.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pkg.py b/src/StdLib/Lib/test/test_pkg.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pkg.py rename to src/StdLib/Lib/test/test_pkg.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pkgimport.py b/src/StdLib/Lib/test/test_pkgimport.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pkgimport.py rename to src/StdLib/Lib/test/test_pkgimport.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pkgutil.py b/src/StdLib/Lib/test/test_pkgutil.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pkgutil.py rename to src/StdLib/Lib/test/test_pkgutil.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_platform.py b/src/StdLib/Lib/test/test_platform.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_platform.py rename to src/StdLib/Lib/test/test_platform.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_plistlib.py b/src/StdLib/Lib/test/test_plistlib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_plistlib.py rename to src/StdLib/Lib/test/test_plistlib.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_poll.py b/src/StdLib/Lib/test/test_poll.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_poll.py rename to src/StdLib/Lib/test/test_poll.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_popen.py b/src/StdLib/Lib/test/test_popen.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_popen.py rename to src/StdLib/Lib/test/test_popen.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_poplib.py b/src/StdLib/Lib/test/test_poplib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_poplib.py rename to src/StdLib/Lib/test/test_poplib.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_posix.py b/src/StdLib/Lib/test/test_posix.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_posix.py rename to src/StdLib/Lib/test/test_posix.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_posixpath.py b/src/StdLib/Lib/test/test_posixpath.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_posixpath.py rename to src/StdLib/Lib/test/test_posixpath.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pow.py b/src/StdLib/Lib/test/test_pow.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pow.py rename to src/StdLib/Lib/test/test_pow.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pprint.py b/src/StdLib/Lib/test/test_pprint.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pprint.py rename to src/StdLib/Lib/test/test_pprint.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_print.py b/src/StdLib/Lib/test/test_print.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_print.py rename to src/StdLib/Lib/test/test_print.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_profile.py b/src/StdLib/Lib/test/test_profile.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_profile.py rename to src/StdLib/Lib/test/test_profile.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_property.py b/src/StdLib/Lib/test/test_property.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_property.py rename to src/StdLib/Lib/test/test_property.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pstats.py b/src/StdLib/Lib/test/test_pstats.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pstats.py rename to src/StdLib/Lib/test/test_pstats.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pty.py b/src/StdLib/Lib/test/test_pty.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pty.py rename to src/StdLib/Lib/test/test_pty.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pulldom.py b/src/StdLib/Lib/test/test_pulldom.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pulldom.py rename to src/StdLib/Lib/test/test_pulldom.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pwd.py b/src/StdLib/Lib/test/test_pwd.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pwd.py rename to src/StdLib/Lib/test/test_pwd.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_py_compile.py b/src/StdLib/Lib/test/test_py_compile.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_py_compile.py rename to src/StdLib/Lib/test/test_py_compile.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pyclbr.py b/src/StdLib/Lib/test/test_pyclbr.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pyclbr.py rename to src/StdLib/Lib/test/test_pyclbr.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pydoc.py b/src/StdLib/Lib/test/test_pydoc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pydoc.py rename to src/StdLib/Lib/test/test_pydoc.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_pyexpat.py b/src/StdLib/Lib/test/test_pyexpat.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_pyexpat.py rename to src/StdLib/Lib/test/test_pyexpat.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_queue.py b/src/StdLib/Lib/test/test_queue.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_queue.py rename to src/StdLib/Lib/test/test_queue.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_quopri.py b/src/StdLib/Lib/test/test_quopri.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_quopri.py rename to src/StdLib/Lib/test/test_quopri.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_raise.py b/src/StdLib/Lib/test/test_raise.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_raise.py rename to src/StdLib/Lib/test/test_raise.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_random.py b/src/StdLib/Lib/test/test_random.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_random.py rename to src/StdLib/Lib/test/test_random.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_range.py b/src/StdLib/Lib/test/test_range.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_range.py rename to src/StdLib/Lib/test/test_range.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_re.py b/src/StdLib/Lib/test/test_re.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_re.py rename to src/StdLib/Lib/test/test_re.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_readline.py b/src/StdLib/Lib/test/test_readline.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_readline.py rename to src/StdLib/Lib/test/test_readline.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_regrtest.py b/src/StdLib/Lib/test/test_regrtest.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_regrtest.py rename to src/StdLib/Lib/test/test_regrtest.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_reprlib.py b/src/StdLib/Lib/test/test_reprlib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_reprlib.py rename to src/StdLib/Lib/test/test_reprlib.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_resource.py b/src/StdLib/Lib/test/test_resource.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_resource.py rename to src/StdLib/Lib/test/test_resource.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_richcmp.py b/src/StdLib/Lib/test/test_richcmp.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_richcmp.py rename to src/StdLib/Lib/test/test_richcmp.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_rlcompleter.py b/src/StdLib/Lib/test/test_rlcompleter.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_rlcompleter.py rename to src/StdLib/Lib/test/test_rlcompleter.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_robotparser.py b/src/StdLib/Lib/test/test_robotparser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_robotparser.py rename to src/StdLib/Lib/test/test_robotparser.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_runpy.py b/src/StdLib/Lib/test/test_runpy.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_runpy.py rename to src/StdLib/Lib/test/test_runpy.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_sax.py b/src/StdLib/Lib/test/test_sax.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_sax.py rename to src/StdLib/Lib/test/test_sax.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_sched.py b/src/StdLib/Lib/test/test_sched.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_sched.py rename to src/StdLib/Lib/test/test_sched.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_scope.py b/src/StdLib/Lib/test/test_scope.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_scope.py rename to src/StdLib/Lib/test/test_scope.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_script_helper.py b/src/StdLib/Lib/test/test_script_helper.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_script_helper.py rename to src/StdLib/Lib/test/test_script_helper.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_select.py b/src/StdLib/Lib/test/test_select.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_select.py rename to src/StdLib/Lib/test/test_select.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_selectors.py b/src/StdLib/Lib/test/test_selectors.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_selectors.py rename to src/StdLib/Lib/test/test_selectors.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_set.py b/src/StdLib/Lib/test/test_set.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_set.py rename to src/StdLib/Lib/test/test_set.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_setcomps.py b/src/StdLib/Lib/test/test_setcomps.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_setcomps.py rename to src/StdLib/Lib/test/test_setcomps.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_shelve.py b/src/StdLib/Lib/test/test_shelve.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_shelve.py rename to src/StdLib/Lib/test/test_shelve.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_shlex.py b/src/StdLib/Lib/test/test_shlex.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_shlex.py rename to src/StdLib/Lib/test/test_shlex.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_shutil.py b/src/StdLib/Lib/test/test_shutil.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_shutil.py rename to src/StdLib/Lib/test/test_shutil.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_signal.py b/src/StdLib/Lib/test/test_signal.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_signal.py rename to src/StdLib/Lib/test/test_signal.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_site.py b/src/StdLib/Lib/test/test_site.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_site.py rename to src/StdLib/Lib/test/test_site.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_slice.py b/src/StdLib/Lib/test/test_slice.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_slice.py rename to src/StdLib/Lib/test/test_slice.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_smtpd.py b/src/StdLib/Lib/test/test_smtpd.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_smtpd.py rename to src/StdLib/Lib/test/test_smtpd.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_smtplib.py b/src/StdLib/Lib/test/test_smtplib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_smtplib.py rename to src/StdLib/Lib/test/test_smtplib.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_smtpnet.py b/src/StdLib/Lib/test/test_smtpnet.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_smtpnet.py rename to src/StdLib/Lib/test/test_smtpnet.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_sndhdr.py b/src/StdLib/Lib/test/test_sndhdr.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_sndhdr.py rename to src/StdLib/Lib/test/test_sndhdr.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_socket.py b/src/StdLib/Lib/test/test_socket.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_socket.py rename to src/StdLib/Lib/test/test_socket.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_socketserver.py b/src/StdLib/Lib/test/test_socketserver.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_socketserver.py rename to src/StdLib/Lib/test/test_socketserver.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_sort.py b/src/StdLib/Lib/test/test_sort.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_sort.py rename to src/StdLib/Lib/test/test_sort.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_source_encoding.py b/src/StdLib/Lib/test/test_source_encoding.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_source_encoding.py rename to src/StdLib/Lib/test/test_source_encoding.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_spwd.py b/src/StdLib/Lib/test/test_spwd.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_spwd.py rename to src/StdLib/Lib/test/test_spwd.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_sqlite.py b/src/StdLib/Lib/test/test_sqlite.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_sqlite.py rename to src/StdLib/Lib/test/test_sqlite.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_ssl.py b/src/StdLib/Lib/test/test_ssl.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_ssl.py rename to src/StdLib/Lib/test/test_ssl.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_startfile.py b/src/StdLib/Lib/test/test_startfile.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_startfile.py rename to src/StdLib/Lib/test/test_startfile.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_stat.py b/src/StdLib/Lib/test/test_stat.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_stat.py rename to src/StdLib/Lib/test/test_stat.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_statistics.py b/src/StdLib/Lib/test/test_statistics.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_statistics.py rename to src/StdLib/Lib/test/test_statistics.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_strftime.py b/src/StdLib/Lib/test/test_strftime.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_strftime.py rename to src/StdLib/Lib/test/test_strftime.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_string.py b/src/StdLib/Lib/test/test_string.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_string.py rename to src/StdLib/Lib/test/test_string.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_stringprep.py b/src/StdLib/Lib/test/test_stringprep.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_stringprep.py rename to src/StdLib/Lib/test/test_stringprep.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_strlit.py b/src/StdLib/Lib/test/test_strlit.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_strlit.py rename to src/StdLib/Lib/test/test_strlit.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_strptime.py b/src/StdLib/Lib/test/test_strptime.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_strptime.py rename to src/StdLib/Lib/test/test_strptime.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_strtod.py b/src/StdLib/Lib/test/test_strtod.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_strtod.py rename to src/StdLib/Lib/test/test_strtod.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_struct.py b/src/StdLib/Lib/test/test_struct.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_struct.py rename to src/StdLib/Lib/test/test_struct.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_structmembers.py b/src/StdLib/Lib/test/test_structmembers.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_structmembers.py rename to src/StdLib/Lib/test/test_structmembers.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_structseq.py b/src/StdLib/Lib/test/test_structseq.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_structseq.py rename to src/StdLib/Lib/test/test_structseq.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_subprocess.py b/src/StdLib/Lib/test/test_subprocess.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_subprocess.py rename to src/StdLib/Lib/test/test_subprocess.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_sunau.py b/src/StdLib/Lib/test/test_sunau.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_sunau.py rename to src/StdLib/Lib/test/test_sunau.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_sundry.py b/src/StdLib/Lib/test/test_sundry.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_sundry.py rename to src/StdLib/Lib/test/test_sundry.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_super.py b/src/StdLib/Lib/test/test_super.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_super.py rename to src/StdLib/Lib/test/test_super.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_support.py b/src/StdLib/Lib/test/test_support.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_support.py rename to src/StdLib/Lib/test/test_support.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_symtable.py b/src/StdLib/Lib/test/test_symtable.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_symtable.py rename to src/StdLib/Lib/test/test_symtable.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_syntax.py b/src/StdLib/Lib/test/test_syntax.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_syntax.py rename to src/StdLib/Lib/test/test_syntax.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_sys.py b/src/StdLib/Lib/test/test_sys.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_sys.py rename to src/StdLib/Lib/test/test_sys.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_sys_setprofile.py b/src/StdLib/Lib/test/test_sys_setprofile.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_sys_setprofile.py rename to src/StdLib/Lib/test/test_sys_setprofile.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_sys_settrace.py b/src/StdLib/Lib/test/test_sys_settrace.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_sys_settrace.py rename to src/StdLib/Lib/test/test_sys_settrace.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_sysconfig.py b/src/StdLib/Lib/test/test_sysconfig.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_sysconfig.py rename to src/StdLib/Lib/test/test_sysconfig.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_syslog.py b/src/StdLib/Lib/test/test_syslog.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_syslog.py rename to src/StdLib/Lib/test/test_syslog.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_tarfile.py b/src/StdLib/Lib/test/test_tarfile.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_tarfile.py rename to src/StdLib/Lib/test/test_tarfile.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_tcl.py b/src/StdLib/Lib/test/test_tcl.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_tcl.py rename to src/StdLib/Lib/test/test_tcl.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_telnetlib.py b/src/StdLib/Lib/test/test_telnetlib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_telnetlib.py rename to src/StdLib/Lib/test/test_telnetlib.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_tempfile.py b/src/StdLib/Lib/test/test_tempfile.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_tempfile.py rename to src/StdLib/Lib/test/test_tempfile.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_textwrap.py b/src/StdLib/Lib/test/test_textwrap.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_textwrap.py rename to src/StdLib/Lib/test/test_textwrap.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_thread.py b/src/StdLib/Lib/test/test_thread.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_thread.py rename to src/StdLib/Lib/test/test_thread.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_threaded_import.py b/src/StdLib/Lib/test/test_threaded_import.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_threaded_import.py rename to src/StdLib/Lib/test/test_threaded_import.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_threadedtempfile.py b/src/StdLib/Lib/test/test_threadedtempfile.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_threadedtempfile.py rename to src/StdLib/Lib/test/test_threadedtempfile.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_threading.py b/src/StdLib/Lib/test/test_threading.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_threading.py rename to src/StdLib/Lib/test/test_threading.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_threading_local.py b/src/StdLib/Lib/test/test_threading_local.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_threading_local.py rename to src/StdLib/Lib/test/test_threading_local.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_threadsignals.py b/src/StdLib/Lib/test/test_threadsignals.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_threadsignals.py rename to src/StdLib/Lib/test/test_threadsignals.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_time.py b/src/StdLib/Lib/test/test_time.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_time.py rename to src/StdLib/Lib/test/test_time.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_timeit.py b/src/StdLib/Lib/test/test_timeit.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_timeit.py rename to src/StdLib/Lib/test/test_timeit.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_timeout.py b/src/StdLib/Lib/test/test_timeout.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_timeout.py rename to src/StdLib/Lib/test/test_timeout.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_tk.py b/src/StdLib/Lib/test/test_tk.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_tk.py rename to src/StdLib/Lib/test/test_tk.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_tokenize.py b/src/StdLib/Lib/test/test_tokenize.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_tokenize.py rename to src/StdLib/Lib/test/test_tokenize.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_tools/__init__.py b/src/StdLib/Lib/test/test_tools/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_tools/__init__.py rename to src/StdLib/Lib/test/test_tools/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_tools/__main__.py b/src/StdLib/Lib/test/test_tools/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_tools/__main__.py rename to src/StdLib/Lib/test/test_tools/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_tools/test_gprof2html.py b/src/StdLib/Lib/test/test_tools/test_gprof2html.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_tools/test_gprof2html.py rename to src/StdLib/Lib/test/test_tools/test_gprof2html.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_tools/test_md5sum.py b/src/StdLib/Lib/test/test_tools/test_md5sum.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_tools/test_md5sum.py rename to src/StdLib/Lib/test/test_tools/test_md5sum.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_tools/test_pdeps.py b/src/StdLib/Lib/test/test_tools/test_pdeps.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_tools/test_pdeps.py rename to src/StdLib/Lib/test/test_tools/test_pdeps.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_tools/test_pindent.py b/src/StdLib/Lib/test/test_tools/test_pindent.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_tools/test_pindent.py rename to src/StdLib/Lib/test/test_tools/test_pindent.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_tools/test_reindent.py b/src/StdLib/Lib/test/test_tools/test_reindent.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_tools/test_reindent.py rename to src/StdLib/Lib/test/test_tools/test_reindent.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_tools/test_sundry.py b/src/StdLib/Lib/test/test_tools/test_sundry.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_tools/test_sundry.py rename to src/StdLib/Lib/test/test_tools/test_sundry.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_tools/test_unparse.py b/src/StdLib/Lib/test/test_tools/test_unparse.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_tools/test_unparse.py rename to src/StdLib/Lib/test/test_tools/test_unparse.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_trace.py b/src/StdLib/Lib/test/test_trace.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_trace.py rename to src/StdLib/Lib/test/test_trace.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_traceback.py b/src/StdLib/Lib/test/test_traceback.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_traceback.py rename to src/StdLib/Lib/test/test_traceback.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_tracemalloc.py b/src/StdLib/Lib/test/test_tracemalloc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_tracemalloc.py rename to src/StdLib/Lib/test/test_tracemalloc.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_ttk_guionly.py b/src/StdLib/Lib/test/test_ttk_guionly.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_ttk_guionly.py rename to src/StdLib/Lib/test/test_ttk_guionly.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_ttk_textonly.py b/src/StdLib/Lib/test/test_ttk_textonly.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_ttk_textonly.py rename to src/StdLib/Lib/test/test_ttk_textonly.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_tuple.py b/src/StdLib/Lib/test/test_tuple.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_tuple.py rename to src/StdLib/Lib/test/test_tuple.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_typechecks.py b/src/StdLib/Lib/test/test_typechecks.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_typechecks.py rename to src/StdLib/Lib/test/test_typechecks.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_types.py b/src/StdLib/Lib/test/test_types.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_types.py rename to src/StdLib/Lib/test/test_types.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_typing.py b/src/StdLib/Lib/test/test_typing.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_typing.py rename to src/StdLib/Lib/test/test_typing.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_ucn.py b/src/StdLib/Lib/test/test_ucn.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_ucn.py rename to src/StdLib/Lib/test/test_ucn.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_unary.py b/src/StdLib/Lib/test/test_unary.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_unary.py rename to src/StdLib/Lib/test/test_unary.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_unicode.py b/src/StdLib/Lib/test/test_unicode.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_unicode.py rename to src/StdLib/Lib/test/test_unicode.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_unicode_file.py b/src/StdLib/Lib/test/test_unicode_file.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_unicode_file.py rename to src/StdLib/Lib/test/test_unicode_file.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_unicodedata.py b/src/StdLib/Lib/test/test_unicodedata.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_unicodedata.py rename to src/StdLib/Lib/test/test_unicodedata.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_unittest.py b/src/StdLib/Lib/test/test_unittest.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_unittest.py rename to src/StdLib/Lib/test/test_unittest.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_univnewlines.py b/src/StdLib/Lib/test/test_univnewlines.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_univnewlines.py rename to src/StdLib/Lib/test/test_univnewlines.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_unpack.py b/src/StdLib/Lib/test/test_unpack.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_unpack.py rename to src/StdLib/Lib/test/test_unpack.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_unpack_ex.py b/src/StdLib/Lib/test/test_unpack_ex.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_unpack_ex.py rename to src/StdLib/Lib/test/test_unpack_ex.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_urllib.py b/src/StdLib/Lib/test/test_urllib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_urllib.py rename to src/StdLib/Lib/test/test_urllib.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_urllib2.py b/src/StdLib/Lib/test/test_urllib2.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_urllib2.py rename to src/StdLib/Lib/test/test_urllib2.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_urllib2_localnet.py b/src/StdLib/Lib/test/test_urllib2_localnet.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_urllib2_localnet.py rename to src/StdLib/Lib/test/test_urllib2_localnet.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_urllib2net.py b/src/StdLib/Lib/test/test_urllib2net.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_urllib2net.py rename to src/StdLib/Lib/test/test_urllib2net.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_urllib_response.py b/src/StdLib/Lib/test/test_urllib_response.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_urllib_response.py rename to src/StdLib/Lib/test/test_urllib_response.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_urllibnet.py b/src/StdLib/Lib/test/test_urllibnet.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_urllibnet.py rename to src/StdLib/Lib/test/test_urllibnet.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_urlparse.py b/src/StdLib/Lib/test/test_urlparse.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_urlparse.py rename to src/StdLib/Lib/test/test_urlparse.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_userdict.py b/src/StdLib/Lib/test/test_userdict.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_userdict.py rename to src/StdLib/Lib/test/test_userdict.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_userlist.py b/src/StdLib/Lib/test/test_userlist.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_userlist.py rename to src/StdLib/Lib/test/test_userlist.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_userstring.py b/src/StdLib/Lib/test/test_userstring.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_userstring.py rename to src/StdLib/Lib/test/test_userstring.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_utf8_mode.py b/src/StdLib/Lib/test/test_utf8_mode.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_utf8_mode.py rename to src/StdLib/Lib/test/test_utf8_mode.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_uu.py b/src/StdLib/Lib/test/test_uu.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_uu.py rename to src/StdLib/Lib/test/test_uu.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_uuid.py b/src/StdLib/Lib/test/test_uuid.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_uuid.py rename to src/StdLib/Lib/test/test_uuid.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_venv.py b/src/StdLib/Lib/test/test_venv.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_venv.py rename to src/StdLib/Lib/test/test_venv.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_wait3.py b/src/StdLib/Lib/test/test_wait3.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_wait3.py rename to src/StdLib/Lib/test/test_wait3.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_wait4.py b/src/StdLib/Lib/test/test_wait4.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_wait4.py rename to src/StdLib/Lib/test/test_wait4.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_warnings.py b/src/StdLib/Lib/test/test_warnings.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_warnings.py rename to src/StdLib/Lib/test/test_warnings.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_wave.py b/src/StdLib/Lib/test/test_wave.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_wave.py rename to src/StdLib/Lib/test/test_wave.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_weakref.py b/src/StdLib/Lib/test/test_weakref.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_weakref.py rename to src/StdLib/Lib/test/test_weakref.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_weakset.py b/src/StdLib/Lib/test/test_weakset.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_weakset.py rename to src/StdLib/Lib/test/test_weakset.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_webbrowser.py b/src/StdLib/Lib/test/test_webbrowser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_webbrowser.py rename to src/StdLib/Lib/test/test_webbrowser.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_winreg.py b/src/StdLib/Lib/test/test_winreg.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_winreg.py rename to src/StdLib/Lib/test/test_winreg.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_winsound.py b/src/StdLib/Lib/test/test_winsound.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_winsound.py rename to src/StdLib/Lib/test/test_winsound.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_with.py b/src/StdLib/Lib/test/test_with.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_with.py rename to src/StdLib/Lib/test/test_with.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_wsgiref.py b/src/StdLib/Lib/test/test_wsgiref.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_wsgiref.py rename to src/StdLib/Lib/test/test_wsgiref.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_xdrlib.py b/src/StdLib/Lib/test/test_xdrlib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_xdrlib.py rename to src/StdLib/Lib/test/test_xdrlib.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_xml_dom_minicompat.py b/src/StdLib/Lib/test/test_xml_dom_minicompat.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_xml_dom_minicompat.py rename to src/StdLib/Lib/test/test_xml_dom_minicompat.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_xml_etree.py b/src/StdLib/Lib/test/test_xml_etree.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_xml_etree.py rename to src/StdLib/Lib/test/test_xml_etree.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_xml_etree_c.py b/src/StdLib/Lib/test/test_xml_etree_c.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_xml_etree_c.py rename to src/StdLib/Lib/test/test_xml_etree_c.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_xmlrpc.py b/src/StdLib/Lib/test/test_xmlrpc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_xmlrpc.py rename to src/StdLib/Lib/test/test_xmlrpc.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_xmlrpc_net.py b/src/StdLib/Lib/test/test_xmlrpc_net.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_xmlrpc_net.py rename to src/StdLib/Lib/test/test_xmlrpc_net.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_zipfile.py b/src/StdLib/Lib/test/test_zipfile.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_zipfile.py rename to src/StdLib/Lib/test/test_zipfile.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_zipfile64.py b/src/StdLib/Lib/test/test_zipfile64.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_zipfile64.py rename to src/StdLib/Lib/test/test_zipfile64.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_zipimport.py b/src/StdLib/Lib/test/test_zipimport.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_zipimport.py rename to src/StdLib/Lib/test/test_zipimport.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_zipimport_support.py b/src/StdLib/Lib/test/test_zipimport_support.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_zipimport_support.py rename to src/StdLib/Lib/test/test_zipimport_support.py diff --git a/Src.GetRenamed/StdLib/Lib/test/test_zlib.py b/src/StdLib/Lib/test/test_zlib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/test_zlib.py rename to src/StdLib/Lib/test/test_zlib.py diff --git a/Src.GetRenamed/StdLib/Lib/test/testcodec.py b/src/StdLib/Lib/test/testcodec.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/testcodec.py rename to src/StdLib/Lib/test/testcodec.py diff --git a/Src.GetRenamed/StdLib/Lib/test/testtar.tar b/src/StdLib/Lib/test/testtar.tar similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/testtar.tar rename to src/StdLib/Lib/test/testtar.tar diff --git a/Src.GetRenamed/StdLib/Lib/test/tf_inherit_check.py b/src/StdLib/Lib/test/tf_inherit_check.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/tf_inherit_check.py rename to src/StdLib/Lib/test/tf_inherit_check.py diff --git a/Src.GetRenamed/StdLib/Lib/test/threaded_import_hangers.py b/src/StdLib/Lib/test/threaded_import_hangers.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/threaded_import_hangers.py rename to src/StdLib/Lib/test/threaded_import_hangers.py diff --git a/Src.GetRenamed/StdLib/Lib/test/time_hashlib.py b/src/StdLib/Lib/test/time_hashlib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/time_hashlib.py rename to src/StdLib/Lib/test/time_hashlib.py diff --git a/Src.GetRenamed/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt b/src/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt rename to src/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt b/src/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt rename to src/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt b/src/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt rename to src/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt b/src/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt rename to src/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/tokenize_tests.txt b/src/StdLib/Lib/test/tokenize_tests.txt similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/tokenize_tests.txt rename to src/StdLib/Lib/test/tokenize_tests.txt diff --git a/Src.GetRenamed/StdLib/Lib/test/tracedmodules/__init__.py b/src/StdLib/Lib/test/tracedmodules/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/tracedmodules/__init__.py rename to src/StdLib/Lib/test/tracedmodules/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/test/tracedmodules/testmod.py b/src/StdLib/Lib/test/tracedmodules/testmod.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/tracedmodules/testmod.py rename to src/StdLib/Lib/test/tracedmodules/testmod.py diff --git a/Src.GetRenamed/StdLib/Lib/test/warning_tests.py b/src/StdLib/Lib/test/warning_tests.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/warning_tests.py rename to src/StdLib/Lib/test/warning_tests.py diff --git a/Src.GetRenamed/StdLib/Lib/test/win_console_handler.py b/src/StdLib/Lib/test/win_console_handler.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/win_console_handler.py rename to src/StdLib/Lib/test/win_console_handler.py diff --git a/Src.GetRenamed/StdLib/Lib/test/xmltestdata/simple-ns.xml b/src/StdLib/Lib/test/xmltestdata/simple-ns.xml similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/xmltestdata/simple-ns.xml rename to src/StdLib/Lib/test/xmltestdata/simple-ns.xml diff --git a/Src.GetRenamed/StdLib/Lib/test/xmltestdata/simple.xml b/src/StdLib/Lib/test/xmltestdata/simple.xml similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/xmltestdata/simple.xml rename to src/StdLib/Lib/test/xmltestdata/simple.xml diff --git a/Src.GetRenamed/StdLib/Lib/test/xmltestdata/test.xml b/src/StdLib/Lib/test/xmltestdata/test.xml similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/xmltestdata/test.xml rename to src/StdLib/Lib/test/xmltestdata/test.xml diff --git a/Src.GetRenamed/StdLib/Lib/test/xmltestdata/test.xml.out b/src/StdLib/Lib/test/xmltestdata/test.xml.out similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/xmltestdata/test.xml.out rename to src/StdLib/Lib/test/xmltestdata/test.xml.out diff --git a/Src.GetRenamed/StdLib/Lib/test/xmltests.py b/src/StdLib/Lib/test/xmltests.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/xmltests.py rename to src/StdLib/Lib/test/xmltests.py diff --git a/Src.GetRenamed/StdLib/Lib/test/zip_cp437_header.zip b/src/StdLib/Lib/test/zip_cp437_header.zip similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/zip_cp437_header.zip rename to src/StdLib/Lib/test/zip_cp437_header.zip diff --git a/Src.GetRenamed/StdLib/Lib/test/zipdir.zip b/src/StdLib/Lib/test/zipdir.zip similarity index 100% rename from Src.GetRenamed/StdLib/Lib/test/zipdir.zip rename to src/StdLib/Lib/test/zipdir.zip diff --git a/Src.GetRenamed/StdLib/Lib/textwrap.py b/src/StdLib/Lib/textwrap.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/textwrap.py rename to src/StdLib/Lib/textwrap.py diff --git a/Src.GetRenamed/StdLib/Lib/this.py b/src/StdLib/Lib/this.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/this.py rename to src/StdLib/Lib/this.py diff --git a/Src.GetRenamed/StdLib/Lib/threading.py b/src/StdLib/Lib/threading.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/threading.py rename to src/StdLib/Lib/threading.py diff --git a/Src.GetRenamed/StdLib/Lib/timeit.py b/src/StdLib/Lib/timeit.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/timeit.py rename to src/StdLib/Lib/timeit.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/__init__.py b/src/StdLib/Lib/tkinter/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/__init__.py rename to src/StdLib/Lib/tkinter/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/__main__.py b/src/StdLib/Lib/tkinter/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/__main__.py rename to src/StdLib/Lib/tkinter/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/_fix.py b/src/StdLib/Lib/tkinter/_fix.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/_fix.py rename to src/StdLib/Lib/tkinter/_fix.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/colorchooser.py b/src/StdLib/Lib/tkinter/colorchooser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/colorchooser.py rename to src/StdLib/Lib/tkinter/colorchooser.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/commondialog.py b/src/StdLib/Lib/tkinter/commondialog.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/commondialog.py rename to src/StdLib/Lib/tkinter/commondialog.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/constants.py b/src/StdLib/Lib/tkinter/constants.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/constants.py rename to src/StdLib/Lib/tkinter/constants.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/dialog.py b/src/StdLib/Lib/tkinter/dialog.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/dialog.py rename to src/StdLib/Lib/tkinter/dialog.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/dnd.py b/src/StdLib/Lib/tkinter/dnd.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/dnd.py rename to src/StdLib/Lib/tkinter/dnd.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/filedialog.py b/src/StdLib/Lib/tkinter/filedialog.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/filedialog.py rename to src/StdLib/Lib/tkinter/filedialog.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/font.py b/src/StdLib/Lib/tkinter/font.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/font.py rename to src/StdLib/Lib/tkinter/font.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/messagebox.py b/src/StdLib/Lib/tkinter/messagebox.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/messagebox.py rename to src/StdLib/Lib/tkinter/messagebox.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/scrolledtext.py b/src/StdLib/Lib/tkinter/scrolledtext.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/scrolledtext.py rename to src/StdLib/Lib/tkinter/scrolledtext.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/simpledialog.py b/src/StdLib/Lib/tkinter/simpledialog.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/simpledialog.py rename to src/StdLib/Lib/tkinter/simpledialog.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/test/README b/src/StdLib/Lib/tkinter/test/README similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/test/README rename to src/StdLib/Lib/tkinter/test/README diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/test/__init__.py b/src/StdLib/Lib/tkinter/test/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/test/__init__.py rename to src/StdLib/Lib/tkinter/test/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/test/runtktests.py b/src/StdLib/Lib/tkinter/test/runtktests.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/test/runtktests.py rename to src/StdLib/Lib/tkinter/test/runtktests.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/test/support.py b/src/StdLib/Lib/tkinter/test/support.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/test/support.py rename to src/StdLib/Lib/tkinter/test/support.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/__init__.py b/src/StdLib/Lib/tkinter/test/test_tkinter/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/__init__.py rename to src/StdLib/Lib/tkinter/test/test_tkinter/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_font.py b/src/StdLib/Lib/tkinter/test/test_tkinter/test_font.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_font.py rename to src/StdLib/Lib/tkinter/test/test_tkinter/test_font.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py b/src/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py rename to src/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_images.py b/src/StdLib/Lib/tkinter/test/test_tkinter/test_images.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_images.py rename to src/StdLib/Lib/tkinter/test/test_tkinter/test_images.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py b/src/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py rename to src/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py b/src/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py rename to src/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_text.py b/src/StdLib/Lib/tkinter/test/test_tkinter/test_text.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_text.py rename to src/StdLib/Lib/tkinter/test/test_tkinter/test_text.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py b/src/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py rename to src/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py b/src/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py rename to src/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/test/test_ttk/__init__.py b/src/StdLib/Lib/tkinter/test/test_ttk/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/test/test_ttk/__init__.py rename to src/StdLib/Lib/tkinter/test/test_ttk/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py b/src/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py rename to src/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/test/test_ttk/test_functions.py b/src/StdLib/Lib/tkinter/test/test_ttk/test_functions.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/test/test_ttk/test_functions.py rename to src/StdLib/Lib/tkinter/test/test_ttk/test_functions.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/test/test_ttk/test_style.py b/src/StdLib/Lib/tkinter/test/test_ttk/test_style.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/test/test_ttk/test_style.py rename to src/StdLib/Lib/tkinter/test/test_ttk/test_style.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py b/src/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py rename to src/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/test/widget_tests.py b/src/StdLib/Lib/tkinter/test/widget_tests.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/test/widget_tests.py rename to src/StdLib/Lib/tkinter/test/widget_tests.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/tix.py b/src/StdLib/Lib/tkinter/tix.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/tix.py rename to src/StdLib/Lib/tkinter/tix.py diff --git a/Src.GetRenamed/StdLib/Lib/tkinter/ttk.py b/src/StdLib/Lib/tkinter/ttk.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tkinter/ttk.py rename to src/StdLib/Lib/tkinter/ttk.py diff --git a/Src.GetRenamed/StdLib/Lib/token.py b/src/StdLib/Lib/token.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/token.py rename to src/StdLib/Lib/token.py diff --git a/Src.GetRenamed/StdLib/Lib/tokenize.py b/src/StdLib/Lib/tokenize.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tokenize.py rename to src/StdLib/Lib/tokenize.py diff --git a/Src.GetRenamed/StdLib/Lib/trace.py b/src/StdLib/Lib/trace.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/trace.py rename to src/StdLib/Lib/trace.py diff --git a/Src.GetRenamed/StdLib/Lib/traceback.py b/src/StdLib/Lib/traceback.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/traceback.py rename to src/StdLib/Lib/traceback.py diff --git a/Src.GetRenamed/StdLib/Lib/tracemalloc.py b/src/StdLib/Lib/tracemalloc.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tracemalloc.py rename to src/StdLib/Lib/tracemalloc.py diff --git a/Src.GetRenamed/StdLib/Lib/tty.py b/src/StdLib/Lib/tty.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/tty.py rename to src/StdLib/Lib/tty.py diff --git a/Src.GetRenamed/StdLib/Lib/turtle.py b/src/StdLib/Lib/turtle.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtle.py rename to src/StdLib/Lib/turtle.py diff --git a/Src.GetRenamed/StdLib/Lib/turtledemo/__init__.py b/src/StdLib/Lib/turtledemo/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtledemo/__init__.py rename to src/StdLib/Lib/turtledemo/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/turtledemo/__main__.py b/src/StdLib/Lib/turtledemo/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtledemo/__main__.py rename to src/StdLib/Lib/turtledemo/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/turtledemo/bytedesign.py b/src/StdLib/Lib/turtledemo/bytedesign.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtledemo/bytedesign.py rename to src/StdLib/Lib/turtledemo/bytedesign.py diff --git a/Src.GetRenamed/StdLib/Lib/turtledemo/chaos.py b/src/StdLib/Lib/turtledemo/chaos.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtledemo/chaos.py rename to src/StdLib/Lib/turtledemo/chaos.py diff --git a/Src.GetRenamed/StdLib/Lib/turtledemo/clock.py b/src/StdLib/Lib/turtledemo/clock.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtledemo/clock.py rename to src/StdLib/Lib/turtledemo/clock.py diff --git a/Src.GetRenamed/StdLib/Lib/turtledemo/colormixer.py b/src/StdLib/Lib/turtledemo/colormixer.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtledemo/colormixer.py rename to src/StdLib/Lib/turtledemo/colormixer.py diff --git a/Src.GetRenamed/StdLib/Lib/turtledemo/forest.py b/src/StdLib/Lib/turtledemo/forest.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtledemo/forest.py rename to src/StdLib/Lib/turtledemo/forest.py diff --git a/Src.GetRenamed/StdLib/Lib/turtledemo/fractalcurves.py b/src/StdLib/Lib/turtledemo/fractalcurves.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtledemo/fractalcurves.py rename to src/StdLib/Lib/turtledemo/fractalcurves.py diff --git a/Src.GetRenamed/StdLib/Lib/turtledemo/lindenmayer.py b/src/StdLib/Lib/turtledemo/lindenmayer.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtledemo/lindenmayer.py rename to src/StdLib/Lib/turtledemo/lindenmayer.py diff --git a/Src.GetRenamed/StdLib/Lib/turtledemo/minimal_hanoi.py b/src/StdLib/Lib/turtledemo/minimal_hanoi.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtledemo/minimal_hanoi.py rename to src/StdLib/Lib/turtledemo/minimal_hanoi.py diff --git a/Src.GetRenamed/StdLib/Lib/turtledemo/nim.py b/src/StdLib/Lib/turtledemo/nim.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtledemo/nim.py rename to src/StdLib/Lib/turtledemo/nim.py diff --git a/Src.GetRenamed/StdLib/Lib/turtledemo/paint.py b/src/StdLib/Lib/turtledemo/paint.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtledemo/paint.py rename to src/StdLib/Lib/turtledemo/paint.py diff --git a/Src.GetRenamed/StdLib/Lib/turtledemo/peace.py b/src/StdLib/Lib/turtledemo/peace.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtledemo/peace.py rename to src/StdLib/Lib/turtledemo/peace.py diff --git a/Src.GetRenamed/StdLib/Lib/turtledemo/penrose.py b/src/StdLib/Lib/turtledemo/penrose.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtledemo/penrose.py rename to src/StdLib/Lib/turtledemo/penrose.py diff --git a/Src.GetRenamed/StdLib/Lib/turtledemo/planet_and_moon.py b/src/StdLib/Lib/turtledemo/planet_and_moon.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtledemo/planet_and_moon.py rename to src/StdLib/Lib/turtledemo/planet_and_moon.py diff --git a/Src.GetRenamed/StdLib/Lib/turtledemo/round_dance.py b/src/StdLib/Lib/turtledemo/round_dance.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtledemo/round_dance.py rename to src/StdLib/Lib/turtledemo/round_dance.py diff --git a/Src.GetRenamed/StdLib/Lib/turtledemo/tree.py b/src/StdLib/Lib/turtledemo/tree.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtledemo/tree.py rename to src/StdLib/Lib/turtledemo/tree.py diff --git a/Src.GetRenamed/StdLib/Lib/turtledemo/turtle.cfg b/src/StdLib/Lib/turtledemo/turtle.cfg similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtledemo/turtle.cfg rename to src/StdLib/Lib/turtledemo/turtle.cfg diff --git a/Src.GetRenamed/StdLib/Lib/turtledemo/two_canvases.py b/src/StdLib/Lib/turtledemo/two_canvases.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtledemo/two_canvases.py rename to src/StdLib/Lib/turtledemo/two_canvases.py diff --git a/Src.GetRenamed/StdLib/Lib/turtledemo/wikipedia.py b/src/StdLib/Lib/turtledemo/wikipedia.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtledemo/wikipedia.py rename to src/StdLib/Lib/turtledemo/wikipedia.py diff --git a/Src.GetRenamed/StdLib/Lib/turtledemo/yinyang.py b/src/StdLib/Lib/turtledemo/yinyang.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/turtledemo/yinyang.py rename to src/StdLib/Lib/turtledemo/yinyang.py diff --git a/Src.GetRenamed/StdLib/Lib/types.py b/src/StdLib/Lib/types.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/types.py rename to src/StdLib/Lib/types.py diff --git a/Src.GetRenamed/StdLib/Lib/typing.py b/src/StdLib/Lib/typing.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/typing.py rename to src/StdLib/Lib/typing.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/__init__.py b/src/StdLib/Lib/unittest/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/__init__.py rename to src/StdLib/Lib/unittest/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/__main__.py b/src/StdLib/Lib/unittest/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/__main__.py rename to src/StdLib/Lib/unittest/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/case.py b/src/StdLib/Lib/unittest/case.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/case.py rename to src/StdLib/Lib/unittest/case.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/loader.py b/src/StdLib/Lib/unittest/loader.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/loader.py rename to src/StdLib/Lib/unittest/loader.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/main.py b/src/StdLib/Lib/unittest/main.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/main.py rename to src/StdLib/Lib/unittest/main.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/mock.py b/src/StdLib/Lib/unittest/mock.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/mock.py rename to src/StdLib/Lib/unittest/mock.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/result.py b/src/StdLib/Lib/unittest/result.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/result.py rename to src/StdLib/Lib/unittest/result.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/runner.py b/src/StdLib/Lib/unittest/runner.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/runner.py rename to src/StdLib/Lib/unittest/runner.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/signals.py b/src/StdLib/Lib/unittest/signals.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/signals.py rename to src/StdLib/Lib/unittest/signals.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/suite.py b/src/StdLib/Lib/unittest/suite.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/suite.py rename to src/StdLib/Lib/unittest/suite.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/__init__.py b/src/StdLib/Lib/unittest/test/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/__init__.py rename to src/StdLib/Lib/unittest/test/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/__main__.py b/src/StdLib/Lib/unittest/test/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/__main__.py rename to src/StdLib/Lib/unittest/test/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/_test_warnings.py b/src/StdLib/Lib/unittest/test/_test_warnings.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/_test_warnings.py rename to src/StdLib/Lib/unittest/test/_test_warnings.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/dummy.py b/src/StdLib/Lib/unittest/test/dummy.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/dummy.py rename to src/StdLib/Lib/unittest/test/dummy.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/support.py b/src/StdLib/Lib/unittest/test/support.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/support.py rename to src/StdLib/Lib/unittest/test/support.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/test_assertions.py b/src/StdLib/Lib/unittest/test/test_assertions.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/test_assertions.py rename to src/StdLib/Lib/unittest/test/test_assertions.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/test_break.py b/src/StdLib/Lib/unittest/test/test_break.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/test_break.py rename to src/StdLib/Lib/unittest/test/test_break.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/test_case.py b/src/StdLib/Lib/unittest/test/test_case.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/test_case.py rename to src/StdLib/Lib/unittest/test/test_case.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/test_discovery.py b/src/StdLib/Lib/unittest/test/test_discovery.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/test_discovery.py rename to src/StdLib/Lib/unittest/test/test_discovery.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/test_functiontestcase.py b/src/StdLib/Lib/unittest/test/test_functiontestcase.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/test_functiontestcase.py rename to src/StdLib/Lib/unittest/test/test_functiontestcase.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/test_loader.py b/src/StdLib/Lib/unittest/test/test_loader.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/test_loader.py rename to src/StdLib/Lib/unittest/test/test_loader.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/test_program.py b/src/StdLib/Lib/unittest/test/test_program.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/test_program.py rename to src/StdLib/Lib/unittest/test/test_program.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/test_result.py b/src/StdLib/Lib/unittest/test/test_result.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/test_result.py rename to src/StdLib/Lib/unittest/test/test_result.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/test_runner.py b/src/StdLib/Lib/unittest/test/test_runner.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/test_runner.py rename to src/StdLib/Lib/unittest/test/test_runner.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/test_setups.py b/src/StdLib/Lib/unittest/test/test_setups.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/test_setups.py rename to src/StdLib/Lib/unittest/test/test_setups.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/test_skipping.py b/src/StdLib/Lib/unittest/test/test_skipping.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/test_skipping.py rename to src/StdLib/Lib/unittest/test/test_skipping.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/test_suite.py b/src/StdLib/Lib/unittest/test/test_suite.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/test_suite.py rename to src/StdLib/Lib/unittest/test/test_suite.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/testmock/__init__.py b/src/StdLib/Lib/unittest/test/testmock/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/testmock/__init__.py rename to src/StdLib/Lib/unittest/test/testmock/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/testmock/__main__.py b/src/StdLib/Lib/unittest/test/testmock/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/testmock/__main__.py rename to src/StdLib/Lib/unittest/test/testmock/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/testmock/support.py b/src/StdLib/Lib/unittest/test/testmock/support.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/testmock/support.py rename to src/StdLib/Lib/unittest/test/testmock/support.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testcallable.py b/src/StdLib/Lib/unittest/test/testmock/testcallable.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testcallable.py rename to src/StdLib/Lib/unittest/test/testmock/testcallable.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testhelpers.py b/src/StdLib/Lib/unittest/test/testmock/testhelpers.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testhelpers.py rename to src/StdLib/Lib/unittest/test/testmock/testhelpers.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testmagicmethods.py b/src/StdLib/Lib/unittest/test/testmock/testmagicmethods.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testmagicmethods.py rename to src/StdLib/Lib/unittest/test/testmock/testmagicmethods.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testmock.py b/src/StdLib/Lib/unittest/test/testmock/testmock.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testmock.py rename to src/StdLib/Lib/unittest/test/testmock/testmock.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testpatch.py b/src/StdLib/Lib/unittest/test/testmock/testpatch.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testpatch.py rename to src/StdLib/Lib/unittest/test/testmock/testpatch.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testsentinel.py b/src/StdLib/Lib/unittest/test/testmock/testsentinel.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testsentinel.py rename to src/StdLib/Lib/unittest/test/testmock/testsentinel.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testwith.py b/src/StdLib/Lib/unittest/test/testmock/testwith.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/test/testmock/testwith.py rename to src/StdLib/Lib/unittest/test/testmock/testwith.py diff --git a/Src.GetRenamed/StdLib/Lib/unittest/util.py b/src/StdLib/Lib/unittest/util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/unittest/util.py rename to src/StdLib/Lib/unittest/util.py diff --git a/Src.GetRenamed/StdLib/Lib/urllib/__init__.py b/src/StdLib/Lib/urllib/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/urllib/__init__.py rename to src/StdLib/Lib/urllib/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/urllib/error.py b/src/StdLib/Lib/urllib/error.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/urllib/error.py rename to src/StdLib/Lib/urllib/error.py diff --git a/Src.GetRenamed/StdLib/Lib/urllib/parse.py b/src/StdLib/Lib/urllib/parse.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/urllib/parse.py rename to src/StdLib/Lib/urllib/parse.py diff --git a/Src.GetRenamed/StdLib/Lib/urllib/request.py b/src/StdLib/Lib/urllib/request.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/urllib/request.py rename to src/StdLib/Lib/urllib/request.py diff --git a/Src.GetRenamed/StdLib/Lib/urllib/response.py b/src/StdLib/Lib/urllib/response.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/urllib/response.py rename to src/StdLib/Lib/urllib/response.py diff --git a/Src.GetRenamed/StdLib/Lib/urllib/robotparser.py b/src/StdLib/Lib/urllib/robotparser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/urllib/robotparser.py rename to src/StdLib/Lib/urllib/robotparser.py diff --git a/Src.GetRenamed/StdLib/Lib/uu.py b/src/StdLib/Lib/uu.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/uu.py rename to src/StdLib/Lib/uu.py diff --git a/Src.GetRenamed/StdLib/Lib/uuid.py b/src/StdLib/Lib/uuid.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/uuid.py rename to src/StdLib/Lib/uuid.py diff --git a/Src.GetRenamed/StdLib/Lib/venv/__init__.py b/src/StdLib/Lib/venv/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/venv/__init__.py rename to src/StdLib/Lib/venv/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/venv/__main__.py b/src/StdLib/Lib/venv/__main__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/venv/__main__.py rename to src/StdLib/Lib/venv/__main__.py diff --git a/Src.GetRenamed/StdLib/Lib/venv/scripts/nt/Activate.ps1 b/src/StdLib/Lib/venv/scripts/nt/Activate.ps1 similarity index 100% rename from Src.GetRenamed/StdLib/Lib/venv/scripts/nt/Activate.ps1 rename to src/StdLib/Lib/venv/scripts/nt/Activate.ps1 diff --git a/Src.GetRenamed/StdLib/Lib/venv/scripts/nt/activate.bat b/src/StdLib/Lib/venv/scripts/nt/activate.bat similarity index 100% rename from Src.GetRenamed/StdLib/Lib/venv/scripts/nt/activate.bat rename to src/StdLib/Lib/venv/scripts/nt/activate.bat diff --git a/Src.GetRenamed/StdLib/Lib/venv/scripts/nt/deactivate.bat b/src/StdLib/Lib/venv/scripts/nt/deactivate.bat similarity index 100% rename from Src.GetRenamed/StdLib/Lib/venv/scripts/nt/deactivate.bat rename to src/StdLib/Lib/venv/scripts/nt/deactivate.bat diff --git a/Src.GetRenamed/StdLib/Lib/venv/scripts/posix/activate b/src/StdLib/Lib/venv/scripts/posix/activate similarity index 100% rename from Src.GetRenamed/StdLib/Lib/venv/scripts/posix/activate rename to src/StdLib/Lib/venv/scripts/posix/activate diff --git a/Src.GetRenamed/StdLib/Lib/venv/scripts/posix/activate.csh b/src/StdLib/Lib/venv/scripts/posix/activate.csh similarity index 100% rename from Src.GetRenamed/StdLib/Lib/venv/scripts/posix/activate.csh rename to src/StdLib/Lib/venv/scripts/posix/activate.csh diff --git a/Src.GetRenamed/StdLib/Lib/venv/scripts/posix/activate.fish b/src/StdLib/Lib/venv/scripts/posix/activate.fish similarity index 100% rename from Src.GetRenamed/StdLib/Lib/venv/scripts/posix/activate.fish rename to src/StdLib/Lib/venv/scripts/posix/activate.fish diff --git a/Src.GetRenamed/StdLib/Lib/warnings.py b/src/StdLib/Lib/warnings.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/warnings.py rename to src/StdLib/Lib/warnings.py diff --git a/Src.GetRenamed/StdLib/Lib/wave.py b/src/StdLib/Lib/wave.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/wave.py rename to src/StdLib/Lib/wave.py diff --git a/Src.GetRenamed/StdLib/Lib/weakref.py b/src/StdLib/Lib/weakref.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/weakref.py rename to src/StdLib/Lib/weakref.py diff --git a/Src.GetRenamed/StdLib/Lib/webbrowser.py b/src/StdLib/Lib/webbrowser.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/webbrowser.py rename to src/StdLib/Lib/webbrowser.py diff --git a/Src.GetRenamed/StdLib/Lib/wpf.py b/src/StdLib/Lib/wpf.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/wpf.py rename to src/StdLib/Lib/wpf.py diff --git a/Src.GetRenamed/StdLib/Lib/wsgiref/__init__.py b/src/StdLib/Lib/wsgiref/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/wsgiref/__init__.py rename to src/StdLib/Lib/wsgiref/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/wsgiref/handlers.py b/src/StdLib/Lib/wsgiref/handlers.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/wsgiref/handlers.py rename to src/StdLib/Lib/wsgiref/handlers.py diff --git a/Src.GetRenamed/StdLib/Lib/wsgiref/headers.py b/src/StdLib/Lib/wsgiref/headers.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/wsgiref/headers.py rename to src/StdLib/Lib/wsgiref/headers.py diff --git a/Src.GetRenamed/StdLib/Lib/wsgiref/simple_server.py b/src/StdLib/Lib/wsgiref/simple_server.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/wsgiref/simple_server.py rename to src/StdLib/Lib/wsgiref/simple_server.py diff --git a/Src.GetRenamed/StdLib/Lib/wsgiref/util.py b/src/StdLib/Lib/wsgiref/util.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/wsgiref/util.py rename to src/StdLib/Lib/wsgiref/util.py diff --git a/Src.GetRenamed/StdLib/Lib/wsgiref/validate.py b/src/StdLib/Lib/wsgiref/validate.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/wsgiref/validate.py rename to src/StdLib/Lib/wsgiref/validate.py diff --git a/Src.GetRenamed/StdLib/Lib/xdrlib.py b/src/StdLib/Lib/xdrlib.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xdrlib.py rename to src/StdLib/Lib/xdrlib.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/__init__.py b/src/StdLib/Lib/xml/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/__init__.py rename to src/StdLib/Lib/xml/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/dom/NodeFilter.py b/src/StdLib/Lib/xml/dom/NodeFilter.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/dom/NodeFilter.py rename to src/StdLib/Lib/xml/dom/NodeFilter.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/dom/__init__.py b/src/StdLib/Lib/xml/dom/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/dom/__init__.py rename to src/StdLib/Lib/xml/dom/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/dom/domreg.py b/src/StdLib/Lib/xml/dom/domreg.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/dom/domreg.py rename to src/StdLib/Lib/xml/dom/domreg.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/dom/expatbuilder.py b/src/StdLib/Lib/xml/dom/expatbuilder.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/dom/expatbuilder.py rename to src/StdLib/Lib/xml/dom/expatbuilder.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/dom/minicompat.py b/src/StdLib/Lib/xml/dom/minicompat.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/dom/minicompat.py rename to src/StdLib/Lib/xml/dom/minicompat.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/dom/minidom.py b/src/StdLib/Lib/xml/dom/minidom.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/dom/minidom.py rename to src/StdLib/Lib/xml/dom/minidom.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/dom/pulldom.py b/src/StdLib/Lib/xml/dom/pulldom.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/dom/pulldom.py rename to src/StdLib/Lib/xml/dom/pulldom.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/dom/xmlbuilder.py b/src/StdLib/Lib/xml/dom/xmlbuilder.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/dom/xmlbuilder.py rename to src/StdLib/Lib/xml/dom/xmlbuilder.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/etree/ElementInclude.py b/src/StdLib/Lib/xml/etree/ElementInclude.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/etree/ElementInclude.py rename to src/StdLib/Lib/xml/etree/ElementInclude.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/etree/ElementPath.py b/src/StdLib/Lib/xml/etree/ElementPath.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/etree/ElementPath.py rename to src/StdLib/Lib/xml/etree/ElementPath.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/etree/ElementTree.py b/src/StdLib/Lib/xml/etree/ElementTree.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/etree/ElementTree.py rename to src/StdLib/Lib/xml/etree/ElementTree.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/etree/__init__.py b/src/StdLib/Lib/xml/etree/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/etree/__init__.py rename to src/StdLib/Lib/xml/etree/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/etree/cElementTree.py b/src/StdLib/Lib/xml/etree/cElementTree.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/etree/cElementTree.py rename to src/StdLib/Lib/xml/etree/cElementTree.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/parsers/__init__.py b/src/StdLib/Lib/xml/parsers/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/parsers/__init__.py rename to src/StdLib/Lib/xml/parsers/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/parsers/expat.py b/src/StdLib/Lib/xml/parsers/expat.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/parsers/expat.py rename to src/StdLib/Lib/xml/parsers/expat.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/sax/__init__.py b/src/StdLib/Lib/xml/sax/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/sax/__init__.py rename to src/StdLib/Lib/xml/sax/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/sax/_exceptions.py b/src/StdLib/Lib/xml/sax/_exceptions.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/sax/_exceptions.py rename to src/StdLib/Lib/xml/sax/_exceptions.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/sax/expatreader.py b/src/StdLib/Lib/xml/sax/expatreader.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/sax/expatreader.py rename to src/StdLib/Lib/xml/sax/expatreader.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/sax/handler.py b/src/StdLib/Lib/xml/sax/handler.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/sax/handler.py rename to src/StdLib/Lib/xml/sax/handler.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/sax/saxutils.py b/src/StdLib/Lib/xml/sax/saxutils.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/sax/saxutils.py rename to src/StdLib/Lib/xml/sax/saxutils.py diff --git a/Src.GetRenamed/StdLib/Lib/xml/sax/xmlreader.py b/src/StdLib/Lib/xml/sax/xmlreader.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xml/sax/xmlreader.py rename to src/StdLib/Lib/xml/sax/xmlreader.py diff --git a/Src.GetRenamed/StdLib/Lib/xmlrpc/__init__.py b/src/StdLib/Lib/xmlrpc/__init__.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xmlrpc/__init__.py rename to src/StdLib/Lib/xmlrpc/__init__.py diff --git a/Src.GetRenamed/StdLib/Lib/xmlrpc/client.py b/src/StdLib/Lib/xmlrpc/client.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xmlrpc/client.py rename to src/StdLib/Lib/xmlrpc/client.py diff --git a/Src.GetRenamed/StdLib/Lib/xmlrpc/server.py b/src/StdLib/Lib/xmlrpc/server.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/xmlrpc/server.py rename to src/StdLib/Lib/xmlrpc/server.py diff --git a/Src.GetRenamed/StdLib/Lib/zipfile.py b/src/StdLib/Lib/zipfile.py similarity index 100% rename from Src.GetRenamed/StdLib/Lib/zipfile.py rename to src/StdLib/Lib/zipfile.py diff --git a/Src.GetRenamed/StdLib/StdLib.License.txt b/src/StdLib/StdLib.License.txt similarity index 100% rename from Src.GetRenamed/StdLib/StdLib.License.txt rename to src/StdLib/StdLib.License.txt diff --git a/Src.GetRenamed/StdLib/StdLib.pyproj b/src/StdLib/StdLib.pyproj similarity index 100% rename from Src.GetRenamed/StdLib/StdLib.pyproj rename to src/StdLib/StdLib.pyproj diff --git a/Src.GetRenamed/StdLib/stdlib-upgrade.txt b/src/StdLib/stdlib-upgrade.txt similarity index 100% rename from Src.GetRenamed/StdLib/stdlib-upgrade.txt rename to src/StdLib/stdlib-upgrade.txt diff --git a/Src.GetRenamed/StdLib/update-stdlib.cmd b/src/StdLib/update-stdlib.cmd similarity index 100% rename from Src.GetRenamed/StdLib/update-stdlib.cmd rename to src/StdLib/update-stdlib.cmd diff --git a/Src.GetRenamed/StdLib/update-stdlib.sh b/src/StdLib/update-stdlib.sh similarity index 100% rename from Src.GetRenamed/StdLib/update-stdlib.sh rename to src/StdLib/update-stdlib.sh diff --git a/Src.GetRenamed/Tests/AssemblyInfo.cs b/src/Tests/AssemblyInfo.cs similarity index 100% rename from Src.GetRenamed/Tests/AssemblyInfo.cs rename to src/Tests/AssemblyInfo.cs diff --git a/Src.GetRenamed/Tests/AttrInjectorTest.cs b/src/Tests/AttrInjectorTest.cs similarity index 100% rename from Src.GetRenamed/Tests/AttrInjectorTest.cs rename to src/Tests/AttrInjectorTest.cs diff --git a/Src.GetRenamed/Tests/BindTest.cs b/src/Tests/BindTest.cs similarity index 100% rename from Src.GetRenamed/Tests/BindTest.cs rename to src/Tests/BindTest.cs diff --git a/Src.GetRenamed/Tests/BinderTest.cs b/src/Tests/BinderTest.cs similarity index 100% rename from Src.GetRenamed/Tests/BinderTest.cs rename to src/Tests/BinderTest.cs diff --git a/Src.GetRenamed/Tests/Cases/CPythonCases.cs b/src/Tests/Cases/CPythonCases.cs similarity index 100% rename from Src.GetRenamed/Tests/Cases/CPythonCases.cs rename to src/Tests/Cases/CPythonCases.cs diff --git a/Src.GetRenamed/Tests/Cases/CPythonCasesManifest.ini b/src/Tests/Cases/CPythonCasesManifest.ini similarity index 100% rename from Src.GetRenamed/Tests/Cases/CPythonCasesManifest.ini rename to src/Tests/Cases/CPythonCasesManifest.ini diff --git a/Src.GetRenamed/Tests/Cases/CaseExecuter.cs b/src/Tests/Cases/CaseExecuter.cs similarity index 100% rename from Src.GetRenamed/Tests/Cases/CaseExecuter.cs rename to src/Tests/Cases/CaseExecuter.cs diff --git a/Src.GetRenamed/Tests/Cases/CaseGenerator.cs b/src/Tests/Cases/CaseGenerator.cs similarity index 100% rename from Src.GetRenamed/Tests/Cases/CaseGenerator.cs rename to src/Tests/Cases/CaseGenerator.cs diff --git a/Src.GetRenamed/Tests/Cases/CommonCases.cs b/src/Tests/Cases/CommonCases.cs similarity index 100% rename from Src.GetRenamed/Tests/Cases/CommonCases.cs rename to src/Tests/Cases/CommonCases.cs diff --git a/Src.GetRenamed/Tests/Cases/IronPythonCases.cs b/src/Tests/Cases/IronPythonCases.cs similarity index 100% rename from Src.GetRenamed/Tests/Cases/IronPythonCases.cs rename to src/Tests/Cases/IronPythonCases.cs diff --git a/Src.GetRenamed/Tests/Cases/IronPythonCasesManifest.ini b/src/Tests/Cases/IronPythonCasesManifest.ini similarity index 100% rename from Src.GetRenamed/Tests/Cases/IronPythonCasesManifest.ini rename to src/Tests/Cases/IronPythonCasesManifest.ini diff --git a/Src.GetRenamed/Tests/ClrType.cs b/src/Tests/ClrType.cs similarity index 100% rename from Src.GetRenamed/Tests/ClrType.cs rename to src/Tests/ClrType.cs diff --git a/Src.GetRenamed/Tests/Cmplx.cs b/src/Tests/Cmplx.cs similarity index 100% rename from Src.GetRenamed/Tests/Cmplx.cs rename to src/Tests/Cmplx.cs diff --git a/Src.GetRenamed/Tests/Conversions.cs b/src/Tests/Conversions.cs similarity index 100% rename from Src.GetRenamed/Tests/Conversions.cs rename to src/Tests/Conversions.cs diff --git a/Src.GetRenamed/Tests/DeTest.cs b/src/Tests/DeTest.cs similarity index 100% rename from Src.GetRenamed/Tests/DeTest.cs rename to src/Tests/DeTest.cs diff --git a/Src.GetRenamed/Tests/DelegateTest.cs b/src/Tests/DelegateTest.cs similarity index 100% rename from Src.GetRenamed/Tests/DelegateTest.cs rename to src/Tests/DelegateTest.cs diff --git a/Src.GetRenamed/Tests/DynamicRegressions.cs b/src/Tests/DynamicRegressions.cs similarity index 100% rename from Src.GetRenamed/Tests/DynamicRegressions.cs rename to src/Tests/DynamicRegressions.cs diff --git a/Src.GetRenamed/Tests/EncodingTest.cs b/src/Tests/EncodingTest.cs similarity index 100% rename from Src.GetRenamed/Tests/EncodingTest.cs rename to src/Tests/EncodingTest.cs diff --git a/Src.GetRenamed/Tests/EngineTest.cs b/src/Tests/EngineTest.cs similarity index 100% rename from Src.GetRenamed/Tests/EngineTest.cs rename to src/Tests/EngineTest.cs diff --git a/Src.GetRenamed/Tests/Enums.cs b/src/Tests/Enums.cs similarity index 100% rename from Src.GetRenamed/Tests/Enums.cs rename to src/Tests/Enums.cs diff --git a/Src.GetRenamed/Tests/Events.cs b/src/Tests/Events.cs similarity index 100% rename from Src.GetRenamed/Tests/Events.cs rename to src/Tests/Events.cs diff --git a/Src.GetRenamed/Tests/ExceptionConverter.cs b/src/Tests/ExceptionConverter.cs similarity index 100% rename from Src.GetRenamed/Tests/ExceptionConverter.cs rename to src/Tests/ExceptionConverter.cs diff --git a/Src.GetRenamed/Tests/Exceptions.cs b/src/Tests/Exceptions.cs similarity index 100% rename from Src.GetRenamed/Tests/Exceptions.cs rename to src/Tests/Exceptions.cs diff --git a/Src.GetRenamed/Tests/Explicit.cs b/src/Tests/Explicit.cs similarity index 100% rename from Src.GetRenamed/Tests/Explicit.cs rename to src/Tests/Explicit.cs diff --git a/Src.GetRenamed/Tests/ExtensionMethodTest.cs b/src/Tests/ExtensionMethodTest.cs similarity index 100% rename from Src.GetRenamed/Tests/ExtensionMethodTest.cs rename to src/Tests/ExtensionMethodTest.cs diff --git a/Src.GetRenamed/Tests/GenMeth.cs b/src/Tests/GenMeth.cs similarity index 100% rename from Src.GetRenamed/Tests/GenMeth.cs rename to src/Tests/GenMeth.cs diff --git a/Src.GetRenamed/Tests/Indexable.cs b/src/Tests/Indexable.cs similarity index 100% rename from Src.GetRenamed/Tests/Indexable.cs rename to src/Tests/Indexable.cs diff --git a/Src.GetRenamed/Tests/InheritTest.cs b/src/Tests/InheritTest.cs similarity index 100% rename from Src.GetRenamed/Tests/InheritTest.cs rename to src/Tests/InheritTest.cs diff --git a/Src.GetRenamed/Tests/IntegerTest.cs b/src/Tests/IntegerTest.cs similarity index 100% rename from Src.GetRenamed/Tests/IntegerTest.cs rename to src/Tests/IntegerTest.cs diff --git a/Src.GetRenamed/Tests/IronMath.cs b/src/Tests/IronMath.cs similarity index 100% rename from Src.GetRenamed/Tests/IronMath.cs rename to src/Tests/IronMath.cs diff --git a/Src.GetRenamed/Tests/IronPython.Tests.csproj b/src/Tests/IronPython.Tests.csproj similarity index 100% rename from Src.GetRenamed/Tests/IronPython.Tests.csproj rename to src/Tests/IronPython.Tests.csproj diff --git a/Src.GetRenamed/Tests/LoadTest.cs b/src/Tests/LoadTest.cs similarity index 100% rename from Src.GetRenamed/Tests/LoadTest.cs rename to src/Tests/LoadTest.cs diff --git a/Src.GetRenamed/Tests/MemberMappingTests.cs b/src/Tests/MemberMappingTests.cs similarity index 100% rename from Src.GetRenamed/Tests/MemberMappingTests.cs rename to src/Tests/MemberMappingTests.cs diff --git a/Src.GetRenamed/Tests/MemberOverloadTest.cs b/src/Tests/MemberOverloadTest.cs similarity index 100% rename from Src.GetRenamed/Tests/MemberOverloadTest.cs rename to src/Tests/MemberOverloadTest.cs diff --git a/Src.GetRenamed/Tests/MethodParametersStubs.cs b/src/Tests/MethodParametersStubs.cs similarity index 100% rename from Src.GetRenamed/Tests/MethodParametersStubs.cs rename to src/Tests/MethodParametersStubs.cs diff --git a/Src.GetRenamed/Tests/NestedClass.cs b/src/Tests/NestedClass.cs similarity index 100% rename from Src.GetRenamed/Tests/NestedClass.cs rename to src/Tests/NestedClass.cs diff --git a/Src.GetRenamed/Tests/NullableTest.cs b/src/Tests/NullableTest.cs similarity index 100% rename from Src.GetRenamed/Tests/NullableTest.cs rename to src/Tests/NullableTest.cs diff --git a/Src.GetRenamed/Tests/OperatorTest.cs b/src/Tests/OperatorTest.cs similarity index 100% rename from Src.GetRenamed/Tests/OperatorTest.cs rename to src/Tests/OperatorTest.cs diff --git a/Src.GetRenamed/Tests/ProtocolTest.cs b/src/Tests/ProtocolTest.cs similarity index 100% rename from Src.GetRenamed/Tests/ProtocolTest.cs rename to src/Tests/ProtocolTest.cs diff --git a/Src.GetRenamed/Tests/StaticTest.cs b/src/Tests/StaticTest.cs similarity index 100% rename from Src.GetRenamed/Tests/StaticTest.cs rename to src/Tests/StaticTest.cs diff --git a/Src.GetRenamed/Tests/Stress/Engine.cs b/src/Tests/Stress/Engine.cs similarity index 100% rename from Src.GetRenamed/Tests/Stress/Engine.cs rename to src/Tests/Stress/Engine.cs diff --git a/Src.GetRenamed/Tests/StringDictionaryStorage.cs b/src/Tests/StringDictionaryStorage.cs similarity index 100% rename from Src.GetRenamed/Tests/StringDictionaryStorage.cs rename to src/Tests/StringDictionaryStorage.cs diff --git a/Src.GetRenamed/Tests/TestBuiltinModule.cs b/src/Tests/TestBuiltinModule.cs similarity index 100% rename from Src.GetRenamed/Tests/TestBuiltinModule.cs rename to src/Tests/TestBuiltinModule.cs diff --git a/Src.GetRenamed/Tests/TypeDescriptor.cs b/src/Tests/TypeDescriptor.cs similarity index 100% rename from Src.GetRenamed/Tests/TypeDescriptor.cs rename to src/Tests/TypeDescriptor.cs diff --git a/Src.GetRenamed/Tests/Util/IniParser.cs b/src/Tests/Util/IniParser.cs similarity index 100% rename from Src.GetRenamed/Tests/Util/IniParser.cs rename to src/Tests/Util/IniParser.cs diff --git a/Src.GetRenamed/Tests/Util/TestManifest.cs b/src/Tests/Util/TestManifest.cs similarity index 100% rename from Src.GetRenamed/Tests/Util/TestManifest.cs rename to src/Tests/Util/TestManifest.cs diff --git a/Src.GetRenamed/Wpf/DynamicXamlReader.cs b/src/Wpf/DynamicXamlReader.cs similarity index 100% rename from Src.GetRenamed/Wpf/DynamicXamlReader.cs rename to src/Wpf/DynamicXamlReader.cs diff --git a/Src.GetRenamed/Wpf/IronPython.Wpf.csproj b/src/Wpf/IronPython.Wpf.csproj similarity index 100% rename from Src.GetRenamed/Wpf/IronPython.Wpf.csproj rename to src/Wpf/IronPython.Wpf.csproj diff --git a/Src.GetRenamed/Wpf/Properties/AssemblyInfo.cs b/src/Wpf/Properties/AssemblyInfo.cs similarity index 100% rename from Src.GetRenamed/Wpf/Properties/AssemblyInfo.cs rename to src/Wpf/Properties/AssemblyInfo.cs diff --git a/Src.GetRenamed/Wpf/_wpf.cs b/src/Wpf/_wpf.cs similarity index 100% rename from Src.GetRenamed/Wpf/_wpf.cs rename to src/Wpf/_wpf.cs diff --git a/Utils.GetRenamed/NuGet/nuget.exe b/utils/NuGet/nuget.exe similarity index 100% rename from Utils.GetRenamed/NuGet/nuget.exe rename to utils/NuGet/nuget.exe diff --git a/Utils.GetRenamed/References/IKVM/IKVM.Reflection.License.txt b/utils/References/IKVM/IKVM.Reflection.License.txt similarity index 100% rename from Utils.GetRenamed/References/IKVM/IKVM.Reflection.License.txt rename to utils/References/IKVM/IKVM.Reflection.License.txt diff --git a/Utils.GetRenamed/References/IKVM/IKVM.Reflection.dll b/utils/References/IKVM/IKVM.Reflection.dll similarity index 100% rename from Utils.GetRenamed/References/IKVM/IKVM.Reflection.dll rename to utils/References/IKVM/IKVM.Reflection.dll diff --git a/Utils.GetRenamed/References/Mono.Posix.dll b/utils/References/Mono.Posix.dll similarity index 100% rename from Utils.GetRenamed/References/Mono.Posix.dll rename to utils/References/Mono.Posix.dll From 9930af4640e3b7cd04fdc3309016fef5694b2d80 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 17:20:19 +0000 Subject: [PATCH 16/84] Change capitalization in `.gitmodules` --- .gitmodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 5cd8e15d8..5c5b9f9ee 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ -[submodule "Src/DLR"] - path = Src/DLR +[submodule "src/DLR"] + path = src/DLR url = https://github.com/IronLanguages/dlr branch = main From dda691593620faa1dfe173eb67b9229b5d6b7db6 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 17:23:33 +0000 Subject: [PATCH 17/84] Initialize submodule --- src/DLR | 1 + 1 file changed, 1 insertion(+) create mode 160000 src/DLR diff --git a/src/DLR b/src/DLR new file mode 160000 index 000000000..fe26cf45d --- /dev/null +++ b/src/DLR @@ -0,0 +1 @@ +Subproject commit fe26cf45d383be65a56f0d4b964644eff89e01a8 From 16bdc18e1e9346e1b900bb60a7fc82c816fd4200 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 17:40:37 +0000 Subject: [PATCH 18/84] Sort internal directories --- {src/Scripts => scripts}/CompareDirs.py | 0 .../Enter-IronPythonEnvironment.ps1 | 0 {src/Scripts => scripts}/Install-IronPython.ps1 | 0 {src/Scripts => scripts}/clean.py | 0 {src/Scripts => scripts}/copyrights.py | 0 {src/Scripts => scripts}/generate.py | 0 .../generate_UncollectableCompilationMode.py | 0 {src/Scripts => scripts}/generate_alltypes.py | 0 {src/Scripts => scripts}/generate_calls.py | 0 {src/Scripts => scripts}/generate_casts.py | 0 {src/Scripts => scripts}/generate_comdispatch.py | 0 {src/Scripts => scripts}/generate_dict_views.py | 0 .../generate_dynamic_instructions.py | 0 {src/Scripts => scripts}/generate_dynsites.py | 0 .../generate_encoding_aliases.py | 0 .../generate_exception_factory.py | 0 {src/Scripts => scripts}/generate_exceptions.py | 0 {src/Scripts => scripts}/generate_indicestest.py | 0 {src/Scripts => scripts}/generate_math.py | 0 {src/Scripts => scripts}/generate_ops.py | 0 {src/Scripts => scripts}/generate_os_codes.py | 0 .../Scripts => scripts}/generate_reflected_calls.py | 0 {src/Scripts => scripts}/generate_set.py | 0 {src/Scripts => scripts}/generate_tuples.py | 0 {src/Scripts => scripts}/generate_typecache.py | 0 {src/Scripts => scripts}/generate_walker.py | 0 {src/Scripts => scripts}/ipcom.ps1 | 0 {src/Scripts => scripts}/make_meta1.py | 0 {src/Scripts => scripts}/radix_generator.py | 0 {src/Scripts => scripts}/run_compiled.py | 0 {src/Scripts => scripts}/run_interactive.py | 0 {src/Scripts => scripts}/smtpmailer.py | 0 {src/Scripts => scripts}/test_builder.py | 0 {src/Scripts => scripts}/test_cgcheck.py | 0 {src/Scripts => scripts}/test_parrot.py | 0 {src/Scripts => scripts}/test_pystone.py | 0 .../IronPython.Console.Host.csproj | 0 .../IronPython.Console.Host}/IronPythonWindow.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../IronPython.Console.Host}/ipyw.ico | Bin .../IronPython.Console}/Console.cs | 0 .../IronPython.Console}/IronPython.Console.csproj | 0 .../IronPython.Console}/Properties/AssemblyInfo.cs | 0 .../IronPython.Console}/app.manifest | 0 .../IronPython.Console}/ipy-mono.sh | 0 src/{Console => console/IronPython.Console}/ipy.ico | Bin src/{Console => console/IronPython.Console}/ipy.sh | 0 .../IronPython.Console}/runtimeconfig.template.json | 0 .../IronPython.Console32.Host.csproj | 0 .../IronPython.Console32.csproj | 0 .../IronPython.SQLite}/Connection.cs | 0 .../IronPython.SQLite}/Contants.cs | 0 .../IronPython.SQLite}/Cursor.cs | 0 .../IronPython.SQLite}/Exceptions.cs | 0 .../IronPython.SQLite}/Extensions.cs | 0 .../IronPython.SQLite}/IronPython.SQLite.csproj | 0 .../IronPython.SQLite}/Properties/AssemblyInfo.cs | 0 src/{SQLite => extensions/IronPython.SQLite}/Row.cs | 0 .../IronPython.SQLite}/Statement.cs | 0 .../IronPython.SQLite}/Util.cs | 0 .../IronPython.SQLite}/_sqlite.cs | 0 .../IronPython.SQLite}/c#sqlite/.editorconfig | 0 .../IronPython.SQLite}/c#sqlite/BtreeInt_h.cs | 0 .../IronPython.SQLite}/c#sqlite/Btree_h.cs | 0 .../IronPython.SQLite}/c#sqlite/Delegates.cs | 0 .../IronPython.SQLite}/c#sqlite/Hash_h.cs | 0 .../IronPython.SQLite}/c#sqlite/VdbeInt_h.cs | 0 .../IronPython.SQLite}/c#sqlite/Vdbe_h.cs | 0 .../IronPython.SQLite}/c#sqlite/_Custom.cs | 0 .../IronPython.SQLite}/c#sqlite/alter_c.cs | 0 .../IronPython.SQLite}/c#sqlite/analyze_c.cs | 0 .../IronPython.SQLite}/c#sqlite/attach_c.cs | 0 .../IronPython.SQLite}/c#sqlite/auth_c.cs | 0 .../IronPython.SQLite}/c#sqlite/backup_c.cs | 0 .../IronPython.SQLite}/c#sqlite/bitvec_c.cs | 0 .../IronPython.SQLite}/c#sqlite/btmutex_c.cs | 0 .../IronPython.SQLite}/c#sqlite/btree_c.cs | 0 .../IronPython.SQLite}/c#sqlite/build_c.cs | 0 .../IronPython.SQLite}/c#sqlite/callback_c.cs | 0 .../IronPython.SQLite}/c#sqlite/complete_c.cs | 0 .../IronPython.SQLite}/c#sqlite/crypto.cs | 0 .../IronPython.SQLite}/c#sqlite/ctime_c.cs | 0 .../IronPython.SQLite}/c#sqlite/date_c.cs | 0 .../IronPython.SQLite}/c#sqlite/delete_c.cs | 0 .../IronPython.SQLite}/c#sqlite/expr_c.cs | 0 .../IronPython.SQLite}/c#sqlite/fault_c.cs | 0 .../IronPython.SQLite}/c#sqlite/fkey_c.cs | 0 .../IronPython.SQLite}/c#sqlite/func_c.cs | 0 .../IronPython.SQLite}/c#sqlite/global_c.cs | 0 .../IronPython.SQLite}/c#sqlite/hash_c.cs | 0 .../IronPython.SQLite}/c#sqlite/hwtime_c.cs | 0 .../IronPython.SQLite}/c#sqlite/insert_c.cs | 0 .../IronPython.SQLite}/c#sqlite/journal_c.cs | 0 .../IronPython.SQLite}/c#sqlite/keywordhash_h.cs | 0 .../IronPython.SQLite}/c#sqlite/legacy_c.cs | 0 .../IronPython.SQLite}/c#sqlite/loadext_c.cs | 0 .../IronPython.SQLite}/c#sqlite/main_c.cs | 0 .../IronPython.SQLite}/c#sqlite/malloc_c.cs | 0 .../IronPython.SQLite}/c#sqlite/mem_Pool.cs | 0 .../IronPython.SQLite}/c#sqlite/memjournal_c.cs | 0 .../IronPython.SQLite}/c#sqlite/mutex_c.cs | 0 .../IronPython.SQLite}/c#sqlite/mutex_h.cs | 0 .../IronPython.SQLite}/c#sqlite/mutex_noop_c.cs | 0 .../IronPython.SQLite}/c#sqlite/mutex_w32.cs | 0 .../IronPython.SQLite}/c#sqlite/notify_c.cs | 0 .../IronPython.SQLite}/c#sqlite/opcodes_c.cs | 0 .../IronPython.SQLite}/c#sqlite/opcodes_h.cs | 0 .../IronPython.SQLite}/c#sqlite/os_c.cs | 0 .../IronPython.SQLite}/c#sqlite/os_common_h.cs | 0 .../IronPython.SQLite}/c#sqlite/os_h.cs | 0 .../IronPython.SQLite}/c#sqlite/os_win_c.cs | 0 .../IronPython.SQLite}/c#sqlite/pager_c.cs | 0 .../IronPython.SQLite}/c#sqlite/pager_h.cs | 0 .../IronPython.SQLite}/c#sqlite/parse_c.cs | 0 .../IronPython.SQLite}/c#sqlite/parse_h.cs | 0 .../IronPython.SQLite}/c#sqlite/pcache1_c.cs | 0 .../IronPython.SQLite}/c#sqlite/pcache_c.cs | 0 .../IronPython.SQLite}/c#sqlite/pcache_h.cs | 0 .../IronPython.SQLite}/c#sqlite/pragma_c.cs | 0 .../IronPython.SQLite}/c#sqlite/prepare_c.cs | 0 .../IronPython.SQLite}/c#sqlite/printf_c.cs | 0 .../IronPython.SQLite}/c#sqlite/random_c.cs | 0 .../IronPython.SQLite}/c#sqlite/resolve_c.cs | 0 .../IronPython.SQLite}/c#sqlite/rowset_c.cs | 0 .../IronPython.SQLite}/c#sqlite/select_c.cs | 0 .../IronPython.SQLite}/c#sqlite/sqlite3_h.cs | 0 .../IronPython.SQLite}/c#sqlite/sqliteInt_h.cs | 0 .../IronPython.SQLite}/c#sqlite/sqliteLimit_h.cs | 0 .../IronPython.SQLite}/c#sqlite/status_c.cs | 0 .../IronPython.SQLite}/c#sqlite/table_c.cs | 0 .../IronPython.SQLite}/c#sqlite/tokenize_c.cs | 0 .../IronPython.SQLite}/c#sqlite/trigger_c.cs | 0 .../IronPython.SQLite}/c#sqlite/update_c.cs | 0 .../IronPython.SQLite}/c#sqlite/utf_c.cs | 0 .../IronPython.SQLite}/c#sqlite/util_c.cs | 0 .../IronPython.SQLite}/c#sqlite/vacuum_c.cs | 0 .../IronPython.SQLite}/c#sqlite/vdbe_c.cs | 0 .../IronPython.SQLite}/c#sqlite/vdbeapi_c.cs | 0 .../IronPython.SQLite}/c#sqlite/vdbeaux_c.cs | 0 .../IronPython.SQLite}/c#sqlite/vdbeblob_c.cs | 0 .../IronPython.SQLite}/c#sqlite/vdbemem_c.cs | 0 .../IronPython.SQLite}/c#sqlite/vdbetrace_c.cs | 0 .../IronPython.SQLite}/c#sqlite/vtab_c.cs | 0 .../IronPython.SQLite}/c#sqlite/wal_c.cs | 0 .../IronPython.SQLite}/c#sqlite/wal_h.cs | 0 .../IronPython.SQLite}/c#sqlite/walker_c.cs | 0 .../IronPython.SQLite}/c#sqlite/where_c.cs | 0 .../IronPython.Wpf}/DynamicXamlReader.cs | 0 .../IronPython.Wpf}/IronPython.Wpf.csproj | 0 .../IronPython.Wpf}/Properties/AssemblyInfo.cs | 0 src/{Wpf => extensions/IronPython.Wpf}/_wpf.cs | 0 src/{ => extensions}/StdLib/.gitattributes | 0 src/{ => extensions}/StdLib/Lib/__future__.py | 0 src/{ => extensions}/StdLib/Lib/__phello__.foo.py | 0 src/{ => extensions}/StdLib/Lib/_bootlocale.py | 0 src/{ => extensions}/StdLib/Lib/_collections_abc.py | 0 src/{ => extensions}/StdLib/Lib/_compat_pickle.py | 0 src/{ => extensions}/StdLib/Lib/_dummy_thread.py | 0 src/{ => extensions}/StdLib/Lib/_markupbase.py | 0 src/{ => extensions}/StdLib/Lib/_osx_support.py | 0 src/{ => extensions}/StdLib/Lib/_pyio.py | 0 src/{ => extensions}/StdLib/Lib/_sitebuiltins.py | 0 src/{ => extensions}/StdLib/Lib/_strptime.py | 0 src/{ => extensions}/StdLib/Lib/_threading_local.py | 0 src/{ => extensions}/StdLib/Lib/_weakrefset.py | 0 src/{ => extensions}/StdLib/Lib/abc.py | 0 src/{ => extensions}/StdLib/Lib/aifc.py | 0 src/{ => extensions}/StdLib/Lib/antigravity.py | 0 src/{ => extensions}/StdLib/Lib/argparse.py | 0 src/{ => extensions}/StdLib/Lib/ast.py | 0 src/{ => extensions}/StdLib/Lib/asynchat.py | 0 src/{ => extensions}/StdLib/Lib/asyncio/__init__.py | 0 .../StdLib/Lib/asyncio/base_events.py | 0 .../StdLib/Lib/asyncio/base_subprocess.py | 0 src/{ => extensions}/StdLib/Lib/asyncio/compat.py | 0 .../StdLib/Lib/asyncio/constants.py | 0 .../StdLib/Lib/asyncio/coroutines.py | 0 src/{ => extensions}/StdLib/Lib/asyncio/events.py | 0 src/{ => extensions}/StdLib/Lib/asyncio/futures.py | 0 src/{ => extensions}/StdLib/Lib/asyncio/locks.py | 0 src/{ => extensions}/StdLib/Lib/asyncio/log.py | 0 .../StdLib/Lib/asyncio/proactor_events.py | 0 .../StdLib/Lib/asyncio/protocols.py | 0 src/{ => extensions}/StdLib/Lib/asyncio/queues.py | 0 .../StdLib/Lib/asyncio/selector_events.py | 0 src/{ => extensions}/StdLib/Lib/asyncio/sslproto.py | 0 src/{ => extensions}/StdLib/Lib/asyncio/streams.py | 0 .../StdLib/Lib/asyncio/subprocess.py | 0 src/{ => extensions}/StdLib/Lib/asyncio/tasks.py | 0 .../StdLib/Lib/asyncio/test_utils.py | 0 .../StdLib/Lib/asyncio/transports.py | 0 .../StdLib/Lib/asyncio/unix_events.py | 0 .../StdLib/Lib/asyncio/windows_events.py | 0 .../StdLib/Lib/asyncio/windows_utils.py | 0 src/{ => extensions}/StdLib/Lib/asyncore.py | 0 src/{ => extensions}/StdLib/Lib/base64.py | 0 src/{ => extensions}/StdLib/Lib/bdb.py | 0 src/{ => extensions}/StdLib/Lib/binhex.py | 0 src/{ => extensions}/StdLib/Lib/bisect.py | 0 src/{ => extensions}/StdLib/Lib/bz2.py | 0 src/{ => extensions}/StdLib/Lib/cProfile.py | 0 src/{ => extensions}/StdLib/Lib/calendar.py | 0 src/{ => extensions}/StdLib/Lib/cgi.py | 0 src/{ => extensions}/StdLib/Lib/cgitb.py | 0 src/{ => extensions}/StdLib/Lib/chunk.py | 0 src/{ => extensions}/StdLib/Lib/clrtype.py | 0 src/{ => extensions}/StdLib/Lib/cmd.py | 0 src/{ => extensions}/StdLib/Lib/code.py | 0 src/{ => extensions}/StdLib/Lib/codecs.py | 0 src/{ => extensions}/StdLib/Lib/codeop.py | 0 .../StdLib/Lib/collections/__init__.py | 0 .../StdLib/Lib/collections/__main__.py | 0 src/{ => extensions}/StdLib/Lib/collections/abc.py | 0 src/{ => extensions}/StdLib/Lib/colorsys.py | 0 src/{ => extensions}/StdLib/Lib/compileall.py | 0 .../StdLib/Lib/concurrent/__init__.py | 0 .../StdLib/Lib/concurrent/futures/__init__.py | 0 .../StdLib/Lib/concurrent/futures/_base.py | 0 .../StdLib/Lib/concurrent/futures/process.py | 0 .../StdLib/Lib/concurrent/futures/thread.py | 0 src/{ => extensions}/StdLib/Lib/configparser.py | 0 src/{ => extensions}/StdLib/Lib/contextlib.py | 0 src/{ => extensions}/StdLib/Lib/copy.py | 0 src/{ => extensions}/StdLib/Lib/copyreg.py | 0 src/{ => extensions}/StdLib/Lib/crypt.py | 0 src/{ => extensions}/StdLib/Lib/csv.py | 0 src/{ => extensions}/StdLib/Lib/ctypes/__init__.py | 0 src/{ => extensions}/StdLib/Lib/ctypes/_endian.py | 0 .../StdLib/Lib/ctypes/macholib/README.ctypes | 0 .../StdLib/Lib/ctypes/macholib/__init__.py | 0 .../StdLib/Lib/ctypes/macholib/dyld.py | 0 .../StdLib/Lib/ctypes/macholib/dylib.py | 0 .../StdLib/Lib/ctypes/macholib/fetch_macholib | 0 .../StdLib/Lib/ctypes/macholib/fetch_macholib.bat | 0 .../StdLib/Lib/ctypes/macholib/framework.py | 0 .../StdLib/Lib/ctypes/test/__init__.py | 0 .../StdLib/Lib/ctypes/test/__main__.py | 0 .../StdLib/Lib/ctypes/test/test_anon.py | 0 .../StdLib/Lib/ctypes/test/test_array_in_pointer.py | 0 .../StdLib/Lib/ctypes/test/test_arrays.py | 0 .../StdLib/Lib/ctypes/test/test_as_parameter.py | 0 .../StdLib/Lib/ctypes/test/test_bitfields.py | 0 .../StdLib/Lib/ctypes/test/test_buffers.py | 0 .../StdLib/Lib/ctypes/test/test_bytes.py | 0 .../StdLib/Lib/ctypes/test/test_byteswap.py | 0 .../StdLib/Lib/ctypes/test/test_callbacks.py | 0 .../StdLib/Lib/ctypes/test/test_cast.py | 0 .../StdLib/Lib/ctypes/test/test_cfuncs.py | 0 .../StdLib/Lib/ctypes/test/test_checkretval.py | 0 .../StdLib/Lib/ctypes/test/test_delattr.py | 0 .../StdLib/Lib/ctypes/test/test_errno.py | 0 .../StdLib/Lib/ctypes/test/test_find.py | 0 .../StdLib/Lib/ctypes/test/test_frombuffer.py | 0 .../StdLib/Lib/ctypes/test/test_funcptr.py | 0 .../StdLib/Lib/ctypes/test/test_functions.py | 0 .../StdLib/Lib/ctypes/test/test_incomplete.py | 0 .../StdLib/Lib/ctypes/test/test_init.py | 0 .../StdLib/Lib/ctypes/test/test_internals.py | 0 .../StdLib/Lib/ctypes/test/test_keeprefs.py | 0 .../StdLib/Lib/ctypes/test/test_libc.py | 0 .../StdLib/Lib/ctypes/test/test_loading.py | 0 .../StdLib/Lib/ctypes/test/test_macholib.py | 0 .../StdLib/Lib/ctypes/test/test_memfunctions.py | 0 .../StdLib/Lib/ctypes/test/test_numbers.py | 0 .../StdLib/Lib/ctypes/test/test_objects.py | 0 .../StdLib/Lib/ctypes/test/test_parameters.py | 0 .../StdLib/Lib/ctypes/test/test_pep3118.py | 0 .../StdLib/Lib/ctypes/test/test_pickling.py | 0 .../StdLib/Lib/ctypes/test/test_pointers.py | 0 .../StdLib/Lib/ctypes/test/test_prototypes.py | 0 .../StdLib/Lib/ctypes/test/test_python_api.py | 0 .../StdLib/Lib/ctypes/test/test_random_things.py | 0 .../StdLib/Lib/ctypes/test/test_refcounts.py | 0 .../StdLib/Lib/ctypes/test/test_repr.py | 0 .../StdLib/Lib/ctypes/test/test_returnfuncptrs.py | 0 .../StdLib/Lib/ctypes/test/test_simplesubclasses.py | 0 .../StdLib/Lib/ctypes/test/test_sizes.py | 0 .../StdLib/Lib/ctypes/test/test_slicing.py | 0 .../StdLib/Lib/ctypes/test/test_stringptr.py | 0 .../StdLib/Lib/ctypes/test/test_strings.py | 0 .../StdLib/Lib/ctypes/test/test_struct_fields.py | 0 .../StdLib/Lib/ctypes/test/test_structures.py | 0 .../Lib/ctypes/test/test_unaligned_structures.py | 0 .../StdLib/Lib/ctypes/test/test_unicode.py | 0 .../StdLib/Lib/ctypes/test/test_values.py | 0 .../StdLib/Lib/ctypes/test/test_varsize_struct.py | 0 .../StdLib/Lib/ctypes/test/test_win32.py | 0 .../StdLib/Lib/ctypes/test/test_wintypes.py | 0 src/{ => extensions}/StdLib/Lib/ctypes/util.py | 0 src/{ => extensions}/StdLib/Lib/ctypes/wintypes.py | 0 src/{ => extensions}/StdLib/Lib/curses/__init__.py | 0 src/{ => extensions}/StdLib/Lib/curses/ascii.py | 0 src/{ => extensions}/StdLib/Lib/curses/has_key.py | 0 src/{ => extensions}/StdLib/Lib/curses/panel.py | 0 src/{ => extensions}/StdLib/Lib/curses/textpad.py | 0 src/{ => extensions}/StdLib/Lib/datetime.py | 0 src/{ => extensions}/StdLib/Lib/dbm/__init__.py | 0 src/{ => extensions}/StdLib/Lib/dbm/dumb.py | 0 src/{ => extensions}/StdLib/Lib/dbm/gnu.py | 0 src/{ => extensions}/StdLib/Lib/dbm/ndbm.py | 0 src/{ => extensions}/StdLib/Lib/decimal.py | 0 src/{ => extensions}/StdLib/Lib/difflib.py | 0 src/{ => extensions}/StdLib/Lib/dis.py | 0 src/{ => extensions}/StdLib/Lib/distutils/README | 0 .../StdLib/Lib/distutils/__init__.py | 0 .../StdLib/Lib/distutils/archive_util.py | 0 .../StdLib/Lib/distutils/bcppcompiler.py | 0 .../StdLib/Lib/distutils/ccompiler.py | 0 src/{ => extensions}/StdLib/Lib/distutils/cmd.py | 0 .../StdLib/Lib/distutils/command/__init__.py | 0 .../StdLib/Lib/distutils/command/bdist.py | 0 .../StdLib/Lib/distutils/command/bdist_dumb.py | 0 .../StdLib/Lib/distutils/command/bdist_msi.py | 0 .../StdLib/Lib/distutils/command/bdist_rpm.py | 0 .../StdLib/Lib/distutils/command/bdist_wininst.py | 0 .../StdLib/Lib/distutils/command/build.py | 0 .../StdLib/Lib/distutils/command/build_clib.py | 0 .../StdLib/Lib/distutils/command/build_ext.py | 0 .../StdLib/Lib/distutils/command/build_py.py | 0 .../StdLib/Lib/distutils/command/build_scripts.py | 0 .../StdLib/Lib/distutils/command/check.py | 0 .../StdLib/Lib/distutils/command/clean.py | 0 .../StdLib/Lib/distutils/command/command_template | 0 .../StdLib/Lib/distutils/command/config.py | 0 .../StdLib/Lib/distutils/command/install.py | 0 .../StdLib/Lib/distutils/command/install_data.py | 0 .../Lib/distutils/command/install_egg_info.py | 0 .../StdLib/Lib/distutils/command/install_headers.py | 0 .../StdLib/Lib/distutils/command/install_lib.py | 0 .../StdLib/Lib/distutils/command/install_scripts.py | 0 .../StdLib/Lib/distutils/command/register.py | 0 .../StdLib/Lib/distutils/command/sdist.py | 0 .../StdLib/Lib/distutils/command/upload.py | 0 .../Lib/distutils/command/wininst-10.0-amd64.exe | Bin .../StdLib/Lib/distutils/command/wininst-10.0.exe | Bin .../StdLib/Lib/distutils/command/wininst-6.0.exe | Bin .../StdLib/Lib/distutils/command/wininst-7.1.exe | Bin .../StdLib/Lib/distutils/command/wininst-8.0.exe | Bin .../Lib/distutils/command/wininst-9.0-amd64.exe | Bin .../StdLib/Lib/distutils/command/wininst-9.0.exe | Bin src/{ => extensions}/StdLib/Lib/distutils/config.py | 0 src/{ => extensions}/StdLib/Lib/distutils/core.py | 0 .../StdLib/Lib/distutils/cygwinccompiler.py | 0 src/{ => extensions}/StdLib/Lib/distutils/debug.py | 0 .../StdLib/Lib/distutils/dep_util.py | 0 .../StdLib/Lib/distutils/dir_util.py | 0 src/{ => extensions}/StdLib/Lib/distutils/dist.py | 0 src/{ => extensions}/StdLib/Lib/distutils/errors.py | 0 .../StdLib/Lib/distutils/extension.py | 0 .../StdLib/Lib/distutils/fancy_getopt.py | 0 .../StdLib/Lib/distutils/file_util.py | 0 .../StdLib/Lib/distutils/filelist.py | 0 src/{ => extensions}/StdLib/Lib/distutils/log.py | 0 .../StdLib/Lib/distutils/msvc9compiler.py | 0 .../StdLib/Lib/distutils/msvccompiler.py | 0 src/{ => extensions}/StdLib/Lib/distutils/spawn.py | 0 .../StdLib/Lib/distutils/sysconfig.py | 0 .../StdLib/Lib/distutils/tests/Setup.sample | 0 .../StdLib/Lib/distutils/tests/__init__.py | 0 .../StdLib/Lib/distutils/tests/support.py | 0 .../StdLib/Lib/distutils/tests/test_archive_util.py | 0 .../StdLib/Lib/distutils/tests/test_bdist.py | 0 .../StdLib/Lib/distutils/tests/test_bdist_dumb.py | 0 .../StdLib/Lib/distutils/tests/test_bdist_msi.py | 0 .../StdLib/Lib/distutils/tests/test_bdist_rpm.py | 0 .../Lib/distutils/tests/test_bdist_wininst.py | 0 .../StdLib/Lib/distutils/tests/test_build.py | 0 .../StdLib/Lib/distutils/tests/test_build_clib.py | 0 .../StdLib/Lib/distutils/tests/test_build_ext.py | 0 .../StdLib/Lib/distutils/tests/test_build_py.py | 0 .../Lib/distutils/tests/test_build_scripts.py | 0 .../StdLib/Lib/distutils/tests/test_check.py | 0 .../StdLib/Lib/distutils/tests/test_clean.py | 0 .../StdLib/Lib/distutils/tests/test_cmd.py | 0 .../StdLib/Lib/distutils/tests/test_config.py | 0 .../StdLib/Lib/distutils/tests/test_config_cmd.py | 0 .../StdLib/Lib/distutils/tests/test_core.py | 0 .../Lib/distutils/tests/test_cygwinccompiler.py | 0 .../StdLib/Lib/distutils/tests/test_dep_util.py | 0 .../StdLib/Lib/distutils/tests/test_dir_util.py | 0 .../StdLib/Lib/distutils/tests/test_dist.py | 0 .../StdLib/Lib/distutils/tests/test_extension.py | 0 .../StdLib/Lib/distutils/tests/test_file_util.py | 0 .../StdLib/Lib/distutils/tests/test_filelist.py | 0 .../StdLib/Lib/distutils/tests/test_install.py | 0 .../StdLib/Lib/distutils/tests/test_install_data.py | 0 .../Lib/distutils/tests/test_install_headers.py | 0 .../StdLib/Lib/distutils/tests/test_install_lib.py | 0 .../Lib/distutils/tests/test_install_scripts.py | 0 .../StdLib/Lib/distutils/tests/test_log.py | 0 .../Lib/distutils/tests/test_msvc9compiler.py | 0 .../StdLib/Lib/distutils/tests/test_register.py | 0 .../StdLib/Lib/distutils/tests/test_sdist.py | 0 .../StdLib/Lib/distutils/tests/test_spawn.py | 0 .../StdLib/Lib/distutils/tests/test_sysconfig.py | 0 .../StdLib/Lib/distutils/tests/test_text_file.py | 0 .../Lib/distutils/tests/test_unixccompiler.py | 0 .../StdLib/Lib/distutils/tests/test_upload.py | 0 .../StdLib/Lib/distutils/tests/test_util.py | 0 .../StdLib/Lib/distutils/tests/test_version.py | 0 .../Lib/distutils/tests/test_versionpredicate.py | 0 .../StdLib/Lib/distutils/text_file.py | 0 .../StdLib/Lib/distutils/unixccompiler.py | 0 src/{ => extensions}/StdLib/Lib/distutils/util.py | 0 .../StdLib/Lib/distutils/version.py | 0 .../StdLib/Lib/distutils/versionpredicate.py | 0 src/{ => extensions}/StdLib/Lib/doctest.py | 0 src/{ => extensions}/StdLib/Lib/dummy_threading.py | 0 src/{ => extensions}/StdLib/Lib/email/__init__.py | 0 .../StdLib/Lib/email/_encoded_words.py | 0 .../StdLib/Lib/email/_header_value_parser.py | 0 src/{ => extensions}/StdLib/Lib/email/_parseaddr.py | 0 .../StdLib/Lib/email/_policybase.py | 0 .../StdLib/Lib/email/architecture.rst | 0 src/{ => extensions}/StdLib/Lib/email/base64mime.py | 0 src/{ => extensions}/StdLib/Lib/email/charset.py | 0 .../StdLib/Lib/email/contentmanager.py | 0 src/{ => extensions}/StdLib/Lib/email/encoders.py | 0 src/{ => extensions}/StdLib/Lib/email/errors.py | 0 src/{ => extensions}/StdLib/Lib/email/feedparser.py | 0 src/{ => extensions}/StdLib/Lib/email/generator.py | 0 src/{ => extensions}/StdLib/Lib/email/header.py | 0 .../StdLib/Lib/email/headerregistry.py | 0 src/{ => extensions}/StdLib/Lib/email/iterators.py | 0 src/{ => extensions}/StdLib/Lib/email/message.py | 0 .../StdLib/Lib/email/mime/__init__.py | 0 .../StdLib/Lib/email/mime/application.py | 0 src/{ => extensions}/StdLib/Lib/email/mime/audio.py | 0 src/{ => extensions}/StdLib/Lib/email/mime/base.py | 0 src/{ => extensions}/StdLib/Lib/email/mime/image.py | 0 .../StdLib/Lib/email/mime/message.py | 0 .../StdLib/Lib/email/mime/multipart.py | 0 .../StdLib/Lib/email/mime/nonmultipart.py | 0 src/{ => extensions}/StdLib/Lib/email/mime/text.py | 0 src/{ => extensions}/StdLib/Lib/email/parser.py | 0 src/{ => extensions}/StdLib/Lib/email/policy.py | 0 src/{ => extensions}/StdLib/Lib/email/quoprimime.py | 0 src/{ => extensions}/StdLib/Lib/email/utils.py | 0 .../StdLib/Lib/encodings/__init__.py | 0 .../StdLib/Lib/encodings/aliases.py | 0 src/{ => extensions}/StdLib/Lib/encodings/ascii.py | 0 .../StdLib/Lib/encodings/base64_codec.py | 0 src/{ => extensions}/StdLib/Lib/encodings/big5.py | 0 .../StdLib/Lib/encodings/big5hkscs.py | 0 .../StdLib/Lib/encodings/bz2_codec.py | 0 .../StdLib/Lib/encodings/charmap.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp037.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp1006.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp1026.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp1125.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp1140.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp1250.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp1251.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp1252.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp1253.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp1254.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp1255.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp1256.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp1257.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp1258.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp273.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp424.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp437.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp500.py | 0 .../StdLib/Lib/encodings/cp65001.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp720.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp737.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp775.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp850.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp852.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp855.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp856.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp857.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp858.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp860.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp861.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp862.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp863.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp864.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp865.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp866.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp869.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp874.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp875.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp932.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp949.py | 0 src/{ => extensions}/StdLib/Lib/encodings/cp950.py | 0 .../StdLib/Lib/encodings/euc_jis_2004.py | 0 .../StdLib/Lib/encodings/euc_jisx0213.py | 0 src/{ => extensions}/StdLib/Lib/encodings/euc_jp.py | 0 src/{ => extensions}/StdLib/Lib/encodings/euc_kr.py | 0 .../StdLib/Lib/encodings/gb18030.py | 0 src/{ => extensions}/StdLib/Lib/encodings/gb2312.py | 0 src/{ => extensions}/StdLib/Lib/encodings/gbk.py | 0 .../StdLib/Lib/encodings/hex_codec.py | 0 .../StdLib/Lib/encodings/hp_roman8.py | 0 src/{ => extensions}/StdLib/Lib/encodings/hz.py | 0 src/{ => extensions}/StdLib/Lib/encodings/idna.py | 0 .../StdLib/Lib/encodings/iso2022_jp.py | 0 .../StdLib/Lib/encodings/iso2022_jp_1.py | 0 .../StdLib/Lib/encodings/iso2022_jp_2.py | 0 .../StdLib/Lib/encodings/iso2022_jp_2004.py | 0 .../StdLib/Lib/encodings/iso2022_jp_3.py | 0 .../StdLib/Lib/encodings/iso2022_jp_ext.py | 0 .../StdLib/Lib/encodings/iso2022_kr.py | 0 .../StdLib/Lib/encodings/iso8859_1.py | 0 .../StdLib/Lib/encodings/iso8859_10.py | 0 .../StdLib/Lib/encodings/iso8859_11.py | 0 .../StdLib/Lib/encodings/iso8859_13.py | 0 .../StdLib/Lib/encodings/iso8859_14.py | 0 .../StdLib/Lib/encodings/iso8859_15.py | 0 .../StdLib/Lib/encodings/iso8859_16.py | 0 .../StdLib/Lib/encodings/iso8859_2.py | 0 .../StdLib/Lib/encodings/iso8859_3.py | 0 .../StdLib/Lib/encodings/iso8859_4.py | 0 .../StdLib/Lib/encodings/iso8859_5.py | 0 .../StdLib/Lib/encodings/iso8859_6.py | 0 .../StdLib/Lib/encodings/iso8859_7.py | 0 .../StdLib/Lib/encodings/iso8859_8.py | 0 .../StdLib/Lib/encodings/iso8859_9.py | 0 src/{ => extensions}/StdLib/Lib/encodings/johab.py | 0 src/{ => extensions}/StdLib/Lib/encodings/koi8_r.py | 0 src/{ => extensions}/StdLib/Lib/encodings/koi8_u.py | 0 .../StdLib/Lib/encodings/latin_1.py | 0 .../StdLib/Lib/encodings/mac_arabic.py | 0 .../StdLib/Lib/encodings/mac_centeuro.py | 0 .../StdLib/Lib/encodings/mac_croatian.py | 0 .../StdLib/Lib/encodings/mac_cyrillic.py | 0 .../StdLib/Lib/encodings/mac_farsi.py | 0 .../StdLib/Lib/encodings/mac_greek.py | 0 .../StdLib/Lib/encodings/mac_iceland.py | 0 .../StdLib/Lib/encodings/mac_latin2.py | 0 .../StdLib/Lib/encodings/mac_roman.py | 0 .../StdLib/Lib/encodings/mac_romanian.py | 0 .../StdLib/Lib/encodings/mac_turkish.py | 0 src/{ => extensions}/StdLib/Lib/encodings/mbcs.py | 0 src/{ => extensions}/StdLib/Lib/encodings/palmos.py | 0 .../StdLib/Lib/encodings/ptcp154.py | 0 .../StdLib/Lib/encodings/punycode.py | 0 .../StdLib/Lib/encodings/quopri_codec.py | 0 .../StdLib/Lib/encodings/raw_unicode_escape.py | 0 src/{ => extensions}/StdLib/Lib/encodings/rot_13.py | 0 .../StdLib/Lib/encodings/shift_jis.py | 0 .../StdLib/Lib/encodings/shift_jis_2004.py | 0 .../StdLib/Lib/encodings/shift_jisx0213.py | 0 .../StdLib/Lib/encodings/tis_620.py | 0 .../StdLib/Lib/encodings/undefined.py | 0 .../StdLib/Lib/encodings/unicode_escape.py | 0 .../StdLib/Lib/encodings/unicode_internal.py | 0 src/{ => extensions}/StdLib/Lib/encodings/utf_16.py | 0 .../StdLib/Lib/encodings/utf_16_be.py | 0 .../StdLib/Lib/encodings/utf_16_le.py | 0 src/{ => extensions}/StdLib/Lib/encodings/utf_32.py | 0 .../StdLib/Lib/encodings/utf_32_be.py | 0 .../StdLib/Lib/encodings/utf_32_le.py | 0 src/{ => extensions}/StdLib/Lib/encodings/utf_7.py | 0 src/{ => extensions}/StdLib/Lib/encodings/utf_8.py | 0 .../StdLib/Lib/encodings/utf_8_sig.py | 0 .../StdLib/Lib/encodings/uu_codec.py | 0 .../StdLib/Lib/encodings/zlib_codec.py | 0 .../StdLib/Lib/ensurepip/__init__.py | 0 .../StdLib/Lib/ensurepip/__main__.py | 0 .../_bundled/pip-18.1-py2.py3-none-any.whl | Bin .../_bundled/setuptools-40.6.2-py2.py3-none-any.whl | Bin .../StdLib/Lib/ensurepip/_uninstall.py | 0 src/{ => extensions}/StdLib/Lib/enum.py | 0 src/{ => extensions}/StdLib/Lib/filecmp.py | 0 src/{ => extensions}/StdLib/Lib/fileinput.py | 0 src/{ => extensions}/StdLib/Lib/fnmatch.py | 0 src/{ => extensions}/StdLib/Lib/formatter.py | 0 src/{ => extensions}/StdLib/Lib/fractions.py | 0 src/{ => extensions}/StdLib/Lib/ftplib.py | 0 src/{ => extensions}/StdLib/Lib/functools.py | 0 src/{ => extensions}/StdLib/Lib/genericpath.py | 0 src/{ => extensions}/StdLib/Lib/getopt.py | 0 src/{ => extensions}/StdLib/Lib/getpass.py | 0 src/{ => extensions}/StdLib/Lib/gettext.py | 0 src/{ => extensions}/StdLib/Lib/glob.py | 0 src/{ => extensions}/StdLib/Lib/gzip.py | 0 src/{ => extensions}/StdLib/Lib/hashlib.py | 0 src/{ => extensions}/StdLib/Lib/heapq.py | 0 src/{ => extensions}/StdLib/Lib/hmac.py | 0 src/{ => extensions}/StdLib/Lib/html/__init__.py | 0 src/{ => extensions}/StdLib/Lib/html/entities.py | 0 src/{ => extensions}/StdLib/Lib/html/parser.py | 0 src/{ => extensions}/StdLib/Lib/http/__init__.py | 0 src/{ => extensions}/StdLib/Lib/http/client.py | 0 src/{ => extensions}/StdLib/Lib/http/cookiejar.py | 0 src/{ => extensions}/StdLib/Lib/http/cookies.py | 0 src/{ => extensions}/StdLib/Lib/http/server.py | 0 .../StdLib/Lib/idlelib/AutoComplete.py | 0 .../StdLib/Lib/idlelib/AutoCompleteWindow.py | 0 .../StdLib/Lib/idlelib/AutoExpand.py | 0 src/{ => extensions}/StdLib/Lib/idlelib/Bindings.py | 0 src/{ => extensions}/StdLib/Lib/idlelib/CREDITS.txt | 0 .../StdLib/Lib/idlelib/CallTipWindow.py | 0 src/{ => extensions}/StdLib/Lib/idlelib/CallTips.py | 0 src/{ => extensions}/StdLib/Lib/idlelib/ChangeLog | 0 .../StdLib/Lib/idlelib/ClassBrowser.py | 0 .../StdLib/Lib/idlelib/CodeContext.py | 0 .../StdLib/Lib/idlelib/ColorDelegator.py | 0 src/{ => extensions}/StdLib/Lib/idlelib/Debugger.py | 0 .../StdLib/Lib/idlelib/Delegator.py | 0 .../StdLib/Lib/idlelib/EditorWindow.py | 0 src/{ => extensions}/StdLib/Lib/idlelib/FileList.py | 0 .../StdLib/Lib/idlelib/FormatParagraph.py | 0 .../StdLib/Lib/idlelib/GrepDialog.py | 0 src/{ => extensions}/StdLib/Lib/idlelib/HISTORY.txt | 0 .../StdLib/Lib/idlelib/HyperParser.py | 0 .../StdLib/Lib/idlelib/IOBinding.py | 0 .../StdLib/Lib/idlelib/Icons/folder.gif | Bin .../StdLib/Lib/idlelib/Icons/idle.icns | Bin .../StdLib/Lib/idlelib/Icons/idle.ico | Bin .../StdLib/Lib/idlelib/Icons/idle_16.gif | Bin .../StdLib/Lib/idlelib/Icons/idle_16.png | Bin .../StdLib/Lib/idlelib/Icons/idle_32.gif | Bin .../StdLib/Lib/idlelib/Icons/idle_32.png | Bin .../StdLib/Lib/idlelib/Icons/idle_48.gif | Bin .../StdLib/Lib/idlelib/Icons/idle_48.png | Bin .../StdLib/Lib/idlelib/Icons/minusnode.gif | Bin .../StdLib/Lib/idlelib/Icons/openfolder.gif | Bin .../StdLib/Lib/idlelib/Icons/plusnode.gif | Bin .../StdLib/Lib/idlelib/Icons/python.gif | Bin .../StdLib/Lib/idlelib/Icons/tk.gif | Bin .../StdLib/Lib/idlelib/IdleHistory.py | 0 .../StdLib/Lib/idlelib/MultiCall.py | 0 .../StdLib/Lib/idlelib/MultiStatusBar.py | 0 src/{ => extensions}/StdLib/Lib/idlelib/NEWS.txt | 0 .../StdLib/Lib/idlelib/ObjectBrowser.py | 0 .../StdLib/Lib/idlelib/OutputWindow.py | 0 .../StdLib/Lib/idlelib/ParenMatch.py | 0 .../StdLib/Lib/idlelib/PathBrowser.py | 0 .../StdLib/Lib/idlelib/Percolator.py | 0 src/{ => extensions}/StdLib/Lib/idlelib/PyParse.py | 0 src/{ => extensions}/StdLib/Lib/idlelib/PyShell.py | 0 src/{ => extensions}/StdLib/Lib/idlelib/README.txt | 0 .../StdLib/Lib/idlelib/RemoteDebugger.py | 0 .../StdLib/Lib/idlelib/RemoteObjectBrowser.py | 0 .../StdLib/Lib/idlelib/ReplaceDialog.py | 0 .../StdLib/Lib/idlelib/RstripExtension.py | 0 .../StdLib/Lib/idlelib/ScriptBinding.py | 0 .../StdLib/Lib/idlelib/ScrolledList.py | 0 .../StdLib/Lib/idlelib/SearchDialog.py | 0 .../StdLib/Lib/idlelib/SearchDialogBase.py | 0 .../StdLib/Lib/idlelib/SearchEngine.py | 0 .../StdLib/Lib/idlelib/StackViewer.py | 0 src/{ => extensions}/StdLib/Lib/idlelib/TODO.txt | 0 src/{ => extensions}/StdLib/Lib/idlelib/ToolTip.py | 0 .../StdLib/Lib/idlelib/TreeWidget.py | 0 .../StdLib/Lib/idlelib/UndoDelegator.py | 0 .../StdLib/Lib/idlelib/WidgetRedirector.py | 0 .../StdLib/Lib/idlelib/WindowList.py | 0 .../StdLib/Lib/idlelib/ZoomHeight.py | 0 src/{ => extensions}/StdLib/Lib/idlelib/__init__.py | 0 src/{ => extensions}/StdLib/Lib/idlelib/__main__.py | 0 .../StdLib/Lib/idlelib/aboutDialog.py | 0 .../StdLib/Lib/idlelib/config-extensions.def | 0 .../StdLib/Lib/idlelib/config-highlight.def | 0 .../StdLib/Lib/idlelib/config-keys.def | 0 .../StdLib/Lib/idlelib/config-main.def | 0 .../StdLib/Lib/idlelib/configDialog.py | 0 .../StdLib/Lib/idlelib/configHandler.py | 0 .../StdLib/Lib/idlelib/configHelpSourceEdit.py | 0 .../StdLib/Lib/idlelib/configSectionNameDialog.py | 0 .../StdLib/Lib/idlelib/dynOptionMenuWidget.py | 0 src/{ => extensions}/StdLib/Lib/idlelib/extend.txt | 0 src/{ => extensions}/StdLib/Lib/idlelib/help.html | 0 src/{ => extensions}/StdLib/Lib/idlelib/help.py | 0 src/{ => extensions}/StdLib/Lib/idlelib/help.txt | 0 src/{ => extensions}/StdLib/Lib/idlelib/idle.bat | 0 src/{ => extensions}/StdLib/Lib/idlelib/idle.py | 0 src/{ => extensions}/StdLib/Lib/idlelib/idle.pyw | 0 .../StdLib/Lib/idlelib/idle_test/README.txt | 0 .../StdLib/Lib/idlelib/idle_test/__init__.py | 0 .../StdLib/Lib/idlelib/idle_test/htest.py | 0 .../StdLib/Lib/idlelib/idle_test/mock_idle.py | 0 .../StdLib/Lib/idlelib/idle_test/mock_tk.py | 0 .../Lib/idlelib/idle_test/test_autocomplete.py | 0 .../StdLib/Lib/idlelib/idle_test/test_autoexpand.py | 0 .../StdLib/Lib/idlelib/idle_test/test_calltips.py | 0 .../Lib/idlelib/idle_test/test_config_name.py | 0 .../Lib/idlelib/idle_test/test_configdialog.py | 0 .../StdLib/Lib/idlelib/idle_test/test_delegator.py | 0 .../StdLib/Lib/idlelib/idle_test/test_editor.py | 0 .../Lib/idlelib/idle_test/test_formatparagraph.py | 0 .../StdLib/Lib/idlelib/idle_test/test_grep.py | 0 .../Lib/idlelib/idle_test/test_hyperparser.py | 0 .../Lib/idlelib/idle_test/test_idlehistory.py | 0 .../StdLib/Lib/idlelib/idle_test/test_io.py | 0 .../StdLib/Lib/idlelib/idle_test/test_parenmatch.py | 0 .../Lib/idlelib/idle_test/test_pathbrowser.py | 0 .../StdLib/Lib/idlelib/idle_test/test_rstrip.py | 0 .../Lib/idlelib/idle_test/test_searchdialogbase.py | 0 .../Lib/idlelib/idle_test/test_searchengine.py | 0 .../StdLib/Lib/idlelib/idle_test/test_text.py | 0 .../StdLib/Lib/idlelib/idle_test/test_textview.py | 0 .../StdLib/Lib/idlelib/idle_test/test_warning.py | 0 .../Lib/idlelib/idle_test/test_widgetredir.py | 0 src/{ => extensions}/StdLib/Lib/idlelib/idlever.py | 0 .../StdLib/Lib/idlelib/keybindingDialog.py | 0 .../StdLib/Lib/idlelib/macosxSupport.py | 0 src/{ => extensions}/StdLib/Lib/idlelib/rpc.py | 0 src/{ => extensions}/StdLib/Lib/idlelib/run.py | 0 .../StdLib/Lib/idlelib/tabbedpages.py | 0 src/{ => extensions}/StdLib/Lib/idlelib/textView.py | 0 src/{ => extensions}/StdLib/Lib/imaplib.py | 0 src/{ => extensions}/StdLib/Lib/imghdr.py | 0 src/{ => extensions}/StdLib/Lib/imp.py | 0 .../StdLib/Lib/importlib/__init__.py | 0 .../StdLib/Lib/importlib/_bootstrap.py | 0 src/{ => extensions}/StdLib/Lib/importlib/abc.py | 0 .../StdLib/Lib/importlib/machinery.py | 0 src/{ => extensions}/StdLib/Lib/importlib/util.py | 0 src/{ => extensions}/StdLib/Lib/inspect.py | 0 src/{ => extensions}/StdLib/Lib/io.py | 0 src/{ => extensions}/StdLib/Lib/ipaddress.py | 0 src/{ => extensions}/StdLib/Lib/json/__init__.py | 0 src/{ => extensions}/StdLib/Lib/json/decoder.py | 0 src/{ => extensions}/StdLib/Lib/json/encoder.py | 0 src/{ => extensions}/StdLib/Lib/json/scanner.py | 0 src/{ => extensions}/StdLib/Lib/json/tool.py | 0 src/{ => extensions}/StdLib/Lib/keyword.py | 0 src/{ => extensions}/StdLib/Lib/lib2to3/Grammar.txt | 0 .../StdLib/Lib/lib2to3/PatternGrammar.txt | 0 src/{ => extensions}/StdLib/Lib/lib2to3/__init__.py | 0 src/{ => extensions}/StdLib/Lib/lib2to3/__main__.py | 0 .../StdLib/Lib/lib2to3/btm_matcher.py | 0 .../StdLib/Lib/lib2to3/btm_utils.py | 0 .../StdLib/Lib/lib2to3/fixer_base.py | 0 .../StdLib/Lib/lib2to3/fixer_util.py | 0 .../StdLib/Lib/lib2to3/fixes/__init__.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_apply.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_asserts.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_basestring.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_buffer.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_callable.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_dict.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_except.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_exec.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_execfile.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_exitfunc.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_filter.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_funcattrs.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_future.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_getcwdu.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_has_key.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_idioms.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_import.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_imports.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_imports2.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_input.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_intern.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_isinstance.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_itertools.py | 0 .../Lib/lib2to3/fixes/fix_itertools_imports.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_long.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_map.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_metaclass.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_methodattrs.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_ne.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_next.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_nonzero.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_numliterals.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_operator.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_paren.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_print.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_raise.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_raw_input.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_reduce.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_reload.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_renames.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_repr.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_set_literal.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_standarderror.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_sys_exc.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_throw.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_tuple_params.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_types.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_unicode.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_urllib.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_ws_comma.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_xrange.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_xreadlines.py | 0 .../StdLib/Lib/lib2to3/fixes/fix_zip.py | 0 src/{ => extensions}/StdLib/Lib/lib2to3/main.py | 0 src/{ => extensions}/StdLib/Lib/lib2to3/patcomp.py | 0 .../StdLib/Lib/lib2to3/pgen2/__init__.py | 0 .../StdLib/Lib/lib2to3/pgen2/conv.py | 0 .../StdLib/Lib/lib2to3/pgen2/driver.py | 0 .../StdLib/Lib/lib2to3/pgen2/grammar.py | 0 .../StdLib/Lib/lib2to3/pgen2/literals.py | 0 .../StdLib/Lib/lib2to3/pgen2/parse.py | 0 .../StdLib/Lib/lib2to3/pgen2/pgen.py | 0 .../StdLib/Lib/lib2to3/pgen2/token.py | 0 .../StdLib/Lib/lib2to3/pgen2/tokenize.py | 0 src/{ => extensions}/StdLib/Lib/lib2to3/pygram.py | 0 src/{ => extensions}/StdLib/Lib/lib2to3/pytree.py | 0 src/{ => extensions}/StdLib/Lib/lib2to3/refactor.py | 0 .../StdLib/Lib/lib2to3/tests/__init__.py | 0 .../StdLib/Lib/lib2to3/tests/__main__.py | 0 .../StdLib/Lib/lib2to3/tests/data/README | 0 .../StdLib/Lib/lib2to3/tests/data/bom.py | 0 .../StdLib/Lib/lib2to3/tests/data/crlf.py | 0 .../Lib/lib2to3/tests/data/different_encoding.py | 0 .../StdLib/Lib/lib2to3/tests/data/false_encoding.py | 0 .../Lib/lib2to3/tests/data/fixers/bad_order.py | 0 .../lib2to3/tests/data/fixers/myfixes/__init__.py | 0 .../tests/data/fixers/myfixes/fix_explicit.py | 0 .../lib2to3/tests/data/fixers/myfixes/fix_first.py | 0 .../lib2to3/tests/data/fixers/myfixes/fix_last.py | 0 .../lib2to3/tests/data/fixers/myfixes/fix_parrot.py | 0 .../tests/data/fixers/myfixes/fix_preorder.py | 0 .../Lib/lib2to3/tests/data/fixers/no_fixer_cls.py | 0 .../Lib/lib2to3/tests/data/fixers/parrot_example.py | 0 .../Lib/lib2to3/tests/data/infinite_recursion.py | 0 .../Lib/lib2to3/tests/data/py2_test_grammar.py | 0 .../Lib/lib2to3/tests/data/py3_test_grammar.py | 0 .../StdLib/Lib/lib2to3/tests/pytree_idempotency.py | 0 .../StdLib/Lib/lib2to3/tests/support.py | 0 .../StdLib/Lib/lib2to3/tests/test_all_fixers.py | 0 .../StdLib/Lib/lib2to3/tests/test_fixers.py | 0 .../StdLib/Lib/lib2to3/tests/test_main.py | 0 .../StdLib/Lib/lib2to3/tests/test_parser.py | 0 .../StdLib/Lib/lib2to3/tests/test_pytree.py | 0 .../StdLib/Lib/lib2to3/tests/test_refactor.py | 0 .../StdLib/Lib/lib2to3/tests/test_util.py | 0 src/{ => extensions}/StdLib/Lib/linecache.py | 0 src/{ => extensions}/StdLib/Lib/locale.py | 0 src/{ => extensions}/StdLib/Lib/logging/__init__.py | 0 src/{ => extensions}/StdLib/Lib/logging/config.py | 0 src/{ => extensions}/StdLib/Lib/logging/handlers.py | 0 src/{ => extensions}/StdLib/Lib/lzma.py | 0 src/{ => extensions}/StdLib/Lib/macpath.py | 0 src/{ => extensions}/StdLib/Lib/macurl2path.py | 0 src/{ => extensions}/StdLib/Lib/mailbox.py | 0 src/{ => extensions}/StdLib/Lib/mailcap.py | 0 src/{ => extensions}/StdLib/Lib/mimetypes.py | 0 src/{ => extensions}/StdLib/Lib/modulefinder.py | 0 src/{ => extensions}/StdLib/Lib/msilib/__init__.py | 0 src/{ => extensions}/StdLib/Lib/msilib/schema.py | 0 src/{ => extensions}/StdLib/Lib/msilib/sequence.py | 0 src/{ => extensions}/StdLib/Lib/msilib/text.py | 0 .../StdLib/Lib/multiprocessing/__init__.py | 0 .../StdLib/Lib/multiprocessing/connection.py | 0 .../StdLib/Lib/multiprocessing/context.py | 0 .../StdLib/Lib/multiprocessing/dummy/__init__.py | 0 .../StdLib/Lib/multiprocessing/dummy/connection.py | 0 .../StdLib/Lib/multiprocessing/forkserver.py | 0 .../StdLib/Lib/multiprocessing/heap.py | 0 .../StdLib/Lib/multiprocessing/managers.py | 0 .../StdLib/Lib/multiprocessing/pool.py | 0 .../StdLib/Lib/multiprocessing/popen_fork.py | 0 .../StdLib/Lib/multiprocessing/popen_forkserver.py | 0 .../StdLib/Lib/multiprocessing/popen_spawn_posix.py | 0 .../StdLib/Lib/multiprocessing/popen_spawn_win32.py | 0 .../StdLib/Lib/multiprocessing/process.py | 0 .../StdLib/Lib/multiprocessing/queues.py | 0 .../StdLib/Lib/multiprocessing/reduction.py | 0 .../StdLib/Lib/multiprocessing/resource_sharer.py | 0 .../StdLib/Lib/multiprocessing/semaphore_tracker.py | 0 .../StdLib/Lib/multiprocessing/sharedctypes.py | 0 .../StdLib/Lib/multiprocessing/spawn.py | 0 .../StdLib/Lib/multiprocessing/synchronize.py | 0 .../StdLib/Lib/multiprocessing/util.py | 0 src/{ => extensions}/StdLib/Lib/netrc.py | 0 src/{ => extensions}/StdLib/Lib/nntplib.py | 0 src/{ => extensions}/StdLib/Lib/ntpath.py | 0 src/{ => extensions}/StdLib/Lib/nturl2path.py | 0 src/{ => extensions}/StdLib/Lib/numbers.py | 0 src/{ => extensions}/StdLib/Lib/opcode.py | 0 src/{ => extensions}/StdLib/Lib/operator.py | 0 src/{ => extensions}/StdLib/Lib/optparse.py | 0 src/{ => extensions}/StdLib/Lib/os.py | 0 src/{ => extensions}/StdLib/Lib/pathlib.py | 0 src/{ => extensions}/StdLib/Lib/pdb.py | 0 src/{ => extensions}/StdLib/Lib/pickle.py | 0 src/{ => extensions}/StdLib/Lib/pickletools.py | 0 src/{ => extensions}/StdLib/Lib/pipes.py | 0 src/{ => extensions}/StdLib/Lib/pkgutil.py | 0 src/{ => extensions}/StdLib/Lib/platform.py | 0 src/{ => extensions}/StdLib/Lib/plistlib.py | 0 src/{ => extensions}/StdLib/Lib/poplib.py | 0 src/{ => extensions}/StdLib/Lib/posixpath.py | 0 src/{ => extensions}/StdLib/Lib/pprint.py | 0 src/{ => extensions}/StdLib/Lib/profile.py | 0 src/{ => extensions}/StdLib/Lib/pstats.py | 0 src/{ => extensions}/StdLib/Lib/pty.py | 0 src/{ => extensions}/StdLib/Lib/py_compile.py | 0 src/{ => extensions}/StdLib/Lib/pyclbr.py | 0 src/{ => extensions}/StdLib/Lib/pydoc.py | 0 .../StdLib/Lib/pydoc_data/__init__.py | 0 .../StdLib/Lib/pydoc_data/_pydoc.css | 0 .../StdLib/Lib/pydoc_data/topics.py | 0 src/{ => extensions}/StdLib/Lib/queue.py | 0 src/{ => extensions}/StdLib/Lib/quopri.py | 0 src/{ => extensions}/StdLib/Lib/random.py | 0 src/{ => extensions}/StdLib/Lib/re.py | 0 src/{ => extensions}/StdLib/Lib/reprlib.py | 0 src/{ => extensions}/StdLib/Lib/rlcompleter.py | 0 src/{ => extensions}/StdLib/Lib/runpy.py | 0 src/{ => extensions}/StdLib/Lib/sched.py | 0 src/{ => extensions}/StdLib/Lib/selectors.py | 0 src/{ => extensions}/StdLib/Lib/shelve.py | 0 src/{ => extensions}/StdLib/Lib/shlex.py | 0 src/{ => extensions}/StdLib/Lib/shutil.py | 0 .../StdLib/Lib/site-packages/README | 0 src/{ => extensions}/StdLib/Lib/site.py | 0 src/{ => extensions}/StdLib/Lib/smtpd.py | 0 src/{ => extensions}/StdLib/Lib/smtplib.py | 0 src/{ => extensions}/StdLib/Lib/sndhdr.py | 0 src/{ => extensions}/StdLib/Lib/socket.py | 0 src/{ => extensions}/StdLib/Lib/socketserver.py | 0 src/{ => extensions}/StdLib/Lib/sqlite3/__init__.py | 0 src/{ => extensions}/StdLib/Lib/sqlite3/dbapi2.py | 0 src/{ => extensions}/StdLib/Lib/sqlite3/dump.py | 0 .../StdLib/Lib/sqlite3/test/__init__.py | 0 .../StdLib/Lib/sqlite3/test/dbapi.py | 0 .../StdLib/Lib/sqlite3/test/dump.py | 0 .../StdLib/Lib/sqlite3/test/factory.py | 0 .../StdLib/Lib/sqlite3/test/hooks.py | 0 .../StdLib/Lib/sqlite3/test/regression.py | 0 .../StdLib/Lib/sqlite3/test/transactions.py | 0 .../StdLib/Lib/sqlite3/test/types.py | 0 .../StdLib/Lib/sqlite3/test/userfunctions.py | 0 src/{ => extensions}/StdLib/Lib/sre_compile.py | 0 src/{ => extensions}/StdLib/Lib/sre_constants.py | 0 src/{ => extensions}/StdLib/Lib/sre_parse.py | 0 src/{ => extensions}/StdLib/Lib/ssl.py | 0 src/{ => extensions}/StdLib/Lib/stat.py | 0 src/{ => extensions}/StdLib/Lib/statistics.py | 0 src/{ => extensions}/StdLib/Lib/string.py | 0 src/{ => extensions}/StdLib/Lib/stringprep.py | 0 src/{ => extensions}/StdLib/Lib/struct.py | 0 src/{ => extensions}/StdLib/Lib/subprocess.py | 0 src/{ => extensions}/StdLib/Lib/sunau.py | 0 src/{ => extensions}/StdLib/Lib/symbol.py | 0 src/{ => extensions}/StdLib/Lib/symtable.py | 0 src/{ => extensions}/StdLib/Lib/sysconfig.py | 0 src/{ => extensions}/StdLib/Lib/tabnanny.py | 0 src/{ => extensions}/StdLib/Lib/tarfile.py | 0 src/{ => extensions}/StdLib/Lib/telnetlib.py | 0 src/{ => extensions}/StdLib/Lib/tempfile.py | 0 src/{ => extensions}/StdLib/Lib/test/185test.db | Bin .../StdLib/Lib/test/Sine-1000Hz-300ms.aif | Bin src/{ => extensions}/StdLib/Lib/test/__init__.py | 0 src/{ => extensions}/StdLib/Lib/test/__main__.py | 0 .../StdLib/Lib/test/_test_multiprocessing.py | 0 .../StdLib/Lib/test/audiodata/pluck-alaw.aifc | Bin .../StdLib/Lib/test/audiodata/pluck-pcm16.aiff | Bin .../StdLib/Lib/test/audiodata/pluck-pcm16.au | Bin .../StdLib/Lib/test/audiodata/pluck-pcm16.wav | Bin .../StdLib/Lib/test/audiodata/pluck-pcm24.aiff | Bin .../StdLib/Lib/test/audiodata/pluck-pcm24.au | Bin .../StdLib/Lib/test/audiodata/pluck-pcm24.wav | Bin .../StdLib/Lib/test/audiodata/pluck-pcm32.aiff | Bin .../StdLib/Lib/test/audiodata/pluck-pcm32.au | Bin .../StdLib/Lib/test/audiodata/pluck-pcm32.wav | Bin .../StdLib/Lib/test/audiodata/pluck-pcm8.aiff | Bin .../StdLib/Lib/test/audiodata/pluck-pcm8.au | Bin .../StdLib/Lib/test/audiodata/pluck-pcm8.wav | Bin .../StdLib/Lib/test/audiodata/pluck-ulaw.aifc | Bin .../StdLib/Lib/test/audiodata/pluck-ulaw.au | Bin src/{ => extensions}/StdLib/Lib/test/audiotest.au | Bin src/{ => extensions}/StdLib/Lib/test/audiotests.py | 0 src/{ => extensions}/StdLib/Lib/test/autotest.py | 0 src/{ => extensions}/StdLib/Lib/test/bad_coding.py | 0 src/{ => extensions}/StdLib/Lib/test/bad_coding2.py | 0 src/{ => extensions}/StdLib/Lib/test/badcert.pem | 0 src/{ => extensions}/StdLib/Lib/test/badkey.pem | 0 .../StdLib/Lib/test/badsyntax_3131.py | 0 .../StdLib/Lib/test/badsyntax_future10.py | 0 .../StdLib/Lib/test/badsyntax_future3.py | 0 .../StdLib/Lib/test/badsyntax_future4.py | 0 .../StdLib/Lib/test/badsyntax_future5.py | 0 .../StdLib/Lib/test/badsyntax_future6.py | 0 .../StdLib/Lib/test/badsyntax_future7.py | 0 .../StdLib/Lib/test/badsyntax_future8.py | 0 .../StdLib/Lib/test/badsyntax_future9.py | 0 .../StdLib/Lib/test/badsyntax_pep3120.py | 0 .../StdLib/Lib/test/buffer_tests.py | 0 .../StdLib/Lib/test/bytecode_helper.py | 0 .../StdLib/Lib/test/capath/0e4015b9.0 | 0 .../StdLib/Lib/test/capath/4e1295a3.0 | 0 .../StdLib/Lib/test/capath/5ed36f99.0 | 0 .../StdLib/Lib/test/capath/6e88d7b8.0 | 0 .../StdLib/Lib/test/capath/99d0fa06.0 | 0 .../StdLib/Lib/test/capath/ce7b8643.0 | 0 src/{ => extensions}/StdLib/Lib/test/cfgparser.1 | 0 src/{ => extensions}/StdLib/Lib/test/cfgparser.2 | 0 src/{ => extensions}/StdLib/Lib/test/cfgparser.3 | 0 .../StdLib/Lib/test/check_soundcard.vbs | 0 .../StdLib/Lib/test/cjkencodings/big5-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/big5.txt | 0 .../StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/big5hkscs.txt | 0 .../StdLib/Lib/test/cjkencodings/cp949-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/cp949.txt | 0 .../Lib/test/cjkencodings/euc_jisx0213-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/euc_jisx0213.txt | 0 .../StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/euc_jp.txt | 0 .../StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/euc_kr.txt | 0 .../StdLib/Lib/test/cjkencodings/gb18030-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/gb18030.txt | 0 .../StdLib/Lib/test/cjkencodings/gb2312-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/gb2312.txt | 0 .../StdLib/Lib/test/cjkencodings/gbk-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/gbk.txt | 0 .../StdLib/Lib/test/cjkencodings/hz-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/hz.txt | 0 .../Lib/test/cjkencodings/iso2022_jp-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/iso2022_jp.txt | 0 .../Lib/test/cjkencodings/iso2022_kr-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/iso2022_kr.txt | 0 .../StdLib/Lib/test/cjkencodings/johab-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/johab.txt | 0 .../StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/shift_jis.txt | 0 .../Lib/test/cjkencodings/shift_jisx0213-utf8.txt | 0 .../StdLib/Lib/test/cjkencodings/shift_jisx0213.txt | 0 .../StdLib/Lib/test/cmath_testcases.txt | 0 src/{ => extensions}/StdLib/Lib/test/coding20731.py | 0 .../StdLib/Lib/test/crashers/README | 0 .../StdLib/Lib/test/crashers/bogus_code_obj.py | 0 .../StdLib/Lib/test/crashers/gc_inspection.py | 0 .../StdLib/Lib/test/crashers/infinite_loop_re.py | 0 .../Lib/test/crashers/mutation_inside_cyclegc.py | 0 .../StdLib/Lib/test/crashers/recursive_call.py | 0 .../Lib/test/crashers/trace_at_recursion_limit.py | 0 .../StdLib/Lib/test/crashers/underlying_dict.py | 0 .../StdLib/Lib/test/curses_tests.py | 0 src/{ => extensions}/StdLib/Lib/test/data/README | 0 .../StdLib/Lib/test/datetimetester.py | 0 .../StdLib/Lib/test/decimaltestdata/abs.decTest | 0 .../StdLib/Lib/test/decimaltestdata/add.decTest | 0 .../StdLib/Lib/test/decimaltestdata/and.decTest | 0 .../StdLib/Lib/test/decimaltestdata/base.decTest | 0 .../StdLib/Lib/test/decimaltestdata/clamp.decTest | 0 .../StdLib/Lib/test/decimaltestdata/class.decTest | 0 .../StdLib/Lib/test/decimaltestdata/compare.decTest | 0 .../Lib/test/decimaltestdata/comparetotal.decTest | 0 .../Lib/test/decimaltestdata/comparetotmag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/copy.decTest | 0 .../StdLib/Lib/test/decimaltestdata/copyabs.decTest | 0 .../Lib/test/decimaltestdata/copynegate.decTest | 0 .../Lib/test/decimaltestdata/copysign.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddAbs.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddAdd.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddAnd.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddBase.decTest | 0 .../Lib/test/decimaltestdata/ddCanonical.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddClass.decTest | 0 .../Lib/test/decimaltestdata/ddCompare.decTest | 0 .../Lib/test/decimaltestdata/ddCompareSig.decTest | 0 .../Lib/test/decimaltestdata/ddCompareTotal.decTest | 0 .../test/decimaltestdata/ddCompareTotalMag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddCopy.decTest | 0 .../Lib/test/decimaltestdata/ddCopyAbs.decTest | 0 .../Lib/test/decimaltestdata/ddCopyNegate.decTest | 0 .../Lib/test/decimaltestdata/ddCopySign.decTest | 0 .../Lib/test/decimaltestdata/ddDivide.decTest | 0 .../Lib/test/decimaltestdata/ddDivideInt.decTest | 0 .../Lib/test/decimaltestdata/ddEncode.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddFMA.decTest | 0 .../Lib/test/decimaltestdata/ddInvert.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddLogB.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddMax.decTest | 0 .../Lib/test/decimaltestdata/ddMaxMag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddMin.decTest | 0 .../Lib/test/decimaltestdata/ddMinMag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddMinus.decTest | 0 .../Lib/test/decimaltestdata/ddMultiply.decTest | 0 .../Lib/test/decimaltestdata/ddNextMinus.decTest | 0 .../Lib/test/decimaltestdata/ddNextPlus.decTest | 0 .../Lib/test/decimaltestdata/ddNextToward.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddOr.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddPlus.decTest | 0 .../Lib/test/decimaltestdata/ddQuantize.decTest | 0 .../Lib/test/decimaltestdata/ddReduce.decTest | 0 .../Lib/test/decimaltestdata/ddRemainder.decTest | 0 .../test/decimaltestdata/ddRemainderNear.decTest | 0 .../Lib/test/decimaltestdata/ddRotate.decTest | 0 .../Lib/test/decimaltestdata/ddSameQuantum.decTest | 0 .../Lib/test/decimaltestdata/ddScaleB.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddShift.decTest | 0 .../Lib/test/decimaltestdata/ddSubtract.decTest | 0 .../Lib/test/decimaltestdata/ddToIntegral.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ddXor.decTest | 0 .../Lib/test/decimaltestdata/decDouble.decTest | 0 .../StdLib/Lib/test/decimaltestdata/decQuad.decTest | 0 .../Lib/test/decimaltestdata/decSingle.decTest | 0 .../StdLib/Lib/test/decimaltestdata/divide.decTest | 0 .../Lib/test/decimaltestdata/divideint.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqAbs.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqAdd.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqAnd.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqBase.decTest | 0 .../Lib/test/decimaltestdata/dqCanonical.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqClass.decTest | 0 .../Lib/test/decimaltestdata/dqCompare.decTest | 0 .../Lib/test/decimaltestdata/dqCompareSig.decTest | 0 .../Lib/test/decimaltestdata/dqCompareTotal.decTest | 0 .../test/decimaltestdata/dqCompareTotalMag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqCopy.decTest | 0 .../Lib/test/decimaltestdata/dqCopyAbs.decTest | 0 .../Lib/test/decimaltestdata/dqCopyNegate.decTest | 0 .../Lib/test/decimaltestdata/dqCopySign.decTest | 0 .../Lib/test/decimaltestdata/dqDivide.decTest | 0 .../Lib/test/decimaltestdata/dqDivideInt.decTest | 0 .../Lib/test/decimaltestdata/dqEncode.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqFMA.decTest | 0 .../Lib/test/decimaltestdata/dqInvert.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqLogB.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqMax.decTest | 0 .../Lib/test/decimaltestdata/dqMaxMag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqMin.decTest | 0 .../Lib/test/decimaltestdata/dqMinMag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqMinus.decTest | 0 .../Lib/test/decimaltestdata/dqMultiply.decTest | 0 .../Lib/test/decimaltestdata/dqNextMinus.decTest | 0 .../Lib/test/decimaltestdata/dqNextPlus.decTest | 0 .../Lib/test/decimaltestdata/dqNextToward.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqOr.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqPlus.decTest | 0 .../Lib/test/decimaltestdata/dqQuantize.decTest | 0 .../Lib/test/decimaltestdata/dqReduce.decTest | 0 .../Lib/test/decimaltestdata/dqRemainder.decTest | 0 .../test/decimaltestdata/dqRemainderNear.decTest | 0 .../Lib/test/decimaltestdata/dqRotate.decTest | 0 .../Lib/test/decimaltestdata/dqSameQuantum.decTest | 0 .../Lib/test/decimaltestdata/dqScaleB.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqShift.decTest | 0 .../Lib/test/decimaltestdata/dqSubtract.decTest | 0 .../Lib/test/decimaltestdata/dqToIntegral.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dqXor.decTest | 0 .../StdLib/Lib/test/decimaltestdata/dsBase.decTest | 0 .../Lib/test/decimaltestdata/dsEncode.decTest | 0 .../StdLib/Lib/test/decimaltestdata/exp.decTest | 0 .../StdLib/Lib/test/decimaltestdata/extra.decTest | 0 .../StdLib/Lib/test/decimaltestdata/fma.decTest | 0 .../StdLib/Lib/test/decimaltestdata/inexact.decTest | 0 .../StdLib/Lib/test/decimaltestdata/invert.decTest | 0 .../StdLib/Lib/test/decimaltestdata/ln.decTest | 0 .../StdLib/Lib/test/decimaltestdata/log10.decTest | 0 .../StdLib/Lib/test/decimaltestdata/logb.decTest | 0 .../StdLib/Lib/test/decimaltestdata/max.decTest | 0 .../StdLib/Lib/test/decimaltestdata/maxmag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/min.decTest | 0 .../StdLib/Lib/test/decimaltestdata/minmag.decTest | 0 .../StdLib/Lib/test/decimaltestdata/minus.decTest | 0 .../Lib/test/decimaltestdata/multiply.decTest | 0 .../Lib/test/decimaltestdata/nextminus.decTest | 0 .../Lib/test/decimaltestdata/nextplus.decTest | 0 .../Lib/test/decimaltestdata/nexttoward.decTest | 0 .../StdLib/Lib/test/decimaltestdata/or.decTest | 0 .../StdLib/Lib/test/decimaltestdata/plus.decTest | 0 .../StdLib/Lib/test/decimaltestdata/power.decTest | 0 .../Lib/test/decimaltestdata/powersqrt.decTest | 0 .../Lib/test/decimaltestdata/quantize.decTest | 0 .../Lib/test/decimaltestdata/randomBound32.decTest | 0 .../StdLib/Lib/test/decimaltestdata/randoms.decTest | 0 .../StdLib/Lib/test/decimaltestdata/reduce.decTest | 0 .../Lib/test/decimaltestdata/remainder.decTest | 0 .../Lib/test/decimaltestdata/remainderNear.decTest | 0 .../StdLib/Lib/test/decimaltestdata/rescale.decTest | 0 .../StdLib/Lib/test/decimaltestdata/rotate.decTest | 0 .../Lib/test/decimaltestdata/rounding.decTest | 0 .../Lib/test/decimaltestdata/samequantum.decTest | 0 .../StdLib/Lib/test/decimaltestdata/scaleb.decTest | 0 .../StdLib/Lib/test/decimaltestdata/shift.decTest | 0 .../Lib/test/decimaltestdata/squareroot.decTest | 0 .../Lib/test/decimaltestdata/subtract.decTest | 0 .../StdLib/Lib/test/decimaltestdata/testall.decTest | 0 .../Lib/test/decimaltestdata/tointegral.decTest | 0 .../Lib/test/decimaltestdata/tointegralx.decTest | 0 .../StdLib/Lib/test/decimaltestdata/xor.decTest | 0 src/{ => extensions}/StdLib/Lib/test/dh1024.pem | 0 src/{ => extensions}/StdLib/Lib/test/dis_module.py | 0 .../StdLib/Lib/test/doctest_aliases.py | 0 .../StdLib/Lib/test/double_const.py | 0 src/{ => extensions}/StdLib/Lib/test/empty.vbs | 0 .../StdLib/Lib/test/encoded_modules/__init__.py | 0 .../Lib/test/encoded_modules/module_iso_8859_1.py | 0 .../Lib/test/encoded_modules/module_koi8_r.py | 0 .../StdLib/Lib/test/exception_hierarchy.txt | 0 src/{ => extensions}/StdLib/Lib/test/final_a.py | 0 src/{ => extensions}/StdLib/Lib/test/final_b.py | 0 .../StdLib/Lib/test/floating_points.txt | 0 src/{ => extensions}/StdLib/Lib/test/fork_wait.py | 0 .../StdLib/Lib/test/formatfloat_testcases.txt | 0 .../StdLib/Lib/test/future_test1.py | 0 .../StdLib/Lib/test/future_test2.py | 0 src/{ => extensions}/StdLib/Lib/test/gdb_sample.py | 0 src/{ => extensions}/StdLib/Lib/test/ieee754.txt | 0 .../StdLib/Lib/test/imghdrdata/python.bmp | Bin .../StdLib/Lib/test/imghdrdata/python.gif | Bin .../StdLib/Lib/test/imghdrdata/python.jpg | Bin .../StdLib/Lib/test/imghdrdata/python.pbm | 0 .../StdLib/Lib/test/imghdrdata/python.pgm | Bin .../StdLib/Lib/test/imghdrdata/python.png | Bin .../StdLib/Lib/test/imghdrdata/python.ppm | Bin .../StdLib/Lib/test/imghdrdata/python.ras | Bin .../StdLib/Lib/test/imghdrdata/python.sgi | Bin .../StdLib/Lib/test/imghdrdata/python.tiff | Bin .../StdLib/Lib/test/imghdrdata/python.xbm | 0 .../StdLib/Lib/test/inspect_fodder.py | 0 .../StdLib/Lib/test/inspect_fodder2.py | 0 .../StdLib/Lib/test/keycert.passwd.pem | 0 src/{ => extensions}/StdLib/Lib/test/keycert.pem | 0 src/{ => extensions}/StdLib/Lib/test/keycert2.pem | 0 src/{ => extensions}/StdLib/Lib/test/keycert3.pem | 0 src/{ => extensions}/StdLib/Lib/test/keycert4.pem | 0 .../StdLib/Lib/test/leakers/README.txt | 0 .../StdLib/Lib/test/leakers/__init__.py | 0 .../StdLib/Lib/test/leakers/test_ctypes.py | 0 .../StdLib/Lib/test/leakers/test_selftype.py | 0 src/{ => extensions}/StdLib/Lib/test/list_tests.py | 0 src/{ => extensions}/StdLib/Lib/test/lock_tests.py | 0 src/{ => extensions}/StdLib/Lib/test/mailcap.txt | 0 .../StdLib/Lib/test/make_ssl_certs.py | 0 .../StdLib/Lib/test/mapping_tests.py | 0 .../StdLib/Lib/test/math_testcases.txt | 0 .../StdLib/Lib/test/memory_watchdog.py | 0 src/{ => extensions}/StdLib/Lib/test/mime.types | 0 src/{ => extensions}/StdLib/Lib/test/mock_socket.py | 0 .../StdLib/Lib/test/mod_generics_cache.py | 0 .../StdLib/Lib/test/mp_fork_bomb.py | 0 .../StdLib/Lib/test/multibytecodec_support.py | 0 src/{ => extensions}/StdLib/Lib/test/nokia.pem | 0 .../StdLib/Lib/test/nullbytecert.pem | 0 src/{ => extensions}/StdLib/Lib/test/nullcert.pem | 0 .../StdLib/Lib/test/outstanding_bugs.py | 0 .../StdLib/Lib/test/pickletester.py | 0 src/{ => extensions}/StdLib/Lib/test/profilee.py | 0 src/{ => extensions}/StdLib/Lib/test/pstats.pck | Bin src/{ => extensions}/StdLib/Lib/test/pycacert.pem | 0 src/{ => extensions}/StdLib/Lib/test/pycakey.pem | 0 .../StdLib/Lib/test/pyclbr_input.py | 0 src/{ => extensions}/StdLib/Lib/test/pydoc_mod.py | 0 src/{ => extensions}/StdLib/Lib/test/pydocfodder.py | 0 src/{ => extensions}/StdLib/Lib/test/pystone.py | 0 src/{ => extensions}/StdLib/Lib/test/randv2_32.pck | 0 src/{ => extensions}/StdLib/Lib/test/randv2_64.pck | 0 src/{ => extensions}/StdLib/Lib/test/randv3.pck | 0 src/{ => extensions}/StdLib/Lib/test/re_tests.py | 0 src/{ => extensions}/StdLib/Lib/test/regrtest.py | 0 src/{ => extensions}/StdLib/Lib/test/relimport.py | 0 src/{ => extensions}/StdLib/Lib/test/reperf.py | 0 src/{ => extensions}/StdLib/Lib/test/revocation.crl | 0 .../StdLib/Lib/test/sample_doctest.py | 0 .../StdLib/Lib/test/sample_doctest_no_docstrings.py | 0 .../StdLib/Lib/test/sample_doctest_no_doctests.py | 0 .../StdLib/Lib/test/script_helper.py | 0 .../StdLib/Lib/test/selfsigned_pythontestdotnet.pem | 0 src/{ => extensions}/StdLib/Lib/test/seq_tests.py | 0 .../StdLib/Lib/test/sgml_input.html | 0 src/{ => extensions}/StdLib/Lib/test/sha256.pem | 0 .../StdLib/Lib/test/sndhdrdata/README | 0 .../StdLib/Lib/test/sndhdrdata/sndhdr.8svx | Bin .../StdLib/Lib/test/sndhdrdata/sndhdr.aifc | Bin .../StdLib/Lib/test/sndhdrdata/sndhdr.aiff | Bin .../StdLib/Lib/test/sndhdrdata/sndhdr.au | Bin .../StdLib/Lib/test/sndhdrdata/sndhdr.hcom | Bin .../StdLib/Lib/test/sndhdrdata/sndhdr.sndt | Bin .../StdLib/Lib/test/sndhdrdata/sndhdr.voc | Bin .../StdLib/Lib/test/sndhdrdata/sndhdr.wav | Bin src/{ => extensions}/StdLib/Lib/test/sortperf.py | 0 src/{ => extensions}/StdLib/Lib/test/ssl_cert.pem | 0 .../StdLib/Lib/test/ssl_key.passwd.pem | 0 src/{ => extensions}/StdLib/Lib/test/ssl_key.pem | 0 src/{ => extensions}/StdLib/Lib/test/ssl_servers.py | 0 src/{ => extensions}/StdLib/Lib/test/ssltests.py | 0 .../StdLib/Lib/test/string_tests.py | 0 .../StdLib/Lib/test/subprocessdata/fd_status.py | 0 .../StdLib/Lib/test/subprocessdata/input_reader.py | 0 .../StdLib/Lib/test/subprocessdata/qcat.py | 0 .../StdLib/Lib/test/subprocessdata/qgrep.py | 0 .../Lib/test/subprocessdata/sigchild_ignore.py | 0 .../StdLib/Lib/test/support/__init__.py | 0 .../StdLib/Lib/test/talos-2019-0758.pem | 0 .../StdLib/Lib/test/test___all__.py | 0 .../StdLib/Lib/test/test___future__.py | 0 .../StdLib/Lib/test/test__locale.py | 0 .../StdLib/Lib/test/test__opcode.py | 0 .../StdLib/Lib/test/test__osx_support.py | 0 src/{ => extensions}/StdLib/Lib/test/test_abc.py | 0 .../StdLib/Lib/test/test_abstract_numbers.py | 0 src/{ => extensions}/StdLib/Lib/test/test_aifc.py | 0 .../StdLib/Lib/test/test_argparse.py | 0 src/{ => extensions}/StdLib/Lib/test/test_array.py | 0 src/{ => extensions}/StdLib/Lib/test/test_ast.py | 0 .../StdLib/Lib/test/test_asynchat.py | 0 .../StdLib/Lib/test/test_asyncio/__init__.py | 0 .../StdLib/Lib/test/test_asyncio/__main__.py | 0 .../StdLib/Lib/test/test_asyncio/echo.py | 0 .../StdLib/Lib/test/test_asyncio/echo2.py | 0 .../StdLib/Lib/test/test_asyncio/echo3.py | 0 .../StdLib/Lib/test/test_asyncio/keycert3.pem | 0 .../StdLib/Lib/test/test_asyncio/pycacert.pem | 0 .../StdLib/Lib/test/test_asyncio/ssl_cert.pem | 0 .../StdLib/Lib/test/test_asyncio/ssl_key.pem | 0 .../Lib/test/test_asyncio/test_base_events.py | 0 .../StdLib/Lib/test/test_asyncio/test_events.py | 0 .../StdLib/Lib/test/test_asyncio/test_futures.py | 0 .../StdLib/Lib/test/test_asyncio/test_locks.py | 0 .../Lib/test/test_asyncio/test_proactor_events.py | 0 .../StdLib/Lib/test/test_asyncio/test_queues.py | 0 .../Lib/test/test_asyncio/test_selector_events.py | 0 .../StdLib/Lib/test/test_asyncio/test_sslproto.py | 0 .../StdLib/Lib/test/test_asyncio/test_streams.py | 0 .../StdLib/Lib/test/test_asyncio/test_subprocess.py | 0 .../StdLib/Lib/test/test_asyncio/test_tasks.py | 0 .../StdLib/Lib/test/test_asyncio/test_transports.py | 0 .../Lib/test/test_asyncio/test_unix_events.py | 0 .../Lib/test/test_asyncio/test_windows_events.py | 0 .../Lib/test/test_asyncio/test_windows_utils.py | 0 .../StdLib/Lib/test/test_asyncore.py | 0 src/{ => extensions}/StdLib/Lib/test/test_atexit.py | 0 .../StdLib/Lib/test/test_audioop.py | 0 .../StdLib/Lib/test/test_augassign.py | 0 src/{ => extensions}/StdLib/Lib/test/test_base64.py | 0 .../StdLib/Lib/test/test_bigaddrspace.py | 0 src/{ => extensions}/StdLib/Lib/test/test_bigmem.py | 0 .../StdLib/Lib/test/test_binascii.py | 0 src/{ => extensions}/StdLib/Lib/test/test_binhex.py | 0 src/{ => extensions}/StdLib/Lib/test/test_binop.py | 0 src/{ => extensions}/StdLib/Lib/test/test_bisect.py | 0 src/{ => extensions}/StdLib/Lib/test/test_bool.py | 0 src/{ => extensions}/StdLib/Lib/test/test_buffer.py | 0 src/{ => extensions}/StdLib/Lib/test/test_bufio.py | 0 .../StdLib/Lib/test/test_builtin.py | 0 src/{ => extensions}/StdLib/Lib/test/test_bytes.py | 0 src/{ => extensions}/StdLib/Lib/test/test_bz2.py | 0 .../StdLib/Lib/test/test_calendar.py | 0 src/{ => extensions}/StdLib/Lib/test/test_call.py | 0 src/{ => extensions}/StdLib/Lib/test/test_capi.py | 0 src/{ => extensions}/StdLib/Lib/test/test_cgi.py | 0 src/{ => extensions}/StdLib/Lib/test/test_cgitb.py | 0 .../StdLib/Lib/test/test_charmapcodec.py | 0 src/{ => extensions}/StdLib/Lib/test/test_class.py | 0 src/{ => extensions}/StdLib/Lib/test/test_cmath.py | 0 src/{ => extensions}/StdLib/Lib/test/test_cmd.py | 0 .../StdLib/Lib/test/test_cmd_line.py | 0 .../StdLib/Lib/test/test_cmd_line_script.py | 0 src/{ => extensions}/StdLib/Lib/test/test_code.py | 0 .../StdLib/Lib/test/test_code_module.py | 0 .../StdLib/Lib/test/test_codeccallbacks.py | 0 .../StdLib/Lib/test/test_codecencodings_cn.py | 0 .../StdLib/Lib/test/test_codecencodings_hk.py | 0 .../StdLib/Lib/test/test_codecencodings_iso2022.py | 0 .../StdLib/Lib/test/test_codecencodings_jp.py | 0 .../StdLib/Lib/test/test_codecencodings_kr.py | 0 .../StdLib/Lib/test/test_codecencodings_tw.py | 0 .../StdLib/Lib/test/test_codecmaps_cn.py | 0 .../StdLib/Lib/test/test_codecmaps_hk.py | 0 .../StdLib/Lib/test/test_codecmaps_jp.py | 0 .../StdLib/Lib/test/test_codecmaps_kr.py | 0 .../StdLib/Lib/test/test_codecmaps_tw.py | 0 src/{ => extensions}/StdLib/Lib/test/test_codecs.py | 0 src/{ => extensions}/StdLib/Lib/test/test_codeop.py | 0 .../StdLib/Lib/test/test_collections.py | 0 .../StdLib/Lib/test/test_colorsys.py | 0 .../StdLib/Lib/test/test_compare.py | 0 .../StdLib/Lib/test/test_compile.py | 0 .../StdLib/Lib/test/test_compileall.py | 0 .../StdLib/Lib/test/test_complex.py | 0 .../StdLib/Lib/test/test_concurrent_futures.py | 0 .../StdLib/Lib/test/test_configparser.py | 0 .../StdLib/Lib/test/test_contains.py | 0 .../StdLib/Lib/test/test_contextlib.py | 0 src/{ => extensions}/StdLib/Lib/test/test_copy.py | 0 .../StdLib/Lib/test/test_copyreg.py | 0 .../StdLib/Lib/test/test_cprofile.py | 0 .../StdLib/Lib/test/test_crashers.py | 0 src/{ => extensions}/StdLib/Lib/test/test_crypt.py | 0 src/{ => extensions}/StdLib/Lib/test/test_csv.py | 0 src/{ => extensions}/StdLib/Lib/test/test_ctypes.py | 0 src/{ => extensions}/StdLib/Lib/test/test_curses.py | 0 .../StdLib/Lib/test/test_datetime.py | 0 src/{ => extensions}/StdLib/Lib/test/test_dbm.py | 0 .../StdLib/Lib/test/test_dbm_dumb.py | 0 .../StdLib/Lib/test/test_dbm_gnu.py | 0 .../StdLib/Lib/test/test_dbm_ndbm.py | 0 .../StdLib/Lib/test/test_decimal.py | 0 .../StdLib/Lib/test/test_decorators.py | 0 .../StdLib/Lib/test/test_defaultdict.py | 0 src/{ => extensions}/StdLib/Lib/test/test_deque.py | 0 src/{ => extensions}/StdLib/Lib/test/test_descr.py | 0 .../StdLib/Lib/test/test_descrtut.py | 0 .../StdLib/Lib/test/test_devpoll.py | 0 src/{ => extensions}/StdLib/Lib/test/test_dict.py | 0 .../StdLib/Lib/test/test_dictcomps.py | 0 .../StdLib/Lib/test/test_dictviews.py | 0 .../StdLib/Lib/test/test_difflib.py | 0 .../StdLib/Lib/test/test_difflib_expect.html | 0 src/{ => extensions}/StdLib/Lib/test/test_dis.py | 0 .../StdLib/Lib/test/test_distutils.py | 0 .../StdLib/Lib/test/test_doctest.py | 0 .../StdLib/Lib/test/test_doctest.txt | 0 .../StdLib/Lib/test/test_doctest2.py | 0 .../StdLib/Lib/test/test_doctest2.txt | 0 .../StdLib/Lib/test/test_doctest3.txt | 0 .../StdLib/Lib/test/test_doctest4.txt | 0 .../StdLib/Lib/test/test_docxmlrpc.py | 0 .../StdLib/Lib/test/test_dummy_thread.py | 0 .../StdLib/Lib/test/test_dummy_threading.py | 0 .../StdLib/Lib/test/test_dynamic.py | 0 .../StdLib/Lib/test/test_dynamicclassattribute.py | 0 .../StdLib/Lib/test/test_email/__init__.py | 0 .../StdLib/Lib/test/test_email/__main__.py | 0 .../StdLib/Lib/test/test_email/data/PyBanner048.gif | Bin .../StdLib/Lib/test/test_email/data/audiotest.au | Bin .../StdLib/Lib/test/test_email/data/msg_01.txt | 0 .../StdLib/Lib/test/test_email/data/msg_02.txt | 0 .../StdLib/Lib/test/test_email/data/msg_03.txt | 0 .../StdLib/Lib/test/test_email/data/msg_04.txt | 0 .../StdLib/Lib/test/test_email/data/msg_05.txt | 0 .../StdLib/Lib/test/test_email/data/msg_06.txt | 0 .../StdLib/Lib/test/test_email/data/msg_07.txt | 0 .../StdLib/Lib/test/test_email/data/msg_08.txt | 0 .../StdLib/Lib/test/test_email/data/msg_09.txt | 0 .../StdLib/Lib/test/test_email/data/msg_10.txt | 0 .../StdLib/Lib/test/test_email/data/msg_11.txt | 0 .../StdLib/Lib/test/test_email/data/msg_12.txt | 0 .../StdLib/Lib/test/test_email/data/msg_12a.txt | 0 .../StdLib/Lib/test/test_email/data/msg_13.txt | 0 .../StdLib/Lib/test/test_email/data/msg_14.txt | 0 .../StdLib/Lib/test/test_email/data/msg_15.txt | 0 .../StdLib/Lib/test/test_email/data/msg_16.txt | 0 .../StdLib/Lib/test/test_email/data/msg_17.txt | 0 .../StdLib/Lib/test/test_email/data/msg_18.txt | 0 .../StdLib/Lib/test/test_email/data/msg_19.txt | 0 .../StdLib/Lib/test/test_email/data/msg_20.txt | 0 .../StdLib/Lib/test/test_email/data/msg_21.txt | 0 .../StdLib/Lib/test/test_email/data/msg_22.txt | 0 .../StdLib/Lib/test/test_email/data/msg_23.txt | 0 .../StdLib/Lib/test/test_email/data/msg_24.txt | 0 .../StdLib/Lib/test/test_email/data/msg_25.txt | 0 .../StdLib/Lib/test/test_email/data/msg_26.txt | 0 .../StdLib/Lib/test/test_email/data/msg_27.txt | 0 .../StdLib/Lib/test/test_email/data/msg_28.txt | 0 .../StdLib/Lib/test/test_email/data/msg_29.txt | 0 .../StdLib/Lib/test/test_email/data/msg_30.txt | 0 .../StdLib/Lib/test/test_email/data/msg_31.txt | 0 .../StdLib/Lib/test/test_email/data/msg_32.txt | 0 .../StdLib/Lib/test/test_email/data/msg_33.txt | 0 .../StdLib/Lib/test/test_email/data/msg_34.txt | 0 .../StdLib/Lib/test/test_email/data/msg_35.txt | 0 .../StdLib/Lib/test/test_email/data/msg_36.txt | 0 .../StdLib/Lib/test/test_email/data/msg_37.txt | 0 .../StdLib/Lib/test/test_email/data/msg_38.txt | 0 .../StdLib/Lib/test/test_email/data/msg_39.txt | 0 .../StdLib/Lib/test/test_email/data/msg_40.txt | 0 .../StdLib/Lib/test/test_email/data/msg_41.txt | 0 .../StdLib/Lib/test/test_email/data/msg_42.txt | 0 .../StdLib/Lib/test/test_email/data/msg_43.txt | 0 .../StdLib/Lib/test/test_email/data/msg_44.txt | 0 .../StdLib/Lib/test/test_email/data/msg_45.txt | 0 .../StdLib/Lib/test/test_email/data/msg_46.txt | 0 .../Lib/test/test_email/test__encoded_words.py | 0 .../test/test_email/test__header_value_parser.py | 0 .../StdLib/Lib/test/test_email/test_asian_codecs.py | 0 .../Lib/test/test_email/test_contentmanager.py | 0 .../Lib/test/test_email/test_defect_handling.py | 0 .../StdLib/Lib/test/test_email/test_email.py | 0 .../StdLib/Lib/test/test_email/test_generator.py | 0 .../Lib/test/test_email/test_headerregistry.py | 0 .../StdLib/Lib/test/test_email/test_inversion.py | 0 .../StdLib/Lib/test/test_email/test_message.py | 0 .../StdLib/Lib/test/test_email/test_parser.py | 0 .../StdLib/Lib/test/test_email/test_pickleable.py | 0 .../StdLib/Lib/test/test_email/test_policy.py | 0 .../StdLib/Lib/test/test_email/test_utils.py | 0 .../StdLib/Lib/test/test_email/torture_test.py | 0 .../StdLib/Lib/test/test_ensurepip.py | 0 src/{ => extensions}/StdLib/Lib/test/test_enum.py | 0 .../StdLib/Lib/test/test_enumerate.py | 0 src/{ => extensions}/StdLib/Lib/test/test_eof.py | 0 src/{ => extensions}/StdLib/Lib/test/test_epoll.py | 0 src/{ => extensions}/StdLib/Lib/test/test_errno.py | 0 .../StdLib/Lib/test/test_exception_variations.py | 0 .../StdLib/Lib/test/test_exceptions.py | 0 .../StdLib/Lib/test/test_extcall.py | 0 .../StdLib/Lib/test/test_faulthandler.py | 0 src/{ => extensions}/StdLib/Lib/test/test_fcntl.py | 0 src/{ => extensions}/StdLib/Lib/test/test_file.py | 0 .../StdLib/Lib/test/test_file_eintr.py | 0 .../StdLib/Lib/test/test_filecmp.py | 0 .../StdLib/Lib/test/test_fileinput.py | 0 src/{ => extensions}/StdLib/Lib/test/test_fileio.py | 0 .../StdLib/Lib/test/test_finalization.py | 0 src/{ => extensions}/StdLib/Lib/test/test_float.py | 0 src/{ => extensions}/StdLib/Lib/test/test_flufl.py | 0 .../StdLib/Lib/test/test_fnmatch.py | 0 src/{ => extensions}/StdLib/Lib/test/test_fork1.py | 0 src/{ => extensions}/StdLib/Lib/test/test_format.py | 0 .../StdLib/Lib/test/test_fractions.py | 0 src/{ => extensions}/StdLib/Lib/test/test_frame.py | 0 .../StdLib/Lib/test/test_fstring.py | 0 src/{ => extensions}/StdLib/Lib/test/test_ftplib.py | 0 .../StdLib/Lib/test/test_funcattrs.py | 0 .../StdLib/Lib/test/test_functools.py | 0 src/{ => extensions}/StdLib/Lib/test/test_future.py | 0 .../StdLib/Lib/test/test_future3.py | 0 .../StdLib/Lib/test/test_future4.py | 0 .../StdLib/Lib/test/test_future5.py | 0 src/{ => extensions}/StdLib/Lib/test/test_gc.py | 0 src/{ => extensions}/StdLib/Lib/test/test_gdb.py | 0 .../StdLib/Lib/test/test_generators.py | 0 .../StdLib/Lib/test/test_genericpath.py | 0 .../StdLib/Lib/test/test_genexps.py | 0 .../StdLib/Lib/test/test_getargs2.py | 0 src/{ => extensions}/StdLib/Lib/test/test_getopt.py | 0 .../StdLib/Lib/test/test_getpass.py | 0 .../StdLib/Lib/test/test_gettext.py | 0 src/{ => extensions}/StdLib/Lib/test/test_glob.py | 0 src/{ => extensions}/StdLib/Lib/test/test_global.py | 0 .../StdLib/Lib/test/test_grammar.py | 0 src/{ => extensions}/StdLib/Lib/test/test_grp.py | 0 src/{ => extensions}/StdLib/Lib/test/test_gzip.py | 0 src/{ => extensions}/StdLib/Lib/test/test_hash.py | 0 .../StdLib/Lib/test/test_hashlib.py | 0 src/{ => extensions}/StdLib/Lib/test/test_heapq.py | 0 src/{ => extensions}/StdLib/Lib/test/test_hmac.py | 0 src/{ => extensions}/StdLib/Lib/test/test_html.py | 0 .../StdLib/Lib/test/test_htmlparser.py | 0 .../StdLib/Lib/test/test_http_cookiejar.py | 0 .../StdLib/Lib/test/test_http_cookies.py | 0 .../StdLib/Lib/test/test_httplib.py | 0 .../StdLib/Lib/test/test_httpservers.py | 0 src/{ => extensions}/StdLib/Lib/test/test_idle.py | 0 .../StdLib/Lib/test/test_imaplib.py | 0 src/{ => extensions}/StdLib/Lib/test/test_imghdr.py | 0 src/{ => extensions}/StdLib/Lib/test/test_imp.py | 0 src/{ => extensions}/StdLib/Lib/test/test_import.py | 0 .../StdLib/Lib/test/test_importlib/__init__.py | 0 .../StdLib/Lib/test/test_importlib/__main__.py | 0 .../StdLib/Lib/test/test_importlib/abc.py | 0 .../Lib/test/test_importlib/builtin/__init__.py | 0 .../Lib/test/test_importlib/builtin/__main__.py | 0 .../Lib/test/test_importlib/builtin/test_finder.py | 0 .../Lib/test/test_importlib/builtin/test_loader.py | 0 .../StdLib/Lib/test/test_importlib/builtin/util.py | 0 .../Lib/test/test_importlib/extension/__init__.py | 0 .../Lib/test/test_importlib/extension/__main__.py | 0 .../extension/test_case_sensitivity.py | 0 .../test/test_importlib/extension/test_finder.py | 0 .../test/test_importlib/extension/test_loader.py | 0 .../test/test_importlib/extension/test_path_hook.py | 0 .../Lib/test/test_importlib/extension/util.py | 0 .../Lib/test/test_importlib/frozen/__init__.py | 0 .../Lib/test/test_importlib/frozen/__main__.py | 0 .../Lib/test/test_importlib/frozen/test_finder.py | 0 .../Lib/test/test_importlib/frozen/test_loader.py | 0 .../Lib/test/test_importlib/import_/__init__.py | 0 .../Lib/test/test_importlib/import_/__main__.py | 0 .../test/test_importlib/import_/test___loader__.py | 0 .../test/test_importlib/import_/test___package__.py | 0 .../Lib/test/test_importlib/import_/test_api.py | 0 .../Lib/test/test_importlib/import_/test_caching.py | 0 .../test/test_importlib/import_/test_fromlist.py | 0 .../test/test_importlib/import_/test_meta_path.py | 0 .../test/test_importlib/import_/test_packages.py | 0 .../Lib/test/test_importlib/import_/test_path.py | 0 .../test_importlib/import_/test_relative_imports.py | 0 .../StdLib/Lib/test/test_importlib/import_/util.py | 0 .../namespace_pkgs/both_portions/foo/one.py | 0 .../namespace_pkgs/both_portions/foo/two.py | 0 .../namespace_pkgs/missing_directory.zip | Bin .../module_and_namespace_package/a_test.py | 0 .../module_and_namespace_package/a_test/empty | 0 .../namespace_pkgs/nested_portion1.zip | Bin .../not_a_namespace_pkg/foo/__init__.py | 0 .../namespace_pkgs/not_a_namespace_pkg/foo/one.py | 0 .../namespace_pkgs/portion1/foo/one.py | 0 .../namespace_pkgs/portion2/foo/two.py | 0 .../namespace_pkgs/project1/parent/child/one.py | 0 .../namespace_pkgs/project2/parent/child/two.py | 0 .../namespace_pkgs/project3/parent/child/three.py | 0 .../namespace_pkgs/top_level_portion1.zip | Bin .../StdLib/Lib/test/test_importlib/regrtest.py | 0 .../Lib/test/test_importlib/source/__init__.py | 0 .../Lib/test/test_importlib/source/__main__.py | 0 .../test_importlib/source/test_case_sensitivity.py | 0 .../test/test_importlib/source/test_file_loader.py | 0 .../Lib/test/test_importlib/source/test_finder.py | 0 .../test/test_importlib/source/test_path_hook.py | 0 .../test_importlib/source/test_source_encoding.py | 0 .../StdLib/Lib/test/test_importlib/source/util.py | 0 .../StdLib/Lib/test/test_importlib/test_abc.py | 0 .../StdLib/Lib/test/test_importlib/test_api.py | 0 .../StdLib/Lib/test/test_importlib/test_locks.py | 0 .../Lib/test/test_importlib/test_namespace_pkgs.py | 0 .../StdLib/Lib/test/test_importlib/test_spec.py | 0 .../StdLib/Lib/test/test_importlib/test_util.py | 0 .../StdLib/Lib/test/test_importlib/test_windows.py | 0 .../StdLib/Lib/test/test_importlib/util.py | 0 src/{ => extensions}/StdLib/Lib/test/test_index.py | 0 .../StdLib/Lib/test/test_inspect.py | 0 src/{ => extensions}/StdLib/Lib/test/test_int.py | 0 .../StdLib/Lib/test/test_int_literal.py | 0 src/{ => extensions}/StdLib/Lib/test/test_io.py | 0 src/{ => extensions}/StdLib/Lib/test/test_ioctl.py | 0 .../StdLib/Lib/test/test_ipaddress.py | 0 .../StdLib/Lib/test/test_isinstance.py | 0 src/{ => extensions}/StdLib/Lib/test/test_iter.py | 0 .../StdLib/Lib/test/test_iterlen.py | 0 .../StdLib/Lib/test/test_itertools.py | 0 .../StdLib/Lib/test/test_json/__init__.py | 0 .../StdLib/Lib/test/test_json/__main__.py | 0 .../StdLib/Lib/test/test_json/test_decode.py | 0 .../StdLib/Lib/test/test_json/test_default.py | 0 .../StdLib/Lib/test/test_json/test_dump.py | 0 .../test/test_json/test_encode_basestring_ascii.py | 0 .../StdLib/Lib/test/test_json/test_enum.py | 0 .../StdLib/Lib/test/test_json/test_fail.py | 0 .../StdLib/Lib/test/test_json/test_float.py | 0 .../StdLib/Lib/test/test_json/test_indent.py | 0 .../StdLib/Lib/test/test_json/test_pass1.py | 0 .../StdLib/Lib/test/test_json/test_pass2.py | 0 .../StdLib/Lib/test/test_json/test_pass3.py | 0 .../StdLib/Lib/test/test_json/test_recursion.py | 0 .../StdLib/Lib/test/test_json/test_scanstring.py | 0 .../StdLib/Lib/test/test_json/test_separators.py | 0 .../StdLib/Lib/test/test_json/test_speedups.py | 0 .../StdLib/Lib/test/test_json/test_tool.py | 0 .../StdLib/Lib/test/test_json/test_unicode.py | 0 .../StdLib/Lib/test/test_keyword.py | 0 .../StdLib/Lib/test/test_keywordonlyarg.py | 0 src/{ => extensions}/StdLib/Lib/test/test_kqueue.py | 0 .../StdLib/Lib/test/test_largefile.py | 0 .../StdLib/Lib/test/test_lib2to3.py | 0 .../StdLib/Lib/test/test_linecache.py | 0 src/{ => extensions}/StdLib/Lib/test/test_list.py | 0 .../StdLib/Lib/test/test_listcomps.py | 0 src/{ => extensions}/StdLib/Lib/test/test_locale.py | 0 .../StdLib/Lib/test/test_logging.py | 0 src/{ => extensions}/StdLib/Lib/test/test_long.py | 0 .../StdLib/Lib/test/test_longexp.py | 0 src/{ => extensions}/StdLib/Lib/test/test_lzma.py | 0 .../StdLib/Lib/test/test_macpath.py | 0 .../StdLib/Lib/test/test_macurl2path.py | 0 .../StdLib/Lib/test/test_mailbox.py | 0 .../StdLib/Lib/test/test_mailcap.py | 0 .../StdLib/Lib/test/test_marshal.py | 0 src/{ => extensions}/StdLib/Lib/test/test_math.py | 0 .../StdLib/Lib/test/test_memoryio.py | 0 .../StdLib/Lib/test/test_memoryview.py | 0 .../StdLib/Lib/test/test_metaclass.py | 0 .../StdLib/Lib/test/test_mimetypes.py | 0 .../StdLib/Lib/test/test_minidom.py | 0 src/{ => extensions}/StdLib/Lib/test/test_mmap.py | 0 src/{ => extensions}/StdLib/Lib/test/test_module.py | 0 .../StdLib/Lib/test/test_modulefinder.py | 0 src/{ => extensions}/StdLib/Lib/test/test_msilib.py | 0 .../StdLib/Lib/test/test_multibytecodec.py | 0 .../StdLib/Lib/test/test_multiprocessing_fork.py | 0 .../Lib/test/test_multiprocessing_forkserver.py | 0 .../Lib/test/test_multiprocessing_main_handling.py | 0 .../StdLib/Lib/test/test_multiprocessing_spawn.py | 0 src/{ => extensions}/StdLib/Lib/test/test_netrc.py | 0 src/{ => extensions}/StdLib/Lib/test/test_nis.py | 0 .../StdLib/Lib/test/test_nntplib.py | 0 .../StdLib/Lib/test/test_normalization.py | 0 src/{ => extensions}/StdLib/Lib/test/test_ntpath.py | 0 .../StdLib/Lib/test/test_numeric_tower.py | 0 .../StdLib/Lib/test/test_opcodes.py | 0 .../StdLib/Lib/test/test_openpty.py | 0 .../StdLib/Lib/test/test_operator.py | 0 .../StdLib/Lib/test/test_optparse.py | 0 .../StdLib/Lib/test/test_ordered_dict.py | 0 src/{ => extensions}/StdLib/Lib/test/test_os.py | 0 .../StdLib/Lib/test/test_ossaudiodev.py | 0 .../StdLib/Lib/test/test_osx_env.py | 0 src/{ => extensions}/StdLib/Lib/test/test_parser.py | 0 .../StdLib/Lib/test/test_pathlib.py | 0 src/{ => extensions}/StdLib/Lib/test/test_pdb.py | 0 .../StdLib/Lib/test/test_peepholer.py | 0 src/{ => extensions}/StdLib/Lib/test/test_pep247.py | 0 src/{ => extensions}/StdLib/Lib/test/test_pep277.py | 0 src/{ => extensions}/StdLib/Lib/test/test_pep292.py | 0 .../StdLib/Lib/test/test_pep3120.py | 0 .../StdLib/Lib/test/test_pep3131.py | 0 .../StdLib/Lib/test/test_pep3151.py | 0 src/{ => extensions}/StdLib/Lib/test/test_pep352.py | 0 src/{ => extensions}/StdLib/Lib/test/test_pep380.py | 0 src/{ => extensions}/StdLib/Lib/test/test_pep479.py | 0 src/{ => extensions}/StdLib/Lib/test/test_pickle.py | 0 .../StdLib/Lib/test/test_pickletools.py | 0 src/{ => extensions}/StdLib/Lib/test/test_pipes.py | 0 src/{ => extensions}/StdLib/Lib/test/test_pkg.py | 0 .../StdLib/Lib/test/test_pkgimport.py | 0 .../StdLib/Lib/test/test_pkgutil.py | 0 .../StdLib/Lib/test/test_platform.py | 0 .../StdLib/Lib/test/test_plistlib.py | 0 src/{ => extensions}/StdLib/Lib/test/test_poll.py | 0 src/{ => extensions}/StdLib/Lib/test/test_popen.py | 0 src/{ => extensions}/StdLib/Lib/test/test_poplib.py | 0 src/{ => extensions}/StdLib/Lib/test/test_posix.py | 0 .../StdLib/Lib/test/test_posixpath.py | 0 src/{ => extensions}/StdLib/Lib/test/test_pow.py | 0 src/{ => extensions}/StdLib/Lib/test/test_pprint.py | 0 src/{ => extensions}/StdLib/Lib/test/test_print.py | 0 .../StdLib/Lib/test/test_profile.py | 0 .../StdLib/Lib/test/test_property.py | 0 src/{ => extensions}/StdLib/Lib/test/test_pstats.py | 0 src/{ => extensions}/StdLib/Lib/test/test_pty.py | 0 .../StdLib/Lib/test/test_pulldom.py | 0 src/{ => extensions}/StdLib/Lib/test/test_pwd.py | 0 .../StdLib/Lib/test/test_py_compile.py | 0 src/{ => extensions}/StdLib/Lib/test/test_pyclbr.py | 0 src/{ => extensions}/StdLib/Lib/test/test_pydoc.py | 0 .../StdLib/Lib/test/test_pyexpat.py | 0 src/{ => extensions}/StdLib/Lib/test/test_queue.py | 0 src/{ => extensions}/StdLib/Lib/test/test_quopri.py | 0 src/{ => extensions}/StdLib/Lib/test/test_raise.py | 0 src/{ => extensions}/StdLib/Lib/test/test_random.py | 0 src/{ => extensions}/StdLib/Lib/test/test_range.py | 0 src/{ => extensions}/StdLib/Lib/test/test_re.py | 0 .../StdLib/Lib/test/test_readline.py | 0 .../StdLib/Lib/test/test_regrtest.py | 0 .../StdLib/Lib/test/test_reprlib.py | 0 .../StdLib/Lib/test/test_resource.py | 0 .../StdLib/Lib/test/test_richcmp.py | 0 .../StdLib/Lib/test/test_rlcompleter.py | 0 .../StdLib/Lib/test/test_robotparser.py | 0 src/{ => extensions}/StdLib/Lib/test/test_runpy.py | 0 src/{ => extensions}/StdLib/Lib/test/test_sax.py | 0 src/{ => extensions}/StdLib/Lib/test/test_sched.py | 0 src/{ => extensions}/StdLib/Lib/test/test_scope.py | 0 .../StdLib/Lib/test/test_script_helper.py | 0 src/{ => extensions}/StdLib/Lib/test/test_select.py | 0 .../StdLib/Lib/test/test_selectors.py | 0 src/{ => extensions}/StdLib/Lib/test/test_set.py | 0 .../StdLib/Lib/test/test_setcomps.py | 0 src/{ => extensions}/StdLib/Lib/test/test_shelve.py | 0 src/{ => extensions}/StdLib/Lib/test/test_shlex.py | 0 src/{ => extensions}/StdLib/Lib/test/test_shutil.py | 0 src/{ => extensions}/StdLib/Lib/test/test_signal.py | 0 src/{ => extensions}/StdLib/Lib/test/test_site.py | 0 src/{ => extensions}/StdLib/Lib/test/test_slice.py | 0 src/{ => extensions}/StdLib/Lib/test/test_smtpd.py | 0 .../StdLib/Lib/test/test_smtplib.py | 0 .../StdLib/Lib/test/test_smtpnet.py | 0 src/{ => extensions}/StdLib/Lib/test/test_sndhdr.py | 0 src/{ => extensions}/StdLib/Lib/test/test_socket.py | 0 .../StdLib/Lib/test/test_socketserver.py | 0 src/{ => extensions}/StdLib/Lib/test/test_sort.py | 0 .../StdLib/Lib/test/test_source_encoding.py | 0 src/{ => extensions}/StdLib/Lib/test/test_spwd.py | 0 src/{ => extensions}/StdLib/Lib/test/test_sqlite.py | 0 src/{ => extensions}/StdLib/Lib/test/test_ssl.py | 0 .../StdLib/Lib/test/test_startfile.py | 0 src/{ => extensions}/StdLib/Lib/test/test_stat.py | 0 .../StdLib/Lib/test/test_statistics.py | 0 .../StdLib/Lib/test/test_strftime.py | 0 src/{ => extensions}/StdLib/Lib/test/test_string.py | 0 .../StdLib/Lib/test/test_stringprep.py | 0 src/{ => extensions}/StdLib/Lib/test/test_strlit.py | 0 .../StdLib/Lib/test/test_strptime.py | 0 src/{ => extensions}/StdLib/Lib/test/test_strtod.py | 0 src/{ => extensions}/StdLib/Lib/test/test_struct.py | 0 .../StdLib/Lib/test/test_structmembers.py | 0 .../StdLib/Lib/test/test_structseq.py | 0 .../StdLib/Lib/test/test_subprocess.py | 0 src/{ => extensions}/StdLib/Lib/test/test_sunau.py | 0 src/{ => extensions}/StdLib/Lib/test/test_sundry.py | 0 src/{ => extensions}/StdLib/Lib/test/test_super.py | 0 .../StdLib/Lib/test/test_support.py | 0 .../StdLib/Lib/test/test_symtable.py | 0 src/{ => extensions}/StdLib/Lib/test/test_syntax.py | 0 src/{ => extensions}/StdLib/Lib/test/test_sys.py | 0 .../StdLib/Lib/test/test_sys_setprofile.py | 0 .../StdLib/Lib/test/test_sys_settrace.py | 0 .../StdLib/Lib/test/test_sysconfig.py | 0 src/{ => extensions}/StdLib/Lib/test/test_syslog.py | 0 .../StdLib/Lib/test/test_tarfile.py | 0 src/{ => extensions}/StdLib/Lib/test/test_tcl.py | 0 .../StdLib/Lib/test/test_telnetlib.py | 0 .../StdLib/Lib/test/test_tempfile.py | 0 .../StdLib/Lib/test/test_textwrap.py | 0 src/{ => extensions}/StdLib/Lib/test/test_thread.py | 0 .../StdLib/Lib/test/test_threaded_import.py | 0 .../StdLib/Lib/test/test_threadedtempfile.py | 0 .../StdLib/Lib/test/test_threading.py | 0 .../StdLib/Lib/test/test_threading_local.py | 0 .../StdLib/Lib/test/test_threadsignals.py | 0 src/{ => extensions}/StdLib/Lib/test/test_time.py | 0 src/{ => extensions}/StdLib/Lib/test/test_timeit.py | 0 .../StdLib/Lib/test/test_timeout.py | 0 src/{ => extensions}/StdLib/Lib/test/test_tk.py | 0 .../StdLib/Lib/test/test_tokenize.py | 0 .../StdLib/Lib/test/test_tools/__init__.py | 0 .../StdLib/Lib/test/test_tools/__main__.py | 0 .../StdLib/Lib/test/test_tools/test_gprof2html.py | 0 .../StdLib/Lib/test/test_tools/test_md5sum.py | 0 .../StdLib/Lib/test/test_tools/test_pdeps.py | 0 .../StdLib/Lib/test/test_tools/test_pindent.py | 0 .../StdLib/Lib/test/test_tools/test_reindent.py | 0 .../StdLib/Lib/test/test_tools/test_sundry.py | 0 .../StdLib/Lib/test/test_tools/test_unparse.py | 0 src/{ => extensions}/StdLib/Lib/test/test_trace.py | 0 .../StdLib/Lib/test/test_traceback.py | 0 .../StdLib/Lib/test/test_tracemalloc.py | 0 .../StdLib/Lib/test/test_ttk_guionly.py | 0 .../StdLib/Lib/test/test_ttk_textonly.py | 0 src/{ => extensions}/StdLib/Lib/test/test_tuple.py | 0 .../StdLib/Lib/test/test_typechecks.py | 0 src/{ => extensions}/StdLib/Lib/test/test_types.py | 0 src/{ => extensions}/StdLib/Lib/test/test_typing.py | 0 src/{ => extensions}/StdLib/Lib/test/test_ucn.py | 0 src/{ => extensions}/StdLib/Lib/test/test_unary.py | 0 .../StdLib/Lib/test/test_unicode.py | 0 .../StdLib/Lib/test/test_unicode_file.py | 0 .../StdLib/Lib/test/test_unicodedata.py | 0 .../StdLib/Lib/test/test_unittest.py | 0 .../StdLib/Lib/test/test_univnewlines.py | 0 src/{ => extensions}/StdLib/Lib/test/test_unpack.py | 0 .../StdLib/Lib/test/test_unpack_ex.py | 0 src/{ => extensions}/StdLib/Lib/test/test_urllib.py | 0 .../StdLib/Lib/test/test_urllib2.py | 0 .../StdLib/Lib/test/test_urllib2_localnet.py | 0 .../StdLib/Lib/test/test_urllib2net.py | 0 .../StdLib/Lib/test/test_urllib_response.py | 0 .../StdLib/Lib/test/test_urllibnet.py | 0 .../StdLib/Lib/test/test_urlparse.py | 0 .../StdLib/Lib/test/test_userdict.py | 0 .../StdLib/Lib/test/test_userlist.py | 0 .../StdLib/Lib/test/test_userstring.py | 0 .../StdLib/Lib/test/test_utf8_mode.py | 0 src/{ => extensions}/StdLib/Lib/test/test_uu.py | 0 src/{ => extensions}/StdLib/Lib/test/test_uuid.py | 0 src/{ => extensions}/StdLib/Lib/test/test_venv.py | 0 src/{ => extensions}/StdLib/Lib/test/test_wait3.py | 0 src/{ => extensions}/StdLib/Lib/test/test_wait4.py | 0 .../StdLib/Lib/test/test_warnings.py | 0 src/{ => extensions}/StdLib/Lib/test/test_wave.py | 0 .../StdLib/Lib/test/test_weakref.py | 0 .../StdLib/Lib/test/test_weakset.py | 0 .../StdLib/Lib/test/test_webbrowser.py | 0 src/{ => extensions}/StdLib/Lib/test/test_winreg.py | 0 .../StdLib/Lib/test/test_winsound.py | 0 src/{ => extensions}/StdLib/Lib/test/test_with.py | 0 .../StdLib/Lib/test/test_wsgiref.py | 0 src/{ => extensions}/StdLib/Lib/test/test_xdrlib.py | 0 .../StdLib/Lib/test/test_xml_dom_minicompat.py | 0 .../StdLib/Lib/test/test_xml_etree.py | 0 .../StdLib/Lib/test/test_xml_etree_c.py | 0 src/{ => extensions}/StdLib/Lib/test/test_xmlrpc.py | 0 .../StdLib/Lib/test/test_xmlrpc_net.py | 0 .../StdLib/Lib/test/test_zipfile.py | 0 .../StdLib/Lib/test/test_zipfile64.py | 0 .../StdLib/Lib/test/test_zipimport.py | 0 .../StdLib/Lib/test/test_zipimport_support.py | 0 src/{ => extensions}/StdLib/Lib/test/test_zlib.py | 0 src/{ => extensions}/StdLib/Lib/test/testcodec.py | 0 src/{ => extensions}/StdLib/Lib/test/testtar.tar | Bin .../StdLib/Lib/test/tf_inherit_check.py | 0 .../StdLib/Lib/test/threaded_import_hangers.py | 0 .../StdLib/Lib/test/time_hashlib.py | 0 ..._tests-latin1-coding-cookie-and-utf8-bom-sig.txt | 0 ...tests-no-coding-cookie-and-utf8-bom-sig-only.txt | 0 ...tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt | 0 ...ze_tests-utf8-coding-cookie-and-utf8-bom-sig.txt | 0 .../StdLib/Lib/test/tokenize_tests.txt | 0 .../StdLib/Lib/test/tracedmodules/__init__.py | 0 .../StdLib/Lib/test/tracedmodules/testmod.py | 0 .../StdLib/Lib/test/warning_tests.py | 0 .../StdLib/Lib/test/win_console_handler.py | 0 .../StdLib/Lib/test/xmltestdata/simple-ns.xml | 0 .../StdLib/Lib/test/xmltestdata/simple.xml | 0 .../StdLib/Lib/test/xmltestdata/test.xml | 0 .../StdLib/Lib/test/xmltestdata/test.xml.out | 0 src/{ => extensions}/StdLib/Lib/test/xmltests.py | 0 .../StdLib/Lib/test/zip_cp437_header.zip | Bin src/{ => extensions}/StdLib/Lib/test/zipdir.zip | Bin src/{ => extensions}/StdLib/Lib/textwrap.py | 0 src/{ => extensions}/StdLib/Lib/this.py | 0 src/{ => extensions}/StdLib/Lib/threading.py | 0 src/{ => extensions}/StdLib/Lib/timeit.py | 0 src/{ => extensions}/StdLib/Lib/tkinter/__init__.py | 0 src/{ => extensions}/StdLib/Lib/tkinter/__main__.py | 0 src/{ => extensions}/StdLib/Lib/tkinter/_fix.py | 0 .../StdLib/Lib/tkinter/colorchooser.py | 0 .../StdLib/Lib/tkinter/commondialog.py | 0 .../StdLib/Lib/tkinter/constants.py | 0 src/{ => extensions}/StdLib/Lib/tkinter/dialog.py | 0 src/{ => extensions}/StdLib/Lib/tkinter/dnd.py | 0 .../StdLib/Lib/tkinter/filedialog.py | 0 src/{ => extensions}/StdLib/Lib/tkinter/font.py | 0 .../StdLib/Lib/tkinter/messagebox.py | 0 .../StdLib/Lib/tkinter/scrolledtext.py | 0 .../StdLib/Lib/tkinter/simpledialog.py | 0 src/{ => extensions}/StdLib/Lib/tkinter/test/README | 0 .../StdLib/Lib/tkinter/test/__init__.py | 0 .../StdLib/Lib/tkinter/test/runtktests.py | 0 .../StdLib/Lib/tkinter/test/support.py | 0 .../Lib/tkinter/test/test_tkinter/__init__.py | 0 .../Lib/tkinter/test/test_tkinter/test_font.py | 0 .../test/test_tkinter/test_geometry_managers.py | 0 .../Lib/tkinter/test/test_tkinter/test_images.py | 0 .../Lib/tkinter/test/test_tkinter/test_loadtk.py | 0 .../Lib/tkinter/test/test_tkinter/test_misc.py | 0 .../Lib/tkinter/test/test_tkinter/test_text.py | 0 .../Lib/tkinter/test/test_tkinter/test_variables.py | 0 .../Lib/tkinter/test/test_tkinter/test_widgets.py | 0 .../StdLib/Lib/tkinter/test/test_ttk/__init__.py | 0 .../Lib/tkinter/test/test_ttk/test_extensions.py | 0 .../Lib/tkinter/test/test_ttk/test_functions.py | 0 .../StdLib/Lib/tkinter/test/test_ttk/test_style.py | 0 .../Lib/tkinter/test/test_ttk/test_widgets.py | 0 .../StdLib/Lib/tkinter/test/widget_tests.py | 0 src/{ => extensions}/StdLib/Lib/tkinter/tix.py | 0 src/{ => extensions}/StdLib/Lib/tkinter/ttk.py | 0 src/{ => extensions}/StdLib/Lib/token.py | 0 src/{ => extensions}/StdLib/Lib/tokenize.py | 0 src/{ => extensions}/StdLib/Lib/trace.py | 0 src/{ => extensions}/StdLib/Lib/traceback.py | 0 src/{ => extensions}/StdLib/Lib/tracemalloc.py | 0 src/{ => extensions}/StdLib/Lib/tty.py | 0 src/{ => extensions}/StdLib/Lib/turtle.py | 0 .../StdLib/Lib/turtledemo/__init__.py | 0 .../StdLib/Lib/turtledemo/__main__.py | 0 .../StdLib/Lib/turtledemo/bytedesign.py | 0 src/{ => extensions}/StdLib/Lib/turtledemo/chaos.py | 0 src/{ => extensions}/StdLib/Lib/turtledemo/clock.py | 0 .../StdLib/Lib/turtledemo/colormixer.py | 0 .../StdLib/Lib/turtledemo/forest.py | 0 .../StdLib/Lib/turtledemo/fractalcurves.py | 0 .../StdLib/Lib/turtledemo/lindenmayer.py | 0 .../StdLib/Lib/turtledemo/minimal_hanoi.py | 0 src/{ => extensions}/StdLib/Lib/turtledemo/nim.py | 0 src/{ => extensions}/StdLib/Lib/turtledemo/paint.py | 0 src/{ => extensions}/StdLib/Lib/turtledemo/peace.py | 0 .../StdLib/Lib/turtledemo/penrose.py | 0 .../StdLib/Lib/turtledemo/planet_and_moon.py | 0 .../StdLib/Lib/turtledemo/round_dance.py | 0 src/{ => extensions}/StdLib/Lib/turtledemo/tree.py | 0 .../StdLib/Lib/turtledemo/turtle.cfg | 0 .../StdLib/Lib/turtledemo/two_canvases.py | 0 .../StdLib/Lib/turtledemo/wikipedia.py | 0 .../StdLib/Lib/turtledemo/yinyang.py | 0 src/{ => extensions}/StdLib/Lib/types.py | 0 src/{ => extensions}/StdLib/Lib/typing.py | 0 .../StdLib/Lib/unittest/__init__.py | 0 .../StdLib/Lib/unittest/__main__.py | 0 src/{ => extensions}/StdLib/Lib/unittest/case.py | 0 src/{ => extensions}/StdLib/Lib/unittest/loader.py | 0 src/{ => extensions}/StdLib/Lib/unittest/main.py | 0 src/{ => extensions}/StdLib/Lib/unittest/mock.py | 0 src/{ => extensions}/StdLib/Lib/unittest/result.py | 0 src/{ => extensions}/StdLib/Lib/unittest/runner.py | 0 src/{ => extensions}/StdLib/Lib/unittest/signals.py | 0 src/{ => extensions}/StdLib/Lib/unittest/suite.py | 0 .../StdLib/Lib/unittest/test/__init__.py | 0 .../StdLib/Lib/unittest/test/__main__.py | 0 .../StdLib/Lib/unittest/test/_test_warnings.py | 0 .../StdLib/Lib/unittest/test/dummy.py | 0 .../StdLib/Lib/unittest/test/support.py | 0 .../StdLib/Lib/unittest/test/test_assertions.py | 0 .../StdLib/Lib/unittest/test/test_break.py | 0 .../StdLib/Lib/unittest/test/test_case.py | 0 .../StdLib/Lib/unittest/test/test_discovery.py | 0 .../Lib/unittest/test/test_functiontestcase.py | 0 .../StdLib/Lib/unittest/test/test_loader.py | 0 .../StdLib/Lib/unittest/test/test_program.py | 0 .../StdLib/Lib/unittest/test/test_result.py | 0 .../StdLib/Lib/unittest/test/test_runner.py | 0 .../StdLib/Lib/unittest/test/test_setups.py | 0 .../StdLib/Lib/unittest/test/test_skipping.py | 0 .../StdLib/Lib/unittest/test/test_suite.py | 0 .../StdLib/Lib/unittest/test/testmock/__init__.py | 0 .../StdLib/Lib/unittest/test/testmock/__main__.py | 0 .../StdLib/Lib/unittest/test/testmock/support.py | 0 .../Lib/unittest/test/testmock/testcallable.py | 0 .../Lib/unittest/test/testmock/testhelpers.py | 0 .../Lib/unittest/test/testmock/testmagicmethods.py | 0 .../StdLib/Lib/unittest/test/testmock/testmock.py | 0 .../StdLib/Lib/unittest/test/testmock/testpatch.py | 0 .../Lib/unittest/test/testmock/testsentinel.py | 0 .../StdLib/Lib/unittest/test/testmock/testwith.py | 0 src/{ => extensions}/StdLib/Lib/unittest/util.py | 0 src/{ => extensions}/StdLib/Lib/urllib/__init__.py | 0 src/{ => extensions}/StdLib/Lib/urllib/error.py | 0 src/{ => extensions}/StdLib/Lib/urllib/parse.py | 0 src/{ => extensions}/StdLib/Lib/urllib/request.py | 0 src/{ => extensions}/StdLib/Lib/urllib/response.py | 0 .../StdLib/Lib/urllib/robotparser.py | 0 src/{ => extensions}/StdLib/Lib/uu.py | 0 src/{ => extensions}/StdLib/Lib/uuid.py | 0 src/{ => extensions}/StdLib/Lib/venv/__init__.py | 0 src/{ => extensions}/StdLib/Lib/venv/__main__.py | 0 .../StdLib/Lib/venv/scripts/nt/Activate.ps1 | 0 .../StdLib/Lib/venv/scripts/nt/activate.bat | 0 .../StdLib/Lib/venv/scripts/nt/deactivate.bat | 0 .../StdLib/Lib/venv/scripts/posix/activate | 0 .../StdLib/Lib/venv/scripts/posix/activate.csh | 0 .../StdLib/Lib/venv/scripts/posix/activate.fish | 0 src/{ => extensions}/StdLib/Lib/warnings.py | 0 src/{ => extensions}/StdLib/Lib/wave.py | 0 src/{ => extensions}/StdLib/Lib/weakref.py | 0 src/{ => extensions}/StdLib/Lib/webbrowser.py | 0 src/{ => extensions}/StdLib/Lib/wpf.py | 0 src/{ => extensions}/StdLib/Lib/wsgiref/__init__.py | 0 src/{ => extensions}/StdLib/Lib/wsgiref/handlers.py | 0 src/{ => extensions}/StdLib/Lib/wsgiref/headers.py | 0 .../StdLib/Lib/wsgiref/simple_server.py | 0 src/{ => extensions}/StdLib/Lib/wsgiref/util.py | 0 src/{ => extensions}/StdLib/Lib/wsgiref/validate.py | 0 src/{ => extensions}/StdLib/Lib/xdrlib.py | 0 src/{ => extensions}/StdLib/Lib/xml/__init__.py | 0 .../StdLib/Lib/xml/dom/NodeFilter.py | 0 src/{ => extensions}/StdLib/Lib/xml/dom/__init__.py | 0 src/{ => extensions}/StdLib/Lib/xml/dom/domreg.py | 0 .../StdLib/Lib/xml/dom/expatbuilder.py | 0 .../StdLib/Lib/xml/dom/minicompat.py | 0 src/{ => extensions}/StdLib/Lib/xml/dom/minidom.py | 0 src/{ => extensions}/StdLib/Lib/xml/dom/pulldom.py | 0 .../StdLib/Lib/xml/dom/xmlbuilder.py | 0 .../StdLib/Lib/xml/etree/ElementInclude.py | 0 .../StdLib/Lib/xml/etree/ElementPath.py | 0 .../StdLib/Lib/xml/etree/ElementTree.py | 0 .../StdLib/Lib/xml/etree/__init__.py | 0 .../StdLib/Lib/xml/etree/cElementTree.py | 0 .../StdLib/Lib/xml/parsers/__init__.py | 0 .../StdLib/Lib/xml/parsers/expat.py | 0 src/{ => extensions}/StdLib/Lib/xml/sax/__init__.py | 0 .../StdLib/Lib/xml/sax/_exceptions.py | 0 .../StdLib/Lib/xml/sax/expatreader.py | 0 src/{ => extensions}/StdLib/Lib/xml/sax/handler.py | 0 src/{ => extensions}/StdLib/Lib/xml/sax/saxutils.py | 0 .../StdLib/Lib/xml/sax/xmlreader.py | 0 src/{ => extensions}/StdLib/Lib/xmlrpc/__init__.py | 0 src/{ => extensions}/StdLib/Lib/xmlrpc/client.py | 0 src/{ => extensions}/StdLib/Lib/xmlrpc/server.py | 0 src/{ => extensions}/StdLib/Lib/zipfile.py | 0 src/{ => extensions}/StdLib/StdLib.License.txt | 0 src/{ => extensions}/StdLib/StdLib.pyproj | 0 src/{ => extensions}/StdLib/stdlib-upgrade.txt | 0 src/{ => extensions}/StdLib/update-stdlib.cmd | 0 src/{ => extensions}/StdLib/update-stdlib.sh | 0 src/{ => ipy}/CTypes/Makefile | 0 src/{ => ipy}/CTypes/_ctypes_test.c | 0 src/{ => ipy}/CTypes/_ctypes_test.sln | 0 src/{ => ipy}/CTypes/_ctypes_test.vcxproj | 0 .../AssemblyResolver.cs | 0 .../IronPython.CompilerServices}/Config.cs | 0 .../IronPython.CompilerServices}/ConsoleOps.cs | 0 .../IronPython.CompilerServices.csproj | 0 .../IronPython.CompilerServices}/Program.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../IronPython.CompilerServices}/README.md | 0 .../IronPython.Modules}/IronPython.Modules.csproj | 0 .../IronPython.Modules}/IterTools.cs | 0 .../IronPython.Modules}/ModuleOps.cs | 0 .../IronPython.Modules}/NtSignalState.cs | 0 .../IronPython.Modules}/Properties/AssemblyInfo.cs | 0 .../IronPython.Modules}/ResourceMetaPathImporter.cs | 0 .../IronPython.Modules}/SimpleSignalState.cs | 0 src/{Modules => ipy/IronPython.Modules}/_bisect.cs | 0 src/{Modules => ipy/IronPython.Modules}/_codecs.cs | 0 .../IronPython.Modules}/_codecs_cn.cs | 0 .../IronPython.Modules}/_collections.cs | 0 src/{Modules => ipy/IronPython.Modules}/_csv.cs | 0 .../IronPython.Modules}/_ctypes/Array.cs | 0 .../IronPython.Modules}/_ctypes/ArrayType.cs | 0 .../IronPython.Modules}/_ctypes/CData.cs | 0 .../IronPython.Modules}/_ctypes/CFuncPtr.cs | 0 .../IronPython.Modules}/_ctypes/CFuncPtrType.cs | 0 .../IronPython.Modules}/_ctypes/Extensions.cs | 0 .../IronPython.Modules}/_ctypes/Field.cs | 0 .../IronPython.Modules}/_ctypes/INativeType.cs | 0 .../IronPython.Modules}/_ctypes/LocalOrArg.cs | 0 .../IronPython.Modules}/_ctypes/MarshalCleanup.cs | 0 .../IronPython.Modules}/_ctypes/MemoryHolder.cs | 0 .../IronPython.Modules}/_ctypes/NativeArgument.cs | 0 .../IronPython.Modules}/_ctypes/NativeFunctions.cs | 0 .../IronPython.Modules}/_ctypes/Pointer.cs | 0 .../IronPython.Modules}/_ctypes/PointerType.cs | 0 .../IronPython.Modules}/_ctypes/SimpleCData.cs | 0 .../IronPython.Modules}/_ctypes/SimpleType.cs | 0 .../IronPython.Modules}/_ctypes/SimpleTypeKind.cs | 0 .../IronPython.Modules}/_ctypes/StructType.cs | 0 .../IronPython.Modules}/_ctypes/Structure.cs | 0 .../IronPython.Modules}/_ctypes/Union.cs | 0 .../IronPython.Modules}/_ctypes/UnionType.cs | 0 .../IronPython.Modules}/_ctypes/_ctypes.cs | 0 .../IronPython.Modules}/_ctypes_test.cs | 0 .../IronPython.Modules}/_datetime.cs | 0 .../IronPython.Modules}/_functools.cs | 0 src/{Modules => ipy/IronPython.Modules}/_heapq.cs | 0 .../IronPython.Modules}/_multibytecodec.cs | 0 .../IronPython.Modules}/_multiprocessing.cs | 0 src/{Modules => ipy/IronPython.Modules}/_opcode.cs | 0 .../IronPython.Modules}/_operator.cs | 0 .../IronPython.Modules}/_overlapped.cs | 0 src/{Modules => ipy/IronPython.Modules}/_pickle.cs | 0 .../IronPython.Modules}/_posixsubprocess.cs | 0 .../IronPython.Modules}/_random.RandomGen.cs | 0 src/{Modules => ipy/IronPython.Modules}/_random.cs | 0 src/{Modules => ipy/IronPython.Modules}/_socket.cs | 0 src/{Modules => ipy/IronPython.Modules}/_sre.cs | 0 src/{Modules => ipy/IronPython.Modules}/_ssl.cs | 0 src/{Modules => ipy/IronPython.Modules}/_string.cs | 0 src/{Modules => ipy/IronPython.Modules}/_struct.cs | 0 .../IronPython.Modules}/_sysconfigdata.cs | 0 src/{Modules => ipy/IronPython.Modules}/_thread.cs | 0 .../IronPython.Modules}/_warnings.cs | 0 .../IronPython.Modules}/_weakref.Generated.cs | 0 src/{Modules => ipy/IronPython.Modules}/_weakref.cs | 0 src/{Modules => ipy/IronPython.Modules}/_winapi.cs | 0 src/{Modules => ipy/IronPython.Modules}/array.cs | 0 src/{Modules => ipy/IronPython.Modules}/atexit.cs | 0 src/{Modules => ipy/IronPython.Modules}/audioop.cs | 0 src/{Modules => ipy/IronPython.Modules}/binascii.cs | 0 .../IronPython.Modules}/bz2/BZ2Compressor.cs | 0 .../IronPython.Modules}/bz2/BZ2Decompressor.cs | 0 .../IronPython.Modules}/bz2/BZ2Module.cs | 0 .../bz2/dotnetzip/BZip2/BZip2Compressor.cs | 0 .../bz2/dotnetzip/BZip2/BZip2InputStream.cs | 0 .../bz2/dotnetzip/BZip2/BZip2OutputStream.cs | 0 .../bz2/dotnetzip/BZip2/BitWriter.cs | 0 .../bz2/dotnetzip/BZip2/CRC32.cs | 0 .../dotnetzip/BZip2/ParallelBZip2OutputStream.cs | 0 .../IronPython.Modules}/bz2/dotnetzip/BZip2/Rand.cs | 0 .../IronPython.Modules}/bz2/dotnetzip/source.txt | 0 src/{Modules => ipy/IronPython.Modules}/cmath.cs | 0 src/{Modules => ipy/IronPython.Modules}/errno.cs | 0 .../IronPython.Modules}/faulthandler.cs | 0 src/{Modules => ipy/IronPython.Modules}/fcntl.cs | 0 src/{Modules => ipy/IronPython.Modules}/gc.cs | 0 src/{Modules => ipy/IronPython.Modules}/grp.cs | 0 .../hashlib/MD5CryptoServiceProvider.cs | 0 .../hashlib/SHA1CryptoServiceProvider.cs | 0 .../IronPython.Modules}/hashlib/SHA224.cs | 0 .../IronPython.Modules}/hashlib/SHA224Managed.cs | 0 .../IronPython.Modules}/hashlib/SHA256Managed.cs | 0 .../IronPython.Modules}/hashlib/SHA384Managed.cs | 0 .../IronPython.Modules}/hashlib/SHA512Managed.cs | 0 .../IronPython.Modules}/hashlib/SHAConstants.cs | 0 .../IronPython.Modules}/hashlib/_hashlib.cs | 0 .../IronPython.Modules}/hashlib/_md5.cs | 0 .../IronPython.Modules}/hashlib/_sha1.cs | 0 .../IronPython.Modules}/hashlib/_sha256.cs | 0 .../IronPython.Modules}/hashlib/_sha512.cs | 0 src/{Modules => ipy/IronPython.Modules}/marshal.cs | 0 .../IronPython.Modules}/math.Generated.cs | 0 src/{Modules => ipy/IronPython.Modules}/math.cs | 0 src/{Modules => ipy/IronPython.Modules}/mmap.cs | 0 src/{Modules => ipy/IronPython.Modules}/msvcrt.cs | 0 src/{Modules => ipy/IronPython.Modules}/nt.cs | 0 .../policy.IronPython.Modules.config | 0 src/{Modules => ipy/IronPython.Modules}/pwd.cs | 0 src/{Modules => ipy/IronPython.Modules}/pyexpat.cs | 0 src/{Modules => ipy/IronPython.Modules}/re.cs | 0 src/{Modules => ipy/IronPython.Modules}/resource.cs | 0 src/{Modules => ipy/IronPython.Modules}/select.cs | 0 src/{Modules => ipy/IronPython.Modules}/signal.cs | 0 src/{Modules => ipy/IronPython.Modules}/spwd.cs | 0 src/{Modules => ipy/IronPython.Modules}/time.cs | 0 src/{Modules => ipy/IronPython.Modules}/winreg.cs | 0 src/{Modules => ipy/IronPython.Modules}/winsound.cs | 0 .../IronPython.Modules}/xxsubtype.cs | 0 .../IronPython.Modules}/zipimport.cs | 0 .../IronPython.Modules}/zlib/Compress.cs | 0 .../IronPython.Modules}/zlib/Decompress.cs | 0 .../IronPython.Modules}/zlib/ZlibModule.cs | 0 .../IronPython.Modules}/zlib/zlib.net/Adler32.cs | 0 .../IronPython.Modules}/zlib/zlib.net/Deflate.cs | 0 .../IronPython.Modules}/zlib/zlib.net/InfBlocks.cs | 0 .../IronPython.Modules}/zlib/zlib.net/InfCodes.cs | 0 .../IronPython.Modules}/zlib/zlib.net/InfTree.cs | 0 .../IronPython.Modules}/zlib/zlib.net/Inflate.cs | 0 .../IronPython.Modules}/zlib/zlib.net/StaticTree.cs | 0 .../IronPython.Modules}/zlib/zlib.net/Tree.cs | 0 .../IronPython.Modules}/zlib/zlib.net/ZStream.cs | 0 .../zlib/zlib.net/ZStreamException.cs | 0 .../IronPython.Modules}/zlib/zlib.net/Zlib.cs | 0 .../IronPython.Modules}/zlib/zlib.net/history.txt | 0 .../IronPython.Modules}/zlib/zlib.net/license.txt | 0 .../IronPython.Modules}/zlib/zlib.net/readme.txt | 0 .../IronPython/Compiler/Ast/AndExpression.cs | 0 .../Compiler/Ast/AnnotatedAssignStatement.cs | 0 .../IronPython/Compiler/Ast/AssertStatement.cs | 0 .../IronPython/Compiler/Ast/AssignmentStatement.cs | 0 src/{ => ipy}/IronPython/Compiler/Ast/AstMethods.cs | 0 .../IronPython/Compiler/Ast/AsyncStatement.cs | 0 .../Compiler/Ast/AugmentedAssignStatement.cs | 0 .../Compiler/Ast/BinaryExpression.Generated.cs | 0 .../IronPython/Compiler/Ast/BinaryExpression.cs | 0 .../IronPython/Compiler/Ast/BreakStatement.cs | 0 .../IronPython/Compiler/Ast/CallExpression.cs | 0 .../IronPython/Compiler/Ast/ClassDefinition.cs | 0 .../IronPython/Compiler/Ast/Comprehension.cs | 0 .../IronPython/Compiler/Ast/ComprehensionFor.cs | 0 .../IronPython/Compiler/Ast/ComprehensionIf.cs | 0 .../Compiler/Ast/ConditionalExpression.cs | 0 .../IronPython/Compiler/Ast/ConstantExpression.cs | 0 .../IronPython/Compiler/Ast/ContinueStatement.cs | 0 .../IronPython/Compiler/Ast/DelStatement.cs | 0 .../IronPython/Compiler/Ast/DictionaryExpression.cs | 0 src/{ => ipy}/IronPython/Compiler/Ast/DottedName.cs | 0 .../Compiler/Ast/DynamicConvertExpression.cs | 0 .../Compiler/Ast/DynamicGetMemberExpression.cs | 0 .../IronPython/Compiler/Ast/EmptyStatement.cs | 0 .../IronPython/Compiler/Ast/ErrorExpression.cs | 0 src/{ => ipy}/IronPython/Compiler/Ast/Expression.cs | 0 .../IronPython/Compiler/Ast/ExpressionStatement.cs | 0 .../IronPython/Compiler/Ast/FlowChecker.cs | 0 .../IronPython/Compiler/Ast/ForStatement.cs | 0 .../Compiler/Ast/FormattedValueExpression.cs | 0 .../IronPython/Compiler/Ast/FromImportStatement.cs | 0 .../IronPython/Compiler/Ast/FunctionDefinition.cs | 0 .../IronPython/Compiler/Ast/GeneratorExpression.cs | 0 .../Compiler/Ast/GetGlobalContextExpression.cs | 0 .../Ast/GetParentContextFromFunctionExpression.cs | 0 .../IronPython/Compiler/Ast/GlobalStatement.cs | 0 .../IronPython/Compiler/Ast/ILoopStatement.cs | 0 .../IronPython/Compiler/Ast/IfStatement.cs | 0 .../IronPython/Compiler/Ast/IfStatementTest.cs | 0 .../IronPython/Compiler/Ast/ImportStatement.cs | 0 .../IronPython/Compiler/Ast/IndexExpression.cs | 0 .../Compiler/Ast/JoinedStringExpression.cs | 0 src/{ => ipy}/IronPython/Compiler/Ast/Keyword.cs | 0 .../IronPython/Compiler/Ast/LambdaExpression.cs | 0 .../IronPython/Compiler/Ast/ListExpression.cs | 0 .../IronPython/Compiler/Ast/MemberExpression.cs | 0 src/{ => ipy}/IronPython/Compiler/Ast/ModuleName.cs | 0 .../IronPython/Compiler/Ast/NameExpression.cs | 0 src/{ => ipy}/IronPython/Compiler/Ast/Node.cs | 0 .../IronPython/Compiler/Ast/NonlocalStatement.cs | 0 .../IronPython/Compiler/Ast/OrExpression.cs | 0 src/{ => ipy}/IronPython/Compiler/Ast/Parameter.cs | 0 .../Compiler/Ast/ParenthesisExpression.cs | 0 src/{ => ipy}/IronPython/Compiler/Ast/PythonAst.cs | 0 .../Compiler/Ast/PythonConstantExpression.cs | 0 .../IronPython/Compiler/Ast/PythonNameBinder.cs | 0 .../IronPython/Compiler/Ast/PythonReference.cs | 0 .../IronPython/Compiler/Ast/PythonVariable.cs | 0 .../Compiler/Ast/PythonWalker.Generated.cs | 0 .../IronPython/Compiler/Ast/RaiseStatement.cs | 0 .../IronPython/Compiler/Ast/RelativeModuleName.cs | 0 .../IronPython/Compiler/Ast/ReturnStatement.cs | 0 .../IronPython/Compiler/Ast/ScopeStatement.cs | 0 .../IronPython/Compiler/Ast/SequenceExpression.cs | 0 .../Compiler/Ast/SerializedScopeStatement.cs | 0 .../IronPython/Compiler/Ast/SetExpression.cs | 0 .../IronPython/Compiler/Ast/SliceExpression.cs | 0 .../IronPython/Compiler/Ast/StarredExpression.cs | 0 src/{ => ipy}/IronPython/Compiler/Ast/Statement.cs | 0 .../IronPython/Compiler/Ast/SuiteStatement.cs | 0 .../IronPython/Compiler/Ast/TryStatement.cs | 0 .../IronPython/Compiler/Ast/TupleExpression.cs | 0 .../IronPython/Compiler/Ast/UnaryExpression.cs | 0 .../IronPython/Compiler/Ast/VariableKind.cs | 0 .../IronPython/Compiler/Ast/WhileStatement.cs | 0 .../IronPython/Compiler/Ast/WithStatement.cs | 0 .../IronPython/Compiler/Ast/YieldExpression.cs | 0 .../IronPython/Compiler/Ast/YieldFromExpression.cs | 0 .../IronPython/Compiler/ClosureExpression.cs | 0 src/{ => ipy}/IronPython/Compiler/ClosureInfo.cs | 0 .../Compiler/CollectableCompilationMode.cs | 0 .../IronPython/Compiler/CompilationMode.cs | 0 .../IronPython/Compiler/GeneratorRewriter.cs | 0 src/{ => ipy}/IronPython/Compiler/LazyCode.cs | 0 .../IronPython/Compiler/LookupCompilationMode.cs | 0 .../IronPython/Compiler/OnDiskScriptCode.cs | 0 src/{ => ipy}/IronPython/Compiler/Parser.cs | 0 .../IronPython/Compiler/PythonCallTargets.cs | 0 .../IronPython/Compiler/PythonCompilerOptions.cs | 0 .../IronPython/Compiler/PythonDynamicExpression.cs | 0 src/{ => ipy}/IronPython/Compiler/PythonGlobal.cs | 0 .../Compiler/PythonGlobalVariableExpression.cs | 0 src/{ => ipy}/IronPython/Compiler/PythonOperator.cs | 0 .../IronPython/Compiler/PythonSavableScriptCode.cs | 0 .../IronPython/Compiler/PythonScriptCode.cs | 0 .../Compiler/ReducableDynamicExpression.cs | 0 .../IronPython/Compiler/RunnableScriptCode.cs | 0 .../IronPython/Compiler/RuntimeScriptCode.cs | 0 .../IronPython/Compiler/ToDiskCompilationMode.cs | 0 src/{ => ipy}/IronPython/Compiler/Token.cs | 0 .../IronPython/Compiler/TokenKind.Generated.cs | 0 .../IronPython/Compiler/Tokenizer.Generated.cs | 0 src/{ => ipy}/IronPython/Compiler/Tokenizer.cs | 0 .../UncollectableCompilationMode.Generated.cs | 0 .../Compiler/UncollectableCompilationMode.cs | 0 src/{ => ipy}/IronPython/FakeInteropServices.cs | 0 src/{ => ipy}/IronPython/Hosting/Python.cs | 0 .../IronPython/Hosting/PythonCodeDomCodeGen.cs | 0 .../IronPython/Hosting/PythonCommandLine.cs | 0 .../IronPython/Hosting/PythonConsoleOptions.cs | 0 .../IronPython/Hosting/PythonOptionsParser.cs | 0 src/{ => ipy}/IronPython/Hosting/PythonService.cs | 0 .../IronPython/Interop/Windows/Interop.Libraries.cs | 0 .../Windows/Kernel32/Interop.GetWindowsExW.cs | 0 .../Windows/Kernel32/Interop.OSVERSIONINFOEX.cs | 0 .../Interop/Windows/NtDll/Interop.RtlGetVersion.cs | 0 .../Interop/Windows/Ucrtbase/Interop.strerror.cs | 0 src/{ => ipy}/IronPython/IronPython.csproj | 0 src/{ => ipy}/IronPython/Lib/iptest/__init__.py | 0 .../IronPython/Lib/iptest/cominterop_util.py | 0 src/{ => ipy}/IronPython/Lib/iptest/console_util.py | 0 src/{ => ipy}/IronPython/Lib/iptest/file_util.py | 0 src/{ => ipy}/IronPython/Lib/iptest/ipunittest.py | 0 src/{ => ipy}/IronPython/Lib/iptest/misc_util.py | 0 src/{ => ipy}/IronPython/Lib/iptest/process_util.py | 0 src/{ => ipy}/IronPython/Lib/iptest/runner.py | 0 src/{ => ipy}/IronPython/Lib/iptest/test_env.py | 0 src/{ => ipy}/IronPython/Lib/iptest/type_util.py | 0 .../IronPython/Modules/Builtin.Generated.cs | 0 src/{ => ipy}/IronPython/Modules/Builtin.cs | 0 src/{ => ipy}/IronPython/Modules/_ast.cs | 0 src/{ => ipy}/IronPython/Modules/_fileio.cs | 0 src/{ => ipy}/IronPython/Modules/_imp.cs | 0 src/{ => ipy}/IronPython/Modules/_io.cs | 0 src/{ => ipy}/IronPython/Modules/_io/BytesIO.cs | 0 src/{ => ipy}/IronPython/Modules/_io/StringIO.cs | 0 src/{ => ipy}/IronPython/Modules/_locale.cs | 0 src/{ => ipy}/IronPython/Modules/sys.cs | 0 src/{ => ipy}/IronPython/Modules/unicodedata.cs | 0 .../IronPython/Modules/unicodedata/CaseFolding.txt | 0 .../Modules/unicodedata/EastAsianWidth-3.2.0.txt | 0 .../Modules/unicodedata/EastAsianWidth.txt | 0 .../Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz | Bin .../Modules/unicodedata/IPyUnicodeData.txt.gz | Bin .../IronPython/Modules/unicodedata/NameAliases.txt | 0 .../Modules/unicodedata/UnicodeData-3.2.0.txt | 0 .../IronPython/Modules/unicodedata/UnicodeData.txt | 0 .../Modules/unicodedata/genunicodedata.py | 0 .../IronPython/Modules/unicodedata/license.txt | 0 src/{ => ipy}/IronPython/Properties/AssemblyInfo.cs | 0 src/{ => ipy}/IronPython/Resources.Designer.cs | 0 src/{ => ipy}/IronPython/Resources.resx | 0 src/{ => ipy}/IronPython/Runtime/ArrayData.cs | 0 .../Binding/BinaryRetTypeBinder.Generated.cs | 0 .../Runtime/Binding/BinaryRetTypeBinder.cs | 0 src/{ => ipy}/IronPython/Runtime/Binding/Binders.cs | 0 .../IronPython/Runtime/Binding/BindingHelpers.cs | 0 .../IronPython/Runtime/Binding/BindingWarnings.cs | 0 .../Runtime/Binding/CompatibilityInvokeBinder.cs | 0 .../Runtime/Binding/ConditionalBuilder.cs | 0 .../IronPython/Runtime/Binding/ContextArgBuilder.cs | 0 .../IronPython/Runtime/Binding/ConversionBinder.cs | 0 .../Runtime/Binding/CreateFallbackBinder.cs | 0 .../IronPython/Runtime/Binding/FastBindResult.cs | 0 .../IronPython/Runtime/Binding/FastGetBase.cs | 0 .../IronPython/Runtime/Binding/FastSetBase.cs | 0 .../IronPython/Runtime/Binding/IComConvertible.cs | 0 .../IronPython/Runtime/Binding/IFastGettable.cs | 0 .../IronPython/Runtime/Binding/IFastInvokable.cs | 0 .../IronPython/Runtime/Binding/IFastSettable.cs | 0 .../Runtime/Binding/IPythonConvertible.cs | 0 .../IronPython/Runtime/Binding/IPythonExpandable.cs | 0 .../IronPython/Runtime/Binding/IPythonGetable.cs | 0 .../IronPython/Runtime/Binding/IPythonInvokable.cs | 0 .../IronPython/Runtime/Binding/IPythonOperable.cs | 0 .../IronPython/Runtime/Binding/IPythonSite.cs | 0 .../Runtime/Binding/MetaBuiltinFunction.cs | 0 .../Runtime/Binding/MetaBuiltinMethodDescriptor.cs | 0 .../IronPython/Runtime/Binding/MetaMethod.cs | 0 .../Runtime/Binding/MetaPythonFunction.cs | 0 .../IronPython/Runtime/Binding/MetaPythonObject.cs | 0 .../Runtime/Binding/MetaPythonType.Calls.cs | 0 .../Runtime/Binding/MetaPythonType.Members.cs | 0 .../IronPython/Runtime/Binding/MetaPythonType.cs | 0 .../Runtime/Binding/MetaUserObject.Members.cs | 0 .../IronPython/Runtime/Binding/MetaUserObject.cs | 0 .../Runtime/Binding/PythonBinaryOperationBinder.cs | 0 .../Runtime/Binding/PythonBinder.Create.cs | 0 .../IronPython/Runtime/Binding/PythonBinder.cs | 0 .../Runtime/Binding/PythonDeleteIndexBinder.cs | 0 .../Runtime/Binding/PythonDeleteMemberBinder.cs | 0 .../Runtime/Binding/PythonDeleteSliceBinder.cs | 0 .../Runtime/Binding/PythonExtensionBinder.cs | 0 .../Runtime/Binding/PythonGetIndexBinder.cs | 0 .../Runtime/Binding/PythonGetMemberBinder.cs | 0 .../Runtime/Binding/PythonGetSliceBinder.cs | 0 .../IronPython/Runtime/Binding/PythonIndexType.cs | 0 .../Runtime/Binding/PythonInvokeBinder.cs | 0 .../Runtime/Binding/PythonOperationBinder.cs | 0 .../Runtime/Binding/PythonOperationKind.cs | 0 .../Runtime/Binding/PythonOverloadResolver.cs | 0 .../Runtime/Binding/PythonProtocol.Operations.cs | 0 .../IronPython/Runtime/Binding/PythonProtocol.cs | 0 .../Runtime/Binding/PythonSetIndexBinder.cs | 0 .../Runtime/Binding/PythonSetMemberBinder.cs | 0 .../Runtime/Binding/PythonSetSliceBinder.cs | 0 .../Runtime/Binding/PythonUnaryOperationBinder.cs | 0 .../Runtime/Binding/SiteLocalStorageBuilder.cs | 0 .../IronPython/Runtime/Binding/SlotOrFunction.cs | 0 .../IronPython/Runtime/Binding/WarningInfo.cs | 0 src/{ => ipy}/IronPython/Runtime/BufferProtocol.cs | 0 .../IronPython/Runtime/BuiltinPythonModule.cs | 0 .../IronPython/Runtime/BuiltinsDictionaryStorage.cs | 0 src/{ => ipy}/IronPython/Runtime/ByteArray.cs | 0 .../IronPython/Runtime/ByteArrayIterator.cs | 0 src/{ => ipy}/IronPython/Runtime/Bytes.cs | 0 src/{ => ipy}/IronPython/Runtime/BytesIterator.cs | 0 .../IronPython/Runtime/BytesLikeAttribute.cs | 0 .../IronPython/Runtime/ClassMethodAttribute.cs | 0 .../IronPython/Runtime/ClassMethodDescriptor.cs | 0 src/{ => ipy}/IronPython/Runtime/ClrModule.cs | 0 src/{ => ipy}/IronPython/Runtime/CodeContext.cs | 0 .../IronPython/Runtime/CollectionDebugView.cs | 0 .../IronPython/Runtime/CommonDictionaryStorage.cs | 0 src/{ => ipy}/IronPython/Runtime/CompareUtil.cs | 0 src/{ => ipy}/IronPython/Runtime/CompileFlags.cs | 0 src/{ => ipy}/IronPython/Runtime/CompiledLoader.cs | 0 .../IronPython/Runtime/ConstantDictionaryStorage.cs | 0 .../IronPython/Runtime/ConversionWrappers.cs | 0 src/{ => ipy}/IronPython/Runtime/Converter.cs | 0 .../IronPython/Runtime/CustomDictionaryStorage.cs | 0 .../IronPython/Runtime/DebuggerDictionaryStorage.cs | 0 src/{ => ipy}/IronPython/Runtime/DefaultContext.cs | 0 src/{ => ipy}/IronPython/Runtime/Descriptors.cs | 0 src/{ => ipy}/IronPython/Runtime/DictionaryOps.cs | 0 .../IronPython/Runtime/DictionaryStorage.cs | 0 .../Runtime/DictionaryTypeInfoAttribute.cs | 0 .../Runtime/DontMapGetMemberNamesToDirAttribute.cs | 0 .../Runtime/DontMapICollectionToLenAttribute.cs | 0 .../DontMapIDisposableToContextManagerAttribute.cs | 0 .../DontMapIEnumerableToContainsAttribute.cs | 0 .../Runtime/DontMapIEnumerableToIterAttribute.cs | 0 .../IronPython/Runtime/EmptyDictionaryStorage.cs | 0 src/{ => ipy}/IronPython/Runtime/Enumerate.cs | 0 src/{ => ipy}/IronPython/Runtime/ErrorCodes.cs | 0 .../Exceptions/AssertionException.Generated.cs | 0 .../Runtime/Exceptions/AttributeErrorException.cs | 0 .../Exceptions/BlockingIOException.Generated.cs | 0 .../Exceptions/BrokenPipeException.Generated.cs | 0 .../Runtime/Exceptions/BufferException.Generated.cs | 0 .../Exceptions/BytesWarningException.Generated.cs | 0 .../Exceptions/ChildProcessException.Generated.cs | 0 .../ConnectionAbortedException.Generated.cs | 0 .../Exceptions/ConnectionException.Generated.cs | 0 .../ConnectionRefusedException.Generated.cs | 0 .../ConnectionResetException.Generated.cs | 0 .../DeprecationWarningException.Generated.cs | 0 .../Exceptions/FileExistsException.Generated.cs | 0 .../Exceptions/FloatingPointException.Generated.cs | 0 .../Exceptions/FutureWarningException.Generated.cs | 0 .../Runtime/Exceptions/GeneratorExitException.cs | 0 .../Runtime/Exceptions/ImportException.Generated.cs | 0 .../Exceptions/ImportWarningException.Generated.cs | 0 .../Runtime/Exceptions/IndentationException.cs | 0 .../Exceptions/InterruptedException.Generated.cs | 0 .../Exceptions/IsADirectoryException.Generated.cs | 0 .../Runtime/Exceptions/LookupException.Generated.cs | 0 .../Runtime/Exceptions/ModuleNotFoundException.cs | 0 .../Exceptions/NotADirectoryException.Generated.cs | 0 .../Runtime/Exceptions/OSException.Generated.cs | 0 .../PendingDeprecationWarningException.Generated.cs | 0 .../Exceptions/ProcessLookupException.Generated.cs | 0 .../Runtime/Exceptions/PythonException.cs | 0 .../Exceptions/PythonExceptions.BaseException.cs | 0 .../Exceptions/PythonExceptions.Generated.cs | 0 .../Runtime/Exceptions/PythonExceptions.cs | 0 .../Exceptions/RecursionException.Generated.cs | 0 .../Exceptions/ReferenceException.Generated.cs | 0 .../ResourceWarningException.Generated.cs | 0 .../Exceptions/RuntimeException.Generated.cs | 0 .../Exceptions/RuntimeWarningException.Generated.cs | 0 .../StopAsyncIterationException.Generated.cs | 0 .../Exceptions/StopIterationException.Generated.cs | 0 .../Exceptions/SyntaxWarningException.Generated.cs | 0 .../Runtime/Exceptions/SystemExitException.cs | 0 .../IronPython/Runtime/Exceptions/TabException.cs | 0 .../IronPython/Runtime/Exceptions/TraceBack.cs | 0 .../Runtime/Exceptions/TypeErrorException.cs | 0 .../Exceptions/UnicodeException.Generated.cs | 0 .../UnicodeTranslateException.Generated.cs | 0 .../Exceptions/UnicodeWarningException.Generated.cs | 0 .../Exceptions/UserWarningException.Generated.cs | 0 .../Runtime/Exceptions/ValueErrorException.cs | 0 .../IronPython/Runtime/ExtensionMethodSet.cs | 0 src/{ => ipy}/IronPython/Runtime/Filter.cs | 0 .../IronPython/Runtime/FormattingHelper.cs | 0 .../IronPython/Runtime/FunctionAttributes.cs | 0 src/{ => ipy}/IronPython/Runtime/FunctionCode.cs | 0 src/{ => ipy}/IronPython/Runtime/Generator.cs | 0 .../IronPython/Runtime/GlobalDictionaryStorage.cs | 0 .../IronPython/Runtime/IParameterSequence.cs | 0 src/{ => ipy}/IronPython/Runtime/Implementation.cs | 0 src/{ => ipy}/IronPython/Runtime/Importer.cs | 0 src/{ => ipy}/IronPython/Runtime/Index.cs | 0 .../Runtime/InstancedModuleDictionaryStorage.cs | 0 src/{ => ipy}/IronPython/Runtime/Interfaces.cs | 0 src/{ => ipy}/IronPython/Runtime/KwCallInfo.cs | 0 src/{ => ipy}/IronPython/Runtime/LiteralParser.cs | 0 src/{ => ipy}/IronPython/Runtime/Map.cs | 0 .../Runtime/MaybeNotImplementedAttribute.cs | 0 .../Runtime/MemoryStreamContentProvider.cs | 0 src/{ => ipy}/IronPython/Runtime/MemoryView.cs | 0 .../IronPython/Runtime/Method.Generated.cs | 0 src/{ => ipy}/IronPython/Runtime/Method.cs | 0 .../IronPython/Runtime/MissingParameter.cs | 0 src/{ => ipy}/IronPython/Runtime/ModuleContext.cs | 0 .../IronPython/Runtime/ModuleDictionaryStorage.cs | 0 .../IronPython/Runtime/ModuleGlobalCache.cs | 0 src/{ => ipy}/IronPython/Runtime/ModuleLoader.cs | 0 src/{ => ipy}/IronPython/Runtime/ModuleOptions.cs | 0 src/{ => ipy}/IronPython/Runtime/NameType.cs | 0 .../IronPython/Runtime/NewStringFormatter.cs | 0 .../IronPython/Runtime/ObjectAttributesAdapter.cs | 0 src/{ => ipy}/IronPython/Runtime/ObjectDebugView.cs | 0 .../IronPython/Runtime/Operations/ArrayOps.cs | 0 .../IronPython/Runtime/Operations/BigIntegerOps.cs | 0 .../IronPython/Runtime/Operations/BoolOps.cs | 0 .../IronPython/Runtime/Operations/ByteOps.cs | 0 .../IronPython/Runtime/Operations/CharOps.cs | 0 .../IronPython/Runtime/Operations/ComOps.cs | 0 .../IronPython/Runtime/Operations/ComplexOps.cs | 0 .../Runtime/Operations/CustomTypeDescHelpers.cs | 0 .../IronPython/Runtime/Operations/DBNullOps.cs | 0 .../IronPython/Runtime/Operations/DateTimeOps.cs | 0 .../IronPython/Runtime/Operations/DecimalOps.cs | 0 .../IronPython/Runtime/Operations/DelegateOps.cs | 0 .../Runtime/Operations/DictionaryOfTOps.cs | 0 .../IronPython/Runtime/Operations/EnumOps.cs | 0 .../Runtime/Operations/FloatOps.Generated.cs | 0 .../IronPython/Runtime/Operations/FloatOps.cs | 0 .../IronPython/Runtime/Operations/IListOfByteOps.cs | 0 .../IronPython/Runtime/Operations/InstanceOps.cs | 0 .../Runtime/Operations/IntOps.Generated.cs | 0 .../IronPython/Runtime/Operations/IntOps.cs | 0 .../IronPython/Runtime/Operations/IntPtrOps.cs | 0 .../IronPython/Runtime/Operations/ListOfTOps.cs | 0 .../IronPython/Runtime/Operations/MarshalOps.cs | 0 .../Runtime/Operations/NamespaceTrackerOps.cs | 0 .../IronPython/Runtime/Operations/ObjectOps.cs | 0 .../IronPython/Runtime/Operations/PythonCalls.cs | 0 .../Runtime/Operations/PythonOps.Generated.cs | 0 .../IronPython/Runtime/Operations/PythonOps.cs | 0 .../IronPython/Runtime/Operations/PythonTypeOps.cs | 0 .../Runtime/Operations/StringOps.Generated.cs | 0 .../IronPython/Runtime/Operations/StringOps.cs | 0 .../IronPython/Runtime/Operations/TypeGroupOps.cs | 0 .../IronPython/Runtime/Operations/TypeTrackerOps.cs | 0 .../IronPython/Runtime/Operations/UIntPtrOps.cs | 0 .../IronPython/Runtime/Operations/UserTypeOps.cs | 0 src/{ => ipy}/IronPython/Runtime/OutputWriter.cs | 0 .../IronPython/Runtime/PlatformsAttribute.cs | 0 src/{ => ipy}/IronPython/Runtime/Profiler.cs | 0 .../IronPython/Runtime/PythonContext.Generated.cs | 0 src/{ => ipy}/IronPython/Runtime/PythonContext.cs | 0 .../IronPython/Runtime/PythonDictionary.cs | 0 .../Runtime/PythonDocumentationProvider.cs | 0 .../IronPython/Runtime/PythonDynamicStackFrame.cs | 0 src/{ => ipy}/IronPython/Runtime/PythonEncoding.cs | 0 .../IronPython/Runtime/PythonFileManager.cs | 0 .../IronPython/Runtime/PythonFunction.Generated.cs | 0 src/{ => ipy}/IronPython/Runtime/PythonFunction.cs | 0 .../IronPython/Runtime/PythonHiddenAttribute.cs | 0 .../Runtime/PythonHiddenBaseClassAttribute.cs | 0 src/{ => ipy}/IronPython/Runtime/PythonList.cs | 0 src/{ => ipy}/IronPython/Runtime/PythonModule.cs | 0 .../IronPython/Runtime/PythonModuleAttribute.cs | 0 src/{ => ipy}/IronPython/Runtime/PythonNarrowing.cs | 0 src/{ => ipy}/IronPython/Runtime/PythonOptions.cs | 0 src/{ => ipy}/IronPython/Runtime/PythonRange.cs | 0 .../IronPython/Runtime/PythonScopeExtension.cs | 0 .../IronPython/Runtime/PythonStrIterator.cs | 0 .../IronPython/Runtime/PythonTracebackListener.cs | 0 src/{ => ipy}/IronPython/Runtime/PythonTuple.cs | 0 .../IronPython/Runtime/PythonTypeAttribute.cs | 0 src/{ => ipy}/IronPython/Runtime/Reversed.cs | 0 .../Runtime/RuntimeVariablesDictionaryStorage.cs | 0 .../IronPython/Runtime/ScopeDictionaryStorage.cs | 0 .../IronPython/Runtime/SequenceTypeInfoAttribute.cs | 0 src/{ => ipy}/IronPython/Runtime/Set.cs | 0 src/{ => ipy}/IronPython/Runtime/SetStorage.cs | 0 src/{ => ipy}/IronPython/Runtime/SimpleNamespace.cs | 0 .../IronPython/Runtime/SiteLocalStorage.cs | 0 src/{ => ipy}/IronPython/Runtime/Slice.cs | 0 .../IronPython/Runtime/StringDictionaryStorage.cs | 0 .../IronPython/Runtime/StringFormatSpec.cs | 0 src/{ => ipy}/IronPython/Runtime/StringFormatter.cs | 0 src/{ => ipy}/IronPython/Runtime/Super.cs | 0 .../IronPython/Runtime/Symbols.Generated.cs | 0 .../IronPython/Runtime/ThrowingErrorSink.cs | 0 src/{ => ipy}/IronPython/Runtime/TypecodeOps.cs | 0 .../IronPython/Runtime/Types/BuiltinFunction.cs | 0 .../Runtime/Types/BuiltinFunctionOverloadMapper.cs | 0 .../Runtime/Types/BuiltinMethodDescriptor.cs | 0 .../IronPython/Runtime/Types/CachedNewTypeInfo.cs | 0 .../IronPython/Runtime/Types/ConstructorFunction.cs | 0 .../Runtime/Types/CustomAttributeTracker.cs | 0 .../Types/CustomInstanceDictionaryStorage.cs | 0 .../IronPython/Runtime/Types/DocBuilder.cs | 0 .../Runtime/Types/DynamicBaseTypeAttribute.cs | 0 .../IronPython/Runtime/Types/DynamicHelpers.cs | 0 src/{ => ipy}/IronPython/Runtime/Types/EmptyType.cs | 0 .../Runtime/Types/ExtensionPropertyInfo.cs | 0 .../IronPython/Runtime/Types/FunctionType.cs | 0 .../IronPython/Runtime/Types/IPythonObject.cs | 0 .../IronPython/Runtime/Types/InstanceCreator.cs | 0 .../IronPython/Runtime/Types/MappingProxy.cs | 0 src/{ => ipy}/IronPython/Runtime/Types/Mro.cs | 0 .../IronPython/Runtime/Types/NameConverter.cs | 0 .../IronPython/Runtime/Types/NewTypeInfo.cs | 0 .../IronPython/Runtime/Types/NewTypeMaker.cs | 0 .../IronPython/Runtime/Types/OperatorMapping.cs | 0 .../Runtime/Types/ParameterInfoWrapper.cs | 0 .../IronPython/Runtime/Types/PythonAssemblyOps.cs | 0 .../IronPython/Runtime/Types/PythonSiteCache.cs | 0 .../Runtime/Types/PythonType.Generated.cs | 0 .../IronPython/Runtime/Types/PythonType.cs | 0 .../IronPython/Runtime/Types/PythonTypeDataSlot.cs | 0 .../IronPython/Runtime/Types/PythonTypeDictSlot.cs | 0 .../Runtime/Types/PythonTypeInfo.Generated.cs | 0 .../IronPython/Runtime/Types/PythonTypeInfo.cs | 0 .../IronPython/Runtime/Types/PythonTypeSlot.cs | 0 .../IronPython/Runtime/Types/PythonTypeTypeSlot.cs | 0 .../Runtime/Types/PythonTypeUserDescriptorSlot.cs | 0 .../Runtime/Types/PythonTypeWeakRefSlot.cs | 0 .../IronPython/Runtime/Types/ReflectedEvent.cs | 0 .../Runtime/Types/ReflectedExtensionProperty.cs | 0 .../IronPython/Runtime/Types/ReflectedField.cs | 0 .../Runtime/Types/ReflectedGetterSetter.cs | 0 .../IronPython/Runtime/Types/ReflectedIndexer.cs | 0 .../IronPython/Runtime/Types/ReflectedProperty.cs | 0 .../Runtime/Types/ReflectedSlotProperty.cs | 0 .../IronPython/Runtime/Types/ResolvedMember.cs | 0 .../IronPython/Runtime/Types/SlotFieldAttribute.cs | 0 .../Runtime/Types/StaticUnderlyingSystemType.cs | 0 .../IronPython/Runtime/Types/TypeCache.Generated.cs | 0 .../IronPython/Runtime/UnboundNameException.cs | 0 src/{ => ipy}/IronPython/Runtime/WeakRef.cs | 0 .../Runtime/WrapperDescriptorAttribute.cs | 0 .../IronPython/Runtime/WrapperDictionary.cs | 0 src/{ => ipy}/IronPython/Runtime/Zip.cs | 0 src/{ => ipy}/IronPython/SerializationStubs.cs | 0 src/{ => ipy}/IronPython/StringExtensions.cs | 0 src/{ => ipy}/IronPython/SystemRuntimeVersioning.cs | 0 src/{ => ipy}/IronPython/policy.IronPython.config | 0 .../IronPython.DiagnosticAnalyzer}/Analyzer.cs | 0 .../Directory.Build.props | 0 .../IronPython.DiagnosticAnalyzer.csproj | 0 {src/Tests => tests/ironpython}/AssemblyInfo.cs | 0 {src/Tests => tests/ironpython}/AttrInjectorTest.cs | 0 {src/Tests => tests/ironpython}/BindTest.cs | 0 {src/Tests => tests/ironpython}/BinderTest.cs | 0 .../ironpython}/Cases/CPythonCases.cs | 0 .../ironpython}/Cases/CPythonCasesManifest.ini | 0 .../ironpython}/Cases/CaseExecuter.cs | 0 .../ironpython}/Cases/CaseGenerator.cs | 0 .../Tests => tests/ironpython}/Cases/CommonCases.cs | 0 .../ironpython}/Cases/IronPythonCases.cs | 0 .../ironpython}/Cases/IronPythonCasesManifest.ini | 0 {src/Tests => tests/ironpython}/ClrType.cs | 0 {src/Tests => tests/ironpython}/Cmplx.cs | 0 {src/Tests => tests/ironpython}/Conversions.cs | 0 {src/Tests => tests/ironpython}/DeTest.cs | 0 {src/Tests => tests/ironpython}/DelegateTest.cs | 0 .../ironpython}/DynamicRegressions.cs | 0 {src/Tests => tests/ironpython}/EncodingTest.cs | 0 {src/Tests => tests/ironpython}/EngineTest.cs | 0 {src/Tests => tests/ironpython}/Enums.cs | 0 {src/Tests => tests/ironpython}/Events.cs | 0 .../ironpython}/ExceptionConverter.cs | 0 {src/Tests => tests/ironpython}/Exceptions.cs | 0 {src/Tests => tests/ironpython}/Explicit.cs | 0 .../ironpython}/ExtensionMethodTest.cs | 0 {src/Tests => tests/ironpython}/GenMeth.cs | 0 {src/Tests => tests/ironpython}/Indexable.cs | 0 {src/Tests => tests/ironpython}/InheritTest.cs | 0 {src/Tests => tests/ironpython}/IntegerTest.cs | 0 {src/Tests => tests/ironpython}/IronMath.cs | 0 .../ironpython}/IronPython.Tests.csproj | 0 {src/Tests => tests/ironpython}/LoadTest.cs | 0 .../ironpython}/MemberMappingTests.cs | 0 .../ironpython}/MemberOverloadTest.cs | 0 .../ironpython}/MethodParametersStubs.cs | 0 {src/Tests => tests/ironpython}/NestedClass.cs | 0 {src/Tests => tests/ironpython}/NullableTest.cs | 0 {src/Tests => tests/ironpython}/OperatorTest.cs | 0 {src/Tests => tests/ironpython}/ProtocolTest.cs | 0 {src/Tests => tests/ironpython}/StaticTest.cs | 0 {src/Tests => tests/ironpython}/Stress/Engine.cs | 0 .../ironpython}/StringDictionaryStorage.cs | 0 .../Tests => tests/ironpython}/TestBuiltinModule.cs | 0 {src/Tests => tests/ironpython}/TypeDescriptor.cs | 0 {src/Tests => tests/ironpython}/Util/IniParser.cs | 0 .../Tests => tests/ironpython}/Util/TestManifest.cs | 0 tests/{ => python}/IndicesTest.py | 0 tests/{ => python}/Inputs/RemoteConsole.py | 0 tests/{ => python}/Inputs/UseCLI.py | 0 tests/{ => python}/Inputs/exit.py | 0 tests/{ => python}/Inputs/exitFuncRaises.py | 0 tests/{ => python}/Inputs/exitFuncRuns.py | 0 tests/{ => python}/Inputs/raise.py | 0 tests/{ => python}/Inputs/simpleCommand.py | 0 tests/{ => python}/Inputs/syntaxError.py | 0 tests/{ => python}/Inputs/uninitializedGlobal.py | 0 tests/{ => python}/Modes/ConsoleFlags.ps1 | 0 tests/{ => python}/Modes/ConsoleHelp.Debug.out | 0 tests/{ => python}/Modes/ConsoleHelp.Release.out | 0 tests/{ => python}/RunAgainstCpy.py | 0 tests/{ => python}/Tools/baselines/__builtin__.log | 0 tests/{ => python}/Tools/baselines/_codecs.log | 0 tests/{ => python}/Tools/baselines/_collections.log | 0 tests/{ => python}/Tools/baselines/_sre.log | 0 tests/{ => python}/Tools/baselines/_struct.log | 0 tests/{ => python}/Tools/baselines/_subprocess.log | 0 tests/{ => python}/Tools/baselines/_weakref.log | 0 tests/{ => python}/Tools/baselines/_winreg.log | 0 tests/{ => python}/Tools/baselines/array.log | 0 tests/{ => python}/Tools/baselines/cPickle.log | 0 tests/{ => python}/Tools/baselines/cStringIO.log | 0 tests/{ => python}/Tools/baselines/copy_reg.log | 0 tests/{ => python}/Tools/baselines/datetime.log | 0 tests/{ => python}/Tools/baselines/gc.log | 0 tests/{ => python}/Tools/baselines/itertools.log | 0 tests/{ => python}/Tools/baselines/math.log | 0 tests/{ => python}/Tools/baselines/mmap.log | 0 tests/{ => python}/Tools/baselines/msvcrt.log | 0 tests/{ => python}/Tools/baselines/nt.log | 0 tests/{ => python}/Tools/baselines/select.log | 0 tests/{ => python}/Tools/baselines/signal.log | 0 tests/{ => python}/Tools/baselines/sys.log | 0 tests/{ => python}/Tools/baselines/thread.log | 0 tests/{ => python}/Tools/baselines/time.log | 0 tests/{ => python}/Tools/baselines/types_only.log | 0 tests/{ => python}/Tools/baselines/xxsubtype.log | 0 tests/{ => python}/Tools/check/_functools.log | 0 tests/{ => python}/Tools/cleantests.py | 0 tests/{ => python}/Tools/clr_helpers.py | 0 tests/{ => python}/Tools/cmodule.py | 0 tests/{ => python}/Tools/cpy_tests.py | 0 tests/{ => python}/Tools/logmodule.py | 0 tests/{ => python}/Tools/modulediff.py | 0 tests/{ => python}/Tools/stdmodules.py | 0 tests/{ => python}/_ctypes_test_linux32.pyd | Bin tests/{ => python}/_ctypes_test_linux64.pyd | Bin tests/{ => python}/_ctypes_test_win32.pyd | Bin tests/{ => python}/_ctypes_test_win64.pyd | Bin tests/{ => python}/badil.py | 0 tests/{ => python}/c1.cs | 0 tests/{ => python}/c2.cs | 0 tests/{ => python}/c3.cs | 0 tests/{ => python}/c4.cs | 0 tests/{ => python}/check_result.bat | 0 tests/{ => python}/compat/common.py | 0 tests/{ => python}/compat/rulediff.py | 0 tests/{ => python}/compat/runsbs.py | 0 tests/{ => python}/compat/sbs_builtin.py | 0 tests/{ => python}/compat/sbs_class_compare.py | 0 .../{ => python}/compat/sbs_exceptions/__init__.py | 0 tests/{ => python}/compat/sbs_exceptions/define.py | 0 .../{ => python}/compat/sbs_exceptions/for_loop.py | 0 .../{ => python}/compat/sbs_exceptions/if_false.py | 0 tests/{ => python}/compat/sbs_exceptions/if_true.py | 0 tests/{ => python}/compat/sbs_exceptions/shared.py | 0 .../{ => python}/compat/sbs_exceptions/try_else.py | 0 .../compat/sbs_exceptions/try_except1.py | 0 .../compat/sbs_exceptions/try_except2.py | 0 .../compat/sbs_exceptions/try_except3.py | 0 .../compat/sbs_exceptions/try_finally1.py | 0 .../compat/sbs_exceptions/try_finally2.py | 0 .../compat/sbs_exceptions/try_finally3.py | 0 .../compat/sbs_exceptions/while_loop.py | 0 tests/{ => python}/compat/sbs_func_args.py | 0 tests/{ => python}/compat/sbs_library.cs | 0 tests/{ => python}/compat/sbs_newtype.py | 0 tests/{ => python}/compat/sbs_parse_string.py | 0 tests/{ => python}/compat/sbs_simple_compare.py | 0 tests/{ => python}/compat/sbs_simple_ops.py | 0 tests/{ => python}/compat/sbs_true_division.py | 0 tests/{ => python}/compat/sbs_typeop.py | 0 tests/{ => python}/compat/testdata.py | 0 tests/{ => python}/custombuiltins.py | 0 tests/{ => python}/debugging/__init__.py | 0 tests/{ => python}/debugging/mdbg_tool/__init__.py | 0 tests/{ => python}/debugging/pdb_mod/__init__.py | 0 tests/{ => python}/debugging/vs/__init__.py | 0 tests/{ => python}/dllsite.py | 0 tests/{ => python}/dummy_module.py | 0 .../{ => python}/dynamic_sanity/dynamic_runner.bat | 0 tests/{ => python}/dynamic_sanity/dynamic_sanity.cs | 0 tests/{ => python}/dynamic_sanity/mock.py | 0 .../{ => python}/encoded_files/bad_encoding_name.py | 0 tests/{ => python}/encoded_files/bad_latin1_bom.py | 0 .../encoded_files/bad_latin1_bom_decl.py | 0 tests/{ => python}/encoded_files/bad_latin1_nbsp.py | 0 .../{ => python}/encoded_files/bad_latin1_nodecl.py | 0 .../{ => python}/encoded_files/bad_utf8_bom_decl.py | 0 tests/{ => python}/encoded_files/cp1019.py | 0 tests/{ => python}/encoded_files/cp11334_bad.py | 0 tests/{ => python}/encoded_files/cp11334_ok.py | 0 tests/{ => python}/encoded_files/cp20472.py | 0 .../encoded_files/ok_encoding_nonascii.py | 0 .../encoded_files/ok_encoding_whitespace.py | 0 tests/{ => python}/file_with_BOM.txt | 2 +- tests/{ => python}/file_without_BOM.txt | 2 +- tests/{ => python}/functions/test_signatures.py | 0 tests/{ => python}/gen_stdlib_test.py | 0 tests/{ => python}/gh129.zip | Bin tests/{ => python}/harness.py | 0 .../hosting/editor_svcs/test_errorlistener.py | 0 .../hosting/editor_svcs/test_tokencategorizer.py | 0 .../{ => python}/import_extant/_vendor/__init__.py | 0 .../import_extant/_vendor/packaging/__init__.py | 0 .../import_extant/_vendor/packaging/_structures.py | 0 .../import_extant/_vendor/packaging/version.py | 0 tests/{ => python}/import_extant/extern/__init__.py | 0 tests/{ => python}/interop/__init__.py | 0 tests/{ => python}/interop/com/apps/MultiOffice.py | 0 tests/{ => python}/interop/com/apps/adodb.py | 0 tests/{ => python}/interop/com/apps/excel.py | 0 tests/{ => python}/interop/com/apps/scriptpw.py | 0 tests/{ => python}/interop/com/apps/word.py | 0 tests/{ => python}/interop/com/compat/__init__.py | 0 tests/{ => python}/interop/com/compat/hw.py | 0 tests/{ => python}/interop/com/compat/hw_client.py | 0 .../interop/com/dlrcomlib/DispEvents.py | 0 .../interop/com/dlrcomlib/InOutParams.py | 0 .../interop/com/dlrcomlib/MultipleParams.py | 0 .../interop/com/dlrcomlib/OptionalParams.py | 0 .../{ => python}/interop/com/dlrcomlib/OutParams.py | 0 .../interop/com/dlrcomlib/ReturnValues.py | 0 .../interop/com/dlrcomlib/SimpleErrors.py | 0 .../{ => python}/interop/com/dlrcomlib/__init__.py | 0 .../interop/com/dlrcomlib/dlrcomserver.py | 0 .../interop/com/dlrcomlib/paramsinretval.py | 0 .../interop/com/dlrcomlib/properties.py | 0 .../interop/com/dlrcomlib/pytraits/__init__.py | 0 .../interop/com/dlrcomlib/pytraits/method.py | 0 .../interop/com/dlrcomlib/pytraits/obj.py | 0 .../interop/com/dlrcomlib/pytraits/prop.py | 0 tests/{ => python}/interop/com/dlrcomlib/typelib.py | 0 .../interop/net/derivation/test_ctor_override.py | 0 .../interop/net/derivation/test_event_override.py | 0 .../interop/net/derivation/test_method_override.py | 0 .../interop/net/derivation/test_method_signature.py | 0 .../net/derivation/test_property_override.py | 0 .../interop/net/derivation/test_simplederive.py | 0 .../interop/net/derivation/test_special_method.py | 0 .../interop/net/dynamic/test_dynamic_regressions.py | 0 .../{ => python}/interop/net/event/test_delegate.py | 0 tests/{ => python}/interop/net/event/test_event.py | 0 .../interop/net/field/test_field_misc.py | 0 .../interop/net/field/test_fields_inside_enum.py | 0 .../interop/net/field/test_initonly_fields.py | 0 .../interop/net/field/test_instance_fields.py | 0 .../interop/net/field/test_literal_fields.py | 0 .../interop/net/field/test_static_fields.py | 0 tests/{ => python}/interop/net/loadorder/module.py | 0 tests/{ => python}/interop/net/loadorder/t1a.py | 0 tests/{ => python}/interop/net/loadorder/t1b.py | 0 tests/{ => python}/interop/net/loadorder/t1c.py | 0 tests/{ => python}/interop/net/loadorder/t1d.py | 0 tests/{ => python}/interop/net/loadorder/t2a.py | 0 tests/{ => python}/interop/net/loadorder/t2b.py | 0 tests/{ => python}/interop/net/loadorder/t2c.py | 0 tests/{ => python}/interop/net/loadorder/t2d.py | 0 tests/{ => python}/interop/net/loadorder/t2e.py | 0 tests/{ => python}/interop/net/loadorder/t2f.py | 0 tests/{ => python}/interop/net/loadorder/t2g.py | 0 tests/{ => python}/interop/net/loadorder/t2h.py | 0 tests/{ => python}/interop/net/loadorder/t3a.py | 0 tests/{ => python}/interop/net/loadorder/t3b.py | 0 tests/{ => python}/interop/net/loadorder/t3c0.py | 0 tests/{ => python}/interop/net/loadorder/t3c1.py | 0 tests/{ => python}/interop/net/loadorder/t3c2.py | 0 tests/{ => python}/interop/net/loadorder/t3d.py | 0 tests/{ => python}/interop/net/loadorder/t3e.py | 0 tests/{ => python}/interop/net/loadorder/t3f.py | 0 tests/{ => python}/interop/net/loadorder/t3g1.py | 0 tests/{ => python}/interop/net/loadorder/t3g2.py | 0 tests/{ => python}/interop/net/loadorder/t3h.py | 0 tests/{ => python}/interop/net/loadorder/t3i.py | 0 tests/{ => python}/interop/net/loadorder/t4a.py | 0 tests/{ => python}/interop/net/loadorder/t4b.py | 0 tests/{ => python}/interop/net/loadorder/t4c.py | 0 tests/{ => python}/interop/net/loadorder/t5a.py | 0 tests/{ => python}/interop/net/loadorder/t5b.py | 0 tests/{ => python}/interop/net/loadorder/t5c1.py | 0 tests/{ => python}/interop/net/loadorder/t5c2.py | 0 tests/{ => python}/interop/net/loadorder/t6.py | 0 tests/{ => python}/interop/net/loadorder/t7a.py | 0 tests/{ => python}/interop/net/loadorder/t7b.py | 0 tests/{ => python}/interop/net/loadorder/t7c.py | 0 tests/{ => python}/interop/net/loadorder/t7d.py | 0 tests/{ => python}/interop/net/loadorder/t7e.py | 0 tests/{ => python}/interop/net/loadorder/t7f.py | 0 .../interop/net/method/test_arguments.py | 0 .../interop/net/method/test_op_explicit.py | 0 .../interop/net/method/test_op_implicit.py | 0 .../interop/net/method/test_operators.py | 0 .../interop/net/method/test_returnvalue.py | 0 .../interop/net/property/test_indexercs.py | 0 .../interop/net/property/test_indexervb.py | 0 .../interop/net/property/test_property.py | 0 .../{ => python}/interop/net/test_accessibility.py | 0 .../interop/net/test_dynamicobjectmodel.py | 0 tests/{ => python}/interop/net/test_loadorder.py | 0 .../{ => python}/interop/net/type/test___clrtype.py | 0 .../{ => python}/interop/net/type/test_assembly.py | 0 .../{ => python}/interop/net/type/test_clr_array.py | 0 tests/{ => python}/interop/net/type/test_ctor.py | 0 .../interop/net/type/test_defaultmember.py | 0 .../{ => python}/interop/net/type/test_reachtype.py | 0 .../interop/net/versions/test_four_dot_zero.py | 0 tests/{ => python}/modules/__init__.py | 0 .../modules/io_related/test__bytesio.py | 0 .../{ => python}/modules/io_related/test__fileio.py | 0 .../modules/io_related/test_binascii.py | 0 .../{ => python}/modules/io_related/test_cPickle.py | 0 .../{ => python}/modules/io_related/test_codecs.py | 0 .../{ => python}/modules/io_related/test_copyreg.py | 0 tests/{ => python}/modules/io_related/test_fd.py | 0 .../modules/io_related/test_io_StringIO.py | 0 .../{ => python}/modules/io_related/test_marshal.py | 0 tests/{ => python}/modules/io_related/test_re.py | 0 tests/{ => python}/modules/misc/test__opcode.py | 0 tests/{ => python}/modules/misc/test__random.py | 0 tests/{ => python}/modules/misc/test__sha256.py | 0 tests/{ => python}/modules/misc/test__sha512.py | 0 tests/{ => python}/modules/misc/test__warnings.py | 0 tests/{ => python}/modules/misc/test__weakref.py | 0 tests/{ => python}/modules/misc/test_ctypes.py | 0 tests/{ => python}/modules/misc/test_datetime.py | 0 tests/{ => python}/modules/misc/test_math.py | 0 tests/{ => python}/modules/misc/test_operator.py | 0 .../modules/misc/test_system_namespaces.py | 0 tests/{ => python}/modules/misc/test_zlib.py | 0 .../modules/network_related/__init__.py | 0 .../modules/network_related/keycert.pem | 0 .../modules/network_related/test__socket.py | 0 .../modules/network_related/test__ssl.py | 0 .../{ => python}/modules/system_related/__init__.py | 0 .../modules/system_related/test__locale.py | 0 .../modules/system_related/test_errno.py | 0 .../{ => python}/modules/system_related/test_gc.py | 0 .../{ => python}/modules/system_related/test_nt.py | 0 .../{ => python}/modules/system_related/test_os.py | 0 .../modules/system_related/test_resource.py | 0 .../modules/system_related/test_resource_stdlib.py | 0 .../modules/system_related/test_signal.py | 0 .../{ => python}/modules/system_related/test_sys.py | 0 .../modules/system_related/test_sys_getframe.py | 0 .../modules/system_related/test_thread.py | 0 .../modules/system_related/test_time.py | 0 tests/{ => python}/modules/type_related/__init__.py | 0 .../modules/type_related/test__struct.py | 0 .../{ => python}/modules/type_related/test_array.py | 0 .../type_related/test_bitfields_ctypes_stdlib.py | 0 .../modules/type_related/test_ctypes.py | 0 .../{ => python}/modules/type_related/test_types.py | 0 tests/{ => python}/perf_micro_calls.py | 0 tests/{ => python}/pickles/cp18666.pickle | 0 tests/{ => python}/plans/debugging.html | 0 tests/{ => python}/plans/debugging.mdbg_tool.html | 0 tests/{ => python}/plans/debugging.pdb_mod.html | 0 tests/{ => python}/plans/debugging.vs.html | 0 tests/{ => python}/plans/generic_plan_template.py | 0 .../{ => python}/plans/interop.net.derivation.html | 0 .../interop.net.derivation.test_ctor_override.html | 0 .../interop.net.derivation.test_event_override.html | 0 ...interop.net.derivation.test_method_override.html | 0 ...nterop.net.derivation.test_method_signature.html | 0 ...terop.net.derivation.test_property_override.html | 0 .../interop.net.derivation.test_simplederive.html | 0 .../interop.net.derivation.test_special_method.html | 0 tests/{ => python}/plans/interop.net.event.html | 0 .../plans/interop.net.event.test_delegate.html | 0 .../plans/interop.net.event.test_event.html | 0 tests/{ => python}/plans/interop.net.field.html | 0 .../plans/interop.net.field.test_field_misc.html | 0 .../interop.net.field.test_fields_inside_enum.html | 0 tests/{ => python}/plans/interop.net.html | 0 .../plans/interop.net.insert_csharp.html | 0 tests/{ => python}/plans/interop.net.method.html | 0 .../plans/interop.net.method.test_arguments.html | 0 .../plans/interop.net.method.test_op_explicit.html | 0 .../plans/interop.net.method.test_op_implicit.html | 0 .../plans/interop.net.method.test_operators.html | 0 .../plans/interop.net.method.test_returnvalue.html | 0 tests/{ => python}/plans/interop.net.property.html | 0 .../plans/interop.net.property.test_indexercs.html | 0 .../plans/interop.net.property.test_indexervb.html | 0 .../plans/interop.net.property.test_property.html | 0 .../plans/interop.net.test_accessibility.html | 0 .../plans/interop.net.test_dynamicobjectmodel.html | 0 .../plans/interop.net.test_loadorder.html | 0 tests/{ => python}/plans/interop.net.type.html | 0 .../plans/interop.net.type.test_assembly.html | 0 .../plans/interop.net.type.test_clr_array.html | 0 .../plans/interop.net.type.test_ctor.html | 0 .../plans/interop.net.type.test_defaultmember.html | 0 .../plans/interop.net.type.test_reachtype.html | 0 tests/{ => python}/pretest.py | 0 tests/{ => python}/pyc/console_hw.py | 0 tests/{ => python}/pyc/console_hw_args.py | 0 tests/{ => python}/pyc/other_hw.py | 0 tests/{ => python}/pyc/pkg/__init__.py | 0 tests/{ => python}/pyc/pkg/a.py | 0 tests/{ => python}/pyc/pkg/b.py | 0 tests/{ => python}/pyc/pycpkgtest.py | 0 tests/{ => python}/pyc/stdmodules_ok.ps1 | 0 tests/{ => python}/pyc/test_pyc.ps1 | 0 tests/{ => python}/pyc/winforms_hw.py | 0 tests/{ => python}/run.py | 0 tests/{ => python}/run_transformed.bat | 0 tests/{ => python}/sample.txt.gz | Bin tests/{ => python}/specialcontext/Consoleless.ps1 | 0 tests/{ => python}/specialcontext/verify_ipyw.py | 0 tests/{ => python}/stress/__init__.py | 0 tests/{ => python}/stress/bigimport1_test.py | 0 tests/{ => python}/test_array.py | 0 tests/{ => python}/test_assert.py | 0 tests/{ => python}/test_ast.py | 0 tests/{ => python}/test_attr.py | 0 tests/{ => python}/test_attribute_customize.py | 0 tests/{ => python}/test_attrinjector.py | 0 tests/{ => python}/test_bigint.py | 0 tests/{ => python}/test_bool.py | 0 tests/{ => python}/test_builtin_stdlib.py | 0 tests/{ => python}/test_builtinfunc.py | 0 tests/{ => python}/test_bytes.py | 0 tests/{ => python}/test_bz2.py | 0 tests/{ => python}/test_bz2_stdlib.py | 0 tests/{ => python}/test_class.py | 0 tests/{ => python}/test_class_stdlib.py | 0 tests/{ => python}/test_cliclass.py | 0 tests/{ => python}/test_closure.py | 0 tests/{ => python}/test_clrexception.py | 0 tests/{ => python}/test_clrload.py | 0 tests/{ => python}/test_clrload2.py | 0 tests/{ => python}/test_clrnuminterop.py | 0 tests/{ => python}/test_clrtype.py | 0 tests/{ => python}/test_clruse.py | 0 tests/{ => python}/test_codeccallbacks_stdlib.py | 0 tests/{ => python}/test_codecs.py | 0 tests/{ => python}/test_codecs_stdlib.py | 0 tests/{ => python}/test_compiler.py | 0 tests/{ => python}/test_complex.py | 0 tests/{ => python}/test_complex_stdlib.py | 0 tests/{ => python}/test_conditional.py | 0 tests/{ => python}/test_data.gz | Bin tests/{ => python}/test_datetime.py | 0 tests/{ => python}/test_datetime_stdlib.py | 0 tests/{ => python}/test_decimal.py | 0 tests/{ => python}/test_decorator.py | 0 tests/{ => python}/test_delegate.py | 0 tests/{ => python}/test_deque.py | 0 tests/{ => python}/test_descr_stdlib.py | 0 tests/{ => python}/test_dict.py | 0 tests/{ => python}/test_dict_stdlib.py | 0 tests/{ => python}/test_dictcomp.py | 0 tests/{ => python}/test_dllsite.py | 0 tests/{ => python}/test_dlrkwarg.py | 0 tests/{ => python}/test_doc.py | 0 tests/{ => python}/test_enum.py | 0 tests/{ => python}/test_exceptions.py | 0 tests/{ => python}/test_exceptions_generated.py | 0 tests/{ => python}/test_excinfo.py | 0 tests/{ => python}/test_exec.py | 0 tests/{ => python}/test_file.py | 0 tests/{ => python}/test_float_stdlib.py | 0 tests/{ => python}/test_formatting.py | 0 tests/{ => python}/test_function.py | 0 tests/{ => python}/test_functools_stdlib.py | 0 tests/{ => python}/test_fuzz_parser.py | 0 tests/{ => python}/test_generator.py | 0 tests/{ => python}/test_generator_throw.py | 0 tests/{ => python}/test_genericmeth.py | 0 tests/{ => python}/test_hash.py | 0 tests/{ => python}/test_help.py | 0 tests/{ => python}/test_httplib_stdlib.py | 0 tests/{ => python}/test_imp.py | 0 tests/{ => python}/test_importext.py | 0 tests/{ => python}/test_importpkg.py | 0 tests/{ => python}/test_in.py | 0 tests/{ => python}/test_index.py | 0 tests/{ => python}/test_inheritance.py | 0 tests/{ => python}/test_int.py | 0 tests/{ => python}/test_interactive.py | 0 tests/{ => python}/test_io.py | 0 tests/{ => python}/test_io_stdlib.py | 0 tests/{ => python}/test_ipyc.py | 0 tests/{ => python}/test_ipye.py | 0 tests/{ => python}/test_ironmath.py | 0 tests/{ => python}/test_is.py | 0 tests/{ => python}/test_isinstance.py | 0 tests/{ => python}/test_isinstance2.py | 0 tests/{ => python}/test_iterator.py | 0 tests/{ => python}/test_iteratorlength.py | 0 tests/{ => python}/test_itertools_stdlib.py | 0 tests/{ => python}/test_json.py | 0 tests/{ => python}/test_kwarg.py | 0 tests/{ => python}/test_list.py | 0 tests/{ => python}/test_listcomp.py | 0 tests/{ => python}/test_long_stdlib.py | 0 tests/{ => python}/test_memory.py | 0 tests/{ => python}/test_memoryio_stdlib.py | 0 tests/{ => python}/test_memoryview.py | 0 tests/{ => python}/test_metaclass.py | 0 tests/{ => python}/test_methodbinder1.py | 0 tests/{ => python}/test_methodbinder2.py | 0 tests/{ => python}/test_methoddispatch.py | 0 tests/{ => python}/test_missing.py | 0 tests/{ => python}/test_namebinding.py | 0 tests/{ => python}/test_nonetype.py | 0 tests/{ => python}/test_nonlocal.py | 0 tests/{ => python}/test_number.py | 0 tests/{ => python}/test_numberhash.py | 0 tests/{ => python}/test_numtypes.py | 0 tests/{ => python}/test_pep380_stdlib.py | 0 tests/{ => python}/test_peverify.py | 0 tests/{ => python}/test_pow.py | 0 tests/{ => python}/test_privateBinding.py | 0 tests/{ => python}/test_property.py | 0 tests/{ => python}/test_protected.py | 0 tests/{ => python}/test_pyexpat.py | 0 tests/{ => python}/test_python25.py | 0 tests/{ => python}/test_python26.py | 0 tests/{ => python}/test_range.py | 0 tests/{ => python}/test_re_stdlib.py | 0 tests/{ => python}/test_regressions.py | 0 tests/{ => python}/test_regressions_compiled.py | 0 tests/{ => python}/test_sax_stdlib.py | 0 tests/{ => python}/test_scope_stdlib.py | 0 tests/{ => python}/test_set.py | 0 tests/{ => python}/test_setcomp.py | 0 tests/{ => python}/test_shutil.py | 0 tests/{ => python}/test_slice.py | 0 tests/{ => python}/test_slots.py | 0 tests/{ => python}/test_socket_stdlib.py | 0 tests/{ => python}/test_specialcontext.py | 0 tests/{ => python}/test_sqlite3_stdlib.py | 0 tests/{ => python}/test_ssl_stdlib.py | 0 tests/{ => python}/test_statics.py | 0 tests/{ => python}/test_stdconsole.py | 0 tests/{ => python}/test_stdmodules.py | 0 tests/{ => python}/test_str.py | 0 tests/{ => python}/test_str_bytes.py | 0 tests/{ => python}/test_strformat.py | 0 tests/{ => python}/test_struct.py | 0 tests/{ => python}/test_struct_stdlib.py | 0 tests/{ => python}/test_struct_threadsafe.py | 0 tests/{ => python}/test_super.py | 0 tests/{ => python}/test_superconsole.py | 0 tests/{ => python}/test_surrogateescape.py | 0 .../test_surrogateescape_pythonfuture.py | 0 tests/{ => python}/test_surrogatepass.py | 0 tests/{ => python}/test_syntax.py | 0 tests/{ => python}/test_sys_stdlib.py | 0 tests/{ => python}/test_system_timers.py | 0 tests/{ => python}/test_tcf.py | 0 tests/{ => python}/test_threadsafety.py | 0 tests/{ => python}/test_time_stdlib.py | 0 tests/{ => python}/test_traceback.py | 0 tests/{ => python}/test_tuple.py | 0 tests/{ => python}/test_types_stdlib.py | 0 tests/{ => python}/test_typing_stdlib.py | 0 tests/{ => python}/test_unicode.py | 0 tests/{ => python}/test_unicode_stdlib.py | 0 tests/{ => python}/test_unpack.py | 0 tests/{ => python}/test_utf8_mode_stdlib.py | 0 tests/{ => python}/test_weakref.py | 0 tests/{ => python}/test_weakset_stdlib.py | 0 tests/{ => python}/test_winforms.py | 0 tests/{ => python}/test_with.py | 0 tests/{ => python}/test_zipimport.py | 0 tests/{ => python}/testpkg1/__init__.py | 0 tests/{ => python}/testpkg1/mod1.py | 0 tests/{ => python}/timeit.py | 0 tests/{ => python}/toimport.py | 0 tests/{ => python}/transform.py | 0 3171 files changed, 2 insertions(+), 2 deletions(-) rename {src/Scripts => scripts}/CompareDirs.py (100%) rename {src/Scripts => scripts}/Enter-IronPythonEnvironment.ps1 (100%) rename {src/Scripts => scripts}/Install-IronPython.ps1 (100%) rename {src/Scripts => scripts}/clean.py (100%) rename {src/Scripts => scripts}/copyrights.py (100%) rename {src/Scripts => scripts}/generate.py (100%) rename {src/Scripts => scripts}/generate_UncollectableCompilationMode.py (100%) rename {src/Scripts => scripts}/generate_alltypes.py (100%) rename {src/Scripts => scripts}/generate_calls.py (100%) rename {src/Scripts => scripts}/generate_casts.py (100%) rename {src/Scripts => scripts}/generate_comdispatch.py (100%) rename {src/Scripts => scripts}/generate_dict_views.py (100%) rename {src/Scripts => scripts}/generate_dynamic_instructions.py (100%) rename {src/Scripts => scripts}/generate_dynsites.py (100%) rename {src/Scripts => scripts}/generate_encoding_aliases.py (100%) rename {src/Scripts => scripts}/generate_exception_factory.py (100%) rename {src/Scripts => scripts}/generate_exceptions.py (100%) rename {src/Scripts => scripts}/generate_indicestest.py (100%) rename {src/Scripts => scripts}/generate_math.py (100%) rename {src/Scripts => scripts}/generate_ops.py (100%) rename {src/Scripts => scripts}/generate_os_codes.py (100%) rename {src/Scripts => scripts}/generate_reflected_calls.py (100%) rename {src/Scripts => scripts}/generate_set.py (100%) rename {src/Scripts => scripts}/generate_tuples.py (100%) rename {src/Scripts => scripts}/generate_typecache.py (100%) rename {src/Scripts => scripts}/generate_walker.py (100%) rename {src/Scripts => scripts}/ipcom.ps1 (100%) rename {src/Scripts => scripts}/make_meta1.py (100%) rename {src/Scripts => scripts}/radix_generator.py (100%) rename {src/Scripts => scripts}/run_compiled.py (100%) rename {src/Scripts => scripts}/run_interactive.py (100%) rename {src/Scripts => scripts}/smtpmailer.py (100%) rename {src/Scripts => scripts}/test_builder.py (100%) rename {src/Scripts => scripts}/test_cgcheck.py (100%) rename {src/Scripts => scripts}/test_parrot.py (100%) rename {src/Scripts => scripts}/test_pystone.py (100%) rename src/{Console.Host => console/IronPython.Console.Host}/IronPython.Console.Host.csproj (100%) rename src/{Console.Host => console/IronPython.Console.Host}/IronPythonWindow.cs (100%) rename src/{Console.Host => console/IronPython.Console.Host}/Properties/AssemblyInfo.cs (100%) rename src/{Console.Host => console/IronPython.Console.Host}/ipyw.ico (100%) rename src/{Console => console/IronPython.Console}/Console.cs (100%) rename src/{Console => console/IronPython.Console}/IronPython.Console.csproj (100%) rename src/{Console => console/IronPython.Console}/Properties/AssemblyInfo.cs (100%) rename src/{Console => console/IronPython.Console}/app.manifest (100%) rename src/{Console => console/IronPython.Console}/ipy-mono.sh (100%) rename src/{Console => console/IronPython.Console}/ipy.ico (100%) rename src/{Console => console/IronPython.Console}/ipy.sh (100%) rename src/{Console => console/IronPython.Console}/runtimeconfig.template.json (100%) rename src/{Console32.Host => console/IronPython.Console32.Host}/IronPython.Console32.Host.csproj (100%) rename src/{Console32 => console/IronPython.Console32}/IronPython.Console32.csproj (100%) rename src/{SQLite => extensions/IronPython.SQLite}/Connection.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/Contants.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/Cursor.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/Exceptions.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/Extensions.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/IronPython.SQLite.csproj (100%) rename src/{SQLite => extensions/IronPython.SQLite}/Properties/AssemblyInfo.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/Row.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/Statement.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/Util.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/_sqlite.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/.editorconfig (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/BtreeInt_h.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/Btree_h.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/Delegates.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/Hash_h.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/VdbeInt_h.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/Vdbe_h.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/_Custom.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/alter_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/analyze_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/attach_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/auth_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/backup_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/bitvec_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/btmutex_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/btree_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/build_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/callback_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/complete_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/crypto.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/ctime_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/date_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/delete_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/expr_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/fault_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/fkey_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/func_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/global_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/hash_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/hwtime_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/insert_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/journal_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/keywordhash_h.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/legacy_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/loadext_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/main_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/malloc_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/mem_Pool.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/memjournal_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/mutex_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/mutex_h.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/mutex_noop_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/mutex_w32.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/notify_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/opcodes_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/opcodes_h.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/os_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/os_common_h.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/os_h.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/os_win_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/pager_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/pager_h.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/parse_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/parse_h.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/pcache1_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/pcache_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/pcache_h.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/pragma_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/prepare_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/printf_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/random_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/resolve_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/rowset_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/select_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/sqlite3_h.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/sqliteInt_h.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/sqliteLimit_h.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/status_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/table_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/tokenize_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/trigger_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/update_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/utf_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/util_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/vacuum_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/vdbe_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/vdbeapi_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/vdbeaux_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/vdbeblob_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/vdbemem_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/vdbetrace_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/vtab_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/wal_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/wal_h.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/walker_c.cs (100%) rename src/{SQLite => extensions/IronPython.SQLite}/c#sqlite/where_c.cs (100%) rename src/{Wpf => extensions/IronPython.Wpf}/DynamicXamlReader.cs (100%) rename src/{Wpf => extensions/IronPython.Wpf}/IronPython.Wpf.csproj (100%) rename src/{Wpf => extensions/IronPython.Wpf}/Properties/AssemblyInfo.cs (100%) rename src/{Wpf => extensions/IronPython.Wpf}/_wpf.cs (100%) rename src/{ => extensions}/StdLib/.gitattributes (100%) rename src/{ => extensions}/StdLib/Lib/__future__.py (100%) rename src/{ => extensions}/StdLib/Lib/__phello__.foo.py (100%) rename src/{ => extensions}/StdLib/Lib/_bootlocale.py (100%) rename src/{ => extensions}/StdLib/Lib/_collections_abc.py (100%) rename src/{ => extensions}/StdLib/Lib/_compat_pickle.py (100%) rename src/{ => extensions}/StdLib/Lib/_dummy_thread.py (100%) rename src/{ => extensions}/StdLib/Lib/_markupbase.py (100%) rename src/{ => extensions}/StdLib/Lib/_osx_support.py (100%) rename src/{ => extensions}/StdLib/Lib/_pyio.py (100%) rename src/{ => extensions}/StdLib/Lib/_sitebuiltins.py (100%) rename src/{ => extensions}/StdLib/Lib/_strptime.py (100%) rename src/{ => extensions}/StdLib/Lib/_threading_local.py (100%) rename src/{ => extensions}/StdLib/Lib/_weakrefset.py (100%) rename src/{ => extensions}/StdLib/Lib/abc.py (100%) rename src/{ => extensions}/StdLib/Lib/aifc.py (100%) rename src/{ => extensions}/StdLib/Lib/antigravity.py (100%) rename src/{ => extensions}/StdLib/Lib/argparse.py (100%) rename src/{ => extensions}/StdLib/Lib/ast.py (100%) rename src/{ => extensions}/StdLib/Lib/asynchat.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/base_events.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/base_subprocess.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/compat.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/constants.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/coroutines.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/events.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/futures.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/locks.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/log.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/proactor_events.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/protocols.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/queues.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/selector_events.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/sslproto.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/streams.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/subprocess.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/tasks.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/test_utils.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/transports.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/unix_events.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/windows_events.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncio/windows_utils.py (100%) rename src/{ => extensions}/StdLib/Lib/asyncore.py (100%) rename src/{ => extensions}/StdLib/Lib/base64.py (100%) rename src/{ => extensions}/StdLib/Lib/bdb.py (100%) rename src/{ => extensions}/StdLib/Lib/binhex.py (100%) rename src/{ => extensions}/StdLib/Lib/bisect.py (100%) rename src/{ => extensions}/StdLib/Lib/bz2.py (100%) rename src/{ => extensions}/StdLib/Lib/cProfile.py (100%) rename src/{ => extensions}/StdLib/Lib/calendar.py (100%) rename src/{ => extensions}/StdLib/Lib/cgi.py (100%) rename src/{ => extensions}/StdLib/Lib/cgitb.py (100%) rename src/{ => extensions}/StdLib/Lib/chunk.py (100%) rename src/{ => extensions}/StdLib/Lib/clrtype.py (100%) rename src/{ => extensions}/StdLib/Lib/cmd.py (100%) rename src/{ => extensions}/StdLib/Lib/code.py (100%) rename src/{ => extensions}/StdLib/Lib/codecs.py (100%) rename src/{ => extensions}/StdLib/Lib/codeop.py (100%) rename src/{ => extensions}/StdLib/Lib/collections/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/collections/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/collections/abc.py (100%) rename src/{ => extensions}/StdLib/Lib/colorsys.py (100%) rename src/{ => extensions}/StdLib/Lib/compileall.py (100%) rename src/{ => extensions}/StdLib/Lib/concurrent/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/concurrent/futures/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/concurrent/futures/_base.py (100%) rename src/{ => extensions}/StdLib/Lib/concurrent/futures/process.py (100%) rename src/{ => extensions}/StdLib/Lib/concurrent/futures/thread.py (100%) rename src/{ => extensions}/StdLib/Lib/configparser.py (100%) rename src/{ => extensions}/StdLib/Lib/contextlib.py (100%) rename src/{ => extensions}/StdLib/Lib/copy.py (100%) rename src/{ => extensions}/StdLib/Lib/copyreg.py (100%) rename src/{ => extensions}/StdLib/Lib/crypt.py (100%) rename src/{ => extensions}/StdLib/Lib/csv.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/_endian.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/macholib/README.ctypes (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/macholib/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/macholib/dyld.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/macholib/dylib.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/macholib/fetch_macholib (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/macholib/fetch_macholib.bat (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/macholib/framework.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_anon.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_array_in_pointer.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_arrays.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_as_parameter.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_bitfields.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_buffers.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_bytes.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_byteswap.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_callbacks.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_cast.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_cfuncs.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_checkretval.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_delattr.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_errno.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_find.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_frombuffer.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_funcptr.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_functions.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_incomplete.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_init.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_internals.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_keeprefs.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_libc.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_loading.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_macholib.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_memfunctions.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_numbers.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_objects.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_parameters.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_pep3118.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_pickling.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_pointers.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_prototypes.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_python_api.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_random_things.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_refcounts.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_repr.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_returnfuncptrs.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_simplesubclasses.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_sizes.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_slicing.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_stringptr.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_strings.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_struct_fields.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_structures.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_unaligned_structures.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_unicode.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_values.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_varsize_struct.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_win32.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/test/test_wintypes.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/util.py (100%) rename src/{ => extensions}/StdLib/Lib/ctypes/wintypes.py (100%) rename src/{ => extensions}/StdLib/Lib/curses/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/curses/ascii.py (100%) rename src/{ => extensions}/StdLib/Lib/curses/has_key.py (100%) rename src/{ => extensions}/StdLib/Lib/curses/panel.py (100%) rename src/{ => extensions}/StdLib/Lib/curses/textpad.py (100%) rename src/{ => extensions}/StdLib/Lib/datetime.py (100%) rename src/{ => extensions}/StdLib/Lib/dbm/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/dbm/dumb.py (100%) rename src/{ => extensions}/StdLib/Lib/dbm/gnu.py (100%) rename src/{ => extensions}/StdLib/Lib/dbm/ndbm.py (100%) rename src/{ => extensions}/StdLib/Lib/decimal.py (100%) rename src/{ => extensions}/StdLib/Lib/difflib.py (100%) rename src/{ => extensions}/StdLib/Lib/dis.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/README (100%) rename src/{ => extensions}/StdLib/Lib/distutils/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/archive_util.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/bcppcompiler.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/ccompiler.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/cmd.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/bdist.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/bdist_dumb.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/bdist_msi.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/bdist_rpm.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/bdist_wininst.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/build.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/build_clib.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/build_ext.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/build_py.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/build_scripts.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/check.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/clean.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/command_template (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/config.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/install.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/install_data.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/install_egg_info.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/install_headers.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/install_lib.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/install_scripts.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/register.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/sdist.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/upload.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/wininst-10.0.exe (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/wininst-6.0.exe (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/wininst-7.1.exe (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/wininst-8.0.exe (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe (100%) rename src/{ => extensions}/StdLib/Lib/distutils/command/wininst-9.0.exe (100%) rename src/{ => extensions}/StdLib/Lib/distutils/config.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/core.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/cygwinccompiler.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/debug.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/dep_util.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/dir_util.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/dist.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/errors.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/extension.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/fancy_getopt.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/file_util.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/filelist.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/log.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/msvc9compiler.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/msvccompiler.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/spawn.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/sysconfig.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/Setup.sample (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/support.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_archive_util.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_bdist.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_bdist_dumb.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_bdist_msi.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_bdist_rpm.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_bdist_wininst.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_build.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_build_clib.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_build_ext.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_build_py.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_build_scripts.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_check.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_clean.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_cmd.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_config.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_config_cmd.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_core.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_cygwinccompiler.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_dep_util.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_dir_util.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_dist.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_extension.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_file_util.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_filelist.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_install.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_install_data.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_install_headers.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_install_lib.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_install_scripts.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_log.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_msvc9compiler.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_register.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_sdist.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_spawn.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_sysconfig.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_text_file.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_unixccompiler.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_upload.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_util.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_version.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/tests/test_versionpredicate.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/text_file.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/unixccompiler.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/util.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/version.py (100%) rename src/{ => extensions}/StdLib/Lib/distutils/versionpredicate.py (100%) rename src/{ => extensions}/StdLib/Lib/doctest.py (100%) rename src/{ => extensions}/StdLib/Lib/dummy_threading.py (100%) rename src/{ => extensions}/StdLib/Lib/email/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/email/_encoded_words.py (100%) rename src/{ => extensions}/StdLib/Lib/email/_header_value_parser.py (100%) rename src/{ => extensions}/StdLib/Lib/email/_parseaddr.py (100%) rename src/{ => extensions}/StdLib/Lib/email/_policybase.py (100%) rename src/{ => extensions}/StdLib/Lib/email/architecture.rst (100%) rename src/{ => extensions}/StdLib/Lib/email/base64mime.py (100%) rename src/{ => extensions}/StdLib/Lib/email/charset.py (100%) rename src/{ => extensions}/StdLib/Lib/email/contentmanager.py (100%) rename src/{ => extensions}/StdLib/Lib/email/encoders.py (100%) rename src/{ => extensions}/StdLib/Lib/email/errors.py (100%) rename src/{ => extensions}/StdLib/Lib/email/feedparser.py (100%) rename src/{ => extensions}/StdLib/Lib/email/generator.py (100%) rename src/{ => extensions}/StdLib/Lib/email/header.py (100%) rename src/{ => extensions}/StdLib/Lib/email/headerregistry.py (100%) rename src/{ => extensions}/StdLib/Lib/email/iterators.py (100%) rename src/{ => extensions}/StdLib/Lib/email/message.py (100%) rename src/{ => extensions}/StdLib/Lib/email/mime/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/email/mime/application.py (100%) rename src/{ => extensions}/StdLib/Lib/email/mime/audio.py (100%) rename src/{ => extensions}/StdLib/Lib/email/mime/base.py (100%) rename src/{ => extensions}/StdLib/Lib/email/mime/image.py (100%) rename src/{ => extensions}/StdLib/Lib/email/mime/message.py (100%) rename src/{ => extensions}/StdLib/Lib/email/mime/multipart.py (100%) rename src/{ => extensions}/StdLib/Lib/email/mime/nonmultipart.py (100%) rename src/{ => extensions}/StdLib/Lib/email/mime/text.py (100%) rename src/{ => extensions}/StdLib/Lib/email/parser.py (100%) rename src/{ => extensions}/StdLib/Lib/email/policy.py (100%) rename src/{ => extensions}/StdLib/Lib/email/quoprimime.py (100%) rename src/{ => extensions}/StdLib/Lib/email/utils.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/aliases.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/ascii.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/base64_codec.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/big5.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/big5hkscs.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/bz2_codec.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/charmap.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp037.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp1006.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp1026.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp1125.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp1140.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp1250.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp1251.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp1252.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp1253.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp1254.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp1255.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp1256.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp1257.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp1258.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp273.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp424.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp437.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp500.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp65001.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp720.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp737.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp775.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp850.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp852.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp855.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp856.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp857.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp858.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp860.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp861.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp862.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp863.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp864.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp865.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp866.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp869.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp874.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp875.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp932.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp949.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/cp950.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/euc_jis_2004.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/euc_jisx0213.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/euc_jp.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/euc_kr.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/gb18030.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/gb2312.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/gbk.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/hex_codec.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/hp_roman8.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/hz.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/idna.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso2022_jp.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso2022_jp_1.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso2022_jp_2.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso2022_jp_2004.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso2022_jp_3.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso2022_jp_ext.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso2022_kr.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso8859_1.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso8859_10.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso8859_11.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso8859_13.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso8859_14.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso8859_15.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso8859_16.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso8859_2.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso8859_3.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso8859_4.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso8859_5.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso8859_6.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso8859_7.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso8859_8.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/iso8859_9.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/johab.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/koi8_r.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/koi8_u.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/latin_1.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/mac_arabic.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/mac_centeuro.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/mac_croatian.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/mac_cyrillic.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/mac_farsi.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/mac_greek.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/mac_iceland.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/mac_latin2.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/mac_roman.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/mac_romanian.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/mac_turkish.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/mbcs.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/palmos.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/ptcp154.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/punycode.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/quopri_codec.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/raw_unicode_escape.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/rot_13.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/shift_jis.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/shift_jis_2004.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/shift_jisx0213.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/tis_620.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/undefined.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/unicode_escape.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/unicode_internal.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/utf_16.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/utf_16_be.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/utf_16_le.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/utf_32.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/utf_32_be.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/utf_32_le.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/utf_7.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/utf_8.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/utf_8_sig.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/uu_codec.py (100%) rename src/{ => extensions}/StdLib/Lib/encodings/zlib_codec.py (100%) rename src/{ => extensions}/StdLib/Lib/ensurepip/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/ensurepip/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl (100%) rename src/{ => extensions}/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl (100%) rename src/{ => extensions}/StdLib/Lib/ensurepip/_uninstall.py (100%) rename src/{ => extensions}/StdLib/Lib/enum.py (100%) rename src/{ => extensions}/StdLib/Lib/filecmp.py (100%) rename src/{ => extensions}/StdLib/Lib/fileinput.py (100%) rename src/{ => extensions}/StdLib/Lib/fnmatch.py (100%) rename src/{ => extensions}/StdLib/Lib/formatter.py (100%) rename src/{ => extensions}/StdLib/Lib/fractions.py (100%) rename src/{ => extensions}/StdLib/Lib/ftplib.py (100%) rename src/{ => extensions}/StdLib/Lib/functools.py (100%) rename src/{ => extensions}/StdLib/Lib/genericpath.py (100%) rename src/{ => extensions}/StdLib/Lib/getopt.py (100%) rename src/{ => extensions}/StdLib/Lib/getpass.py (100%) rename src/{ => extensions}/StdLib/Lib/gettext.py (100%) rename src/{ => extensions}/StdLib/Lib/glob.py (100%) rename src/{ => extensions}/StdLib/Lib/gzip.py (100%) rename src/{ => extensions}/StdLib/Lib/hashlib.py (100%) rename src/{ => extensions}/StdLib/Lib/heapq.py (100%) rename src/{ => extensions}/StdLib/Lib/hmac.py (100%) rename src/{ => extensions}/StdLib/Lib/html/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/html/entities.py (100%) rename src/{ => extensions}/StdLib/Lib/html/parser.py (100%) rename src/{ => extensions}/StdLib/Lib/http/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/http/client.py (100%) rename src/{ => extensions}/StdLib/Lib/http/cookiejar.py (100%) rename src/{ => extensions}/StdLib/Lib/http/cookies.py (100%) rename src/{ => extensions}/StdLib/Lib/http/server.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/AutoComplete.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/AutoCompleteWindow.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/AutoExpand.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/Bindings.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/CREDITS.txt (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/CallTipWindow.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/CallTips.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/ChangeLog (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/ClassBrowser.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/CodeContext.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/ColorDelegator.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/Debugger.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/Delegator.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/EditorWindow.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/FileList.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/FormatParagraph.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/GrepDialog.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/HISTORY.txt (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/HyperParser.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/IOBinding.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/Icons/folder.gif (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/Icons/idle.icns (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/Icons/idle.ico (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/Icons/idle_16.gif (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/Icons/idle_16.png (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/Icons/idle_32.gif (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/Icons/idle_32.png (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/Icons/idle_48.gif (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/Icons/idle_48.png (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/Icons/minusnode.gif (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/Icons/openfolder.gif (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/Icons/plusnode.gif (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/Icons/python.gif (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/Icons/tk.gif (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/IdleHistory.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/MultiCall.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/MultiStatusBar.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/NEWS.txt (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/ObjectBrowser.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/OutputWindow.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/ParenMatch.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/PathBrowser.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/Percolator.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/PyParse.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/PyShell.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/README.txt (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/RemoteDebugger.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/RemoteObjectBrowser.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/ReplaceDialog.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/RstripExtension.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/ScriptBinding.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/ScrolledList.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/SearchDialog.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/SearchDialogBase.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/SearchEngine.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/StackViewer.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/TODO.txt (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/ToolTip.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/TreeWidget.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/UndoDelegator.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/WidgetRedirector.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/WindowList.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/ZoomHeight.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/aboutDialog.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/config-extensions.def (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/config-highlight.def (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/config-keys.def (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/config-main.def (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/configDialog.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/configHandler.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/configHelpSourceEdit.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/configSectionNameDialog.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/dynOptionMenuWidget.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/extend.txt (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/help.html (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/help.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/help.txt (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle.bat (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle.pyw (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/README.txt (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/htest.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/mock_idle.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/mock_tk.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/test_autocomplete.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/test_autoexpand.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/test_calltips.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/test_config_name.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/test_configdialog.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/test_delegator.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/test_editor.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/test_grep.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/test_hyperparser.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/test_idlehistory.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/test_io.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/test_parenmatch.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/test_rstrip.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/test_searchengine.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/test_text.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/test_textview.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/test_warning.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idle_test/test_widgetredir.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/idlever.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/keybindingDialog.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/macosxSupport.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/rpc.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/run.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/tabbedpages.py (100%) rename src/{ => extensions}/StdLib/Lib/idlelib/textView.py (100%) rename src/{ => extensions}/StdLib/Lib/imaplib.py (100%) rename src/{ => extensions}/StdLib/Lib/imghdr.py (100%) rename src/{ => extensions}/StdLib/Lib/imp.py (100%) rename src/{ => extensions}/StdLib/Lib/importlib/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/importlib/_bootstrap.py (100%) rename src/{ => extensions}/StdLib/Lib/importlib/abc.py (100%) rename src/{ => extensions}/StdLib/Lib/importlib/machinery.py (100%) rename src/{ => extensions}/StdLib/Lib/importlib/util.py (100%) rename src/{ => extensions}/StdLib/Lib/inspect.py (100%) rename src/{ => extensions}/StdLib/Lib/io.py (100%) rename src/{ => extensions}/StdLib/Lib/ipaddress.py (100%) rename src/{ => extensions}/StdLib/Lib/json/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/json/decoder.py (100%) rename src/{ => extensions}/StdLib/Lib/json/encoder.py (100%) rename src/{ => extensions}/StdLib/Lib/json/scanner.py (100%) rename src/{ => extensions}/StdLib/Lib/json/tool.py (100%) rename src/{ => extensions}/StdLib/Lib/keyword.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/Grammar.txt (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/PatternGrammar.txt (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/btm_matcher.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/btm_utils.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixer_base.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixer_util.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_apply.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_asserts.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_basestring.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_buffer.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_callable.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_dict.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_except.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_exec.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_execfile.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_filter.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_future.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_has_key.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_idioms.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_import.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_imports.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_imports2.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_input.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_intern.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_isinstance.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_itertools.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_long.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_map.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_metaclass.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_ne.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_next.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_nonzero.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_numliterals.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_operator.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_paren.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_print.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_raise.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_raw_input.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_reduce.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_reload.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_renames.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_repr.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_set_literal.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_standarderror.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_throw.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_types.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_unicode.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_urllib.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_xrange.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/fixes/fix_zip.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/main.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/patcomp.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/pgen2/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/pgen2/conv.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/pgen2/driver.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/pgen2/grammar.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/pgen2/literals.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/pgen2/parse.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/pgen2/pgen.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/pgen2/token.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/pgen2/tokenize.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/pygram.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/pytree.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/refactor.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/data/README (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/data/bom.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/data/crlf.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/data/different_encoding.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/data/false_encoding.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/pytree_idempotency.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/support.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/test_all_fixers.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/test_fixers.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/test_main.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/test_parser.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/test_pytree.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/test_refactor.py (100%) rename src/{ => extensions}/StdLib/Lib/lib2to3/tests/test_util.py (100%) rename src/{ => extensions}/StdLib/Lib/linecache.py (100%) rename src/{ => extensions}/StdLib/Lib/locale.py (100%) rename src/{ => extensions}/StdLib/Lib/logging/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/logging/config.py (100%) rename src/{ => extensions}/StdLib/Lib/logging/handlers.py (100%) rename src/{ => extensions}/StdLib/Lib/lzma.py (100%) rename src/{ => extensions}/StdLib/Lib/macpath.py (100%) rename src/{ => extensions}/StdLib/Lib/macurl2path.py (100%) rename src/{ => extensions}/StdLib/Lib/mailbox.py (100%) rename src/{ => extensions}/StdLib/Lib/mailcap.py (100%) rename src/{ => extensions}/StdLib/Lib/mimetypes.py (100%) rename src/{ => extensions}/StdLib/Lib/modulefinder.py (100%) rename src/{ => extensions}/StdLib/Lib/msilib/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/msilib/schema.py (100%) rename src/{ => extensions}/StdLib/Lib/msilib/sequence.py (100%) rename src/{ => extensions}/StdLib/Lib/msilib/text.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/connection.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/context.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/dummy/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/dummy/connection.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/forkserver.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/heap.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/managers.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/pool.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/popen_fork.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/popen_forkserver.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/popen_spawn_posix.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/popen_spawn_win32.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/process.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/queues.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/reduction.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/resource_sharer.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/semaphore_tracker.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/sharedctypes.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/spawn.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/synchronize.py (100%) rename src/{ => extensions}/StdLib/Lib/multiprocessing/util.py (100%) rename src/{ => extensions}/StdLib/Lib/netrc.py (100%) rename src/{ => extensions}/StdLib/Lib/nntplib.py (100%) rename src/{ => extensions}/StdLib/Lib/ntpath.py (100%) rename src/{ => extensions}/StdLib/Lib/nturl2path.py (100%) rename src/{ => extensions}/StdLib/Lib/numbers.py (100%) rename src/{ => extensions}/StdLib/Lib/opcode.py (100%) rename src/{ => extensions}/StdLib/Lib/operator.py (100%) rename src/{ => extensions}/StdLib/Lib/optparse.py (100%) rename src/{ => extensions}/StdLib/Lib/os.py (100%) rename src/{ => extensions}/StdLib/Lib/pathlib.py (100%) rename src/{ => extensions}/StdLib/Lib/pdb.py (100%) rename src/{ => extensions}/StdLib/Lib/pickle.py (100%) rename src/{ => extensions}/StdLib/Lib/pickletools.py (100%) rename src/{ => extensions}/StdLib/Lib/pipes.py (100%) rename src/{ => extensions}/StdLib/Lib/pkgutil.py (100%) rename src/{ => extensions}/StdLib/Lib/platform.py (100%) rename src/{ => extensions}/StdLib/Lib/plistlib.py (100%) rename src/{ => extensions}/StdLib/Lib/poplib.py (100%) rename src/{ => extensions}/StdLib/Lib/posixpath.py (100%) rename src/{ => extensions}/StdLib/Lib/pprint.py (100%) rename src/{ => extensions}/StdLib/Lib/profile.py (100%) rename src/{ => extensions}/StdLib/Lib/pstats.py (100%) rename src/{ => extensions}/StdLib/Lib/pty.py (100%) rename src/{ => extensions}/StdLib/Lib/py_compile.py (100%) rename src/{ => extensions}/StdLib/Lib/pyclbr.py (100%) rename src/{ => extensions}/StdLib/Lib/pydoc.py (100%) rename src/{ => extensions}/StdLib/Lib/pydoc_data/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/pydoc_data/_pydoc.css (100%) rename src/{ => extensions}/StdLib/Lib/pydoc_data/topics.py (100%) rename src/{ => extensions}/StdLib/Lib/queue.py (100%) rename src/{ => extensions}/StdLib/Lib/quopri.py (100%) rename src/{ => extensions}/StdLib/Lib/random.py (100%) rename src/{ => extensions}/StdLib/Lib/re.py (100%) rename src/{ => extensions}/StdLib/Lib/reprlib.py (100%) rename src/{ => extensions}/StdLib/Lib/rlcompleter.py (100%) rename src/{ => extensions}/StdLib/Lib/runpy.py (100%) rename src/{ => extensions}/StdLib/Lib/sched.py (100%) rename src/{ => extensions}/StdLib/Lib/selectors.py (100%) rename src/{ => extensions}/StdLib/Lib/shelve.py (100%) rename src/{ => extensions}/StdLib/Lib/shlex.py (100%) rename src/{ => extensions}/StdLib/Lib/shutil.py (100%) rename src/{ => extensions}/StdLib/Lib/site-packages/README (100%) rename src/{ => extensions}/StdLib/Lib/site.py (100%) rename src/{ => extensions}/StdLib/Lib/smtpd.py (100%) rename src/{ => extensions}/StdLib/Lib/smtplib.py (100%) rename src/{ => extensions}/StdLib/Lib/sndhdr.py (100%) rename src/{ => extensions}/StdLib/Lib/socket.py (100%) rename src/{ => extensions}/StdLib/Lib/socketserver.py (100%) rename src/{ => extensions}/StdLib/Lib/sqlite3/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/sqlite3/dbapi2.py (100%) rename src/{ => extensions}/StdLib/Lib/sqlite3/dump.py (100%) rename src/{ => extensions}/StdLib/Lib/sqlite3/test/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/sqlite3/test/dbapi.py (100%) rename src/{ => extensions}/StdLib/Lib/sqlite3/test/dump.py (100%) rename src/{ => extensions}/StdLib/Lib/sqlite3/test/factory.py (100%) rename src/{ => extensions}/StdLib/Lib/sqlite3/test/hooks.py (100%) rename src/{ => extensions}/StdLib/Lib/sqlite3/test/regression.py (100%) rename src/{ => extensions}/StdLib/Lib/sqlite3/test/transactions.py (100%) rename src/{ => extensions}/StdLib/Lib/sqlite3/test/types.py (100%) rename src/{ => extensions}/StdLib/Lib/sqlite3/test/userfunctions.py (100%) rename src/{ => extensions}/StdLib/Lib/sre_compile.py (100%) rename src/{ => extensions}/StdLib/Lib/sre_constants.py (100%) rename src/{ => extensions}/StdLib/Lib/sre_parse.py (100%) rename src/{ => extensions}/StdLib/Lib/ssl.py (100%) rename src/{ => extensions}/StdLib/Lib/stat.py (100%) rename src/{ => extensions}/StdLib/Lib/statistics.py (100%) rename src/{ => extensions}/StdLib/Lib/string.py (100%) rename src/{ => extensions}/StdLib/Lib/stringprep.py (100%) rename src/{ => extensions}/StdLib/Lib/struct.py (100%) rename src/{ => extensions}/StdLib/Lib/subprocess.py (100%) rename src/{ => extensions}/StdLib/Lib/sunau.py (100%) rename src/{ => extensions}/StdLib/Lib/symbol.py (100%) rename src/{ => extensions}/StdLib/Lib/symtable.py (100%) rename src/{ => extensions}/StdLib/Lib/sysconfig.py (100%) rename src/{ => extensions}/StdLib/Lib/tabnanny.py (100%) rename src/{ => extensions}/StdLib/Lib/tarfile.py (100%) rename src/{ => extensions}/StdLib/Lib/telnetlib.py (100%) rename src/{ => extensions}/StdLib/Lib/tempfile.py (100%) rename src/{ => extensions}/StdLib/Lib/test/185test.db (100%) rename src/{ => extensions}/StdLib/Lib/test/Sine-1000Hz-300ms.aif (100%) rename src/{ => extensions}/StdLib/Lib/test/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/_test_multiprocessing.py (100%) rename src/{ => extensions}/StdLib/Lib/test/audiodata/pluck-alaw.aifc (100%) rename src/{ => extensions}/StdLib/Lib/test/audiodata/pluck-pcm16.aiff (100%) rename src/{ => extensions}/StdLib/Lib/test/audiodata/pluck-pcm16.au (100%) rename src/{ => extensions}/StdLib/Lib/test/audiodata/pluck-pcm16.wav (100%) rename src/{ => extensions}/StdLib/Lib/test/audiodata/pluck-pcm24.aiff (100%) rename src/{ => extensions}/StdLib/Lib/test/audiodata/pluck-pcm24.au (100%) rename src/{ => extensions}/StdLib/Lib/test/audiodata/pluck-pcm24.wav (100%) rename src/{ => extensions}/StdLib/Lib/test/audiodata/pluck-pcm32.aiff (100%) rename src/{ => extensions}/StdLib/Lib/test/audiodata/pluck-pcm32.au (100%) rename src/{ => extensions}/StdLib/Lib/test/audiodata/pluck-pcm32.wav (100%) rename src/{ => extensions}/StdLib/Lib/test/audiodata/pluck-pcm8.aiff (100%) rename src/{ => extensions}/StdLib/Lib/test/audiodata/pluck-pcm8.au (100%) rename src/{ => extensions}/StdLib/Lib/test/audiodata/pluck-pcm8.wav (100%) rename src/{ => extensions}/StdLib/Lib/test/audiodata/pluck-ulaw.aifc (100%) rename src/{ => extensions}/StdLib/Lib/test/audiodata/pluck-ulaw.au (100%) rename src/{ => extensions}/StdLib/Lib/test/audiotest.au (100%) rename src/{ => extensions}/StdLib/Lib/test/audiotests.py (100%) rename src/{ => extensions}/StdLib/Lib/test/autotest.py (100%) rename src/{ => extensions}/StdLib/Lib/test/bad_coding.py (100%) rename src/{ => extensions}/StdLib/Lib/test/bad_coding2.py (100%) rename src/{ => extensions}/StdLib/Lib/test/badcert.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/badkey.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/badsyntax_3131.py (100%) rename src/{ => extensions}/StdLib/Lib/test/badsyntax_future10.py (100%) rename src/{ => extensions}/StdLib/Lib/test/badsyntax_future3.py (100%) rename src/{ => extensions}/StdLib/Lib/test/badsyntax_future4.py (100%) rename src/{ => extensions}/StdLib/Lib/test/badsyntax_future5.py (100%) rename src/{ => extensions}/StdLib/Lib/test/badsyntax_future6.py (100%) rename src/{ => extensions}/StdLib/Lib/test/badsyntax_future7.py (100%) rename src/{ => extensions}/StdLib/Lib/test/badsyntax_future8.py (100%) rename src/{ => extensions}/StdLib/Lib/test/badsyntax_future9.py (100%) rename src/{ => extensions}/StdLib/Lib/test/badsyntax_pep3120.py (100%) rename src/{ => extensions}/StdLib/Lib/test/buffer_tests.py (100%) rename src/{ => extensions}/StdLib/Lib/test/bytecode_helper.py (100%) rename src/{ => extensions}/StdLib/Lib/test/capath/0e4015b9.0 (100%) rename src/{ => extensions}/StdLib/Lib/test/capath/4e1295a3.0 (100%) rename src/{ => extensions}/StdLib/Lib/test/capath/5ed36f99.0 (100%) rename src/{ => extensions}/StdLib/Lib/test/capath/6e88d7b8.0 (100%) rename src/{ => extensions}/StdLib/Lib/test/capath/99d0fa06.0 (100%) rename src/{ => extensions}/StdLib/Lib/test/capath/ce7b8643.0 (100%) rename src/{ => extensions}/StdLib/Lib/test/cfgparser.1 (100%) rename src/{ => extensions}/StdLib/Lib/test/cfgparser.2 (100%) rename src/{ => extensions}/StdLib/Lib/test/cfgparser.3 (100%) rename src/{ => extensions}/StdLib/Lib/test/check_soundcard.vbs (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/big5-utf8.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/big5.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/big5hkscs.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/cp949-utf8.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/cp949.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/euc_jp.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/euc_kr.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/gb18030.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/gb2312.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/gbk-utf8.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/gbk.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/hz-utf8.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/hz.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/iso2022_jp.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/iso2022_kr.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/johab-utf8.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/johab.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/shift_jis.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/cmath_testcases.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/coding20731.py (100%) rename src/{ => extensions}/StdLib/Lib/test/crashers/README (100%) rename src/{ => extensions}/StdLib/Lib/test/crashers/bogus_code_obj.py (100%) rename src/{ => extensions}/StdLib/Lib/test/crashers/gc_inspection.py (100%) rename src/{ => extensions}/StdLib/Lib/test/crashers/infinite_loop_re.py (100%) rename src/{ => extensions}/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py (100%) rename src/{ => extensions}/StdLib/Lib/test/crashers/recursive_call.py (100%) rename src/{ => extensions}/StdLib/Lib/test/crashers/trace_at_recursion_limit.py (100%) rename src/{ => extensions}/StdLib/Lib/test/crashers/underlying_dict.py (100%) rename src/{ => extensions}/StdLib/Lib/test/curses_tests.py (100%) rename src/{ => extensions}/StdLib/Lib/test/data/README (100%) rename src/{ => extensions}/StdLib/Lib/test/datetimetester.py (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/abs.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/add.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/and.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/base.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/clamp.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/class.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/compare.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/comparetotal.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/copy.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/copyabs.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/copynegate.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/copysign.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddAbs.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddAdd.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddAnd.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddBase.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddClass.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddCompare.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddCopy.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddDivide.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddEncode.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddFMA.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddInvert.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddLogB.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddMax.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddMin.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddMinus.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddOr.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddPlus.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddReduce.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddRotate.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddShift.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ddXor.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/decDouble.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/decQuad.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/decSingle.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/divide.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/divideint.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqAbs.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqAdd.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqAnd.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqBase.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqClass.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqCompare.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqCopy.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqDivide.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqEncode.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqFMA.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqInvert.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqLogB.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqMax.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqMin.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqMinus.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqOr.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqPlus.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqReduce.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqRotate.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqShift.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dqXor.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dsBase.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/dsEncode.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/exp.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/extra.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/fma.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/inexact.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/invert.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/ln.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/log10.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/logb.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/max.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/maxmag.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/min.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/minmag.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/minus.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/multiply.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/nextminus.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/nextplus.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/nexttoward.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/or.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/plus.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/power.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/powersqrt.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/quantize.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/randomBound32.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/randoms.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/reduce.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/remainder.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/remainderNear.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/rescale.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/rotate.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/rounding.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/samequantum.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/scaleb.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/shift.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/squareroot.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/subtract.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/testall.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/tointegral.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/tointegralx.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/decimaltestdata/xor.decTest (100%) rename src/{ => extensions}/StdLib/Lib/test/dh1024.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/dis_module.py (100%) rename src/{ => extensions}/StdLib/Lib/test/doctest_aliases.py (100%) rename src/{ => extensions}/StdLib/Lib/test/double_const.py (100%) rename src/{ => extensions}/StdLib/Lib/test/empty.vbs (100%) rename src/{ => extensions}/StdLib/Lib/test/encoded_modules/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py (100%) rename src/{ => extensions}/StdLib/Lib/test/encoded_modules/module_koi8_r.py (100%) rename src/{ => extensions}/StdLib/Lib/test/exception_hierarchy.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/final_a.py (100%) rename src/{ => extensions}/StdLib/Lib/test/final_b.py (100%) rename src/{ => extensions}/StdLib/Lib/test/floating_points.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/fork_wait.py (100%) rename src/{ => extensions}/StdLib/Lib/test/formatfloat_testcases.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/future_test1.py (100%) rename src/{ => extensions}/StdLib/Lib/test/future_test2.py (100%) rename src/{ => extensions}/StdLib/Lib/test/gdb_sample.py (100%) rename src/{ => extensions}/StdLib/Lib/test/ieee754.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/imghdrdata/python.bmp (100%) rename src/{ => extensions}/StdLib/Lib/test/imghdrdata/python.gif (100%) rename src/{ => extensions}/StdLib/Lib/test/imghdrdata/python.jpg (100%) rename src/{ => extensions}/StdLib/Lib/test/imghdrdata/python.pbm (100%) rename src/{ => extensions}/StdLib/Lib/test/imghdrdata/python.pgm (100%) rename src/{ => extensions}/StdLib/Lib/test/imghdrdata/python.png (100%) rename src/{ => extensions}/StdLib/Lib/test/imghdrdata/python.ppm (100%) rename src/{ => extensions}/StdLib/Lib/test/imghdrdata/python.ras (100%) rename src/{ => extensions}/StdLib/Lib/test/imghdrdata/python.sgi (100%) rename src/{ => extensions}/StdLib/Lib/test/imghdrdata/python.tiff (100%) rename src/{ => extensions}/StdLib/Lib/test/imghdrdata/python.xbm (100%) rename src/{ => extensions}/StdLib/Lib/test/inspect_fodder.py (100%) rename src/{ => extensions}/StdLib/Lib/test/inspect_fodder2.py (100%) rename src/{ => extensions}/StdLib/Lib/test/keycert.passwd.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/keycert.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/keycert2.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/keycert3.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/keycert4.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/leakers/README.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/leakers/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/leakers/test_ctypes.py (100%) rename src/{ => extensions}/StdLib/Lib/test/leakers/test_selftype.py (100%) rename src/{ => extensions}/StdLib/Lib/test/list_tests.py (100%) rename src/{ => extensions}/StdLib/Lib/test/lock_tests.py (100%) rename src/{ => extensions}/StdLib/Lib/test/mailcap.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/make_ssl_certs.py (100%) rename src/{ => extensions}/StdLib/Lib/test/mapping_tests.py (100%) rename src/{ => extensions}/StdLib/Lib/test/math_testcases.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/memory_watchdog.py (100%) rename src/{ => extensions}/StdLib/Lib/test/mime.types (100%) rename src/{ => extensions}/StdLib/Lib/test/mock_socket.py (100%) rename src/{ => extensions}/StdLib/Lib/test/mod_generics_cache.py (100%) rename src/{ => extensions}/StdLib/Lib/test/mp_fork_bomb.py (100%) rename src/{ => extensions}/StdLib/Lib/test/multibytecodec_support.py (100%) rename src/{ => extensions}/StdLib/Lib/test/nokia.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/nullbytecert.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/nullcert.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/outstanding_bugs.py (100%) rename src/{ => extensions}/StdLib/Lib/test/pickletester.py (100%) rename src/{ => extensions}/StdLib/Lib/test/profilee.py (100%) rename src/{ => extensions}/StdLib/Lib/test/pstats.pck (100%) rename src/{ => extensions}/StdLib/Lib/test/pycacert.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/pycakey.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/pyclbr_input.py (100%) rename src/{ => extensions}/StdLib/Lib/test/pydoc_mod.py (100%) rename src/{ => extensions}/StdLib/Lib/test/pydocfodder.py (100%) rename src/{ => extensions}/StdLib/Lib/test/pystone.py (100%) rename src/{ => extensions}/StdLib/Lib/test/randv2_32.pck (100%) rename src/{ => extensions}/StdLib/Lib/test/randv2_64.pck (100%) rename src/{ => extensions}/StdLib/Lib/test/randv3.pck (100%) rename src/{ => extensions}/StdLib/Lib/test/re_tests.py (100%) rename src/{ => extensions}/StdLib/Lib/test/regrtest.py (100%) rename src/{ => extensions}/StdLib/Lib/test/relimport.py (100%) rename src/{ => extensions}/StdLib/Lib/test/reperf.py (100%) rename src/{ => extensions}/StdLib/Lib/test/revocation.crl (100%) rename src/{ => extensions}/StdLib/Lib/test/sample_doctest.py (100%) rename src/{ => extensions}/StdLib/Lib/test/sample_doctest_no_docstrings.py (100%) rename src/{ => extensions}/StdLib/Lib/test/sample_doctest_no_doctests.py (100%) rename src/{ => extensions}/StdLib/Lib/test/script_helper.py (100%) rename src/{ => extensions}/StdLib/Lib/test/selfsigned_pythontestdotnet.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/seq_tests.py (100%) rename src/{ => extensions}/StdLib/Lib/test/sgml_input.html (100%) rename src/{ => extensions}/StdLib/Lib/test/sha256.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/sndhdrdata/README (100%) rename src/{ => extensions}/StdLib/Lib/test/sndhdrdata/sndhdr.8svx (100%) rename src/{ => extensions}/StdLib/Lib/test/sndhdrdata/sndhdr.aifc (100%) rename src/{ => extensions}/StdLib/Lib/test/sndhdrdata/sndhdr.aiff (100%) rename src/{ => extensions}/StdLib/Lib/test/sndhdrdata/sndhdr.au (100%) rename src/{ => extensions}/StdLib/Lib/test/sndhdrdata/sndhdr.hcom (100%) rename src/{ => extensions}/StdLib/Lib/test/sndhdrdata/sndhdr.sndt (100%) rename src/{ => extensions}/StdLib/Lib/test/sndhdrdata/sndhdr.voc (100%) rename src/{ => extensions}/StdLib/Lib/test/sndhdrdata/sndhdr.wav (100%) rename src/{ => extensions}/StdLib/Lib/test/sortperf.py (100%) rename src/{ => extensions}/StdLib/Lib/test/ssl_cert.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/ssl_key.passwd.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/ssl_key.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/ssl_servers.py (100%) rename src/{ => extensions}/StdLib/Lib/test/ssltests.py (100%) rename src/{ => extensions}/StdLib/Lib/test/string_tests.py (100%) rename src/{ => extensions}/StdLib/Lib/test/subprocessdata/fd_status.py (100%) rename src/{ => extensions}/StdLib/Lib/test/subprocessdata/input_reader.py (100%) rename src/{ => extensions}/StdLib/Lib/test/subprocessdata/qcat.py (100%) rename src/{ => extensions}/StdLib/Lib/test/subprocessdata/qgrep.py (100%) rename src/{ => extensions}/StdLib/Lib/test/subprocessdata/sigchild_ignore.py (100%) rename src/{ => extensions}/StdLib/Lib/test/support/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/talos-2019-0758.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/test___all__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test___future__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test__locale.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test__opcode.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test__osx_support.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_abc.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_abstract_numbers.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_aifc.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_argparse.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_array.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_ast.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asynchat.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/echo.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/echo2.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/echo3.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/keycert3.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/pycacert.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/ssl_cert.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/ssl_key.pem (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/test_base_events.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/test_events.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/test_futures.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/test_locks.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/test_proactor_events.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/test_queues.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/test_selector_events.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/test_sslproto.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/test_streams.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/test_subprocess.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/test_tasks.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/test_transports.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/test_unix_events.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/test_windows_events.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncio/test_windows_utils.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_asyncore.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_atexit.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_audioop.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_augassign.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_base64.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_bigaddrspace.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_bigmem.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_binascii.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_binhex.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_binop.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_bisect.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_bool.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_buffer.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_bufio.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_builtin.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_bytes.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_bz2.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_calendar.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_call.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_capi.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_cgi.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_cgitb.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_charmapcodec.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_class.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_cmath.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_cmd.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_cmd_line.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_cmd_line_script.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_code.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_code_module.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_codeccallbacks.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_codecencodings_cn.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_codecencodings_hk.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_codecencodings_iso2022.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_codecencodings_jp.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_codecencodings_kr.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_codecencodings_tw.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_codecmaps_cn.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_codecmaps_hk.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_codecmaps_jp.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_codecmaps_kr.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_codecmaps_tw.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_codecs.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_codeop.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_collections.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_colorsys.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_compare.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_compile.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_compileall.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_complex.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_concurrent_futures.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_configparser.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_contains.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_contextlib.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_copy.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_copyreg.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_cprofile.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_crashers.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_crypt.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_csv.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_ctypes.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_curses.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_datetime.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_dbm.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_dbm_dumb.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_dbm_gnu.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_dbm_ndbm.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_decimal.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_decorators.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_defaultdict.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_deque.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_descr.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_descrtut.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_devpoll.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_dict.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_dictcomps.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_dictviews.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_difflib.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_difflib_expect.html (100%) rename src/{ => extensions}/StdLib/Lib/test/test_dis.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_distutils.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_doctest.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_doctest.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_doctest2.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_doctest2.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_doctest3.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_doctest4.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_docxmlrpc.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_dummy_thread.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_dummy_threading.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_dynamic.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_dynamicclassattribute.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/PyBanner048.gif (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/audiotest.au (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_01.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_02.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_03.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_04.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_05.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_06.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_07.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_08.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_09.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_10.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_11.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_12.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_12a.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_13.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_14.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_15.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_16.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_17.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_18.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_19.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_20.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_21.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_22.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_23.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_24.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_25.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_26.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_27.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_28.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_29.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_30.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_31.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_32.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_33.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_34.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_35.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_36.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_37.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_38.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_39.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_40.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_41.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_42.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_43.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_44.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_45.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/data/msg_46.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/test__encoded_words.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/test__header_value_parser.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/test_asian_codecs.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/test_contentmanager.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/test_defect_handling.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/test_email.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/test_generator.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/test_headerregistry.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/test_inversion.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/test_message.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/test_parser.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/test_pickleable.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/test_policy.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/test_utils.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_email/torture_test.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_ensurepip.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_enum.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_enumerate.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_eof.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_epoll.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_errno.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_exception_variations.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_exceptions.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_extcall.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_faulthandler.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_fcntl.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_file.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_file_eintr.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_filecmp.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_fileinput.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_fileio.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_finalization.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_float.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_flufl.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_fnmatch.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_fork1.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_format.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_fractions.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_frame.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_fstring.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_ftplib.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_funcattrs.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_functools.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_future.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_future3.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_future4.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_future5.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_gc.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_gdb.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_generators.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_genericpath.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_genexps.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_getargs2.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_getopt.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_getpass.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_gettext.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_glob.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_global.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_grammar.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_grp.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_gzip.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_hash.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_hashlib.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_heapq.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_hmac.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_html.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_htmlparser.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_http_cookiejar.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_http_cookies.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_httplib.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_httpservers.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_idle.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_imaplib.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_imghdr.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_imp.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_import.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/abc.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/builtin/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/builtin/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/builtin/test_finder.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/builtin/test_loader.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/builtin/util.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/extension/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/extension/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/extension/test_finder.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/extension/test_loader.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/extension/test_path_hook.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/extension/util.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/frozen/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/frozen/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/frozen/test_finder.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/frozen/test_loader.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/import_/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/import_/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/import_/test___loader__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/import_/test___package__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/import_/test_api.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/import_/test_caching.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/import_/test_fromlist.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/import_/test_meta_path.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/import_/test_packages.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/import_/test_path.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/import_/util.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/regrtest.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/source/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/source/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/source/test_file_loader.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/source/test_finder.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/source/test_path_hook.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/source/test_source_encoding.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/source/util.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/test_abc.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/test_api.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/test_locks.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/test_spec.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/test_util.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/test_windows.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_importlib/util.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_index.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_inspect.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_int.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_int_literal.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_io.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_ioctl.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_ipaddress.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_isinstance.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_iter.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_iterlen.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_itertools.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_json/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_json/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_json/test_decode.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_json/test_default.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_json/test_dump.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_json/test_enum.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_json/test_fail.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_json/test_float.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_json/test_indent.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_json/test_pass1.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_json/test_pass2.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_json/test_pass3.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_json/test_recursion.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_json/test_scanstring.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_json/test_separators.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_json/test_speedups.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_json/test_tool.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_json/test_unicode.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_keyword.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_keywordonlyarg.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_kqueue.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_largefile.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_lib2to3.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_linecache.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_list.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_listcomps.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_locale.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_logging.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_long.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_longexp.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_lzma.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_macpath.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_macurl2path.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_mailbox.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_mailcap.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_marshal.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_math.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_memoryio.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_memoryview.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_metaclass.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_mimetypes.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_minidom.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_mmap.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_module.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_modulefinder.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_msilib.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_multibytecodec.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_multiprocessing_fork.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_multiprocessing_forkserver.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_multiprocessing_main_handling.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_multiprocessing_spawn.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_netrc.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_nis.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_nntplib.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_normalization.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_ntpath.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_numeric_tower.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_opcodes.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_openpty.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_operator.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_optparse.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_ordered_dict.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_os.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_ossaudiodev.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_osx_env.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_parser.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pathlib.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pdb.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_peepholer.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pep247.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pep277.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pep292.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pep3120.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pep3131.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pep3151.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pep352.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pep380.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pep479.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pickle.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pickletools.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pipes.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pkg.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pkgimport.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pkgutil.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_platform.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_plistlib.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_poll.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_popen.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_poplib.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_posix.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_posixpath.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pow.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pprint.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_print.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_profile.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_property.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pstats.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pty.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pulldom.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pwd.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_py_compile.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pyclbr.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pydoc.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_pyexpat.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_queue.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_quopri.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_raise.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_random.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_range.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_re.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_readline.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_regrtest.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_reprlib.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_resource.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_richcmp.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_rlcompleter.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_robotparser.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_runpy.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_sax.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_sched.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_scope.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_script_helper.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_select.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_selectors.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_set.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_setcomps.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_shelve.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_shlex.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_shutil.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_signal.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_site.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_slice.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_smtpd.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_smtplib.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_smtpnet.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_sndhdr.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_socket.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_socketserver.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_sort.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_source_encoding.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_spwd.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_sqlite.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_ssl.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_startfile.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_stat.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_statistics.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_strftime.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_string.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_stringprep.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_strlit.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_strptime.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_strtod.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_struct.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_structmembers.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_structseq.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_subprocess.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_sunau.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_sundry.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_super.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_support.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_symtable.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_syntax.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_sys.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_sys_setprofile.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_sys_settrace.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_sysconfig.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_syslog.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_tarfile.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_tcl.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_telnetlib.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_tempfile.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_textwrap.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_thread.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_threaded_import.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_threadedtempfile.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_threading.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_threading_local.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_threadsignals.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_time.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_timeit.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_timeout.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_tk.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_tokenize.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_tools/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_tools/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_tools/test_gprof2html.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_tools/test_md5sum.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_tools/test_pdeps.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_tools/test_pindent.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_tools/test_reindent.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_tools/test_sundry.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_tools/test_unparse.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_trace.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_traceback.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_tracemalloc.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_ttk_guionly.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_ttk_textonly.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_tuple.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_typechecks.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_types.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_typing.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_ucn.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_unary.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_unicode.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_unicode_file.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_unicodedata.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_unittest.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_univnewlines.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_unpack.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_unpack_ex.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_urllib.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_urllib2.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_urllib2_localnet.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_urllib2net.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_urllib_response.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_urllibnet.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_urlparse.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_userdict.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_userlist.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_userstring.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_utf8_mode.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_uu.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_uuid.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_venv.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_wait3.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_wait4.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_warnings.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_wave.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_weakref.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_weakset.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_webbrowser.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_winreg.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_winsound.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_with.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_wsgiref.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_xdrlib.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_xml_dom_minicompat.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_xml_etree.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_xml_etree_c.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_xmlrpc.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_xmlrpc_net.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_zipfile.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_zipfile64.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_zipimport.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_zipimport_support.py (100%) rename src/{ => extensions}/StdLib/Lib/test/test_zlib.py (100%) rename src/{ => extensions}/StdLib/Lib/test/testcodec.py (100%) rename src/{ => extensions}/StdLib/Lib/test/testtar.tar (100%) rename src/{ => extensions}/StdLib/Lib/test/tf_inherit_check.py (100%) rename src/{ => extensions}/StdLib/Lib/test/threaded_import_hangers.py (100%) rename src/{ => extensions}/StdLib/Lib/test/time_hashlib.py (100%) rename src/{ => extensions}/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/tokenize_tests.txt (100%) rename src/{ => extensions}/StdLib/Lib/test/tracedmodules/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/test/tracedmodules/testmod.py (100%) rename src/{ => extensions}/StdLib/Lib/test/warning_tests.py (100%) rename src/{ => extensions}/StdLib/Lib/test/win_console_handler.py (100%) rename src/{ => extensions}/StdLib/Lib/test/xmltestdata/simple-ns.xml (100%) rename src/{ => extensions}/StdLib/Lib/test/xmltestdata/simple.xml (100%) rename src/{ => extensions}/StdLib/Lib/test/xmltestdata/test.xml (100%) rename src/{ => extensions}/StdLib/Lib/test/xmltestdata/test.xml.out (100%) rename src/{ => extensions}/StdLib/Lib/test/xmltests.py (100%) rename src/{ => extensions}/StdLib/Lib/test/zip_cp437_header.zip (100%) rename src/{ => extensions}/StdLib/Lib/test/zipdir.zip (100%) rename src/{ => extensions}/StdLib/Lib/textwrap.py (100%) rename src/{ => extensions}/StdLib/Lib/this.py (100%) rename src/{ => extensions}/StdLib/Lib/threading.py (100%) rename src/{ => extensions}/StdLib/Lib/timeit.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/_fix.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/colorchooser.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/commondialog.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/constants.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/dialog.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/dnd.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/filedialog.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/font.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/messagebox.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/scrolledtext.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/simpledialog.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/test/README (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/test/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/test/runtktests.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/test/support.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/test/test_tkinter/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/test/test_tkinter/test_font.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/test/test_tkinter/test_images.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/test/test_tkinter/test_text.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/test/test_ttk/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/test/test_ttk/test_functions.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/test/test_ttk/test_style.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/test/widget_tests.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/tix.py (100%) rename src/{ => extensions}/StdLib/Lib/tkinter/ttk.py (100%) rename src/{ => extensions}/StdLib/Lib/token.py (100%) rename src/{ => extensions}/StdLib/Lib/tokenize.py (100%) rename src/{ => extensions}/StdLib/Lib/trace.py (100%) rename src/{ => extensions}/StdLib/Lib/traceback.py (100%) rename src/{ => extensions}/StdLib/Lib/tracemalloc.py (100%) rename src/{ => extensions}/StdLib/Lib/tty.py (100%) rename src/{ => extensions}/StdLib/Lib/turtle.py (100%) rename src/{ => extensions}/StdLib/Lib/turtledemo/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/turtledemo/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/turtledemo/bytedesign.py (100%) rename src/{ => extensions}/StdLib/Lib/turtledemo/chaos.py (100%) rename src/{ => extensions}/StdLib/Lib/turtledemo/clock.py (100%) rename src/{ => extensions}/StdLib/Lib/turtledemo/colormixer.py (100%) rename src/{ => extensions}/StdLib/Lib/turtledemo/forest.py (100%) rename src/{ => extensions}/StdLib/Lib/turtledemo/fractalcurves.py (100%) rename src/{ => extensions}/StdLib/Lib/turtledemo/lindenmayer.py (100%) rename src/{ => extensions}/StdLib/Lib/turtledemo/minimal_hanoi.py (100%) rename src/{ => extensions}/StdLib/Lib/turtledemo/nim.py (100%) rename src/{ => extensions}/StdLib/Lib/turtledemo/paint.py (100%) rename src/{ => extensions}/StdLib/Lib/turtledemo/peace.py (100%) rename src/{ => extensions}/StdLib/Lib/turtledemo/penrose.py (100%) rename src/{ => extensions}/StdLib/Lib/turtledemo/planet_and_moon.py (100%) rename src/{ => extensions}/StdLib/Lib/turtledemo/round_dance.py (100%) rename src/{ => extensions}/StdLib/Lib/turtledemo/tree.py (100%) rename src/{ => extensions}/StdLib/Lib/turtledemo/turtle.cfg (100%) rename src/{ => extensions}/StdLib/Lib/turtledemo/two_canvases.py (100%) rename src/{ => extensions}/StdLib/Lib/turtledemo/wikipedia.py (100%) rename src/{ => extensions}/StdLib/Lib/turtledemo/yinyang.py (100%) rename src/{ => extensions}/StdLib/Lib/types.py (100%) rename src/{ => extensions}/StdLib/Lib/typing.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/case.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/loader.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/main.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/mock.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/result.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/runner.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/signals.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/suite.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/_test_warnings.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/dummy.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/support.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/test_assertions.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/test_break.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/test_case.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/test_discovery.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/test_functiontestcase.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/test_loader.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/test_program.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/test_result.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/test_runner.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/test_setups.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/test_skipping.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/test_suite.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/testmock/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/testmock/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/testmock/support.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/testmock/testcallable.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/testmock/testhelpers.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/testmock/testmagicmethods.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/testmock/testmock.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/testmock/testpatch.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/testmock/testsentinel.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/test/testmock/testwith.py (100%) rename src/{ => extensions}/StdLib/Lib/unittest/util.py (100%) rename src/{ => extensions}/StdLib/Lib/urllib/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/urllib/error.py (100%) rename src/{ => extensions}/StdLib/Lib/urllib/parse.py (100%) rename src/{ => extensions}/StdLib/Lib/urllib/request.py (100%) rename src/{ => extensions}/StdLib/Lib/urllib/response.py (100%) rename src/{ => extensions}/StdLib/Lib/urllib/robotparser.py (100%) rename src/{ => extensions}/StdLib/Lib/uu.py (100%) rename src/{ => extensions}/StdLib/Lib/uuid.py (100%) rename src/{ => extensions}/StdLib/Lib/venv/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/venv/__main__.py (100%) rename src/{ => extensions}/StdLib/Lib/venv/scripts/nt/Activate.ps1 (100%) rename src/{ => extensions}/StdLib/Lib/venv/scripts/nt/activate.bat (100%) rename src/{ => extensions}/StdLib/Lib/venv/scripts/nt/deactivate.bat (100%) rename src/{ => extensions}/StdLib/Lib/venv/scripts/posix/activate (100%) rename src/{ => extensions}/StdLib/Lib/venv/scripts/posix/activate.csh (100%) rename src/{ => extensions}/StdLib/Lib/venv/scripts/posix/activate.fish (100%) rename src/{ => extensions}/StdLib/Lib/warnings.py (100%) rename src/{ => extensions}/StdLib/Lib/wave.py (100%) rename src/{ => extensions}/StdLib/Lib/weakref.py (100%) rename src/{ => extensions}/StdLib/Lib/webbrowser.py (100%) rename src/{ => extensions}/StdLib/Lib/wpf.py (100%) rename src/{ => extensions}/StdLib/Lib/wsgiref/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/wsgiref/handlers.py (100%) rename src/{ => extensions}/StdLib/Lib/wsgiref/headers.py (100%) rename src/{ => extensions}/StdLib/Lib/wsgiref/simple_server.py (100%) rename src/{ => extensions}/StdLib/Lib/wsgiref/util.py (100%) rename src/{ => extensions}/StdLib/Lib/wsgiref/validate.py (100%) rename src/{ => extensions}/StdLib/Lib/xdrlib.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/dom/NodeFilter.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/dom/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/dom/domreg.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/dom/expatbuilder.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/dom/minicompat.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/dom/minidom.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/dom/pulldom.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/dom/xmlbuilder.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/etree/ElementInclude.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/etree/ElementPath.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/etree/ElementTree.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/etree/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/etree/cElementTree.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/parsers/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/parsers/expat.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/sax/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/sax/_exceptions.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/sax/expatreader.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/sax/handler.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/sax/saxutils.py (100%) rename src/{ => extensions}/StdLib/Lib/xml/sax/xmlreader.py (100%) rename src/{ => extensions}/StdLib/Lib/xmlrpc/__init__.py (100%) rename src/{ => extensions}/StdLib/Lib/xmlrpc/client.py (100%) rename src/{ => extensions}/StdLib/Lib/xmlrpc/server.py (100%) rename src/{ => extensions}/StdLib/Lib/zipfile.py (100%) rename src/{ => extensions}/StdLib/StdLib.License.txt (100%) rename src/{ => extensions}/StdLib/StdLib.pyproj (100%) rename src/{ => extensions}/StdLib/stdlib-upgrade.txt (100%) rename src/{ => extensions}/StdLib/update-stdlib.cmd (100%) rename src/{ => extensions}/StdLib/update-stdlib.sh (100%) rename src/{ => ipy}/CTypes/Makefile (100%) rename src/{ => ipy}/CTypes/_ctypes_test.c (100%) rename src/{ => ipy}/CTypes/_ctypes_test.sln (100%) rename src/{ => ipy}/CTypes/_ctypes_test.vcxproj (100%) rename src/{CompilerServices => ipy/IronPython.CompilerServices}/AssemblyResolver.cs (100%) rename src/{CompilerServices => ipy/IronPython.CompilerServices}/Config.cs (100%) rename src/{CompilerServices => ipy/IronPython.CompilerServices}/ConsoleOps.cs (100%) rename src/{CompilerServices => ipy/IronPython.CompilerServices}/IronPython.CompilerServices.csproj (100%) rename src/{CompilerServices => ipy/IronPython.CompilerServices}/Program.cs (100%) rename src/{CompilerServices => ipy/IronPython.CompilerServices}/Properties/AssemblyInfo.cs (100%) rename src/{CompilerServices => ipy/IronPython.CompilerServices}/README.md (100%) rename src/{Modules => ipy/IronPython.Modules}/IronPython.Modules.csproj (100%) rename src/{Modules => ipy/IronPython.Modules}/IterTools.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/ModuleOps.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/NtSignalState.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/Properties/AssemblyInfo.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/ResourceMetaPathImporter.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/SimpleSignalState.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_bisect.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_codecs.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_codecs_cn.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_collections.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_csv.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/Array.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/ArrayType.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/CData.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/CFuncPtr.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/CFuncPtrType.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/Extensions.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/Field.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/INativeType.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/LocalOrArg.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/MarshalCleanup.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/MemoryHolder.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/NativeArgument.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/NativeFunctions.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/Pointer.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/PointerType.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/SimpleCData.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/SimpleType.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/SimpleTypeKind.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/StructType.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/Structure.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/Union.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/UnionType.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes/_ctypes.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ctypes_test.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_datetime.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_functools.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_heapq.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_multibytecodec.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_multiprocessing.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_opcode.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_operator.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_overlapped.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_pickle.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_posixsubprocess.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_random.RandomGen.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_random.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_socket.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_sre.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_ssl.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_string.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_struct.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_sysconfigdata.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_thread.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_warnings.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_weakref.Generated.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_weakref.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/_winapi.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/array.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/atexit.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/audioop.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/binascii.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/bz2/BZ2Compressor.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/bz2/BZ2Decompressor.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/bz2/BZ2Module.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/bz2/dotnetzip/BZip2/BZip2Compressor.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/bz2/dotnetzip/BZip2/BZip2InputStream.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/bz2/dotnetzip/BZip2/BZip2OutputStream.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/bz2/dotnetzip/BZip2/BitWriter.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/bz2/dotnetzip/BZip2/CRC32.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/bz2/dotnetzip/BZip2/Rand.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/bz2/dotnetzip/source.txt (100%) rename src/{Modules => ipy/IronPython.Modules}/cmath.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/errno.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/faulthandler.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/fcntl.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/gc.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/grp.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/hashlib/MD5CryptoServiceProvider.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/hashlib/SHA1CryptoServiceProvider.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/hashlib/SHA224.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/hashlib/SHA224Managed.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/hashlib/SHA256Managed.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/hashlib/SHA384Managed.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/hashlib/SHA512Managed.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/hashlib/SHAConstants.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/hashlib/_hashlib.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/hashlib/_md5.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/hashlib/_sha1.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/hashlib/_sha256.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/hashlib/_sha512.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/marshal.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/math.Generated.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/math.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/mmap.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/msvcrt.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/nt.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/policy.IronPython.Modules.config (100%) rename src/{Modules => ipy/IronPython.Modules}/pwd.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/pyexpat.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/re.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/resource.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/select.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/signal.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/spwd.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/time.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/winreg.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/winsound.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/xxsubtype.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/zipimport.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/zlib/Compress.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/zlib/Decompress.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/zlib/ZlibModule.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/zlib/zlib.net/Adler32.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/zlib/zlib.net/Deflate.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/zlib/zlib.net/InfBlocks.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/zlib/zlib.net/InfCodes.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/zlib/zlib.net/InfTree.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/zlib/zlib.net/Inflate.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/zlib/zlib.net/StaticTree.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/zlib/zlib.net/Tree.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/zlib/zlib.net/ZStream.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/zlib/zlib.net/ZStreamException.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/zlib/zlib.net/Zlib.cs (100%) rename src/{Modules => ipy/IronPython.Modules}/zlib/zlib.net/history.txt (100%) rename src/{Modules => ipy/IronPython.Modules}/zlib/zlib.net/license.txt (100%) rename src/{Modules => ipy/IronPython.Modules}/zlib/zlib.net/readme.txt (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/AndExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/AssertStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/AssignmentStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/AstMethods.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/AsyncStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/AugmentedAssignStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/BinaryExpression.Generated.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/BinaryExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/BreakStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/CallExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/ClassDefinition.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/Comprehension.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/ComprehensionFor.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/ComprehensionIf.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/ConditionalExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/ConstantExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/ContinueStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/DelStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/DictionaryExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/DottedName.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/DynamicConvertExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/EmptyStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/ErrorExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/Expression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/ExpressionStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/FlowChecker.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/ForStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/FormattedValueExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/FromImportStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/FunctionDefinition.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/GeneratorExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/GetGlobalContextExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/GlobalStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/ILoopStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/IfStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/IfStatementTest.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/ImportStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/IndexExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/JoinedStringExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/Keyword.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/LambdaExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/ListExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/MemberExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/ModuleName.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/NameExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/Node.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/NonlocalStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/OrExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/Parameter.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/ParenthesisExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/PythonAst.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/PythonConstantExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/PythonNameBinder.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/PythonReference.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/PythonVariable.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/PythonWalker.Generated.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/RaiseStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/RelativeModuleName.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/ReturnStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/ScopeStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/SequenceExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/SerializedScopeStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/SetExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/SliceExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/StarredExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/Statement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/SuiteStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/TryStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/TupleExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/UnaryExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/VariableKind.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/WhileStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/WithStatement.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/YieldExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Ast/YieldFromExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/ClosureExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/ClosureInfo.cs (100%) rename src/{ => ipy}/IronPython/Compiler/CollectableCompilationMode.cs (100%) rename src/{ => ipy}/IronPython/Compiler/CompilationMode.cs (100%) rename src/{ => ipy}/IronPython/Compiler/GeneratorRewriter.cs (100%) rename src/{ => ipy}/IronPython/Compiler/LazyCode.cs (100%) rename src/{ => ipy}/IronPython/Compiler/LookupCompilationMode.cs (100%) rename src/{ => ipy}/IronPython/Compiler/OnDiskScriptCode.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Parser.cs (100%) rename src/{ => ipy}/IronPython/Compiler/PythonCallTargets.cs (100%) rename src/{ => ipy}/IronPython/Compiler/PythonCompilerOptions.cs (100%) rename src/{ => ipy}/IronPython/Compiler/PythonDynamicExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/PythonGlobal.cs (100%) rename src/{ => ipy}/IronPython/Compiler/PythonGlobalVariableExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/PythonOperator.cs (100%) rename src/{ => ipy}/IronPython/Compiler/PythonSavableScriptCode.cs (100%) rename src/{ => ipy}/IronPython/Compiler/PythonScriptCode.cs (100%) rename src/{ => ipy}/IronPython/Compiler/ReducableDynamicExpression.cs (100%) rename src/{ => ipy}/IronPython/Compiler/RunnableScriptCode.cs (100%) rename src/{ => ipy}/IronPython/Compiler/RuntimeScriptCode.cs (100%) rename src/{ => ipy}/IronPython/Compiler/ToDiskCompilationMode.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Token.cs (100%) rename src/{ => ipy}/IronPython/Compiler/TokenKind.Generated.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Tokenizer.Generated.cs (100%) rename src/{ => ipy}/IronPython/Compiler/Tokenizer.cs (100%) rename src/{ => ipy}/IronPython/Compiler/UncollectableCompilationMode.Generated.cs (100%) rename src/{ => ipy}/IronPython/Compiler/UncollectableCompilationMode.cs (100%) rename src/{ => ipy}/IronPython/FakeInteropServices.cs (100%) rename src/{ => ipy}/IronPython/Hosting/Python.cs (100%) rename src/{ => ipy}/IronPython/Hosting/PythonCodeDomCodeGen.cs (100%) rename src/{ => ipy}/IronPython/Hosting/PythonCommandLine.cs (100%) rename src/{ => ipy}/IronPython/Hosting/PythonConsoleOptions.cs (100%) rename src/{ => ipy}/IronPython/Hosting/PythonOptionsParser.cs (100%) rename src/{ => ipy}/IronPython/Hosting/PythonService.cs (100%) rename src/{ => ipy}/IronPython/Interop/Windows/Interop.Libraries.cs (100%) rename src/{ => ipy}/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs (100%) rename src/{ => ipy}/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs (100%) rename src/{ => ipy}/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs (100%) rename src/{ => ipy}/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs (100%) rename src/{ => ipy}/IronPython/IronPython.csproj (100%) rename src/{ => ipy}/IronPython/Lib/iptest/__init__.py (100%) rename src/{ => ipy}/IronPython/Lib/iptest/cominterop_util.py (100%) rename src/{ => ipy}/IronPython/Lib/iptest/console_util.py (100%) rename src/{ => ipy}/IronPython/Lib/iptest/file_util.py (100%) rename src/{ => ipy}/IronPython/Lib/iptest/ipunittest.py (100%) rename src/{ => ipy}/IronPython/Lib/iptest/misc_util.py (100%) rename src/{ => ipy}/IronPython/Lib/iptest/process_util.py (100%) rename src/{ => ipy}/IronPython/Lib/iptest/runner.py (100%) rename src/{ => ipy}/IronPython/Lib/iptest/test_env.py (100%) rename src/{ => ipy}/IronPython/Lib/iptest/type_util.py (100%) rename src/{ => ipy}/IronPython/Modules/Builtin.Generated.cs (100%) rename src/{ => ipy}/IronPython/Modules/Builtin.cs (100%) rename src/{ => ipy}/IronPython/Modules/_ast.cs (100%) rename src/{ => ipy}/IronPython/Modules/_fileio.cs (100%) rename src/{ => ipy}/IronPython/Modules/_imp.cs (100%) rename src/{ => ipy}/IronPython/Modules/_io.cs (100%) rename src/{ => ipy}/IronPython/Modules/_io/BytesIO.cs (100%) rename src/{ => ipy}/IronPython/Modules/_io/StringIO.cs (100%) rename src/{ => ipy}/IronPython/Modules/_locale.cs (100%) rename src/{ => ipy}/IronPython/Modules/sys.cs (100%) rename src/{ => ipy}/IronPython/Modules/unicodedata.cs (100%) rename src/{ => ipy}/IronPython/Modules/unicodedata/CaseFolding.txt (100%) rename src/{ => ipy}/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt (100%) rename src/{ => ipy}/IronPython/Modules/unicodedata/EastAsianWidth.txt (100%) rename src/{ => ipy}/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz (100%) rename src/{ => ipy}/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz (100%) rename src/{ => ipy}/IronPython/Modules/unicodedata/NameAliases.txt (100%) rename src/{ => ipy}/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt (100%) rename src/{ => ipy}/IronPython/Modules/unicodedata/UnicodeData.txt (100%) rename src/{ => ipy}/IronPython/Modules/unicodedata/genunicodedata.py (100%) rename src/{ => ipy}/IronPython/Modules/unicodedata/license.txt (100%) rename src/{ => ipy}/IronPython/Properties/AssemblyInfo.cs (100%) rename src/{ => ipy}/IronPython/Resources.Designer.cs (100%) rename src/{ => ipy}/IronPython/Resources.resx (100%) rename src/{ => ipy}/IronPython/Runtime/ArrayData.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/Binders.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/BindingHelpers.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/BindingWarnings.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/ConditionalBuilder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/ContextArgBuilder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/ConversionBinder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/CreateFallbackBinder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/FastBindResult.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/FastGetBase.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/FastSetBase.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/IComConvertible.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/IFastGettable.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/IFastInvokable.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/IFastSettable.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/IPythonConvertible.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/IPythonExpandable.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/IPythonGetable.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/IPythonInvokable.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/IPythonOperable.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/IPythonSite.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/MetaBuiltinFunction.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/MetaMethod.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/MetaPythonFunction.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/MetaPythonObject.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/MetaPythonType.Calls.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/MetaPythonType.Members.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/MetaPythonType.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/MetaUserObject.Members.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/MetaUserObject.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/PythonBinder.Create.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/PythonBinder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/PythonExtensionBinder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/PythonGetIndexBinder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/PythonGetMemberBinder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/PythonGetSliceBinder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/PythonIndexType.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/PythonInvokeBinder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/PythonOperationBinder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/PythonOperationKind.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/PythonOverloadResolver.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/PythonProtocol.Operations.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/PythonProtocol.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/PythonSetIndexBinder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/PythonSetMemberBinder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/PythonSetSliceBinder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/SlotOrFunction.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Binding/WarningInfo.cs (100%) rename src/{ => ipy}/IronPython/Runtime/BufferProtocol.cs (100%) rename src/{ => ipy}/IronPython/Runtime/BuiltinPythonModule.cs (100%) rename src/{ => ipy}/IronPython/Runtime/BuiltinsDictionaryStorage.cs (100%) rename src/{ => ipy}/IronPython/Runtime/ByteArray.cs (100%) rename src/{ => ipy}/IronPython/Runtime/ByteArrayIterator.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Bytes.cs (100%) rename src/{ => ipy}/IronPython/Runtime/BytesIterator.cs (100%) rename src/{ => ipy}/IronPython/Runtime/BytesLikeAttribute.cs (100%) rename src/{ => ipy}/IronPython/Runtime/ClassMethodAttribute.cs (100%) rename src/{ => ipy}/IronPython/Runtime/ClassMethodDescriptor.cs (100%) rename src/{ => ipy}/IronPython/Runtime/ClrModule.cs (100%) rename src/{ => ipy}/IronPython/Runtime/CodeContext.cs (100%) rename src/{ => ipy}/IronPython/Runtime/CollectionDebugView.cs (100%) rename src/{ => ipy}/IronPython/Runtime/CommonDictionaryStorage.cs (100%) rename src/{ => ipy}/IronPython/Runtime/CompareUtil.cs (100%) rename src/{ => ipy}/IronPython/Runtime/CompileFlags.cs (100%) rename src/{ => ipy}/IronPython/Runtime/CompiledLoader.cs (100%) rename src/{ => ipy}/IronPython/Runtime/ConstantDictionaryStorage.cs (100%) rename src/{ => ipy}/IronPython/Runtime/ConversionWrappers.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Converter.cs (100%) rename src/{ => ipy}/IronPython/Runtime/CustomDictionaryStorage.cs (100%) rename src/{ => ipy}/IronPython/Runtime/DebuggerDictionaryStorage.cs (100%) rename src/{ => ipy}/IronPython/Runtime/DefaultContext.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Descriptors.cs (100%) rename src/{ => ipy}/IronPython/Runtime/DictionaryOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/DictionaryStorage.cs (100%) rename src/{ => ipy}/IronPython/Runtime/DictionaryTypeInfoAttribute.cs (100%) rename src/{ => ipy}/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs (100%) rename src/{ => ipy}/IronPython/Runtime/DontMapICollectionToLenAttribute.cs (100%) rename src/{ => ipy}/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs (100%) rename src/{ => ipy}/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs (100%) rename src/{ => ipy}/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs (100%) rename src/{ => ipy}/IronPython/Runtime/EmptyDictionaryStorage.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Enumerate.cs (100%) rename src/{ => ipy}/IronPython/Runtime/ErrorCodes.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/AssertionException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/AttributeErrorException.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/BufferException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/GeneratorExitException.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/ImportException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/IndentationException.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/LookupException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/OSException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/PythonException.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/PythonExceptions.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/RecursionException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/SystemExitException.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/TabException.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/TraceBack.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/TypeErrorException.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Exceptions/ValueErrorException.cs (100%) rename src/{ => ipy}/IronPython/Runtime/ExtensionMethodSet.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Filter.cs (100%) rename src/{ => ipy}/IronPython/Runtime/FormattingHelper.cs (100%) rename src/{ => ipy}/IronPython/Runtime/FunctionAttributes.cs (100%) rename src/{ => ipy}/IronPython/Runtime/FunctionCode.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Generator.cs (100%) rename src/{ => ipy}/IronPython/Runtime/GlobalDictionaryStorage.cs (100%) rename src/{ => ipy}/IronPython/Runtime/IParameterSequence.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Implementation.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Importer.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Index.cs (100%) rename src/{ => ipy}/IronPython/Runtime/InstancedModuleDictionaryStorage.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Interfaces.cs (100%) rename src/{ => ipy}/IronPython/Runtime/KwCallInfo.cs (100%) rename src/{ => ipy}/IronPython/Runtime/LiteralParser.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Map.cs (100%) rename src/{ => ipy}/IronPython/Runtime/MaybeNotImplementedAttribute.cs (100%) rename src/{ => ipy}/IronPython/Runtime/MemoryStreamContentProvider.cs (100%) rename src/{ => ipy}/IronPython/Runtime/MemoryView.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Method.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Method.cs (100%) rename src/{ => ipy}/IronPython/Runtime/MissingParameter.cs (100%) rename src/{ => ipy}/IronPython/Runtime/ModuleContext.cs (100%) rename src/{ => ipy}/IronPython/Runtime/ModuleDictionaryStorage.cs (100%) rename src/{ => ipy}/IronPython/Runtime/ModuleGlobalCache.cs (100%) rename src/{ => ipy}/IronPython/Runtime/ModuleLoader.cs (100%) rename src/{ => ipy}/IronPython/Runtime/ModuleOptions.cs (100%) rename src/{ => ipy}/IronPython/Runtime/NameType.cs (100%) rename src/{ => ipy}/IronPython/Runtime/NewStringFormatter.cs (100%) rename src/{ => ipy}/IronPython/Runtime/ObjectAttributesAdapter.cs (100%) rename src/{ => ipy}/IronPython/Runtime/ObjectDebugView.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/ArrayOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/BigIntegerOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/BoolOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/ByteOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/CharOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/ComOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/ComplexOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/DBNullOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/DateTimeOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/DecimalOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/DelegateOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/DictionaryOfTOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/EnumOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/FloatOps.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/FloatOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/IListOfByteOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/InstanceOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/IntOps.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/IntOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/IntPtrOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/ListOfTOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/MarshalOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/NamespaceTrackerOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/ObjectOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/PythonCalls.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/PythonOps.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/PythonOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/PythonTypeOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/StringOps.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/StringOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/TypeGroupOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/TypeTrackerOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/UIntPtrOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Operations/UserTypeOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/OutputWriter.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PlatformsAttribute.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Profiler.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonContext.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonContext.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonDictionary.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonDocumentationProvider.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonDynamicStackFrame.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonEncoding.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonFileManager.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonFunction.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonFunction.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonHiddenAttribute.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonList.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonModule.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonModuleAttribute.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonNarrowing.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonOptions.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonRange.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonScopeExtension.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonStrIterator.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonTracebackListener.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonTuple.cs (100%) rename src/{ => ipy}/IronPython/Runtime/PythonTypeAttribute.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Reversed.cs (100%) rename src/{ => ipy}/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs (100%) rename src/{ => ipy}/IronPython/Runtime/ScopeDictionaryStorage.cs (100%) rename src/{ => ipy}/IronPython/Runtime/SequenceTypeInfoAttribute.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Set.cs (100%) rename src/{ => ipy}/IronPython/Runtime/SetStorage.cs (100%) rename src/{ => ipy}/IronPython/Runtime/SimpleNamespace.cs (100%) rename src/{ => ipy}/IronPython/Runtime/SiteLocalStorage.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Slice.cs (100%) rename src/{ => ipy}/IronPython/Runtime/StringDictionaryStorage.cs (100%) rename src/{ => ipy}/IronPython/Runtime/StringFormatSpec.cs (100%) rename src/{ => ipy}/IronPython/Runtime/StringFormatter.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Super.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Symbols.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/ThrowingErrorSink.cs (100%) rename src/{ => ipy}/IronPython/Runtime/TypecodeOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/BuiltinFunction.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/CachedNewTypeInfo.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/ConstructorFunction.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/CustomAttributeTracker.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/DocBuilder.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/DynamicHelpers.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/EmptyType.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/ExtensionPropertyInfo.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/FunctionType.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/IPythonObject.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/InstanceCreator.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/MappingProxy.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/Mro.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/NameConverter.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/NewTypeInfo.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/NewTypeMaker.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/OperatorMapping.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/ParameterInfoWrapper.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/PythonAssemblyOps.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/PythonSiteCache.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/PythonType.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/PythonType.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/PythonTypeDataSlot.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/PythonTypeDictSlot.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/PythonTypeInfo.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/PythonTypeSlot.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/PythonTypeTypeSlot.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/ReflectedEvent.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/ReflectedExtensionProperty.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/ReflectedField.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/ReflectedGetterSetter.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/ReflectedIndexer.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/ReflectedProperty.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/ReflectedSlotProperty.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/ResolvedMember.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/SlotFieldAttribute.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Types/TypeCache.Generated.cs (100%) rename src/{ => ipy}/IronPython/Runtime/UnboundNameException.cs (100%) rename src/{ => ipy}/IronPython/Runtime/WeakRef.cs (100%) rename src/{ => ipy}/IronPython/Runtime/WrapperDescriptorAttribute.cs (100%) rename src/{ => ipy}/IronPython/Runtime/WrapperDictionary.cs (100%) rename src/{ => ipy}/IronPython/Runtime/Zip.cs (100%) rename src/{ => ipy}/IronPython/SerializationStubs.cs (100%) rename src/{ => ipy}/IronPython/StringExtensions.cs (100%) rename src/{ => ipy}/IronPython/SystemRuntimeVersioning.cs (100%) rename src/{ => ipy}/IronPython/policy.IronPython.config (100%) rename src/{DiagnosticAnalyzer => roslyn/IronPython.DiagnosticAnalyzer}/Analyzer.cs (100%) rename src/{DiagnosticAnalyzer => roslyn/IronPython.DiagnosticAnalyzer}/Directory.Build.props (100%) rename src/{DiagnosticAnalyzer => roslyn/IronPython.DiagnosticAnalyzer}/IronPython.DiagnosticAnalyzer.csproj (100%) rename {src/Tests => tests/ironpython}/AssemblyInfo.cs (100%) rename {src/Tests => tests/ironpython}/AttrInjectorTest.cs (100%) rename {src/Tests => tests/ironpython}/BindTest.cs (100%) rename {src/Tests => tests/ironpython}/BinderTest.cs (100%) rename {src/Tests => tests/ironpython}/Cases/CPythonCases.cs (100%) rename {src/Tests => tests/ironpython}/Cases/CPythonCasesManifest.ini (100%) rename {src/Tests => tests/ironpython}/Cases/CaseExecuter.cs (100%) rename {src/Tests => tests/ironpython}/Cases/CaseGenerator.cs (100%) rename {src/Tests => tests/ironpython}/Cases/CommonCases.cs (100%) rename {src/Tests => tests/ironpython}/Cases/IronPythonCases.cs (100%) rename {src/Tests => tests/ironpython}/Cases/IronPythonCasesManifest.ini (100%) rename {src/Tests => tests/ironpython}/ClrType.cs (100%) rename {src/Tests => tests/ironpython}/Cmplx.cs (100%) rename {src/Tests => tests/ironpython}/Conversions.cs (100%) rename {src/Tests => tests/ironpython}/DeTest.cs (100%) rename {src/Tests => tests/ironpython}/DelegateTest.cs (100%) rename {src/Tests => tests/ironpython}/DynamicRegressions.cs (100%) rename {src/Tests => tests/ironpython}/EncodingTest.cs (100%) rename {src/Tests => tests/ironpython}/EngineTest.cs (100%) rename {src/Tests => tests/ironpython}/Enums.cs (100%) rename {src/Tests => tests/ironpython}/Events.cs (100%) rename {src/Tests => tests/ironpython}/ExceptionConverter.cs (100%) rename {src/Tests => tests/ironpython}/Exceptions.cs (100%) rename {src/Tests => tests/ironpython}/Explicit.cs (100%) rename {src/Tests => tests/ironpython}/ExtensionMethodTest.cs (100%) rename {src/Tests => tests/ironpython}/GenMeth.cs (100%) rename {src/Tests => tests/ironpython}/Indexable.cs (100%) rename {src/Tests => tests/ironpython}/InheritTest.cs (100%) rename {src/Tests => tests/ironpython}/IntegerTest.cs (100%) rename {src/Tests => tests/ironpython}/IronMath.cs (100%) rename {src/Tests => tests/ironpython}/IronPython.Tests.csproj (100%) rename {src/Tests => tests/ironpython}/LoadTest.cs (100%) rename {src/Tests => tests/ironpython}/MemberMappingTests.cs (100%) rename {src/Tests => tests/ironpython}/MemberOverloadTest.cs (100%) rename {src/Tests => tests/ironpython}/MethodParametersStubs.cs (100%) rename {src/Tests => tests/ironpython}/NestedClass.cs (100%) rename {src/Tests => tests/ironpython}/NullableTest.cs (100%) rename {src/Tests => tests/ironpython}/OperatorTest.cs (100%) rename {src/Tests => tests/ironpython}/ProtocolTest.cs (100%) rename {src/Tests => tests/ironpython}/StaticTest.cs (100%) rename {src/Tests => tests/ironpython}/Stress/Engine.cs (100%) rename {src/Tests => tests/ironpython}/StringDictionaryStorage.cs (100%) rename {src/Tests => tests/ironpython}/TestBuiltinModule.cs (100%) rename {src/Tests => tests/ironpython}/TypeDescriptor.cs (100%) rename {src/Tests => tests/ironpython}/Util/IniParser.cs (100%) rename {src/Tests => tests/ironpython}/Util/TestManifest.cs (100%) rename tests/{ => python}/IndicesTest.py (100%) rename tests/{ => python}/Inputs/RemoteConsole.py (100%) rename tests/{ => python}/Inputs/UseCLI.py (100%) rename tests/{ => python}/Inputs/exit.py (100%) rename tests/{ => python}/Inputs/exitFuncRaises.py (100%) rename tests/{ => python}/Inputs/exitFuncRuns.py (100%) rename tests/{ => python}/Inputs/raise.py (100%) rename tests/{ => python}/Inputs/simpleCommand.py (100%) rename tests/{ => python}/Inputs/syntaxError.py (100%) rename tests/{ => python}/Inputs/uninitializedGlobal.py (100%) rename tests/{ => python}/Modes/ConsoleFlags.ps1 (100%) rename tests/{ => python}/Modes/ConsoleHelp.Debug.out (100%) rename tests/{ => python}/Modes/ConsoleHelp.Release.out (100%) rename tests/{ => python}/RunAgainstCpy.py (100%) rename tests/{ => python}/Tools/baselines/__builtin__.log (100%) rename tests/{ => python}/Tools/baselines/_codecs.log (100%) rename tests/{ => python}/Tools/baselines/_collections.log (100%) rename tests/{ => python}/Tools/baselines/_sre.log (100%) rename tests/{ => python}/Tools/baselines/_struct.log (100%) rename tests/{ => python}/Tools/baselines/_subprocess.log (100%) rename tests/{ => python}/Tools/baselines/_weakref.log (100%) rename tests/{ => python}/Tools/baselines/_winreg.log (100%) rename tests/{ => python}/Tools/baselines/array.log (100%) rename tests/{ => python}/Tools/baselines/cPickle.log (100%) rename tests/{ => python}/Tools/baselines/cStringIO.log (100%) rename tests/{ => python}/Tools/baselines/copy_reg.log (100%) rename tests/{ => python}/Tools/baselines/datetime.log (100%) rename tests/{ => python}/Tools/baselines/gc.log (100%) rename tests/{ => python}/Tools/baselines/itertools.log (100%) rename tests/{ => python}/Tools/baselines/math.log (100%) rename tests/{ => python}/Tools/baselines/mmap.log (100%) rename tests/{ => python}/Tools/baselines/msvcrt.log (100%) rename tests/{ => python}/Tools/baselines/nt.log (100%) rename tests/{ => python}/Tools/baselines/select.log (100%) rename tests/{ => python}/Tools/baselines/signal.log (100%) rename tests/{ => python}/Tools/baselines/sys.log (100%) rename tests/{ => python}/Tools/baselines/thread.log (100%) rename tests/{ => python}/Tools/baselines/time.log (100%) rename tests/{ => python}/Tools/baselines/types_only.log (100%) rename tests/{ => python}/Tools/baselines/xxsubtype.log (100%) rename tests/{ => python}/Tools/check/_functools.log (100%) rename tests/{ => python}/Tools/cleantests.py (100%) rename tests/{ => python}/Tools/clr_helpers.py (100%) rename tests/{ => python}/Tools/cmodule.py (100%) rename tests/{ => python}/Tools/cpy_tests.py (100%) rename tests/{ => python}/Tools/logmodule.py (100%) rename tests/{ => python}/Tools/modulediff.py (100%) rename tests/{ => python}/Tools/stdmodules.py (100%) rename tests/{ => python}/_ctypes_test_linux32.pyd (100%) rename tests/{ => python}/_ctypes_test_linux64.pyd (100%) rename tests/{ => python}/_ctypes_test_win32.pyd (100%) rename tests/{ => python}/_ctypes_test_win64.pyd (100%) rename tests/{ => python}/badil.py (100%) rename tests/{ => python}/c1.cs (100%) rename tests/{ => python}/c2.cs (100%) rename tests/{ => python}/c3.cs (100%) rename tests/{ => python}/c4.cs (100%) rename tests/{ => python}/check_result.bat (100%) rename tests/{ => python}/compat/common.py (100%) rename tests/{ => python}/compat/rulediff.py (100%) rename tests/{ => python}/compat/runsbs.py (100%) rename tests/{ => python}/compat/sbs_builtin.py (100%) rename tests/{ => python}/compat/sbs_class_compare.py (100%) rename tests/{ => python}/compat/sbs_exceptions/__init__.py (100%) rename tests/{ => python}/compat/sbs_exceptions/define.py (100%) rename tests/{ => python}/compat/sbs_exceptions/for_loop.py (100%) rename tests/{ => python}/compat/sbs_exceptions/if_false.py (100%) rename tests/{ => python}/compat/sbs_exceptions/if_true.py (100%) rename tests/{ => python}/compat/sbs_exceptions/shared.py (100%) rename tests/{ => python}/compat/sbs_exceptions/try_else.py (100%) rename tests/{ => python}/compat/sbs_exceptions/try_except1.py (100%) rename tests/{ => python}/compat/sbs_exceptions/try_except2.py (100%) rename tests/{ => python}/compat/sbs_exceptions/try_except3.py (100%) rename tests/{ => python}/compat/sbs_exceptions/try_finally1.py (100%) rename tests/{ => python}/compat/sbs_exceptions/try_finally2.py (100%) rename tests/{ => python}/compat/sbs_exceptions/try_finally3.py (100%) rename tests/{ => python}/compat/sbs_exceptions/while_loop.py (100%) rename tests/{ => python}/compat/sbs_func_args.py (100%) rename tests/{ => python}/compat/sbs_library.cs (100%) rename tests/{ => python}/compat/sbs_newtype.py (100%) rename tests/{ => python}/compat/sbs_parse_string.py (100%) rename tests/{ => python}/compat/sbs_simple_compare.py (100%) rename tests/{ => python}/compat/sbs_simple_ops.py (100%) rename tests/{ => python}/compat/sbs_true_division.py (100%) rename tests/{ => python}/compat/sbs_typeop.py (100%) rename tests/{ => python}/compat/testdata.py (100%) rename tests/{ => python}/custombuiltins.py (100%) rename tests/{ => python}/debugging/__init__.py (100%) rename tests/{ => python}/debugging/mdbg_tool/__init__.py (100%) rename tests/{ => python}/debugging/pdb_mod/__init__.py (100%) rename tests/{ => python}/debugging/vs/__init__.py (100%) rename tests/{ => python}/dllsite.py (100%) rename tests/{ => python}/dummy_module.py (100%) rename tests/{ => python}/dynamic_sanity/dynamic_runner.bat (100%) rename tests/{ => python}/dynamic_sanity/dynamic_sanity.cs (100%) rename tests/{ => python}/dynamic_sanity/mock.py (100%) rename tests/{ => python}/encoded_files/bad_encoding_name.py (100%) rename tests/{ => python}/encoded_files/bad_latin1_bom.py (100%) rename tests/{ => python}/encoded_files/bad_latin1_bom_decl.py (100%) rename tests/{ => python}/encoded_files/bad_latin1_nbsp.py (100%) rename tests/{ => python}/encoded_files/bad_latin1_nodecl.py (100%) rename tests/{ => python}/encoded_files/bad_utf8_bom_decl.py (100%) rename tests/{ => python}/encoded_files/cp1019.py (100%) rename tests/{ => python}/encoded_files/cp11334_bad.py (100%) rename tests/{ => python}/encoded_files/cp11334_ok.py (100%) rename tests/{ => python}/encoded_files/cp20472.py (100%) rename tests/{ => python}/encoded_files/ok_encoding_nonascii.py (100%) rename tests/{ => python}/encoded_files/ok_encoding_whitespace.py (100%) rename tests/{ => python}/file_with_BOM.txt (88%) rename tests/{ => python}/file_without_BOM.txt (83%) rename tests/{ => python}/functions/test_signatures.py (100%) rename tests/{ => python}/gen_stdlib_test.py (100%) rename tests/{ => python}/gh129.zip (100%) rename tests/{ => python}/harness.py (100%) rename tests/{ => python}/hosting/editor_svcs/test_errorlistener.py (100%) rename tests/{ => python}/hosting/editor_svcs/test_tokencategorizer.py (100%) rename tests/{ => python}/import_extant/_vendor/__init__.py (100%) rename tests/{ => python}/import_extant/_vendor/packaging/__init__.py (100%) rename tests/{ => python}/import_extant/_vendor/packaging/_structures.py (100%) rename tests/{ => python}/import_extant/_vendor/packaging/version.py (100%) rename tests/{ => python}/import_extant/extern/__init__.py (100%) rename tests/{ => python}/interop/__init__.py (100%) rename tests/{ => python}/interop/com/apps/MultiOffice.py (100%) rename tests/{ => python}/interop/com/apps/adodb.py (100%) rename tests/{ => python}/interop/com/apps/excel.py (100%) rename tests/{ => python}/interop/com/apps/scriptpw.py (100%) rename tests/{ => python}/interop/com/apps/word.py (100%) rename tests/{ => python}/interop/com/compat/__init__.py (100%) rename tests/{ => python}/interop/com/compat/hw.py (100%) rename tests/{ => python}/interop/com/compat/hw_client.py (100%) rename tests/{ => python}/interop/com/dlrcomlib/DispEvents.py (100%) rename tests/{ => python}/interop/com/dlrcomlib/InOutParams.py (100%) rename tests/{ => python}/interop/com/dlrcomlib/MultipleParams.py (100%) rename tests/{ => python}/interop/com/dlrcomlib/OptionalParams.py (100%) rename tests/{ => python}/interop/com/dlrcomlib/OutParams.py (100%) rename tests/{ => python}/interop/com/dlrcomlib/ReturnValues.py (100%) rename tests/{ => python}/interop/com/dlrcomlib/SimpleErrors.py (100%) rename tests/{ => python}/interop/com/dlrcomlib/__init__.py (100%) rename tests/{ => python}/interop/com/dlrcomlib/dlrcomserver.py (100%) rename tests/{ => python}/interop/com/dlrcomlib/paramsinretval.py (100%) rename tests/{ => python}/interop/com/dlrcomlib/properties.py (100%) rename tests/{ => python}/interop/com/dlrcomlib/pytraits/__init__.py (100%) rename tests/{ => python}/interop/com/dlrcomlib/pytraits/method.py (100%) rename tests/{ => python}/interop/com/dlrcomlib/pytraits/obj.py (100%) rename tests/{ => python}/interop/com/dlrcomlib/pytraits/prop.py (100%) rename tests/{ => python}/interop/com/dlrcomlib/typelib.py (100%) rename tests/{ => python}/interop/net/derivation/test_ctor_override.py (100%) rename tests/{ => python}/interop/net/derivation/test_event_override.py (100%) rename tests/{ => python}/interop/net/derivation/test_method_override.py (100%) rename tests/{ => python}/interop/net/derivation/test_method_signature.py (100%) rename tests/{ => python}/interop/net/derivation/test_property_override.py (100%) rename tests/{ => python}/interop/net/derivation/test_simplederive.py (100%) rename tests/{ => python}/interop/net/derivation/test_special_method.py (100%) rename tests/{ => python}/interop/net/dynamic/test_dynamic_regressions.py (100%) rename tests/{ => python}/interop/net/event/test_delegate.py (100%) rename tests/{ => python}/interop/net/event/test_event.py (100%) rename tests/{ => python}/interop/net/field/test_field_misc.py (100%) rename tests/{ => python}/interop/net/field/test_fields_inside_enum.py (100%) rename tests/{ => python}/interop/net/field/test_initonly_fields.py (100%) rename tests/{ => python}/interop/net/field/test_instance_fields.py (100%) rename tests/{ => python}/interop/net/field/test_literal_fields.py (100%) rename tests/{ => python}/interop/net/field/test_static_fields.py (100%) rename tests/{ => python}/interop/net/loadorder/module.py (100%) rename tests/{ => python}/interop/net/loadorder/t1a.py (100%) rename tests/{ => python}/interop/net/loadorder/t1b.py (100%) rename tests/{ => python}/interop/net/loadorder/t1c.py (100%) rename tests/{ => python}/interop/net/loadorder/t1d.py (100%) rename tests/{ => python}/interop/net/loadorder/t2a.py (100%) rename tests/{ => python}/interop/net/loadorder/t2b.py (100%) rename tests/{ => python}/interop/net/loadorder/t2c.py (100%) rename tests/{ => python}/interop/net/loadorder/t2d.py (100%) rename tests/{ => python}/interop/net/loadorder/t2e.py (100%) rename tests/{ => python}/interop/net/loadorder/t2f.py (100%) rename tests/{ => python}/interop/net/loadorder/t2g.py (100%) rename tests/{ => python}/interop/net/loadorder/t2h.py (100%) rename tests/{ => python}/interop/net/loadorder/t3a.py (100%) rename tests/{ => python}/interop/net/loadorder/t3b.py (100%) rename tests/{ => python}/interop/net/loadorder/t3c0.py (100%) rename tests/{ => python}/interop/net/loadorder/t3c1.py (100%) rename tests/{ => python}/interop/net/loadorder/t3c2.py (100%) rename tests/{ => python}/interop/net/loadorder/t3d.py (100%) rename tests/{ => python}/interop/net/loadorder/t3e.py (100%) rename tests/{ => python}/interop/net/loadorder/t3f.py (100%) rename tests/{ => python}/interop/net/loadorder/t3g1.py (100%) rename tests/{ => python}/interop/net/loadorder/t3g2.py (100%) rename tests/{ => python}/interop/net/loadorder/t3h.py (100%) rename tests/{ => python}/interop/net/loadorder/t3i.py (100%) rename tests/{ => python}/interop/net/loadorder/t4a.py (100%) rename tests/{ => python}/interop/net/loadorder/t4b.py (100%) rename tests/{ => python}/interop/net/loadorder/t4c.py (100%) rename tests/{ => python}/interop/net/loadorder/t5a.py (100%) rename tests/{ => python}/interop/net/loadorder/t5b.py (100%) rename tests/{ => python}/interop/net/loadorder/t5c1.py (100%) rename tests/{ => python}/interop/net/loadorder/t5c2.py (100%) rename tests/{ => python}/interop/net/loadorder/t6.py (100%) rename tests/{ => python}/interop/net/loadorder/t7a.py (100%) rename tests/{ => python}/interop/net/loadorder/t7b.py (100%) rename tests/{ => python}/interop/net/loadorder/t7c.py (100%) rename tests/{ => python}/interop/net/loadorder/t7d.py (100%) rename tests/{ => python}/interop/net/loadorder/t7e.py (100%) rename tests/{ => python}/interop/net/loadorder/t7f.py (100%) rename tests/{ => python}/interop/net/method/test_arguments.py (100%) rename tests/{ => python}/interop/net/method/test_op_explicit.py (100%) rename tests/{ => python}/interop/net/method/test_op_implicit.py (100%) rename tests/{ => python}/interop/net/method/test_operators.py (100%) rename tests/{ => python}/interop/net/method/test_returnvalue.py (100%) rename tests/{ => python}/interop/net/property/test_indexercs.py (100%) rename tests/{ => python}/interop/net/property/test_indexervb.py (100%) rename tests/{ => python}/interop/net/property/test_property.py (100%) rename tests/{ => python}/interop/net/test_accessibility.py (100%) rename tests/{ => python}/interop/net/test_dynamicobjectmodel.py (100%) rename tests/{ => python}/interop/net/test_loadorder.py (100%) rename tests/{ => python}/interop/net/type/test___clrtype.py (100%) rename tests/{ => python}/interop/net/type/test_assembly.py (100%) rename tests/{ => python}/interop/net/type/test_clr_array.py (100%) rename tests/{ => python}/interop/net/type/test_ctor.py (100%) rename tests/{ => python}/interop/net/type/test_defaultmember.py (100%) rename tests/{ => python}/interop/net/type/test_reachtype.py (100%) rename tests/{ => python}/interop/net/versions/test_four_dot_zero.py (100%) rename tests/{ => python}/modules/__init__.py (100%) rename tests/{ => python}/modules/io_related/test__bytesio.py (100%) rename tests/{ => python}/modules/io_related/test__fileio.py (100%) rename tests/{ => python}/modules/io_related/test_binascii.py (100%) rename tests/{ => python}/modules/io_related/test_cPickle.py (100%) rename tests/{ => python}/modules/io_related/test_codecs.py (100%) rename tests/{ => python}/modules/io_related/test_copyreg.py (100%) rename tests/{ => python}/modules/io_related/test_fd.py (100%) rename tests/{ => python}/modules/io_related/test_io_StringIO.py (100%) rename tests/{ => python}/modules/io_related/test_marshal.py (100%) rename tests/{ => python}/modules/io_related/test_re.py (100%) rename tests/{ => python}/modules/misc/test__opcode.py (100%) rename tests/{ => python}/modules/misc/test__random.py (100%) rename tests/{ => python}/modules/misc/test__sha256.py (100%) rename tests/{ => python}/modules/misc/test__sha512.py (100%) rename tests/{ => python}/modules/misc/test__warnings.py (100%) rename tests/{ => python}/modules/misc/test__weakref.py (100%) rename tests/{ => python}/modules/misc/test_ctypes.py (100%) rename tests/{ => python}/modules/misc/test_datetime.py (100%) rename tests/{ => python}/modules/misc/test_math.py (100%) rename tests/{ => python}/modules/misc/test_operator.py (100%) rename tests/{ => python}/modules/misc/test_system_namespaces.py (100%) rename tests/{ => python}/modules/misc/test_zlib.py (100%) rename tests/{ => python}/modules/network_related/__init__.py (100%) rename tests/{ => python}/modules/network_related/keycert.pem (100%) rename tests/{ => python}/modules/network_related/test__socket.py (100%) rename tests/{ => python}/modules/network_related/test__ssl.py (100%) rename tests/{ => python}/modules/system_related/__init__.py (100%) rename tests/{ => python}/modules/system_related/test__locale.py (100%) rename tests/{ => python}/modules/system_related/test_errno.py (100%) rename tests/{ => python}/modules/system_related/test_gc.py (100%) rename tests/{ => python}/modules/system_related/test_nt.py (100%) rename tests/{ => python}/modules/system_related/test_os.py (100%) rename tests/{ => python}/modules/system_related/test_resource.py (100%) rename tests/{ => python}/modules/system_related/test_resource_stdlib.py (100%) rename tests/{ => python}/modules/system_related/test_signal.py (100%) rename tests/{ => python}/modules/system_related/test_sys.py (100%) rename tests/{ => python}/modules/system_related/test_sys_getframe.py (100%) rename tests/{ => python}/modules/system_related/test_thread.py (100%) rename tests/{ => python}/modules/system_related/test_time.py (100%) rename tests/{ => python}/modules/type_related/__init__.py (100%) rename tests/{ => python}/modules/type_related/test__struct.py (100%) rename tests/{ => python}/modules/type_related/test_array.py (100%) rename tests/{ => python}/modules/type_related/test_bitfields_ctypes_stdlib.py (100%) rename tests/{ => python}/modules/type_related/test_ctypes.py (100%) rename tests/{ => python}/modules/type_related/test_types.py (100%) rename tests/{ => python}/perf_micro_calls.py (100%) rename tests/{ => python}/pickles/cp18666.pickle (100%) rename tests/{ => python}/plans/debugging.html (100%) rename tests/{ => python}/plans/debugging.mdbg_tool.html (100%) rename tests/{ => python}/plans/debugging.pdb_mod.html (100%) rename tests/{ => python}/plans/debugging.vs.html (100%) rename tests/{ => python}/plans/generic_plan_template.py (100%) rename tests/{ => python}/plans/interop.net.derivation.html (100%) rename tests/{ => python}/plans/interop.net.derivation.test_ctor_override.html (100%) rename tests/{ => python}/plans/interop.net.derivation.test_event_override.html (100%) rename tests/{ => python}/plans/interop.net.derivation.test_method_override.html (100%) rename tests/{ => python}/plans/interop.net.derivation.test_method_signature.html (100%) rename tests/{ => python}/plans/interop.net.derivation.test_property_override.html (100%) rename tests/{ => python}/plans/interop.net.derivation.test_simplederive.html (100%) rename tests/{ => python}/plans/interop.net.derivation.test_special_method.html (100%) rename tests/{ => python}/plans/interop.net.event.html (100%) rename tests/{ => python}/plans/interop.net.event.test_delegate.html (100%) rename tests/{ => python}/plans/interop.net.event.test_event.html (100%) rename tests/{ => python}/plans/interop.net.field.html (100%) rename tests/{ => python}/plans/interop.net.field.test_field_misc.html (100%) rename tests/{ => python}/plans/interop.net.field.test_fields_inside_enum.html (100%) rename tests/{ => python}/plans/interop.net.html (100%) rename tests/{ => python}/plans/interop.net.insert_csharp.html (100%) rename tests/{ => python}/plans/interop.net.method.html (100%) rename tests/{ => python}/plans/interop.net.method.test_arguments.html (100%) rename tests/{ => python}/plans/interop.net.method.test_op_explicit.html (100%) rename tests/{ => python}/plans/interop.net.method.test_op_implicit.html (100%) rename tests/{ => python}/plans/interop.net.method.test_operators.html (100%) rename tests/{ => python}/plans/interop.net.method.test_returnvalue.html (100%) rename tests/{ => python}/plans/interop.net.property.html (100%) rename tests/{ => python}/plans/interop.net.property.test_indexercs.html (100%) rename tests/{ => python}/plans/interop.net.property.test_indexervb.html (100%) rename tests/{ => python}/plans/interop.net.property.test_property.html (100%) rename tests/{ => python}/plans/interop.net.test_accessibility.html (100%) rename tests/{ => python}/plans/interop.net.test_dynamicobjectmodel.html (100%) rename tests/{ => python}/plans/interop.net.test_loadorder.html (100%) rename tests/{ => python}/plans/interop.net.type.html (100%) rename tests/{ => python}/plans/interop.net.type.test_assembly.html (100%) rename tests/{ => python}/plans/interop.net.type.test_clr_array.html (100%) rename tests/{ => python}/plans/interop.net.type.test_ctor.html (100%) rename tests/{ => python}/plans/interop.net.type.test_defaultmember.html (100%) rename tests/{ => python}/plans/interop.net.type.test_reachtype.html (100%) rename tests/{ => python}/pretest.py (100%) rename tests/{ => python}/pyc/console_hw.py (100%) rename tests/{ => python}/pyc/console_hw_args.py (100%) rename tests/{ => python}/pyc/other_hw.py (100%) rename tests/{ => python}/pyc/pkg/__init__.py (100%) rename tests/{ => python}/pyc/pkg/a.py (100%) rename tests/{ => python}/pyc/pkg/b.py (100%) rename tests/{ => python}/pyc/pycpkgtest.py (100%) rename tests/{ => python}/pyc/stdmodules_ok.ps1 (100%) rename tests/{ => python}/pyc/test_pyc.ps1 (100%) rename tests/{ => python}/pyc/winforms_hw.py (100%) rename tests/{ => python}/run.py (100%) rename tests/{ => python}/run_transformed.bat (100%) rename tests/{ => python}/sample.txt.gz (100%) rename tests/{ => python}/specialcontext/Consoleless.ps1 (100%) rename tests/{ => python}/specialcontext/verify_ipyw.py (100%) rename tests/{ => python}/stress/__init__.py (100%) rename tests/{ => python}/stress/bigimport1_test.py (100%) rename tests/{ => python}/test_array.py (100%) rename tests/{ => python}/test_assert.py (100%) rename tests/{ => python}/test_ast.py (100%) rename tests/{ => python}/test_attr.py (100%) rename tests/{ => python}/test_attribute_customize.py (100%) rename tests/{ => python}/test_attrinjector.py (100%) rename tests/{ => python}/test_bigint.py (100%) rename tests/{ => python}/test_bool.py (100%) rename tests/{ => python}/test_builtin_stdlib.py (100%) rename tests/{ => python}/test_builtinfunc.py (100%) rename tests/{ => python}/test_bytes.py (100%) rename tests/{ => python}/test_bz2.py (100%) rename tests/{ => python}/test_bz2_stdlib.py (100%) rename tests/{ => python}/test_class.py (100%) rename tests/{ => python}/test_class_stdlib.py (100%) rename tests/{ => python}/test_cliclass.py (100%) rename tests/{ => python}/test_closure.py (100%) rename tests/{ => python}/test_clrexception.py (100%) rename tests/{ => python}/test_clrload.py (100%) rename tests/{ => python}/test_clrload2.py (100%) rename tests/{ => python}/test_clrnuminterop.py (100%) rename tests/{ => python}/test_clrtype.py (100%) rename tests/{ => python}/test_clruse.py (100%) rename tests/{ => python}/test_codeccallbacks_stdlib.py (100%) rename tests/{ => python}/test_codecs.py (100%) rename tests/{ => python}/test_codecs_stdlib.py (100%) rename tests/{ => python}/test_compiler.py (100%) rename tests/{ => python}/test_complex.py (100%) rename tests/{ => python}/test_complex_stdlib.py (100%) rename tests/{ => python}/test_conditional.py (100%) rename tests/{ => python}/test_data.gz (100%) rename tests/{ => python}/test_datetime.py (100%) rename tests/{ => python}/test_datetime_stdlib.py (100%) rename tests/{ => python}/test_decimal.py (100%) rename tests/{ => python}/test_decorator.py (100%) rename tests/{ => python}/test_delegate.py (100%) rename tests/{ => python}/test_deque.py (100%) rename tests/{ => python}/test_descr_stdlib.py (100%) rename tests/{ => python}/test_dict.py (100%) rename tests/{ => python}/test_dict_stdlib.py (100%) rename tests/{ => python}/test_dictcomp.py (100%) rename tests/{ => python}/test_dllsite.py (100%) rename tests/{ => python}/test_dlrkwarg.py (100%) rename tests/{ => python}/test_doc.py (100%) rename tests/{ => python}/test_enum.py (100%) rename tests/{ => python}/test_exceptions.py (100%) rename tests/{ => python}/test_exceptions_generated.py (100%) rename tests/{ => python}/test_excinfo.py (100%) rename tests/{ => python}/test_exec.py (100%) rename tests/{ => python}/test_file.py (100%) rename tests/{ => python}/test_float_stdlib.py (100%) rename tests/{ => python}/test_formatting.py (100%) rename tests/{ => python}/test_function.py (100%) rename tests/{ => python}/test_functools_stdlib.py (100%) rename tests/{ => python}/test_fuzz_parser.py (100%) rename tests/{ => python}/test_generator.py (100%) rename tests/{ => python}/test_generator_throw.py (100%) rename tests/{ => python}/test_genericmeth.py (100%) rename tests/{ => python}/test_hash.py (100%) rename tests/{ => python}/test_help.py (100%) rename tests/{ => python}/test_httplib_stdlib.py (100%) rename tests/{ => python}/test_imp.py (100%) rename tests/{ => python}/test_importext.py (100%) rename tests/{ => python}/test_importpkg.py (100%) rename tests/{ => python}/test_in.py (100%) rename tests/{ => python}/test_index.py (100%) rename tests/{ => python}/test_inheritance.py (100%) rename tests/{ => python}/test_int.py (100%) rename tests/{ => python}/test_interactive.py (100%) rename tests/{ => python}/test_io.py (100%) rename tests/{ => python}/test_io_stdlib.py (100%) rename tests/{ => python}/test_ipyc.py (100%) rename tests/{ => python}/test_ipye.py (100%) rename tests/{ => python}/test_ironmath.py (100%) rename tests/{ => python}/test_is.py (100%) rename tests/{ => python}/test_isinstance.py (100%) rename tests/{ => python}/test_isinstance2.py (100%) rename tests/{ => python}/test_iterator.py (100%) rename tests/{ => python}/test_iteratorlength.py (100%) rename tests/{ => python}/test_itertools_stdlib.py (100%) rename tests/{ => python}/test_json.py (100%) rename tests/{ => python}/test_kwarg.py (100%) rename tests/{ => python}/test_list.py (100%) rename tests/{ => python}/test_listcomp.py (100%) rename tests/{ => python}/test_long_stdlib.py (100%) rename tests/{ => python}/test_memory.py (100%) rename tests/{ => python}/test_memoryio_stdlib.py (100%) rename tests/{ => python}/test_memoryview.py (100%) rename tests/{ => python}/test_metaclass.py (100%) rename tests/{ => python}/test_methodbinder1.py (100%) rename tests/{ => python}/test_methodbinder2.py (100%) rename tests/{ => python}/test_methoddispatch.py (100%) rename tests/{ => python}/test_missing.py (100%) rename tests/{ => python}/test_namebinding.py (100%) rename tests/{ => python}/test_nonetype.py (100%) rename tests/{ => python}/test_nonlocal.py (100%) rename tests/{ => python}/test_number.py (100%) rename tests/{ => python}/test_numberhash.py (100%) rename tests/{ => python}/test_numtypes.py (100%) rename tests/{ => python}/test_pep380_stdlib.py (100%) rename tests/{ => python}/test_peverify.py (100%) rename tests/{ => python}/test_pow.py (100%) rename tests/{ => python}/test_privateBinding.py (100%) rename tests/{ => python}/test_property.py (100%) rename tests/{ => python}/test_protected.py (100%) rename tests/{ => python}/test_pyexpat.py (100%) rename tests/{ => python}/test_python25.py (100%) rename tests/{ => python}/test_python26.py (100%) rename tests/{ => python}/test_range.py (100%) rename tests/{ => python}/test_re_stdlib.py (100%) rename tests/{ => python}/test_regressions.py (100%) rename tests/{ => python}/test_regressions_compiled.py (100%) rename tests/{ => python}/test_sax_stdlib.py (100%) rename tests/{ => python}/test_scope_stdlib.py (100%) rename tests/{ => python}/test_set.py (100%) rename tests/{ => python}/test_setcomp.py (100%) rename tests/{ => python}/test_shutil.py (100%) rename tests/{ => python}/test_slice.py (100%) rename tests/{ => python}/test_slots.py (100%) rename tests/{ => python}/test_socket_stdlib.py (100%) rename tests/{ => python}/test_specialcontext.py (100%) rename tests/{ => python}/test_sqlite3_stdlib.py (100%) rename tests/{ => python}/test_ssl_stdlib.py (100%) rename tests/{ => python}/test_statics.py (100%) rename tests/{ => python}/test_stdconsole.py (100%) rename tests/{ => python}/test_stdmodules.py (100%) rename tests/{ => python}/test_str.py (100%) rename tests/{ => python}/test_str_bytes.py (100%) rename tests/{ => python}/test_strformat.py (100%) rename tests/{ => python}/test_struct.py (100%) rename tests/{ => python}/test_struct_stdlib.py (100%) rename tests/{ => python}/test_struct_threadsafe.py (100%) rename tests/{ => python}/test_super.py (100%) rename tests/{ => python}/test_superconsole.py (100%) rename tests/{ => python}/test_surrogateescape.py (100%) rename tests/{ => python}/test_surrogateescape_pythonfuture.py (100%) rename tests/{ => python}/test_surrogatepass.py (100%) rename tests/{ => python}/test_syntax.py (100%) rename tests/{ => python}/test_sys_stdlib.py (100%) rename tests/{ => python}/test_system_timers.py (100%) rename tests/{ => python}/test_tcf.py (100%) rename tests/{ => python}/test_threadsafety.py (100%) rename tests/{ => python}/test_time_stdlib.py (100%) rename tests/{ => python}/test_traceback.py (100%) rename tests/{ => python}/test_tuple.py (100%) rename tests/{ => python}/test_types_stdlib.py (100%) rename tests/{ => python}/test_typing_stdlib.py (100%) rename tests/{ => python}/test_unicode.py (100%) rename tests/{ => python}/test_unicode_stdlib.py (100%) rename tests/{ => python}/test_unpack.py (100%) rename tests/{ => python}/test_utf8_mode_stdlib.py (100%) rename tests/{ => python}/test_weakref.py (100%) rename tests/{ => python}/test_weakset_stdlib.py (100%) rename tests/{ => python}/test_winforms.py (100%) rename tests/{ => python}/test_with.py (100%) rename tests/{ => python}/test_zipimport.py (100%) rename tests/{ => python}/testpkg1/__init__.py (100%) rename tests/{ => python}/testpkg1/mod1.py (100%) rename tests/{ => python}/timeit.py (100%) rename tests/{ => python}/toimport.py (100%) rename tests/{ => python}/transform.py (100%) diff --git a/src/Scripts/CompareDirs.py b/scripts/CompareDirs.py similarity index 100% rename from src/Scripts/CompareDirs.py rename to scripts/CompareDirs.py diff --git a/src/Scripts/Enter-IronPythonEnvironment.ps1 b/scripts/Enter-IronPythonEnvironment.ps1 similarity index 100% rename from src/Scripts/Enter-IronPythonEnvironment.ps1 rename to scripts/Enter-IronPythonEnvironment.ps1 diff --git a/src/Scripts/Install-IronPython.ps1 b/scripts/Install-IronPython.ps1 similarity index 100% rename from src/Scripts/Install-IronPython.ps1 rename to scripts/Install-IronPython.ps1 diff --git a/src/Scripts/clean.py b/scripts/clean.py similarity index 100% rename from src/Scripts/clean.py rename to scripts/clean.py diff --git a/src/Scripts/copyrights.py b/scripts/copyrights.py similarity index 100% rename from src/Scripts/copyrights.py rename to scripts/copyrights.py diff --git a/src/Scripts/generate.py b/scripts/generate.py similarity index 100% rename from src/Scripts/generate.py rename to scripts/generate.py diff --git a/src/Scripts/generate_UncollectableCompilationMode.py b/scripts/generate_UncollectableCompilationMode.py similarity index 100% rename from src/Scripts/generate_UncollectableCompilationMode.py rename to scripts/generate_UncollectableCompilationMode.py diff --git a/src/Scripts/generate_alltypes.py b/scripts/generate_alltypes.py similarity index 100% rename from src/Scripts/generate_alltypes.py rename to scripts/generate_alltypes.py diff --git a/src/Scripts/generate_calls.py b/scripts/generate_calls.py similarity index 100% rename from src/Scripts/generate_calls.py rename to scripts/generate_calls.py diff --git a/src/Scripts/generate_casts.py b/scripts/generate_casts.py similarity index 100% rename from src/Scripts/generate_casts.py rename to scripts/generate_casts.py diff --git a/src/Scripts/generate_comdispatch.py b/scripts/generate_comdispatch.py similarity index 100% rename from src/Scripts/generate_comdispatch.py rename to scripts/generate_comdispatch.py diff --git a/src/Scripts/generate_dict_views.py b/scripts/generate_dict_views.py similarity index 100% rename from src/Scripts/generate_dict_views.py rename to scripts/generate_dict_views.py diff --git a/src/Scripts/generate_dynamic_instructions.py b/scripts/generate_dynamic_instructions.py similarity index 100% rename from src/Scripts/generate_dynamic_instructions.py rename to scripts/generate_dynamic_instructions.py diff --git a/src/Scripts/generate_dynsites.py b/scripts/generate_dynsites.py similarity index 100% rename from src/Scripts/generate_dynsites.py rename to scripts/generate_dynsites.py diff --git a/src/Scripts/generate_encoding_aliases.py b/scripts/generate_encoding_aliases.py similarity index 100% rename from src/Scripts/generate_encoding_aliases.py rename to scripts/generate_encoding_aliases.py diff --git a/src/Scripts/generate_exception_factory.py b/scripts/generate_exception_factory.py similarity index 100% rename from src/Scripts/generate_exception_factory.py rename to scripts/generate_exception_factory.py diff --git a/src/Scripts/generate_exceptions.py b/scripts/generate_exceptions.py similarity index 100% rename from src/Scripts/generate_exceptions.py rename to scripts/generate_exceptions.py diff --git a/src/Scripts/generate_indicestest.py b/scripts/generate_indicestest.py similarity index 100% rename from src/Scripts/generate_indicestest.py rename to scripts/generate_indicestest.py diff --git a/src/Scripts/generate_math.py b/scripts/generate_math.py similarity index 100% rename from src/Scripts/generate_math.py rename to scripts/generate_math.py diff --git a/src/Scripts/generate_ops.py b/scripts/generate_ops.py similarity index 100% rename from src/Scripts/generate_ops.py rename to scripts/generate_ops.py diff --git a/src/Scripts/generate_os_codes.py b/scripts/generate_os_codes.py similarity index 100% rename from src/Scripts/generate_os_codes.py rename to scripts/generate_os_codes.py diff --git a/src/Scripts/generate_reflected_calls.py b/scripts/generate_reflected_calls.py similarity index 100% rename from src/Scripts/generate_reflected_calls.py rename to scripts/generate_reflected_calls.py diff --git a/src/Scripts/generate_set.py b/scripts/generate_set.py similarity index 100% rename from src/Scripts/generate_set.py rename to scripts/generate_set.py diff --git a/src/Scripts/generate_tuples.py b/scripts/generate_tuples.py similarity index 100% rename from src/Scripts/generate_tuples.py rename to scripts/generate_tuples.py diff --git a/src/Scripts/generate_typecache.py b/scripts/generate_typecache.py similarity index 100% rename from src/Scripts/generate_typecache.py rename to scripts/generate_typecache.py diff --git a/src/Scripts/generate_walker.py b/scripts/generate_walker.py similarity index 100% rename from src/Scripts/generate_walker.py rename to scripts/generate_walker.py diff --git a/src/Scripts/ipcom.ps1 b/scripts/ipcom.ps1 similarity index 100% rename from src/Scripts/ipcom.ps1 rename to scripts/ipcom.ps1 diff --git a/src/Scripts/make_meta1.py b/scripts/make_meta1.py similarity index 100% rename from src/Scripts/make_meta1.py rename to scripts/make_meta1.py diff --git a/src/Scripts/radix_generator.py b/scripts/radix_generator.py similarity index 100% rename from src/Scripts/radix_generator.py rename to scripts/radix_generator.py diff --git a/src/Scripts/run_compiled.py b/scripts/run_compiled.py similarity index 100% rename from src/Scripts/run_compiled.py rename to scripts/run_compiled.py diff --git a/src/Scripts/run_interactive.py b/scripts/run_interactive.py similarity index 100% rename from src/Scripts/run_interactive.py rename to scripts/run_interactive.py diff --git a/src/Scripts/smtpmailer.py b/scripts/smtpmailer.py similarity index 100% rename from src/Scripts/smtpmailer.py rename to scripts/smtpmailer.py diff --git a/src/Scripts/test_builder.py b/scripts/test_builder.py similarity index 100% rename from src/Scripts/test_builder.py rename to scripts/test_builder.py diff --git a/src/Scripts/test_cgcheck.py b/scripts/test_cgcheck.py similarity index 100% rename from src/Scripts/test_cgcheck.py rename to scripts/test_cgcheck.py diff --git a/src/Scripts/test_parrot.py b/scripts/test_parrot.py similarity index 100% rename from src/Scripts/test_parrot.py rename to scripts/test_parrot.py diff --git a/src/Scripts/test_pystone.py b/scripts/test_pystone.py similarity index 100% rename from src/Scripts/test_pystone.py rename to scripts/test_pystone.py diff --git a/src/Console.Host/IronPython.Console.Host.csproj b/src/console/IronPython.Console.Host/IronPython.Console.Host.csproj similarity index 100% rename from src/Console.Host/IronPython.Console.Host.csproj rename to src/console/IronPython.Console.Host/IronPython.Console.Host.csproj diff --git a/src/Console.Host/IronPythonWindow.cs b/src/console/IronPython.Console.Host/IronPythonWindow.cs similarity index 100% rename from src/Console.Host/IronPythonWindow.cs rename to src/console/IronPython.Console.Host/IronPythonWindow.cs diff --git a/src/Console.Host/Properties/AssemblyInfo.cs b/src/console/IronPython.Console.Host/Properties/AssemblyInfo.cs similarity index 100% rename from src/Console.Host/Properties/AssemblyInfo.cs rename to src/console/IronPython.Console.Host/Properties/AssemblyInfo.cs diff --git a/src/Console.Host/ipyw.ico b/src/console/IronPython.Console.Host/ipyw.ico similarity index 100% rename from src/Console.Host/ipyw.ico rename to src/console/IronPython.Console.Host/ipyw.ico diff --git a/src/Console/Console.cs b/src/console/IronPython.Console/Console.cs similarity index 100% rename from src/Console/Console.cs rename to src/console/IronPython.Console/Console.cs diff --git a/src/Console/IronPython.Console.csproj b/src/console/IronPython.Console/IronPython.Console.csproj similarity index 100% rename from src/Console/IronPython.Console.csproj rename to src/console/IronPython.Console/IronPython.Console.csproj diff --git a/src/Console/Properties/AssemblyInfo.cs b/src/console/IronPython.Console/Properties/AssemblyInfo.cs similarity index 100% rename from src/Console/Properties/AssemblyInfo.cs rename to src/console/IronPython.Console/Properties/AssemblyInfo.cs diff --git a/src/Console/app.manifest b/src/console/IronPython.Console/app.manifest similarity index 100% rename from src/Console/app.manifest rename to src/console/IronPython.Console/app.manifest diff --git a/src/Console/ipy-mono.sh b/src/console/IronPython.Console/ipy-mono.sh similarity index 100% rename from src/Console/ipy-mono.sh rename to src/console/IronPython.Console/ipy-mono.sh diff --git a/src/Console/ipy.ico b/src/console/IronPython.Console/ipy.ico similarity index 100% rename from src/Console/ipy.ico rename to src/console/IronPython.Console/ipy.ico diff --git a/src/Console/ipy.sh b/src/console/IronPython.Console/ipy.sh similarity index 100% rename from src/Console/ipy.sh rename to src/console/IronPython.Console/ipy.sh diff --git a/src/Console/runtimeconfig.template.json b/src/console/IronPython.Console/runtimeconfig.template.json similarity index 100% rename from src/Console/runtimeconfig.template.json rename to src/console/IronPython.Console/runtimeconfig.template.json diff --git a/src/Console32.Host/IronPython.Console32.Host.csproj b/src/console/IronPython.Console32.Host/IronPython.Console32.Host.csproj similarity index 100% rename from src/Console32.Host/IronPython.Console32.Host.csproj rename to src/console/IronPython.Console32.Host/IronPython.Console32.Host.csproj diff --git a/src/Console32/IronPython.Console32.csproj b/src/console/IronPython.Console32/IronPython.Console32.csproj similarity index 100% rename from src/Console32/IronPython.Console32.csproj rename to src/console/IronPython.Console32/IronPython.Console32.csproj diff --git a/src/SQLite/Connection.cs b/src/extensions/IronPython.SQLite/Connection.cs similarity index 100% rename from src/SQLite/Connection.cs rename to src/extensions/IronPython.SQLite/Connection.cs diff --git a/src/SQLite/Contants.cs b/src/extensions/IronPython.SQLite/Contants.cs similarity index 100% rename from src/SQLite/Contants.cs rename to src/extensions/IronPython.SQLite/Contants.cs diff --git a/src/SQLite/Cursor.cs b/src/extensions/IronPython.SQLite/Cursor.cs similarity index 100% rename from src/SQLite/Cursor.cs rename to src/extensions/IronPython.SQLite/Cursor.cs diff --git a/src/SQLite/Exceptions.cs b/src/extensions/IronPython.SQLite/Exceptions.cs similarity index 100% rename from src/SQLite/Exceptions.cs rename to src/extensions/IronPython.SQLite/Exceptions.cs diff --git a/src/SQLite/Extensions.cs b/src/extensions/IronPython.SQLite/Extensions.cs similarity index 100% rename from src/SQLite/Extensions.cs rename to src/extensions/IronPython.SQLite/Extensions.cs diff --git a/src/SQLite/IronPython.SQLite.csproj b/src/extensions/IronPython.SQLite/IronPython.SQLite.csproj similarity index 100% rename from src/SQLite/IronPython.SQLite.csproj rename to src/extensions/IronPython.SQLite/IronPython.SQLite.csproj diff --git a/src/SQLite/Properties/AssemblyInfo.cs b/src/extensions/IronPython.SQLite/Properties/AssemblyInfo.cs similarity index 100% rename from src/SQLite/Properties/AssemblyInfo.cs rename to src/extensions/IronPython.SQLite/Properties/AssemblyInfo.cs diff --git a/src/SQLite/Row.cs b/src/extensions/IronPython.SQLite/Row.cs similarity index 100% rename from src/SQLite/Row.cs rename to src/extensions/IronPython.SQLite/Row.cs diff --git a/src/SQLite/Statement.cs b/src/extensions/IronPython.SQLite/Statement.cs similarity index 100% rename from src/SQLite/Statement.cs rename to src/extensions/IronPython.SQLite/Statement.cs diff --git a/src/SQLite/Util.cs b/src/extensions/IronPython.SQLite/Util.cs similarity index 100% rename from src/SQLite/Util.cs rename to src/extensions/IronPython.SQLite/Util.cs diff --git a/src/SQLite/_sqlite.cs b/src/extensions/IronPython.SQLite/_sqlite.cs similarity index 100% rename from src/SQLite/_sqlite.cs rename to src/extensions/IronPython.SQLite/_sqlite.cs diff --git a/src/SQLite/c#sqlite/.editorconfig b/src/extensions/IronPython.SQLite/c#sqlite/.editorconfig similarity index 100% rename from src/SQLite/c#sqlite/.editorconfig rename to src/extensions/IronPython.SQLite/c#sqlite/.editorconfig diff --git a/src/SQLite/c#sqlite/BtreeInt_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/BtreeInt_h.cs similarity index 100% rename from src/SQLite/c#sqlite/BtreeInt_h.cs rename to src/extensions/IronPython.SQLite/c#sqlite/BtreeInt_h.cs diff --git a/src/SQLite/c#sqlite/Btree_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/Btree_h.cs similarity index 100% rename from src/SQLite/c#sqlite/Btree_h.cs rename to src/extensions/IronPython.SQLite/c#sqlite/Btree_h.cs diff --git a/src/SQLite/c#sqlite/Delegates.cs b/src/extensions/IronPython.SQLite/c#sqlite/Delegates.cs similarity index 100% rename from src/SQLite/c#sqlite/Delegates.cs rename to src/extensions/IronPython.SQLite/c#sqlite/Delegates.cs diff --git a/src/SQLite/c#sqlite/Hash_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/Hash_h.cs similarity index 100% rename from src/SQLite/c#sqlite/Hash_h.cs rename to src/extensions/IronPython.SQLite/c#sqlite/Hash_h.cs diff --git a/src/SQLite/c#sqlite/VdbeInt_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/VdbeInt_h.cs similarity index 100% rename from src/SQLite/c#sqlite/VdbeInt_h.cs rename to src/extensions/IronPython.SQLite/c#sqlite/VdbeInt_h.cs diff --git a/src/SQLite/c#sqlite/Vdbe_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/Vdbe_h.cs similarity index 100% rename from src/SQLite/c#sqlite/Vdbe_h.cs rename to src/extensions/IronPython.SQLite/c#sqlite/Vdbe_h.cs diff --git a/src/SQLite/c#sqlite/_Custom.cs b/src/extensions/IronPython.SQLite/c#sqlite/_Custom.cs similarity index 100% rename from src/SQLite/c#sqlite/_Custom.cs rename to src/extensions/IronPython.SQLite/c#sqlite/_Custom.cs diff --git a/src/SQLite/c#sqlite/alter_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/alter_c.cs similarity index 100% rename from src/SQLite/c#sqlite/alter_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/alter_c.cs diff --git a/src/SQLite/c#sqlite/analyze_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/analyze_c.cs similarity index 100% rename from src/SQLite/c#sqlite/analyze_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/analyze_c.cs diff --git a/src/SQLite/c#sqlite/attach_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/attach_c.cs similarity index 100% rename from src/SQLite/c#sqlite/attach_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/attach_c.cs diff --git a/src/SQLite/c#sqlite/auth_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/auth_c.cs similarity index 100% rename from src/SQLite/c#sqlite/auth_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/auth_c.cs diff --git a/src/SQLite/c#sqlite/backup_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/backup_c.cs similarity index 100% rename from src/SQLite/c#sqlite/backup_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/backup_c.cs diff --git a/src/SQLite/c#sqlite/bitvec_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/bitvec_c.cs similarity index 100% rename from src/SQLite/c#sqlite/bitvec_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/bitvec_c.cs diff --git a/src/SQLite/c#sqlite/btmutex_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/btmutex_c.cs similarity index 100% rename from src/SQLite/c#sqlite/btmutex_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/btmutex_c.cs diff --git a/src/SQLite/c#sqlite/btree_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/btree_c.cs similarity index 100% rename from src/SQLite/c#sqlite/btree_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/btree_c.cs diff --git a/src/SQLite/c#sqlite/build_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/build_c.cs similarity index 100% rename from src/SQLite/c#sqlite/build_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/build_c.cs diff --git a/src/SQLite/c#sqlite/callback_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/callback_c.cs similarity index 100% rename from src/SQLite/c#sqlite/callback_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/callback_c.cs diff --git a/src/SQLite/c#sqlite/complete_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/complete_c.cs similarity index 100% rename from src/SQLite/c#sqlite/complete_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/complete_c.cs diff --git a/src/SQLite/c#sqlite/crypto.cs b/src/extensions/IronPython.SQLite/c#sqlite/crypto.cs similarity index 100% rename from src/SQLite/c#sqlite/crypto.cs rename to src/extensions/IronPython.SQLite/c#sqlite/crypto.cs diff --git a/src/SQLite/c#sqlite/ctime_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/ctime_c.cs similarity index 100% rename from src/SQLite/c#sqlite/ctime_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/ctime_c.cs diff --git a/src/SQLite/c#sqlite/date_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/date_c.cs similarity index 100% rename from src/SQLite/c#sqlite/date_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/date_c.cs diff --git a/src/SQLite/c#sqlite/delete_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/delete_c.cs similarity index 100% rename from src/SQLite/c#sqlite/delete_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/delete_c.cs diff --git a/src/SQLite/c#sqlite/expr_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/expr_c.cs similarity index 100% rename from src/SQLite/c#sqlite/expr_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/expr_c.cs diff --git a/src/SQLite/c#sqlite/fault_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/fault_c.cs similarity index 100% rename from src/SQLite/c#sqlite/fault_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/fault_c.cs diff --git a/src/SQLite/c#sqlite/fkey_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/fkey_c.cs similarity index 100% rename from src/SQLite/c#sqlite/fkey_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/fkey_c.cs diff --git a/src/SQLite/c#sqlite/func_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/func_c.cs similarity index 100% rename from src/SQLite/c#sqlite/func_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/func_c.cs diff --git a/src/SQLite/c#sqlite/global_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/global_c.cs similarity index 100% rename from src/SQLite/c#sqlite/global_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/global_c.cs diff --git a/src/SQLite/c#sqlite/hash_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/hash_c.cs similarity index 100% rename from src/SQLite/c#sqlite/hash_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/hash_c.cs diff --git a/src/SQLite/c#sqlite/hwtime_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/hwtime_c.cs similarity index 100% rename from src/SQLite/c#sqlite/hwtime_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/hwtime_c.cs diff --git a/src/SQLite/c#sqlite/insert_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/insert_c.cs similarity index 100% rename from src/SQLite/c#sqlite/insert_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/insert_c.cs diff --git a/src/SQLite/c#sqlite/journal_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/journal_c.cs similarity index 100% rename from src/SQLite/c#sqlite/journal_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/journal_c.cs diff --git a/src/SQLite/c#sqlite/keywordhash_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/keywordhash_h.cs similarity index 100% rename from src/SQLite/c#sqlite/keywordhash_h.cs rename to src/extensions/IronPython.SQLite/c#sqlite/keywordhash_h.cs diff --git a/src/SQLite/c#sqlite/legacy_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/legacy_c.cs similarity index 100% rename from src/SQLite/c#sqlite/legacy_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/legacy_c.cs diff --git a/src/SQLite/c#sqlite/loadext_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/loadext_c.cs similarity index 100% rename from src/SQLite/c#sqlite/loadext_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/loadext_c.cs diff --git a/src/SQLite/c#sqlite/main_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/main_c.cs similarity index 100% rename from src/SQLite/c#sqlite/main_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/main_c.cs diff --git a/src/SQLite/c#sqlite/malloc_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/malloc_c.cs similarity index 100% rename from src/SQLite/c#sqlite/malloc_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/malloc_c.cs diff --git a/src/SQLite/c#sqlite/mem_Pool.cs b/src/extensions/IronPython.SQLite/c#sqlite/mem_Pool.cs similarity index 100% rename from src/SQLite/c#sqlite/mem_Pool.cs rename to src/extensions/IronPython.SQLite/c#sqlite/mem_Pool.cs diff --git a/src/SQLite/c#sqlite/memjournal_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/memjournal_c.cs similarity index 100% rename from src/SQLite/c#sqlite/memjournal_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/memjournal_c.cs diff --git a/src/SQLite/c#sqlite/mutex_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/mutex_c.cs similarity index 100% rename from src/SQLite/c#sqlite/mutex_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/mutex_c.cs diff --git a/src/SQLite/c#sqlite/mutex_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/mutex_h.cs similarity index 100% rename from src/SQLite/c#sqlite/mutex_h.cs rename to src/extensions/IronPython.SQLite/c#sqlite/mutex_h.cs diff --git a/src/SQLite/c#sqlite/mutex_noop_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/mutex_noop_c.cs similarity index 100% rename from src/SQLite/c#sqlite/mutex_noop_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/mutex_noop_c.cs diff --git a/src/SQLite/c#sqlite/mutex_w32.cs b/src/extensions/IronPython.SQLite/c#sqlite/mutex_w32.cs similarity index 100% rename from src/SQLite/c#sqlite/mutex_w32.cs rename to src/extensions/IronPython.SQLite/c#sqlite/mutex_w32.cs diff --git a/src/SQLite/c#sqlite/notify_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/notify_c.cs similarity index 100% rename from src/SQLite/c#sqlite/notify_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/notify_c.cs diff --git a/src/SQLite/c#sqlite/opcodes_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/opcodes_c.cs similarity index 100% rename from src/SQLite/c#sqlite/opcodes_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/opcodes_c.cs diff --git a/src/SQLite/c#sqlite/opcodes_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/opcodes_h.cs similarity index 100% rename from src/SQLite/c#sqlite/opcodes_h.cs rename to src/extensions/IronPython.SQLite/c#sqlite/opcodes_h.cs diff --git a/src/SQLite/c#sqlite/os_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/os_c.cs similarity index 100% rename from src/SQLite/c#sqlite/os_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/os_c.cs diff --git a/src/SQLite/c#sqlite/os_common_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/os_common_h.cs similarity index 100% rename from src/SQLite/c#sqlite/os_common_h.cs rename to src/extensions/IronPython.SQLite/c#sqlite/os_common_h.cs diff --git a/src/SQLite/c#sqlite/os_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/os_h.cs similarity index 100% rename from src/SQLite/c#sqlite/os_h.cs rename to src/extensions/IronPython.SQLite/c#sqlite/os_h.cs diff --git a/src/SQLite/c#sqlite/os_win_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/os_win_c.cs similarity index 100% rename from src/SQLite/c#sqlite/os_win_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/os_win_c.cs diff --git a/src/SQLite/c#sqlite/pager_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/pager_c.cs similarity index 100% rename from src/SQLite/c#sqlite/pager_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/pager_c.cs diff --git a/src/SQLite/c#sqlite/pager_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/pager_h.cs similarity index 100% rename from src/SQLite/c#sqlite/pager_h.cs rename to src/extensions/IronPython.SQLite/c#sqlite/pager_h.cs diff --git a/src/SQLite/c#sqlite/parse_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/parse_c.cs similarity index 100% rename from src/SQLite/c#sqlite/parse_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/parse_c.cs diff --git a/src/SQLite/c#sqlite/parse_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/parse_h.cs similarity index 100% rename from src/SQLite/c#sqlite/parse_h.cs rename to src/extensions/IronPython.SQLite/c#sqlite/parse_h.cs diff --git a/src/SQLite/c#sqlite/pcache1_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/pcache1_c.cs similarity index 100% rename from src/SQLite/c#sqlite/pcache1_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/pcache1_c.cs diff --git a/src/SQLite/c#sqlite/pcache_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/pcache_c.cs similarity index 100% rename from src/SQLite/c#sqlite/pcache_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/pcache_c.cs diff --git a/src/SQLite/c#sqlite/pcache_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/pcache_h.cs similarity index 100% rename from src/SQLite/c#sqlite/pcache_h.cs rename to src/extensions/IronPython.SQLite/c#sqlite/pcache_h.cs diff --git a/src/SQLite/c#sqlite/pragma_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/pragma_c.cs similarity index 100% rename from src/SQLite/c#sqlite/pragma_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/pragma_c.cs diff --git a/src/SQLite/c#sqlite/prepare_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/prepare_c.cs similarity index 100% rename from src/SQLite/c#sqlite/prepare_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/prepare_c.cs diff --git a/src/SQLite/c#sqlite/printf_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/printf_c.cs similarity index 100% rename from src/SQLite/c#sqlite/printf_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/printf_c.cs diff --git a/src/SQLite/c#sqlite/random_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/random_c.cs similarity index 100% rename from src/SQLite/c#sqlite/random_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/random_c.cs diff --git a/src/SQLite/c#sqlite/resolve_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/resolve_c.cs similarity index 100% rename from src/SQLite/c#sqlite/resolve_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/resolve_c.cs diff --git a/src/SQLite/c#sqlite/rowset_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/rowset_c.cs similarity index 100% rename from src/SQLite/c#sqlite/rowset_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/rowset_c.cs diff --git a/src/SQLite/c#sqlite/select_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/select_c.cs similarity index 100% rename from src/SQLite/c#sqlite/select_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/select_c.cs diff --git a/src/SQLite/c#sqlite/sqlite3_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/sqlite3_h.cs similarity index 100% rename from src/SQLite/c#sqlite/sqlite3_h.cs rename to src/extensions/IronPython.SQLite/c#sqlite/sqlite3_h.cs diff --git a/src/SQLite/c#sqlite/sqliteInt_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/sqliteInt_h.cs similarity index 100% rename from src/SQLite/c#sqlite/sqliteInt_h.cs rename to src/extensions/IronPython.SQLite/c#sqlite/sqliteInt_h.cs diff --git a/src/SQLite/c#sqlite/sqliteLimit_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/sqliteLimit_h.cs similarity index 100% rename from src/SQLite/c#sqlite/sqliteLimit_h.cs rename to src/extensions/IronPython.SQLite/c#sqlite/sqliteLimit_h.cs diff --git a/src/SQLite/c#sqlite/status_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/status_c.cs similarity index 100% rename from src/SQLite/c#sqlite/status_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/status_c.cs diff --git a/src/SQLite/c#sqlite/table_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/table_c.cs similarity index 100% rename from src/SQLite/c#sqlite/table_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/table_c.cs diff --git a/src/SQLite/c#sqlite/tokenize_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/tokenize_c.cs similarity index 100% rename from src/SQLite/c#sqlite/tokenize_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/tokenize_c.cs diff --git a/src/SQLite/c#sqlite/trigger_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/trigger_c.cs similarity index 100% rename from src/SQLite/c#sqlite/trigger_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/trigger_c.cs diff --git a/src/SQLite/c#sqlite/update_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/update_c.cs similarity index 100% rename from src/SQLite/c#sqlite/update_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/update_c.cs diff --git a/src/SQLite/c#sqlite/utf_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/utf_c.cs similarity index 100% rename from src/SQLite/c#sqlite/utf_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/utf_c.cs diff --git a/src/SQLite/c#sqlite/util_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/util_c.cs similarity index 100% rename from src/SQLite/c#sqlite/util_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/util_c.cs diff --git a/src/SQLite/c#sqlite/vacuum_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/vacuum_c.cs similarity index 100% rename from src/SQLite/c#sqlite/vacuum_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/vacuum_c.cs diff --git a/src/SQLite/c#sqlite/vdbe_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/vdbe_c.cs similarity index 100% rename from src/SQLite/c#sqlite/vdbe_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/vdbe_c.cs diff --git a/src/SQLite/c#sqlite/vdbeapi_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/vdbeapi_c.cs similarity index 100% rename from src/SQLite/c#sqlite/vdbeapi_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/vdbeapi_c.cs diff --git a/src/SQLite/c#sqlite/vdbeaux_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/vdbeaux_c.cs similarity index 100% rename from src/SQLite/c#sqlite/vdbeaux_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/vdbeaux_c.cs diff --git a/src/SQLite/c#sqlite/vdbeblob_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/vdbeblob_c.cs similarity index 100% rename from src/SQLite/c#sqlite/vdbeblob_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/vdbeblob_c.cs diff --git a/src/SQLite/c#sqlite/vdbemem_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/vdbemem_c.cs similarity index 100% rename from src/SQLite/c#sqlite/vdbemem_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/vdbemem_c.cs diff --git a/src/SQLite/c#sqlite/vdbetrace_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/vdbetrace_c.cs similarity index 100% rename from src/SQLite/c#sqlite/vdbetrace_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/vdbetrace_c.cs diff --git a/src/SQLite/c#sqlite/vtab_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/vtab_c.cs similarity index 100% rename from src/SQLite/c#sqlite/vtab_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/vtab_c.cs diff --git a/src/SQLite/c#sqlite/wal_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/wal_c.cs similarity index 100% rename from src/SQLite/c#sqlite/wal_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/wal_c.cs diff --git a/src/SQLite/c#sqlite/wal_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/wal_h.cs similarity index 100% rename from src/SQLite/c#sqlite/wal_h.cs rename to src/extensions/IronPython.SQLite/c#sqlite/wal_h.cs diff --git a/src/SQLite/c#sqlite/walker_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/walker_c.cs similarity index 100% rename from src/SQLite/c#sqlite/walker_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/walker_c.cs diff --git a/src/SQLite/c#sqlite/where_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/where_c.cs similarity index 100% rename from src/SQLite/c#sqlite/where_c.cs rename to src/extensions/IronPython.SQLite/c#sqlite/where_c.cs diff --git a/src/Wpf/DynamicXamlReader.cs b/src/extensions/IronPython.Wpf/DynamicXamlReader.cs similarity index 100% rename from src/Wpf/DynamicXamlReader.cs rename to src/extensions/IronPython.Wpf/DynamicXamlReader.cs diff --git a/src/Wpf/IronPython.Wpf.csproj b/src/extensions/IronPython.Wpf/IronPython.Wpf.csproj similarity index 100% rename from src/Wpf/IronPython.Wpf.csproj rename to src/extensions/IronPython.Wpf/IronPython.Wpf.csproj diff --git a/src/Wpf/Properties/AssemblyInfo.cs b/src/extensions/IronPython.Wpf/Properties/AssemblyInfo.cs similarity index 100% rename from src/Wpf/Properties/AssemblyInfo.cs rename to src/extensions/IronPython.Wpf/Properties/AssemblyInfo.cs diff --git a/src/Wpf/_wpf.cs b/src/extensions/IronPython.Wpf/_wpf.cs similarity index 100% rename from src/Wpf/_wpf.cs rename to src/extensions/IronPython.Wpf/_wpf.cs diff --git a/src/StdLib/.gitattributes b/src/extensions/StdLib/.gitattributes similarity index 100% rename from src/StdLib/.gitattributes rename to src/extensions/StdLib/.gitattributes diff --git a/src/StdLib/Lib/__future__.py b/src/extensions/StdLib/Lib/__future__.py similarity index 100% rename from src/StdLib/Lib/__future__.py rename to src/extensions/StdLib/Lib/__future__.py diff --git a/src/StdLib/Lib/__phello__.foo.py b/src/extensions/StdLib/Lib/__phello__.foo.py similarity index 100% rename from src/StdLib/Lib/__phello__.foo.py rename to src/extensions/StdLib/Lib/__phello__.foo.py diff --git a/src/StdLib/Lib/_bootlocale.py b/src/extensions/StdLib/Lib/_bootlocale.py similarity index 100% rename from src/StdLib/Lib/_bootlocale.py rename to src/extensions/StdLib/Lib/_bootlocale.py diff --git a/src/StdLib/Lib/_collections_abc.py b/src/extensions/StdLib/Lib/_collections_abc.py similarity index 100% rename from src/StdLib/Lib/_collections_abc.py rename to src/extensions/StdLib/Lib/_collections_abc.py diff --git a/src/StdLib/Lib/_compat_pickle.py b/src/extensions/StdLib/Lib/_compat_pickle.py similarity index 100% rename from src/StdLib/Lib/_compat_pickle.py rename to src/extensions/StdLib/Lib/_compat_pickle.py diff --git a/src/StdLib/Lib/_dummy_thread.py b/src/extensions/StdLib/Lib/_dummy_thread.py similarity index 100% rename from src/StdLib/Lib/_dummy_thread.py rename to src/extensions/StdLib/Lib/_dummy_thread.py diff --git a/src/StdLib/Lib/_markupbase.py b/src/extensions/StdLib/Lib/_markupbase.py similarity index 100% rename from src/StdLib/Lib/_markupbase.py rename to src/extensions/StdLib/Lib/_markupbase.py diff --git a/src/StdLib/Lib/_osx_support.py b/src/extensions/StdLib/Lib/_osx_support.py similarity index 100% rename from src/StdLib/Lib/_osx_support.py rename to src/extensions/StdLib/Lib/_osx_support.py diff --git a/src/StdLib/Lib/_pyio.py b/src/extensions/StdLib/Lib/_pyio.py similarity index 100% rename from src/StdLib/Lib/_pyio.py rename to src/extensions/StdLib/Lib/_pyio.py diff --git a/src/StdLib/Lib/_sitebuiltins.py b/src/extensions/StdLib/Lib/_sitebuiltins.py similarity index 100% rename from src/StdLib/Lib/_sitebuiltins.py rename to src/extensions/StdLib/Lib/_sitebuiltins.py diff --git a/src/StdLib/Lib/_strptime.py b/src/extensions/StdLib/Lib/_strptime.py similarity index 100% rename from src/StdLib/Lib/_strptime.py rename to src/extensions/StdLib/Lib/_strptime.py diff --git a/src/StdLib/Lib/_threading_local.py b/src/extensions/StdLib/Lib/_threading_local.py similarity index 100% rename from src/StdLib/Lib/_threading_local.py rename to src/extensions/StdLib/Lib/_threading_local.py diff --git a/src/StdLib/Lib/_weakrefset.py b/src/extensions/StdLib/Lib/_weakrefset.py similarity index 100% rename from src/StdLib/Lib/_weakrefset.py rename to src/extensions/StdLib/Lib/_weakrefset.py diff --git a/src/StdLib/Lib/abc.py b/src/extensions/StdLib/Lib/abc.py similarity index 100% rename from src/StdLib/Lib/abc.py rename to src/extensions/StdLib/Lib/abc.py diff --git a/src/StdLib/Lib/aifc.py b/src/extensions/StdLib/Lib/aifc.py similarity index 100% rename from src/StdLib/Lib/aifc.py rename to src/extensions/StdLib/Lib/aifc.py diff --git a/src/StdLib/Lib/antigravity.py b/src/extensions/StdLib/Lib/antigravity.py similarity index 100% rename from src/StdLib/Lib/antigravity.py rename to src/extensions/StdLib/Lib/antigravity.py diff --git a/src/StdLib/Lib/argparse.py b/src/extensions/StdLib/Lib/argparse.py similarity index 100% rename from src/StdLib/Lib/argparse.py rename to src/extensions/StdLib/Lib/argparse.py diff --git a/src/StdLib/Lib/ast.py b/src/extensions/StdLib/Lib/ast.py similarity index 100% rename from src/StdLib/Lib/ast.py rename to src/extensions/StdLib/Lib/ast.py diff --git a/src/StdLib/Lib/asynchat.py b/src/extensions/StdLib/Lib/asynchat.py similarity index 100% rename from src/StdLib/Lib/asynchat.py rename to src/extensions/StdLib/Lib/asynchat.py diff --git a/src/StdLib/Lib/asyncio/__init__.py b/src/extensions/StdLib/Lib/asyncio/__init__.py similarity index 100% rename from src/StdLib/Lib/asyncio/__init__.py rename to src/extensions/StdLib/Lib/asyncio/__init__.py diff --git a/src/StdLib/Lib/asyncio/base_events.py b/src/extensions/StdLib/Lib/asyncio/base_events.py similarity index 100% rename from src/StdLib/Lib/asyncio/base_events.py rename to src/extensions/StdLib/Lib/asyncio/base_events.py diff --git a/src/StdLib/Lib/asyncio/base_subprocess.py b/src/extensions/StdLib/Lib/asyncio/base_subprocess.py similarity index 100% rename from src/StdLib/Lib/asyncio/base_subprocess.py rename to src/extensions/StdLib/Lib/asyncio/base_subprocess.py diff --git a/src/StdLib/Lib/asyncio/compat.py b/src/extensions/StdLib/Lib/asyncio/compat.py similarity index 100% rename from src/StdLib/Lib/asyncio/compat.py rename to src/extensions/StdLib/Lib/asyncio/compat.py diff --git a/src/StdLib/Lib/asyncio/constants.py b/src/extensions/StdLib/Lib/asyncio/constants.py similarity index 100% rename from src/StdLib/Lib/asyncio/constants.py rename to src/extensions/StdLib/Lib/asyncio/constants.py diff --git a/src/StdLib/Lib/asyncio/coroutines.py b/src/extensions/StdLib/Lib/asyncio/coroutines.py similarity index 100% rename from src/StdLib/Lib/asyncio/coroutines.py rename to src/extensions/StdLib/Lib/asyncio/coroutines.py diff --git a/src/StdLib/Lib/asyncio/events.py b/src/extensions/StdLib/Lib/asyncio/events.py similarity index 100% rename from src/StdLib/Lib/asyncio/events.py rename to src/extensions/StdLib/Lib/asyncio/events.py diff --git a/src/StdLib/Lib/asyncio/futures.py b/src/extensions/StdLib/Lib/asyncio/futures.py similarity index 100% rename from src/StdLib/Lib/asyncio/futures.py rename to src/extensions/StdLib/Lib/asyncio/futures.py diff --git a/src/StdLib/Lib/asyncio/locks.py b/src/extensions/StdLib/Lib/asyncio/locks.py similarity index 100% rename from src/StdLib/Lib/asyncio/locks.py rename to src/extensions/StdLib/Lib/asyncio/locks.py diff --git a/src/StdLib/Lib/asyncio/log.py b/src/extensions/StdLib/Lib/asyncio/log.py similarity index 100% rename from src/StdLib/Lib/asyncio/log.py rename to src/extensions/StdLib/Lib/asyncio/log.py diff --git a/src/StdLib/Lib/asyncio/proactor_events.py b/src/extensions/StdLib/Lib/asyncio/proactor_events.py similarity index 100% rename from src/StdLib/Lib/asyncio/proactor_events.py rename to src/extensions/StdLib/Lib/asyncio/proactor_events.py diff --git a/src/StdLib/Lib/asyncio/protocols.py b/src/extensions/StdLib/Lib/asyncio/protocols.py similarity index 100% rename from src/StdLib/Lib/asyncio/protocols.py rename to src/extensions/StdLib/Lib/asyncio/protocols.py diff --git a/src/StdLib/Lib/asyncio/queues.py b/src/extensions/StdLib/Lib/asyncio/queues.py similarity index 100% rename from src/StdLib/Lib/asyncio/queues.py rename to src/extensions/StdLib/Lib/asyncio/queues.py diff --git a/src/StdLib/Lib/asyncio/selector_events.py b/src/extensions/StdLib/Lib/asyncio/selector_events.py similarity index 100% rename from src/StdLib/Lib/asyncio/selector_events.py rename to src/extensions/StdLib/Lib/asyncio/selector_events.py diff --git a/src/StdLib/Lib/asyncio/sslproto.py b/src/extensions/StdLib/Lib/asyncio/sslproto.py similarity index 100% rename from src/StdLib/Lib/asyncio/sslproto.py rename to src/extensions/StdLib/Lib/asyncio/sslproto.py diff --git a/src/StdLib/Lib/asyncio/streams.py b/src/extensions/StdLib/Lib/asyncio/streams.py similarity index 100% rename from src/StdLib/Lib/asyncio/streams.py rename to src/extensions/StdLib/Lib/asyncio/streams.py diff --git a/src/StdLib/Lib/asyncio/subprocess.py b/src/extensions/StdLib/Lib/asyncio/subprocess.py similarity index 100% rename from src/StdLib/Lib/asyncio/subprocess.py rename to src/extensions/StdLib/Lib/asyncio/subprocess.py diff --git a/src/StdLib/Lib/asyncio/tasks.py b/src/extensions/StdLib/Lib/asyncio/tasks.py similarity index 100% rename from src/StdLib/Lib/asyncio/tasks.py rename to src/extensions/StdLib/Lib/asyncio/tasks.py diff --git a/src/StdLib/Lib/asyncio/test_utils.py b/src/extensions/StdLib/Lib/asyncio/test_utils.py similarity index 100% rename from src/StdLib/Lib/asyncio/test_utils.py rename to src/extensions/StdLib/Lib/asyncio/test_utils.py diff --git a/src/StdLib/Lib/asyncio/transports.py b/src/extensions/StdLib/Lib/asyncio/transports.py similarity index 100% rename from src/StdLib/Lib/asyncio/transports.py rename to src/extensions/StdLib/Lib/asyncio/transports.py diff --git a/src/StdLib/Lib/asyncio/unix_events.py b/src/extensions/StdLib/Lib/asyncio/unix_events.py similarity index 100% rename from src/StdLib/Lib/asyncio/unix_events.py rename to src/extensions/StdLib/Lib/asyncio/unix_events.py diff --git a/src/StdLib/Lib/asyncio/windows_events.py b/src/extensions/StdLib/Lib/asyncio/windows_events.py similarity index 100% rename from src/StdLib/Lib/asyncio/windows_events.py rename to src/extensions/StdLib/Lib/asyncio/windows_events.py diff --git a/src/StdLib/Lib/asyncio/windows_utils.py b/src/extensions/StdLib/Lib/asyncio/windows_utils.py similarity index 100% rename from src/StdLib/Lib/asyncio/windows_utils.py rename to src/extensions/StdLib/Lib/asyncio/windows_utils.py diff --git a/src/StdLib/Lib/asyncore.py b/src/extensions/StdLib/Lib/asyncore.py similarity index 100% rename from src/StdLib/Lib/asyncore.py rename to src/extensions/StdLib/Lib/asyncore.py diff --git a/src/StdLib/Lib/base64.py b/src/extensions/StdLib/Lib/base64.py similarity index 100% rename from src/StdLib/Lib/base64.py rename to src/extensions/StdLib/Lib/base64.py diff --git a/src/StdLib/Lib/bdb.py b/src/extensions/StdLib/Lib/bdb.py similarity index 100% rename from src/StdLib/Lib/bdb.py rename to src/extensions/StdLib/Lib/bdb.py diff --git a/src/StdLib/Lib/binhex.py b/src/extensions/StdLib/Lib/binhex.py similarity index 100% rename from src/StdLib/Lib/binhex.py rename to src/extensions/StdLib/Lib/binhex.py diff --git a/src/StdLib/Lib/bisect.py b/src/extensions/StdLib/Lib/bisect.py similarity index 100% rename from src/StdLib/Lib/bisect.py rename to src/extensions/StdLib/Lib/bisect.py diff --git a/src/StdLib/Lib/bz2.py b/src/extensions/StdLib/Lib/bz2.py similarity index 100% rename from src/StdLib/Lib/bz2.py rename to src/extensions/StdLib/Lib/bz2.py diff --git a/src/StdLib/Lib/cProfile.py b/src/extensions/StdLib/Lib/cProfile.py similarity index 100% rename from src/StdLib/Lib/cProfile.py rename to src/extensions/StdLib/Lib/cProfile.py diff --git a/src/StdLib/Lib/calendar.py b/src/extensions/StdLib/Lib/calendar.py similarity index 100% rename from src/StdLib/Lib/calendar.py rename to src/extensions/StdLib/Lib/calendar.py diff --git a/src/StdLib/Lib/cgi.py b/src/extensions/StdLib/Lib/cgi.py similarity index 100% rename from src/StdLib/Lib/cgi.py rename to src/extensions/StdLib/Lib/cgi.py diff --git a/src/StdLib/Lib/cgitb.py b/src/extensions/StdLib/Lib/cgitb.py similarity index 100% rename from src/StdLib/Lib/cgitb.py rename to src/extensions/StdLib/Lib/cgitb.py diff --git a/src/StdLib/Lib/chunk.py b/src/extensions/StdLib/Lib/chunk.py similarity index 100% rename from src/StdLib/Lib/chunk.py rename to src/extensions/StdLib/Lib/chunk.py diff --git a/src/StdLib/Lib/clrtype.py b/src/extensions/StdLib/Lib/clrtype.py similarity index 100% rename from src/StdLib/Lib/clrtype.py rename to src/extensions/StdLib/Lib/clrtype.py diff --git a/src/StdLib/Lib/cmd.py b/src/extensions/StdLib/Lib/cmd.py similarity index 100% rename from src/StdLib/Lib/cmd.py rename to src/extensions/StdLib/Lib/cmd.py diff --git a/src/StdLib/Lib/code.py b/src/extensions/StdLib/Lib/code.py similarity index 100% rename from src/StdLib/Lib/code.py rename to src/extensions/StdLib/Lib/code.py diff --git a/src/StdLib/Lib/codecs.py b/src/extensions/StdLib/Lib/codecs.py similarity index 100% rename from src/StdLib/Lib/codecs.py rename to src/extensions/StdLib/Lib/codecs.py diff --git a/src/StdLib/Lib/codeop.py b/src/extensions/StdLib/Lib/codeop.py similarity index 100% rename from src/StdLib/Lib/codeop.py rename to src/extensions/StdLib/Lib/codeop.py diff --git a/src/StdLib/Lib/collections/__init__.py b/src/extensions/StdLib/Lib/collections/__init__.py similarity index 100% rename from src/StdLib/Lib/collections/__init__.py rename to src/extensions/StdLib/Lib/collections/__init__.py diff --git a/src/StdLib/Lib/collections/__main__.py b/src/extensions/StdLib/Lib/collections/__main__.py similarity index 100% rename from src/StdLib/Lib/collections/__main__.py rename to src/extensions/StdLib/Lib/collections/__main__.py diff --git a/src/StdLib/Lib/collections/abc.py b/src/extensions/StdLib/Lib/collections/abc.py similarity index 100% rename from src/StdLib/Lib/collections/abc.py rename to src/extensions/StdLib/Lib/collections/abc.py diff --git a/src/StdLib/Lib/colorsys.py b/src/extensions/StdLib/Lib/colorsys.py similarity index 100% rename from src/StdLib/Lib/colorsys.py rename to src/extensions/StdLib/Lib/colorsys.py diff --git a/src/StdLib/Lib/compileall.py b/src/extensions/StdLib/Lib/compileall.py similarity index 100% rename from src/StdLib/Lib/compileall.py rename to src/extensions/StdLib/Lib/compileall.py diff --git a/src/StdLib/Lib/concurrent/__init__.py b/src/extensions/StdLib/Lib/concurrent/__init__.py similarity index 100% rename from src/StdLib/Lib/concurrent/__init__.py rename to src/extensions/StdLib/Lib/concurrent/__init__.py diff --git a/src/StdLib/Lib/concurrent/futures/__init__.py b/src/extensions/StdLib/Lib/concurrent/futures/__init__.py similarity index 100% rename from src/StdLib/Lib/concurrent/futures/__init__.py rename to src/extensions/StdLib/Lib/concurrent/futures/__init__.py diff --git a/src/StdLib/Lib/concurrent/futures/_base.py b/src/extensions/StdLib/Lib/concurrent/futures/_base.py similarity index 100% rename from src/StdLib/Lib/concurrent/futures/_base.py rename to src/extensions/StdLib/Lib/concurrent/futures/_base.py diff --git a/src/StdLib/Lib/concurrent/futures/process.py b/src/extensions/StdLib/Lib/concurrent/futures/process.py similarity index 100% rename from src/StdLib/Lib/concurrent/futures/process.py rename to src/extensions/StdLib/Lib/concurrent/futures/process.py diff --git a/src/StdLib/Lib/concurrent/futures/thread.py b/src/extensions/StdLib/Lib/concurrent/futures/thread.py similarity index 100% rename from src/StdLib/Lib/concurrent/futures/thread.py rename to src/extensions/StdLib/Lib/concurrent/futures/thread.py diff --git a/src/StdLib/Lib/configparser.py b/src/extensions/StdLib/Lib/configparser.py similarity index 100% rename from src/StdLib/Lib/configparser.py rename to src/extensions/StdLib/Lib/configparser.py diff --git a/src/StdLib/Lib/contextlib.py b/src/extensions/StdLib/Lib/contextlib.py similarity index 100% rename from src/StdLib/Lib/contextlib.py rename to src/extensions/StdLib/Lib/contextlib.py diff --git a/src/StdLib/Lib/copy.py b/src/extensions/StdLib/Lib/copy.py similarity index 100% rename from src/StdLib/Lib/copy.py rename to src/extensions/StdLib/Lib/copy.py diff --git a/src/StdLib/Lib/copyreg.py b/src/extensions/StdLib/Lib/copyreg.py similarity index 100% rename from src/StdLib/Lib/copyreg.py rename to src/extensions/StdLib/Lib/copyreg.py diff --git a/src/StdLib/Lib/crypt.py b/src/extensions/StdLib/Lib/crypt.py similarity index 100% rename from src/StdLib/Lib/crypt.py rename to src/extensions/StdLib/Lib/crypt.py diff --git a/src/StdLib/Lib/csv.py b/src/extensions/StdLib/Lib/csv.py similarity index 100% rename from src/StdLib/Lib/csv.py rename to src/extensions/StdLib/Lib/csv.py diff --git a/src/StdLib/Lib/ctypes/__init__.py b/src/extensions/StdLib/Lib/ctypes/__init__.py similarity index 100% rename from src/StdLib/Lib/ctypes/__init__.py rename to src/extensions/StdLib/Lib/ctypes/__init__.py diff --git a/src/StdLib/Lib/ctypes/_endian.py b/src/extensions/StdLib/Lib/ctypes/_endian.py similarity index 100% rename from src/StdLib/Lib/ctypes/_endian.py rename to src/extensions/StdLib/Lib/ctypes/_endian.py diff --git a/src/StdLib/Lib/ctypes/macholib/README.ctypes b/src/extensions/StdLib/Lib/ctypes/macholib/README.ctypes similarity index 100% rename from src/StdLib/Lib/ctypes/macholib/README.ctypes rename to src/extensions/StdLib/Lib/ctypes/macholib/README.ctypes diff --git a/src/StdLib/Lib/ctypes/macholib/__init__.py b/src/extensions/StdLib/Lib/ctypes/macholib/__init__.py similarity index 100% rename from src/StdLib/Lib/ctypes/macholib/__init__.py rename to src/extensions/StdLib/Lib/ctypes/macholib/__init__.py diff --git a/src/StdLib/Lib/ctypes/macholib/dyld.py b/src/extensions/StdLib/Lib/ctypes/macholib/dyld.py similarity index 100% rename from src/StdLib/Lib/ctypes/macholib/dyld.py rename to src/extensions/StdLib/Lib/ctypes/macholib/dyld.py diff --git a/src/StdLib/Lib/ctypes/macholib/dylib.py b/src/extensions/StdLib/Lib/ctypes/macholib/dylib.py similarity index 100% rename from src/StdLib/Lib/ctypes/macholib/dylib.py rename to src/extensions/StdLib/Lib/ctypes/macholib/dylib.py diff --git a/src/StdLib/Lib/ctypes/macholib/fetch_macholib b/src/extensions/StdLib/Lib/ctypes/macholib/fetch_macholib similarity index 100% rename from src/StdLib/Lib/ctypes/macholib/fetch_macholib rename to src/extensions/StdLib/Lib/ctypes/macholib/fetch_macholib diff --git a/src/StdLib/Lib/ctypes/macholib/fetch_macholib.bat b/src/extensions/StdLib/Lib/ctypes/macholib/fetch_macholib.bat similarity index 100% rename from src/StdLib/Lib/ctypes/macholib/fetch_macholib.bat rename to src/extensions/StdLib/Lib/ctypes/macholib/fetch_macholib.bat diff --git a/src/StdLib/Lib/ctypes/macholib/framework.py b/src/extensions/StdLib/Lib/ctypes/macholib/framework.py similarity index 100% rename from src/StdLib/Lib/ctypes/macholib/framework.py rename to src/extensions/StdLib/Lib/ctypes/macholib/framework.py diff --git a/src/StdLib/Lib/ctypes/test/__init__.py b/src/extensions/StdLib/Lib/ctypes/test/__init__.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/__init__.py rename to src/extensions/StdLib/Lib/ctypes/test/__init__.py diff --git a/src/StdLib/Lib/ctypes/test/__main__.py b/src/extensions/StdLib/Lib/ctypes/test/__main__.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/__main__.py rename to src/extensions/StdLib/Lib/ctypes/test/__main__.py diff --git a/src/StdLib/Lib/ctypes/test/test_anon.py b/src/extensions/StdLib/Lib/ctypes/test/test_anon.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_anon.py rename to src/extensions/StdLib/Lib/ctypes/test/test_anon.py diff --git a/src/StdLib/Lib/ctypes/test/test_array_in_pointer.py b/src/extensions/StdLib/Lib/ctypes/test/test_array_in_pointer.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_array_in_pointer.py rename to src/extensions/StdLib/Lib/ctypes/test/test_array_in_pointer.py diff --git a/src/StdLib/Lib/ctypes/test/test_arrays.py b/src/extensions/StdLib/Lib/ctypes/test/test_arrays.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_arrays.py rename to src/extensions/StdLib/Lib/ctypes/test/test_arrays.py diff --git a/src/StdLib/Lib/ctypes/test/test_as_parameter.py b/src/extensions/StdLib/Lib/ctypes/test/test_as_parameter.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_as_parameter.py rename to src/extensions/StdLib/Lib/ctypes/test/test_as_parameter.py diff --git a/src/StdLib/Lib/ctypes/test/test_bitfields.py b/src/extensions/StdLib/Lib/ctypes/test/test_bitfields.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_bitfields.py rename to src/extensions/StdLib/Lib/ctypes/test/test_bitfields.py diff --git a/src/StdLib/Lib/ctypes/test/test_buffers.py b/src/extensions/StdLib/Lib/ctypes/test/test_buffers.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_buffers.py rename to src/extensions/StdLib/Lib/ctypes/test/test_buffers.py diff --git a/src/StdLib/Lib/ctypes/test/test_bytes.py b/src/extensions/StdLib/Lib/ctypes/test/test_bytes.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_bytes.py rename to src/extensions/StdLib/Lib/ctypes/test/test_bytes.py diff --git a/src/StdLib/Lib/ctypes/test/test_byteswap.py b/src/extensions/StdLib/Lib/ctypes/test/test_byteswap.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_byteswap.py rename to src/extensions/StdLib/Lib/ctypes/test/test_byteswap.py diff --git a/src/StdLib/Lib/ctypes/test/test_callbacks.py b/src/extensions/StdLib/Lib/ctypes/test/test_callbacks.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_callbacks.py rename to src/extensions/StdLib/Lib/ctypes/test/test_callbacks.py diff --git a/src/StdLib/Lib/ctypes/test/test_cast.py b/src/extensions/StdLib/Lib/ctypes/test/test_cast.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_cast.py rename to src/extensions/StdLib/Lib/ctypes/test/test_cast.py diff --git a/src/StdLib/Lib/ctypes/test/test_cfuncs.py b/src/extensions/StdLib/Lib/ctypes/test/test_cfuncs.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_cfuncs.py rename to src/extensions/StdLib/Lib/ctypes/test/test_cfuncs.py diff --git a/src/StdLib/Lib/ctypes/test/test_checkretval.py b/src/extensions/StdLib/Lib/ctypes/test/test_checkretval.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_checkretval.py rename to src/extensions/StdLib/Lib/ctypes/test/test_checkretval.py diff --git a/src/StdLib/Lib/ctypes/test/test_delattr.py b/src/extensions/StdLib/Lib/ctypes/test/test_delattr.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_delattr.py rename to src/extensions/StdLib/Lib/ctypes/test/test_delattr.py diff --git a/src/StdLib/Lib/ctypes/test/test_errno.py b/src/extensions/StdLib/Lib/ctypes/test/test_errno.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_errno.py rename to src/extensions/StdLib/Lib/ctypes/test/test_errno.py diff --git a/src/StdLib/Lib/ctypes/test/test_find.py b/src/extensions/StdLib/Lib/ctypes/test/test_find.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_find.py rename to src/extensions/StdLib/Lib/ctypes/test/test_find.py diff --git a/src/StdLib/Lib/ctypes/test/test_frombuffer.py b/src/extensions/StdLib/Lib/ctypes/test/test_frombuffer.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_frombuffer.py rename to src/extensions/StdLib/Lib/ctypes/test/test_frombuffer.py diff --git a/src/StdLib/Lib/ctypes/test/test_funcptr.py b/src/extensions/StdLib/Lib/ctypes/test/test_funcptr.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_funcptr.py rename to src/extensions/StdLib/Lib/ctypes/test/test_funcptr.py diff --git a/src/StdLib/Lib/ctypes/test/test_functions.py b/src/extensions/StdLib/Lib/ctypes/test/test_functions.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_functions.py rename to src/extensions/StdLib/Lib/ctypes/test/test_functions.py diff --git a/src/StdLib/Lib/ctypes/test/test_incomplete.py b/src/extensions/StdLib/Lib/ctypes/test/test_incomplete.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_incomplete.py rename to src/extensions/StdLib/Lib/ctypes/test/test_incomplete.py diff --git a/src/StdLib/Lib/ctypes/test/test_init.py b/src/extensions/StdLib/Lib/ctypes/test/test_init.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_init.py rename to src/extensions/StdLib/Lib/ctypes/test/test_init.py diff --git a/src/StdLib/Lib/ctypes/test/test_internals.py b/src/extensions/StdLib/Lib/ctypes/test/test_internals.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_internals.py rename to src/extensions/StdLib/Lib/ctypes/test/test_internals.py diff --git a/src/StdLib/Lib/ctypes/test/test_keeprefs.py b/src/extensions/StdLib/Lib/ctypes/test/test_keeprefs.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_keeprefs.py rename to src/extensions/StdLib/Lib/ctypes/test/test_keeprefs.py diff --git a/src/StdLib/Lib/ctypes/test/test_libc.py b/src/extensions/StdLib/Lib/ctypes/test/test_libc.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_libc.py rename to src/extensions/StdLib/Lib/ctypes/test/test_libc.py diff --git a/src/StdLib/Lib/ctypes/test/test_loading.py b/src/extensions/StdLib/Lib/ctypes/test/test_loading.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_loading.py rename to src/extensions/StdLib/Lib/ctypes/test/test_loading.py diff --git a/src/StdLib/Lib/ctypes/test/test_macholib.py b/src/extensions/StdLib/Lib/ctypes/test/test_macholib.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_macholib.py rename to src/extensions/StdLib/Lib/ctypes/test/test_macholib.py diff --git a/src/StdLib/Lib/ctypes/test/test_memfunctions.py b/src/extensions/StdLib/Lib/ctypes/test/test_memfunctions.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_memfunctions.py rename to src/extensions/StdLib/Lib/ctypes/test/test_memfunctions.py diff --git a/src/StdLib/Lib/ctypes/test/test_numbers.py b/src/extensions/StdLib/Lib/ctypes/test/test_numbers.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_numbers.py rename to src/extensions/StdLib/Lib/ctypes/test/test_numbers.py diff --git a/src/StdLib/Lib/ctypes/test/test_objects.py b/src/extensions/StdLib/Lib/ctypes/test/test_objects.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_objects.py rename to src/extensions/StdLib/Lib/ctypes/test/test_objects.py diff --git a/src/StdLib/Lib/ctypes/test/test_parameters.py b/src/extensions/StdLib/Lib/ctypes/test/test_parameters.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_parameters.py rename to src/extensions/StdLib/Lib/ctypes/test/test_parameters.py diff --git a/src/StdLib/Lib/ctypes/test/test_pep3118.py b/src/extensions/StdLib/Lib/ctypes/test/test_pep3118.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_pep3118.py rename to src/extensions/StdLib/Lib/ctypes/test/test_pep3118.py diff --git a/src/StdLib/Lib/ctypes/test/test_pickling.py b/src/extensions/StdLib/Lib/ctypes/test/test_pickling.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_pickling.py rename to src/extensions/StdLib/Lib/ctypes/test/test_pickling.py diff --git a/src/StdLib/Lib/ctypes/test/test_pointers.py b/src/extensions/StdLib/Lib/ctypes/test/test_pointers.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_pointers.py rename to src/extensions/StdLib/Lib/ctypes/test/test_pointers.py diff --git a/src/StdLib/Lib/ctypes/test/test_prototypes.py b/src/extensions/StdLib/Lib/ctypes/test/test_prototypes.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_prototypes.py rename to src/extensions/StdLib/Lib/ctypes/test/test_prototypes.py diff --git a/src/StdLib/Lib/ctypes/test/test_python_api.py b/src/extensions/StdLib/Lib/ctypes/test/test_python_api.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_python_api.py rename to src/extensions/StdLib/Lib/ctypes/test/test_python_api.py diff --git a/src/StdLib/Lib/ctypes/test/test_random_things.py b/src/extensions/StdLib/Lib/ctypes/test/test_random_things.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_random_things.py rename to src/extensions/StdLib/Lib/ctypes/test/test_random_things.py diff --git a/src/StdLib/Lib/ctypes/test/test_refcounts.py b/src/extensions/StdLib/Lib/ctypes/test/test_refcounts.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_refcounts.py rename to src/extensions/StdLib/Lib/ctypes/test/test_refcounts.py diff --git a/src/StdLib/Lib/ctypes/test/test_repr.py b/src/extensions/StdLib/Lib/ctypes/test/test_repr.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_repr.py rename to src/extensions/StdLib/Lib/ctypes/test/test_repr.py diff --git a/src/StdLib/Lib/ctypes/test/test_returnfuncptrs.py b/src/extensions/StdLib/Lib/ctypes/test/test_returnfuncptrs.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_returnfuncptrs.py rename to src/extensions/StdLib/Lib/ctypes/test/test_returnfuncptrs.py diff --git a/src/StdLib/Lib/ctypes/test/test_simplesubclasses.py b/src/extensions/StdLib/Lib/ctypes/test/test_simplesubclasses.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_simplesubclasses.py rename to src/extensions/StdLib/Lib/ctypes/test/test_simplesubclasses.py diff --git a/src/StdLib/Lib/ctypes/test/test_sizes.py b/src/extensions/StdLib/Lib/ctypes/test/test_sizes.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_sizes.py rename to src/extensions/StdLib/Lib/ctypes/test/test_sizes.py diff --git a/src/StdLib/Lib/ctypes/test/test_slicing.py b/src/extensions/StdLib/Lib/ctypes/test/test_slicing.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_slicing.py rename to src/extensions/StdLib/Lib/ctypes/test/test_slicing.py diff --git a/src/StdLib/Lib/ctypes/test/test_stringptr.py b/src/extensions/StdLib/Lib/ctypes/test/test_stringptr.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_stringptr.py rename to src/extensions/StdLib/Lib/ctypes/test/test_stringptr.py diff --git a/src/StdLib/Lib/ctypes/test/test_strings.py b/src/extensions/StdLib/Lib/ctypes/test/test_strings.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_strings.py rename to src/extensions/StdLib/Lib/ctypes/test/test_strings.py diff --git a/src/StdLib/Lib/ctypes/test/test_struct_fields.py b/src/extensions/StdLib/Lib/ctypes/test/test_struct_fields.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_struct_fields.py rename to src/extensions/StdLib/Lib/ctypes/test/test_struct_fields.py diff --git a/src/StdLib/Lib/ctypes/test/test_structures.py b/src/extensions/StdLib/Lib/ctypes/test/test_structures.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_structures.py rename to src/extensions/StdLib/Lib/ctypes/test/test_structures.py diff --git a/src/StdLib/Lib/ctypes/test/test_unaligned_structures.py b/src/extensions/StdLib/Lib/ctypes/test/test_unaligned_structures.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_unaligned_structures.py rename to src/extensions/StdLib/Lib/ctypes/test/test_unaligned_structures.py diff --git a/src/StdLib/Lib/ctypes/test/test_unicode.py b/src/extensions/StdLib/Lib/ctypes/test/test_unicode.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_unicode.py rename to src/extensions/StdLib/Lib/ctypes/test/test_unicode.py diff --git a/src/StdLib/Lib/ctypes/test/test_values.py b/src/extensions/StdLib/Lib/ctypes/test/test_values.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_values.py rename to src/extensions/StdLib/Lib/ctypes/test/test_values.py diff --git a/src/StdLib/Lib/ctypes/test/test_varsize_struct.py b/src/extensions/StdLib/Lib/ctypes/test/test_varsize_struct.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_varsize_struct.py rename to src/extensions/StdLib/Lib/ctypes/test/test_varsize_struct.py diff --git a/src/StdLib/Lib/ctypes/test/test_win32.py b/src/extensions/StdLib/Lib/ctypes/test/test_win32.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_win32.py rename to src/extensions/StdLib/Lib/ctypes/test/test_win32.py diff --git a/src/StdLib/Lib/ctypes/test/test_wintypes.py b/src/extensions/StdLib/Lib/ctypes/test/test_wintypes.py similarity index 100% rename from src/StdLib/Lib/ctypes/test/test_wintypes.py rename to src/extensions/StdLib/Lib/ctypes/test/test_wintypes.py diff --git a/src/StdLib/Lib/ctypes/util.py b/src/extensions/StdLib/Lib/ctypes/util.py similarity index 100% rename from src/StdLib/Lib/ctypes/util.py rename to src/extensions/StdLib/Lib/ctypes/util.py diff --git a/src/StdLib/Lib/ctypes/wintypes.py b/src/extensions/StdLib/Lib/ctypes/wintypes.py similarity index 100% rename from src/StdLib/Lib/ctypes/wintypes.py rename to src/extensions/StdLib/Lib/ctypes/wintypes.py diff --git a/src/StdLib/Lib/curses/__init__.py b/src/extensions/StdLib/Lib/curses/__init__.py similarity index 100% rename from src/StdLib/Lib/curses/__init__.py rename to src/extensions/StdLib/Lib/curses/__init__.py diff --git a/src/StdLib/Lib/curses/ascii.py b/src/extensions/StdLib/Lib/curses/ascii.py similarity index 100% rename from src/StdLib/Lib/curses/ascii.py rename to src/extensions/StdLib/Lib/curses/ascii.py diff --git a/src/StdLib/Lib/curses/has_key.py b/src/extensions/StdLib/Lib/curses/has_key.py similarity index 100% rename from src/StdLib/Lib/curses/has_key.py rename to src/extensions/StdLib/Lib/curses/has_key.py diff --git a/src/StdLib/Lib/curses/panel.py b/src/extensions/StdLib/Lib/curses/panel.py similarity index 100% rename from src/StdLib/Lib/curses/panel.py rename to src/extensions/StdLib/Lib/curses/panel.py diff --git a/src/StdLib/Lib/curses/textpad.py b/src/extensions/StdLib/Lib/curses/textpad.py similarity index 100% rename from src/StdLib/Lib/curses/textpad.py rename to src/extensions/StdLib/Lib/curses/textpad.py diff --git a/src/StdLib/Lib/datetime.py b/src/extensions/StdLib/Lib/datetime.py similarity index 100% rename from src/StdLib/Lib/datetime.py rename to src/extensions/StdLib/Lib/datetime.py diff --git a/src/StdLib/Lib/dbm/__init__.py b/src/extensions/StdLib/Lib/dbm/__init__.py similarity index 100% rename from src/StdLib/Lib/dbm/__init__.py rename to src/extensions/StdLib/Lib/dbm/__init__.py diff --git a/src/StdLib/Lib/dbm/dumb.py b/src/extensions/StdLib/Lib/dbm/dumb.py similarity index 100% rename from src/StdLib/Lib/dbm/dumb.py rename to src/extensions/StdLib/Lib/dbm/dumb.py diff --git a/src/StdLib/Lib/dbm/gnu.py b/src/extensions/StdLib/Lib/dbm/gnu.py similarity index 100% rename from src/StdLib/Lib/dbm/gnu.py rename to src/extensions/StdLib/Lib/dbm/gnu.py diff --git a/src/StdLib/Lib/dbm/ndbm.py b/src/extensions/StdLib/Lib/dbm/ndbm.py similarity index 100% rename from src/StdLib/Lib/dbm/ndbm.py rename to src/extensions/StdLib/Lib/dbm/ndbm.py diff --git a/src/StdLib/Lib/decimal.py b/src/extensions/StdLib/Lib/decimal.py similarity index 100% rename from src/StdLib/Lib/decimal.py rename to src/extensions/StdLib/Lib/decimal.py diff --git a/src/StdLib/Lib/difflib.py b/src/extensions/StdLib/Lib/difflib.py similarity index 100% rename from src/StdLib/Lib/difflib.py rename to src/extensions/StdLib/Lib/difflib.py diff --git a/src/StdLib/Lib/dis.py b/src/extensions/StdLib/Lib/dis.py similarity index 100% rename from src/StdLib/Lib/dis.py rename to src/extensions/StdLib/Lib/dis.py diff --git a/src/StdLib/Lib/distutils/README b/src/extensions/StdLib/Lib/distutils/README similarity index 100% rename from src/StdLib/Lib/distutils/README rename to src/extensions/StdLib/Lib/distutils/README diff --git a/src/StdLib/Lib/distutils/__init__.py b/src/extensions/StdLib/Lib/distutils/__init__.py similarity index 100% rename from src/StdLib/Lib/distutils/__init__.py rename to src/extensions/StdLib/Lib/distutils/__init__.py diff --git a/src/StdLib/Lib/distutils/archive_util.py b/src/extensions/StdLib/Lib/distutils/archive_util.py similarity index 100% rename from src/StdLib/Lib/distutils/archive_util.py rename to src/extensions/StdLib/Lib/distutils/archive_util.py diff --git a/src/StdLib/Lib/distutils/bcppcompiler.py b/src/extensions/StdLib/Lib/distutils/bcppcompiler.py similarity index 100% rename from src/StdLib/Lib/distutils/bcppcompiler.py rename to src/extensions/StdLib/Lib/distutils/bcppcompiler.py diff --git a/src/StdLib/Lib/distutils/ccompiler.py b/src/extensions/StdLib/Lib/distutils/ccompiler.py similarity index 100% rename from src/StdLib/Lib/distutils/ccompiler.py rename to src/extensions/StdLib/Lib/distutils/ccompiler.py diff --git a/src/StdLib/Lib/distutils/cmd.py b/src/extensions/StdLib/Lib/distutils/cmd.py similarity index 100% rename from src/StdLib/Lib/distutils/cmd.py rename to src/extensions/StdLib/Lib/distutils/cmd.py diff --git a/src/StdLib/Lib/distutils/command/__init__.py b/src/extensions/StdLib/Lib/distutils/command/__init__.py similarity index 100% rename from src/StdLib/Lib/distutils/command/__init__.py rename to src/extensions/StdLib/Lib/distutils/command/__init__.py diff --git a/src/StdLib/Lib/distutils/command/bdist.py b/src/extensions/StdLib/Lib/distutils/command/bdist.py similarity index 100% rename from src/StdLib/Lib/distutils/command/bdist.py rename to src/extensions/StdLib/Lib/distutils/command/bdist.py diff --git a/src/StdLib/Lib/distutils/command/bdist_dumb.py b/src/extensions/StdLib/Lib/distutils/command/bdist_dumb.py similarity index 100% rename from src/StdLib/Lib/distutils/command/bdist_dumb.py rename to src/extensions/StdLib/Lib/distutils/command/bdist_dumb.py diff --git a/src/StdLib/Lib/distutils/command/bdist_msi.py b/src/extensions/StdLib/Lib/distutils/command/bdist_msi.py similarity index 100% rename from src/StdLib/Lib/distutils/command/bdist_msi.py rename to src/extensions/StdLib/Lib/distutils/command/bdist_msi.py diff --git a/src/StdLib/Lib/distutils/command/bdist_rpm.py b/src/extensions/StdLib/Lib/distutils/command/bdist_rpm.py similarity index 100% rename from src/StdLib/Lib/distutils/command/bdist_rpm.py rename to src/extensions/StdLib/Lib/distutils/command/bdist_rpm.py diff --git a/src/StdLib/Lib/distutils/command/bdist_wininst.py b/src/extensions/StdLib/Lib/distutils/command/bdist_wininst.py similarity index 100% rename from src/StdLib/Lib/distutils/command/bdist_wininst.py rename to src/extensions/StdLib/Lib/distutils/command/bdist_wininst.py diff --git a/src/StdLib/Lib/distutils/command/build.py b/src/extensions/StdLib/Lib/distutils/command/build.py similarity index 100% rename from src/StdLib/Lib/distutils/command/build.py rename to src/extensions/StdLib/Lib/distutils/command/build.py diff --git a/src/StdLib/Lib/distutils/command/build_clib.py b/src/extensions/StdLib/Lib/distutils/command/build_clib.py similarity index 100% rename from src/StdLib/Lib/distutils/command/build_clib.py rename to src/extensions/StdLib/Lib/distutils/command/build_clib.py diff --git a/src/StdLib/Lib/distutils/command/build_ext.py b/src/extensions/StdLib/Lib/distutils/command/build_ext.py similarity index 100% rename from src/StdLib/Lib/distutils/command/build_ext.py rename to src/extensions/StdLib/Lib/distutils/command/build_ext.py diff --git a/src/StdLib/Lib/distutils/command/build_py.py b/src/extensions/StdLib/Lib/distutils/command/build_py.py similarity index 100% rename from src/StdLib/Lib/distutils/command/build_py.py rename to src/extensions/StdLib/Lib/distutils/command/build_py.py diff --git a/src/StdLib/Lib/distutils/command/build_scripts.py b/src/extensions/StdLib/Lib/distutils/command/build_scripts.py similarity index 100% rename from src/StdLib/Lib/distutils/command/build_scripts.py rename to src/extensions/StdLib/Lib/distutils/command/build_scripts.py diff --git a/src/StdLib/Lib/distutils/command/check.py b/src/extensions/StdLib/Lib/distutils/command/check.py similarity index 100% rename from src/StdLib/Lib/distutils/command/check.py rename to src/extensions/StdLib/Lib/distutils/command/check.py diff --git a/src/StdLib/Lib/distutils/command/clean.py b/src/extensions/StdLib/Lib/distutils/command/clean.py similarity index 100% rename from src/StdLib/Lib/distutils/command/clean.py rename to src/extensions/StdLib/Lib/distutils/command/clean.py diff --git a/src/StdLib/Lib/distutils/command/command_template b/src/extensions/StdLib/Lib/distutils/command/command_template similarity index 100% rename from src/StdLib/Lib/distutils/command/command_template rename to src/extensions/StdLib/Lib/distutils/command/command_template diff --git a/src/StdLib/Lib/distutils/command/config.py b/src/extensions/StdLib/Lib/distutils/command/config.py similarity index 100% rename from src/StdLib/Lib/distutils/command/config.py rename to src/extensions/StdLib/Lib/distutils/command/config.py diff --git a/src/StdLib/Lib/distutils/command/install.py b/src/extensions/StdLib/Lib/distutils/command/install.py similarity index 100% rename from src/StdLib/Lib/distutils/command/install.py rename to src/extensions/StdLib/Lib/distutils/command/install.py diff --git a/src/StdLib/Lib/distutils/command/install_data.py b/src/extensions/StdLib/Lib/distutils/command/install_data.py similarity index 100% rename from src/StdLib/Lib/distutils/command/install_data.py rename to src/extensions/StdLib/Lib/distutils/command/install_data.py diff --git a/src/StdLib/Lib/distutils/command/install_egg_info.py b/src/extensions/StdLib/Lib/distutils/command/install_egg_info.py similarity index 100% rename from src/StdLib/Lib/distutils/command/install_egg_info.py rename to src/extensions/StdLib/Lib/distutils/command/install_egg_info.py diff --git a/src/StdLib/Lib/distutils/command/install_headers.py b/src/extensions/StdLib/Lib/distutils/command/install_headers.py similarity index 100% rename from src/StdLib/Lib/distutils/command/install_headers.py rename to src/extensions/StdLib/Lib/distutils/command/install_headers.py diff --git a/src/StdLib/Lib/distutils/command/install_lib.py b/src/extensions/StdLib/Lib/distutils/command/install_lib.py similarity index 100% rename from src/StdLib/Lib/distutils/command/install_lib.py rename to src/extensions/StdLib/Lib/distutils/command/install_lib.py diff --git a/src/StdLib/Lib/distutils/command/install_scripts.py b/src/extensions/StdLib/Lib/distutils/command/install_scripts.py similarity index 100% rename from src/StdLib/Lib/distutils/command/install_scripts.py rename to src/extensions/StdLib/Lib/distutils/command/install_scripts.py diff --git a/src/StdLib/Lib/distutils/command/register.py b/src/extensions/StdLib/Lib/distutils/command/register.py similarity index 100% rename from src/StdLib/Lib/distutils/command/register.py rename to src/extensions/StdLib/Lib/distutils/command/register.py diff --git a/src/StdLib/Lib/distutils/command/sdist.py b/src/extensions/StdLib/Lib/distutils/command/sdist.py similarity index 100% rename from src/StdLib/Lib/distutils/command/sdist.py rename to src/extensions/StdLib/Lib/distutils/command/sdist.py diff --git a/src/StdLib/Lib/distutils/command/upload.py b/src/extensions/StdLib/Lib/distutils/command/upload.py similarity index 100% rename from src/StdLib/Lib/distutils/command/upload.py rename to src/extensions/StdLib/Lib/distutils/command/upload.py diff --git a/src/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe b/src/extensions/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe similarity index 100% rename from src/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe rename to src/extensions/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe diff --git a/src/StdLib/Lib/distutils/command/wininst-10.0.exe b/src/extensions/StdLib/Lib/distutils/command/wininst-10.0.exe similarity index 100% rename from src/StdLib/Lib/distutils/command/wininst-10.0.exe rename to src/extensions/StdLib/Lib/distutils/command/wininst-10.0.exe diff --git a/src/StdLib/Lib/distutils/command/wininst-6.0.exe b/src/extensions/StdLib/Lib/distutils/command/wininst-6.0.exe similarity index 100% rename from src/StdLib/Lib/distutils/command/wininst-6.0.exe rename to src/extensions/StdLib/Lib/distutils/command/wininst-6.0.exe diff --git a/src/StdLib/Lib/distutils/command/wininst-7.1.exe b/src/extensions/StdLib/Lib/distutils/command/wininst-7.1.exe similarity index 100% rename from src/StdLib/Lib/distutils/command/wininst-7.1.exe rename to src/extensions/StdLib/Lib/distutils/command/wininst-7.1.exe diff --git a/src/StdLib/Lib/distutils/command/wininst-8.0.exe b/src/extensions/StdLib/Lib/distutils/command/wininst-8.0.exe similarity index 100% rename from src/StdLib/Lib/distutils/command/wininst-8.0.exe rename to src/extensions/StdLib/Lib/distutils/command/wininst-8.0.exe diff --git a/src/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe b/src/extensions/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe similarity index 100% rename from src/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe rename to src/extensions/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe diff --git a/src/StdLib/Lib/distutils/command/wininst-9.0.exe b/src/extensions/StdLib/Lib/distutils/command/wininst-9.0.exe similarity index 100% rename from src/StdLib/Lib/distutils/command/wininst-9.0.exe rename to src/extensions/StdLib/Lib/distutils/command/wininst-9.0.exe diff --git a/src/StdLib/Lib/distutils/config.py b/src/extensions/StdLib/Lib/distutils/config.py similarity index 100% rename from src/StdLib/Lib/distutils/config.py rename to src/extensions/StdLib/Lib/distutils/config.py diff --git a/src/StdLib/Lib/distutils/core.py b/src/extensions/StdLib/Lib/distutils/core.py similarity index 100% rename from src/StdLib/Lib/distutils/core.py rename to src/extensions/StdLib/Lib/distutils/core.py diff --git a/src/StdLib/Lib/distutils/cygwinccompiler.py b/src/extensions/StdLib/Lib/distutils/cygwinccompiler.py similarity index 100% rename from src/StdLib/Lib/distutils/cygwinccompiler.py rename to src/extensions/StdLib/Lib/distutils/cygwinccompiler.py diff --git a/src/StdLib/Lib/distutils/debug.py b/src/extensions/StdLib/Lib/distutils/debug.py similarity index 100% rename from src/StdLib/Lib/distutils/debug.py rename to src/extensions/StdLib/Lib/distutils/debug.py diff --git a/src/StdLib/Lib/distutils/dep_util.py b/src/extensions/StdLib/Lib/distutils/dep_util.py similarity index 100% rename from src/StdLib/Lib/distutils/dep_util.py rename to src/extensions/StdLib/Lib/distutils/dep_util.py diff --git a/src/StdLib/Lib/distutils/dir_util.py b/src/extensions/StdLib/Lib/distutils/dir_util.py similarity index 100% rename from src/StdLib/Lib/distutils/dir_util.py rename to src/extensions/StdLib/Lib/distutils/dir_util.py diff --git a/src/StdLib/Lib/distutils/dist.py b/src/extensions/StdLib/Lib/distutils/dist.py similarity index 100% rename from src/StdLib/Lib/distutils/dist.py rename to src/extensions/StdLib/Lib/distutils/dist.py diff --git a/src/StdLib/Lib/distutils/errors.py b/src/extensions/StdLib/Lib/distutils/errors.py similarity index 100% rename from src/StdLib/Lib/distutils/errors.py rename to src/extensions/StdLib/Lib/distutils/errors.py diff --git a/src/StdLib/Lib/distutils/extension.py b/src/extensions/StdLib/Lib/distutils/extension.py similarity index 100% rename from src/StdLib/Lib/distutils/extension.py rename to src/extensions/StdLib/Lib/distutils/extension.py diff --git a/src/StdLib/Lib/distutils/fancy_getopt.py b/src/extensions/StdLib/Lib/distutils/fancy_getopt.py similarity index 100% rename from src/StdLib/Lib/distutils/fancy_getopt.py rename to src/extensions/StdLib/Lib/distutils/fancy_getopt.py diff --git a/src/StdLib/Lib/distutils/file_util.py b/src/extensions/StdLib/Lib/distutils/file_util.py similarity index 100% rename from src/StdLib/Lib/distutils/file_util.py rename to src/extensions/StdLib/Lib/distutils/file_util.py diff --git a/src/StdLib/Lib/distutils/filelist.py b/src/extensions/StdLib/Lib/distutils/filelist.py similarity index 100% rename from src/StdLib/Lib/distutils/filelist.py rename to src/extensions/StdLib/Lib/distutils/filelist.py diff --git a/src/StdLib/Lib/distutils/log.py b/src/extensions/StdLib/Lib/distutils/log.py similarity index 100% rename from src/StdLib/Lib/distutils/log.py rename to src/extensions/StdLib/Lib/distutils/log.py diff --git a/src/StdLib/Lib/distutils/msvc9compiler.py b/src/extensions/StdLib/Lib/distutils/msvc9compiler.py similarity index 100% rename from src/StdLib/Lib/distutils/msvc9compiler.py rename to src/extensions/StdLib/Lib/distutils/msvc9compiler.py diff --git a/src/StdLib/Lib/distutils/msvccompiler.py b/src/extensions/StdLib/Lib/distutils/msvccompiler.py similarity index 100% rename from src/StdLib/Lib/distutils/msvccompiler.py rename to src/extensions/StdLib/Lib/distutils/msvccompiler.py diff --git a/src/StdLib/Lib/distutils/spawn.py b/src/extensions/StdLib/Lib/distutils/spawn.py similarity index 100% rename from src/StdLib/Lib/distutils/spawn.py rename to src/extensions/StdLib/Lib/distutils/spawn.py diff --git a/src/StdLib/Lib/distutils/sysconfig.py b/src/extensions/StdLib/Lib/distutils/sysconfig.py similarity index 100% rename from src/StdLib/Lib/distutils/sysconfig.py rename to src/extensions/StdLib/Lib/distutils/sysconfig.py diff --git a/src/StdLib/Lib/distutils/tests/Setup.sample b/src/extensions/StdLib/Lib/distutils/tests/Setup.sample similarity index 100% rename from src/StdLib/Lib/distutils/tests/Setup.sample rename to src/extensions/StdLib/Lib/distutils/tests/Setup.sample diff --git a/src/StdLib/Lib/distutils/tests/__init__.py b/src/extensions/StdLib/Lib/distutils/tests/__init__.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/__init__.py rename to src/extensions/StdLib/Lib/distutils/tests/__init__.py diff --git a/src/StdLib/Lib/distutils/tests/support.py b/src/extensions/StdLib/Lib/distutils/tests/support.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/support.py rename to src/extensions/StdLib/Lib/distutils/tests/support.py diff --git a/src/StdLib/Lib/distutils/tests/test_archive_util.py b/src/extensions/StdLib/Lib/distutils/tests/test_archive_util.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_archive_util.py rename to src/extensions/StdLib/Lib/distutils/tests/test_archive_util.py diff --git a/src/StdLib/Lib/distutils/tests/test_bdist.py b/src/extensions/StdLib/Lib/distutils/tests/test_bdist.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_bdist.py rename to src/extensions/StdLib/Lib/distutils/tests/test_bdist.py diff --git a/src/StdLib/Lib/distutils/tests/test_bdist_dumb.py b/src/extensions/StdLib/Lib/distutils/tests/test_bdist_dumb.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_bdist_dumb.py rename to src/extensions/StdLib/Lib/distutils/tests/test_bdist_dumb.py diff --git a/src/StdLib/Lib/distutils/tests/test_bdist_msi.py b/src/extensions/StdLib/Lib/distutils/tests/test_bdist_msi.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_bdist_msi.py rename to src/extensions/StdLib/Lib/distutils/tests/test_bdist_msi.py diff --git a/src/StdLib/Lib/distutils/tests/test_bdist_rpm.py b/src/extensions/StdLib/Lib/distutils/tests/test_bdist_rpm.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_bdist_rpm.py rename to src/extensions/StdLib/Lib/distutils/tests/test_bdist_rpm.py diff --git a/src/StdLib/Lib/distutils/tests/test_bdist_wininst.py b/src/extensions/StdLib/Lib/distutils/tests/test_bdist_wininst.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_bdist_wininst.py rename to src/extensions/StdLib/Lib/distutils/tests/test_bdist_wininst.py diff --git a/src/StdLib/Lib/distutils/tests/test_build.py b/src/extensions/StdLib/Lib/distutils/tests/test_build.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_build.py rename to src/extensions/StdLib/Lib/distutils/tests/test_build.py diff --git a/src/StdLib/Lib/distutils/tests/test_build_clib.py b/src/extensions/StdLib/Lib/distutils/tests/test_build_clib.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_build_clib.py rename to src/extensions/StdLib/Lib/distutils/tests/test_build_clib.py diff --git a/src/StdLib/Lib/distutils/tests/test_build_ext.py b/src/extensions/StdLib/Lib/distutils/tests/test_build_ext.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_build_ext.py rename to src/extensions/StdLib/Lib/distutils/tests/test_build_ext.py diff --git a/src/StdLib/Lib/distutils/tests/test_build_py.py b/src/extensions/StdLib/Lib/distutils/tests/test_build_py.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_build_py.py rename to src/extensions/StdLib/Lib/distutils/tests/test_build_py.py diff --git a/src/StdLib/Lib/distutils/tests/test_build_scripts.py b/src/extensions/StdLib/Lib/distutils/tests/test_build_scripts.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_build_scripts.py rename to src/extensions/StdLib/Lib/distutils/tests/test_build_scripts.py diff --git a/src/StdLib/Lib/distutils/tests/test_check.py b/src/extensions/StdLib/Lib/distutils/tests/test_check.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_check.py rename to src/extensions/StdLib/Lib/distutils/tests/test_check.py diff --git a/src/StdLib/Lib/distutils/tests/test_clean.py b/src/extensions/StdLib/Lib/distutils/tests/test_clean.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_clean.py rename to src/extensions/StdLib/Lib/distutils/tests/test_clean.py diff --git a/src/StdLib/Lib/distutils/tests/test_cmd.py b/src/extensions/StdLib/Lib/distutils/tests/test_cmd.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_cmd.py rename to src/extensions/StdLib/Lib/distutils/tests/test_cmd.py diff --git a/src/StdLib/Lib/distutils/tests/test_config.py b/src/extensions/StdLib/Lib/distutils/tests/test_config.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_config.py rename to src/extensions/StdLib/Lib/distutils/tests/test_config.py diff --git a/src/StdLib/Lib/distutils/tests/test_config_cmd.py b/src/extensions/StdLib/Lib/distutils/tests/test_config_cmd.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_config_cmd.py rename to src/extensions/StdLib/Lib/distutils/tests/test_config_cmd.py diff --git a/src/StdLib/Lib/distutils/tests/test_core.py b/src/extensions/StdLib/Lib/distutils/tests/test_core.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_core.py rename to src/extensions/StdLib/Lib/distutils/tests/test_core.py diff --git a/src/StdLib/Lib/distutils/tests/test_cygwinccompiler.py b/src/extensions/StdLib/Lib/distutils/tests/test_cygwinccompiler.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_cygwinccompiler.py rename to src/extensions/StdLib/Lib/distutils/tests/test_cygwinccompiler.py diff --git a/src/StdLib/Lib/distutils/tests/test_dep_util.py b/src/extensions/StdLib/Lib/distutils/tests/test_dep_util.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_dep_util.py rename to src/extensions/StdLib/Lib/distutils/tests/test_dep_util.py diff --git a/src/StdLib/Lib/distutils/tests/test_dir_util.py b/src/extensions/StdLib/Lib/distutils/tests/test_dir_util.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_dir_util.py rename to src/extensions/StdLib/Lib/distutils/tests/test_dir_util.py diff --git a/src/StdLib/Lib/distutils/tests/test_dist.py b/src/extensions/StdLib/Lib/distutils/tests/test_dist.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_dist.py rename to src/extensions/StdLib/Lib/distutils/tests/test_dist.py diff --git a/src/StdLib/Lib/distutils/tests/test_extension.py b/src/extensions/StdLib/Lib/distutils/tests/test_extension.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_extension.py rename to src/extensions/StdLib/Lib/distutils/tests/test_extension.py diff --git a/src/StdLib/Lib/distutils/tests/test_file_util.py b/src/extensions/StdLib/Lib/distutils/tests/test_file_util.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_file_util.py rename to src/extensions/StdLib/Lib/distutils/tests/test_file_util.py diff --git a/src/StdLib/Lib/distutils/tests/test_filelist.py b/src/extensions/StdLib/Lib/distutils/tests/test_filelist.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_filelist.py rename to src/extensions/StdLib/Lib/distutils/tests/test_filelist.py diff --git a/src/StdLib/Lib/distutils/tests/test_install.py b/src/extensions/StdLib/Lib/distutils/tests/test_install.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_install.py rename to src/extensions/StdLib/Lib/distutils/tests/test_install.py diff --git a/src/StdLib/Lib/distutils/tests/test_install_data.py b/src/extensions/StdLib/Lib/distutils/tests/test_install_data.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_install_data.py rename to src/extensions/StdLib/Lib/distutils/tests/test_install_data.py diff --git a/src/StdLib/Lib/distutils/tests/test_install_headers.py b/src/extensions/StdLib/Lib/distutils/tests/test_install_headers.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_install_headers.py rename to src/extensions/StdLib/Lib/distutils/tests/test_install_headers.py diff --git a/src/StdLib/Lib/distutils/tests/test_install_lib.py b/src/extensions/StdLib/Lib/distutils/tests/test_install_lib.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_install_lib.py rename to src/extensions/StdLib/Lib/distutils/tests/test_install_lib.py diff --git a/src/StdLib/Lib/distutils/tests/test_install_scripts.py b/src/extensions/StdLib/Lib/distutils/tests/test_install_scripts.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_install_scripts.py rename to src/extensions/StdLib/Lib/distutils/tests/test_install_scripts.py diff --git a/src/StdLib/Lib/distutils/tests/test_log.py b/src/extensions/StdLib/Lib/distutils/tests/test_log.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_log.py rename to src/extensions/StdLib/Lib/distutils/tests/test_log.py diff --git a/src/StdLib/Lib/distutils/tests/test_msvc9compiler.py b/src/extensions/StdLib/Lib/distutils/tests/test_msvc9compiler.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_msvc9compiler.py rename to src/extensions/StdLib/Lib/distutils/tests/test_msvc9compiler.py diff --git a/src/StdLib/Lib/distutils/tests/test_register.py b/src/extensions/StdLib/Lib/distutils/tests/test_register.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_register.py rename to src/extensions/StdLib/Lib/distutils/tests/test_register.py diff --git a/src/StdLib/Lib/distutils/tests/test_sdist.py b/src/extensions/StdLib/Lib/distutils/tests/test_sdist.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_sdist.py rename to src/extensions/StdLib/Lib/distutils/tests/test_sdist.py diff --git a/src/StdLib/Lib/distutils/tests/test_spawn.py b/src/extensions/StdLib/Lib/distutils/tests/test_spawn.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_spawn.py rename to src/extensions/StdLib/Lib/distutils/tests/test_spawn.py diff --git a/src/StdLib/Lib/distutils/tests/test_sysconfig.py b/src/extensions/StdLib/Lib/distutils/tests/test_sysconfig.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_sysconfig.py rename to src/extensions/StdLib/Lib/distutils/tests/test_sysconfig.py diff --git a/src/StdLib/Lib/distutils/tests/test_text_file.py b/src/extensions/StdLib/Lib/distutils/tests/test_text_file.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_text_file.py rename to src/extensions/StdLib/Lib/distutils/tests/test_text_file.py diff --git a/src/StdLib/Lib/distutils/tests/test_unixccompiler.py b/src/extensions/StdLib/Lib/distutils/tests/test_unixccompiler.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_unixccompiler.py rename to src/extensions/StdLib/Lib/distutils/tests/test_unixccompiler.py diff --git a/src/StdLib/Lib/distutils/tests/test_upload.py b/src/extensions/StdLib/Lib/distutils/tests/test_upload.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_upload.py rename to src/extensions/StdLib/Lib/distutils/tests/test_upload.py diff --git a/src/StdLib/Lib/distutils/tests/test_util.py b/src/extensions/StdLib/Lib/distutils/tests/test_util.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_util.py rename to src/extensions/StdLib/Lib/distutils/tests/test_util.py diff --git a/src/StdLib/Lib/distutils/tests/test_version.py b/src/extensions/StdLib/Lib/distutils/tests/test_version.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_version.py rename to src/extensions/StdLib/Lib/distutils/tests/test_version.py diff --git a/src/StdLib/Lib/distutils/tests/test_versionpredicate.py b/src/extensions/StdLib/Lib/distutils/tests/test_versionpredicate.py similarity index 100% rename from src/StdLib/Lib/distutils/tests/test_versionpredicate.py rename to src/extensions/StdLib/Lib/distutils/tests/test_versionpredicate.py diff --git a/src/StdLib/Lib/distutils/text_file.py b/src/extensions/StdLib/Lib/distutils/text_file.py similarity index 100% rename from src/StdLib/Lib/distutils/text_file.py rename to src/extensions/StdLib/Lib/distutils/text_file.py diff --git a/src/StdLib/Lib/distutils/unixccompiler.py b/src/extensions/StdLib/Lib/distutils/unixccompiler.py similarity index 100% rename from src/StdLib/Lib/distutils/unixccompiler.py rename to src/extensions/StdLib/Lib/distutils/unixccompiler.py diff --git a/src/StdLib/Lib/distutils/util.py b/src/extensions/StdLib/Lib/distutils/util.py similarity index 100% rename from src/StdLib/Lib/distutils/util.py rename to src/extensions/StdLib/Lib/distutils/util.py diff --git a/src/StdLib/Lib/distutils/version.py b/src/extensions/StdLib/Lib/distutils/version.py similarity index 100% rename from src/StdLib/Lib/distutils/version.py rename to src/extensions/StdLib/Lib/distutils/version.py diff --git a/src/StdLib/Lib/distutils/versionpredicate.py b/src/extensions/StdLib/Lib/distutils/versionpredicate.py similarity index 100% rename from src/StdLib/Lib/distutils/versionpredicate.py rename to src/extensions/StdLib/Lib/distutils/versionpredicate.py diff --git a/src/StdLib/Lib/doctest.py b/src/extensions/StdLib/Lib/doctest.py similarity index 100% rename from src/StdLib/Lib/doctest.py rename to src/extensions/StdLib/Lib/doctest.py diff --git a/src/StdLib/Lib/dummy_threading.py b/src/extensions/StdLib/Lib/dummy_threading.py similarity index 100% rename from src/StdLib/Lib/dummy_threading.py rename to src/extensions/StdLib/Lib/dummy_threading.py diff --git a/src/StdLib/Lib/email/__init__.py b/src/extensions/StdLib/Lib/email/__init__.py similarity index 100% rename from src/StdLib/Lib/email/__init__.py rename to src/extensions/StdLib/Lib/email/__init__.py diff --git a/src/StdLib/Lib/email/_encoded_words.py b/src/extensions/StdLib/Lib/email/_encoded_words.py similarity index 100% rename from src/StdLib/Lib/email/_encoded_words.py rename to src/extensions/StdLib/Lib/email/_encoded_words.py diff --git a/src/StdLib/Lib/email/_header_value_parser.py b/src/extensions/StdLib/Lib/email/_header_value_parser.py similarity index 100% rename from src/StdLib/Lib/email/_header_value_parser.py rename to src/extensions/StdLib/Lib/email/_header_value_parser.py diff --git a/src/StdLib/Lib/email/_parseaddr.py b/src/extensions/StdLib/Lib/email/_parseaddr.py similarity index 100% rename from src/StdLib/Lib/email/_parseaddr.py rename to src/extensions/StdLib/Lib/email/_parseaddr.py diff --git a/src/StdLib/Lib/email/_policybase.py b/src/extensions/StdLib/Lib/email/_policybase.py similarity index 100% rename from src/StdLib/Lib/email/_policybase.py rename to src/extensions/StdLib/Lib/email/_policybase.py diff --git a/src/StdLib/Lib/email/architecture.rst b/src/extensions/StdLib/Lib/email/architecture.rst similarity index 100% rename from src/StdLib/Lib/email/architecture.rst rename to src/extensions/StdLib/Lib/email/architecture.rst diff --git a/src/StdLib/Lib/email/base64mime.py b/src/extensions/StdLib/Lib/email/base64mime.py similarity index 100% rename from src/StdLib/Lib/email/base64mime.py rename to src/extensions/StdLib/Lib/email/base64mime.py diff --git a/src/StdLib/Lib/email/charset.py b/src/extensions/StdLib/Lib/email/charset.py similarity index 100% rename from src/StdLib/Lib/email/charset.py rename to src/extensions/StdLib/Lib/email/charset.py diff --git a/src/StdLib/Lib/email/contentmanager.py b/src/extensions/StdLib/Lib/email/contentmanager.py similarity index 100% rename from src/StdLib/Lib/email/contentmanager.py rename to src/extensions/StdLib/Lib/email/contentmanager.py diff --git a/src/StdLib/Lib/email/encoders.py b/src/extensions/StdLib/Lib/email/encoders.py similarity index 100% rename from src/StdLib/Lib/email/encoders.py rename to src/extensions/StdLib/Lib/email/encoders.py diff --git a/src/StdLib/Lib/email/errors.py b/src/extensions/StdLib/Lib/email/errors.py similarity index 100% rename from src/StdLib/Lib/email/errors.py rename to src/extensions/StdLib/Lib/email/errors.py diff --git a/src/StdLib/Lib/email/feedparser.py b/src/extensions/StdLib/Lib/email/feedparser.py similarity index 100% rename from src/StdLib/Lib/email/feedparser.py rename to src/extensions/StdLib/Lib/email/feedparser.py diff --git a/src/StdLib/Lib/email/generator.py b/src/extensions/StdLib/Lib/email/generator.py similarity index 100% rename from src/StdLib/Lib/email/generator.py rename to src/extensions/StdLib/Lib/email/generator.py diff --git a/src/StdLib/Lib/email/header.py b/src/extensions/StdLib/Lib/email/header.py similarity index 100% rename from src/StdLib/Lib/email/header.py rename to src/extensions/StdLib/Lib/email/header.py diff --git a/src/StdLib/Lib/email/headerregistry.py b/src/extensions/StdLib/Lib/email/headerregistry.py similarity index 100% rename from src/StdLib/Lib/email/headerregistry.py rename to src/extensions/StdLib/Lib/email/headerregistry.py diff --git a/src/StdLib/Lib/email/iterators.py b/src/extensions/StdLib/Lib/email/iterators.py similarity index 100% rename from src/StdLib/Lib/email/iterators.py rename to src/extensions/StdLib/Lib/email/iterators.py diff --git a/src/StdLib/Lib/email/message.py b/src/extensions/StdLib/Lib/email/message.py similarity index 100% rename from src/StdLib/Lib/email/message.py rename to src/extensions/StdLib/Lib/email/message.py diff --git a/src/StdLib/Lib/email/mime/__init__.py b/src/extensions/StdLib/Lib/email/mime/__init__.py similarity index 100% rename from src/StdLib/Lib/email/mime/__init__.py rename to src/extensions/StdLib/Lib/email/mime/__init__.py diff --git a/src/StdLib/Lib/email/mime/application.py b/src/extensions/StdLib/Lib/email/mime/application.py similarity index 100% rename from src/StdLib/Lib/email/mime/application.py rename to src/extensions/StdLib/Lib/email/mime/application.py diff --git a/src/StdLib/Lib/email/mime/audio.py b/src/extensions/StdLib/Lib/email/mime/audio.py similarity index 100% rename from src/StdLib/Lib/email/mime/audio.py rename to src/extensions/StdLib/Lib/email/mime/audio.py diff --git a/src/StdLib/Lib/email/mime/base.py b/src/extensions/StdLib/Lib/email/mime/base.py similarity index 100% rename from src/StdLib/Lib/email/mime/base.py rename to src/extensions/StdLib/Lib/email/mime/base.py diff --git a/src/StdLib/Lib/email/mime/image.py b/src/extensions/StdLib/Lib/email/mime/image.py similarity index 100% rename from src/StdLib/Lib/email/mime/image.py rename to src/extensions/StdLib/Lib/email/mime/image.py diff --git a/src/StdLib/Lib/email/mime/message.py b/src/extensions/StdLib/Lib/email/mime/message.py similarity index 100% rename from src/StdLib/Lib/email/mime/message.py rename to src/extensions/StdLib/Lib/email/mime/message.py diff --git a/src/StdLib/Lib/email/mime/multipart.py b/src/extensions/StdLib/Lib/email/mime/multipart.py similarity index 100% rename from src/StdLib/Lib/email/mime/multipart.py rename to src/extensions/StdLib/Lib/email/mime/multipart.py diff --git a/src/StdLib/Lib/email/mime/nonmultipart.py b/src/extensions/StdLib/Lib/email/mime/nonmultipart.py similarity index 100% rename from src/StdLib/Lib/email/mime/nonmultipart.py rename to src/extensions/StdLib/Lib/email/mime/nonmultipart.py diff --git a/src/StdLib/Lib/email/mime/text.py b/src/extensions/StdLib/Lib/email/mime/text.py similarity index 100% rename from src/StdLib/Lib/email/mime/text.py rename to src/extensions/StdLib/Lib/email/mime/text.py diff --git a/src/StdLib/Lib/email/parser.py b/src/extensions/StdLib/Lib/email/parser.py similarity index 100% rename from src/StdLib/Lib/email/parser.py rename to src/extensions/StdLib/Lib/email/parser.py diff --git a/src/StdLib/Lib/email/policy.py b/src/extensions/StdLib/Lib/email/policy.py similarity index 100% rename from src/StdLib/Lib/email/policy.py rename to src/extensions/StdLib/Lib/email/policy.py diff --git a/src/StdLib/Lib/email/quoprimime.py b/src/extensions/StdLib/Lib/email/quoprimime.py similarity index 100% rename from src/StdLib/Lib/email/quoprimime.py rename to src/extensions/StdLib/Lib/email/quoprimime.py diff --git a/src/StdLib/Lib/email/utils.py b/src/extensions/StdLib/Lib/email/utils.py similarity index 100% rename from src/StdLib/Lib/email/utils.py rename to src/extensions/StdLib/Lib/email/utils.py diff --git a/src/StdLib/Lib/encodings/__init__.py b/src/extensions/StdLib/Lib/encodings/__init__.py similarity index 100% rename from src/StdLib/Lib/encodings/__init__.py rename to src/extensions/StdLib/Lib/encodings/__init__.py diff --git a/src/StdLib/Lib/encodings/aliases.py b/src/extensions/StdLib/Lib/encodings/aliases.py similarity index 100% rename from src/StdLib/Lib/encodings/aliases.py rename to src/extensions/StdLib/Lib/encodings/aliases.py diff --git a/src/StdLib/Lib/encodings/ascii.py b/src/extensions/StdLib/Lib/encodings/ascii.py similarity index 100% rename from src/StdLib/Lib/encodings/ascii.py rename to src/extensions/StdLib/Lib/encodings/ascii.py diff --git a/src/StdLib/Lib/encodings/base64_codec.py b/src/extensions/StdLib/Lib/encodings/base64_codec.py similarity index 100% rename from src/StdLib/Lib/encodings/base64_codec.py rename to src/extensions/StdLib/Lib/encodings/base64_codec.py diff --git a/src/StdLib/Lib/encodings/big5.py b/src/extensions/StdLib/Lib/encodings/big5.py similarity index 100% rename from src/StdLib/Lib/encodings/big5.py rename to src/extensions/StdLib/Lib/encodings/big5.py diff --git a/src/StdLib/Lib/encodings/big5hkscs.py b/src/extensions/StdLib/Lib/encodings/big5hkscs.py similarity index 100% rename from src/StdLib/Lib/encodings/big5hkscs.py rename to src/extensions/StdLib/Lib/encodings/big5hkscs.py diff --git a/src/StdLib/Lib/encodings/bz2_codec.py b/src/extensions/StdLib/Lib/encodings/bz2_codec.py similarity index 100% rename from src/StdLib/Lib/encodings/bz2_codec.py rename to src/extensions/StdLib/Lib/encodings/bz2_codec.py diff --git a/src/StdLib/Lib/encodings/charmap.py b/src/extensions/StdLib/Lib/encodings/charmap.py similarity index 100% rename from src/StdLib/Lib/encodings/charmap.py rename to src/extensions/StdLib/Lib/encodings/charmap.py diff --git a/src/StdLib/Lib/encodings/cp037.py b/src/extensions/StdLib/Lib/encodings/cp037.py similarity index 100% rename from src/StdLib/Lib/encodings/cp037.py rename to src/extensions/StdLib/Lib/encodings/cp037.py diff --git a/src/StdLib/Lib/encodings/cp1006.py b/src/extensions/StdLib/Lib/encodings/cp1006.py similarity index 100% rename from src/StdLib/Lib/encodings/cp1006.py rename to src/extensions/StdLib/Lib/encodings/cp1006.py diff --git a/src/StdLib/Lib/encodings/cp1026.py b/src/extensions/StdLib/Lib/encodings/cp1026.py similarity index 100% rename from src/StdLib/Lib/encodings/cp1026.py rename to src/extensions/StdLib/Lib/encodings/cp1026.py diff --git a/src/StdLib/Lib/encodings/cp1125.py b/src/extensions/StdLib/Lib/encodings/cp1125.py similarity index 100% rename from src/StdLib/Lib/encodings/cp1125.py rename to src/extensions/StdLib/Lib/encodings/cp1125.py diff --git a/src/StdLib/Lib/encodings/cp1140.py b/src/extensions/StdLib/Lib/encodings/cp1140.py similarity index 100% rename from src/StdLib/Lib/encodings/cp1140.py rename to src/extensions/StdLib/Lib/encodings/cp1140.py diff --git a/src/StdLib/Lib/encodings/cp1250.py b/src/extensions/StdLib/Lib/encodings/cp1250.py similarity index 100% rename from src/StdLib/Lib/encodings/cp1250.py rename to src/extensions/StdLib/Lib/encodings/cp1250.py diff --git a/src/StdLib/Lib/encodings/cp1251.py b/src/extensions/StdLib/Lib/encodings/cp1251.py similarity index 100% rename from src/StdLib/Lib/encodings/cp1251.py rename to src/extensions/StdLib/Lib/encodings/cp1251.py diff --git a/src/StdLib/Lib/encodings/cp1252.py b/src/extensions/StdLib/Lib/encodings/cp1252.py similarity index 100% rename from src/StdLib/Lib/encodings/cp1252.py rename to src/extensions/StdLib/Lib/encodings/cp1252.py diff --git a/src/StdLib/Lib/encodings/cp1253.py b/src/extensions/StdLib/Lib/encodings/cp1253.py similarity index 100% rename from src/StdLib/Lib/encodings/cp1253.py rename to src/extensions/StdLib/Lib/encodings/cp1253.py diff --git a/src/StdLib/Lib/encodings/cp1254.py b/src/extensions/StdLib/Lib/encodings/cp1254.py similarity index 100% rename from src/StdLib/Lib/encodings/cp1254.py rename to src/extensions/StdLib/Lib/encodings/cp1254.py diff --git a/src/StdLib/Lib/encodings/cp1255.py b/src/extensions/StdLib/Lib/encodings/cp1255.py similarity index 100% rename from src/StdLib/Lib/encodings/cp1255.py rename to src/extensions/StdLib/Lib/encodings/cp1255.py diff --git a/src/StdLib/Lib/encodings/cp1256.py b/src/extensions/StdLib/Lib/encodings/cp1256.py similarity index 100% rename from src/StdLib/Lib/encodings/cp1256.py rename to src/extensions/StdLib/Lib/encodings/cp1256.py diff --git a/src/StdLib/Lib/encodings/cp1257.py b/src/extensions/StdLib/Lib/encodings/cp1257.py similarity index 100% rename from src/StdLib/Lib/encodings/cp1257.py rename to src/extensions/StdLib/Lib/encodings/cp1257.py diff --git a/src/StdLib/Lib/encodings/cp1258.py b/src/extensions/StdLib/Lib/encodings/cp1258.py similarity index 100% rename from src/StdLib/Lib/encodings/cp1258.py rename to src/extensions/StdLib/Lib/encodings/cp1258.py diff --git a/src/StdLib/Lib/encodings/cp273.py b/src/extensions/StdLib/Lib/encodings/cp273.py similarity index 100% rename from src/StdLib/Lib/encodings/cp273.py rename to src/extensions/StdLib/Lib/encodings/cp273.py diff --git a/src/StdLib/Lib/encodings/cp424.py b/src/extensions/StdLib/Lib/encodings/cp424.py similarity index 100% rename from src/StdLib/Lib/encodings/cp424.py rename to src/extensions/StdLib/Lib/encodings/cp424.py diff --git a/src/StdLib/Lib/encodings/cp437.py b/src/extensions/StdLib/Lib/encodings/cp437.py similarity index 100% rename from src/StdLib/Lib/encodings/cp437.py rename to src/extensions/StdLib/Lib/encodings/cp437.py diff --git a/src/StdLib/Lib/encodings/cp500.py b/src/extensions/StdLib/Lib/encodings/cp500.py similarity index 100% rename from src/StdLib/Lib/encodings/cp500.py rename to src/extensions/StdLib/Lib/encodings/cp500.py diff --git a/src/StdLib/Lib/encodings/cp65001.py b/src/extensions/StdLib/Lib/encodings/cp65001.py similarity index 100% rename from src/StdLib/Lib/encodings/cp65001.py rename to src/extensions/StdLib/Lib/encodings/cp65001.py diff --git a/src/StdLib/Lib/encodings/cp720.py b/src/extensions/StdLib/Lib/encodings/cp720.py similarity index 100% rename from src/StdLib/Lib/encodings/cp720.py rename to src/extensions/StdLib/Lib/encodings/cp720.py diff --git a/src/StdLib/Lib/encodings/cp737.py b/src/extensions/StdLib/Lib/encodings/cp737.py similarity index 100% rename from src/StdLib/Lib/encodings/cp737.py rename to src/extensions/StdLib/Lib/encodings/cp737.py diff --git a/src/StdLib/Lib/encodings/cp775.py b/src/extensions/StdLib/Lib/encodings/cp775.py similarity index 100% rename from src/StdLib/Lib/encodings/cp775.py rename to src/extensions/StdLib/Lib/encodings/cp775.py diff --git a/src/StdLib/Lib/encodings/cp850.py b/src/extensions/StdLib/Lib/encodings/cp850.py similarity index 100% rename from src/StdLib/Lib/encodings/cp850.py rename to src/extensions/StdLib/Lib/encodings/cp850.py diff --git a/src/StdLib/Lib/encodings/cp852.py b/src/extensions/StdLib/Lib/encodings/cp852.py similarity index 100% rename from src/StdLib/Lib/encodings/cp852.py rename to src/extensions/StdLib/Lib/encodings/cp852.py diff --git a/src/StdLib/Lib/encodings/cp855.py b/src/extensions/StdLib/Lib/encodings/cp855.py similarity index 100% rename from src/StdLib/Lib/encodings/cp855.py rename to src/extensions/StdLib/Lib/encodings/cp855.py diff --git a/src/StdLib/Lib/encodings/cp856.py b/src/extensions/StdLib/Lib/encodings/cp856.py similarity index 100% rename from src/StdLib/Lib/encodings/cp856.py rename to src/extensions/StdLib/Lib/encodings/cp856.py diff --git a/src/StdLib/Lib/encodings/cp857.py b/src/extensions/StdLib/Lib/encodings/cp857.py similarity index 100% rename from src/StdLib/Lib/encodings/cp857.py rename to src/extensions/StdLib/Lib/encodings/cp857.py diff --git a/src/StdLib/Lib/encodings/cp858.py b/src/extensions/StdLib/Lib/encodings/cp858.py similarity index 100% rename from src/StdLib/Lib/encodings/cp858.py rename to src/extensions/StdLib/Lib/encodings/cp858.py diff --git a/src/StdLib/Lib/encodings/cp860.py b/src/extensions/StdLib/Lib/encodings/cp860.py similarity index 100% rename from src/StdLib/Lib/encodings/cp860.py rename to src/extensions/StdLib/Lib/encodings/cp860.py diff --git a/src/StdLib/Lib/encodings/cp861.py b/src/extensions/StdLib/Lib/encodings/cp861.py similarity index 100% rename from src/StdLib/Lib/encodings/cp861.py rename to src/extensions/StdLib/Lib/encodings/cp861.py diff --git a/src/StdLib/Lib/encodings/cp862.py b/src/extensions/StdLib/Lib/encodings/cp862.py similarity index 100% rename from src/StdLib/Lib/encodings/cp862.py rename to src/extensions/StdLib/Lib/encodings/cp862.py diff --git a/src/StdLib/Lib/encodings/cp863.py b/src/extensions/StdLib/Lib/encodings/cp863.py similarity index 100% rename from src/StdLib/Lib/encodings/cp863.py rename to src/extensions/StdLib/Lib/encodings/cp863.py diff --git a/src/StdLib/Lib/encodings/cp864.py b/src/extensions/StdLib/Lib/encodings/cp864.py similarity index 100% rename from src/StdLib/Lib/encodings/cp864.py rename to src/extensions/StdLib/Lib/encodings/cp864.py diff --git a/src/StdLib/Lib/encodings/cp865.py b/src/extensions/StdLib/Lib/encodings/cp865.py similarity index 100% rename from src/StdLib/Lib/encodings/cp865.py rename to src/extensions/StdLib/Lib/encodings/cp865.py diff --git a/src/StdLib/Lib/encodings/cp866.py b/src/extensions/StdLib/Lib/encodings/cp866.py similarity index 100% rename from src/StdLib/Lib/encodings/cp866.py rename to src/extensions/StdLib/Lib/encodings/cp866.py diff --git a/src/StdLib/Lib/encodings/cp869.py b/src/extensions/StdLib/Lib/encodings/cp869.py similarity index 100% rename from src/StdLib/Lib/encodings/cp869.py rename to src/extensions/StdLib/Lib/encodings/cp869.py diff --git a/src/StdLib/Lib/encodings/cp874.py b/src/extensions/StdLib/Lib/encodings/cp874.py similarity index 100% rename from src/StdLib/Lib/encodings/cp874.py rename to src/extensions/StdLib/Lib/encodings/cp874.py diff --git a/src/StdLib/Lib/encodings/cp875.py b/src/extensions/StdLib/Lib/encodings/cp875.py similarity index 100% rename from src/StdLib/Lib/encodings/cp875.py rename to src/extensions/StdLib/Lib/encodings/cp875.py diff --git a/src/StdLib/Lib/encodings/cp932.py b/src/extensions/StdLib/Lib/encodings/cp932.py similarity index 100% rename from src/StdLib/Lib/encodings/cp932.py rename to src/extensions/StdLib/Lib/encodings/cp932.py diff --git a/src/StdLib/Lib/encodings/cp949.py b/src/extensions/StdLib/Lib/encodings/cp949.py similarity index 100% rename from src/StdLib/Lib/encodings/cp949.py rename to src/extensions/StdLib/Lib/encodings/cp949.py diff --git a/src/StdLib/Lib/encodings/cp950.py b/src/extensions/StdLib/Lib/encodings/cp950.py similarity index 100% rename from src/StdLib/Lib/encodings/cp950.py rename to src/extensions/StdLib/Lib/encodings/cp950.py diff --git a/src/StdLib/Lib/encodings/euc_jis_2004.py b/src/extensions/StdLib/Lib/encodings/euc_jis_2004.py similarity index 100% rename from src/StdLib/Lib/encodings/euc_jis_2004.py rename to src/extensions/StdLib/Lib/encodings/euc_jis_2004.py diff --git a/src/StdLib/Lib/encodings/euc_jisx0213.py b/src/extensions/StdLib/Lib/encodings/euc_jisx0213.py similarity index 100% rename from src/StdLib/Lib/encodings/euc_jisx0213.py rename to src/extensions/StdLib/Lib/encodings/euc_jisx0213.py diff --git a/src/StdLib/Lib/encodings/euc_jp.py b/src/extensions/StdLib/Lib/encodings/euc_jp.py similarity index 100% rename from src/StdLib/Lib/encodings/euc_jp.py rename to src/extensions/StdLib/Lib/encodings/euc_jp.py diff --git a/src/StdLib/Lib/encodings/euc_kr.py b/src/extensions/StdLib/Lib/encodings/euc_kr.py similarity index 100% rename from src/StdLib/Lib/encodings/euc_kr.py rename to src/extensions/StdLib/Lib/encodings/euc_kr.py diff --git a/src/StdLib/Lib/encodings/gb18030.py b/src/extensions/StdLib/Lib/encodings/gb18030.py similarity index 100% rename from src/StdLib/Lib/encodings/gb18030.py rename to src/extensions/StdLib/Lib/encodings/gb18030.py diff --git a/src/StdLib/Lib/encodings/gb2312.py b/src/extensions/StdLib/Lib/encodings/gb2312.py similarity index 100% rename from src/StdLib/Lib/encodings/gb2312.py rename to src/extensions/StdLib/Lib/encodings/gb2312.py diff --git a/src/StdLib/Lib/encodings/gbk.py b/src/extensions/StdLib/Lib/encodings/gbk.py similarity index 100% rename from src/StdLib/Lib/encodings/gbk.py rename to src/extensions/StdLib/Lib/encodings/gbk.py diff --git a/src/StdLib/Lib/encodings/hex_codec.py b/src/extensions/StdLib/Lib/encodings/hex_codec.py similarity index 100% rename from src/StdLib/Lib/encodings/hex_codec.py rename to src/extensions/StdLib/Lib/encodings/hex_codec.py diff --git a/src/StdLib/Lib/encodings/hp_roman8.py b/src/extensions/StdLib/Lib/encodings/hp_roman8.py similarity index 100% rename from src/StdLib/Lib/encodings/hp_roman8.py rename to src/extensions/StdLib/Lib/encodings/hp_roman8.py diff --git a/src/StdLib/Lib/encodings/hz.py b/src/extensions/StdLib/Lib/encodings/hz.py similarity index 100% rename from src/StdLib/Lib/encodings/hz.py rename to src/extensions/StdLib/Lib/encodings/hz.py diff --git a/src/StdLib/Lib/encodings/idna.py b/src/extensions/StdLib/Lib/encodings/idna.py similarity index 100% rename from src/StdLib/Lib/encodings/idna.py rename to src/extensions/StdLib/Lib/encodings/idna.py diff --git a/src/StdLib/Lib/encodings/iso2022_jp.py b/src/extensions/StdLib/Lib/encodings/iso2022_jp.py similarity index 100% rename from src/StdLib/Lib/encodings/iso2022_jp.py rename to src/extensions/StdLib/Lib/encodings/iso2022_jp.py diff --git a/src/StdLib/Lib/encodings/iso2022_jp_1.py b/src/extensions/StdLib/Lib/encodings/iso2022_jp_1.py similarity index 100% rename from src/StdLib/Lib/encodings/iso2022_jp_1.py rename to src/extensions/StdLib/Lib/encodings/iso2022_jp_1.py diff --git a/src/StdLib/Lib/encodings/iso2022_jp_2.py b/src/extensions/StdLib/Lib/encodings/iso2022_jp_2.py similarity index 100% rename from src/StdLib/Lib/encodings/iso2022_jp_2.py rename to src/extensions/StdLib/Lib/encodings/iso2022_jp_2.py diff --git a/src/StdLib/Lib/encodings/iso2022_jp_2004.py b/src/extensions/StdLib/Lib/encodings/iso2022_jp_2004.py similarity index 100% rename from src/StdLib/Lib/encodings/iso2022_jp_2004.py rename to src/extensions/StdLib/Lib/encodings/iso2022_jp_2004.py diff --git a/src/StdLib/Lib/encodings/iso2022_jp_3.py b/src/extensions/StdLib/Lib/encodings/iso2022_jp_3.py similarity index 100% rename from src/StdLib/Lib/encodings/iso2022_jp_3.py rename to src/extensions/StdLib/Lib/encodings/iso2022_jp_3.py diff --git a/src/StdLib/Lib/encodings/iso2022_jp_ext.py b/src/extensions/StdLib/Lib/encodings/iso2022_jp_ext.py similarity index 100% rename from src/StdLib/Lib/encodings/iso2022_jp_ext.py rename to src/extensions/StdLib/Lib/encodings/iso2022_jp_ext.py diff --git a/src/StdLib/Lib/encodings/iso2022_kr.py b/src/extensions/StdLib/Lib/encodings/iso2022_kr.py similarity index 100% rename from src/StdLib/Lib/encodings/iso2022_kr.py rename to src/extensions/StdLib/Lib/encodings/iso2022_kr.py diff --git a/src/StdLib/Lib/encodings/iso8859_1.py b/src/extensions/StdLib/Lib/encodings/iso8859_1.py similarity index 100% rename from src/StdLib/Lib/encodings/iso8859_1.py rename to src/extensions/StdLib/Lib/encodings/iso8859_1.py diff --git a/src/StdLib/Lib/encodings/iso8859_10.py b/src/extensions/StdLib/Lib/encodings/iso8859_10.py similarity index 100% rename from src/StdLib/Lib/encodings/iso8859_10.py rename to src/extensions/StdLib/Lib/encodings/iso8859_10.py diff --git a/src/StdLib/Lib/encodings/iso8859_11.py b/src/extensions/StdLib/Lib/encodings/iso8859_11.py similarity index 100% rename from src/StdLib/Lib/encodings/iso8859_11.py rename to src/extensions/StdLib/Lib/encodings/iso8859_11.py diff --git a/src/StdLib/Lib/encodings/iso8859_13.py b/src/extensions/StdLib/Lib/encodings/iso8859_13.py similarity index 100% rename from src/StdLib/Lib/encodings/iso8859_13.py rename to src/extensions/StdLib/Lib/encodings/iso8859_13.py diff --git a/src/StdLib/Lib/encodings/iso8859_14.py b/src/extensions/StdLib/Lib/encodings/iso8859_14.py similarity index 100% rename from src/StdLib/Lib/encodings/iso8859_14.py rename to src/extensions/StdLib/Lib/encodings/iso8859_14.py diff --git a/src/StdLib/Lib/encodings/iso8859_15.py b/src/extensions/StdLib/Lib/encodings/iso8859_15.py similarity index 100% rename from src/StdLib/Lib/encodings/iso8859_15.py rename to src/extensions/StdLib/Lib/encodings/iso8859_15.py diff --git a/src/StdLib/Lib/encodings/iso8859_16.py b/src/extensions/StdLib/Lib/encodings/iso8859_16.py similarity index 100% rename from src/StdLib/Lib/encodings/iso8859_16.py rename to src/extensions/StdLib/Lib/encodings/iso8859_16.py diff --git a/src/StdLib/Lib/encodings/iso8859_2.py b/src/extensions/StdLib/Lib/encodings/iso8859_2.py similarity index 100% rename from src/StdLib/Lib/encodings/iso8859_2.py rename to src/extensions/StdLib/Lib/encodings/iso8859_2.py diff --git a/src/StdLib/Lib/encodings/iso8859_3.py b/src/extensions/StdLib/Lib/encodings/iso8859_3.py similarity index 100% rename from src/StdLib/Lib/encodings/iso8859_3.py rename to src/extensions/StdLib/Lib/encodings/iso8859_3.py diff --git a/src/StdLib/Lib/encodings/iso8859_4.py b/src/extensions/StdLib/Lib/encodings/iso8859_4.py similarity index 100% rename from src/StdLib/Lib/encodings/iso8859_4.py rename to src/extensions/StdLib/Lib/encodings/iso8859_4.py diff --git a/src/StdLib/Lib/encodings/iso8859_5.py b/src/extensions/StdLib/Lib/encodings/iso8859_5.py similarity index 100% rename from src/StdLib/Lib/encodings/iso8859_5.py rename to src/extensions/StdLib/Lib/encodings/iso8859_5.py diff --git a/src/StdLib/Lib/encodings/iso8859_6.py b/src/extensions/StdLib/Lib/encodings/iso8859_6.py similarity index 100% rename from src/StdLib/Lib/encodings/iso8859_6.py rename to src/extensions/StdLib/Lib/encodings/iso8859_6.py diff --git a/src/StdLib/Lib/encodings/iso8859_7.py b/src/extensions/StdLib/Lib/encodings/iso8859_7.py similarity index 100% rename from src/StdLib/Lib/encodings/iso8859_7.py rename to src/extensions/StdLib/Lib/encodings/iso8859_7.py diff --git a/src/StdLib/Lib/encodings/iso8859_8.py b/src/extensions/StdLib/Lib/encodings/iso8859_8.py similarity index 100% rename from src/StdLib/Lib/encodings/iso8859_8.py rename to src/extensions/StdLib/Lib/encodings/iso8859_8.py diff --git a/src/StdLib/Lib/encodings/iso8859_9.py b/src/extensions/StdLib/Lib/encodings/iso8859_9.py similarity index 100% rename from src/StdLib/Lib/encodings/iso8859_9.py rename to src/extensions/StdLib/Lib/encodings/iso8859_9.py diff --git a/src/StdLib/Lib/encodings/johab.py b/src/extensions/StdLib/Lib/encodings/johab.py similarity index 100% rename from src/StdLib/Lib/encodings/johab.py rename to src/extensions/StdLib/Lib/encodings/johab.py diff --git a/src/StdLib/Lib/encodings/koi8_r.py b/src/extensions/StdLib/Lib/encodings/koi8_r.py similarity index 100% rename from src/StdLib/Lib/encodings/koi8_r.py rename to src/extensions/StdLib/Lib/encodings/koi8_r.py diff --git a/src/StdLib/Lib/encodings/koi8_u.py b/src/extensions/StdLib/Lib/encodings/koi8_u.py similarity index 100% rename from src/StdLib/Lib/encodings/koi8_u.py rename to src/extensions/StdLib/Lib/encodings/koi8_u.py diff --git a/src/StdLib/Lib/encodings/latin_1.py b/src/extensions/StdLib/Lib/encodings/latin_1.py similarity index 100% rename from src/StdLib/Lib/encodings/latin_1.py rename to src/extensions/StdLib/Lib/encodings/latin_1.py diff --git a/src/StdLib/Lib/encodings/mac_arabic.py b/src/extensions/StdLib/Lib/encodings/mac_arabic.py similarity index 100% rename from src/StdLib/Lib/encodings/mac_arabic.py rename to src/extensions/StdLib/Lib/encodings/mac_arabic.py diff --git a/src/StdLib/Lib/encodings/mac_centeuro.py b/src/extensions/StdLib/Lib/encodings/mac_centeuro.py similarity index 100% rename from src/StdLib/Lib/encodings/mac_centeuro.py rename to src/extensions/StdLib/Lib/encodings/mac_centeuro.py diff --git a/src/StdLib/Lib/encodings/mac_croatian.py b/src/extensions/StdLib/Lib/encodings/mac_croatian.py similarity index 100% rename from src/StdLib/Lib/encodings/mac_croatian.py rename to src/extensions/StdLib/Lib/encodings/mac_croatian.py diff --git a/src/StdLib/Lib/encodings/mac_cyrillic.py b/src/extensions/StdLib/Lib/encodings/mac_cyrillic.py similarity index 100% rename from src/StdLib/Lib/encodings/mac_cyrillic.py rename to src/extensions/StdLib/Lib/encodings/mac_cyrillic.py diff --git a/src/StdLib/Lib/encodings/mac_farsi.py b/src/extensions/StdLib/Lib/encodings/mac_farsi.py similarity index 100% rename from src/StdLib/Lib/encodings/mac_farsi.py rename to src/extensions/StdLib/Lib/encodings/mac_farsi.py diff --git a/src/StdLib/Lib/encodings/mac_greek.py b/src/extensions/StdLib/Lib/encodings/mac_greek.py similarity index 100% rename from src/StdLib/Lib/encodings/mac_greek.py rename to src/extensions/StdLib/Lib/encodings/mac_greek.py diff --git a/src/StdLib/Lib/encodings/mac_iceland.py b/src/extensions/StdLib/Lib/encodings/mac_iceland.py similarity index 100% rename from src/StdLib/Lib/encodings/mac_iceland.py rename to src/extensions/StdLib/Lib/encodings/mac_iceland.py diff --git a/src/StdLib/Lib/encodings/mac_latin2.py b/src/extensions/StdLib/Lib/encodings/mac_latin2.py similarity index 100% rename from src/StdLib/Lib/encodings/mac_latin2.py rename to src/extensions/StdLib/Lib/encodings/mac_latin2.py diff --git a/src/StdLib/Lib/encodings/mac_roman.py b/src/extensions/StdLib/Lib/encodings/mac_roman.py similarity index 100% rename from src/StdLib/Lib/encodings/mac_roman.py rename to src/extensions/StdLib/Lib/encodings/mac_roman.py diff --git a/src/StdLib/Lib/encodings/mac_romanian.py b/src/extensions/StdLib/Lib/encodings/mac_romanian.py similarity index 100% rename from src/StdLib/Lib/encodings/mac_romanian.py rename to src/extensions/StdLib/Lib/encodings/mac_romanian.py diff --git a/src/StdLib/Lib/encodings/mac_turkish.py b/src/extensions/StdLib/Lib/encodings/mac_turkish.py similarity index 100% rename from src/StdLib/Lib/encodings/mac_turkish.py rename to src/extensions/StdLib/Lib/encodings/mac_turkish.py diff --git a/src/StdLib/Lib/encodings/mbcs.py b/src/extensions/StdLib/Lib/encodings/mbcs.py similarity index 100% rename from src/StdLib/Lib/encodings/mbcs.py rename to src/extensions/StdLib/Lib/encodings/mbcs.py diff --git a/src/StdLib/Lib/encodings/palmos.py b/src/extensions/StdLib/Lib/encodings/palmos.py similarity index 100% rename from src/StdLib/Lib/encodings/palmos.py rename to src/extensions/StdLib/Lib/encodings/palmos.py diff --git a/src/StdLib/Lib/encodings/ptcp154.py b/src/extensions/StdLib/Lib/encodings/ptcp154.py similarity index 100% rename from src/StdLib/Lib/encodings/ptcp154.py rename to src/extensions/StdLib/Lib/encodings/ptcp154.py diff --git a/src/StdLib/Lib/encodings/punycode.py b/src/extensions/StdLib/Lib/encodings/punycode.py similarity index 100% rename from src/StdLib/Lib/encodings/punycode.py rename to src/extensions/StdLib/Lib/encodings/punycode.py diff --git a/src/StdLib/Lib/encodings/quopri_codec.py b/src/extensions/StdLib/Lib/encodings/quopri_codec.py similarity index 100% rename from src/StdLib/Lib/encodings/quopri_codec.py rename to src/extensions/StdLib/Lib/encodings/quopri_codec.py diff --git a/src/StdLib/Lib/encodings/raw_unicode_escape.py b/src/extensions/StdLib/Lib/encodings/raw_unicode_escape.py similarity index 100% rename from src/StdLib/Lib/encodings/raw_unicode_escape.py rename to src/extensions/StdLib/Lib/encodings/raw_unicode_escape.py diff --git a/src/StdLib/Lib/encodings/rot_13.py b/src/extensions/StdLib/Lib/encodings/rot_13.py similarity index 100% rename from src/StdLib/Lib/encodings/rot_13.py rename to src/extensions/StdLib/Lib/encodings/rot_13.py diff --git a/src/StdLib/Lib/encodings/shift_jis.py b/src/extensions/StdLib/Lib/encodings/shift_jis.py similarity index 100% rename from src/StdLib/Lib/encodings/shift_jis.py rename to src/extensions/StdLib/Lib/encodings/shift_jis.py diff --git a/src/StdLib/Lib/encodings/shift_jis_2004.py b/src/extensions/StdLib/Lib/encodings/shift_jis_2004.py similarity index 100% rename from src/StdLib/Lib/encodings/shift_jis_2004.py rename to src/extensions/StdLib/Lib/encodings/shift_jis_2004.py diff --git a/src/StdLib/Lib/encodings/shift_jisx0213.py b/src/extensions/StdLib/Lib/encodings/shift_jisx0213.py similarity index 100% rename from src/StdLib/Lib/encodings/shift_jisx0213.py rename to src/extensions/StdLib/Lib/encodings/shift_jisx0213.py diff --git a/src/StdLib/Lib/encodings/tis_620.py b/src/extensions/StdLib/Lib/encodings/tis_620.py similarity index 100% rename from src/StdLib/Lib/encodings/tis_620.py rename to src/extensions/StdLib/Lib/encodings/tis_620.py diff --git a/src/StdLib/Lib/encodings/undefined.py b/src/extensions/StdLib/Lib/encodings/undefined.py similarity index 100% rename from src/StdLib/Lib/encodings/undefined.py rename to src/extensions/StdLib/Lib/encodings/undefined.py diff --git a/src/StdLib/Lib/encodings/unicode_escape.py b/src/extensions/StdLib/Lib/encodings/unicode_escape.py similarity index 100% rename from src/StdLib/Lib/encodings/unicode_escape.py rename to src/extensions/StdLib/Lib/encodings/unicode_escape.py diff --git a/src/StdLib/Lib/encodings/unicode_internal.py b/src/extensions/StdLib/Lib/encodings/unicode_internal.py similarity index 100% rename from src/StdLib/Lib/encodings/unicode_internal.py rename to src/extensions/StdLib/Lib/encodings/unicode_internal.py diff --git a/src/StdLib/Lib/encodings/utf_16.py b/src/extensions/StdLib/Lib/encodings/utf_16.py similarity index 100% rename from src/StdLib/Lib/encodings/utf_16.py rename to src/extensions/StdLib/Lib/encodings/utf_16.py diff --git a/src/StdLib/Lib/encodings/utf_16_be.py b/src/extensions/StdLib/Lib/encodings/utf_16_be.py similarity index 100% rename from src/StdLib/Lib/encodings/utf_16_be.py rename to src/extensions/StdLib/Lib/encodings/utf_16_be.py diff --git a/src/StdLib/Lib/encodings/utf_16_le.py b/src/extensions/StdLib/Lib/encodings/utf_16_le.py similarity index 100% rename from src/StdLib/Lib/encodings/utf_16_le.py rename to src/extensions/StdLib/Lib/encodings/utf_16_le.py diff --git a/src/StdLib/Lib/encodings/utf_32.py b/src/extensions/StdLib/Lib/encodings/utf_32.py similarity index 100% rename from src/StdLib/Lib/encodings/utf_32.py rename to src/extensions/StdLib/Lib/encodings/utf_32.py diff --git a/src/StdLib/Lib/encodings/utf_32_be.py b/src/extensions/StdLib/Lib/encodings/utf_32_be.py similarity index 100% rename from src/StdLib/Lib/encodings/utf_32_be.py rename to src/extensions/StdLib/Lib/encodings/utf_32_be.py diff --git a/src/StdLib/Lib/encodings/utf_32_le.py b/src/extensions/StdLib/Lib/encodings/utf_32_le.py similarity index 100% rename from src/StdLib/Lib/encodings/utf_32_le.py rename to src/extensions/StdLib/Lib/encodings/utf_32_le.py diff --git a/src/StdLib/Lib/encodings/utf_7.py b/src/extensions/StdLib/Lib/encodings/utf_7.py similarity index 100% rename from src/StdLib/Lib/encodings/utf_7.py rename to src/extensions/StdLib/Lib/encodings/utf_7.py diff --git a/src/StdLib/Lib/encodings/utf_8.py b/src/extensions/StdLib/Lib/encodings/utf_8.py similarity index 100% rename from src/StdLib/Lib/encodings/utf_8.py rename to src/extensions/StdLib/Lib/encodings/utf_8.py diff --git a/src/StdLib/Lib/encodings/utf_8_sig.py b/src/extensions/StdLib/Lib/encodings/utf_8_sig.py similarity index 100% rename from src/StdLib/Lib/encodings/utf_8_sig.py rename to src/extensions/StdLib/Lib/encodings/utf_8_sig.py diff --git a/src/StdLib/Lib/encodings/uu_codec.py b/src/extensions/StdLib/Lib/encodings/uu_codec.py similarity index 100% rename from src/StdLib/Lib/encodings/uu_codec.py rename to src/extensions/StdLib/Lib/encodings/uu_codec.py diff --git a/src/StdLib/Lib/encodings/zlib_codec.py b/src/extensions/StdLib/Lib/encodings/zlib_codec.py similarity index 100% rename from src/StdLib/Lib/encodings/zlib_codec.py rename to src/extensions/StdLib/Lib/encodings/zlib_codec.py diff --git a/src/StdLib/Lib/ensurepip/__init__.py b/src/extensions/StdLib/Lib/ensurepip/__init__.py similarity index 100% rename from src/StdLib/Lib/ensurepip/__init__.py rename to src/extensions/StdLib/Lib/ensurepip/__init__.py diff --git a/src/StdLib/Lib/ensurepip/__main__.py b/src/extensions/StdLib/Lib/ensurepip/__main__.py similarity index 100% rename from src/StdLib/Lib/ensurepip/__main__.py rename to src/extensions/StdLib/Lib/ensurepip/__main__.py diff --git a/src/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl b/src/extensions/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl similarity index 100% rename from src/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl rename to src/extensions/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl diff --git a/src/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl b/src/extensions/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl similarity index 100% rename from src/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl rename to src/extensions/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl diff --git a/src/StdLib/Lib/ensurepip/_uninstall.py b/src/extensions/StdLib/Lib/ensurepip/_uninstall.py similarity index 100% rename from src/StdLib/Lib/ensurepip/_uninstall.py rename to src/extensions/StdLib/Lib/ensurepip/_uninstall.py diff --git a/src/StdLib/Lib/enum.py b/src/extensions/StdLib/Lib/enum.py similarity index 100% rename from src/StdLib/Lib/enum.py rename to src/extensions/StdLib/Lib/enum.py diff --git a/src/StdLib/Lib/filecmp.py b/src/extensions/StdLib/Lib/filecmp.py similarity index 100% rename from src/StdLib/Lib/filecmp.py rename to src/extensions/StdLib/Lib/filecmp.py diff --git a/src/StdLib/Lib/fileinput.py b/src/extensions/StdLib/Lib/fileinput.py similarity index 100% rename from src/StdLib/Lib/fileinput.py rename to src/extensions/StdLib/Lib/fileinput.py diff --git a/src/StdLib/Lib/fnmatch.py b/src/extensions/StdLib/Lib/fnmatch.py similarity index 100% rename from src/StdLib/Lib/fnmatch.py rename to src/extensions/StdLib/Lib/fnmatch.py diff --git a/src/StdLib/Lib/formatter.py b/src/extensions/StdLib/Lib/formatter.py similarity index 100% rename from src/StdLib/Lib/formatter.py rename to src/extensions/StdLib/Lib/formatter.py diff --git a/src/StdLib/Lib/fractions.py b/src/extensions/StdLib/Lib/fractions.py similarity index 100% rename from src/StdLib/Lib/fractions.py rename to src/extensions/StdLib/Lib/fractions.py diff --git a/src/StdLib/Lib/ftplib.py b/src/extensions/StdLib/Lib/ftplib.py similarity index 100% rename from src/StdLib/Lib/ftplib.py rename to src/extensions/StdLib/Lib/ftplib.py diff --git a/src/StdLib/Lib/functools.py b/src/extensions/StdLib/Lib/functools.py similarity index 100% rename from src/StdLib/Lib/functools.py rename to src/extensions/StdLib/Lib/functools.py diff --git a/src/StdLib/Lib/genericpath.py b/src/extensions/StdLib/Lib/genericpath.py similarity index 100% rename from src/StdLib/Lib/genericpath.py rename to src/extensions/StdLib/Lib/genericpath.py diff --git a/src/StdLib/Lib/getopt.py b/src/extensions/StdLib/Lib/getopt.py similarity index 100% rename from src/StdLib/Lib/getopt.py rename to src/extensions/StdLib/Lib/getopt.py diff --git a/src/StdLib/Lib/getpass.py b/src/extensions/StdLib/Lib/getpass.py similarity index 100% rename from src/StdLib/Lib/getpass.py rename to src/extensions/StdLib/Lib/getpass.py diff --git a/src/StdLib/Lib/gettext.py b/src/extensions/StdLib/Lib/gettext.py similarity index 100% rename from src/StdLib/Lib/gettext.py rename to src/extensions/StdLib/Lib/gettext.py diff --git a/src/StdLib/Lib/glob.py b/src/extensions/StdLib/Lib/glob.py similarity index 100% rename from src/StdLib/Lib/glob.py rename to src/extensions/StdLib/Lib/glob.py diff --git a/src/StdLib/Lib/gzip.py b/src/extensions/StdLib/Lib/gzip.py similarity index 100% rename from src/StdLib/Lib/gzip.py rename to src/extensions/StdLib/Lib/gzip.py diff --git a/src/StdLib/Lib/hashlib.py b/src/extensions/StdLib/Lib/hashlib.py similarity index 100% rename from src/StdLib/Lib/hashlib.py rename to src/extensions/StdLib/Lib/hashlib.py diff --git a/src/StdLib/Lib/heapq.py b/src/extensions/StdLib/Lib/heapq.py similarity index 100% rename from src/StdLib/Lib/heapq.py rename to src/extensions/StdLib/Lib/heapq.py diff --git a/src/StdLib/Lib/hmac.py b/src/extensions/StdLib/Lib/hmac.py similarity index 100% rename from src/StdLib/Lib/hmac.py rename to src/extensions/StdLib/Lib/hmac.py diff --git a/src/StdLib/Lib/html/__init__.py b/src/extensions/StdLib/Lib/html/__init__.py similarity index 100% rename from src/StdLib/Lib/html/__init__.py rename to src/extensions/StdLib/Lib/html/__init__.py diff --git a/src/StdLib/Lib/html/entities.py b/src/extensions/StdLib/Lib/html/entities.py similarity index 100% rename from src/StdLib/Lib/html/entities.py rename to src/extensions/StdLib/Lib/html/entities.py diff --git a/src/StdLib/Lib/html/parser.py b/src/extensions/StdLib/Lib/html/parser.py similarity index 100% rename from src/StdLib/Lib/html/parser.py rename to src/extensions/StdLib/Lib/html/parser.py diff --git a/src/StdLib/Lib/http/__init__.py b/src/extensions/StdLib/Lib/http/__init__.py similarity index 100% rename from src/StdLib/Lib/http/__init__.py rename to src/extensions/StdLib/Lib/http/__init__.py diff --git a/src/StdLib/Lib/http/client.py b/src/extensions/StdLib/Lib/http/client.py similarity index 100% rename from src/StdLib/Lib/http/client.py rename to src/extensions/StdLib/Lib/http/client.py diff --git a/src/StdLib/Lib/http/cookiejar.py b/src/extensions/StdLib/Lib/http/cookiejar.py similarity index 100% rename from src/StdLib/Lib/http/cookiejar.py rename to src/extensions/StdLib/Lib/http/cookiejar.py diff --git a/src/StdLib/Lib/http/cookies.py b/src/extensions/StdLib/Lib/http/cookies.py similarity index 100% rename from src/StdLib/Lib/http/cookies.py rename to src/extensions/StdLib/Lib/http/cookies.py diff --git a/src/StdLib/Lib/http/server.py b/src/extensions/StdLib/Lib/http/server.py similarity index 100% rename from src/StdLib/Lib/http/server.py rename to src/extensions/StdLib/Lib/http/server.py diff --git a/src/StdLib/Lib/idlelib/AutoComplete.py b/src/extensions/StdLib/Lib/idlelib/AutoComplete.py similarity index 100% rename from src/StdLib/Lib/idlelib/AutoComplete.py rename to src/extensions/StdLib/Lib/idlelib/AutoComplete.py diff --git a/src/StdLib/Lib/idlelib/AutoCompleteWindow.py b/src/extensions/StdLib/Lib/idlelib/AutoCompleteWindow.py similarity index 100% rename from src/StdLib/Lib/idlelib/AutoCompleteWindow.py rename to src/extensions/StdLib/Lib/idlelib/AutoCompleteWindow.py diff --git a/src/StdLib/Lib/idlelib/AutoExpand.py b/src/extensions/StdLib/Lib/idlelib/AutoExpand.py similarity index 100% rename from src/StdLib/Lib/idlelib/AutoExpand.py rename to src/extensions/StdLib/Lib/idlelib/AutoExpand.py diff --git a/src/StdLib/Lib/idlelib/Bindings.py b/src/extensions/StdLib/Lib/idlelib/Bindings.py similarity index 100% rename from src/StdLib/Lib/idlelib/Bindings.py rename to src/extensions/StdLib/Lib/idlelib/Bindings.py diff --git a/src/StdLib/Lib/idlelib/CREDITS.txt b/src/extensions/StdLib/Lib/idlelib/CREDITS.txt similarity index 100% rename from src/StdLib/Lib/idlelib/CREDITS.txt rename to src/extensions/StdLib/Lib/idlelib/CREDITS.txt diff --git a/src/StdLib/Lib/idlelib/CallTipWindow.py b/src/extensions/StdLib/Lib/idlelib/CallTipWindow.py similarity index 100% rename from src/StdLib/Lib/idlelib/CallTipWindow.py rename to src/extensions/StdLib/Lib/idlelib/CallTipWindow.py diff --git a/src/StdLib/Lib/idlelib/CallTips.py b/src/extensions/StdLib/Lib/idlelib/CallTips.py similarity index 100% rename from src/StdLib/Lib/idlelib/CallTips.py rename to src/extensions/StdLib/Lib/idlelib/CallTips.py diff --git a/src/StdLib/Lib/idlelib/ChangeLog b/src/extensions/StdLib/Lib/idlelib/ChangeLog similarity index 100% rename from src/StdLib/Lib/idlelib/ChangeLog rename to src/extensions/StdLib/Lib/idlelib/ChangeLog diff --git a/src/StdLib/Lib/idlelib/ClassBrowser.py b/src/extensions/StdLib/Lib/idlelib/ClassBrowser.py similarity index 100% rename from src/StdLib/Lib/idlelib/ClassBrowser.py rename to src/extensions/StdLib/Lib/idlelib/ClassBrowser.py diff --git a/src/StdLib/Lib/idlelib/CodeContext.py b/src/extensions/StdLib/Lib/idlelib/CodeContext.py similarity index 100% rename from src/StdLib/Lib/idlelib/CodeContext.py rename to src/extensions/StdLib/Lib/idlelib/CodeContext.py diff --git a/src/StdLib/Lib/idlelib/ColorDelegator.py b/src/extensions/StdLib/Lib/idlelib/ColorDelegator.py similarity index 100% rename from src/StdLib/Lib/idlelib/ColorDelegator.py rename to src/extensions/StdLib/Lib/idlelib/ColorDelegator.py diff --git a/src/StdLib/Lib/idlelib/Debugger.py b/src/extensions/StdLib/Lib/idlelib/Debugger.py similarity index 100% rename from src/StdLib/Lib/idlelib/Debugger.py rename to src/extensions/StdLib/Lib/idlelib/Debugger.py diff --git a/src/StdLib/Lib/idlelib/Delegator.py b/src/extensions/StdLib/Lib/idlelib/Delegator.py similarity index 100% rename from src/StdLib/Lib/idlelib/Delegator.py rename to src/extensions/StdLib/Lib/idlelib/Delegator.py diff --git a/src/StdLib/Lib/idlelib/EditorWindow.py b/src/extensions/StdLib/Lib/idlelib/EditorWindow.py similarity index 100% rename from src/StdLib/Lib/idlelib/EditorWindow.py rename to src/extensions/StdLib/Lib/idlelib/EditorWindow.py diff --git a/src/StdLib/Lib/idlelib/FileList.py b/src/extensions/StdLib/Lib/idlelib/FileList.py similarity index 100% rename from src/StdLib/Lib/idlelib/FileList.py rename to src/extensions/StdLib/Lib/idlelib/FileList.py diff --git a/src/StdLib/Lib/idlelib/FormatParagraph.py b/src/extensions/StdLib/Lib/idlelib/FormatParagraph.py similarity index 100% rename from src/StdLib/Lib/idlelib/FormatParagraph.py rename to src/extensions/StdLib/Lib/idlelib/FormatParagraph.py diff --git a/src/StdLib/Lib/idlelib/GrepDialog.py b/src/extensions/StdLib/Lib/idlelib/GrepDialog.py similarity index 100% rename from src/StdLib/Lib/idlelib/GrepDialog.py rename to src/extensions/StdLib/Lib/idlelib/GrepDialog.py diff --git a/src/StdLib/Lib/idlelib/HISTORY.txt b/src/extensions/StdLib/Lib/idlelib/HISTORY.txt similarity index 100% rename from src/StdLib/Lib/idlelib/HISTORY.txt rename to src/extensions/StdLib/Lib/idlelib/HISTORY.txt diff --git a/src/StdLib/Lib/idlelib/HyperParser.py b/src/extensions/StdLib/Lib/idlelib/HyperParser.py similarity index 100% rename from src/StdLib/Lib/idlelib/HyperParser.py rename to src/extensions/StdLib/Lib/idlelib/HyperParser.py diff --git a/src/StdLib/Lib/idlelib/IOBinding.py b/src/extensions/StdLib/Lib/idlelib/IOBinding.py similarity index 100% rename from src/StdLib/Lib/idlelib/IOBinding.py rename to src/extensions/StdLib/Lib/idlelib/IOBinding.py diff --git a/src/StdLib/Lib/idlelib/Icons/folder.gif b/src/extensions/StdLib/Lib/idlelib/Icons/folder.gif similarity index 100% rename from src/StdLib/Lib/idlelib/Icons/folder.gif rename to src/extensions/StdLib/Lib/idlelib/Icons/folder.gif diff --git a/src/StdLib/Lib/idlelib/Icons/idle.icns b/src/extensions/StdLib/Lib/idlelib/Icons/idle.icns similarity index 100% rename from src/StdLib/Lib/idlelib/Icons/idle.icns rename to src/extensions/StdLib/Lib/idlelib/Icons/idle.icns diff --git a/src/StdLib/Lib/idlelib/Icons/idle.ico b/src/extensions/StdLib/Lib/idlelib/Icons/idle.ico similarity index 100% rename from src/StdLib/Lib/idlelib/Icons/idle.ico rename to src/extensions/StdLib/Lib/idlelib/Icons/idle.ico diff --git a/src/StdLib/Lib/idlelib/Icons/idle_16.gif b/src/extensions/StdLib/Lib/idlelib/Icons/idle_16.gif similarity index 100% rename from src/StdLib/Lib/idlelib/Icons/idle_16.gif rename to src/extensions/StdLib/Lib/idlelib/Icons/idle_16.gif diff --git a/src/StdLib/Lib/idlelib/Icons/idle_16.png b/src/extensions/StdLib/Lib/idlelib/Icons/idle_16.png similarity index 100% rename from src/StdLib/Lib/idlelib/Icons/idle_16.png rename to src/extensions/StdLib/Lib/idlelib/Icons/idle_16.png diff --git a/src/StdLib/Lib/idlelib/Icons/idle_32.gif b/src/extensions/StdLib/Lib/idlelib/Icons/idle_32.gif similarity index 100% rename from src/StdLib/Lib/idlelib/Icons/idle_32.gif rename to src/extensions/StdLib/Lib/idlelib/Icons/idle_32.gif diff --git a/src/StdLib/Lib/idlelib/Icons/idle_32.png b/src/extensions/StdLib/Lib/idlelib/Icons/idle_32.png similarity index 100% rename from src/StdLib/Lib/idlelib/Icons/idle_32.png rename to src/extensions/StdLib/Lib/idlelib/Icons/idle_32.png diff --git a/src/StdLib/Lib/idlelib/Icons/idle_48.gif b/src/extensions/StdLib/Lib/idlelib/Icons/idle_48.gif similarity index 100% rename from src/StdLib/Lib/idlelib/Icons/idle_48.gif rename to src/extensions/StdLib/Lib/idlelib/Icons/idle_48.gif diff --git a/src/StdLib/Lib/idlelib/Icons/idle_48.png b/src/extensions/StdLib/Lib/idlelib/Icons/idle_48.png similarity index 100% rename from src/StdLib/Lib/idlelib/Icons/idle_48.png rename to src/extensions/StdLib/Lib/idlelib/Icons/idle_48.png diff --git a/src/StdLib/Lib/idlelib/Icons/minusnode.gif b/src/extensions/StdLib/Lib/idlelib/Icons/minusnode.gif similarity index 100% rename from src/StdLib/Lib/idlelib/Icons/minusnode.gif rename to src/extensions/StdLib/Lib/idlelib/Icons/minusnode.gif diff --git a/src/StdLib/Lib/idlelib/Icons/openfolder.gif b/src/extensions/StdLib/Lib/idlelib/Icons/openfolder.gif similarity index 100% rename from src/StdLib/Lib/idlelib/Icons/openfolder.gif rename to src/extensions/StdLib/Lib/idlelib/Icons/openfolder.gif diff --git a/src/StdLib/Lib/idlelib/Icons/plusnode.gif b/src/extensions/StdLib/Lib/idlelib/Icons/plusnode.gif similarity index 100% rename from src/StdLib/Lib/idlelib/Icons/plusnode.gif rename to src/extensions/StdLib/Lib/idlelib/Icons/plusnode.gif diff --git a/src/StdLib/Lib/idlelib/Icons/python.gif b/src/extensions/StdLib/Lib/idlelib/Icons/python.gif similarity index 100% rename from src/StdLib/Lib/idlelib/Icons/python.gif rename to src/extensions/StdLib/Lib/idlelib/Icons/python.gif diff --git a/src/StdLib/Lib/idlelib/Icons/tk.gif b/src/extensions/StdLib/Lib/idlelib/Icons/tk.gif similarity index 100% rename from src/StdLib/Lib/idlelib/Icons/tk.gif rename to src/extensions/StdLib/Lib/idlelib/Icons/tk.gif diff --git a/src/StdLib/Lib/idlelib/IdleHistory.py b/src/extensions/StdLib/Lib/idlelib/IdleHistory.py similarity index 100% rename from src/StdLib/Lib/idlelib/IdleHistory.py rename to src/extensions/StdLib/Lib/idlelib/IdleHistory.py diff --git a/src/StdLib/Lib/idlelib/MultiCall.py b/src/extensions/StdLib/Lib/idlelib/MultiCall.py similarity index 100% rename from src/StdLib/Lib/idlelib/MultiCall.py rename to src/extensions/StdLib/Lib/idlelib/MultiCall.py diff --git a/src/StdLib/Lib/idlelib/MultiStatusBar.py b/src/extensions/StdLib/Lib/idlelib/MultiStatusBar.py similarity index 100% rename from src/StdLib/Lib/idlelib/MultiStatusBar.py rename to src/extensions/StdLib/Lib/idlelib/MultiStatusBar.py diff --git a/src/StdLib/Lib/idlelib/NEWS.txt b/src/extensions/StdLib/Lib/idlelib/NEWS.txt similarity index 100% rename from src/StdLib/Lib/idlelib/NEWS.txt rename to src/extensions/StdLib/Lib/idlelib/NEWS.txt diff --git a/src/StdLib/Lib/idlelib/ObjectBrowser.py b/src/extensions/StdLib/Lib/idlelib/ObjectBrowser.py similarity index 100% rename from src/StdLib/Lib/idlelib/ObjectBrowser.py rename to src/extensions/StdLib/Lib/idlelib/ObjectBrowser.py diff --git a/src/StdLib/Lib/idlelib/OutputWindow.py b/src/extensions/StdLib/Lib/idlelib/OutputWindow.py similarity index 100% rename from src/StdLib/Lib/idlelib/OutputWindow.py rename to src/extensions/StdLib/Lib/idlelib/OutputWindow.py diff --git a/src/StdLib/Lib/idlelib/ParenMatch.py b/src/extensions/StdLib/Lib/idlelib/ParenMatch.py similarity index 100% rename from src/StdLib/Lib/idlelib/ParenMatch.py rename to src/extensions/StdLib/Lib/idlelib/ParenMatch.py diff --git a/src/StdLib/Lib/idlelib/PathBrowser.py b/src/extensions/StdLib/Lib/idlelib/PathBrowser.py similarity index 100% rename from src/StdLib/Lib/idlelib/PathBrowser.py rename to src/extensions/StdLib/Lib/idlelib/PathBrowser.py diff --git a/src/StdLib/Lib/idlelib/Percolator.py b/src/extensions/StdLib/Lib/idlelib/Percolator.py similarity index 100% rename from src/StdLib/Lib/idlelib/Percolator.py rename to src/extensions/StdLib/Lib/idlelib/Percolator.py diff --git a/src/StdLib/Lib/idlelib/PyParse.py b/src/extensions/StdLib/Lib/idlelib/PyParse.py similarity index 100% rename from src/StdLib/Lib/idlelib/PyParse.py rename to src/extensions/StdLib/Lib/idlelib/PyParse.py diff --git a/src/StdLib/Lib/idlelib/PyShell.py b/src/extensions/StdLib/Lib/idlelib/PyShell.py similarity index 100% rename from src/StdLib/Lib/idlelib/PyShell.py rename to src/extensions/StdLib/Lib/idlelib/PyShell.py diff --git a/src/StdLib/Lib/idlelib/README.txt b/src/extensions/StdLib/Lib/idlelib/README.txt similarity index 100% rename from src/StdLib/Lib/idlelib/README.txt rename to src/extensions/StdLib/Lib/idlelib/README.txt diff --git a/src/StdLib/Lib/idlelib/RemoteDebugger.py b/src/extensions/StdLib/Lib/idlelib/RemoteDebugger.py similarity index 100% rename from src/StdLib/Lib/idlelib/RemoteDebugger.py rename to src/extensions/StdLib/Lib/idlelib/RemoteDebugger.py diff --git a/src/StdLib/Lib/idlelib/RemoteObjectBrowser.py b/src/extensions/StdLib/Lib/idlelib/RemoteObjectBrowser.py similarity index 100% rename from src/StdLib/Lib/idlelib/RemoteObjectBrowser.py rename to src/extensions/StdLib/Lib/idlelib/RemoteObjectBrowser.py diff --git a/src/StdLib/Lib/idlelib/ReplaceDialog.py b/src/extensions/StdLib/Lib/idlelib/ReplaceDialog.py similarity index 100% rename from src/StdLib/Lib/idlelib/ReplaceDialog.py rename to src/extensions/StdLib/Lib/idlelib/ReplaceDialog.py diff --git a/src/StdLib/Lib/idlelib/RstripExtension.py b/src/extensions/StdLib/Lib/idlelib/RstripExtension.py similarity index 100% rename from src/StdLib/Lib/idlelib/RstripExtension.py rename to src/extensions/StdLib/Lib/idlelib/RstripExtension.py diff --git a/src/StdLib/Lib/idlelib/ScriptBinding.py b/src/extensions/StdLib/Lib/idlelib/ScriptBinding.py similarity index 100% rename from src/StdLib/Lib/idlelib/ScriptBinding.py rename to src/extensions/StdLib/Lib/idlelib/ScriptBinding.py diff --git a/src/StdLib/Lib/idlelib/ScrolledList.py b/src/extensions/StdLib/Lib/idlelib/ScrolledList.py similarity index 100% rename from src/StdLib/Lib/idlelib/ScrolledList.py rename to src/extensions/StdLib/Lib/idlelib/ScrolledList.py diff --git a/src/StdLib/Lib/idlelib/SearchDialog.py b/src/extensions/StdLib/Lib/idlelib/SearchDialog.py similarity index 100% rename from src/StdLib/Lib/idlelib/SearchDialog.py rename to src/extensions/StdLib/Lib/idlelib/SearchDialog.py diff --git a/src/StdLib/Lib/idlelib/SearchDialogBase.py b/src/extensions/StdLib/Lib/idlelib/SearchDialogBase.py similarity index 100% rename from src/StdLib/Lib/idlelib/SearchDialogBase.py rename to src/extensions/StdLib/Lib/idlelib/SearchDialogBase.py diff --git a/src/StdLib/Lib/idlelib/SearchEngine.py b/src/extensions/StdLib/Lib/idlelib/SearchEngine.py similarity index 100% rename from src/StdLib/Lib/idlelib/SearchEngine.py rename to src/extensions/StdLib/Lib/idlelib/SearchEngine.py diff --git a/src/StdLib/Lib/idlelib/StackViewer.py b/src/extensions/StdLib/Lib/idlelib/StackViewer.py similarity index 100% rename from src/StdLib/Lib/idlelib/StackViewer.py rename to src/extensions/StdLib/Lib/idlelib/StackViewer.py diff --git a/src/StdLib/Lib/idlelib/TODO.txt b/src/extensions/StdLib/Lib/idlelib/TODO.txt similarity index 100% rename from src/StdLib/Lib/idlelib/TODO.txt rename to src/extensions/StdLib/Lib/idlelib/TODO.txt diff --git a/src/StdLib/Lib/idlelib/ToolTip.py b/src/extensions/StdLib/Lib/idlelib/ToolTip.py similarity index 100% rename from src/StdLib/Lib/idlelib/ToolTip.py rename to src/extensions/StdLib/Lib/idlelib/ToolTip.py diff --git a/src/StdLib/Lib/idlelib/TreeWidget.py b/src/extensions/StdLib/Lib/idlelib/TreeWidget.py similarity index 100% rename from src/StdLib/Lib/idlelib/TreeWidget.py rename to src/extensions/StdLib/Lib/idlelib/TreeWidget.py diff --git a/src/StdLib/Lib/idlelib/UndoDelegator.py b/src/extensions/StdLib/Lib/idlelib/UndoDelegator.py similarity index 100% rename from src/StdLib/Lib/idlelib/UndoDelegator.py rename to src/extensions/StdLib/Lib/idlelib/UndoDelegator.py diff --git a/src/StdLib/Lib/idlelib/WidgetRedirector.py b/src/extensions/StdLib/Lib/idlelib/WidgetRedirector.py similarity index 100% rename from src/StdLib/Lib/idlelib/WidgetRedirector.py rename to src/extensions/StdLib/Lib/idlelib/WidgetRedirector.py diff --git a/src/StdLib/Lib/idlelib/WindowList.py b/src/extensions/StdLib/Lib/idlelib/WindowList.py similarity index 100% rename from src/StdLib/Lib/idlelib/WindowList.py rename to src/extensions/StdLib/Lib/idlelib/WindowList.py diff --git a/src/StdLib/Lib/idlelib/ZoomHeight.py b/src/extensions/StdLib/Lib/idlelib/ZoomHeight.py similarity index 100% rename from src/StdLib/Lib/idlelib/ZoomHeight.py rename to src/extensions/StdLib/Lib/idlelib/ZoomHeight.py diff --git a/src/StdLib/Lib/idlelib/__init__.py b/src/extensions/StdLib/Lib/idlelib/__init__.py similarity index 100% rename from src/StdLib/Lib/idlelib/__init__.py rename to src/extensions/StdLib/Lib/idlelib/__init__.py diff --git a/src/StdLib/Lib/idlelib/__main__.py b/src/extensions/StdLib/Lib/idlelib/__main__.py similarity index 100% rename from src/StdLib/Lib/idlelib/__main__.py rename to src/extensions/StdLib/Lib/idlelib/__main__.py diff --git a/src/StdLib/Lib/idlelib/aboutDialog.py b/src/extensions/StdLib/Lib/idlelib/aboutDialog.py similarity index 100% rename from src/StdLib/Lib/idlelib/aboutDialog.py rename to src/extensions/StdLib/Lib/idlelib/aboutDialog.py diff --git a/src/StdLib/Lib/idlelib/config-extensions.def b/src/extensions/StdLib/Lib/idlelib/config-extensions.def similarity index 100% rename from src/StdLib/Lib/idlelib/config-extensions.def rename to src/extensions/StdLib/Lib/idlelib/config-extensions.def diff --git a/src/StdLib/Lib/idlelib/config-highlight.def b/src/extensions/StdLib/Lib/idlelib/config-highlight.def similarity index 100% rename from src/StdLib/Lib/idlelib/config-highlight.def rename to src/extensions/StdLib/Lib/idlelib/config-highlight.def diff --git a/src/StdLib/Lib/idlelib/config-keys.def b/src/extensions/StdLib/Lib/idlelib/config-keys.def similarity index 100% rename from src/StdLib/Lib/idlelib/config-keys.def rename to src/extensions/StdLib/Lib/idlelib/config-keys.def diff --git a/src/StdLib/Lib/idlelib/config-main.def b/src/extensions/StdLib/Lib/idlelib/config-main.def similarity index 100% rename from src/StdLib/Lib/idlelib/config-main.def rename to src/extensions/StdLib/Lib/idlelib/config-main.def diff --git a/src/StdLib/Lib/idlelib/configDialog.py b/src/extensions/StdLib/Lib/idlelib/configDialog.py similarity index 100% rename from src/StdLib/Lib/idlelib/configDialog.py rename to src/extensions/StdLib/Lib/idlelib/configDialog.py diff --git a/src/StdLib/Lib/idlelib/configHandler.py b/src/extensions/StdLib/Lib/idlelib/configHandler.py similarity index 100% rename from src/StdLib/Lib/idlelib/configHandler.py rename to src/extensions/StdLib/Lib/idlelib/configHandler.py diff --git a/src/StdLib/Lib/idlelib/configHelpSourceEdit.py b/src/extensions/StdLib/Lib/idlelib/configHelpSourceEdit.py similarity index 100% rename from src/StdLib/Lib/idlelib/configHelpSourceEdit.py rename to src/extensions/StdLib/Lib/idlelib/configHelpSourceEdit.py diff --git a/src/StdLib/Lib/idlelib/configSectionNameDialog.py b/src/extensions/StdLib/Lib/idlelib/configSectionNameDialog.py similarity index 100% rename from src/StdLib/Lib/idlelib/configSectionNameDialog.py rename to src/extensions/StdLib/Lib/idlelib/configSectionNameDialog.py diff --git a/src/StdLib/Lib/idlelib/dynOptionMenuWidget.py b/src/extensions/StdLib/Lib/idlelib/dynOptionMenuWidget.py similarity index 100% rename from src/StdLib/Lib/idlelib/dynOptionMenuWidget.py rename to src/extensions/StdLib/Lib/idlelib/dynOptionMenuWidget.py diff --git a/src/StdLib/Lib/idlelib/extend.txt b/src/extensions/StdLib/Lib/idlelib/extend.txt similarity index 100% rename from src/StdLib/Lib/idlelib/extend.txt rename to src/extensions/StdLib/Lib/idlelib/extend.txt diff --git a/src/StdLib/Lib/idlelib/help.html b/src/extensions/StdLib/Lib/idlelib/help.html similarity index 100% rename from src/StdLib/Lib/idlelib/help.html rename to src/extensions/StdLib/Lib/idlelib/help.html diff --git a/src/StdLib/Lib/idlelib/help.py b/src/extensions/StdLib/Lib/idlelib/help.py similarity index 100% rename from src/StdLib/Lib/idlelib/help.py rename to src/extensions/StdLib/Lib/idlelib/help.py diff --git a/src/StdLib/Lib/idlelib/help.txt b/src/extensions/StdLib/Lib/idlelib/help.txt similarity index 100% rename from src/StdLib/Lib/idlelib/help.txt rename to src/extensions/StdLib/Lib/idlelib/help.txt diff --git a/src/StdLib/Lib/idlelib/idle.bat b/src/extensions/StdLib/Lib/idlelib/idle.bat similarity index 100% rename from src/StdLib/Lib/idlelib/idle.bat rename to src/extensions/StdLib/Lib/idlelib/idle.bat diff --git a/src/StdLib/Lib/idlelib/idle.py b/src/extensions/StdLib/Lib/idlelib/idle.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle.py rename to src/extensions/StdLib/Lib/idlelib/idle.py diff --git a/src/StdLib/Lib/idlelib/idle.pyw b/src/extensions/StdLib/Lib/idlelib/idle.pyw similarity index 100% rename from src/StdLib/Lib/idlelib/idle.pyw rename to src/extensions/StdLib/Lib/idlelib/idle.pyw diff --git a/src/StdLib/Lib/idlelib/idle_test/README.txt b/src/extensions/StdLib/Lib/idlelib/idle_test/README.txt similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/README.txt rename to src/extensions/StdLib/Lib/idlelib/idle_test/README.txt diff --git a/src/StdLib/Lib/idlelib/idle_test/__init__.py b/src/extensions/StdLib/Lib/idlelib/idle_test/__init__.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/__init__.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/__init__.py diff --git a/src/StdLib/Lib/idlelib/idle_test/htest.py b/src/extensions/StdLib/Lib/idlelib/idle_test/htest.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/htest.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/htest.py diff --git a/src/StdLib/Lib/idlelib/idle_test/mock_idle.py b/src/extensions/StdLib/Lib/idlelib/idle_test/mock_idle.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/mock_idle.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/mock_idle.py diff --git a/src/StdLib/Lib/idlelib/idle_test/mock_tk.py b/src/extensions/StdLib/Lib/idlelib/idle_test/mock_tk.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/mock_tk.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/mock_tk.py diff --git a/src/StdLib/Lib/idlelib/idle_test/test_autocomplete.py b/src/extensions/StdLib/Lib/idlelib/idle_test/test_autocomplete.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/test_autocomplete.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/test_autocomplete.py diff --git a/src/StdLib/Lib/idlelib/idle_test/test_autoexpand.py b/src/extensions/StdLib/Lib/idlelib/idle_test/test_autoexpand.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/test_autoexpand.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/test_autoexpand.py diff --git a/src/StdLib/Lib/idlelib/idle_test/test_calltips.py b/src/extensions/StdLib/Lib/idlelib/idle_test/test_calltips.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/test_calltips.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/test_calltips.py diff --git a/src/StdLib/Lib/idlelib/idle_test/test_config_name.py b/src/extensions/StdLib/Lib/idlelib/idle_test/test_config_name.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/test_config_name.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/test_config_name.py diff --git a/src/StdLib/Lib/idlelib/idle_test/test_configdialog.py b/src/extensions/StdLib/Lib/idlelib/idle_test/test_configdialog.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/test_configdialog.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/test_configdialog.py diff --git a/src/StdLib/Lib/idlelib/idle_test/test_delegator.py b/src/extensions/StdLib/Lib/idlelib/idle_test/test_delegator.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/test_delegator.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/test_delegator.py diff --git a/src/StdLib/Lib/idlelib/idle_test/test_editor.py b/src/extensions/StdLib/Lib/idlelib/idle_test/test_editor.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/test_editor.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/test_editor.py diff --git a/src/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py b/src/extensions/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py diff --git a/src/StdLib/Lib/idlelib/idle_test/test_grep.py b/src/extensions/StdLib/Lib/idlelib/idle_test/test_grep.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/test_grep.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/test_grep.py diff --git a/src/StdLib/Lib/idlelib/idle_test/test_hyperparser.py b/src/extensions/StdLib/Lib/idlelib/idle_test/test_hyperparser.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/test_hyperparser.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/test_hyperparser.py diff --git a/src/StdLib/Lib/idlelib/idle_test/test_idlehistory.py b/src/extensions/StdLib/Lib/idlelib/idle_test/test_idlehistory.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/test_idlehistory.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/test_idlehistory.py diff --git a/src/StdLib/Lib/idlelib/idle_test/test_io.py b/src/extensions/StdLib/Lib/idlelib/idle_test/test_io.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/test_io.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/test_io.py diff --git a/src/StdLib/Lib/idlelib/idle_test/test_parenmatch.py b/src/extensions/StdLib/Lib/idlelib/idle_test/test_parenmatch.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/test_parenmatch.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/test_parenmatch.py diff --git a/src/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py b/src/extensions/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py diff --git a/src/StdLib/Lib/idlelib/idle_test/test_rstrip.py b/src/extensions/StdLib/Lib/idlelib/idle_test/test_rstrip.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/test_rstrip.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/test_rstrip.py diff --git a/src/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py b/src/extensions/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py diff --git a/src/StdLib/Lib/idlelib/idle_test/test_searchengine.py b/src/extensions/StdLib/Lib/idlelib/idle_test/test_searchengine.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/test_searchengine.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/test_searchengine.py diff --git a/src/StdLib/Lib/idlelib/idle_test/test_text.py b/src/extensions/StdLib/Lib/idlelib/idle_test/test_text.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/test_text.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/test_text.py diff --git a/src/StdLib/Lib/idlelib/idle_test/test_textview.py b/src/extensions/StdLib/Lib/idlelib/idle_test/test_textview.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/test_textview.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/test_textview.py diff --git a/src/StdLib/Lib/idlelib/idle_test/test_warning.py b/src/extensions/StdLib/Lib/idlelib/idle_test/test_warning.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/test_warning.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/test_warning.py diff --git a/src/StdLib/Lib/idlelib/idle_test/test_widgetredir.py b/src/extensions/StdLib/Lib/idlelib/idle_test/test_widgetredir.py similarity index 100% rename from src/StdLib/Lib/idlelib/idle_test/test_widgetredir.py rename to src/extensions/StdLib/Lib/idlelib/idle_test/test_widgetredir.py diff --git a/src/StdLib/Lib/idlelib/idlever.py b/src/extensions/StdLib/Lib/idlelib/idlever.py similarity index 100% rename from src/StdLib/Lib/idlelib/idlever.py rename to src/extensions/StdLib/Lib/idlelib/idlever.py diff --git a/src/StdLib/Lib/idlelib/keybindingDialog.py b/src/extensions/StdLib/Lib/idlelib/keybindingDialog.py similarity index 100% rename from src/StdLib/Lib/idlelib/keybindingDialog.py rename to src/extensions/StdLib/Lib/idlelib/keybindingDialog.py diff --git a/src/StdLib/Lib/idlelib/macosxSupport.py b/src/extensions/StdLib/Lib/idlelib/macosxSupport.py similarity index 100% rename from src/StdLib/Lib/idlelib/macosxSupport.py rename to src/extensions/StdLib/Lib/idlelib/macosxSupport.py diff --git a/src/StdLib/Lib/idlelib/rpc.py b/src/extensions/StdLib/Lib/idlelib/rpc.py similarity index 100% rename from src/StdLib/Lib/idlelib/rpc.py rename to src/extensions/StdLib/Lib/idlelib/rpc.py diff --git a/src/StdLib/Lib/idlelib/run.py b/src/extensions/StdLib/Lib/idlelib/run.py similarity index 100% rename from src/StdLib/Lib/idlelib/run.py rename to src/extensions/StdLib/Lib/idlelib/run.py diff --git a/src/StdLib/Lib/idlelib/tabbedpages.py b/src/extensions/StdLib/Lib/idlelib/tabbedpages.py similarity index 100% rename from src/StdLib/Lib/idlelib/tabbedpages.py rename to src/extensions/StdLib/Lib/idlelib/tabbedpages.py diff --git a/src/StdLib/Lib/idlelib/textView.py b/src/extensions/StdLib/Lib/idlelib/textView.py similarity index 100% rename from src/StdLib/Lib/idlelib/textView.py rename to src/extensions/StdLib/Lib/idlelib/textView.py diff --git a/src/StdLib/Lib/imaplib.py b/src/extensions/StdLib/Lib/imaplib.py similarity index 100% rename from src/StdLib/Lib/imaplib.py rename to src/extensions/StdLib/Lib/imaplib.py diff --git a/src/StdLib/Lib/imghdr.py b/src/extensions/StdLib/Lib/imghdr.py similarity index 100% rename from src/StdLib/Lib/imghdr.py rename to src/extensions/StdLib/Lib/imghdr.py diff --git a/src/StdLib/Lib/imp.py b/src/extensions/StdLib/Lib/imp.py similarity index 100% rename from src/StdLib/Lib/imp.py rename to src/extensions/StdLib/Lib/imp.py diff --git a/src/StdLib/Lib/importlib/__init__.py b/src/extensions/StdLib/Lib/importlib/__init__.py similarity index 100% rename from src/StdLib/Lib/importlib/__init__.py rename to src/extensions/StdLib/Lib/importlib/__init__.py diff --git a/src/StdLib/Lib/importlib/_bootstrap.py b/src/extensions/StdLib/Lib/importlib/_bootstrap.py similarity index 100% rename from src/StdLib/Lib/importlib/_bootstrap.py rename to src/extensions/StdLib/Lib/importlib/_bootstrap.py diff --git a/src/StdLib/Lib/importlib/abc.py b/src/extensions/StdLib/Lib/importlib/abc.py similarity index 100% rename from src/StdLib/Lib/importlib/abc.py rename to src/extensions/StdLib/Lib/importlib/abc.py diff --git a/src/StdLib/Lib/importlib/machinery.py b/src/extensions/StdLib/Lib/importlib/machinery.py similarity index 100% rename from src/StdLib/Lib/importlib/machinery.py rename to src/extensions/StdLib/Lib/importlib/machinery.py diff --git a/src/StdLib/Lib/importlib/util.py b/src/extensions/StdLib/Lib/importlib/util.py similarity index 100% rename from src/StdLib/Lib/importlib/util.py rename to src/extensions/StdLib/Lib/importlib/util.py diff --git a/src/StdLib/Lib/inspect.py b/src/extensions/StdLib/Lib/inspect.py similarity index 100% rename from src/StdLib/Lib/inspect.py rename to src/extensions/StdLib/Lib/inspect.py diff --git a/src/StdLib/Lib/io.py b/src/extensions/StdLib/Lib/io.py similarity index 100% rename from src/StdLib/Lib/io.py rename to src/extensions/StdLib/Lib/io.py diff --git a/src/StdLib/Lib/ipaddress.py b/src/extensions/StdLib/Lib/ipaddress.py similarity index 100% rename from src/StdLib/Lib/ipaddress.py rename to src/extensions/StdLib/Lib/ipaddress.py diff --git a/src/StdLib/Lib/json/__init__.py b/src/extensions/StdLib/Lib/json/__init__.py similarity index 100% rename from src/StdLib/Lib/json/__init__.py rename to src/extensions/StdLib/Lib/json/__init__.py diff --git a/src/StdLib/Lib/json/decoder.py b/src/extensions/StdLib/Lib/json/decoder.py similarity index 100% rename from src/StdLib/Lib/json/decoder.py rename to src/extensions/StdLib/Lib/json/decoder.py diff --git a/src/StdLib/Lib/json/encoder.py b/src/extensions/StdLib/Lib/json/encoder.py similarity index 100% rename from src/StdLib/Lib/json/encoder.py rename to src/extensions/StdLib/Lib/json/encoder.py diff --git a/src/StdLib/Lib/json/scanner.py b/src/extensions/StdLib/Lib/json/scanner.py similarity index 100% rename from src/StdLib/Lib/json/scanner.py rename to src/extensions/StdLib/Lib/json/scanner.py diff --git a/src/StdLib/Lib/json/tool.py b/src/extensions/StdLib/Lib/json/tool.py similarity index 100% rename from src/StdLib/Lib/json/tool.py rename to src/extensions/StdLib/Lib/json/tool.py diff --git a/src/StdLib/Lib/keyword.py b/src/extensions/StdLib/Lib/keyword.py similarity index 100% rename from src/StdLib/Lib/keyword.py rename to src/extensions/StdLib/Lib/keyword.py diff --git a/src/StdLib/Lib/lib2to3/Grammar.txt b/src/extensions/StdLib/Lib/lib2to3/Grammar.txt similarity index 100% rename from src/StdLib/Lib/lib2to3/Grammar.txt rename to src/extensions/StdLib/Lib/lib2to3/Grammar.txt diff --git a/src/StdLib/Lib/lib2to3/PatternGrammar.txt b/src/extensions/StdLib/Lib/lib2to3/PatternGrammar.txt similarity index 100% rename from src/StdLib/Lib/lib2to3/PatternGrammar.txt rename to src/extensions/StdLib/Lib/lib2to3/PatternGrammar.txt diff --git a/src/StdLib/Lib/lib2to3/__init__.py b/src/extensions/StdLib/Lib/lib2to3/__init__.py similarity index 100% rename from src/StdLib/Lib/lib2to3/__init__.py rename to src/extensions/StdLib/Lib/lib2to3/__init__.py diff --git a/src/StdLib/Lib/lib2to3/__main__.py b/src/extensions/StdLib/Lib/lib2to3/__main__.py similarity index 100% rename from src/StdLib/Lib/lib2to3/__main__.py rename to src/extensions/StdLib/Lib/lib2to3/__main__.py diff --git a/src/StdLib/Lib/lib2to3/btm_matcher.py b/src/extensions/StdLib/Lib/lib2to3/btm_matcher.py similarity index 100% rename from src/StdLib/Lib/lib2to3/btm_matcher.py rename to src/extensions/StdLib/Lib/lib2to3/btm_matcher.py diff --git a/src/StdLib/Lib/lib2to3/btm_utils.py b/src/extensions/StdLib/Lib/lib2to3/btm_utils.py similarity index 100% rename from src/StdLib/Lib/lib2to3/btm_utils.py rename to src/extensions/StdLib/Lib/lib2to3/btm_utils.py diff --git a/src/StdLib/Lib/lib2to3/fixer_base.py b/src/extensions/StdLib/Lib/lib2to3/fixer_base.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixer_base.py rename to src/extensions/StdLib/Lib/lib2to3/fixer_base.py diff --git a/src/StdLib/Lib/lib2to3/fixer_util.py b/src/extensions/StdLib/Lib/lib2to3/fixer_util.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixer_util.py rename to src/extensions/StdLib/Lib/lib2to3/fixer_util.py diff --git a/src/StdLib/Lib/lib2to3/fixes/__init__.py b/src/extensions/StdLib/Lib/lib2to3/fixes/__init__.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/__init__.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/__init__.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_apply.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_apply.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_apply.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_apply.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_asserts.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_asserts.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_asserts.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_asserts.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_basestring.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_basestring.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_basestring.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_basestring.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_buffer.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_buffer.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_buffer.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_buffer.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_callable.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_callable.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_callable.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_callable.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_dict.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_dict.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_dict.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_dict.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_except.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_except.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_except.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_except.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_exec.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_exec.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_exec.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_exec.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_execfile.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_execfile.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_execfile.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_execfile.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_filter.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_filter.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_filter.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_filter.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_future.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_future.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_future.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_future.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_has_key.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_has_key.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_has_key.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_has_key.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_idioms.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_idioms.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_idioms.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_idioms.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_import.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_import.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_import.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_import.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_imports.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_imports.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_imports.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_imports.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_imports2.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_imports2.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_imports2.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_imports2.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_input.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_input.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_input.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_input.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_intern.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_intern.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_intern.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_intern.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_isinstance.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_isinstance.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_isinstance.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_isinstance.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_itertools.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_itertools.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_itertools.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_itertools.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_long.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_long.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_long.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_long.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_map.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_map.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_map.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_map.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_metaclass.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_metaclass.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_metaclass.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_metaclass.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_ne.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_ne.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_ne.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_ne.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_next.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_next.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_next.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_next.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_nonzero.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_nonzero.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_nonzero.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_nonzero.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_numliterals.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_numliterals.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_numliterals.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_numliterals.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_operator.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_operator.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_operator.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_operator.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_paren.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_paren.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_paren.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_paren.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_print.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_print.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_print.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_print.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_raise.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_raise.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_raise.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_raise.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_raw_input.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_raw_input.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_raw_input.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_raw_input.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_reduce.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_reduce.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_reduce.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_reduce.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_reload.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_reload.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_reload.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_reload.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_renames.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_renames.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_renames.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_renames.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_repr.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_repr.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_repr.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_repr.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_set_literal.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_set_literal.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_set_literal.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_set_literal.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_standarderror.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_standarderror.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_standarderror.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_standarderror.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_throw.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_throw.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_throw.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_throw.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_types.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_types.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_types.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_types.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_unicode.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_unicode.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_unicode.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_unicode.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_urllib.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_urllib.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_urllib.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_urllib.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_xrange.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_xrange.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_xrange.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_xrange.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py diff --git a/src/StdLib/Lib/lib2to3/fixes/fix_zip.py b/src/extensions/StdLib/Lib/lib2to3/fixes/fix_zip.py similarity index 100% rename from src/StdLib/Lib/lib2to3/fixes/fix_zip.py rename to src/extensions/StdLib/Lib/lib2to3/fixes/fix_zip.py diff --git a/src/StdLib/Lib/lib2to3/main.py b/src/extensions/StdLib/Lib/lib2to3/main.py similarity index 100% rename from src/StdLib/Lib/lib2to3/main.py rename to src/extensions/StdLib/Lib/lib2to3/main.py diff --git a/src/StdLib/Lib/lib2to3/patcomp.py b/src/extensions/StdLib/Lib/lib2to3/patcomp.py similarity index 100% rename from src/StdLib/Lib/lib2to3/patcomp.py rename to src/extensions/StdLib/Lib/lib2to3/patcomp.py diff --git a/src/StdLib/Lib/lib2to3/pgen2/__init__.py b/src/extensions/StdLib/Lib/lib2to3/pgen2/__init__.py similarity index 100% rename from src/StdLib/Lib/lib2to3/pgen2/__init__.py rename to src/extensions/StdLib/Lib/lib2to3/pgen2/__init__.py diff --git a/src/StdLib/Lib/lib2to3/pgen2/conv.py b/src/extensions/StdLib/Lib/lib2to3/pgen2/conv.py similarity index 100% rename from src/StdLib/Lib/lib2to3/pgen2/conv.py rename to src/extensions/StdLib/Lib/lib2to3/pgen2/conv.py diff --git a/src/StdLib/Lib/lib2to3/pgen2/driver.py b/src/extensions/StdLib/Lib/lib2to3/pgen2/driver.py similarity index 100% rename from src/StdLib/Lib/lib2to3/pgen2/driver.py rename to src/extensions/StdLib/Lib/lib2to3/pgen2/driver.py diff --git a/src/StdLib/Lib/lib2to3/pgen2/grammar.py b/src/extensions/StdLib/Lib/lib2to3/pgen2/grammar.py similarity index 100% rename from src/StdLib/Lib/lib2to3/pgen2/grammar.py rename to src/extensions/StdLib/Lib/lib2to3/pgen2/grammar.py diff --git a/src/StdLib/Lib/lib2to3/pgen2/literals.py b/src/extensions/StdLib/Lib/lib2to3/pgen2/literals.py similarity index 100% rename from src/StdLib/Lib/lib2to3/pgen2/literals.py rename to src/extensions/StdLib/Lib/lib2to3/pgen2/literals.py diff --git a/src/StdLib/Lib/lib2to3/pgen2/parse.py b/src/extensions/StdLib/Lib/lib2to3/pgen2/parse.py similarity index 100% rename from src/StdLib/Lib/lib2to3/pgen2/parse.py rename to src/extensions/StdLib/Lib/lib2to3/pgen2/parse.py diff --git a/src/StdLib/Lib/lib2to3/pgen2/pgen.py b/src/extensions/StdLib/Lib/lib2to3/pgen2/pgen.py similarity index 100% rename from src/StdLib/Lib/lib2to3/pgen2/pgen.py rename to src/extensions/StdLib/Lib/lib2to3/pgen2/pgen.py diff --git a/src/StdLib/Lib/lib2to3/pgen2/token.py b/src/extensions/StdLib/Lib/lib2to3/pgen2/token.py similarity index 100% rename from src/StdLib/Lib/lib2to3/pgen2/token.py rename to src/extensions/StdLib/Lib/lib2to3/pgen2/token.py diff --git a/src/StdLib/Lib/lib2to3/pgen2/tokenize.py b/src/extensions/StdLib/Lib/lib2to3/pgen2/tokenize.py similarity index 100% rename from src/StdLib/Lib/lib2to3/pgen2/tokenize.py rename to src/extensions/StdLib/Lib/lib2to3/pgen2/tokenize.py diff --git a/src/StdLib/Lib/lib2to3/pygram.py b/src/extensions/StdLib/Lib/lib2to3/pygram.py similarity index 100% rename from src/StdLib/Lib/lib2to3/pygram.py rename to src/extensions/StdLib/Lib/lib2to3/pygram.py diff --git a/src/StdLib/Lib/lib2to3/pytree.py b/src/extensions/StdLib/Lib/lib2to3/pytree.py similarity index 100% rename from src/StdLib/Lib/lib2to3/pytree.py rename to src/extensions/StdLib/Lib/lib2to3/pytree.py diff --git a/src/StdLib/Lib/lib2to3/refactor.py b/src/extensions/StdLib/Lib/lib2to3/refactor.py similarity index 100% rename from src/StdLib/Lib/lib2to3/refactor.py rename to src/extensions/StdLib/Lib/lib2to3/refactor.py diff --git a/src/StdLib/Lib/lib2to3/tests/__init__.py b/src/extensions/StdLib/Lib/lib2to3/tests/__init__.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/__init__.py rename to src/extensions/StdLib/Lib/lib2to3/tests/__init__.py diff --git a/src/StdLib/Lib/lib2to3/tests/__main__.py b/src/extensions/StdLib/Lib/lib2to3/tests/__main__.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/__main__.py rename to src/extensions/StdLib/Lib/lib2to3/tests/__main__.py diff --git a/src/StdLib/Lib/lib2to3/tests/data/README b/src/extensions/StdLib/Lib/lib2to3/tests/data/README similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/data/README rename to src/extensions/StdLib/Lib/lib2to3/tests/data/README diff --git a/src/StdLib/Lib/lib2to3/tests/data/bom.py b/src/extensions/StdLib/Lib/lib2to3/tests/data/bom.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/data/bom.py rename to src/extensions/StdLib/Lib/lib2to3/tests/data/bom.py diff --git a/src/StdLib/Lib/lib2to3/tests/data/crlf.py b/src/extensions/StdLib/Lib/lib2to3/tests/data/crlf.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/data/crlf.py rename to src/extensions/StdLib/Lib/lib2to3/tests/data/crlf.py diff --git a/src/StdLib/Lib/lib2to3/tests/data/different_encoding.py b/src/extensions/StdLib/Lib/lib2to3/tests/data/different_encoding.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/data/different_encoding.py rename to src/extensions/StdLib/Lib/lib2to3/tests/data/different_encoding.py diff --git a/src/StdLib/Lib/lib2to3/tests/data/false_encoding.py b/src/extensions/StdLib/Lib/lib2to3/tests/data/false_encoding.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/data/false_encoding.py rename to src/extensions/StdLib/Lib/lib2to3/tests/data/false_encoding.py diff --git a/src/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py b/src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py rename to src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py diff --git a/src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py b/src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py rename to src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py diff --git a/src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py b/src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py rename to src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py diff --git a/src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py b/src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py rename to src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py diff --git a/src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py b/src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py rename to src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py diff --git a/src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py b/src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py rename to src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py diff --git a/src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py b/src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py rename to src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py diff --git a/src/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py b/src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py rename to src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py diff --git a/src/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py b/src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py rename to src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py diff --git a/src/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py b/src/extensions/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py rename to src/extensions/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py diff --git a/src/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py b/src/extensions/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py rename to src/extensions/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py diff --git a/src/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py b/src/extensions/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py rename to src/extensions/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py diff --git a/src/StdLib/Lib/lib2to3/tests/pytree_idempotency.py b/src/extensions/StdLib/Lib/lib2to3/tests/pytree_idempotency.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/pytree_idempotency.py rename to src/extensions/StdLib/Lib/lib2to3/tests/pytree_idempotency.py diff --git a/src/StdLib/Lib/lib2to3/tests/support.py b/src/extensions/StdLib/Lib/lib2to3/tests/support.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/support.py rename to src/extensions/StdLib/Lib/lib2to3/tests/support.py diff --git a/src/StdLib/Lib/lib2to3/tests/test_all_fixers.py b/src/extensions/StdLib/Lib/lib2to3/tests/test_all_fixers.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/test_all_fixers.py rename to src/extensions/StdLib/Lib/lib2to3/tests/test_all_fixers.py diff --git a/src/StdLib/Lib/lib2to3/tests/test_fixers.py b/src/extensions/StdLib/Lib/lib2to3/tests/test_fixers.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/test_fixers.py rename to src/extensions/StdLib/Lib/lib2to3/tests/test_fixers.py diff --git a/src/StdLib/Lib/lib2to3/tests/test_main.py b/src/extensions/StdLib/Lib/lib2to3/tests/test_main.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/test_main.py rename to src/extensions/StdLib/Lib/lib2to3/tests/test_main.py diff --git a/src/StdLib/Lib/lib2to3/tests/test_parser.py b/src/extensions/StdLib/Lib/lib2to3/tests/test_parser.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/test_parser.py rename to src/extensions/StdLib/Lib/lib2to3/tests/test_parser.py diff --git a/src/StdLib/Lib/lib2to3/tests/test_pytree.py b/src/extensions/StdLib/Lib/lib2to3/tests/test_pytree.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/test_pytree.py rename to src/extensions/StdLib/Lib/lib2to3/tests/test_pytree.py diff --git a/src/StdLib/Lib/lib2to3/tests/test_refactor.py b/src/extensions/StdLib/Lib/lib2to3/tests/test_refactor.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/test_refactor.py rename to src/extensions/StdLib/Lib/lib2to3/tests/test_refactor.py diff --git a/src/StdLib/Lib/lib2to3/tests/test_util.py b/src/extensions/StdLib/Lib/lib2to3/tests/test_util.py similarity index 100% rename from src/StdLib/Lib/lib2to3/tests/test_util.py rename to src/extensions/StdLib/Lib/lib2to3/tests/test_util.py diff --git a/src/StdLib/Lib/linecache.py b/src/extensions/StdLib/Lib/linecache.py similarity index 100% rename from src/StdLib/Lib/linecache.py rename to src/extensions/StdLib/Lib/linecache.py diff --git a/src/StdLib/Lib/locale.py b/src/extensions/StdLib/Lib/locale.py similarity index 100% rename from src/StdLib/Lib/locale.py rename to src/extensions/StdLib/Lib/locale.py diff --git a/src/StdLib/Lib/logging/__init__.py b/src/extensions/StdLib/Lib/logging/__init__.py similarity index 100% rename from src/StdLib/Lib/logging/__init__.py rename to src/extensions/StdLib/Lib/logging/__init__.py diff --git a/src/StdLib/Lib/logging/config.py b/src/extensions/StdLib/Lib/logging/config.py similarity index 100% rename from src/StdLib/Lib/logging/config.py rename to src/extensions/StdLib/Lib/logging/config.py diff --git a/src/StdLib/Lib/logging/handlers.py b/src/extensions/StdLib/Lib/logging/handlers.py similarity index 100% rename from src/StdLib/Lib/logging/handlers.py rename to src/extensions/StdLib/Lib/logging/handlers.py diff --git a/src/StdLib/Lib/lzma.py b/src/extensions/StdLib/Lib/lzma.py similarity index 100% rename from src/StdLib/Lib/lzma.py rename to src/extensions/StdLib/Lib/lzma.py diff --git a/src/StdLib/Lib/macpath.py b/src/extensions/StdLib/Lib/macpath.py similarity index 100% rename from src/StdLib/Lib/macpath.py rename to src/extensions/StdLib/Lib/macpath.py diff --git a/src/StdLib/Lib/macurl2path.py b/src/extensions/StdLib/Lib/macurl2path.py similarity index 100% rename from src/StdLib/Lib/macurl2path.py rename to src/extensions/StdLib/Lib/macurl2path.py diff --git a/src/StdLib/Lib/mailbox.py b/src/extensions/StdLib/Lib/mailbox.py similarity index 100% rename from src/StdLib/Lib/mailbox.py rename to src/extensions/StdLib/Lib/mailbox.py diff --git a/src/StdLib/Lib/mailcap.py b/src/extensions/StdLib/Lib/mailcap.py similarity index 100% rename from src/StdLib/Lib/mailcap.py rename to src/extensions/StdLib/Lib/mailcap.py diff --git a/src/StdLib/Lib/mimetypes.py b/src/extensions/StdLib/Lib/mimetypes.py similarity index 100% rename from src/StdLib/Lib/mimetypes.py rename to src/extensions/StdLib/Lib/mimetypes.py diff --git a/src/StdLib/Lib/modulefinder.py b/src/extensions/StdLib/Lib/modulefinder.py similarity index 100% rename from src/StdLib/Lib/modulefinder.py rename to src/extensions/StdLib/Lib/modulefinder.py diff --git a/src/StdLib/Lib/msilib/__init__.py b/src/extensions/StdLib/Lib/msilib/__init__.py similarity index 100% rename from src/StdLib/Lib/msilib/__init__.py rename to src/extensions/StdLib/Lib/msilib/__init__.py diff --git a/src/StdLib/Lib/msilib/schema.py b/src/extensions/StdLib/Lib/msilib/schema.py similarity index 100% rename from src/StdLib/Lib/msilib/schema.py rename to src/extensions/StdLib/Lib/msilib/schema.py diff --git a/src/StdLib/Lib/msilib/sequence.py b/src/extensions/StdLib/Lib/msilib/sequence.py similarity index 100% rename from src/StdLib/Lib/msilib/sequence.py rename to src/extensions/StdLib/Lib/msilib/sequence.py diff --git a/src/StdLib/Lib/msilib/text.py b/src/extensions/StdLib/Lib/msilib/text.py similarity index 100% rename from src/StdLib/Lib/msilib/text.py rename to src/extensions/StdLib/Lib/msilib/text.py diff --git a/src/StdLib/Lib/multiprocessing/__init__.py b/src/extensions/StdLib/Lib/multiprocessing/__init__.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/__init__.py rename to src/extensions/StdLib/Lib/multiprocessing/__init__.py diff --git a/src/StdLib/Lib/multiprocessing/connection.py b/src/extensions/StdLib/Lib/multiprocessing/connection.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/connection.py rename to src/extensions/StdLib/Lib/multiprocessing/connection.py diff --git a/src/StdLib/Lib/multiprocessing/context.py b/src/extensions/StdLib/Lib/multiprocessing/context.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/context.py rename to src/extensions/StdLib/Lib/multiprocessing/context.py diff --git a/src/StdLib/Lib/multiprocessing/dummy/__init__.py b/src/extensions/StdLib/Lib/multiprocessing/dummy/__init__.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/dummy/__init__.py rename to src/extensions/StdLib/Lib/multiprocessing/dummy/__init__.py diff --git a/src/StdLib/Lib/multiprocessing/dummy/connection.py b/src/extensions/StdLib/Lib/multiprocessing/dummy/connection.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/dummy/connection.py rename to src/extensions/StdLib/Lib/multiprocessing/dummy/connection.py diff --git a/src/StdLib/Lib/multiprocessing/forkserver.py b/src/extensions/StdLib/Lib/multiprocessing/forkserver.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/forkserver.py rename to src/extensions/StdLib/Lib/multiprocessing/forkserver.py diff --git a/src/StdLib/Lib/multiprocessing/heap.py b/src/extensions/StdLib/Lib/multiprocessing/heap.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/heap.py rename to src/extensions/StdLib/Lib/multiprocessing/heap.py diff --git a/src/StdLib/Lib/multiprocessing/managers.py b/src/extensions/StdLib/Lib/multiprocessing/managers.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/managers.py rename to src/extensions/StdLib/Lib/multiprocessing/managers.py diff --git a/src/StdLib/Lib/multiprocessing/pool.py b/src/extensions/StdLib/Lib/multiprocessing/pool.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/pool.py rename to src/extensions/StdLib/Lib/multiprocessing/pool.py diff --git a/src/StdLib/Lib/multiprocessing/popen_fork.py b/src/extensions/StdLib/Lib/multiprocessing/popen_fork.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/popen_fork.py rename to src/extensions/StdLib/Lib/multiprocessing/popen_fork.py diff --git a/src/StdLib/Lib/multiprocessing/popen_forkserver.py b/src/extensions/StdLib/Lib/multiprocessing/popen_forkserver.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/popen_forkserver.py rename to src/extensions/StdLib/Lib/multiprocessing/popen_forkserver.py diff --git a/src/StdLib/Lib/multiprocessing/popen_spawn_posix.py b/src/extensions/StdLib/Lib/multiprocessing/popen_spawn_posix.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/popen_spawn_posix.py rename to src/extensions/StdLib/Lib/multiprocessing/popen_spawn_posix.py diff --git a/src/StdLib/Lib/multiprocessing/popen_spawn_win32.py b/src/extensions/StdLib/Lib/multiprocessing/popen_spawn_win32.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/popen_spawn_win32.py rename to src/extensions/StdLib/Lib/multiprocessing/popen_spawn_win32.py diff --git a/src/StdLib/Lib/multiprocessing/process.py b/src/extensions/StdLib/Lib/multiprocessing/process.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/process.py rename to src/extensions/StdLib/Lib/multiprocessing/process.py diff --git a/src/StdLib/Lib/multiprocessing/queues.py b/src/extensions/StdLib/Lib/multiprocessing/queues.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/queues.py rename to src/extensions/StdLib/Lib/multiprocessing/queues.py diff --git a/src/StdLib/Lib/multiprocessing/reduction.py b/src/extensions/StdLib/Lib/multiprocessing/reduction.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/reduction.py rename to src/extensions/StdLib/Lib/multiprocessing/reduction.py diff --git a/src/StdLib/Lib/multiprocessing/resource_sharer.py b/src/extensions/StdLib/Lib/multiprocessing/resource_sharer.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/resource_sharer.py rename to src/extensions/StdLib/Lib/multiprocessing/resource_sharer.py diff --git a/src/StdLib/Lib/multiprocessing/semaphore_tracker.py b/src/extensions/StdLib/Lib/multiprocessing/semaphore_tracker.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/semaphore_tracker.py rename to src/extensions/StdLib/Lib/multiprocessing/semaphore_tracker.py diff --git a/src/StdLib/Lib/multiprocessing/sharedctypes.py b/src/extensions/StdLib/Lib/multiprocessing/sharedctypes.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/sharedctypes.py rename to src/extensions/StdLib/Lib/multiprocessing/sharedctypes.py diff --git a/src/StdLib/Lib/multiprocessing/spawn.py b/src/extensions/StdLib/Lib/multiprocessing/spawn.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/spawn.py rename to src/extensions/StdLib/Lib/multiprocessing/spawn.py diff --git a/src/StdLib/Lib/multiprocessing/synchronize.py b/src/extensions/StdLib/Lib/multiprocessing/synchronize.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/synchronize.py rename to src/extensions/StdLib/Lib/multiprocessing/synchronize.py diff --git a/src/StdLib/Lib/multiprocessing/util.py b/src/extensions/StdLib/Lib/multiprocessing/util.py similarity index 100% rename from src/StdLib/Lib/multiprocessing/util.py rename to src/extensions/StdLib/Lib/multiprocessing/util.py diff --git a/src/StdLib/Lib/netrc.py b/src/extensions/StdLib/Lib/netrc.py similarity index 100% rename from src/StdLib/Lib/netrc.py rename to src/extensions/StdLib/Lib/netrc.py diff --git a/src/StdLib/Lib/nntplib.py b/src/extensions/StdLib/Lib/nntplib.py similarity index 100% rename from src/StdLib/Lib/nntplib.py rename to src/extensions/StdLib/Lib/nntplib.py diff --git a/src/StdLib/Lib/ntpath.py b/src/extensions/StdLib/Lib/ntpath.py similarity index 100% rename from src/StdLib/Lib/ntpath.py rename to src/extensions/StdLib/Lib/ntpath.py diff --git a/src/StdLib/Lib/nturl2path.py b/src/extensions/StdLib/Lib/nturl2path.py similarity index 100% rename from src/StdLib/Lib/nturl2path.py rename to src/extensions/StdLib/Lib/nturl2path.py diff --git a/src/StdLib/Lib/numbers.py b/src/extensions/StdLib/Lib/numbers.py similarity index 100% rename from src/StdLib/Lib/numbers.py rename to src/extensions/StdLib/Lib/numbers.py diff --git a/src/StdLib/Lib/opcode.py b/src/extensions/StdLib/Lib/opcode.py similarity index 100% rename from src/StdLib/Lib/opcode.py rename to src/extensions/StdLib/Lib/opcode.py diff --git a/src/StdLib/Lib/operator.py b/src/extensions/StdLib/Lib/operator.py similarity index 100% rename from src/StdLib/Lib/operator.py rename to src/extensions/StdLib/Lib/operator.py diff --git a/src/StdLib/Lib/optparse.py b/src/extensions/StdLib/Lib/optparse.py similarity index 100% rename from src/StdLib/Lib/optparse.py rename to src/extensions/StdLib/Lib/optparse.py diff --git a/src/StdLib/Lib/os.py b/src/extensions/StdLib/Lib/os.py similarity index 100% rename from src/StdLib/Lib/os.py rename to src/extensions/StdLib/Lib/os.py diff --git a/src/StdLib/Lib/pathlib.py b/src/extensions/StdLib/Lib/pathlib.py similarity index 100% rename from src/StdLib/Lib/pathlib.py rename to src/extensions/StdLib/Lib/pathlib.py diff --git a/src/StdLib/Lib/pdb.py b/src/extensions/StdLib/Lib/pdb.py similarity index 100% rename from src/StdLib/Lib/pdb.py rename to src/extensions/StdLib/Lib/pdb.py diff --git a/src/StdLib/Lib/pickle.py b/src/extensions/StdLib/Lib/pickle.py similarity index 100% rename from src/StdLib/Lib/pickle.py rename to src/extensions/StdLib/Lib/pickle.py diff --git a/src/StdLib/Lib/pickletools.py b/src/extensions/StdLib/Lib/pickletools.py similarity index 100% rename from src/StdLib/Lib/pickletools.py rename to src/extensions/StdLib/Lib/pickletools.py diff --git a/src/StdLib/Lib/pipes.py b/src/extensions/StdLib/Lib/pipes.py similarity index 100% rename from src/StdLib/Lib/pipes.py rename to src/extensions/StdLib/Lib/pipes.py diff --git a/src/StdLib/Lib/pkgutil.py b/src/extensions/StdLib/Lib/pkgutil.py similarity index 100% rename from src/StdLib/Lib/pkgutil.py rename to src/extensions/StdLib/Lib/pkgutil.py diff --git a/src/StdLib/Lib/platform.py b/src/extensions/StdLib/Lib/platform.py similarity index 100% rename from src/StdLib/Lib/platform.py rename to src/extensions/StdLib/Lib/platform.py diff --git a/src/StdLib/Lib/plistlib.py b/src/extensions/StdLib/Lib/plistlib.py similarity index 100% rename from src/StdLib/Lib/plistlib.py rename to src/extensions/StdLib/Lib/plistlib.py diff --git a/src/StdLib/Lib/poplib.py b/src/extensions/StdLib/Lib/poplib.py similarity index 100% rename from src/StdLib/Lib/poplib.py rename to src/extensions/StdLib/Lib/poplib.py diff --git a/src/StdLib/Lib/posixpath.py b/src/extensions/StdLib/Lib/posixpath.py similarity index 100% rename from src/StdLib/Lib/posixpath.py rename to src/extensions/StdLib/Lib/posixpath.py diff --git a/src/StdLib/Lib/pprint.py b/src/extensions/StdLib/Lib/pprint.py similarity index 100% rename from src/StdLib/Lib/pprint.py rename to src/extensions/StdLib/Lib/pprint.py diff --git a/src/StdLib/Lib/profile.py b/src/extensions/StdLib/Lib/profile.py similarity index 100% rename from src/StdLib/Lib/profile.py rename to src/extensions/StdLib/Lib/profile.py diff --git a/src/StdLib/Lib/pstats.py b/src/extensions/StdLib/Lib/pstats.py similarity index 100% rename from src/StdLib/Lib/pstats.py rename to src/extensions/StdLib/Lib/pstats.py diff --git a/src/StdLib/Lib/pty.py b/src/extensions/StdLib/Lib/pty.py similarity index 100% rename from src/StdLib/Lib/pty.py rename to src/extensions/StdLib/Lib/pty.py diff --git a/src/StdLib/Lib/py_compile.py b/src/extensions/StdLib/Lib/py_compile.py similarity index 100% rename from src/StdLib/Lib/py_compile.py rename to src/extensions/StdLib/Lib/py_compile.py diff --git a/src/StdLib/Lib/pyclbr.py b/src/extensions/StdLib/Lib/pyclbr.py similarity index 100% rename from src/StdLib/Lib/pyclbr.py rename to src/extensions/StdLib/Lib/pyclbr.py diff --git a/src/StdLib/Lib/pydoc.py b/src/extensions/StdLib/Lib/pydoc.py similarity index 100% rename from src/StdLib/Lib/pydoc.py rename to src/extensions/StdLib/Lib/pydoc.py diff --git a/src/StdLib/Lib/pydoc_data/__init__.py b/src/extensions/StdLib/Lib/pydoc_data/__init__.py similarity index 100% rename from src/StdLib/Lib/pydoc_data/__init__.py rename to src/extensions/StdLib/Lib/pydoc_data/__init__.py diff --git a/src/StdLib/Lib/pydoc_data/_pydoc.css b/src/extensions/StdLib/Lib/pydoc_data/_pydoc.css similarity index 100% rename from src/StdLib/Lib/pydoc_data/_pydoc.css rename to src/extensions/StdLib/Lib/pydoc_data/_pydoc.css diff --git a/src/StdLib/Lib/pydoc_data/topics.py b/src/extensions/StdLib/Lib/pydoc_data/topics.py similarity index 100% rename from src/StdLib/Lib/pydoc_data/topics.py rename to src/extensions/StdLib/Lib/pydoc_data/topics.py diff --git a/src/StdLib/Lib/queue.py b/src/extensions/StdLib/Lib/queue.py similarity index 100% rename from src/StdLib/Lib/queue.py rename to src/extensions/StdLib/Lib/queue.py diff --git a/src/StdLib/Lib/quopri.py b/src/extensions/StdLib/Lib/quopri.py similarity index 100% rename from src/StdLib/Lib/quopri.py rename to src/extensions/StdLib/Lib/quopri.py diff --git a/src/StdLib/Lib/random.py b/src/extensions/StdLib/Lib/random.py similarity index 100% rename from src/StdLib/Lib/random.py rename to src/extensions/StdLib/Lib/random.py diff --git a/src/StdLib/Lib/re.py b/src/extensions/StdLib/Lib/re.py similarity index 100% rename from src/StdLib/Lib/re.py rename to src/extensions/StdLib/Lib/re.py diff --git a/src/StdLib/Lib/reprlib.py b/src/extensions/StdLib/Lib/reprlib.py similarity index 100% rename from src/StdLib/Lib/reprlib.py rename to src/extensions/StdLib/Lib/reprlib.py diff --git a/src/StdLib/Lib/rlcompleter.py b/src/extensions/StdLib/Lib/rlcompleter.py similarity index 100% rename from src/StdLib/Lib/rlcompleter.py rename to src/extensions/StdLib/Lib/rlcompleter.py diff --git a/src/StdLib/Lib/runpy.py b/src/extensions/StdLib/Lib/runpy.py similarity index 100% rename from src/StdLib/Lib/runpy.py rename to src/extensions/StdLib/Lib/runpy.py diff --git a/src/StdLib/Lib/sched.py b/src/extensions/StdLib/Lib/sched.py similarity index 100% rename from src/StdLib/Lib/sched.py rename to src/extensions/StdLib/Lib/sched.py diff --git a/src/StdLib/Lib/selectors.py b/src/extensions/StdLib/Lib/selectors.py similarity index 100% rename from src/StdLib/Lib/selectors.py rename to src/extensions/StdLib/Lib/selectors.py diff --git a/src/StdLib/Lib/shelve.py b/src/extensions/StdLib/Lib/shelve.py similarity index 100% rename from src/StdLib/Lib/shelve.py rename to src/extensions/StdLib/Lib/shelve.py diff --git a/src/StdLib/Lib/shlex.py b/src/extensions/StdLib/Lib/shlex.py similarity index 100% rename from src/StdLib/Lib/shlex.py rename to src/extensions/StdLib/Lib/shlex.py diff --git a/src/StdLib/Lib/shutil.py b/src/extensions/StdLib/Lib/shutil.py similarity index 100% rename from src/StdLib/Lib/shutil.py rename to src/extensions/StdLib/Lib/shutil.py diff --git a/src/StdLib/Lib/site-packages/README b/src/extensions/StdLib/Lib/site-packages/README similarity index 100% rename from src/StdLib/Lib/site-packages/README rename to src/extensions/StdLib/Lib/site-packages/README diff --git a/src/StdLib/Lib/site.py b/src/extensions/StdLib/Lib/site.py similarity index 100% rename from src/StdLib/Lib/site.py rename to src/extensions/StdLib/Lib/site.py diff --git a/src/StdLib/Lib/smtpd.py b/src/extensions/StdLib/Lib/smtpd.py similarity index 100% rename from src/StdLib/Lib/smtpd.py rename to src/extensions/StdLib/Lib/smtpd.py diff --git a/src/StdLib/Lib/smtplib.py b/src/extensions/StdLib/Lib/smtplib.py similarity index 100% rename from src/StdLib/Lib/smtplib.py rename to src/extensions/StdLib/Lib/smtplib.py diff --git a/src/StdLib/Lib/sndhdr.py b/src/extensions/StdLib/Lib/sndhdr.py similarity index 100% rename from src/StdLib/Lib/sndhdr.py rename to src/extensions/StdLib/Lib/sndhdr.py diff --git a/src/StdLib/Lib/socket.py b/src/extensions/StdLib/Lib/socket.py similarity index 100% rename from src/StdLib/Lib/socket.py rename to src/extensions/StdLib/Lib/socket.py diff --git a/src/StdLib/Lib/socketserver.py b/src/extensions/StdLib/Lib/socketserver.py similarity index 100% rename from src/StdLib/Lib/socketserver.py rename to src/extensions/StdLib/Lib/socketserver.py diff --git a/src/StdLib/Lib/sqlite3/__init__.py b/src/extensions/StdLib/Lib/sqlite3/__init__.py similarity index 100% rename from src/StdLib/Lib/sqlite3/__init__.py rename to src/extensions/StdLib/Lib/sqlite3/__init__.py diff --git a/src/StdLib/Lib/sqlite3/dbapi2.py b/src/extensions/StdLib/Lib/sqlite3/dbapi2.py similarity index 100% rename from src/StdLib/Lib/sqlite3/dbapi2.py rename to src/extensions/StdLib/Lib/sqlite3/dbapi2.py diff --git a/src/StdLib/Lib/sqlite3/dump.py b/src/extensions/StdLib/Lib/sqlite3/dump.py similarity index 100% rename from src/StdLib/Lib/sqlite3/dump.py rename to src/extensions/StdLib/Lib/sqlite3/dump.py diff --git a/src/StdLib/Lib/sqlite3/test/__init__.py b/src/extensions/StdLib/Lib/sqlite3/test/__init__.py similarity index 100% rename from src/StdLib/Lib/sqlite3/test/__init__.py rename to src/extensions/StdLib/Lib/sqlite3/test/__init__.py diff --git a/src/StdLib/Lib/sqlite3/test/dbapi.py b/src/extensions/StdLib/Lib/sqlite3/test/dbapi.py similarity index 100% rename from src/StdLib/Lib/sqlite3/test/dbapi.py rename to src/extensions/StdLib/Lib/sqlite3/test/dbapi.py diff --git a/src/StdLib/Lib/sqlite3/test/dump.py b/src/extensions/StdLib/Lib/sqlite3/test/dump.py similarity index 100% rename from src/StdLib/Lib/sqlite3/test/dump.py rename to src/extensions/StdLib/Lib/sqlite3/test/dump.py diff --git a/src/StdLib/Lib/sqlite3/test/factory.py b/src/extensions/StdLib/Lib/sqlite3/test/factory.py similarity index 100% rename from src/StdLib/Lib/sqlite3/test/factory.py rename to src/extensions/StdLib/Lib/sqlite3/test/factory.py diff --git a/src/StdLib/Lib/sqlite3/test/hooks.py b/src/extensions/StdLib/Lib/sqlite3/test/hooks.py similarity index 100% rename from src/StdLib/Lib/sqlite3/test/hooks.py rename to src/extensions/StdLib/Lib/sqlite3/test/hooks.py diff --git a/src/StdLib/Lib/sqlite3/test/regression.py b/src/extensions/StdLib/Lib/sqlite3/test/regression.py similarity index 100% rename from src/StdLib/Lib/sqlite3/test/regression.py rename to src/extensions/StdLib/Lib/sqlite3/test/regression.py diff --git a/src/StdLib/Lib/sqlite3/test/transactions.py b/src/extensions/StdLib/Lib/sqlite3/test/transactions.py similarity index 100% rename from src/StdLib/Lib/sqlite3/test/transactions.py rename to src/extensions/StdLib/Lib/sqlite3/test/transactions.py diff --git a/src/StdLib/Lib/sqlite3/test/types.py b/src/extensions/StdLib/Lib/sqlite3/test/types.py similarity index 100% rename from src/StdLib/Lib/sqlite3/test/types.py rename to src/extensions/StdLib/Lib/sqlite3/test/types.py diff --git a/src/StdLib/Lib/sqlite3/test/userfunctions.py b/src/extensions/StdLib/Lib/sqlite3/test/userfunctions.py similarity index 100% rename from src/StdLib/Lib/sqlite3/test/userfunctions.py rename to src/extensions/StdLib/Lib/sqlite3/test/userfunctions.py diff --git a/src/StdLib/Lib/sre_compile.py b/src/extensions/StdLib/Lib/sre_compile.py similarity index 100% rename from src/StdLib/Lib/sre_compile.py rename to src/extensions/StdLib/Lib/sre_compile.py diff --git a/src/StdLib/Lib/sre_constants.py b/src/extensions/StdLib/Lib/sre_constants.py similarity index 100% rename from src/StdLib/Lib/sre_constants.py rename to src/extensions/StdLib/Lib/sre_constants.py diff --git a/src/StdLib/Lib/sre_parse.py b/src/extensions/StdLib/Lib/sre_parse.py similarity index 100% rename from src/StdLib/Lib/sre_parse.py rename to src/extensions/StdLib/Lib/sre_parse.py diff --git a/src/StdLib/Lib/ssl.py b/src/extensions/StdLib/Lib/ssl.py similarity index 100% rename from src/StdLib/Lib/ssl.py rename to src/extensions/StdLib/Lib/ssl.py diff --git a/src/StdLib/Lib/stat.py b/src/extensions/StdLib/Lib/stat.py similarity index 100% rename from src/StdLib/Lib/stat.py rename to src/extensions/StdLib/Lib/stat.py diff --git a/src/StdLib/Lib/statistics.py b/src/extensions/StdLib/Lib/statistics.py similarity index 100% rename from src/StdLib/Lib/statistics.py rename to src/extensions/StdLib/Lib/statistics.py diff --git a/src/StdLib/Lib/string.py b/src/extensions/StdLib/Lib/string.py similarity index 100% rename from src/StdLib/Lib/string.py rename to src/extensions/StdLib/Lib/string.py diff --git a/src/StdLib/Lib/stringprep.py b/src/extensions/StdLib/Lib/stringprep.py similarity index 100% rename from src/StdLib/Lib/stringprep.py rename to src/extensions/StdLib/Lib/stringprep.py diff --git a/src/StdLib/Lib/struct.py b/src/extensions/StdLib/Lib/struct.py similarity index 100% rename from src/StdLib/Lib/struct.py rename to src/extensions/StdLib/Lib/struct.py diff --git a/src/StdLib/Lib/subprocess.py b/src/extensions/StdLib/Lib/subprocess.py similarity index 100% rename from src/StdLib/Lib/subprocess.py rename to src/extensions/StdLib/Lib/subprocess.py diff --git a/src/StdLib/Lib/sunau.py b/src/extensions/StdLib/Lib/sunau.py similarity index 100% rename from src/StdLib/Lib/sunau.py rename to src/extensions/StdLib/Lib/sunau.py diff --git a/src/StdLib/Lib/symbol.py b/src/extensions/StdLib/Lib/symbol.py similarity index 100% rename from src/StdLib/Lib/symbol.py rename to src/extensions/StdLib/Lib/symbol.py diff --git a/src/StdLib/Lib/symtable.py b/src/extensions/StdLib/Lib/symtable.py similarity index 100% rename from src/StdLib/Lib/symtable.py rename to src/extensions/StdLib/Lib/symtable.py diff --git a/src/StdLib/Lib/sysconfig.py b/src/extensions/StdLib/Lib/sysconfig.py similarity index 100% rename from src/StdLib/Lib/sysconfig.py rename to src/extensions/StdLib/Lib/sysconfig.py diff --git a/src/StdLib/Lib/tabnanny.py b/src/extensions/StdLib/Lib/tabnanny.py similarity index 100% rename from src/StdLib/Lib/tabnanny.py rename to src/extensions/StdLib/Lib/tabnanny.py diff --git a/src/StdLib/Lib/tarfile.py b/src/extensions/StdLib/Lib/tarfile.py similarity index 100% rename from src/StdLib/Lib/tarfile.py rename to src/extensions/StdLib/Lib/tarfile.py diff --git a/src/StdLib/Lib/telnetlib.py b/src/extensions/StdLib/Lib/telnetlib.py similarity index 100% rename from src/StdLib/Lib/telnetlib.py rename to src/extensions/StdLib/Lib/telnetlib.py diff --git a/src/StdLib/Lib/tempfile.py b/src/extensions/StdLib/Lib/tempfile.py similarity index 100% rename from src/StdLib/Lib/tempfile.py rename to src/extensions/StdLib/Lib/tempfile.py diff --git a/src/StdLib/Lib/test/185test.db b/src/extensions/StdLib/Lib/test/185test.db similarity index 100% rename from src/StdLib/Lib/test/185test.db rename to src/extensions/StdLib/Lib/test/185test.db diff --git a/src/StdLib/Lib/test/Sine-1000Hz-300ms.aif b/src/extensions/StdLib/Lib/test/Sine-1000Hz-300ms.aif similarity index 100% rename from src/StdLib/Lib/test/Sine-1000Hz-300ms.aif rename to src/extensions/StdLib/Lib/test/Sine-1000Hz-300ms.aif diff --git a/src/StdLib/Lib/test/__init__.py b/src/extensions/StdLib/Lib/test/__init__.py similarity index 100% rename from src/StdLib/Lib/test/__init__.py rename to src/extensions/StdLib/Lib/test/__init__.py diff --git a/src/StdLib/Lib/test/__main__.py b/src/extensions/StdLib/Lib/test/__main__.py similarity index 100% rename from src/StdLib/Lib/test/__main__.py rename to src/extensions/StdLib/Lib/test/__main__.py diff --git a/src/StdLib/Lib/test/_test_multiprocessing.py b/src/extensions/StdLib/Lib/test/_test_multiprocessing.py similarity index 100% rename from src/StdLib/Lib/test/_test_multiprocessing.py rename to src/extensions/StdLib/Lib/test/_test_multiprocessing.py diff --git a/src/StdLib/Lib/test/audiodata/pluck-alaw.aifc b/src/extensions/StdLib/Lib/test/audiodata/pluck-alaw.aifc similarity index 100% rename from src/StdLib/Lib/test/audiodata/pluck-alaw.aifc rename to src/extensions/StdLib/Lib/test/audiodata/pluck-alaw.aifc diff --git a/src/StdLib/Lib/test/audiodata/pluck-pcm16.aiff b/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm16.aiff similarity index 100% rename from src/StdLib/Lib/test/audiodata/pluck-pcm16.aiff rename to src/extensions/StdLib/Lib/test/audiodata/pluck-pcm16.aiff diff --git a/src/StdLib/Lib/test/audiodata/pluck-pcm16.au b/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm16.au similarity index 100% rename from src/StdLib/Lib/test/audiodata/pluck-pcm16.au rename to src/extensions/StdLib/Lib/test/audiodata/pluck-pcm16.au diff --git a/src/StdLib/Lib/test/audiodata/pluck-pcm16.wav b/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm16.wav similarity index 100% rename from src/StdLib/Lib/test/audiodata/pluck-pcm16.wav rename to src/extensions/StdLib/Lib/test/audiodata/pluck-pcm16.wav diff --git a/src/StdLib/Lib/test/audiodata/pluck-pcm24.aiff b/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm24.aiff similarity index 100% rename from src/StdLib/Lib/test/audiodata/pluck-pcm24.aiff rename to src/extensions/StdLib/Lib/test/audiodata/pluck-pcm24.aiff diff --git a/src/StdLib/Lib/test/audiodata/pluck-pcm24.au b/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm24.au similarity index 100% rename from src/StdLib/Lib/test/audiodata/pluck-pcm24.au rename to src/extensions/StdLib/Lib/test/audiodata/pluck-pcm24.au diff --git a/src/StdLib/Lib/test/audiodata/pluck-pcm24.wav b/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm24.wav similarity index 100% rename from src/StdLib/Lib/test/audiodata/pluck-pcm24.wav rename to src/extensions/StdLib/Lib/test/audiodata/pluck-pcm24.wav diff --git a/src/StdLib/Lib/test/audiodata/pluck-pcm32.aiff b/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm32.aiff similarity index 100% rename from src/StdLib/Lib/test/audiodata/pluck-pcm32.aiff rename to src/extensions/StdLib/Lib/test/audiodata/pluck-pcm32.aiff diff --git a/src/StdLib/Lib/test/audiodata/pluck-pcm32.au b/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm32.au similarity index 100% rename from src/StdLib/Lib/test/audiodata/pluck-pcm32.au rename to src/extensions/StdLib/Lib/test/audiodata/pluck-pcm32.au diff --git a/src/StdLib/Lib/test/audiodata/pluck-pcm32.wav b/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm32.wav similarity index 100% rename from src/StdLib/Lib/test/audiodata/pluck-pcm32.wav rename to src/extensions/StdLib/Lib/test/audiodata/pluck-pcm32.wav diff --git a/src/StdLib/Lib/test/audiodata/pluck-pcm8.aiff b/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm8.aiff similarity index 100% rename from src/StdLib/Lib/test/audiodata/pluck-pcm8.aiff rename to src/extensions/StdLib/Lib/test/audiodata/pluck-pcm8.aiff diff --git a/src/StdLib/Lib/test/audiodata/pluck-pcm8.au b/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm8.au similarity index 100% rename from src/StdLib/Lib/test/audiodata/pluck-pcm8.au rename to src/extensions/StdLib/Lib/test/audiodata/pluck-pcm8.au diff --git a/src/StdLib/Lib/test/audiodata/pluck-pcm8.wav b/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm8.wav similarity index 100% rename from src/StdLib/Lib/test/audiodata/pluck-pcm8.wav rename to src/extensions/StdLib/Lib/test/audiodata/pluck-pcm8.wav diff --git a/src/StdLib/Lib/test/audiodata/pluck-ulaw.aifc b/src/extensions/StdLib/Lib/test/audiodata/pluck-ulaw.aifc similarity index 100% rename from src/StdLib/Lib/test/audiodata/pluck-ulaw.aifc rename to src/extensions/StdLib/Lib/test/audiodata/pluck-ulaw.aifc diff --git a/src/StdLib/Lib/test/audiodata/pluck-ulaw.au b/src/extensions/StdLib/Lib/test/audiodata/pluck-ulaw.au similarity index 100% rename from src/StdLib/Lib/test/audiodata/pluck-ulaw.au rename to src/extensions/StdLib/Lib/test/audiodata/pluck-ulaw.au diff --git a/src/StdLib/Lib/test/audiotest.au b/src/extensions/StdLib/Lib/test/audiotest.au similarity index 100% rename from src/StdLib/Lib/test/audiotest.au rename to src/extensions/StdLib/Lib/test/audiotest.au diff --git a/src/StdLib/Lib/test/audiotests.py b/src/extensions/StdLib/Lib/test/audiotests.py similarity index 100% rename from src/StdLib/Lib/test/audiotests.py rename to src/extensions/StdLib/Lib/test/audiotests.py diff --git a/src/StdLib/Lib/test/autotest.py b/src/extensions/StdLib/Lib/test/autotest.py similarity index 100% rename from src/StdLib/Lib/test/autotest.py rename to src/extensions/StdLib/Lib/test/autotest.py diff --git a/src/StdLib/Lib/test/bad_coding.py b/src/extensions/StdLib/Lib/test/bad_coding.py similarity index 100% rename from src/StdLib/Lib/test/bad_coding.py rename to src/extensions/StdLib/Lib/test/bad_coding.py diff --git a/src/StdLib/Lib/test/bad_coding2.py b/src/extensions/StdLib/Lib/test/bad_coding2.py similarity index 100% rename from src/StdLib/Lib/test/bad_coding2.py rename to src/extensions/StdLib/Lib/test/bad_coding2.py diff --git a/src/StdLib/Lib/test/badcert.pem b/src/extensions/StdLib/Lib/test/badcert.pem similarity index 100% rename from src/StdLib/Lib/test/badcert.pem rename to src/extensions/StdLib/Lib/test/badcert.pem diff --git a/src/StdLib/Lib/test/badkey.pem b/src/extensions/StdLib/Lib/test/badkey.pem similarity index 100% rename from src/StdLib/Lib/test/badkey.pem rename to src/extensions/StdLib/Lib/test/badkey.pem diff --git a/src/StdLib/Lib/test/badsyntax_3131.py b/src/extensions/StdLib/Lib/test/badsyntax_3131.py similarity index 100% rename from src/StdLib/Lib/test/badsyntax_3131.py rename to src/extensions/StdLib/Lib/test/badsyntax_3131.py diff --git a/src/StdLib/Lib/test/badsyntax_future10.py b/src/extensions/StdLib/Lib/test/badsyntax_future10.py similarity index 100% rename from src/StdLib/Lib/test/badsyntax_future10.py rename to src/extensions/StdLib/Lib/test/badsyntax_future10.py diff --git a/src/StdLib/Lib/test/badsyntax_future3.py b/src/extensions/StdLib/Lib/test/badsyntax_future3.py similarity index 100% rename from src/StdLib/Lib/test/badsyntax_future3.py rename to src/extensions/StdLib/Lib/test/badsyntax_future3.py diff --git a/src/StdLib/Lib/test/badsyntax_future4.py b/src/extensions/StdLib/Lib/test/badsyntax_future4.py similarity index 100% rename from src/StdLib/Lib/test/badsyntax_future4.py rename to src/extensions/StdLib/Lib/test/badsyntax_future4.py diff --git a/src/StdLib/Lib/test/badsyntax_future5.py b/src/extensions/StdLib/Lib/test/badsyntax_future5.py similarity index 100% rename from src/StdLib/Lib/test/badsyntax_future5.py rename to src/extensions/StdLib/Lib/test/badsyntax_future5.py diff --git a/src/StdLib/Lib/test/badsyntax_future6.py b/src/extensions/StdLib/Lib/test/badsyntax_future6.py similarity index 100% rename from src/StdLib/Lib/test/badsyntax_future6.py rename to src/extensions/StdLib/Lib/test/badsyntax_future6.py diff --git a/src/StdLib/Lib/test/badsyntax_future7.py b/src/extensions/StdLib/Lib/test/badsyntax_future7.py similarity index 100% rename from src/StdLib/Lib/test/badsyntax_future7.py rename to src/extensions/StdLib/Lib/test/badsyntax_future7.py diff --git a/src/StdLib/Lib/test/badsyntax_future8.py b/src/extensions/StdLib/Lib/test/badsyntax_future8.py similarity index 100% rename from src/StdLib/Lib/test/badsyntax_future8.py rename to src/extensions/StdLib/Lib/test/badsyntax_future8.py diff --git a/src/StdLib/Lib/test/badsyntax_future9.py b/src/extensions/StdLib/Lib/test/badsyntax_future9.py similarity index 100% rename from src/StdLib/Lib/test/badsyntax_future9.py rename to src/extensions/StdLib/Lib/test/badsyntax_future9.py diff --git a/src/StdLib/Lib/test/badsyntax_pep3120.py b/src/extensions/StdLib/Lib/test/badsyntax_pep3120.py similarity index 100% rename from src/StdLib/Lib/test/badsyntax_pep3120.py rename to src/extensions/StdLib/Lib/test/badsyntax_pep3120.py diff --git a/src/StdLib/Lib/test/buffer_tests.py b/src/extensions/StdLib/Lib/test/buffer_tests.py similarity index 100% rename from src/StdLib/Lib/test/buffer_tests.py rename to src/extensions/StdLib/Lib/test/buffer_tests.py diff --git a/src/StdLib/Lib/test/bytecode_helper.py b/src/extensions/StdLib/Lib/test/bytecode_helper.py similarity index 100% rename from src/StdLib/Lib/test/bytecode_helper.py rename to src/extensions/StdLib/Lib/test/bytecode_helper.py diff --git a/src/StdLib/Lib/test/capath/0e4015b9.0 b/src/extensions/StdLib/Lib/test/capath/0e4015b9.0 similarity index 100% rename from src/StdLib/Lib/test/capath/0e4015b9.0 rename to src/extensions/StdLib/Lib/test/capath/0e4015b9.0 diff --git a/src/StdLib/Lib/test/capath/4e1295a3.0 b/src/extensions/StdLib/Lib/test/capath/4e1295a3.0 similarity index 100% rename from src/StdLib/Lib/test/capath/4e1295a3.0 rename to src/extensions/StdLib/Lib/test/capath/4e1295a3.0 diff --git a/src/StdLib/Lib/test/capath/5ed36f99.0 b/src/extensions/StdLib/Lib/test/capath/5ed36f99.0 similarity index 100% rename from src/StdLib/Lib/test/capath/5ed36f99.0 rename to src/extensions/StdLib/Lib/test/capath/5ed36f99.0 diff --git a/src/StdLib/Lib/test/capath/6e88d7b8.0 b/src/extensions/StdLib/Lib/test/capath/6e88d7b8.0 similarity index 100% rename from src/StdLib/Lib/test/capath/6e88d7b8.0 rename to src/extensions/StdLib/Lib/test/capath/6e88d7b8.0 diff --git a/src/StdLib/Lib/test/capath/99d0fa06.0 b/src/extensions/StdLib/Lib/test/capath/99d0fa06.0 similarity index 100% rename from src/StdLib/Lib/test/capath/99d0fa06.0 rename to src/extensions/StdLib/Lib/test/capath/99d0fa06.0 diff --git a/src/StdLib/Lib/test/capath/ce7b8643.0 b/src/extensions/StdLib/Lib/test/capath/ce7b8643.0 similarity index 100% rename from src/StdLib/Lib/test/capath/ce7b8643.0 rename to src/extensions/StdLib/Lib/test/capath/ce7b8643.0 diff --git a/src/StdLib/Lib/test/cfgparser.1 b/src/extensions/StdLib/Lib/test/cfgparser.1 similarity index 100% rename from src/StdLib/Lib/test/cfgparser.1 rename to src/extensions/StdLib/Lib/test/cfgparser.1 diff --git a/src/StdLib/Lib/test/cfgparser.2 b/src/extensions/StdLib/Lib/test/cfgparser.2 similarity index 100% rename from src/StdLib/Lib/test/cfgparser.2 rename to src/extensions/StdLib/Lib/test/cfgparser.2 diff --git a/src/StdLib/Lib/test/cfgparser.3 b/src/extensions/StdLib/Lib/test/cfgparser.3 similarity index 100% rename from src/StdLib/Lib/test/cfgparser.3 rename to src/extensions/StdLib/Lib/test/cfgparser.3 diff --git a/src/StdLib/Lib/test/check_soundcard.vbs b/src/extensions/StdLib/Lib/test/check_soundcard.vbs similarity index 100% rename from src/StdLib/Lib/test/check_soundcard.vbs rename to src/extensions/StdLib/Lib/test/check_soundcard.vbs diff --git a/src/StdLib/Lib/test/cjkencodings/big5-utf8.txt b/src/extensions/StdLib/Lib/test/cjkencodings/big5-utf8.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/big5-utf8.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/big5-utf8.txt diff --git a/src/StdLib/Lib/test/cjkencodings/big5.txt b/src/extensions/StdLib/Lib/test/cjkencodings/big5.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/big5.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/big5.txt diff --git a/src/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt b/src/extensions/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt diff --git a/src/StdLib/Lib/test/cjkencodings/big5hkscs.txt b/src/extensions/StdLib/Lib/test/cjkencodings/big5hkscs.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/big5hkscs.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/big5hkscs.txt diff --git a/src/StdLib/Lib/test/cjkencodings/cp949-utf8.txt b/src/extensions/StdLib/Lib/test/cjkencodings/cp949-utf8.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/cp949-utf8.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/cp949-utf8.txt diff --git a/src/StdLib/Lib/test/cjkencodings/cp949.txt b/src/extensions/StdLib/Lib/test/cjkencodings/cp949.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/cp949.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/cp949.txt diff --git a/src/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt b/src/extensions/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt diff --git a/src/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt b/src/extensions/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt diff --git a/src/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt b/src/extensions/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt diff --git a/src/StdLib/Lib/test/cjkencodings/euc_jp.txt b/src/extensions/StdLib/Lib/test/cjkencodings/euc_jp.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/euc_jp.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/euc_jp.txt diff --git a/src/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt b/src/extensions/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt diff --git a/src/StdLib/Lib/test/cjkencodings/euc_kr.txt b/src/extensions/StdLib/Lib/test/cjkencodings/euc_kr.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/euc_kr.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/euc_kr.txt diff --git a/src/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt b/src/extensions/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt diff --git a/src/StdLib/Lib/test/cjkencodings/gb18030.txt b/src/extensions/StdLib/Lib/test/cjkencodings/gb18030.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/gb18030.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/gb18030.txt diff --git a/src/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt b/src/extensions/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt diff --git a/src/StdLib/Lib/test/cjkencodings/gb2312.txt b/src/extensions/StdLib/Lib/test/cjkencodings/gb2312.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/gb2312.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/gb2312.txt diff --git a/src/StdLib/Lib/test/cjkencodings/gbk-utf8.txt b/src/extensions/StdLib/Lib/test/cjkencodings/gbk-utf8.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/gbk-utf8.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/gbk-utf8.txt diff --git a/src/StdLib/Lib/test/cjkencodings/gbk.txt b/src/extensions/StdLib/Lib/test/cjkencodings/gbk.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/gbk.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/gbk.txt diff --git a/src/StdLib/Lib/test/cjkencodings/hz-utf8.txt b/src/extensions/StdLib/Lib/test/cjkencodings/hz-utf8.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/hz-utf8.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/hz-utf8.txt diff --git a/src/StdLib/Lib/test/cjkencodings/hz.txt b/src/extensions/StdLib/Lib/test/cjkencodings/hz.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/hz.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/hz.txt diff --git a/src/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt b/src/extensions/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt diff --git a/src/StdLib/Lib/test/cjkencodings/iso2022_jp.txt b/src/extensions/StdLib/Lib/test/cjkencodings/iso2022_jp.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/iso2022_jp.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/iso2022_jp.txt diff --git a/src/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt b/src/extensions/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt diff --git a/src/StdLib/Lib/test/cjkencodings/iso2022_kr.txt b/src/extensions/StdLib/Lib/test/cjkencodings/iso2022_kr.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/iso2022_kr.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/iso2022_kr.txt diff --git a/src/StdLib/Lib/test/cjkencodings/johab-utf8.txt b/src/extensions/StdLib/Lib/test/cjkencodings/johab-utf8.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/johab-utf8.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/johab-utf8.txt diff --git a/src/StdLib/Lib/test/cjkencodings/johab.txt b/src/extensions/StdLib/Lib/test/cjkencodings/johab.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/johab.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/johab.txt diff --git a/src/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt b/src/extensions/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt diff --git a/src/StdLib/Lib/test/cjkencodings/shift_jis.txt b/src/extensions/StdLib/Lib/test/cjkencodings/shift_jis.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/shift_jis.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/shift_jis.txt diff --git a/src/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt b/src/extensions/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt diff --git a/src/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt b/src/extensions/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt similarity index 100% rename from src/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt rename to src/extensions/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt diff --git a/src/StdLib/Lib/test/cmath_testcases.txt b/src/extensions/StdLib/Lib/test/cmath_testcases.txt similarity index 100% rename from src/StdLib/Lib/test/cmath_testcases.txt rename to src/extensions/StdLib/Lib/test/cmath_testcases.txt diff --git a/src/StdLib/Lib/test/coding20731.py b/src/extensions/StdLib/Lib/test/coding20731.py similarity index 100% rename from src/StdLib/Lib/test/coding20731.py rename to src/extensions/StdLib/Lib/test/coding20731.py diff --git a/src/StdLib/Lib/test/crashers/README b/src/extensions/StdLib/Lib/test/crashers/README similarity index 100% rename from src/StdLib/Lib/test/crashers/README rename to src/extensions/StdLib/Lib/test/crashers/README diff --git a/src/StdLib/Lib/test/crashers/bogus_code_obj.py b/src/extensions/StdLib/Lib/test/crashers/bogus_code_obj.py similarity index 100% rename from src/StdLib/Lib/test/crashers/bogus_code_obj.py rename to src/extensions/StdLib/Lib/test/crashers/bogus_code_obj.py diff --git a/src/StdLib/Lib/test/crashers/gc_inspection.py b/src/extensions/StdLib/Lib/test/crashers/gc_inspection.py similarity index 100% rename from src/StdLib/Lib/test/crashers/gc_inspection.py rename to src/extensions/StdLib/Lib/test/crashers/gc_inspection.py diff --git a/src/StdLib/Lib/test/crashers/infinite_loop_re.py b/src/extensions/StdLib/Lib/test/crashers/infinite_loop_re.py similarity index 100% rename from src/StdLib/Lib/test/crashers/infinite_loop_re.py rename to src/extensions/StdLib/Lib/test/crashers/infinite_loop_re.py diff --git a/src/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py b/src/extensions/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py similarity index 100% rename from src/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py rename to src/extensions/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py diff --git a/src/StdLib/Lib/test/crashers/recursive_call.py b/src/extensions/StdLib/Lib/test/crashers/recursive_call.py similarity index 100% rename from src/StdLib/Lib/test/crashers/recursive_call.py rename to src/extensions/StdLib/Lib/test/crashers/recursive_call.py diff --git a/src/StdLib/Lib/test/crashers/trace_at_recursion_limit.py b/src/extensions/StdLib/Lib/test/crashers/trace_at_recursion_limit.py similarity index 100% rename from src/StdLib/Lib/test/crashers/trace_at_recursion_limit.py rename to src/extensions/StdLib/Lib/test/crashers/trace_at_recursion_limit.py diff --git a/src/StdLib/Lib/test/crashers/underlying_dict.py b/src/extensions/StdLib/Lib/test/crashers/underlying_dict.py similarity index 100% rename from src/StdLib/Lib/test/crashers/underlying_dict.py rename to src/extensions/StdLib/Lib/test/crashers/underlying_dict.py diff --git a/src/StdLib/Lib/test/curses_tests.py b/src/extensions/StdLib/Lib/test/curses_tests.py similarity index 100% rename from src/StdLib/Lib/test/curses_tests.py rename to src/extensions/StdLib/Lib/test/curses_tests.py diff --git a/src/StdLib/Lib/test/data/README b/src/extensions/StdLib/Lib/test/data/README similarity index 100% rename from src/StdLib/Lib/test/data/README rename to src/extensions/StdLib/Lib/test/data/README diff --git a/src/StdLib/Lib/test/datetimetester.py b/src/extensions/StdLib/Lib/test/datetimetester.py similarity index 100% rename from src/StdLib/Lib/test/datetimetester.py rename to src/extensions/StdLib/Lib/test/datetimetester.py diff --git a/src/StdLib/Lib/test/decimaltestdata/abs.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/abs.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/abs.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/abs.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/add.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/add.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/add.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/add.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/and.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/and.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/and.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/and.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/base.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/base.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/base.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/base.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/clamp.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/clamp.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/clamp.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/clamp.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/class.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/class.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/class.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/class.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/compare.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/compare.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/compare.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/compare.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/comparetotal.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/comparetotal.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/comparetotal.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/comparetotal.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/copy.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/copy.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/copy.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/copy.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/copyabs.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/copyabs.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/copyabs.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/copyabs.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/copynegate.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/copynegate.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/copynegate.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/copynegate.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/copysign.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/copysign.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/copysign.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/copysign.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddAbs.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddAbs.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddAbs.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddAbs.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddAdd.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddAdd.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddAdd.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddAdd.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddAnd.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddAnd.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddAnd.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddAnd.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddBase.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddBase.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddBase.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddBase.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddClass.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddClass.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddClass.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddClass.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddCompare.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddCompare.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddCompare.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddCompare.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddCopy.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddCopy.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddCopy.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddCopy.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddDivide.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddDivide.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddDivide.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddDivide.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddEncode.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddEncode.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddEncode.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddEncode.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddFMA.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddFMA.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddFMA.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddFMA.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddInvert.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddInvert.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddInvert.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddInvert.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddLogB.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddLogB.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddLogB.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddLogB.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddMax.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddMax.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddMax.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddMax.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddMin.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddMin.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddMin.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddMin.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddMinus.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddMinus.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddMinus.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddMinus.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddOr.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddOr.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddOr.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddOr.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddPlus.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddPlus.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddPlus.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddPlus.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddReduce.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddReduce.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddReduce.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddReduce.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddRotate.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddRotate.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddRotate.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddRotate.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddShift.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddShift.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddShift.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddShift.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ddXor.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ddXor.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ddXor.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ddXor.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/decDouble.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/decDouble.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/decDouble.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/decDouble.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/decQuad.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/decQuad.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/decQuad.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/decQuad.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/decSingle.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/decSingle.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/decSingle.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/decSingle.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/divide.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/divide.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/divide.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/divide.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/divideint.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/divideint.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/divideint.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/divideint.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqAbs.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqAbs.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqAbs.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqAbs.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqAdd.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqAdd.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqAdd.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqAdd.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqAnd.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqAnd.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqAnd.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqAnd.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqBase.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqBase.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqBase.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqBase.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqClass.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqClass.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqClass.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqClass.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqCompare.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqCompare.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqCompare.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqCompare.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqCopy.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqCopy.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqCopy.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqCopy.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqDivide.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqDivide.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqDivide.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqDivide.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqEncode.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqEncode.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqEncode.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqEncode.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqFMA.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqFMA.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqFMA.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqFMA.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqInvert.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqInvert.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqInvert.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqInvert.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqLogB.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqLogB.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqLogB.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqLogB.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqMax.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqMax.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqMax.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqMax.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqMin.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqMin.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqMin.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqMin.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqMinus.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqMinus.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqMinus.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqMinus.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqOr.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqOr.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqOr.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqOr.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqPlus.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqPlus.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqPlus.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqPlus.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqReduce.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqReduce.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqReduce.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqReduce.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqRotate.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqRotate.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqRotate.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqRotate.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqShift.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqShift.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqShift.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqShift.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dqXor.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dqXor.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dqXor.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dqXor.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dsBase.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dsBase.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dsBase.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dsBase.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/dsEncode.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/dsEncode.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/dsEncode.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/dsEncode.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/exp.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/exp.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/exp.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/exp.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/extra.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/extra.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/extra.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/extra.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/fma.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/fma.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/fma.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/fma.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/inexact.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/inexact.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/inexact.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/inexact.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/invert.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/invert.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/invert.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/invert.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/ln.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/ln.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/ln.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/ln.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/log10.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/log10.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/log10.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/log10.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/logb.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/logb.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/logb.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/logb.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/max.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/max.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/max.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/max.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/maxmag.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/maxmag.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/maxmag.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/maxmag.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/min.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/min.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/min.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/min.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/minmag.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/minmag.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/minmag.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/minmag.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/minus.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/minus.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/minus.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/minus.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/multiply.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/multiply.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/multiply.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/multiply.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/nextminus.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/nextminus.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/nextminus.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/nextminus.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/nextplus.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/nextplus.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/nextplus.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/nextplus.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/nexttoward.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/nexttoward.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/nexttoward.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/nexttoward.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/or.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/or.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/or.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/or.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/plus.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/plus.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/plus.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/plus.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/power.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/power.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/power.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/power.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/powersqrt.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/powersqrt.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/powersqrt.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/powersqrt.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/quantize.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/quantize.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/quantize.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/quantize.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/randomBound32.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/randomBound32.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/randomBound32.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/randomBound32.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/randoms.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/randoms.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/randoms.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/randoms.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/reduce.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/reduce.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/reduce.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/reduce.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/remainder.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/remainder.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/remainder.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/remainder.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/remainderNear.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/remainderNear.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/remainderNear.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/remainderNear.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/rescale.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/rescale.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/rescale.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/rescale.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/rotate.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/rotate.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/rotate.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/rotate.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/rounding.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/rounding.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/rounding.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/rounding.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/samequantum.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/samequantum.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/samequantum.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/samequantum.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/scaleb.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/scaleb.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/scaleb.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/scaleb.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/shift.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/shift.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/shift.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/shift.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/squareroot.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/squareroot.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/squareroot.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/squareroot.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/subtract.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/subtract.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/subtract.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/subtract.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/testall.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/testall.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/testall.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/testall.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/tointegral.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/tointegral.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/tointegral.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/tointegral.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/tointegralx.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/tointegralx.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/tointegralx.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/tointegralx.decTest diff --git a/src/StdLib/Lib/test/decimaltestdata/xor.decTest b/src/extensions/StdLib/Lib/test/decimaltestdata/xor.decTest similarity index 100% rename from src/StdLib/Lib/test/decimaltestdata/xor.decTest rename to src/extensions/StdLib/Lib/test/decimaltestdata/xor.decTest diff --git a/src/StdLib/Lib/test/dh1024.pem b/src/extensions/StdLib/Lib/test/dh1024.pem similarity index 100% rename from src/StdLib/Lib/test/dh1024.pem rename to src/extensions/StdLib/Lib/test/dh1024.pem diff --git a/src/StdLib/Lib/test/dis_module.py b/src/extensions/StdLib/Lib/test/dis_module.py similarity index 100% rename from src/StdLib/Lib/test/dis_module.py rename to src/extensions/StdLib/Lib/test/dis_module.py diff --git a/src/StdLib/Lib/test/doctest_aliases.py b/src/extensions/StdLib/Lib/test/doctest_aliases.py similarity index 100% rename from src/StdLib/Lib/test/doctest_aliases.py rename to src/extensions/StdLib/Lib/test/doctest_aliases.py diff --git a/src/StdLib/Lib/test/double_const.py b/src/extensions/StdLib/Lib/test/double_const.py similarity index 100% rename from src/StdLib/Lib/test/double_const.py rename to src/extensions/StdLib/Lib/test/double_const.py diff --git a/src/StdLib/Lib/test/empty.vbs b/src/extensions/StdLib/Lib/test/empty.vbs similarity index 100% rename from src/StdLib/Lib/test/empty.vbs rename to src/extensions/StdLib/Lib/test/empty.vbs diff --git a/src/StdLib/Lib/test/encoded_modules/__init__.py b/src/extensions/StdLib/Lib/test/encoded_modules/__init__.py similarity index 100% rename from src/StdLib/Lib/test/encoded_modules/__init__.py rename to src/extensions/StdLib/Lib/test/encoded_modules/__init__.py diff --git a/src/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py b/src/extensions/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py similarity index 100% rename from src/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py rename to src/extensions/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py diff --git a/src/StdLib/Lib/test/encoded_modules/module_koi8_r.py b/src/extensions/StdLib/Lib/test/encoded_modules/module_koi8_r.py similarity index 100% rename from src/StdLib/Lib/test/encoded_modules/module_koi8_r.py rename to src/extensions/StdLib/Lib/test/encoded_modules/module_koi8_r.py diff --git a/src/StdLib/Lib/test/exception_hierarchy.txt b/src/extensions/StdLib/Lib/test/exception_hierarchy.txt similarity index 100% rename from src/StdLib/Lib/test/exception_hierarchy.txt rename to src/extensions/StdLib/Lib/test/exception_hierarchy.txt diff --git a/src/StdLib/Lib/test/final_a.py b/src/extensions/StdLib/Lib/test/final_a.py similarity index 100% rename from src/StdLib/Lib/test/final_a.py rename to src/extensions/StdLib/Lib/test/final_a.py diff --git a/src/StdLib/Lib/test/final_b.py b/src/extensions/StdLib/Lib/test/final_b.py similarity index 100% rename from src/StdLib/Lib/test/final_b.py rename to src/extensions/StdLib/Lib/test/final_b.py diff --git a/src/StdLib/Lib/test/floating_points.txt b/src/extensions/StdLib/Lib/test/floating_points.txt similarity index 100% rename from src/StdLib/Lib/test/floating_points.txt rename to src/extensions/StdLib/Lib/test/floating_points.txt diff --git a/src/StdLib/Lib/test/fork_wait.py b/src/extensions/StdLib/Lib/test/fork_wait.py similarity index 100% rename from src/StdLib/Lib/test/fork_wait.py rename to src/extensions/StdLib/Lib/test/fork_wait.py diff --git a/src/StdLib/Lib/test/formatfloat_testcases.txt b/src/extensions/StdLib/Lib/test/formatfloat_testcases.txt similarity index 100% rename from src/StdLib/Lib/test/formatfloat_testcases.txt rename to src/extensions/StdLib/Lib/test/formatfloat_testcases.txt diff --git a/src/StdLib/Lib/test/future_test1.py b/src/extensions/StdLib/Lib/test/future_test1.py similarity index 100% rename from src/StdLib/Lib/test/future_test1.py rename to src/extensions/StdLib/Lib/test/future_test1.py diff --git a/src/StdLib/Lib/test/future_test2.py b/src/extensions/StdLib/Lib/test/future_test2.py similarity index 100% rename from src/StdLib/Lib/test/future_test2.py rename to src/extensions/StdLib/Lib/test/future_test2.py diff --git a/src/StdLib/Lib/test/gdb_sample.py b/src/extensions/StdLib/Lib/test/gdb_sample.py similarity index 100% rename from src/StdLib/Lib/test/gdb_sample.py rename to src/extensions/StdLib/Lib/test/gdb_sample.py diff --git a/src/StdLib/Lib/test/ieee754.txt b/src/extensions/StdLib/Lib/test/ieee754.txt similarity index 100% rename from src/StdLib/Lib/test/ieee754.txt rename to src/extensions/StdLib/Lib/test/ieee754.txt diff --git a/src/StdLib/Lib/test/imghdrdata/python.bmp b/src/extensions/StdLib/Lib/test/imghdrdata/python.bmp similarity index 100% rename from src/StdLib/Lib/test/imghdrdata/python.bmp rename to src/extensions/StdLib/Lib/test/imghdrdata/python.bmp diff --git a/src/StdLib/Lib/test/imghdrdata/python.gif b/src/extensions/StdLib/Lib/test/imghdrdata/python.gif similarity index 100% rename from src/StdLib/Lib/test/imghdrdata/python.gif rename to src/extensions/StdLib/Lib/test/imghdrdata/python.gif diff --git a/src/StdLib/Lib/test/imghdrdata/python.jpg b/src/extensions/StdLib/Lib/test/imghdrdata/python.jpg similarity index 100% rename from src/StdLib/Lib/test/imghdrdata/python.jpg rename to src/extensions/StdLib/Lib/test/imghdrdata/python.jpg diff --git a/src/StdLib/Lib/test/imghdrdata/python.pbm b/src/extensions/StdLib/Lib/test/imghdrdata/python.pbm similarity index 100% rename from src/StdLib/Lib/test/imghdrdata/python.pbm rename to src/extensions/StdLib/Lib/test/imghdrdata/python.pbm diff --git a/src/StdLib/Lib/test/imghdrdata/python.pgm b/src/extensions/StdLib/Lib/test/imghdrdata/python.pgm similarity index 100% rename from src/StdLib/Lib/test/imghdrdata/python.pgm rename to src/extensions/StdLib/Lib/test/imghdrdata/python.pgm diff --git a/src/StdLib/Lib/test/imghdrdata/python.png b/src/extensions/StdLib/Lib/test/imghdrdata/python.png similarity index 100% rename from src/StdLib/Lib/test/imghdrdata/python.png rename to src/extensions/StdLib/Lib/test/imghdrdata/python.png diff --git a/src/StdLib/Lib/test/imghdrdata/python.ppm b/src/extensions/StdLib/Lib/test/imghdrdata/python.ppm similarity index 100% rename from src/StdLib/Lib/test/imghdrdata/python.ppm rename to src/extensions/StdLib/Lib/test/imghdrdata/python.ppm diff --git a/src/StdLib/Lib/test/imghdrdata/python.ras b/src/extensions/StdLib/Lib/test/imghdrdata/python.ras similarity index 100% rename from src/StdLib/Lib/test/imghdrdata/python.ras rename to src/extensions/StdLib/Lib/test/imghdrdata/python.ras diff --git a/src/StdLib/Lib/test/imghdrdata/python.sgi b/src/extensions/StdLib/Lib/test/imghdrdata/python.sgi similarity index 100% rename from src/StdLib/Lib/test/imghdrdata/python.sgi rename to src/extensions/StdLib/Lib/test/imghdrdata/python.sgi diff --git a/src/StdLib/Lib/test/imghdrdata/python.tiff b/src/extensions/StdLib/Lib/test/imghdrdata/python.tiff similarity index 100% rename from src/StdLib/Lib/test/imghdrdata/python.tiff rename to src/extensions/StdLib/Lib/test/imghdrdata/python.tiff diff --git a/src/StdLib/Lib/test/imghdrdata/python.xbm b/src/extensions/StdLib/Lib/test/imghdrdata/python.xbm similarity index 100% rename from src/StdLib/Lib/test/imghdrdata/python.xbm rename to src/extensions/StdLib/Lib/test/imghdrdata/python.xbm diff --git a/src/StdLib/Lib/test/inspect_fodder.py b/src/extensions/StdLib/Lib/test/inspect_fodder.py similarity index 100% rename from src/StdLib/Lib/test/inspect_fodder.py rename to src/extensions/StdLib/Lib/test/inspect_fodder.py diff --git a/src/StdLib/Lib/test/inspect_fodder2.py b/src/extensions/StdLib/Lib/test/inspect_fodder2.py similarity index 100% rename from src/StdLib/Lib/test/inspect_fodder2.py rename to src/extensions/StdLib/Lib/test/inspect_fodder2.py diff --git a/src/StdLib/Lib/test/keycert.passwd.pem b/src/extensions/StdLib/Lib/test/keycert.passwd.pem similarity index 100% rename from src/StdLib/Lib/test/keycert.passwd.pem rename to src/extensions/StdLib/Lib/test/keycert.passwd.pem diff --git a/src/StdLib/Lib/test/keycert.pem b/src/extensions/StdLib/Lib/test/keycert.pem similarity index 100% rename from src/StdLib/Lib/test/keycert.pem rename to src/extensions/StdLib/Lib/test/keycert.pem diff --git a/src/StdLib/Lib/test/keycert2.pem b/src/extensions/StdLib/Lib/test/keycert2.pem similarity index 100% rename from src/StdLib/Lib/test/keycert2.pem rename to src/extensions/StdLib/Lib/test/keycert2.pem diff --git a/src/StdLib/Lib/test/keycert3.pem b/src/extensions/StdLib/Lib/test/keycert3.pem similarity index 100% rename from src/StdLib/Lib/test/keycert3.pem rename to src/extensions/StdLib/Lib/test/keycert3.pem diff --git a/src/StdLib/Lib/test/keycert4.pem b/src/extensions/StdLib/Lib/test/keycert4.pem similarity index 100% rename from src/StdLib/Lib/test/keycert4.pem rename to src/extensions/StdLib/Lib/test/keycert4.pem diff --git a/src/StdLib/Lib/test/leakers/README.txt b/src/extensions/StdLib/Lib/test/leakers/README.txt similarity index 100% rename from src/StdLib/Lib/test/leakers/README.txt rename to src/extensions/StdLib/Lib/test/leakers/README.txt diff --git a/src/StdLib/Lib/test/leakers/__init__.py b/src/extensions/StdLib/Lib/test/leakers/__init__.py similarity index 100% rename from src/StdLib/Lib/test/leakers/__init__.py rename to src/extensions/StdLib/Lib/test/leakers/__init__.py diff --git a/src/StdLib/Lib/test/leakers/test_ctypes.py b/src/extensions/StdLib/Lib/test/leakers/test_ctypes.py similarity index 100% rename from src/StdLib/Lib/test/leakers/test_ctypes.py rename to src/extensions/StdLib/Lib/test/leakers/test_ctypes.py diff --git a/src/StdLib/Lib/test/leakers/test_selftype.py b/src/extensions/StdLib/Lib/test/leakers/test_selftype.py similarity index 100% rename from src/StdLib/Lib/test/leakers/test_selftype.py rename to src/extensions/StdLib/Lib/test/leakers/test_selftype.py diff --git a/src/StdLib/Lib/test/list_tests.py b/src/extensions/StdLib/Lib/test/list_tests.py similarity index 100% rename from src/StdLib/Lib/test/list_tests.py rename to src/extensions/StdLib/Lib/test/list_tests.py diff --git a/src/StdLib/Lib/test/lock_tests.py b/src/extensions/StdLib/Lib/test/lock_tests.py similarity index 100% rename from src/StdLib/Lib/test/lock_tests.py rename to src/extensions/StdLib/Lib/test/lock_tests.py diff --git a/src/StdLib/Lib/test/mailcap.txt b/src/extensions/StdLib/Lib/test/mailcap.txt similarity index 100% rename from src/StdLib/Lib/test/mailcap.txt rename to src/extensions/StdLib/Lib/test/mailcap.txt diff --git a/src/StdLib/Lib/test/make_ssl_certs.py b/src/extensions/StdLib/Lib/test/make_ssl_certs.py similarity index 100% rename from src/StdLib/Lib/test/make_ssl_certs.py rename to src/extensions/StdLib/Lib/test/make_ssl_certs.py diff --git a/src/StdLib/Lib/test/mapping_tests.py b/src/extensions/StdLib/Lib/test/mapping_tests.py similarity index 100% rename from src/StdLib/Lib/test/mapping_tests.py rename to src/extensions/StdLib/Lib/test/mapping_tests.py diff --git a/src/StdLib/Lib/test/math_testcases.txt b/src/extensions/StdLib/Lib/test/math_testcases.txt similarity index 100% rename from src/StdLib/Lib/test/math_testcases.txt rename to src/extensions/StdLib/Lib/test/math_testcases.txt diff --git a/src/StdLib/Lib/test/memory_watchdog.py b/src/extensions/StdLib/Lib/test/memory_watchdog.py similarity index 100% rename from src/StdLib/Lib/test/memory_watchdog.py rename to src/extensions/StdLib/Lib/test/memory_watchdog.py diff --git a/src/StdLib/Lib/test/mime.types b/src/extensions/StdLib/Lib/test/mime.types similarity index 100% rename from src/StdLib/Lib/test/mime.types rename to src/extensions/StdLib/Lib/test/mime.types diff --git a/src/StdLib/Lib/test/mock_socket.py b/src/extensions/StdLib/Lib/test/mock_socket.py similarity index 100% rename from src/StdLib/Lib/test/mock_socket.py rename to src/extensions/StdLib/Lib/test/mock_socket.py diff --git a/src/StdLib/Lib/test/mod_generics_cache.py b/src/extensions/StdLib/Lib/test/mod_generics_cache.py similarity index 100% rename from src/StdLib/Lib/test/mod_generics_cache.py rename to src/extensions/StdLib/Lib/test/mod_generics_cache.py diff --git a/src/StdLib/Lib/test/mp_fork_bomb.py b/src/extensions/StdLib/Lib/test/mp_fork_bomb.py similarity index 100% rename from src/StdLib/Lib/test/mp_fork_bomb.py rename to src/extensions/StdLib/Lib/test/mp_fork_bomb.py diff --git a/src/StdLib/Lib/test/multibytecodec_support.py b/src/extensions/StdLib/Lib/test/multibytecodec_support.py similarity index 100% rename from src/StdLib/Lib/test/multibytecodec_support.py rename to src/extensions/StdLib/Lib/test/multibytecodec_support.py diff --git a/src/StdLib/Lib/test/nokia.pem b/src/extensions/StdLib/Lib/test/nokia.pem similarity index 100% rename from src/StdLib/Lib/test/nokia.pem rename to src/extensions/StdLib/Lib/test/nokia.pem diff --git a/src/StdLib/Lib/test/nullbytecert.pem b/src/extensions/StdLib/Lib/test/nullbytecert.pem similarity index 100% rename from src/StdLib/Lib/test/nullbytecert.pem rename to src/extensions/StdLib/Lib/test/nullbytecert.pem diff --git a/src/StdLib/Lib/test/nullcert.pem b/src/extensions/StdLib/Lib/test/nullcert.pem similarity index 100% rename from src/StdLib/Lib/test/nullcert.pem rename to src/extensions/StdLib/Lib/test/nullcert.pem diff --git a/src/StdLib/Lib/test/outstanding_bugs.py b/src/extensions/StdLib/Lib/test/outstanding_bugs.py similarity index 100% rename from src/StdLib/Lib/test/outstanding_bugs.py rename to src/extensions/StdLib/Lib/test/outstanding_bugs.py diff --git a/src/StdLib/Lib/test/pickletester.py b/src/extensions/StdLib/Lib/test/pickletester.py similarity index 100% rename from src/StdLib/Lib/test/pickletester.py rename to src/extensions/StdLib/Lib/test/pickletester.py diff --git a/src/StdLib/Lib/test/profilee.py b/src/extensions/StdLib/Lib/test/profilee.py similarity index 100% rename from src/StdLib/Lib/test/profilee.py rename to src/extensions/StdLib/Lib/test/profilee.py diff --git a/src/StdLib/Lib/test/pstats.pck b/src/extensions/StdLib/Lib/test/pstats.pck similarity index 100% rename from src/StdLib/Lib/test/pstats.pck rename to src/extensions/StdLib/Lib/test/pstats.pck diff --git a/src/StdLib/Lib/test/pycacert.pem b/src/extensions/StdLib/Lib/test/pycacert.pem similarity index 100% rename from src/StdLib/Lib/test/pycacert.pem rename to src/extensions/StdLib/Lib/test/pycacert.pem diff --git a/src/StdLib/Lib/test/pycakey.pem b/src/extensions/StdLib/Lib/test/pycakey.pem similarity index 100% rename from src/StdLib/Lib/test/pycakey.pem rename to src/extensions/StdLib/Lib/test/pycakey.pem diff --git a/src/StdLib/Lib/test/pyclbr_input.py b/src/extensions/StdLib/Lib/test/pyclbr_input.py similarity index 100% rename from src/StdLib/Lib/test/pyclbr_input.py rename to src/extensions/StdLib/Lib/test/pyclbr_input.py diff --git a/src/StdLib/Lib/test/pydoc_mod.py b/src/extensions/StdLib/Lib/test/pydoc_mod.py similarity index 100% rename from src/StdLib/Lib/test/pydoc_mod.py rename to src/extensions/StdLib/Lib/test/pydoc_mod.py diff --git a/src/StdLib/Lib/test/pydocfodder.py b/src/extensions/StdLib/Lib/test/pydocfodder.py similarity index 100% rename from src/StdLib/Lib/test/pydocfodder.py rename to src/extensions/StdLib/Lib/test/pydocfodder.py diff --git a/src/StdLib/Lib/test/pystone.py b/src/extensions/StdLib/Lib/test/pystone.py similarity index 100% rename from src/StdLib/Lib/test/pystone.py rename to src/extensions/StdLib/Lib/test/pystone.py diff --git a/src/StdLib/Lib/test/randv2_32.pck b/src/extensions/StdLib/Lib/test/randv2_32.pck similarity index 100% rename from src/StdLib/Lib/test/randv2_32.pck rename to src/extensions/StdLib/Lib/test/randv2_32.pck diff --git a/src/StdLib/Lib/test/randv2_64.pck b/src/extensions/StdLib/Lib/test/randv2_64.pck similarity index 100% rename from src/StdLib/Lib/test/randv2_64.pck rename to src/extensions/StdLib/Lib/test/randv2_64.pck diff --git a/src/StdLib/Lib/test/randv3.pck b/src/extensions/StdLib/Lib/test/randv3.pck similarity index 100% rename from src/StdLib/Lib/test/randv3.pck rename to src/extensions/StdLib/Lib/test/randv3.pck diff --git a/src/StdLib/Lib/test/re_tests.py b/src/extensions/StdLib/Lib/test/re_tests.py similarity index 100% rename from src/StdLib/Lib/test/re_tests.py rename to src/extensions/StdLib/Lib/test/re_tests.py diff --git a/src/StdLib/Lib/test/regrtest.py b/src/extensions/StdLib/Lib/test/regrtest.py similarity index 100% rename from src/StdLib/Lib/test/regrtest.py rename to src/extensions/StdLib/Lib/test/regrtest.py diff --git a/src/StdLib/Lib/test/relimport.py b/src/extensions/StdLib/Lib/test/relimport.py similarity index 100% rename from src/StdLib/Lib/test/relimport.py rename to src/extensions/StdLib/Lib/test/relimport.py diff --git a/src/StdLib/Lib/test/reperf.py b/src/extensions/StdLib/Lib/test/reperf.py similarity index 100% rename from src/StdLib/Lib/test/reperf.py rename to src/extensions/StdLib/Lib/test/reperf.py diff --git a/src/StdLib/Lib/test/revocation.crl b/src/extensions/StdLib/Lib/test/revocation.crl similarity index 100% rename from src/StdLib/Lib/test/revocation.crl rename to src/extensions/StdLib/Lib/test/revocation.crl diff --git a/src/StdLib/Lib/test/sample_doctest.py b/src/extensions/StdLib/Lib/test/sample_doctest.py similarity index 100% rename from src/StdLib/Lib/test/sample_doctest.py rename to src/extensions/StdLib/Lib/test/sample_doctest.py diff --git a/src/StdLib/Lib/test/sample_doctest_no_docstrings.py b/src/extensions/StdLib/Lib/test/sample_doctest_no_docstrings.py similarity index 100% rename from src/StdLib/Lib/test/sample_doctest_no_docstrings.py rename to src/extensions/StdLib/Lib/test/sample_doctest_no_docstrings.py diff --git a/src/StdLib/Lib/test/sample_doctest_no_doctests.py b/src/extensions/StdLib/Lib/test/sample_doctest_no_doctests.py similarity index 100% rename from src/StdLib/Lib/test/sample_doctest_no_doctests.py rename to src/extensions/StdLib/Lib/test/sample_doctest_no_doctests.py diff --git a/src/StdLib/Lib/test/script_helper.py b/src/extensions/StdLib/Lib/test/script_helper.py similarity index 100% rename from src/StdLib/Lib/test/script_helper.py rename to src/extensions/StdLib/Lib/test/script_helper.py diff --git a/src/StdLib/Lib/test/selfsigned_pythontestdotnet.pem b/src/extensions/StdLib/Lib/test/selfsigned_pythontestdotnet.pem similarity index 100% rename from src/StdLib/Lib/test/selfsigned_pythontestdotnet.pem rename to src/extensions/StdLib/Lib/test/selfsigned_pythontestdotnet.pem diff --git a/src/StdLib/Lib/test/seq_tests.py b/src/extensions/StdLib/Lib/test/seq_tests.py similarity index 100% rename from src/StdLib/Lib/test/seq_tests.py rename to src/extensions/StdLib/Lib/test/seq_tests.py diff --git a/src/StdLib/Lib/test/sgml_input.html b/src/extensions/StdLib/Lib/test/sgml_input.html similarity index 100% rename from src/StdLib/Lib/test/sgml_input.html rename to src/extensions/StdLib/Lib/test/sgml_input.html diff --git a/src/StdLib/Lib/test/sha256.pem b/src/extensions/StdLib/Lib/test/sha256.pem similarity index 100% rename from src/StdLib/Lib/test/sha256.pem rename to src/extensions/StdLib/Lib/test/sha256.pem diff --git a/src/StdLib/Lib/test/sndhdrdata/README b/src/extensions/StdLib/Lib/test/sndhdrdata/README similarity index 100% rename from src/StdLib/Lib/test/sndhdrdata/README rename to src/extensions/StdLib/Lib/test/sndhdrdata/README diff --git a/src/StdLib/Lib/test/sndhdrdata/sndhdr.8svx b/src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.8svx similarity index 100% rename from src/StdLib/Lib/test/sndhdrdata/sndhdr.8svx rename to src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.8svx diff --git a/src/StdLib/Lib/test/sndhdrdata/sndhdr.aifc b/src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.aifc similarity index 100% rename from src/StdLib/Lib/test/sndhdrdata/sndhdr.aifc rename to src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.aifc diff --git a/src/StdLib/Lib/test/sndhdrdata/sndhdr.aiff b/src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.aiff similarity index 100% rename from src/StdLib/Lib/test/sndhdrdata/sndhdr.aiff rename to src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.aiff diff --git a/src/StdLib/Lib/test/sndhdrdata/sndhdr.au b/src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.au similarity index 100% rename from src/StdLib/Lib/test/sndhdrdata/sndhdr.au rename to src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.au diff --git a/src/StdLib/Lib/test/sndhdrdata/sndhdr.hcom b/src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.hcom similarity index 100% rename from src/StdLib/Lib/test/sndhdrdata/sndhdr.hcom rename to src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.hcom diff --git a/src/StdLib/Lib/test/sndhdrdata/sndhdr.sndt b/src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.sndt similarity index 100% rename from src/StdLib/Lib/test/sndhdrdata/sndhdr.sndt rename to src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.sndt diff --git a/src/StdLib/Lib/test/sndhdrdata/sndhdr.voc b/src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.voc similarity index 100% rename from src/StdLib/Lib/test/sndhdrdata/sndhdr.voc rename to src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.voc diff --git a/src/StdLib/Lib/test/sndhdrdata/sndhdr.wav b/src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.wav similarity index 100% rename from src/StdLib/Lib/test/sndhdrdata/sndhdr.wav rename to src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.wav diff --git a/src/StdLib/Lib/test/sortperf.py b/src/extensions/StdLib/Lib/test/sortperf.py similarity index 100% rename from src/StdLib/Lib/test/sortperf.py rename to src/extensions/StdLib/Lib/test/sortperf.py diff --git a/src/StdLib/Lib/test/ssl_cert.pem b/src/extensions/StdLib/Lib/test/ssl_cert.pem similarity index 100% rename from src/StdLib/Lib/test/ssl_cert.pem rename to src/extensions/StdLib/Lib/test/ssl_cert.pem diff --git a/src/StdLib/Lib/test/ssl_key.passwd.pem b/src/extensions/StdLib/Lib/test/ssl_key.passwd.pem similarity index 100% rename from src/StdLib/Lib/test/ssl_key.passwd.pem rename to src/extensions/StdLib/Lib/test/ssl_key.passwd.pem diff --git a/src/StdLib/Lib/test/ssl_key.pem b/src/extensions/StdLib/Lib/test/ssl_key.pem similarity index 100% rename from src/StdLib/Lib/test/ssl_key.pem rename to src/extensions/StdLib/Lib/test/ssl_key.pem diff --git a/src/StdLib/Lib/test/ssl_servers.py b/src/extensions/StdLib/Lib/test/ssl_servers.py similarity index 100% rename from src/StdLib/Lib/test/ssl_servers.py rename to src/extensions/StdLib/Lib/test/ssl_servers.py diff --git a/src/StdLib/Lib/test/ssltests.py b/src/extensions/StdLib/Lib/test/ssltests.py similarity index 100% rename from src/StdLib/Lib/test/ssltests.py rename to src/extensions/StdLib/Lib/test/ssltests.py diff --git a/src/StdLib/Lib/test/string_tests.py b/src/extensions/StdLib/Lib/test/string_tests.py similarity index 100% rename from src/StdLib/Lib/test/string_tests.py rename to src/extensions/StdLib/Lib/test/string_tests.py diff --git a/src/StdLib/Lib/test/subprocessdata/fd_status.py b/src/extensions/StdLib/Lib/test/subprocessdata/fd_status.py similarity index 100% rename from src/StdLib/Lib/test/subprocessdata/fd_status.py rename to src/extensions/StdLib/Lib/test/subprocessdata/fd_status.py diff --git a/src/StdLib/Lib/test/subprocessdata/input_reader.py b/src/extensions/StdLib/Lib/test/subprocessdata/input_reader.py similarity index 100% rename from src/StdLib/Lib/test/subprocessdata/input_reader.py rename to src/extensions/StdLib/Lib/test/subprocessdata/input_reader.py diff --git a/src/StdLib/Lib/test/subprocessdata/qcat.py b/src/extensions/StdLib/Lib/test/subprocessdata/qcat.py similarity index 100% rename from src/StdLib/Lib/test/subprocessdata/qcat.py rename to src/extensions/StdLib/Lib/test/subprocessdata/qcat.py diff --git a/src/StdLib/Lib/test/subprocessdata/qgrep.py b/src/extensions/StdLib/Lib/test/subprocessdata/qgrep.py similarity index 100% rename from src/StdLib/Lib/test/subprocessdata/qgrep.py rename to src/extensions/StdLib/Lib/test/subprocessdata/qgrep.py diff --git a/src/StdLib/Lib/test/subprocessdata/sigchild_ignore.py b/src/extensions/StdLib/Lib/test/subprocessdata/sigchild_ignore.py similarity index 100% rename from src/StdLib/Lib/test/subprocessdata/sigchild_ignore.py rename to src/extensions/StdLib/Lib/test/subprocessdata/sigchild_ignore.py diff --git a/src/StdLib/Lib/test/support/__init__.py b/src/extensions/StdLib/Lib/test/support/__init__.py similarity index 100% rename from src/StdLib/Lib/test/support/__init__.py rename to src/extensions/StdLib/Lib/test/support/__init__.py diff --git a/src/StdLib/Lib/test/talos-2019-0758.pem b/src/extensions/StdLib/Lib/test/talos-2019-0758.pem similarity index 100% rename from src/StdLib/Lib/test/talos-2019-0758.pem rename to src/extensions/StdLib/Lib/test/talos-2019-0758.pem diff --git a/src/StdLib/Lib/test/test___all__.py b/src/extensions/StdLib/Lib/test/test___all__.py similarity index 100% rename from src/StdLib/Lib/test/test___all__.py rename to src/extensions/StdLib/Lib/test/test___all__.py diff --git a/src/StdLib/Lib/test/test___future__.py b/src/extensions/StdLib/Lib/test/test___future__.py similarity index 100% rename from src/StdLib/Lib/test/test___future__.py rename to src/extensions/StdLib/Lib/test/test___future__.py diff --git a/src/StdLib/Lib/test/test__locale.py b/src/extensions/StdLib/Lib/test/test__locale.py similarity index 100% rename from src/StdLib/Lib/test/test__locale.py rename to src/extensions/StdLib/Lib/test/test__locale.py diff --git a/src/StdLib/Lib/test/test__opcode.py b/src/extensions/StdLib/Lib/test/test__opcode.py similarity index 100% rename from src/StdLib/Lib/test/test__opcode.py rename to src/extensions/StdLib/Lib/test/test__opcode.py diff --git a/src/StdLib/Lib/test/test__osx_support.py b/src/extensions/StdLib/Lib/test/test__osx_support.py similarity index 100% rename from src/StdLib/Lib/test/test__osx_support.py rename to src/extensions/StdLib/Lib/test/test__osx_support.py diff --git a/src/StdLib/Lib/test/test_abc.py b/src/extensions/StdLib/Lib/test/test_abc.py similarity index 100% rename from src/StdLib/Lib/test/test_abc.py rename to src/extensions/StdLib/Lib/test/test_abc.py diff --git a/src/StdLib/Lib/test/test_abstract_numbers.py b/src/extensions/StdLib/Lib/test/test_abstract_numbers.py similarity index 100% rename from src/StdLib/Lib/test/test_abstract_numbers.py rename to src/extensions/StdLib/Lib/test/test_abstract_numbers.py diff --git a/src/StdLib/Lib/test/test_aifc.py b/src/extensions/StdLib/Lib/test/test_aifc.py similarity index 100% rename from src/StdLib/Lib/test/test_aifc.py rename to src/extensions/StdLib/Lib/test/test_aifc.py diff --git a/src/StdLib/Lib/test/test_argparse.py b/src/extensions/StdLib/Lib/test/test_argparse.py similarity index 100% rename from src/StdLib/Lib/test/test_argparse.py rename to src/extensions/StdLib/Lib/test/test_argparse.py diff --git a/src/StdLib/Lib/test/test_array.py b/src/extensions/StdLib/Lib/test/test_array.py similarity index 100% rename from src/StdLib/Lib/test/test_array.py rename to src/extensions/StdLib/Lib/test/test_array.py diff --git a/src/StdLib/Lib/test/test_ast.py b/src/extensions/StdLib/Lib/test/test_ast.py similarity index 100% rename from src/StdLib/Lib/test/test_ast.py rename to src/extensions/StdLib/Lib/test/test_ast.py diff --git a/src/StdLib/Lib/test/test_asynchat.py b/src/extensions/StdLib/Lib/test/test_asynchat.py similarity index 100% rename from src/StdLib/Lib/test/test_asynchat.py rename to src/extensions/StdLib/Lib/test/test_asynchat.py diff --git a/src/StdLib/Lib/test/test_asyncio/__init__.py b/src/extensions/StdLib/Lib/test/test_asyncio/__init__.py similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/__init__.py rename to src/extensions/StdLib/Lib/test/test_asyncio/__init__.py diff --git a/src/StdLib/Lib/test/test_asyncio/__main__.py b/src/extensions/StdLib/Lib/test/test_asyncio/__main__.py similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/__main__.py rename to src/extensions/StdLib/Lib/test/test_asyncio/__main__.py diff --git a/src/StdLib/Lib/test/test_asyncio/echo.py b/src/extensions/StdLib/Lib/test/test_asyncio/echo.py similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/echo.py rename to src/extensions/StdLib/Lib/test/test_asyncio/echo.py diff --git a/src/StdLib/Lib/test/test_asyncio/echo2.py b/src/extensions/StdLib/Lib/test/test_asyncio/echo2.py similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/echo2.py rename to src/extensions/StdLib/Lib/test/test_asyncio/echo2.py diff --git a/src/StdLib/Lib/test/test_asyncio/echo3.py b/src/extensions/StdLib/Lib/test/test_asyncio/echo3.py similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/echo3.py rename to src/extensions/StdLib/Lib/test/test_asyncio/echo3.py diff --git a/src/StdLib/Lib/test/test_asyncio/keycert3.pem b/src/extensions/StdLib/Lib/test/test_asyncio/keycert3.pem similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/keycert3.pem rename to src/extensions/StdLib/Lib/test/test_asyncio/keycert3.pem diff --git a/src/StdLib/Lib/test/test_asyncio/pycacert.pem b/src/extensions/StdLib/Lib/test/test_asyncio/pycacert.pem similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/pycacert.pem rename to src/extensions/StdLib/Lib/test/test_asyncio/pycacert.pem diff --git a/src/StdLib/Lib/test/test_asyncio/ssl_cert.pem b/src/extensions/StdLib/Lib/test/test_asyncio/ssl_cert.pem similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/ssl_cert.pem rename to src/extensions/StdLib/Lib/test/test_asyncio/ssl_cert.pem diff --git a/src/StdLib/Lib/test/test_asyncio/ssl_key.pem b/src/extensions/StdLib/Lib/test/test_asyncio/ssl_key.pem similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/ssl_key.pem rename to src/extensions/StdLib/Lib/test/test_asyncio/ssl_key.pem diff --git a/src/StdLib/Lib/test/test_asyncio/test_base_events.py b/src/extensions/StdLib/Lib/test/test_asyncio/test_base_events.py similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/test_base_events.py rename to src/extensions/StdLib/Lib/test/test_asyncio/test_base_events.py diff --git a/src/StdLib/Lib/test/test_asyncio/test_events.py b/src/extensions/StdLib/Lib/test/test_asyncio/test_events.py similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/test_events.py rename to src/extensions/StdLib/Lib/test/test_asyncio/test_events.py diff --git a/src/StdLib/Lib/test/test_asyncio/test_futures.py b/src/extensions/StdLib/Lib/test/test_asyncio/test_futures.py similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/test_futures.py rename to src/extensions/StdLib/Lib/test/test_asyncio/test_futures.py diff --git a/src/StdLib/Lib/test/test_asyncio/test_locks.py b/src/extensions/StdLib/Lib/test/test_asyncio/test_locks.py similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/test_locks.py rename to src/extensions/StdLib/Lib/test/test_asyncio/test_locks.py diff --git a/src/StdLib/Lib/test/test_asyncio/test_proactor_events.py b/src/extensions/StdLib/Lib/test/test_asyncio/test_proactor_events.py similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/test_proactor_events.py rename to src/extensions/StdLib/Lib/test/test_asyncio/test_proactor_events.py diff --git a/src/StdLib/Lib/test/test_asyncio/test_queues.py b/src/extensions/StdLib/Lib/test/test_asyncio/test_queues.py similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/test_queues.py rename to src/extensions/StdLib/Lib/test/test_asyncio/test_queues.py diff --git a/src/StdLib/Lib/test/test_asyncio/test_selector_events.py b/src/extensions/StdLib/Lib/test/test_asyncio/test_selector_events.py similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/test_selector_events.py rename to src/extensions/StdLib/Lib/test/test_asyncio/test_selector_events.py diff --git a/src/StdLib/Lib/test/test_asyncio/test_sslproto.py b/src/extensions/StdLib/Lib/test/test_asyncio/test_sslproto.py similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/test_sslproto.py rename to src/extensions/StdLib/Lib/test/test_asyncio/test_sslproto.py diff --git a/src/StdLib/Lib/test/test_asyncio/test_streams.py b/src/extensions/StdLib/Lib/test/test_asyncio/test_streams.py similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/test_streams.py rename to src/extensions/StdLib/Lib/test/test_asyncio/test_streams.py diff --git a/src/StdLib/Lib/test/test_asyncio/test_subprocess.py b/src/extensions/StdLib/Lib/test/test_asyncio/test_subprocess.py similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/test_subprocess.py rename to src/extensions/StdLib/Lib/test/test_asyncio/test_subprocess.py diff --git a/src/StdLib/Lib/test/test_asyncio/test_tasks.py b/src/extensions/StdLib/Lib/test/test_asyncio/test_tasks.py similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/test_tasks.py rename to src/extensions/StdLib/Lib/test/test_asyncio/test_tasks.py diff --git a/src/StdLib/Lib/test/test_asyncio/test_transports.py b/src/extensions/StdLib/Lib/test/test_asyncio/test_transports.py similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/test_transports.py rename to src/extensions/StdLib/Lib/test/test_asyncio/test_transports.py diff --git a/src/StdLib/Lib/test/test_asyncio/test_unix_events.py b/src/extensions/StdLib/Lib/test/test_asyncio/test_unix_events.py similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/test_unix_events.py rename to src/extensions/StdLib/Lib/test/test_asyncio/test_unix_events.py diff --git a/src/StdLib/Lib/test/test_asyncio/test_windows_events.py b/src/extensions/StdLib/Lib/test/test_asyncio/test_windows_events.py similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/test_windows_events.py rename to src/extensions/StdLib/Lib/test/test_asyncio/test_windows_events.py diff --git a/src/StdLib/Lib/test/test_asyncio/test_windows_utils.py b/src/extensions/StdLib/Lib/test/test_asyncio/test_windows_utils.py similarity index 100% rename from src/StdLib/Lib/test/test_asyncio/test_windows_utils.py rename to src/extensions/StdLib/Lib/test/test_asyncio/test_windows_utils.py diff --git a/src/StdLib/Lib/test/test_asyncore.py b/src/extensions/StdLib/Lib/test/test_asyncore.py similarity index 100% rename from src/StdLib/Lib/test/test_asyncore.py rename to src/extensions/StdLib/Lib/test/test_asyncore.py diff --git a/src/StdLib/Lib/test/test_atexit.py b/src/extensions/StdLib/Lib/test/test_atexit.py similarity index 100% rename from src/StdLib/Lib/test/test_atexit.py rename to src/extensions/StdLib/Lib/test/test_atexit.py diff --git a/src/StdLib/Lib/test/test_audioop.py b/src/extensions/StdLib/Lib/test/test_audioop.py similarity index 100% rename from src/StdLib/Lib/test/test_audioop.py rename to src/extensions/StdLib/Lib/test/test_audioop.py diff --git a/src/StdLib/Lib/test/test_augassign.py b/src/extensions/StdLib/Lib/test/test_augassign.py similarity index 100% rename from src/StdLib/Lib/test/test_augassign.py rename to src/extensions/StdLib/Lib/test/test_augassign.py diff --git a/src/StdLib/Lib/test/test_base64.py b/src/extensions/StdLib/Lib/test/test_base64.py similarity index 100% rename from src/StdLib/Lib/test/test_base64.py rename to src/extensions/StdLib/Lib/test/test_base64.py diff --git a/src/StdLib/Lib/test/test_bigaddrspace.py b/src/extensions/StdLib/Lib/test/test_bigaddrspace.py similarity index 100% rename from src/StdLib/Lib/test/test_bigaddrspace.py rename to src/extensions/StdLib/Lib/test/test_bigaddrspace.py diff --git a/src/StdLib/Lib/test/test_bigmem.py b/src/extensions/StdLib/Lib/test/test_bigmem.py similarity index 100% rename from src/StdLib/Lib/test/test_bigmem.py rename to src/extensions/StdLib/Lib/test/test_bigmem.py diff --git a/src/StdLib/Lib/test/test_binascii.py b/src/extensions/StdLib/Lib/test/test_binascii.py similarity index 100% rename from src/StdLib/Lib/test/test_binascii.py rename to src/extensions/StdLib/Lib/test/test_binascii.py diff --git a/src/StdLib/Lib/test/test_binhex.py b/src/extensions/StdLib/Lib/test/test_binhex.py similarity index 100% rename from src/StdLib/Lib/test/test_binhex.py rename to src/extensions/StdLib/Lib/test/test_binhex.py diff --git a/src/StdLib/Lib/test/test_binop.py b/src/extensions/StdLib/Lib/test/test_binop.py similarity index 100% rename from src/StdLib/Lib/test/test_binop.py rename to src/extensions/StdLib/Lib/test/test_binop.py diff --git a/src/StdLib/Lib/test/test_bisect.py b/src/extensions/StdLib/Lib/test/test_bisect.py similarity index 100% rename from src/StdLib/Lib/test/test_bisect.py rename to src/extensions/StdLib/Lib/test/test_bisect.py diff --git a/src/StdLib/Lib/test/test_bool.py b/src/extensions/StdLib/Lib/test/test_bool.py similarity index 100% rename from src/StdLib/Lib/test/test_bool.py rename to src/extensions/StdLib/Lib/test/test_bool.py diff --git a/src/StdLib/Lib/test/test_buffer.py b/src/extensions/StdLib/Lib/test/test_buffer.py similarity index 100% rename from src/StdLib/Lib/test/test_buffer.py rename to src/extensions/StdLib/Lib/test/test_buffer.py diff --git a/src/StdLib/Lib/test/test_bufio.py b/src/extensions/StdLib/Lib/test/test_bufio.py similarity index 100% rename from src/StdLib/Lib/test/test_bufio.py rename to src/extensions/StdLib/Lib/test/test_bufio.py diff --git a/src/StdLib/Lib/test/test_builtin.py b/src/extensions/StdLib/Lib/test/test_builtin.py similarity index 100% rename from src/StdLib/Lib/test/test_builtin.py rename to src/extensions/StdLib/Lib/test/test_builtin.py diff --git a/src/StdLib/Lib/test/test_bytes.py b/src/extensions/StdLib/Lib/test/test_bytes.py similarity index 100% rename from src/StdLib/Lib/test/test_bytes.py rename to src/extensions/StdLib/Lib/test/test_bytes.py diff --git a/src/StdLib/Lib/test/test_bz2.py b/src/extensions/StdLib/Lib/test/test_bz2.py similarity index 100% rename from src/StdLib/Lib/test/test_bz2.py rename to src/extensions/StdLib/Lib/test/test_bz2.py diff --git a/src/StdLib/Lib/test/test_calendar.py b/src/extensions/StdLib/Lib/test/test_calendar.py similarity index 100% rename from src/StdLib/Lib/test/test_calendar.py rename to src/extensions/StdLib/Lib/test/test_calendar.py diff --git a/src/StdLib/Lib/test/test_call.py b/src/extensions/StdLib/Lib/test/test_call.py similarity index 100% rename from src/StdLib/Lib/test/test_call.py rename to src/extensions/StdLib/Lib/test/test_call.py diff --git a/src/StdLib/Lib/test/test_capi.py b/src/extensions/StdLib/Lib/test/test_capi.py similarity index 100% rename from src/StdLib/Lib/test/test_capi.py rename to src/extensions/StdLib/Lib/test/test_capi.py diff --git a/src/StdLib/Lib/test/test_cgi.py b/src/extensions/StdLib/Lib/test/test_cgi.py similarity index 100% rename from src/StdLib/Lib/test/test_cgi.py rename to src/extensions/StdLib/Lib/test/test_cgi.py diff --git a/src/StdLib/Lib/test/test_cgitb.py b/src/extensions/StdLib/Lib/test/test_cgitb.py similarity index 100% rename from src/StdLib/Lib/test/test_cgitb.py rename to src/extensions/StdLib/Lib/test/test_cgitb.py diff --git a/src/StdLib/Lib/test/test_charmapcodec.py b/src/extensions/StdLib/Lib/test/test_charmapcodec.py similarity index 100% rename from src/StdLib/Lib/test/test_charmapcodec.py rename to src/extensions/StdLib/Lib/test/test_charmapcodec.py diff --git a/src/StdLib/Lib/test/test_class.py b/src/extensions/StdLib/Lib/test/test_class.py similarity index 100% rename from src/StdLib/Lib/test/test_class.py rename to src/extensions/StdLib/Lib/test/test_class.py diff --git a/src/StdLib/Lib/test/test_cmath.py b/src/extensions/StdLib/Lib/test/test_cmath.py similarity index 100% rename from src/StdLib/Lib/test/test_cmath.py rename to src/extensions/StdLib/Lib/test/test_cmath.py diff --git a/src/StdLib/Lib/test/test_cmd.py b/src/extensions/StdLib/Lib/test/test_cmd.py similarity index 100% rename from src/StdLib/Lib/test/test_cmd.py rename to src/extensions/StdLib/Lib/test/test_cmd.py diff --git a/src/StdLib/Lib/test/test_cmd_line.py b/src/extensions/StdLib/Lib/test/test_cmd_line.py similarity index 100% rename from src/StdLib/Lib/test/test_cmd_line.py rename to src/extensions/StdLib/Lib/test/test_cmd_line.py diff --git a/src/StdLib/Lib/test/test_cmd_line_script.py b/src/extensions/StdLib/Lib/test/test_cmd_line_script.py similarity index 100% rename from src/StdLib/Lib/test/test_cmd_line_script.py rename to src/extensions/StdLib/Lib/test/test_cmd_line_script.py diff --git a/src/StdLib/Lib/test/test_code.py b/src/extensions/StdLib/Lib/test/test_code.py similarity index 100% rename from src/StdLib/Lib/test/test_code.py rename to src/extensions/StdLib/Lib/test/test_code.py diff --git a/src/StdLib/Lib/test/test_code_module.py b/src/extensions/StdLib/Lib/test/test_code_module.py similarity index 100% rename from src/StdLib/Lib/test/test_code_module.py rename to src/extensions/StdLib/Lib/test/test_code_module.py diff --git a/src/StdLib/Lib/test/test_codeccallbacks.py b/src/extensions/StdLib/Lib/test/test_codeccallbacks.py similarity index 100% rename from src/StdLib/Lib/test/test_codeccallbacks.py rename to src/extensions/StdLib/Lib/test/test_codeccallbacks.py diff --git a/src/StdLib/Lib/test/test_codecencodings_cn.py b/src/extensions/StdLib/Lib/test/test_codecencodings_cn.py similarity index 100% rename from src/StdLib/Lib/test/test_codecencodings_cn.py rename to src/extensions/StdLib/Lib/test/test_codecencodings_cn.py diff --git a/src/StdLib/Lib/test/test_codecencodings_hk.py b/src/extensions/StdLib/Lib/test/test_codecencodings_hk.py similarity index 100% rename from src/StdLib/Lib/test/test_codecencodings_hk.py rename to src/extensions/StdLib/Lib/test/test_codecencodings_hk.py diff --git a/src/StdLib/Lib/test/test_codecencodings_iso2022.py b/src/extensions/StdLib/Lib/test/test_codecencodings_iso2022.py similarity index 100% rename from src/StdLib/Lib/test/test_codecencodings_iso2022.py rename to src/extensions/StdLib/Lib/test/test_codecencodings_iso2022.py diff --git a/src/StdLib/Lib/test/test_codecencodings_jp.py b/src/extensions/StdLib/Lib/test/test_codecencodings_jp.py similarity index 100% rename from src/StdLib/Lib/test/test_codecencodings_jp.py rename to src/extensions/StdLib/Lib/test/test_codecencodings_jp.py diff --git a/src/StdLib/Lib/test/test_codecencodings_kr.py b/src/extensions/StdLib/Lib/test/test_codecencodings_kr.py similarity index 100% rename from src/StdLib/Lib/test/test_codecencodings_kr.py rename to src/extensions/StdLib/Lib/test/test_codecencodings_kr.py diff --git a/src/StdLib/Lib/test/test_codecencodings_tw.py b/src/extensions/StdLib/Lib/test/test_codecencodings_tw.py similarity index 100% rename from src/StdLib/Lib/test/test_codecencodings_tw.py rename to src/extensions/StdLib/Lib/test/test_codecencodings_tw.py diff --git a/src/StdLib/Lib/test/test_codecmaps_cn.py b/src/extensions/StdLib/Lib/test/test_codecmaps_cn.py similarity index 100% rename from src/StdLib/Lib/test/test_codecmaps_cn.py rename to src/extensions/StdLib/Lib/test/test_codecmaps_cn.py diff --git a/src/StdLib/Lib/test/test_codecmaps_hk.py b/src/extensions/StdLib/Lib/test/test_codecmaps_hk.py similarity index 100% rename from src/StdLib/Lib/test/test_codecmaps_hk.py rename to src/extensions/StdLib/Lib/test/test_codecmaps_hk.py diff --git a/src/StdLib/Lib/test/test_codecmaps_jp.py b/src/extensions/StdLib/Lib/test/test_codecmaps_jp.py similarity index 100% rename from src/StdLib/Lib/test/test_codecmaps_jp.py rename to src/extensions/StdLib/Lib/test/test_codecmaps_jp.py diff --git a/src/StdLib/Lib/test/test_codecmaps_kr.py b/src/extensions/StdLib/Lib/test/test_codecmaps_kr.py similarity index 100% rename from src/StdLib/Lib/test/test_codecmaps_kr.py rename to src/extensions/StdLib/Lib/test/test_codecmaps_kr.py diff --git a/src/StdLib/Lib/test/test_codecmaps_tw.py b/src/extensions/StdLib/Lib/test/test_codecmaps_tw.py similarity index 100% rename from src/StdLib/Lib/test/test_codecmaps_tw.py rename to src/extensions/StdLib/Lib/test/test_codecmaps_tw.py diff --git a/src/StdLib/Lib/test/test_codecs.py b/src/extensions/StdLib/Lib/test/test_codecs.py similarity index 100% rename from src/StdLib/Lib/test/test_codecs.py rename to src/extensions/StdLib/Lib/test/test_codecs.py diff --git a/src/StdLib/Lib/test/test_codeop.py b/src/extensions/StdLib/Lib/test/test_codeop.py similarity index 100% rename from src/StdLib/Lib/test/test_codeop.py rename to src/extensions/StdLib/Lib/test/test_codeop.py diff --git a/src/StdLib/Lib/test/test_collections.py b/src/extensions/StdLib/Lib/test/test_collections.py similarity index 100% rename from src/StdLib/Lib/test/test_collections.py rename to src/extensions/StdLib/Lib/test/test_collections.py diff --git a/src/StdLib/Lib/test/test_colorsys.py b/src/extensions/StdLib/Lib/test/test_colorsys.py similarity index 100% rename from src/StdLib/Lib/test/test_colorsys.py rename to src/extensions/StdLib/Lib/test/test_colorsys.py diff --git a/src/StdLib/Lib/test/test_compare.py b/src/extensions/StdLib/Lib/test/test_compare.py similarity index 100% rename from src/StdLib/Lib/test/test_compare.py rename to src/extensions/StdLib/Lib/test/test_compare.py diff --git a/src/StdLib/Lib/test/test_compile.py b/src/extensions/StdLib/Lib/test/test_compile.py similarity index 100% rename from src/StdLib/Lib/test/test_compile.py rename to src/extensions/StdLib/Lib/test/test_compile.py diff --git a/src/StdLib/Lib/test/test_compileall.py b/src/extensions/StdLib/Lib/test/test_compileall.py similarity index 100% rename from src/StdLib/Lib/test/test_compileall.py rename to src/extensions/StdLib/Lib/test/test_compileall.py diff --git a/src/StdLib/Lib/test/test_complex.py b/src/extensions/StdLib/Lib/test/test_complex.py similarity index 100% rename from src/StdLib/Lib/test/test_complex.py rename to src/extensions/StdLib/Lib/test/test_complex.py diff --git a/src/StdLib/Lib/test/test_concurrent_futures.py b/src/extensions/StdLib/Lib/test/test_concurrent_futures.py similarity index 100% rename from src/StdLib/Lib/test/test_concurrent_futures.py rename to src/extensions/StdLib/Lib/test/test_concurrent_futures.py diff --git a/src/StdLib/Lib/test/test_configparser.py b/src/extensions/StdLib/Lib/test/test_configparser.py similarity index 100% rename from src/StdLib/Lib/test/test_configparser.py rename to src/extensions/StdLib/Lib/test/test_configparser.py diff --git a/src/StdLib/Lib/test/test_contains.py b/src/extensions/StdLib/Lib/test/test_contains.py similarity index 100% rename from src/StdLib/Lib/test/test_contains.py rename to src/extensions/StdLib/Lib/test/test_contains.py diff --git a/src/StdLib/Lib/test/test_contextlib.py b/src/extensions/StdLib/Lib/test/test_contextlib.py similarity index 100% rename from src/StdLib/Lib/test/test_contextlib.py rename to src/extensions/StdLib/Lib/test/test_contextlib.py diff --git a/src/StdLib/Lib/test/test_copy.py b/src/extensions/StdLib/Lib/test/test_copy.py similarity index 100% rename from src/StdLib/Lib/test/test_copy.py rename to src/extensions/StdLib/Lib/test/test_copy.py diff --git a/src/StdLib/Lib/test/test_copyreg.py b/src/extensions/StdLib/Lib/test/test_copyreg.py similarity index 100% rename from src/StdLib/Lib/test/test_copyreg.py rename to src/extensions/StdLib/Lib/test/test_copyreg.py diff --git a/src/StdLib/Lib/test/test_cprofile.py b/src/extensions/StdLib/Lib/test/test_cprofile.py similarity index 100% rename from src/StdLib/Lib/test/test_cprofile.py rename to src/extensions/StdLib/Lib/test/test_cprofile.py diff --git a/src/StdLib/Lib/test/test_crashers.py b/src/extensions/StdLib/Lib/test/test_crashers.py similarity index 100% rename from src/StdLib/Lib/test/test_crashers.py rename to src/extensions/StdLib/Lib/test/test_crashers.py diff --git a/src/StdLib/Lib/test/test_crypt.py b/src/extensions/StdLib/Lib/test/test_crypt.py similarity index 100% rename from src/StdLib/Lib/test/test_crypt.py rename to src/extensions/StdLib/Lib/test/test_crypt.py diff --git a/src/StdLib/Lib/test/test_csv.py b/src/extensions/StdLib/Lib/test/test_csv.py similarity index 100% rename from src/StdLib/Lib/test/test_csv.py rename to src/extensions/StdLib/Lib/test/test_csv.py diff --git a/src/StdLib/Lib/test/test_ctypes.py b/src/extensions/StdLib/Lib/test/test_ctypes.py similarity index 100% rename from src/StdLib/Lib/test/test_ctypes.py rename to src/extensions/StdLib/Lib/test/test_ctypes.py diff --git a/src/StdLib/Lib/test/test_curses.py b/src/extensions/StdLib/Lib/test/test_curses.py similarity index 100% rename from src/StdLib/Lib/test/test_curses.py rename to src/extensions/StdLib/Lib/test/test_curses.py diff --git a/src/StdLib/Lib/test/test_datetime.py b/src/extensions/StdLib/Lib/test/test_datetime.py similarity index 100% rename from src/StdLib/Lib/test/test_datetime.py rename to src/extensions/StdLib/Lib/test/test_datetime.py diff --git a/src/StdLib/Lib/test/test_dbm.py b/src/extensions/StdLib/Lib/test/test_dbm.py similarity index 100% rename from src/StdLib/Lib/test/test_dbm.py rename to src/extensions/StdLib/Lib/test/test_dbm.py diff --git a/src/StdLib/Lib/test/test_dbm_dumb.py b/src/extensions/StdLib/Lib/test/test_dbm_dumb.py similarity index 100% rename from src/StdLib/Lib/test/test_dbm_dumb.py rename to src/extensions/StdLib/Lib/test/test_dbm_dumb.py diff --git a/src/StdLib/Lib/test/test_dbm_gnu.py b/src/extensions/StdLib/Lib/test/test_dbm_gnu.py similarity index 100% rename from src/StdLib/Lib/test/test_dbm_gnu.py rename to src/extensions/StdLib/Lib/test/test_dbm_gnu.py diff --git a/src/StdLib/Lib/test/test_dbm_ndbm.py b/src/extensions/StdLib/Lib/test/test_dbm_ndbm.py similarity index 100% rename from src/StdLib/Lib/test/test_dbm_ndbm.py rename to src/extensions/StdLib/Lib/test/test_dbm_ndbm.py diff --git a/src/StdLib/Lib/test/test_decimal.py b/src/extensions/StdLib/Lib/test/test_decimal.py similarity index 100% rename from src/StdLib/Lib/test/test_decimal.py rename to src/extensions/StdLib/Lib/test/test_decimal.py diff --git a/src/StdLib/Lib/test/test_decorators.py b/src/extensions/StdLib/Lib/test/test_decorators.py similarity index 100% rename from src/StdLib/Lib/test/test_decorators.py rename to src/extensions/StdLib/Lib/test/test_decorators.py diff --git a/src/StdLib/Lib/test/test_defaultdict.py b/src/extensions/StdLib/Lib/test/test_defaultdict.py similarity index 100% rename from src/StdLib/Lib/test/test_defaultdict.py rename to src/extensions/StdLib/Lib/test/test_defaultdict.py diff --git a/src/StdLib/Lib/test/test_deque.py b/src/extensions/StdLib/Lib/test/test_deque.py similarity index 100% rename from src/StdLib/Lib/test/test_deque.py rename to src/extensions/StdLib/Lib/test/test_deque.py diff --git a/src/StdLib/Lib/test/test_descr.py b/src/extensions/StdLib/Lib/test/test_descr.py similarity index 100% rename from src/StdLib/Lib/test/test_descr.py rename to src/extensions/StdLib/Lib/test/test_descr.py diff --git a/src/StdLib/Lib/test/test_descrtut.py b/src/extensions/StdLib/Lib/test/test_descrtut.py similarity index 100% rename from src/StdLib/Lib/test/test_descrtut.py rename to src/extensions/StdLib/Lib/test/test_descrtut.py diff --git a/src/StdLib/Lib/test/test_devpoll.py b/src/extensions/StdLib/Lib/test/test_devpoll.py similarity index 100% rename from src/StdLib/Lib/test/test_devpoll.py rename to src/extensions/StdLib/Lib/test/test_devpoll.py diff --git a/src/StdLib/Lib/test/test_dict.py b/src/extensions/StdLib/Lib/test/test_dict.py similarity index 100% rename from src/StdLib/Lib/test/test_dict.py rename to src/extensions/StdLib/Lib/test/test_dict.py diff --git a/src/StdLib/Lib/test/test_dictcomps.py b/src/extensions/StdLib/Lib/test/test_dictcomps.py similarity index 100% rename from src/StdLib/Lib/test/test_dictcomps.py rename to src/extensions/StdLib/Lib/test/test_dictcomps.py diff --git a/src/StdLib/Lib/test/test_dictviews.py b/src/extensions/StdLib/Lib/test/test_dictviews.py similarity index 100% rename from src/StdLib/Lib/test/test_dictviews.py rename to src/extensions/StdLib/Lib/test/test_dictviews.py diff --git a/src/StdLib/Lib/test/test_difflib.py b/src/extensions/StdLib/Lib/test/test_difflib.py similarity index 100% rename from src/StdLib/Lib/test/test_difflib.py rename to src/extensions/StdLib/Lib/test/test_difflib.py diff --git a/src/StdLib/Lib/test/test_difflib_expect.html b/src/extensions/StdLib/Lib/test/test_difflib_expect.html similarity index 100% rename from src/StdLib/Lib/test/test_difflib_expect.html rename to src/extensions/StdLib/Lib/test/test_difflib_expect.html diff --git a/src/StdLib/Lib/test/test_dis.py b/src/extensions/StdLib/Lib/test/test_dis.py similarity index 100% rename from src/StdLib/Lib/test/test_dis.py rename to src/extensions/StdLib/Lib/test/test_dis.py diff --git a/src/StdLib/Lib/test/test_distutils.py b/src/extensions/StdLib/Lib/test/test_distutils.py similarity index 100% rename from src/StdLib/Lib/test/test_distutils.py rename to src/extensions/StdLib/Lib/test/test_distutils.py diff --git a/src/StdLib/Lib/test/test_doctest.py b/src/extensions/StdLib/Lib/test/test_doctest.py similarity index 100% rename from src/StdLib/Lib/test/test_doctest.py rename to src/extensions/StdLib/Lib/test/test_doctest.py diff --git a/src/StdLib/Lib/test/test_doctest.txt b/src/extensions/StdLib/Lib/test/test_doctest.txt similarity index 100% rename from src/StdLib/Lib/test/test_doctest.txt rename to src/extensions/StdLib/Lib/test/test_doctest.txt diff --git a/src/StdLib/Lib/test/test_doctest2.py b/src/extensions/StdLib/Lib/test/test_doctest2.py similarity index 100% rename from src/StdLib/Lib/test/test_doctest2.py rename to src/extensions/StdLib/Lib/test/test_doctest2.py diff --git a/src/StdLib/Lib/test/test_doctest2.txt b/src/extensions/StdLib/Lib/test/test_doctest2.txt similarity index 100% rename from src/StdLib/Lib/test/test_doctest2.txt rename to src/extensions/StdLib/Lib/test/test_doctest2.txt diff --git a/src/StdLib/Lib/test/test_doctest3.txt b/src/extensions/StdLib/Lib/test/test_doctest3.txt similarity index 100% rename from src/StdLib/Lib/test/test_doctest3.txt rename to src/extensions/StdLib/Lib/test/test_doctest3.txt diff --git a/src/StdLib/Lib/test/test_doctest4.txt b/src/extensions/StdLib/Lib/test/test_doctest4.txt similarity index 100% rename from src/StdLib/Lib/test/test_doctest4.txt rename to src/extensions/StdLib/Lib/test/test_doctest4.txt diff --git a/src/StdLib/Lib/test/test_docxmlrpc.py b/src/extensions/StdLib/Lib/test/test_docxmlrpc.py similarity index 100% rename from src/StdLib/Lib/test/test_docxmlrpc.py rename to src/extensions/StdLib/Lib/test/test_docxmlrpc.py diff --git a/src/StdLib/Lib/test/test_dummy_thread.py b/src/extensions/StdLib/Lib/test/test_dummy_thread.py similarity index 100% rename from src/StdLib/Lib/test/test_dummy_thread.py rename to src/extensions/StdLib/Lib/test/test_dummy_thread.py diff --git a/src/StdLib/Lib/test/test_dummy_threading.py b/src/extensions/StdLib/Lib/test/test_dummy_threading.py similarity index 100% rename from src/StdLib/Lib/test/test_dummy_threading.py rename to src/extensions/StdLib/Lib/test/test_dummy_threading.py diff --git a/src/StdLib/Lib/test/test_dynamic.py b/src/extensions/StdLib/Lib/test/test_dynamic.py similarity index 100% rename from src/StdLib/Lib/test/test_dynamic.py rename to src/extensions/StdLib/Lib/test/test_dynamic.py diff --git a/src/StdLib/Lib/test/test_dynamicclassattribute.py b/src/extensions/StdLib/Lib/test/test_dynamicclassattribute.py similarity index 100% rename from src/StdLib/Lib/test/test_dynamicclassattribute.py rename to src/extensions/StdLib/Lib/test/test_dynamicclassattribute.py diff --git a/src/StdLib/Lib/test/test_email/__init__.py b/src/extensions/StdLib/Lib/test/test_email/__init__.py similarity index 100% rename from src/StdLib/Lib/test/test_email/__init__.py rename to src/extensions/StdLib/Lib/test/test_email/__init__.py diff --git a/src/StdLib/Lib/test/test_email/__main__.py b/src/extensions/StdLib/Lib/test/test_email/__main__.py similarity index 100% rename from src/StdLib/Lib/test/test_email/__main__.py rename to src/extensions/StdLib/Lib/test/test_email/__main__.py diff --git a/src/StdLib/Lib/test/test_email/data/PyBanner048.gif b/src/extensions/StdLib/Lib/test/test_email/data/PyBanner048.gif similarity index 100% rename from src/StdLib/Lib/test/test_email/data/PyBanner048.gif rename to src/extensions/StdLib/Lib/test/test_email/data/PyBanner048.gif diff --git a/src/StdLib/Lib/test/test_email/data/audiotest.au b/src/extensions/StdLib/Lib/test/test_email/data/audiotest.au similarity index 100% rename from src/StdLib/Lib/test/test_email/data/audiotest.au rename to src/extensions/StdLib/Lib/test/test_email/data/audiotest.au diff --git a/src/StdLib/Lib/test/test_email/data/msg_01.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_01.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_01.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_01.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_02.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_02.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_02.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_02.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_03.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_03.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_03.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_03.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_04.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_04.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_04.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_04.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_05.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_05.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_05.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_05.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_06.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_06.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_06.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_06.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_07.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_07.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_07.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_07.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_08.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_08.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_08.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_08.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_09.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_09.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_09.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_09.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_10.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_10.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_10.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_10.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_11.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_11.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_11.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_11.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_12.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_12.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_12.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_12.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_12a.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_12a.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_12a.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_12a.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_13.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_13.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_13.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_13.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_14.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_14.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_14.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_14.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_15.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_15.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_15.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_15.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_16.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_16.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_16.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_16.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_17.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_17.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_17.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_17.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_18.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_18.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_18.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_18.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_19.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_19.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_19.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_19.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_20.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_20.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_20.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_20.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_21.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_21.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_21.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_21.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_22.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_22.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_22.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_22.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_23.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_23.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_23.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_23.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_24.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_24.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_24.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_24.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_25.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_25.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_25.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_25.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_26.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_26.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_26.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_26.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_27.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_27.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_27.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_27.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_28.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_28.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_28.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_28.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_29.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_29.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_29.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_29.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_30.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_30.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_30.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_30.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_31.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_31.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_31.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_31.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_32.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_32.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_32.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_32.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_33.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_33.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_33.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_33.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_34.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_34.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_34.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_34.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_35.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_35.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_35.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_35.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_36.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_36.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_36.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_36.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_37.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_37.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_37.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_37.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_38.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_38.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_38.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_38.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_39.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_39.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_39.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_39.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_40.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_40.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_40.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_40.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_41.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_41.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_41.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_41.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_42.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_42.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_42.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_42.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_43.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_43.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_43.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_43.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_44.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_44.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_44.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_44.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_45.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_45.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_45.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_45.txt diff --git a/src/StdLib/Lib/test/test_email/data/msg_46.txt b/src/extensions/StdLib/Lib/test/test_email/data/msg_46.txt similarity index 100% rename from src/StdLib/Lib/test/test_email/data/msg_46.txt rename to src/extensions/StdLib/Lib/test/test_email/data/msg_46.txt diff --git a/src/StdLib/Lib/test/test_email/test__encoded_words.py b/src/extensions/StdLib/Lib/test/test_email/test__encoded_words.py similarity index 100% rename from src/StdLib/Lib/test/test_email/test__encoded_words.py rename to src/extensions/StdLib/Lib/test/test_email/test__encoded_words.py diff --git a/src/StdLib/Lib/test/test_email/test__header_value_parser.py b/src/extensions/StdLib/Lib/test/test_email/test__header_value_parser.py similarity index 100% rename from src/StdLib/Lib/test/test_email/test__header_value_parser.py rename to src/extensions/StdLib/Lib/test/test_email/test__header_value_parser.py diff --git a/src/StdLib/Lib/test/test_email/test_asian_codecs.py b/src/extensions/StdLib/Lib/test/test_email/test_asian_codecs.py similarity index 100% rename from src/StdLib/Lib/test/test_email/test_asian_codecs.py rename to src/extensions/StdLib/Lib/test/test_email/test_asian_codecs.py diff --git a/src/StdLib/Lib/test/test_email/test_contentmanager.py b/src/extensions/StdLib/Lib/test/test_email/test_contentmanager.py similarity index 100% rename from src/StdLib/Lib/test/test_email/test_contentmanager.py rename to src/extensions/StdLib/Lib/test/test_email/test_contentmanager.py diff --git a/src/StdLib/Lib/test/test_email/test_defect_handling.py b/src/extensions/StdLib/Lib/test/test_email/test_defect_handling.py similarity index 100% rename from src/StdLib/Lib/test/test_email/test_defect_handling.py rename to src/extensions/StdLib/Lib/test/test_email/test_defect_handling.py diff --git a/src/StdLib/Lib/test/test_email/test_email.py b/src/extensions/StdLib/Lib/test/test_email/test_email.py similarity index 100% rename from src/StdLib/Lib/test/test_email/test_email.py rename to src/extensions/StdLib/Lib/test/test_email/test_email.py diff --git a/src/StdLib/Lib/test/test_email/test_generator.py b/src/extensions/StdLib/Lib/test/test_email/test_generator.py similarity index 100% rename from src/StdLib/Lib/test/test_email/test_generator.py rename to src/extensions/StdLib/Lib/test/test_email/test_generator.py diff --git a/src/StdLib/Lib/test/test_email/test_headerregistry.py b/src/extensions/StdLib/Lib/test/test_email/test_headerregistry.py similarity index 100% rename from src/StdLib/Lib/test/test_email/test_headerregistry.py rename to src/extensions/StdLib/Lib/test/test_email/test_headerregistry.py diff --git a/src/StdLib/Lib/test/test_email/test_inversion.py b/src/extensions/StdLib/Lib/test/test_email/test_inversion.py similarity index 100% rename from src/StdLib/Lib/test/test_email/test_inversion.py rename to src/extensions/StdLib/Lib/test/test_email/test_inversion.py diff --git a/src/StdLib/Lib/test/test_email/test_message.py b/src/extensions/StdLib/Lib/test/test_email/test_message.py similarity index 100% rename from src/StdLib/Lib/test/test_email/test_message.py rename to src/extensions/StdLib/Lib/test/test_email/test_message.py diff --git a/src/StdLib/Lib/test/test_email/test_parser.py b/src/extensions/StdLib/Lib/test/test_email/test_parser.py similarity index 100% rename from src/StdLib/Lib/test/test_email/test_parser.py rename to src/extensions/StdLib/Lib/test/test_email/test_parser.py diff --git a/src/StdLib/Lib/test/test_email/test_pickleable.py b/src/extensions/StdLib/Lib/test/test_email/test_pickleable.py similarity index 100% rename from src/StdLib/Lib/test/test_email/test_pickleable.py rename to src/extensions/StdLib/Lib/test/test_email/test_pickleable.py diff --git a/src/StdLib/Lib/test/test_email/test_policy.py b/src/extensions/StdLib/Lib/test/test_email/test_policy.py similarity index 100% rename from src/StdLib/Lib/test/test_email/test_policy.py rename to src/extensions/StdLib/Lib/test/test_email/test_policy.py diff --git a/src/StdLib/Lib/test/test_email/test_utils.py b/src/extensions/StdLib/Lib/test/test_email/test_utils.py similarity index 100% rename from src/StdLib/Lib/test/test_email/test_utils.py rename to src/extensions/StdLib/Lib/test/test_email/test_utils.py diff --git a/src/StdLib/Lib/test/test_email/torture_test.py b/src/extensions/StdLib/Lib/test/test_email/torture_test.py similarity index 100% rename from src/StdLib/Lib/test/test_email/torture_test.py rename to src/extensions/StdLib/Lib/test/test_email/torture_test.py diff --git a/src/StdLib/Lib/test/test_ensurepip.py b/src/extensions/StdLib/Lib/test/test_ensurepip.py similarity index 100% rename from src/StdLib/Lib/test/test_ensurepip.py rename to src/extensions/StdLib/Lib/test/test_ensurepip.py diff --git a/src/StdLib/Lib/test/test_enum.py b/src/extensions/StdLib/Lib/test/test_enum.py similarity index 100% rename from src/StdLib/Lib/test/test_enum.py rename to src/extensions/StdLib/Lib/test/test_enum.py diff --git a/src/StdLib/Lib/test/test_enumerate.py b/src/extensions/StdLib/Lib/test/test_enumerate.py similarity index 100% rename from src/StdLib/Lib/test/test_enumerate.py rename to src/extensions/StdLib/Lib/test/test_enumerate.py diff --git a/src/StdLib/Lib/test/test_eof.py b/src/extensions/StdLib/Lib/test/test_eof.py similarity index 100% rename from src/StdLib/Lib/test/test_eof.py rename to src/extensions/StdLib/Lib/test/test_eof.py diff --git a/src/StdLib/Lib/test/test_epoll.py b/src/extensions/StdLib/Lib/test/test_epoll.py similarity index 100% rename from src/StdLib/Lib/test/test_epoll.py rename to src/extensions/StdLib/Lib/test/test_epoll.py diff --git a/src/StdLib/Lib/test/test_errno.py b/src/extensions/StdLib/Lib/test/test_errno.py similarity index 100% rename from src/StdLib/Lib/test/test_errno.py rename to src/extensions/StdLib/Lib/test/test_errno.py diff --git a/src/StdLib/Lib/test/test_exception_variations.py b/src/extensions/StdLib/Lib/test/test_exception_variations.py similarity index 100% rename from src/StdLib/Lib/test/test_exception_variations.py rename to src/extensions/StdLib/Lib/test/test_exception_variations.py diff --git a/src/StdLib/Lib/test/test_exceptions.py b/src/extensions/StdLib/Lib/test/test_exceptions.py similarity index 100% rename from src/StdLib/Lib/test/test_exceptions.py rename to src/extensions/StdLib/Lib/test/test_exceptions.py diff --git a/src/StdLib/Lib/test/test_extcall.py b/src/extensions/StdLib/Lib/test/test_extcall.py similarity index 100% rename from src/StdLib/Lib/test/test_extcall.py rename to src/extensions/StdLib/Lib/test/test_extcall.py diff --git a/src/StdLib/Lib/test/test_faulthandler.py b/src/extensions/StdLib/Lib/test/test_faulthandler.py similarity index 100% rename from src/StdLib/Lib/test/test_faulthandler.py rename to src/extensions/StdLib/Lib/test/test_faulthandler.py diff --git a/src/StdLib/Lib/test/test_fcntl.py b/src/extensions/StdLib/Lib/test/test_fcntl.py similarity index 100% rename from src/StdLib/Lib/test/test_fcntl.py rename to src/extensions/StdLib/Lib/test/test_fcntl.py diff --git a/src/StdLib/Lib/test/test_file.py b/src/extensions/StdLib/Lib/test/test_file.py similarity index 100% rename from src/StdLib/Lib/test/test_file.py rename to src/extensions/StdLib/Lib/test/test_file.py diff --git a/src/StdLib/Lib/test/test_file_eintr.py b/src/extensions/StdLib/Lib/test/test_file_eintr.py similarity index 100% rename from src/StdLib/Lib/test/test_file_eintr.py rename to src/extensions/StdLib/Lib/test/test_file_eintr.py diff --git a/src/StdLib/Lib/test/test_filecmp.py b/src/extensions/StdLib/Lib/test/test_filecmp.py similarity index 100% rename from src/StdLib/Lib/test/test_filecmp.py rename to src/extensions/StdLib/Lib/test/test_filecmp.py diff --git a/src/StdLib/Lib/test/test_fileinput.py b/src/extensions/StdLib/Lib/test/test_fileinput.py similarity index 100% rename from src/StdLib/Lib/test/test_fileinput.py rename to src/extensions/StdLib/Lib/test/test_fileinput.py diff --git a/src/StdLib/Lib/test/test_fileio.py b/src/extensions/StdLib/Lib/test/test_fileio.py similarity index 100% rename from src/StdLib/Lib/test/test_fileio.py rename to src/extensions/StdLib/Lib/test/test_fileio.py diff --git a/src/StdLib/Lib/test/test_finalization.py b/src/extensions/StdLib/Lib/test/test_finalization.py similarity index 100% rename from src/StdLib/Lib/test/test_finalization.py rename to src/extensions/StdLib/Lib/test/test_finalization.py diff --git a/src/StdLib/Lib/test/test_float.py b/src/extensions/StdLib/Lib/test/test_float.py similarity index 100% rename from src/StdLib/Lib/test/test_float.py rename to src/extensions/StdLib/Lib/test/test_float.py diff --git a/src/StdLib/Lib/test/test_flufl.py b/src/extensions/StdLib/Lib/test/test_flufl.py similarity index 100% rename from src/StdLib/Lib/test/test_flufl.py rename to src/extensions/StdLib/Lib/test/test_flufl.py diff --git a/src/StdLib/Lib/test/test_fnmatch.py b/src/extensions/StdLib/Lib/test/test_fnmatch.py similarity index 100% rename from src/StdLib/Lib/test/test_fnmatch.py rename to src/extensions/StdLib/Lib/test/test_fnmatch.py diff --git a/src/StdLib/Lib/test/test_fork1.py b/src/extensions/StdLib/Lib/test/test_fork1.py similarity index 100% rename from src/StdLib/Lib/test/test_fork1.py rename to src/extensions/StdLib/Lib/test/test_fork1.py diff --git a/src/StdLib/Lib/test/test_format.py b/src/extensions/StdLib/Lib/test/test_format.py similarity index 100% rename from src/StdLib/Lib/test/test_format.py rename to src/extensions/StdLib/Lib/test/test_format.py diff --git a/src/StdLib/Lib/test/test_fractions.py b/src/extensions/StdLib/Lib/test/test_fractions.py similarity index 100% rename from src/StdLib/Lib/test/test_fractions.py rename to src/extensions/StdLib/Lib/test/test_fractions.py diff --git a/src/StdLib/Lib/test/test_frame.py b/src/extensions/StdLib/Lib/test/test_frame.py similarity index 100% rename from src/StdLib/Lib/test/test_frame.py rename to src/extensions/StdLib/Lib/test/test_frame.py diff --git a/src/StdLib/Lib/test/test_fstring.py b/src/extensions/StdLib/Lib/test/test_fstring.py similarity index 100% rename from src/StdLib/Lib/test/test_fstring.py rename to src/extensions/StdLib/Lib/test/test_fstring.py diff --git a/src/StdLib/Lib/test/test_ftplib.py b/src/extensions/StdLib/Lib/test/test_ftplib.py similarity index 100% rename from src/StdLib/Lib/test/test_ftplib.py rename to src/extensions/StdLib/Lib/test/test_ftplib.py diff --git a/src/StdLib/Lib/test/test_funcattrs.py b/src/extensions/StdLib/Lib/test/test_funcattrs.py similarity index 100% rename from src/StdLib/Lib/test/test_funcattrs.py rename to src/extensions/StdLib/Lib/test/test_funcattrs.py diff --git a/src/StdLib/Lib/test/test_functools.py b/src/extensions/StdLib/Lib/test/test_functools.py similarity index 100% rename from src/StdLib/Lib/test/test_functools.py rename to src/extensions/StdLib/Lib/test/test_functools.py diff --git a/src/StdLib/Lib/test/test_future.py b/src/extensions/StdLib/Lib/test/test_future.py similarity index 100% rename from src/StdLib/Lib/test/test_future.py rename to src/extensions/StdLib/Lib/test/test_future.py diff --git a/src/StdLib/Lib/test/test_future3.py b/src/extensions/StdLib/Lib/test/test_future3.py similarity index 100% rename from src/StdLib/Lib/test/test_future3.py rename to src/extensions/StdLib/Lib/test/test_future3.py diff --git a/src/StdLib/Lib/test/test_future4.py b/src/extensions/StdLib/Lib/test/test_future4.py similarity index 100% rename from src/StdLib/Lib/test/test_future4.py rename to src/extensions/StdLib/Lib/test/test_future4.py diff --git a/src/StdLib/Lib/test/test_future5.py b/src/extensions/StdLib/Lib/test/test_future5.py similarity index 100% rename from src/StdLib/Lib/test/test_future5.py rename to src/extensions/StdLib/Lib/test/test_future5.py diff --git a/src/StdLib/Lib/test/test_gc.py b/src/extensions/StdLib/Lib/test/test_gc.py similarity index 100% rename from src/StdLib/Lib/test/test_gc.py rename to src/extensions/StdLib/Lib/test/test_gc.py diff --git a/src/StdLib/Lib/test/test_gdb.py b/src/extensions/StdLib/Lib/test/test_gdb.py similarity index 100% rename from src/StdLib/Lib/test/test_gdb.py rename to src/extensions/StdLib/Lib/test/test_gdb.py diff --git a/src/StdLib/Lib/test/test_generators.py b/src/extensions/StdLib/Lib/test/test_generators.py similarity index 100% rename from src/StdLib/Lib/test/test_generators.py rename to src/extensions/StdLib/Lib/test/test_generators.py diff --git a/src/StdLib/Lib/test/test_genericpath.py b/src/extensions/StdLib/Lib/test/test_genericpath.py similarity index 100% rename from src/StdLib/Lib/test/test_genericpath.py rename to src/extensions/StdLib/Lib/test/test_genericpath.py diff --git a/src/StdLib/Lib/test/test_genexps.py b/src/extensions/StdLib/Lib/test/test_genexps.py similarity index 100% rename from src/StdLib/Lib/test/test_genexps.py rename to src/extensions/StdLib/Lib/test/test_genexps.py diff --git a/src/StdLib/Lib/test/test_getargs2.py b/src/extensions/StdLib/Lib/test/test_getargs2.py similarity index 100% rename from src/StdLib/Lib/test/test_getargs2.py rename to src/extensions/StdLib/Lib/test/test_getargs2.py diff --git a/src/StdLib/Lib/test/test_getopt.py b/src/extensions/StdLib/Lib/test/test_getopt.py similarity index 100% rename from src/StdLib/Lib/test/test_getopt.py rename to src/extensions/StdLib/Lib/test/test_getopt.py diff --git a/src/StdLib/Lib/test/test_getpass.py b/src/extensions/StdLib/Lib/test/test_getpass.py similarity index 100% rename from src/StdLib/Lib/test/test_getpass.py rename to src/extensions/StdLib/Lib/test/test_getpass.py diff --git a/src/StdLib/Lib/test/test_gettext.py b/src/extensions/StdLib/Lib/test/test_gettext.py similarity index 100% rename from src/StdLib/Lib/test/test_gettext.py rename to src/extensions/StdLib/Lib/test/test_gettext.py diff --git a/src/StdLib/Lib/test/test_glob.py b/src/extensions/StdLib/Lib/test/test_glob.py similarity index 100% rename from src/StdLib/Lib/test/test_glob.py rename to src/extensions/StdLib/Lib/test/test_glob.py diff --git a/src/StdLib/Lib/test/test_global.py b/src/extensions/StdLib/Lib/test/test_global.py similarity index 100% rename from src/StdLib/Lib/test/test_global.py rename to src/extensions/StdLib/Lib/test/test_global.py diff --git a/src/StdLib/Lib/test/test_grammar.py b/src/extensions/StdLib/Lib/test/test_grammar.py similarity index 100% rename from src/StdLib/Lib/test/test_grammar.py rename to src/extensions/StdLib/Lib/test/test_grammar.py diff --git a/src/StdLib/Lib/test/test_grp.py b/src/extensions/StdLib/Lib/test/test_grp.py similarity index 100% rename from src/StdLib/Lib/test/test_grp.py rename to src/extensions/StdLib/Lib/test/test_grp.py diff --git a/src/StdLib/Lib/test/test_gzip.py b/src/extensions/StdLib/Lib/test/test_gzip.py similarity index 100% rename from src/StdLib/Lib/test/test_gzip.py rename to src/extensions/StdLib/Lib/test/test_gzip.py diff --git a/src/StdLib/Lib/test/test_hash.py b/src/extensions/StdLib/Lib/test/test_hash.py similarity index 100% rename from src/StdLib/Lib/test/test_hash.py rename to src/extensions/StdLib/Lib/test/test_hash.py diff --git a/src/StdLib/Lib/test/test_hashlib.py b/src/extensions/StdLib/Lib/test/test_hashlib.py similarity index 100% rename from src/StdLib/Lib/test/test_hashlib.py rename to src/extensions/StdLib/Lib/test/test_hashlib.py diff --git a/src/StdLib/Lib/test/test_heapq.py b/src/extensions/StdLib/Lib/test/test_heapq.py similarity index 100% rename from src/StdLib/Lib/test/test_heapq.py rename to src/extensions/StdLib/Lib/test/test_heapq.py diff --git a/src/StdLib/Lib/test/test_hmac.py b/src/extensions/StdLib/Lib/test/test_hmac.py similarity index 100% rename from src/StdLib/Lib/test/test_hmac.py rename to src/extensions/StdLib/Lib/test/test_hmac.py diff --git a/src/StdLib/Lib/test/test_html.py b/src/extensions/StdLib/Lib/test/test_html.py similarity index 100% rename from src/StdLib/Lib/test/test_html.py rename to src/extensions/StdLib/Lib/test/test_html.py diff --git a/src/StdLib/Lib/test/test_htmlparser.py b/src/extensions/StdLib/Lib/test/test_htmlparser.py similarity index 100% rename from src/StdLib/Lib/test/test_htmlparser.py rename to src/extensions/StdLib/Lib/test/test_htmlparser.py diff --git a/src/StdLib/Lib/test/test_http_cookiejar.py b/src/extensions/StdLib/Lib/test/test_http_cookiejar.py similarity index 100% rename from src/StdLib/Lib/test/test_http_cookiejar.py rename to src/extensions/StdLib/Lib/test/test_http_cookiejar.py diff --git a/src/StdLib/Lib/test/test_http_cookies.py b/src/extensions/StdLib/Lib/test/test_http_cookies.py similarity index 100% rename from src/StdLib/Lib/test/test_http_cookies.py rename to src/extensions/StdLib/Lib/test/test_http_cookies.py diff --git a/src/StdLib/Lib/test/test_httplib.py b/src/extensions/StdLib/Lib/test/test_httplib.py similarity index 100% rename from src/StdLib/Lib/test/test_httplib.py rename to src/extensions/StdLib/Lib/test/test_httplib.py diff --git a/src/StdLib/Lib/test/test_httpservers.py b/src/extensions/StdLib/Lib/test/test_httpservers.py similarity index 100% rename from src/StdLib/Lib/test/test_httpservers.py rename to src/extensions/StdLib/Lib/test/test_httpservers.py diff --git a/src/StdLib/Lib/test/test_idle.py b/src/extensions/StdLib/Lib/test/test_idle.py similarity index 100% rename from src/StdLib/Lib/test/test_idle.py rename to src/extensions/StdLib/Lib/test/test_idle.py diff --git a/src/StdLib/Lib/test/test_imaplib.py b/src/extensions/StdLib/Lib/test/test_imaplib.py similarity index 100% rename from src/StdLib/Lib/test/test_imaplib.py rename to src/extensions/StdLib/Lib/test/test_imaplib.py diff --git a/src/StdLib/Lib/test/test_imghdr.py b/src/extensions/StdLib/Lib/test/test_imghdr.py similarity index 100% rename from src/StdLib/Lib/test/test_imghdr.py rename to src/extensions/StdLib/Lib/test/test_imghdr.py diff --git a/src/StdLib/Lib/test/test_imp.py b/src/extensions/StdLib/Lib/test/test_imp.py similarity index 100% rename from src/StdLib/Lib/test/test_imp.py rename to src/extensions/StdLib/Lib/test/test_imp.py diff --git a/src/StdLib/Lib/test/test_import.py b/src/extensions/StdLib/Lib/test/test_import.py similarity index 100% rename from src/StdLib/Lib/test/test_import.py rename to src/extensions/StdLib/Lib/test/test_import.py diff --git a/src/StdLib/Lib/test/test_importlib/__init__.py b/src/extensions/StdLib/Lib/test/test_importlib/__init__.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/__init__.py rename to src/extensions/StdLib/Lib/test/test_importlib/__init__.py diff --git a/src/StdLib/Lib/test/test_importlib/__main__.py b/src/extensions/StdLib/Lib/test/test_importlib/__main__.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/__main__.py rename to src/extensions/StdLib/Lib/test/test_importlib/__main__.py diff --git a/src/StdLib/Lib/test/test_importlib/abc.py b/src/extensions/StdLib/Lib/test/test_importlib/abc.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/abc.py rename to src/extensions/StdLib/Lib/test/test_importlib/abc.py diff --git a/src/StdLib/Lib/test/test_importlib/builtin/__init__.py b/src/extensions/StdLib/Lib/test/test_importlib/builtin/__init__.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/builtin/__init__.py rename to src/extensions/StdLib/Lib/test/test_importlib/builtin/__init__.py diff --git a/src/StdLib/Lib/test/test_importlib/builtin/__main__.py b/src/extensions/StdLib/Lib/test/test_importlib/builtin/__main__.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/builtin/__main__.py rename to src/extensions/StdLib/Lib/test/test_importlib/builtin/__main__.py diff --git a/src/StdLib/Lib/test/test_importlib/builtin/test_finder.py b/src/extensions/StdLib/Lib/test/test_importlib/builtin/test_finder.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/builtin/test_finder.py rename to src/extensions/StdLib/Lib/test/test_importlib/builtin/test_finder.py diff --git a/src/StdLib/Lib/test/test_importlib/builtin/test_loader.py b/src/extensions/StdLib/Lib/test/test_importlib/builtin/test_loader.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/builtin/test_loader.py rename to src/extensions/StdLib/Lib/test/test_importlib/builtin/test_loader.py diff --git a/src/StdLib/Lib/test/test_importlib/builtin/util.py b/src/extensions/StdLib/Lib/test/test_importlib/builtin/util.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/builtin/util.py rename to src/extensions/StdLib/Lib/test/test_importlib/builtin/util.py diff --git a/src/StdLib/Lib/test/test_importlib/extension/__init__.py b/src/extensions/StdLib/Lib/test/test_importlib/extension/__init__.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/extension/__init__.py rename to src/extensions/StdLib/Lib/test/test_importlib/extension/__init__.py diff --git a/src/StdLib/Lib/test/test_importlib/extension/__main__.py b/src/extensions/StdLib/Lib/test/test_importlib/extension/__main__.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/extension/__main__.py rename to src/extensions/StdLib/Lib/test/test_importlib/extension/__main__.py diff --git a/src/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py b/src/extensions/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py rename to src/extensions/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py diff --git a/src/StdLib/Lib/test/test_importlib/extension/test_finder.py b/src/extensions/StdLib/Lib/test/test_importlib/extension/test_finder.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/extension/test_finder.py rename to src/extensions/StdLib/Lib/test/test_importlib/extension/test_finder.py diff --git a/src/StdLib/Lib/test/test_importlib/extension/test_loader.py b/src/extensions/StdLib/Lib/test/test_importlib/extension/test_loader.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/extension/test_loader.py rename to src/extensions/StdLib/Lib/test/test_importlib/extension/test_loader.py diff --git a/src/StdLib/Lib/test/test_importlib/extension/test_path_hook.py b/src/extensions/StdLib/Lib/test/test_importlib/extension/test_path_hook.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/extension/test_path_hook.py rename to src/extensions/StdLib/Lib/test/test_importlib/extension/test_path_hook.py diff --git a/src/StdLib/Lib/test/test_importlib/extension/util.py b/src/extensions/StdLib/Lib/test/test_importlib/extension/util.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/extension/util.py rename to src/extensions/StdLib/Lib/test/test_importlib/extension/util.py diff --git a/src/StdLib/Lib/test/test_importlib/frozen/__init__.py b/src/extensions/StdLib/Lib/test/test_importlib/frozen/__init__.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/frozen/__init__.py rename to src/extensions/StdLib/Lib/test/test_importlib/frozen/__init__.py diff --git a/src/StdLib/Lib/test/test_importlib/frozen/__main__.py b/src/extensions/StdLib/Lib/test/test_importlib/frozen/__main__.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/frozen/__main__.py rename to src/extensions/StdLib/Lib/test/test_importlib/frozen/__main__.py diff --git a/src/StdLib/Lib/test/test_importlib/frozen/test_finder.py b/src/extensions/StdLib/Lib/test/test_importlib/frozen/test_finder.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/frozen/test_finder.py rename to src/extensions/StdLib/Lib/test/test_importlib/frozen/test_finder.py diff --git a/src/StdLib/Lib/test/test_importlib/frozen/test_loader.py b/src/extensions/StdLib/Lib/test/test_importlib/frozen/test_loader.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/frozen/test_loader.py rename to src/extensions/StdLib/Lib/test/test_importlib/frozen/test_loader.py diff --git a/src/StdLib/Lib/test/test_importlib/import_/__init__.py b/src/extensions/StdLib/Lib/test/test_importlib/import_/__init__.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/import_/__init__.py rename to src/extensions/StdLib/Lib/test/test_importlib/import_/__init__.py diff --git a/src/StdLib/Lib/test/test_importlib/import_/__main__.py b/src/extensions/StdLib/Lib/test/test_importlib/import_/__main__.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/import_/__main__.py rename to src/extensions/StdLib/Lib/test/test_importlib/import_/__main__.py diff --git a/src/StdLib/Lib/test/test_importlib/import_/test___loader__.py b/src/extensions/StdLib/Lib/test/test_importlib/import_/test___loader__.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/import_/test___loader__.py rename to src/extensions/StdLib/Lib/test/test_importlib/import_/test___loader__.py diff --git a/src/StdLib/Lib/test/test_importlib/import_/test___package__.py b/src/extensions/StdLib/Lib/test/test_importlib/import_/test___package__.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/import_/test___package__.py rename to src/extensions/StdLib/Lib/test/test_importlib/import_/test___package__.py diff --git a/src/StdLib/Lib/test/test_importlib/import_/test_api.py b/src/extensions/StdLib/Lib/test/test_importlib/import_/test_api.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/import_/test_api.py rename to src/extensions/StdLib/Lib/test/test_importlib/import_/test_api.py diff --git a/src/StdLib/Lib/test/test_importlib/import_/test_caching.py b/src/extensions/StdLib/Lib/test/test_importlib/import_/test_caching.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/import_/test_caching.py rename to src/extensions/StdLib/Lib/test/test_importlib/import_/test_caching.py diff --git a/src/StdLib/Lib/test/test_importlib/import_/test_fromlist.py b/src/extensions/StdLib/Lib/test/test_importlib/import_/test_fromlist.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/import_/test_fromlist.py rename to src/extensions/StdLib/Lib/test/test_importlib/import_/test_fromlist.py diff --git a/src/StdLib/Lib/test/test_importlib/import_/test_meta_path.py b/src/extensions/StdLib/Lib/test/test_importlib/import_/test_meta_path.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/import_/test_meta_path.py rename to src/extensions/StdLib/Lib/test/test_importlib/import_/test_meta_path.py diff --git a/src/StdLib/Lib/test/test_importlib/import_/test_packages.py b/src/extensions/StdLib/Lib/test/test_importlib/import_/test_packages.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/import_/test_packages.py rename to src/extensions/StdLib/Lib/test/test_importlib/import_/test_packages.py diff --git a/src/StdLib/Lib/test/test_importlib/import_/test_path.py b/src/extensions/StdLib/Lib/test/test_importlib/import_/test_path.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/import_/test_path.py rename to src/extensions/StdLib/Lib/test/test_importlib/import_/test_path.py diff --git a/src/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py b/src/extensions/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py rename to src/extensions/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py diff --git a/src/StdLib/Lib/test/test_importlib/import_/util.py b/src/extensions/StdLib/Lib/test/test_importlib/import_/util.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/import_/util.py rename to src/extensions/StdLib/Lib/test/test_importlib/import_/util.py diff --git a/src/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py b/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py rename to src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py diff --git a/src/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py b/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py rename to src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py diff --git a/src/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip b/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip similarity index 100% rename from src/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip rename to src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip diff --git a/src/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py b/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py rename to src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py diff --git a/src/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty b/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty similarity index 100% rename from src/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty rename to src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty diff --git a/src/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip b/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip similarity index 100% rename from src/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip rename to src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip diff --git a/src/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py b/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py rename to src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py diff --git a/src/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py b/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py rename to src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py diff --git a/src/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py b/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py rename to src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py diff --git a/src/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py b/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py rename to src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py diff --git a/src/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py b/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py rename to src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py diff --git a/src/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py b/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py rename to src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py diff --git a/src/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py b/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py rename to src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py diff --git a/src/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip b/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip similarity index 100% rename from src/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip rename to src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip diff --git a/src/StdLib/Lib/test/test_importlib/regrtest.py b/src/extensions/StdLib/Lib/test/test_importlib/regrtest.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/regrtest.py rename to src/extensions/StdLib/Lib/test/test_importlib/regrtest.py diff --git a/src/StdLib/Lib/test/test_importlib/source/__init__.py b/src/extensions/StdLib/Lib/test/test_importlib/source/__init__.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/source/__init__.py rename to src/extensions/StdLib/Lib/test/test_importlib/source/__init__.py diff --git a/src/StdLib/Lib/test/test_importlib/source/__main__.py b/src/extensions/StdLib/Lib/test/test_importlib/source/__main__.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/source/__main__.py rename to src/extensions/StdLib/Lib/test/test_importlib/source/__main__.py diff --git a/src/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py b/src/extensions/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py rename to src/extensions/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py diff --git a/src/StdLib/Lib/test/test_importlib/source/test_file_loader.py b/src/extensions/StdLib/Lib/test/test_importlib/source/test_file_loader.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/source/test_file_loader.py rename to src/extensions/StdLib/Lib/test/test_importlib/source/test_file_loader.py diff --git a/src/StdLib/Lib/test/test_importlib/source/test_finder.py b/src/extensions/StdLib/Lib/test/test_importlib/source/test_finder.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/source/test_finder.py rename to src/extensions/StdLib/Lib/test/test_importlib/source/test_finder.py diff --git a/src/StdLib/Lib/test/test_importlib/source/test_path_hook.py b/src/extensions/StdLib/Lib/test/test_importlib/source/test_path_hook.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/source/test_path_hook.py rename to src/extensions/StdLib/Lib/test/test_importlib/source/test_path_hook.py diff --git a/src/StdLib/Lib/test/test_importlib/source/test_source_encoding.py b/src/extensions/StdLib/Lib/test/test_importlib/source/test_source_encoding.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/source/test_source_encoding.py rename to src/extensions/StdLib/Lib/test/test_importlib/source/test_source_encoding.py diff --git a/src/StdLib/Lib/test/test_importlib/source/util.py b/src/extensions/StdLib/Lib/test/test_importlib/source/util.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/source/util.py rename to src/extensions/StdLib/Lib/test/test_importlib/source/util.py diff --git a/src/StdLib/Lib/test/test_importlib/test_abc.py b/src/extensions/StdLib/Lib/test/test_importlib/test_abc.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/test_abc.py rename to src/extensions/StdLib/Lib/test/test_importlib/test_abc.py diff --git a/src/StdLib/Lib/test/test_importlib/test_api.py b/src/extensions/StdLib/Lib/test/test_importlib/test_api.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/test_api.py rename to src/extensions/StdLib/Lib/test/test_importlib/test_api.py diff --git a/src/StdLib/Lib/test/test_importlib/test_locks.py b/src/extensions/StdLib/Lib/test/test_importlib/test_locks.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/test_locks.py rename to src/extensions/StdLib/Lib/test/test_importlib/test_locks.py diff --git a/src/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py b/src/extensions/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py rename to src/extensions/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py diff --git a/src/StdLib/Lib/test/test_importlib/test_spec.py b/src/extensions/StdLib/Lib/test/test_importlib/test_spec.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/test_spec.py rename to src/extensions/StdLib/Lib/test/test_importlib/test_spec.py diff --git a/src/StdLib/Lib/test/test_importlib/test_util.py b/src/extensions/StdLib/Lib/test/test_importlib/test_util.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/test_util.py rename to src/extensions/StdLib/Lib/test/test_importlib/test_util.py diff --git a/src/StdLib/Lib/test/test_importlib/test_windows.py b/src/extensions/StdLib/Lib/test/test_importlib/test_windows.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/test_windows.py rename to src/extensions/StdLib/Lib/test/test_importlib/test_windows.py diff --git a/src/StdLib/Lib/test/test_importlib/util.py b/src/extensions/StdLib/Lib/test/test_importlib/util.py similarity index 100% rename from src/StdLib/Lib/test/test_importlib/util.py rename to src/extensions/StdLib/Lib/test/test_importlib/util.py diff --git a/src/StdLib/Lib/test/test_index.py b/src/extensions/StdLib/Lib/test/test_index.py similarity index 100% rename from src/StdLib/Lib/test/test_index.py rename to src/extensions/StdLib/Lib/test/test_index.py diff --git a/src/StdLib/Lib/test/test_inspect.py b/src/extensions/StdLib/Lib/test/test_inspect.py similarity index 100% rename from src/StdLib/Lib/test/test_inspect.py rename to src/extensions/StdLib/Lib/test/test_inspect.py diff --git a/src/StdLib/Lib/test/test_int.py b/src/extensions/StdLib/Lib/test/test_int.py similarity index 100% rename from src/StdLib/Lib/test/test_int.py rename to src/extensions/StdLib/Lib/test/test_int.py diff --git a/src/StdLib/Lib/test/test_int_literal.py b/src/extensions/StdLib/Lib/test/test_int_literal.py similarity index 100% rename from src/StdLib/Lib/test/test_int_literal.py rename to src/extensions/StdLib/Lib/test/test_int_literal.py diff --git a/src/StdLib/Lib/test/test_io.py b/src/extensions/StdLib/Lib/test/test_io.py similarity index 100% rename from src/StdLib/Lib/test/test_io.py rename to src/extensions/StdLib/Lib/test/test_io.py diff --git a/src/StdLib/Lib/test/test_ioctl.py b/src/extensions/StdLib/Lib/test/test_ioctl.py similarity index 100% rename from src/StdLib/Lib/test/test_ioctl.py rename to src/extensions/StdLib/Lib/test/test_ioctl.py diff --git a/src/StdLib/Lib/test/test_ipaddress.py b/src/extensions/StdLib/Lib/test/test_ipaddress.py similarity index 100% rename from src/StdLib/Lib/test/test_ipaddress.py rename to src/extensions/StdLib/Lib/test/test_ipaddress.py diff --git a/src/StdLib/Lib/test/test_isinstance.py b/src/extensions/StdLib/Lib/test/test_isinstance.py similarity index 100% rename from src/StdLib/Lib/test/test_isinstance.py rename to src/extensions/StdLib/Lib/test/test_isinstance.py diff --git a/src/StdLib/Lib/test/test_iter.py b/src/extensions/StdLib/Lib/test/test_iter.py similarity index 100% rename from src/StdLib/Lib/test/test_iter.py rename to src/extensions/StdLib/Lib/test/test_iter.py diff --git a/src/StdLib/Lib/test/test_iterlen.py b/src/extensions/StdLib/Lib/test/test_iterlen.py similarity index 100% rename from src/StdLib/Lib/test/test_iterlen.py rename to src/extensions/StdLib/Lib/test/test_iterlen.py diff --git a/src/StdLib/Lib/test/test_itertools.py b/src/extensions/StdLib/Lib/test/test_itertools.py similarity index 100% rename from src/StdLib/Lib/test/test_itertools.py rename to src/extensions/StdLib/Lib/test/test_itertools.py diff --git a/src/StdLib/Lib/test/test_json/__init__.py b/src/extensions/StdLib/Lib/test/test_json/__init__.py similarity index 100% rename from src/StdLib/Lib/test/test_json/__init__.py rename to src/extensions/StdLib/Lib/test/test_json/__init__.py diff --git a/src/StdLib/Lib/test/test_json/__main__.py b/src/extensions/StdLib/Lib/test/test_json/__main__.py similarity index 100% rename from src/StdLib/Lib/test/test_json/__main__.py rename to src/extensions/StdLib/Lib/test/test_json/__main__.py diff --git a/src/StdLib/Lib/test/test_json/test_decode.py b/src/extensions/StdLib/Lib/test/test_json/test_decode.py similarity index 100% rename from src/StdLib/Lib/test/test_json/test_decode.py rename to src/extensions/StdLib/Lib/test/test_json/test_decode.py diff --git a/src/StdLib/Lib/test/test_json/test_default.py b/src/extensions/StdLib/Lib/test/test_json/test_default.py similarity index 100% rename from src/StdLib/Lib/test/test_json/test_default.py rename to src/extensions/StdLib/Lib/test/test_json/test_default.py diff --git a/src/StdLib/Lib/test/test_json/test_dump.py b/src/extensions/StdLib/Lib/test/test_json/test_dump.py similarity index 100% rename from src/StdLib/Lib/test/test_json/test_dump.py rename to src/extensions/StdLib/Lib/test/test_json/test_dump.py diff --git a/src/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py b/src/extensions/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py similarity index 100% rename from src/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py rename to src/extensions/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py diff --git a/src/StdLib/Lib/test/test_json/test_enum.py b/src/extensions/StdLib/Lib/test/test_json/test_enum.py similarity index 100% rename from src/StdLib/Lib/test/test_json/test_enum.py rename to src/extensions/StdLib/Lib/test/test_json/test_enum.py diff --git a/src/StdLib/Lib/test/test_json/test_fail.py b/src/extensions/StdLib/Lib/test/test_json/test_fail.py similarity index 100% rename from src/StdLib/Lib/test/test_json/test_fail.py rename to src/extensions/StdLib/Lib/test/test_json/test_fail.py diff --git a/src/StdLib/Lib/test/test_json/test_float.py b/src/extensions/StdLib/Lib/test/test_json/test_float.py similarity index 100% rename from src/StdLib/Lib/test/test_json/test_float.py rename to src/extensions/StdLib/Lib/test/test_json/test_float.py diff --git a/src/StdLib/Lib/test/test_json/test_indent.py b/src/extensions/StdLib/Lib/test/test_json/test_indent.py similarity index 100% rename from src/StdLib/Lib/test/test_json/test_indent.py rename to src/extensions/StdLib/Lib/test/test_json/test_indent.py diff --git a/src/StdLib/Lib/test/test_json/test_pass1.py b/src/extensions/StdLib/Lib/test/test_json/test_pass1.py similarity index 100% rename from src/StdLib/Lib/test/test_json/test_pass1.py rename to src/extensions/StdLib/Lib/test/test_json/test_pass1.py diff --git a/src/StdLib/Lib/test/test_json/test_pass2.py b/src/extensions/StdLib/Lib/test/test_json/test_pass2.py similarity index 100% rename from src/StdLib/Lib/test/test_json/test_pass2.py rename to src/extensions/StdLib/Lib/test/test_json/test_pass2.py diff --git a/src/StdLib/Lib/test/test_json/test_pass3.py b/src/extensions/StdLib/Lib/test/test_json/test_pass3.py similarity index 100% rename from src/StdLib/Lib/test/test_json/test_pass3.py rename to src/extensions/StdLib/Lib/test/test_json/test_pass3.py diff --git a/src/StdLib/Lib/test/test_json/test_recursion.py b/src/extensions/StdLib/Lib/test/test_json/test_recursion.py similarity index 100% rename from src/StdLib/Lib/test/test_json/test_recursion.py rename to src/extensions/StdLib/Lib/test/test_json/test_recursion.py diff --git a/src/StdLib/Lib/test/test_json/test_scanstring.py b/src/extensions/StdLib/Lib/test/test_json/test_scanstring.py similarity index 100% rename from src/StdLib/Lib/test/test_json/test_scanstring.py rename to src/extensions/StdLib/Lib/test/test_json/test_scanstring.py diff --git a/src/StdLib/Lib/test/test_json/test_separators.py b/src/extensions/StdLib/Lib/test/test_json/test_separators.py similarity index 100% rename from src/StdLib/Lib/test/test_json/test_separators.py rename to src/extensions/StdLib/Lib/test/test_json/test_separators.py diff --git a/src/StdLib/Lib/test/test_json/test_speedups.py b/src/extensions/StdLib/Lib/test/test_json/test_speedups.py similarity index 100% rename from src/StdLib/Lib/test/test_json/test_speedups.py rename to src/extensions/StdLib/Lib/test/test_json/test_speedups.py diff --git a/src/StdLib/Lib/test/test_json/test_tool.py b/src/extensions/StdLib/Lib/test/test_json/test_tool.py similarity index 100% rename from src/StdLib/Lib/test/test_json/test_tool.py rename to src/extensions/StdLib/Lib/test/test_json/test_tool.py diff --git a/src/StdLib/Lib/test/test_json/test_unicode.py b/src/extensions/StdLib/Lib/test/test_json/test_unicode.py similarity index 100% rename from src/StdLib/Lib/test/test_json/test_unicode.py rename to src/extensions/StdLib/Lib/test/test_json/test_unicode.py diff --git a/src/StdLib/Lib/test/test_keyword.py b/src/extensions/StdLib/Lib/test/test_keyword.py similarity index 100% rename from src/StdLib/Lib/test/test_keyword.py rename to src/extensions/StdLib/Lib/test/test_keyword.py diff --git a/src/StdLib/Lib/test/test_keywordonlyarg.py b/src/extensions/StdLib/Lib/test/test_keywordonlyarg.py similarity index 100% rename from src/StdLib/Lib/test/test_keywordonlyarg.py rename to src/extensions/StdLib/Lib/test/test_keywordonlyarg.py diff --git a/src/StdLib/Lib/test/test_kqueue.py b/src/extensions/StdLib/Lib/test/test_kqueue.py similarity index 100% rename from src/StdLib/Lib/test/test_kqueue.py rename to src/extensions/StdLib/Lib/test/test_kqueue.py diff --git a/src/StdLib/Lib/test/test_largefile.py b/src/extensions/StdLib/Lib/test/test_largefile.py similarity index 100% rename from src/StdLib/Lib/test/test_largefile.py rename to src/extensions/StdLib/Lib/test/test_largefile.py diff --git a/src/StdLib/Lib/test/test_lib2to3.py b/src/extensions/StdLib/Lib/test/test_lib2to3.py similarity index 100% rename from src/StdLib/Lib/test/test_lib2to3.py rename to src/extensions/StdLib/Lib/test/test_lib2to3.py diff --git a/src/StdLib/Lib/test/test_linecache.py b/src/extensions/StdLib/Lib/test/test_linecache.py similarity index 100% rename from src/StdLib/Lib/test/test_linecache.py rename to src/extensions/StdLib/Lib/test/test_linecache.py diff --git a/src/StdLib/Lib/test/test_list.py b/src/extensions/StdLib/Lib/test/test_list.py similarity index 100% rename from src/StdLib/Lib/test/test_list.py rename to src/extensions/StdLib/Lib/test/test_list.py diff --git a/src/StdLib/Lib/test/test_listcomps.py b/src/extensions/StdLib/Lib/test/test_listcomps.py similarity index 100% rename from src/StdLib/Lib/test/test_listcomps.py rename to src/extensions/StdLib/Lib/test/test_listcomps.py diff --git a/src/StdLib/Lib/test/test_locale.py b/src/extensions/StdLib/Lib/test/test_locale.py similarity index 100% rename from src/StdLib/Lib/test/test_locale.py rename to src/extensions/StdLib/Lib/test/test_locale.py diff --git a/src/StdLib/Lib/test/test_logging.py b/src/extensions/StdLib/Lib/test/test_logging.py similarity index 100% rename from src/StdLib/Lib/test/test_logging.py rename to src/extensions/StdLib/Lib/test/test_logging.py diff --git a/src/StdLib/Lib/test/test_long.py b/src/extensions/StdLib/Lib/test/test_long.py similarity index 100% rename from src/StdLib/Lib/test/test_long.py rename to src/extensions/StdLib/Lib/test/test_long.py diff --git a/src/StdLib/Lib/test/test_longexp.py b/src/extensions/StdLib/Lib/test/test_longexp.py similarity index 100% rename from src/StdLib/Lib/test/test_longexp.py rename to src/extensions/StdLib/Lib/test/test_longexp.py diff --git a/src/StdLib/Lib/test/test_lzma.py b/src/extensions/StdLib/Lib/test/test_lzma.py similarity index 100% rename from src/StdLib/Lib/test/test_lzma.py rename to src/extensions/StdLib/Lib/test/test_lzma.py diff --git a/src/StdLib/Lib/test/test_macpath.py b/src/extensions/StdLib/Lib/test/test_macpath.py similarity index 100% rename from src/StdLib/Lib/test/test_macpath.py rename to src/extensions/StdLib/Lib/test/test_macpath.py diff --git a/src/StdLib/Lib/test/test_macurl2path.py b/src/extensions/StdLib/Lib/test/test_macurl2path.py similarity index 100% rename from src/StdLib/Lib/test/test_macurl2path.py rename to src/extensions/StdLib/Lib/test/test_macurl2path.py diff --git a/src/StdLib/Lib/test/test_mailbox.py b/src/extensions/StdLib/Lib/test/test_mailbox.py similarity index 100% rename from src/StdLib/Lib/test/test_mailbox.py rename to src/extensions/StdLib/Lib/test/test_mailbox.py diff --git a/src/StdLib/Lib/test/test_mailcap.py b/src/extensions/StdLib/Lib/test/test_mailcap.py similarity index 100% rename from src/StdLib/Lib/test/test_mailcap.py rename to src/extensions/StdLib/Lib/test/test_mailcap.py diff --git a/src/StdLib/Lib/test/test_marshal.py b/src/extensions/StdLib/Lib/test/test_marshal.py similarity index 100% rename from src/StdLib/Lib/test/test_marshal.py rename to src/extensions/StdLib/Lib/test/test_marshal.py diff --git a/src/StdLib/Lib/test/test_math.py b/src/extensions/StdLib/Lib/test/test_math.py similarity index 100% rename from src/StdLib/Lib/test/test_math.py rename to src/extensions/StdLib/Lib/test/test_math.py diff --git a/src/StdLib/Lib/test/test_memoryio.py b/src/extensions/StdLib/Lib/test/test_memoryio.py similarity index 100% rename from src/StdLib/Lib/test/test_memoryio.py rename to src/extensions/StdLib/Lib/test/test_memoryio.py diff --git a/src/StdLib/Lib/test/test_memoryview.py b/src/extensions/StdLib/Lib/test/test_memoryview.py similarity index 100% rename from src/StdLib/Lib/test/test_memoryview.py rename to src/extensions/StdLib/Lib/test/test_memoryview.py diff --git a/src/StdLib/Lib/test/test_metaclass.py b/src/extensions/StdLib/Lib/test/test_metaclass.py similarity index 100% rename from src/StdLib/Lib/test/test_metaclass.py rename to src/extensions/StdLib/Lib/test/test_metaclass.py diff --git a/src/StdLib/Lib/test/test_mimetypes.py b/src/extensions/StdLib/Lib/test/test_mimetypes.py similarity index 100% rename from src/StdLib/Lib/test/test_mimetypes.py rename to src/extensions/StdLib/Lib/test/test_mimetypes.py diff --git a/src/StdLib/Lib/test/test_minidom.py b/src/extensions/StdLib/Lib/test/test_minidom.py similarity index 100% rename from src/StdLib/Lib/test/test_minidom.py rename to src/extensions/StdLib/Lib/test/test_minidom.py diff --git a/src/StdLib/Lib/test/test_mmap.py b/src/extensions/StdLib/Lib/test/test_mmap.py similarity index 100% rename from src/StdLib/Lib/test/test_mmap.py rename to src/extensions/StdLib/Lib/test/test_mmap.py diff --git a/src/StdLib/Lib/test/test_module.py b/src/extensions/StdLib/Lib/test/test_module.py similarity index 100% rename from src/StdLib/Lib/test/test_module.py rename to src/extensions/StdLib/Lib/test/test_module.py diff --git a/src/StdLib/Lib/test/test_modulefinder.py b/src/extensions/StdLib/Lib/test/test_modulefinder.py similarity index 100% rename from src/StdLib/Lib/test/test_modulefinder.py rename to src/extensions/StdLib/Lib/test/test_modulefinder.py diff --git a/src/StdLib/Lib/test/test_msilib.py b/src/extensions/StdLib/Lib/test/test_msilib.py similarity index 100% rename from src/StdLib/Lib/test/test_msilib.py rename to src/extensions/StdLib/Lib/test/test_msilib.py diff --git a/src/StdLib/Lib/test/test_multibytecodec.py b/src/extensions/StdLib/Lib/test/test_multibytecodec.py similarity index 100% rename from src/StdLib/Lib/test/test_multibytecodec.py rename to src/extensions/StdLib/Lib/test/test_multibytecodec.py diff --git a/src/StdLib/Lib/test/test_multiprocessing_fork.py b/src/extensions/StdLib/Lib/test/test_multiprocessing_fork.py similarity index 100% rename from src/StdLib/Lib/test/test_multiprocessing_fork.py rename to src/extensions/StdLib/Lib/test/test_multiprocessing_fork.py diff --git a/src/StdLib/Lib/test/test_multiprocessing_forkserver.py b/src/extensions/StdLib/Lib/test/test_multiprocessing_forkserver.py similarity index 100% rename from src/StdLib/Lib/test/test_multiprocessing_forkserver.py rename to src/extensions/StdLib/Lib/test/test_multiprocessing_forkserver.py diff --git a/src/StdLib/Lib/test/test_multiprocessing_main_handling.py b/src/extensions/StdLib/Lib/test/test_multiprocessing_main_handling.py similarity index 100% rename from src/StdLib/Lib/test/test_multiprocessing_main_handling.py rename to src/extensions/StdLib/Lib/test/test_multiprocessing_main_handling.py diff --git a/src/StdLib/Lib/test/test_multiprocessing_spawn.py b/src/extensions/StdLib/Lib/test/test_multiprocessing_spawn.py similarity index 100% rename from src/StdLib/Lib/test/test_multiprocessing_spawn.py rename to src/extensions/StdLib/Lib/test/test_multiprocessing_spawn.py diff --git a/src/StdLib/Lib/test/test_netrc.py b/src/extensions/StdLib/Lib/test/test_netrc.py similarity index 100% rename from src/StdLib/Lib/test/test_netrc.py rename to src/extensions/StdLib/Lib/test/test_netrc.py diff --git a/src/StdLib/Lib/test/test_nis.py b/src/extensions/StdLib/Lib/test/test_nis.py similarity index 100% rename from src/StdLib/Lib/test/test_nis.py rename to src/extensions/StdLib/Lib/test/test_nis.py diff --git a/src/StdLib/Lib/test/test_nntplib.py b/src/extensions/StdLib/Lib/test/test_nntplib.py similarity index 100% rename from src/StdLib/Lib/test/test_nntplib.py rename to src/extensions/StdLib/Lib/test/test_nntplib.py diff --git a/src/StdLib/Lib/test/test_normalization.py b/src/extensions/StdLib/Lib/test/test_normalization.py similarity index 100% rename from src/StdLib/Lib/test/test_normalization.py rename to src/extensions/StdLib/Lib/test/test_normalization.py diff --git a/src/StdLib/Lib/test/test_ntpath.py b/src/extensions/StdLib/Lib/test/test_ntpath.py similarity index 100% rename from src/StdLib/Lib/test/test_ntpath.py rename to src/extensions/StdLib/Lib/test/test_ntpath.py diff --git a/src/StdLib/Lib/test/test_numeric_tower.py b/src/extensions/StdLib/Lib/test/test_numeric_tower.py similarity index 100% rename from src/StdLib/Lib/test/test_numeric_tower.py rename to src/extensions/StdLib/Lib/test/test_numeric_tower.py diff --git a/src/StdLib/Lib/test/test_opcodes.py b/src/extensions/StdLib/Lib/test/test_opcodes.py similarity index 100% rename from src/StdLib/Lib/test/test_opcodes.py rename to src/extensions/StdLib/Lib/test/test_opcodes.py diff --git a/src/StdLib/Lib/test/test_openpty.py b/src/extensions/StdLib/Lib/test/test_openpty.py similarity index 100% rename from src/StdLib/Lib/test/test_openpty.py rename to src/extensions/StdLib/Lib/test/test_openpty.py diff --git a/src/StdLib/Lib/test/test_operator.py b/src/extensions/StdLib/Lib/test/test_operator.py similarity index 100% rename from src/StdLib/Lib/test/test_operator.py rename to src/extensions/StdLib/Lib/test/test_operator.py diff --git a/src/StdLib/Lib/test/test_optparse.py b/src/extensions/StdLib/Lib/test/test_optparse.py similarity index 100% rename from src/StdLib/Lib/test/test_optparse.py rename to src/extensions/StdLib/Lib/test/test_optparse.py diff --git a/src/StdLib/Lib/test/test_ordered_dict.py b/src/extensions/StdLib/Lib/test/test_ordered_dict.py similarity index 100% rename from src/StdLib/Lib/test/test_ordered_dict.py rename to src/extensions/StdLib/Lib/test/test_ordered_dict.py diff --git a/src/StdLib/Lib/test/test_os.py b/src/extensions/StdLib/Lib/test/test_os.py similarity index 100% rename from src/StdLib/Lib/test/test_os.py rename to src/extensions/StdLib/Lib/test/test_os.py diff --git a/src/StdLib/Lib/test/test_ossaudiodev.py b/src/extensions/StdLib/Lib/test/test_ossaudiodev.py similarity index 100% rename from src/StdLib/Lib/test/test_ossaudiodev.py rename to src/extensions/StdLib/Lib/test/test_ossaudiodev.py diff --git a/src/StdLib/Lib/test/test_osx_env.py b/src/extensions/StdLib/Lib/test/test_osx_env.py similarity index 100% rename from src/StdLib/Lib/test/test_osx_env.py rename to src/extensions/StdLib/Lib/test/test_osx_env.py diff --git a/src/StdLib/Lib/test/test_parser.py b/src/extensions/StdLib/Lib/test/test_parser.py similarity index 100% rename from src/StdLib/Lib/test/test_parser.py rename to src/extensions/StdLib/Lib/test/test_parser.py diff --git a/src/StdLib/Lib/test/test_pathlib.py b/src/extensions/StdLib/Lib/test/test_pathlib.py similarity index 100% rename from src/StdLib/Lib/test/test_pathlib.py rename to src/extensions/StdLib/Lib/test/test_pathlib.py diff --git a/src/StdLib/Lib/test/test_pdb.py b/src/extensions/StdLib/Lib/test/test_pdb.py similarity index 100% rename from src/StdLib/Lib/test/test_pdb.py rename to src/extensions/StdLib/Lib/test/test_pdb.py diff --git a/src/StdLib/Lib/test/test_peepholer.py b/src/extensions/StdLib/Lib/test/test_peepholer.py similarity index 100% rename from src/StdLib/Lib/test/test_peepholer.py rename to src/extensions/StdLib/Lib/test/test_peepholer.py diff --git a/src/StdLib/Lib/test/test_pep247.py b/src/extensions/StdLib/Lib/test/test_pep247.py similarity index 100% rename from src/StdLib/Lib/test/test_pep247.py rename to src/extensions/StdLib/Lib/test/test_pep247.py diff --git a/src/StdLib/Lib/test/test_pep277.py b/src/extensions/StdLib/Lib/test/test_pep277.py similarity index 100% rename from src/StdLib/Lib/test/test_pep277.py rename to src/extensions/StdLib/Lib/test/test_pep277.py diff --git a/src/StdLib/Lib/test/test_pep292.py b/src/extensions/StdLib/Lib/test/test_pep292.py similarity index 100% rename from src/StdLib/Lib/test/test_pep292.py rename to src/extensions/StdLib/Lib/test/test_pep292.py diff --git a/src/StdLib/Lib/test/test_pep3120.py b/src/extensions/StdLib/Lib/test/test_pep3120.py similarity index 100% rename from src/StdLib/Lib/test/test_pep3120.py rename to src/extensions/StdLib/Lib/test/test_pep3120.py diff --git a/src/StdLib/Lib/test/test_pep3131.py b/src/extensions/StdLib/Lib/test/test_pep3131.py similarity index 100% rename from src/StdLib/Lib/test/test_pep3131.py rename to src/extensions/StdLib/Lib/test/test_pep3131.py diff --git a/src/StdLib/Lib/test/test_pep3151.py b/src/extensions/StdLib/Lib/test/test_pep3151.py similarity index 100% rename from src/StdLib/Lib/test/test_pep3151.py rename to src/extensions/StdLib/Lib/test/test_pep3151.py diff --git a/src/StdLib/Lib/test/test_pep352.py b/src/extensions/StdLib/Lib/test/test_pep352.py similarity index 100% rename from src/StdLib/Lib/test/test_pep352.py rename to src/extensions/StdLib/Lib/test/test_pep352.py diff --git a/src/StdLib/Lib/test/test_pep380.py b/src/extensions/StdLib/Lib/test/test_pep380.py similarity index 100% rename from src/StdLib/Lib/test/test_pep380.py rename to src/extensions/StdLib/Lib/test/test_pep380.py diff --git a/src/StdLib/Lib/test/test_pep479.py b/src/extensions/StdLib/Lib/test/test_pep479.py similarity index 100% rename from src/StdLib/Lib/test/test_pep479.py rename to src/extensions/StdLib/Lib/test/test_pep479.py diff --git a/src/StdLib/Lib/test/test_pickle.py b/src/extensions/StdLib/Lib/test/test_pickle.py similarity index 100% rename from src/StdLib/Lib/test/test_pickle.py rename to src/extensions/StdLib/Lib/test/test_pickle.py diff --git a/src/StdLib/Lib/test/test_pickletools.py b/src/extensions/StdLib/Lib/test/test_pickletools.py similarity index 100% rename from src/StdLib/Lib/test/test_pickletools.py rename to src/extensions/StdLib/Lib/test/test_pickletools.py diff --git a/src/StdLib/Lib/test/test_pipes.py b/src/extensions/StdLib/Lib/test/test_pipes.py similarity index 100% rename from src/StdLib/Lib/test/test_pipes.py rename to src/extensions/StdLib/Lib/test/test_pipes.py diff --git a/src/StdLib/Lib/test/test_pkg.py b/src/extensions/StdLib/Lib/test/test_pkg.py similarity index 100% rename from src/StdLib/Lib/test/test_pkg.py rename to src/extensions/StdLib/Lib/test/test_pkg.py diff --git a/src/StdLib/Lib/test/test_pkgimport.py b/src/extensions/StdLib/Lib/test/test_pkgimport.py similarity index 100% rename from src/StdLib/Lib/test/test_pkgimport.py rename to src/extensions/StdLib/Lib/test/test_pkgimport.py diff --git a/src/StdLib/Lib/test/test_pkgutil.py b/src/extensions/StdLib/Lib/test/test_pkgutil.py similarity index 100% rename from src/StdLib/Lib/test/test_pkgutil.py rename to src/extensions/StdLib/Lib/test/test_pkgutil.py diff --git a/src/StdLib/Lib/test/test_platform.py b/src/extensions/StdLib/Lib/test/test_platform.py similarity index 100% rename from src/StdLib/Lib/test/test_platform.py rename to src/extensions/StdLib/Lib/test/test_platform.py diff --git a/src/StdLib/Lib/test/test_plistlib.py b/src/extensions/StdLib/Lib/test/test_plistlib.py similarity index 100% rename from src/StdLib/Lib/test/test_plistlib.py rename to src/extensions/StdLib/Lib/test/test_plistlib.py diff --git a/src/StdLib/Lib/test/test_poll.py b/src/extensions/StdLib/Lib/test/test_poll.py similarity index 100% rename from src/StdLib/Lib/test/test_poll.py rename to src/extensions/StdLib/Lib/test/test_poll.py diff --git a/src/StdLib/Lib/test/test_popen.py b/src/extensions/StdLib/Lib/test/test_popen.py similarity index 100% rename from src/StdLib/Lib/test/test_popen.py rename to src/extensions/StdLib/Lib/test/test_popen.py diff --git a/src/StdLib/Lib/test/test_poplib.py b/src/extensions/StdLib/Lib/test/test_poplib.py similarity index 100% rename from src/StdLib/Lib/test/test_poplib.py rename to src/extensions/StdLib/Lib/test/test_poplib.py diff --git a/src/StdLib/Lib/test/test_posix.py b/src/extensions/StdLib/Lib/test/test_posix.py similarity index 100% rename from src/StdLib/Lib/test/test_posix.py rename to src/extensions/StdLib/Lib/test/test_posix.py diff --git a/src/StdLib/Lib/test/test_posixpath.py b/src/extensions/StdLib/Lib/test/test_posixpath.py similarity index 100% rename from src/StdLib/Lib/test/test_posixpath.py rename to src/extensions/StdLib/Lib/test/test_posixpath.py diff --git a/src/StdLib/Lib/test/test_pow.py b/src/extensions/StdLib/Lib/test/test_pow.py similarity index 100% rename from src/StdLib/Lib/test/test_pow.py rename to src/extensions/StdLib/Lib/test/test_pow.py diff --git a/src/StdLib/Lib/test/test_pprint.py b/src/extensions/StdLib/Lib/test/test_pprint.py similarity index 100% rename from src/StdLib/Lib/test/test_pprint.py rename to src/extensions/StdLib/Lib/test/test_pprint.py diff --git a/src/StdLib/Lib/test/test_print.py b/src/extensions/StdLib/Lib/test/test_print.py similarity index 100% rename from src/StdLib/Lib/test/test_print.py rename to src/extensions/StdLib/Lib/test/test_print.py diff --git a/src/StdLib/Lib/test/test_profile.py b/src/extensions/StdLib/Lib/test/test_profile.py similarity index 100% rename from src/StdLib/Lib/test/test_profile.py rename to src/extensions/StdLib/Lib/test/test_profile.py diff --git a/src/StdLib/Lib/test/test_property.py b/src/extensions/StdLib/Lib/test/test_property.py similarity index 100% rename from src/StdLib/Lib/test/test_property.py rename to src/extensions/StdLib/Lib/test/test_property.py diff --git a/src/StdLib/Lib/test/test_pstats.py b/src/extensions/StdLib/Lib/test/test_pstats.py similarity index 100% rename from src/StdLib/Lib/test/test_pstats.py rename to src/extensions/StdLib/Lib/test/test_pstats.py diff --git a/src/StdLib/Lib/test/test_pty.py b/src/extensions/StdLib/Lib/test/test_pty.py similarity index 100% rename from src/StdLib/Lib/test/test_pty.py rename to src/extensions/StdLib/Lib/test/test_pty.py diff --git a/src/StdLib/Lib/test/test_pulldom.py b/src/extensions/StdLib/Lib/test/test_pulldom.py similarity index 100% rename from src/StdLib/Lib/test/test_pulldom.py rename to src/extensions/StdLib/Lib/test/test_pulldom.py diff --git a/src/StdLib/Lib/test/test_pwd.py b/src/extensions/StdLib/Lib/test/test_pwd.py similarity index 100% rename from src/StdLib/Lib/test/test_pwd.py rename to src/extensions/StdLib/Lib/test/test_pwd.py diff --git a/src/StdLib/Lib/test/test_py_compile.py b/src/extensions/StdLib/Lib/test/test_py_compile.py similarity index 100% rename from src/StdLib/Lib/test/test_py_compile.py rename to src/extensions/StdLib/Lib/test/test_py_compile.py diff --git a/src/StdLib/Lib/test/test_pyclbr.py b/src/extensions/StdLib/Lib/test/test_pyclbr.py similarity index 100% rename from src/StdLib/Lib/test/test_pyclbr.py rename to src/extensions/StdLib/Lib/test/test_pyclbr.py diff --git a/src/StdLib/Lib/test/test_pydoc.py b/src/extensions/StdLib/Lib/test/test_pydoc.py similarity index 100% rename from src/StdLib/Lib/test/test_pydoc.py rename to src/extensions/StdLib/Lib/test/test_pydoc.py diff --git a/src/StdLib/Lib/test/test_pyexpat.py b/src/extensions/StdLib/Lib/test/test_pyexpat.py similarity index 100% rename from src/StdLib/Lib/test/test_pyexpat.py rename to src/extensions/StdLib/Lib/test/test_pyexpat.py diff --git a/src/StdLib/Lib/test/test_queue.py b/src/extensions/StdLib/Lib/test/test_queue.py similarity index 100% rename from src/StdLib/Lib/test/test_queue.py rename to src/extensions/StdLib/Lib/test/test_queue.py diff --git a/src/StdLib/Lib/test/test_quopri.py b/src/extensions/StdLib/Lib/test/test_quopri.py similarity index 100% rename from src/StdLib/Lib/test/test_quopri.py rename to src/extensions/StdLib/Lib/test/test_quopri.py diff --git a/src/StdLib/Lib/test/test_raise.py b/src/extensions/StdLib/Lib/test/test_raise.py similarity index 100% rename from src/StdLib/Lib/test/test_raise.py rename to src/extensions/StdLib/Lib/test/test_raise.py diff --git a/src/StdLib/Lib/test/test_random.py b/src/extensions/StdLib/Lib/test/test_random.py similarity index 100% rename from src/StdLib/Lib/test/test_random.py rename to src/extensions/StdLib/Lib/test/test_random.py diff --git a/src/StdLib/Lib/test/test_range.py b/src/extensions/StdLib/Lib/test/test_range.py similarity index 100% rename from src/StdLib/Lib/test/test_range.py rename to src/extensions/StdLib/Lib/test/test_range.py diff --git a/src/StdLib/Lib/test/test_re.py b/src/extensions/StdLib/Lib/test/test_re.py similarity index 100% rename from src/StdLib/Lib/test/test_re.py rename to src/extensions/StdLib/Lib/test/test_re.py diff --git a/src/StdLib/Lib/test/test_readline.py b/src/extensions/StdLib/Lib/test/test_readline.py similarity index 100% rename from src/StdLib/Lib/test/test_readline.py rename to src/extensions/StdLib/Lib/test/test_readline.py diff --git a/src/StdLib/Lib/test/test_regrtest.py b/src/extensions/StdLib/Lib/test/test_regrtest.py similarity index 100% rename from src/StdLib/Lib/test/test_regrtest.py rename to src/extensions/StdLib/Lib/test/test_regrtest.py diff --git a/src/StdLib/Lib/test/test_reprlib.py b/src/extensions/StdLib/Lib/test/test_reprlib.py similarity index 100% rename from src/StdLib/Lib/test/test_reprlib.py rename to src/extensions/StdLib/Lib/test/test_reprlib.py diff --git a/src/StdLib/Lib/test/test_resource.py b/src/extensions/StdLib/Lib/test/test_resource.py similarity index 100% rename from src/StdLib/Lib/test/test_resource.py rename to src/extensions/StdLib/Lib/test/test_resource.py diff --git a/src/StdLib/Lib/test/test_richcmp.py b/src/extensions/StdLib/Lib/test/test_richcmp.py similarity index 100% rename from src/StdLib/Lib/test/test_richcmp.py rename to src/extensions/StdLib/Lib/test/test_richcmp.py diff --git a/src/StdLib/Lib/test/test_rlcompleter.py b/src/extensions/StdLib/Lib/test/test_rlcompleter.py similarity index 100% rename from src/StdLib/Lib/test/test_rlcompleter.py rename to src/extensions/StdLib/Lib/test/test_rlcompleter.py diff --git a/src/StdLib/Lib/test/test_robotparser.py b/src/extensions/StdLib/Lib/test/test_robotparser.py similarity index 100% rename from src/StdLib/Lib/test/test_robotparser.py rename to src/extensions/StdLib/Lib/test/test_robotparser.py diff --git a/src/StdLib/Lib/test/test_runpy.py b/src/extensions/StdLib/Lib/test/test_runpy.py similarity index 100% rename from src/StdLib/Lib/test/test_runpy.py rename to src/extensions/StdLib/Lib/test/test_runpy.py diff --git a/src/StdLib/Lib/test/test_sax.py b/src/extensions/StdLib/Lib/test/test_sax.py similarity index 100% rename from src/StdLib/Lib/test/test_sax.py rename to src/extensions/StdLib/Lib/test/test_sax.py diff --git a/src/StdLib/Lib/test/test_sched.py b/src/extensions/StdLib/Lib/test/test_sched.py similarity index 100% rename from src/StdLib/Lib/test/test_sched.py rename to src/extensions/StdLib/Lib/test/test_sched.py diff --git a/src/StdLib/Lib/test/test_scope.py b/src/extensions/StdLib/Lib/test/test_scope.py similarity index 100% rename from src/StdLib/Lib/test/test_scope.py rename to src/extensions/StdLib/Lib/test/test_scope.py diff --git a/src/StdLib/Lib/test/test_script_helper.py b/src/extensions/StdLib/Lib/test/test_script_helper.py similarity index 100% rename from src/StdLib/Lib/test/test_script_helper.py rename to src/extensions/StdLib/Lib/test/test_script_helper.py diff --git a/src/StdLib/Lib/test/test_select.py b/src/extensions/StdLib/Lib/test/test_select.py similarity index 100% rename from src/StdLib/Lib/test/test_select.py rename to src/extensions/StdLib/Lib/test/test_select.py diff --git a/src/StdLib/Lib/test/test_selectors.py b/src/extensions/StdLib/Lib/test/test_selectors.py similarity index 100% rename from src/StdLib/Lib/test/test_selectors.py rename to src/extensions/StdLib/Lib/test/test_selectors.py diff --git a/src/StdLib/Lib/test/test_set.py b/src/extensions/StdLib/Lib/test/test_set.py similarity index 100% rename from src/StdLib/Lib/test/test_set.py rename to src/extensions/StdLib/Lib/test/test_set.py diff --git a/src/StdLib/Lib/test/test_setcomps.py b/src/extensions/StdLib/Lib/test/test_setcomps.py similarity index 100% rename from src/StdLib/Lib/test/test_setcomps.py rename to src/extensions/StdLib/Lib/test/test_setcomps.py diff --git a/src/StdLib/Lib/test/test_shelve.py b/src/extensions/StdLib/Lib/test/test_shelve.py similarity index 100% rename from src/StdLib/Lib/test/test_shelve.py rename to src/extensions/StdLib/Lib/test/test_shelve.py diff --git a/src/StdLib/Lib/test/test_shlex.py b/src/extensions/StdLib/Lib/test/test_shlex.py similarity index 100% rename from src/StdLib/Lib/test/test_shlex.py rename to src/extensions/StdLib/Lib/test/test_shlex.py diff --git a/src/StdLib/Lib/test/test_shutil.py b/src/extensions/StdLib/Lib/test/test_shutil.py similarity index 100% rename from src/StdLib/Lib/test/test_shutil.py rename to src/extensions/StdLib/Lib/test/test_shutil.py diff --git a/src/StdLib/Lib/test/test_signal.py b/src/extensions/StdLib/Lib/test/test_signal.py similarity index 100% rename from src/StdLib/Lib/test/test_signal.py rename to src/extensions/StdLib/Lib/test/test_signal.py diff --git a/src/StdLib/Lib/test/test_site.py b/src/extensions/StdLib/Lib/test/test_site.py similarity index 100% rename from src/StdLib/Lib/test/test_site.py rename to src/extensions/StdLib/Lib/test/test_site.py diff --git a/src/StdLib/Lib/test/test_slice.py b/src/extensions/StdLib/Lib/test/test_slice.py similarity index 100% rename from src/StdLib/Lib/test/test_slice.py rename to src/extensions/StdLib/Lib/test/test_slice.py diff --git a/src/StdLib/Lib/test/test_smtpd.py b/src/extensions/StdLib/Lib/test/test_smtpd.py similarity index 100% rename from src/StdLib/Lib/test/test_smtpd.py rename to src/extensions/StdLib/Lib/test/test_smtpd.py diff --git a/src/StdLib/Lib/test/test_smtplib.py b/src/extensions/StdLib/Lib/test/test_smtplib.py similarity index 100% rename from src/StdLib/Lib/test/test_smtplib.py rename to src/extensions/StdLib/Lib/test/test_smtplib.py diff --git a/src/StdLib/Lib/test/test_smtpnet.py b/src/extensions/StdLib/Lib/test/test_smtpnet.py similarity index 100% rename from src/StdLib/Lib/test/test_smtpnet.py rename to src/extensions/StdLib/Lib/test/test_smtpnet.py diff --git a/src/StdLib/Lib/test/test_sndhdr.py b/src/extensions/StdLib/Lib/test/test_sndhdr.py similarity index 100% rename from src/StdLib/Lib/test/test_sndhdr.py rename to src/extensions/StdLib/Lib/test/test_sndhdr.py diff --git a/src/StdLib/Lib/test/test_socket.py b/src/extensions/StdLib/Lib/test/test_socket.py similarity index 100% rename from src/StdLib/Lib/test/test_socket.py rename to src/extensions/StdLib/Lib/test/test_socket.py diff --git a/src/StdLib/Lib/test/test_socketserver.py b/src/extensions/StdLib/Lib/test/test_socketserver.py similarity index 100% rename from src/StdLib/Lib/test/test_socketserver.py rename to src/extensions/StdLib/Lib/test/test_socketserver.py diff --git a/src/StdLib/Lib/test/test_sort.py b/src/extensions/StdLib/Lib/test/test_sort.py similarity index 100% rename from src/StdLib/Lib/test/test_sort.py rename to src/extensions/StdLib/Lib/test/test_sort.py diff --git a/src/StdLib/Lib/test/test_source_encoding.py b/src/extensions/StdLib/Lib/test/test_source_encoding.py similarity index 100% rename from src/StdLib/Lib/test/test_source_encoding.py rename to src/extensions/StdLib/Lib/test/test_source_encoding.py diff --git a/src/StdLib/Lib/test/test_spwd.py b/src/extensions/StdLib/Lib/test/test_spwd.py similarity index 100% rename from src/StdLib/Lib/test/test_spwd.py rename to src/extensions/StdLib/Lib/test/test_spwd.py diff --git a/src/StdLib/Lib/test/test_sqlite.py b/src/extensions/StdLib/Lib/test/test_sqlite.py similarity index 100% rename from src/StdLib/Lib/test/test_sqlite.py rename to src/extensions/StdLib/Lib/test/test_sqlite.py diff --git a/src/StdLib/Lib/test/test_ssl.py b/src/extensions/StdLib/Lib/test/test_ssl.py similarity index 100% rename from src/StdLib/Lib/test/test_ssl.py rename to src/extensions/StdLib/Lib/test/test_ssl.py diff --git a/src/StdLib/Lib/test/test_startfile.py b/src/extensions/StdLib/Lib/test/test_startfile.py similarity index 100% rename from src/StdLib/Lib/test/test_startfile.py rename to src/extensions/StdLib/Lib/test/test_startfile.py diff --git a/src/StdLib/Lib/test/test_stat.py b/src/extensions/StdLib/Lib/test/test_stat.py similarity index 100% rename from src/StdLib/Lib/test/test_stat.py rename to src/extensions/StdLib/Lib/test/test_stat.py diff --git a/src/StdLib/Lib/test/test_statistics.py b/src/extensions/StdLib/Lib/test/test_statistics.py similarity index 100% rename from src/StdLib/Lib/test/test_statistics.py rename to src/extensions/StdLib/Lib/test/test_statistics.py diff --git a/src/StdLib/Lib/test/test_strftime.py b/src/extensions/StdLib/Lib/test/test_strftime.py similarity index 100% rename from src/StdLib/Lib/test/test_strftime.py rename to src/extensions/StdLib/Lib/test/test_strftime.py diff --git a/src/StdLib/Lib/test/test_string.py b/src/extensions/StdLib/Lib/test/test_string.py similarity index 100% rename from src/StdLib/Lib/test/test_string.py rename to src/extensions/StdLib/Lib/test/test_string.py diff --git a/src/StdLib/Lib/test/test_stringprep.py b/src/extensions/StdLib/Lib/test/test_stringprep.py similarity index 100% rename from src/StdLib/Lib/test/test_stringprep.py rename to src/extensions/StdLib/Lib/test/test_stringprep.py diff --git a/src/StdLib/Lib/test/test_strlit.py b/src/extensions/StdLib/Lib/test/test_strlit.py similarity index 100% rename from src/StdLib/Lib/test/test_strlit.py rename to src/extensions/StdLib/Lib/test/test_strlit.py diff --git a/src/StdLib/Lib/test/test_strptime.py b/src/extensions/StdLib/Lib/test/test_strptime.py similarity index 100% rename from src/StdLib/Lib/test/test_strptime.py rename to src/extensions/StdLib/Lib/test/test_strptime.py diff --git a/src/StdLib/Lib/test/test_strtod.py b/src/extensions/StdLib/Lib/test/test_strtod.py similarity index 100% rename from src/StdLib/Lib/test/test_strtod.py rename to src/extensions/StdLib/Lib/test/test_strtod.py diff --git a/src/StdLib/Lib/test/test_struct.py b/src/extensions/StdLib/Lib/test/test_struct.py similarity index 100% rename from src/StdLib/Lib/test/test_struct.py rename to src/extensions/StdLib/Lib/test/test_struct.py diff --git a/src/StdLib/Lib/test/test_structmembers.py b/src/extensions/StdLib/Lib/test/test_structmembers.py similarity index 100% rename from src/StdLib/Lib/test/test_structmembers.py rename to src/extensions/StdLib/Lib/test/test_structmembers.py diff --git a/src/StdLib/Lib/test/test_structseq.py b/src/extensions/StdLib/Lib/test/test_structseq.py similarity index 100% rename from src/StdLib/Lib/test/test_structseq.py rename to src/extensions/StdLib/Lib/test/test_structseq.py diff --git a/src/StdLib/Lib/test/test_subprocess.py b/src/extensions/StdLib/Lib/test/test_subprocess.py similarity index 100% rename from src/StdLib/Lib/test/test_subprocess.py rename to src/extensions/StdLib/Lib/test/test_subprocess.py diff --git a/src/StdLib/Lib/test/test_sunau.py b/src/extensions/StdLib/Lib/test/test_sunau.py similarity index 100% rename from src/StdLib/Lib/test/test_sunau.py rename to src/extensions/StdLib/Lib/test/test_sunau.py diff --git a/src/StdLib/Lib/test/test_sundry.py b/src/extensions/StdLib/Lib/test/test_sundry.py similarity index 100% rename from src/StdLib/Lib/test/test_sundry.py rename to src/extensions/StdLib/Lib/test/test_sundry.py diff --git a/src/StdLib/Lib/test/test_super.py b/src/extensions/StdLib/Lib/test/test_super.py similarity index 100% rename from src/StdLib/Lib/test/test_super.py rename to src/extensions/StdLib/Lib/test/test_super.py diff --git a/src/StdLib/Lib/test/test_support.py b/src/extensions/StdLib/Lib/test/test_support.py similarity index 100% rename from src/StdLib/Lib/test/test_support.py rename to src/extensions/StdLib/Lib/test/test_support.py diff --git a/src/StdLib/Lib/test/test_symtable.py b/src/extensions/StdLib/Lib/test/test_symtable.py similarity index 100% rename from src/StdLib/Lib/test/test_symtable.py rename to src/extensions/StdLib/Lib/test/test_symtable.py diff --git a/src/StdLib/Lib/test/test_syntax.py b/src/extensions/StdLib/Lib/test/test_syntax.py similarity index 100% rename from src/StdLib/Lib/test/test_syntax.py rename to src/extensions/StdLib/Lib/test/test_syntax.py diff --git a/src/StdLib/Lib/test/test_sys.py b/src/extensions/StdLib/Lib/test/test_sys.py similarity index 100% rename from src/StdLib/Lib/test/test_sys.py rename to src/extensions/StdLib/Lib/test/test_sys.py diff --git a/src/StdLib/Lib/test/test_sys_setprofile.py b/src/extensions/StdLib/Lib/test/test_sys_setprofile.py similarity index 100% rename from src/StdLib/Lib/test/test_sys_setprofile.py rename to src/extensions/StdLib/Lib/test/test_sys_setprofile.py diff --git a/src/StdLib/Lib/test/test_sys_settrace.py b/src/extensions/StdLib/Lib/test/test_sys_settrace.py similarity index 100% rename from src/StdLib/Lib/test/test_sys_settrace.py rename to src/extensions/StdLib/Lib/test/test_sys_settrace.py diff --git a/src/StdLib/Lib/test/test_sysconfig.py b/src/extensions/StdLib/Lib/test/test_sysconfig.py similarity index 100% rename from src/StdLib/Lib/test/test_sysconfig.py rename to src/extensions/StdLib/Lib/test/test_sysconfig.py diff --git a/src/StdLib/Lib/test/test_syslog.py b/src/extensions/StdLib/Lib/test/test_syslog.py similarity index 100% rename from src/StdLib/Lib/test/test_syslog.py rename to src/extensions/StdLib/Lib/test/test_syslog.py diff --git a/src/StdLib/Lib/test/test_tarfile.py b/src/extensions/StdLib/Lib/test/test_tarfile.py similarity index 100% rename from src/StdLib/Lib/test/test_tarfile.py rename to src/extensions/StdLib/Lib/test/test_tarfile.py diff --git a/src/StdLib/Lib/test/test_tcl.py b/src/extensions/StdLib/Lib/test/test_tcl.py similarity index 100% rename from src/StdLib/Lib/test/test_tcl.py rename to src/extensions/StdLib/Lib/test/test_tcl.py diff --git a/src/StdLib/Lib/test/test_telnetlib.py b/src/extensions/StdLib/Lib/test/test_telnetlib.py similarity index 100% rename from src/StdLib/Lib/test/test_telnetlib.py rename to src/extensions/StdLib/Lib/test/test_telnetlib.py diff --git a/src/StdLib/Lib/test/test_tempfile.py b/src/extensions/StdLib/Lib/test/test_tempfile.py similarity index 100% rename from src/StdLib/Lib/test/test_tempfile.py rename to src/extensions/StdLib/Lib/test/test_tempfile.py diff --git a/src/StdLib/Lib/test/test_textwrap.py b/src/extensions/StdLib/Lib/test/test_textwrap.py similarity index 100% rename from src/StdLib/Lib/test/test_textwrap.py rename to src/extensions/StdLib/Lib/test/test_textwrap.py diff --git a/src/StdLib/Lib/test/test_thread.py b/src/extensions/StdLib/Lib/test/test_thread.py similarity index 100% rename from src/StdLib/Lib/test/test_thread.py rename to src/extensions/StdLib/Lib/test/test_thread.py diff --git a/src/StdLib/Lib/test/test_threaded_import.py b/src/extensions/StdLib/Lib/test/test_threaded_import.py similarity index 100% rename from src/StdLib/Lib/test/test_threaded_import.py rename to src/extensions/StdLib/Lib/test/test_threaded_import.py diff --git a/src/StdLib/Lib/test/test_threadedtempfile.py b/src/extensions/StdLib/Lib/test/test_threadedtempfile.py similarity index 100% rename from src/StdLib/Lib/test/test_threadedtempfile.py rename to src/extensions/StdLib/Lib/test/test_threadedtempfile.py diff --git a/src/StdLib/Lib/test/test_threading.py b/src/extensions/StdLib/Lib/test/test_threading.py similarity index 100% rename from src/StdLib/Lib/test/test_threading.py rename to src/extensions/StdLib/Lib/test/test_threading.py diff --git a/src/StdLib/Lib/test/test_threading_local.py b/src/extensions/StdLib/Lib/test/test_threading_local.py similarity index 100% rename from src/StdLib/Lib/test/test_threading_local.py rename to src/extensions/StdLib/Lib/test/test_threading_local.py diff --git a/src/StdLib/Lib/test/test_threadsignals.py b/src/extensions/StdLib/Lib/test/test_threadsignals.py similarity index 100% rename from src/StdLib/Lib/test/test_threadsignals.py rename to src/extensions/StdLib/Lib/test/test_threadsignals.py diff --git a/src/StdLib/Lib/test/test_time.py b/src/extensions/StdLib/Lib/test/test_time.py similarity index 100% rename from src/StdLib/Lib/test/test_time.py rename to src/extensions/StdLib/Lib/test/test_time.py diff --git a/src/StdLib/Lib/test/test_timeit.py b/src/extensions/StdLib/Lib/test/test_timeit.py similarity index 100% rename from src/StdLib/Lib/test/test_timeit.py rename to src/extensions/StdLib/Lib/test/test_timeit.py diff --git a/src/StdLib/Lib/test/test_timeout.py b/src/extensions/StdLib/Lib/test/test_timeout.py similarity index 100% rename from src/StdLib/Lib/test/test_timeout.py rename to src/extensions/StdLib/Lib/test/test_timeout.py diff --git a/src/StdLib/Lib/test/test_tk.py b/src/extensions/StdLib/Lib/test/test_tk.py similarity index 100% rename from src/StdLib/Lib/test/test_tk.py rename to src/extensions/StdLib/Lib/test/test_tk.py diff --git a/src/StdLib/Lib/test/test_tokenize.py b/src/extensions/StdLib/Lib/test/test_tokenize.py similarity index 100% rename from src/StdLib/Lib/test/test_tokenize.py rename to src/extensions/StdLib/Lib/test/test_tokenize.py diff --git a/src/StdLib/Lib/test/test_tools/__init__.py b/src/extensions/StdLib/Lib/test/test_tools/__init__.py similarity index 100% rename from src/StdLib/Lib/test/test_tools/__init__.py rename to src/extensions/StdLib/Lib/test/test_tools/__init__.py diff --git a/src/StdLib/Lib/test/test_tools/__main__.py b/src/extensions/StdLib/Lib/test/test_tools/__main__.py similarity index 100% rename from src/StdLib/Lib/test/test_tools/__main__.py rename to src/extensions/StdLib/Lib/test/test_tools/__main__.py diff --git a/src/StdLib/Lib/test/test_tools/test_gprof2html.py b/src/extensions/StdLib/Lib/test/test_tools/test_gprof2html.py similarity index 100% rename from src/StdLib/Lib/test/test_tools/test_gprof2html.py rename to src/extensions/StdLib/Lib/test/test_tools/test_gprof2html.py diff --git a/src/StdLib/Lib/test/test_tools/test_md5sum.py b/src/extensions/StdLib/Lib/test/test_tools/test_md5sum.py similarity index 100% rename from src/StdLib/Lib/test/test_tools/test_md5sum.py rename to src/extensions/StdLib/Lib/test/test_tools/test_md5sum.py diff --git a/src/StdLib/Lib/test/test_tools/test_pdeps.py b/src/extensions/StdLib/Lib/test/test_tools/test_pdeps.py similarity index 100% rename from src/StdLib/Lib/test/test_tools/test_pdeps.py rename to src/extensions/StdLib/Lib/test/test_tools/test_pdeps.py diff --git a/src/StdLib/Lib/test/test_tools/test_pindent.py b/src/extensions/StdLib/Lib/test/test_tools/test_pindent.py similarity index 100% rename from src/StdLib/Lib/test/test_tools/test_pindent.py rename to src/extensions/StdLib/Lib/test/test_tools/test_pindent.py diff --git a/src/StdLib/Lib/test/test_tools/test_reindent.py b/src/extensions/StdLib/Lib/test/test_tools/test_reindent.py similarity index 100% rename from src/StdLib/Lib/test/test_tools/test_reindent.py rename to src/extensions/StdLib/Lib/test/test_tools/test_reindent.py diff --git a/src/StdLib/Lib/test/test_tools/test_sundry.py b/src/extensions/StdLib/Lib/test/test_tools/test_sundry.py similarity index 100% rename from src/StdLib/Lib/test/test_tools/test_sundry.py rename to src/extensions/StdLib/Lib/test/test_tools/test_sundry.py diff --git a/src/StdLib/Lib/test/test_tools/test_unparse.py b/src/extensions/StdLib/Lib/test/test_tools/test_unparse.py similarity index 100% rename from src/StdLib/Lib/test/test_tools/test_unparse.py rename to src/extensions/StdLib/Lib/test/test_tools/test_unparse.py diff --git a/src/StdLib/Lib/test/test_trace.py b/src/extensions/StdLib/Lib/test/test_trace.py similarity index 100% rename from src/StdLib/Lib/test/test_trace.py rename to src/extensions/StdLib/Lib/test/test_trace.py diff --git a/src/StdLib/Lib/test/test_traceback.py b/src/extensions/StdLib/Lib/test/test_traceback.py similarity index 100% rename from src/StdLib/Lib/test/test_traceback.py rename to src/extensions/StdLib/Lib/test/test_traceback.py diff --git a/src/StdLib/Lib/test/test_tracemalloc.py b/src/extensions/StdLib/Lib/test/test_tracemalloc.py similarity index 100% rename from src/StdLib/Lib/test/test_tracemalloc.py rename to src/extensions/StdLib/Lib/test/test_tracemalloc.py diff --git a/src/StdLib/Lib/test/test_ttk_guionly.py b/src/extensions/StdLib/Lib/test/test_ttk_guionly.py similarity index 100% rename from src/StdLib/Lib/test/test_ttk_guionly.py rename to src/extensions/StdLib/Lib/test/test_ttk_guionly.py diff --git a/src/StdLib/Lib/test/test_ttk_textonly.py b/src/extensions/StdLib/Lib/test/test_ttk_textonly.py similarity index 100% rename from src/StdLib/Lib/test/test_ttk_textonly.py rename to src/extensions/StdLib/Lib/test/test_ttk_textonly.py diff --git a/src/StdLib/Lib/test/test_tuple.py b/src/extensions/StdLib/Lib/test/test_tuple.py similarity index 100% rename from src/StdLib/Lib/test/test_tuple.py rename to src/extensions/StdLib/Lib/test/test_tuple.py diff --git a/src/StdLib/Lib/test/test_typechecks.py b/src/extensions/StdLib/Lib/test/test_typechecks.py similarity index 100% rename from src/StdLib/Lib/test/test_typechecks.py rename to src/extensions/StdLib/Lib/test/test_typechecks.py diff --git a/src/StdLib/Lib/test/test_types.py b/src/extensions/StdLib/Lib/test/test_types.py similarity index 100% rename from src/StdLib/Lib/test/test_types.py rename to src/extensions/StdLib/Lib/test/test_types.py diff --git a/src/StdLib/Lib/test/test_typing.py b/src/extensions/StdLib/Lib/test/test_typing.py similarity index 100% rename from src/StdLib/Lib/test/test_typing.py rename to src/extensions/StdLib/Lib/test/test_typing.py diff --git a/src/StdLib/Lib/test/test_ucn.py b/src/extensions/StdLib/Lib/test/test_ucn.py similarity index 100% rename from src/StdLib/Lib/test/test_ucn.py rename to src/extensions/StdLib/Lib/test/test_ucn.py diff --git a/src/StdLib/Lib/test/test_unary.py b/src/extensions/StdLib/Lib/test/test_unary.py similarity index 100% rename from src/StdLib/Lib/test/test_unary.py rename to src/extensions/StdLib/Lib/test/test_unary.py diff --git a/src/StdLib/Lib/test/test_unicode.py b/src/extensions/StdLib/Lib/test/test_unicode.py similarity index 100% rename from src/StdLib/Lib/test/test_unicode.py rename to src/extensions/StdLib/Lib/test/test_unicode.py diff --git a/src/StdLib/Lib/test/test_unicode_file.py b/src/extensions/StdLib/Lib/test/test_unicode_file.py similarity index 100% rename from src/StdLib/Lib/test/test_unicode_file.py rename to src/extensions/StdLib/Lib/test/test_unicode_file.py diff --git a/src/StdLib/Lib/test/test_unicodedata.py b/src/extensions/StdLib/Lib/test/test_unicodedata.py similarity index 100% rename from src/StdLib/Lib/test/test_unicodedata.py rename to src/extensions/StdLib/Lib/test/test_unicodedata.py diff --git a/src/StdLib/Lib/test/test_unittest.py b/src/extensions/StdLib/Lib/test/test_unittest.py similarity index 100% rename from src/StdLib/Lib/test/test_unittest.py rename to src/extensions/StdLib/Lib/test/test_unittest.py diff --git a/src/StdLib/Lib/test/test_univnewlines.py b/src/extensions/StdLib/Lib/test/test_univnewlines.py similarity index 100% rename from src/StdLib/Lib/test/test_univnewlines.py rename to src/extensions/StdLib/Lib/test/test_univnewlines.py diff --git a/src/StdLib/Lib/test/test_unpack.py b/src/extensions/StdLib/Lib/test/test_unpack.py similarity index 100% rename from src/StdLib/Lib/test/test_unpack.py rename to src/extensions/StdLib/Lib/test/test_unpack.py diff --git a/src/StdLib/Lib/test/test_unpack_ex.py b/src/extensions/StdLib/Lib/test/test_unpack_ex.py similarity index 100% rename from src/StdLib/Lib/test/test_unpack_ex.py rename to src/extensions/StdLib/Lib/test/test_unpack_ex.py diff --git a/src/StdLib/Lib/test/test_urllib.py b/src/extensions/StdLib/Lib/test/test_urllib.py similarity index 100% rename from src/StdLib/Lib/test/test_urllib.py rename to src/extensions/StdLib/Lib/test/test_urllib.py diff --git a/src/StdLib/Lib/test/test_urllib2.py b/src/extensions/StdLib/Lib/test/test_urllib2.py similarity index 100% rename from src/StdLib/Lib/test/test_urllib2.py rename to src/extensions/StdLib/Lib/test/test_urllib2.py diff --git a/src/StdLib/Lib/test/test_urllib2_localnet.py b/src/extensions/StdLib/Lib/test/test_urllib2_localnet.py similarity index 100% rename from src/StdLib/Lib/test/test_urllib2_localnet.py rename to src/extensions/StdLib/Lib/test/test_urllib2_localnet.py diff --git a/src/StdLib/Lib/test/test_urllib2net.py b/src/extensions/StdLib/Lib/test/test_urllib2net.py similarity index 100% rename from src/StdLib/Lib/test/test_urllib2net.py rename to src/extensions/StdLib/Lib/test/test_urllib2net.py diff --git a/src/StdLib/Lib/test/test_urllib_response.py b/src/extensions/StdLib/Lib/test/test_urllib_response.py similarity index 100% rename from src/StdLib/Lib/test/test_urllib_response.py rename to src/extensions/StdLib/Lib/test/test_urllib_response.py diff --git a/src/StdLib/Lib/test/test_urllibnet.py b/src/extensions/StdLib/Lib/test/test_urllibnet.py similarity index 100% rename from src/StdLib/Lib/test/test_urllibnet.py rename to src/extensions/StdLib/Lib/test/test_urllibnet.py diff --git a/src/StdLib/Lib/test/test_urlparse.py b/src/extensions/StdLib/Lib/test/test_urlparse.py similarity index 100% rename from src/StdLib/Lib/test/test_urlparse.py rename to src/extensions/StdLib/Lib/test/test_urlparse.py diff --git a/src/StdLib/Lib/test/test_userdict.py b/src/extensions/StdLib/Lib/test/test_userdict.py similarity index 100% rename from src/StdLib/Lib/test/test_userdict.py rename to src/extensions/StdLib/Lib/test/test_userdict.py diff --git a/src/StdLib/Lib/test/test_userlist.py b/src/extensions/StdLib/Lib/test/test_userlist.py similarity index 100% rename from src/StdLib/Lib/test/test_userlist.py rename to src/extensions/StdLib/Lib/test/test_userlist.py diff --git a/src/StdLib/Lib/test/test_userstring.py b/src/extensions/StdLib/Lib/test/test_userstring.py similarity index 100% rename from src/StdLib/Lib/test/test_userstring.py rename to src/extensions/StdLib/Lib/test/test_userstring.py diff --git a/src/StdLib/Lib/test/test_utf8_mode.py b/src/extensions/StdLib/Lib/test/test_utf8_mode.py similarity index 100% rename from src/StdLib/Lib/test/test_utf8_mode.py rename to src/extensions/StdLib/Lib/test/test_utf8_mode.py diff --git a/src/StdLib/Lib/test/test_uu.py b/src/extensions/StdLib/Lib/test/test_uu.py similarity index 100% rename from src/StdLib/Lib/test/test_uu.py rename to src/extensions/StdLib/Lib/test/test_uu.py diff --git a/src/StdLib/Lib/test/test_uuid.py b/src/extensions/StdLib/Lib/test/test_uuid.py similarity index 100% rename from src/StdLib/Lib/test/test_uuid.py rename to src/extensions/StdLib/Lib/test/test_uuid.py diff --git a/src/StdLib/Lib/test/test_venv.py b/src/extensions/StdLib/Lib/test/test_venv.py similarity index 100% rename from src/StdLib/Lib/test/test_venv.py rename to src/extensions/StdLib/Lib/test/test_venv.py diff --git a/src/StdLib/Lib/test/test_wait3.py b/src/extensions/StdLib/Lib/test/test_wait3.py similarity index 100% rename from src/StdLib/Lib/test/test_wait3.py rename to src/extensions/StdLib/Lib/test/test_wait3.py diff --git a/src/StdLib/Lib/test/test_wait4.py b/src/extensions/StdLib/Lib/test/test_wait4.py similarity index 100% rename from src/StdLib/Lib/test/test_wait4.py rename to src/extensions/StdLib/Lib/test/test_wait4.py diff --git a/src/StdLib/Lib/test/test_warnings.py b/src/extensions/StdLib/Lib/test/test_warnings.py similarity index 100% rename from src/StdLib/Lib/test/test_warnings.py rename to src/extensions/StdLib/Lib/test/test_warnings.py diff --git a/src/StdLib/Lib/test/test_wave.py b/src/extensions/StdLib/Lib/test/test_wave.py similarity index 100% rename from src/StdLib/Lib/test/test_wave.py rename to src/extensions/StdLib/Lib/test/test_wave.py diff --git a/src/StdLib/Lib/test/test_weakref.py b/src/extensions/StdLib/Lib/test/test_weakref.py similarity index 100% rename from src/StdLib/Lib/test/test_weakref.py rename to src/extensions/StdLib/Lib/test/test_weakref.py diff --git a/src/StdLib/Lib/test/test_weakset.py b/src/extensions/StdLib/Lib/test/test_weakset.py similarity index 100% rename from src/StdLib/Lib/test/test_weakset.py rename to src/extensions/StdLib/Lib/test/test_weakset.py diff --git a/src/StdLib/Lib/test/test_webbrowser.py b/src/extensions/StdLib/Lib/test/test_webbrowser.py similarity index 100% rename from src/StdLib/Lib/test/test_webbrowser.py rename to src/extensions/StdLib/Lib/test/test_webbrowser.py diff --git a/src/StdLib/Lib/test/test_winreg.py b/src/extensions/StdLib/Lib/test/test_winreg.py similarity index 100% rename from src/StdLib/Lib/test/test_winreg.py rename to src/extensions/StdLib/Lib/test/test_winreg.py diff --git a/src/StdLib/Lib/test/test_winsound.py b/src/extensions/StdLib/Lib/test/test_winsound.py similarity index 100% rename from src/StdLib/Lib/test/test_winsound.py rename to src/extensions/StdLib/Lib/test/test_winsound.py diff --git a/src/StdLib/Lib/test/test_with.py b/src/extensions/StdLib/Lib/test/test_with.py similarity index 100% rename from src/StdLib/Lib/test/test_with.py rename to src/extensions/StdLib/Lib/test/test_with.py diff --git a/src/StdLib/Lib/test/test_wsgiref.py b/src/extensions/StdLib/Lib/test/test_wsgiref.py similarity index 100% rename from src/StdLib/Lib/test/test_wsgiref.py rename to src/extensions/StdLib/Lib/test/test_wsgiref.py diff --git a/src/StdLib/Lib/test/test_xdrlib.py b/src/extensions/StdLib/Lib/test/test_xdrlib.py similarity index 100% rename from src/StdLib/Lib/test/test_xdrlib.py rename to src/extensions/StdLib/Lib/test/test_xdrlib.py diff --git a/src/StdLib/Lib/test/test_xml_dom_minicompat.py b/src/extensions/StdLib/Lib/test/test_xml_dom_minicompat.py similarity index 100% rename from src/StdLib/Lib/test/test_xml_dom_minicompat.py rename to src/extensions/StdLib/Lib/test/test_xml_dom_minicompat.py diff --git a/src/StdLib/Lib/test/test_xml_etree.py b/src/extensions/StdLib/Lib/test/test_xml_etree.py similarity index 100% rename from src/StdLib/Lib/test/test_xml_etree.py rename to src/extensions/StdLib/Lib/test/test_xml_etree.py diff --git a/src/StdLib/Lib/test/test_xml_etree_c.py b/src/extensions/StdLib/Lib/test/test_xml_etree_c.py similarity index 100% rename from src/StdLib/Lib/test/test_xml_etree_c.py rename to src/extensions/StdLib/Lib/test/test_xml_etree_c.py diff --git a/src/StdLib/Lib/test/test_xmlrpc.py b/src/extensions/StdLib/Lib/test/test_xmlrpc.py similarity index 100% rename from src/StdLib/Lib/test/test_xmlrpc.py rename to src/extensions/StdLib/Lib/test/test_xmlrpc.py diff --git a/src/StdLib/Lib/test/test_xmlrpc_net.py b/src/extensions/StdLib/Lib/test/test_xmlrpc_net.py similarity index 100% rename from src/StdLib/Lib/test/test_xmlrpc_net.py rename to src/extensions/StdLib/Lib/test/test_xmlrpc_net.py diff --git a/src/StdLib/Lib/test/test_zipfile.py b/src/extensions/StdLib/Lib/test/test_zipfile.py similarity index 100% rename from src/StdLib/Lib/test/test_zipfile.py rename to src/extensions/StdLib/Lib/test/test_zipfile.py diff --git a/src/StdLib/Lib/test/test_zipfile64.py b/src/extensions/StdLib/Lib/test/test_zipfile64.py similarity index 100% rename from src/StdLib/Lib/test/test_zipfile64.py rename to src/extensions/StdLib/Lib/test/test_zipfile64.py diff --git a/src/StdLib/Lib/test/test_zipimport.py b/src/extensions/StdLib/Lib/test/test_zipimport.py similarity index 100% rename from src/StdLib/Lib/test/test_zipimport.py rename to src/extensions/StdLib/Lib/test/test_zipimport.py diff --git a/src/StdLib/Lib/test/test_zipimport_support.py b/src/extensions/StdLib/Lib/test/test_zipimport_support.py similarity index 100% rename from src/StdLib/Lib/test/test_zipimport_support.py rename to src/extensions/StdLib/Lib/test/test_zipimport_support.py diff --git a/src/StdLib/Lib/test/test_zlib.py b/src/extensions/StdLib/Lib/test/test_zlib.py similarity index 100% rename from src/StdLib/Lib/test/test_zlib.py rename to src/extensions/StdLib/Lib/test/test_zlib.py diff --git a/src/StdLib/Lib/test/testcodec.py b/src/extensions/StdLib/Lib/test/testcodec.py similarity index 100% rename from src/StdLib/Lib/test/testcodec.py rename to src/extensions/StdLib/Lib/test/testcodec.py diff --git a/src/StdLib/Lib/test/testtar.tar b/src/extensions/StdLib/Lib/test/testtar.tar similarity index 100% rename from src/StdLib/Lib/test/testtar.tar rename to src/extensions/StdLib/Lib/test/testtar.tar diff --git a/src/StdLib/Lib/test/tf_inherit_check.py b/src/extensions/StdLib/Lib/test/tf_inherit_check.py similarity index 100% rename from src/StdLib/Lib/test/tf_inherit_check.py rename to src/extensions/StdLib/Lib/test/tf_inherit_check.py diff --git a/src/StdLib/Lib/test/threaded_import_hangers.py b/src/extensions/StdLib/Lib/test/threaded_import_hangers.py similarity index 100% rename from src/StdLib/Lib/test/threaded_import_hangers.py rename to src/extensions/StdLib/Lib/test/threaded_import_hangers.py diff --git a/src/StdLib/Lib/test/time_hashlib.py b/src/extensions/StdLib/Lib/test/time_hashlib.py similarity index 100% rename from src/StdLib/Lib/test/time_hashlib.py rename to src/extensions/StdLib/Lib/test/time_hashlib.py diff --git a/src/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt b/src/extensions/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt similarity index 100% rename from src/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt rename to src/extensions/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt diff --git a/src/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt b/src/extensions/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt similarity index 100% rename from src/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt rename to src/extensions/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt diff --git a/src/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt b/src/extensions/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt similarity index 100% rename from src/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt rename to src/extensions/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt diff --git a/src/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt b/src/extensions/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt similarity index 100% rename from src/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt rename to src/extensions/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt diff --git a/src/StdLib/Lib/test/tokenize_tests.txt b/src/extensions/StdLib/Lib/test/tokenize_tests.txt similarity index 100% rename from src/StdLib/Lib/test/tokenize_tests.txt rename to src/extensions/StdLib/Lib/test/tokenize_tests.txt diff --git a/src/StdLib/Lib/test/tracedmodules/__init__.py b/src/extensions/StdLib/Lib/test/tracedmodules/__init__.py similarity index 100% rename from src/StdLib/Lib/test/tracedmodules/__init__.py rename to src/extensions/StdLib/Lib/test/tracedmodules/__init__.py diff --git a/src/StdLib/Lib/test/tracedmodules/testmod.py b/src/extensions/StdLib/Lib/test/tracedmodules/testmod.py similarity index 100% rename from src/StdLib/Lib/test/tracedmodules/testmod.py rename to src/extensions/StdLib/Lib/test/tracedmodules/testmod.py diff --git a/src/StdLib/Lib/test/warning_tests.py b/src/extensions/StdLib/Lib/test/warning_tests.py similarity index 100% rename from src/StdLib/Lib/test/warning_tests.py rename to src/extensions/StdLib/Lib/test/warning_tests.py diff --git a/src/StdLib/Lib/test/win_console_handler.py b/src/extensions/StdLib/Lib/test/win_console_handler.py similarity index 100% rename from src/StdLib/Lib/test/win_console_handler.py rename to src/extensions/StdLib/Lib/test/win_console_handler.py diff --git a/src/StdLib/Lib/test/xmltestdata/simple-ns.xml b/src/extensions/StdLib/Lib/test/xmltestdata/simple-ns.xml similarity index 100% rename from src/StdLib/Lib/test/xmltestdata/simple-ns.xml rename to src/extensions/StdLib/Lib/test/xmltestdata/simple-ns.xml diff --git a/src/StdLib/Lib/test/xmltestdata/simple.xml b/src/extensions/StdLib/Lib/test/xmltestdata/simple.xml similarity index 100% rename from src/StdLib/Lib/test/xmltestdata/simple.xml rename to src/extensions/StdLib/Lib/test/xmltestdata/simple.xml diff --git a/src/StdLib/Lib/test/xmltestdata/test.xml b/src/extensions/StdLib/Lib/test/xmltestdata/test.xml similarity index 100% rename from src/StdLib/Lib/test/xmltestdata/test.xml rename to src/extensions/StdLib/Lib/test/xmltestdata/test.xml diff --git a/src/StdLib/Lib/test/xmltestdata/test.xml.out b/src/extensions/StdLib/Lib/test/xmltestdata/test.xml.out similarity index 100% rename from src/StdLib/Lib/test/xmltestdata/test.xml.out rename to src/extensions/StdLib/Lib/test/xmltestdata/test.xml.out diff --git a/src/StdLib/Lib/test/xmltests.py b/src/extensions/StdLib/Lib/test/xmltests.py similarity index 100% rename from src/StdLib/Lib/test/xmltests.py rename to src/extensions/StdLib/Lib/test/xmltests.py diff --git a/src/StdLib/Lib/test/zip_cp437_header.zip b/src/extensions/StdLib/Lib/test/zip_cp437_header.zip similarity index 100% rename from src/StdLib/Lib/test/zip_cp437_header.zip rename to src/extensions/StdLib/Lib/test/zip_cp437_header.zip diff --git a/src/StdLib/Lib/test/zipdir.zip b/src/extensions/StdLib/Lib/test/zipdir.zip similarity index 100% rename from src/StdLib/Lib/test/zipdir.zip rename to src/extensions/StdLib/Lib/test/zipdir.zip diff --git a/src/StdLib/Lib/textwrap.py b/src/extensions/StdLib/Lib/textwrap.py similarity index 100% rename from src/StdLib/Lib/textwrap.py rename to src/extensions/StdLib/Lib/textwrap.py diff --git a/src/StdLib/Lib/this.py b/src/extensions/StdLib/Lib/this.py similarity index 100% rename from src/StdLib/Lib/this.py rename to src/extensions/StdLib/Lib/this.py diff --git a/src/StdLib/Lib/threading.py b/src/extensions/StdLib/Lib/threading.py similarity index 100% rename from src/StdLib/Lib/threading.py rename to src/extensions/StdLib/Lib/threading.py diff --git a/src/StdLib/Lib/timeit.py b/src/extensions/StdLib/Lib/timeit.py similarity index 100% rename from src/StdLib/Lib/timeit.py rename to src/extensions/StdLib/Lib/timeit.py diff --git a/src/StdLib/Lib/tkinter/__init__.py b/src/extensions/StdLib/Lib/tkinter/__init__.py similarity index 100% rename from src/StdLib/Lib/tkinter/__init__.py rename to src/extensions/StdLib/Lib/tkinter/__init__.py diff --git a/src/StdLib/Lib/tkinter/__main__.py b/src/extensions/StdLib/Lib/tkinter/__main__.py similarity index 100% rename from src/StdLib/Lib/tkinter/__main__.py rename to src/extensions/StdLib/Lib/tkinter/__main__.py diff --git a/src/StdLib/Lib/tkinter/_fix.py b/src/extensions/StdLib/Lib/tkinter/_fix.py similarity index 100% rename from src/StdLib/Lib/tkinter/_fix.py rename to src/extensions/StdLib/Lib/tkinter/_fix.py diff --git a/src/StdLib/Lib/tkinter/colorchooser.py b/src/extensions/StdLib/Lib/tkinter/colorchooser.py similarity index 100% rename from src/StdLib/Lib/tkinter/colorchooser.py rename to src/extensions/StdLib/Lib/tkinter/colorchooser.py diff --git a/src/StdLib/Lib/tkinter/commondialog.py b/src/extensions/StdLib/Lib/tkinter/commondialog.py similarity index 100% rename from src/StdLib/Lib/tkinter/commondialog.py rename to src/extensions/StdLib/Lib/tkinter/commondialog.py diff --git a/src/StdLib/Lib/tkinter/constants.py b/src/extensions/StdLib/Lib/tkinter/constants.py similarity index 100% rename from src/StdLib/Lib/tkinter/constants.py rename to src/extensions/StdLib/Lib/tkinter/constants.py diff --git a/src/StdLib/Lib/tkinter/dialog.py b/src/extensions/StdLib/Lib/tkinter/dialog.py similarity index 100% rename from src/StdLib/Lib/tkinter/dialog.py rename to src/extensions/StdLib/Lib/tkinter/dialog.py diff --git a/src/StdLib/Lib/tkinter/dnd.py b/src/extensions/StdLib/Lib/tkinter/dnd.py similarity index 100% rename from src/StdLib/Lib/tkinter/dnd.py rename to src/extensions/StdLib/Lib/tkinter/dnd.py diff --git a/src/StdLib/Lib/tkinter/filedialog.py b/src/extensions/StdLib/Lib/tkinter/filedialog.py similarity index 100% rename from src/StdLib/Lib/tkinter/filedialog.py rename to src/extensions/StdLib/Lib/tkinter/filedialog.py diff --git a/src/StdLib/Lib/tkinter/font.py b/src/extensions/StdLib/Lib/tkinter/font.py similarity index 100% rename from src/StdLib/Lib/tkinter/font.py rename to src/extensions/StdLib/Lib/tkinter/font.py diff --git a/src/StdLib/Lib/tkinter/messagebox.py b/src/extensions/StdLib/Lib/tkinter/messagebox.py similarity index 100% rename from src/StdLib/Lib/tkinter/messagebox.py rename to src/extensions/StdLib/Lib/tkinter/messagebox.py diff --git a/src/StdLib/Lib/tkinter/scrolledtext.py b/src/extensions/StdLib/Lib/tkinter/scrolledtext.py similarity index 100% rename from src/StdLib/Lib/tkinter/scrolledtext.py rename to src/extensions/StdLib/Lib/tkinter/scrolledtext.py diff --git a/src/StdLib/Lib/tkinter/simpledialog.py b/src/extensions/StdLib/Lib/tkinter/simpledialog.py similarity index 100% rename from src/StdLib/Lib/tkinter/simpledialog.py rename to src/extensions/StdLib/Lib/tkinter/simpledialog.py diff --git a/src/StdLib/Lib/tkinter/test/README b/src/extensions/StdLib/Lib/tkinter/test/README similarity index 100% rename from src/StdLib/Lib/tkinter/test/README rename to src/extensions/StdLib/Lib/tkinter/test/README diff --git a/src/StdLib/Lib/tkinter/test/__init__.py b/src/extensions/StdLib/Lib/tkinter/test/__init__.py similarity index 100% rename from src/StdLib/Lib/tkinter/test/__init__.py rename to src/extensions/StdLib/Lib/tkinter/test/__init__.py diff --git a/src/StdLib/Lib/tkinter/test/runtktests.py b/src/extensions/StdLib/Lib/tkinter/test/runtktests.py similarity index 100% rename from src/StdLib/Lib/tkinter/test/runtktests.py rename to src/extensions/StdLib/Lib/tkinter/test/runtktests.py diff --git a/src/StdLib/Lib/tkinter/test/support.py b/src/extensions/StdLib/Lib/tkinter/test/support.py similarity index 100% rename from src/StdLib/Lib/tkinter/test/support.py rename to src/extensions/StdLib/Lib/tkinter/test/support.py diff --git a/src/StdLib/Lib/tkinter/test/test_tkinter/__init__.py b/src/extensions/StdLib/Lib/tkinter/test/test_tkinter/__init__.py similarity index 100% rename from src/StdLib/Lib/tkinter/test/test_tkinter/__init__.py rename to src/extensions/StdLib/Lib/tkinter/test/test_tkinter/__init__.py diff --git a/src/StdLib/Lib/tkinter/test/test_tkinter/test_font.py b/src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_font.py similarity index 100% rename from src/StdLib/Lib/tkinter/test/test_tkinter/test_font.py rename to src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_font.py diff --git a/src/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py b/src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py similarity index 100% rename from src/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py rename to src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py diff --git a/src/StdLib/Lib/tkinter/test/test_tkinter/test_images.py b/src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_images.py similarity index 100% rename from src/StdLib/Lib/tkinter/test/test_tkinter/test_images.py rename to src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_images.py diff --git a/src/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py b/src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py similarity index 100% rename from src/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py rename to src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py diff --git a/src/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py b/src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py similarity index 100% rename from src/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py rename to src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py diff --git a/src/StdLib/Lib/tkinter/test/test_tkinter/test_text.py b/src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_text.py similarity index 100% rename from src/StdLib/Lib/tkinter/test/test_tkinter/test_text.py rename to src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_text.py diff --git a/src/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py b/src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py similarity index 100% rename from src/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py rename to src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py diff --git a/src/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py b/src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py similarity index 100% rename from src/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py rename to src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py diff --git a/src/StdLib/Lib/tkinter/test/test_ttk/__init__.py b/src/extensions/StdLib/Lib/tkinter/test/test_ttk/__init__.py similarity index 100% rename from src/StdLib/Lib/tkinter/test/test_ttk/__init__.py rename to src/extensions/StdLib/Lib/tkinter/test/test_ttk/__init__.py diff --git a/src/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py b/src/extensions/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py similarity index 100% rename from src/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py rename to src/extensions/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py diff --git a/src/StdLib/Lib/tkinter/test/test_ttk/test_functions.py b/src/extensions/StdLib/Lib/tkinter/test/test_ttk/test_functions.py similarity index 100% rename from src/StdLib/Lib/tkinter/test/test_ttk/test_functions.py rename to src/extensions/StdLib/Lib/tkinter/test/test_ttk/test_functions.py diff --git a/src/StdLib/Lib/tkinter/test/test_ttk/test_style.py b/src/extensions/StdLib/Lib/tkinter/test/test_ttk/test_style.py similarity index 100% rename from src/StdLib/Lib/tkinter/test/test_ttk/test_style.py rename to src/extensions/StdLib/Lib/tkinter/test/test_ttk/test_style.py diff --git a/src/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py b/src/extensions/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py similarity index 100% rename from src/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py rename to src/extensions/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py diff --git a/src/StdLib/Lib/tkinter/test/widget_tests.py b/src/extensions/StdLib/Lib/tkinter/test/widget_tests.py similarity index 100% rename from src/StdLib/Lib/tkinter/test/widget_tests.py rename to src/extensions/StdLib/Lib/tkinter/test/widget_tests.py diff --git a/src/StdLib/Lib/tkinter/tix.py b/src/extensions/StdLib/Lib/tkinter/tix.py similarity index 100% rename from src/StdLib/Lib/tkinter/tix.py rename to src/extensions/StdLib/Lib/tkinter/tix.py diff --git a/src/StdLib/Lib/tkinter/ttk.py b/src/extensions/StdLib/Lib/tkinter/ttk.py similarity index 100% rename from src/StdLib/Lib/tkinter/ttk.py rename to src/extensions/StdLib/Lib/tkinter/ttk.py diff --git a/src/StdLib/Lib/token.py b/src/extensions/StdLib/Lib/token.py similarity index 100% rename from src/StdLib/Lib/token.py rename to src/extensions/StdLib/Lib/token.py diff --git a/src/StdLib/Lib/tokenize.py b/src/extensions/StdLib/Lib/tokenize.py similarity index 100% rename from src/StdLib/Lib/tokenize.py rename to src/extensions/StdLib/Lib/tokenize.py diff --git a/src/StdLib/Lib/trace.py b/src/extensions/StdLib/Lib/trace.py similarity index 100% rename from src/StdLib/Lib/trace.py rename to src/extensions/StdLib/Lib/trace.py diff --git a/src/StdLib/Lib/traceback.py b/src/extensions/StdLib/Lib/traceback.py similarity index 100% rename from src/StdLib/Lib/traceback.py rename to src/extensions/StdLib/Lib/traceback.py diff --git a/src/StdLib/Lib/tracemalloc.py b/src/extensions/StdLib/Lib/tracemalloc.py similarity index 100% rename from src/StdLib/Lib/tracemalloc.py rename to src/extensions/StdLib/Lib/tracemalloc.py diff --git a/src/StdLib/Lib/tty.py b/src/extensions/StdLib/Lib/tty.py similarity index 100% rename from src/StdLib/Lib/tty.py rename to src/extensions/StdLib/Lib/tty.py diff --git a/src/StdLib/Lib/turtle.py b/src/extensions/StdLib/Lib/turtle.py similarity index 100% rename from src/StdLib/Lib/turtle.py rename to src/extensions/StdLib/Lib/turtle.py diff --git a/src/StdLib/Lib/turtledemo/__init__.py b/src/extensions/StdLib/Lib/turtledemo/__init__.py similarity index 100% rename from src/StdLib/Lib/turtledemo/__init__.py rename to src/extensions/StdLib/Lib/turtledemo/__init__.py diff --git a/src/StdLib/Lib/turtledemo/__main__.py b/src/extensions/StdLib/Lib/turtledemo/__main__.py similarity index 100% rename from src/StdLib/Lib/turtledemo/__main__.py rename to src/extensions/StdLib/Lib/turtledemo/__main__.py diff --git a/src/StdLib/Lib/turtledemo/bytedesign.py b/src/extensions/StdLib/Lib/turtledemo/bytedesign.py similarity index 100% rename from src/StdLib/Lib/turtledemo/bytedesign.py rename to src/extensions/StdLib/Lib/turtledemo/bytedesign.py diff --git a/src/StdLib/Lib/turtledemo/chaos.py b/src/extensions/StdLib/Lib/turtledemo/chaos.py similarity index 100% rename from src/StdLib/Lib/turtledemo/chaos.py rename to src/extensions/StdLib/Lib/turtledemo/chaos.py diff --git a/src/StdLib/Lib/turtledemo/clock.py b/src/extensions/StdLib/Lib/turtledemo/clock.py similarity index 100% rename from src/StdLib/Lib/turtledemo/clock.py rename to src/extensions/StdLib/Lib/turtledemo/clock.py diff --git a/src/StdLib/Lib/turtledemo/colormixer.py b/src/extensions/StdLib/Lib/turtledemo/colormixer.py similarity index 100% rename from src/StdLib/Lib/turtledemo/colormixer.py rename to src/extensions/StdLib/Lib/turtledemo/colormixer.py diff --git a/src/StdLib/Lib/turtledemo/forest.py b/src/extensions/StdLib/Lib/turtledemo/forest.py similarity index 100% rename from src/StdLib/Lib/turtledemo/forest.py rename to src/extensions/StdLib/Lib/turtledemo/forest.py diff --git a/src/StdLib/Lib/turtledemo/fractalcurves.py b/src/extensions/StdLib/Lib/turtledemo/fractalcurves.py similarity index 100% rename from src/StdLib/Lib/turtledemo/fractalcurves.py rename to src/extensions/StdLib/Lib/turtledemo/fractalcurves.py diff --git a/src/StdLib/Lib/turtledemo/lindenmayer.py b/src/extensions/StdLib/Lib/turtledemo/lindenmayer.py similarity index 100% rename from src/StdLib/Lib/turtledemo/lindenmayer.py rename to src/extensions/StdLib/Lib/turtledemo/lindenmayer.py diff --git a/src/StdLib/Lib/turtledemo/minimal_hanoi.py b/src/extensions/StdLib/Lib/turtledemo/minimal_hanoi.py similarity index 100% rename from src/StdLib/Lib/turtledemo/minimal_hanoi.py rename to src/extensions/StdLib/Lib/turtledemo/minimal_hanoi.py diff --git a/src/StdLib/Lib/turtledemo/nim.py b/src/extensions/StdLib/Lib/turtledemo/nim.py similarity index 100% rename from src/StdLib/Lib/turtledemo/nim.py rename to src/extensions/StdLib/Lib/turtledemo/nim.py diff --git a/src/StdLib/Lib/turtledemo/paint.py b/src/extensions/StdLib/Lib/turtledemo/paint.py similarity index 100% rename from src/StdLib/Lib/turtledemo/paint.py rename to src/extensions/StdLib/Lib/turtledemo/paint.py diff --git a/src/StdLib/Lib/turtledemo/peace.py b/src/extensions/StdLib/Lib/turtledemo/peace.py similarity index 100% rename from src/StdLib/Lib/turtledemo/peace.py rename to src/extensions/StdLib/Lib/turtledemo/peace.py diff --git a/src/StdLib/Lib/turtledemo/penrose.py b/src/extensions/StdLib/Lib/turtledemo/penrose.py similarity index 100% rename from src/StdLib/Lib/turtledemo/penrose.py rename to src/extensions/StdLib/Lib/turtledemo/penrose.py diff --git a/src/StdLib/Lib/turtledemo/planet_and_moon.py b/src/extensions/StdLib/Lib/turtledemo/planet_and_moon.py similarity index 100% rename from src/StdLib/Lib/turtledemo/planet_and_moon.py rename to src/extensions/StdLib/Lib/turtledemo/planet_and_moon.py diff --git a/src/StdLib/Lib/turtledemo/round_dance.py b/src/extensions/StdLib/Lib/turtledemo/round_dance.py similarity index 100% rename from src/StdLib/Lib/turtledemo/round_dance.py rename to src/extensions/StdLib/Lib/turtledemo/round_dance.py diff --git a/src/StdLib/Lib/turtledemo/tree.py b/src/extensions/StdLib/Lib/turtledemo/tree.py similarity index 100% rename from src/StdLib/Lib/turtledemo/tree.py rename to src/extensions/StdLib/Lib/turtledemo/tree.py diff --git a/src/StdLib/Lib/turtledemo/turtle.cfg b/src/extensions/StdLib/Lib/turtledemo/turtle.cfg similarity index 100% rename from src/StdLib/Lib/turtledemo/turtle.cfg rename to src/extensions/StdLib/Lib/turtledemo/turtle.cfg diff --git a/src/StdLib/Lib/turtledemo/two_canvases.py b/src/extensions/StdLib/Lib/turtledemo/two_canvases.py similarity index 100% rename from src/StdLib/Lib/turtledemo/two_canvases.py rename to src/extensions/StdLib/Lib/turtledemo/two_canvases.py diff --git a/src/StdLib/Lib/turtledemo/wikipedia.py b/src/extensions/StdLib/Lib/turtledemo/wikipedia.py similarity index 100% rename from src/StdLib/Lib/turtledemo/wikipedia.py rename to src/extensions/StdLib/Lib/turtledemo/wikipedia.py diff --git a/src/StdLib/Lib/turtledemo/yinyang.py b/src/extensions/StdLib/Lib/turtledemo/yinyang.py similarity index 100% rename from src/StdLib/Lib/turtledemo/yinyang.py rename to src/extensions/StdLib/Lib/turtledemo/yinyang.py diff --git a/src/StdLib/Lib/types.py b/src/extensions/StdLib/Lib/types.py similarity index 100% rename from src/StdLib/Lib/types.py rename to src/extensions/StdLib/Lib/types.py diff --git a/src/StdLib/Lib/typing.py b/src/extensions/StdLib/Lib/typing.py similarity index 100% rename from src/StdLib/Lib/typing.py rename to src/extensions/StdLib/Lib/typing.py diff --git a/src/StdLib/Lib/unittest/__init__.py b/src/extensions/StdLib/Lib/unittest/__init__.py similarity index 100% rename from src/StdLib/Lib/unittest/__init__.py rename to src/extensions/StdLib/Lib/unittest/__init__.py diff --git a/src/StdLib/Lib/unittest/__main__.py b/src/extensions/StdLib/Lib/unittest/__main__.py similarity index 100% rename from src/StdLib/Lib/unittest/__main__.py rename to src/extensions/StdLib/Lib/unittest/__main__.py diff --git a/src/StdLib/Lib/unittest/case.py b/src/extensions/StdLib/Lib/unittest/case.py similarity index 100% rename from src/StdLib/Lib/unittest/case.py rename to src/extensions/StdLib/Lib/unittest/case.py diff --git a/src/StdLib/Lib/unittest/loader.py b/src/extensions/StdLib/Lib/unittest/loader.py similarity index 100% rename from src/StdLib/Lib/unittest/loader.py rename to src/extensions/StdLib/Lib/unittest/loader.py diff --git a/src/StdLib/Lib/unittest/main.py b/src/extensions/StdLib/Lib/unittest/main.py similarity index 100% rename from src/StdLib/Lib/unittest/main.py rename to src/extensions/StdLib/Lib/unittest/main.py diff --git a/src/StdLib/Lib/unittest/mock.py b/src/extensions/StdLib/Lib/unittest/mock.py similarity index 100% rename from src/StdLib/Lib/unittest/mock.py rename to src/extensions/StdLib/Lib/unittest/mock.py diff --git a/src/StdLib/Lib/unittest/result.py b/src/extensions/StdLib/Lib/unittest/result.py similarity index 100% rename from src/StdLib/Lib/unittest/result.py rename to src/extensions/StdLib/Lib/unittest/result.py diff --git a/src/StdLib/Lib/unittest/runner.py b/src/extensions/StdLib/Lib/unittest/runner.py similarity index 100% rename from src/StdLib/Lib/unittest/runner.py rename to src/extensions/StdLib/Lib/unittest/runner.py diff --git a/src/StdLib/Lib/unittest/signals.py b/src/extensions/StdLib/Lib/unittest/signals.py similarity index 100% rename from src/StdLib/Lib/unittest/signals.py rename to src/extensions/StdLib/Lib/unittest/signals.py diff --git a/src/StdLib/Lib/unittest/suite.py b/src/extensions/StdLib/Lib/unittest/suite.py similarity index 100% rename from src/StdLib/Lib/unittest/suite.py rename to src/extensions/StdLib/Lib/unittest/suite.py diff --git a/src/StdLib/Lib/unittest/test/__init__.py b/src/extensions/StdLib/Lib/unittest/test/__init__.py similarity index 100% rename from src/StdLib/Lib/unittest/test/__init__.py rename to src/extensions/StdLib/Lib/unittest/test/__init__.py diff --git a/src/StdLib/Lib/unittest/test/__main__.py b/src/extensions/StdLib/Lib/unittest/test/__main__.py similarity index 100% rename from src/StdLib/Lib/unittest/test/__main__.py rename to src/extensions/StdLib/Lib/unittest/test/__main__.py diff --git a/src/StdLib/Lib/unittest/test/_test_warnings.py b/src/extensions/StdLib/Lib/unittest/test/_test_warnings.py similarity index 100% rename from src/StdLib/Lib/unittest/test/_test_warnings.py rename to src/extensions/StdLib/Lib/unittest/test/_test_warnings.py diff --git a/src/StdLib/Lib/unittest/test/dummy.py b/src/extensions/StdLib/Lib/unittest/test/dummy.py similarity index 100% rename from src/StdLib/Lib/unittest/test/dummy.py rename to src/extensions/StdLib/Lib/unittest/test/dummy.py diff --git a/src/StdLib/Lib/unittest/test/support.py b/src/extensions/StdLib/Lib/unittest/test/support.py similarity index 100% rename from src/StdLib/Lib/unittest/test/support.py rename to src/extensions/StdLib/Lib/unittest/test/support.py diff --git a/src/StdLib/Lib/unittest/test/test_assertions.py b/src/extensions/StdLib/Lib/unittest/test/test_assertions.py similarity index 100% rename from src/StdLib/Lib/unittest/test/test_assertions.py rename to src/extensions/StdLib/Lib/unittest/test/test_assertions.py diff --git a/src/StdLib/Lib/unittest/test/test_break.py b/src/extensions/StdLib/Lib/unittest/test/test_break.py similarity index 100% rename from src/StdLib/Lib/unittest/test/test_break.py rename to src/extensions/StdLib/Lib/unittest/test/test_break.py diff --git a/src/StdLib/Lib/unittest/test/test_case.py b/src/extensions/StdLib/Lib/unittest/test/test_case.py similarity index 100% rename from src/StdLib/Lib/unittest/test/test_case.py rename to src/extensions/StdLib/Lib/unittest/test/test_case.py diff --git a/src/StdLib/Lib/unittest/test/test_discovery.py b/src/extensions/StdLib/Lib/unittest/test/test_discovery.py similarity index 100% rename from src/StdLib/Lib/unittest/test/test_discovery.py rename to src/extensions/StdLib/Lib/unittest/test/test_discovery.py diff --git a/src/StdLib/Lib/unittest/test/test_functiontestcase.py b/src/extensions/StdLib/Lib/unittest/test/test_functiontestcase.py similarity index 100% rename from src/StdLib/Lib/unittest/test/test_functiontestcase.py rename to src/extensions/StdLib/Lib/unittest/test/test_functiontestcase.py diff --git a/src/StdLib/Lib/unittest/test/test_loader.py b/src/extensions/StdLib/Lib/unittest/test/test_loader.py similarity index 100% rename from src/StdLib/Lib/unittest/test/test_loader.py rename to src/extensions/StdLib/Lib/unittest/test/test_loader.py diff --git a/src/StdLib/Lib/unittest/test/test_program.py b/src/extensions/StdLib/Lib/unittest/test/test_program.py similarity index 100% rename from src/StdLib/Lib/unittest/test/test_program.py rename to src/extensions/StdLib/Lib/unittest/test/test_program.py diff --git a/src/StdLib/Lib/unittest/test/test_result.py b/src/extensions/StdLib/Lib/unittest/test/test_result.py similarity index 100% rename from src/StdLib/Lib/unittest/test/test_result.py rename to src/extensions/StdLib/Lib/unittest/test/test_result.py diff --git a/src/StdLib/Lib/unittest/test/test_runner.py b/src/extensions/StdLib/Lib/unittest/test/test_runner.py similarity index 100% rename from src/StdLib/Lib/unittest/test/test_runner.py rename to src/extensions/StdLib/Lib/unittest/test/test_runner.py diff --git a/src/StdLib/Lib/unittest/test/test_setups.py b/src/extensions/StdLib/Lib/unittest/test/test_setups.py similarity index 100% rename from src/StdLib/Lib/unittest/test/test_setups.py rename to src/extensions/StdLib/Lib/unittest/test/test_setups.py diff --git a/src/StdLib/Lib/unittest/test/test_skipping.py b/src/extensions/StdLib/Lib/unittest/test/test_skipping.py similarity index 100% rename from src/StdLib/Lib/unittest/test/test_skipping.py rename to src/extensions/StdLib/Lib/unittest/test/test_skipping.py diff --git a/src/StdLib/Lib/unittest/test/test_suite.py b/src/extensions/StdLib/Lib/unittest/test/test_suite.py similarity index 100% rename from src/StdLib/Lib/unittest/test/test_suite.py rename to src/extensions/StdLib/Lib/unittest/test/test_suite.py diff --git a/src/StdLib/Lib/unittest/test/testmock/__init__.py b/src/extensions/StdLib/Lib/unittest/test/testmock/__init__.py similarity index 100% rename from src/StdLib/Lib/unittest/test/testmock/__init__.py rename to src/extensions/StdLib/Lib/unittest/test/testmock/__init__.py diff --git a/src/StdLib/Lib/unittest/test/testmock/__main__.py b/src/extensions/StdLib/Lib/unittest/test/testmock/__main__.py similarity index 100% rename from src/StdLib/Lib/unittest/test/testmock/__main__.py rename to src/extensions/StdLib/Lib/unittest/test/testmock/__main__.py diff --git a/src/StdLib/Lib/unittest/test/testmock/support.py b/src/extensions/StdLib/Lib/unittest/test/testmock/support.py similarity index 100% rename from src/StdLib/Lib/unittest/test/testmock/support.py rename to src/extensions/StdLib/Lib/unittest/test/testmock/support.py diff --git a/src/StdLib/Lib/unittest/test/testmock/testcallable.py b/src/extensions/StdLib/Lib/unittest/test/testmock/testcallable.py similarity index 100% rename from src/StdLib/Lib/unittest/test/testmock/testcallable.py rename to src/extensions/StdLib/Lib/unittest/test/testmock/testcallable.py diff --git a/src/StdLib/Lib/unittest/test/testmock/testhelpers.py b/src/extensions/StdLib/Lib/unittest/test/testmock/testhelpers.py similarity index 100% rename from src/StdLib/Lib/unittest/test/testmock/testhelpers.py rename to src/extensions/StdLib/Lib/unittest/test/testmock/testhelpers.py diff --git a/src/StdLib/Lib/unittest/test/testmock/testmagicmethods.py b/src/extensions/StdLib/Lib/unittest/test/testmock/testmagicmethods.py similarity index 100% rename from src/StdLib/Lib/unittest/test/testmock/testmagicmethods.py rename to src/extensions/StdLib/Lib/unittest/test/testmock/testmagicmethods.py diff --git a/src/StdLib/Lib/unittest/test/testmock/testmock.py b/src/extensions/StdLib/Lib/unittest/test/testmock/testmock.py similarity index 100% rename from src/StdLib/Lib/unittest/test/testmock/testmock.py rename to src/extensions/StdLib/Lib/unittest/test/testmock/testmock.py diff --git a/src/StdLib/Lib/unittest/test/testmock/testpatch.py b/src/extensions/StdLib/Lib/unittest/test/testmock/testpatch.py similarity index 100% rename from src/StdLib/Lib/unittest/test/testmock/testpatch.py rename to src/extensions/StdLib/Lib/unittest/test/testmock/testpatch.py diff --git a/src/StdLib/Lib/unittest/test/testmock/testsentinel.py b/src/extensions/StdLib/Lib/unittest/test/testmock/testsentinel.py similarity index 100% rename from src/StdLib/Lib/unittest/test/testmock/testsentinel.py rename to src/extensions/StdLib/Lib/unittest/test/testmock/testsentinel.py diff --git a/src/StdLib/Lib/unittest/test/testmock/testwith.py b/src/extensions/StdLib/Lib/unittest/test/testmock/testwith.py similarity index 100% rename from src/StdLib/Lib/unittest/test/testmock/testwith.py rename to src/extensions/StdLib/Lib/unittest/test/testmock/testwith.py diff --git a/src/StdLib/Lib/unittest/util.py b/src/extensions/StdLib/Lib/unittest/util.py similarity index 100% rename from src/StdLib/Lib/unittest/util.py rename to src/extensions/StdLib/Lib/unittest/util.py diff --git a/src/StdLib/Lib/urllib/__init__.py b/src/extensions/StdLib/Lib/urllib/__init__.py similarity index 100% rename from src/StdLib/Lib/urllib/__init__.py rename to src/extensions/StdLib/Lib/urllib/__init__.py diff --git a/src/StdLib/Lib/urllib/error.py b/src/extensions/StdLib/Lib/urllib/error.py similarity index 100% rename from src/StdLib/Lib/urllib/error.py rename to src/extensions/StdLib/Lib/urllib/error.py diff --git a/src/StdLib/Lib/urllib/parse.py b/src/extensions/StdLib/Lib/urllib/parse.py similarity index 100% rename from src/StdLib/Lib/urllib/parse.py rename to src/extensions/StdLib/Lib/urllib/parse.py diff --git a/src/StdLib/Lib/urllib/request.py b/src/extensions/StdLib/Lib/urllib/request.py similarity index 100% rename from src/StdLib/Lib/urllib/request.py rename to src/extensions/StdLib/Lib/urllib/request.py diff --git a/src/StdLib/Lib/urllib/response.py b/src/extensions/StdLib/Lib/urllib/response.py similarity index 100% rename from src/StdLib/Lib/urllib/response.py rename to src/extensions/StdLib/Lib/urllib/response.py diff --git a/src/StdLib/Lib/urllib/robotparser.py b/src/extensions/StdLib/Lib/urllib/robotparser.py similarity index 100% rename from src/StdLib/Lib/urllib/robotparser.py rename to src/extensions/StdLib/Lib/urllib/robotparser.py diff --git a/src/StdLib/Lib/uu.py b/src/extensions/StdLib/Lib/uu.py similarity index 100% rename from src/StdLib/Lib/uu.py rename to src/extensions/StdLib/Lib/uu.py diff --git a/src/StdLib/Lib/uuid.py b/src/extensions/StdLib/Lib/uuid.py similarity index 100% rename from src/StdLib/Lib/uuid.py rename to src/extensions/StdLib/Lib/uuid.py diff --git a/src/StdLib/Lib/venv/__init__.py b/src/extensions/StdLib/Lib/venv/__init__.py similarity index 100% rename from src/StdLib/Lib/venv/__init__.py rename to src/extensions/StdLib/Lib/venv/__init__.py diff --git a/src/StdLib/Lib/venv/__main__.py b/src/extensions/StdLib/Lib/venv/__main__.py similarity index 100% rename from src/StdLib/Lib/venv/__main__.py rename to src/extensions/StdLib/Lib/venv/__main__.py diff --git a/src/StdLib/Lib/venv/scripts/nt/Activate.ps1 b/src/extensions/StdLib/Lib/venv/scripts/nt/Activate.ps1 similarity index 100% rename from src/StdLib/Lib/venv/scripts/nt/Activate.ps1 rename to src/extensions/StdLib/Lib/venv/scripts/nt/Activate.ps1 diff --git a/src/StdLib/Lib/venv/scripts/nt/activate.bat b/src/extensions/StdLib/Lib/venv/scripts/nt/activate.bat similarity index 100% rename from src/StdLib/Lib/venv/scripts/nt/activate.bat rename to src/extensions/StdLib/Lib/venv/scripts/nt/activate.bat diff --git a/src/StdLib/Lib/venv/scripts/nt/deactivate.bat b/src/extensions/StdLib/Lib/venv/scripts/nt/deactivate.bat similarity index 100% rename from src/StdLib/Lib/venv/scripts/nt/deactivate.bat rename to src/extensions/StdLib/Lib/venv/scripts/nt/deactivate.bat diff --git a/src/StdLib/Lib/venv/scripts/posix/activate b/src/extensions/StdLib/Lib/venv/scripts/posix/activate similarity index 100% rename from src/StdLib/Lib/venv/scripts/posix/activate rename to src/extensions/StdLib/Lib/venv/scripts/posix/activate diff --git a/src/StdLib/Lib/venv/scripts/posix/activate.csh b/src/extensions/StdLib/Lib/venv/scripts/posix/activate.csh similarity index 100% rename from src/StdLib/Lib/venv/scripts/posix/activate.csh rename to src/extensions/StdLib/Lib/venv/scripts/posix/activate.csh diff --git a/src/StdLib/Lib/venv/scripts/posix/activate.fish b/src/extensions/StdLib/Lib/venv/scripts/posix/activate.fish similarity index 100% rename from src/StdLib/Lib/venv/scripts/posix/activate.fish rename to src/extensions/StdLib/Lib/venv/scripts/posix/activate.fish diff --git a/src/StdLib/Lib/warnings.py b/src/extensions/StdLib/Lib/warnings.py similarity index 100% rename from src/StdLib/Lib/warnings.py rename to src/extensions/StdLib/Lib/warnings.py diff --git a/src/StdLib/Lib/wave.py b/src/extensions/StdLib/Lib/wave.py similarity index 100% rename from src/StdLib/Lib/wave.py rename to src/extensions/StdLib/Lib/wave.py diff --git a/src/StdLib/Lib/weakref.py b/src/extensions/StdLib/Lib/weakref.py similarity index 100% rename from src/StdLib/Lib/weakref.py rename to src/extensions/StdLib/Lib/weakref.py diff --git a/src/StdLib/Lib/webbrowser.py b/src/extensions/StdLib/Lib/webbrowser.py similarity index 100% rename from src/StdLib/Lib/webbrowser.py rename to src/extensions/StdLib/Lib/webbrowser.py diff --git a/src/StdLib/Lib/wpf.py b/src/extensions/StdLib/Lib/wpf.py similarity index 100% rename from src/StdLib/Lib/wpf.py rename to src/extensions/StdLib/Lib/wpf.py diff --git a/src/StdLib/Lib/wsgiref/__init__.py b/src/extensions/StdLib/Lib/wsgiref/__init__.py similarity index 100% rename from src/StdLib/Lib/wsgiref/__init__.py rename to src/extensions/StdLib/Lib/wsgiref/__init__.py diff --git a/src/StdLib/Lib/wsgiref/handlers.py b/src/extensions/StdLib/Lib/wsgiref/handlers.py similarity index 100% rename from src/StdLib/Lib/wsgiref/handlers.py rename to src/extensions/StdLib/Lib/wsgiref/handlers.py diff --git a/src/StdLib/Lib/wsgiref/headers.py b/src/extensions/StdLib/Lib/wsgiref/headers.py similarity index 100% rename from src/StdLib/Lib/wsgiref/headers.py rename to src/extensions/StdLib/Lib/wsgiref/headers.py diff --git a/src/StdLib/Lib/wsgiref/simple_server.py b/src/extensions/StdLib/Lib/wsgiref/simple_server.py similarity index 100% rename from src/StdLib/Lib/wsgiref/simple_server.py rename to src/extensions/StdLib/Lib/wsgiref/simple_server.py diff --git a/src/StdLib/Lib/wsgiref/util.py b/src/extensions/StdLib/Lib/wsgiref/util.py similarity index 100% rename from src/StdLib/Lib/wsgiref/util.py rename to src/extensions/StdLib/Lib/wsgiref/util.py diff --git a/src/StdLib/Lib/wsgiref/validate.py b/src/extensions/StdLib/Lib/wsgiref/validate.py similarity index 100% rename from src/StdLib/Lib/wsgiref/validate.py rename to src/extensions/StdLib/Lib/wsgiref/validate.py diff --git a/src/StdLib/Lib/xdrlib.py b/src/extensions/StdLib/Lib/xdrlib.py similarity index 100% rename from src/StdLib/Lib/xdrlib.py rename to src/extensions/StdLib/Lib/xdrlib.py diff --git a/src/StdLib/Lib/xml/__init__.py b/src/extensions/StdLib/Lib/xml/__init__.py similarity index 100% rename from src/StdLib/Lib/xml/__init__.py rename to src/extensions/StdLib/Lib/xml/__init__.py diff --git a/src/StdLib/Lib/xml/dom/NodeFilter.py b/src/extensions/StdLib/Lib/xml/dom/NodeFilter.py similarity index 100% rename from src/StdLib/Lib/xml/dom/NodeFilter.py rename to src/extensions/StdLib/Lib/xml/dom/NodeFilter.py diff --git a/src/StdLib/Lib/xml/dom/__init__.py b/src/extensions/StdLib/Lib/xml/dom/__init__.py similarity index 100% rename from src/StdLib/Lib/xml/dom/__init__.py rename to src/extensions/StdLib/Lib/xml/dom/__init__.py diff --git a/src/StdLib/Lib/xml/dom/domreg.py b/src/extensions/StdLib/Lib/xml/dom/domreg.py similarity index 100% rename from src/StdLib/Lib/xml/dom/domreg.py rename to src/extensions/StdLib/Lib/xml/dom/domreg.py diff --git a/src/StdLib/Lib/xml/dom/expatbuilder.py b/src/extensions/StdLib/Lib/xml/dom/expatbuilder.py similarity index 100% rename from src/StdLib/Lib/xml/dom/expatbuilder.py rename to src/extensions/StdLib/Lib/xml/dom/expatbuilder.py diff --git a/src/StdLib/Lib/xml/dom/minicompat.py b/src/extensions/StdLib/Lib/xml/dom/minicompat.py similarity index 100% rename from src/StdLib/Lib/xml/dom/minicompat.py rename to src/extensions/StdLib/Lib/xml/dom/minicompat.py diff --git a/src/StdLib/Lib/xml/dom/minidom.py b/src/extensions/StdLib/Lib/xml/dom/minidom.py similarity index 100% rename from src/StdLib/Lib/xml/dom/minidom.py rename to src/extensions/StdLib/Lib/xml/dom/minidom.py diff --git a/src/StdLib/Lib/xml/dom/pulldom.py b/src/extensions/StdLib/Lib/xml/dom/pulldom.py similarity index 100% rename from src/StdLib/Lib/xml/dom/pulldom.py rename to src/extensions/StdLib/Lib/xml/dom/pulldom.py diff --git a/src/StdLib/Lib/xml/dom/xmlbuilder.py b/src/extensions/StdLib/Lib/xml/dom/xmlbuilder.py similarity index 100% rename from src/StdLib/Lib/xml/dom/xmlbuilder.py rename to src/extensions/StdLib/Lib/xml/dom/xmlbuilder.py diff --git a/src/StdLib/Lib/xml/etree/ElementInclude.py b/src/extensions/StdLib/Lib/xml/etree/ElementInclude.py similarity index 100% rename from src/StdLib/Lib/xml/etree/ElementInclude.py rename to src/extensions/StdLib/Lib/xml/etree/ElementInclude.py diff --git a/src/StdLib/Lib/xml/etree/ElementPath.py b/src/extensions/StdLib/Lib/xml/etree/ElementPath.py similarity index 100% rename from src/StdLib/Lib/xml/etree/ElementPath.py rename to src/extensions/StdLib/Lib/xml/etree/ElementPath.py diff --git a/src/StdLib/Lib/xml/etree/ElementTree.py b/src/extensions/StdLib/Lib/xml/etree/ElementTree.py similarity index 100% rename from src/StdLib/Lib/xml/etree/ElementTree.py rename to src/extensions/StdLib/Lib/xml/etree/ElementTree.py diff --git a/src/StdLib/Lib/xml/etree/__init__.py b/src/extensions/StdLib/Lib/xml/etree/__init__.py similarity index 100% rename from src/StdLib/Lib/xml/etree/__init__.py rename to src/extensions/StdLib/Lib/xml/etree/__init__.py diff --git a/src/StdLib/Lib/xml/etree/cElementTree.py b/src/extensions/StdLib/Lib/xml/etree/cElementTree.py similarity index 100% rename from src/StdLib/Lib/xml/etree/cElementTree.py rename to src/extensions/StdLib/Lib/xml/etree/cElementTree.py diff --git a/src/StdLib/Lib/xml/parsers/__init__.py b/src/extensions/StdLib/Lib/xml/parsers/__init__.py similarity index 100% rename from src/StdLib/Lib/xml/parsers/__init__.py rename to src/extensions/StdLib/Lib/xml/parsers/__init__.py diff --git a/src/StdLib/Lib/xml/parsers/expat.py b/src/extensions/StdLib/Lib/xml/parsers/expat.py similarity index 100% rename from src/StdLib/Lib/xml/parsers/expat.py rename to src/extensions/StdLib/Lib/xml/parsers/expat.py diff --git a/src/StdLib/Lib/xml/sax/__init__.py b/src/extensions/StdLib/Lib/xml/sax/__init__.py similarity index 100% rename from src/StdLib/Lib/xml/sax/__init__.py rename to src/extensions/StdLib/Lib/xml/sax/__init__.py diff --git a/src/StdLib/Lib/xml/sax/_exceptions.py b/src/extensions/StdLib/Lib/xml/sax/_exceptions.py similarity index 100% rename from src/StdLib/Lib/xml/sax/_exceptions.py rename to src/extensions/StdLib/Lib/xml/sax/_exceptions.py diff --git a/src/StdLib/Lib/xml/sax/expatreader.py b/src/extensions/StdLib/Lib/xml/sax/expatreader.py similarity index 100% rename from src/StdLib/Lib/xml/sax/expatreader.py rename to src/extensions/StdLib/Lib/xml/sax/expatreader.py diff --git a/src/StdLib/Lib/xml/sax/handler.py b/src/extensions/StdLib/Lib/xml/sax/handler.py similarity index 100% rename from src/StdLib/Lib/xml/sax/handler.py rename to src/extensions/StdLib/Lib/xml/sax/handler.py diff --git a/src/StdLib/Lib/xml/sax/saxutils.py b/src/extensions/StdLib/Lib/xml/sax/saxutils.py similarity index 100% rename from src/StdLib/Lib/xml/sax/saxutils.py rename to src/extensions/StdLib/Lib/xml/sax/saxutils.py diff --git a/src/StdLib/Lib/xml/sax/xmlreader.py b/src/extensions/StdLib/Lib/xml/sax/xmlreader.py similarity index 100% rename from src/StdLib/Lib/xml/sax/xmlreader.py rename to src/extensions/StdLib/Lib/xml/sax/xmlreader.py diff --git a/src/StdLib/Lib/xmlrpc/__init__.py b/src/extensions/StdLib/Lib/xmlrpc/__init__.py similarity index 100% rename from src/StdLib/Lib/xmlrpc/__init__.py rename to src/extensions/StdLib/Lib/xmlrpc/__init__.py diff --git a/src/StdLib/Lib/xmlrpc/client.py b/src/extensions/StdLib/Lib/xmlrpc/client.py similarity index 100% rename from src/StdLib/Lib/xmlrpc/client.py rename to src/extensions/StdLib/Lib/xmlrpc/client.py diff --git a/src/StdLib/Lib/xmlrpc/server.py b/src/extensions/StdLib/Lib/xmlrpc/server.py similarity index 100% rename from src/StdLib/Lib/xmlrpc/server.py rename to src/extensions/StdLib/Lib/xmlrpc/server.py diff --git a/src/StdLib/Lib/zipfile.py b/src/extensions/StdLib/Lib/zipfile.py similarity index 100% rename from src/StdLib/Lib/zipfile.py rename to src/extensions/StdLib/Lib/zipfile.py diff --git a/src/StdLib/StdLib.License.txt b/src/extensions/StdLib/StdLib.License.txt similarity index 100% rename from src/StdLib/StdLib.License.txt rename to src/extensions/StdLib/StdLib.License.txt diff --git a/src/StdLib/StdLib.pyproj b/src/extensions/StdLib/StdLib.pyproj similarity index 100% rename from src/StdLib/StdLib.pyproj rename to src/extensions/StdLib/StdLib.pyproj diff --git a/src/StdLib/stdlib-upgrade.txt b/src/extensions/StdLib/stdlib-upgrade.txt similarity index 100% rename from src/StdLib/stdlib-upgrade.txt rename to src/extensions/StdLib/stdlib-upgrade.txt diff --git a/src/StdLib/update-stdlib.cmd b/src/extensions/StdLib/update-stdlib.cmd similarity index 100% rename from src/StdLib/update-stdlib.cmd rename to src/extensions/StdLib/update-stdlib.cmd diff --git a/src/StdLib/update-stdlib.sh b/src/extensions/StdLib/update-stdlib.sh similarity index 100% rename from src/StdLib/update-stdlib.sh rename to src/extensions/StdLib/update-stdlib.sh diff --git a/src/CTypes/Makefile b/src/ipy/CTypes/Makefile similarity index 100% rename from src/CTypes/Makefile rename to src/ipy/CTypes/Makefile diff --git a/src/CTypes/_ctypes_test.c b/src/ipy/CTypes/_ctypes_test.c similarity index 100% rename from src/CTypes/_ctypes_test.c rename to src/ipy/CTypes/_ctypes_test.c diff --git a/src/CTypes/_ctypes_test.sln b/src/ipy/CTypes/_ctypes_test.sln similarity index 100% rename from src/CTypes/_ctypes_test.sln rename to src/ipy/CTypes/_ctypes_test.sln diff --git a/src/CTypes/_ctypes_test.vcxproj b/src/ipy/CTypes/_ctypes_test.vcxproj similarity index 100% rename from src/CTypes/_ctypes_test.vcxproj rename to src/ipy/CTypes/_ctypes_test.vcxproj diff --git a/src/CompilerServices/AssemblyResolver.cs b/src/ipy/IronPython.CompilerServices/AssemblyResolver.cs similarity index 100% rename from src/CompilerServices/AssemblyResolver.cs rename to src/ipy/IronPython.CompilerServices/AssemblyResolver.cs diff --git a/src/CompilerServices/Config.cs b/src/ipy/IronPython.CompilerServices/Config.cs similarity index 100% rename from src/CompilerServices/Config.cs rename to src/ipy/IronPython.CompilerServices/Config.cs diff --git a/src/CompilerServices/ConsoleOps.cs b/src/ipy/IronPython.CompilerServices/ConsoleOps.cs similarity index 100% rename from src/CompilerServices/ConsoleOps.cs rename to src/ipy/IronPython.CompilerServices/ConsoleOps.cs diff --git a/src/CompilerServices/IronPython.CompilerServices.csproj b/src/ipy/IronPython.CompilerServices/IronPython.CompilerServices.csproj similarity index 100% rename from src/CompilerServices/IronPython.CompilerServices.csproj rename to src/ipy/IronPython.CompilerServices/IronPython.CompilerServices.csproj diff --git a/src/CompilerServices/Program.cs b/src/ipy/IronPython.CompilerServices/Program.cs similarity index 100% rename from src/CompilerServices/Program.cs rename to src/ipy/IronPython.CompilerServices/Program.cs diff --git a/src/CompilerServices/Properties/AssemblyInfo.cs b/src/ipy/IronPython.CompilerServices/Properties/AssemblyInfo.cs similarity index 100% rename from src/CompilerServices/Properties/AssemblyInfo.cs rename to src/ipy/IronPython.CompilerServices/Properties/AssemblyInfo.cs diff --git a/src/CompilerServices/README.md b/src/ipy/IronPython.CompilerServices/README.md similarity index 100% rename from src/CompilerServices/README.md rename to src/ipy/IronPython.CompilerServices/README.md diff --git a/src/Modules/IronPython.Modules.csproj b/src/ipy/IronPython.Modules/IronPython.Modules.csproj similarity index 100% rename from src/Modules/IronPython.Modules.csproj rename to src/ipy/IronPython.Modules/IronPython.Modules.csproj diff --git a/src/Modules/IterTools.cs b/src/ipy/IronPython.Modules/IterTools.cs similarity index 100% rename from src/Modules/IterTools.cs rename to src/ipy/IronPython.Modules/IterTools.cs diff --git a/src/Modules/ModuleOps.cs b/src/ipy/IronPython.Modules/ModuleOps.cs similarity index 100% rename from src/Modules/ModuleOps.cs rename to src/ipy/IronPython.Modules/ModuleOps.cs diff --git a/src/Modules/NtSignalState.cs b/src/ipy/IronPython.Modules/NtSignalState.cs similarity index 100% rename from src/Modules/NtSignalState.cs rename to src/ipy/IronPython.Modules/NtSignalState.cs diff --git a/src/Modules/Properties/AssemblyInfo.cs b/src/ipy/IronPython.Modules/Properties/AssemblyInfo.cs similarity index 100% rename from src/Modules/Properties/AssemblyInfo.cs rename to src/ipy/IronPython.Modules/Properties/AssemblyInfo.cs diff --git a/src/Modules/ResourceMetaPathImporter.cs b/src/ipy/IronPython.Modules/ResourceMetaPathImporter.cs similarity index 100% rename from src/Modules/ResourceMetaPathImporter.cs rename to src/ipy/IronPython.Modules/ResourceMetaPathImporter.cs diff --git a/src/Modules/SimpleSignalState.cs b/src/ipy/IronPython.Modules/SimpleSignalState.cs similarity index 100% rename from src/Modules/SimpleSignalState.cs rename to src/ipy/IronPython.Modules/SimpleSignalState.cs diff --git a/src/Modules/_bisect.cs b/src/ipy/IronPython.Modules/_bisect.cs similarity index 100% rename from src/Modules/_bisect.cs rename to src/ipy/IronPython.Modules/_bisect.cs diff --git a/src/Modules/_codecs.cs b/src/ipy/IronPython.Modules/_codecs.cs similarity index 100% rename from src/Modules/_codecs.cs rename to src/ipy/IronPython.Modules/_codecs.cs diff --git a/src/Modules/_codecs_cn.cs b/src/ipy/IronPython.Modules/_codecs_cn.cs similarity index 100% rename from src/Modules/_codecs_cn.cs rename to src/ipy/IronPython.Modules/_codecs_cn.cs diff --git a/src/Modules/_collections.cs b/src/ipy/IronPython.Modules/_collections.cs similarity index 100% rename from src/Modules/_collections.cs rename to src/ipy/IronPython.Modules/_collections.cs diff --git a/src/Modules/_csv.cs b/src/ipy/IronPython.Modules/_csv.cs similarity index 100% rename from src/Modules/_csv.cs rename to src/ipy/IronPython.Modules/_csv.cs diff --git a/src/Modules/_ctypes/Array.cs b/src/ipy/IronPython.Modules/_ctypes/Array.cs similarity index 100% rename from src/Modules/_ctypes/Array.cs rename to src/ipy/IronPython.Modules/_ctypes/Array.cs diff --git a/src/Modules/_ctypes/ArrayType.cs b/src/ipy/IronPython.Modules/_ctypes/ArrayType.cs similarity index 100% rename from src/Modules/_ctypes/ArrayType.cs rename to src/ipy/IronPython.Modules/_ctypes/ArrayType.cs diff --git a/src/Modules/_ctypes/CData.cs b/src/ipy/IronPython.Modules/_ctypes/CData.cs similarity index 100% rename from src/Modules/_ctypes/CData.cs rename to src/ipy/IronPython.Modules/_ctypes/CData.cs diff --git a/src/Modules/_ctypes/CFuncPtr.cs b/src/ipy/IronPython.Modules/_ctypes/CFuncPtr.cs similarity index 100% rename from src/Modules/_ctypes/CFuncPtr.cs rename to src/ipy/IronPython.Modules/_ctypes/CFuncPtr.cs diff --git a/src/Modules/_ctypes/CFuncPtrType.cs b/src/ipy/IronPython.Modules/_ctypes/CFuncPtrType.cs similarity index 100% rename from src/Modules/_ctypes/CFuncPtrType.cs rename to src/ipy/IronPython.Modules/_ctypes/CFuncPtrType.cs diff --git a/src/Modules/_ctypes/Extensions.cs b/src/ipy/IronPython.Modules/_ctypes/Extensions.cs similarity index 100% rename from src/Modules/_ctypes/Extensions.cs rename to src/ipy/IronPython.Modules/_ctypes/Extensions.cs diff --git a/src/Modules/_ctypes/Field.cs b/src/ipy/IronPython.Modules/_ctypes/Field.cs similarity index 100% rename from src/Modules/_ctypes/Field.cs rename to src/ipy/IronPython.Modules/_ctypes/Field.cs diff --git a/src/Modules/_ctypes/INativeType.cs b/src/ipy/IronPython.Modules/_ctypes/INativeType.cs similarity index 100% rename from src/Modules/_ctypes/INativeType.cs rename to src/ipy/IronPython.Modules/_ctypes/INativeType.cs diff --git a/src/Modules/_ctypes/LocalOrArg.cs b/src/ipy/IronPython.Modules/_ctypes/LocalOrArg.cs similarity index 100% rename from src/Modules/_ctypes/LocalOrArg.cs rename to src/ipy/IronPython.Modules/_ctypes/LocalOrArg.cs diff --git a/src/Modules/_ctypes/MarshalCleanup.cs b/src/ipy/IronPython.Modules/_ctypes/MarshalCleanup.cs similarity index 100% rename from src/Modules/_ctypes/MarshalCleanup.cs rename to src/ipy/IronPython.Modules/_ctypes/MarshalCleanup.cs diff --git a/src/Modules/_ctypes/MemoryHolder.cs b/src/ipy/IronPython.Modules/_ctypes/MemoryHolder.cs similarity index 100% rename from src/Modules/_ctypes/MemoryHolder.cs rename to src/ipy/IronPython.Modules/_ctypes/MemoryHolder.cs diff --git a/src/Modules/_ctypes/NativeArgument.cs b/src/ipy/IronPython.Modules/_ctypes/NativeArgument.cs similarity index 100% rename from src/Modules/_ctypes/NativeArgument.cs rename to src/ipy/IronPython.Modules/_ctypes/NativeArgument.cs diff --git a/src/Modules/_ctypes/NativeFunctions.cs b/src/ipy/IronPython.Modules/_ctypes/NativeFunctions.cs similarity index 100% rename from src/Modules/_ctypes/NativeFunctions.cs rename to src/ipy/IronPython.Modules/_ctypes/NativeFunctions.cs diff --git a/src/Modules/_ctypes/Pointer.cs b/src/ipy/IronPython.Modules/_ctypes/Pointer.cs similarity index 100% rename from src/Modules/_ctypes/Pointer.cs rename to src/ipy/IronPython.Modules/_ctypes/Pointer.cs diff --git a/src/Modules/_ctypes/PointerType.cs b/src/ipy/IronPython.Modules/_ctypes/PointerType.cs similarity index 100% rename from src/Modules/_ctypes/PointerType.cs rename to src/ipy/IronPython.Modules/_ctypes/PointerType.cs diff --git a/src/Modules/_ctypes/SimpleCData.cs b/src/ipy/IronPython.Modules/_ctypes/SimpleCData.cs similarity index 100% rename from src/Modules/_ctypes/SimpleCData.cs rename to src/ipy/IronPython.Modules/_ctypes/SimpleCData.cs diff --git a/src/Modules/_ctypes/SimpleType.cs b/src/ipy/IronPython.Modules/_ctypes/SimpleType.cs similarity index 100% rename from src/Modules/_ctypes/SimpleType.cs rename to src/ipy/IronPython.Modules/_ctypes/SimpleType.cs diff --git a/src/Modules/_ctypes/SimpleTypeKind.cs b/src/ipy/IronPython.Modules/_ctypes/SimpleTypeKind.cs similarity index 100% rename from src/Modules/_ctypes/SimpleTypeKind.cs rename to src/ipy/IronPython.Modules/_ctypes/SimpleTypeKind.cs diff --git a/src/Modules/_ctypes/StructType.cs b/src/ipy/IronPython.Modules/_ctypes/StructType.cs similarity index 100% rename from src/Modules/_ctypes/StructType.cs rename to src/ipy/IronPython.Modules/_ctypes/StructType.cs diff --git a/src/Modules/_ctypes/Structure.cs b/src/ipy/IronPython.Modules/_ctypes/Structure.cs similarity index 100% rename from src/Modules/_ctypes/Structure.cs rename to src/ipy/IronPython.Modules/_ctypes/Structure.cs diff --git a/src/Modules/_ctypes/Union.cs b/src/ipy/IronPython.Modules/_ctypes/Union.cs similarity index 100% rename from src/Modules/_ctypes/Union.cs rename to src/ipy/IronPython.Modules/_ctypes/Union.cs diff --git a/src/Modules/_ctypes/UnionType.cs b/src/ipy/IronPython.Modules/_ctypes/UnionType.cs similarity index 100% rename from src/Modules/_ctypes/UnionType.cs rename to src/ipy/IronPython.Modules/_ctypes/UnionType.cs diff --git a/src/Modules/_ctypes/_ctypes.cs b/src/ipy/IronPython.Modules/_ctypes/_ctypes.cs similarity index 100% rename from src/Modules/_ctypes/_ctypes.cs rename to src/ipy/IronPython.Modules/_ctypes/_ctypes.cs diff --git a/src/Modules/_ctypes_test.cs b/src/ipy/IronPython.Modules/_ctypes_test.cs similarity index 100% rename from src/Modules/_ctypes_test.cs rename to src/ipy/IronPython.Modules/_ctypes_test.cs diff --git a/src/Modules/_datetime.cs b/src/ipy/IronPython.Modules/_datetime.cs similarity index 100% rename from src/Modules/_datetime.cs rename to src/ipy/IronPython.Modules/_datetime.cs diff --git a/src/Modules/_functools.cs b/src/ipy/IronPython.Modules/_functools.cs similarity index 100% rename from src/Modules/_functools.cs rename to src/ipy/IronPython.Modules/_functools.cs diff --git a/src/Modules/_heapq.cs b/src/ipy/IronPython.Modules/_heapq.cs similarity index 100% rename from src/Modules/_heapq.cs rename to src/ipy/IronPython.Modules/_heapq.cs diff --git a/src/Modules/_multibytecodec.cs b/src/ipy/IronPython.Modules/_multibytecodec.cs similarity index 100% rename from src/Modules/_multibytecodec.cs rename to src/ipy/IronPython.Modules/_multibytecodec.cs diff --git a/src/Modules/_multiprocessing.cs b/src/ipy/IronPython.Modules/_multiprocessing.cs similarity index 100% rename from src/Modules/_multiprocessing.cs rename to src/ipy/IronPython.Modules/_multiprocessing.cs diff --git a/src/Modules/_opcode.cs b/src/ipy/IronPython.Modules/_opcode.cs similarity index 100% rename from src/Modules/_opcode.cs rename to src/ipy/IronPython.Modules/_opcode.cs diff --git a/src/Modules/_operator.cs b/src/ipy/IronPython.Modules/_operator.cs similarity index 100% rename from src/Modules/_operator.cs rename to src/ipy/IronPython.Modules/_operator.cs diff --git a/src/Modules/_overlapped.cs b/src/ipy/IronPython.Modules/_overlapped.cs similarity index 100% rename from src/Modules/_overlapped.cs rename to src/ipy/IronPython.Modules/_overlapped.cs diff --git a/src/Modules/_pickle.cs b/src/ipy/IronPython.Modules/_pickle.cs similarity index 100% rename from src/Modules/_pickle.cs rename to src/ipy/IronPython.Modules/_pickle.cs diff --git a/src/Modules/_posixsubprocess.cs b/src/ipy/IronPython.Modules/_posixsubprocess.cs similarity index 100% rename from src/Modules/_posixsubprocess.cs rename to src/ipy/IronPython.Modules/_posixsubprocess.cs diff --git a/src/Modules/_random.RandomGen.cs b/src/ipy/IronPython.Modules/_random.RandomGen.cs similarity index 100% rename from src/Modules/_random.RandomGen.cs rename to src/ipy/IronPython.Modules/_random.RandomGen.cs diff --git a/src/Modules/_random.cs b/src/ipy/IronPython.Modules/_random.cs similarity index 100% rename from src/Modules/_random.cs rename to src/ipy/IronPython.Modules/_random.cs diff --git a/src/Modules/_socket.cs b/src/ipy/IronPython.Modules/_socket.cs similarity index 100% rename from src/Modules/_socket.cs rename to src/ipy/IronPython.Modules/_socket.cs diff --git a/src/Modules/_sre.cs b/src/ipy/IronPython.Modules/_sre.cs similarity index 100% rename from src/Modules/_sre.cs rename to src/ipy/IronPython.Modules/_sre.cs diff --git a/src/Modules/_ssl.cs b/src/ipy/IronPython.Modules/_ssl.cs similarity index 100% rename from src/Modules/_ssl.cs rename to src/ipy/IronPython.Modules/_ssl.cs diff --git a/src/Modules/_string.cs b/src/ipy/IronPython.Modules/_string.cs similarity index 100% rename from src/Modules/_string.cs rename to src/ipy/IronPython.Modules/_string.cs diff --git a/src/Modules/_struct.cs b/src/ipy/IronPython.Modules/_struct.cs similarity index 100% rename from src/Modules/_struct.cs rename to src/ipy/IronPython.Modules/_struct.cs diff --git a/src/Modules/_sysconfigdata.cs b/src/ipy/IronPython.Modules/_sysconfigdata.cs similarity index 100% rename from src/Modules/_sysconfigdata.cs rename to src/ipy/IronPython.Modules/_sysconfigdata.cs diff --git a/src/Modules/_thread.cs b/src/ipy/IronPython.Modules/_thread.cs similarity index 100% rename from src/Modules/_thread.cs rename to src/ipy/IronPython.Modules/_thread.cs diff --git a/src/Modules/_warnings.cs b/src/ipy/IronPython.Modules/_warnings.cs similarity index 100% rename from src/Modules/_warnings.cs rename to src/ipy/IronPython.Modules/_warnings.cs diff --git a/src/Modules/_weakref.Generated.cs b/src/ipy/IronPython.Modules/_weakref.Generated.cs similarity index 100% rename from src/Modules/_weakref.Generated.cs rename to src/ipy/IronPython.Modules/_weakref.Generated.cs diff --git a/src/Modules/_weakref.cs b/src/ipy/IronPython.Modules/_weakref.cs similarity index 100% rename from src/Modules/_weakref.cs rename to src/ipy/IronPython.Modules/_weakref.cs diff --git a/src/Modules/_winapi.cs b/src/ipy/IronPython.Modules/_winapi.cs similarity index 100% rename from src/Modules/_winapi.cs rename to src/ipy/IronPython.Modules/_winapi.cs diff --git a/src/Modules/array.cs b/src/ipy/IronPython.Modules/array.cs similarity index 100% rename from src/Modules/array.cs rename to src/ipy/IronPython.Modules/array.cs diff --git a/src/Modules/atexit.cs b/src/ipy/IronPython.Modules/atexit.cs similarity index 100% rename from src/Modules/atexit.cs rename to src/ipy/IronPython.Modules/atexit.cs diff --git a/src/Modules/audioop.cs b/src/ipy/IronPython.Modules/audioop.cs similarity index 100% rename from src/Modules/audioop.cs rename to src/ipy/IronPython.Modules/audioop.cs diff --git a/src/Modules/binascii.cs b/src/ipy/IronPython.Modules/binascii.cs similarity index 100% rename from src/Modules/binascii.cs rename to src/ipy/IronPython.Modules/binascii.cs diff --git a/src/Modules/bz2/BZ2Compressor.cs b/src/ipy/IronPython.Modules/bz2/BZ2Compressor.cs similarity index 100% rename from src/Modules/bz2/BZ2Compressor.cs rename to src/ipy/IronPython.Modules/bz2/BZ2Compressor.cs diff --git a/src/Modules/bz2/BZ2Decompressor.cs b/src/ipy/IronPython.Modules/bz2/BZ2Decompressor.cs similarity index 100% rename from src/Modules/bz2/BZ2Decompressor.cs rename to src/ipy/IronPython.Modules/bz2/BZ2Decompressor.cs diff --git a/src/Modules/bz2/BZ2Module.cs b/src/ipy/IronPython.Modules/bz2/BZ2Module.cs similarity index 100% rename from src/Modules/bz2/BZ2Module.cs rename to src/ipy/IronPython.Modules/bz2/BZ2Module.cs diff --git a/src/Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs b/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs similarity index 100% rename from src/Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs rename to src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs diff --git a/src/Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs b/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs similarity index 100% rename from src/Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs rename to src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs diff --git a/src/Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs b/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs similarity index 100% rename from src/Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs rename to src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs diff --git a/src/Modules/bz2/dotnetzip/BZip2/BitWriter.cs b/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BitWriter.cs similarity index 100% rename from src/Modules/bz2/dotnetzip/BZip2/BitWriter.cs rename to src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BitWriter.cs diff --git a/src/Modules/bz2/dotnetzip/BZip2/CRC32.cs b/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/CRC32.cs similarity index 100% rename from src/Modules/bz2/dotnetzip/BZip2/CRC32.cs rename to src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/CRC32.cs diff --git a/src/Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs b/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs similarity index 100% rename from src/Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs rename to src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs diff --git a/src/Modules/bz2/dotnetzip/BZip2/Rand.cs b/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/Rand.cs similarity index 100% rename from src/Modules/bz2/dotnetzip/BZip2/Rand.cs rename to src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/Rand.cs diff --git a/src/Modules/bz2/dotnetzip/source.txt b/src/ipy/IronPython.Modules/bz2/dotnetzip/source.txt similarity index 100% rename from src/Modules/bz2/dotnetzip/source.txt rename to src/ipy/IronPython.Modules/bz2/dotnetzip/source.txt diff --git a/src/Modules/cmath.cs b/src/ipy/IronPython.Modules/cmath.cs similarity index 100% rename from src/Modules/cmath.cs rename to src/ipy/IronPython.Modules/cmath.cs diff --git a/src/Modules/errno.cs b/src/ipy/IronPython.Modules/errno.cs similarity index 100% rename from src/Modules/errno.cs rename to src/ipy/IronPython.Modules/errno.cs diff --git a/src/Modules/faulthandler.cs b/src/ipy/IronPython.Modules/faulthandler.cs similarity index 100% rename from src/Modules/faulthandler.cs rename to src/ipy/IronPython.Modules/faulthandler.cs diff --git a/src/Modules/fcntl.cs b/src/ipy/IronPython.Modules/fcntl.cs similarity index 100% rename from src/Modules/fcntl.cs rename to src/ipy/IronPython.Modules/fcntl.cs diff --git a/src/Modules/gc.cs b/src/ipy/IronPython.Modules/gc.cs similarity index 100% rename from src/Modules/gc.cs rename to src/ipy/IronPython.Modules/gc.cs diff --git a/src/Modules/grp.cs b/src/ipy/IronPython.Modules/grp.cs similarity index 100% rename from src/Modules/grp.cs rename to src/ipy/IronPython.Modules/grp.cs diff --git a/src/Modules/hashlib/MD5CryptoServiceProvider.cs b/src/ipy/IronPython.Modules/hashlib/MD5CryptoServiceProvider.cs similarity index 100% rename from src/Modules/hashlib/MD5CryptoServiceProvider.cs rename to src/ipy/IronPython.Modules/hashlib/MD5CryptoServiceProvider.cs diff --git a/src/Modules/hashlib/SHA1CryptoServiceProvider.cs b/src/ipy/IronPython.Modules/hashlib/SHA1CryptoServiceProvider.cs similarity index 100% rename from src/Modules/hashlib/SHA1CryptoServiceProvider.cs rename to src/ipy/IronPython.Modules/hashlib/SHA1CryptoServiceProvider.cs diff --git a/src/Modules/hashlib/SHA224.cs b/src/ipy/IronPython.Modules/hashlib/SHA224.cs similarity index 100% rename from src/Modules/hashlib/SHA224.cs rename to src/ipy/IronPython.Modules/hashlib/SHA224.cs diff --git a/src/Modules/hashlib/SHA224Managed.cs b/src/ipy/IronPython.Modules/hashlib/SHA224Managed.cs similarity index 100% rename from src/Modules/hashlib/SHA224Managed.cs rename to src/ipy/IronPython.Modules/hashlib/SHA224Managed.cs diff --git a/src/Modules/hashlib/SHA256Managed.cs b/src/ipy/IronPython.Modules/hashlib/SHA256Managed.cs similarity index 100% rename from src/Modules/hashlib/SHA256Managed.cs rename to src/ipy/IronPython.Modules/hashlib/SHA256Managed.cs diff --git a/src/Modules/hashlib/SHA384Managed.cs b/src/ipy/IronPython.Modules/hashlib/SHA384Managed.cs similarity index 100% rename from src/Modules/hashlib/SHA384Managed.cs rename to src/ipy/IronPython.Modules/hashlib/SHA384Managed.cs diff --git a/src/Modules/hashlib/SHA512Managed.cs b/src/ipy/IronPython.Modules/hashlib/SHA512Managed.cs similarity index 100% rename from src/Modules/hashlib/SHA512Managed.cs rename to src/ipy/IronPython.Modules/hashlib/SHA512Managed.cs diff --git a/src/Modules/hashlib/SHAConstants.cs b/src/ipy/IronPython.Modules/hashlib/SHAConstants.cs similarity index 100% rename from src/Modules/hashlib/SHAConstants.cs rename to src/ipy/IronPython.Modules/hashlib/SHAConstants.cs diff --git a/src/Modules/hashlib/_hashlib.cs b/src/ipy/IronPython.Modules/hashlib/_hashlib.cs similarity index 100% rename from src/Modules/hashlib/_hashlib.cs rename to src/ipy/IronPython.Modules/hashlib/_hashlib.cs diff --git a/src/Modules/hashlib/_md5.cs b/src/ipy/IronPython.Modules/hashlib/_md5.cs similarity index 100% rename from src/Modules/hashlib/_md5.cs rename to src/ipy/IronPython.Modules/hashlib/_md5.cs diff --git a/src/Modules/hashlib/_sha1.cs b/src/ipy/IronPython.Modules/hashlib/_sha1.cs similarity index 100% rename from src/Modules/hashlib/_sha1.cs rename to src/ipy/IronPython.Modules/hashlib/_sha1.cs diff --git a/src/Modules/hashlib/_sha256.cs b/src/ipy/IronPython.Modules/hashlib/_sha256.cs similarity index 100% rename from src/Modules/hashlib/_sha256.cs rename to src/ipy/IronPython.Modules/hashlib/_sha256.cs diff --git a/src/Modules/hashlib/_sha512.cs b/src/ipy/IronPython.Modules/hashlib/_sha512.cs similarity index 100% rename from src/Modules/hashlib/_sha512.cs rename to src/ipy/IronPython.Modules/hashlib/_sha512.cs diff --git a/src/Modules/marshal.cs b/src/ipy/IronPython.Modules/marshal.cs similarity index 100% rename from src/Modules/marshal.cs rename to src/ipy/IronPython.Modules/marshal.cs diff --git a/src/Modules/math.Generated.cs b/src/ipy/IronPython.Modules/math.Generated.cs similarity index 100% rename from src/Modules/math.Generated.cs rename to src/ipy/IronPython.Modules/math.Generated.cs diff --git a/src/Modules/math.cs b/src/ipy/IronPython.Modules/math.cs similarity index 100% rename from src/Modules/math.cs rename to src/ipy/IronPython.Modules/math.cs diff --git a/src/Modules/mmap.cs b/src/ipy/IronPython.Modules/mmap.cs similarity index 100% rename from src/Modules/mmap.cs rename to src/ipy/IronPython.Modules/mmap.cs diff --git a/src/Modules/msvcrt.cs b/src/ipy/IronPython.Modules/msvcrt.cs similarity index 100% rename from src/Modules/msvcrt.cs rename to src/ipy/IronPython.Modules/msvcrt.cs diff --git a/src/Modules/nt.cs b/src/ipy/IronPython.Modules/nt.cs similarity index 100% rename from src/Modules/nt.cs rename to src/ipy/IronPython.Modules/nt.cs diff --git a/src/Modules/policy.IronPython.Modules.config b/src/ipy/IronPython.Modules/policy.IronPython.Modules.config similarity index 100% rename from src/Modules/policy.IronPython.Modules.config rename to src/ipy/IronPython.Modules/policy.IronPython.Modules.config diff --git a/src/Modules/pwd.cs b/src/ipy/IronPython.Modules/pwd.cs similarity index 100% rename from src/Modules/pwd.cs rename to src/ipy/IronPython.Modules/pwd.cs diff --git a/src/Modules/pyexpat.cs b/src/ipy/IronPython.Modules/pyexpat.cs similarity index 100% rename from src/Modules/pyexpat.cs rename to src/ipy/IronPython.Modules/pyexpat.cs diff --git a/src/Modules/re.cs b/src/ipy/IronPython.Modules/re.cs similarity index 100% rename from src/Modules/re.cs rename to src/ipy/IronPython.Modules/re.cs diff --git a/src/Modules/resource.cs b/src/ipy/IronPython.Modules/resource.cs similarity index 100% rename from src/Modules/resource.cs rename to src/ipy/IronPython.Modules/resource.cs diff --git a/src/Modules/select.cs b/src/ipy/IronPython.Modules/select.cs similarity index 100% rename from src/Modules/select.cs rename to src/ipy/IronPython.Modules/select.cs diff --git a/src/Modules/signal.cs b/src/ipy/IronPython.Modules/signal.cs similarity index 100% rename from src/Modules/signal.cs rename to src/ipy/IronPython.Modules/signal.cs diff --git a/src/Modules/spwd.cs b/src/ipy/IronPython.Modules/spwd.cs similarity index 100% rename from src/Modules/spwd.cs rename to src/ipy/IronPython.Modules/spwd.cs diff --git a/src/Modules/time.cs b/src/ipy/IronPython.Modules/time.cs similarity index 100% rename from src/Modules/time.cs rename to src/ipy/IronPython.Modules/time.cs diff --git a/src/Modules/winreg.cs b/src/ipy/IronPython.Modules/winreg.cs similarity index 100% rename from src/Modules/winreg.cs rename to src/ipy/IronPython.Modules/winreg.cs diff --git a/src/Modules/winsound.cs b/src/ipy/IronPython.Modules/winsound.cs similarity index 100% rename from src/Modules/winsound.cs rename to src/ipy/IronPython.Modules/winsound.cs diff --git a/src/Modules/xxsubtype.cs b/src/ipy/IronPython.Modules/xxsubtype.cs similarity index 100% rename from src/Modules/xxsubtype.cs rename to src/ipy/IronPython.Modules/xxsubtype.cs diff --git a/src/Modules/zipimport.cs b/src/ipy/IronPython.Modules/zipimport.cs similarity index 100% rename from src/Modules/zipimport.cs rename to src/ipy/IronPython.Modules/zipimport.cs diff --git a/src/Modules/zlib/Compress.cs b/src/ipy/IronPython.Modules/zlib/Compress.cs similarity index 100% rename from src/Modules/zlib/Compress.cs rename to src/ipy/IronPython.Modules/zlib/Compress.cs diff --git a/src/Modules/zlib/Decompress.cs b/src/ipy/IronPython.Modules/zlib/Decompress.cs similarity index 100% rename from src/Modules/zlib/Decompress.cs rename to src/ipy/IronPython.Modules/zlib/Decompress.cs diff --git a/src/Modules/zlib/ZlibModule.cs b/src/ipy/IronPython.Modules/zlib/ZlibModule.cs similarity index 100% rename from src/Modules/zlib/ZlibModule.cs rename to src/ipy/IronPython.Modules/zlib/ZlibModule.cs diff --git a/src/Modules/zlib/zlib.net/Adler32.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/Adler32.cs similarity index 100% rename from src/Modules/zlib/zlib.net/Adler32.cs rename to src/ipy/IronPython.Modules/zlib/zlib.net/Adler32.cs diff --git a/src/Modules/zlib/zlib.net/Deflate.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/Deflate.cs similarity index 100% rename from src/Modules/zlib/zlib.net/Deflate.cs rename to src/ipy/IronPython.Modules/zlib/zlib.net/Deflate.cs diff --git a/src/Modules/zlib/zlib.net/InfBlocks.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/InfBlocks.cs similarity index 100% rename from src/Modules/zlib/zlib.net/InfBlocks.cs rename to src/ipy/IronPython.Modules/zlib/zlib.net/InfBlocks.cs diff --git a/src/Modules/zlib/zlib.net/InfCodes.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/InfCodes.cs similarity index 100% rename from src/Modules/zlib/zlib.net/InfCodes.cs rename to src/ipy/IronPython.Modules/zlib/zlib.net/InfCodes.cs diff --git a/src/Modules/zlib/zlib.net/InfTree.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/InfTree.cs similarity index 100% rename from src/Modules/zlib/zlib.net/InfTree.cs rename to src/ipy/IronPython.Modules/zlib/zlib.net/InfTree.cs diff --git a/src/Modules/zlib/zlib.net/Inflate.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/Inflate.cs similarity index 100% rename from src/Modules/zlib/zlib.net/Inflate.cs rename to src/ipy/IronPython.Modules/zlib/zlib.net/Inflate.cs diff --git a/src/Modules/zlib/zlib.net/StaticTree.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/StaticTree.cs similarity index 100% rename from src/Modules/zlib/zlib.net/StaticTree.cs rename to src/ipy/IronPython.Modules/zlib/zlib.net/StaticTree.cs diff --git a/src/Modules/zlib/zlib.net/Tree.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/Tree.cs similarity index 100% rename from src/Modules/zlib/zlib.net/Tree.cs rename to src/ipy/IronPython.Modules/zlib/zlib.net/Tree.cs diff --git a/src/Modules/zlib/zlib.net/ZStream.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/ZStream.cs similarity index 100% rename from src/Modules/zlib/zlib.net/ZStream.cs rename to src/ipy/IronPython.Modules/zlib/zlib.net/ZStream.cs diff --git a/src/Modules/zlib/zlib.net/ZStreamException.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/ZStreamException.cs similarity index 100% rename from src/Modules/zlib/zlib.net/ZStreamException.cs rename to src/ipy/IronPython.Modules/zlib/zlib.net/ZStreamException.cs diff --git a/src/Modules/zlib/zlib.net/Zlib.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/Zlib.cs similarity index 100% rename from src/Modules/zlib/zlib.net/Zlib.cs rename to src/ipy/IronPython.Modules/zlib/zlib.net/Zlib.cs diff --git a/src/Modules/zlib/zlib.net/history.txt b/src/ipy/IronPython.Modules/zlib/zlib.net/history.txt similarity index 100% rename from src/Modules/zlib/zlib.net/history.txt rename to src/ipy/IronPython.Modules/zlib/zlib.net/history.txt diff --git a/src/Modules/zlib/zlib.net/license.txt b/src/ipy/IronPython.Modules/zlib/zlib.net/license.txt similarity index 100% rename from src/Modules/zlib/zlib.net/license.txt rename to src/ipy/IronPython.Modules/zlib/zlib.net/license.txt diff --git a/src/Modules/zlib/zlib.net/readme.txt b/src/ipy/IronPython.Modules/zlib/zlib.net/readme.txt similarity index 100% rename from src/Modules/zlib/zlib.net/readme.txt rename to src/ipy/IronPython.Modules/zlib/zlib.net/readme.txt diff --git a/src/IronPython/Compiler/Ast/AndExpression.cs b/src/ipy/IronPython/Compiler/Ast/AndExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/AndExpression.cs rename to src/ipy/IronPython/Compiler/Ast/AndExpression.cs diff --git a/src/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs b/src/ipy/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs rename to src/ipy/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs diff --git a/src/IronPython/Compiler/Ast/AssertStatement.cs b/src/ipy/IronPython/Compiler/Ast/AssertStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/AssertStatement.cs rename to src/ipy/IronPython/Compiler/Ast/AssertStatement.cs diff --git a/src/IronPython/Compiler/Ast/AssignmentStatement.cs b/src/ipy/IronPython/Compiler/Ast/AssignmentStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/AssignmentStatement.cs rename to src/ipy/IronPython/Compiler/Ast/AssignmentStatement.cs diff --git a/src/IronPython/Compiler/Ast/AstMethods.cs b/src/ipy/IronPython/Compiler/Ast/AstMethods.cs similarity index 100% rename from src/IronPython/Compiler/Ast/AstMethods.cs rename to src/ipy/IronPython/Compiler/Ast/AstMethods.cs diff --git a/src/IronPython/Compiler/Ast/AsyncStatement.cs b/src/ipy/IronPython/Compiler/Ast/AsyncStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/AsyncStatement.cs rename to src/ipy/IronPython/Compiler/Ast/AsyncStatement.cs diff --git a/src/IronPython/Compiler/Ast/AugmentedAssignStatement.cs b/src/ipy/IronPython/Compiler/Ast/AugmentedAssignStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/AugmentedAssignStatement.cs rename to src/ipy/IronPython/Compiler/Ast/AugmentedAssignStatement.cs diff --git a/src/IronPython/Compiler/Ast/BinaryExpression.Generated.cs b/src/ipy/IronPython/Compiler/Ast/BinaryExpression.Generated.cs similarity index 100% rename from src/IronPython/Compiler/Ast/BinaryExpression.Generated.cs rename to src/ipy/IronPython/Compiler/Ast/BinaryExpression.Generated.cs diff --git a/src/IronPython/Compiler/Ast/BinaryExpression.cs b/src/ipy/IronPython/Compiler/Ast/BinaryExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/BinaryExpression.cs rename to src/ipy/IronPython/Compiler/Ast/BinaryExpression.cs diff --git a/src/IronPython/Compiler/Ast/BreakStatement.cs b/src/ipy/IronPython/Compiler/Ast/BreakStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/BreakStatement.cs rename to src/ipy/IronPython/Compiler/Ast/BreakStatement.cs diff --git a/src/IronPython/Compiler/Ast/CallExpression.cs b/src/ipy/IronPython/Compiler/Ast/CallExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/CallExpression.cs rename to src/ipy/IronPython/Compiler/Ast/CallExpression.cs diff --git a/src/IronPython/Compiler/Ast/ClassDefinition.cs b/src/ipy/IronPython/Compiler/Ast/ClassDefinition.cs similarity index 100% rename from src/IronPython/Compiler/Ast/ClassDefinition.cs rename to src/ipy/IronPython/Compiler/Ast/ClassDefinition.cs diff --git a/src/IronPython/Compiler/Ast/Comprehension.cs b/src/ipy/IronPython/Compiler/Ast/Comprehension.cs similarity index 100% rename from src/IronPython/Compiler/Ast/Comprehension.cs rename to src/ipy/IronPython/Compiler/Ast/Comprehension.cs diff --git a/src/IronPython/Compiler/Ast/ComprehensionFor.cs b/src/ipy/IronPython/Compiler/Ast/ComprehensionFor.cs similarity index 100% rename from src/IronPython/Compiler/Ast/ComprehensionFor.cs rename to src/ipy/IronPython/Compiler/Ast/ComprehensionFor.cs diff --git a/src/IronPython/Compiler/Ast/ComprehensionIf.cs b/src/ipy/IronPython/Compiler/Ast/ComprehensionIf.cs similarity index 100% rename from src/IronPython/Compiler/Ast/ComprehensionIf.cs rename to src/ipy/IronPython/Compiler/Ast/ComprehensionIf.cs diff --git a/src/IronPython/Compiler/Ast/ConditionalExpression.cs b/src/ipy/IronPython/Compiler/Ast/ConditionalExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/ConditionalExpression.cs rename to src/ipy/IronPython/Compiler/Ast/ConditionalExpression.cs diff --git a/src/IronPython/Compiler/Ast/ConstantExpression.cs b/src/ipy/IronPython/Compiler/Ast/ConstantExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/ConstantExpression.cs rename to src/ipy/IronPython/Compiler/Ast/ConstantExpression.cs diff --git a/src/IronPython/Compiler/Ast/ContinueStatement.cs b/src/ipy/IronPython/Compiler/Ast/ContinueStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/ContinueStatement.cs rename to src/ipy/IronPython/Compiler/Ast/ContinueStatement.cs diff --git a/src/IronPython/Compiler/Ast/DelStatement.cs b/src/ipy/IronPython/Compiler/Ast/DelStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/DelStatement.cs rename to src/ipy/IronPython/Compiler/Ast/DelStatement.cs diff --git a/src/IronPython/Compiler/Ast/DictionaryExpression.cs b/src/ipy/IronPython/Compiler/Ast/DictionaryExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/DictionaryExpression.cs rename to src/ipy/IronPython/Compiler/Ast/DictionaryExpression.cs diff --git a/src/IronPython/Compiler/Ast/DottedName.cs b/src/ipy/IronPython/Compiler/Ast/DottedName.cs similarity index 100% rename from src/IronPython/Compiler/Ast/DottedName.cs rename to src/ipy/IronPython/Compiler/Ast/DottedName.cs diff --git a/src/IronPython/Compiler/Ast/DynamicConvertExpression.cs b/src/ipy/IronPython/Compiler/Ast/DynamicConvertExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/DynamicConvertExpression.cs rename to src/ipy/IronPython/Compiler/Ast/DynamicConvertExpression.cs diff --git a/src/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs b/src/ipy/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs rename to src/ipy/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs diff --git a/src/IronPython/Compiler/Ast/EmptyStatement.cs b/src/ipy/IronPython/Compiler/Ast/EmptyStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/EmptyStatement.cs rename to src/ipy/IronPython/Compiler/Ast/EmptyStatement.cs diff --git a/src/IronPython/Compiler/Ast/ErrorExpression.cs b/src/ipy/IronPython/Compiler/Ast/ErrorExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/ErrorExpression.cs rename to src/ipy/IronPython/Compiler/Ast/ErrorExpression.cs diff --git a/src/IronPython/Compiler/Ast/Expression.cs b/src/ipy/IronPython/Compiler/Ast/Expression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/Expression.cs rename to src/ipy/IronPython/Compiler/Ast/Expression.cs diff --git a/src/IronPython/Compiler/Ast/ExpressionStatement.cs b/src/ipy/IronPython/Compiler/Ast/ExpressionStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/ExpressionStatement.cs rename to src/ipy/IronPython/Compiler/Ast/ExpressionStatement.cs diff --git a/src/IronPython/Compiler/Ast/FlowChecker.cs b/src/ipy/IronPython/Compiler/Ast/FlowChecker.cs similarity index 100% rename from src/IronPython/Compiler/Ast/FlowChecker.cs rename to src/ipy/IronPython/Compiler/Ast/FlowChecker.cs diff --git a/src/IronPython/Compiler/Ast/ForStatement.cs b/src/ipy/IronPython/Compiler/Ast/ForStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/ForStatement.cs rename to src/ipy/IronPython/Compiler/Ast/ForStatement.cs diff --git a/src/IronPython/Compiler/Ast/FormattedValueExpression.cs b/src/ipy/IronPython/Compiler/Ast/FormattedValueExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/FormattedValueExpression.cs rename to src/ipy/IronPython/Compiler/Ast/FormattedValueExpression.cs diff --git a/src/IronPython/Compiler/Ast/FromImportStatement.cs b/src/ipy/IronPython/Compiler/Ast/FromImportStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/FromImportStatement.cs rename to src/ipy/IronPython/Compiler/Ast/FromImportStatement.cs diff --git a/src/IronPython/Compiler/Ast/FunctionDefinition.cs b/src/ipy/IronPython/Compiler/Ast/FunctionDefinition.cs similarity index 100% rename from src/IronPython/Compiler/Ast/FunctionDefinition.cs rename to src/ipy/IronPython/Compiler/Ast/FunctionDefinition.cs diff --git a/src/IronPython/Compiler/Ast/GeneratorExpression.cs b/src/ipy/IronPython/Compiler/Ast/GeneratorExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/GeneratorExpression.cs rename to src/ipy/IronPython/Compiler/Ast/GeneratorExpression.cs diff --git a/src/IronPython/Compiler/Ast/GetGlobalContextExpression.cs b/src/ipy/IronPython/Compiler/Ast/GetGlobalContextExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/GetGlobalContextExpression.cs rename to src/ipy/IronPython/Compiler/Ast/GetGlobalContextExpression.cs diff --git a/src/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs b/src/ipy/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs rename to src/ipy/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs diff --git a/src/IronPython/Compiler/Ast/GlobalStatement.cs b/src/ipy/IronPython/Compiler/Ast/GlobalStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/GlobalStatement.cs rename to src/ipy/IronPython/Compiler/Ast/GlobalStatement.cs diff --git a/src/IronPython/Compiler/Ast/ILoopStatement.cs b/src/ipy/IronPython/Compiler/Ast/ILoopStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/ILoopStatement.cs rename to src/ipy/IronPython/Compiler/Ast/ILoopStatement.cs diff --git a/src/IronPython/Compiler/Ast/IfStatement.cs b/src/ipy/IronPython/Compiler/Ast/IfStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/IfStatement.cs rename to src/ipy/IronPython/Compiler/Ast/IfStatement.cs diff --git a/src/IronPython/Compiler/Ast/IfStatementTest.cs b/src/ipy/IronPython/Compiler/Ast/IfStatementTest.cs similarity index 100% rename from src/IronPython/Compiler/Ast/IfStatementTest.cs rename to src/ipy/IronPython/Compiler/Ast/IfStatementTest.cs diff --git a/src/IronPython/Compiler/Ast/ImportStatement.cs b/src/ipy/IronPython/Compiler/Ast/ImportStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/ImportStatement.cs rename to src/ipy/IronPython/Compiler/Ast/ImportStatement.cs diff --git a/src/IronPython/Compiler/Ast/IndexExpression.cs b/src/ipy/IronPython/Compiler/Ast/IndexExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/IndexExpression.cs rename to src/ipy/IronPython/Compiler/Ast/IndexExpression.cs diff --git a/src/IronPython/Compiler/Ast/JoinedStringExpression.cs b/src/ipy/IronPython/Compiler/Ast/JoinedStringExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/JoinedStringExpression.cs rename to src/ipy/IronPython/Compiler/Ast/JoinedStringExpression.cs diff --git a/src/IronPython/Compiler/Ast/Keyword.cs b/src/ipy/IronPython/Compiler/Ast/Keyword.cs similarity index 100% rename from src/IronPython/Compiler/Ast/Keyword.cs rename to src/ipy/IronPython/Compiler/Ast/Keyword.cs diff --git a/src/IronPython/Compiler/Ast/LambdaExpression.cs b/src/ipy/IronPython/Compiler/Ast/LambdaExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/LambdaExpression.cs rename to src/ipy/IronPython/Compiler/Ast/LambdaExpression.cs diff --git a/src/IronPython/Compiler/Ast/ListExpression.cs b/src/ipy/IronPython/Compiler/Ast/ListExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/ListExpression.cs rename to src/ipy/IronPython/Compiler/Ast/ListExpression.cs diff --git a/src/IronPython/Compiler/Ast/MemberExpression.cs b/src/ipy/IronPython/Compiler/Ast/MemberExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/MemberExpression.cs rename to src/ipy/IronPython/Compiler/Ast/MemberExpression.cs diff --git a/src/IronPython/Compiler/Ast/ModuleName.cs b/src/ipy/IronPython/Compiler/Ast/ModuleName.cs similarity index 100% rename from src/IronPython/Compiler/Ast/ModuleName.cs rename to src/ipy/IronPython/Compiler/Ast/ModuleName.cs diff --git a/src/IronPython/Compiler/Ast/NameExpression.cs b/src/ipy/IronPython/Compiler/Ast/NameExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/NameExpression.cs rename to src/ipy/IronPython/Compiler/Ast/NameExpression.cs diff --git a/src/IronPython/Compiler/Ast/Node.cs b/src/ipy/IronPython/Compiler/Ast/Node.cs similarity index 100% rename from src/IronPython/Compiler/Ast/Node.cs rename to src/ipy/IronPython/Compiler/Ast/Node.cs diff --git a/src/IronPython/Compiler/Ast/NonlocalStatement.cs b/src/ipy/IronPython/Compiler/Ast/NonlocalStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/NonlocalStatement.cs rename to src/ipy/IronPython/Compiler/Ast/NonlocalStatement.cs diff --git a/src/IronPython/Compiler/Ast/OrExpression.cs b/src/ipy/IronPython/Compiler/Ast/OrExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/OrExpression.cs rename to src/ipy/IronPython/Compiler/Ast/OrExpression.cs diff --git a/src/IronPython/Compiler/Ast/Parameter.cs b/src/ipy/IronPython/Compiler/Ast/Parameter.cs similarity index 100% rename from src/IronPython/Compiler/Ast/Parameter.cs rename to src/ipy/IronPython/Compiler/Ast/Parameter.cs diff --git a/src/IronPython/Compiler/Ast/ParenthesisExpression.cs b/src/ipy/IronPython/Compiler/Ast/ParenthesisExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/ParenthesisExpression.cs rename to src/ipy/IronPython/Compiler/Ast/ParenthesisExpression.cs diff --git a/src/IronPython/Compiler/Ast/PythonAst.cs b/src/ipy/IronPython/Compiler/Ast/PythonAst.cs similarity index 100% rename from src/IronPython/Compiler/Ast/PythonAst.cs rename to src/ipy/IronPython/Compiler/Ast/PythonAst.cs diff --git a/src/IronPython/Compiler/Ast/PythonConstantExpression.cs b/src/ipy/IronPython/Compiler/Ast/PythonConstantExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/PythonConstantExpression.cs rename to src/ipy/IronPython/Compiler/Ast/PythonConstantExpression.cs diff --git a/src/IronPython/Compiler/Ast/PythonNameBinder.cs b/src/ipy/IronPython/Compiler/Ast/PythonNameBinder.cs similarity index 100% rename from src/IronPython/Compiler/Ast/PythonNameBinder.cs rename to src/ipy/IronPython/Compiler/Ast/PythonNameBinder.cs diff --git a/src/IronPython/Compiler/Ast/PythonReference.cs b/src/ipy/IronPython/Compiler/Ast/PythonReference.cs similarity index 100% rename from src/IronPython/Compiler/Ast/PythonReference.cs rename to src/ipy/IronPython/Compiler/Ast/PythonReference.cs diff --git a/src/IronPython/Compiler/Ast/PythonVariable.cs b/src/ipy/IronPython/Compiler/Ast/PythonVariable.cs similarity index 100% rename from src/IronPython/Compiler/Ast/PythonVariable.cs rename to src/ipy/IronPython/Compiler/Ast/PythonVariable.cs diff --git a/src/IronPython/Compiler/Ast/PythonWalker.Generated.cs b/src/ipy/IronPython/Compiler/Ast/PythonWalker.Generated.cs similarity index 100% rename from src/IronPython/Compiler/Ast/PythonWalker.Generated.cs rename to src/ipy/IronPython/Compiler/Ast/PythonWalker.Generated.cs diff --git a/src/IronPython/Compiler/Ast/RaiseStatement.cs b/src/ipy/IronPython/Compiler/Ast/RaiseStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/RaiseStatement.cs rename to src/ipy/IronPython/Compiler/Ast/RaiseStatement.cs diff --git a/src/IronPython/Compiler/Ast/RelativeModuleName.cs b/src/ipy/IronPython/Compiler/Ast/RelativeModuleName.cs similarity index 100% rename from src/IronPython/Compiler/Ast/RelativeModuleName.cs rename to src/ipy/IronPython/Compiler/Ast/RelativeModuleName.cs diff --git a/src/IronPython/Compiler/Ast/ReturnStatement.cs b/src/ipy/IronPython/Compiler/Ast/ReturnStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/ReturnStatement.cs rename to src/ipy/IronPython/Compiler/Ast/ReturnStatement.cs diff --git a/src/IronPython/Compiler/Ast/ScopeStatement.cs b/src/ipy/IronPython/Compiler/Ast/ScopeStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/ScopeStatement.cs rename to src/ipy/IronPython/Compiler/Ast/ScopeStatement.cs diff --git a/src/IronPython/Compiler/Ast/SequenceExpression.cs b/src/ipy/IronPython/Compiler/Ast/SequenceExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/SequenceExpression.cs rename to src/ipy/IronPython/Compiler/Ast/SequenceExpression.cs diff --git a/src/IronPython/Compiler/Ast/SerializedScopeStatement.cs b/src/ipy/IronPython/Compiler/Ast/SerializedScopeStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/SerializedScopeStatement.cs rename to src/ipy/IronPython/Compiler/Ast/SerializedScopeStatement.cs diff --git a/src/IronPython/Compiler/Ast/SetExpression.cs b/src/ipy/IronPython/Compiler/Ast/SetExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/SetExpression.cs rename to src/ipy/IronPython/Compiler/Ast/SetExpression.cs diff --git a/src/IronPython/Compiler/Ast/SliceExpression.cs b/src/ipy/IronPython/Compiler/Ast/SliceExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/SliceExpression.cs rename to src/ipy/IronPython/Compiler/Ast/SliceExpression.cs diff --git a/src/IronPython/Compiler/Ast/StarredExpression.cs b/src/ipy/IronPython/Compiler/Ast/StarredExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/StarredExpression.cs rename to src/ipy/IronPython/Compiler/Ast/StarredExpression.cs diff --git a/src/IronPython/Compiler/Ast/Statement.cs b/src/ipy/IronPython/Compiler/Ast/Statement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/Statement.cs rename to src/ipy/IronPython/Compiler/Ast/Statement.cs diff --git a/src/IronPython/Compiler/Ast/SuiteStatement.cs b/src/ipy/IronPython/Compiler/Ast/SuiteStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/SuiteStatement.cs rename to src/ipy/IronPython/Compiler/Ast/SuiteStatement.cs diff --git a/src/IronPython/Compiler/Ast/TryStatement.cs b/src/ipy/IronPython/Compiler/Ast/TryStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/TryStatement.cs rename to src/ipy/IronPython/Compiler/Ast/TryStatement.cs diff --git a/src/IronPython/Compiler/Ast/TupleExpression.cs b/src/ipy/IronPython/Compiler/Ast/TupleExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/TupleExpression.cs rename to src/ipy/IronPython/Compiler/Ast/TupleExpression.cs diff --git a/src/IronPython/Compiler/Ast/UnaryExpression.cs b/src/ipy/IronPython/Compiler/Ast/UnaryExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/UnaryExpression.cs rename to src/ipy/IronPython/Compiler/Ast/UnaryExpression.cs diff --git a/src/IronPython/Compiler/Ast/VariableKind.cs b/src/ipy/IronPython/Compiler/Ast/VariableKind.cs similarity index 100% rename from src/IronPython/Compiler/Ast/VariableKind.cs rename to src/ipy/IronPython/Compiler/Ast/VariableKind.cs diff --git a/src/IronPython/Compiler/Ast/WhileStatement.cs b/src/ipy/IronPython/Compiler/Ast/WhileStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/WhileStatement.cs rename to src/ipy/IronPython/Compiler/Ast/WhileStatement.cs diff --git a/src/IronPython/Compiler/Ast/WithStatement.cs b/src/ipy/IronPython/Compiler/Ast/WithStatement.cs similarity index 100% rename from src/IronPython/Compiler/Ast/WithStatement.cs rename to src/ipy/IronPython/Compiler/Ast/WithStatement.cs diff --git a/src/IronPython/Compiler/Ast/YieldExpression.cs b/src/ipy/IronPython/Compiler/Ast/YieldExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/YieldExpression.cs rename to src/ipy/IronPython/Compiler/Ast/YieldExpression.cs diff --git a/src/IronPython/Compiler/Ast/YieldFromExpression.cs b/src/ipy/IronPython/Compiler/Ast/YieldFromExpression.cs similarity index 100% rename from src/IronPython/Compiler/Ast/YieldFromExpression.cs rename to src/ipy/IronPython/Compiler/Ast/YieldFromExpression.cs diff --git a/src/IronPython/Compiler/ClosureExpression.cs b/src/ipy/IronPython/Compiler/ClosureExpression.cs similarity index 100% rename from src/IronPython/Compiler/ClosureExpression.cs rename to src/ipy/IronPython/Compiler/ClosureExpression.cs diff --git a/src/IronPython/Compiler/ClosureInfo.cs b/src/ipy/IronPython/Compiler/ClosureInfo.cs similarity index 100% rename from src/IronPython/Compiler/ClosureInfo.cs rename to src/ipy/IronPython/Compiler/ClosureInfo.cs diff --git a/src/IronPython/Compiler/CollectableCompilationMode.cs b/src/ipy/IronPython/Compiler/CollectableCompilationMode.cs similarity index 100% rename from src/IronPython/Compiler/CollectableCompilationMode.cs rename to src/ipy/IronPython/Compiler/CollectableCompilationMode.cs diff --git a/src/IronPython/Compiler/CompilationMode.cs b/src/ipy/IronPython/Compiler/CompilationMode.cs similarity index 100% rename from src/IronPython/Compiler/CompilationMode.cs rename to src/ipy/IronPython/Compiler/CompilationMode.cs diff --git a/src/IronPython/Compiler/GeneratorRewriter.cs b/src/ipy/IronPython/Compiler/GeneratorRewriter.cs similarity index 100% rename from src/IronPython/Compiler/GeneratorRewriter.cs rename to src/ipy/IronPython/Compiler/GeneratorRewriter.cs diff --git a/src/IronPython/Compiler/LazyCode.cs b/src/ipy/IronPython/Compiler/LazyCode.cs similarity index 100% rename from src/IronPython/Compiler/LazyCode.cs rename to src/ipy/IronPython/Compiler/LazyCode.cs diff --git a/src/IronPython/Compiler/LookupCompilationMode.cs b/src/ipy/IronPython/Compiler/LookupCompilationMode.cs similarity index 100% rename from src/IronPython/Compiler/LookupCompilationMode.cs rename to src/ipy/IronPython/Compiler/LookupCompilationMode.cs diff --git a/src/IronPython/Compiler/OnDiskScriptCode.cs b/src/ipy/IronPython/Compiler/OnDiskScriptCode.cs similarity index 100% rename from src/IronPython/Compiler/OnDiskScriptCode.cs rename to src/ipy/IronPython/Compiler/OnDiskScriptCode.cs diff --git a/src/IronPython/Compiler/Parser.cs b/src/ipy/IronPython/Compiler/Parser.cs similarity index 100% rename from src/IronPython/Compiler/Parser.cs rename to src/ipy/IronPython/Compiler/Parser.cs diff --git a/src/IronPython/Compiler/PythonCallTargets.cs b/src/ipy/IronPython/Compiler/PythonCallTargets.cs similarity index 100% rename from src/IronPython/Compiler/PythonCallTargets.cs rename to src/ipy/IronPython/Compiler/PythonCallTargets.cs diff --git a/src/IronPython/Compiler/PythonCompilerOptions.cs b/src/ipy/IronPython/Compiler/PythonCompilerOptions.cs similarity index 100% rename from src/IronPython/Compiler/PythonCompilerOptions.cs rename to src/ipy/IronPython/Compiler/PythonCompilerOptions.cs diff --git a/src/IronPython/Compiler/PythonDynamicExpression.cs b/src/ipy/IronPython/Compiler/PythonDynamicExpression.cs similarity index 100% rename from src/IronPython/Compiler/PythonDynamicExpression.cs rename to src/ipy/IronPython/Compiler/PythonDynamicExpression.cs diff --git a/src/IronPython/Compiler/PythonGlobal.cs b/src/ipy/IronPython/Compiler/PythonGlobal.cs similarity index 100% rename from src/IronPython/Compiler/PythonGlobal.cs rename to src/ipy/IronPython/Compiler/PythonGlobal.cs diff --git a/src/IronPython/Compiler/PythonGlobalVariableExpression.cs b/src/ipy/IronPython/Compiler/PythonGlobalVariableExpression.cs similarity index 100% rename from src/IronPython/Compiler/PythonGlobalVariableExpression.cs rename to src/ipy/IronPython/Compiler/PythonGlobalVariableExpression.cs diff --git a/src/IronPython/Compiler/PythonOperator.cs b/src/ipy/IronPython/Compiler/PythonOperator.cs similarity index 100% rename from src/IronPython/Compiler/PythonOperator.cs rename to src/ipy/IronPython/Compiler/PythonOperator.cs diff --git a/src/IronPython/Compiler/PythonSavableScriptCode.cs b/src/ipy/IronPython/Compiler/PythonSavableScriptCode.cs similarity index 100% rename from src/IronPython/Compiler/PythonSavableScriptCode.cs rename to src/ipy/IronPython/Compiler/PythonSavableScriptCode.cs diff --git a/src/IronPython/Compiler/PythonScriptCode.cs b/src/ipy/IronPython/Compiler/PythonScriptCode.cs similarity index 100% rename from src/IronPython/Compiler/PythonScriptCode.cs rename to src/ipy/IronPython/Compiler/PythonScriptCode.cs diff --git a/src/IronPython/Compiler/ReducableDynamicExpression.cs b/src/ipy/IronPython/Compiler/ReducableDynamicExpression.cs similarity index 100% rename from src/IronPython/Compiler/ReducableDynamicExpression.cs rename to src/ipy/IronPython/Compiler/ReducableDynamicExpression.cs diff --git a/src/IronPython/Compiler/RunnableScriptCode.cs b/src/ipy/IronPython/Compiler/RunnableScriptCode.cs similarity index 100% rename from src/IronPython/Compiler/RunnableScriptCode.cs rename to src/ipy/IronPython/Compiler/RunnableScriptCode.cs diff --git a/src/IronPython/Compiler/RuntimeScriptCode.cs b/src/ipy/IronPython/Compiler/RuntimeScriptCode.cs similarity index 100% rename from src/IronPython/Compiler/RuntimeScriptCode.cs rename to src/ipy/IronPython/Compiler/RuntimeScriptCode.cs diff --git a/src/IronPython/Compiler/ToDiskCompilationMode.cs b/src/ipy/IronPython/Compiler/ToDiskCompilationMode.cs similarity index 100% rename from src/IronPython/Compiler/ToDiskCompilationMode.cs rename to src/ipy/IronPython/Compiler/ToDiskCompilationMode.cs diff --git a/src/IronPython/Compiler/Token.cs b/src/ipy/IronPython/Compiler/Token.cs similarity index 100% rename from src/IronPython/Compiler/Token.cs rename to src/ipy/IronPython/Compiler/Token.cs diff --git a/src/IronPython/Compiler/TokenKind.Generated.cs b/src/ipy/IronPython/Compiler/TokenKind.Generated.cs similarity index 100% rename from src/IronPython/Compiler/TokenKind.Generated.cs rename to src/ipy/IronPython/Compiler/TokenKind.Generated.cs diff --git a/src/IronPython/Compiler/Tokenizer.Generated.cs b/src/ipy/IronPython/Compiler/Tokenizer.Generated.cs similarity index 100% rename from src/IronPython/Compiler/Tokenizer.Generated.cs rename to src/ipy/IronPython/Compiler/Tokenizer.Generated.cs diff --git a/src/IronPython/Compiler/Tokenizer.cs b/src/ipy/IronPython/Compiler/Tokenizer.cs similarity index 100% rename from src/IronPython/Compiler/Tokenizer.cs rename to src/ipy/IronPython/Compiler/Tokenizer.cs diff --git a/src/IronPython/Compiler/UncollectableCompilationMode.Generated.cs b/src/ipy/IronPython/Compiler/UncollectableCompilationMode.Generated.cs similarity index 100% rename from src/IronPython/Compiler/UncollectableCompilationMode.Generated.cs rename to src/ipy/IronPython/Compiler/UncollectableCompilationMode.Generated.cs diff --git a/src/IronPython/Compiler/UncollectableCompilationMode.cs b/src/ipy/IronPython/Compiler/UncollectableCompilationMode.cs similarity index 100% rename from src/IronPython/Compiler/UncollectableCompilationMode.cs rename to src/ipy/IronPython/Compiler/UncollectableCompilationMode.cs diff --git a/src/IronPython/FakeInteropServices.cs b/src/ipy/IronPython/FakeInteropServices.cs similarity index 100% rename from src/IronPython/FakeInteropServices.cs rename to src/ipy/IronPython/FakeInteropServices.cs diff --git a/src/IronPython/Hosting/Python.cs b/src/ipy/IronPython/Hosting/Python.cs similarity index 100% rename from src/IronPython/Hosting/Python.cs rename to src/ipy/IronPython/Hosting/Python.cs diff --git a/src/IronPython/Hosting/PythonCodeDomCodeGen.cs b/src/ipy/IronPython/Hosting/PythonCodeDomCodeGen.cs similarity index 100% rename from src/IronPython/Hosting/PythonCodeDomCodeGen.cs rename to src/ipy/IronPython/Hosting/PythonCodeDomCodeGen.cs diff --git a/src/IronPython/Hosting/PythonCommandLine.cs b/src/ipy/IronPython/Hosting/PythonCommandLine.cs similarity index 100% rename from src/IronPython/Hosting/PythonCommandLine.cs rename to src/ipy/IronPython/Hosting/PythonCommandLine.cs diff --git a/src/IronPython/Hosting/PythonConsoleOptions.cs b/src/ipy/IronPython/Hosting/PythonConsoleOptions.cs similarity index 100% rename from src/IronPython/Hosting/PythonConsoleOptions.cs rename to src/ipy/IronPython/Hosting/PythonConsoleOptions.cs diff --git a/src/IronPython/Hosting/PythonOptionsParser.cs b/src/ipy/IronPython/Hosting/PythonOptionsParser.cs similarity index 100% rename from src/IronPython/Hosting/PythonOptionsParser.cs rename to src/ipy/IronPython/Hosting/PythonOptionsParser.cs diff --git a/src/IronPython/Hosting/PythonService.cs b/src/ipy/IronPython/Hosting/PythonService.cs similarity index 100% rename from src/IronPython/Hosting/PythonService.cs rename to src/ipy/IronPython/Hosting/PythonService.cs diff --git a/src/IronPython/Interop/Windows/Interop.Libraries.cs b/src/ipy/IronPython/Interop/Windows/Interop.Libraries.cs similarity index 100% rename from src/IronPython/Interop/Windows/Interop.Libraries.cs rename to src/ipy/IronPython/Interop/Windows/Interop.Libraries.cs diff --git a/src/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs b/src/ipy/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs similarity index 100% rename from src/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs rename to src/ipy/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs diff --git a/src/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs b/src/ipy/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs similarity index 100% rename from src/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs rename to src/ipy/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs diff --git a/src/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs b/src/ipy/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs similarity index 100% rename from src/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs rename to src/ipy/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs diff --git a/src/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs b/src/ipy/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs similarity index 100% rename from src/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs rename to src/ipy/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs diff --git a/src/IronPython/IronPython.csproj b/src/ipy/IronPython/IronPython.csproj similarity index 100% rename from src/IronPython/IronPython.csproj rename to src/ipy/IronPython/IronPython.csproj diff --git a/src/IronPython/Lib/iptest/__init__.py b/src/ipy/IronPython/Lib/iptest/__init__.py similarity index 100% rename from src/IronPython/Lib/iptest/__init__.py rename to src/ipy/IronPython/Lib/iptest/__init__.py diff --git a/src/IronPython/Lib/iptest/cominterop_util.py b/src/ipy/IronPython/Lib/iptest/cominterop_util.py similarity index 100% rename from src/IronPython/Lib/iptest/cominterop_util.py rename to src/ipy/IronPython/Lib/iptest/cominterop_util.py diff --git a/src/IronPython/Lib/iptest/console_util.py b/src/ipy/IronPython/Lib/iptest/console_util.py similarity index 100% rename from src/IronPython/Lib/iptest/console_util.py rename to src/ipy/IronPython/Lib/iptest/console_util.py diff --git a/src/IronPython/Lib/iptest/file_util.py b/src/ipy/IronPython/Lib/iptest/file_util.py similarity index 100% rename from src/IronPython/Lib/iptest/file_util.py rename to src/ipy/IronPython/Lib/iptest/file_util.py diff --git a/src/IronPython/Lib/iptest/ipunittest.py b/src/ipy/IronPython/Lib/iptest/ipunittest.py similarity index 100% rename from src/IronPython/Lib/iptest/ipunittest.py rename to src/ipy/IronPython/Lib/iptest/ipunittest.py diff --git a/src/IronPython/Lib/iptest/misc_util.py b/src/ipy/IronPython/Lib/iptest/misc_util.py similarity index 100% rename from src/IronPython/Lib/iptest/misc_util.py rename to src/ipy/IronPython/Lib/iptest/misc_util.py diff --git a/src/IronPython/Lib/iptest/process_util.py b/src/ipy/IronPython/Lib/iptest/process_util.py similarity index 100% rename from src/IronPython/Lib/iptest/process_util.py rename to src/ipy/IronPython/Lib/iptest/process_util.py diff --git a/src/IronPython/Lib/iptest/runner.py b/src/ipy/IronPython/Lib/iptest/runner.py similarity index 100% rename from src/IronPython/Lib/iptest/runner.py rename to src/ipy/IronPython/Lib/iptest/runner.py diff --git a/src/IronPython/Lib/iptest/test_env.py b/src/ipy/IronPython/Lib/iptest/test_env.py similarity index 100% rename from src/IronPython/Lib/iptest/test_env.py rename to src/ipy/IronPython/Lib/iptest/test_env.py diff --git a/src/IronPython/Lib/iptest/type_util.py b/src/ipy/IronPython/Lib/iptest/type_util.py similarity index 100% rename from src/IronPython/Lib/iptest/type_util.py rename to src/ipy/IronPython/Lib/iptest/type_util.py diff --git a/src/IronPython/Modules/Builtin.Generated.cs b/src/ipy/IronPython/Modules/Builtin.Generated.cs similarity index 100% rename from src/IronPython/Modules/Builtin.Generated.cs rename to src/ipy/IronPython/Modules/Builtin.Generated.cs diff --git a/src/IronPython/Modules/Builtin.cs b/src/ipy/IronPython/Modules/Builtin.cs similarity index 100% rename from src/IronPython/Modules/Builtin.cs rename to src/ipy/IronPython/Modules/Builtin.cs diff --git a/src/IronPython/Modules/_ast.cs b/src/ipy/IronPython/Modules/_ast.cs similarity index 100% rename from src/IronPython/Modules/_ast.cs rename to src/ipy/IronPython/Modules/_ast.cs diff --git a/src/IronPython/Modules/_fileio.cs b/src/ipy/IronPython/Modules/_fileio.cs similarity index 100% rename from src/IronPython/Modules/_fileio.cs rename to src/ipy/IronPython/Modules/_fileio.cs diff --git a/src/IronPython/Modules/_imp.cs b/src/ipy/IronPython/Modules/_imp.cs similarity index 100% rename from src/IronPython/Modules/_imp.cs rename to src/ipy/IronPython/Modules/_imp.cs diff --git a/src/IronPython/Modules/_io.cs b/src/ipy/IronPython/Modules/_io.cs similarity index 100% rename from src/IronPython/Modules/_io.cs rename to src/ipy/IronPython/Modules/_io.cs diff --git a/src/IronPython/Modules/_io/BytesIO.cs b/src/ipy/IronPython/Modules/_io/BytesIO.cs similarity index 100% rename from src/IronPython/Modules/_io/BytesIO.cs rename to src/ipy/IronPython/Modules/_io/BytesIO.cs diff --git a/src/IronPython/Modules/_io/StringIO.cs b/src/ipy/IronPython/Modules/_io/StringIO.cs similarity index 100% rename from src/IronPython/Modules/_io/StringIO.cs rename to src/ipy/IronPython/Modules/_io/StringIO.cs diff --git a/src/IronPython/Modules/_locale.cs b/src/ipy/IronPython/Modules/_locale.cs similarity index 100% rename from src/IronPython/Modules/_locale.cs rename to src/ipy/IronPython/Modules/_locale.cs diff --git a/src/IronPython/Modules/sys.cs b/src/ipy/IronPython/Modules/sys.cs similarity index 100% rename from src/IronPython/Modules/sys.cs rename to src/ipy/IronPython/Modules/sys.cs diff --git a/src/IronPython/Modules/unicodedata.cs b/src/ipy/IronPython/Modules/unicodedata.cs similarity index 100% rename from src/IronPython/Modules/unicodedata.cs rename to src/ipy/IronPython/Modules/unicodedata.cs diff --git a/src/IronPython/Modules/unicodedata/CaseFolding.txt b/src/ipy/IronPython/Modules/unicodedata/CaseFolding.txt similarity index 100% rename from src/IronPython/Modules/unicodedata/CaseFolding.txt rename to src/ipy/IronPython/Modules/unicodedata/CaseFolding.txt diff --git a/src/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt b/src/ipy/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt similarity index 100% rename from src/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt rename to src/ipy/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt diff --git a/src/IronPython/Modules/unicodedata/EastAsianWidth.txt b/src/ipy/IronPython/Modules/unicodedata/EastAsianWidth.txt similarity index 100% rename from src/IronPython/Modules/unicodedata/EastAsianWidth.txt rename to src/ipy/IronPython/Modules/unicodedata/EastAsianWidth.txt diff --git a/src/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz b/src/ipy/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz similarity index 100% rename from src/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz rename to src/ipy/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz diff --git a/src/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz b/src/ipy/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz similarity index 100% rename from src/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz rename to src/ipy/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz diff --git a/src/IronPython/Modules/unicodedata/NameAliases.txt b/src/ipy/IronPython/Modules/unicodedata/NameAliases.txt similarity index 100% rename from src/IronPython/Modules/unicodedata/NameAliases.txt rename to src/ipy/IronPython/Modules/unicodedata/NameAliases.txt diff --git a/src/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt b/src/ipy/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt similarity index 100% rename from src/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt rename to src/ipy/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt diff --git a/src/IronPython/Modules/unicodedata/UnicodeData.txt b/src/ipy/IronPython/Modules/unicodedata/UnicodeData.txt similarity index 100% rename from src/IronPython/Modules/unicodedata/UnicodeData.txt rename to src/ipy/IronPython/Modules/unicodedata/UnicodeData.txt diff --git a/src/IronPython/Modules/unicodedata/genunicodedata.py b/src/ipy/IronPython/Modules/unicodedata/genunicodedata.py similarity index 100% rename from src/IronPython/Modules/unicodedata/genunicodedata.py rename to src/ipy/IronPython/Modules/unicodedata/genunicodedata.py diff --git a/src/IronPython/Modules/unicodedata/license.txt b/src/ipy/IronPython/Modules/unicodedata/license.txt similarity index 100% rename from src/IronPython/Modules/unicodedata/license.txt rename to src/ipy/IronPython/Modules/unicodedata/license.txt diff --git a/src/IronPython/Properties/AssemblyInfo.cs b/src/ipy/IronPython/Properties/AssemblyInfo.cs similarity index 100% rename from src/IronPython/Properties/AssemblyInfo.cs rename to src/ipy/IronPython/Properties/AssemblyInfo.cs diff --git a/src/IronPython/Resources.Designer.cs b/src/ipy/IronPython/Resources.Designer.cs similarity index 100% rename from src/IronPython/Resources.Designer.cs rename to src/ipy/IronPython/Resources.Designer.cs diff --git a/src/IronPython/Resources.resx b/src/ipy/IronPython/Resources.resx similarity index 100% rename from src/IronPython/Resources.resx rename to src/ipy/IronPython/Resources.resx diff --git a/src/IronPython/Runtime/ArrayData.cs b/src/ipy/IronPython/Runtime/ArrayData.cs similarity index 100% rename from src/IronPython/Runtime/ArrayData.cs rename to src/ipy/IronPython/Runtime/ArrayData.cs diff --git a/src/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs b/src/ipy/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs rename to src/ipy/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs diff --git a/src/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs b/src/ipy/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs rename to src/ipy/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs diff --git a/src/IronPython/Runtime/Binding/Binders.cs b/src/ipy/IronPython/Runtime/Binding/Binders.cs similarity index 100% rename from src/IronPython/Runtime/Binding/Binders.cs rename to src/ipy/IronPython/Runtime/Binding/Binders.cs diff --git a/src/IronPython/Runtime/Binding/BindingHelpers.cs b/src/ipy/IronPython/Runtime/Binding/BindingHelpers.cs similarity index 100% rename from src/IronPython/Runtime/Binding/BindingHelpers.cs rename to src/ipy/IronPython/Runtime/Binding/BindingHelpers.cs diff --git a/src/IronPython/Runtime/Binding/BindingWarnings.cs b/src/ipy/IronPython/Runtime/Binding/BindingWarnings.cs similarity index 100% rename from src/IronPython/Runtime/Binding/BindingWarnings.cs rename to src/ipy/IronPython/Runtime/Binding/BindingWarnings.cs diff --git a/src/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs b/src/ipy/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs rename to src/ipy/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs diff --git a/src/IronPython/Runtime/Binding/ConditionalBuilder.cs b/src/ipy/IronPython/Runtime/Binding/ConditionalBuilder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/ConditionalBuilder.cs rename to src/ipy/IronPython/Runtime/Binding/ConditionalBuilder.cs diff --git a/src/IronPython/Runtime/Binding/ContextArgBuilder.cs b/src/ipy/IronPython/Runtime/Binding/ContextArgBuilder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/ContextArgBuilder.cs rename to src/ipy/IronPython/Runtime/Binding/ContextArgBuilder.cs diff --git a/src/IronPython/Runtime/Binding/ConversionBinder.cs b/src/ipy/IronPython/Runtime/Binding/ConversionBinder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/ConversionBinder.cs rename to src/ipy/IronPython/Runtime/Binding/ConversionBinder.cs diff --git a/src/IronPython/Runtime/Binding/CreateFallbackBinder.cs b/src/ipy/IronPython/Runtime/Binding/CreateFallbackBinder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/CreateFallbackBinder.cs rename to src/ipy/IronPython/Runtime/Binding/CreateFallbackBinder.cs diff --git a/src/IronPython/Runtime/Binding/FastBindResult.cs b/src/ipy/IronPython/Runtime/Binding/FastBindResult.cs similarity index 100% rename from src/IronPython/Runtime/Binding/FastBindResult.cs rename to src/ipy/IronPython/Runtime/Binding/FastBindResult.cs diff --git a/src/IronPython/Runtime/Binding/FastGetBase.cs b/src/ipy/IronPython/Runtime/Binding/FastGetBase.cs similarity index 100% rename from src/IronPython/Runtime/Binding/FastGetBase.cs rename to src/ipy/IronPython/Runtime/Binding/FastGetBase.cs diff --git a/src/IronPython/Runtime/Binding/FastSetBase.cs b/src/ipy/IronPython/Runtime/Binding/FastSetBase.cs similarity index 100% rename from src/IronPython/Runtime/Binding/FastSetBase.cs rename to src/ipy/IronPython/Runtime/Binding/FastSetBase.cs diff --git a/src/IronPython/Runtime/Binding/IComConvertible.cs b/src/ipy/IronPython/Runtime/Binding/IComConvertible.cs similarity index 100% rename from src/IronPython/Runtime/Binding/IComConvertible.cs rename to src/ipy/IronPython/Runtime/Binding/IComConvertible.cs diff --git a/src/IronPython/Runtime/Binding/IFastGettable.cs b/src/ipy/IronPython/Runtime/Binding/IFastGettable.cs similarity index 100% rename from src/IronPython/Runtime/Binding/IFastGettable.cs rename to src/ipy/IronPython/Runtime/Binding/IFastGettable.cs diff --git a/src/IronPython/Runtime/Binding/IFastInvokable.cs b/src/ipy/IronPython/Runtime/Binding/IFastInvokable.cs similarity index 100% rename from src/IronPython/Runtime/Binding/IFastInvokable.cs rename to src/ipy/IronPython/Runtime/Binding/IFastInvokable.cs diff --git a/src/IronPython/Runtime/Binding/IFastSettable.cs b/src/ipy/IronPython/Runtime/Binding/IFastSettable.cs similarity index 100% rename from src/IronPython/Runtime/Binding/IFastSettable.cs rename to src/ipy/IronPython/Runtime/Binding/IFastSettable.cs diff --git a/src/IronPython/Runtime/Binding/IPythonConvertible.cs b/src/ipy/IronPython/Runtime/Binding/IPythonConvertible.cs similarity index 100% rename from src/IronPython/Runtime/Binding/IPythonConvertible.cs rename to src/ipy/IronPython/Runtime/Binding/IPythonConvertible.cs diff --git a/src/IronPython/Runtime/Binding/IPythonExpandable.cs b/src/ipy/IronPython/Runtime/Binding/IPythonExpandable.cs similarity index 100% rename from src/IronPython/Runtime/Binding/IPythonExpandable.cs rename to src/ipy/IronPython/Runtime/Binding/IPythonExpandable.cs diff --git a/src/IronPython/Runtime/Binding/IPythonGetable.cs b/src/ipy/IronPython/Runtime/Binding/IPythonGetable.cs similarity index 100% rename from src/IronPython/Runtime/Binding/IPythonGetable.cs rename to src/ipy/IronPython/Runtime/Binding/IPythonGetable.cs diff --git a/src/IronPython/Runtime/Binding/IPythonInvokable.cs b/src/ipy/IronPython/Runtime/Binding/IPythonInvokable.cs similarity index 100% rename from src/IronPython/Runtime/Binding/IPythonInvokable.cs rename to src/ipy/IronPython/Runtime/Binding/IPythonInvokable.cs diff --git a/src/IronPython/Runtime/Binding/IPythonOperable.cs b/src/ipy/IronPython/Runtime/Binding/IPythonOperable.cs similarity index 100% rename from src/IronPython/Runtime/Binding/IPythonOperable.cs rename to src/ipy/IronPython/Runtime/Binding/IPythonOperable.cs diff --git a/src/IronPython/Runtime/Binding/IPythonSite.cs b/src/ipy/IronPython/Runtime/Binding/IPythonSite.cs similarity index 100% rename from src/IronPython/Runtime/Binding/IPythonSite.cs rename to src/ipy/IronPython/Runtime/Binding/IPythonSite.cs diff --git a/src/IronPython/Runtime/Binding/MetaBuiltinFunction.cs b/src/ipy/IronPython/Runtime/Binding/MetaBuiltinFunction.cs similarity index 100% rename from src/IronPython/Runtime/Binding/MetaBuiltinFunction.cs rename to src/ipy/IronPython/Runtime/Binding/MetaBuiltinFunction.cs diff --git a/src/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs b/src/ipy/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs similarity index 100% rename from src/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs rename to src/ipy/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs diff --git a/src/IronPython/Runtime/Binding/MetaMethod.cs b/src/ipy/IronPython/Runtime/Binding/MetaMethod.cs similarity index 100% rename from src/IronPython/Runtime/Binding/MetaMethod.cs rename to src/ipy/IronPython/Runtime/Binding/MetaMethod.cs diff --git a/src/IronPython/Runtime/Binding/MetaPythonFunction.cs b/src/ipy/IronPython/Runtime/Binding/MetaPythonFunction.cs similarity index 100% rename from src/IronPython/Runtime/Binding/MetaPythonFunction.cs rename to src/ipy/IronPython/Runtime/Binding/MetaPythonFunction.cs diff --git a/src/IronPython/Runtime/Binding/MetaPythonObject.cs b/src/ipy/IronPython/Runtime/Binding/MetaPythonObject.cs similarity index 100% rename from src/IronPython/Runtime/Binding/MetaPythonObject.cs rename to src/ipy/IronPython/Runtime/Binding/MetaPythonObject.cs diff --git a/src/IronPython/Runtime/Binding/MetaPythonType.Calls.cs b/src/ipy/IronPython/Runtime/Binding/MetaPythonType.Calls.cs similarity index 100% rename from src/IronPython/Runtime/Binding/MetaPythonType.Calls.cs rename to src/ipy/IronPython/Runtime/Binding/MetaPythonType.Calls.cs diff --git a/src/IronPython/Runtime/Binding/MetaPythonType.Members.cs b/src/ipy/IronPython/Runtime/Binding/MetaPythonType.Members.cs similarity index 100% rename from src/IronPython/Runtime/Binding/MetaPythonType.Members.cs rename to src/ipy/IronPython/Runtime/Binding/MetaPythonType.Members.cs diff --git a/src/IronPython/Runtime/Binding/MetaPythonType.cs b/src/ipy/IronPython/Runtime/Binding/MetaPythonType.cs similarity index 100% rename from src/IronPython/Runtime/Binding/MetaPythonType.cs rename to src/ipy/IronPython/Runtime/Binding/MetaPythonType.cs diff --git a/src/IronPython/Runtime/Binding/MetaUserObject.Members.cs b/src/ipy/IronPython/Runtime/Binding/MetaUserObject.Members.cs similarity index 100% rename from src/IronPython/Runtime/Binding/MetaUserObject.Members.cs rename to src/ipy/IronPython/Runtime/Binding/MetaUserObject.Members.cs diff --git a/src/IronPython/Runtime/Binding/MetaUserObject.cs b/src/ipy/IronPython/Runtime/Binding/MetaUserObject.cs similarity index 100% rename from src/IronPython/Runtime/Binding/MetaUserObject.cs rename to src/ipy/IronPython/Runtime/Binding/MetaUserObject.cs diff --git a/src/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs rename to src/ipy/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs diff --git a/src/IronPython/Runtime/Binding/PythonBinder.Create.cs b/src/ipy/IronPython/Runtime/Binding/PythonBinder.Create.cs similarity index 100% rename from src/IronPython/Runtime/Binding/PythonBinder.Create.cs rename to src/ipy/IronPython/Runtime/Binding/PythonBinder.Create.cs diff --git a/src/IronPython/Runtime/Binding/PythonBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonBinder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/PythonBinder.cs rename to src/ipy/IronPython/Runtime/Binding/PythonBinder.cs diff --git a/src/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs rename to src/ipy/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs diff --git a/src/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs rename to src/ipy/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs diff --git a/src/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs rename to src/ipy/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs diff --git a/src/IronPython/Runtime/Binding/PythonExtensionBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonExtensionBinder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/PythonExtensionBinder.cs rename to src/ipy/IronPython/Runtime/Binding/PythonExtensionBinder.cs diff --git a/src/IronPython/Runtime/Binding/PythonGetIndexBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonGetIndexBinder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/PythonGetIndexBinder.cs rename to src/ipy/IronPython/Runtime/Binding/PythonGetIndexBinder.cs diff --git a/src/IronPython/Runtime/Binding/PythonGetMemberBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonGetMemberBinder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/PythonGetMemberBinder.cs rename to src/ipy/IronPython/Runtime/Binding/PythonGetMemberBinder.cs diff --git a/src/IronPython/Runtime/Binding/PythonGetSliceBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonGetSliceBinder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/PythonGetSliceBinder.cs rename to src/ipy/IronPython/Runtime/Binding/PythonGetSliceBinder.cs diff --git a/src/IronPython/Runtime/Binding/PythonIndexType.cs b/src/ipy/IronPython/Runtime/Binding/PythonIndexType.cs similarity index 100% rename from src/IronPython/Runtime/Binding/PythonIndexType.cs rename to src/ipy/IronPython/Runtime/Binding/PythonIndexType.cs diff --git a/src/IronPython/Runtime/Binding/PythonInvokeBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonInvokeBinder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/PythonInvokeBinder.cs rename to src/ipy/IronPython/Runtime/Binding/PythonInvokeBinder.cs diff --git a/src/IronPython/Runtime/Binding/PythonOperationBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonOperationBinder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/PythonOperationBinder.cs rename to src/ipy/IronPython/Runtime/Binding/PythonOperationBinder.cs diff --git a/src/IronPython/Runtime/Binding/PythonOperationKind.cs b/src/ipy/IronPython/Runtime/Binding/PythonOperationKind.cs similarity index 100% rename from src/IronPython/Runtime/Binding/PythonOperationKind.cs rename to src/ipy/IronPython/Runtime/Binding/PythonOperationKind.cs diff --git a/src/IronPython/Runtime/Binding/PythonOverloadResolver.cs b/src/ipy/IronPython/Runtime/Binding/PythonOverloadResolver.cs similarity index 100% rename from src/IronPython/Runtime/Binding/PythonOverloadResolver.cs rename to src/ipy/IronPython/Runtime/Binding/PythonOverloadResolver.cs diff --git a/src/IronPython/Runtime/Binding/PythonProtocol.Operations.cs b/src/ipy/IronPython/Runtime/Binding/PythonProtocol.Operations.cs similarity index 100% rename from src/IronPython/Runtime/Binding/PythonProtocol.Operations.cs rename to src/ipy/IronPython/Runtime/Binding/PythonProtocol.Operations.cs diff --git a/src/IronPython/Runtime/Binding/PythonProtocol.cs b/src/ipy/IronPython/Runtime/Binding/PythonProtocol.cs similarity index 100% rename from src/IronPython/Runtime/Binding/PythonProtocol.cs rename to src/ipy/IronPython/Runtime/Binding/PythonProtocol.cs diff --git a/src/IronPython/Runtime/Binding/PythonSetIndexBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonSetIndexBinder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/PythonSetIndexBinder.cs rename to src/ipy/IronPython/Runtime/Binding/PythonSetIndexBinder.cs diff --git a/src/IronPython/Runtime/Binding/PythonSetMemberBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonSetMemberBinder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/PythonSetMemberBinder.cs rename to src/ipy/IronPython/Runtime/Binding/PythonSetMemberBinder.cs diff --git a/src/IronPython/Runtime/Binding/PythonSetSliceBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonSetSliceBinder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/PythonSetSliceBinder.cs rename to src/ipy/IronPython/Runtime/Binding/PythonSetSliceBinder.cs diff --git a/src/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs rename to src/ipy/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs diff --git a/src/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs b/src/ipy/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs similarity index 100% rename from src/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs rename to src/ipy/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs diff --git a/src/IronPython/Runtime/Binding/SlotOrFunction.cs b/src/ipy/IronPython/Runtime/Binding/SlotOrFunction.cs similarity index 100% rename from src/IronPython/Runtime/Binding/SlotOrFunction.cs rename to src/ipy/IronPython/Runtime/Binding/SlotOrFunction.cs diff --git a/src/IronPython/Runtime/Binding/WarningInfo.cs b/src/ipy/IronPython/Runtime/Binding/WarningInfo.cs similarity index 100% rename from src/IronPython/Runtime/Binding/WarningInfo.cs rename to src/ipy/IronPython/Runtime/Binding/WarningInfo.cs diff --git a/src/IronPython/Runtime/BufferProtocol.cs b/src/ipy/IronPython/Runtime/BufferProtocol.cs similarity index 100% rename from src/IronPython/Runtime/BufferProtocol.cs rename to src/ipy/IronPython/Runtime/BufferProtocol.cs diff --git a/src/IronPython/Runtime/BuiltinPythonModule.cs b/src/ipy/IronPython/Runtime/BuiltinPythonModule.cs similarity index 100% rename from src/IronPython/Runtime/BuiltinPythonModule.cs rename to src/ipy/IronPython/Runtime/BuiltinPythonModule.cs diff --git a/src/IronPython/Runtime/BuiltinsDictionaryStorage.cs b/src/ipy/IronPython/Runtime/BuiltinsDictionaryStorage.cs similarity index 100% rename from src/IronPython/Runtime/BuiltinsDictionaryStorage.cs rename to src/ipy/IronPython/Runtime/BuiltinsDictionaryStorage.cs diff --git a/src/IronPython/Runtime/ByteArray.cs b/src/ipy/IronPython/Runtime/ByteArray.cs similarity index 100% rename from src/IronPython/Runtime/ByteArray.cs rename to src/ipy/IronPython/Runtime/ByteArray.cs diff --git a/src/IronPython/Runtime/ByteArrayIterator.cs b/src/ipy/IronPython/Runtime/ByteArrayIterator.cs similarity index 100% rename from src/IronPython/Runtime/ByteArrayIterator.cs rename to src/ipy/IronPython/Runtime/ByteArrayIterator.cs diff --git a/src/IronPython/Runtime/Bytes.cs b/src/ipy/IronPython/Runtime/Bytes.cs similarity index 100% rename from src/IronPython/Runtime/Bytes.cs rename to src/ipy/IronPython/Runtime/Bytes.cs diff --git a/src/IronPython/Runtime/BytesIterator.cs b/src/ipy/IronPython/Runtime/BytesIterator.cs similarity index 100% rename from src/IronPython/Runtime/BytesIterator.cs rename to src/ipy/IronPython/Runtime/BytesIterator.cs diff --git a/src/IronPython/Runtime/BytesLikeAttribute.cs b/src/ipy/IronPython/Runtime/BytesLikeAttribute.cs similarity index 100% rename from src/IronPython/Runtime/BytesLikeAttribute.cs rename to src/ipy/IronPython/Runtime/BytesLikeAttribute.cs diff --git a/src/IronPython/Runtime/ClassMethodAttribute.cs b/src/ipy/IronPython/Runtime/ClassMethodAttribute.cs similarity index 100% rename from src/IronPython/Runtime/ClassMethodAttribute.cs rename to src/ipy/IronPython/Runtime/ClassMethodAttribute.cs diff --git a/src/IronPython/Runtime/ClassMethodDescriptor.cs b/src/ipy/IronPython/Runtime/ClassMethodDescriptor.cs similarity index 100% rename from src/IronPython/Runtime/ClassMethodDescriptor.cs rename to src/ipy/IronPython/Runtime/ClassMethodDescriptor.cs diff --git a/src/IronPython/Runtime/ClrModule.cs b/src/ipy/IronPython/Runtime/ClrModule.cs similarity index 100% rename from src/IronPython/Runtime/ClrModule.cs rename to src/ipy/IronPython/Runtime/ClrModule.cs diff --git a/src/IronPython/Runtime/CodeContext.cs b/src/ipy/IronPython/Runtime/CodeContext.cs similarity index 100% rename from src/IronPython/Runtime/CodeContext.cs rename to src/ipy/IronPython/Runtime/CodeContext.cs diff --git a/src/IronPython/Runtime/CollectionDebugView.cs b/src/ipy/IronPython/Runtime/CollectionDebugView.cs similarity index 100% rename from src/IronPython/Runtime/CollectionDebugView.cs rename to src/ipy/IronPython/Runtime/CollectionDebugView.cs diff --git a/src/IronPython/Runtime/CommonDictionaryStorage.cs b/src/ipy/IronPython/Runtime/CommonDictionaryStorage.cs similarity index 100% rename from src/IronPython/Runtime/CommonDictionaryStorage.cs rename to src/ipy/IronPython/Runtime/CommonDictionaryStorage.cs diff --git a/src/IronPython/Runtime/CompareUtil.cs b/src/ipy/IronPython/Runtime/CompareUtil.cs similarity index 100% rename from src/IronPython/Runtime/CompareUtil.cs rename to src/ipy/IronPython/Runtime/CompareUtil.cs diff --git a/src/IronPython/Runtime/CompileFlags.cs b/src/ipy/IronPython/Runtime/CompileFlags.cs similarity index 100% rename from src/IronPython/Runtime/CompileFlags.cs rename to src/ipy/IronPython/Runtime/CompileFlags.cs diff --git a/src/IronPython/Runtime/CompiledLoader.cs b/src/ipy/IronPython/Runtime/CompiledLoader.cs similarity index 100% rename from src/IronPython/Runtime/CompiledLoader.cs rename to src/ipy/IronPython/Runtime/CompiledLoader.cs diff --git a/src/IronPython/Runtime/ConstantDictionaryStorage.cs b/src/ipy/IronPython/Runtime/ConstantDictionaryStorage.cs similarity index 100% rename from src/IronPython/Runtime/ConstantDictionaryStorage.cs rename to src/ipy/IronPython/Runtime/ConstantDictionaryStorage.cs diff --git a/src/IronPython/Runtime/ConversionWrappers.cs b/src/ipy/IronPython/Runtime/ConversionWrappers.cs similarity index 100% rename from src/IronPython/Runtime/ConversionWrappers.cs rename to src/ipy/IronPython/Runtime/ConversionWrappers.cs diff --git a/src/IronPython/Runtime/Converter.cs b/src/ipy/IronPython/Runtime/Converter.cs similarity index 100% rename from src/IronPython/Runtime/Converter.cs rename to src/ipy/IronPython/Runtime/Converter.cs diff --git a/src/IronPython/Runtime/CustomDictionaryStorage.cs b/src/ipy/IronPython/Runtime/CustomDictionaryStorage.cs similarity index 100% rename from src/IronPython/Runtime/CustomDictionaryStorage.cs rename to src/ipy/IronPython/Runtime/CustomDictionaryStorage.cs diff --git a/src/IronPython/Runtime/DebuggerDictionaryStorage.cs b/src/ipy/IronPython/Runtime/DebuggerDictionaryStorage.cs similarity index 100% rename from src/IronPython/Runtime/DebuggerDictionaryStorage.cs rename to src/ipy/IronPython/Runtime/DebuggerDictionaryStorage.cs diff --git a/src/IronPython/Runtime/DefaultContext.cs b/src/ipy/IronPython/Runtime/DefaultContext.cs similarity index 100% rename from src/IronPython/Runtime/DefaultContext.cs rename to src/ipy/IronPython/Runtime/DefaultContext.cs diff --git a/src/IronPython/Runtime/Descriptors.cs b/src/ipy/IronPython/Runtime/Descriptors.cs similarity index 100% rename from src/IronPython/Runtime/Descriptors.cs rename to src/ipy/IronPython/Runtime/Descriptors.cs diff --git a/src/IronPython/Runtime/DictionaryOps.cs b/src/ipy/IronPython/Runtime/DictionaryOps.cs similarity index 100% rename from src/IronPython/Runtime/DictionaryOps.cs rename to src/ipy/IronPython/Runtime/DictionaryOps.cs diff --git a/src/IronPython/Runtime/DictionaryStorage.cs b/src/ipy/IronPython/Runtime/DictionaryStorage.cs similarity index 100% rename from src/IronPython/Runtime/DictionaryStorage.cs rename to src/ipy/IronPython/Runtime/DictionaryStorage.cs diff --git a/src/IronPython/Runtime/DictionaryTypeInfoAttribute.cs b/src/ipy/IronPython/Runtime/DictionaryTypeInfoAttribute.cs similarity index 100% rename from src/IronPython/Runtime/DictionaryTypeInfoAttribute.cs rename to src/ipy/IronPython/Runtime/DictionaryTypeInfoAttribute.cs diff --git a/src/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs b/src/ipy/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs similarity index 100% rename from src/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs rename to src/ipy/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs diff --git a/src/IronPython/Runtime/DontMapICollectionToLenAttribute.cs b/src/ipy/IronPython/Runtime/DontMapICollectionToLenAttribute.cs similarity index 100% rename from src/IronPython/Runtime/DontMapICollectionToLenAttribute.cs rename to src/ipy/IronPython/Runtime/DontMapICollectionToLenAttribute.cs diff --git a/src/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs b/src/ipy/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs similarity index 100% rename from src/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs rename to src/ipy/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs diff --git a/src/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs b/src/ipy/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs similarity index 100% rename from src/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs rename to src/ipy/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs diff --git a/src/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs b/src/ipy/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs similarity index 100% rename from src/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs rename to src/ipy/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs diff --git a/src/IronPython/Runtime/EmptyDictionaryStorage.cs b/src/ipy/IronPython/Runtime/EmptyDictionaryStorage.cs similarity index 100% rename from src/IronPython/Runtime/EmptyDictionaryStorage.cs rename to src/ipy/IronPython/Runtime/EmptyDictionaryStorage.cs diff --git a/src/IronPython/Runtime/Enumerate.cs b/src/ipy/IronPython/Runtime/Enumerate.cs similarity index 100% rename from src/IronPython/Runtime/Enumerate.cs rename to src/ipy/IronPython/Runtime/Enumerate.cs diff --git a/src/IronPython/Runtime/ErrorCodes.cs b/src/ipy/IronPython/Runtime/ErrorCodes.cs similarity index 100% rename from src/IronPython/Runtime/ErrorCodes.cs rename to src/ipy/IronPython/Runtime/ErrorCodes.cs diff --git a/src/IronPython/Runtime/Exceptions/AssertionException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/AssertionException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/AssertionException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/AssertionException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/AttributeErrorException.cs b/src/ipy/IronPython/Runtime/Exceptions/AttributeErrorException.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/AttributeErrorException.cs rename to src/ipy/IronPython/Runtime/Exceptions/AttributeErrorException.cs diff --git a/src/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/BufferException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/BufferException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/BufferException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/BufferException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/GeneratorExitException.cs b/src/ipy/IronPython/Runtime/Exceptions/GeneratorExitException.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/GeneratorExitException.cs rename to src/ipy/IronPython/Runtime/Exceptions/GeneratorExitException.cs diff --git a/src/IronPython/Runtime/Exceptions/ImportException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/ImportException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/ImportException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/ImportException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/IndentationException.cs b/src/ipy/IronPython/Runtime/Exceptions/IndentationException.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/IndentationException.cs rename to src/ipy/IronPython/Runtime/Exceptions/IndentationException.cs diff --git a/src/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/LookupException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/LookupException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/LookupException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/LookupException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs b/src/ipy/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs rename to src/ipy/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs diff --git a/src/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/OSException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/OSException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/OSException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/OSException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/PythonException.cs b/src/ipy/IronPython/Runtime/Exceptions/PythonException.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/PythonException.cs rename to src/ipy/IronPython/Runtime/Exceptions/PythonException.cs diff --git a/src/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs b/src/ipy/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs rename to src/ipy/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs diff --git a/src/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/PythonExceptions.cs b/src/ipy/IronPython/Runtime/Exceptions/PythonExceptions.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/PythonExceptions.cs rename to src/ipy/IronPython/Runtime/Exceptions/PythonExceptions.cs diff --git a/src/IronPython/Runtime/Exceptions/RecursionException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/RecursionException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/RecursionException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/RecursionException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/SystemExitException.cs b/src/ipy/IronPython/Runtime/Exceptions/SystemExitException.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/SystemExitException.cs rename to src/ipy/IronPython/Runtime/Exceptions/SystemExitException.cs diff --git a/src/IronPython/Runtime/Exceptions/TabException.cs b/src/ipy/IronPython/Runtime/Exceptions/TabException.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/TabException.cs rename to src/ipy/IronPython/Runtime/Exceptions/TabException.cs diff --git a/src/IronPython/Runtime/Exceptions/TraceBack.cs b/src/ipy/IronPython/Runtime/Exceptions/TraceBack.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/TraceBack.cs rename to src/ipy/IronPython/Runtime/Exceptions/TraceBack.cs diff --git a/src/IronPython/Runtime/Exceptions/TypeErrorException.cs b/src/ipy/IronPython/Runtime/Exceptions/TypeErrorException.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/TypeErrorException.cs rename to src/ipy/IronPython/Runtime/Exceptions/TypeErrorException.cs diff --git a/src/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs b/src/ipy/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs rename to src/ipy/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs diff --git a/src/IronPython/Runtime/Exceptions/ValueErrorException.cs b/src/ipy/IronPython/Runtime/Exceptions/ValueErrorException.cs similarity index 100% rename from src/IronPython/Runtime/Exceptions/ValueErrorException.cs rename to src/ipy/IronPython/Runtime/Exceptions/ValueErrorException.cs diff --git a/src/IronPython/Runtime/ExtensionMethodSet.cs b/src/ipy/IronPython/Runtime/ExtensionMethodSet.cs similarity index 100% rename from src/IronPython/Runtime/ExtensionMethodSet.cs rename to src/ipy/IronPython/Runtime/ExtensionMethodSet.cs diff --git a/src/IronPython/Runtime/Filter.cs b/src/ipy/IronPython/Runtime/Filter.cs similarity index 100% rename from src/IronPython/Runtime/Filter.cs rename to src/ipy/IronPython/Runtime/Filter.cs diff --git a/src/IronPython/Runtime/FormattingHelper.cs b/src/ipy/IronPython/Runtime/FormattingHelper.cs similarity index 100% rename from src/IronPython/Runtime/FormattingHelper.cs rename to src/ipy/IronPython/Runtime/FormattingHelper.cs diff --git a/src/IronPython/Runtime/FunctionAttributes.cs b/src/ipy/IronPython/Runtime/FunctionAttributes.cs similarity index 100% rename from src/IronPython/Runtime/FunctionAttributes.cs rename to src/ipy/IronPython/Runtime/FunctionAttributes.cs diff --git a/src/IronPython/Runtime/FunctionCode.cs b/src/ipy/IronPython/Runtime/FunctionCode.cs similarity index 100% rename from src/IronPython/Runtime/FunctionCode.cs rename to src/ipy/IronPython/Runtime/FunctionCode.cs diff --git a/src/IronPython/Runtime/Generator.cs b/src/ipy/IronPython/Runtime/Generator.cs similarity index 100% rename from src/IronPython/Runtime/Generator.cs rename to src/ipy/IronPython/Runtime/Generator.cs diff --git a/src/IronPython/Runtime/GlobalDictionaryStorage.cs b/src/ipy/IronPython/Runtime/GlobalDictionaryStorage.cs similarity index 100% rename from src/IronPython/Runtime/GlobalDictionaryStorage.cs rename to src/ipy/IronPython/Runtime/GlobalDictionaryStorage.cs diff --git a/src/IronPython/Runtime/IParameterSequence.cs b/src/ipy/IronPython/Runtime/IParameterSequence.cs similarity index 100% rename from src/IronPython/Runtime/IParameterSequence.cs rename to src/ipy/IronPython/Runtime/IParameterSequence.cs diff --git a/src/IronPython/Runtime/Implementation.cs b/src/ipy/IronPython/Runtime/Implementation.cs similarity index 100% rename from src/IronPython/Runtime/Implementation.cs rename to src/ipy/IronPython/Runtime/Implementation.cs diff --git a/src/IronPython/Runtime/Importer.cs b/src/ipy/IronPython/Runtime/Importer.cs similarity index 100% rename from src/IronPython/Runtime/Importer.cs rename to src/ipy/IronPython/Runtime/Importer.cs diff --git a/src/IronPython/Runtime/Index.cs b/src/ipy/IronPython/Runtime/Index.cs similarity index 100% rename from src/IronPython/Runtime/Index.cs rename to src/ipy/IronPython/Runtime/Index.cs diff --git a/src/IronPython/Runtime/InstancedModuleDictionaryStorage.cs b/src/ipy/IronPython/Runtime/InstancedModuleDictionaryStorage.cs similarity index 100% rename from src/IronPython/Runtime/InstancedModuleDictionaryStorage.cs rename to src/ipy/IronPython/Runtime/InstancedModuleDictionaryStorage.cs diff --git a/src/IronPython/Runtime/Interfaces.cs b/src/ipy/IronPython/Runtime/Interfaces.cs similarity index 100% rename from src/IronPython/Runtime/Interfaces.cs rename to src/ipy/IronPython/Runtime/Interfaces.cs diff --git a/src/IronPython/Runtime/KwCallInfo.cs b/src/ipy/IronPython/Runtime/KwCallInfo.cs similarity index 100% rename from src/IronPython/Runtime/KwCallInfo.cs rename to src/ipy/IronPython/Runtime/KwCallInfo.cs diff --git a/src/IronPython/Runtime/LiteralParser.cs b/src/ipy/IronPython/Runtime/LiteralParser.cs similarity index 100% rename from src/IronPython/Runtime/LiteralParser.cs rename to src/ipy/IronPython/Runtime/LiteralParser.cs diff --git a/src/IronPython/Runtime/Map.cs b/src/ipy/IronPython/Runtime/Map.cs similarity index 100% rename from src/IronPython/Runtime/Map.cs rename to src/ipy/IronPython/Runtime/Map.cs diff --git a/src/IronPython/Runtime/MaybeNotImplementedAttribute.cs b/src/ipy/IronPython/Runtime/MaybeNotImplementedAttribute.cs similarity index 100% rename from src/IronPython/Runtime/MaybeNotImplementedAttribute.cs rename to src/ipy/IronPython/Runtime/MaybeNotImplementedAttribute.cs diff --git a/src/IronPython/Runtime/MemoryStreamContentProvider.cs b/src/ipy/IronPython/Runtime/MemoryStreamContentProvider.cs similarity index 100% rename from src/IronPython/Runtime/MemoryStreamContentProvider.cs rename to src/ipy/IronPython/Runtime/MemoryStreamContentProvider.cs diff --git a/src/IronPython/Runtime/MemoryView.cs b/src/ipy/IronPython/Runtime/MemoryView.cs similarity index 100% rename from src/IronPython/Runtime/MemoryView.cs rename to src/ipy/IronPython/Runtime/MemoryView.cs diff --git a/src/IronPython/Runtime/Method.Generated.cs b/src/ipy/IronPython/Runtime/Method.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Method.Generated.cs rename to src/ipy/IronPython/Runtime/Method.Generated.cs diff --git a/src/IronPython/Runtime/Method.cs b/src/ipy/IronPython/Runtime/Method.cs similarity index 100% rename from src/IronPython/Runtime/Method.cs rename to src/ipy/IronPython/Runtime/Method.cs diff --git a/src/IronPython/Runtime/MissingParameter.cs b/src/ipy/IronPython/Runtime/MissingParameter.cs similarity index 100% rename from src/IronPython/Runtime/MissingParameter.cs rename to src/ipy/IronPython/Runtime/MissingParameter.cs diff --git a/src/IronPython/Runtime/ModuleContext.cs b/src/ipy/IronPython/Runtime/ModuleContext.cs similarity index 100% rename from src/IronPython/Runtime/ModuleContext.cs rename to src/ipy/IronPython/Runtime/ModuleContext.cs diff --git a/src/IronPython/Runtime/ModuleDictionaryStorage.cs b/src/ipy/IronPython/Runtime/ModuleDictionaryStorage.cs similarity index 100% rename from src/IronPython/Runtime/ModuleDictionaryStorage.cs rename to src/ipy/IronPython/Runtime/ModuleDictionaryStorage.cs diff --git a/src/IronPython/Runtime/ModuleGlobalCache.cs b/src/ipy/IronPython/Runtime/ModuleGlobalCache.cs similarity index 100% rename from src/IronPython/Runtime/ModuleGlobalCache.cs rename to src/ipy/IronPython/Runtime/ModuleGlobalCache.cs diff --git a/src/IronPython/Runtime/ModuleLoader.cs b/src/ipy/IronPython/Runtime/ModuleLoader.cs similarity index 100% rename from src/IronPython/Runtime/ModuleLoader.cs rename to src/ipy/IronPython/Runtime/ModuleLoader.cs diff --git a/src/IronPython/Runtime/ModuleOptions.cs b/src/ipy/IronPython/Runtime/ModuleOptions.cs similarity index 100% rename from src/IronPython/Runtime/ModuleOptions.cs rename to src/ipy/IronPython/Runtime/ModuleOptions.cs diff --git a/src/IronPython/Runtime/NameType.cs b/src/ipy/IronPython/Runtime/NameType.cs similarity index 100% rename from src/IronPython/Runtime/NameType.cs rename to src/ipy/IronPython/Runtime/NameType.cs diff --git a/src/IronPython/Runtime/NewStringFormatter.cs b/src/ipy/IronPython/Runtime/NewStringFormatter.cs similarity index 100% rename from src/IronPython/Runtime/NewStringFormatter.cs rename to src/ipy/IronPython/Runtime/NewStringFormatter.cs diff --git a/src/IronPython/Runtime/ObjectAttributesAdapter.cs b/src/ipy/IronPython/Runtime/ObjectAttributesAdapter.cs similarity index 100% rename from src/IronPython/Runtime/ObjectAttributesAdapter.cs rename to src/ipy/IronPython/Runtime/ObjectAttributesAdapter.cs diff --git a/src/IronPython/Runtime/ObjectDebugView.cs b/src/ipy/IronPython/Runtime/ObjectDebugView.cs similarity index 100% rename from src/IronPython/Runtime/ObjectDebugView.cs rename to src/ipy/IronPython/Runtime/ObjectDebugView.cs diff --git a/src/IronPython/Runtime/Operations/ArrayOps.cs b/src/ipy/IronPython/Runtime/Operations/ArrayOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/ArrayOps.cs rename to src/ipy/IronPython/Runtime/Operations/ArrayOps.cs diff --git a/src/IronPython/Runtime/Operations/BigIntegerOps.cs b/src/ipy/IronPython/Runtime/Operations/BigIntegerOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/BigIntegerOps.cs rename to src/ipy/IronPython/Runtime/Operations/BigIntegerOps.cs diff --git a/src/IronPython/Runtime/Operations/BoolOps.cs b/src/ipy/IronPython/Runtime/Operations/BoolOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/BoolOps.cs rename to src/ipy/IronPython/Runtime/Operations/BoolOps.cs diff --git a/src/IronPython/Runtime/Operations/ByteOps.cs b/src/ipy/IronPython/Runtime/Operations/ByteOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/ByteOps.cs rename to src/ipy/IronPython/Runtime/Operations/ByteOps.cs diff --git a/src/IronPython/Runtime/Operations/CharOps.cs b/src/ipy/IronPython/Runtime/Operations/CharOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/CharOps.cs rename to src/ipy/IronPython/Runtime/Operations/CharOps.cs diff --git a/src/IronPython/Runtime/Operations/ComOps.cs b/src/ipy/IronPython/Runtime/Operations/ComOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/ComOps.cs rename to src/ipy/IronPython/Runtime/Operations/ComOps.cs diff --git a/src/IronPython/Runtime/Operations/ComplexOps.cs b/src/ipy/IronPython/Runtime/Operations/ComplexOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/ComplexOps.cs rename to src/ipy/IronPython/Runtime/Operations/ComplexOps.cs diff --git a/src/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs b/src/ipy/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs similarity index 100% rename from src/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs rename to src/ipy/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs diff --git a/src/IronPython/Runtime/Operations/DBNullOps.cs b/src/ipy/IronPython/Runtime/Operations/DBNullOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/DBNullOps.cs rename to src/ipy/IronPython/Runtime/Operations/DBNullOps.cs diff --git a/src/IronPython/Runtime/Operations/DateTimeOps.cs b/src/ipy/IronPython/Runtime/Operations/DateTimeOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/DateTimeOps.cs rename to src/ipy/IronPython/Runtime/Operations/DateTimeOps.cs diff --git a/src/IronPython/Runtime/Operations/DecimalOps.cs b/src/ipy/IronPython/Runtime/Operations/DecimalOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/DecimalOps.cs rename to src/ipy/IronPython/Runtime/Operations/DecimalOps.cs diff --git a/src/IronPython/Runtime/Operations/DelegateOps.cs b/src/ipy/IronPython/Runtime/Operations/DelegateOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/DelegateOps.cs rename to src/ipy/IronPython/Runtime/Operations/DelegateOps.cs diff --git a/src/IronPython/Runtime/Operations/DictionaryOfTOps.cs b/src/ipy/IronPython/Runtime/Operations/DictionaryOfTOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/DictionaryOfTOps.cs rename to src/ipy/IronPython/Runtime/Operations/DictionaryOfTOps.cs diff --git a/src/IronPython/Runtime/Operations/EnumOps.cs b/src/ipy/IronPython/Runtime/Operations/EnumOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/EnumOps.cs rename to src/ipy/IronPython/Runtime/Operations/EnumOps.cs diff --git a/src/IronPython/Runtime/Operations/FloatOps.Generated.cs b/src/ipy/IronPython/Runtime/Operations/FloatOps.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Operations/FloatOps.Generated.cs rename to src/ipy/IronPython/Runtime/Operations/FloatOps.Generated.cs diff --git a/src/IronPython/Runtime/Operations/FloatOps.cs b/src/ipy/IronPython/Runtime/Operations/FloatOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/FloatOps.cs rename to src/ipy/IronPython/Runtime/Operations/FloatOps.cs diff --git a/src/IronPython/Runtime/Operations/IListOfByteOps.cs b/src/ipy/IronPython/Runtime/Operations/IListOfByteOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/IListOfByteOps.cs rename to src/ipy/IronPython/Runtime/Operations/IListOfByteOps.cs diff --git a/src/IronPython/Runtime/Operations/InstanceOps.cs b/src/ipy/IronPython/Runtime/Operations/InstanceOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/InstanceOps.cs rename to src/ipy/IronPython/Runtime/Operations/InstanceOps.cs diff --git a/src/IronPython/Runtime/Operations/IntOps.Generated.cs b/src/ipy/IronPython/Runtime/Operations/IntOps.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Operations/IntOps.Generated.cs rename to src/ipy/IronPython/Runtime/Operations/IntOps.Generated.cs diff --git a/src/IronPython/Runtime/Operations/IntOps.cs b/src/ipy/IronPython/Runtime/Operations/IntOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/IntOps.cs rename to src/ipy/IronPython/Runtime/Operations/IntOps.cs diff --git a/src/IronPython/Runtime/Operations/IntPtrOps.cs b/src/ipy/IronPython/Runtime/Operations/IntPtrOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/IntPtrOps.cs rename to src/ipy/IronPython/Runtime/Operations/IntPtrOps.cs diff --git a/src/IronPython/Runtime/Operations/ListOfTOps.cs b/src/ipy/IronPython/Runtime/Operations/ListOfTOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/ListOfTOps.cs rename to src/ipy/IronPython/Runtime/Operations/ListOfTOps.cs diff --git a/src/IronPython/Runtime/Operations/MarshalOps.cs b/src/ipy/IronPython/Runtime/Operations/MarshalOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/MarshalOps.cs rename to src/ipy/IronPython/Runtime/Operations/MarshalOps.cs diff --git a/src/IronPython/Runtime/Operations/NamespaceTrackerOps.cs b/src/ipy/IronPython/Runtime/Operations/NamespaceTrackerOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/NamespaceTrackerOps.cs rename to src/ipy/IronPython/Runtime/Operations/NamespaceTrackerOps.cs diff --git a/src/IronPython/Runtime/Operations/ObjectOps.cs b/src/ipy/IronPython/Runtime/Operations/ObjectOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/ObjectOps.cs rename to src/ipy/IronPython/Runtime/Operations/ObjectOps.cs diff --git a/src/IronPython/Runtime/Operations/PythonCalls.cs b/src/ipy/IronPython/Runtime/Operations/PythonCalls.cs similarity index 100% rename from src/IronPython/Runtime/Operations/PythonCalls.cs rename to src/ipy/IronPython/Runtime/Operations/PythonCalls.cs diff --git a/src/IronPython/Runtime/Operations/PythonOps.Generated.cs b/src/ipy/IronPython/Runtime/Operations/PythonOps.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Operations/PythonOps.Generated.cs rename to src/ipy/IronPython/Runtime/Operations/PythonOps.Generated.cs diff --git a/src/IronPython/Runtime/Operations/PythonOps.cs b/src/ipy/IronPython/Runtime/Operations/PythonOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/PythonOps.cs rename to src/ipy/IronPython/Runtime/Operations/PythonOps.cs diff --git a/src/IronPython/Runtime/Operations/PythonTypeOps.cs b/src/ipy/IronPython/Runtime/Operations/PythonTypeOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/PythonTypeOps.cs rename to src/ipy/IronPython/Runtime/Operations/PythonTypeOps.cs diff --git a/src/IronPython/Runtime/Operations/StringOps.Generated.cs b/src/ipy/IronPython/Runtime/Operations/StringOps.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Operations/StringOps.Generated.cs rename to src/ipy/IronPython/Runtime/Operations/StringOps.Generated.cs diff --git a/src/IronPython/Runtime/Operations/StringOps.cs b/src/ipy/IronPython/Runtime/Operations/StringOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/StringOps.cs rename to src/ipy/IronPython/Runtime/Operations/StringOps.cs diff --git a/src/IronPython/Runtime/Operations/TypeGroupOps.cs b/src/ipy/IronPython/Runtime/Operations/TypeGroupOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/TypeGroupOps.cs rename to src/ipy/IronPython/Runtime/Operations/TypeGroupOps.cs diff --git a/src/IronPython/Runtime/Operations/TypeTrackerOps.cs b/src/ipy/IronPython/Runtime/Operations/TypeTrackerOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/TypeTrackerOps.cs rename to src/ipy/IronPython/Runtime/Operations/TypeTrackerOps.cs diff --git a/src/IronPython/Runtime/Operations/UIntPtrOps.cs b/src/ipy/IronPython/Runtime/Operations/UIntPtrOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/UIntPtrOps.cs rename to src/ipy/IronPython/Runtime/Operations/UIntPtrOps.cs diff --git a/src/IronPython/Runtime/Operations/UserTypeOps.cs b/src/ipy/IronPython/Runtime/Operations/UserTypeOps.cs similarity index 100% rename from src/IronPython/Runtime/Operations/UserTypeOps.cs rename to src/ipy/IronPython/Runtime/Operations/UserTypeOps.cs diff --git a/src/IronPython/Runtime/OutputWriter.cs b/src/ipy/IronPython/Runtime/OutputWriter.cs similarity index 100% rename from src/IronPython/Runtime/OutputWriter.cs rename to src/ipy/IronPython/Runtime/OutputWriter.cs diff --git a/src/IronPython/Runtime/PlatformsAttribute.cs b/src/ipy/IronPython/Runtime/PlatformsAttribute.cs similarity index 100% rename from src/IronPython/Runtime/PlatformsAttribute.cs rename to src/ipy/IronPython/Runtime/PlatformsAttribute.cs diff --git a/src/IronPython/Runtime/Profiler.cs b/src/ipy/IronPython/Runtime/Profiler.cs similarity index 100% rename from src/IronPython/Runtime/Profiler.cs rename to src/ipy/IronPython/Runtime/Profiler.cs diff --git a/src/IronPython/Runtime/PythonContext.Generated.cs b/src/ipy/IronPython/Runtime/PythonContext.Generated.cs similarity index 100% rename from src/IronPython/Runtime/PythonContext.Generated.cs rename to src/ipy/IronPython/Runtime/PythonContext.Generated.cs diff --git a/src/IronPython/Runtime/PythonContext.cs b/src/ipy/IronPython/Runtime/PythonContext.cs similarity index 100% rename from src/IronPython/Runtime/PythonContext.cs rename to src/ipy/IronPython/Runtime/PythonContext.cs diff --git a/src/IronPython/Runtime/PythonDictionary.cs b/src/ipy/IronPython/Runtime/PythonDictionary.cs similarity index 100% rename from src/IronPython/Runtime/PythonDictionary.cs rename to src/ipy/IronPython/Runtime/PythonDictionary.cs diff --git a/src/IronPython/Runtime/PythonDocumentationProvider.cs b/src/ipy/IronPython/Runtime/PythonDocumentationProvider.cs similarity index 100% rename from src/IronPython/Runtime/PythonDocumentationProvider.cs rename to src/ipy/IronPython/Runtime/PythonDocumentationProvider.cs diff --git a/src/IronPython/Runtime/PythonDynamicStackFrame.cs b/src/ipy/IronPython/Runtime/PythonDynamicStackFrame.cs similarity index 100% rename from src/IronPython/Runtime/PythonDynamicStackFrame.cs rename to src/ipy/IronPython/Runtime/PythonDynamicStackFrame.cs diff --git a/src/IronPython/Runtime/PythonEncoding.cs b/src/ipy/IronPython/Runtime/PythonEncoding.cs similarity index 100% rename from src/IronPython/Runtime/PythonEncoding.cs rename to src/ipy/IronPython/Runtime/PythonEncoding.cs diff --git a/src/IronPython/Runtime/PythonFileManager.cs b/src/ipy/IronPython/Runtime/PythonFileManager.cs similarity index 100% rename from src/IronPython/Runtime/PythonFileManager.cs rename to src/ipy/IronPython/Runtime/PythonFileManager.cs diff --git a/src/IronPython/Runtime/PythonFunction.Generated.cs b/src/ipy/IronPython/Runtime/PythonFunction.Generated.cs similarity index 100% rename from src/IronPython/Runtime/PythonFunction.Generated.cs rename to src/ipy/IronPython/Runtime/PythonFunction.Generated.cs diff --git a/src/IronPython/Runtime/PythonFunction.cs b/src/ipy/IronPython/Runtime/PythonFunction.cs similarity index 100% rename from src/IronPython/Runtime/PythonFunction.cs rename to src/ipy/IronPython/Runtime/PythonFunction.cs diff --git a/src/IronPython/Runtime/PythonHiddenAttribute.cs b/src/ipy/IronPython/Runtime/PythonHiddenAttribute.cs similarity index 100% rename from src/IronPython/Runtime/PythonHiddenAttribute.cs rename to src/ipy/IronPython/Runtime/PythonHiddenAttribute.cs diff --git a/src/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs b/src/ipy/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs similarity index 100% rename from src/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs rename to src/ipy/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs diff --git a/src/IronPython/Runtime/PythonList.cs b/src/ipy/IronPython/Runtime/PythonList.cs similarity index 100% rename from src/IronPython/Runtime/PythonList.cs rename to src/ipy/IronPython/Runtime/PythonList.cs diff --git a/src/IronPython/Runtime/PythonModule.cs b/src/ipy/IronPython/Runtime/PythonModule.cs similarity index 100% rename from src/IronPython/Runtime/PythonModule.cs rename to src/ipy/IronPython/Runtime/PythonModule.cs diff --git a/src/IronPython/Runtime/PythonModuleAttribute.cs b/src/ipy/IronPython/Runtime/PythonModuleAttribute.cs similarity index 100% rename from src/IronPython/Runtime/PythonModuleAttribute.cs rename to src/ipy/IronPython/Runtime/PythonModuleAttribute.cs diff --git a/src/IronPython/Runtime/PythonNarrowing.cs b/src/ipy/IronPython/Runtime/PythonNarrowing.cs similarity index 100% rename from src/IronPython/Runtime/PythonNarrowing.cs rename to src/ipy/IronPython/Runtime/PythonNarrowing.cs diff --git a/src/IronPython/Runtime/PythonOptions.cs b/src/ipy/IronPython/Runtime/PythonOptions.cs similarity index 100% rename from src/IronPython/Runtime/PythonOptions.cs rename to src/ipy/IronPython/Runtime/PythonOptions.cs diff --git a/src/IronPython/Runtime/PythonRange.cs b/src/ipy/IronPython/Runtime/PythonRange.cs similarity index 100% rename from src/IronPython/Runtime/PythonRange.cs rename to src/ipy/IronPython/Runtime/PythonRange.cs diff --git a/src/IronPython/Runtime/PythonScopeExtension.cs b/src/ipy/IronPython/Runtime/PythonScopeExtension.cs similarity index 100% rename from src/IronPython/Runtime/PythonScopeExtension.cs rename to src/ipy/IronPython/Runtime/PythonScopeExtension.cs diff --git a/src/IronPython/Runtime/PythonStrIterator.cs b/src/ipy/IronPython/Runtime/PythonStrIterator.cs similarity index 100% rename from src/IronPython/Runtime/PythonStrIterator.cs rename to src/ipy/IronPython/Runtime/PythonStrIterator.cs diff --git a/src/IronPython/Runtime/PythonTracebackListener.cs b/src/ipy/IronPython/Runtime/PythonTracebackListener.cs similarity index 100% rename from src/IronPython/Runtime/PythonTracebackListener.cs rename to src/ipy/IronPython/Runtime/PythonTracebackListener.cs diff --git a/src/IronPython/Runtime/PythonTuple.cs b/src/ipy/IronPython/Runtime/PythonTuple.cs similarity index 100% rename from src/IronPython/Runtime/PythonTuple.cs rename to src/ipy/IronPython/Runtime/PythonTuple.cs diff --git a/src/IronPython/Runtime/PythonTypeAttribute.cs b/src/ipy/IronPython/Runtime/PythonTypeAttribute.cs similarity index 100% rename from src/IronPython/Runtime/PythonTypeAttribute.cs rename to src/ipy/IronPython/Runtime/PythonTypeAttribute.cs diff --git a/src/IronPython/Runtime/Reversed.cs b/src/ipy/IronPython/Runtime/Reversed.cs similarity index 100% rename from src/IronPython/Runtime/Reversed.cs rename to src/ipy/IronPython/Runtime/Reversed.cs diff --git a/src/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs b/src/ipy/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs similarity index 100% rename from src/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs rename to src/ipy/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs diff --git a/src/IronPython/Runtime/ScopeDictionaryStorage.cs b/src/ipy/IronPython/Runtime/ScopeDictionaryStorage.cs similarity index 100% rename from src/IronPython/Runtime/ScopeDictionaryStorage.cs rename to src/ipy/IronPython/Runtime/ScopeDictionaryStorage.cs diff --git a/src/IronPython/Runtime/SequenceTypeInfoAttribute.cs b/src/ipy/IronPython/Runtime/SequenceTypeInfoAttribute.cs similarity index 100% rename from src/IronPython/Runtime/SequenceTypeInfoAttribute.cs rename to src/ipy/IronPython/Runtime/SequenceTypeInfoAttribute.cs diff --git a/src/IronPython/Runtime/Set.cs b/src/ipy/IronPython/Runtime/Set.cs similarity index 100% rename from src/IronPython/Runtime/Set.cs rename to src/ipy/IronPython/Runtime/Set.cs diff --git a/src/IronPython/Runtime/SetStorage.cs b/src/ipy/IronPython/Runtime/SetStorage.cs similarity index 100% rename from src/IronPython/Runtime/SetStorage.cs rename to src/ipy/IronPython/Runtime/SetStorage.cs diff --git a/src/IronPython/Runtime/SimpleNamespace.cs b/src/ipy/IronPython/Runtime/SimpleNamespace.cs similarity index 100% rename from src/IronPython/Runtime/SimpleNamespace.cs rename to src/ipy/IronPython/Runtime/SimpleNamespace.cs diff --git a/src/IronPython/Runtime/SiteLocalStorage.cs b/src/ipy/IronPython/Runtime/SiteLocalStorage.cs similarity index 100% rename from src/IronPython/Runtime/SiteLocalStorage.cs rename to src/ipy/IronPython/Runtime/SiteLocalStorage.cs diff --git a/src/IronPython/Runtime/Slice.cs b/src/ipy/IronPython/Runtime/Slice.cs similarity index 100% rename from src/IronPython/Runtime/Slice.cs rename to src/ipy/IronPython/Runtime/Slice.cs diff --git a/src/IronPython/Runtime/StringDictionaryStorage.cs b/src/ipy/IronPython/Runtime/StringDictionaryStorage.cs similarity index 100% rename from src/IronPython/Runtime/StringDictionaryStorage.cs rename to src/ipy/IronPython/Runtime/StringDictionaryStorage.cs diff --git a/src/IronPython/Runtime/StringFormatSpec.cs b/src/ipy/IronPython/Runtime/StringFormatSpec.cs similarity index 100% rename from src/IronPython/Runtime/StringFormatSpec.cs rename to src/ipy/IronPython/Runtime/StringFormatSpec.cs diff --git a/src/IronPython/Runtime/StringFormatter.cs b/src/ipy/IronPython/Runtime/StringFormatter.cs similarity index 100% rename from src/IronPython/Runtime/StringFormatter.cs rename to src/ipy/IronPython/Runtime/StringFormatter.cs diff --git a/src/IronPython/Runtime/Super.cs b/src/ipy/IronPython/Runtime/Super.cs similarity index 100% rename from src/IronPython/Runtime/Super.cs rename to src/ipy/IronPython/Runtime/Super.cs diff --git a/src/IronPython/Runtime/Symbols.Generated.cs b/src/ipy/IronPython/Runtime/Symbols.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Symbols.Generated.cs rename to src/ipy/IronPython/Runtime/Symbols.Generated.cs diff --git a/src/IronPython/Runtime/ThrowingErrorSink.cs b/src/ipy/IronPython/Runtime/ThrowingErrorSink.cs similarity index 100% rename from src/IronPython/Runtime/ThrowingErrorSink.cs rename to src/ipy/IronPython/Runtime/ThrowingErrorSink.cs diff --git a/src/IronPython/Runtime/TypecodeOps.cs b/src/ipy/IronPython/Runtime/TypecodeOps.cs similarity index 100% rename from src/IronPython/Runtime/TypecodeOps.cs rename to src/ipy/IronPython/Runtime/TypecodeOps.cs diff --git a/src/IronPython/Runtime/Types/BuiltinFunction.cs b/src/ipy/IronPython/Runtime/Types/BuiltinFunction.cs similarity index 100% rename from src/IronPython/Runtime/Types/BuiltinFunction.cs rename to src/ipy/IronPython/Runtime/Types/BuiltinFunction.cs diff --git a/src/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs b/src/ipy/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs similarity index 100% rename from src/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs rename to src/ipy/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs diff --git a/src/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs b/src/ipy/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs similarity index 100% rename from src/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs rename to src/ipy/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs diff --git a/src/IronPython/Runtime/Types/CachedNewTypeInfo.cs b/src/ipy/IronPython/Runtime/Types/CachedNewTypeInfo.cs similarity index 100% rename from src/IronPython/Runtime/Types/CachedNewTypeInfo.cs rename to src/ipy/IronPython/Runtime/Types/CachedNewTypeInfo.cs diff --git a/src/IronPython/Runtime/Types/ConstructorFunction.cs b/src/ipy/IronPython/Runtime/Types/ConstructorFunction.cs similarity index 100% rename from src/IronPython/Runtime/Types/ConstructorFunction.cs rename to src/ipy/IronPython/Runtime/Types/ConstructorFunction.cs diff --git a/src/IronPython/Runtime/Types/CustomAttributeTracker.cs b/src/ipy/IronPython/Runtime/Types/CustomAttributeTracker.cs similarity index 100% rename from src/IronPython/Runtime/Types/CustomAttributeTracker.cs rename to src/ipy/IronPython/Runtime/Types/CustomAttributeTracker.cs diff --git a/src/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs b/src/ipy/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs similarity index 100% rename from src/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs rename to src/ipy/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs diff --git a/src/IronPython/Runtime/Types/DocBuilder.cs b/src/ipy/IronPython/Runtime/Types/DocBuilder.cs similarity index 100% rename from src/IronPython/Runtime/Types/DocBuilder.cs rename to src/ipy/IronPython/Runtime/Types/DocBuilder.cs diff --git a/src/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs b/src/ipy/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs similarity index 100% rename from src/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs rename to src/ipy/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs diff --git a/src/IronPython/Runtime/Types/DynamicHelpers.cs b/src/ipy/IronPython/Runtime/Types/DynamicHelpers.cs similarity index 100% rename from src/IronPython/Runtime/Types/DynamicHelpers.cs rename to src/ipy/IronPython/Runtime/Types/DynamicHelpers.cs diff --git a/src/IronPython/Runtime/Types/EmptyType.cs b/src/ipy/IronPython/Runtime/Types/EmptyType.cs similarity index 100% rename from src/IronPython/Runtime/Types/EmptyType.cs rename to src/ipy/IronPython/Runtime/Types/EmptyType.cs diff --git a/src/IronPython/Runtime/Types/ExtensionPropertyInfo.cs b/src/ipy/IronPython/Runtime/Types/ExtensionPropertyInfo.cs similarity index 100% rename from src/IronPython/Runtime/Types/ExtensionPropertyInfo.cs rename to src/ipy/IronPython/Runtime/Types/ExtensionPropertyInfo.cs diff --git a/src/IronPython/Runtime/Types/FunctionType.cs b/src/ipy/IronPython/Runtime/Types/FunctionType.cs similarity index 100% rename from src/IronPython/Runtime/Types/FunctionType.cs rename to src/ipy/IronPython/Runtime/Types/FunctionType.cs diff --git a/src/IronPython/Runtime/Types/IPythonObject.cs b/src/ipy/IronPython/Runtime/Types/IPythonObject.cs similarity index 100% rename from src/IronPython/Runtime/Types/IPythonObject.cs rename to src/ipy/IronPython/Runtime/Types/IPythonObject.cs diff --git a/src/IronPython/Runtime/Types/InstanceCreator.cs b/src/ipy/IronPython/Runtime/Types/InstanceCreator.cs similarity index 100% rename from src/IronPython/Runtime/Types/InstanceCreator.cs rename to src/ipy/IronPython/Runtime/Types/InstanceCreator.cs diff --git a/src/IronPython/Runtime/Types/MappingProxy.cs b/src/ipy/IronPython/Runtime/Types/MappingProxy.cs similarity index 100% rename from src/IronPython/Runtime/Types/MappingProxy.cs rename to src/ipy/IronPython/Runtime/Types/MappingProxy.cs diff --git a/src/IronPython/Runtime/Types/Mro.cs b/src/ipy/IronPython/Runtime/Types/Mro.cs similarity index 100% rename from src/IronPython/Runtime/Types/Mro.cs rename to src/ipy/IronPython/Runtime/Types/Mro.cs diff --git a/src/IronPython/Runtime/Types/NameConverter.cs b/src/ipy/IronPython/Runtime/Types/NameConverter.cs similarity index 100% rename from src/IronPython/Runtime/Types/NameConverter.cs rename to src/ipy/IronPython/Runtime/Types/NameConverter.cs diff --git a/src/IronPython/Runtime/Types/NewTypeInfo.cs b/src/ipy/IronPython/Runtime/Types/NewTypeInfo.cs similarity index 100% rename from src/IronPython/Runtime/Types/NewTypeInfo.cs rename to src/ipy/IronPython/Runtime/Types/NewTypeInfo.cs diff --git a/src/IronPython/Runtime/Types/NewTypeMaker.cs b/src/ipy/IronPython/Runtime/Types/NewTypeMaker.cs similarity index 100% rename from src/IronPython/Runtime/Types/NewTypeMaker.cs rename to src/ipy/IronPython/Runtime/Types/NewTypeMaker.cs diff --git a/src/IronPython/Runtime/Types/OperatorMapping.cs b/src/ipy/IronPython/Runtime/Types/OperatorMapping.cs similarity index 100% rename from src/IronPython/Runtime/Types/OperatorMapping.cs rename to src/ipy/IronPython/Runtime/Types/OperatorMapping.cs diff --git a/src/IronPython/Runtime/Types/ParameterInfoWrapper.cs b/src/ipy/IronPython/Runtime/Types/ParameterInfoWrapper.cs similarity index 100% rename from src/IronPython/Runtime/Types/ParameterInfoWrapper.cs rename to src/ipy/IronPython/Runtime/Types/ParameterInfoWrapper.cs diff --git a/src/IronPython/Runtime/Types/PythonAssemblyOps.cs b/src/ipy/IronPython/Runtime/Types/PythonAssemblyOps.cs similarity index 100% rename from src/IronPython/Runtime/Types/PythonAssemblyOps.cs rename to src/ipy/IronPython/Runtime/Types/PythonAssemblyOps.cs diff --git a/src/IronPython/Runtime/Types/PythonSiteCache.cs b/src/ipy/IronPython/Runtime/Types/PythonSiteCache.cs similarity index 100% rename from src/IronPython/Runtime/Types/PythonSiteCache.cs rename to src/ipy/IronPython/Runtime/Types/PythonSiteCache.cs diff --git a/src/IronPython/Runtime/Types/PythonType.Generated.cs b/src/ipy/IronPython/Runtime/Types/PythonType.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Types/PythonType.Generated.cs rename to src/ipy/IronPython/Runtime/Types/PythonType.Generated.cs diff --git a/src/IronPython/Runtime/Types/PythonType.cs b/src/ipy/IronPython/Runtime/Types/PythonType.cs similarity index 100% rename from src/IronPython/Runtime/Types/PythonType.cs rename to src/ipy/IronPython/Runtime/Types/PythonType.cs diff --git a/src/IronPython/Runtime/Types/PythonTypeDataSlot.cs b/src/ipy/IronPython/Runtime/Types/PythonTypeDataSlot.cs similarity index 100% rename from src/IronPython/Runtime/Types/PythonTypeDataSlot.cs rename to src/ipy/IronPython/Runtime/Types/PythonTypeDataSlot.cs diff --git a/src/IronPython/Runtime/Types/PythonTypeDictSlot.cs b/src/ipy/IronPython/Runtime/Types/PythonTypeDictSlot.cs similarity index 100% rename from src/IronPython/Runtime/Types/PythonTypeDictSlot.cs rename to src/ipy/IronPython/Runtime/Types/PythonTypeDictSlot.cs diff --git a/src/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs b/src/ipy/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs rename to src/ipy/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs diff --git a/src/IronPython/Runtime/Types/PythonTypeInfo.cs b/src/ipy/IronPython/Runtime/Types/PythonTypeInfo.cs similarity index 100% rename from src/IronPython/Runtime/Types/PythonTypeInfo.cs rename to src/ipy/IronPython/Runtime/Types/PythonTypeInfo.cs diff --git a/src/IronPython/Runtime/Types/PythonTypeSlot.cs b/src/ipy/IronPython/Runtime/Types/PythonTypeSlot.cs similarity index 100% rename from src/IronPython/Runtime/Types/PythonTypeSlot.cs rename to src/ipy/IronPython/Runtime/Types/PythonTypeSlot.cs diff --git a/src/IronPython/Runtime/Types/PythonTypeTypeSlot.cs b/src/ipy/IronPython/Runtime/Types/PythonTypeTypeSlot.cs similarity index 100% rename from src/IronPython/Runtime/Types/PythonTypeTypeSlot.cs rename to src/ipy/IronPython/Runtime/Types/PythonTypeTypeSlot.cs diff --git a/src/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs b/src/ipy/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs similarity index 100% rename from src/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs rename to src/ipy/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs diff --git a/src/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs b/src/ipy/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs similarity index 100% rename from src/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs rename to src/ipy/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs diff --git a/src/IronPython/Runtime/Types/ReflectedEvent.cs b/src/ipy/IronPython/Runtime/Types/ReflectedEvent.cs similarity index 100% rename from src/IronPython/Runtime/Types/ReflectedEvent.cs rename to src/ipy/IronPython/Runtime/Types/ReflectedEvent.cs diff --git a/src/IronPython/Runtime/Types/ReflectedExtensionProperty.cs b/src/ipy/IronPython/Runtime/Types/ReflectedExtensionProperty.cs similarity index 100% rename from src/IronPython/Runtime/Types/ReflectedExtensionProperty.cs rename to src/ipy/IronPython/Runtime/Types/ReflectedExtensionProperty.cs diff --git a/src/IronPython/Runtime/Types/ReflectedField.cs b/src/ipy/IronPython/Runtime/Types/ReflectedField.cs similarity index 100% rename from src/IronPython/Runtime/Types/ReflectedField.cs rename to src/ipy/IronPython/Runtime/Types/ReflectedField.cs diff --git a/src/IronPython/Runtime/Types/ReflectedGetterSetter.cs b/src/ipy/IronPython/Runtime/Types/ReflectedGetterSetter.cs similarity index 100% rename from src/IronPython/Runtime/Types/ReflectedGetterSetter.cs rename to src/ipy/IronPython/Runtime/Types/ReflectedGetterSetter.cs diff --git a/src/IronPython/Runtime/Types/ReflectedIndexer.cs b/src/ipy/IronPython/Runtime/Types/ReflectedIndexer.cs similarity index 100% rename from src/IronPython/Runtime/Types/ReflectedIndexer.cs rename to src/ipy/IronPython/Runtime/Types/ReflectedIndexer.cs diff --git a/src/IronPython/Runtime/Types/ReflectedProperty.cs b/src/ipy/IronPython/Runtime/Types/ReflectedProperty.cs similarity index 100% rename from src/IronPython/Runtime/Types/ReflectedProperty.cs rename to src/ipy/IronPython/Runtime/Types/ReflectedProperty.cs diff --git a/src/IronPython/Runtime/Types/ReflectedSlotProperty.cs b/src/ipy/IronPython/Runtime/Types/ReflectedSlotProperty.cs similarity index 100% rename from src/IronPython/Runtime/Types/ReflectedSlotProperty.cs rename to src/ipy/IronPython/Runtime/Types/ReflectedSlotProperty.cs diff --git a/src/IronPython/Runtime/Types/ResolvedMember.cs b/src/ipy/IronPython/Runtime/Types/ResolvedMember.cs similarity index 100% rename from src/IronPython/Runtime/Types/ResolvedMember.cs rename to src/ipy/IronPython/Runtime/Types/ResolvedMember.cs diff --git a/src/IronPython/Runtime/Types/SlotFieldAttribute.cs b/src/ipy/IronPython/Runtime/Types/SlotFieldAttribute.cs similarity index 100% rename from src/IronPython/Runtime/Types/SlotFieldAttribute.cs rename to src/ipy/IronPython/Runtime/Types/SlotFieldAttribute.cs diff --git a/src/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs b/src/ipy/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs similarity index 100% rename from src/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs rename to src/ipy/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs diff --git a/src/IronPython/Runtime/Types/TypeCache.Generated.cs b/src/ipy/IronPython/Runtime/Types/TypeCache.Generated.cs similarity index 100% rename from src/IronPython/Runtime/Types/TypeCache.Generated.cs rename to src/ipy/IronPython/Runtime/Types/TypeCache.Generated.cs diff --git a/src/IronPython/Runtime/UnboundNameException.cs b/src/ipy/IronPython/Runtime/UnboundNameException.cs similarity index 100% rename from src/IronPython/Runtime/UnboundNameException.cs rename to src/ipy/IronPython/Runtime/UnboundNameException.cs diff --git a/src/IronPython/Runtime/WeakRef.cs b/src/ipy/IronPython/Runtime/WeakRef.cs similarity index 100% rename from src/IronPython/Runtime/WeakRef.cs rename to src/ipy/IronPython/Runtime/WeakRef.cs diff --git a/src/IronPython/Runtime/WrapperDescriptorAttribute.cs b/src/ipy/IronPython/Runtime/WrapperDescriptorAttribute.cs similarity index 100% rename from src/IronPython/Runtime/WrapperDescriptorAttribute.cs rename to src/ipy/IronPython/Runtime/WrapperDescriptorAttribute.cs diff --git a/src/IronPython/Runtime/WrapperDictionary.cs b/src/ipy/IronPython/Runtime/WrapperDictionary.cs similarity index 100% rename from src/IronPython/Runtime/WrapperDictionary.cs rename to src/ipy/IronPython/Runtime/WrapperDictionary.cs diff --git a/src/IronPython/Runtime/Zip.cs b/src/ipy/IronPython/Runtime/Zip.cs similarity index 100% rename from src/IronPython/Runtime/Zip.cs rename to src/ipy/IronPython/Runtime/Zip.cs diff --git a/src/IronPython/SerializationStubs.cs b/src/ipy/IronPython/SerializationStubs.cs similarity index 100% rename from src/IronPython/SerializationStubs.cs rename to src/ipy/IronPython/SerializationStubs.cs diff --git a/src/IronPython/StringExtensions.cs b/src/ipy/IronPython/StringExtensions.cs similarity index 100% rename from src/IronPython/StringExtensions.cs rename to src/ipy/IronPython/StringExtensions.cs diff --git a/src/IronPython/SystemRuntimeVersioning.cs b/src/ipy/IronPython/SystemRuntimeVersioning.cs similarity index 100% rename from src/IronPython/SystemRuntimeVersioning.cs rename to src/ipy/IronPython/SystemRuntimeVersioning.cs diff --git a/src/IronPython/policy.IronPython.config b/src/ipy/IronPython/policy.IronPython.config similarity index 100% rename from src/IronPython/policy.IronPython.config rename to src/ipy/IronPython/policy.IronPython.config diff --git a/src/DiagnosticAnalyzer/Analyzer.cs b/src/roslyn/IronPython.DiagnosticAnalyzer/Analyzer.cs similarity index 100% rename from src/DiagnosticAnalyzer/Analyzer.cs rename to src/roslyn/IronPython.DiagnosticAnalyzer/Analyzer.cs diff --git a/src/DiagnosticAnalyzer/Directory.Build.props b/src/roslyn/IronPython.DiagnosticAnalyzer/Directory.Build.props similarity index 100% rename from src/DiagnosticAnalyzer/Directory.Build.props rename to src/roslyn/IronPython.DiagnosticAnalyzer/Directory.Build.props diff --git a/src/DiagnosticAnalyzer/IronPython.DiagnosticAnalyzer.csproj b/src/roslyn/IronPython.DiagnosticAnalyzer/IronPython.DiagnosticAnalyzer.csproj similarity index 100% rename from src/DiagnosticAnalyzer/IronPython.DiagnosticAnalyzer.csproj rename to src/roslyn/IronPython.DiagnosticAnalyzer/IronPython.DiagnosticAnalyzer.csproj diff --git a/src/Tests/AssemblyInfo.cs b/tests/ironpython/AssemblyInfo.cs similarity index 100% rename from src/Tests/AssemblyInfo.cs rename to tests/ironpython/AssemblyInfo.cs diff --git a/src/Tests/AttrInjectorTest.cs b/tests/ironpython/AttrInjectorTest.cs similarity index 100% rename from src/Tests/AttrInjectorTest.cs rename to tests/ironpython/AttrInjectorTest.cs diff --git a/src/Tests/BindTest.cs b/tests/ironpython/BindTest.cs similarity index 100% rename from src/Tests/BindTest.cs rename to tests/ironpython/BindTest.cs diff --git a/src/Tests/BinderTest.cs b/tests/ironpython/BinderTest.cs similarity index 100% rename from src/Tests/BinderTest.cs rename to tests/ironpython/BinderTest.cs diff --git a/src/Tests/Cases/CPythonCases.cs b/tests/ironpython/Cases/CPythonCases.cs similarity index 100% rename from src/Tests/Cases/CPythonCases.cs rename to tests/ironpython/Cases/CPythonCases.cs diff --git a/src/Tests/Cases/CPythonCasesManifest.ini b/tests/ironpython/Cases/CPythonCasesManifest.ini similarity index 100% rename from src/Tests/Cases/CPythonCasesManifest.ini rename to tests/ironpython/Cases/CPythonCasesManifest.ini diff --git a/src/Tests/Cases/CaseExecuter.cs b/tests/ironpython/Cases/CaseExecuter.cs similarity index 100% rename from src/Tests/Cases/CaseExecuter.cs rename to tests/ironpython/Cases/CaseExecuter.cs diff --git a/src/Tests/Cases/CaseGenerator.cs b/tests/ironpython/Cases/CaseGenerator.cs similarity index 100% rename from src/Tests/Cases/CaseGenerator.cs rename to tests/ironpython/Cases/CaseGenerator.cs diff --git a/src/Tests/Cases/CommonCases.cs b/tests/ironpython/Cases/CommonCases.cs similarity index 100% rename from src/Tests/Cases/CommonCases.cs rename to tests/ironpython/Cases/CommonCases.cs diff --git a/src/Tests/Cases/IronPythonCases.cs b/tests/ironpython/Cases/IronPythonCases.cs similarity index 100% rename from src/Tests/Cases/IronPythonCases.cs rename to tests/ironpython/Cases/IronPythonCases.cs diff --git a/src/Tests/Cases/IronPythonCasesManifest.ini b/tests/ironpython/Cases/IronPythonCasesManifest.ini similarity index 100% rename from src/Tests/Cases/IronPythonCasesManifest.ini rename to tests/ironpython/Cases/IronPythonCasesManifest.ini diff --git a/src/Tests/ClrType.cs b/tests/ironpython/ClrType.cs similarity index 100% rename from src/Tests/ClrType.cs rename to tests/ironpython/ClrType.cs diff --git a/src/Tests/Cmplx.cs b/tests/ironpython/Cmplx.cs similarity index 100% rename from src/Tests/Cmplx.cs rename to tests/ironpython/Cmplx.cs diff --git a/src/Tests/Conversions.cs b/tests/ironpython/Conversions.cs similarity index 100% rename from src/Tests/Conversions.cs rename to tests/ironpython/Conversions.cs diff --git a/src/Tests/DeTest.cs b/tests/ironpython/DeTest.cs similarity index 100% rename from src/Tests/DeTest.cs rename to tests/ironpython/DeTest.cs diff --git a/src/Tests/DelegateTest.cs b/tests/ironpython/DelegateTest.cs similarity index 100% rename from src/Tests/DelegateTest.cs rename to tests/ironpython/DelegateTest.cs diff --git a/src/Tests/DynamicRegressions.cs b/tests/ironpython/DynamicRegressions.cs similarity index 100% rename from src/Tests/DynamicRegressions.cs rename to tests/ironpython/DynamicRegressions.cs diff --git a/src/Tests/EncodingTest.cs b/tests/ironpython/EncodingTest.cs similarity index 100% rename from src/Tests/EncodingTest.cs rename to tests/ironpython/EncodingTest.cs diff --git a/src/Tests/EngineTest.cs b/tests/ironpython/EngineTest.cs similarity index 100% rename from src/Tests/EngineTest.cs rename to tests/ironpython/EngineTest.cs diff --git a/src/Tests/Enums.cs b/tests/ironpython/Enums.cs similarity index 100% rename from src/Tests/Enums.cs rename to tests/ironpython/Enums.cs diff --git a/src/Tests/Events.cs b/tests/ironpython/Events.cs similarity index 100% rename from src/Tests/Events.cs rename to tests/ironpython/Events.cs diff --git a/src/Tests/ExceptionConverter.cs b/tests/ironpython/ExceptionConverter.cs similarity index 100% rename from src/Tests/ExceptionConverter.cs rename to tests/ironpython/ExceptionConverter.cs diff --git a/src/Tests/Exceptions.cs b/tests/ironpython/Exceptions.cs similarity index 100% rename from src/Tests/Exceptions.cs rename to tests/ironpython/Exceptions.cs diff --git a/src/Tests/Explicit.cs b/tests/ironpython/Explicit.cs similarity index 100% rename from src/Tests/Explicit.cs rename to tests/ironpython/Explicit.cs diff --git a/src/Tests/ExtensionMethodTest.cs b/tests/ironpython/ExtensionMethodTest.cs similarity index 100% rename from src/Tests/ExtensionMethodTest.cs rename to tests/ironpython/ExtensionMethodTest.cs diff --git a/src/Tests/GenMeth.cs b/tests/ironpython/GenMeth.cs similarity index 100% rename from src/Tests/GenMeth.cs rename to tests/ironpython/GenMeth.cs diff --git a/src/Tests/Indexable.cs b/tests/ironpython/Indexable.cs similarity index 100% rename from src/Tests/Indexable.cs rename to tests/ironpython/Indexable.cs diff --git a/src/Tests/InheritTest.cs b/tests/ironpython/InheritTest.cs similarity index 100% rename from src/Tests/InheritTest.cs rename to tests/ironpython/InheritTest.cs diff --git a/src/Tests/IntegerTest.cs b/tests/ironpython/IntegerTest.cs similarity index 100% rename from src/Tests/IntegerTest.cs rename to tests/ironpython/IntegerTest.cs diff --git a/src/Tests/IronMath.cs b/tests/ironpython/IronMath.cs similarity index 100% rename from src/Tests/IronMath.cs rename to tests/ironpython/IronMath.cs diff --git a/src/Tests/IronPython.Tests.csproj b/tests/ironpython/IronPython.Tests.csproj similarity index 100% rename from src/Tests/IronPython.Tests.csproj rename to tests/ironpython/IronPython.Tests.csproj diff --git a/src/Tests/LoadTest.cs b/tests/ironpython/LoadTest.cs similarity index 100% rename from src/Tests/LoadTest.cs rename to tests/ironpython/LoadTest.cs diff --git a/src/Tests/MemberMappingTests.cs b/tests/ironpython/MemberMappingTests.cs similarity index 100% rename from src/Tests/MemberMappingTests.cs rename to tests/ironpython/MemberMappingTests.cs diff --git a/src/Tests/MemberOverloadTest.cs b/tests/ironpython/MemberOverloadTest.cs similarity index 100% rename from src/Tests/MemberOverloadTest.cs rename to tests/ironpython/MemberOverloadTest.cs diff --git a/src/Tests/MethodParametersStubs.cs b/tests/ironpython/MethodParametersStubs.cs similarity index 100% rename from src/Tests/MethodParametersStubs.cs rename to tests/ironpython/MethodParametersStubs.cs diff --git a/src/Tests/NestedClass.cs b/tests/ironpython/NestedClass.cs similarity index 100% rename from src/Tests/NestedClass.cs rename to tests/ironpython/NestedClass.cs diff --git a/src/Tests/NullableTest.cs b/tests/ironpython/NullableTest.cs similarity index 100% rename from src/Tests/NullableTest.cs rename to tests/ironpython/NullableTest.cs diff --git a/src/Tests/OperatorTest.cs b/tests/ironpython/OperatorTest.cs similarity index 100% rename from src/Tests/OperatorTest.cs rename to tests/ironpython/OperatorTest.cs diff --git a/src/Tests/ProtocolTest.cs b/tests/ironpython/ProtocolTest.cs similarity index 100% rename from src/Tests/ProtocolTest.cs rename to tests/ironpython/ProtocolTest.cs diff --git a/src/Tests/StaticTest.cs b/tests/ironpython/StaticTest.cs similarity index 100% rename from src/Tests/StaticTest.cs rename to tests/ironpython/StaticTest.cs diff --git a/src/Tests/Stress/Engine.cs b/tests/ironpython/Stress/Engine.cs similarity index 100% rename from src/Tests/Stress/Engine.cs rename to tests/ironpython/Stress/Engine.cs diff --git a/src/Tests/StringDictionaryStorage.cs b/tests/ironpython/StringDictionaryStorage.cs similarity index 100% rename from src/Tests/StringDictionaryStorage.cs rename to tests/ironpython/StringDictionaryStorage.cs diff --git a/src/Tests/TestBuiltinModule.cs b/tests/ironpython/TestBuiltinModule.cs similarity index 100% rename from src/Tests/TestBuiltinModule.cs rename to tests/ironpython/TestBuiltinModule.cs diff --git a/src/Tests/TypeDescriptor.cs b/tests/ironpython/TypeDescriptor.cs similarity index 100% rename from src/Tests/TypeDescriptor.cs rename to tests/ironpython/TypeDescriptor.cs diff --git a/src/Tests/Util/IniParser.cs b/tests/ironpython/Util/IniParser.cs similarity index 100% rename from src/Tests/Util/IniParser.cs rename to tests/ironpython/Util/IniParser.cs diff --git a/src/Tests/Util/TestManifest.cs b/tests/ironpython/Util/TestManifest.cs similarity index 100% rename from src/Tests/Util/TestManifest.cs rename to tests/ironpython/Util/TestManifest.cs diff --git a/tests/IndicesTest.py b/tests/python/IndicesTest.py similarity index 100% rename from tests/IndicesTest.py rename to tests/python/IndicesTest.py diff --git a/tests/Inputs/RemoteConsole.py b/tests/python/Inputs/RemoteConsole.py similarity index 100% rename from tests/Inputs/RemoteConsole.py rename to tests/python/Inputs/RemoteConsole.py diff --git a/tests/Inputs/UseCLI.py b/tests/python/Inputs/UseCLI.py similarity index 100% rename from tests/Inputs/UseCLI.py rename to tests/python/Inputs/UseCLI.py diff --git a/tests/Inputs/exit.py b/tests/python/Inputs/exit.py similarity index 100% rename from tests/Inputs/exit.py rename to tests/python/Inputs/exit.py diff --git a/tests/Inputs/exitFuncRaises.py b/tests/python/Inputs/exitFuncRaises.py similarity index 100% rename from tests/Inputs/exitFuncRaises.py rename to tests/python/Inputs/exitFuncRaises.py diff --git a/tests/Inputs/exitFuncRuns.py b/tests/python/Inputs/exitFuncRuns.py similarity index 100% rename from tests/Inputs/exitFuncRuns.py rename to tests/python/Inputs/exitFuncRuns.py diff --git a/tests/Inputs/raise.py b/tests/python/Inputs/raise.py similarity index 100% rename from tests/Inputs/raise.py rename to tests/python/Inputs/raise.py diff --git a/tests/Inputs/simpleCommand.py b/tests/python/Inputs/simpleCommand.py similarity index 100% rename from tests/Inputs/simpleCommand.py rename to tests/python/Inputs/simpleCommand.py diff --git a/tests/Inputs/syntaxError.py b/tests/python/Inputs/syntaxError.py similarity index 100% rename from tests/Inputs/syntaxError.py rename to tests/python/Inputs/syntaxError.py diff --git a/tests/Inputs/uninitializedGlobal.py b/tests/python/Inputs/uninitializedGlobal.py similarity index 100% rename from tests/Inputs/uninitializedGlobal.py rename to tests/python/Inputs/uninitializedGlobal.py diff --git a/tests/Modes/ConsoleFlags.ps1 b/tests/python/Modes/ConsoleFlags.ps1 similarity index 100% rename from tests/Modes/ConsoleFlags.ps1 rename to tests/python/Modes/ConsoleFlags.ps1 diff --git a/tests/Modes/ConsoleHelp.Debug.out b/tests/python/Modes/ConsoleHelp.Debug.out similarity index 100% rename from tests/Modes/ConsoleHelp.Debug.out rename to tests/python/Modes/ConsoleHelp.Debug.out diff --git a/tests/Modes/ConsoleHelp.Release.out b/tests/python/Modes/ConsoleHelp.Release.out similarity index 100% rename from tests/Modes/ConsoleHelp.Release.out rename to tests/python/Modes/ConsoleHelp.Release.out diff --git a/tests/RunAgainstCpy.py b/tests/python/RunAgainstCpy.py similarity index 100% rename from tests/RunAgainstCpy.py rename to tests/python/RunAgainstCpy.py diff --git a/tests/Tools/baselines/__builtin__.log b/tests/python/Tools/baselines/__builtin__.log similarity index 100% rename from tests/Tools/baselines/__builtin__.log rename to tests/python/Tools/baselines/__builtin__.log diff --git a/tests/Tools/baselines/_codecs.log b/tests/python/Tools/baselines/_codecs.log similarity index 100% rename from tests/Tools/baselines/_codecs.log rename to tests/python/Tools/baselines/_codecs.log diff --git a/tests/Tools/baselines/_collections.log b/tests/python/Tools/baselines/_collections.log similarity index 100% rename from tests/Tools/baselines/_collections.log rename to tests/python/Tools/baselines/_collections.log diff --git a/tests/Tools/baselines/_sre.log b/tests/python/Tools/baselines/_sre.log similarity index 100% rename from tests/Tools/baselines/_sre.log rename to tests/python/Tools/baselines/_sre.log diff --git a/tests/Tools/baselines/_struct.log b/tests/python/Tools/baselines/_struct.log similarity index 100% rename from tests/Tools/baselines/_struct.log rename to tests/python/Tools/baselines/_struct.log diff --git a/tests/Tools/baselines/_subprocess.log b/tests/python/Tools/baselines/_subprocess.log similarity index 100% rename from tests/Tools/baselines/_subprocess.log rename to tests/python/Tools/baselines/_subprocess.log diff --git a/tests/Tools/baselines/_weakref.log b/tests/python/Tools/baselines/_weakref.log similarity index 100% rename from tests/Tools/baselines/_weakref.log rename to tests/python/Tools/baselines/_weakref.log diff --git a/tests/Tools/baselines/_winreg.log b/tests/python/Tools/baselines/_winreg.log similarity index 100% rename from tests/Tools/baselines/_winreg.log rename to tests/python/Tools/baselines/_winreg.log diff --git a/tests/Tools/baselines/array.log b/tests/python/Tools/baselines/array.log similarity index 100% rename from tests/Tools/baselines/array.log rename to tests/python/Tools/baselines/array.log diff --git a/tests/Tools/baselines/cPickle.log b/tests/python/Tools/baselines/cPickle.log similarity index 100% rename from tests/Tools/baselines/cPickle.log rename to tests/python/Tools/baselines/cPickle.log diff --git a/tests/Tools/baselines/cStringIO.log b/tests/python/Tools/baselines/cStringIO.log similarity index 100% rename from tests/Tools/baselines/cStringIO.log rename to tests/python/Tools/baselines/cStringIO.log diff --git a/tests/Tools/baselines/copy_reg.log b/tests/python/Tools/baselines/copy_reg.log similarity index 100% rename from tests/Tools/baselines/copy_reg.log rename to tests/python/Tools/baselines/copy_reg.log diff --git a/tests/Tools/baselines/datetime.log b/tests/python/Tools/baselines/datetime.log similarity index 100% rename from tests/Tools/baselines/datetime.log rename to tests/python/Tools/baselines/datetime.log diff --git a/tests/Tools/baselines/gc.log b/tests/python/Tools/baselines/gc.log similarity index 100% rename from tests/Tools/baselines/gc.log rename to tests/python/Tools/baselines/gc.log diff --git a/tests/Tools/baselines/itertools.log b/tests/python/Tools/baselines/itertools.log similarity index 100% rename from tests/Tools/baselines/itertools.log rename to tests/python/Tools/baselines/itertools.log diff --git a/tests/Tools/baselines/math.log b/tests/python/Tools/baselines/math.log similarity index 100% rename from tests/Tools/baselines/math.log rename to tests/python/Tools/baselines/math.log diff --git a/tests/Tools/baselines/mmap.log b/tests/python/Tools/baselines/mmap.log similarity index 100% rename from tests/Tools/baselines/mmap.log rename to tests/python/Tools/baselines/mmap.log diff --git a/tests/Tools/baselines/msvcrt.log b/tests/python/Tools/baselines/msvcrt.log similarity index 100% rename from tests/Tools/baselines/msvcrt.log rename to tests/python/Tools/baselines/msvcrt.log diff --git a/tests/Tools/baselines/nt.log b/tests/python/Tools/baselines/nt.log similarity index 100% rename from tests/Tools/baselines/nt.log rename to tests/python/Tools/baselines/nt.log diff --git a/tests/Tools/baselines/select.log b/tests/python/Tools/baselines/select.log similarity index 100% rename from tests/Tools/baselines/select.log rename to tests/python/Tools/baselines/select.log diff --git a/tests/Tools/baselines/signal.log b/tests/python/Tools/baselines/signal.log similarity index 100% rename from tests/Tools/baselines/signal.log rename to tests/python/Tools/baselines/signal.log diff --git a/tests/Tools/baselines/sys.log b/tests/python/Tools/baselines/sys.log similarity index 100% rename from tests/Tools/baselines/sys.log rename to tests/python/Tools/baselines/sys.log diff --git a/tests/Tools/baselines/thread.log b/tests/python/Tools/baselines/thread.log similarity index 100% rename from tests/Tools/baselines/thread.log rename to tests/python/Tools/baselines/thread.log diff --git a/tests/Tools/baselines/time.log b/tests/python/Tools/baselines/time.log similarity index 100% rename from tests/Tools/baselines/time.log rename to tests/python/Tools/baselines/time.log diff --git a/tests/Tools/baselines/types_only.log b/tests/python/Tools/baselines/types_only.log similarity index 100% rename from tests/Tools/baselines/types_only.log rename to tests/python/Tools/baselines/types_only.log diff --git a/tests/Tools/baselines/xxsubtype.log b/tests/python/Tools/baselines/xxsubtype.log similarity index 100% rename from tests/Tools/baselines/xxsubtype.log rename to tests/python/Tools/baselines/xxsubtype.log diff --git a/tests/Tools/check/_functools.log b/tests/python/Tools/check/_functools.log similarity index 100% rename from tests/Tools/check/_functools.log rename to tests/python/Tools/check/_functools.log diff --git a/tests/Tools/cleantests.py b/tests/python/Tools/cleantests.py similarity index 100% rename from tests/Tools/cleantests.py rename to tests/python/Tools/cleantests.py diff --git a/tests/Tools/clr_helpers.py b/tests/python/Tools/clr_helpers.py similarity index 100% rename from tests/Tools/clr_helpers.py rename to tests/python/Tools/clr_helpers.py diff --git a/tests/Tools/cmodule.py b/tests/python/Tools/cmodule.py similarity index 100% rename from tests/Tools/cmodule.py rename to tests/python/Tools/cmodule.py diff --git a/tests/Tools/cpy_tests.py b/tests/python/Tools/cpy_tests.py similarity index 100% rename from tests/Tools/cpy_tests.py rename to tests/python/Tools/cpy_tests.py diff --git a/tests/Tools/logmodule.py b/tests/python/Tools/logmodule.py similarity index 100% rename from tests/Tools/logmodule.py rename to tests/python/Tools/logmodule.py diff --git a/tests/Tools/modulediff.py b/tests/python/Tools/modulediff.py similarity index 100% rename from tests/Tools/modulediff.py rename to tests/python/Tools/modulediff.py diff --git a/tests/Tools/stdmodules.py b/tests/python/Tools/stdmodules.py similarity index 100% rename from tests/Tools/stdmodules.py rename to tests/python/Tools/stdmodules.py diff --git a/tests/_ctypes_test_linux32.pyd b/tests/python/_ctypes_test_linux32.pyd similarity index 100% rename from tests/_ctypes_test_linux32.pyd rename to tests/python/_ctypes_test_linux32.pyd diff --git a/tests/_ctypes_test_linux64.pyd b/tests/python/_ctypes_test_linux64.pyd similarity index 100% rename from tests/_ctypes_test_linux64.pyd rename to tests/python/_ctypes_test_linux64.pyd diff --git a/tests/_ctypes_test_win32.pyd b/tests/python/_ctypes_test_win32.pyd similarity index 100% rename from tests/_ctypes_test_win32.pyd rename to tests/python/_ctypes_test_win32.pyd diff --git a/tests/_ctypes_test_win64.pyd b/tests/python/_ctypes_test_win64.pyd similarity index 100% rename from tests/_ctypes_test_win64.pyd rename to tests/python/_ctypes_test_win64.pyd diff --git a/tests/badil.py b/tests/python/badil.py similarity index 100% rename from tests/badil.py rename to tests/python/badil.py diff --git a/tests/c1.cs b/tests/python/c1.cs similarity index 100% rename from tests/c1.cs rename to tests/python/c1.cs diff --git a/tests/c2.cs b/tests/python/c2.cs similarity index 100% rename from tests/c2.cs rename to tests/python/c2.cs diff --git a/tests/c3.cs b/tests/python/c3.cs similarity index 100% rename from tests/c3.cs rename to tests/python/c3.cs diff --git a/tests/c4.cs b/tests/python/c4.cs similarity index 100% rename from tests/c4.cs rename to tests/python/c4.cs diff --git a/tests/check_result.bat b/tests/python/check_result.bat similarity index 100% rename from tests/check_result.bat rename to tests/python/check_result.bat diff --git a/tests/compat/common.py b/tests/python/compat/common.py similarity index 100% rename from tests/compat/common.py rename to tests/python/compat/common.py diff --git a/tests/compat/rulediff.py b/tests/python/compat/rulediff.py similarity index 100% rename from tests/compat/rulediff.py rename to tests/python/compat/rulediff.py diff --git a/tests/compat/runsbs.py b/tests/python/compat/runsbs.py similarity index 100% rename from tests/compat/runsbs.py rename to tests/python/compat/runsbs.py diff --git a/tests/compat/sbs_builtin.py b/tests/python/compat/sbs_builtin.py similarity index 100% rename from tests/compat/sbs_builtin.py rename to tests/python/compat/sbs_builtin.py diff --git a/tests/compat/sbs_class_compare.py b/tests/python/compat/sbs_class_compare.py similarity index 100% rename from tests/compat/sbs_class_compare.py rename to tests/python/compat/sbs_class_compare.py diff --git a/tests/compat/sbs_exceptions/__init__.py b/tests/python/compat/sbs_exceptions/__init__.py similarity index 100% rename from tests/compat/sbs_exceptions/__init__.py rename to tests/python/compat/sbs_exceptions/__init__.py diff --git a/tests/compat/sbs_exceptions/define.py b/tests/python/compat/sbs_exceptions/define.py similarity index 100% rename from tests/compat/sbs_exceptions/define.py rename to tests/python/compat/sbs_exceptions/define.py diff --git a/tests/compat/sbs_exceptions/for_loop.py b/tests/python/compat/sbs_exceptions/for_loop.py similarity index 100% rename from tests/compat/sbs_exceptions/for_loop.py rename to tests/python/compat/sbs_exceptions/for_loop.py diff --git a/tests/compat/sbs_exceptions/if_false.py b/tests/python/compat/sbs_exceptions/if_false.py similarity index 100% rename from tests/compat/sbs_exceptions/if_false.py rename to tests/python/compat/sbs_exceptions/if_false.py diff --git a/tests/compat/sbs_exceptions/if_true.py b/tests/python/compat/sbs_exceptions/if_true.py similarity index 100% rename from tests/compat/sbs_exceptions/if_true.py rename to tests/python/compat/sbs_exceptions/if_true.py diff --git a/tests/compat/sbs_exceptions/shared.py b/tests/python/compat/sbs_exceptions/shared.py similarity index 100% rename from tests/compat/sbs_exceptions/shared.py rename to tests/python/compat/sbs_exceptions/shared.py diff --git a/tests/compat/sbs_exceptions/try_else.py b/tests/python/compat/sbs_exceptions/try_else.py similarity index 100% rename from tests/compat/sbs_exceptions/try_else.py rename to tests/python/compat/sbs_exceptions/try_else.py diff --git a/tests/compat/sbs_exceptions/try_except1.py b/tests/python/compat/sbs_exceptions/try_except1.py similarity index 100% rename from tests/compat/sbs_exceptions/try_except1.py rename to tests/python/compat/sbs_exceptions/try_except1.py diff --git a/tests/compat/sbs_exceptions/try_except2.py b/tests/python/compat/sbs_exceptions/try_except2.py similarity index 100% rename from tests/compat/sbs_exceptions/try_except2.py rename to tests/python/compat/sbs_exceptions/try_except2.py diff --git a/tests/compat/sbs_exceptions/try_except3.py b/tests/python/compat/sbs_exceptions/try_except3.py similarity index 100% rename from tests/compat/sbs_exceptions/try_except3.py rename to tests/python/compat/sbs_exceptions/try_except3.py diff --git a/tests/compat/sbs_exceptions/try_finally1.py b/tests/python/compat/sbs_exceptions/try_finally1.py similarity index 100% rename from tests/compat/sbs_exceptions/try_finally1.py rename to tests/python/compat/sbs_exceptions/try_finally1.py diff --git a/tests/compat/sbs_exceptions/try_finally2.py b/tests/python/compat/sbs_exceptions/try_finally2.py similarity index 100% rename from tests/compat/sbs_exceptions/try_finally2.py rename to tests/python/compat/sbs_exceptions/try_finally2.py diff --git a/tests/compat/sbs_exceptions/try_finally3.py b/tests/python/compat/sbs_exceptions/try_finally3.py similarity index 100% rename from tests/compat/sbs_exceptions/try_finally3.py rename to tests/python/compat/sbs_exceptions/try_finally3.py diff --git a/tests/compat/sbs_exceptions/while_loop.py b/tests/python/compat/sbs_exceptions/while_loop.py similarity index 100% rename from tests/compat/sbs_exceptions/while_loop.py rename to tests/python/compat/sbs_exceptions/while_loop.py diff --git a/tests/compat/sbs_func_args.py b/tests/python/compat/sbs_func_args.py similarity index 100% rename from tests/compat/sbs_func_args.py rename to tests/python/compat/sbs_func_args.py diff --git a/tests/compat/sbs_library.cs b/tests/python/compat/sbs_library.cs similarity index 100% rename from tests/compat/sbs_library.cs rename to tests/python/compat/sbs_library.cs diff --git a/tests/compat/sbs_newtype.py b/tests/python/compat/sbs_newtype.py similarity index 100% rename from tests/compat/sbs_newtype.py rename to tests/python/compat/sbs_newtype.py diff --git a/tests/compat/sbs_parse_string.py b/tests/python/compat/sbs_parse_string.py similarity index 100% rename from tests/compat/sbs_parse_string.py rename to tests/python/compat/sbs_parse_string.py diff --git a/tests/compat/sbs_simple_compare.py b/tests/python/compat/sbs_simple_compare.py similarity index 100% rename from tests/compat/sbs_simple_compare.py rename to tests/python/compat/sbs_simple_compare.py diff --git a/tests/compat/sbs_simple_ops.py b/tests/python/compat/sbs_simple_ops.py similarity index 100% rename from tests/compat/sbs_simple_ops.py rename to tests/python/compat/sbs_simple_ops.py diff --git a/tests/compat/sbs_true_division.py b/tests/python/compat/sbs_true_division.py similarity index 100% rename from tests/compat/sbs_true_division.py rename to tests/python/compat/sbs_true_division.py diff --git a/tests/compat/sbs_typeop.py b/tests/python/compat/sbs_typeop.py similarity index 100% rename from tests/compat/sbs_typeop.py rename to tests/python/compat/sbs_typeop.py diff --git a/tests/compat/testdata.py b/tests/python/compat/testdata.py similarity index 100% rename from tests/compat/testdata.py rename to tests/python/compat/testdata.py diff --git a/tests/custombuiltins.py b/tests/python/custombuiltins.py similarity index 100% rename from tests/custombuiltins.py rename to tests/python/custombuiltins.py diff --git a/tests/debugging/__init__.py b/tests/python/debugging/__init__.py similarity index 100% rename from tests/debugging/__init__.py rename to tests/python/debugging/__init__.py diff --git a/tests/debugging/mdbg_tool/__init__.py b/tests/python/debugging/mdbg_tool/__init__.py similarity index 100% rename from tests/debugging/mdbg_tool/__init__.py rename to tests/python/debugging/mdbg_tool/__init__.py diff --git a/tests/debugging/pdb_mod/__init__.py b/tests/python/debugging/pdb_mod/__init__.py similarity index 100% rename from tests/debugging/pdb_mod/__init__.py rename to tests/python/debugging/pdb_mod/__init__.py diff --git a/tests/debugging/vs/__init__.py b/tests/python/debugging/vs/__init__.py similarity index 100% rename from tests/debugging/vs/__init__.py rename to tests/python/debugging/vs/__init__.py diff --git a/tests/dllsite.py b/tests/python/dllsite.py similarity index 100% rename from tests/dllsite.py rename to tests/python/dllsite.py diff --git a/tests/dummy_module.py b/tests/python/dummy_module.py similarity index 100% rename from tests/dummy_module.py rename to tests/python/dummy_module.py diff --git a/tests/dynamic_sanity/dynamic_runner.bat b/tests/python/dynamic_sanity/dynamic_runner.bat similarity index 100% rename from tests/dynamic_sanity/dynamic_runner.bat rename to tests/python/dynamic_sanity/dynamic_runner.bat diff --git a/tests/dynamic_sanity/dynamic_sanity.cs b/tests/python/dynamic_sanity/dynamic_sanity.cs similarity index 100% rename from tests/dynamic_sanity/dynamic_sanity.cs rename to tests/python/dynamic_sanity/dynamic_sanity.cs diff --git a/tests/dynamic_sanity/mock.py b/tests/python/dynamic_sanity/mock.py similarity index 100% rename from tests/dynamic_sanity/mock.py rename to tests/python/dynamic_sanity/mock.py diff --git a/tests/encoded_files/bad_encoding_name.py b/tests/python/encoded_files/bad_encoding_name.py similarity index 100% rename from tests/encoded_files/bad_encoding_name.py rename to tests/python/encoded_files/bad_encoding_name.py diff --git a/tests/encoded_files/bad_latin1_bom.py b/tests/python/encoded_files/bad_latin1_bom.py similarity index 100% rename from tests/encoded_files/bad_latin1_bom.py rename to tests/python/encoded_files/bad_latin1_bom.py diff --git a/tests/encoded_files/bad_latin1_bom_decl.py b/tests/python/encoded_files/bad_latin1_bom_decl.py similarity index 100% rename from tests/encoded_files/bad_latin1_bom_decl.py rename to tests/python/encoded_files/bad_latin1_bom_decl.py diff --git a/tests/encoded_files/bad_latin1_nbsp.py b/tests/python/encoded_files/bad_latin1_nbsp.py similarity index 100% rename from tests/encoded_files/bad_latin1_nbsp.py rename to tests/python/encoded_files/bad_latin1_nbsp.py diff --git a/tests/encoded_files/bad_latin1_nodecl.py b/tests/python/encoded_files/bad_latin1_nodecl.py similarity index 100% rename from tests/encoded_files/bad_latin1_nodecl.py rename to tests/python/encoded_files/bad_latin1_nodecl.py diff --git a/tests/encoded_files/bad_utf8_bom_decl.py b/tests/python/encoded_files/bad_utf8_bom_decl.py similarity index 100% rename from tests/encoded_files/bad_utf8_bom_decl.py rename to tests/python/encoded_files/bad_utf8_bom_decl.py diff --git a/tests/encoded_files/cp1019.py b/tests/python/encoded_files/cp1019.py similarity index 100% rename from tests/encoded_files/cp1019.py rename to tests/python/encoded_files/cp1019.py diff --git a/tests/encoded_files/cp11334_bad.py b/tests/python/encoded_files/cp11334_bad.py similarity index 100% rename from tests/encoded_files/cp11334_bad.py rename to tests/python/encoded_files/cp11334_bad.py diff --git a/tests/encoded_files/cp11334_ok.py b/tests/python/encoded_files/cp11334_ok.py similarity index 100% rename from tests/encoded_files/cp11334_ok.py rename to tests/python/encoded_files/cp11334_ok.py diff --git a/tests/encoded_files/cp20472.py b/tests/python/encoded_files/cp20472.py similarity index 100% rename from tests/encoded_files/cp20472.py rename to tests/python/encoded_files/cp20472.py diff --git a/tests/encoded_files/ok_encoding_nonascii.py b/tests/python/encoded_files/ok_encoding_nonascii.py similarity index 100% rename from tests/encoded_files/ok_encoding_nonascii.py rename to tests/python/encoded_files/ok_encoding_nonascii.py diff --git a/tests/encoded_files/ok_encoding_whitespace.py b/tests/python/encoded_files/ok_encoding_whitespace.py similarity index 100% rename from tests/encoded_files/ok_encoding_whitespace.py rename to tests/python/encoded_files/ok_encoding_whitespace.py diff --git a/tests/file_with_BOM.txt b/tests/python/file_with_BOM.txt similarity index 88% rename from tests/file_with_BOM.txt rename to tests/python/file_with_BOM.txt index 41bc4eb86..e451428cd 100644 --- a/tests/file_with_BOM.txt +++ b/tests/python/file_with_BOM.txt @@ -1 +1 @@ -BÓM +BÓM diff --git a/tests/file_without_BOM.txt b/tests/python/file_without_BOM.txt similarity index 83% rename from tests/file_without_BOM.txt rename to tests/python/file_without_BOM.txt index 5835e0bf5..cae98f32b 100644 --- a/tests/file_without_BOM.txt +++ b/tests/python/file_without_BOM.txt @@ -1 +1 @@ -BÓM +BÓM diff --git a/tests/functions/test_signatures.py b/tests/python/functions/test_signatures.py similarity index 100% rename from tests/functions/test_signatures.py rename to tests/python/functions/test_signatures.py diff --git a/tests/gen_stdlib_test.py b/tests/python/gen_stdlib_test.py similarity index 100% rename from tests/gen_stdlib_test.py rename to tests/python/gen_stdlib_test.py diff --git a/tests/gh129.zip b/tests/python/gh129.zip similarity index 100% rename from tests/gh129.zip rename to tests/python/gh129.zip diff --git a/tests/harness.py b/tests/python/harness.py similarity index 100% rename from tests/harness.py rename to tests/python/harness.py diff --git a/tests/hosting/editor_svcs/test_errorlistener.py b/tests/python/hosting/editor_svcs/test_errorlistener.py similarity index 100% rename from tests/hosting/editor_svcs/test_errorlistener.py rename to tests/python/hosting/editor_svcs/test_errorlistener.py diff --git a/tests/hosting/editor_svcs/test_tokencategorizer.py b/tests/python/hosting/editor_svcs/test_tokencategorizer.py similarity index 100% rename from tests/hosting/editor_svcs/test_tokencategorizer.py rename to tests/python/hosting/editor_svcs/test_tokencategorizer.py diff --git a/tests/import_extant/_vendor/__init__.py b/tests/python/import_extant/_vendor/__init__.py similarity index 100% rename from tests/import_extant/_vendor/__init__.py rename to tests/python/import_extant/_vendor/__init__.py diff --git a/tests/import_extant/_vendor/packaging/__init__.py b/tests/python/import_extant/_vendor/packaging/__init__.py similarity index 100% rename from tests/import_extant/_vendor/packaging/__init__.py rename to tests/python/import_extant/_vendor/packaging/__init__.py diff --git a/tests/import_extant/_vendor/packaging/_structures.py b/tests/python/import_extant/_vendor/packaging/_structures.py similarity index 100% rename from tests/import_extant/_vendor/packaging/_structures.py rename to tests/python/import_extant/_vendor/packaging/_structures.py diff --git a/tests/import_extant/_vendor/packaging/version.py b/tests/python/import_extant/_vendor/packaging/version.py similarity index 100% rename from tests/import_extant/_vendor/packaging/version.py rename to tests/python/import_extant/_vendor/packaging/version.py diff --git a/tests/import_extant/extern/__init__.py b/tests/python/import_extant/extern/__init__.py similarity index 100% rename from tests/import_extant/extern/__init__.py rename to tests/python/import_extant/extern/__init__.py diff --git a/tests/interop/__init__.py b/tests/python/interop/__init__.py similarity index 100% rename from tests/interop/__init__.py rename to tests/python/interop/__init__.py diff --git a/tests/interop/com/apps/MultiOffice.py b/tests/python/interop/com/apps/MultiOffice.py similarity index 100% rename from tests/interop/com/apps/MultiOffice.py rename to tests/python/interop/com/apps/MultiOffice.py diff --git a/tests/interop/com/apps/adodb.py b/tests/python/interop/com/apps/adodb.py similarity index 100% rename from tests/interop/com/apps/adodb.py rename to tests/python/interop/com/apps/adodb.py diff --git a/tests/interop/com/apps/excel.py b/tests/python/interop/com/apps/excel.py similarity index 100% rename from tests/interop/com/apps/excel.py rename to tests/python/interop/com/apps/excel.py diff --git a/tests/interop/com/apps/scriptpw.py b/tests/python/interop/com/apps/scriptpw.py similarity index 100% rename from tests/interop/com/apps/scriptpw.py rename to tests/python/interop/com/apps/scriptpw.py diff --git a/tests/interop/com/apps/word.py b/tests/python/interop/com/apps/word.py similarity index 100% rename from tests/interop/com/apps/word.py rename to tests/python/interop/com/apps/word.py diff --git a/tests/interop/com/compat/__init__.py b/tests/python/interop/com/compat/__init__.py similarity index 100% rename from tests/interop/com/compat/__init__.py rename to tests/python/interop/com/compat/__init__.py diff --git a/tests/interop/com/compat/hw.py b/tests/python/interop/com/compat/hw.py similarity index 100% rename from tests/interop/com/compat/hw.py rename to tests/python/interop/com/compat/hw.py diff --git a/tests/interop/com/compat/hw_client.py b/tests/python/interop/com/compat/hw_client.py similarity index 100% rename from tests/interop/com/compat/hw_client.py rename to tests/python/interop/com/compat/hw_client.py diff --git a/tests/interop/com/dlrcomlib/DispEvents.py b/tests/python/interop/com/dlrcomlib/DispEvents.py similarity index 100% rename from tests/interop/com/dlrcomlib/DispEvents.py rename to tests/python/interop/com/dlrcomlib/DispEvents.py diff --git a/tests/interop/com/dlrcomlib/InOutParams.py b/tests/python/interop/com/dlrcomlib/InOutParams.py similarity index 100% rename from tests/interop/com/dlrcomlib/InOutParams.py rename to tests/python/interop/com/dlrcomlib/InOutParams.py diff --git a/tests/interop/com/dlrcomlib/MultipleParams.py b/tests/python/interop/com/dlrcomlib/MultipleParams.py similarity index 100% rename from tests/interop/com/dlrcomlib/MultipleParams.py rename to tests/python/interop/com/dlrcomlib/MultipleParams.py diff --git a/tests/interop/com/dlrcomlib/OptionalParams.py b/tests/python/interop/com/dlrcomlib/OptionalParams.py similarity index 100% rename from tests/interop/com/dlrcomlib/OptionalParams.py rename to tests/python/interop/com/dlrcomlib/OptionalParams.py diff --git a/tests/interop/com/dlrcomlib/OutParams.py b/tests/python/interop/com/dlrcomlib/OutParams.py similarity index 100% rename from tests/interop/com/dlrcomlib/OutParams.py rename to tests/python/interop/com/dlrcomlib/OutParams.py diff --git a/tests/interop/com/dlrcomlib/ReturnValues.py b/tests/python/interop/com/dlrcomlib/ReturnValues.py similarity index 100% rename from tests/interop/com/dlrcomlib/ReturnValues.py rename to tests/python/interop/com/dlrcomlib/ReturnValues.py diff --git a/tests/interop/com/dlrcomlib/SimpleErrors.py b/tests/python/interop/com/dlrcomlib/SimpleErrors.py similarity index 100% rename from tests/interop/com/dlrcomlib/SimpleErrors.py rename to tests/python/interop/com/dlrcomlib/SimpleErrors.py diff --git a/tests/interop/com/dlrcomlib/__init__.py b/tests/python/interop/com/dlrcomlib/__init__.py similarity index 100% rename from tests/interop/com/dlrcomlib/__init__.py rename to tests/python/interop/com/dlrcomlib/__init__.py diff --git a/tests/interop/com/dlrcomlib/dlrcomserver.py b/tests/python/interop/com/dlrcomlib/dlrcomserver.py similarity index 100% rename from tests/interop/com/dlrcomlib/dlrcomserver.py rename to tests/python/interop/com/dlrcomlib/dlrcomserver.py diff --git a/tests/interop/com/dlrcomlib/paramsinretval.py b/tests/python/interop/com/dlrcomlib/paramsinretval.py similarity index 100% rename from tests/interop/com/dlrcomlib/paramsinretval.py rename to tests/python/interop/com/dlrcomlib/paramsinretval.py diff --git a/tests/interop/com/dlrcomlib/properties.py b/tests/python/interop/com/dlrcomlib/properties.py similarity index 100% rename from tests/interop/com/dlrcomlib/properties.py rename to tests/python/interop/com/dlrcomlib/properties.py diff --git a/tests/interop/com/dlrcomlib/pytraits/__init__.py b/tests/python/interop/com/dlrcomlib/pytraits/__init__.py similarity index 100% rename from tests/interop/com/dlrcomlib/pytraits/__init__.py rename to tests/python/interop/com/dlrcomlib/pytraits/__init__.py diff --git a/tests/interop/com/dlrcomlib/pytraits/method.py b/tests/python/interop/com/dlrcomlib/pytraits/method.py similarity index 100% rename from tests/interop/com/dlrcomlib/pytraits/method.py rename to tests/python/interop/com/dlrcomlib/pytraits/method.py diff --git a/tests/interop/com/dlrcomlib/pytraits/obj.py b/tests/python/interop/com/dlrcomlib/pytraits/obj.py similarity index 100% rename from tests/interop/com/dlrcomlib/pytraits/obj.py rename to tests/python/interop/com/dlrcomlib/pytraits/obj.py diff --git a/tests/interop/com/dlrcomlib/pytraits/prop.py b/tests/python/interop/com/dlrcomlib/pytraits/prop.py similarity index 100% rename from tests/interop/com/dlrcomlib/pytraits/prop.py rename to tests/python/interop/com/dlrcomlib/pytraits/prop.py diff --git a/tests/interop/com/dlrcomlib/typelib.py b/tests/python/interop/com/dlrcomlib/typelib.py similarity index 100% rename from tests/interop/com/dlrcomlib/typelib.py rename to tests/python/interop/com/dlrcomlib/typelib.py diff --git a/tests/interop/net/derivation/test_ctor_override.py b/tests/python/interop/net/derivation/test_ctor_override.py similarity index 100% rename from tests/interop/net/derivation/test_ctor_override.py rename to tests/python/interop/net/derivation/test_ctor_override.py diff --git a/tests/interop/net/derivation/test_event_override.py b/tests/python/interop/net/derivation/test_event_override.py similarity index 100% rename from tests/interop/net/derivation/test_event_override.py rename to tests/python/interop/net/derivation/test_event_override.py diff --git a/tests/interop/net/derivation/test_method_override.py b/tests/python/interop/net/derivation/test_method_override.py similarity index 100% rename from tests/interop/net/derivation/test_method_override.py rename to tests/python/interop/net/derivation/test_method_override.py diff --git a/tests/interop/net/derivation/test_method_signature.py b/tests/python/interop/net/derivation/test_method_signature.py similarity index 100% rename from tests/interop/net/derivation/test_method_signature.py rename to tests/python/interop/net/derivation/test_method_signature.py diff --git a/tests/interop/net/derivation/test_property_override.py b/tests/python/interop/net/derivation/test_property_override.py similarity index 100% rename from tests/interop/net/derivation/test_property_override.py rename to tests/python/interop/net/derivation/test_property_override.py diff --git a/tests/interop/net/derivation/test_simplederive.py b/tests/python/interop/net/derivation/test_simplederive.py similarity index 100% rename from tests/interop/net/derivation/test_simplederive.py rename to tests/python/interop/net/derivation/test_simplederive.py diff --git a/tests/interop/net/derivation/test_special_method.py b/tests/python/interop/net/derivation/test_special_method.py similarity index 100% rename from tests/interop/net/derivation/test_special_method.py rename to tests/python/interop/net/derivation/test_special_method.py diff --git a/tests/interop/net/dynamic/test_dynamic_regressions.py b/tests/python/interop/net/dynamic/test_dynamic_regressions.py similarity index 100% rename from tests/interop/net/dynamic/test_dynamic_regressions.py rename to tests/python/interop/net/dynamic/test_dynamic_regressions.py diff --git a/tests/interop/net/event/test_delegate.py b/tests/python/interop/net/event/test_delegate.py similarity index 100% rename from tests/interop/net/event/test_delegate.py rename to tests/python/interop/net/event/test_delegate.py diff --git a/tests/interop/net/event/test_event.py b/tests/python/interop/net/event/test_event.py similarity index 100% rename from tests/interop/net/event/test_event.py rename to tests/python/interop/net/event/test_event.py diff --git a/tests/interop/net/field/test_field_misc.py b/tests/python/interop/net/field/test_field_misc.py similarity index 100% rename from tests/interop/net/field/test_field_misc.py rename to tests/python/interop/net/field/test_field_misc.py diff --git a/tests/interop/net/field/test_fields_inside_enum.py b/tests/python/interop/net/field/test_fields_inside_enum.py similarity index 100% rename from tests/interop/net/field/test_fields_inside_enum.py rename to tests/python/interop/net/field/test_fields_inside_enum.py diff --git a/tests/interop/net/field/test_initonly_fields.py b/tests/python/interop/net/field/test_initonly_fields.py similarity index 100% rename from tests/interop/net/field/test_initonly_fields.py rename to tests/python/interop/net/field/test_initonly_fields.py diff --git a/tests/interop/net/field/test_instance_fields.py b/tests/python/interop/net/field/test_instance_fields.py similarity index 100% rename from tests/interop/net/field/test_instance_fields.py rename to tests/python/interop/net/field/test_instance_fields.py diff --git a/tests/interop/net/field/test_literal_fields.py b/tests/python/interop/net/field/test_literal_fields.py similarity index 100% rename from tests/interop/net/field/test_literal_fields.py rename to tests/python/interop/net/field/test_literal_fields.py diff --git a/tests/interop/net/field/test_static_fields.py b/tests/python/interop/net/field/test_static_fields.py similarity index 100% rename from tests/interop/net/field/test_static_fields.py rename to tests/python/interop/net/field/test_static_fields.py diff --git a/tests/interop/net/loadorder/module.py b/tests/python/interop/net/loadorder/module.py similarity index 100% rename from tests/interop/net/loadorder/module.py rename to tests/python/interop/net/loadorder/module.py diff --git a/tests/interop/net/loadorder/t1a.py b/tests/python/interop/net/loadorder/t1a.py similarity index 100% rename from tests/interop/net/loadorder/t1a.py rename to tests/python/interop/net/loadorder/t1a.py diff --git a/tests/interop/net/loadorder/t1b.py b/tests/python/interop/net/loadorder/t1b.py similarity index 100% rename from tests/interop/net/loadorder/t1b.py rename to tests/python/interop/net/loadorder/t1b.py diff --git a/tests/interop/net/loadorder/t1c.py b/tests/python/interop/net/loadorder/t1c.py similarity index 100% rename from tests/interop/net/loadorder/t1c.py rename to tests/python/interop/net/loadorder/t1c.py diff --git a/tests/interop/net/loadorder/t1d.py b/tests/python/interop/net/loadorder/t1d.py similarity index 100% rename from tests/interop/net/loadorder/t1d.py rename to tests/python/interop/net/loadorder/t1d.py diff --git a/tests/interop/net/loadorder/t2a.py b/tests/python/interop/net/loadorder/t2a.py similarity index 100% rename from tests/interop/net/loadorder/t2a.py rename to tests/python/interop/net/loadorder/t2a.py diff --git a/tests/interop/net/loadorder/t2b.py b/tests/python/interop/net/loadorder/t2b.py similarity index 100% rename from tests/interop/net/loadorder/t2b.py rename to tests/python/interop/net/loadorder/t2b.py diff --git a/tests/interop/net/loadorder/t2c.py b/tests/python/interop/net/loadorder/t2c.py similarity index 100% rename from tests/interop/net/loadorder/t2c.py rename to tests/python/interop/net/loadorder/t2c.py diff --git a/tests/interop/net/loadorder/t2d.py b/tests/python/interop/net/loadorder/t2d.py similarity index 100% rename from tests/interop/net/loadorder/t2d.py rename to tests/python/interop/net/loadorder/t2d.py diff --git a/tests/interop/net/loadorder/t2e.py b/tests/python/interop/net/loadorder/t2e.py similarity index 100% rename from tests/interop/net/loadorder/t2e.py rename to tests/python/interop/net/loadorder/t2e.py diff --git a/tests/interop/net/loadorder/t2f.py b/tests/python/interop/net/loadorder/t2f.py similarity index 100% rename from tests/interop/net/loadorder/t2f.py rename to tests/python/interop/net/loadorder/t2f.py diff --git a/tests/interop/net/loadorder/t2g.py b/tests/python/interop/net/loadorder/t2g.py similarity index 100% rename from tests/interop/net/loadorder/t2g.py rename to tests/python/interop/net/loadorder/t2g.py diff --git a/tests/interop/net/loadorder/t2h.py b/tests/python/interop/net/loadorder/t2h.py similarity index 100% rename from tests/interop/net/loadorder/t2h.py rename to tests/python/interop/net/loadorder/t2h.py diff --git a/tests/interop/net/loadorder/t3a.py b/tests/python/interop/net/loadorder/t3a.py similarity index 100% rename from tests/interop/net/loadorder/t3a.py rename to tests/python/interop/net/loadorder/t3a.py diff --git a/tests/interop/net/loadorder/t3b.py b/tests/python/interop/net/loadorder/t3b.py similarity index 100% rename from tests/interop/net/loadorder/t3b.py rename to tests/python/interop/net/loadorder/t3b.py diff --git a/tests/interop/net/loadorder/t3c0.py b/tests/python/interop/net/loadorder/t3c0.py similarity index 100% rename from tests/interop/net/loadorder/t3c0.py rename to tests/python/interop/net/loadorder/t3c0.py diff --git a/tests/interop/net/loadorder/t3c1.py b/tests/python/interop/net/loadorder/t3c1.py similarity index 100% rename from tests/interop/net/loadorder/t3c1.py rename to tests/python/interop/net/loadorder/t3c1.py diff --git a/tests/interop/net/loadorder/t3c2.py b/tests/python/interop/net/loadorder/t3c2.py similarity index 100% rename from tests/interop/net/loadorder/t3c2.py rename to tests/python/interop/net/loadorder/t3c2.py diff --git a/tests/interop/net/loadorder/t3d.py b/tests/python/interop/net/loadorder/t3d.py similarity index 100% rename from tests/interop/net/loadorder/t3d.py rename to tests/python/interop/net/loadorder/t3d.py diff --git a/tests/interop/net/loadorder/t3e.py b/tests/python/interop/net/loadorder/t3e.py similarity index 100% rename from tests/interop/net/loadorder/t3e.py rename to tests/python/interop/net/loadorder/t3e.py diff --git a/tests/interop/net/loadorder/t3f.py b/tests/python/interop/net/loadorder/t3f.py similarity index 100% rename from tests/interop/net/loadorder/t3f.py rename to tests/python/interop/net/loadorder/t3f.py diff --git a/tests/interop/net/loadorder/t3g1.py b/tests/python/interop/net/loadorder/t3g1.py similarity index 100% rename from tests/interop/net/loadorder/t3g1.py rename to tests/python/interop/net/loadorder/t3g1.py diff --git a/tests/interop/net/loadorder/t3g2.py b/tests/python/interop/net/loadorder/t3g2.py similarity index 100% rename from tests/interop/net/loadorder/t3g2.py rename to tests/python/interop/net/loadorder/t3g2.py diff --git a/tests/interop/net/loadorder/t3h.py b/tests/python/interop/net/loadorder/t3h.py similarity index 100% rename from tests/interop/net/loadorder/t3h.py rename to tests/python/interop/net/loadorder/t3h.py diff --git a/tests/interop/net/loadorder/t3i.py b/tests/python/interop/net/loadorder/t3i.py similarity index 100% rename from tests/interop/net/loadorder/t3i.py rename to tests/python/interop/net/loadorder/t3i.py diff --git a/tests/interop/net/loadorder/t4a.py b/tests/python/interop/net/loadorder/t4a.py similarity index 100% rename from tests/interop/net/loadorder/t4a.py rename to tests/python/interop/net/loadorder/t4a.py diff --git a/tests/interop/net/loadorder/t4b.py b/tests/python/interop/net/loadorder/t4b.py similarity index 100% rename from tests/interop/net/loadorder/t4b.py rename to tests/python/interop/net/loadorder/t4b.py diff --git a/tests/interop/net/loadorder/t4c.py b/tests/python/interop/net/loadorder/t4c.py similarity index 100% rename from tests/interop/net/loadorder/t4c.py rename to tests/python/interop/net/loadorder/t4c.py diff --git a/tests/interop/net/loadorder/t5a.py b/tests/python/interop/net/loadorder/t5a.py similarity index 100% rename from tests/interop/net/loadorder/t5a.py rename to tests/python/interop/net/loadorder/t5a.py diff --git a/tests/interop/net/loadorder/t5b.py b/tests/python/interop/net/loadorder/t5b.py similarity index 100% rename from tests/interop/net/loadorder/t5b.py rename to tests/python/interop/net/loadorder/t5b.py diff --git a/tests/interop/net/loadorder/t5c1.py b/tests/python/interop/net/loadorder/t5c1.py similarity index 100% rename from tests/interop/net/loadorder/t5c1.py rename to tests/python/interop/net/loadorder/t5c1.py diff --git a/tests/interop/net/loadorder/t5c2.py b/tests/python/interop/net/loadorder/t5c2.py similarity index 100% rename from tests/interop/net/loadorder/t5c2.py rename to tests/python/interop/net/loadorder/t5c2.py diff --git a/tests/interop/net/loadorder/t6.py b/tests/python/interop/net/loadorder/t6.py similarity index 100% rename from tests/interop/net/loadorder/t6.py rename to tests/python/interop/net/loadorder/t6.py diff --git a/tests/interop/net/loadorder/t7a.py b/tests/python/interop/net/loadorder/t7a.py similarity index 100% rename from tests/interop/net/loadorder/t7a.py rename to tests/python/interop/net/loadorder/t7a.py diff --git a/tests/interop/net/loadorder/t7b.py b/tests/python/interop/net/loadorder/t7b.py similarity index 100% rename from tests/interop/net/loadorder/t7b.py rename to tests/python/interop/net/loadorder/t7b.py diff --git a/tests/interop/net/loadorder/t7c.py b/tests/python/interop/net/loadorder/t7c.py similarity index 100% rename from tests/interop/net/loadorder/t7c.py rename to tests/python/interop/net/loadorder/t7c.py diff --git a/tests/interop/net/loadorder/t7d.py b/tests/python/interop/net/loadorder/t7d.py similarity index 100% rename from tests/interop/net/loadorder/t7d.py rename to tests/python/interop/net/loadorder/t7d.py diff --git a/tests/interop/net/loadorder/t7e.py b/tests/python/interop/net/loadorder/t7e.py similarity index 100% rename from tests/interop/net/loadorder/t7e.py rename to tests/python/interop/net/loadorder/t7e.py diff --git a/tests/interop/net/loadorder/t7f.py b/tests/python/interop/net/loadorder/t7f.py similarity index 100% rename from tests/interop/net/loadorder/t7f.py rename to tests/python/interop/net/loadorder/t7f.py diff --git a/tests/interop/net/method/test_arguments.py b/tests/python/interop/net/method/test_arguments.py similarity index 100% rename from tests/interop/net/method/test_arguments.py rename to tests/python/interop/net/method/test_arguments.py diff --git a/tests/interop/net/method/test_op_explicit.py b/tests/python/interop/net/method/test_op_explicit.py similarity index 100% rename from tests/interop/net/method/test_op_explicit.py rename to tests/python/interop/net/method/test_op_explicit.py diff --git a/tests/interop/net/method/test_op_implicit.py b/tests/python/interop/net/method/test_op_implicit.py similarity index 100% rename from tests/interop/net/method/test_op_implicit.py rename to tests/python/interop/net/method/test_op_implicit.py diff --git a/tests/interop/net/method/test_operators.py b/tests/python/interop/net/method/test_operators.py similarity index 100% rename from tests/interop/net/method/test_operators.py rename to tests/python/interop/net/method/test_operators.py diff --git a/tests/interop/net/method/test_returnvalue.py b/tests/python/interop/net/method/test_returnvalue.py similarity index 100% rename from tests/interop/net/method/test_returnvalue.py rename to tests/python/interop/net/method/test_returnvalue.py diff --git a/tests/interop/net/property/test_indexercs.py b/tests/python/interop/net/property/test_indexercs.py similarity index 100% rename from tests/interop/net/property/test_indexercs.py rename to tests/python/interop/net/property/test_indexercs.py diff --git a/tests/interop/net/property/test_indexervb.py b/tests/python/interop/net/property/test_indexervb.py similarity index 100% rename from tests/interop/net/property/test_indexervb.py rename to tests/python/interop/net/property/test_indexervb.py diff --git a/tests/interop/net/property/test_property.py b/tests/python/interop/net/property/test_property.py similarity index 100% rename from tests/interop/net/property/test_property.py rename to tests/python/interop/net/property/test_property.py diff --git a/tests/interop/net/test_accessibility.py b/tests/python/interop/net/test_accessibility.py similarity index 100% rename from tests/interop/net/test_accessibility.py rename to tests/python/interop/net/test_accessibility.py diff --git a/tests/interop/net/test_dynamicobjectmodel.py b/tests/python/interop/net/test_dynamicobjectmodel.py similarity index 100% rename from tests/interop/net/test_dynamicobjectmodel.py rename to tests/python/interop/net/test_dynamicobjectmodel.py diff --git a/tests/interop/net/test_loadorder.py b/tests/python/interop/net/test_loadorder.py similarity index 100% rename from tests/interop/net/test_loadorder.py rename to tests/python/interop/net/test_loadorder.py diff --git a/tests/interop/net/type/test___clrtype.py b/tests/python/interop/net/type/test___clrtype.py similarity index 100% rename from tests/interop/net/type/test___clrtype.py rename to tests/python/interop/net/type/test___clrtype.py diff --git a/tests/interop/net/type/test_assembly.py b/tests/python/interop/net/type/test_assembly.py similarity index 100% rename from tests/interop/net/type/test_assembly.py rename to tests/python/interop/net/type/test_assembly.py diff --git a/tests/interop/net/type/test_clr_array.py b/tests/python/interop/net/type/test_clr_array.py similarity index 100% rename from tests/interop/net/type/test_clr_array.py rename to tests/python/interop/net/type/test_clr_array.py diff --git a/tests/interop/net/type/test_ctor.py b/tests/python/interop/net/type/test_ctor.py similarity index 100% rename from tests/interop/net/type/test_ctor.py rename to tests/python/interop/net/type/test_ctor.py diff --git a/tests/interop/net/type/test_defaultmember.py b/tests/python/interop/net/type/test_defaultmember.py similarity index 100% rename from tests/interop/net/type/test_defaultmember.py rename to tests/python/interop/net/type/test_defaultmember.py diff --git a/tests/interop/net/type/test_reachtype.py b/tests/python/interop/net/type/test_reachtype.py similarity index 100% rename from tests/interop/net/type/test_reachtype.py rename to tests/python/interop/net/type/test_reachtype.py diff --git a/tests/interop/net/versions/test_four_dot_zero.py b/tests/python/interop/net/versions/test_four_dot_zero.py similarity index 100% rename from tests/interop/net/versions/test_four_dot_zero.py rename to tests/python/interop/net/versions/test_four_dot_zero.py diff --git a/tests/modules/__init__.py b/tests/python/modules/__init__.py similarity index 100% rename from tests/modules/__init__.py rename to tests/python/modules/__init__.py diff --git a/tests/modules/io_related/test__bytesio.py b/tests/python/modules/io_related/test__bytesio.py similarity index 100% rename from tests/modules/io_related/test__bytesio.py rename to tests/python/modules/io_related/test__bytesio.py diff --git a/tests/modules/io_related/test__fileio.py b/tests/python/modules/io_related/test__fileio.py similarity index 100% rename from tests/modules/io_related/test__fileio.py rename to tests/python/modules/io_related/test__fileio.py diff --git a/tests/modules/io_related/test_binascii.py b/tests/python/modules/io_related/test_binascii.py similarity index 100% rename from tests/modules/io_related/test_binascii.py rename to tests/python/modules/io_related/test_binascii.py diff --git a/tests/modules/io_related/test_cPickle.py b/tests/python/modules/io_related/test_cPickle.py similarity index 100% rename from tests/modules/io_related/test_cPickle.py rename to tests/python/modules/io_related/test_cPickle.py diff --git a/tests/modules/io_related/test_codecs.py b/tests/python/modules/io_related/test_codecs.py similarity index 100% rename from tests/modules/io_related/test_codecs.py rename to tests/python/modules/io_related/test_codecs.py diff --git a/tests/modules/io_related/test_copyreg.py b/tests/python/modules/io_related/test_copyreg.py similarity index 100% rename from tests/modules/io_related/test_copyreg.py rename to tests/python/modules/io_related/test_copyreg.py diff --git a/tests/modules/io_related/test_fd.py b/tests/python/modules/io_related/test_fd.py similarity index 100% rename from tests/modules/io_related/test_fd.py rename to tests/python/modules/io_related/test_fd.py diff --git a/tests/modules/io_related/test_io_StringIO.py b/tests/python/modules/io_related/test_io_StringIO.py similarity index 100% rename from tests/modules/io_related/test_io_StringIO.py rename to tests/python/modules/io_related/test_io_StringIO.py diff --git a/tests/modules/io_related/test_marshal.py b/tests/python/modules/io_related/test_marshal.py similarity index 100% rename from tests/modules/io_related/test_marshal.py rename to tests/python/modules/io_related/test_marshal.py diff --git a/tests/modules/io_related/test_re.py b/tests/python/modules/io_related/test_re.py similarity index 100% rename from tests/modules/io_related/test_re.py rename to tests/python/modules/io_related/test_re.py diff --git a/tests/modules/misc/test__opcode.py b/tests/python/modules/misc/test__opcode.py similarity index 100% rename from tests/modules/misc/test__opcode.py rename to tests/python/modules/misc/test__opcode.py diff --git a/tests/modules/misc/test__random.py b/tests/python/modules/misc/test__random.py similarity index 100% rename from tests/modules/misc/test__random.py rename to tests/python/modules/misc/test__random.py diff --git a/tests/modules/misc/test__sha256.py b/tests/python/modules/misc/test__sha256.py similarity index 100% rename from tests/modules/misc/test__sha256.py rename to tests/python/modules/misc/test__sha256.py diff --git a/tests/modules/misc/test__sha512.py b/tests/python/modules/misc/test__sha512.py similarity index 100% rename from tests/modules/misc/test__sha512.py rename to tests/python/modules/misc/test__sha512.py diff --git a/tests/modules/misc/test__warnings.py b/tests/python/modules/misc/test__warnings.py similarity index 100% rename from tests/modules/misc/test__warnings.py rename to tests/python/modules/misc/test__warnings.py diff --git a/tests/modules/misc/test__weakref.py b/tests/python/modules/misc/test__weakref.py similarity index 100% rename from tests/modules/misc/test__weakref.py rename to tests/python/modules/misc/test__weakref.py diff --git a/tests/modules/misc/test_ctypes.py b/tests/python/modules/misc/test_ctypes.py similarity index 100% rename from tests/modules/misc/test_ctypes.py rename to tests/python/modules/misc/test_ctypes.py diff --git a/tests/modules/misc/test_datetime.py b/tests/python/modules/misc/test_datetime.py similarity index 100% rename from tests/modules/misc/test_datetime.py rename to tests/python/modules/misc/test_datetime.py diff --git a/tests/modules/misc/test_math.py b/tests/python/modules/misc/test_math.py similarity index 100% rename from tests/modules/misc/test_math.py rename to tests/python/modules/misc/test_math.py diff --git a/tests/modules/misc/test_operator.py b/tests/python/modules/misc/test_operator.py similarity index 100% rename from tests/modules/misc/test_operator.py rename to tests/python/modules/misc/test_operator.py diff --git a/tests/modules/misc/test_system_namespaces.py b/tests/python/modules/misc/test_system_namespaces.py similarity index 100% rename from tests/modules/misc/test_system_namespaces.py rename to tests/python/modules/misc/test_system_namespaces.py diff --git a/tests/modules/misc/test_zlib.py b/tests/python/modules/misc/test_zlib.py similarity index 100% rename from tests/modules/misc/test_zlib.py rename to tests/python/modules/misc/test_zlib.py diff --git a/tests/modules/network_related/__init__.py b/tests/python/modules/network_related/__init__.py similarity index 100% rename from tests/modules/network_related/__init__.py rename to tests/python/modules/network_related/__init__.py diff --git a/tests/modules/network_related/keycert.pem b/tests/python/modules/network_related/keycert.pem similarity index 100% rename from tests/modules/network_related/keycert.pem rename to tests/python/modules/network_related/keycert.pem diff --git a/tests/modules/network_related/test__socket.py b/tests/python/modules/network_related/test__socket.py similarity index 100% rename from tests/modules/network_related/test__socket.py rename to tests/python/modules/network_related/test__socket.py diff --git a/tests/modules/network_related/test__ssl.py b/tests/python/modules/network_related/test__ssl.py similarity index 100% rename from tests/modules/network_related/test__ssl.py rename to tests/python/modules/network_related/test__ssl.py diff --git a/tests/modules/system_related/__init__.py b/tests/python/modules/system_related/__init__.py similarity index 100% rename from tests/modules/system_related/__init__.py rename to tests/python/modules/system_related/__init__.py diff --git a/tests/modules/system_related/test__locale.py b/tests/python/modules/system_related/test__locale.py similarity index 100% rename from tests/modules/system_related/test__locale.py rename to tests/python/modules/system_related/test__locale.py diff --git a/tests/modules/system_related/test_errno.py b/tests/python/modules/system_related/test_errno.py similarity index 100% rename from tests/modules/system_related/test_errno.py rename to tests/python/modules/system_related/test_errno.py diff --git a/tests/modules/system_related/test_gc.py b/tests/python/modules/system_related/test_gc.py similarity index 100% rename from tests/modules/system_related/test_gc.py rename to tests/python/modules/system_related/test_gc.py diff --git a/tests/modules/system_related/test_nt.py b/tests/python/modules/system_related/test_nt.py similarity index 100% rename from tests/modules/system_related/test_nt.py rename to tests/python/modules/system_related/test_nt.py diff --git a/tests/modules/system_related/test_os.py b/tests/python/modules/system_related/test_os.py similarity index 100% rename from tests/modules/system_related/test_os.py rename to tests/python/modules/system_related/test_os.py diff --git a/tests/modules/system_related/test_resource.py b/tests/python/modules/system_related/test_resource.py similarity index 100% rename from tests/modules/system_related/test_resource.py rename to tests/python/modules/system_related/test_resource.py diff --git a/tests/modules/system_related/test_resource_stdlib.py b/tests/python/modules/system_related/test_resource_stdlib.py similarity index 100% rename from tests/modules/system_related/test_resource_stdlib.py rename to tests/python/modules/system_related/test_resource_stdlib.py diff --git a/tests/modules/system_related/test_signal.py b/tests/python/modules/system_related/test_signal.py similarity index 100% rename from tests/modules/system_related/test_signal.py rename to tests/python/modules/system_related/test_signal.py diff --git a/tests/modules/system_related/test_sys.py b/tests/python/modules/system_related/test_sys.py similarity index 100% rename from tests/modules/system_related/test_sys.py rename to tests/python/modules/system_related/test_sys.py diff --git a/tests/modules/system_related/test_sys_getframe.py b/tests/python/modules/system_related/test_sys_getframe.py similarity index 100% rename from tests/modules/system_related/test_sys_getframe.py rename to tests/python/modules/system_related/test_sys_getframe.py diff --git a/tests/modules/system_related/test_thread.py b/tests/python/modules/system_related/test_thread.py similarity index 100% rename from tests/modules/system_related/test_thread.py rename to tests/python/modules/system_related/test_thread.py diff --git a/tests/modules/system_related/test_time.py b/tests/python/modules/system_related/test_time.py similarity index 100% rename from tests/modules/system_related/test_time.py rename to tests/python/modules/system_related/test_time.py diff --git a/tests/modules/type_related/__init__.py b/tests/python/modules/type_related/__init__.py similarity index 100% rename from tests/modules/type_related/__init__.py rename to tests/python/modules/type_related/__init__.py diff --git a/tests/modules/type_related/test__struct.py b/tests/python/modules/type_related/test__struct.py similarity index 100% rename from tests/modules/type_related/test__struct.py rename to tests/python/modules/type_related/test__struct.py diff --git a/tests/modules/type_related/test_array.py b/tests/python/modules/type_related/test_array.py similarity index 100% rename from tests/modules/type_related/test_array.py rename to tests/python/modules/type_related/test_array.py diff --git a/tests/modules/type_related/test_bitfields_ctypes_stdlib.py b/tests/python/modules/type_related/test_bitfields_ctypes_stdlib.py similarity index 100% rename from tests/modules/type_related/test_bitfields_ctypes_stdlib.py rename to tests/python/modules/type_related/test_bitfields_ctypes_stdlib.py diff --git a/tests/modules/type_related/test_ctypes.py b/tests/python/modules/type_related/test_ctypes.py similarity index 100% rename from tests/modules/type_related/test_ctypes.py rename to tests/python/modules/type_related/test_ctypes.py diff --git a/tests/modules/type_related/test_types.py b/tests/python/modules/type_related/test_types.py similarity index 100% rename from tests/modules/type_related/test_types.py rename to tests/python/modules/type_related/test_types.py diff --git a/tests/perf_micro_calls.py b/tests/python/perf_micro_calls.py similarity index 100% rename from tests/perf_micro_calls.py rename to tests/python/perf_micro_calls.py diff --git a/tests/pickles/cp18666.pickle b/tests/python/pickles/cp18666.pickle similarity index 100% rename from tests/pickles/cp18666.pickle rename to tests/python/pickles/cp18666.pickle diff --git a/tests/plans/debugging.html b/tests/python/plans/debugging.html similarity index 100% rename from tests/plans/debugging.html rename to tests/python/plans/debugging.html diff --git a/tests/plans/debugging.mdbg_tool.html b/tests/python/plans/debugging.mdbg_tool.html similarity index 100% rename from tests/plans/debugging.mdbg_tool.html rename to tests/python/plans/debugging.mdbg_tool.html diff --git a/tests/plans/debugging.pdb_mod.html b/tests/python/plans/debugging.pdb_mod.html similarity index 100% rename from tests/plans/debugging.pdb_mod.html rename to tests/python/plans/debugging.pdb_mod.html diff --git a/tests/plans/debugging.vs.html b/tests/python/plans/debugging.vs.html similarity index 100% rename from tests/plans/debugging.vs.html rename to tests/python/plans/debugging.vs.html diff --git a/tests/plans/generic_plan_template.py b/tests/python/plans/generic_plan_template.py similarity index 100% rename from tests/plans/generic_plan_template.py rename to tests/python/plans/generic_plan_template.py diff --git a/tests/plans/interop.net.derivation.html b/tests/python/plans/interop.net.derivation.html similarity index 100% rename from tests/plans/interop.net.derivation.html rename to tests/python/plans/interop.net.derivation.html diff --git a/tests/plans/interop.net.derivation.test_ctor_override.html b/tests/python/plans/interop.net.derivation.test_ctor_override.html similarity index 100% rename from tests/plans/interop.net.derivation.test_ctor_override.html rename to tests/python/plans/interop.net.derivation.test_ctor_override.html diff --git a/tests/plans/interop.net.derivation.test_event_override.html b/tests/python/plans/interop.net.derivation.test_event_override.html similarity index 100% rename from tests/plans/interop.net.derivation.test_event_override.html rename to tests/python/plans/interop.net.derivation.test_event_override.html diff --git a/tests/plans/interop.net.derivation.test_method_override.html b/tests/python/plans/interop.net.derivation.test_method_override.html similarity index 100% rename from tests/plans/interop.net.derivation.test_method_override.html rename to tests/python/plans/interop.net.derivation.test_method_override.html diff --git a/tests/plans/interop.net.derivation.test_method_signature.html b/tests/python/plans/interop.net.derivation.test_method_signature.html similarity index 100% rename from tests/plans/interop.net.derivation.test_method_signature.html rename to tests/python/plans/interop.net.derivation.test_method_signature.html diff --git a/tests/plans/interop.net.derivation.test_property_override.html b/tests/python/plans/interop.net.derivation.test_property_override.html similarity index 100% rename from tests/plans/interop.net.derivation.test_property_override.html rename to tests/python/plans/interop.net.derivation.test_property_override.html diff --git a/tests/plans/interop.net.derivation.test_simplederive.html b/tests/python/plans/interop.net.derivation.test_simplederive.html similarity index 100% rename from tests/plans/interop.net.derivation.test_simplederive.html rename to tests/python/plans/interop.net.derivation.test_simplederive.html diff --git a/tests/plans/interop.net.derivation.test_special_method.html b/tests/python/plans/interop.net.derivation.test_special_method.html similarity index 100% rename from tests/plans/interop.net.derivation.test_special_method.html rename to tests/python/plans/interop.net.derivation.test_special_method.html diff --git a/tests/plans/interop.net.event.html b/tests/python/plans/interop.net.event.html similarity index 100% rename from tests/plans/interop.net.event.html rename to tests/python/plans/interop.net.event.html diff --git a/tests/plans/interop.net.event.test_delegate.html b/tests/python/plans/interop.net.event.test_delegate.html similarity index 100% rename from tests/plans/interop.net.event.test_delegate.html rename to tests/python/plans/interop.net.event.test_delegate.html diff --git a/tests/plans/interop.net.event.test_event.html b/tests/python/plans/interop.net.event.test_event.html similarity index 100% rename from tests/plans/interop.net.event.test_event.html rename to tests/python/plans/interop.net.event.test_event.html diff --git a/tests/plans/interop.net.field.html b/tests/python/plans/interop.net.field.html similarity index 100% rename from tests/plans/interop.net.field.html rename to tests/python/plans/interop.net.field.html diff --git a/tests/plans/interop.net.field.test_field_misc.html b/tests/python/plans/interop.net.field.test_field_misc.html similarity index 100% rename from tests/plans/interop.net.field.test_field_misc.html rename to tests/python/plans/interop.net.field.test_field_misc.html diff --git a/tests/plans/interop.net.field.test_fields_inside_enum.html b/tests/python/plans/interop.net.field.test_fields_inside_enum.html similarity index 100% rename from tests/plans/interop.net.field.test_fields_inside_enum.html rename to tests/python/plans/interop.net.field.test_fields_inside_enum.html diff --git a/tests/plans/interop.net.html b/tests/python/plans/interop.net.html similarity index 100% rename from tests/plans/interop.net.html rename to tests/python/plans/interop.net.html diff --git a/tests/plans/interop.net.insert_csharp.html b/tests/python/plans/interop.net.insert_csharp.html similarity index 100% rename from tests/plans/interop.net.insert_csharp.html rename to tests/python/plans/interop.net.insert_csharp.html diff --git a/tests/plans/interop.net.method.html b/tests/python/plans/interop.net.method.html similarity index 100% rename from tests/plans/interop.net.method.html rename to tests/python/plans/interop.net.method.html diff --git a/tests/plans/interop.net.method.test_arguments.html b/tests/python/plans/interop.net.method.test_arguments.html similarity index 100% rename from tests/plans/interop.net.method.test_arguments.html rename to tests/python/plans/interop.net.method.test_arguments.html diff --git a/tests/plans/interop.net.method.test_op_explicit.html b/tests/python/plans/interop.net.method.test_op_explicit.html similarity index 100% rename from tests/plans/interop.net.method.test_op_explicit.html rename to tests/python/plans/interop.net.method.test_op_explicit.html diff --git a/tests/plans/interop.net.method.test_op_implicit.html b/tests/python/plans/interop.net.method.test_op_implicit.html similarity index 100% rename from tests/plans/interop.net.method.test_op_implicit.html rename to tests/python/plans/interop.net.method.test_op_implicit.html diff --git a/tests/plans/interop.net.method.test_operators.html b/tests/python/plans/interop.net.method.test_operators.html similarity index 100% rename from tests/plans/interop.net.method.test_operators.html rename to tests/python/plans/interop.net.method.test_operators.html diff --git a/tests/plans/interop.net.method.test_returnvalue.html b/tests/python/plans/interop.net.method.test_returnvalue.html similarity index 100% rename from tests/plans/interop.net.method.test_returnvalue.html rename to tests/python/plans/interop.net.method.test_returnvalue.html diff --git a/tests/plans/interop.net.property.html b/tests/python/plans/interop.net.property.html similarity index 100% rename from tests/plans/interop.net.property.html rename to tests/python/plans/interop.net.property.html diff --git a/tests/plans/interop.net.property.test_indexercs.html b/tests/python/plans/interop.net.property.test_indexercs.html similarity index 100% rename from tests/plans/interop.net.property.test_indexercs.html rename to tests/python/plans/interop.net.property.test_indexercs.html diff --git a/tests/plans/interop.net.property.test_indexervb.html b/tests/python/plans/interop.net.property.test_indexervb.html similarity index 100% rename from tests/plans/interop.net.property.test_indexervb.html rename to tests/python/plans/interop.net.property.test_indexervb.html diff --git a/tests/plans/interop.net.property.test_property.html b/tests/python/plans/interop.net.property.test_property.html similarity index 100% rename from tests/plans/interop.net.property.test_property.html rename to tests/python/plans/interop.net.property.test_property.html diff --git a/tests/plans/interop.net.test_accessibility.html b/tests/python/plans/interop.net.test_accessibility.html similarity index 100% rename from tests/plans/interop.net.test_accessibility.html rename to tests/python/plans/interop.net.test_accessibility.html diff --git a/tests/plans/interop.net.test_dynamicobjectmodel.html b/tests/python/plans/interop.net.test_dynamicobjectmodel.html similarity index 100% rename from tests/plans/interop.net.test_dynamicobjectmodel.html rename to tests/python/plans/interop.net.test_dynamicobjectmodel.html diff --git a/tests/plans/interop.net.test_loadorder.html b/tests/python/plans/interop.net.test_loadorder.html similarity index 100% rename from tests/plans/interop.net.test_loadorder.html rename to tests/python/plans/interop.net.test_loadorder.html diff --git a/tests/plans/interop.net.type.html b/tests/python/plans/interop.net.type.html similarity index 100% rename from tests/plans/interop.net.type.html rename to tests/python/plans/interop.net.type.html diff --git a/tests/plans/interop.net.type.test_assembly.html b/tests/python/plans/interop.net.type.test_assembly.html similarity index 100% rename from tests/plans/interop.net.type.test_assembly.html rename to tests/python/plans/interop.net.type.test_assembly.html diff --git a/tests/plans/interop.net.type.test_clr_array.html b/tests/python/plans/interop.net.type.test_clr_array.html similarity index 100% rename from tests/plans/interop.net.type.test_clr_array.html rename to tests/python/plans/interop.net.type.test_clr_array.html diff --git a/tests/plans/interop.net.type.test_ctor.html b/tests/python/plans/interop.net.type.test_ctor.html similarity index 100% rename from tests/plans/interop.net.type.test_ctor.html rename to tests/python/plans/interop.net.type.test_ctor.html diff --git a/tests/plans/interop.net.type.test_defaultmember.html b/tests/python/plans/interop.net.type.test_defaultmember.html similarity index 100% rename from tests/plans/interop.net.type.test_defaultmember.html rename to tests/python/plans/interop.net.type.test_defaultmember.html diff --git a/tests/plans/interop.net.type.test_reachtype.html b/tests/python/plans/interop.net.type.test_reachtype.html similarity index 100% rename from tests/plans/interop.net.type.test_reachtype.html rename to tests/python/plans/interop.net.type.test_reachtype.html diff --git a/tests/pretest.py b/tests/python/pretest.py similarity index 100% rename from tests/pretest.py rename to tests/python/pretest.py diff --git a/tests/pyc/console_hw.py b/tests/python/pyc/console_hw.py similarity index 100% rename from tests/pyc/console_hw.py rename to tests/python/pyc/console_hw.py diff --git a/tests/pyc/console_hw_args.py b/tests/python/pyc/console_hw_args.py similarity index 100% rename from tests/pyc/console_hw_args.py rename to tests/python/pyc/console_hw_args.py diff --git a/tests/pyc/other_hw.py b/tests/python/pyc/other_hw.py similarity index 100% rename from tests/pyc/other_hw.py rename to tests/python/pyc/other_hw.py diff --git a/tests/pyc/pkg/__init__.py b/tests/python/pyc/pkg/__init__.py similarity index 100% rename from tests/pyc/pkg/__init__.py rename to tests/python/pyc/pkg/__init__.py diff --git a/tests/pyc/pkg/a.py b/tests/python/pyc/pkg/a.py similarity index 100% rename from tests/pyc/pkg/a.py rename to tests/python/pyc/pkg/a.py diff --git a/tests/pyc/pkg/b.py b/tests/python/pyc/pkg/b.py similarity index 100% rename from tests/pyc/pkg/b.py rename to tests/python/pyc/pkg/b.py diff --git a/tests/pyc/pycpkgtest.py b/tests/python/pyc/pycpkgtest.py similarity index 100% rename from tests/pyc/pycpkgtest.py rename to tests/python/pyc/pycpkgtest.py diff --git a/tests/pyc/stdmodules_ok.ps1 b/tests/python/pyc/stdmodules_ok.ps1 similarity index 100% rename from tests/pyc/stdmodules_ok.ps1 rename to tests/python/pyc/stdmodules_ok.ps1 diff --git a/tests/pyc/test_pyc.ps1 b/tests/python/pyc/test_pyc.ps1 similarity index 100% rename from tests/pyc/test_pyc.ps1 rename to tests/python/pyc/test_pyc.ps1 diff --git a/tests/pyc/winforms_hw.py b/tests/python/pyc/winforms_hw.py similarity index 100% rename from tests/pyc/winforms_hw.py rename to tests/python/pyc/winforms_hw.py diff --git a/tests/run.py b/tests/python/run.py similarity index 100% rename from tests/run.py rename to tests/python/run.py diff --git a/tests/run_transformed.bat b/tests/python/run_transformed.bat similarity index 100% rename from tests/run_transformed.bat rename to tests/python/run_transformed.bat diff --git a/tests/sample.txt.gz b/tests/python/sample.txt.gz similarity index 100% rename from tests/sample.txt.gz rename to tests/python/sample.txt.gz diff --git a/tests/specialcontext/Consoleless.ps1 b/tests/python/specialcontext/Consoleless.ps1 similarity index 100% rename from tests/specialcontext/Consoleless.ps1 rename to tests/python/specialcontext/Consoleless.ps1 diff --git a/tests/specialcontext/verify_ipyw.py b/tests/python/specialcontext/verify_ipyw.py similarity index 100% rename from tests/specialcontext/verify_ipyw.py rename to tests/python/specialcontext/verify_ipyw.py diff --git a/tests/stress/__init__.py b/tests/python/stress/__init__.py similarity index 100% rename from tests/stress/__init__.py rename to tests/python/stress/__init__.py diff --git a/tests/stress/bigimport1_test.py b/tests/python/stress/bigimport1_test.py similarity index 100% rename from tests/stress/bigimport1_test.py rename to tests/python/stress/bigimport1_test.py diff --git a/tests/test_array.py b/tests/python/test_array.py similarity index 100% rename from tests/test_array.py rename to tests/python/test_array.py diff --git a/tests/test_assert.py b/tests/python/test_assert.py similarity index 100% rename from tests/test_assert.py rename to tests/python/test_assert.py diff --git a/tests/test_ast.py b/tests/python/test_ast.py similarity index 100% rename from tests/test_ast.py rename to tests/python/test_ast.py diff --git a/tests/test_attr.py b/tests/python/test_attr.py similarity index 100% rename from tests/test_attr.py rename to tests/python/test_attr.py diff --git a/tests/test_attribute_customize.py b/tests/python/test_attribute_customize.py similarity index 100% rename from tests/test_attribute_customize.py rename to tests/python/test_attribute_customize.py diff --git a/tests/test_attrinjector.py b/tests/python/test_attrinjector.py similarity index 100% rename from tests/test_attrinjector.py rename to tests/python/test_attrinjector.py diff --git a/tests/test_bigint.py b/tests/python/test_bigint.py similarity index 100% rename from tests/test_bigint.py rename to tests/python/test_bigint.py diff --git a/tests/test_bool.py b/tests/python/test_bool.py similarity index 100% rename from tests/test_bool.py rename to tests/python/test_bool.py diff --git a/tests/test_builtin_stdlib.py b/tests/python/test_builtin_stdlib.py similarity index 100% rename from tests/test_builtin_stdlib.py rename to tests/python/test_builtin_stdlib.py diff --git a/tests/test_builtinfunc.py b/tests/python/test_builtinfunc.py similarity index 100% rename from tests/test_builtinfunc.py rename to tests/python/test_builtinfunc.py diff --git a/tests/test_bytes.py b/tests/python/test_bytes.py similarity index 100% rename from tests/test_bytes.py rename to tests/python/test_bytes.py diff --git a/tests/test_bz2.py b/tests/python/test_bz2.py similarity index 100% rename from tests/test_bz2.py rename to tests/python/test_bz2.py diff --git a/tests/test_bz2_stdlib.py b/tests/python/test_bz2_stdlib.py similarity index 100% rename from tests/test_bz2_stdlib.py rename to tests/python/test_bz2_stdlib.py diff --git a/tests/test_class.py b/tests/python/test_class.py similarity index 100% rename from tests/test_class.py rename to tests/python/test_class.py diff --git a/tests/test_class_stdlib.py b/tests/python/test_class_stdlib.py similarity index 100% rename from tests/test_class_stdlib.py rename to tests/python/test_class_stdlib.py diff --git a/tests/test_cliclass.py b/tests/python/test_cliclass.py similarity index 100% rename from tests/test_cliclass.py rename to tests/python/test_cliclass.py diff --git a/tests/test_closure.py b/tests/python/test_closure.py similarity index 100% rename from tests/test_closure.py rename to tests/python/test_closure.py diff --git a/tests/test_clrexception.py b/tests/python/test_clrexception.py similarity index 100% rename from tests/test_clrexception.py rename to tests/python/test_clrexception.py diff --git a/tests/test_clrload.py b/tests/python/test_clrload.py similarity index 100% rename from tests/test_clrload.py rename to tests/python/test_clrload.py diff --git a/tests/test_clrload2.py b/tests/python/test_clrload2.py similarity index 100% rename from tests/test_clrload2.py rename to tests/python/test_clrload2.py diff --git a/tests/test_clrnuminterop.py b/tests/python/test_clrnuminterop.py similarity index 100% rename from tests/test_clrnuminterop.py rename to tests/python/test_clrnuminterop.py diff --git a/tests/test_clrtype.py b/tests/python/test_clrtype.py similarity index 100% rename from tests/test_clrtype.py rename to tests/python/test_clrtype.py diff --git a/tests/test_clruse.py b/tests/python/test_clruse.py similarity index 100% rename from tests/test_clruse.py rename to tests/python/test_clruse.py diff --git a/tests/test_codeccallbacks_stdlib.py b/tests/python/test_codeccallbacks_stdlib.py similarity index 100% rename from tests/test_codeccallbacks_stdlib.py rename to tests/python/test_codeccallbacks_stdlib.py diff --git a/tests/test_codecs.py b/tests/python/test_codecs.py similarity index 100% rename from tests/test_codecs.py rename to tests/python/test_codecs.py diff --git a/tests/test_codecs_stdlib.py b/tests/python/test_codecs_stdlib.py similarity index 100% rename from tests/test_codecs_stdlib.py rename to tests/python/test_codecs_stdlib.py diff --git a/tests/test_compiler.py b/tests/python/test_compiler.py similarity index 100% rename from tests/test_compiler.py rename to tests/python/test_compiler.py diff --git a/tests/test_complex.py b/tests/python/test_complex.py similarity index 100% rename from tests/test_complex.py rename to tests/python/test_complex.py diff --git a/tests/test_complex_stdlib.py b/tests/python/test_complex_stdlib.py similarity index 100% rename from tests/test_complex_stdlib.py rename to tests/python/test_complex_stdlib.py diff --git a/tests/test_conditional.py b/tests/python/test_conditional.py similarity index 100% rename from tests/test_conditional.py rename to tests/python/test_conditional.py diff --git a/tests/test_data.gz b/tests/python/test_data.gz similarity index 100% rename from tests/test_data.gz rename to tests/python/test_data.gz diff --git a/tests/test_datetime.py b/tests/python/test_datetime.py similarity index 100% rename from tests/test_datetime.py rename to tests/python/test_datetime.py diff --git a/tests/test_datetime_stdlib.py b/tests/python/test_datetime_stdlib.py similarity index 100% rename from tests/test_datetime_stdlib.py rename to tests/python/test_datetime_stdlib.py diff --git a/tests/test_decimal.py b/tests/python/test_decimal.py similarity index 100% rename from tests/test_decimal.py rename to tests/python/test_decimal.py diff --git a/tests/test_decorator.py b/tests/python/test_decorator.py similarity index 100% rename from tests/test_decorator.py rename to tests/python/test_decorator.py diff --git a/tests/test_delegate.py b/tests/python/test_delegate.py similarity index 100% rename from tests/test_delegate.py rename to tests/python/test_delegate.py diff --git a/tests/test_deque.py b/tests/python/test_deque.py similarity index 100% rename from tests/test_deque.py rename to tests/python/test_deque.py diff --git a/tests/test_descr_stdlib.py b/tests/python/test_descr_stdlib.py similarity index 100% rename from tests/test_descr_stdlib.py rename to tests/python/test_descr_stdlib.py diff --git a/tests/test_dict.py b/tests/python/test_dict.py similarity index 100% rename from tests/test_dict.py rename to tests/python/test_dict.py diff --git a/tests/test_dict_stdlib.py b/tests/python/test_dict_stdlib.py similarity index 100% rename from tests/test_dict_stdlib.py rename to tests/python/test_dict_stdlib.py diff --git a/tests/test_dictcomp.py b/tests/python/test_dictcomp.py similarity index 100% rename from tests/test_dictcomp.py rename to tests/python/test_dictcomp.py diff --git a/tests/test_dllsite.py b/tests/python/test_dllsite.py similarity index 100% rename from tests/test_dllsite.py rename to tests/python/test_dllsite.py diff --git a/tests/test_dlrkwarg.py b/tests/python/test_dlrkwarg.py similarity index 100% rename from tests/test_dlrkwarg.py rename to tests/python/test_dlrkwarg.py diff --git a/tests/test_doc.py b/tests/python/test_doc.py similarity index 100% rename from tests/test_doc.py rename to tests/python/test_doc.py diff --git a/tests/test_enum.py b/tests/python/test_enum.py similarity index 100% rename from tests/test_enum.py rename to tests/python/test_enum.py diff --git a/tests/test_exceptions.py b/tests/python/test_exceptions.py similarity index 100% rename from tests/test_exceptions.py rename to tests/python/test_exceptions.py diff --git a/tests/test_exceptions_generated.py b/tests/python/test_exceptions_generated.py similarity index 100% rename from tests/test_exceptions_generated.py rename to tests/python/test_exceptions_generated.py diff --git a/tests/test_excinfo.py b/tests/python/test_excinfo.py similarity index 100% rename from tests/test_excinfo.py rename to tests/python/test_excinfo.py diff --git a/tests/test_exec.py b/tests/python/test_exec.py similarity index 100% rename from tests/test_exec.py rename to tests/python/test_exec.py diff --git a/tests/test_file.py b/tests/python/test_file.py similarity index 100% rename from tests/test_file.py rename to tests/python/test_file.py diff --git a/tests/test_float_stdlib.py b/tests/python/test_float_stdlib.py similarity index 100% rename from tests/test_float_stdlib.py rename to tests/python/test_float_stdlib.py diff --git a/tests/test_formatting.py b/tests/python/test_formatting.py similarity index 100% rename from tests/test_formatting.py rename to tests/python/test_formatting.py diff --git a/tests/test_function.py b/tests/python/test_function.py similarity index 100% rename from tests/test_function.py rename to tests/python/test_function.py diff --git a/tests/test_functools_stdlib.py b/tests/python/test_functools_stdlib.py similarity index 100% rename from tests/test_functools_stdlib.py rename to tests/python/test_functools_stdlib.py diff --git a/tests/test_fuzz_parser.py b/tests/python/test_fuzz_parser.py similarity index 100% rename from tests/test_fuzz_parser.py rename to tests/python/test_fuzz_parser.py diff --git a/tests/test_generator.py b/tests/python/test_generator.py similarity index 100% rename from tests/test_generator.py rename to tests/python/test_generator.py diff --git a/tests/test_generator_throw.py b/tests/python/test_generator_throw.py similarity index 100% rename from tests/test_generator_throw.py rename to tests/python/test_generator_throw.py diff --git a/tests/test_genericmeth.py b/tests/python/test_genericmeth.py similarity index 100% rename from tests/test_genericmeth.py rename to tests/python/test_genericmeth.py diff --git a/tests/test_hash.py b/tests/python/test_hash.py similarity index 100% rename from tests/test_hash.py rename to tests/python/test_hash.py diff --git a/tests/test_help.py b/tests/python/test_help.py similarity index 100% rename from tests/test_help.py rename to tests/python/test_help.py diff --git a/tests/test_httplib_stdlib.py b/tests/python/test_httplib_stdlib.py similarity index 100% rename from tests/test_httplib_stdlib.py rename to tests/python/test_httplib_stdlib.py diff --git a/tests/test_imp.py b/tests/python/test_imp.py similarity index 100% rename from tests/test_imp.py rename to tests/python/test_imp.py diff --git a/tests/test_importext.py b/tests/python/test_importext.py similarity index 100% rename from tests/test_importext.py rename to tests/python/test_importext.py diff --git a/tests/test_importpkg.py b/tests/python/test_importpkg.py similarity index 100% rename from tests/test_importpkg.py rename to tests/python/test_importpkg.py diff --git a/tests/test_in.py b/tests/python/test_in.py similarity index 100% rename from tests/test_in.py rename to tests/python/test_in.py diff --git a/tests/test_index.py b/tests/python/test_index.py similarity index 100% rename from tests/test_index.py rename to tests/python/test_index.py diff --git a/tests/test_inheritance.py b/tests/python/test_inheritance.py similarity index 100% rename from tests/test_inheritance.py rename to tests/python/test_inheritance.py diff --git a/tests/test_int.py b/tests/python/test_int.py similarity index 100% rename from tests/test_int.py rename to tests/python/test_int.py diff --git a/tests/test_interactive.py b/tests/python/test_interactive.py similarity index 100% rename from tests/test_interactive.py rename to tests/python/test_interactive.py diff --git a/tests/test_io.py b/tests/python/test_io.py similarity index 100% rename from tests/test_io.py rename to tests/python/test_io.py diff --git a/tests/test_io_stdlib.py b/tests/python/test_io_stdlib.py similarity index 100% rename from tests/test_io_stdlib.py rename to tests/python/test_io_stdlib.py diff --git a/tests/test_ipyc.py b/tests/python/test_ipyc.py similarity index 100% rename from tests/test_ipyc.py rename to tests/python/test_ipyc.py diff --git a/tests/test_ipye.py b/tests/python/test_ipye.py similarity index 100% rename from tests/test_ipye.py rename to tests/python/test_ipye.py diff --git a/tests/test_ironmath.py b/tests/python/test_ironmath.py similarity index 100% rename from tests/test_ironmath.py rename to tests/python/test_ironmath.py diff --git a/tests/test_is.py b/tests/python/test_is.py similarity index 100% rename from tests/test_is.py rename to tests/python/test_is.py diff --git a/tests/test_isinstance.py b/tests/python/test_isinstance.py similarity index 100% rename from tests/test_isinstance.py rename to tests/python/test_isinstance.py diff --git a/tests/test_isinstance2.py b/tests/python/test_isinstance2.py similarity index 100% rename from tests/test_isinstance2.py rename to tests/python/test_isinstance2.py diff --git a/tests/test_iterator.py b/tests/python/test_iterator.py similarity index 100% rename from tests/test_iterator.py rename to tests/python/test_iterator.py diff --git a/tests/test_iteratorlength.py b/tests/python/test_iteratorlength.py similarity index 100% rename from tests/test_iteratorlength.py rename to tests/python/test_iteratorlength.py diff --git a/tests/test_itertools_stdlib.py b/tests/python/test_itertools_stdlib.py similarity index 100% rename from tests/test_itertools_stdlib.py rename to tests/python/test_itertools_stdlib.py diff --git a/tests/test_json.py b/tests/python/test_json.py similarity index 100% rename from tests/test_json.py rename to tests/python/test_json.py diff --git a/tests/test_kwarg.py b/tests/python/test_kwarg.py similarity index 100% rename from tests/test_kwarg.py rename to tests/python/test_kwarg.py diff --git a/tests/test_list.py b/tests/python/test_list.py similarity index 100% rename from tests/test_list.py rename to tests/python/test_list.py diff --git a/tests/test_listcomp.py b/tests/python/test_listcomp.py similarity index 100% rename from tests/test_listcomp.py rename to tests/python/test_listcomp.py diff --git a/tests/test_long_stdlib.py b/tests/python/test_long_stdlib.py similarity index 100% rename from tests/test_long_stdlib.py rename to tests/python/test_long_stdlib.py diff --git a/tests/test_memory.py b/tests/python/test_memory.py similarity index 100% rename from tests/test_memory.py rename to tests/python/test_memory.py diff --git a/tests/test_memoryio_stdlib.py b/tests/python/test_memoryio_stdlib.py similarity index 100% rename from tests/test_memoryio_stdlib.py rename to tests/python/test_memoryio_stdlib.py diff --git a/tests/test_memoryview.py b/tests/python/test_memoryview.py similarity index 100% rename from tests/test_memoryview.py rename to tests/python/test_memoryview.py diff --git a/tests/test_metaclass.py b/tests/python/test_metaclass.py similarity index 100% rename from tests/test_metaclass.py rename to tests/python/test_metaclass.py diff --git a/tests/test_methodbinder1.py b/tests/python/test_methodbinder1.py similarity index 100% rename from tests/test_methodbinder1.py rename to tests/python/test_methodbinder1.py diff --git a/tests/test_methodbinder2.py b/tests/python/test_methodbinder2.py similarity index 100% rename from tests/test_methodbinder2.py rename to tests/python/test_methodbinder2.py diff --git a/tests/test_methoddispatch.py b/tests/python/test_methoddispatch.py similarity index 100% rename from tests/test_methoddispatch.py rename to tests/python/test_methoddispatch.py diff --git a/tests/test_missing.py b/tests/python/test_missing.py similarity index 100% rename from tests/test_missing.py rename to tests/python/test_missing.py diff --git a/tests/test_namebinding.py b/tests/python/test_namebinding.py similarity index 100% rename from tests/test_namebinding.py rename to tests/python/test_namebinding.py diff --git a/tests/test_nonetype.py b/tests/python/test_nonetype.py similarity index 100% rename from tests/test_nonetype.py rename to tests/python/test_nonetype.py diff --git a/tests/test_nonlocal.py b/tests/python/test_nonlocal.py similarity index 100% rename from tests/test_nonlocal.py rename to tests/python/test_nonlocal.py diff --git a/tests/test_number.py b/tests/python/test_number.py similarity index 100% rename from tests/test_number.py rename to tests/python/test_number.py diff --git a/tests/test_numberhash.py b/tests/python/test_numberhash.py similarity index 100% rename from tests/test_numberhash.py rename to tests/python/test_numberhash.py diff --git a/tests/test_numtypes.py b/tests/python/test_numtypes.py similarity index 100% rename from tests/test_numtypes.py rename to tests/python/test_numtypes.py diff --git a/tests/test_pep380_stdlib.py b/tests/python/test_pep380_stdlib.py similarity index 100% rename from tests/test_pep380_stdlib.py rename to tests/python/test_pep380_stdlib.py diff --git a/tests/test_peverify.py b/tests/python/test_peverify.py similarity index 100% rename from tests/test_peverify.py rename to tests/python/test_peverify.py diff --git a/tests/test_pow.py b/tests/python/test_pow.py similarity index 100% rename from tests/test_pow.py rename to tests/python/test_pow.py diff --git a/tests/test_privateBinding.py b/tests/python/test_privateBinding.py similarity index 100% rename from tests/test_privateBinding.py rename to tests/python/test_privateBinding.py diff --git a/tests/test_property.py b/tests/python/test_property.py similarity index 100% rename from tests/test_property.py rename to tests/python/test_property.py diff --git a/tests/test_protected.py b/tests/python/test_protected.py similarity index 100% rename from tests/test_protected.py rename to tests/python/test_protected.py diff --git a/tests/test_pyexpat.py b/tests/python/test_pyexpat.py similarity index 100% rename from tests/test_pyexpat.py rename to tests/python/test_pyexpat.py diff --git a/tests/test_python25.py b/tests/python/test_python25.py similarity index 100% rename from tests/test_python25.py rename to tests/python/test_python25.py diff --git a/tests/test_python26.py b/tests/python/test_python26.py similarity index 100% rename from tests/test_python26.py rename to tests/python/test_python26.py diff --git a/tests/test_range.py b/tests/python/test_range.py similarity index 100% rename from tests/test_range.py rename to tests/python/test_range.py diff --git a/tests/test_re_stdlib.py b/tests/python/test_re_stdlib.py similarity index 100% rename from tests/test_re_stdlib.py rename to tests/python/test_re_stdlib.py diff --git a/tests/test_regressions.py b/tests/python/test_regressions.py similarity index 100% rename from tests/test_regressions.py rename to tests/python/test_regressions.py diff --git a/tests/test_regressions_compiled.py b/tests/python/test_regressions_compiled.py similarity index 100% rename from tests/test_regressions_compiled.py rename to tests/python/test_regressions_compiled.py diff --git a/tests/test_sax_stdlib.py b/tests/python/test_sax_stdlib.py similarity index 100% rename from tests/test_sax_stdlib.py rename to tests/python/test_sax_stdlib.py diff --git a/tests/test_scope_stdlib.py b/tests/python/test_scope_stdlib.py similarity index 100% rename from tests/test_scope_stdlib.py rename to tests/python/test_scope_stdlib.py diff --git a/tests/test_set.py b/tests/python/test_set.py similarity index 100% rename from tests/test_set.py rename to tests/python/test_set.py diff --git a/tests/test_setcomp.py b/tests/python/test_setcomp.py similarity index 100% rename from tests/test_setcomp.py rename to tests/python/test_setcomp.py diff --git a/tests/test_shutil.py b/tests/python/test_shutil.py similarity index 100% rename from tests/test_shutil.py rename to tests/python/test_shutil.py diff --git a/tests/test_slice.py b/tests/python/test_slice.py similarity index 100% rename from tests/test_slice.py rename to tests/python/test_slice.py diff --git a/tests/test_slots.py b/tests/python/test_slots.py similarity index 100% rename from tests/test_slots.py rename to tests/python/test_slots.py diff --git a/tests/test_socket_stdlib.py b/tests/python/test_socket_stdlib.py similarity index 100% rename from tests/test_socket_stdlib.py rename to tests/python/test_socket_stdlib.py diff --git a/tests/test_specialcontext.py b/tests/python/test_specialcontext.py similarity index 100% rename from tests/test_specialcontext.py rename to tests/python/test_specialcontext.py diff --git a/tests/test_sqlite3_stdlib.py b/tests/python/test_sqlite3_stdlib.py similarity index 100% rename from tests/test_sqlite3_stdlib.py rename to tests/python/test_sqlite3_stdlib.py diff --git a/tests/test_ssl_stdlib.py b/tests/python/test_ssl_stdlib.py similarity index 100% rename from tests/test_ssl_stdlib.py rename to tests/python/test_ssl_stdlib.py diff --git a/tests/test_statics.py b/tests/python/test_statics.py similarity index 100% rename from tests/test_statics.py rename to tests/python/test_statics.py diff --git a/tests/test_stdconsole.py b/tests/python/test_stdconsole.py similarity index 100% rename from tests/test_stdconsole.py rename to tests/python/test_stdconsole.py diff --git a/tests/test_stdmodules.py b/tests/python/test_stdmodules.py similarity index 100% rename from tests/test_stdmodules.py rename to tests/python/test_stdmodules.py diff --git a/tests/test_str.py b/tests/python/test_str.py similarity index 100% rename from tests/test_str.py rename to tests/python/test_str.py diff --git a/tests/test_str_bytes.py b/tests/python/test_str_bytes.py similarity index 100% rename from tests/test_str_bytes.py rename to tests/python/test_str_bytes.py diff --git a/tests/test_strformat.py b/tests/python/test_strformat.py similarity index 100% rename from tests/test_strformat.py rename to tests/python/test_strformat.py diff --git a/tests/test_struct.py b/tests/python/test_struct.py similarity index 100% rename from tests/test_struct.py rename to tests/python/test_struct.py diff --git a/tests/test_struct_stdlib.py b/tests/python/test_struct_stdlib.py similarity index 100% rename from tests/test_struct_stdlib.py rename to tests/python/test_struct_stdlib.py diff --git a/tests/test_struct_threadsafe.py b/tests/python/test_struct_threadsafe.py similarity index 100% rename from tests/test_struct_threadsafe.py rename to tests/python/test_struct_threadsafe.py diff --git a/tests/test_super.py b/tests/python/test_super.py similarity index 100% rename from tests/test_super.py rename to tests/python/test_super.py diff --git a/tests/test_superconsole.py b/tests/python/test_superconsole.py similarity index 100% rename from tests/test_superconsole.py rename to tests/python/test_superconsole.py diff --git a/tests/test_surrogateescape.py b/tests/python/test_surrogateescape.py similarity index 100% rename from tests/test_surrogateescape.py rename to tests/python/test_surrogateescape.py diff --git a/tests/test_surrogateescape_pythonfuture.py b/tests/python/test_surrogateescape_pythonfuture.py similarity index 100% rename from tests/test_surrogateescape_pythonfuture.py rename to tests/python/test_surrogateescape_pythonfuture.py diff --git a/tests/test_surrogatepass.py b/tests/python/test_surrogatepass.py similarity index 100% rename from tests/test_surrogatepass.py rename to tests/python/test_surrogatepass.py diff --git a/tests/test_syntax.py b/tests/python/test_syntax.py similarity index 100% rename from tests/test_syntax.py rename to tests/python/test_syntax.py diff --git a/tests/test_sys_stdlib.py b/tests/python/test_sys_stdlib.py similarity index 100% rename from tests/test_sys_stdlib.py rename to tests/python/test_sys_stdlib.py diff --git a/tests/test_system_timers.py b/tests/python/test_system_timers.py similarity index 100% rename from tests/test_system_timers.py rename to tests/python/test_system_timers.py diff --git a/tests/test_tcf.py b/tests/python/test_tcf.py similarity index 100% rename from tests/test_tcf.py rename to tests/python/test_tcf.py diff --git a/tests/test_threadsafety.py b/tests/python/test_threadsafety.py similarity index 100% rename from tests/test_threadsafety.py rename to tests/python/test_threadsafety.py diff --git a/tests/test_time_stdlib.py b/tests/python/test_time_stdlib.py similarity index 100% rename from tests/test_time_stdlib.py rename to tests/python/test_time_stdlib.py diff --git a/tests/test_traceback.py b/tests/python/test_traceback.py similarity index 100% rename from tests/test_traceback.py rename to tests/python/test_traceback.py diff --git a/tests/test_tuple.py b/tests/python/test_tuple.py similarity index 100% rename from tests/test_tuple.py rename to tests/python/test_tuple.py diff --git a/tests/test_types_stdlib.py b/tests/python/test_types_stdlib.py similarity index 100% rename from tests/test_types_stdlib.py rename to tests/python/test_types_stdlib.py diff --git a/tests/test_typing_stdlib.py b/tests/python/test_typing_stdlib.py similarity index 100% rename from tests/test_typing_stdlib.py rename to tests/python/test_typing_stdlib.py diff --git a/tests/test_unicode.py b/tests/python/test_unicode.py similarity index 100% rename from tests/test_unicode.py rename to tests/python/test_unicode.py diff --git a/tests/test_unicode_stdlib.py b/tests/python/test_unicode_stdlib.py similarity index 100% rename from tests/test_unicode_stdlib.py rename to tests/python/test_unicode_stdlib.py diff --git a/tests/test_unpack.py b/tests/python/test_unpack.py similarity index 100% rename from tests/test_unpack.py rename to tests/python/test_unpack.py diff --git a/tests/test_utf8_mode_stdlib.py b/tests/python/test_utf8_mode_stdlib.py similarity index 100% rename from tests/test_utf8_mode_stdlib.py rename to tests/python/test_utf8_mode_stdlib.py diff --git a/tests/test_weakref.py b/tests/python/test_weakref.py similarity index 100% rename from tests/test_weakref.py rename to tests/python/test_weakref.py diff --git a/tests/test_weakset_stdlib.py b/tests/python/test_weakset_stdlib.py similarity index 100% rename from tests/test_weakset_stdlib.py rename to tests/python/test_weakset_stdlib.py diff --git a/tests/test_winforms.py b/tests/python/test_winforms.py similarity index 100% rename from tests/test_winforms.py rename to tests/python/test_winforms.py diff --git a/tests/test_with.py b/tests/python/test_with.py similarity index 100% rename from tests/test_with.py rename to tests/python/test_with.py diff --git a/tests/test_zipimport.py b/tests/python/test_zipimport.py similarity index 100% rename from tests/test_zipimport.py rename to tests/python/test_zipimport.py diff --git a/tests/testpkg1/__init__.py b/tests/python/testpkg1/__init__.py similarity index 100% rename from tests/testpkg1/__init__.py rename to tests/python/testpkg1/__init__.py diff --git a/tests/testpkg1/mod1.py b/tests/python/testpkg1/mod1.py similarity index 100% rename from tests/testpkg1/mod1.py rename to tests/python/testpkg1/mod1.py diff --git a/tests/timeit.py b/tests/python/timeit.py similarity index 100% rename from tests/timeit.py rename to tests/python/timeit.py diff --git a/tests/toimport.py b/tests/python/toimport.py similarity index 100% rename from tests/toimport.py rename to tests/python/toimport.py diff --git a/tests/transform.py b/tests/python/transform.py similarity index 100% rename from tests/transform.py rename to tests/python/transform.py From 20fb46c30c092aa46982df35926175753fe73b09 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 17:42:07 +0000 Subject: [PATCH 19/84] Rename `DLR` to `runtime` to match structure of .NET Runtime --- .gitmodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 5c5b9f9ee..6db3ad2ca 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ -[submodule "src/DLR"] - path = src/DLR +[submodule "src/runtime"] + path = src/runtime url = https://github.com/IronLanguages/dlr branch = main From 6eb0a2ae452b5be5b04e83156e95501681ad7594 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 17:42:43 +0000 Subject: [PATCH 20/84] Remove DLR submodule --- src/DLR | 1 - 1 file changed, 1 deletion(-) delete mode 160000 src/DLR diff --git a/src/DLR b/src/DLR deleted file mode 160000 index fe26cf45d..000000000 --- a/src/DLR +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fe26cf45d383be65a56f0d4b964644eff89e01a8 From 679d995cba15cb1e68d778cf2f3454beaa2f29c2 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 17:43:17 +0000 Subject: [PATCH 21/84] Initialize DLR submodule --- src/runtime | 1 + 1 file changed, 1 insertion(+) create mode 160000 src/runtime diff --git a/src/runtime b/src/runtime new file mode 160000 index 000000000..fe26cf45d --- /dev/null +++ b/src/runtime @@ -0,0 +1 @@ +Subproject commit fe26cf45d383be65a56f0d4b964644eff89e01a8 From d26305994cc5a2140786bcedb98d4d039babbf2c Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 17:46:49 +0000 Subject: [PATCH 22/84] Add documentation for `src` directory --- src/README.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/README.md b/src/README.md index 3cea95b51..17c887849 100644 --- a/src/README.md +++ b/src/README.md @@ -1,14 +1,10 @@ # `src` -- `IronPython`: Core compiler and runtime (IronPython.dll) - -- `IronPython.Tests`: Targetted compiler and runtime unit tests hosted in a C# test harness. - -- `Scripts`: Infrastructure scripts and helpers. - -- `StdLib`: Python standard library imports. - -- `Tests`: Test suites. +- `console` IronPython console and conhost +- `extensions` IronPython tools including WPF, SQLite and others +- `ipy`: Core compiler and runtime (IronPython.dll) +- `roslyn`: IronPython roslyn analyzers +- `runtime`: The Dynamic Language Runtime Please see [the wiki](https://github.com/IronLanguages/ironpython3/wiki) for information on: From 488758d2e46f417c82929a39bcb214ed68b67c40 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 17:51:24 +0000 Subject: [PATCH 23/84] Document Roslyn analyzer directory --- src/roslyn/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/roslyn/README.md diff --git a/src/roslyn/README.md b/src/roslyn/README.md new file mode 100644 index 000000000..926a73245 --- /dev/null +++ b/src/roslyn/README.md @@ -0,0 +1,9 @@ +# `src/roslyn` + +This directory contains the IronPython Roslyn analyzer which allows for rich language analysis in using IronPython. + +- `IPY01`: Non-nullable reference type parameters should have the `NotNoneAttribute`. +- `IPY02`: Nullable reference type parameters should not have the `NotNoneAttribute`. +- `IPY03`: `BytesLikeAttribute` is only allowed on parameters of type `IReadOnlyList`, or `IList`. +- `IPY04`: To obtain a name of a python type of a given object to display to a user, use `PythonOps.GetPythonTypeName`. +- `IPY05`: `NotNullAttribute` is ambiguous between `System.Diagnostics.CodeAnalysis.NotNullAttribute` and `Microsoft.Scripting.Runtime.NotNullAttribute`. The latter should be accesses as `NotNoneAttribute`. From cb61876f8205dd94c19cc3b6f1abb009396d7755 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 17:56:47 +0000 Subject: [PATCH 24/84] Document extensions directory --- src/extensions/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/extensions/README.md diff --git a/src/extensions/README.md b/src/extensions/README.md new file mode 100644 index 000000000..dd3e9407c --- /dev/null +++ b/src/extensions/README.md @@ -0,0 +1,3 @@ +# `src/extensions` + +This directory contains various extensions to IronPython, including support for SQLite and the Windows Presentation Framework. From 90804c969ba8eadf44f6ee183ad838b37b9efc68 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 17:58:58 +0000 Subject: [PATCH 25/84] Document console directory --- src/console/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/console/README.md diff --git a/src/console/README.md b/src/console/README.md new file mode 100644 index 000000000..d8ca9f2de --- /dev/null +++ b/src/console/README.md @@ -0,0 +1,3 @@ +# `src/console` + +This directory contains various projects that make up the IronPython Console, including its 32-bit representations. From dcd182747b3d196db301edbae49e0eb86b92a2ef Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 18:00:26 +0000 Subject: [PATCH 26/84] Document IronPython directory --- src/ipy/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/ipy/README.md diff --git a/src/ipy/README.md b/src/ipy/README.md new file mode 100644 index 000000000..631c3d171 --- /dev/null +++ b/src/ipy/README.md @@ -0,0 +1,3 @@ +# `src/ipy` + +This directory contains the core IronPython code, including the compiler, Python modules, and also the core IronPython project assembly. From 966b0b23745bac9d3b7aed336ae8f9652cfdaa70 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 18:01:01 +0000 Subject: [PATCH 27/84] Update `src/README.md` --- src/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/README.md b/src/README.md index 17c887849..2b046dfb6 100644 --- a/src/README.md +++ b/src/README.md @@ -6,8 +6,10 @@ - `roslyn`: IronPython roslyn analyzers - `runtime`: The Dynamic Language Runtime +--- + Please see [the wiki](https://github.com/IronLanguages/ironpython3/wiki) for information on: - Setting up a development environment with easy access to utility scripts - Building -- Running test +- Running tests From 3d18b150764a57a64a350138ad9b6d4ac504a156 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 18:03:41 +0000 Subject: [PATCH 28/84] Document build directory --- eng/README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 eng/README.md diff --git a/eng/README.md b/eng/README.md new file mode 100644 index 000000000..4eeab23fb --- /dev/null +++ b/eng/README.md @@ -0,0 +1,4 @@ +# `eng` + +This directory contains MSBuild targets and project property files for building the app on different configurations that are consumed by the main `Build.proj` file in the root directory as well as the `make.ps1` script used to build the binaries in bulk. +This directory also contains packaging targets, exactly the same as the .NET Runtime repo. From d7fd8b04d0f1bfcb7452064b620e4058391efaac Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 18:06:54 +0000 Subject: [PATCH 29/84] Document tests directory --- tests/README.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/README.md diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 000000000..a25015fea --- /dev/null +++ b/tests/README.md @@ -0,0 +1,6 @@ +# `tests` + +This directory contains Python scripts and MSBuild-based testing projects (NUnit) that allow for testing IronPython in action with ease. + +- `ironpython`: NUnit framework testing project that allows for testing the library and compiler +- `python`: Various Python scripts used by the Azure CI to test the app with hundreds of Python modules From a1e6005fe26c54470c74c40c57116c9e17211ab7 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 18:07:21 +0000 Subject: [PATCH 30/84] Remove full-stop character from Roslyn analyzer documentation --- src/roslyn/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/roslyn/README.md b/src/roslyn/README.md index 926a73245..9d848538c 100644 --- a/src/roslyn/README.md +++ b/src/roslyn/README.md @@ -2,8 +2,8 @@ This directory contains the IronPython Roslyn analyzer which allows for rich language analysis in using IronPython. -- `IPY01`: Non-nullable reference type parameters should have the `NotNoneAttribute`. -- `IPY02`: Nullable reference type parameters should not have the `NotNoneAttribute`. -- `IPY03`: `BytesLikeAttribute` is only allowed on parameters of type `IReadOnlyList`, or `IList`. -- `IPY04`: To obtain a name of a python type of a given object to display to a user, use `PythonOps.GetPythonTypeName`. -- `IPY05`: `NotNullAttribute` is ambiguous between `System.Diagnostics.CodeAnalysis.NotNullAttribute` and `Microsoft.Scripting.Runtime.NotNullAttribute`. The latter should be accesses as `NotNoneAttribute`. +- `IPY01`: Non-nullable reference type parameters should have the `NotNoneAttribute` +- `IPY02`: Nullable reference type parameters should not have the `NotNoneAttribute` +- `IPY03`: `BytesLikeAttribute` is only allowed on parameters of type `IReadOnlyList`, or `IList` +- `IPY04`: To obtain a name of a python type of a given object to display to a user, use `PythonOps.GetPythonTypeName` +- `IPY05`: `NotNullAttribute` is ambiguous between `System.Diagnostics.CodeAnalysis.NotNullAttribute` and `Microsoft.Scripting.Runtime.NotNullAttribute`. The latter should be accesses as `NotNoneAttribute` From 0829c77404a2ab4107f7d20706ebd32a087a1cb1 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 18:18:16 +0000 Subject: [PATCH 31/84] Fix project references in solution --- IronPython.sln | 84 +++++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/IronPython.sln b/IronPython.sln index 9d9ace479..2dde29282 100644 --- a/IronPython.sln +++ b/IronPython.sln @@ -3,17 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.9.34714.143 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython", "Src\IronPython\IronPython.csproj", "{95289EA9-5778-489D-AB48-F81F2CE2DA32}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython", "src\ipy\IronPython\IronPython.csproj", "{95289EA9-5778-489D-AB48-F81F2CE2DA32}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Modules", "Src\Modules\IronPython.Modules.csproj", "{155CE436-1669-4A48-8095-410F2430237F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Modules", "src\ipy\IronPython.Modules\IronPython.Modules.csproj", "{155CE436-1669-4A48-8095-410F2430237F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Wpf", "Src\Wpf\IronPython.Wpf.csproj", "{65E997B7-E99B-4C83-B29E-9951429BB293}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Wpf", "src\extensions\IronPython.Wpf\IronPython.Wpf.csproj", "{65E997B7-E99B-4C83-B29E-9951429BB293}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console", "Src\Console\IronPython.Console.csproj", "{811AC32C-11F3-4ED8-92A7-A7E39C2BB704}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console", "src\console\IronPython.Console\IronPython.Console.csproj", "{811AC32C-11F3-4ED8-92A7-A7E39C2BB704}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Tests", "Src\Tests\IronPython.Tests.csproj", "{B6B42537-07F8-4F6C-A99A-B155CAEB124E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Tests", "tests\ironpython\IronPython.Tests.csproj", "{B6B42537-07F8-4F6C-A99A-B155CAEB124E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console.Host", "Src\Console.Host\IronPython.Console.Host.csproj", "{81DA19C7-4FEC-47E7-981B-D9310D549F95}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console.Host", "src\console\IronPython.Console.Host\IronPython.Console.Host.csproj", "{81DA19C7-4FEC-47E7-981B-D9310D549F95}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3A14D070-628F-44EF-92DD-47C8BE5C33CD}" ProjectSection(SolutionItems) = preProject @@ -29,82 +29,82 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{17737ACB-40C6-41A6-83DA-3203A4DCEC19}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "eng", "eng", "{17737ACB-40C6-41A6-83DA-3203A4DCEC19}" ProjectSection(SolutionItems) = preProject - Build\After.targets = Build\After.targets - Build\net462.props = Build\net462.props - Build\net6.0-windows.props = Build\net6.0-windows.props - Build\net6.0.props = Build\net6.0.props - Build\net8.0-windows.props = Build\net8.0-windows.props - Build\net8.0.props = Build\net8.0.props - Build\net9.0-windows.props = Build\net9.0-windows.props - Build\net9.0.props = Build\net9.0.props - Build\netcoreapp3.1.props = Build\netcoreapp3.1.props - Build\netstandard2.0.props = Build\netstandard2.0.props - Build\steps.yml = Build\steps.yml - Build\Tasks.Targets = Build\Tasks.Targets + eng\After.targets = eng\After.targets + eng\net462.props = eng\net462.props + eng\net6.0-windows.props = eng\net6.0-windows.props + eng\net6.0.props = eng\net6.0.props + eng\net8.0-windows.props = eng\net8.0-windows.props + eng\net8.0.props = eng\net8.0.props + eng\net9.0-windows.props = eng\net9.0-windows.props + eng\net9.0.props = eng\net9.0.props + eng\netcoreapp3.1.props = eng\netcoreapp3.1.props + eng\netstandard2.0.props = eng\netstandard2.0.props + eng\steps.yml = eng\steps.yml + eng\Tasks.Targets = eng\Tasks.Targets EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.CompilerServices", "Src\CompilerServices\IronPython.CompilerServices.csproj", "{3DFB096E-AC09-4E7A-9288-7F7C33C288C7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.CompilerServices", "src\ipy\IronPython.CompilerServices\IronPython.CompilerServices.csproj", "{3DFB096E-AC09-4E7A-9288-7F7C33C288C7}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DLR", "DLR", "{AC38EFB1-820D-4E90-BF40-BEF3AC825542}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Dynamic", "Src\DLR\Src\Microsoft.Dynamic\Microsoft.Dynamic.csproj", "{EB66B766-6354-4208-A3D4-AACBDCB5C3B3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Dynamic", "src\runtime\Src\Microsoft.Dynamic\Microsoft.Dynamic.csproj", "{EB66B766-6354-4208-A3D4-AACBDCB5C3B3}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Scripting", "Src\DLR\Src\Microsoft.Scripting\Microsoft.Scripting.csproj", "{02FF0909-F5AD-48CF-A86A-345E721B7E40}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Scripting", "src\runtime\Src\Microsoft.Scripting\Microsoft.Scripting.csproj", "{02FF0909-F5AD-48CF-A86A-345E721B7E40}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Scripting.Metadata", "Src\DLR\Src\Microsoft.Scripting.Metadata\Microsoft.Scripting.Metadata.csproj", "{ACDD9B9E-8FE6-439C-9521-1CCBA47F6143}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Scripting.Metadata", "src\runtime\Src\Microsoft.Scripting.Metadata\Microsoft.Scripting.Metadata.csproj", "{ACDD9B9E-8FE6-439C-9521-1CCBA47F6143}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{60836ADE-CAB7-4587-B6FB-8C4FEB872752}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClrAssembly", "Src\DLR\Tests\ClrAssembly\ClrAssembly.csproj", "{BEE737B9-18D5-48D9-8672-9A896213C98B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClrAssembly", "src\runtime\Tests\ClrAssembly\ClrAssembly.csproj", "{BEE737B9-18D5-48D9-8672-9A896213C98B}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Package", "Package", "{CE610DDE-D1DB-44D8-BAE9-BAAB00DA98F0}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Packaging", "Packaging", "{CE610DDE-D1DB-44D8-BAE9-BAAB00DA98F0}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nuget", "nuget", "{EE77D917-27F7-4E54-B72F-C8CEE4AEDCAA}" ProjectSection(SolutionItems) = preProject - Package\nuget\IronPython.nuspec = Package\nuget\IronPython.nuspec - Package\nuget\IronPython.StdLib.nuspec = Package\nuget\IronPython.StdLib.nuspec + eng\nuget\IronPython.nuspec = eng\nuget\IronPython.nuspec + eng\nuget\IronPython.StdLib.nuspec = eng\nuget\IronPython.StdLib.nuspec EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32", "Src\Console32\IronPython.Console32.csproj", "{AD21022F-E7C1-4B74-97C1-0A0E48EFF992}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32", "src\console\IronPython.Console32\IronPython.Console32.csproj", "{AD21022F-E7C1-4B74-97C1-0A0E48EFF992}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "choco", "choco", "{EA550FD8-2241-4131-8292-619D009E0199}" ProjectSection(SolutionItems) = preProject - Package\choco\Choco.Packaging.targets = Package\choco\Choco.Packaging.targets - Package\choco\IronPython.nuspec = Package\choco\IronPython.nuspec + eng\choco\Choco.Packaging.targets = eng\choco\Choco.Packaging.targets + eng\choco\IronPython.nuspec = eng\choco\IronPython.nuspec EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "pkg", "pkg", "{01CE1AE6-CD7F-491B-8150-58CD738B20AC}" ProjectSection(SolutionItems) = preProject - Package\pkg\Pkg.Packaging.targets = Package\pkg\Pkg.Packaging.targets + eng\pkg\Pkg.Packaging.targets = eng\pkg\Pkg.Packaging.targets EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "deb", "deb", "{676093FF-CB44-4BD5-B83C-A28FE88D5017}" ProjectSection(SolutionItems) = preProject - Package\deb\Deb.Packaging.targets = Package\deb\Deb.Packaging.targets + eng\deb\Deb.Packaging.targets = eng\deb\Deb.Packaging.targets EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "zip", "zip", "{8FC07B92-D2AC-4921-9E97-A92A84D2B461}" ProjectSection(SolutionItems) = preProject - Package\zip\Zip.Packaging.targets = Package\zip\Zip.Packaging.targets + eng\zip\Zip.Packaging.targets = eng\zip\Zip.Packaging.targets EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "msi", "msi", "{450F93D5-DF02-4C04-960B-AE7E454668AA}" ProjectSection(SolutionItems) = preProject - Package\msi\Dlr.wxs = Package\msi\Dlr.wxs - Package\msi\IronPython.Installer.wixproj = Package\msi\IronPython.Installer.wixproj - Package\msi\IronPython.wxs = Package\msi\IronPython.wxs - Package\msi\Msi.Packaging.targets = Package\msi\Msi.Packaging.targets - Package\msi\Product.wxs = Package\msi\Product.wxs - Package\msi\Version.wxi = Package\msi\Version.wxi + eng\msi\Dlr.wxs = eng\msi\Dlr.wxs + eng\msi\IronPython.Installer.wixproj = eng\msi\IronPython.Installer.wixproj + eng\msi\IronPython.wxs = eng\msi\IronPython.wxs + eng\msi\Msi.Packaging.targets = eng\msi\Msi.Packaging.targets + eng\msi\Product.wxs = eng\msi\Product.wxs + eng\msi\Version.wxi = eng\msi\Version.wxi EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32.Host", "Src\Console32.Host\IronPython.Console32.Host.csproj", "{8F177DC2-9822-45BD-AB05-1F40FCA86168}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32.Host", "src\console\IronPython.Console32.Host\IronPython.Console32.Host.csproj", "{8F177DC2-9822-45BD-AB05-1F40FCA86168}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronPython.DiagnosticAnalyzer", "DiagnosticAnalyzer\IronPython.DiagnosticAnalyzer.csproj", "{2DFE89D7-0C39-44E9-94CD-496CC985DFC3}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronPython.DiagnosticAnalyzer", "src\roslyn\IronPython.DiagnosticAnalyzer\IronPython.DiagnosticAnalyzer.csproj", "{2DFE89D7-0C39-44E9-94CD-496CC985DFC3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronPython.SQLite", "Src\SQLite\IronPython.SQLite.csproj", "{2F1071BF-891C-42A3-8A82-6B8A168BDE64}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronPython.SQLite", "src\extensions\IronPython.SQLite\IronPython.SQLite.csproj", "{2F1071BF-891C-42A3-8A82-6B8A168BDE64}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution From 573b14cd90e2ef56fccef6dcecdd686c16f5a431 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 18:18:37 +0000 Subject: [PATCH 32/84] Remove deleted ruleset file from solution --- IronPython.sln | 1 - 1 file changed, 1 deletion(-) diff --git a/IronPython.sln b/IronPython.sln index 2dde29282..ca3c902b0 100644 --- a/IronPython.sln +++ b/IronPython.sln @@ -22,7 +22,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Build.proj = Build.proj CurrentVersion.props = CurrentVersion.props Directory.Build.props = Directory.Build.props - IronPython.ruleset = IronPython.ruleset LICENSE = LICENSE make.ps1 = make.ps1 NuGet.config = NuGet.config From 1b9e47aa1e85a4c5d504d0b6d6ea5ee8e807ed7b Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 18:24:20 +0000 Subject: [PATCH 33/84] Make solution prettier --- IronPython.sln | 48 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/IronPython.sln b/IronPython.sln index ca3c902b0..8fe4806ab 100644 --- a/IronPython.sln +++ b/IronPython.sln @@ -15,7 +15,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Tests", "tests\i EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console.Host", "src\console\IronPython.Console.Host\IronPython.Console.Host.csproj", "{81DA19C7-4FEC-47E7-981B-D9310D549F95}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3A14D070-628F-44EF-92DD-47C8BE5C33CD}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{3A14D070-628F-44EF-92DD-47C8BE5C33CD}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig .gitignore = .gitignore @@ -46,7 +46,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "eng", "eng", "{17737ACB-40C EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.CompilerServices", "src\ipy\IronPython.CompilerServices\IronPython.CompilerServices.csproj", "{3DFB096E-AC09-4E7A-9288-7F7C33C288C7}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DLR", "DLR", "{AC38EFB1-820D-4E90-BF40-BEF3AC825542}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "runtime", "runtime", "{AC38EFB1-820D-4E90-BF40-BEF3AC825542}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Dynamic", "src\runtime\Src\Microsoft.Dynamic\Microsoft.Dynamic.csproj", "{EB66B766-6354-4208-A3D4-AACBDCB5C3B3}" EndProject @@ -58,8 +58,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{60836ADE EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClrAssembly", "src\runtime\Tests\ClrAssembly\ClrAssembly.csproj", "{BEE737B9-18D5-48D9-8672-9A896213C98B}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Packaging", "Packaging", "{CE610DDE-D1DB-44D8-BAE9-BAAB00DA98F0}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nuget", "nuget", "{EE77D917-27F7-4E54-B72F-C8CEE4AEDCAA}" ProjectSection(SolutionItems) = preProject eng\nuget\IronPython.nuspec = eng\nuget\IronPython.nuspec @@ -105,6 +103,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronPython.DiagnosticAnalyz EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronPython.SQLite", "src\extensions\IronPython.SQLite\IronPython.SQLite.csproj", "{2F1071BF-891C-42A3-8A82-6B8A168BDE64}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{18794F51-C0FB-4F30-AC4A-39BCE6937DD9}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "console", "console", "{9DC5996F-F2AB-41AA-9B17-C004CB3AB288}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ipy", "ipy", "{B8A5415F-9DF1-4BE3-AE4C-B3423764C6DC}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "extensions", "extensions", "{11738435-FAB8-4E7A-BCD8-0D5D53302181}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "roslyn", "roslyn", "{426817C8-2747-49E6-8060-245E05FFAEC0}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{26425961-0A4E-4CFA-9F45-9072AD6FA6F1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -176,19 +186,33 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {17737ACB-40C6-41A6-83DA-3203A4DCEC19} = {3A14D070-628F-44EF-92DD-47C8BE5C33CD} + {95289EA9-5778-489D-AB48-F81F2CE2DA32} = {B8A5415F-9DF1-4BE3-AE4C-B3423764C6DC} + {155CE436-1669-4A48-8095-410F2430237F} = {B8A5415F-9DF1-4BE3-AE4C-B3423764C6DC} + {65E997B7-E99B-4C83-B29E-9951429BB293} = {11738435-FAB8-4E7A-BCD8-0D5D53302181} + {811AC32C-11F3-4ED8-92A7-A7E39C2BB704} = {9DC5996F-F2AB-41AA-9B17-C004CB3AB288} + {B6B42537-07F8-4F6C-A99A-B155CAEB124E} = {26425961-0A4E-4CFA-9F45-9072AD6FA6F1} + {81DA19C7-4FEC-47E7-981B-D9310D549F95} = {9DC5996F-F2AB-41AA-9B17-C004CB3AB288} + {3DFB096E-AC09-4E7A-9288-7F7C33C288C7} = {B8A5415F-9DF1-4BE3-AE4C-B3423764C6DC} + {AC38EFB1-820D-4E90-BF40-BEF3AC825542} = {18794F51-C0FB-4F30-AC4A-39BCE6937DD9} {EB66B766-6354-4208-A3D4-AACBDCB5C3B3} = {AC38EFB1-820D-4E90-BF40-BEF3AC825542} {02FF0909-F5AD-48CF-A86A-345E721B7E40} = {AC38EFB1-820D-4E90-BF40-BEF3AC825542} {ACDD9B9E-8FE6-439C-9521-1CCBA47F6143} = {AC38EFB1-820D-4E90-BF40-BEF3AC825542} {60836ADE-CAB7-4587-B6FB-8C4FEB872752} = {AC38EFB1-820D-4E90-BF40-BEF3AC825542} {BEE737B9-18D5-48D9-8672-9A896213C98B} = {60836ADE-CAB7-4587-B6FB-8C4FEB872752} - {CE610DDE-D1DB-44D8-BAE9-BAAB00DA98F0} = {3A14D070-628F-44EF-92DD-47C8BE5C33CD} - {EE77D917-27F7-4E54-B72F-C8CEE4AEDCAA} = {CE610DDE-D1DB-44D8-BAE9-BAAB00DA98F0} - {EA550FD8-2241-4131-8292-619D009E0199} = {CE610DDE-D1DB-44D8-BAE9-BAAB00DA98F0} - {01CE1AE6-CD7F-491B-8150-58CD738B20AC} = {CE610DDE-D1DB-44D8-BAE9-BAAB00DA98F0} - {676093FF-CB44-4BD5-B83C-A28FE88D5017} = {CE610DDE-D1DB-44D8-BAE9-BAAB00DA98F0} - {8FC07B92-D2AC-4921-9E97-A92A84D2B461} = {CE610DDE-D1DB-44D8-BAE9-BAAB00DA98F0} - {450F93D5-DF02-4C04-960B-AE7E454668AA} = {CE610DDE-D1DB-44D8-BAE9-BAAB00DA98F0} + {EE77D917-27F7-4E54-B72F-C8CEE4AEDCAA} = {17737ACB-40C6-41A6-83DA-3203A4DCEC19} + {AD21022F-E7C1-4B74-97C1-0A0E48EFF992} = {9DC5996F-F2AB-41AA-9B17-C004CB3AB288} + {EA550FD8-2241-4131-8292-619D009E0199} = {17737ACB-40C6-41A6-83DA-3203A4DCEC19} + {01CE1AE6-CD7F-491B-8150-58CD738B20AC} = {17737ACB-40C6-41A6-83DA-3203A4DCEC19} + {676093FF-CB44-4BD5-B83C-A28FE88D5017} = {17737ACB-40C6-41A6-83DA-3203A4DCEC19} + {8FC07B92-D2AC-4921-9E97-A92A84D2B461} = {17737ACB-40C6-41A6-83DA-3203A4DCEC19} + {450F93D5-DF02-4C04-960B-AE7E454668AA} = {17737ACB-40C6-41A6-83DA-3203A4DCEC19} + {8F177DC2-9822-45BD-AB05-1F40FCA86168} = {9DC5996F-F2AB-41AA-9B17-C004CB3AB288} + {2DFE89D7-0C39-44E9-94CD-496CC985DFC3} = {426817C8-2747-49E6-8060-245E05FFAEC0} + {2F1071BF-891C-42A3-8A82-6B8A168BDE64} = {11738435-FAB8-4E7A-BCD8-0D5D53302181} + {9DC5996F-F2AB-41AA-9B17-C004CB3AB288} = {18794F51-C0FB-4F30-AC4A-39BCE6937DD9} + {B8A5415F-9DF1-4BE3-AE4C-B3423764C6DC} = {18794F51-C0FB-4F30-AC4A-39BCE6937DD9} + {11738435-FAB8-4E7A-BCD8-0D5D53302181} = {18794F51-C0FB-4F30-AC4A-39BCE6937DD9} + {426817C8-2747-49E6-8060-245E05FFAEC0} = {18794F51-C0FB-4F30-AC4A-39BCE6937DD9} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {981EA700-AB4F-462F-96D7-F35FAAAA7E89} From 6340581deeffdd371ed71a9c5459599c9ee29c09 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 18:34:31 +0000 Subject: [PATCH 34/84] Fix all project references attempt 1 --- .../IronPython.Console.Host.csproj | 2 +- .../IronPython.Console/IronPython.Console.csproj | 6 +++--- .../IronPython.Console32/IronPython.Console32.csproj | 8 ++++---- .../IronPython.SQLite/IronPython.SQLite.csproj | 6 +++--- src/extensions/IronPython.Wpf/IronPython.Wpf.csproj | 6 +++--- .../IronPython.CompilerServices.csproj | 4 ++-- src/ipy/IronPython.Modules/IronPython.Modules.csproj | 4 ++-- src/ipy/IronPython/IronPython.csproj | 10 +++++----- tests/ironpython/IronPython.Tests.csproj | 8 ++++---- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/console/IronPython.Console.Host/IronPython.Console.Host.csproj b/src/console/IronPython.Console.Host/IronPython.Console.Host.csproj index 536086341..5c01d2c9d 100644 --- a/src/console/IronPython.Console.Host/IronPython.Console.Host.csproj +++ b/src/console/IronPython.Console.Host/IronPython.Console.Host.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/console/IronPython.Console/IronPython.Console.csproj b/src/console/IronPython.Console/IronPython.Console.csproj index 1c8057427..02060e127 100644 --- a/src/console/IronPython.Console/IronPython.Console.csproj +++ b/src/console/IronPython.Console/IronPython.Console.csproj @@ -14,14 +14,14 @@ - - + + false Content PreserveNewest - + false Content PreserveNewest diff --git a/src/console/IronPython.Console32/IronPython.Console32.csproj b/src/console/IronPython.Console32/IronPython.Console32.csproj index 1dda10bf9..220d80735 100644 --- a/src/console/IronPython.Console32/IronPython.Console32.csproj +++ b/src/console/IronPython.Console32/IronPython.Console32.csproj @@ -11,15 +11,15 @@ - - + + false - - + + diff --git a/src/extensions/IronPython.SQLite/IronPython.SQLite.csproj b/src/extensions/IronPython.SQLite/IronPython.SQLite.csproj index 60466e71a..5d18e0c4c 100644 --- a/src/extensions/IronPython.SQLite/IronPython.SQLite.csproj +++ b/src/extensions/IronPython.SQLite/IronPython.SQLite.csproj @@ -24,9 +24,9 @@ - - - + + + diff --git a/src/extensions/IronPython.Wpf/IronPython.Wpf.csproj b/src/extensions/IronPython.Wpf/IronPython.Wpf.csproj index 97f2aebb6..4ba14fde3 100644 --- a/src/extensions/IronPython.Wpf/IronPython.Wpf.csproj +++ b/src/extensions/IronPython.Wpf/IronPython.Wpf.csproj @@ -13,9 +13,9 @@ - - - + + + diff --git a/src/ipy/IronPython.CompilerServices/IronPython.CompilerServices.csproj b/src/ipy/IronPython.CompilerServices/IronPython.CompilerServices.csproj index ffa1d0cb4..f0704e5b5 100644 --- a/src/ipy/IronPython.CompilerServices/IronPython.CompilerServices.csproj +++ b/src/ipy/IronPython.CompilerServices/IronPython.CompilerServices.csproj @@ -15,12 +15,12 @@ - + - ..\..\Util\References\IKVM\IKVM.Reflection.dll + ..\..\..\utils\References\IKVM\IKVM.Reflection.dll diff --git a/src/ipy/IronPython.Modules/IronPython.Modules.csproj b/src/ipy/IronPython.Modules/IronPython.Modules.csproj index 0f54dd0d0..e6baefc59 100644 --- a/src/ipy/IronPython.Modules/IronPython.Modules.csproj +++ b/src/ipy/IronPython.Modules/IronPython.Modules.csproj @@ -10,7 +10,7 @@ True - ..\..\Utils\References\Mono.Posix.dll + ..\..\..\utils\References\Mono.Posix.dll @@ -26,7 +26,7 @@ - + false Analyzer diff --git a/src/ipy/IronPython/IronPython.csproj b/src/ipy/IronPython/IronPython.csproj index 4af3f1695..c5e954dac 100644 --- a/src/ipy/IronPython/IronPython.csproj +++ b/src/ipy/IronPython/IronPython.csproj @@ -8,7 +8,7 @@ - + @@ -23,7 +23,7 @@ True - ..\..\Utils\References\Mono.Posix.dll + ..\..\..\utils\References\Mono.Posix.dll @@ -38,7 +38,7 @@ PreserveNewest - + PreserveNewest @@ -46,7 +46,7 @@ - + @@ -58,7 +58,7 @@ - + false Analyzer diff --git a/tests/ironpython/IronPython.Tests.csproj b/tests/ironpython/IronPython.Tests.csproj index 95d56194d..f4fa85996 100644 --- a/tests/ironpython/IronPython.Tests.csproj +++ b/tests/ironpython/IronPython.Tests.csproj @@ -8,7 +8,7 @@ - + @@ -28,15 +28,15 @@ - + false - - + + From 8d48c8e48edb92a49aa504ce53aa2870252ad2bd Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 18:46:53 +0000 Subject: [PATCH 35/84] Fix PowerShell script --- make.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/make.ps1 b/make.ps1 index 16e082c1b..696c997d6 100755 --- a/make.ps1 +++ b/make.ps1 @@ -43,7 +43,7 @@ function EnsureMSBuild() { function Main([String] $target, [String] $configuration) { # verify that the DLR submodule has been initialized - if(![System.Linq.Enumerable]::Any([System.IO.Directory]::EnumerateFileSystemEntries([System.IO.Path]::Combine($_BASEDIR, "Src/DLR")))) { + if(![System.Linq.Enumerable]::Any([System.IO.Directory]::EnumerateFileSystemEntries([System.IO.Path]::Combine($_BASEDIR, "src/runtime")))) { if(Get-Command git -ErrorAction SilentlyContinue) { & git submodule update --init } else { @@ -100,7 +100,7 @@ function GenerateRunSettings([String] $framework, [String] $platform, [String] $ $doc.AppendChild($runSettings) | Out-Null - $fileName = [System.IO.Path]::Combine($_BASEDIR, "Src", "IronPythonTest", "runsettings.$framework.xml") + $fileName = [System.IO.Path]::Combine($_BASEDIR, "tests", "ironpython", "runsettings.$framework.xml") $doc.Save($fileName) return $fileName } @@ -176,7 +176,7 @@ function Test([String] $target, [String] $configuration, [String[]] $frameworks, $runSettings = GenerateRunSettings $framework $platform $configuration $runIgnored function createTask($filtername, $filter) { - [Object[]] $args = @("$_BASEDIR/Src/IronPythonTest/IronPythonTest.csproj", '-f', "$framework", '-o', "$_BASEDIR/bin/$configuration/$framework", '-c', "$configuration", '--no-build', '-v', 'n', '-l', "trx;LogFileName=$filtername-$framework-$configuration-result.trx", '-s', "$runSettings", "--filter=$filter"); + [Object[]] $args = @("$_BASEDIR/tests/ironpython/IronPython.Tests.csproj", '-f', "$framework", '-o', "$_BASEDIR/bin/$configuration/$framework", '-c', "$configuration", '--no-build', '-v', 'n', '-l', "trx;LogFileName=$filtername-$framework-$configuration-result.trx", '-s', "$runSettings", "--filter=$filter"); Write-Host "Enqueue [$framework $filtername]:" Write-Host "dotnet test $args" Write-Host @@ -216,7 +216,7 @@ function Purge() { Get-ChildItem -Name "obj" -Directory -Path "$_BASEDIR" -Recurse | Remove-Item -Force -Recurse Write-Verbose "Deleting ""bin"" directories..." - foreach ($dir in @("", (Join-Path "IronPythonAnalyzer" "IronPythonAnalyzer"))) { + foreach ($dir in @("", (Join-Path "src" "roslyn" "IronPython.DiagnosticAnalyzer"))) { if (Test-Path (Join-Path $_BASEDIR $dir "bin" -OutVariable targetPath)) { Remove-Item -Path $targetPath -Force -Recurse } @@ -233,7 +233,7 @@ function Purge() { } Write-Verbose "Deleting test run settings..." - Remove-Item -Path (Join-Path $_BASEDIR "Src" "IronPythonTest" "runsettings.*.xml") + Remove-Item -Path (Join-Path $_BASEDIR "tests" "ironpython" "runsettings.*.xml") Write-Information "Done. Consider restoring dependencies." -InformationAction Continue } From af7e86b53f21b0d7bffdd2abff1f63b47c655f08 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 18:53:00 +0000 Subject: [PATCH 36/84] Fix final references --- Build.proj | 14 +++++++------- Directory.Build.props | 4 ++-- .../IronPython.Console32.Host.csproj | 8 ++++---- .../IronPython.Console32.csproj | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Build.proj b/Build.proj index 21c6967d6..8554e497d 100644 --- a/Build.proj +++ b/Build.proj @@ -9,10 +9,10 @@ $(MSBuildThisFileDirectory) $(RootDir)IronPython.sln - $(RootDir)Util - $(RootDir)Util\References + $(RootDir)utils + $(RootDir)utils\References $(RootDir)bin - $(RootDir)Build + $(RootDir)eng @@ -21,8 +21,8 @@ $(MajorVersion).$(MinorVersion).$(MicroVersion) $(MajorVersion).$(MinorVersion).$(MicroVersion)-$(ReleaseLevel)$(ReleaseSerial) - $(RootDir)Package\$(Configuration)\Stage\IronPython-$(PackageVersion) - $(RootDir)Package\$(Configuration)\Packages\IronPython-$(PackageVersion) + $(RootDir)eng\$(Configuration)\Stage\IronPython-$(PackageVersion) + $(RootDir)eng\$(Configuration)\Packages\IronPython-$(PackageVersion) lib @@ -117,7 +117,7 @@ - @@ -138,5 +138,5 @@ - + diff --git a/Directory.Build.props b/Directory.Build.props index e7e2231de..92c0afa8c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,8 +5,8 @@ $(MSBuildThisFileDirectory) - $(RootDir)Build - $(RootDir)Util\References + $(RootDir)eng + $(RootDir)utils\References true diff --git a/src/console/IronPython.Console32.Host/IronPython.Console32.Host.csproj b/src/console/IronPython.Console32.Host/IronPython.Console32.Host.csproj index 0ed23ee55..c420e54f4 100644 --- a/src/console/IronPython.Console32.Host/IronPython.Console32.Host.csproj +++ b/src/console/IronPython.Console32.Host/IronPython.Console32.Host.csproj @@ -6,12 +6,12 @@ WinExe IronPythonWindow ipyw32 - ..\IronPythonWindow\ipyw.ico + ..\IronPython.Console.Host\ipyw.ico true - + @@ -19,8 +19,8 @@ - - + + diff --git a/src/console/IronPython.Console32/IronPython.Console32.csproj b/src/console/IronPython.Console32/IronPython.Console32.csproj index 220d80735..de107bb20 100644 --- a/src/console/IronPython.Console32/IronPython.Console32.csproj +++ b/src/console/IronPython.Console32/IronPython.Console32.csproj @@ -6,7 +6,7 @@ Exe IronPythonConsole ipy32 - ..\Console\ipy.ico + ..\IronPython.Console\ipy.ico true From 10a679ee2d92b7c25c4d3ff075e1375e7c50cf5e Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 18:57:23 +0000 Subject: [PATCH 37/84] Fix internal assembly component reference errors --- src/ipy/IronPython/Runtime/CommonDictionaryStorage.cs | 2 +- src/ipy/IronPython/Runtime/ConstantDictionaryStorage.cs | 2 +- src/ipy/IronPython/Runtime/DictionaryStorage.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ipy/IronPython/Runtime/CommonDictionaryStorage.cs b/src/ipy/IronPython/Runtime/CommonDictionaryStorage.cs index 43a7b0036..5d6d0657c 100644 --- a/src/ipy/IronPython/Runtime/CommonDictionaryStorage.cs +++ b/src/ipy/IronPython/Runtime/CommonDictionaryStorage.cs @@ -35,7 +35,7 @@ namespace IronPython.Runtime { /// array to ensure that readers are not seeing multiple bucket arrays. /// [Serializable] - internal class CommonDictionaryStorage : DictionaryStorage, ISerializable, IDeserializationCallback { + public class CommonDictionaryStorage : DictionaryStorage, ISerializable, IDeserializationCallback { protected Bucket[] _buckets; private int _count; private int _version; diff --git a/src/ipy/IronPython/Runtime/ConstantDictionaryStorage.cs b/src/ipy/IronPython/Runtime/ConstantDictionaryStorage.cs index 2107abb8c..8e73eac5c 100644 --- a/src/ipy/IronPython/Runtime/ConstantDictionaryStorage.cs +++ b/src/ipy/IronPython/Runtime/ConstantDictionaryStorage.cs @@ -17,7 +17,7 @@ namespace IronPython.Runtime { /// Copy on write constant dictionary storage used for dictionaries created with constant items. /// [Serializable] - internal class ConstantDictionaryStorage : DictionaryStorage, IExpressionSerializable { + public class ConstantDictionaryStorage : DictionaryStorage, IExpressionSerializable { private readonly CommonDictionaryStorage _storage; public ConstantDictionaryStorage(CommonDictionaryStorage storage) { diff --git a/src/ipy/IronPython/Runtime/DictionaryStorage.cs b/src/ipy/IronPython/Runtime/DictionaryStorage.cs index 0a4e7c22e..227a31fe3 100644 --- a/src/ipy/IronPython/Runtime/DictionaryStorage.cs +++ b/src/ipy/IronPython/Runtime/DictionaryStorage.cs @@ -23,7 +23,7 @@ namespace IronPython.Runtime { /// around large operations and call lock free functions. /// [Serializable] - internal abstract class DictionaryStorage { + public abstract class DictionaryStorage { public abstract void Add(ref DictionaryStorage storage, object? key, object? value); public virtual void AddNoLock(ref DictionaryStorage storage, object? key, object? value) { From 99a35c78967d72cbb6dd7b7ad21d8f27723f6bf7 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 19:02:37 +0000 Subject: [PATCH 38/84] Remove internal declaration on built-in module test method --- tests/ironpython/TestBuiltinModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ironpython/TestBuiltinModule.cs b/tests/ironpython/TestBuiltinModule.cs index 5ea4ccb60..201e307cf 100644 --- a/tests/ironpython/TestBuiltinModule.cs +++ b/tests/ironpython/TestBuiltinModule.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. @@ -17,13 +17,13 @@ public TestBuiltinModule(PythonContext context) : base(context) { } - protected internal override void Initialize(CodeContext codeContext, Dictionary globals) { + protected override void Initialize(CodeContext codeContext, Dictionary globals) { _test_attr = globals["test_attr"]; _test_min = globals["min"]; base.Initialize(codeContext, globals); } - protected internal override IEnumerable GetGlobalVariableNames() { + protected override IEnumerable GetGlobalVariableNames() { return new string[] { "test_attr", "test_overlap_method", "test_overlap_type", "min" }; } From a562f6143d9879ab8cd22ce0822fade7f1ca58e0 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Mon, 25 Nov 2024 19:08:49 +0000 Subject: [PATCH 39/84] Replace more `internal` statements with `public` ones --- src/ipy/IronPython/Runtime/Operations/StringOps.cs | 2 +- src/ipy/IronPython/Runtime/PythonEncoding.cs | 6 +++--- src/ipy/IronPython/Runtime/PythonTuple.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ipy/IronPython/Runtime/Operations/StringOps.cs b/src/ipy/IronPython/Runtime/Operations/StringOps.cs index 2fb8bb95c..e07b94ea6 100644 --- a/src/ipy/IronPython/Runtime/Operations/StringOps.cs +++ b/src/ipy/IronPython/Runtime/Operations/StringOps.cs @@ -155,7 +155,7 @@ public virtual bool __contains__(object? value) { /// defined in the CLS System.String type. /// public static partial class StringOps { - internal static Encoding Latin1Encoding => _latin1 ??= Encoding.GetEncoding(28591, new EncoderExceptionFallback(), new DecoderExceptionFallback()); // ISO-8859-1 + public static Encoding Latin1Encoding => _latin1 ??= Encoding.GetEncoding(28591, new EncoderExceptionFallback(), new DecoderExceptionFallback()); // ISO-8859-1 [DisallowNull] private static Encoding? _latin1; internal static object FastNew(CodeContext/*!*/ context, object? x) { diff --git a/src/ipy/IronPython/Runtime/PythonEncoding.cs b/src/ipy/IronPython/Runtime/PythonEncoding.cs index fe7c00c4e..e32f4ca25 100644 --- a/src/ipy/IronPython/Runtime/PythonEncoding.cs +++ b/src/ipy/IronPython/Runtime/PythonEncoding.cs @@ -39,7 +39,7 @@ namespace IronPython.Runtime { /// to the constructor. Also, the fallbacks have to be of type /// and , which implement the extended fallback protocol. /// - internal class PythonEncoding : Encoding { + public class PythonEncoding : Encoding { // The following two must be different from each other and be pass-through characters for UTF-7 private const char Pass1Marker = '?'; private const char Pass2Marker = '-'; @@ -931,7 +931,7 @@ public override void Reset() { } - internal class PythonSurrogateEscapeEncoding : PythonEncoding { + public class PythonSurrogateEscapeEncoding : PythonEncoding { // Defined in PEP 383 private const ushort LoneSurrogateBase = 0xdc00; @@ -1007,7 +1007,7 @@ public override ReadOnlyMemory GetFallbackChars(byte[] bytesUnknown, int i } } - internal class PythonSurrogatePassEncoding : PythonEncoding { + public class PythonSurrogatePassEncoding : PythonEncoding { private const ushort SurrogateRangeStart = 0xd800; private const ushort SurrogateRangeEnd = 0xdfff; private const byte Utf8LeadByte = 0b_1110_0000; diff --git a/src/ipy/IronPython/Runtime/PythonTuple.cs b/src/ipy/IronPython/Runtime/PythonTuple.cs index 51e048af9..896f58f32 100644 --- a/src/ipy/IronPython/Runtime/PythonTuple.cs +++ b/src/ipy/IronPython/Runtime/PythonTuple.cs @@ -112,12 +112,12 @@ public int count(object? obj) { #endregion - internal static PythonTuple Make(object o) { + public static PythonTuple Make(object o) { if (o is PythonTuple t) return t; return new PythonTuple(o); } - internal static PythonTuple MakeTuple(params object?[] items) { + public static PythonTuple MakeTuple(params object?[] items) { if (items.Length == 0) return EMPTY; return new PythonTuple(items); } From 5c5c1ef3fb0d6a4887bccc48d64b30298b9d8815 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Tue, 26 Nov 2024 07:40:00 +0000 Subject: [PATCH 40/84] Code mess-up Well it's not exactly code cleanup! --- .../IronPythonWindow.cs | 2 - .../IronPython.SQLite/Connection.cs | 305 +- src/extensions/IronPython.SQLite/Contants.cs | 6 +- src/extensions/IronPython.SQLite/Cursor.cs | 286 +- .../IronPython.SQLite/Exceptions.cs | 53 +- .../IronPython.SQLite/Extensions.cs | 12 +- .../Properties/AssemblyInfo.cs | 1 + src/extensions/IronPython.SQLite/Row.cs | 54 +- src/extensions/IronPython.SQLite/Statement.cs | 155 +- src/extensions/IronPython.SQLite/Util.cs | 11 +- src/extensions/IronPython.SQLite/_sqlite.cs | 35 +- .../IronPython.SQLite/c#sqlite/BtreeInt_h.cs | 1510 +- .../IronPython.SQLite/c#sqlite/Btree_h.cs | 540 +- .../IronPython.SQLite/c#sqlite/Delegates.cs | 480 +- .../IronPython.SQLite/c#sqlite/Hash_h.cs | 249 +- .../IronPython.SQLite/c#sqlite/VdbeInt_h.cs | 1116 +- .../IronPython.SQLite/c#sqlite/Vdbe_h.cs | 493 +- .../IronPython.SQLite/c#sqlite/_Custom.cs | 966 +- .../IronPython.SQLite/c#sqlite/alter_c.cs | 1625 +- .../IronPython.SQLite/c#sqlite/analyze_c.cs | 1196 +- .../IronPython.SQLite/c#sqlite/attach_c.cs | 1114 +- .../IronPython.SQLite/c#sqlite/auth_c.cs | 70 +- .../IronPython.SQLite/c#sqlite/backup_c.cs | 1417 +- .../IronPython.SQLite/c#sqlite/bitvec_c.cs | 967 +- .../IronPython.SQLite/c#sqlite/btmutex_c.cs | 60 +- .../IronPython.SQLite/c#sqlite/btree_c.cs | 15614 ++++++++-------- .../IronPython.SQLite/c#sqlite/build_c.cs | 7461 ++++---- .../IronPython.SQLite/c#sqlite/callback_c.cs | 946 +- .../IronPython.SQLite/c#sqlite/complete_c.cs | 526 +- .../IronPython.SQLite/c#sqlite/crypto.cs | 110 +- .../IronPython.SQLite/c#sqlite/ctime_c.cs | 145 +- .../IronPython.SQLite/c#sqlite/date_c.cs | 2368 +-- .../IronPython.SQLite/c#sqlite/delete_c.cs | 1126 +- .../IronPython.SQLite/c#sqlite/expr_c.cs | 7828 ++++---- .../IronPython.SQLite/c#sqlite/fault_c.cs | 190 +- .../IronPython.SQLite/c#sqlite/fkey_c.cs | 2441 +-- .../IronPython.SQLite/c#sqlite/func_c.cs | 3462 ++-- .../IronPython.SQLite/c#sqlite/global_c.cs | 372 +- .../IronPython.SQLite/c#sqlite/hash_c.cs | 599 +- .../IronPython.SQLite/c#sqlite/hwtime_c.cs | 107 +- .../IronPython.SQLite/c#sqlite/insert_c.cs | 3758 ++-- .../IronPython.SQLite/c#sqlite/journal_c.cs | 74 +- .../c#sqlite/keywordhash_h.cs | 415 +- .../IronPython.SQLite/c#sqlite/legacy_c.cs | 417 +- .../IronPython.SQLite/c#sqlite/loadext_c.cs | 1211 +- .../IronPython.SQLite/c#sqlite/main_c.cs | 5230 +++--- .../IronPython.SQLite/c#sqlite/malloc_c.cs | 1793 +- .../IronPython.SQLite/c#sqlite/mem_Pool.cs | 288 +- .../c#sqlite/memjournal_c.cs | 543 +- .../IronPython.SQLite/c#sqlite/mutex_c.cs | 292 +- .../IronPython.SQLite/c#sqlite/mutex_h.cs | 128 +- .../c#sqlite/mutex_noop_c.cs | 357 +- .../IronPython.SQLite/c#sqlite/mutex_w32.cs | 596 +- .../IronPython.SQLite/c#sqlite/notify_c.cs | 60 +- .../IronPython.SQLite/c#sqlite/opcodes_c.cs | 21 +- .../IronPython.SQLite/c#sqlite/opcodes_h.cs | 640 +- .../IronPython.SQLite/c#sqlite/os_c.cs | 677 +- .../IronPython.SQLite/c#sqlite/os_common_h.cs | 132 +- .../IronPython.SQLite/c#sqlite/os_h.cs | 504 +- .../IronPython.SQLite/c#sqlite/os_win_c.cs | 3975 ++-- .../IronPython.SQLite/c#sqlite/pager_c.cs | 12349 ++++++------ .../IronPython.SQLite/c#sqlite/pager_h.cs | 397 +- .../IronPython.SQLite/c#sqlite/parse_c.cs | 5676 +++--- .../IronPython.SQLite/c#sqlite/parse_h.cs | 636 +- .../IronPython.SQLite/c#sqlite/pcache1_c.cs | 1974 +- .../IronPython.SQLite/c#sqlite/pcache_c.cs | 1208 +- .../IronPython.SQLite/c#sqlite/pcache_h.cs | 309 +- .../IronPython.SQLite/c#sqlite/pragma_c.cs | 2699 +-- .../IronPython.SQLite/c#sqlite/prepare_c.cs | 1729 +- .../IronPython.SQLite/c#sqlite/printf_c.cs | 2506 +-- .../IronPython.SQLite/c#sqlite/random_c.cs | 335 +- .../IronPython.SQLite/c#sqlite/resolve_c.cs | 2431 +-- .../IronPython.SQLite/c#sqlite/rowset_c.cs | 909 +- .../IronPython.SQLite/c#sqlite/select_c.cs | 9154 ++++----- .../IronPython.SQLite/c#sqlite/sqlite3_h.cs | 14735 +++++++-------- .../IronPython.SQLite/c#sqlite/sqliteInt_h.cs | 7658 ++++---- .../c#sqlite/sqliteLimit_h.cs | 336 +- .../IronPython.SQLite/c#sqlite/status_c.cs | 473 +- .../IronPython.SQLite/c#sqlite/table_c.cs | 69 +- .../IronPython.SQLite/c#sqlite/tokenize_c.cs | 1215 +- .../IronPython.SQLite/c#sqlite/trigger_c.cs | 2292 +-- .../IronPython.SQLite/c#sqlite/update_c.cs | 1314 +- .../IronPython.SQLite/c#sqlite/utf_c.cs | 482 +- .../IronPython.SQLite/c#sqlite/util_c.cs | 2810 +-- .../IronPython.SQLite/c#sqlite/vacuum_c.cs | 716 +- .../IronPython.SQLite/c#sqlite/vdbe_c.cs | 12111 ++++++------ .../IronPython.SQLite/c#sqlite/vdbeapi_c.cs | 2508 +-- .../IronPython.SQLite/c#sqlite/vdbeaux_c.cs | 7270 +++---- .../IronPython.SQLite/c#sqlite/vdbeblob_c.cs | 58 +- .../IronPython.SQLite/c#sqlite/vdbemem_c.cs | 2700 +-- .../IronPython.SQLite/c#sqlite/vdbetrace_c.cs | 322 +- .../IronPython.SQLite/c#sqlite/vtab_c.cs | 2195 ++- .../IronPython.SQLite/c#sqlite/wal_c.cs | 511 +- .../IronPython.SQLite/c#sqlite/wal_h.cs | 250 +- .../IronPython.SQLite/c#sqlite/walker_c.cs | 333 +- .../IronPython.SQLite/c#sqlite/where_c.cs | 9424 +++++----- .../IronPython.Wpf/DynamicXamlReader.cs | 12 +- .../IronPython.Wpf/Properties/AssemblyInfo.cs | 1 + src/extensions/IronPython.Wpf/_wpf.cs | 4 +- .../AssemblyResolver.cs | 3 + src/ipy/IronPython.CompilerServices/Config.cs | 9 +- .../IronPython.CompilerServices/ConsoleOps.cs | 3 + .../Properties/AssemblyInfo.cs | 1 + src/ipy/IronPython.Modules/IterTools.cs | 42 +- src/ipy/IronPython.Modules/ModuleOps.cs | 13 +- src/ipy/IronPython.Modules/NtSignalState.cs | 2 +- .../Properties/AssemblyInfo.cs | 1 + .../ResourceMetaPathImporter.cs | 44 +- .../IronPython.Modules/SimpleSignalState.cs | 8 +- src/ipy/IronPython.Modules/_bisect.cs | 12 +- src/ipy/IronPython.Modules/_codecs.cs | 3 +- src/ipy/IronPython.Modules/_codecs_cn.cs | 7 + src/ipy/IronPython.Modules/_collections.cs | 33 +- src/ipy/IronPython.Modules/_csv.cs | 2 +- src/ipy/IronPython.Modules/_ctypes/Array.cs | 1 + .../IronPython.Modules/_ctypes/ArrayType.cs | 1 + src/ipy/IronPython.Modules/_ctypes/CData.cs | 5 +- .../_ctypes/CFuncPtrType.cs | 13 +- src/ipy/IronPython.Modules/_ctypes/Field.cs | 4 +- .../_ctypes/MarshalCleanup.cs | 2 + .../_ctypes/MemoryHolder.cs | 20 +- .../_ctypes/NativeArgument.cs | 6 +- src/ipy/IronPython.Modules/_ctypes/Pointer.cs | 2 +- .../IronPython.Modules/_ctypes/PointerType.cs | 11 +- .../IronPython.Modules/_ctypes/SimpleCData.cs | 9 +- .../IronPython.Modules/_ctypes/SimpleType.cs | 6 +- .../_ctypes/SimpleTypeKind.cs | 2 + .../IronPython.Modules/_ctypes/StructType.cs | 6 +- .../IronPython.Modules/_ctypes/Structure.cs | 6 +- src/ipy/IronPython.Modules/_ctypes/Union.cs | 2 +- .../IronPython.Modules/_ctypes/UnionType.cs | 3 + src/ipy/IronPython.Modules/_datetime.cs | 3 +- src/ipy/IronPython.Modules/_functools.cs | 2 +- src/ipy/IronPython.Modules/_heapq.cs | 7 +- src/ipy/IronPython.Modules/_multibytecodec.cs | 8 + .../IronPython.Modules/_multiprocessing.cs | 2 + src/ipy/IronPython.Modules/_opcode.cs | 13 +- src/ipy/IronPython.Modules/_random.cs | 2 +- src/ipy/IronPython.Modules/_socket.cs | 40 +- src/ipy/IronPython.Modules/_ssl.cs | 6 +- src/ipy/IronPython.Modules/_struct.cs | 10 +- src/ipy/IronPython.Modules/_warnings.cs | 18 +- src/ipy/IronPython.Modules/_weakref.cs | 27 +- src/ipy/IronPython.Modules/_winapi.cs | 7 +- src/ipy/IronPython.Modules/array.cs | 21 +- src/ipy/IronPython.Modules/atexit.cs | 17 +- .../IronPython.Modules/bz2/BZ2Compressor.cs | 7 +- .../IronPython.Modules/bz2/BZ2Decompressor.cs | 3 - src/ipy/IronPython.Modules/bz2/BZ2Module.cs | 3 + .../bz2/dotnetzip/BZip2/BZip2Compressor.cs | 784 +- .../bz2/dotnetzip/BZip2/BZip2InputStream.cs | 576 +- .../bz2/dotnetzip/BZip2/BZip2OutputStream.cs | 128 +- .../bz2/dotnetzip/BZip2/BitWriter.cs | 58 +- .../bz2/dotnetzip/BZip2/CRC32.cs | 230 +- .../BZip2/ParallelBZip2OutputStream.cs | 249 +- .../bz2/dotnetzip/BZip2/Rand.cs | 9 +- src/ipy/IronPython.Modules/gc.cs | 16 +- src/ipy/IronPython.Modules/grp.cs | 31 +- .../hashlib/SHA224Managed.cs | 2 + .../hashlib/SHA384Managed.cs | 1 + .../IronPython.Modules/hashlib/_hashlib.cs | 1 + src/ipy/IronPython.Modules/marshal.cs | 2 +- src/ipy/IronPython.Modules/math.cs | 6 +- src/ipy/IronPython.Modules/msvcrt.cs | 21 +- src/ipy/IronPython.Modules/nt.cs | 7 +- src/ipy/IronPython.Modules/pwd.cs | 26 +- src/ipy/IronPython.Modules/pyexpat.cs | 2 +- src/ipy/IronPython.Modules/re.cs | 14 +- src/ipy/IronPython.Modules/resource.cs | 34 +- src/ipy/IronPython.Modules/select.cs | 4 +- src/ipy/IronPython.Modules/signal.cs | 6 +- src/ipy/IronPython.Modules/spwd.cs | 22 +- src/ipy/IronPython.Modules/winreg.cs | 5 +- src/ipy/IronPython.Modules/winsound.cs | 3 +- src/ipy/IronPython.Modules/xxsubtype.cs | 11 +- src/ipy/IronPython.Modules/zipimport.cs | 3 +- src/ipy/IronPython.Modules/zlib/Compress.cs | 50 +- src/ipy/IronPython.Modules/zlib/Decompress.cs | 54 +- src/ipy/IronPython.Modules/zlib/ZlibModule.cs | 98 +- .../zlib/zlib.net/Adler32.cs | 110 +- .../zlib/zlib.net/Deflate.cs | 666 +- .../zlib/zlib.net/InfBlocks.cs | 301 +- .../zlib/zlib.net/InfCodes.cs | 1181 +- .../zlib/zlib.net/InfTree.cs | 526 +- .../zlib/zlib.net/Inflate.cs | 657 +- .../zlib/zlib.net/StaticTree.cs | 78 +- .../IronPython.Modules/zlib/zlib.net/Tree.cs | 423 +- .../zlib/zlib.net/ZStream.cs | 273 +- .../zlib/zlib.net/ZStreamException.cs | 28 +- .../IronPython.Modules/zlib/zlib.net/Zlib.cs | 344 +- .../IronPython/Compiler/Ast/AndExpression.cs | 1 - .../Compiler/Ast/AssertStatement.cs | 5 +- .../Compiler/Ast/AssignmentStatement.cs | 11 +- src/ipy/IronPython/Compiler/Ast/AstMethods.cs | 6 +- .../Compiler/Ast/AugmentedAssignStatement.cs | 5 +- .../Compiler/Ast/BinaryExpression.cs | 14 +- .../IronPython/Compiler/Ast/BreakStatement.cs | 2 + .../Compiler/Ast/ClassDefinition.cs | 1 + .../IronPython/Compiler/Ast/Comprehension.cs | 7 +- .../Compiler/Ast/ComprehensionFor.cs | 4 +- .../Compiler/Ast/ComprehensionIf.cs | 5 +- .../Compiler/Ast/ConditionalExpression.cs | 6 +- .../Compiler/Ast/ConstantExpression.cs | 7 +- .../Compiler/Ast/ContinueStatement.cs | 2 + .../IronPython/Compiler/Ast/DelStatement.cs | 4 +- src/ipy/IronPython/Compiler/Ast/DottedName.cs | 2 + .../Compiler/Ast/DynamicConvertExpression.cs | 6 +- .../Ast/DynamicGetMemberExpression.cs | 16 +- .../IronPython/Compiler/Ast/EmptyStatement.cs | 3 +- .../Compiler/Ast/ErrorExpression.cs | 4 + src/ipy/IronPython/Compiler/Ast/Expression.cs | 3 +- .../Compiler/Ast/ExpressionStatement.cs | 2 + .../IronPython/Compiler/Ast/FlowChecker.cs | 3 +- .../IronPython/Compiler/Ast/ForStatement.cs | 12 +- .../Compiler/Ast/FromImportStatement.cs | 6 +- .../Compiler/Ast/FunctionDefinition.cs | 28 +- .../Compiler/Ast/GeneratorExpression.cs | 8 + .../Ast/GetGlobalContextExpression.cs | 5 +- .../GetParentContextFromFunctionExpression.cs | 4 +- .../IronPython/Compiler/Ast/IfStatement.cs | 7 +- .../Compiler/Ast/ImportStatement.cs | 5 +- .../Compiler/Ast/IndexExpression.cs | 4 +- .../Compiler/Ast/LambdaExpression.cs | 2 + .../Compiler/Ast/MemberExpression.cs | 7 +- src/ipy/IronPython/Compiler/Ast/ModuleName.cs | 2 + .../IronPython/Compiler/Ast/NameExpression.cs | 7 +- src/ipy/IronPython/Compiler/Ast/Node.cs | 25 +- .../IronPython/Compiler/Ast/OrExpression.cs | 1 - src/ipy/IronPython/Compiler/Ast/Parameter.cs | 3 + .../Compiler/Ast/ParenthesisExpression.cs | 4 +- src/ipy/IronPython/Compiler/Ast/PythonAst.cs | 36 +- .../Compiler/Ast/PythonNameBinder.cs | 10 +- .../IronPython/Compiler/Ast/PythonVariable.cs | 9 + .../Compiler/Ast/RelativeModuleName.cs | 2 + .../IronPython/Compiler/Ast/ScopeStatement.cs | 6 +- .../Compiler/Ast/SerializedScopeStatement.cs | 6 + .../Compiler/Ast/SliceExpression.cs | 2 + .../IronPython/Compiler/Ast/SuiteStatement.cs | 14 +- .../IronPython/Compiler/Ast/TryStatement.cs | 9 +- .../Compiler/Ast/UnaryExpression.cs | 8 +- .../IronPython/Compiler/Ast/WhileStatement.cs | 3 +- .../IronPython/Compiler/Ast/WithStatement.cs | 26 +- .../Compiler/Ast/YieldExpression.cs | 6 +- .../Compiler/Ast/YieldFromExpression.cs | 6 +- .../IronPython/Compiler/ClosureExpression.cs | 9 +- src/ipy/IronPython/Compiler/ClosureInfo.cs | 8 +- .../Compiler/CollectableCompilationMode.cs | 9 +- .../IronPython/Compiler/CompilationMode.cs | 20 +- .../IronPython/Compiler/GeneratorRewriter.cs | 33 +- .../Compiler/LookupCompilationMode.cs | 11 +- .../IronPython/Compiler/OnDiskScriptCode.cs | 8 +- src/ipy/IronPython/Compiler/Parser.cs | 8 +- .../IronPython/Compiler/PythonCallTargets.cs | 41 +- .../Compiler/PythonCompilerOptions.cs | 4 +- .../Compiler/PythonDynamicExpression.cs | 13 +- src/ipy/IronPython/Compiler/PythonGlobal.cs | 8 +- .../PythonGlobalVariableExpression.cs | 14 +- .../Compiler/PythonSavableScriptCode.cs | 9 +- .../IronPython/Compiler/PythonScriptCode.cs | 26 +- .../Compiler/ReducableDynamicExpression.cs | 10 +- .../IronPython/Compiler/RunnableScriptCode.cs | 9 +- .../IronPython/Compiler/RuntimeScriptCode.cs | 15 +- .../Compiler/ToDiskCompilationMode.cs | 10 +- src/ipy/IronPython/Compiler/Token.cs | 2 +- .../Compiler/UncollectableCompilationMode.cs | 21 +- src/ipy/IronPython/Hosting/Python.cs | 16 +- .../Hosting/PythonCodeDomCodeGen.cs | 4 +- .../Hosting/PythonConsoleOptions.cs | 3 +- src/ipy/IronPython/Hosting/PythonService.cs | 6 +- .../Windows/Ucrtbase/Interop.strerror.cs | 2 + src/ipy/IronPython/Modules/_ast.cs | 1 + src/ipy/IronPython/Modules/_fileio.cs | 5 +- src/ipy/IronPython/Modules/_imp.cs | 6 +- src/ipy/IronPython/Modules/_io.cs | 154 +- src/ipy/IronPython/Runtime/ArrayData.cs | 10 +- .../Runtime/Binding/BinaryRetTypeBinder.cs | 8 +- src/ipy/IronPython/Runtime/Binding/Binders.cs | 7 +- .../Runtime/Binding/BindingHelpers.cs | 27 +- .../Runtime/Binding/BindingWarnings.cs | 1 + .../Binding/CompatibilityInvokeBinder.cs | 10 + .../Runtime/Binding/ConditionalBuilder.cs | 6 +- .../Runtime/Binding/ContextArgBuilder.cs | 11 +- .../Runtime/Binding/ConversionBinder.cs | 13 +- .../Runtime/Binding/CreateFallbackBinder.cs | 10 + .../Runtime/Binding/FastBindResult.cs | 10 + .../IronPython/Runtime/Binding/FastGetBase.cs | 2 + .../IronPython/Runtime/Binding/FastSetBase.cs | 1 + .../Runtime/Binding/IComConvertible.cs | 3 + .../Runtime/Binding/IFastGettable.cs | 7 + .../Runtime/Binding/IFastInvokable.cs | 5 + .../Runtime/Binding/IFastSettable.cs | 8 + .../Runtime/Binding/IPythonConvertible.cs | 4 + .../Runtime/Binding/IPythonGetable.cs | 3 + .../Runtime/Binding/IPythonInvokable.cs | 4 +- .../Runtime/Binding/IPythonOperable.cs | 3 + .../IronPython/Runtime/Binding/IPythonSite.cs | 6 +- .../Runtime/Binding/MetaBuiltinFunction.cs | 99 +- .../Binding/MetaBuiltinMethodDescriptor.cs | 10 +- .../Runtime/Binding/MetaPythonFunction.cs | 26 +- .../Runtime/Binding/MetaPythonObject.cs | 14 +- .../Runtime/Binding/MetaPythonType.Calls.cs | 52 +- .../Runtime/Binding/MetaPythonType.Members.cs | 14 +- .../Runtime/Binding/MetaPythonType.cs | 10 +- .../Runtime/Binding/MetaUserObject.Members.cs | 62 +- .../Runtime/Binding/MetaUserObject.cs | 26 +- .../Binding/PythonBinaryOperationBinder.cs | 31 +- .../Runtime/Binding/PythonBinder.Create.cs | 8 +- .../Runtime/Binding/PythonBinder.cs | 47 +- .../Binding/PythonDeleteIndexBinder.cs | 9 +- .../Binding/PythonDeleteMemberBinder.cs | 10 +- .../Binding/PythonDeleteSliceBinder.cs | 6 +- .../Runtime/Binding/PythonExtensionBinder.cs | 7 +- .../Runtime/Binding/PythonGetIndexBinder.cs | 12 +- .../Runtime/Binding/PythonGetMemberBinder.cs | 11 +- .../Runtime/Binding/PythonGetSliceBinder.cs | 6 +- .../Runtime/Binding/PythonIndexType.cs | 4 + .../Runtime/Binding/PythonInvokeBinder.cs | 12 +- .../Runtime/Binding/PythonOperationBinder.cs | 23 +- .../Runtime/Binding/PythonOperationKind.cs | 12 +- .../Runtime/Binding/PythonOverloadResolver.cs | 12 +- .../Binding/PythonProtocol.Operations.cs | 32 +- .../Runtime/Binding/PythonSetIndexBinder.cs | 12 +- .../Runtime/Binding/PythonSetMemberBinder.cs | 14 +- .../Runtime/Binding/PythonSetSliceBinder.cs | 8 +- .../Binding/PythonUnaryOperationBinder.cs | 8 +- .../Binding/SiteLocalStorageBuilder.cs | 12 +- .../Runtime/Binding/SlotOrFunction.cs | 15 +- .../IronPython/Runtime/Binding/WarningInfo.cs | 1 - src/ipy/IronPython/Runtime/BufferProtocol.cs | 28 +- .../IronPython/Runtime/BuiltinPythonModule.cs | 3 +- .../Runtime/BuiltinsDictionaryStorage.cs | 7 +- src/ipy/IronPython/Runtime/ByteArray.cs | 25 +- src/ipy/IronPython/Runtime/Bytes.cs | 23 +- .../Runtime/ClassMethodDescriptor.cs | 6 +- src/ipy/IronPython/Runtime/ClrModule.cs | 14 +- src/ipy/IronPython/Runtime/CodeContext.cs | 5 +- .../IronPython/Runtime/CollectionDebugView.cs | 4 +- .../Runtime/CommonDictionaryStorage.cs | 6 +- src/ipy/IronPython/Runtime/CompiledLoader.cs | 5 +- .../Runtime/ConstantDictionaryStorage.cs | 14 +- src/ipy/IronPython/Runtime/Converter.cs | 24 +- .../Runtime/CustomDictionaryStorage.cs | 1 + .../Runtime/DebuggerDictionaryStorage.cs | 2 + src/ipy/IronPython/Runtime/DefaultContext.cs | 6 +- src/ipy/IronPython/Runtime/Descriptors.cs | 19 +- src/ipy/IronPython/Runtime/DictionaryOps.cs | 8 +- .../IronPython/Runtime/DictionaryStorage.cs | 5 +- .../Runtime/DictionaryTypeInfoAttribute.cs | 2 +- .../Runtime/EmptyDictionaryStorage.cs | 3 +- src/ipy/IronPython/Runtime/Enumerate.cs | 4 +- src/ipy/IronPython/Runtime/ErrorCodes.cs | 4 +- .../Exceptions/AttributeErrorException.cs | 1 - .../Exceptions/IndentationException.cs | 1 - .../Runtime/Exceptions/PythonException.cs | 1 - .../PythonExceptions.BaseException.cs | 6 +- .../Runtime/Exceptions/PythonExceptions.cs | 22 +- .../Runtime/Exceptions/SystemExitException.cs | 1 - .../Runtime/Exceptions/TabException.cs | 2 +- .../Runtime/Exceptions/TraceBack.cs | 18 +- .../Runtime/Exceptions/TypeErrorException.cs | 5 +- .../Runtime/Exceptions/ValueErrorException.cs | 1 - .../IronPython/Runtime/FunctionAttributes.cs | 4 +- src/ipy/IronPython/Runtime/FunctionCode.cs | 21 +- src/ipy/IronPython/Runtime/Generator.cs | 11 +- .../Runtime/GlobalDictionaryStorage.cs | 7 +- src/ipy/IronPython/Runtime/Implementation.cs | 3 + src/ipy/IronPython/Runtime/Importer.cs | 14 +- src/ipy/IronPython/Runtime/Index.cs | 5 +- .../InstancedModuleDictionaryStorage.cs | 2 +- src/ipy/IronPython/Runtime/Interfaces.cs | 2 +- .../Runtime/MemoryStreamContentProvider.cs | 1 - src/ipy/IronPython/Runtime/MemoryView.cs | 39 +- src/ipy/IronPython/Runtime/Method.cs | 12 +- src/ipy/IronPython/Runtime/ModuleContext.cs | 2 +- .../Runtime/ModuleDictionaryStorage.cs | 4 +- .../IronPython/Runtime/ModuleGlobalCache.cs | 5 +- src/ipy/IronPython/Runtime/ModuleLoader.cs | 2 + src/ipy/IronPython/Runtime/ModuleOptions.cs | 2 + .../IronPython/Runtime/NewStringFormatter.cs | 6 +- .../Runtime/ObjectAttributesAdapter.cs | 5 +- src/ipy/IronPython/Runtime/ObjectDebugView.cs | 4 +- .../IronPython/Runtime/Operations/ArrayOps.cs | 4 +- .../Runtime/Operations/BigIntegerOps.cs | 28 +- .../IronPython/Runtime/Operations/BoolOps.cs | 3 +- .../IronPython/Runtime/Operations/ByteOps.cs | 3 + .../IronPython/Runtime/Operations/CharOps.cs | 3 +- .../Runtime/Operations/DBNullOps.cs | 2 +- .../Runtime/Operations/DelegateOps.cs | 6 +- .../IronPython/Runtime/Operations/EnumOps.cs | 2 +- .../IronPython/Runtime/Operations/FloatOps.cs | 7 +- .../Runtime/Operations/IListOfByteOps.cs | 7 +- .../Runtime/Operations/InstanceOps.cs | 22 +- .../IronPython/Runtime/Operations/IntOps.cs | 4 +- .../Runtime/Operations/MarshalOps.cs | 380 +- .../Runtime/Operations/NamespaceTrackerOps.cs | 7 +- .../Runtime/Operations/ObjectOps.cs | 10 +- .../Runtime/Operations/PythonCalls.cs | 2 + .../Runtime/Operations/PythonOps.cs | 33 +- .../Runtime/Operations/PythonTypeOps.cs | 54 +- .../Runtime/Operations/StringOps.cs | 46 +- .../Runtime/Operations/TypeGroupOps.cs | 10 +- .../Runtime/Operations/TypeTrackerOps.cs | 4 +- .../Runtime/Operations/UserTypeOps.cs | 26 +- src/ipy/IronPython/Runtime/OutputWriter.cs | 3 +- src/ipy/IronPython/Runtime/Profiler.cs | 9 +- src/ipy/IronPython/Runtime/PythonContext.cs | 14 +- .../IronPython/Runtime/PythonDictionary.cs | 16 +- .../Runtime/PythonDocumentationProvider.cs | 10 +- .../Runtime/PythonDynamicStackFrame.cs | 3 +- src/ipy/IronPython/Runtime/PythonEncoding.cs | 16 +- .../IronPython/Runtime/PythonFileManager.cs | 12 +- src/ipy/IronPython/Runtime/PythonFunction.cs | 13 +- .../Runtime/PythonHiddenBaseClassAttribute.cs | 3 + src/ipy/IronPython/Runtime/PythonList.cs | 7 +- src/ipy/IronPython/Runtime/PythonModule.cs | 16 +- src/ipy/IronPython/Runtime/PythonOptions.cs | 6 +- .../Runtime/PythonScopeExtension.cs | 1 + .../IronPython/Runtime/PythonStrIterator.cs | 6 +- .../Runtime/PythonTracebackListener.cs | 14 +- src/ipy/IronPython/Runtime/PythonTuple.cs | 3 +- .../IronPython/Runtime/PythonTypeAttribute.cs | 2 + .../RuntimeVariablesDictionaryStorage.cs | 1 + .../Runtime/ScopeDictionaryStorage.cs | 6 +- .../Runtime/SequenceTypeInfoAttribute.cs | 6 +- src/ipy/IronPython/Runtime/SetStorage.cs | 24 +- src/ipy/IronPython/Runtime/Slice.cs | 4 +- .../Runtime/StringDictionaryStorage.cs | 3 +- .../IronPython/Runtime/StringFormatSpec.cs | 10 +- src/ipy/IronPython/Runtime/Super.cs | 11 +- .../IronPython/Runtime/ThrowingErrorSink.cs | 4 +- src/ipy/IronPython/Runtime/TypecodeOps.cs | 3 +- .../Runtime/Types/BuiltinFunction.cs | 11 +- .../Types/BuiltinFunctionOverloadMapper.cs | 6 +- .../Runtime/Types/BuiltinMethodDescriptor.cs | 14 +- .../Runtime/Types/CachedNewTypeInfo.cs | 2 +- .../Runtime/Types/ConstructorFunction.cs | 5 +- .../Runtime/Types/CustomAttributeTracker.cs | 20 +- .../Types/CustomInstanceDictionaryStorage.cs | 8 +- .../IronPython/Runtime/Types/DocBuilder.cs | 23 +- .../Runtime/Types/DynamicBaseTypeAttribute.cs | 2 +- src/ipy/IronPython/Runtime/Types/EmptyType.cs | 6 +- .../Runtime/Types/ExtensionPropertyInfo.cs | 4 +- .../IronPython/Runtime/Types/IPythonObject.cs | 3 + .../Runtime/Types/InstanceCreator.cs | 3 +- .../IronPython/Runtime/Types/NameConverter.cs | 12 +- .../IronPython/Runtime/Types/NewTypeInfo.cs | 4 +- .../IronPython/Runtime/Types/NewTypeMaker.cs | 50 +- .../Runtime/Types/OperatorMapping.cs | 4 +- .../Runtime/Types/ParameterInfoWrapper.cs | 2 +- .../Runtime/Types/PythonAssemblyOps.cs | 4 +- .../Runtime/Types/PythonSiteCache.cs | 6 +- .../IronPython/Runtime/Types/PythonType.cs | 95 +- .../Runtime/Types/PythonTypeDataSlot.cs | 4 + .../Runtime/Types/PythonTypeDictSlot.cs | 3 +- .../Runtime/Types/PythonTypeInfo.cs | 25 +- .../Runtime/Types/PythonTypeSlot.cs | 11 +- .../Runtime/Types/PythonTypeTypeSlot.cs | 2 +- .../Types/PythonTypeUserDescriptorSlot.cs | 3 +- .../Runtime/Types/PythonTypeWeakRefSlot.cs | 2 +- .../Runtime/Types/ReflectedEvent.cs | 4 +- .../Types/ReflectedExtensionProperty.cs | 4 +- .../Runtime/Types/ReflectedField.cs | 16 +- .../Runtime/Types/ReflectedGetterSetter.cs | 9 +- .../Runtime/Types/ReflectedIndexer.cs | 6 +- .../Runtime/Types/ReflectedProperty.cs | 13 +- .../Runtime/Types/ReflectedSlotProperty.cs | 10 +- src/ipy/IronPython/Runtime/WeakRef.cs | 6 +- .../IronPython/Runtime/WrapperDictionary.cs | 4 +- src/ipy/IronPython/Runtime/Zip.cs | 4 +- .../IronPython.DiagnosticAnalyzer/Analyzer.cs | 6 +- tests/ironpython/AttrInjectorTest.cs | 4 +- tests/ironpython/BindTest.cs | 37 +- tests/ironpython/BinderTest.cs | 36 +- tests/ironpython/Cases/CPythonCases.cs | 3 +- tests/ironpython/Cases/CaseExecuter.cs | 5 +- tests/ironpython/Cases/CaseGenerator.cs | 1 - tests/ironpython/Cases/IronPythonCases.cs | 3 +- tests/ironpython/ClrType.cs | 6 +- tests/ironpython/Conversions.cs | 3 +- tests/ironpython/DynamicRegressions.cs | 30 +- tests/ironpython/EncodingTest.cs | 6 +- tests/ironpython/EngineTest.cs | 3 + tests/ironpython/Events.cs | 2 +- tests/ironpython/ExtensionMethodTest.cs | 8 +- tests/ironpython/Indexable.cs | 2 +- tests/ironpython/InheritTest.cs | 23 +- tests/ironpython/IronMath.cs | 1 - tests/ironpython/MemberMappingTests.cs | 5 +- tests/ironpython/MemberOverloadTest.cs | 7 +- tests/ironpython/MethodParametersStubs.cs | 8 +- tests/ironpython/NullableTest.cs | 13 +- tests/ironpython/OperatorTest.cs | 1 - tests/ironpython/ProtocolTest.cs | 1 - tests/ironpython/StaticTest.cs | 12 +- tests/ironpython/Stress/Engine.cs | 5 +- tests/ironpython/StringDictionaryStorage.cs | 9 +- tests/ironpython/TestBuiltinModule.cs | 6 +- tests/ironpython/TypeDescriptor.cs | 2 +- tests/ironpython/Util/IniParser.cs | 10 +- tests/ironpython/Util/TestManifest.cs | 4 + 500 files changed, 105771 insertions(+), 94636 deletions(-) diff --git a/src/console/IronPython.Console.Host/IronPythonWindow.cs b/src/console/IronPython.Console.Host/IronPythonWindow.cs index 92f31110d..4bd2a22fc 100644 --- a/src/console/IronPython.Console.Host/IronPythonWindow.cs +++ b/src/console/IronPython.Console.Host/IronPythonWindow.cs @@ -5,10 +5,8 @@ using System; using System.Text; using System.Windows.Forms; - using IronPython.Hosting; using IronPython.Runtime; - using Microsoft.Scripting.Hosting; using Microsoft.Scripting.Hosting.Providers; using Microsoft.Scripting.Hosting.Shell; diff --git a/src/extensions/IronPython.SQLite/Connection.cs b/src/extensions/IronPython.SQLite/Connection.cs index 3ab5bb0ff..65e5e9361 100644 --- a/src/extensions/IronPython.SQLite/Connection.cs +++ b/src/extensions/IronPython.SQLite/Connection.cs @@ -8,37 +8,42 @@ using System; using System.Collections; using System.Collections.Generic; - +using System.Runtime.InteropServices; +using System.Threading; using Community.CsharpSqlite; - using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; - using Microsoft.Scripting; using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; using sqlite3_stmt = Community.CsharpSqlite.Sqlite3.Vdbe; using sqlite3_value = Community.CsharpSqlite.Sqlite3.Mem; -namespace IronPython.SQLite { - public static partial class PythonSQLite { +namespace IronPython.SQLite +{ + public static partial class PythonSQLite + { [PythonType] - public class Connection { + public class Connection + { public bool autocommit = false; public int total_changes { get { return Sqlite3.sqlite3_total_changes(this.db); } } - + public int detect_types { get; set; } public bool check_same_thread { get; set; } private double _timeout; - public double timeout { + public double timeout + { get { return _timeout; } set { _timeout = value; Sqlite3.sqlite3_busy_timeout(this.db, (int)(_timeout * 1000)); } } private string _isolation_level; - public string isolation_level { + public string isolation_level + { get { return _isolation_level; } set { setIsolationLevel(value); } } @@ -60,7 +65,7 @@ public string isolation_level { internal bool inTransaction = false; internal int thread_ident = Environment.CurrentManagedThreadId; - private static readonly Dictionary emptyKwargs = new Dictionary(); + private static readonly Dictionary emptyKwargs= new Dictionary(); public PythonType Warning = PythonSQLite.Warning; public PythonType Error = PythonSQLite.Error; @@ -73,21 +78,23 @@ public string isolation_level { public PythonType ProgrammingError = PythonSQLite.ProgrammingError; public PythonType NotSupportedError = PythonSQLite.NotSupportedError; - private enum AllStatmentsAction { + private enum AllStatmentsAction + { Reset, Finalize } public Connection(string database, - double timeout = 0.0, - int detect_types = 0, - string isolation_level = null, - bool check_same_thread = true, - object factory = null, - int cached_statements = 0) { + double timeout=0.0, + int detect_types=0, + string isolation_level=null, + bool check_same_thread=true, + object factory=null, + int cached_statements=0) + { this.text_factory = typeof(string); int rc = Sqlite3.sqlite3_open(database, out this.db); - if (rc != Sqlite3.SQLITE_OK) + if(rc != Sqlite3.SQLITE_OK) throw GetSqliteError(this.db, null); setIsolationLevel(isolation_level ?? ""); @@ -97,135 +104,150 @@ public Connection(string database, this.check_same_thread = check_same_thread; } - ~Connection() { - if (this.db != null) + ~Connection() + { + if(this.db != null) Sqlite3.sqlite3_close(this.db); } [Documentation("Closes the connection.")] - public void close() { + public void close() + { checkThread(); doAllStatements(AllStatmentsAction.Finalize); - if (this.db != null) { + if(this.db != null) + { int rc = Sqlite3.SQLITE_OK, i = 0; - - do { + + do + { rc = Sqlite3.sqlite3_close(this.db); - if (rc == Sqlite3.SQLITE_BUSY) { + if(rc == Sqlite3.SQLITE_BUSY) + { GC.Collect(); GC.WaitForPendingFinalizers(); } - } while (rc == Sqlite3.SQLITE_BUSY && i++ < 3); + } while(rc == Sqlite3.SQLITE_BUSY && i++ < 3); - if (rc != Sqlite3.SQLITE_OK) + if(rc != Sqlite3.SQLITE_OK) throw GetSqliteError(this.db, null); this.db = null; } } - internal void begin() { + internal void begin() + { sqlite3_stmt statement = null; string tail = null; int rc = Sqlite3.sqlite3_prepare(this.db, this.begin_statement, -1, ref statement, ref tail); - if (rc != Sqlite3.SQLITE_OK) + if(rc != Sqlite3.SQLITE_OK) throw GetSqliteError(this.db, statement); rc = Util.Step(statement); - if (rc == Sqlite3.SQLITE_DONE) + if(rc == Sqlite3.SQLITE_DONE) this.inTransaction = true; else throw GetSqliteError(this.db, statement); rc = Sqlite3.sqlite3_finalize(statement); - if (rc != Sqlite3.SQLITE_OK) + if(rc != Sqlite3.SQLITE_OK) GetSqliteError(this.db, null); } [Documentation("Commit the current transaction.")] - public void commit() { + public void commit() + { checkThread(); checkConnection(); - if (inTransaction) { + if(inTransaction) + { sqlite3_stmt statement = null; string tail = null; int rc = Sqlite3.sqlite3_prepare(this.db, "COMMIT", -1, ref statement, ref tail); - if (rc != Sqlite3.SQLITE_OK) + if(rc != Sqlite3.SQLITE_OK) throw GetSqliteError(this.db, null); rc = Util.Step(statement); - if (rc == Sqlite3.SQLITE_DONE) + if(rc == Sqlite3.SQLITE_DONE) this.inTransaction = false; else throw GetSqliteError(this.db, statement); rc = Sqlite3.sqlite3_finalize(statement); - if (rc != Sqlite3.SQLITE_OK) + if(rc != Sqlite3.SQLITE_OK) GetSqliteError(this.db, null); } } [Documentation("Roll back the current transaction.")] - public void rollback() { + public void rollback() + { checkThread(); checkConnection(); - if (inTransaction) { + if(inTransaction) + { doAllStatements(AllStatmentsAction.Reset); sqlite3_stmt statement = null; string tail = null; int rc = Sqlite3.sqlite3_prepare(this.db, "ROLLBACK", -1, ref statement, ref tail); - if (rc != Sqlite3.SQLITE_OK) + if(rc != Sqlite3.SQLITE_OK) throw GetSqliteError(this.db, null); rc = Util.Step(statement); - if (rc == Sqlite3.SQLITE_DONE) + if(rc == Sqlite3.SQLITE_DONE) this.inTransaction = false; else throw GetSqliteError(this.db, statement); rc = Sqlite3.sqlite3_finalize(statement); - if (rc != Sqlite3.SQLITE_OK) + if(rc != Sqlite3.SQLITE_OK) GetSqliteError(this.db, null); } } [Documentation("Return a cursor for the connection.")] - public object cursor(CodeContext context, object factory = null) { + public object cursor(CodeContext context, object factory=null) + { checkThread(); checkConnection(); object cursor = factory == null ? new Cursor(context, this) : PythonCalls.Call(context, factory, this); - if (this.row_factory != null) + if(this.row_factory != null) context.LanguageContext.Operations.SetMember(cursor, "row_factory", this.row_factory); return cursor; } [Documentation("Executes a SQL statement. Non-standard.")] - public object execute(CodeContext context, [ParamDictionary] IDictionary kwargs, params object[] args) { + public object execute(CodeContext context, [ParamDictionary]IDictionary kwargs, params object[] args) + { object c = cursor(context, null); object execute = context.LanguageContext.Operations.GetMember(c, "execute"); return PythonCalls.CallWithKeywordArgs(context, execute, args, kwargs); } [Documentation("Repeatedly executes a SQL statement. Non-standard.")] - public object executemany(CodeContext context, [ParamDictionary] IDictionary kwargs, params object[] args) { + public object executemany(CodeContext context, [ParamDictionary]IDictionary kwargs, params object[] args) + { object c = cursor(context, null); object executemany = context.LanguageContext.Operations.GetMember(c, "executemany"); return PythonCalls.CallWithKeywordArgs(context, executemany, args, kwargs); } [Documentation("Executes a multiple SQL statements at once. Non-standard.")] - public object executescript(CodeContext context, [ParamDictionary] IDictionary kwargs, params object[] args) { + public object executescript(CodeContext context, [ParamDictionary]IDictionary kwargs, params object[] args) + { object c = cursor(context, null); object executescript = context.LanguageContext.Operations.GetMember(c, "executescript"); return PythonCalls.CallWithKeywordArgs(context, executescript, args, kwargs); } - public object __call__(string sql) { + public object __call__(string sql) + { dropUnusedStatementReferences(); Statement statement = new Statement(this, sql); @@ -233,16 +255,17 @@ public object __call__(string sql) { return statement; } - private void dropUnusedStatementReferences() { - if (this.created_statements++ < 200) + private void dropUnusedStatementReferences() + { + if(this.created_statements++ < 200) return; this.created_statements = 0; List new_list = new List(); - foreach (WeakReference weakref in this.statements) - if (weakref.IsAlive) + foreach(WeakReference weakref in this.statements) + if(weakref.IsAlive) new_list.Add(weakref); this.statements = new_list; @@ -251,43 +274,51 @@ private void dropUnusedStatementReferences() { #region User functions [Documentation("Creates a new function. Non-standard.")] - public void create_function(CodeContext context, string name, int narg, object func) { - int rc = Sqlite3.sqlite3_create_function(this.db, - name, narg, - Sqlite3.SQLITE_ANY, - new object[] { context, func }, - callUserFunction, + public void create_function(CodeContext context, string name, int narg, object func) + { + int rc = Sqlite3.sqlite3_create_function(this.db, + name, narg, + Sqlite3.SQLITE_ANY, + new object[] { context, func }, + callUserFunction, null, null); - - if (rc != Sqlite3.SQLITE_OK) + + if(rc != Sqlite3.SQLITE_OK) throw MakeOperationalError("Error creating function"); else this.function_pinboard[func] = null; } - private static void callUserFunction(Sqlite3.sqlite3_context ctx, int argc, sqlite3_value[] argv) { + private static void callUserFunction(Sqlite3.sqlite3_context ctx, int argc, sqlite3_value[] argv) + { object[] data = (object[])Sqlite3.sqlite3_user_data(ctx); CodeContext context = (CodeContext)data[0]; object func = data[1]; object[] args = buildPyParams(context, ctx, argc, argv); - try { + try + { object result = PythonCalls.CallWithKeywordArgs(context, func, args, emptyKwargs); setResult(ctx, result); - } catch (Exception) { + } + catch(Exception) + { Sqlite3.sqlite3_result_error(ctx, "user-defined function raised exception", -1); } } - private static object[] buildPyParams(CodeContext context, Sqlite3.sqlite3_context ctx, int argc, sqlite3_value[] argv) { + private static object[] buildPyParams(CodeContext context, Sqlite3.sqlite3_context ctx, int argc, sqlite3_value[] argv) + { object[] args = new object[argc]; - for (int i = 0; i < argc; ++i) { + for(int i = 0; i < argc; ++i) + { sqlite3_value cur_value = argv[i]; object cur_py_value = null; - switch (Sqlite3.sqlite3_value_type(cur_value)) { + switch(Sqlite3.sqlite3_value_type(cur_value)) + { case Sqlite3.SQLITE_INTEGER: cur_py_value = (int)Sqlite3.sqlite3_value_int64(cur_value); break; @@ -316,28 +347,32 @@ private static object[] buildPyParams(CodeContext context, Sqlite3.sqlite3_conte return args; } - private static void setResult(Sqlite3.sqlite3_context ctx, object result) { - if (result == null) + private static void setResult(Sqlite3.sqlite3_context ctx, object result) + { + if(result == null) Sqlite3.sqlite3_result_null(ctx); - else if (result is bool) + else if(result is bool) Sqlite3.sqlite3_result_int64(ctx, ((bool)result) ? 1 : 0); - else if (result is int) + else if(result is int) Sqlite3.sqlite3_result_int64(ctx, (int)result); - else if (result is long) + else if(result is long) Sqlite3.sqlite3_result_int64(ctx, (long)result); else if (result is System.Numerics.BigInteger) Sqlite3.sqlite3_result_int64(ctx, (long)(System.Numerics.BigInteger)result); - else if (result is float) + else if(result is float) Sqlite3.sqlite3_result_double(ctx, (float)result); - else if (result is double) + else if(result is double) Sqlite3.sqlite3_result_double(ctx, (double)result); - else if (result is string) + else if(result is string) Sqlite3.sqlite3_result_text(ctx, (string)result, -1, Sqlite3.SQLITE_TRANSIENT); - else if (result is byte[]) { + else if(result is byte[]) + { byte[] b = (byte[])result; string s = Latin1.GetString(b, 0, b.Length); Sqlite3.sqlite3_result_blob(ctx, s, s.Length, Sqlite3.SQLITE_TRANSIENT); - } else { + } + else + { // TODO raise error } } @@ -346,44 +381,58 @@ private static void setResult(Sqlite3.sqlite3_context ctx, object result) { #region User aggregates - private class UserAggregateThunk { - public UserAggregateThunk(CodeContext context, string name, object aggregate_class) { + private class UserAggregateThunk + { + public UserAggregateThunk(CodeContext context, string name, object aggregate_class) + { this.context = context; this.aggregate_class = aggregate_class; this.name = name; } - public void stepCallback(Sqlite3.sqlite3_context ctx, int argc, sqlite3_value[] param) { - if (instance == null) { - try { + public void stepCallback(Sqlite3.sqlite3_context ctx, int argc, sqlite3_value[] param) + { + if(instance == null) + { + try + { instance = PythonCalls.Call(context, aggregate_class); - } catch (Exception) { + } + catch(Exception) + { Sqlite3.sqlite3_result_error(ctx, "user-defined aggregate's '__init__' method raised error", -1); return; } } - try { + try + { object step = context.LanguageContext.Operations.GetMember(instance, "step"); object[] args = buildPyParams(context, ctx, argc, param); PythonCalls.CallWithKeywordArgs(context, step, args, new Dictionary()); - } catch (Exception e) { - if (e is MissingMemberException) + } + catch(Exception e) + { + if(e is MissingMemberException) throw; Sqlite3.sqlite3_result_error(ctx, "user-defined aggregate's 'step' method raised error", -1); } } - public void finalCallback(Sqlite3.sqlite3_context ctx) { - if (instance == null) + public void finalCallback(Sqlite3.sqlite3_context ctx) + { + if(instance == null) return; - try { + try + { object function_result = context.LanguageContext.Operations.InvokeMember(instance, "finalize"); setResult(ctx, function_result); - } catch (Exception) { + } + catch(Exception) + { Sqlite3.sqlite3_result_error(ctx, "user-defined aggregate's 'finalize' method raised error", -1); } } @@ -395,7 +444,8 @@ public void finalCallback(Sqlite3.sqlite3_context ctx) { } [Documentation("Creates a new aggregate. Non-standard.")] - public void create_aggregate(CodeContext context, string name, int n_arg, object aggregate_class) { + public void create_aggregate(CodeContext context, string name, int n_arg, object aggregate_class) + { UserAggregateThunk thunk = new UserAggregateThunk(context, name, aggregate_class); int rc = Sqlite3.sqlite3_create_function(this.db, @@ -406,7 +456,7 @@ public void create_aggregate(CodeContext context, string name, int n_arg, object thunk.stepCallback, thunk.finalCallback); - if (rc != Sqlite3.SQLITE_OK) + if(rc != Sqlite3.SQLITE_OK) throw MakeOperationalError("Error creating aggregate"); else this.function_pinboard[aggregate_class] = null; @@ -415,37 +465,45 @@ public void create_aggregate(CodeContext context, string name, int n_arg, object #endregion [Documentation("Creates a collation function. Non-standard.")] - public void create_collation(params object[] args) { + public void create_collation(params object[] args) + { throw new NotImplementedException(); } [Documentation("Sets progress handler callback. Non-standard.")] - public void set_progress_handler(params object[] args) { + public void set_progress_handler(params object[] args) + { throw new NotImplementedException(); } [Documentation("Sets authorizer callback. Non-standard.")] - public void set_authorizer(params object[] args) { + public void set_authorizer(params object[] args) + { throw new NotImplementedException(); } [Documentation("For context manager. Non-standard.")] - public object __enter__() { + public object __enter__() + { return this; } [Documentation("For context manager. Non-standard.")] - public object __exit__(CodeContext context, object exc_type, object exc_value, object exc_tb) { + public object __exit__(CodeContext context, object exc_type, object exc_value, object exc_tb) + { DynamicOperations ops = context.LanguageContext.Operations; - if (exc_type == null && exc_value == null && exc_tb == null) { + if(exc_type == null && exc_value == null && exc_tb == null) + { object commitfn; - if (ops.TryGetMember(this, "commit", out commitfn)) + if(ops.TryGetMember(this, "commit", out commitfn)) ops.Invoke(commitfn); else commit(); - } else { + } + else + { object rollbackfn; - if (ops.TryGetMember(this, "rollback", out rollbackfn)) + if(ops.TryGetMember(this, "rollback", out rollbackfn)) ops.Invoke(rollbackfn); else rollback(); @@ -454,64 +512,77 @@ public object __exit__(CodeContext context, object exc_type, object exc_value, o return false; } - public object iterdump(CodeContext context) { + public object iterdump(CodeContext context) + { throw new NotImplementedException("Not supported with C#-sqlite for unknown reasons."); //var ops = context.LanguageContext.Operations; //PythonModule sqlite3 = Importer.ImportModule(context, context.GlobalScope, "sqlite3", false, -1) as PythonModule; //PythonModule dump = Importer.ImportFrom(context, sqlite3, "dump") as PythonModule; - + //object _iterdump = ops.GetMember(dump, "_iterdump"); //object result = ops.Invoke(_iterdump, this); //return result; } - internal void checkConnection() { - if (this.db == null) + internal void checkConnection() + { + if(this.db == null) throw MakeProgrammingError("Cannot operate on a closed database."); } - internal void checkThread() { - if (this.check_same_thread) - if (this.thread_ident != Environment.CurrentManagedThreadId) + internal void checkThread() + { + if(this.check_same_thread) + if(this.thread_ident != Environment.CurrentManagedThreadId) throw MakeProgrammingError("SQLite objects created in a thread can only be used in that same thread." + "The object was created in thread id {0} and this is thread id {1}".Format( this.thread_ident, Environment.CurrentManagedThreadId)); } - internal static void verify(Connection connection) { + internal static void verify(Connection connection) + { verify(connection, false); } - internal static void verify(Connection connection, bool closed) { - if (!closed && (connection == null || connection.db == null)) + internal static void verify(Connection connection, bool closed) + { + if(!closed && (connection == null || connection.db == null)) throw MakeProgrammingError("Cannot operate on a closed database."); connection.checkThread(); } - private void setIsolationLevel(string isolation_level) { + private void setIsolationLevel(string isolation_level) + { this.begin_statement = null; - if (isolation_level == null) { + if(isolation_level == null) + { this._isolation_level = null; this.commit(); this.inTransaction = false; - } else { + } + else + { this._isolation_level = isolation_level; this.begin_statement = "BEGIN " + isolation_level; } } - private void doAllStatements(AllStatmentsAction action) { - foreach (WeakReference weakref in this.statements) { - if (weakref.IsAlive) { + private void doAllStatements(AllStatmentsAction action) + { + foreach(WeakReference weakref in this.statements) + { + if(weakref.IsAlive) + { Statement statement = weakref.Target as Statement; - if (statement != null) { - if (action == AllStatmentsAction.Reset) + if(statement != null) + { + if(action == AllStatmentsAction.Reset) statement.Reset(); else statement.SqliteFinalize(); diff --git a/src/extensions/IronPython.SQLite/Contants.cs b/src/extensions/IronPython.SQLite/Contants.cs index ad65e4f3e..f3fe63263 100644 --- a/src/extensions/IronPython.SQLite/Contants.cs +++ b/src/extensions/IronPython.SQLite/Contants.cs @@ -7,8 +7,10 @@ using Community.CsharpSqlite; -namespace IronPython.SQLite { - public static partial class PythonSQLite { +namespace IronPython.SQLite +{ + public static partial class PythonSQLite + { public const int SQLITE_OK = Sqlite3.SQLITE_OK; public const int SQLITE_DENY = 1; diff --git a/src/extensions/IronPython.SQLite/Cursor.cs b/src/extensions/IronPython.SQLite/Cursor.cs index 4d90c8770..8570ad7ef 100644 --- a/src/extensions/IronPython.SQLite/Cursor.cs +++ b/src/extensions/IronPython.SQLite/Cursor.cs @@ -9,22 +9,24 @@ using System.Collections; using System.Collections.Generic; using System.Numerics; +using System.Runtime.InteropServices; using System.Text.RegularExpressions; - using Community.CsharpSqlite; - using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; - using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; using sqlite3_stmt = Community.CsharpSqlite.Sqlite3.Vdbe; -namespace IronPython.SQLite { - public static partial class PythonSQLite { +namespace IronPython.SQLite +{ + public static partial class PythonSQLite + { [PythonType] - public class Cursor : IEnumerable { + public class Cursor : IEnumerable + { public const string __doc__ = "SQLite database cursor class."; private Statement statement; @@ -38,8 +40,9 @@ public class Cursor : IEnumerable { public int rowcount { get; private set; } - public int? rownumber { - get { return null; } + public int? rownumber + { + get { return null; } } public BigInteger? lastrowid { get; private set; } @@ -50,54 +53,62 @@ public int? rownumber { public Connection connection { get; private set; } - public object callproc(string procname) { + public object callproc(string procname) + { throw PythonSQLite.MakeNotSupportedError(); } private CodeContext context; - public Cursor(CodeContext context, Connection connection) { + public Cursor(CodeContext context, Connection connection) + { this.context = context; this.connection = connection; this.arraysize = 1; this.rowcount = -1; - if (this.connection != null) + if(this.connection != null) this.connection.checkThread(); } - ~Cursor() { - if (this.statement != null) + ~Cursor() + { + if(this.statement != null) this.statement.Reset(); } [Documentation("Closes the cursor.")] - public void close() { + public void close() + { connection.checkThread(); connection.checkConnection(); - if (this.statement != null) { + if(this.statement != null) + { this.statement.Reset(); } } [Documentation("Executes a SQL statement.")] - public object execute(CodeContext context, object operation, object args = null) { + public object execute(CodeContext context, object operation, object args=null) + { return queryExecute(context, false, operation, args); } [Documentation("Repeatedly executes a SQL statement.")] - public object executemany(CodeContext context, object operation, object args) { + public object executemany(CodeContext context, object operation, object args) + { return queryExecute(context, true, operation, args); } - private object queryExecute(CodeContext context, bool multiple, object operation_obj, object args) { - if (!(operation_obj is string)) + private object queryExecute(CodeContext context, bool multiple, object operation_obj, object args) + { + if(!(operation_obj is string)) throw CreateThrowable(PythonExceptions.ValueError, "operation parameter must be str or unicode"); string operation = (string)operation_obj; - if (string.IsNullOrEmpty(operation)) + if(string.IsNullOrEmpty(operation)) return null; int rc; @@ -107,18 +118,21 @@ private object queryExecute(CodeContext context, bool multiple, object operation this.next_row = null; IEnumerator parameters_iter = null; - if (multiple) { - if (args != null) + if(multiple) + { + if(args != null) parameters_iter = PythonOps.CreatePythonEnumerator(context, args); - } else { + } + else + { object[] parameters_list = { args }; - if (parameters_list[0] == null) + if(parameters_list[0] == null) parameters_list[0] = new PythonTuple(); parameters_iter = parameters_list.GetEnumerator(); } - if (this.statement != null) + if(this.statement != null) rc = this.statement.Reset(); this.description = null; @@ -127,33 +141,35 @@ private object queryExecute(CodeContext context, bool multiple, object operation // TODO: use stmt cache instead ? this.statement = (Statement)this.connection.__call__(operation); - if (this.statement.in_use) + if(this.statement.in_use) this.statement = new Statement(connection, operation); this.statement.Reset(); this.statement.MarkDirty(); - if (!string.IsNullOrEmpty(connection.begin_statement)) { - switch (statement.StatementType) { + if(!string.IsNullOrEmpty(connection.begin_statement)) + { + switch(statement.StatementType) + { case StatementType.Update: case StatementType.Insert: case StatementType.Delete: case StatementType.Replace: - if (!connection.inTransaction) + if(!connection.inTransaction) connection.begin(); - + break; case StatementType.Other: // it's a DDL statement or something similar // we better COMMIT first so it works for all cases - if (connection.inTransaction) + if(connection.inTransaction) connection.commit(); break; case StatementType.Select: - if (multiple) + if(multiple) throw MakeProgrammingError("You cannot execute SELECT statements in executemany()."); break; @@ -162,8 +178,9 @@ private object queryExecute(CodeContext context, bool multiple, object operation } } - while (true) { - if (!parameters_iter.MoveNext()) + while(true) + { + if(!parameters_iter.MoveNext()) break; object parameters = parameters_iter.Current; @@ -171,35 +188,45 @@ private object queryExecute(CodeContext context, bool multiple, object operation this.statement.MarkDirty(); this.statement.BindParameters(context, parameters); - while (true) { + while(true) + { rc = this.statement.RawStep(); - if (rc == Sqlite3.SQLITE_DONE || rc == Sqlite3.SQLITE_ROW) + if(rc == Sqlite3.SQLITE_DONE || rc == Sqlite3.SQLITE_ROW) break; rc = this.statement.Reset(); - if (rc == Sqlite3.SQLITE_SCHEMA) { + if(rc == Sqlite3.SQLITE_SCHEMA) + { rc = this.statement.Recompile(context, parameters); - if (rc == Sqlite3.SQLITE_OK) { + if(rc == Sqlite3.SQLITE_OK) + { continue; - } else { + } + else + { this.statement.Reset(); throw GetSqliteError(this.connection.db, null); } - } else { + } + else + { this.statement.Reset(); throw GetSqliteError(this.connection.db, null); } } - if (!buildRowCastMap()) + if(!buildRowCastMap()) throw MakeOperationalError("Error while building row_cast_map"); - if (rc == Sqlite3.SQLITE_ROW || (rc == Sqlite3.SQLITE_DONE && this.statement.StatementType == StatementType.Select)) { - if (this.description == null) { + if(rc == Sqlite3.SQLITE_ROW || (rc == Sqlite3.SQLITE_DONE && this.statement.StatementType == StatementType.Select)) + { + if(this.description == null) + { int numcols = Sqlite3.sqlite3_column_count(this.statement.st); object[] new_description = new object[numcols]; - for (int i = 0; i < numcols; ++i) { + for(int i = 0; i < numcols; ++i) + { string name = buildColumnName(Sqlite3.sqlite3_column_name(this.statement.st, i)); object descriptor = new object[] { @@ -219,78 +246,98 @@ private object queryExecute(CodeContext context, bool multiple, object operation } } - if (rc == Sqlite3.SQLITE_ROW) { - if (multiple) + if(rc == Sqlite3.SQLITE_ROW) + { + if(multiple) throw MakeProgrammingError("executemany() can only execute DML statements."); this.next_row = fetchOneRow(context); - } else if (rc == Sqlite3.SQLITE_DONE && !multiple) { + } + else if(rc == Sqlite3.SQLITE_DONE && !multiple) + { this.statement.Reset(); } - switch (this.statement.StatementType) { + switch(this.statement.StatementType) + { case StatementType.Update: case StatementType.Delete: case StatementType.Insert: case StatementType.Replace: - if (this.rowcount == -1) + if(this.rowcount == -1) this.rowcount = 0; this.rowcount += Sqlite3.sqlite3_changes(this.connection.db); break; } - if (!multiple && this.statement.StatementType == StatementType.Insert) { + if(!multiple && this.statement.StatementType == StatementType.Insert) + { this.lastrowid = Sqlite3.sqlite3_last_insert_rowid(this.connection.db); - } else { + } + else + { this.lastrowid = null; } - if (multiple) + if(multiple) rc = this.statement.Reset(); } return this; } - private string buildColumnName(string colname) { + private string buildColumnName(string colname) + { int n = colname.IndexOf('['); return n < 0 ? colname : colname.Substring(0, n).Trim(); } - private object fetchOneRow(CodeContext context) { + private object fetchOneRow(CodeContext context) + { int numcols = Sqlite3.sqlite3_data_count(this.statement.st); object[] row = new object[numcols]; object converter = null; - for (int i = 0; i < numcols; ++i) { + for(int i = 0; i < numcols; ++i) + { object converted = null; - if (this.connection.detect_types != 0) { + if(this.connection.detect_types != 0) + { converter = row_cast_map[i]; - } else { + } + else + { converter = null; } - if (converter != null) { + if(converter != null) + { byte[] val = Sqlite3.sqlite3_column_blob(this.statement.st, i); - if (val == null) { + if(val == null) + { converted = null; - } else { + } + else + { string item = Latin1.GetString(val, 0, val.Length); converted = PythonCalls.Call(context, converter, item); } - } else { + } + else + { int coltype = Sqlite3.sqlite3_column_type(this.statement.st, i); - switch (coltype) { + switch(coltype) + { case Sqlite3.SQLITE_NULL: converted = null; break; case Sqlite3.SQLITE_INTEGER: long l = Sqlite3.sqlite3_column_int64(this.statement.st, i); - if (l < int.MinValue || l > int.MaxValue) + if(l < int.MinValue || l > int.MaxValue) converted = (BigInteger)l; else converted = (int)l; @@ -318,7 +365,8 @@ private object fetchOneRow(CodeContext context) { return new PythonTuple(row); } - public Cursor executescript(string operation) { + public Cursor executescript(string operation) + { connection.checkThread(); connection.checkConnection(); this.connection.commit(); @@ -326,8 +374,9 @@ public Cursor executescript(string operation) { sqlite3_stmt statement = null; string script = operation; bool statement_completed = false; - while (true) { - if (Sqlite3.sqlite3_complete(operation) == 0) + while(true) + { + if(Sqlite3.sqlite3_complete(operation) == 0) break; statement_completed = true; @@ -337,41 +386,46 @@ public Cursor executescript(string operation) { ref statement, ref script); - if (rc != Sqlite3.SQLITE_OK) + if(rc != Sqlite3.SQLITE_OK) throw GetSqliteError(this.connection.db, null); /* execute statement, and ignore results of SELECT statements */ rc = Sqlite3.SQLITE_ROW; - while (rc == Sqlite3.SQLITE_ROW) + while(rc == Sqlite3.SQLITE_ROW) rc = Sqlite3.sqlite3_step(statement); - if (rc != Sqlite3.SQLITE_DONE) { + if(rc != Sqlite3.SQLITE_DONE) + { Sqlite3.sqlite3_finalize(statement); throw GetSqliteError(this.connection.db, null); } rc = Sqlite3.sqlite3_finalize(statement); - if (rc != Sqlite3.SQLITE_OK) + if(rc != Sqlite3.SQLITE_OK) throw GetSqliteError(this.connection.db, null); } - if (!statement_completed) + if(!statement_completed) throw MakeProgrammingError("you did not provide a complete SQL statement"); return this; } - public object __iter__() { + public object __iter__() + { return this; } - public object __next__(CodeContext context) { + public object __next__(CodeContext context) + { object next_row_tuple, next_row; connection.checkThread(); connection.checkConnection(); - if (this.next_row == null) { - if (this.statement != null) { + if(this.next_row == null) + { + if(this.statement != null) + { this.statement.Reset(); this.statement = null; } @@ -382,20 +436,25 @@ public object __next__(CodeContext context) { next_row_tuple = this.next_row; this.next_row = null; - if (this.row_factory != null) { + if(this.row_factory != null) + { next_row = PythonCalls.Call(context, this.row_factory, this, next_row_tuple); - } else { + } + else + { next_row = next_row_tuple; } - if (this.statement != null) { + if(this.statement != null) + { int rc = this.statement.RawStep(); - if (rc != Sqlite3.SQLITE_DONE && rc != Sqlite3.SQLITE_ROW) { + if(rc != Sqlite3.SQLITE_DONE && rc != Sqlite3.SQLITE_ROW) + { this.statement.Reset(); throw GetSqliteError(this.connection.db, this.statement.st); } - if (rc == Sqlite3.SQLITE_ROW) + if(rc == Sqlite3.SQLITE_ROW) this.next_row = fetchOneRow(context); } @@ -403,33 +462,41 @@ public object __next__(CodeContext context) { } [Documentation("Fetches one row from the resultset.")] - public object fetchone(CodeContext context) { - try { + public object fetchone(CodeContext context) + { + try + { return this.__next__(context); - } catch (StopIterationException) { + } + catch(StopIterationException) + { return null; } } - public object fetchmany(CodeContext context) { + public object fetchmany(CodeContext context) + { return fetchmany(context, this.arraysize); } [Documentation("Fetches several rows from the resultset.")] - public object fetchmany(CodeContext context, int size) { + public object fetchmany(CodeContext context, int size) + { PythonList result = new PythonList(); object item = fetchone(context); - for (int i = 0; i < size && item != null; ++i, item = fetchone(context)) + for(int i = 0; i < size && item != null; ++i, item = fetchone(context)) result.Add(item); return result; } [Documentation("Fetches all rows from the resultset.")] - public object fetchall(CodeContext context) { + public object fetchall(CodeContext context) + { PythonList result = new PythonList(); object item = fetchone(context); - while (item != null) { + while(item != null) + { result.Add(item); item = fetchone(context); } @@ -437,7 +504,8 @@ public object fetchall(CodeContext context) { return result; } - public object nextset() { + public object nextset() + { return null; } @@ -447,34 +515,42 @@ public void setinputsizes(object sizes) { } [Documentation("Required by DB-API. Does nothing in IronPython.Sqlite3.")] public void setoutputsize(params object[] args) { } - private bool buildRowCastMap() { - if (this.connection.detect_types == 0) + private bool buildRowCastMap() + { + if(this.connection.detect_types == 0) return true; row_cast_map = new List(); object converter = null; - for (int i = 0; i < Sqlite3.sqlite3_column_count(this.statement.st); ++i) { + for(int i = 0; i < Sqlite3.sqlite3_column_count(this.statement.st); ++i) + { converter = null; - if ((this.connection.detect_types & PARSE_COLNAMES) != 0) { + if((this.connection.detect_types & PARSE_COLNAMES) != 0) + { string colname = Sqlite3.sqlite3_column_name(this.statement.st, i); - if (colname != null) { + if(colname != null) + { Regex matchColname = new Regex(@"\[(\w+)\]"); Match match = matchColname.Match(colname); - if (match.Success) { + if(match.Success) + { string key = match.Groups[1].ToString(); converter = getConverter(key); } } } - if ((converter == null) && ((this.connection.detect_types & PARSE_DECLTYPES) != 0)) { + if((converter == null) && ((this.connection.detect_types & PARSE_DECLTYPES) != 0)) + { string decltype = Sqlite3.sqlite3_column_decltype(this.statement.st, i); - if (decltype != null) { + if(decltype != null) + { Regex matchDecltype = new Regex(@"\b(\w+)\b"); Match match = matchDecltype.Match(decltype); - if (match.Success) { + if(match.Success) + { string py_decltype = match.Groups[1].ToString(); converter = getConverter(py_decltype); } @@ -487,19 +563,23 @@ private bool buildRowCastMap() { return true; } - private object getConverter(string key) { + private object getConverter(string key) + { object converter; return converters.TryGetValue(key.ToUpperInvariant(), out converter) ? converter : null; } #region IEnumerable Members - public IEnumerator GetEnumerator() { + public IEnumerator GetEnumerator() + { PythonList results = new PythonList(); - try { - while (true) + try + { + while(true) results.append(this.__next__(this.context)); - } catch (StopIterationException) { } + } + catch(StopIterationException) { } return results.GetEnumerator(); } diff --git a/src/extensions/IronPython.SQLite/Exceptions.cs b/src/extensions/IronPython.SQLite/Exceptions.cs index 978cf76e6..99117ae47 100644 --- a/src/extensions/IronPython.SQLite/Exceptions.cs +++ b/src/extensions/IronPython.SQLite/Exceptions.cs @@ -6,17 +6,18 @@ // using System; - using Community.CsharpSqlite; - using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -namespace IronPython.SQLite { - public static partial class PythonSQLite { - private static void InitModuleExceptions(PythonContext context, PythonDictionary dict) { +namespace IronPython.SQLite +{ + public static partial class PythonSQLite + { + private static void InitModuleExceptions(PythonContext context, PythonDictionary dict) + { Warning = context.EnsureModuleException("sqlite.Warning", PythonExceptions.Warning, dict, "Warning", "_sqlite3"); Error = context.EnsureModuleException("sqlite.Error", PythonExceptions.Exception, dict, "Error", "_sqlite3"); InterfaceError = context.EnsureModuleException("sqlite.InterfaceError", Error, dict, "InterfaceError", "_sqlite3"); @@ -30,65 +31,78 @@ private static void InitModuleExceptions(PythonContext context, PythonDictionary } public static PythonType Warning; - internal static Exception MakeWarning(params object[] args) { + internal static Exception MakeWarning(params object[] args) + { return CreateThrowable(Warning, args); } public static PythonType Error; - internal static Exception MakeError(params object[] args) { + internal static Exception MakeError(params object[] args) + { return CreateThrowable(Error, args); } public static PythonType InterfaceError; - internal static Exception MakeInterfaceError(params object[] args) { + internal static Exception MakeInterfaceError(params object[] args) + { return CreateThrowable(InterfaceError, args); } public static PythonType DatabaseError; - internal static Exception MakeDatabaseError(params object[] args) { + internal static Exception MakeDatabaseError(params object[] args) + { return CreateThrowable(DatabaseError, args); } public static PythonType DataError; - internal static Exception MakeDataError(params object[] args) { + internal static Exception MakeDataError(params object[] args) + { return CreateThrowable(DataError, args); } public static PythonType OperationalError; - internal static Exception MakeOperationalError(params object[] args) { + internal static Exception MakeOperationalError(params object[] args) + { return CreateThrowable(OperationalError, args); } public static PythonType IntegrityError; - internal static Exception MakeIntegrityError(params object[] args) { + internal static Exception MakeIntegrityError(params object[] args) + { return CreateThrowable(IntegrityError, args); } public static PythonType InternalError; - internal static Exception MakeInternalError(params object[] args) { + internal static Exception MakeInternalError(params object[] args) + { return CreateThrowable(InternalError, args); } public static PythonType ProgrammingError; - internal static Exception MakeProgrammingError(params object[] args) { + internal static Exception MakeProgrammingError(params object[] args) + { return CreateThrowable(ProgrammingError, args); } public static PythonType NotSupportedError; - internal static Exception MakeNotSupportedError(params object[] args) { + internal static Exception MakeNotSupportedError(params object[] args) + { return CreateThrowable(NotSupportedError, args); } - internal static Exception GetSqliteError(Sqlite3.sqlite3 db, Sqlite3.Vdbe st) { + internal static Exception GetSqliteError(Sqlite3.sqlite3 db, Sqlite3.Vdbe st) + { /* SQLite often doesn't report anything useful, unless you reset the statement first */ - if (st != null) { + if(st != null) + { Sqlite3.sqlite3_reset(st); } int errorcode = Sqlite3.sqlite3_errcode(db); string errmsg = Sqlite3.sqlite3_errmsg(db); - switch (errorcode) { + switch(errorcode) + { case SQLITE_OK: return null; @@ -132,7 +146,8 @@ internal static Exception GetSqliteError(Sqlite3.sqlite3 db, Sqlite3.Vdbe st) { } } - private static Exception CreateThrowable(PythonType type, params object[] args) { + private static Exception CreateThrowable(PythonType type, params object[] args) + { return PythonOps.CreateThrowable(type, args); } } diff --git a/src/extensions/IronPython.SQLite/Extensions.cs b/src/extensions/IronPython.SQLite/Extensions.cs index 2f556d5e1..40c1cf389 100644 --- a/src/extensions/IronPython.SQLite/Extensions.cs +++ b/src/extensions/IronPython.SQLite/Extensions.cs @@ -5,13 +5,17 @@ // Copyright (c) Jeff Hardy 2010-2012. // -namespace IronPython.SQLite { - internal static class StringExtensions { - public static string Format(this string format, params object[] args) { +namespace IronPython.SQLite +{ + internal static class StringExtensions + { + public static string Format(this string format, params object[] args) + { return string.Format(format, args); } - public static bool IsNullOrEmpty(this string value) { + public static bool IsNullOrEmpty(this string value) + { return string.IsNullOrEmpty(value); } } diff --git a/src/extensions/IronPython.SQLite/Properties/AssemblyInfo.cs b/src/extensions/IronPython.SQLite/Properties/AssemblyInfo.cs index 78ec08d19..e1fc294d1 100644 --- a/src/extensions/IronPython.SQLite/Properties/AssemblyInfo.cs +++ b/src/extensions/IronPython.SQLite/Properties/AssemblyInfo.cs @@ -1,4 +1,5 @@ using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; diff --git a/src/extensions/IronPython.SQLite/Row.cs b/src/extensions/IronPython.SQLite/Row.cs index baef4eb67..75215ced7 100644 --- a/src/extensions/IronPython.SQLite/Row.cs +++ b/src/extensions/IronPython.SQLite/Row.cs @@ -6,52 +6,65 @@ // using System; -using System.Collections; - +using System.Collections.Generic; +using System.Linq; +using System.Text; using IronPython.Runtime; +using System.Collections; using IronPython.Runtime.Exceptions; -namespace IronPython.SQLite { - public static partial class PythonSQLite { +namespace IronPython.SQLite +{ + public static partial class PythonSQLite + { [PythonType] - public class Row : IEnumerable { + public class Row : IEnumerable + { private PythonTuple data; private PythonTuple description; - public Row(Cursor cursor, PythonTuple data) { + public Row(Cursor cursor, PythonTuple data) + { this.data = data; this.description = cursor.description; } - public override bool Equals(object obj) { + public override bool Equals(object obj) + { Row other = obj as Row; - if (other == null) + if(other == null) return false; - if (object.ReferenceEquals(this, other)) + if(object.ReferenceEquals(this, other)) return true; return this.description.Equals(other.description) && this.data.Equals(other.data); } - public override int GetHashCode() { + public override int GetHashCode() + { return description.GetHashCode() ^ data.GetHashCode(); } - public object __iter__() { + public object __iter__() + { return data; } - public object this[long i] { + public object this[long i] + { get { return this.data[i]; } } - public object this[string s] { - get { - for (int i = 0; i < data.Count; ++i) { + public object this[string s] + { + get + { + for(int i = 0; i < data.Count; ++i) + { PythonTuple col_desc = (PythonTuple)description[i]; - if (s.Equals((string)col_desc[0], StringComparison.OrdinalIgnoreCase)) + if(s.Equals((string)col_desc[0], StringComparison.OrdinalIgnoreCase)) return data[i]; } @@ -59,10 +72,12 @@ public object this[string s] { } } - public PythonList keys() { + public PythonList keys() + { PythonList list = new PythonList(); - for (int i = 0; i < data.Count; ++i) { + for(int i = 0; i < data.Count; ++i) + { list.append(((PythonTuple)description[i])[0]); } @@ -71,7 +86,8 @@ public PythonList keys() { #region IEnumerable Members - public IEnumerator GetEnumerator() { + public IEnumerator GetEnumerator() + { return data.GetEnumerator(); } diff --git a/src/extensions/IronPython.SQLite/Statement.cs b/src/extensions/IronPython.SQLite/Statement.cs index 8eb121ec6..373787b47 100644 --- a/src/extensions/IronPython.SQLite/Statement.cs +++ b/src/extensions/IronPython.SQLite/Statement.cs @@ -8,17 +8,17 @@ using System; using System.Collections; using System.Diagnostics; - using Community.CsharpSqlite; - using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; using sqlite3_stmt = Community.CsharpSqlite.Sqlite3.Vdbe; -namespace IronPython.SQLite { - internal enum StatementType { +namespace IronPython.SQLite +{ + internal enum StatementType + { Unknown, Select, Insert, @@ -29,7 +29,8 @@ internal enum StatementType { } [DebuggerDisplay("{sql}")] - internal class Statement { + internal class Statement + { private readonly Guid uniqueid; private Sqlite3.sqlite3 db; internal sqlite3_stmt st; @@ -42,7 +43,8 @@ internal class Statement { public string Tail { get; private set; } - public Statement(PythonSQLite.Connection connection, string operation) { + public Statement(PythonSQLite.Connection connection, string operation) + { this.uniqueid = Guid.NewGuid(); this.db = connection.db; @@ -50,7 +52,8 @@ public Statement(PythonSQLite.Connection connection, string operation) { this.st = null; string tail = null; - if (Sqlite3.sqlite3_prepare(this.db, this.sql, -1, ref this.st, ref tail) != Sqlite3.SQLITE_OK /*TODO: || too much sql */) { + if(Sqlite3.sqlite3_prepare(this.db, this.sql, -1, ref this.st, ref tail) != Sqlite3.SQLITE_OK /*TODO: || too much sql */) + { Sqlite3.sqlite3_finalize(st); this.st = null; throw PythonSQLite.GetSqliteError(this.db, null); @@ -59,7 +62,8 @@ public Statement(PythonSQLite.Connection connection, string operation) { this.Tail = tail; } - private Statement(Sqlite3.sqlite3 db, sqlite3_stmt stmt, string operation, string tail) { + private Statement(Sqlite3.sqlite3 db, sqlite3_stmt stmt, string operation, string tail) + { this.uniqueid = Guid.NewGuid(); this.db = db; @@ -69,8 +73,10 @@ private Statement(Sqlite3.sqlite3 db, sqlite3_stmt stmt, string operation, strin this.Tail = tail; } - ~Statement() { - if (this.st != null) { + ~Statement() + { + if(this.st != null) + { Sqlite3.sqlite3_finalize(this.st); } @@ -78,22 +84,24 @@ private Statement(Sqlite3.sqlite3 db, sqlite3_stmt stmt, string operation, strin } private StatementType _type = StatementType.Unknown; - public StatementType StatementType { - get { - if (this._type != StatementType.Unknown) + public StatementType StatementType + { + get + { + if(this._type != StatementType.Unknown) return _type; string s = this.sql.TrimStart(); - if (s.StartsWith("select", StringComparison.InvariantCultureIgnoreCase)) + if(s.StartsWith("select", StringComparison.InvariantCultureIgnoreCase)) this._type = StatementType.Select; - else if (s.StartsWith("insert", StringComparison.InvariantCultureIgnoreCase)) + else if(s.StartsWith("insert", StringComparison.InvariantCultureIgnoreCase)) this._type = StatementType.Insert; - else if (s.StartsWith("update", StringComparison.InvariantCultureIgnoreCase)) + else if(s.StartsWith("update", StringComparison.InvariantCultureIgnoreCase)) this._type = StatementType.Update; - else if (s.StartsWith("delete", StringComparison.InvariantCultureIgnoreCase)) + else if(s.StartsWith("delete", StringComparison.InvariantCultureIgnoreCase)) this._type = StatementType.Delete; - else if (s.StartsWith("replace", StringComparison.InvariantCultureIgnoreCase)) + else if(s.StartsWith("replace", StringComparison.InvariantCultureIgnoreCase)) this._type = StatementType.Replace; else this._type = StatementType.Other; @@ -102,22 +110,24 @@ public StatementType StatementType { } } - public void BindParameters(CodeContext context, object parameters) { - if (bound) + public void BindParameters(CodeContext context, object parameters) + { + if(bound) this.ClearParameters(); int num_params_needed = Sqlite3.sqlite3_bind_parameter_count(this.st); - if (parameters == null) { - if (num_params_needed > 0) + if(parameters == null) + { + if(num_params_needed > 0) throw PythonSQLite.MakeProgrammingError("parameters are required but not specified."); else return; } - if (parameters is IDictionary) + if(parameters is IDictionary) BindParameters(context, (IDictionary)parameters, num_params_needed); - else if (parameters is IList) + else if(parameters is IList) BindParameters(context, (IList)parameters, num_params_needed); else throw PythonSQLite.MakeProgrammingError("unknown parameter type"); @@ -125,65 +135,72 @@ public void BindParameters(CodeContext context, object parameters) { bound = true; } - private void BindParameters(CodeContext context, IDictionary args, int num_params_needed) { - for (int i = 1; i <= num_params_needed; ++i) { + private void BindParameters(CodeContext context, IDictionary args, int num_params_needed) + { + for(int i = 1; i <= num_params_needed; ++i) + { string binding_name = Sqlite3.sqlite3_bind_parameter_name(this.st, i); - if (string.IsNullOrEmpty(binding_name)) + if(string.IsNullOrEmpty(binding_name)) throw PythonSQLite.MakeProgrammingError("Binding {0} has no name, but you supplied a dictionary (which has only names).".Format(i)); // remove the leading colon binding_name = binding_name.Substring(1); - if (args.Contains(binding_name)) + if(args.Contains(binding_name)) BindParameter(context, i, maybeAdapt(context, args[binding_name])); else throw PythonSQLite.MakeProgrammingError("You did not supply a value for binding {0}.".Format(i)); } } - private void BindParameters(CodeContext context, IList args, int num_params_needed) { - if (num_params_needed != args.Count) + private void BindParameters(CodeContext context, IList args, int num_params_needed) + { + if(num_params_needed != args.Count) throw PythonSQLite.MakeProgrammingError("Incorrect number of bindings supplied."); - for (int i = 0; i < args.Count; ++i) { + for(int i = 0; i < args.Count; ++i) + { BindParameter(context, i + 1, maybeAdapt(context, args[i])); } } - private void BindParameter(CodeContext context, int index, object arg) { + private void BindParameter(CodeContext context, int index, object arg) + { int rc; - if (arg == null) + if(arg == null) rc = Sqlite3.sqlite3_bind_null(st, index); - else if (arg is int) + else if(arg is int) rc = Sqlite3.sqlite3_bind_int(st, index, (int)arg); - else if (arg is bool) + else if(arg is bool) rc = Sqlite3.sqlite3_bind_int(st, index, (bool)arg ? 1 : 0); - else if (arg is long) + else if(arg is long) rc = Sqlite3.sqlite3_bind_int64(st, index, (long)arg); else if (arg is System.Numerics.BigInteger) rc = Sqlite3.sqlite3_bind_int64(st, index, (long)((System.Numerics.BigInteger)arg)); - else if (arg is float) + else if(arg is float) rc = Sqlite3.sqlite3_bind_double(st, index, (float)arg); - else if (arg is double) + else if(arg is double) rc = Sqlite3.sqlite3_bind_double(st, index, (double)arg); - else if (arg is string) + else if(arg is string) rc = Sqlite3.sqlite3_bind_text(st, index, (string)arg, -1, Sqlite3.SQLITE_TRANSIENT); - else if (arg is byte[]) + else if(arg is byte[]) rc = Sqlite3.sqlite3_bind_blob(this.st, index, (byte[])arg, -1, Sqlite3.SQLITE_TRANSIENT); else throw PythonSQLite.MakeInterfaceError("Unable to bind parameter {0} - unsupported type {1}".Format(index, arg.GetType())); - if (rc != Sqlite3.SQLITE_OK) + if(rc != Sqlite3.SQLITE_OK) throw PythonSQLite.MakeInterfaceError("Unable to bind parameter {0}: {1}".Format(index, Sqlite3.sqlite3_errmsg(db))); } - private object maybeAdapt(CodeContext context, object value) { + private object maybeAdapt(CodeContext context, object value) + { return needsAdaptation(context, value) ? adaptValue(context, value) : value; } - private bool needsAdaptation(CodeContext context, object value) { + private bool needsAdaptation(CodeContext context, object value) + { // TODO The check for primitive types could probably be cached like pysqlite does - if (value == null || + if(value == null || value is int || value is bool || value is long || @@ -191,26 +208,31 @@ value is System.Numerics.BigInteger || value is float || value is double || value is string || - value is byte[]) { + value is byte[]) + { object proto = DynamicHelpers.GetPythonTypeFromType(typeof(PythonSQLite.PrepareProtocol)); object type = DynamicHelpers.GetPythonType(value); object key = new PythonTuple(new[] { type, proto }); return PythonSQLite.adapters.ContainsKey(key); - } else { + } + else + { return true; } } - private object adaptValue(CodeContext context, object value) { + private object adaptValue(CodeContext context, object value) + { object proto = DynamicHelpers.GetPythonTypeFromType(typeof(PythonSQLite.PrepareProtocol)); object type = DynamicHelpers.GetPythonType(value); object key = new PythonTuple(new[] { type, proto }); object adapter; - if (PythonSQLite.adapters.TryGetValue(key, out adapter)) { + if(PythonSQLite.adapters.TryGetValue(key, out adapter)) + { object adapted = PythonCalls.Call(context, adapter, value); return adapted; } @@ -218,9 +240,11 @@ private object adaptValue(CodeContext context, object value) { // TODO: Use proto? Any value whatsoever? object conform; - if (context.LanguageContext.Operations.TryGetMember(value, "__conform__", out conform)) { + if(context.LanguageContext.Operations.TryGetMember(value, "__conform__", out conform)) + { object adapted = PythonCalls.Call(context, conform, proto); - if (adapted != null) { + if(adapted != null) + { return adapted; } } @@ -228,14 +252,17 @@ private object adaptValue(CodeContext context, object value) { return value; } - public int RawStep() { + public int RawStep() + { return Util.Step(st); } - public int SqliteFinalize() { + public int SqliteFinalize() + { int rc = Sqlite3.SQLITE_OK; - if (this.st != null) { + if(this.st != null) + { rc = Sqlite3.sqlite3_finalize(this.st); this.st = null; } @@ -245,34 +272,40 @@ public int SqliteFinalize() { return rc; } - public int Reset() { + public int Reset() + { int rc = Sqlite3.SQLITE_OK; - if (this.in_use && this.st != null) { + if(this.in_use && this.st != null) + { rc = Sqlite3.sqlite3_reset(this.st); - if (rc == Sqlite3.SQLITE_OK) + if(rc == Sqlite3.SQLITE_OK) this.in_use = false; } return rc; } - private void ClearParameters() { - if (Sqlite3.sqlite3_clear_bindings(this.st) != Sqlite3.SQLITE_OK) + private void ClearParameters() + { + if(Sqlite3.sqlite3_clear_bindings(this.st) != Sqlite3.SQLITE_OK) throw PythonSQLite.GetSqliteError(this.db, null); } - internal void MarkDirty() { + internal void MarkDirty() + { this.in_use = true; } - internal int Recompile(CodeContext context, object parameters) { + internal int Recompile(CodeContext context, object parameters) + { sqlite3_stmt new_st = null; string tail = null; int rc = Sqlite3.sqlite3_prepare(this.db, this.sql, -1, ref new_st, ref tail); - if (rc == Sqlite3.SQLITE_OK) { + if(rc == Sqlite3.SQLITE_OK) + { Statement new_stmt = new Statement(this.st.db, new_st, this.sql, tail); new_stmt.BindParameters(context, parameters); diff --git a/src/extensions/IronPython.SQLite/Util.cs b/src/extensions/IronPython.SQLite/Util.cs index d0a370c5d..ab23d0b28 100644 --- a/src/extensions/IronPython.SQLite/Util.cs +++ b/src/extensions/IronPython.SQLite/Util.cs @@ -7,10 +7,13 @@ using Community.CsharpSqlite; -namespace IronPython.SQLite { - internal static class Util { - public static int Step(Sqlite3.Vdbe statement) { - if (statement == null) +namespace IronPython.SQLite +{ + internal static class Util + { + public static int Step(Sqlite3.Vdbe statement) + { + if(statement == null) return Sqlite3.SQLITE_OK; else return Sqlite3.sqlite3_step(statement); diff --git a/src/extensions/IronPython.SQLite/_sqlite.cs b/src/extensions/IronPython.SQLite/_sqlite.cs index 9d62d6b28..732a93db3 100644 --- a/src/extensions/IronPython.SQLite/_sqlite.cs +++ b/src/extensions/IronPython.SQLite/_sqlite.cs @@ -7,20 +7,21 @@ using System; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; using System.Text; - using Community.CsharpSqlite; - using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; - using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; [assembly: PythonModule("_sqlite3", typeof(IronPython.SQLite.PythonSQLite))] -namespace IronPython.SQLite { - public static partial class PythonSQLite { +namespace IronPython.SQLite +{ + public static partial class PythonSQLite + { public static readonly string version = typeof(PythonSQLite).Assembly.GetName().Version.ToString(3); public static readonly string sqlite_version = Sqlite3.sqlite3_version.Replace("(C#)", ""); @@ -32,19 +33,21 @@ public static partial class PythonSQLite { internal static Encoding Latin1 = Encoding.GetEncoding("iso-8859-1"); [SpecialName] - public static void PerformModuleReload(PythonContext context, PythonDictionary dict) { + public static void PerformModuleReload(PythonContext context, PythonDictionary dict) + { InitModuleExceptions(context, dict); } public static object connect(CodeContext context, string database, - double timeout = 0.0, - int detect_types = 0, - string isolation_level = null, - bool check_same_thread = true, - object factory = null, - int cached_statements = 0) { - if (factory == null) + double timeout=0.0, + int detect_types=0, + string isolation_level=null, + bool check_same_thread=true, + object factory=null, + int cached_statements=0) + { + if(factory == null) return new Connection(database, timeout, detect_types, isolation_level, check_same_thread, factory, cached_statements); else return PythonCalls.Call(context, factory, database, timeout, detect_types, isolation_level, check_same_thread, factory, cached_statements); @@ -53,7 +56,8 @@ public static object connect(CodeContext context, [Documentation(@"register_adapter(type, callable) Registers an adapter with pysqlite's adapter registry. Non-standard.")] - public static void register_adapter(CodeContext context, PythonType type, object adapter) { + public static void register_adapter(CodeContext context, PythonType type, object adapter) + { object proto = DynamicHelpers.GetPythonTypeFromType(typeof(PrepareProtocol)); object key = new PythonTuple(new object[] { type, proto }); adapters[key] = adapter; @@ -62,7 +66,8 @@ public static void register_adapter(CodeContext context, PythonType type, object [Documentation(@"register_converter(typename, callable) Registers a converter with pysqlite. Non-standard.")] - public static void register_converter(CodeContext context, string type, object converter) { + public static void register_converter(CodeContext context, string type, object converter) + { converters[type.ToUpperInvariant()] = converter; } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/BtreeInt_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/BtreeInt_h.cs index 064daab41..e68d86db3 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/BtreeInt_h.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/BtreeInt_h.cs @@ -3,499 +3,515 @@ using i16 = System.Int16; using i64 = System.Int64; -using Pgno = System.UInt32; -using sqlite3_int64 = System.Int64; +using u8 = System.Byte; using u16 = System.UInt16; using u32 = System.UInt32; -using u8 = System.Byte; +using u64 = System.UInt64; -namespace Community.CsharpSqlite { - using DbPage = Sqlite3.PgHdr; - - public partial class Sqlite3 { - /* - ** 2004 April 6 - ** - ** 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 implements a external (disk-based) database using BTrees. - ** For a detailed discussion of BTrees, refer to - ** - ** Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3: - ** "Sorting And Searching", pages 473-480. Addison-Wesley - ** Publishing Company, Reading, Massachusetts. - ** - ** The basic idea is that each page of the file contains N database - ** entries and N+1 pointers to subpages. - ** - ** ---------------------------------------------------------------- - ** | Ptr(0) | Key(0) | Ptr(1) | Key(1) | ... | Key(N-1) | Ptr(N) | - ** ---------------------------------------------------------------- - ** - ** All of the keys on the page that Ptr(0) points to have values less - ** than Key(0). All of the keys on page Ptr(1) and its subpages have - ** values greater than Key(0) and less than Key(1). All of the keys - ** on Ptr(N) and its subpages have values greater than Key(N-1). And - ** so forth. - ** - ** Finding a particular key requires reading O(log(M)) pages from the - ** disk where M is the number of entries in the tree. - ** - ** In this implementation, a single file can hold one or more separate - ** BTrees. Each BTree is identified by the index of its root page. The - ** key and data for any entry are combined to form the "payload". A - ** fixed amount of payload can be carried directly on the database - ** page. If the payload is larger than the preset amount then surplus - ** bytes are stored on overflow pages. The payload for an entry - ** and the preceding pointer are combined to form a "Cell". Each - ** page has a small header which contains the Ptr(N) pointer and other - ** information such as the size of key and data. - ** - ** FORMAT DETAILS - ** - ** The file is divided into pages. The first page is called page 1, - ** the second is page 2, and so forth. A page number of zero indicates - ** "no such page". The page size can be any power of 2 between 512 and 65536. - ** Each page can be either a btree page, a freelist page, an overflow - ** page, or a pointer-map page. - ** - ** The first page is always a btree page. The first 100 bytes of the first - ** 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. - ** 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 - ** 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 - ** - ** 40 4 Schema cookie - ** 44 4 File format of schema layer - ** 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 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 - ** and thus when they need to flush their cache. - ** - ** The max embedded payload fraction is the amount of the total usable - ** space in a page that can be consumed by a single cell for standard - ** B-tree (non-LEAFDATA) tables. A value of 255 means 100%. The default - ** is to limit the maximum cell size so that at least 4 cells will fit - ** on one page. Thus the default max embedded payload fraction is 64. - ** - ** If the payload for a cell is larger than the max payload, then extra - ** payload is spilled to overflow pages. Once an overflow page is allocated, - ** as many bytes as possible are moved into the overflow pages without letting - ** the cell size drop below the min embedded payload fraction. - ** - ** The min leaf payload fraction is like the min embedded payload fraction - ** except that it applies to leaf nodes in a LEAFDATA tree. The maximum - ** payload fraction for a LEAFDATA tree is always 100% (or 255) and it - ** not specified in the header. - ** - ** Each btree pages is divided into three sections: The header, the - ** cell pointer array, and the cell content area. Page 1 also has a 100-byte - ** file header that occurs before the page header. - ** - ** |----------------| - ** | file header | 100 bytes. Page 1 only. - ** |----------------| - ** | page header | 8 bytes for leaves. 12 bytes for interior nodes - ** |----------------| - ** | cell pointer | | 2 bytes per cell. Sorted order. - ** | array | | Grows downward - ** | | v - ** |----------------| - ** | unallocated | - ** | space | - ** |----------------| ^ Grows upwards - ** | cell content | | Arbitrary order interspersed with freeblocks. - ** | area | | and free space fragments. - ** |----------------| - ** - ** The page headers looks like this: - ** - ** OFFSET SIZE DESCRIPTION - ** 0 1 Flags. 1: intkey, 2: zerodata, 4: leafdata, 8: leaf - ** 1 2 byte offset to the first freeblock - ** 3 2 number of cells on this page - ** 5 2 first byte of the cell content area - ** 7 1 number of fragmented free bytes - ** 8 4 Right child (the Ptr(N) value). Omitted on leaves. - ** - ** The flags define the format of this btree page. The leaf flag means that - ** this page has no children. The zerodata flag means that this page carries - ** only keys and no data. The intkey flag means that the key is a integer - ** which is stored in the key size entry of the cell header rather than in - ** the payload area. - ** - ** The cell pointer array begins on the first byte after the page header. - ** The cell pointer array contains zero or more 2-byte numbers which are - ** offsets from the beginning of the page to the cell content in the cell - ** content area. The cell pointers occur in sorted order. The system strives - ** to keep free space after the last cell pointer so that new cells can - ** be easily added without having to defragment the page. - ** - ** Cell content is stored at the very end of the page and grows toward the - ** beginning of the page. - ** - ** Unused space within the cell content area is collected into a linked list of - ** freeblocks. Each freeblock is at least 4 bytes in size. The byte offset - ** to the first freeblock is given in the header. Freeblocks occur in - ** increasing order. Because a freeblock must be at least 4 bytes in size, - ** any group of 3 or fewer unused bytes in the cell content area cannot - ** exist on the freeblock chain. A group of 3 or fewer free bytes is called - ** a fragment. The total number of bytes in all fragments is recorded. - ** in the page header at offset 7. - ** - ** SIZE DESCRIPTION - ** 2 Byte offset of the next freeblock - ** 2 Bytes in this freeblock - ** - ** Cells are of variable length. Cells are stored in the cell content area at - ** the end of the page. Pointers to the cells are in the cell pointer array - ** that immediately follows the page header. Cells is not necessarily - ** contiguous or in order, but cell pointers are contiguous and in order. - ** - ** Cell content makes use of variable length integers. A variable - ** length integer is 1 to 9 bytes where the lower 7 bits of each - ** byte are used. The integer consists of all bytes that have bit 8 set and - ** the first byte with bit 8 clear. The most significant byte of the integer - ** appears first. A variable-length integer may not be more than 9 bytes long. - ** As a special case, all 8 bytes of the 9th byte are used as data. This - ** allows a 64-bit integer to be encoded in 9 bytes. - ** - ** 0x00 becomes 0x00000000 - ** 0x7f becomes 0x0000007f - ** 0x81 0x00 becomes 0x00000080 - ** 0x82 0x00 becomes 0x00000100 - ** 0x80 0x7f becomes 0x0000007f - ** 0x8a 0x91 0xd1 0xac 0x78 becomes 0x12345678 - ** 0x81 0x81 0x81 0x81 0x01 becomes 0x10204081 - ** - ** Variable length integers are used for rowids and to hold the number of - ** bytes of key and data in a btree cell. - ** - ** The content of a cell looks like this: - ** - ** SIZE DESCRIPTION - ** 4 Page number of the left child. Omitted if leaf flag is set. - ** var Number of bytes of data. Omitted if the zerodata flag is set. - ** var Number of bytes of key. Or the key itself if intkey flag is set. - ** * Payload - ** 4 First page of the overflow chain. Omitted if no overflow - ** - ** Overflow pages form a linked list. Each page except the last is completely - ** filled with data (pagesize - 4 bytes). The last page can have as little - ** as 1 byte of data. - ** - ** SIZE DESCRIPTION - ** 4 Page number of next overflow page - ** * Data - ** - ** Freelist pages come in two subtypes: trunk pages and leaf pages. The - ** file header points to the first in a linked list of trunk page. Each trunk - ** page points to multiple leaf pages. The content of a leaf page is - ** unspecified. A trunk page looks like this: - ** - ** SIZE DESCRIPTION - ** 4 Page number of next trunk page - ** 4 Number of leaf pointers on this page - ** * zero or more pages numbers of leaves - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - - /* The following value is the maximum cell size assuming a maximum page - ** size give above. - */ - //#define MX_CELL_SIZE(pBt) ((int)(pBt->pageSize-8)) - static int MX_CELL_SIZE(BtShared pBt) { - return (int)(pBt.pageSize - 8); - } +using sqlite3_int64 = System.Int64; +using Pgno = System.UInt32; - /* The maximum number of cells on a single page of the database. This - ** assumes a minimum cell size of 6 bytes (4 bytes for the cell itself - ** plus 2 bytes for the index to the cell in the page header). Such - ** small cells will be rare, but they are possible. - */ - //#define MX_CELL(pBt) ((pBt.pageSize-8)/6) - static int MX_CELL(BtShared pBt) { - return ((int)(pBt.pageSize - 8) / 6); - } +namespace Community.CsharpSqlite +{ + using DbPage = Sqlite3.PgHdr; + + public partial class Sqlite3 + { + /* + ** 2004 April 6 + ** + ** 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 implements a external (disk-based) database using BTrees. + ** For a detailed discussion of BTrees, refer to + ** + ** Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3: + ** "Sorting And Searching", pages 473-480. Addison-Wesley + ** Publishing Company, Reading, Massachusetts. + ** + ** The basic idea is that each page of the file contains N database + ** entries and N+1 pointers to subpages. + ** + ** ---------------------------------------------------------------- + ** | Ptr(0) | Key(0) | Ptr(1) | Key(1) | ... | Key(N-1) | Ptr(N) | + ** ---------------------------------------------------------------- + ** + ** All of the keys on the page that Ptr(0) points to have values less + ** than Key(0). All of the keys on page Ptr(1) and its subpages have + ** values greater than Key(0) and less than Key(1). All of the keys + ** on Ptr(N) and its subpages have values greater than Key(N-1). And + ** so forth. + ** + ** Finding a particular key requires reading O(log(M)) pages from the + ** disk where M is the number of entries in the tree. + ** + ** In this implementation, a single file can hold one or more separate + ** BTrees. Each BTree is identified by the index of its root page. The + ** key and data for any entry are combined to form the "payload". A + ** fixed amount of payload can be carried directly on the database + ** page. If the payload is larger than the preset amount then surplus + ** bytes are stored on overflow pages. The payload for an entry + ** and the preceding pointer are combined to form a "Cell". Each + ** page has a small header which contains the Ptr(N) pointer and other + ** information such as the size of key and data. + ** + ** FORMAT DETAILS + ** + ** The file is divided into pages. The first page is called page 1, + ** the second is page 2, and so forth. A page number of zero indicates + ** "no such page". The page size can be any power of 2 between 512 and 65536. + ** Each page can be either a btree page, a freelist page, an overflow + ** page, or a pointer-map page. + ** + ** The first page is always a btree page. The first 100 bytes of the first + ** 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. + ** 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 + ** 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 + ** + ** 40 4 Schema cookie + ** 44 4 File format of schema layer + ** 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 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 + ** and thus when they need to flush their cache. + ** + ** The max embedded payload fraction is the amount of the total usable + ** space in a page that can be consumed by a single cell for standard + ** B-tree (non-LEAFDATA) tables. A value of 255 means 100%. The default + ** is to limit the maximum cell size so that at least 4 cells will fit + ** on one page. Thus the default max embedded payload fraction is 64. + ** + ** If the payload for a cell is larger than the max payload, then extra + ** payload is spilled to overflow pages. Once an overflow page is allocated, + ** as many bytes as possible are moved into the overflow pages without letting + ** the cell size drop below the min embedded payload fraction. + ** + ** The min leaf payload fraction is like the min embedded payload fraction + ** except that it applies to leaf nodes in a LEAFDATA tree. The maximum + ** payload fraction for a LEAFDATA tree is always 100% (or 255) and it + ** not specified in the header. + ** + ** Each btree pages is divided into three sections: The header, the + ** cell pointer array, and the cell content area. Page 1 also has a 100-byte + ** file header that occurs before the page header. + ** + ** |----------------| + ** | file header | 100 bytes. Page 1 only. + ** |----------------| + ** | page header | 8 bytes for leaves. 12 bytes for interior nodes + ** |----------------| + ** | cell pointer | | 2 bytes per cell. Sorted order. + ** | array | | Grows downward + ** | | v + ** |----------------| + ** | unallocated | + ** | space | + ** |----------------| ^ Grows upwards + ** | cell content | | Arbitrary order interspersed with freeblocks. + ** | area | | and free space fragments. + ** |----------------| + ** + ** The page headers looks like this: + ** + ** OFFSET SIZE DESCRIPTION + ** 0 1 Flags. 1: intkey, 2: zerodata, 4: leafdata, 8: leaf + ** 1 2 byte offset to the first freeblock + ** 3 2 number of cells on this page + ** 5 2 first byte of the cell content area + ** 7 1 number of fragmented free bytes + ** 8 4 Right child (the Ptr(N) value). Omitted on leaves. + ** + ** The flags define the format of this btree page. The leaf flag means that + ** this page has no children. The zerodata flag means that this page carries + ** only keys and no data. The intkey flag means that the key is a integer + ** which is stored in the key size entry of the cell header rather than in + ** the payload area. + ** + ** The cell pointer array begins on the first byte after the page header. + ** The cell pointer array contains zero or more 2-byte numbers which are + ** offsets from the beginning of the page to the cell content in the cell + ** content area. The cell pointers occur in sorted order. The system strives + ** to keep free space after the last cell pointer so that new cells can + ** be easily added without having to defragment the page. + ** + ** Cell content is stored at the very end of the page and grows toward the + ** beginning of the page. + ** + ** Unused space within the cell content area is collected into a linked list of + ** freeblocks. Each freeblock is at least 4 bytes in size. The byte offset + ** to the first freeblock is given in the header. Freeblocks occur in + ** increasing order. Because a freeblock must be at least 4 bytes in size, + ** any group of 3 or fewer unused bytes in the cell content area cannot + ** exist on the freeblock chain. A group of 3 or fewer free bytes is called + ** a fragment. The total number of bytes in all fragments is recorded. + ** in the page header at offset 7. + ** + ** SIZE DESCRIPTION + ** 2 Byte offset of the next freeblock + ** 2 Bytes in this freeblock + ** + ** Cells are of variable length. Cells are stored in the cell content area at + ** the end of the page. Pointers to the cells are in the cell pointer array + ** that immediately follows the page header. Cells is not necessarily + ** contiguous or in order, but cell pointers are contiguous and in order. + ** + ** Cell content makes use of variable length integers. A variable + ** length integer is 1 to 9 bytes where the lower 7 bits of each + ** byte are used. The integer consists of all bytes that have bit 8 set and + ** the first byte with bit 8 clear. The most significant byte of the integer + ** appears first. A variable-length integer may not be more than 9 bytes long. + ** As a special case, all 8 bytes of the 9th byte are used as data. This + ** allows a 64-bit integer to be encoded in 9 bytes. + ** + ** 0x00 becomes 0x00000000 + ** 0x7f becomes 0x0000007f + ** 0x81 0x00 becomes 0x00000080 + ** 0x82 0x00 becomes 0x00000100 + ** 0x80 0x7f becomes 0x0000007f + ** 0x8a 0x91 0xd1 0xac 0x78 becomes 0x12345678 + ** 0x81 0x81 0x81 0x81 0x01 becomes 0x10204081 + ** + ** Variable length integers are used for rowids and to hold the number of + ** bytes of key and data in a btree cell. + ** + ** The content of a cell looks like this: + ** + ** SIZE DESCRIPTION + ** 4 Page number of the left child. Omitted if leaf flag is set. + ** var Number of bytes of data. Omitted if the zerodata flag is set. + ** var Number of bytes of key. Or the key itself if intkey flag is set. + ** * Payload + ** 4 First page of the overflow chain. Omitted if no overflow + ** + ** Overflow pages form a linked list. Each page except the last is completely + ** filled with data (pagesize - 4 bytes). The last page can have as little + ** as 1 byte of data. + ** + ** SIZE DESCRIPTION + ** 4 Page number of next overflow page + ** * Data + ** + ** Freelist pages come in two subtypes: trunk pages and leaf pages. The + ** file header points to the first in a linked list of trunk page. Each trunk + ** page points to multiple leaf pages. The content of a leaf page is + ** unspecified. A trunk page looks like this: + ** + ** SIZE DESCRIPTION + ** 4 Page number of next trunk page + ** 4 Number of leaf pointers on this page + ** * zero or more pages numbers of leaves + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + + /* The following value is the maximum cell size assuming a maximum page + ** size give above. + */ + //#define MX_CELL_SIZE(pBt) ((int)(pBt->pageSize-8)) + static int MX_CELL_SIZE( BtShared pBt ) + { + return (int)( pBt.pageSize - 8 ); + } + + /* The maximum number of cells on a single page of the database. This + ** assumes a minimum cell size of 6 bytes (4 bytes for the cell itself + ** plus 2 bytes for the index to the cell in the page header). Such + ** small cells will be rare, but they are possible. + */ + //#define MX_CELL(pBt) ((pBt.pageSize-8)/6) + static int MX_CELL( BtShared pBt ) + { + return ( (int)( pBt.pageSize - 8 ) / 6 ); + } - /* Forward declarations */ - //typedef struct MemPage MemPage; - //typedef struct BtLock BtLock; - - /* - ** This is a magic string that appears at the beginning of every - ** SQLite database in order to identify the file as a real database. - ** - ** You can change this value at compile-time by specifying a - ** -DSQLITE_FILE_HEADER="..." on the compiler command-line. The - ** header must be exactly 16 bytes including the zero-terminator so - ** the string itself should be 15 characters long. If you change - ** the header, then your custom library will not be able to read - ** databases generated by the standard tools and the standard tools - ** will not be able to read databases created by your custom library. - */ + /* Forward declarations */ + //typedef struct MemPage MemPage; + //typedef struct BtLock BtLock; + + /* + ** This is a magic string that appears at the beginning of every + ** SQLite database in order to identify the file as a real database. + ** + ** You can change this value at compile-time by specifying a + ** -DSQLITE_FILE_HEADER="..." on the compiler command-line. The + ** header must be exactly 16 bytes including the zero-terminator so + ** the string itself should be 15 characters long. If you change + ** the header, then your custom library will not be able to read + ** databases generated by the standard tools and the standard tools + ** will not be able to read databases created by your custom library. + */ #if !SQLITE_FILE_HEADER //* 123456789 123456 */ - const string SQLITE_FILE_HEADER = "SQLite format 3\0"; + const string SQLITE_FILE_HEADER = "SQLite format 3\0"; #endif - /* - ** Page type flags. An ORed combination of these flags appear as the - ** first byte of on-disk image of every BTree page. + /* +** Page type flags. An ORed combination of these flags appear as the +** first byte of on-disk image of every BTree page. +*/ + const byte PTF_INTKEY = 0x01; + const byte PTF_ZERODATA = 0x02; + const byte PTF_LEAFDATA = 0x04; + const byte PTF_LEAF = 0x08; + + /* + ** As each page of the file is loaded into memory, an instance of the following + ** structure is appended and initialized to zero. This structure stores + ** information about the page that is decoded from the raw file page. + ** + ** The pParent field points back to the parent page. This allows us to + ** walk up the BTree from any leaf to the root. Care must be taken to + ** unref() the parent page pointer when this page is no longer referenced. + ** The pageDestructor() routine handles that chore. + ** + ** Access to all fields of this structure is controlled by the mutex + ** stored in MemPage.pBt.mutex. + */ + public struct _OvflCell + { /* Cells that will not fit on aData[] */ + public u8[] pCell; /* Pointers to the body of the overflow cell */ + public u16 idx; /* Insert this cell before idx-th non-overflow cell */ + public _OvflCell Copy() + { + _OvflCell cp = new _OvflCell(); + if ( pCell != null ) + { + cp.pCell = sqlite3Malloc( pCell.Length ); + Buffer.BlockCopy( pCell, 0, cp.pCell, 0, pCell.Length ); + } + cp.idx = idx; + return cp; + } + }; + public class MemPage + { + public u8 isInit; /* True if previously initialized. MUST BE FIRST! */ + public u8 nOverflow; /* Number of overflow cell bodies in aCell[] */ + public u8 intKey; /* True if u8key flag is set */ + public u8 leaf; /* 1 if leaf flag is set */ + public u8 hasData; /* True if this page stores data */ + public u8 hdrOffset; /* 100 for page 1. 0 otherwise */ + public u8 childPtrSize; /* 0 if leaf==1. 4 if leaf==0 */ + public u16 maxLocal; /* Copy of BtShared.maxLocal or BtShared.maxLeaf */ + public u16 minLocal; /* Copy of BtShared.minLocal or BtShared.minLeaf */ + public u16 cellOffset; /* Index in aData of first cell pou16er */ + public u16 nFree; /* Number of free bytes on the page */ + public u16 nCell; /* Number of cells on this page, local and ovfl */ + public u16 maskPage; /* Mask for page offset */ + public _OvflCell[] aOvfl = new _OvflCell[5]; + public BtShared pBt; /* Pointer to BtShared that this page is part of */ + public byte[] aData; /* Pointer to disk image of the page data */ + public DbPage pDbPage; /* Pager page handle */ + public Pgno pgno; /* Page number for this page */ + + //public byte[] aData + //{ + // get + // { + // Debug.Assert( pgno != 1 || pDbPage.pData == _aData ); + // return _aData; + // } + // set + // { + // _aData = value; + // Debug.Assert( pgno != 1 || pDbPage.pData == _aData ); + // } + //} + + public MemPage Copy() + { + MemPage cp = (MemPage)MemberwiseClone(); + if ( aOvfl != null ) + { + cp.aOvfl = new _OvflCell[aOvfl.Length]; + for ( int i = 0; i < aOvfl.Length; i++ ) + cp.aOvfl[i] = aOvfl[i].Copy(); + } + if ( aData != null ) + { + cp.aData = sqlite3Malloc( aData.Length ); + Buffer.BlockCopy( aData, 0, cp.aData, 0, aData.Length ); + } + return cp; + } + }; + + /* + ** The in-memory image of a disk page has the auxiliary information appended + ** to the end. EXTRA_SIZE is the number of bytes of space needed to hold + ** that extra information. */ - const byte PTF_INTKEY = 0x01; - const byte PTF_ZERODATA = 0x02; - const byte PTF_LEAFDATA = 0x04; - const byte PTF_LEAF = 0x08; - - /* - ** As each page of the file is loaded into memory, an instance of the following - ** structure is appended and initialized to zero. This structure stores - ** information about the page that is decoded from the raw file page. - ** - ** The pParent field points back to the parent page. This allows us to - ** walk up the BTree from any leaf to the root. Care must be taken to - ** unref() the parent page pointer when this page is no longer referenced. - ** The pageDestructor() routine handles that chore. - ** - ** Access to all fields of this structure is controlled by the mutex - ** stored in MemPage.pBt.mutex. - */ - public struct _OvflCell { /* Cells that will not fit on aData[] */ - public u8[] pCell; /* Pointers to the body of the overflow cell */ - public u16 idx; /* Insert this cell before idx-th non-overflow cell */ - public _OvflCell Copy() { - _OvflCell cp = new _OvflCell(); - if (pCell != null) { - cp.pCell = sqlite3Malloc(pCell.Length); - Buffer.BlockCopy(pCell, 0, cp.pCell, 0, pCell.Length); - } - cp.idx = idx; - return cp; - } - }; - public class MemPage { - public u8 isInit; /* True if previously initialized. MUST BE FIRST! */ - public u8 nOverflow; /* Number of overflow cell bodies in aCell[] */ - public u8 intKey; /* True if u8key flag is set */ - public u8 leaf; /* 1 if leaf flag is set */ - public u8 hasData; /* True if this page stores data */ - public u8 hdrOffset; /* 100 for page 1. 0 otherwise */ - public u8 childPtrSize; /* 0 if leaf==1. 4 if leaf==0 */ - public u16 maxLocal; /* Copy of BtShared.maxLocal or BtShared.maxLeaf */ - public u16 minLocal; /* Copy of BtShared.minLocal or BtShared.minLeaf */ - public u16 cellOffset; /* Index in aData of first cell pou16er */ - public u16 nFree; /* Number of free bytes on the page */ - public u16 nCell; /* Number of cells on this page, local and ovfl */ - public u16 maskPage; /* Mask for page offset */ - public _OvflCell[] aOvfl = new _OvflCell[5]; - public BtShared pBt; /* Pointer to BtShared that this page is part of */ - public byte[] aData; /* Pointer to disk image of the page data */ - public DbPage pDbPage; /* Pager page handle */ - public Pgno pgno; /* Page number for this page */ - - //public byte[] aData - //{ - // get - // { - // Debug.Assert( pgno != 1 || pDbPage.pData == _aData ); - // return _aData; - // } - // set - // { - // _aData = value; - // Debug.Assert( pgno != 1 || pDbPage.pData == _aData ); - // } - //} - - public MemPage Copy() { - MemPage cp = (MemPage)MemberwiseClone(); - if (aOvfl != null) { - cp.aOvfl = new _OvflCell[aOvfl.Length]; - for (int i = 0; i < aOvfl.Length; i++) - cp.aOvfl[i] = aOvfl[i].Copy(); - } - if (aData != null) { - cp.aData = sqlite3Malloc(aData.Length); - Buffer.BlockCopy(aData, 0, cp.aData, 0, aData.Length); - } - return cp; - } - }; - - /* - ** The in-memory image of a disk page has the auxiliary information appended - ** to the end. EXTRA_SIZE is the number of bytes of space needed to hold - ** that extra information. - */ - const int EXTRA_SIZE = 0;// No used in C#, since we use create a class; was MemPage.Length; - - /* - ** A linked list of the following structures is stored at BtShared.pLock. - ** Locks are added (or upgraded from READ_LOCK to WRITE_LOCK) when a cursor - ** is opened on the table with root page BtShared.iTable. Locks are removed - ** from this list when a transaction is committed or rolled back, or when - ** a btree handle is closed. - */ - public class BtLock { - Btree pBtree; /* Btree handle holding this lock */ - Pgno iTable; /* Root page of table */ - u8 eLock; /* READ_LOCK or WRITE_LOCK */ - BtLock pNext; /* Next in BtShared.pLock list */ - }; - - /* Candidate values for BtLock.eLock */ - //#define READ_LOCK 1 - //#define WRITE_LOCK 2 - const int READ_LOCK = 1; - const int WRITE_LOCK = 2; - - /* A Btree handle - ** - ** A database connection contains a pointer to an instance of - ** this object for every database file that it has open. This structure - ** is opaque to the database connection. The database connection cannot - ** see the internals of this structure and only deals with pointers to - ** this structure. - ** - ** For some database files, the same underlying database cache might be - ** shared between multiple connections. In that case, each connection - ** has it own instance of this object. But each instance of this object - ** points to the same BtShared object. The database cache and the - ** schema associated with the database file are all contained within - ** the BtShared object. - ** - ** All fields in this structure are accessed under sqlite3.mutex. - ** The pBt pointer itself may not be changed while there exists cursors - ** in the referenced BtShared that point back to this Btree since those - ** cursors have to go through this Btree to find their BtShared and - ** they often do so without holding sqlite3.mutex. - */ - public class Btree { - public sqlite3 db; /* The database connection holding this Btree */ - public BtShared pBt; /* Sharable content of this Btree */ - public u8 inTrans; /* TRANS_NONE, TRANS_READ or TRANS_WRITE */ - public bool sharable; /* True if we can share pBt with another db */ - public bool locked; /* True if db currently has pBt locked */ - public int wantToLock; /* Number of nested calls to sqlite3BtreeEnter() */ - public int nBackup; /* Number of backup operations reading this btree */ - public Btree pNext; /* List of other sharable Btrees from the same db */ - public Btree pPrev; /* Back pointer of the same list */ + const int EXTRA_SIZE = 0;// No used in C#, since we use create a class; was MemPage.Length; + + /* + ** A linked list of the following structures is stored at BtShared.pLock. + ** Locks are added (or upgraded from READ_LOCK to WRITE_LOCK) when a cursor + ** is opened on the table with root page BtShared.iTable. Locks are removed + ** from this list when a transaction is committed or rolled back, or when + ** a btree handle is closed. + */ + public class BtLock + { + Btree pBtree; /* Btree handle holding this lock */ + Pgno iTable; /* Root page of table */ + u8 eLock; /* READ_LOCK or WRITE_LOCK */ + BtLock pNext; /* Next in BtShared.pLock list */ + }; + + /* Candidate values for BtLock.eLock */ + //#define READ_LOCK 1 + //#define WRITE_LOCK 2 + const int READ_LOCK = 1; + const int WRITE_LOCK = 2; + + /* A Btree handle + ** + ** A database connection contains a pointer to an instance of + ** this object for every database file that it has open. This structure + ** is opaque to the database connection. The database connection cannot + ** see the internals of this structure and only deals with pointers to + ** this structure. + ** + ** For some database files, the same underlying database cache might be + ** shared between multiple connections. In that case, each connection + ** has it own instance of this object. But each instance of this object + ** points to the same BtShared object. The database cache and the + ** schema associated with the database file are all contained within + ** the BtShared object. + ** + ** All fields in this structure are accessed under sqlite3.mutex. + ** The pBt pointer itself may not be changed while there exists cursors + ** in the referenced BtShared that point back to this Btree since those + ** cursors have to go through this Btree to find their BtShared and + ** they often do so without holding sqlite3.mutex. + */ + public class Btree + { + public sqlite3 db; /* The database connection holding this Btree */ + public BtShared pBt; /* Sharable content of this Btree */ + public u8 inTrans; /* TRANS_NONE, TRANS_READ or TRANS_WRITE */ + public bool sharable; /* True if we can share pBt with another db */ + public bool locked; /* True if db currently has pBt locked */ + public int wantToLock; /* Number of nested calls to sqlite3BtreeEnter() */ + public int nBackup; /* Number of backup operations reading this btree */ + public Btree pNext; /* List of other sharable Btrees from the same db */ + public Btree pPrev; /* Back pointer of the same list */ #if !SQLITE_OMIT_SHARED_CACHE BtLock lock; /* Object used to lock page 1 */ #endif - }; - - /* - ** Btree.inTrans may take one of the following values. - ** - ** If the shared-data extension is enabled, there may be multiple users - ** of the Btree structure. At most one of these may open a write transaction, - ** but any number may have active read transactions. - */ - const byte TRANS_NONE = 0; - const byte TRANS_READ = 1; - const byte TRANS_WRITE = 2; - - /* - ** An instance of this object represents a single database file. - ** - ** A single database file can be in use as the same time by two - ** or more database connections. When two or more connections are - ** sharing the same database file, each connection has it own - ** private Btree object for the file and each of those Btrees points - ** to this one BtShared object. BtShared.nRef is the number of - ** connections currently sharing this database file. - ** - ** Fields in this structure are accessed under the BtShared.mutex - ** mutex, except for nRef and pNext which are accessed under the - ** global SQLITE_MUTEX_STATIC_MASTER mutex. The pPager field - ** may not be modified once it is initially set as long as nRef>0. - ** The pSchema field may be set once under BtShared.mutex and - ** thereafter is unchanged as long as nRef>0. - ** - ** isPending: - ** - ** If a BtShared client fails to obtain a write-lock on a database - ** table (because there exists one or more read-locks on the table), - ** the shared-cache enters 'pending-lock' state and isPending is - ** set to true. - ** - ** The shared-cache leaves the 'pending lock' state when either of - ** the following occur: - ** - ** 1) The current writer (BtShared.pWriter) concludes its transaction, OR - ** 2) The number of locks held by other connections drops to zero. - ** - ** while in the 'pending-lock' state, no connection may start a new - ** transaction. - ** - ** This feature is included to help prevent writer-starvation. - */ - public class BtShared { - public Pager pPager; /* The page cache */ - public sqlite3 db; /* Database connection currently using this Btree */ - public BtCursor pCursor; /* A list of all open cursors */ - public MemPage pPage1; /* First page of the database */ - public bool readOnly; /* True if the underlying file is readonly */ - public bool pageSizeFixed; /* True if the page size can no longer be changed */ - public bool secureDelete; /* True if secure_delete is enabled */ - public bool initiallyEmpty; /* Database is empty at start of transaction */ - public u8 openFlags; /* Flags to sqlite3BtreeOpen() */ + }; + + /* + ** Btree.inTrans may take one of the following values. + ** + ** If the shared-data extension is enabled, there may be multiple users + ** of the Btree structure. At most one of these may open a write transaction, + ** but any number may have active read transactions. + */ + const byte TRANS_NONE = 0; + const byte TRANS_READ = 1; + const byte TRANS_WRITE = 2; + + /* + ** An instance of this object represents a single database file. + ** + ** A single database file can be in use as the same time by two + ** or more database connections. When two or more connections are + ** sharing the same database file, each connection has it own + ** private Btree object for the file and each of those Btrees points + ** to this one BtShared object. BtShared.nRef is the number of + ** connections currently sharing this database file. + ** + ** Fields in this structure are accessed under the BtShared.mutex + ** mutex, except for nRef and pNext which are accessed under the + ** global SQLITE_MUTEX_STATIC_MASTER mutex. The pPager field + ** may not be modified once it is initially set as long as nRef>0. + ** The pSchema field may be set once under BtShared.mutex and + ** thereafter is unchanged as long as nRef>0. + ** + ** isPending: + ** + ** If a BtShared client fails to obtain a write-lock on a database + ** table (because there exists one or more read-locks on the table), + ** the shared-cache enters 'pending-lock' state and isPending is + ** set to true. + ** + ** The shared-cache leaves the 'pending lock' state when either of + ** the following occur: + ** + ** 1) The current writer (BtShared.pWriter) concludes its transaction, OR + ** 2) The number of locks held by other connections drops to zero. + ** + ** while in the 'pending-lock' state, no connection may start a new + ** transaction. + ** + ** This feature is included to help prevent writer-starvation. + */ + public class BtShared + { + public Pager pPager; /* The page cache */ + public sqlite3 db; /* Database connection currently using this Btree */ + public BtCursor pCursor; /* A list of all open cursors */ + public MemPage pPage1; /* First page of the database */ + public bool readOnly; /* True if the underlying file is readonly */ + public bool pageSizeFixed; /* True if the page size can no longer be changed */ + public bool secureDelete; /* True if secure_delete is enabled */ + public bool initiallyEmpty; /* Database is empty at start of transaction */ + public u8 openFlags; /* Flags to sqlite3BtreeOpen() */ #if !SQLITE_OMIT_AUTOVACUUM - public bool autoVacuum; /* True if auto-vacuum is enabled */ - public bool incrVacuum; /* True if incr-vacuum is enabled */ + public bool autoVacuum; /* True if auto-vacuum is enabled */ + public bool incrVacuum; /* True if incr-vacuum is enabled */ #endif - public u8 inTransaction; /* Transaction state */ - public bool doNotUseWAL; /* If true, do not open write-ahead-log file */ - public u16 maxLocal; /* Maximum local payload in non-LEAFDATA tables */ - public u16 minLocal; /* Minimum local payload in non-LEAFDATA tables */ - public u16 maxLeaf; /* Maximum local payload in a LEAFDATA table */ - public u16 minLeaf; /* Minimum local payload in a LEAFDATA table */ - public u32 pageSize; /* Total number of bytes on a page */ - public u32 usableSize; /* Number of usable bytes on each page */ - public int nTransaction; /* Number of open transactions (read + write) */ - public Pgno nPage; /* Number of pages in the database */ - public Schema pSchema; /* Pointer to space allocated by sqlite3BtreeSchema() */ - public dxFreeSchema xFreeSchema;/* Destructor for BtShared.pSchema */ - public sqlite3_mutex mutex; /* Non-recursive mutex required to access this object */ - public Bitvec pHasContent; /* Set of pages moved to free-list this transaction */ + public u8 inTransaction; /* Transaction state */ + public bool doNotUseWAL; /* If true, do not open write-ahead-log file */ + public u16 maxLocal; /* Maximum local payload in non-LEAFDATA tables */ + public u16 minLocal; /* Minimum local payload in non-LEAFDATA tables */ + public u16 maxLeaf; /* Maximum local payload in a LEAFDATA table */ + public u16 minLeaf; /* Minimum local payload in a LEAFDATA table */ + public u32 pageSize; /* Total number of bytes on a page */ + public u32 usableSize; /* Number of usable bytes on each page */ + public int nTransaction; /* Number of open transactions (read + write) */ + public Pgno nPage; /* Number of pages in the database */ + public Schema pSchema; /* Pointer to space allocated by sqlite3BtreeSchema() */ + public dxFreeSchema xFreeSchema;/* Destructor for BtShared.pSchema */ + public sqlite3_mutex mutex; /* Non-recursive mutex required to access this object */ + public Bitvec pHasContent; /* Set of pages moved to free-list this transaction */ #if !SQLITE_OMIT_SHARED_CACHE public int nRef; /* Number of references to this structure */ public BtShared pNext; /* Next on a list of sharable BtShared structs */ @@ -504,290 +520,304 @@ public class BtShared { public u8 isExclusive; /* True if pWriter has an EXCLUSIVE lock on the db */ public u8 isPending; /* If waiting for read-locks to clear */ #endif - public byte[] pTmpSpace; /* BtShared.pageSize bytes of space for tmp use */ - }; - - /* - ** An instance of the following structure is used to hold information - ** about a cell. The parseCellPtr() function fills in this structure - ** based on information extract from the raw disk page. - */ - //typedef struct CellInfo CellInfo; - public struct CellInfo { - public int iCell; /* Offset to start of cell content -- Needed for C# */ - public byte[] pCell; /* Pointer to the start of cell content */ - public i64 nKey; /* The key for INTKEY tables, or number of bytes in key */ - public u32 nData; /* Number of bytes of data */ - public u32 nPayload; /* Total amount of payload */ - public u16 nHeader; /* Size of the cell content header in bytes */ - public u16 nLocal; /* Amount of payload held locally */ - public u16 iOverflow; /* Offset to overflow page number. Zero if no overflow */ - public u16 nSize; /* Size of the cell content on the main b-tree page */ - public bool Equals(CellInfo ci) { - if (ci.iCell >= ci.pCell.Length || iCell >= this.pCell.Length) - return false; - if (ci.pCell[ci.iCell] != this.pCell[iCell]) - return false; - if (ci.nKey != this.nKey || ci.nData != this.nData || ci.nPayload != this.nPayload) - return false; - if (ci.nHeader != this.nHeader || ci.nLocal != this.nLocal) - return false; - if (ci.iOverflow != this.iOverflow || ci.nSize != this.nSize) - return false; - return true; - } - }; - - /* - ** Maximum depth of an SQLite B-Tree structure. Any B-Tree deeper than - ** this will be declared corrupt. This value is calculated based on a - ** maximum database size of 2^31 pages a minimum fanout of 2 for a - ** root-node and 3 for all other internal nodes. - ** - ** If a tree that appears to be taller than this is encountered, it is - ** assumed that the database is corrupt. - */ - //#define BTCURSOR_MAX_DEPTH 20 - const int BTCURSOR_MAX_DEPTH = 20; - - /* - ** A cursor is a pointer to a particular entry within a particular - ** b-tree within a database file. - ** - ** The entry is identified by its MemPage and the index in - ** MemPage.aCell[] of the entry. - ** - ** A single database file can shared by two more database connections, - ** but cursors cannot be shared. Each cursor is associated with a - ** particular database connection identified BtCursor.pBtree.db. - ** - ** Fields in this structure are accessed under the BtShared.mutex - ** found at self.pBt.mutex. - */ - public class BtCursor { - public Btree pBtree; /* The Btree to which this cursor belongs */ - public BtShared pBt; /* The BtShared this cursor points to */ - public BtCursor pNext; - public BtCursor pPrev; /* Forms a linked list of all cursors */ - public KeyInfo pKeyInfo; /* Argument passed to comparison function */ - public Pgno pgnoRoot; /* The root page of this tree */ - public sqlite3_int64 cachedRowid; /* Next rowid cache. 0 means not valid */ - public CellInfo info = new CellInfo(); /* A parse of the cell we are pointing at */ - public byte[] pKey; /* Saved key that was cursor's last known position */ - public i64 nKey; /* Size of pKey, or last integer key */ - public int skipNext; /* Prev() is noop if negative. Next() is noop if positive */ - public u8 wrFlag; /* True if writable */ - public u8 atLast; /* VdbeCursor pointing to the last entry */ - public bool validNKey; /* True if info.nKey is valid */ - public int eState; /* One of the CURSOR_XXX constants (see below) */ + public byte[] pTmpSpace; /* BtShared.pageSize bytes of space for tmp use */ + }; + + /* + ** An instance of the following structure is used to hold information + ** about a cell. The parseCellPtr() function fills in this structure + ** based on information extract from the raw disk page. + */ + //typedef struct CellInfo CellInfo; + public struct CellInfo + { + public int iCell; /* Offset to start of cell content -- Needed for C# */ + public byte[] pCell; /* Pointer to the start of cell content */ + public i64 nKey; /* The key for INTKEY tables, or number of bytes in key */ + public u32 nData; /* Number of bytes of data */ + public u32 nPayload; /* Total amount of payload */ + public u16 nHeader; /* Size of the cell content header in bytes */ + public u16 nLocal; /* Amount of payload held locally */ + public u16 iOverflow; /* Offset to overflow page number. Zero if no overflow */ + public u16 nSize; /* Size of the cell content on the main b-tree page */ + public bool Equals( CellInfo ci ) + { + if ( ci.iCell >= ci.pCell.Length || iCell >= this.pCell.Length ) + return false; + if ( ci.pCell[ci.iCell] != this.pCell[iCell] ) + return false; + if ( ci.nKey != this.nKey || ci.nData != this.nData || ci.nPayload != this.nPayload ) + return false; + if ( ci.nHeader != this.nHeader || ci.nLocal != this.nLocal ) + return false; + if ( ci.iOverflow != this.iOverflow || ci.nSize != this.nSize ) + return false; + return true; + } + }; + + /* + ** Maximum depth of an SQLite B-Tree structure. Any B-Tree deeper than + ** this will be declared corrupt. This value is calculated based on a + ** maximum database size of 2^31 pages a minimum fanout of 2 for a + ** root-node and 3 for all other internal nodes. + ** + ** If a tree that appears to be taller than this is encountered, it is + ** assumed that the database is corrupt. + */ + //#define BTCURSOR_MAX_DEPTH 20 + const int BTCURSOR_MAX_DEPTH = 20; + + /* + ** A cursor is a pointer to a particular entry within a particular + ** b-tree within a database file. + ** + ** The entry is identified by its MemPage and the index in + ** MemPage.aCell[] of the entry. + ** + ** A single database file can shared by two more database connections, + ** but cursors cannot be shared. Each cursor is associated with a + ** particular database connection identified BtCursor.pBtree.db. + ** + ** Fields in this structure are accessed under the BtShared.mutex + ** found at self.pBt.mutex. + */ + public class BtCursor + { + public Btree pBtree; /* The Btree to which this cursor belongs */ + public BtShared pBt; /* The BtShared this cursor points to */ + public BtCursor pNext; + public BtCursor pPrev; /* Forms a linked list of all cursors */ + public KeyInfo pKeyInfo; /* Argument passed to comparison function */ + public Pgno pgnoRoot; /* The root page of this tree */ + public sqlite3_int64 cachedRowid; /* Next rowid cache. 0 means not valid */ + public CellInfo info = new CellInfo(); /* A parse of the cell we are pointing at */ + public byte[] pKey; /* Saved key that was cursor's last known position */ + public i64 nKey; /* Size of pKey, or last integer key */ + public int skipNext; /* Prev() is noop if negative. Next() is noop if positive */ + public u8 wrFlag; /* True if writable */ + public u8 atLast; /* VdbeCursor pointing to the last entry */ + public bool validNKey; /* True if info.nKey is valid */ + public int eState; /* One of the CURSOR_XXX constants (see below) */ #if !SQLITE_OMIT_INCRBLOB public Pgno[] aOverflow; /* Cache of overflow page locations */ public bool isIncrblobHandle; /* True if this cursor is an incr. io handle */ #endif - public i16 iPage; /* Index of current page in apPage */ - public u16[] aiIdx = new u16[BTCURSOR_MAX_DEPTH]; /* Current index in apPage[i] */ - public MemPage[] apPage = new MemPage[BTCURSOR_MAX_DEPTH]; /* Pages from root to current page */ - - public void Clear() { - pNext = null; - pPrev = null; - pKeyInfo = null; - pgnoRoot = 0; - cachedRowid = 0; - info = new CellInfo(); - wrFlag = 0; - atLast = 0; - validNKey = false; - eState = 0; - pKey = null; - nKey = 0; - skipNext = 0; + public i16 iPage; /* Index of current page in apPage */ + public u16[] aiIdx = new u16[BTCURSOR_MAX_DEPTH]; /* Current index in apPage[i] */ + public MemPage[] apPage = new MemPage[BTCURSOR_MAX_DEPTH]; /* Pages from root to current page */ + + public void Clear() + { + pNext = null; + pPrev = null; + pKeyInfo = null; + pgnoRoot = 0; + cachedRowid = 0; + info = new CellInfo(); + wrFlag = 0; + atLast = 0; + validNKey = false; + eState = 0; + pKey = null; + nKey = 0; + skipNext = 0; #if !SQLITE_OMIT_INCRBLOB isIncrblobHandle=false; aOverflow= null; #endif - iPage = 0; - } - public BtCursor Copy() { - BtCursor cp = (BtCursor)MemberwiseClone(); - return cp; - } - }; - - /* - ** Potential values for BtCursor.eState. - ** - ** CURSOR_VALID: - ** VdbeCursor points to a valid entry. getPayload() etc. may be called. - ** - ** CURSOR_INVALID: - ** VdbeCursor does not point to a valid entry. This can happen (for example) - ** because the table is empty or because BtreeCursorFirst() has not been - ** called. - ** - ** CURSOR_REQUIRESEEK: - ** The table that this cursor was opened on still exists, but has been - ** modified since the cursor was last used. The cursor position is saved - ** in variables BtCursor.pKey and BtCursor.nKey. When a cursor is in - ** this state, restoreCursorPosition() can be called to attempt to - ** seek the cursor to the saved position. - ** - ** CURSOR_FAULT: - ** A unrecoverable error (an I/O error or a malloc failure) has occurred - ** on a different connection that shares the BtShared cache with this - ** cursor. The error has left the cache in an inconsistent state. - ** Do nothing else with this cursor. Any attempt to use the cursor - ** should return the error code stored in BtCursor.skip - */ - const int CURSOR_INVALID = 0; - const int CURSOR_VALID = 1; - const int CURSOR_REQUIRESEEK = 2; - const int CURSOR_FAULT = 3; - - /* - ** The database page the PENDING_BYTE occupies. This page is never used. - */ - //# define PENDING_BYTE_PAGE(pBt) PAGER_MJ_PGNO(pBt) - // TODO -- Convert PENDING_BYTE_PAGE to inline - static u32 PENDING_BYTE_PAGE(BtShared pBt) { - return (u32)PAGER_MJ_PGNO(pBt.pPager); - } + iPage = 0; + } + public BtCursor Copy() + { + BtCursor cp = (BtCursor)MemberwiseClone(); + return cp; + } + }; + + /* + ** Potential values for BtCursor.eState. + ** + ** CURSOR_VALID: + ** VdbeCursor points to a valid entry. getPayload() etc. may be called. + ** + ** CURSOR_INVALID: + ** VdbeCursor does not point to a valid entry. This can happen (for example) + ** because the table is empty or because BtreeCursorFirst() has not been + ** called. + ** + ** CURSOR_REQUIRESEEK: + ** The table that this cursor was opened on still exists, but has been + ** modified since the cursor was last used. The cursor position is saved + ** in variables BtCursor.pKey and BtCursor.nKey. When a cursor is in + ** this state, restoreCursorPosition() can be called to attempt to + ** seek the cursor to the saved position. + ** + ** CURSOR_FAULT: + ** A unrecoverable error (an I/O error or a malloc failure) has occurred + ** on a different connection that shares the BtShared cache with this + ** cursor. The error has left the cache in an inconsistent state. + ** Do nothing else with this cursor. Any attempt to use the cursor + ** should return the error code stored in BtCursor.skip + */ + const int CURSOR_INVALID = 0; + const int CURSOR_VALID = 1; + const int CURSOR_REQUIRESEEK = 2; + const int CURSOR_FAULT = 3; - /* - ** These macros define the location of the pointer-map entry for a - ** database page. The first argument to each is the number of usable - ** bytes on each page of the database (often 1024). The second is the - ** page number to look up in the pointer map. - ** - ** PTRMAP_PAGENO returns the database page number of the pointer-map - ** page that stores the required pointer. PTRMAP_PTROFFSET returns - ** the offset of the requested map entry. - ** - ** If the pgno argument passed to PTRMAP_PAGENO is a pointer-map page, - ** then pgno is returned. So (pgno==PTRMAP_PAGENO(pgsz, pgno)) can be - ** used to test if pgno is a pointer-map page. PTRMAP_ISPAGE implements - ** this test. - */ - //#define PTRMAP_PAGENO(pBt, pgno) ptrmapPageno(pBt, pgno) - static Pgno PTRMAP_PAGENO(BtShared pBt, Pgno pgno) { - return ptrmapPageno(pBt, pgno); - } - //#define PTRMAP_PTROFFSET(pgptrmap, pgno) (5*(pgno-pgptrmap-1)) - static u32 PTRMAP_PTROFFSET(u32 pgptrmap, u32 pgno) { - return (5 * (pgno - pgptrmap - 1)); - } - //#define PTRMAP_ISPAGE(pBt, pgno) (PTRMAP_PAGENO((pBt),(pgno))==(pgno)) - static bool PTRMAP_ISPAGE(BtShared pBt, u32 pgno) { - return (PTRMAP_PAGENO((pBt), (pgno)) == (pgno)); - } - /* - ** The pointer map is a lookup table that identifies the parent page for - ** each child page in the database file. The parent page is the page that - ** contains a pointer to the child. Every page in the database contains - ** 0 or 1 parent pages. (In this context 'database page' refers - ** to any page that is not part of the pointer map itself.) Each pointer map - ** entry consists of a single byte 'type' and a 4 byte parent page number. - ** The PTRMAP_XXX identifiers below are the valid types. - ** - ** The purpose of the pointer map is to facility moving pages from one - ** position in the file to another as part of autovacuum. When a page - ** is moved, the pointer in its parent must be updated to point to the - ** new location. The pointer map is used to locate the parent page quickly. - ** - ** PTRMAP_ROOTPAGE: The database page is a root-page. The page-number is not - ** used in this case. - ** - ** PTRMAP_FREEPAGE: The database page is an unused (free) page. The page-number - ** is not used in this case. - ** - ** PTRMAP_OVERFLOW1: The database page is the first page in a list of - ** overflow pages. The page number identifies the page that - ** contains the cell with a pointer to this overflow page. - ** - ** PTRMAP_OVERFLOW2: The database page is the second or later page in a list of - ** overflow pages. The page-number identifies the previous - ** page in the overflow page list. - ** - ** PTRMAP_BTREE: The database page is a non-root btree page. The page number - ** identifies the parent page in the btree. - */ - //#define PTRMAP_ROOTPAGE 1 - //#define PTRMAP_FREEPAGE 2 - //#define PTRMAP_OVERFLOW1 3 - //#define PTRMAP_OVERFLOW2 4 - //#define PTRMAP_BTREE 5 - const int PTRMAP_ROOTPAGE = 1; - const int PTRMAP_FREEPAGE = 2; - const int PTRMAP_OVERFLOW1 = 3; - const int PTRMAP_OVERFLOW2 = 4; - const int PTRMAP_BTREE = 5; - - /* A bunch of Debug.Assert() statements to check the transaction state variables - ** of handle p (type Btree*) are internally consistent. - */ + /* + ** The database page the PENDING_BYTE occupies. This page is never used. + */ + //# define PENDING_BYTE_PAGE(pBt) PAGER_MJ_PGNO(pBt) + // TODO -- Convert PENDING_BYTE_PAGE to inline + static u32 PENDING_BYTE_PAGE( BtShared pBt ) + { + return (u32)PAGER_MJ_PGNO( pBt.pPager ); + } + + /* + ** These macros define the location of the pointer-map entry for a + ** database page. The first argument to each is the number of usable + ** bytes on each page of the database (often 1024). The second is the + ** page number to look up in the pointer map. + ** + ** PTRMAP_PAGENO returns the database page number of the pointer-map + ** page that stores the required pointer. PTRMAP_PTROFFSET returns + ** the offset of the requested map entry. + ** + ** If the pgno argument passed to PTRMAP_PAGENO is a pointer-map page, + ** then pgno is returned. So (pgno==PTRMAP_PAGENO(pgsz, pgno)) can be + ** used to test if pgno is a pointer-map page. PTRMAP_ISPAGE implements + ** this test. + */ + //#define PTRMAP_PAGENO(pBt, pgno) ptrmapPageno(pBt, pgno) + static Pgno PTRMAP_PAGENO( BtShared pBt, Pgno pgno ) + { + return ptrmapPageno( pBt, pgno ); + } + //#define PTRMAP_PTROFFSET(pgptrmap, pgno) (5*(pgno-pgptrmap-1)) + static u32 PTRMAP_PTROFFSET( u32 pgptrmap, u32 pgno ) + { + return ( 5 * ( pgno - pgptrmap - 1 ) ); + } + //#define PTRMAP_ISPAGE(pBt, pgno) (PTRMAP_PAGENO((pBt),(pgno))==(pgno)) + static bool PTRMAP_ISPAGE( BtShared pBt, u32 pgno ) + { + return ( PTRMAP_PAGENO( ( pBt ), ( pgno ) ) == ( pgno ) ); + } + /* + ** The pointer map is a lookup table that identifies the parent page for + ** each child page in the database file. The parent page is the page that + ** contains a pointer to the child. Every page in the database contains + ** 0 or 1 parent pages. (In this context 'database page' refers + ** to any page that is not part of the pointer map itself.) Each pointer map + ** entry consists of a single byte 'type' and a 4 byte parent page number. + ** The PTRMAP_XXX identifiers below are the valid types. + ** + ** The purpose of the pointer map is to facility moving pages from one + ** position in the file to another as part of autovacuum. When a page + ** is moved, the pointer in its parent must be updated to point to the + ** new location. The pointer map is used to locate the parent page quickly. + ** + ** PTRMAP_ROOTPAGE: The database page is a root-page. The page-number is not + ** used in this case. + ** + ** PTRMAP_FREEPAGE: The database page is an unused (free) page. The page-number + ** is not used in this case. + ** + ** PTRMAP_OVERFLOW1: The database page is the first page in a list of + ** overflow pages. The page number identifies the page that + ** contains the cell with a pointer to this overflow page. + ** + ** PTRMAP_OVERFLOW2: The database page is the second or later page in a list of + ** overflow pages. The page-number identifies the previous + ** page in the overflow page list. + ** + ** PTRMAP_BTREE: The database page is a non-root btree page. The page number + ** identifies the parent page in the btree. + */ + //#define PTRMAP_ROOTPAGE 1 + //#define PTRMAP_FREEPAGE 2 + //#define PTRMAP_OVERFLOW1 3 + //#define PTRMAP_OVERFLOW2 4 + //#define PTRMAP_BTREE 5 + const int PTRMAP_ROOTPAGE = 1; + const int PTRMAP_FREEPAGE = 2; + const int PTRMAP_OVERFLOW1 = 3; + const int PTRMAP_OVERFLOW2 = 4; + const int PTRMAP_BTREE = 5; + + /* A bunch of Debug.Assert() statements to check the transaction state variables + ** of handle p (type Btree*) are internally consistent. + */ #if DEBUG - //#define btreeIntegrity(p) \ - // Debug.Assert( p.pBt.inTransaction!=TRANS_NONE || p.pBt.nTransaction==0 ); \ - // Debug.Assert( p.pBt.inTransaction>=p.inTrans ); - static void btreeIntegrity(Btree p) { - Debug.Assert(p.pBt.inTransaction != TRANS_NONE || p.pBt.nTransaction == 0); - Debug.Assert(p.pBt.inTransaction >= p.inTrans); - } + //#define btreeIntegrity(p) \ + // Debug.Assert( p.pBt.inTransaction!=TRANS_NONE || p.pBt.nTransaction==0 ); \ + // Debug.Assert( p.pBt.inTransaction>=p.inTrans ); + static void btreeIntegrity( Btree p ) + { + Debug.Assert( p.pBt.inTransaction != TRANS_NONE || p.pBt.nTransaction == 0 ); + Debug.Assert( p.pBt.inTransaction >= p.inTrans ); + } #else static void btreeIntegrity(Btree p) { } #endif - /* - ** The ISAUTOVACUUM macro is used within balance_nonroot() to determine - ** if the database supports auto-vacuum or not. Because it is used - ** within an expression that is an argument to another macro - ** (sqliteMallocRaw), it is not possible to use conditional compilation. - ** So, this macro is defined instead. - */ + /* +** The ISAUTOVACUUM macro is used within balance_nonroot() to determine +** if the database supports auto-vacuum or not. Because it is used +** within an expression that is an argument to another macro +** (sqliteMallocRaw), it is not possible to use conditional compilation. +** So, this macro is defined instead. +*/ #if !SQLITE_OMIT_AUTOVACUUM - //#define ISAUTOVACUUM (pBt.autoVacuum) + //#define ISAUTOVACUUM (pBt.autoVacuum) #else //#define ISAUTOVACUUM 0 public static bool ISAUTOVACUUM =false; #endif - /* - ** This structure is passed around through all the sanity checking routines - ** in order to keep track of some global state information. + /* +** This structure is passed around through all the sanity checking routines +** in order to keep track of some global state information. +*/ + //typedef struct IntegrityCk IntegrityCk; + public class IntegrityCk + { + public BtShared pBt; /* The tree being checked out */ + public Pager pPager; /* The associated pager. Also accessible by pBt.pPager */ + public Pgno nPage; /* Number of pages in the database */ + public int[] anRef; /* Number of times each page is referenced */ + public int mxErr; /* Stop accumulating errors when this reaches zero */ + public int nErr; /* Number of messages written to zErrMsg so far */ + //public int mallocFailed; /* A memory allocation error has occurred */ + public StrAccum errMsg = new StrAccum( 100 ); /* Accumulate the error message text here */ + }; + + /* + ** Read or write a two- and four-byte big-endian integer values. */ - //typedef struct IntegrityCk IntegrityCk; - public class IntegrityCk { - public BtShared pBt; /* The tree being checked out */ - public Pager pPager; /* The associated pager. Also accessible by pBt.pPager */ - public Pgno nPage; /* Number of pages in the database */ - public int[] anRef; /* Number of times each page is referenced */ - public int mxErr; /* Stop accumulating errors when this reaches zero */ - public int nErr; /* Number of messages written to zErrMsg so far */ - //public int mallocFailed; /* A memory allocation error has occurred */ - public StrAccum errMsg = new StrAccum(100); /* Accumulate the error message text here */ - }; - - /* - ** Read or write a two- and four-byte big-endian integer values. - */ - //#define get2byte(x) ((x)[0]<<8 | (x)[1]) - static int get2byte(byte[] p, int offset) { - return p[offset + 0] << 8 | p[offset + 1]; - } + //#define get2byte(x) ((x)[0]<<8 | (x)[1]) + static int get2byte( byte[] p, int offset ) + { + return p[offset + 0] << 8 | p[offset + 1]; + } - //#define put2byte(p,v) ((p)[0] = (u8)((v)>>8), (p)[1] = (u8)(v)) - static void put2byte(byte[] pData, int Offset, u32 v) { - pData[Offset + 0] = (byte)(v >> 8); - pData[Offset + 1] = (byte)v; - } - static void put2byte(byte[] pData, int Offset, int v) { - pData[Offset + 0] = (byte)(v >> 8); - pData[Offset + 1] = (byte)v; - } + //#define put2byte(p,v) ((p)[0] = (u8)((v)>>8), (p)[1] = (u8)(v)) + static void put2byte( byte[] pData, int Offset, u32 v ) + { + pData[Offset + 0] = (byte)( v >> 8 ); + pData[Offset + 1] = (byte)v; + } + static void put2byte( byte[] pData, int Offset, int v ) + { + pData[Offset + 0] = (byte)( v >> 8 ); + pData[Offset + 1] = (byte)v; + } - //#define get4byte sqlite3Get4byte - //#define put4byte sqlite3Put4byte + //#define get4byte sqlite3Get4byte + //#define put4byte sqlite3Put4byte - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/Btree_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/Btree_h.cs index 688165138..996516f23 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/Btree_h.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/Btree_h.cs @@ -1,243 +1,247 @@ -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 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. - ** - ************************************************************************* - ** This header file defines the interface that the sqlite B-Tree file - ** subsystem. See comments in the source code for a detailed description - ** of what each interface routine does. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#if !_BTREE_H_ - //#define _BTREE_H_ - - /* TODO: This definition is just included so other modules compile. It - ** needs to be revisited. - */ - const int SQLITE_N_BTREE_META = 10; - - /* - ** If defined as non-zero, auto-vacuum is enabled by default. Otherwise - ** it must be turned on for each database using "PRAGMA auto_vacuum = 1". - */ +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 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. + ** + ************************************************************************* + ** This header file defines the interface that the sqlite B-Tree file + ** subsystem. See comments in the source code for a detailed description + ** of what each interface routine does. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#if !_BTREE_H_ + //#define _BTREE_H_ + + /* TODO: This definition is just included so other modules compile. It + ** needs to be revisited. + */ + const int SQLITE_N_BTREE_META = 10; + + /* + ** If defined as non-zero, auto-vacuum is enabled by default. Otherwise + ** it must be turned on for each database using "PRAGMA auto_vacuum = 1". + */ #if !SQLITE_DEFAULT_AUTOVACUUM - const int SQLITE_DEFAULT_AUTOVACUUM = 0; + const int SQLITE_DEFAULT_AUTOVACUUM = 0; #endif - const int BTREE_AUTOVACUUM_NONE = 0; /* Do not do auto-vacuum */ - const int BTREE_AUTOVACUUM_FULL = 1; /* Do full auto-vacuum */ - const int BTREE_AUTOVACUUM_INCR = 2; /* Incremental vacuum */ - - /* - ** Forward declarations of structure - */ - //typedef struct Btree Btree; - //typedef struct BtCursor BtCursor; - //typedef struct BtShared BtShared; - - //int sqlite3BtreeOpen( - // sqlite3_vfs *pVfs, /* VFS to use with this b-tree */ - // string zFilename, /* Name of database file to open */ - // sqlite3 db, /* Associated database connection */ - // Btree **ppBtree, /* Return open Btree* here */ - // int flags, /* Flags */ - // int vfsFlags /* Flags passed through to VFS open */ - //); - - /* The flags parameter to sqlite3BtreeOpen can be the bitwise or of the - ** following values. - ** - ** NOTE: These values must match the corresponding PAGER_ values in - ** pager.h. - */ - //#define BTREE_OMIT_JOURNAL 1 /* Do not create or use a rollback journal */ - //#define BTREE_NO_READLOCK 2 /* Omit readlocks on readonly files */ - //#define BTREE_MEMORY 4 /* This is an in-memory DB */ - //#define BTREE_SINGLE 8 /* The file contains at most 1 b-tree */ - //#define BTREE_UNORDERED 16 /* Use of a hash implementation is OK */ - const int BTREE_OMIT_JOURNAL = 1; /* Do not create or use a rollback journal */ - const int BTREE_NO_READLOCK = 2; /* Omit readlocks on readonly files */ - const int BTREE_MEMORY = 4; /* This is an in-memory DB */ - const int BTREE_SINGLE = 8; /* The file contains at most 1 b-tree */ - const int BTREE_UNORDERED = 16; /* Use of a hash implementation is OK */ - - //int sqlite3BtreeClose(Btree); - //int sqlite3BtreeSetCacheSize(Btree*,int); - //int sqlite3BtreeSetSafetyLevel(Btree*,int,int,int); - //int sqlite3BtreeSyncDisabled(Btree); - //int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix); - //int sqlite3BtreeGetPageSize(Btree); - //int sqlite3BtreeMaxPageCount(Btree*,int); - //u32 sqlite3BtreeLastPage(Btree); - //int sqlite3BtreeSecureDelete(Btree*,int); - //int sqlite3BtreeGetReserve(Btree); - //int sqlite3BtreeSetAutoVacuum(Btree , int); - //int sqlite3BtreeGetAutoVacuum(Btree ); - //int sqlite3BtreeBeginTrans(Btree*,int); - //int sqlite3BtreeCommitPhaseOne(Btree*, string zMaster); - //int sqlite3BtreeCommitPhaseTwo(Btree*, int); - //int sqlite3BtreeCommit(Btree); - //int sqlite3BtreeRollback(Btree); - //int sqlite3BtreeBeginStmt(Btree); - //int sqlite3BtreeCreateTable(Btree*, int*, int flags); - //int sqlite3BtreeIsInTrans(Btree); - //int sqlite3BtreeIsInReadTrans(Btree); - //int sqlite3BtreeIsInBackup(Btree); - //void *sqlite3BtreeSchema(Btree , int, void()(void )); - //int sqlite3BtreeSchemaLocked( Btree* pBtree ); - //int sqlite3BtreeLockTable( Btree* pBtree, int iTab, u8 isWriteLock ); - //int sqlite3BtreeSavepoint(Btree *, int, int); - - //string sqlite3BtreeGetFilename(Btree ); - //string sqlite3BtreeGetJournalname(Btree ); - //int sqlite3BtreeCopyFile(Btree *, Btree ); - - //int sqlite3BtreeIncrVacuum(Btree ); - - /* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR - ** of the flags shown below. - ** - ** Every SQLite table must have either BTREE_INTKEY or BTREE_BLOBKEY set. - ** With BTREE_INTKEY, the table key is a 64-bit integer and arbitrary data - ** is stored in the leaves. (BTREE_INTKEY is used for SQL tables.) With - ** BTREE_BLOBKEY, the key is an arbitrary BLOB and no content is stored - ** anywhere - the key is the content. (BTREE_BLOBKEY is used for SQL - ** indices.) - */ - //#define BTREE_INTKEY 1 /* Table has only 64-bit signed integer keys */ - //#define BTREE_BLOBKEY 2 /* Table has keys only - no data */ - const int BTREE_INTKEY = 1; - const int BTREE_BLOBKEY = 2; - - //int sqlite3BtreeDropTable(Btree*, int, int); - //int sqlite3BtreeClearTable(Btree*, int, int); - //void sqlite3BtreeTripAllCursors(Btree*, int); - - //void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue); - //int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value); - - - /* - ** The second parameter to sqlite3BtreeGetMeta or sqlite3BtreeUpdateMeta - ** should be one of the following values. The integer values are assigned - ** to constants so that the offset of the corresponding field in an - ** SQLite database header may be found using the following formula: - ** - ** offset = 36 + (idx * 4) - ** - ** For example, the free-page-count field is located at byte offset 36 of - ** the database file header. The incr-vacuum-flag field is located at - ** byte offset 64 (== 36+4*7). - */ - //#define BTREE_FREE_PAGE_COUNT 0 - //#define BTREE_SCHEMA_VERSION 1 - //#define BTREE_FILE_FORMAT 2 - //#define BTREE_DEFAULT_CACHE_SIZE 3 - //#define BTREE_LARGEST_ROOT_PAGE 4 - //#define BTREE_TEXT_ENCODING 5 - //#define BTREE_USER_VERSION 6 - //#define BTREE_INCR_VACUUM 7 - const int BTREE_FREE_PAGE_COUNT = 0; - const int BTREE_SCHEMA_VERSION = 1; - const int BTREE_FILE_FORMAT = 2; - const int BTREE_DEFAULT_CACHE_SIZE = 3; - const int BTREE_LARGEST_ROOT_PAGE = 4; - const int BTREE_TEXT_ENCODING = 5; - const int BTREE_USER_VERSION = 6; - const int BTREE_INCR_VACUUM = 7; - - //int sqlite3BtreeCursor( - // Btree*, /* BTree containing table to open */ - // int iTable, /* Index of root page */ - // int wrFlag, /* 1 for writing. 0 for read-only */ - // struct KeyInfo*, /* First argument to compare function */ - // BtCursor pCursor /* Space to write cursor structure */ - //); - //int sqlite3BtreeCursorSize(void); - //void sqlite3BtreeCursorZero(BtCursor); - - //int sqlite3BtreeCloseCursor(BtCursor); - //int sqlite3BtreeMovetoUnpacked( - // BtCursor*, - // UnpackedRecord pUnKey, - // i64 intKey, - // int bias, - // int pRes - //); - //int sqlite3BtreeCursorHasMoved(BtCursor*, int); - //int sqlite3BtreeDelete(BtCursor); - //int sqlite3BtreeInsert(BtCursor*, const void pKey, i64 nKey, - // const void pData, int nData, - // int nZero, int bias, int seekResult); - //int sqlite3BtreeFirst(BtCursor*, int pRes); - //int sqlite3BtreeLast(BtCursor*, int pRes); - //int sqlite3BtreeNext(BtCursor*, int pRes); - //int sqlite3BtreeEof(BtCursor); - //int sqlite3BtreePrevious(BtCursor*, int pRes); - //int sqlite3BtreeKeySize(BtCursor*, i64 pSize); - //int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void); - //const void *sqlite3BtreeKeyFetch(BtCursor*, int pAmt); - //const void *sqlite3BtreeDataFetch(BtCursor*, int pAmt); - //int sqlite3BtreeDataSize(BtCursor*, u32 pSize); - //int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void); - //void sqlite3BtreeSetCachedRowid(BtCursor*, sqlite3_int64); - //sqlite3_int64 sqlite3BtreeGetCachedRowid(BtCursor); - - //char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int); - //struct Pager *sqlite3BtreePager(Btree); - - //int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void); - //void sqlite3BtreeCacheOverflow(BtCursor ); - //void sqlite3BtreeClearCursor(BtCursor ); - - //int sqlite3BtreeSetVersion(Btree *pBt, int iVersion); - - //#if !NDEBUG - //int sqlite3BtreeCursorIsValid(BtCursor); - //#endif - - //#if !SQLITE_OMIT_BTREECOUNT - //int sqlite3BtreeCount(BtCursor *, i64 ); - //#endif - - //#if SQLITE_TEST - //int sqlite3BtreeCursorInfo(BtCursor*, int*, int); - //void sqlite3BtreeCursorList(Btree); - //#endif + const int BTREE_AUTOVACUUM_NONE = 0; /* Do not do auto-vacuum */ + const int BTREE_AUTOVACUUM_FULL = 1; /* Do full auto-vacuum */ + const int BTREE_AUTOVACUUM_INCR = 2; /* Incremental vacuum */ + + /* + ** Forward declarations of structure + */ + //typedef struct Btree Btree; + //typedef struct BtCursor BtCursor; + //typedef struct BtShared BtShared; + + //int sqlite3BtreeOpen( + // sqlite3_vfs *pVfs, /* VFS to use with this b-tree */ + // string zFilename, /* Name of database file to open */ + // sqlite3 db, /* Associated database connection */ + // Btree **ppBtree, /* Return open Btree* here */ + // int flags, /* Flags */ + // int vfsFlags /* Flags passed through to VFS open */ + //); + + /* The flags parameter to sqlite3BtreeOpen can be the bitwise or of the + ** following values. + ** + ** NOTE: These values must match the corresponding PAGER_ values in + ** pager.h. + */ + //#define BTREE_OMIT_JOURNAL 1 /* Do not create or use a rollback journal */ + //#define BTREE_NO_READLOCK 2 /* Omit readlocks on readonly files */ + //#define BTREE_MEMORY 4 /* This is an in-memory DB */ + //#define BTREE_SINGLE 8 /* The file contains at most 1 b-tree */ + //#define BTREE_UNORDERED 16 /* Use of a hash implementation is OK */ + const int BTREE_OMIT_JOURNAL = 1; /* Do not create or use a rollback journal */ + const int BTREE_NO_READLOCK = 2; /* Omit readlocks on readonly files */ + const int BTREE_MEMORY = 4; /* This is an in-memory DB */ + const int BTREE_SINGLE = 8; /* The file contains at most 1 b-tree */ + const int BTREE_UNORDERED = 16; /* Use of a hash implementation is OK */ + + //int sqlite3BtreeClose(Btree); + //int sqlite3BtreeSetCacheSize(Btree*,int); + //int sqlite3BtreeSetSafetyLevel(Btree*,int,int,int); + //int sqlite3BtreeSyncDisabled(Btree); + //int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix); + //int sqlite3BtreeGetPageSize(Btree); + //int sqlite3BtreeMaxPageCount(Btree*,int); + //u32 sqlite3BtreeLastPage(Btree); + //int sqlite3BtreeSecureDelete(Btree*,int); + //int sqlite3BtreeGetReserve(Btree); + //int sqlite3BtreeSetAutoVacuum(Btree , int); + //int sqlite3BtreeGetAutoVacuum(Btree ); + //int sqlite3BtreeBeginTrans(Btree*,int); + //int sqlite3BtreeCommitPhaseOne(Btree*, string zMaster); + //int sqlite3BtreeCommitPhaseTwo(Btree*, int); + //int sqlite3BtreeCommit(Btree); + //int sqlite3BtreeRollback(Btree); + //int sqlite3BtreeBeginStmt(Btree); + //int sqlite3BtreeCreateTable(Btree*, int*, int flags); + //int sqlite3BtreeIsInTrans(Btree); + //int sqlite3BtreeIsInReadTrans(Btree); + //int sqlite3BtreeIsInBackup(Btree); + //void *sqlite3BtreeSchema(Btree , int, void()(void )); + //int sqlite3BtreeSchemaLocked( Btree* pBtree ); + //int sqlite3BtreeLockTable( Btree* pBtree, int iTab, u8 isWriteLock ); + //int sqlite3BtreeSavepoint(Btree *, int, int); + + //string sqlite3BtreeGetFilename(Btree ); + //string sqlite3BtreeGetJournalname(Btree ); + //int sqlite3BtreeCopyFile(Btree *, Btree ); + + //int sqlite3BtreeIncrVacuum(Btree ); + + /* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR + ** of the flags shown below. + ** + ** Every SQLite table must have either BTREE_INTKEY or BTREE_BLOBKEY set. + ** With BTREE_INTKEY, the table key is a 64-bit integer and arbitrary data + ** is stored in the leaves. (BTREE_INTKEY is used for SQL tables.) With + ** BTREE_BLOBKEY, the key is an arbitrary BLOB and no content is stored + ** anywhere - the key is the content. (BTREE_BLOBKEY is used for SQL + ** indices.) + */ + //#define BTREE_INTKEY 1 /* Table has only 64-bit signed integer keys */ + //#define BTREE_BLOBKEY 2 /* Table has keys only - no data */ + const int BTREE_INTKEY = 1; + const int BTREE_BLOBKEY = 2; + + //int sqlite3BtreeDropTable(Btree*, int, int); + //int sqlite3BtreeClearTable(Btree*, int, int); + //void sqlite3BtreeTripAllCursors(Btree*, int); + + //void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue); + //int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value); + + + /* + ** The second parameter to sqlite3BtreeGetMeta or sqlite3BtreeUpdateMeta + ** should be one of the following values. The integer values are assigned + ** to constants so that the offset of the corresponding field in an + ** SQLite database header may be found using the following formula: + ** + ** offset = 36 + (idx * 4) + ** + ** For example, the free-page-count field is located at byte offset 36 of + ** the database file header. The incr-vacuum-flag field is located at + ** byte offset 64 (== 36+4*7). + */ + //#define BTREE_FREE_PAGE_COUNT 0 + //#define BTREE_SCHEMA_VERSION 1 + //#define BTREE_FILE_FORMAT 2 + //#define BTREE_DEFAULT_CACHE_SIZE 3 + //#define BTREE_LARGEST_ROOT_PAGE 4 + //#define BTREE_TEXT_ENCODING 5 + //#define BTREE_USER_VERSION 6 + //#define BTREE_INCR_VACUUM 7 + const int BTREE_FREE_PAGE_COUNT = 0; + const int BTREE_SCHEMA_VERSION = 1; + const int BTREE_FILE_FORMAT = 2; + const int BTREE_DEFAULT_CACHE_SIZE = 3; + const int BTREE_LARGEST_ROOT_PAGE = 4; + const int BTREE_TEXT_ENCODING = 5; + const int BTREE_USER_VERSION = 6; + const int BTREE_INCR_VACUUM = 7; + + //int sqlite3BtreeCursor( + // Btree*, /* BTree containing table to open */ + // int iTable, /* Index of root page */ + // int wrFlag, /* 1 for writing. 0 for read-only */ + // struct KeyInfo*, /* First argument to compare function */ + // BtCursor pCursor /* Space to write cursor structure */ + //); + //int sqlite3BtreeCursorSize(void); + //void sqlite3BtreeCursorZero(BtCursor); + + //int sqlite3BtreeCloseCursor(BtCursor); + //int sqlite3BtreeMovetoUnpacked( + // BtCursor*, + // UnpackedRecord pUnKey, + // i64 intKey, + // int bias, + // int pRes + //); + //int sqlite3BtreeCursorHasMoved(BtCursor*, int); + //int sqlite3BtreeDelete(BtCursor); + //int sqlite3BtreeInsert(BtCursor*, const void pKey, i64 nKey, + // const void pData, int nData, + // int nZero, int bias, int seekResult); + //int sqlite3BtreeFirst(BtCursor*, int pRes); + //int sqlite3BtreeLast(BtCursor*, int pRes); + //int sqlite3BtreeNext(BtCursor*, int pRes); + //int sqlite3BtreeEof(BtCursor); + //int sqlite3BtreePrevious(BtCursor*, int pRes); + //int sqlite3BtreeKeySize(BtCursor*, i64 pSize); + //int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void); + //const void *sqlite3BtreeKeyFetch(BtCursor*, int pAmt); + //const void *sqlite3BtreeDataFetch(BtCursor*, int pAmt); + //int sqlite3BtreeDataSize(BtCursor*, u32 pSize); + //int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void); + //void sqlite3BtreeSetCachedRowid(BtCursor*, sqlite3_int64); + //sqlite3_int64 sqlite3BtreeGetCachedRowid(BtCursor); + + //char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int); + //struct Pager *sqlite3BtreePager(Btree); + + //int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void); + //void sqlite3BtreeCacheOverflow(BtCursor ); + //void sqlite3BtreeClearCursor(BtCursor ); + + //int sqlite3BtreeSetVersion(Btree *pBt, int iVersion); + + //#if !NDEBUG + //int sqlite3BtreeCursorIsValid(BtCursor); + //#endif + + //#if !SQLITE_OMIT_BTREECOUNT + //int sqlite3BtreeCount(BtCursor *, i64 ); + //#endif + + //#if SQLITE_TEST + //int sqlite3BtreeCursorInfo(BtCursor*, int*, int); + //void sqlite3BtreeCursorList(Btree); + //#endif #if !SQLITE_OMIT_WAL //int sqlite3BtreeCheckpoint(Btree*, int, int *, int ); #endif - /* - ** If we are not using shared cache, then there is no need to - ** use mutexes to access the BtShared structures. So make the - ** Enter and Leave procedures no-ops. - */ + /* +** If we are not using shared cache, then there is no need to +** use mutexes to access the BtShared structures. So make the +** Enter and Leave procedures no-ops. +*/ #if !SQLITE_OMIT_SHARED_CACHE //void sqlite3BtreeEnter(Btree); //void sqlite3BtreeEnterAll(sqlite3); #else - //# define sqlite3BtreeEnter(X) - static void sqlite3BtreeEnter(Btree bt) { - } - //# define sqlite3BtreeEnterAll(X) - static void sqlite3BtreeEnterAll(sqlite3 p) { - } + //# define sqlite3BtreeEnter(X) + static void sqlite3BtreeEnter( Btree bt ) + { + } + //# define sqlite3BtreeEnterAll(X) + static void sqlite3BtreeEnterAll( sqlite3 p ) + { + } #endif #if !(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE @@ -253,42 +257,50 @@ static void sqlite3BtreeEnterAll(sqlite3 p) { int sqlite3SchemaMutexHeld(sqlite3*,int,Schema); #endif #else - //# define sqlite3BtreeSharable(X) 0 - static bool sqlite3BtreeSharable(Btree X) { - return false; - } - - //# define sqlite3BtreeLeave(X) - static void sqlite3BtreeLeave(Btree X) { - } - - //# define sqlite3BtreeEnterCursor(X) - static void sqlite3BtreeEnterCursor(BtCursor X) { - } - - //# define sqlite3BtreeLeaveCursor(X) - static void sqlite3BtreeLeaveCursor(BtCursor X) { - } - - //# define sqlite3BtreeLeaveAll(X) - static void sqlite3BtreeLeaveAll(sqlite3 X) { - } - - //# define sqlite3BtreeHoldsMutex(X) 1 - static bool sqlite3BtreeHoldsMutex(Btree X) { - return true; - } - - //# define sqlite3BtreeHoldsAllMutexes(X) 1 - static bool sqlite3BtreeHoldsAllMutexes(sqlite3 X) { - return true; - } - //# define sqlite3SchemaMutexHeld(X,Y,Z) 1 - static bool sqlite3SchemaMutexHeld(sqlite3 X, int y, Schema z) { - return true; - } -#endif + //# define sqlite3BtreeSharable(X) 0 + static bool sqlite3BtreeSharable( Btree X ) + { + return false; + } + + //# define sqlite3BtreeLeave(X) + static void sqlite3BtreeLeave( Btree X ) + { + } + + //# define sqlite3BtreeEnterCursor(X) + static void sqlite3BtreeEnterCursor( BtCursor X ) + { + } + + //# define sqlite3BtreeLeaveCursor(X) + static void sqlite3BtreeLeaveCursor( BtCursor X ) + { + } - //#endif // * _BTREE_H_ */ + //# define sqlite3BtreeLeaveAll(X) + static void sqlite3BtreeLeaveAll( sqlite3 X ) + { } + + //# define sqlite3BtreeHoldsMutex(X) 1 + static bool sqlite3BtreeHoldsMutex( Btree X ) + { + return true; + } + + //# define sqlite3BtreeHoldsAllMutexes(X) 1 + static bool sqlite3BtreeHoldsAllMutexes( sqlite3 X ) + { + return true; + } + //# define sqlite3SchemaMutexHeld(X,Y,Z) 1 + static bool sqlite3SchemaMutexHeld( sqlite3 X, int y, Schema z ) + { + return true; + } +#endif + + //#endif // * _BTREE_H_ */ + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/Delegates.cs b/src/extensions/IronPython.SQLite/c#sqlite/Delegates.cs index e59053ae5..97a7aeb4f 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/Delegates.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/Delegates.cs @@ -7,101 +7,103 @@ using System; using System.Text; - using HANDLE = System.IntPtr; +using i16 = System.Int16; using sqlite3_int64 = System.Int64; using u32 = System.UInt32; -namespace Community.CsharpSqlite { - using DbPage = Sqlite3.PgHdr; - using sqlite3_pcache = Sqlite3.PCache1; - using sqlite3_stmt = Sqlite3.Vdbe; - using sqlite3_value = Sqlite3.Mem; +namespace Community.CsharpSqlite +{ + using DbPage = Sqlite3.PgHdr; + using sqlite3_pcache = Sqlite3.PCache1; + using sqlite3_stmt = Sqlite3.Vdbe; + using sqlite3_value = Sqlite3.Mem; - public partial class Sqlite3 { - public delegate void dxAuth(object pAuthArg, int b, string c, string d, string e, string f); - public delegate int dxBusy(object pBtShared, int iValue); - public delegate void dxFreeAux(object pAuxArg); - public delegate int dxCallback(object pCallbackArg, sqlite3_int64 argc, object p2, object p3); - public delegate void dxalarmCallback(object pNotUsed, sqlite3_int64 iNotUsed, int size); - public delegate void dxCollNeeded(object pCollNeededArg, sqlite3 db, int eTextRep, string collationName); - public delegate int dxCommitCallback(object pCommitArg); - public delegate int dxCompare(object pCompareArg, int size1, string Key1, int size2, string Key2); - public delegate bool dxCompare4(string Key1, int size1, string Key2, int size2); - public delegate void dxDel(ref string pDelArg); // needs ref - public delegate void dxDelCollSeq(ref object pDelArg); // needs ref - public delegate void dxLog(object pLogArg, int i, string msg); - public delegate void dxLogcallback(object pCallbackArg, int argc, string p2); - public delegate void dxProfile(object pProfileArg, string msg, sqlite3_int64 time); - public delegate int dxProgress(object pProgressArg); - public delegate void dxRollbackCallback(object pRollbackArg); - public delegate void dxTrace(object pTraceArg, string msg); - public delegate void dxUpdateCallback(object pUpdateArg, int b, string c, string d, sqlite3_int64 e); - public delegate int dxWalCallback(object pWalArg, sqlite3 db, string zDb, int nEntry); + public partial class Sqlite3 + { + public delegate void dxAuth( object pAuthArg, int b, string c, string d, string e, string f ); + public delegate int dxBusy( object pBtShared, int iValue ); + public delegate void dxFreeAux( object pAuxArg ); + public delegate int dxCallback( object pCallbackArg, sqlite3_int64 argc, object p2, object p3 ); + public delegate void dxalarmCallback( object pNotUsed, sqlite3_int64 iNotUsed, int size ); + public delegate void dxCollNeeded( object pCollNeededArg, sqlite3 db, int eTextRep, string collationName ); + public delegate int dxCommitCallback( object pCommitArg ); + public delegate int dxCompare( object pCompareArg, int size1, string Key1, int size2, string Key2 ); + public delegate bool dxCompare4( string Key1, int size1, string Key2, int size2 ); + public delegate void dxDel( ref string pDelArg ); // needs ref + public delegate void dxDelCollSeq( ref object pDelArg ); // needs ref + public delegate void dxLog( object pLogArg, int i, string msg ); + public delegate void dxLogcallback( object pCallbackArg, int argc, string p2 ); + public delegate void dxProfile( object pProfileArg, string msg, sqlite3_int64 time ); + public delegate int dxProgress( object pProgressArg ); + public delegate void dxRollbackCallback( object pRollbackArg ); + public delegate void dxTrace( object pTraceArg, string msg ); + public delegate void dxUpdateCallback( object pUpdateArg, int b, string c, string d, sqlite3_int64 e ); + public delegate int dxWalCallback( object pWalArg, sqlite3 db, string zDb, int nEntry ); - /* - * FUNCTIONS - * - */ - public delegate void dxFunc(sqlite3_context ctx, int intValue, sqlite3_value[] value); - public delegate void dxStep(sqlite3_context ctx, int intValue, sqlite3_value[] value); - public delegate void dxFinal(sqlite3_context ctx); - public delegate void dxFDestroy(object pArg); - // - public delegate string dxColname(sqlite3_value pVal); - public delegate int dxFuncBtree(Btree p); - public delegate int dxExprTreeFunction(ref int pArg, Expr pExpr); - public delegate int dxExprTreeFunction_NC(NameContext pArg, ref Expr pExpr); - public delegate int dxExprTreeFunction_OBJ(object pArg, Expr pExpr); - /* - VFS Delegates - */ - public delegate int dxClose(sqlite3_file File_ID); - public delegate int dxCheckReservedLock(sqlite3_file File_ID, ref int pRes); - public delegate int dxDeviceCharacteristics(sqlite3_file File_ID); - public delegate int dxFileControl(sqlite3_file File_ID, int op, ref sqlite3_int64 pArgs); - public delegate int dxFileSize(sqlite3_file File_ID, ref long size); - public delegate int dxLock(sqlite3_file File_ID, int locktype); - public delegate int dxRead(sqlite3_file File_ID, byte[] buffer, int amount, sqlite3_int64 offset); - public delegate int dxSectorSize(sqlite3_file File_ID); - public delegate int dxSync(sqlite3_file File_ID, int flags); - public delegate int dxTruncate(sqlite3_file File_ID, sqlite3_int64 size); - public delegate int dxUnlock(sqlite3_file File_ID, int locktype); - public delegate int dxWrite(sqlite3_file File_ID, byte[] buffer, int amount, sqlite3_int64 offset); - public delegate int dxShmMap(sqlite3_file File_ID, int iPg, int pgsz, int pInt, out object pvolatile); - public delegate int dxShmLock(sqlite3_file File_ID, int offset, int n, int flags); - public delegate void dxShmBarrier(sqlite3_file File_ID); - public delegate int dxShmUnmap(sqlite3_file File_ID, int deleteFlag); - /* - sqlite_vfs Delegates - */ - public delegate int dxOpen(sqlite3_vfs vfs, string zName, sqlite3_file db, int flags, out int pOutFlags); - public delegate int dxDelete(sqlite3_vfs vfs, string zName, int syncDir); - public delegate int dxAccess(sqlite3_vfs vfs, string zName, int flags, out int pResOut); - public delegate int dxFullPathname(sqlite3_vfs vfs, string zName, int nOut, StringBuilder zOut); - public delegate HANDLE dxDlOpen(sqlite3_vfs vfs, string zFilename); - public delegate int dxDlError(sqlite3_vfs vfs, int nByte, string zErrMsg); - public delegate HANDLE dxDlSym(sqlite3_vfs vfs, HANDLE data, string zSymbol); - public delegate int dxDlClose(sqlite3_vfs vfs, HANDLE data); - public delegate int dxRandomness(sqlite3_vfs vfs, int nByte, byte[] buffer); - public delegate int dxSleep(sqlite3_vfs vfs, int microseconds); - public delegate int dxCurrentTime(sqlite3_vfs vfs, ref double currenttime); - public delegate int dxGetLastError(sqlite3_vfs pVfs, int nBuf, ref string zBuf); - public delegate int dxCurrentTimeInt64(sqlite3_vfs pVfs, ref sqlite3_int64 pTime); - public delegate int dxSetSystemCall(sqlite3_vfs pVfs, string zName, sqlite3_int64 sqlite3_syscall_ptr); - public delegate int dxGetSystemCall(sqlite3_vfs pVfs, string zName, sqlite3_int64 sqlite3_syscall_ptr); - public delegate int dxNextSystemCall(sqlite3_vfs pVfs, string zName, sqlite3_int64 sqlite3_syscall_ptr); + /* + * FUNCTIONS + * + */ + public delegate void dxFunc( sqlite3_context ctx, int intValue, sqlite3_value[] value ); + public delegate void dxStep( sqlite3_context ctx, int intValue, sqlite3_value[] value ); + public delegate void dxFinal( sqlite3_context ctx ); + public delegate void dxFDestroy( object pArg ); + // + public delegate string dxColname( sqlite3_value pVal ); + public delegate int dxFuncBtree( Btree p ); + public delegate int dxExprTreeFunction( ref int pArg, Expr pExpr ); + public delegate int dxExprTreeFunction_NC( NameContext pArg, ref Expr pExpr ); + public delegate int dxExprTreeFunction_OBJ( object pArg, Expr pExpr ); + /* + VFS Delegates + */ + public delegate int dxClose( sqlite3_file File_ID ); + public delegate int dxCheckReservedLock( sqlite3_file File_ID, ref int pRes ); + public delegate int dxDeviceCharacteristics( sqlite3_file File_ID ); + public delegate int dxFileControl( sqlite3_file File_ID, int op, ref sqlite3_int64 pArgs ); + public delegate int dxFileSize( sqlite3_file File_ID, ref long size ); + public delegate int dxLock( sqlite3_file File_ID, int locktype ); + public delegate int dxRead( sqlite3_file File_ID, byte[] buffer, int amount, sqlite3_int64 offset ); + public delegate int dxSectorSize( sqlite3_file File_ID ); + public delegate int dxSync( sqlite3_file File_ID, int flags ); + public delegate int dxTruncate( sqlite3_file File_ID, sqlite3_int64 size ); + public delegate int dxUnlock( sqlite3_file File_ID, int locktype ); + public delegate int dxWrite( sqlite3_file File_ID, byte[] buffer, int amount, sqlite3_int64 offset ); + public delegate int dxShmMap( sqlite3_file File_ID, int iPg, int pgsz, int pInt, out object pvolatile ); + public delegate int dxShmLock( sqlite3_file File_ID, int offset, int n, int flags ); + public delegate void dxShmBarrier( sqlite3_file File_ID ); + public delegate int dxShmUnmap( sqlite3_file File_ID, int deleteFlag ); + /* + sqlite_vfs Delegates + */ + public delegate int dxOpen( sqlite3_vfs vfs, string zName, sqlite3_file db, int flags, out int pOutFlags ); + public delegate int dxDelete( sqlite3_vfs vfs, string zName, int syncDir ); + public delegate int dxAccess( sqlite3_vfs vfs, string zName, int flags, out int pResOut ); + public delegate int dxFullPathname( sqlite3_vfs vfs, string zName, int nOut, StringBuilder zOut ); + public delegate HANDLE dxDlOpen( sqlite3_vfs vfs, string zFilename ); + public delegate int dxDlError( sqlite3_vfs vfs, int nByte, string zErrMsg ); + public delegate HANDLE dxDlSym( sqlite3_vfs vfs, HANDLE data, string zSymbol ); + public delegate int dxDlClose( sqlite3_vfs vfs, HANDLE data ); + public delegate int dxRandomness( sqlite3_vfs vfs, int nByte, byte[] buffer ); + public delegate int dxSleep( sqlite3_vfs vfs, int microseconds ); + public delegate int dxCurrentTime( sqlite3_vfs vfs, ref double currenttime ); + public delegate int dxGetLastError( sqlite3_vfs pVfs, int nBuf, ref string zBuf ); + public delegate int dxCurrentTimeInt64( sqlite3_vfs pVfs, ref sqlite3_int64 pTime ); + public delegate int dxSetSystemCall( sqlite3_vfs pVfs, string zName, sqlite3_int64 sqlite3_syscall_ptr ); + public delegate int dxGetSystemCall( sqlite3_vfs pVfs, string zName, sqlite3_int64 sqlite3_syscall_ptr ); + public delegate int dxNextSystemCall( sqlite3_vfs pVfs, string zName, sqlite3_int64 sqlite3_syscall_ptr ); - /* - * Pager Delegates - */ + /* + * Pager Delegates + */ - public delegate void dxDestructor(DbPage dbPage); /* Call this routine when freeing pages */ - public delegate int dxBusyHandler(object pBusyHandlerArg); - public delegate void dxReiniter(DbPage dbPage); /* Call this routine when reloading pages */ + public delegate void dxDestructor( DbPage dbPage ); /* Call this routine when freeing pages */ + public delegate int dxBusyHandler( object pBusyHandlerArg ); + public delegate void dxReiniter( DbPage dbPage ); /* Call this routine when reloading pages */ - public delegate void dxFreeSchema(Schema schema); + public delegate void dxFreeSchema( Schema schema ); #if SQLITE_HAS_CODEC public delegate byte[] dxCodec( codec_ctx pCodec, byte[] D, uint pageNumber, int X ); //void *(*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */ @@ -109,184 +111,184 @@ sqlite_vfs Delegates public delegate void dxCodecFree( ref codec_ctx pCodec ); //void (*xCodecFree)(void); /* Destructor for the codec */ #endif - //Module - public delegate void dxDestroy(ref PgHdr pDestroyArg); - public delegate int dxStress(object obj, PgHdr pPhHdr); + //Module + public delegate void dxDestroy( ref PgHdr pDestroyArg ); + public delegate int dxStress( object obj, PgHdr pPhHdr ); - //sqlite3_module - public delegate int smdxCreateConnect(sqlite3 db, object pAux, int argc, string[] constargv, out sqlite3_vtab ppVTab, out string pError); - public delegate int smdxBestIndex(sqlite3_vtab pVTab, ref sqlite3_index_info pIndex); - public delegate int smdxDisconnect(ref object pVTab); - public delegate int smdxDestroy(ref object pVTab); - public delegate int smdxOpen(sqlite3_vtab pVTab, out sqlite3_vtab_cursor ppCursor); - public delegate int smdxClose(ref sqlite3_vtab_cursor pCursor); - public delegate int smdxFilter(sqlite3_vtab_cursor pCursor, int idxNum, string idxStr, int argc, sqlite3_value[] argv); - public delegate int smdxNext(sqlite3_vtab_cursor pCursor); - public delegate int smdxEof(sqlite3_vtab_cursor pCursor); - public delegate int smdxColumn(sqlite3_vtab_cursor pCursor, sqlite3_context p2, int p3); - public delegate int smdxRowid(sqlite3_vtab_cursor pCursor, out sqlite3_int64 pRowid); - public delegate int smdxUpdate(sqlite3_vtab pVTab, int p1, sqlite3_value[] p2, out sqlite3_int64 p3); - public delegate int smdxFunction(sqlite3_vtab pVTab); - public delegate int smdxFindFunction(sqlite3_vtab pVtab, int nArg, string zName, ref dxFunc pxFunc, ref object ppArg); - public delegate int smdxRename(sqlite3_vtab pVtab, string zNew); - public delegate int smdxFunctionArg(sqlite3_vtab pVTab, int nArg); + //sqlite3_module + public delegate int smdxCreateConnect( sqlite3 db, object pAux, int argc, string[] constargv, out sqlite3_vtab ppVTab, out string pError ); + public delegate int smdxBestIndex( sqlite3_vtab pVTab, ref sqlite3_index_info pIndex ); + public delegate int smdxDisconnect( ref object pVTab ); + public delegate int smdxDestroy(ref object pVTab ); + public delegate int smdxOpen( sqlite3_vtab pVTab, out sqlite3_vtab_cursor ppCursor ); + public delegate int smdxClose( ref sqlite3_vtab_cursor pCursor ); + public delegate int smdxFilter( sqlite3_vtab_cursor pCursor, int idxNum, string idxStr, int argc, sqlite3_value[] argv ); + public delegate int smdxNext( sqlite3_vtab_cursor pCursor ); + public delegate int smdxEof( sqlite3_vtab_cursor pCursor ); + public delegate int smdxColumn( sqlite3_vtab_cursor pCursor, sqlite3_context p2, int p3 ); + public delegate int smdxRowid( sqlite3_vtab_cursor pCursor, out sqlite3_int64 pRowid ); + public delegate int smdxUpdate( sqlite3_vtab pVTab, int p1, sqlite3_value[] p2, out sqlite3_int64 p3 ); + public delegate int smdxFunction ( sqlite3_vtab pVTab ); + public delegate int smdxFindFunction( sqlite3_vtab pVtab, int nArg, string zName, ref dxFunc pxFunc, ref object ppArg ); + public delegate int smdxRename( sqlite3_vtab pVtab, string zNew ); + public delegate int smdxFunctionArg (sqlite3_vtab pVTab, int nArg ); - //AutoExtention - public delegate int dxInit(sqlite3 db, ref string zMessage, sqlite3_api_routines sar); + //AutoExtention + public delegate int dxInit( sqlite3 db, ref string zMessage, sqlite3_api_routines sar ); #if !SQLITE_OMIT_VIRTUALTABLE - public delegate int dmxCreate(sqlite3 db, object pAux, int argc, string p4, object argv, sqlite3_vtab ppVTab, char p7); - public delegate int dmxConnect(sqlite3 db, object pAux, int argc, string p4, object argv, sqlite3_vtab ppVTab, char p7); - public delegate int dmxBestIndex(sqlite3_vtab pVTab, ref sqlite3_index_info pIndexInfo); - public delegate int dmxDisconnect(sqlite3_vtab pVTab); - public delegate int dmxDestroy(sqlite3_vtab pVTab); - public delegate int dmxOpen(sqlite3_vtab pVTab, sqlite3_vtab_cursor ppCursor); - public delegate int dmxClose(sqlite3_vtab_cursor pCursor); - public delegate int dmxFilter(sqlite3_vtab_cursor pCursor, int idmxNum, string idmxStr, int argc, sqlite3_value argv); - public delegate int dmxNext(sqlite3_vtab_cursor pCursor); - public delegate int dmxEof(sqlite3_vtab_cursor pCursor); - public delegate int dmxColumn(sqlite3_vtab_cursor pCursor, sqlite3_context ctx, int i3); - public delegate int dmxRowid(sqlite3_vtab_cursor pCursor, sqlite3_int64 pRowid); - public delegate int dmxUpdate(sqlite3_vtab pVTab, int i2, sqlite3_value sv3, sqlite3_int64 v4); - public delegate int dmxBegin(sqlite3_vtab pVTab); - public delegate int dmxSync(sqlite3_vtab pVTab); - public delegate int dmxCommit(sqlite3_vtab pVTab); - public delegate int dmxRollback(sqlite3_vtab pVTab); - public delegate int dmxFindFunction(sqlite3_vtab pVtab, int nArg, string zName); - public delegate int dmxRename(sqlite3_vtab pVtab, string zNew); + public delegate int dmxCreate(sqlite3 db, object pAux, int argc, string p4, object argv, sqlite3_vtab ppVTab, char p7); + public delegate int dmxConnect(sqlite3 db, object pAux, int argc, string p4, object argv, sqlite3_vtab ppVTab, char p7); + public delegate int dmxBestIndex(sqlite3_vtab pVTab, ref sqlite3_index_info pIndexInfo); + public delegate int dmxDisconnect(sqlite3_vtab pVTab); + public delegate int dmxDestroy(sqlite3_vtab pVTab); + public delegate int dmxOpen(sqlite3_vtab pVTab, sqlite3_vtab_cursor ppCursor); + public delegate int dmxClose(sqlite3_vtab_cursor pCursor); + public delegate int dmxFilter(sqlite3_vtab_cursor pCursor, int idmxNum, string idmxStr, int argc, sqlite3_value argv); + public delegate int dmxNext(sqlite3_vtab_cursor pCursor); + public delegate int dmxEof(sqlite3_vtab_cursor pCursor); + public delegate int dmxColumn(sqlite3_vtab_cursor pCursor, sqlite3_context ctx, int i3); + public delegate int dmxRowid(sqlite3_vtab_cursor pCursor, sqlite3_int64 pRowid); + public delegate int dmxUpdate(sqlite3_vtab pVTab, int i2, sqlite3_value sv3, sqlite3_int64 v4); + public delegate int dmxBegin(sqlite3_vtab pVTab); + public delegate int dmxSync(sqlite3_vtab pVTab); + public delegate int dmxCommit(sqlite3_vtab pVTab); + public delegate int dmxRollback(sqlite3_vtab pVTab); + public delegate int dmxFindFunction(sqlite3_vtab pVtab, int nArg, string zName); + public delegate int dmxRename(sqlite3_vtab pVtab, string zNew); #endif - //Faults - public delegate void void_function(); + //Faults + public delegate void void_function(); - //Mem Methods - public delegate int dxMemInit(object o); - public delegate void dxMemShutdown(object o); - public delegate byte[] dxMalloc(int nSize); - public delegate int[] dxMallocInt(int nSize); - public delegate Mem dxMallocMem(Mem pMem); - public delegate void dxFree(ref byte[] pOld); - public delegate void dxFreeInt(ref int[] pOld); - public delegate void dxFreeMem(ref Mem pOld); - public delegate byte[] dxRealloc(byte[] pOld, int nSize); - public delegate int dxSize(byte[] pArray); - public delegate int dxRoundup(int nSize); + //Mem Methods + public delegate int dxMemInit( object o ); + public delegate void dxMemShutdown( object o ); + public delegate byte[] dxMalloc( int nSize ); + public delegate int[] dxMallocInt( int nSize ); + public delegate Mem dxMallocMem( Mem pMem ); + public delegate void dxFree( ref byte[] pOld ); + public delegate void dxFreeInt( ref int[] pOld ); + public delegate void dxFreeMem( ref Mem pOld ); + public delegate byte[] dxRealloc( byte[] pOld, int nSize ); + public delegate int dxSize( byte[] pArray ); + public delegate int dxRoundup( int nSize ); - //Mutex Methods - public delegate int dxMutexInit(); - public delegate int dxMutexEnd(); - public delegate sqlite3_mutex dxMutexAlloc(int iNumber); - public delegate void dxMutexFree(sqlite3_mutex sm); - public delegate void dxMutexEnter(sqlite3_mutex sm); - public delegate int dxMutexTry(sqlite3_mutex sm); - public delegate void dxMutexLeave(sqlite3_mutex sm); - public delegate bool dxMutexHeld(sqlite3_mutex sm); - public delegate bool dxMutexNotheld(sqlite3_mutex sm); + //Mutex Methods + public delegate int dxMutexInit(); + public delegate int dxMutexEnd(); + public delegate sqlite3_mutex dxMutexAlloc( int iNumber ); + public delegate void dxMutexFree( sqlite3_mutex sm ); + public delegate void dxMutexEnter( sqlite3_mutex sm ); + public delegate int dxMutexTry( sqlite3_mutex sm ); + public delegate void dxMutexLeave( sqlite3_mutex sm ); + public delegate bool dxMutexHeld( sqlite3_mutex sm ); + public delegate bool dxMutexNotheld( sqlite3_mutex sm ); - public delegate object dxColumn(sqlite3_stmt pStmt, int i); - public delegate int dxColumn_I(sqlite3_stmt pStmt, int i); + public delegate object dxColumn( sqlite3_stmt pStmt, int i ); + public delegate int dxColumn_I( sqlite3_stmt pStmt, int i ); - // Walker Methods - public delegate int dxExprCallback(Walker W, ref Expr E); /* Callback for expressions */ - public delegate int dxSelectCallback(Walker W, Select S); /* Callback for SELECTs */ + // Walker Methods + public delegate int dxExprCallback( Walker W, ref Expr E ); /* Callback for expressions */ + public delegate int dxSelectCallback( Walker W, Select S ); /* Callback for SELECTs */ - // pcache Methods - public delegate int dxPC_Init(object NotUsed); - public delegate void dxPC_Shutdown(object NotUsed); - public delegate sqlite3_pcache dxPC_Create(int szPage, bool bPurgeable); - public delegate void dxPC_Cachesize(sqlite3_pcache pCache, int nCachesize); - public delegate int dxPC_Pagecount(sqlite3_pcache pCache); - public delegate PgHdr dxPC_Fetch(sqlite3_pcache pCache, u32 key, int createFlag); - public delegate void dxPC_Unpin(sqlite3_pcache pCache, PgHdr p2, bool discard); - public delegate void dxPC_Rekey(sqlite3_pcache pCache, PgHdr p2, u32 oldKey, u32 newKey); - public delegate void dxPC_Truncate(sqlite3_pcache pCache, u32 iLimit); - public delegate void dxPC_Destroy(ref sqlite3_pcache pCache); + // pcache Methods + public delegate int dxPC_Init( object NotUsed ); + public delegate void dxPC_Shutdown( object NotUsed ); + public delegate sqlite3_pcache dxPC_Create( int szPage, bool bPurgeable ); + public delegate void dxPC_Cachesize( sqlite3_pcache pCache, int nCachesize ); + public delegate int dxPC_Pagecount( sqlite3_pcache pCache ); + public delegate PgHdr dxPC_Fetch( sqlite3_pcache pCache, u32 key, int createFlag ); + public delegate void dxPC_Unpin( sqlite3_pcache pCache, PgHdr p2, bool discard ); + public delegate void dxPC_Rekey( sqlite3_pcache pCache, PgHdr p2, u32 oldKey, u32 newKey ); + public delegate void dxPC_Truncate( sqlite3_pcache pCache, u32 iLimit ); + public delegate void dxPC_Destroy( ref sqlite3_pcache pCache ); - public delegate void dxIter(PgHdr p); + public delegate void dxIter( PgHdr p ); #if NET_35 || NET_40 - //API Simplifications -- Actions - public static Action ResultBlob = sqlite3_result_blob; - public static Action ResultDouble = sqlite3_result_double; - public static Action ResultError = sqlite3_result_error; - public static Action ResultErrorCode = sqlite3_result_error_code; - public static Action ResultErrorNoMem = sqlite3_result_error_nomem; - public static Action ResultErrorTooBig = sqlite3_result_error_toobig; - public static Action ResultInt = sqlite3_result_int; - public static Action ResultInt64 = sqlite3_result_int64; - public static Action ResultNull = sqlite3_result_null; - public static Action ResultText = sqlite3_result_text; - public static Action ResultText_Offset = sqlite3_result_text; - public static Action ResultValue = sqlite3_result_value; - public static Action ResultZeroblob = sqlite3_result_zeroblob; - public static Action SetAuxdata = sqlite3_set_auxdata; + //API Simplifications -- Actions + public static Action ResultBlob = sqlite3_result_blob; + public static Action ResultDouble = sqlite3_result_double; + public static Action ResultError = sqlite3_result_error; + public static Action ResultErrorCode = sqlite3_result_error_code; + public static Action ResultErrorNoMem = sqlite3_result_error_nomem; + public static Action ResultErrorTooBig = sqlite3_result_error_toobig; + public static Action ResultInt = sqlite3_result_int; + public static Action ResultInt64 = sqlite3_result_int64; + public static Action ResultNull = sqlite3_result_null; + public static Action ResultText = sqlite3_result_text; + public static Action ResultText_Offset = sqlite3_result_text; + public static Action ResultValue = sqlite3_result_value; + public static Action ResultZeroblob = sqlite3_result_zeroblob; + public static Action SetAuxdata = sqlite3_set_auxdata; - //API Simplifications -- Functions - public delegate Int32 FinalizeDelegate(sqlite3_stmt pStmt); - public static FinalizeDelegate Finalize = sqlite3_finalize; + //API Simplifications -- Functions + public delegate Int32 FinalizeDelegate( sqlite3_stmt pStmt ); + public static FinalizeDelegate Finalize = sqlite3_finalize; - public static Func ClearBindings = sqlite3_clear_bindings; - public static Func ColumnBlob = sqlite3_column_blob; - public static Func ColumnBytes = sqlite3_column_bytes; - public static Func ColumnBytes16 = sqlite3_column_bytes16; - public static Func ColumnCount = sqlite3_column_count; - public static Func ColumnDecltype = sqlite3_column_decltype; - public static Func ColumnDouble = sqlite3_column_double; - public static Func ColumnInt = sqlite3_column_int; - public static Func ColumnInt64 = sqlite3_column_int64; - public static Func ColumnName = sqlite3_column_name; - public static Func ColumnText = sqlite3_column_text; - public static Func ColumnType = sqlite3_column_type; - public static Func ColumnValue = sqlite3_column_value; - public static Func DataCount = sqlite3_data_count; - public static Func Reset = sqlite3_reset; - public static Func Step = sqlite3_step; + public static Func ClearBindings = sqlite3_clear_bindings; + public static Func ColumnBlob = sqlite3_column_blob; + public static Func ColumnBytes = sqlite3_column_bytes; + public static Func ColumnBytes16 = sqlite3_column_bytes16; + public static Func ColumnCount = sqlite3_column_count; + public static Func ColumnDecltype = sqlite3_column_decltype; + public static Func ColumnDouble = sqlite3_column_double; + public static Func ColumnInt = sqlite3_column_int; + public static Func ColumnInt64 = sqlite3_column_int64; + public static Func ColumnName = sqlite3_column_name; + public static Func ColumnText = sqlite3_column_text; + public static Func ColumnType = sqlite3_column_type; + public static Func ColumnValue = sqlite3_column_value; + public static Func DataCount = sqlite3_data_count; + public static Func Reset = sqlite3_reset; + public static Func Step = sqlite3_step; - public static Func BindBlob = sqlite3_bind_blob; - public static Func BindDouble = sqlite3_bind_double; - public static Func BindInt = sqlite3_bind_int; - public static Func BindInt64 = sqlite3_bind_int64; - public static Func BindNull = sqlite3_bind_null; - public static Func BindParameterCount = sqlite3_bind_parameter_count; - public static Func BindParameterIndex = sqlite3_bind_parameter_index; - public static Func BindParameterName = sqlite3_bind_parameter_name; - public static Func BindText = sqlite3_bind_text; - public static Func BindValue = sqlite3_bind_value; - public static Func BindZeroblob = sqlite3_bind_zeroblob; + public static Func BindBlob = sqlite3_bind_blob; + public static Func BindDouble = sqlite3_bind_double; + public static Func BindInt = sqlite3_bind_int; + public static Func BindInt64 = sqlite3_bind_int64; + public static Func BindNull = sqlite3_bind_null; + public static Func BindParameterCount = sqlite3_bind_parameter_count; + public static Func BindParameterIndex = sqlite3_bind_parameter_index; + public static Func BindParameterName = sqlite3_bind_parameter_name; + public static Func BindText = sqlite3_bind_text; + public static Func BindValue = sqlite3_bind_value; + public static Func BindZeroblob = sqlite3_bind_zeroblob; - public delegate Int32 OpenDelegate(string zFilename, out sqlite3 ppDb); - public static Func Close = sqlite3_close; - public static Func DbHandle = sqlite3_db_handle; - public static Func Errmsg = sqlite3_errmsg; - public static OpenDelegate Open = sqlite3_open; - public static Func NextStmt = sqlite3_next_stmt; - public static Func Shutdown = sqlite3_shutdown; - public static Func StmtStatus = sqlite3_stmt_status; + public delegate Int32 OpenDelegate( string zFilename, out sqlite3 ppDb ); + public static Func Close = sqlite3_close; + public static Func DbHandle = sqlite3_db_handle; + public static Func Errmsg = sqlite3_errmsg; + public static OpenDelegate Open = sqlite3_open; + public static Func NextStmt = sqlite3_next_stmt; + public static Func Shutdown = sqlite3_shutdown; + public static Func StmtStatus = sqlite3_stmt_status; - public delegate Int32 PrepareDelegate(sqlite3 db, String zSql, Int32 nBytes, ref sqlite3_stmt ppStmt, ref string pzTail); - public delegate Int32 PrepareDelegateNoTail(sqlite3 db, String zSql, Int32 nBytes, ref sqlite3_stmt ppStmt, Int32 iDummy); - public static PrepareDelegate Prepare = sqlite3_prepare; - public static PrepareDelegate PrepareV2 = sqlite3_prepare_v2; - public static PrepareDelegateNoTail PrepareV2NoTail = sqlite3_prepare_v2; + public delegate Int32 PrepareDelegate( sqlite3 db, String zSql, Int32 nBytes, ref sqlite3_stmt ppStmt, ref string pzTail ); + public delegate Int32 PrepareDelegateNoTail( sqlite3 db, String zSql, Int32 nBytes, ref sqlite3_stmt ppStmt, Int32 iDummy ); + public static PrepareDelegate Prepare = sqlite3_prepare; + public static PrepareDelegate PrepareV2 = sqlite3_prepare_v2; + public static PrepareDelegateNoTail PrepareV2NoTail = sqlite3_prepare_v2; - public static Func AggregateContext = sqlite3_aggregate_context; - public static Func GetAuxdata = sqlite3_get_auxdata; - public static Func ContextDbHandle = sqlite3_context_db_handle; - public static Func UserData = sqlite3_user_data; + public static Func AggregateContext = sqlite3_aggregate_context; + public static Func GetAuxdata = sqlite3_get_auxdata; + public static Func ContextDbHandle = sqlite3_context_db_handle; + public static Func UserData = sqlite3_user_data; - public static Func ValueBlob = sqlite3_value_blob; - public static Func ValueBytes = sqlite3_value_bytes; - public static Func ValueBytes16 = sqlite3_value_bytes16; - public static Func ValueDouble = sqlite3_value_double; - public static Func ValueInt = sqlite3_value_int; - public static Func ValueInt64 = sqlite3_value_int64; - public static Func ValueText = sqlite3_value_text; - public static Func ValueType = sqlite3_value_type; + public static Func ValueBlob = sqlite3_value_blob; + public static Func ValueBytes = sqlite3_value_bytes; + public static Func ValueBytes16 = sqlite3_value_bytes16; + public static Func ValueDouble = sqlite3_value_double; + public static Func ValueInt = sqlite3_value_int; + public static Func ValueInt64 = sqlite3_value_int64; + public static Func ValueText = sqlite3_value_text; + public static Func ValueType = sqlite3_value_type; #endif - } + } } -#if (NET_35 && !NET_40) || WINDOWS_PHONE +#if( NET_35 && !NET_40) || WINDOWS_PHONE namespace System { // Summary: diff --git a/src/extensions/IronPython.SQLite/c#sqlite/Hash_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/Hash_h.cs index 7274cd967..cbb09ce7a 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/Hash_h.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/Hash_h.cs @@ -1,130 +1,141 @@ +using u8 = System.Byte; using u32 = System.UInt32; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2001 September 22 - ** - ** 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 is the header file for the generic hash-table implemenation - ** used in SQLite. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#if !_SQLITE_HASH_H_ - //#define _SQLITE_HASH_H_ +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 2001 September 22 + ** + ** 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 is the header file for the generic hash-table implemenation + ** used in SQLite. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + //#if !_SQLITE_HASH_H_ + //#define _SQLITE_HASH_H_ - /* Forward declarations of structures. */ - //typedef struct Hash Hash; - //typedef struct HashElem HashElem; + /* Forward declarations of structures. */ + //typedef struct Hash Hash; + //typedef struct HashElem HashElem; - /* A complete hash table is an instance of the following structure. - ** The internals of this structure are intended to be opaque -- client - ** code should not attempt to access or modify the fields of this structure - ** directly. Change this structure only by using the routines below. - ** However, some of the "procedures" and "functions" for modifying and - ** accessing this structure are really macros, so we can't really make - ** this structure opaque. - ** - ** All elements of the hash table are on a single doubly-linked list. - ** Hash.first points to the head of this list. - ** - ** There are Hash.htsize buckets. Each bucket points to a spot in - ** the global doubly-linked list. The contents of the bucket are the - ** element pointed to plus the next _ht.count-1 elements in the list. - ** - ** Hash.htsize and Hash.ht may be zero. In that case lookup is done - ** by a linear search of the global list. For small tables, the - ** Hash.ht table is never allocated because if there are few elements - ** in the table, it is faster to do a linear search than to manage - ** the hash table. - */ - public class _ht { /* the hash table */ - public int count; /* Number of entries with this hash */ - public HashElem chain; /* Pointer to first entry with this hash */ - }; + /* A complete hash table is an instance of the following structure. + ** The internals of this structure are intended to be opaque -- client + ** code should not attempt to access or modify the fields of this structure + ** directly. Change this structure only by using the routines below. + ** However, some of the "procedures" and "functions" for modifying and + ** accessing this structure are really macros, so we can't really make + ** this structure opaque. + ** + ** All elements of the hash table are on a single doubly-linked list. + ** Hash.first points to the head of this list. + ** + ** There are Hash.htsize buckets. Each bucket points to a spot in + ** the global doubly-linked list. The contents of the bucket are the + ** element pointed to plus the next _ht.count-1 elements in the list. + ** + ** Hash.htsize and Hash.ht may be zero. In that case lookup is done + ** by a linear search of the global list. For small tables, the + ** Hash.ht table is never allocated because if there are few elements + ** in the table, it is faster to do a linear search than to manage + ** the hash table. + */ + public class _ht + { /* the hash table */ + public int count; /* Number of entries with this hash */ + public HashElem chain; /* Pointer to first entry with this hash */ + }; - public class Hash { - public u32 htsize = 31; /* Number of buckets in the hash table */ - public u32 count; /* Number of entries in this table */ - public HashElem first; /* The first element of the array */ - public _ht[] ht; - public Hash Copy() { - if (this == null) - return null; - else { - Hash cp = (Hash)MemberwiseClone(); - return cp; - } - } - }; + public class Hash + { + public u32 htsize = 31; /* Number of buckets in the hash table */ + public u32 count; /* Number of entries in this table */ + public HashElem first; /* The first element of the array */ + public _ht[] ht; + public Hash Copy() + { + if ( this == null ) + return null; + else + { + Hash cp = (Hash)MemberwiseClone(); + return cp; + } + } + }; - /* Each element in the hash table is an instance of the following - ** structure. All elements are stored on a single doubly-linked list. - ** - ** Again, this structure is intended to be opaque, but it can't really - ** be opaque because it is used by macros. - */ - public class HashElem { - public HashElem next; - public HashElem prev; /* Next and previous elements in the table */ - public object data; /* Data associated with this element */ - public string pKey; - public int nKey; /* Key associated with this element */ - }; + /* Each element in the hash table is an instance of the following + ** structure. All elements are stored on a single doubly-linked list. + ** + ** Again, this structure is intended to be opaque, but it can't really + ** be opaque because it is used by macros. + */ + public class HashElem + { + public HashElem next; + public HashElem prev; /* Next and previous elements in the table */ + public object data; /* Data associated with this element */ + public string pKey; + public int nKey; /* Key associated with this element */ + }; - /* - ** Access routines. To delete, insert a NULL pointer. - */ - //void sqlite3HashInit(Hash); - //void *sqlite3HashInsert(Hash*, string pKey, int nKey, object *pData); - //void *sqlite3HashFind(const Hash*, string pKey, int nKey); - //void sqlite3HashClear(Hash); + /* + ** Access routines. To delete, insert a NULL pointer. + */ + //void sqlite3HashInit(Hash); + //void *sqlite3HashInsert(Hash*, string pKey, int nKey, object *pData); + //void *sqlite3HashFind(const Hash*, string pKey, int nKey); + //void sqlite3HashClear(Hash); - /* - ** Macros for looping over all elements of a hash table. The idiom is - ** like this: - ** - ** Hash h; - ** HashElem p; - ** ... - ** for(p=sqliteHashFirst(&h); p; p=sqliteHashNext(p)){ - ** SomeStructure pData = sqliteHashData(p); - ** // do something with pData - ** } - */ - //#define sqliteHashFirst(H) ((H).first) - static HashElem sqliteHashFirst(Hash H) { - return H.first; - } - //#define sqliteHashNext(E) ((E).next) - static HashElem sqliteHashNext(HashElem E) { - return E.next; - } - //#define sqliteHashData(E) ((E).data) - static object sqliteHashData(HashElem E) { - return E.data; - } - /* #define sqliteHashKey(E) ((E)->pKey) // NOT USED */ - /* #define sqliteHashKeysize(E) ((E)->nKey) // NOT USED */ + /* + ** Macros for looping over all elements of a hash table. The idiom is + ** like this: + ** + ** Hash h; + ** HashElem p; + ** ... + ** for(p=sqliteHashFirst(&h); p; p=sqliteHashNext(p)){ + ** SomeStructure pData = sqliteHashData(p); + ** // do something with pData + ** } + */ + //#define sqliteHashFirst(H) ((H).first) + static HashElem sqliteHashFirst( Hash H ) + { + return H.first; + } + //#define sqliteHashNext(E) ((E).next) + static HashElem sqliteHashNext( HashElem E ) + { + return E.next; + } + //#define sqliteHashData(E) ((E).data) + static object sqliteHashData( HashElem E ) + { + return E.data; + } + /* #define sqliteHashKey(E) ((E)->pKey) // NOT USED */ + /* #define sqliteHashKeysize(E) ((E)->nKey) // NOT USED */ - /* - ** Number of entries in a hash table - */ - /* #define sqliteHashCount(H) ((H)->count) // NOT USED */ + /* + ** Number of entries in a hash table + */ + /* #define sqliteHashCount(H) ((H)->count) // NOT USED */ - //#endif // * _SQLITE_HASH_H_ */ - } + //#endif // * _SQLITE_HASH_H_ */ + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/VdbeInt_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/VdbeInt_h.cs index 2666c677b..8dba30007 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/VdbeInt_h.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/VdbeInt_h.cs @@ -1,4 +1,6 @@ using System; +using System.Diagnostics; +using System.Runtime.InteropServices; using FILE = System.IO.TextWriter; @@ -6,6 +8,8 @@ using u8 = System.Byte; using u16 = System.UInt16; using u32 = System.UInt32; +using u64 = System.UInt64; +using unsigned = System.UIntPtr; using Pgno = System.UInt32; @@ -26,169 +30,176 @@ #endif -namespace Community.CsharpSqlite { - using Op = Sqlite3.VdbeOp; - - public partial class Sqlite3 { - /* - ** 2003 September 6 - ** - ** 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 is the header file for information that is private to the - ** VDBE. This information used to all be at the top of the single - ** source code file "vdbe.c". When that file became too big (over - ** 6000 lines long) it was split up into several smaller files and - ** this header information was factored out. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#if !_VDBEINT_H_ - //#define _VDBEINT_H_ - - /* - ** SQL is translated into a sequence of instructions to be - ** executed by a virtual machine. Each instruction is an instance - ** of the following structure. - */ - //typedef struct VdbeOp Op; - - /* - ** Boolean values - */ - //typedef unsigned char Bool; - - /* - ** A cursor is a pointer into a single BTree within a database file. - ** The cursor can seek to a BTree entry with a particular key, or - ** loop over all entries of the Btree. You can also insert new BTree - ** entries or retrieve the key or data from the entry that the cursor - ** is currently pointing to. - ** - ** Every cursor that the virtual machine has open is represented by an - ** instance of the following structure. - */ - public class VdbeCursor { - public BtCursor pCursor; /* The cursor structure of the backend */ - public Btree pBt; /* Separate file holding temporary table */ - public KeyInfo pKeyInfo; /* Info about index keys needed by index cursors */ - public int iDb; /* Index of cursor database in db->aDb[] (or -1) */ - public int pseudoTableReg; /* Register holding pseudotable content. */ - public int nField; /* Number of fields in the header */ - public bool zeroed; /* True if zeroed out and ready for reuse */ - public bool rowidIsValid; /* True if lastRowid is valid */ - public bool atFirst; /* True if pointing to first entry */ - public bool useRandomRowid; /* Generate new record numbers semi-randomly */ - public bool nullRow; /* True if pointing to a row with no data */ - public bool deferredMoveto; /* A call to sqlite3BtreeMoveto() is needed */ - public bool isTable; /* True if a table requiring integer keys */ - public bool isIndex; /* True if an index containing keys only - no data */ - public bool isOrdered; /* True if the underlying table is BTREE_UNORDERED */ +namespace Community.CsharpSqlite +{ + using Op = Sqlite3.VdbeOp; + + public partial class Sqlite3 + { + /* + ** 2003 September 6 + ** + ** 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 is the header file for information that is private to the + ** VDBE. This information used to all be at the top of the single + ** source code file "vdbe.c". When that file became too big (over + ** 6000 lines long) it was split up into several smaller files and + ** this header information was factored out. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#if !_VDBEINT_H_ + //#define _VDBEINT_H_ + + /* + ** SQL is translated into a sequence of instructions to be + ** executed by a virtual machine. Each instruction is an instance + ** of the following structure. + */ + //typedef struct VdbeOp Op; + + /* + ** Boolean values + */ + //typedef unsigned char Bool; + + /* + ** A cursor is a pointer into a single BTree within a database file. + ** The cursor can seek to a BTree entry with a particular key, or + ** loop over all entries of the Btree. You can also insert new BTree + ** entries or retrieve the key or data from the entry that the cursor + ** is currently pointing to. + ** + ** Every cursor that the virtual machine has open is represented by an + ** instance of the following structure. + */ + public class VdbeCursor + { + public BtCursor pCursor; /* The cursor structure of the backend */ + public Btree pBt; /* Separate file holding temporary table */ + public KeyInfo pKeyInfo; /* Info about index keys needed by index cursors */ + public int iDb; /* Index of cursor database in db->aDb[] (or -1) */ + public int pseudoTableReg; /* Register holding pseudotable content. */ + public int nField; /* Number of fields in the header */ + public bool zeroed; /* True if zeroed out and ready for reuse */ + public bool rowidIsValid; /* True if lastRowid is valid */ + public bool atFirst; /* True if pointing to first entry */ + public bool useRandomRowid; /* Generate new record numbers semi-randomly */ + public bool nullRow; /* True if pointing to a row with no data */ + public bool deferredMoveto; /* A call to sqlite3BtreeMoveto() is needed */ + public bool isTable; /* True if a table requiring integer keys */ + public bool isIndex; /* True if an index containing keys only - no data */ + public bool isOrdered; /* True if the underlying table is BTREE_UNORDERED */ #if !SQLITE_OMIT_VIRTUALTABLE - public sqlite3_vtab_cursor pVtabCursor; /* The cursor for a virtual table */ - public sqlite3_module pModule; /* Module for cursor pVtabCursor */ + public sqlite3_vtab_cursor pVtabCursor; /* The cursor for a virtual table */ + public sqlite3_module pModule; /* Module for cursor pVtabCursor */ #endif - public i64 seqCount; /* Sequence counter */ - public i64 movetoTarget; /* Argument to the deferred sqlite3BtreeMoveto() */ - public i64 lastRowid; /* Last rowid from a Next or NextIdx operation */ - - /* Result of last sqlite3BtreeMoveto() done by an OP_NotExists or - ** OP_IsUnique opcode on this cursor. */ - public int seekResult; - - /* Cached information about the header for the data record that the - ** cursor is currently pointing to. Only valid if cacheStatus matches - ** Vdbe.cacheCtr. Vdbe.cacheCtr will never take on the value of - ** CACHE_STALE and so setting cacheStatus=CACHE_STALE guarantees that - ** the cache is out of date. - ** - ** aRow might point to (ephemeral) data for the current row, or it might - ** be NULL. - */ - public u32 cacheStatus; /* Cache is valid if this matches Vdbe.cacheCtr */ - public Pgno payloadSize; /* Total number of bytes in the record */ - public u32[] aType; /* Type values for all entries in the record */ - public u32[] aOffset; /* Cached offsets to the start of each columns data */ - public int aRow; /* Pointer to Data for the current row, if all on one page */ - - public VdbeCursor Copy() { - return (VdbeCursor)MemberwiseClone(); - } - }; - //typedef struct VdbeCursor VdbeCursor; - - - /* - ** When a sub-program is executed (OP_Program), a structure of this type - ** is allocated to store the current value of the program counter, as - ** well as the current memory cell array and various other frame specific - ** values stored in the Vdbe struct. When the sub-program is finished, - ** these values are copied back to the Vdbe from the VdbeFrame structure, - ** restoring the state of the VM to as it was before the sub-program - ** began executing. - ** - ** The memory for a VdbeFrame object is allocated and managed by a memory - ** cell in the parent (calling) frame. When the memory cell is deleted or - ** overwritten, the VdbeFrame object is not freed immediately. Instead, it - ** is linked into the Vdbe.pDelFrame list. The contents of the Vdbe.pDelFrame - ** list is deleted when the VM is reset in VdbeHalt(). The reason for doing - ** this instead of deleting the VdbeFrame immediately is to avoid recursive - ** calls to sqlite3VdbeMemRelease() when the memory cells belonging to the - ** child frame are released. - ** - ** The currently executing frame is stored in Vdbe.pFrame. Vdbe.pFrame is - ** set to NULL if the currently executing frame is the main program. - */ - //typedef struct VdbeFrame VdbeFrame; - public class VdbeFrame { - public Vdbe v; /* VM this frame belongs to */ - public int pc; /* Program Counter in parent (calling) frame */ - public Op[] aOp; /* Program instructions for parent frame */ - public int nOp; /* Size of aOp array */ - public Mem[] aMem; /* Array of memory cells for parent frame */ - public int nMem; /* Number of entries in aMem */ - public VdbeCursor[] apCsr; /* Array of Vdbe cursors for parent frame */ - public u16 nCursor; /* Number of entries in apCsr */ - public int token; /* Copy of SubProgram.token */ - public int nChildMem; /* Number of memory cells for child frame */ - public int nChildCsr; /* Number of cursors for child frame */ - public i64 lastRowid; /* Last insert rowid (sqlite3.lastRowid) */ - public int nChange; /* Statement changes (Vdbe.nChanges) */ - public VdbeFrame pParent; /* Parent of this frame, or NULL if parent is main */ - // - // Needed for C# Implementation - // - public Mem[] aChildMem; /* Array of memory cells for child frame */ - public VdbeCursor[] aChildCsr; /* Array of cursors for child frame */ - }; - - //#define VdbeFrameMem(p) ((Mem )&((u8 )p)[ROUND8(sizeof(VdbeFrame))]) - /* - ** A value for VdbeCursor.cacheValid that means the cache is always invalid. - */ - const int CACHE_STALE = 0; - - /* - ** Internally, the vdbe manipulates nearly all SQL values as Mem - ** structures. Each Mem struct may cache multiple representations (string, - ** integer etc.) of the same value. - */ - public class Mem { - public sqlite3 db; /* The associated database connection */ - public string z; /* String value */ - public double r; /* Real value */ - public struct union_ip { + public i64 seqCount; /* Sequence counter */ + public i64 movetoTarget; /* Argument to the deferred sqlite3BtreeMoveto() */ + public i64 lastRowid; /* Last rowid from a Next or NextIdx operation */ + + /* Result of last sqlite3BtreeMoveto() done by an OP_NotExists or + ** OP_IsUnique opcode on this cursor. */ + public int seekResult; + + /* Cached information about the header for the data record that the + ** cursor is currently pointing to. Only valid if cacheStatus matches + ** Vdbe.cacheCtr. Vdbe.cacheCtr will never take on the value of + ** CACHE_STALE and so setting cacheStatus=CACHE_STALE guarantees that + ** the cache is out of date. + ** + ** aRow might point to (ephemeral) data for the current row, or it might + ** be NULL. + */ + public u32 cacheStatus; /* Cache is valid if this matches Vdbe.cacheCtr */ + public Pgno payloadSize; /* Total number of bytes in the record */ + public u32[] aType; /* Type values for all entries in the record */ + public u32[] aOffset; /* Cached offsets to the start of each columns data */ + public int aRow; /* Pointer to Data for the current row, if all on one page */ + + public VdbeCursor Copy() + { + return (VdbeCursor)MemberwiseClone(); + } + }; + //typedef struct VdbeCursor VdbeCursor; + + + /* + ** When a sub-program is executed (OP_Program), a structure of this type + ** is allocated to store the current value of the program counter, as + ** well as the current memory cell array and various other frame specific + ** values stored in the Vdbe struct. When the sub-program is finished, + ** these values are copied back to the Vdbe from the VdbeFrame structure, + ** restoring the state of the VM to as it was before the sub-program + ** began executing. + ** + ** The memory for a VdbeFrame object is allocated and managed by a memory + ** cell in the parent (calling) frame. When the memory cell is deleted or + ** overwritten, the VdbeFrame object is not freed immediately. Instead, it + ** is linked into the Vdbe.pDelFrame list. The contents of the Vdbe.pDelFrame + ** list is deleted when the VM is reset in VdbeHalt(). The reason for doing + ** this instead of deleting the VdbeFrame immediately is to avoid recursive + ** calls to sqlite3VdbeMemRelease() when the memory cells belonging to the + ** child frame are released. + ** + ** The currently executing frame is stored in Vdbe.pFrame. Vdbe.pFrame is + ** set to NULL if the currently executing frame is the main program. + */ + //typedef struct VdbeFrame VdbeFrame; + public class VdbeFrame + { + public Vdbe v; /* VM this frame belongs to */ + public int pc; /* Program Counter in parent (calling) frame */ + public Op[] aOp; /* Program instructions for parent frame */ + public int nOp; /* Size of aOp array */ + public Mem[] aMem; /* Array of memory cells for parent frame */ + public int nMem; /* Number of entries in aMem */ + public VdbeCursor[] apCsr; /* Array of Vdbe cursors for parent frame */ + public u16 nCursor; /* Number of entries in apCsr */ + public int token; /* Copy of SubProgram.token */ + public int nChildMem; /* Number of memory cells for child frame */ + public int nChildCsr; /* Number of cursors for child frame */ + public i64 lastRowid; /* Last insert rowid (sqlite3.lastRowid) */ + public int nChange; /* Statement changes (Vdbe.nChanges) */ + public VdbeFrame pParent; /* Parent of this frame, or NULL if parent is main */ + // + // Needed for C# Implementation + // + public Mem[] aChildMem; /* Array of memory cells for child frame */ + public VdbeCursor[] aChildCsr; /* Array of cursors for child frame */ + }; + + //#define VdbeFrameMem(p) ((Mem )&((u8 )p)[ROUND8(sizeof(VdbeFrame))]) + /* + ** A value for VdbeCursor.cacheValid that means the cache is always invalid. + */ + const int CACHE_STALE = 0; + + /* + ** Internally, the vdbe manipulates nearly all SQL values as Mem + ** structures. Each Mem struct may cache multiple representations (string, + ** integer etc.) of the same value. + */ + public class Mem + { + public sqlite3 db; /* The associated database connection */ + public string z; /* String value */ + public double r; /* Real value */ + public struct union_ip + { #if DEBUG_CLASS_MEM || DEBUG_CLASS_ALL public i64 _i; /* First operand */ public i64 i @@ -197,16 +208,16 @@ public i64 i set { _i = value; } } #else - public i64 i; /* Integer value used when MEM_Int is set in flags */ + public i64 i; /* Integer value used when MEM_Int is set in flags */ #endif - public int nZero; /* Used when bit MEM_Zero is set in flags */ - public FuncDef pDef; /* Used only when flags==MEM_Agg */ - public RowSet pRowSet; /* Used only when flags==MEM_RowSet */ - public VdbeFrame pFrame; /* Used when flags==MEM_Frame */ - }; - public union_ip u; - public byte[] zBLOB; /* BLOB value */ - public int n; /* Number of characters in string value, excluding '\0' */ + public int nZero; /* Used when bit MEM_Zero is set in flags */ + public FuncDef pDef; /* Used only when flags==MEM_Agg */ + public RowSet pRowSet; /* Used only when flags==MEM_RowSet */ + public VdbeFrame pFrame; /* Used when flags==MEM_Frame */ + }; + public union_ip u; + public byte[] zBLOB; /* BLOB value */ + public int n; /* Number of characters in string value, excluding '\0' */ #if DEBUG_CLASS_MEM || DEBUG_CLASS_ALL public u16 _flags; /* First operand */ public u16 flags @@ -215,322 +226,334 @@ public u16 flags set { _flags = value; } } #else - public u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */ + public u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */ #endif - public u8 type; /* One of SQLITE_NULL, SQLITE_TEXT, SQLITE_INTEGER, etc */ - public u8 enc; /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */ + public u8 type; /* One of SQLITE_NULL, SQLITE_TEXT, SQLITE_INTEGER, etc */ + public u8 enc; /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */ #if SQLITE_DEBUG - public Mem pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */ - public object pFiller; /* So that sizeof(Mem) is a multiple of 8 */ + public Mem pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */ + public object pFiller; /* So that sizeof(Mem) is a multiple of 8 */ #endif - public dxDel xDel; /* If not null, call this function to delete Mem.z */ - // Not used under c# - //public string zMalloc; /* Dynamic buffer allocated by sqlite3Malloc() */ - public Mem _Mem; /* Used when C# overload Z as MEM space */ - public SumCtx _SumCtx; /* Used when C# overload Z as Sum context */ - public SubProgram[] _SubProgram;/* Used when C# overload Z as SubProgram*/ - public StrAccum _StrAccum; /* Used when C# overload Z as STR context */ - public object _MD5Context; /* Used when C# overload Z as MD5 context */ - - public Mem() { - } - - public Mem(sqlite3 db, string z, double r, int i, int n, u16 flags, u8 type, u8 enc + public dxDel xDel; /* If not null, call this function to delete Mem.z */ + // Not used under c# + //public string zMalloc; /* Dynamic buffer allocated by sqlite3Malloc() */ + public Mem _Mem; /* Used when C# overload Z as MEM space */ + public SumCtx _SumCtx; /* Used when C# overload Z as Sum context */ + public SubProgram[] _SubProgram;/* Used when C# overload Z as SubProgram*/ + public StrAccum _StrAccum; /* Used when C# overload Z as STR context */ + public object _MD5Context; /* Used when C# overload Z as MD5 context */ + + public Mem() + { + } + + public Mem( sqlite3 db, string z, double r, int i, int n, u16 flags, u8 type, u8 enc #if SQLITE_DEBUG - , Mem pScopyFrom, object pFiller /* pScopyFrom, pFiller */ + , Mem pScopyFrom, object pFiller /* pScopyFrom, pFiller */ #endif - ) { - this.db = db; - this.z = z; - this.r = r; - this.u.i = i; - this.n = n; - this.flags = flags; + ) + { + this.db = db; + this.z = z; + this.r = r; + this.u.i = i; + this.n = n; + this.flags = flags; #if SQLITE_DEBUG - this.pScopyFrom = pScopyFrom; - this.pFiller = pFiller; + this.pScopyFrom = pScopyFrom; + this.pFiller = pFiller; #endif - this.type = type; - this.enc = enc; - } - - public void CopyTo(ref Mem ct) { - if (ct == null) - ct = new Mem(); - ct.u = u; - ct.r = r; - ct.db = db; - ct.z = z; - if (zBLOB == null) - ct.zBLOB = null; - else { - ct.zBLOB = sqlite3Malloc(zBLOB.Length); - Buffer.BlockCopy(zBLOB, 0, ct.zBLOB, 0, zBLOB.Length); - } - ct.n = n; - ct.flags = flags; - ct.type = type; - ct.enc = enc; - ct.xDel = xDel; - } - - }; - - /* One or more of the following flags are set to indicate the validOK - ** representations of the value stored in the Mem struct. - ** - ** If the MEM_Null flag is set, then the value is an SQL NULL value. - ** No other flags may be set in this case. - ** - ** If the MEM_Str flag is set then Mem.z points at a string representation. - ** Usually this is encoded in the same unicode encoding as the main - ** database (see below for exceptions). If the MEM_Term flag is also - ** set, then the string is nul terminated. The MEM_Int and MEM_Real - ** flags may coexist with the MEM_Str flag. - */ - //#define MEM_Null 0x0001 /* Value is NULL */ - //#define MEM_Str 0x0002 /* Value is a string */ - //#define MEM_Int 0x0004 /* Value is an integer */ - //#define MEM_Real 0x0008 /* Value is a real number */ - //#define MEM_Blob 0x0010 /* Value is a BLOB */ - //#define MEM_RowSet 0x0020 /* Value is a RowSet object */ - //#define MEM_Frame 0x0040 /* Value is a VdbeFrame object */ - //#define MEM_Invalid 0x0080 /* Value is undefined */ - //#define MEM_TypeMask 0x00ff /* Mask of type bits */ - const int MEM_Null = 0x0001; - const int MEM_Str = 0x0002; - const int MEM_Int = 0x0004; - const int MEM_Real = 0x0008; - const int MEM_Blob = 0x0010; - const int MEM_RowSet = 0x0020; - const int MEM_Frame = 0x0040; - const int MEM_Invalid = 0x0080; - const int MEM_TypeMask = 0x00ff; - - /* Whenever Mem contains a valid string or blob representation, one of - ** the following flags must be set to determine the memory management - ** policy for Mem.z. The MEM_Term flag tells us whether or not the - ** string is \000 or \u0000 terminated - // */ - //#define MEM_Term 0x0200 /* String rep is nul terminated */ - //#define MEM_Dyn 0x0400 /* Need to call sqliteFree() on Mem.z */ - //#define MEM_Static 0x0800 /* Mem.z points to a static string */ - //#define MEM_Ephem 0x1000 /* Mem.z points to an ephemeral string */ - //#define MEM_Agg 0x2000 /* Mem.z points to an agg function context */ - //#define MEM_Zero 0x4000 /* Mem.i contains count of 0s appended to blob */ - //#if SQLITE_OMIT_INCRBLOB - // #undef MEM_Zero - // #define MEM_Zero 0x0000 - //#endif - const int MEM_Term = 0x0200; - const int MEM_Dyn = 0x0400; - const int MEM_Static = 0x0800; - const int MEM_Ephem = 0x1000; - const int MEM_Agg = 0x2000; + this.type = type; + this.enc = enc; + } + + public void CopyTo( ref Mem ct ) + { + if ( ct == null ) + ct = new Mem(); + ct.u = u; + ct.r = r; + ct.db = db; + ct.z = z; + if ( zBLOB == null ) + ct.zBLOB = null; + else + { + ct.zBLOB = sqlite3Malloc( zBLOB.Length ); + Buffer.BlockCopy( zBLOB, 0, ct.zBLOB, 0, zBLOB.Length ); + } + ct.n = n; + ct.flags = flags; + ct.type = type; + ct.enc = enc; + ct.xDel = xDel; + } + + }; + + /* One or more of the following flags are set to indicate the validOK + ** representations of the value stored in the Mem struct. + ** + ** If the MEM_Null flag is set, then the value is an SQL NULL value. + ** No other flags may be set in this case. + ** + ** If the MEM_Str flag is set then Mem.z points at a string representation. + ** Usually this is encoded in the same unicode encoding as the main + ** database (see below for exceptions). If the MEM_Term flag is also + ** set, then the string is nul terminated. The MEM_Int and MEM_Real + ** flags may coexist with the MEM_Str flag. + */ + //#define MEM_Null 0x0001 /* Value is NULL */ + //#define MEM_Str 0x0002 /* Value is a string */ + //#define MEM_Int 0x0004 /* Value is an integer */ + //#define MEM_Real 0x0008 /* Value is a real number */ + //#define MEM_Blob 0x0010 /* Value is a BLOB */ + //#define MEM_RowSet 0x0020 /* Value is a RowSet object */ + //#define MEM_Frame 0x0040 /* Value is a VdbeFrame object */ + //#define MEM_Invalid 0x0080 /* Value is undefined */ + //#define MEM_TypeMask 0x00ff /* Mask of type bits */ + const int MEM_Null = 0x0001; + const int MEM_Str = 0x0002; + const int MEM_Int = 0x0004; + const int MEM_Real = 0x0008; + const int MEM_Blob = 0x0010; + const int MEM_RowSet = 0x0020; + const int MEM_Frame = 0x0040; + const int MEM_Invalid = 0x0080; + const int MEM_TypeMask = 0x00ff; + + /* Whenever Mem contains a valid string or blob representation, one of + ** the following flags must be set to determine the memory management + ** policy for Mem.z. The MEM_Term flag tells us whether or not the + ** string is \000 or \u0000 terminated + // */ + //#define MEM_Term 0x0200 /* String rep is nul terminated */ + //#define MEM_Dyn 0x0400 /* Need to call sqliteFree() on Mem.z */ + //#define MEM_Static 0x0800 /* Mem.z points to a static string */ + //#define MEM_Ephem 0x1000 /* Mem.z points to an ephemeral string */ + //#define MEM_Agg 0x2000 /* Mem.z points to an agg function context */ + //#define MEM_Zero 0x4000 /* Mem.i contains count of 0s appended to blob */ + //#if SQLITE_OMIT_INCRBLOB + // #undef MEM_Zero + // #define MEM_Zero 0x0000 + //#endif + const int MEM_Term = 0x0200; + const int MEM_Dyn = 0x0400; + const int MEM_Static = 0x0800; + const int MEM_Ephem = 0x1000; + const int MEM_Agg = 0x2000; #if !SQLITE_OMIT_INCRBLOB const int MEM_Zero = 0x4000; #else - const int MEM_Zero = 0x0000; + const int MEM_Zero = 0x0000; #endif - /* - ** Clear any existing type flags from a Mem and replace them with f + /* +** Clear any existing type flags from a Mem and replace them with f +*/ + //#define MemSetTypeFlag(p, f) \ + // ((p)->flags = ((p)->flags&~(MEM_TypeMask|MEM_Zero))|f) + static void MemSetTypeFlag( Mem p, int f ) + { + p.flags = (u16)( p.flags & ~( MEM_TypeMask | MEM_Zero ) | f ); + }// TODO -- Convert back to inline for speed + + /* + ** Return true if a memory cell is not marked as invalid. This macro + ** is for use inside Debug.Assert() statements only. */ - //#define MemSetTypeFlag(p, f) \ - // ((p)->flags = ((p)->flags&~(MEM_TypeMask|MEM_Zero))|f) - static void MemSetTypeFlag(Mem p, int f) { - p.flags = (u16)(p.flags & ~(MEM_TypeMask | MEM_Zero) | f); - }// TODO -- Convert back to inline for speed - - /* - ** Return true if a memory cell is not marked as invalid. This macro - ** is for use inside Debug.Assert() statements only. - */ #if SQLITE_DEBUG - //#define memIsValid(M) ((M)->flags & MEM_Invalid)==0 - static bool memIsValid(Mem M) { - return ((M).flags & MEM_Invalid) == 0; - } + //#define memIsValid(M) ((M)->flags & MEM_Invalid)==0 + static bool memIsValid( Mem M ) + { + return ( ( M ).flags & MEM_Invalid ) == 0; + } #else static bool memIsValid( Mem M ) { return true; } #endif - /* A VdbeFunc is just a FuncDef (defined in sqliteInt.h) that contains - ** additional information about auxiliary information bound to arguments - ** of the function. This is used to implement the sqlite3_get_auxdata() - ** and sqlite3_set_auxdata() APIs. The "auxdata" is some auxiliary data - ** that can be associated with a constant argument to a function. This - ** allows functions such as "regexp" to compile their constant regular - ** expression argument once and reused the compiled code for multiple - ** invocations. + /* A VdbeFunc is just a FuncDef (defined in sqliteInt.h) that contains +** additional information about auxiliary information bound to arguments +** of the function. This is used to implement the sqlite3_get_auxdata() +** and sqlite3_set_auxdata() APIs. The "auxdata" is some auxiliary data +** that can be associated with a constant argument to a function. This +** allows functions such as "regexp" to compile their constant regular +** expression argument once and reused the compiled code for multiple +** invocations. +*/ + public class AuxData + { + public object pAux; /* Aux data for the i-th argument */ + //(void ); /* Destructor for the aux data */ + }; + + public class VdbeFunc : FuncDef + { + public FuncDef pFunc; /* The definition of the function */ + public int nAux; /* Number of entries allocated for apAux[] */ + public AuxData[] apAux = new AuxData[2]; /* One slot for each function argument */ + }; + + /* + ** The "context" argument for a installable function. A pointer to an + ** instance of this structure is the first argument to the routines used + ** implement the SQL functions. + ** + ** There is a typedef for this structure in sqlite.h. So all routines, + ** even the public interface to SQLite, can use a pointer to this structure. + ** But this file is the only place where the internal details of this + ** structure are known. + ** + ** This structure is defined inside of vdbeInt.h because it uses substructures + ** (Mem) which are only defined there. + */ + public class sqlite3_context + { + public FuncDef pFunc; /* Pointer to function information. MUST BE FIRST */ + public VdbeFunc pVdbeFunc; /* Auxilary data, if created. */ + public Mem s = new Mem(); /* The return value is stored here */ + public Mem pMem; /* Memory cell used to store aggregate context */ + public int isError; /* Error code returned by the function. */ + public CollSeq pColl; /* Collating sequence */ + + }; + + /* + ** An instance of the virtual machine. This structure contains the complete + ** state of the virtual machine. + ** + ** The "sqlite3_stmt" structure pointer that is returned by sqlite3_prepare() + ** is really a pointer to an instance of this structure. + ** + ** The Vdbe.inVtabMethod variable is set to non-zero for the duration of + ** any virtual table method invocations made by the vdbe program. It is + ** set to 2 for xDestroy method calls and 1 for all other methods. This + ** variable is used for two purposes: to allow xDestroy methods to execute + ** "DROP TABLE" statements and to prevent some nasty side effects of + ** malloc failure when SQLite is invoked recursively by a virtual table + ** method function. */ - public class AuxData { - public object pAux; /* Aux data for the i-th argument */ - //(void ); /* Destructor for the aux data */ - }; - - public class VdbeFunc : FuncDef { - public FuncDef pFunc; /* The definition of the function */ - public int nAux; /* Number of entries allocated for apAux[] */ - public AuxData[] apAux = new AuxData[2]; /* One slot for each function argument */ - }; - - /* - ** The "context" argument for a installable function. A pointer to an - ** instance of this structure is the first argument to the routines used - ** implement the SQL functions. - ** - ** There is a typedef for this structure in sqlite.h. So all routines, - ** even the public interface to SQLite, can use a pointer to this structure. - ** But this file is the only place where the internal details of this - ** structure are known. - ** - ** This structure is defined inside of vdbeInt.h because it uses substructures - ** (Mem) which are only defined there. - */ - public class sqlite3_context { - public FuncDef pFunc; /* Pointer to function information. MUST BE FIRST */ - public VdbeFunc pVdbeFunc; /* Auxilary data, if created. */ - public Mem s = new Mem(); /* The return value is stored here */ - public Mem pMem; /* Memory cell used to store aggregate context */ - public int isError; /* Error code returned by the function. */ - public CollSeq pColl; /* Collating sequence */ - - }; - - /* - ** An instance of the virtual machine. This structure contains the complete - ** state of the virtual machine. - ** - ** The "sqlite3_stmt" structure pointer that is returned by sqlite3_prepare() - ** is really a pointer to an instance of this structure. - ** - ** The Vdbe.inVtabMethod variable is set to non-zero for the duration of - ** any virtual table method invocations made by the vdbe program. It is - ** set to 2 for xDestroy method calls and 1 for all other methods. This - ** variable is used for two purposes: to allow xDestroy methods to execute - ** "DROP TABLE" statements and to prevent some nasty side effects of - ** malloc failure when SQLite is invoked recursively by a virtual table - ** method function. - */ - public class Vdbe { - public sqlite3 db; /* The database connection that owns this statement */ - public Op[] aOp; /* Space to hold the virtual machine's program */ - public Mem[] aMem; /* The memory locations */ - public Mem[] apArg; /* Arguments to currently executing user function */ - public Mem[] aColName; /* Column names to return */ - public Mem[] pResultSet; /* Pointer to an array of results */ - public int nMem; /* Number of memory locations currently allocated */ - public int nOp; /* Number of instructions in the program */ - public int nOpAlloc; /* Number of slots allocated for aOp[] */ - public int nLabel; /* Number of labels used */ - public int nLabelAlloc; /* Number of slots allocated in aLabel[] */ - public int[] aLabel; /* Space to hold the labels */ - public u16 nResColumn; /* Number of columns in one row of the result set */ - public u16 nCursor; /* Number of slots in apCsr[] */ - public u32 magic; /* Magic number for sanity checking */ - public string zErrMsg; /* Error message written here */ - public Vdbe pPrev; /* Linked list of VDBEs with the same Vdbe.db */ - public Vdbe pNext; /* Linked list of VDBEs with the same Vdbe.db */ - public VdbeCursor[] apCsr; /* One element of this array for each open cursor */ - public Mem[] aVar; /* Values for the OP_Variable opcode. */ - public string[] azVar; /* Name of variables */ - public ynVar nVar; /* Number of entries in aVar[] */ - public ynVar nzVar; /* Number of entries in azVar[] */ - public u32 cacheCtr; /* VdbeCursor row cache generation counter */ - public int pc; /* The program counter */ - public int rc; /* Value to return */ - public u8 errorAction; /* Recovery action to do in case of an error */ - public int explain; /* True if EXPLAIN present on SQL command */ - public bool changeCntOn; /* True to update the change-counter */ - public bool expired; /* True if the VM needs to be recompiled */ - public u8 runOnlyOnce; /* Automatically expire on reset */ - public int minWriteFileFormat; /* Minimum file format for writable database files */ - public int inVtabMethod; /* See comments above */ - public bool usesStmtJournal; /* True if uses a statement journal */ - public bool readOnly; /* True for read-only statements */ - public int nChange; /* Number of db changes made since last reset */ - public bool isPrepareV2; /* True if prepared with prepare_v2() */ - public yDbMask btreeMask; /* Bitmask of db.aDb[] entries referenced */ - public yDbMask lockMask; /* Subset of btreeMask that requires a lock */ - - public int iStatement; /* Statement number (or 0 if has not opened stmt) */ - public int[] aCounter = new int[3]; /* Counters used by sqlite3_stmt_status() */ + public class Vdbe + { + public sqlite3 db; /* The database connection that owns this statement */ + public Op[] aOp; /* Space to hold the virtual machine's program */ + public Mem[] aMem; /* The memory locations */ + public Mem[] apArg; /* Arguments to currently executing user function */ + public Mem[] aColName; /* Column names to return */ + public Mem[] pResultSet; /* Pointer to an array of results */ + public int nMem; /* Number of memory locations currently allocated */ + public int nOp; /* Number of instructions in the program */ + public int nOpAlloc; /* Number of slots allocated for aOp[] */ + public int nLabel; /* Number of labels used */ + public int nLabelAlloc; /* Number of slots allocated in aLabel[] */ + public int[] aLabel; /* Space to hold the labels */ + public u16 nResColumn; /* Number of columns in one row of the result set */ + public u16 nCursor; /* Number of slots in apCsr[] */ + public u32 magic; /* Magic number for sanity checking */ + public string zErrMsg; /* Error message written here */ + public Vdbe pPrev; /* Linked list of VDBEs with the same Vdbe.db */ + public Vdbe pNext; /* Linked list of VDBEs with the same Vdbe.db */ + public VdbeCursor[] apCsr; /* One element of this array for each open cursor */ + public Mem[] aVar; /* Values for the OP_Variable opcode. */ + public string[] azVar; /* Name of variables */ + public ynVar nVar; /* Number of entries in aVar[] */ + public ynVar nzVar; /* Number of entries in azVar[] */ + public u32 cacheCtr; /* VdbeCursor row cache generation counter */ + public int pc; /* The program counter */ + public int rc; /* Value to return */ + public u8 errorAction; /* Recovery action to do in case of an error */ + public int explain; /* True if EXPLAIN present on SQL command */ + public bool changeCntOn; /* True to update the change-counter */ + public bool expired; /* True if the VM needs to be recompiled */ + public u8 runOnlyOnce; /* Automatically expire on reset */ + public int minWriteFileFormat; /* Minimum file format for writable database files */ + public int inVtabMethod; /* See comments above */ + public bool usesStmtJournal; /* True if uses a statement journal */ + public bool readOnly; /* True for read-only statements */ + public int nChange; /* Number of db changes made since last reset */ + public bool isPrepareV2; /* True if prepared with prepare_v2() */ + public yDbMask btreeMask; /* Bitmask of db.aDb[] entries referenced */ + public yDbMask lockMask; /* Subset of btreeMask that requires a lock */ + + public int iStatement; /* Statement number (or 0 if has not opened stmt) */ + public int[] aCounter = new int[3]; /* Counters used by sqlite3_stmt_status() */ #if !SQLITE_OMIT_TRACE - public i64 startTime; /* Time when query started - used for profiling */ + public i64 startTime; /* Time when query started - used for profiling */ #endif - public i64 nFkConstraint; /* Number of imm. FK constraints this VM */ - public i64 nStmtDefCons; /* Number of def. constraints when stmt started */ - public string zSql = ""; /* Text of the SQL statement that generated this */ - public object pFree; /* Free this when deleting the vdbe */ + public i64 nFkConstraint; /* Number of imm. FK constraints this VM */ + public i64 nStmtDefCons; /* Number of def. constraints when stmt started */ + public string zSql = ""; /* Text of the SQL statement that generated this */ + public object pFree; /* Free this when deleting the vdbe */ #if SQLITE_DEBUG - public FILE trace; /* Write an execution trace here, if not NULL */ + public FILE trace; /* Write an execution trace here, if not NULL */ #endif - public VdbeFrame pFrame; /* Parent frame */ - public VdbeFrame pDelFrame; /* List of frame objects to free on VM reset */ - public int nFrame; /* Number of frames in pFrame list */ - public u32 expmask; /* Binding to these vars invalidates VM */ - public SubProgram pProgram; /* Linked list of all sub-programs used by VM */ - - public Vdbe Copy() { - Vdbe cp = (Vdbe)MemberwiseClone(); - return cp; - } - public void CopyTo(Vdbe ct) { - ct.db = db; - ct.pPrev = pPrev; - ct.pNext = pNext; - ct.nOp = nOp; - ct.nOpAlloc = nOpAlloc; - ct.aOp = aOp; - ct.nLabel = nLabel; - ct.nLabelAlloc = nLabelAlloc; - ct.aLabel = aLabel; - ct.apArg = apArg; - ct.aColName = aColName; - ct.nCursor = nCursor; - ct.apCsr = apCsr; - ct.aVar = aVar; - ct.azVar = azVar; - ct.nVar = nVar; - ct.nzVar = nzVar; - ct.magic = magic; - ct.nMem = nMem; - ct.aMem = aMem; - ct.cacheCtr = cacheCtr; - ct.pc = pc; - ct.rc = rc; - ct.errorAction = errorAction; - ct.nResColumn = nResColumn; - ct.zErrMsg = zErrMsg; - ct.pResultSet = pResultSet; - ct.explain = explain; - ct.changeCntOn = changeCntOn; - ct.expired = expired; - ct.minWriteFileFormat = minWriteFileFormat; - ct.inVtabMethod = inVtabMethod; - ct.usesStmtJournal = usesStmtJournal; - ct.readOnly = readOnly; - ct.nChange = nChange; - ct.isPrepareV2 = isPrepareV2; + public VdbeFrame pFrame; /* Parent frame */ + public VdbeFrame pDelFrame; /* List of frame objects to free on VM reset */ + public int nFrame; /* Number of frames in pFrame list */ + public u32 expmask; /* Binding to these vars invalidates VM */ + public SubProgram pProgram; /* Linked list of all sub-programs used by VM */ + + public Vdbe Copy() + { + Vdbe cp = (Vdbe)MemberwiseClone(); + return cp; + } + public void CopyTo( Vdbe ct ) + { + ct.db = db; + ct.pPrev = pPrev; + ct.pNext = pNext; + ct.nOp = nOp; + ct.nOpAlloc = nOpAlloc; + ct.aOp = aOp; + ct.nLabel = nLabel; + ct.nLabelAlloc = nLabelAlloc; + ct.aLabel = aLabel; + ct.apArg = apArg; + ct.aColName = aColName; + ct.nCursor = nCursor; + ct.apCsr = apCsr; + ct.aVar = aVar; + ct.azVar = azVar; + ct.nVar = nVar; + ct.nzVar = nzVar; + ct.magic = magic; + ct.nMem = nMem; + ct.aMem = aMem; + ct.cacheCtr = cacheCtr; + ct.pc = pc; + ct.rc = rc; + ct.errorAction = errorAction; + ct.nResColumn = nResColumn; + ct.zErrMsg = zErrMsg; + ct.pResultSet = pResultSet; + ct.explain = explain; + ct.changeCntOn = changeCntOn; + ct.expired = expired; + ct.minWriteFileFormat = minWriteFileFormat; + ct.inVtabMethod = inVtabMethod; + ct.usesStmtJournal = usesStmtJournal; + ct.readOnly = readOnly; + ct.nChange = nChange; + ct.isPrepareV2 = isPrepareV2; #if !SQLITE_OMIT_TRACE - ct.startTime = startTime; + ct.startTime = startTime; #endif - ct.btreeMask = btreeMask; - ct.lockMask = lockMask; - aCounter.CopyTo(ct.aCounter, 0); - ct.zSql = zSql; - ct.pFree = pFree; + ct.btreeMask = btreeMask; + ct.lockMask = lockMask; + aCounter.CopyTo( ct.aCounter, 0 ); + ct.zSql = zSql; + ct.pFree = pFree; #if SQLITE_DEBUG - ct.trace = trace; + ct.trace = trace; #endif - ct.nFkConstraint = nFkConstraint; - ct.nStmtDefCons = nStmtDefCons; - ct.iStatement = iStatement; - ct.pFrame = pFrame; - ct.nFrame = nFrame; - ct.expmask = expmask; - ct.pProgram = pProgram; + ct.nFkConstraint = nFkConstraint; + ct.nStmtDefCons = nStmtDefCons; + ct.iStatement = iStatement; + ct.pFrame = pFrame; + ct.nFrame = nFrame; + ct.expmask = expmask; + ct.pProgram = pProgram; #if SQLITE_SSE ct.fetchId=fetchId; ct.lru=lru; @@ -539,116 +562,119 @@ public void CopyTo(Vdbe ct) { ct.pLruPrev=pLruPrev; ct.pLruNext=pLruNext; #endif - } - }; - - /* - ** The following are allowed values for Vdbe.magic - */ - //#define VDBE_MAGIC_INIT 0x26bceaa5 /* Building a VDBE program */ - //#define VDBE_MAGIC_RUN 0xbdf20da3 /* VDBE is ready to execute */ - //#define VDBE_MAGIC_HALT 0x519c2973 /* VDBE has completed execution */ - //#define VDBE_MAGIC_DEAD 0xb606c3c8 /* The VDBE has been deallocated */ - const u32 VDBE_MAGIC_INIT = 0x26bceaa5; /* Building a VDBE program */ - const u32 VDBE_MAGIC_RUN = 0xbdf20da3; /* VDBE is ready to execute */ - const u32 VDBE_MAGIC_HALT = 0x519c2973; /* VDBE has completed execution */ - const u32 VDBE_MAGIC_DEAD = 0xb606c3c8; /* The VDBE has been deallocated */ - /* - ** Function prototypes - */ - //void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor); - //void sqliteVdbePopStack(Vdbe*,int); - //int sqlite3VdbeCursorMoveto(VdbeCursor); - //#if (SQLITE_DEBUG) || defined(VDBE_PROFILE) - //void sqlite3VdbePrintOp(FILE*, int, Op); - //#endif - //u32 sqlite3VdbeSerialTypeLen(u32); - //u32 sqlite3VdbeSerialType(Mem*, int); - //u32sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int); - //u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem); - //void sqlite3VdbeDeleteAuxData(VdbeFunc*, int); - - //int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int ); - //int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int); - //int sqlite3VdbeIdxRowid(sqlite3 *, i64 ); - //int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq); - //int sqlite3VdbeExec(Vdbe); - //int sqlite3VdbeList(Vdbe); - //int sqlite3VdbeHalt(Vdbe); - //int sqlite3VdbeChangeEncoding(Mem *, int); - //int sqlite3VdbeMemTooBig(Mem); - //int sqlite3VdbeMemCopy(Mem*, const Mem); - //void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int); - //void sqlite3VdbeMemMove(Mem*, Mem); - //int sqlite3VdbeMemNulTerminate(Mem); - //int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, void()(void)); - //void sqlite3VdbeMemSetInt64(Mem*, i64); + } + }; + + /* + ** The following are allowed values for Vdbe.magic + */ + //#define VDBE_MAGIC_INIT 0x26bceaa5 /* Building a VDBE program */ + //#define VDBE_MAGIC_RUN 0xbdf20da3 /* VDBE is ready to execute */ + //#define VDBE_MAGIC_HALT 0x519c2973 /* VDBE has completed execution */ + //#define VDBE_MAGIC_DEAD 0xb606c3c8 /* The VDBE has been deallocated */ + const u32 VDBE_MAGIC_INIT = 0x26bceaa5; /* Building a VDBE program */ + const u32 VDBE_MAGIC_RUN = 0xbdf20da3; /* VDBE is ready to execute */ + const u32 VDBE_MAGIC_HALT = 0x519c2973; /* VDBE has completed execution */ + const u32 VDBE_MAGIC_DEAD = 0xb606c3c8; /* The VDBE has been deallocated */ + /* + ** Function prototypes + */ + //void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor); + //void sqliteVdbePopStack(Vdbe*,int); + //int sqlite3VdbeCursorMoveto(VdbeCursor); + //#if (SQLITE_DEBUG) || defined(VDBE_PROFILE) + //void sqlite3VdbePrintOp(FILE*, int, Op); + //#endif + //u32 sqlite3VdbeSerialTypeLen(u32); + //u32 sqlite3VdbeSerialType(Mem*, int); + //u32sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int); + //u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem); + //void sqlite3VdbeDeleteAuxData(VdbeFunc*, int); + + //int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int ); + //int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int); + //int sqlite3VdbeIdxRowid(sqlite3 *, i64 ); + //int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq); + //int sqlite3VdbeExec(Vdbe); + //int sqlite3VdbeList(Vdbe); + //int sqlite3VdbeHalt(Vdbe); + //int sqlite3VdbeChangeEncoding(Mem *, int); + //int sqlite3VdbeMemTooBig(Mem); + //int sqlite3VdbeMemCopy(Mem*, const Mem); + //void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int); + //void sqlite3VdbeMemMove(Mem*, Mem); + //int sqlite3VdbeMemNulTerminate(Mem); + //int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, void()(void)); + //void sqlite3VdbeMemSetInt64(Mem*, i64); #if SQLITE_OMIT_FLOATING_POINT //# define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64 #else - //void sqlite3VdbeMemSetDouble(Mem*, double); + //void sqlite3VdbeMemSetDouble(Mem*, double); #endif - //void sqlite3VdbeMemSetNull(Mem); - //void sqlite3VdbeMemSetZeroBlob(Mem*,int); - //void sqlite3VdbeMemSetRowSet(Mem); - //int sqlite3VdbeMemMakeWriteable(Mem); - //int sqlite3VdbeMemStringify(Mem*, int); - //i64 sqlite3VdbeIntValue(Mem); - //int sqlite3VdbeMemIntegerify(Mem); - //double sqlite3VdbeRealValue(Mem); - //void sqlite3VdbeIntegerAffinity(Mem); - //int sqlite3VdbeMemRealify(Mem); - //int sqlite3VdbeMemNumerify(Mem); - //int sqlite3VdbeMemFromBtree(BtCursor*,int,int,int,Mem); - //void sqlite3VdbeMemRelease(Mem p); - //void sqlite3VdbeMemReleaseExternal(Mem p); - //int sqlite3VdbeMemFinalize(Mem*, FuncDef); - //string sqlite3OpcodeName(int); - //int sqlite3VdbeMemGrow(Mem pMem, int n, int preserve); - //int sqlite3VdbeCloseStatement(Vdbe *, int); - //void sqlite3VdbeFrameDelete(VdbeFrame); - //int sqlite3VdbeFrameRestore(VdbeFrame ); - //void sqlite3VdbeMemStoreType(Mem *pMem); + //void sqlite3VdbeMemSetNull(Mem); + //void sqlite3VdbeMemSetZeroBlob(Mem*,int); + //void sqlite3VdbeMemSetRowSet(Mem); + //int sqlite3VdbeMemMakeWriteable(Mem); + //int sqlite3VdbeMemStringify(Mem*, int); + //i64 sqlite3VdbeIntValue(Mem); + //int sqlite3VdbeMemIntegerify(Mem); + //double sqlite3VdbeRealValue(Mem); + //void sqlite3VdbeIntegerAffinity(Mem); + //int sqlite3VdbeMemRealify(Mem); + //int sqlite3VdbeMemNumerify(Mem); + //int sqlite3VdbeMemFromBtree(BtCursor*,int,int,int,Mem); + //void sqlite3VdbeMemRelease(Mem p); + //void sqlite3VdbeMemReleaseExternal(Mem p); + //int sqlite3VdbeMemFinalize(Mem*, FuncDef); + //string sqlite3OpcodeName(int); + //int sqlite3VdbeMemGrow(Mem pMem, int n, int preserve); + //int sqlite3VdbeCloseStatement(Vdbe *, int); + //void sqlite3VdbeFrameDelete(VdbeFrame); + //int sqlite3VdbeFrameRestore(VdbeFrame ); + //void sqlite3VdbeMemStoreType(Mem *pMem); #if !(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE//>0 //void sqlite3VdbeEnter(Vdbe); //void sqlite3VdbeLeave(Vdbe); #else - //# define sqlite3VdbeEnter(X) - static void sqlite3VdbeEnter(Vdbe p) { - } - //# define sqlite3VdbeLeave(X) - static void sqlite3VdbeLeave(Vdbe p) { - } +//# define sqlite3VdbeEnter(X) + static void sqlite3VdbeEnter( Vdbe p ) + { + } +//# define sqlite3VdbeLeave(X) + static void sqlite3VdbeLeave( Vdbe p ) + { + } #endif #if SQLITE_DEBUG - //void sqlite3VdbeMemPrepareToChange(Vdbe*,Mem); + //void sqlite3VdbeMemPrepareToChange(Vdbe*,Mem); #endif #if !SQLITE_OMIT_FOREIGN_KEY - //int sqlite3VdbeCheckFk(Vdbe *, int); + //int sqlite3VdbeCheckFk(Vdbe *, int); #else //# define sqlite3VdbeCheckFk(p,i) 0 static int sqlite3VdbeCheckFk( Vdbe p, int i ) { return 0; } #endif - //int sqlite3VdbeMemTranslate(Mem*, u8); - //#if SQLITE_DEBUG - // void sqlite3VdbePrintSql(Vdbe); - // void sqlite3VdbeMemPrettyPrint(Mem pMem, string zBuf); - //#endif - //int sqlite3VdbeMemHandleBom(Mem pMem); + //int sqlite3VdbeMemTranslate(Mem*, u8); + //#if SQLITE_DEBUG + // void sqlite3VdbePrintSql(Vdbe); + // void sqlite3VdbeMemPrettyPrint(Mem pMem, string zBuf); + //#endif + //int sqlite3VdbeMemHandleBom(Mem pMem); #if !SQLITE_OMIT_INCRBLOB // int sqlite3VdbeMemExpandBlob(Mem ); #else - // #define sqlite3VdbeMemExpandBlob(x) SQLITE_OK - static int sqlite3VdbeMemExpandBlob(Mem x) { - return SQLITE_OK; - } + // #define sqlite3VdbeMemExpandBlob(x) SQLITE_OK + static int sqlite3VdbeMemExpandBlob( Mem x ) + { + return SQLITE_OK; + } #endif - //#endif //* !_VDBEINT_H_) */ - } + //#endif //* !_VDBEINT_H_) */ + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/Vdbe_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/Vdbe_h.cs index 250ba71cc..28d39cb07 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/Vdbe_h.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/Vdbe_h.cs @@ -1,78 +1,83 @@ using i64 = System.Int64; using u8 = System.Byte; +using u64 = System.UInt64; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 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. - ** - ************************************************************************* - ** Header file for the Virtual DataBase Engine (VDBE) - ** - ** This header defines the interface to the virtual database engine - ** or VDBE. The VDBE implements an abstract machine that runs a - ** simple program to access and modify the underlying database. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#if !_SQLITE_VDBE_H_ - //#define _SQLITE_VDBE_H_ - //#include +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 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. + ** + ************************************************************************* + ** Header file for the Virtual DataBase Engine (VDBE) + ** + ** This header defines the interface to the virtual database engine + ** or VDBE. The VDBE implements an abstract machine that runs a + ** simple program to access and modify the underlying database. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#if !_SQLITE_VDBE_H_ + //#define _SQLITE_VDBE_H_ + //#include - /* - ** A single VDBE is an opaque structure named "Vdbe". Only routines - ** in the source file sqliteVdbe.c are allowed to see the insides - ** of this structure. - */ - //typedef struct Vdbe Vdbe; + /* + ** A single VDBE is an opaque structure named "Vdbe". Only routines + ** in the source file sqliteVdbe.c are allowed to see the insides + ** of this structure. + */ + //typedef struct Vdbe Vdbe; - /* - ** The names of the following types declared in vdbeInt.h are required - ** for the VdbeOp definition. - */ - //typedef struct VdbeFunc VdbeFunc; - //typedef struct Mem Mem; - //typedef struct SubProgram SubProgram; + /* + ** The names of the following types declared in vdbeInt.h are required + ** for the VdbeOp definition. + */ + //typedef struct VdbeFunc VdbeFunc; + //typedef struct Mem Mem; + //typedef struct SubProgram SubProgram; - /* - ** A single instruction of the virtual machine has an opcode - ** and as many as three operands. The instruction is recorded - ** as an instance of the following structure: - */ - public class union_p4 { /* fourth parameter */ - public int i; /* Integer value if p4type==P4_INT32 */ - public object p; /* Generic pointer */ - //public string z; /* Pointer to data for string (char array) types */ - public string z; // In C# string is unicode, so use byte[] instead - public i64 pI64; /* Used when p4type is P4_INT64 */ - public double pReal; /* Used when p4type is P4_REAL */ - public FuncDef pFunc; /* Used when p4type is P4_FUNCDEF */ - public VdbeFunc pVdbeFunc; /* Used when p4type is P4_VDBEFUNC */ - public CollSeq pColl; /* Used when p4type is P4_COLLSEQ */ - public Mem pMem; /* Used when p4type is P4_MEM */ - public VTable pVtab; /* Used when p4type is P4_VTAB */ - public KeyInfo pKeyInfo; /* Used when p4type is P4_KEYINFO */ - public int[] ai; /* Used when p4type is P4_INTARRAY */ - public SubProgram pProgram; /* Used when p4type is P4_SUBPROGRAM */ - public dxDel pFuncDel; /* Used when p4type is P4_FUNCDEL */ - }; - public class VdbeOp { - public u8 opcode; /* What operation to perform */ - public int p4type; /* One of the P4_xxx constants for p4 */ - public u8 opflags; /* Mask of the OPFLG_* flags in opcodes.h */ - public u8 p5; /* Fifth parameter is an unsigned character */ + /* + ** A single instruction of the virtual machine has an opcode + ** and as many as three operands. The instruction is recorded + ** as an instance of the following structure: + */ + public class union_p4 + { /* fourth parameter */ + public int i; /* Integer value if p4type==P4_INT32 */ + public object p; /* Generic pointer */ + //public string z; /* Pointer to data for string (char array) types */ + public string z; // In C# string is unicode, so use byte[] instead + public i64 pI64; /* Used when p4type is P4_INT64 */ + public double pReal; /* Used when p4type is P4_REAL */ + public FuncDef pFunc; /* Used when p4type is P4_FUNCDEF */ + public VdbeFunc pVdbeFunc; /* Used when p4type is P4_VDBEFUNC */ + public CollSeq pColl; /* Used when p4type is P4_COLLSEQ */ + public Mem pMem; /* Used when p4type is P4_MEM */ + public VTable pVtab; /* Used when p4type is P4_VTAB */ + public KeyInfo pKeyInfo; /* Used when p4type is P4_KEYINFO */ + public int[] ai; /* Used when p4type is P4_INTARRAY */ + public SubProgram pProgram; /* Used when p4type is P4_SUBPROGRAM */ + public dxDel pFuncDel; /* Used when p4type is P4_FUNCDEL */ + } ; + public class VdbeOp + { + public u8 opcode; /* What operation to perform */ + public int p4type; /* One of the P4_xxx constants for p4 */ + public u8 opflags; /* Mask of the OPFLG_* flags in opcodes.h */ + public u8 p5; /* Fifth parameter is an unsigned character */ #if DEBUG_CLASS_VDBEOP || DEBUG_CLASS_ALL public int _p1; /* First operand */ public int p1 @@ -95,206 +100,212 @@ public int p3 set { _p3 = value; } } #else - public int p1; /* First operand */ - public int p2; /* Second parameter (often the jump destination) */ - public int p3; /* The third parameter */ + public int p1; /* First operand */ + public int p2; /* Second parameter (often the jump destination) */ + public int p3; /* The third parameter */ #endif - public union_p4 p4 = new union_p4(); + public union_p4 p4 = new union_p4(); #if SQLITE_DEBUG || DEBUG - public string zComment; /* Comment to improve readability */ + public string zComment; /* Comment to improve readability */ #endif #if VDBE_PROFILE public int cnt; /* Number of times this instruction was executed */ public u64 cycles; /* Total time spend executing this instruction */ #endif - }; - //typedef struct VdbeOp VdbeOp; + }; + //typedef struct VdbeOp VdbeOp; - /* - ** A sub-routine used to implement a trigger program. - */ - public class SubProgram { - public VdbeOp[] aOp; /* Array of opcodes for sub-program */ - public int nOp; /* Elements in aOp[] */ - public int nMem; /* Number of memory cells required */ - public int nCsr; /* Number of cursors required */ - public int token; /* id that may be used to recursive triggers */ - public SubProgram pNext; /* Next sub-program already visited */ - }; + /* + ** A sub-routine used to implement a trigger program. + */ + public class SubProgram + { + public VdbeOp[] aOp; /* Array of opcodes for sub-program */ + public int nOp; /* Elements in aOp[] */ + public int nMem; /* Number of memory cells required */ + public int nCsr; /* Number of cursors required */ + public int token; /* id that may be used to recursive triggers */ + public SubProgram pNext; /* Next sub-program already visited */ + }; - /* - ** A smaller version of VdbeOp used for the VdbeAddOpList() function because - ** it takes up less space. - */ - public struct VdbeOpList { - public u8 opcode; /* What operation to perform */ - public int p1; /* First operand */ - public int p2; /* Second parameter (often the jump destination) */ - public int p3; /* Third parameter */ - public VdbeOpList(u8 opcode, int p1, int p2, int p3) { - this.opcode = opcode; - this.p1 = p1; - this.p2 = p2; - this.p3 = p3; - } + /* + ** A smaller version of VdbeOp used for the VdbeAddOpList() function because + ** it takes up less space. + */ + public struct VdbeOpList + { + public u8 opcode; /* What operation to perform */ + public int p1; /* First operand */ + public int p2; /* Second parameter (often the jump destination) */ + public int p3; /* Third parameter */ + public VdbeOpList( u8 opcode, int p1, int p2, int p3 ) + { + this.opcode = opcode; + this.p1 = p1; + this.p2 = p2; + this.p3 = p3; + } - }; - //typedef struct VdbeOpList VdbeOpList; + }; + //typedef struct VdbeOpList VdbeOpList; - /* - ** Allowed values of VdbeOp.p4type - */ - const int P4_NOTUSED = 0; /* The P4 parameter is not used */ - const int P4_DYNAMIC = (-1); /* Pointer to a string obtained from sqliteMalloc=(); */ - const int P4_STATIC = (-2); /* Pointer to a static string */ - const int P4_COLLSEQ = (-4); /* P4 is a pointer to a CollSeq structure */ - const int P4_FUNCDEF = (-5); /* P4 is a pointer to a FuncDef structure */ - const int P4_KEYINFO = (-6); /* P4 is a pointer to a KeyInfo structure */ - const int P4_VDBEFUNC = (-7); /* P4 is a pointer to a VdbeFunc structure */ - const int P4_MEM = (-8); /* P4 is a pointer to a Mem* structure */ - const int P4_TRANSIENT = 0; /* P4 is a pointer to a transient string */ - const int P4_VTAB = (-10); /* P4 is a pointer to an sqlite3_vtab structure */ - const int P4_MPRINTF = (-11); /* P4 is a string obtained from sqlite3_mprintf=(); */ - const int P4_REAL = (-12); /* P4 is a 64-bit floating point value */ - const int P4_INT64 = (-13); /* P4 is a 64-bit signed integer */ - const int P4_INT32 = (-14); /* P4 is a 32-bit signed integer */ - const int P4_INTARRAY = (-15); /* #define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */ - const int P4_SUBPROGRAM = (-18);/* #define P4_SUBPROGRAM (-18) /* P4 is a pointer to a SubProgram structure */ + /* + ** Allowed values of VdbeOp.p4type + */ + const int P4_NOTUSED = 0; /* The P4 parameter is not used */ + const int P4_DYNAMIC = ( -1 ); /* Pointer to a string obtained from sqliteMalloc=(); */ + const int P4_STATIC = ( -2 ); /* Pointer to a static string */ + const int P4_COLLSEQ = ( -4 ); /* P4 is a pointer to a CollSeq structure */ + const int P4_FUNCDEF = ( -5 ); /* P4 is a pointer to a FuncDef structure */ + const int P4_KEYINFO = ( -6 ); /* P4 is a pointer to a KeyInfo structure */ + const int P4_VDBEFUNC = ( -7 ); /* P4 is a pointer to a VdbeFunc structure */ + const int P4_MEM = ( -8 ); /* P4 is a pointer to a Mem* structure */ + const int P4_TRANSIENT = 0; /* P4 is a pointer to a transient string */ + const int P4_VTAB = ( -10 ); /* P4 is a pointer to an sqlite3_vtab structure */ + const int P4_MPRINTF = ( -11 ); /* P4 is a string obtained from sqlite3_mprintf=(); */ + const int P4_REAL = ( -12 ); /* P4 is a 64-bit floating point value */ + const int P4_INT64 = ( -13 ); /* P4 is a 64-bit signed integer */ + const int P4_INT32 = ( -14 ); /* P4 is a 32-bit signed integer */ + const int P4_INTARRAY = ( -15 ); /* #define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */ + const int P4_SUBPROGRAM = ( -18 );/* #define P4_SUBPROGRAM (-18) /* P4 is a pointer to a SubProgram structure */ - /* When adding a P4 argument using P4_KEYINFO, a copy of the KeyInfo structure - ** is made. That copy is freed when the Vdbe is finalized. But if the - ** argument is P4_KEYINFO_HANDOFF, the passed in pointer is used. It still - ** gets freed when the Vdbe is finalized so it still should be obtained - ** from a single sqliteMalloc(). But no copy is made and the calling - ** function should *not* try to free the KeyInfo. - */ - const int P4_KEYINFO_HANDOFF = (-16); // #define P4_KEYINFO_HANDOFF (-16) - const int P4_KEYINFO_STATIC = (-17); // #define P4_KEYINFO_STATIC (-17) + /* When adding a P4 argument using P4_KEYINFO, a copy of the KeyInfo structure + ** is made. That copy is freed when the Vdbe is finalized. But if the + ** argument is P4_KEYINFO_HANDOFF, the passed in pointer is used. It still + ** gets freed when the Vdbe is finalized so it still should be obtained + ** from a single sqliteMalloc(). But no copy is made and the calling + ** function should *not* try to free the KeyInfo. + */ + const int P4_KEYINFO_HANDOFF = ( -16 ); // #define P4_KEYINFO_HANDOFF (-16) + const int P4_KEYINFO_STATIC = ( -17 ); // #define P4_KEYINFO_STATIC (-17) - /* - ** The Vdbe.aColName array contains 5n Mem structures, where n is the - ** number of columns of data returned by the statement. - */ - //#define COLNAME_NAME 0 - //#define COLNAME_DECLTYPE 1 - //#define COLNAME_DATABASE 2 - //#define COLNAME_TABLE 3 - //#define COLNAME_COLUMN 4 - //#if SQLITE_ENABLE_COLUMN_METADATA - //# define COLNAME_N 5 /* Number of COLNAME_xxx symbols */ - //#else - //# ifdef SQLITE_OMIT_DECLTYPE - //# define COLNAME_N 1 /* Store only the name */ - //# else - //# define COLNAME_N 2 /* Store the name and decltype */ - //# endif - //#endif - const int COLNAME_NAME = 0; - const int COLNAME_DECLTYPE = 1; - const int COLNAME_DATABASE = 2; - const int COLNAME_TABLE = 3; - const int COLNAME_COLUMN = 4; + /* + ** The Vdbe.aColName array contains 5n Mem structures, where n is the + ** number of columns of data returned by the statement. + */ + //#define COLNAME_NAME 0 + //#define COLNAME_DECLTYPE 1 + //#define COLNAME_DATABASE 2 + //#define COLNAME_TABLE 3 + //#define COLNAME_COLUMN 4 + //#if SQLITE_ENABLE_COLUMN_METADATA + //# define COLNAME_N 5 /* Number of COLNAME_xxx symbols */ + //#else + //# ifdef SQLITE_OMIT_DECLTYPE + //# define COLNAME_N 1 /* Store only the name */ + //# else + //# define COLNAME_N 2 /* Store the name and decltype */ + //# endif + //#endif + const int COLNAME_NAME = 0; + const int COLNAME_DECLTYPE = 1; + const int COLNAME_DATABASE = 2; + const int COLNAME_TABLE = 3; + const int COLNAME_COLUMN = 4; #if SQLITE_ENABLE_COLUMN_METADATA - const int COLNAME_N = 5; /* Number of COLNAME_xxx symbols */ +const int COLNAME_N = 5; /* Number of COLNAME_xxx symbols */ #else -#if SQLITE_OMIT_DECLTYPE +# if SQLITE_OMIT_DECLTYPE const int COLNAME_N = 1; /* Number of COLNAME_xxx symbols */ -#else +# else const int COLNAME_N = 2; -#endif +# endif #endif - /* - ** The following macro converts a relative address in the p2 field - ** of a VdbeOp structure into a negative number so that - ** sqlite3VdbeAddOpList() knows that the address is relative. Calling - ** the macro again restores the address. + /* +** The following macro converts a relative address in the p2 field +** of a VdbeOp structure into a negative number so that +** sqlite3VdbeAddOpList() knows that the address is relative. Calling +** the macro again restores the address. +*/ + //#define ADDR(X) (-1-(X)) + static int ADDR( int x ) + { + return -1 - x; + } + /* + ** The makefile scans the vdbe.c source file and creates the "opcodes.h" + ** header file that defines a number for each opcode used by the VDBE. */ - //#define ADDR(X) (-1-(X)) - static int ADDR(int x) { - return -1 - x; - } - /* - ** The makefile scans the vdbe.c source file and creates the "opcodes.h" - ** header file that defines a number for each opcode used by the VDBE. - */ - //#include "opcodes.h" + //#include "opcodes.h" - /* - ** Prototypes for the VDBE interface. See comments on the implementation - ** for a description of what each of these routines does. - */ - /* - ** Prototypes for the VDBE interface. See comments on the implementation - ** for a description of what each of these routines does. - */ - //Vdbe *sqlite3VdbeCreate(sqlite3); - //int sqlite3VdbeAddOp0(Vdbe*,int); - //int sqlite3VdbeAddOp1(Vdbe*,int,int); - //int sqlite3VdbeAddOp2(Vdbe*,int,int,int); - //int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int); - //int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,string zP4,int); - //int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int); - //int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp); - //void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char); - //void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1); - //void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2); - //void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3); - //void sqlite3VdbeChangeP5(Vdbe*, u8 P5); - //void sqlite3VdbeJumpHere(Vdbe*, int addr); - //void sqlite3VdbeChangeToNoop(Vdbe*, int addr, int N); - //void sqlite3VdbeChangeP4(Vdbe*, int addr, string zP4, int N); - //void sqlite3VdbeUsesBtree(Vdbe*, int); - //VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); - //int sqlite3VdbeMakeLabel(Vdbe); - //void sqlite3VdbeRunOnlyOnce(Vdbe); - //void sqlite3VdbeDelete(Vdbe); - //void sqlite3VdbeDeleteObject(sqlite3*,Vdbe); - //void sqlite3VdbeMakeReady(Vdbe*,Parse); - //int sqlite3VdbeFinalize(Vdbe); - //void sqlite3VdbeResolveLabel(Vdbe*, int); - //int sqlite3VdbeCurrentAddr(Vdbe); - //#if SQLITE_DEBUG - // int sqlite3VdbeAssertMayAbort(Vdbe *, int); - // void sqlite3VdbeTrace(Vdbe*,FILE); - //#endif - //void sqlite3VdbeResetStepResult(Vdbe); - //void sqlite3VdbeRewind(Vdbe); - //int sqlite3VdbeReset(Vdbe); - //void sqlite3VdbeSetNumCols(Vdbe*,int); - //int sqlite3VdbeSetColName(Vdbe*, int, int, string , void()(void)); - //void sqlite3VdbeCountChanges(Vdbe); - //sqlite3 *sqlite3VdbeDb(Vdbe); - //void sqlite3VdbeSetSql(Vdbe*, string z, int n, int); - //void sqlite3VdbeSwap(Vdbe*,Vdbe); - //VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int); - //sqlite3_value *sqlite3VdbeGetValue(Vdbe*, int, u8); - //void sqlite3VdbeSetVarmask(Vdbe*, int); - //#if !SQLITE_OMIT_TRACE - // char *sqlite3VdbeExpandSql(Vdbe*, const char); - //#endif + /* + ** Prototypes for the VDBE interface. See comments on the implementation + ** for a description of what each of these routines does. + */ + /* + ** Prototypes for the VDBE interface. See comments on the implementation + ** for a description of what each of these routines does. + */ + //Vdbe *sqlite3VdbeCreate(sqlite3); + //int sqlite3VdbeAddOp0(Vdbe*,int); + //int sqlite3VdbeAddOp1(Vdbe*,int,int); + //int sqlite3VdbeAddOp2(Vdbe*,int,int,int); + //int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int); + //int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,string zP4,int); + //int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int); + //int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp); + //void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char); + //void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1); + //void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2); + //void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3); + //void sqlite3VdbeChangeP5(Vdbe*, u8 P5); + //void sqlite3VdbeJumpHere(Vdbe*, int addr); + //void sqlite3VdbeChangeToNoop(Vdbe*, int addr, int N); + //void sqlite3VdbeChangeP4(Vdbe*, int addr, string zP4, int N); + //void sqlite3VdbeUsesBtree(Vdbe*, int); + //VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); + //int sqlite3VdbeMakeLabel(Vdbe); + //void sqlite3VdbeRunOnlyOnce(Vdbe); + //void sqlite3VdbeDelete(Vdbe); + //void sqlite3VdbeDeleteObject(sqlite3*,Vdbe); + //void sqlite3VdbeMakeReady(Vdbe*,Parse); + //int sqlite3VdbeFinalize(Vdbe); + //void sqlite3VdbeResolveLabel(Vdbe*, int); + //int sqlite3VdbeCurrentAddr(Vdbe); + //#if SQLITE_DEBUG + // int sqlite3VdbeAssertMayAbort(Vdbe *, int); + // void sqlite3VdbeTrace(Vdbe*,FILE); + //#endif + //void sqlite3VdbeResetStepResult(Vdbe); + //void sqlite3VdbeRewind(Vdbe); + //int sqlite3VdbeReset(Vdbe); + //void sqlite3VdbeSetNumCols(Vdbe*,int); + //int sqlite3VdbeSetColName(Vdbe*, int, int, string , void()(void)); + //void sqlite3VdbeCountChanges(Vdbe); + //sqlite3 *sqlite3VdbeDb(Vdbe); + //void sqlite3VdbeSetSql(Vdbe*, string z, int n, int); + //void sqlite3VdbeSwap(Vdbe*,Vdbe); + //VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int); + //sqlite3_value *sqlite3VdbeGetValue(Vdbe*, int, u8); + //void sqlite3VdbeSetVarmask(Vdbe*, int); + //#if !SQLITE_OMIT_TRACE + // char *sqlite3VdbeExpandSql(Vdbe*, const char); + //#endif - //UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,char*,int); - //void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord); - //int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord); + //UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,char*,int); + //void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord); + //int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord); - //#if !SQLITE_OMIT_TRIGGER - //void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram ); - //#endif + //#if !SQLITE_OMIT_TRIGGER + //void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram ); + //#endif #if !NDEBUG - //void sqlite3VdbeComment(Vdbe*, const char*, ...); - static void VdbeComment(Vdbe v, string zFormat, params object[] ap) { - sqlite3VdbeComment(v, zFormat, ap); - }//# define VdbeComment(X) sqlite3VdbeComment X - //void sqlite3VdbeNoopComment(Vdbe*, const char*, ...); - static void VdbeNoopComment(Vdbe v, string zFormat, params object[] ap) { - sqlite3VdbeNoopComment(v, zFormat, ap); - }//# define VdbeNoopComment(X) sqlite3VdbeNoopComment X + //void sqlite3VdbeComment(Vdbe*, const char*, ...); + static void VdbeComment( Vdbe v, string zFormat, params object[] ap ) + { + sqlite3VdbeComment( v, zFormat, ap ); + }//# define VdbeComment(X) sqlite3VdbeComment X + //void sqlite3VdbeNoopComment(Vdbe*, const char*, ...); + static void VdbeNoopComment( Vdbe v, string zFormat, params object[] ap ) + { + sqlite3VdbeNoopComment( v, zFormat, ap ); + }//# define VdbeNoopComment(X) sqlite3VdbeNoopComment X #else //# define VdbeComment(X) static void VdbeComment( Vdbe v, string zFormat, params object[] ap ) { } //# define VdbeNoopComment(X) static void VdbeNoopComment( Vdbe v, string zFormat, params object[] ap ) { } #endif - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/_Custom.cs b/src/extensions/IronPython.SQLite/c#sqlite/_Custom.cs index b0c0f7dc2..06be9aa74 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/_Custom.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/_Custom.cs @@ -18,483 +18,583 @@ using u32 = System.UInt32; using time_t = System.Int64; -namespace Community.CsharpSqlite { - using sqlite3_value = Sqlite3.Mem; +namespace Community.CsharpSqlite +{ + using sqlite3_value = Sqlite3.Mem; - public partial class Sqlite3 { + public partial class Sqlite3 + { - static int atoi(byte[] inStr) { - return atoi(Encoding.UTF8.GetString(inStr, 0, inStr.Length)); - } +static int atoi( byte[] inStr ) +{ + return atoi( Encoding.UTF8.GetString( inStr, 0, inStr.Length ) ); +} - static int atoi(string inStr) { - int i; - for (i = 0; i < inStr.Length; i++) { - if (!sqlite3Isdigit(inStr[i]) && inStr[i] != '-') - break; - } - int result = 0; -#if WINDOWS_MOBILE +static int atoi( string inStr ) +{ + int i; + for ( i = 0; i < inStr.Length; i++ ) + { + if ( !sqlite3Isdigit( inStr[i] ) && inStr[i] != '-' ) + break; + } + int result = 0; +#if WINDOWS_MOBILE try { result = Int32.Parse(inStr.Substring(0, i)); } catch { } return result; #else - return (Int32.TryParse(inStr.Substring(0, i), out result) ? result : 0); + return ( Int32.TryParse( inStr.Substring( 0, i ), out result ) ? result : 0 ); #endif - } +} - static void fprintf(TextWriter tw, string zFormat, params object[] ap) { - tw.Write(sqlite3_mprintf(zFormat, ap)); - } - static void printf(string zFormat, params object[] ap) { +static void fprintf( TextWriter tw, string zFormat, params object[] ap ) +{ + tw.Write( sqlite3_mprintf( zFormat, ap ) ); +} +static void printf( string zFormat, params object[] ap ) +{ #if !SQLITE_WINRT - Console.Out.Write(sqlite3_mprintf(zFormat, ap)); + Console.Out.Write( sqlite3_mprintf( zFormat, ap ) ); #endif - } +} - //Byte Buffer Testing - static int memcmp(byte[] bA, byte[] bB, int Limit) { - if (bA.Length < Limit) - return (bA.Length < bB.Length) ? -1 : +1; - if (bB.Length < Limit) - return +1; - for (int i = 0; i < Limit; i++) { - if (bA[i] != bB[i]) - return (bA[i] < bB[i]) ? -1 : 1; - } - return 0; - } +//Byte Buffer Testing +static int memcmp( byte[] bA, byte[] bB, int Limit ) +{ + if ( bA.Length < Limit ) + return ( bA.Length < bB.Length ) ? -1 : +1; + if ( bB.Length < Limit ) + return +1; + for ( int i = 0; i < Limit; i++ ) + { + if ( bA[i] != bB[i] ) + return ( bA[i] < bB[i] ) ? -1 : 1; + } + return 0; +} - //Byte Buffer & String Testing - static int memcmp(string A, byte[] bB, int Limit) { - if (A.Length < Limit) - return (A.Length < bB.Length) ? -1 : +1; - if (bB.Length < Limit) - return +1; - char[] cA = A.ToCharArray(); - for (int i = 0; i < Limit; i++) { - if (cA[i] != bB[i]) - return (cA[i] < bB[i]) ? -1 : 1; - } - return 0; - } +//Byte Buffer & String Testing +static int memcmp( string A, byte[] bB, int Limit ) +{ + if ( A.Length < Limit ) + return ( A.Length < bB.Length ) ? -1 : +1; + if ( bB.Length < Limit ) + return +1; + char[] cA = A.ToCharArray(); + for ( int i = 0; i < Limit; i++ ) + { + if ( cA[i] != bB[i] ) + return ( cA[i] < bB[i] ) ? -1 : 1; + } + return 0; +} - //byte with Offset & String Testing - static int memcmp(byte[] a, int Offset, byte[] b, int Limit) { - if (a.Length < Offset + Limit) - return (a.Length - Offset < b.Length) ? -1 : +1; - if (b.Length < Limit) - return +1; - for (int i = 0; i < Limit; i++) { - if (a[i + Offset] != b[i]) - return (a[i + Offset] < b[i]) ? -1 : 1; - } - return 0; - } +//byte with Offset & String Testing +static int memcmp( byte[] a, int Offset, byte[] b, int Limit ) +{ + if ( a.Length < Offset + Limit ) + return ( a.Length - Offset < b.Length ) ? -1 : +1; + if ( b.Length < Limit ) + return +1; + for ( int i = 0; i < Limit; i++ ) + { + if ( a[i + Offset] != b[i] ) + return ( a[i + Offset] < b[i] ) ? -1 : 1; + } + return 0; +} - //byte with Offset & String Testing - static int memcmp(byte[] a, int Aoffset, byte[] b, int Boffset, int Limit) { - if (a.Length < Aoffset + Limit) - return (a.Length - Aoffset < b.Length - Boffset) ? -1 : +1; - if (b.Length < Boffset + Limit) - return +1; - for (int i = 0; i < Limit; i++) { - if (a[i + Aoffset] != b[i + Boffset]) - return (a[i + Aoffset] < b[i + Boffset]) ? -1 : 1; - } - return 0; - } +//byte with Offset & String Testing +static int memcmp( byte[] a, int Aoffset, byte[] b, int Boffset, int Limit ) +{ + if ( a.Length < Aoffset + Limit ) + return ( a.Length - Aoffset < b.Length - Boffset ) ? -1 : +1; + if ( b.Length < Boffset + Limit ) + return +1; + for ( int i = 0; i < Limit; i++ ) + { + if ( a[i + Aoffset] != b[i + Boffset] ) + return ( a[i + Aoffset] < b[i + Boffset] ) ? -1 : 1; + } + return 0; +} - static int memcmp(byte[] a, int Offset, string b, int Limit) { - if (a.Length < Offset + Limit) - return (a.Length - Offset < b.Length) ? -1 : +1; - if (b.Length < Limit) - return +1; - for (int i = 0; i < Limit; i++) { - if (a[i + Offset] != b[i]) - return (a[i + Offset] < b[i]) ? -1 : 1; - } - return 0; - } - //String Testing - static int memcmp(string A, string B, int Limit) { - if (A.Length < Limit) - return (A.Length < B.Length) ? -1 : +1; - if (B.Length < Limit) - return +1; - int rc; - if ((rc = String.Compare(A, 0, B, 0, Limit, StringComparison.Ordinal)) == 0) - return 0; - return rc < 0 ? -1 : +1; - } +static int memcmp( byte[] a, int Offset, string b, int Limit ) +{ + if ( a.Length < Offset + Limit ) + return ( a.Length - Offset < b.Length ) ? -1 : +1; + if ( b.Length < Limit ) + return +1; + for ( int i = 0; i < Limit; i++ ) + { + if ( a[i + Offset] != b[i] ) + return ( a[i + Offset] < b[i] ) ? -1 : 1; + } + return 0; +} +//String Testing +static int memcmp( string A, string B, int Limit ) +{ + if ( A.Length < Limit ) + return ( A.Length < B.Length ) ? -1 : +1; + if ( B.Length < Limit ) + return +1; + int rc; + if ( ( rc = String.Compare( A, 0, B, 0, Limit, StringComparison.Ordinal ) ) == 0 ) + return 0; + return rc < 0 ? -1 : +1; +} - // ---------------------------- - // ** Builtin Functions - // ---------------------------- - - - static Regex oRegex = null; - /* - ** The regexp() function. two arguments are both strings - ** Collating sequences are not used. - */ - static void regexpFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - string zTest; /* The input string A */ - string zRegex; /* The regex string B */ - - Debug.Assert(argc == 2); - UNUSED_PARAMETER(argc); - zRegex = sqlite3_value_text(argv[0]); - zTest = sqlite3_value_text(argv[1]); - - if (zTest == null || String.IsNullOrEmpty(zRegex)) { - sqlite3_result_int(context, 0); - return; - } - - if (oRegex == null || oRegex.ToString() == zRegex) { - oRegex = new Regex(zRegex, RegexOptions.IgnoreCase); - } - sqlite3_result_int(context, oRegex.IsMatch(zTest) ? 1 : 0); - } +// ---------------------------- +// ** Builtin Functions +// ---------------------------- - // ---------------------------- - // ** Convertion routines - // ---------------------------- - static Object lock_va_list = new Object(); +static Regex oRegex = null; +/* +** The regexp() function. two arguments are both strings +** Collating sequences are not used. +*/ +static void regexpFunc( +sqlite3_context context, +int argc, +sqlite3_value[] argv +) +{ + string zTest; /* The input string A */ + string zRegex; /* The regex string B */ + + Debug.Assert( argc == 2 ); + UNUSED_PARAMETER( argc ); + zRegex = sqlite3_value_text( argv[0] ); + zTest = sqlite3_value_text( argv[1] ); + + if ( zTest == null || String.IsNullOrEmpty( zRegex ) ) + { + sqlite3_result_int( context, 0 ); + return; + } + + if ( oRegex == null || oRegex.ToString() == zRegex ) + { + oRegex = new Regex( zRegex, RegexOptions.IgnoreCase ); + } + sqlite3_result_int( context, oRegex.IsMatch( zTest ) ? 1 : 0 ); +} - static string vaFORMAT; - static int vaNEXT; - static void va_start(object[] ap, string zFormat) { - vaFORMAT = zFormat; - vaNEXT = 0; - } +// ---------------------------- +// ** Convertion routines +// ---------------------------- +static Object lock_va_list = new Object(); - static Boolean va_arg(object[] ap, Boolean sysType) { - return Convert.ToBoolean(ap[vaNEXT++]); - } +static string vaFORMAT; +static int vaNEXT; - static Byte[] va_arg(object[] ap, Byte[] sysType) { - return (Byte[])ap[vaNEXT++]; - } +static void va_start( object[] ap, string zFormat ) +{ + vaFORMAT = zFormat; + vaNEXT = 0; +} - static Byte[][] va_arg(object[] ap, Byte[][] sysType) { - if (ap[vaNEXT] == null) { - { - vaNEXT++; - return null; - } - } else { - return (Byte[][])ap[vaNEXT++]; - } - } +static Boolean va_arg( object[] ap, Boolean sysType ) +{ + return Convert.ToBoolean( ap[vaNEXT++] ); +} - static Char va_arg(object[] ap, Char sysType) { - if (ap[vaNEXT] is Int32 && (int)ap[vaNEXT] == 0) { - vaNEXT++; - return (char)'0'; - } else { - if (ap[vaNEXT] is Int64) - if ((i64)ap[vaNEXT] == 0) { - vaNEXT++; - return (char)'0'; - } else - return (char)((i64)ap[vaNEXT++]); - else - return (char)ap[vaNEXT++]; - } +static Byte[] va_arg( object[] ap, Byte[] sysType ) +{ + return (Byte[])ap[vaNEXT++]; +} - } +static Byte[][] va_arg( object[] ap, Byte[][] sysType ) +{ + if ( ap[vaNEXT] == null ) + { + { + vaNEXT++; + return null; + } + } + else + { + return (Byte[][])ap[vaNEXT++]; + } +} - static Double va_arg(object[] ap, Double sysType) { - return Convert.ToDouble(ap[vaNEXT++]); - } +static Char va_arg( object[] ap, Char sysType ) +{ + if ( ap[vaNEXT] is Int32 && (int)ap[vaNEXT] == 0 ) + { + vaNEXT++; + return (char)'0'; + } + else + { + if ( ap[vaNEXT] is Int64 ) + if ( (i64)ap[vaNEXT] == 0 ) + { + vaNEXT++; + return (char)'0'; + } + else + return (char)( (i64)ap[vaNEXT++] ); + else + return (char)ap[vaNEXT++]; + } - static dxLog va_arg(object[] ap, dxLog sysType) { - return (dxLog)ap[vaNEXT++]; - } +} - static Int64 va_arg(object[] ap, Int64 sysType) { - if (ap[vaNEXT] is System.Int64) - return Convert.ToInt64(ap[vaNEXT++]); - else - return (Int64)(ap[vaNEXT++].GetHashCode()); - } +static Double va_arg( object[] ap, Double sysType ) +{ + return Convert.ToDouble( ap[vaNEXT++] ); +} - static Int32 va_arg(object[] ap, Int32 sysType) { - if (Convert.ToInt64(ap[vaNEXT]) > 0 && (Convert.ToUInt32(ap[vaNEXT]) > Int32.MaxValue)) - return (Int32)(Convert.ToUInt32(ap[vaNEXT++]) - System.UInt32.MaxValue - 1); - else - return (Int32)Convert.ToInt32(ap[vaNEXT++]); - } +static dxLog va_arg( object[] ap, dxLog sysType ) +{ + return (dxLog)ap[vaNEXT++]; +} - static Int32[] va_arg(object[] ap, Int32[] sysType) { - if (ap[vaNEXT] == null) { - { - vaNEXT++; - return null; - } - } else { - return (Int32[])ap[vaNEXT++]; - } - } +static Int64 va_arg( object[] ap, Int64 sysType ) +{ + if ( ap[vaNEXT] is System.Int64) + return Convert.ToInt64( ap[vaNEXT++] ); + else + return (Int64)( ap[vaNEXT++].GetHashCode() ); +} - static MemPage va_arg(object[] ap, MemPage sysType) { - return (MemPage)ap[vaNEXT++]; - } +static Int32 va_arg( object[] ap, Int32 sysType ) +{ + if ( Convert.ToInt64( ap[vaNEXT] ) > 0 && ( Convert.ToUInt32( ap[vaNEXT] ) > Int32.MaxValue ) ) + return (Int32)( Convert.ToUInt32( ap[vaNEXT++] ) - System.UInt32.MaxValue - 1 ); + else + return (Int32)Convert.ToInt32( ap[vaNEXT++] ); +} - static Object va_arg(object[] ap, Object sysType) { - return (Object)ap[vaNEXT++]; - } +static Int32[] va_arg( object[] ap, Int32[] sysType ) +{ + if ( ap[vaNEXT] == null ) + { + { + vaNEXT++; + return null; + } + } + else + { + return (Int32[])ap[vaNEXT++]; + } +} - static sqlite3 va_arg(object[] ap, sqlite3 sysType) { - return (sqlite3)ap[vaNEXT++]; - } +static MemPage va_arg( object[] ap, MemPage sysType ) +{ + return (MemPage)ap[vaNEXT++]; +} - static sqlite3_mem_methods va_arg(object[] ap, sqlite3_mem_methods sysType) { - return (sqlite3_mem_methods)ap[vaNEXT++]; - } +static Object va_arg( object[] ap, Object sysType ) +{ + return (Object)ap[vaNEXT++]; +} - static sqlite3_mutex_methods va_arg(object[] ap, sqlite3_mutex_methods sysType) { - return (sqlite3_mutex_methods)ap[vaNEXT++]; - } +static sqlite3 va_arg( object[] ap, sqlite3 sysType ) +{ + return (sqlite3)ap[vaNEXT++]; +} - static SrcList va_arg(object[] ap, SrcList sysType) { - return (SrcList)ap[vaNEXT++]; - } +static sqlite3_mem_methods va_arg( object[] ap, sqlite3_mem_methods sysType ) +{ + return (sqlite3_mem_methods)ap[vaNEXT++]; +} - static String va_arg(object[] ap, String sysType) { - if (ap.Length < vaNEXT - 1 || ap[vaNEXT] == null) { - vaNEXT++; - return "NULL"; - } else { - if (ap[vaNEXT] is Byte[]) - if (Encoding.UTF8.GetString((byte[])ap[vaNEXT], 0, ((byte[])ap[vaNEXT]).Length) == "\0") { - vaNEXT++; - return ""; - } else - return Encoding.UTF8.GetString((byte[])ap[vaNEXT], 0, ((byte[])ap[vaNEXT++]).Length); - else if (ap[vaNEXT] is Int32) { - vaNEXT++; - return null; - } else if (ap[vaNEXT] is StringBuilder) - return (String)ap[vaNEXT++].ToString(); - else if (ap[vaNEXT] is Char) - return ((Char)ap[vaNEXT++]).ToString(); - else - return (String)ap[vaNEXT++]; - } - } +static sqlite3_mutex_methods va_arg( object[] ap, sqlite3_mutex_methods sysType ) +{ + return (sqlite3_mutex_methods)ap[vaNEXT++]; +} - static Token va_arg(object[] ap, Token sysType) { - return (Token)ap[vaNEXT++]; - } +static SrcList va_arg( object[] ap, SrcList sysType ) +{ + return (SrcList)ap[vaNEXT++]; +} + +static String va_arg( object[] ap, String sysType ) +{ + if ( ap.Length < vaNEXT - 1 || ap[vaNEXT] == null ) + { + vaNEXT++; + return "NULL"; + } + else + { + if ( ap[vaNEXT] is Byte[] ) + if ( Encoding.UTF8.GetString( (byte[])ap[vaNEXT], 0, ( (byte[])ap[vaNEXT] ).Length ) == "\0" ) + { + vaNEXT++; + return ""; + } + else + return Encoding.UTF8.GetString( (byte[])ap[vaNEXT], 0, ( (byte[])ap[vaNEXT++] ).Length ); + else if ( ap[vaNEXT] is Int32 ) + { + vaNEXT++; + return null; + } + else if ( ap[vaNEXT] is StringBuilder ) + return (String)ap[vaNEXT++].ToString(); + else if ( ap[vaNEXT] is Char ) + return ( (Char)ap[vaNEXT++] ).ToString(); + else + return (String)ap[vaNEXT++]; + } +} + +static Token va_arg( object[] ap, Token sysType ) +{ + return (Token)ap[vaNEXT++]; +} - static UInt32 va_arg(object[] ap, UInt32 sysType) { +static UInt32 va_arg( object[] ap, UInt32 sysType ) +{ #if SQLITE_WINRT Type t = ap[vaNEXT].GetType(); if ( t.IsClass ) #else - if (ap[vaNEXT].GetType().IsClass) + if ( ap[vaNEXT].GetType().IsClass ) #endif - { - return (UInt32)ap[vaNEXT++].GetHashCode(); - } else { - return (UInt32)Convert.ToUInt32(ap[vaNEXT++]); - } - } + { + return (UInt32)ap[vaNEXT++].GetHashCode(); + } + else + { + return (UInt32)Convert.ToUInt32( ap[vaNEXT++] ); + } +} - static UInt64 va_arg(object[] ap, UInt64 sysType) { +static UInt64 va_arg( object[] ap, UInt64 sysType ) +{ #if SQLITE_WINRT Type t = ap[vaNEXT].GetType(); if (t.IsClass) #else - if (ap[vaNEXT].GetType().IsClass) + if ( ap[vaNEXT].GetType().IsClass ) #endif - { - return (UInt64)ap[vaNEXT++].GetHashCode(); - } else { - return (UInt64)Convert.ToUInt64(ap[vaNEXT++]); - } - } + { + return (UInt64)ap[vaNEXT++].GetHashCode(); + } + else + { + return (UInt64)Convert.ToUInt64( ap[vaNEXT++] ); + } +} - static void_function va_arg(object[] ap, void_function sysType) { - return (void_function)ap[vaNEXT++]; - } +static void_function va_arg( object[] ap, void_function sysType ) +{ + return (void_function)ap[vaNEXT++]; +} - static void va_end(ref string[] ap) { - ap = null; - vaNEXT = -1; - vaFORMAT = ""; - } - static void va_end(ref object[] ap) { - ap = null; - vaNEXT = -1; - vaFORMAT = ""; - } +static void va_end( ref string[] ap ) +{ + ap = null; + vaNEXT = -1; + vaFORMAT = ""; +} +static void va_end( ref object[] ap ) +{ + ap = null; + vaNEXT = -1; + vaFORMAT = ""; +} - public static tm localtime(time_t baseTime) { - System.DateTime RefTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0); - RefTime = RefTime.AddSeconds(Convert.ToDouble(baseTime)).ToLocalTime(); - tm tm = new tm(); - tm.tm_sec = RefTime.Second; - tm.tm_min = RefTime.Minute; - tm.tm_hour = RefTime.Hour; - tm.tm_mday = RefTime.Day; - tm.tm_mon = RefTime.Month; - tm.tm_year = RefTime.Year; - tm.tm_wday = (int)RefTime.DayOfWeek; - tm.tm_yday = RefTime.DayOfYear; - tm.tm_isdst = RefTime.IsDaylightSavingTime() ? 1 : 0; - return tm; - } +public static tm localtime( time_t baseTime ) +{ + System.DateTime RefTime = new System.DateTime( 1970, 1, 1, 0, 0, 0, 0 ); + RefTime = RefTime.AddSeconds( Convert.ToDouble( baseTime ) ).ToLocalTime(); + tm tm = new tm(); + tm.tm_sec = RefTime.Second; + tm.tm_min = RefTime.Minute; + tm.tm_hour = RefTime.Hour; + tm.tm_mday = RefTime.Day; + tm.tm_mon = RefTime.Month; + tm.tm_year = RefTime.Year; + tm.tm_wday = (int)RefTime.DayOfWeek; + tm.tm_yday = RefTime.DayOfYear; + tm.tm_isdst = RefTime.IsDaylightSavingTime() ? 1 : 0; + return tm; +} - public static long ToUnixtime(System.DateTime date) { - System.DateTime unixStartTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0); - System.TimeSpan timeSpan = date - unixStartTime; - return Convert.ToInt64(timeSpan.TotalSeconds); - } +public static long ToUnixtime( System.DateTime date ) +{ + System.DateTime unixStartTime = new System.DateTime( 1970, 1, 1, 0, 0, 0, 0 ); + System.TimeSpan timeSpan = date - unixStartTime; + return Convert.ToInt64( timeSpan.TotalSeconds ); +} - public static System.DateTime ToCSharpTime(long unixTime) { - System.DateTime unixStartTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0); - return unixStartTime.AddSeconds(Convert.ToDouble(unixTime)); - } +public static System.DateTime ToCSharpTime( long unixTime ) +{ + System.DateTime unixStartTime = new System.DateTime( 1970, 1, 1, 0, 0, 0, 0 ); + return unixStartTime.AddSeconds( Convert.ToDouble( unixTime ) ); +} - public class tm { - public int tm_sec; /* seconds after the minute - [0,59] */ - public int tm_min; /* minutes after the hour - [0,59] */ - public int tm_hour; /* hours since midnight - [0,23] */ - public int tm_mday; /* day of the month - [1,31] */ - public int tm_mon; /* months since January - [0,11] */ - public int tm_year; /* years since 1900 */ - public int tm_wday; /* days since Sunday - [0,6] */ - public int tm_yday; /* days since January 1 - [0,365] */ - public int tm_isdst; /* daylight savings time flag */ - }; - - public struct FILETIME { - public u32 dwLowDateTime; - public u32 dwHighDateTime; - } +public class tm +{ + public int tm_sec; /* seconds after the minute - [0,59] */ + public int tm_min; /* minutes after the hour - [0,59] */ + public int tm_hour; /* hours since midnight - [0,23] */ + public int tm_mday; /* day of the month - [1,31] */ + public int tm_mon; /* months since January - [0,11] */ + public int tm_year; /* years since 1900 */ + public int tm_wday; /* days since Sunday - [0,6] */ + public int tm_yday; /* days since January 1 - [0,365] */ + public int tm_isdst; /* daylight savings time flag */ +}; - static void SWAP(ref T A, ref T B) { - T t = A; - A = B; - B = t; - } +public struct FILETIME +{ + public u32 dwLowDateTime; + public u32 dwHighDateTime; +} - static void x_CountStep( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - SumCtx p; - - int type; - Debug.Assert(argc <= 1); - Mem pMem = sqlite3_aggregate_context(context, 1);//sizeof(*p)); - if (pMem._SumCtx == null) - pMem._SumCtx = new SumCtx(); - p = pMem._SumCtx; - if (p.Context == null) - p.Context = pMem; - if (argc == 0 || SQLITE_NULL == sqlite3_value_type(argv[0])) { - p.cnt++; - p.iSum += 1; - } else { - type = sqlite3_value_numeric_type(argv[0]); - if (p != null && type != SQLITE_NULL) { - p.cnt++; - if (type == SQLITE_INTEGER) { - i64 v = sqlite3_value_int64(argv[0]); - if (v == 40 || v == 41) { - sqlite3_result_error(context, "value of " + v + " handed to x_count", -1); - return; - } else { - p.iSum += v; - if (!(p.approx | p.overflow != 0)) { - i64 iNewSum = p.iSum + v; - int s1 = (int)(p.iSum >> (sizeof(i64) * 8 - 1)); - int s2 = (int)(v >> (sizeof(i64) * 8 - 1)); - int s3 = (int)(iNewSum >> (sizeof(i64) * 8 - 1)); - p.overflow = ((s1 & s2 & ~s3) | (~s1 & ~s2 & s3)) != 0 ? 1 : 0; - p.iSum = iNewSum; - } - } - } else { - p.rSum += sqlite3_value_double(argv[0]); - p.approx = true; - } - } - } - } - static void x_CountFinalize(sqlite3_context context) { - SumCtx p; - Mem pMem = sqlite3_aggregate_context(context, 0); - p = pMem._SumCtx; - if (p != null && p.cnt > 0) { - if (p.overflow != 0) { - sqlite3_result_error(context, "integer overflow", -1); - } else if (p.approx) { - sqlite3_result_double(context, p.rSum); - } else if (p.iSum == 42) { - sqlite3_result_error(context, "x_count totals to 42", -1); - } else { - sqlite3_result_int64(context, p.iSum); - } - } - } +static void SWAP( ref T A, ref T B ) +{ + T t = A; + A = B; + B = t; +} + +static void x_CountStep( +sqlite3_context context, +int argc, +sqlite3_value[] argv +) +{ + SumCtx p; + + int type; + Debug.Assert( argc <= 1 ); + Mem pMem = sqlite3_aggregate_context( context, 1 );//sizeof(*p)); + if ( pMem._SumCtx == null ) + pMem._SumCtx = new SumCtx(); + p = pMem._SumCtx; + if ( p.Context == null ) + p.Context = pMem; + if ( argc == 0 || SQLITE_NULL == sqlite3_value_type( argv[0] ) ) + { + p.cnt++; + p.iSum += 1; + } + else + { + type = sqlite3_value_numeric_type( argv[0] ); + if ( p != null && type != SQLITE_NULL ) + { + p.cnt++; + if ( type == SQLITE_INTEGER ) + { + i64 v = sqlite3_value_int64( argv[0] ); + if ( v == 40 || v == 41 ) + { + sqlite3_result_error( context, "value of " + v + " handed to x_count", -1 ); + return; + } + else + { + p.iSum += v; + if ( !( p.approx | p.overflow != 0 ) ) + { + i64 iNewSum = p.iSum + v; + int s1 = (int)( p.iSum >> ( sizeof( i64 ) * 8 - 1 ) ); + int s2 = (int)( v >> ( sizeof( i64 ) * 8 - 1 ) ); + int s3 = (int)( iNewSum >> ( sizeof( i64 ) * 8 - 1 ) ); + p.overflow = ( ( s1 & s2 & ~s3 ) | ( ~s1 & ~s2 & s3 ) ) != 0 ? 1 : 0; + p.iSum = iNewSum; + } + } + } + else + { + p.rSum += sqlite3_value_double( argv[0] ); + p.approx = true; + } + } + } +} +static void x_CountFinalize( sqlite3_context context ) +{ + SumCtx p; + Mem pMem = sqlite3_aggregate_context( context, 0 ); + p = pMem._SumCtx; + if ( p != null && p.cnt > 0 ) + { + if ( p.overflow != 0 ) + { + sqlite3_result_error( context, "integer overflow", -1 ); + } + else if ( p.approx ) + { + sqlite3_result_double( context, p.rSum ); + } + else if ( p.iSum == 42 ) + { + sqlite3_result_error( context, "x_count totals to 42", -1 ); + } + else + { + sqlite3_result_int64( context, p.iSum ); + } + } +} #if SQLITE_MUTEX_W32 - //---------------------WIN32 Definitions - static int GetCurrentThreadId() { - return Environment.CurrentManagedThreadId; - } - static long InterlockedIncrement(long location) { - Interlocked.Increment(ref location); - return location; - } - static void EnterCriticalSection(Object mtx) { - //long mid = mtx.GetHashCode(); - //int tid = Thread.CurrentThread.ManagedThreadId; - //long ticks = cnt++; - //Debug.WriteLine(String.Format( "{2}: +EnterCriticalSection; Mutex {0} Thread {1}", mtx.GetHashCode(), Thread.CurrentThread.ManagedThreadId, ticks) ); - Monitor.Enter(mtx); - } - static void InitializeCriticalSection(Object mtx) { - //Debug.WriteLine(String.Format( "{2}: +InitializeCriticalSection; Mutex {0} Thread {1}", mtx.GetHashCode(), Thread.CurrentThread.ManagedThreadId, System.DateTime.Now.Ticks )); - } - static void DeleteCriticalSection(Object mtx) { - //Debug.WriteLine(String.Format( "{2}: +DeleteCriticalSection; Mutex {0} Thread {1}", mtx.GetHashCode(), Thread.CurrentThread.ManagedThreadId, System.DateTime.Now.Ticks) ); - } - static void LeaveCriticalSection(Object mtx) { - //Debug.WriteLine(String.Format("{2}: +LeaveCriticalSection; Mutex {0} Thread {1}", mtx.GetHashCode(), Thread.CurrentThread.ManagedThreadId, System.DateTime.Now.Ticks )); - Monitor.Exit(mtx); - } +//---------------------WIN32 Definitions +static int GetCurrentThreadId() +{ + return Environment.CurrentManagedThreadId; +} +static long InterlockedIncrement( long location ) +{ + Interlocked.Increment( ref location ); + return location; +} +static void EnterCriticalSection( Object mtx ) +{ + //long mid = mtx.GetHashCode(); + //int tid = Thread.CurrentThread.ManagedThreadId; + //long ticks = cnt++; + //Debug.WriteLine(String.Format( "{2}: +EnterCriticalSection; Mutex {0} Thread {1}", mtx.GetHashCode(), Thread.CurrentThread.ManagedThreadId, ticks) ); + Monitor.Enter( mtx ); +} +static void InitializeCriticalSection( Object mtx ) +{ + //Debug.WriteLine(String.Format( "{2}: +InitializeCriticalSection; Mutex {0} Thread {1}", mtx.GetHashCode(), Thread.CurrentThread.ManagedThreadId, System.DateTime.Now.Ticks )); +} +static void DeleteCriticalSection( Object mtx ) +{ + //Debug.WriteLine(String.Format( "{2}: +DeleteCriticalSection; Mutex {0} Thread {1}", mtx.GetHashCode(), Thread.CurrentThread.ManagedThreadId, System.DateTime.Now.Ticks) ); +} +static void LeaveCriticalSection( Object mtx ) +{ + //Debug.WriteLine(String.Format("{2}: +LeaveCriticalSection; Mutex {0} Thread {1}", mtx.GetHashCode(), Thread.CurrentThread.ManagedThreadId, System.DateTime.Now.Ticks )); + Monitor.Exit( mtx ); +} #endif - // Miscellaneous Windows Constants - //#define ERROR_FILE_NOT_FOUND 2L - //#define ERROR_HANDLE_DISK_FULL 39L - //#define ERROR_NOT_SUPPORTED 50L - //#define ERROR_DISK_FULL 112L - const long ERROR_FILE_NOT_FOUND = 2L; - const long ERROR_HANDLE_DISK_FULL = 39L; - const long ERROR_NOT_SUPPORTED = 50L; - const long ERROR_DISK_FULL = 112L; - - private class SQLite3UpperToLower { - static int[] sqlite3UpperToLower = new int[] { +// Miscellaneous Windows Constants +//#define ERROR_FILE_NOT_FOUND 2L +//#define ERROR_HANDLE_DISK_FULL 39L +//#define ERROR_NOT_SUPPORTED 50L +//#define ERROR_DISK_FULL 112L +const long ERROR_FILE_NOT_FOUND = 2L; +const long ERROR_HANDLE_DISK_FULL = 39L; +const long ERROR_NOT_SUPPORTED = 50L; +const long ERROR_DISK_FULL = 112L; + +private class SQLite3UpperToLower +{ + static int[] sqlite3UpperToLower = new int[] { #if SQLITE_ASCII 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, @@ -513,27 +613,31 @@ private class SQLite3UpperToLower { 252,253,254,255 #endif }; - public int this[int index] { - get { - if (index < sqlite3UpperToLower.Length) - return sqlite3UpperToLower[index]; - else - return index; - } - } - - public int this[u32 index] { - get { - if (index < sqlite3UpperToLower.Length) - return sqlite3UpperToLower[index]; - else - return (int)index; - } - } - } + public int this[int index] + { + get + { + if ( index < sqlite3UpperToLower.Length ) + return sqlite3UpperToLower[index]; + else + return index; + } + } + + public int this[u32 index] + { + get + { + if ( index < sqlite3UpperToLower.Length ) + return sqlite3UpperToLower[index]; + else + return (int)index; + } + } +} - static SQLite3UpperToLower sqlite3UpperToLower = new SQLite3UpperToLower(); - static SQLite3UpperToLower UpperToLower = sqlite3UpperToLower; +static SQLite3UpperToLower sqlite3UpperToLower = new SQLite3UpperToLower(); +static SQLite3UpperToLower UpperToLower = sqlite3UpperToLower; - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/alter_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/alter_c.cs index f1eb50e99..d2147ab74 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/alter_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/alter_c.cs @@ -1,259 +1,278 @@ using System; using System.Diagnostics; - -namespace Community.CsharpSqlite { - using sqlite3_value = Sqlite3.Mem; - - public partial class Sqlite3 { - /* - ** 2005 February 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. - ** - ************************************************************************* - ** This file contains C code routines that used to generate VDBE code - ** that implements the ALTER TABLE command. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - - /* - ** The code in this file only exists if we are not omitting the - ** ALTER TABLE logic from the build. - */ +using System.Text; + +namespace Community.CsharpSqlite +{ + using sqlite3_value = Sqlite3.Mem; + + public partial class Sqlite3 + { +/* +** 2005 February 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. +** +************************************************************************* +** This file contains C code routines that used to generate VDBE code +** that implements the ALTER TABLE command. +************************************************************************* +** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart +** C#-SQLite is an independent reimplementation of the SQLite software library +** +** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 +** +************************************************************************* +*/ +//#include "sqliteInt.h" + +/* +** The code in this file only exists if we are not omitting the +** ALTER TABLE logic from the build. +*/ #if !SQLITE_OMIT_ALTERTABLE - /* - ** This function is used by SQL generated to implement the - ** ALTER TABLE command. The first argument is the text of a CREATE TABLE or - ** CREATE INDEX command. The second is a table name. The table name in - ** the CREATE TABLE or CREATE INDEX statement is replaced with the third - ** argument and the result returned. Examples: - ** - ** sqlite_rename_table('CREATE TABLE abc(a, b, c)', 'def') - ** . 'CREATE TABLE def(a, b, c)' - ** - ** sqlite_rename_table('CREATE INDEX i ON abc(a)', 'def') - ** . 'CREATE INDEX i ON def(a, b, c)' - */ - static void renameTableFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] argv - ) { - string bResult = sqlite3_value_text(argv[0]); - string zSql = bResult == null ? "" : bResult; - string zTableName = sqlite3_value_text(argv[1]); - - int token = 0; - Token tname = new Token(); - int zCsr = 0; - int zLoc = 0; - int len = 0; - string zRet; - - sqlite3 db = sqlite3_context_db_handle(context); - - UNUSED_PARAMETER(NotUsed); - - /* The principle used to locate the table name in the CREATE TABLE - ** statement is that the table name is the first non-space token that - ** is immediately followed by a TK_LP or TK_USING token. - */ - if (zSql != "") { - do { - if (zCsr == zSql.Length) { - /* Ran out of input before finding an opening bracket. Return NULL. */ - return; - } - - /* Store the token that zCsr points to in tname. */ - zLoc = zCsr; - tname.z = zSql.Substring(zCsr);//(char*)zCsr; - tname.n = len; - - /* Advance zCsr to the next token. Store that token type in 'token', - ** and its length in 'len' (to be used next iteration of this loop). - */ - do { - zCsr += len; - len = (zCsr == zSql.Length) ? 1 : sqlite3GetToken(zSql, zCsr, ref token); - } while (token == TK_SPACE); - Debug.Assert(len > 0); - } while (token != TK_LP && token != TK_USING); - - zRet = sqlite3MPrintf(db, "%.*s\"%w\"%s", zLoc, zSql.Substring(0, zLoc), - zTableName, zSql.Substring(zLoc + tname.n)); - - sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC); - } - } - - /* - ** This C function implements an SQL user function that is used by SQL code - ** generated by the ALTER TABLE ... RENAME command to modify the definition - ** of any foreign key constraints that use the table being renamed as the - ** parent table. It is passed three arguments: - ** - ** 1) The complete text of the CREATE TABLE statement being modified, - ** 2) The old name of the table being renamed, and - ** 3) The new name of the table being renamed. - ** - ** It returns the new CREATE TABLE statement. For example: - ** - ** sqlite_rename_parent('CREATE TABLE t1(a REFERENCES t2)', 't2', 't3') - ** -> 'CREATE TABLE t1(a REFERENCES t3)' - */ +/* +** This function is used by SQL generated to implement the +** ALTER TABLE command. The first argument is the text of a CREATE TABLE or +** CREATE INDEX command. The second is a table name. The table name in +** the CREATE TABLE or CREATE INDEX statement is replaced with the third +** argument and the result returned. Examples: +** +** sqlite_rename_table('CREATE TABLE abc(a, b, c)', 'def') +** . 'CREATE TABLE def(a, b, c)' +** +** sqlite_rename_table('CREATE INDEX i ON abc(a)', 'def') +** . 'CREATE INDEX i ON def(a, b, c)' +*/ +static void renameTableFunc( +sqlite3_context context, +int NotUsed, +sqlite3_value[] argv +) +{ + string bResult = sqlite3_value_text( argv[0] ); + string zSql = bResult == null ? "" : bResult; + string zTableName = sqlite3_value_text( argv[1] ); + + int token = 0; + Token tname = new Token(); + int zCsr = 0; + int zLoc = 0; + int len = 0; + string zRet; + + sqlite3 db = sqlite3_context_db_handle( context ); + + UNUSED_PARAMETER( NotUsed ); + + /* The principle used to locate the table name in the CREATE TABLE + ** statement is that the table name is the first non-space token that + ** is immediately followed by a TK_LP or TK_USING token. + */ + if ( zSql != "" ) + { + do + { + if ( zCsr == zSql.Length ) + { + /* Ran out of input before finding an opening bracket. Return NULL. */ + return; + } + + /* Store the token that zCsr points to in tname. */ + zLoc = zCsr; + tname.z = zSql.Substring( zCsr );//(char*)zCsr; + tname.n = len; + + /* Advance zCsr to the next token. Store that token type in 'token', + ** and its length in 'len' (to be used next iteration of this loop). + */ + do + { + zCsr += len; + len = ( zCsr == zSql.Length ) ? 1 : sqlite3GetToken( zSql, zCsr, ref token ); + } while ( token == TK_SPACE ); + Debug.Assert( len > 0 ); + } while ( token != TK_LP && token != TK_USING ); + + zRet = sqlite3MPrintf( db, "%.*s\"%w\"%s", zLoc, zSql.Substring( 0, zLoc ), + zTableName, zSql.Substring( zLoc + tname.n ) ); + + sqlite3_result_text( context, zRet, -1, SQLITE_DYNAMIC ); + } +} + +/* +** This C function implements an SQL user function that is used by SQL code +** generated by the ALTER TABLE ... RENAME command to modify the definition +** of any foreign key constraints that use the table being renamed as the +** parent table. It is passed three arguments: +** +** 1) The complete text of the CREATE TABLE statement being modified, +** 2) The old name of the table being renamed, and +** 3) The new name of the table being renamed. +** +** It returns the new CREATE TABLE statement. For example: +** +** sqlite_rename_parent('CREATE TABLE t1(a REFERENCES t2)', 't2', 't3') +** -> 'CREATE TABLE t1(a REFERENCES t3)' +*/ #if !SQLITE_OMIT_FOREIGN_KEY - static void renameParentFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] argv - ) { - sqlite3 db = sqlite3_context_db_handle(context); - string zOutput = ""; - string zResult; - string zInput = sqlite3_value_text(argv[0]); - string zOld = sqlite3_value_text(argv[1]); - string zNew = sqlite3_value_text(argv[2]); - - int zIdx; /* Pointer to token */ - int zLeft = 0; /* Pointer to remainder of String */ - int n = 0; /* Length of token z */ - int token = 0; /* Type of token */ - - UNUSED_PARAMETER(NotUsed); - for (zIdx = 0; zIdx < zInput.Length; zIdx += n)//z=zInput; *z; z=z+n) - { - n = sqlite3GetToken(zInput, zIdx, ref token); - if (token == TK_REFERENCES) { - string zParent; - do { - zIdx += n; - n = sqlite3GetToken(zInput, zIdx, ref token); - } while (token == TK_SPACE); - - zParent = zIdx + n < zInput.Length ? zInput.Substring(zIdx, n) : "";//sqlite3DbStrNDup(db, zIdx, n); - if (String.IsNullOrEmpty(zParent)) - break; - sqlite3Dequote(ref zParent); - if (zOld.Equals(zParent, StringComparison.OrdinalIgnoreCase)) { - string zOut = sqlite3MPrintf(db, "%s%.*s\"%w\"", - zOutput, zIdx - zLeft, zInput.Substring(zLeft), zNew - ); - sqlite3DbFree(db, ref zOutput); - zOutput = zOut; - zIdx += n;// zInput = &z[n]; - zLeft = zIdx; - } - sqlite3DbFree(db, ref zParent); - } - } - - zResult = sqlite3MPrintf(db, "%s%s", zOutput, zInput.Substring(zLeft)); - sqlite3_result_text(context, zResult, -1, SQLITE_DYNAMIC); - sqlite3DbFree(db, ref zOutput); - } +static void renameParentFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] argv +) +{ + sqlite3 db = sqlite3_context_db_handle( context ); + string zOutput = ""; + string zResult; + string zInput = sqlite3_value_text( argv[0] ); + string zOld = sqlite3_value_text( argv[1] ); + string zNew = sqlite3_value_text( argv[2] ); + + int zIdx; /* Pointer to token */ + int zLeft = 0; /* Pointer to remainder of String */ + int n = 0; /* Length of token z */ + int token = 0; /* Type of token */ + + UNUSED_PARAMETER( NotUsed ); + for ( zIdx = 0; zIdx < zInput.Length; zIdx += n )//z=zInput; *z; z=z+n) + { + n = sqlite3GetToken( zInput, zIdx, ref token ); + if ( token == TK_REFERENCES ) + { + string zParent; + do + { + zIdx += n; + n = sqlite3GetToken( zInput, zIdx, ref token ); + } while ( token == TK_SPACE ); + + zParent = zIdx + n < zInput.Length ? zInput.Substring( zIdx, n ) : "";//sqlite3DbStrNDup(db, zIdx, n); + if ( String.IsNullOrEmpty( zParent ) ) + break; + sqlite3Dequote( ref zParent ); + if ( zOld.Equals( zParent, StringComparison.OrdinalIgnoreCase) ) + { + string zOut = sqlite3MPrintf( db, "%s%.*s\"%w\"", + zOutput, zIdx - zLeft, zInput.Substring( zLeft ), zNew + ); + sqlite3DbFree( db, ref zOutput ); + zOutput = zOut; + zIdx += n;// zInput = &z[n]; + zLeft = zIdx; + } + sqlite3DbFree( db, ref zParent ); + } + } + + zResult = sqlite3MPrintf( db, "%s%s", zOutput, zInput.Substring( zLeft ) ); + sqlite3_result_text( context, zResult, -1, SQLITE_DYNAMIC ); + sqlite3DbFree( db, ref zOutput ); +} #endif #if !SQLITE_OMIT_TRIGGER - /* This function is used by SQL generated to implement the - ** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER - ** statement. The second is a table name. The table name in the CREATE - ** TRIGGER statement is replaced with the third argument and the result - ** returned. This is analagous to renameTableFunc() above, except for CREATE - ** TRIGGER, not CREATE INDEX and CREATE TABLE. - */ - static void renameTriggerFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] argv - ) { - string zSql = sqlite3_value_text(argv[0]); - string zTableName = sqlite3_value_text(argv[1]); - - int token = 0; - Token tname = new Token(); - int dist = 3; - int zCsr = 0; - int zLoc = 0; - int len = 1; - string zRet; - - sqlite3 db = sqlite3_context_db_handle(context); - - UNUSED_PARAMETER(NotUsed); - - /* The principle used to locate the table name in the CREATE TRIGGER - ** statement is that the table name is the first token that is immediatedly - ** preceded by either TK_ON or TK_DOT and immediatedly followed by one - ** of TK_WHEN, TK_BEGIN or TK_FOR. - */ - if (zSql != null) { - do { - - if (zCsr == zSql.Length) { - /* Ran out of input before finding the table name. Return NULL. */ - return; - } - - /* Store the token that zCsr points to in tname. */ - zLoc = zCsr; - tname.z = zSql.Substring(zCsr, len);//(char*)zCsr; - tname.n = len; - - /* Advance zCsr to the next token. Store that token type in 'token', - ** and its length in 'len' (to be used next iteration of this loop). - */ - do { - zCsr += len; - len = (zCsr == zSql.Length) ? 1 : sqlite3GetToken(zSql, zCsr, ref token); - } while (token == TK_SPACE); - Debug.Assert(len > 0); - - /* Variable 'dist' stores the number of tokens read since the most - ** recent TK_DOT or TK_ON. This means that when a WHEN, FOR or BEGIN - ** token is read and 'dist' equals 2, the condition stated above - ** to be met. - ** - ** Note that ON cannot be a database, table or column name, so - ** there is no need to worry about syntax like - ** "CREATE TRIGGER ... ON ON.ON BEGIN ..." etc. - */ - dist++; - if (token == TK_DOT || token == TK_ON) { - dist = 0; - } - } while (dist != 2 || (token != TK_WHEN && token != TK_FOR && token != TK_BEGIN)); - - /* Variable tname now contains the token that is the old table-name - ** in the CREATE TRIGGER statement. - */ - zRet = sqlite3MPrintf(db, "%.*s\"%w\"%s", zLoc, zSql.Substring(0, zLoc), - zTableName, zSql.Substring(zLoc + tname.n)); - sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC); - } - } +/* This function is used by SQL generated to implement the +** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER +** statement. The second is a table name. The table name in the CREATE +** TRIGGER statement is replaced with the third argument and the result +** returned. This is analagous to renameTableFunc() above, except for CREATE +** TRIGGER, not CREATE INDEX and CREATE TABLE. +*/ +static void renameTriggerFunc( +sqlite3_context context, +int NotUsed, +sqlite3_value[] argv +) +{ + string zSql = sqlite3_value_text( argv[0] ); + string zTableName = sqlite3_value_text( argv[1] ); + + int token = 0; + Token tname = new Token(); + int dist = 3; + int zCsr = 0; + int zLoc = 0; + int len = 1; + string zRet; + + sqlite3 db = sqlite3_context_db_handle( context ); + + UNUSED_PARAMETER( NotUsed ); + + /* The principle used to locate the table name in the CREATE TRIGGER + ** statement is that the table name is the first token that is immediatedly + ** preceded by either TK_ON or TK_DOT and immediatedly followed by one + ** of TK_WHEN, TK_BEGIN or TK_FOR. + */ + if ( zSql != null ) + { + do + { + + if ( zCsr == zSql.Length ) + { + /* Ran out of input before finding the table name. Return NULL. */ + return; + } + + /* Store the token that zCsr points to in tname. */ + zLoc = zCsr; + tname.z = zSql.Substring( zCsr, len );//(char*)zCsr; + tname.n = len; + + /* Advance zCsr to the next token. Store that token type in 'token', + ** and its length in 'len' (to be used next iteration of this loop). + */ + do + { + zCsr += len; + len = ( zCsr == zSql.Length ) ? 1 : sqlite3GetToken( zSql, zCsr, ref token ); + } while ( token == TK_SPACE ); + Debug.Assert( len > 0 ); + + /* Variable 'dist' stores the number of tokens read since the most + ** recent TK_DOT or TK_ON. This means that when a WHEN, FOR or BEGIN + ** token is read and 'dist' equals 2, the condition stated above + ** to be met. + ** + ** Note that ON cannot be a database, table or column name, so + ** there is no need to worry about syntax like + ** "CREATE TRIGGER ... ON ON.ON BEGIN ..." etc. + */ + dist++; + if ( token == TK_DOT || token == TK_ON ) + { + dist = 0; + } + } while ( dist != 2 || ( token != TK_WHEN && token != TK_FOR && token != TK_BEGIN ) ); + + /* Variable tname now contains the token that is the old table-name + ** in the CREATE TRIGGER statement. + */ + zRet = sqlite3MPrintf( db, "%.*s\"%w\"%s", zLoc, zSql.Substring( 0, zLoc ), + zTableName, zSql.Substring( zLoc + tname.n ) ); + sqlite3_result_text( context, zRet, -1, SQLITE_DYNAMIC ); + } +} #endif // * !SQLITE_OMIT_TRIGGER */ - /* - ** Register built-in functions used to help implement ALTER TABLE - */ - static FuncDef[] aAlterTableFuncs; - static void sqlite3AlterFunctions() { - aAlterTableFuncs = new FuncDef[] { +/* +** Register built-in functions used to help implement ALTER TABLE +*/ +static FuncDef[] aAlterTableFuncs; +static void sqlite3AlterFunctions() +{ + aAlterTableFuncs = new FuncDef[] { FUNCTION("sqlite_rename_table", 2, 0, 0, renameTableFunc), #if !SQLITE_OMIT_TRIGGER FUNCTION("sqlite_rename_trigger", 2, 0, 0, renameTriggerFunc), @@ -262,227 +281,249 @@ static void sqlite3AlterFunctions() { FUNCTION("sqlite_rename_parent", 3, 0, 0, renameParentFunc), #endif }; - int i; + int i; #if SQLITE_OMIT_WSD FuncDefHash pHash = GLOBAL(FuncDefHash, sqlite3GlobalFunctions); FuncDef[] aFunc = GLOBAL(FuncDef, aAlterTableFuncs); #else - FuncDefHash pHash = sqlite3GlobalFunctions; - FuncDef[] aFunc = aAlterTableFuncs; + FuncDefHash pHash = sqlite3GlobalFunctions; + FuncDef[] aFunc = aAlterTableFuncs; #endif - for (i = 0; i < ArraySize(aAlterTableFuncs); i++) { - sqlite3FuncDefInsert(pHash, aFunc[i]); - } - } - - /* - ** This function is used to create the text of expressions of the form: - ** - ** name= OR name= OR ... - ** - ** If argument zWhere is NULL, then a pointer string containing the text - ** "name=" is returned, where is the quoted version - ** of the string passed as argument zConstant. The returned buffer is - ** allocated using sqlite3DbMalloc(). It is the responsibility of the - ** caller to ensure that it is eventually freed. - ** - ** If argument zWhere is not NULL, then the string returned is - ** " OR name=", where is the contents of zWhere. - ** In this case zWhere is passed to sqlite3DbFree() before returning. - ** - */ - static string whereOrName(sqlite3 db, string zWhere, string zConstant) { - string zNew; - if (String.IsNullOrEmpty(zWhere)) { - zNew = sqlite3MPrintf(db, "name=%Q", zConstant); - } else { - zNew = sqlite3MPrintf(db, "%s OR name=%Q", zWhere, zConstant); - sqlite3DbFree(db, ref zWhere); - } - return zNew; - } + for ( i = 0; i < ArraySize( aAlterTableFuncs ); i++ ) + { + sqlite3FuncDefInsert( pHash, aFunc[i] ); + } +} + +/* +** This function is used to create the text of expressions of the form: +** +** name= OR name= OR ... +** +** If argument zWhere is NULL, then a pointer string containing the text +** "name=" is returned, where is the quoted version +** of the string passed as argument zConstant. The returned buffer is +** allocated using sqlite3DbMalloc(). It is the responsibility of the +** caller to ensure that it is eventually freed. +** +** If argument zWhere is not NULL, then the string returned is +** " OR name=", where is the contents of zWhere. +** In this case zWhere is passed to sqlite3DbFree() before returning. +** +*/ +static string whereOrName( sqlite3 db, string zWhere, string zConstant ) +{ + string zNew; + if ( String.IsNullOrEmpty( zWhere ) ) + { + zNew = sqlite3MPrintf( db, "name=%Q", zConstant ); + } + else + { + zNew = sqlite3MPrintf( db, "%s OR name=%Q", zWhere, zConstant ); + sqlite3DbFree( db, ref zWhere ); + } + return zNew; +} #if !(SQLITE_OMIT_FOREIGN_KEY) && !(SQLITE_OMIT_TRIGGER) - /* - ** Generate the text of a WHERE expression which can be used to select all - ** tables that have foreign key constraints that refer to table pTab (i.e. - ** constraints for which pTab is the parent table) from the sqlite_master - ** table. - */ - static string whereForeignKeys(Parse pParse, Table pTab) { - FKey p; - string zWhere = ""; - for (p = sqlite3FkReferences(pTab); p != null; p = p.pNextTo) { - zWhere = whereOrName(pParse.db, zWhere, p.pFrom.zName); - } - return zWhere; - } +/* +** Generate the text of a WHERE expression which can be used to select all +** tables that have foreign key constraints that refer to table pTab (i.e. +** constraints for which pTab is the parent table) from the sqlite_master +** table. +*/ +static string whereForeignKeys( Parse pParse, Table pTab ) +{ + FKey p; + string zWhere = ""; + for ( p = sqlite3FkReferences( pTab ); p != null; p = p.pNextTo ) + { + zWhere = whereOrName( pParse.db, zWhere, p.pFrom.zName ); + } + return zWhere; +} #endif - /* - ** Generate the text of a WHERE expression which can be used to select all - ** temporary triggers on table pTab from the sqlite_temp_master table. If - ** table pTab has no temporary triggers, or is itself stored in the - ** temporary database, NULL is returned. - */ - static string whereTempTriggers(Parse pParse, Table pTab) { - Trigger pTrig; - string zWhere = ""; - Schema pTempSchema = pParse.db.aDb[1].pSchema; /* Temp db schema */ - - /* If the table is not located in the temp.db (in which case NULL is - ** returned, loop through the tables list of triggers. For each trigger - ** that is not part of the temp.db schema, add a clause to the WHERE - ** expression being built up in zWhere. - */ - if (pTab.pSchema != pTempSchema) { - sqlite3 db = pParse.db; - for (pTrig = sqlite3TriggerList(pParse, pTab); pTrig != null; pTrig = pTrig.pNext) { - if (pTrig.pSchema == pTempSchema) { - zWhere = whereOrName(db, zWhere, pTrig.zName); - } - } - } - if (!String.IsNullOrEmpty(zWhere)) { - zWhere = sqlite3MPrintf(pParse.db, "type='trigger' AND (%s)", zWhere); - //sqlite3DbFree( pParse.db, ref zWhere ); - //zWhere = zNew; - } - return zWhere; - } - - /* - ** Generate code to drop and reload the internal representation of table - ** pTab from the database, including triggers and temporary triggers. - ** Argument zName is the name of the table in the database schema at - ** the time the generated code is executed. This can be different from - ** pTab.zName if this function is being called to code part of an - ** "ALTER TABLE RENAME TO" statement. - */ - static void reloadTableSchema(Parse pParse, Table pTab, string zName) { - Vdbe v; - string zWhere; - int iDb; /* Index of database containing pTab */ +/* +** Generate the text of a WHERE expression which can be used to select all +** temporary triggers on table pTab from the sqlite_temp_master table. If +** table pTab has no temporary triggers, or is itself stored in the +** temporary database, NULL is returned. +*/ +static string whereTempTriggers( Parse pParse, Table pTab ) +{ + Trigger pTrig; + string zWhere = ""; + Schema pTempSchema = pParse.db.aDb[1].pSchema; /* Temp db schema */ + + /* If the table is not located in the temp.db (in which case NULL is + ** returned, loop through the tables list of triggers. For each trigger + ** that is not part of the temp.db schema, add a clause to the WHERE + ** expression being built up in zWhere. + */ + if ( pTab.pSchema != pTempSchema ) + { + sqlite3 db = pParse.db; + for ( pTrig = sqlite3TriggerList( pParse, pTab ); pTrig != null; pTrig = pTrig.pNext ) + { + if ( pTrig.pSchema == pTempSchema ) + { + zWhere = whereOrName( db, zWhere, pTrig.zName ); + } + } + } + if ( !String.IsNullOrEmpty( zWhere ) ) + { + zWhere = sqlite3MPrintf( pParse.db, "type='trigger' AND (%s)", zWhere ); + //sqlite3DbFree( pParse.db, ref zWhere ); + //zWhere = zNew; + } + return zWhere; +} + +/* +** Generate code to drop and reload the internal representation of table +** pTab from the database, including triggers and temporary triggers. +** Argument zName is the name of the table in the database schema at +** the time the generated code is executed. This can be different from +** pTab.zName if this function is being called to code part of an +** "ALTER TABLE RENAME TO" statement. +*/ +static void reloadTableSchema( Parse pParse, Table pTab, string zName ) +{ + Vdbe v; + string zWhere; + int iDb; /* Index of database containing pTab */ #if !SQLITE_OMIT_TRIGGER - Trigger pTrig; + Trigger pTrig; #endif - v = sqlite3GetVdbe(pParse); - if (NEVER(v == null)) - return; - Debug.Assert(sqlite3BtreeHoldsAllMutexes(pParse.db)); - iDb = sqlite3SchemaToIndex(pParse.db, pTab.pSchema); - Debug.Assert(iDb >= 0); + v = sqlite3GetVdbe( pParse ); + if ( NEVER( v == null ) ) + return; + Debug.Assert( sqlite3BtreeHoldsAllMutexes( pParse.db ) ); + iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema ); + Debug.Assert( iDb >= 0 ); #if !SQLITE_OMIT_TRIGGER - /* Drop any table triggers from the internal schema. */ - for (pTrig = sqlite3TriggerList(pParse, pTab); pTrig != null; pTrig = pTrig.pNext) { - int iTrigDb = sqlite3SchemaToIndex(pParse.db, pTrig.pSchema); - Debug.Assert(iTrigDb == iDb || iTrigDb == 1); - sqlite3VdbeAddOp4(v, OP_DropTrigger, iTrigDb, 0, 0, pTrig.zName, 0); - } + /* Drop any table triggers from the internal schema. */ + for ( pTrig = sqlite3TriggerList( pParse, pTab ); pTrig != null; pTrig = pTrig.pNext ) + { + int iTrigDb = sqlite3SchemaToIndex( pParse.db, pTrig.pSchema ); + Debug.Assert( iTrigDb == iDb || iTrigDb == 1 ); + sqlite3VdbeAddOp4( v, OP_DropTrigger, iTrigDb, 0, 0, pTrig.zName, 0 ); + } #endif - /* Drop the table and index from the internal schema. */ - sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab.zName, 0); + /* Drop the table and index from the internal schema. */ + sqlite3VdbeAddOp4( v, OP_DropTable, iDb, 0, 0, pTab.zName, 0 ); - /* Reload the table, index and permanent trigger schemas. */ - zWhere = sqlite3MPrintf(pParse.db, "tbl_name=%Q", zName); - if (zWhere == null) - return; - sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere); + /* Reload the table, index and permanent trigger schemas. */ + zWhere = sqlite3MPrintf( pParse.db, "tbl_name=%Q", zName ); + if ( zWhere == null ) + return; + sqlite3VdbeAddParseSchemaOp( v, iDb, zWhere ); #if !SQLITE_OMIT_TRIGGER - /* Now, if the table is not stored in the temp database, reload any temp - ** triggers. Don't use IN(...) in case SQLITE_OMIT_SUBQUERY is defined. - */ - if ((zWhere = whereTempTriggers(pParse, pTab)) != "") { - sqlite3VdbeAddParseSchemaOp(v, 1, zWhere); - } + /* Now, if the table is not stored in the temp database, reload any temp +** triggers. Don't use IN(...) in case SQLITE_OMIT_SUBQUERY is defined. +*/ + if ( ( zWhere = whereTempTriggers( pParse, pTab ) ) != "" ) + { + sqlite3VdbeAddParseSchemaOp( v, 1, zWhere ); + } #endif - } - - /* - ** Parameter zName is the name of a table that is about to be altered - ** (either with ALTER TABLE ... RENAME TO or ALTER TABLE ... ADD COLUMN). - ** If the table is a system table, this function leaves an error message - ** in pParse->zErr (system tables may not be altered) and returns non-zero. - ** - ** Or, if zName is not a system table, zero is returned. - */ - static int isSystemTable(Parse pParse, string zName) { - if (zName.StartsWith("sqlite_", System.StringComparison.OrdinalIgnoreCase)) { - sqlite3ErrorMsg(pParse, "table %s may not be altered", zName); - return 1; - } - return 0; - } - - /* - ** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy" - ** command. - */ - static void sqlite3AlterRenameTable( - Parse pParse, /* Parser context. */ - SrcList pSrc, /* The table to rename. */ - Token pName /* The new table name. */ - ) { - int iDb; /* Database that contains the table */ - string zDb; /* Name of database iDb */ - Table pTab; /* Table being renamed */ - string zName = null; /* NULL-terminated version of pName */ - sqlite3 db = pParse.db; /* Database connection */ - int nTabName; /* Number of UTF-8 characters in zTabName */ - string zTabName; /* Original name of the table */ - Vdbe v; +} + +/* +** Parameter zName is the name of a table that is about to be altered +** (either with ALTER TABLE ... RENAME TO or ALTER TABLE ... ADD COLUMN). +** If the table is a system table, this function leaves an error message +** in pParse->zErr (system tables may not be altered) and returns non-zero. +** +** Or, if zName is not a system table, zero is returned. +*/ +static int isSystemTable( Parse pParse, string zName ) +{ + if (zName.StartsWith("sqlite_", System.StringComparison.OrdinalIgnoreCase)) + { + sqlite3ErrorMsg( pParse, "table %s may not be altered", zName ); + return 1; + } + return 0; +} + +/* +** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy" +** command. +*/ +static void sqlite3AlterRenameTable( +Parse pParse, /* Parser context. */ +SrcList pSrc, /* The table to rename. */ +Token pName /* The new table name. */ +) +{ + int iDb; /* Database that contains the table */ + string zDb; /* Name of database iDb */ + Table pTab; /* Table being renamed */ + string zName = null; /* NULL-terminated version of pName */ + sqlite3 db = pParse.db; /* Database connection */ + int nTabName; /* Number of UTF-8 characters in zTabName */ + string zTabName; /* Original name of the table */ + Vdbe v; #if !SQLITE_OMIT_TRIGGER - string zWhere = ""; /* Where clause to locate temp triggers */ + string zWhere = ""; /* Where clause to locate temp triggers */ #endif - VTable pVTab = null; /* Non-zero if this is a v-tab with an xRename() */ - int savedDbFlags; /* Saved value of db->flags */ - - savedDbFlags = db.flags; - - //if ( NEVER( db.mallocFailed != 0 ) ) goto exit_rename_table; - Debug.Assert(pSrc.nSrc == 1); - Debug.Assert(sqlite3BtreeHoldsAllMutexes(pParse.db)); - pTab = sqlite3LocateTable(pParse, 0, pSrc.a[0].zName, pSrc.a[0].zDatabase); - if (pTab == null) - goto exit_rename_table; - iDb = sqlite3SchemaToIndex(pParse.db, pTab.pSchema); - zDb = db.aDb[iDb].zName; - db.flags |= SQLITE_PreferBuiltin; - - /* Get a NULL terminated version of the new table name. */ - zName = sqlite3NameFromToken(db, pName); - if (zName == null) - goto exit_rename_table; - - /* Check that a table or index named 'zName' does not already exist - ** in database iDb. If so, this is an error. - */ - if (sqlite3FindTable(db, zName, zDb) != null || sqlite3FindIndex(db, zName, zDb) != null) { - sqlite3ErrorMsg(pParse, - "there is already another table or index with this name: %s", zName); - goto exit_rename_table; - } - - /* Make sure it is not a system table being altered, or a reserved name - ** that the table is being renamed to. - */ - if (SQLITE_OK != isSystemTable(pParse, pTab.zName)) { - goto exit_rename_table; - } - if (SQLITE_OK != sqlite3CheckObjectName(pParse, zName)) { - goto exit_rename_table; - } + VTable pVTab = null; /* Non-zero if this is a v-tab with an xRename() */ + int savedDbFlags; /* Saved value of db->flags */ + + savedDbFlags = db.flags; + + //if ( NEVER( db.mallocFailed != 0 ) ) goto exit_rename_table; + Debug.Assert( pSrc.nSrc == 1 ); + Debug.Assert( sqlite3BtreeHoldsAllMutexes( pParse.db ) ); + pTab = sqlite3LocateTable( pParse, 0, pSrc.a[0].zName, pSrc.a[0].zDatabase ); + if ( pTab == null ) + goto exit_rename_table; + iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema ); + zDb = db.aDb[iDb].zName; + db.flags |= SQLITE_PreferBuiltin; + + /* Get a NULL terminated version of the new table name. */ + zName = sqlite3NameFromToken( db, pName ); + if ( zName == null ) + goto exit_rename_table; + + /* Check that a table or index named 'zName' does not already exist + ** in database iDb. If so, this is an error. + */ + if ( sqlite3FindTable( db, zName, zDb ) != null || sqlite3FindIndex( db, zName, zDb ) != null ) + { + sqlite3ErrorMsg( pParse, + "there is already another table or index with this name: %s", zName ); + goto exit_rename_table; + } + + /* Make sure it is not a system table being altered, or a reserved name + ** that the table is being renamed to. + */ + if ( SQLITE_OK!=isSystemTable(pParse, pTab.zName) ) + { + goto exit_rename_table; + } + if ( SQLITE_OK != sqlite3CheckObjectName( pParse, zName ) ) + { + goto exit_rename_table; + } #if !SQLITE_OMIT_VIEW - if (pTab.pSelect != null) { - sqlite3ErrorMsg(pParse, "view %s may not be altered", pTab.zName); - goto exit_rename_table; - } + if ( pTab.pSelect != null ) + { + sqlite3ErrorMsg( pParse, "view %s may not be altered", pTab.zName ); + goto exit_rename_table; + } #endif #if !SQLITE_OMIT_AUTHORIZATION @@ -492,192 +533,207 @@ static void sqlite3AlterRenameTable( } #endif - if (sqlite3ViewGetColumnNames(pParse, pTab) != 0) { - goto exit_rename_table; - } + if ( sqlite3ViewGetColumnNames( pParse, pTab ) != 0 ) + { + goto exit_rename_table; + } #if !SQLITE_OMIT_VIRTUALTABLE - if (IsVirtual(pTab)) { - pVTab = sqlite3GetVTable(db, pTab); - if (pVTab.pVtab.pModule.xRename == null) { - pVTab = null; - } - } + if ( IsVirtual( pTab ) ) + { + pVTab = sqlite3GetVTable( db, pTab ); + if ( pVTab.pVtab.pModule.xRename == null ) + { + pVTab = null; + } + } #endif - /* Begin a transaction and code the VerifyCookie for database iDb. - ** Then modify the schema cookie (since the ALTER TABLE modifies the - ** schema). Open a statement transaction if the table is a virtual - ** table. - */ - v = sqlite3GetVdbe(pParse); - if (v == null) { - goto exit_rename_table; - } - sqlite3BeginWriteOperation(pParse, pVTab != null ? 1 : 0, iDb); - sqlite3ChangeCookie(pParse, iDb); - - /* If this is a virtual table, invoke the xRename() function if - ** one is defined. The xRename() callback will modify the names - ** of any resources used by the v-table implementation (including other - ** SQLite tables) that are identified by the name of the virtual table. - */ -#if !SQLITE_OMIT_VIRTUALTABLE - if (pVTab != null) { - int i = ++pParse.nMem; - sqlite3VdbeAddOp4(v, OP_String8, 0, i, 0, zName, 0); - sqlite3VdbeAddOp4(v, OP_VRename, i, 0, 0, pVTab, P4_VTAB); - sqlite3MayAbort(pParse); - } + /* Begin a transaction and code the VerifyCookie for database iDb. +** Then modify the schema cookie (since the ALTER TABLE modifies the +** schema). Open a statement transaction if the table is a virtual +** table. +*/ + v = sqlite3GetVdbe( pParse ); + if ( v == null ) + { + goto exit_rename_table; + } + sqlite3BeginWriteOperation( pParse, pVTab != null ? 1 : 0, iDb ); + sqlite3ChangeCookie( pParse, iDb ); + + /* If this is a virtual table, invoke the xRename() function if + ** one is defined. The xRename() callback will modify the names + ** of any resources used by the v-table implementation (including other + ** SQLite tables) that are identified by the name of the virtual table. + */ +#if !SQLITE_OMIT_VIRTUALTABLE +if ( pVTab !=null) +{ +int i = ++pParse.nMem; +sqlite3VdbeAddOp4( v, OP_String8, 0, i, 0, zName, 0 ); +sqlite3VdbeAddOp4( v, OP_VRename, i, 0, 0, pVTab, P4_VTAB ); +sqlite3MayAbort(pParse); +} #endif - /* figure out how many UTF-8 characters are in zName */ - zTabName = pTab.zName; - nTabName = sqlite3Utf8CharLen(zTabName, -1); + /* figure out how many UTF-8 characters are in zName */ + zTabName = pTab.zName; + nTabName = sqlite3Utf8CharLen( zTabName, -1 ); #if !(SQLITE_OMIT_FOREIGN_KEY) && !(SQLITE_OMIT_TRIGGER) - if ((db.flags & SQLITE_ForeignKeys) != 0) { - /* If foreign-key support is enabled, rewrite the CREATE TABLE - ** statements corresponding to all child tables of foreign key constraints - ** for which the renamed table is the parent table. */ - if ((zWhere = whereForeignKeys(pParse, pTab)) != null) { - sqlite3NestedParse(pParse, - "UPDATE \"%w\".%s SET " + - "sql = sqlite_rename_parent(sql, %Q, %Q) " + - "WHERE %s;", zDb, SCHEMA_TABLE(iDb), zTabName, zName, zWhere); - sqlite3DbFree(db, ref zWhere); - } - } + if ( ( db.flags & SQLITE_ForeignKeys ) != 0 ) + { + /* If foreign-key support is enabled, rewrite the CREATE TABLE + ** statements corresponding to all child tables of foreign key constraints + ** for which the renamed table is the parent table. */ + if ( ( zWhere = whereForeignKeys( pParse, pTab ) ) != null ) + { + sqlite3NestedParse( pParse, + "UPDATE \"%w\".%s SET " + + "sql = sqlite_rename_parent(sql, %Q, %Q) " + + "WHERE %s;", zDb, SCHEMA_TABLE( iDb ), zTabName, zName, zWhere ); + sqlite3DbFree( db, ref zWhere ); + } + } #endif - /* Modify the sqlite_master table to use the new table name. */ - sqlite3NestedParse(pParse, - "UPDATE %Q.%s SET " + + /* Modify the sqlite_master table to use the new table name. */ + sqlite3NestedParse( pParse, + "UPDATE %Q.%s SET " + #if SQLITE_OMIT_TRIGGER "sql = sqlite_rename_table(sql, %Q), " + #else - "sql = CASE " + - "WHEN type = 'trigger' THEN sqlite_rename_trigger(sql, %Q)" + - "ELSE sqlite_rename_table(sql, %Q) END, " + + "sql = CASE " + + "WHEN type = 'trigger' THEN sqlite_rename_trigger(sql, %Q)" + + "ELSE sqlite_rename_table(sql, %Q) END, " + #endif - "tbl_name = %Q, " + - "name = CASE " + - "WHEN type='table' THEN %Q " + - "WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN " + - "'sqlite_autoindex_' || %Q || substr(name,%d+18) " + - "ELSE name END " + - "WHERE tbl_name=%Q AND " + - "(type='table' OR type='index' OR type='trigger');", - zDb, SCHEMA_TABLE(iDb), zName, zName, zName, + "tbl_name = %Q, " + + "name = CASE " + + "WHEN type='table' THEN %Q " + + "WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN " + + "'sqlite_autoindex_' || %Q || substr(name,%d+18) " + + "ELSE name END " + + "WHERE tbl_name=%Q AND " + + "(type='table' OR type='index' OR type='trigger');", + zDb, SCHEMA_TABLE( iDb ), zName, zName, zName, #if !SQLITE_OMIT_TRIGGER - zName, + zName, #endif - zName, nTabName, zTabName - ); + zName, nTabName, zTabName + ); #if !SQLITE_OMIT_AUTOINCREMENT - /* If the sqlite_sequence table exists in this database, then update - ** it with the new table name. - */ - if (sqlite3FindTable(db, "sqlite_sequence", zDb) != null) { - sqlite3NestedParse(pParse, - "UPDATE \"%w\".sqlite_sequence set name = %Q WHERE name = %Q", - zDb, zName, pTab.zName - ); - } + /* If the sqlite_sequence table exists in this database, then update +** it with the new table name. +*/ + if ( sqlite3FindTable( db, "sqlite_sequence", zDb ) != null ) + { + sqlite3NestedParse( pParse, + "UPDATE \"%w\".sqlite_sequence set name = %Q WHERE name = %Q", + zDb, zName, pTab.zName + ); + } #endif #if !SQLITE_OMIT_TRIGGER - /* If there are TEMP triggers on this table, modify the sqlite_temp_master - ** table. Don't do this if the table being ALTERed is itself located in - ** the temp database. - */ - if ((zWhere = whereTempTriggers(pParse, pTab)) != "") { - sqlite3NestedParse(pParse, - "UPDATE sqlite_temp_master SET " + - "sql = sqlite_rename_trigger(sql, %Q), " + - "tbl_name = %Q " + - "WHERE %s;", zName, zName, zWhere); - sqlite3DbFree(db, ref zWhere); - } + /* If there are TEMP triggers on this table, modify the sqlite_temp_master +** table. Don't do this if the table being ALTERed is itself located in +** the temp database. +*/ + if ( ( zWhere = whereTempTriggers( pParse, pTab ) ) != "" ) + { + sqlite3NestedParse( pParse, + "UPDATE sqlite_temp_master SET " + + "sql = sqlite_rename_trigger(sql, %Q), " + + "tbl_name = %Q " + + "WHERE %s;", zName, zName, zWhere ); + sqlite3DbFree( db, ref zWhere ); + } #endif #if !(SQLITE_OMIT_FOREIGN_KEY) && !(SQLITE_OMIT_TRIGGER) - if ((db.flags & SQLITE_ForeignKeys) != 0) { - FKey p; - for (p = sqlite3FkReferences(pTab); p != null; p = p.pNextTo) { - Table pFrom = p.pFrom; - if (pFrom != pTab) { - reloadTableSchema(pParse, p.pFrom, pFrom.zName); - } - } - } + if ( ( db.flags & SQLITE_ForeignKeys ) != 0 ) + { + FKey p; + for ( p = sqlite3FkReferences( pTab ); p != null; p = p.pNextTo ) + { + Table pFrom = p.pFrom; + if ( pFrom != pTab ) + { + reloadTableSchema( pParse, p.pFrom, pFrom.zName ); + } + } + } #endif - /* Drop and reload the internal table schema. */ - reloadTableSchema(pParse, pTab, zName); - - exit_rename_table: - sqlite3SrcListDelete(db, ref pSrc); - sqlite3DbFree(db, ref zName); - db.flags = savedDbFlags; - } - - /* - ** Generate code to make sure the file format number is at least minFormat. - ** The generated code will increase the file format number if necessary. - */ - static void sqlite3MinimumFileFormat(Parse pParse, int iDb, int minFormat) { - Vdbe v; - v = sqlite3GetVdbe(pParse); - /* The VDBE should have been allocated before this routine is called. - ** If that allocation failed, we would have quit before reaching this - ** point */ - if (ALWAYS(v)) { - int r1 = sqlite3GetTempReg(pParse); - int r2 = sqlite3GetTempReg(pParse); - int j1; - sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT); - sqlite3VdbeUsesBtree(v, iDb); - sqlite3VdbeAddOp2(v, OP_Integer, minFormat, r2); - j1 = sqlite3VdbeAddOp3(v, OP_Ge, r2, 0, r1); - sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, r2); - sqlite3VdbeJumpHere(v, j1); - sqlite3ReleaseTempReg(pParse, r1); - sqlite3ReleaseTempReg(pParse, r2); - } - } - - /* - ** This function is called after an "ALTER TABLE ... ADD" statement - ** has been parsed. Argument pColDef contains the text of the new - ** column definition. - ** - ** The Table structure pParse.pNewTable was extended to include - ** the new column during parsing. - */ - static void sqlite3AlterFinishAddColumn(Parse pParse, Token pColDef) { - Table pNew; /* Copy of pParse.pNewTable */ - Table pTab; /* Table being altered */ - int iDb; /* Database number */ - string zDb; /* Database name */ - string zTab; /* Table name */ - string zCol; /* Null-terminated column definition */ - Column pCol; /* The new column */ - Expr pDflt; /* Default value for the new column */ - sqlite3 db; /* The database connection; */ - - db = pParse.db; - if (pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) - return; - pNew = pParse.pNewTable; - Debug.Assert(pNew != null); - Debug.Assert(sqlite3BtreeHoldsAllMutexes(db)); - iDb = sqlite3SchemaToIndex(db, pNew.pSchema); - zDb = db.aDb[iDb].zName; - zTab = pNew.zName.Substring(16);// zTab = &pNew->zName[16]; /* Skip the "sqlite_altertab_" prefix on the name */ - pCol = pNew.aCol[pNew.nCol - 1]; - pDflt = pCol.pDflt; - pTab = sqlite3FindTable(db, zTab, zDb); - Debug.Assert(pTab != null); + /* Drop and reload the internal table schema. */ + reloadTableSchema( pParse, pTab, zName ); + +exit_rename_table: + sqlite3SrcListDelete( db, ref pSrc ); + sqlite3DbFree( db, ref zName ); + db.flags = savedDbFlags; +} + +/* +** Generate code to make sure the file format number is at least minFormat. +** The generated code will increase the file format number if necessary. +*/ +static void sqlite3MinimumFileFormat( Parse pParse, int iDb, int minFormat ) +{ + Vdbe v; + v = sqlite3GetVdbe( pParse ); + /* The VDBE should have been allocated before this routine is called. + ** If that allocation failed, we would have quit before reaching this + ** point */ + if ( ALWAYS( v ) ) + { + int r1 = sqlite3GetTempReg( pParse ); + int r2 = sqlite3GetTempReg( pParse ); + int j1; + sqlite3VdbeAddOp3( v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT ); + sqlite3VdbeUsesBtree( v, iDb ); + sqlite3VdbeAddOp2( v, OP_Integer, minFormat, r2 ); + j1 = sqlite3VdbeAddOp3( v, OP_Ge, r2, 0, r1 ); + sqlite3VdbeAddOp3( v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, r2 ); + sqlite3VdbeJumpHere( v, j1 ); + sqlite3ReleaseTempReg( pParse, r1 ); + sqlite3ReleaseTempReg( pParse, r2 ); + } +} + +/* +** This function is called after an "ALTER TABLE ... ADD" statement +** has been parsed. Argument pColDef contains the text of the new +** column definition. +** +** The Table structure pParse.pNewTable was extended to include +** the new column during parsing. +*/ +static void sqlite3AlterFinishAddColumn( Parse pParse, Token pColDef ) +{ + Table pNew; /* Copy of pParse.pNewTable */ + Table pTab; /* Table being altered */ + int iDb; /* Database number */ + string zDb; /* Database name */ + string zTab; /* Table name */ + string zCol; /* Null-terminated column definition */ + Column pCol; /* The new column */ + Expr pDflt; /* Default value for the new column */ + sqlite3 db; /* The database connection; */ + + db = pParse.db; + if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) + return; + pNew = pParse.pNewTable; + Debug.Assert( pNew != null ); + Debug.Assert( sqlite3BtreeHoldsAllMutexes( db ) ); + iDb = sqlite3SchemaToIndex( db, pNew.pSchema ); + zDb = db.aDb[iDb].zName; + zTab = pNew.zName.Substring( 16 );// zTab = &pNew->zName[16]; /* Skip the "sqlite_altertab_" prefix on the name */ + pCol = pNew.aCol[pNew.nCol - 1]; + pDflt = pCol.pDflt; + pTab = sqlite3FindTable( db, zTab, zDb ); + Debug.Assert( pTab != null ); #if !SQLITE_OMIT_AUTHORIZATION /* Invoke the authorization callback. */ @@ -686,179 +742,194 @@ static void sqlite3AlterFinishAddColumn(Parse pParse, Token pColDef) { } #endif - /* If the default value for the new column was specified with a - ** literal NULL, then set pDflt to 0. This simplifies checking - ** for an SQL NULL default below. - */ - if (pDflt != null && pDflt.op == TK_NULL) { - pDflt = null; - } - - /* Check that the new column is not specified as PRIMARY KEY or UNIQUE. - ** If there is a NOT NULL constraint, then the default value for the - ** column must not be NULL. - */ - if (pCol.isPrimKey != 0) { - sqlite3ErrorMsg(pParse, "Cannot add a PRIMARY KEY column"); - return; - } - if (pNew.pIndex != null) { - sqlite3ErrorMsg(pParse, "Cannot add a UNIQUE column"); - return; - } - if ((db.flags & SQLITE_ForeignKeys) != 0 && pNew.pFKey != null && pDflt != null) { - sqlite3ErrorMsg(pParse, - "Cannot add a REFERENCES column with non-NULL default value"); - return; - } - if (pCol.notNull != 0 && pDflt == null) { - sqlite3ErrorMsg(pParse, - "Cannot add a NOT NULL column with default value NULL"); - return; - } - - /* Ensure the default expression is something that sqlite3ValueFromExpr() - ** can handle (i.e. not CURRENT_TIME etc.) - */ - if (pDflt != null) { - sqlite3_value pVal = null; - if (sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, ref pVal) != 0) { - // db.mallocFailed = 1; - return; - } - if (pVal == null) { - sqlite3ErrorMsg(pParse, "Cannot add a column with non-constant default"); - return; - } - sqlite3ValueFree(ref pVal); - } - - /* Modify the CREATE TABLE statement. */ - zCol = pColDef.z.Substring(0, pColDef.n).Replace(";", " ").Trim();//sqlite3DbStrNDup(db, (char*)pColDef.z, pColDef.n); - if (zCol != null) { - // char zEnd = zCol[pColDef.n-1]; - int savedDbFlags = db.flags; - // while( zEnd>zCol && (*zEnd==';' || sqlite3Isspace(*zEnd)) ){ - // zEnd-- = '\0'; - // } - db.flags |= SQLITE_PreferBuiltin; - sqlite3NestedParse(pParse, - "UPDATE \"%w\".%s SET " + - "sql = substr(sql,1,%d) || ', ' || %Q || substr(sql,%d) " + - "WHERE type = 'table' AND name = %Q", - zDb, SCHEMA_TABLE(iDb), pNew.addColOffset, zCol, pNew.addColOffset + 1, - zTab - ); - sqlite3DbFree(db, ref zCol); - db.flags = savedDbFlags; - } - - /* If the default value of the new column is NULL, then set the file - ** format to 2. If the default value of the new column is not NULL, - ** the file format becomes 3. - */ - sqlite3MinimumFileFormat(pParse, iDb, pDflt != null ? 3 : 2); - - /* Reload the schema of the modified table. */ - reloadTableSchema(pParse, pTab, pTab.zName); - } - - /* - ** This function is called by the parser after the table-name in - ** an "ALTER TABLE ADD" statement is parsed. Argument - ** pSrc is the full-name of the table being altered. - ** - ** This routine makes a (partial) copy of the Table structure - ** for the table being altered and sets Parse.pNewTable to point - ** to it. Routines called by the parser as the column definition - ** is parsed (i.e. sqlite3AddColumn()) add the new Column data to - ** the copy. The copy of the Table structure is deleted by tokenize.c - ** after parsing is finished. - ** - ** Routine sqlite3AlterFinishAddColumn() will be called to complete - ** coding the "ALTER TABLE ... ADD" statement. - */ - static void sqlite3AlterBeginAddColumn(Parse pParse, SrcList pSrc) { - Table pNew; - Table pTab; - Vdbe v; - int iDb; - int i; - int nAlloc; - sqlite3 db = pParse.db; - - /* Look up the table being altered. */ - Debug.Assert(pParse.pNewTable == null); - Debug.Assert(sqlite3BtreeHoldsAllMutexes(db)); - // if ( db.mallocFailed != 0 ) goto exit_begin_add_column; - pTab = sqlite3LocateTable(pParse, 0, pSrc.a[0].zName, pSrc.a[0].zDatabase); - if (pTab == null) - goto exit_begin_add_column; - - if (IsVirtual(pTab)) { - sqlite3ErrorMsg(pParse, "virtual tables may not be altered"); - goto exit_begin_add_column; - } - - /* Make sure this is not an attempt to ALTER a view. */ - if (pTab.pSelect != null) { - sqlite3ErrorMsg(pParse, "Cannot add a column to a view"); - goto exit_begin_add_column; - } - if (SQLITE_OK != isSystemTable(pParse, pTab.zName)) { - goto exit_begin_add_column; - } - - Debug.Assert(pTab.addColOffset > 0); - iDb = sqlite3SchemaToIndex(db, pTab.pSchema); - - /* Put a copy of the Table struct in Parse.pNewTable for the - ** sqlite3AddColumn() function and friends to modify. But modify - ** the name by adding an "sqlite_altertab_" prefix. By adding this - ** prefix, we insure that the name will not collide with an existing - ** table because user table are not allowed to have the "sqlite_" - ** prefix on their name. - */ - pNew = new Table();// (Table*)sqlite3DbMallocZero( db, sizeof(Table)) - if (pNew == null) - goto exit_begin_add_column; - pParse.pNewTable = pNew; - pNew.nRef = 1; - pNew.nCol = pTab.nCol; - Debug.Assert(pNew.nCol > 0); - nAlloc = (((pNew.nCol - 1) / 8) * 8) + 8; - Debug.Assert(nAlloc >= pNew.nCol && nAlloc % 8 == 0 && nAlloc - pNew.nCol < 8); - pNew.aCol = new Column[nAlloc];// (Column*)sqlite3DbMallocZero( db, sizeof(Column) * nAlloc ); - pNew.zName = sqlite3MPrintf(db, "sqlite_altertab_%s", pTab.zName); - if (pNew.aCol == null || pNew.zName == null) { - // db.mallocFailed = 1; - goto exit_begin_add_column; - } - // memcpy( pNew.aCol, pTab.aCol, sizeof(Column) * pNew.nCol ); - for (i = 0; i < pNew.nCol; i++) { - Column pCol = pTab.aCol[i].Copy(); - // sqlite3DbStrDup( db, pCol.zName ); - pCol.zColl = null; - pCol.zType = null; - pCol.pDflt = null; - pCol.zDflt = null; - pNew.aCol[i] = pCol; - } - pNew.pSchema = db.aDb[iDb].pSchema; - pNew.addColOffset = pTab.addColOffset; - pNew.nRef = 1; - - /* Begin a transaction and increment the schema cookie. */ - sqlite3BeginWriteOperation(pParse, 0, iDb); - v = sqlite3GetVdbe(pParse); - if (v == null) - goto exit_begin_add_column; - sqlite3ChangeCookie(pParse, iDb); - - exit_begin_add_column: - sqlite3SrcListDelete(db, ref pSrc); - return; - } -#endif // * SQLITE_ALTER_TABLE */ + /* If the default value for the new column was specified with a +** literal NULL, then set pDflt to 0. This simplifies checking +** for an SQL NULL default below. +*/ + if ( pDflt != null && pDflt.op == TK_NULL ) + { + pDflt = null; + } + + /* Check that the new column is not specified as PRIMARY KEY or UNIQUE. + ** If there is a NOT NULL constraint, then the default value for the + ** column must not be NULL. + */ + if ( pCol.isPrimKey != 0 ) + { + sqlite3ErrorMsg( pParse, "Cannot add a PRIMARY KEY column" ); + return; + } + if ( pNew.pIndex != null ) + { + sqlite3ErrorMsg( pParse, "Cannot add a UNIQUE column" ); + return; + } + if ( ( db.flags & SQLITE_ForeignKeys ) != 0 && pNew.pFKey != null && pDflt != null ) + { + sqlite3ErrorMsg( pParse, + "Cannot add a REFERENCES column with non-NULL default value" ); + return; + } + if ( pCol.notNull != 0 && pDflt == null ) + { + sqlite3ErrorMsg( pParse, + "Cannot add a NOT NULL column with default value NULL" ); + return; + } + + /* Ensure the default expression is something that sqlite3ValueFromExpr() + ** can handle (i.e. not CURRENT_TIME etc.) + */ + if ( pDflt != null ) + { + sqlite3_value pVal = null; + if ( sqlite3ValueFromExpr( db, pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, ref pVal ) != 0 ) + { + // db.mallocFailed = 1; + return; + } + if ( pVal == null ) + { + sqlite3ErrorMsg( pParse, "Cannot add a column with non-constant default" ); + return; } + sqlite3ValueFree( ref pVal ); + } + + /* Modify the CREATE TABLE statement. */ + zCol = pColDef.z.Substring( 0, pColDef.n ).Replace( ";", " " ).Trim();//sqlite3DbStrNDup(db, (char*)pColDef.z, pColDef.n); + if ( zCol != null ) + { + // char zEnd = zCol[pColDef.n-1]; + int savedDbFlags = db.flags; + // while( zEnd>zCol && (*zEnd==';' || sqlite3Isspace(*zEnd)) ){ + // zEnd-- = '\0'; + // } + db.flags |= SQLITE_PreferBuiltin; + sqlite3NestedParse( pParse, + "UPDATE \"%w\".%s SET " + + "sql = substr(sql,1,%d) || ', ' || %Q || substr(sql,%d) " + + "WHERE type = 'table' AND name = %Q", + zDb, SCHEMA_TABLE( iDb ), pNew.addColOffset, zCol, pNew.addColOffset + 1, + zTab + ); + sqlite3DbFree( db, ref zCol ); + db.flags = savedDbFlags; + } + + /* If the default value of the new column is NULL, then set the file + ** format to 2. If the default value of the new column is not NULL, + ** the file format becomes 3. + */ + sqlite3MinimumFileFormat( pParse, iDb, pDflt != null ? 3 : 2 ); + + /* Reload the schema of the modified table. */ + reloadTableSchema( pParse, pTab, pTab.zName ); +} + +/* +** This function is called by the parser after the table-name in +** an "ALTER TABLE ADD" statement is parsed. Argument +** pSrc is the full-name of the table being altered. +** +** This routine makes a (partial) copy of the Table structure +** for the table being altered and sets Parse.pNewTable to point +** to it. Routines called by the parser as the column definition +** is parsed (i.e. sqlite3AddColumn()) add the new Column data to +** the copy. The copy of the Table structure is deleted by tokenize.c +** after parsing is finished. +** +** Routine sqlite3AlterFinishAddColumn() will be called to complete +** coding the "ALTER TABLE ... ADD" statement. +*/ +static void sqlite3AlterBeginAddColumn( Parse pParse, SrcList pSrc ) +{ + Table pNew; + Table pTab; + Vdbe v; + int iDb; + int i; + int nAlloc; + sqlite3 db = pParse.db; + + /* Look up the table being altered. */ + Debug.Assert( pParse.pNewTable == null ); + Debug.Assert( sqlite3BtreeHoldsAllMutexes( db ) ); + // if ( db.mallocFailed != 0 ) goto exit_begin_add_column; + pTab = sqlite3LocateTable( pParse, 0, pSrc.a[0].zName, pSrc.a[0].zDatabase ); + if ( pTab == null ) + goto exit_begin_add_column; + + if ( IsVirtual( pTab ) ) + { + sqlite3ErrorMsg( pParse, "virtual tables may not be altered" ); + goto exit_begin_add_column; + } + + /* Make sure this is not an attempt to ALTER a view. */ + if ( pTab.pSelect != null ) + { + sqlite3ErrorMsg( pParse, "Cannot add a column to a view" ); + goto exit_begin_add_column; + } + if ( SQLITE_OK != isSystemTable( pParse, pTab.zName ) ) + { + goto exit_begin_add_column; + } + + Debug.Assert( pTab.addColOffset > 0 ); + iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); + + /* Put a copy of the Table struct in Parse.pNewTable for the + ** sqlite3AddColumn() function and friends to modify. But modify + ** the name by adding an "sqlite_altertab_" prefix. By adding this + ** prefix, we insure that the name will not collide with an existing + ** table because user table are not allowed to have the "sqlite_" + ** prefix on their name. + */ + pNew = new Table();// (Table*)sqlite3DbMallocZero( db, sizeof(Table)) + if ( pNew == null ) + goto exit_begin_add_column; + pParse.pNewTable = pNew; + pNew.nRef = 1; + pNew.nCol = pTab.nCol; + Debug.Assert( pNew.nCol > 0 ); + nAlloc = ( ( ( pNew.nCol - 1 ) / 8 ) * 8 ) + 8; + Debug.Assert( nAlloc >= pNew.nCol && nAlloc % 8 == 0 && nAlloc - pNew.nCol < 8 ); + pNew.aCol = new Column[nAlloc];// (Column*)sqlite3DbMallocZero( db, sizeof(Column) * nAlloc ); + pNew.zName = sqlite3MPrintf( db, "sqlite_altertab_%s", pTab.zName ); + if ( pNew.aCol == null || pNew.zName == null ) + { + // db.mallocFailed = 1; + goto exit_begin_add_column; + } + // memcpy( pNew.aCol, pTab.aCol, sizeof(Column) * pNew.nCol ); + for ( i = 0; i < pNew.nCol; i++ ) + { + Column pCol = pTab.aCol[i].Copy(); + // sqlite3DbStrDup( db, pCol.zName ); + pCol.zColl = null; + pCol.zType = null; + pCol.pDflt = null; + pCol.zDflt = null; + pNew.aCol[i] = pCol; + } + pNew.pSchema = db.aDb[iDb].pSchema; + pNew.addColOffset = pTab.addColOffset; + pNew.nRef = 1; + + /* Begin a transaction and increment the schema cookie. */ + sqlite3BeginWriteOperation( pParse, 0, iDb ); + v = sqlite3GetVdbe( pParse ); + if ( v == null ) + goto exit_begin_add_column; + sqlite3ChangeCookie( pParse, iDb ); + +exit_begin_add_column: + sqlite3SrcListDelete( db, ref pSrc ); + return; +} +#endif // * SQLITE_ALTER_TABLE */ + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/analyze_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/analyze_c.cs index 899ab6392..23d5cd4ce 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/analyze_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/analyze_c.cs @@ -1,152 +1,168 @@ using System; using System.Diagnostics; +using System.Text; using u8 = System.Byte; -namespace Community.CsharpSqlite { - using sqlite3_int64 = System.Int64; +namespace Community.CsharpSqlite +{ + using sqlite3_int64 = System.Int64; + using sqlite3_stmt = Sqlite3.Vdbe; - public partial class Sqlite3 { - /* - ** 2005 July 8 - ** - ** 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 contains code associated with the ANALYZE command. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ + public partial class Sqlite3 + { +/* +** 2005 July 8 +** +** 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 contains code associated with the ANALYZE command. +************************************************************************* +** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart +** C#-SQLite is an independent reimplementation of the SQLite software library +** +** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e +** +************************************************************************* +*/ #if !SQLITE_OMIT_ANALYZE - //#include "sqliteInt.h" - - /* - ** This routine generates code that opens the sqlite_stat1 table for - ** writing with cursor iStatCur. If the library was built with the - ** SQLITE_ENABLE_STAT2 macro defined, then the sqlite_stat2 table is - ** opened for writing using cursor (iStatCur+1) - ** - ** If the sqlite_stat1 tables does not previously exist, it is created. - ** Similarly, if the sqlite_stat2 table does not exist and the library - ** is compiled with SQLITE_ENABLE_STAT2 defined, it is created. - ** - ** Argument zWhere may be a pointer to a buffer containing a table name, - ** or it may be a NULL pointer. If it is not NULL, then all entries in - ** the sqlite_stat1 and (if applicable) sqlite_stat2 tables associated - ** with the named table are deleted. If zWhere==0, then code is generated - ** to delete all stat table entries. - */ - public struct _aTable { - public string zName; - public string zCols; - public _aTable(string zName, string zCols) { - this.zName = zName; - this.zCols = zCols; - } - }; - static _aTable[] aTable = new _aTable[]{ +//#include "sqliteInt.h" + +/* +** This routine generates code that opens the sqlite_stat1 table for +** writing with cursor iStatCur. If the library was built with the +** SQLITE_ENABLE_STAT2 macro defined, then the sqlite_stat2 table is +** opened for writing using cursor (iStatCur+1) +** +** If the sqlite_stat1 tables does not previously exist, it is created. +** Similarly, if the sqlite_stat2 table does not exist and the library +** is compiled with SQLITE_ENABLE_STAT2 defined, it is created. +** +** Argument zWhere may be a pointer to a buffer containing a table name, +** or it may be a NULL pointer. If it is not NULL, then all entries in +** the sqlite_stat1 and (if applicable) sqlite_stat2 tables associated +** with the named table are deleted. If zWhere==0, then code is generated +** to delete all stat table entries. +*/ +public struct _aTable +{ + public string zName; + public string zCols; + public _aTable( string zName, string zCols ) + { + this.zName = zName; + this.zCols = zCols; + } +}; +static _aTable[] aTable = new _aTable[]{ new _aTable( "sqlite_stat1", "tbl,idx,stat" ), #if SQLITE_ENABLE_STAT2 new _aTable( "sqlite_stat2", "tbl,idx,sampleno,sample" ), #endif }; - static void openStatTable( - Parse pParse, /* Parsing context */ - int iDb, /* The database we are looking in */ - int iStatCur, /* Open the sqlite_stat1 table on this cursor */ - string zWhere, /* Delete entries for this table or index */ - string zWhereType /* Either "tbl" or "idx" */ - ) { - int[] aRoot = new int[] { 0, 0 }; - u8[] aCreateTbl = new u8[] { 0, 0 }; - - int i; - sqlite3 db = pParse.db; - Db pDb; - Vdbe v = sqlite3GetVdbe(pParse); - - if (v == null) - return; - Debug.Assert(sqlite3BtreeHoldsAllMutexes(db)); - Debug.Assert(sqlite3VdbeDb(v) == db); - pDb = db.aDb[iDb]; - - for (i = 0; i < ArraySize(aTable); i++) { - string zTab = aTable[i].zName; - Table pStat; - if ((pStat = sqlite3FindTable(db, zTab, pDb.zName)) == null) { - /* The sqlite_stat[12] table does not exist. Create it. Note that a - ** side-effect of the CREATE TABLE statement is to leave the rootpage - ** of the new table in register pParse.regRoot. This is important - ** because the OpenWrite opcode below will be needing it. */ - sqlite3NestedParse(pParse, - "CREATE TABLE %Q.%s(%s)", pDb.zName, zTab, aTable[i].zCols - ); - aRoot[i] = pParse.regRoot; - aCreateTbl[i] = 1; - } else { - /* The table already exists. If zWhere is not NULL, delete all entries - ** associated with the table zWhere. If zWhere is NULL, delete the - ** entire contents of the table. */ - aRoot[i] = pStat.tnum; - sqlite3TableLock(pParse, iDb, aRoot[i], 1, zTab); - if (!String.IsNullOrEmpty(zWhere)) { - sqlite3NestedParse(pParse, - "DELETE FROM %Q.%s WHERE %s=%Q", pDb.zName, zTab, zWhereType, zWhere - ); - } else { - /* The sqlite_stat[12] table already exists. Delete all rows. */ - sqlite3VdbeAddOp2(v, OP_Clear, aRoot[i], iDb); - } - } - } +static void openStatTable( +Parse pParse, /* Parsing context */ +int iDb, /* The database we are looking in */ +int iStatCur, /* Open the sqlite_stat1 table on this cursor */ +string zWhere, /* Delete entries for this table or index */ +string zWhereType /* Either "tbl" or "idx" */ +) +{ + int[] aRoot = new int[] { 0, 0 }; + u8[] aCreateTbl = new u8[] { 0, 0 }; + + int i; + sqlite3 db = pParse.db; + Db pDb; + Vdbe v = sqlite3GetVdbe( pParse ); + + if ( v == null ) + return; + Debug.Assert( sqlite3BtreeHoldsAllMutexes( db ) ); + Debug.Assert( sqlite3VdbeDb( v ) == db ); + pDb = db.aDb[iDb]; + + for ( i = 0; i < ArraySize( aTable ); i++ ) + { + string zTab = aTable[i].zName; + Table pStat; + if ( ( pStat = sqlite3FindTable( db, zTab, pDb.zName ) ) == null ) + { + /* The sqlite_stat[12] table does not exist. Create it. Note that a + ** side-effect of the CREATE TABLE statement is to leave the rootpage + ** of the new table in register pParse.regRoot. This is important + ** because the OpenWrite opcode below will be needing it. */ + sqlite3NestedParse( pParse, + "CREATE TABLE %Q.%s(%s)", pDb.zName, zTab, aTable[i].zCols + ); + aRoot[i] = pParse.regRoot; + aCreateTbl[i] = 1; + } + else + { + /* The table already exists. If zWhere is not NULL, delete all entries + ** associated with the table zWhere. If zWhere is NULL, delete the + ** entire contents of the table. */ + aRoot[i] = pStat.tnum; + sqlite3TableLock( pParse, iDb, aRoot[i], 1, zTab ); + if ( !String.IsNullOrEmpty( zWhere ) ) + { + sqlite3NestedParse( pParse, + "DELETE FROM %Q.%s WHERE %s=%Q", pDb.zName, zTab, zWhereType, zWhere + ); + } + else + { + /* The sqlite_stat[12] table already exists. Delete all rows. */ + sqlite3VdbeAddOp2( v, OP_Clear, aRoot[i], iDb ); + } + } + } - /* Open the sqlite_stat[12] tables for writing. */ - for (i = 0; i < ArraySize(aTable); i++) { - sqlite3VdbeAddOp3(v, OP_OpenWrite, iStatCur + i, aRoot[i], iDb); - sqlite3VdbeChangeP4(v, -1, 3, P4_INT32); - sqlite3VdbeChangeP5(v, aCreateTbl[i]); - } - } + /* Open the sqlite_stat[12] tables for writing. */ + for ( i = 0; i < ArraySize( aTable ); i++ ) + { + sqlite3VdbeAddOp3( v, OP_OpenWrite, iStatCur + i, aRoot[i], iDb ); + sqlite3VdbeChangeP4( v, -1, 3, P4_INT32 ); + sqlite3VdbeChangeP5( v, aCreateTbl[i] ); + } +} - /* - ** Generate code to do an analysis of all indices associated with - ** a single table. - */ - static void analyzeOneTable( - Parse pParse, /* Parser context */ - Table pTab, /* Table whose indices are to be analyzed */ - Index pOnlyIdx, /* If not NULL, only analyze this one index */ - int iStatCur, /* Index of VdbeCursor that writes the sqlite_stat1 table */ - int iMem /* Available memory locations begin here */ - ) { - sqlite3 db = pParse.db; /* Database handle */ - Index pIdx; /* An index to being analyzed */ - int iIdxCur; /* Cursor open on index being analyzed */ - Vdbe v; /* The virtual machine being built up */ - int i; /* Loop counter */ - int topOfLoop; /* The top of the loop */ - int endOfLoop; /* The end of the loop */ - int jZeroRows = -1; /* Jump from here if number of rows is zero */ - int iDb; /* Index of database containing pTab */ - int regTabname = iMem++; /* Register containing table name */ - int regIdxname = iMem++; /* Register containing index name */ - int regSampleno = iMem++; /* Register containing next sample number */ - int regCol = iMem++; /* Content of a column analyzed table */ - int regRec = iMem++; /* Register holding completed record */ - int regTemp = iMem++; /* Temporary use register */ - int regRowid = iMem++; /* Rowid for the inserted record */ +/* +** Generate code to do an analysis of all indices associated with +** a single table. +*/ +static void analyzeOneTable( +Parse pParse, /* Parser context */ +Table pTab, /* Table whose indices are to be analyzed */ +Index pOnlyIdx, /* If not NULL, only analyze this one index */ +int iStatCur, /* Index of VdbeCursor that writes the sqlite_stat1 table */ +int iMem /* Available memory locations begin here */ +) +{ + sqlite3 db = pParse.db; /* Database handle */ + Index pIdx; /* An index to being analyzed */ + int iIdxCur; /* Cursor open on index being analyzed */ + Vdbe v; /* The virtual machine being built up */ + int i; /* Loop counter */ + int topOfLoop; /* The top of the loop */ + int endOfLoop; /* The end of the loop */ + int jZeroRows = -1; /* Jump from here if number of rows is zero */ + int iDb; /* Index of database containing pTab */ + int regTabname = iMem++; /* Register containing table name */ + int regIdxname = iMem++; /* Register containing index name */ + int regSampleno = iMem++; /* Register containing next sample number */ + int regCol = iMem++; /* Content of a column analyzed table */ + int regRec = iMem++; /* Register holding completed record */ + int regTemp = iMem++; /* Temporary use register */ + int regRowid = iMem++; /* Rowid for the inserted record */ #if SQLITE_ENABLE_STAT2 int addr = 0; /* Instruction address */ @@ -157,22 +173,25 @@ int iMem /* Available memory locations begin here */ int regFirst = iMem++; /* Index of first sample to record */ #endif - v = sqlite3GetVdbe(pParse); - if (v == null || NEVER(pTab == null)) { - return; - } - if (pTab.tnum == 0) { - /* Do not gather statistics on views or virtual tables */ - return; - } - if (pTab.zName.StartsWith("sqlite_", StringComparison.OrdinalIgnoreCase)) { - /* Do not gather statistics on system tables */ - return; - } - Debug.Assert(sqlite3BtreeHoldsAllMutexes(db)); - iDb = sqlite3SchemaToIndex(db, pTab.pSchema); - Debug.Assert(iDb >= 0); - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); + v = sqlite3GetVdbe( pParse ); + if ( v == null || NEVER( pTab == null ) ) + { + return; + } + if ( pTab.tnum == 0 ) + { + /* Do not gather statistics on views or virtual tables */ + return; + } + if ( pTab.zName.StartsWith( "sqlite_", StringComparison.OrdinalIgnoreCase ) ) + { + /* Do not gather statistics on system tables */ + return; + } + Debug.Assert( sqlite3BtreeHoldsAllMutexes( db ) ); + iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); + Debug.Assert( iDb >= 0 ); + Debug.Assert( sqlite3SchemaMutexHeld(db, iDb, null) ); #if !SQLITE_OMIT_AUTHORIZATION if( sqlite3AuthCheck(pParse, SQLITE_ANALYZE, pTab.zName, 0, db.aDb[iDb].zName ) ){ @@ -180,31 +199,33 @@ int iMem /* Available memory locations begin here */ } #endif - /* Establish a read-lock on the table at the shared-cache level. */ - sqlite3TableLock(pParse, iDb, pTab.tnum, 0, pTab.zName); - - iIdxCur = pParse.nTab++; - sqlite3VdbeAddOp4(v, OP_String8, 0, regTabname, 0, pTab.zName, 0); - for (pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext) { - int nCol; - KeyInfo pKey; - if (pOnlyIdx != null && pOnlyIdx != pIdx) - continue; - nCol = pIdx.nColumn; - pKey = sqlite3IndexKeyinfo(pParse, pIdx); - - if (iMem + 1 + (nCol * 2) > pParse.nMem) { - pParse.nMem = iMem + 1 + (nCol * 2); - } + /* Establish a read-lock on the table at the shared-cache level. */ + sqlite3TableLock( pParse, iDb, pTab.tnum, 0, pTab.zName ); + + iIdxCur = pParse.nTab++; + sqlite3VdbeAddOp4( v, OP_String8, 0, regTabname, 0, pTab.zName, 0 ); + for ( pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext ) + { + int nCol; + KeyInfo pKey; + if ( pOnlyIdx != null && pOnlyIdx != pIdx ) + continue; + nCol = pIdx.nColumn; + pKey = sqlite3IndexKeyinfo( pParse, pIdx ); + + if ( iMem + 1 + ( nCol * 2 ) > pParse.nMem ) + { + pParse.nMem = iMem + 1 + ( nCol * 2 ); + } - /* Open a cursor to the index to be analyzed. */ - Debug.Assert(iDb == sqlite3SchemaToIndex(db, pIdx.pSchema)); - sqlite3VdbeAddOp4(v, OP_OpenRead, iIdxCur, pIdx.tnum, iDb, - pKey, P4_KEYINFO_HANDOFF); - VdbeComment(v, "%s", pIdx.zName); + /* Open a cursor to the index to be analyzed. */ + Debug.Assert( iDb == sqlite3SchemaToIndex( db, pIdx.pSchema ) ); + sqlite3VdbeAddOp4( v, OP_OpenRead, iIdxCur, pIdx.tnum, iDb, + pKey, P4_KEYINFO_HANDOFF ); + VdbeComment( v, "%s", pIdx.zName ); - /* Populate the registers containing the index names. */ - sqlite3VdbeAddOp4(v, OP_String8, 0, regIdxname, 0, pIdx.zName, 0); + /* Populate the registers containing the index names. */ + sqlite3VdbeAddOp4( v, OP_String8, 0, regIdxname, 0, pIdx.zName, 0 ); #if SQLITE_ENABLE_STAT2 @@ -233,40 +254,44 @@ int iMem /* Available memory locations begin here */ sqlite3VdbeAddOp2( v, OP_Copy, regFirst, regSamplerecno ); #endif - /* The block of memory cells initialized here is used as follows. - ** - ** iMem: - ** The total number of rows in the table. - ** - ** iMem+1 .. iMem+nCol: - ** Number of distinct entries in index considering the - ** left-most N columns only, where N is between 1 and nCol, - ** inclusive. - ** - ** iMem+nCol+1 .. Mem+2*nCol: - ** Previous value of indexed columns, from left to right. - ** - ** Cells iMem through iMem+nCol are initialized to 0. The others are - ** initialized to contain an SQL NULL. - */ - for (i = 0; i <= nCol; i++) { - sqlite3VdbeAddOp2(v, OP_Integer, 0, iMem + i); - } - for (i = 0; i < nCol; i++) { - sqlite3VdbeAddOp2(v, OP_Null, 0, iMem + nCol + i + 1); - } + /* The block of memory cells initialized here is used as follows. +** +** iMem: +** The total number of rows in the table. +** +** iMem+1 .. iMem+nCol: +** Number of distinct entries in index considering the +** left-most N columns only, where N is between 1 and nCol, +** inclusive. +** +** iMem+nCol+1 .. Mem+2*nCol: +** Previous value of indexed columns, from left to right. +** +** Cells iMem through iMem+nCol are initialized to 0. The others are +** initialized to contain an SQL NULL. +*/ + for ( i = 0; i <= nCol; i++ ) + { + sqlite3VdbeAddOp2( v, OP_Integer, 0, iMem + i ); + } + for ( i = 0; i < nCol; i++ ) + { + sqlite3VdbeAddOp2( v, OP_Null, 0, iMem + nCol + i + 1 ); + } - /* Start the analysis loop. This loop runs through all the entries in - ** the index b-tree. */ - endOfLoop = sqlite3VdbeMakeLabel(v); - sqlite3VdbeAddOp2(v, OP_Rewind, iIdxCur, endOfLoop); - topOfLoop = sqlite3VdbeCurrentAddr(v); - sqlite3VdbeAddOp2(v, OP_AddImm, iMem, 1); - - for (i = 0; i < nCol; i++) { - sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, regCol); - CollSeq pColl; - if (i == 0) { + /* Start the analysis loop. This loop runs through all the entries in + ** the index b-tree. */ + endOfLoop = sqlite3VdbeMakeLabel( v ); + sqlite3VdbeAddOp2( v, OP_Rewind, iIdxCur, endOfLoop ); + topOfLoop = sqlite3VdbeCurrentAddr( v ); + sqlite3VdbeAddOp2( v, OP_AddImm, iMem, 1 ); + + for ( i = 0; i < nCol; i++ ) + { + sqlite3VdbeAddOp3( v, OP_Column, iIdxCur, i, regCol ); + CollSeq pColl; + if ( i == 0 ) + { #if SQLITE_ENABLE_STAT2 /* Check if the record that cursor iIdxCur points to contains a ** value that should be stored in the sqlite_stat2 table. If so, @@ -298,307 +323,353 @@ int iMem /* Available memory locations begin here */ sqlite3VdbeAddOp2( v, OP_AddImm, regRecno, 1 ); #endif - /* Always record the very first row */ - sqlite3VdbeAddOp1(v, OP_IfNot, iMem + 1); - } - Debug.Assert(pIdx.azColl != null); - Debug.Assert(pIdx.azColl[i] != null); - pColl = sqlite3LocateCollSeq(pParse, pIdx.azColl[i]); - sqlite3VdbeAddOp4(v, OP_Ne, regCol, 0, iMem + nCol + i + 1, - pColl, P4_COLLSEQ); - sqlite3VdbeChangeP5(v, SQLITE_NULLEQ); - } - //if( db.mallocFailed ){ - // /* If a malloc failure has occurred, then the result of the expression - // ** passed as the second argument to the call to sqlite3VdbeJumpHere() - // ** below may be negative. Which causes an Debug.Assert() to fail (or an - // ** out-of-bounds write if SQLITE_DEBUG is not defined). */ - // return; - //} - sqlite3VdbeAddOp2(v, OP_Goto, 0, endOfLoop); - for (i = 0; i < nCol; i++) { - int addr2 = sqlite3VdbeCurrentAddr(v) - (nCol * 2); - if (i == 0) { - sqlite3VdbeJumpHere(v, addr2 - 1); /* Set jump dest for the OP_IfNot */ - } - sqlite3VdbeJumpHere(v, addr2); /* Set jump dest for the OP_Ne */ - sqlite3VdbeAddOp2(v, OP_AddImm, iMem + i + 1, 1); - sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, iMem + nCol + i + 1); - } + /* Always record the very first row */ + sqlite3VdbeAddOp1( v, OP_IfNot, iMem + 1 ); + } + Debug.Assert( pIdx.azColl != null ); + Debug.Assert( pIdx.azColl[i] != null ); + pColl = sqlite3LocateCollSeq( pParse, pIdx.azColl[i] ); + sqlite3VdbeAddOp4( v, OP_Ne, regCol, 0, iMem + nCol + i + 1, + pColl, P4_COLLSEQ ); + sqlite3VdbeChangeP5( v, SQLITE_NULLEQ ); + } + //if( db.mallocFailed ){ + // /* If a malloc failure has occurred, then the result of the expression + // ** passed as the second argument to the call to sqlite3VdbeJumpHere() + // ** below may be negative. Which causes an Debug.Assert() to fail (or an + // ** out-of-bounds write if SQLITE_DEBUG is not defined). */ + // return; + //} + sqlite3VdbeAddOp2( v, OP_Goto, 0, endOfLoop ); + for ( i = 0; i < nCol; i++ ) + { + int addr2 = sqlite3VdbeCurrentAddr( v ) - ( nCol * 2 ); + if ( i == 0 ) + { + sqlite3VdbeJumpHere( v, addr2 - 1 ); /* Set jump dest for the OP_IfNot */ + } + sqlite3VdbeJumpHere( v, addr2 ); /* Set jump dest for the OP_Ne */ + sqlite3VdbeAddOp2( v, OP_AddImm, iMem + i + 1, 1 ); + sqlite3VdbeAddOp3( v, OP_Column, iIdxCur, i, iMem + nCol + i + 1 ); + } - /* End of the analysis loop. */ - sqlite3VdbeResolveLabel(v, endOfLoop); - sqlite3VdbeAddOp2(v, OP_Next, iIdxCur, topOfLoop); - sqlite3VdbeAddOp1(v, OP_Close, iIdxCur); - - /* Store the results in sqlite_stat1. - ** - ** The result is a single row of the sqlite_stat1 table. The first - ** two columns are the names of the table and index. The third column - ** is a string composed of a list of integer statistics about the - ** index. The first integer in the list is the total number of entries - ** in the index. There is one additional integer in the list for each - ** column of the table. This additional integer is a guess of how many - ** rows of the table the index will select. If D is the count of distinct - ** values and K is the total number of rows, then the integer is computed - ** as: - ** - ** I = (K+D-1)/D - ** - ** If K==0 then no entry is made into the sqlite_stat1 table. - ** If K>0 then it is always the case the D>0 so division by zero - ** is never possible. - */ - sqlite3VdbeAddOp2(v, OP_SCopy, iMem, regSampleno); - if (jZeroRows < 0) { - jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem); - } - for (i = 0; i < nCol; i++) { - sqlite3VdbeAddOp4(v, OP_String8, 0, regTemp, 0, " ", 0); - sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regSampleno, regSampleno); - sqlite3VdbeAddOp3(v, OP_Add, iMem, iMem + i + 1, regTemp); - sqlite3VdbeAddOp2(v, OP_AddImm, regTemp, -1); - sqlite3VdbeAddOp3(v, OP_Divide, iMem + i + 1, regTemp, regTemp); - sqlite3VdbeAddOp1(v, OP_ToInt, regTemp); - sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regSampleno, regSampleno); - } - sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0); - sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regRowid); - sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regRowid); - sqlite3VdbeChangeP5(v, OPFLAG_APPEND); - } + /* End of the analysis loop. */ + sqlite3VdbeResolveLabel( v, endOfLoop ); + sqlite3VdbeAddOp2( v, OP_Next, iIdxCur, topOfLoop ); + sqlite3VdbeAddOp1( v, OP_Close, iIdxCur ); + + /* Store the results in sqlite_stat1. + ** + ** The result is a single row of the sqlite_stat1 table. The first + ** two columns are the names of the table and index. The third column + ** is a string composed of a list of integer statistics about the + ** index. The first integer in the list is the total number of entries + ** in the index. There is one additional integer in the list for each + ** column of the table. This additional integer is a guess of how many + ** rows of the table the index will select. If D is the count of distinct + ** values and K is the total number of rows, then the integer is computed + ** as: + ** + ** I = (K+D-1)/D + ** + ** If K==0 then no entry is made into the sqlite_stat1 table. + ** If K>0 then it is always the case the D>0 so division by zero + ** is never possible. + */ + sqlite3VdbeAddOp2( v, OP_SCopy, iMem, regSampleno ); + if ( jZeroRows < 0 ) + { + jZeroRows = sqlite3VdbeAddOp1( v, OP_IfNot, iMem ); + } + for ( i = 0; i < nCol; i++ ) + { + sqlite3VdbeAddOp4( v, OP_String8, 0, regTemp, 0, " ", 0 ); + sqlite3VdbeAddOp3( v, OP_Concat, regTemp, regSampleno, regSampleno ); + sqlite3VdbeAddOp3( v, OP_Add, iMem, iMem + i + 1, regTemp ); + sqlite3VdbeAddOp2( v, OP_AddImm, regTemp, -1 ); + sqlite3VdbeAddOp3( v, OP_Divide, iMem + i + 1, regTemp, regTemp ); + sqlite3VdbeAddOp1( v, OP_ToInt, regTemp ); + sqlite3VdbeAddOp3( v, OP_Concat, regTemp, regSampleno, regSampleno ); + } + sqlite3VdbeAddOp4( v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0 ); + sqlite3VdbeAddOp2( v, OP_NewRowid, iStatCur, regRowid ); + sqlite3VdbeAddOp3( v, OP_Insert, iStatCur, regRec, regRowid ); + sqlite3VdbeChangeP5( v, OPFLAG_APPEND ); + } - /* If the table has no indices, create a single sqlite_stat1 entry - ** containing NULL as the index name and the row count as the content. - */ - if (pTab.pIndex == null) { - sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pTab.tnum, iDb); - VdbeComment(v, "%s", pTab.zName); - sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regSampleno); - sqlite3VdbeAddOp1(v, OP_Close, iIdxCur); - jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regSampleno); - } else { - sqlite3VdbeJumpHere(v, jZeroRows); - jZeroRows = sqlite3VdbeAddOp0(v, OP_Goto); - } - sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname); - sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0); - sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regRowid); - sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regRowid); - sqlite3VdbeChangeP5(v, OPFLAG_APPEND); - if (pParse.nMem < regRec) - pParse.nMem = regRec; - sqlite3VdbeJumpHere(v, jZeroRows); - } + /* If the table has no indices, create a single sqlite_stat1 entry + ** containing NULL as the index name and the row count as the content. + */ + if ( pTab.pIndex == null ) + { + sqlite3VdbeAddOp3( v, OP_OpenRead, iIdxCur, pTab.tnum, iDb ); + VdbeComment( v, "%s", pTab.zName ); + sqlite3VdbeAddOp2( v, OP_Count, iIdxCur, regSampleno ); + sqlite3VdbeAddOp1( v, OP_Close, iIdxCur ); + jZeroRows = sqlite3VdbeAddOp1( v, OP_IfNot, regSampleno ); + } + else + { + sqlite3VdbeJumpHere( v, jZeroRows ); + jZeroRows = sqlite3VdbeAddOp0( v, OP_Goto ); + } + sqlite3VdbeAddOp2( v, OP_Null, 0, regIdxname ); + sqlite3VdbeAddOp4( v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0 ); + sqlite3VdbeAddOp2( v, OP_NewRowid, iStatCur, regRowid ); + sqlite3VdbeAddOp3( v, OP_Insert, iStatCur, regRec, regRowid ); + sqlite3VdbeChangeP5( v, OPFLAG_APPEND ); + if ( pParse.nMem < regRec ) + pParse.nMem = regRec; + sqlite3VdbeJumpHere( v, jZeroRows ); +} - /* - ** Generate code that will cause the most recent index analysis to - ** be loaded into internal hash tables where is can be used. - */ - static void loadAnalysis(Parse pParse, int iDb) { - Vdbe v = sqlite3GetVdbe(pParse); - if (v != null) { - sqlite3VdbeAddOp1(v, OP_LoadAnalysis, iDb); - } - } +/* +** Generate code that will cause the most recent index analysis to +** be loaded into internal hash tables where is can be used. +*/ +static void loadAnalysis( Parse pParse, int iDb ) +{ + Vdbe v = sqlite3GetVdbe( pParse ); + if ( v != null ) + { + sqlite3VdbeAddOp1( v, OP_LoadAnalysis, iDb ); + } +} - /* - ** Generate code that will do an analysis of an entire database - */ - static void analyzeDatabase(Parse pParse, int iDb) { - sqlite3 db = pParse.db; - Schema pSchema = db.aDb[iDb].pSchema; /* Schema of database iDb */ - HashElem k; - int iStatCur; - int iMem; - - sqlite3BeginWriteOperation(pParse, 0, iDb); - iStatCur = pParse.nTab; - pParse.nTab += 2; - openStatTable(pParse, iDb, iStatCur, null, null); - iMem = pParse.nMem + 1; - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); - //for(k=sqliteHashFirst(pSchema.tblHash); k; k=sqliteHashNext(k)){ - for (k = pSchema.tblHash.first; k != null; k = k.next) { - Table pTab = (Table)k.data;// sqliteHashData( k ); - analyzeOneTable(pParse, pTab, null, iStatCur, iMem); - } - loadAnalysis(pParse, iDb); - } +/* +** Generate code that will do an analysis of an entire database +*/ +static void analyzeDatabase( Parse pParse, int iDb ) +{ + sqlite3 db = pParse.db; + Schema pSchema = db.aDb[iDb].pSchema; /* Schema of database iDb */ + HashElem k; + int iStatCur; + int iMem; + + sqlite3BeginWriteOperation( pParse, 0, iDb ); + iStatCur = pParse.nTab; + pParse.nTab += 2; + openStatTable( pParse, iDb, iStatCur, null, null ); + iMem = pParse.nMem + 1; + Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); + //for(k=sqliteHashFirst(pSchema.tblHash); k; k=sqliteHashNext(k)){ + for ( k = pSchema.tblHash.first; k != null; k = k.next ) + { + Table pTab = (Table)k.data;// sqliteHashData( k ); + analyzeOneTable( pParse, pTab, null, iStatCur, iMem ); + } + loadAnalysis( pParse, iDb ); +} - /* - ** Generate code that will do an analysis of a single table in - ** a database. If pOnlyIdx is not NULL then it is a single index - ** in pTab that should be analyzed. - */ - static void analyzeTable(Parse pParse, Table pTab, Index pOnlyIdx) { - int iDb; - int iStatCur; - - Debug.Assert(pTab != null); - Debug.Assert(sqlite3BtreeHoldsAllMutexes(pParse.db)); - iDb = sqlite3SchemaToIndex(pParse.db, pTab.pSchema); - sqlite3BeginWriteOperation(pParse, 0, iDb); - iStatCur = pParse.nTab; - pParse.nTab += 2; - if (pOnlyIdx != null) { - openStatTable(pParse, iDb, iStatCur, pOnlyIdx.zName, "idx"); - } else { - openStatTable(pParse, iDb, iStatCur, pTab.zName, "tbl"); - } - analyzeOneTable(pParse, pTab, pOnlyIdx, iStatCur, pParse.nMem + 1); - loadAnalysis(pParse, iDb); - } +/* +** Generate code that will do an analysis of a single table in +** a database. If pOnlyIdx is not NULL then it is a single index +** in pTab that should be analyzed. +*/ +static void analyzeTable( Parse pParse, Table pTab, Index pOnlyIdx) +{ + int iDb; + int iStatCur; + + Debug.Assert( pTab != null ); + Debug.Assert( sqlite3BtreeHoldsAllMutexes( pParse.db ) ); + iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema ); + sqlite3BeginWriteOperation( pParse, 0, iDb ); + iStatCur = pParse.nTab; + pParse.nTab += 2; + if ( pOnlyIdx != null ) + { + openStatTable( pParse, iDb, iStatCur, pOnlyIdx.zName, "idx" ); + } + else + { + openStatTable( pParse, iDb, iStatCur, pTab.zName, "tbl" ); + } + analyzeOneTable( pParse, pTab, pOnlyIdx, iStatCur, pParse.nMem + 1 ); + loadAnalysis( pParse, iDb ); +} - /* - ** Generate code for the ANALYZE command. The parser calls this routine - ** when it recognizes an ANALYZE command. - ** - ** ANALYZE -- 1 - ** ANALYZE -- 2 - ** ANALYZE ?.? -- 3 - ** - ** Form 1 causes all indices in all attached databases to be analyzed. - ** Form 2 analyzes all indices the single database named. - ** Form 3 analyzes all indices associated with the named table. - */ - // OVERLOADS, so I don't need to rewrite parse.c - static void sqlite3Analyze(Parse pParse, int null_2, int null_3) { - sqlite3Analyze(pParse, null, null); - } - static void sqlite3Analyze(Parse pParse, Token pName1, Token pName2) { - sqlite3 db = pParse.db; - int iDb; - int i; - string z, zDb; - Table pTab; - Index pIdx; - Token pTableName = null; - - /* Read the database schema. If an error occurs, leave an error message - ** and code in pParse and return NULL. */ - Debug.Assert(sqlite3BtreeHoldsAllMutexes(pParse.db)); - if (SQLITE_OK != sqlite3ReadSchema(pParse)) { - return; - } +/* +** Generate code for the ANALYZE command. The parser calls this routine +** when it recognizes an ANALYZE command. +** +** ANALYZE -- 1 +** ANALYZE -- 2 +** ANALYZE ?.? -- 3 +** +** Form 1 causes all indices in all attached databases to be analyzed. +** Form 2 analyzes all indices the single database named. +** Form 3 analyzes all indices associated with the named table. +*/ +// OVERLOADS, so I don't need to rewrite parse.c +static void sqlite3Analyze( Parse pParse, int null_2, int null_3 ) +{ + sqlite3Analyze( pParse, null, null ); +} +static void sqlite3Analyze( Parse pParse, Token pName1, Token pName2 ) +{ + sqlite3 db = pParse.db; + int iDb; + int i; + string z, zDb; + Table pTab; + Index pIdx; + Token pTableName = null; + + /* Read the database schema. If an error occurs, leave an error message + ** and code in pParse and return NULL. */ + Debug.Assert( sqlite3BtreeHoldsAllMutexes( pParse.db ) ); + if ( SQLITE_OK != sqlite3ReadSchema( pParse ) ) + { + return; + } - Debug.Assert(pName2 != null || pName1 == null); - if (pName1 == null) { - /* Form 1: Analyze everything */ - for (i = 0; i < db.nDb; i++) { - if (i == 1) - continue; /* Do not analyze the TEMP database */ - analyzeDatabase(pParse, i); - } - } else if (pName2.n == 0) { - /* Form 2: Analyze the database or table named */ - iDb = sqlite3FindDb(db, pName1); - if (iDb >= 0) { - analyzeDatabase(pParse, iDb); - } else { - z = sqlite3NameFromToken(db, pName1); - if (z != null) { - if ((pIdx = sqlite3FindIndex(db, z, null)) != null) { - analyzeTable(pParse, pIdx.pTable, pIdx); - } else if ((pTab = sqlite3LocateTable(pParse, 0, z, null)) != null) { - analyzeTable(pParse, pTab, null); - } - z = null;//sqlite3DbFree( db, z ); - } - } - } else { - /* Form 3: Analyze the fully qualified table name */ - iDb = sqlite3TwoPartName(pParse, pName1, pName2, ref pTableName); - if (iDb >= 0) { - zDb = db.aDb[iDb].zName; - z = sqlite3NameFromToken(db, pTableName); - if (z != null) { - if ((pIdx = sqlite3FindIndex(db, z, zDb)) != null) { - analyzeTable(pParse, pIdx.pTable, pIdx); - } else if ((pTab = sqlite3LocateTable(pParse, 0, z, zDb)) != null) { - analyzeTable(pParse, pTab, null); - } - z = null; //sqlite3DbFree( db, z ); - } - } - } + Debug.Assert( pName2 != null || pName1 == null ); + if ( pName1 == null ) + { + /* Form 1: Analyze everything */ + for ( i = 0; i < db.nDb; i++ ) + { + if ( i == 1 ) + continue; /* Do not analyze the TEMP database */ + analyzeDatabase( pParse, i ); + } + } + else if ( pName2.n == 0 ) + { + /* Form 2: Analyze the database or table named */ + iDb = sqlite3FindDb( db, pName1 ); + if ( iDb >= 0 ) + { + analyzeDatabase( pParse, iDb ); + } + else + { + z = sqlite3NameFromToken( db, pName1 ); + if ( z != null ) + { + if ( ( pIdx = sqlite3FindIndex( db, z, null ) ) != null ) + { + analyzeTable( pParse, pIdx.pTable, pIdx ); + } + else if ( ( pTab = sqlite3LocateTable( pParse, 0, z, null ) ) != null ) + { + analyzeTable( pParse, pTab, null ); + } + z = null;//sqlite3DbFree( db, z ); + } + } + } + else + { + /* Form 3: Analyze the fully qualified table name */ + iDb = sqlite3TwoPartName( pParse, pName1, pName2, ref pTableName ); + if ( iDb >= 0 ) + { + zDb = db.aDb[iDb].zName; + z = sqlite3NameFromToken( db, pTableName ); + if ( z != null ) + { + if ( ( pIdx = sqlite3FindIndex( db, z, zDb ) ) != null ) + { + analyzeTable( pParse, pIdx.pTable, pIdx ); + } + else if ( ( pTab = sqlite3LocateTable( pParse, 0, z, zDb ) ) != null ) + { + analyzeTable( pParse, pTab, null ); } + z = null; //sqlite3DbFree( db, z ); + } + } + } +} - /* - ** Used to pass information from the analyzer reader through to the - ** callback routine. - */ - //typedef struct analysisInfo analysisInfo; - public struct analysisInfo { - public sqlite3 db; - public string zDatabase; - }; - - /* - ** This callback is invoked once for each index when reading the - ** sqlite_stat1 table. - ** - ** argv[0] = name of the table - ** argv[1] = name of the index (might be NULL) - ** argv[2] = results of analysis - on integer for each column - ** - ** Entries for which argv[1]==NULL simply record the number of rows in - ** the table. - */ - static int analysisLoader(object pData, sqlite3_int64 argc, object Oargv, object NotUsed) { - string[] argv = (string[])Oargv; - analysisInfo pInfo = (analysisInfo)pData; - Index pIndex; - Table pTable; - int i, c, n; - int v; - string z; - - Debug.Assert(argc == 3); - UNUSED_PARAMETER2(NotUsed, argc); - if (argv == null || argv[0] == null || argv[2] == null) { - return 0; - } - pTable = sqlite3FindTable(pInfo.db, argv[0], pInfo.zDatabase); - if (pTable == null) { - return 0; - } - if (!String.IsNullOrEmpty(argv[1])) { - pIndex = sqlite3FindIndex(pInfo.db, argv[1], pInfo.zDatabase); - } else { - pIndex = null; - } +/* +** Used to pass information from the analyzer reader through to the +** callback routine. +*/ +//typedef struct analysisInfo analysisInfo; +public struct analysisInfo +{ + public sqlite3 db; + public string zDatabase; +}; - n = pIndex != null ? pIndex.nColumn : 0; - z = argv[2]; - int zIndex = 0; - for (i = 0; z != null && i <= n; i++) { - v = 0; - while (zIndex < z.Length && (c = z[zIndex]) >= '0' && c <= '9') { - v = v * 10 + c - '0'; - zIndex++; - } - if (i == 0) - pTable.nRowEst = (uint)v; - if (pIndex == null) - break; - pIndex.aiRowEst[i] = v; - if (zIndex < z.Length && z[zIndex] == ' ') - zIndex++; - if (string.Equals(z.Substring(zIndex), "unordered", StringComparison.Ordinal))//memcmp( z, "unordered", 10 ) == 0 ) - { - pIndex.bUnordered = 1; - break; - } - } - return 0; - } +/* +** This callback is invoked once for each index when reading the +** sqlite_stat1 table. +** +** argv[0] = name of the table +** argv[1] = name of the index (might be NULL) +** argv[2] = results of analysis - on integer for each column +** +** Entries for which argv[1]==NULL simply record the number of rows in +** the table. +*/ +static int analysisLoader( object pData, sqlite3_int64 argc, object Oargv, object NotUsed ) +{ + string[] argv = (string[])Oargv; + analysisInfo pInfo = (analysisInfo)pData; + Index pIndex; + Table pTable; + int i, c, n; + int v; + string z; + + Debug.Assert( argc == 3 ); + UNUSED_PARAMETER2( NotUsed, argc ); + if ( argv == null || argv[0] == null || argv[2] == null ) + { + return 0; + } + pTable = sqlite3FindTable( pInfo.db, argv[0], pInfo.zDatabase ); + if ( pTable == null ) + { + return 0; + } + if ( !String.IsNullOrEmpty( argv[1] ) ) + { + pIndex = sqlite3FindIndex( pInfo.db, argv[1], pInfo.zDatabase ); + } + else + { + pIndex = null; + } - /* - ** If the Index.aSample variable is not NULL, delete the aSample[] array - ** and its contents. - */ - static void sqlite3DeleteIndexSamples(sqlite3 db, Index pIdx) { + n = pIndex != null ? pIndex.nColumn : 0; + z = argv[2]; + int zIndex = 0; + for ( i = 0; z != null && i <= n; i++ ) + { + v = 0; + while ( zIndex < z.Length && ( c = z[zIndex] ) >= '0' && c <= '9' ) + { + v = v * 10 + c - '0'; + zIndex++; + } + if ( i == 0 ) + pTable.nRowEst = (uint)v; + if ( pIndex == null ) + break; + pIndex.aiRowEst[i] = v; + if ( zIndex < z.Length && z[zIndex] == ' ' ) + zIndex++; + if ( string.Equals(z.Substring(zIndex), "unordered", StringComparison.Ordinal) )//memcmp( z, "unordered", 10 ) == 0 ) + { + pIndex.bUnordered = 1; + break; + } + } + return 0; +} + +/* +** If the Index.aSample variable is not NULL, delete the aSample[] array +** and its contents. +*/ +static void sqlite3DeleteIndexSamples( sqlite3 db, Index pIdx ) +{ #if SQLITE_ENABLE_STAT2 if ( pIdx.aSample != null ) { @@ -615,72 +686,75 @@ static void sqlite3DeleteIndexSamples(sqlite3 db, Index pIdx) { sqlite3DbFree( db, ref pIdx.aSample ); } #else - UNUSED_PARAMETER(db); - UNUSED_PARAMETER(pIdx); +UNUSED_PARAMETER(db); +UNUSED_PARAMETER( pIdx ); #endif - } +} - /* - ** Load the content of the sqlite_stat1 and sqlite_stat2 tables. The - ** contents of sqlite_stat1 are used to populate the Index.aiRowEst[] - ** arrays. The contents of sqlite_stat2 are used to populate the - ** Index.aSample[] arrays. - ** - ** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR - ** is returned. In this case, even if SQLITE_ENABLE_STAT2 was defined - ** during compilation and the sqlite_stat2 table is present, no data is - ** read from it. - ** - ** If SQLITE_ENABLE_STAT2 was defined during compilation and the - ** sqlite_stat2 table is not present in the database, SQLITE_ERROR is - ** returned. However, in this case, data is read from the sqlite_stat1 - ** table (if it is present) before returning. - ** - ** If an OOM error occurs, this function always sets db.mallocFailed. - ** This means if the caller does not care about other errors, the return - ** code may be ignored. - */ - static int sqlite3AnalysisLoad(sqlite3 db, int iDb) { - analysisInfo sInfo; - HashElem i; - string zSql; - int rc; - - Debug.Assert(iDb >= 0 && iDb < db.nDb); - Debug.Assert(db.aDb[iDb].pBt != null); - /* Clear any prior statistics */ - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); - //for(i=sqliteHashFirst(&db.aDb[iDb].pSchema.idxHash);i;i=sqliteHashNext(i)){ - for (i = db.aDb[iDb].pSchema.idxHash.first; i != null; i = i.next) { - Index pIdx = (Index)i.data;// sqliteHashData( i ); - sqlite3DefaultRowEst(pIdx); - sqlite3DeleteIndexSamples(db, pIdx); - pIdx.aSample = null; - } +/* +** Load the content of the sqlite_stat1 and sqlite_stat2 tables. The +** contents of sqlite_stat1 are used to populate the Index.aiRowEst[] +** arrays. The contents of sqlite_stat2 are used to populate the +** Index.aSample[] arrays. +** +** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR +** is returned. In this case, even if SQLITE_ENABLE_STAT2 was defined +** during compilation and the sqlite_stat2 table is present, no data is +** read from it. +** +** If SQLITE_ENABLE_STAT2 was defined during compilation and the +** sqlite_stat2 table is not present in the database, SQLITE_ERROR is +** returned. However, in this case, data is read from the sqlite_stat1 +** table (if it is present) before returning. +** +** If an OOM error occurs, this function always sets db.mallocFailed. +** This means if the caller does not care about other errors, the return +** code may be ignored. +*/ +static int sqlite3AnalysisLoad( sqlite3 db, int iDb ) +{ + analysisInfo sInfo; + HashElem i; + string zSql; + int rc; + + Debug.Assert( iDb >= 0 && iDb < db.nDb ); + Debug.Assert( db.aDb[iDb].pBt != null ); + /* Clear any prior statistics */ + Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); + //for(i=sqliteHashFirst(&db.aDb[iDb].pSchema.idxHash);i;i=sqliteHashNext(i)){ + for ( i = db.aDb[iDb].pSchema.idxHash.first; i != null; i = i.next ) + { + Index pIdx = (Index)i.data;// sqliteHashData( i ); + sqlite3DefaultRowEst( pIdx ); + sqlite3DeleteIndexSamples( db, pIdx ); + pIdx.aSample = null; + } - /* Check to make sure the sqlite_stat1 table exists */ - sInfo.db = db; - sInfo.zDatabase = db.aDb[iDb].zName; - if (sqlite3FindTable(db, "sqlite_stat1", sInfo.zDatabase) == null) { - return SQLITE_ERROR; - } + /* Check to make sure the sqlite_stat1 table exists */ + sInfo.db = db; + sInfo.zDatabase = db.aDb[iDb].zName; + if ( sqlite3FindTable( db, "sqlite_stat1", sInfo.zDatabase ) == null ) + { + return SQLITE_ERROR; + } - /* Load new statistics out of the sqlite_stat1 table */ - zSql = sqlite3MPrintf(db, - "SELECT tbl, idx, stat FROM %Q.sqlite_stat1", sInfo.zDatabase); - //if ( zSql == null ) - //{ - // rc = SQLITE_NOMEM; - //} - //else - { - rc = sqlite3_exec(db, zSql, (dxCallback)analysisLoader, sInfo, 0); - sqlite3DbFree(db, ref zSql); - } + /* Load new statistics out of the sqlite_stat1 table */ + zSql = sqlite3MPrintf( db, + "SELECT tbl, idx, stat FROM %Q.sqlite_stat1", sInfo.zDatabase ); + //if ( zSql == null ) + //{ + // rc = SQLITE_NOMEM; + //} + //else + { + rc = sqlite3_exec( db, zSql, (dxCallback)analysisLoader, sInfo, 0 ); + sqlite3DbFree( db, ref zSql ); + } - /* Load the statistics from the sqlite_stat2 table. */ + /* Load the statistics from the sqlite_stat2 table. */ #if SQLITE_ENABLE_STAT2 if ( rc == SQLITE_OK && null == sqlite3FindTable( db, "sqlite_stat2", sInfo.zDatabase ) ) { @@ -781,12 +855,12 @@ static int sqlite3AnalysisLoad(sqlite3 db, int iDb) { } #endif - //if( rc==SQLITE_NOMEM ){ - // db.mallocFailed = 1; - //} - return rc; - } + //if( rc==SQLITE_NOMEM ){ + // db.mallocFailed = 1; + //} + return rc; +} #endif // * SQLITE_OMIT_ANALYZE */ - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/attach_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/attach_c.cs index 16149bd60..ede667540 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/attach_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/attach_c.cs @@ -3,195 +3,214 @@ using System.Text; using u8 = System.Byte; +using u32 = System.UInt32; -namespace Community.CsharpSqlite { - using sqlite3_value = Sqlite3.Mem; - - public partial class Sqlite3 { - /* - ** 2003 April 6 - ** - ** 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 contains code used to implement the ATTACH and DETACH commands. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +namespace Community.CsharpSqlite +{ + using sqlite3_value = Sqlite3.Mem; + + public partial class Sqlite3 + { +/* +** 2003 April 6 +** +** 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 contains code used to implement the ATTACH and DETACH commands. +************************************************************************* +** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart +** C#-SQLite is an independent reimplementation of the SQLite software library +** +** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 +** +************************************************************************* +*/ +//#include "sqliteInt.h" #if !SQLITE_OMIT_ATTACH - /* - ** Resolve an expression that was part of an ATTACH or DETACH statement. This - ** is slightly different from resolving a normal SQL expression, because simple - ** identifiers are treated as strings, not possible column names or aliases. - ** - ** i.e. if the parser sees: - ** - ** ATTACH DATABASE abc AS def - ** - ** it treats the two expressions as literal strings 'abc' and 'def' instead of - ** looking for columns of the same name. - ** - ** This only applies to the root node of pExpr, so the statement: - ** - ** ATTACH DATABASE abc||def AS 'db2' - ** - ** will fail because neither abc or def can be resolved. - */ - static int resolveAttachExpr(NameContext pName, Expr pExpr) { - int rc = SQLITE_OK; - if (pExpr != null) { - if (pExpr.op != TK_ID) { - rc = sqlite3ResolveExprNames(pName, ref pExpr); - if (rc == SQLITE_OK && sqlite3ExprIsConstant(pExpr) == 0) { - sqlite3ErrorMsg(pName.pParse, "invalid name: \"%s\"", pExpr.u.zToken); - return SQLITE_ERROR; - } - } else { - pExpr.op = TK_STRING; - } - } - return rc; - } +/* +** Resolve an expression that was part of an ATTACH or DETACH statement. This +** is slightly different from resolving a normal SQL expression, because simple +** identifiers are treated as strings, not possible column names or aliases. +** +** i.e. if the parser sees: +** +** ATTACH DATABASE abc AS def +** +** it treats the two expressions as literal strings 'abc' and 'def' instead of +** looking for columns of the same name. +** +** This only applies to the root node of pExpr, so the statement: +** +** ATTACH DATABASE abc||def AS 'db2' +** +** will fail because neither abc or def can be resolved. +*/ +static int resolveAttachExpr( NameContext pName, Expr pExpr ) +{ + int rc = SQLITE_OK; + if ( pExpr != null ) + { + if ( pExpr.op != TK_ID ) + { + rc = sqlite3ResolveExprNames( pName, ref pExpr ); + if ( rc == SQLITE_OK && sqlite3ExprIsConstant( pExpr ) == 0 ) + { + sqlite3ErrorMsg( pName.pParse, "invalid name: \"%s\"", pExpr.u.zToken ); + return SQLITE_ERROR; + } + } + else + { + pExpr.op = TK_STRING; + } + } + return rc; +} - /* - ** An SQL user-function registered to do the work of an ATTACH statement. The - ** three arguments to the function come directly from an attach statement: - ** - ** ATTACH DATABASE x AS y KEY z - ** - ** SELECT sqlite_attach(x, y, z) - ** - ** If the optional "KEY z" syntax is omitted, an SQL NULL is passed as the - ** third argument. - */ - static void attachFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] argv - ) { - int i; - int rc = 0; - sqlite3 db = sqlite3_context_db_handle(context); - string zName; - string zFile; - string zPath = ""; - string zErr = ""; - int flags; - - Db aNew = null; - string zErrDyn = ""; - sqlite3_vfs pVfs = null; - - UNUSED_PARAMETER(NotUsed); - - zFile = argv[0].z != null && (argv[0].z.Length > 0) && argv[0].flags != MEM_Null ? sqlite3_value_text(argv[0]) : ""; - zName = argv[1].z != null && (argv[1].z.Length > 0) && argv[1].flags != MEM_Null ? sqlite3_value_text(argv[1]) : ""; - //if( zFile==null ) zFile = ""; - //if ( zName == null ) zName = ""; - - - /* Check for the following errors: - ** - ** * Too many attached databases, - ** * Transaction currently open - ** * Specified database name already being used. - */ - if (db.nDb >= db.aLimit[SQLITE_LIMIT_ATTACHED] + 2) { - zErrDyn = sqlite3MPrintf(db, "too many attached databases - max %d", - db.aLimit[SQLITE_LIMIT_ATTACHED] - ); - goto attach_error; - } - if (0 == db.autoCommit) { - zErrDyn = sqlite3MPrintf(db, "cannot ATTACH database within transaction"); - goto attach_error; - } - for (i = 0; i < db.nDb; i++) { - string z = db.aDb[i].zName; - Debug.Assert(z != null && zName != null); - if (z.Equals(zName, StringComparison.OrdinalIgnoreCase)) { - zErrDyn = sqlite3MPrintf(db, "database %s is already in use", zName); - goto attach_error; - } - } - - /* Allocate the new entry in the db.aDb[] array and initialise the schema - ** hash tables. - */ - /* Allocate the new entry in the db.aDb[] array and initialise the schema - ** hash tables. - */ - //if( db.aDb==db.aDbStatic ){ - // aNew = sqlite3DbMallocRaw(db, sizeof(db.aDb[0])*3 ); - // if( aNew==0 ) return; - // memcpy(aNew, db.aDb, sizeof(db.aDb[0])*2); - //}else { - if (db.aDb.Length <= db.nDb) - Array.Resize(ref db.aDb, db.nDb + 1);//aNew = sqlite3DbRealloc(db, db.aDb, sizeof(db.aDb[0])*(db.nDb+1) ); - if (db.aDb == null) - return; // if( aNew==0 ) return; - //} - db.aDb[db.nDb] = new Db();//db.aDb = aNew; - aNew = db.aDb[db.nDb];//memset(aNew, 0, sizeof(*aNew)); - // memset(aNew, 0, sizeof(*aNew)); - - /* Open the database file. If the btree is successfully opened, use - ** it to obtain the database schema. At this point the schema may - ** or may not be initialised. - */ - flags = (int)db.openFlags; - rc = sqlite3ParseUri(vfsList.zName, zFile, ref flags, ref pVfs, ref zPath, ref zErr); - if (rc != SQLITE_OK) { - //if ( rc == SQLITE_NOMEM ) - //db.mallocFailed = 1; - sqlite3_result_error(context, zErr, -1); - //sqlite3_free( zErr ); - return; - } - Debug.Assert(pVfs != null); - flags |= SQLITE_OPEN_MAIN_DB; - rc = sqlite3BtreeOpen(pVfs, zPath, db, ref aNew.pBt, 0, (int)flags); - //sqlite3_free( zPath ); - - db.nDb++; - if (rc == SQLITE_CONSTRAINT) { - rc = SQLITE_ERROR; - zErrDyn = sqlite3MPrintf(db, "database is already attached"); - } else if (rc == SQLITE_OK) { - Pager pPager; - aNew.pSchema = sqlite3SchemaGet(db, aNew.pBt); - //if ( aNew.pSchema == null ) - //{ - // rc = SQLITE_NOMEM; - //} - //else - if (aNew.pSchema.file_format != 0 && aNew.pSchema.enc != ENC(db)) { - zErrDyn = sqlite3MPrintf(db, - "attached databases must use the same text encoding as main database"); - rc = SQLITE_ERROR; - } - pPager = sqlite3BtreePager(aNew.pBt); - sqlite3PagerLockingMode(pPager, db.dfltLockMode); - sqlite3BtreeSecureDelete(aNew.pBt, - sqlite3BtreeSecureDelete(db.aDb[0].pBt, -1)); - } - aNew.safety_level = 3; - aNew.zName = zName;//sqlite3DbStrDup(db, zName); - //if( rc==SQLITE_OK && aNew.zName==0 ){ - // rc = SQLITE_NOMEM; - //} +/* +** An SQL user-function registered to do the work of an ATTACH statement. The +** three arguments to the function come directly from an attach statement: +** +** ATTACH DATABASE x AS y KEY z +** +** SELECT sqlite_attach(x, y, z) +** +** If the optional "KEY z" syntax is omitted, an SQL NULL is passed as the +** third argument. +*/ +static void attachFunc( +sqlite3_context context, +int NotUsed, +sqlite3_value[] argv +) +{ + int i; + int rc = 0; + sqlite3 db = sqlite3_context_db_handle( context ); + string zName; + string zFile; + string zPath = ""; + string zErr = ""; + int flags; + + Db aNew = null; + string zErrDyn = ""; + sqlite3_vfs pVfs = null; + + UNUSED_PARAMETER( NotUsed ); + + zFile = argv[0].z != null && ( argv[0].z.Length > 0 ) && argv[0].flags != MEM_Null ? sqlite3_value_text( argv[0] ) : ""; + zName = argv[1].z != null && ( argv[1].z.Length > 0 ) && argv[1].flags != MEM_Null ? sqlite3_value_text( argv[1] ) : ""; + //if( zFile==null ) zFile = ""; + //if ( zName == null ) zName = ""; + + + /* Check for the following errors: + ** + ** * Too many attached databases, + ** * Transaction currently open + ** * Specified database name already being used. + */ + if ( db.nDb >= db.aLimit[SQLITE_LIMIT_ATTACHED] + 2 ) + { + zErrDyn = sqlite3MPrintf( db, "too many attached databases - max %d", + db.aLimit[SQLITE_LIMIT_ATTACHED] + ); + goto attach_error; + } + if ( 0 == db.autoCommit ) + { + zErrDyn = sqlite3MPrintf( db, "cannot ATTACH database within transaction" ); + goto attach_error; + } + for ( i = 0; i < db.nDb; i++ ) + { + string z = db.aDb[i].zName; + Debug.Assert( z != null && zName != null ); + if ( z.Equals( zName, StringComparison.OrdinalIgnoreCase ) ) + { + zErrDyn = sqlite3MPrintf( db, "database %s is already in use", zName ); + goto attach_error; + } + } + + /* Allocate the new entry in the db.aDb[] array and initialise the schema + ** hash tables. + */ + /* Allocate the new entry in the db.aDb[] array and initialise the schema + ** hash tables. + */ + //if( db.aDb==db.aDbStatic ){ + // aNew = sqlite3DbMallocRaw(db, sizeof(db.aDb[0])*3 ); + // if( aNew==0 ) return; + // memcpy(aNew, db.aDb, sizeof(db.aDb[0])*2); + //}else { + if ( db.aDb.Length <= db.nDb ) + Array.Resize( ref db.aDb, db.nDb + 1 );//aNew = sqlite3DbRealloc(db, db.aDb, sizeof(db.aDb[0])*(db.nDb+1) ); + if ( db.aDb == null ) + return; // if( aNew==0 ) return; + //} + db.aDb[db.nDb] = new Db();//db.aDb = aNew; + aNew = db.aDb[db.nDb];//memset(aNew, 0, sizeof(*aNew)); + // memset(aNew, 0, sizeof(*aNew)); + + /* Open the database file. If the btree is successfully opened, use + ** it to obtain the database schema. At this point the schema may + ** or may not be initialised. + */ + flags = (int)db.openFlags; + rc = sqlite3ParseUri( vfsList.zName, zFile, ref flags, ref pVfs, ref zPath, ref zErr ); + if ( rc != SQLITE_OK ) + { + //if ( rc == SQLITE_NOMEM ) + //db.mallocFailed = 1; + sqlite3_result_error( context, zErr, -1 ); + //sqlite3_free( zErr ); + return; + } + Debug.Assert( pVfs != null); + flags |= SQLITE_OPEN_MAIN_DB; + rc = sqlite3BtreeOpen( pVfs, zPath, db, ref aNew.pBt, 0, (int)flags ); + //sqlite3_free( zPath ); + + db.nDb++; + if ( rc == SQLITE_CONSTRAINT ) + { + rc = SQLITE_ERROR; + zErrDyn = sqlite3MPrintf( db, "database is already attached" ); + } + else if ( rc == SQLITE_OK ) + { + Pager pPager; + aNew.pSchema = sqlite3SchemaGet( db, aNew.pBt ); + //if ( aNew.pSchema == null ) + //{ + // rc = SQLITE_NOMEM; + //} + //else + if ( aNew.pSchema.file_format != 0 && aNew.pSchema.enc != ENC( db ) ) + { + zErrDyn = sqlite3MPrintf( db, + "attached databases must use the same text encoding as main database" ); + rc = SQLITE_ERROR; + } + pPager = sqlite3BtreePager( aNew.pBt ); + sqlite3PagerLockingMode( pPager, db.dfltLockMode ); + sqlite3BtreeSecureDelete( aNew.pBt, + sqlite3BtreeSecureDelete( db.aDb[0].pBt, -1 ) ); + } + aNew.safety_level = 3; + aNew.zName = zName;//sqlite3DbStrDup(db, zName); + //if( rc==SQLITE_OK && aNew.zName==0 ){ + // rc = SQLITE_NOMEM; + //} #if SQLITE_HAS_CODEC if ( rc == SQLITE_OK ) @@ -228,136 +247,151 @@ sqlite3_value[] argv } #endif - /* If the file was opened successfully, read the schema for the new database. - ** If this fails, or if opening the file failed, then close the file and - ** remove the entry from the db.aDb[] array. i.e. put everything back the way - ** we found it. - */ - if (rc == SQLITE_OK) { - sqlite3BtreeEnterAll(db); - rc = sqlite3Init(db, ref zErrDyn); - sqlite3BtreeLeaveAll(db); - } - if (rc != 0) { - int iDb = db.nDb - 1; - Debug.Assert(iDb >= 2); - if (db.aDb[iDb].pBt != null) { - sqlite3BtreeClose(ref db.aDb[iDb].pBt); - db.aDb[iDb].pBt = null; - db.aDb[iDb].pSchema = null; - } - sqlite3ResetInternalSchema(db, -1); - db.nDb = iDb; - if (rc == SQLITE_NOMEM || rc == SQLITE_IOERR_NOMEM) { - //// db.mallocFailed = 1; - sqlite3DbFree(db, ref zErrDyn); - zErrDyn = sqlite3MPrintf(db, "out of memory"); - } else if (zErrDyn == "") { - zErrDyn = sqlite3MPrintf(db, "unable to open database: %s", zFile); - } - goto attach_error; - } - - return; - - attach_error: - /* Return an error if we get here */ - if (zErrDyn != "") { - sqlite3_result_error(context, zErrDyn, -1); - sqlite3DbFree(db, ref zErrDyn); - } - if (rc != 0) - sqlite3_result_error_code(context, rc); - } + /* If the file was opened successfully, read the schema for the new database. +** If this fails, or if opening the file failed, then close the file and +** remove the entry from the db.aDb[] array. i.e. put everything back the way +** we found it. +*/ + if ( rc == SQLITE_OK ) + { + sqlite3BtreeEnterAll( db ); + rc = sqlite3Init( db, ref zErrDyn ); + sqlite3BtreeLeaveAll( db ); + } + if ( rc != 0 ) + { + int iDb = db.nDb - 1; + Debug.Assert( iDb >= 2 ); + if ( db.aDb[iDb].pBt != null ) + { + sqlite3BtreeClose( ref db.aDb[iDb].pBt ); + db.aDb[iDb].pBt = null; + db.aDb[iDb].pSchema = null; + } + sqlite3ResetInternalSchema( db, -1 ); + db.nDb = iDb; + if ( rc == SQLITE_NOMEM || rc == SQLITE_IOERR_NOMEM ) + { + //// db.mallocFailed = 1; + sqlite3DbFree( db, ref zErrDyn ); + zErrDyn = sqlite3MPrintf( db, "out of memory" ); + } + else if ( zErrDyn == "" ) + { + zErrDyn = sqlite3MPrintf( db, "unable to open database: %s", zFile ); + } + goto attach_error; + } - /* - ** An SQL user-function registered to do the work of an DETACH statement. The - ** three arguments to the function come directly from a detach statement: - ** - ** DETACH DATABASE x - ** - ** SELECT sqlite_detach(x) - */ - static void detachFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] argv - ) { - string zName = zName = argv[0].z != null && (argv[0].z.Length > 0) ? sqlite3_value_text(argv[0]) : "";//(sqlite3_value_text(argv[0]); - sqlite3 db = sqlite3_context_db_handle(context); - int i; - Db pDb = null; - StringBuilder zErr = new StringBuilder(200); - - UNUSED_PARAMETER(NotUsed); - - if (zName == null) - zName = ""; - for (i = 0; i < db.nDb; i++) { - pDb = db.aDb[i]; - if (pDb.pBt == null) - continue; - if (pDb.zName.Equals(zName, StringComparison.OrdinalIgnoreCase)) - break; - } - - if (i >= db.nDb) { - sqlite3_snprintf(200, zErr, "no such database: %s", zName); - goto detach_error; - } - if (i < 2) { - sqlite3_snprintf(200, zErr, "cannot detach database %s", zName); - goto detach_error; - } - if (0 == db.autoCommit) { - sqlite3_snprintf(200, zErr, - "cannot DETACH database within transaction"); - goto detach_error; - } - if (sqlite3BtreeIsInReadTrans(pDb.pBt) || sqlite3BtreeIsInBackup(pDb.pBt)) { - sqlite3_snprintf(200, zErr, "database %s is locked", zName); - goto detach_error; - } - - sqlite3BtreeClose(ref pDb.pBt); - pDb.pBt = null; - pDb.pSchema = null; - sqlite3ResetInternalSchema(db, -1); - return; - - detach_error: - sqlite3_result_error(context, zErr.ToString(), -1); - } + return; + +attach_error: + /* Return an error if we get here */ + if ( zErrDyn != "" ) + { + sqlite3_result_error( context, zErrDyn, -1 ); + sqlite3DbFree( db, ref zErrDyn ); + } + if ( rc != 0 ) + sqlite3_result_error_code( context, rc ); +} + +/* +** An SQL user-function registered to do the work of an DETACH statement. The +** three arguments to the function come directly from a detach statement: +** +** DETACH DATABASE x +** +** SELECT sqlite_detach(x) +*/ +static void detachFunc( +sqlite3_context context, +int NotUsed, +sqlite3_value[] argv +) +{ + string zName = zName = argv[0].z != null && ( argv[0].z.Length > 0 ) ? sqlite3_value_text( argv[0] ) : "";//(sqlite3_value_text(argv[0]); + sqlite3 db = sqlite3_context_db_handle( context ); + int i; + Db pDb = null; + StringBuilder zErr = new StringBuilder( 200 ); + + UNUSED_PARAMETER( NotUsed ); + + if ( zName == null ) + zName = ""; + for ( i = 0; i < db.nDb; i++ ) + { + pDb = db.aDb[i]; + if ( pDb.pBt == null ) + continue; + if ( pDb.zName.Equals( zName, StringComparison.OrdinalIgnoreCase ) ) + break; + } - /* - ** This procedure generates VDBE code for a single invocation of either the - ** sqlite_detach() or sqlite_attach() SQL user functions. - */ - static void codeAttach( - Parse pParse, /* The parser context */ - int type, /* Either SQLITE_ATTACH or SQLITE_DETACH */ - FuncDef pFunc, /* FuncDef wrapper for detachFunc() or attachFunc() */ - Expr pAuthArg, /* Expression to pass to authorization callback */ - Expr pFilename, /* Name of database file */ - Expr pDbname, /* Name of the database to use internally */ - Expr pKey /* Database key for encryption extension */ - ) { - NameContext sName; - Vdbe v; - sqlite3 db = pParse.db; - int regArgs; - - sName = new NameContext();// memset( &sName, 0, sizeof(NameContext)); - sName.pParse = pParse; - - if ( - SQLITE_OK != resolveAttachExpr(sName, pFilename) || - SQLITE_OK != resolveAttachExpr(sName, pDbname) || - SQLITE_OK != resolveAttachExpr(sName, pKey) - ) { - pParse.nErr++; - goto attach_end; - } + if ( i >= db.nDb ) + { + sqlite3_snprintf( 200, zErr, "no such database: %s", zName ); + goto detach_error; + } + if ( i < 2 ) + { + sqlite3_snprintf( 200, zErr, "cannot detach database %s", zName ); + goto detach_error; + } + if ( 0 == db.autoCommit ) + { + sqlite3_snprintf( 200, zErr, + "cannot DETACH database within transaction" ); + goto detach_error; + } + if ( sqlite3BtreeIsInReadTrans( pDb.pBt ) || sqlite3BtreeIsInBackup( pDb.pBt ) ) + { + sqlite3_snprintf( 200, zErr, "database %s is locked", zName ); + goto detach_error; + } + + sqlite3BtreeClose( ref pDb.pBt ); + pDb.pBt = null; + pDb.pSchema = null; + sqlite3ResetInternalSchema( db, -1 ); + return; + +detach_error: + sqlite3_result_error( context, zErr.ToString(), -1 ); +} + +/* +** This procedure generates VDBE code for a single invocation of either the +** sqlite_detach() or sqlite_attach() SQL user functions. +*/ +static void codeAttach( +Parse pParse, /* The parser context */ +int type, /* Either SQLITE_ATTACH or SQLITE_DETACH */ +FuncDef pFunc, /* FuncDef wrapper for detachFunc() or attachFunc() */ +Expr pAuthArg, /* Expression to pass to authorization callback */ +Expr pFilename, /* Name of database file */ +Expr pDbname, /* Name of the database to use internally */ +Expr pKey /* Database key for encryption extension */ +) +{ + NameContext sName; + Vdbe v; + sqlite3 db = pParse.db; + int regArgs; + + sName = new NameContext();// memset( &sName, 0, sizeof(NameContext)); + sName.pParse = pParse; + + if ( + SQLITE_OK != resolveAttachExpr( sName, pFilename ) || + SQLITE_OK != resolveAttachExpr( sName, pDbname ) || + SQLITE_OK != resolveAttachExpr( sName, pKey ) + ) + { + pParse.nErr++; + goto attach_end; + } #if !SQLITE_OMIT_AUTHORIZATION if( pAuthArg ){ @@ -374,230 +408,258 @@ static void codeAttach( } #endif //* SQLITE_OMIT_AUTHORIZATION */ - v = sqlite3GetVdbe(pParse); - regArgs = sqlite3GetTempRange(pParse, 4); - sqlite3ExprCode(pParse, pFilename, regArgs); - sqlite3ExprCode(pParse, pDbname, regArgs + 1); - sqlite3ExprCode(pParse, pKey, regArgs + 2); - - Debug.Assert(v != null /*|| db.mallocFailed != 0 */ ); - if (v != null) { - sqlite3VdbeAddOp3(v, OP_Function, 0, regArgs + 3 - pFunc.nArg, regArgs + 3); - Debug.Assert(pFunc.nArg == -1 || (pFunc.nArg & 0xff) == pFunc.nArg); - sqlite3VdbeChangeP5(v, (u8)(pFunc.nArg)); - sqlite3VdbeChangeP4(v, -1, pFunc, P4_FUNCDEF); - - /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this - ** statement only). For DETACH, set it to false (expire all existing - ** statements). - */ - sqlite3VdbeAddOp1(v, OP_Expire, (type == SQLITE_ATTACH) ? 1 : 0); - } - - attach_end: - sqlite3ExprDelete(db, ref pFilename); - sqlite3ExprDelete(db, ref pDbname); - sqlite3ExprDelete(db, ref pKey); - } + v = sqlite3GetVdbe( pParse ); + regArgs = sqlite3GetTempRange( pParse, 4 ); + sqlite3ExprCode( pParse, pFilename, regArgs ); + sqlite3ExprCode( pParse, pDbname, regArgs + 1 ); + sqlite3ExprCode( pParse, pKey, regArgs + 2 ); - /* - ** Called by the parser to compile a DETACH statement. - ** - ** DETACH pDbname - */ - static FuncDef detach_func = new FuncDef( - 1, /* nArg */ - SQLITE_UTF8, /* iPrefEnc */ - 0, /* flags */ - null, /* pUserData */ - null, /* pNext */ - detachFunc, /* xFunc */ - null, /* xStep */ - null, /* xFinalize */ - "sqlite_detach", /* zName */ - null, /* pHash */ - null /* pDestructor */ - ); - static void sqlite3Detach(Parse pParse, Expr pDbname) { - codeAttach(pParse, SQLITE_DETACH, detach_func, pDbname, null, null, pDbname); - } + Debug.Assert( v != null /*|| db.mallocFailed != 0 */ ); + if ( v != null ) + { + sqlite3VdbeAddOp3( v, OP_Function, 0, regArgs + 3 - pFunc.nArg, regArgs + 3 ); + Debug.Assert( pFunc.nArg == -1 || ( pFunc.nArg & 0xff ) == pFunc.nArg ); + sqlite3VdbeChangeP5( v, (u8)( pFunc.nArg ) ); + sqlite3VdbeChangeP4( v, -1, pFunc, P4_FUNCDEF ); + + /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this + ** statement only). For DETACH, set it to false (expire all existing + ** statements). + */ + sqlite3VdbeAddOp1( v, OP_Expire, ( type == SQLITE_ATTACH ) ? 1 : 0 ); + } - /* - ** Called by the parser to compile an ATTACH statement. - ** - ** ATTACH p AS pDbname KEY pKey - */ - static FuncDef attach_func = new FuncDef( - 3, /* nArg */ - SQLITE_UTF8, /* iPrefEnc */ - 0, /* flags */ - null, /* pUserData */ - null, /* pNext */ - attachFunc, /* xFunc */ - null, /* xStep */ - null, /* xFinalize */ - "sqlite_attach", /* zName */ - null, /* pHash */ - null /* pDestructor */ - ); - static void sqlite3Attach(Parse pParse, Expr p, Expr pDbname, Expr pKey) { - codeAttach(pParse, SQLITE_ATTACH, attach_func, p, p, pDbname, pKey); - } +attach_end: + sqlite3ExprDelete( db, ref pFilename ); + sqlite3ExprDelete( db, ref pDbname ); + sqlite3ExprDelete( db, ref pKey ); +} + +/* +** Called by the parser to compile a DETACH statement. +** +** DETACH pDbname +*/ +static FuncDef detach_func = new FuncDef( +1, /* nArg */ +SQLITE_UTF8, /* iPrefEnc */ +0, /* flags */ +null, /* pUserData */ +null, /* pNext */ +detachFunc, /* xFunc */ +null, /* xStep */ +null, /* xFinalize */ +"sqlite_detach", /* zName */ +null, /* pHash */ +null /* pDestructor */ +); +static void sqlite3Detach( Parse pParse, Expr pDbname ) +{ + codeAttach( pParse, SQLITE_DETACH, detach_func, pDbname, null, null, pDbname ); +} + +/* +** Called by the parser to compile an ATTACH statement. +** +** ATTACH p AS pDbname KEY pKey +*/ +static FuncDef attach_func = new FuncDef( +3, /* nArg */ +SQLITE_UTF8, /* iPrefEnc */ +0, /* flags */ +null, /* pUserData */ +null, /* pNext */ +attachFunc, /* xFunc */ +null, /* xStep */ +null, /* xFinalize */ +"sqlite_attach", /* zName */ +null, /* pHash */ +null /* pDestructor */ +); +static void sqlite3Attach( Parse pParse, Expr p, Expr pDbname, Expr pKey ) +{ + codeAttach( pParse, SQLITE_ATTACH, attach_func, p, p, pDbname, pKey ); +} #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. - */ - static 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 */ - string zType, /* "view", "trigger", or "index" */ - Token pName /* Name of the view, trigger, or index */ - ) { - sqlite3 db; - - if (NEVER(iDb < 0) || iDb == 1) - return 0; - db = pParse.db; - Debug.Assert(db.nDb > iDb); - pFix.pParse = pParse; - pFix.zDb = db.aDb[iDb].zName; - pFix.zType = zType; - pFix.pName = pName; - return 1; - } +/* +** 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. +*/ +static 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 */ +string zType, /* "view", "trigger", or "index" */ +Token pName /* Name of the view, trigger, or index */ +) +{ + sqlite3 db; + + if ( NEVER( iDb < 0 ) || iDb == 1 ) + return 0; + db = pParse.db; + Debug.Assert( db.nDb > iDb ); + pFix.pParse = pParse; + pFix.zDb = db.aDb[iDb].zName; + pFix.zType = zType; + pFix.pName = pName; + 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 - ** was left unspecified in the original SQL statement. The pFix structure - ** must have been initialized by a prior call to sqlite3FixInit(). - ** - ** These routines are used to make sure that an index, trigger, or - ** view in one database does not refer to objects in a different database. - ** (Exception: indices, triggers, and views in the TEMP database are - ** allowed to refer to anything.) If a reference is explicitly made - ** to an object in a different database, an error message is added to - ** pParse.zErrMsg and these routines return non-zero. If everything - ** checks out, these routines return 0. - */ - static int sqlite3FixSrcList( - DbFixer pFix, /* Context of the fixation */ - SrcList pList /* The Source list to check and modify */ - ) { - int i; - string zDb; - SrcList_item pItem; - - if (NEVER(pList == null)) - return 0; - zDb = pFix.zDb; - for (i = 0; i < pList.nSrc; i++) {//, pItem++){ - pItem = pList.a[i]; - if (pItem.zDatabase == null) { - pItem.zDatabase = zDb;// sqlite3DbStrDup( pFix.pParse.db, zDb ); - } else if (!pItem.zDatabase.Equals(zDb, StringComparison.OrdinalIgnoreCase)) { - sqlite3ErrorMsg(pFix.pParse, - "%s %T cannot reference objects in database %s", - pFix.zType, pFix.pName, pItem.zDatabase); - 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 +** was left unspecified in the original SQL statement. The pFix structure +** must have been initialized by a prior call to sqlite3FixInit(). +** +** These routines are used to make sure that an index, trigger, or +** view in one database does not refer to objects in a different database. +** (Exception: indices, triggers, and views in the TEMP database are +** allowed to refer to anything.) If a reference is explicitly made +** to an object in a different database, an error message is added to +** pParse.zErrMsg and these routines return non-zero. If everything +** checks out, these routines return 0. +*/ +static int sqlite3FixSrcList( +DbFixer pFix, /* Context of the fixation */ +SrcList pList /* The Source list to check and modify */ +) +{ + int i; + string zDb; + SrcList_item pItem; + + if ( NEVER( pList == null ) ) + return 0; + zDb = pFix.zDb; + for ( i = 0; i < pList.nSrc; i++ ) + {//, pItem++){ + pItem = pList.a[i]; + if ( pItem.zDatabase == null ) + { + pItem.zDatabase = zDb;// sqlite3DbStrDup( pFix.pParse.db, zDb ); + } + else if ( !pItem.zDatabase.Equals( zDb ,StringComparison.OrdinalIgnoreCase ) ) + { + sqlite3ErrorMsg( pFix.pParse, + "%s %T cannot reference objects in database %s", + pFix.zType, pFix.pName, pItem.zDatabase ); + return 1; + } #if !SQLITE_OMIT_VIEW || !SQLITE_OMIT_TRIGGER - if (sqlite3FixSelect(pFix, pItem.pSelect) != 0) - return 1; - if (sqlite3FixExpr(pFix, pItem.pOn) != 0) - return 1; + if ( sqlite3FixSelect( pFix, pItem.pSelect ) != 0 ) + return 1; + if ( sqlite3FixExpr( pFix, pItem.pOn ) != 0 ) + return 1; #endif - } - return 0; - } + } + return 0; +} #if !SQLITE_OMIT_VIEW || !SQLITE_OMIT_TRIGGER - static int sqlite3FixSelect( - DbFixer pFix, /* Context of the fixation */ - Select pSelect /* The SELECT statement to be fixed to one database */ - ) { - while (pSelect != null) { - if (sqlite3FixExprList(pFix, pSelect.pEList) != 0) { - return 1; - } - if (sqlite3FixSrcList(pFix, pSelect.pSrc) != 0) { - return 1; - } - if (sqlite3FixExpr(pFix, pSelect.pWhere) != 0) { - return 1; - } - if (sqlite3FixExpr(pFix, pSelect.pHaving) != 0) { - return 1; - } - pSelect = pSelect.pPrior; - } - return 0; - } - static int sqlite3FixExpr( - DbFixer pFix, /* Context of the fixation */ - Expr pExpr /* The expression to be fixed to one database */ - ) { - while (pExpr != null) { - if (ExprHasAnyProperty(pExpr, EP_TokenOnly)) - break; - if (ExprHasProperty(pExpr, EP_xIsSelect)) { - if (sqlite3FixSelect(pFix, pExpr.x.pSelect) != 0) - return 1; - } else { - if (sqlite3FixExprList(pFix, pExpr.x.pList) != 0) - return 1; - } - if (sqlite3FixExpr(pFix, pExpr.pRight) != 0) { - return 1; - } - pExpr = pExpr.pLeft; - } - return 0; - } - static int sqlite3FixExprList( - DbFixer pFix, /* Context of the fixation */ - ExprList pList /* The expression to be fixed to one database */ - ) { - int i; - ExprList_item pItem; - if (pList == null) - return 0; - for (i = 0; i < pList.nExpr; i++)//, pItem++ ) - { - pItem = pList.a[i]; - if (sqlite3FixExpr(pFix, pItem.pExpr) != 0) { - return 1; - } - } - return 0; - } +static int sqlite3FixSelect( +DbFixer pFix, /* Context of the fixation */ +Select pSelect /* The SELECT statement to be fixed to one database */ +) +{ + while ( pSelect != null ) + { + if ( sqlite3FixExprList( pFix, pSelect.pEList ) != 0 ) + { + return 1; + } + if ( sqlite3FixSrcList( pFix, pSelect.pSrc ) != 0 ) + { + return 1; + } + if ( sqlite3FixExpr( pFix, pSelect.pWhere ) != 0 ) + { + return 1; + } + if ( sqlite3FixExpr( pFix, pSelect.pHaving ) != 0 ) + { + return 1; + } + pSelect = pSelect.pPrior; + } + return 0; +} +static int sqlite3FixExpr( +DbFixer pFix, /* Context of the fixation */ +Expr pExpr /* The expression to be fixed to one database */ +) +{ + while ( pExpr != null ) + { + if ( ExprHasAnyProperty( pExpr, EP_TokenOnly ) ) + break; + if ( ExprHasProperty( pExpr, EP_xIsSelect ) ) + { + if ( sqlite3FixSelect( pFix, pExpr.x.pSelect ) != 0 ) + return 1; + } + else + { + if ( sqlite3FixExprList( pFix, pExpr.x.pList ) != 0 ) + return 1; + } + if ( sqlite3FixExpr( pFix, pExpr.pRight ) != 0 ) + { + return 1; + } + pExpr = pExpr.pLeft; + } + return 0; +} +static int sqlite3FixExprList( +DbFixer pFix, /* Context of the fixation */ +ExprList pList /* The expression to be fixed to one database */ +) +{ + int i; + ExprList_item pItem; + if ( pList == null ) + return 0; + for ( i = 0; i < pList.nExpr; i++ )//, pItem++ ) + { + pItem = pList.a[i]; + if ( sqlite3FixExpr( pFix, pItem.pExpr ) != 0 ) + { + return 1; + } + } + return 0; +} #endif #if !SQLITE_OMIT_TRIGGER - static int sqlite3FixTriggerStep( - DbFixer pFix, /* Context of the fixation */ - TriggerStep pStep /* The trigger step be fixed to one database */ - ) { - while (pStep != null) { - if (sqlite3FixSelect(pFix, pStep.pSelect) != 0) { - return 1; - } - if (sqlite3FixExpr(pFix, pStep.pWhere) != 0) { - return 1; - } - if (sqlite3FixExprList(pFix, pStep.pExprList) != 0) { - return 1; - } - pStep = pStep.pNext; - } - return 0; - } +static int sqlite3FixTriggerStep( +DbFixer pFix, /* Context of the fixation */ +TriggerStep pStep /* The trigger step be fixed to one database */ +) +{ + while ( pStep != null ) + { + if ( sqlite3FixSelect( pFix, pStep.pSelect ) != 0 ) + { + return 1; + } + if ( sqlite3FixExpr( pFix, pStep.pWhere ) != 0 ) + { + return 1; + } + if ( sqlite3FixExprList( pFix, pStep.pExprList ) != 0 ) + { + return 1; + } + pStep = pStep.pNext; + } + return 0; +} #endif - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/auth_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/auth_c.cs index 846777e9f..f2ee6a610 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/auth_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/auth_c.cs @@ -1,34 +1,42 @@ -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2003 January 11 - ** - ** 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 contains code used to implement the sqlite3_set_authorizer() - ** API. This facility is an optional feature of the library. Embedded - ** systems that do not need this facility may omit it by recompiling - ** the library with -DSQLITE_OMIT_AUTHORIZATION=1 - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +using System; +using System.Diagnostics; +using System.Text; - /* - ** All of the code in this file may be omitted by defining a single - ** macro. - */ +namespace Community.CsharpSqlite +{ + using sqlite3_value = Sqlite3.Mem; + + public partial class Sqlite3 + { +/* +** 2003 January 11 +** +** 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 contains code used to implement the sqlite3_set_authorizer() +** API. This facility is an optional feature of the library. Embedded +** systems that do not need this facility may omit it by recompiling +** the library with -DSQLITE_OMIT_AUTHORIZATION=1 +************************************************************************* +** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart +** C#-SQLite is an independent reimplementation of the SQLite software library +** +** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 +** +************************************************************************* +*/ +//#include "sqliteInt.h" + +/* +** All of the code in this file may be omitted by defining a single +** macro. +*/ #if !SQLITE_OMIT_AUTHORIZATION /* @@ -255,5 +263,5 @@ void sqlite3AuthContextPop(AuthContext *pContext){ } #endif //* SQLITE_OMIT_AUTHORIZATION */ - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/backup_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/backup_c.cs index 51939abd2..7936670f6 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/backup_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/backup_c.cs @@ -1,263 +1,289 @@ using System; using System.Diagnostics; +using System.Text; using i64 = System.Int64; -using Pgno = System.UInt32; +using u8 = System.Byte; using u32 = System.UInt32; +using Pgno = System.UInt32; -namespace Community.CsharpSqlite { - using DbPage = Sqlite3.PgHdr; - public partial class Sqlite3 { - /* - ** 2009 January 28 - ** - ** 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 contains the implementation of the sqlite3_backup_XXX() - ** API functions and the related features. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include "btreeInt.h" - /* Macro to find the minimum of two numeric values. - */ +namespace Community.CsharpSqlite +{ + using sqlite3_int64 = System.Int64; + using DbPage = Sqlite3.PgHdr; + public partial class Sqlite3 + { +/* +** 2009 January 28 +** +** 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 contains the implementation of the sqlite3_backup_XXX() +** API functions and the related features. +************************************************************************* +** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart +** C#-SQLite is an independent reimplementation of the SQLite software library +** +** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e +** +************************************************************************* +*/ +//#include "sqliteInt.h" +//#include "btreeInt.h" + +/* Macro to find the minimum of two numeric values. +*/ #if !MIN - //# define MIN(x,y) ((x)<(y)?(x):(y)) +//# define MIN(x,y) ((x)<(y)?(x):(y)) #endif - /* - ** Structure allocated for each backup operation. - */ - public class sqlite3_backup { - public sqlite3 pDestDb; /* Destination database handle */ - public Btree pDest; /* Destination b-tree file */ - public u32 iDestSchema; /* Original schema cookie in destination */ - public int bDestLocked; /* True once a write-transaction is open on pDest */ - - public Pgno iNext; /* Page number of the next source page to copy */ - public sqlite3 pSrcDb; /* Source database handle */ - public Btree pSrc; /* Source b-tree file */ - - public int rc; /* Backup process error code */ - - /* These two variables are set by every call to backup_step(). They are - ** read by calls to backup_remaining() and backup_pagecount(). - */ - public Pgno nRemaining; /* Number of pages left to copy */ - public Pgno nPagecount; /* Total number of pages to copy */ - - public int isAttached; /* True once backup has been registered with pager */ - public sqlite3_backup pNext; /* Next backup associated with source pager */ - }; - - /* - ** THREAD SAFETY NOTES: - ** - ** Once it has been created using backup_init(), a single sqlite3_backup - ** structure may be accessed via two groups of thread-safe entry points: - ** - ** * Via the sqlite3_backup_XXX() API function backup_step() and - ** backup_finish(). Both these functions obtain the source database - ** handle mutex and the mutex associated with the source BtShared - ** structure, in that order. - ** - ** * Via the BackupUpdate() and BackupRestart() functions, which are - ** invoked by the pager layer to report various state changes in - ** the page cache associated with the source database. The mutex - ** associated with the source database BtShared structure will always - ** be held when either of these functions are invoked. - ** - ** The other sqlite3_backup_XXX() API functions, backup_remaining() and - ** backup_pagecount() are not thread-safe functions. If they are called - ** while some other thread is calling backup_step() or backup_finish(), - ** the values returned may be invalid. There is no way for a call to - ** BackupUpdate() or BackupRestart() to interfere with backup_remaining() - ** or backup_pagecount(). - ** - ** Depending on the SQLite configuration, the database handles and/or - ** the Btree objects may have their own mutexes that require locking. - ** Non-sharable Btrees (in-memory databases for example), do not have - ** associated mutexes. - */ +/* +** Structure allocated for each backup operation. +*/ +public class sqlite3_backup +{ + public sqlite3 pDestDb; /* Destination database handle */ + public Btree pDest; /* Destination b-tree file */ + public u32 iDestSchema; /* Original schema cookie in destination */ + public int bDestLocked; /* True once a write-transaction is open on pDest */ - /* - ** Return a pointer corresponding to database zDb (i.e. "main", "temp") - ** in connection handle pDb. If such a database cannot be found, return - ** a NULL pointer and write an error message to pErrorDb. - ** - ** If the "temp" database is requested, it may need to be opened by this - ** function. If an error occurs while doing so, return 0 and write an - ** error message to pErrorDb. - */ - static Btree findBtree(sqlite3 pErrorDb, sqlite3 pDb, string zDb) { - int i = sqlite3FindDbName(pDb, zDb); - - if (i == 1) { - Parse pParse; - int rc = 0; - pParse = new Parse();//sqlite3StackAllocZero(pErrorDb, sizeof(*pParse)); - if (pParse == null) { - sqlite3Error(pErrorDb, SQLITE_NOMEM, "out of memory"); - rc = SQLITE_NOMEM; - } else { - pParse.db = pDb; - if (sqlite3OpenTempDatabase(pParse) != 0) { - sqlite3Error(pErrorDb, pParse.rc, "%s", pParse.zErrMsg); - rc = SQLITE_ERROR; - } - sqlite3DbFree(pErrorDb, ref pParse.zErrMsg); - //sqlite3StackFree( pErrorDb, pParse ); - } - if (rc != 0) { - return null; - } - } - - if (i < 0) { - sqlite3Error(pErrorDb, SQLITE_ERROR, "unknown database %s", zDb); - return null; - } - - return pDb.aDb[i].pBt; - } + public Pgno iNext; /* Page number of the next source page to copy */ + public sqlite3 pSrcDb; /* Source database handle */ + public Btree pSrc; /* Source b-tree file */ - /* - ** Attempt to set the page size of the destination to match the page size - ** of the source. - */ - static int setDestPgsz(sqlite3_backup p) { - int rc; - rc = sqlite3BtreeSetPageSize(p.pDest, sqlite3BtreeGetPageSize(p.pSrc), -1, 0); - return rc; - } + public int rc; /* Backup process error code */ - /* - ** Create an sqlite3_backup process to copy the contents of zSrcDb from - ** connection handle pSrcDb to zDestDb in pDestDb. If successful, return - ** a pointer to the new sqlite3_backup object. - ** - ** If an error occurs, NULL is returned and an error code and error message - ** stored in database handle pDestDb. - */ - static public sqlite3_backup sqlite3_backup_init( - sqlite3 pDestDb, /* Database to write to */ - string zDestDb, /* Name of database within pDestDb */ - sqlite3 pSrcDb, /* Database connection to read from */ - string zSrcDb /* Name of database within pSrcDb */ - ) { - sqlite3_backup p; /* Value to return */ - - /* Lock the source database handle. The destination database - ** handle is not locked in this routine, but it is locked in - ** sqlite3_backup_step(). The user is required to ensure that no - ** other thread accesses the destination handle for the duration - ** of the backup operation. Any attempt to use the destination - ** database connection while a backup is in progress may cause - ** a malfunction or a deadlock. - */ - sqlite3_mutex_enter(pSrcDb.mutex); - sqlite3_mutex_enter(pDestDb.mutex); - - if (pSrcDb == pDestDb) { - sqlite3Error( - pDestDb, SQLITE_ERROR, "source and destination must be distinct" - ); - p = null; - } else { - /* Allocate space for a new sqlite3_backup object... - ** EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a - ** call to sqlite3_backup_init() and is destroyed by a call to - ** sqlite3_backup_finish(). */ - p = new sqlite3_backup();// (sqlite3_backup)sqlite3_malloc( sizeof( sqlite3_backup ) ); - //if ( null == p ) - //{ - // sqlite3Error( pDestDb, SQLITE_NOMEM, 0 ); - //} - } - - /* If the allocation succeeded, populate the new object. */ - if (p != null) { - // memset( p, 0, sizeof( sqlite3_backup ) ); - p.pSrc = findBtree(pDestDb, pSrcDb, zSrcDb); - p.pDest = findBtree(pDestDb, pDestDb, zDestDb); - p.pDestDb = pDestDb; - p.pSrcDb = pSrcDb; - p.iNext = 1; - p.isAttached = 0; - - if (null == p.pSrc || null == p.pDest || setDestPgsz(p) == SQLITE_NOMEM) { - /* One (or both) of the named databases did not exist or an OOM - ** error was hit. The error has already been written into the - ** pDestDb handle. All that is left to do here is free the - ** sqlite3_backup structure. - */ - //sqlite3_free( ref p ); - p = null; - } - } - - if (p != null) { - p.pSrc.nBackup++; - } - - sqlite3_mutex_leave(pDestDb.mutex); - sqlite3_mutex_leave(pSrcDb.mutex); - return p; - } + /* These two variables are set by every call to backup_step(). They are + ** read by calls to backup_remaining() and backup_pagecount(). + */ + public Pgno nRemaining; /* Number of pages left to copy */ + public Pgno nPagecount; /* Total number of pages to copy */ + + public int isAttached; /* True once backup has been registered with pager */ + public sqlite3_backup pNext; /* Next backup associated with source pager */ +}; + +/* +** THREAD SAFETY NOTES: +** +** Once it has been created using backup_init(), a single sqlite3_backup +** structure may be accessed via two groups of thread-safe entry points: +** +** * Via the sqlite3_backup_XXX() API function backup_step() and +** backup_finish(). Both these functions obtain the source database +** handle mutex and the mutex associated with the source BtShared +** structure, in that order. +** +** * Via the BackupUpdate() and BackupRestart() functions, which are +** invoked by the pager layer to report various state changes in +** the page cache associated with the source database. The mutex +** associated with the source database BtShared structure will always +** be held when either of these functions are invoked. +** +** The other sqlite3_backup_XXX() API functions, backup_remaining() and +** backup_pagecount() are not thread-safe functions. If they are called +** while some other thread is calling backup_step() or backup_finish(), +** the values returned may be invalid. There is no way for a call to +** BackupUpdate() or BackupRestart() to interfere with backup_remaining() +** or backup_pagecount(). +** +** Depending on the SQLite configuration, the database handles and/or +** the Btree objects may have their own mutexes that require locking. +** Non-sharable Btrees (in-memory databases for example), do not have +** associated mutexes. +*/ + +/* +** Return a pointer corresponding to database zDb (i.e. "main", "temp") +** in connection handle pDb. If such a database cannot be found, return +** a NULL pointer and write an error message to pErrorDb. +** +** If the "temp" database is requested, it may need to be opened by this +** function. If an error occurs while doing so, return 0 and write an +** error message to pErrorDb. +*/ +static Btree findBtree( sqlite3 pErrorDb, sqlite3 pDb, string zDb ) +{ + int i = sqlite3FindDbName( pDb, zDb ); + + if ( i == 1 ) + { + Parse pParse; + int rc = 0; + pParse = new Parse();//sqlite3StackAllocZero(pErrorDb, sizeof(*pParse)); + if ( pParse == null ) + { + sqlite3Error( pErrorDb, SQLITE_NOMEM, "out of memory" ); + rc = SQLITE_NOMEM; + } + else + { + pParse.db = pDb; + if ( sqlite3OpenTempDatabase( pParse ) != 0 ) + { + sqlite3Error( pErrorDb, pParse.rc, "%s", pParse.zErrMsg ); + rc = SQLITE_ERROR; + } + sqlite3DbFree( pErrorDb, ref pParse.zErrMsg ); + //sqlite3StackFree( pErrorDb, pParse ); + } + if ( rc != 0 ) + { + return null; + } + } - /* - ** Argument rc is an SQLite error code. Return true if this error is - ** considered fatal if encountered during a backup operation. All errors - ** are considered fatal except for SQLITE_BUSY and SQLITE_LOCKED. - */ - static bool isFatalError(int rc) { - return (rc != SQLITE_OK && rc != SQLITE_BUSY && ALWAYS(rc != SQLITE_LOCKED)); - } + if ( i < 0 ) + { + sqlite3Error( pErrorDb, SQLITE_ERROR, "unknown database %s", zDb ); + return null; + } - /* - ** Parameter zSrcData points to a buffer containing the data for - ** page iSrcPg from the source database. Copy this data into the - ** destination database. - */ - static int backupOnePage(sqlite3_backup p, Pgno iSrcPg, byte[] zSrcData) { - Pager pDestPager = sqlite3BtreePager(p.pDest); - int nSrcPgsz = sqlite3BtreeGetPageSize(p.pSrc); - int nDestPgsz = sqlite3BtreeGetPageSize(p.pDest); - int nCopy = MIN(nSrcPgsz, nDestPgsz); - i64 iEnd = (i64)iSrcPg * (i64)nSrcPgsz; + return pDb.aDb[i].pBt; +} + +/* +** Attempt to set the page size of the destination to match the page size +** of the source. +*/ +static int setDestPgsz( sqlite3_backup p ) +{ + int rc; + rc = sqlite3BtreeSetPageSize( p.pDest, sqlite3BtreeGetPageSize( p.pSrc ), -1, 0 ); + return rc; +} + +/* +** Create an sqlite3_backup process to copy the contents of zSrcDb from +** connection handle pSrcDb to zDestDb in pDestDb. If successful, return +** a pointer to the new sqlite3_backup object. +** +** If an error occurs, NULL is returned and an error code and error message +** stored in database handle pDestDb. +*/ +static public sqlite3_backup sqlite3_backup_init( +sqlite3 pDestDb, /* Database to write to */ +string zDestDb, /* Name of database within pDestDb */ +sqlite3 pSrcDb, /* Database connection to read from */ +string zSrcDb /* Name of database within pSrcDb */ +) +{ + sqlite3_backup p; /* Value to return */ + + /* Lock the source database handle. The destination database + ** handle is not locked in this routine, but it is locked in + ** sqlite3_backup_step(). The user is required to ensure that no + ** other thread accesses the destination handle for the duration + ** of the backup operation. Any attempt to use the destination + ** database connection while a backup is in progress may cause + ** a malfunction or a deadlock. + */ + sqlite3_mutex_enter( pSrcDb.mutex ); + sqlite3_mutex_enter( pDestDb.mutex ); + + if ( pSrcDb == pDestDb ) + { + sqlite3Error( + pDestDb, SQLITE_ERROR, "source and destination must be distinct" + ); + p = null; + } + else + { + /* Allocate space for a new sqlite3_backup object... + ** EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a + ** call to sqlite3_backup_init() and is destroyed by a call to + ** sqlite3_backup_finish(). */ + p = new sqlite3_backup();// (sqlite3_backup)sqlite3_malloc( sizeof( sqlite3_backup ) ); + //if ( null == p ) + //{ + // sqlite3Error( pDestDb, SQLITE_NOMEM, 0 ); + //} + } + + /* If the allocation succeeded, populate the new object. */ + if ( p != null ) + { + // memset( p, 0, sizeof( sqlite3_backup ) ); + p.pSrc = findBtree( pDestDb, pSrcDb, zSrcDb ); + p.pDest = findBtree( pDestDb, pDestDb, zDestDb ); + p.pDestDb = pDestDb; + p.pSrcDb = pSrcDb; + p.iNext = 1; + p.isAttached = 0; + + if ( null == p.pSrc || null == p.pDest || setDestPgsz( p ) == SQLITE_NOMEM ) + { + /* One (or both) of the named databases did not exist or an OOM + ** error was hit. The error has already been written into the + ** pDestDb handle. All that is left to do here is free the + ** sqlite3_backup structure. + */ + //sqlite3_free( ref p ); + p = null; + } + } + + if ( p != null ) + { + p.pSrc.nBackup++; + } + + sqlite3_mutex_leave( pDestDb.mutex ); + sqlite3_mutex_leave( pSrcDb.mutex ); + return p; +} + +/* +** Argument rc is an SQLite error code. Return true if this error is +** considered fatal if encountered during a backup operation. All errors +** are considered fatal except for SQLITE_BUSY and SQLITE_LOCKED. +*/ +static bool isFatalError( int rc ) +{ + return ( rc != SQLITE_OK && rc != SQLITE_BUSY && ALWAYS( rc != SQLITE_LOCKED ) ); +} + +/* +** Parameter zSrcData points to a buffer containing the data for +** page iSrcPg from the source database. Copy this data into the +** destination database. +*/ +static int backupOnePage( sqlite3_backup p, Pgno iSrcPg, byte[] zSrcData ) +{ + Pager pDestPager = sqlite3BtreePager( p.pDest ); + int nSrcPgsz = sqlite3BtreeGetPageSize( p.pSrc ); + int nDestPgsz = sqlite3BtreeGetPageSize( p.pDest ); + int nCopy = MIN( nSrcPgsz, nDestPgsz ); + i64 iEnd = (i64)iSrcPg * (i64)nSrcPgsz; #if SQLITE_HAS_CODEC int nSrcReserve = sqlite3BtreeGetReserve(p.pSrc); int nDestReserve = sqlite3BtreeGetReserve(p.pDest); #endif - int rc = SQLITE_OK; - i64 iOff; + int rc = SQLITE_OK; + i64 iOff; - Debug.Assert(p.bDestLocked != 0); - Debug.Assert(!isFatalError(p.rc)); - Debug.Assert(iSrcPg != PENDING_BYTE_PAGE(p.pSrc.pBt)); - Debug.Assert(zSrcData != null); + Debug.Assert( p.bDestLocked != 0 ); + Debug.Assert( !isFatalError( p.rc ) ); + Debug.Assert( iSrcPg != PENDING_BYTE_PAGE( p.pSrc.pBt ) ); + Debug.Assert( zSrcData != null ); - /* Catch the case where the destination is an in-memory database and the - ** page sizes of the source and destination differ. - */ - if (nSrcPgsz != nDestPgsz && sqlite3PagerIsMemdb(pDestPager)) { - rc = SQLITE_READONLY; - } + /* Catch the case where the destination is an in-memory database and the + ** page sizes of the source and destination differ. + */ + if ( nSrcPgsz != nDestPgsz && sqlite3PagerIsMemdb( pDestPager ) ) + { + rc = SQLITE_READONLY; + } #if SQLITE_HAS_CODEC /* Backup is not possible if the page size of the destination is changing @@ -282,456 +308,511 @@ static int backupOnePage(sqlite3_backup p, Pgno iSrcPg, byte[] zSrcData) { } #endif - /* This loop runs once for each destination page spanned by the source - ** page. For each iteration, variable iOff is set to the byte offset - ** of the destination page. - */ - for (iOff = iEnd - (i64)nSrcPgsz; rc == SQLITE_OK && iOff < iEnd; iOff += nDestPgsz) { - DbPage pDestPg = null; - u32 iDest = (u32)(iOff / nDestPgsz) + 1; - if (iDest == PENDING_BYTE_PAGE(p.pDest.pBt)) - continue; - if (SQLITE_OK == (rc = sqlite3PagerGet(pDestPager, iDest, ref pDestPg)) - && SQLITE_OK == (rc = sqlite3PagerWrite(pDestPg)) - ) { - //string zIn = &zSrcData[iOff%nSrcPgsz]; - byte[] zDestData = sqlite3PagerGetData(pDestPg); - //string zOut = &zDestData[iOff % nDestPgsz]; - - /* Copy the data from the source page into the destination page. - ** Then clear the Btree layer MemPage.isInit flag. Both this module - ** and the pager code use this trick (clearing the first byte - ** of the page 'extra' space to invalidate the Btree layers - ** cached parse of the page). MemPage.isInit is marked - ** "MUST BE FIRST" for this purpose. - */ - Buffer.BlockCopy(zSrcData, (int)(iOff % nSrcPgsz), zDestData, (int)(iOff % nDestPgsz), nCopy);// memcpy( zOut, zIn, nCopy ); - sqlite3PagerGetExtra(pDestPg).isInit = 0;// ( sqlite3PagerGetExtra( pDestPg ) )[0] = 0; - } - sqlite3PagerUnref(pDestPg); - } - - return rc; + /* This loop runs once for each destination page spanned by the source + ** page. For each iteration, variable iOff is set to the byte offset + ** of the destination page. + */ + for ( iOff = iEnd - (i64)nSrcPgsz; rc == SQLITE_OK && iOff < iEnd; iOff += nDestPgsz ) + { + DbPage pDestPg = null; + u32 iDest = (u32)( iOff / nDestPgsz ) + 1; + if ( iDest == PENDING_BYTE_PAGE( p.pDest.pBt ) ) + continue; + if ( SQLITE_OK == ( rc = sqlite3PagerGet( pDestPager, iDest, ref pDestPg ) ) + && SQLITE_OK == ( rc = sqlite3PagerWrite( pDestPg ) ) + ) + { + //string zIn = &zSrcData[iOff%nSrcPgsz]; + byte[] zDestData = sqlite3PagerGetData( pDestPg ); + //string zOut = &zDestData[iOff % nDestPgsz]; + + /* Copy the data from the source page into the destination page. + ** Then clear the Btree layer MemPage.isInit flag. Both this module + ** and the pager code use this trick (clearing the first byte + ** of the page 'extra' space to invalidate the Btree layers + ** cached parse of the page). MemPage.isInit is marked + ** "MUST BE FIRST" for this purpose. + */ + Buffer.BlockCopy( zSrcData, (int)( iOff % nSrcPgsz ), zDestData, (int)( iOff % nDestPgsz ), nCopy );// memcpy( zOut, zIn, nCopy ); + sqlite3PagerGetExtra( pDestPg ).isInit = 0;// ( sqlite3PagerGetExtra( pDestPg ) )[0] = 0; + } + sqlite3PagerUnref( pDestPg ); + } + + return rc; +} + +/* +** If pFile is currently larger than iSize bytes, then truncate it to +** exactly iSize bytes. If pFile is not larger than iSize bytes, then +** this function is a no-op. +** +** Return SQLITE_OK if everything is successful, or an SQLite error +** code if an error occurs. +*/ +static int backupTruncateFile( sqlite3_file pFile, int iSize ) +{ + long iCurrent = 0; + int rc = sqlite3OsFileSize( pFile, ref iCurrent ); + if ( rc == SQLITE_OK && iCurrent > iSize ) + { + rc = sqlite3OsTruncate( pFile, iSize ); + } + return rc; +} + +/* +** Register this backup object with the associated source pager for +** callbacks when pages are changed or the cache invalidated. +*/ +static void attachBackupObject( sqlite3_backup p ) +{ + sqlite3_backup pp; + Debug.Assert( sqlite3BtreeHoldsMutex( p.pSrc ) ); + pp = sqlite3PagerBackupPtr( sqlite3BtreePager( p.pSrc ) ); + p.pNext = pp; + sqlite3BtreePager( p.pSrc ).pBackup = p; //*pp = p; + p.isAttached = 1; +} + +/* +** Copy nPage pages from the source b-tree to the destination. +*/ +static public int sqlite3_backup_step( sqlite3_backup p, int nPage ) +{ + int rc; + int destMode; /* Destination journal mode */ + int pgszSrc = 0; /* Source page size */ + int pgszDest = 0; /* Destination page size */ + + sqlite3_mutex_enter( p.pSrcDb.mutex ); + sqlite3BtreeEnter( p.pSrc ); + if ( p.pDestDb != null ) + { + sqlite3_mutex_enter( p.pDestDb.mutex ); + } + + rc = p.rc; + if ( !isFatalError( rc ) ) + { + Pager pSrcPager = sqlite3BtreePager( p.pSrc ); /* Source pager */ + Pager pDestPager = sqlite3BtreePager( p.pDest ); /* Dest pager */ + int ii; /* Iterator variable */ + Pgno nSrcPage = 0; /* Size of source db in pages */ + int bCloseTrans = 0; /* True if src db requires unlocking */ + + /* If the source pager is currently in a write-transaction, return + ** SQLITE_BUSY immediately. + */ + if ( p.pDestDb != null && p.pSrc.pBt.inTransaction == TRANS_WRITE ) + { + rc = SQLITE_BUSY; + } + else + { + rc = SQLITE_OK; + } + + /* Lock the destination database, if it is not locked already. */ + if ( SQLITE_OK == rc && p.bDestLocked == 0 + && SQLITE_OK == ( rc = sqlite3BtreeBeginTrans( p.pDest, 2 ) ) + ) + { + p.bDestLocked = 1; + sqlite3BtreeGetMeta( p.pDest, BTREE_SCHEMA_VERSION, ref p.iDestSchema ); + } + + /* If there is no open read-transaction on the source database, open + ** one now. If a transaction is opened here, then it will be closed + ** before this function exits. + */ + if ( rc == SQLITE_OK && !sqlite3BtreeIsInReadTrans( p.pSrc ) ) + { + rc = sqlite3BtreeBeginTrans( p.pSrc, 0 ); + bCloseTrans = 1; + } + + /* Do not allow backup if the destination database is in WAL mode + ** and the page sizes are different between source and destination */ + pgszSrc = sqlite3BtreeGetPageSize( p.pSrc ); + pgszDest = sqlite3BtreeGetPageSize( p.pDest ); + destMode = sqlite3PagerGetJournalMode( sqlite3BtreePager( p.pDest ) ); + if ( SQLITE_OK == rc && destMode == PAGER_JOURNALMODE_WAL && pgszSrc != pgszDest ) + { + rc = SQLITE_READONLY; + } + + /* Now that there is a read-lock on the source database, query the + ** source pager for the number of pages in the database. + */ + nSrcPage = sqlite3BtreeLastPage( p.pSrc ); + Debug.Assert( nSrcPage >= 0 ); + + for ( ii = 0; ( nPage < 0 || ii < nPage ) && p.iNext <= nSrcPage && 0 == rc; ii++ ) + { + Pgno iSrcPg = p.iNext; /* Source page number */ + if ( iSrcPg != PENDING_BYTE_PAGE( p.pSrc.pBt ) ) + { + DbPage pSrcPg = null; /* Source page object */ + rc = sqlite3PagerGet( pSrcPager, (u32)iSrcPg, ref pSrcPg ); + if ( rc == SQLITE_OK ) + { + rc = backupOnePage( p, iSrcPg, sqlite3PagerGetData( pSrcPg ) ); + sqlite3PagerUnref( pSrcPg ); } + } + p.iNext++; + } + if ( rc == SQLITE_OK ) + { + p.nPagecount = nSrcPage; + p.nRemaining = ( nSrcPage + 1 - p.iNext ); + if ( p.iNext > nSrcPage ) + { + rc = SQLITE_DONE; + } + else if ( 0 == p.isAttached ) + { + attachBackupObject( p ); + } + } + - /* - ** If pFile is currently larger than iSize bytes, then truncate it to - ** exactly iSize bytes. If pFile is not larger than iSize bytes, then - ** this function is a no-op. + /* Update the schema version field in the destination database. This + ** is to make sure that the schema-version really does change in + ** the case where the source and destination databases have the + ** same schema version. + */ + if ( rc == SQLITE_DONE + && ( rc = sqlite3BtreeUpdateMeta( p.pDest, 1, p.iDestSchema + 1 ) ) == SQLITE_OK + ) + { + Pgno nDestTruncate; + if ( p.pDestDb != null ) + { + sqlite3ResetInternalSchema( p.pDestDb, -1 ); + } + + /* Set nDestTruncate to the final number of pages in the destination + ** database. The complication here is that the destination page + ** size may be different to the source page size. + ** + ** If the source page size is smaller than the destination page size, + ** round up. In this case the call to sqlite3OsTruncate() below will + ** fix the size of the file. However it is important to call + ** sqlite3PagerTruncateImage() here so that any pages in the + ** destination file that lie beyond the nDestTruncate page mark are + ** journalled by PagerCommitPhaseOne() before they are destroyed + ** by the file truncation. + */ + Debug.Assert( pgszSrc == sqlite3BtreeGetPageSize( p.pSrc ) ); + Debug.Assert( pgszDest == sqlite3BtreeGetPageSize( p.pDest ) ); + if ( pgszSrc < pgszDest ) + { + int ratio = pgszDest / pgszSrc; + nDestTruncate = (Pgno)( ( nSrcPage + ratio - 1 ) / ratio ); + if ( nDestTruncate == (int)PENDING_BYTE_PAGE( p.pDest.pBt ) ) + { + nDestTruncate--; + } + } + else + { + nDestTruncate = (Pgno)( nSrcPage * ( pgszSrc / pgszDest ) ); + } + sqlite3PagerTruncateImage( pDestPager, nDestTruncate ); + + if ( pgszSrc < pgszDest ) + { + /* If the source page-size is smaller than the destination page-size, + ** two extra things may need to happen: + ** + ** * The destination may need to be truncated, and ** - ** Return SQLITE_OK if everything is successful, or an SQLite error - ** code if an error occurs. + ** * Data stored on the pages immediately following the + ** pending-byte page in the source database may need to be + ** copied into the destination database. */ - static int backupTruncateFile(sqlite3_file pFile, int iSize) { - long iCurrent = 0; - int rc = sqlite3OsFileSize(pFile, ref iCurrent); - if (rc == SQLITE_OK && iCurrent > iSize) { - rc = sqlite3OsTruncate(pFile, iSize); - } - return rc; + int iSize = (int)( pgszSrc * nSrcPage ); + sqlite3_file pFile = sqlite3PagerFile( pDestPager ); + i64 iOff; + i64 iEnd; + + Debug.Assert( pFile != null ); + Debug.Assert( (i64)nDestTruncate * (i64)pgszDest >= iSize || ( + nDestTruncate == (int)( PENDING_BYTE_PAGE( p.pDest.pBt ) - 1 ) + && iSize >= PENDING_BYTE && iSize <= PENDING_BYTE + pgszDest + ) ); + + /* This call ensures that all data required to recreate the original + ** database has been stored in the journal for pDestPager and the + ** journal synced to disk. So at this point we may safely modify + ** the database file in any way, knowing that if a power failure + ** occurs, the original database will be reconstructed from the + ** journal file. */ + rc = sqlite3PagerCommitPhaseOne( pDestPager, null, true ); + + /* Write the extra pages and truncate the database file as required. */ + iEnd = MIN( PENDING_BYTE + pgszDest, iSize ); + for ( + iOff = PENDING_BYTE + pgszSrc; + rc == SQLITE_OK && iOff < iEnd; + iOff += pgszSrc + ) + { + PgHdr pSrcPg = null; + u32 iSrcPg = (u32)( ( iOff / pgszSrc ) + 1 ); + rc = sqlite3PagerGet( pSrcPager, iSrcPg, ref pSrcPg ); + if ( rc == SQLITE_OK ) + { + byte[] zData = sqlite3PagerGetData( pSrcPg ); + rc = sqlite3OsWrite( pFile, zData, pgszSrc, iOff ); + } + sqlite3PagerUnref( pSrcPg ); + } + if ( rc == SQLITE_OK ) + { + rc = backupTruncateFile( pFile, (int)iSize ); } - /* - ** Register this backup object with the associated source pager for - ** callbacks when pages are changed or the cache invalidated. - */ - static void attachBackupObject(sqlite3_backup p) { - sqlite3_backup pp; - Debug.Assert(sqlite3BtreeHoldsMutex(p.pSrc)); - pp = sqlite3PagerBackupPtr(sqlite3BtreePager(p.pSrc)); - p.pNext = pp; - sqlite3BtreePager(p.pSrc).pBackup = p; //*pp = p; - p.isAttached = 1; + /* Sync the database file to disk. */ + if ( rc == SQLITE_OK ) + { + rc = sqlite3PagerSync( pDestPager ); } + } + else + { + rc = sqlite3PagerCommitPhaseOne( pDestPager, null, false ); + } + + /* Finish committing the transaction to the destination database. */ + if ( SQLITE_OK == rc + && SQLITE_OK == ( rc = sqlite3BtreeCommitPhaseTwo( p.pDest, 0 ) ) + ) + { + rc = SQLITE_DONE; + } + } - /* - ** Copy nPage pages from the source b-tree to the destination. - */ - static public int sqlite3_backup_step(sqlite3_backup p, int nPage) { - int rc; - int destMode; /* Destination journal mode */ - int pgszSrc = 0; /* Source page size */ - int pgszDest = 0; /* Destination page size */ - - sqlite3_mutex_enter(p.pSrcDb.mutex); - sqlite3BtreeEnter(p.pSrc); - if (p.pDestDb != null) { - sqlite3_mutex_enter(p.pDestDb.mutex); - } - - rc = p.rc; - if (!isFatalError(rc)) { - Pager pSrcPager = sqlite3BtreePager(p.pSrc); /* Source pager */ - Pager pDestPager = sqlite3BtreePager(p.pDest); /* Dest pager */ - int ii; /* Iterator variable */ - Pgno nSrcPage = 0; /* Size of source db in pages */ - int bCloseTrans = 0; /* True if src db requires unlocking */ - - /* If the source pager is currently in a write-transaction, return - ** SQLITE_BUSY immediately. - */ - if (p.pDestDb != null && p.pSrc.pBt.inTransaction == TRANS_WRITE) { - rc = SQLITE_BUSY; - } else { - rc = SQLITE_OK; - } - - /* Lock the destination database, if it is not locked already. */ - if (SQLITE_OK == rc && p.bDestLocked == 0 - && SQLITE_OK == (rc = sqlite3BtreeBeginTrans(p.pDest, 2)) - ) { - p.bDestLocked = 1; - sqlite3BtreeGetMeta(p.pDest, BTREE_SCHEMA_VERSION, ref p.iDestSchema); - } - - /* If there is no open read-transaction on the source database, open - ** one now. If a transaction is opened here, then it will be closed - ** before this function exits. - */ - if (rc == SQLITE_OK && !sqlite3BtreeIsInReadTrans(p.pSrc)) { - rc = sqlite3BtreeBeginTrans(p.pSrc, 0); - bCloseTrans = 1; - } - - /* Do not allow backup if the destination database is in WAL mode - ** and the page sizes are different between source and destination */ - pgszSrc = sqlite3BtreeGetPageSize(p.pSrc); - pgszDest = sqlite3BtreeGetPageSize(p.pDest); - destMode = sqlite3PagerGetJournalMode(sqlite3BtreePager(p.pDest)); - if (SQLITE_OK == rc && destMode == PAGER_JOURNALMODE_WAL && pgszSrc != pgszDest) { - rc = SQLITE_READONLY; - } - - /* Now that there is a read-lock on the source database, query the - ** source pager for the number of pages in the database. - */ - nSrcPage = sqlite3BtreeLastPage(p.pSrc); - Debug.Assert(nSrcPage >= 0); - - for (ii = 0; (nPage < 0 || ii < nPage) && p.iNext <= nSrcPage && 0 == rc; ii++) { - Pgno iSrcPg = p.iNext; /* Source page number */ - if (iSrcPg != PENDING_BYTE_PAGE(p.pSrc.pBt)) { - DbPage pSrcPg = null; /* Source page object */ - rc = sqlite3PagerGet(pSrcPager, (u32)iSrcPg, ref pSrcPg); - if (rc == SQLITE_OK) { - rc = backupOnePage(p, iSrcPg, sqlite3PagerGetData(pSrcPg)); - sqlite3PagerUnref(pSrcPg); - } - } - p.iNext++; - } - if (rc == SQLITE_OK) { - p.nPagecount = nSrcPage; - p.nRemaining = (nSrcPage + 1 - p.iNext); - if (p.iNext > nSrcPage) { - rc = SQLITE_DONE; - } else if (0 == p.isAttached) { - attachBackupObject(p); - } - } - - - /* Update the schema version field in the destination database. This - ** is to make sure that the schema-version really does change in - ** the case where the source and destination databases have the - ** same schema version. - */ - if (rc == SQLITE_DONE - && (rc = sqlite3BtreeUpdateMeta(p.pDest, 1, p.iDestSchema + 1)) == SQLITE_OK - ) { - Pgno nDestTruncate; - if (p.pDestDb != null) { - sqlite3ResetInternalSchema(p.pDestDb, -1); - } - - /* Set nDestTruncate to the final number of pages in the destination - ** database. The complication here is that the destination page - ** size may be different to the source page size. - ** - ** If the source page size is smaller than the destination page size, - ** round up. In this case the call to sqlite3OsTruncate() below will - ** fix the size of the file. However it is important to call - ** sqlite3PagerTruncateImage() here so that any pages in the - ** destination file that lie beyond the nDestTruncate page mark are - ** journalled by PagerCommitPhaseOne() before they are destroyed - ** by the file truncation. - */ - Debug.Assert(pgszSrc == sqlite3BtreeGetPageSize(p.pSrc)); - Debug.Assert(pgszDest == sqlite3BtreeGetPageSize(p.pDest)); - if (pgszSrc < pgszDest) { - int ratio = pgszDest / pgszSrc; - nDestTruncate = (Pgno)((nSrcPage + ratio - 1) / ratio); - if (nDestTruncate == (int)PENDING_BYTE_PAGE(p.pDest.pBt)) { - nDestTruncate--; - } - } else { - nDestTruncate = (Pgno)(nSrcPage * (pgszSrc / pgszDest)); - } - sqlite3PagerTruncateImage(pDestPager, nDestTruncate); - - if (pgszSrc < pgszDest) { - /* If the source page-size is smaller than the destination page-size, - ** two extra things may need to happen: - ** - ** * The destination may need to be truncated, and - ** - ** * Data stored on the pages immediately following the - ** pending-byte page in the source database may need to be - ** copied into the destination database. - */ - int iSize = (int)(pgszSrc * nSrcPage); - sqlite3_file pFile = sqlite3PagerFile(pDestPager); - i64 iOff; - i64 iEnd; - - Debug.Assert(pFile != null); - Debug.Assert((i64)nDestTruncate * (i64)pgszDest >= iSize || ( - nDestTruncate == (int)(PENDING_BYTE_PAGE(p.pDest.pBt) - 1) - && iSize >= PENDING_BYTE && iSize <= PENDING_BYTE + pgszDest - )); - - /* This call ensures that all data required to recreate the original - ** database has been stored in the journal for pDestPager and the - ** journal synced to disk. So at this point we may safely modify - ** the database file in any way, knowing that if a power failure - ** occurs, the original database will be reconstructed from the - ** journal file. */ - rc = sqlite3PagerCommitPhaseOne(pDestPager, null, true); - - /* Write the extra pages and truncate the database file as required. */ - iEnd = MIN(PENDING_BYTE + pgszDest, iSize); - for ( - iOff = PENDING_BYTE + pgszSrc; - rc == SQLITE_OK && iOff < iEnd; - iOff += pgszSrc - ) { - PgHdr pSrcPg = null; - u32 iSrcPg = (u32)((iOff / pgszSrc) + 1); - rc = sqlite3PagerGet(pSrcPager, iSrcPg, ref pSrcPg); - if (rc == SQLITE_OK) { - byte[] zData = sqlite3PagerGetData(pSrcPg); - rc = sqlite3OsWrite(pFile, zData, pgszSrc, iOff); - } - sqlite3PagerUnref(pSrcPg); - } - if (rc == SQLITE_OK) { - rc = backupTruncateFile(pFile, (int)iSize); - } - - /* Sync the database file to disk. */ - if (rc == SQLITE_OK) { - rc = sqlite3PagerSync(pDestPager); - } - } else { - rc = sqlite3PagerCommitPhaseOne(pDestPager, null, false); - } - - /* Finish committing the transaction to the destination database. */ - if (SQLITE_OK == rc - && SQLITE_OK == (rc = sqlite3BtreeCommitPhaseTwo(p.pDest, 0)) - ) { - rc = SQLITE_DONE; - } - } - - /* If bCloseTrans is true, then this function opened a read transaction - ** on the source database. Close the read transaction here. There is - ** no need to check the return values of the btree methods here, as - ** "committing" a read-only transaction cannot fail. - */ - if (bCloseTrans != 0) { + /* If bCloseTrans is true, then this function opened a read transaction + ** on the source database. Close the read transaction here. There is + ** no need to check the return values of the btree methods here, as + ** "committing" a read-only transaction cannot fail. + */ + if ( bCloseTrans != 0 ) + { #if !NDEBUG || SQLITE_COVERAGE_TEST - //TESTONLY( int rc2 ); - //TESTONLY( rc2 = ) sqlite3BtreeCommitPhaseOne(p.pSrc, 0); - //TESTONLY( rc2 |= ) sqlite3BtreeCommitPhaseTwo(p.pSrc); - int rc2; - rc2 = sqlite3BtreeCommitPhaseOne(p.pSrc, ""); - rc2 |= sqlite3BtreeCommitPhaseTwo(p.pSrc, 0); - Debug.Assert(rc2 == SQLITE_OK); + //TESTONLY( int rc2 ); + //TESTONLY( rc2 = ) sqlite3BtreeCommitPhaseOne(p.pSrc, 0); + //TESTONLY( rc2 |= ) sqlite3BtreeCommitPhaseTwo(p.pSrc); + int rc2; + rc2 = sqlite3BtreeCommitPhaseOne( p.pSrc, "" ); + rc2 |= sqlite3BtreeCommitPhaseTwo( p.pSrc, 0 ); + Debug.Assert( rc2 == SQLITE_OK ); #else sqlite3BtreeCommitPhaseOne(p.pSrc, null); sqlite3BtreeCommitPhaseTwo(p.pSrc, 0); #endif - } - - if (rc == SQLITE_IOERR_NOMEM) { - rc = SQLITE_NOMEM; - } - p.rc = rc; - } - if (p.pDestDb != null) { - sqlite3_mutex_leave(p.pDestDb.mutex); - } - sqlite3BtreeLeave(p.pSrc); - sqlite3_mutex_leave(p.pSrcDb.mutex); - return rc; - } + } - /* - ** Release all resources associated with an sqlite3_backup* handle. - */ - static public int sqlite3_backup_finish(sqlite3_backup p) { - sqlite3_backup pp; /* Ptr to head of pagers backup list */ - sqlite3_mutex mutex; /* Mutex to protect source database */ - int rc; /* Value to return */ - - /* Enter the mutexes */ - if (p == null) - return SQLITE_OK; - sqlite3_mutex_enter(p.pSrcDb.mutex); - sqlite3BtreeEnter(p.pSrc); - mutex = p.pSrcDb.mutex; - if (p.pDestDb != null) { - sqlite3_mutex_enter(p.pDestDb.mutex); - } - - /* Detach this backup from the source pager. */ - if (p.pDestDb != null) { - p.pSrc.nBackup--; - } - if (p.isAttached != 0) { - pp = sqlite3PagerBackupPtr(sqlite3BtreePager(p.pSrc)); - while (pp != p) { - pp = (pp).pNext; - } - sqlite3BtreePager(p.pSrc).pBackup = p.pNext; - } - - /* If a transaction is still open on the Btree, roll it back. */ - sqlite3BtreeRollback(p.pDest); - - /* Set the error code of the destination database handle. */ - rc = (p.rc == SQLITE_DONE) ? SQLITE_OK : p.rc; - sqlite3Error(p.pDestDb, rc, 0); - - /* Exit the mutexes and free the backup context structure. */ - if (p.pDestDb != null) { - sqlite3_mutex_leave(p.pDestDb.mutex); - } - sqlite3BtreeLeave(p.pSrc); - if (p.pDestDb != null) { - /* EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a - ** call to sqlite3_backup_init() and is destroyed by a call to - ** sqlite3_backup_finish(). */ - //sqlite3_free( ref p ); - } - sqlite3_mutex_leave(mutex); - return rc; - } + if ( rc == SQLITE_IOERR_NOMEM ) + { + rc = SQLITE_NOMEM; + } + p.rc = rc; + } + if ( p.pDestDb != null ) + { + sqlite3_mutex_leave( p.pDestDb.mutex ); + } + sqlite3BtreeLeave( p.pSrc ); + sqlite3_mutex_leave( p.pSrcDb.mutex ); + return rc; +} - /* - ** Return the number of pages still to be backed up as of the most recent - ** call to sqlite3_backup_step(). - */ - static int sqlite3_backup_remaining(sqlite3_backup p) { - return (int)p.nRemaining; - } +/* +** Release all resources associated with an sqlite3_backup* handle. +*/ +static public int sqlite3_backup_finish( sqlite3_backup p ) +{ + sqlite3_backup pp; /* Ptr to head of pagers backup list */ + sqlite3_mutex mutex; /* Mutex to protect source database */ + int rc; /* Value to return */ + + /* Enter the mutexes */ + if ( p == null ) + return SQLITE_OK; + sqlite3_mutex_enter( p.pSrcDb.mutex ); + sqlite3BtreeEnter( p.pSrc ); + mutex = p.pSrcDb.mutex; + if ( p.pDestDb != null ) + { + sqlite3_mutex_enter( p.pDestDb.mutex ); + } - /* - ** Return the total number of pages in the source database as of the most - ** recent call to sqlite3_backup_step(). - */ - static int sqlite3_backup_pagecount(sqlite3_backup p) { - return (int)p.nPagecount; - } + /* Detach this backup from the source pager. */ + if ( p.pDestDb != null ) + { + p.pSrc.nBackup--; + } + if ( p.isAttached != 0 ) + { + pp = sqlite3PagerBackupPtr( sqlite3BtreePager( p.pSrc ) ); + while ( pp != p ) + { + pp = ( pp ).pNext; + } + sqlite3BtreePager( p.pSrc ).pBackup = p.pNext; + } - /* - ** This function is called after the contents of page iPage of the - ** source database have been modified. If page iPage has already been - ** copied into the destination database, then the data written to the - ** destination is now invalidated. The destination copy of iPage needs - ** to be updated with the new data before the backup operation is - ** complete. - ** - ** It is assumed that the mutex associated with the BtShared object - ** corresponding to the source database is held when this function is - ** called. - */ - static void sqlite3BackupUpdate(sqlite3_backup pBackup, Pgno iPage, byte[] aData) { - sqlite3_backup p; /* Iterator variable */ - for (p = pBackup; p != null; p = p.pNext) { - Debug.Assert(sqlite3_mutex_held(p.pSrc.pBt.mutex)); - if (!isFatalError(p.rc) && iPage < p.iNext) { - /* The backup process p has already copied page iPage. But now it - ** has been modified by a transaction on the source pager. Copy - ** the new data into the backup. - */ - int rc; - Debug.Assert(p.pDestDb != null); - sqlite3_mutex_enter(p.pDestDb.mutex); - rc = backupOnePage(p, iPage, aData); - sqlite3_mutex_leave(p.pDestDb.mutex); - Debug.Assert(rc != SQLITE_BUSY && rc != SQLITE_LOCKED); - if (rc != SQLITE_OK) { - p.rc = rc; - } - } - } - } + /* If a transaction is still open on the Btree, roll it back. */ + sqlite3BtreeRollback( p.pDest ); - /* - ** Restart the backup process. This is called when the pager layer - ** detects that the database has been modified by an external database - ** connection. In this case there is no way of knowing which of the - ** pages that have been copied into the destination database are still - ** valid and which are not, so the entire process needs to be restarted. - ** - ** It is assumed that the mutex associated with the BtShared object - ** corresponding to the source database is held when this function is - ** called. - */ - static void sqlite3BackupRestart(sqlite3_backup pBackup) { - sqlite3_backup p; /* Iterator variable */ - for (p = pBackup; p != null; p = p.pNext) { - Debug.Assert(sqlite3_mutex_held(p.pSrc.pBt.mutex)); - p.iNext = 1; - } - } + /* Set the error code of the destination database handle. */ + rc = ( p.rc == SQLITE_DONE ) ? SQLITE_OK : p.rc; + sqlite3Error( p.pDestDb, rc, 0 ); + + /* Exit the mutexes and free the backup context structure. */ + if ( p.pDestDb != null ) + { + sqlite3_mutex_leave( p.pDestDb.mutex ); + } + sqlite3BtreeLeave( p.pSrc ); + if ( p.pDestDb != null ) + { + /* EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a + ** call to sqlite3_backup_init() and is destroyed by a call to + ** sqlite3_backup_finish(). */ + //sqlite3_free( ref p ); + } + sqlite3_mutex_leave( mutex ); + return rc; +} + +/* +** Return the number of pages still to be backed up as of the most recent +** call to sqlite3_backup_step(). +*/ +static int sqlite3_backup_remaining( sqlite3_backup p ) +{ + return (int)p.nRemaining; +} + +/* +** Return the total number of pages in the source database as of the most +** recent call to sqlite3_backup_step(). +*/ +static int sqlite3_backup_pagecount( sqlite3_backup p ) +{ + return (int)p.nPagecount; +} + +/* +** This function is called after the contents of page iPage of the +** source database have been modified. If page iPage has already been +** copied into the destination database, then the data written to the +** destination is now invalidated. The destination copy of iPage needs +** to be updated with the new data before the backup operation is +** complete. +** +** It is assumed that the mutex associated with the BtShared object +** corresponding to the source database is held when this function is +** called. +*/ +static void sqlite3BackupUpdate( sqlite3_backup pBackup, Pgno iPage, byte[] aData ) +{ + sqlite3_backup p; /* Iterator variable */ + for ( p = pBackup; p != null; p = p.pNext ) + { + Debug.Assert( sqlite3_mutex_held( p.pSrc.pBt.mutex ) ); + if ( !isFatalError( p.rc ) && iPage < p.iNext ) + { + /* The backup process p has already copied page iPage. But now it + ** has been modified by a transaction on the source pager. Copy + ** the new data into the backup. + */ + int rc; + Debug.Assert( p.pDestDb != null ); + sqlite3_mutex_enter( p.pDestDb.mutex ); + rc = backupOnePage( p, iPage, aData ); + sqlite3_mutex_leave( p.pDestDb.mutex ); + Debug.Assert( rc != SQLITE_BUSY && rc != SQLITE_LOCKED ); + if ( rc != SQLITE_OK ) + { + p.rc = rc; + } + } + } +} + +/* +** Restart the backup process. This is called when the pager layer +** detects that the database has been modified by an external database +** connection. In this case there is no way of knowing which of the +** pages that have been copied into the destination database are still +** valid and which are not, so the entire process needs to be restarted. +** +** It is assumed that the mutex associated with the BtShared object +** corresponding to the source database is held when this function is +** called. +*/ +static void sqlite3BackupRestart( sqlite3_backup pBackup ) +{ + sqlite3_backup p; /* Iterator variable */ + for ( p = pBackup; p != null; p = p.pNext ) + { + Debug.Assert( sqlite3_mutex_held( p.pSrc.pBt.mutex ) ); + p.iNext = 1; + } +} #if !SQLITE_OMIT_VACUUM - /* - ** Copy the complete content of pBtFrom into pBtTo. A transaction - ** must be active for both files. - ** - ** The size of file pTo may be reduced by this operation. If anything - ** goes wrong, the transaction on pTo is rolled back. If successful, the - ** transaction is committed before returning. - */ - static int sqlite3BtreeCopyFile(Btree pTo, Btree pFrom) { - int rc; - sqlite3_backup b; - sqlite3BtreeEnter(pTo); - sqlite3BtreeEnter(pFrom); - - /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set - ** to 0. This is used by the implementations of sqlite3_backup_step() - ** and sqlite3_backup_finish() to detect that they are being called - ** from this function, not directly by the user. - */ - b = new sqlite3_backup();// memset( &b, 0, sizeof( b ) ); - b.pSrcDb = pFrom.db; - b.pSrc = pFrom; - b.pDest = pTo; - b.iNext = 1; - - /* 0x7FFFFFFF is the hard limit for the number of pages in a database - ** file. By passing this as the number of pages to copy to - ** sqlite3_backup_step(), we can guarantee that the copy finishes - ** within a single call (unless an error occurs). The Debug.Assert() statement - ** checks this assumption - (p.rc) should be set to either SQLITE_DONE - ** or an error code. - */ - sqlite3_backup_step(b, 0x7FFFFFFF); - Debug.Assert(b.rc != SQLITE_OK); - rc = sqlite3_backup_finish(b); - if (rc == SQLITE_OK) { - pTo.pBt.pageSizeFixed = false; - } - - sqlite3BtreeLeave(pFrom); - sqlite3BtreeLeave(pTo); - return rc; - } +/* +** Copy the complete content of pBtFrom into pBtTo. A transaction +** must be active for both files. +** +** The size of file pTo may be reduced by this operation. If anything +** goes wrong, the transaction on pTo is rolled back. If successful, the +** transaction is committed before returning. +*/ +static int sqlite3BtreeCopyFile( Btree pTo, Btree pFrom ) +{ + int rc; + sqlite3_backup b; + sqlite3BtreeEnter( pTo ); + sqlite3BtreeEnter( pFrom ); + + /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set + ** to 0. This is used by the implementations of sqlite3_backup_step() + ** and sqlite3_backup_finish() to detect that they are being called + ** from this function, not directly by the user. + */ + b = new sqlite3_backup();// memset( &b, 0, sizeof( b ) ); + b.pSrcDb = pFrom.db; + b.pSrc = pFrom; + b.pDest = pTo; + b.iNext = 1; + + /* 0x7FFFFFFF is the hard limit for the number of pages in a database + ** file. By passing this as the number of pages to copy to + ** sqlite3_backup_step(), we can guarantee that the copy finishes + ** within a single call (unless an error occurs). The Debug.Assert() statement + ** checks this assumption - (p.rc) should be set to either SQLITE_DONE + ** or an error code. + */ + sqlite3_backup_step( b, 0x7FFFFFFF ); + Debug.Assert( b.rc != SQLITE_OK ); + rc = sqlite3_backup_finish( b ); + if ( rc == SQLITE_OK ) + { + pTo.pBt.pageSizeFixed = false; + } + + sqlite3BtreeLeave( pFrom ); + sqlite3BtreeLeave( pTo ); + return rc; +} #endif //* SQLITE_OMIT_VACUUM */ - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/bitvec_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/bitvec_c.cs index 7df896883..6b7414ba0 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/bitvec_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/bitvec_c.cs @@ -1,479 +1,534 @@ using System; using System.Diagnostics; +using System.Runtime.InteropServices; -using BITVEC_TELEM = System.Byte; +using Pgno = System.UInt32; using i64 = System.Int64; using u32 = System.UInt32; +using BITVEC_TELEM = System.Byte; -namespace Community.CsharpSqlite { - - public partial class Sqlite3 { - /* - ** 2008 February 16 - ** - ** 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 implements an object that represents a fixed-length - ** bitmap. Bits are numbered starting with 1. - ** - ** A bitmap is used to record which pages of a database file have been - ** journalled during a transaction, or which pages have the "dont-write" - ** property. Usually only a few pages are meet either condition. - ** So the bitmap is usually sparse and has low cardinality. - ** But sometimes (for example when during a DROP of a large table) most - ** or all of the pages in a database can get journalled. In those cases, - ** the bitmap becomes dense with high cardinality. The algorithm needs - ** to handle both cases well. - ** - ** The size of the bitmap is fixed when the object is created. - ** - ** All bits are clear when the bitmap is created. Individual bits - ** may be set or cleared one at a time. - ** - ** Test operations are about 100 times more common that set operations. - ** Clear operations are exceedingly rare. There are usually between - ** 5 and 500 set operations per Bitvec object, though the number of sets can - ** sometimes grow into tens of thousands or larger. The size of the - ** Bitvec object is the number of pages in the database file at the - ** start of a transaction, and is thus usually less than a few thousand, - ** but can be as large as 2 billion for a really big database. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - - /* Size of the Bitvec structure in bytes. */ - static int BITVEC_SZ = 512; - - - /* Round the union size down to the nearest pointer boundary, since that's how - ** it will be aligned within the Bitvec struct. */ - //#define BITVEC_USIZE (((BITVEC_SZ-(3*sizeof(u32)))/sizeof(Bitvec*))*sizeof(Bitvec*)) - static int BITVEC_USIZE = (((BITVEC_SZ - (3 * sizeof(u32))) / 4) * 4); - - /* Type of the array "element" for the bitmap representation. - ** Should be a power of 2, and ideally, evenly divide into BITVEC_USIZE. - ** Setting this to the "natural word" size of your CPU may improve - ** performance. */ - //#define BITVEC_TELEM u8 - //using BITVEC_TELEM = System.Byte; - - /* Size, in bits, of the bitmap element. */ - //#define BITVEC_SZELEM 8 - const int BITVEC_SZELEM = 8; - - /* Number of elements in a bitmap array. */ - //#define BITVEC_NELEM (BITVEC_USIZE/sizeof(BITVEC_TELEM)) - static int BITVEC_NELEM = (int)(BITVEC_USIZE / sizeof(BITVEC_TELEM)); - - /* Number of bits in the bitmap array. */ - //#define BITVEC_NBIT (BITVEC_NELEM*BITVEC_SZELEM) - static int BITVEC_NBIT = (BITVEC_NELEM * BITVEC_SZELEM); - - /* Number of u32 values in hash table. */ - //#define BITVEC_NINT (BITVEC_USIZE/sizeof(u32)) - static u32 BITVEC_NINT = (u32)(BITVEC_USIZE / sizeof(u32)); - - /* Maximum number of entries in hash table before - ** sub-dividing and re-hashing. */ - //#define BITVEC_MXHASH (BITVEC_NINT/2) - static int BITVEC_MXHASH = (int)(BITVEC_NINT / 2); - - /* Hashing function for the aHash representation. - ** Empirical testing showed that the *37 multiplier - ** (an arbitrary prime)in the hash function provided - ** no fewer collisions than the no-op *1. */ - //#define BITVEC_HASH(X) (((X)*1)%BITVEC_NINT) - static u32 BITVEC_HASH(u32 X) { - return (u32)(((X) * 1) % BITVEC_NINT); - } +namespace Community.CsharpSqlite +{ + + public partial class Sqlite3 + { +/* +** 2008 February 16 +** +** 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 implements an object that represents a fixed-length +** bitmap. Bits are numbered starting with 1. +** +** A bitmap is used to record which pages of a database file have been +** journalled during a transaction, or which pages have the "dont-write" +** property. Usually only a few pages are meet either condition. +** So the bitmap is usually sparse and has low cardinality. +** But sometimes (for example when during a DROP of a large table) most +** or all of the pages in a database can get journalled. In those cases, +** the bitmap becomes dense with high cardinality. The algorithm needs +** to handle both cases well. +** +** The size of the bitmap is fixed when the object is created. +** +** All bits are clear when the bitmap is created. Individual bits +** may be set or cleared one at a time. +** +** Test operations are about 100 times more common that set operations. +** Clear operations are exceedingly rare. There are usually between +** 5 and 500 set operations per Bitvec object, though the number of sets can +** sometimes grow into tens of thousands or larger. The size of the +** Bitvec object is the number of pages in the database file at the +** start of a transaction, and is thus usually less than a few thousand, +** but can be as large as 2 billion for a really big database. +************************************************************************* +** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart +** C#-SQLite is an independent reimplementation of the SQLite software library +** +** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 +** +************************************************************************* +*/ +//#include "sqliteInt.h" + +/* Size of the Bitvec structure in bytes. */ +static int BITVEC_SZ = 512; + + +/* Round the union size down to the nearest pointer boundary, since that's how +** it will be aligned within the Bitvec struct. */ +//#define BITVEC_USIZE (((BITVEC_SZ-(3*sizeof(u32)))/sizeof(Bitvec*))*sizeof(Bitvec*)) +static int BITVEC_USIZE = ( ( ( BITVEC_SZ - ( 3 * sizeof( u32 ) ) ) / 4 ) * 4 ); + +/* Type of the array "element" for the bitmap representation. +** Should be a power of 2, and ideally, evenly divide into BITVEC_USIZE. +** Setting this to the "natural word" size of your CPU may improve +** performance. */ +//#define BITVEC_TELEM u8 +//using BITVEC_TELEM = System.Byte; + +/* Size, in bits, of the bitmap element. */ +//#define BITVEC_SZELEM 8 +const int BITVEC_SZELEM = 8; + +/* Number of elements in a bitmap array. */ +//#define BITVEC_NELEM (BITVEC_USIZE/sizeof(BITVEC_TELEM)) +static int BITVEC_NELEM = (int)( BITVEC_USIZE / sizeof( BITVEC_TELEM ) ); + +/* Number of bits in the bitmap array. */ +//#define BITVEC_NBIT (BITVEC_NELEM*BITVEC_SZELEM) +static int BITVEC_NBIT = ( BITVEC_NELEM * BITVEC_SZELEM ); + +/* Number of u32 values in hash table. */ +//#define BITVEC_NINT (BITVEC_USIZE/sizeof(u32)) +static u32 BITVEC_NINT = (u32)( BITVEC_USIZE / sizeof( u32 ) ); + +/* Maximum number of entries in hash table before +** sub-dividing and re-hashing. */ +//#define BITVEC_MXHASH (BITVEC_NINT/2) +static int BITVEC_MXHASH = (int)( BITVEC_NINT / 2 ); + +/* Hashing function for the aHash representation. +** Empirical testing showed that the *37 multiplier +** (an arbitrary prime)in the hash function provided +** no fewer collisions than the no-op *1. */ +//#define BITVEC_HASH(X) (((X)*1)%BITVEC_NINT) +static u32 BITVEC_HASH( u32 X ) +{ + return (u32)( ( ( X ) * 1 ) % BITVEC_NINT ); +} - static int BITVEC_NPTR = (int)(BITVEC_USIZE / 4);//sizeof(Bitvec *)); - - - /* - ** A bitmap is an instance of the following structure. - ** - ** This bitmap records the existence of zero or more bits - ** with values between 1 and iSize, inclusive. - ** - ** There are three possible representations of the bitmap. - ** If iSize<=BITVEC_NBIT, then Bitvec.u.aBitmap[] is a straight - ** bitmap. The least significant bit is bit 1. - ** - ** If iSize>BITVEC_NBIT and iDivisor==0 then Bitvec.u.aHash[] is - ** a hash table that will hold up to BITVEC_MXHASH distinct values. - ** - ** Otherwise, the value i is redirected into one of BITVEC_NPTR - ** sub-bitmaps pointed to by Bitvec.u.apSub[]. Each subbitmap - ** handles up to iDivisor separate values of i. apSub[0] holds - ** values between 1 and iDivisor. apSub[1] holds values between - ** iDivisor+1 and 2*iDivisor. apSub[N] holds values between - ** N*iDivisor+1 and (N+1)*iDivisor. Each subbitmap is normalized - ** to hold deal with values between 1 and iDivisor. - */ - public class _u { - public BITVEC_TELEM[] aBitmap = new byte[BITVEC_NELEM]; /* Bitmap representation */ - public u32[] aHash = new u32[BITVEC_NINT]; /* Hash table representation */ - public Bitvec[] apSub = new Bitvec[BITVEC_NPTR]; /* Recursive representation */ - } - public class Bitvec { - public u32 iSize; /* Maximum bit index. Max iSize is 4,294,967,296. */ - public u32 nSet; /* Number of bits that are set - only valid for aHash +static int BITVEC_NPTR = (int)( BITVEC_USIZE / 4 );//sizeof(Bitvec *)); + + +/* +** A bitmap is an instance of the following structure. +** +** This bitmap records the existence of zero or more bits +** with values between 1 and iSize, inclusive. +** +** There are three possible representations of the bitmap. +** If iSize<=BITVEC_NBIT, then Bitvec.u.aBitmap[] is a straight +** bitmap. The least significant bit is bit 1. +** +** If iSize>BITVEC_NBIT and iDivisor==0 then Bitvec.u.aHash[] is +** a hash table that will hold up to BITVEC_MXHASH distinct values. +** +** Otherwise, the value i is redirected into one of BITVEC_NPTR +** sub-bitmaps pointed to by Bitvec.u.apSub[]. Each subbitmap +** handles up to iDivisor separate values of i. apSub[0] holds +** values between 1 and iDivisor. apSub[1] holds values between +** iDivisor+1 and 2*iDivisor. apSub[N] holds values between +** N*iDivisor+1 and (N+1)*iDivisor. Each subbitmap is normalized +** to hold deal with values between 1 and iDivisor. +*/ +public class _u +{ + public BITVEC_TELEM[] aBitmap = new byte[BITVEC_NELEM]; /* Bitmap representation */ + public u32[] aHash = new u32[BITVEC_NINT]; /* Hash table representation */ + public Bitvec[] apSub = new Bitvec[BITVEC_NPTR]; /* Recursive representation */ +} +public class Bitvec +{ + public u32 iSize; /* Maximum bit index. Max iSize is 4,294,967,296. */ + public u32 nSet; /* Number of bits that are set - only valid for aHash ** element. Max is BITVEC_NINT. For BITVEC_SZ of 512, ** this would be 125. */ - public u32 iDivisor; /* Number of bits handled by each apSub[] entry. */ - /* Should >=0 for apSub element. */ - /* Max iDivisor is max(u32) / BITVEC_NPTR + 1. */ - /* For a BITVEC_SZ of 512, this would be 34,359,739. */ - public _u u = new _u(); - - public static implicit operator bool(Bitvec b) { - return (b != null); - } - }; - - /* - ** Create a new bitmap object able to handle bits between 0 and iSize, - ** inclusive. Return a pointer to the new object. Return NULL if - ** malloc fails. - */ - static Bitvec sqlite3BitvecCreate(u32 iSize) { - Bitvec p; - //Debug.Assert( sizeof(p)==BITVEC_SZ ); - p = new Bitvec();//sqlite3MallocZero( sizeof(p) ); - if (p != null) { - p.iSize = iSize; - } - return p; - } + public u32 iDivisor; /* Number of bits handled by each apSub[] entry. */ + /* Should >=0 for apSub element. */ + /* Max iDivisor is max(u32) / BITVEC_NPTR + 1. */ + /* For a BITVEC_SZ of 512, this would be 34,359,739. */ + public _u u = new _u(); + + public static implicit operator bool( Bitvec b ) + { + return ( b != null ); + } +}; + +/* +** Create a new bitmap object able to handle bits between 0 and iSize, +** inclusive. Return a pointer to the new object. Return NULL if +** malloc fails. +*/ +static Bitvec sqlite3BitvecCreate( u32 iSize ) +{ + Bitvec p; + //Debug.Assert( sizeof(p)==BITVEC_SZ ); + p = new Bitvec();//sqlite3MallocZero( sizeof(p) ); + if ( p != null ) + { + p.iSize = iSize; + } + return p; +} - /* - ** Check to see if the i-th bit is set. Return true or false. - ** If p is NULL (if the bitmap has not been created) or if - ** i is out of range, then return false. - */ - static int sqlite3BitvecTest(Bitvec p, u32 i) { - if (p == null || i == 0) - return 0; - if (i > p.iSize) - return 0; - i--; - while (p.iDivisor != 0) { - u32 bin = i / p.iDivisor; - i = i % p.iDivisor; - p = p.u.apSub[bin]; - if (null == p) { - return 0; - } - } - if (p.iSize <= BITVEC_NBIT) { - return ((p.u.aBitmap[i / BITVEC_SZELEM] & (1 << (int)(i & (BITVEC_SZELEM - 1)))) != 0) ? 1 : 0; - } else { - u32 h = BITVEC_HASH(i++); - while (p.u.aHash[h] != 0) { - if (p.u.aHash[h] == i) - return 1; - h = (h + 1) % BITVEC_NINT; - } - return 0; - } - } +/* +** Check to see if the i-th bit is set. Return true or false. +** If p is NULL (if the bitmap has not been created) or if +** i is out of range, then return false. +*/ +static int sqlite3BitvecTest( Bitvec p, u32 i ) +{ + if ( p == null || i == 0 ) + return 0; + if ( i > p.iSize ) + return 0; + i--; + while ( p.iDivisor != 0 ) + { + u32 bin = i / p.iDivisor; + i = i % p.iDivisor; + p = p.u.apSub[bin]; + if ( null == p ) + { + return 0; + } + } + if ( p.iSize <= BITVEC_NBIT ) + { + return ( ( p.u.aBitmap[i / BITVEC_SZELEM] & ( 1 << (int)( i & ( BITVEC_SZELEM - 1 ) ) ) ) != 0 ) ? 1 : 0; + } + else + { + u32 h = BITVEC_HASH( i++ ); + while ( p.u.aHash[h] != 0 ) + { + if ( p.u.aHash[h] == i ) + return 1; + h = ( h + 1 ) % BITVEC_NINT; + } + return 0; + } +} - /* - ** Set the i-th bit. Return 0 on success and an error code if - ** anything goes wrong. - ** - ** This routine might cause sub-bitmaps to be allocated. Failing - ** to get the memory needed to hold the sub-bitmap is the only - ** that can go wrong with an insert, assuming p and i are valid. - ** - ** The calling function must ensure that p is a valid Bitvec object - ** and that the value for "i" is within range of the Bitvec object. - ** Otherwise the behavior is undefined. - */ - static int sqlite3BitvecSet(Bitvec p, u32 i) { - u32 h; - if (p == null) - return SQLITE_OK; - Debug.Assert(i > 0); - Debug.Assert(i <= p.iSize); - i--; - while ((p.iSize > BITVEC_NBIT) && p.iDivisor != 0) { - u32 bin = i / p.iDivisor; - i = i % p.iDivisor; - if (p.u.apSub[bin] == null) { - p.u.apSub[bin] = sqlite3BitvecCreate(p.iDivisor); - //if ( p.u.apSub[bin] == null ) - // return SQLITE_NOMEM; - } - p = p.u.apSub[bin]; - } - if (p.iSize <= BITVEC_NBIT) { - p.u.aBitmap[i / BITVEC_SZELEM] |= (byte)(1 << (int)(i & (BITVEC_SZELEM - 1))); - return SQLITE_OK; - } - h = BITVEC_HASH(i++); - /* if there wasn't a hash collision, and this doesn't */ - /* completely fill the hash, then just add it without */ - /* worring about sub-dividing and re-hashing. */ - if (0 == p.u.aHash[h]) { - if (p.nSet < (BITVEC_NINT - 1)) { - goto bitvec_set_end; - } else { - goto bitvec_set_rehash; - } - } - /* there was a collision, check to see if it's already */ - /* in hash, if not, try to find a spot for it */ - do { - if (p.u.aHash[h] == i) - return SQLITE_OK; - h++; - if (h >= BITVEC_NINT) - h = 0; - } while (p.u.aHash[h] != 0); - /* we didn't find it in the hash. h points to the first */ - /* available free spot. check to see if this is going to */ - /* make our hash too "full". */ - bitvec_set_rehash: - if (p.nSet >= BITVEC_MXHASH) { - u32 j; - int rc; - u32[] aiValues = new u32[BITVEC_NINT];// = sqlite3StackAllocRaw(0, sizeof(p->u.aHash)); - //if ( aiValues == null ) - //{ - // return SQLITE_NOMEM; - //} - //else - { - - Buffer.BlockCopy(p.u.aHash, 0, aiValues, 0, aiValues.Length * (sizeof(u32)));// memcpy(aiValues, p->u.aHash, sizeof(p->u.aHash)); - p.u.apSub = new Bitvec[BITVEC_NPTR];//memset(p->u.apSub, 0, sizeof(p->u.apSub)); - p.iDivisor = (u32)((p.iSize + BITVEC_NPTR - 1) / BITVEC_NPTR); - rc = sqlite3BitvecSet(p, i); - for (j = 0; j < BITVEC_NINT; j++) { - if (aiValues[j] != 0) - rc |= sqlite3BitvecSet(p, aiValues[j]); - } - //sqlite3StackFree( null, aiValues ); - return rc; - } - } - bitvec_set_end: - p.nSet++; - p.u.aHash[h] = i; - return SQLITE_OK; - } +/* +** Set the i-th bit. Return 0 on success and an error code if +** anything goes wrong. +** +** This routine might cause sub-bitmaps to be allocated. Failing +** to get the memory needed to hold the sub-bitmap is the only +** that can go wrong with an insert, assuming p and i are valid. +** +** The calling function must ensure that p is a valid Bitvec object +** and that the value for "i" is within range of the Bitvec object. +** Otherwise the behavior is undefined. +*/ +static int sqlite3BitvecSet( Bitvec p, u32 i ) +{ + u32 h; + if ( p == null ) + return SQLITE_OK; + Debug.Assert( i > 0 ); + Debug.Assert( i <= p.iSize ); + i--; + while ( ( p.iSize > BITVEC_NBIT ) && p.iDivisor != 0 ) + { + u32 bin = i / p.iDivisor; + i = i % p.iDivisor; + if ( p.u.apSub[bin] == null ) + { + p.u.apSub[bin] = sqlite3BitvecCreate( p.iDivisor ); + //if ( p.u.apSub[bin] == null ) + // return SQLITE_NOMEM; + } + p = p.u.apSub[bin]; + } + if ( p.iSize <= BITVEC_NBIT ) + { + p.u.aBitmap[i / BITVEC_SZELEM] |= (byte)( 1 << (int)( i & ( BITVEC_SZELEM - 1 ) ) ); + return SQLITE_OK; + } + h = BITVEC_HASH( i++ ); + /* if there wasn't a hash collision, and this doesn't */ + /* completely fill the hash, then just add it without */ + /* worring about sub-dividing and re-hashing. */ + if ( 0 == p.u.aHash[h] ) + { + if ( p.nSet < ( BITVEC_NINT - 1 ) ) + { + goto bitvec_set_end; + } + else + { + goto bitvec_set_rehash; + } + } + /* there was a collision, check to see if it's already */ + /* in hash, if not, try to find a spot for it */ + do + { + if ( p.u.aHash[h] == i ) + return SQLITE_OK; + h++; + if ( h >= BITVEC_NINT ) + h = 0; + } while ( p.u.aHash[h] != 0 ); +/* we didn't find it in the hash. h points to the first */ +/* available free spot. check to see if this is going to */ +/* make our hash too "full". */ +bitvec_set_rehash: + if ( p.nSet >= BITVEC_MXHASH ) + { + u32 j; + int rc; + u32[] aiValues = new u32[BITVEC_NINT];// = sqlite3StackAllocRaw(0, sizeof(p->u.aHash)); + //if ( aiValues == null ) + //{ + // return SQLITE_NOMEM; + //} + //else + { + + Buffer.BlockCopy( p.u.aHash, 0, aiValues, 0, aiValues.Length * ( sizeof( u32 ) ) );// memcpy(aiValues, p->u.aHash, sizeof(p->u.aHash)); + p.u.apSub = new Bitvec[BITVEC_NPTR];//memset(p->u.apSub, 0, sizeof(p->u.apSub)); + p.iDivisor = (u32)( ( p.iSize + BITVEC_NPTR - 1 ) / BITVEC_NPTR ); + rc = sqlite3BitvecSet( p, i ); + for ( j = 0; j < BITVEC_NINT; j++ ) + { + if ( aiValues[j] != 0 ) + rc |= sqlite3BitvecSet( p, aiValues[j] ); + } + //sqlite3StackFree( null, aiValues ); + return rc; + } + } +bitvec_set_end: + p.nSet++; + p.u.aHash[h] = i; + return SQLITE_OK; +} - /* - ** Clear the i-th bit. - ** - ** pBuf must be a pointer to at least BITVEC_SZ bytes of temporary storage - ** that BitvecClear can use to rebuilt its hash table. - */ - static void sqlite3BitvecClear(Bitvec p, u32 i, u32[] pBuf) { - if (p == null) - return; - Debug.Assert(i > 0); - i--; - while (p.iDivisor != 0) { - u32 bin = i / p.iDivisor; - i = i % p.iDivisor; - p = p.u.apSub[bin]; - if (null == p) { - return; - } - } - if (p.iSize <= BITVEC_NBIT) { - p.u.aBitmap[i / BITVEC_SZELEM] &= (byte)~((1 << (int)(i & (BITVEC_SZELEM - 1)))); - } else { - u32 j; - u32[] aiValues = pBuf; - Array.Copy(p.u.aHash, aiValues, p.u.aHash.Length);//memcpy(aiValues, p->u.aHash, sizeof(p->u.aHash)); - p.u.aHash = new u32[aiValues.Length];// memset(p->u.aHash, 0, sizeof(p->u.aHash)); - p.nSet = 0; - for (j = 0; j < BITVEC_NINT; j++) { - if (aiValues[j] != 0 && aiValues[j] != (i + 1)) { - u32 h = BITVEC_HASH(aiValues[j] - 1); - p.nSet++; - while (p.u.aHash[h] != 0) { - h++; - if (h >= BITVEC_NINT) - h = 0; - } - p.u.aHash[h] = aiValues[j]; - } - } - } +/* +** Clear the i-th bit. +** +** pBuf must be a pointer to at least BITVEC_SZ bytes of temporary storage +** that BitvecClear can use to rebuilt its hash table. +*/ +static void sqlite3BitvecClear( Bitvec p, u32 i, u32[] pBuf ) +{ + if ( p == null ) + return; + Debug.Assert( i > 0 ); + i--; + while ( p.iDivisor != 0 ) + { + u32 bin = i / p.iDivisor; + i = i % p.iDivisor; + p = p.u.apSub[bin]; + if ( null == p ) + { + return; + } + } + if ( p.iSize <= BITVEC_NBIT ) + { + p.u.aBitmap[i / BITVEC_SZELEM] &= (byte)~( ( 1 << (int)( i & ( BITVEC_SZELEM - 1 ) ) ) ); + } + else + { + u32 j; + u32[] aiValues = pBuf; + Array.Copy( p.u.aHash, aiValues, p.u.aHash.Length );//memcpy(aiValues, p->u.aHash, sizeof(p->u.aHash)); + p.u.aHash = new u32[aiValues.Length];// memset(p->u.aHash, 0, sizeof(p->u.aHash)); + p.nSet = 0; + for ( j = 0; j < BITVEC_NINT; j++ ) + { + if ( aiValues[j] != 0 && aiValues[j] != ( i + 1 ) ) + { + u32 h = BITVEC_HASH( aiValues[j] - 1 ); + p.nSet++; + while ( p.u.aHash[h] != 0 ) + { + h++; + if ( h >= BITVEC_NINT ) + h = 0; } + p.u.aHash[h] = aiValues[j]; + } + } + } +} - /* - ** Destroy a bitmap object. Reclaim all memory used. - */ - static void sqlite3BitvecDestroy(ref Bitvec p) { - if (p == null) - return; - if (p.iDivisor != 0) { - u32 i; - for (i = 0; i < BITVEC_NPTR; i++) { - sqlite3BitvecDestroy(ref p.u.apSub[i]); - } - } - //sqlite3_free( ref p ); - } +/* +** Destroy a bitmap object. Reclaim all memory used. +*/ +static void sqlite3BitvecDestroy( ref Bitvec p ) +{ + if ( p == null ) + return; + if ( p.iDivisor != 0 ) + { + u32 i; + for ( i = 0; i < BITVEC_NPTR; i++ ) + { + sqlite3BitvecDestroy( ref p.u.apSub[i] ); + } + } + //sqlite3_free( ref p ); +} - /* - ** Return the value of the iSize parameter specified when Bitvec *p - ** was created. - */ - static u32 sqlite3BitvecSize(Bitvec p) { - return p.iSize; - } +/* +** Return the value of the iSize parameter specified when Bitvec *p +** was created. +*/ +static u32 sqlite3BitvecSize( Bitvec p ) +{ + return p.iSize; +} #if !SQLITE_OMIT_BUILTIN_TEST - /* - ** Let V[] be an array of unsigned characters sufficient to hold - ** up to N bits. Let I be an integer between 0 and N. 0<=I>3] |= (1<<(I&7)) - static void SETBIT(byte[] V, int I) { - V[I >> 3] |= (byte)(1 << (I & 7)); - } +/* +** Let V[] be an array of unsigned characters sufficient to hold +** up to N bits. Let I be an integer between 0 and N. 0<=I>3] |= (1<<(I&7)) +static void SETBIT( byte[] V, int I ) +{ + V[I >> 3] |= (byte)( 1 << ( I & 7 ) ); +} - //#define CLEARBIT(V,I) V[I>>3] &= ~(1<<(I&7)) - static void CLEARBIT(byte[] V, int I) { - V[I >> 3] &= (byte)~(1 << (I & 7)); - } +//#define CLEARBIT(V,I) V[I>>3] &= ~(1<<(I&7)) +static void CLEARBIT( byte[] V, int I ) +{ + V[I >> 3] &= (byte)~( 1 << ( I & 7 ) ); +} - //#define TESTBIT(V,I) (V[I>>3]&(1<<(I&7)))!=0 - static int TESTBIT(byte[] V, int I) { - return (V[I >> 3] & (1 << (I & 7))) != 0 ? 1 : 0; - } +//#define TESTBIT(V,I) (V[I>>3]&(1<<(I&7)))!=0 +static int TESTBIT( byte[] V, int I ) +{ + return ( V[I >> 3] & ( 1 << ( I & 7 ) ) ) != 0 ? 1 : 0; +} - /* - ** This routine runs an extensive test of the Bitvec code. - ** - ** The input is an array of integers that acts as a program - ** to test the Bitvec. The integers are opcodes followed - ** by 0, 1, or 3 operands, depending on the opcode. Another - ** opcode follows immediately after the last operand. - ** - ** There are 6 opcodes numbered from 0 through 5. 0 is the - ** "halt" opcode and causes the test to end. - ** - ** 0 Halt and return the number of errors - ** 1 N S X Set N bits beginning with S and incrementing by X - ** 2 N S X Clear N bits beginning with S and incrementing by X - ** 3 N Set N randomly chosen bits - ** 4 N Clear N randomly chosen bits - ** 5 N S X Set N bits from S increment X in array only, not in bitvec - ** - ** The opcodes 1 through 4 perform set and clear operations are performed - ** on both a Bitvec object and on a linear array of bits obtained from malloc. - ** Opcode 5 works on the linear array only, not on the Bitvec. - ** Opcode 5 is used to deliberately induce a fault in order to - ** confirm that error detection works. - ** - ** At the conclusion of the test the linear array is compared - ** against the Bitvec object. If there are any differences, - ** an error is returned. If they are the same, zero is returned. - ** - ** If a memory allocation error occurs, return -1. - */ - static int sqlite3BitvecBuiltinTest(u32 sz, int[] aOp) { - Bitvec pBitvec = null; - byte[] pV = null; - int rc = -1; - int i, nx, pc, op; - u32[] pTmpSpace; - - /* Allocate the Bitvec to be tested and a linear array of - ** bits to act as the reference */ - pBitvec = sqlite3BitvecCreate(sz); - pV = sqlite3_malloc((int)(sz + 7) / 8 + 1); - pTmpSpace = new u32[BITVEC_SZ];// sqlite3_malloc( BITVEC_SZ ); - if (pBitvec == null || pV == null || pTmpSpace == null) - goto bitvec_end; - Array.Clear(pV, 0, (int)(sz + 7) / 8 + 1);// memset( pV, 0, ( sz + 7 ) / 8 + 1 ); - - /* NULL pBitvec tests */ - sqlite3BitvecSet(null, (u32)1); - sqlite3BitvecClear(null, 1, pTmpSpace); - - /* Run the program */ - pc = 0; - while ((op = aOp[pc]) != 0) { - switch (op) { - case 1: - case 2: - case 5: { - nx = 4; - i = aOp[pc + 2] - 1; - aOp[pc + 2] += aOp[pc + 3]; - break; - } - case 3: - case 4: - default: { - nx = 2; - i64 i64Temp = 0; - sqlite3_randomness(sizeof(i64), ref i64Temp); - i = (int)i64Temp; - break; - } - } - if ((--aOp[pc + 1]) > 0) - nx = 0; - pc += nx; - i = (int)((i & 0x7fffffff) % sz); - if ((op & 1) != 0) { - SETBIT(pV, (i + 1)); - if (op != 5) { - if (sqlite3BitvecSet(pBitvec, (u32)i + 1) != 0) - goto bitvec_end; - } - } else { - CLEARBIT(pV, (i + 1)); - sqlite3BitvecClear(pBitvec, (u32)i + 1, pTmpSpace); - } - } - - /* Test to make sure the linear array exactly matches the - ** Bitvec object. Start with the assumption that they do - ** match (rc==0). Change rc to non-zero if a discrepancy - ** is found. - */ - rc = sqlite3BitvecTest(null, 0) + sqlite3BitvecTest(pBitvec, sz + 1) - + sqlite3BitvecTest(pBitvec, 0) - + (int)(sqlite3BitvecSize(pBitvec) - sz); - for (i = 1; i <= sz; i++) { - if ((TESTBIT(pV, i)) != sqlite3BitvecTest(pBitvec, (u32)i)) { - rc = i; - break; - } - } - - /* Free allocated structure */ - bitvec_end: - //sqlite3_free( ref pTmpSpace ); - //sqlite3_free( ref pV ); - sqlite3BitvecDestroy(ref pBitvec); - return rc; +/* +** This routine runs an extensive test of the Bitvec code. +** +** The input is an array of integers that acts as a program +** to test the Bitvec. The integers are opcodes followed +** by 0, 1, or 3 operands, depending on the opcode. Another +** opcode follows immediately after the last operand. +** +** There are 6 opcodes numbered from 0 through 5. 0 is the +** "halt" opcode and causes the test to end. +** +** 0 Halt and return the number of errors +** 1 N S X Set N bits beginning with S and incrementing by X +** 2 N S X Clear N bits beginning with S and incrementing by X +** 3 N Set N randomly chosen bits +** 4 N Clear N randomly chosen bits +** 5 N S X Set N bits from S increment X in array only, not in bitvec +** +** The opcodes 1 through 4 perform set and clear operations are performed +** on both a Bitvec object and on a linear array of bits obtained from malloc. +** Opcode 5 works on the linear array only, not on the Bitvec. +** Opcode 5 is used to deliberately induce a fault in order to +** confirm that error detection works. +** +** At the conclusion of the test the linear array is compared +** against the Bitvec object. If there are any differences, +** an error is returned. If they are the same, zero is returned. +** +** If a memory allocation error occurs, return -1. +*/ +static int sqlite3BitvecBuiltinTest( u32 sz, int[] aOp ) +{ + Bitvec pBitvec = null; + byte[] pV = null; + int rc = -1; + int i, nx, pc, op; + u32[] pTmpSpace; + + /* Allocate the Bitvec to be tested and a linear array of + ** bits to act as the reference */ + pBitvec = sqlite3BitvecCreate( sz ); + pV = sqlite3_malloc( (int)( sz + 7 ) / 8 + 1 ); + pTmpSpace = new u32[BITVEC_SZ];// sqlite3_malloc( BITVEC_SZ ); + if ( pBitvec == null || pV == null || pTmpSpace == null ) + goto bitvec_end; + Array.Clear( pV, 0, (int)( sz + 7 ) / 8 + 1 );// memset( pV, 0, ( sz + 7 ) / 8 + 1 ); + + /* NULL pBitvec tests */ + sqlite3BitvecSet( null, (u32)1 ); + sqlite3BitvecClear( null, 1, pTmpSpace ); + + /* Run the program */ + pc = 0; + while ( ( op = aOp[pc] ) != 0 ) + { + switch ( op ) + { + case 1: + case 2: + case 5: + { + nx = 4; + i = aOp[pc + 2] - 1; + aOp[pc + 2] += aOp[pc + 3]; + break; } -#endif //* SQLITE_OMIT_BUILTIN_TEST */ + case 3: + case 4: + default: + { + nx = 2; + i64 i64Temp = 0; + sqlite3_randomness( sizeof( i64 ), ref i64Temp ); + i = (int)i64Temp; + break; + } + } + if ( ( --aOp[pc + 1] ) > 0 ) + nx = 0; + pc += nx; + i = (int)( ( i & 0x7fffffff ) % sz ); + if ( ( op & 1 ) != 0 ) + { + SETBIT( pV, ( i + 1 ) ); + if ( op != 5 ) + { + if ( sqlite3BitvecSet( pBitvec, (u32)i + 1 ) != 0 ) + goto bitvec_end; + } } + else + { + CLEARBIT( pV, ( i + 1 ) ); + sqlite3BitvecClear( pBitvec, (u32)i + 1, pTmpSpace ); + } + } + + /* Test to make sure the linear array exactly matches the + ** Bitvec object. Start with the assumption that they do + ** match (rc==0). Change rc to non-zero if a discrepancy + ** is found. + */ + rc = sqlite3BitvecTest( null, 0 ) + sqlite3BitvecTest( pBitvec, sz + 1 ) + + sqlite3BitvecTest( pBitvec, 0 ) + + (int)( sqlite3BitvecSize( pBitvec ) - sz ); + for ( i = 1; i <= sz; i++ ) + { + if ( ( TESTBIT( pV, i ) ) != sqlite3BitvecTest( pBitvec, (u32)i ) ) + { + rc = i; + break; + } + } + + /* Free allocated structure */ +bitvec_end: + //sqlite3_free( ref pTmpSpace ); + //sqlite3_free( ref pV ); + sqlite3BitvecDestroy( ref pBitvec ); + return rc; +} +#endif //* SQLITE_OMIT_BUILTIN_TEST */ + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/btmutex_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/btmutex_c.cs index e7b134c50..1f814b85a 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/btmutex_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/btmutex_c.cs @@ -1,30 +1,34 @@ -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2007 August 27 - ** - ** 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 contains code used to implement mutexes on Btree objects. - ** This code really belongs in btree.c. But btree.c is getting too - ** big and we want to break it down some. This packaged seemed like - ** a good breakout. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ - //#include "btreeInt.h" +using System.Diagnostics; + +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { +/* +** 2007 August 27 +** +** 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 contains code used to implement mutexes on Btree objects. +** This code really belongs in btree.c. But btree.c is getting too +** big and we want to break it down some. This packaged seemed like +** a good breakout. + ************************************************************************* +** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart +** C#-SQLite is an independent reimplementation of the SQLite software library +** +** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e +** +************************************************************************* +*/ +//#include "btreeInt.h" #if !SQLITE_OMIT_SHARED_CACHE #if SQLITE_THREADSAFE @@ -295,5 +299,5 @@ void sqlite3BtreeEnterAll(sqlite3 db){ #endif //* if SQLITE_THREADSAFE */ #endif //* ifndef SQLITE_OMIT_SHARED_CACHE */ - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/btree_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/btree_c.cs index 273d6df86..611dcc5f1 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/btree_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/btree_c.cs @@ -3,54 +3,56 @@ using System.Text; using i64 = System.Int64; -using Pgno = System.UInt32; -using sqlite3_int64 = System.Int64; +using u8 = System.Byte; using u16 = System.UInt16; using u32 = System.UInt32; using u64 = System.UInt64; -using u8 = System.Byte; +using sqlite3_int64 = System.Int64; +using Pgno = System.UInt32; -namespace Community.CsharpSqlite { - using DbPage = Sqlite3.PgHdr; +namespace Community.CsharpSqlite +{ + using DbPage = Sqlite3.PgHdr; - public partial class Sqlite3 { - /* - ** 2004 April 6 - ** - ** 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 implements a external (disk-based) database using BTrees. - ** See the header comment on "btreeInt.h" for additional information. - ** Including a description of file format and an overview of operation. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "btreeInt.h" + public partial class Sqlite3 + { +/* +** 2004 April 6 +** +** 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 implements a external (disk-based) database using BTrees. +** See the header comment on "btreeInt.h" for additional information. +** Including a description of file format and an overview of operation. +************************************************************************* +** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart +** C#-SQLite is an independent reimplementation of the SQLite software library +** +** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 +** +************************************************************************* +*/ +//#include "btreeInt.h" - /* - ** The header string that appears at the beginning of every - ** SQLite database. - */ - static byte[] zMagicHeader = Encoding.UTF8.GetBytes(SQLITE_FILE_HEADER); +/* +** The header string that appears at the beginning of every +** SQLite database. +*/ +static byte[] zMagicHeader = Encoding.UTF8.GetBytes( SQLITE_FILE_HEADER ); - /* - ** Set this global variable to 1 to enable tracing using the TRACE - ** macro. - */ -#if TRACE - static bool sqlite3BtreeTrace = false; /* True to enable tracing */ - //# define TRACE(X) if(sqlite3BtreeTrace){printf X;fflush(stdout);} - static void TRACE(string X, params object[] ap) { if (sqlite3BtreeTrace) printf(X, ap); } +/* +** Set this global variable to 1 to enable tracing using the TRACE +** macro. +*/ +#if TRACE +static bool sqlite3BtreeTrace=false; /* True to enable tracing */ +//# define TRACE(X) if(sqlite3BtreeTrace){printf X;fflush(stdout);} +static void TRACE(string X, params object[] ap) { if (sqlite3BtreeTrace) printf(X, ap); } #else //# define TRACE(X) static void TRACE( string X, params object[] ap ) @@ -60,19 +62,20 @@ static void TRACE( string X, params object[] ap ) - /* - ** Extract a 2-byte big-endian integer from an array of unsigned bytes. - ** But if the value is zero, make it 65536. - ** - ** This routine is used to extract the "offset to cell content area" value - ** from the header of a btree page. If the page size is 65536 and the page - ** is empty, the offset should be 65536, but the 2-byte value stores zero. - ** This routine makes the necessary adjustment to 65536. - */ - //#define get2byteNotZero(X) (((((int)get2byte(X))-1)&0xffff)+1) - static int get2byteNotZero(byte[] X, int offset) { - return (((((int)get2byte(X, offset)) - 1) & 0xffff) + 1); - } +/* +** Extract a 2-byte big-endian integer from an array of unsigned bytes. +** But if the value is zero, make it 65536. +** +** This routine is used to extract the "offset to cell content area" value +** from the header of a btree page. If the page size is 65536 and the page +** is empty, the offset should be 65536, but the 2-byte value stores zero. +** This routine makes the necessary adjustment to 65536. +*/ +//#define get2byteNotZero(X) (((((int)get2byte(X))-1)&0xffff)+1) +static int get2byteNotZero( byte[] X, int offset ) +{ + return ( ( ( ( (int)get2byte( X, offset ) ) - 1 ) & 0xffff ) + 1 ); +} #if !SQLITE_OMIT_SHARED_CACHE /* @@ -107,35 +110,40 @@ int sqlite3_enable_shared_cache(int enable){ #if SQLITE_OMIT_SHARED_CACHE - /* - ** The functions querySharedCacheTableLock(), setSharedCacheTableLock(), - ** and clearAllSharedCacheTableLocks() - ** manipulate entries in the BtShared.pLock linked list used to store - ** shared-cache table level locks. If the library is compiled with the - ** shared-cache feature disabled, then there is only ever one user - ** of each BtShared structure and so this locking is not necessary. - ** So define the lock related functions as no-ops. - */ - //#define querySharedCacheTableLock(a,b,c) SQLITE_OK - static int querySharedCacheTableLock(Btree p, Pgno iTab, u8 eLock) { - return SQLITE_OK; - } +/* +** The functions querySharedCacheTableLock(), setSharedCacheTableLock(), +** and clearAllSharedCacheTableLocks() +** manipulate entries in the BtShared.pLock linked list used to store +** shared-cache table level locks. If the library is compiled with the +** shared-cache feature disabled, then there is only ever one user +** of each BtShared structure and so this locking is not necessary. +** So define the lock related functions as no-ops. +*/ +//#define querySharedCacheTableLock(a,b,c) SQLITE_OK +static int querySharedCacheTableLock( Btree p, Pgno iTab, u8 eLock ) +{ + return SQLITE_OK; +} - //#define setSharedCacheTableLock(a,b,c) SQLITE_OK - //#define clearAllSharedCacheTableLocks(a) - static void clearAllSharedCacheTableLocks(Btree a) { - } - //#define downgradeAllSharedCacheTableLocks(a) - static void downgradeAllSharedCacheTableLocks(Btree a) { - } - //#define hasSharedCacheTableLock(a,b,c,d) 1 - static bool hasSharedCacheTableLock(Btree a, Pgno b, int c, int d) { - return true; - } - //#define hasReadConflicts(a, b) 0 - static bool hasReadConflicts(Btree a, Pgno b) { - return false; - } +//#define setSharedCacheTableLock(a,b,c) SQLITE_OK +//#define clearAllSharedCacheTableLocks(a) +static void clearAllSharedCacheTableLocks( Btree a ) +{ +} +//#define downgradeAllSharedCacheTableLocks(a) +static void downgradeAllSharedCacheTableLocks( Btree a ) +{ +} +//#define hasSharedCacheTableLock(a,b,c,d) 1 +static bool hasSharedCacheTableLock( Btree a, Pgno b, int c, int d ) +{ + return true; +} +//#define hasReadConflicts(a, b) 0 +static bool hasReadConflicts( Btree a, Pgno b ) +{ + return false; +} #endif #if !SQLITE_OMIT_SHARED_CACHE @@ -462,17 +470,18 @@ static void downgradeAllSharedCacheTableLocks(Btree p){ #endif //* SQLITE_OMIT_SHARED_CACHE */ - //static void releasePage(MemPage pPage); /* Forward reference */ +//static void releasePage(MemPage pPage); /* Forward reference */ - /* - ***** This routine is used inside of assert() only **** - ** - ** Verify that the cursor holds the mutex on its BtShared - */ +/* +***** This routine is used inside of assert() only **** +** +** Verify that the cursor holds the mutex on its BtShared +*/ #if SQLITE_DEBUG - static bool cursorHoldsMutex(BtCursor p) { - return sqlite3_mutex_held(p.pBt.mutex); - } +static bool cursorHoldsMutex( BtCursor p ) +{ + return sqlite3_mutex_held( p.pBt.mutex ); +} #else static bool cursorHoldsMutex(BtCursor p) { return true; } #endif @@ -529,387 +538,430 @@ static void invalidateIncrblobCursors( } #else - /* Stub functions when INCRBLOB is omitted */ - //#define invalidateOverflowCache(x) - static void invalidateOverflowCache(BtCursor pCur) { - } - //#define invalidateAllOverflowCache(x) - static void invalidateAllOverflowCache(BtShared pBt) { - } - //#define invalidateIncrblobCursors(x,y,z) - static void invalidateIncrblobCursors(Btree x, i64 y, int z) { - } +/* Stub functions when INCRBLOB is omitted */ +//#define invalidateOverflowCache(x) +static void invalidateOverflowCache( BtCursor pCur ) +{ +} +//#define invalidateAllOverflowCache(x) +static void invalidateAllOverflowCache( BtShared pBt ) +{ +} +//#define invalidateIncrblobCursors(x,y,z) +static void invalidateIncrblobCursors( Btree x, i64 y, int z ) +{ +} #endif //* SQLITE_OMIT_INCRBLOB */ - /* - ** Set bit pgno of the BtShared.pHasContent bitvec. This is called - ** when a page that previously contained data becomes a free-list leaf - ** page. - ** - ** The BtShared.pHasContent bitvec exists to work around an obscure - ** bug caused by the interaction of two useful IO optimizations surrounding - ** free-list leaf pages: - ** - ** 1) When all data is deleted from a page and the page becomes - ** a free-list leaf page, the page is not written to the database - ** (as free-list leaf pages contain no meaningful data). Sometimes - ** such a page is not even journalled (as it will not be modified, - ** why bother journalling it?). - ** - ** 2) When a free-list leaf page is reused, its content is not read - ** from the database or written to the journal file (why should it - ** be, if it is not at all meaningful?). - ** - ** By themselves, these optimizations work fine and provide a handy - ** performance boost to bulk delete or insert operations. However, if - ** a page is moved to the free-list and then reused within the same - ** transaction, a problem comes up. If the page is not journalled when - ** it is moved to the free-list and it is also not journalled when it - ** is extracted from the free-list and reused, then the original data - ** may be lost. In the event of a rollback, it may not be possible - ** to restore the database to its original configuration. - ** - ** The solution is the BtShared.pHasContent bitvec. Whenever a page is - ** moved to become a free-list leaf page, the corresponding bit is - ** set in the bitvec. Whenever a leaf page is extracted from the free-list, - ** optimization 2 above is omitted if the corresponding bit is already - ** set in BtShared.pHasContent. The contents of the bitvec are cleared - ** at the end of every transaction. - */ - static int btreeSetHasContent(BtShared pBt, Pgno pgno) { - int rc = SQLITE_OK; - if (null == pBt.pHasContent) { - Debug.Assert(pgno <= pBt.nPage); - pBt.pHasContent = sqlite3BitvecCreate(pBt.nPage); - //if ( null == pBt.pHasContent ) - //{ - // rc = SQLITE_NOMEM; - //} - } - if (rc == SQLITE_OK && pgno <= sqlite3BitvecSize(pBt.pHasContent)) { - rc = sqlite3BitvecSet(pBt.pHasContent, pgno); - } - return rc; - } - - /* - ** Query the BtShared.pHasContent vector. - ** - ** This function is called when a free-list leaf page is removed from the - ** free-list for reuse. It returns false if it is safe to retrieve the - ** page from the pager layer with the 'no-content' flag set. True otherwise. - */ - static bool btreeGetHasContent(BtShared pBt, Pgno pgno) { - Bitvec p = pBt.pHasContent; - return (p != null && (pgno > sqlite3BitvecSize(p) || sqlite3BitvecTest(p, pgno) != 0)); - } - - /* - ** Clear (destroy) the BtShared.pHasContent bitvec. This should be - ** invoked at the conclusion of each write-transaction. - */ - static void btreeClearHasContent(BtShared pBt) { - sqlite3BitvecDestroy(ref pBt.pHasContent); - pBt.pHasContent = null; - } +/* +** Set bit pgno of the BtShared.pHasContent bitvec. This is called +** when a page that previously contained data becomes a free-list leaf +** page. +** +** The BtShared.pHasContent bitvec exists to work around an obscure +** bug caused by the interaction of two useful IO optimizations surrounding +** free-list leaf pages: +** +** 1) When all data is deleted from a page and the page becomes +** a free-list leaf page, the page is not written to the database +** (as free-list leaf pages contain no meaningful data). Sometimes +** such a page is not even journalled (as it will not be modified, +** why bother journalling it?). +** +** 2) When a free-list leaf page is reused, its content is not read +** from the database or written to the journal file (why should it +** be, if it is not at all meaningful?). +** +** By themselves, these optimizations work fine and provide a handy +** performance boost to bulk delete or insert operations. However, if +** a page is moved to the free-list and then reused within the same +** transaction, a problem comes up. If the page is not journalled when +** it is moved to the free-list and it is also not journalled when it +** is extracted from the free-list and reused, then the original data +** may be lost. In the event of a rollback, it may not be possible +** to restore the database to its original configuration. +** +** The solution is the BtShared.pHasContent bitvec. Whenever a page is +** moved to become a free-list leaf page, the corresponding bit is +** set in the bitvec. Whenever a leaf page is extracted from the free-list, +** optimization 2 above is omitted if the corresponding bit is already +** set in BtShared.pHasContent. The contents of the bitvec are cleared +** at the end of every transaction. +*/ +static int btreeSetHasContent( BtShared pBt, Pgno pgno ) +{ + int rc = SQLITE_OK; + if ( null == pBt.pHasContent ) + { + Debug.Assert( pgno <= pBt.nPage ); + pBt.pHasContent = sqlite3BitvecCreate( pBt.nPage ); + //if ( null == pBt.pHasContent ) + //{ + // rc = SQLITE_NOMEM; + //} + } + if ( rc == SQLITE_OK && pgno <= sqlite3BitvecSize( pBt.pHasContent ) ) + { + rc = sqlite3BitvecSet( pBt.pHasContent, pgno ); + } + return rc; +} - /* - ** Save the current cursor position in the variables BtCursor.nKey - ** and BtCursor.pKey. The cursor's state is set to CURSOR_REQUIRESEEK. - ** - ** The caller must ensure that the cursor is valid (has eState==CURSOR_VALID) - ** prior to calling this routine. - */ - static int saveCursorPosition(BtCursor pCur) { - int rc; - - Debug.Assert(CURSOR_VALID == pCur.eState); - Debug.Assert(null == pCur.pKey); - Debug.Assert(cursorHoldsMutex(pCur)); - - rc = sqlite3BtreeKeySize(pCur, ref pCur.nKey); - Debug.Assert(rc == SQLITE_OK); /* KeySize() cannot fail */ - - /* If this is an intKey table, then the above call to BtreeKeySize() - ** stores the integer key in pCur.nKey. In this case this value is - ** all that is required. Otherwise, if pCur is not open on an intKey - ** table, then malloc space for and store the pCur.nKey bytes of key - ** data. - */ - if (0 == pCur.apPage[0].intKey) { - byte[] pKey = sqlite3Malloc((int)pCur.nKey); - //if( pKey !=null){ - rc = sqlite3BtreeKey(pCur, 0, (u32)pCur.nKey, pKey); - if (rc == SQLITE_OK) { - pCur.pKey = pKey; - } - //else{ - // sqlite3_free(ref pKey); - //} - //}else{ - // rc = SQLITE_NOMEM; - //} - } - Debug.Assert(0 == pCur.apPage[0].intKey || null == pCur.pKey); - - if (rc == SQLITE_OK) { - int i; - for (i = 0; i <= pCur.iPage; i++) { - releasePage(pCur.apPage[i]); - pCur.apPage[i] = null; - } - pCur.iPage = -1; - pCur.eState = CURSOR_REQUIRESEEK; - } +/* +** Query the BtShared.pHasContent vector. +** +** This function is called when a free-list leaf page is removed from the +** free-list for reuse. It returns false if it is safe to retrieve the +** page from the pager layer with the 'no-content' flag set. True otherwise. +*/ +static bool btreeGetHasContent( BtShared pBt, Pgno pgno ) +{ + Bitvec p = pBt.pHasContent; + return ( p != null && ( pgno > sqlite3BitvecSize( p ) || sqlite3BitvecTest( p, pgno ) != 0 ) ); +} - invalidateOverflowCache(pCur); - return rc; - } +/* +** Clear (destroy) the BtShared.pHasContent bitvec. This should be +** invoked at the conclusion of each write-transaction. +*/ +static void btreeClearHasContent( BtShared pBt ) +{ + sqlite3BitvecDestroy( ref pBt.pHasContent ); + pBt.pHasContent = null; +} - /* - ** Save the positions of all cursors (except pExcept) that are open on - ** the table with root-page iRoot. Usually, this is called just before cursor - ** pExcept is used to modify the table (BtreeDelete() or BtreeInsert()). - */ - static int saveAllCursors(BtShared pBt, Pgno iRoot, BtCursor pExcept) { - BtCursor p; - Debug.Assert(sqlite3_mutex_held(pBt.mutex)); - Debug.Assert(pExcept == null || pExcept.pBt == pBt); - for (p = pBt.pCursor; p != null; p = p.pNext) { - if (p != pExcept && (0 == iRoot || p.pgnoRoot == iRoot) && - p.eState == CURSOR_VALID) { - int rc = saveCursorPosition(p); - if (SQLITE_OK != rc) { - return rc; - } - } - } - return SQLITE_OK; - } +/* +** Save the current cursor position in the variables BtCursor.nKey +** and BtCursor.pKey. The cursor's state is set to CURSOR_REQUIRESEEK. +** +** The caller must ensure that the cursor is valid (has eState==CURSOR_VALID) +** prior to calling this routine. +*/ +static int saveCursorPosition( BtCursor pCur ) +{ + int rc; + + Debug.Assert( CURSOR_VALID == pCur.eState ); + Debug.Assert( null == pCur.pKey ); + Debug.Assert( cursorHoldsMutex( pCur ) ); + + rc = sqlite3BtreeKeySize( pCur, ref pCur.nKey ); + Debug.Assert( rc == SQLITE_OK ); /* KeySize() cannot fail */ + + /* If this is an intKey table, then the above call to BtreeKeySize() + ** stores the integer key in pCur.nKey. In this case this value is + ** all that is required. Otherwise, if pCur is not open on an intKey + ** table, then malloc space for and store the pCur.nKey bytes of key + ** data. + */ + if ( 0 == pCur.apPage[0].intKey ) + { + byte[] pKey = sqlite3Malloc( (int)pCur.nKey ); + //if( pKey !=null){ + rc = sqlite3BtreeKey( pCur, 0, (u32)pCur.nKey, pKey ); + if ( rc == SQLITE_OK ) + { + pCur.pKey = pKey; + } + //else{ + // sqlite3_free(ref pKey); + //} + //}else{ + // rc = SQLITE_NOMEM; + //} + } + Debug.Assert( 0 == pCur.apPage[0].intKey || null == pCur.pKey ); + + if ( rc == SQLITE_OK ) + { + int i; + for ( i = 0; i <= pCur.iPage; i++ ) + { + releasePage( pCur.apPage[i] ); + pCur.apPage[i] = null; + } + pCur.iPage = -1; + pCur.eState = CURSOR_REQUIRESEEK; + } - /* - ** Clear the current cursor position. - */ - static void sqlite3BtreeClearCursor(BtCursor pCur) { - Debug.Assert(cursorHoldsMutex(pCur)); - sqlite3_free(ref pCur.pKey); - pCur.eState = CURSOR_INVALID; - } + invalidateOverflowCache( pCur ); + return rc; +} - /* - ** In this version of BtreeMoveto, pKey is a packed index record - ** such as is generated by the OP_MakeRecord opcode. Unpack the - ** record and then call BtreeMovetoUnpacked() to do the work. - */ - static int btreeMoveto( - BtCursor pCur, /* Cursor open on the btree to be searched */ - byte[] pKey, /* Packed key if the btree is an index */ - i64 nKey, /* Integer key for tables. Size of pKey for indices */ - int bias, /* Bias search to the high end */ - ref int pRes /* Write search results here */ - ) { - int rc; /* Status code */ - UnpackedRecord pIdxKey; /* Unpacked index key */ - UnpackedRecord aSpace = new UnpackedRecord();//char aSpace[150]; /* Temp space for pIdxKey - to avoid a malloc */ - - if (pKey != null) { - Debug.Assert(nKey == (i64)(int)nKey); - pIdxKey = sqlite3VdbeRecordUnpack(pCur.pKeyInfo, (int)nKey, pKey, - aSpace, 16);//sizeof( aSpace ) ); - //if ( pIdxKey == null ) - // return SQLITE_NOMEM; - } else { - pIdxKey = null; - } - rc = sqlite3BtreeMovetoUnpacked(pCur, pIdxKey, nKey, bias != 0 ? 1 : 0, ref pRes); +/* +** Save the positions of all cursors (except pExcept) that are open on +** the table with root-page iRoot. Usually, this is called just before cursor +** pExcept is used to modify the table (BtreeDelete() or BtreeInsert()). +*/ +static int saveAllCursors( BtShared pBt, Pgno iRoot, BtCursor pExcept ) +{ + BtCursor p; + Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); + Debug.Assert( pExcept == null || pExcept.pBt == pBt ); + for ( p = pBt.pCursor; p != null; p = p.pNext ) + { + if ( p != pExcept && ( 0 == iRoot || p.pgnoRoot == iRoot ) && + p.eState == CURSOR_VALID ) + { + int rc = saveCursorPosition( p ); + if ( SQLITE_OK != rc ) + { + return rc; + } + } + } + return SQLITE_OK; +} - if (pKey != null) { - sqlite3VdbeDeleteUnpackedRecord(pIdxKey); - } - return rc; - } +/* +** Clear the current cursor position. +*/ +static void sqlite3BtreeClearCursor( BtCursor pCur ) +{ + Debug.Assert( cursorHoldsMutex( pCur ) ); + sqlite3_free( ref pCur.pKey ); + pCur.eState = CURSOR_INVALID; +} - /* - ** Restore the cursor to the position it was in (or as close to as possible) - ** when saveCursorPosition() was called. Note that this call deletes the - ** saved position info stored by saveCursorPosition(), so there can be - ** at most one effective restoreCursorPosition() call after each - ** saveCursorPosition(). - */ - static int btreeRestoreCursorPosition(BtCursor pCur) { - int rc; - Debug.Assert(cursorHoldsMutex(pCur)); - Debug.Assert(pCur.eState >= CURSOR_REQUIRESEEK); - if (pCur.eState == CURSOR_FAULT) { - return pCur.skipNext; - } - pCur.eState = CURSOR_INVALID; - rc = btreeMoveto(pCur, pCur.pKey, pCur.nKey, 0, ref pCur.skipNext); - if (rc == SQLITE_OK) { - //sqlite3_free(ref pCur.pKey); - pCur.pKey = null; - Debug.Assert(pCur.eState == CURSOR_VALID || pCur.eState == CURSOR_INVALID); - } - return rc; - } +/* +** In this version of BtreeMoveto, pKey is a packed index record +** such as is generated by the OP_MakeRecord opcode. Unpack the +** record and then call BtreeMovetoUnpacked() to do the work. +*/ +static int btreeMoveto( +BtCursor pCur, /* Cursor open on the btree to be searched */ +byte[] pKey, /* Packed key if the btree is an index */ +i64 nKey, /* Integer key for tables. Size of pKey for indices */ +int bias, /* Bias search to the high end */ +ref int pRes /* Write search results here */ +) +{ + int rc; /* Status code */ + UnpackedRecord pIdxKey; /* Unpacked index key */ + UnpackedRecord aSpace = new UnpackedRecord();//char aSpace[150]; /* Temp space for pIdxKey - to avoid a malloc */ + + if ( pKey != null ) + { + Debug.Assert( nKey == (i64)(int)nKey ); + pIdxKey = sqlite3VdbeRecordUnpack( pCur.pKeyInfo, (int)nKey, pKey, + aSpace, 16 );//sizeof( aSpace ) ); + //if ( pIdxKey == null ) + // return SQLITE_NOMEM; + } + else + { + pIdxKey = null; + } + rc = sqlite3BtreeMovetoUnpacked( pCur, pIdxKey, nKey, bias != 0 ? 1 : 0, ref pRes ); + + if ( pKey != null ) + { + sqlite3VdbeDeleteUnpackedRecord( pIdxKey ); + } + return rc; +} - //#define restoreCursorPosition(p) \ - // (p.eState>=CURSOR_REQUIRESEEK ? \ - // btreeRestoreCursorPosition(p) : \ - // SQLITE_OK) - static int restoreCursorPosition(BtCursor pCur) { - if (pCur.eState >= CURSOR_REQUIRESEEK) - return btreeRestoreCursorPosition(pCur); - else - return SQLITE_OK; - } +/* +** Restore the cursor to the position it was in (or as close to as possible) +** when saveCursorPosition() was called. Note that this call deletes the +** saved position info stored by saveCursorPosition(), so there can be +** at most one effective restoreCursorPosition() call after each +** saveCursorPosition(). +*/ +static int btreeRestoreCursorPosition( BtCursor pCur ) +{ + int rc; + Debug.Assert( cursorHoldsMutex( pCur ) ); + Debug.Assert( pCur.eState >= CURSOR_REQUIRESEEK ); + if ( pCur.eState == CURSOR_FAULT ) + { + return pCur.skipNext; + } + pCur.eState = CURSOR_INVALID; + rc = btreeMoveto( pCur, pCur.pKey, pCur.nKey, 0, ref pCur.skipNext ); + if ( rc == SQLITE_OK ) + { + //sqlite3_free(ref pCur.pKey); + pCur.pKey = null; + Debug.Assert( pCur.eState == CURSOR_VALID || pCur.eState == CURSOR_INVALID ); + } + return rc; +} - /* - ** Determine whether or not a cursor has moved from the position it - ** was last placed at. Cursors can move when the row they are pointing - ** at is deleted out from under them. - ** - ** This routine returns an error code if something goes wrong. The - ** integer pHasMoved is set to one if the cursor has moved and 0 if not. - */ - static int sqlite3BtreeCursorHasMoved(BtCursor pCur, ref int pHasMoved) { - int rc; +//#define restoreCursorPosition(p) \ +// (p.eState>=CURSOR_REQUIRESEEK ? \ +// btreeRestoreCursorPosition(p) : \ +// SQLITE_OK) +static int restoreCursorPosition( BtCursor pCur ) +{ + if ( pCur.eState >= CURSOR_REQUIRESEEK ) + return btreeRestoreCursorPosition( pCur ); + else + return SQLITE_OK; +} - rc = restoreCursorPosition(pCur); - if (rc != 0) { - pHasMoved = 1; - return rc; - } - if (pCur.eState != CURSOR_VALID || pCur.skipNext != 0) { - pHasMoved = 1; - } else { - pHasMoved = 0; - } - return SQLITE_OK; - } +/* +** Determine whether or not a cursor has moved from the position it +** was last placed at. Cursors can move when the row they are pointing +** at is deleted out from under them. +** +** This routine returns an error code if something goes wrong. The +** integer pHasMoved is set to one if the cursor has moved and 0 if not. +*/ +static int sqlite3BtreeCursorHasMoved( BtCursor pCur, ref int pHasMoved ) +{ + int rc; + + rc = restoreCursorPosition( pCur ); + if ( rc != 0 ) + { + pHasMoved = 1; + return rc; + } + if ( pCur.eState != CURSOR_VALID || pCur.skipNext != 0 ) + { + pHasMoved = 1; + } + else + { + pHasMoved = 0; + } + return SQLITE_OK; +} #if !SQLITE_OMIT_AUTOVACUUM - /* - ** Given a page number of a regular database page, return the page - ** number for the pointer-map page that contains the entry for the - ** input page number. - ** - ** Return 0 (not a valid page) for pgno==1 since there is - ** no pointer map associated with page 1. The integrity_check logic - ** requires that ptrmapPageno(*,1)!=1. - */ - static Pgno ptrmapPageno(BtShared pBt, Pgno pgno) { - int nPagesPerMapPage; - Pgno iPtrMap, ret; - Debug.Assert(sqlite3_mutex_held(pBt.mutex)); - if (pgno < 2) - return 0; - nPagesPerMapPage = (int)(pBt.usableSize / 5 + 1); - iPtrMap = (Pgno)((pgno - 2) / nPagesPerMapPage); - ret = (Pgno)(iPtrMap * nPagesPerMapPage) + 2; - if (ret == PENDING_BYTE_PAGE(pBt)) { - ret++; - } - return ret; - } - - /* - ** Write an entry into the pointer map. - ** - ** This routine updates the pointer map entry for page number 'key' - ** so that it maps to type 'eType' and parent page number 'pgno'. - ** - ** If pRC is initially non-zero (non-SQLITE_OK) then this routine is - ** a no-op. If an error occurs, the appropriate error code is written - ** into pRC. - */ - static void ptrmapPut(BtShared pBt, Pgno key, u8 eType, Pgno parent, ref int pRC) { - PgHdr pDbPage = new PgHdr(); /* The pointer map page */ - u8[] pPtrmap; /* The pointer map data */ - Pgno iPtrmap; /* The pointer map page number */ - int offset; /* Offset in pointer map page */ - int rc; /* Return code from subfunctions */ - - if (pRC != 0) - return; - - Debug.Assert(sqlite3_mutex_held(pBt.mutex)); - /* The master-journal page number must never be used as a pointer map page */ - Debug.Assert(false == PTRMAP_ISPAGE(pBt, PENDING_BYTE_PAGE(pBt))); - - Debug.Assert(pBt.autoVacuum); - if (key == 0) { - pRC = SQLITE_CORRUPT_BKPT(); - return; - } - iPtrmap = PTRMAP_PAGENO(pBt, key); - rc = sqlite3PagerGet(pBt.pPager, iPtrmap, ref pDbPage); - if (rc != SQLITE_OK) { - pRC = rc; - return; - } - offset = (int)PTRMAP_PTROFFSET(iPtrmap, key); - if (offset < 0) { - pRC = SQLITE_CORRUPT_BKPT(); - goto ptrmap_exit; - } - Debug.Assert(offset <= (int)pBt.usableSize - 5); - pPtrmap = sqlite3PagerGetData(pDbPage); - - if (eType != pPtrmap[offset] || sqlite3Get4byte(pPtrmap, offset + 1) != parent) { - TRACE("PTRMAP_UPDATE: %d->(%d,%d)\n", key, eType, parent); - pRC = rc = sqlite3PagerWrite(pDbPage); - if (rc == SQLITE_OK) { - pPtrmap[offset] = eType; - sqlite3Put4byte(pPtrmap, offset + 1, parent); - } - } +/* +** Given a page number of a regular database page, return the page +** number for the pointer-map page that contains the entry for the +** input page number. +** +** Return 0 (not a valid page) for pgno==1 since there is +** no pointer map associated with page 1. The integrity_check logic +** requires that ptrmapPageno(*,1)!=1. +*/ +static Pgno ptrmapPageno( BtShared pBt, Pgno pgno ) +{ + int nPagesPerMapPage; + Pgno iPtrMap, ret; + Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); + if ( pgno < 2 ) + return 0; + nPagesPerMapPage = (int)( pBt.usableSize / 5 + 1 ); + iPtrMap = (Pgno)( ( pgno - 2 ) / nPagesPerMapPage ); + ret = (Pgno)( iPtrMap * nPagesPerMapPage ) + 2; + if ( ret == PENDING_BYTE_PAGE( pBt ) ) + { + ret++; + } + return ret; +} - ptrmap_exit: - sqlite3PagerUnref(pDbPage); - } +/* +** Write an entry into the pointer map. +** +** This routine updates the pointer map entry for page number 'key' +** so that it maps to type 'eType' and parent page number 'pgno'. +** +** If pRC is initially non-zero (non-SQLITE_OK) then this routine is +** a no-op. If an error occurs, the appropriate error code is written +** into pRC. +*/ +static void ptrmapPut( BtShared pBt, Pgno key, u8 eType, Pgno parent, ref int pRC ) +{ + PgHdr pDbPage = new PgHdr(); /* The pointer map page */ + u8[] pPtrmap; /* The pointer map data */ + Pgno iPtrmap; /* The pointer map page number */ + int offset; /* Offset in pointer map page */ + int rc; /* Return code from subfunctions */ + + if ( pRC != 0 ) + return; + + Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); + /* The master-journal page number must never be used as a pointer map page */ + Debug.Assert( false == PTRMAP_ISPAGE( pBt, PENDING_BYTE_PAGE( pBt ) ) ); + + Debug.Assert( pBt.autoVacuum ); + if ( key == 0 ) + { + pRC = SQLITE_CORRUPT_BKPT(); + return; + } + iPtrmap = PTRMAP_PAGENO( pBt, key ); + rc = sqlite3PagerGet( pBt.pPager, iPtrmap, ref pDbPage ); + if ( rc != SQLITE_OK ) + { + pRC = rc; + return; + } + offset = (int)PTRMAP_PTROFFSET( iPtrmap, key ); + if ( offset < 0 ) + { + pRC = SQLITE_CORRUPT_BKPT(); + goto ptrmap_exit; + } + Debug.Assert( offset <= (int)pBt.usableSize - 5 ); + pPtrmap = sqlite3PagerGetData( pDbPage ); + + if ( eType != pPtrmap[offset] || sqlite3Get4byte( pPtrmap, offset + 1 ) != parent ) + { + TRACE( "PTRMAP_UPDATE: %d->(%d,%d)\n", key, eType, parent ); + pRC = rc = sqlite3PagerWrite( pDbPage ); + if ( rc == SQLITE_OK ) + { + pPtrmap[offset] = eType; + sqlite3Put4byte( pPtrmap, offset + 1, parent ); + } + } - /* - ** Read an entry from the pointer map. - ** - ** This routine retrieves the pointer map entry for page 'key', writing - ** the type and parent page number to pEType and pPgno respectively. - ** An error code is returned if something goes wrong, otherwise SQLITE_OK. - */ - static int ptrmapGet(BtShared pBt, Pgno key, ref u8 pEType, ref Pgno pPgno) { - PgHdr pDbPage = new PgHdr();/* The pointer map page */ - int iPtrmap; /* Pointer map page index */ - u8[] pPtrmap; /* Pointer map page data */ - int offset; /* Offset of entry in pointer map */ - int rc; - - Debug.Assert(sqlite3_mutex_held(pBt.mutex)); - - iPtrmap = (int)PTRMAP_PAGENO(pBt, key); - rc = sqlite3PagerGet(pBt.pPager, (u32)iPtrmap, ref pDbPage); - if (rc != 0) { - return rc; - } - pPtrmap = sqlite3PagerGetData(pDbPage); +ptrmap_exit: + sqlite3PagerUnref( pDbPage ); +} - offset = (int)PTRMAP_PTROFFSET((u32)iPtrmap, key); - if (offset < 0) { - sqlite3PagerUnref(pDbPage); - return SQLITE_CORRUPT_BKPT(); - } - Debug.Assert(offset <= (int)pBt.usableSize - 5); - // Under C# pEType will always exist. No need to test; // - //Debug.Assert( pEType != 0 ); - pEType = pPtrmap[offset]; - // Under C# pPgno will always exist. No need to test; // - //if ( pPgno != 0 ) - pPgno = sqlite3Get4byte(pPtrmap, offset + 1); - - sqlite3PagerUnref(pDbPage); - if (pEType < 1 || pEType > 5) - return SQLITE_CORRUPT_BKPT(); - return SQLITE_OK; - } +/* +** Read an entry from the pointer map. +** +** This routine retrieves the pointer map entry for page 'key', writing +** the type and parent page number to pEType and pPgno respectively. +** An error code is returned if something goes wrong, otherwise SQLITE_OK. +*/ +static int ptrmapGet( BtShared pBt, Pgno key, ref u8 pEType, ref Pgno pPgno ) +{ + PgHdr pDbPage = new PgHdr();/* The pointer map page */ + int iPtrmap; /* Pointer map page index */ + u8[] pPtrmap; /* Pointer map page data */ + int offset; /* Offset of entry in pointer map */ + int rc; + + Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); + + iPtrmap = (int)PTRMAP_PAGENO( pBt, key ); + rc = sqlite3PagerGet( pBt.pPager, (u32)iPtrmap, ref pDbPage ); + if ( rc != 0 ) + { + return rc; + } + pPtrmap = sqlite3PagerGetData( pDbPage ); + + offset = (int)PTRMAP_PTROFFSET( (u32)iPtrmap, key ); + if ( offset < 0 ) + { + sqlite3PagerUnref( pDbPage ); + return SQLITE_CORRUPT_BKPT(); + } + Debug.Assert( offset <= (int)pBt.usableSize - 5 ); + // Under C# pEType will always exist. No need to test; // + //Debug.Assert( pEType != 0 ); + pEType = pPtrmap[offset]; + // Under C# pPgno will always exist. No need to test; // + //if ( pPgno != 0 ) + pPgno = sqlite3Get4byte( pPtrmap, offset + 1 ); + + sqlite3PagerUnref( pDbPage ); + if ( pEType < 1 || pEType > 5 ) + return SQLITE_CORRUPT_BKPT(); + return SQLITE_OK; +} #else //* if defined SQLITE_OMIT_AUTOVACUUM */ //#define ptrmapPut(w,x,y,z,rc) @@ -917,332 +969,374 @@ static int ptrmapGet(BtShared pBt, Pgno key, ref u8 pEType, ref Pgno pPgno) { //#define ptrmapPutOvflPtr(x, y, rc) #endif - /* - ** Given a btree page and a cell index (0 means the first cell on - ** the page, 1 means the second cell, and so forth) return a pointer - ** to the cell content. - ** - ** This routine works only for pages that do not contain overflow cells. - */ - //#define findCell(P,I) \ - // ((P).aData + ((P).maskPage & get2byte((P).aData[(P).cellOffset+2*(I)]))) - static int findCell(MemPage pPage, int iCell) { - return get2byte(pPage.aData, pPage.cellOffset + 2 * (iCell)); - } +/* +** Given a btree page and a cell index (0 means the first cell on +** the page, 1 means the second cell, and so forth) return a pointer +** to the cell content. +** +** This routine works only for pages that do not contain overflow cells. +*/ +//#define findCell(P,I) \ +// ((P).aData + ((P).maskPage & get2byte((P).aData[(P).cellOffset+2*(I)]))) +static int findCell( MemPage pPage, int iCell ) +{ + return get2byte( pPage.aData, pPage.cellOffset + 2 * ( iCell ) ); +} - //#define findCellv2(D,M,O,I) (D+(M&get2byte(D+(O+2*(I))))) - static u8[] findCellv2(u8[] pPage, u16 iCell, u16 O, int I) { - Debugger.Break(); - return pPage; - } +//#define findCellv2(D,M,O,I) (D+(M&get2byte(D+(O+2*(I))))) +static u8[] findCellv2( u8[] pPage, u16 iCell, u16 O, int I ) +{ + Debugger.Break(); + return pPage; +} - /* - ** This a more complex version of findCell() that works for - ** pages that do contain overflow cells. - */ - static int findOverflowCell(MemPage pPage, int iCell) { - int i; - Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); - for (i = pPage.nOverflow - 1; i >= 0; i--) { - int k; - _OvflCell pOvfl; - pOvfl = pPage.aOvfl[i]; - k = pOvfl.idx; - if (k <= iCell) { - if (k == iCell) { - //return pOvfl.pCell; - return -i - 1; // Negative Offset means overflow cells - } - iCell--; - } - } - return findCell(pPage, iCell); - } +/* +** This a more complex version of findCell() that works for +** pages that do contain overflow cells. +*/ +static int findOverflowCell( MemPage pPage, int iCell ) +{ + int i; + Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); + for ( i = pPage.nOverflow - 1; i >= 0; i-- ) + { + int k; + _OvflCell pOvfl; + pOvfl = pPage.aOvfl[i]; + k = pOvfl.idx; + if ( k <= iCell ) + { + if ( k == iCell ) + { + //return pOvfl.pCell; + return -i - 1; // Negative Offset means overflow cells + } + iCell--; + } + } + return findCell( pPage, iCell ); +} - /* - ** Parse a cell content block and fill in the CellInfo structure. There - ** are two versions of this function. btreeParseCell() takes a - ** cell index as the second argument and btreeParseCellPtr() - ** takes a pointer to the body of the cell as its second argument. - ** - ** Within this file, the parseCell() macro can be called instead of - ** btreeParseCellPtr(). Using some compilers, this will be faster. - */ - //OVERLOADS - static void btreeParseCellPtr( - MemPage pPage, /* Page containing the cell */ - int iCell, /* Pointer to the cell text. */ - ref CellInfo pInfo /* Fill in this structure */ - ) { - btreeParseCellPtr(pPage, pPage.aData, iCell, ref pInfo); - } - static void btreeParseCellPtr( - MemPage pPage, /* Page containing the cell */ - byte[] pCell, /* The actual data */ - ref CellInfo pInfo /* Fill in this structure */ - ) { - btreeParseCellPtr(pPage, pCell, 0, ref pInfo); - } - static void btreeParseCellPtr( - MemPage pPage, /* Page containing the cell */ - u8[] pCell, /* Pointer to the cell text. */ - int iCell, /* Pointer to the cell text. */ - ref CellInfo pInfo /* Fill in this structure */ - ) { - u16 n; /* Number bytes in cell content header */ - u32 nPayload = 0; /* Number of bytes of cell payload */ - - Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); - - if (pInfo.pCell != pCell) - pInfo.pCell = pCell; - pInfo.iCell = iCell; - Debug.Assert(pPage.leaf == 0 || pPage.leaf == 1); - n = pPage.childPtrSize; - Debug.Assert(n == 4 - 4 * pPage.leaf); - if (pPage.intKey != 0) { - if (pPage.hasData != 0) { - n += (u16)getVarint32(pCell, iCell + n, out nPayload); - } else { - nPayload = 0; - } - n += (u16)getVarint(pCell, iCell + n, out pInfo.nKey); - pInfo.nData = nPayload; - } else { - pInfo.nData = 0; - n += (u16)getVarint32(pCell, iCell + n, out nPayload); - pInfo.nKey = nPayload; - } - pInfo.nPayload = nPayload; - pInfo.nHeader = n; - testcase(nPayload == pPage.maxLocal); - testcase(nPayload == pPage.maxLocal + 1); - if (likely(nPayload <= pPage.maxLocal)) { - /* This is the (easy) common case where the entire payload fits - ** on the local page. No overflow is required. - */ - if ((pInfo.nSize = (u16)(n + nPayload)) < 4) - pInfo.nSize = 4; - pInfo.nLocal = (u16)nPayload; - pInfo.iOverflow = 0; - } else { - /* If the payload will not fit completely on the local page, we have - ** to decide how much to store locally and how much to spill onto - ** overflow pages. The strategy is to minimize the amount of unused - ** space on overflow pages while keeping the amount of local storage - ** in between minLocal and maxLocal. - ** - ** Warning: changing the way overflow payload is distributed in any - ** way will result in an incompatible file format. - */ - int minLocal; /* Minimum amount of payload held locally */ - int maxLocal; /* Maximum amount of payload held locally */ - int surplus; /* Overflow payload available for local storage */ - - minLocal = pPage.minLocal; - maxLocal = pPage.maxLocal; - surplus = (int)(minLocal + (nPayload - minLocal) % (pPage.pBt.usableSize - 4)); - testcase(surplus == maxLocal); - testcase(surplus == maxLocal + 1); - if (surplus <= maxLocal) { - pInfo.nLocal = (u16)surplus; - } else { - pInfo.nLocal = (u16)minLocal; - } - pInfo.iOverflow = (u16)(pInfo.nLocal + n); - pInfo.nSize = (u16)(pInfo.iOverflow + 4); - } - } - //#define parseCell(pPage, iCell, pInfo) \ - // btreeParseCellPtr((pPage), findCell((pPage), (iCell)), (pInfo)) - static void parseCell(MemPage pPage, int iCell, ref CellInfo pInfo) { - btreeParseCellPtr(pPage, findCell(pPage, iCell), ref pInfo); - } +/* +** Parse a cell content block and fill in the CellInfo structure. There +** are two versions of this function. btreeParseCell() takes a +** cell index as the second argument and btreeParseCellPtr() +** takes a pointer to the body of the cell as its second argument. +** +** Within this file, the parseCell() macro can be called instead of +** btreeParseCellPtr(). Using some compilers, this will be faster. +*/ +//OVERLOADS +static void btreeParseCellPtr( +MemPage pPage, /* Page containing the cell */ +int iCell, /* Pointer to the cell text. */ +ref CellInfo pInfo /* Fill in this structure */ +) +{ + btreeParseCellPtr( pPage, pPage.aData, iCell, ref pInfo ); +} +static void btreeParseCellPtr( +MemPage pPage, /* Page containing the cell */ +byte[] pCell, /* The actual data */ +ref CellInfo pInfo /* Fill in this structure */ +) +{ + btreeParseCellPtr( pPage, pCell, 0, ref pInfo ); +} +static void btreeParseCellPtr( +MemPage pPage, /* Page containing the cell */ +u8[] pCell, /* Pointer to the cell text. */ +int iCell, /* Pointer to the cell text. */ +ref CellInfo pInfo /* Fill in this structure */ +) +{ + u16 n; /* Number bytes in cell content header */ + u32 nPayload = 0; /* Number of bytes of cell payload */ + + Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); + + if ( pInfo.pCell != pCell ) + pInfo.pCell = pCell; + pInfo.iCell = iCell; + Debug.Assert( pPage.leaf == 0 || pPage.leaf == 1 ); + n = pPage.childPtrSize; + Debug.Assert( n == 4 - 4 * pPage.leaf ); + if ( pPage.intKey != 0 ) + { + if ( pPage.hasData != 0 ) + { + n += (u16)getVarint32( pCell, iCell + n, out nPayload ); + } + else + { + nPayload = 0; + } + n += (u16)getVarint( pCell, iCell + n, out pInfo.nKey ); + pInfo.nData = nPayload; + } + else + { + pInfo.nData = 0; + n += (u16)getVarint32( pCell, iCell + n, out nPayload ); + pInfo.nKey = nPayload; + } + pInfo.nPayload = nPayload; + pInfo.nHeader = n; + testcase( nPayload == pPage.maxLocal ); + testcase( nPayload == pPage.maxLocal + 1 ); + if ( likely( nPayload <= pPage.maxLocal ) ) + { + /* This is the (easy) common case where the entire payload fits + ** on the local page. No overflow is required. + */ + if ( ( pInfo.nSize = (u16)( n + nPayload ) ) < 4 ) + pInfo.nSize = 4; + pInfo.nLocal = (u16)nPayload; + pInfo.iOverflow = 0; + } + else + { + /* If the payload will not fit completely on the local page, we have + ** to decide how much to store locally and how much to spill onto + ** overflow pages. The strategy is to minimize the amount of unused + ** space on overflow pages while keeping the amount of local storage + ** in between minLocal and maxLocal. + ** + ** Warning: changing the way overflow payload is distributed in any + ** way will result in an incompatible file format. + */ + int minLocal; /* Minimum amount of payload held locally */ + int maxLocal; /* Maximum amount of payload held locally */ + int surplus; /* Overflow payload available for local storage */ + + minLocal = pPage.minLocal; + maxLocal = pPage.maxLocal; + surplus = (int)( minLocal + ( nPayload - minLocal ) % ( pPage.pBt.usableSize - 4 ) ); + testcase( surplus == maxLocal ); + testcase( surplus == maxLocal + 1 ); + if ( surplus <= maxLocal ) + { + pInfo.nLocal = (u16)surplus; + } + else + { + pInfo.nLocal = (u16)minLocal; + } + pInfo.iOverflow = (u16)( pInfo.nLocal + n ); + pInfo.nSize = (u16)( pInfo.iOverflow + 4 ); + } +} +//#define parseCell(pPage, iCell, pInfo) \ +// btreeParseCellPtr((pPage), findCell((pPage), (iCell)), (pInfo)) +static void parseCell( MemPage pPage, int iCell, ref CellInfo pInfo ) +{ + btreeParseCellPtr( pPage, findCell( pPage, iCell ), ref pInfo ); +} - static void btreeParseCell( - MemPage pPage, /* Page containing the cell */ - int iCell, /* The cell index. First cell is 0 */ - ref CellInfo pInfo /* Fill in this structure */ - ) { - parseCell(pPage, iCell, ref pInfo); - } +static void btreeParseCell( +MemPage pPage, /* Page containing the cell */ +int iCell, /* The cell index. First cell is 0 */ +ref CellInfo pInfo /* Fill in this structure */ +) +{ + parseCell( pPage, iCell, ref pInfo ); +} - /* - ** Compute the total number of bytes that a Cell needs in the cell - ** data area of the btree-page. The return number includes the cell - ** data header and the local payload, but not any overflow page or - ** the space used by the cell pointer. - */ - // Alternative form for C# - static u16 cellSizePtr(MemPage pPage, int iCell) { - CellInfo info = new CellInfo(); - byte[] pCell = new byte[13]; - // Minimum Size = (2 bytes of Header or (4) Child Pointer) + (maximum of) 9 bytes data - if (iCell < 0)// Overflow Cell - Buffer.BlockCopy(pPage.aOvfl[-(iCell + 1)].pCell, 0, pCell, 0, pCell.Length < pPage.aOvfl[-(iCell + 1)].pCell.Length ? pCell.Length : pPage.aOvfl[-(iCell + 1)].pCell.Length); - else if (iCell >= pPage.aData.Length + 1 - pCell.Length) - Buffer.BlockCopy(pPage.aData, iCell, pCell, 0, pPage.aData.Length - iCell); - else - Buffer.BlockCopy(pPage.aData, iCell, pCell, 0, pCell.Length); - btreeParseCellPtr(pPage, pCell, ref info); - return info.nSize; - } +/* +** Compute the total number of bytes that a Cell needs in the cell +** data area of the btree-page. The return number includes the cell +** data header and the local payload, but not any overflow page or +** the space used by the cell pointer. +*/ +// Alternative form for C# +static u16 cellSizePtr( MemPage pPage, int iCell ) +{ + CellInfo info = new CellInfo(); + byte[] pCell = new byte[13]; + // Minimum Size = (2 bytes of Header or (4) Child Pointer) + (maximum of) 9 bytes data + if ( iCell < 0 )// Overflow Cell + Buffer.BlockCopy( pPage.aOvfl[-( iCell + 1 )].pCell, 0, pCell, 0, pCell.Length < pPage.aOvfl[-( iCell + 1 )].pCell.Length ? pCell.Length : pPage.aOvfl[-( iCell + 1 )].pCell.Length ); + else if ( iCell >= pPage.aData.Length + 1 - pCell.Length ) + Buffer.BlockCopy( pPage.aData, iCell, pCell, 0, pPage.aData.Length - iCell ); + else + Buffer.BlockCopy( pPage.aData, iCell, pCell, 0, pCell.Length ); + btreeParseCellPtr( pPage, pCell, ref info ); + return info.nSize; +} - // Alternative form for C# - static u16 cellSizePtr(MemPage pPage, byte[] pCell, int offset) { - CellInfo info = new CellInfo(); - info.pCell = sqlite3Malloc(pCell.Length); - Buffer.BlockCopy(pCell, offset, info.pCell, 0, pCell.Length - offset); - btreeParseCellPtr(pPage, info.pCell, ref info); - return info.nSize; - } +// Alternative form for C# +static u16 cellSizePtr( MemPage pPage, byte[] pCell, int offset ) +{ + CellInfo info = new CellInfo(); + info.pCell = sqlite3Malloc( pCell.Length ); + Buffer.BlockCopy( pCell, offset, info.pCell, 0, pCell.Length - offset ); + btreeParseCellPtr( pPage, info.pCell, ref info ); + return info.nSize; +} - static u16 cellSizePtr(MemPage pPage, u8[] pCell) { - int _pIter = pPage.childPtrSize; //u8 pIter = &pCell[pPage.childPtrSize]; - u32 nSize = 0; +static u16 cellSizePtr( MemPage pPage, u8[] pCell ) +{ + int _pIter = pPage.childPtrSize; //u8 pIter = &pCell[pPage.childPtrSize]; + u32 nSize = 0; #if SQLITE_DEBUG || DEBUG - /* The value returned by this function should always be the same as - ** the (CellInfo.nSize) value found by doing a full parse of the - ** cell. If SQLITE_DEBUG is defined, an Debug.Assert() at the bottom of - ** this function verifies that this invariant is not violated. */ - CellInfo debuginfo = new CellInfo(); - btreeParseCellPtr(pPage, pCell, ref debuginfo); + /* The value returned by this function should always be the same as +** the (CellInfo.nSize) value found by doing a full parse of the +** cell. If SQLITE_DEBUG is defined, an Debug.Assert() at the bottom of +** this function verifies that this invariant is not violated. */ + CellInfo debuginfo = new CellInfo(); + btreeParseCellPtr( pPage, pCell, ref debuginfo ); #else CellInfo debuginfo = new CellInfo(); #endif - if (pPage.intKey != 0) { - int pEnd; - if (pPage.hasData != 0) { - _pIter += getVarint32(pCell, out nSize);// pIter += getVarint32( pIter, out nSize ); - } else { - nSize = 0; - } - - /* pIter now points at the 64-bit integer key value, a variable length - ** integer. The following block moves pIter to point at the first byte - ** past the end of the key value. */ - pEnd = _pIter + 9;//pEnd = &pIter[9]; - while (((pCell[_pIter++]) & 0x80) != 0 && _pIter < pEnd) - ;//while( (pIter++)&0x80 && pIter pPage.maxLocal) { - int minLocal = pPage.minLocal; - nSize = (u32)(minLocal + (nSize - minLocal) % (pPage.pBt.usableSize - 4)); - testcase(nSize == pPage.maxLocal); - testcase(nSize == pPage.maxLocal + 1); - if (nSize > pPage.maxLocal) { - nSize = (u32)minLocal; - } - nSize += 4; - } - nSize += (uint)_pIter;//nSize += (u32)(pIter - pCell); - - /* The minimum size of any cell is 4 bytes. */ - if (nSize < 4) { - nSize = 4; - } + if ( pPage.intKey != 0 ) + { + int pEnd; + if ( pPage.hasData != 0 ) + { + _pIter += getVarint32( pCell, out nSize );// pIter += getVarint32( pIter, out nSize ); + } + else + { + nSize = 0; + } - Debug.Assert(nSize == debuginfo.nSize); - return (u16)nSize; - } + /* pIter now points at the 64-bit integer key value, a variable length + ** integer. The following block moves pIter to point at the first byte + ** past the end of the key value. */ + pEnd = _pIter + 9;//pEnd = &pIter[9]; + while ( ( ( pCell[_pIter++] ) & 0x80 ) != 0 && _pIter < pEnd ) + ;//while( (pIter++)&0x80 && pIter pPage.maxLocal ) + { + int minLocal = pPage.minLocal; + nSize = (u32)( minLocal + ( nSize - minLocal ) % ( pPage.pBt.usableSize - 4 ) ); + testcase( nSize == pPage.maxLocal ); + testcase( nSize == pPage.maxLocal + 1 ); + if ( nSize > pPage.maxLocal ) + { + nSize = (u32)minLocal; + } + nSize += 4; + } + nSize += (uint)_pIter;//nSize += (u32)(pIter - pCell); + + /* The minimum size of any cell is 4 bytes. */ + if ( nSize < 4 ) + { + nSize = 4; + } + + Debug.Assert( nSize == debuginfo.nSize ); + return (u16)nSize; +} #if SQLITE_DEBUG - /* This variation on cellSizePtr() is used inside of assert() statements - ** only. */ - static u16 cellSize(MemPage pPage, int iCell) { - return cellSizePtr(pPage, findCell(pPage, iCell)); - } +/* This variation on cellSizePtr() is used inside of assert() statements +** only. */ +static u16 cellSize( MemPage pPage, int iCell ) +{ + return cellSizePtr( pPage, findCell( pPage, iCell ) ); +} #else static int cellSize(MemPage pPage, int iCell) { return -1; } #endif #if !SQLITE_OMIT_AUTOVACUUM - /* - ** If the cell pCell, part of page pPage contains a pointer - ** to an overflow page, insert an entry into the pointer-map - ** for the overflow page. - */ - static void ptrmapPutOvflPtr(MemPage pPage, int pCell, ref int pRC) { - if (pRC != 0) - return; - CellInfo info = new CellInfo(); - Debug.Assert(pCell != 0); - btreeParseCellPtr(pPage, pCell, ref info); - Debug.Assert((info.nData + (pPage.intKey != 0 ? 0 : info.nKey)) == info.nPayload); - if (info.iOverflow != 0) { - Pgno ovfl = sqlite3Get4byte(pPage.aData, pCell, info.iOverflow); - ptrmapPut(pPage.pBt, ovfl, PTRMAP_OVERFLOW1, pPage.pgno, ref pRC); - } - } +/* +** If the cell pCell, part of page pPage contains a pointer +** to an overflow page, insert an entry into the pointer-map +** for the overflow page. +*/ +static void ptrmapPutOvflPtr( MemPage pPage, int pCell, ref int pRC ) +{ + if ( pRC != 0 ) + return; + CellInfo info = new CellInfo(); + Debug.Assert( pCell != 0 ); + btreeParseCellPtr( pPage, pCell, ref info ); + Debug.Assert( ( info.nData + ( pPage.intKey != 0 ? 0 : info.nKey ) ) == info.nPayload ); + if ( info.iOverflow != 0 ) + { + Pgno ovfl = sqlite3Get4byte( pPage.aData, pCell, info.iOverflow ); + ptrmapPut( pPage.pBt, ovfl, PTRMAP_OVERFLOW1, pPage.pgno, ref pRC ); + } +} - static void ptrmapPutOvflPtr(MemPage pPage, u8[] pCell, ref int pRC) { - if (pRC != 0) - return; - CellInfo info = new CellInfo(); - Debug.Assert(pCell != null); - btreeParseCellPtr(pPage, pCell, ref info); - Debug.Assert((info.nData + (pPage.intKey != 0 ? 0 : info.nKey)) == info.nPayload); - if (info.iOverflow != 0) { - Pgno ovfl = sqlite3Get4byte(pCell, info.iOverflow); - ptrmapPut(pPage.pBt, ovfl, PTRMAP_OVERFLOW1, pPage.pgno, ref pRC); - } - } +static void ptrmapPutOvflPtr( MemPage pPage, u8[] pCell, ref int pRC ) +{ + if ( pRC != 0 ) + return; + CellInfo info = new CellInfo(); + Debug.Assert( pCell != null ); + btreeParseCellPtr( pPage, pCell, ref info ); + Debug.Assert( ( info.nData + ( pPage.intKey != 0 ? 0 : info.nKey ) ) == info.nPayload ); + if ( info.iOverflow != 0 ) + { + Pgno ovfl = sqlite3Get4byte( pCell, info.iOverflow ); + ptrmapPut( pPage.pBt, ovfl, PTRMAP_OVERFLOW1, pPage.pgno, ref pRC ); + } +} #endif - /* - ** Defragment the page given. All Cells are moved to the - ** end of the page and all free space is collected into one - ** big FreeBlk that occurs in between the header and cell - ** pointer array and the cell content area. - */ - static int defragmentPage(MemPage pPage) { - int i; /* Loop counter */ - int pc; /* Address of a i-th cell */ - int addr; /* Offset of first byte after cell pointer array */ - int hdr; /* Offset to the page header */ - int size; /* Size of a cell */ - int usableSize; /* Number of usable bytes on a page */ - int cellOffset; /* Offset to the cell pointer array */ - int cbrk; /* Offset to the cell content area */ - int nCell; /* Number of cells on the page */ - byte[] data; /* The page data */ - byte[] temp; /* Temp area for cell content */ - int iCellFirst; /* First allowable cell index */ - int iCellLast; /* Last possible cell index */ - - - Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); - Debug.Assert(pPage.pBt != null); - Debug.Assert(pPage.pBt.usableSize <= SQLITE_MAX_PAGE_SIZE); - Debug.Assert(pPage.nOverflow == 0); - Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); - temp = sqlite3PagerTempSpace(pPage.pBt.pPager); - data = pPage.aData; - hdr = pPage.hdrOffset; - cellOffset = pPage.cellOffset; - nCell = pPage.nCell; - Debug.Assert(nCell == get2byte(data, hdr + 3)); - usableSize = (int)pPage.pBt.usableSize; - cbrk = get2byte(data, hdr + 5); - Buffer.BlockCopy(data, cbrk, temp, cbrk, usableSize - cbrk);//memcpy( temp[cbrk], ref data[cbrk], usableSize - cbrk ); - cbrk = usableSize; - iCellFirst = cellOffset + 2 * nCell; - iCellLast = usableSize - 4; - for (i = 0; i < nCell; i++) { - int pAddr; /* The i-th cell pointer */ - pAddr = cellOffset + i * 2; // &data[cellOffset + i * 2]; - pc = get2byte(data, pAddr); - testcase(pc == iCellFirst); - testcase(pc == iCellLast); +/* +** Defragment the page given. All Cells are moved to the +** end of the page and all free space is collected into one +** big FreeBlk that occurs in between the header and cell +** pointer array and the cell content area. +*/ +static int defragmentPage( MemPage pPage ) +{ + int i; /* Loop counter */ + int pc; /* Address of a i-th cell */ + int addr; /* Offset of first byte after cell pointer array */ + int hdr; /* Offset to the page header */ + int size; /* Size of a cell */ + int usableSize; /* Number of usable bytes on a page */ + int cellOffset; /* Offset to the cell pointer array */ + int cbrk; /* Offset to the cell content area */ + int nCell; /* Number of cells on the page */ + byte[] data; /* The page data */ + byte[] temp; /* Temp area for cell content */ + int iCellFirst; /* First allowable cell index */ + int iCellLast; /* Last possible cell index */ + + + Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); + Debug.Assert( pPage.pBt != null ); + Debug.Assert( pPage.pBt.usableSize <= SQLITE_MAX_PAGE_SIZE ); + Debug.Assert( pPage.nOverflow == 0 ); + Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); + temp = sqlite3PagerTempSpace( pPage.pBt.pPager ); + data = pPage.aData; + hdr = pPage.hdrOffset; + cellOffset = pPage.cellOffset; + nCell = pPage.nCell; + Debug.Assert( nCell == get2byte( data, hdr + 3 ) ); + usableSize = (int)pPage.pBt.usableSize; + cbrk = get2byte( data, hdr + 5 ); + Buffer.BlockCopy( data, cbrk, temp, cbrk, usableSize - cbrk );//memcpy( temp[cbrk], ref data[cbrk], usableSize - cbrk ); + cbrk = usableSize; + iCellFirst = cellOffset + 2 * nCell; + iCellLast = usableSize - 4; + for ( i = 0; i < nCell; i++ ) + { + int pAddr; /* The i-th cell pointer */ + pAddr = cellOffset + i * 2; // &data[cellOffset + i * 2]; + pc = get2byte( data, pAddr ); + testcase( pc == iCellFirst ); + testcase( pc == iCellLast ); #if !(SQLITE_ENABLE_OVERSIZE_CELL_CHECK) /* These conditions have already been verified in btreeInitPage() ** if SQLITE_ENABLE_OVERSIZE_CELL_CHECK is defined @@ -1252,670 +1346,737 @@ static int defragmentPage(MemPage pPage) { return SQLITE_CORRUPT_BKPT(); } #endif - Debug.Assert(pc >= iCellFirst && pc <= iCellLast); - size = cellSizePtr(pPage, temp, pc); - cbrk -= size; + Debug.Assert( pc >= iCellFirst && pc <= iCellLast ); + size = cellSizePtr( pPage, temp, pc ); + cbrk -= size; #if (SQLITE_ENABLE_OVERSIZE_CELL_CHECK) - if (cbrk < iCellFirst || pc + size > usableSize) { - return SQLITE_CORRUPT_BKPT(); - } + if ( cbrk < iCellFirst || pc + size > usableSize ) + { + return SQLITE_CORRUPT_BKPT(); + } #else if ( cbrk < iCellFirst || pc + size > usableSize ) { return SQLITE_CORRUPT_BKPT(); } #endif - Debug.Assert(cbrk + size <= usableSize && cbrk >= iCellFirst); - testcase(cbrk + size == usableSize); - testcase(pc + size == usableSize); - Buffer.BlockCopy(temp, pc, data, cbrk, size);//memcpy(data[cbrk], ref temp[pc], size); - put2byte(data, pAddr, cbrk); - } - Debug.Assert(cbrk >= iCellFirst); - put2byte(data, hdr + 5, cbrk); - data[hdr + 1] = 0; - data[hdr + 2] = 0; - data[hdr + 7] = 0; - addr = cellOffset + 2 * nCell; - Array.Clear(data, addr, cbrk - addr); //memset(data[iCellFirst], 0, cbrk-iCellFirst); - Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); - if (cbrk - iCellFirst != pPage.nFree) { - return SQLITE_CORRUPT_BKPT(); - } - return SQLITE_OK; - } - - /* - ** Allocate nByte bytes of space from within the B-Tree page passed - ** as the first argument. Write into pIdx the index into pPage.aData[] - ** of the first byte of allocated space. Return either SQLITE_OK or - ** an error code (usually SQLITE_CORRUPT). - ** - ** The caller guarantees that there is sufficient space to make the - ** allocation. This routine might need to defragment in order to bring - ** all the space together, however. This routine will avoid using - ** the first two bytes past the cell pointer area since presumably this - ** allocation is being made in order to insert a new cell, so we will - ** also end up needing a new cell pointer. - */ - static int allocateSpace(MemPage pPage, int nByte, ref int pIdx) { - int hdr = pPage.hdrOffset; /* Local cache of pPage.hdrOffset */ - u8[] data = pPage.aData; /* Local cache of pPage.aData */ - int nFrag; /* Number of fragmented bytes on pPage */ - int top; /* First byte of cell content area */ - int gap; /* First byte of gap between cell pointers and cell content */ - int rc; /* Integer return code */ - u32 usableSize; /* Usable size of the page */ - - Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); - Debug.Assert(pPage.pBt != null); - Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); - Debug.Assert(nByte >= 0); /* Minimum cell size is 4 */ - Debug.Assert(pPage.nFree >= nByte); - Debug.Assert(pPage.nOverflow == 0); - usableSize = pPage.pBt.usableSize; - Debug.Assert(nByte < usableSize - 8); - - nFrag = data[hdr + 7]; - Debug.Assert(pPage.cellOffset == hdr + 12 - 4 * pPage.leaf); - gap = pPage.cellOffset + 2 * pPage.nCell; - top = get2byteNotZero(data, hdr + 5); - if (gap > top) - return SQLITE_CORRUPT_BKPT(); - testcase(gap + 2 == top); - testcase(gap + 1 == top); - testcase(gap == top); - - if (nFrag >= 60) { - /* Always defragment highly fragmented pages */ - rc = defragmentPage(pPage); - if (rc != 0) - return rc; - top = get2byteNotZero(data, hdr + 5); - } else if (gap + 2 <= top) { - /* Search the freelist looking for a free slot big enough to satisfy - ** the request. The allocation is made from the first free slot in - ** the list that is large enough to accomadate it. - */ - int pc, addr; - for (addr = hdr + 1; (pc = get2byte(data, addr)) > 0; addr = pc) { - int size; /* Size of free slot */ - if (pc > usableSize - 4 || pc < addr + 4) { - return SQLITE_CORRUPT_BKPT(); - } - size = get2byte(data, pc + 2); - if (size >= nByte) { - int x = size - nByte; - testcase(x == 4); - testcase(x == 3); - if (x < 4) { - /* Remove the slot from the free-list. Update the number of - ** fragmented bytes within the page. */ - data[addr + 0] = data[pc + 0]; - data[addr + 1] = data[pc + 1]; //memcpy( data[addr], ref data[pc], 2 ); - data[hdr + 7] = (u8)(nFrag + x); - } else if (size + pc > usableSize) { - return SQLITE_CORRUPT_BKPT(); - } else { - /* The slot remains on the free-list. Reduce its size to account - ** for the portion used by the new allocation. */ - put2byte(data, pc + 2, x); - } - pIdx = pc + x; - return SQLITE_OK; - } - } - } - - /* Check to make sure there is enough space in the gap to satisfy - ** the allocation. If not, defragment. - */ - testcase(gap + 2 + nByte == top); - if (gap + 2 + nByte > top) { - rc = defragmentPage(pPage); - if (rc != 0) - return rc; - top = get2byteNotZero(data, hdr + 5); - Debug.Assert(gap + nByte <= top); - } - - - /* Allocate memory from the gap in between the cell pointer array - ** and the cell content area. The btreeInitPage() call has already - ** validated the freelist. Given that the freelist is valid, there - ** is no way that the allocation can extend off the end of the page. - ** The Debug.Assert() below verifies the previous sentence. - */ - top -= nByte; - put2byte(data, hdr + 5, top); - Debug.Assert(top + nByte <= (int)pPage.pBt.usableSize); - pIdx = top; - return SQLITE_OK; - } + Debug.Assert( cbrk + size <= usableSize && cbrk >= iCellFirst ); + testcase( cbrk + size == usableSize ); + testcase( pc + size == usableSize ); + Buffer.BlockCopy( temp, pc, data, cbrk, size );//memcpy(data[cbrk], ref temp[pc], size); + put2byte( data, pAddr, cbrk ); + } + Debug.Assert( cbrk >= iCellFirst ); + put2byte( data, hdr + 5, cbrk ); + data[hdr + 1] = 0; + data[hdr + 2] = 0; + data[hdr + 7] = 0; + addr = cellOffset + 2 * nCell; + Array.Clear( data, addr, cbrk - addr ); //memset(data[iCellFirst], 0, cbrk-iCellFirst); + Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); + if ( cbrk - iCellFirst != pPage.nFree ) + { + return SQLITE_CORRUPT_BKPT(); + } + return SQLITE_OK; +} - /* - ** Return a section of the pPage.aData to the freelist. - ** The first byte of the new free block is pPage.aDisk[start] - ** and the size of the block is "size" bytes. - ** - ** Most of the effort here is involved in coalesing adjacent - ** free blocks into a single big free block. - */ - static int freeSpace(MemPage pPage, u32 start, int size) { - return freeSpace(pPage, (int)start, size); - } - static int freeSpace(MemPage pPage, int start, int size) { - int addr, pbegin, hdr; - int iLast; /* Largest possible freeblock offset */ - byte[] data = pPage.aData; - - Debug.Assert(pPage.pBt != null); - Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); - Debug.Assert(start >= pPage.hdrOffset + 6 + pPage.childPtrSize); - Debug.Assert((start + size) <= (int)pPage.pBt.usableSize); - Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); - Debug.Assert(size >= 0); /* Minimum cell size is 4 */ - - if (pPage.pBt.secureDelete) { - /* Overwrite deleted information with zeros when the secure_delete - ** option is enabled */ - Array.Clear(data, start, size);// memset(&data[start], 0, size); - } +/* +** Allocate nByte bytes of space from within the B-Tree page passed +** as the first argument. Write into pIdx the index into pPage.aData[] +** of the first byte of allocated space. Return either SQLITE_OK or +** an error code (usually SQLITE_CORRUPT). +** +** The caller guarantees that there is sufficient space to make the +** allocation. This routine might need to defragment in order to bring +** all the space together, however. This routine will avoid using +** the first two bytes past the cell pointer area since presumably this +** allocation is being made in order to insert a new cell, so we will +** also end up needing a new cell pointer. +*/ +static int allocateSpace( MemPage pPage, int nByte, ref int pIdx ) +{ + int hdr = pPage.hdrOffset; /* Local cache of pPage.hdrOffset */ + u8[] data = pPage.aData; /* Local cache of pPage.aData */ + int nFrag; /* Number of fragmented bytes on pPage */ + int top; /* First byte of cell content area */ + int gap; /* First byte of gap between cell pointers and cell content */ + int rc; /* Integer return code */ + u32 usableSize; /* Usable size of the page */ + + Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); + Debug.Assert( pPage.pBt != null ); + Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); + Debug.Assert( nByte >= 0 ); /* Minimum cell size is 4 */ + Debug.Assert( pPage.nFree >= nByte ); + Debug.Assert( pPage.nOverflow == 0 ); + usableSize = pPage.pBt.usableSize; + Debug.Assert( nByte < usableSize - 8 ); + + nFrag = data[hdr + 7]; + Debug.Assert( pPage.cellOffset == hdr + 12 - 4 * pPage.leaf ); + gap = pPage.cellOffset + 2 * pPage.nCell; + top = get2byteNotZero( data, hdr + 5 ); + if ( gap > top ) + return SQLITE_CORRUPT_BKPT(); + testcase( gap + 2 == top ); + testcase( gap + 1 == top ); + testcase( gap == top ); + + if ( nFrag >= 60 ) + { + /* Always defragment highly fragmented pages */ + rc = defragmentPage( pPage ); + if ( rc != 0 ) + return rc; + top = get2byteNotZero( data, hdr + 5 ); + } + else if ( gap + 2 <= top ) + { + /* Search the freelist looking for a free slot big enough to satisfy + ** the request. The allocation is made from the first free slot in + ** the list that is large enough to accomadate it. + */ + int pc, addr; + for ( addr = hdr + 1; ( pc = get2byte( data, addr ) ) > 0; addr = pc ) + { + int size; /* Size of free slot */ + if ( pc > usableSize - 4 || pc < addr + 4 ) + { + return SQLITE_CORRUPT_BKPT(); + } + size = get2byte( data, pc + 2 ); + if ( size >= nByte ) + { + int x = size - nByte; + testcase( x == 4 ); + testcase( x == 3 ); + if ( x < 4 ) + { + /* Remove the slot from the free-list. Update the number of + ** fragmented bytes within the page. */ + data[addr + 0] = data[pc + 0]; + data[addr + 1] = data[pc + 1]; //memcpy( data[addr], ref data[pc], 2 ); + data[hdr + 7] = (u8)( nFrag + x ); + } + else if ( size + pc > usableSize ) + { + return SQLITE_CORRUPT_BKPT(); + } + else + { + /* The slot remains on the free-list. Reduce its size to account + ** for the portion used by the new allocation. */ + put2byte( data, pc + 2, x ); + } + pIdx = pc + x; + return SQLITE_OK; + } + } + } + + /* Check to make sure there is enough space in the gap to satisfy + ** the allocation. If not, defragment. + */ + testcase( gap + 2 + nByte == top ); + if ( gap + 2 + nByte > top ) + { + rc = defragmentPage( pPage ); + if ( rc != 0 ) + return rc; + top = get2byteNotZero( data, hdr + 5 ); + Debug.Assert( gap + nByte <= top ); + } + + + /* Allocate memory from the gap in between the cell pointer array + ** and the cell content area. The btreeInitPage() call has already + ** validated the freelist. Given that the freelist is valid, there + ** is no way that the allocation can extend off the end of the page. + ** The Debug.Assert() below verifies the previous sentence. + */ + top -= nByte; + put2byte( data, hdr + 5, top ); + Debug.Assert( top + nByte <= (int)pPage.pBt.usableSize ); + pIdx = top; + return SQLITE_OK; +} - /* Add the space back into the linked list of freeblocks. Note that - ** even though the freeblock list was checked by btreeInitPage(), - ** btreeInitPage() did not detect overlapping cells or - ** freeblocks that overlapped cells. Nor does it detect when the - ** cell content area exceeds the value in the page header. If these - ** situations arise, then subsequent insert operations might corrupt - ** the freelist. So we do need to check for corruption while scanning - ** the freelist. - */ - hdr = pPage.hdrOffset; - addr = hdr + 1; - iLast = (int)pPage.pBt.usableSize - 4; - Debug.Assert(start <= iLast); - while ((pbegin = get2byte(data, addr)) < start && pbegin > 0) { - if (pbegin < addr + 4) { - return SQLITE_CORRUPT_BKPT(); - } - addr = pbegin; - } - if (pbegin > iLast) { - return SQLITE_CORRUPT_BKPT(); - } - Debug.Assert(pbegin > addr || pbegin == 0); - put2byte(data, addr, start); - put2byte(data, start, pbegin); - put2byte(data, start + 2, size); - pPage.nFree = (u16)(pPage.nFree + size); - - /* Coalesce adjacent free blocks */ - addr = hdr + 1; - while ((pbegin = get2byte(data, addr)) > 0) { - int pnext, psize, x; - Debug.Assert(pbegin > addr); - Debug.Assert(pbegin <= (int)pPage.pBt.usableSize - 4); - pnext = get2byte(data, pbegin); - psize = get2byte(data, pbegin + 2); - if (pbegin + psize + 3 >= pnext && pnext > 0) { - int frag = pnext - (pbegin + psize); - if ((frag < 0) || (frag > (int)data[hdr + 7])) { - return SQLITE_CORRUPT_BKPT(); - } - data[hdr + 7] -= (u8)frag; - x = get2byte(data, pnext); - put2byte(data, pbegin, x); - x = pnext + get2byte(data, pnext + 2) - pbegin; - put2byte(data, pbegin + 2, x); - } else { - addr = pbegin; - } - } +/* +** Return a section of the pPage.aData to the freelist. +** The first byte of the new free block is pPage.aDisk[start] +** and the size of the block is "size" bytes. +** +** Most of the effort here is involved in coalesing adjacent +** free blocks into a single big free block. +*/ +static int freeSpace( MemPage pPage, u32 start, int size ) +{ + return freeSpace( pPage, (int)start, size ); +} +static int freeSpace( MemPage pPage, int start, int size ) +{ + int addr, pbegin, hdr; + int iLast; /* Largest possible freeblock offset */ + byte[] data = pPage.aData; + + Debug.Assert( pPage.pBt != null ); + Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); + Debug.Assert( start >= pPage.hdrOffset + 6 + pPage.childPtrSize ); + Debug.Assert( ( start + size ) <= (int)pPage.pBt.usableSize ); + Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); + Debug.Assert( size >= 0 ); /* Minimum cell size is 4 */ + + if ( pPage.pBt.secureDelete ) + { + /* Overwrite deleted information with zeros when the secure_delete + ** option is enabled */ + Array.Clear( data, start, size );// memset(&data[start], 0, size); + } + + /* Add the space back into the linked list of freeblocks. Note that + ** even though the freeblock list was checked by btreeInitPage(), + ** btreeInitPage() did not detect overlapping cells or + ** freeblocks that overlapped cells. Nor does it detect when the + ** cell content area exceeds the value in the page header. If these + ** situations arise, then subsequent insert operations might corrupt + ** the freelist. So we do need to check for corruption while scanning + ** the freelist. + */ + hdr = pPage.hdrOffset; + addr = hdr + 1; + iLast = (int)pPage.pBt.usableSize - 4; + Debug.Assert( start <= iLast ); + while ( ( pbegin = get2byte( data, addr ) ) < start && pbegin > 0 ) + { + if ( pbegin < addr + 4 ) + { + return SQLITE_CORRUPT_BKPT(); + } + addr = pbegin; + } + if ( pbegin > iLast ) + { + return SQLITE_CORRUPT_BKPT(); + } + Debug.Assert( pbegin > addr || pbegin == 0 ); + put2byte( data, addr, start ); + put2byte( data, start, pbegin ); + put2byte( data, start + 2, size ); + pPage.nFree = (u16)( pPage.nFree + size ); + + /* Coalesce adjacent free blocks */ + addr = hdr + 1; + while ( ( pbegin = get2byte( data, addr ) ) > 0 ) + { + int pnext, psize, x; + Debug.Assert( pbegin > addr ); + Debug.Assert( pbegin <= (int)pPage.pBt.usableSize - 4 ); + pnext = get2byte( data, pbegin ); + psize = get2byte( data, pbegin + 2 ); + if ( pbegin + psize + 3 >= pnext && pnext > 0 ) + { + int frag = pnext - ( pbegin + psize ); + if ( ( frag < 0 ) || ( frag > (int)data[hdr + 7] ) ) + { + return SQLITE_CORRUPT_BKPT(); + } + data[hdr + 7] -= (u8)frag; + x = get2byte( data, pnext ); + put2byte( data, pbegin, x ); + x = pnext + get2byte( data, pnext + 2 ) - pbegin; + put2byte( data, pbegin + 2, x ); + } + else + { + addr = pbegin; + } + } + + /* If the cell content area begins with a freeblock, remove it. */ + if ( data[hdr + 1] == data[hdr + 5] && data[hdr + 2] == data[hdr + 6] ) + { + int top; + pbegin = get2byte( data, hdr + 1 ); + put2byte( data, hdr + 1, get2byte( data, pbegin ) ); //memcpy( data[hdr + 1], ref data[pbegin], 2 ); + top = get2byte( data, hdr + 5 ) + get2byte( data, pbegin + 2 ); + put2byte( data, hdr + 5, top ); + } + Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); + return SQLITE_OK; +} - /* If the cell content area begins with a freeblock, remove it. */ - if (data[hdr + 1] == data[hdr + 5] && data[hdr + 2] == data[hdr + 6]) { - int top; - pbegin = get2byte(data, hdr + 1); - put2byte(data, hdr + 1, get2byte(data, pbegin)); //memcpy( data[hdr + 1], ref data[pbegin], 2 ); - top = get2byte(data, hdr + 5) + get2byte(data, pbegin + 2); - put2byte(data, hdr + 5, top); - } - Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); - return SQLITE_OK; - } +/* +** Decode the flags byte (the first byte of the header) for a page +** and initialize fields of the MemPage structure accordingly. +** +** Only the following combinations are supported. Anything different +** indicates a corrupt database files: +** +** PTF_ZERODATA +** PTF_ZERODATA | PTF_LEAF +** PTF_LEAFDATA | PTF_INTKEY +** PTF_LEAFDATA | PTF_INTKEY | PTF_LEAF +*/ +static int decodeFlags( MemPage pPage, int flagByte ) +{ + BtShared pBt; /* A copy of pPage.pBt */ + + Debug.Assert( pPage.hdrOffset == ( pPage.pgno == 1 ? 100 : 0 ) ); + Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); + pPage.leaf = (u8)( flagByte >> 3 ); + Debug.Assert( PTF_LEAF == 1 << 3 ); + flagByte &= ~PTF_LEAF; + pPage.childPtrSize = (u8)( 4 - 4 * pPage.leaf ); + pBt = pPage.pBt; + if ( flagByte == ( PTF_LEAFDATA | PTF_INTKEY ) ) + { + pPage.intKey = 1; + pPage.hasData = pPage.leaf; + pPage.maxLocal = pBt.maxLeaf; + pPage.minLocal = pBt.minLeaf; + } + else if ( flagByte == PTF_ZERODATA ) + { + pPage.intKey = 0; + pPage.hasData = 0; + pPage.maxLocal = pBt.maxLocal; + pPage.minLocal = pBt.minLocal; + } + else + { + return SQLITE_CORRUPT_BKPT(); + } + return SQLITE_OK; +} - /* - ** Decode the flags byte (the first byte of the header) for a page - ** and initialize fields of the MemPage structure accordingly. - ** - ** Only the following combinations are supported. Anything different - ** indicates a corrupt database files: - ** - ** PTF_ZERODATA - ** PTF_ZERODATA | PTF_LEAF - ** PTF_LEAFDATA | PTF_INTKEY - ** PTF_LEAFDATA | PTF_INTKEY | PTF_LEAF - */ - static int decodeFlags(MemPage pPage, int flagByte) { - BtShared pBt; /* A copy of pPage.pBt */ - - Debug.Assert(pPage.hdrOffset == (pPage.pgno == 1 ? 100 : 0)); - Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); - pPage.leaf = (u8)(flagByte >> 3); - Debug.Assert(PTF_LEAF == 1 << 3); - flagByte &= ~PTF_LEAF; - pPage.childPtrSize = (u8)(4 - 4 * pPage.leaf); - pBt = pPage.pBt; - if (flagByte == (PTF_LEAFDATA | PTF_INTKEY)) { - pPage.intKey = 1; - pPage.hasData = pPage.leaf; - pPage.maxLocal = pBt.maxLeaf; - pPage.minLocal = pBt.minLeaf; - } else if (flagByte == PTF_ZERODATA) { - pPage.intKey = 0; - pPage.hasData = 0; - pPage.maxLocal = pBt.maxLocal; - pPage.minLocal = pBt.minLocal; - } else { - return SQLITE_CORRUPT_BKPT(); - } - return SQLITE_OK; - } +/* +** Initialize the auxiliary information for a disk block. +** +** Return SQLITE_OK on success. If we see that the page does +** not contain a well-formed database page, then return +** SQLITE_CORRUPT. Note that a return of SQLITE_OK does not +** guarantee that the page is well-formed. It only shows that +** we failed to detect any corruption. +*/ +static int btreeInitPage( MemPage pPage ) +{ - /* - ** Initialize the auxiliary information for a disk block. - ** - ** Return SQLITE_OK on success. If we see that the page does - ** not contain a well-formed database page, then return - ** SQLITE_CORRUPT. Note that a return of SQLITE_OK does not - ** guarantee that the page is well-formed. It only shows that - ** we failed to detect any corruption. - */ - static int btreeInitPage(MemPage pPage) { - - Debug.Assert(pPage.pBt != null); - Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); - Debug.Assert(pPage.pgno == sqlite3PagerPagenumber(pPage.pDbPage)); - Debug.Assert(pPage == sqlite3PagerGetExtra(pPage.pDbPage)); - Debug.Assert(pPage.aData == sqlite3PagerGetData(pPage.pDbPage)); - - if (0 == pPage.isInit) { - u16 pc; /* Address of a freeblock within pPage.aData[] */ - u8 hdr; /* Offset to beginning of page header */ - u8[] data; /* Equal to pPage.aData */ - BtShared pBt; /* The main btree structure */ - int usableSize; /* Amount of usable space on each page */ - u16 cellOffset; /* Offset from start of page to first cell pointer */ - int nFree; /* Number of unused bytes on the page */ - int top; /* First byte of the cell content area */ - int iCellFirst; /* First allowable cell or freeblock offset */ - int iCellLast; /* Last possible cell or freeblock offset */ - - pBt = pPage.pBt; - - hdr = pPage.hdrOffset; - data = pPage.aData; - if (decodeFlags(pPage, data[hdr]) != 0) - return SQLITE_CORRUPT_BKPT(); - Debug.Assert(pBt.pageSize >= 512 && pBt.pageSize <= 65536); - pPage.maskPage = (u16)(pBt.pageSize - 1); - pPage.nOverflow = 0; - usableSize = (int)pBt.usableSize; - pPage.cellOffset = (cellOffset = (u16)(hdr + 12 - 4 * pPage.leaf)); - top = get2byteNotZero(data, hdr + 5); - pPage.nCell = (u16)(get2byte(data, hdr + 3)); - if (pPage.nCell > MX_CELL(pBt)) { - /* To many cells for a single page. The page must be corrupt */ - return SQLITE_CORRUPT_BKPT(); - } - testcase(pPage.nCell == MX_CELL(pBt)); - - /* A malformed database page might cause us to read past the end - ** of page when parsing a cell. - ** - ** The following block of code checks early to see if a cell extends - ** past the end of a page boundary and causes SQLITE_CORRUPT to be - ** returned if it does. - */ - iCellFirst = cellOffset + 2 * pPage.nCell; - iCellLast = usableSize - 4; + Debug.Assert( pPage.pBt != null ); + Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); + Debug.Assert( pPage.pgno == sqlite3PagerPagenumber( pPage.pDbPage ) ); + Debug.Assert( pPage == sqlite3PagerGetExtra( pPage.pDbPage ) ); + Debug.Assert( pPage.aData == sqlite3PagerGetData( pPage.pDbPage ) ); + + if ( 0 == pPage.isInit ) + { + u16 pc; /* Address of a freeblock within pPage.aData[] */ + u8 hdr; /* Offset to beginning of page header */ + u8[] data; /* Equal to pPage.aData */ + BtShared pBt; /* The main btree structure */ + int usableSize; /* Amount of usable space on each page */ + u16 cellOffset; /* Offset from start of page to first cell pointer */ + int nFree; /* Number of unused bytes on the page */ + int top; /* First byte of the cell content area */ + int iCellFirst; /* First allowable cell or freeblock offset */ + int iCellLast; /* Last possible cell or freeblock offset */ + + pBt = pPage.pBt; + + hdr = pPage.hdrOffset; + data = pPage.aData; + if ( decodeFlags( pPage, data[hdr] ) != 0 ) + return SQLITE_CORRUPT_BKPT(); + Debug.Assert( pBt.pageSize >= 512 && pBt.pageSize <= 65536 ); + pPage.maskPage = (u16)( pBt.pageSize - 1 ); + pPage.nOverflow = 0; + usableSize = (int)pBt.usableSize; + pPage.cellOffset = ( cellOffset = (u16)( hdr + 12 - 4 * pPage.leaf ) ); + top = get2byteNotZero( data, hdr + 5 ); + pPage.nCell = (u16)( get2byte( data, hdr + 3 ) ); + if ( pPage.nCell > MX_CELL( pBt ) ) + { + /* To many cells for a single page. The page must be corrupt */ + return SQLITE_CORRUPT_BKPT(); + } + testcase( pPage.nCell == MX_CELL( pBt ) ); + + /* A malformed database page might cause us to read past the end + ** of page when parsing a cell. + ** + ** The following block of code checks early to see if a cell extends + ** past the end of a page boundary and causes SQLITE_CORRUPT to be + ** returned if it does. + */ + iCellFirst = cellOffset + 2 * pPage.nCell; + iCellLast = usableSize - 4; #if (SQLITE_ENABLE_OVERSIZE_CELL_CHECK) - { - int i; /* Index into the cell pointer array */ - int sz; /* Size of a cell */ - - if (0 == pPage.leaf) - iCellLast--; - for (i = 0; i < pPage.nCell; i++) { - pc = (u16)get2byte(data, cellOffset + i * 2); - testcase(pc == iCellFirst); - testcase(pc == iCellLast); - if (pc < iCellFirst || pc > iCellLast) { - return SQLITE_CORRUPT_BKPT(); - } - sz = cellSizePtr(pPage, data, pc); - testcase(pc + sz == usableSize); - if (pc + sz > usableSize) { - return SQLITE_CORRUPT_BKPT(); - } - } - if (0 == pPage.leaf) - iCellLast++; - } + { + int i; /* Index into the cell pointer array */ + int sz; /* Size of a cell */ + + if ( 0 == pPage.leaf ) + iCellLast--; + for ( i = 0; i < pPage.nCell; i++ ) + { + pc = (u16)get2byte( data, cellOffset + i * 2 ); + testcase( pc == iCellFirst ); + testcase( pc == iCellLast ); + if ( pc < iCellFirst || pc > iCellLast ) + { + return SQLITE_CORRUPT_BKPT(); + } + sz = cellSizePtr( pPage, data, pc ); + testcase( pc + sz == usableSize ); + if ( pc + sz > usableSize ) + { + return SQLITE_CORRUPT_BKPT(); + } + } + if ( 0 == pPage.leaf ) + iCellLast++; + } #endif - /* Compute the total free space on the page */ - pc = (u16)get2byte(data, hdr + 1); - nFree = (u16)(data[hdr + 7] + top); - while (pc > 0) { - u16 next, size; - if (pc < iCellFirst || pc > iCellLast) { - /* Start of free block is off the page */ - return SQLITE_CORRUPT_BKPT(); - } - next = (u16)get2byte(data, pc); - size = (u16)get2byte(data, pc + 2); - if ((next > 0 && next <= pc + size + 3) || pc + size > usableSize) { - /* Free blocks must be in ascending order. And the last byte of - ** the free-block must lie on the database page. */ - return SQLITE_CORRUPT_BKPT(); - } - nFree = (u16)(nFree + size); - pc = next; - } - - /* At this point, nFree contains the sum of the offset to the start - ** of the cell-content area plus the number of free bytes within - ** the cell-content area. If this is greater than the usable-size - ** of the page, then the page must be corrupted. This check also - ** serves to verify that the offset to the start of the cell-content - ** area, according to the page header, lies within the page. - */ - if (nFree > usableSize) { - return SQLITE_CORRUPT_BKPT(); - } - pPage.nFree = (u16)(nFree - iCellFirst); - pPage.isInit = 1; - } - return SQLITE_OK; - } + /* Compute the total free space on the page */ + pc = (u16)get2byte( data, hdr + 1 ); + nFree = (u16)( data[hdr + 7] + top ); + while ( pc > 0 ) + { + u16 next, size; + if ( pc < iCellFirst || pc > iCellLast ) + { + /* Start of free block is off the page */ + return SQLITE_CORRUPT_BKPT(); + } + next = (u16)get2byte( data, pc ); + size = (u16)get2byte( data, pc + 2 ); + if ( ( next > 0 && next <= pc + size + 3 ) || pc + size > usableSize ) + { + /* Free blocks must be in ascending order. And the last byte of + ** the free-block must lie on the database page. */ + return SQLITE_CORRUPT_BKPT(); + } + nFree = (u16)( nFree + size ); + pc = next; + } - /* - ** Set up a raw page so that it looks like a database page holding - ** no entries. - */ - static void zeroPage(MemPage pPage, int flags) { - byte[] data = pPage.aData; - BtShared pBt = pPage.pBt; - u8 hdr = pPage.hdrOffset; - u16 first; - - Debug.Assert(sqlite3PagerPagenumber(pPage.pDbPage) == pPage.pgno); - Debug.Assert(sqlite3PagerGetExtra(pPage.pDbPage) == pPage); - Debug.Assert(sqlite3PagerGetData(pPage.pDbPage) == data); - Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); - Debug.Assert(sqlite3_mutex_held(pBt.mutex)); - if (pBt.secureDelete) { - Array.Clear(data, hdr, (int)(pBt.usableSize - hdr));//memset(&data[hdr], 0, pBt->usableSize - hdr); - } + /* At this point, nFree contains the sum of the offset to the start + ** of the cell-content area plus the number of free bytes within + ** the cell-content area. If this is greater than the usable-size + ** of the page, then the page must be corrupted. This check also + ** serves to verify that the offset to the start of the cell-content + ** area, according to the page header, lies within the page. + */ + if ( nFree > usableSize ) + { + return SQLITE_CORRUPT_BKPT(); + } + pPage.nFree = (u16)( nFree - iCellFirst ); + pPage.isInit = 1; + } + return SQLITE_OK; +} - data[hdr] = (u8)flags; - first = (u16)(hdr + 8 + 4 * ((flags & PTF_LEAF) == 0 ? 1 : 0)); - Array.Clear(data, hdr + 1, 4);//memset(data[hdr+1], 0, 4); - data[hdr + 7] = 0; - put2byte(data, hdr + 5, pBt.usableSize); - pPage.nFree = (u16)(pBt.usableSize - first); - decodeFlags(pPage, flags); - pPage.hdrOffset = hdr; - pPage.cellOffset = first; - pPage.nOverflow = 0; - Debug.Assert(pBt.pageSize >= 512 && pBt.pageSize <= 65536); - pPage.maskPage = (u16)(pBt.pageSize - 1); - pPage.nCell = 0; - pPage.isInit = 1; - } +/* +** Set up a raw page so that it looks like a database page holding +** no entries. +*/ +static void zeroPage( MemPage pPage, int flags ) +{ + byte[] data = pPage.aData; + BtShared pBt = pPage.pBt; + u8 hdr = pPage.hdrOffset; + u16 first; + + Debug.Assert( sqlite3PagerPagenumber( pPage.pDbPage ) == pPage.pgno ); + Debug.Assert( sqlite3PagerGetExtra( pPage.pDbPage ) == pPage ); + Debug.Assert( sqlite3PagerGetData( pPage.pDbPage ) == data ); + Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); + Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); + if ( pBt.secureDelete ) + { + Array.Clear( data, hdr, (int)( pBt.usableSize - hdr ) );//memset(&data[hdr], 0, pBt->usableSize - hdr); + } + + data[hdr] = (u8)flags; + first = (u16)( hdr + 8 + 4 * ( ( flags & PTF_LEAF ) == 0 ? 1 : 0 ) ); + Array.Clear( data, hdr + 1, 4 );//memset(data[hdr+1], 0, 4); + data[hdr + 7] = 0; + put2byte( data, hdr + 5, pBt.usableSize ); + pPage.nFree = (u16)( pBt.usableSize - first ); + decodeFlags( pPage, flags ); + pPage.hdrOffset = hdr; + pPage.cellOffset = first; + pPage.nOverflow = 0; + Debug.Assert( pBt.pageSize >= 512 && pBt.pageSize <= 65536 ); + pPage.maskPage = (u16)( pBt.pageSize - 1 ); + pPage.nCell = 0; + pPage.isInit = 1; +} - /* - ** Convert a DbPage obtained from the pager into a MemPage used by - ** the btree layer. - */ - static MemPage btreePageFromDbPage(DbPage pDbPage, Pgno pgno, BtShared pBt) { - MemPage pPage = (MemPage)sqlite3PagerGetExtra(pDbPage); - pPage.aData = sqlite3PagerGetData(pDbPage); - pPage.pDbPage = pDbPage; - pPage.pBt = pBt; - pPage.pgno = pgno; - pPage.hdrOffset = (u8)(pPage.pgno == 1 ? 100 : 0); - return pPage; - } +/* +** Convert a DbPage obtained from the pager into a MemPage used by +** the btree layer. +*/ +static MemPage btreePageFromDbPage( DbPage pDbPage, Pgno pgno, BtShared pBt ) +{ + MemPage pPage = (MemPage)sqlite3PagerGetExtra( pDbPage ); + pPage.aData = sqlite3PagerGetData( pDbPage ); + pPage.pDbPage = pDbPage; + pPage.pBt = pBt; + pPage.pgno = pgno; + pPage.hdrOffset = (u8)( pPage.pgno == 1 ? 100 : 0 ); + return pPage; +} - /* - ** Get a page from the pager. Initialize the MemPage.pBt and - ** MemPage.aData elements if needed. - ** - ** If the noContent flag is set, it means that we do not care about - ** the content of the page at this time. So do not go to the disk - ** to fetch the content. Just fill in the content with zeros for now. - ** If in the future we call sqlite3PagerWrite() on this page, that - ** means we have started to be concerned about content and the disk - ** read should occur at that point. - */ - static int btreeGetPage( - BtShared pBt, /* The btree */ - Pgno pgno, /* Number of the page to fetch */ - ref MemPage ppPage, /* Return the page in this parameter */ - int noContent /* Do not load page content if true */ - ) { - int rc; - DbPage pDbPage = null; - - Debug.Assert(sqlite3_mutex_held(pBt.mutex)); - rc = sqlite3PagerAcquire(pBt.pPager, pgno, ref pDbPage, (u8)noContent); - if (rc != 0) - return rc; - ppPage = btreePageFromDbPage(pDbPage, pgno, pBt); - return SQLITE_OK; - } +/* +** Get a page from the pager. Initialize the MemPage.pBt and +** MemPage.aData elements if needed. +** +** If the noContent flag is set, it means that we do not care about +** the content of the page at this time. So do not go to the disk +** to fetch the content. Just fill in the content with zeros for now. +** If in the future we call sqlite3PagerWrite() on this page, that +** means we have started to be concerned about content and the disk +** read should occur at that point. +*/ +static int btreeGetPage( +BtShared pBt, /* The btree */ +Pgno pgno, /* Number of the page to fetch */ +ref MemPage ppPage, /* Return the page in this parameter */ +int noContent /* Do not load page content if true */ +) +{ + int rc; + DbPage pDbPage = null; + + Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); + rc = sqlite3PagerAcquire( pBt.pPager, pgno, ref pDbPage, (u8)noContent ); + if ( rc != 0 ) + return rc; + ppPage = btreePageFromDbPage( pDbPage, pgno, pBt ); + return SQLITE_OK; +} - /* - ** Retrieve a page from the pager cache. If the requested page is not - ** already in the pager cache return NULL. Initialize the MemPage.pBt and - ** MemPage.aData elements if needed. - */ - static MemPage btreePageLookup(BtShared pBt, Pgno pgno) { - DbPage pDbPage; - Debug.Assert(sqlite3_mutex_held(pBt.mutex)); - pDbPage = sqlite3PagerLookup(pBt.pPager, pgno); - if (pDbPage) { - return btreePageFromDbPage(pDbPage, pgno, pBt); - } - return null; - } +/* +** Retrieve a page from the pager cache. If the requested page is not +** already in the pager cache return NULL. Initialize the MemPage.pBt and +** MemPage.aData elements if needed. +*/ +static MemPage btreePageLookup( BtShared pBt, Pgno pgno ) +{ + DbPage pDbPage; + Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); + pDbPage = sqlite3PagerLookup( pBt.pPager, pgno ); + if ( pDbPage ) + { + return btreePageFromDbPage( pDbPage, pgno, pBt ); + } + return null; +} - /* - ** Return the size of the database file in pages. If there is any kind of - ** error, return ((unsigned int)-1). - */ - static Pgno btreePagecount(BtShared pBt) { - return pBt.nPage; - } - static Pgno sqlite3BtreeLastPage(Btree p) { - Debug.Assert(sqlite3BtreeHoldsMutex(p)); - Debug.Assert(((p.pBt.nPage) & 0x8000000) == 0); - return (Pgno)btreePagecount(p.pBt); - } +/* +** Return the size of the database file in pages. If there is any kind of +** error, return ((unsigned int)-1). +*/ +static Pgno btreePagecount( BtShared pBt ) +{ + return pBt.nPage; +} +static Pgno sqlite3BtreeLastPage( Btree p ) +{ + Debug.Assert( sqlite3BtreeHoldsMutex( p ) ); + Debug.Assert( ( ( p.pBt.nPage ) & 0x8000000 ) == 0 ); + return (Pgno)btreePagecount( p.pBt ); +} - /* - ** Get a page from the pager and initialize it. This routine is just a - ** convenience wrapper around separate calls to btreeGetPage() and - ** btreeInitPage(). - ** - ** If an error occurs, then the value ppPage is set to is undefined. It - ** may remain unchanged, or it may be set to an invalid value. - */ - static int getAndInitPage( - BtShared pBt, /* The database file */ - Pgno pgno, /* Number of the page to get */ - ref MemPage ppPage /* Write the page pointer here */ - ) { - int rc; - Debug.Assert(sqlite3_mutex_held(pBt.mutex)); - - if (pgno > btreePagecount(pBt)) { - rc = SQLITE_CORRUPT_BKPT(); - } else { - rc = btreeGetPage(pBt, pgno, ref ppPage, 0); - if (rc == SQLITE_OK) { - rc = btreeInitPage(ppPage); - if (rc != SQLITE_OK) { - releasePage(ppPage); - } - } - } +/* +** Get a page from the pager and initialize it. This routine is just a +** convenience wrapper around separate calls to btreeGetPage() and +** btreeInitPage(). +** +** If an error occurs, then the value ppPage is set to is undefined. It +** may remain unchanged, or it may be set to an invalid value. +*/ +static int getAndInitPage( +BtShared pBt, /* The database file */ +Pgno pgno, /* Number of the page to get */ +ref MemPage ppPage /* Write the page pointer here */ +) +{ + int rc; + Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); + + if ( pgno > btreePagecount( pBt ) ) + { + rc = SQLITE_CORRUPT_BKPT(); + } + else + { + rc = btreeGetPage( pBt, pgno, ref ppPage, 0 ); + if ( rc == SQLITE_OK ) + { + rc = btreeInitPage( ppPage ); + if ( rc != SQLITE_OK ) + { + releasePage( ppPage ); + } + } + } - testcase(pgno == 0); - Debug.Assert(pgno != 0 || rc == SQLITE_CORRUPT); + testcase( pgno == 0 ); + Debug.Assert( pgno != 0 || rc == SQLITE_CORRUPT ); - return rc; - } + return rc; +} - /* - ** Release a MemPage. This should be called once for each prior - ** call to btreeGetPage. - */ - static void releasePage(MemPage pPage) { - if (pPage != null) { - Debug.Assert(pPage.aData != null); - Debug.Assert(pPage.pBt != null); - //TODO -- find out why corrupt9 & diskfull fail on this tests - //Debug.Assert( sqlite3PagerGetExtra( pPage.pDbPage ) == pPage ); - //Debug.Assert( sqlite3PagerGetData( pPage.pDbPage ) == pPage.aData ); - Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); - sqlite3PagerUnref(pPage.pDbPage); - } - } +/* +** Release a MemPage. This should be called once for each prior +** call to btreeGetPage. +*/ +static void releasePage( MemPage pPage ) +{ + if ( pPage != null ) + { + Debug.Assert( pPage.aData != null ); + Debug.Assert( pPage.pBt != null ); + //TODO -- find out why corrupt9 & diskfull fail on this tests + //Debug.Assert( sqlite3PagerGetExtra( pPage.pDbPage ) == pPage ); + //Debug.Assert( sqlite3PagerGetData( pPage.pDbPage ) == pPage.aData ); + Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); + sqlite3PagerUnref( pPage.pDbPage ); + } +} - /* - ** During a rollback, when the pager reloads information into the cache - ** so that the cache is restored to its original state at the start of - ** the transaction, for each page restored this routine is called. - ** - ** This routine needs to reset the extra data section at the end of the - ** page to agree with the restored data. - */ - static void pageReinit(DbPage pData) { - MemPage pPage; - pPage = sqlite3PagerGetExtra(pData); - Debug.Assert(sqlite3PagerPageRefcount(pData) > 0); - if (pPage.isInit != 0) { - Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); - pPage.isInit = 0; - if (sqlite3PagerPageRefcount(pData) > 1) { - /* pPage might not be a btree page; it might be an overflow page - ** or ptrmap page or a free page. In those cases, the following - ** call to btreeInitPage() will likely return SQLITE_CORRUPT. - ** But no harm is done by this. And it is very important that - ** btreeInitPage() be called on every btree page so we make - ** the call for every page that comes in for re-initing. */ - btreeInitPage(pPage); - } - } - } +/* +** During a rollback, when the pager reloads information into the cache +** so that the cache is restored to its original state at the start of +** the transaction, for each page restored this routine is called. +** +** This routine needs to reset the extra data section at the end of the +** page to agree with the restored data. +*/ +static void pageReinit( DbPage pData ) +{ + MemPage pPage; + pPage = sqlite3PagerGetExtra( pData ); + Debug.Assert( sqlite3PagerPageRefcount( pData ) > 0 ); + if ( pPage.isInit != 0 ) + { + Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); + pPage.isInit = 0; + if ( sqlite3PagerPageRefcount( pData ) > 1 ) + { + /* pPage might not be a btree page; it might be an overflow page + ** or ptrmap page or a free page. In those cases, the following + ** call to btreeInitPage() will likely return SQLITE_CORRUPT. + ** But no harm is done by this. And it is very important that + ** btreeInitPage() be called on every btree page so we make + ** the call for every page that comes in for re-initing. */ + btreeInitPage( pPage ); + } + } +} - /* - ** Invoke the busy handler for a btree. - */ - static int btreeInvokeBusyHandler(object pArg) { - BtShared pBt = (BtShared)pArg; - Debug.Assert(pBt.db != null); - Debug.Assert(sqlite3_mutex_held(pBt.db.mutex)); - return sqlite3InvokeBusyHandler(pBt.db.busyHandler); - } +/* +** Invoke the busy handler for a btree. +*/ +static int btreeInvokeBusyHandler( object pArg ) +{ + BtShared pBt = (BtShared)pArg; + Debug.Assert( pBt.db != null ); + Debug.Assert( sqlite3_mutex_held( pBt.db.mutex ) ); + return sqlite3InvokeBusyHandler( pBt.db.busyHandler ); +} - /* - ** Open a database file. - ** - ** zFilename is the name of the database file. If zFilename is NULL - ** then an ephemeral database is created. The ephemeral database might - ** be exclusively in memory, or it might use a disk-based memory cache. - ** Either way, the ephemeral database will be automatically deleted - ** when sqlite3BtreeClose() is called. - ** - ** If zFilename is ":memory:" then an in-memory database is created - ** that is automatically destroyed when it is closed. - ** - ** The "flags" parameter is a bitmask that might contain bits - ** BTREE_OMIT_JOURNAL and/or BTREE_NO_READLOCK. The BTREE_NO_READLOCK - ** bit is also set if the SQLITE_NoReadlock flags is set in db->flags. - ** These flags are passed through into sqlite3PagerOpen() and must - ** be the same values as PAGER_OMIT_JOURNAL and PAGER_NO_READLOCK. - ** - ** If the database is already opened in the same database connection - ** and we are in shared cache mode, then the open will fail with an - ** SQLITE_CONSTRAINT error. We cannot allow two or more BtShared - ** objects in the same database connection since doing so will lead - ** to problems with locking. - */ - static int sqlite3BtreeOpen( - sqlite3_vfs pVfs, /* VFS to use for this b-tree */ - string zFilename, /* Name of the file containing the BTree database */ - sqlite3 db, /* Associated database handle */ - ref Btree ppBtree, /* Pointer to new Btree object written here */ - int flags, /* Options */ - int vfsFlags /* Flags passed through to sqlite3_vfs.xOpen() */ - ) { - BtShared pBt = null; /* Shared part of btree structure */ - Btree p; /* Handle to return */ - sqlite3_mutex mutexOpen = null; /* Prevents a race condition. Ticket #3537 */ - int rc = SQLITE_OK; /* Result code from this function */ - u8 nReserve; /* Byte of unused space on each page */ - byte[] zDbHeader = new byte[100]; /* Database header content */ - - /* True if opening an ephemeral, temporary database */ - bool isTempDb = String.IsNullOrEmpty(zFilename);//zFilename==0 || zFilename[0]==0; - - /* Set the variable isMemdb to true for an in-memory database, or - ** false for a file-based database. - */ +/* +** Open a database file. +** +** zFilename is the name of the database file. If zFilename is NULL +** then an ephemeral database is created. The ephemeral database might +** be exclusively in memory, or it might use a disk-based memory cache. +** Either way, the ephemeral database will be automatically deleted +** when sqlite3BtreeClose() is called. +** +** If zFilename is ":memory:" then an in-memory database is created +** that is automatically destroyed when it is closed. +** +** The "flags" parameter is a bitmask that might contain bits +** BTREE_OMIT_JOURNAL and/or BTREE_NO_READLOCK. The BTREE_NO_READLOCK +** bit is also set if the SQLITE_NoReadlock flags is set in db->flags. +** These flags are passed through into sqlite3PagerOpen() and must +** be the same values as PAGER_OMIT_JOURNAL and PAGER_NO_READLOCK. +** +** If the database is already opened in the same database connection +** and we are in shared cache mode, then the open will fail with an +** SQLITE_CONSTRAINT error. We cannot allow two or more BtShared +** objects in the same database connection since doing so will lead +** to problems with locking. +*/ +static int sqlite3BtreeOpen( +sqlite3_vfs pVfs, /* VFS to use for this b-tree */ +string zFilename, /* Name of the file containing the BTree database */ +sqlite3 db, /* Associated database handle */ +ref Btree ppBtree, /* Pointer to new Btree object written here */ +int flags, /* Options */ +int vfsFlags /* Flags passed through to sqlite3_vfs.xOpen() */ +) +{ + BtShared pBt = null; /* Shared part of btree structure */ + Btree p; /* Handle to return */ + sqlite3_mutex mutexOpen = null; /* Prevents a race condition. Ticket #3537 */ + int rc = SQLITE_OK; /* Result code from this function */ + u8 nReserve; /* Byte of unused space on each page */ + byte[] zDbHeader = new byte[100]; /* Database header content */ + + /* True if opening an ephemeral, temporary database */ + bool isTempDb = String.IsNullOrEmpty( zFilename );//zFilename==0 || zFilename[0]==0; + + /* Set the variable isMemdb to true for an in-memory database, or + ** false for a file-based database. + */ #if SQLITE_OMIT_MEMORYDB bool isMemdb = false; #else - bool isMemdb = (zFilename == ":memory:") - || (isTempDb && sqlite3TempInMemory(db)); + bool isMemdb = ( zFilename == ":memory:" ) + || ( isTempDb && sqlite3TempInMemory( db ) ); #endif - Debug.Assert(db != null); - Debug.Assert(pVfs != null); - Debug.Assert(sqlite3_mutex_held(db.mutex)); - Debug.Assert((flags & 0xff) == flags); /* flags fit in 8 bits */ - - /* Only a BTREE_SINGLE database can be BTREE_UNORDERED */ - Debug.Assert((flags & BTREE_UNORDERED) == 0 || (flags & BTREE_SINGLE) != 0); - - /* A BTREE_SINGLE database is always a temporary and/or ephemeral */ - Debug.Assert((flags & BTREE_SINGLE) == 0 || isTempDb); - - if ((db.flags & SQLITE_NoReadlock) != 0) { - flags |= BTREE_NO_READLOCK; - } - if (isMemdb) { - flags |= BTREE_MEMORY; - } - if ((vfsFlags & SQLITE_OPEN_MAIN_DB) != 0 && (isMemdb || isTempDb)) { - vfsFlags = (vfsFlags & ~SQLITE_OPEN_MAIN_DB) | SQLITE_OPEN_TEMP_DB; - } - - p = new Btree();//sqlite3MallocZero(sizeof(Btree)); - //if( !p ){ - // return SQLITE_NOMEM; - //} - p.inTrans = TRANS_NONE; - p.db = db; + Debug.Assert( db != null ); + Debug.Assert( pVfs != null ); + Debug.Assert( sqlite3_mutex_held( db.mutex ) ); + Debug.Assert( ( flags & 0xff ) == flags ); /* flags fit in 8 bits */ + + /* Only a BTREE_SINGLE database can be BTREE_UNORDERED */ + Debug.Assert( ( flags & BTREE_UNORDERED ) == 0 || ( flags & BTREE_SINGLE ) != 0 ); + + /* A BTREE_SINGLE database is always a temporary and/or ephemeral */ + Debug.Assert( ( flags & BTREE_SINGLE ) == 0 || isTempDb ); + + if ( ( db.flags & SQLITE_NoReadlock ) != 0 ) + { + flags |= BTREE_NO_READLOCK; + } + if ( isMemdb ) + { + flags |= BTREE_MEMORY; + } + if ( ( vfsFlags & SQLITE_OPEN_MAIN_DB ) != 0 && ( isMemdb || isTempDb ) ) + { + vfsFlags = ( vfsFlags & ~SQLITE_OPEN_MAIN_DB ) | SQLITE_OPEN_TEMP_DB; + } + + p = new Btree();//sqlite3MallocZero(sizeof(Btree)); + //if( !p ){ + // return SQLITE_NOMEM; + //} + p.inTrans = TRANS_NONE; + p.db = db; #if !SQLITE_OMIT_SHARED_CACHE p.lock.pBtree = p; p.lock.iTable = 1; @@ -1976,72 +2137,79 @@ static int sqlite3BtreeOpen( #endif } #endif - if (pBt == null) { - /* - ** The following asserts make sure that structures used by the btree are - ** the right size. This is to guard against size changes that result - ** when compiling on a different architecture. - */ - Debug.Assert(sizeof(i64) == 8 || sizeof(i64) == 4); - Debug.Assert(sizeof(u64) == 8 || sizeof(u64) == 4); - Debug.Assert(sizeof(u32) == 4); - Debug.Assert(sizeof(u16) == 2); - Debug.Assert(sizeof(Pgno) == 4); - - pBt = new BtShared();//sqlite3MallocZero( sizeof(pBt) ); - //if( pBt==null ){ - // rc = SQLITE_NOMEM; - // goto btree_open_out; - //} - rc = sqlite3PagerOpen(pVfs, out pBt.pPager, zFilename, - EXTRA_SIZE, flags, vfsFlags, pageReinit); - if (rc == SQLITE_OK) { - rc = sqlite3PagerReadFileheader(pBt.pPager, zDbHeader.Length, zDbHeader); - } - if (rc != SQLITE_OK) { - goto btree_open_out; - } - pBt.openFlags = (u8)flags; - pBt.db = db; - sqlite3PagerSetBusyhandler(pBt.pPager, btreeInvokeBusyHandler, pBt); - p.pBt = pBt; - - pBt.pCursor = null; - pBt.pPage1 = null; - pBt.readOnly = sqlite3PagerIsreadonly(pBt.pPager); + if ( pBt == null ) + { + /* + ** The following asserts make sure that structures used by the btree are + ** the right size. This is to guard against size changes that result + ** when compiling on a different architecture. + */ + Debug.Assert( sizeof( i64 ) == 8 || sizeof( i64 ) == 4 ); + Debug.Assert( sizeof( u64 ) == 8 || sizeof( u64 ) == 4 ); + Debug.Assert( sizeof( u32 ) == 4 ); + Debug.Assert( sizeof( u16 ) == 2 ); + Debug.Assert( sizeof( Pgno ) == 4 ); + + pBt = new BtShared();//sqlite3MallocZero( sizeof(pBt) ); + //if( pBt==null ){ + // rc = SQLITE_NOMEM; + // goto btree_open_out; + //} + rc = sqlite3PagerOpen( pVfs, out pBt.pPager, zFilename, + EXTRA_SIZE, flags, vfsFlags, pageReinit ); + if ( rc == SQLITE_OK ) + { + rc = sqlite3PagerReadFileheader( pBt.pPager, zDbHeader.Length, zDbHeader ); + } + if ( rc != SQLITE_OK ) + { + goto btree_open_out; + } + pBt.openFlags = (u8)flags; + pBt.db = db; + sqlite3PagerSetBusyhandler( pBt.pPager, btreeInvokeBusyHandler, pBt ); + p.pBt = pBt; + + pBt.pCursor = null; + pBt.pPage1 = null; + pBt.readOnly = sqlite3PagerIsreadonly( pBt.pPager ); #if SQLITE_SECURE_DELETE pBt.secureDelete = true; #endif - pBt.pageSize = (u32)((zDbHeader[16] << 8) | (zDbHeader[17] << 16)); - if (pBt.pageSize < 512 || pBt.pageSize > SQLITE_MAX_PAGE_SIZE - || ((pBt.pageSize - 1) & pBt.pageSize) != 0) { - pBt.pageSize = 0; + pBt.pageSize = (u32)( ( zDbHeader[16] << 8 ) | ( zDbHeader[17] << 16 ) ); + if ( pBt.pageSize < 512 || pBt.pageSize > SQLITE_MAX_PAGE_SIZE + || ( ( pBt.pageSize - 1 ) & pBt.pageSize ) != 0 ) + { + pBt.pageSize = 0; #if !SQLITE_OMIT_AUTOVACUUM - /* If the magic name ":memory:" will create an in-memory database, then - ** leave the autoVacuum mode at 0 (do not auto-vacuum), even if - ** SQLITE_DEFAULT_AUTOVACUUM is true. On the other hand, if - ** SQLITE_OMIT_MEMORYDB has been defined, then ":memory:" is just a - ** regular file-name. In this case the auto-vacuum applies as per normal. - */ - if (zFilename != "" && !isMemdb) { - pBt.autoVacuum = (SQLITE_DEFAULT_AUTOVACUUM != 0); - pBt.incrVacuum = (SQLITE_DEFAULT_AUTOVACUUM == 2); - } + /* If the magic name ":memory:" will create an in-memory database, then +** leave the autoVacuum mode at 0 (do not auto-vacuum), even if +** SQLITE_DEFAULT_AUTOVACUUM is true. On the other hand, if +** SQLITE_OMIT_MEMORYDB has been defined, then ":memory:" is just a +** regular file-name. In this case the auto-vacuum applies as per normal. +*/ + if ( zFilename != "" && !isMemdb ) + { + pBt.autoVacuum = ( SQLITE_DEFAULT_AUTOVACUUM != 0 ); + pBt.incrVacuum = ( SQLITE_DEFAULT_AUTOVACUUM == 2 ); + } #endif - nReserve = 0; - } else { - nReserve = zDbHeader[20]; - pBt.pageSizeFixed = true; + nReserve = 0; + } + else + { + nReserve = zDbHeader[20]; + pBt.pageSizeFixed = true; #if !SQLITE_OMIT_AUTOVACUUM - pBt.autoVacuum = sqlite3Get4byte(zDbHeader, 36 + 4 * 4) != 0; - pBt.incrVacuum = sqlite3Get4byte(zDbHeader, 36 + 7 * 4) != 0; + pBt.autoVacuum = sqlite3Get4byte( zDbHeader, 36 + 4 * 4 ) != 0; + pBt.incrVacuum = sqlite3Get4byte( zDbHeader, 36 + 7 * 4 ) != 0; #endif - } - rc = sqlite3PagerSetPagesize(pBt.pPager, ref pBt.pageSize, nReserve); - if (rc != 0) - goto btree_open_out; - pBt.usableSize = (u16)(pBt.pageSize - nReserve); - Debug.Assert((pBt.pageSize & 7) == 0); /* 8-byte alignment of pageSize */ + } + rc = sqlite3PagerSetPagesize( pBt.pPager, ref pBt.pageSize, nReserve ); + if ( rc != 0 ) + goto btree_open_out; + pBt.usableSize = (u16)( pBt.pageSize - nReserve ); + Debug.Assert( ( pBt.pageSize & 7 ) == 0 ); /* 8-byte alignment of pageSize */ #if !(SQLITE_OMIT_SHARED_CACHE) && !(SQLITE_OMIT_DISKIO) /* Add the new BtShared object to the linked list sharable BtShareds. @@ -2064,7 +2232,7 @@ static int sqlite3BtreeOpen( sqlite3_mutex_leave(mutexShared); } #endif - } + } #if !(SQLITE_OMIT_SHARED_CACHE) && !(SQLITE_OMIT_DISKIO) /* If the new Btree uses a sharable pBtShared, then link the new @@ -2097,40 +2265,47 @@ static int sqlite3BtreeOpen( } } #endif - ppBtree = p; - - btree_open_out: - if (rc != SQLITE_OK) { - if (pBt != null && pBt.pPager != null) { - sqlite3PagerClose(pBt.pPager); - } - pBt = null; // sqlite3_free(ref pBt); - p = null; // sqlite3_free(ref p); - ppBtree = null; - } else { - /* If the B-Tree was successfully opened, set the pager-cache size to the - ** default value. Except, when opening on an existing shared pager-cache, - ** do not change the pager-cache size. - */ - if (sqlite3BtreeSchema(p, 0, null) == null) { - sqlite3PagerSetCachesize(p.pBt.pPager, SQLITE_DEFAULT_CACHE_SIZE); - } + ppBtree = p; - } - if (mutexOpen != null) { - Debug.Assert(sqlite3_mutex_held(mutexOpen)); - sqlite3_mutex_leave(mutexOpen); - } - return rc; - } +btree_open_out: + if ( rc != SQLITE_OK ) + { + if ( pBt != null && pBt.pPager != null ) + { + sqlite3PagerClose( pBt.pPager ); + } + pBt = null; // sqlite3_free(ref pBt); + p = null; // sqlite3_free(ref p); + ppBtree = null; + } + else + { + /* If the B-Tree was successfully opened, set the pager-cache size to the + ** default value. Except, when opening on an existing shared pager-cache, + ** do not change the pager-cache size. + */ + if ( sqlite3BtreeSchema( p, 0, null ) == null ) + { + sqlite3PagerSetCachesize( p.pBt.pPager, SQLITE_DEFAULT_CACHE_SIZE ); + } - /* - ** Decrement the BtShared.nRef counter. When it reaches zero, - ** remove the BtShared structure from the sharing list. Return - ** true if the BtShared.nRef counter reaches zero and return - ** false if it is still positive. - */ - static bool removeFromSharingList(BtShared pBt) { + } + if ( mutexOpen != null ) + { + Debug.Assert( sqlite3_mutex_held( mutexOpen ) ); + sqlite3_mutex_leave( mutexOpen ); + } + return rc; +} + +/* +** Decrement the BtShared.nRef counter. When it reaches zero, +** remove the BtShared structure from the sharing list. Return +** true if the BtShared.nRef counter reaches zero and return +** false if it is still positive. +*/ +static bool removeFromSharingList( BtShared pBt ) +{ #if !SQLITE_OMIT_SHARED_CACHE sqlite3_mutex pMaster; BtShared pList; @@ -2160,73 +2335,81 @@ static bool removeFromSharingList(BtShared pBt) { sqlite3_mutex_leave(pMaster); return removed; #else - return true; + return true; #endif - } - - /* - ** Make sure pBt.pTmpSpace points to an allocation of - ** MX_CELL_SIZE(pBt) bytes. - */ - static void allocateTempSpace(BtShared pBt) { - if (null == pBt.pTmpSpace) { - pBt.pTmpSpace = sqlite3Malloc(pBt.pageSize); - } - } +} - /* - ** Free the pBt.pTmpSpace allocation - */ - static void freeTempSpace(BtShared pBt) { - sqlite3PageFree(ref pBt.pTmpSpace); - } +/* +** Make sure pBt.pTmpSpace points to an allocation of +** MX_CELL_SIZE(pBt) bytes. +*/ +static void allocateTempSpace( BtShared pBt ) +{ + if ( null == pBt.pTmpSpace ) + { + pBt.pTmpSpace = sqlite3Malloc( pBt.pageSize ); + } +} - /* - ** Close an open database and invalidate all cursors. - */ - static int sqlite3BtreeClose(ref Btree p) { - BtShared pBt = p.pBt; - BtCursor pCur; - - /* Close all cursors opened via this handle. */ - Debug.Assert(sqlite3_mutex_held(p.db.mutex)); - sqlite3BtreeEnter(p); - pCur = pBt.pCursor; - while (pCur != null) { - BtCursor pTmp = pCur; - pCur = pCur.pNext; - if (pTmp.pBtree == p) { - sqlite3BtreeCloseCursor(pTmp); - } - } +/* +** Free the pBt.pTmpSpace allocation +*/ +static void freeTempSpace( BtShared pBt ) +{ + sqlite3PageFree( ref pBt.pTmpSpace ); +} - /* Rollback any active transaction and free the handle structure. - ** The call to sqlite3BtreeRollback() drops any table-locks held by - ** this handle. - */ - sqlite3BtreeRollback(p); - sqlite3BtreeLeave(p); - - /* If there are still other outstanding references to the shared-btree - ** structure, return now. The remainder of this procedure cleans - ** up the shared-btree. - */ - Debug.Assert(p.wantToLock == 0 && !p.locked); - if (!p.sharable || removeFromSharingList(pBt)) { - /* The pBt is no longer on the sharing list, so we can access - ** it without having to hold the mutex. - ** - ** Clean out and delete the BtShared object. - */ - Debug.Assert(null == pBt.pCursor); - sqlite3PagerClose(pBt.pPager); - if (pBt.xFreeSchema != null && pBt.pSchema != null) { - pBt.xFreeSchema(pBt.pSchema); - } - pBt.pSchema = null;// sqlite3DbFree(0, pBt->pSchema); - //freeTempSpace(pBt); - pBt = null; //sqlite3_free(ref pBt); - } +/* +** Close an open database and invalidate all cursors. +*/ +static int sqlite3BtreeClose( ref Btree p ) +{ + BtShared pBt = p.pBt; + BtCursor pCur; + + /* Close all cursors opened via this handle. */ + Debug.Assert( sqlite3_mutex_held( p.db.mutex ) ); + sqlite3BtreeEnter( p ); + pCur = pBt.pCursor; + while ( pCur != null ) + { + BtCursor pTmp = pCur; + pCur = pCur.pNext; + if ( pTmp.pBtree == p ) + { + sqlite3BtreeCloseCursor( pTmp ); + } + } + + /* Rollback any active transaction and free the handle structure. + ** The call to sqlite3BtreeRollback() drops any table-locks held by + ** this handle. + */ + sqlite3BtreeRollback( p ); + sqlite3BtreeLeave( p ); + + /* If there are still other outstanding references to the shared-btree + ** structure, return now. The remainder of this procedure cleans + ** up the shared-btree. + */ + Debug.Assert( p.wantToLock == 0 && !p.locked ); + if ( !p.sharable || removeFromSharingList( pBt ) ) + { + /* The pBt is no longer on the sharing list, so we can access + ** it without having to hold the mutex. + ** + ** Clean out and delete the BtShared object. + */ + Debug.Assert( null == pBt.pCursor ); + sqlite3PagerClose( pBt.pPager ); + if ( pBt.xFreeSchema != null && pBt.pSchema != null ) + { + pBt.xFreeSchema( pBt.pSchema ); + } + pBt.pSchema = null;// sqlite3DbFree(0, pBt->pSchema); + //freeTempSpace(pBt); + pBt = null; //sqlite3_free(ref pBt); + } #if !SQLITE_OMIT_SHARED_CACHE Debug.Assert( p.wantToLock==null ); @@ -2235,273 +2418,295 @@ static int sqlite3BtreeClose(ref Btree p) { if( p.pNext ) p.pNext.pPrev = p.pPrev; #endif - //sqlite3_free(ref p); - return SQLITE_OK; - } - - /* - ** Change the limit on the number of pages allowed in the cache. - ** - ** The maximum number of cache pages is set to the absolute - ** value of mxPage. If mxPage is negative, the pager will - ** operate asynchronously - it will not stop to do fsync()s - ** to insure data is written to the disk surface before - ** continuing. Transactions still work if synchronous is off, - ** and the database cannot be corrupted if this program - ** crashes. But if the operating system crashes or there is - ** an abrupt power failure when synchronous is off, the database - ** could be left in an inconsistent and unrecoverable state. - ** Synchronous is on by default so database corruption is not - ** normally a worry. - */ - static int sqlite3BtreeSetCacheSize(Btree p, int mxPage) { - BtShared pBt = p.pBt; - Debug.Assert(sqlite3_mutex_held(p.db.mutex)); - sqlite3BtreeEnter(p); - sqlite3PagerSetCachesize(pBt.pPager, mxPage); - sqlite3BtreeLeave(p); - return SQLITE_OK; - } + //sqlite3_free(ref p); + return SQLITE_OK; +} - /* - ** Change the way data is synced to disk in order to increase or decrease - ** how well the database resists damage due to OS crashes and power - ** failures. Level 1 is the same as asynchronous (no syncs() occur and - ** there is a high probability of damage) Level 2 is the default. There - ** is a very low but non-zero probability of damage. Level 3 reduces the - ** probability of damage to near zero but with a write performance reduction. - */ -#if !SQLITE_OMIT_PAGER_PRAGMAS - static int sqlite3BtreeSetSafetyLevel( - Btree p, /* The btree to set the safety level on */ - int level, /* PRAGMA synchronous. 1=OFF, 2=NORMAL, 3=FULL */ - int fullSync, /* PRAGMA fullfsync. */ - int ckptFullSync /* PRAGMA checkpoint_fullfync */ - ) { - BtShared pBt = p.pBt; - Debug.Assert(sqlite3_mutex_held(p.db.mutex)); - Debug.Assert(level >= 1 && level <= 3); - sqlite3BtreeEnter(p); - sqlite3PagerSetSafetyLevel(pBt.pPager, level, fullSync, ckptFullSync); - sqlite3BtreeLeave(p); - return SQLITE_OK; - } +/* +** Change the limit on the number of pages allowed in the cache. +** +** The maximum number of cache pages is set to the absolute +** value of mxPage. If mxPage is negative, the pager will +** operate asynchronously - it will not stop to do fsync()s +** to insure data is written to the disk surface before +** continuing. Transactions still work if synchronous is off, +** and the database cannot be corrupted if this program +** crashes. But if the operating system crashes or there is +** an abrupt power failure when synchronous is off, the database +** could be left in an inconsistent and unrecoverable state. +** Synchronous is on by default so database corruption is not +** normally a worry. +*/ +static int sqlite3BtreeSetCacheSize( Btree p, int mxPage ) +{ + BtShared pBt = p.pBt; + Debug.Assert( sqlite3_mutex_held( p.db.mutex ) ); + sqlite3BtreeEnter( p ); + sqlite3PagerSetCachesize( pBt.pPager, mxPage ); + sqlite3BtreeLeave( p ); + return SQLITE_OK; +} + +/* +** Change the way data is synced to disk in order to increase or decrease +** how well the database resists damage due to OS crashes and power +** failures. Level 1 is the same as asynchronous (no syncs() occur and +** there is a high probability of damage) Level 2 is the default. There +** is a very low but non-zero probability of damage. Level 3 reduces the +** probability of damage to near zero but with a write performance reduction. +*/ +#if !SQLITE_OMIT_PAGER_PRAGMAS +static int sqlite3BtreeSetSafetyLevel( +Btree p, /* The btree to set the safety level on */ +int level, /* PRAGMA synchronous. 1=OFF, 2=NORMAL, 3=FULL */ +int fullSync, /* PRAGMA fullfsync. */ +int ckptFullSync /* PRAGMA checkpoint_fullfync */ +) +{ + BtShared pBt = p.pBt; + Debug.Assert( sqlite3_mutex_held( p.db.mutex ) ); + Debug.Assert( level >= 1 && level <= 3 ); + sqlite3BtreeEnter( p ); + sqlite3PagerSetSafetyLevel( pBt.pPager, level, fullSync, ckptFullSync ); + sqlite3BtreeLeave( p ); + return SQLITE_OK; +} #endif - /* - ** Return TRUE if the given btree is set to safety level 1. In other - ** words, return TRUE if no sync() occurs on the disk files. - */ - static int sqlite3BtreeSyncDisabled(Btree p) { - BtShared pBt = p.pBt; - int rc; - Debug.Assert(sqlite3_mutex_held(p.db.mutex)); - sqlite3BtreeEnter(p); - Debug.Assert(pBt != null && pBt.pPager != null); - rc = sqlite3PagerNosync(pBt.pPager) ? 1 : 0; - sqlite3BtreeLeave(p); - return rc; - } +/* +** Return TRUE if the given btree is set to safety level 1. In other +** words, return TRUE if no sync() occurs on the disk files. +*/ +static int sqlite3BtreeSyncDisabled( Btree p ) +{ + BtShared pBt = p.pBt; + int rc; + Debug.Assert( sqlite3_mutex_held( p.db.mutex ) ); + sqlite3BtreeEnter( p ); + Debug.Assert( pBt != null && pBt.pPager != null ); + rc = sqlite3PagerNosync( pBt.pPager ) ? 1 : 0; + sqlite3BtreeLeave( p ); + return rc; +} - /* - ** Change the default pages size and the number of reserved bytes per page. - ** Or, if the page size has already been fixed, return SQLITE_READONLY - ** without changing anything. - ** - ** The page size must be a power of 2 between 512 and 65536. If the page - ** size supplied does not meet this constraint then the page size is not - ** changed. - ** - ** Page sizes are constrained to be a power of two so that the region - ** of the database file used for locking (beginning at PENDING_BYTE, - ** the first byte past the 1GB boundary, 0x40000000) needs to occur - ** at the beginning of a page. - ** - ** If parameter nReserve is less than zero, then the number of reserved - ** bytes per page is left unchanged. - ** - ** If iFix!=0 then the pageSizeFixed flag is set so that the page size - ** and autovacuum mode can no longer be changed. - */ - static int sqlite3BtreeSetPageSize(Btree p, int pageSize, int nReserve, int iFix) { - int rc = SQLITE_OK; - BtShared pBt = p.pBt; - Debug.Assert(nReserve >= -1 && nReserve <= 255); - sqlite3BtreeEnter(p); - if (pBt.pageSizeFixed) { - sqlite3BtreeLeave(p); - return SQLITE_READONLY; - } - if (nReserve < 0) { - nReserve = (int)(pBt.pageSize - pBt.usableSize); - } - Debug.Assert(nReserve >= 0 && nReserve <= 255); - if (pageSize >= 512 && pageSize <= SQLITE_MAX_PAGE_SIZE && - ((pageSize - 1) & pageSize) == 0) { - Debug.Assert((pageSize & 7) == 0); - Debug.Assert(null == pBt.pPage1 && null == pBt.pCursor); - pBt.pageSize = (u32)pageSize; - // freeTempSpace(pBt); - } - rc = sqlite3PagerSetPagesize(pBt.pPager, ref pBt.pageSize, nReserve); - pBt.usableSize = (u16)(pBt.pageSize - nReserve); - if (iFix != 0) - pBt.pageSizeFixed = true; - sqlite3BtreeLeave(p); - return rc; - } +/* +** Change the default pages size and the number of reserved bytes per page. +** Or, if the page size has already been fixed, return SQLITE_READONLY +** without changing anything. +** +** The page size must be a power of 2 between 512 and 65536. If the page +** size supplied does not meet this constraint then the page size is not +** changed. +** +** Page sizes are constrained to be a power of two so that the region +** of the database file used for locking (beginning at PENDING_BYTE, +** the first byte past the 1GB boundary, 0x40000000) needs to occur +** at the beginning of a page. +** +** If parameter nReserve is less than zero, then the number of reserved +** bytes per page is left unchanged. +** +** If iFix!=0 then the pageSizeFixed flag is set so that the page size +** and autovacuum mode can no longer be changed. +*/ +static int sqlite3BtreeSetPageSize( Btree p, int pageSize, int nReserve, int iFix ) +{ + int rc = SQLITE_OK; + BtShared pBt = p.pBt; + Debug.Assert( nReserve >= -1 && nReserve <= 255 ); + sqlite3BtreeEnter( p ); + if ( pBt.pageSizeFixed ) + { + sqlite3BtreeLeave( p ); + return SQLITE_READONLY; + } + if ( nReserve < 0 ) + { + nReserve = (int)( pBt.pageSize - pBt.usableSize ); + } + Debug.Assert( nReserve >= 0 && nReserve <= 255 ); + if ( pageSize >= 512 && pageSize <= SQLITE_MAX_PAGE_SIZE && + ( ( pageSize - 1 ) & pageSize ) == 0 ) + { + Debug.Assert( ( pageSize & 7 ) == 0 ); + Debug.Assert( null == pBt.pPage1 && null == pBt.pCursor ); + pBt.pageSize = (u32)pageSize; + // freeTempSpace(pBt); + } + rc = sqlite3PagerSetPagesize( pBt.pPager, ref pBt.pageSize, nReserve ); + pBt.usableSize = (u16)( pBt.pageSize - nReserve ); + if ( iFix != 0 ) + pBt.pageSizeFixed = true; + sqlite3BtreeLeave( p ); + return rc; +} - /* - ** Return the currently defined page size - */ - static int sqlite3BtreeGetPageSize(Btree p) { - return (int)p.pBt.pageSize; - } +/* +** Return the currently defined page size +*/ +static int sqlite3BtreeGetPageSize( Btree p ) +{ + return (int)p.pBt.pageSize; +} #if !(SQLITE_OMIT_PAGER_PRAGMAS) || !(SQLITE_OMIT_VACUUM) - /* - ** Return the number of bytes of space at the end of every page that - ** are intentually left unused. This is the "reserved" space that is - ** sometimes used by extensions. - */ - static int sqlite3BtreeGetReserve(Btree p) { - int n; - sqlite3BtreeEnter(p); - n = (int)(p.pBt.pageSize - p.pBt.usableSize); - sqlite3BtreeLeave(p); - return n; - } +/* +** Return the number of bytes of space at the end of every page that +** are intentually left unused. This is the "reserved" space that is +** sometimes used by extensions. +*/ +static int sqlite3BtreeGetReserve( Btree p ) +{ + int n; + sqlite3BtreeEnter( p ); + n = (int)( p.pBt.pageSize - p.pBt.usableSize ); + sqlite3BtreeLeave( p ); + return n; +} - /* - ** Set the maximum page count for a database if mxPage is positive. - ** No changes are made if mxPage is 0 or negative. - ** Regardless of the value of mxPage, return the maximum page count. - */ - static Pgno sqlite3BtreeMaxPageCount(Btree p, int mxPage) { - Pgno n; - sqlite3BtreeEnter(p); - n = sqlite3PagerMaxPageCount(p.pBt.pPager, mxPage); - sqlite3BtreeLeave(p); - return n; - } +/* +** Set the maximum page count for a database if mxPage is positive. +** No changes are made if mxPage is 0 or negative. +** Regardless of the value of mxPage, return the maximum page count. +*/ +static Pgno sqlite3BtreeMaxPageCount( Btree p, int mxPage ) +{ + Pgno n; + sqlite3BtreeEnter( p ); + n = sqlite3PagerMaxPageCount( p.pBt.pPager, mxPage ); + sqlite3BtreeLeave( p ); + return n; +} - /* - ** Set the secureDelete flag if newFlag is 0 or 1. If newFlag is -1, - ** then make no changes. Always return the value of the secureDelete - ** setting after the change. - */ - static int sqlite3BtreeSecureDelete(Btree p, int newFlag) { - int b; - if (p == null) - return 0; - sqlite3BtreeEnter(p); - if (newFlag >= 0) { - p.pBt.secureDelete = (newFlag != 0); - } - b = p.pBt.secureDelete ? 1 : 0; - sqlite3BtreeLeave(p); - return b; - } +/* +** Set the secureDelete flag if newFlag is 0 or 1. If newFlag is -1, +** then make no changes. Always return the value of the secureDelete +** setting after the change. +*/ +static int sqlite3BtreeSecureDelete( Btree p, int newFlag ) +{ + int b; + if ( p == null ) + return 0; + sqlite3BtreeEnter( p ); + if ( newFlag >= 0 ) + { + p.pBt.secureDelete = ( newFlag != 0 ); + } + b = p.pBt.secureDelete ? 1 : 0; + sqlite3BtreeLeave( p ); + return b; +} #endif //* !(SQLITE_OMIT_PAGER_PRAGMAS) || !(SQLITE_OMIT_VACUUM) */ - /* - ** Change the 'auto-vacuum' property of the database. If the 'autoVacuum' - ** parameter is non-zero, then auto-vacuum mode is enabled. If zero, it - ** is disabled. The default value for the auto-vacuum property is - ** determined by the SQLITE_DEFAULT_AUTOVACUUM macro. - */ - static int sqlite3BtreeSetAutoVacuum(Btree p, int autoVacuum) { +/* +** Change the 'auto-vacuum' property of the database. If the 'autoVacuum' +** parameter is non-zero, then auto-vacuum mode is enabled. If zero, it +** is disabled. The default value for the auto-vacuum property is +** determined by the SQLITE_DEFAULT_AUTOVACUUM macro. +*/ +static int sqlite3BtreeSetAutoVacuum( Btree p, int autoVacuum ) +{ #if SQLITE_OMIT_AUTOVACUUM return SQLITE_READONLY; #else - BtShared pBt = p.pBt; - int rc = SQLITE_OK; - u8 av = (u8)autoVacuum; - - sqlite3BtreeEnter(p); - if (pBt.pageSizeFixed && (av != 0) != pBt.autoVacuum) { - rc = SQLITE_READONLY; - } else { - pBt.autoVacuum = av != 0; - pBt.incrVacuum = av == 2; - } - sqlite3BtreeLeave(p); - return rc; + BtShared pBt = p.pBt; + int rc = SQLITE_OK; + u8 av = (u8)autoVacuum; + + sqlite3BtreeEnter( p ); + if ( pBt.pageSizeFixed && ( av != 0 ) != pBt.autoVacuum ) + { + rc = SQLITE_READONLY; + } + else + { + pBt.autoVacuum = av != 0; + pBt.incrVacuum = av == 2; + } + sqlite3BtreeLeave( p ); + return rc; #endif - } +} - /* - ** Return the value of the 'auto-vacuum' property. If auto-vacuum is - ** enabled 1 is returned. Otherwise 0. - */ - static int sqlite3BtreeGetAutoVacuum(Btree p) { +/* +** Return the value of the 'auto-vacuum' property. If auto-vacuum is +** enabled 1 is returned. Otherwise 0. +*/ +static int sqlite3BtreeGetAutoVacuum( Btree p ) +{ #if SQLITE_OMIT_AUTOVACUUM return BTREE_AUTOVACUUM_NONE; #else - int rc; - sqlite3BtreeEnter(p); - rc = ( - (!p.pBt.autoVacuum) ? BTREE_AUTOVACUUM_NONE : - (!p.pBt.incrVacuum) ? BTREE_AUTOVACUUM_FULL : - BTREE_AUTOVACUUM_INCR - ); - sqlite3BtreeLeave(p); - return rc; + int rc; + sqlite3BtreeEnter( p ); + rc = ( + ( !p.pBt.autoVacuum ) ? BTREE_AUTOVACUUM_NONE : + ( !p.pBt.incrVacuum ) ? BTREE_AUTOVACUUM_FULL : + BTREE_AUTOVACUUM_INCR + ); + sqlite3BtreeLeave( p ); + return rc; #endif - } +} - /* - ** Get a reference to pPage1 of the database file. This will - ** also acquire a readlock on that file. - ** - ** SQLITE_OK is returned on success. If the file is not a - ** well-formed database file, then SQLITE_CORRUPT is returned. - ** SQLITE_BUSY is returned if the database is locked. SQLITE_NOMEM - ** is returned if we run out of memory. - */ - static int lockBtree(BtShared pBt) { - int rc; /* Result code from subfunctions */ - MemPage pPage1 = null; /* Page 1 of the database file */ - Pgno nPage; /* Number of pages in the database */ - Pgno nPageFile = 0; /* Number of pages in the database file */ - ////Pgno nPageHeader; /* Number of pages in the database according to hdr */ - - Debug.Assert(sqlite3_mutex_held(pBt.mutex)); - Debug.Assert(pBt.pPage1 == null); - rc = sqlite3PagerSharedLock(pBt.pPager); - if (rc != SQLITE_OK) - return rc; - rc = btreeGetPage(pBt, 1, ref pPage1, 0); - if (rc != SQLITE_OK) - return rc; - - /* Do some checking to help insure the file we opened really is - ** a valid database file. - */ - nPage = sqlite3Get4byte(pPage1.aData, 28);//get4byte(28+(u8*)pPage1->aData); - sqlite3PagerPagecount(pBt.pPager, out nPageFile); - if (nPage == 0 || memcmp(pPage1.aData, 24, pPage1.aData, 92, 4) != 0)//memcmp(24 + (u8*)pPage1.aData, 92 + (u8*)pPage1.aData, 4) != 0) - { - nPage = nPageFile; - } - if (nPage > 0) { - u32 pageSize; - u32 usableSize; - u8[] page1 = pPage1.aData; - rc = SQLITE_NOTADB; - if (memcmp(page1, zMagicHeader, 16) != 0) { - goto page1_init_failed; - } +/* +** Get a reference to pPage1 of the database file. This will +** also acquire a readlock on that file. +** +** SQLITE_OK is returned on success. If the file is not a +** well-formed database file, then SQLITE_CORRUPT is returned. +** SQLITE_BUSY is returned if the database is locked. SQLITE_NOMEM +** is returned if we run out of memory. +*/ +static int lockBtree( BtShared pBt ) +{ + int rc; /* Result code from subfunctions */ + MemPage pPage1 = null; /* Page 1 of the database file */ + Pgno nPage; /* Number of pages in the database */ + Pgno nPageFile = 0; /* Number of pages in the database file */ + ////Pgno nPageHeader; /* Number of pages in the database according to hdr */ + + Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); + Debug.Assert( pBt.pPage1 == null ); + rc = sqlite3PagerSharedLock( pBt.pPager ); + if ( rc != SQLITE_OK ) + return rc; + rc = btreeGetPage( pBt, 1, ref pPage1, 0 ); + if ( rc != SQLITE_OK ) + return rc; + + /* Do some checking to help insure the file we opened really is + ** a valid database file. + */ + nPage = sqlite3Get4byte( pPage1.aData, 28 );//get4byte(28+(u8*)pPage1->aData); + sqlite3PagerPagecount( pBt.pPager, out nPageFile ); + if ( nPage == 0 || memcmp( pPage1.aData, 24, pPage1.aData, 92, 4 ) != 0 )//memcmp(24 + (u8*)pPage1.aData, 92 + (u8*)pPage1.aData, 4) != 0) + { + nPage = nPageFile; + } + if ( nPage > 0 ) + { + u32 pageSize; + u32 usableSize; + u8[] page1 = pPage1.aData; + rc = SQLITE_NOTADB; + if ( memcmp( page1, zMagicHeader, 16 ) != 0 ) + { + goto page1_init_failed; + } #if SQLITE_OMIT_WAL - if (page1[18] > 1) { - pBt.readOnly = true; - } - if (page1[19] > 1) { - pBt.pSchema.file_format = page1[19]; - goto page1_init_failed; - } + if ( page1[18] > 1 ) + { + pBt.readOnly = true; + } + if ( page1[19] > 1 ) + { + pBt.pSchema.file_format = page1[19]; + goto page1_init_failed; + } #else if( page1[18]>2 ){ pBt.readOnly = true; @@ -2531,201 +2736,212 @@ static int lockBtree(BtShared pBt) { } #endif - /* The maximum embedded fraction must be exactly 25%. And the minimum - ** embedded fraction must be 12.5% for both leaf-data and non-leaf-data. - ** The original design allowed these amounts to vary, but as of - ** version 3.6.0, we require them to be fixed. - */ - if (memcmp(page1, 21, "\x0040\x0020\x0020", 3) != 0)// "\100\040\040" - { - goto page1_init_failed; - } - pageSize = (u32)((page1[16] << 8) | (page1[17] << 16)); - if (((pageSize - 1) & pageSize) != 0 - || pageSize > SQLITE_MAX_PAGE_SIZE - || pageSize <= 256 - ) { - goto page1_init_failed; - } - Debug.Assert((pageSize & 7) == 0); - usableSize = pageSize - page1[20]; - if (pageSize != pBt.pageSize) { - /* After reading the first page of the database assuming a page size - ** of BtShared.pageSize, we have discovered that the page-size is - ** actually pageSize. Unlock the database, leave pBt.pPage1 at - ** zero and return SQLITE_OK. The caller will call this function - ** again with the correct page-size. - */ - releasePage(pPage1); - pBt.usableSize = usableSize; - pBt.pageSize = pageSize; - // freeTempSpace(pBt); - rc = sqlite3PagerSetPagesize(pBt.pPager, ref pBt.pageSize, - (int)(pageSize - usableSize)); - return rc; - } - if ((pBt.db.flags & SQLITE_RecoveryMode) == 0 && nPage > nPageFile) { - rc = SQLITE_CORRUPT_BKPT(); - goto page1_init_failed; - } - if (usableSize < 480) { - goto page1_init_failed; - } - pBt.pageSize = pageSize; - pBt.usableSize = usableSize; + /* The maximum embedded fraction must be exactly 25%. And the minimum +** embedded fraction must be 12.5% for both leaf-data and non-leaf-data. +** The original design allowed these amounts to vary, but as of +** version 3.6.0, we require them to be fixed. +*/ + if ( memcmp( page1, 21, "\x0040\x0020\x0020", 3 ) != 0 )// "\100\040\040" + { + goto page1_init_failed; + } + pageSize = (u32)( ( page1[16] << 8 ) | ( page1[17] << 16 ) ); + if ( ( ( pageSize - 1 ) & pageSize ) != 0 + || pageSize > SQLITE_MAX_PAGE_SIZE + || pageSize <= 256 + ) + { + goto page1_init_failed; + } + Debug.Assert( ( pageSize & 7 ) == 0 ); + usableSize = pageSize - page1[20]; + if ( pageSize != pBt.pageSize ) + { + /* After reading the first page of the database assuming a page size + ** of BtShared.pageSize, we have discovered that the page-size is + ** actually pageSize. Unlock the database, leave pBt.pPage1 at + ** zero and return SQLITE_OK. The caller will call this function + ** again with the correct page-size. + */ + releasePage( pPage1 ); + pBt.usableSize = usableSize; + pBt.pageSize = pageSize; + // freeTempSpace(pBt); + rc = sqlite3PagerSetPagesize( pBt.pPager, ref pBt.pageSize, + (int)( pageSize - usableSize ) ); + return rc; + } + if ( ( pBt.db.flags & SQLITE_RecoveryMode ) == 0 && nPage > nPageFile ) + { + rc = SQLITE_CORRUPT_BKPT(); + goto page1_init_failed; + } + if ( usableSize < 480 ) + { + goto page1_init_failed; + } + pBt.pageSize = pageSize; + pBt.usableSize = usableSize; #if !SQLITE_OMIT_AUTOVACUUM - pBt.autoVacuum = (sqlite3Get4byte(page1, 36 + 4 * 4) != 0); - pBt.incrVacuum = (sqlite3Get4byte(page1, 36 + 7 * 4) != 0); + pBt.autoVacuum = ( sqlite3Get4byte( page1, 36 + 4 * 4 ) != 0 ); + pBt.incrVacuum = ( sqlite3Get4byte( page1, 36 + 7 * 4 ) != 0 ); #endif - } - - /* maxLocal is the maximum amount of payload to store locally for - ** a cell. Make sure it is small enough so that at least minFanout - ** cells can will fit on one page. We assume a 10-byte page header. - ** Besides the payload, the cell must store: - ** 2-byte pointer to the cell - ** 4-byte child pointer - ** 9-byte nKey value - ** 4-byte nData value - ** 4-byte overflow page pointer - ** So a cell consists of a 2-byte pointer, a header which is as much as - ** 17 bytes long, 0 to N bytes of payload, and an optional 4 byte overflow - ** page pointer. - */ - pBt.maxLocal = (u16)((pBt.usableSize - 12) * 64 / 255 - 23); - pBt.minLocal = (u16)((pBt.usableSize - 12) * 32 / 255 - 23); - pBt.maxLeaf = (u16)(pBt.usableSize - 35); - pBt.minLeaf = (u16)((pBt.usableSize - 12) * 32 / 255 - 23); - Debug.Assert(pBt.maxLeaf + 23 <= MX_CELL_SIZE(pBt)); - pBt.pPage1 = pPage1; - pBt.nPage = nPage; - return SQLITE_OK; - - page1_init_failed: - releasePage(pPage1); - pBt.pPage1 = null; - return rc; - } + } + + /* maxLocal is the maximum amount of payload to store locally for + ** a cell. Make sure it is small enough so that at least minFanout + ** cells can will fit on one page. We assume a 10-byte page header. + ** Besides the payload, the cell must store: + ** 2-byte pointer to the cell + ** 4-byte child pointer + ** 9-byte nKey value + ** 4-byte nData value + ** 4-byte overflow page pointer + ** So a cell consists of a 2-byte pointer, a header which is as much as + ** 17 bytes long, 0 to N bytes of payload, and an optional 4 byte overflow + ** page pointer. + */ + pBt.maxLocal = (u16)( ( pBt.usableSize - 12 ) * 64 / 255 - 23 ); + pBt.minLocal = (u16)( ( pBt.usableSize - 12 ) * 32 / 255 - 23 ); + pBt.maxLeaf = (u16)( pBt.usableSize - 35 ); + pBt.minLeaf = (u16)( ( pBt.usableSize - 12 ) * 32 / 255 - 23 ); + Debug.Assert( pBt.maxLeaf + 23 <= MX_CELL_SIZE( pBt ) ); + pBt.pPage1 = pPage1; + pBt.nPage = nPage; + return SQLITE_OK; + +page1_init_failed: + releasePage( pPage1 ); + pBt.pPage1 = null; + return rc; +} - /* - ** If there are no outstanding cursors and we are not in the middle - ** of a transaction but there is a read lock on the database, then - ** this routine unrefs the first page of the database file which - ** has the effect of releasing the read lock. - ** - ** If there is a transaction in progress, this routine is a no-op. - */ - static void unlockBtreeIfUnused(BtShared pBt) { - Debug.Assert(sqlite3_mutex_held(pBt.mutex)); - Debug.Assert(pBt.pCursor == null || pBt.inTransaction > TRANS_NONE); - if (pBt.inTransaction == TRANS_NONE && pBt.pPage1 != null) { - Debug.Assert(pBt.pPage1.aData != null); - //Debug.Assert( sqlite3PagerRefcount( pBt.pPager ) == 1 ); - releasePage(pBt.pPage1); - pBt.pPage1 = null; - } - } +/* +** If there are no outstanding cursors and we are not in the middle +** of a transaction but there is a read lock on the database, then +** this routine unrefs the first page of the database file which +** has the effect of releasing the read lock. +** +** If there is a transaction in progress, this routine is a no-op. +*/ +static void unlockBtreeIfUnused( BtShared pBt ) +{ + Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); + Debug.Assert( pBt.pCursor == null || pBt.inTransaction > TRANS_NONE ); + if ( pBt.inTransaction == TRANS_NONE && pBt.pPage1 != null ) + { + Debug.Assert( pBt.pPage1.aData != null ); + //Debug.Assert( sqlite3PagerRefcount( pBt.pPager ) == 1 ); + releasePage( pBt.pPage1 ); + pBt.pPage1 = null; + } +} - /* - ** If pBt points to an empty file then convert that empty file - ** into a new empty database by initializing the first page of - ** the database. - */ - static int newDatabase(BtShared pBt) { - MemPage pP1; - byte[] data; - int rc; - - Debug.Assert(sqlite3_mutex_held(pBt.mutex)); - if (pBt.nPage > 0) { - return SQLITE_OK; - } - pP1 = pBt.pPage1; - Debug.Assert(pP1 != null); - data = pP1.aData; - rc = sqlite3PagerWrite(pP1.pDbPage); - if (rc != 0) - return rc; - Buffer.BlockCopy(zMagicHeader, 0, data, 0, 16);// memcpy(data, zMagicHeader, sizeof(zMagicHeader)); - Debug.Assert(zMagicHeader.Length == 16); - data[16] = (u8)((pBt.pageSize >> 8) & 0xff); - data[17] = (u8)((pBt.pageSize >> 16) & 0xff); - data[18] = 1; - data[19] = 1; - Debug.Assert(pBt.usableSize <= pBt.pageSize && pBt.usableSize + 255 >= pBt.pageSize); - data[20] = (u8)(pBt.pageSize - pBt.usableSize); - data[21] = 64; - data[22] = 32; - data[23] = 32; - //memset(&data[24], 0, 100-24); - zeroPage(pP1, PTF_INTKEY | PTF_LEAF | PTF_LEAFDATA); - pBt.pageSizeFixed = true; +/* +** If pBt points to an empty file then convert that empty file +** into a new empty database by initializing the first page of +** the database. +*/ +static int newDatabase( BtShared pBt ) +{ + MemPage pP1; + byte[] data; + int rc; + + Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); + if ( pBt.nPage > 0 ) + { + return SQLITE_OK; + } + pP1 = pBt.pPage1; + Debug.Assert( pP1 != null ); + data = pP1.aData; + rc = sqlite3PagerWrite( pP1.pDbPage ); + if ( rc != 0 ) + return rc; + Buffer.BlockCopy( zMagicHeader, 0, data, 0, 16 );// memcpy(data, zMagicHeader, sizeof(zMagicHeader)); + Debug.Assert( zMagicHeader.Length == 16 ); + data[16] = (u8)( ( pBt.pageSize >> 8 ) & 0xff ); + data[17] = (u8)( ( pBt.pageSize >> 16 ) & 0xff ); + data[18] = 1; + data[19] = 1; + Debug.Assert( pBt.usableSize <= pBt.pageSize && pBt.usableSize + 255 >= pBt.pageSize ); + data[20] = (u8)( pBt.pageSize - pBt.usableSize ); + data[21] = 64; + data[22] = 32; + data[23] = 32; + //memset(&data[24], 0, 100-24); + zeroPage( pP1, PTF_INTKEY | PTF_LEAF | PTF_LEAFDATA ); + pBt.pageSizeFixed = true; #if !SQLITE_OMIT_AUTOVACUUM - Debug.Assert(pBt.autoVacuum == true || pBt.autoVacuum == false); - Debug.Assert(pBt.incrVacuum == true || pBt.incrVacuum == false); - sqlite3Put4byte(data, 36 + 4 * 4, pBt.autoVacuum ? 1 : 0); - sqlite3Put4byte(data, 36 + 7 * 4, pBt.incrVacuum ? 1 : 0); + Debug.Assert( pBt.autoVacuum == true || pBt.autoVacuum == false ); + Debug.Assert( pBt.incrVacuum == true || pBt.incrVacuum == false ); + sqlite3Put4byte( data, 36 + 4 * 4, pBt.autoVacuum ? 1 : 0 ); + sqlite3Put4byte( data, 36 + 7 * 4, pBt.incrVacuum ? 1 : 0 ); #endif - pBt.nPage = 1; - data[31] = 1; - return SQLITE_OK; - } - - /* - ** Attempt to start a new transaction. A write-transaction - ** is started if the second argument is nonzero, otherwise a read- - ** transaction. If the second argument is 2 or more and exclusive - ** transaction is started, meaning that no other process is allowed - ** to access the database. A preexisting transaction may not be - ** upgraded to exclusive by calling this routine a second time - the - ** exclusivity flag only works for a new transaction. - ** - ** A write-transaction must be started before attempting any - ** changes to the database. None of the following routines - ** will work unless a transaction is started first: - ** - ** sqlite3BtreeCreateTable() - ** sqlite3BtreeCreateIndex() - ** sqlite3BtreeClearTable() - ** sqlite3BtreeDropTable() - ** sqlite3BtreeInsert() - ** sqlite3BtreeDelete() - ** sqlite3BtreeUpdateMeta() - ** - ** If an initial attempt to acquire the lock fails because of lock contention - ** and the database was previously unlocked, then invoke the busy handler - ** if there is one. But if there was previously a read-lock, do not - ** invoke the busy handler - just return SQLITE_BUSY. SQLITE_BUSY is - ** returned when there is already a read-lock in order to avoid a deadlock. - ** - ** Suppose there are two processes A and B. A has a read lock and B has - ** a reserved lock. B tries to promote to exclusive but is blocked because - ** of A's read lock. A tries to promote to reserved but is blocked by B. - ** One or the other of the two processes must give way or there can be - ** no progress. By returning SQLITE_BUSY and not invoking the busy callback - ** when A already has a read lock, we encourage A to give up and let B - ** proceed. - */ - static int sqlite3BtreeBeginTrans(Btree p, int wrflag) { - BtShared pBt = p.pBt; - int rc = SQLITE_OK; - - sqlite3BtreeEnter(p); - btreeIntegrity(p); - - /* If the btree is already in a write-transaction, or it - ** is already in a read-transaction and a read-transaction - ** is requested, this is a no-op. - */ - if (p.inTrans == TRANS_WRITE || (p.inTrans == TRANS_READ && 0 == wrflag)) { - goto trans_begun; - } + pBt.nPage = 1; + data[31] = 1; + return SQLITE_OK; +} - /* Write transactions are not possible on a read-only database */ - if (pBt.readOnly && wrflag != 0) { - rc = SQLITE_READONLY; - goto trans_begun; - } +/* +** Attempt to start a new transaction. A write-transaction +** is started if the second argument is nonzero, otherwise a read- +** transaction. If the second argument is 2 or more and exclusive +** transaction is started, meaning that no other process is allowed +** to access the database. A preexisting transaction may not be +** upgraded to exclusive by calling this routine a second time - the +** exclusivity flag only works for a new transaction. +** +** A write-transaction must be started before attempting any +** changes to the database. None of the following routines +** will work unless a transaction is started first: +** +** sqlite3BtreeCreateTable() +** sqlite3BtreeCreateIndex() +** sqlite3BtreeClearTable() +** sqlite3BtreeDropTable() +** sqlite3BtreeInsert() +** sqlite3BtreeDelete() +** sqlite3BtreeUpdateMeta() +** +** If an initial attempt to acquire the lock fails because of lock contention +** and the database was previously unlocked, then invoke the busy handler +** if there is one. But if there was previously a read-lock, do not +** invoke the busy handler - just return SQLITE_BUSY. SQLITE_BUSY is +** returned when there is already a read-lock in order to avoid a deadlock. +** +** Suppose there are two processes A and B. A has a read lock and B has +** a reserved lock. B tries to promote to exclusive but is blocked because +** of A's read lock. A tries to promote to reserved but is blocked by B. +** One or the other of the two processes must give way or there can be +** no progress. By returning SQLITE_BUSY and not invoking the busy callback +** when A already has a read lock, we encourage A to give up and let B +** proceed. +*/ +static int sqlite3BtreeBeginTrans( Btree p, int wrflag ) +{ + BtShared pBt = p.pBt; + int rc = SQLITE_OK; + + sqlite3BtreeEnter( p ); + btreeIntegrity( p ); + + /* If the btree is already in a write-transaction, or it + ** is already in a read-transaction and a read-transaction + ** is requested, this is a no-op. + */ + if ( p.inTrans == TRANS_WRITE || ( p.inTrans == TRANS_READ && 0 == wrflag ) ) + { + goto trans_begun; + } + + /* Write transactions are not possible on a read-only database */ + if ( pBt.readOnly && wrflag != 0 ) + { + rc = SQLITE_READONLY; + goto trans_begun; + } #if !SQLITE_OMIT_SHARED_CACHE /* If another database handle has already opened a write transaction @@ -2750,45 +2966,54 @@ static int sqlite3BtreeBeginTrans(Btree p, int wrflag) { } #endif - /* Any read-only or read-write transaction implies a read-lock on - ** page 1. So if some other shared-cache client already has a write-lock - ** on page 1, the transaction cannot be opened. */ - rc = querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK); - if (SQLITE_OK != rc) - goto trans_begun; - - pBt.initiallyEmpty = pBt.nPage == 0; - do { - /* Call lockBtree() until either pBt.pPage1 is populated or - ** lockBtree() returns something other than SQLITE_OK. lockBtree() - ** may return SQLITE_OK but leave pBt.pPage1 set to 0 if after - ** reading page 1 it discovers that the page-size of the database - ** file is not pBt.pageSize. In this case lockBtree() will update - ** pBt.pageSize to the page-size of the file on disk. - */ - while (pBt.pPage1 == null && SQLITE_OK == (rc = lockBtree(pBt))) - ; - - if (rc == SQLITE_OK && wrflag != 0) { - if (pBt.readOnly) { - rc = SQLITE_READONLY; - } else { - rc = sqlite3PagerBegin(pBt.pPager, wrflag > 1, sqlite3TempInMemory(p.db) ? 1 : 0); - if (rc == SQLITE_OK) { - rc = newDatabase(pBt); - } - } - } - - if (rc != SQLITE_OK) { - unlockBtreeIfUnused(pBt); - } - } while ((rc & 0xFF) == SQLITE_BUSY && pBt.inTransaction == TRANS_NONE && - btreeInvokeBusyHandler(pBt) != 0); - - if (rc == SQLITE_OK) { - if (p.inTrans == TRANS_NONE) { - pBt.nTransaction++; + /* Any read-only or read-write transaction implies a read-lock on +** page 1. So if some other shared-cache client already has a write-lock +** on page 1, the transaction cannot be opened. */ + rc = querySharedCacheTableLock( p, MASTER_ROOT, READ_LOCK ); + if ( SQLITE_OK != rc ) + goto trans_begun; + + pBt.initiallyEmpty = pBt.nPage == 0; + do + { + /* Call lockBtree() until either pBt.pPage1 is populated or + ** lockBtree() returns something other than SQLITE_OK. lockBtree() + ** may return SQLITE_OK but leave pBt.pPage1 set to 0 if after + ** reading page 1 it discovers that the page-size of the database + ** file is not pBt.pageSize. In this case lockBtree() will update + ** pBt.pageSize to the page-size of the file on disk. + */ + while ( pBt.pPage1 == null && SQLITE_OK == ( rc = lockBtree( pBt ) ) ) + ; + + if ( rc == SQLITE_OK && wrflag != 0 ) + { + if ( pBt.readOnly ) + { + rc = SQLITE_READONLY; + } + else + { + rc = sqlite3PagerBegin( pBt.pPager, wrflag > 1, sqlite3TempInMemory( p.db ) ? 1 : 0 ); + if ( rc == SQLITE_OK ) + { + rc = newDatabase( pBt ); + } + } + } + + if ( rc != SQLITE_OK ) + { + unlockBtreeIfUnused( pBt ); + } + } while ( ( rc & 0xFF ) == SQLITE_BUSY && pBt.inTransaction == TRANS_NONE && + btreeInvokeBusyHandler( pBt ) != 0 ); + + if ( rc == SQLITE_OK ) + { + if ( p.inTrans == TRANS_NONE ) + { + pBt.nTransaction++; #if !SQLITE_OMIT_SHARED_CACHE if( p.sharable ){ Debug.Assert( p.lock.pBtree==p && p.lock.iTable==1 ); @@ -2797,688 +3022,778 @@ static int sqlite3BtreeBeginTrans(Btree p, int wrflag) { pBt.pLock = &p.lock; } #endif - } - p.inTrans = (wrflag != 0 ? TRANS_WRITE : TRANS_READ); - if (p.inTrans > pBt.inTransaction) { - pBt.inTransaction = p.inTrans; - } - if (wrflag != 0) { - MemPage pPage1 = pBt.pPage1; + } + p.inTrans = ( wrflag != 0 ? TRANS_WRITE : TRANS_READ ); + if ( p.inTrans > pBt.inTransaction ) + { + pBt.inTransaction = p.inTrans; + } + if ( wrflag != 0 ) + { + MemPage pPage1 = pBt.pPage1; #if !SQLITE_OMIT_SHARED_CACHE Debug.Assert( !pBt.pWriter ); pBt.pWriter = p; pBt.isExclusive = (u8)(wrflag>1); #endif - /* If the db-size header field is incorrect (as it may be if an old - ** client has been writing the database file), update it now. Doing - ** this sooner rather than later means the database size can safely - ** re-read the database size from page 1 if a savepoint or transaction - ** rollback occurs within the transaction. - */ - if (pBt.nPage != sqlite3Get4byte(pPage1.aData, 28)) { - rc = sqlite3PagerWrite(pPage1.pDbPage); - if (rc == SQLITE_OK) { - sqlite3Put4byte(pPage1.aData, (u32)28, pBt.nPage); - } - } - } - } + /* If the db-size header field is incorrect (as it may be if an old +** client has been writing the database file), update it now. Doing +** this sooner rather than later means the database size can safely +** re-read the database size from page 1 if a savepoint or transaction +** rollback occurs within the transaction. +*/ + if ( pBt.nPage != sqlite3Get4byte( pPage1.aData, 28 ) ) + { + rc = sqlite3PagerWrite( pPage1.pDbPage ); + if ( rc == SQLITE_OK ) + { + sqlite3Put4byte( pPage1.aData, (u32)28, pBt.nPage ); + } + } + } + } + + +trans_begun: + if ( rc == SQLITE_OK && wrflag != 0 ) + { + /* This call makes sure that the pager has the correct number of + ** open savepoints. If the second parameter is greater than 0 and + ** the sub-journal is not already open, then it will be opened here. + */ + rc = sqlite3PagerOpenSavepoint( pBt.pPager, p.db.nSavepoint ); + } + + btreeIntegrity( p ); + sqlite3BtreeLeave( p ); + return rc; +} +#if !SQLITE_OMIT_AUTOVACUUM - trans_begun: - if (rc == SQLITE_OK && wrflag != 0) { - /* This call makes sure that the pager has the correct number of - ** open savepoints. If the second parameter is greater than 0 and - ** the sub-journal is not already open, then it will be opened here. - */ - rc = sqlite3PagerOpenSavepoint(pBt.pPager, p.db.nSavepoint); - } +/* +** Set the pointer-map entries for all children of page pPage. Also, if +** pPage contains cells that point to overflow pages, set the pointer +** map entries for the overflow pages as well. +*/ +static int setChildPtrmaps( MemPage pPage ) +{ + int i; /* Counter variable */ + int nCell; /* Number of cells in page pPage */ + int rc; /* Return code */ + BtShared pBt = pPage.pBt; + u8 isInitOrig = pPage.isInit; + Pgno pgno = pPage.pgno; + + Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); + rc = btreeInitPage( pPage ); + if ( rc != SQLITE_OK ) + { + goto set_child_ptrmaps_out; + } + nCell = pPage.nCell; + + for ( i = 0; i < nCell; i++ ) + { + int pCell = findCell( pPage, i ); + + ptrmapPutOvflPtr( pPage, pCell, ref rc ); + + if ( 0 == pPage.leaf ) + { + Pgno childPgno = sqlite3Get4byte( pPage.aData, pCell ); + ptrmapPut( pBt, childPgno, PTRMAP_BTREE, pgno, ref rc ); + } + } - btreeIntegrity(p); - sqlite3BtreeLeave(p); - return rc; - } + if ( 0 == pPage.leaf ) + { + Pgno childPgno = sqlite3Get4byte( pPage.aData, pPage.hdrOffset + 8 ); + ptrmapPut( pBt, childPgno, PTRMAP_BTREE, pgno, ref rc ); + } -#if !SQLITE_OMIT_AUTOVACUUM +set_child_ptrmaps_out: + pPage.isInit = isInitOrig; + return rc; +} - /* - ** Set the pointer-map entries for all children of page pPage. Also, if - ** pPage contains cells that point to overflow pages, set the pointer - ** map entries for the overflow pages as well. - */ - static int setChildPtrmaps(MemPage pPage) { - int i; /* Counter variable */ - int nCell; /* Number of cells in page pPage */ - int rc; /* Return code */ - BtShared pBt = pPage.pBt; - u8 isInitOrig = pPage.isInit; - Pgno pgno = pPage.pgno; - - Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); - rc = btreeInitPage(pPage); - if (rc != SQLITE_OK) { - goto set_child_ptrmaps_out; - } - nCell = pPage.nCell; +/* +** Somewhere on pPage is a pointer to page iFrom. Modify this pointer so +** that it points to iTo. Parameter eType describes the type of pointer to +** be modified, as follows: +** +** PTRMAP_BTREE: pPage is a btree-page. The pointer points at a child +** page of pPage. +** +** PTRMAP_OVERFLOW1: pPage is a btree-page. The pointer points at an overflow +** page pointed to by one of the cells on pPage. +** +** PTRMAP_OVERFLOW2: pPage is an overflow-page. The pointer points at the next +** overflow page in the list. +*/ +static int modifyPagePointer( MemPage pPage, Pgno iFrom, Pgno iTo, u8 eType ) +{ + Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); + Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); + if ( eType == PTRMAP_OVERFLOW2 ) + { + /* The pointer is always the first 4 bytes of the page in this case. */ + if ( sqlite3Get4byte( pPage.aData ) != iFrom ) + { + return SQLITE_CORRUPT_BKPT(); + } + sqlite3Put4byte( pPage.aData, iTo ); + } + else + { + u8 isInitOrig = pPage.isInit; + int i; + int nCell; + + btreeInitPage( pPage ); + nCell = pPage.nCell; + + for ( i = 0; i < nCell; i++ ) + { + int pCell = findCell( pPage, i ); + if ( eType == PTRMAP_OVERFLOW1 ) + { + CellInfo info = new CellInfo(); + btreeParseCellPtr( pPage, pCell, ref info ); + if ( info.iOverflow != 0 ) + { + if ( iFrom == sqlite3Get4byte( pPage.aData, pCell, info.iOverflow ) ) + { + sqlite3Put4byte( pPage.aData, pCell + info.iOverflow, (int)iTo ); + break; + } + } + } + else + { + if ( sqlite3Get4byte( pPage.aData, pCell ) == iFrom ) + { + sqlite3Put4byte( pPage.aData, pCell, (int)iTo ); + break; + } + } + } - for (i = 0; i < nCell; i++) { - int pCell = findCell(pPage, i); + if ( i == nCell ) + { + if ( eType != PTRMAP_BTREE || + sqlite3Get4byte( pPage.aData, pPage.hdrOffset + 8 ) != iFrom ) + { + return SQLITE_CORRUPT_BKPT(); + } + sqlite3Put4byte( pPage.aData, pPage.hdrOffset + 8, iTo ); + } - ptrmapPutOvflPtr(pPage, pCell, ref rc); + pPage.isInit = isInitOrig; + } + return SQLITE_OK; +} - if (0 == pPage.leaf) { - Pgno childPgno = sqlite3Get4byte(pPage.aData, pCell); - ptrmapPut(pBt, childPgno, PTRMAP_BTREE, pgno, ref rc); - } - } - if (0 == pPage.leaf) { - Pgno childPgno = sqlite3Get4byte(pPage.aData, pPage.hdrOffset + 8); - ptrmapPut(pBt, childPgno, PTRMAP_BTREE, pgno, ref rc); - } +/* +** Move the open database page pDbPage to location iFreePage in the +** database. The pDbPage reference remains valid. +** +** The isCommit flag indicates that there is no need to remember that +** the journal needs to be sync()ed before database page pDbPage.pgno +** can be written to. The caller has already promised not to write to that +** page. +*/ +static int relocatePage( +BtShared pBt, /* Btree */ +MemPage pDbPage, /* Open page to move */ +u8 eType, /* Pointer map 'type' entry for pDbPage */ +Pgno iPtrPage, /* Pointer map 'page-no' entry for pDbPage */ +Pgno iFreePage, /* The location to move pDbPage to */ +int isCommit /* isCommit flag passed to sqlite3PagerMovepage */ +) +{ + MemPage pPtrPage = new MemPage(); /* The page that contains a pointer to pDbPage */ + Pgno iDbPage = pDbPage.pgno; + Pager pPager = pBt.pPager; + int rc; + + Debug.Assert( eType == PTRMAP_OVERFLOW2 || eType == PTRMAP_OVERFLOW1 || + eType == PTRMAP_BTREE || eType == PTRMAP_ROOTPAGE ); + Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); + Debug.Assert( pDbPage.pBt == pBt ); + + /* Move page iDbPage from its current location to page number iFreePage */ + TRACE( "AUTOVACUUM: Moving %d to free page %d (ptr page %d type %d)\n", + iDbPage, iFreePage, iPtrPage, eType ); + rc = sqlite3PagerMovepage( pPager, pDbPage.pDbPage, iFreePage, isCommit ); + if ( rc != SQLITE_OK ) + { + return rc; + } + pDbPage.pgno = iFreePage; + + /* If pDbPage was a btree-page, then it may have child pages and/or cells + ** that point to overflow pages. The pointer map entries for all these + ** pages need to be changed. + ** + ** If pDbPage is an overflow page, then the first 4 bytes may store a + ** pointer to a subsequent overflow page. If this is the case, then + ** the pointer map needs to be updated for the subsequent overflow page. + */ + if ( eType == PTRMAP_BTREE || eType == PTRMAP_ROOTPAGE ) + { + rc = setChildPtrmaps( pDbPage ); + if ( rc != SQLITE_OK ) + { + return rc; + } + } + else + { + Pgno nextOvfl = sqlite3Get4byte( pDbPage.aData ); + if ( nextOvfl != 0 ) + { + ptrmapPut( pBt, nextOvfl, PTRMAP_OVERFLOW2, iFreePage, ref rc ); + if ( rc != SQLITE_OK ) + { + return rc; + } + } + } + + /* Fix the database pointer on page iPtrPage that pointed at iDbPage so + ** that it points at iFreePage. Also fix the pointer map entry for + ** iPtrPage. + */ + if ( eType != PTRMAP_ROOTPAGE ) + { + rc = btreeGetPage( pBt, iPtrPage, ref pPtrPage, 0 ); + if ( rc != SQLITE_OK ) + { + return rc; + } + rc = sqlite3PagerWrite( pPtrPage.pDbPage ); + if ( rc != SQLITE_OK ) + { + releasePage( pPtrPage ); + return rc; + } + rc = modifyPagePointer( pPtrPage, iDbPage, iFreePage, eType ); + releasePage( pPtrPage ); + if ( rc == SQLITE_OK ) + { + ptrmapPut( pBt, iFreePage, eType, iPtrPage, ref rc ); + } + } + return rc; +} - set_child_ptrmaps_out: - pPage.isInit = isInitOrig; - return rc; - } +/* Forward declaration required by incrVacuumStep(). */ +//static int allocateBtreePage(BtShared *, MemPage **, Pgno *, Pgno, u8); - /* - ** Somewhere on pPage is a pointer to page iFrom. Modify this pointer so - ** that it points to iTo. Parameter eType describes the type of pointer to - ** be modified, as follows: - ** - ** PTRMAP_BTREE: pPage is a btree-page. The pointer points at a child - ** page of pPage. - ** - ** PTRMAP_OVERFLOW1: pPage is a btree-page. The pointer points at an overflow - ** page pointed to by one of the cells on pPage. - ** - ** PTRMAP_OVERFLOW2: pPage is an overflow-page. The pointer points at the next - ** overflow page in the list. - */ - static int modifyPagePointer(MemPage pPage, Pgno iFrom, Pgno iTo, u8 eType) { - Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); - Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); - if (eType == PTRMAP_OVERFLOW2) { - /* The pointer is always the first 4 bytes of the page in this case. */ - if (sqlite3Get4byte(pPage.aData) != iFrom) { - return SQLITE_CORRUPT_BKPT(); - } - sqlite3Put4byte(pPage.aData, iTo); - } else { - u8 isInitOrig = pPage.isInit; - int i; - int nCell; - - btreeInitPage(pPage); - nCell = pPage.nCell; - - for (i = 0; i < nCell; i++) { - int pCell = findCell(pPage, i); - if (eType == PTRMAP_OVERFLOW1) { - CellInfo info = new CellInfo(); - btreeParseCellPtr(pPage, pCell, ref info); - if (info.iOverflow != 0) { - if (iFrom == sqlite3Get4byte(pPage.aData, pCell, info.iOverflow)) { - sqlite3Put4byte(pPage.aData, pCell + info.iOverflow, (int)iTo); - break; - } - } - } else { - if (sqlite3Get4byte(pPage.aData, pCell) == iFrom) { - sqlite3Put4byte(pPage.aData, pCell, (int)iTo); - break; - } - } - } - - if (i == nCell) { - if (eType != PTRMAP_BTREE || - sqlite3Get4byte(pPage.aData, pPage.hdrOffset + 8) != iFrom) { - return SQLITE_CORRUPT_BKPT(); - } - sqlite3Put4byte(pPage.aData, pPage.hdrOffset + 8, iTo); - } - - pPage.isInit = isInitOrig; - } - return SQLITE_OK; - } +/* +** Perform a single step of an incremental-vacuum. If successful, +** return SQLITE_OK. If there is no work to do (and therefore no +** point in calling this function again), return SQLITE_DONE. +** +** More specificly, this function attempts to re-organize the +** database so that the last page of the file currently in use +** is no longer in use. +** +** If the nFin parameter is non-zero, this function assumes +** that the caller will keep calling incrVacuumStep() until +** it returns SQLITE_DONE or an error, and that nFin is the +** number of pages the database file will contain after this +** process is complete. If nFin is zero, it is assumed that +** incrVacuumStep() will be called a finite amount of times +** which may or may not empty the freelist. A full autovacuum +** has nFin>0. A "PRAGMA incremental_vacuum" has nFin==null. +*/ +static int incrVacuumStep( BtShared pBt, Pgno nFin, Pgno iLastPg ) +{ + Pgno nFreeList; /* Number of pages still on the free-list */ + int rc; + Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); + Debug.Assert( iLastPg > nFin ); - /* - ** Move the open database page pDbPage to location iFreePage in the - ** database. The pDbPage reference remains valid. - ** - ** The isCommit flag indicates that there is no need to remember that - ** the journal needs to be sync()ed before database page pDbPage.pgno - ** can be written to. The caller has already promised not to write to that - ** page. - */ - static int relocatePage( - BtShared pBt, /* Btree */ - MemPage pDbPage, /* Open page to move */ - u8 eType, /* Pointer map 'type' entry for pDbPage */ - Pgno iPtrPage, /* Pointer map 'page-no' entry for pDbPage */ - Pgno iFreePage, /* The location to move pDbPage to */ - int isCommit /* isCommit flag passed to sqlite3PagerMovepage */ - ) { - MemPage pPtrPage = new MemPage(); /* The page that contains a pointer to pDbPage */ - Pgno iDbPage = pDbPage.pgno; - Pager pPager = pBt.pPager; - int rc; - - Debug.Assert(eType == PTRMAP_OVERFLOW2 || eType == PTRMAP_OVERFLOW1 || - eType == PTRMAP_BTREE || eType == PTRMAP_ROOTPAGE); - Debug.Assert(sqlite3_mutex_held(pBt.mutex)); - Debug.Assert(pDbPage.pBt == pBt); - - /* Move page iDbPage from its current location to page number iFreePage */ - TRACE("AUTOVACUUM: Moving %d to free page %d (ptr page %d type %d)\n", - iDbPage, iFreePage, iPtrPage, eType); - rc = sqlite3PagerMovepage(pPager, pDbPage.pDbPage, iFreePage, isCommit); - if (rc != SQLITE_OK) { - return rc; - } - pDbPage.pgno = iFreePage; - - /* If pDbPage was a btree-page, then it may have child pages and/or cells - ** that point to overflow pages. The pointer map entries for all these - ** pages need to be changed. - ** - ** If pDbPage is an overflow page, then the first 4 bytes may store a - ** pointer to a subsequent overflow page. If this is the case, then - ** the pointer map needs to be updated for the subsequent overflow page. - */ - if (eType == PTRMAP_BTREE || eType == PTRMAP_ROOTPAGE) { - rc = setChildPtrmaps(pDbPage); - if (rc != SQLITE_OK) { - return rc; - } - } else { - Pgno nextOvfl = sqlite3Get4byte(pDbPage.aData); - if (nextOvfl != 0) { - ptrmapPut(pBt, nextOvfl, PTRMAP_OVERFLOW2, iFreePage, ref rc); - if (rc != SQLITE_OK) { - return rc; - } - } - } + if ( !PTRMAP_ISPAGE( pBt, iLastPg ) && iLastPg != PENDING_BYTE_PAGE( pBt ) ) + { + u8 eType = 0; + Pgno iPtrPage = 0; - /* Fix the database pointer on page iPtrPage that pointed at iDbPage so - ** that it points at iFreePage. Also fix the pointer map entry for - ** iPtrPage. - */ - if (eType != PTRMAP_ROOTPAGE) { - rc = btreeGetPage(pBt, iPtrPage, ref pPtrPage, 0); - if (rc != SQLITE_OK) { - return rc; - } - rc = sqlite3PagerWrite(pPtrPage.pDbPage); - if (rc != SQLITE_OK) { - releasePage(pPtrPage); - return rc; - } - rc = modifyPagePointer(pPtrPage, iDbPage, iFreePage, eType); - releasePage(pPtrPage); - if (rc == SQLITE_OK) { - ptrmapPut(pBt, iFreePage, eType, iPtrPage, ref rc); - } - } - return rc; - } + nFreeList = sqlite3Get4byte( pBt.pPage1.aData, 36 ); + if ( nFreeList == 0 ) + { + return SQLITE_DONE; + } - /* Forward declaration required by incrVacuumStep(). */ - //static int allocateBtreePage(BtShared *, MemPage **, Pgno *, Pgno, u8); + rc = ptrmapGet( pBt, iLastPg, ref eType, ref iPtrPage ); + if ( rc != SQLITE_OK ) + { + return rc; + } + if ( eType == PTRMAP_ROOTPAGE ) + { + return SQLITE_CORRUPT_BKPT(); + } - /* - ** Perform a single step of an incremental-vacuum. If successful, - ** return SQLITE_OK. If there is no work to do (and therefore no - ** point in calling this function again), return SQLITE_DONE. - ** - ** More specificly, this function attempts to re-organize the - ** database so that the last page of the file currently in use - ** is no longer in use. - ** - ** If the nFin parameter is non-zero, this function assumes - ** that the caller will keep calling incrVacuumStep() until - ** it returns SQLITE_DONE or an error, and that nFin is the - ** number of pages the database file will contain after this - ** process is complete. If nFin is zero, it is assumed that - ** incrVacuumStep() will be called a finite amount of times - ** which may or may not empty the freelist. A full autovacuum - ** has nFin>0. A "PRAGMA incremental_vacuum" has nFin==null. - */ - static int incrVacuumStep(BtShared pBt, Pgno nFin, Pgno iLastPg) { - Pgno nFreeList; /* Number of pages still on the free-list */ - int rc; - - Debug.Assert(sqlite3_mutex_held(pBt.mutex)); - Debug.Assert(iLastPg > nFin); - - if (!PTRMAP_ISPAGE(pBt, iLastPg) && iLastPg != PENDING_BYTE_PAGE(pBt)) { - u8 eType = 0; - Pgno iPtrPage = 0; - - nFreeList = sqlite3Get4byte(pBt.pPage1.aData, 36); - if (nFreeList == 0) { - return SQLITE_DONE; - } - - rc = ptrmapGet(pBt, iLastPg, ref eType, ref iPtrPage); - if (rc != SQLITE_OK) { - return rc; - } - if (eType == PTRMAP_ROOTPAGE) { - return SQLITE_CORRUPT_BKPT(); - } - - if (eType == PTRMAP_FREEPAGE) { - if (nFin == 0) { - /* Remove the page from the files free-list. This is not required - ** if nFin is non-zero. In that case, the free-list will be - ** truncated to zero after this function returns, so it doesn't - ** matter if it still contains some garbage entries. - */ - Pgno iFreePg = 0; - MemPage pFreePg = new MemPage(); - rc = allocateBtreePage(pBt, ref pFreePg, ref iFreePg, iLastPg, 1); - if (rc != SQLITE_OK) { - return rc; - } - Debug.Assert(iFreePg == iLastPg); - releasePage(pFreePg); - } - } else { - Pgno iFreePg = 0; /* Index of free page to move pLastPg to */ - MemPage pLastPg = new MemPage(); - - rc = btreeGetPage(pBt, iLastPg, ref pLastPg, 0); - if (rc != SQLITE_OK) { - return rc; - } - - /* If nFin is zero, this loop runs exactly once and page pLastPg - ** is swapped with the first free page pulled off the free list. - ** - ** On the other hand, if nFin is greater than zero, then keep - ** looping until a free-page located within the first nFin pages - ** of the file is found. - */ - do { - MemPage pFreePg = new MemPage(); - rc = allocateBtreePage(pBt, ref pFreePg, ref iFreePg, 0, 0); - if (rc != SQLITE_OK) { - releasePage(pLastPg); - return rc; - } - releasePage(pFreePg); - } while (nFin != 0 && iFreePg > nFin); - Debug.Assert(iFreePg < iLastPg); - - rc = sqlite3PagerWrite(pLastPg.pDbPage); - if (rc == SQLITE_OK) { - rc = relocatePage(pBt, pLastPg, eType, iPtrPage, iFreePg, (nFin != 0) ? 1 : 0); - } - releasePage(pLastPg); - if (rc != SQLITE_OK) { - return rc; - } - } - } + if ( eType == PTRMAP_FREEPAGE ) + { + if ( nFin == 0 ) + { + /* Remove the page from the files free-list. This is not required + ** if nFin is non-zero. In that case, the free-list will be + ** truncated to zero after this function returns, so it doesn't + ** matter if it still contains some garbage entries. + */ + Pgno iFreePg = 0; + MemPage pFreePg = new MemPage(); + rc = allocateBtreePage( pBt, ref pFreePg, ref iFreePg, iLastPg, 1 ); + if ( rc != SQLITE_OK ) + { + return rc; + } + Debug.Assert( iFreePg == iLastPg ); + releasePage( pFreePg ); + } + } + else + { + Pgno iFreePg = 0; /* Index of free page to move pLastPg to */ + MemPage pLastPg = new MemPage(); + + rc = btreeGetPage( pBt, iLastPg, ref pLastPg, 0 ); + if ( rc != SQLITE_OK ) + { + return rc; + } + + /* If nFin is zero, this loop runs exactly once and page pLastPg + ** is swapped with the first free page pulled off the free list. + ** + ** On the other hand, if nFin is greater than zero, then keep + ** looping until a free-page located within the first nFin pages + ** of the file is found. + */ + do + { + MemPage pFreePg = new MemPage(); + rc = allocateBtreePage( pBt, ref pFreePg, ref iFreePg, 0, 0 ); + if ( rc != SQLITE_OK ) + { + releasePage( pLastPg ); + return rc; + } + releasePage( pFreePg ); + } while ( nFin != 0 && iFreePg > nFin ); + Debug.Assert( iFreePg < iLastPg ); + + rc = sqlite3PagerWrite( pLastPg.pDbPage ); + if ( rc == SQLITE_OK ) + { + rc = relocatePage( pBt, pLastPg, eType, iPtrPage, iFreePg, ( nFin != 0 ) ? 1 : 0 ); + } + releasePage( pLastPg ); + if ( rc != SQLITE_OK ) + { + return rc; + } + } + } - if (nFin == 0) { - iLastPg--; - while (iLastPg == PENDING_BYTE_PAGE(pBt) || PTRMAP_ISPAGE(pBt, iLastPg)) { - if (PTRMAP_ISPAGE(pBt, iLastPg)) { - MemPage pPg = new MemPage(); - rc = btreeGetPage(pBt, iLastPg, ref pPg, 0); - if (rc != SQLITE_OK) { - return rc; - } - rc = sqlite3PagerWrite(pPg.pDbPage); - releasePage(pPg); - if (rc != SQLITE_OK) { - return rc; - } - } - iLastPg--; - } - sqlite3PagerTruncateImage(pBt.pPager, iLastPg); - pBt.nPage = iLastPg; - } - return SQLITE_OK; - } + if ( nFin == 0 ) + { + iLastPg--; + while ( iLastPg == PENDING_BYTE_PAGE( pBt ) || PTRMAP_ISPAGE( pBt, iLastPg ) ) + { + if ( PTRMAP_ISPAGE( pBt, iLastPg ) ) + { + MemPage pPg = new MemPage(); + rc = btreeGetPage( pBt, iLastPg, ref pPg, 0 ); + if ( rc != SQLITE_OK ) + { + return rc; + } + rc = sqlite3PagerWrite( pPg.pDbPage ); + releasePage( pPg ); + if ( rc != SQLITE_OK ) + { + return rc; + } + } + iLastPg--; + } + sqlite3PagerTruncateImage( pBt.pPager, iLastPg ); + pBt.nPage = iLastPg; + } + return SQLITE_OK; +} - /* - ** A write-transaction must be opened before calling this function. - ** It performs a single unit of work towards an incremental vacuum. - ** - ** If the incremental vacuum is finished after this function has run, - ** SQLITE_DONE is returned. If it is not finished, but no error occurred, - ** SQLITE_OK is returned. Otherwise an SQLite error code. - */ - static int sqlite3BtreeIncrVacuum(Btree p) { - int rc; - BtShared pBt = p.pBt; - - sqlite3BtreeEnter(p); - Debug.Assert(pBt.inTransaction == TRANS_WRITE && p.inTrans == TRANS_WRITE); - if (!pBt.autoVacuum) { - rc = SQLITE_DONE; - } else { - invalidateAllOverflowCache(pBt); - rc = incrVacuumStep(pBt, 0, btreePagecount(pBt)); - if (rc == SQLITE_OK) { - rc = sqlite3PagerWrite(pBt.pPage1.pDbPage); - sqlite3Put4byte(pBt.pPage1.aData, (u32)28, pBt.nPage);//put4byte(&pBt->pPage1->aData[28], pBt->nPage); - } - } - sqlite3BtreeLeave(p); - return rc; - } +/* +** A write-transaction must be opened before calling this function. +** It performs a single unit of work towards an incremental vacuum. +** +** If the incremental vacuum is finished after this function has run, +** SQLITE_DONE is returned. If it is not finished, but no error occurred, +** SQLITE_OK is returned. Otherwise an SQLite error code. +*/ +static int sqlite3BtreeIncrVacuum( Btree p ) +{ + int rc; + BtShared pBt = p.pBt; + + sqlite3BtreeEnter( p ); + Debug.Assert( pBt.inTransaction == TRANS_WRITE && p.inTrans == TRANS_WRITE ); + if ( !pBt.autoVacuum ) + { + rc = SQLITE_DONE; + } + else + { + invalidateAllOverflowCache( pBt ); + rc = incrVacuumStep( pBt, 0, btreePagecount( pBt ) ); + if ( rc == SQLITE_OK ) + { + rc = sqlite3PagerWrite( pBt.pPage1.pDbPage ); + sqlite3Put4byte( pBt.pPage1.aData, (u32)28, pBt.nPage );//put4byte(&pBt->pPage1->aData[28], pBt->nPage); + } + } + sqlite3BtreeLeave( p ); + return rc; +} - /* - ** This routine is called prior to sqlite3PagerCommit when a transaction - ** is commited for an auto-vacuum database. - ** - ** If SQLITE_OK is returned, then pnTrunc is set to the number of pages - ** the database file should be truncated to during the commit process. - ** i.e. the database has been reorganized so that only the first pnTrunc - ** pages are in use. - */ - static int autoVacuumCommit(BtShared pBt) { - int rc = SQLITE_OK; - Pager pPager = pBt.pPager; - // VVA_ONLY( int nRef = sqlite3PagerRefcount(pPager) ); +/* +** This routine is called prior to sqlite3PagerCommit when a transaction +** is commited for an auto-vacuum database. +** +** If SQLITE_OK is returned, then pnTrunc is set to the number of pages +** the database file should be truncated to during the commit process. +** i.e. the database has been reorganized so that only the first pnTrunc +** pages are in use. +*/ +static int autoVacuumCommit( BtShared pBt ) +{ + int rc = SQLITE_OK; + Pager pPager = pBt.pPager; + // VVA_ONLY( int nRef = sqlite3PagerRefcount(pPager) ); #if !NDEBUG || DEBUG - int nRef = sqlite3PagerRefcount(pPager); + int nRef = sqlite3PagerRefcount( pPager ); #else int nRef=0; #endif - Debug.Assert(sqlite3_mutex_held(pBt.mutex)); - invalidateAllOverflowCache(pBt); - Debug.Assert(pBt.autoVacuum); - if (!pBt.incrVacuum) { - Pgno nFin; /* Number of pages in database after autovacuuming */ - Pgno nFree; /* Number of pages on the freelist initially */ - Pgno nPtrmap; /* Number of PtrMap pages to be freed */ - Pgno iFree; /* The next page to be freed */ - int nEntry; /* Number of entries on one ptrmap page */ - Pgno nOrig; /* Database size before freeing */ - - nOrig = btreePagecount(pBt); - if (PTRMAP_ISPAGE(pBt, nOrig) || nOrig == PENDING_BYTE_PAGE(pBt)) { - /* It is not possible to create a database for which the final page - ** is either a pointer-map page or the pending-byte page. If one - ** is encountered, this indicates corruption. - */ - return SQLITE_CORRUPT_BKPT(); - } - - nFree = sqlite3Get4byte(pBt.pPage1.aData, 36); - nEntry = (int)pBt.usableSize / 5; - nPtrmap = (Pgno)((nFree - nOrig + PTRMAP_PAGENO(pBt, nOrig) + (Pgno)nEntry) / nEntry); - nFin = nOrig - nFree - nPtrmap; - if (nOrig > PENDING_BYTE_PAGE(pBt) && nFin < PENDING_BYTE_PAGE(pBt)) { - nFin--; - } - while (PTRMAP_ISPAGE(pBt, nFin) || nFin == PENDING_BYTE_PAGE(pBt)) { - nFin--; - } - if (nFin > nOrig) - return SQLITE_CORRUPT_BKPT(); - - for (iFree = nOrig; iFree > nFin && rc == SQLITE_OK; iFree--) { - rc = incrVacuumStep(pBt, nFin, iFree); - } - if ((rc == SQLITE_DONE || rc == SQLITE_OK) && nFree > 0) { - rc = sqlite3PagerWrite(pBt.pPage1.pDbPage); - sqlite3Put4byte(pBt.pPage1.aData, 32, 0); - sqlite3Put4byte(pBt.pPage1.aData, 36, 0); - sqlite3Put4byte(pBt.pPage1.aData, (u32)28, nFin); - sqlite3PagerTruncateImage(pBt.pPager, nFin); - pBt.nPage = nFin; - } - if (rc != SQLITE_OK) { - sqlite3PagerRollback(pPager); - } - } + Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); + invalidateAllOverflowCache( pBt ); + Debug.Assert( pBt.autoVacuum ); + if ( !pBt.incrVacuum ) + { + Pgno nFin; /* Number of pages in database after autovacuuming */ + Pgno nFree; /* Number of pages on the freelist initially */ + Pgno nPtrmap; /* Number of PtrMap pages to be freed */ + Pgno iFree; /* The next page to be freed */ + int nEntry; /* Number of entries on one ptrmap page */ + Pgno nOrig; /* Database size before freeing */ + + nOrig = btreePagecount( pBt ); + if ( PTRMAP_ISPAGE( pBt, nOrig ) || nOrig == PENDING_BYTE_PAGE( pBt ) ) + { + /* It is not possible to create a database for which the final page + ** is either a pointer-map page or the pending-byte page. If one + ** is encountered, this indicates corruption. + */ + return SQLITE_CORRUPT_BKPT(); + } - Debug.Assert(nRef == sqlite3PagerRefcount(pPager)); - return rc; - } + nFree = sqlite3Get4byte( pBt.pPage1.aData, 36 ); + nEntry = (int)pBt.usableSize / 5; + nPtrmap = (Pgno)( ( nFree - nOrig + PTRMAP_PAGENO( pBt, nOrig ) + (Pgno)nEntry ) / nEntry ); + nFin = nOrig - nFree - nPtrmap; + if ( nOrig > PENDING_BYTE_PAGE( pBt ) && nFin < PENDING_BYTE_PAGE( pBt ) ) + { + nFin--; + } + while ( PTRMAP_ISPAGE( pBt, nFin ) || nFin == PENDING_BYTE_PAGE( pBt ) ) + { + nFin--; + } + if ( nFin > nOrig ) + return SQLITE_CORRUPT_BKPT(); + + for ( iFree = nOrig; iFree > nFin && rc == SQLITE_OK; iFree-- ) + { + rc = incrVacuumStep( pBt, nFin, iFree ); + } + if ( ( rc == SQLITE_DONE || rc == SQLITE_OK ) && nFree > 0 ) + { + rc = sqlite3PagerWrite( pBt.pPage1.pDbPage ); + sqlite3Put4byte( pBt.pPage1.aData, 32, 0 ); + sqlite3Put4byte( pBt.pPage1.aData, 36, 0 ); + sqlite3Put4byte( pBt.pPage1.aData, (u32)28, nFin ); + sqlite3PagerTruncateImage( pBt.pPager, nFin ); + pBt.nPage = nFin; + } + if ( rc != SQLITE_OK ) + { + sqlite3PagerRollback( pPager ); + } + } + + Debug.Assert( nRef == sqlite3PagerRefcount( pPager ) ); + return rc; +} #else //* ifndef SQLITE_OMIT_AUTOVACUUM */ //# define setChildPtrmaps(x) SQLITE_OK #endif - /* - ** This routine does the first phase of a two-phase commit. This routine - ** causes a rollback journal to be created (if it does not already exist) - ** and populated with enough information so that if a power loss occurs - ** the database can be restored to its original state by playing back - ** the journal. Then the contents of the journal are flushed out to - ** the disk. After the journal is safely on oxide, the changes to the - ** database are written into the database file and flushed to oxide. - ** At the end of this call, the rollback journal still exists on the - ** disk and we are still holding all locks, so the transaction has not - ** committed. See sqlite3BtreeCommitPhaseTwo() for the second phase of the - ** commit process. - ** - ** This call is a no-op if no write-transaction is currently active on pBt. - ** - ** Otherwise, sync the database file for the btree pBt. zMaster points to - ** the name of a master journal file that should be written into the - ** individual journal file, or is NULL, indicating no master journal file - ** (single database transaction). - ** - ** When this is called, the master journal should already have been - ** created, populated with this journal pointer and synced to disk. - ** - ** Once this is routine has returned, the only thing required to commit - ** the write-transaction for this database file is to delete the journal. - */ - static int sqlite3BtreeCommitPhaseOne(Btree p, string zMaster) { - int rc = SQLITE_OK; - if (p.inTrans == TRANS_WRITE) { - BtShared pBt = p.pBt; - sqlite3BtreeEnter(p); +/* +** This routine does the first phase of a two-phase commit. This routine +** causes a rollback journal to be created (if it does not already exist) +** and populated with enough information so that if a power loss occurs +** the database can be restored to its original state by playing back +** the journal. Then the contents of the journal are flushed out to +** the disk. After the journal is safely on oxide, the changes to the +** database are written into the database file and flushed to oxide. +** At the end of this call, the rollback journal still exists on the +** disk and we are still holding all locks, so the transaction has not +** committed. See sqlite3BtreeCommitPhaseTwo() for the second phase of the +** commit process. +** +** This call is a no-op if no write-transaction is currently active on pBt. +** +** Otherwise, sync the database file for the btree pBt. zMaster points to +** the name of a master journal file that should be written into the +** individual journal file, or is NULL, indicating no master journal file +** (single database transaction). +** +** When this is called, the master journal should already have been +** created, populated with this journal pointer and synced to disk. +** +** Once this is routine has returned, the only thing required to commit +** the write-transaction for this database file is to delete the journal. +*/ +static int sqlite3BtreeCommitPhaseOne( Btree p, string zMaster ) +{ + int rc = SQLITE_OK; + if ( p.inTrans == TRANS_WRITE ) + { + BtShared pBt = p.pBt; + sqlite3BtreeEnter( p ); #if !SQLITE_OMIT_AUTOVACUUM - if (pBt.autoVacuum) { - rc = autoVacuumCommit(pBt); - if (rc != SQLITE_OK) { - sqlite3BtreeLeave(p); - return rc; - } - } + if ( pBt.autoVacuum ) + { + rc = autoVacuumCommit( pBt ); + if ( rc != SQLITE_OK ) + { + sqlite3BtreeLeave( p ); + return rc; + } + } #endif - rc = sqlite3PagerCommitPhaseOne(pBt.pPager, zMaster, false); - sqlite3BtreeLeave(p); - } - return rc; - } + rc = sqlite3PagerCommitPhaseOne( pBt.pPager, zMaster, false ); + sqlite3BtreeLeave( p ); + } + return rc; +} - /* - ** This function is called from both BtreeCommitPhaseTwo() and BtreeRollback() - ** at the conclusion of a transaction. - */ - static void btreeEndTransaction(Btree p) { - BtShared pBt = p.pBt; - Debug.Assert(sqlite3BtreeHoldsMutex(p)); - - btreeClearHasContent(pBt); - if (p.inTrans > TRANS_NONE && p.db.activeVdbeCnt > 1) { - /* If there are other active statements that belong to this database - ** handle, downgrade to a read-only transaction. The other statements - ** may still be reading from the database. */ - - downgradeAllSharedCacheTableLocks(p); - p.inTrans = TRANS_READ; - } else { - /* If the handle had any kind of transaction open, decrement the - ** transaction count of the shared btree. If the transaction count - ** reaches 0, set the shared state to TRANS_NONE. The unlockBtreeIfUnused() - ** call below will unlock the pager. */ - if (p.inTrans != TRANS_NONE) { - clearAllSharedCacheTableLocks(p); - pBt.nTransaction--; - if (0 == pBt.nTransaction) { - pBt.inTransaction = TRANS_NONE; - } - } - - /* Set the current transaction state to TRANS_NONE and unlock the - ** pager if this call closed the only read or write transaction. */ - p.inTrans = TRANS_NONE; - unlockBtreeIfUnused(pBt); - } +/* +** This function is called from both BtreeCommitPhaseTwo() and BtreeRollback() +** at the conclusion of a transaction. +*/ +static void btreeEndTransaction( Btree p ) +{ + BtShared pBt = p.pBt; + Debug.Assert( sqlite3BtreeHoldsMutex( p ) ); + + btreeClearHasContent( pBt ); + if ( p.inTrans > TRANS_NONE && p.db.activeVdbeCnt > 1 ) + { + /* If there are other active statements that belong to this database + ** handle, downgrade to a read-only transaction. The other statements + ** may still be reading from the database. */ + + downgradeAllSharedCacheTableLocks( p ); + p.inTrans = TRANS_READ; + } + else + { + /* If the handle had any kind of transaction open, decrement the + ** transaction count of the shared btree. If the transaction count + ** reaches 0, set the shared state to TRANS_NONE. The unlockBtreeIfUnused() + ** call below will unlock the pager. */ + if ( p.inTrans != TRANS_NONE ) + { + clearAllSharedCacheTableLocks( p ); + pBt.nTransaction--; + if ( 0 == pBt.nTransaction ) + { + pBt.inTransaction = TRANS_NONE; + } + } - btreeIntegrity(p); - } + /* Set the current transaction state to TRANS_NONE and unlock the + ** pager if this call closed the only read or write transaction. */ + p.inTrans = TRANS_NONE; + unlockBtreeIfUnused( pBt ); + } - /* - ** Commit the transaction currently in progress. - ** - ** This routine implements the second phase of a 2-phase commit. The - ** sqlite3BtreeCommitPhaseOne() routine does the first phase and should - ** be invoked prior to calling this routine. The sqlite3BtreeCommitPhaseOne() - ** routine did all the work of writing information out to disk and flushing the - ** contents so that they are written onto the disk platter. All this - ** routine has to do is delete or truncate or zero the header in the - ** the rollback journal (which causes the transaction to commit) and - ** drop locks. - ** - ** Normally, if an error occurs while the pager layer is attempting to - ** finalize the underlying journal file, this function returns an error and - ** the upper layer will attempt a rollback. However, if the second argument - ** is non-zero then this b-tree transaction is part of a multi-file - ** transaction. In this case, the transaction has already been committed - ** (by deleting a master journal file) and the caller will ignore this - ** functions return code. So, even if an error occurs in the pager layer, - ** reset the b-tree objects internal state to indicate that the write - ** transaction has been closed. This is quite safe, as the pager will have - ** transitioned to the error state. - ** - ** This will release the write lock on the database file. If there - ** are no active cursors, it also releases the read lock. - */ - static int sqlite3BtreeCommitPhaseTwo(Btree p, int bCleanup) { - if (p.inTrans == TRANS_NONE) - return SQLITE_OK; - sqlite3BtreeEnter(p); - btreeIntegrity(p); - - /* If the handle has a write-transaction open, commit the shared-btrees - ** transaction and set the shared state to TRANS_READ. - */ - if (p.inTrans == TRANS_WRITE) { - int rc; - BtShared pBt = p.pBt; - Debug.Assert(pBt.inTransaction == TRANS_WRITE); - Debug.Assert(pBt.nTransaction > 0); - rc = sqlite3PagerCommitPhaseTwo(pBt.pPager); - if (rc != SQLITE_OK && bCleanup == 0) { - sqlite3BtreeLeave(p); - return rc; - } - pBt.inTransaction = TRANS_READ; - } + btreeIntegrity( p ); +} - btreeEndTransaction(p); - sqlite3BtreeLeave(p); - return SQLITE_OK; - } +/* +** Commit the transaction currently in progress. +** +** This routine implements the second phase of a 2-phase commit. The +** sqlite3BtreeCommitPhaseOne() routine does the first phase and should +** be invoked prior to calling this routine. The sqlite3BtreeCommitPhaseOne() +** routine did all the work of writing information out to disk and flushing the +** contents so that they are written onto the disk platter. All this +** routine has to do is delete or truncate or zero the header in the +** the rollback journal (which causes the transaction to commit) and +** drop locks. +** +** Normally, if an error occurs while the pager layer is attempting to +** finalize the underlying journal file, this function returns an error and +** the upper layer will attempt a rollback. However, if the second argument +** is non-zero then this b-tree transaction is part of a multi-file +** transaction. In this case, the transaction has already been committed +** (by deleting a master journal file) and the caller will ignore this +** functions return code. So, even if an error occurs in the pager layer, +** reset the b-tree objects internal state to indicate that the write +** transaction has been closed. This is quite safe, as the pager will have +** transitioned to the error state. +** +** This will release the write lock on the database file. If there +** are no active cursors, it also releases the read lock. +*/ +static int sqlite3BtreeCommitPhaseTwo( Btree p, int bCleanup) +{ + if ( p.inTrans == TRANS_NONE ) + return SQLITE_OK; + sqlite3BtreeEnter( p ); + btreeIntegrity( p ); + + /* If the handle has a write-transaction open, commit the shared-btrees + ** transaction and set the shared state to TRANS_READ. + */ + if ( p.inTrans == TRANS_WRITE ) + { + int rc; + BtShared pBt = p.pBt; + Debug.Assert( pBt.inTransaction == TRANS_WRITE ); + Debug.Assert( pBt.nTransaction > 0 ); + rc = sqlite3PagerCommitPhaseTwo( pBt.pPager ); + if ( rc != SQLITE_OK && bCleanup == 0 ) + { + sqlite3BtreeLeave( p ); + return rc; + } + pBt.inTransaction = TRANS_READ; + } - /* - ** Do both phases of a commit. - */ - static int sqlite3BtreeCommit(Btree p) { - int rc; - sqlite3BtreeEnter(p); - rc = sqlite3BtreeCommitPhaseOne(p, null); - if (rc == SQLITE_OK) { - rc = sqlite3BtreeCommitPhaseTwo(p, 0); - } - sqlite3BtreeLeave(p); - return rc; - } + btreeEndTransaction( p ); + sqlite3BtreeLeave( p ); + return SQLITE_OK; +} + +/* +** Do both phases of a commit. +*/ +static int sqlite3BtreeCommit( Btree p ) +{ + int rc; + sqlite3BtreeEnter( p ); + rc = sqlite3BtreeCommitPhaseOne( p, null ); + if ( rc == SQLITE_OK ) + { + rc = sqlite3BtreeCommitPhaseTwo( p, 0 ); + } + sqlite3BtreeLeave( p ); + return rc; +} #if !NDEBUG || DEBUG - /* - ** Return the number of write-cursors open on this handle. This is for use - ** in Debug.Assert() expressions, so it is only compiled if NDEBUG is not - ** defined. - ** - ** For the purposes of this routine, a write-cursor is any cursor that - ** is capable of writing to the databse. That means the cursor was - ** originally opened for writing and the cursor has not be disabled - ** by having its state changed to CURSOR_FAULT. - */ - static int countWriteCursors(BtShared pBt) { - BtCursor pCur; - int r = 0; - for (pCur = pBt.pCursor; pCur != null; pCur = pCur.pNext) { - if (pCur.wrFlag != 0 && pCur.eState != CURSOR_FAULT) - r++; - } - return r; - } +/* +** Return the number of write-cursors open on this handle. This is for use +** in Debug.Assert() expressions, so it is only compiled if NDEBUG is not +** defined. +** +** For the purposes of this routine, a write-cursor is any cursor that +** is capable of writing to the databse. That means the cursor was +** originally opened for writing and the cursor has not be disabled +** by having its state changed to CURSOR_FAULT. +*/ +static int countWriteCursors( BtShared pBt ) +{ + BtCursor pCur; + int r = 0; + for ( pCur = pBt.pCursor; pCur != null; pCur = pCur.pNext ) + { + if ( pCur.wrFlag != 0 && pCur.eState != CURSOR_FAULT ) + r++; + } + return r; +} #else static int countWriteCursors(BtShared pBt) { return -1; } #endif - /* - ** This routine sets the state to CURSOR_FAULT and the error - ** code to errCode for every cursor on BtShared that pBtree - ** references. - ** - ** Every cursor is tripped, including cursors that belong - ** to other database connections that happen to be sharing - ** the cache with pBtree. - ** - ** This routine gets called when a rollback occurs. - ** All cursors using the same cache must be tripped - ** to prevent them from trying to use the btree after - ** the rollback. The rollback may have deleted tables - ** or moved root pages, so it is not sufficient to - ** save the state of the cursor. The cursor must be - ** invalidated. - */ - static void sqlite3BtreeTripAllCursors(Btree pBtree, int errCode) { - BtCursor p; - sqlite3BtreeEnter(pBtree); - for (p = pBtree.pBt.pCursor; p != null; p = p.pNext) { - int i; - sqlite3BtreeClearCursor(p); - p.eState = CURSOR_FAULT; - p.skipNext = errCode; - for (i = 0; i <= p.iPage; i++) { - releasePage(p.apPage[i]); - p.apPage[i] = null; - } - } - sqlite3BtreeLeave(pBtree); - } +/* +** This routine sets the state to CURSOR_FAULT and the error +** code to errCode for every cursor on BtShared that pBtree +** references. +** +** Every cursor is tripped, including cursors that belong +** to other database connections that happen to be sharing +** the cache with pBtree. +** +** This routine gets called when a rollback occurs. +** All cursors using the same cache must be tripped +** to prevent them from trying to use the btree after +** the rollback. The rollback may have deleted tables +** or moved root pages, so it is not sufficient to +** save the state of the cursor. The cursor must be +** invalidated. +*/ +static void sqlite3BtreeTripAllCursors( Btree pBtree, int errCode ) +{ + BtCursor p; + sqlite3BtreeEnter( pBtree ); + for ( p = pBtree.pBt.pCursor; p != null; p = p.pNext ) + { + int i; + sqlite3BtreeClearCursor( p ); + p.eState = CURSOR_FAULT; + p.skipNext = errCode; + for ( i = 0; i <= p.iPage; i++ ) + { + releasePage( p.apPage[i] ); + p.apPage[i] = null; + } + } + sqlite3BtreeLeave( pBtree ); +} - /* - ** Rollback the transaction in progress. All cursors will be - ** invalided by this operation. Any attempt to use a cursor - ** that was open at the beginning of this operation will result - ** in an error. - ** - ** This will release the write lock on the database file. If there - ** are no active cursors, it also releases the read lock. - */ - static int sqlite3BtreeRollback(Btree p) { - int rc; - BtShared pBt = p.pBt; - MemPage pPage1 = new MemPage(); +/* +** Rollback the transaction in progress. All cursors will be +** invalided by this operation. Any attempt to use a cursor +** that was open at the beginning of this operation will result +** in an error. +** +** This will release the write lock on the database file. If there +** are no active cursors, it also releases the read lock. +*/ +static int sqlite3BtreeRollback( Btree p ) +{ + int rc; + BtShared pBt = p.pBt; + MemPage pPage1 = new MemPage(); - sqlite3BtreeEnter(p); - rc = saveAllCursors(pBt, 0, null); + sqlite3BtreeEnter( p ); + rc = saveAllCursors( pBt, 0, null ); #if !SQLITE_OMIT_SHARED_CACHE if( rc!=SQLITE_OK ){ /* This is a horrible situation. An IO or malloc() error occurred whilst @@ -3491,327 +3806,356 @@ static int sqlite3BtreeRollback(Btree p) { sqlite3BtreeTripAllCursors(p, rc); } #endif - btreeIntegrity(p); - - if (p.inTrans == TRANS_WRITE) { - int rc2; - - Debug.Assert(TRANS_WRITE == pBt.inTransaction); - rc2 = sqlite3PagerRollback(pBt.pPager); - if (rc2 != SQLITE_OK) { - rc = rc2; - } - - /* The rollback may have destroyed the pPage1.aData value. So - ** call btreeGetPage() on page 1 again to make - ** sure pPage1.aData is set correctly. */ - if (btreeGetPage(pBt, 1, ref pPage1, 0) == SQLITE_OK) { - Pgno nPage = sqlite3Get4byte(pPage1.aData, 28); - testcase(nPage == 0); - if (nPage == 0) - sqlite3PagerPagecount(pBt.pPager, out nPage); - testcase(pBt.nPage != nPage); - pBt.nPage = nPage; - releasePage(pPage1); - } - Debug.Assert(countWriteCursors(pBt) == 0); - pBt.inTransaction = TRANS_READ; - } + btreeIntegrity( p ); - btreeEndTransaction(p); - sqlite3BtreeLeave(p); - return rc; - } + if ( p.inTrans == TRANS_WRITE ) + { + int rc2; - /* - ** Start a statement subtransaction. The subtransaction can can be rolled - ** back independently of the main transaction. You must start a transaction - ** before starting a subtransaction. The subtransaction is ended automatically - ** if the main transaction commits or rolls back. - ** - ** Statement subtransactions are used around individual SQL statements - ** that are contained within a BEGIN...COMMIT block. If a constraint - ** error occurs within the statement, the effect of that one statement - ** can be rolled back without having to rollback the entire transaction. - ** - ** A statement sub-transaction is implemented as an anonymous savepoint. The - ** value passed as the second parameter is the total number of savepoints, - ** including the new anonymous savepoint, open on the B-Tree. i.e. if there - ** are no active savepoints and no other statement-transactions open, - ** iStatement is 1. This anonymous savepoint can be released or rolled back - ** using the sqlite3BtreeSavepoint() function. - */ - static int sqlite3BtreeBeginStmt(Btree p, int iStatement) { - int rc; - BtShared pBt = p.pBt; - sqlite3BtreeEnter(p); - Debug.Assert(p.inTrans == TRANS_WRITE); - Debug.Assert(!pBt.readOnly); - Debug.Assert(iStatement > 0); - Debug.Assert(iStatement > p.db.nSavepoint); - Debug.Assert(pBt.inTransaction == TRANS_WRITE); - /* At the pager level, a statement transaction is a savepoint with - ** an index greater than all savepoints created explicitly using - ** SQL statements. It is illegal to open, release or rollback any - ** such savepoints while the statement transaction savepoint is active. - */ - rc = sqlite3PagerOpenSavepoint(pBt.pPager, iStatement); - sqlite3BtreeLeave(p); - return rc; - } + Debug.Assert( TRANS_WRITE == pBt.inTransaction ); + rc2 = sqlite3PagerRollback( pBt.pPager ); + if ( rc2 != SQLITE_OK ) + { + rc = rc2; + } - /* - ** The second argument to this function, op, is always SAVEPOINT_ROLLBACK - ** or SAVEPOINT_RELEASE. This function either releases or rolls back the - ** savepoint identified by parameter iSavepoint, depending on the value - ** of op. - ** - ** Normally, iSavepoint is greater than or equal to zero. However, if op is - ** SAVEPOINT_ROLLBACK, then iSavepoint may also be -1. In this case the - ** contents of the entire transaction are rolled back. This is different - ** from a normal transaction rollback, as no locks are released and the - ** transaction remains open. - */ - static int sqlite3BtreeSavepoint(Btree p, int op, int iSavepoint) { - int rc = SQLITE_OK; - if (p != null && p.inTrans == TRANS_WRITE) { - BtShared pBt = p.pBt; - Debug.Assert(op == SAVEPOINT_RELEASE || op == SAVEPOINT_ROLLBACK); - Debug.Assert(iSavepoint >= 0 || (iSavepoint == -1 && op == SAVEPOINT_ROLLBACK)); - sqlite3BtreeEnter(p); - rc = sqlite3PagerSavepoint(pBt.pPager, op, iSavepoint); - if (rc == SQLITE_OK) { - if (iSavepoint < 0 && pBt.initiallyEmpty) - pBt.nPage = 0; - rc = newDatabase(pBt); - pBt.nPage = sqlite3Get4byte(pBt.pPage1.aData, 28); - /* The database size was written into the offset 28 of the header - ** when the transaction started, so we know that the value at offset - ** 28 is nonzero. */ - Debug.Assert(pBt.nPage > 0); - } - sqlite3BtreeLeave(p); - } - return rc; - } + /* The rollback may have destroyed the pPage1.aData value. So + ** call btreeGetPage() on page 1 again to make + ** sure pPage1.aData is set correctly. */ + if ( btreeGetPage( pBt, 1, ref pPage1, 0 ) == SQLITE_OK ) + { + Pgno nPage = sqlite3Get4byte( pPage1.aData, 28 ); + testcase( nPage == 0 ); + if ( nPage == 0 ) + sqlite3PagerPagecount( pBt.pPager, out nPage ); + testcase( pBt.nPage != nPage ); + pBt.nPage = nPage; + releasePage( pPage1 ); + } + Debug.Assert( countWriteCursors( pBt ) == 0 ); + pBt.inTransaction = TRANS_READ; + } - /* - ** Create a new cursor for the BTree whose root is on the page - ** iTable. If a read-only cursor is requested, it is assumed that - ** the caller already has at least a read-only transaction open - ** on the database already. If a write-cursor is requested, then - ** the caller is assumed to have an open write transaction. - ** - ** If wrFlag==null, then the cursor can only be used for reading. - ** If wrFlag==1, then the cursor can be used for reading or for - ** writing if other conditions for writing are also met. These - ** are the conditions that must be met in order for writing to - ** be allowed: - ** - ** 1: The cursor must have been opened with wrFlag==1 - ** - ** 2: Other database connections that share the same pager cache - ** but which are not in the READ_UNCOMMITTED state may not have - ** cursors open with wrFlag==null on the same table. Otherwise - ** the changes made by this write cursor would be visible to - ** the read cursors in the other database connection. - ** - ** 3: The database must be writable (not on read-only media) - ** - ** 4: There must be an active transaction. - ** - ** No checking is done to make sure that page iTable really is the - ** root page of a b-tree. If it is not, then the cursor acquired - ** will not work correctly. - ** - ** It is assumed that the sqlite3BtreeCursorZero() has been called - ** on pCur to initialize the memory space prior to invoking this routine. - */ - static int btreeCursor( - Btree p, /* The btree */ - int iTable, /* Root page of table to open */ - int wrFlag, /* 1 to write. 0 read-only */ - KeyInfo pKeyInfo, /* First arg to comparison function */ - BtCursor pCur /* Space for new cursor */ - ) { - BtShared pBt = p.pBt; /* Shared b-tree handle */ - - Debug.Assert(sqlite3BtreeHoldsMutex(p)); - Debug.Assert(wrFlag == 0 || wrFlag == 1); - - /* The following Debug.Assert statements verify that if this is a sharable - ** b-tree database, the connection is holding the required table locks, - ** and that no other connection has any open cursor that conflicts with - ** this lock. */ - Debug.Assert(hasSharedCacheTableLock(p, (u32)iTable, pKeyInfo != null ? 1 : 0, wrFlag + 1)); - Debug.Assert(wrFlag == 0 || !hasReadConflicts(p, (u32)iTable)); - - /* Assert that the caller has opened the required transaction. */ - Debug.Assert(p.inTrans > TRANS_NONE); - Debug.Assert(wrFlag == 0 || p.inTrans == TRANS_WRITE); - Debug.Assert(pBt.pPage1 != null && pBt.pPage1.aData != null); - - if (NEVER(wrFlag != 0 && pBt.readOnly)) { - return SQLITE_READONLY; - } - if (iTable == 1 && btreePagecount(pBt) == 0) { - return SQLITE_EMPTY; - } + btreeEndTransaction( p ); + sqlite3BtreeLeave( p ); + return rc; +} - /* Now that no other errors can occur, finish filling in the BtCursor - ** variables and link the cursor into the BtShared list. */ - pCur.pgnoRoot = (Pgno)iTable; - pCur.iPage = -1; - pCur.pKeyInfo = pKeyInfo; - pCur.pBtree = p; - pCur.pBt = pBt; - pCur.wrFlag = (u8)wrFlag; - pCur.pNext = pBt.pCursor; - if (pCur.pNext != null) { - pCur.pNext.pPrev = pCur; - } - pBt.pCursor = pCur; - pCur.eState = CURSOR_INVALID; - pCur.cachedRowid = 0; - return SQLITE_OK; - } - static int sqlite3BtreeCursor( - Btree p, /* The btree */ - int iTable, /* Root page of table to open */ - int wrFlag, /* 1 to write. 0 read-only */ - KeyInfo pKeyInfo, /* First arg to xCompare() */ - BtCursor pCur /* Write new cursor here */ - ) { - int rc; - sqlite3BtreeEnter(p); - rc = btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur); - sqlite3BtreeLeave(p); - return rc; - } +/* +** Start a statement subtransaction. The subtransaction can can be rolled +** back independently of the main transaction. You must start a transaction +** before starting a subtransaction. The subtransaction is ended automatically +** if the main transaction commits or rolls back. +** +** Statement subtransactions are used around individual SQL statements +** that are contained within a BEGIN...COMMIT block. If a constraint +** error occurs within the statement, the effect of that one statement +** can be rolled back without having to rollback the entire transaction. +** +** A statement sub-transaction is implemented as an anonymous savepoint. The +** value passed as the second parameter is the total number of savepoints, +** including the new anonymous savepoint, open on the B-Tree. i.e. if there +** are no active savepoints and no other statement-transactions open, +** iStatement is 1. This anonymous savepoint can be released or rolled back +** using the sqlite3BtreeSavepoint() function. +*/ +static int sqlite3BtreeBeginStmt( Btree p, int iStatement ) +{ + int rc; + BtShared pBt = p.pBt; + sqlite3BtreeEnter( p ); + Debug.Assert( p.inTrans == TRANS_WRITE ); + Debug.Assert( !pBt.readOnly ); + Debug.Assert( iStatement > 0 ); + Debug.Assert( iStatement > p.db.nSavepoint ); + Debug.Assert( pBt.inTransaction == TRANS_WRITE ); + /* At the pager level, a statement transaction is a savepoint with + ** an index greater than all savepoints created explicitly using + ** SQL statements. It is illegal to open, release or rollback any + ** such savepoints while the statement transaction savepoint is active. + */ + rc = sqlite3PagerOpenSavepoint( pBt.pPager, iStatement ); + sqlite3BtreeLeave( p ); + return rc; +} - /* - ** Return the size of a BtCursor object in bytes. - ** - ** This interfaces is needed so that users of cursors can preallocate - ** sufficient storage to hold a cursor. The BtCursor object is opaque - ** to users so they cannot do the sizeof() themselves - they must call - ** this routine. - */ - static int sqlite3BtreeCursorSize() { - return -1; // Not Used -- return ROUND8(sizeof(BtCursor)); - } +/* +** The second argument to this function, op, is always SAVEPOINT_ROLLBACK +** or SAVEPOINT_RELEASE. This function either releases or rolls back the +** savepoint identified by parameter iSavepoint, depending on the value +** of op. +** +** Normally, iSavepoint is greater than or equal to zero. However, if op is +** SAVEPOINT_ROLLBACK, then iSavepoint may also be -1. In this case the +** contents of the entire transaction are rolled back. This is different +** from a normal transaction rollback, as no locks are released and the +** transaction remains open. +*/ +static int sqlite3BtreeSavepoint( Btree p, int op, int iSavepoint ) +{ + int rc = SQLITE_OK; + if ( p != null && p.inTrans == TRANS_WRITE ) + { + BtShared pBt = p.pBt; + Debug.Assert( op == SAVEPOINT_RELEASE || op == SAVEPOINT_ROLLBACK ); + Debug.Assert( iSavepoint >= 0 || ( iSavepoint == -1 && op == SAVEPOINT_ROLLBACK ) ); + sqlite3BtreeEnter( p ); + rc = sqlite3PagerSavepoint( pBt.pPager, op, iSavepoint ); + if ( rc == SQLITE_OK ) + { + if ( iSavepoint < 0 && pBt.initiallyEmpty ) + pBt.nPage = 0; + rc = newDatabase( pBt ); + pBt.nPage = sqlite3Get4byte( pBt.pPage1.aData, 28 ); + /* The database size was written into the offset 28 of the header + ** when the transaction started, so we know that the value at offset + ** 28 is nonzero. */ + Debug.Assert( pBt.nPage > 0 ); + } + sqlite3BtreeLeave( p ); + } + return rc; +} - /* - ** Initialize memory that will be converted into a BtCursor object. - ** - ** The simple approach here would be to memset() the entire object - ** to zero. But it turns out that the apPage[] and aiIdx[] arrays - ** do not need to be zeroed and they are large, so we can save a lot - ** of run-time by skipping the initialization of those elements. - */ - static void sqlite3BtreeCursorZero(BtCursor p) { - p.Clear(); // memset( p, 0, offsetof( BtCursor, iPage ) ); - } +/* +** Create a new cursor for the BTree whose root is on the page +** iTable. If a read-only cursor is requested, it is assumed that +** the caller already has at least a read-only transaction open +** on the database already. If a write-cursor is requested, then +** the caller is assumed to have an open write transaction. +** +** If wrFlag==null, then the cursor can only be used for reading. +** If wrFlag==1, then the cursor can be used for reading or for +** writing if other conditions for writing are also met. These +** are the conditions that must be met in order for writing to +** be allowed: +** +** 1: The cursor must have been opened with wrFlag==1 +** +** 2: Other database connections that share the same pager cache +** but which are not in the READ_UNCOMMITTED state may not have +** cursors open with wrFlag==null on the same table. Otherwise +** the changes made by this write cursor would be visible to +** the read cursors in the other database connection. +** +** 3: The database must be writable (not on read-only media) +** +** 4: There must be an active transaction. +** +** No checking is done to make sure that page iTable really is the +** root page of a b-tree. If it is not, then the cursor acquired +** will not work correctly. +** +** It is assumed that the sqlite3BtreeCursorZero() has been called +** on pCur to initialize the memory space prior to invoking this routine. +*/ +static int btreeCursor( +Btree p, /* The btree */ +int iTable, /* Root page of table to open */ +int wrFlag, /* 1 to write. 0 read-only */ +KeyInfo pKeyInfo, /* First arg to comparison function */ +BtCursor pCur /* Space for new cursor */ +) +{ + BtShared pBt = p.pBt; /* Shared b-tree handle */ + + Debug.Assert( sqlite3BtreeHoldsMutex( p ) ); + Debug.Assert( wrFlag == 0 || wrFlag == 1 ); + + /* The following Debug.Assert statements verify that if this is a sharable + ** b-tree database, the connection is holding the required table locks, + ** and that no other connection has any open cursor that conflicts with + ** this lock. */ + Debug.Assert( hasSharedCacheTableLock( p, (u32)iTable, pKeyInfo != null ? 1 : 0, wrFlag + 1 ) ); + Debug.Assert( wrFlag == 0 || !hasReadConflicts( p, (u32)iTable ) ); + + /* Assert that the caller has opened the required transaction. */ + Debug.Assert( p.inTrans > TRANS_NONE ); + Debug.Assert( wrFlag == 0 || p.inTrans == TRANS_WRITE ); + Debug.Assert( pBt.pPage1 != null && pBt.pPage1.aData != null ); + + if ( NEVER( wrFlag != 0 && pBt.readOnly ) ) + { + return SQLITE_READONLY; + } + if ( iTable == 1 && btreePagecount( pBt ) == 0 ) + { + return SQLITE_EMPTY; + } + + /* Now that no other errors can occur, finish filling in the BtCursor + ** variables and link the cursor into the BtShared list. */ + pCur.pgnoRoot = (Pgno)iTable; + pCur.iPage = -1; + pCur.pKeyInfo = pKeyInfo; + pCur.pBtree = p; + pCur.pBt = pBt; + pCur.wrFlag = (u8)wrFlag; + pCur.pNext = pBt.pCursor; + if ( pCur.pNext != null ) + { + pCur.pNext.pPrev = pCur; + } + pBt.pCursor = pCur; + pCur.eState = CURSOR_INVALID; + pCur.cachedRowid = 0; + return SQLITE_OK; +} +static int sqlite3BtreeCursor( +Btree p, /* The btree */ +int iTable, /* Root page of table to open */ +int wrFlag, /* 1 to write. 0 read-only */ +KeyInfo pKeyInfo, /* First arg to xCompare() */ +BtCursor pCur /* Write new cursor here */ +) +{ + int rc; + sqlite3BtreeEnter( p ); + rc = btreeCursor( p, iTable, wrFlag, pKeyInfo, pCur ); + sqlite3BtreeLeave( p ); + return rc; +} - /* - ** Set the cached rowid value of every cursor in the same database file - ** as pCur and having the same root page number as pCur. The value is - ** set to iRowid. - ** - ** Only positive rowid values are considered valid for this cache. - ** The cache is initialized to zero, indicating an invalid cache. - ** A btree will work fine with zero or negative rowids. We just cannot - ** cache zero or negative rowids, which means tables that use zero or - ** negative rowids might run a little slower. But in practice, zero - ** or negative rowids are very uncommon so this should not be a problem. - */ - static void sqlite3BtreeSetCachedRowid(BtCursor pCur, sqlite3_int64 iRowid) { - BtCursor p; - for (p = pCur.pBt.pCursor; p != null; p = p.pNext) { - if (p.pgnoRoot == pCur.pgnoRoot) - p.cachedRowid = iRowid; - } - Debug.Assert(pCur.cachedRowid == iRowid); - } +/* +** Return the size of a BtCursor object in bytes. +** +** This interfaces is needed so that users of cursors can preallocate +** sufficient storage to hold a cursor. The BtCursor object is opaque +** to users so they cannot do the sizeof() themselves - they must call +** this routine. +*/ +static int sqlite3BtreeCursorSize() +{ + return -1; // Not Used -- return ROUND8(sizeof(BtCursor)); +} - /* - ** Return the cached rowid for the given cursor. A negative or zero - ** return value indicates that the rowid cache is invalid and should be - ** ignored. If the rowid cache has never before been set, then a - ** zero is returned. - */ - static sqlite3_int64 sqlite3BtreeGetCachedRowid(BtCursor pCur) { - return pCur.cachedRowid; - } +/* +** Initialize memory that will be converted into a BtCursor object. +** +** The simple approach here would be to memset() the entire object +** to zero. But it turns out that the apPage[] and aiIdx[] arrays +** do not need to be zeroed and they are large, so we can save a lot +** of run-time by skipping the initialization of those elements. +*/ +static void sqlite3BtreeCursorZero( BtCursor p ) +{ + p.Clear(); // memset( p, 0, offsetof( BtCursor, iPage ) ); +} - /* - ** Close a cursor. The read lock on the database file is released - ** when the last cursor is closed. - */ - static int sqlite3BtreeCloseCursor(BtCursor pCur) { - Btree pBtree = pCur.pBtree; - if (pBtree != null) { - int i; - BtShared pBt = pCur.pBt; - sqlite3BtreeEnter(pBtree); - sqlite3BtreeClearCursor(pCur); - if (pCur.pPrev != null) { - pCur.pPrev.pNext = pCur.pNext; - } else { - pBt.pCursor = pCur.pNext; - } - if (pCur.pNext != null) { - pCur.pNext.pPrev = pCur.pPrev; - } - for (i = 0; i <= pCur.iPage; i++) { - releasePage(pCur.apPage[i]); - } - unlockBtreeIfUnused(pBt); - invalidateOverflowCache(pCur); - /* sqlite3_free(ref pCur); */ - sqlite3BtreeLeave(pBtree); - } - return SQLITE_OK; - } +/* +** Set the cached rowid value of every cursor in the same database file +** as pCur and having the same root page number as pCur. The value is +** set to iRowid. +** +** Only positive rowid values are considered valid for this cache. +** The cache is initialized to zero, indicating an invalid cache. +** A btree will work fine with zero or negative rowids. We just cannot +** cache zero or negative rowids, which means tables that use zero or +** negative rowids might run a little slower. But in practice, zero +** or negative rowids are very uncommon so this should not be a problem. +*/ +static void sqlite3BtreeSetCachedRowid( BtCursor pCur, sqlite3_int64 iRowid ) +{ + BtCursor p; + for ( p = pCur.pBt.pCursor; p != null; p = p.pNext ) + { + if ( p.pgnoRoot == pCur.pgnoRoot ) + p.cachedRowid = iRowid; + } + Debug.Assert( pCur.cachedRowid == iRowid ); +} - /* - ** Make sure the BtCursor* given in the argument has a valid - ** BtCursor.info structure. If it is not already valid, call - ** btreeParseCell() to fill it in. - ** - ** BtCursor.info is a cache of the information in the current cell. - ** Using this cache reduces the number of calls to btreeParseCell(). - ** - ** 2007-06-25: There is a bug in some versions of MSVC that cause the - ** compiler to crash when getCellInfo() is implemented as a macro. - ** But there is a measureable speed advantage to using the macro on gcc - ** (when less compiler optimizations like -Os or -O0 are used and the - ** compiler is not doing agressive inlining.) So we use a real function - ** for MSVC and a macro for everything else. Ticket #2457. - */ +/* +** Return the cached rowid for the given cursor. A negative or zero +** return value indicates that the rowid cache is invalid and should be +** ignored. If the rowid cache has never before been set, then a +** zero is returned. +*/ +static sqlite3_int64 sqlite3BtreeGetCachedRowid( BtCursor pCur ) +{ + return pCur.cachedRowid; +} + +/* +** Close a cursor. The read lock on the database file is released +** when the last cursor is closed. +*/ +static int sqlite3BtreeCloseCursor( BtCursor pCur ) +{ + Btree pBtree = pCur.pBtree; + if ( pBtree != null ) + { + int i; + BtShared pBt = pCur.pBt; + sqlite3BtreeEnter( pBtree ); + sqlite3BtreeClearCursor( pCur ); + if ( pCur.pPrev != null ) + { + pCur.pPrev.pNext = pCur.pNext; + } + else + { + pBt.pCursor = pCur.pNext; + } + if ( pCur.pNext != null ) + { + pCur.pNext.pPrev = pCur.pPrev; + } + for ( i = 0; i <= pCur.iPage; i++ ) + { + releasePage( pCur.apPage[i] ); + } + unlockBtreeIfUnused( pBt ); + invalidateOverflowCache( pCur ); + /* sqlite3_free(ref pCur); */ + sqlite3BtreeLeave( pBtree ); + } + return SQLITE_OK; +} + +/* +** Make sure the BtCursor* given in the argument has a valid +** BtCursor.info structure. If it is not already valid, call +** btreeParseCell() to fill it in. +** +** BtCursor.info is a cache of the information in the current cell. +** Using this cache reduces the number of calls to btreeParseCell(). +** +** 2007-06-25: There is a bug in some versions of MSVC that cause the +** compiler to crash when getCellInfo() is implemented as a macro. +** But there is a measureable speed advantage to using the macro on gcc +** (when less compiler optimizations like -Os or -O0 are used and the +** compiler is not doing agressive inlining.) So we use a real function +** for MSVC and a macro for everything else. Ticket #2457. +*/ #if !NDEBUG - static void assertCellInfo(BtCursor pCur) { - CellInfo info; - int iPage = pCur.iPage; - info = new CellInfo();//memset(info, 0, sizeof(info)); - btreeParseCell(pCur.apPage[iPage], pCur.aiIdx[iPage], ref info); - Debug.Assert(info.GetHashCode() == pCur.info.GetHashCode() || info.Equals(pCur.info));//memcmp(info, pCur.info, sizeof(info))==0 ); - } +static void assertCellInfo( BtCursor pCur ) +{ + CellInfo info; + int iPage = pCur.iPage; + info = new CellInfo();//memset(info, 0, sizeof(info)); + btreeParseCell( pCur.apPage[iPage], pCur.aiIdx[iPage], ref info ); + Debug.Assert( info.GetHashCode() == pCur.info.GetHashCode() || info.Equals( pCur.info ) );//memcmp(info, pCur.info, sizeof(info))==0 ); +} #else // #define assertCellInfo(x) static void assertCellInfo(BtCursor pCur) { } #endif #if _MSC_VER - /* Use a real function in MSVC to work around bugs in that compiler. */ - static void getCellInfo(BtCursor pCur) { - if (pCur.info.nSize == 0) { - int iPage = pCur.iPage; - btreeParseCell(pCur.apPage[iPage], pCur.aiIdx[iPage], ref pCur.info); - pCur.validNKey = true; - } else { - assertCellInfo(pCur); - } - } +/* Use a real function in MSVC to work around bugs in that compiler. */ +static void getCellInfo( BtCursor pCur ) +{ + if ( pCur.info.nSize == 0 ) + { + int iPage = pCur.iPage; + btreeParseCell( pCur.apPage[iPage], pCur.aiIdx[iPage], ref pCur.info ); + pCur.validNKey = true; + } + else + { + assertCellInfo( pCur ); + } +} #else //* if not _MSC_VER */ /* Use a macro in all other compilers so that the function is inlined */ //#define getCellInfo(pCur) \ @@ -3825,271 +4169,299 @@ static void getCellInfo(BtCursor pCur) { #endif //* _MSC_VER */ #if !NDEBUG //* The next routine used only within Debug.Assert() statements */ - /* - ** Return true if the given BtCursor is valid. A valid cursor is one - ** that is currently pointing to a row in a (non-empty) table. - ** This is a verification routine is used only within Debug.Assert() statements. - */ - static bool sqlite3BtreeCursorIsValid(BtCursor pCur) { - return pCur != null && pCur.eState == CURSOR_VALID; - } +/* +** Return true if the given BtCursor is valid. A valid cursor is one +** that is currently pointing to a row in a (non-empty) table. +** This is a verification routine is used only within Debug.Assert() statements. +*/ +static bool sqlite3BtreeCursorIsValid( BtCursor pCur ) +{ + return pCur != null && pCur.eState == CURSOR_VALID; +} #else static bool sqlite3BtreeCursorIsValid(BtCursor pCur) { return true; } #endif //* NDEBUG */ - /* - ** Set pSize to the size of the buffer needed to hold the value of - ** the key for the current entry. If the cursor is not pointing - ** to a valid entry, pSize is set to 0. - ** - ** For a table with the INTKEY flag set, this routine returns the key - ** itself, not the number of bytes in the key. - ** - ** The caller must position the cursor prior to invoking this routine. - ** - ** This routine cannot fail. It always returns SQLITE_OK. - */ - static int sqlite3BtreeKeySize(BtCursor pCur, ref i64 pSize) { - Debug.Assert(cursorHoldsMutex(pCur)); - Debug.Assert(pCur.eState == CURSOR_INVALID || pCur.eState == CURSOR_VALID); - if (pCur.eState != CURSOR_VALID) { - pSize = 0; - } else { - getCellInfo(pCur); - pSize = pCur.info.nKey; - } - return SQLITE_OK; - } +/* +** Set pSize to the size of the buffer needed to hold the value of +** the key for the current entry. If the cursor is not pointing +** to a valid entry, pSize is set to 0. +** +** For a table with the INTKEY flag set, this routine returns the key +** itself, not the number of bytes in the key. +** +** The caller must position the cursor prior to invoking this routine. +** +** This routine cannot fail. It always returns SQLITE_OK. +*/ +static int sqlite3BtreeKeySize( BtCursor pCur, ref i64 pSize ) +{ + Debug.Assert( cursorHoldsMutex( pCur ) ); + Debug.Assert( pCur.eState == CURSOR_INVALID || pCur.eState == CURSOR_VALID ); + if ( pCur.eState != CURSOR_VALID ) + { + pSize = 0; + } + else + { + getCellInfo( pCur ); + pSize = pCur.info.nKey; + } + return SQLITE_OK; +} - /* - ** Set pSize to the number of bytes of data in the entry the - ** cursor currently points to. - ** - ** The caller must guarantee that the cursor is pointing to a non-NULL - ** valid entry. In other words, the calling procedure must guarantee - ** that the cursor has Cursor.eState==CURSOR_VALID. - ** - ** Failure is not possible. This function always returns SQLITE_OK. - ** It might just as well be a procedure (returning void) but we continue - ** to return an integer result code for historical reasons. - */ - static int sqlite3BtreeDataSize(BtCursor pCur, ref u32 pSize) { - Debug.Assert(cursorHoldsMutex(pCur)); - Debug.Assert(pCur.eState == CURSOR_VALID); - getCellInfo(pCur); - pSize = pCur.info.nData; - return SQLITE_OK; - } +/* +** Set pSize to the number of bytes of data in the entry the +** cursor currently points to. +** +** The caller must guarantee that the cursor is pointing to a non-NULL +** valid entry. In other words, the calling procedure must guarantee +** that the cursor has Cursor.eState==CURSOR_VALID. +** +** Failure is not possible. This function always returns SQLITE_OK. +** It might just as well be a procedure (returning void) but we continue +** to return an integer result code for historical reasons. +*/ +static int sqlite3BtreeDataSize( BtCursor pCur, ref u32 pSize ) +{ + Debug.Assert( cursorHoldsMutex( pCur ) ); + Debug.Assert( pCur.eState == CURSOR_VALID ); + getCellInfo( pCur ); + pSize = pCur.info.nData; + return SQLITE_OK; +} - /* - ** Given the page number of an overflow page in the database (parameter - ** ovfl), this function finds the page number of the next page in the - ** linked list of overflow pages. If possible, it uses the auto-vacuum - ** pointer-map data instead of reading the content of page ovfl to do so. - ** - ** If an error occurs an SQLite error code is returned. Otherwise: - ** - ** The page number of the next overflow page in the linked list is - ** written to pPgnoNext. If page ovfl is the last page in its linked - ** list, pPgnoNext is set to zero. - ** - ** If ppPage is not NULL, and a reference to the MemPage object corresponding - ** to page number pOvfl was obtained, then ppPage is set to point to that - ** reference. It is the responsibility of the caller to call releasePage() - ** on ppPage to free the reference. In no reference was obtained (because - ** the pointer-map was used to obtain the value for pPgnoNext), then - ** ppPage is set to zero. - */ - static int getOverflowPage( - BtShared pBt, /* The database file */ - Pgno ovfl, /* Current overflow page number */ - out MemPage ppPage, /* OUT: MemPage handle (may be NULL) */ - out Pgno pPgnoNext /* OUT: Next overflow page number */ - ) { - Pgno next = 0; - MemPage pPage = null; - ppPage = null; - int rc = SQLITE_OK; - - Debug.Assert(sqlite3_mutex_held(pBt.mutex)); - // Debug.Assert( pPgnoNext); +/* +** Given the page number of an overflow page in the database (parameter +** ovfl), this function finds the page number of the next page in the +** linked list of overflow pages. If possible, it uses the auto-vacuum +** pointer-map data instead of reading the content of page ovfl to do so. +** +** If an error occurs an SQLite error code is returned. Otherwise: +** +** The page number of the next overflow page in the linked list is +** written to pPgnoNext. If page ovfl is the last page in its linked +** list, pPgnoNext is set to zero. +** +** If ppPage is not NULL, and a reference to the MemPage object corresponding +** to page number pOvfl was obtained, then ppPage is set to point to that +** reference. It is the responsibility of the caller to call releasePage() +** on ppPage to free the reference. In no reference was obtained (because +** the pointer-map was used to obtain the value for pPgnoNext), then +** ppPage is set to zero. +*/ +static int getOverflowPage( +BtShared pBt, /* The database file */ +Pgno ovfl, /* Current overflow page number */ +out MemPage ppPage, /* OUT: MemPage handle (may be NULL) */ +out Pgno pPgnoNext /* OUT: Next overflow page number */ +) +{ + Pgno next = 0; + MemPage pPage = null; + ppPage = null; + int rc = SQLITE_OK; + + Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); + // Debug.Assert( pPgnoNext); #if !SQLITE_OMIT_AUTOVACUUM - /* Try to find the next page in the overflow list using the - ** autovacuum pointer-map pages. Guess that the next page in - ** the overflow list is page number (ovfl+1). If that guess turns - ** out to be wrong, fall back to loading the data of page - ** number ovfl to determine the next page number. - */ - if (pBt.autoVacuum) { - Pgno pgno = 0; - Pgno iGuess = ovfl + 1; - u8 eType = 0; - - while (PTRMAP_ISPAGE(pBt, iGuess) || iGuess == PENDING_BYTE_PAGE(pBt)) { - iGuess++; - } - - if (iGuess <= btreePagecount(pBt)) { - rc = ptrmapGet(pBt, iGuess, ref eType, ref pgno); - if (rc == SQLITE_OK && eType == PTRMAP_OVERFLOW2 && pgno == ovfl) { - next = iGuess; - rc = SQLITE_DONE; - } - } - } -#endif + /* Try to find the next page in the overflow list using the +** autovacuum pointer-map pages. Guess that the next page in +** the overflow list is page number (ovfl+1). If that guess turns +** out to be wrong, fall back to loading the data of page +** number ovfl to determine the next page number. +*/ + if ( pBt.autoVacuum ) + { + Pgno pgno = 0; + Pgno iGuess = ovfl + 1; + u8 eType = 0; - Debug.Assert(next == 0 || rc == SQLITE_DONE); - if (rc == SQLITE_OK) { - rc = btreeGetPage(pBt, ovfl, ref pPage, 0); - Debug.Assert(rc == SQLITE_OK || pPage == null); - if (rc == SQLITE_OK) { - next = sqlite3Get4byte(pPage.aData); - } - } + while ( PTRMAP_ISPAGE( pBt, iGuess ) || iGuess == PENDING_BYTE_PAGE( pBt ) ) + { + iGuess++; + } - pPgnoNext = next; - if (ppPage != null) { - ppPage = pPage; - } else { - releasePage(pPage); - } - return (rc == SQLITE_DONE ? SQLITE_OK : rc); - } + if ( iGuess <= btreePagecount( pBt ) ) + { + rc = ptrmapGet( pBt, iGuess, ref eType, ref pgno ); + if ( rc == SQLITE_OK && eType == PTRMAP_OVERFLOW2 && pgno == ovfl ) + { + next = iGuess; + rc = SQLITE_DONE; + } + } + } +#endif - /* - ** Copy data from a buffer to a page, or from a page to a buffer. - ** - ** pPayload is a pointer to data stored on database page pDbPage. - ** If argument eOp is false, then nByte bytes of data are copied - ** from pPayload to the buffer pointed at by pBuf. If eOp is true, - ** then sqlite3PagerWrite() is called on pDbPage and nByte bytes - ** of data are copied from the buffer pBuf to pPayload. - ** - ** SQLITE_OK is returned on success, otherwise an error code. - */ - static int copyPayload( - byte[] pPayload, /* Pointer to page data */ - u32 payloadOffset, /* Offset into page data */ - byte[] pBuf, /* Pointer to buffer */ - u32 pBufOffset, /* Offset into buffer */ - u32 nByte, /* Number of bytes to copy */ - int eOp, /* 0 . copy from page, 1 . copy to page */ - DbPage pDbPage /* Page containing pPayload */ - ) { - if (eOp != 0) { - /* Copy data from buffer to page (a write operation) */ - int rc = sqlite3PagerWrite(pDbPage); - if (rc != SQLITE_OK) { - return rc; - } - Buffer.BlockCopy(pBuf, (int)pBufOffset, pPayload, (int)payloadOffset, (int)nByte);// memcpy( pPayload, pBuf, nByte ); - } else { - /* Copy data from page to buffer (a read operation) */ - Buffer.BlockCopy(pPayload, (int)payloadOffset, pBuf, (int)pBufOffset, (int)nByte);//memcpy(pBuf, pPayload, nByte); - } - return SQLITE_OK; - } - //static int copyPayload( - // byte[] pPayload, /* Pointer to page data */ - // byte[] pBuf, /* Pointer to buffer */ - // int nByte, /* Number of bytes to copy */ - // int eOp, /* 0 -> copy from page, 1 -> copy to page */ - // DbPage pDbPage /* Page containing pPayload */ - //){ - // if( eOp!=0 ){ - // /* Copy data from buffer to page (a write operation) */ - // int rc = sqlite3PagerWrite(pDbPage); - // if( rc!=SQLITE_OK ){ - // return rc; - // } - // memcpy(pPayload, pBuf, nByte); - // }else{ - // /* Copy data from page to buffer (a read operation) */ - // memcpy(pBuf, pPayload, nByte); - // } - // return SQLITE_OK; - //} - - /* - ** This function is used to read or overwrite payload information - ** for the entry that the pCur cursor is pointing to. If the eOp - ** parameter is 0, this is a read operation (data copied into - ** buffer pBuf). If it is non-zero, a write (data copied from - ** buffer pBuf). - ** - ** A total of "amt" bytes are read or written beginning at "offset". - ** Data is read to or from the buffer pBuf. - ** - ** The content being read or written might appear on the main page - ** or be scattered out on multiple overflow pages. - ** - ** If the BtCursor.isIncrblobHandle flag is set, and the current - ** cursor entry uses one or more overflow pages, this function - ** allocates space for and lazily popluates the overflow page-list - ** cache array (BtCursor.aOverflow). Subsequent calls use this - ** cache to make seeking to the supplied offset more efficient. - ** - ** Once an overflow page-list cache has been allocated, it may be - ** invalidated if some other cursor writes to the same table, or if - ** the cursor is moved to a different row. Additionally, in auto-vacuum - ** mode, the following events may invalidate an overflow page-list cache. - ** - ** * An incremental vacuum, - ** * A commit in auto_vacuum="full" mode, - ** * Creating a table (may require moving an overflow page). - */ - static int accessPayload( - BtCursor pCur, /* Cursor pointing to entry to read from */ - u32 offset, /* Begin reading this far into payload */ - u32 amt, /* Read this many bytes */ - byte[] pBuf, /* Write the bytes into this buffer */ - int eOp /* zero to read. non-zero to write. */ - ) { - u32 pBufOffset = 0; - byte[] aPayload; - int rc = SQLITE_OK; - u32 nKey; - int iIdx = 0; - MemPage pPage = pCur.apPage[pCur.iPage]; /* Btree page of current entry */ - BtShared pBt = pCur.pBt; /* Btree this cursor belongs to */ - - Debug.Assert(pPage != null); - Debug.Assert(pCur.eState == CURSOR_VALID); - Debug.Assert(pCur.aiIdx[pCur.iPage] < pPage.nCell); - Debug.Assert(cursorHoldsMutex(pCur)); - - getCellInfo(pCur); - aPayload = pCur.info.pCell; //pCur.info.pCell + pCur.info.nHeader; - nKey = (u32)(pPage.intKey != 0 ? 0 : (int)pCur.info.nKey); - - if (NEVER(offset + amt > nKey + pCur.info.nData) - || pCur.info.nLocal > pBt.usableSize//&aPayload[pCur.info.nLocal] > &pPage.aData[pBt.usableSize] - ) { - /* Trying to read or write past the end of the data is an error */ - return SQLITE_CORRUPT_BKPT(); - } - - /* Check if data must be read/written to/from the btree page itself. */ - if (offset < pCur.info.nLocal) { - int a = (int)amt; - if (a + offset > pCur.info.nLocal) { - a = (int)(pCur.info.nLocal - offset); - } - rc = copyPayload(aPayload, (u32)(offset + pCur.info.iCell + pCur.info.nHeader), pBuf, pBufOffset, (u32)a, eOp, pPage.pDbPage); - offset = 0; - pBufOffset += (u32)a; //pBuf += a; - amt -= (u32)a; - } else { - offset -= pCur.info.nLocal; - } + Debug.Assert( next == 0 || rc == SQLITE_DONE ); + if ( rc == SQLITE_OK ) + { + rc = btreeGetPage( pBt, ovfl, ref pPage, 0 ); + Debug.Assert( rc == SQLITE_OK || pPage == null ); + if ( rc == SQLITE_OK ) + { + next = sqlite3Get4byte( pPage.aData ); + } + } + + pPgnoNext = next; + if ( ppPage != null ) + { + ppPage = pPage; + } + else + { + releasePage( pPage ); + } + return ( rc == SQLITE_DONE ? SQLITE_OK : rc ); +} - if (rc == SQLITE_OK && amt > 0) { - u32 ovflSize = (u32)(pBt.usableSize - 4); /* Bytes content per ovfl page */ - Pgno nextPage; +/* +** Copy data from a buffer to a page, or from a page to a buffer. +** +** pPayload is a pointer to data stored on database page pDbPage. +** If argument eOp is false, then nByte bytes of data are copied +** from pPayload to the buffer pointed at by pBuf. If eOp is true, +** then sqlite3PagerWrite() is called on pDbPage and nByte bytes +** of data are copied from the buffer pBuf to pPayload. +** +** SQLITE_OK is returned on success, otherwise an error code. +*/ +static int copyPayload( +byte[] pPayload, /* Pointer to page data */ +u32 payloadOffset, /* Offset into page data */ +byte[] pBuf, /* Pointer to buffer */ +u32 pBufOffset, /* Offset into buffer */ +u32 nByte, /* Number of bytes to copy */ +int eOp, /* 0 . copy from page, 1 . copy to page */ +DbPage pDbPage /* Page containing pPayload */ +) +{ + if ( eOp != 0 ) + { + /* Copy data from buffer to page (a write operation) */ + int rc = sqlite3PagerWrite( pDbPage ); + if ( rc != SQLITE_OK ) + { + return rc; + } + Buffer.BlockCopy( pBuf, (int)pBufOffset, pPayload, (int)payloadOffset, (int)nByte );// memcpy( pPayload, pBuf, nByte ); + } + else + { + /* Copy data from page to buffer (a read operation) */ + Buffer.BlockCopy( pPayload, (int)payloadOffset, pBuf, (int)pBufOffset, (int)nByte );//memcpy(pBuf, pPayload, nByte); + } + return SQLITE_OK; +} +//static int copyPayload( +// byte[] pPayload, /* Pointer to page data */ +// byte[] pBuf, /* Pointer to buffer */ +// int nByte, /* Number of bytes to copy */ +// int eOp, /* 0 -> copy from page, 1 -> copy to page */ +// DbPage pDbPage /* Page containing pPayload */ +//){ +// if( eOp!=0 ){ +// /* Copy data from buffer to page (a write operation) */ +// int rc = sqlite3PagerWrite(pDbPage); +// if( rc!=SQLITE_OK ){ +// return rc; +// } +// memcpy(pPayload, pBuf, nByte); +// }else{ +// /* Copy data from page to buffer (a read operation) */ +// memcpy(pBuf, pPayload, nByte); +// } +// return SQLITE_OK; +//} - nextPage = sqlite3Get4byte(aPayload, pCur.info.nLocal + pCur.info.iCell + pCur.info.nHeader); +/* +** This function is used to read or overwrite payload information +** for the entry that the pCur cursor is pointing to. If the eOp +** parameter is 0, this is a read operation (data copied into +** buffer pBuf). If it is non-zero, a write (data copied from +** buffer pBuf). +** +** A total of "amt" bytes are read or written beginning at "offset". +** Data is read to or from the buffer pBuf. +** +** The content being read or written might appear on the main page +** or be scattered out on multiple overflow pages. +** +** If the BtCursor.isIncrblobHandle flag is set, and the current +** cursor entry uses one or more overflow pages, this function +** allocates space for and lazily popluates the overflow page-list +** cache array (BtCursor.aOverflow). Subsequent calls use this +** cache to make seeking to the supplied offset more efficient. +** +** Once an overflow page-list cache has been allocated, it may be +** invalidated if some other cursor writes to the same table, or if +** the cursor is moved to a different row. Additionally, in auto-vacuum +** mode, the following events may invalidate an overflow page-list cache. +** +** * An incremental vacuum, +** * A commit in auto_vacuum="full" mode, +** * Creating a table (may require moving an overflow page). +*/ +static int accessPayload( +BtCursor pCur, /* Cursor pointing to entry to read from */ +u32 offset, /* Begin reading this far into payload */ +u32 amt, /* Read this many bytes */ +byte[] pBuf, /* Write the bytes into this buffer */ +int eOp /* zero to read. non-zero to write. */ +) +{ + u32 pBufOffset = 0; + byte[] aPayload; + int rc = SQLITE_OK; + u32 nKey; + int iIdx = 0; + MemPage pPage = pCur.apPage[pCur.iPage]; /* Btree page of current entry */ + BtShared pBt = pCur.pBt; /* Btree this cursor belongs to */ + + Debug.Assert( pPage != null ); + Debug.Assert( pCur.eState == CURSOR_VALID ); + Debug.Assert( pCur.aiIdx[pCur.iPage] < pPage.nCell ); + Debug.Assert( cursorHoldsMutex( pCur ) ); + + getCellInfo( pCur ); + aPayload = pCur.info.pCell; //pCur.info.pCell + pCur.info.nHeader; + nKey = (u32)( pPage.intKey != 0 ? 0 : (int)pCur.info.nKey ); + + if ( NEVER( offset + amt > nKey + pCur.info.nData ) + || pCur.info.nLocal > pBt.usableSize//&aPayload[pCur.info.nLocal] > &pPage.aData[pBt.usableSize] + ) + { + /* Trying to read or write past the end of the data is an error */ + return SQLITE_CORRUPT_BKPT(); + } + + /* Check if data must be read/written to/from the btree page itself. */ + if ( offset < pCur.info.nLocal ) + { + int a = (int)amt; + if ( a + offset > pCur.info.nLocal ) + { + a = (int)( pCur.info.nLocal - offset ); + } + rc = copyPayload( aPayload, (u32)( offset + pCur.info.iCell + pCur.info.nHeader ), pBuf, pBufOffset, (u32)a, eOp, pPage.pDbPage ); + offset = 0; + pBufOffset += (u32)a; //pBuf += a; + amt -= (u32)a; + } + else + { + offset -= pCur.info.nLocal; + } + + if ( rc == SQLITE_OK && amt > 0 ) + { + u32 ovflSize = (u32)( pBt.usableSize - 4 ); /* Bytes content per ovfl page */ + Pgno nextPage; + + nextPage = sqlite3Get4byte( aPayload, pCur.info.nLocal + pCur.info.iCell + pCur.info.nHeader ); #if !SQLITE_OMIT_INCRBLOB /* If the isIncrblobHandle flag is set and the BtCursor.aOverflow[] @@ -4120,7 +4492,8 @@ int eOp /* zero to read. non-zero to write. */ } #endif - for (; rc == SQLITE_OK && amt > 0 && nextPage != 0; iIdx++) { + for ( ; rc == SQLITE_OK && amt > 0 && nextPage != 0; iIdx++ ) + { #if !SQLITE_OMIT_INCRBLOB /* If required, populate the overflow page-list cache. */ @@ -4130,81 +4503,89 @@ int eOp /* zero to read. non-zero to write. */ } #endif - MemPage MemPageDummy = null; - if (offset >= ovflSize) { - /* The only reason to read this page is to obtain the page - ** number for the next page in the overflow chain. The page - ** data is not required. So first try to lookup the overflow - ** page-list cache, if any, then fall back to the getOverflowPage() - ** function. - */ + MemPage MemPageDummy = null; + if ( offset >= ovflSize ) + { + /* The only reason to read this page is to obtain the page + ** number for the next page in the overflow chain. The page + ** data is not required. So first try to lookup the overflow + ** page-list cache, if any, then fall back to the getOverflowPage() + ** function. + */ #if !SQLITE_OMIT_INCRBLOB if( pCur.aOverflow && pCur.aOverflow[iIdx+1] ){ nextPage = pCur.aOverflow[iIdx+1]; } else #endif - rc = getOverflowPage(pBt, nextPage, out MemPageDummy, out nextPage); - offset -= ovflSize; - } else { - /* Need to read this page properly. It contains some of the - ** range of data that is being read (eOp==null) or written (eOp!=null). - */ - PgHdr pDbPage = new PgHdr(); - int a = (int)amt; - rc = sqlite3PagerGet(pBt.pPager, nextPage, ref pDbPage); - if (rc == SQLITE_OK) { - aPayload = sqlite3PagerGetData(pDbPage); - nextPage = sqlite3Get4byte(aPayload); - if (a + offset > ovflSize) { - a = (int)(ovflSize - offset); - } - rc = copyPayload(aPayload, offset + 4, pBuf, pBufOffset, (u32)a, eOp, pDbPage); - sqlite3PagerUnref(pDbPage); - offset = 0; - amt -= (u32)a; - pBufOffset += (u32)a;//pBuf += a; - } - } - } - } + rc = getOverflowPage( pBt, nextPage, out MemPageDummy, out nextPage ); + offset -= ovflSize; + } + else + { + /* Need to read this page properly. It contains some of the + ** range of data that is being read (eOp==null) or written (eOp!=null). + */ + PgHdr pDbPage = new PgHdr(); + int a = (int)amt; + rc = sqlite3PagerGet( pBt.pPager, nextPage, ref pDbPage ); + if ( rc == SQLITE_OK ) + { + aPayload = sqlite3PagerGetData( pDbPage ); + nextPage = sqlite3Get4byte( aPayload ); + if ( a + offset > ovflSize ) + { + a = (int)( ovflSize - offset ); + } + rc = copyPayload( aPayload, offset + 4, pBuf, pBufOffset, (u32)a, eOp, pDbPage ); + sqlite3PagerUnref( pDbPage ); + offset = 0; + amt -= (u32)a; + pBufOffset += (u32)a;//pBuf += a; + } + } + } + } - if (rc == SQLITE_OK && amt > 0) { - return SQLITE_CORRUPT_BKPT(); - } - return rc; - } + if ( rc == SQLITE_OK && amt > 0 ) + { + return SQLITE_CORRUPT_BKPT(); + } + return rc; +} - /* - ** Read part of the key associated with cursor pCur. Exactly - ** "amt" bytes will be transfered into pBuf[]. The transfer - ** begins at "offset". - ** - ** The caller must ensure that pCur is pointing to a valid row - ** in the table. - ** - ** Return SQLITE_OK on success or an error code if anything goes - ** wrong. An error is returned if "offset+amt" is larger than - ** the available payload. - */ - static int sqlite3BtreeKey(BtCursor pCur, u32 offset, u32 amt, byte[] pBuf) { - Debug.Assert(cursorHoldsMutex(pCur)); - Debug.Assert(pCur.eState == CURSOR_VALID); - Debug.Assert(pCur.iPage >= 0 && pCur.apPage[pCur.iPage] != null); - Debug.Assert(pCur.aiIdx[pCur.iPage] < pCur.apPage[pCur.iPage].nCell); - return accessPayload(pCur, offset, amt, pBuf, 0); - } +/* +** Read part of the key associated with cursor pCur. Exactly +** "amt" bytes will be transfered into pBuf[]. The transfer +** begins at "offset". +** +** The caller must ensure that pCur is pointing to a valid row +** in the table. +** +** Return SQLITE_OK on success or an error code if anything goes +** wrong. An error is returned if "offset+amt" is larger than +** the available payload. +*/ +static int sqlite3BtreeKey( BtCursor pCur, u32 offset, u32 amt, byte[] pBuf ) +{ + Debug.Assert( cursorHoldsMutex( pCur ) ); + Debug.Assert( pCur.eState == CURSOR_VALID ); + Debug.Assert( pCur.iPage >= 0 && pCur.apPage[pCur.iPage] != null ); + Debug.Assert( pCur.aiIdx[pCur.iPage] < pCur.apPage[pCur.iPage].nCell ); + return accessPayload( pCur, offset, amt, pBuf, 0 ); +} - /* - ** Read part of the data associated with cursor pCur. Exactly - ** "amt" bytes will be transfered into pBuf[]. The transfer - ** begins at "offset". - ** - ** Return SQLITE_OK on success or an error code if anything goes - ** wrong. An error is returned if "offset+amt" is larger than - ** the available payload. - */ - static int sqlite3BtreeData(BtCursor pCur, u32 offset, u32 amt, byte[] pBuf) { - int rc; +/* +** Read part of the data associated with cursor pCur. Exactly +** "amt" bytes will be transfered into pBuf[]. The transfer +** begins at "offset". +** +** Return SQLITE_OK on success or an error code if anything goes +** wrong. An error is returned if "offset+amt" is larger than +** the available payload. +*/ +static int sqlite3BtreeData( BtCursor pCur, u32 offset, u32 amt, byte[] pBuf ) +{ + int rc; #if !SQLITE_OMIT_INCRBLOB if ( pCur.eState==CURSOR_INVALID ){ @@ -4212,1861 +4593,2100 @@ static int sqlite3BtreeData(BtCursor pCur, u32 offset, u32 amt, byte[] pBuf) { } #endif - Debug.Assert(cursorHoldsMutex(pCur)); - rc = restoreCursorPosition(pCur); - if (rc == SQLITE_OK) { - Debug.Assert(pCur.eState == CURSOR_VALID); - Debug.Assert(pCur.iPage >= 0 && pCur.apPage[pCur.iPage] != null); - Debug.Assert(pCur.aiIdx[pCur.iPage] < pCur.apPage[pCur.iPage].nCell); - rc = accessPayload(pCur, offset, amt, pBuf, 0); - } - return rc; - } + Debug.Assert( cursorHoldsMutex( pCur ) ); + rc = restoreCursorPosition( pCur ); + if ( rc == SQLITE_OK ) + { + Debug.Assert( pCur.eState == CURSOR_VALID ); + Debug.Assert( pCur.iPage >= 0 && pCur.apPage[pCur.iPage] != null ); + Debug.Assert( pCur.aiIdx[pCur.iPage] < pCur.apPage[pCur.iPage].nCell ); + rc = accessPayload( pCur, offset, amt, pBuf, 0 ); + } + return rc; +} - /* - ** Return a pointer to payload information from the entry that the - ** pCur cursor is pointing to. The pointer is to the beginning of - ** the key if skipKey==null and it points to the beginning of data if - ** skipKey==1. The number of bytes of available key/data is written - ** into pAmt. If pAmt==null, then the value returned will not be - ** a valid pointer. - ** - ** This routine is an optimization. It is common for the entire key - ** and data to fit on the local page and for there to be no overflow - ** pages. When that is so, this routine can be used to access the - ** key and data without making a copy. If the key and/or data spills - ** onto overflow pages, then accessPayload() must be used to reassemble - ** the key/data and copy it into a preallocated buffer. - ** - ** The pointer returned by this routine looks directly into the cached - ** page of the database. The data might change or move the next time - ** any btree routine is called. - */ - static byte[] fetchPayload( - BtCursor pCur, /* Cursor pointing to entry to read from */ - ref int pAmt, /* Write the number of available bytes here */ - ref int outOffset, /* Offset into Buffer */ - bool skipKey /* read beginning at data if this is true */ - ) { - byte[] aPayload; - MemPage pPage; - u32 nKey; - u32 nLocal; - - Debug.Assert(pCur != null && pCur.iPage >= 0 && pCur.apPage[pCur.iPage] != null); - Debug.Assert(pCur.eState == CURSOR_VALID); - Debug.Assert(cursorHoldsMutex(pCur)); - outOffset = -1; - pPage = pCur.apPage[pCur.iPage]; - Debug.Assert(pCur.aiIdx[pCur.iPage] < pPage.nCell); - if (NEVER(pCur.info.nSize == 0)) { - btreeParseCell(pCur.apPage[pCur.iPage], pCur.aiIdx[pCur.iPage], - ref pCur.info); - } - //aPayload = pCur.info.pCell; - //aPayload += pCur.info.nHeader; - aPayload = sqlite3Malloc(pCur.info.nSize - pCur.info.nHeader); - if (pPage.intKey != 0) { - nKey = 0; - } else { - nKey = (u32)pCur.info.nKey; - } - if (skipKey) { - //aPayload += nKey; - outOffset = (int)(pCur.info.iCell + pCur.info.nHeader + nKey); - Buffer.BlockCopy(pCur.info.pCell, outOffset, aPayload, 0, (int)(pCur.info.nSize - pCur.info.nHeader - nKey)); - nLocal = pCur.info.nLocal - nKey; - } else { - outOffset = (int)(pCur.info.iCell + pCur.info.nHeader); - Buffer.BlockCopy(pCur.info.pCell, outOffset, aPayload, 0, pCur.info.nSize - pCur.info.nHeader); - nLocal = pCur.info.nLocal; - Debug.Assert(nLocal <= nKey); - } - pAmt = (int)nLocal; - return aPayload; - } +/* +** Return a pointer to payload information from the entry that the +** pCur cursor is pointing to. The pointer is to the beginning of +** the key if skipKey==null and it points to the beginning of data if +** skipKey==1. The number of bytes of available key/data is written +** into pAmt. If pAmt==null, then the value returned will not be +** a valid pointer. +** +** This routine is an optimization. It is common for the entire key +** and data to fit on the local page and for there to be no overflow +** pages. When that is so, this routine can be used to access the +** key and data without making a copy. If the key and/or data spills +** onto overflow pages, then accessPayload() must be used to reassemble +** the key/data and copy it into a preallocated buffer. +** +** The pointer returned by this routine looks directly into the cached +** page of the database. The data might change or move the next time +** any btree routine is called. +*/ +static byte[] fetchPayload( +BtCursor pCur, /* Cursor pointing to entry to read from */ +ref int pAmt, /* Write the number of available bytes here */ +ref int outOffset, /* Offset into Buffer */ +bool skipKey /* read beginning at data if this is true */ +) +{ + byte[] aPayload; + MemPage pPage; + u32 nKey; + u32 nLocal; + + Debug.Assert( pCur != null && pCur.iPage >= 0 && pCur.apPage[pCur.iPage] != null ); + Debug.Assert( pCur.eState == CURSOR_VALID ); + Debug.Assert( cursorHoldsMutex( pCur ) ); + outOffset = -1; + pPage = pCur.apPage[pCur.iPage]; + Debug.Assert( pCur.aiIdx[pCur.iPage] < pPage.nCell ); + if ( NEVER( pCur.info.nSize == 0 ) ) + { + btreeParseCell( pCur.apPage[pCur.iPage], pCur.aiIdx[pCur.iPage], + ref pCur.info ); + } + //aPayload = pCur.info.pCell; + //aPayload += pCur.info.nHeader; + aPayload = sqlite3Malloc( pCur.info.nSize - pCur.info.nHeader ); + if ( pPage.intKey != 0 ) + { + nKey = 0; + } + else + { + nKey = (u32)pCur.info.nKey; + } + if ( skipKey ) + { + //aPayload += nKey; + outOffset = (int)( pCur.info.iCell + pCur.info.nHeader + nKey ); + Buffer.BlockCopy( pCur.info.pCell, outOffset, aPayload, 0, (int)( pCur.info.nSize - pCur.info.nHeader - nKey ) ); + nLocal = pCur.info.nLocal - nKey; + } + else + { + outOffset = (int)( pCur.info.iCell + pCur.info.nHeader ); + Buffer.BlockCopy( pCur.info.pCell, outOffset, aPayload, 0, pCur.info.nSize - pCur.info.nHeader ); + nLocal = pCur.info.nLocal; + Debug.Assert( nLocal <= nKey ); + } + pAmt = (int)nLocal; + return aPayload; +} - /* - ** For the entry that cursor pCur is point to, return as - ** many bytes of the key or data as are available on the local - ** b-tree page. Write the number of available bytes into pAmt. - ** - ** The pointer returned is ephemeral. The key/data may move - ** or be destroyed on the next call to any Btree routine, - ** including calls from other threads against the same cache. - ** Hence, a mutex on the BtShared should be held prior to calling - ** this routine. - ** - ** These routines is used to get quick access to key and data - ** in the common case where no overflow pages are used. - */ - static byte[] sqlite3BtreeKeyFetch(BtCursor pCur, ref int pAmt, ref int outOffset) { - byte[] p = null; - Debug.Assert(sqlite3_mutex_held(pCur.pBtree.db.mutex)); - Debug.Assert(cursorHoldsMutex(pCur)); - if (ALWAYS(pCur.eState == CURSOR_VALID)) { - p = fetchPayload(pCur, ref pAmt, ref outOffset, false); - } - return p; - } - static byte[] sqlite3BtreeDataFetch(BtCursor pCur, ref int pAmt, ref int outOffset) { - byte[] p = null; - Debug.Assert(sqlite3_mutex_held(pCur.pBtree.db.mutex)); - Debug.Assert(cursorHoldsMutex(pCur)); - if (ALWAYS(pCur.eState == CURSOR_VALID)) { - p = fetchPayload(pCur, ref pAmt, ref outOffset, true); - } - return p; - } +/* +** For the entry that cursor pCur is point to, return as +** many bytes of the key or data as are available on the local +** b-tree page. Write the number of available bytes into pAmt. +** +** The pointer returned is ephemeral. The key/data may move +** or be destroyed on the next call to any Btree routine, +** including calls from other threads against the same cache. +** Hence, a mutex on the BtShared should be held prior to calling +** this routine. +** +** These routines is used to get quick access to key and data +** in the common case where no overflow pages are used. +*/ +static byte[] sqlite3BtreeKeyFetch( BtCursor pCur, ref int pAmt, ref int outOffset ) +{ + byte[] p = null; + Debug.Assert( sqlite3_mutex_held( pCur.pBtree.db.mutex ) ); + Debug.Assert( cursorHoldsMutex( pCur ) ); + if ( ALWAYS( pCur.eState == CURSOR_VALID ) ) + { + p = fetchPayload( pCur, ref pAmt, ref outOffset, false ); + } + return p; +} +static byte[] sqlite3BtreeDataFetch( BtCursor pCur, ref int pAmt, ref int outOffset ) +{ + byte[] p = null; + Debug.Assert( sqlite3_mutex_held( pCur.pBtree.db.mutex ) ); + Debug.Assert( cursorHoldsMutex( pCur ) ); + if ( ALWAYS( pCur.eState == CURSOR_VALID ) ) + { + p = fetchPayload( pCur, ref pAmt, ref outOffset, true ); + } + return p; +} - /* - ** Move the cursor down to a new child page. The newPgno argument is the - ** page number of the child page to move to. - ** - ** This function returns SQLITE_CORRUPT if the page-header flags field of - ** the new child page does not match the flags field of the parent (i.e. - ** if an intkey page appears to be the parent of a non-intkey page, or - ** vice-versa). - */ - static int moveToChild(BtCursor pCur, u32 newPgno) { - int rc; - int i = pCur.iPage; - MemPage pNewPage = new MemPage(); - BtShared pBt = pCur.pBt; - - Debug.Assert(cursorHoldsMutex(pCur)); - Debug.Assert(pCur.eState == CURSOR_VALID); - Debug.Assert(pCur.iPage < BTCURSOR_MAX_DEPTH); - if (pCur.iPage >= (BTCURSOR_MAX_DEPTH - 1)) { - return SQLITE_CORRUPT_BKPT(); - } - rc = getAndInitPage(pBt, newPgno, ref pNewPage); - if (rc != 0) - return rc; - pCur.apPage[i + 1] = pNewPage; - pCur.aiIdx[i + 1] = 0; - pCur.iPage++; - - pCur.info.nSize = 0; - pCur.validNKey = false; - if (pNewPage.nCell < 1 || pNewPage.intKey != pCur.apPage[i].intKey) { - return SQLITE_CORRUPT_BKPT(); - } - return SQLITE_OK; - } +/* +** Move the cursor down to a new child page. The newPgno argument is the +** page number of the child page to move to. +** +** This function returns SQLITE_CORRUPT if the page-header flags field of +** the new child page does not match the flags field of the parent (i.e. +** if an intkey page appears to be the parent of a non-intkey page, or +** vice-versa). +*/ +static int moveToChild( BtCursor pCur, u32 newPgno ) +{ + int rc; + int i = pCur.iPage; + MemPage pNewPage = new MemPage(); + BtShared pBt = pCur.pBt; + + Debug.Assert( cursorHoldsMutex( pCur ) ); + Debug.Assert( pCur.eState == CURSOR_VALID ); + Debug.Assert( pCur.iPage < BTCURSOR_MAX_DEPTH ); + if ( pCur.iPage >= ( BTCURSOR_MAX_DEPTH - 1 ) ) + { + return SQLITE_CORRUPT_BKPT(); + } + rc = getAndInitPage( pBt, newPgno, ref pNewPage ); + if ( rc != 0 ) + return rc; + pCur.apPage[i + 1] = pNewPage; + pCur.aiIdx[i + 1] = 0; + pCur.iPage++; + + pCur.info.nSize = 0; + pCur.validNKey = false; + if ( pNewPage.nCell < 1 || pNewPage.intKey != pCur.apPage[i].intKey ) + { + return SQLITE_CORRUPT_BKPT(); + } + return SQLITE_OK; +} #if !NDEBUG - /* - ** Page pParent is an internal (non-leaf) tree page. This function - ** asserts that page number iChild is the left-child if the iIdx'th - ** cell in page pParent. Or, if iIdx is equal to the total number of - ** cells in pParent, that page number iChild is the right-child of - ** the page. - */ - static void assertParentIndex(MemPage pParent, int iIdx, Pgno iChild) { - Debug.Assert(iIdx <= pParent.nCell); - if (iIdx == pParent.nCell) { - Debug.Assert(sqlite3Get4byte(pParent.aData, pParent.hdrOffset + 8) == iChild); - } else { - Debug.Assert(sqlite3Get4byte(pParent.aData, findCell(pParent, iIdx)) == iChild); - } - } +/* +** Page pParent is an internal (non-leaf) tree page. This function +** asserts that page number iChild is the left-child if the iIdx'th +** cell in page pParent. Or, if iIdx is equal to the total number of +** cells in pParent, that page number iChild is the right-child of +** the page. +*/ +static void assertParentIndex( MemPage pParent, int iIdx, Pgno iChild ) +{ + Debug.Assert( iIdx <= pParent.nCell ); + if ( iIdx == pParent.nCell ) + { + Debug.Assert( sqlite3Get4byte( pParent.aData, pParent.hdrOffset + 8 ) == iChild ); + } + else + { + Debug.Assert( sqlite3Get4byte( pParent.aData, findCell( pParent, iIdx ) ) == iChild ); + } +} #else //# define assertParentIndex(x,y,z) static void assertParentIndex(MemPage pParent, int iIdx, Pgno iChild) { } #endif - /* - ** Move the cursor up to the parent page. - ** - ** pCur.idx is set to the cell index that contains the pointer - ** to the page we are coming from. If we are coming from the - ** right-most child page then pCur.idx is set to one more than - ** the largest cell index. - */ - static void moveToParent(BtCursor pCur) { - Debug.Assert(cursorHoldsMutex(pCur)); - Debug.Assert(pCur.eState == CURSOR_VALID); - Debug.Assert(pCur.iPage > 0); - Debug.Assert(pCur.apPage[pCur.iPage] != null); - assertParentIndex( - pCur.apPage[pCur.iPage - 1], - pCur.aiIdx[pCur.iPage - 1], - pCur.apPage[pCur.iPage].pgno - ); - releasePage(pCur.apPage[pCur.iPage]); - pCur.iPage--; - pCur.info.nSize = 0; - pCur.validNKey = false; - } - - /* - ** Move the cursor to point to the root page of its b-tree structure. - ** - ** If the table has a virtual root page, then the cursor is moved to point - ** to the virtual root page instead of the actual root page. A table has a - ** virtual root page when the actual root page contains no cells and a - ** single child page. This can only happen with the table rooted at page 1. - ** - ** If the b-tree structure is empty, the cursor state is set to - ** CURSOR_INVALID. Otherwise, the cursor is set to point to the first - ** cell located on the root (or virtual root) page and the cursor state - ** is set to CURSOR_VALID. - ** - ** If this function returns successfully, it may be assumed that the - ** page-header flags indicate that the [virtual] root-page is the expected - ** kind of b-tree page (i.e. if when opening the cursor the caller did not - ** specify a KeyInfo structure the flags byte is set to 0x05 or 0x0D, - ** indicating a table b-tree, or if the caller did specify a KeyInfo - ** structure the flags byte is set to 0x02 or 0x0A, indicating an index - ** b-tree). - */ - static int moveToRoot(BtCursor pCur) { - MemPage pRoot; - int rc = SQLITE_OK; - Btree p = pCur.pBtree; - BtShared pBt = p.pBt; - - Debug.Assert(cursorHoldsMutex(pCur)); - Debug.Assert(CURSOR_INVALID < CURSOR_REQUIRESEEK); - Debug.Assert(CURSOR_VALID < CURSOR_REQUIRESEEK); - Debug.Assert(CURSOR_FAULT > CURSOR_REQUIRESEEK); - if (pCur.eState >= CURSOR_REQUIRESEEK) { - if (pCur.eState == CURSOR_FAULT) { - Debug.Assert(pCur.skipNext != SQLITE_OK); - return pCur.skipNext; - } - sqlite3BtreeClearCursor(pCur); - } +/* +** Move the cursor up to the parent page. +** +** pCur.idx is set to the cell index that contains the pointer +** to the page we are coming from. If we are coming from the +** right-most child page then pCur.idx is set to one more than +** the largest cell index. +*/ +static void moveToParent( BtCursor pCur ) +{ + Debug.Assert( cursorHoldsMutex( pCur ) ); + Debug.Assert( pCur.eState == CURSOR_VALID ); + Debug.Assert( pCur.iPage > 0 ); + Debug.Assert( pCur.apPage[pCur.iPage] != null ); + assertParentIndex( + pCur.apPage[pCur.iPage - 1], + pCur.aiIdx[pCur.iPage - 1], + pCur.apPage[pCur.iPage].pgno + ); + releasePage( pCur.apPage[pCur.iPage] ); + pCur.iPage--; + pCur.info.nSize = 0; + pCur.validNKey = false; +} - if (pCur.iPage >= 0) { - int i; - for (i = 1; i <= pCur.iPage; i++) { - releasePage(pCur.apPage[i]); - } - pCur.iPage = 0; - } else { - rc = getAndInitPage(pBt, pCur.pgnoRoot, ref pCur.apPage[0]); - if (rc != SQLITE_OK) { - pCur.eState = CURSOR_INVALID; - return rc; - } - pCur.iPage = 0; - - /* If pCur.pKeyInfo is not NULL, then the caller that opened this cursor - ** expected to open it on an index b-tree. Otherwise, if pKeyInfo is - ** NULL, the caller expects a table b-tree. If this is not the case, - ** return an SQLITE_CORRUPT error. */ - Debug.Assert(pCur.apPage[0].intKey == 1 || pCur.apPage[0].intKey == 0); - if ((pCur.pKeyInfo == null) != (pCur.apPage[0].intKey != 0)) { - return SQLITE_CORRUPT_BKPT(); - } - } +/* +** Move the cursor to point to the root page of its b-tree structure. +** +** If the table has a virtual root page, then the cursor is moved to point +** to the virtual root page instead of the actual root page. A table has a +** virtual root page when the actual root page contains no cells and a +** single child page. This can only happen with the table rooted at page 1. +** +** If the b-tree structure is empty, the cursor state is set to +** CURSOR_INVALID. Otherwise, the cursor is set to point to the first +** cell located on the root (or virtual root) page and the cursor state +** is set to CURSOR_VALID. +** +** If this function returns successfully, it may be assumed that the +** page-header flags indicate that the [virtual] root-page is the expected +** kind of b-tree page (i.e. if when opening the cursor the caller did not +** specify a KeyInfo structure the flags byte is set to 0x05 or 0x0D, +** indicating a table b-tree, or if the caller did specify a KeyInfo +** structure the flags byte is set to 0x02 or 0x0A, indicating an index +** b-tree). +*/ +static int moveToRoot( BtCursor pCur ) +{ + MemPage pRoot; + int rc = SQLITE_OK; + Btree p = pCur.pBtree; + BtShared pBt = p.pBt; + + Debug.Assert( cursorHoldsMutex( pCur ) ); + Debug.Assert( CURSOR_INVALID < CURSOR_REQUIRESEEK ); + Debug.Assert( CURSOR_VALID < CURSOR_REQUIRESEEK ); + Debug.Assert( CURSOR_FAULT > CURSOR_REQUIRESEEK ); + if ( pCur.eState >= CURSOR_REQUIRESEEK ) + { + if ( pCur.eState == CURSOR_FAULT ) + { + Debug.Assert( pCur.skipNext != SQLITE_OK ); + return pCur.skipNext; + } + sqlite3BtreeClearCursor( pCur ); + } - /* Assert that the root page is of the correct type. This must be the - ** case as the call to this function that loaded the root-page (either - ** this call or a previous invocation) would have detected corruption - ** if the assumption were not true, and it is not possible for the flags - ** byte to have been modified while this cursor is holding a reference - ** to the page. */ - pRoot = pCur.apPage[0]; - Debug.Assert(pRoot.pgno == pCur.pgnoRoot); - Debug.Assert(pRoot.isInit != 0 && (pCur.pKeyInfo == null) == (pRoot.intKey != 0)); - - pCur.aiIdx[0] = 0; - pCur.info.nSize = 0; - pCur.atLast = 0; - pCur.validNKey = false; - - if (pRoot.nCell == 0 && 0 == pRoot.leaf) { - Pgno subpage; - if (pRoot.pgno != 1) - return SQLITE_CORRUPT_BKPT(); - subpage = sqlite3Get4byte(pRoot.aData, pRoot.hdrOffset + 8); - pCur.eState = CURSOR_VALID; - rc = moveToChild(pCur, subpage); - } else { - pCur.eState = ((pRoot.nCell > 0) ? CURSOR_VALID : CURSOR_INVALID); - } - return rc; - } + if ( pCur.iPage >= 0 ) + { + int i; + for ( i = 1; i <= pCur.iPage; i++ ) + { + releasePage( pCur.apPage[i] ); + } + pCur.iPage = 0; + } + else + { + rc = getAndInitPage( pBt, pCur.pgnoRoot, ref pCur.apPage[0] ); + if ( rc != SQLITE_OK ) + { + pCur.eState = CURSOR_INVALID; + return rc; + } + pCur.iPage = 0; + + /* If pCur.pKeyInfo is not NULL, then the caller that opened this cursor + ** expected to open it on an index b-tree. Otherwise, if pKeyInfo is + ** NULL, the caller expects a table b-tree. If this is not the case, + ** return an SQLITE_CORRUPT error. */ + Debug.Assert( pCur.apPage[0].intKey == 1 || pCur.apPage[0].intKey == 0 ); + if ( ( pCur.pKeyInfo == null ) != ( pCur.apPage[0].intKey != 0 ) ) + { + return SQLITE_CORRUPT_BKPT(); + } + } + + /* Assert that the root page is of the correct type. This must be the + ** case as the call to this function that loaded the root-page (either + ** this call or a previous invocation) would have detected corruption + ** if the assumption were not true, and it is not possible for the flags + ** byte to have been modified while this cursor is holding a reference + ** to the page. */ + pRoot = pCur.apPage[0]; + Debug.Assert( pRoot.pgno == pCur.pgnoRoot ); + Debug.Assert( pRoot.isInit != 0 && ( pCur.pKeyInfo == null ) == ( pRoot.intKey != 0 ) ); + + pCur.aiIdx[0] = 0; + pCur.info.nSize = 0; + pCur.atLast = 0; + pCur.validNKey = false; + + if ( pRoot.nCell == 0 && 0 == pRoot.leaf ) + { + Pgno subpage; + if ( pRoot.pgno != 1 ) + return SQLITE_CORRUPT_BKPT(); + subpage = sqlite3Get4byte( pRoot.aData, pRoot.hdrOffset + 8 ); + pCur.eState = CURSOR_VALID; + rc = moveToChild( pCur, subpage ); + } + else + { + pCur.eState = ( ( pRoot.nCell > 0 ) ? CURSOR_VALID : CURSOR_INVALID ); + } + return rc; +} - /* - ** Move the cursor down to the left-most leaf entry beneath the - ** entry to which it is currently pointing. - ** - ** The left-most leaf is the one with the smallest key - the first - ** in ascending order. - */ - static int moveToLeftmost(BtCursor pCur) { - Pgno pgno; - int rc = SQLITE_OK; - MemPage pPage; - - Debug.Assert(cursorHoldsMutex(pCur)); - Debug.Assert(pCur.eState == CURSOR_VALID); - while (rc == SQLITE_OK && 0 == (pPage = pCur.apPage[pCur.iPage]).leaf) { - Debug.Assert(pCur.aiIdx[pCur.iPage] < pPage.nCell); - pgno = sqlite3Get4byte(pPage.aData, findCell(pPage, pCur.aiIdx[pCur.iPage])); - rc = moveToChild(pCur, pgno); - } - return rc; - } +/* +** Move the cursor down to the left-most leaf entry beneath the +** entry to which it is currently pointing. +** +** The left-most leaf is the one with the smallest key - the first +** in ascending order. +*/ +static int moveToLeftmost( BtCursor pCur ) +{ + Pgno pgno; + int rc = SQLITE_OK; + MemPage pPage; + + Debug.Assert( cursorHoldsMutex( pCur ) ); + Debug.Assert( pCur.eState == CURSOR_VALID ); + while ( rc == SQLITE_OK && 0 == ( pPage = pCur.apPage[pCur.iPage] ).leaf ) + { + Debug.Assert( pCur.aiIdx[pCur.iPage] < pPage.nCell ); + pgno = sqlite3Get4byte( pPage.aData, findCell( pPage, pCur.aiIdx[pCur.iPage] ) ); + rc = moveToChild( pCur, pgno ); + } + return rc; +} - /* - ** Move the cursor down to the right-most leaf entry beneath the - ** page to which it is currently pointing. Notice the difference - ** between moveToLeftmost() and moveToRightmost(). moveToLeftmost() - ** finds the left-most entry beneath the *entry* whereas moveToRightmost() - ** finds the right-most entry beneath the page*. - ** - ** The right-most entry is the one with the largest key - the last - ** key in ascending order. - */ - static int moveToRightmost(BtCursor pCur) { - Pgno pgno; - int rc = SQLITE_OK; - MemPage pPage = null; - - Debug.Assert(cursorHoldsMutex(pCur)); - Debug.Assert(pCur.eState == CURSOR_VALID); - while (rc == SQLITE_OK && 0 == (pPage = pCur.apPage[pCur.iPage]).leaf) { - pgno = sqlite3Get4byte(pPage.aData, pPage.hdrOffset + 8); - pCur.aiIdx[pCur.iPage] = pPage.nCell; - rc = moveToChild(pCur, pgno); - } - if (rc == SQLITE_OK) { - pCur.aiIdx[pCur.iPage] = (u16)(pPage.nCell - 1); - pCur.info.nSize = 0; - pCur.validNKey = false; - } - return rc; - } +/* +** Move the cursor down to the right-most leaf entry beneath the +** page to which it is currently pointing. Notice the difference +** between moveToLeftmost() and moveToRightmost(). moveToLeftmost() +** finds the left-most entry beneath the *entry* whereas moveToRightmost() +** finds the right-most entry beneath the page*. +** +** The right-most entry is the one with the largest key - the last +** key in ascending order. +*/ +static int moveToRightmost( BtCursor pCur ) +{ + Pgno pgno; + int rc = SQLITE_OK; + MemPage pPage = null; + + Debug.Assert( cursorHoldsMutex( pCur ) ); + Debug.Assert( pCur.eState == CURSOR_VALID ); + while ( rc == SQLITE_OK && 0 == ( pPage = pCur.apPage[pCur.iPage] ).leaf ) + { + pgno = sqlite3Get4byte( pPage.aData, pPage.hdrOffset + 8 ); + pCur.aiIdx[pCur.iPage] = pPage.nCell; + rc = moveToChild( pCur, pgno ); + } + if ( rc == SQLITE_OK ) + { + pCur.aiIdx[pCur.iPage] = (u16)( pPage.nCell - 1 ); + pCur.info.nSize = 0; + pCur.validNKey = false; + } + return rc; +} - /* Move the cursor to the first entry in the table. Return SQLITE_OK - ** on success. Set pRes to 0 if the cursor actually points to something - ** or set pRes to 1 if the table is empty. - */ - static int sqlite3BtreeFirst(BtCursor pCur, ref int pRes) { - int rc; - - Debug.Assert(cursorHoldsMutex(pCur)); - Debug.Assert(sqlite3_mutex_held(pCur.pBtree.db.mutex)); - rc = moveToRoot(pCur); - if (rc == SQLITE_OK) { - if (pCur.eState == CURSOR_INVALID) { - Debug.Assert(pCur.apPage[pCur.iPage].nCell == 0); - pRes = 1; - } else { - Debug.Assert(pCur.apPage[pCur.iPage].nCell > 0); - pRes = 0; - rc = moveToLeftmost(pCur); - } - } - return rc; - } +/* Move the cursor to the first entry in the table. Return SQLITE_OK +** on success. Set pRes to 0 if the cursor actually points to something +** or set pRes to 1 if the table is empty. +*/ +static int sqlite3BtreeFirst( BtCursor pCur, ref int pRes ) +{ + int rc; + + Debug.Assert( cursorHoldsMutex( pCur ) ); + Debug.Assert( sqlite3_mutex_held( pCur.pBtree.db.mutex ) ); + rc = moveToRoot( pCur ); + if ( rc == SQLITE_OK ) + { + if ( pCur.eState == CURSOR_INVALID ) + { + Debug.Assert( pCur.apPage[pCur.iPage].nCell == 0 ); + pRes = 1; + } + else + { + Debug.Assert( pCur.apPage[pCur.iPage].nCell > 0 ); + pRes = 0; + rc = moveToLeftmost( pCur ); + } + } + return rc; +} - /* Move the cursor to the last entry in the table. Return SQLITE_OK - ** on success. Set pRes to 0 if the cursor actually points to something - ** or set pRes to 1 if the table is empty. - */ - static int sqlite3BtreeLast(BtCursor pCur, ref int pRes) { - int rc; +/* Move the cursor to the last entry in the table. Return SQLITE_OK +** on success. Set pRes to 0 if the cursor actually points to something +** or set pRes to 1 if the table is empty. +*/ +static int sqlite3BtreeLast( BtCursor pCur, ref int pRes ) +{ + int rc; - Debug.Assert(cursorHoldsMutex(pCur)); - Debug.Assert(sqlite3_mutex_held(pCur.pBtree.db.mutex)); + Debug.Assert( cursorHoldsMutex( pCur ) ); + Debug.Assert( sqlite3_mutex_held( pCur.pBtree.db.mutex ) ); - /* If the cursor already points to the last entry, this is a no-op. */ - if (CURSOR_VALID == pCur.eState && pCur.atLast != 0) { + /* If the cursor already points to the last entry, this is a no-op. */ + if ( CURSOR_VALID == pCur.eState && pCur.atLast != 0 ) + { #if SQLITE_DEBUG - /* This block serves to Debug.Assert() that the cursor really does point - ** to the last entry in the b-tree. */ - int ii; - for (ii = 0; ii < pCur.iPage; ii++) { - Debug.Assert(pCur.aiIdx[ii] == pCur.apPage[ii].nCell); - } - Debug.Assert(pCur.aiIdx[pCur.iPage] == pCur.apPage[pCur.iPage].nCell - 1); - Debug.Assert(pCur.apPage[pCur.iPage].leaf != 0); + /* This block serves to Debug.Assert() that the cursor really does point +** to the last entry in the b-tree. */ + int ii; + for ( ii = 0; ii < pCur.iPage; ii++ ) + { + Debug.Assert( pCur.aiIdx[ii] == pCur.apPage[ii].nCell ); + } + Debug.Assert( pCur.aiIdx[pCur.iPage] == pCur.apPage[pCur.iPage].nCell - 1 ); + Debug.Assert( pCur.apPage[pCur.iPage].leaf != 0 ); #endif - return SQLITE_OK; - } + return SQLITE_OK; + } - rc = moveToRoot(pCur); - if (rc == SQLITE_OK) { - if (CURSOR_INVALID == pCur.eState) { - Debug.Assert(pCur.apPage[pCur.iPage].nCell == 0); - pRes = 1; - } else { - Debug.Assert(pCur.eState == CURSOR_VALID); - pRes = 0; - rc = moveToRightmost(pCur); - pCur.atLast = (u8)(rc == SQLITE_OK ? 1 : 0); - } - } - return rc; - } + rc = moveToRoot( pCur ); + if ( rc == SQLITE_OK ) + { + if ( CURSOR_INVALID == pCur.eState ) + { + Debug.Assert( pCur.apPage[pCur.iPage].nCell == 0 ); + pRes = 1; + } + else + { + Debug.Assert( pCur.eState == CURSOR_VALID ); + pRes = 0; + rc = moveToRightmost( pCur ); + pCur.atLast = (u8)( rc == SQLITE_OK ? 1 : 0 ); + } + } + return rc; +} - /* Move the cursor so that it points to an entry near the key - ** specified by pIdxKey or intKey. Return a success code. - ** - ** For INTKEY tables, the intKey parameter is used. pIdxKey - ** must be NULL. For index tables, pIdxKey is used and intKey - ** is ignored. - ** - ** If an exact match is not found, then the cursor is always - ** left pointing at a leaf page which would hold the entry if it - ** were present. The cursor might point to an entry that comes - ** before or after the key. - ** - ** An integer is written into pRes which is the result of - ** comparing the key with the entry to which the cursor is - ** pointing. The meaning of the integer written into - ** pRes is as follows: - ** - ** pRes<0 The cursor is left pointing at an entry that - ** is smaller than intKey/pIdxKey or if the table is empty - ** and the cursor is therefore left point to nothing. - ** - ** pRes==null The cursor is left pointing at an entry that - ** exactly matches intKey/pIdxKey. - ** - ** pRes>0 The cursor is left pointing at an entry that - ** is larger than intKey/pIdxKey. - ** - */ - static int sqlite3BtreeMovetoUnpacked( - BtCursor pCur, /* The cursor to be moved */ - UnpackedRecord pIdxKey, /* Unpacked index key */ - i64 intKey, /* The table key */ - int biasRight, /* If true, bias the search to the high end */ - ref int pRes /* Write search results here */ - ) { - int rc; - - Debug.Assert(cursorHoldsMutex(pCur)); - Debug.Assert(sqlite3_mutex_held(pCur.pBtree.db.mutex)); - // Not needed in C# // Debug.Assert( pRes != 0 ); - Debug.Assert((pIdxKey == null) == (pCur.pKeyInfo == null)); - - /* If the cursor is already positioned at the point we are trying - ** to move to, then just return without doing any work */ - if (pCur.eState == CURSOR_VALID && pCur.validNKey - && pCur.apPage[0].intKey != 0 - ) { - if (pCur.info.nKey == intKey) { - pRes = 0; - return SQLITE_OK; - } - if (pCur.atLast != 0 && pCur.info.nKey < intKey) { - pRes = -1; - return SQLITE_OK; - } - } +/* Move the cursor so that it points to an entry near the key +** specified by pIdxKey or intKey. Return a success code. +** +** For INTKEY tables, the intKey parameter is used. pIdxKey +** must be NULL. For index tables, pIdxKey is used and intKey +** is ignored. +** +** If an exact match is not found, then the cursor is always +** left pointing at a leaf page which would hold the entry if it +** were present. The cursor might point to an entry that comes +** before or after the key. +** +** An integer is written into pRes which is the result of +** comparing the key with the entry to which the cursor is +** pointing. The meaning of the integer written into +** pRes is as follows: +** +** pRes<0 The cursor is left pointing at an entry that +** is smaller than intKey/pIdxKey or if the table is empty +** and the cursor is therefore left point to nothing. +** +** pRes==null The cursor is left pointing at an entry that +** exactly matches intKey/pIdxKey. +** +** pRes>0 The cursor is left pointing at an entry that +** is larger than intKey/pIdxKey. +** +*/ +static int sqlite3BtreeMovetoUnpacked( +BtCursor pCur, /* The cursor to be moved */ +UnpackedRecord pIdxKey, /* Unpacked index key */ +i64 intKey, /* The table key */ +int biasRight, /* If true, bias the search to the high end */ +ref int pRes /* Write search results here */ +) +{ + int rc; + + Debug.Assert( cursorHoldsMutex( pCur ) ); + Debug.Assert( sqlite3_mutex_held( pCur.pBtree.db.mutex ) ); + // Not needed in C# // Debug.Assert( pRes != 0 ); + Debug.Assert( ( pIdxKey == null ) == ( pCur.pKeyInfo == null ) ); + + /* If the cursor is already positioned at the point we are trying + ** to move to, then just return without doing any work */ + if ( pCur.eState == CURSOR_VALID && pCur.validNKey + && pCur.apPage[0].intKey != 0 + ) + { + if ( pCur.info.nKey == intKey ) + { + pRes = 0; + return SQLITE_OK; + } + if ( pCur.atLast != 0 && pCur.info.nKey < intKey ) + { + pRes = -1; + return SQLITE_OK; + } + } + + rc = moveToRoot( pCur ); + if ( rc != 0 ) + { + return rc; + } + Debug.Assert( pCur.apPage[pCur.iPage] != null ); + Debug.Assert( pCur.apPage[pCur.iPage].isInit != 0 ); + Debug.Assert( pCur.apPage[pCur.iPage].nCell > 0 || pCur.eState == CURSOR_INVALID ); + if ( pCur.eState == CURSOR_INVALID ) + { + pRes = -1; + Debug.Assert( pCur.apPage[pCur.iPage].nCell == 0 ); + return SQLITE_OK; + } + Debug.Assert( pCur.apPage[0].intKey != 0 || pIdxKey != null ); + for ( ; ; ) + { + int lwr, upr, idx; + Pgno chldPg; + MemPage pPage = pCur.apPage[pCur.iPage]; + int c; + + /* pPage.nCell must be greater than zero. If this is the root-page + ** the cursor would have been INVALID above and this for(;;) loop + ** not run. If this is not the root-page, then the moveToChild() routine + ** would have already detected db corruption. Similarly, pPage must + ** be the right kind (index or table) of b-tree page. Otherwise + ** a moveToChild() or moveToRoot() call would have detected corruption. */ + Debug.Assert( pPage.nCell > 0 ); + Debug.Assert( pPage.intKey == ( ( pIdxKey == null ) ? 1 : 0 ) ); + lwr = 0; + upr = pPage.nCell - 1; + if ( biasRight != 0 ) + { + pCur.aiIdx[pCur.iPage] = (u16)( idx = upr ); + } + else + { + pCur.aiIdx[pCur.iPage] = (u16)( idx = ( upr + lwr ) / 2 ); + } + for ( ; ; ) + { + int pCell; /* Pointer to current cell in pPage */ + + Debug.Assert( idx == pCur.aiIdx[pCur.iPage] ); + pCur.info.nSize = 0; + pCell = findCell( pPage, idx ) + pPage.childPtrSize; + if ( pPage.intKey != 0 ) + { + i64 nCellKey = 0; + if ( pPage.hasData != 0 ) + { + u32 Dummy0 = 0; + pCell += getVarint32( pPage.aData, pCell, out Dummy0 ); + } + getVarint( pPage.aData, pCell, out nCellKey ); + if ( nCellKey == intKey ) + { + c = 0; + } + else if ( nCellKey < intKey ) + { + c = -1; + } + else + { + Debug.Assert( nCellKey > intKey ); + c = +1; + } + pCur.validNKey = true; + pCur.info.nKey = nCellKey; + } + else + { + /* The maximum supported page-size is 65536 bytes. This means that + ** the maximum number of record bytes stored on an index B-Tree + ** page is less than 16384 bytes and may be stored as a 2-byte + ** varint. This information is used to attempt to avoid parsing + ** the entire cell by checking for the cases where the record is + ** stored entirely within the b-tree page by inspecting the first + ** 2 bytes of the cell. + */ + int nCell = pPage.aData[pCell + 0]; //pCell[0]; + if ( 0 == ( nCell & 0x80 ) && nCell <= pPage.maxLocal ) + { + /* This branch runs if the record-size field of the cell is a + ** single byte varint and the record fits entirely on the main + ** b-tree page. */ + c = sqlite3VdbeRecordCompare( nCell, pPage.aData, pCell + 1, pIdxKey ); //c = sqlite3VdbeRecordCompare( nCell, (void*)&pCell[1], pIdxKey ); + } + else if ( 0 == ( pPage.aData[pCell + 1] & 0x80 )//!(pCell[1] & 0x80) + && ( nCell = ( ( nCell & 0x7f ) << 7 ) + pPage.aData[pCell + 1] ) <= pPage.maxLocal//pCell[1])<=pPage.maxLocal + ) + { + /* The record-size field is a 2 byte varint and the record + ** fits entirely on the main b-tree page. */ + c = sqlite3VdbeRecordCompare( nCell, pPage.aData, pCell + 2, pIdxKey ); //c = sqlite3VdbeRecordCompare( nCell, (void*)&pCell[2], pIdxKey ); + } + else + { + /* The record flows over onto one or more overflow pages. In + ** this case the whole cell needs to be parsed, a buffer allocated + ** and accessPayload() used to retrieve the record into the + ** buffer before VdbeRecordCompare() can be called. */ + u8[] pCellKey; + u8[] pCellBody = new u8[pPage.aData.Length - pCell + pPage.childPtrSize]; + Buffer.BlockCopy( pPage.aData, pCell - pPage.childPtrSize, pCellBody, 0, pCellBody.Length );// u8 * const pCellBody = pCell - pPage->childPtrSize; + btreeParseCellPtr( pPage, pCellBody, ref pCur.info ); + nCell = (int)pCur.info.nKey; + pCellKey = sqlite3Malloc( nCell ); + //if ( pCellKey == null ) + //{ + // rc = SQLITE_NOMEM; + // goto moveto_finish; + //} + rc = accessPayload( pCur, 0, (u32)nCell, pCellKey, 0 ); + if ( rc != 0 ) + { + pCellKey = null;// sqlite3_free(ref pCellKey ); + goto moveto_finish; + } + c = sqlite3VdbeRecordCompare( nCell, pCellKey, pIdxKey ); + pCellKey = null;// sqlite3_free(ref pCellKey ); + } + } + if ( c == 0 ) + { + if ( pPage.intKey != 0 && 0 == pPage.leaf ) + { + lwr = idx; + upr = lwr - 1; + break; + } + else + { + pRes = 0; + rc = SQLITE_OK; + goto moveto_finish; + } + } + if ( c < 0 ) + { + lwr = idx + 1; + } + else + { + upr = idx - 1; + } + if ( lwr > upr ) + { + break; + } + pCur.aiIdx[pCur.iPage] = (u16)( idx = ( lwr + upr ) / 2 ); + } + Debug.Assert( lwr == upr + 1 ); + Debug.Assert( pPage.isInit != 0 ); + if ( pPage.leaf != 0 ) + { + chldPg = 0; + } + else if ( lwr >= pPage.nCell ) + { + chldPg = sqlite3Get4byte( pPage.aData, pPage.hdrOffset + 8 ); + } + else + { + chldPg = sqlite3Get4byte( pPage.aData, findCell( pPage, lwr ) ); + } + if ( chldPg == 0 ) + { + Debug.Assert( pCur.aiIdx[pCur.iPage] < pCur.apPage[pCur.iPage].nCell ); + pRes = c; + rc = SQLITE_OK; + goto moveto_finish; + } + pCur.aiIdx[pCur.iPage] = (u16)lwr; + pCur.info.nSize = 0; + pCur.validNKey = false; + rc = moveToChild( pCur, chldPg ); + if ( rc != 0 ) + goto moveto_finish; + } +moveto_finish: + return rc; +} - rc = moveToRoot(pCur); - if (rc != 0) { - return rc; - } - Debug.Assert(pCur.apPage[pCur.iPage] != null); - Debug.Assert(pCur.apPage[pCur.iPage].isInit != 0); - Debug.Assert(pCur.apPage[pCur.iPage].nCell > 0 || pCur.eState == CURSOR_INVALID); - if (pCur.eState == CURSOR_INVALID) { - pRes = -1; - Debug.Assert(pCur.apPage[pCur.iPage].nCell == 0); - return SQLITE_OK; - } - Debug.Assert(pCur.apPage[0].intKey != 0 || pIdxKey != null); - for (; ; ) - { - int lwr, upr, idx; - Pgno chldPg; - MemPage pPage = pCur.apPage[pCur.iPage]; - int c; - - /* pPage.nCell must be greater than zero. If this is the root-page - ** the cursor would have been INVALID above and this for(;;) loop - ** not run. If this is not the root-page, then the moveToChild() routine - ** would have already detected db corruption. Similarly, pPage must - ** be the right kind (index or table) of b-tree page. Otherwise - ** a moveToChild() or moveToRoot() call would have detected corruption. */ - Debug.Assert(pPage.nCell > 0); - Debug.Assert(pPage.intKey == ((pIdxKey == null) ? 1 : 0)); - lwr = 0; - upr = pPage.nCell - 1; - if (biasRight != 0) { - pCur.aiIdx[pCur.iPage] = (u16)(idx = upr); - } else { - pCur.aiIdx[pCur.iPage] = (u16)(idx = (upr + lwr) / 2); - } - for (; ; ) - { - int pCell; /* Pointer to current cell in pPage */ - - Debug.Assert(idx == pCur.aiIdx[pCur.iPage]); - pCur.info.nSize = 0; - pCell = findCell(pPage, idx) + pPage.childPtrSize; - if (pPage.intKey != 0) { - i64 nCellKey = 0; - if (pPage.hasData != 0) { - u32 Dummy0 = 0; - pCell += getVarint32(pPage.aData, pCell, out Dummy0); - } - getVarint(pPage.aData, pCell, out nCellKey); - if (nCellKey == intKey) { - c = 0; - } else if (nCellKey < intKey) { - c = -1; - } else { - Debug.Assert(nCellKey > intKey); - c = +1; - } - pCur.validNKey = true; - pCur.info.nKey = nCellKey; - } else { - /* The maximum supported page-size is 65536 bytes. This means that - ** the maximum number of record bytes stored on an index B-Tree - ** page is less than 16384 bytes and may be stored as a 2-byte - ** varint. This information is used to attempt to avoid parsing - ** the entire cell by checking for the cases where the record is - ** stored entirely within the b-tree page by inspecting the first - ** 2 bytes of the cell. - */ - int nCell = pPage.aData[pCell + 0]; //pCell[0]; - if (0 == (nCell & 0x80) && nCell <= pPage.maxLocal) { - /* This branch runs if the record-size field of the cell is a - ** single byte varint and the record fits entirely on the main - ** b-tree page. */ - c = sqlite3VdbeRecordCompare(nCell, pPage.aData, pCell + 1, pIdxKey); //c = sqlite3VdbeRecordCompare( nCell, (void*)&pCell[1], pIdxKey ); - } else if (0 == (pPage.aData[pCell + 1] & 0x80)//!(pCell[1] & 0x80) - && (nCell = ((nCell & 0x7f) << 7) + pPage.aData[pCell + 1]) <= pPage.maxLocal//pCell[1])<=pPage.maxLocal - ) { - /* The record-size field is a 2 byte varint and the record - ** fits entirely on the main b-tree page. */ - c = sqlite3VdbeRecordCompare(nCell, pPage.aData, pCell + 2, pIdxKey); //c = sqlite3VdbeRecordCompare( nCell, (void*)&pCell[2], pIdxKey ); - } else { - /* The record flows over onto one or more overflow pages. In - ** this case the whole cell needs to be parsed, a buffer allocated - ** and accessPayload() used to retrieve the record into the - ** buffer before VdbeRecordCompare() can be called. */ - u8[] pCellKey; - u8[] pCellBody = new u8[pPage.aData.Length - pCell + pPage.childPtrSize]; - Buffer.BlockCopy(pPage.aData, pCell - pPage.childPtrSize, pCellBody, 0, pCellBody.Length);// u8 * const pCellBody = pCell - pPage->childPtrSize; - btreeParseCellPtr(pPage, pCellBody, ref pCur.info); - nCell = (int)pCur.info.nKey; - pCellKey = sqlite3Malloc(nCell); - //if ( pCellKey == null ) - //{ - // rc = SQLITE_NOMEM; - // goto moveto_finish; - //} - rc = accessPayload(pCur, 0, (u32)nCell, pCellKey, 0); - if (rc != 0) { - pCellKey = null;// sqlite3_free(ref pCellKey ); - goto moveto_finish; - } - c = sqlite3VdbeRecordCompare(nCell, pCellKey, pIdxKey); - pCellKey = null;// sqlite3_free(ref pCellKey ); - } - } - if (c == 0) { - if (pPage.intKey != 0 && 0 == pPage.leaf) { - lwr = idx; - upr = lwr - 1; - break; - } else { - pRes = 0; - rc = SQLITE_OK; - goto moveto_finish; - } - } - if (c < 0) { - lwr = idx + 1; - } else { - upr = idx - 1; - } - if (lwr > upr) { - break; - } - pCur.aiIdx[pCur.iPage] = (u16)(idx = (lwr + upr) / 2); - } - Debug.Assert(lwr == upr + 1); - Debug.Assert(pPage.isInit != 0); - if (pPage.leaf != 0) { - chldPg = 0; - } else if (lwr >= pPage.nCell) { - chldPg = sqlite3Get4byte(pPage.aData, pPage.hdrOffset + 8); - } else { - chldPg = sqlite3Get4byte(pPage.aData, findCell(pPage, lwr)); - } - if (chldPg == 0) { - Debug.Assert(pCur.aiIdx[pCur.iPage] < pCur.apPage[pCur.iPage].nCell); - pRes = c; - rc = SQLITE_OK; - goto moveto_finish; - } - pCur.aiIdx[pCur.iPage] = (u16)lwr; - pCur.info.nSize = 0; - pCur.validNKey = false; - rc = moveToChild(pCur, chldPg); - if (rc != 0) - goto moveto_finish; - } - moveto_finish: - return rc; - } +/* +** Return TRUE if the cursor is not pointing at an entry of the table. +** +** TRUE will be returned after a call to sqlite3BtreeNext() moves +** past the last entry in the table or sqlite3BtreePrev() moves past +** the first entry. TRUE is also returned if the table is empty. +*/ +static bool sqlite3BtreeEof( BtCursor pCur ) +{ + /* TODO: What if the cursor is in CURSOR_REQUIRESEEK but all table entries + ** have been deleted? This API will need to change to return an error code + ** as well as the boolean result value. + */ + return ( CURSOR_VALID != pCur.eState ); +} - /* - ** Return TRUE if the cursor is not pointing at an entry of the table. - ** - ** TRUE will be returned after a call to sqlite3BtreeNext() moves - ** past the last entry in the table or sqlite3BtreePrev() moves past - ** the first entry. TRUE is also returned if the table is empty. - */ - static bool sqlite3BtreeEof(BtCursor pCur) { - /* TODO: What if the cursor is in CURSOR_REQUIRESEEK but all table entries - ** have been deleted? This API will need to change to return an error code - ** as well as the boolean result value. - */ - return (CURSOR_VALID != pCur.eState); - } +/* +** Advance the cursor to the next entry in the database. If +** successful then set pRes=0. If the cursor +** was already pointing to the last entry in the database before +** this routine was called, then set pRes=1. +*/ +static int sqlite3BtreeNext( BtCursor pCur, ref int pRes ) +{ + int rc; + int idx; + MemPage pPage; + + Debug.Assert( cursorHoldsMutex( pCur ) ); + rc = restoreCursorPosition( pCur ); + if ( rc != SQLITE_OK ) + { + return rc; + } + // Not needed in C# // Debug.Assert( pRes != 0 ); + if ( CURSOR_INVALID == pCur.eState ) + { + pRes = 1; + return SQLITE_OK; + } + if ( pCur.skipNext > 0 ) + { + pCur.skipNext = 0; + pRes = 0; + return SQLITE_OK; + } + pCur.skipNext = 0; + + pPage = pCur.apPage[pCur.iPage]; + idx = ++pCur.aiIdx[pCur.iPage]; + Debug.Assert( pPage.isInit != 0 ); + Debug.Assert( idx <= pPage.nCell ); + + pCur.info.nSize = 0; + pCur.validNKey = false; + if ( idx >= pPage.nCell ) + { + if ( 0 == pPage.leaf ) + { + rc = moveToChild( pCur, sqlite3Get4byte( pPage.aData, pPage.hdrOffset + 8 ) ); + if ( rc != 0 ) + return rc; + rc = moveToLeftmost( pCur ); + pRes = 0; + return rc; + } + do + { + if ( pCur.iPage == 0 ) + { + pRes = 1; + pCur.eState = CURSOR_INVALID; + return SQLITE_OK; + } + moveToParent( pCur ); + pPage = pCur.apPage[pCur.iPage]; + } while ( pCur.aiIdx[pCur.iPage] >= pPage.nCell ); + pRes = 0; + if ( pPage.intKey != 0 ) + { + rc = sqlite3BtreeNext( pCur, ref pRes ); + } + else + { + rc = SQLITE_OK; + } + return rc; + } + pRes = 0; + if ( pPage.leaf != 0 ) + { + return SQLITE_OK; + } + rc = moveToLeftmost( pCur ); + return rc; +} - /* - ** Advance the cursor to the next entry in the database. If - ** successful then set pRes=0. If the cursor - ** was already pointing to the last entry in the database before - ** this routine was called, then set pRes=1. - */ - static int sqlite3BtreeNext(BtCursor pCur, ref int pRes) { - int rc; - int idx; - MemPage pPage; - - Debug.Assert(cursorHoldsMutex(pCur)); - rc = restoreCursorPosition(pCur); - if (rc != SQLITE_OK) { - return rc; - } - // Not needed in C# // Debug.Assert( pRes != 0 ); - if (CURSOR_INVALID == pCur.eState) { - pRes = 1; - return SQLITE_OK; - } - if (pCur.skipNext > 0) { - pCur.skipNext = 0; - pRes = 0; - return SQLITE_OK; - } - pCur.skipNext = 0; - - pPage = pCur.apPage[pCur.iPage]; - idx = ++pCur.aiIdx[pCur.iPage]; - Debug.Assert(pPage.isInit != 0); - Debug.Assert(idx <= pPage.nCell); - - pCur.info.nSize = 0; - pCur.validNKey = false; - if (idx >= pPage.nCell) { - if (0 == pPage.leaf) { - rc = moveToChild(pCur, sqlite3Get4byte(pPage.aData, pPage.hdrOffset + 8)); - if (rc != 0) - return rc; - rc = moveToLeftmost(pCur); - pRes = 0; - return rc; - } - do { - if (pCur.iPage == 0) { - pRes = 1; - pCur.eState = CURSOR_INVALID; - return SQLITE_OK; - } - moveToParent(pCur); - pPage = pCur.apPage[pCur.iPage]; - } while (pCur.aiIdx[pCur.iPage] >= pPage.nCell); - pRes = 0; - if (pPage.intKey != 0) { - rc = sqlite3BtreeNext(pCur, ref pRes); - } else { - rc = SQLITE_OK; - } - return rc; - } - pRes = 0; - if (pPage.leaf != 0) { - return SQLITE_OK; - } - rc = moveToLeftmost(pCur); - return rc; - } +/* +** Step the cursor to the back to the previous entry in the database. If +** successful then set pRes=0. If the cursor +** was already pointing to the first entry in the database before +** this routine was called, then set pRes=1. +*/ +static int sqlite3BtreePrevious( BtCursor pCur, ref int pRes ) +{ + int rc; + MemPage pPage; + + Debug.Assert( cursorHoldsMutex( pCur ) ); + rc = restoreCursorPosition( pCur ); + if ( rc != SQLITE_OK ) + { + return rc; + } + pCur.atLast = 0; + if ( CURSOR_INVALID == pCur.eState ) + { + pRes = 1; + return SQLITE_OK; + } + if ( pCur.skipNext < 0 ) + { + pCur.skipNext = 0; + pRes = 0; + return SQLITE_OK; + } + pCur.skipNext = 0; + + pPage = pCur.apPage[pCur.iPage]; + Debug.Assert( pPage.isInit != 0 ); + if ( 0 == pPage.leaf ) + { + int idx = pCur.aiIdx[pCur.iPage]; + rc = moveToChild( pCur, sqlite3Get4byte( pPage.aData, findCell( pPage, idx ) ) ); + if ( rc != 0 ) + { + return rc; + } + rc = moveToRightmost( pCur ); + } + else + { + while ( pCur.aiIdx[pCur.iPage] == 0 ) + { + if ( pCur.iPage == 0 ) + { + pCur.eState = CURSOR_INVALID; + pRes = 1; + return SQLITE_OK; + } + moveToParent( pCur ); + } + pCur.info.nSize = 0; + pCur.validNKey = false; - /* - ** Step the cursor to the back to the previous entry in the database. If - ** successful then set pRes=0. If the cursor - ** was already pointing to the first entry in the database before - ** this routine was called, then set pRes=1. - */ - static int sqlite3BtreePrevious(BtCursor pCur, ref int pRes) { - int rc; - MemPage pPage; - - Debug.Assert(cursorHoldsMutex(pCur)); - rc = restoreCursorPosition(pCur); - if (rc != SQLITE_OK) { - return rc; - } - pCur.atLast = 0; - if (CURSOR_INVALID == pCur.eState) { - pRes = 1; - return SQLITE_OK; - } - if (pCur.skipNext < 0) { - pCur.skipNext = 0; - pRes = 0; - return SQLITE_OK; - } - pCur.skipNext = 0; - - pPage = pCur.apPage[pCur.iPage]; - Debug.Assert(pPage.isInit != 0); - if (0 == pPage.leaf) { - int idx = pCur.aiIdx[pCur.iPage]; - rc = moveToChild(pCur, sqlite3Get4byte(pPage.aData, findCell(pPage, idx))); - if (rc != 0) { - return rc; - } - rc = moveToRightmost(pCur); - } else { - while (pCur.aiIdx[pCur.iPage] == 0) { - if (pCur.iPage == 0) { - pCur.eState = CURSOR_INVALID; - pRes = 1; - return SQLITE_OK; - } - moveToParent(pCur); - } - pCur.info.nSize = 0; - pCur.validNKey = false; - - pCur.aiIdx[pCur.iPage]--; - pPage = pCur.apPage[pCur.iPage]; - if (pPage.intKey != 0 && 0 == pPage.leaf) { - rc = sqlite3BtreePrevious(pCur, ref pRes); - } else { - rc = SQLITE_OK; - } - } - pRes = 0; - return rc; - } + pCur.aiIdx[pCur.iPage]--; + pPage = pCur.apPage[pCur.iPage]; + if ( pPage.intKey != 0 && 0 == pPage.leaf ) + { + rc = sqlite3BtreePrevious( pCur, ref pRes ); + } + else + { + rc = SQLITE_OK; + } + } + pRes = 0; + return rc; +} - /* - ** Allocate a new page from the database file. - ** - ** The new page is marked as dirty. (In other words, sqlite3PagerWrite() - ** has already been called on the new page.) The new page has also - ** been referenced and the calling routine is responsible for calling - ** sqlite3PagerUnref() on the new page when it is done. - ** - ** SQLITE_OK is returned on success. Any other return value indicates - ** an error. ppPage and pPgno are undefined in the event of an error. - ** Do not invoke sqlite3PagerUnref() on ppPage if an error is returned. - ** - ** If the "nearby" parameter is not 0, then a (feeble) effort is made to - ** locate a page close to the page number "nearby". This can be used in an - ** attempt to keep related pages close to each other in the database file, - ** which in turn can make database access faster. - ** - ** If the "exact" parameter is not 0, and the page-number nearby exists - ** anywhere on the free-list, then it is guarenteed to be returned. This - ** is only used by auto-vacuum databases when allocating a new table. - */ - static int allocateBtreePage( - BtShared pBt, - ref MemPage ppPage, - ref Pgno pPgno, - Pgno nearby, - u8 exact - ) { - MemPage pPage1; - int rc; - u32 n; /* Number of pages on the freelist */ - u32 k; /* Number of leaves on the trunk of the freelist */ - MemPage pTrunk = null; - MemPage pPrevTrunk = null; - Pgno mxPage; /* Total size of the database file */ - - Debug.Assert(sqlite3_mutex_held(pBt.mutex)); - pPage1 = pBt.pPage1; - mxPage = btreePagecount(pBt); - n = sqlite3Get4byte(pPage1.aData, 36); - testcase(n == mxPage - 1); - if (n >= mxPage) { - return SQLITE_CORRUPT_BKPT(); - } - if (n > 0) { - /* There are pages on the freelist. Reuse one of those pages. */ - Pgno iTrunk; - u8 searchList = 0; /* If the free-list must be searched for 'nearby' */ - - /* If the 'exact' parameter was true and a query of the pointer-map - ** shows that the page 'nearby' is somewhere on the free-list, then - ** the entire-list will be searched for that page. - */ +/* +** Allocate a new page from the database file. +** +** The new page is marked as dirty. (In other words, sqlite3PagerWrite() +** has already been called on the new page.) The new page has also +** been referenced and the calling routine is responsible for calling +** sqlite3PagerUnref() on the new page when it is done. +** +** SQLITE_OK is returned on success. Any other return value indicates +** an error. ppPage and pPgno are undefined in the event of an error. +** Do not invoke sqlite3PagerUnref() on ppPage if an error is returned. +** +** If the "nearby" parameter is not 0, then a (feeble) effort is made to +** locate a page close to the page number "nearby". This can be used in an +** attempt to keep related pages close to each other in the database file, +** which in turn can make database access faster. +** +** If the "exact" parameter is not 0, and the page-number nearby exists +** anywhere on the free-list, then it is guarenteed to be returned. This +** is only used by auto-vacuum databases when allocating a new table. +*/ +static int allocateBtreePage( +BtShared pBt, +ref MemPage ppPage, +ref Pgno pPgno, +Pgno nearby, +u8 exact +) +{ + MemPage pPage1; + int rc; + u32 n; /* Number of pages on the freelist */ + u32 k; /* Number of leaves on the trunk of the freelist */ + MemPage pTrunk = null; + MemPage pPrevTrunk = null; + Pgno mxPage; /* Total size of the database file */ + + Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); + pPage1 = pBt.pPage1; + mxPage = btreePagecount( pBt ); + n = sqlite3Get4byte( pPage1.aData, 36 ); + testcase( n == mxPage - 1 ); + if ( n >= mxPage ) + { + return SQLITE_CORRUPT_BKPT(); + } + if ( n > 0 ) + { + /* There are pages on the freelist. Reuse one of those pages. */ + Pgno iTrunk; + u8 searchList = 0; /* If the free-list must be searched for 'nearby' */ + + /* If the 'exact' parameter was true and a query of the pointer-map + ** shows that the page 'nearby' is somewhere on the free-list, then + ** the entire-list will be searched for that page. + */ #if !SQLITE_OMIT_AUTOVACUUM - if (exact != 0 && nearby <= mxPage) { - u8 eType = 0; - Debug.Assert(nearby > 0); - Debug.Assert(pBt.autoVacuum); - u32 Dummy0 = 0; - rc = ptrmapGet(pBt, nearby, ref eType, ref Dummy0); - if (rc != 0) - return rc; - if (eType == PTRMAP_FREEPAGE) { - searchList = 1; - } - pPgno = nearby; - } + if ( exact != 0 && nearby <= mxPage ) + { + u8 eType = 0; + Debug.Assert( nearby > 0 ); + Debug.Assert( pBt.autoVacuum ); + u32 Dummy0 = 0; + rc = ptrmapGet( pBt, nearby, ref eType, ref Dummy0 ); + if ( rc != 0 ) + return rc; + if ( eType == PTRMAP_FREEPAGE ) + { + searchList = 1; + } + pPgno = nearby; + } #endif - /* Decrement the free-list count by 1. Set iTrunk to the index of the - ** first free-list trunk page. iPrevTrunk is initially 1. - */ - rc = sqlite3PagerWrite(pPage1.pDbPage); - if (rc != 0) - return rc; - sqlite3Put4byte(pPage1.aData, (u32)36, n - 1); - - /* The code within this loop is run only once if the 'searchList' variable - ** is not true. Otherwise, it runs once for each trunk-page on the - ** free-list until the page 'nearby' is located. - */ - do { - pPrevTrunk = pTrunk; - if (pPrevTrunk != null) { - iTrunk = sqlite3Get4byte(pPrevTrunk.aData, 0); - } else { - iTrunk = sqlite3Get4byte(pPage1.aData, 32); - } - testcase(iTrunk == mxPage); - if (iTrunk > mxPage) { - rc = SQLITE_CORRUPT_BKPT(); - } else { - rc = btreeGetPage(pBt, iTrunk, ref pTrunk, 0); - } - if (rc != 0) { - pTrunk = null; - goto end_allocate_page; - } - - k = sqlite3Get4byte(pTrunk.aData, 4); /* # of leaves on this trunk page */ - if (k == 0 && 0 == searchList) { - /* The trunk has no leaves and the list is not being searched. - ** So extract the trunk page itself and use it as the newly - ** allocated page */ - Debug.Assert(pPrevTrunk == null); - rc = sqlite3PagerWrite(pTrunk.pDbPage); - if (rc != 0) { - goto end_allocate_page; - } - pPgno = iTrunk; - Buffer.BlockCopy(pTrunk.aData, 0, pPage1.aData, 32, 4);//memcpy( pPage1.aData[32], ref pTrunk.aData[0], 4 ); - ppPage = pTrunk; - pTrunk = null; - TRACE("ALLOCATE: %d trunk - %d free pages left\n", pPgno, n - 1); - } else if (k > (u32)(pBt.usableSize / 4 - 2)) { - /* Value of k is out of range. Database corruption */ - rc = SQLITE_CORRUPT_BKPT(); - goto end_allocate_page; + /* Decrement the free-list count by 1. Set iTrunk to the index of the +** first free-list trunk page. iPrevTrunk is initially 1. +*/ + rc = sqlite3PagerWrite( pPage1.pDbPage ); + if ( rc != 0 ) + return rc; + sqlite3Put4byte( pPage1.aData, (u32)36, n - 1 ); + + /* The code within this loop is run only once if the 'searchList' variable + ** is not true. Otherwise, it runs once for each trunk-page on the + ** free-list until the page 'nearby' is located. + */ + do + { + pPrevTrunk = pTrunk; + if ( pPrevTrunk != null ) + { + iTrunk = sqlite3Get4byte( pPrevTrunk.aData, 0 ); + } + else + { + iTrunk = sqlite3Get4byte( pPage1.aData, 32 ); + } + testcase( iTrunk == mxPage ); + if ( iTrunk > mxPage ) + { + rc = SQLITE_CORRUPT_BKPT(); + } + else + { + rc = btreeGetPage( pBt, iTrunk, ref pTrunk, 0 ); + } + if ( rc != 0 ) + { + pTrunk = null; + goto end_allocate_page; + } + + k = sqlite3Get4byte( pTrunk.aData, 4 ); /* # of leaves on this trunk page */ + if ( k == 0 && 0 == searchList ) + { + /* The trunk has no leaves and the list is not being searched. + ** So extract the trunk page itself and use it as the newly + ** allocated page */ + Debug.Assert( pPrevTrunk == null ); + rc = sqlite3PagerWrite( pTrunk.pDbPage ); + if ( rc != 0 ) + { + goto end_allocate_page; + } + pPgno = iTrunk; + Buffer.BlockCopy( pTrunk.aData, 0, pPage1.aData, 32, 4 );//memcpy( pPage1.aData[32], ref pTrunk.aData[0], 4 ); + ppPage = pTrunk; + pTrunk = null; + TRACE( "ALLOCATE: %d trunk - %d free pages left\n", pPgno, n - 1 ); + } + else if ( k > (u32)( pBt.usableSize / 4 - 2 ) ) + { + /* Value of k is out of range. Database corruption */ + rc = SQLITE_CORRUPT_BKPT(); + goto end_allocate_page; #if !SQLITE_OMIT_AUTOVACUUM - } else if (searchList != 0 && nearby == iTrunk) { - /* The list is being searched and this trunk page is the page - ** to allocate, regardless of whether it has leaves. - */ - Debug.Assert(pPgno == iTrunk); - ppPage = pTrunk; - searchList = 0; - rc = sqlite3PagerWrite(pTrunk.pDbPage); - if (rc != 0) { - goto end_allocate_page; - } - if (k == 0) { - if (null == pPrevTrunk) { - //memcpy(pPage1.aData[32], pTrunk.aData[0], 4); - pPage1.aData[32 + 0] = pTrunk.aData[0 + 0]; - pPage1.aData[32 + 1] = pTrunk.aData[0 + 1]; - pPage1.aData[32 + 2] = pTrunk.aData[0 + 2]; - pPage1.aData[32 + 3] = pTrunk.aData[0 + 3]; - } else { - rc = sqlite3PagerWrite(pPrevTrunk.pDbPage); - if (rc != SQLITE_OK) { - goto end_allocate_page; - } - //memcpy(pPrevTrunk.aData[0], pTrunk.aData[0], 4); - pPrevTrunk.aData[0 + 0] = pTrunk.aData[0 + 0]; - pPrevTrunk.aData[0 + 1] = pTrunk.aData[0 + 1]; - pPrevTrunk.aData[0 + 2] = pTrunk.aData[0 + 2]; - pPrevTrunk.aData[0 + 3] = pTrunk.aData[0 + 3]; - } - } else { - /* The trunk page is required by the caller but it contains - ** pointers to free-list leaves. The first leaf becomes a trunk - ** page in this case. - */ - MemPage pNewTrunk = new MemPage(); - Pgno iNewTrunk = sqlite3Get4byte(pTrunk.aData, 8); - if (iNewTrunk > mxPage) { - rc = SQLITE_CORRUPT_BKPT(); - goto end_allocate_page; - } - testcase(iNewTrunk == mxPage); - rc = btreeGetPage(pBt, iNewTrunk, ref pNewTrunk, 0); - if (rc != SQLITE_OK) { - goto end_allocate_page; - } - rc = sqlite3PagerWrite(pNewTrunk.pDbPage); - if (rc != SQLITE_OK) { - releasePage(pNewTrunk); - goto end_allocate_page; - } - //memcpy(pNewTrunk.aData[0], pTrunk.aData[0], 4); - pNewTrunk.aData[0 + 0] = pTrunk.aData[0 + 0]; - pNewTrunk.aData[0 + 1] = pTrunk.aData[0 + 1]; - pNewTrunk.aData[0 + 2] = pTrunk.aData[0 + 2]; - pNewTrunk.aData[0 + 3] = pTrunk.aData[0 + 3]; - sqlite3Put4byte(pNewTrunk.aData, (u32)4, (u32)(k - 1)); - Buffer.BlockCopy(pTrunk.aData, 12, pNewTrunk.aData, 8, (int)(k - 1) * 4);//memcpy( pNewTrunk.aData[8], ref pTrunk.aData[12], ( k - 1 ) * 4 ); - releasePage(pNewTrunk); - if (null == pPrevTrunk) { - Debug.Assert(sqlite3PagerIswriteable(pPage1.pDbPage)); - sqlite3Put4byte(pPage1.aData, (u32)32, iNewTrunk); - } else { - rc = sqlite3PagerWrite(pPrevTrunk.pDbPage); - if (rc != 0) { - goto end_allocate_page; - } - sqlite3Put4byte(pPrevTrunk.aData, (u32)0, iNewTrunk); - } - } - pTrunk = null; - TRACE("ALLOCATE: %d trunk - %d free pages left\n", pPgno, n - 1); + } + else if ( searchList != 0 && nearby == iTrunk ) + { + /* The list is being searched and this trunk page is the page + ** to allocate, regardless of whether it has leaves. + */ + Debug.Assert( pPgno == iTrunk ); + ppPage = pTrunk; + searchList = 0; + rc = sqlite3PagerWrite( pTrunk.pDbPage ); + if ( rc != 0 ) + { + goto end_allocate_page; + } + if ( k == 0 ) + { + if ( null == pPrevTrunk ) + { + //memcpy(pPage1.aData[32], pTrunk.aData[0], 4); + pPage1.aData[32 + 0] = pTrunk.aData[0 + 0]; + pPage1.aData[32 + 1] = pTrunk.aData[0 + 1]; + pPage1.aData[32 + 2] = pTrunk.aData[0 + 2]; + pPage1.aData[32 + 3] = pTrunk.aData[0 + 3]; + } + else + { + rc = sqlite3PagerWrite( pPrevTrunk.pDbPage ); + if ( rc != SQLITE_OK ) + { + goto end_allocate_page; + } + //memcpy(pPrevTrunk.aData[0], pTrunk.aData[0], 4); + pPrevTrunk.aData[0 + 0] = pTrunk.aData[0 + 0]; + pPrevTrunk.aData[0 + 1] = pTrunk.aData[0 + 1]; + pPrevTrunk.aData[0 + 2] = pTrunk.aData[0 + 2]; + pPrevTrunk.aData[0 + 3] = pTrunk.aData[0 + 3]; + } + } + else + { + /* The trunk page is required by the caller but it contains + ** pointers to free-list leaves. The first leaf becomes a trunk + ** page in this case. + */ + MemPage pNewTrunk = new MemPage(); + Pgno iNewTrunk = sqlite3Get4byte( pTrunk.aData, 8 ); + if ( iNewTrunk > mxPage ) + { + rc = SQLITE_CORRUPT_BKPT(); + goto end_allocate_page; + } + testcase( iNewTrunk == mxPage ); + rc = btreeGetPage( pBt, iNewTrunk, ref pNewTrunk, 0 ); + if ( rc != SQLITE_OK ) + { + goto end_allocate_page; + } + rc = sqlite3PagerWrite( pNewTrunk.pDbPage ); + if ( rc != SQLITE_OK ) + { + releasePage( pNewTrunk ); + goto end_allocate_page; + } + //memcpy(pNewTrunk.aData[0], pTrunk.aData[0], 4); + pNewTrunk.aData[0 + 0] = pTrunk.aData[0 + 0]; + pNewTrunk.aData[0 + 1] = pTrunk.aData[0 + 1]; + pNewTrunk.aData[0 + 2] = pTrunk.aData[0 + 2]; + pNewTrunk.aData[0 + 3] = pTrunk.aData[0 + 3]; + sqlite3Put4byte( pNewTrunk.aData, (u32)4, (u32)( k - 1 ) ); + Buffer.BlockCopy( pTrunk.aData, 12, pNewTrunk.aData, 8, (int)( k - 1 ) * 4 );//memcpy( pNewTrunk.aData[8], ref pTrunk.aData[12], ( k - 1 ) * 4 ); + releasePage( pNewTrunk ); + if ( null == pPrevTrunk ) + { + Debug.Assert( sqlite3PagerIswriteable( pPage1.pDbPage ) ); + sqlite3Put4byte( pPage1.aData, (u32)32, iNewTrunk ); + } + else + { + rc = sqlite3PagerWrite( pPrevTrunk.pDbPage ); + if ( rc != 0 ) + { + goto end_allocate_page; + } + sqlite3Put4byte( pPrevTrunk.aData, (u32)0, iNewTrunk ); + } + } + pTrunk = null; + TRACE( "ALLOCATE: %d trunk - %d free pages left\n", pPgno, n - 1 ); #endif - } else if (k > 0) { - /* Extract a leaf from the trunk */ - u32 closest; - Pgno iPage; - byte[] aData = pTrunk.aData; - if (nearby > 0) { - u32 i; - int dist; - closest = 0; - dist = sqlite3AbsInt32((int)(sqlite3Get4byte(aData, 8) - nearby)); - for (i = 1; i < k; i++) { - int d2 = sqlite3AbsInt32((int)(sqlite3Get4byte(aData, 8 + i * 4) - nearby)); - if (d2 < dist) { - closest = i; - dist = d2; - } - } - } else { - closest = 0; - } - - iPage = sqlite3Get4byte(aData, 8 + closest * 4); - testcase(iPage == mxPage); - if (iPage > mxPage) { - rc = SQLITE_CORRUPT_BKPT(); - goto end_allocate_page; - } - testcase(iPage == mxPage); - if (0 == searchList || iPage == nearby) { - int noContent; - pPgno = iPage; - TRACE("ALLOCATE: %d was leaf %d of %d on trunk %d" + - ": %d more free pages\n", - pPgno, closest + 1, k, pTrunk.pgno, n - 1); - rc = sqlite3PagerWrite(pTrunk.pDbPage); - if (rc != 0) - goto end_allocate_page; - if (closest < k - 1) { - Buffer.BlockCopy(aData, (int)(4 + k * 4), aData, 8 + (int)closest * 4, 4);//memcpy( aData[8 + closest * 4], ref aData[4 + k * 4], 4 ); - } - sqlite3Put4byte(aData, (u32)4, (k - 1));// sqlite3Put4byte( aData, 4, k - 1 ); - noContent = !btreeGetHasContent(pBt, pPgno) ? 1 : 0; - rc = btreeGetPage(pBt, pPgno, ref ppPage, noContent); - if (rc == SQLITE_OK) { - rc = sqlite3PagerWrite((ppPage).pDbPage); - if (rc != SQLITE_OK) { - releasePage(ppPage); - } - } - searchList = 0; - } - } - releasePage(pPrevTrunk); - pPrevTrunk = null; - } while (searchList != 0); - } else { - /* There are no pages on the freelist, so create a new page at the - ** end of the file */ - rc = sqlite3PagerWrite(pBt.pPage1.pDbPage); - if (rc != 0) - return rc; - pBt.nPage++; - if (pBt.nPage == PENDING_BYTE_PAGE(pBt)) - pBt.nPage++; + } + else if ( k > 0 ) + { + /* Extract a leaf from the trunk */ + u32 closest; + Pgno iPage; + byte[] aData = pTrunk.aData; + if ( nearby > 0 ) + { + u32 i; + int dist; + closest = 0; + dist = sqlite3AbsInt32( (int)(sqlite3Get4byte( aData, 8 ) - nearby )); + for ( i = 1; i < k; i++ ) + { + int d2 = sqlite3AbsInt32( (int)(sqlite3Get4byte( aData, 8 + i * 4 ) - nearby )); + if ( d2 < dist ) + { + closest = i; + dist = d2; + } + } + } + else + { + closest = 0; + } + + iPage = sqlite3Get4byte( aData, 8 + closest * 4 ); + testcase( iPage == mxPage ); + if ( iPage > mxPage ) + { + rc = SQLITE_CORRUPT_BKPT(); + goto end_allocate_page; + } + testcase( iPage == mxPage ); + if ( 0 == searchList || iPage == nearby ) + { + int noContent; + pPgno = iPage; + TRACE( "ALLOCATE: %d was leaf %d of %d on trunk %d" + + ": %d more free pages\n", + pPgno, closest + 1, k, pTrunk.pgno, n - 1 ); + rc = sqlite3PagerWrite( pTrunk.pDbPage ); + if ( rc != 0) + goto end_allocate_page; + if ( closest < k - 1 ) + { + Buffer.BlockCopy( aData, (int)( 4 + k * 4 ), aData, 8 + (int)closest * 4, 4 );//memcpy( aData[8 + closest * 4], ref aData[4 + k * 4], 4 ); + } + sqlite3Put4byte( aData, (u32)4, ( k - 1 ) );// sqlite3Put4byte( aData, 4, k - 1 ); + noContent = !btreeGetHasContent( pBt, pPgno ) ? 1 : 0; + rc = btreeGetPage( pBt, pPgno, ref ppPage, noContent ); + if ( rc == SQLITE_OK ) + { + rc = sqlite3PagerWrite( ( ppPage ).pDbPage ); + if ( rc != SQLITE_OK ) + { + releasePage( ppPage ); + } + } + searchList = 0; + } + } + releasePage( pPrevTrunk ); + pPrevTrunk = null; + } while ( searchList != 0 ); + } + else + { + /* There are no pages on the freelist, so create a new page at the + ** end of the file */ + rc = sqlite3PagerWrite( pBt.pPage1.pDbPage ); + if ( rc != 0 ) + return rc; + pBt.nPage++; + if ( pBt.nPage == PENDING_BYTE_PAGE( pBt ) ) + pBt.nPage++; #if !SQLITE_OMIT_AUTOVACUUM - if (pBt.autoVacuum && PTRMAP_ISPAGE(pBt, pBt.nPage)) { - /* If pPgno refers to a pointer-map page, allocate two new pages - ** at the end of the file instead of one. The first allocated page - ** becomes a new pointer-map page, the second is used by the caller. - */ - MemPage pPg = null; - TRACE("ALLOCATE: %d from end of file (pointer-map page)\n", pPgno); - Debug.Assert(pBt.nPage != PENDING_BYTE_PAGE(pBt)); - rc = btreeGetPage(pBt, pBt.nPage, ref pPg, 1); - if (rc == SQLITE_OK) { - rc = sqlite3PagerWrite(pPg.pDbPage); - releasePage(pPg); - } - if (rc != 0) - return rc; - pBt.nPage++; - if (pBt.nPage == PENDING_BYTE_PAGE(pBt)) { - pBt.nPage++; - } - } + if ( pBt.autoVacuum && PTRMAP_ISPAGE( pBt, pBt.nPage ) ) + { + /* If pPgno refers to a pointer-map page, allocate two new pages + ** at the end of the file instead of one. The first allocated page + ** becomes a new pointer-map page, the second is used by the caller. + */ + MemPage pPg = null; + TRACE( "ALLOCATE: %d from end of file (pointer-map page)\n", pPgno ); + Debug.Assert( pBt.nPage != PENDING_BYTE_PAGE( pBt ) ); + rc = btreeGetPage( pBt, pBt.nPage, ref pPg, 1 ); + if ( rc == SQLITE_OK ) + { + rc = sqlite3PagerWrite( pPg.pDbPage ); + releasePage( pPg ); + } + if ( rc != 0 ) + return rc; + pBt.nPage++; + if ( pBt.nPage == PENDING_BYTE_PAGE( pBt ) ) + { + pBt.nPage++; + } + } #endif - sqlite3Put4byte(pBt.pPage1.aData, (u32)28, pBt.nPage); - pPgno = pBt.nPage; - - Debug.Assert(pPgno != PENDING_BYTE_PAGE(pBt)); - rc = btreeGetPage(pBt, pPgno, ref ppPage, 1); - if (rc != 0) - return rc; - rc = sqlite3PagerWrite((ppPage).pDbPage); - if (rc != SQLITE_OK) { - releasePage(ppPage); - } - TRACE("ALLOCATE: %d from end of file\n", pPgno); - } + sqlite3Put4byte( pBt.pPage1.aData, (u32)28, pBt.nPage ); + pPgno = pBt.nPage; + + Debug.Assert( pPgno != PENDING_BYTE_PAGE( pBt ) ); + rc = btreeGetPage( pBt, pPgno, ref ppPage, 1 ); + if ( rc != 0 ) + return rc; + rc = sqlite3PagerWrite( ( ppPage ).pDbPage ); + if ( rc != SQLITE_OK ) + { + releasePage( ppPage ); + } + TRACE( "ALLOCATE: %d from end of file\n", pPgno ); + } - Debug.Assert(pPgno != PENDING_BYTE_PAGE(pBt)); - - end_allocate_page: - releasePage(pTrunk); - releasePage(pPrevTrunk); - if (rc == SQLITE_OK) { - if (sqlite3PagerPageRefcount((ppPage).pDbPage) > 1) { - releasePage(ppPage); - return SQLITE_CORRUPT_BKPT(); - } - (ppPage).isInit = 0; - } else { - ppPage = null; - } - Debug.Assert(rc != SQLITE_OK || sqlite3PagerIswriteable((ppPage).pDbPage)); - return rc; - } + Debug.Assert( pPgno != PENDING_BYTE_PAGE( pBt ) ); - /* - ** This function is used to add page iPage to the database file free-list. - ** It is assumed that the page is not already a part of the free-list. - ** - ** The value passed as the second argument to this function is optional. - ** If the caller happens to have a pointer to the MemPage object - ** corresponding to page iPage handy, it may pass it as the second value. - ** Otherwise, it may pass NULL. - ** - ** If a pointer to a MemPage object is passed as the second argument, - ** its reference count is not altered by this function. - */ - static int freePage2(BtShared pBt, MemPage pMemPage, Pgno iPage) { - MemPage pTrunk = null; /* Free-list trunk page */ - Pgno iTrunk = 0; /* Page number of free-list trunk page */ - MemPage pPage1 = pBt.pPage1; /* Local reference to page 1 */ - MemPage pPage; /* Page being freed. May be NULL. */ - int rc; /* Return Code */ - int nFree; /* Initial number of pages on free-list */ - - Debug.Assert(sqlite3_mutex_held(pBt.mutex)); - Debug.Assert(iPage > 1); - Debug.Assert(null == pMemPage || pMemPage.pgno == iPage); - - if (pMemPage != null) { - pPage = pMemPage; - sqlite3PagerRef(pPage.pDbPage); - } else { - pPage = btreePageLookup(pBt, iPage); - } +end_allocate_page: + releasePage( pTrunk ); + releasePage( pPrevTrunk ); + if ( rc == SQLITE_OK ) + { + if ( sqlite3PagerPageRefcount( ( ppPage ).pDbPage ) > 1 ) + { + releasePage( ppPage ); + return SQLITE_CORRUPT_BKPT(); + } + ( ppPage ).isInit = 0; + } + else + { + ppPage = null; + } + Debug.Assert( rc != SQLITE_OK || sqlite3PagerIswriteable( ( ppPage ).pDbPage ) ); + return rc; +} - /* Increment the free page count on pPage1 */ - rc = sqlite3PagerWrite(pPage1.pDbPage); - if (rc != 0) - goto freepage_out; - nFree = (int)sqlite3Get4byte(pPage1.aData, 36); - sqlite3Put4byte(pPage1.aData, 36, nFree + 1); - - if (pBt.secureDelete) { - /* If the secure_delete option is enabled, then - ** always fully overwrite deleted information with zeros. - */ - if ((null == pPage && ((rc = btreeGetPage(pBt, iPage, ref pPage, 0)) != 0)) - || ((rc = sqlite3PagerWrite(pPage.pDbPage)) != 0) - ) { - goto freepage_out; - } - Array.Clear(pPage.aData, 0, (int)pPage.pBt.pageSize);//memset(pPage->aData, 0, pPage->pBt->pageSize); - } +/* +** This function is used to add page iPage to the database file free-list. +** It is assumed that the page is not already a part of the free-list. +** +** The value passed as the second argument to this function is optional. +** If the caller happens to have a pointer to the MemPage object +** corresponding to page iPage handy, it may pass it as the second value. +** Otherwise, it may pass NULL. +** +** If a pointer to a MemPage object is passed as the second argument, +** its reference count is not altered by this function. +*/ +static int freePage2( BtShared pBt, MemPage pMemPage, Pgno iPage ) +{ + MemPage pTrunk = null; /* Free-list trunk page */ + Pgno iTrunk = 0; /* Page number of free-list trunk page */ + MemPage pPage1 = pBt.pPage1; /* Local reference to page 1 */ + MemPage pPage; /* Page being freed. May be NULL. */ + int rc; /* Return Code */ + int nFree; /* Initial number of pages on free-list */ + + Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); + Debug.Assert( iPage > 1 ); + Debug.Assert( null == pMemPage || pMemPage.pgno == iPage ); + + if ( pMemPage != null ) + { + pPage = pMemPage; + sqlite3PagerRef( pPage.pDbPage ); + } + else + { + pPage = btreePageLookup( pBt, iPage ); + } + + /* Increment the free page count on pPage1 */ + rc = sqlite3PagerWrite( pPage1.pDbPage ); + if ( rc != 0 ) + goto freepage_out; + nFree = (int)sqlite3Get4byte( pPage1.aData, 36 ); + sqlite3Put4byte( pPage1.aData, 36, nFree + 1 ); + + if ( pBt.secureDelete ) + { + /* If the secure_delete option is enabled, then + ** always fully overwrite deleted information with zeros. + */ + if ( ( null == pPage && ( ( rc = btreeGetPage( pBt, iPage, ref pPage, 0 ) ) != 0 ) ) + || ( ( rc = sqlite3PagerWrite( pPage.pDbPage ) ) != 0 ) + ) + { + goto freepage_out; + } + Array.Clear( pPage.aData, 0, (int)pPage.pBt.pageSize );//memset(pPage->aData, 0, pPage->pBt->pageSize); + } - /* If the database supports auto-vacuum, write an entry in the pointer-map - ** to indicate that the page is free. - */ + /* If the database supports auto-vacuum, write an entry in the pointer-map + ** to indicate that the page is free. + */ #if !SQLITE_OMIT_AUTOVACUUM // if ( ISAUTOVACUUM ) - if (pBt.autoVacuum) + if ( pBt.autoVacuum ) #else if (false) #endif - { - ptrmapPut(pBt, iPage, PTRMAP_FREEPAGE, 0, ref rc); - if (rc != 0) - goto freepage_out; - } + { + ptrmapPut( pBt, iPage, PTRMAP_FREEPAGE, 0, ref rc ); + if ( rc != 0 ) + goto freepage_out; + } + + /* Now manipulate the actual database free-list structure. There are two + ** possibilities. If the free-list is currently empty, or if the first + ** trunk page in the free-list is full, then this page will become a + ** new free-list trunk page. Otherwise, it will become a leaf of the + ** first trunk page in the current free-list. This block tests if it + ** is possible to add the page as a new free-list leaf. + */ + if ( nFree != 0 ) + { + u32 nLeaf; /* Initial number of leaf cells on trunk page */ + + iTrunk = sqlite3Get4byte( pPage1.aData, 32 ); + rc = btreeGetPage( pBt, iTrunk, ref pTrunk, 0 ); + if ( rc != SQLITE_OK ) + { + goto freepage_out; + } - /* Now manipulate the actual database free-list structure. There are two - ** possibilities. If the free-list is currently empty, or if the first - ** trunk page in the free-list is full, then this page will become a - ** new free-list trunk page. Otherwise, it will become a leaf of the - ** first trunk page in the current free-list. This block tests if it - ** is possible to add the page as a new free-list leaf. - */ - if (nFree != 0) { - u32 nLeaf; /* Initial number of leaf cells on trunk page */ - - iTrunk = sqlite3Get4byte(pPage1.aData, 32); - rc = btreeGetPage(pBt, iTrunk, ref pTrunk, 0); - if (rc != SQLITE_OK) { - goto freepage_out; - } - - nLeaf = sqlite3Get4byte(pTrunk.aData, 4); - Debug.Assert(pBt.usableSize > 32); - if (nLeaf > (u32)pBt.usableSize / 4 - 2) { - rc = SQLITE_CORRUPT_BKPT(); - goto freepage_out; - } - if (nLeaf < (u32)pBt.usableSize / 4 - 8) { - /* In this case there is room on the trunk page to insert the page - ** being freed as a new leaf. - ** - ** Note that the trunk page is not really full until it contains - ** usableSize/4 - 2 entries, not usableSize/4 - 8 entries as we have - ** coded. But due to a coding error in versions of SQLite prior to - ** 3.6.0, databases with freelist trunk pages holding more than - ** usableSize/4 - 8 entries will be reported as corrupt. In order - ** to maintain backwards compatibility with older versions of SQLite, - ** we will continue to restrict the number of entries to usableSize/4 - 8 - ** for now. At some point in the future (once everyone has upgraded - ** to 3.6.0 or later) we should consider fixing the conditional above - ** to read "usableSize/4-2" instead of "usableSize/4-8". - */ - rc = sqlite3PagerWrite(pTrunk.pDbPage); - if (rc == SQLITE_OK) { - sqlite3Put4byte(pTrunk.aData, (u32)4, nLeaf + 1); - sqlite3Put4byte(pTrunk.aData, (u32)8 + nLeaf * 4, iPage); - if (pPage != null && !pBt.secureDelete) { - sqlite3PagerDontWrite(pPage.pDbPage); - } - rc = btreeSetHasContent(pBt, iPage); - } - TRACE("FREE-PAGE: %d leaf on trunk page %d\n", iPage, pTrunk.pgno); - goto freepage_out; - } - } + nLeaf = sqlite3Get4byte( pTrunk.aData, 4 ); + Debug.Assert( pBt.usableSize > 32 ); + if ( nLeaf > (u32)pBt.usableSize / 4 - 2 ) + { + rc = SQLITE_CORRUPT_BKPT(); + goto freepage_out; + } + if ( nLeaf < (u32)pBt.usableSize / 4 - 8 ) + { + /* In this case there is room on the trunk page to insert the page + ** being freed as a new leaf. + ** + ** Note that the trunk page is not really full until it contains + ** usableSize/4 - 2 entries, not usableSize/4 - 8 entries as we have + ** coded. But due to a coding error in versions of SQLite prior to + ** 3.6.0, databases with freelist trunk pages holding more than + ** usableSize/4 - 8 entries will be reported as corrupt. In order + ** to maintain backwards compatibility with older versions of SQLite, + ** we will continue to restrict the number of entries to usableSize/4 - 8 + ** for now. At some point in the future (once everyone has upgraded + ** to 3.6.0 or later) we should consider fixing the conditional above + ** to read "usableSize/4-2" instead of "usableSize/4-8". + */ + rc = sqlite3PagerWrite( pTrunk.pDbPage ); + if ( rc == SQLITE_OK ) + { + sqlite3Put4byte( pTrunk.aData, (u32)4, nLeaf + 1 ); + sqlite3Put4byte( pTrunk.aData, (u32)8 + nLeaf * 4, iPage ); + if ( pPage != null && !pBt.secureDelete ) + { + sqlite3PagerDontWrite( pPage.pDbPage ); + } + rc = btreeSetHasContent( pBt, iPage ); + } + TRACE( "FREE-PAGE: %d leaf on trunk page %d\n", iPage, pTrunk.pgno ); + goto freepage_out; + } + } + + /* If control flows to this point, then it was not possible to add the + ** the page being freed as a leaf page of the first trunk in the free-list. + ** Possibly because the free-list is empty, or possibly because the + ** first trunk in the free-list is full. Either way, the page being freed + ** will become the new first trunk page in the free-list. + */ + if ( pPage == null && SQLITE_OK != ( rc = btreeGetPage( pBt, iPage, ref pPage, 0 ) ) ) + { + goto freepage_out; + } + rc = sqlite3PagerWrite( pPage.pDbPage ); + if ( rc != SQLITE_OK ) + { + goto freepage_out; + } + sqlite3Put4byte( pPage.aData, iTrunk ); + sqlite3Put4byte( pPage.aData, 4, 0 ); + sqlite3Put4byte( pPage1.aData, (u32)32, iPage ); + TRACE( "FREE-PAGE: %d new trunk page replacing %d\n", pPage.pgno, iTrunk ); + +freepage_out: + if ( pPage != null ) + { + pPage.isInit = 0; + } + releasePage( pPage ); + releasePage( pTrunk ); + return rc; +} +static void freePage( MemPage pPage, ref int pRC ) +{ + if ( ( pRC ) == SQLITE_OK ) + { + pRC = freePage2( pPage.pBt, pPage, pPage.pgno ); + } +} - /* If control flows to this point, then it was not possible to add the - ** the page being freed as a leaf page of the first trunk in the free-list. - ** Possibly because the free-list is empty, or possibly because the - ** first trunk in the free-list is full. Either way, the page being freed - ** will become the new first trunk page in the free-list. - */ - if (pPage == null && SQLITE_OK != (rc = btreeGetPage(pBt, iPage, ref pPage, 0))) { - goto freepage_out; - } - rc = sqlite3PagerWrite(pPage.pDbPage); - if (rc != SQLITE_OK) { - goto freepage_out; - } - sqlite3Put4byte(pPage.aData, iTrunk); - sqlite3Put4byte(pPage.aData, 4, 0); - sqlite3Put4byte(pPage1.aData, (u32)32, iPage); - TRACE("FREE-PAGE: %d new trunk page replacing %d\n", pPage.pgno, iTrunk); - - freepage_out: - if (pPage != null) { - pPage.isInit = 0; - } - releasePage(pPage); - releasePage(pTrunk); - return rc; - } - static void freePage(MemPage pPage, ref int pRC) { - if ((pRC) == SQLITE_OK) { - pRC = freePage2(pPage.pBt, pPage, pPage.pgno); - } - } +/* +** Free any overflow pages associated with the given Cell. +*/ +static int clearCell( MemPage pPage, int pCell ) +{ + BtShared pBt = pPage.pBt; + CellInfo info = new CellInfo(); + Pgno ovflPgno; + int rc; + int nOvfl; + u32 ovflPageSize; + + Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); + btreeParseCellPtr( pPage, pCell, ref info ); + if ( info.iOverflow == 0 ) + { + return SQLITE_OK; /* No overflow pages. Return without doing anything */ + } + ovflPgno = sqlite3Get4byte( pPage.aData, pCell, info.iOverflow ); + Debug.Assert( pBt.usableSize > 4 ); + ovflPageSize = (u16)( pBt.usableSize - 4 ); + nOvfl = (int)( ( info.nPayload - info.nLocal + ovflPageSize - 1 ) / ovflPageSize ); + Debug.Assert( ovflPgno == 0 || nOvfl > 0 ); + while ( nOvfl-- != 0 ) + { + Pgno iNext = 0; + MemPage pOvfl = null; + if ( ovflPgno < 2 || ovflPgno > btreePagecount( pBt ) ) + { + /* 0 is not a legal page number and page 1 cannot be an + ** overflow page. Therefore if ovflPgno<2 or past the end of the + ** file the database must be corrupt. */ + return SQLITE_CORRUPT_BKPT(); + } + if ( nOvfl != 0 ) + { + rc = getOverflowPage( pBt, ovflPgno, out pOvfl, out iNext ); + if ( rc != 0 ) + return rc; + } - /* - ** Free any overflow pages associated with the given Cell. - */ - static int clearCell(MemPage pPage, int pCell) { - BtShared pBt = pPage.pBt; - CellInfo info = new CellInfo(); - Pgno ovflPgno; - int rc; - int nOvfl; - u32 ovflPageSize; - - Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); - btreeParseCellPtr(pPage, pCell, ref info); - if (info.iOverflow == 0) { - return SQLITE_OK; /* No overflow pages. Return without doing anything */ - } - ovflPgno = sqlite3Get4byte(pPage.aData, pCell, info.iOverflow); - Debug.Assert(pBt.usableSize > 4); - ovflPageSize = (u16)(pBt.usableSize - 4); - nOvfl = (int)((info.nPayload - info.nLocal + ovflPageSize - 1) / ovflPageSize); - Debug.Assert(ovflPgno == 0 || nOvfl > 0); - while (nOvfl-- != 0) { - Pgno iNext = 0; - MemPage pOvfl = null; - if (ovflPgno < 2 || ovflPgno > btreePagecount(pBt)) { - /* 0 is not a legal page number and page 1 cannot be an - ** overflow page. Therefore if ovflPgno<2 or past the end of the - ** file the database must be corrupt. */ - return SQLITE_CORRUPT_BKPT(); - } - if (nOvfl != 0) { - rc = getOverflowPage(pBt, ovflPgno, out pOvfl, out iNext); - if (rc != 0) - return rc; - } - - if ((pOvfl != null || ((pOvfl = btreePageLookup(pBt, ovflPgno)) != null)) - && sqlite3PagerPageRefcount(pOvfl.pDbPage) != 1 - ) { - /* There is no reason any cursor should have an outstanding reference - ** to an overflow page belonging to a cell that is being deleted/updated. - ** So if there exists more than one reference to this page, then it - ** must not really be an overflow page and the database must be corrupt. - ** It is helpful to detect this before calling freePage2(), as - ** freePage2() may zero the page contents if secure-delete mode is - ** enabled. If this 'overflow' page happens to be a page that the - ** caller is iterating through or using in some other way, this - ** can be problematic. - */ - rc = SQLITE_CORRUPT_BKPT(); - } else { - rc = freePage2(pBt, pOvfl, ovflPgno); - } - if (pOvfl != null) { - sqlite3PagerUnref(pOvfl.pDbPage); - } - if (rc != 0) - return rc; - ovflPgno = iNext; - } - return SQLITE_OK; - } + if ( ( pOvfl != null || ( ( pOvfl = btreePageLookup( pBt, ovflPgno ) ) != null ) ) + && sqlite3PagerPageRefcount( pOvfl.pDbPage ) != 1 + ) + { + /* There is no reason any cursor should have an outstanding reference + ** to an overflow page belonging to a cell that is being deleted/updated. + ** So if there exists more than one reference to this page, then it + ** must not really be an overflow page and the database must be corrupt. + ** It is helpful to detect this before calling freePage2(), as + ** freePage2() may zero the page contents if secure-delete mode is + ** enabled. If this 'overflow' page happens to be a page that the + ** caller is iterating through or using in some other way, this + ** can be problematic. + */ + rc = SQLITE_CORRUPT_BKPT(); + } + else + { + rc = freePage2( pBt, pOvfl, ovflPgno ); + } + if ( pOvfl != null ) + { + sqlite3PagerUnref( pOvfl.pDbPage ); + } + if ( rc != 0 ) + return rc; + ovflPgno = iNext; + } + return SQLITE_OK; +} - /* - ** Create the byte sequence used to represent a cell on page pPage - ** and write that byte sequence into pCell[]. Overflow pages are - ** allocated and filled in as necessary. The calling procedure - ** is responsible for making sure sufficient space has been allocated - ** for pCell[]. - ** - ** Note that pCell does not necessary need to point to the pPage.aData - ** area. pCell might point to some temporary storage. The cell will - ** be constructed in this temporary area then copied into pPage.aData - ** later. - */ - static int fillInCell( - MemPage pPage, /* The page that contains the cell */ - byte[] pCell, /* Complete text of the cell */ - byte[] pKey, i64 nKey, /* The key */ - byte[] pData, int nData, /* The data */ - int nZero, /* Extra zero bytes to append to pData */ - ref int pnSize /* Write cell size here */ - ) { - int nPayload; - u8[] pSrc; - int pSrcIndex = 0; - int nSrc, n, rc; - int spaceLeft; - MemPage pOvfl = null; - MemPage pToRelease = null; - byte[] pPrior; - int pPriorIndex = 0; - byte[] pPayload; - int pPayloadIndex = 0; - BtShared pBt = pPage.pBt; - Pgno pgnoOvfl = 0; - int nHeader; - CellInfo info = new CellInfo(); - - Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); - - /* pPage is not necessarily writeable since pCell might be auxiliary - ** buffer space that is separate from the pPage buffer area */ - // TODO -- Determine if the following Assert is needed under c# - //Debug.Assert( pCell < pPage.aData || pCell >= &pPage.aData[pBt.pageSize] - // || sqlite3PagerIswriteable(pPage.pDbPage) ); - - /* Fill in the header. */ - nHeader = 0; - if (0 == pPage.leaf) { - nHeader += 4; - } - if (pPage.hasData != 0) { - nHeader += (int)putVarint(pCell, nHeader, (int)(nData + nZero)); //putVarint( pCell[nHeader], nData + nZero ); - } else { - nData = nZero = 0; - } - nHeader += putVarint(pCell, nHeader, (u64)nKey); //putVarint( pCell[nHeader], *(u64*)&nKey ); - btreeParseCellPtr(pPage, pCell, ref info); - Debug.Assert(info.nHeader == nHeader); - Debug.Assert(info.nKey == nKey); - Debug.Assert(info.nData == (u32)(nData + nZero)); - - /* Fill in the payload */ - nPayload = nData + nZero; - if (pPage.intKey != 0) { - pSrc = pData; - nSrc = nData; - nData = 0; - } else { - if (NEVER(nKey > 0x7fffffff || pKey == null)) { - return SQLITE_CORRUPT_BKPT(); - } - nPayload += (int)nKey; - pSrc = pKey; - nSrc = (int)nKey; - } - pnSize = info.nSize; - spaceLeft = info.nLocal; - // pPayload = &pCell[nHeader]; - pPayload = pCell; - pPayloadIndex = nHeader; - // pPrior = &pCell[info.iOverflow]; - pPrior = pCell; - pPriorIndex = info.iOverflow; - - while (nPayload > 0) { - if (spaceLeft == 0) { +/* +** Create the byte sequence used to represent a cell on page pPage +** and write that byte sequence into pCell[]. Overflow pages are +** allocated and filled in as necessary. The calling procedure +** is responsible for making sure sufficient space has been allocated +** for pCell[]. +** +** Note that pCell does not necessary need to point to the pPage.aData +** area. pCell might point to some temporary storage. The cell will +** be constructed in this temporary area then copied into pPage.aData +** later. +*/ +static int fillInCell( +MemPage pPage, /* The page that contains the cell */ +byte[] pCell, /* Complete text of the cell */ +byte[] pKey, i64 nKey, /* The key */ +byte[] pData, int nData, /* The data */ +int nZero, /* Extra zero bytes to append to pData */ +ref int pnSize /* Write cell size here */ +) +{ + int nPayload; + u8[] pSrc; + int pSrcIndex = 0; + int nSrc, n, rc; + int spaceLeft; + MemPage pOvfl = null; + MemPage pToRelease = null; + byte[] pPrior; + int pPriorIndex = 0; + byte[] pPayload; + int pPayloadIndex = 0; + BtShared pBt = pPage.pBt; + Pgno pgnoOvfl = 0; + int nHeader; + CellInfo info = new CellInfo(); + + Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); + + /* pPage is not necessarily writeable since pCell might be auxiliary + ** buffer space that is separate from the pPage buffer area */ + // TODO -- Determine if the following Assert is needed under c# + //Debug.Assert( pCell < pPage.aData || pCell >= &pPage.aData[pBt.pageSize] + // || sqlite3PagerIswriteable(pPage.pDbPage) ); + + /* Fill in the header. */ + nHeader = 0; + if ( 0 == pPage.leaf ) + { + nHeader += 4; + } + if ( pPage.hasData != 0 ) + { + nHeader += (int)putVarint( pCell, nHeader, (int)( nData + nZero ) ); //putVarint( pCell[nHeader], nData + nZero ); + } + else + { + nData = nZero = 0; + } + nHeader += putVarint( pCell, nHeader, (u64)nKey ); //putVarint( pCell[nHeader], *(u64*)&nKey ); + btreeParseCellPtr( pPage, pCell, ref info ); + Debug.Assert( info.nHeader == nHeader ); + Debug.Assert( info.nKey == nKey ); + Debug.Assert( info.nData == (u32)( nData + nZero ) ); + + /* Fill in the payload */ + nPayload = nData + nZero; + if ( pPage.intKey != 0 ) + { + pSrc = pData; + nSrc = nData; + nData = 0; + } + else + { + if ( NEVER( nKey > 0x7fffffff || pKey == null ) ) + { + return SQLITE_CORRUPT_BKPT(); + } + nPayload += (int)nKey; + pSrc = pKey; + nSrc = (int)nKey; + } + pnSize = info.nSize; + spaceLeft = info.nLocal; + // pPayload = &pCell[nHeader]; + pPayload = pCell; + pPayloadIndex = nHeader; + // pPrior = &pCell[info.iOverflow]; + pPrior = pCell; + pPriorIndex = info.iOverflow; + + while ( nPayload > 0 ) + { + if ( spaceLeft == 0 ) + { #if !SQLITE_OMIT_AUTOVACUUM - Pgno pgnoPtrmap = pgnoOvfl; /* Overflow page pointer-map entry page */ - if (pBt.autoVacuum) { - do { - pgnoOvfl++; - } while ( - PTRMAP_ISPAGE(pBt, pgnoOvfl) || pgnoOvfl == PENDING_BYTE_PAGE(pBt) - ); - } + Pgno pgnoPtrmap = pgnoOvfl; /* Overflow page pointer-map entry page */ + if ( pBt.autoVacuum ) + { + do + { + pgnoOvfl++; + } while ( + PTRMAP_ISPAGE( pBt, pgnoOvfl ) || pgnoOvfl == PENDING_BYTE_PAGE( pBt ) + ); + } #endif - rc = allocateBtreePage(pBt, ref pOvfl, ref pgnoOvfl, pgnoOvfl, 0); + rc = allocateBtreePage( pBt, ref pOvfl, ref pgnoOvfl, pgnoOvfl, 0 ); #if !SQLITE_OMIT_AUTOVACUUM - /* If the database supports auto-vacuum, and the second or subsequent - ** overflow page is being allocated, add an entry to the pointer-map - ** for that page now. - ** - ** If this is the first overflow page, then write a partial entry - ** to the pointer-map. If we write nothing to this pointer-map slot, - ** then the optimistic overflow chain processing in clearCell() - ** may misinterpret the uninitialised values and delete the - ** wrong pages from the database. - */ - if (pBt.autoVacuum && rc == SQLITE_OK) { - u8 eType = (u8)(pgnoPtrmap != 0 ? PTRMAP_OVERFLOW2 : PTRMAP_OVERFLOW1); - ptrmapPut(pBt, pgnoOvfl, eType, pgnoPtrmap, ref rc); - if (rc != 0) { - releasePage(pOvfl); - } - } + /* If the database supports auto-vacuum, and the second or subsequent +** overflow page is being allocated, add an entry to the pointer-map +** for that page now. +** +** If this is the first overflow page, then write a partial entry +** to the pointer-map. If we write nothing to this pointer-map slot, +** then the optimistic overflow chain processing in clearCell() +** may misinterpret the uninitialised values and delete the +** wrong pages from the database. +*/ + if ( pBt.autoVacuum && rc == SQLITE_OK ) + { + u8 eType = (u8)( pgnoPtrmap != 0 ? PTRMAP_OVERFLOW2 : PTRMAP_OVERFLOW1 ); + ptrmapPut( pBt, pgnoOvfl, eType, pgnoPtrmap, ref rc ); + if ( rc != 0 ) + { + releasePage( pOvfl ); + } + } #endif - if (rc != 0) { - releasePage(pToRelease); - return rc; - } - - /* If pToRelease is not zero than pPrior points into the data area - ** of pToRelease. Make sure pToRelease is still writeable. */ - Debug.Assert(pToRelease == null || sqlite3PagerIswriteable(pToRelease.pDbPage)); - - /* If pPrior is part of the data area of pPage, then make sure pPage - ** is still writeable */ - // TODO -- Determine if the following Assert is needed under c# - //Debug.Assert( pPrior < pPage.aData || pPrior >= &pPage.aData[pBt.pageSize] - // || sqlite3PagerIswriteable(pPage.pDbPage) ); - - sqlite3Put4byte(pPrior, pPriorIndex, pgnoOvfl); - releasePage(pToRelease); - pToRelease = pOvfl; - pPrior = pOvfl.aData; - pPriorIndex = 0; - sqlite3Put4byte(pPrior, 0); - pPayload = pOvfl.aData; - pPayloadIndex = 4; //&pOvfl.aData[4]; - spaceLeft = (int)pBt.usableSize - 4; - } - n = nPayload; - if (n > spaceLeft) - n = spaceLeft; - - /* If pToRelease is not zero than pPayload points into the data area - ** of pToRelease. Make sure pToRelease is still writeable. */ - Debug.Assert(pToRelease == null || sqlite3PagerIswriteable(pToRelease.pDbPage)); - - /* If pPayload is part of the data area of pPage, then make sure pPage - ** is still writeable */ - // TODO -- Determine if the following Assert is needed under c# - //Debug.Assert( pPayload < pPage.aData || pPayload >= &pPage.aData[pBt.pageSize] - // || sqlite3PagerIswriteable(pPage.pDbPage) ); - - if (nSrc > 0) { - if (n > nSrc) - n = nSrc; - Debug.Assert(pSrc != null); - Buffer.BlockCopy(pSrc, pSrcIndex, pPayload, pPayloadIndex, n);//memcpy(pPayload, pSrc, n); - } else { - byte[] pZeroBlob = sqlite3Malloc(n); // memset(pPayload, 0, n); - Buffer.BlockCopy(pZeroBlob, 0, pPayload, pPayloadIndex, n); - } - nPayload -= n; - pPayloadIndex += n;// pPayload += n; - pSrcIndex += n;// pSrc += n; - nSrc -= n; - spaceLeft -= n; - if (nSrc == 0) { - nSrc = nData; - pSrc = pData; - } - } - releasePage(pToRelease); - return SQLITE_OK; - } + if ( rc != 0 ) + { + releasePage( pToRelease ); + return rc; + } + + /* If pToRelease is not zero than pPrior points into the data area + ** of pToRelease. Make sure pToRelease is still writeable. */ + Debug.Assert( pToRelease == null || sqlite3PagerIswriteable( pToRelease.pDbPage ) ); + + /* If pPrior is part of the data area of pPage, then make sure pPage + ** is still writeable */ + // TODO -- Determine if the following Assert is needed under c# + //Debug.Assert( pPrior < pPage.aData || pPrior >= &pPage.aData[pBt.pageSize] + // || sqlite3PagerIswriteable(pPage.pDbPage) ); + + sqlite3Put4byte( pPrior, pPriorIndex, pgnoOvfl ); + releasePage( pToRelease ); + pToRelease = pOvfl; + pPrior = pOvfl.aData; + pPriorIndex = 0; + sqlite3Put4byte( pPrior, 0 ); + pPayload = pOvfl.aData; + pPayloadIndex = 4; //&pOvfl.aData[4]; + spaceLeft = (int)pBt.usableSize - 4; + } + n = nPayload; + if ( n > spaceLeft ) + n = spaceLeft; - /* - ** Remove the i-th cell from pPage. This routine effects pPage only. - ** The cell content is not freed or deallocated. It is assumed that - ** the cell content has been copied someplace else. This routine just - ** removes the reference to the cell from pPage. - ** - ** "sz" must be the number of bytes in the cell. - */ - static void dropCell(MemPage pPage, int idx, int sz, ref int pRC) { - u32 pc; /* Offset to cell content of cell being deleted */ - u8[] data; /* pPage.aData */ - int ptr; /* Used to move bytes around within data[] */ - int endPtr; /* End of loop */ - int rc; /* The return code */ - int hdr; /* Beginning of the header. 0 most pages. 100 page 1 */ - - if (pRC != 0) - return; - - Debug.Assert(idx >= 0 && idx < pPage.nCell); + /* If pToRelease is not zero than pPayload points into the data area + ** of pToRelease. Make sure pToRelease is still writeable. */ + Debug.Assert( pToRelease == null || sqlite3PagerIswriteable( pToRelease.pDbPage ) ); + + /* If pPayload is part of the data area of pPage, then make sure pPage + ** is still writeable */ + // TODO -- Determine if the following Assert is needed under c# + //Debug.Assert( pPayload < pPage.aData || pPayload >= &pPage.aData[pBt.pageSize] + // || sqlite3PagerIswriteable(pPage.pDbPage) ); + + if ( nSrc > 0 ) + { + if ( n > nSrc ) + n = nSrc; + Debug.Assert( pSrc != null ); + Buffer.BlockCopy( pSrc, pSrcIndex, pPayload, pPayloadIndex, n );//memcpy(pPayload, pSrc, n); + } + else + { + byte[] pZeroBlob = sqlite3Malloc( n ); // memset(pPayload, 0, n); + Buffer.BlockCopy( pZeroBlob, 0, pPayload, pPayloadIndex, n ); + } + nPayload -= n; + pPayloadIndex += n;// pPayload += n; + pSrcIndex += n;// pSrc += n; + nSrc -= n; + spaceLeft -= n; + if ( nSrc == 0 ) + { + nSrc = nData; + pSrc = pData; + } + } + releasePage( pToRelease ); + return SQLITE_OK; +} + +/* +** Remove the i-th cell from pPage. This routine effects pPage only. +** The cell content is not freed or deallocated. It is assumed that +** the cell content has been copied someplace else. This routine just +** removes the reference to the cell from pPage. +** +** "sz" must be the number of bytes in the cell. +*/ +static void dropCell( MemPage pPage, int idx, int sz, ref int pRC ) +{ + u32 pc; /* Offset to cell content of cell being deleted */ + u8[] data; /* pPage.aData */ + int ptr; /* Used to move bytes around within data[] */ + int endPtr; /* End of loop */ + int rc; /* The return code */ + int hdr; /* Beginning of the header. 0 most pages. 100 page 1 */ + + if ( pRC != 0 ) + return; + + Debug.Assert( idx >= 0 && idx < pPage.nCell ); #if SQLITE_DEBUG - Debug.Assert(sz == cellSize(pPage, idx)); + Debug.Assert( sz == cellSize( pPage, idx ) ); #endif - Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); - Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); - data = pPage.aData; - ptr = pPage.cellOffset + 2 * idx; //ptr = &data[pPage.cellOffset + 2 * idx]; - pc = (u32)get2byte(data, ptr); - hdr = pPage.hdrOffset; - testcase(pc == get2byte(data, hdr + 5)); - testcase(pc + sz == pPage.pBt.usableSize); - if (pc < (u32)get2byte(data, hdr + 5) || pc + sz > pPage.pBt.usableSize) { - pRC = SQLITE_CORRUPT_BKPT(); - return; - } - rc = freeSpace(pPage, pc, sz); - if (rc != 0) { - pRC = rc; - return; - } - //endPtr = &data[pPage->cellOffset + 2*pPage->nCell - 2]; - //assert( (SQLITE_PTR_TO_INT(ptr)&1)==0 ); /* ptr is always 2-byte aligned */ - //while( ptr> 8); - data[pPage.hdrOffset + 4] = (byte)(pPage.nCell); //put2byte( data, hdr + 3, pPage.nCell ); - pPage.nFree += 2; - } + Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); + Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); + data = pPage.aData; + ptr = pPage.cellOffset + 2 * idx; //ptr = &data[pPage.cellOffset + 2 * idx]; + pc = (u32)get2byte( data, ptr ); + hdr = pPage.hdrOffset; + testcase( pc == get2byte( data, hdr + 5 ) ); + testcase( pc + sz == pPage.pBt.usableSize ); + if ( pc < (u32)get2byte( data, hdr + 5 ) || pc + sz > pPage.pBt.usableSize ) + { + pRC = SQLITE_CORRUPT_BKPT(); + return; + } + rc = freeSpace( pPage, pc, sz ); + if ( rc != 0 ) + { + pRC = rc; + return; + } + //endPtr = &data[pPage->cellOffset + 2*pPage->nCell - 2]; + //assert( (SQLITE_PTR_TO_INT(ptr)&1)==0 ); /* ptr is always 2-byte aligned */ + //while( ptr> 8 ); + data[pPage.hdrOffset + 4] = (byte)( pPage.nCell ); //put2byte( data, hdr + 3, pPage.nCell ); + pPage.nFree += 2; +} - /* - ** Insert a new cell on pPage at cell index "i". pCell points to the - ** content of the cell. - ** - ** If the cell content will fit on the page, then put it there. If it - ** will not fit, then make a copy of the cell content into pTemp if - ** pTemp is not null. Regardless of pTemp, allocate a new entry - ** in pPage.aOvfl[] and make it point to the cell content (either - ** in pTemp or the original pCell) and also record its index. - ** Allocating a new entry in pPage.aCell[] implies that - ** pPage.nOverflow is incremented. - ** - ** If nSkip is non-zero, then do not copy the first nSkip bytes of the - ** cell. The caller will overwrite them after this function returns. If - ** nSkip is non-zero, then pCell may not point to an invalid memory location - ** (but pCell+nSkip is always valid). - */ - static void insertCell( - MemPage pPage, /* Page into which we are copying */ - int i, /* New cell becomes the i-th cell of the page */ - u8[] pCell, /* Content of the new cell */ - int sz, /* Bytes of content in pCell */ - u8[] pTemp, /* Temp storage space for pCell, if needed */ - Pgno iChild, /* If non-zero, replace first 4 bytes with this value */ - ref int pRC /* Read and write return code from here */ - ) { - int idx = 0; /* Where to write new cell content in data[] */ - int j; /* Loop counter */ - int end; /* First byte past the last cell pointer in data[] */ - int ins; /* Index in data[] where new cell pointer is inserted */ - int cellOffset; /* Address of first cell pointer in data[] */ - u8[] data; /* The content of the whole page */ - u8 ptr; /* Used for moving information around in data[] */ - u8 endPtr; /* End of the loop */ - - int nSkip = (iChild != 0 ? 4 : 0); - - if (pRC != 0) - return; - - Debug.Assert(i >= 0 && i <= pPage.nCell + pPage.nOverflow); - Debug.Assert(pPage.nCell <= MX_CELL(pPage.pBt) && MX_CELL(pPage.pBt) <= 10921); - Debug.Assert(pPage.nOverflow <= ArraySize(pPage.aOvfl)); - Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); - /* The cell should normally be sized correctly. However, when moving a - ** malformed cell from a leaf page to an interior page, if the cell size - ** wanted to be less than 4 but got rounded up to 4 on the leaf, then size - ** might be less than 8 (leaf-size + pointer) on the interior node. Hence - ** the term after the || in the following assert(). */ - Debug.Assert(sz == cellSizePtr(pPage, pCell) || (sz == 8 && iChild > 0)); - if (pPage.nOverflow != 0 || sz + 2 > pPage.nFree) { - if (pTemp != null) { - Buffer.BlockCopy(pCell, nSkip, pTemp, nSkip, sz - nSkip);//memcpy(pTemp+nSkip, pCell+nSkip, sz-nSkip); - pCell = pTemp; - } - if (iChild != 0) { - sqlite3Put4byte(pCell, iChild); - } - j = pPage.nOverflow++; - Debug.Assert(j < pPage.aOvfl.Length);//(int)(sizeof(pPage.aOvfl)/sizeof(pPage.aOvfl[0])) ); - pPage.aOvfl[j].pCell = pCell; - pPage.aOvfl[j].idx = (u16)i; - } else { - int rc = sqlite3PagerWrite(pPage.pDbPage); - if (rc != SQLITE_OK) { - pRC = rc; - return; - } - Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); - data = pPage.aData; - cellOffset = pPage.cellOffset; - end = cellOffset + 2 * pPage.nCell; - ins = cellOffset + 2 * i; - rc = allocateSpace(pPage, sz, ref idx); - if (rc != 0) { - pRC = rc; - return; - } - /* The allocateSpace() routine guarantees the following two properties - ** if it returns success */ - Debug.Assert(idx >= end + 2); - Debug.Assert(idx + sz <= (int)pPage.pBt.usableSize); - pPage.nCell++; - pPage.nFree -= (u16)(2 + sz); - Buffer.BlockCopy(pCell, nSkip, data, idx + nSkip, sz - nSkip); //memcpy( data[idx + nSkip], pCell + nSkip, sz - nSkip ); - if (iChild != 0) { - sqlite3Put4byte(data, idx, iChild); - } - //ptr = &data[end]; - //endPtr = &data[ins]; - //assert( ( SQLITE_PTR_TO_INT( ptr ) & 1 ) == 0 ); /* ptr is always 2-byte aligned */ - //while ( ptr > endPtr ) - //{ - // *(u16*)ptr = *(u16*)&ptr[-2]; - // ptr -= 2; - //} - for (j = end; j > ins; j -= 2) { - data[j + 0] = data[j - 2]; - data[j + 1] = data[j - 1]; - } - put2byte(data, ins, idx); - put2byte(data, pPage.hdrOffset + 3, pPage.nCell); +/* +** Insert a new cell on pPage at cell index "i". pCell points to the +** content of the cell. +** +** If the cell content will fit on the page, then put it there. If it +** will not fit, then make a copy of the cell content into pTemp if +** pTemp is not null. Regardless of pTemp, allocate a new entry +** in pPage.aOvfl[] and make it point to the cell content (either +** in pTemp or the original pCell) and also record its index. +** Allocating a new entry in pPage.aCell[] implies that +** pPage.nOverflow is incremented. +** +** If nSkip is non-zero, then do not copy the first nSkip bytes of the +** cell. The caller will overwrite them after this function returns. If +** nSkip is non-zero, then pCell may not point to an invalid memory location +** (but pCell+nSkip is always valid). +*/ +static void insertCell( +MemPage pPage, /* Page into which we are copying */ +int i, /* New cell becomes the i-th cell of the page */ +u8[] pCell, /* Content of the new cell */ +int sz, /* Bytes of content in pCell */ +u8[] pTemp, /* Temp storage space for pCell, if needed */ +Pgno iChild, /* If non-zero, replace first 4 bytes with this value */ +ref int pRC /* Read and write return code from here */ +) +{ + int idx = 0; /* Where to write new cell content in data[] */ + int j; /* Loop counter */ + int end; /* First byte past the last cell pointer in data[] */ + int ins; /* Index in data[] where new cell pointer is inserted */ + int cellOffset; /* Address of first cell pointer in data[] */ + u8[] data; /* The content of the whole page */ + u8 ptr; /* Used for moving information around in data[] */ + u8 endPtr; /* End of the loop */ + + int nSkip = ( iChild != 0 ? 4 : 0 ); + + if ( pRC != 0 ) + return; + + Debug.Assert( i >= 0 && i <= pPage.nCell + pPage.nOverflow ); + Debug.Assert( pPage.nCell <= MX_CELL( pPage.pBt ) && MX_CELL( pPage.pBt ) <= 10921 ); + Debug.Assert( pPage.nOverflow <= ArraySize( pPage.aOvfl ) ); + Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); + /* The cell should normally be sized correctly. However, when moving a + ** malformed cell from a leaf page to an interior page, if the cell size + ** wanted to be less than 4 but got rounded up to 4 on the leaf, then size + ** might be less than 8 (leaf-size + pointer) on the interior node. Hence + ** the term after the || in the following assert(). */ + Debug.Assert( sz == cellSizePtr( pPage, pCell ) || ( sz == 8 && iChild > 0 ) ); + if ( pPage.nOverflow != 0 || sz + 2 > pPage.nFree ) + { + if ( pTemp != null ) + { + Buffer.BlockCopy( pCell, nSkip, pTemp, nSkip, sz - nSkip );//memcpy(pTemp+nSkip, pCell+nSkip, sz-nSkip); + pCell = pTemp; + } + if ( iChild != 0 ) + { + sqlite3Put4byte( pCell, iChild ); + } + j = pPage.nOverflow++; + Debug.Assert( j < pPage.aOvfl.Length );//(int)(sizeof(pPage.aOvfl)/sizeof(pPage.aOvfl[0])) ); + pPage.aOvfl[j].pCell = pCell; + pPage.aOvfl[j].idx = (u16)i; + } + else + { + int rc = sqlite3PagerWrite( pPage.pDbPage ); + if ( rc != SQLITE_OK ) + { + pRC = rc; + return; + } + Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); + data = pPage.aData; + cellOffset = pPage.cellOffset; + end = cellOffset + 2 * pPage.nCell; + ins = cellOffset + 2 * i; + rc = allocateSpace( pPage, sz, ref idx ); + if ( rc != 0 ) + { + pRC = rc; + return; + } + /* The allocateSpace() routine guarantees the following two properties + ** if it returns success */ + Debug.Assert( idx >= end + 2 ); + Debug.Assert( idx + sz <= (int)pPage.pBt.usableSize ); + pPage.nCell++; + pPage.nFree -= (u16)( 2 + sz ); + Buffer.BlockCopy( pCell, nSkip, data, idx + nSkip, sz - nSkip ); //memcpy( data[idx + nSkip], pCell + nSkip, sz - nSkip ); + if ( iChild != 0 ) + { + sqlite3Put4byte( data, idx, iChild ); + } + //ptr = &data[end]; + //endPtr = &data[ins]; + //assert( ( SQLITE_PTR_TO_INT( ptr ) & 1 ) == 0 ); /* ptr is always 2-byte aligned */ + //while ( ptr > endPtr ) + //{ + // *(u16*)ptr = *(u16*)&ptr[-2]; + // ptr -= 2; + //} + for ( j = end; j > ins; j -= 2 ) + { + data[j + 0] = data[j - 2]; + data[j + 1] = data[j - 1]; + } + put2byte( data, ins, idx ); + put2byte( data, pPage.hdrOffset + 3, pPage.nCell ); #if !SQLITE_OMIT_AUTOVACUUM - if (pPage.pBt.autoVacuum) { - /* The cell may contain a pointer to an overflow page. If so, write - ** the entry for the overflow page into the pointer map. - */ - ptrmapPutOvflPtr(pPage, pCell, ref pRC); - } + if ( pPage.pBt.autoVacuum ) + { + /* The cell may contain a pointer to an overflow page. If so, write + ** the entry for the overflow page into the pointer map. + */ + ptrmapPutOvflPtr( pPage, pCell, ref pRC ); + } #endif - } - } + } +} - /* - ** Add a list of cells to a page. The page should be initially empty. - ** The cells are guaranteed to fit on the page. - */ - static void assemblePage( - MemPage pPage, /* The page to be assemblied */ - int nCell, /* The number of cells to add to this page */ - u8[] apCell, /* Pointer to a single the cell bodies */ - int[] aSize /* Sizes of the cells bodie*/ - ) { - int i; /* Loop counter */ - int pCellptr; /* Address of next cell pointer */ - int cellbody; /* Address of next cell body */ - byte[] data = pPage.aData; /* Pointer to data for pPage */ - int hdr = pPage.hdrOffset; /* Offset of header on pPage */ - int nUsable = (int)pPage.pBt.usableSize; /* Usable size of page */ - - Debug.Assert(pPage.nOverflow == 0); - Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); - Debug.Assert(nCell >= 0 && nCell <= (int)MX_CELL(pPage.pBt) - && (int)MX_CELL(pPage.pBt) <= 10921); - - Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); - - /* Check that the page has just been zeroed by zeroPage() */ - Debug.Assert(pPage.nCell == 0); - Debug.Assert(get2byteNotZero(data, hdr + 5) == nUsable); - - pCellptr = pPage.cellOffset + nCell * 2; //data[pPage.cellOffset + nCell * 2]; - cellbody = nUsable; - for (i = nCell - 1; i >= 0; i--) { - u16 sz = (u16)aSize[i]; - pCellptr -= 2; - cellbody -= sz; - put2byte(data, pCellptr, cellbody); - Buffer.BlockCopy(apCell, 0, data, cellbody, sz);// memcpy(&data[cellbody], apCell[i], sz); - } - put2byte(data, hdr + 3, nCell); - put2byte(data, hdr + 5, cellbody); - pPage.nFree -= (u16)(nCell * 2 + nUsable - cellbody); - pPage.nCell = (u16)nCell; - } - static void assemblePage( - MemPage pPage, /* The page to be assemblied */ - int nCell, /* The number of cells to add to this page */ - u8[][] apCell, /* Pointers to cell bodies */ - u16[] aSize, /* Sizes of the cells */ - int offset /* Offset into the cell bodies, for c# */ - ) { - int i; /* Loop counter */ - int pCellptr; /* Address of next cell pointer */ - int cellbody; /* Address of next cell body */ - byte[] data = pPage.aData; /* Pointer to data for pPage */ - int hdr = pPage.hdrOffset; /* Offset of header on pPage */ - int nUsable = (int)pPage.pBt.usableSize; /* Usable size of page */ - - Debug.Assert(pPage.nOverflow == 0); - Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); - Debug.Assert(nCell >= 0 && nCell <= MX_CELL(pPage.pBt) && MX_CELL(pPage.pBt) <= 5460); - Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); - - /* Check that the page has just been zeroed by zeroPage() */ - Debug.Assert(pPage.nCell == 0); - Debug.Assert(get2byte(data, hdr + 5) == nUsable); - - pCellptr = pPage.cellOffset + nCell * 2; //data[pPage.cellOffset + nCell * 2]; - cellbody = nUsable; - for (i = nCell - 1; i >= 0; i--) { - pCellptr -= 2; - cellbody -= aSize[i + offset]; - put2byte(data, pCellptr, cellbody); - Buffer.BlockCopy(apCell[offset + i], 0, data, cellbody, aSize[i + offset]);// memcpy(&data[cellbody], apCell[i], aSize[i]); - } - put2byte(data, hdr + 3, nCell); - put2byte(data, hdr + 5, cellbody); - pPage.nFree -= (u16)(nCell * 2 + nUsable - cellbody); - pPage.nCell = (u16)nCell; - } +/* +** Add a list of cells to a page. The page should be initially empty. +** The cells are guaranteed to fit on the page. +*/ +static void assemblePage( +MemPage pPage, /* The page to be assemblied */ +int nCell, /* The number of cells to add to this page */ +u8[] apCell, /* Pointer to a single the cell bodies */ +int[] aSize /* Sizes of the cells bodie*/ +) +{ + int i; /* Loop counter */ + int pCellptr; /* Address of next cell pointer */ + int cellbody; /* Address of next cell body */ + byte[] data = pPage.aData; /* Pointer to data for pPage */ + int hdr = pPage.hdrOffset; /* Offset of header on pPage */ + int nUsable = (int)pPage.pBt.usableSize; /* Usable size of page */ + + Debug.Assert( pPage.nOverflow == 0 ); + Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); + Debug.Assert( nCell >= 0 && nCell <= (int)MX_CELL( pPage.pBt ) + && (int)MX_CELL( pPage.pBt ) <= 10921 ); + + Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); + + /* Check that the page has just been zeroed by zeroPage() */ + Debug.Assert( pPage.nCell == 0 ); + Debug.Assert( get2byteNotZero( data, hdr + 5 ) == nUsable ); + + pCellptr = pPage.cellOffset + nCell * 2; //data[pPage.cellOffset + nCell * 2]; + cellbody = nUsable; + for ( i = nCell - 1; i >= 0; i-- ) + { + u16 sz = (u16)aSize[i]; + pCellptr -= 2; + cellbody -= sz; + put2byte( data, pCellptr, cellbody ); + Buffer.BlockCopy( apCell, 0, data, cellbody, sz );// memcpy(&data[cellbody], apCell[i], sz); + } + put2byte( data, hdr + 3, nCell ); + put2byte( data, hdr + 5, cellbody ); + pPage.nFree -= (u16)( nCell * 2 + nUsable - cellbody ); + pPage.nCell = (u16)nCell; +} +static void assemblePage( +MemPage pPage, /* The page to be assemblied */ +int nCell, /* The number of cells to add to this page */ +u8[][] apCell, /* Pointers to cell bodies */ +u16[] aSize, /* Sizes of the cells */ +int offset /* Offset into the cell bodies, for c# */ +) +{ + int i; /* Loop counter */ + int pCellptr; /* Address of next cell pointer */ + int cellbody; /* Address of next cell body */ + byte[] data = pPage.aData; /* Pointer to data for pPage */ + int hdr = pPage.hdrOffset; /* Offset of header on pPage */ + int nUsable = (int)pPage.pBt.usableSize; /* Usable size of page */ + + Debug.Assert( pPage.nOverflow == 0 ); + Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); + Debug.Assert( nCell >= 0 && nCell <= MX_CELL( pPage.pBt ) && MX_CELL( pPage.pBt ) <= 5460 ); + Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); + + /* Check that the page has just been zeroed by zeroPage() */ + Debug.Assert( pPage.nCell == 0 ); + Debug.Assert( get2byte( data, hdr + 5 ) == nUsable ); + + pCellptr = pPage.cellOffset + nCell * 2; //data[pPage.cellOffset + nCell * 2]; + cellbody = nUsable; + for ( i = nCell - 1; i >= 0; i-- ) + { + pCellptr -= 2; + cellbody -= aSize[i + offset]; + put2byte( data, pCellptr, cellbody ); + Buffer.BlockCopy( apCell[offset + i], 0, data, cellbody, aSize[i + offset] );// memcpy(&data[cellbody], apCell[i], aSize[i]); + } + put2byte( data, hdr + 3, nCell ); + put2byte( data, hdr + 5, cellbody ); + pPage.nFree -= (u16)( nCell * 2 + nUsable - cellbody ); + pPage.nCell = (u16)nCell; +} - static void assemblePage( - MemPage pPage, /* The page to be assemblied */ - int nCell, /* The number of cells to add to this page */ - u8[] apCell, /* Pointers to cell bodies */ - u16[] aSize /* Sizes of the cells */ - ) { - int i; /* Loop counter */ - int pCellptr; /* Address of next cell pointer */ - int cellbody; /* Address of next cell body */ - u8[] data = pPage.aData; /* Pointer to data for pPage */ - int hdr = pPage.hdrOffset; /* Offset of header on pPage */ - int nUsable = (int)pPage.pBt.usableSize; /* Usable size of page */ - - Debug.Assert(pPage.nOverflow == 0); - Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); - Debug.Assert(nCell >= 0 && nCell <= MX_CELL(pPage.pBt) && MX_CELL(pPage.pBt) <= 5460); - Debug.Assert(sqlite3PagerIswriteable(pPage.pDbPage)); - - /* Check that the page has just been zeroed by zeroPage() */ - Debug.Assert(pPage.nCell == 0); - Debug.Assert(get2byte(data, hdr + 5) == nUsable); - - pCellptr = pPage.cellOffset + nCell * 2; //&data[pPage.cellOffset + nCell * 2]; - cellbody = nUsable; - for (i = nCell - 1; i >= 0; i--) { - pCellptr -= 2; - cellbody -= aSize[i]; - put2byte(data, pCellptr, cellbody); - Buffer.BlockCopy(apCell, 0, data, cellbody, aSize[i]);//memcpy( data[cellbody], apCell[i], aSize[i] ); - } - put2byte(data, hdr + 3, nCell); - put2byte(data, hdr + 5, cellbody); - pPage.nFree -= (u16)(nCell * 2 + nUsable - cellbody); - pPage.nCell = (u16)nCell; - } +static void assemblePage( +MemPage pPage, /* The page to be assemblied */ +int nCell, /* The number of cells to add to this page */ +u8[] apCell, /* Pointers to cell bodies */ +u16[] aSize /* Sizes of the cells */ +) +{ + int i; /* Loop counter */ + int pCellptr; /* Address of next cell pointer */ + int cellbody; /* Address of next cell body */ + u8[] data = pPage.aData; /* Pointer to data for pPage */ + int hdr = pPage.hdrOffset; /* Offset of header on pPage */ + int nUsable = (int)pPage.pBt.usableSize; /* Usable size of page */ + + Debug.Assert( pPage.nOverflow == 0 ); + Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); + Debug.Assert( nCell >= 0 && nCell <= MX_CELL( pPage.pBt ) && MX_CELL( pPage.pBt ) <= 5460 ); + Debug.Assert( sqlite3PagerIswriteable( pPage.pDbPage ) ); + + /* Check that the page has just been zeroed by zeroPage() */ + Debug.Assert( pPage.nCell == 0 ); + Debug.Assert( get2byte( data, hdr + 5 ) == nUsable ); + + pCellptr = pPage.cellOffset + nCell * 2; //&data[pPage.cellOffset + nCell * 2]; + cellbody = nUsable; + for ( i = nCell - 1; i >= 0; i-- ) + { + pCellptr -= 2; + cellbody -= aSize[i]; + put2byte( data, pCellptr, cellbody ); + Buffer.BlockCopy( apCell, 0, data, cellbody, aSize[i] );//memcpy( data[cellbody], apCell[i], aSize[i] ); + } + put2byte( data, hdr + 3, nCell ); + put2byte( data, hdr + 5, cellbody ); + pPage.nFree -= (u16)( nCell * 2 + nUsable - cellbody ); + pPage.nCell = (u16)nCell; +} - /* - ** The following parameters determine how many adjacent pages get involved - ** in a balancing operation. NN is the number of neighbors on either side - ** of the page that participate in the balancing operation. NB is the - ** total number of pages that participate, including the target page and - ** NN neighbors on either side. - ** - ** The minimum value of NN is 1 (of course). Increasing NN above 1 - ** (to 2 or 3) gives a modest improvement in SELECT and DELETE performance - ** in exchange for a larger degradation in INSERT and UPDATE performance. - ** The value of NN appears to give the best results overall. - */ - static int NN = 1; /* Number of neighbors on either side of pPage */ - static int NB = (NN * 2 + 1); /* Total pages involved in the balance */ +/* +** The following parameters determine how many adjacent pages get involved +** in a balancing operation. NN is the number of neighbors on either side +** of the page that participate in the balancing operation. NB is the +** total number of pages that participate, including the target page and +** NN neighbors on either side. +** +** The minimum value of NN is 1 (of course). Increasing NN above 1 +** (to 2 or 3) gives a modest improvement in SELECT and DELETE performance +** in exchange for a larger degradation in INSERT and UPDATE performance. +** The value of NN appears to give the best results overall. +*/ +static int NN = 1; /* Number of neighbors on either side of pPage */ +static int NB = ( NN * 2 + 1 ); /* Total pages involved in the balance */ #if !SQLITE_OMIT_QUICKBALANCE - /* - ** This version of balance() handles the common special case where - ** a new entry is being inserted on the extreme right-end of the - ** tree, in other words, when the new entry will become the largest - ** entry in the tree. - ** - ** Instead of trying to balance the 3 right-most leaf pages, just add - ** a new page to the right-hand side and put the one new entry in - ** that page. This leaves the right side of the tree somewhat - ** unbalanced. But odds are that we will be inserting new entries - ** at the end soon afterwards so the nearly empty page will quickly - ** fill up. On average. - ** - ** pPage is the leaf page which is the right-most page in the tree. - ** pParent is its parent. pPage must have a single overflow entry - ** which is also the right-most entry on the page. - ** - ** The pSpace buffer is used to store a temporary copy of the divider - ** cell that will be inserted into pParent. Such a cell consists of a 4 - ** byte page number followed by a variable length integer. In other - ** words, at most 13 bytes. Hence the pSpace buffer must be at - ** least 13 bytes in size. - */ - static int balance_quick(MemPage pParent, MemPage pPage, u8[] pSpace) { - BtShared pBt = pPage.pBt; /* B-Tree Database */ - MemPage pNew = new MemPage();/* Newly allocated page */ - int rc; /* Return Code */ - Pgno pgnoNew = 0; /* Page number of pNew */ - - Debug.Assert(sqlite3_mutex_held(pPage.pBt.mutex)); - Debug.Assert(sqlite3PagerIswriteable(pParent.pDbPage)); - Debug.Assert(pPage.nOverflow == 1); - - /* This error condition is now caught prior to reaching this function */ - if (pPage.nCell <= 0) - return SQLITE_CORRUPT_BKPT(); - - /* Allocate a new page. This page will become the right-sibling of - ** pPage. Make the parent page writable, so that the new divider cell - ** may be inserted. If both these operations are successful, proceed. - */ - rc = allocateBtreePage(pBt, ref pNew, ref pgnoNew, 0, 0); - - if (rc == SQLITE_OK) { - - int pOut = 4;//u8 pOut = &pSpace[4]; - u8[] pCell = pPage.aOvfl[0].pCell; - int[] szCell = new int[1]; - szCell[0] = cellSizePtr(pPage, pCell); - int pStop; - - Debug.Assert(sqlite3PagerIswriteable(pNew.pDbPage)); - Debug.Assert(pPage.aData[0] == (PTF_INTKEY | PTF_LEAFDATA | PTF_LEAF)); - zeroPage(pNew, PTF_INTKEY | PTF_LEAFDATA | PTF_LEAF); - assemblePage(pNew, 1, pCell, szCell); - - /* If this is an auto-vacuum database, update the pointer map - ** with entries for the new page, and any pointer from the - ** cell on the page to an overflow page. If either of these - ** operations fails, the return code is set, but the contents - ** of the parent page are still manipulated by thh code below. - ** That is Ok, at this point the parent page is guaranteed to - ** be marked as dirty. Returning an error code will cause a - ** rollback, undoing any changes made to the parent page. - */ +/* +** This version of balance() handles the common special case where +** a new entry is being inserted on the extreme right-end of the +** tree, in other words, when the new entry will become the largest +** entry in the tree. +** +** Instead of trying to balance the 3 right-most leaf pages, just add +** a new page to the right-hand side and put the one new entry in +** that page. This leaves the right side of the tree somewhat +** unbalanced. But odds are that we will be inserting new entries +** at the end soon afterwards so the nearly empty page will quickly +** fill up. On average. +** +** pPage is the leaf page which is the right-most page in the tree. +** pParent is its parent. pPage must have a single overflow entry +** which is also the right-most entry on the page. +** +** The pSpace buffer is used to store a temporary copy of the divider +** cell that will be inserted into pParent. Such a cell consists of a 4 +** byte page number followed by a variable length integer. In other +** words, at most 13 bytes. Hence the pSpace buffer must be at +** least 13 bytes in size. +*/ +static int balance_quick( MemPage pParent, MemPage pPage, u8[] pSpace ) +{ + BtShared pBt = pPage.pBt; /* B-Tree Database */ + MemPage pNew = new MemPage();/* Newly allocated page */ + int rc; /* Return Code */ + Pgno pgnoNew = 0; /* Page number of pNew */ + + Debug.Assert( sqlite3_mutex_held( pPage.pBt.mutex ) ); + Debug.Assert( sqlite3PagerIswriteable( pParent.pDbPage ) ); + Debug.Assert( pPage.nOverflow == 1 ); + + /* This error condition is now caught prior to reaching this function */ + if ( pPage.nCell <= 0 ) + return SQLITE_CORRUPT_BKPT(); + + /* Allocate a new page. This page will become the right-sibling of + ** pPage. Make the parent page writable, so that the new divider cell + ** may be inserted. If both these operations are successful, proceed. + */ + rc = allocateBtreePage( pBt, ref pNew, ref pgnoNew, 0, 0 ); + + if ( rc == SQLITE_OK ) + { + + int pOut = 4;//u8 pOut = &pSpace[4]; + u8[] pCell = pPage.aOvfl[0].pCell; + int[] szCell = new int[1]; + szCell[0] = cellSizePtr( pPage, pCell ); + int pStop; + + Debug.Assert( sqlite3PagerIswriteable( pNew.pDbPage ) ); + Debug.Assert( pPage.aData[0] == ( PTF_INTKEY | PTF_LEAFDATA | PTF_LEAF ) ); + zeroPage( pNew, PTF_INTKEY | PTF_LEAFDATA | PTF_LEAF ); + assemblePage( pNew, 1, pCell, szCell ); + + /* If this is an auto-vacuum database, update the pointer map + ** with entries for the new page, and any pointer from the + ** cell on the page to an overflow page. If either of these + ** operations fails, the return code is set, but the contents + ** of the parent page are still manipulated by thh code below. + ** That is Ok, at this point the parent page is guaranteed to + ** be marked as dirty. Returning an error code will cause a + ** rollback, undoing any changes made to the parent page. + */ #if !SQLITE_OMIT_AUTOVACUUM // if ( ISAUTOVACUUM ) - if (pBt.autoVacuum) + if ( pBt.autoVacuum ) #else if (false) #endif - { - ptrmapPut(pBt, pgnoNew, PTRMAP_BTREE, pParent.pgno, ref rc); - if (szCell[0] > pNew.minLocal) { - ptrmapPutOvflPtr(pNew, pCell, ref rc); - } - } - - /* Create a divider cell to insert into pParent. The divider cell - ** consists of a 4-byte page number (the page number of pPage) and - ** a variable length key value (which must be the same value as the - ** largest key on pPage). - ** - ** To find the largest key value on pPage, first find the right-most - ** cell on pPage. The first two fields of this cell are the - ** record-length (a variable length integer at most 32-bits in size) - ** and the key value (a variable length integer, may have any value). - ** The first of the while(...) loops below skips over the record-length - ** field. The second while(...) loop copies the key value from the - ** cell on pPage into the pSpace buffer. - */ - int iCell = findCell(pPage, pPage.nCell - 1); //pCell = findCell( pPage, pPage.nCell - 1 ); - pCell = pPage.aData; - int _pCell = iCell; - pStop = _pCell + 9; //pStop = &pCell[9]; - while (((pCell[_pCell++]) & 0x80) != 0 && _pCell < pStop) - ; //while ( ( *( pCell++ ) & 0x80 ) && pCell < pStop ) ; - pStop = _pCell + 9;//pStop = &pCell[9]; - while (((pSpace[pOut++] = pCell[_pCell++]) & 0x80) != 0 && _pCell < pStop) - ; //while ( ( ( *( pOut++ ) = *( pCell++ ) ) & 0x80 ) && pCell < pStop ) ; - - /* Insert the new divider cell into pParent. */ - insertCell(pParent, pParent.nCell, pSpace, pOut, //(int)(pOut-pSpace), - null, pPage.pgno, ref rc); - - /* Set the right-child pointer of pParent to point to the new page. */ - sqlite3Put4byte(pParent.aData, pParent.hdrOffset + 8, pgnoNew); - - /* Release the reference to the new page. */ - releasePage(pNew); - } + { + ptrmapPut( pBt, pgnoNew, PTRMAP_BTREE, pParent.pgno, ref rc ); + if ( szCell[0] > pNew.minLocal ) + { + ptrmapPutOvflPtr( pNew, pCell, ref rc ); + } + } - return rc; - } + /* Create a divider cell to insert into pParent. The divider cell + ** consists of a 4-byte page number (the page number of pPage) and + ** a variable length key value (which must be the same value as the + ** largest key on pPage). + ** + ** To find the largest key value on pPage, first find the right-most + ** cell on pPage. The first two fields of this cell are the + ** record-length (a variable length integer at most 32-bits in size) + ** and the key value (a variable length integer, may have any value). + ** The first of the while(...) loops below skips over the record-length + ** field. The second while(...) loop copies the key value from the + ** cell on pPage into the pSpace buffer. + */ + int iCell = findCell( pPage, pPage.nCell - 1 ); //pCell = findCell( pPage, pPage.nCell - 1 ); + pCell = pPage.aData; + int _pCell = iCell; + pStop = _pCell + 9; //pStop = &pCell[9]; + while ( ( ( pCell[_pCell++] ) & 0x80 ) != 0 && _pCell < pStop ) + ; //while ( ( *( pCell++ ) & 0x80 ) && pCell < pStop ) ; + pStop = _pCell + 9;//pStop = &pCell[9]; + while ( ( ( pSpace[pOut++] = pCell[_pCell++] ) & 0x80 ) != 0 && _pCell < pStop ) + ; //while ( ( ( *( pOut++ ) = *( pCell++ ) ) & 0x80 ) && pCell < pStop ) ; + + /* Insert the new divider cell into pParent. */ + insertCell( pParent, pParent.nCell, pSpace, pOut, //(int)(pOut-pSpace), + null, pPage.pgno, ref rc ); + + /* Set the right-child pointer of pParent to point to the new page. */ + sqlite3Put4byte( pParent.aData, pParent.hdrOffset + 8, pgnoNew ); + + /* Release the reference to the new page. */ + releasePage( pNew ); + } + + return rc; +} #endif //* SQLITE_OMIT_QUICKBALANCE */ #if FALSE @@ -6111,746 +6731,815 @@ static int ptrmapCheckPages(MemPage **apPage, int nPage){ } #endif - /* - ** This function is used to copy the contents of the b-tree node stored - ** on page pFrom to page pTo. If page pFrom was not a leaf page, then - ** the pointer-map entries for each child page are updated so that the - ** parent page stored in the pointer map is page pTo. If pFrom contained - ** any cells with overflow page pointers, then the corresponding pointer - ** map entries are also updated so that the parent page is page pTo. - ** - ** If pFrom is currently carrying any overflow cells (entries in the - ** MemPage.aOvfl[] array), they are not copied to pTo. - ** - ** Before returning, page pTo is reinitialized using btreeInitPage(). - ** - ** The performance of this function is not critical. It is only used by - ** the balance_shallower() and balance_deeper() procedures, neither of - ** which are called often under normal circumstances. - */ - static void copyNodeContent(MemPage pFrom, MemPage pTo, ref int pRC) { - if ((pRC) == SQLITE_OK) { - BtShared pBt = pFrom.pBt; - u8[] aFrom = pFrom.aData; - u8[] aTo = pTo.aData; - int iFromHdr = pFrom.hdrOffset; - int iToHdr = ((pTo.pgno == 1) ? 100 : 0); - int rc; - int iData; - - - Debug.Assert(pFrom.isInit != 0); - Debug.Assert(pFrom.nFree >= iToHdr); - Debug.Assert(get2byte(aFrom, iFromHdr + 5) <= (int)pBt.usableSize); - - /* Copy the b-tree node content from page pFrom to page pTo. */ - iData = get2byte(aFrom, iFromHdr + 5); - Buffer.BlockCopy(aFrom, iData, aTo, iData, (int)pBt.usableSize - iData);//memcpy(aTo[iData], ref aFrom[iData], pBt.usableSize-iData); - Buffer.BlockCopy(aFrom, iFromHdr, aTo, iToHdr, pFrom.cellOffset + 2 * pFrom.nCell);//memcpy(aTo[iToHdr], ref aFrom[iFromHdr], pFrom.cellOffset + 2*pFrom.nCell); - - /* Reinitialize page pTo so that the contents of the MemPage structure - ** match the new data. The initialization of pTo can actually fail under - ** fairly obscure circumstances, even though it is a copy of initialized - ** page pFrom. - */ - pTo.isInit = 0; - rc = btreeInitPage(pTo); - if (rc != SQLITE_OK) { - pRC = rc; - return; - } - - /* If this is an auto-vacuum database, update the pointer-map entries - ** for any b-tree or overflow pages that pTo now contains the pointers to. - */ +/* +** This function is used to copy the contents of the b-tree node stored +** on page pFrom to page pTo. If page pFrom was not a leaf page, then +** the pointer-map entries for each child page are updated so that the +** parent page stored in the pointer map is page pTo. If pFrom contained +** any cells with overflow page pointers, then the corresponding pointer +** map entries are also updated so that the parent page is page pTo. +** +** If pFrom is currently carrying any overflow cells (entries in the +** MemPage.aOvfl[] array), they are not copied to pTo. +** +** Before returning, page pTo is reinitialized using btreeInitPage(). +** +** The performance of this function is not critical. It is only used by +** the balance_shallower() and balance_deeper() procedures, neither of +** which are called often under normal circumstances. +*/ +static void copyNodeContent( MemPage pFrom, MemPage pTo, ref int pRC ) +{ + if ( ( pRC ) == SQLITE_OK ) + { + BtShared pBt = pFrom.pBt; + u8[] aFrom = pFrom.aData; + u8[] aTo = pTo.aData; + int iFromHdr = pFrom.hdrOffset; + int iToHdr = ( ( pTo.pgno == 1 ) ? 100 : 0 ); + int rc; + int iData; + + + Debug.Assert( pFrom.isInit != 0 ); + Debug.Assert( pFrom.nFree >= iToHdr ); + Debug.Assert( get2byte( aFrom, iFromHdr + 5 ) <= (int)pBt.usableSize ); + + /* Copy the b-tree node content from page pFrom to page pTo. */ + iData = get2byte( aFrom, iFromHdr + 5 ); + Buffer.BlockCopy( aFrom, iData, aTo, iData, (int)pBt.usableSize - iData );//memcpy(aTo[iData], ref aFrom[iData], pBt.usableSize-iData); + Buffer.BlockCopy( aFrom, iFromHdr, aTo, iToHdr, pFrom.cellOffset + 2 * pFrom.nCell );//memcpy(aTo[iToHdr], ref aFrom[iFromHdr], pFrom.cellOffset + 2*pFrom.nCell); + + /* Reinitialize page pTo so that the contents of the MemPage structure + ** match the new data. The initialization of pTo can actually fail under + ** fairly obscure circumstances, even though it is a copy of initialized + ** page pFrom. + */ + pTo.isInit = 0; + rc = btreeInitPage( pTo ); + if ( rc != SQLITE_OK ) + { + pRC = rc; + return; + } + + /* If this is an auto-vacuum database, update the pointer-map entries + ** for any b-tree or overflow pages that pTo now contains the pointers to. + */ #if !SQLITE_OMIT_AUTOVACUUM // if ( ISAUTOVACUUM ) - if (pBt.autoVacuum) + if ( pBt.autoVacuum ) #else if (false) #endif - { - pRC = setChildPtrmaps(pTo); - } - } - } + { + pRC = setChildPtrmaps( pTo ); + } + } +} - /* - ** This routine redistributes cells on the iParentIdx'th child of pParent - ** (hereafter "the page") and up to 2 siblings so that all pages have about the - ** same amount of free space. Usually a single sibling on either side of the - ** page are used in the balancing, though both siblings might come from one - ** side if the page is the first or last child of its parent. If the page - ** has fewer than 2 siblings (something which can only happen if the page - ** is a root page or a child of a root page) then all available siblings - ** participate in the balancing. - ** - ** The number of siblings of the page might be increased or decreased by - ** one or two in an effort to keep pages nearly full but not over full. - ** - ** Note that when this routine is called, some of the cells on the page - ** might not actually be stored in MemPage.aData[]. This can happen - ** if the page is overfull. This routine ensures that all cells allocated - ** to the page and its siblings fit into MemPage.aData[] before returning. - ** - ** In the course of balancing the page and its siblings, cells may be - ** inserted into or removed from the parent page (pParent). Doing so - ** may cause the parent page to become overfull or underfull. If this - ** happens, it is the responsibility of the caller to invoke the correct - ** balancing routine to fix this problem (see the balance() routine). - ** - ** If this routine fails for any reason, it might leave the database - ** in a corrupted state. So if this routine fails, the database should - ** be rolled back. - ** - ** The third argument to this function, aOvflSpace, is a pointer to a - ** buffer big enough to hold one page. If while inserting cells into the parent - ** page (pParent) the parent page becomes overfull, this buffer is - ** used to store the parent's overflow cells. Because this function inserts - ** a maximum of four divider cells into the parent page, and the maximum - ** size of a cell stored within an internal node is always less than 1/4 - ** of the page-size, the aOvflSpace[] buffer is guaranteed to be large - ** enough for all overflow cells. - ** - ** If aOvflSpace is set to a null pointer, this function returns - ** SQLITE_NOMEM. - */ +/* +** This routine redistributes cells on the iParentIdx'th child of pParent +** (hereafter "the page") and up to 2 siblings so that all pages have about the +** same amount of free space. Usually a single sibling on either side of the +** page are used in the balancing, though both siblings might come from one +** side if the page is the first or last child of its parent. If the page +** has fewer than 2 siblings (something which can only happen if the page +** is a root page or a child of a root page) then all available siblings +** participate in the balancing. +** +** The number of siblings of the page might be increased or decreased by +** one or two in an effort to keep pages nearly full but not over full. +** +** Note that when this routine is called, some of the cells on the page +** might not actually be stored in MemPage.aData[]. This can happen +** if the page is overfull. This routine ensures that all cells allocated +** to the page and its siblings fit into MemPage.aData[] before returning. +** +** In the course of balancing the page and its siblings, cells may be +** inserted into or removed from the parent page (pParent). Doing so +** may cause the parent page to become overfull or underfull. If this +** happens, it is the responsibility of the caller to invoke the correct +** balancing routine to fix this problem (see the balance() routine). +** +** If this routine fails for any reason, it might leave the database +** in a corrupted state. So if this routine fails, the database should +** be rolled back. +** +** The third argument to this function, aOvflSpace, is a pointer to a +** buffer big enough to hold one page. If while inserting cells into the parent +** page (pParent) the parent page becomes overfull, this buffer is +** used to store the parent's overflow cells. Because this function inserts +** a maximum of four divider cells into the parent page, and the maximum +** size of a cell stored within an internal node is always less than 1/4 +** of the page-size, the aOvflSpace[] buffer is guaranteed to be large +** enough for all overflow cells. +** +** If aOvflSpace is set to a null pointer, this function returns +** SQLITE_NOMEM. +*/ + +// under C#; Try to reuse Memory - // under C#; Try to reuse Memory - - static int balance_nonroot( - MemPage pParent, /* Parent page of siblings being balanced */ - int iParentIdx, /* Index of "the page" in pParent */ - u8[] aOvflSpace, /* page-size bytes of space for parent ovfl */ - int isRoot /* True if pParent is a root-page */ - ) { - MemPage[] apOld = new MemPage[NB]; /* pPage and up to two siblings */ - MemPage[] apCopy = new MemPage[NB]; /* Private copies of apOld[] pages */ - MemPage[] apNew = new MemPage[NB + 2];/* pPage and up to NB siblings after balancing */ - int[] apDiv = new int[NB - 1]; /* Divider cells in pParent */ - int[] cntNew = new int[NB + 2]; /* Index in aCell[] of cell after i-th page */ - int[] szNew = new int[NB + 2]; /* Combined size of cells place on i-th page */ - u16[] szCell = new u16[1]; /* Local size of all cells in apCell[] */ - BtShared pBt; /* The whole database */ - int nCell = 0; /* Number of cells in apCell[] */ - int nMaxCells = 0; /* Allocated size of apCell, szCell, aFrom. */ - int nNew = 0; /* Number of pages in apNew[] */ - int nOld; /* Number of pages in apOld[] */ - int i, j, k; /* Loop counters */ - int nxDiv; /* Next divider slot in pParent.aCell[] */ - int rc = SQLITE_OK; /* The return code */ - u16 leafCorrection; /* 4 if pPage is a leaf. 0 if not */ - int leafData; /* True if pPage is a leaf of a LEAFDATA tree */ - int usableSpace; /* Bytes in pPage beyond the header */ - int pageFlags; /* Value of pPage.aData[0] */ - int subtotal; /* Subtotal of bytes in cells on one page */ - //int iSpace1 = 0; /* First unused byte of aSpace1[] */ - int iOvflSpace = 0; /* First unused byte of aOvflSpace[] */ - int szScratch; /* Size of scratch memory requested */ - int pRight; /* Location in parent of right-sibling pointer */ - u8[][] apCell = null; /* All cells begin balanced */ - //u16[] szCell; /* Local size of all cells in apCell[] */ - //u8[] aSpace1; /* Space for copies of dividers cells */ - Pgno pgno; /* Temp var to store a page number in */ - - pBt = pParent.pBt; - Debug.Assert(sqlite3_mutex_held(pBt.mutex)); - Debug.Assert(sqlite3PagerIswriteable(pParent.pDbPage)); +static int balance_nonroot( +MemPage pParent, /* Parent page of siblings being balanced */ +int iParentIdx, /* Index of "the page" in pParent */ +u8[] aOvflSpace, /* page-size bytes of space for parent ovfl */ +int isRoot /* True if pParent is a root-page */ +) +{ + MemPage[] apOld = new MemPage[NB]; /* pPage and up to two siblings */ + MemPage[] apCopy = new MemPage[NB]; /* Private copies of apOld[] pages */ + MemPage[] apNew = new MemPage[NB + 2];/* pPage and up to NB siblings after balancing */ + int[] apDiv = new int[NB - 1]; /* Divider cells in pParent */ + int[] cntNew = new int[NB + 2]; /* Index in aCell[] of cell after i-th page */ + int[] szNew = new int[NB + 2]; /* Combined size of cells place on i-th page */ + u16[] szCell = new u16[1]; /* Local size of all cells in apCell[] */ + BtShared pBt; /* The whole database */ + int nCell = 0; /* Number of cells in apCell[] */ + int nMaxCells = 0; /* Allocated size of apCell, szCell, aFrom. */ + int nNew = 0; /* Number of pages in apNew[] */ + int nOld; /* Number of pages in apOld[] */ + int i, j, k; /* Loop counters */ + int nxDiv; /* Next divider slot in pParent.aCell[] */ + int rc = SQLITE_OK; /* The return code */ + u16 leafCorrection; /* 4 if pPage is a leaf. 0 if not */ + int leafData; /* True if pPage is a leaf of a LEAFDATA tree */ + int usableSpace; /* Bytes in pPage beyond the header */ + int pageFlags; /* Value of pPage.aData[0] */ + int subtotal; /* Subtotal of bytes in cells on one page */ + //int iSpace1 = 0; /* First unused byte of aSpace1[] */ + int iOvflSpace = 0; /* First unused byte of aOvflSpace[] */ + int szScratch; /* Size of scratch memory requested */ + int pRight; /* Location in parent of right-sibling pointer */ + u8[][] apCell = null; /* All cells begin balanced */ + //u16[] szCell; /* Local size of all cells in apCell[] */ + //u8[] aSpace1; /* Space for copies of dividers cells */ + Pgno pgno; /* Temp var to store a page number in */ + + pBt = pParent.pBt; + Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); + Debug.Assert( sqlite3PagerIswriteable( pParent.pDbPage ) ); #if FALSE TRACE("BALANCE: begin page %d child of %d\n", pPage.pgno, pParent.pgno); #endif - /* At this point pParent may have at most one overflow cell. And if - ** this overflow cell is present, it must be the cell with - ** index iParentIdx. This scenario comes about when this function - ** is called (indirectly) from sqlite3BtreeDelete(). - */ - Debug.Assert(pParent.nOverflow == 0 || pParent.nOverflow == 1); - Debug.Assert(pParent.nOverflow == 0 || pParent.aOvfl[0].idx == iParentIdx); - - //if( !aOvflSpace ){ - // return SQLITE_NOMEM; - //} - - /* Find the sibling pages to balance. Also locate the cells in pParent - ** that divide the siblings. An attempt is made to find NN siblings on - ** either side of pPage. More siblings are taken from one side, however, - ** if there are fewer than NN siblings on the other side. If pParent - ** has NB or fewer children then all children of pParent are taken. - ** - ** This loop also drops the divider cells from the parent page. This - ** way, the remainder of the function does not have to deal with any - ** overflow cells in the parent page, since if any existed they will - ** have already been removed. - */ - i = pParent.nOverflow + pParent.nCell; - if (i < 2) { - nxDiv = 0; - nOld = i + 1; - } else { - nOld = 3; - if (iParentIdx == 0) { - nxDiv = 0; - } else if (iParentIdx == i) { - nxDiv = i - 2; - } else { - nxDiv = iParentIdx - 1; - } - i = 2; - } - if ((i + nxDiv - pParent.nOverflow) == pParent.nCell) { - pRight = pParent.hdrOffset + 8; //&pParent.aData[pParent.hdrOffset + 8]; - } else { - pRight = findCell(pParent, i + nxDiv - pParent.nOverflow); - } - pgno = sqlite3Get4byte(pParent.aData, pRight); - while (true) { - rc = getAndInitPage(pBt, pgno, ref apOld[i]); - if (rc != 0) { - //memset(apOld, 0, (i+1)*sizeof(MemPage*)); - goto balance_cleanup; - } - nMaxCells += 1 + apOld[i].nCell + apOld[i].nOverflow; - if ((i--) == 0) - break; - - if (i + nxDiv == pParent.aOvfl[0].idx && pParent.nOverflow != 0) { - apDiv[i] = 0;// = pParent.aOvfl[0].pCell; - pgno = sqlite3Get4byte(pParent.aOvfl[0].pCell, apDiv[i]); - szNew[i] = cellSizePtr(pParent, apDiv[i]); - pParent.nOverflow = 0; - } else { - apDiv[i] = findCell(pParent, i + nxDiv - pParent.nOverflow); - pgno = sqlite3Get4byte(pParent.aData, apDiv[i]); - szNew[i] = cellSizePtr(pParent, apDiv[i]); - - /* Drop the cell from the parent page. apDiv[i] still points to - ** the cell within the parent, even though it has been dropped. - ** This is safe because dropping a cell only overwrites the first - ** four bytes of it, and this function does not need the first - ** four bytes of the divider cell. So the pointer is safe to use - ** later on. - ** - ** Unless SQLite is compiled in secure-delete mode. In this case, - ** the dropCell() routine will overwrite the entire cell with zeroes. - ** In this case, temporarily copy the cell into the aOvflSpace[] - ** buffer. It will be copied out again as soon as the aSpace[] buffer - ** is allocated. */ - //if (pBt.secureDelete) - //{ - // int iOff = (int)(apDiv[i]) - (int)(pParent.aData); //SQLITE_PTR_TO_INT(apDiv[i]) - SQLITE_PTR_TO_INT(pParent.aData); - // if( (iOff+szNew[i])>(int)pBt->usableSize ) - // { - // rc = SQLITE_CORRUPT_BKPT(); - // Array.Clear(apOld[0].aData,0,apOld[0].aData.Length); //memset(apOld, 0, (i + 1) * sizeof(MemPage*)); - // goto balance_cleanup; - // } - // else - // { - // memcpy(&aOvflSpace[iOff], apDiv[i], szNew[i]); - // apDiv[i] = &aOvflSpace[apDiv[i] - pParent.aData]; - // } - //} - dropCell(pParent, i + nxDiv - pParent.nOverflow, szNew[i], ref rc); - } - } - - /* Make nMaxCells a multiple of 4 in order to preserve 8-byte - ** alignment */ - nMaxCells = (nMaxCells + 3) & ~3; - - /* - ** Allocate space for memory structures - */ - //k = pBt.pageSize + ROUND8(sizeof(MemPage)); - //szScratch = - // nMaxCells*sizeof(u8*) /* apCell */ - // + nMaxCells*sizeof(u16) /* szCell */ - // + pBt.pageSize /* aSpace1 */ - // + k*nOld; /* Page copies (apCopy) */ - apCell = sqlite3ScratchMalloc(apCell, nMaxCells); - //if( apCell==null ){ - // rc = SQLITE_NOMEM; - // goto balance_cleanup; - //} - if (szCell.Length < nMaxCells) - Array.Resize(ref szCell, nMaxCells); //(u16*)&apCell[nMaxCells]; - //aSpace1 = new byte[pBt.pageSize * (nMaxCells)];// aSpace1 = (u8*)&szCell[nMaxCells]; - //Debug.Assert( EIGHT_BYTE_ALIGNMENT(aSpace1) ); - - /* - ** Load pointers to all cells on sibling pages and the divider cells - ** into the local apCell[] array. Make copies of the divider cells - ** into space obtained from aSpace1[] and remove the the divider Cells - ** from pParent. - ** - ** If the siblings are on leaf pages, then the child pointers of the - ** divider cells are stripped from the cells before they are copied - ** into aSpace1[]. In this way, all cells in apCell[] are without - ** child pointers. If siblings are not leaves, then all cell in - ** apCell[] include child pointers. Either way, all cells in apCell[] - ** are alike. - ** - ** leafCorrection: 4 if pPage is a leaf. 0 if pPage is not a leaf. - ** leafData: 1 if pPage holds key+data and pParent holds only keys. - */ - leafCorrection = (u16)(apOld[0].leaf * 4); - leafData = apOld[0].hasData; - for (i = 0; i < nOld; i++) { - int limit; - - /* Before doing anything else, take a copy of the i'th original sibling - ** The rest of this function will use data from the copies rather - ** that the original pages since the original pages will be in the - ** process of being overwritten. */ - //MemPage pOld = apCopy[i] = (MemPage*)&aSpace1[pBt.pageSize + k*i]; - //memcpy(pOld, apOld[i], sizeof(MemPage)); - //pOld.aData = (void*)&pOld[1]; - //memcpy(pOld.aData, apOld[i].aData, pBt.pageSize); - MemPage pOld = apCopy[i] = apOld[i].Copy(); - - limit = pOld.nCell + pOld.nOverflow; - if (pOld.nOverflow > 0 || true) { - for (j = 0; j < limit; j++) { - Debug.Assert(nCell < nMaxCells); - //apCell[nCell] = findOverflowCell( pOld, j ); - //szCell[nCell] = cellSizePtr( pOld, apCell, nCell ); - int iFOFC = findOverflowCell(pOld, j); - szCell[nCell] = cellSizePtr(pOld, iFOFC); - // Copy the Data Locally - if (apCell[nCell] == null) - apCell[nCell] = new u8[szCell[nCell]]; - else if (apCell[nCell].Length < szCell[nCell]) - Array.Resize(ref apCell[nCell], szCell[nCell]); - if (iFOFC < 0) // Overflow Cell - Buffer.BlockCopy(pOld.aOvfl[-(iFOFC + 1)].pCell, 0, apCell[nCell], 0, szCell[nCell]); - else - Buffer.BlockCopy(pOld.aData, iFOFC, apCell[nCell], 0, szCell[nCell]); - nCell++; - } - } else { - u8[] aData = pOld.aData; - u16 maskPage = pOld.maskPage; - u16 cellOffset = pOld.cellOffset; - for (j = 0; j < limit; j++) { - Debugger.Break(); - Debug.Assert(nCell < nMaxCells); - apCell[nCell] = findCellv2(aData, maskPage, cellOffset, j); - szCell[nCell] = cellSizePtr(pOld, apCell[nCell]); - nCell++; - } - } - if (i < nOld - 1 && 0 == leafData) { - u16 sz = (u16)szNew[i]; - byte[] pTemp = sqlite3Malloc(sz + leafCorrection); - Debug.Assert(nCell < nMaxCells); - szCell[nCell] = sz; - //pTemp = &aSpace1[iSpace1]; - //iSpace1 += sz; - Debug.Assert(sz <= pBt.maxLocal + 23); - //Debug.Assert(iSpace1 <= (int)pBt.pageSize); - Buffer.BlockCopy(pParent.aData, apDiv[i], pTemp, 0, sz);//memcpy( pTemp, apDiv[i], sz ); - if (apCell[nCell] == null || apCell[nCell].Length < sz) - Array.Resize(ref apCell[nCell], sz); - Buffer.BlockCopy(pTemp, leafCorrection, apCell[nCell], 0, sz);//apCell[nCell] = pTemp + leafCorrection; - Debug.Assert(leafCorrection == 0 || leafCorrection == 4); - szCell[nCell] = (u16)(szCell[nCell] - leafCorrection); - if (0 == pOld.leaf) { - Debug.Assert(leafCorrection == 0); - Debug.Assert(pOld.hdrOffset == 0); - /* The right pointer of the child page pOld becomes the left - ** pointer of the divider cell */ - Buffer.BlockCopy(pOld.aData, 8, apCell[nCell], 0, 4);//memcpy( apCell[nCell], ref pOld.aData[8], 4 ); - } else { - Debug.Assert(leafCorrection == 4); - if (szCell[nCell] < 4) { - /* Do not allow any cells smaller than 4 bytes. */ - szCell[nCell] = 4; - } - } - nCell++; - } - } - - /* - ** Figure out the number of pages needed to hold all nCell cells. - ** Store this number in "k". Also compute szNew[] which is the total - ** size of all cells on the i-th page and cntNew[] which is the index - ** in apCell[] of the cell that divides page i from page i+1. - ** cntNew[k] should equal nCell. - ** - ** Values computed by this block: - ** - ** k: The total number of sibling pages - ** szNew[i]: Spaced used on the i-th sibling page. - ** cntNew[i]: Index in apCell[] and szCell[] for the first cell to - ** the right of the i-th sibling page. - ** usableSpace: Number of bytes of space available on each sibling. - ** - */ - usableSpace = (int)pBt.usableSize - 12 + leafCorrection; - for (subtotal = k = i = 0; i < nCell; i++) { - Debug.Assert(i < nMaxCells); - subtotal += szCell[i] + 2; - if (subtotal > usableSpace) { - szNew[k] = subtotal - szCell[i]; - cntNew[k] = i; - if (leafData != 0) { - i--; - } - subtotal = 0; - k++; - if (k > NB + 1) { - rc = SQLITE_CORRUPT_BKPT(); - goto balance_cleanup; - } - } - } - szNew[k] = subtotal; - cntNew[k] = nCell; - k++; - - /* - ** The packing computed by the previous block is biased toward the siblings - ** on the left side. The left siblings are always nearly full, while the - ** right-most sibling might be nearly empty. This block of code attempts - ** to adjust the packing of siblings to get a better balance. - ** - ** This adjustment is more than an optimization. The packing above might - ** be so out of balance as to be illegal. For example, the right-most - ** sibling might be completely empty. This adjustment is not optional. - */ - for (i = k - 1; i > 0; i--) { - int szRight = szNew[i]; /* Size of sibling on the right */ - int szLeft = szNew[i - 1]; /* Size of sibling on the left */ - int r; /* Index of right-most cell in left sibling */ - int d; /* Index of first cell to the left of right sibling */ - - r = cntNew[i - 1] - 1; - d = r + 1 - leafData; - Debug.Assert(d < nMaxCells); - Debug.Assert(r < nMaxCells); - while (szRight == 0 || szRight + szCell[d] + 2 <= szLeft - (szCell[r] + 2)) { - szRight += szCell[d] + 2; - szLeft -= szCell[r] + 2; - cntNew[i - 1]--; - r = cntNew[i - 1] - 1; - d = r + 1 - leafData; - } - szNew[i] = szRight; - szNew[i - 1] = szLeft; - } + /* At this point pParent may have at most one overflow cell. And if +** this overflow cell is present, it must be the cell with +** index iParentIdx. This scenario comes about when this function +** is called (indirectly) from sqlite3BtreeDelete(). +*/ + Debug.Assert( pParent.nOverflow == 0 || pParent.nOverflow == 1 ); + Debug.Assert( pParent.nOverflow == 0 || pParent.aOvfl[0].idx == iParentIdx ); + + //if( !aOvflSpace ){ + // return SQLITE_NOMEM; + //} + + /* Find the sibling pages to balance. Also locate the cells in pParent + ** that divide the siblings. An attempt is made to find NN siblings on + ** either side of pPage. More siblings are taken from one side, however, + ** if there are fewer than NN siblings on the other side. If pParent + ** has NB or fewer children then all children of pParent are taken. + ** + ** This loop also drops the divider cells from the parent page. This + ** way, the remainder of the function does not have to deal with any + ** overflow cells in the parent page, since if any existed they will + ** have already been removed. + */ + i = pParent.nOverflow + pParent.nCell; + if ( i < 2 ) + { + nxDiv = 0; + nOld = i + 1; + } + else + { + nOld = 3; + if ( iParentIdx == 0 ) + { + nxDiv = 0; + } + else if ( iParentIdx == i ) + { + nxDiv = i - 2; + } + else + { + nxDiv = iParentIdx - 1; + } + i = 2; + } + if ( ( i + nxDiv - pParent.nOverflow ) == pParent.nCell ) + { + pRight = pParent.hdrOffset + 8; //&pParent.aData[pParent.hdrOffset + 8]; + } + else + { + pRight = findCell( pParent, i + nxDiv - pParent.nOverflow ); + } + pgno = sqlite3Get4byte( pParent.aData, pRight ); + while ( true ) + { + rc = getAndInitPage( pBt, pgno, ref apOld[i] ); + if ( rc != 0 ) + { + //memset(apOld, 0, (i+1)*sizeof(MemPage*)); + goto balance_cleanup; + } + nMaxCells += 1 + apOld[i].nCell + apOld[i].nOverflow; + if ( ( i-- ) == 0 ) + break; - /* Either we found one or more cells (cntnew[0])>0) or pPage is - ** a virtual root page. A virtual root page is when the real root - ** page is page 1 and we are the only child of that page. - */ - Debug.Assert(cntNew[0] > 0 || (pParent.pgno == 1 && pParent.nCell == 0)); - - TRACE("BALANCE: old: %d %d %d ", - apOld[0].pgno, - nOld >= 2 ? apOld[1].pgno : 0, - nOld >= 3 ? apOld[2].pgno : 0 - ); - - /* - ** Allocate k new pages. Reuse old pages where possible. - */ - if (apOld[0].pgno <= 1) { - rc = SQLITE_CORRUPT_BKPT(); - goto balance_cleanup; - } - pageFlags = apOld[0].aData[0]; - for (i = 0; i < k; i++) { - MemPage pNew = new MemPage(); - if (i < nOld) { - pNew = apNew[i] = apOld[i]; - apOld[i] = null; - rc = sqlite3PagerWrite(pNew.pDbPage); - nNew++; - if (rc != 0) - goto balance_cleanup; - } else { - Debug.Assert(i > 0); - rc = allocateBtreePage(pBt, ref pNew, ref pgno, pgno, 0); - if (rc != 0) - goto balance_cleanup; - apNew[i] = pNew; - nNew++; - - /* Set the pointer-map entry for the new sibling page. */ + if ( i + nxDiv == pParent.aOvfl[0].idx && pParent.nOverflow != 0 ) + { + apDiv[i] = 0;// = pParent.aOvfl[0].pCell; + pgno = sqlite3Get4byte( pParent.aOvfl[0].pCell, apDiv[i] ); + szNew[i] = cellSizePtr( pParent, apDiv[i] ); + pParent.nOverflow = 0; + } + else + { + apDiv[i] = findCell( pParent, i + nxDiv - pParent.nOverflow ); + pgno = sqlite3Get4byte( pParent.aData, apDiv[i] ); + szNew[i] = cellSizePtr( pParent, apDiv[i] ); + + /* Drop the cell from the parent page. apDiv[i] still points to + ** the cell within the parent, even though it has been dropped. + ** This is safe because dropping a cell only overwrites the first + ** four bytes of it, and this function does not need the first + ** four bytes of the divider cell. So the pointer is safe to use + ** later on. + ** + ** Unless SQLite is compiled in secure-delete mode. In this case, + ** the dropCell() routine will overwrite the entire cell with zeroes. + ** In this case, temporarily copy the cell into the aOvflSpace[] + ** buffer. It will be copied out again as soon as the aSpace[] buffer + ** is allocated. */ + //if (pBt.secureDelete) + //{ + // int iOff = (int)(apDiv[i]) - (int)(pParent.aData); //SQLITE_PTR_TO_INT(apDiv[i]) - SQLITE_PTR_TO_INT(pParent.aData); + // if( (iOff+szNew[i])>(int)pBt->usableSize ) + // { + // rc = SQLITE_CORRUPT_BKPT(); + // Array.Clear(apOld[0].aData,0,apOld[0].aData.Length); //memset(apOld, 0, (i + 1) * sizeof(MemPage*)); + // goto balance_cleanup; + // } + // else + // { + // memcpy(&aOvflSpace[iOff], apDiv[i], szNew[i]); + // apDiv[i] = &aOvflSpace[apDiv[i] - pParent.aData]; + // } + //} + dropCell( pParent, i + nxDiv - pParent.nOverflow, szNew[i], ref rc ); + } + } + + /* Make nMaxCells a multiple of 4 in order to preserve 8-byte + ** alignment */ + nMaxCells = ( nMaxCells + 3 ) & ~3; + + /* + ** Allocate space for memory structures + */ + //k = pBt.pageSize + ROUND8(sizeof(MemPage)); + //szScratch = + // nMaxCells*sizeof(u8*) /* apCell */ + // + nMaxCells*sizeof(u16) /* szCell */ + // + pBt.pageSize /* aSpace1 */ + // + k*nOld; /* Page copies (apCopy) */ + apCell = sqlite3ScratchMalloc( apCell, nMaxCells ); + //if( apCell==null ){ + // rc = SQLITE_NOMEM; + // goto balance_cleanup; + //} + if ( szCell.Length < nMaxCells ) + Array.Resize( ref szCell, nMaxCells ); //(u16*)&apCell[nMaxCells]; + //aSpace1 = new byte[pBt.pageSize * (nMaxCells)];// aSpace1 = (u8*)&szCell[nMaxCells]; + //Debug.Assert( EIGHT_BYTE_ALIGNMENT(aSpace1) ); + + /* + ** Load pointers to all cells on sibling pages and the divider cells + ** into the local apCell[] array. Make copies of the divider cells + ** into space obtained from aSpace1[] and remove the the divider Cells + ** from pParent. + ** + ** If the siblings are on leaf pages, then the child pointers of the + ** divider cells are stripped from the cells before they are copied + ** into aSpace1[]. In this way, all cells in apCell[] are without + ** child pointers. If siblings are not leaves, then all cell in + ** apCell[] include child pointers. Either way, all cells in apCell[] + ** are alike. + ** + ** leafCorrection: 4 if pPage is a leaf. 0 if pPage is not a leaf. + ** leafData: 1 if pPage holds key+data and pParent holds only keys. + */ + leafCorrection = (u16)( apOld[0].leaf * 4 ); + leafData = apOld[0].hasData; + for ( i = 0; i < nOld; i++ ) + { + int limit; + + /* Before doing anything else, take a copy of the i'th original sibling + ** The rest of this function will use data from the copies rather + ** that the original pages since the original pages will be in the + ** process of being overwritten. */ + //MemPage pOld = apCopy[i] = (MemPage*)&aSpace1[pBt.pageSize + k*i]; + //memcpy(pOld, apOld[i], sizeof(MemPage)); + //pOld.aData = (void*)&pOld[1]; + //memcpy(pOld.aData, apOld[i].aData, pBt.pageSize); + MemPage pOld = apCopy[i] = apOld[i].Copy(); + + limit = pOld.nCell + pOld.nOverflow; + if( pOld.nOverflow>0 || true){ + for ( j = 0; j < limit; j++ ) + { + Debug.Assert( nCell < nMaxCells ); + //apCell[nCell] = findOverflowCell( pOld, j ); + //szCell[nCell] = cellSizePtr( pOld, apCell, nCell ); + int iFOFC = findOverflowCell( pOld, j ); + szCell[nCell] = cellSizePtr( pOld, iFOFC ); + // Copy the Data Locally + if ( apCell[nCell] == null ) + apCell[nCell] = new u8[szCell[nCell]]; + else if ( apCell[nCell].Length < szCell[nCell] ) + Array.Resize( ref apCell[nCell], szCell[nCell] ); + if ( iFOFC < 0 ) // Overflow Cell + Buffer.BlockCopy( pOld.aOvfl[-( iFOFC + 1 )].pCell, 0, apCell[nCell], 0, szCell[nCell] ); + else + Buffer.BlockCopy( pOld.aData, iFOFC, apCell[nCell], 0, szCell[nCell] ); + nCell++; + } + } + else + { + u8[] aData = pOld.aData; + u16 maskPage = pOld.maskPage; + u16 cellOffset = pOld.cellOffset; + for ( j = 0; j < limit; j++ ) + { + Debugger.Break(); + Debug.Assert( nCell < nMaxCells ); + apCell[nCell] = findCellv2( aData, maskPage, cellOffset, j ); + szCell[nCell] = cellSizePtr( pOld, apCell[nCell] ); + nCell++; + } + } + if ( i < nOld - 1 && 0 == leafData ) + { + u16 sz = (u16)szNew[i]; + byte[] pTemp = sqlite3Malloc( sz + leafCorrection ); + Debug.Assert( nCell < nMaxCells ); + szCell[nCell] = sz; + //pTemp = &aSpace1[iSpace1]; + //iSpace1 += sz; + Debug.Assert( sz <= pBt.maxLocal + 23 ); + //Debug.Assert(iSpace1 <= (int)pBt.pageSize); + Buffer.BlockCopy( pParent.aData, apDiv[i], pTemp, 0, sz );//memcpy( pTemp, apDiv[i], sz ); + if ( apCell[nCell] == null || apCell[nCell].Length < sz ) + Array.Resize( ref apCell[nCell], sz ); + Buffer.BlockCopy( pTemp, leafCorrection, apCell[nCell], 0, sz );//apCell[nCell] = pTemp + leafCorrection; + Debug.Assert( leafCorrection == 0 || leafCorrection == 4 ); + szCell[nCell] = (u16)( szCell[nCell] - leafCorrection ); + if ( 0 == pOld.leaf ) + { + Debug.Assert( leafCorrection == 0 ); + Debug.Assert( pOld.hdrOffset == 0 ); + /* The right pointer of the child page pOld becomes the left + ** pointer of the divider cell */ + Buffer.BlockCopy( pOld.aData, 8, apCell[nCell], 0, 4 );//memcpy( apCell[nCell], ref pOld.aData[8], 4 ); + } + else + { + Debug.Assert( leafCorrection == 4 ); + if ( szCell[nCell] < 4 ) + { + /* Do not allow any cells smaller than 4 bytes. */ + szCell[nCell] = 4; + } + } + nCell++; + } + } + + /* + ** Figure out the number of pages needed to hold all nCell cells. + ** Store this number in "k". Also compute szNew[] which is the total + ** size of all cells on the i-th page and cntNew[] which is the index + ** in apCell[] of the cell that divides page i from page i+1. + ** cntNew[k] should equal nCell. + ** + ** Values computed by this block: + ** + ** k: The total number of sibling pages + ** szNew[i]: Spaced used on the i-th sibling page. + ** cntNew[i]: Index in apCell[] and szCell[] for the first cell to + ** the right of the i-th sibling page. + ** usableSpace: Number of bytes of space available on each sibling. + ** + */ + usableSpace = (int)pBt.usableSize - 12 + leafCorrection; + for ( subtotal = k = i = 0; i < nCell; i++ ) + { + Debug.Assert( i < nMaxCells ); + subtotal += szCell[i] + 2; + if ( subtotal > usableSpace ) + { + szNew[k] = subtotal - szCell[i]; + cntNew[k] = i; + if ( leafData != 0 ) + { + i--; + } + subtotal = 0; + k++; + if ( k > NB + 1 ) + { + rc = SQLITE_CORRUPT_BKPT(); + goto balance_cleanup; + } + } + } + szNew[k] = subtotal; + cntNew[k] = nCell; + k++; + + /* + ** The packing computed by the previous block is biased toward the siblings + ** on the left side. The left siblings are always nearly full, while the + ** right-most sibling might be nearly empty. This block of code attempts + ** to adjust the packing of siblings to get a better balance. + ** + ** This adjustment is more than an optimization. The packing above might + ** be so out of balance as to be illegal. For example, the right-most + ** sibling might be completely empty. This adjustment is not optional. + */ + for ( i = k - 1; i > 0; i-- ) + { + int szRight = szNew[i]; /* Size of sibling on the right */ + int szLeft = szNew[i - 1]; /* Size of sibling on the left */ + int r; /* Index of right-most cell in left sibling */ + int d; /* Index of first cell to the left of right sibling */ + + r = cntNew[i - 1] - 1; + d = r + 1 - leafData; + Debug.Assert( d < nMaxCells ); + Debug.Assert( r < nMaxCells ); + while ( szRight == 0 || szRight + szCell[d] + 2 <= szLeft - ( szCell[r] + 2 ) ) + { + szRight += szCell[d] + 2; + szLeft -= szCell[r] + 2; + cntNew[i - 1]--; + r = cntNew[i - 1] - 1; + d = r + 1 - leafData; + } + szNew[i] = szRight; + szNew[i - 1] = szLeft; + } + + /* Either we found one or more cells (cntnew[0])>0) or pPage is + ** a virtual root page. A virtual root page is when the real root + ** page is page 1 and we are the only child of that page. + */ + Debug.Assert( cntNew[0] > 0 || ( pParent.pgno == 1 && pParent.nCell == 0 ) ); + + TRACE( "BALANCE: old: %d %d %d ", + apOld[0].pgno, + nOld >= 2 ? apOld[1].pgno : 0, + nOld >= 3 ? apOld[2].pgno : 0 + ); + + /* + ** Allocate k new pages. Reuse old pages where possible. + */ + if ( apOld[0].pgno <= 1 ) + { + rc = SQLITE_CORRUPT_BKPT(); + goto balance_cleanup; + } + pageFlags = apOld[0].aData[0]; + for ( i = 0; i < k; i++ ) + { + MemPage pNew = new MemPage(); + if ( i < nOld ) + { + pNew = apNew[i] = apOld[i]; + apOld[i] = null; + rc = sqlite3PagerWrite( pNew.pDbPage ); + nNew++; + if ( rc != 0 ) + goto balance_cleanup; + } + else + { + Debug.Assert( i > 0 ); + rc = allocateBtreePage( pBt, ref pNew, ref pgno, pgno, 0 ); + if ( rc != 0 ) + goto balance_cleanup; + apNew[i] = pNew; + nNew++; + + /* Set the pointer-map entry for the new sibling page. */ #if !SQLITE_OMIT_AUTOVACUUM // if ( ISAUTOVACUUM ) - if (pBt.autoVacuum) + if ( pBt.autoVacuum ) #else if (false) #endif - { - ptrmapPut(pBt, pNew.pgno, PTRMAP_BTREE, pParent.pgno, ref rc); - if (rc != SQLITE_OK) { - goto balance_cleanup; - } - } - } - } - - /* Free any old pages that were not reused as new pages. - */ - while (i < nOld) { - freePage(apOld[i], ref rc); - if (rc != 0) - goto balance_cleanup; - releasePage(apOld[i]); - apOld[i] = null; - i++; - } - - /* - ** Put the new pages in accending order. This helps to - ** keep entries in the disk file in order so that a scan - ** of the table is a linear scan through the file. That - ** in turn helps the operating system to deliver pages - ** from the disk more rapidly. - ** - ** An O(n^2) insertion sort algorithm is used, but since - ** n is never more than NB (a small constant), that should - ** not be a problem. - ** - ** When NB==3, this one optimization makes the database - ** about 25% faster for large insertions and deletions. - */ - for (i = 0; i < k - 1; i++) { - int minV = (int)apNew[i].pgno; - int minI = i; - for (j = i + 1; j < k; j++) { - if (apNew[j].pgno < (u32)minV) { - minI = j; - minV = (int)apNew[j].pgno; - } - } - if (minI > i) { - MemPage pT; - pT = apNew[i]; - apNew[i] = apNew[minI]; - apNew[minI] = pT; - } - } - TRACE("new: %d(%d) %d(%d) %d(%d) %d(%d) %d(%d)\n", - apNew[0].pgno, szNew[0], - nNew >= 2 ? apNew[1].pgno : 0, nNew >= 2 ? szNew[1] : 0, - nNew >= 3 ? apNew[2].pgno : 0, nNew >= 3 ? szNew[2] : 0, - nNew >= 4 ? apNew[3].pgno : 0, nNew >= 4 ? szNew[3] : 0, - nNew >= 5 ? apNew[4].pgno : 0, nNew >= 5 ? szNew[4] : 0); - - Debug.Assert(sqlite3PagerIswriteable(pParent.pDbPage)); - sqlite3Put4byte(pParent.aData, pRight, apNew[nNew - 1].pgno); - - /* - ** Evenly distribute the data in apCell[] across the new pages. - ** Insert divider cells into pParent as necessary. - */ - j = 0; - for (i = 0; i < nNew; i++) { - /* Assemble the new sibling page. */ - MemPage pNew = apNew[i]; - Debug.Assert(j < nMaxCells); - zeroPage(pNew, pageFlags); - assemblePage(pNew, cntNew[i] - j, apCell, szCell, j); - Debug.Assert(pNew.nCell > 0 || (nNew == 1 && cntNew[0] == 0)); - Debug.Assert(pNew.nOverflow == 0); - - j = cntNew[i]; - - /* If the sibling page assembled above was not the right-most sibling, - ** insert a divider cell into the parent page. - */ - Debug.Assert(i < nNew - 1 || j == nCell); - if (j < nCell) { - u8[] pCell; - u8[] pTemp; - int sz; - - Debug.Assert(j < nMaxCells); - pCell = apCell[j]; - sz = szCell[j] + leafCorrection; - pTemp = sqlite3Malloc(sz);//&aOvflSpace[iOvflSpace]; - if (0 == pNew.leaf) { - Buffer.BlockCopy(pCell, 0, pNew.aData, 8, 4);//memcpy( pNew.aData[8], pCell, 4 ); - } else if (leafData != 0) { - /* If the tree is a leaf-data tree, and the siblings are leaves, - ** then there is no divider cell in apCell[]. Instead, the divider - ** cell consists of the integer key for the right-most cell of - ** the sibling-page assembled above only. - */ - CellInfo info = new CellInfo(); - j--; - btreeParseCellPtr(pNew, apCell[j], ref info); - pCell = pTemp; - sz = 4 + putVarint(pCell, 4, (u64)info.nKey); - pTemp = null; - } else { - //------------ pCell -= 4; - byte[] _pCell_4 = sqlite3Malloc(pCell.Length + 4); - Buffer.BlockCopy(pCell, 0, _pCell_4, 4, pCell.Length); - pCell = _pCell_4; - // - /* Obscure case for non-leaf-data trees: If the cell at pCell was - ** previously stored on a leaf node, and its reported size was 4 - ** bytes, then it may actually be smaller than this - ** (see btreeParseCellPtr(), 4 bytes is the minimum size of - ** any cell). But it is important to pass the correct size to - ** insertCell(), so reparse the cell now. - ** - ** Note that this can never happen in an SQLite data file, as all - ** cells are at least 4 bytes. It only happens in b-trees used - ** to evaluate "IN (SELECT ...)" and similar clauses. - */ - if (szCell[j] == 4) { - Debug.Assert(leafCorrection == 4); - sz = cellSizePtr(pParent, pCell); - } - } - iOvflSpace += sz; - Debug.Assert(sz <= pBt.maxLocal + 23); - Debug.Assert(iOvflSpace <= (int)pBt.pageSize); - insertCell(pParent, nxDiv, pCell, sz, pTemp, pNew.pgno, ref rc); - if (rc != SQLITE_OK) - goto balance_cleanup; - Debug.Assert(sqlite3PagerIswriteable(pParent.pDbPage)); - - j++; - nxDiv++; - } - } - Debug.Assert(j == nCell); - Debug.Assert(nOld > 0); - Debug.Assert(nNew > 0); - if ((pageFlags & PTF_LEAF) == 0) { - Buffer.BlockCopy(apCopy[nOld - 1].aData, 8, apNew[nNew - 1].aData, 8, 4); //u8* zChild = &apCopy[nOld - 1].aData[8]; - //memcpy( apNew[nNew - 1].aData[8], zChild, 4 ); - } - - if (isRoot != 0 && pParent.nCell == 0 && pParent.hdrOffset <= apNew[0].nFree) { - /* The root page of the b-tree now contains no cells. The only sibling - ** page is the right-child of the parent. Copy the contents of the - ** child page into the parent, decreasing the overall height of the - ** b-tree structure by one. This is described as the "balance-shallower" - ** sub-algorithm in some documentation. - ** - ** If this is an auto-vacuum database, the call to copyNodeContent() - ** sets all pointer-map entries corresponding to database image pages - ** for which the pointer is stored within the content being copied. - ** - ** The second Debug.Assert below verifies that the child page is defragmented - ** (it must be, as it was just reconstructed using assemblePage()). This - ** is important if the parent page happens to be page 1 of the database - ** image. */ - Debug.Assert(nNew == 1); - Debug.Assert(apNew[0].nFree == - (get2byte(apNew[0].aData, 5) - apNew[0].cellOffset - apNew[0].nCell * 2) - ); - copyNodeContent(apNew[0], pParent, ref rc); - freePage(apNew[0], ref rc); - } else + { + ptrmapPut( pBt, pNew.pgno, PTRMAP_BTREE, pParent.pgno, ref rc ); + if ( rc != SQLITE_OK ) + { + goto balance_cleanup; + } + } + } + } + + /* Free any old pages that were not reused as new pages. + */ + while ( i < nOld ) + { + freePage( apOld[i], ref rc ); + if ( rc != 0 ) + goto balance_cleanup; + releasePage( apOld[i] ); + apOld[i] = null; + i++; + } + + /* + ** Put the new pages in accending order. This helps to + ** keep entries in the disk file in order so that a scan + ** of the table is a linear scan through the file. That + ** in turn helps the operating system to deliver pages + ** from the disk more rapidly. + ** + ** An O(n^2) insertion sort algorithm is used, but since + ** n is never more than NB (a small constant), that should + ** not be a problem. + ** + ** When NB==3, this one optimization makes the database + ** about 25% faster for large insertions and deletions. + */ + for ( i = 0; i < k - 1; i++ ) + { + int minV = (int)apNew[i].pgno; + int minI = i; + for ( j = i + 1; j < k; j++ ) + { + if ( apNew[j].pgno < (u32)minV ) + { + minI = j; + minV = (int)apNew[j].pgno; + } + } + if ( minI > i ) + { + MemPage pT; + pT = apNew[i]; + apNew[i] = apNew[minI]; + apNew[minI] = pT; + } + } + TRACE( "new: %d(%d) %d(%d) %d(%d) %d(%d) %d(%d)\n", + apNew[0].pgno, szNew[0], + nNew >= 2 ? apNew[1].pgno : 0, nNew >= 2 ? szNew[1] : 0, + nNew >= 3 ? apNew[2].pgno : 0, nNew >= 3 ? szNew[2] : 0, + nNew >= 4 ? apNew[3].pgno : 0, nNew >= 4 ? szNew[3] : 0, + nNew >= 5 ? apNew[4].pgno : 0, nNew >= 5 ? szNew[4] : 0 ); + + Debug.Assert( sqlite3PagerIswriteable( pParent.pDbPage ) ); + sqlite3Put4byte( pParent.aData, pRight, apNew[nNew - 1].pgno ); + + /* + ** Evenly distribute the data in apCell[] across the new pages. + ** Insert divider cells into pParent as necessary. + */ + j = 0; + for ( i = 0; i < nNew; i++ ) + { + /* Assemble the new sibling page. */ + MemPage pNew = apNew[i]; + Debug.Assert( j < nMaxCells ); + zeroPage( pNew, pageFlags ); + assemblePage( pNew, cntNew[i] - j, apCell, szCell, j ); + Debug.Assert( pNew.nCell > 0 || ( nNew == 1 && cntNew[0] == 0 ) ); + Debug.Assert( pNew.nOverflow == 0 ); + + j = cntNew[i]; + + /* If the sibling page assembled above was not the right-most sibling, + ** insert a divider cell into the parent page. + */ + Debug.Assert( i < nNew - 1 || j == nCell ); + if ( j < nCell ) + { + u8[] pCell; + u8[] pTemp; + int sz; + + Debug.Assert( j < nMaxCells ); + pCell = apCell[j]; + sz = szCell[j] + leafCorrection; + pTemp = sqlite3Malloc( sz );//&aOvflSpace[iOvflSpace]; + if ( 0 == pNew.leaf ) + { + Buffer.BlockCopy( pCell, 0, pNew.aData, 8, 4 );//memcpy( pNew.aData[8], pCell, 4 ); + } + else if ( leafData != 0 ) + { + /* If the tree is a leaf-data tree, and the siblings are leaves, + ** then there is no divider cell in apCell[]. Instead, the divider + ** cell consists of the integer key for the right-most cell of + ** the sibling-page assembled above only. + */ + CellInfo info = new CellInfo(); + j--; + btreeParseCellPtr( pNew, apCell[j], ref info ); + pCell = pTemp; + sz = 4 + putVarint( pCell, 4, (u64)info.nKey ); + pTemp = null; + } + else + { + //------------ pCell -= 4; + byte[] _pCell_4 = sqlite3Malloc( pCell.Length + 4 ); + Buffer.BlockCopy( pCell, 0, _pCell_4, 4, pCell.Length ); + pCell = _pCell_4; + // + /* Obscure case for non-leaf-data trees: If the cell at pCell was + ** previously stored on a leaf node, and its reported size was 4 + ** bytes, then it may actually be smaller than this + ** (see btreeParseCellPtr(), 4 bytes is the minimum size of + ** any cell). But it is important to pass the correct size to + ** insertCell(), so reparse the cell now. + ** + ** Note that this can never happen in an SQLite data file, as all + ** cells are at least 4 bytes. It only happens in b-trees used + ** to evaluate "IN (SELECT ...)" and similar clauses. + */ + if ( szCell[j] == 4 ) + { + Debug.Assert( leafCorrection == 4 ); + sz = cellSizePtr( pParent, pCell ); + } + } + iOvflSpace += sz; + Debug.Assert( sz <= pBt.maxLocal + 23 ); + Debug.Assert( iOvflSpace <= (int)pBt.pageSize ); + insertCell( pParent, nxDiv, pCell, sz, pTemp, pNew.pgno, ref rc ); + if ( rc != SQLITE_OK ) + goto balance_cleanup; + Debug.Assert( sqlite3PagerIswriteable( pParent.pDbPage ) ); + + j++; + nxDiv++; + } + } + Debug.Assert( j == nCell ); + Debug.Assert( nOld > 0 ); + Debug.Assert( nNew > 0 ); + if ( ( pageFlags & PTF_LEAF ) == 0 ) + { + Buffer.BlockCopy( apCopy[nOld - 1].aData, 8, apNew[nNew - 1].aData, 8, 4 ); //u8* zChild = &apCopy[nOld - 1].aData[8]; + //memcpy( apNew[nNew - 1].aData[8], zChild, 4 ); + } + + if ( isRoot != 0 && pParent.nCell == 0 && pParent.hdrOffset <= apNew[0].nFree ) + { + /* The root page of the b-tree now contains no cells. The only sibling + ** page is the right-child of the parent. Copy the contents of the + ** child page into the parent, decreasing the overall height of the + ** b-tree structure by one. This is described as the "balance-shallower" + ** sub-algorithm in some documentation. + ** + ** If this is an auto-vacuum database, the call to copyNodeContent() + ** sets all pointer-map entries corresponding to database image pages + ** for which the pointer is stored within the content being copied. + ** + ** The second Debug.Assert below verifies that the child page is defragmented + ** (it must be, as it was just reconstructed using assemblePage()). This + ** is important if the parent page happens to be page 1 of the database + ** image. */ + Debug.Assert( nNew == 1 ); + Debug.Assert( apNew[0].nFree == + ( get2byte( apNew[0].aData, 5 ) - apNew[0].cellOffset - apNew[0].nCell * 2 ) + ); + copyNodeContent( apNew[0], pParent, ref rc ); + freePage( apNew[0], ref rc ); + } + else #if !SQLITE_OMIT_AUTOVACUUM // if ( ISAUTOVACUUM ) - if (pBt.autoVacuum) + if ( pBt.autoVacuum ) #else if (false) #endif - { - /* Fix the pointer-map entries for all the cells that were shifted around. - ** There are several different types of pointer-map entries that need to - ** be dealt with by this routine. Some of these have been set already, but - ** many have not. The following is a summary: - ** - ** 1) The entries associated with new sibling pages that were not - ** siblings when this function was called. These have already - ** been set. We don't need to worry about old siblings that were - ** moved to the free-list - the freePage() code has taken care - ** of those. - ** - ** 2) The pointer-map entries associated with the first overflow - ** page in any overflow chains used by new divider cells. These - ** have also already been taken care of by the insertCell() code. - ** - ** 3) If the sibling pages are not leaves, then the child pages of - ** cells stored on the sibling pages may need to be updated. - ** - ** 4) If the sibling pages are not internal intkey nodes, then any - ** overflow pages used by these cells may need to be updated - ** (internal intkey nodes never contain pointers to overflow pages). - ** - ** 5) If the sibling pages are not leaves, then the pointer-map - ** entries for the right-child pages of each sibling may need - ** to be updated. - ** - ** Cases 1 and 2 are dealt with above by other code. The next - ** block deals with cases 3 and 4 and the one after that, case 5. Since - ** setting a pointer map entry is a relatively expensive operation, this - ** code only sets pointer map entries for child or overflow pages that have - ** actually moved between pages. */ - MemPage pNew = apNew[0]; - MemPage pOld = apCopy[0]; - int nOverflow = pOld.nOverflow; - int iNextOld = pOld.nCell + nOverflow; - int iOverflow = (nOverflow != 0 ? pOld.aOvfl[0].idx : -1); - j = 0; /* Current 'old' sibling page */ - k = 0; /* Current 'new' sibling page */ - for (i = 0; i < nCell; i++) { - int isDivider = 0; - while (i == iNextOld) { - /* Cell i is the cell immediately following the last cell on old - ** sibling page j. If the siblings are not leaf pages of an - ** intkey b-tree, then cell i was a divider cell. */ - pOld = apCopy[++j]; - iNextOld = i + (0 == leafData ? 1 : 0) + pOld.nCell + pOld.nOverflow; - if (pOld.nOverflow != 0) { - nOverflow = pOld.nOverflow; - iOverflow = i + (0 == leafData ? 1 : 0) + pOld.aOvfl[0].idx; - } - isDivider = 0 == leafData ? 1 : 0; - } - - Debug.Assert(nOverflow > 0 || iOverflow < i); - Debug.Assert(nOverflow < 2 || pOld.aOvfl[0].idx == pOld.aOvfl[1].idx - 1); - Debug.Assert(nOverflow < 3 || pOld.aOvfl[1].idx == pOld.aOvfl[2].idx - 1); - if (i == iOverflow) { - isDivider = 1; - if ((--nOverflow) > 0) { - iOverflow++; - } - } - - if (i == cntNew[k]) { - /* Cell i is the cell immediately following the last cell on new - ** sibling page k. If the siblings are not leaf pages of an - ** intkey b-tree, then cell i is a divider cell. */ - pNew = apNew[++k]; - if (0 == leafData) - continue; - } - Debug.Assert(j < nOld); - Debug.Assert(k < nNew); - - /* If the cell was originally divider cell (and is not now) or - ** an overflow cell, or if the cell was located on a different sibling - ** page before the balancing, then the pointer map entries associated - ** with any child or overflow pages need to be updated. */ - if (isDivider != 0 || pOld.pgno != pNew.pgno) { - if (0 == leafCorrection) { - ptrmapPut(pBt, sqlite3Get4byte(apCell[i]), PTRMAP_BTREE, pNew.pgno, ref rc); - } - if (szCell[i] > pNew.minLocal) { - ptrmapPutOvflPtr(pNew, apCell[i], ref rc); - } - } - } - - if (0 == leafCorrection) { - for (i = 0; i < nNew; i++) { - u32 key = sqlite3Get4byte(apNew[i].aData, 8); - ptrmapPut(pBt, key, PTRMAP_BTREE, apNew[i].pgno, ref rc); - } - } + { + /* Fix the pointer-map entries for all the cells that were shifted around. + ** There are several different types of pointer-map entries that need to + ** be dealt with by this routine. Some of these have been set already, but + ** many have not. The following is a summary: + ** + ** 1) The entries associated with new sibling pages that were not + ** siblings when this function was called. These have already + ** been set. We don't need to worry about old siblings that were + ** moved to the free-list - the freePage() code has taken care + ** of those. + ** + ** 2) The pointer-map entries associated with the first overflow + ** page in any overflow chains used by new divider cells. These + ** have also already been taken care of by the insertCell() code. + ** + ** 3) If the sibling pages are not leaves, then the child pages of + ** cells stored on the sibling pages may need to be updated. + ** + ** 4) If the sibling pages are not internal intkey nodes, then any + ** overflow pages used by these cells may need to be updated + ** (internal intkey nodes never contain pointers to overflow pages). + ** + ** 5) If the sibling pages are not leaves, then the pointer-map + ** entries for the right-child pages of each sibling may need + ** to be updated. + ** + ** Cases 1 and 2 are dealt with above by other code. The next + ** block deals with cases 3 and 4 and the one after that, case 5. Since + ** setting a pointer map entry is a relatively expensive operation, this + ** code only sets pointer map entries for child or overflow pages that have + ** actually moved between pages. */ + MemPage pNew = apNew[0]; + MemPage pOld = apCopy[0]; + int nOverflow = pOld.nOverflow; + int iNextOld = pOld.nCell + nOverflow; + int iOverflow = ( nOverflow != 0 ? pOld.aOvfl[0].idx : -1 ); + j = 0; /* Current 'old' sibling page */ + k = 0; /* Current 'new' sibling page */ + for ( i = 0; i < nCell; i++ ) + { + int isDivider = 0; + while ( i == iNextOld ) + { + /* Cell i is the cell immediately following the last cell on old + ** sibling page j. If the siblings are not leaf pages of an + ** intkey b-tree, then cell i was a divider cell. */ + pOld = apCopy[++j]; + iNextOld = i + ( 0 == leafData ? 1 : 0 ) + pOld.nCell + pOld.nOverflow; + if ( pOld.nOverflow != 0 ) + { + nOverflow = pOld.nOverflow; + iOverflow = i + ( 0 == leafData ? 1 : 0 ) + pOld.aOvfl[0].idx; + } + isDivider = 0 == leafData ? 1 : 0; + } + + Debug.Assert( nOverflow > 0 || iOverflow < i ); + Debug.Assert( nOverflow < 2 || pOld.aOvfl[0].idx == pOld.aOvfl[1].idx - 1 ); + Debug.Assert( nOverflow < 3 || pOld.aOvfl[1].idx == pOld.aOvfl[2].idx - 1 ); + if ( i == iOverflow ) + { + isDivider = 1; + if ( ( --nOverflow ) > 0 ) + { + iOverflow++; + } + } + + if ( i == cntNew[k] ) + { + /* Cell i is the cell immediately following the last cell on new + ** sibling page k. If the siblings are not leaf pages of an + ** intkey b-tree, then cell i is a divider cell. */ + pNew = apNew[++k]; + if ( 0 == leafData ) + continue; + } + Debug.Assert( j < nOld ); + Debug.Assert( k < nNew ); + + /* If the cell was originally divider cell (and is not now) or + ** an overflow cell, or if the cell was located on a different sibling + ** page before the balancing, then the pointer map entries associated + ** with any child or overflow pages need to be updated. */ + if ( isDivider != 0 || pOld.pgno != pNew.pgno ) + { + if ( 0 == leafCorrection ) + { + ptrmapPut( pBt, sqlite3Get4byte( apCell[i] ), PTRMAP_BTREE, pNew.pgno, ref rc ); + } + if ( szCell[i] > pNew.minLocal ) + { + ptrmapPutOvflPtr( pNew, apCell[i], ref rc ); + } + } + } + + if ( 0 == leafCorrection ) + { + for ( i = 0; i < nNew; i++ ) + { + u32 key = sqlite3Get4byte( apNew[i].aData, 8 ); + ptrmapPut( pBt, key, PTRMAP_BTREE, apNew[i].pgno, ref rc ); + } + } #if FALSE /* The ptrmapCheckPages() contains Debug.Assert() statements that verify that @@ -6860,539 +7549,579 @@ static int balance_nonroot( ptrmapCheckPages(apNew, nNew); ptrmapCheckPages(pParent, 1); #endif - } - - Debug.Assert(pParent.isInit != 0); - TRACE("BALANCE: finished: old=%d new=%d cells=%d\n", - nOld, nNew, nCell); + } - /* - ** Cleanup before returning. - */ - balance_cleanup: - sqlite3ScratchFree(apCell); - for (i = 0; i < nOld; i++) { - releasePage(apOld[i]); - } - for (i = 0; i < nNew; i++) { - releasePage(apNew[i]); - } + Debug.Assert( pParent.isInit != 0 ); + TRACE( "BALANCE: finished: old=%d new=%d cells=%d\n", + nOld, nNew, nCell ); - return rc; - } +/* +** Cleanup before returning. +*/ +balance_cleanup: + sqlite3ScratchFree( apCell ); + for ( i = 0; i < nOld; i++ ) + { + releasePage( apOld[i] ); + } + for ( i = 0; i < nNew; i++ ) + { + releasePage( apNew[i] ); + } + + return rc; +} - /* - ** This function is called when the root page of a b-tree structure is - ** overfull (has one or more overflow pages). - ** - ** A new child page is allocated and the contents of the current root - ** page, including overflow cells, are copied into the child. The root - ** page is then overwritten to make it an empty page with the right-child - ** pointer pointing to the new page. - ** - ** Before returning, all pointer-map entries corresponding to pages - ** that the new child-page now contains pointers to are updated. The - ** entry corresponding to the new right-child pointer of the root - ** page is also updated. - ** - ** If successful, ppChild is set to contain a reference to the child - ** page and SQLITE_OK is returned. In this case the caller is required - ** to call releasePage() on ppChild exactly once. If an error occurs, - ** an error code is returned and ppChild is set to 0. - */ - static int balance_deeper(MemPage pRoot, ref MemPage ppChild) { - int rc; /* Return value from subprocedures */ - MemPage pChild = null; /* Pointer to a new child page */ - Pgno pgnoChild = 0; /* Page number of the new child page */ - BtShared pBt = pRoot.pBt; /* The BTree */ - - Debug.Assert(pRoot.nOverflow > 0); - Debug.Assert(sqlite3_mutex_held(pBt.mutex)); - - /* Make pRoot, the root page of the b-tree, writable. Allocate a new - ** page that will become the new right-child of pPage. Copy the contents - ** of the node stored on pRoot into the new child page. - */ - rc = sqlite3PagerWrite(pRoot.pDbPage); - if (rc == SQLITE_OK) { - rc = allocateBtreePage(pBt, ref pChild, ref pgnoChild, pRoot.pgno, 0); - copyNodeContent(pRoot, pChild, ref rc); +/* +** This function is called when the root page of a b-tree structure is +** overfull (has one or more overflow pages). +** +** A new child page is allocated and the contents of the current root +** page, including overflow cells, are copied into the child. The root +** page is then overwritten to make it an empty page with the right-child +** pointer pointing to the new page. +** +** Before returning, all pointer-map entries corresponding to pages +** that the new child-page now contains pointers to are updated. The +** entry corresponding to the new right-child pointer of the root +** page is also updated. +** +** If successful, ppChild is set to contain a reference to the child +** page and SQLITE_OK is returned. In this case the caller is required +** to call releasePage() on ppChild exactly once. If an error occurs, +** an error code is returned and ppChild is set to 0. +*/ +static int balance_deeper( MemPage pRoot, ref MemPage ppChild ) +{ + int rc; /* Return value from subprocedures */ + MemPage pChild = null; /* Pointer to a new child page */ + Pgno pgnoChild = 0; /* Page number of the new child page */ + BtShared pBt = pRoot.pBt; /* The BTree */ + + Debug.Assert( pRoot.nOverflow > 0 ); + Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); + + /* Make pRoot, the root page of the b-tree, writable. Allocate a new + ** page that will become the new right-child of pPage. Copy the contents + ** of the node stored on pRoot into the new child page. + */ + rc = sqlite3PagerWrite( pRoot.pDbPage ); + if ( rc == SQLITE_OK ) + { + rc = allocateBtreePage( pBt, ref pChild, ref pgnoChild, pRoot.pgno, 0 ); + copyNodeContent( pRoot, pChild, ref rc ); #if !SQLITE_OMIT_AUTOVACUUM // if ( ISAUTOVACUUM ) - if (pBt.autoVacuum) + if ( pBt.autoVacuum ) #else if (false) #endif - { - ptrmapPut(pBt, pgnoChild, PTRMAP_BTREE, pRoot.pgno, ref rc); - } - } - if (rc != 0) { - ppChild = null; - releasePage(pChild); - return rc; - } - Debug.Assert(sqlite3PagerIswriteable(pChild.pDbPage)); - Debug.Assert(sqlite3PagerIswriteable(pRoot.pDbPage)); - Debug.Assert(pChild.nCell == pRoot.nCell); - - TRACE("BALANCE: copy root %d into %d\n", pRoot.pgno, pChild.pgno); - - /* Copy the overflow cells from pRoot to pChild */ - Array.Copy(pRoot.aOvfl, pChild.aOvfl, pRoot.nOverflow);//memcpy(pChild.aOvfl, pRoot.aOvfl, pRoot.nOverflow*sizeof(pRoot.aOvfl[0])); - pChild.nOverflow = pRoot.nOverflow; - - /* Zero the contents of pRoot. Then install pChild as the right-child. */ - zeroPage(pRoot, pChild.aData[0] & ~PTF_LEAF); - sqlite3Put4byte(pRoot.aData, pRoot.hdrOffset + 8, pgnoChild); - - ppChild = pChild; - return SQLITE_OK; - } + { + ptrmapPut( pBt, pgnoChild, PTRMAP_BTREE, pRoot.pgno, ref rc ); + } + } + if ( rc != 0 ) + { + ppChild = null; + releasePage( pChild ); + return rc; + } + Debug.Assert( sqlite3PagerIswriteable( pChild.pDbPage ) ); + Debug.Assert( sqlite3PagerIswriteable( pRoot.pDbPage ) ); + Debug.Assert( pChild.nCell == pRoot.nCell ); + + TRACE( "BALANCE: copy root %d into %d\n", pRoot.pgno, pChild.pgno ); + + /* Copy the overflow cells from pRoot to pChild */ + Array.Copy( pRoot.aOvfl, pChild.aOvfl, pRoot.nOverflow );//memcpy(pChild.aOvfl, pRoot.aOvfl, pRoot.nOverflow*sizeof(pRoot.aOvfl[0])); + pChild.nOverflow = pRoot.nOverflow; + + /* Zero the contents of pRoot. Then install pChild as the right-child. */ + zeroPage( pRoot, pChild.aData[0] & ~PTF_LEAF ); + sqlite3Put4byte( pRoot.aData, pRoot.hdrOffset + 8, pgnoChild ); + + ppChild = pChild; + return SQLITE_OK; +} - /* - ** The page that pCur currently points to has just been modified in - ** some way. This function figures out if this modification means the - ** tree needs to be balanced, and if so calls the appropriate balancing - ** routine. Balancing routines are: - ** - ** balance_quick() - ** balance_deeper() - ** balance_nonroot() - */ - static u8[] aBalanceQuickSpace = new u8[13]; - static int balance(BtCursor pCur) { - int rc = SQLITE_OK; - int nMin = (int)pCur.pBt.usableSize * 2 / 3; +/* +** The page that pCur currently points to has just been modified in +** some way. This function figures out if this modification means the +** tree needs to be balanced, and if so calls the appropriate balancing +** routine. Balancing routines are: +** +** balance_quick() +** balance_deeper() +** balance_nonroot() +*/ +static u8[] aBalanceQuickSpace = new u8[13]; +static int balance( BtCursor pCur ) +{ + int rc = SQLITE_OK; + int nMin = (int)pCur.pBt.usableSize * 2 / 3; - //u8[] pFree = null; + //u8[] pFree = null; #if !NDEBUG || SQLITE_COVERAGE_TEST || DEBUG - int balance_quick_called = 0;//TESTONLY( int balance_quick_called = 0 ); - int balance_deeper_called = 0;//TESTONLY( int balance_deeper_called = 0 ); + int balance_quick_called = 0;//TESTONLY( int balance_quick_called = 0 ); + int balance_deeper_called = 0;//TESTONLY( int balance_deeper_called = 0 ); #else int balance_quick_called = 0; int balance_deeper_called = 0; #endif - do { - int iPage = pCur.iPage; - MemPage pPage = pCur.apPage[iPage]; - - if (iPage == 0) { - if (pPage.nOverflow != 0) { - /* The root page of the b-tree is overfull. In this case call the - ** balance_deeper() function to create a new child for the root-page - ** and copy the current contents of the root-page to it. The - ** next iteration of the do-loop will balance the child page. - */ - Debug.Assert((balance_deeper_called++) == 0); - rc = balance_deeper(pPage, ref pCur.apPage[1]); - if (rc == SQLITE_OK) { - pCur.iPage = 1; - pCur.aiIdx[0] = 0; - pCur.aiIdx[1] = 0; - Debug.Assert(pCur.apPage[1].nOverflow != 0); - } - } else { - break; - } - } else if (pPage.nOverflow == 0 && pPage.nFree <= nMin) { - break; - } else { - MemPage pParent = pCur.apPage[iPage - 1]; - int iIdx = pCur.aiIdx[iPage - 1]; - - rc = sqlite3PagerWrite(pParent.pDbPage); - if (rc == SQLITE_OK) { -#if !SQLITE_OMIT_QUICKBALANCE - if (pPage.hasData != 0 - && pPage.nOverflow == 1 - && pPage.aOvfl[0].idx == pPage.nCell - && pParent.pgno != 1 - && pParent.nCell == iIdx - ) { - /* Call balance_quick() to create a new sibling of pPage on which - ** to store the overflow cell. balance_quick() inserts a new cell - ** into pParent, which may cause pParent overflow. If this - ** happens, the next interation of the do-loop will balance pParent - ** use either balance_nonroot() or balance_deeper(). Until this - ** happens, the overflow cell is stored in the aBalanceQuickSpace[] - ** buffer. - ** - ** The purpose of the following Debug.Assert() is to check that only a - ** single call to balance_quick() is made for each call to this - ** function. If this were not verified, a subtle bug involving reuse - ** of the aBalanceQuickSpace[] might sneak in. - */ - Debug.Assert((balance_quick_called++) == 0); - rc = balance_quick(pParent, pPage, aBalanceQuickSpace); - } else -#endif - { - /* In this case, call balance_nonroot() to redistribute cells - ** between pPage and up to 2 of its sibling pages. This involves - ** modifying the contents of pParent, which may cause pParent to - ** become overfull or underfull. The next iteration of the do-loop - ** will balance the parent page to correct this. - ** - ** If the parent page becomes overfull, the overflow cell or cells - ** are stored in the pSpace buffer allocated immediately below. - ** A subsequent iteration of the do-loop will deal with this by - ** calling balance_nonroot() (balance_deeper() may be called first, - ** but it doesn't deal with overflow cells - just moves them to a - ** different page). Once this subsequent call to balance_nonroot() - ** has completed, it is safe to release the pSpace buffer used by - ** the previous call, as the overflow cell data will have been - ** copied either into the body of a database page or into the new - ** pSpace buffer passed to the latter call to balance_nonroot(). - */ - ////u8[] pSpace = new u8[pCur.pBt.pageSize];// u8 pSpace = sqlite3PageMalloc( pCur.pBt.pageSize ); - rc = balance_nonroot(pParent, iIdx, null, iPage == 1 ? 1 : 0); - //if (pFree != null) - //{ - // /* If pFree is not NULL, it points to the pSpace buffer used - // ** by a previous call to balance_nonroot(). Its contents are - // ** now stored either on real database pages or within the - // ** new pSpace buffer, so it may be safely freed here. */ - // sqlite3PageFree(ref pFree); - //} - - /* The pSpace buffer will be freed after the next call to - ** balance_nonroot(), or just before this function returns, whichever - ** comes first. */ - //pFree = pSpace; - } - } - - pPage.nOverflow = 0; - - /* The next iteration of the do-loop balances the parent page. */ - releasePage(pPage); - pCur.iPage--; - } - } while (rc == SQLITE_OK); - - //if (pFree != null) - //{ - // sqlite3PageFree(ref pFree); - //} - return rc; - } - - - /* - ** Insert a new record into the BTree. The key is given by (pKey,nKey) - ** and the data is given by (pData,nData). The cursor is used only to - ** define what table the record should be inserted into. The cursor - ** is left pointing at a random location. - ** - ** For an INTKEY table, only the nKey value of the key is used. pKey is - ** ignored. For a ZERODATA table, the pData and nData are both ignored. - ** - ** If the seekResult parameter is non-zero, then a successful call to - ** MovetoUnpacked() to seek cursor pCur to (pKey, nKey) has already - ** been performed. seekResult is the search result returned (a negative - ** number if pCur points at an entry that is smaller than (pKey, nKey), or - ** a positive value if pCur points at an etry that is larger than - ** (pKey, nKey)). - ** - ** If the seekResult parameter is non-zero, then the caller guarantees that - ** cursor pCur is pointing at the existing copy of a row that is to be - ** overwritten. If the seekResult parameter is 0, then cursor pCur may - ** point to any entry or to no entry at all and so this function has to seek - ** the cursor before the new key can be inserted. - */ - static int sqlite3BtreeInsert( - BtCursor pCur, /* Insert data into the table of this cursor */ - byte[] pKey, i64 nKey, /* The key of the new record */ - byte[] pData, int nData, /* The data of the new record */ - int nZero, /* Number of extra 0 bytes to append to data */ - int appendBias, /* True if this is likely an append */ - int seekResult /* Result of prior MovetoUnpacked() call */ - ) { - int rc; - int loc = seekResult; /* -1: before desired location +1: after */ - int szNew = 0; - int idx; - MemPage pPage; - Btree p = pCur.pBtree; - BtShared pBt = p.pBt; - int oldCell; - byte[] newCell = null; - - if (pCur.eState == CURSOR_FAULT) { - Debug.Assert(pCur.skipNext != SQLITE_OK); - return pCur.skipNext; - } - - Debug.Assert(cursorHoldsMutex(pCur)); - Debug.Assert(pCur.wrFlag != 0 && pBt.inTransaction == TRANS_WRITE && !pBt.readOnly); - Debug.Assert(hasSharedCacheTableLock(p, pCur.pgnoRoot, pCur.pKeyInfo != null ? 1 : 0, 2)); - - /* Assert that the caller has been consistent. If this cursor was opened - ** expecting an index b-tree, then the caller should be inserting blob - ** keys with no associated data. If the cursor was opened expecting an - ** intkey table, the caller should be inserting integer keys with a - ** blob of associated data. */ - Debug.Assert((pKey == null) == (pCur.pKeyInfo == null)); - - /* If this is an insert into a table b-tree, invalidate any incrblob - ** cursors open on the row being replaced (assuming this is a replace - ** operation - if it is not, the following is a no-op). */ - if (pCur.pKeyInfo == null) { - invalidateIncrblobCursors(p, nKey, 0); - } + do + { + int iPage = pCur.iPage; + MemPage pPage = pCur.apPage[iPage]; - /* Save the positions of any other cursors open on this table. - ** - ** In some cases, the call to btreeMoveto() below is a no-op. For - ** example, when inserting data into a table with auto-generated integer - ** keys, the VDBE layer invokes sqlite3BtreeLast() to figure out the - ** integer key to use. It then calls this function to actually insert the - ** data into the intkey B-Tree. In this case btreeMoveto() recognizes - ** that the cursor is already where it needs to be and returns without - ** doing any work. To avoid thwarting these optimizations, it is important - ** not to clear the cursor here. - */ - rc = saveAllCursors(pBt, pCur.pgnoRoot, pCur); - if (rc != 0) - return rc; - if (0 == loc) { - rc = btreeMoveto(pCur, pKey, nKey, appendBias, ref loc); - if (rc != 0) - return rc; - } - Debug.Assert(pCur.eState == CURSOR_VALID || (pCur.eState == CURSOR_INVALID && loc != 0)); - - pPage = pCur.apPage[pCur.iPage]; - Debug.Assert(pPage.intKey != 0 || nKey >= 0); - Debug.Assert(pPage.leaf != 0 || 0 == pPage.intKey); - - TRACE("INSERT: table=%d nkey=%lld ndata=%d page=%d %s\n", - pCur.pgnoRoot, nKey, nData, pPage.pgno, - loc == 0 ? "overwrite" : "new entry"); - Debug.Assert(pPage.isInit != 0); - allocateTempSpace(pBt); - newCell = pBt.pTmpSpace; - //if (newCell == null) return SQLITE_NOMEM; - rc = fillInCell(pPage, newCell, pKey, nKey, pData, nData, nZero, ref szNew); - if (rc != 0) - goto end_insert; - Debug.Assert(szNew == cellSizePtr(pPage, newCell)); - Debug.Assert(szNew <= MX_CELL_SIZE(pBt)); - idx = pCur.aiIdx[pCur.iPage]; - if (loc == 0) { - u16 szOld; - Debug.Assert(idx < pPage.nCell); - rc = sqlite3PagerWrite(pPage.pDbPage); - if (rc != 0) { - goto end_insert; - } - oldCell = findCell(pPage, idx); - if (0 == pPage.leaf) { - //memcpy(newCell, oldCell, 4); - newCell[0] = pPage.aData[oldCell + 0]; - newCell[1] = pPage.aData[oldCell + 1]; - newCell[2] = pPage.aData[oldCell + 2]; - newCell[3] = pPage.aData[oldCell + 3]; - } - szOld = cellSizePtr(pPage, oldCell); - rc = clearCell(pPage, oldCell); - dropCell(pPage, idx, szOld, ref rc); - if (rc != 0) - goto end_insert; - } else if (loc < 0 && pPage.nCell > 0) { - Debug.Assert(pPage.leaf != 0); - idx = ++pCur.aiIdx[pCur.iPage]; - } else { - Debug.Assert(pPage.leaf != 0); - } - insertCell(pPage, idx, newCell, szNew, null, 0, ref rc); - Debug.Assert(rc != SQLITE_OK || pPage.nCell > 0 || pPage.nOverflow > 0); - - /* If no error has occured and pPage has an overflow cell, call balance() - ** to redistribute the cells within the tree. Since balance() may move - ** the cursor, zero the BtCursor.info.nSize and BtCursor.validNKey - ** variables. - ** - ** Previous versions of SQLite called moveToRoot() to move the cursor - ** back to the root page as balance() used to invalidate the contents - ** of BtCursor.apPage[] and BtCursor.aiIdx[]. Instead of doing that, - ** set the cursor state to "invalid". This makes common insert operations - ** slightly faster. - ** - ** There is a subtle but important optimization here too. When inserting - ** multiple records into an intkey b-tree using a single cursor (as can - ** happen while processing an "INSERT INTO ... SELECT" statement), it - ** is advantageous to leave the cursor pointing to the last entry in - ** the b-tree if possible. If the cursor is left pointing to the last - ** entry in the table, and the next row inserted has an integer key - ** larger than the largest existing key, it is possible to insert the - ** row without seeking the cursor. This can be a big performance boost. - */ - pCur.info.nSize = 0; - pCur.validNKey = false; - if (rc == SQLITE_OK && pPage.nOverflow != 0) { - rc = balance(pCur); - - /* Must make sure nOverflow is reset to zero even if the balance() - ** fails. Internal data structure corruption will result otherwise. - ** Also, set the cursor state to invalid. This stops saveCursorPosition() - ** from trying to save the current position of the cursor. */ - pCur.apPage[pCur.iPage].nOverflow = 0; - pCur.eState = CURSOR_INVALID; - } - Debug.Assert(pCur.apPage[pCur.iPage].nOverflow == 0); + if ( iPage == 0 ) + { + if ( pPage.nOverflow != 0 ) + { + /* The root page of the b-tree is overfull. In this case call the + ** balance_deeper() function to create a new child for the root-page + ** and copy the current contents of the root-page to it. The + ** next iteration of the do-loop will balance the child page. + */ + Debug.Assert( ( balance_deeper_called++ ) == 0 ); + rc = balance_deeper( pPage, ref pCur.apPage[1] ); + if ( rc == SQLITE_OK ) + { + pCur.iPage = 1; + pCur.aiIdx[0] = 0; + pCur.aiIdx[1] = 0; + Debug.Assert( pCur.apPage[1].nOverflow != 0 ); + } + } + else + { + break; + } + } + else if ( pPage.nOverflow == 0 && pPage.nFree <= nMin ) + { + break; + } + else + { + MemPage pParent = pCur.apPage[iPage - 1]; + int iIdx = pCur.aiIdx[iPage - 1]; - end_insert: - return rc; + rc = sqlite3PagerWrite( pParent.pDbPage ); + if ( rc == SQLITE_OK ) + { +#if !SQLITE_OMIT_QUICKBALANCE + if ( pPage.hasData != 0 + && pPage.nOverflow == 1 + && pPage.aOvfl[0].idx == pPage.nCell + && pParent.pgno != 1 + && pParent.nCell == iIdx + ) + { + /* Call balance_quick() to create a new sibling of pPage on which + ** to store the overflow cell. balance_quick() inserts a new cell + ** into pParent, which may cause pParent overflow. If this + ** happens, the next interation of the do-loop will balance pParent + ** use either balance_nonroot() or balance_deeper(). Until this + ** happens, the overflow cell is stored in the aBalanceQuickSpace[] + ** buffer. + ** + ** The purpose of the following Debug.Assert() is to check that only a + ** single call to balance_quick() is made for each call to this + ** function. If this were not verified, a subtle bug involving reuse + ** of the aBalanceQuickSpace[] might sneak in. + */ + Debug.Assert( ( balance_quick_called++ ) == 0 ); + rc = balance_quick( pParent, pPage, aBalanceQuickSpace ); } + else +#endif + { + /* In this case, call balance_nonroot() to redistribute cells + ** between pPage and up to 2 of its sibling pages. This involves + ** modifying the contents of pParent, which may cause pParent to + ** become overfull or underfull. The next iteration of the do-loop + ** will balance the parent page to correct this. + ** + ** If the parent page becomes overfull, the overflow cell or cells + ** are stored in the pSpace buffer allocated immediately below. + ** A subsequent iteration of the do-loop will deal with this by + ** calling balance_nonroot() (balance_deeper() may be called first, + ** but it doesn't deal with overflow cells - just moves them to a + ** different page). Once this subsequent call to balance_nonroot() + ** has completed, it is safe to release the pSpace buffer used by + ** the previous call, as the overflow cell data will have been + ** copied either into the body of a database page or into the new + ** pSpace buffer passed to the latter call to balance_nonroot(). + */ + ////u8[] pSpace = new u8[pCur.pBt.pageSize];// u8 pSpace = sqlite3PageMalloc( pCur.pBt.pageSize ); + rc = balance_nonroot( pParent, iIdx, null, iPage == 1 ? 1 : 0 ); + //if (pFree != null) + //{ + // /* If pFree is not NULL, it points to the pSpace buffer used + // ** by a previous call to balance_nonroot(). Its contents are + // ** now stored either on real database pages or within the + // ** new pSpace buffer, so it may be safely freed here. */ + // sqlite3PageFree(ref pFree); + //} + + /* The pSpace buffer will be freed after the next call to + ** balance_nonroot(), or just before this function returns, whichever + ** comes first. */ + //pFree = pSpace; + } + } + + pPage.nOverflow = 0; + + /* The next iteration of the do-loop balances the parent page. */ + releasePage( pPage ); + pCur.iPage--; + } + } while ( rc == SQLITE_OK ); - /* - ** Delete the entry that the cursor is pointing to. The cursor - ** is left pointing at a arbitrary location. - */ - static int sqlite3BtreeDelete(BtCursor pCur) { - Btree p = pCur.pBtree; - BtShared pBt = p.pBt; - int rc; /* Return code */ - MemPage pPage; /* Page to delete cell from */ - int pCell; /* Pointer to cell to delete */ - int iCellIdx; /* Index of cell to delete */ - int iCellDepth; /* Depth of node containing pCell */ - - Debug.Assert(cursorHoldsMutex(pCur)); - Debug.Assert(pBt.inTransaction == TRANS_WRITE); - Debug.Assert(!pBt.readOnly); - Debug.Assert(pCur.wrFlag != 0); - Debug.Assert(hasSharedCacheTableLock(p, pCur.pgnoRoot, pCur.pKeyInfo != null ? 1 : 0, 2)); - Debug.Assert(!hasReadConflicts(p, pCur.pgnoRoot)); - - if (NEVER(pCur.aiIdx[pCur.iPage] >= pCur.apPage[pCur.iPage].nCell) - || NEVER(pCur.eState != CURSOR_VALID) - ) { - return SQLITE_ERROR; /* Something has gone awry. */ - } - - /* If this is a delete operation to remove a row from a table b-tree, - ** invalidate any incrblob cursors open on the row being deleted. */ - if (pCur.pKeyInfo == null) { - invalidateIncrblobCursors(p, pCur.info.nKey, 0); - } - - iCellDepth = pCur.iPage; - iCellIdx = pCur.aiIdx[iCellDepth]; - pPage = pCur.apPage[iCellDepth]; - pCell = findCell(pPage, iCellIdx); - - /* If the page containing the entry to delete is not a leaf page, move - ** the cursor to the largest entry in the tree that is smaller than - ** the entry being deleted. This cell will replace the cell being deleted - ** from the internal node. The 'previous' entry is used for this instead - ** of the 'next' entry, as the previous entry is always a part of the - ** sub-tree headed by the child page of the cell being deleted. This makes - ** balancing the tree following the delete operation easier. */ - if (0 == pPage.leaf) { - int notUsed = 0; - rc = sqlite3BtreePrevious(pCur, ref notUsed); - if (rc != 0) - return rc; - } + //if (pFree != null) + //{ + // sqlite3PageFree(ref pFree); + //} + return rc; +} - /* Save the positions of any other cursors open on this table before - ** making any modifications. Make the page containing the entry to be - ** deleted writable. Then free any overflow pages associated with the - ** entry and finally remove the cell itself from within the page. - */ - rc = saveAllCursors(pBt, pCur.pgnoRoot, pCur); - if (rc != 0) - return rc; - rc = sqlite3PagerWrite(pPage.pDbPage); - if (rc != 0) - return rc; - rc = clearCell(pPage, pCell); - dropCell(pPage, iCellIdx, cellSizePtr(pPage, pCell), ref rc); - if (rc != 0) - return rc; - - /* If the cell deleted was not located on a leaf page, then the cursor - ** is currently pointing to the largest entry in the sub-tree headed - ** by the child-page of the cell that was just deleted from an internal - ** node. The cell from the leaf node needs to be moved to the internal - ** node to replace the deleted cell. */ - if (0 == pPage.leaf) { - MemPage pLeaf = pCur.apPage[pCur.iPage]; - int nCell; - Pgno n = pCur.apPage[iCellDepth + 1].pgno; - //byte[] pTmp; - - pCell = findCell(pLeaf, pLeaf.nCell - 1); - nCell = cellSizePtr(pLeaf, pCell); - Debug.Assert(MX_CELL_SIZE(pBt) >= nCell); - - //allocateTempSpace(pBt); - //pTmp = pBt.pTmpSpace; - - rc = sqlite3PagerWrite(pLeaf.pDbPage); - byte[] pNext_4 = sqlite3Malloc(nCell + 4); - Buffer.BlockCopy(pLeaf.aData, pCell - 4, pNext_4, 0, nCell + 4); - insertCell(pPage, iCellIdx, pNext_4, nCell + 4, null, n, ref rc); //insertCell( pPage, iCellIdx, pCell - 4, nCell + 4, pTmp, n, ref rc ); - dropCell(pLeaf, pLeaf.nCell - 1, nCell, ref rc); - if (rc != 0) - return rc; - } - /* Balance the tree. If the entry deleted was located on a leaf page, - ** then the cursor still points to that page. In this case the first - ** call to balance() repairs the tree, and the if(...) condition is - ** never true. - ** - ** Otherwise, if the entry deleted was on an internal node page, then - ** pCur is pointing to the leaf page from which a cell was removed to - ** replace the cell deleted from the internal node. This is slightly - ** tricky as the leaf node may be underfull, and the internal node may - ** be either under or overfull. In this case run the balancing algorithm - ** on the leaf node first. If the balance proceeds far enough up the - ** tree that we can be sure that any problem in the internal node has - ** been corrected, so be it. Otherwise, after balancing the leaf node, - ** walk the cursor up the tree to the internal node and balance it as - ** well. */ - rc = balance(pCur); - if (rc == SQLITE_OK && pCur.iPage > iCellDepth) { - while (pCur.iPage > iCellDepth) { - releasePage(pCur.apPage[pCur.iPage--]); - } - rc = balance(pCur); - } +/* +** Insert a new record into the BTree. The key is given by (pKey,nKey) +** and the data is given by (pData,nData). The cursor is used only to +** define what table the record should be inserted into. The cursor +** is left pointing at a random location. +** +** For an INTKEY table, only the nKey value of the key is used. pKey is +** ignored. For a ZERODATA table, the pData and nData are both ignored. +** +** If the seekResult parameter is non-zero, then a successful call to +** MovetoUnpacked() to seek cursor pCur to (pKey, nKey) has already +** been performed. seekResult is the search result returned (a negative +** number if pCur points at an entry that is smaller than (pKey, nKey), or +** a positive value if pCur points at an etry that is larger than +** (pKey, nKey)). +** +** If the seekResult parameter is non-zero, then the caller guarantees that +** cursor pCur is pointing at the existing copy of a row that is to be +** overwritten. If the seekResult parameter is 0, then cursor pCur may +** point to any entry or to no entry at all and so this function has to seek +** the cursor before the new key can be inserted. +*/ +static int sqlite3BtreeInsert( +BtCursor pCur, /* Insert data into the table of this cursor */ +byte[] pKey, i64 nKey, /* The key of the new record */ +byte[] pData, int nData, /* The data of the new record */ +int nZero, /* Number of extra 0 bytes to append to data */ +int appendBias, /* True if this is likely an append */ +int seekResult /* Result of prior MovetoUnpacked() call */ +) +{ + int rc; + int loc = seekResult; /* -1: before desired location +1: after */ + int szNew = 0; + int idx; + MemPage pPage; + Btree p = pCur.pBtree; + BtShared pBt = p.pBt; + int oldCell; + byte[] newCell = null; + + if ( pCur.eState == CURSOR_FAULT ) + { + Debug.Assert( pCur.skipNext != SQLITE_OK ); + return pCur.skipNext; + } + + Debug.Assert( cursorHoldsMutex( pCur ) ); + Debug.Assert( pCur.wrFlag != 0 && pBt.inTransaction == TRANS_WRITE && !pBt.readOnly ); + Debug.Assert( hasSharedCacheTableLock( p, pCur.pgnoRoot, pCur.pKeyInfo != null ? 1 : 0, 2 ) ); + + /* Assert that the caller has been consistent. If this cursor was opened + ** expecting an index b-tree, then the caller should be inserting blob + ** keys with no associated data. If the cursor was opened expecting an + ** intkey table, the caller should be inserting integer keys with a + ** blob of associated data. */ + Debug.Assert( ( pKey == null ) == ( pCur.pKeyInfo == null ) ); + + /* If this is an insert into a table b-tree, invalidate any incrblob + ** cursors open on the row being replaced (assuming this is a replace + ** operation - if it is not, the following is a no-op). */ + if ( pCur.pKeyInfo == null ) + { + invalidateIncrblobCursors( p, nKey, 0 ); + } + + /* Save the positions of any other cursors open on this table. + ** + ** In some cases, the call to btreeMoveto() below is a no-op. For + ** example, when inserting data into a table with auto-generated integer + ** keys, the VDBE layer invokes sqlite3BtreeLast() to figure out the + ** integer key to use. It then calls this function to actually insert the + ** data into the intkey B-Tree. In this case btreeMoveto() recognizes + ** that the cursor is already where it needs to be and returns without + ** doing any work. To avoid thwarting these optimizations, it is important + ** not to clear the cursor here. + */ + rc = saveAllCursors( pBt, pCur.pgnoRoot, pCur ); + if ( rc != 0 ) + return rc; + if ( 0 == loc ) + { + rc = btreeMoveto( pCur, pKey, nKey, appendBias, ref loc ); + if ( rc != 0 ) + return rc; + } + Debug.Assert( pCur.eState == CURSOR_VALID || ( pCur.eState == CURSOR_INVALID && loc != 0 ) ); + + pPage = pCur.apPage[pCur.iPage]; + Debug.Assert( pPage.intKey != 0 || nKey >= 0 ); + Debug.Assert( pPage.leaf != 0 || 0 == pPage.intKey ); + + TRACE( "INSERT: table=%d nkey=%lld ndata=%d page=%d %s\n", + pCur.pgnoRoot, nKey, nData, pPage.pgno, + loc == 0 ? "overwrite" : "new entry" ); + Debug.Assert( pPage.isInit != 0 ); + allocateTempSpace( pBt ); + newCell = pBt.pTmpSpace; + //if (newCell == null) return SQLITE_NOMEM; + rc = fillInCell( pPage, newCell, pKey, nKey, pData, nData, nZero, ref szNew ); + if ( rc != 0 ) + goto end_insert; + Debug.Assert( szNew == cellSizePtr( pPage, newCell ) ); + Debug.Assert( szNew <= MX_CELL_SIZE( pBt ) ); + idx = pCur.aiIdx[pCur.iPage]; + if ( loc == 0 ) + { + u16 szOld; + Debug.Assert( idx < pPage.nCell ); + rc = sqlite3PagerWrite( pPage.pDbPage ); + if ( rc != 0 ) + { + goto end_insert; + } + oldCell = findCell( pPage, idx ); + if ( 0 == pPage.leaf ) + { + //memcpy(newCell, oldCell, 4); + newCell[0] = pPage.aData[oldCell + 0]; + newCell[1] = pPage.aData[oldCell + 1]; + newCell[2] = pPage.aData[oldCell + 2]; + newCell[3] = pPage.aData[oldCell + 3]; + } + szOld = cellSizePtr( pPage, oldCell ); + rc = clearCell( pPage, oldCell ); + dropCell( pPage, idx, szOld, ref rc ); + if ( rc != 0 ) + goto end_insert; + } + else if ( loc < 0 && pPage.nCell > 0 ) + { + Debug.Assert( pPage.leaf != 0 ); + idx = ++pCur.aiIdx[pCur.iPage]; + } + else + { + Debug.Assert( pPage.leaf != 0 ); + } + insertCell( pPage, idx, newCell, szNew, null, 0, ref rc ); + Debug.Assert( rc != SQLITE_OK || pPage.nCell > 0 || pPage.nOverflow > 0 ); + + /* If no error has occured and pPage has an overflow cell, call balance() + ** to redistribute the cells within the tree. Since balance() may move + ** the cursor, zero the BtCursor.info.nSize and BtCursor.validNKey + ** variables. + ** + ** Previous versions of SQLite called moveToRoot() to move the cursor + ** back to the root page as balance() used to invalidate the contents + ** of BtCursor.apPage[] and BtCursor.aiIdx[]. Instead of doing that, + ** set the cursor state to "invalid". This makes common insert operations + ** slightly faster. + ** + ** There is a subtle but important optimization here too. When inserting + ** multiple records into an intkey b-tree using a single cursor (as can + ** happen while processing an "INSERT INTO ... SELECT" statement), it + ** is advantageous to leave the cursor pointing to the last entry in + ** the b-tree if possible. If the cursor is left pointing to the last + ** entry in the table, and the next row inserted has an integer key + ** larger than the largest existing key, it is possible to insert the + ** row without seeking the cursor. This can be a big performance boost. + */ + pCur.info.nSize = 0; + pCur.validNKey = false; + if ( rc == SQLITE_OK && pPage.nOverflow != 0 ) + { + rc = balance( pCur ); + + /* Must make sure nOverflow is reset to zero even if the balance() + ** fails. Internal data structure corruption will result otherwise. + ** Also, set the cursor state to invalid. This stops saveCursorPosition() + ** from trying to save the current position of the cursor. */ + pCur.apPage[pCur.iPage].nOverflow = 0; + pCur.eState = CURSOR_INVALID; + } + Debug.Assert( pCur.apPage[pCur.iPage].nOverflow == 0 ); + +end_insert: + return rc; +} - if (rc == SQLITE_OK) { - moveToRoot(pCur); - } - return rc; - } +/* +** Delete the entry that the cursor is pointing to. The cursor +** is left pointing at a arbitrary location. +*/ +static int sqlite3BtreeDelete( BtCursor pCur ) +{ + Btree p = pCur.pBtree; + BtShared pBt = p.pBt; + int rc; /* Return code */ + MemPage pPage; /* Page to delete cell from */ + int pCell; /* Pointer to cell to delete */ + int iCellIdx; /* Index of cell to delete */ + int iCellDepth; /* Depth of node containing pCell */ + + Debug.Assert( cursorHoldsMutex( pCur ) ); + Debug.Assert( pBt.inTransaction == TRANS_WRITE ); + Debug.Assert( !pBt.readOnly ); + Debug.Assert( pCur.wrFlag != 0 ); + Debug.Assert( hasSharedCacheTableLock( p, pCur.pgnoRoot, pCur.pKeyInfo != null ? 1 : 0, 2 ) ); + Debug.Assert( !hasReadConflicts( p, pCur.pgnoRoot ) ); + + if ( NEVER( pCur.aiIdx[pCur.iPage] >= pCur.apPage[pCur.iPage].nCell ) + || NEVER( pCur.eState != CURSOR_VALID ) + ) + { + return SQLITE_ERROR; /* Something has gone awry. */ + } + + /* If this is a delete operation to remove a row from a table b-tree, + ** invalidate any incrblob cursors open on the row being deleted. */ + if ( pCur.pKeyInfo == null ) + { + invalidateIncrblobCursors( p, pCur.info.nKey, 0 ); + } + + iCellDepth = pCur.iPage; + iCellIdx = pCur.aiIdx[iCellDepth]; + pPage = pCur.apPage[iCellDepth]; + pCell = findCell( pPage, iCellIdx ); + + /* If the page containing the entry to delete is not a leaf page, move + ** the cursor to the largest entry in the tree that is smaller than + ** the entry being deleted. This cell will replace the cell being deleted + ** from the internal node. The 'previous' entry is used for this instead + ** of the 'next' entry, as the previous entry is always a part of the + ** sub-tree headed by the child page of the cell being deleted. This makes + ** balancing the tree following the delete operation easier. */ + if ( 0 == pPage.leaf ) + { + int notUsed = 0; + rc = sqlite3BtreePrevious( pCur, ref notUsed ); + if ( rc != 0 ) + return rc; + } + + /* Save the positions of any other cursors open on this table before + ** making any modifications. Make the page containing the entry to be + ** deleted writable. Then free any overflow pages associated with the + ** entry and finally remove the cell itself from within the page. + */ + rc = saveAllCursors( pBt, pCur.pgnoRoot, pCur ); + if ( rc != 0 ) + return rc; + rc = sqlite3PagerWrite( pPage.pDbPage ); + if ( rc != 0 ) + return rc; + rc = clearCell( pPage, pCell ); + dropCell( pPage, iCellIdx, cellSizePtr( pPage, pCell ), ref rc ); + if ( rc != 0 ) + return rc; + + /* If the cell deleted was not located on a leaf page, then the cursor + ** is currently pointing to the largest entry in the sub-tree headed + ** by the child-page of the cell that was just deleted from an internal + ** node. The cell from the leaf node needs to be moved to the internal + ** node to replace the deleted cell. */ + if ( 0 == pPage.leaf ) + { + MemPage pLeaf = pCur.apPage[pCur.iPage]; + int nCell; + Pgno n = pCur.apPage[iCellDepth + 1].pgno; + //byte[] pTmp; + + pCell = findCell( pLeaf, pLeaf.nCell - 1 ); + nCell = cellSizePtr( pLeaf, pCell ); + Debug.Assert( MX_CELL_SIZE( pBt ) >= nCell ); + + //allocateTempSpace(pBt); + //pTmp = pBt.pTmpSpace; + + rc = sqlite3PagerWrite( pLeaf.pDbPage ); + byte[] pNext_4 = sqlite3Malloc( nCell + 4 ); + Buffer.BlockCopy( pLeaf.aData, pCell - 4, pNext_4, 0, nCell + 4 ); + insertCell( pPage, iCellIdx, pNext_4, nCell + 4, null, n, ref rc ); //insertCell( pPage, iCellIdx, pCell - 4, nCell + 4, pTmp, n, ref rc ); + dropCell( pLeaf, pLeaf.nCell - 1, nCell, ref rc ); + if ( rc != 0 ) + return rc; + } + + /* Balance the tree. If the entry deleted was located on a leaf page, + ** then the cursor still points to that page. In this case the first + ** call to balance() repairs the tree, and the if(...) condition is + ** never true. + ** + ** Otherwise, if the entry deleted was on an internal node page, then + ** pCur is pointing to the leaf page from which a cell was removed to + ** replace the cell deleted from the internal node. This is slightly + ** tricky as the leaf node may be underfull, and the internal node may + ** be either under or overfull. In this case run the balancing algorithm + ** on the leaf node first. If the balance proceeds far enough up the + ** tree that we can be sure that any problem in the internal node has + ** been corrected, so be it. Otherwise, after balancing the leaf node, + ** walk the cursor up the tree to the internal node and balance it as + ** well. */ + rc = balance( pCur ); + if ( rc == SQLITE_OK && pCur.iPage > iCellDepth ) + { + while ( pCur.iPage > iCellDepth ) + { + releasePage( pCur.apPage[pCur.iPage--] ); + } + rc = balance( pCur ); + } + + if ( rc == SQLITE_OK ) + { + moveToRoot( pCur ); + } + return rc; +} - /* - ** Create a new BTree table. Write into piTable the page - ** number for the root page of the new table. - ** - ** The type of type is determined by the flags parameter. Only the - ** following values of flags are currently in use. Other values for - ** flags might not work: - ** - ** BTREE_INTKEY|BTREE_LEAFDATA Used for SQL tables with rowid keys - ** BTREE_ZERODATA Used for SQL indices - */ - static int btreeCreateTable(Btree p, ref int piTable, int createTabFlags) { - BtShared pBt = p.pBt; - MemPage pRoot = new MemPage(); - Pgno pgnoRoot = 0; - int rc; - int ptfFlags; /* Page-type flage for the root page of new table */ +/* +** Create a new BTree table. Write into piTable the page +** number for the root page of the new table. +** +** The type of type is determined by the flags parameter. Only the +** following values of flags are currently in use. Other values for +** flags might not work: +** +** BTREE_INTKEY|BTREE_LEAFDATA Used for SQL tables with rowid keys +** BTREE_ZERODATA Used for SQL indices +*/ +static int btreeCreateTable( Btree p, ref int piTable, int createTabFlags ) +{ + BtShared pBt = p.pBt; + MemPage pRoot = new MemPage(); + Pgno pgnoRoot = 0; + int rc; + int ptfFlags; /* Page-type flage for the root page of new table */ - Debug.Assert(sqlite3BtreeHoldsMutex(p)); - Debug.Assert(pBt.inTransaction == TRANS_WRITE); - Debug.Assert(!pBt.readOnly); + Debug.Assert( sqlite3BtreeHoldsMutex( p ) ); + Debug.Assert( pBt.inTransaction == TRANS_WRITE ); + Debug.Assert( !pBt.readOnly ); #if SQLITE_OMIT_AUTOVACUUM rc = allocateBtreePage(pBt, ref pRoot, ref pgnoRoot, 1, 0); @@ -7400,1079 +8129,1216 @@ static int btreeCreateTable(Btree p, ref int piTable, int createTabFlags) { return rc; } #else - if (pBt.autoVacuum) { - Pgno pgnoMove = 0; /* Move a page here to make room for the root-page */ - MemPage pPageMove = new MemPage(); /* The page to move to. */ - - /* Creating a new table may probably require moving an existing database - ** to make room for the new tables root page. In case this page turns - ** out to be an overflow page, delete all overflow page-map caches - ** held by open cursors. - */ - invalidateAllOverflowCache(pBt); - - /* Read the value of meta[3] from the database to determine where the - ** root page of the new table should go. meta[3] is the largest root-page - ** created so far, so the new root-page is (meta[3]+1). - */ - sqlite3BtreeGetMeta(p, BTREE_LARGEST_ROOT_PAGE, ref pgnoRoot); - pgnoRoot++; - - /* The new root-page may not be allocated on a pointer-map page, or the - ** PENDING_BYTE page. - */ - while (pgnoRoot == PTRMAP_PAGENO(pBt, pgnoRoot) || - pgnoRoot == PENDING_BYTE_PAGE(pBt)) { - pgnoRoot++; - } - Debug.Assert(pgnoRoot >= 3); - - /* Allocate a page. The page that currently resides at pgnoRoot will - ** be moved to the allocated page (unless the allocated page happens - ** to reside at pgnoRoot). - */ - rc = allocateBtreePage(pBt, ref pPageMove, ref pgnoMove, pgnoRoot, 1); - if (rc != SQLITE_OK) { - return rc; - } - - if (pgnoMove != pgnoRoot) { - /* pgnoRoot is the page that will be used for the root-page of - ** the new table (assuming an error did not occur). But we were - ** allocated pgnoMove. If required (i.e. if it was not allocated - ** by extending the file), the current page at position pgnoMove - ** is already journaled. - */ - u8 eType = 0; - Pgno iPtrPage = 0; - - releasePage(pPageMove); - - /* Move the page currently at pgnoRoot to pgnoMove. */ - rc = btreeGetPage(pBt, pgnoRoot, ref pRoot, 0); - if (rc != SQLITE_OK) { - return rc; - } - rc = ptrmapGet(pBt, pgnoRoot, ref eType, ref iPtrPage); - if (eType == PTRMAP_ROOTPAGE || eType == PTRMAP_FREEPAGE) { - rc = SQLITE_CORRUPT_BKPT(); - } - if (rc != SQLITE_OK) { - releasePage(pRoot); - return rc; - } - Debug.Assert(eType != PTRMAP_ROOTPAGE); - Debug.Assert(eType != PTRMAP_FREEPAGE); - rc = relocatePage(pBt, pRoot, eType, iPtrPage, pgnoMove, 0); - releasePage(pRoot); - - /* Obtain the page at pgnoRoot */ - if (rc != SQLITE_OK) { - return rc; - } - rc = btreeGetPage(pBt, pgnoRoot, ref pRoot, 0); - if (rc != SQLITE_OK) { - return rc; - } - rc = sqlite3PagerWrite(pRoot.pDbPage); - if (rc != SQLITE_OK) { - releasePage(pRoot); - return rc; - } - } else { - pRoot = pPageMove; - } - - /* Update the pointer-map and meta-data with the new root-page number. */ - ptrmapPut(pBt, pgnoRoot, PTRMAP_ROOTPAGE, 0, ref rc); - if (rc != 0) { - releasePage(pRoot); - return rc; - } - - /* When the new root page was allocated, page 1 was made writable in - ** order either to increase the database filesize, or to decrement the - ** freelist count. Hence, the sqlite3BtreeUpdateMeta() call cannot fail. - */ - Debug.Assert(sqlite3PagerIswriteable(pBt.pPage1.pDbPage)); - rc = sqlite3BtreeUpdateMeta(p, 4, pgnoRoot); - if (NEVER(rc != 0)) { - releasePage(pRoot); - return rc; - } - - } else { - rc = allocateBtreePage(pBt, ref pRoot, ref pgnoRoot, 1, 0); - if (rc != 0) - return rc; - } -#endif - Debug.Assert(sqlite3PagerIswriteable(pRoot.pDbPage)); - if ((createTabFlags & BTREE_INTKEY) != 0) { - ptfFlags = PTF_INTKEY | PTF_LEAFDATA | PTF_LEAF; - } else { - ptfFlags = PTF_ZERODATA | PTF_LEAF; - } - zeroPage(pRoot, ptfFlags); - sqlite3PagerUnref(pRoot.pDbPage); - Debug.Assert((pBt.openFlags & BTREE_SINGLE) == 0 || pgnoRoot == 2); - piTable = (int)pgnoRoot; - return SQLITE_OK; - } - static int sqlite3BtreeCreateTable(Btree p, ref int piTable, int flags) { - int rc; - sqlite3BtreeEnter(p); - rc = btreeCreateTable(p, ref piTable, flags); - sqlite3BtreeLeave(p); - return rc; - } - - /* - ** Erase the given database page and all its children. Return - ** the page to the freelist. - */ - static int clearDatabasePage( - BtShared pBt, /* The BTree that contains the table */ - Pgno pgno, /* Page number to clear */ - int freePageFlag, /* Deallocate page if true */ - ref int pnChange /* Add number of Cells freed to this counter */ - ) { - MemPage pPage = new MemPage(); - int rc; - byte[] pCell; - int i; - - Debug.Assert(sqlite3_mutex_held(pBt.mutex)); - if (pgno > btreePagecount(pBt)) { - return SQLITE_CORRUPT_BKPT(); - } - - rc = getAndInitPage(pBt, pgno, ref pPage); - if (rc != 0) - return rc; - for (i = 0; i < pPage.nCell; i++) { - int iCell = findCell(pPage, i); - pCell = pPage.aData; // pCell = findCell( pPage, i ); - if (0 == pPage.leaf) { - rc = clearDatabasePage(pBt, sqlite3Get4byte(pCell, iCell), 1, ref pnChange); - if (rc != 0) - goto cleardatabasepage_out; - } - rc = clearCell(pPage, iCell); - if (rc != 0) - goto cleardatabasepage_out; - } - if (0 == pPage.leaf) { - rc = clearDatabasePage(pBt, sqlite3Get4byte(pPage.aData, 8), 1, ref pnChange); - if (rc != 0) - goto cleardatabasepage_out; - } else //if (pnChange != 0) - { - //Debug.Assert(pPage.intKey != 0); - pnChange += pPage.nCell; - } - if (freePageFlag != 0) { - freePage(pPage, ref rc); - } else if ((rc = sqlite3PagerWrite(pPage.pDbPage)) == 0) { - zeroPage(pPage, pPage.aData[0] | PTF_LEAF); - } + if ( pBt.autoVacuum ) + { + Pgno pgnoMove = 0; /* Move a page here to make room for the root-page */ + MemPage pPageMove = new MemPage(); /* The page to move to. */ + + /* Creating a new table may probably require moving an existing database + ** to make room for the new tables root page. In case this page turns + ** out to be an overflow page, delete all overflow page-map caches + ** held by open cursors. + */ + invalidateAllOverflowCache( pBt ); + + /* Read the value of meta[3] from the database to determine where the + ** root page of the new table should go. meta[3] is the largest root-page + ** created so far, so the new root-page is (meta[3]+1). + */ + sqlite3BtreeGetMeta( p, BTREE_LARGEST_ROOT_PAGE, ref pgnoRoot ); + pgnoRoot++; + + /* The new root-page may not be allocated on a pointer-map page, or the + ** PENDING_BYTE page. + */ + while ( pgnoRoot == PTRMAP_PAGENO( pBt, pgnoRoot ) || + pgnoRoot == PENDING_BYTE_PAGE( pBt ) ) + { + pgnoRoot++; + } + Debug.Assert( pgnoRoot >= 3 ); + + /* Allocate a page. The page that currently resides at pgnoRoot will + ** be moved to the allocated page (unless the allocated page happens + ** to reside at pgnoRoot). + */ + rc = allocateBtreePage( pBt, ref pPageMove, ref pgnoMove, pgnoRoot, 1 ); + if ( rc != SQLITE_OK ) + { + return rc; + } - cleardatabasepage_out: - releasePage(pPage); - return rc; - } + if ( pgnoMove != pgnoRoot ) + { + /* pgnoRoot is the page that will be used for the root-page of + ** the new table (assuming an error did not occur). But we were + ** allocated pgnoMove. If required (i.e. if it was not allocated + ** by extending the file), the current page at position pgnoMove + ** is already journaled. + */ + u8 eType = 0; + Pgno iPtrPage = 0; + + releasePage( pPageMove ); + + /* Move the page currently at pgnoRoot to pgnoMove. */ + rc = btreeGetPage( pBt, pgnoRoot, ref pRoot, 0 ); + if ( rc != SQLITE_OK ) + { + return rc; + } + rc = ptrmapGet( pBt, pgnoRoot, ref eType, ref iPtrPage ); + if ( eType == PTRMAP_ROOTPAGE || eType == PTRMAP_FREEPAGE ) + { + rc = SQLITE_CORRUPT_BKPT(); + } + if ( rc != SQLITE_OK ) + { + releasePage( pRoot ); + return rc; + } + Debug.Assert( eType != PTRMAP_ROOTPAGE ); + Debug.Assert( eType != PTRMAP_FREEPAGE ); + rc = relocatePage( pBt, pRoot, eType, iPtrPage, pgnoMove, 0 ); + releasePage( pRoot ); + + /* Obtain the page at pgnoRoot */ + if ( rc != SQLITE_OK ) + { + return rc; + } + rc = btreeGetPage( pBt, pgnoRoot, ref pRoot, 0 ); + if ( rc != SQLITE_OK ) + { + return rc; + } + rc = sqlite3PagerWrite( pRoot.pDbPage ); + if ( rc != SQLITE_OK ) + { + releasePage( pRoot ); + return rc; + } + } + else + { + pRoot = pPageMove; + } - /* - ** Delete all information from a single table in the database. iTable is - ** the page number of the root of the table. After this routine returns, - ** the root page is empty, but still exists. - ** - ** This routine will fail with SQLITE_LOCKED if there are any open - ** read cursors on the table. Open write cursors are moved to the - ** root of the table. - ** - ** If pnChange is not NULL, then table iTable must be an intkey table. The - ** integer value pointed to by pnChange is incremented by the number of - ** entries in the table. - */ - static int sqlite3BtreeClearTable(Btree p, int iTable, ref int pnChange) { - int rc; - BtShared pBt = p.pBt; - sqlite3BtreeEnter(p); - Debug.Assert(p.inTrans == TRANS_WRITE); - - /* Invalidate all incrblob cursors open on table iTable (assuming iTable - ** is the root of a table b-tree - if it is not, the following call is - ** a no-op). */ - invalidateIncrblobCursors(p, 0, 1); - - rc = saveAllCursors(pBt, (Pgno)iTable, null); - if (SQLITE_OK == rc) { - rc = clearDatabasePage(pBt, (Pgno)iTable, 0, ref pnChange); - } - sqlite3BtreeLeave(p); - return rc; - } + /* Update the pointer-map and meta-data with the new root-page number. */ + ptrmapPut( pBt, pgnoRoot, PTRMAP_ROOTPAGE, 0, ref rc ); + if ( rc != 0 ) + { + releasePage( pRoot ); + return rc; + } - /* - ** Erase all information in a table and add the root of the table to - ** the freelist. Except, the root of the principle table (the one on - ** page 1) is never added to the freelist. - ** - ** This routine will fail with SQLITE_LOCKED if there are any open - ** cursors on the table. - ** - ** If AUTOVACUUM is enabled and the page at iTable is not the last - ** root page in the database file, then the last root page - ** in the database file is moved into the slot formerly occupied by - ** iTable and that last slot formerly occupied by the last root page - ** is added to the freelist instead of iTable. In this say, all - ** root pages are kept at the beginning of the database file, which - ** is necessary for AUTOVACUUM to work right. piMoved is set to the - ** page number that used to be the last root page in the file before - ** the move. If no page gets moved, piMoved is set to 0. - ** The last root page is recorded in meta[3] and the value of - ** meta[3] is updated by this procedure. - */ - static int btreeDropTable(Btree p, Pgno iTable, ref int piMoved) { - int rc; - MemPage pPage = null; - BtShared pBt = p.pBt; - - Debug.Assert(sqlite3BtreeHoldsMutex(p)); - Debug.Assert(p.inTrans == TRANS_WRITE); - - /* It is illegal to drop a table if any cursors are open on the - ** database. This is because in auto-vacuum mode the backend may - ** need to move another root-page to fill a gap left by the deleted - ** root page. If an open cursor was using this page a problem would - ** occur. - ** - ** This error is caught long before control reaches this point. - */ - if (NEVER(pBt.pCursor)) { - sqlite3ConnectionBlocked(p.db, pBt.pCursor.pBtree.db); - return SQLITE_LOCKED_SHAREDCACHE; - } + /* When the new root page was allocated, page 1 was made writable in + ** order either to increase the database filesize, or to decrement the + ** freelist count. Hence, the sqlite3BtreeUpdateMeta() call cannot fail. + */ + Debug.Assert( sqlite3PagerIswriteable( pBt.pPage1.pDbPage ) ); + rc = sqlite3BtreeUpdateMeta( p, 4, pgnoRoot ); + if ( NEVER( rc != 0 ) ) + { + releasePage( pRoot ); + return rc; + } - rc = btreeGetPage(pBt, (Pgno)iTable, ref pPage, 0); - if (rc != 0) - return rc; - int Dummy0 = 0; - rc = sqlite3BtreeClearTable(p, (int)iTable, ref Dummy0); - if (rc != 0) { - releasePage(pPage); - return rc; - } + } + else + { + rc = allocateBtreePage( pBt, ref pRoot, ref pgnoRoot, 1, 0 ); + if ( rc != 0 ) + return rc; + } +#endif + Debug.Assert( sqlite3PagerIswriteable( pRoot.pDbPage ) ); + if ( ( createTabFlags & BTREE_INTKEY ) != 0 ) + { + ptfFlags = PTF_INTKEY | PTF_LEAFDATA | PTF_LEAF; + } + else + { + ptfFlags = PTF_ZERODATA | PTF_LEAF; + } + zeroPage( pRoot, ptfFlags ); + sqlite3PagerUnref( pRoot.pDbPage ); + Debug.Assert( ( pBt.openFlags & BTREE_SINGLE ) == 0 || pgnoRoot == 2 ); + piTable = (int)pgnoRoot; + return SQLITE_OK; +} +static int sqlite3BtreeCreateTable( Btree p, ref int piTable, int flags ) +{ + int rc; + sqlite3BtreeEnter( p ); + rc = btreeCreateTable( p, ref piTable, flags ); + sqlite3BtreeLeave( p ); + return rc; +} + +/* +** Erase the given database page and all its children. Return +** the page to the freelist. +*/ +static int clearDatabasePage( +BtShared pBt, /* The BTree that contains the table */ +Pgno pgno, /* Page number to clear */ +int freePageFlag, /* Deallocate page if true */ +ref int pnChange /* Add number of Cells freed to this counter */ +) +{ + MemPage pPage = new MemPage(); + int rc; + byte[] pCell; + int i; + + Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); + if ( pgno > btreePagecount( pBt ) ) + { + return SQLITE_CORRUPT_BKPT(); + } + + rc = getAndInitPage( pBt, pgno, ref pPage ); + if ( rc != 0 ) + return rc; + for ( i = 0; i < pPage.nCell; i++ ) + { + int iCell = findCell( pPage, i ); + pCell = pPage.aData; // pCell = findCell( pPage, i ); + if ( 0 == pPage.leaf ) + { + rc = clearDatabasePage( pBt, sqlite3Get4byte( pCell, iCell ), 1, ref pnChange ); + if ( rc != 0 ) + goto cleardatabasepage_out; + } + rc = clearCell( pPage, iCell ); + if ( rc != 0 ) + goto cleardatabasepage_out; + } + if ( 0 == pPage.leaf ) + { + rc = clearDatabasePage( pBt, sqlite3Get4byte( pPage.aData, 8 ), 1, ref pnChange ); + if ( rc != 0 ) + goto cleardatabasepage_out; + } + else //if (pnChange != 0) + { + //Debug.Assert(pPage.intKey != 0); + pnChange += pPage.nCell; + } + if ( freePageFlag != 0 ) + { + freePage( pPage, ref rc ); + } + else if ( ( rc = sqlite3PagerWrite( pPage.pDbPage ) ) == 0 ) + { + zeroPage( pPage, pPage.aData[0] | PTF_LEAF ); + } + +cleardatabasepage_out: + releasePage( pPage ); + return rc; +} - piMoved = 0; +/* +** Delete all information from a single table in the database. iTable is +** the page number of the root of the table. After this routine returns, +** the root page is empty, but still exists. +** +** This routine will fail with SQLITE_LOCKED if there are any open +** read cursors on the table. Open write cursors are moved to the +** root of the table. +** +** If pnChange is not NULL, then table iTable must be an intkey table. The +** integer value pointed to by pnChange is incremented by the number of +** entries in the table. +*/ +static int sqlite3BtreeClearTable( Btree p, int iTable, ref int pnChange ) +{ + int rc; + BtShared pBt = p.pBt; + sqlite3BtreeEnter( p ); + Debug.Assert( p.inTrans == TRANS_WRITE ); + + /* Invalidate all incrblob cursors open on table iTable (assuming iTable + ** is the root of a table b-tree - if it is not, the following call is + ** a no-op). */ + invalidateIncrblobCursors( p, 0, 1 ); + + rc = saveAllCursors( pBt, (Pgno)iTable, null ); + if ( SQLITE_OK == rc ) + { + rc = clearDatabasePage( pBt, (Pgno)iTable, 0, ref pnChange ); + } + sqlite3BtreeLeave( p ); + return rc; +} - if (iTable > 1) { +/* +** Erase all information in a table and add the root of the table to +** the freelist. Except, the root of the principle table (the one on +** page 1) is never added to the freelist. +** +** This routine will fail with SQLITE_LOCKED if there are any open +** cursors on the table. +** +** If AUTOVACUUM is enabled and the page at iTable is not the last +** root page in the database file, then the last root page +** in the database file is moved into the slot formerly occupied by +** iTable and that last slot formerly occupied by the last root page +** is added to the freelist instead of iTable. In this say, all +** root pages are kept at the beginning of the database file, which +** is necessary for AUTOVACUUM to work right. piMoved is set to the +** page number that used to be the last root page in the file before +** the move. If no page gets moved, piMoved is set to 0. +** The last root page is recorded in meta[3] and the value of +** meta[3] is updated by this procedure. +*/ +static int btreeDropTable( Btree p, Pgno iTable, ref int piMoved ) +{ + int rc; + MemPage pPage = null; + BtShared pBt = p.pBt; + + Debug.Assert( sqlite3BtreeHoldsMutex( p ) ); + Debug.Assert( p.inTrans == TRANS_WRITE ); + + /* It is illegal to drop a table if any cursors are open on the + ** database. This is because in auto-vacuum mode the backend may + ** need to move another root-page to fill a gap left by the deleted + ** root page. If an open cursor was using this page a problem would + ** occur. + ** + ** This error is caught long before control reaches this point. + */ + if ( NEVER( pBt.pCursor ) ) + { + sqlite3ConnectionBlocked( p.db, pBt.pCursor.pBtree.db ); + return SQLITE_LOCKED_SHAREDCACHE; + } + + rc = btreeGetPage( pBt, (Pgno)iTable, ref pPage, 0 ); + if ( rc != 0 ) + return rc; + int Dummy0 = 0; + rc = sqlite3BtreeClearTable( p, (int)iTable, ref Dummy0 ); + if ( rc != 0 ) + { + releasePage( pPage ); + return rc; + } + + piMoved = 0; + + if ( iTable > 1 ) + { #if SQLITE_OMIT_AUTOVACUUM freePage(pPage, ref rc); releasePage(pPage); #else - if (pBt.autoVacuum) { - Pgno maxRootPgno = 0; - sqlite3BtreeGetMeta(p, BTREE_LARGEST_ROOT_PAGE, ref maxRootPgno); - - if (iTable == maxRootPgno) { - /* If the table being dropped is the table with the largest root-page - ** number in the database, put the root page on the free list. - */ - freePage(pPage, ref rc); - releasePage(pPage); - if (rc != SQLITE_OK) { - return rc; - } - } else { - /* The table being dropped does not have the largest root-page - ** number in the database. So move the page that does into the - ** gap left by the deleted root-page. - */ - MemPage pMove = new MemPage(); - releasePage(pPage); - rc = btreeGetPage(pBt, maxRootPgno, ref pMove, 0); - if (rc != SQLITE_OK) { - return rc; - } - rc = relocatePage(pBt, pMove, PTRMAP_ROOTPAGE, 0, iTable, 0); - releasePage(pMove); - if (rc != SQLITE_OK) { - return rc; - } - pMove = null; - rc = btreeGetPage(pBt, maxRootPgno, ref pMove, 0); - freePage(pMove, ref rc); - releasePage(pMove); - if (rc != SQLITE_OK) { - return rc; - } - piMoved = (int)maxRootPgno; - } - - /* Set the new 'max-root-page' value in the database header. This - ** is the old value less one, less one more if that happens to - ** be a root-page number, less one again if that is the - ** PENDING_BYTE_PAGE. - */ - maxRootPgno--; - while (maxRootPgno == PENDING_BYTE_PAGE(pBt) - || PTRMAP_ISPAGE(pBt, maxRootPgno)) { - maxRootPgno--; - } - Debug.Assert(maxRootPgno != PENDING_BYTE_PAGE(pBt)); - - rc = sqlite3BtreeUpdateMeta(p, 4, maxRootPgno); - } else { - freePage(pPage, ref rc); - releasePage(pPage); - } + if ( pBt.autoVacuum ) + { + Pgno maxRootPgno = 0; + sqlite3BtreeGetMeta( p, BTREE_LARGEST_ROOT_PAGE, ref maxRootPgno ); + + if ( iTable == maxRootPgno ) + { + /* If the table being dropped is the table with the largest root-page + ** number in the database, put the root page on the free list. + */ + freePage( pPage, ref rc ); + releasePage( pPage ); + if ( rc != SQLITE_OK ) + { + return rc; + } + } + else + { + /* The table being dropped does not have the largest root-page + ** number in the database. So move the page that does into the + ** gap left by the deleted root-page. + */ + MemPage pMove = new MemPage(); + releasePage( pPage ); + rc = btreeGetPage( pBt, maxRootPgno, ref pMove, 0 ); + if ( rc != SQLITE_OK ) + { + return rc; + } + rc = relocatePage( pBt, pMove, PTRMAP_ROOTPAGE, 0, iTable, 0 ); + releasePage( pMove ); + if ( rc != SQLITE_OK ) + { + return rc; + } + pMove = null; + rc = btreeGetPage( pBt, maxRootPgno, ref pMove, 0 ); + freePage( pMove, ref rc ); + releasePage( pMove ); + if ( rc != SQLITE_OK ) + { + return rc; + } + piMoved = (int)maxRootPgno; + } + + /* Set the new 'max-root-page' value in the database header. This + ** is the old value less one, less one more if that happens to + ** be a root-page number, less one again if that is the + ** PENDING_BYTE_PAGE. + */ + maxRootPgno--; + while ( maxRootPgno == PENDING_BYTE_PAGE( pBt ) + || PTRMAP_ISPAGE( pBt, maxRootPgno ) ) + { + maxRootPgno--; + } + Debug.Assert( maxRootPgno != PENDING_BYTE_PAGE( pBt ) ); + + rc = sqlite3BtreeUpdateMeta( p, 4, maxRootPgno ); + } + else + { + freePage( pPage, ref rc ); + releasePage( pPage ); + } #endif - } else { - /* If sqlite3BtreeDropTable was called on page 1. - ** This really never should happen except in a corrupt - ** database. - */ - zeroPage(pPage, PTF_INTKEY | PTF_LEAF); - releasePage(pPage); - } - return rc; - } - static int sqlite3BtreeDropTable(Btree p, int iTable, ref int piMoved) { - int rc; - sqlite3BtreeEnter(p); - rc = btreeDropTable(p, (u32)iTable, ref piMoved); - sqlite3BtreeLeave(p); - return rc; - } + } + else + { + /* If sqlite3BtreeDropTable was called on page 1. + ** This really never should happen except in a corrupt + ** database. + */ + zeroPage( pPage, PTF_INTKEY | PTF_LEAF ); + releasePage( pPage ); + } + return rc; +} +static int sqlite3BtreeDropTable( Btree p, int iTable, ref int piMoved ) +{ + int rc; + sqlite3BtreeEnter( p ); + rc = btreeDropTable( p, (u32)iTable, ref piMoved ); + sqlite3BtreeLeave( p ); + return rc; +} - /* - ** This function may only be called if the b-tree connection already - ** has a read or write transaction open on the database. - ** - ** Read the meta-information out of a database file. Meta[0] - ** is the number of free pages currently in the database. Meta[1] - ** through meta[15] are available for use by higher layers. Meta[0] - ** is read-only, the others are read/write. - ** - ** The schema layer numbers meta values differently. At the schema - ** layer (and the SetCookie and ReadCookie opcodes) the number of - ** free pages is not visible. So Cookie[0] is the same as Meta[1]. - */ - static void sqlite3BtreeGetMeta(Btree p, int idx, ref u32 pMeta) { - BtShared pBt = p.pBt; +/* +** This function may only be called if the b-tree connection already +** has a read or write transaction open on the database. +** +** Read the meta-information out of a database file. Meta[0] +** is the number of free pages currently in the database. Meta[1] +** through meta[15] are available for use by higher layers. Meta[0] +** is read-only, the others are read/write. +** +** The schema layer numbers meta values differently. At the schema +** layer (and the SetCookie and ReadCookie opcodes) the number of +** free pages is not visible. So Cookie[0] is the same as Meta[1]. +*/ +static void sqlite3BtreeGetMeta( Btree p, int idx, ref u32 pMeta ) +{ + BtShared pBt = p.pBt; - sqlite3BtreeEnter(p); - Debug.Assert(p.inTrans > TRANS_NONE); - Debug.Assert(SQLITE_OK == querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK)); - Debug.Assert(pBt.pPage1 != null); - Debug.Assert(idx >= 0 && idx <= 15); + sqlite3BtreeEnter( p ); + Debug.Assert( p.inTrans > TRANS_NONE ); + Debug.Assert( SQLITE_OK == querySharedCacheTableLock( p, MASTER_ROOT, READ_LOCK ) ); + Debug.Assert( pBt.pPage1 != null ); + Debug.Assert( idx >= 0 && idx <= 15 ); - pMeta = sqlite3Get4byte(pBt.pPage1.aData, 36 + idx * 4); + pMeta = sqlite3Get4byte( pBt.pPage1.aData, 36 + idx * 4 ); - /* If auto-vacuum is disabled in this build and this is an auto-vacuum - ** database, mark the database as read-only. */ + /* If auto-vacuum is disabled in this build and this is an auto-vacuum + ** database, mark the database as read-only. */ #if SQLITE_OMIT_AUTOVACUUM if( idx==BTREE_LARGEST_ROOT_PAGE && pMeta>0 ) pBt.readOnly = 1; #endif - sqlite3BtreeLeave(p); - } + sqlite3BtreeLeave( p ); +} - /* - ** Write meta-information back into the database. Meta[0] is - ** read-only and may not be written. - */ - static int sqlite3BtreeUpdateMeta(Btree p, int idx, u32 iMeta) { - BtShared pBt = p.pBt; - byte[] pP1; - int rc; - Debug.Assert(idx >= 1 && idx <= 15); - sqlite3BtreeEnter(p); - Debug.Assert(p.inTrans == TRANS_WRITE); - Debug.Assert(pBt.pPage1 != null); - pP1 = pBt.pPage1.aData; - rc = sqlite3PagerWrite(pBt.pPage1.pDbPage); - if (rc == SQLITE_OK) { - sqlite3Put4byte(pP1, 36 + idx * 4, iMeta); +/* +** Write meta-information back into the database. Meta[0] is +** read-only and may not be written. +*/ +static int sqlite3BtreeUpdateMeta( Btree p, int idx, u32 iMeta ) +{ + BtShared pBt = p.pBt; + byte[] pP1; + int rc; + Debug.Assert( idx >= 1 && idx <= 15 ); + sqlite3BtreeEnter( p ); + Debug.Assert( p.inTrans == TRANS_WRITE ); + Debug.Assert( pBt.pPage1 != null ); + pP1 = pBt.pPage1.aData; + rc = sqlite3PagerWrite( pBt.pPage1.pDbPage ); + if ( rc == SQLITE_OK ) + { + sqlite3Put4byte( pP1, 36 + idx * 4, iMeta ); #if !SQLITE_OMIT_AUTOVACUUM - if (idx == BTREE_INCR_VACUUM) { - Debug.Assert(pBt.autoVacuum || iMeta == 0); - Debug.Assert(iMeta == 0 || iMeta == 1); - pBt.incrVacuum = iMeta != 0; - } + if ( idx == BTREE_INCR_VACUUM ) + { + Debug.Assert( pBt.autoVacuum || iMeta == 0 ); + Debug.Assert( iMeta == 0 || iMeta == 1 ); + pBt.incrVacuum = iMeta != 0; + } #endif - } - sqlite3BtreeLeave(p); - return rc; - } + } + sqlite3BtreeLeave( p ); + return rc; +} #if !SQLITE_OMIT_BTREECOUNT - /* - ** The first argument, pCur, is a cursor opened on some b-tree. Count the - ** number of entries in the b-tree and write the result to pnEntry. - ** - ** SQLITE_OK is returned if the operation is successfully executed. - ** Otherwise, if an error is encountered (i.e. an IO error or database - ** corruption) an SQLite error code is returned. - */ - static int sqlite3BtreeCount(BtCursor pCur, ref i64 pnEntry) { - i64 nEntry = 0; /* Value to return in pnEntry */ - int rc; /* Return code */ - rc = moveToRoot(pCur); - - /* Unless an error occurs, the following loop runs one iteration for each - ** page in the B-Tree structure (not including overflow pages). - */ - while (rc == SQLITE_OK) { - int iIdx; /* Index of child node in parent */ - MemPage pPage; /* Current page of the b-tree */ - - /* If this is a leaf page or the tree is not an int-key tree, then - ** this page contains countable entries. Increment the entry counter - ** accordingly. - */ - pPage = pCur.apPage[pCur.iPage]; - if (pPage.leaf != 0 || 0 == pPage.intKey) { - nEntry += pPage.nCell; - } - - /* pPage is a leaf node. This loop navigates the cursor so that it - ** points to the first interior cell that it points to the parent of - ** the next page in the tree that has not yet been visited. The - ** pCur.aiIdx[pCur.iPage] value is set to the index of the parent cell - ** of the page, or to the number of cells in the page if the next page - ** to visit is the right-child of its parent. - ** - ** If all pages in the tree have been visited, return SQLITE_OK to the - ** caller. - */ - if (pPage.leaf != 0) { - do { - if (pCur.iPage == 0) { - /* All pages of the b-tree have been visited. Return successfully. */ - pnEntry = nEntry; - return SQLITE_OK; - } - moveToParent(pCur); - } while (pCur.aiIdx[pCur.iPage] >= pCur.apPage[pCur.iPage].nCell); - - pCur.aiIdx[pCur.iPage]++; - pPage = pCur.apPage[pCur.iPage]; - } - - /* Descend to the child node of the cell that the cursor currently - ** points at. This is the right-child if (iIdx==pPage.nCell). - */ - iIdx = pCur.aiIdx[pCur.iPage]; - if (iIdx == pPage.nCell) { - rc = moveToChild(pCur, sqlite3Get4byte(pPage.aData, pPage.hdrOffset + 8)); - } else { - rc = moveToChild(pCur, sqlite3Get4byte(pPage.aData, findCell(pPage, iIdx))); - } - } +/* +** The first argument, pCur, is a cursor opened on some b-tree. Count the +** number of entries in the b-tree and write the result to pnEntry. +** +** SQLITE_OK is returned if the operation is successfully executed. +** Otherwise, if an error is encountered (i.e. an IO error or database +** corruption) an SQLite error code is returned. +*/ +static int sqlite3BtreeCount( BtCursor pCur, ref i64 pnEntry ) +{ + i64 nEntry = 0; /* Value to return in pnEntry */ + int rc; /* Return code */ + rc = moveToRoot( pCur ); + + /* Unless an error occurs, the following loop runs one iteration for each + ** page in the B-Tree structure (not including overflow pages). + */ + while ( rc == SQLITE_OK ) + { + int iIdx; /* Index of child node in parent */ + MemPage pPage; /* Current page of the b-tree */ + + /* If this is a leaf page or the tree is not an int-key tree, then + ** this page contains countable entries. Increment the entry counter + ** accordingly. + */ + pPage = pCur.apPage[pCur.iPage]; + if ( pPage.leaf != 0 || 0 == pPage.intKey ) + { + nEntry += pPage.nCell; + } - /* An error has occurred. Return an error code. */ - return rc; - } + /* pPage is a leaf node. This loop navigates the cursor so that it + ** points to the first interior cell that it points to the parent of + ** the next page in the tree that has not yet been visited. The + ** pCur.aiIdx[pCur.iPage] value is set to the index of the parent cell + ** of the page, or to the number of cells in the page if the next page + ** to visit is the right-child of its parent. + ** + ** If all pages in the tree have been visited, return SQLITE_OK to the + ** caller. + */ + if ( pPage.leaf != 0 ) + { + do + { + if ( pCur.iPage == 0 ) + { + /* All pages of the b-tree have been visited. Return successfully. */ + pnEntry = nEntry; + return SQLITE_OK; + } + moveToParent( pCur ); + } while ( pCur.aiIdx[pCur.iPage] >= pCur.apPage[pCur.iPage].nCell ); + + pCur.aiIdx[pCur.iPage]++; + pPage = pCur.apPage[pCur.iPage]; + } + + /* Descend to the child node of the cell that the cursor currently + ** points at. This is the right-child if (iIdx==pPage.nCell). + */ + iIdx = pCur.aiIdx[pCur.iPage]; + if ( iIdx == pPage.nCell ) + { + rc = moveToChild( pCur, sqlite3Get4byte( pPage.aData, pPage.hdrOffset + 8 ) ); + } + else + { + rc = moveToChild( pCur, sqlite3Get4byte( pPage.aData, findCell( pPage, iIdx ) ) ); + } + } + + /* An error has occurred. Return an error code. */ + return rc; +} #endif - /* - ** Return the pager associated with a BTree. This routine is used for - ** testing and debugging only. - */ - static Pager sqlite3BtreePager(Btree p) { - return p.pBt.pPager; - } +/* +** Return the pager associated with a BTree. This routine is used for +** testing and debugging only. +*/ +static Pager sqlite3BtreePager( Btree p ) +{ + return p.pBt.pPager; +} #if !SQLITE_OMIT_INTEGRITY_CHECK - /* - ** Append a message to the error message string. - */ - static void checkAppendMsg( - IntegrityCk pCheck, - string zMsg1, - string zFormat, - params object[] ap - ) { - if (0 == pCheck.mxErr) - return; - //va_list ap; - lock (lock_va_list) { - pCheck.mxErr--; - pCheck.nErr++; - va_start(ap, zFormat); - if (pCheck.errMsg.zText.Length != 0) { - sqlite3StrAccumAppend(pCheck.errMsg, "\n", 1); - } - if (zMsg1.Length > 0) { - sqlite3StrAccumAppend(pCheck.errMsg, zMsg1.ToString(), -1); - } - sqlite3VXPrintf(pCheck.errMsg, 1, zFormat, ap); - va_end(ref ap); - } - } +/* +** Append a message to the error message string. +*/ +static void checkAppendMsg( +IntegrityCk pCheck, +string zMsg1, +string zFormat, +params object[] ap +) +{ + if ( 0 == pCheck.mxErr ) + return; + //va_list ap; + lock ( lock_va_list ) + { + pCheck.mxErr--; + pCheck.nErr++; + va_start( ap, zFormat ); + if ( pCheck.errMsg.zText.Length != 0 ) + { + sqlite3StrAccumAppend( pCheck.errMsg, "\n", 1 ); + } + if ( zMsg1.Length > 0 ) + { + sqlite3StrAccumAppend( pCheck.errMsg, zMsg1.ToString(), -1 ); + } + sqlite3VXPrintf( pCheck.errMsg, 1, zFormat, ap ); + va_end( ref ap ); + } +} - static void checkAppendMsg( - IntegrityCk pCheck, - StringBuilder zMsg1, - string zFormat, - params object[] ap - ) { - if (0 == pCheck.mxErr) - return; - //va_list ap; - lock (lock_va_list) { - pCheck.mxErr--; - pCheck.nErr++; - va_start(ap, zFormat); - if (pCheck.errMsg.zText.Length != 0) { - sqlite3StrAccumAppend(pCheck.errMsg, "\n", 1); - } - if (zMsg1.Length > 0) { - sqlite3StrAccumAppend(pCheck.errMsg, zMsg1.ToString(), -1); - } - sqlite3VXPrintf(pCheck.errMsg, 1, zFormat, ap); - va_end(ref ap); - } - //if( pCheck.errMsg.mallocFailed ){ - // pCheck.mallocFailed = 1; - //} - } +static void checkAppendMsg( +IntegrityCk pCheck, +StringBuilder zMsg1, +string zFormat, +params object[] ap +) +{ + if ( 0 == pCheck.mxErr ) + return; + //va_list ap; + lock ( lock_va_list ) + { + pCheck.mxErr--; + pCheck.nErr++; + va_start( ap, zFormat ); + if ( pCheck.errMsg.zText.Length != 0 ) + { + sqlite3StrAccumAppend( pCheck.errMsg, "\n", 1 ); + } + if ( zMsg1.Length > 0 ) + { + sqlite3StrAccumAppend( pCheck.errMsg, zMsg1.ToString(), -1 ); + } + sqlite3VXPrintf( pCheck.errMsg, 1, zFormat, ap ); + va_end( ref ap ); + } + //if( pCheck.errMsg.mallocFailed ){ + // pCheck.mallocFailed = 1; + //} +} #endif //* SQLITE_OMIT_INTEGRITY_CHECK */ #if !SQLITE_OMIT_INTEGRITY_CHECK - /* - ** Add 1 to the reference count for page iPage. If this is the second - ** reference to the page, add an error message to pCheck.zErrMsg. - ** Return 1 if there are 2 ore more references to the page and 0 if - ** if this is the first reference to the page. - ** - ** Also check that the page number is in bounds. - */ - static int checkRef(IntegrityCk pCheck, Pgno iPage, string zContext) { - if (iPage == 0) - return 1; - if (iPage > pCheck.nPage) { - checkAppendMsg(pCheck, zContext, "invalid page number %d", iPage); - return 1; - } - if (pCheck.anRef[iPage] == 1) { - checkAppendMsg(pCheck, zContext, "2nd reference to page %d", iPage); - return 1; - } - return ((pCheck.anRef[iPage]++) > 1) ? 1 : 0; - } +/* +** Add 1 to the reference count for page iPage. If this is the second +** reference to the page, add an error message to pCheck.zErrMsg. +** Return 1 if there are 2 ore more references to the page and 0 if +** if this is the first reference to the page. +** +** Also check that the page number is in bounds. +*/ +static int checkRef( IntegrityCk pCheck, Pgno iPage, string zContext ) +{ + if ( iPage == 0 ) + return 1; + if ( iPage > pCheck.nPage ) + { + checkAppendMsg( pCheck, zContext, "invalid page number %d", iPage ); + return 1; + } + if ( pCheck.anRef[iPage] == 1 ) + { + checkAppendMsg( pCheck, zContext, "2nd reference to page %d", iPage ); + return 1; + } + return ( ( pCheck.anRef[iPage]++ ) > 1 ) ? 1 : 0; +} #if !SQLITE_OMIT_AUTOVACUUM - /* - ** Check that the entry in the pointer-map for page iChild maps to - ** page iParent, pointer type ptrType. If not, append an error message - ** to pCheck. - */ - static void checkPtrmap( - IntegrityCk pCheck, /* Integrity check context */ - Pgno iChild, /* Child page number */ - u8 eType, /* Expected pointer map type */ - Pgno iParent, /* Expected pointer map parent page number */ - string zContext /* Context description (used for error msg) */ - ) { - int rc; - u8 ePtrmapType = 0; - Pgno iPtrmapParent = 0; - - rc = ptrmapGet(pCheck.pBt, iChild, ref ePtrmapType, ref iPtrmapParent); - if (rc != SQLITE_OK) { - //if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ) pCheck.mallocFailed = 1; - checkAppendMsg(pCheck, zContext, "Failed to read ptrmap key=%d", iChild); - return; - } - - if (ePtrmapType != eType || iPtrmapParent != iParent) { - checkAppendMsg(pCheck, zContext, - "Bad ptr map entry key=%d expected=(%d,%d) got=(%d,%d)", - iChild, eType, iParent, ePtrmapType, iPtrmapParent); - } - } +/* +** Check that the entry in the pointer-map for page iChild maps to +** page iParent, pointer type ptrType. If not, append an error message +** to pCheck. +*/ +static void checkPtrmap( +IntegrityCk pCheck, /* Integrity check context */ +Pgno iChild, /* Child page number */ +u8 eType, /* Expected pointer map type */ +Pgno iParent, /* Expected pointer map parent page number */ +string zContext /* Context description (used for error msg) */ +) +{ + int rc; + u8 ePtrmapType = 0; + Pgno iPtrmapParent = 0; + + rc = ptrmapGet( pCheck.pBt, iChild, ref ePtrmapType, ref iPtrmapParent ); + if ( rc != SQLITE_OK ) + { + //if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ) pCheck.mallocFailed = 1; + checkAppendMsg( pCheck, zContext, "Failed to read ptrmap key=%d", iChild ); + return; + } + + if ( ePtrmapType != eType || iPtrmapParent != iParent ) + { + checkAppendMsg( pCheck, zContext, + "Bad ptr map entry key=%d expected=(%d,%d) got=(%d,%d)", + iChild, eType, iParent, ePtrmapType, iPtrmapParent ); + } +} #endif - /* - ** Check the integrity of the freelist or of an overflow page list. - ** Verify that the number of pages on the list is N. - */ - static void checkList( - IntegrityCk pCheck, /* Integrity checking context */ - int isFreeList, /* True for a freelist. False for overflow page list */ - int iPage, /* Page number for first page in the list */ - int N, /* Expected number of pages in the list */ - string zContext /* Context for error messages */ - ) { - int i; - int expected = N; - int iFirst = iPage; - while (N-- > 0 && pCheck.mxErr != 0) { - PgHdr pOvflPage = new PgHdr(); - byte[] pOvflData; - if (iPage < 1) { - checkAppendMsg(pCheck, zContext, - "%d of %d pages missing from overflow list starting at %d", - N + 1, expected, iFirst); - break; - } - if (checkRef(pCheck, (u32)iPage, zContext) != 0) - break; - if (sqlite3PagerGet(pCheck.pPager, (Pgno)iPage, ref pOvflPage) != 0) { - checkAppendMsg(pCheck, zContext, "failed to get page %d", iPage); - break; - } - pOvflData = sqlite3PagerGetData(pOvflPage); - if (isFreeList != 0) { - int n = (int)sqlite3Get4byte(pOvflData, 4); +/* +** Check the integrity of the freelist or of an overflow page list. +** Verify that the number of pages on the list is N. +*/ +static void checkList( +IntegrityCk pCheck, /* Integrity checking context */ +int isFreeList, /* True for a freelist. False for overflow page list */ +int iPage, /* Page number for first page in the list */ +int N, /* Expected number of pages in the list */ +string zContext /* Context for error messages */ +) +{ + int i; + int expected = N; + int iFirst = iPage; + while ( N-- > 0 && pCheck.mxErr != 0 ) + { + PgHdr pOvflPage = new PgHdr(); + byte[] pOvflData; + if ( iPage < 1 ) + { + checkAppendMsg( pCheck, zContext, + "%d of %d pages missing from overflow list starting at %d", + N + 1, expected, iFirst ); + break; + } + if ( checkRef( pCheck, (u32)iPage, zContext ) != 0 ) + break; + if ( sqlite3PagerGet( pCheck.pPager, (Pgno)iPage, ref pOvflPage ) != 0 ) + { + checkAppendMsg( pCheck, zContext, "failed to get page %d", iPage ); + break; + } + pOvflData = sqlite3PagerGetData( pOvflPage ); + if ( isFreeList != 0 ) + { + int n = (int)sqlite3Get4byte( pOvflData, 4 ); #if !SQLITE_OMIT_AUTOVACUUM - if (pCheck.pBt.autoVacuum) { - checkPtrmap(pCheck, (u32)iPage, PTRMAP_FREEPAGE, 0, zContext); - } + if ( pCheck.pBt.autoVacuum ) + { + checkPtrmap( pCheck, (u32)iPage, PTRMAP_FREEPAGE, 0, zContext ); + } #endif - if (n > (int)pCheck.pBt.usableSize / 4 - 2) { - checkAppendMsg(pCheck, zContext, - "freelist leaf count too big on page %d", iPage); - N--; - } else { - for (i = 0; i < n; i++) { - Pgno iFreePage = sqlite3Get4byte(pOvflData, 8 + i * 4); + if ( n > (int)pCheck.pBt.usableSize / 4 - 2 ) + { + checkAppendMsg( pCheck, zContext, + "freelist leaf count too big on page %d", iPage ); + N--; + } + else + { + for ( i = 0; i < n; i++ ) + { + Pgno iFreePage = sqlite3Get4byte( pOvflData, 8 + i * 4 ); #if !SQLITE_OMIT_AUTOVACUUM - if (pCheck.pBt.autoVacuum) { - checkPtrmap(pCheck, iFreePage, PTRMAP_FREEPAGE, 0, zContext); - } + if ( pCheck.pBt.autoVacuum ) + { + checkPtrmap( pCheck, iFreePage, PTRMAP_FREEPAGE, 0, zContext ); + } #endif - checkRef(pCheck, iFreePage, zContext); - } - N -= n; - } - } + checkRef( pCheck, iFreePage, zContext ); + } + N -= n; + } + } #if !SQLITE_OMIT_AUTOVACUUM - else { - /* If this database supports auto-vacuum and iPage is not the last - ** page in this overflow list, check that the pointer-map entry for - ** the following page matches iPage. - */ - if (pCheck.pBt.autoVacuum && N > 0) { - i = (int)sqlite3Get4byte(pOvflData); - checkPtrmap(pCheck, (u32)i, PTRMAP_OVERFLOW2, (u32)iPage, zContext); - } - } + else + { + /* If this database supports auto-vacuum and iPage is not the last + ** page in this overflow list, check that the pointer-map entry for + ** the following page matches iPage. + */ + if ( pCheck.pBt.autoVacuum && N > 0 ) + { + i = (int)sqlite3Get4byte( pOvflData ); + checkPtrmap( pCheck, (u32)i, PTRMAP_OVERFLOW2, (u32)iPage, zContext ); + } + } #endif - iPage = (int)sqlite3Get4byte(pOvflData); - sqlite3PagerUnref(pOvflPage); - } - } + iPage = (int)sqlite3Get4byte( pOvflData ); + sqlite3PagerUnref( pOvflPage ); + } +} #endif //* SQLITE_OMIT_INTEGRITY_CHECK */ #if !SQLITE_OMIT_INTEGRITY_CHECK - /* - ** Do various sanity checks on a single page of a tree. Return - ** the tree depth. Root pages return 0. Parents of root pages - ** return 1, and so forth. - ** - ** These checks are done: - ** - ** 1. Make sure that cells and freeblocks do not overlap - ** but combine to completely cover the page. - ** NO 2. Make sure cell keys are in order. - ** NO 3. Make sure no key is less than or equal to zLowerBound. - ** NO 4. Make sure no key is greater than or equal to zUpperBound. - ** 5. Check the integrity of overflow pages. - ** 6. Recursively call checkTreePage on all children. - ** 7. Verify that the depth of all children is the same. - ** 8. Make sure this page is at least 33% full or else it is - ** the root of the tree. - */ - - static i64 refNULL = 0; //Dummy for C# ref NULL - - static int checkTreePage( - IntegrityCk pCheck, /* Context for the sanity check */ - int iPage, /* Page number of the page to check */ - string zParentContext, /* Parent context */ - ref i64 pnParentMinKey, - ref i64 pnParentMaxKey, - object _pnParentMinKey, /* C# Needed to determine if content passed*/ - object _pnParentMaxKey /* C# Needed to determine if content passed*/ - ) { - MemPage pPage = new MemPage(); - int i, rc, depth, d2, pgno, cnt; - int hdr, cellStart; - int nCell; - u8[] data; - BtShared pBt; - int usableSize; - StringBuilder zContext = new StringBuilder(100); - byte[] hit = null; - i64 nMinKey = 0; - i64 nMaxKey = 0; - - - sqlite3_snprintf(200, zContext, "Page %d: ", iPage); - - /* Check that the page exists - */ - pBt = pCheck.pBt; - usableSize = (int)pBt.usableSize; - if (iPage == 0) - return 0; - if (checkRef(pCheck, (u32)iPage, zParentContext) != 0) - return 0; - if ((rc = btreeGetPage(pBt, (Pgno)iPage, ref pPage, 0)) != 0) { - checkAppendMsg(pCheck, zContext.ToString(), - "unable to get the page. error code=%d", rc); - return 0; - } - - /* Clear MemPage.isInit to make sure the corruption detection code in - ** btreeInitPage() is executed. */ - pPage.isInit = 0; - if ((rc = btreeInitPage(pPage)) != 0) { - Debug.Assert(rc == SQLITE_CORRUPT); /* The only possible error from InitPage */ - checkAppendMsg(pCheck, zContext.ToString(), - "btreeInitPage() returns error code %d", rc); - releasePage(pPage); - return 0; - } +/* +** Do various sanity checks on a single page of a tree. Return +** the tree depth. Root pages return 0. Parents of root pages +** return 1, and so forth. +** +** These checks are done: +** +** 1. Make sure that cells and freeblocks do not overlap +** but combine to completely cover the page. +** NO 2. Make sure cell keys are in order. +** NO 3. Make sure no key is less than or equal to zLowerBound. +** NO 4. Make sure no key is greater than or equal to zUpperBound. +** 5. Check the integrity of overflow pages. +** 6. Recursively call checkTreePage on all children. +** 7. Verify that the depth of all children is the same. +** 8. Make sure this page is at least 33% full or else it is +** the root of the tree. +*/ - /* Check out all the cells. - */ - depth = 0; - for (i = 0; i < pPage.nCell && pCheck.mxErr != 0; i++) { - u8[] pCell; - u32 sz; - CellInfo info = new CellInfo(); - - /* Check payload overflow pages - */ - sqlite3_snprintf(200, zContext, - "On tree page %d cell %d: ", iPage, i); - int iCell = findCell(pPage, i); //pCell = findCell( pPage, i ); - pCell = pPage.aData; - btreeParseCellPtr(pPage, iCell, ref info); //btreeParseCellPtr( pPage, pCell, info ); - sz = info.nData; - if (0 == pPage.intKey) - sz += (u32)info.nKey; - /* For intKey pages, check that the keys are in order. - */ - else if (i == 0) - nMinKey = nMaxKey = info.nKey; - else { - if (info.nKey <= nMaxKey) { - checkAppendMsg(pCheck, zContext.ToString(), - "Rowid %lld out of order (previous was %lld)", info.nKey, nMaxKey); - } - nMaxKey = info.nKey; - } - Debug.Assert(sz == info.nPayload); - if ((sz > info.nLocal) - //&& (pCell[info.iOverflow]<=&pPage.aData[pBt.usableSize]) - ) { - int nPage = (int)(sz - info.nLocal + usableSize - 5) / (usableSize - 4); - Pgno pgnoOvfl = sqlite3Get4byte(pCell, iCell, info.iOverflow); +static i64 refNULL = 0; //Dummy for C# ref NULL + +static int checkTreePage( +IntegrityCk pCheck, /* Context for the sanity check */ +int iPage, /* Page number of the page to check */ +string zParentContext, /* Parent context */ +ref i64 pnParentMinKey, +ref i64 pnParentMaxKey, +object _pnParentMinKey, /* C# Needed to determine if content passed*/ +object _pnParentMaxKey /* C# Needed to determine if content passed*/ +) +{ + MemPage pPage = new MemPage(); + int i, rc, depth, d2, pgno, cnt; + int hdr, cellStart; + int nCell; + u8[] data; + BtShared pBt; + int usableSize; + StringBuilder zContext = new StringBuilder( 100 ); + byte[] hit = null; + i64 nMinKey = 0; + i64 nMaxKey = 0; + + + sqlite3_snprintf( 200, zContext, "Page %d: ", iPage ); + + /* Check that the page exists + */ + pBt = pCheck.pBt; + usableSize = (int)pBt.usableSize; + if ( iPage == 0 ) + return 0; + if ( checkRef( pCheck, (u32)iPage, zParentContext ) != 0 ) + return 0; + if ( ( rc = btreeGetPage( pBt, (Pgno)iPage, ref pPage, 0 ) ) != 0 ) + { + checkAppendMsg( pCheck, zContext.ToString(), + "unable to get the page. error code=%d", rc ); + return 0; + } + + /* Clear MemPage.isInit to make sure the corruption detection code in + ** btreeInitPage() is executed. */ + pPage.isInit = 0; + if ( ( rc = btreeInitPage( pPage ) ) != 0 ) + { + Debug.Assert( rc == SQLITE_CORRUPT ); /* The only possible error from InitPage */ + checkAppendMsg( pCheck, zContext.ToString(), + "btreeInitPage() returns error code %d", rc ); + releasePage( pPage ); + return 0; + } + + /* Check out all the cells. + */ + depth = 0; + for ( i = 0; i < pPage.nCell && pCheck.mxErr != 0; i++ ) + { + u8[] pCell; + u32 sz; + CellInfo info = new CellInfo(); + + /* Check payload overflow pages + */ + sqlite3_snprintf( 200, zContext, + "On tree page %d cell %d: ", iPage, i ); + int iCell = findCell( pPage, i ); //pCell = findCell( pPage, i ); + pCell = pPage.aData; + btreeParseCellPtr( pPage, iCell, ref info ); //btreeParseCellPtr( pPage, pCell, info ); + sz = info.nData; + if ( 0 == pPage.intKey ) + sz += (u32)info.nKey; + /* For intKey pages, check that the keys are in order. + */ + else if ( i == 0 ) + nMinKey = nMaxKey = info.nKey; + else + { + if ( info.nKey <= nMaxKey ) + { + checkAppendMsg( pCheck, zContext.ToString(), + "Rowid %lld out of order (previous was %lld)", info.nKey, nMaxKey ); + } + nMaxKey = info.nKey; + } + Debug.Assert( sz == info.nPayload ); + if ( ( sz > info.nLocal ) + //&& (pCell[info.iOverflow]<=&pPage.aData[pBt.usableSize]) + ) + { + int nPage = (int)( sz - info.nLocal + usableSize - 5 ) / ( usableSize - 4 ); + Pgno pgnoOvfl = sqlite3Get4byte( pCell, iCell, info.iOverflow ); #if !SQLITE_OMIT_AUTOVACUUM - if (pBt.autoVacuum) { - checkPtrmap(pCheck, pgnoOvfl, PTRMAP_OVERFLOW1, (u32)iPage, zContext.ToString()); - } + if ( pBt.autoVacuum ) + { + checkPtrmap( pCheck, pgnoOvfl, PTRMAP_OVERFLOW1, (u32)iPage, zContext.ToString() ); + } #endif - checkList(pCheck, 0, (int)pgnoOvfl, nPage, zContext.ToString()); - } + checkList( pCheck, 0, (int)pgnoOvfl, nPage, zContext.ToString() ); + } - /* Check sanity of left child page. - */ - if (0 == pPage.leaf) { - pgno = (int)sqlite3Get4byte(pCell, iCell); //sqlite3Get4byte( pCell ); + /* Check sanity of left child page. + */ + if ( 0 == pPage.leaf ) + { + pgno = (int)sqlite3Get4byte( pCell, iCell ); //sqlite3Get4byte( pCell ); #if !SQLITE_OMIT_AUTOVACUUM - if (pBt.autoVacuum) { - checkPtrmap(pCheck, (u32)pgno, PTRMAP_BTREE, (u32)iPage, zContext.ToString()); - } + if ( pBt.autoVacuum ) + { + checkPtrmap( pCheck, (u32)pgno, PTRMAP_BTREE, (u32)iPage, zContext.ToString() ); + } #endif - if (i == 0) - d2 = checkTreePage(pCheck, pgno, zContext.ToString(), ref nMinKey, ref refNULL, pCheck, null); - else - d2 = checkTreePage(pCheck, pgno, zContext.ToString(), ref nMinKey, ref nMaxKey, pCheck, pCheck); - - if (i > 0 && d2 != depth) { - checkAppendMsg(pCheck, zContext, "Child page depth differs"); - } - depth = d2; - } - } - if (0 == pPage.leaf) { - pgno = (int)sqlite3Get4byte(pPage.aData, pPage.hdrOffset + 8); - sqlite3_snprintf(200, zContext, - "On page %d at right child: ", iPage); + if ( i == 0 ) + d2 = checkTreePage( pCheck, pgno, zContext.ToString(), ref nMinKey, ref refNULL, pCheck, null ); + else + d2 = checkTreePage( pCheck, pgno, zContext.ToString(), ref nMinKey, ref nMaxKey, pCheck, pCheck ); + + if ( i > 0 && d2 != depth ) + { + checkAppendMsg( pCheck, zContext, "Child page depth differs" ); + } + depth = d2; + } + } + if ( 0 == pPage.leaf ) + { + pgno = (int)sqlite3Get4byte( pPage.aData, pPage.hdrOffset + 8 ); + sqlite3_snprintf( 200, zContext, + "On page %d at right child: ", iPage ); #if !SQLITE_OMIT_AUTOVACUUM - if (pBt.autoVacuum) { - checkPtrmap(pCheck, (u32)pgno, PTRMAP_BTREE, (u32)iPage, zContext.ToString()); - } + if ( pBt.autoVacuum ) + { + checkPtrmap( pCheck, (u32)pgno, PTRMAP_BTREE, (u32)iPage, zContext.ToString() ); + } #endif - // checkTreePage(pCheck, pgno, zContext, NULL, !pPage->nCell ? NULL : &nMaxKey); - if (0 == pPage.nCell) - checkTreePage(pCheck, pgno, zContext.ToString(), ref refNULL, ref refNULL, null, null); - else - checkTreePage(pCheck, pgno, zContext.ToString(), ref refNULL, ref nMaxKey, null, pCheck); - } - - /* For intKey leaf pages, check that the min/max keys are in order - ** with any left/parent/right pages. - */ - if (pPage.leaf != 0 && pPage.intKey != 0) { - /* if we are a left child page */ - if (_pnParentMinKey != null) { - /* if we are the left most child page */ - if (_pnParentMaxKey == null) { - if (nMaxKey > pnParentMinKey) { - checkAppendMsg(pCheck, zContext, - "Rowid %lld out of order (max larger than parent min of %lld)", - nMaxKey, pnParentMinKey); - } - } else { - if (nMinKey <= pnParentMinKey) { - checkAppendMsg(pCheck, zContext, - "Rowid %lld out of order (min less than parent min of %lld)", - nMinKey, pnParentMinKey); - } - if (nMaxKey > pnParentMaxKey) { - checkAppendMsg(pCheck, zContext, - "Rowid %lld out of order (max larger than parent max of %lld)", - nMaxKey, pnParentMaxKey); - } - pnParentMinKey = nMaxKey; - } - /* else if we're a right child page */ - } else if (_pnParentMaxKey != null) { - if (nMinKey <= pnParentMaxKey) { - checkAppendMsg(pCheck, zContext, - "Rowid %lld out of order (min less than parent max of %lld)", - nMinKey, pnParentMaxKey); - } - } - } - - /* Check for complete coverage of the page - */ - data = pPage.aData; - hdr = pPage.hdrOffset; - hit = sqlite3Malloc(pBt.pageSize); - //if( hit==null ){ - // pCheck.mallocFailed = 1; - //}else - { - int contentOffset = get2byteNotZero(data, hdr + 5); - Debug.Assert(contentOffset <= usableSize); /* Enforced by btreeInitPage() */ - Array.Clear(hit, contentOffset, usableSize - contentOffset);//memset(hit+contentOffset, 0, usableSize-contentOffset); - for (int iLoop = contentOffset - 1; iLoop >= 0; iLoop--) - hit[iLoop] = 1;//memset(hit, 1, contentOffset); - nCell = get2byte(data, hdr + 3); - cellStart = hdr + 12 - 4 * pPage.leaf; - for (i = 0; i < nCell; i++) { - int pc = get2byte(data, cellStart + i * 2); - u32 size = 65536; - int j; - if (pc <= usableSize - 4) { - size = cellSizePtr(pPage, data, pc); - } - if ((int)(pc + size - 1) >= usableSize) { - checkAppendMsg(pCheck, "", - "Corruption detected in cell %d on page %d", i, iPage); - } else { - for (j = (int)(pc + size - 1); j >= pc; j--) - hit[j]++; - } - } - i = get2byte(data, hdr + 1); - while (i > 0) { - int size, j; - Debug.Assert(i <= usableSize - 4); /* Enforced by btreeInitPage() */ - size = get2byte(data, i + 2); - Debug.Assert(i + size <= usableSize); /* Enforced by btreeInitPage() */ - for (j = i + size - 1; j >= i; j--) - hit[j]++; - j = get2byte(data, i); - Debug.Assert(j == 0 || j > i + size); /* Enforced by btreeInitPage() */ - Debug.Assert(j <= usableSize - 4); /* Enforced by btreeInitPage() */ - i = j; - } - for (i = cnt = 0; i < usableSize; i++) { - if (hit[i] == 0) { - cnt++; - } else if (hit[i] > 1) { - checkAppendMsg(pCheck, "", - "Multiple uses for byte %d of page %d", i, iPage); - break; - } - } - if (cnt != data[hdr + 7]) { - checkAppendMsg(pCheck, "", - "Fragmentation of %d bytes reported as %d on page %d", - cnt, data[hdr + 7], iPage); - } - } - sqlite3PageFree(ref hit); - releasePage(pPage); - return depth + 1; - } + // checkTreePage(pCheck, pgno, zContext, NULL, !pPage->nCell ? NULL : &nMaxKey); + if ( 0 == pPage.nCell ) + checkTreePage( pCheck, pgno, zContext.ToString(), ref refNULL, ref refNULL, null, null ); + else + checkTreePage( pCheck, pgno, zContext.ToString(), ref refNULL, ref nMaxKey, null, pCheck ); + } + + /* For intKey leaf pages, check that the min/max keys are in order + ** with any left/parent/right pages. + */ + if ( pPage.leaf != 0 && pPage.intKey != 0 ) + { + /* if we are a left child page */ + if ( _pnParentMinKey != null ) + { + /* if we are the left most child page */ + if ( _pnParentMaxKey == null ) + { + if ( nMaxKey > pnParentMinKey ) + { + checkAppendMsg( pCheck, zContext, + "Rowid %lld out of order (max larger than parent min of %lld)", + nMaxKey, pnParentMinKey ); + } + } + else + { + if ( nMinKey <= pnParentMinKey ) + { + checkAppendMsg( pCheck, zContext, + "Rowid %lld out of order (min less than parent min of %lld)", + nMinKey, pnParentMinKey ); + } + if ( nMaxKey > pnParentMaxKey ) + { + checkAppendMsg( pCheck, zContext, + "Rowid %lld out of order (max larger than parent max of %lld)", + nMaxKey, pnParentMaxKey ); + } + pnParentMinKey = nMaxKey; + } + /* else if we're a right child page */ + } + else if ( _pnParentMaxKey != null ) + { + if ( nMinKey <= pnParentMaxKey ) + { + checkAppendMsg( pCheck, zContext, + "Rowid %lld out of order (min less than parent max of %lld)", + nMinKey, pnParentMaxKey ); + } + } + } + + /* Check for complete coverage of the page + */ + data = pPage.aData; + hdr = pPage.hdrOffset; + hit = sqlite3Malloc( pBt.pageSize ); + //if( hit==null ){ + // pCheck.mallocFailed = 1; + //}else + { + int contentOffset = get2byteNotZero( data, hdr + 5 ); + Debug.Assert( contentOffset <= usableSize ); /* Enforced by btreeInitPage() */ + Array.Clear( hit, contentOffset, usableSize - contentOffset );//memset(hit+contentOffset, 0, usableSize-contentOffset); + for ( int iLoop = contentOffset - 1; iLoop >= 0; iLoop-- ) + hit[iLoop] = 1;//memset(hit, 1, contentOffset); + nCell = get2byte( data, hdr + 3 ); + cellStart = hdr + 12 - 4 * pPage.leaf; + for ( i = 0; i < nCell; i++ ) + { + int pc = get2byte( data, cellStart + i * 2 ); + u32 size = 65536; + int j; + if ( pc <= usableSize - 4 ) + { + size = cellSizePtr( pPage, data, pc ); + } + if ( (int)( pc + size - 1 ) >= usableSize ) + { + checkAppendMsg( pCheck, "", + "Corruption detected in cell %d on page %d", i, iPage ); + } + else + { + for ( j = (int)( pc + size - 1 ); j >= pc; j-- ) + hit[j]++; + } + } + i = get2byte( data, hdr + 1 ); + while ( i > 0 ) + { + int size, j; + Debug.Assert( i <= usableSize - 4 ); /* Enforced by btreeInitPage() */ + size = get2byte( data, i + 2 ); + Debug.Assert( i + size <= usableSize ); /* Enforced by btreeInitPage() */ + for ( j = i + size - 1; j >= i; j-- ) + hit[j]++; + j = get2byte( data, i ); + Debug.Assert( j == 0 || j > i + size ); /* Enforced by btreeInitPage() */ + Debug.Assert( j <= usableSize - 4 ); /* Enforced by btreeInitPage() */ + i = j; + } + for ( i = cnt = 0; i < usableSize; i++ ) + { + if ( hit[i] == 0 ) + { + cnt++; + } + else if ( hit[i] > 1 ) + { + checkAppendMsg( pCheck, "", + "Multiple uses for byte %d of page %d", i, iPage ); + break; + } + } + if ( cnt != data[hdr + 7] ) + { + checkAppendMsg( pCheck, "", + "Fragmentation of %d bytes reported as %d on page %d", + cnt, data[hdr + 7], iPage ); + } + } + sqlite3PageFree( ref hit ); + releasePage( pPage ); + return depth + 1; +} #endif //* SQLITE_OMIT_INTEGRITY_CHECK */ #if !SQLITE_OMIT_INTEGRITY_CHECK - /* - ** This routine does a complete check of the given BTree file. aRoot[] is - ** an array of pages numbers were each page number is the root page of - ** a table. nRoot is the number of entries in aRoot. - ** - ** A read-only or read-write transaction must be opened before calling - ** this function. - ** - ** Write the number of error seen in pnErr. Except for some memory - ** allocation errors, an error message held in memory obtained from - ** malloc is returned if pnErr is non-zero. If pnErr==null then NULL is - ** returned. If a memory allocation error occurs, NULL is returned. - */ - static string sqlite3BtreeIntegrityCheck( - Btree p, /* The btree to be checked */ - int[] aRoot, /* An array of root pages numbers for individual trees */ - int nRoot, /* Number of entries in aRoot[] */ - int mxErr, /* Stop reporting errors after this many */ - ref int pnErr /* Write number of errors seen to this variable */ - ) { - Pgno i; - int nRef; - IntegrityCk sCheck = new IntegrityCk(); - BtShared pBt = p.pBt; - - sqlite3BtreeEnter(p); - Debug.Assert(p.inTrans > TRANS_NONE && pBt.inTransaction > TRANS_NONE); - nRef = sqlite3PagerRefcount(pBt.pPager); - sCheck.pBt = pBt; - sCheck.pPager = pBt.pPager; - sCheck.nPage = btreePagecount(sCheck.pBt); - sCheck.mxErr = mxErr; - sCheck.nErr = 0; - //sCheck.mallocFailed = 0; - pnErr = 0; - if (sCheck.nPage == 0) { - sqlite3BtreeLeave(p); - return ""; - } - sCheck.anRef = sqlite3Malloc(sCheck.anRef, (int)sCheck.nPage + 1); - //if( !sCheck.anRef ){ - // pnErr = 1; - // sqlite3BtreeLeave(p); - // return 0; - //} - // for (i = 0; i <= sCheck.nPage; i++) { sCheck.anRef[i] = 0; } - i = PENDING_BYTE_PAGE(pBt); - if (i <= sCheck.nPage) { - sCheck.anRef[i] = 1; - } - sqlite3StrAccumInit(sCheck.errMsg, null, 1000, 20000); - //sCheck.errMsg.useMalloc = 2; - - /* Check the integrity of the freelist - */ - checkList(sCheck, 1, (int)sqlite3Get4byte(pBt.pPage1.aData, 32), - (int)sqlite3Get4byte(pBt.pPage1.aData, 36), "Main freelist: "); - - /* Check all the tables. - */ - for (i = 0; (int)i < nRoot && sCheck.mxErr != 0; i++) { - if (aRoot[i] == 0) - continue; +/* +** This routine does a complete check of the given BTree file. aRoot[] is +** an array of pages numbers were each page number is the root page of +** a table. nRoot is the number of entries in aRoot. +** +** A read-only or read-write transaction must be opened before calling +** this function. +** +** Write the number of error seen in pnErr. Except for some memory +** allocation errors, an error message held in memory obtained from +** malloc is returned if pnErr is non-zero. If pnErr==null then NULL is +** returned. If a memory allocation error occurs, NULL is returned. +*/ +static string sqlite3BtreeIntegrityCheck( +Btree p, /* The btree to be checked */ +int[] aRoot, /* An array of root pages numbers for individual trees */ +int nRoot, /* Number of entries in aRoot[] */ +int mxErr, /* Stop reporting errors after this many */ +ref int pnErr /* Write number of errors seen to this variable */ +) +{ + Pgno i; + int nRef; + IntegrityCk sCheck = new IntegrityCk(); + BtShared pBt = p.pBt; + + sqlite3BtreeEnter( p ); + Debug.Assert( p.inTrans > TRANS_NONE && pBt.inTransaction > TRANS_NONE ); + nRef = sqlite3PagerRefcount( pBt.pPager ); + sCheck.pBt = pBt; + sCheck.pPager = pBt.pPager; + sCheck.nPage = btreePagecount( sCheck.pBt ); + sCheck.mxErr = mxErr; + sCheck.nErr = 0; + //sCheck.mallocFailed = 0; + pnErr = 0; + if ( sCheck.nPage == 0 ) + { + sqlite3BtreeLeave( p ); + return ""; + } + sCheck.anRef = sqlite3Malloc( sCheck.anRef, (int)sCheck.nPage + 1 ); + //if( !sCheck.anRef ){ + // pnErr = 1; + // sqlite3BtreeLeave(p); + // return 0; + //} + // for (i = 0; i <= sCheck.nPage; i++) { sCheck.anRef[i] = 0; } + i = PENDING_BYTE_PAGE( pBt ); + if ( i <= sCheck.nPage ) + { + sCheck.anRef[i] = 1; + } + sqlite3StrAccumInit( sCheck.errMsg, null, 1000, 20000 ); + //sCheck.errMsg.useMalloc = 2; + + /* Check the integrity of the freelist + */ + checkList( sCheck, 1, (int)sqlite3Get4byte( pBt.pPage1.aData, 32 ), + (int)sqlite3Get4byte( pBt.pPage1.aData, 36 ), "Main freelist: " ); + + /* Check all the tables. + */ + for ( i = 0; (int)i < nRoot && sCheck.mxErr != 0; i++ ) + { + if ( aRoot[i] == 0 ) + continue; #if !SQLITE_OMIT_AUTOVACUUM - if (pBt.autoVacuum && aRoot[i] > 1) { - checkPtrmap(sCheck, (u32)aRoot[i], PTRMAP_ROOTPAGE, 0, ""); - } + if ( pBt.autoVacuum && aRoot[i] > 1 ) + { + checkPtrmap( sCheck, (u32)aRoot[i], PTRMAP_ROOTPAGE, 0, "" ); + } #endif - checkTreePage(sCheck, aRoot[i], "List of tree roots: ", ref refNULL, ref refNULL, null, null); - } + checkTreePage( sCheck, aRoot[i], "List of tree roots: ", ref refNULL, ref refNULL, null, null ); + } - /* Make sure every page in the file is referenced - */ - for (i = 1; i <= sCheck.nPage && sCheck.mxErr != 0; i++) { + /* Make sure every page in the file is referenced + */ + for ( i = 1; i <= sCheck.nPage && sCheck.mxErr != 0; i++ ) + { #if SQLITE_OMIT_AUTOVACUUM if( sCheck.anRef[i]==null ){ checkAppendMsg(sCheck, 0, "Page %d is never used", i); } #else - /* If the database supports auto-vacuum, make sure no tables contain - ** references to pointer-map pages. - */ - if (sCheck.anRef[i] == 0 && - (PTRMAP_PAGENO(pBt, i) != i || !pBt.autoVacuum)) { - checkAppendMsg(sCheck, "", "Page %d is never used", i); - } - if (sCheck.anRef[i] != 0 && - (PTRMAP_PAGENO(pBt, i) == i && pBt.autoVacuum)) { - checkAppendMsg(sCheck, "", "Pointer map page %d is referenced", i); - } + /* If the database supports auto-vacuum, make sure no tables contain +** references to pointer-map pages. +*/ + if ( sCheck.anRef[i] == 0 && + ( PTRMAP_PAGENO( pBt, i ) != i || !pBt.autoVacuum ) ) + { + checkAppendMsg( sCheck, "", "Page %d is never used", i ); + } + if ( sCheck.anRef[i] != 0 && + ( PTRMAP_PAGENO( pBt, i ) == i && pBt.autoVacuum ) ) + { + checkAppendMsg( sCheck, "", "Pointer map page %d is referenced", i ); + } #endif - } - - /* Make sure this analysis did not leave any unref() pages. - ** This is an internal consistency check; an integrity check - ** of the integrity check. - */ - if (NEVER(nRef != sqlite3PagerRefcount(pBt.pPager))) { - checkAppendMsg(sCheck, "", - "Outstanding page count goes from %d to %d during this analysis", - nRef, sqlite3PagerRefcount(pBt.pPager) - ); - } - - /* Clean up and report errors. - */ - sqlite3BtreeLeave(p); - sCheck.anRef = null;// sqlite3_free( ref sCheck.anRef ); - //if( sCheck.mallocFailed ){ - // sqlite3StrAccumReset(sCheck.errMsg); - // pnErr = sCheck.nErr+1; - // return 0; - //} - pnErr = sCheck.nErr; - if (sCheck.nErr == 0) - sqlite3StrAccumReset(sCheck.errMsg); - return sqlite3StrAccumFinish(sCheck.errMsg); - } + } + + /* Make sure this analysis did not leave any unref() pages. + ** This is an internal consistency check; an integrity check + ** of the integrity check. + */ + if ( NEVER( nRef != sqlite3PagerRefcount( pBt.pPager ) ) ) + { + checkAppendMsg( sCheck, "", + "Outstanding page count goes from %d to %d during this analysis", + nRef, sqlite3PagerRefcount( pBt.pPager ) + ); + } + + /* Clean up and report errors. + */ + sqlite3BtreeLeave( p ); + sCheck.anRef = null;// sqlite3_free( ref sCheck.anRef ); + //if( sCheck.mallocFailed ){ + // sqlite3StrAccumReset(sCheck.errMsg); + // pnErr = sCheck.nErr+1; + // return 0; + //} + pnErr = sCheck.nErr; + if ( sCheck.nErr == 0 ) + sqlite3StrAccumReset( sCheck.errMsg ); + return sqlite3StrAccumFinish( sCheck.errMsg ); +} #endif //* SQLITE_OMIT_INTEGRITY_CHECK */ - /* - ** Return the full pathname of the underlying database file. - ** - ** The pager filename is invariant as long as the pager is - ** open so it is safe to access without the BtShared mutex. - */ - static string sqlite3BtreeGetFilename(Btree p) { - Debug.Assert(p.pBt.pPager != null); - return sqlite3PagerFilename(p.pBt.pPager); - } +/* +** Return the full pathname of the underlying database file. +** +** The pager filename is invariant as long as the pager is +** open so it is safe to access without the BtShared mutex. +*/ +static string sqlite3BtreeGetFilename( Btree p ) +{ + Debug.Assert( p.pBt.pPager != null ); + return sqlite3PagerFilename( p.pBt.pPager ); +} - /* - ** Return the pathname of the journal file for this database. The return - ** value of this routine is the same regardless of whether the journal file - ** has been created or not. - ** - ** The pager journal filename is invariant as long as the pager is - ** open so it is safe to access without the BtShared mutex. - */ - static string sqlite3BtreeGetJournalname(Btree p) { - Debug.Assert(p.pBt.pPager != null); - return sqlite3PagerJournalname(p.pBt.pPager); - } +/* +** Return the pathname of the journal file for this database. The return +** value of this routine is the same regardless of whether the journal file +** has been created or not. +** +** The pager journal filename is invariant as long as the pager is +** open so it is safe to access without the BtShared mutex. +*/ +static string sqlite3BtreeGetJournalname( Btree p ) +{ + Debug.Assert( p.pBt.pPager != null ); + return sqlite3PagerJournalname( p.pBt.pPager ); +} - /* - ** Return non-zero if a transaction is active. - */ - static bool sqlite3BtreeIsInTrans(Btree p) { - Debug.Assert(p == null || sqlite3_mutex_held(p.db.mutex)); - return (p != null && (p.inTrans == TRANS_WRITE)); - } +/* +** Return non-zero if a transaction is active. +*/ +static bool sqlite3BtreeIsInTrans( Btree p ) +{ + Debug.Assert( p == null || sqlite3_mutex_held( p.db.mutex ) ); + return ( p != null && ( p.inTrans == TRANS_WRITE ) ); +} #if !SQLITE_OMIT_WAL /* @@ -8499,66 +9365,71 @@ static bool sqlite3BtreeIsInTrans(Btree p) { } #endif - /* - ** Return non-zero if a read (or write) transaction is active. - */ - static bool sqlite3BtreeIsInReadTrans(Btree p) { - Debug.Assert(p != null); - Debug.Assert(sqlite3_mutex_held(p.db.mutex)); - return p.inTrans != TRANS_NONE; - } +/* +** Return non-zero if a read (or write) transaction is active. +*/ +static bool sqlite3BtreeIsInReadTrans( Btree p ) +{ + Debug.Assert( p != null ); + Debug.Assert( sqlite3_mutex_held( p.db.mutex ) ); + return p.inTrans != TRANS_NONE; +} - static bool sqlite3BtreeIsInBackup(Btree p) { - Debug.Assert(p != null); - Debug.Assert(sqlite3_mutex_held(p.db.mutex)); - return p.nBackup != 0; - } +static bool sqlite3BtreeIsInBackup( Btree p ) +{ + Debug.Assert( p != null ); + Debug.Assert( sqlite3_mutex_held( p.db.mutex ) ); + return p.nBackup != 0; +} - /* - ** This function returns a pointer to a blob of memory associated with - ** a single shared-btree. The memory is used by client code for its own - ** purposes (for example, to store a high-level schema associated with - ** the shared-btree). The btree layer manages reference counting issues. - ** - ** The first time this is called on a shared-btree, nBytes bytes of memory - ** are allocated, zeroed, and returned to the caller. For each subsequent - ** call the nBytes parameter is ignored and a pointer to the same blob - ** of memory returned. - ** - ** If the nBytes parameter is 0 and the blob of memory has not yet been - ** allocated, a null pointer is returned. If the blob has already been - ** allocated, it is returned as normal. - ** - ** Just before the shared-btree is closed, the function passed as the - ** xFree argument when the memory allocation was made is invoked on the - ** blob of allocated memory. The xFree function should not call sqlite3_free() - ** on the memory, the btree layer does that. - */ - static Schema sqlite3BtreeSchema(Btree p, int nBytes, dxFreeSchema xFree) { - BtShared pBt = p.pBt; - sqlite3BtreeEnter(p); - if (null == pBt.pSchema && nBytes != 0) { - pBt.pSchema = new Schema();//sqlite3DbMallocZero(0, nBytes); - pBt.xFreeSchema = xFree; - } - sqlite3BtreeLeave(p); - return pBt.pSchema; - } +/* +** This function returns a pointer to a blob of memory associated with +** a single shared-btree. The memory is used by client code for its own +** purposes (for example, to store a high-level schema associated with +** the shared-btree). The btree layer manages reference counting issues. +** +** The first time this is called on a shared-btree, nBytes bytes of memory +** are allocated, zeroed, and returned to the caller. For each subsequent +** call the nBytes parameter is ignored and a pointer to the same blob +** of memory returned. +** +** If the nBytes parameter is 0 and the blob of memory has not yet been +** allocated, a null pointer is returned. If the blob has already been +** allocated, it is returned as normal. +** +** Just before the shared-btree is closed, the function passed as the +** xFree argument when the memory allocation was made is invoked on the +** blob of allocated memory. The xFree function should not call sqlite3_free() +** on the memory, the btree layer does that. +*/ +static Schema sqlite3BtreeSchema( Btree p, int nBytes, dxFreeSchema xFree ) +{ + BtShared pBt = p.pBt; + sqlite3BtreeEnter( p ); + if ( null == pBt.pSchema && nBytes != 0 ) + { + pBt.pSchema = new Schema();//sqlite3DbMallocZero(0, nBytes); + pBt.xFreeSchema = xFree; + } + sqlite3BtreeLeave( p ); + return pBt.pSchema; +} - /* - ** Return SQLITE_LOCKED_SHAREDCACHE if another user of the same shared - ** btree as the argument handle holds an exclusive lock on the - ** sqlite_master table. Otherwise SQLITE_OK. - */ - static int sqlite3BtreeSchemaLocked(Btree p) { - int rc; - Debug.Assert(sqlite3_mutex_held(p.db.mutex)); - sqlite3BtreeEnter(p); - rc = querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK); - Debug.Assert(rc == SQLITE_OK || rc == SQLITE_LOCKED_SHAREDCACHE); - sqlite3BtreeLeave(p); - return rc; - } +/* +** Return SQLITE_LOCKED_SHAREDCACHE if another user of the same shared +** btree as the argument handle holds an exclusive lock on the +** sqlite_master table. Otherwise SQLITE_OK. +*/ +static int sqlite3BtreeSchemaLocked( Btree p ) +{ + int rc; + Debug.Assert( sqlite3_mutex_held( p.db.mutex ) ); + sqlite3BtreeEnter( p ); + rc = querySharedCacheTableLock( p, MASTER_ROOT, READ_LOCK ); + Debug.Assert( rc == SQLITE_OK || rc == SQLITE_LOCKED_SHAREDCACHE ); + sqlite3BtreeLeave( p ); + return rc; +} #if !SQLITE_OMIT_SHARED_CACHE @@ -8648,40 +9519,45 @@ static void sqlite3BtreeCacheOverflow(BtCursor pCur){ } #endif - /* - ** Set both the "read version" (single byte at byte offset 18) and - ** "write version" (single byte at byte offset 19) fields in the database - ** header to iVersion. - */ - static int sqlite3BtreeSetVersion(Btree pBtree, int iVersion) { - BtShared pBt = pBtree.pBt; - int rc; /* Return code */ - - Debug.Assert(pBtree.inTrans == TRANS_NONE); - Debug.Assert(iVersion == 1 || iVersion == 2); - - /* If setting the version fields to 1, do not automatically open the - ** WAL connection, even if the version fields are currently set to 2. - */ - pBt.doNotUseWAL = iVersion == 1; - - rc = sqlite3BtreeBeginTrans(pBtree, 0); - if (rc == SQLITE_OK) { - u8[] aData = pBt.pPage1.aData; - if (aData[18] != (u8)iVersion || aData[19] != (u8)iVersion) { - rc = sqlite3BtreeBeginTrans(pBtree, 2); - if (rc == SQLITE_OK) { - rc = sqlite3PagerWrite(pBt.pPage1.pDbPage); - if (rc == SQLITE_OK) { - aData[18] = (u8)iVersion; - aData[19] = (u8)iVersion; - } - } - } - } - - pBt.doNotUseWAL = false; - return rc; - } +/* +** Set both the "read version" (single byte at byte offset 18) and +** "write version" (single byte at byte offset 19) fields in the database +** header to iVersion. +*/ +static int sqlite3BtreeSetVersion( Btree pBtree, int iVersion ) +{ + BtShared pBt = pBtree.pBt; + int rc; /* Return code */ + + Debug.Assert( pBtree.inTrans == TRANS_NONE ); + Debug.Assert( iVersion == 1 || iVersion == 2 ); + + /* If setting the version fields to 1, do not automatically open the + ** WAL connection, even if the version fields are currently set to 2. + */ + pBt.doNotUseWAL = iVersion == 1; + + rc = sqlite3BtreeBeginTrans( pBtree, 0 ); + if ( rc == SQLITE_OK ) + { + u8[] aData = pBt.pPage1.aData; + if ( aData[18] != (u8)iVersion || aData[19] != (u8)iVersion ) + { + rc = sqlite3BtreeBeginTrans( pBtree, 2 ); + if ( rc == SQLITE_OK ) + { + rc = sqlite3PagerWrite( pBt.pPage1.pDbPage ); + if ( rc == SQLITE_OK ) + { + aData[18] = (u8)iVersion; + aData[19] = (u8)iVersion; + } + } } + } + + pBt.doNotUseWAL = false; + return rc; +} + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/build_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/build_c.cs index 754334f1c..0050bf2f0 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/build_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/build_c.cs @@ -8,6 +8,8 @@ using u16 = System.UInt16; using u32 = System.UInt32; +using Pgno = System.UInt32; + /* ** The yDbMask datatype for the bitmask of all attached databases. */ @@ -16,52 +18,55 @@ using yDbMask = System.Int64; #else // typedef unsigned int yDbMask; -using yDbMask = System.Int32; +using yDbMask = System.Int32; #endif -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 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. - ** - ************************************************************************* - ** This file contains C code routines that are called by the SQLite parser - ** when syntax rules are reduced. The routines in this file handle the - ** following kinds of SQL syntax: - ** - ** CREATE TABLE - ** DROP TABLE - ** CREATE INDEX - ** DROP INDEX - ** creating ID lists - ** BEGIN TRANSACTION - ** COMMIT - ** ROLLBACK - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 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. + ** + ************************************************************************* + ** This file contains C code routines that are called by the SQLite parser + ** when syntax rules are reduced. The routines in this file handle the + ** following kinds of SQL syntax: + ** + ** CREATE TABLE + ** DROP TABLE + ** CREATE INDEX + ** DROP INDEX + ** creating ID lists + ** BEGIN TRANSACTION + ** COMMIT + ** ROLLBACK + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" - /* - ** This routine is called when a new SQL statement is beginning to - ** be parsed. Initialize the pParse structure as needed. - */ - static void sqlite3BeginParse(Parse pParse, int explainFlag) { - pParse.explain = (byte)explainFlag; - pParse.nVar = 0; - } + /* + ** This routine is called when a new SQL statement is beginning to + ** be parsed. Initialize the pParse structure as needed. + */ + static void sqlite3BeginParse( Parse pParse, int explainFlag ) + { + pParse.explain = (byte)explainFlag; + pParse.nVar = 0; + } #if !SQLITE_OMIT_SHARED_CACHE /* @@ -149,450 +154,496 @@ static void codeTableLocks( Parse pParse ) } } #else - // #define codeTableLocks(x) - static void codeTableLocks(Parse pParse) { - } + // #define codeTableLocks(x) + static void codeTableLocks( Parse pParse ) + { + } #endif - /* - ** This routine is called after a single SQL statement has been - ** parsed and a VDBE program to execute that statement has been - ** prepared. This routine puts the finishing touches on the - ** VDBE program and resets the pParse structure for the next - ** parse. - ** - ** Note that if an error occurred, it might be the case that - ** no VDBE code was generated. - */ - static void sqlite3FinishCoding(Parse pParse) { - sqlite3 db; - Vdbe v; - - db = pParse.db; - // if ( db.mallocFailed != 0 ) return; - if (pParse.nested != 0) - return; - if (pParse.nErr != 0) - return; - - /* Begin by generating some termination code at the end of the - ** vdbe program - */ - v = sqlite3GetVdbe(pParse); - Debug.Assert(0 == pParse.isMultiWrite -#if SQLITE_DEBUG - || sqlite3VdbeAssertMayAbort(v, pParse.mayAbort) != 0 + /* +** This routine is called after a single SQL statement has been +** parsed and a VDBE program to execute that statement has been +** prepared. This routine puts the finishing touches on the +** VDBE program and resets the pParse structure for the next +** parse. +** +** Note that if an error occurred, it might be the case that +** no VDBE code was generated. +*/ + static void sqlite3FinishCoding( Parse pParse ) + { + sqlite3 db; + Vdbe v; + + db = pParse.db; + // if ( db.mallocFailed != 0 ) return; + if ( pParse.nested != 0 ) + return; + if ( pParse.nErr != 0 ) + return; + + /* Begin by generating some termination code at the end of the + ** vdbe program + */ + v = sqlite3GetVdbe( pParse ); + Debug.Assert( 0 == pParse.isMultiWrite +#if SQLITE_DEBUG + || sqlite3VdbeAssertMayAbort( v, pParse.mayAbort ) != 0 #endif - ); - if (v != null) { - sqlite3VdbeAddOp0(v, OP_Halt); - - /* The cookie mask contains one bit for each database file open. - ** (Bit 0 is for main, bit 1 is for temp, and so forth.) Bits are - ** set for each database that is used. Generate code to start a - ** transaction on each used database and to verify the schema cookie - ** on each used database. - */ - if (pParse.cookieGoto > 0) { - u32 mask; - int iDb; - sqlite3VdbeJumpHere(v, pParse.cookieGoto - 1); - for (iDb = 0, mask = 1; iDb < db.nDb; mask <<= 1, iDb++) { - if ((mask & pParse.cookieMask) == 0) - continue; - sqlite3VdbeUsesBtree(v, iDb); - sqlite3VdbeAddOp2(v, OP_Transaction, iDb, (mask & pParse.writeMask) != 0); - if (db.init.busy == 0) { - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); - sqlite3VdbeAddOp3(v, OP_VerifyCookie, - iDb, pParse.cookieValue[iDb], - (int)db.aDb[iDb].pSchema.iGeneration); - } - } + ); + if ( v != null ) + { + sqlite3VdbeAddOp0( v, OP_Halt ); + + /* The cookie mask contains one bit for each database file open. + ** (Bit 0 is for main, bit 1 is for temp, and so forth.) Bits are + ** set for each database that is used. Generate code to start a + ** transaction on each used database and to verify the schema cookie + ** on each used database. + */ + if ( pParse.cookieGoto > 0 ) + { + u32 mask; + int iDb; + sqlite3VdbeJumpHere( v, pParse.cookieGoto - 1 ); + for ( iDb = 0, mask = 1; iDb < db.nDb; mask <<= 1, iDb++ ) + { + if ( ( mask & pParse.cookieMask ) == 0 ) + continue; + sqlite3VdbeUsesBtree( v, iDb ); + sqlite3VdbeAddOp2( v, OP_Transaction, iDb, ( mask & pParse.writeMask ) != 0 ); + if ( db.init.busy == 0 ) + { + Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); + sqlite3VdbeAddOp3( v, OP_VerifyCookie, + iDb, pParse.cookieValue[iDb], + (int)db.aDb[iDb].pSchema.iGeneration ); + } + } #if !SQLITE_OMIT_VIRTUALTABLE - { - int i; - for (i = 0; i < pParse.nVtabLock; i++) { - VTable vtab = sqlite3GetVTable(db, pParse.apVtabLock[i]); - sqlite3VdbeAddOp4(v, OP_VBegin, 0, 0, 0, vtab, P4_VTAB); - } - pParse.nVtabLock = 0; - } + { + int i; + for ( i = 0; i < pParse.nVtabLock; i++ ) + { + VTable vtab = sqlite3GetVTable( db, pParse.apVtabLock[i] ); + sqlite3VdbeAddOp4( v, OP_VBegin, 0, 0, 0, vtab, P4_VTAB ); + } + pParse.nVtabLock = 0; + } #endif - /* Once all the cookies have been verified and transactions opened, - ** obtain the required table-locks. This is a no-op unless the - ** shared-cache feature is enabled. - */ - codeTableLocks(pParse); + /* Once all the cookies have been verified and transactions opened, +** obtain the required table-locks. This is a no-op unless the +** shared-cache feature is enabled. +*/ + codeTableLocks( pParse ); - /* Initialize any AUTOINCREMENT data structures required. - */ - sqlite3AutoincrementBegin(pParse); + /* Initialize any AUTOINCREMENT data structures required. + */ + sqlite3AutoincrementBegin( pParse ); - /* Finally, jump back to the beginning of the executable code. */ - sqlite3VdbeAddOp2(v, OP_Goto, 0, pParse.cookieGoto); - } - } + /* Finally, jump back to the beginning of the executable code. */ + sqlite3VdbeAddOp2( v, OP_Goto, 0, pParse.cookieGoto ); + } + } - /* Get the VDBE program ready for execution - */ - if (v != null && ALWAYS(pParse.nErr == 0) /* && 0 == db.mallocFailed */ ) { -#if SQLITE_DEBUG && !SQLITE_WINRT - TextWriter trace = (db.flags & SQLITE_VdbeTrace) != 0 ? Console.Out : null; - sqlite3VdbeTrace(v, trace); + /* Get the VDBE program ready for execution + */ + if ( v != null && ALWAYS( pParse.nErr == 0 ) /* && 0 == db.mallocFailed */ ) + { +#if SQLITE_DEBUG && !SQLITE_WINRT + TextWriter trace = ( db.flags & SQLITE_VdbeTrace ) != 0 ? Console.Out : null; + sqlite3VdbeTrace( v, trace ); #endif - Debug.Assert(pParse.iCacheLevel == 0); /* Disables and re-enables match */ - /* A minimum of one cursor is required if autoincrement is used - * See ticket [a696379c1f08866] */ - if (pParse.pAinc != null && pParse.nTab == 0) - pParse.nTab = 1; - sqlite3VdbeMakeReady(v, pParse); - pParse.rc = SQLITE_DONE; - pParse.colNamesSet = 0; - } else { - pParse.rc = SQLITE_ERROR; - } - pParse.nTab = 0; - pParse.nMem = 0; - pParse.nSet = 0; - pParse.nVar = 0; - pParse.cookieMask = 0; - pParse.cookieGoto = 0; - } - - /* - ** Run the parser and code generator recursively in order to generate - ** code for the SQL statement given onto the end of the pParse context - ** currently under construction. When the parser is run recursively - ** this way, the final OP_Halt is not appended and other initialization - ** and finalization steps are omitted because those are handling by the - ** outermost parser. - ** - ** Not everything is nestable. This facility is designed to permit - ** INSERT, UPDATE, and DELETE operations against SQLITE_MASTER. Use - ** care if you decide to try to use this routine for some other purposes. - */ - static void sqlite3NestedParse(Parse pParse, string zFormat, params object[] ap) { - string zSql; // string zSql; - string zErrMsg = "";// char* zErrMsg = 0; - sqlite3 db = pParse.db; - - //# define SAVE_SZ (Parse.Length - offsetof(Parse,nVar)) - // char saveBuf[SAVE_SZ]; - - if (pParse.nErr != 0) - return; - Debug.Assert(pParse.nested < 10); /* Nesting should only be of limited depth */ - // va_list ap; - lock (lock_va_list) { - va_start(ap, zFormat); - zSql = sqlite3VMPrintf(db, zFormat, ap); - va_end(ref ap); - } - //if( zSql=="" ){ - // return; /* A malloc must have failed */ - //} - lock (nestingLock) { - pParse.nested++; - pParse.SaveMembers(); // memcpy(saveBuf, pParse.nVar, SAVE_SZ); - pParse.ResetMembers(); // memset(pParse.nVar, 0, SAVE_SZ); - sqlite3RunParser(pParse, zSql, ref zErrMsg); - sqlite3DbFree(db, ref zErrMsg); - sqlite3DbFree(db, ref zSql); - pParse.RestoreMembers(); // memcpy(pParse.nVar, saveBuf, SAVE_SZ); - pParse.nested--; - } - } - static Object nestingLock = new Object(); + Debug.Assert( pParse.iCacheLevel == 0 ); /* Disables and re-enables match */ + /* A minimum of one cursor is required if autoincrement is used + * See ticket [a696379c1f08866] */ + if ( pParse.pAinc != null && pParse.nTab == 0 ) + pParse.nTab = 1; + sqlite3VdbeMakeReady( v, pParse); + pParse.rc = SQLITE_DONE; + pParse.colNamesSet = 0; + } + else + { + pParse.rc = SQLITE_ERROR; + } + pParse.nTab = 0; + pParse.nMem = 0; + pParse.nSet = 0; + pParse.nVar = 0; + pParse.cookieMask = 0; + pParse.cookieGoto = 0; + } - /* - ** Locate the in-memory structure that describes a particular database - ** table given the name of that table and (optionally) the name of the - ** database containing the table. Return NULL if not found. - ** - ** If zDatabase is 0, all databases are searched for the table and the - ** first matching table is returned. (No checking for duplicate table - ** names is done.) The search order is TEMP first, then MAIN, then any - ** auxiliary databases added using the ATTACH command. - ** - ** See also sqlite3LocateTable(). - */ - static Table sqlite3FindTable(sqlite3 db, string zName, string zDatabase) { - Table p = null; - int i; - int nName; - Debug.Assert(zName != null); - nName = sqlite3Strlen30(zName); - /* All mutexes are required for schema access. Make sure we hold them. */ - Debug.Assert(zDatabase != null || sqlite3BtreeHoldsAllMutexes(db)); - for (i = OMIT_TEMPDB; i < db.nDb; i++) { - int j = (i < 2) ? i ^ 1 : i; /* Search TEMP before MAIN */ - if (zDatabase != null && !zDatabase.Equals(db.aDb[j].zName, StringComparison.OrdinalIgnoreCase)) - continue; - Debug.Assert(sqlite3SchemaMutexHeld(db, j, null)); - p = sqlite3HashFind(db.aDb[j].pSchema.tblHash, zName, nName, (Table)null); - if (p != null) - break; - } - return p; - } + /* + ** Run the parser and code generator recursively in order to generate + ** code for the SQL statement given onto the end of the pParse context + ** currently under construction. When the parser is run recursively + ** this way, the final OP_Halt is not appended and other initialization + ** and finalization steps are omitted because those are handling by the + ** outermost parser. + ** + ** Not everything is nestable. This facility is designed to permit + ** INSERT, UPDATE, and DELETE operations against SQLITE_MASTER. Use + ** care if you decide to try to use this routine for some other purposes. + */ + static void sqlite3NestedParse( Parse pParse, string zFormat, params object[] ap ) + { + string zSql; // string zSql; + string zErrMsg = "";// char* zErrMsg = 0; + sqlite3 db = pParse.db; + + //# define SAVE_SZ (Parse.Length - offsetof(Parse,nVar)) + // char saveBuf[SAVE_SZ]; + + if ( pParse.nErr != 0 ) + return; + Debug.Assert( pParse.nested < 10 ); /* Nesting should only be of limited depth */ + // va_list ap; + lock ( lock_va_list ) + { + va_start( ap, zFormat ); + zSql = sqlite3VMPrintf( db, zFormat, ap ); + va_end( ref ap ); + } + //if( zSql=="" ){ + // return; /* A malloc must have failed */ + //} + lock ( nestingLock ) + { + pParse.nested++; + pParse.SaveMembers(); // memcpy(saveBuf, pParse.nVar, SAVE_SZ); + pParse.ResetMembers(); // memset(pParse.nVar, 0, SAVE_SZ); + sqlite3RunParser( pParse, zSql, ref zErrMsg ); + sqlite3DbFree( db, ref zErrMsg ); + sqlite3DbFree( db, ref zSql ); + pParse.RestoreMembers(); // memcpy(pParse.nVar, saveBuf, SAVE_SZ); + pParse.nested--; + } + } + static Object nestingLock = new Object(); - /* - ** Locate the in-memory structure that describes a particular database - ** table given the name of that table and (optionally) the name of the - ** database containing the table. Return NULL if not found. Also leave an - ** error message in pParse.zErrMsg. - ** - ** The difference between this routine and sqlite3FindTable() is that this - ** routine leaves an error message in pParse.zErrMsg where - ** sqlite3FindTable() does not. - */ - static Table sqlite3LocateTable( - Parse pParse, /* context in which to report errors */ - int isView, /* True if looking for a VIEW rather than a TABLE */ - string zName, /* Name of the table we are looking for */ - string zDbase /* Name of the database. Might be NULL */ - ) { - Table p; - - /* Read the database schema. If an error occurs, leave an error message - ** and code in pParse and return NULL. */ - if (SQLITE_OK != sqlite3ReadSchema(pParse)) { - return null; - } + /* + ** Locate the in-memory structure that describes a particular database + ** table given the name of that table and (optionally) the name of the + ** database containing the table. Return NULL if not found. + ** + ** If zDatabase is 0, all databases are searched for the table and the + ** first matching table is returned. (No checking for duplicate table + ** names is done.) The search order is TEMP first, then MAIN, then any + ** auxiliary databases added using the ATTACH command. + ** + ** See also sqlite3LocateTable(). + */ + static Table sqlite3FindTable( sqlite3 db, string zName, string zDatabase ) + { + Table p = null; + int i; + int nName; + Debug.Assert( zName != null ); + nName = sqlite3Strlen30( zName ); + /* All mutexes are required for schema access. Make sure we hold them. */ + Debug.Assert( zDatabase != null || sqlite3BtreeHoldsAllMutexes( db ) ); + for ( i = OMIT_TEMPDB; i < db.nDb; i++ ) + { + int j = ( i < 2 ) ? i ^ 1 : i; /* Search TEMP before MAIN */ + if ( zDatabase != null && !zDatabase.Equals( db.aDb[j].zName, StringComparison.OrdinalIgnoreCase ) ) + continue; + Debug.Assert( sqlite3SchemaMutexHeld( db, j, null ) ); + p = sqlite3HashFind( db.aDb[j].pSchema.tblHash, zName, nName, (Table)null ); + if ( p != null ) + break; + } + return p; + } - p = sqlite3FindTable(pParse.db, zName, zDbase); - if (p == null) { - string zMsg = isView != 0 ? "no such view" : "no such table"; - if (zDbase != null) { - sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName); - } else { - sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName); - } - pParse.checkSchema = 1; - } - return p; + /* + ** Locate the in-memory structure that describes a particular database + ** table given the name of that table and (optionally) the name of the + ** database containing the table. Return NULL if not found. Also leave an + ** error message in pParse.zErrMsg. + ** + ** The difference between this routine and sqlite3FindTable() is that this + ** routine leaves an error message in pParse.zErrMsg where + ** sqlite3FindTable() does not. + */ + static Table sqlite3LocateTable( + Parse pParse, /* context in which to report errors */ + int isView, /* True if looking for a VIEW rather than a TABLE */ + string zName, /* Name of the table we are looking for */ + string zDbase /* Name of the database. Might be NULL */ + ) + { + Table p; + + /* Read the database schema. If an error occurs, leave an error message + ** and code in pParse and return NULL. */ + if ( SQLITE_OK != sqlite3ReadSchema( pParse ) ) + { + return null; + } + + p = sqlite3FindTable( pParse.db, zName, zDbase ); + if ( p == null ) + { + string zMsg = isView != 0 ? "no such view" : "no such table"; + if ( zDbase != null ) + { + sqlite3ErrorMsg( pParse, "%s: %s.%s", zMsg, zDbase, zName ); } - - /* - ** Locate the in-memory structure that describes - ** a particular index given the name of that index - ** and the name of the database that contains the index. - ** Return NULL if not found. - ** - ** If zDatabase is 0, all databases are searched for the - ** table and the first matching index is returned. (No checking - ** for duplicate index names is done.) The search order is - ** TEMP first, then MAIN, then any auxiliary databases added - ** using the ATTACH command. - */ - static Index sqlite3FindIndex(sqlite3 db, string zName, string zDb) { - Index p = null; - int i; - int nName = sqlite3Strlen30(zName); - /* All mutexes are required for schema access. Make sure we hold them. */ - Debug.Assert(zDb != null || sqlite3BtreeHoldsAllMutexes(db)); - for (i = OMIT_TEMPDB; i < db.nDb; i++) { - int j = (i < 2) ? i ^ 1 : i; /* Search TEMP before MAIN */ - Schema pSchema = db.aDb[j].pSchema; - Debug.Assert(pSchema != null); - if (zDb != null && !zDb.Equals(db.aDb[j].zName, StringComparison.OrdinalIgnoreCase)) - continue; - Debug.Assert(sqlite3SchemaMutexHeld(db, j, null)); - p = sqlite3HashFind(pSchema.idxHash, zName, nName, (Index)null); - if (p != null) - break; - } - return p; + else + { + sqlite3ErrorMsg( pParse, "%s: %s", zMsg, zName ); } + pParse.checkSchema = 1; + } + return p; + } - /* - ** Reclaim the memory used by an index - */ - static void freeIndex(sqlite3 db, ref Index p) { + /* + ** Locate the in-memory structure that describes + ** a particular index given the name of that index + ** and the name of the database that contains the index. + ** Return NULL if not found. + ** + ** If zDatabase is 0, all databases are searched for the + ** table and the first matching index is returned. (No checking + ** for duplicate index names is done.) The search order is + ** TEMP first, then MAIN, then any auxiliary databases added + ** using the ATTACH command. + */ + static Index sqlite3FindIndex( sqlite3 db, string zName, string zDb ) + { + Index p = null; + int i; + int nName = sqlite3Strlen30( zName ); + /* All mutexes are required for schema access. Make sure we hold them. */ + Debug.Assert( zDb != null || sqlite3BtreeHoldsAllMutexes( db ) ); + for ( i = OMIT_TEMPDB; i < db.nDb; i++ ) + { + int j = ( i < 2 ) ? i ^ 1 : i; /* Search TEMP before MAIN */ + Schema pSchema = db.aDb[j].pSchema; + Debug.Assert( pSchema != null ); + if ( zDb != null && !zDb.Equals( db.aDb[j].zName, StringComparison.OrdinalIgnoreCase ) ) + continue; + Debug.Assert( sqlite3SchemaMutexHeld( db, j, null ) ); + p = sqlite3HashFind( pSchema.idxHash, zName, nName, (Index)null ); + if ( p != null ) + break; + } + return p; + } + + /* + ** Reclaim the memory used by an index + */ + static void freeIndex( sqlite3 db, ref Index p ) + { #if !SQLITE_OMIT_ANALYZE - sqlite3DeleteIndexSamples(db, p); + sqlite3DeleteIndexSamples( db, p ); #endif - sqlite3DbFree(db, ref p.zColAff); - sqlite3DbFree(db, ref p); - } + sqlite3DbFree( db, ref p.zColAff ); + sqlite3DbFree( db, ref p ); + } - /* - ** For the index called zIdxName which is found in the database iDb, - ** unlike that index from its Table then remove the index from - ** the index hash table and free all memory structures associated - ** with the index. - */ - static void sqlite3UnlinkAndDeleteIndex(sqlite3 db, int iDb, string zIdxName) { - Index pIndex; - int len; - Hash pHash; - - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); - pHash = db.aDb[iDb].pSchema.idxHash; - - len = sqlite3Strlen30(zIdxName); - pIndex = sqlite3HashInsert(ref pHash, zIdxName, len, (Index)null); - if (ALWAYS(pIndex)) { - if (pIndex.pTable.pIndex == pIndex) { - pIndex.pTable.pIndex = pIndex.pNext; - } else { - Index p; - /* Justification of ALWAYS(); The index must be on the list of - ** indices. */ - p = pIndex.pTable.pIndex; - while (ALWAYS(p != null) && p.pNext != pIndex) { - p = p.pNext; - } - if (ALWAYS(p != null && p.pNext == pIndex)) { - p.pNext = pIndex.pNext; - } - } - freeIndex(db, ref pIndex); - } - db.flags |= SQLITE_InternChanges; + /* + ** For the index called zIdxName which is found in the database iDb, + ** unlike that index from its Table then remove the index from + ** the index hash table and free all memory structures associated + ** with the index. + */ + static void sqlite3UnlinkAndDeleteIndex( sqlite3 db, int iDb, string zIdxName ) + { + Index pIndex; + int len; + Hash pHash; + + Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); + pHash = db.aDb[iDb].pSchema.idxHash; + + len = sqlite3Strlen30( zIdxName ); + pIndex = sqlite3HashInsert( ref pHash, zIdxName, len, (Index)null ); + if ( ALWAYS(pIndex) ) + { + if ( pIndex.pTable.pIndex == pIndex ) + { + pIndex.pTable.pIndex = pIndex.pNext; } - - /* - ** Erase all schema information from the in-memory hash tables of - ** a single database. This routine is called to reclaim memory - ** before the database closes. It is also called during a rollback - ** if there were schema changes during the transaction or if a - ** schema-cookie mismatch occurs. - ** - ** If iDb<0 then reset the internal schema tables for all database - ** files. If iDb>=0 then reset the internal schema for only the - ** single file indicated. - */ - static void sqlite3ResetInternalSchema(sqlite3 db, int iDb) { - int i, j; - Debug.Assert(iDb < db.nDb); - - if (iDb >= 0) { - /* Case 1: Reset the single schema identified by iDb */ - Db pDb = db.aDb[iDb]; - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); - Debug.Assert(pDb.pSchema != null); - sqlite3SchemaClear(pDb.pSchema); - - /* If any database other than TEMP is reset, then also reset TEMP - ** since TEMP might be holding triggers that reference tables in the - ** other database. - */ - if (iDb != 1) { - pDb = db.aDb[1]; - Debug.Assert(pDb.pSchema != null); - sqlite3SchemaClear(pDb.pSchema); - } - return; - } - /* Case 2 (from here to the end): Reset all schemas for all attached - ** databases. */ - Debug.Assert(iDb < 0); - sqlite3BtreeEnterAll(db); - for (i = 0; i < db.nDb; i++) { - Db pDb = db.aDb[i]; - if (pDb.pSchema != null) { - sqlite3SchemaClear(pDb.pSchema); - } - } - db.flags &= ~SQLITE_InternChanges; - sqlite3VtabUnlockList(db); - sqlite3BtreeLeaveAll(db); - /* If one or more of the auxiliary database files has been closed, - ** then remove them from the auxiliary database list. We take the - ** opportunity to do this here since we have just deleted all of the - ** schema hash tables and therefore do not have to make any changes - ** to any of those tables. - */ - for (i = j = 2; i < db.nDb; i++) { - Db pDb = db.aDb[i]; - if (pDb.pBt == null) { - sqlite3DbFree(db, ref pDb.zName); - continue; - } - if (j < i) { - db.aDb[j] = db.aDb[i]; - } - j++; - } - if (db.nDb != j) - db.aDb[j] = new Db();//memset(db.aDb[j], 0, (db.nDb-j)*sizeof(db.aDb[j])); - db.nDb = j; - if (db.nDb <= 2 && db.aDb != db.aDbStatic) { - Array.Copy(db.aDb, db.aDbStatic, 2);// memcpy(db.aDbStatic, db.aDb, 2*sizeof(db.aDb[0])); - //sqlite3DbFree( db, ref db.aDb ); - //db.aDb = db.aDbStatic; - } + else + { + Index p; + /* Justification of ALWAYS(); The index must be on the list of + ** indices. */ + p = pIndex.pTable.pIndex; + while ( ALWAYS( p != null ) && p.pNext != pIndex ) + { + p = p.pNext; + } + if ( ALWAYS( p != null && p.pNext == pIndex ) ) + { + p.pNext = pIndex.pNext; + } } + freeIndex( db, ref pIndex ); + } + db.flags |= SQLITE_InternChanges; + } - /* - ** This routine is called when a commit occurs. + /* + ** Erase all schema information from the in-memory hash tables of + ** a single database. This routine is called to reclaim memory + ** before the database closes. It is also called during a rollback + ** if there were schema changes during the transaction or if a + ** schema-cookie mismatch occurs. + ** + ** If iDb<0 then reset the internal schema tables for all database + ** files. If iDb>=0 then reset the internal schema for only the + ** single file indicated. + */ + static void sqlite3ResetInternalSchema( sqlite3 db, int iDb ) + { + int i, j; + Debug.Assert( iDb < db.nDb ); + + if ( iDb >= 0 ) + { + /* Case 1: Reset the single schema identified by iDb */ + Db pDb = db.aDb[iDb]; + Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); + Debug.Assert( pDb.pSchema != null); + sqlite3SchemaClear( pDb.pSchema ); + + /* If any database other than TEMP is reset, then also reset TEMP + ** since TEMP might be holding triggers that reference tables in the + ** other database. */ - static void sqlite3CommitInternalChanges(sqlite3 db) { - db.flags &= ~SQLITE_InternChanges; + if ( iDb != 1 ) + { + pDb = db.aDb[1]; + Debug.Assert( pDb.pSchema != null ); + sqlite3SchemaClear( pDb.pSchema ); + } + return; + } + /* Case 2 (from here to the end): Reset all schemas for all attached + ** databases. */ + Debug.Assert( iDb < 0 ); + sqlite3BtreeEnterAll( db ); + for ( i = 0; i < db.nDb; i++ ) + { + Db pDb = db.aDb[i]; + if ( pDb.pSchema != null ) + { + sqlite3SchemaClear( pDb.pSchema ); + } + } + db.flags &= ~SQLITE_InternChanges; + sqlite3VtabUnlockList( db ); + sqlite3BtreeLeaveAll( db ); + /* If one or more of the auxiliary database files has been closed, + ** then remove them from the auxiliary database list. We take the + ** opportunity to do this here since we have just deleted all of the + ** schema hash tables and therefore do not have to make any changes + ** to any of those tables. + */ + for ( i = j = 2; i < db.nDb; i++ ) + { + Db pDb = db.aDb[i]; + if ( pDb.pBt == null ) + { + sqlite3DbFree( db, ref pDb.zName ); + continue; + } + if ( j < i ) + { + db.aDb[j] = db.aDb[i]; } + j++; + } + if ( db.nDb != j ) + db.aDb[j] = new Db();//memset(db.aDb[j], 0, (db.nDb-j)*sizeof(db.aDb[j])); + db.nDb = j; + if ( db.nDb <= 2 && db.aDb != db.aDbStatic ) + { + Array.Copy( db.aDb, db.aDbStatic, 2 );// memcpy(db.aDbStatic, db.aDb, 2*sizeof(db.aDb[0])); + //sqlite3DbFree( db, ref db.aDb ); + //db.aDb = db.aDbStatic; + } + } - /* - ** Delete memory allocated for the column names of a table or view (the - ** Table.aCol[] array). - */ - static void sqliteDeleteColumnNames(sqlite3 db, Table pTable) { - int i; - Column pCol; - Debug.Assert(pTable != null); - for (i = 0; i < pTable.nCol; i++) { - pCol = pTable.aCol[i]; - if (pCol != null) { - sqlite3DbFree(db, ref pCol.zName); - sqlite3ExprDelete(db, ref pCol.pDflt); - sqlite3DbFree(db, ref pCol.zDflt); - sqlite3DbFree(db, ref pCol.zType); - sqlite3DbFree(db, ref pCol.zColl); - } - } + /* + ** This routine is called when a commit occurs. + */ + static void sqlite3CommitInternalChanges( sqlite3 db ) + { + db.flags &= ~SQLITE_InternChanges; + } + + /* + ** Delete memory allocated for the column names of a table or view (the + ** Table.aCol[] array). + */ + static void sqliteDeleteColumnNames( sqlite3 db, Table pTable ) + { + int i; + Column pCol; + Debug.Assert( pTable != null ); + for ( i = 0; i < pTable.nCol; i++ ) + { + pCol = pTable.aCol[i]; + if ( pCol != null ) + { + sqlite3DbFree( db, ref pCol.zName ); + sqlite3ExprDelete( db, ref pCol.pDflt ); + sqlite3DbFree( db, ref pCol.zDflt ); + sqlite3DbFree( db, ref pCol.zType ); + sqlite3DbFree( db, ref pCol.zColl ); } + } + } - /* - ** Remove the memory data structures associated with the given - ** Table. No changes are made to disk by this routine. - ** - ** This routine just deletes the data structure. It does not unlink - ** the table data structure from the hash table. But it does destroy - ** memory structures of the indices and foreign keys associated with - ** the table. - */ - static void sqlite3DeleteTable(sqlite3 db, ref Table pTable) { - Index pIndex; - Index pNext; - - Debug.Assert(null == pTable || pTable.nRef > 0); - - /* Do not delete the table until the reference count reaches zero. */ - if (null == pTable) - return; - if ((// ( !db || db->pnBytesFreed == 0 ) && - (--pTable.nRef) > 0)) - return; - - /* Delete all indices associated with this table. */ - for (pIndex = pTable.pIndex; pIndex != null; pIndex = pNext) { - pNext = pIndex.pNext; - Debug.Assert(pIndex.pSchema == pTable.pSchema); - //if( null==db || db.pnBytesFreed==0 ){ - string zName = pIndex.zName; - // + /* + ** Remove the memory data structures associated with the given + ** Table. No changes are made to disk by this routine. + ** + ** This routine just deletes the data structure. It does not unlink + ** the table data structure from the hash table. But it does destroy + ** memory structures of the indices and foreign keys associated with + ** the table. + */ + static void sqlite3DeleteTable( sqlite3 db, ref Table pTable ) + { + Index pIndex; + Index pNext; + + Debug.Assert( null == pTable || pTable.nRef > 0 ); + + /* Do not delete the table until the reference count reaches zero. */ + if ( null == pTable ) + return; + if ( (// ( !db || db->pnBytesFreed == 0 ) && + ( --pTable.nRef ) > 0 ) ) + return; + + /* Delete all indices associated with this table. */ + for ( pIndex = pTable.pIndex; pIndex != null; pIndex = pNext ) + { + pNext = pIndex.pNext; + Debug.Assert( pIndex.pSchema == pTable.pSchema ); + //if( null==db || db.pnBytesFreed==0 ){ + string zName = pIndex.zName; + // #if !NDEBUG || SQLITE_COVERAGE_TEST - // TESTONLY ( Index pOld = ) sqlite3HashInsert( - //ref pIndex.pSchema.idxHash, zName, sqlite3Strlen30(zName), 0 - // ); - Index pOld = sqlite3HashInsert( - ref pIndex.pSchema.idxHash, zName, sqlite3Strlen30(zName), (Index)null - ); - Debug.Assert(db == null || sqlite3SchemaMutexHeld(db, 0, pIndex.pSchema)); - Debug.Assert(pOld == pIndex || pOld == null); + // TESTONLY ( Index pOld = ) sqlite3HashInsert( + //ref pIndex.pSchema.idxHash, zName, sqlite3Strlen30(zName), 0 + // ); + Index pOld = sqlite3HashInsert( + ref pIndex.pSchema.idxHash, zName, sqlite3Strlen30( zName ), (Index)null + ); + Debug.Assert( db == null || sqlite3SchemaMutexHeld( db, 0, pIndex.pSchema ) ); + Debug.Assert( pOld == pIndex || pOld == null ); #else // TESTONLY ( Index pOld = ) sqlite3HashInsert( //ref pIndex.pSchema.idxHash, zName, sqlite3Strlen30(zName), 0 @@ -601,257 +652,280 @@ static void sqlite3DeleteTable(sqlite3 db, ref Table pTable) { ref pIndex.pSchema.idxHash, zName, sqlite3Strlen30(zName),(Index)null ); #endif - //} - freeIndex(db, ref pIndex); - } + //} + freeIndex( db, ref pIndex ); + } - /* Delete any foreign keys attached to this table. */ - sqlite3FkDelete(db, pTable); + /* Delete any foreign keys attached to this table. */ + sqlite3FkDelete( db, pTable ); - /* Delete the Table structure itself. - */ - sqliteDeleteColumnNames(db, pTable); - sqlite3DbFree(db, ref pTable.zName); - sqlite3DbFree(db, ref pTable.zColAff); - sqlite3SelectDelete(db, ref pTable.pSelect); + /* Delete the Table structure itself. +*/ + sqliteDeleteColumnNames( db, pTable ); + sqlite3DbFree( db, ref pTable.zName ); + sqlite3DbFree( db, ref pTable.zColAff ); + sqlite3SelectDelete( db, ref pTable.pSelect ); #if !SQLITE_OMIT_CHECK - sqlite3ExprDelete(db, ref pTable.pCheck); + sqlite3ExprDelete( db, ref pTable.pCheck ); #endif #if !SQLITE_OMIT_VIRTUALTABLE - sqlite3VtabClear(db, pTable); + sqlite3VtabClear(db, pTable); #endif - pTable = null;// sqlite3DbFree( db, ref pTable ); - } + pTable = null;// sqlite3DbFree( db, ref pTable ); + } - /* - ** Unlink the given table from the hash tables and the delete the - ** table structure with all its indices and foreign keys. - */ - static void sqlite3UnlinkAndDeleteTable(sqlite3 db, int iDb, string zTabName) { - Table p; - Db pDb; - - Debug.Assert(db != null); - Debug.Assert(iDb >= 0 && iDb < db.nDb); - Debug.Assert(zTabName != null); - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); - testcase(zTabName.Length == 0); /* Zero-length table names are allowed */ - pDb = db.aDb[iDb]; - p = sqlite3HashInsert(ref pDb.pSchema.tblHash, zTabName, - sqlite3Strlen30(zTabName), (Table)null); - sqlite3DeleteTable(db, ref p); - db.flags |= SQLITE_InternChanges; - } + /* + ** Unlink the given table from the hash tables and the delete the + ** table structure with all its indices and foreign keys. + */ + static void sqlite3UnlinkAndDeleteTable( sqlite3 db, int iDb, string zTabName ) + { + Table p; + Db pDb; + + Debug.Assert( db != null ); + Debug.Assert( iDb >= 0 && iDb < db.nDb ); + Debug.Assert( zTabName != null ); + Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); + testcase( zTabName.Length == 0 ); /* Zero-length table names are allowed */ + pDb = db.aDb[iDb]; + p = sqlite3HashInsert( ref pDb.pSchema.tblHash, zTabName, + sqlite3Strlen30( zTabName ), (Table)null ); + sqlite3DeleteTable( db, ref p ); + db.flags |= SQLITE_InternChanges; + } - /* - ** Given a token, return a string that consists of the text of that - ** token. Space to hold the returned string - ** is obtained from sqliteMalloc() and must be freed by the calling - ** function. - ** - ** Any quotation marks (ex: "name", 'name', [name], or `name`) that - ** surround the body of the token are removed. - ** - ** Tokens are often just pointers into the original SQL text and so - ** are not \000 terminated and are not persistent. The returned string - ** is \000 terminated and is persistent. - */ - static string sqlite3NameFromToken(sqlite3 db, Token pName) { - string zName; - if (pName != null && pName.z != null) { - zName = pName.z.Substring(0, pName.n);//sqlite3DbStrNDup(db, (char)pName.z, pName.n); - sqlite3Dequote(ref zName); - } else { - return null; - } - return zName; - } + /* + ** Given a token, return a string that consists of the text of that + ** token. Space to hold the returned string + ** is obtained from sqliteMalloc() and must be freed by the calling + ** function. + ** + ** Any quotation marks (ex: "name", 'name', [name], or `name`) that + ** surround the body of the token are removed. + ** + ** Tokens are often just pointers into the original SQL text and so + ** are not \000 terminated and are not persistent. The returned string + ** is \000 terminated and is persistent. + */ + static string sqlite3NameFromToken( sqlite3 db, Token pName ) + { + string zName; + if ( pName != null && pName.z != null ) + { + zName = pName.z.Substring( 0, pName.n );//sqlite3DbStrNDup(db, (char)pName.z, pName.n); + sqlite3Dequote( ref zName ); + } + else + { + return null; + } + return zName; + } - /* - ** Open the sqlite_master table stored in database number iDb for - ** writing. The table is opened using cursor 0. - */ - static void sqlite3OpenMasterTable(Parse p, int iDb) { - Vdbe v = sqlite3GetVdbe(p); - sqlite3TableLock(p, iDb, MASTER_ROOT, 1, SCHEMA_TABLE(iDb)); - sqlite3VdbeAddOp3(v, OP_OpenWrite, 0, MASTER_ROOT, iDb); - sqlite3VdbeChangeP4(v, -1, (int)5, P4_INT32); /* 5 column table */ - if (p.nTab == 0) { - p.nTab = 1; - } - } + /* + ** Open the sqlite_master table stored in database number iDb for + ** writing. The table is opened using cursor 0. + */ + static void sqlite3OpenMasterTable( Parse p, int iDb ) + { + Vdbe v = sqlite3GetVdbe( p ); + sqlite3TableLock( p, iDb, MASTER_ROOT, 1, SCHEMA_TABLE( iDb ) ); + sqlite3VdbeAddOp3( v, OP_OpenWrite, 0, MASTER_ROOT, iDb ); + sqlite3VdbeChangeP4( v, -1, (int)5, P4_INT32 ); /* 5 column table */ + if ( p.nTab == 0 ) + { + p.nTab = 1; + } + } - /* - ** Parameter zName points to a nul-terminated buffer containing the name - ** of a database ("main", "temp" or the name of an attached db). This - ** function returns the index of the named database in db->aDb[], or - ** -1 if the named db cannot be found. - */ - static int sqlite3FindDbName(sqlite3 db, string zName) { - int i = -1; /* Database number */ - if (zName != null) { - Db pDb; - int n = sqlite3Strlen30(zName); - for (i = (db.nDb - 1); i >= 0; i--) { - pDb = db.aDb[i]; - if ((OMIT_TEMPDB == 0 || i != 1) && n == sqlite3Strlen30(pDb.zName) && - pDb.zName.Equals(zName, StringComparison.OrdinalIgnoreCase)) { - break; - } - } - } - return i; + /* + ** Parameter zName points to a nul-terminated buffer containing the name + ** of a database ("main", "temp" or the name of an attached db). This + ** function returns the index of the named database in db->aDb[], or + ** -1 if the named db cannot be found. + */ + static int sqlite3FindDbName( sqlite3 db, string zName ) + { + int i = -1; /* Database number */ + if ( zName != null ) + { + Db pDb; + int n = sqlite3Strlen30( zName ); + for ( i = ( db.nDb - 1 ); i >= 0; i-- ) + { + pDb = db.aDb[i]; + if ( ( OMIT_TEMPDB == 0 || i != 1 ) && n == sqlite3Strlen30( pDb.zName ) && + pDb.zName.Equals( zName, StringComparison.OrdinalIgnoreCase ) ) + { + break; + } } + } + return i; + } - /* - ** The token *pName contains the name of a database (either "main" or - ** "temp" or the name of an attached db). This routine returns the - ** index of the named database in db->aDb[], or -1 if the named db - ** does not exist. - */ - static int sqlite3FindDb(sqlite3 db, Token pName) { - int i; /* Database number */ - string zName; /* Name we are searching for */ - zName = sqlite3NameFromToken(db, pName); - i = sqlite3FindDbName(db, zName); - sqlite3DbFree(db, ref zName); - return i; - } + /* + ** The token *pName contains the name of a database (either "main" or + ** "temp" or the name of an attached db). This routine returns the + ** index of the named database in db->aDb[], or -1 if the named db + ** does not exist. + */ + static int sqlite3FindDb( sqlite3 db, Token pName ) + { + int i; /* Database number */ + string zName; /* Name we are searching for */ + zName = sqlite3NameFromToken( db, pName ); + i = sqlite3FindDbName( db, zName ); + sqlite3DbFree( db, ref zName ); + return i; + } - /* The table or view or trigger name is passed to this routine via tokens - ** pName1 and pName2. If the table name was fully qualified, for example: - ** - ** CREATE TABLE xxx.yyy (...); - ** - ** Then pName1 is set to "xxx" and pName2 "yyy". On the other hand if - ** the table name is not fully qualified, i.e.: - ** - ** CREATE TABLE yyy(...); - ** - ** Then pName1 is set to "yyy" and pName2 is "". - ** - ** This routine sets the ppUnqual pointer to point at the token (pName1 or - ** pName2) that stores the unqualified table name. The index of the - ** database "xxx" is returned. - */ - static int sqlite3TwoPartName( - Parse pParse, /* Parsing and code generating context */ - Token pName1, /* The "xxx" in the name "xxx.yyy" or "xxx" */ - Token pName2, /* The "yyy" in the name "xxx.yyy" */ - ref Token pUnqual /* Write the unqualified object name here */ - ) { - int iDb; /* Database holding the object */ - sqlite3 db = pParse.db; - - if (ALWAYS(pName2 != null) && pName2.n > 0) { - if (db.init.busy != 0) { - sqlite3ErrorMsg(pParse, "corrupt database"); - pParse.nErr++; - return -1; - } - pUnqual = pName2; - iDb = sqlite3FindDb(db, pName1); - if (iDb < 0) { - sqlite3ErrorMsg(pParse, "unknown database %T", pName1); - pParse.nErr++; - return -1; - } - } else { - Debug.Assert(db.init.iDb == 0 || db.init.busy != 0); - iDb = db.init.iDb; - pUnqual = pName1; - } - return iDb; + /* The table or view or trigger name is passed to this routine via tokens + ** pName1 and pName2. If the table name was fully qualified, for example: + ** + ** CREATE TABLE xxx.yyy (...); + ** + ** Then pName1 is set to "xxx" and pName2 "yyy". On the other hand if + ** the table name is not fully qualified, i.e.: + ** + ** CREATE TABLE yyy(...); + ** + ** Then pName1 is set to "yyy" and pName2 is "". + ** + ** This routine sets the ppUnqual pointer to point at the token (pName1 or + ** pName2) that stores the unqualified table name. The index of the + ** database "xxx" is returned. + */ + static int sqlite3TwoPartName( + Parse pParse, /* Parsing and code generating context */ + Token pName1, /* The "xxx" in the name "xxx.yyy" or "xxx" */ + Token pName2, /* The "yyy" in the name "xxx.yyy" */ + ref Token pUnqual /* Write the unqualified object name here */ + ) + { + int iDb; /* Database holding the object */ + sqlite3 db = pParse.db; + + if ( ALWAYS( pName2 != null ) && pName2.n > 0 ) + { + if ( db.init.busy != 0 ) + { + sqlite3ErrorMsg( pParse, "corrupt database" ); + pParse.nErr++; + return -1; } - - /* - ** This routine is used to check if the UTF-8 string zName is a legal - ** unqualified name for a new schema object (vtable, index, view or - ** trigger). All names are legal except those that begin with the string - ** "sqlite_" (in upper, lower or mixed case). This portion of the namespace - ** is reserved for internal use. - */ - static int sqlite3CheckObjectName(Parse pParse, string zName) { - if (0 == pParse.db.init.busy && pParse.nested == 0 - && (pParse.db.flags & SQLITE_WriteSchema) == 0 - && zName.StartsWith("sqlite_", System.StringComparison.OrdinalIgnoreCase)) { - sqlite3ErrorMsg(pParse, "object name reserved for internal use: %s", zName); - return SQLITE_ERROR; - } - return SQLITE_OK; + pUnqual = pName2; + iDb = sqlite3FindDb( db, pName1 ); + if ( iDb < 0 ) + { + sqlite3ErrorMsg( pParse, "unknown database %T", pName1 ); + pParse.nErr++; + return -1; } + } + else + { + Debug.Assert( db.init.iDb == 0 || db.init.busy != 0 ); + iDb = db.init.iDb; + pUnqual = pName1; + } + return iDb; + } - /* - ** Begin constructing a new table representation in memory. This is - ** the first of several action routines that get called in response - ** to a CREATE TABLE statement. In particular, this routine is called - ** after seeing tokens "CREATE" and "TABLE" and the table name. The isTemp - ** flag is true if the table should be stored in the auxiliary database - ** file instead of in the main database file. This is normally the case - ** when the "TEMP" or "TEMPORARY" keyword occurs in between - ** CREATE and TABLE. - ** - ** The new table record is initialized and put in pParse.pNewTable. - ** As more of the CREATE TABLE statement is parsed, additional action - ** routines will be called to add more information to this record. - ** At the end of the CREATE TABLE statement, the sqlite3EndTable() routine - ** is called to complete the construction of the new table record. - */ - static void sqlite3StartTable( - Parse pParse, /* Parser context */ - Token pName1, /* First part of the name of the table or view */ - Token pName2, /* Second part of the name of the table or view */ - int isTemp, /* True if this is a TEMP table */ - int isView, /* True if this is a VIEW */ - int isVirtual, /* True if this is a VIRTUAL table */ - int noErr /* Do nothing if table already exists */ - ) { - Table pTable; - string zName = null; /* The name of the new table */ - sqlite3 db = pParse.db; - Vdbe v; - int iDb; /* Database number to create the table in */ - Token pName = new Token(); /* Unqualified name of the table to create */ - - /* The table or view name to create is passed to this routine via tokens - ** pName1 and pName2. If the table name was fully qualified, for example: - ** - ** CREATE TABLE xxx.yyy (...); - ** - ** Then pName1 is set to "xxx" and pName2 "yyy". On the other hand if - ** the table name is not fully qualified, i.e.: - ** - ** CREATE TABLE yyy(...); - ** - ** Then pName1 is set to "yyy" and pName2 is "". - ** - ** The call below sets the pName pointer to point at the token (pName1 or - ** pName2) that stores the unqualified table name. The variable iDb is - ** set to the index of the database that the table or view is to be - ** created in. - */ - iDb = sqlite3TwoPartName(pParse, pName1, pName2, ref pName); - if (iDb < 0) - return; - if (0 == OMIT_TEMPDB && isTemp != 0 && pName2.n > 0 && iDb != 1) { - /* If creating a temp table, the name may not be qualified. Unless - ** the database name is "temp" anyway. */ - - sqlite3ErrorMsg(pParse, "temporary table name must be unqualified"); - return; - } - if (OMIT_TEMPDB == 0 && isTemp != 0) - iDb = 1; - - pParse.sNameToken = pName; - zName = sqlite3NameFromToken(db, pName); - if (zName == null) - return; - if (SQLITE_OK != sqlite3CheckObjectName(pParse, zName)) { - goto begin_table_error; - } - if (db.init.iDb == 1) - isTemp = 1; + /* + ** This routine is used to check if the UTF-8 string zName is a legal + ** unqualified name for a new schema object (vtable, index, view or + ** trigger). All names are legal except those that begin with the string + ** "sqlite_" (in upper, lower or mixed case). This portion of the namespace + ** is reserved for internal use. + */ + static int sqlite3CheckObjectName( Parse pParse, string zName ) + { + if ( 0 == pParse.db.init.busy && pParse.nested == 0 + && ( pParse.db.flags & SQLITE_WriteSchema ) == 0 + && zName.StartsWith( "sqlite_", System.StringComparison.OrdinalIgnoreCase ) ) + { + sqlite3ErrorMsg( pParse, "object name reserved for internal use: %s", zName ); + return SQLITE_ERROR; + } + return SQLITE_OK; + } + + /* + ** Begin constructing a new table representation in memory. This is + ** the first of several action routines that get called in response + ** to a CREATE TABLE statement. In particular, this routine is called + ** after seeing tokens "CREATE" and "TABLE" and the table name. The isTemp + ** flag is true if the table should be stored in the auxiliary database + ** file instead of in the main database file. This is normally the case + ** when the "TEMP" or "TEMPORARY" keyword occurs in between + ** CREATE and TABLE. + ** + ** The new table record is initialized and put in pParse.pNewTable. + ** As more of the CREATE TABLE statement is parsed, additional action + ** routines will be called to add more information to this record. + ** At the end of the CREATE TABLE statement, the sqlite3EndTable() routine + ** is called to complete the construction of the new table record. + */ + static void sqlite3StartTable( + Parse pParse, /* Parser context */ + Token pName1, /* First part of the name of the table or view */ + Token pName2, /* Second part of the name of the table or view */ + int isTemp, /* True if this is a TEMP table */ + int isView, /* True if this is a VIEW */ + int isVirtual, /* True if this is a VIRTUAL table */ + int noErr /* Do nothing if table already exists */ + ) + { + Table pTable; + string zName = null; /* The name of the new table */ + sqlite3 db = pParse.db; + Vdbe v; + int iDb; /* Database number to create the table in */ + Token pName = new Token(); /* Unqualified name of the table to create */ + + /* The table or view name to create is passed to this routine via tokens + ** pName1 and pName2. If the table name was fully qualified, for example: + ** + ** CREATE TABLE xxx.yyy (...); + ** + ** Then pName1 is set to "xxx" and pName2 "yyy". On the other hand if + ** the table name is not fully qualified, i.e.: + ** + ** CREATE TABLE yyy(...); + ** + ** Then pName1 is set to "yyy" and pName2 is "". + ** + ** The call below sets the pName pointer to point at the token (pName1 or + ** pName2) that stores the unqualified table name. The variable iDb is + ** set to the index of the database that the table or view is to be + ** created in. + */ + iDb = sqlite3TwoPartName( pParse, pName1, pName2, ref pName ); + if ( iDb < 0 ) + return; + if ( 0 == OMIT_TEMPDB && isTemp != 0 && pName2.n > 0 && iDb != 1 ) + { + /* If creating a temp table, the name may not be qualified. Unless + ** the database name is "temp" anyway. */ + + sqlite3ErrorMsg( pParse, "temporary table name must be unqualified" ); + return; + } + if ( OMIT_TEMPDB == 0 && isTemp != 0 ) + iDb = 1; + + pParse.sNameToken = pName; + zName = sqlite3NameFromToken( db, pName ); + if ( zName == null ) + return; + if ( SQLITE_OK != sqlite3CheckObjectName( pParse, zName ) ) + { + goto begin_table_error; + } + if ( db.init.iDb == 1 ) + isTemp = 1; #if !SQLITE_OMIT_AUTHORIZATION Debug.Assert( (isTemp & 1)==isTemp ); { @@ -879,1001 +953,1102 @@ static void sqlite3StartTable( } #endif - /* Make sure the new table name does not collide with an existing - ** index or table name in the same database. Issue an error message if - ** it does. The exception is if the statement being parsed was passed - ** to an sqlite3_declare_vtab() call. In that case only the column names - ** and types will be used, so there is no need to test for namespace - ** collisions. + /* Make sure the new table name does not collide with an existing +** index or table name in the same database. Issue an error message if +** it does. The exception is if the statement being parsed was passed +** to an sqlite3_declare_vtab() call. In that case only the column names +** and types will be used, so there is no need to test for namespace +** collisions. +*/ + if ( !IN_DECLARE_VTAB( pParse ) ) + { + String zDb = db.aDb[iDb].zName; + if ( SQLITE_OK != sqlite3ReadSchema( pParse ) ) + { + goto begin_table_error; + } + pTable = sqlite3FindTable( db, zName, zDb ); + if ( pTable != null ) + { + if ( noErr == 0 ) + { + sqlite3ErrorMsg( pParse, "table %T already exists", pName ); + } + else + { + Debug.Assert( 0 == db.init.busy ); + sqlite3CodeVerifySchema( pParse, iDb ); + } + goto begin_table_error; + } + if ( sqlite3FindIndex( db, zName, zDb ) != null ) + { + sqlite3ErrorMsg( pParse, "there is already an index named %s", zName ); + goto begin_table_error; + } + } + + pTable = new Table();// sqlite3DbMallocZero(db, Table).Length; + //if ( pTable == null ) + //{ + // db.mallocFailed = 1; + // pParse.rc = SQLITE_NOMEM; + // pParse.nErr++; + // goto begin_table_error; + //} + pTable.zName = zName; + pTable.iPKey = -1; + pTable.pSchema = db.aDb[iDb].pSchema; + pTable.nRef = 1; + pTable.nRowEst = 1000000; + Debug.Assert( pParse.pNewTable == null ); + 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 + ** so that INSERT can find the table easily. */ - if (!IN_DECLARE_VTAB(pParse)) { - String zDb = db.aDb[iDb].zName; - if (SQLITE_OK != sqlite3ReadSchema(pParse)) { - goto begin_table_error; - } - pTable = sqlite3FindTable(db, zName, zDb); - if (pTable != null) { - if (noErr == 0) { - sqlite3ErrorMsg(pParse, "table %T already exists", pName); - } else { - Debug.Assert(0 == db.init.busy); - sqlite3CodeVerifySchema(pParse, iDb); - } - goto begin_table_error; - } - if (sqlite3FindIndex(db, zName, zDb) != null) { - sqlite3ErrorMsg(pParse, "there is already an index named %s", zName); - goto begin_table_error; - } - } - - pTable = new Table();// sqlite3DbMallocZero(db, Table).Length; - //if ( pTable == null ) - //{ - // db.mallocFailed = 1; - // pParse.rc = SQLITE_NOMEM; - // pParse.nErr++; - // goto begin_table_error; - //} - pTable.zName = zName; - pTable.iPKey = -1; - pTable.pSchema = db.aDb[iDb].pSchema; - pTable.nRef = 1; - pTable.nRowEst = 1000000; - Debug.Assert(pParse.pNewTable == null); - 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 - ** so that INSERT can find the table easily. - */ #if !SQLITE_OMIT_AUTOINCREMENT - if (pParse.nested == 0 && zName == "sqlite_sequence") { - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); - pTable.pSchema.pSeqTab = pTable; - } + if ( pParse.nested == 0 && zName == "sqlite_sequence" ) + { + Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); + pTable.pSchema.pSeqTab = pTable; + } #endif - /* Begin generating the code that will insert the table record into - ** the SQLITE_MASTER table. Note in particular that we must go ahead - ** and allocate the record number for the table entry now. Before any - ** PRIMARY KEY or UNIQUE keywords are parsed. Those keywords will cause - ** indices to be created and the table record must come before the - ** indices. Hence, the record number for the table must be allocated - ** now. - */ - if (0 == db.init.busy && (v = sqlite3GetVdbe(pParse)) != null) { - int j1; - int fileFormat; - int reg1, reg2, reg3; - sqlite3BeginWriteOperation(pParse, 0, iDb); - - if (isVirtual != 0) { - sqlite3VdbeAddOp0(v, OP_VBegin); - } - - /* If the file format and encoding in the database have not been set, - ** set them now. - */ - reg1 = pParse.regRowid = ++pParse.nMem; - reg2 = pParse.regRoot = ++pParse.nMem; - reg3 = ++pParse.nMem; - sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, reg3, BTREE_FILE_FORMAT); - sqlite3VdbeUsesBtree(v, iDb); - j1 = sqlite3VdbeAddOp1(v, OP_If, reg3); - fileFormat = (db.flags & SQLITE_LegacyFileFmt) != 0 ? - 1 : SQLITE_MAX_FILE_FORMAT; - sqlite3VdbeAddOp2(v, OP_Integer, fileFormat, reg3); - sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, reg3); - sqlite3VdbeAddOp2(v, OP_Integer, ENC(db), reg3); - sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_TEXT_ENCODING, reg3); - sqlite3VdbeJumpHere(v, j1); - - /* This just creates a place-holder record in the sqlite_master table. - ** The record created does not contain anything yet. It will be replaced - ** by the real entry in code generated at sqlite3EndTable(). - ** - ** The rowid for the new entry is left in register pParse->regRowid. - ** The root page number of the new table is left in reg pParse->regRoot. - ** The rowid and root page number values are needed by the code that - ** sqlite3EndTable will generate. - */ - if (isView != 0 || isVirtual != 0) { - sqlite3VdbeAddOp2(v, OP_Integer, 0, reg2); - } else { - sqlite3VdbeAddOp2(v, OP_CreateTable, iDb, reg2); - } - sqlite3OpenMasterTable(pParse, iDb); - sqlite3VdbeAddOp2(v, OP_NewRowid, 0, reg1); - sqlite3VdbeAddOp2(v, OP_Null, 0, reg3); - sqlite3VdbeAddOp3(v, OP_Insert, 0, reg3, reg1); - sqlite3VdbeChangeP5(v, OPFLAG_APPEND); - sqlite3VdbeAddOp0(v, OP_Close); - } - - /* Normal (non-error) return. */ - return; - - /* If an error occurs, we jump here */ - begin_table_error: - sqlite3DbFree(db, ref zName); - return; + /* Begin generating the code that will insert the table record into +** the SQLITE_MASTER table. Note in particular that we must go ahead +** and allocate the record number for the table entry now. Before any +** PRIMARY KEY or UNIQUE keywords are parsed. Those keywords will cause +** indices to be created and the table record must come before the +** indices. Hence, the record number for the table must be allocated +** now. +*/ + if ( 0 == db.init.busy && ( v = sqlite3GetVdbe( pParse ) ) != null ) + { + int j1; + int fileFormat; + int reg1, reg2, reg3; + sqlite3BeginWriteOperation( pParse, 0, iDb ); + + if ( isVirtual != 0 ) + { + sqlite3VdbeAddOp0( v, OP_VBegin ); } - /* - ** This macro is used to compare two strings in a case-insensitive manner. - ** It is slightly faster than calling sqlite3StrICmp() directly, but - ** produces larger code. - ** - ** WARNING: This macro is not compatible with the strcmp() family. It - ** returns true if the two strings are equal, otherwise false. + /* If the file format and encoding in the database have not been set, + ** set them now. */ - //#define STRICMP(x, y) (\ - //sqlite3UpperToLower[*(unsigned char )(x)]== \ - //sqlite3UpperToLower[*(unsigned char )(y)] \ - //&& sqlite3StrICmp((x)+1,(y)+1)==0 ) - - /* - ** Add a new column to the table currently being constructed. + reg1 = pParse.regRowid = ++pParse.nMem; + reg2 = pParse.regRoot = ++pParse.nMem; + reg3 = ++pParse.nMem; + sqlite3VdbeAddOp3( v, OP_ReadCookie, iDb, reg3, BTREE_FILE_FORMAT ); + sqlite3VdbeUsesBtree( v, iDb ); + j1 = sqlite3VdbeAddOp1( v, OP_If, reg3 ); + fileFormat = ( db.flags & SQLITE_LegacyFileFmt ) != 0 ? + 1 : SQLITE_MAX_FILE_FORMAT; + sqlite3VdbeAddOp2( v, OP_Integer, fileFormat, reg3 ); + sqlite3VdbeAddOp3( v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, reg3 ); + sqlite3VdbeAddOp2( v, OP_Integer, ENC( db ), reg3 ); + sqlite3VdbeAddOp3( v, OP_SetCookie, iDb, BTREE_TEXT_ENCODING, reg3 ); + sqlite3VdbeJumpHere( v, j1 ); + + /* This just creates a place-holder record in the sqlite_master table. + ** The record created does not contain anything yet. It will be replaced + ** by the real entry in code generated at sqlite3EndTable(). ** - ** The parser calls this routine once for each column declaration - ** in a CREATE TABLE statement. sqlite3StartTable() gets called - ** first to get things going. Then this routine is called for each - ** column. + ** The rowid for the new entry is left in register pParse->regRowid. + ** The root page number of the new table is left in reg pParse->regRoot. + ** The rowid and root page number values are needed by the code that + ** sqlite3EndTable will generate. */ - static void sqlite3AddColumn(Parse pParse, Token pName) { - Table p; - int i; - string z; - Column pCol; - sqlite3 db = pParse.db; - if ((p = pParse.pNewTable) == null) - return; -#if SQLITE_MAX_COLUMN || !SQLITE_MAX_COLUMN - if (p.nCol + 1 > db.aLimit[SQLITE_LIMIT_COLUMN]) { - sqlite3ErrorMsg(pParse, "too many columns on %s", p.zName); - return; - } -#endif - z = sqlite3NameFromToken(db, pName); - if (z == null) - return; - for (i = 0; i < p.nCol; i++) { - if (z.Equals(p.aCol[i].zName, StringComparison.OrdinalIgnoreCase)) {//STRICMP(z, p.aCol[i].zName) ){ - sqlite3ErrorMsg(pParse, "duplicate column name: %s", z); - sqlite3DbFree(db, ref z); - return; - } - } - if ((p.nCol & 0x7) == 0) { - //aNew = sqlite3DbRealloc(db,p.aCol,(p.nCol+8)*sizeof(p.aCol[0])); - //if( aNew==0 ){ - // sqlite3DbFree(db,ref z); - // return; - //} - Array.Resize(ref p.aCol, p.nCol + 8); - } - p.aCol[p.nCol] = new Column(); - pCol = p.aCol[p.nCol]; - //memset(pCol, 0, sizeof(p.aCol[0])); - pCol.zName = z; - - /* 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; - p.nCol++; + if ( isView != 0 || isVirtual != 0 ) + { + sqlite3VdbeAddOp2( v, OP_Integer, 0, reg2 ); } - - /* - ** This routine is called by the parser while in the middle of - ** parsing a CREATE TABLE statement. A "NOT NULL" constraint has - ** been seen on a column. This routine sets the notNull flag on - ** the column currently under construction. - */ - static void sqlite3AddNotNull(Parse pParse, int onError) { - Table p; - p = pParse.pNewTable; - if (p == null || NEVER(p.nCol < 1)) - return; - p.aCol[p.nCol - 1].notNull = (u8)onError; + else + { + sqlite3VdbeAddOp2( v, OP_CreateTable, iDb, reg2 ); } + sqlite3OpenMasterTable( pParse, iDb ); + sqlite3VdbeAddOp2( v, OP_NewRowid, 0, reg1 ); + sqlite3VdbeAddOp2( v, OP_Null, 0, reg3 ); + sqlite3VdbeAddOp3( v, OP_Insert, 0, reg3, reg1 ); + sqlite3VdbeChangeP5( v, OPFLAG_APPEND ); + sqlite3VdbeAddOp0( v, OP_Close ); + } + + /* Normal (non-error) return. */ + return; - /* - ** Scan the column type name zType (length nType) and return the - ** associated affinity type. - ** - ** This routine does a case-independent search of zType for the - ** substrings in the following table. If one of the substrings is - ** found, the corresponding affinity is returned. If zType contains - ** more than one of the substrings, entries toward the top of - ** the table take priority. For example, if zType is 'BLOBINT', - ** SQLITE_AFF_INTEGER is returned. - ** - ** Substring | Affinity - ** -------------------------------- - ** 'INT' | SQLITE_AFF_INTEGER - ** 'CHAR' | SQLITE_AFF_TEXT - ** 'CLOB' | SQLITE_AFF_TEXT - ** 'TEXT' | SQLITE_AFF_TEXT - ** 'BLOB' | SQLITE_AFF_NONE - ** 'REAL' | SQLITE_AFF_REAL - ** 'FLOA' | SQLITE_AFF_REAL - ** 'DOUB' | SQLITE_AFF_REAL - ** - ** If none of the substrings in the above table are found, - ** SQLITE_AFF_NUMERIC is returned. - */ - static char sqlite3AffinityType(string zIn) { - //u32 h = 0; - //char aff = SQLITE_AFF_NUMERIC; - zIn = zIn.ToLowerInvariant(); - if (zIn.Contains("char") || zIn.Contains("clob") || zIn.Contains("text")) - return SQLITE_AFF_TEXT; - if (zIn.Contains("blob")) - return SQLITE_AFF_NONE; - if (zIn.Contains("doub") || zIn.Contains("floa") || zIn.Contains("real")) - return SQLITE_AFF_REAL; - if (zIn.Contains("int")) - return SQLITE_AFF_INTEGER; - return SQLITE_AFF_NUMERIC; - // string zEnd = pType.z.Substring(pType.n); - - // while( zIn!=zEnd ){ - // h = (h<<8) + sqlite3UpperToLower[*zIn]; - // zIn++; - // if( h==(('c'<<24)+('h'<<16)+('a'<<8)+'r') ){ /* CHAR */ - // 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 !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 */ - // && aff==SQLITE_AFF_NUMERIC ){ - // aff = SQLITE_AFF_REAL; - // }else if( h==(('d'<<24)+('o'<<16)+('u'<<8)+'b') /* DOUB */ - // && aff==SQLITE_AFF_NUMERIC ){ - // aff = SQLITE_AFF_REAL; - //#endif - // }else if( (h&0x00FFFFFF)==(('i'<<16)+('n'<<8)+'t') ){ /* INT */ - // aff = SQLITE_AFF_INTEGER; - // break; - // } - // } - - // return aff; - } + /* If an error occurs, we jump here */ +begin_table_error: + sqlite3DbFree( db, ref zName ); + return; + } - /* - ** This routine is called by the parser while in the middle of - ** parsing a CREATE TABLE statement. The pFirst token is the first - ** token in the sequence of tokens that describe the type of the - ** column currently under construction. pLast is the last token - ** in the sequence. Use this information to construct a string - ** that contains the typename of the column and store that string - ** in zType. - */ - static void sqlite3AddColumnType(Parse pParse, Token pType) { - Table p; - Column pCol; + /* + ** This macro is used to compare two strings in a case-insensitive manner. + ** It is slightly faster than calling sqlite3StrICmp() directly, but + ** produces larger code. + ** + ** WARNING: This macro is not compatible with the strcmp() family. It + ** returns true if the two strings are equal, otherwise false. + */ + //#define STRICMP(x, y) (\ + //sqlite3UpperToLower[*(unsigned char )(x)]== \ + //sqlite3UpperToLower[*(unsigned char )(y)] \ + //&& sqlite3StrICmp((x)+1,(y)+1)==0 ) - p = pParse.pNewTable; - if (p == null || NEVER(p.nCol < 1)) - return; - pCol = p.aCol[p.nCol - 1]; - Debug.Assert(pCol.zType == null); - pCol.zType = sqlite3NameFromToken(pParse.db, pType); - pCol.affinity = sqlite3AffinityType(pCol.zType); - } + /* + ** Add a new column to the table currently being constructed. + ** + ** The parser calls this routine once for each column declaration + ** in a CREATE TABLE statement. sqlite3StartTable() gets called + ** first to get things going. Then this routine is called for each + ** column. + */ + static void sqlite3AddColumn( Parse pParse, Token pName ) + { + Table p; + int i; + string z; + Column pCol; + sqlite3 db = pParse.db; + if ( ( p = pParse.pNewTable ) == null ) + return; +#if SQLITE_MAX_COLUMN || !SQLITE_MAX_COLUMN + if ( p.nCol + 1 > db.aLimit[SQLITE_LIMIT_COLUMN] ) + { + sqlite3ErrorMsg( pParse, "too many columns on %s", p.zName ); + return; + } +#endif + z = sqlite3NameFromToken( db, pName ); + if ( z == null ) + return; + for ( i = 0; i < p.nCol; i++ ) + { + if ( z.Equals( p.aCol[i].zName, StringComparison.OrdinalIgnoreCase ) ) + {//STRICMP(z, p.aCol[i].zName) ){ + sqlite3ErrorMsg( pParse, "duplicate column name: %s", z ); + sqlite3DbFree( db, ref z ); + return; + } + } + if ( ( p.nCol & 0x7 ) == 0 ) + { + //aNew = sqlite3DbRealloc(db,p.aCol,(p.nCol+8)*sizeof(p.aCol[0])); + //if( aNew==0 ){ + // sqlite3DbFree(db,ref z); + // return; + //} + Array.Resize( ref p.aCol, p.nCol + 8 ); + } + p.aCol[p.nCol] = new Column(); + pCol = p.aCol[p.nCol]; + //memset(pCol, 0, sizeof(p.aCol[0])); + pCol.zName = z; + + /* 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; + p.nCol++; + } + /* + ** This routine is called by the parser while in the middle of + ** parsing a CREATE TABLE statement. A "NOT NULL" constraint has + ** been seen on a column. This routine sets the notNull flag on + ** the column currently under construction. + */ + static void sqlite3AddNotNull( Parse pParse, int onError ) + { + Table p; + p = pParse.pNewTable; + if ( p == null || NEVER( p.nCol < 1 ) ) + return; + p.aCol[p.nCol - 1].notNull = (u8)onError; + } - /* - ** The expression is the default value for the most recently added column - ** of the table currently under construction. - ** - ** Default value expressions must be constant. Raise an exception if this - ** is not the case. - ** - ** This routine is called by the parser while in the middle of - ** parsing a CREATE TABLE statement. - */ - static void sqlite3AddDefaultValue(Parse pParse, ExprSpan pSpan) { - Table p; - Column pCol; - sqlite3 db = pParse.db; - p = pParse.pNewTable; - if (p != null) { - pCol = (p.aCol[p.nCol - 1]); - if (sqlite3ExprIsConstantOrFunction(pSpan.pExpr) == 0) { - sqlite3ErrorMsg(pParse, "default value of column [%s] is not constant", - pCol.zName); - } else { - /* A copy of pExpr is used instead of the original, as pExpr contains - ** tokens that point to volatile memory. The 'span' of the expression - ** is required by pragma table_info. - */ - sqlite3ExprDelete(db, ref pCol.pDflt); - pCol.pDflt = sqlite3ExprDup(db, pSpan.pExpr, EXPRDUP_REDUCE); - sqlite3DbFree(db, ref pCol.zDflt); - pCol.zDflt = pSpan.zStart.Substring(0, pSpan.zStart.Length - pSpan.zEnd.Length); - //sqlite3DbStrNDup( db, pSpan.zStart, - // (int)( pSpan.zEnd.Length - pSpan.zStart.Length ) ); - } - } - sqlite3ExprDelete(db, ref pSpan.pExpr); + /* + ** Scan the column type name zType (length nType) and return the + ** associated affinity type. + ** + ** This routine does a case-independent search of zType for the + ** substrings in the following table. If one of the substrings is + ** found, the corresponding affinity is returned. If zType contains + ** more than one of the substrings, entries toward the top of + ** the table take priority. For example, if zType is 'BLOBINT', + ** SQLITE_AFF_INTEGER is returned. + ** + ** Substring | Affinity + ** -------------------------------- + ** 'INT' | SQLITE_AFF_INTEGER + ** 'CHAR' | SQLITE_AFF_TEXT + ** 'CLOB' | SQLITE_AFF_TEXT + ** 'TEXT' | SQLITE_AFF_TEXT + ** 'BLOB' | SQLITE_AFF_NONE + ** 'REAL' | SQLITE_AFF_REAL + ** 'FLOA' | SQLITE_AFF_REAL + ** 'DOUB' | SQLITE_AFF_REAL + ** + ** If none of the substrings in the above table are found, + ** SQLITE_AFF_NUMERIC is returned. + */ + static char sqlite3AffinityType( string zIn ) + { + //u32 h = 0; + //char aff = SQLITE_AFF_NUMERIC; + zIn = zIn.ToLowerInvariant(); + if ( zIn.Contains( "char" ) || zIn.Contains( "clob" ) || zIn.Contains( "text" ) ) + return SQLITE_AFF_TEXT; + if ( zIn.Contains( "blob" ) ) + return SQLITE_AFF_NONE; + if ( zIn.Contains( "doub" ) || zIn.Contains( "floa" ) || zIn.Contains( "real" ) ) + return SQLITE_AFF_REAL; + if ( zIn.Contains( "int" ) ) + return SQLITE_AFF_INTEGER; + return SQLITE_AFF_NUMERIC; + // string zEnd = pType.z.Substring(pType.n); + + // while( zIn!=zEnd ){ + // h = (h<<8) + sqlite3UpperToLower[*zIn]; + // zIn++; + // if( h==(('c'<<24)+('h'<<16)+('a'<<8)+'r') ){ /* CHAR */ + // 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 !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 */ + // && aff==SQLITE_AFF_NUMERIC ){ + // aff = SQLITE_AFF_REAL; + // }else if( h==(('d'<<24)+('o'<<16)+('u'<<8)+'b') /* DOUB */ + // && aff==SQLITE_AFF_NUMERIC ){ + // aff = SQLITE_AFF_REAL; + //#endif + // }else if( (h&0x00FFFFFF)==(('i'<<16)+('n'<<8)+'t') ){ /* INT */ + // aff = SQLITE_AFF_INTEGER; + // break; + // } + // } + + // return aff; + } + + /* + ** This routine is called by the parser while in the middle of + ** parsing a CREATE TABLE statement. The pFirst token is the first + ** token in the sequence of tokens that describe the type of the + ** column currently under construction. pLast is the last token + ** in the sequence. Use this information to construct a string + ** that contains the typename of the column and store that string + ** in zType. + */ + static void sqlite3AddColumnType( Parse pParse, Token pType ) + { + Table p; + Column pCol; + + p = pParse.pNewTable; + if ( p == null || NEVER( p.nCol < 1 ) ) + return; + pCol = p.aCol[p.nCol - 1]; + Debug.Assert( pCol.zType == null ); + pCol.zType = sqlite3NameFromToken( pParse.db, pType ); + pCol.affinity = sqlite3AffinityType( pCol.zType ); + } + + + /* + ** The expression is the default value for the most recently added column + ** of the table currently under construction. + ** + ** Default value expressions must be constant. Raise an exception if this + ** is not the case. + ** + ** This routine is called by the parser while in the middle of + ** parsing a CREATE TABLE statement. + */ + static void sqlite3AddDefaultValue( Parse pParse, ExprSpan pSpan ) + { + Table p; + Column pCol; + sqlite3 db = pParse.db; + p = pParse.pNewTable; + if ( p != null ) + { + pCol = ( p.aCol[p.nCol - 1] ); + if ( sqlite3ExprIsConstantOrFunction( pSpan.pExpr ) == 0 ) + { + sqlite3ErrorMsg( pParse, "default value of column [%s] is not constant", + pCol.zName ); } + else + { + /* A copy of pExpr is used instead of the original, as pExpr contains + ** tokens that point to volatile memory. The 'span' of the expression + ** is required by pragma table_info. + */ + sqlite3ExprDelete( db, ref pCol.pDflt ); + pCol.pDflt = sqlite3ExprDup( db, pSpan.pExpr, EXPRDUP_REDUCE ); + sqlite3DbFree( db, ref pCol.zDflt ); + pCol.zDflt = pSpan.zStart.Substring( 0, pSpan.zStart.Length - pSpan.zEnd.Length ); + //sqlite3DbStrNDup( db, pSpan.zStart, + // (int)( pSpan.zEnd.Length - pSpan.zStart.Length ) ); + } + } + sqlite3ExprDelete( db, ref pSpan.pExpr ); + } - /* - ** Designate the PRIMARY KEY for the table. pList is a list of names - ** of columns that form the primary key. If pList is NULL, then the - ** most recently added column of the table is the primary key. - ** - ** A table can have at most one primary key. If the table already has - ** a primary key (and this is the second primary key) then create an - ** error. - ** - ** If the PRIMARY KEY is on a single column whose datatype is INTEGER, - ** then we will try to use that column as the rowid. Set the Table.iPKey - ** field of the table under construction to be the index of the - ** INTEGER PRIMARY KEY column. Table.iPKey is set to -1 if there is - ** no INTEGER PRIMARY KEY. - ** - ** If the key is not an INTEGER PRIMARY KEY, then create a unique - ** index for the key. No index is created for INTEGER PRIMARY KEYs. - */ - // OVERLOADS, so I don't need to rewrite parse.c - static void sqlite3AddPrimaryKey(Parse pParse, int null_2, int onError, int autoInc, int sortOrder) { - sqlite3AddPrimaryKey(pParse, null, onError, autoInc, sortOrder); - } - static void sqlite3AddPrimaryKey( - Parse pParse, /* Parsing context */ - ExprList pList, /* List of field names to be indexed */ - int onError, /* What to do with a uniqueness conflict */ - int autoInc, /* True if the AUTOINCREMENT keyword is present */ - int sortOrder /* SQLITE_SO_ASC or SQLITE_SO_DESC */ - ) { - Table pTab = pParse.pNewTable; - string zType = null; - int iCol = -1, i; - if (pTab == null || IN_DECLARE_VTAB(pParse)) - goto primary_key_exit; - if ((pTab.tabFlags & TF_HasPrimaryKey) != 0) { - sqlite3ErrorMsg(pParse, - "table \"%s\" has more than one primary key", pTab.zName); - goto primary_key_exit; - } - pTab.tabFlags |= TF_HasPrimaryKey; - if (pList == null) { - iCol = pTab.nCol - 1; - pTab.aCol[iCol].isPrimKey = 1; - } else { - for (i = 0; i < pList.nExpr; i++) { - for (iCol = 0; iCol < pTab.nCol; iCol++) { - if (pList.a[i].zName.Equals(pTab.aCol[iCol].zName, StringComparison.OrdinalIgnoreCase)) { - break; - } - } - if (iCol < pTab.nCol) { - pTab.aCol[iCol].isPrimKey = 1; - } - } - if (pList.nExpr > 1) - iCol = -1; - } - if (iCol >= 0 && iCol < pTab.nCol) { - zType = pTab.aCol[iCol].zType; + /* + ** Designate the PRIMARY KEY for the table. pList is a list of names + ** of columns that form the primary key. If pList is NULL, then the + ** most recently added column of the table is the primary key. + ** + ** A table can have at most one primary key. If the table already has + ** a primary key (and this is the second primary key) then create an + ** error. + ** + ** If the PRIMARY KEY is on a single column whose datatype is INTEGER, + ** then we will try to use that column as the rowid. Set the Table.iPKey + ** field of the table under construction to be the index of the + ** INTEGER PRIMARY KEY column. Table.iPKey is set to -1 if there is + ** no INTEGER PRIMARY KEY. + ** + ** If the key is not an INTEGER PRIMARY KEY, then create a unique + ** index for the key. No index is created for INTEGER PRIMARY KEYs. + */ + // OVERLOADS, so I don't need to rewrite parse.c + static void sqlite3AddPrimaryKey( Parse pParse, int null_2, int onError, int autoInc, int sortOrder ) + { + sqlite3AddPrimaryKey( pParse, null, onError, autoInc, sortOrder ); + } + static void sqlite3AddPrimaryKey( + Parse pParse, /* Parsing context */ + ExprList pList, /* List of field names to be indexed */ + int onError, /* What to do with a uniqueness conflict */ + int autoInc, /* True if the AUTOINCREMENT keyword is present */ + int sortOrder /* SQLITE_SO_ASC or SQLITE_SO_DESC */ + ) + { + Table pTab = pParse.pNewTable; + string zType = null; + int iCol = -1, i; + if ( pTab == null || IN_DECLARE_VTAB( pParse ) ) + goto primary_key_exit; + if ( ( pTab.tabFlags & TF_HasPrimaryKey ) != 0 ) + { + sqlite3ErrorMsg( pParse, + "table \"%s\" has more than one primary key", pTab.zName ); + goto primary_key_exit; + } + pTab.tabFlags |= TF_HasPrimaryKey; + if ( pList == null ) + { + iCol = pTab.nCol - 1; + pTab.aCol[iCol].isPrimKey = 1; + } + else + { + for ( i = 0; i < pList.nExpr; i++ ) + { + for ( iCol = 0; iCol < pTab.nCol; iCol++ ) + { + if ( pList.a[i].zName.Equals( pTab.aCol[iCol].zName, StringComparison.OrdinalIgnoreCase ) ) + { + break; } - if (zType != null && zType.Equals("INTEGER", StringComparison.OrdinalIgnoreCase) - && sortOrder == SQLITE_SO_ASC) { - pTab.iPKey = iCol; - pTab.keyConf = (byte)onError; - Debug.Assert(autoInc == 0 || autoInc == 1); - pTab.tabFlags |= (u8)(autoInc * TF_Autoincrement); - } else if (autoInc != 0) { + } + if ( iCol < pTab.nCol ) + { + pTab.aCol[iCol].isPrimKey = 1; + } + } + if ( pList.nExpr > 1 ) + iCol = -1; + } + if ( iCol >= 0 && iCol < pTab.nCol ) + { + zType = pTab.aCol[iCol].zType; + } + if ( zType != null && zType.Equals( "INTEGER", StringComparison.OrdinalIgnoreCase ) + && sortOrder == SQLITE_SO_ASC ) + { + pTab.iPKey = iCol; + pTab.keyConf = (byte)onError; + Debug.Assert( autoInc == 0 || autoInc == 1 ); + pTab.tabFlags |= (u8)( autoInc * TF_Autoincrement ); + } + else if ( autoInc != 0 ) + { #if !SQLITE_OMIT_AUTOINCREMENT - sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an " + - "INTEGER PRIMARY KEY"); + sqlite3ErrorMsg( pParse, "AUTOINCREMENT is only allowed on an " + + "INTEGER PRIMARY KEY" ); #endif - } else { - Index p; - p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, 0, sortOrder, 0); - if (p != null) { - p.autoIndex = 2; - } - pList = null; - } - - primary_key_exit: - sqlite3ExprListDelete(pParse.db, ref pList); - return; + } + else + { + Index p; + p = sqlite3CreateIndex( pParse, 0, 0, 0, pList, onError, 0, 0, sortOrder, 0 ); + if ( p != null ) + { + p.autoIndex = 2; } + pList = null; + } - /* - ** Add a new CHECK constraint to the table currently under construction. - */ - static void sqlite3AddCheckConstraint( - Parse pParse, /* Parsing context */ - Expr pCheckExpr /* The check expression */ - ) { - sqlite3 db = pParse.db; +primary_key_exit: + sqlite3ExprListDelete( pParse.db, ref pList ); + return; + } + + /* + ** Add a new CHECK constraint to the table currently under construction. + */ + static void sqlite3AddCheckConstraint( + Parse pParse, /* Parsing context */ + Expr pCheckExpr /* The check expression */ + ) + { + sqlite3 db = pParse.db; #if !SQLITE_OMIT_CHECK - Table pTab = pParse.pNewTable; - if (pTab != null && !IN_DECLARE_VTAB(pParse)) { - pTab.pCheck = sqlite3ExprAnd(db, pTab.pCheck, pCheckExpr); - } else + Table pTab = pParse.pNewTable; + if ( pTab != null && !IN_DECLARE_VTAB( pParse ) ) + { + pTab.pCheck = sqlite3ExprAnd( db, pTab.pCheck, pCheckExpr ); + } + else #endif - { - sqlite3ExprDelete(db, ref pCheckExpr); - } - } - /* - ** Set the collation function of the most recently parsed table column - ** to the CollSeq given. + { + sqlite3ExprDelete( db, ref pCheckExpr ); + } + } + /* + ** Set the collation function of the most recently parsed table column + ** to the CollSeq given. + */ + static void sqlite3AddCollateType( Parse pParse, Token pToken ) + { + Table p; + int i; + string zColl; /* Dequoted name of collation sequence */ + sqlite3 db; + + if ( ( p = pParse.pNewTable ) == null ) + return; + i = p.nCol - 1; + db = pParse.db; + zColl = sqlite3NameFromToken( db, pToken ); + if ( zColl == null ) + return; + + if ( sqlite3LocateCollSeq( pParse, zColl ) != null ) + { + Index pIdx; + p.aCol[i].zColl = zColl; + + /* If the column is declared as " PRIMARY KEY COLLATE ", + ** then an index may have been created on this column before the + ** collation type was added. Correct this if it is the case. */ - static void sqlite3AddCollateType(Parse pParse, Token pToken) { - Table p; - int i; - string zColl; /* Dequoted name of collation sequence */ - sqlite3 db; - - if ((p = pParse.pNewTable) == null) - return; - i = p.nCol - 1; - db = pParse.db; - zColl = sqlite3NameFromToken(db, pToken); - if (zColl == null) - return; - - if (sqlite3LocateCollSeq(pParse, zColl) != null) { - Index pIdx; - p.aCol[i].zColl = zColl; - - /* If the column is declared as " PRIMARY KEY COLLATE ", - ** then an index may have been created on this column before the - ** collation type was added. Correct this if it is the case. - */ - for (pIdx = p.pIndex; pIdx != null; pIdx = pIdx.pNext) { - Debug.Assert(pIdx.nColumn == 1); - if (pIdx.aiColumn[0] == i) { - pIdx.azColl[0] = p.aCol[i].zColl; - } - } - } else { - sqlite3DbFree(db, ref zColl); - } + for ( pIdx = p.pIndex; pIdx != null; pIdx = pIdx.pNext ) + { + Debug.Assert( pIdx.nColumn == 1 ); + if ( pIdx.aiColumn[0] == i ) + { + pIdx.azColl[0] = p.aCol[i].zColl; + } } + } + else + { + sqlite3DbFree( db, ref zColl ); + } + } - /* - ** This function returns the collation sequence for database native text - ** encoding identified by the string zName, length nName. - ** - ** If the requested collation sequence is not available, or not available - ** in the database native encoding, the collation factory is invoked to - ** request it. If the collation factory does not supply such a sequence, - ** and the sequence is available in another text encoding, then that is - ** returned instead. - ** - ** If no versions of the requested collations sequence are available, or - ** another error occurs, NULL is returned and an error message written into - ** pParse. - ** - ** This routine is a wrapper around sqlite3FindCollSeq(). This routine - ** invokes the collation factory if the named collation cannot be found - ** and generates an error message. - ** - ** See also: sqlite3FindCollSeq(), sqlite3GetCollSeq() - */ - static CollSeq sqlite3LocateCollSeq(Parse pParse, string zName) { - sqlite3 db = pParse.db; - u8 enc = db.aDb[0].pSchema.enc;// ENC(db); - u8 initbusy = db.init.busy; - CollSeq pColl; - - pColl = sqlite3FindCollSeq(db, enc, zName, initbusy); - if (0 == initbusy && (pColl == null || pColl.xCmp == null)) { - pColl = sqlite3GetCollSeq(db, enc, pColl, zName); - if (pColl == null) { - sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName); - } - } - - return pColl; + /* + ** This function returns the collation sequence for database native text + ** encoding identified by the string zName, length nName. + ** + ** If the requested collation sequence is not available, or not available + ** in the database native encoding, the collation factory is invoked to + ** request it. If the collation factory does not supply such a sequence, + ** and the sequence is available in another text encoding, then that is + ** returned instead. + ** + ** If no versions of the requested collations sequence are available, or + ** another error occurs, NULL is returned and an error message written into + ** pParse. + ** + ** This routine is a wrapper around sqlite3FindCollSeq(). This routine + ** invokes the collation factory if the named collation cannot be found + ** and generates an error message. + ** + ** See also: sqlite3FindCollSeq(), sqlite3GetCollSeq() + */ + static CollSeq sqlite3LocateCollSeq( Parse pParse, string zName ) + { + sqlite3 db = pParse.db; + u8 enc = db.aDb[0].pSchema.enc;// ENC(db); + u8 initbusy = db.init.busy; + CollSeq pColl; + + pColl = sqlite3FindCollSeq( db, enc, zName, initbusy ); + if ( 0 == initbusy && ( pColl == null || pColl.xCmp == null ) ) + { + pColl = sqlite3GetCollSeq( db, enc, pColl, zName ); + if ( pColl == null ) + { + sqlite3ErrorMsg( pParse, "no such collation sequence: %s", zName ); } + } + return pColl; + } - /* - ** Generate code that will increment the schema cookie. - ** - ** The schema cookie is used to determine when the schema for the - ** database changes. After each schema change, the cookie value - ** changes. When a process first reads the schema it records the - ** cookie. Thereafter, whenever it goes to access the database, - ** it checks the cookie to make sure the schema has not changed - ** since it was last read. - ** - ** This plan is not completely bullet-proof. It is possible for - ** the schema to change multiple times and for the cookie to be - ** set back to prior value. But schema changes are infrequent - ** and the probability of hitting the same cookie value is only - ** 1 chance in 2^32. So we're safe enough. - */ - static void sqlite3ChangeCookie(Parse pParse, int iDb) { - int r1 = sqlite3GetTempReg(pParse); - sqlite3 db = pParse.db; - Vdbe v = pParse.pVdbe; - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); - sqlite3VdbeAddOp2(v, OP_Integer, db.aDb[iDb].pSchema.schema_cookie + 1, r1); - sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_SCHEMA_VERSION, r1); - sqlite3ReleaseTempReg(pParse, r1); - } - /* - ** Measure the number of characters needed to output the given - ** identifier. The number returned includes any quotes used - ** but does not include the null terminator. - ** - ** The estimate is conservative. It might be larger that what is - ** really needed. - */ - static int identLength(string z) { - int n; - for (n = 0; n < z.Length; n++) { - if (z[n] == (byte)'"') { - n++; - } - } - return n + 2; + /* + ** Generate code that will increment the schema cookie. + ** + ** The schema cookie is used to determine when the schema for the + ** database changes. After each schema change, the cookie value + ** changes. When a process first reads the schema it records the + ** cookie. Thereafter, whenever it goes to access the database, + ** it checks the cookie to make sure the schema has not changed + ** since it was last read. + ** + ** This plan is not completely bullet-proof. It is possible for + ** the schema to change multiple times and for the cookie to be + ** set back to prior value. But schema changes are infrequent + ** and the probability of hitting the same cookie value is only + ** 1 chance in 2^32. So we're safe enough. + */ + static void sqlite3ChangeCookie( Parse pParse, int iDb ) + { + int r1 = sqlite3GetTempReg( pParse ); + sqlite3 db = pParse.db; + Vdbe v = pParse.pVdbe; + Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); + sqlite3VdbeAddOp2( v, OP_Integer, db.aDb[iDb].pSchema.schema_cookie + 1, r1 ); + sqlite3VdbeAddOp3( v, OP_SetCookie, iDb, BTREE_SCHEMA_VERSION, r1 ); + sqlite3ReleaseTempReg( pParse, r1 ); + } + + /* + ** Measure the number of characters needed to output the given + ** identifier. The number returned includes any quotes used + ** but does not include the null terminator. + ** + ** The estimate is conservative. It might be larger that what is + ** really needed. + */ + static int identLength( string z ) + { + int n; + for ( n = 0; n < z.Length; n++ ) + { + if ( z[n] == (byte)'"' ) + { + n++; } + } + return n + 2; + } - /* - ** The first parameter is a pointer to an output buffer. The second - ** parameter is a pointer to an integer that contains the offset at - ** which to write into the output buffer. This function copies the - ** nul-terminated string pointed to by the third parameter, zSignedIdent, - ** to the specified offset in the buffer and updates *pIdx to refer - ** to the first byte after the last byte written before returning. - ** - ** If the string zSignedIdent consists entirely of alpha-numeric - ** characters, does not begin with a digit and is not an SQL keyword, - ** then it is copied to the output buffer exactly as it is. Otherwise, - ** it is quoted using double-quotes. - */ - static void identPut(StringBuilder z, ref int pIdx, string zSignedIdent) { - string zIdent = zSignedIdent; - int i; - int j; - bool needQuote; - i = pIdx; - for (j = 0; j < zIdent.Length; j++) { - if (!sqlite3Isalnum(zIdent[j]) && zIdent[j] != '_') - break; - } - needQuote = sqlite3Isdigit(zIdent[0]) || sqlite3KeywordCode(zIdent, j) != TK_ID; - if (!needQuote) { - needQuote = (j < zIdent.Length && zIdent[j] != 0); - } - if (needQuote) { - if (i == z.Length) - z.Append('\0'); - z[i++] = '"'; - } - for (j = 0; j < zIdent.Length; j++) { - if (i == z.Length) - z.Append('\0'); - z[i++] = zIdent[j]; - if (zIdent[j] == '"') { - if (i == z.Length) - z.Append('\0'); - z[i++] = '"'; - } - } - if (needQuote) { - if (i == z.Length) - z.Append('\0'); - z[i++] = '"'; - } - //z[i] = 0; - pIdx = i; + /* + ** The first parameter is a pointer to an output buffer. The second + ** parameter is a pointer to an integer that contains the offset at + ** which to write into the output buffer. This function copies the + ** nul-terminated string pointed to by the third parameter, zSignedIdent, + ** to the specified offset in the buffer and updates *pIdx to refer + ** to the first byte after the last byte written before returning. + ** + ** If the string zSignedIdent consists entirely of alpha-numeric + ** characters, does not begin with a digit and is not an SQL keyword, + ** then it is copied to the output buffer exactly as it is. Otherwise, + ** it is quoted using double-quotes. + */ + static void identPut( StringBuilder z, ref int pIdx, string zSignedIdent ) + { + string zIdent = zSignedIdent; + int i; + int j; + bool needQuote; + i = pIdx; + for ( j = 0; j < zIdent.Length; j++ ) + { + if ( !sqlite3Isalnum( zIdent[j] ) && zIdent[j] != '_' ) + break; + } + needQuote = sqlite3Isdigit( zIdent[0] ) || sqlite3KeywordCode( zIdent, j ) != TK_ID; + if ( !needQuote ) + { + needQuote = ( j < zIdent.Length && zIdent[j] != 0 ); + } + if ( needQuote ) + { + if ( i == z.Length ) + z.Append( '\0' ); + z[i++] = '"'; + } + for ( j = 0; j < zIdent.Length; j++ ) + { + if ( i == z.Length ) + z.Append( '\0' ); + z[i++] = zIdent[j]; + if ( zIdent[j] == '"' ) + { + if ( i == z.Length ) + z.Append( '\0' ); + z[i++] = '"'; } + } + if ( needQuote ) + { + if ( i == z.Length ) + z.Append( '\0' ); + z[i++] = '"'; + } + //z[i] = 0; + pIdx = i; + } - /* - ** Generate a CREATE TABLE statement appropriate for the given - ** table. Memory to hold the text of the statement is obtained - ** from sqliteMalloc() and must be freed by the calling function. - */ - static string createTableStmt(sqlite3 db, Table p) { - int i, k, n; - StringBuilder zStmt; - string zSep; - string zSep2; - string zEnd; - Column pCol; - n = 0; - for (i = 0; i < p.nCol; i++) {//, pCol++){ - pCol = p.aCol[i]; - n += identLength(pCol.zName) + 5; - } - n += identLength(p.zName); - if (n < 50) { - zSep = ""; - zSep2 = ","; - zEnd = ")"; - } else { - zSep = "\n "; - zSep2 = ",\n "; - zEnd = "\n)"; - } - n += 35 + 6 * p.nCol; - zStmt = new StringBuilder(n); - //zStmt = sqlite3DbMallocRaw(0, n); - //if( zStmt==0 ){ - // db.mallocFailed = 1; - // return 0; - //} - //sqlite3_snprintf(n, zStmt,"CREATE TABLE "); - zStmt.Append("CREATE TABLE "); - k = sqlite3Strlen30(zStmt); - identPut(zStmt, ref k, p.zName); - zStmt.Append('(');//zStmt[k++] = '('; - for (i = 0; i < p.nCol; i++) {//, pCol++){ - pCol = p.aCol[i]; - string[] azType = new string[] { + /* + ** Generate a CREATE TABLE statement appropriate for the given + ** table. Memory to hold the text of the statement is obtained + ** from sqliteMalloc() and must be freed by the calling function. + */ + static string createTableStmt( sqlite3 db, Table p ) + { + int i, k, n; + StringBuilder zStmt; + string zSep; + string zSep2; + string zEnd; + Column pCol; + n = 0; + for ( i = 0; i < p.nCol; i++ ) + {//, pCol++){ + pCol = p.aCol[i]; + n += identLength( pCol.zName ) + 5; + } + n += identLength( p.zName ); + if ( n < 50 ) + { + zSep = ""; + zSep2 = ","; + zEnd = ")"; + } + else + { + zSep = "\n "; + zSep2 = ",\n "; + zEnd = "\n)"; + } + n += 35 + 6 * p.nCol; + zStmt = new StringBuilder( n ); + //zStmt = sqlite3DbMallocRaw(0, n); + //if( zStmt==0 ){ + // db.mallocFailed = 1; + // return 0; + //} + //sqlite3_snprintf(n, zStmt,"CREATE TABLE "); + zStmt.Append( "CREATE TABLE " ); + k = sqlite3Strlen30( zStmt ); + identPut( zStmt, ref k, p.zName ); + zStmt.Append( '(' );//zStmt[k++] = '('; + for ( i = 0; i < p.nCol; i++ ) + {//, pCol++){ + pCol = p.aCol[i]; + string[] azType = new string[] { /* SQLITE_AFF_TEXT */ " TEXT", /* SQLITE_AFF_NONE */ "", /* SQLITE_AFF_NUMERIC */ " NUM", /* SQLITE_AFF_INTEGER */ " INT", /* SQLITE_AFF_REAL */ " REAL" }; - int len; - string zType; - - zStmt.Append(zSep);// sqlite3_snprintf(n-k, zStmt[k], zSep); - k = sqlite3Strlen30(zStmt);// k += strlen(zStmt[k]); - zSep = zSep2; - identPut(zStmt, ref k, pCol.zName); - Debug.Assert(pCol.affinity - SQLITE_AFF_TEXT >= 0); - Debug.Assert(pCol.affinity - SQLITE_AFF_TEXT < ArraySize(azType)); - testcase(pCol.affinity == SQLITE_AFF_TEXT); - testcase(pCol.affinity == SQLITE_AFF_NONE); - testcase(pCol.affinity == SQLITE_AFF_NUMERIC); - testcase(pCol.affinity == SQLITE_AFF_INTEGER); - testcase(pCol.affinity == SQLITE_AFF_REAL); - - zType = azType[pCol.affinity - SQLITE_AFF_TEXT]; - len = sqlite3Strlen30(zType); - Debug.Assert(pCol.affinity == SQLITE_AFF_NONE - || pCol.affinity == sqlite3AffinityType(zType)); - zStmt.Append(zType);// memcpy( &zStmt[k], zType, len ); - k += len; - Debug.Assert(k <= n); - } - zStmt.Append(zEnd);//sqlite3_snprintf(n-k, zStmt[k], "%s", zEnd); - return zStmt.ToString(); - } + int len; + string zType; + + zStmt.Append( zSep );// sqlite3_snprintf(n-k, zStmt[k], zSep); + k = sqlite3Strlen30( zStmt );// k += strlen(zStmt[k]); + zSep = zSep2; + identPut( zStmt, ref k, pCol.zName ); + Debug.Assert( pCol.affinity - SQLITE_AFF_TEXT >= 0 ); + Debug.Assert( pCol.affinity - SQLITE_AFF_TEXT < ArraySize( azType ) ); + testcase( pCol.affinity == SQLITE_AFF_TEXT ); + testcase( pCol.affinity == SQLITE_AFF_NONE ); + testcase( pCol.affinity == SQLITE_AFF_NUMERIC ); + testcase( pCol.affinity == SQLITE_AFF_INTEGER ); + testcase( pCol.affinity == SQLITE_AFF_REAL ); + + zType = azType[pCol.affinity - SQLITE_AFF_TEXT]; + len = sqlite3Strlen30( zType ); + Debug.Assert( pCol.affinity == SQLITE_AFF_NONE + || pCol.affinity == sqlite3AffinityType( zType ) ); + zStmt.Append( zType );// memcpy( &zStmt[k], zType, len ); + k += len; + Debug.Assert( k <= n ); + } + zStmt.Append( zEnd );//sqlite3_snprintf(n-k, zStmt[k], "%s", zEnd); + return zStmt.ToString(); + } - /* - ** This routine is called to report the final ")" that terminates - ** a CREATE TABLE statement. - ** - ** The table structure that other action routines have been building - ** is added to the internal hash tables, assuming no errors have - ** occurred. - ** - ** An entry for the table is made in the master table on disk, unless - ** this is a temporary table or db.init.busy==1. When db.init.busy==1 - ** it means we are reading the sqlite_master table because we just - ** connected to the database or because the sqlite_master table has - ** recently changed, so the entry for this table already exists in - ** the sqlite_master table. We do not want to create it again. - ** - ** If the pSelect argument is not NULL, it means that this routine - ** was called to create a table generated from a - ** "CREATE TABLE ... AS SELECT ..." statement. The column names of - ** the new table will match the result set of the SELECT. - */ - // OVERLOADS, so I don't need to rewrite parse.c - static void sqlite3EndTable(Parse pParse, Token pCons, Token pEnd, int null_4) { - sqlite3EndTable(pParse, pCons, pEnd, null); - } - static void sqlite3EndTable(Parse pParse, int null_2, int null_3, Select pSelect) { - sqlite3EndTable(pParse, null, null, pSelect); - } - - static void sqlite3EndTable( - 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; - sqlite3 db = pParse.db; - int iDb; - - if ((pEnd == null && pSelect == null) /*|| db.mallocFailed != 0 */ ) { - return; - } - p = pParse.pNewTable; - if (p == null) - return; + /* + ** This routine is called to report the final ")" that terminates + ** a CREATE TABLE statement. + ** + ** The table structure that other action routines have been building + ** is added to the internal hash tables, assuming no errors have + ** occurred. + ** + ** An entry for the table is made in the master table on disk, unless + ** this is a temporary table or db.init.busy==1. When db.init.busy==1 + ** it means we are reading the sqlite_master table because we just + ** connected to the database or because the sqlite_master table has + ** recently changed, so the entry for this table already exists in + ** the sqlite_master table. We do not want to create it again. + ** + ** If the pSelect argument is not NULL, it means that this routine + ** was called to create a table generated from a + ** "CREATE TABLE ... AS SELECT ..." statement. The column names of + ** the new table will match the result set of the SELECT. + */ + // OVERLOADS, so I don't need to rewrite parse.c + static void sqlite3EndTable( Parse pParse, Token pCons, Token pEnd, int null_4 ) + { + sqlite3EndTable( pParse, pCons, pEnd, null ); + } + static void sqlite3EndTable( Parse pParse, int null_2, int null_3, Select pSelect ) + { + sqlite3EndTable( pParse, null, null, pSelect ); + } + + static void sqlite3EndTable( + 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; + sqlite3 db = pParse.db; + int iDb; + + if ( ( pEnd == null && pSelect == null ) /*|| db.mallocFailed != 0 */ ) + { + return; + } + p = pParse.pNewTable; + if ( p == null ) + return; - Debug.Assert(0 == db.init.busy || pSelect == null); + Debug.Assert( 0 == db.init.busy || pSelect == null ); - iDb = sqlite3SchemaToIndex(db, p.pSchema); + iDb = sqlite3SchemaToIndex( db, p.pSchema ); #if !SQLITE_OMIT_CHECK - /* Resolve names in all CHECK constraint expressions. - */ - if (p.pCheck != null) { - SrcList sSrc; /* Fake SrcList for pParse.pNewTable */ - NameContext sNC; /* Name context for pParse.pNewTable */ - - sNC = new NameContext();// memset(sNC, 0, sizeof(sNC)); - sSrc = new SrcList();// memset(sSrc, 0, sizeof(sSrc)); - sSrc.nSrc = 1; - sSrc.a = new SrcList_item[1]; - sSrc.a[0] = new SrcList_item(); - sSrc.a[0].zName = p.zName; - sSrc.a[0].pTab = p; - sSrc.a[0].iCursor = -1; - sNC.pParse = pParse; - sNC.pSrcList = sSrc; - sNC.isCheck = 1; - if (sqlite3ResolveExprNames(sNC, ref p.pCheck) != 0) { - return; - } - } + /* Resolve names in all CHECK constraint expressions. +*/ + if ( p.pCheck != null ) + { + SrcList sSrc; /* Fake SrcList for pParse.pNewTable */ + NameContext sNC; /* Name context for pParse.pNewTable */ + + sNC = new NameContext();// memset(sNC, 0, sizeof(sNC)); + sSrc = new SrcList();// memset(sSrc, 0, sizeof(sSrc)); + sSrc.nSrc = 1; + sSrc.a = new SrcList_item[1]; + sSrc.a[0] = new SrcList_item(); + sSrc.a[0].zName = p.zName; + sSrc.a[0].pTab = p; + sSrc.a[0].iCursor = -1; + sNC.pParse = pParse; + sNC.pSrcList = sSrc; + sNC.isCheck = 1; + if ( sqlite3ResolveExprNames( sNC, ref p.pCheck ) != 0 ) + { + return; + } + } #endif // * !SQLITE_OMIT_CHECK) */ - /* 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.) + /* 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.) +*/ + if ( db.init.busy != 0 ) + { + p.tnum = db.init.newTnum; + } + + /* If not initializing, then create a record for the new table + ** in the SQLITE_MASTER table of the database. + ** + ** If this is a TEMPORARY table, write the entry into the auxiliary + ** file instead of into the main database file. */ - if (db.init.busy != 0) { - p.tnum = db.init.newTnum; - } + if ( 0 == db.init.busy ) + { + int n; + Vdbe v; + String zType = ""; /* "view" or "table" */ + String zType2 = ""; /* "VIEW" or "TABLE" */ + String zStmt = ""; /* Text of the CREATE TABLE or CREATE VIEW statement */ - /* If not initializing, then create a record for the new table - ** in the SQLITE_MASTER table of the database. - ** - ** If this is a TEMPORARY table, write the entry into the auxiliary - ** file instead of into the main database file. - */ - if (0 == db.init.busy) { - int n; - Vdbe v; - String zType = ""; /* "view" or "table" */ - String zType2 = ""; /* "VIEW" or "TABLE" */ - String zStmt = ""; /* Text of the CREATE TABLE or CREATE VIEW statement */ - - v = sqlite3GetVdbe(pParse); - if (NEVER(v == null)) - return; - - sqlite3VdbeAddOp1(v, OP_Close, 0); - - /* - ** Initialize zType for the new view or table. - */ - if (p.pSelect == null) { - /* A regular table */ - zType = "table"; - zType2 = "TABLE"; -#if !SQLITE_OMIT_VIEW - } else { - /* A view */ - zType = "view"; - zType2 = "VIEW"; -#endif - } - - /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT - ** statement to populate the new table. The root-page number for the - ** new table is in register pParse->regRoot. - ** - ** Once the SELECT has been coded by sqlite3Select(), it is in a - ** suitable state to query for the column names and types to be used - ** by the new table. - ** - ** A shared-cache write-lock is not required to write to the new table, - ** as a schema-lock must have already been obtained to create it. Since - ** a schema-lock excludes all other database users, the write-lock would - ** be redundant. - */ - if (pSelect != null) { - SelectDest dest = new SelectDest(); - Table pSelTab; - - Debug.Assert(pParse.nTab == 1); - sqlite3VdbeAddOp3(v, OP_OpenWrite, 1, pParse.regRoot, iDb); - sqlite3VdbeChangeP5(v, 1); - pParse.nTab = 2; - sqlite3SelectDestInit(dest, SRT_Table, 1); - sqlite3Select(pParse, pSelect, ref dest); - sqlite3VdbeAddOp1(v, OP_Close, 1); - if (pParse.nErr == 0) { - pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect); - if (pSelTab == null) - return; - Debug.Assert(p.aCol == null); - p.nCol = pSelTab.nCol; - p.aCol = pSelTab.aCol; - pSelTab.nCol = 0; - pSelTab.aCol = null; - sqlite3DeleteTable(db, ref pSelTab); - } - } - - /* Compute the complete text of the CREATE statement */ - if (pSelect != null) { - zStmt = createTableStmt(db, p); - } else { - n = (int)(pParse.sNameToken.z.Length - pEnd.z.Length) + 1; - zStmt = sqlite3MPrintf(db, - "CREATE %s %.*s", zType2, n, pParse.sNameToken.z - ); - } - - /* A slot for the record has already been allocated in the - ** SQLITE_MASTER table. We just need to update that slot with all - ** the information we've collected. - */ - sqlite3NestedParse(pParse, - "UPDATE %Q.%s " + - "SET type='%s', name=%Q, tbl_name=%Q, rootpage=#%d, sql=%Q " + - "WHERE rowid=#%d", - db.aDb[iDb].zName, SCHEMA_TABLE(iDb), - zType, - p.zName, - p.zName, - pParse.regRoot, - zStmt, - pParse.regRowid - ); - sqlite3DbFree(db, ref zStmt); - sqlite3ChangeCookie(pParse, iDb); + v = sqlite3GetVdbe( pParse ); + if ( NEVER( v == null ) ) + return; -#if !SQLITE_OMIT_AUTOINCREMENT - /* Check to see if we need to create an sqlite_sequence table for - ** keeping track of autoincrement keys. + sqlite3VdbeAddOp1( v, OP_Close, 0 ); + + /* + ** Initialize zType for the new view or table. */ - if ((p.tabFlags & TF_Autoincrement) != 0) { - Db pDb = db.aDb[iDb]; - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); - if (pDb.pSchema.pSeqTab == null) { - sqlite3NestedParse(pParse, - "CREATE TABLE %Q.sqlite_sequence(name,seq)", - pDb.zName - ); - } - } + if ( p.pSelect == null ) + { + /* A regular table */ + zType = "table"; + zType2 = "TABLE"; +#if !SQLITE_OMIT_VIEW + } + else + { + /* A view */ + zType = "view"; + zType2 = "VIEW"; #endif + } - /* Reparse everything to update our internal data structures */ - sqlite3VdbeAddParseSchemaOp(v, iDb, - sqlite3MPrintf(db, "tbl_name='%q'", p.zName)); - } + /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT + ** statement to populate the new table. The root-page number for the + ** new table is in register pParse->regRoot. + ** + ** Once the SELECT has been coded by sqlite3Select(), it is in a + ** suitable state to query for the column names and types to be used + ** by the new table. + ** + ** A shared-cache write-lock is not required to write to the new table, + ** as a schema-lock must have already been obtained to create it. Since + ** a schema-lock excludes all other database users, the write-lock would + ** be redundant. + */ + if ( pSelect != null ) + { + SelectDest dest = new SelectDest(); + Table pSelTab; + + Debug.Assert( pParse.nTab == 1 ); + sqlite3VdbeAddOp3( v, OP_OpenWrite, 1, pParse.regRoot, iDb ); + sqlite3VdbeChangeP5( v, 1 ); + pParse.nTab = 2; + sqlite3SelectDestInit( dest, SRT_Table, 1 ); + sqlite3Select( pParse, pSelect, ref dest ); + sqlite3VdbeAddOp1( v, OP_Close, 1 ); + if ( pParse.nErr == 0 ) + { + pSelTab = sqlite3ResultSetOfSelect( pParse, pSelect ); + if ( pSelTab == null ) + return; + Debug.Assert( p.aCol == null ); + p.nCol = pSelTab.nCol; + p.aCol = pSelTab.aCol; + pSelTab.nCol = 0; + pSelTab.aCol = null; + sqlite3DeleteTable( db, ref pSelTab ); + } + } + /* Compute the complete text of the CREATE statement */ + if ( pSelect != null ) + { + zStmt = createTableStmt( db, p ); + } + else + { + n = (int)( pParse.sNameToken.z.Length - pEnd.z.Length ) + 1; + zStmt = sqlite3MPrintf( db, + "CREATE %s %.*s", zType2, n, pParse.sNameToken.z + ); + } - /* Add the table to the in-memory representation of the database. - */ - if (db.init.busy != 0) { - Table pOld; - Schema pSchema = p.pSchema; - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); - pOld = sqlite3HashInsert(ref pSchema.tblHash, p.zName, - sqlite3Strlen30(p.zName), p); - if (pOld != null) { - Debug.Assert(p == pOld); /* Malloc must have failed inside HashInsert() */ - // db.mallocFailed = 1; - return; - } - pParse.pNewTable = null; - db.nTable++; - db.flags |= SQLITE_InternChanges; + /* A slot for the record has already been allocated in the + ** SQLITE_MASTER table. We just need to update that slot with all + ** the information we've collected. + */ + sqlite3NestedParse( pParse, + "UPDATE %Q.%s " + + "SET type='%s', name=%Q, tbl_name=%Q, rootpage=#%d, sql=%Q " + + "WHERE rowid=#%d", + db.aDb[iDb].zName, SCHEMA_TABLE( iDb ), + zType, + p.zName, + p.zName, + pParse.regRoot, + zStmt, + pParse.regRowid + ); + sqlite3DbFree( db, ref zStmt ); + sqlite3ChangeCookie( pParse, iDb ); -#if !SQLITE_OMIT_ALTERTABLE - if (p.pSelect == null) { - string zName = pParse.sNameToken.z; - int nName; - Debug.Assert(pSelect == null && pCons != null && pEnd != null); - if (pCons.z == null) { - pCons = pEnd; - } - nName = zName.Length - pCons.z.Length; - p.addColOffset = 13 + nName; // sqlite3Utf8CharLen(zName, nName); - } -#endif - } +#if !SQLITE_OMIT_AUTOINCREMENT + /* Check to see if we need to create an sqlite_sequence table for +** keeping track of autoincrement keys. +*/ + if ( ( p.tabFlags & TF_Autoincrement ) != 0 ) + { + Db pDb = db.aDb[iDb]; + Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); + if ( pDb.pSchema.pSeqTab == null ) + { + sqlite3NestedParse( pParse, + "CREATE TABLE %Q.sqlite_sequence(name,seq)", + pDb.zName + ); + } } +#endif -#if !SQLITE_OMIT_VIEW - /* - ** The parser calls this routine in order to create a new VIEW - */ - static void sqlite3CreateView( - Parse pParse, /* The parsing context */ - Token pBegin, /* The CREATE token that begins the statement */ - Token pName1, /* The token that holds the name of the view */ - Token pName2, /* The token that holds the name of the view */ - Select pSelect, /* A SELECT statement that will become the new view */ - int isTemp, /* TRUE for a TEMPORARY view */ - int noErr /* Suppress error messages if VIEW already exists */ - ) { - Table p; - int n; - string z;//string z; - Token sEnd; - DbFixer sFix = new DbFixer(); - Token pName = null; - int iDb; - sqlite3 db = pParse.db; - - if (pParse.nVar > 0) { - sqlite3ErrorMsg(pParse, "parameters are not allowed in views"); - sqlite3SelectDelete(db, ref pSelect); - return; - } - sqlite3StartTable(pParse, pName1, pName2, isTemp, 1, 0, noErr); - p = pParse.pNewTable; - if (p == null || pParse.nErr != 0) { - sqlite3SelectDelete(db, ref pSelect); - return; - } - sqlite3TwoPartName(pParse, pName1, pName2, ref pName); - iDb = sqlite3SchemaToIndex(db, p.pSchema); - if (sqlite3FixInit(sFix, pParse, iDb, "view", pName) != 0 - && sqlite3FixSelect(sFix, pSelect) != 0 - ) { - sqlite3SelectDelete(db, ref pSelect); - return; - } + /* Reparse everything to update our internal data structures */ + sqlite3VdbeAddParseSchemaOp( v, iDb, + sqlite3MPrintf( db, "tbl_name='%q'", p.zName ) ); + } - /* Make a copy of the entire SELECT statement that defines the view. - ** This will force all the Expr.token.z values to be dynamically - ** allocated rather than point to the input string - which means that - ** they will persist after the current sqlite3_exec() call returns. - */ - p.pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE); - sqlite3SelectDelete(db, ref pSelect); - //if ( db.mallocFailed != 0 ) - //{ - // return; - //} - if (0 == db.init.busy) { - sqlite3ViewGetColumnNames(pParse, p); - } - /* Locate the end of the CREATE VIEW statement. Make sEnd point to - ** the end. - */ - sEnd = pParse.sLastToken; - if (ALWAYS(sEnd.z[0] != 0) && sEnd.z[0] != ';') { - sEnd.z = sEnd.z.Substring(sEnd.n); - } - sEnd.n = 0; - n = (int)(pBegin.z.Length - sEnd.z.Length);//sEnd.z - pBegin.z; - z = pBegin.z; - while (ALWAYS(n > 0) && sqlite3Isspace(z[n - 1])) { - n--; - } - sEnd.z = z.Substring(n - 1); - sEnd.n = 1; + /* Add the table to the in-memory representation of the database. + */ + if ( db.init.busy != 0 ) + { + Table pOld; + Schema pSchema = p.pSchema; + Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); + pOld = sqlite3HashInsert( ref pSchema.tblHash, p.zName, + sqlite3Strlen30( p.zName ), p ); + if ( pOld != null ) + { + Debug.Assert( p == pOld ); /* Malloc must have failed inside HashInsert() */ + // db.mallocFailed = 1; + return; + } + pParse.pNewTable = null; + db.nTable++; + db.flags |= SQLITE_InternChanges; - /* Use sqlite3EndTable() to add the view to the SQLITE_MASTER table */ - sqlite3EndTable(pParse, null, sEnd, null); - return; +#if !SQLITE_OMIT_ALTERTABLE + if ( p.pSelect == null ) + { + string zName = pParse.sNameToken.z; + int nName; + Debug.Assert( pSelect == null && pCons != null && pEnd != null ); + if ( pCons.z == null ) + { + pCons = pEnd; + } + nName = zName.Length - pCons.z.Length; + p.addColOffset = 13 + nName; // sqlite3Utf8CharLen(zName, nName); } +#endif + } + } + +#if !SQLITE_OMIT_VIEW + /* +** The parser calls this routine in order to create a new VIEW +*/ + static void sqlite3CreateView( + Parse pParse, /* The parsing context */ + Token pBegin, /* The CREATE token that begins the statement */ + Token pName1, /* The token that holds the name of the view */ + Token pName2, /* The token that holds the name of the view */ + Select pSelect, /* A SELECT statement that will become the new view */ + int isTemp, /* TRUE for a TEMPORARY view */ + int noErr /* Suppress error messages if VIEW already exists */ + ) + { + Table p; + int n; + string z;//string z; + Token sEnd; + DbFixer sFix = new DbFixer(); + Token pName = null; + int iDb; + sqlite3 db = pParse.db; + + if ( pParse.nVar > 0 ) + { + sqlite3ErrorMsg( pParse, "parameters are not allowed in views" ); + sqlite3SelectDelete( db, ref pSelect ); + return; + } + sqlite3StartTable( pParse, pName1, pName2, isTemp, 1, 0, noErr ); + p = pParse.pNewTable; + if ( p == null || pParse.nErr != 0 ) + { + sqlite3SelectDelete( db, ref pSelect ); + return; + } + sqlite3TwoPartName( pParse, pName1, pName2, ref pName ); + iDb = sqlite3SchemaToIndex( db, p.pSchema ); + if ( sqlite3FixInit( sFix, pParse, iDb, "view", pName ) != 0 + && sqlite3FixSelect( sFix, pSelect ) != 0 + ) + { + sqlite3SelectDelete( db, ref pSelect ); + return; + } + + /* Make a copy of the entire SELECT statement that defines the view. + ** This will force all the Expr.token.z values to be dynamically + ** allocated rather than point to the input string - which means that + ** they will persist after the current sqlite3_exec() call returns. + */ + p.pSelect = sqlite3SelectDup( db, pSelect, EXPRDUP_REDUCE ); + sqlite3SelectDelete( db, ref pSelect ); + //if ( db.mallocFailed != 0 ) + //{ + // return; + //} + if ( 0 == db.init.busy ) + { + sqlite3ViewGetColumnNames( pParse, p ); + } + + /* Locate the end of the CREATE VIEW statement. Make sEnd point to + ** the end. + */ + sEnd = pParse.sLastToken; + if ( ALWAYS( sEnd.z[0] != 0 ) && sEnd.z[0] != ';' ) + { + sEnd.z = sEnd.z.Substring( sEnd.n ); + } + sEnd.n = 0; + n = (int)( pBegin.z.Length - sEnd.z.Length );//sEnd.z - pBegin.z; + z = pBegin.z; + while ( ALWAYS( n > 0 ) && sqlite3Isspace( z[n - 1] ) ) + { + n--; + } + sEnd.z = z.Substring( n - 1 ); + sEnd.n = 1; + + /* Use sqlite3EndTable() to add the view to the SQLITE_MASTER table */ + sqlite3EndTable( pParse, null, sEnd, null ); + return; + } #else static void sqlite3CreateView( Parse pParse, /* The parsing context */ @@ -1889,125 +2064,137 @@ static void sqlite3CreateView( #endif // * SQLITE_OMIT_VIEW */ #if !SQLITE_OMIT_VIEW || !SQLITE_OMIT_VIRTUALTABLE - /* - ** The Table structure pTable is really a VIEW. Fill in the names of - ** the columns of the view in the pTable structure. Return the number - ** of errors. If an error is seen leave an error message in pParse.zErrMsg. - */ - static int sqlite3ViewGetColumnNames(Parse pParse, Table pTable) { - Table pSelTab; /* A fake table from which we get the result set */ - Select pSel; /* Copy of the SELECT that implements the view */ - int nErr = 0; /* Number of errors encountered */ - int n; /* Temporarily holds the number of cursors assigned */ - sqlite3 db = pParse.db; /* Database connection for malloc errors */ - dxAuth xAuth; //)(void*,int,const char*,const char*,const char*,const char); + /* +** The Table structure pTable is really a VIEW. Fill in the names of +** the columns of the view in the pTable structure. Return the number +** of errors. If an error is seen leave an error message in pParse.zErrMsg. +*/ + static int sqlite3ViewGetColumnNames( Parse pParse, Table pTable ) + { + Table pSelTab; /* A fake table from which we get the result set */ + Select pSel; /* Copy of the SELECT that implements the view */ + int nErr = 0; /* Number of errors encountered */ + int n; /* Temporarily holds the number of cursors assigned */ + sqlite3 db = pParse.db; /* Database connection for malloc errors */ + dxAuth xAuth; //)(void*,int,const char*,const char*,const char*,const char); - Debug.Assert(pTable != null); + Debug.Assert( pTable != null ); #if !SQLITE_OMIT_VIRTUALTABLE - if (sqlite3VtabCallConnect(pParse, pTable) != 0) { - return SQLITE_ERROR; - } +if ( sqlite3VtabCallConnect( pParse, pTable )!=0 ) +{ +return SQLITE_ERROR; +} #endif - if (IsVirtual(pTable)) - return 0; + if ( IsVirtual( pTable ) ) + return 0; #if !SQLITE_OMIT_VIEW - /* A positive nCol means the columns names for this view are - ** already known. + /* A positive nCol means the columns names for this view are +** already known. +*/ + if ( pTable.nCol > 0 ) + return 0; + + /* A negative nCol is a special marker meaning that we are currently + ** trying to compute the column names. If we enter this routine with + ** a negative nCol, it means two or more views form a loop, like this: + ** + ** CREATE VIEW one AS SELECT * FROM two; + ** CREATE VIEW two AS SELECT * FROM one; + ** + ** Actually, the error above is now caught prior to reaching this point. + ** But the following test is still important as it does come up + ** in the following: + ** + ** CREATE TABLE main.ex1(a); + ** CREATE TEMP VIEW ex1 AS SELECT a FROM ex1; + ** SELECT * FROM temp.ex1; */ - if (pTable.nCol > 0) - return 0; - - /* A negative nCol is a special marker meaning that we are currently - ** trying to compute the column names. If we enter this routine with - ** a negative nCol, it means two or more views form a loop, like this: - ** - ** CREATE VIEW one AS SELECT * FROM two; - ** CREATE VIEW two AS SELECT * FROM one; - ** - ** Actually, the error above is now caught prior to reaching this point. - ** But the following test is still important as it does come up - ** in the following: - ** - ** CREATE TABLE main.ex1(a); - ** CREATE TEMP VIEW ex1 AS SELECT a FROM ex1; - ** SELECT * FROM temp.ex1; - */ - if (pTable.nCol < 0) { - sqlite3ErrorMsg(pParse, "view %s is circularly defined", pTable.zName); - return 1; - } - Debug.Assert(pTable.nCol >= 0); - - /* If we get this far, it means we need to compute the table names. - ** Note that the call to sqlite3ResultSetOfSelect() will expand any - ** "*" elements in the results set of the view and will assign cursors - ** to the elements of the FROM clause. But we do not want these changes - ** to be permanent. So the computation is done on a copy of the SELECT - ** statement that defines the view. - */ - Debug.Assert(pTable.pSelect != null); - pSel = sqlite3SelectDup(db, pTable.pSelect, 0); - if (pSel != null) { - u8 enableLookaside = db.lookaside.bEnabled; - n = pParse.nTab; - sqlite3SrcListAssignCursors(pParse, pSel.pSrc); - pTable.nCol = -1; - db.lookaside.bEnabled = 0; + if ( pTable.nCol < 0 ) + { + sqlite3ErrorMsg( pParse, "view %s is circularly defined", pTable.zName ); + return 1; + } + Debug.Assert( pTable.nCol >= 0 ); + + /* If we get this far, it means we need to compute the table names. + ** Note that the call to sqlite3ResultSetOfSelect() will expand any + ** "*" elements in the results set of the view and will assign cursors + ** to the elements of the FROM clause. But we do not want these changes + ** to be permanent. So the computation is done on a copy of the SELECT + ** statement that defines the view. + */ + Debug.Assert( pTable.pSelect != null ); + pSel = sqlite3SelectDup( db, pTable.pSelect, 0 ); + if ( pSel != null ) + { + u8 enableLookaside = db.lookaside.bEnabled; + n = pParse.nTab; + sqlite3SrcListAssignCursors( pParse, pSel.pSrc ); + pTable.nCol = -1; + db.lookaside.bEnabled = 0; #if !SQLITE_OMIT_AUTHORIZATION xAuth = db.xAuth; db.xAuth = 0; pSelTab = sqlite3ResultSetOfSelect(pParse, pSel); db.xAuth = xAuth; #else - pSelTab = sqlite3ResultSetOfSelect(pParse, pSel); + pSelTab = sqlite3ResultSetOfSelect( pParse, pSel ); #endif - db.lookaside.bEnabled = enableLookaside; - pParse.nTab = n; - if (pSelTab != null) { - Debug.Assert(pTable.aCol == null); - pTable.nCol = pSelTab.nCol; - pTable.aCol = pSelTab.aCol; - pSelTab.nCol = 0; - pSelTab.aCol = null; - sqlite3DeleteTable(db, ref pSelTab); - Debug.Assert(sqlite3SchemaMutexHeld(db, 0, pTable.pSchema)); - pTable.pSchema.flags |= DB_UnresetViews; - } else { - pTable.nCol = 0; - nErr++; - } - sqlite3SelectDelete(db, ref pSel); - } else { - nErr++; - } -#endif // * SQLITE_OMIT_VIEW */ - return nErr; + db.lookaside.bEnabled = enableLookaside; + pParse.nTab = n; + if ( pSelTab != null ) + { + Debug.Assert( pTable.aCol == null ); + pTable.nCol = pSelTab.nCol; + pTable.aCol = pSelTab.aCol; + pSelTab.nCol = 0; + pSelTab.aCol = null; + sqlite3DeleteTable( db, ref pSelTab ); + Debug.Assert( sqlite3SchemaMutexHeld( db, 0, pTable.pSchema ) ); + pTable.pSchema.flags |= DB_UnresetViews; + } + else + { + pTable.nCol = 0; + nErr++; } + sqlite3SelectDelete( db, ref pSel ); + } + else + { + nErr++; + } +#endif // * SQLITE_OMIT_VIEW */ + return nErr; + } #endif // * !SQLITE_OMIT_VIEW) || !SQLITE_OMIT_VIRTUALTABLE) */ #if !SQLITE_OMIT_VIEW - /* - ** Clear the column names from every VIEW in database idx. - */ - static void sqliteViewResetAll(sqlite3 db, int idx) { - HashElem i; - Debug.Assert(sqlite3SchemaMutexHeld(db, idx, null)); - if (!DbHasProperty(db, idx, DB_UnresetViews)) - return; - //for(i=sqliteHashFirst(&db.aDb[idx].pSchema.tblHash); i;i=sqliteHashNext(i)){ - for (i = db.aDb[idx].pSchema.tblHash.first; i != null; i = i.next) { - Table pTab = (Table)i.data;// sqliteHashData( i ); - if (pTab.pSelect != null) { - sqliteDeleteColumnNames(db, pTab); - pTab.aCol = null; - pTab.nCol = 0; - - } - } - DbClearProperty(db, idx, DB_UnresetViews); + /* +** Clear the column names from every VIEW in database idx. +*/ + static void sqliteViewResetAll( sqlite3 db, int idx ) + { + HashElem i; + Debug.Assert( sqlite3SchemaMutexHeld( db, idx, null ) ); + if ( !DbHasProperty( db, idx, DB_UnresetViews ) ) + return; + //for(i=sqliteHashFirst(&db.aDb[idx].pSchema.tblHash); i;i=sqliteHashNext(i)){ + for ( i = db.aDb[idx].pSchema.tblHash.first; i != null; i = i.next ) + { + Table pTab = (Table)i.data;// sqliteHashData( i ); + if ( pTab.pSelect != null ) + { + sqliteDeleteColumnNames( db, pTab ); + pTab.aCol = null; + pTab.nCol = 0; + } + } + DbClearProperty( db, idx, DB_UnresetViews ); + } #else //# define sqliteViewResetAll(A,B) static void sqliteViewResetAll( sqlite3 A, int B ) @@ -2015,87 +2202,92 @@ static void sqliteViewResetAll( sqlite3 A, int B ) } #endif // * SQLITE_OMIT_VIEW */ - /* - ** This function is called by the VDBE to adjust the internal schema - ** used by SQLite when the btree layer moves a table root page. The - ** root-page of a table or index in database iDb has changed from iFrom - ** to iTo. - ** - ** Ticket #1728: The symbol table might still contain information - ** on tables and/or indices that are the process of being deleted. - ** If you are unlucky, one of those deleted indices or tables might - ** have the same rootpage number as the real table or index that is - ** being moved. So we cannot stop searching after the first match - ** because the first match might be for one of the deleted indices - ** or tables and not the table/index that is actually being moved. - ** We must continue looping until all tables and indices with - ** rootpage==iFrom have been converted to have a rootpage of iTo - ** in order to be certain that we got the right one. - */ + /* +** This function is called by the VDBE to adjust the internal schema +** used by SQLite when the btree layer moves a table root page. The +** root-page of a table or index in database iDb has changed from iFrom +** to iTo. +** +** Ticket #1728: The symbol table might still contain information +** on tables and/or indices that are the process of being deleted. +** If you are unlucky, one of those deleted indices or tables might +** have the same rootpage number as the real table or index that is +** being moved. So we cannot stop searching after the first match +** because the first match might be for one of the deleted indices +** or tables and not the table/index that is actually being moved. +** We must continue looping until all tables and indices with +** rootpage==iFrom have been converted to have a rootpage of iTo +** in order to be certain that we got the right one. +*/ #if !SQLITE_OMIT_AUTOVACUUM - static void sqlite3RootPageMoved(sqlite3 db, int iDb, int iFrom, int iTo) { - HashElem pElem; - Hash pHash; - Db pDb; - - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); - pDb = db.aDb[iDb]; - - pHash = pDb.pSchema.tblHash; - for (pElem = pHash.first; pElem != null; pElem = pElem.next)// ( pElem = sqliteHashFirst( pHash ) ; pElem ; pElem = sqliteHashNext( pElem ) ) - { - Table pTab = (Table)pElem.data;// sqliteHashData( pElem ); - if (pTab.tnum == iFrom) { - pTab.tnum = iTo; - } - } - pHash = pDb.pSchema.idxHash; - for (pElem = pHash.first; pElem != null; pElem = pElem.next)// ( pElem = sqliteHashFirst( pHash ) ; pElem ; pElem = sqliteHashNext( pElem ) ) - { - Index pIdx = (Index)pElem.data;// sqliteHashData( pElem ); - if (pIdx.tnum == iFrom) { - pIdx.tnum = iTo; - } - } + static void sqlite3RootPageMoved( sqlite3 db, int iDb, int iFrom, int iTo ) + { + HashElem pElem; + Hash pHash; + Db pDb; + + Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); + pDb = db.aDb[iDb]; + + pHash = pDb.pSchema.tblHash; + for ( pElem = pHash.first; pElem != null; pElem = pElem.next )// ( pElem = sqliteHashFirst( pHash ) ; pElem ; pElem = sqliteHashNext( pElem ) ) + { + Table pTab = (Table)pElem.data;// sqliteHashData( pElem ); + if ( pTab.tnum == iFrom ) + { + pTab.tnum = iTo; + } + } + pHash = pDb.pSchema.idxHash; + for ( pElem = pHash.first; pElem != null; pElem = pElem.next )// ( pElem = sqliteHashFirst( pHash ) ; pElem ; pElem = sqliteHashNext( pElem ) ) + { + Index pIdx = (Index)pElem.data;// sqliteHashData( pElem ); + if ( pIdx.tnum == iFrom ) + { + pIdx.tnum = iTo; } + } + } #endif - /* - ** Write code to erase the table with root-page iTable from database iDb. - ** Also write code to modify the sqlite_master table and internal schema - ** if a root-page of another table is moved by the btree-layer whilst - ** erasing iTable (this can happen with an auto-vacuum database). - */ - static void destroyRootPage(Parse pParse, int iTable, int iDb) { - Vdbe v = sqlite3GetVdbe(pParse); - int r1 = sqlite3GetTempReg(pParse); - sqlite3VdbeAddOp3(v, OP_Destroy, iTable, r1, iDb); - sqlite3MayAbort(pParse); + /* +** Write code to erase the table with root-page iTable from database iDb. +** Also write code to modify the sqlite_master table and internal schema +** if a root-page of another table is moved by the btree-layer whilst +** erasing iTable (this can happen with an auto-vacuum database). +*/ + static void destroyRootPage( Parse pParse, int iTable, int iDb ) + { + Vdbe v = sqlite3GetVdbe( pParse ); + int r1 = sqlite3GetTempReg( pParse ); + sqlite3VdbeAddOp3( v, OP_Destroy, iTable, r1, iDb ); + sqlite3MayAbort( pParse ); #if !SQLITE_OMIT_AUTOVACUUM - /* OP_Destroy stores an in integer r1. If this integer - ** is non-zero, then it is the root page number of a table moved to - ** location iTable. The following code modifies the sqlite_master table to - ** reflect this. - ** - ** The "#NNN" in the SQL is a special constant that means whatever value - ** is in register NNN. See grammar rules associated with the TK_REGISTER - ** token for additional information. - */ - sqlite3NestedParse(pParse, - "UPDATE %Q.%s SET rootpage=%d WHERE #%d AND rootpage=#%d", - pParse.db.aDb[iDb].zName, SCHEMA_TABLE(iDb), iTable, r1, r1); + /* OP_Destroy stores an in integer r1. If this integer +** is non-zero, then it is the root page number of a table moved to +** location iTable. The following code modifies the sqlite_master table to +** reflect this. +** +** The "#NNN" in the SQL is a special constant that means whatever value +** is in register NNN. See grammar rules associated with the TK_REGISTER +** token for additional information. +*/ + sqlite3NestedParse( pParse, + "UPDATE %Q.%s SET rootpage=%d WHERE #%d AND rootpage=#%d", + pParse.db.aDb[iDb].zName, SCHEMA_TABLE( iDb ), iTable, r1, r1 ); #endif - sqlite3ReleaseTempReg(pParse, r1); - } + sqlite3ReleaseTempReg( pParse, r1 ); + } - /* - ** Write VDBE code to erase table pTab and all associated indices on disk. - ** Code to update the sqlite_master tables and internal schema definitions - ** in case a root-page belonging to another table is moved by the btree layer - ** is also added (this can happen with an auto-vacuum database). - */ - static void destroyTable(Parse pParse, Table pTab) { -#if SQLITE_OMIT_AUTOVACUUM + /* + ** Write VDBE code to erase table pTab and all associated indices on disk. + ** Code to update the sqlite_master tables and internal schema definitions + ** in case a root-page belonging to another table is moved by the btree layer + ** is also added (this can happen with an auto-vacuum database). + */ + static void destroyTable( Parse pParse, Table pTab ) + { +#if SQLITE_OMIT_AUTOVACUUM Index pIdx; int iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema ); destroyRootPage( pParse, pTab.tnum, iDb ); @@ -2104,87 +2296,97 @@ static void destroyTable(Parse pParse, Table pTab) { destroyRootPage( pParse, pIdx.tnum, iDb ); } #else - /* If the database may be auto-vacuum capable (if SQLITE_OMIT_AUTOVACUUM - ** is not defined), then it is important to call OP_Destroy on the - ** table and index root-pages in order, starting with the numerically - ** largest root-page number. This guarantees that none of the root-pages - ** to be destroyed is relocated by an earlier OP_Destroy. i.e. if the - ** following were coded: - ** - ** OP_Destroy 4 0 - ** ... - ** OP_Destroy 5 0 - ** - ** and root page 5 happened to be the largest root-page number in the - ** database, then root page 5 would be moved to page 4 by the - ** "OP_Destroy 4 0" opcode. The subsequent "OP_Destroy 5 0" would hit - ** a free-list page. - */ - int iTab = pTab.tnum; - int iDestroyed = 0; - - while (true) { - Index pIdx; - int iLargest = 0; - - if (iDestroyed == 0 || iTab < iDestroyed) { - iLargest = iTab; - } - for (pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext) { - int iIdx = pIdx.tnum; - Debug.Assert(pIdx.pSchema == pTab.pSchema); - if ((iDestroyed == 0 || (iIdx < iDestroyed)) && iIdx > iLargest) { - iLargest = iIdx; - } - } - if (iLargest == 0) { - return; - } else { - int iDb = sqlite3SchemaToIndex(pParse.db, pTab.pSchema); - destroyRootPage(pParse, iLargest, iDb); - iDestroyed = iLargest; - } - } -#endif + /* If the database may be auto-vacuum capable (if SQLITE_OMIT_AUTOVACUUM +** is not defined), then it is important to call OP_Destroy on the +** table and index root-pages in order, starting with the numerically +** largest root-page number. This guarantees that none of the root-pages +** to be destroyed is relocated by an earlier OP_Destroy. i.e. if the +** following were coded: +** +** OP_Destroy 4 0 +** ... +** OP_Destroy 5 0 +** +** and root page 5 happened to be the largest root-page number in the +** database, then root page 5 would be moved to page 4 by the +** "OP_Destroy 4 0" opcode. The subsequent "OP_Destroy 5 0" would hit +** a free-list page. +*/ + int iTab = pTab.tnum; + int iDestroyed = 0; + + while ( true ) + { + Index pIdx; + int iLargest = 0; + + if ( iDestroyed == 0 || iTab < iDestroyed ) + { + iLargest = iTab; + } + for ( pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext ) + { + int iIdx = pIdx.tnum; + Debug.Assert( pIdx.pSchema == pTab.pSchema ); + if ( ( iDestroyed == 0 || ( iIdx < iDestroyed ) ) && iIdx > iLargest ) + { + iLargest = iIdx; + } + } + if ( iLargest == 0 ) + { + return; + } + else + { + int iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema ); + destroyRootPage( pParse, iLargest, iDb ); + iDestroyed = iLargest; } + } +#endif + } - /* - ** This routine is called to do the work of a DROP TABLE statement. - ** pName is the name of the table to be dropped. - */ - static void sqlite3DropTable(Parse pParse, SrcList pName, int isView, int noErr) { - Table pTab; - Vdbe v; - sqlite3 db = pParse.db; - int iDb; - - //if ( db.mallocFailed != 0 ) - //{ - // goto exit_drop_table; - //} - Debug.Assert(pParse.nErr == 0); - Debug.Assert(pName.nSrc == 1); - if (noErr != 0) - db.suppressErr++; - pTab = sqlite3LocateTable(pParse, isView, - pName.a[0].zName, pName.a[0].zDatabase); - if (noErr != 0) - db.suppressErr--; - - if (pTab == null) { - if (noErr != 0) - sqlite3CodeVerifyNamedSchema(pParse, pName.a[0].zDatabase); - goto exit_drop_table; - } - iDb = sqlite3SchemaToIndex(db, pTab.pSchema); - Debug.Assert(iDb >= 0 && iDb < db.nDb); - - /* If pTab is a virtual table, call ViewGetColumnNames() to ensure - ** it is initialized. - */ - if (IsVirtual(pTab) && sqlite3ViewGetColumnNames(pParse, pTab) != 0) { - goto exit_drop_table; - } + /* + ** This routine is called to do the work of a DROP TABLE statement. + ** pName is the name of the table to be dropped. + */ + static void sqlite3DropTable( Parse pParse, SrcList pName, int isView, int noErr ) + { + Table pTab; + Vdbe v; + sqlite3 db = pParse.db; + int iDb; + + //if ( db.mallocFailed != 0 ) + //{ + // goto exit_drop_table; + //} + Debug.Assert( pParse.nErr == 0 ); + Debug.Assert( pName.nSrc == 1 ); + if ( noErr != 0 ) + db.suppressErr++; + pTab = sqlite3LocateTable( pParse, isView, + pName.a[0].zName, pName.a[0].zDatabase ); + if ( noErr != 0 ) + db.suppressErr--; + + if ( pTab == null ) + { + if ( noErr != 0) + sqlite3CodeVerifyNamedSchema( pParse, pName.a[0].zDatabase ); + goto exit_drop_table; + } + iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); + Debug.Assert( iDb >= 0 && iDb < db.nDb ); + + /* If pTab is a virtual table, call ViewGetColumnNames() to ensure + ** it is initialized. + */ + if ( IsVirtual( pTab ) && sqlite3ViewGetColumnNames( pParse, pTab ) != 0 ) + { + goto exit_drop_table; + } #if !SQLITE_OMIT_AUTHORIZATION { int code; @@ -2218,285 +2420,316 @@ static void sqlite3DropTable(Parse pParse, SrcList pName, int isView, int noErr) } } #endif - if (pTab.zName.StartsWith("sqlite_", System.StringComparison.OrdinalIgnoreCase)) { - sqlite3ErrorMsg(pParse, "table %s may not be dropped", pTab.zName); - goto exit_drop_table; - } + if ( pTab.zName.StartsWith( "sqlite_", System.StringComparison.OrdinalIgnoreCase ) ) + { + sqlite3ErrorMsg( pParse, "table %s may not be dropped", pTab.zName ); + goto exit_drop_table; + } #if !SQLITE_OMIT_VIEW - /* Ensure DROP TABLE is not used on a view, and DROP VIEW is not used - ** on a table. - */ - if (isView != 0 && pTab.pSelect == null) { - sqlite3ErrorMsg(pParse, "use DROP TABLE to delete table %s", pTab.zName); - goto exit_drop_table; - } - if (0 == isView && pTab.pSelect != null) { - sqlite3ErrorMsg(pParse, "use DROP VIEW to delete view %s", pTab.zName); - goto exit_drop_table; - } + /* Ensure DROP TABLE is not used on a view, and DROP VIEW is not used +** on a table. +*/ + if ( isView != 0 && pTab.pSelect == null ) + { + sqlite3ErrorMsg( pParse, "use DROP TABLE to delete table %s", pTab.zName ); + goto exit_drop_table; + } + if ( 0 == isView && pTab.pSelect != null ) + { + sqlite3ErrorMsg( pParse, "use DROP VIEW to delete view %s", pTab.zName ); + goto exit_drop_table; + } #endif - /* Generate code to remove the table from the master table - ** on disk. - */ - v = sqlite3GetVdbe(pParse); - if (v != null) { - Trigger pTrigger; - Db pDb = db.aDb[iDb]; - sqlite3BeginWriteOperation(pParse, 1, iDb); + /* Generate code to remove the table from the master table +** on disk. +*/ + v = sqlite3GetVdbe( pParse ); + if ( v != null ) + { + Trigger pTrigger; + Db pDb = db.aDb[iDb]; + sqlite3BeginWriteOperation( pParse, 1, iDb ); #if !SQLITE_OMIT_VIRTUALTABLE - if (IsVirtual(pTab)) { - sqlite3VdbeAddOp0(v, OP_VBegin); - } + if ( IsVirtual( pTab ) ) + { + sqlite3VdbeAddOp0( v, OP_VBegin ); + } #endif - sqlite3FkDropTable(pParse, pName, pTab); - - /* Drop all triggers associated with the table being dropped. Code - ** is generated to remove entries from sqlite_master and/or - ** sqlite_temp_master if required. - */ - pTrigger = sqlite3TriggerList(pParse, pTab); - while (pTrigger != null) { - Debug.Assert(pTrigger.pSchema == pTab.pSchema || - pTrigger.pSchema == db.aDb[1].pSchema); - sqlite3DropTriggerPtr(pParse, pTrigger); - pTrigger = pTrigger.pNext; - } + sqlite3FkDropTable( pParse, pName, pTab ); -#if !SQLITE_OMIT_AUTOINCREMENT - /* Remove any entries of the sqlite_sequence table associated with - ** the table being dropped. This is done before the table is dropped - ** at the btree level, in case the sqlite_sequence table needs to - ** move as a result of the drop (can happen in auto-vacuum mode). + /* Drop all triggers associated with the table being dropped. Code + ** is generated to remove entries from sqlite_master and/or + ** sqlite_temp_master if required. */ - if ((pTab.tabFlags & TF_Autoincrement) != 0) { - sqlite3NestedParse(pParse, - "DELETE FROM %s.sqlite_sequence WHERE name=%Q", - pDb.zName, pTab.zName - ); - } + pTrigger = sqlite3TriggerList( pParse, pTab ); + while ( pTrigger != null ) + { + Debug.Assert( pTrigger.pSchema == pTab.pSchema || + pTrigger.pSchema == db.aDb[1].pSchema ); + sqlite3DropTriggerPtr( pParse, pTrigger ); + pTrigger = pTrigger.pNext; + } + +#if !SQLITE_OMIT_AUTOINCREMENT + /* Remove any entries of the sqlite_sequence table associated with +** the table being dropped. This is done before the table is dropped +** at the btree level, in case the sqlite_sequence table needs to +** move as a result of the drop (can happen in auto-vacuum mode). +*/ + if ( ( pTab.tabFlags & TF_Autoincrement ) != 0 ) + { + sqlite3NestedParse( pParse, + "DELETE FROM %s.sqlite_sequence WHERE name=%Q", + pDb.zName, pTab.zName + ); + } #endif - /* Drop all SQLITE_MASTER table and index entries that refer to the - ** table. The program name loops through the master table and deletes - ** every row that refers to a table of the same name as the one being - ** dropped. Triggers are handled seperately because a trigger can be - ** created in the temp database that refers to a table in another - ** database. - */ - sqlite3NestedParse(pParse, - "DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'", - pDb.zName, SCHEMA_TABLE(iDb), pTab.zName); - - /* Drop any statistics from the sqlite_stat1 table, if it exists */ - if (sqlite3FindTable(db, "sqlite_stat1", db.aDb[iDb].zName) != null) { - sqlite3NestedParse(pParse, - "DELETE FROM %Q.sqlite_stat1 WHERE tbl=%Q", pDb.zName, pTab.zName - ); - } - - if (0 == isView && !IsVirtual(pTab)) { - destroyTable(pParse, pTab); - } - - /* Remove the table entry from SQLite's internal schema and modify - ** the schema cookie. - */ - if (IsVirtual(pTab)) { - sqlite3VdbeAddOp4(v, OP_VDestroy, iDb, 0, 0, pTab.zName, 0); - } - sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab.zName, 0); - sqlite3ChangeCookie(pParse, iDb); - } - sqliteViewResetAll(db, iDb); + /* Drop all SQLITE_MASTER table and index entries that refer to the +** table. The program name loops through the master table and deletes +** every row that refers to a table of the same name as the one being +** dropped. Triggers are handled seperately because a trigger can be +** created in the temp database that refers to a table in another +** database. +*/ + sqlite3NestedParse( pParse, + "DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'", + pDb.zName, SCHEMA_TABLE( iDb ), pTab.zName ); + + /* Drop any statistics from the sqlite_stat1 table, if it exists */ + if ( sqlite3FindTable( db, "sqlite_stat1", db.aDb[iDb].zName ) != null ) + { + sqlite3NestedParse( pParse, + "DELETE FROM %Q.sqlite_stat1 WHERE tbl=%Q", pDb.zName, pTab.zName + ); + } - exit_drop_table: - sqlite3SrcListDelete(db, ref pName); + if ( 0 == isView && !IsVirtual( pTab ) ) + { + destroyTable( pParse, pTab ); } - /* - ** This routine is called to create a new foreign key on the table - ** currently under construction. pFromCol determines which columns - ** in the current table point to the foreign key. If pFromCol==0 then - ** connect the key to the last column inserted. pTo is the name of - ** the table referred to. pToCol is a list of tables in the other - ** pTo table that the foreign key points to. flags contains all - ** information about the conflict resolution algorithms specified - ** in the ON DELETE, ON UPDATE and ON INSERT clauses. - ** - ** An FKey structure is created and added to the table currently - ** under construction in the pParse.pNewTable field. - ** - ** The foreign key is set for IMMEDIATE processing. A subsequent call - ** to sqlite3DeferForeignKey() might change this to DEFERRED. + /* Remove the table entry from SQLite's internal schema and modify + ** the schema cookie. */ - // OVERLOADS, so I don't need to rewrite parse.c - static void sqlite3CreateForeignKey(Parse pParse, int null_2, Token pTo, ExprList pToCol, int flags) { - sqlite3CreateForeignKey(pParse, null, pTo, pToCol, flags); - } - static void sqlite3CreateForeignKey( - Parse pParse, /* Parsing context */ - ExprList pFromCol, /* Columns in this table that point to other table */ - Token pTo, /* Name of the other table */ - ExprList pToCol, /* Columns in the other table */ - int flags /* Conflict resolution algorithms. */ - ) { - sqlite3 db = pParse.db; -#if !SQLITE_OMIT_FOREIGN_KEY - FKey pFKey = null; - FKey pNextTo; - Table p = pParse.pNewTable; - int nByte; - int i; - int nCol; - //string z; - - Debug.Assert(pTo != null); - if (p == null || IN_DECLARE_VTAB(pParse)) - goto fk_end; - if (pFromCol == null) { - int iCol = p.nCol - 1; - if (NEVER(iCol < 0)) - goto fk_end; - if (pToCol != null && pToCol.nExpr != 1) { - sqlite3ErrorMsg(pParse, "foreign key on %s" + - " should reference only one column of table %T", - p.aCol[iCol].zName, pTo); - goto fk_end; - } - nCol = 1; - } else if (pToCol != null && pToCol.nExpr != pFromCol.nExpr) { - sqlite3ErrorMsg(pParse, - "number of columns in foreign key does not match the number of " + - "columns in the referenced table"); - goto fk_end; - } else { - nCol = pFromCol.nExpr; - } - //nByte = sizeof(*pFKey) + (nCol-1)*sizeof(pFKey.aCol[0]) + pTo.n + 1; - //if( pToCol ){ - // for(i=0; ia[i].zName) + 1; - // } - //} - pFKey = new FKey();//sqlite3DbMallocZero(db, nByte ); - if (pFKey == null) { - goto fk_end; - } - pFKey.pFrom = p; - pFKey.pNextFrom = p.pFKey; - //z = pFKey.aCol[nCol].zCol; - pFKey.aCol = new FKey.sColMap[nCol];// z; - pFKey.aCol[0] = new FKey.sColMap(); - pFKey.zTo = pTo.z.Substring(0, pTo.n); //memcpy( z, pTo.z, pTo.n ); - //z[pTo.n] = 0; - sqlite3Dequote(ref pFKey.zTo); - //z += pTo.n + 1; - pFKey.nCol = nCol; - if (pFromCol == null) { - pFKey.aCol[0].iFrom = p.nCol - 1; - } else { - for (i = 0; i < nCol; i++) { - if (pFKey.aCol[i] == null) - pFKey.aCol[i] = new FKey.sColMap(); - int j; - for (j = 0; j < p.nCol; j++) { - if (p.aCol[j].zName.Equals(pFromCol.a[i].zName, StringComparison.OrdinalIgnoreCase)) { - pFKey.aCol[i].iFrom = j; - break; - } - } - if (j >= p.nCol) { - sqlite3ErrorMsg(pParse, - "unknown column \"%s\" in foreign key definition", - pFromCol.a[i].zName); - goto fk_end; - } - } - } - if (pToCol != null) { - for (i = 0; i < nCol; i++) { - ////int n = sqlite3Strlen30( pToCol.a[i].zName ); - if (pFKey.aCol[i] == null) - pFKey.aCol[i] = new FKey.sColMap(); - pFKey.aCol[i].zCol = pToCol.a[i].zName; - //memcpy( z, pToCol.a[i].zName, n ); - //z[n] = 0; - //z += n + 1; - } - } - pFKey.isDeferred = 0; - pFKey.aAction[0] = (u8)(flags & 0xff); /* ON DELETE action */ - pFKey.aAction[1] = (u8)((flags >> 8) & 0xff); /* ON UPDATE action */ + if ( IsVirtual( pTab ) ) + { + sqlite3VdbeAddOp4( v, OP_VDestroy, iDb, 0, 0, pTab.zName, 0 ); + } + sqlite3VdbeAddOp4( v, OP_DropTable, iDb, 0, 0, pTab.zName, 0 ); + sqlite3ChangeCookie( pParse, iDb ); + } + sqliteViewResetAll( db, iDb ); - Debug.Assert(sqlite3SchemaMutexHeld(db, 0, p.pSchema)); - pNextTo = sqlite3HashInsert(ref p.pSchema.fkeyHash, - pFKey.zTo, sqlite3Strlen30(pFKey.zTo), pFKey - ); - //if( pNextTo==pFKey ){ - // db.mallocFailed = 1; - // goto fk_end; - //} - if (pNextTo != null) { - Debug.Assert(pNextTo.pPrevTo == null); - pFKey.pNextTo = pNextTo; - pNextTo.pPrevTo = pFKey; - } - /* Link the foreign key to the table as the last step. - */ - p.pFKey = pFKey; - pFKey = null; +exit_drop_table: + sqlite3SrcListDelete( db, ref pName ); + } - fk_end: - sqlite3DbFree(db, ref pFKey); -#endif // * !SQLITE_OMIT_FOREIGN_KEY) */ - sqlite3ExprListDelete(db, ref pFromCol); - sqlite3ExprListDelete(db, ref pToCol); + /* + ** This routine is called to create a new foreign key on the table + ** currently under construction. pFromCol determines which columns + ** in the current table point to the foreign key. If pFromCol==0 then + ** connect the key to the last column inserted. pTo is the name of + ** the table referred to. pToCol is a list of tables in the other + ** pTo table that the foreign key points to. flags contains all + ** information about the conflict resolution algorithms specified + ** in the ON DELETE, ON UPDATE and ON INSERT clauses. + ** + ** An FKey structure is created and added to the table currently + ** under construction in the pParse.pNewTable field. + ** + ** The foreign key is set for IMMEDIATE processing. A subsequent call + ** to sqlite3DeferForeignKey() might change this to DEFERRED. + */ + // OVERLOADS, so I don't need to rewrite parse.c + static void sqlite3CreateForeignKey( Parse pParse, int null_2, Token pTo, ExprList pToCol, int flags ) + { + sqlite3CreateForeignKey( pParse, null, pTo, pToCol, flags ); + } + static void sqlite3CreateForeignKey( + Parse pParse, /* Parsing context */ + ExprList pFromCol, /* Columns in this table that point to other table */ + Token pTo, /* Name of the other table */ + ExprList pToCol, /* Columns in the other table */ + int flags /* Conflict resolution algorithms. */ + ) + { + sqlite3 db = pParse.db; +#if !SQLITE_OMIT_FOREIGN_KEY + FKey pFKey = null; + FKey pNextTo; + Table p = pParse.pNewTable; + int nByte; + int i; + int nCol; + //string z; + + Debug.Assert( pTo != null ); + if ( p == null || IN_DECLARE_VTAB( pParse ) ) + goto fk_end; + if ( pFromCol == null ) + { + int iCol = p.nCol - 1; + if ( NEVER( iCol < 0 ) ) + goto fk_end; + if ( pToCol != null && pToCol.nExpr != 1 ) + { + sqlite3ErrorMsg( pParse, "foreign key on %s" + + " should reference only one column of table %T", + p.aCol[iCol].zName, pTo ); + goto fk_end; } + nCol = 1; + } + else if ( pToCol != null && pToCol.nExpr != pFromCol.nExpr ) + { + sqlite3ErrorMsg( pParse, + "number of columns in foreign key does not match the number of " + + "columns in the referenced table" ); + goto fk_end; + } + else + { + nCol = pFromCol.nExpr; + } + //nByte = sizeof(*pFKey) + (nCol-1)*sizeof(pFKey.aCol[0]) + pTo.n + 1; + //if( pToCol ){ + // for(i=0; ia[i].zName) + 1; + // } + //} + pFKey = new FKey();//sqlite3DbMallocZero(db, nByte ); + if ( pFKey == null ) + { + goto fk_end; + } + pFKey.pFrom = p; + pFKey.pNextFrom = p.pFKey; + //z = pFKey.aCol[nCol].zCol; + pFKey.aCol = new FKey.sColMap[nCol];// z; + pFKey.aCol[0] = new FKey.sColMap(); + pFKey.zTo = pTo.z.Substring( 0, pTo.n ); //memcpy( z, pTo.z, pTo.n ); + //z[pTo.n] = 0; + sqlite3Dequote( ref pFKey.zTo ); + //z += pTo.n + 1; + pFKey.nCol = nCol; + if ( pFromCol == null ) + { + pFKey.aCol[0].iFrom = p.nCol - 1; + } + else + { + for ( i = 0; i < nCol; i++ ) + { + if ( pFKey.aCol[i] == null ) + pFKey.aCol[i] = new FKey.sColMap(); + int j; + for ( j = 0; j < p.nCol; j++ ) + { + if ( p.aCol[j].zName.Equals( pFromCol.a[i].zName, StringComparison.OrdinalIgnoreCase ) ) + { + pFKey.aCol[i].iFrom = j; + break; + } + } + if ( j >= p.nCol ) + { + sqlite3ErrorMsg( pParse, + "unknown column \"%s\" in foreign key definition", + pFromCol.a[i].zName ); + goto fk_end; + } + } + } + if ( pToCol != null ) + { + for ( i = 0; i < nCol; i++ ) + { + ////int n = sqlite3Strlen30( pToCol.a[i].zName ); + if ( pFKey.aCol[i] == null ) + pFKey.aCol[i] = new FKey.sColMap(); + pFKey.aCol[i].zCol = pToCol.a[i].zName; + //memcpy( z, pToCol.a[i].zName, n ); + //z[n] = 0; + //z += n + 1; + } + } + pFKey.isDeferred = 0; + pFKey.aAction[0] = (u8)( flags & 0xff ); /* ON DELETE action */ + pFKey.aAction[1] = (u8)( ( flags >> 8 ) & 0xff ); /* ON UPDATE action */ + + Debug.Assert( sqlite3SchemaMutexHeld( db, 0, p.pSchema ) ); + pNextTo = sqlite3HashInsert( ref p.pSchema.fkeyHash, + pFKey.zTo, sqlite3Strlen30( pFKey.zTo ), pFKey + ); + //if( pNextTo==pFKey ){ + // db.mallocFailed = 1; + // goto fk_end; + //} + if ( pNextTo != null ) + { + Debug.Assert( pNextTo.pPrevTo == null ); + pFKey.pNextTo = pNextTo; + pNextTo.pPrevTo = pFKey; + } + /* Link the foreign key to the table as the last step. + */ + p.pFKey = pFKey; + pFKey = null; - /* - ** This routine is called when an INITIALLY IMMEDIATE or INITIALLY DEFERRED - ** clause is seen as part of a foreign key definition. The isDeferred - ** parameter is 1 for INITIALLY DEFERRED and 0 for INITIALLY IMMEDIATE. - ** The behavior of the most recently created foreign key is adjusted - ** accordingly. - */ - static void sqlite3DeferForeignKey(Parse pParse, int isDeferred) { +fk_end: + sqlite3DbFree( db, ref pFKey ); +#endif // * !SQLITE_OMIT_FOREIGN_KEY) */ + sqlite3ExprListDelete( db, ref pFromCol ); + sqlite3ExprListDelete( db, ref pToCol ); + } + + /* + ** This routine is called when an INITIALLY IMMEDIATE or INITIALLY DEFERRED + ** clause is seen as part of a foreign key definition. The isDeferred + ** parameter is 1 for INITIALLY DEFERRED and 0 for INITIALLY IMMEDIATE. + ** The behavior of the most recently created foreign key is adjusted + ** accordingly. + */ + static void sqlite3DeferForeignKey( Parse pParse, int isDeferred ) + { #if !SQLITE_OMIT_FOREIGN_KEY - Table pTab; - FKey pFKey; - if ((pTab = pParse.pNewTable) == null || (pFKey = pTab.pFKey) == null) - return; - Debug.Assert(isDeferred == 0 || isDeferred == 1); /* EV: R-30323-21917 */ - pFKey.isDeferred = (u8)isDeferred; + Table pTab; + FKey pFKey; + if ( ( pTab = pParse.pNewTable ) == null || ( pFKey = pTab.pFKey ) == null ) + return; + Debug.Assert( isDeferred == 0 || isDeferred == 1 ); /* EV: R-30323-21917 */ + pFKey.isDeferred = (u8)isDeferred; #endif - } + } - /* - ** Generate code that will erase and refill index pIdx. This is - ** used to initialize a newly created index or to recompute the - ** content of an index in response to a REINDEX command. - ** - ** if memRootPage is not negative, it means that the index is newly - ** created. The register specified by memRootPage contains the - ** root page number of the index. If memRootPage is negative, then - ** the index already exists and must be cleared before being refilled and - ** the root page number of the index is taken from pIndex.tnum. - */ - static void sqlite3RefillIndex(Parse pParse, Index pIndex, int memRootPage) { - Table pTab = pIndex.pTable; /* The table that is indexed */ - int iTab = pParse.nTab++; /* Btree cursor used for pTab */ - int iIdx = pParse.nTab++; /* Btree cursor used for pIndex */ - int addr1; /* Address of top of loop */ - int tnum; /* Root page of index */ - Vdbe v; /* Generate code into this virtual machine */ - KeyInfo pKey; /* KeyInfo for index */ - int regIdxKey; /* Registers containing the index key */ - int regRecord; /* Register holding assemblied index record */ - sqlite3 db = pParse.db; /* The database connection */ - int iDb = sqlite3SchemaToIndex(db, pIndex.pSchema); + /* + ** Generate code that will erase and refill index pIdx. This is + ** used to initialize a newly created index or to recompute the + ** content of an index in response to a REINDEX command. + ** + ** if memRootPage is not negative, it means that the index is newly + ** created. The register specified by memRootPage contains the + ** root page number of the index. If memRootPage is negative, then + ** the index already exists and must be cleared before being refilled and + ** the root page number of the index is taken from pIndex.tnum. + */ + static void sqlite3RefillIndex( Parse pParse, Index pIndex, int memRootPage ) + { + Table pTab = pIndex.pTable; /* The table that is indexed */ + int iTab = pParse.nTab++; /* Btree cursor used for pTab */ + int iIdx = pParse.nTab++; /* Btree cursor used for pIndex */ + int addr1; /* Address of top of loop */ + int tnum; /* Root page of index */ + Vdbe v; /* Generate code into this virtual machine */ + KeyInfo pKey; /* KeyInfo for index */ + int regIdxKey; /* Registers containing the index key */ + int regRecord; /* Register holding assemblied index record */ + sqlite3 db = pParse.db; /* The database connection */ + int iDb = sqlite3SchemaToIndex( db, pIndex.pSchema ); #if !SQLITE_OMIT_AUTHORIZATION if( sqlite3AuthCheck(pParse, SQLITE_REINDEX, pIndex.zName, 0, @@ -2505,232 +2738,263 @@ static void sqlite3RefillIndex(Parse pParse, Index pIndex, int memRootPage) { } #endif - /* Require a write-lock on the table to perform this operation */ - sqlite3TableLock(pParse, iDb, pTab.tnum, 1, pTab.zName); - v = sqlite3GetVdbe(pParse); - if (v == null) - return; - if (memRootPage >= 0) { - tnum = memRootPage; - } else { - tnum = pIndex.tnum; - sqlite3VdbeAddOp2(v, OP_Clear, tnum, iDb); - } - pKey = sqlite3IndexKeyinfo(pParse, pIndex); - sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, tnum, iDb, - pKey, P4_KEYINFO_HANDOFF); - if (memRootPage >= 0) { - sqlite3VdbeChangeP5(v, 1); - } - sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead); - addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0); - regRecord = sqlite3GetTempReg(pParse); - regIdxKey = sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, true); - if (pIndex.onError != OE_None) { - int regRowid = regIdxKey + pIndex.nColumn; - int j2 = sqlite3VdbeCurrentAddr(v) + 2; - int pRegKey = regIdxKey;// SQLITE_INT_TO_PTR( regIdxKey ); - - /* The registers accessed by the OP_IsUnique opcode were allocated - ** using sqlite3GetTempRange() inside of the sqlite3GenerateIndexKey() - ** call above. Just before that function was freed they were released - ** (made available to the compiler for reuse) using - ** sqlite3ReleaseTempRange(). So in some ways having the OP_IsUnique - ** opcode use the values stored within seems dangerous. However, since - ** we can be sure that no other temp registers have been allocated - ** since sqlite3ReleaseTempRange() was called, it is safe to do so. - */ - sqlite3VdbeAddOp4(v, OP_IsUnique, iIdx, j2, regRowid, pRegKey, P4_INT32); - sqlite3HaltConstraint( - pParse, OE_Abort, "indexed columns are not unique", P4_STATIC); - } - sqlite3VdbeAddOp2(v, OP_IdxInsert, iIdx, regRecord); - sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); - sqlite3ReleaseTempReg(pParse, regRecord); - sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1 + 1); - sqlite3VdbeJumpHere(v, addr1); - sqlite3VdbeAddOp1(v, OP_Close, iTab); - sqlite3VdbeAddOp1(v, OP_Close, iIdx); - } - - /* - ** Create a new index for an SQL table. pName1.pName2 is the name of the index - ** and pTblList is the name of the table that is to be indexed. Both will - ** be NULL for a primary key or an index that is created to satisfy a - ** UNIQUE constraint. If pTable and pIndex are NULL, use pParse.pNewTable - ** as the table to be indexed. pParse.pNewTable is a table that is - ** currently being constructed by a CREATE TABLE statement. - ** - ** pList is a list of columns to be indexed. pList will be NULL if this - ** is a primary key or unique-constraint on the most recent column added - ** to the table currently under construction. - ** - ** If the index is created successfully, return a pointer to the new Index - ** structure. This is used by sqlite3AddPrimaryKey() to mark the index - ** as the tables primary key (Index.autoIndex==2). + /* Require a write-lock on the table to perform this operation */ + sqlite3TableLock( pParse, iDb, pTab.tnum, 1, pTab.zName ); + v = sqlite3GetVdbe( pParse ); + if ( v == null ) + return; + if ( memRootPage >= 0 ) + { + tnum = memRootPage; + } + else + { + tnum = pIndex.tnum; + sqlite3VdbeAddOp2( v, OP_Clear, tnum, iDb ); + } + pKey = sqlite3IndexKeyinfo( pParse, pIndex ); + sqlite3VdbeAddOp4( v, OP_OpenWrite, iIdx, tnum, iDb, + pKey, P4_KEYINFO_HANDOFF ); + if ( memRootPage >= 0 ) + { + sqlite3VdbeChangeP5( v, 1 ); + } + sqlite3OpenTable( pParse, iTab, iDb, pTab, OP_OpenRead ); + addr1 = sqlite3VdbeAddOp2( v, OP_Rewind, iTab, 0 ); + regRecord = sqlite3GetTempReg( pParse ); + regIdxKey = sqlite3GenerateIndexKey( pParse, pIndex, iTab, regRecord, true ); + if ( pIndex.onError != OE_None ) + { + int regRowid = regIdxKey + pIndex.nColumn; + int j2 = sqlite3VdbeCurrentAddr( v ) + 2; + int pRegKey = regIdxKey;// SQLITE_INT_TO_PTR( regIdxKey ); + + /* The registers accessed by the OP_IsUnique opcode were allocated + ** using sqlite3GetTempRange() inside of the sqlite3GenerateIndexKey() + ** call above. Just before that function was freed they were released + ** (made available to the compiler for reuse) using + ** sqlite3ReleaseTempRange(). So in some ways having the OP_IsUnique + ** opcode use the values stored within seems dangerous. However, since + ** we can be sure that no other temp registers have been allocated + ** since sqlite3ReleaseTempRange() was called, it is safe to do so. */ - // OVERLOADS, so I don't need to rewrite parse.c - static Index sqlite3CreateIndex(Parse pParse, int null_2, int null_3, int null_4, int null_5, int onError, int null_7, int null_8, int sortOrder, int ifNotExist) { - return sqlite3CreateIndex(pParse, null, null, null, null, onError, null, null, sortOrder, ifNotExist); - } - static Index sqlite3CreateIndex(Parse pParse, int null_2, int null_3, int null_4, ExprList pList, int onError, int null_7, int null_8, int sortOrder, int ifNotExist) { - return sqlite3CreateIndex(pParse, null, null, null, pList, onError, null, null, sortOrder, ifNotExist); - } - static Index sqlite3CreateIndex( - Parse pParse, /* All information about this Parse */ - Token pName1, /* First part of index name. May be NULL */ - Token pName2, /* Second part of index name. May be NULL */ - SrcList pTblName, /* Table to index. Use pParse.pNewTable if 0 */ - ExprList pList, /* A list of columns to be indexed */ - int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ - Token pStart, /* The CREATE token that begins this statement */ - Token pEnd, /* The ")" that closes the CREATE INDEX statement */ - int sortOrder, /* Sort order of primary key when pList==NULL */ - int ifNotExist /* Omit error if index already exists */ - ) { - Index pRet = null; /* Pointer to return */ - Table pTab = null; /* Table to be indexed */ - Index pIndex = null; /* The index to be created */ - string zName = null; /* Name of the index */ - int nName; /* Number of characters in zName */ - int i, j; - Token nullId = new Token(); /* Fake token for an empty ID list */ - DbFixer sFix = new DbFixer(); /* For assigning database names to pTable */ - int sortOrderMask; /* 1 to honor DESC in index. 0 to ignore. */ - 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 = null; /* Unqualified name of the index to create */ - ExprList_item pListItem; /* For looping over pList */ - int nCol; - int nExtra = 0; - StringBuilder zExtra = new StringBuilder(); - - Debug.Assert(pStart == null || pEnd != null); /* pEnd must be non-NULL if pStart is */ - Debug.Assert(pParse.nErr == 0); /* Never called with prior errors */ - if ( /* db.mallocFailed != 0 || */ - IN_DECLARE_VTAB(pParse)) { - goto exit_create_index; - } - if (SQLITE_OK != sqlite3ReadSchema(pParse)) { - goto exit_create_index; - } + sqlite3VdbeAddOp4( v, OP_IsUnique, iIdx, j2, regRowid, pRegKey, P4_INT32 ); + sqlite3HaltConstraint( + pParse, OE_Abort, "indexed columns are not unique", P4_STATIC ); + } + sqlite3VdbeAddOp2( v, OP_IdxInsert, iIdx, regRecord ); + sqlite3VdbeChangeP5( v, OPFLAG_USESEEKRESULT ); + sqlite3ReleaseTempReg( pParse, regRecord ); + sqlite3VdbeAddOp2( v, OP_Next, iTab, addr1 + 1 ); + sqlite3VdbeJumpHere( v, addr1 ); + sqlite3VdbeAddOp1( v, OP_Close, iTab ); + sqlite3VdbeAddOp1( v, OP_Close, iIdx ); + } - /* - ** Find the table that is to be indexed. Return early if not found. - */ - if (pTblName != null) { + /* + ** Create a new index for an SQL table. pName1.pName2 is the name of the index + ** and pTblList is the name of the table that is to be indexed. Both will + ** be NULL for a primary key or an index that is created to satisfy a + ** UNIQUE constraint. If pTable and pIndex are NULL, use pParse.pNewTable + ** as the table to be indexed. pParse.pNewTable is a table that is + ** currently being constructed by a CREATE TABLE statement. + ** + ** pList is a list of columns to be indexed. pList will be NULL if this + ** is a primary key or unique-constraint on the most recent column added + ** to the table currently under construction. + ** + ** If the index is created successfully, return a pointer to the new Index + ** structure. This is used by sqlite3AddPrimaryKey() to mark the index + ** as the tables primary key (Index.autoIndex==2). + */ + // OVERLOADS, so I don't need to rewrite parse.c + static Index sqlite3CreateIndex( Parse pParse, int null_2, int null_3, int null_4, int null_5, int onError, int null_7, int null_8, int sortOrder, int ifNotExist ) + { + return sqlite3CreateIndex( pParse, null, null, null, null, onError, null, null, sortOrder, ifNotExist ); + } + static Index sqlite3CreateIndex( Parse pParse, int null_2, int null_3, int null_4, ExprList pList, int onError, int null_7, int null_8, int sortOrder, int ifNotExist ) + { + return sqlite3CreateIndex( pParse, null, null, null, pList, onError, null, null, sortOrder, ifNotExist ); + } + static Index sqlite3CreateIndex( + Parse pParse, /* All information about this Parse */ + Token pName1, /* First part of index name. May be NULL */ + Token pName2, /* Second part of index name. May be NULL */ + SrcList pTblName, /* Table to index. Use pParse.pNewTable if 0 */ + ExprList pList, /* A list of columns to be indexed */ + int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ + Token pStart, /* The CREATE token that begins this statement */ + Token pEnd, /* The ")" that closes the CREATE INDEX statement */ + int sortOrder, /* Sort order of primary key when pList==NULL */ + int ifNotExist /* Omit error if index already exists */ + ) + { + Index pRet = null; /* Pointer to return */ + Table pTab = null; /* Table to be indexed */ + Index pIndex = null; /* The index to be created */ + string zName = null; /* Name of the index */ + int nName; /* Number of characters in zName */ + int i, j; + Token nullId = new Token(); /* Fake token for an empty ID list */ + DbFixer sFix = new DbFixer(); /* For assigning database names to pTable */ + int sortOrderMask; /* 1 to honor DESC in index. 0 to ignore. */ + 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 = null; /* Unqualified name of the index to create */ + ExprList_item pListItem; /* For looping over pList */ + int nCol; + int nExtra = 0; + StringBuilder zExtra = new StringBuilder(); + + Debug.Assert( pStart == null || pEnd != null ); /* pEnd must be non-NULL if pStart is */ + Debug.Assert( pParse.nErr == 0 ); /* Never called with prior errors */ + if ( /* db.mallocFailed != 0 || */ + IN_DECLARE_VTAB( pParse ) ) + { + goto exit_create_index; + } + if ( SQLITE_OK != sqlite3ReadSchema( pParse ) ) + { + goto exit_create_index; + } + + /* + ** Find the table that is to be indexed. Return early if not found. + */ + if ( pTblName != null ) + { - /* Use the two-part index name to determine the database - ** to search for the table. 'Fix' the table name to this db - ** before looking up the table. - */ - Debug.Assert(pName1 != null && pName2 != null); - iDb = sqlite3TwoPartName(pParse, pName1, pName2, ref pName); - if (iDb < 0) - goto exit_create_index; + /* Use the two-part index name to determine the database + ** to search for the table. 'Fix' the table name to this db + ** before looking up the table. + */ + Debug.Assert( pName1 != null && pName2 != null ); + iDb = sqlite3TwoPartName( pParse, pName1, pName2, ref pName ); + if ( iDb < 0 ) + goto exit_create_index; #if !SQLITE_OMIT_TEMPDB - /* If the index name was unqualified, check if the the table - ** is a temp table. If so, set the database to 1. Do not do this - ** if initialising a database schema. - */ - if (0 == db.init.busy) { - pTab = sqlite3SrcListLookup(pParse, pTblName); - if (pName2.n == 0 && pTab != null && pTab.pSchema == db.aDb[1].pSchema) { - iDb = 1; - } - } + /* If the index name was unqualified, check if the the table +** is a temp table. If so, set the database to 1. Do not do this +** if initialising a database schema. +*/ + if ( 0 == db.init.busy ) + { + pTab = sqlite3SrcListLookup( pParse, pTblName ); + if ( pName2.n == 0 && pTab != null && pTab.pSchema == db.aDb[1].pSchema ) + { + iDb = 1; + } + } #endif - if (sqlite3FixInit(sFix, pParse, iDb, "index", pName) != 0 && - sqlite3FixSrcList(sFix, pTblName) != 0 - ) { - /* Because the parser constructs pTblName from a single identifier, - ** sqlite3FixSrcList can never fail. */ - Debugger.Break(); - } - pTab = sqlite3LocateTable(pParse, 0, pTblName.a[0].zName, - pTblName.a[0].zDatabase); - if (pTab == null /*|| db.mallocFailed != 0 */ ) - goto exit_create_index; - Debug.Assert(db.aDb[iDb].pSchema == pTab.pSchema); - } else { - Debug.Assert(pName == null); - pTab = pParse.pNewTable; - if (pTab == null) - goto exit_create_index; - iDb = sqlite3SchemaToIndex(db, pTab.pSchema); - } - pDb = db.aDb[iDb]; - - Debug.Assert(pTab != null); - Debug.Assert(pParse.nErr == 0); - - if (pTab.zName.StartsWith("sqlite_", System.StringComparison.OrdinalIgnoreCase) - && !pTab.zName.StartsWith("sqlite_altertab_", System.StringComparison.OrdinalIgnoreCase)) { - sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab.zName); - goto exit_create_index; - } + if ( sqlite3FixInit( sFix, pParse, iDb, "index", pName ) != 0 && + sqlite3FixSrcList( sFix, pTblName ) != 0 + ) + { + /* Because the parser constructs pTblName from a single identifier, + ** sqlite3FixSrcList can never fail. */ + Debugger.Break(); + } + pTab = sqlite3LocateTable( pParse, 0, pTblName.a[0].zName, + pTblName.a[0].zDatabase ); + if ( pTab == null /*|| db.mallocFailed != 0 */ ) + goto exit_create_index; + Debug.Assert( db.aDb[iDb].pSchema == pTab.pSchema ); + } + else + { + Debug.Assert( pName == null ); + pTab = pParse.pNewTable; + if ( pTab == null ) + goto exit_create_index; + iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); + } + pDb = db.aDb[iDb]; + + Debug.Assert( pTab != null ); + Debug.Assert( pParse.nErr == 0 ); + + if ( pTab.zName.StartsWith( "sqlite_", System.StringComparison.OrdinalIgnoreCase ) + && !pTab.zName.StartsWith( "sqlite_altertab_", System.StringComparison.OrdinalIgnoreCase ) ) + { + sqlite3ErrorMsg( pParse, "table %s may not be indexed", pTab.zName ); + goto exit_create_index; + } #if !SQLITE_OMIT_VIEW - if (pTab.pSelect != null) { - sqlite3ErrorMsg(pParse, "views may not be indexed"); - goto exit_create_index; - } + if ( pTab.pSelect != null ) + { + sqlite3ErrorMsg( pParse, "views may not be indexed" ); + goto exit_create_index; + } #endif - if (IsVirtual(pTab)) { - sqlite3ErrorMsg(pParse, "virtual tables may not be indexed"); - goto exit_create_index; - } - - /* - ** Find the name of the index. Make sure there is not already another - ** index or table with the same name. - ** - ** Exception: If we are reading the names of permanent indices from the - ** sqlite_master table (because some other process changed the schema) and - ** one of the index names collides with the name of a temporary table or - ** index, then we will continue to process this index. - ** - ** If pName==0 it means that we are - ** dealing with a primary key or UNIQUE constraint. We have to invent our - ** own name. - */ - if (pName != null) { - zName = sqlite3NameFromToken(db, pName); - if (zName == null) - goto exit_create_index; - if (SQLITE_OK != sqlite3CheckObjectName(pParse, zName)) { - goto exit_create_index; - } - if (0 == db.init.busy) { - if (sqlite3FindTable(db, zName, null) != null) { - sqlite3ErrorMsg(pParse, "there is already a table named %s", zName); - goto exit_create_index; - } - } - if (sqlite3FindIndex(db, zName, pDb.zName) != null) { - if (ifNotExist == 0) { - sqlite3ErrorMsg(pParse, "index %s already exists", zName); - } else { - Debug.Assert(0 == db.init.busy); - sqlite3CodeVerifySchema(pParse, iDb); - } - goto exit_create_index; - } - } else { - int n = 0; - Index pLoop; - for (pLoop = pTab.pIndex, n = 1; pLoop != null; pLoop = pLoop.pNext, n++) { - } - zName = sqlite3MPrintf(db, "sqlite_autoindex_%s_%d", pTab.zName, n); - if (zName == null) { - goto exit_create_index; - } - } + if ( IsVirtual( pTab ) ) + { + sqlite3ErrorMsg( pParse, "virtual tables may not be indexed" ); + goto exit_create_index; + } + + /* + ** Find the name of the index. Make sure there is not already another + ** index or table with the same name. + ** + ** Exception: If we are reading the names of permanent indices from the + ** sqlite_master table (because some other process changed the schema) and + ** one of the index names collides with the name of a temporary table or + ** index, then we will continue to process this index. + ** + ** If pName==0 it means that we are + ** dealing with a primary key or UNIQUE constraint. We have to invent our + ** own name. + */ + if ( pName != null ) + { + zName = sqlite3NameFromToken( db, pName ); + if ( zName == null ) + goto exit_create_index; + if ( SQLITE_OK != sqlite3CheckObjectName( pParse, zName ) ) + { + goto exit_create_index; + } + if ( 0 == db.init.busy ) + { + if ( sqlite3FindTable( db, zName, null ) != null ) + { + sqlite3ErrorMsg( pParse, "there is already a table named %s", zName ); + goto exit_create_index; + } + } + if ( sqlite3FindIndex( db, zName, pDb.zName ) != null ) + { + if ( ifNotExist == 0 ) + { + sqlite3ErrorMsg( pParse, "index %s already exists", zName ); + } + else + { + Debug.Assert( 0 == db.init.busy ); + sqlite3CodeVerifySchema( pParse, iDb ); + } + goto exit_create_index; + } + } + else + { + int n = 0; + Index pLoop; + for ( pLoop = pTab.pIndex, n = 1; pLoop != null; pLoop = pLoop.pNext, n++ ) + { + } + zName = sqlite3MPrintf( db, "sqlite_autoindex_%s_%d", pTab.zName, n ); + if ( zName == null ) + { + goto exit_create_index; + } + } - /* Check for authorization to create an index. - */ + /* Check for authorization to create an index. + */ #if !SQLITE_OMIT_AUTHORIZATION { string zDb = pDb.zName; @@ -2745,399 +3009,445 @@ static Index sqlite3CreateIndex( } #endif - /* If pList==0, it means this routine was called to make a primary - ** key out of the last column added to the table under construction. - ** So create a fake list to simulate this. + /* If pList==0, it means this routine was called to make a primary +** key out of the last column added to the table under construction. +** So create a fake list to simulate this. +*/ + if ( pList == null ) + { + nullId.z = pTab.aCol[pTab.nCol - 1].zName; + nullId.n = sqlite3Strlen30( nullId.z ); + pList = sqlite3ExprListAppend( pParse, null, null ); + if ( pList == null ) + goto exit_create_index; + sqlite3ExprListSetName( pParse, pList, nullId, 0 ); + pList.a[0].sortOrder = (u8)sortOrder; + } + + /* Figure out how many bytes of space are required to store explicitly + ** specified collation sequence names. */ - if (pList == null) { - nullId.z = pTab.aCol[pTab.nCol - 1].zName; - nullId.n = sqlite3Strlen30(nullId.z); - pList = sqlite3ExprListAppend(pParse, null, null); - if (pList == null) - goto exit_create_index; - sqlite3ExprListSetName(pParse, pList, nullId, 0); - pList.a[0].sortOrder = (u8)sortOrder; - } - - /* Figure out how many bytes of space are required to store explicitly - ** specified collation sequence names. - */ - for (i = 0; i < pList.nExpr; i++) { - Expr pExpr = pList.a[i].pExpr; - if (pExpr != null) { - CollSeq pColl = pExpr.pColl; - /* Either pColl!=0 or there was an OOM failure. But if an OOM - ** failure we have quit before reaching this point. */ - if (ALWAYS(pColl != null)) { - nExtra += (1 + sqlite3Strlen30(pColl.zName)); - } - } - } + for ( i = 0; i < pList.nExpr; i++ ) + { + Expr pExpr = pList.a[i].pExpr; + if ( pExpr != null ) + { + CollSeq pColl = pExpr.pColl; + /* Either pColl!=0 or there was an OOM failure. But if an OOM + ** failure we have quit before reaching this point. */ + if ( ALWAYS( pColl != null ) ) + { + nExtra += ( 1 + sqlite3Strlen30( pColl.zName ) ); + } + } + } - /* - ** Allocate the index structure. - */ - nName = sqlite3Strlen30(zName); - nCol = pList.nExpr; - pIndex = new Index(); - // sqlite3DbMallocZero( db, - // Index.Length + /* Index structure */ - // sizeof( int ) * nCol + /* Index.aiColumn */ - // sizeof( int ) * ( nCol + 1 ) + /* Index.aiRowEst */ - // sizeof( char* ) * nCol + /* Index.azColl */ - // u8.Length * nCol + /* Index.aSortOrder */ - // nName + 1 + /* Index.zName */ - // nExtra /* Collation sequence names */ - //); - //if ( db.mallocFailed != 0 ) - //{ - // goto exit_create_index; - //} - pIndex.azColl = new string[nCol + 1];//(char*)(pIndex[1]); - pIndex.aiColumn = new int[nCol + 1];//(int )(pIndex->azColl[nCol]); - pIndex.aiRowEst = new int[nCol + 1];//(unsigned )(pIndex->aiColumn[nCol]); - pIndex.aSortOrder = new byte[nCol + 1];//(u8 )(pIndex->aiRowEst[nCol+1]); - //pIndex.zName = null;// (char)( &pIndex->aSortOrder[nCol] ); - zExtra = new StringBuilder(nName + 1);// (char)( &pIndex.zName[nName + 1] ); - if (zName.Length == nName) - pIndex.zName = zName; - else { - pIndex.zName = zName.Substring(0, nName); - }// memcpy( pIndex.zName, zName, nName + 1 ); - pIndex.pTable = pTab; - pIndex.nColumn = pList.nExpr; - pIndex.onError = (u8)onError; - pIndex.autoIndex = (u8)(pName == null ? 1 : 0); - pIndex.pSchema = db.aDb[iDb].pSchema; - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); - - /* Check to see if we should honor DESC requests on index columns - */ - if (pDb.pSchema.file_format >= 4) { - sortOrderMask = 1; /* Honor DESC */ - } else { - sortOrderMask = 0; /* Ignore DESC */ + /* + ** Allocate the index structure. + */ + nName = sqlite3Strlen30( zName ); + nCol = pList.nExpr; + pIndex = new Index(); + // sqlite3DbMallocZero( db, + // Index.Length + /* Index structure */ + // sizeof( int ) * nCol + /* Index.aiColumn */ + // sizeof( int ) * ( nCol + 1 ) + /* Index.aiRowEst */ + // sizeof( char* ) * nCol + /* Index.azColl */ + // u8.Length * nCol + /* Index.aSortOrder */ + // nName + 1 + /* Index.zName */ + // nExtra /* Collation sequence names */ + //); + //if ( db.mallocFailed != 0 ) + //{ + // goto exit_create_index; + //} + pIndex.azColl = new string[nCol + 1];//(char*)(pIndex[1]); + pIndex.aiColumn = new int[nCol + 1];//(int )(pIndex->azColl[nCol]); + pIndex.aiRowEst = new int[nCol + 1];//(unsigned )(pIndex->aiColumn[nCol]); + pIndex.aSortOrder = new byte[nCol + 1];//(u8 )(pIndex->aiRowEst[nCol+1]); + //pIndex.zName = null;// (char)( &pIndex->aSortOrder[nCol] ); + zExtra = new StringBuilder( nName + 1 );// (char)( &pIndex.zName[nName + 1] ); + if ( zName.Length == nName ) + pIndex.zName = zName; + else + { + pIndex.zName = zName.Substring( 0, nName ); + }// memcpy( pIndex.zName, zName, nName + 1 ); + pIndex.pTable = pTab; + pIndex.nColumn = pList.nExpr; + pIndex.onError = (u8)onError; + pIndex.autoIndex = (u8)( pName == null ? 1 : 0 ); + pIndex.pSchema = db.aDb[iDb].pSchema; + Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); + + /* Check to see if we should honor DESC requests on index columns + */ + if ( pDb.pSchema.file_format >= 4 ) + { + sortOrderMask = 1; /* Honor DESC */ + } + else + { + sortOrderMask = 0; /* Ignore DESC */ + } + + /* Scan the names of the columns of the table to be indexed and + ** load the column indices into the Index structure. Report an error + ** if any column is not found. + ** + ** TODO: Add a test to make sure that the same column is not named + ** more than once within the same index. Only the first instance of + ** the column will ever be used by the optimizer. Note that using the + ** same column more than once cannot be an error because that would + ** break backwards compatibility - it needs to be a warning. + */ + for ( i = 0; i < pList.nExpr; i++ ) + {//, pListItem++){ + pListItem = pList.a[i]; + string zColName = pListItem.zName; + Column pTabCol; + byte requestedSortOrder; + string zColl; /* Collation sequence name */ + + for ( j = 0; j < pTab.nCol; j++ ) + {//, pTabCol++){ + pTabCol = pTab.aCol[j]; + if ( zColName.Equals( pTabCol.zName, StringComparison.OrdinalIgnoreCase ) ) + break; + } + if ( j >= pTab.nCol ) + { + sqlite3ErrorMsg( pParse, "table %s has no column named %s", + pTab.zName, zColName ); + pParse.checkSchema = 1; + goto exit_create_index; + } + pIndex.aiColumn[i] = j; + /* Justification of the ALWAYS(pListItem->pExpr->pColl): Because of + ** the way the "idxlist" non-terminal is constructed by the parser, + ** if pListItem->pExpr is not null then either pListItem->pExpr->pColl + ** must exist or else there must have been an OOM error. But if there + ** was an OOM error, we would never reach this point. */ + if ( pListItem.pExpr != null && ALWAYS( pListItem.pExpr.pColl ) ) + { + int nColl; + zColl = pListItem.pExpr.pColl.zName; + nColl = sqlite3Strlen30( zColl ); + Debug.Assert( nExtra >= nColl ); + zExtra = new StringBuilder( zColl.Substring( 0, nColl ) );// memcpy( zExtra, zColl, nColl ); + zColl = zExtra.ToString(); + //zExtra += nColl; + nExtra -= nColl; + } + else + { + zColl = pTab.aCol[j].zColl; + if ( zColl == null ) + { + zColl = db.pDfltColl.zName; + } + } + if ( 0 == db.init.busy && sqlite3LocateCollSeq( pParse, zColl ) == null ) + { + goto exit_create_index; + } + pIndex.azColl[i] = zColl; + requestedSortOrder = (u8)( ( pListItem.sortOrder & sortOrderMask ) != 0 ? 1 : 0 ); + pIndex.aSortOrder[i] = (u8)requestedSortOrder; + } + sqlite3DefaultRowEst( 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. + ** i.e. one of: + ** + ** CREATE TABLE t(x PRIMARY KEY, y); + ** CREATE TABLE t(x, y, UNIQUE(x, y)); + ** + ** Either way, check to see if the table already has such an index. If + ** so, don't bother creating this one. This only applies to + ** automatically created indices. Users can do as they wish with + ** explicit indices. + ** + ** Two UNIQUE or PRIMARY KEY constraints are considered equivalent + ** (and thus suppressing the second one) even if they have different + ** sort orders. + ** + ** If there are different collating sequences or if the columns of + ** the constraint occur in different orders, then the constraints are + ** considered distinct and both result in separate indices. + */ + Index pIdx; + for ( pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext ) + { + int k; + Debug.Assert( pIdx.onError != OE_None ); + Debug.Assert( pIdx.autoIndex != 0 ); + Debug.Assert( pIndex.onError != OE_None ); + + if ( pIdx.nColumn != pIndex.nColumn ) + continue; + for ( k = 0; k < pIdx.nColumn; k++ ) + { + string z1; + string z2; + if ( pIdx.aiColumn[k] != pIndex.aiColumn[k] ) + break; + z1 = pIdx.azColl[k]; + z2 = pIndex.azColl[k]; + if ( z1 != z2 && !z1.Equals( z2, StringComparison.OrdinalIgnoreCase ) ) + break; + } + if ( k == pIdx.nColumn ) + { + if ( pIdx.onError != pIndex.onError ) + { + /* This constraint creates the same index as a previous + ** constraint specified somewhere in the CREATE TABLE statement. + ** However the ON CONFLICT clauses are different. If both this + ** constraint and the previous equivalent constraint have explicit + ** ON CONFLICT clauses this is an error. Otherwise, use the + ** explicitly specified behavior for the index. + */ + if ( !( pIdx.onError == OE_Default || pIndex.onError == OE_Default ) ) + { + sqlite3ErrorMsg( pParse, + "conflicting ON CONFLICT clauses specified", 0 ); + } + if ( pIdx.onError == OE_Default ) + { + pIdx.onError = pIndex.onError; + } } + goto exit_create_index; + } + } + } - /* Scan the names of the columns of the table to be indexed and - ** load the column indices into the Index structure. Report an error - ** if any column is not found. - ** - ** TODO: Add a test to make sure that the same column is not named - ** more than once within the same index. Only the first instance of - ** the column will ever be used by the optimizer. Note that using the - ** same column more than once cannot be an error because that would - ** break backwards compatibility - it needs to be a warning. - */ - for (i = 0; i < pList.nExpr; i++) {//, pListItem++){ - pListItem = pList.a[i]; - string zColName = pListItem.zName; - Column pTabCol; - byte requestedSortOrder; - string zColl; /* Collation sequence name */ - - for (j = 0; j < pTab.nCol; j++) {//, pTabCol++){ - pTabCol = pTab.aCol[j]; - if (zColName.Equals(pTabCol.zName, StringComparison.OrdinalIgnoreCase)) - break; - } - if (j >= pTab.nCol) { - sqlite3ErrorMsg(pParse, "table %s has no column named %s", - pTab.zName, zColName); - pParse.checkSchema = 1; - goto exit_create_index; - } - pIndex.aiColumn[i] = j; - /* Justification of the ALWAYS(pListItem->pExpr->pColl): Because of - ** the way the "idxlist" non-terminal is constructed by the parser, - ** if pListItem->pExpr is not null then either pListItem->pExpr->pColl - ** must exist or else there must have been an OOM error. But if there - ** was an OOM error, we would never reach this point. */ - if (pListItem.pExpr != null && ALWAYS(pListItem.pExpr.pColl)) { - int nColl; - zColl = pListItem.pExpr.pColl.zName; - nColl = sqlite3Strlen30(zColl); - Debug.Assert(nExtra >= nColl); - zExtra = new StringBuilder(zColl.Substring(0, nColl));// memcpy( zExtra, zColl, nColl ); - zColl = zExtra.ToString(); - //zExtra += nColl; - nExtra -= nColl; - } else { - zColl = pTab.aCol[j].zColl; - if (zColl == null) { - zColl = db.pDfltColl.zName; - } - } - if (0 == db.init.busy && sqlite3LocateCollSeq(pParse, zColl) == null) { - goto exit_create_index; - } - pIndex.azColl[i] = zColl; - requestedSortOrder = (u8)((pListItem.sortOrder & sortOrderMask) != 0 ? 1 : 0); - pIndex.aSortOrder[i] = (u8)requestedSortOrder; - } - sqlite3DefaultRowEst(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. - ** i.e. one of: - ** - ** CREATE TABLE t(x PRIMARY KEY, y); - ** CREATE TABLE t(x, y, UNIQUE(x, y)); - ** - ** Either way, check to see if the table already has such an index. If - ** so, don't bother creating this one. This only applies to - ** automatically created indices. Users can do as they wish with - ** explicit indices. - ** - ** Two UNIQUE or PRIMARY KEY constraints are considered equivalent - ** (and thus suppressing the second one) even if they have different - ** sort orders. - ** - ** If there are different collating sequences or if the columns of - ** the constraint occur in different orders, then the constraints are - ** considered distinct and both result in separate indices. - */ - Index pIdx; - for (pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext) { - int k; - Debug.Assert(pIdx.onError != OE_None); - Debug.Assert(pIdx.autoIndex != 0); - Debug.Assert(pIndex.onError != OE_None); - - if (pIdx.nColumn != pIndex.nColumn) - continue; - for (k = 0; k < pIdx.nColumn; k++) { - string z1; - string z2; - if (pIdx.aiColumn[k] != pIndex.aiColumn[k]) - break; - z1 = pIdx.azColl[k]; - z2 = pIndex.azColl[k]; - if (z1 != z2 && !z1.Equals(z2, StringComparison.OrdinalIgnoreCase)) - break; - } - if (k == pIdx.nColumn) { - if (pIdx.onError != pIndex.onError) { - /* This constraint creates the same index as a previous - ** constraint specified somewhere in the CREATE TABLE statement. - ** However the ON CONFLICT clauses are different. If both this - ** constraint and the previous equivalent constraint have explicit - ** ON CONFLICT clauses this is an error. Otherwise, use the - ** explicitly specified behavior for the index. - */ - if (!(pIdx.onError == OE_Default || pIndex.onError == OE_Default)) { - sqlite3ErrorMsg(pParse, - "conflicting ON CONFLICT clauses specified", 0); - } - if (pIdx.onError == OE_Default) { - pIdx.onError = pIndex.onError; - } - } - goto exit_create_index; - } - } - } + /* Link the new Index structure to its table and to the other + ** in-memory database structures. + */ + if ( db.init.busy != 0 ) + { + Index p; + Debug.Assert( sqlite3SchemaMutexHeld( db, 0, pIndex.pSchema ) ); + p = sqlite3HashInsert( ref pIndex.pSchema.idxHash, + pIndex.zName, sqlite3Strlen30( pIndex.zName ), + pIndex ); + if ( p != null ) + { + Debug.Assert( p == pIndex ); /* Malloc must have failed */ + // db.mallocFailed = 1; + goto exit_create_index; + } + db.flags |= SQLITE_InternChanges; + if ( pTblName != null ) + { + pIndex.tnum = db.init.newTnum; + } + } + + /* If the db.init.busy is 0 then create the index on disk. This + ** involves writing the index into the master table and filling in the + ** index with the current table contents. + ** + ** The db.init.busy is 0 when the user first enters a CREATE INDEX + ** command. db.init.busy is 1 when a database is opened and + ** CREATE INDEX statements are read out of the master table. In + ** the latter case the index already exists on disk, which is why + ** we don't want to recreate it. + ** + ** If pTblName==0 it means this index is generated as a primary key + ** or UNIQUE constraint of a CREATE TABLE statement. Since the table + ** has just been created, it contains no data and the index initialization + ** step can be skipped. + */ + else //if ( 0 == db.init.busy ) + { + Vdbe v; + string zStmt; + int iMem = ++pParse.nMem; - /* Link the new Index structure to its table and to the other - ** in-memory database structures. - */ - if (db.init.busy != 0) { - Index p; - Debug.Assert(sqlite3SchemaMutexHeld(db, 0, pIndex.pSchema)); - p = sqlite3HashInsert(ref pIndex.pSchema.idxHash, - pIndex.zName, sqlite3Strlen30(pIndex.zName), - pIndex); - if (p != null) { - Debug.Assert(p == pIndex); /* Malloc must have failed */ - // db.mallocFailed = 1; - goto exit_create_index; - } - db.flags |= SQLITE_InternChanges; - if (pTblName != null) { - pIndex.tnum = db.init.newTnum; - } - } + v = sqlite3GetVdbe( pParse ); + if ( v == null ) + goto exit_create_index; - /* If the db.init.busy is 0 then create the index on disk. This - ** involves writing the index into the master table and filling in the - ** index with the current table contents. - ** - ** The db.init.busy is 0 when the user first enters a CREATE INDEX - ** command. db.init.busy is 1 when a database is opened and - ** CREATE INDEX statements are read out of the master table. In - ** the latter case the index already exists on disk, which is why - ** we don't want to recreate it. - ** - ** If pTblName==0 it means this index is generated as a primary key - ** or UNIQUE constraint of a CREATE TABLE statement. Since the table - ** has just been created, it contains no data and the index initialization - ** step can be skipped. - */ - else //if ( 0 == db.init.busy ) - { - Vdbe v; - string zStmt; - int iMem = ++pParse.nMem; - - v = sqlite3GetVdbe(pParse); - if (v == null) - goto exit_create_index; - - - /* Create the rootpage for the index - */ - sqlite3BeginWriteOperation(pParse, 1, iDb); - sqlite3VdbeAddOp2(v, OP_CreateIndex, iDb, iMem); - - /* Gather the complete text of the CREATE INDEX statement into - ** the zStmt variable - */ - if (pStart != null) { - Debug.Assert(pEnd != null); - /* A named index with an explicit CREATE INDEX statement */ - zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s", - onError == OE_None ? "" : " UNIQUE", - (int)(pName.z.Length - pEnd.z.Length) + 1, - pName.z); - } else { - /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */ - /* zStmt = sqlite3MPrintf(""); */ - zStmt = null; - } - - /* Add an entry in sqlite_master for this index - */ - sqlite3NestedParse(pParse, - "INSERT INTO %Q.%s VALUES('index',%Q,%Q,#%d,%Q);", - db.aDb[iDb].zName, SCHEMA_TABLE(iDb), - pIndex.zName, - pTab.zName, - iMem, - zStmt - ); - sqlite3DbFree(db, ref zStmt); - - /* Fill the index with data and reparse the schema. Code an OP_Expire - ** to invalidate all pre-compiled statements. - */ - if (pTblName != null) { - sqlite3RefillIndex(pParse, pIndex, iMem); - sqlite3ChangeCookie(pParse, iDb); - sqlite3VdbeAddParseSchemaOp(v, iDb, - sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex.zName)); - sqlite3VdbeAddOp1(v, OP_Expire, 0); - } - } - /* When adding an index to the list of indices for a table, make - ** sure all indices labeled OE_Replace come after all those labeled - ** OE_Ignore. This is necessary for the correct constraint check - ** processing (in sqlite3GenerateConstraintChecks()) as part of - ** UPDATE and INSERT statements. - */ - if (db.init.busy != 0 || pTblName == null) { - if (onError != OE_Replace || pTab.pIndex == null - || pTab.pIndex.onError == OE_Replace) { - pIndex.pNext = pTab.pIndex; - pTab.pIndex = pIndex; - } else { - Index pOther = pTab.pIndex; - while (pOther.pNext != null && pOther.pNext.onError != OE_Replace) { - pOther = pOther.pNext; - } - pIndex.pNext = pOther.pNext; - pOther.pNext = pIndex; - } - pRet = pIndex; - pIndex = null; - } + /* Create the rootpage for the index + */ + sqlite3BeginWriteOperation( pParse, 1, iDb ); + sqlite3VdbeAddOp2( v, OP_CreateIndex, iDb, iMem ); - /* Clean up before exiting */ - exit_create_index: - if (pIndex != null) { - //sqlite3DbFree(db, ref pIndex.zColAff ); - sqlite3DbFree(db, ref pIndex); - } - sqlite3ExprListDelete(db, ref pList); - sqlite3SrcListDelete(db, ref pTblName); - sqlite3DbFree(db, ref zName); - return pRet; + /* Gather the complete text of the CREATE INDEX statement into + ** the zStmt variable + */ + if ( pStart != null ) + { + Debug.Assert( pEnd != null ); + /* A named index with an explicit CREATE INDEX statement */ + zStmt = sqlite3MPrintf( db, "CREATE%s INDEX %.*s", + onError == OE_None ? "" : " UNIQUE", + (int)(pName.z.Length - pEnd.z.Length) + 1, + pName.z ); + } + else + { + /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */ + /* zStmt = sqlite3MPrintf(""); */ + zStmt = null; } - /* - ** Fill the Index.aiRowEst[] array with default information - information - ** to be used when we have not run the ANALYZE command. - ** - ** aiRowEst[0] is suppose to contain the number of elements in the index. - ** Since we do not know, guess 1 million. aiRowEst[1] is an estimate of the - ** number of rows in the table that match any particular value of the - ** first column of the index. aiRowEst[2] is an estimate of the number - ** of rows that match any particular combiniation of the first 2 columns - ** of the index. And so forth. It must always be the case that - * - ** aiRowEst[N]<=aiRowEst[N-1] - ** aiRowEst[N]>=1 - ** - ** Apart from that, we have little to go on besides intuition as to - ** how aiRowEst[] should be initialized. The numbers generated here - ** are based on typical values found in actual indices. + /* Add an entry in sqlite_master for this index */ - static void sqlite3DefaultRowEst(Index pIdx) { - int[] a = pIdx.aiRowEst; - int i; - int n; - Debug.Assert(a != null); - a[0] = (int)pIdx.pTable.nRowEst; - if (a[0] < 10) - a[0] = 10; - n = 10; - for (i = 1; i <= pIdx.nColumn; i++) { - a[i] = n; - if (n > 5) - n--; - } - if (pIdx.onError != OE_None) { - a[pIdx.nColumn] = 1; - } + sqlite3NestedParse( pParse, + "INSERT INTO %Q.%s VALUES('index',%Q,%Q,#%d,%Q);", + db.aDb[iDb].zName, SCHEMA_TABLE( iDb ), + pIndex.zName, + pTab.zName, + iMem, + zStmt + ); + sqlite3DbFree( db, ref zStmt ); + + /* Fill the index with data and reparse the schema. Code an OP_Expire + ** to invalidate all pre-compiled statements. + */ + if ( pTblName != null ) + { + sqlite3RefillIndex( pParse, pIndex, iMem ); + sqlite3ChangeCookie( pParse, iDb ); + sqlite3VdbeAddParseSchemaOp( v, iDb, + sqlite3MPrintf( db, "name='%q' AND type='index'", pIndex.zName ) ); + sqlite3VdbeAddOp1( v, OP_Expire, 0 ); } + } - /* - ** This routine will drop an existing named index. This routine - ** implements the DROP INDEX statement. - */ - static void sqlite3DropIndex(Parse pParse, SrcList pName, int ifExists) { - Index pIndex; - Vdbe v; - sqlite3 db = pParse.db; - int iDb; - - Debug.Assert(pParse.nErr == 0); /* Never called with prior errors */ - //if ( db.mallocFailed != 0 ) - //{ - // goto exit_drop_index; - //} - Debug.Assert(pName.nSrc == 1); - if (SQLITE_OK != sqlite3ReadSchema(pParse)) { - goto exit_drop_index; - } - pIndex = sqlite3FindIndex(db, pName.a[0].zName, pName.a[0].zDatabase); - if (pIndex == null) { - if (ifExists == 0) { - sqlite3ErrorMsg(pParse, "no such index: %S", pName, 0); - } else { - sqlite3CodeVerifyNamedSchema(pParse, pName.a[0].zDatabase); - } - pParse.checkSchema = 1; - goto exit_drop_index; - } - if (pIndex.autoIndex != 0) { - sqlite3ErrorMsg(pParse, "index associated with UNIQUE " + - "or PRIMARY KEY constraint cannot be dropped", 0); - goto exit_drop_index; - } - iDb = sqlite3SchemaToIndex(db, pIndex.pSchema); + /* When adding an index to the list of indices for a table, make + ** sure all indices labeled OE_Replace come after all those labeled + ** OE_Ignore. This is necessary for the correct constraint check + ** processing (in sqlite3GenerateConstraintChecks()) as part of + ** UPDATE and INSERT statements. + */ + if ( db.init.busy != 0 || pTblName == null ) + { + if ( onError != OE_Replace || pTab.pIndex == null + || pTab.pIndex.onError == OE_Replace ) + { + pIndex.pNext = pTab.pIndex; + pTab.pIndex = pIndex; + } + else + { + Index pOther = pTab.pIndex; + while ( pOther.pNext != null && pOther.pNext.onError != OE_Replace ) + { + pOther = pOther.pNext; + } + pIndex.pNext = pOther.pNext; + pOther.pNext = pIndex; + } + pRet = pIndex; + pIndex = null; + } + + /* Clean up before exiting */ +exit_create_index: + if ( pIndex != null ) + { + //sqlite3DbFree(db, ref pIndex.zColAff ); + sqlite3DbFree( db, ref pIndex ); + } + sqlite3ExprListDelete( db, ref pList ); + sqlite3SrcListDelete( db, ref pTblName ); + sqlite3DbFree( db, ref zName ); + return pRet; + } + + /* + ** Fill the Index.aiRowEst[] array with default information - information + ** to be used when we have not run the ANALYZE command. + ** + ** aiRowEst[0] is suppose to contain the number of elements in the index. + ** Since we do not know, guess 1 million. aiRowEst[1] is an estimate of the + ** number of rows in the table that match any particular value of the + ** first column of the index. aiRowEst[2] is an estimate of the number + ** of rows that match any particular combiniation of the first 2 columns + ** of the index. And so forth. It must always be the case that + * + ** aiRowEst[N]<=aiRowEst[N-1] + ** aiRowEst[N]>=1 + ** + ** Apart from that, we have little to go on besides intuition as to + ** how aiRowEst[] should be initialized. The numbers generated here + ** are based on typical values found in actual indices. + */ + static void sqlite3DefaultRowEst( Index pIdx ) + { + int[] a = pIdx.aiRowEst; + int i; + int n; + Debug.Assert( a != null ); + a[0] = (int)pIdx.pTable.nRowEst; + if ( a[0] < 10 ) + a[0] = 10; + n = 10; + for ( i = 1; i <= pIdx.nColumn; i++ ) + { + a[i] = n; + if ( n > 5 ) + n--; + } + if ( pIdx.onError != OE_None ) + { + a[pIdx.nColumn] = 1; + } + } + + /* + ** This routine will drop an existing named index. This routine + ** implements the DROP INDEX statement. + */ + static void sqlite3DropIndex( Parse pParse, SrcList pName, int ifExists ) + { + Index pIndex; + Vdbe v; + sqlite3 db = pParse.db; + int iDb; + + Debug.Assert( pParse.nErr == 0 ); /* Never called with prior errors */ + //if ( db.mallocFailed != 0 ) + //{ + // goto exit_drop_index; + //} + Debug.Assert( pName.nSrc == 1 ); + if ( SQLITE_OK != sqlite3ReadSchema( pParse ) ) + { + goto exit_drop_index; + } + pIndex = sqlite3FindIndex( db, pName.a[0].zName, pName.a[0].zDatabase ); + if ( pIndex == null ) + { + if ( ifExists == 0 ) + { + sqlite3ErrorMsg( pParse, "no such index: %S", pName, 0 ); + } + else + { + sqlite3CodeVerifyNamedSchema( pParse, pName.a[0].zDatabase ); + } + pParse.checkSchema = 1; + goto exit_drop_index; + } + if ( pIndex.autoIndex != 0 ) + { + sqlite3ErrorMsg( pParse, "index associated with UNIQUE " + + "or PRIMARY KEY constraint cannot be dropped", 0 ); + goto exit_drop_index; + } + iDb = sqlite3SchemaToIndex( db, pIndex.pSchema ); #if !SQLITE_OMIT_AUTHORIZATION { int code = SQLITE_DROP_INDEX; @@ -3154,866 +3464,959 @@ static void sqlite3DropIndex(Parse pParse, SrcList pName, int ifExists) { } #endif - /* Generate code to remove the index and from the master table */ - v = sqlite3GetVdbe(pParse); - if (v != null) { - sqlite3BeginWriteOperation(pParse, 1, iDb); - sqlite3NestedParse(pParse, - "DELETE FROM %Q.%s WHERE name=%Q AND type='index'", - db.aDb[iDb].zName, SCHEMA_TABLE(iDb), - pIndex.zName - ); - if (sqlite3FindTable(db, "sqlite_stat1", db.aDb[iDb].zName) != null) { - sqlite3NestedParse(pParse, - "DELETE FROM %Q.sqlite_stat1 WHERE idx=%Q", - db.aDb[iDb].zName, pIndex.zName - ); - } - sqlite3ChangeCookie(pParse, iDb); - destroyRootPage(pParse, pIndex.tnum, iDb); - sqlite3VdbeAddOp4(v, OP_DropIndex, iDb, 0, 0, pIndex.zName, 0); - } - - exit_drop_index: - sqlite3SrcListDelete(db, ref pName); + /* Generate code to remove the index and from the master table */ + v = sqlite3GetVdbe( pParse ); + if ( v != null ) + { + sqlite3BeginWriteOperation( pParse, 1, iDb ); + sqlite3NestedParse( pParse, + "DELETE FROM %Q.%s WHERE name=%Q AND type='index'", + db.aDb[iDb].zName, SCHEMA_TABLE( iDb ), + pIndex.zName + ); + if ( sqlite3FindTable( db, "sqlite_stat1", db.aDb[iDb].zName ) != null ) + { + sqlite3NestedParse( pParse, + "DELETE FROM %Q.sqlite_stat1 WHERE idx=%Q", + db.aDb[iDb].zName, pIndex.zName + ); } + sqlite3ChangeCookie( pParse, iDb ); + destroyRootPage( pParse, pIndex.tnum, iDb ); + sqlite3VdbeAddOp4( v, OP_DropIndex, iDb, 0, 0, pIndex.zName, 0 ); + } - /* - ** pArray is a pointer to an array of objects. Each object in the - ** array is szEntry bytes in size. This routine allocates a new - ** object on the end of the array. - ** - ** pnEntry is the number of entries already in use. pnAlloc is - ** the previously allocated size of the array. initSize is the - ** suggested initial array size allocation. - ** - ** The index of the new entry is returned in pIdx. - ** - ** This routine returns a pointer to the array of objects. This - ** might be the same as the pArray parameter or it might be a different - ** pointer if the array was resized. - */ - static T[] sqlite3ArrayAllocate( - sqlite3 db, /* Connection to notify of malloc failures */ - T[] pArray, /* Array of objects. Might be reallocated */ - int szEntry, /* Size of each object in the array */ - int initSize, /* Suggested initial allocation, in elements */ - ref int pnEntry, /* Number of objects currently in use */ - ref int pnAlloc, /* Current size of the allocation, in elements */ - ref int pIdx /* Write the index of a new slot here */ - ) where T : new() { - //char* z; - if (pnEntry >= pnAlloc) { - //void* pNew; - int newSize; - newSize = (pnAlloc) * 2 + initSize; - //pNew = sqlite3DbRealloc(db, pArray, newSize * szEntry); - //if (pNew == 0) - //{ - // pIdx = -1; - // return pArray; - //} - pnAlloc = newSize; //sqlite3DbMallocSize(db, pNew)/szEntry; - //pArray = pNew; - Array.Resize(ref pArray, newSize); - } - pArray[pnEntry] = new T(); - //z = (char)pArray; - //memset(z[*pnEntry * szEntry], 0, szEntry); - pIdx = pnEntry; - ++pnEntry; - return pArray; - } - - /* - ** Append a new element to the given IdList. Create a new IdList if - ** need be. - ** - ** A new IdList is returned, or NULL if malloc() fails. - */ - // OVERLOADS, so I don't need to rewrite parse.c - static IdList sqlite3IdListAppend(sqlite3 db, int null_2, Token pToken) { - return sqlite3IdListAppend(db, null, pToken); - } - static IdList sqlite3IdListAppend(sqlite3 db, IdList pList, Token pToken) { - int i = 0; - if (pList == null) { - pList = new IdList();//sqlite3DbMallocZero(db, sizeof(IdList)); - if (pList == null) - return null; - pList.nAlloc = 0; - } - pList.a = (IdList_item[])sqlite3ArrayAllocate( - db, - pList.a, - -1,//sizeof(pList.a[0]), - 5, - ref pList.nId, - ref pList.nAlloc, - ref i - ); - if (i < 0) { - sqlite3IdListDelete(db, ref pList); - return null; - } - pList.a[i].zName = sqlite3NameFromToken(db, pToken); - return pList; - } - - /* - ** Delete an IdList. - */ - static void sqlite3IdListDelete(sqlite3 db, ref IdList pList) { - int i; - if (pList == null) - return; - for (i = 0; i < pList.nId; i++) { - sqlite3DbFree(db, ref pList.a[i].zName); - } - sqlite3DbFree(db, ref pList.a); - sqlite3DbFree(db, ref pList); - } +exit_drop_index: + sqlite3SrcListDelete( db, ref pName ); + } - /* - ** Return the index in pList of the identifier named zId. Return -1 - ** if not found. - */ - static int sqlite3IdListIndex(IdList pList, string zName) { - int i; - if (pList == null) - return -1; - for (i = 0; i < pList.nId; i++) { - if (pList.a[i].zName.Equals(zName, StringComparison.OrdinalIgnoreCase)) - return i; - } - return -1; - } + /* + ** pArray is a pointer to an array of objects. Each object in the + ** array is szEntry bytes in size. This routine allocates a new + ** object on the end of the array. + ** + ** pnEntry is the number of entries already in use. pnAlloc is + ** the previously allocated size of the array. initSize is the + ** suggested initial array size allocation. + ** + ** The index of the new entry is returned in pIdx. + ** + ** This routine returns a pointer to the array of objects. This + ** might be the same as the pArray parameter or it might be a different + ** pointer if the array was resized. + */ + static T[] sqlite3ArrayAllocate( + sqlite3 db, /* Connection to notify of malloc failures */ + T[] pArray, /* Array of objects. Might be reallocated */ + int szEntry, /* Size of each object in the array */ + int initSize, /* Suggested initial allocation, in elements */ + ref int pnEntry, /* Number of objects currently in use */ + ref int pnAlloc, /* Current size of the allocation, in elements */ + ref int pIdx /* Write the index of a new slot here */ + ) where T : new() + { + //char* z; + if ( pnEntry >= pnAlloc ) + { + //void* pNew; + int newSize; + newSize = ( pnAlloc ) * 2 + initSize; + //pNew = sqlite3DbRealloc(db, pArray, newSize * szEntry); + //if (pNew == 0) + //{ + // pIdx = -1; + // return pArray; + //} + pnAlloc = newSize; //sqlite3DbMallocSize(db, pNew)/szEntry; + //pArray = pNew; + Array.Resize( ref pArray, newSize ); + } + pArray[pnEntry] = new T(); + //z = (char)pArray; + //memset(z[*pnEntry * szEntry], 0, szEntry); + pIdx = pnEntry; + ++pnEntry; + return pArray; + } - /* - ** Expand the space allocated for the given SrcList object by - ** creating nExtra new slots beginning at iStart. iStart is zero based. - ** New slots are zeroed. - ** - ** For example, suppose a SrcList initially contains two entries: A,B. - ** To append 3 new entries onto the end, do this: - ** - ** sqlite3SrcListEnlarge(db, pSrclist, 3, 2); - ** - ** After the call above it would contain: A, B, nil, nil, nil. - ** If the iStart argument had been 1 instead of 2, then the result - ** would have been: A, nil, nil, nil, B. To prepend the new slots, - ** the iStart value would be 0. The result then would - ** be: nil, nil, nil, A, B. - ** - ** If a memory allocation fails the SrcList is unchanged. The - ** db.mallocFailed flag will be set to true. - */ - static SrcList sqlite3SrcListEnlarge( - sqlite3 db, /* Database connection to notify of OOM errors */ - SrcList pSrc, /* The SrcList to be enlarged */ - int nExtra, /* Number of new slots to add to pSrc.a[] */ - int iStart /* Index in pSrc.a[] of first new slot */ - ) { - int i; + /* + ** Append a new element to the given IdList. Create a new IdList if + ** need be. + ** + ** A new IdList is returned, or NULL if malloc() fails. + */ + // OVERLOADS, so I don't need to rewrite parse.c + static IdList sqlite3IdListAppend( sqlite3 db, int null_2, Token pToken ) + { + return sqlite3IdListAppend( db, null, pToken ); + } + static IdList sqlite3IdListAppend( sqlite3 db, IdList pList, Token pToken ) + { + int i = 0; + if ( pList == null ) + { + pList = new IdList();//sqlite3DbMallocZero(db, sizeof(IdList)); + if ( pList == null ) + return null; + pList.nAlloc = 0; + } + pList.a = (IdList_item[])sqlite3ArrayAllocate( + db, + pList.a, + -1,//sizeof(pList.a[0]), + 5, + ref pList.nId, + ref pList.nAlloc, + ref i + ); + if ( i < 0 ) + { + sqlite3IdListDelete( db, ref pList ); + return null; + } + pList.a[i].zName = sqlite3NameFromToken( db, pToken ); + return pList; + } - /* Sanity checking on calling parameters */ - Debug.Assert(iStart >= 0); - Debug.Assert(nExtra >= 1); - Debug.Assert(pSrc != null); - Debug.Assert(iStart <= pSrc.nSrc); - - /* Allocate additional space if needed */ - if (pSrc.nSrc + nExtra > pSrc.nAlloc) { - int nAlloc = pSrc.nSrc + nExtra; - int nGot; - // sqlite3DbRealloc(db, pSrc, - // sizeof(*pSrc) + (nAlloc-1)*sizeof(pSrc.a[0]) ); - pSrc.nAlloc = (i16)nAlloc; - Array.Resize(ref pSrc.a, nAlloc); - // nGot = (sqlite3DbMallocSize(db, pNew) - sizeof(*pSrc))/sizeof(pSrc->a[0])+1; - //pSrc->nAlloc = (u16)nGot; - } + /* + ** Delete an IdList. + */ + static void sqlite3IdListDelete( sqlite3 db, ref IdList pList ) + { + int i; + if ( pList == null ) + return; + for ( i = 0; i < pList.nId; i++ ) + { + sqlite3DbFree( db, ref pList.a[i].zName ); + } + sqlite3DbFree( db, ref pList.a ); + sqlite3DbFree( db, ref pList ); + } - /* Move existing slots that come after the newly inserted slots - ** out of the way */ - for (i = pSrc.nSrc - 1; i >= iStart; i--) { - pSrc.a[i + nExtra] = pSrc.a[i]; - } - pSrc.nSrc += (i16)nExtra; + /* + ** Return the index in pList of the identifier named zId. Return -1 + ** if not found. + */ + static int sqlite3IdListIndex( IdList pList, string zName ) + { + int i; + if ( pList == null ) + return -1; + for ( i = 0; i < pList.nId; i++ ) + { + if ( pList.a[i].zName.Equals( zName, StringComparison.OrdinalIgnoreCase ) ) + return i; + } + return -1; + } - /* Zero the newly allocated slots */ - //memset(&pSrc.a[iStart], 0, sizeof(pSrc.a[0])*nExtra); - for (i = iStart; i < iStart + nExtra; i++) { - pSrc.a[i] = new SrcList_item(); - pSrc.a[i].iCursor = -1; - } + /* + ** Expand the space allocated for the given SrcList object by + ** creating nExtra new slots beginning at iStart. iStart is zero based. + ** New slots are zeroed. + ** + ** For example, suppose a SrcList initially contains two entries: A,B. + ** To append 3 new entries onto the end, do this: + ** + ** sqlite3SrcListEnlarge(db, pSrclist, 3, 2); + ** + ** After the call above it would contain: A, B, nil, nil, nil. + ** If the iStart argument had been 1 instead of 2, then the result + ** would have been: A, nil, nil, nil, B. To prepend the new slots, + ** the iStart value would be 0. The result then would + ** be: nil, nil, nil, A, B. + ** + ** If a memory allocation fails the SrcList is unchanged. The + ** db.mallocFailed flag will be set to true. + */ + static SrcList sqlite3SrcListEnlarge( + sqlite3 db, /* Database connection to notify of OOM errors */ + SrcList pSrc, /* The SrcList to be enlarged */ + int nExtra, /* Number of new slots to add to pSrc.a[] */ + int iStart /* Index in pSrc.a[] of first new slot */ + ) + { + int i; + + /* Sanity checking on calling parameters */ + Debug.Assert( iStart >= 0 ); + Debug.Assert( nExtra >= 1 ); + Debug.Assert( pSrc != null ); + Debug.Assert( iStart <= pSrc.nSrc ); + + /* Allocate additional space if needed */ + if ( pSrc.nSrc + nExtra > pSrc.nAlloc ) + { + int nAlloc = pSrc.nSrc + nExtra; + int nGot; + // sqlite3DbRealloc(db, pSrc, + // sizeof(*pSrc) + (nAlloc-1)*sizeof(pSrc.a[0]) ); + pSrc.nAlloc = (i16)nAlloc; + Array.Resize( ref pSrc.a, nAlloc ); + // nGot = (sqlite3DbMallocSize(db, pNew) - sizeof(*pSrc))/sizeof(pSrc->a[0])+1; + //pSrc->nAlloc = (u16)nGot; + } + + /* Move existing slots that come after the newly inserted slots + ** out of the way */ + for ( i = pSrc.nSrc - 1; i >= iStart; i-- ) + { + pSrc.a[i + nExtra] = pSrc.a[i]; + } + pSrc.nSrc += (i16)nExtra; + + /* Zero the newly allocated slots */ + //memset(&pSrc.a[iStart], 0, sizeof(pSrc.a[0])*nExtra); + for ( i = iStart; i < iStart + nExtra; i++ ) + { + pSrc.a[i] = new SrcList_item(); + pSrc.a[i].iCursor = -1; + } + + /* Return a pointer to the enlarged SrcList */ + return pSrc; + } - /* Return a pointer to the enlarged SrcList */ - return pSrc; - } + /* + ** Append a new table name to the given SrcList. Create a new SrcList if + ** need be. A new entry is created in the SrcList even if pTable is NULL. + ** + ** A SrcList is returned, or NULL if there is an OOM error. The returned + ** SrcList might be the same as the SrcList that was input or it might be + ** a new one. If an OOM error does occurs, then the prior value of pList + ** that is input to this routine is automatically freed. + ** + ** If pDatabase is not null, it means that the table has an optional + ** database name prefix. Like this: "database.table". The pDatabase + ** points to the table name and the pTable points to the database name. + ** The SrcList.a[].zName field is filled with the table name which might + ** come from pTable (if pDatabase is NULL) or from pDatabase. + ** SrcList.a[].zDatabase is filled with the database name from pTable, + ** or with NULL if no database is specified. + ** + ** In other words, if call like this: + ** + ** sqlite3SrcListAppend(D,A,B,0); + ** + ** Then B is a table name and the database name is unspecified. If called + ** like this: + ** + ** sqlite3SrcListAppend(D,A,B,C); + ** + ** Then C is the table name and B is the database name. If C is defined + ** then so is B. In other words, we never have a case where: + ** + ** sqlite3SrcListAppend(D,A,0,C); + ** + ** Both pTable and pDatabase are assumed to be quoted. They are dequoted + ** before being added to the SrcList. + */ + // OVERLOADS, so I don't need to rewrite parse.c + static SrcList sqlite3SrcListAppend( sqlite3 db, int null_2, Token pTable, int null_4 ) + { + return sqlite3SrcListAppend( db, null, pTable, null ); + } + static SrcList sqlite3SrcListAppend( sqlite3 db, int null_2, Token pTable, Token pDatabase ) + { + return sqlite3SrcListAppend( db, null, pTable, pDatabase ); + } + static SrcList sqlite3SrcListAppend( + sqlite3 db, /* Connection to notify of malloc failures */ + SrcList pList, /* Append to this SrcList. NULL creates a new SrcList */ + Token pTable, /* Table to append */ + Token pDatabase /* Database of the table */ + ) + { + SrcList_item pItem; + Debug.Assert( pDatabase == null || pTable != null ); /* Cannot have C without B */ + if ( pList == null ) + { + pList = new SrcList();//sqlite3DbMallocZero(db, SrcList.Length ); + //if ( pList == null ) return null; + pList.nAlloc = 1; + pList.a = new SrcList_item[1]; + } + pList = sqlite3SrcListEnlarge( db, pList, 1, pList.nSrc ); + //if ( db.mallocFailed != 0 ) + //{ + // sqlite3SrcListDelete( db, ref pList ); + // return null; + //} + pItem = pList.a[pList.nSrc - 1]; + if ( pDatabase != null && String.IsNullOrEmpty( pDatabase.z ) ) + { + pDatabase = null; + } + if ( pDatabase != null ) + { + Token pTemp = pDatabase; + pDatabase = pTable; + pTable = pTemp; + } + pItem.zName = sqlite3NameFromToken( db, pTable ); + pItem.zDatabase = sqlite3NameFromToken( db, pDatabase ); + return pList; + } - /* - ** Append a new table name to the given SrcList. Create a new SrcList if - ** need be. A new entry is created in the SrcList even if pTable is NULL. - ** - ** A SrcList is returned, or NULL if there is an OOM error. The returned - ** SrcList might be the same as the SrcList that was input or it might be - ** a new one. If an OOM error does occurs, then the prior value of pList - ** that is input to this routine is automatically freed. - ** - ** If pDatabase is not null, it means that the table has an optional - ** database name prefix. Like this: "database.table". The pDatabase - ** points to the table name and the pTable points to the database name. - ** The SrcList.a[].zName field is filled with the table name which might - ** come from pTable (if pDatabase is NULL) or from pDatabase. - ** SrcList.a[].zDatabase is filled with the database name from pTable, - ** or with NULL if no database is specified. - ** - ** In other words, if call like this: - ** - ** sqlite3SrcListAppend(D,A,B,0); - ** - ** Then B is a table name and the database name is unspecified. If called - ** like this: - ** - ** sqlite3SrcListAppend(D,A,B,C); - ** - ** Then C is the table name and B is the database name. If C is defined - ** then so is B. In other words, we never have a case where: - ** - ** sqlite3SrcListAppend(D,A,0,C); - ** - ** Both pTable and pDatabase are assumed to be quoted. They are dequoted - ** before being added to the SrcList. - */ - // OVERLOADS, so I don't need to rewrite parse.c - static SrcList sqlite3SrcListAppend(sqlite3 db, int null_2, Token pTable, int null_4) { - return sqlite3SrcListAppend(db, null, pTable, null); - } - static SrcList sqlite3SrcListAppend(sqlite3 db, int null_2, Token pTable, Token pDatabase) { - return sqlite3SrcListAppend(db, null, pTable, pDatabase); - } - static SrcList sqlite3SrcListAppend( - sqlite3 db, /* Connection to notify of malloc failures */ - SrcList pList, /* Append to this SrcList. NULL creates a new SrcList */ - Token pTable, /* Table to append */ - Token pDatabase /* Database of the table */ - ) { - SrcList_item pItem; - Debug.Assert(pDatabase == null || pTable != null); /* Cannot have C without B */ - if (pList == null) { - pList = new SrcList();//sqlite3DbMallocZero(db, SrcList.Length ); - //if ( pList == null ) return null; - pList.nAlloc = 1; - pList.a = new SrcList_item[1]; - } - pList = sqlite3SrcListEnlarge(db, pList, 1, pList.nSrc); - //if ( db.mallocFailed != 0 ) - //{ - // sqlite3SrcListDelete( db, ref pList ); - // return null; - //} - pItem = pList.a[pList.nSrc - 1]; - if (pDatabase != null && String.IsNullOrEmpty(pDatabase.z)) { - pDatabase = null; - } - if (pDatabase != null) { - Token pTemp = pDatabase; - pDatabase = pTable; - pTable = pTemp; - } - pItem.zName = sqlite3NameFromToken(db, pTable); - pItem.zDatabase = sqlite3NameFromToken(db, pDatabase); - return pList; + /* + ** Assign VdbeCursor index numbers to all tables in a SrcList + */ + static void sqlite3SrcListAssignCursors( Parse pParse, SrcList pList ) + { + int i; + SrcList_item pItem; + Debug.Assert( pList != null /* || pParse.db.mallocFailed != 0 */ ); + if ( pList != null ) + { + for ( i = 0; i < pList.nSrc; i++ ) + { + pItem = pList.a[i]; + if ( pItem.iCursor >= 0 ) + break; + pItem.iCursor = pParse.nTab++; + if ( pItem.pSelect != null ) + { + sqlite3SrcListAssignCursors( pParse, pItem.pSelect.pSrc ); + } } + } + } - /* - ** Assign VdbeCursor index numbers to all tables in a SrcList - */ - static void sqlite3SrcListAssignCursors(Parse pParse, SrcList pList) { - int i; - SrcList_item pItem; - Debug.Assert(pList != null /* || pParse.db.mallocFailed != 0 */ ); - if (pList != null) { - for (i = 0; i < pList.nSrc; i++) { - pItem = pList.a[i]; - if (pItem.iCursor >= 0) - break; - pItem.iCursor = pParse.nTab++; - if (pItem.pSelect != null) { - sqlite3SrcListAssignCursors(pParse, pItem.pSelect.pSrc); - } - } - } - } + /* + ** Delete an entire SrcList including all its substructure. + */ + static void sqlite3SrcListDelete( sqlite3 db, ref SrcList pList ) + { + int i; + SrcList_item pItem; + if ( pList == null ) + return; + for ( i = 0; i < pList.nSrc; i++ ) + {//, pItem++){ + pItem = pList.a[i]; + sqlite3DbFree( db, ref pItem.zDatabase ); + sqlite3DbFree( db, ref pItem.zName ); + sqlite3DbFree( db, ref pItem.zAlias ); + sqlite3DbFree( db, ref pItem.zIndex ); + sqlite3DeleteTable( db, ref pItem.pTab ); + sqlite3SelectDelete( db, ref pItem.pSelect ); + sqlite3ExprDelete( db, ref pItem.pOn ); + sqlite3IdListDelete( db, ref pItem.pUsing ); + } + sqlite3DbFree( db, ref pList ); + } - /* - ** Delete an entire SrcList including all its substructure. - */ - static void sqlite3SrcListDelete(sqlite3 db, ref SrcList pList) { - int i; - SrcList_item pItem; - if (pList == null) - return; - for (i = 0; i < pList.nSrc; i++) {//, pItem++){ - pItem = pList.a[i]; - sqlite3DbFree(db, ref pItem.zDatabase); - sqlite3DbFree(db, ref pItem.zName); - sqlite3DbFree(db, ref pItem.zAlias); - sqlite3DbFree(db, ref pItem.zIndex); - sqlite3DeleteTable(db, ref pItem.pTab); - sqlite3SelectDelete(db, ref pItem.pSelect); - sqlite3ExprDelete(db, ref pItem.pOn); - sqlite3IdListDelete(db, ref pItem.pUsing); - } - sqlite3DbFree(db, ref pList); - } + /* + ** This routine is called by the parser to add a new term to the + ** end of a growing FROM clause. The "p" parameter is the part of + ** the FROM clause that has already been constructed. "p" is NULL + ** if this is the first term of the FROM clause. pTable and pDatabase + ** are the name of the table and database named in the FROM clause term. + ** pDatabase is NULL if the database name qualifier is missing - the + ** usual case. If the term has a alias, then pAlias points to the + ** alias token. If the term is a subquery, then pSubquery is the + ** SELECT statement that the subquery encodes. The pTable and + ** pDatabase parameters are NULL for subqueries. The pOn and pUsing + ** parameters are the content of the ON and USING clauses. + ** + ** Return a new SrcList which encodes is the FROM with the new + ** term added. + */ + // OVERLOADS, so I don't need to rewrite parse.c + static SrcList sqlite3SrcListAppendFromTerm( Parse pParse, SrcList p, int null_3, int null_4, Token pAlias, Select pSubquery, Expr pOn, IdList pUsing ) + { + return sqlite3SrcListAppendFromTerm( pParse, p, null, null, pAlias, pSubquery, pOn, pUsing ); + } + static SrcList sqlite3SrcListAppendFromTerm( Parse pParse, SrcList p, Token pTable, Token pDatabase, Token pAlias, int null_6, Expr pOn, IdList pUsing ) + { + return sqlite3SrcListAppendFromTerm( pParse, p, pTable, pDatabase, pAlias, null, pOn, pUsing ); + } + static SrcList sqlite3SrcListAppendFromTerm( + Parse pParse, /* Parsing context */ + SrcList p, /* The left part of the FROM clause already seen */ + Token pTable, /* Name of the table to add to the FROM clause */ + Token pDatabase, /* Name of the database containing pTable */ + Token pAlias, /* The right-hand side of the AS subexpression */ + Select pSubquery, /* A subquery used in place of a table name */ + Expr pOn, /* The ON clause of a join */ + IdList pUsing /* The USING clause of a join */ + ) + { + SrcList_item pItem; + sqlite3 db = pParse.db; + if ( null == p && ( pOn != null || pUsing != null ) ) + { + sqlite3ErrorMsg( pParse, "a JOIN clause is required before %s", + ( pOn != null ? "ON" : "USING" ) + ); + goto append_from_error; + } + p = sqlite3SrcListAppend( db, p, pTable, pDatabase ); + //if ( p == null || NEVER( p.nSrc == 0 ) ) + //{ + // goto append_from_error; + //} + pItem = p.a[p.nSrc - 1]; + Debug.Assert( pAlias != null ); + if ( pAlias.n != 0 ) + { + pItem.zAlias = sqlite3NameFromToken( db, pAlias ); + } + pItem.pSelect = pSubquery; + pItem.pOn = pOn; + pItem.pUsing = pUsing; + return p; +append_from_error: + Debug.Assert( p == null ); + sqlite3ExprDelete( db, ref pOn ); + sqlite3IdListDelete( db, ref pUsing ); + sqlite3SelectDelete( db, ref pSubquery ); + return null; + } - /* - ** This routine is called by the parser to add a new term to the - ** end of a growing FROM clause. The "p" parameter is the part of - ** the FROM clause that has already been constructed. "p" is NULL - ** if this is the first term of the FROM clause. pTable and pDatabase - ** are the name of the table and database named in the FROM clause term. - ** pDatabase is NULL if the database name qualifier is missing - the - ** usual case. If the term has a alias, then pAlias points to the - ** alias token. If the term is a subquery, then pSubquery is the - ** SELECT statement that the subquery encodes. The pTable and - ** pDatabase parameters are NULL for subqueries. The pOn and pUsing - ** parameters are the content of the ON and USING clauses. - ** - ** Return a new SrcList which encodes is the FROM with the new - ** term added. - */ - // OVERLOADS, so I don't need to rewrite parse.c - static SrcList sqlite3SrcListAppendFromTerm(Parse pParse, SrcList p, int null_3, int null_4, Token pAlias, Select pSubquery, Expr pOn, IdList pUsing) { - return sqlite3SrcListAppendFromTerm(pParse, p, null, null, pAlias, pSubquery, pOn, pUsing); - } - static SrcList sqlite3SrcListAppendFromTerm(Parse pParse, SrcList p, Token pTable, Token pDatabase, Token pAlias, int null_6, Expr pOn, IdList pUsing) { - return sqlite3SrcListAppendFromTerm(pParse, p, pTable, pDatabase, pAlias, null, pOn, pUsing); - } - static SrcList sqlite3SrcListAppendFromTerm( - Parse pParse, /* Parsing context */ - SrcList p, /* The left part of the FROM clause already seen */ - Token pTable, /* Name of the table to add to the FROM clause */ - Token pDatabase, /* Name of the database containing pTable */ - Token pAlias, /* The right-hand side of the AS subexpression */ - Select pSubquery, /* A subquery used in place of a table name */ - Expr pOn, /* The ON clause of a join */ - IdList pUsing /* The USING clause of a join */ - ) { - SrcList_item pItem; - sqlite3 db = pParse.db; - if (null == p && (pOn != null || pUsing != null)) { - sqlite3ErrorMsg(pParse, "a JOIN clause is required before %s", - (pOn != null ? "ON" : "USING") - ); - goto append_from_error; - } - p = sqlite3SrcListAppend(db, p, pTable, pDatabase); - //if ( p == null || NEVER( p.nSrc == 0 ) ) - //{ - // goto append_from_error; - //} - pItem = p.a[p.nSrc - 1]; - Debug.Assert(pAlias != null); - if (pAlias.n != 0) { - pItem.zAlias = sqlite3NameFromToken(db, pAlias); - } - pItem.pSelect = pSubquery; - pItem.pOn = pOn; - pItem.pUsing = pUsing; - return p; - append_from_error: - Debug.Assert(p == null); - sqlite3ExprDelete(db, ref pOn); - sqlite3IdListDelete(db, ref pUsing); - sqlite3SelectDelete(db, ref pSubquery); - return null; + /* + ** Add an INDEXED BY or NOT INDEXED clause to the most recently added + ** element of the source-list passed as the second argument. + */ + static void sqlite3SrcListIndexedBy( Parse pParse, SrcList p, Token pIndexedBy ) + { + Debug.Assert( pIndexedBy != null ); + if ( p != null && ALWAYS( p.nSrc > 0 ) ) + { + SrcList_item pItem = p.a[p.nSrc - 1]; + Debug.Assert( 0 == pItem.notIndexed && pItem.zIndex == null ); + if ( pIndexedBy.n == 1 && null == pIndexedBy.z ) + { + /* A "NOT INDEXED" clause was supplied. See parse.y + ** construct "indexed_opt" for details. */ + pItem.notIndexed = 1; } - - /* - ** Add an INDEXED BY or NOT INDEXED clause to the most recently added - ** element of the source-list passed as the second argument. - */ - static void sqlite3SrcListIndexedBy(Parse pParse, SrcList p, Token pIndexedBy) { - Debug.Assert(pIndexedBy != null); - if (p != null && ALWAYS(p.nSrc > 0)) { - SrcList_item pItem = p.a[p.nSrc - 1]; - Debug.Assert(0 == pItem.notIndexed && pItem.zIndex == null); - if (pIndexedBy.n == 1 && null == pIndexedBy.z) { - /* A "NOT INDEXED" clause was supplied. See parse.y - ** construct "indexed_opt" for details. */ - pItem.notIndexed = 1; - } else { - pItem.zIndex = sqlite3NameFromToken(pParse.db, pIndexedBy); - } - } + else + { + pItem.zIndex = sqlite3NameFromToken( pParse.db, pIndexedBy ); } + } + } - /* - ** When building up a FROM clause in the parser, the join operator - ** is initially attached to the left operand. But the code generator - ** expects the join operator to be on the right operand. This routine - ** Shifts all join operators from left to right for an entire FROM - ** clause. - ** - ** Example: Suppose the join is like this: - ** - ** A natural cross join B - ** - ** The operator is "natural cross join". The A and B operands are stored - ** in p.a[0] and p.a[1], respectively. The parser initially stores the - ** operator with A. This routine shifts that operator over to B. - */ - static void sqlite3SrcListShiftJoinType(SrcList p) { - if (p != null && p.a != null) { - int i; - for (i = p.nSrc - 1; i > 0; i--) { - p.a[i].jointype = p.a[i - 1].jointype; - } - p.a[0].jointype = 0; - } + /* + ** When building up a FROM clause in the parser, the join operator + ** is initially attached to the left operand. But the code generator + ** expects the join operator to be on the right operand. This routine + ** Shifts all join operators from left to right for an entire FROM + ** clause. + ** + ** Example: Suppose the join is like this: + ** + ** A natural cross join B + ** + ** The operator is "natural cross join". The A and B operands are stored + ** in p.a[0] and p.a[1], respectively. The parser initially stores the + ** operator with A. This routine shifts that operator over to B. + */ + static void sqlite3SrcListShiftJoinType( SrcList p ) + { + if ( p != null && p.a != null ) + { + int i; + for ( i = p.nSrc - 1; i > 0; i-- ) + { + p.a[i].jointype = p.a[i - 1].jointype; } + p.a[0].jointype = 0; + } + } - /* - ** Begin a transaction - */ - static void sqlite3BeginTransaction(Parse pParse, int type) { - sqlite3 db; - Vdbe v; - int i; - - Debug.Assert(pParse != null); - db = pParse.db; - Debug.Assert(db != null); - /* if( db.aDb[0].pBt==0 ) return; */ - if (sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "BEGIN", null, null) != 0) { - return; - } - v = sqlite3GetVdbe(pParse); - if (v == null) - return; - if (type != TK_DEFERRED) { - for (i = 0; i < db.nDb; i++) { - sqlite3VdbeAddOp2(v, OP_Transaction, i, (type == TK_EXCLUSIVE) ? 2 : 1); - sqlite3VdbeUsesBtree(v, i); - } - } - sqlite3VdbeAddOp2(v, OP_AutoCommit, 0, 0); + /* + ** Begin a transaction + */ + static void sqlite3BeginTransaction( Parse pParse, int type ) + { + sqlite3 db; + Vdbe v; + int i; + + Debug.Assert( pParse != null ); + db = pParse.db; + Debug.Assert( db != null ); + /* if( db.aDb[0].pBt==0 ) return; */ + if ( sqlite3AuthCheck( pParse, SQLITE_TRANSACTION, "BEGIN", null, null ) != 0 ) + { + return; + } + v = sqlite3GetVdbe( pParse ); + if ( v == null ) + return; + if ( type != TK_DEFERRED ) + { + for ( i = 0; i < db.nDb; i++ ) + { + sqlite3VdbeAddOp2( v, OP_Transaction, i, ( type == TK_EXCLUSIVE ) ? 2 : 1 ); + sqlite3VdbeUsesBtree( v, i ); } + } + sqlite3VdbeAddOp2( v, OP_AutoCommit, 0, 0 ); + } - /* - ** Commit a transaction - */ - static void sqlite3CommitTransaction(Parse pParse) { - sqlite3 db; - Vdbe v; - - Debug.Assert(pParse != null); - db = pParse.db; - Debug.Assert(db != null); - /* if( db.aDb[0].pBt==0 ) return; */ - if (sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "COMMIT", null, null) != 0) { - return; - } - v = sqlite3GetVdbe(pParse); - if (v != null) { - sqlite3VdbeAddOp2(v, OP_AutoCommit, 1, 0); - } - } + /* + ** Commit a transaction + */ + static void sqlite3CommitTransaction( Parse pParse ) + { + sqlite3 db; + Vdbe v; + + Debug.Assert( pParse != null ); + db = pParse.db; + Debug.Assert( db != null ); + /* if( db.aDb[0].pBt==0 ) return; */ + if ( sqlite3AuthCheck( pParse, SQLITE_TRANSACTION, "COMMIT", null, null ) != 0 ) + { + return; + } + v = sqlite3GetVdbe( pParse ); + if ( v != null ) + { + sqlite3VdbeAddOp2( v, OP_AutoCommit, 1, 0 ); + } + } - /* - ** Rollback a transaction - */ - static void sqlite3RollbackTransaction(Parse pParse) { - sqlite3 db; - Vdbe v; - - Debug.Assert(pParse != null); - db = pParse.db; - Debug.Assert(db != null); - /* if( db.aDb[0].pBt==0 ) return; */ - if (sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "ROLLBACK", null, null) != 0) { - return; - } - v = sqlite3GetVdbe(pParse); - if (v != null) { - sqlite3VdbeAddOp2(v, OP_AutoCommit, 1, 1); - } - } + /* + ** Rollback a transaction + */ + static void sqlite3RollbackTransaction( Parse pParse ) + { + sqlite3 db; + Vdbe v; + + Debug.Assert( pParse != null ); + db = pParse.db; + Debug.Assert( db != null ); + /* if( db.aDb[0].pBt==0 ) return; */ + if ( sqlite3AuthCheck( pParse, SQLITE_TRANSACTION, "ROLLBACK", null, null ) != 0 ) + { + return; + } + v = sqlite3GetVdbe( pParse ); + if ( v != null ) + { + sqlite3VdbeAddOp2( v, OP_AutoCommit, 1, 1 ); + } + } - /* - ** This function is called by the parser when it parses a command to create, - ** release or rollback an SQL savepoint. - */ + /* + ** This function is called by the parser when it parses a command to create, + ** release or rollback an SQL savepoint. + */ #if !SQLITE_OMIT_AUTHORIZATION const string[] az = { "BEGIN", "RELEASE", "ROLLBACK" }; #endif - static void sqlite3Savepoint(Parse pParse, int op, Token pName) { - string zName = sqlite3NameFromToken(pParse.db, pName); - if (zName != null) { - Vdbe v = sqlite3GetVdbe(pParse); + static void sqlite3Savepoint( Parse pParse, int op, Token pName ) + { + string zName = sqlite3NameFromToken( pParse.db, pName ); + if ( zName != null ) + { + Vdbe v = sqlite3GetVdbe( pParse ); #if !SQLITE_OMIT_AUTHORIZATION Debug.Assert( !SAVEPOINT_BEGIN && SAVEPOINT_RELEASE==1 && SAVEPOINT_ROLLBACK==2 ); #endif - if (null == v + if ( null == v #if !SQLITE_OMIT_AUTHORIZATION || sqlite3AuthCheck(pParse, SQLITE_SAVEPOINT, az[op], zName, 0) #endif - ) { - sqlite3DbFree(pParse.db, ref zName); - return; - } - sqlite3VdbeAddOp4(v, OP_Savepoint, op, 0, 0, zName, P4_DYNAMIC); - } + ) + { + sqlite3DbFree( pParse.db, ref zName ); + return; } + sqlite3VdbeAddOp4( v, OP_Savepoint, op, 0, 0, zName, P4_DYNAMIC ); + } + } - /* - ** Make sure the TEMP database is open and available for use. Return - ** the number of errors. Leave any error messages in the pParse structure. - */ - static int sqlite3OpenTempDatabase(Parse pParse) { - sqlite3 db = pParse.db; - if (db.aDb[1].pBt == null && pParse.explain == 0) { - int rc; - Btree pBt = null; - const int flags = - SQLITE_OPEN_READWRITE | - SQLITE_OPEN_CREATE | - SQLITE_OPEN_EXCLUSIVE | - SQLITE_OPEN_DELETEONCLOSE | - SQLITE_OPEN_TEMP_DB; - - rc = sqlite3BtreeOpen(db.pVfs, null, db, ref pBt, 0, flags); - if (rc != SQLITE_OK) { - sqlite3ErrorMsg(pParse, "unable to open a temporary database " + - "file for storing temporary tables"); - pParse.rc = rc; - return 1; - } - db.aDb[1].pBt = pBt; - Debug.Assert(db.aDb[1].pSchema != null); - if (SQLITE_NOMEM == sqlite3BtreeSetPageSize(pBt, db.nextPagesize, -1, 0)) { - // db.mallocFailed = 1; - } - } - return 0; + /* + ** Make sure the TEMP database is open and available for use. Return + ** the number of errors. Leave any error messages in the pParse structure. + */ + static int sqlite3OpenTempDatabase( Parse pParse ) + { + sqlite3 db = pParse.db; + if ( db.aDb[1].pBt == null && pParse.explain == 0 ) + { + int rc; + Btree pBt = null; + const int flags = + SQLITE_OPEN_READWRITE | + SQLITE_OPEN_CREATE | + SQLITE_OPEN_EXCLUSIVE | + SQLITE_OPEN_DELETEONCLOSE | + SQLITE_OPEN_TEMP_DB; + + rc = sqlite3BtreeOpen(db.pVfs, null, db, ref pBt, 0, flags ); + if ( rc != SQLITE_OK ) + { + sqlite3ErrorMsg( pParse, "unable to open a temporary database " + + "file for storing temporary tables" ); + pParse.rc = rc; + return 1; } - - /* - ** Generate VDBE code that will verify the schema cookie and start - ** a read-transaction for all named database files. - ** - ** It is important that all schema cookies be verified and all - ** read transactions be started before anything else happens in - ** the VDBE program. But this routine can be called after much other - ** code has been generated. So here is what we do: - ** - ** The first time this routine is called, we code an OP_Goto that - ** will jump to a subroutine at the end of the program. Then we - ** record every database that needs its schema verified in the - ** pParse.cookieMask field. Later, after all other code has been - ** generated, the subroutine that does the cookie verifications and - ** starts the transactions will be coded and the OP_Goto P2 value - ** will be made to point to that subroutine. The generation of the - ** cookie verification subroutine code happens in sqlite3FinishCoding(). - ** - ** If iDb<0 then code the OP_Goto only - don't set flag to verify the - ** schema on any databases. This can be used to position the OP_Goto - ** early in the code, before we know if any database tables will be used. - */ - static void sqlite3CodeVerifySchema(Parse pParse, int iDb) { - Parse pToplevel = sqlite3ParseToplevel(pParse); - - if (pToplevel.cookieGoto == 0) { - Vdbe v = sqlite3GetVdbe(pToplevel); - if (v == null) - return; /* This only happens if there was a prior error */ - pToplevel.cookieGoto = sqlite3VdbeAddOp2(v, OP_Goto, 0, 0) + 1; - } - if (iDb >= 0) { - sqlite3 db = pToplevel.db; - yDbMask mask; - Debug.Assert(iDb < db.nDb); - Debug.Assert(db.aDb[iDb].pBt != null || iDb == 1); - Debug.Assert(iDb < SQLITE_MAX_ATTACHED + 2); - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); - mask = ((yDbMask)1) << iDb; - if ((pToplevel.cookieMask & mask) == 0) { - pToplevel.cookieMask |= mask; - pToplevel.cookieValue[iDb] = db.aDb[iDb].pSchema.schema_cookie; - if (0 == OMIT_TEMPDB && iDb == 1) { - sqlite3OpenTempDatabase(pToplevel); - } - } - } + db.aDb[1].pBt = pBt; + Debug.Assert( db.aDb[1].pSchema != null ); + if ( SQLITE_NOMEM == sqlite3BtreeSetPageSize( pBt, db.nextPagesize, -1, 0 ) ) + { + // db.mallocFailed = 1; } + } + return 0; + } - /* - ** If argument zDb is NULL, then call sqlite3CodeVerifySchema() for each - ** attached database. Otherwise, invoke it for the database named zDb only. - */ - static void sqlite3CodeVerifyNamedSchema(Parse pParse, string zDb) { - sqlite3 db = pParse.db; - int i; - for (i = 0; i < db.nDb; i++) { - Db pDb = db.aDb[i]; - if (pDb.pBt != null && (null == zDb || string.Equals(zDb, pDb.zName, StringComparison.Ordinal))) { - sqlite3CodeVerifySchema(pParse, i); - } - } - } - /* - ** Generate VDBE code that prepares for doing an operation that - ** might change the database. - ** - ** This routine starts a new transaction if we are not already within - ** a transaction. If we are already within a transaction, then a checkpoint - ** is set if the setStatement parameter is true. A checkpoint should - ** be set for operations that might fail (due to a constraint) part of - ** the way through and which will need to undo some writes without having to - ** rollback the whole transaction. For operations where all constraints - ** can be checked before any changes are made to the database, it is never - ** necessary to undo a write and the checkpoint should not be set. - */ - static void sqlite3BeginWriteOperation(Parse pParse, int setStatement, int iDb) { - Parse pToplevel = sqlite3ParseToplevel(pParse); - sqlite3CodeVerifySchema(pParse, iDb); - pToplevel.writeMask |= ((yDbMask)1) << iDb; - pToplevel.isMultiWrite |= (u8)setStatement; + /* + ** Generate VDBE code that will verify the schema cookie and start + ** a read-transaction for all named database files. + ** + ** It is important that all schema cookies be verified and all + ** read transactions be started before anything else happens in + ** the VDBE program. But this routine can be called after much other + ** code has been generated. So here is what we do: + ** + ** The first time this routine is called, we code an OP_Goto that + ** will jump to a subroutine at the end of the program. Then we + ** record every database that needs its schema verified in the + ** pParse.cookieMask field. Later, after all other code has been + ** generated, the subroutine that does the cookie verifications and + ** starts the transactions will be coded and the OP_Goto P2 value + ** will be made to point to that subroutine. The generation of the + ** cookie verification subroutine code happens in sqlite3FinishCoding(). + ** + ** If iDb<0 then code the OP_Goto only - don't set flag to verify the + ** schema on any databases. This can be used to position the OP_Goto + ** early in the code, before we know if any database tables will be used. + */ + static void sqlite3CodeVerifySchema( Parse pParse, int iDb ) + { + Parse pToplevel = sqlite3ParseToplevel( pParse ); + + if ( pToplevel.cookieGoto == 0 ) + { + Vdbe v = sqlite3GetVdbe( pToplevel ); + if ( v == null ) + return; /* This only happens if there was a prior error */ + pToplevel.cookieGoto = sqlite3VdbeAddOp2( v, OP_Goto, 0, 0 ) + 1; + } + if ( iDb >= 0 ) + { + sqlite3 db = pToplevel.db; + yDbMask mask; + Debug.Assert( iDb < db.nDb ); + Debug.Assert( db.aDb[iDb].pBt != null || iDb == 1 ); + Debug.Assert( iDb < SQLITE_MAX_ATTACHED + 2 ); + Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); + mask = ( (yDbMask)1 ) << iDb; + if ( ( pToplevel.cookieMask & mask ) == 0 ) + { + pToplevel.cookieMask |= mask; + pToplevel.cookieValue[iDb] = db.aDb[iDb].pSchema.schema_cookie; + if ( 0 == OMIT_TEMPDB && iDb == 1 ) + { + sqlite3OpenTempDatabase( pToplevel ); + } } + } + } - /* - ** Indicate that the statement currently under construction might write - ** more than one entry (example: deleting one row then inserting another, - ** inserting multiple rows in a table, or inserting a row and index entries.) - ** If an abort occurs after some of these writes have completed, then it will - ** be necessary to undo the completed writes. - */ - static void sqlite3MultiWrite(Parse pParse) { - Parse pToplevel = sqlite3ParseToplevel(pParse); - pToplevel.isMultiWrite = 1; + /* + ** If argument zDb is NULL, then call sqlite3CodeVerifySchema() for each + ** attached database. Otherwise, invoke it for the database named zDb only. + */ + static void sqlite3CodeVerifyNamedSchema( Parse pParse, string zDb ) + { + sqlite3 db = pParse.db; + int i; + for ( i = 0; i < db.nDb; i++ ) + { + Db pDb = db.aDb[i]; + if ( pDb.pBt != null && ( null == zDb || string.Equals( zDb, pDb.zName, StringComparison.Ordinal ) ) ) + { + sqlite3CodeVerifySchema( pParse, i ); } + } + } + /* + ** Generate VDBE code that prepares for doing an operation that + ** might change the database. + ** + ** This routine starts a new transaction if we are not already within + ** a transaction. If we are already within a transaction, then a checkpoint + ** is set if the setStatement parameter is true. A checkpoint should + ** be set for operations that might fail (due to a constraint) part of + ** the way through and which will need to undo some writes without having to + ** rollback the whole transaction. For operations where all constraints + ** can be checked before any changes are made to the database, it is never + ** necessary to undo a write and the checkpoint should not be set. + */ + static void sqlite3BeginWriteOperation( Parse pParse, int setStatement, int iDb ) + { + Parse pToplevel = sqlite3ParseToplevel( pParse ); + sqlite3CodeVerifySchema( pParse, iDb ); + pToplevel.writeMask |= ( (yDbMask)1 ) << iDb; + pToplevel.isMultiWrite |= (u8)setStatement; + } - /* - ** The code generator calls this routine if is discovers that it is - ** possible to abort a statement prior to completion. In order to - ** perform this abort without corrupting the database, we need to make - ** sure that the statement is protected by a statement transaction. - ** - ** Technically, we only need to set the mayAbort flag if the - ** isMultiWrite flag was previously set. There is a time dependency - ** such that the abort must occur after the multiwrite. This makes - ** some statements involving the REPLACE conflict resolution algorithm - ** go a little faster. But taking advantage of this time dependency - ** makes it more difficult to prove that the code is correct (in - ** particular, it prevents us from writing an effective - ** implementation of sqlite3AssertMayAbort()) and so we have chosen - ** to take the safe route and skip the optimization. - */ - static void sqlite3MayAbort(Parse pParse) { - Parse pToplevel = sqlite3ParseToplevel(pParse); - pToplevel.mayAbort = 1; - } + /* + ** Indicate that the statement currently under construction might write + ** more than one entry (example: deleting one row then inserting another, + ** inserting multiple rows in a table, or inserting a row and index entries.) + ** If an abort occurs after some of these writes have completed, then it will + ** be necessary to undo the completed writes. + */ + static void sqlite3MultiWrite( Parse pParse ) + { + Parse pToplevel = sqlite3ParseToplevel( pParse ); + pToplevel.isMultiWrite = 1; + } - /* - ** Code an OP_Halt that causes the vdbe to return an SQLITE_CONSTRAINT - ** error. The onError parameter determines which (if any) of the statement - ** and/or current transaction is rolled back. - */ - static void sqlite3HaltConstraint(Parse pParse, int onError, string p4, int p4type) { - Vdbe v = sqlite3GetVdbe(pParse); - if (onError == OE_Abort) { - sqlite3MayAbort(pParse); - } - sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_CONSTRAINT, onError, 0, p4, p4type); - } + /* + ** The code generator calls this routine if is discovers that it is + ** possible to abort a statement prior to completion. In order to + ** perform this abort without corrupting the database, we need to make + ** sure that the statement is protected by a statement transaction. + ** + ** Technically, we only need to set the mayAbort flag if the + ** isMultiWrite flag was previously set. There is a time dependency + ** such that the abort must occur after the multiwrite. This makes + ** some statements involving the REPLACE conflict resolution algorithm + ** go a little faster. But taking advantage of this time dependency + ** makes it more difficult to prove that the code is correct (in + ** particular, it prevents us from writing an effective + ** implementation of sqlite3AssertMayAbort()) and so we have chosen + ** to take the safe route and skip the optimization. + */ + static void sqlite3MayAbort( Parse pParse ) + { + Parse pToplevel = sqlite3ParseToplevel( pParse ); + pToplevel.mayAbort = 1; + } - static void sqlite3HaltConstraint(Parse pParse, int onError, byte[] p4, int p4type) { - Vdbe v = sqlite3GetVdbe(pParse); - if (onError == OE_Abort) { - sqlite3MayAbort(pParse); - } - sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_CONSTRAINT, onError, 0, p4, p4type); - } + /* + ** Code an OP_Halt that causes the vdbe to return an SQLITE_CONSTRAINT + ** error. The onError parameter determines which (if any) of the statement + ** and/or current transaction is rolled back. + */ + static void sqlite3HaltConstraint( Parse pParse, int onError, string p4, int p4type ) + { + Vdbe v = sqlite3GetVdbe( pParse ); + if ( onError == OE_Abort ) + { + sqlite3MayAbort( pParse ); + } + sqlite3VdbeAddOp4( v, OP_Halt, SQLITE_CONSTRAINT, onError, 0, p4, p4type ); + } - /* - ** Check to see if pIndex uses the collating sequence pColl. Return - ** true if it does and false if it does not. - */ + static void sqlite3HaltConstraint( Parse pParse, int onError, byte[] p4, int p4type ) + { + Vdbe v = sqlite3GetVdbe( pParse ); + if ( onError == OE_Abort ) + { + sqlite3MayAbort( pParse ); + } + sqlite3VdbeAddOp4( v, OP_Halt, SQLITE_CONSTRAINT, onError, 0, p4, p4type ); + } + + /* + ** Check to see if pIndex uses the collating sequence pColl. Return + ** true if it does and false if it does not. + */ #if !SQLITE_OMIT_REINDEX - static bool collationMatch(string zColl, Index pIndex) { - int i; - Debug.Assert(zColl != null); - for (i = 0; i < pIndex.nColumn; i++) { - string z = pIndex.azColl[i]; - Debug.Assert(z != null); - if (z.Equals(zColl, StringComparison.OrdinalIgnoreCase)) { - return true; - } - } - return false; + static bool collationMatch( string zColl, Index pIndex ) + { + int i; + Debug.Assert( zColl != null ); + for ( i = 0; i < pIndex.nColumn; i++ ) + { + string z = pIndex.azColl[i]; + Debug.Assert( z != null ); + if ( z.Equals( zColl, StringComparison.OrdinalIgnoreCase ) ) + { + return true; } + } + return false; + } #endif - /* - ** Recompute all indices of pTab that use the collating sequence pColl. - ** If pColl == null then recompute all indices of pTab. - */ + /* +** Recompute all indices of pTab that use the collating sequence pColl. +** If pColl == null then recompute all indices of pTab. +*/ #if !SQLITE_OMIT_REINDEX - static void reindexTable(Parse pParse, Table pTab, string zColl) { - Index pIndex; /* An index associated with pTab */ - - for (pIndex = pTab.pIndex; pIndex != null; pIndex = pIndex.pNext) { - if (zColl == null || collationMatch(zColl, pIndex)) { - int iDb = sqlite3SchemaToIndex(pParse.db, pTab.pSchema); - sqlite3BeginWriteOperation(pParse, 0, iDb); - sqlite3RefillIndex(pParse, pIndex, -1); - } - } + static void reindexTable( Parse pParse, Table pTab, string zColl ) + { + Index pIndex; /* An index associated with pTab */ + + for ( pIndex = pTab.pIndex; pIndex != null; pIndex = pIndex.pNext ) + { + if ( zColl == null || collationMatch( zColl, pIndex ) ) + { + int iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema ); + sqlite3BeginWriteOperation( pParse, 0, iDb ); + sqlite3RefillIndex( pParse, pIndex, -1 ); } + } + } #endif - /* - ** Recompute all indices of all tables in all databases where the - ** indices use the collating sequence pColl. If pColl == null then recompute - ** all indices everywhere. - */ + /* +** Recompute all indices of all tables in all databases where the +** indices use the collating sequence pColl. If pColl == null then recompute +** all indices everywhere. +*/ #if !SQLITE_OMIT_REINDEX - static void reindexDatabases(Parse pParse, string zColl) { - Db pDb; /* A single database */ - int iDb; /* The database index number */ - sqlite3 db = pParse.db; /* The database connection */ - HashElem k; /* For looping over tables in pDb */ - Table pTab; /* A table in the database */ - - Debug.Assert(sqlite3BtreeHoldsAllMutexes(db)); /* Needed for schema access */ - for (iDb = 0; iDb < db.nDb; iDb++)//, pDb++ ) - { - pDb = db.aDb[iDb]; - Debug.Assert(pDb != null); - for (k = pDb.pSchema.tblHash.first; k != null; k = k.next) //for ( k = sqliteHashFirst( pDb.pSchema.tblHash ) ; k != null ; k = sqliteHashNext( k ) ) - { - pTab = (Table)k.data;// sqliteHashData( k ); - reindexTable(pParse, pTab, zColl); - } - } + static void reindexDatabases( Parse pParse, string zColl ) + { + Db pDb; /* A single database */ + int iDb; /* The database index number */ + sqlite3 db = pParse.db; /* The database connection */ + HashElem k; /* For looping over tables in pDb */ + Table pTab; /* A table in the database */ + + Debug.Assert( sqlite3BtreeHoldsAllMutexes( db ) ); /* Needed for schema access */ + for ( iDb = 0; iDb < db.nDb; iDb++ )//, pDb++ ) + { + pDb = db.aDb[iDb]; + Debug.Assert( pDb != null ); + for ( k = pDb.pSchema.tblHash.first; k != null; k = k.next ) //for ( k = sqliteHashFirst( pDb.pSchema.tblHash ) ; k != null ; k = sqliteHashNext( k ) ) + { + pTab = (Table)k.data;// sqliteHashData( k ); + reindexTable( pParse, pTab, zColl ); } + } + } #endif - /* - ** Generate code for the REINDEX command. - ** - ** REINDEX -- 1 - ** REINDEX -- 2 - ** REINDEX ?.? -- 3 - ** REINDEX ?.? -- 4 - ** - ** Form 1 causes all indices in all attached databases to be rebuilt. - ** Form 2 rebuilds all indices in all databases that use the named - ** collating function. Forms 3 and 4 rebuild the named index or all - ** indices associated with the named table. - */ + /* +** Generate code for the REINDEX command. +** +** REINDEX -- 1 +** REINDEX -- 2 +** REINDEX ?.? -- 3 +** REINDEX ?.? -- 4 +** +** Form 1 causes all indices in all attached databases to be rebuilt. +** Form 2 rebuilds all indices in all databases that use the named +** collating function. Forms 3 and 4 rebuild the named index or all +** indices associated with the named table. +*/ #if !SQLITE_OMIT_REINDEX - // OVERLOADS, so I don't need to rewrite parse.c - static void sqlite3Reindex(Parse pParse, int null_2, int null_3) { - sqlite3Reindex(pParse, null, null); - } - static void sqlite3Reindex(Parse pParse, Token pName1, Token pName2) { - CollSeq pColl; /* Collating sequence to be reindexed, or NULL */ - string z; /* Name of a table or index */ - string zDb; /* Name of the database */ - Table pTab; /* A table in the database */ - Index pIndex; /* An index associated with pTab */ - int iDb; /* The database index number */ - sqlite3 db = pParse.db; /* The database connection */ - Token pObjName = new Token(); /* Name of the table or index to be reindexed */ - - /* Read the database schema. If an error occurs, leave an error message - ** and code in pParse and return NULL. */ - if (SQLITE_OK != sqlite3ReadSchema(pParse)) { - return; - } - - if (pName1 == null) { - reindexDatabases(pParse, null); - return; - } else if (NEVER(pName2 == null) || pName2.z == null || pName2.z.Length == 0) { - string zColl; - Debug.Assert(pName1.z != null); - zColl = sqlite3NameFromToken(pParse.db, pName1); - if (zColl == null) - return; - pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0); - if (pColl != null) { - reindexDatabases(pParse, zColl); - sqlite3DbFree(db, ref zColl); - return; - } - sqlite3DbFree(db, ref zColl); - } - iDb = sqlite3TwoPartName(pParse, pName1, pName2, ref pObjName); - if (iDb < 0) - return; - z = sqlite3NameFromToken(db, pObjName); - if (z == null) - return; - zDb = db.aDb[iDb].zName; - pTab = sqlite3FindTable(db, z, zDb); - if (pTab != null) { - reindexTable(pParse, pTab, null); - sqlite3DbFree(db, ref z); - return; - } - pIndex = sqlite3FindIndex(db, z, zDb); - sqlite3DbFree(db, ref z); - if (pIndex != null) { - sqlite3BeginWriteOperation(pParse, 0, iDb); - sqlite3RefillIndex(pParse, pIndex, -1); - return; - } - sqlite3ErrorMsg(pParse, "unable to identify the object to be reindexed"); + // OVERLOADS, so I don't need to rewrite parse.c + static void sqlite3Reindex( Parse pParse, int null_2, int null_3 ) + { + sqlite3Reindex( pParse, null, null ); + } + static void sqlite3Reindex( Parse pParse, Token pName1, Token pName2 ) + { + CollSeq pColl; /* Collating sequence to be reindexed, or NULL */ + string z; /* Name of a table or index */ + string zDb; /* Name of the database */ + Table pTab; /* A table in the database */ + Index pIndex; /* An index associated with pTab */ + int iDb; /* The database index number */ + sqlite3 db = pParse.db; /* The database connection */ + Token pObjName = new Token(); /* Name of the table or index to be reindexed */ + + /* Read the database schema. If an error occurs, leave an error message + ** and code in pParse and return NULL. */ + if ( SQLITE_OK != sqlite3ReadSchema( pParse ) ) + { + return; + } + + if ( pName1 == null ) + { + reindexDatabases( pParse, null ); + return; + } + else if ( NEVER( pName2 == null ) || pName2.z == null || pName2.z.Length == 0 ) + { + string zColl; + Debug.Assert( pName1.z != null ); + zColl = sqlite3NameFromToken( pParse.db, pName1 ); + if ( zColl == null ) + return; + pColl = sqlite3FindCollSeq( db, ENC( db ), zColl, 0 ); + if ( pColl != null ) + { + reindexDatabases( pParse, zColl ); + sqlite3DbFree( db, ref zColl ); + return; } + sqlite3DbFree( db, ref zColl ); + } + iDb = sqlite3TwoPartName( pParse, pName1, pName2, ref pObjName ); + if ( iDb < 0 ) + return; + z = sqlite3NameFromToken( db, pObjName ); + if ( z == null ) + return; + zDb = db.aDb[iDb].zName; + pTab = sqlite3FindTable( db, z, zDb ); + if ( pTab != null ) + { + reindexTable( pParse, pTab, null ); + sqlite3DbFree( db, ref z ); + return; + } + pIndex = sqlite3FindIndex( db, z, zDb ); + sqlite3DbFree( db, ref z ); + if ( pIndex != null ) + { + sqlite3BeginWriteOperation( pParse, 0, iDb ); + sqlite3RefillIndex( pParse, pIndex, -1 ); + return; + } + sqlite3ErrorMsg( pParse, "unable to identify the object to be reindexed" ); + } #endif - /* - ** Return a dynamicly allocated KeyInfo structure that can be used - ** with OP_OpenRead or OP_OpenWrite to access database index pIdx. - ** - ** If successful, a pointer to the new structure is returned. In this case - ** the caller is responsible for calling sqlite3DbFree(db, ) on the returned - ** pointer. If an error occurs (out of memory or missing collation - ** sequence), NULL is returned and the state of pParse updated to reflect - ** the error. - */ - static KeyInfo sqlite3IndexKeyinfo(Parse pParse, Index pIdx) { - int i; - int nCol = pIdx.nColumn; - //int nBytes = KeyInfo.Length + (nCol - 1) * CollSeq*.Length + nCol; - sqlite3 db = pParse.db; - KeyInfo pKey = new KeyInfo();// (KeyInfo)sqlite3DbMallocZero(db, nBytes); - - if (pKey != null) { - pKey.db = pParse.db; - pKey.aSortOrder = new byte[nCol]; - pKey.aColl = new CollSeq[nCol];// (u8)&(pKey.aColl[nCol]); - // Debug.Assert(pKey.aSortOrder[nCol] == (((u8)pKey)[nBytes])); - for (i = 0; i < nCol; i++) { - string zColl = pIdx.azColl[i]; - Debug.Assert(zColl != null); - pKey.aColl[i] = sqlite3LocateCollSeq(pParse, zColl); - pKey.aSortOrder[i] = pIdx.aSortOrder[i]; - } - pKey.nField = (u16)nCol; - } - - if (pParse.nErr != 0) { - pKey = null; - sqlite3DbFree(db, ref pKey); - } - return pKey; + /* +** Return a dynamicly allocated KeyInfo structure that can be used +** with OP_OpenRead or OP_OpenWrite to access database index pIdx. +** +** If successful, a pointer to the new structure is returned. In this case +** the caller is responsible for calling sqlite3DbFree(db, ) on the returned +** pointer. If an error occurs (out of memory or missing collation +** sequence), NULL is returned and the state of pParse updated to reflect +** the error. +*/ + static KeyInfo sqlite3IndexKeyinfo( Parse pParse, Index pIdx ) + { + int i; + int nCol = pIdx.nColumn; + //int nBytes = KeyInfo.Length + (nCol - 1) * CollSeq*.Length + nCol; + sqlite3 db = pParse.db; + KeyInfo pKey = new KeyInfo();// (KeyInfo)sqlite3DbMallocZero(db, nBytes); + + if ( pKey != null ) + { + pKey.db = pParse.db; + pKey.aSortOrder = new byte[nCol]; + pKey.aColl = new CollSeq[nCol];// (u8)&(pKey.aColl[nCol]); + // Debug.Assert(pKey.aSortOrder[nCol] == (((u8)pKey)[nBytes])); + for ( i = 0; i < nCol; i++ ) + { + string zColl = pIdx.azColl[i]; + Debug.Assert( zColl != null ); + pKey.aColl[i] = sqlite3LocateCollSeq( pParse, zColl ); + pKey.aSortOrder[i] = pIdx.aSortOrder[i]; } + pKey.nField = (u16)nCol; + } + + if ( pParse.nErr != 0 ) + { + pKey = null; + sqlite3DbFree( db, ref pKey ); + } + return pKey; } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/callback_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/callback_c.cs index a014b9d1c..914f86f22 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/callback_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/callback_c.cs @@ -1,50 +1,57 @@ using System; using System.Diagnostics; +using System.Text; using i16 = System.Int16; -using u16 = System.UInt16; using u8 = System.Byte; +using u16 = System.UInt16; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2005 May 23 - ** - ** 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 contains functions used to access the internal hash tables - ** of user defined functions and collation sequences. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ +namespace Community.CsharpSqlite +{ + using sqlite3_value = Sqlite3.Mem; - //#include "sqliteInt.h" + public partial class Sqlite3 + { + /* + ** 2005 May 23 + ** + ** 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 contains functions used to access the internal hash tables + ** of user defined functions and collation sequences. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ - /* - ** Invoke the 'collation needed' callback to request a collation sequence - ** in the encoding enc of name zName, length nName. - */ - static void callCollNeeded(sqlite3 db, int enc, string zName) { - Debug.Assert(db.xCollNeeded == null || db.xCollNeeded16 == null); - if (db.xCollNeeded != null) { - string zExternal = zName;// sqlite3DbStrDup(db, zName); - if (zExternal == null) - return; - db.xCollNeeded(db.pCollNeededArg, db, enc, zExternal); - sqlite3DbFree(db, ref zExternal); - } + //#include "sqliteInt.h" + + /* + ** Invoke the 'collation needed' callback to request a collation sequence + ** in the encoding enc of name zName, length nName. + */ + static void callCollNeeded( sqlite3 db, int enc, string zName ) + { + Debug.Assert( db.xCollNeeded == null || db.xCollNeeded16 == null ); + if ( db.xCollNeeded != null ) + { + string zExternal = zName;// sqlite3DbStrDup(db, zName); + if ( zExternal == null ) + return; + db.xCollNeeded( db.pCollNeededArg, db, enc, zExternal ); + sqlite3DbFree( db, ref zExternal ); + } #if !SQLITE_OMIT_UTF16 if( db.xCollNeeded16!=null ){ string zExternal; @@ -57,445 +64,496 @@ static void callCollNeeded(sqlite3 db, int enc, string zName) { sqlite3ValueFree(ref pTmp); } #endif - } + } - /* - ** This routine is called if the collation factory fails to deliver a - ** collation function in the best encoding but there may be other versions - ** of this collation function (for other text encodings) available. Use one - ** of these instead if they exist. Avoid a UTF-8 <. UTF-16 conversion if - ** possible. - */ - static int synthCollSeq(sqlite3 db, CollSeq pColl) { - CollSeq pColl2; - string z = pColl.zName; - int i; - byte[] aEnc = { SQLITE_UTF16BE, SQLITE_UTF16LE, SQLITE_UTF8 }; - for (i = 0; i < 3; i++) { - pColl2 = sqlite3FindCollSeq(db, aEnc[i], z, 0); - if (pColl2.xCmp != null) { - pColl = pColl2.Copy(); //memcpy(pColl, pColl2, sizeof(CollSeq)); - pColl.xDel = null; /* Do not copy the destructor */ - return SQLITE_OK; - } - } - return SQLITE_ERROR; + /* + ** This routine is called if the collation factory fails to deliver a + ** collation function in the best encoding but there may be other versions + ** of this collation function (for other text encodings) available. Use one + ** of these instead if they exist. Avoid a UTF-8 <. UTF-16 conversion if + ** possible. + */ + static int synthCollSeq( sqlite3 db, CollSeq pColl ) + { + CollSeq pColl2; + string z = pColl.zName; + int i; + byte[] aEnc = { SQLITE_UTF16BE, SQLITE_UTF16LE, SQLITE_UTF8 }; + for ( i = 0; i < 3; i++ ) + { + pColl2 = sqlite3FindCollSeq( db, aEnc[i], z, 0 ); + if ( pColl2.xCmp != null ) + { + pColl = pColl2.Copy(); //memcpy(pColl, pColl2, sizeof(CollSeq)); + pColl.xDel = null; /* Do not copy the destructor */ + return SQLITE_OK; } + } + return SQLITE_ERROR; + } - /* - ** This function is responsible for invoking the collation factory callback - ** or substituting a collation sequence of a different encoding when the - ** requested collation sequence is not available in the desired encoding. - ** - ** If it is not NULL, then pColl must point to the database native encoding - ** collation sequence with name zName, length nName. - ** - ** The return value is either the collation sequence to be used in database - ** db for collation type name zName, length nName, or NULL, if no collation - ** sequence can be found. - ** - ** See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq() - */ - static CollSeq sqlite3GetCollSeq( - sqlite3 db, /* The database connection */ - u8 enc, /* The desired encoding for the collating sequence */ - CollSeq pColl, /* Collating sequence with native encoding, or NULL */ - string zName /* Collating sequence name */ - ) { - CollSeq p; - - p = pColl; - if (p == null) { - p = sqlite3FindCollSeq(db, enc, zName, 0); - } - if (p == null || p.xCmp == null) { - /* No collation sequence of this type for this encoding is registered. - ** Call the collation factory to see if it can supply us with one. - */ - callCollNeeded(db, enc, zName); - p = sqlite3FindCollSeq(db, enc, zName, 0); - } - if (p != null && p.xCmp == null && synthCollSeq(db, p) != 0) { - p = null; - } - Debug.Assert(p == null || p.xCmp != null); - return p; - } + /* + ** This function is responsible for invoking the collation factory callback + ** or substituting a collation sequence of a different encoding when the + ** requested collation sequence is not available in the desired encoding. + ** + ** If it is not NULL, then pColl must point to the database native encoding + ** collation sequence with name zName, length nName. + ** + ** The return value is either the collation sequence to be used in database + ** db for collation type name zName, length nName, or NULL, if no collation + ** sequence can be found. + ** + ** See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq() + */ + static CollSeq sqlite3GetCollSeq( + sqlite3 db, /* The database connection */ + u8 enc, /* The desired encoding for the collating sequence */ + CollSeq pColl, /* Collating sequence with native encoding, or NULL */ + string zName /* Collating sequence name */ + ) + { + CollSeq p; - /* - ** This routine is called on a collation sequence before it is used to - ** check that it is defined. An undefined collation sequence exists when - ** a database is loaded that contains references to collation sequences - ** that have not been defined by sqlite3_create_collation() etc. - ** - ** If required, this routine calls the 'collation needed' callback to - ** request a definition of the collating sequence. If this doesn't work, - ** an equivalent collating sequence that uses a text encoding different - ** from the main database is substituted, if one is available. + p = pColl; + if ( p == null ) + { + p = sqlite3FindCollSeq( db, enc, zName, 0 ); + } + if ( p == null || p.xCmp == null ) + { + /* No collation sequence of this type for this encoding is registered. + ** Call the collation factory to see if it can supply us with one. */ - static int sqlite3CheckCollSeq(Parse pParse, CollSeq pColl) { - if (pColl != null) { - string zName = pColl.zName; - sqlite3 db = pParse.db; - CollSeq p = sqlite3GetCollSeq(db, ENC(db), pColl, zName); - if (null == p) { - sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName); - pParse.nErr++; - return SQLITE_ERROR; - } - // - //Debug.Assert(p == pColl); - if (p != pColl) // Had to lookup appropriate sequence - { - pColl.enc = p.enc; - pColl.pUser = p.pUser; - pColl.type = p.type; - pColl.xCmp = p.xCmp; - pColl.xDel = p.xDel; - } + callCollNeeded( db, enc, zName ); + p = sqlite3FindCollSeq( db, enc, zName, 0 ); + } + if ( p != null && p.xCmp == null && synthCollSeq( db, p ) != 0 ) + { + p = null; + } + Debug.Assert( p == null || p.xCmp != null ); + return p; + } - } - return SQLITE_OK; + /* + ** This routine is called on a collation sequence before it is used to + ** check that it is defined. An undefined collation sequence exists when + ** a database is loaded that contains references to collation sequences + ** that have not been defined by sqlite3_create_collation() etc. + ** + ** If required, this routine calls the 'collation needed' callback to + ** request a definition of the collating sequence. If this doesn't work, + ** an equivalent collating sequence that uses a text encoding different + ** from the main database is substituted, if one is available. + */ + static int sqlite3CheckCollSeq( Parse pParse, CollSeq pColl ) + { + if ( pColl != null ) + { + string zName = pColl.zName; + sqlite3 db = pParse.db; + CollSeq p = sqlite3GetCollSeq( db, ENC( db ), pColl, zName ); + if ( null == p ) + { + sqlite3ErrorMsg( pParse, "no such collation sequence: %s", zName ); + pParse.nErr++; + return SQLITE_ERROR; + } + // + //Debug.Assert(p == pColl); + if ( p != pColl ) // Had to lookup appropriate sequence + { + pColl.enc = p.enc; + pColl.pUser = p.pUser; + pColl.type = p.type; + pColl.xCmp = p.xCmp; + pColl.xDel = p.xDel; } + } + return SQLITE_OK; + } - /* - ** Locate and return an entry from the db.aCollSeq hash table. If the entry - ** specified by zName and nName is not found and parameter 'create' is - ** true, then create a new entry. Otherwise return NULL. - ** - ** Each pointer stored in the sqlite3.aCollSeq hash table contains an - ** array of three CollSeq structures. The first is the collation sequence - ** prefferred for UTF-8, the second UTF-16le, and the third UTF-16be. - ** - ** Stored immediately after the three collation sequences is a copy of - ** the collation sequence name. A pointer to this string is stored in - ** each collation sequence structure. - */ - static CollSeq[] findCollSeqEntry( - sqlite3 db, /* Database connection */ - string zName, /* Name of the collating sequence */ - int create /* Create a new entry if true */ - ) { - CollSeq[] pColl; - int nName = sqlite3Strlen30(zName); - pColl = sqlite3HashFind(db.aCollSeq, zName, nName, (CollSeq[])null); - if ((null == pColl) && create != 0) { - pColl = new CollSeq[3]; //sqlite3DbMallocZero(db, 3*sizeof(*pColl) + nName + 1 ); - if (pColl != null) { - CollSeq pDel = null; - pColl[0] = new CollSeq(); - pColl[0].zName = zName; - pColl[0].enc = SQLITE_UTF8; - pColl[1] = new CollSeq(); - pColl[1].zName = zName; - pColl[1].enc = SQLITE_UTF16LE; - pColl[2] = new CollSeq(); - pColl[2].zName = zName; - pColl[2].enc = SQLITE_UTF16BE; - //memcpy(pColl[0].zName, zName, nName); - //pColl[0].zName[nName] = 0; - CollSeq[] pDelArray = sqlite3HashInsert(ref db.aCollSeq, pColl[0].zName, nName, pColl); - if (pDelArray != null) - pDel = pDelArray[0]; - /* If a malloc() failure occurred in sqlite3HashInsert(), it will - ** return the pColl pointer to be deleted (because it wasn't added - ** to the hash table). - */ - Debug.Assert(pDel == null || pDel == pColl[0]); - if (pDel != null) { - //// db.mallocFailed = 1; - pDel = null; //was sqlite3DbFree(db,ref pDel); - pColl = null; - } - } - } - return pColl; - } + /* + ** Locate and return an entry from the db.aCollSeq hash table. If the entry + ** specified by zName and nName is not found and parameter 'create' is + ** true, then create a new entry. Otherwise return NULL. + ** + ** Each pointer stored in the sqlite3.aCollSeq hash table contains an + ** array of three CollSeq structures. The first is the collation sequence + ** prefferred for UTF-8, the second UTF-16le, and the third UTF-16be. + ** + ** Stored immediately after the three collation sequences is a copy of + ** the collation sequence name. A pointer to this string is stored in + ** each collation sequence structure. + */ + static CollSeq[] findCollSeqEntry( + sqlite3 db, /* Database connection */ + string zName, /* Name of the collating sequence */ + int create /* Create a new entry if true */ + ) + { + CollSeq[] pColl; + int nName = sqlite3Strlen30( zName ); + pColl = sqlite3HashFind( db.aCollSeq, zName, nName, (CollSeq[])null ); - /* - ** Parameter zName points to a UTF-8 encoded string nName bytes long. - ** Return the CollSeq* pointer for the collation sequence named zName - ** for the encoding 'enc' from the database 'db'. - ** - ** If the entry specified is not found and 'create' is true, then create a - ** new entry. Otherwise return NULL. - ** - ** A separate function sqlite3LocateCollSeq() is a wrapper around - ** this routine. sqlite3LocateCollSeq() invokes the collation factory - ** if necessary and generates an error message if the collating sequence - ** cannot be found. - ** - ** See also: sqlite3LocateCollSeq(), sqlite3GetCollSeq() - */ - static CollSeq sqlite3FindCollSeq( - sqlite3 db, - u8 enc, - string zName, - u8 create - ) { - CollSeq[] pColl; - if (zName != null) { - pColl = findCollSeqEntry(db, zName, create); - } else { - pColl = new CollSeq[enc]; - pColl[enc - 1] = db.pDfltColl; - } - Debug.Assert(SQLITE_UTF8 == 1 && SQLITE_UTF16LE == 2 && SQLITE_UTF16BE == 3); - Debug.Assert(enc >= SQLITE_UTF8 && enc <= SQLITE_UTF16BE); - if (pColl != null) { - enc -= 1; // if (pColl != null) pColl += enc - 1; - return pColl[enc]; - } else - return null; + if ( ( null == pColl ) && create != 0 ) + { + pColl = new CollSeq[3]; //sqlite3DbMallocZero(db, 3*sizeof(*pColl) + nName + 1 ); + if ( pColl != null ) + { + CollSeq pDel = null; + pColl[0] = new CollSeq(); + pColl[0].zName = zName; + pColl[0].enc = SQLITE_UTF8; + pColl[1] = new CollSeq(); + pColl[1].zName = zName; + pColl[1].enc = SQLITE_UTF16LE; + pColl[2] = new CollSeq(); + pColl[2].zName = zName; + pColl[2].enc = SQLITE_UTF16BE; + //memcpy(pColl[0].zName, zName, nName); + //pColl[0].zName[nName] = 0; + CollSeq[] pDelArray = sqlite3HashInsert( ref db.aCollSeq, pColl[0].zName, nName, pColl ); + if ( pDelArray != null ) + pDel = pDelArray[0]; + /* If a malloc() failure occurred in sqlite3HashInsert(), it will + ** return the pColl pointer to be deleted (because it wasn't added + ** to the hash table). + */ + Debug.Assert( pDel == null || pDel == pColl[0] ); + if ( pDel != null ) + { + //// db.mallocFailed = 1; + pDel = null; //was sqlite3DbFree(db,ref pDel); + pColl = null; + } } + } + return pColl; + } - /* During the search for the best function definition, this procedure - ** is called to test how well the function passed as the first argument - ** matches the request for a function with nArg arguments in a system - ** that uses encoding enc. The value returned indicates how well the - ** request is matched. A higher value indicates a better match. - ** - ** The returned value is always between 0 and 6, as follows: - ** - ** 0: Not a match, or if nArg<0 and the function is has no implementation. - ** 1: A variable arguments function that prefers UTF-8 when a UTF-16 - ** encoding is requested, or vice versa. - ** 2: A variable arguments function that uses UTF-16BE when UTF-16LE is - ** requested, or vice versa. - ** 3: A variable arguments function using the same text encoding. - ** 4: A function with the exact number of arguments requested that - ** prefers UTF-8 when a UTF-16 encoding is requested, or vice versa. - ** 5: A function with the exact number of arguments requested that - ** prefers UTF-16LE when UTF-16BE is requested, or vice versa. - ** 6: An exact match. - ** - */ - static int matchQuality(FuncDef p, int nArg, int enc) { - int match = 0; - if (p.nArg == -1 || p.nArg == nArg - || (nArg == -1 && (p.xFunc != null || p.xStep != null)) - ) { - match = 1; - if (p.nArg == nArg || nArg == -1) { - match = 4; - } - if (enc == p.iPrefEnc) { - match += 2; - } else if ((enc == SQLITE_UTF16LE && p.iPrefEnc == SQLITE_UTF16BE) || - (enc == SQLITE_UTF16BE && p.iPrefEnc == SQLITE_UTF16LE)) { - match += 1; - } - } - return match; - } + /* + ** Parameter zName points to a UTF-8 encoded string nName bytes long. + ** Return the CollSeq* pointer for the collation sequence named zName + ** for the encoding 'enc' from the database 'db'. + ** + ** If the entry specified is not found and 'create' is true, then create a + ** new entry. Otherwise return NULL. + ** + ** A separate function sqlite3LocateCollSeq() is a wrapper around + ** this routine. sqlite3LocateCollSeq() invokes the collation factory + ** if necessary and generates an error message if the collating sequence + ** cannot be found. + ** + ** See also: sqlite3LocateCollSeq(), sqlite3GetCollSeq() + */ + static CollSeq sqlite3FindCollSeq( + sqlite3 db, + u8 enc, + string zName, + u8 create + ) + { + CollSeq[] pColl; + if ( zName != null ) + { + pColl = findCollSeqEntry( db, zName, create ); + } + else + { + pColl = new CollSeq[enc]; + pColl[enc - 1] = db.pDfltColl; + } + Debug.Assert( SQLITE_UTF8 == 1 && SQLITE_UTF16LE == 2 && SQLITE_UTF16BE == 3 ); + Debug.Assert( enc >= SQLITE_UTF8 && enc <= SQLITE_UTF16BE ); + if ( pColl != null ) + { + enc -= 1; // if (pColl != null) pColl += enc - 1; + return pColl[enc]; + } + else + return null; + } - /* - ** Search a FuncDefHash for a function with the given name. Return - ** a pointer to the matching FuncDef if found, or 0 if there is no match. - */ - static FuncDef functionSearch( - FuncDefHash pHash, /* Hash table to search */ - int h, /* Hash of the name */ - string zFunc, /* Name of function */ - int nFunc /* Number of bytes in zFunc */ - ) { - FuncDef p; - for (p = pHash.a[h]; p != null; p = p.pHash) { - if (p.zName.Length == nFunc && p.zName.StartsWith(zFunc, StringComparison.OrdinalIgnoreCase)) { - return p; - } - } - return null; + /* During the search for the best function definition, this procedure + ** is called to test how well the function passed as the first argument + ** matches the request for a function with nArg arguments in a system + ** that uses encoding enc. The value returned indicates how well the + ** request is matched. A higher value indicates a better match. + ** + ** The returned value is always between 0 and 6, as follows: + ** + ** 0: Not a match, or if nArg<0 and the function is has no implementation. + ** 1: A variable arguments function that prefers UTF-8 when a UTF-16 + ** encoding is requested, or vice versa. + ** 2: A variable arguments function that uses UTF-16BE when UTF-16LE is + ** requested, or vice versa. + ** 3: A variable arguments function using the same text encoding. + ** 4: A function with the exact number of arguments requested that + ** prefers UTF-8 when a UTF-16 encoding is requested, or vice versa. + ** 5: A function with the exact number of arguments requested that + ** prefers UTF-16LE when UTF-16BE is requested, or vice versa. + ** 6: An exact match. + ** + */ + static int matchQuality( FuncDef p, int nArg, int enc ) + { + int match = 0; + if ( p.nArg == -1 || p.nArg == nArg + || ( nArg == -1 && ( p.xFunc != null || p.xStep != null ) ) + ) + { + match = 1; + if ( p.nArg == nArg || nArg == -1 ) + { + match = 4; + } + if ( enc == p.iPrefEnc ) + { + match += 2; + } + else if ( ( enc == SQLITE_UTF16LE && p.iPrefEnc == SQLITE_UTF16BE ) || + ( enc == SQLITE_UTF16BE && p.iPrefEnc == SQLITE_UTF16LE ) ) + { + match += 1; } + } + return match; + } - /* - ** Insert a new FuncDef into a FuncDefHash hash table. - */ - static void sqlite3FuncDefInsert( - FuncDefHash pHash, /* The hash table into which to insert */ - FuncDef pDef /* The function definition to insert */ - ) { - FuncDef pOther; - int nName = sqlite3Strlen30(pDef.zName); - u8 c1 = (u8)pDef.zName[0]; - int h = (sqlite3UpperToLower[c1] + nName) % ArraySize(pHash.a); - pOther = functionSearch(pHash, h, pDef.zName, nName); - if (pOther != null) { - Debug.Assert(pOther != pDef && pOther.pNext != pDef); - pDef.pNext = pOther.pNext; - pOther.pNext = pDef; - } else { - pDef.pNext = null; - pDef.pHash = pHash.a[h]; - pHash.a[h] = pDef; - } + /* + ** Search a FuncDefHash for a function with the given name. Return + ** a pointer to the matching FuncDef if found, or 0 if there is no match. + */ + static FuncDef functionSearch( + FuncDefHash pHash, /* Hash table to search */ + int h, /* Hash of the name */ + string zFunc, /* Name of function */ + int nFunc /* Number of bytes in zFunc */ + ) + { + FuncDef p; + for ( p = pHash.a[h]; p != null; p = p.pHash ) + { + if ( p.zName.Length == nFunc && p.zName.StartsWith( zFunc, StringComparison.OrdinalIgnoreCase ) ) + { + return p; } + } + return null; + } - /* - ** Locate a user function given a name, a number of arguments and a flag - ** indicating whether the function prefers UTF-16 over UTF-8. Return a - ** pointer to the FuncDef structure that defines that function, or return - ** NULL if the function does not exist. - ** - ** If the createFlag argument is true, then a new (blank) FuncDef - ** structure is created and liked into the "db" structure if a - ** no matching function previously existed. When createFlag is true - ** and the nArg parameter is -1, then only a function that accepts - ** any number of arguments will be returned. - ** - ** If createFlag is false and nArg is -1, then the first valid - ** function found is returned. A function is valid if either xFunc - ** or xStep is non-zero. - ** - ** If createFlag is false, then a function with the required name and - ** number of arguments may be returned even if the eTextRep flag does not - ** match that requested. - */ + /* + ** Insert a new FuncDef into a FuncDefHash hash table. + */ + static void sqlite3FuncDefInsert( + FuncDefHash pHash, /* The hash table into which to insert */ + FuncDef pDef /* The function definition to insert */ + ) + { + FuncDef pOther; + int nName = sqlite3Strlen30( pDef.zName ); + u8 c1 = (u8)pDef.zName[0]; + int h = ( sqlite3UpperToLower[c1] + nName ) % ArraySize( pHash.a ); + pOther = functionSearch( pHash, h, pDef.zName, nName ); + if ( pOther != null ) + { + Debug.Assert( pOther != pDef && pOther.pNext != pDef ); + pDef.pNext = pOther.pNext; + pOther.pNext = pDef; + } + else + { + pDef.pNext = null; + pDef.pHash = pHash.a[h]; + pHash.a[h] = pDef; + } + } - static FuncDef sqlite3FindFunction( - sqlite3 db, /* An open database */ - string zName, /* Name of the function. Not null-terminated */ - int nName, /* Number of characters in the name */ - int nArg, /* Number of arguments. -1 means any number */ - u8 enc, /* Preferred text encoding */ - u8 createFlag /* Create new entry if true and does not otherwise exist */ - ) { - FuncDef p; /* Iterator variable */ - FuncDef pBest = null; /* Best match found so far */ - int bestScore = 0; - int h; /* Hash value */ + /* + ** Locate a user function given a name, a number of arguments and a flag + ** indicating whether the function prefers UTF-16 over UTF-8. Return a + ** pointer to the FuncDef structure that defines that function, or return + ** NULL if the function does not exist. + ** + ** If the createFlag argument is true, then a new (blank) FuncDef + ** structure is created and liked into the "db" structure if a + ** no matching function previously existed. When createFlag is true + ** and the nArg parameter is -1, then only a function that accepts + ** any number of arguments will be returned. + ** + ** If createFlag is false and nArg is -1, then the first valid + ** function found is returned. A function is valid if either xFunc + ** or xStep is non-zero. + ** + ** If createFlag is false, then a function with the required name and + ** number of arguments may be returned even if the eTextRep flag does not + ** match that requested. + */ - Debug.Assert(enc == SQLITE_UTF8 || enc == SQLITE_UTF16LE || enc == SQLITE_UTF16BE); - h = (sqlite3UpperToLower[(u8)zName[0]] + nName) % ArraySize(db.aFunc.a); + static FuncDef sqlite3FindFunction( + sqlite3 db, /* An open database */ + string zName, /* Name of the function. Not null-terminated */ + int nName, /* Number of characters in the name */ + int nArg, /* Number of arguments. -1 means any number */ + u8 enc, /* Preferred text encoding */ + u8 createFlag /* Create new entry if true and does not otherwise exist */ + ) + { + FuncDef p; /* Iterator variable */ + FuncDef pBest = null; /* Best match found so far */ + int bestScore = 0; + int h; /* Hash value */ + Debug.Assert( enc == SQLITE_UTF8 || enc == SQLITE_UTF16LE || enc == SQLITE_UTF16BE ); + h = ( sqlite3UpperToLower[(u8)zName[0]] + nName ) % ArraySize( db.aFunc.a ); - /* First search for a match amongst the application-defined functions. - */ - p = functionSearch(db.aFunc, h, zName, nName); - while (p != null) { - int score = matchQuality(p, nArg, enc); - if (score > bestScore) { - pBest = p; - bestScore = score; - } - p = p.pNext; - } + /* First search for a match amongst the application-defined functions. + */ + p = functionSearch( db.aFunc, h, zName, nName ); + while ( p != null ) + { + int score = matchQuality( p, nArg, enc ); + if ( score > bestScore ) + { + pBest = p; + bestScore = score; + + } + p = p.pNext; + } - /* If no match is found, search the built-in functions. - ** - ** If the SQLITE_PreferBuiltin flag is set, then search the built-in - ** functions even if a prior app-defined function was found. And give - ** priority to built-in functions. - ** - ** Except, if createFlag is true, that means that we are trying to - ** install a new function. Whatever FuncDef structure is returned it will - ** have fields overwritten with new information appropriate for the - ** new function. But the FuncDefs for built-in functions are read-only. - ** So we must not search for built-ins when creating a new function. - */ - if (0 == createFlag && (pBest == null || (db.flags & SQLITE_PreferBuiltin) != 0)) { + /* If no match is found, search the built-in functions. + ** + ** If the SQLITE_PreferBuiltin flag is set, then search the built-in + ** functions even if a prior app-defined function was found. And give + ** priority to built-in functions. + ** + ** Except, if createFlag is true, that means that we are trying to + ** install a new function. Whatever FuncDef structure is returned it will + ** have fields overwritten with new information appropriate for the + ** new function. But the FuncDefs for built-in functions are read-only. + ** So we must not search for built-ins when creating a new function. + */ + if ( 0 == createFlag && ( pBest == null || ( db.flags & SQLITE_PreferBuiltin ) != 0 ) ) + { #if SQLITE_OMIT_WSD FuncDefHash pHash = GLOBAL( FuncDefHash, sqlite3GlobalFunctions ); #else - FuncDefHash pHash = sqlite3GlobalFunctions; + FuncDefHash pHash = sqlite3GlobalFunctions; #endif - bestScore = 0; - p = functionSearch(pHash, h, zName, nName); - while (p != null) { - int score = matchQuality(p, nArg, enc); - if (score > bestScore) { - pBest = p; - bestScore = score; - } - p = p.pNext; - } - } + bestScore = 0; + p = functionSearch( pHash, h, zName, nName ); + while ( p != null ) + { + int score = matchQuality( p, nArg, enc ); + if ( score > bestScore ) + { + pBest = p; + bestScore = score; + } + p = p.pNext; + } + } - /* If the createFlag parameter is true and the search did not reveal an - ** exact match for the name, number of arguments and encoding, then add a - ** new entry to the hash table and return it. - */ - if (createFlag != 0 && (bestScore < 6 || pBest.nArg != nArg) && - (pBest = new FuncDef()) != null) { //sqlite3DbMallocZero(db, sizeof(*pBest)+nName+1))!=0 ){ - //pBest.zName = (char *)&pBest[1]; - pBest.nArg = (i16)nArg; - pBest.iPrefEnc = enc; - pBest.zName = zName; //memcpy(pBest.zName, zName, nName); - //pBest.zName[nName] = 0; - sqlite3FuncDefInsert(db.aFunc, pBest); - } + /* If the createFlag parameter is true and the search did not reveal an + ** exact match for the name, number of arguments and encoding, then add a + ** new entry to the hash table and return it. + */ + if ( createFlag != 0 && ( bestScore < 6 || pBest.nArg != nArg ) && + ( pBest = new FuncDef() ) != null ) + { //sqlite3DbMallocZero(db, sizeof(*pBest)+nName+1))!=0 ){ + //pBest.zName = (char *)&pBest[1]; + pBest.nArg = (i16)nArg; + pBest.iPrefEnc = enc; + pBest.zName = zName; //memcpy(pBest.zName, zName, nName); + //pBest.zName[nName] = 0; + sqlite3FuncDefInsert( db.aFunc, pBest ); + } - if (pBest != null && (pBest.xStep != null || pBest.xFunc != null || createFlag != 0)) { - return pBest; - } - return null; - } + if ( pBest != null && ( pBest.xStep != null || pBest.xFunc != null || createFlag != 0 ) ) + { + return pBest; + } + return null; + } - /* - ** Free all resources held by the schema structure. The void* argument points - ** at a Schema struct. This function does not call sqlite3DbFree(db, ) on the - ** pointer itself, it just cleans up subsidiary resources (i.e. the contents - ** of the schema hash tables). - ** - ** The Schema.cache_size variable is not cleared. - */ - static void sqlite3SchemaClear(Schema p) { - Hash temp1; - Hash temp2; - HashElem pElem; - Schema pSchema = p; + /* + ** Free all resources held by the schema structure. The void* argument points + ** at a Schema struct. This function does not call sqlite3DbFree(db, ) on the + ** pointer itself, it just cleans up subsidiary resources (i.e. the contents + ** of the schema hash tables). + ** + ** The Schema.cache_size variable is not cleared. + */ + static void sqlite3SchemaClear( Schema p ) + { + Hash temp1; + Hash temp2; + HashElem pElem; + Schema pSchema = p; - temp1 = pSchema.tblHash; - temp2 = pSchema.trigHash; - sqlite3HashInit(pSchema.trigHash); - sqlite3HashClear(pSchema.idxHash); - for (pElem = sqliteHashFirst(temp2); pElem != null; pElem = sqliteHashNext(pElem)) { - Trigger pTrigger = (Trigger)sqliteHashData(pElem); - sqlite3DeleteTrigger(null, ref pTrigger); - } - sqlite3HashClear(temp2); - sqlite3HashInit(pSchema.trigHash); - for (pElem = temp1.first; pElem != null; pElem = pElem.next)//sqliteHashFirst(&temp1); pElem; pElem = sqliteHashNext(pElem)) - { - Table pTab = (Table)pElem.data; //sqliteHashData(pElem); - sqlite3DeleteTable(null, ref pTab); - } - sqlite3HashClear(temp1); - sqlite3HashClear(pSchema.fkeyHash); - pSchema.pSeqTab = null; - if ((pSchema.flags & DB_SchemaLoaded) != 0) { - pSchema.iGeneration++; - pSchema.flags = (u16)(pSchema.flags & (~DB_SchemaLoaded)); - } - p.Clear(); - } + temp1 = pSchema.tblHash; + temp2 = pSchema.trigHash; + sqlite3HashInit( pSchema.trigHash ); + sqlite3HashClear( pSchema.idxHash ); + for ( pElem = sqliteHashFirst( temp2 ); pElem != null; pElem = sqliteHashNext( pElem ) ) + { + Trigger pTrigger = (Trigger)sqliteHashData( pElem ); + sqlite3DeleteTrigger( null, ref pTrigger ); + } + sqlite3HashClear( temp2 ); + sqlite3HashInit( pSchema.trigHash ); + for ( pElem = temp1.first; pElem != null; pElem = pElem.next )//sqliteHashFirst(&temp1); pElem; pElem = sqliteHashNext(pElem)) + { + Table pTab = (Table)pElem.data; //sqliteHashData(pElem); + sqlite3DeleteTable( null, ref pTab ); + } + sqlite3HashClear( temp1 ); + sqlite3HashClear( pSchema.fkeyHash ); + pSchema.pSeqTab = null; + if ( ( pSchema.flags & DB_SchemaLoaded ) != 0 ) + { + pSchema.iGeneration++; + pSchema.flags = (u16)( pSchema.flags & ( ~DB_SchemaLoaded ) ); + } + p.Clear(); + } - /* - ** Find and return the schema associated with a BTree. Create - ** a new one if necessary. - */ - static Schema sqlite3SchemaGet(sqlite3 db, Btree pBt) { - Schema p; - if (pBt != null) { - p = sqlite3BtreeSchema(pBt, -1, (dxFreeSchema)sqlite3SchemaClear);//Schema.Length, sqlite3SchemaFree); - } else { - p = new Schema(); // (Schema *)sqlite3DbMallocZero(0, sizeof(Schema)); - } - if (p == null) { - //// db.mallocFailed = 1; - } else if (0 == p.file_format) { - sqlite3HashInit(p.tblHash); - sqlite3HashInit(p.idxHash); - sqlite3HashInit(p.trigHash); - sqlite3HashInit(p.fkeyHash); - p.enc = SQLITE_UTF8; - } - return p; - } + /* + ** Find and return the schema associated with a BTree. Create + ** a new one if necessary. + */ + static Schema sqlite3SchemaGet( sqlite3 db, Btree pBt ) + { + Schema p; + if ( pBt != null ) + { + p = sqlite3BtreeSchema( pBt, -1, (dxFreeSchema)sqlite3SchemaClear );//Schema.Length, sqlite3SchemaFree); + } + else + { + p = new Schema(); // (Schema *)sqlite3DbMallocZero(0, sizeof(Schema)); + } + if ( p == null ) + { + //// db.mallocFailed = 1; + } + else if ( 0 == p.file_format ) + { + sqlite3HashInit( p.tblHash ); + sqlite3HashInit( p.idxHash ); + sqlite3HashInit( p.trigHash ); + sqlite3HashInit( p.fkeyHash ); + p.enc = SQLITE_UTF8; + } + return p; } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/complete_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/complete_c.cs index c1556e9d2..e231fa9f4 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/complete_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/complete_c.cs @@ -1,131 +1,137 @@ -namespace Community.CsharpSqlite { +using System.Diagnostics; - using u8 = System.Byte; +namespace Community.CsharpSqlite +{ - public partial class Sqlite3 { - /* - ** 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. - ** - ************************************************************************* - ** An tokenizer for SQL - ** - ** This file contains C code that implements the sqlite3_complete() API. - ** This code used to be part of the tokenizer.c source file. But by - ** separating it out, the code will be automatically omitted from - ** static links that do not use it. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" -#if !SQLITE_OMIT_COMPLETE + using u8 = System.Byte; - /* - ** This is defined in tokenize.c. We just have to import the definition. + public partial class Sqlite3 + { + /* + ** 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. + ** + ************************************************************************* + ** An tokenizer for SQL + ** + ** This file contains C code that implements the sqlite3_complete() API. + ** This code used to be part of the tokenizer.c source file. But by + ** separating it out, the code will be automatically omitted from + ** static links that do not use it. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* */ + //#include "sqliteInt.h" +#if !SQLITE_OMIT_COMPLETE + + /* +** This is defined in tokenize.c. We just have to import the definition. +*/ #if !SQLITE_AMALGAMATION -#if SQLITE_ASCII - //#define IdChar(C) ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0) - static bool IdChar(u8 C) { - return (sqlite3CtypeMap[(char)C] & 0x46) != 0; - } +#if SQLITE_ASCII + //#define IdChar(C) ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0) + static bool IdChar( u8 C ) + { + return ( sqlite3CtypeMap[(char)C] & 0x46 ) != 0; + } #endif - //#if SQLITE_EBCDIC - //extern const char sqlite3IsEbcdicIdChar[]; - //#define IdChar(C) (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40])) - //#endif +//#if SQLITE_EBCDIC +//extern const char sqlite3IsEbcdicIdChar[]; +//#define IdChar(C) (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40])) +//#endif #endif // * SQLITE_AMALGAMATION */ - /* - ** Token types used by the sqlite3_complete() routine. See the header - ** comments on that procedure for additional information. - */ - const int tkSEMI = 0; - const int tkWS = 1; - const int tkOTHER = 2; + /* +** Token types used by the sqlite3_complete() routine. See the header +** comments on that procedure for additional information. +*/ + const int tkSEMI = 0; + const int tkWS = 1; + const int tkOTHER = 2; #if !SQLITE_OMIT_TRIGGER - const int tkEXPLAIN = 3; - const int tkCREATE = 4; - const int tkTEMP = 5; - const int tkTRIGGER = 6; - const int tkEND = 7; + const int tkEXPLAIN = 3; + const int tkCREATE = 4; + const int tkTEMP = 5; + const int tkTRIGGER = 6; + const int tkEND = 7; #endif - /* - ** Return TRUE if the given SQL string ends in a semicolon. - ** - ** Special handling is require for CREATE TRIGGER statements. - ** Whenever the CREATE TRIGGER keywords are seen, the statement - ** must end with ";END;". - ** - ** This implementation uses a state machine with 8 states: - ** - ** (0) INVALID We have not yet seen a non-whitespace character. - ** - ** (1) START At the beginning or end of an SQL statement. This routine - ** returns 1 if it ends in the START state and 0 if it ends - ** in any other state. - ** - ** (2) NORMAL We are in the middle of statement which ends with a single - ** semicolon. - ** - ** (3) EXPLAIN The keyword EXPLAIN has been seen at the beginning of - ** a statement. - ** - ** (4) CREATE The keyword CREATE has been seen at the beginning of a - ** statement, possibly preceeded by EXPLAIN and/or followed by - ** TEMP or TEMPORARY - ** - ** (5) TRIGGER We are in the middle of a trigger definition that must be - ** ended by a semicolon, the keyword END, and another semicolon. - ** - ** (6) SEMI We've seen the first semicolon in the ";END;" that occurs at - ** the end of a trigger definition. - ** - ** (7) END We've seen the ";END" of the ";END;" that occurs at the end - ** of a trigger difinition. - ** - ** Transitions between states above are determined by tokens extracted - ** from the input. The following tokens are significant: - ** - ** (0) tkSEMI A semicolon. - ** (1) tkWS Whitespace. - ** (2) tkOTHER Any other SQL token. - ** (3) tkEXPLAIN The "explain" keyword. - ** (4) tkCREATE The "create" keyword. - ** (5) tkTEMP The "temp" or "temporary" keyword. - ** (6) tkTRIGGER The "trigger" keyword. - ** (7) tkEND The "end" keyword. - ** - ** Whitespace never causes a state transition and is always ignored. - ** This means that a SQL string of all whitespace is invalid. - ** - ** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed - ** to recognize the end of a trigger can be omitted. All we have to do - ** is look for a semicolon that is not part of an string or comment. - */ + /* +** Return TRUE if the given SQL string ends in a semicolon. +** +** Special handling is require for CREATE TRIGGER statements. +** Whenever the CREATE TRIGGER keywords are seen, the statement +** must end with ";END;". +** +** This implementation uses a state machine with 8 states: +** +** (0) INVALID We have not yet seen a non-whitespace character. +** +** (1) START At the beginning or end of an SQL statement. This routine +** returns 1 if it ends in the START state and 0 if it ends +** in any other state. +** +** (2) NORMAL We are in the middle of statement which ends with a single +** semicolon. +** +** (3) EXPLAIN The keyword EXPLAIN has been seen at the beginning of +** a statement. +** +** (4) CREATE The keyword CREATE has been seen at the beginning of a +** statement, possibly preceeded by EXPLAIN and/or followed by +** TEMP or TEMPORARY +** +** (5) TRIGGER We are in the middle of a trigger definition that must be +** ended by a semicolon, the keyword END, and another semicolon. +** +** (6) SEMI We've seen the first semicolon in the ";END;" that occurs at +** the end of a trigger definition. +** +** (7) END We've seen the ";END" of the ";END;" that occurs at the end +** of a trigger difinition. +** +** Transitions between states above are determined by tokens extracted +** from the input. The following tokens are significant: +** +** (0) tkSEMI A semicolon. +** (1) tkWS Whitespace. +** (2) tkOTHER Any other SQL token. +** (3) tkEXPLAIN The "explain" keyword. +** (4) tkCREATE The "create" keyword. +** (5) tkTEMP The "temp" or "temporary" keyword. +** (6) tkTRIGGER The "trigger" keyword. +** (7) tkEND The "end" keyword. +** +** Whitespace never causes a state transition and is always ignored. +** This means that a SQL string of all whitespace is invalid. +** +** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed +** to recognize the end of a trigger can be omitted. All we have to do +** is look for a semicolon that is not part of an string or comment. +*/ - static public int sqlite3_complete(string zSql) { - int state = 0; /* Current state, using numbers defined in header comment */ - int token; /* Value of the next token */ + static public int sqlite3_complete( string zSql ) + { + int state = 0; /* Current state, using numbers defined in header comment */ + int token; /* Value of the next token */ #if !SQLITE_OMIT_TRIGGER - /* A complex statement machine used to detect the end of a CREATE TRIGGER - ** statement. This is the normal case. - */ - u8[][] trans = new u8[][] { + /* A complex statement machine used to detect the end of a CREATE TRIGGER +** statement. This is the normal case. +*/ + u8[][] trans = new u8[][] { /* Token: */ /* State: ** SEMI WS OTHER EXPLAIN CREATE TEMP TRIGGER END */ /* 0 INVALID: */ new u8[]{ 1, 0, 2, 3, 4, 2, 2, 2, }, @@ -150,141 +156,179 @@ static public int sqlite3_complete(string zSql) { }; #endif // * SQLITE_OMIT_TRIGGER */ - int zIdx = 0; - while (zIdx < zSql.Length) { - switch (zSql[zIdx]) { - case ';': { /* A semicolon */ - token = tkSEMI; - break; - } - case ' ': - case '\r': - case '\t': - case '\n': - case '\f': { /* White space is ignored */ - token = tkWS; - break; - } - case '/': { /* C-style comments */ - if (zSql[zIdx + 1] != '*') { - token = tkOTHER; - break; - } - zIdx += 2; - while (zIdx < zSql.Length && zSql[zIdx] != '*' || zIdx < zSql.Length - 1 && zSql[zIdx + 1] != '/') { - zIdx++; - } - if (zIdx == zSql.Length) - return 0; - zIdx++; - token = tkWS; - break; - } - case '-': { /* SQL-style comments from "--" to end of line */ - if (zSql[zIdx + 1] != '-') { - token = tkOTHER; - break; - } - while (zIdx < zSql.Length && zSql[zIdx] != '\n') { - zIdx++; - } - if (zIdx == zSql.Length) - return state == 1 ? 1 : 0;//if( *zSql==0 ) return state==1; - token = tkWS; - break; - } - case '[': { /* Microsoft-style identifiers in [...] */ - zIdx++; - while (zIdx < zSql.Length && zSql[zIdx] != ']') { - zIdx++; - } - if (zIdx == zSql.Length) - return 0; - token = tkOTHER; - break; - } - case '`': /* Grave-accent quoted symbols used by MySQL */ - case '"': /* single- and double-quoted strings */ - case '\'': { - int c = zSql[zIdx]; - zIdx++; - while (zIdx < zSql.Length && zSql[zIdx] != c) { - zIdx++; - } - if (zIdx == zSql.Length) - return 0; - token = tkOTHER; - break; - } - default: { - //#if SQLITE_EBCDIC - // unsigned char c; - //#endif - if (IdChar((u8)zSql[zIdx])) { - /* Keywords and unquoted identifiers */ - int nId; - for (nId = 1; (zIdx + nId) < zSql.Length && IdChar((u8)zSql[zIdx + nId]); nId++) { - } -#if SQLITE_OMIT_TRIGGER + int zIdx = 0; + while ( zIdx < zSql.Length ) + { + switch ( zSql[zIdx] ) + { + case ';': + { /* A semicolon */ + token = tkSEMI; + break; + } + case ' ': + case '\r': + case '\t': + case '\n': + case '\f': + { /* White space is ignored */ + token = tkWS; + break; + } + case '/': + { /* C-style comments */ + if ( zSql[zIdx + 1] != '*' ) + { + token = tkOTHER; + break; + } + zIdx += 2; + while ( zIdx < zSql.Length && zSql[zIdx] != '*' || zIdx < zSql.Length - 1 && zSql[zIdx + 1] != '/' ) + { + zIdx++; + } + if ( zIdx == zSql.Length ) + return 0; + zIdx++; + token = tkWS; + break; + } + case '-': + { /* SQL-style comments from "--" to end of line */ + if ( zSql[zIdx + 1] != '-' ) + { + token = tkOTHER; + break; + } + while ( zIdx < zSql.Length && zSql[zIdx] != '\n' ) + { + zIdx++; + } + if ( zIdx == zSql.Length ) + return state == 1 ? 1 : 0;//if( *zSql==0 ) return state==1; + token = tkWS; + break; + } + case '[': + { /* Microsoft-style identifiers in [...] */ + zIdx++; + while ( zIdx < zSql.Length && zSql[zIdx] != ']' ) + { + zIdx++; + } + if ( zIdx == zSql.Length ) + return 0; + token = tkOTHER; + break; + } + case '`': /* Grave-accent quoted symbols used by MySQL */ + case '"': /* single- and double-quoted strings */ + case '\'': + { + int c = zSql[zIdx]; + zIdx++; + while ( zIdx < zSql.Length && zSql[zIdx] != c ) + { + zIdx++; + } + if ( zIdx == zSql.Length ) + return 0; + token = tkOTHER; + break; + } + default: + { +//#if SQLITE_EBCDIC +// unsigned char c; +//#endif + if ( IdChar( (u8)zSql[zIdx] ) ) + { + /* Keywords and unquoted identifiers */ + int nId; + for ( nId = 1; ( zIdx + nId ) < zSql.Length && IdChar( (u8)zSql[zIdx + nId] ); nId++ ) + { + } +#if SQLITE_OMIT_TRIGGER token = tkOTHER; #else - switch (zSql[zIdx]) { - case 'c': - case 'C': { - if (nId == 6 && sqlite3StrNICmp(zSql, zIdx, "create", 6) == 0) { - token = tkCREATE; - } else { - token = tkOTHER; - } - break; - } - case 't': - case 'T': { - if (nId == 7 && sqlite3StrNICmp(zSql, zIdx, "trigger", 7) == 0) { - token = tkTRIGGER; - } else if (nId == 4 && sqlite3StrNICmp(zSql, zIdx, "temp", 4) == 0) { - token = tkTEMP; - } else if (nId == 9 && sqlite3StrNICmp(zSql, zIdx, "temporary", 9) == 0) { - token = tkTEMP; - } else { - token = tkOTHER; - } - break; - } - case 'e': - case 'E': { - if (nId == 3 && sqlite3StrNICmp(zSql, zIdx, "end", 3) == 0) { - token = tkEND; - } else + switch ( zSql[zIdx] ) + { + case 'c': + case 'C': + { + if ( nId == 6 && sqlite3StrNICmp( zSql, zIdx, "create", 6 ) == 0 ) + { + token = tkCREATE; + } + else + { + token = tkOTHER; + } + break; + } + case 't': + case 'T': + { + if ( nId == 7 && sqlite3StrNICmp( zSql, zIdx, "trigger", 7 ) == 0 ) + { + token = tkTRIGGER; + } + else if ( nId == 4 && sqlite3StrNICmp( zSql, zIdx, "temp", 4 ) == 0 ) + { + token = tkTEMP; + } + else if ( nId == 9 && sqlite3StrNICmp( zSql, zIdx, "temporary", 9 ) == 0 ) + { + token = tkTEMP; + } + else + { + token = tkOTHER; + } + break; + } + case 'e': + case 'E': + { + if ( nId == 3 && sqlite3StrNICmp( zSql, zIdx, "end", 3 ) == 0 ) + { + token = tkEND; + } + else #if !SQLITE_OMIT_EXPLAIN - if (nId == 7 && sqlite3StrNICmp(zSql, zIdx, "explain", 7) == 0) { - token = tkEXPLAIN; - } else + if ( nId == 7 && sqlite3StrNICmp( zSql, zIdx, "explain", 7 ) == 0 ) + { + token = tkEXPLAIN; + } + else #endif - { - token = tkOTHER; - } - break; - } - default: { - token = tkOTHER; - break; - } - } -#endif // * SQLITE_OMIT_TRIGGER */ - zIdx += nId - 1; - } else { - /* Operators and special symbols */ - token = tkOTHER; - } - break; + { + token = tkOTHER; } + break; + } + default: + { + token = tkOTHER; + break; + } } - state = trans[state][token]; - zIdx++; +#endif // * SQLITE_OMIT_TRIGGER */ + zIdx += nId - 1; + } + else + { + /* Operators and special symbols */ + token = tkOTHER; + } + break; } - return (state == 1) ? 1 : 0;//return state==1; } + state = trans[state][token]; + zIdx++; + } + return ( state == 1 ) ? 1 : 0;//return state==1; + } #if !SQLITE_OMIT_UTF16 /* @@ -314,5 +358,5 @@ int sqlite3_complete16(const void *zSql){ } #endif // * SQLITE_OMIT_UTF16 */ #endif // * SQLITE_OMIT_COMPLETE */ - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/crypto.cs b/src/extensions/IronPython.SQLite/c#sqlite/crypto.cs index 7c409ea59..5c3eec460 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/crypto.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/crypto.cs @@ -1,49 +1,63 @@ -namespace Community.CsharpSqlite { -#if !SQLITE_WINRT +using System; +using System.Diagnostics; +using System.Text; + +using u8 = System.Byte; +using u16 = System.UInt16; +using Pgno = System.UInt32; + +namespace Community.CsharpSqlite +{ + using sqlite3_int64 = System.Int64; + using sqlite3_stmt = Sqlite3.Vdbe; +#if !SQLITE_WINRT + using System.Security.Cryptography; + using System.IO; #endif - public partial class Sqlite3 { - /* - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2010 Noah B Hart, Diego Torres - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ************************************************************************* - */ - - /* - ** SQLCipher - ** crypto.c developed by Stephen Lombardo (Zetetic LLC) - ** sjlombardo at zetetic dot net - ** http://zetetic.net - ** - ** Copyright (c) 2009, ZETETIC LLC - ** All rights reserved. - ** - ** Redistribution and use in source and binary forms, with or without - ** modification, are permitted provided that the following conditions are met: - ** * Redistributions of source code must retain the above copyright - ** notice, this list of conditions and the following disclaimer. - ** * Redistributions in binary form must reproduce the above copyright - ** notice, this list of conditions and the following disclaimer in the - ** documentation and/or other materials provided with the distribution. - ** * Neither the name of the ZETETIC LLC nor the - ** names of its contributors may be used to endorse or promote products - ** derived from this software without specific prior written permission. - ** - ** THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY - ** EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - ** DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY - ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ** - */ - /* BEGIN CRYPTO */ + public partial class Sqlite3 + { + /* + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2010 Noah B Hart, Diego Torres + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ************************************************************************* + */ + + /* + ** SQLCipher + ** crypto.c developed by Stephen Lombardo (Zetetic LLC) + ** sjlombardo at zetetic dot net + ** http://zetetic.net + ** + ** Copyright (c) 2009, ZETETIC LLC + ** All rights reserved. + ** + ** Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions are met: + ** * Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** * Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in the + ** documentation and/or other materials provided with the distribution. + ** * Neither the name of the ZETETIC LLC nor the + ** names of its contributors may be used to endorse or promote products + ** derived from this software without specific prior written permission. + ** + ** THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY + ** EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + ** DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY + ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ** + */ + /* BEGIN CRYPTO */ #if SQLITE_HAS_CODEC //#include @@ -744,8 +758,8 @@ static void sqlite3CodecGetKey( sqlite3 db, int nDb, out string zKey, out int nK } /* END CRYPTO */ #endif - const int SQLITE_ENCRYPT_WRITE_CTX = 6; /* Encode page */ - const int SQLITE_ENCRYPT_READ_CTX = 7; /* Encode page */ - const int SQLITE_DECRYPT = 3; /* Decode page */ - } + const int SQLITE_ENCRYPT_WRITE_CTX = 6; /* Encode page */ + const int SQLITE_ENCRYPT_READ_CTX = 7; /* Encode page */ + const int SQLITE_DECRYPT = 3; /* Decode page */ + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/ctime_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/ctime_c.cs index 8e2a85a7b..5f7917a0e 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/ctime_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/ctime_c.cs @@ -1,45 +1,48 @@ #pragma warning disable CA1865 // Use char overload -namespace Community.CsharpSqlite { - using System; +namespace Community.CsharpSqlite +{ + using sqlite3_value = Sqlite3.Mem; + using System; - public partial class Sqlite3 { - /* - ** 2010 February 23 - ** - ** 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 implements routines used to report what compile-time options - ** SQLite was built with. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-01-28 17:03:50 ed759d5a9edb3bba5f48f243df47be29e3fe8cd7 - ** - ************************************************************************* - */ + public partial class Sqlite3 + { + /* + ** 2010 February 23 + ** + ** 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 implements routines used to report what compile-time options + ** SQLite was built with. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-01-28 17:03:50 ed759d5a9edb3bba5f48f243df47be29e3fe8cd7 + ** + ************************************************************************* + */ #if !SQLITE_OMIT_COMPILEOPTION_DIAGS - //#include "sqliteInt.h" + //#include "sqliteInt.h" - /* - ** An array of names of all compile-time options. This array should - ** be sorted A-Z. - ** - ** This array looks large, but in a typical installation actually uses - ** only a handful of compile-time options, so most times this array is usually - ** rather short and uses little memory space. - */ - static string[] azCompileOpt = { + /* + ** An array of names of all compile-time options. This array should + ** be sorted A-Z. + ** + ** This array looks large, but in a typical installation actually uses + ** only a handful of compile-time options, so most times this array is usually + ** rather short and uses little memory space. + */ + static string[] azCompileOpt = { /* These macros are provided to "stringify" the value of the define ** for those options in which the value is meaningful. */ @@ -373,43 +376,47 @@ public partial class Sqlite3 { #endif }; - /* - ** Given the name of a compile-time option, return true if that option - ** was used and false if not. - ** - ** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix - ** is not required for a match. - */ - static int sqlite3_compileoption_used(string zOptName) { - if (zOptName.EndsWith("=", StringComparison.Ordinal)) - return 0; - int i, n = 0; - if (zOptName.StartsWith("SQLITE_", System.StringComparison.OrdinalIgnoreCase)) - n = 7; - //n = sqlite3Strlen30(zOptName); + /* + ** Given the name of a compile-time option, return true if that option + ** was used and false if not. + ** + ** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix + ** is not required for a match. + */ + static int sqlite3_compileoption_used( string zOptName ) + { + if ( zOptName.EndsWith( "=", StringComparison.Ordinal ) ) + return 0; + int i, n = 0; + if ( zOptName.StartsWith( "SQLITE_", System.StringComparison.OrdinalIgnoreCase ) ) + n = 7; + //n = sqlite3Strlen30(zOptName); - /* Since ArraySize(azCompileOpt) is normally in single digits, a - ** linear search is adequate. No need for a binary search. */ - if (!String.IsNullOrEmpty(zOptName)) - for (i = 0; i < ArraySize(azCompileOpt); i++) { - int n1 = (zOptName.Length - n < azCompileOpt[i].Length) ? zOptName.Length - n : azCompileOpt[i].Length; - if (String.Compare(zOptName, n, azCompileOpt[i], 0, n1, StringComparison.OrdinalIgnoreCase) == 0) - return 1; - } - return 0; + /* Since ArraySize(azCompileOpt) is normally in single digits, a + ** linear search is adequate. No need for a binary search. */ + if ( !String.IsNullOrEmpty( zOptName ) ) + for ( i = 0; i < ArraySize( azCompileOpt ); i++ ) + { + int n1 = ( zOptName.Length-n < azCompileOpt[i].Length ) ? zOptName.Length-n : azCompileOpt[i].Length; + if ( String.Compare( zOptName, n, azCompileOpt[i], 0, n1, StringComparison.OrdinalIgnoreCase ) == 0 ) + return 1; } + return 0; + } - /* - ** Return the N-th compile-time option string. If N is out of range, - ** return a NULL pointer. - */ - static string sqlite3_compileoption_get(int N) { - if (N >= 0 && N < ArraySize(azCompileOpt)) { - return azCompileOpt[N]; - } - return null; - } + /* + ** Return the N-th compile-time option string. If N is out of range, + ** return a NULL pointer. + */ + static string sqlite3_compileoption_get( int N ) + { + if ( N >= 0 && N < ArraySize( azCompileOpt ) ) + { + return azCompileOpt[N]; + } + return null; + } #endif //* SQLITE_OMIT_COMPILEOPTION_DIAGS */ - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/date_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/date_c.cs index 9b30ea8a3..4497a7722 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/date_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/date_c.cs @@ -2,515 +2,577 @@ using System.Diagnostics; using System.Text; -using i64 = System.Int64; -using sqlite3_int64 = System.Int64; using time_t = System.Int64; +using sqlite3_int64 = System.Int64; +using i64 = System.Int64; using u64 = System.UInt64; -namespace Community.CsharpSqlite { - using sqlite3_value = Sqlite3.Mem; +namespace Community.CsharpSqlite +{ + using sqlite3_value = Sqlite3.Mem; - public partial class Sqlite3 { - /* - ** 2003 October 31 - ** - ** 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 contains the C functions that implement date and time - ** functions for SQLite. - ** - ** There is only one exported symbol in this file - the function - ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file. - ** All other code has file scope. - ** - ** SQLite processes all times and dates as Julian Day numbers. The - ** dates and times are stored as the number of days since noon - ** in Greenwich on November 24, 4714 B.C. according to the Gregorian - ** calendar system. - ** - ** 1970-01-01 00:00:00 is JD 2440587.5 - ** 2000-01-01 00:00:00 is JD 2451544.5 - ** - ** This implemention requires years to be expressed as a 4-digit number - ** which means that only dates between 0000-01-01 and 9999-12-31 can - ** be represented, even though julian day numbers allow a much wider - ** range of dates. - ** - ** The Gregorian calendar system is used for all dates and times, - ** even those that predate the Gregorian calendar. Historians usually - ** use the Julian calendar for dates prior to 1582-10-15 and for some - ** dates afterwards, depending on locale. Beware of this difference. - ** - ** The conversion algorithms are implemented based on descriptions - ** in the following text: - ** - ** Jean Meeus - ** Astronomical Algorithms, 2nd Edition, 1998 - ** ISBM 0-943396-61-1 - ** Willmann-Bell, Inc - ** Richmond, Virginia (USA) - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include - //#include - //#include + public partial class Sqlite3 + { + /* + ** 2003 October 31 + ** + ** 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 contains the C functions that implement date and time + ** functions for SQLite. + ** + ** There is only one exported symbol in this file - the function + ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file. + ** All other code has file scope. + ** + ** SQLite processes all times and dates as Julian Day numbers. The + ** dates and times are stored as the number of days since noon + ** in Greenwich on November 24, 4714 B.C. according to the Gregorian + ** calendar system. + ** + ** 1970-01-01 00:00:00 is JD 2440587.5 + ** 2000-01-01 00:00:00 is JD 2451544.5 + ** + ** This implemention requires years to be expressed as a 4-digit number + ** which means that only dates between 0000-01-01 and 9999-12-31 can + ** be represented, even though julian day numbers allow a much wider + ** range of dates. + ** + ** The Gregorian calendar system is used for all dates and times, + ** even those that predate the Gregorian calendar. Historians usually + ** use the Julian calendar for dates prior to 1582-10-15 and for some + ** dates afterwards, depending on locale. Beware of this difference. + ** + ** The conversion algorithms are implemented based on descriptions + ** in the following text: + ** + ** Jean Meeus + ** Astronomical Algorithms, 2nd Edition, 1998 + ** ISBM 0-943396-61-1 + ** Willmann-Bell, Inc + ** Richmond, Virginia (USA) + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include + //#include + //#include #if !SQLITE_OMIT_DATETIME_FUNCS - /* - ** A structure for holding a single date and time. - */ - //typedef struct DateTime DateTime; - public class DateTime { - public sqlite3_int64 iJD; /* The julian day number times 86400000 */ - public int Y, M, D; /* Year, month, and day */ - public int h, m; /* Hour and minutes */ - public int tz; /* Timezone offset in minutes */ - public double s; /* Seconds */ - public byte validYMD; /* True (1) if Y,M,D are valid */ - public byte validHMS; /* True (1) if h,m,s are valid */ - public byte validJD; /* True (1) if iJD is valid */ - public byte validTZ; /* True (1) if tz is valid */ + /* + ** A structure for holding a single date and time. + */ + //typedef struct DateTime DateTime; + public class DateTime + { + public sqlite3_int64 iJD; /* The julian day number times 86400000 */ + public int Y, M, D; /* Year, month, and day */ + public int h, m; /* Hour and minutes */ + public int tz; /* Timezone offset in minutes */ + public double s; /* Seconds */ + public byte validYMD; /* True (1) if Y,M,D are valid */ + public byte validHMS; /* True (1) if h,m,s are valid */ + public byte validJD; /* True (1) if iJD is valid */ + public byte validTZ; /* True (1) if tz is valid */ - public void CopyTo(DateTime ct) { - ct.iJD = iJD; - ct.Y = Y; - ct.M = M; - ct.D = D; - ct.h = h; - ct.m = m; - ct.tz = tz; - ct.s = s; - ct.validYMD = validYMD; - ct.validHMS = validHMS; - ct.validJD = validJD; - ct.validTZ = validJD; - } - }; + public void CopyTo( DateTime ct ) + { + ct.iJD = iJD; + ct.Y = Y; + ct.M = M; + ct.D = D; + ct.h = h; + ct.m = m; + ct.tz = tz; + ct.s = s; + ct.validYMD = validYMD; + ct.validHMS = validHMS; + ct.validJD = validJD; + ct.validTZ = validJD; + } + }; - // Temporary String for use in this module - static StringBuilder zdtTemp = new StringBuilder(100); - static StringBuilder zdtBuf = new StringBuilder(100); + // Temporary String for use in this module + static StringBuilder zdtTemp = new StringBuilder( 100 ); + static StringBuilder zdtBuf = new StringBuilder( 100 ); - /* - ** Convert zDate into one or more integers. Additional arguments - ** come in groups of 5 as follows: - ** - ** N number of digits in the integer - ** min minimum allowed value of the integer - ** max maximum allowed value of the integer - ** nextC first character after the integer - ** pVal where to write the integers value. - ** - ** Conversions continue until one with nextC==0 is encountered. - ** The function returns the number of successful conversions. - */ - static int getDigits(string zDate, int N0, int min0, int max0, char nextC0, ref int pVal0, int N1, int min1, int max1, char nextC1, ref int pVal1) { - int c0 = getDigits(zDate + '\0', N0, min0, max0, nextC0, ref pVal0); - return c0 == 0 ? 0 : c0 + getDigits(zDate.Substring(zDate.IndexOf(nextC0) + 1) + '\0', N1, min1, max1, nextC1, ref pVal1); - } - static int getDigits(string zDate, int N0, int min0, int max0, char nextC0, ref int pVal0, int N1, int min1, int max1, char nextC1, ref int pVal1, int N2, int min2, int max2, char nextC2, ref int pVal2) { - int c0 = getDigits(zDate + '\0', N0, min0, max0, nextC0, ref pVal0); - if (c0 == 0) - return 0; - string zDate1 = zDate.Substring(zDate.IndexOf(nextC0) + 1); - int c1 = getDigits(zDate1 + '\0', N1, min1, max1, nextC1, ref pVal1); - if (c1 == 0) - return c0; - return c0 + c1 + getDigits(zDate1.Substring(zDate1.IndexOf(nextC1) + 1) + '\0', N2, min2, max2, nextC2, ref pVal2); - } - static int getDigits(string zDate, int N, int min, int max, char nextC, ref int pVal) { - //va_list ap; - int val; - //int N; - //int min; - //int max; - //char nextC; - //int pVal; - int cnt = 0; - //va_start( ap, zDate ); - int zIndex = 0; - //do - //{ - //N = va_arg( ap, ( Int32 ) 0 ); - //min = va_arg( ap, ( Int32 ) 0 ); - //max = va_arg( ap, ( Int32 ) 0 ); - //nextC = (char)va_arg( ap, "char" ); - //pVal = va_arg( ap, ( Int32 ) 0 ); - val = 0; - while (N-- != 0) { - if (!sqlite3Isdigit(zDate[zIndex])) { - goto end_getDigits; - } - val = val * 10 + zDate[zIndex] - '0'; - zIndex++; - } - if (val < min || val > max || zIndex < zDate.Length && (nextC != 0 && nextC != zDate[zIndex])) { - goto end_getDigits; - } - pVal = val; - zIndex++; - cnt++; - //} while ( nextC != 0 && zIndex < zDate.Length ); - end_getDigits: - //va_end( ap ); - return cnt; + /* + ** Convert zDate into one or more integers. Additional arguments + ** come in groups of 5 as follows: + ** + ** N number of digits in the integer + ** min minimum allowed value of the integer + ** max maximum allowed value of the integer + ** nextC first character after the integer + ** pVal where to write the integers value. + ** + ** Conversions continue until one with nextC==0 is encountered. + ** The function returns the number of successful conversions. + */ + static int getDigits( string zDate, int N0, int min0, int max0, char nextC0, ref int pVal0, int N1, int min1, int max1, char nextC1, ref int pVal1 ) + { + int c0 = getDigits( zDate + '\0', N0, min0, max0, nextC0, ref pVal0 ); + return c0 == 0 ? 0 : c0 + getDigits( zDate.Substring( zDate.IndexOf( nextC0 ) + 1 ) + '\0', N1, min1, max1, nextC1, ref pVal1 ); + } + static int getDigits( string zDate, int N0, int min0, int max0, char nextC0, ref int pVal0, int N1, int min1, int max1, char nextC1, ref int pVal1, int N2, int min2, int max2, char nextC2, ref int pVal2 ) + { + int c0 = getDigits( zDate + '\0', N0, min0, max0, nextC0, ref pVal0 ); + if ( c0 == 0 ) + return 0; + string zDate1 = zDate.Substring( zDate.IndexOf( nextC0 ) + 1 ); + int c1 = getDigits( zDate1 + '\0', N1, min1, max1, nextC1, ref pVal1 ); + if ( c1 == 0 ) + return c0; + return c0 + c1 + getDigits( zDate1.Substring( zDate1.IndexOf( nextC1 ) + 1 ) + '\0', N2, min2, max2, nextC2, ref pVal2 ); + } + static int getDigits( string zDate, int N, int min, int max, char nextC, ref int pVal ) + { + //va_list ap; + int val; + //int N; + //int min; + //int max; + //char nextC; + //int pVal; + int cnt = 0; + //va_start( ap, zDate ); + int zIndex = 0; + //do + //{ + //N = va_arg( ap, ( Int32 ) 0 ); + //min = va_arg( ap, ( Int32 ) 0 ); + //max = va_arg( ap, ( Int32 ) 0 ); + //nextC = (char)va_arg( ap, "char" ); + //pVal = va_arg( ap, ( Int32 ) 0 ); + val = 0; + while ( N-- != 0 ) + { + if ( !sqlite3Isdigit( zDate[zIndex] ) ) + { + goto end_getDigits; } + val = val * 10 + zDate[zIndex] - '0'; + zIndex++; + } + if ( val < min || val > max || zIndex < zDate.Length && ( nextC != 0 && nextC != zDate[zIndex] ) ) + { + goto end_getDigits; + } + pVal = val; + zIndex++; + cnt++; +//} while ( nextC != 0 && zIndex < zDate.Length ); +end_getDigits: + //va_end( ap ); + return cnt; + } - /* - ** Parse a timezone extension on the end of a date-time. - ** The extension is of the form: - ** - ** (+/-)HH:MM - ** - ** - ** Or the "zulu" notation: - ** - ** Z - ** - ** If the parse is successful, write the number of minutes - ** of change in p.tz and return 0. If a parser error occurs, - ** return non-zero. - ** - ** A missing specifier is not considered an error. - */ - static int parseTimezone(string zDate, DateTime p) { - int sgn = 0; - int nHr = 0; - int nMn = 0; - char c; - zDate = zDate.Trim();// while ( sqlite3Isspace( *(u8)zDate ) ) { zDate++; } - p.tz = 0; - c = zDate.Length == 0 ? '\0' : zDate[0]; - if (c == '-') { - sgn = -1; - } else if (c == '+') { - sgn = +1; - } else if (c == 'Z' || c == 'z') { - zDate = zDate.Substring(1).Trim();//zDate++; - goto zulu_time; - } else { - return c != '\0' ? 1 : 0; - } - //zDate++; - if (getDigits(zDate.Substring(1), 2, 0, 14, ':', ref nHr, 2, 0, 59, '\0', ref nMn) != 2) { - return 1; - } - //zDate += 5; - p.tz = sgn * (nMn + nHr * 60); - if (zDate.Length == 6) - zDate = ""; - else if (zDate.Length > 6) - zDate = zDate.Substring(6).Trim();// while ( sqlite3Isspace( *(u8)zDate ) ) { zDate++; } - zulu_time: - return zDate != "" ? 1 : 0; - } + /* + ** Parse a timezone extension on the end of a date-time. + ** The extension is of the form: + ** + ** (+/-)HH:MM + ** + ** + ** Or the "zulu" notation: + ** + ** Z + ** + ** If the parse is successful, write the number of minutes + ** of change in p.tz and return 0. If a parser error occurs, + ** return non-zero. + ** + ** A missing specifier is not considered an error. + */ + static int parseTimezone( string zDate, DateTime p ) + { + int sgn = 0; + int nHr = 0; + int nMn = 0; + char c; + zDate = zDate.Trim();// while ( sqlite3Isspace( *(u8)zDate ) ) { zDate++; } + p.tz = 0; + c = zDate.Length == 0 ? '\0' : zDate[0]; + if ( c == '-' ) + { + sgn = -1; + } + else if ( c == '+' ) + { + sgn = +1; + } + else if ( c == 'Z' || c == 'z' ) + { + zDate = zDate.Substring( 1 ).Trim();//zDate++; + goto zulu_time; + } + else + { + return c != '\0' ? 1 : 0; + } + //zDate++; + if ( getDigits( zDate.Substring( 1 ), 2, 0, 14, ':', ref nHr, 2, 0, 59, '\0', ref nMn ) != 2 ) + { + return 1; + } + //zDate += 5; + p.tz = sgn * ( nMn + nHr * 60 ); + if ( zDate.Length == 6 ) + zDate = ""; + else if ( zDate.Length > 6 ) + zDate = zDate.Substring( 6 ).Trim();// while ( sqlite3Isspace( *(u8)zDate ) ) { zDate++; } +zulu_time: + return zDate != "" ? 1 : 0; + } - /* - ** Parse times of the form HH:MM or HH:MM:SS or HH:MM:SS.FFFF. - ** The HH, MM, and SS must each be exactly 2 digits. The - ** fractional seconds FFFF can be one or more digits. - ** - ** Return 1 if there is a parsing error and 0 on success. - */ - static int parseHhMmSs(string zDate, DateTime p) { - int h = 0; - int m = 0; - int s = 0; - double ms = 0.0; - if (getDigits(zDate, 2, 0, 24, ':', ref h, 2, 0, 59, '\0', ref m) != 2) { - return 1; - } - int zIndex = 5;// zDate += 5; - if (zIndex < zDate.Length && zDate[zIndex] == ':') { - zIndex++;// zDate++; - if (getDigits(zDate.Substring(zIndex), 2, 0, 59, '\0', ref s) != 1) { - return 1; - } - zIndex += 2;// zDate += 2; - if (zIndex + 1 < zDate.Length && zDate[zIndex] == '.' && sqlite3Isdigit(zDate[zIndex + 1])) { - double rScale = 1.0; - zIndex++;// zDate++; - while (zIndex < zDate.Length && sqlite3Isdigit(zDate[zIndex]) - ) { - ms = ms * 10.0 + zDate[zIndex] - '0'; - rScale *= 10.0; - zIndex++;//zDate++; - } - ms /= rScale; - } - } else { - s = 0; - } - p.validJD = 0; - p.validHMS = 1; - p.h = h; - p.m = m; - p.s = s + ms; - if (zIndex < zDate.Length && parseTimezone(zDate.Substring(zIndex), p) != 0) - return 1; - p.validTZ = (byte)((p.tz != 0) ? 1 : 0); - return 0; + /* + ** Parse times of the form HH:MM or HH:MM:SS or HH:MM:SS.FFFF. + ** The HH, MM, and SS must each be exactly 2 digits. The + ** fractional seconds FFFF can be one or more digits. + ** + ** Return 1 if there is a parsing error and 0 on success. + */ + static int parseHhMmSs( string zDate, DateTime p ) + { + int h = 0; + int m = 0; + int s = 0; + double ms = 0.0; + if ( getDigits( zDate, 2, 0, 24, ':', ref h, 2, 0, 59, '\0', ref m ) != 2 ) + { + return 1; + } + int zIndex = 5;// zDate += 5; + if ( zIndex < zDate.Length && zDate[zIndex] == ':' ) + { + zIndex++;// zDate++; + if ( getDigits( zDate.Substring( zIndex ), 2, 0, 59, '\0', ref s ) != 1 ) + { + return 1; + } + zIndex += 2;// zDate += 2; + if ( zIndex + 1 < zDate.Length && zDate[zIndex] == '.' && sqlite3Isdigit( zDate[zIndex + 1] ) ) + { + double rScale = 1.0; + zIndex++;// zDate++; + while ( zIndex < zDate.Length && sqlite3Isdigit( zDate[zIndex] ) + ) + { + ms = ms * 10.0 + zDate[zIndex] - '0'; + rScale *= 10.0; + zIndex++;//zDate++; + } + ms /= rScale; } + } + else + { + s = 0; + } + p.validJD = 0; + p.validHMS = 1; + p.h = h; + p.m = m; + p.s = s + ms; + if ( zIndex < zDate.Length && parseTimezone( zDate.Substring( zIndex ), p ) != 0 ) + return 1; + p.validTZ = (byte)( ( p.tz != 0 ) ? 1 : 0 ); + return 0; + } - /* - ** Convert from YYYY-MM-DD HH:MM:SS to julian day. We always assume - ** that the YYYY-MM-DD is according to the Gregorian calendar. - ** - ** Reference: Meeus page 61 - */ - static void computeJD(DateTime p) { - int Y, M, D, A, B, X1, X2; + /* + ** Convert from YYYY-MM-DD HH:MM:SS to julian day. We always assume + ** that the YYYY-MM-DD is according to the Gregorian calendar. + ** + ** Reference: Meeus page 61 + */ + static void computeJD( DateTime p ) + { + int Y, M, D, A, B, X1, X2; - if (p.validJD != 0) - return; - if (p.validYMD != 0) { - Y = p.Y; - M = p.M; - D = p.D; - } else { - Y = 2000; /* If no YMD specified, assume 2000-Jan-01 */ - M = 1; - D = 1; - } - if (M <= 2) { - Y--; - M += 12; - } - A = Y / 100; - B = 2 - A + (A / 4); - X1 = (int)(36525 * (Y + 4716) / 100); - X2 = (int)(306001 * (M + 1) / 10000); - p.iJD = (long)((X1 + X2 + D + B - 1524.5) * 86400000); - p.validJD = 1; - if (p.validHMS != 0) { - p.iJD += (long)(p.h * 3600000 + p.m * 60000 + p.s * 1000); - if (p.validTZ != 0) { - p.iJD -= p.tz * 60000; - p.validYMD = 0; - p.validHMS = 0; - p.validTZ = 0; - } - } + if ( p.validJD != 0 ) + return; + if ( p.validYMD != 0 ) + { + Y = p.Y; + M = p.M; + D = p.D; + } + else + { + Y = 2000; /* If no YMD specified, assume 2000-Jan-01 */ + M = 1; + D = 1; + } + if ( M <= 2 ) + { + Y--; + M += 12; + } + A = Y / 100; + B = 2 - A + ( A / 4 ); + X1 = (int)( 36525 * ( Y + 4716 ) / 100 ); + X2 = (int)( 306001 * ( M + 1 ) / 10000 ); + p.iJD = (long)( ( X1 + X2 + D + B - 1524.5 ) * 86400000 ); + p.validJD = 1; + if ( p.validHMS != 0 ) + { + p.iJD += (long)( p.h * 3600000 + p.m * 60000 + p.s * 1000 ); + if ( p.validTZ != 0 ) + { + p.iJD -= p.tz * 60000; + p.validYMD = 0; + p.validHMS = 0; + p.validTZ = 0; } + } + } - /* - ** Parse dates of the form - ** - ** YYYY-MM-DD HH:MM:SS.FFF - ** YYYY-MM-DD HH:MM:SS - ** YYYY-MM-DD HH:MM - ** YYYY-MM-DD - ** - ** Write the result into the DateTime structure and return 0 - ** on success and 1 if the input string is not a well-formed - ** date. - */ - static int parseYyyyMmDd(string zDate, DateTime p) { - int Y = 0; - int M = 0; - int D = 0; - bool neg; + /* + ** Parse dates of the form + ** + ** YYYY-MM-DD HH:MM:SS.FFF + ** YYYY-MM-DD HH:MM:SS + ** YYYY-MM-DD HH:MM + ** YYYY-MM-DD + ** + ** Write the result into the DateTime structure and return 0 + ** on success and 1 if the input string is not a well-formed + ** date. + */ + static int parseYyyyMmDd( string zDate, DateTime p ) + { + int Y = 0; + int M = 0; + int D = 0; + bool neg; - int zIndex = 0; - if (zDate[zIndex] == '-') { - zIndex++;// zDate++; - neg = true; - } else { - neg = false; - } - if (getDigits(zDate.Substring(zIndex), 4, 0, 9999, '-', ref Y, 2, 1, 12, '-', ref M, 2, 1, 31, '\0', ref D) != 3) { - return 1; - } - zIndex += 10;// zDate += 10; - while (zIndex < zDate.Length && (sqlite3Isspace(zDate[zIndex]) || 'T' == zDate[zIndex])) { - zIndex++; - }//zDate++; } - if (zIndex < zDate.Length && parseHhMmSs(zDate.Substring(zIndex), p) == 0) { - /* We got the time */ - } else if (zIndex >= zDate.Length)// zDate[zIndex] == '\0') - { - p.validHMS = 0; - } else { - return 1; - } - p.validJD = 0; - p.validYMD = 1; - p.Y = neg ? -Y : Y; - p.M = M; - p.D = D; - if (p.validTZ != 0) { - computeJD(p); - } - return 0; - } + int zIndex = 0; + if ( zDate[zIndex] == '-' ) + { + zIndex++;// zDate++; + neg = true; + } + else + { + neg = false; + } + if ( getDigits( zDate.Substring( zIndex ), 4, 0, 9999, '-', ref Y, 2, 1, 12, '-', ref M, 2, 1, 31, '\0', ref D ) != 3 ) + { + return 1; + } + zIndex += 10;// zDate += 10; + while ( zIndex < zDate.Length && ( sqlite3Isspace( zDate[zIndex] ) || 'T' == zDate[zIndex] ) ) + { + zIndex++; + }//zDate++; } + if ( zIndex < zDate.Length && parseHhMmSs( zDate.Substring( zIndex ), p ) == 0 ) + { + /* We got the time */ + } + else if ( zIndex >= zDate.Length )// zDate[zIndex] == '\0') + { + p.validHMS = 0; + } + else + { + return 1; + } + p.validJD = 0; + p.validYMD = 1; + p.Y = neg ? -Y : Y; + p.M = M; + p.D = D; + if ( p.validTZ != 0 ) + { + computeJD( p ); + } + return 0; + } - /* - ** Set the time to the current time reported by the VFS - */ - static void setDateTimeToCurrent(sqlite3_context context, DateTime p) { - sqlite3 db = sqlite3_context_db_handle(context); - sqlite3OsCurrentTimeInt64(db.pVfs, ref p.iJD); - p.validJD = 1; - } + /* + ** Set the time to the current time reported by the VFS + */ + static void setDateTimeToCurrent( sqlite3_context context, DateTime p ) + { + sqlite3 db = sqlite3_context_db_handle( context ); + sqlite3OsCurrentTimeInt64( db.pVfs, ref p.iJD ); + p.validJD = 1; + } - /* - ** Attempt to parse the given string into a Julian Day Number. Return - ** the number of errors. - ** - ** The following are acceptable forms for the input string: - ** - ** YYYY-MM-DD HH:MM:SS.FFF +/-HH:MM - ** DDDD.DD - ** now - ** - ** In the first form, the +/-HH:MM is always optional. The fractional - ** seconds extension (the ".FFF") is optional. The seconds portion - ** (":SS.FFF") is option. The year and date can be omitted as long - ** as there is a time string. The time string can be omitted as long - ** as there is a year and date. - */ - static int parseDateOrTime( - sqlite3_context context, - string zDate, - ref DateTime p - ) { - double r = 0.0; - if (parseYyyyMmDd(zDate, p) == 0) { - return 0; - } else if (parseHhMmSs(zDate, p) == 0) { - return 0; - } else if (zDate.Equals("now", StringComparison.OrdinalIgnoreCase)) { - setDateTimeToCurrent(context, p); - return 0; - } else if (sqlite3AtoF(zDate, ref r, sqlite3Strlen30(zDate), SQLITE_UTF8)) { - p.iJD = (sqlite3_int64)(r * 86400000.0 + 0.5); - p.validJD = 1; - return 0; - } - return 1; - } + /* + ** Attempt to parse the given string into a Julian Day Number. Return + ** the number of errors. + ** + ** The following are acceptable forms for the input string: + ** + ** YYYY-MM-DD HH:MM:SS.FFF +/-HH:MM + ** DDDD.DD + ** now + ** + ** In the first form, the +/-HH:MM is always optional. The fractional + ** seconds extension (the ".FFF") is optional. The seconds portion + ** (":SS.FFF") is option. The year and date can be omitted as long + ** as there is a time string. The time string can be omitted as long + ** as there is a year and date. + */ + static int parseDateOrTime( + sqlite3_context context, + string zDate, + ref DateTime p + ) + { + double r = 0.0; + if ( parseYyyyMmDd( zDate, p ) == 0 ) + { + return 0; + } + else if ( parseHhMmSs( zDate, p ) == 0 ) + { + return 0; + } + else if ( zDate.Equals( "now", StringComparison.OrdinalIgnoreCase ) ) + { + setDateTimeToCurrent( context, p ); + return 0; + } + else if ( sqlite3AtoF( zDate, ref r, sqlite3Strlen30( zDate ), SQLITE_UTF8 ) ) + { + p.iJD = (sqlite3_int64)( r * 86400000.0 + 0.5 ); + p.validJD = 1; + return 0; + } + return 1; + } - /* - ** Compute the Year, Month, and Day from the julian day number. - */ - static void computeYMD(DateTime p) { - int Z, A, B, C, D, E, X1; - if (p.validYMD != 0) - return; - if (0 == p.validJD) { - p.Y = 2000; - p.M = 1; - p.D = 1; - } else { - Z = (int)((p.iJD + 43200000) / 86400000); - A = (int)((Z - 1867216.25) / 36524.25); - A = Z + 1 + A - (A / 4); - B = A + 1524; - C = (int)((B - 122.1) / 365.25); - D = (int)((36525 * C) / 100); - E = (int)((B - D) / 30.6001); - X1 = (int)(30.6001 * E); - p.D = B - D - X1; - p.M = E < 14 ? E - 1 : E - 13; - p.Y = p.M > 2 ? C - 4716 : C - 4715; - } - p.validYMD = 1; - } + /* + ** Compute the Year, Month, and Day from the julian day number. + */ + static void computeYMD( DateTime p ) + { + int Z, A, B, C, D, E, X1; + if ( p.validYMD != 0 ) + return; + if ( 0 == p.validJD ) + { + p.Y = 2000; + p.M = 1; + p.D = 1; + } + else + { + Z = (int)( ( p.iJD + 43200000 ) / 86400000 ); + A = (int)( ( Z - 1867216.25 ) / 36524.25 ); + A = Z + 1 + A - ( A / 4 ); + B = A + 1524; + C = (int)( ( B - 122.1 ) / 365.25 ); + D = (int)( ( 36525 * C ) / 100 ); + E = (int)( ( B - D ) / 30.6001 ); + X1 = (int)( 30.6001 * E ); + p.D = B - D - X1; + p.M = E < 14 ? E - 1 : E - 13; + p.Y = p.M > 2 ? C - 4716 : C - 4715; + } + p.validYMD = 1; + } - /* - ** Compute the Hour, Minute, and Seconds from the julian day number. - */ - static void computeHMS(DateTime p) { - int s; - if (p.validHMS != 0) - return; - computeJD(p); - s = (int)((p.iJD + 43200000) % 86400000); - p.s = s / 1000.0; - s = (int)p.s; - p.s -= s; - p.h = s / 3600; - s -= p.h * 3600; - p.m = s / 60; - p.s += s - p.m * 60; - p.validHMS = 1; - } + /* + ** Compute the Hour, Minute, and Seconds from the julian day number. + */ + static void computeHMS( DateTime p ) + { + int s; + if ( p.validHMS != 0 ) + return; + computeJD( p ); + s = (int)( ( p.iJD + 43200000 ) % 86400000 ); + p.s = s / 1000.0; + s = (int)p.s; + p.s -= s; + p.h = s / 3600; + s -= p.h * 3600; + p.m = s / 60; + p.s += s - p.m * 60; + p.validHMS = 1; + } - /* - ** Compute both YMD and HMS - */ - static void computeYMD_HMS(DateTime p) { - computeYMD(p); - computeHMS(p); - } + /* + ** Compute both YMD and HMS + */ + static void computeYMD_HMS( DateTime p ) + { + computeYMD( p ); + computeHMS( p ); + } - /* - ** Clear the YMD and HMS and the TZ - */ - static void clearYMD_HMS_TZ(DateTime p) { - p.validYMD = 0; - p.validHMS = 0; - p.validTZ = 0; - } + /* + ** Clear the YMD and HMS and the TZ + */ + static void clearYMD_HMS_TZ( DateTime p ) + { + p.validYMD = 0; + p.validHMS = 0; + p.validTZ = 0; + } - /* - ** On recent Windows platforms, the localtime_s() function is available - ** as part of the "Secure CRT". It is essentially equivalent to - ** localtime_r() available under most POSIX platforms, except that the - ** order of the parameters is reversed. - ** - ** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx. - ** - ** If the user has not indicated to use localtime_r() or localtime_s() - ** already, check for an MSVC build environment that provides - ** localtime_s(). - */ - //#if !defined(HAVE_LOCALTIME_R) && !defined(HAVE_LOCALTIME_S) && \ - // defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE) - //#define HAVE_LOCALTIME_S 1 - //#endif + /* + ** On recent Windows platforms, the localtime_s() function is available + ** as part of the "Secure CRT". It is essentially equivalent to + ** localtime_r() available under most POSIX platforms, except that the + ** order of the parameters is reversed. + ** + ** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx. + ** + ** If the user has not indicated to use localtime_r() or localtime_s() + ** already, check for an MSVC build environment that provides + ** localtime_s(). + */ + //#if !defined(HAVE_LOCALTIME_R) && !defined(HAVE_LOCALTIME_S) && \ + // defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE) + //#define HAVE_LOCALTIME_S 1 + //#endif #if !SQLITE_OMIT_LOCALTIME - /* - ** The following routine implements the rough equivalent of localtime_r() - ** using whatever operating-system specific localtime facility that - ** 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. - */ - static int osLocaltime(time_t t, ref tm pTm) { - int rc; + /* + ** The following routine implements the rough equivalent of localtime_r() + ** using whatever operating-system specific localtime facility that + ** 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. + */ + static int osLocaltime( time_t t, ref tm pTm ) + { + int rc; #if (!(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) && (!(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S) - tm pX; - sqlite3_mutex mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); - sqlite3_mutex_enter(mutex); - pX = localtime(t); + tm pX; + sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); + sqlite3_mutex_enter( mutex ); + pX = localtime( t ); #if !SQLITE_OMIT_BUILTIN_TEST - if (sqlite3GlobalConfig.bLocaltimeFault) - pX = null; + if ( sqlite3GlobalConfig.bLocaltimeFault ) + pX = null; #endif - if (pX != null) - pTm = pX; - sqlite3_mutex_leave(mutex); - rc = pX == null ? 1 : 0; + if ( pX != null ) + pTm = pX; + sqlite3_mutex_leave( mutex ); + rc = pX == null ? 1 : 0; #else #if !SQLITE_OMIT_BUILTIN_TEST if( sqlite3GlobalConfig.bLocaltimeFault ) return 1; @@ -521,662 +583,746 @@ static int osLocaltime(time_t t, ref tm pTm) { rc = localtime_s(pTm, t); #endif //* HAVE_LOCALTIME_R */ #endif //* HAVE_LOCALTIME_R || HAVE_LOCALTIME_S */ - return rc; - } + return rc; + } #endif //* SQLITE_OMIT_LOCALTIME */ #if !SQLITE_OMIT_LOCALTIME - /* - ** Compute the difference (in milliseconds) between localtime and UTC - ** (a.k.a. GMT) for the time value p where p is in UTC. If no error occurs, - ** return this value and set *pRc to SQLITE_OK. - ** - ** Or, if an error does occur, set *pRc to SQLITE_ERROR. The returned value - ** is undefined in this case. - */ - static sqlite3_int64 localtimeOffset( - DateTime p, /* Date at which to calculate offset */ - sqlite3_context pCtx, /* Write error here if one occurs */ - out int pRc /* OUT: Error code. SQLITE_OK or ERROR */ - ) { - DateTime x; - DateTime y = new DateTime(); - time_t t; - tm sLocal = new tm(); + /* +** Compute the difference (in milliseconds) between localtime and UTC +** (a.k.a. GMT) for the time value p where p is in UTC. If no error occurs, +** return this value and set *pRc to SQLITE_OK. +** +** Or, if an error does occur, set *pRc to SQLITE_ERROR. The returned value +** is undefined in this case. +*/ + static sqlite3_int64 localtimeOffset( + DateTime p, /* Date at which to calculate offset */ + sqlite3_context pCtx, /* Write error here if one occurs */ + out int pRc /* OUT: Error code. SQLITE_OK or ERROR */ + ) + { + DateTime x; + DateTime y = new DateTime(); + time_t t; + tm sLocal = new tm(); - /* Initialize the contents of sLocal to avoid a compiler warning. */ - //memset(&sLocal, 0, sizeof(sLocal)); + /* Initialize the contents of sLocal to avoid a compiler warning. */ + //memset(&sLocal, 0, sizeof(sLocal)); - x = p; - computeYMD_HMS(x); - if (x.Y < 1971 || x.Y >= 2038) { - x.Y = 2000; - x.M = 1; - x.D = 1; - x.h = 0; - x.m = 0; - x.s = 0.0; - } else { - int s = (int)(x.s + 0.5); - x.s = s; - } - x.tz = 0; - x.validJD = 0; - computeJD(x); - t = (long)(x.iJD / 1000 - 210866760000L);// (time_t)(x.iJD/1000 - 21086676*(i64)10000); - if (osLocaltime(t, ref sLocal) != 0) { - sqlite3_result_error(pCtx, "local time unavailable", -1); - pRc = SQLITE_ERROR; - return 0; - } - y.Y = sLocal.tm_year;// +1900; - y.M = sLocal.tm_mon;// +1; - y.D = sLocal.tm_mday; - y.h = sLocal.tm_hour; - y.m = sLocal.tm_min; - y.s = sLocal.tm_sec; - y.validYMD = 1; - y.validHMS = 1; - y.validJD = 0; - y.validTZ = 0; - computeJD(y); - pRc = SQLITE_OK; - return (int)(y.iJD - x.iJD); - } + x = p; + computeYMD_HMS( x ); + if ( x.Y < 1971 || x.Y >= 2038 ) + { + x.Y = 2000; + x.M = 1; + x.D = 1; + x.h = 0; + x.m = 0; + x.s = 0.0; + } + else + { + int s = (int)( x.s + 0.5 ); + x.s = s; + } + x.tz = 0; + x.validJD = 0; + computeJD( x ); + t = (long)( x.iJD / 1000 - 210866760000L );// (time_t)(x.iJD/1000 - 21086676*(i64)10000); + if ( osLocaltime( t, ref sLocal ) != 0 ) + { + sqlite3_result_error( pCtx, "local time unavailable", -1 ); + pRc = SQLITE_ERROR; + return 0; + } + y.Y = sLocal.tm_year;// +1900; + y.M = sLocal.tm_mon;// +1; + y.D = sLocal.tm_mday; + y.h = sLocal.tm_hour; + y.m = sLocal.tm_min; + y.s = sLocal.tm_sec; + y.validYMD = 1; + y.validHMS = 1; + y.validJD = 0; + y.validTZ = 0; + computeJD( y ); + pRc = SQLITE_OK; + return (int)( y.iJD - x.iJD ); + } #endif //* SQLITE_OMIT_LOCALTIME */ - /* - ** Process a modifier to a date-time stamp. The modifiers are - ** as follows: - ** - ** NNN days - ** NNN hours - ** NNN minutes - ** NNN.NNNN seconds - ** NNN months - ** NNN years - ** start of month - ** start of year - ** start of week - ** start of day - ** weekday N - ** unixepoch - ** localtime - ** utc - ** - ** Return 0 on success and 1 if there is any kind of error. If the error - ** is in a system call (i.e. localtime()), then an error message is written - ** to context pCtx. If the error is an unrecognized modifier, no error is - ** written to pCtx. - */ - static int parseModifier(sqlite3_context pCtx, string zMod, DateTime p) { - int rc = 1; - int n; - double r = 0; - StringBuilder z = new StringBuilder(zMod.ToLowerInvariant()); - zdtBuf.Length = 0; - //z = zdtBuf; - //for(n=0; niJD = p->iJD/86400 + 21086676*(i64)10000000; - clearYMD_HMS_TZ(p); - rc = 0; - } -#if !SQLITE_OMIT_LOCALTIME - else if (z.ToString() == "utc") { - long c1; - computeJD(p); - c1 = localtimeOffset(p, pCtx, out rc); - if (rc == SQLITE_OK) { - p.iJD -= c1; - clearYMD_HMS_TZ(p); - p.iJD += c1 - localtimeOffset(p, pCtx, out rc); - } - } + case 'u': + { + /* + ** unixepoch + ** + ** Treat the current value of p.iJD as the number of + ** seconds since 1970. Convert to a real julian day number. + */ + if ( z.ToString() == "unixepoch" && p.validJD != 0 ) + { + p.iJD = (long)( ( p.iJD + 43200 ) / 86400 + 210866760000000L );//p->iJD = p->iJD/86400 + 21086676*(i64)10000000; + clearYMD_HMS_TZ( p ); + rc = 0; + } +#if !SQLITE_OMIT_LOCALTIME + else if ( z.ToString() == "utc" ) + { + long c1; + computeJD( p ); + c1 = localtimeOffset( p, pCtx, out rc ); + if ( rc == SQLITE_OK ) + { + p.iJD -= c1; + clearYMD_HMS_TZ( p ); + p.iJD += c1 - localtimeOffset( p, pCtx, out rc ); + } + } #endif - break; - } - case 'w': { - /* - ** weekday N - ** - ** Move the date to the same time on the next occurrence of - ** weekday N where 0==Sunday, 1==Monday, and so forth. If the - ** date is already on the appropriate weekday, this is a no-op. - */ - if (z.ToString().StartsWith("weekday ", StringComparison.Ordinal) - && sqlite3AtoF(z.ToString().Substring(8), ref r, sqlite3Strlen30(z.ToString().Substring(8)), SQLITE_UTF8) - && (n = (int)r) == r && n >= 0 && r < 7) { - sqlite3_int64 Z; - computeYMD_HMS(p); - p.validTZ = 0; - p.validJD = 0; - computeJD(p); - Z = ((p.iJD + 129600000) / 86400000) % 7; - if (Z > n) - Z -= 7; - p.iJD += (n - Z) * 86400000; - clearYMD_HMS_TZ(p); - rc = 0; - } - break; - } - case 's': { - /* - ** start of TTTTT - ** - ** Move the date backwards to the beginning of the current day, - ** or month or year. - */ - if (z.Length <= 9) - z.Length = 0; - else - z.Remove(0, 9);//z += 9; - computeYMD(p); - p.validHMS = 1; - p.h = p.m = 0; - p.s = 0.0; - p.validTZ = 0; - p.validJD = 0; - if (z.ToString() == "month") { - p.D = 1; - rc = 0; - } else if (z.ToString() == "year") { - computeYMD(p); - p.M = 1; - p.D = 1; - rc = 0; - } else if (z.ToString() == "day") { - rc = 0; - } - break; - } - case '+': - case '-': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': { - double rRounder; - for (n = 1; n < z.Length && z[n] != ':' && !sqlite3Isspace(z[n]); n++) { - } - if (!sqlite3AtoF(z.ToString(), ref r, n, SQLITE_UTF8)) { - rc = 1; - break; - } - Debug.Assert(n >= 1); - if (z[n] == ':') { - /* A modifier of the form (+|-)HH:MM:SS.FFF adds (or subtracts) the - ** specified number of hours, minutes, seconds, and fractional seconds - ** to the time. The ".FFF" may be omitted. The ":SS.FFF" may be - ** omitted. - */ - string z2 = z.ToString(); - DateTime tx; - sqlite3_int64 day; - int z2Index = 0; - if (!sqlite3Isdigit(z2[z2Index])) - z2Index++;// z2++; - tx = new DateTime();// memset( &tx, 0, sizeof(tx)); - if (parseHhMmSs(z2.Substring(z2Index), tx) != 0) - break; - computeJD(tx); - tx.iJD -= 43200000; - day = tx.iJD / 86400000; - tx.iJD -= day * 86400000; - if (z[0] == '-') - tx.iJD = -tx.iJD; - computeJD(p); - clearYMD_HMS_TZ(p); - p.iJD += tx.iJD; - rc = 0; - break; - } - //z += n; - while (sqlite3Isspace(z[n])) - n++;// z++; - z = z.Remove(0, n); - n = sqlite3Strlen30(z); - if (n > 10 || n < 3) - break; - if (z[n - 1] == 's') { - z.Length = --n; - }// z[n - 1] = '\0'; n--; } - computeJD(p); - rc = 0; - rRounder = r < 0 ? -0.5 : +0.5; - if (n == 3 && z.ToString() == "day") { - p.iJD += (long)(r * 86400000.0 + rRounder); - } else if (n == 4 && z.ToString() == "hour") { - p.iJD += (long)(r * (86400000.0 / 24.0) + rRounder); - } else if (n == 6 && z.ToString() == "minute") { - p.iJD += (long)(r * (86400000.0 / (24.0 * 60.0)) + rRounder); - } else if (n == 6 && z.ToString() == "second") { - p.iJD += (long)(r * (86400000.0 / (24.0 * 60.0 * 60.0)) + rRounder); - } else if (n == 5 && z.ToString() == "month") { - int x, y; - computeYMD_HMS(p); - p.M += (int)r; - x = p.M > 0 ? (p.M - 1) / 12 : (p.M - 12) / 12; - p.Y += x; - p.M -= x * 12; - p.validJD = 0; - computeJD(p); - y = (int)r; - if (y != r) { - p.iJD += (long)((r - y) * 30.0 * 86400000.0 + rRounder); - } - } else if (n == 4 && z.ToString() == "year") { - int y = (int)r; - computeYMD_HMS(p); - p.Y += y; - p.validJD = 0; - computeJD(p); - if (y != r) { - p.iJD += (sqlite3_int64)((r - y) * 365.0 * 86400000.0 + rRounder); - } - } else { - rc = 1; - } - clearYMD_HMS_TZ(p); - break; - } - default: { - break; - } + break; + } + case 'w': + { + /* + ** weekday N + ** + ** Move the date to the same time on the next occurrence of + ** weekday N where 0==Sunday, 1==Monday, and so forth. If the + ** date is already on the appropriate weekday, this is a no-op. + */ + if ( z.ToString().StartsWith( "weekday ", StringComparison.Ordinal ) + && sqlite3AtoF( z.ToString().Substring( 8 ), ref r, sqlite3Strlen30( z.ToString().Substring( 8 ) ), SQLITE_UTF8 ) + && ( n = (int)r ) == r && n >= 0 && r < 7 ) + { + sqlite3_int64 Z; + computeYMD_HMS( p ); + p.validTZ = 0; + p.validJD = 0; + computeJD( p ); + Z = ( ( p.iJD + 129600000 ) / 86400000 ) % 7; + if ( Z > n ) + Z -= 7; + p.iJD += ( n - Z ) * 86400000; + clearYMD_HMS_TZ( p ); + rc = 0; } - return rc; - } - - /* - ** Process time function arguments. argv[0] is a date-time stamp. - ** argv[1] and following are modifiers. Parse them all and write - ** the resulting time into the DateTime structure p. Return 0 - ** on success and 1 if there are any errors. - ** - ** If there are zero parameters (if even argv[0] is undefined) - ** then assume a default value of "now" for argv[0]. - */ - static int isDate( - sqlite3_context context, - int argc, - sqlite3_value[] argv, - ref DateTime p - ) { - int i; - string z; - int eType; - p = new DateTime();//memset(p, 0, sizeof(*p)); - if (argc == 0) { - setDateTimeToCurrent(context, p); - } else if ((eType = sqlite3_value_type(argv[0])) == SQLITE_FLOAT - || eType == SQLITE_INTEGER) { - p.iJD = (long)(sqlite3_value_double(argv[0]) * 86400000.0 + 0.5); - p.validJD = 1; - } else { - z = sqlite3_value_text(argv[0]); - if (String.IsNullOrEmpty(z) || parseDateOrTime(context, z, ref p) != 0) { - return 1; - } + break; + } + case 's': + { + /* + ** start of TTTTT + ** + ** Move the date backwards to the beginning of the current day, + ** or month or year. + */ + if ( z.Length <= 9 ) + z.Length = 0; + else + z.Remove( 0, 9 );//z += 9; + computeYMD( p ); + p.validHMS = 1; + p.h = p.m = 0; + p.s = 0.0; + p.validTZ = 0; + p.validJD = 0; + if ( z.ToString() == "month" ) + { + p.D = 1; + rc = 0; + } + else if ( z.ToString() == "year" ) + { + computeYMD( p ); + p.M = 1; + p.D = 1; + rc = 0; + } + else if ( z.ToString() == "day" ) + { + rc = 0; + } + break; + } + case '+': + case '-': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + double rRounder; + for ( n = 1; n < z.Length && z[n] != ':' && !sqlite3Isspace( z[n] ); n++ ) + { + } + if ( !sqlite3AtoF( z.ToString(), ref r, n, SQLITE_UTF8 ) ) + { + rc = 1; + break; + } + Debug.Assert( n >= 1 ); + if ( z[n] == ':' ) + { + /* A modifier of the form (+|-)HH:MM:SS.FFF adds (or subtracts) the + ** specified number of hours, minutes, seconds, and fractional seconds + ** to the time. The ".FFF" may be omitted. The ":SS.FFF" may be + ** omitted. + */ + string z2 = z.ToString(); + DateTime tx; + sqlite3_int64 day; + int z2Index = 0; + if ( !sqlite3Isdigit( z2[z2Index] ) ) + z2Index++;// z2++; + tx = new DateTime();// memset( &tx, 0, sizeof(tx)); + if ( parseHhMmSs( z2.Substring( z2Index ), tx ) != 0 ) + break; + computeJD( tx ); + tx.iJD -= 43200000; + day = tx.iJD / 86400000; + tx.iJD -= day * 86400000; + if ( z[0] == '-' ) + tx.iJD = -tx.iJD; + computeJD( p ); + clearYMD_HMS_TZ( p ); + p.iJD += tx.iJD; + rc = 0; + break; + } + //z += n; + while ( sqlite3Isspace( z[n] ) ) + n++;// z++; + z = z.Remove( 0, n ); + n = sqlite3Strlen30( z ); + if ( n > 10 || n < 3 ) + break; + if ( z[n - 1] == 's' ) + { + z.Length = --n; + }// z[n - 1] = '\0'; n--; } + computeJD( p ); + rc = 0; + rRounder = r < 0 ? -0.5 : +0.5; + if ( n == 3 && z.ToString() == "day" ) + { + p.iJD += (long)( r * 86400000.0 + rRounder ); + } + else if ( n == 4 && z.ToString() == "hour" ) + { + p.iJD += (long)( r * ( 86400000.0 / 24.0 ) + rRounder ); + } + else if ( n == 6 && z.ToString() == "minute" ) + { + p.iJD += (long)( r * ( 86400000.0 / ( 24.0 * 60.0 ) ) + rRounder ); } - for (i = 1; i < argc; i++) { - z = sqlite3_value_text(argv[i]); - if (String.IsNullOrEmpty(z) || parseModifier(context, z, p) != 0) - return 1; + else if ( n == 6 && z.ToString() == "second" ) + { + p.iJD += (long)( r * ( 86400000.0 / ( 24.0 * 60.0 * 60.0 ) ) + rRounder ); + } + else if ( n == 5 && z.ToString() == "month" ) + { + int x, y; + computeYMD_HMS( p ); + p.M += (int)r; + x = p.M > 0 ? ( p.M - 1 ) / 12 : ( p.M - 12 ) / 12; + p.Y += x; + p.M -= x * 12; + p.validJD = 0; + computeJD( p ); + y = (int)r; + if ( y != r ) + { + p.iJD += (long)( ( r - y ) * 30.0 * 86400000.0 + rRounder ); + } } - return 0; + else if ( n == 4 && z.ToString() == "year" ) + { + int y = (int)r; + computeYMD_HMS( p ); + p.Y += y; + p.validJD = 0; + computeJD( p ); + if ( y != r ) + { + p.iJD += (sqlite3_int64)( ( r - y ) * 365.0 * 86400000.0 + rRounder ); + } + } + else + { + rc = 1; + } + clearYMD_HMS_TZ( p ); + break; + } + default: + { + break; + } + } + return rc; + } + + /* + ** Process time function arguments. argv[0] is a date-time stamp. + ** argv[1] and following are modifiers. Parse them all and write + ** the resulting time into the DateTime structure p. Return 0 + ** on success and 1 if there are any errors. + ** + ** If there are zero parameters (if even argv[0] is undefined) + ** then assume a default value of "now" for argv[0]. + */ + static int isDate( + sqlite3_context context, + int argc, + sqlite3_value[] argv, + ref DateTime p + ) + { + int i; + string z; + int eType; + p = new DateTime();//memset(p, 0, sizeof(*p)); + if ( argc == 0 ) + { + setDateTimeToCurrent( context, p ); + } + else if ( ( eType = sqlite3_value_type( argv[0] ) ) == SQLITE_FLOAT + || eType == SQLITE_INTEGER ) + { + p.iJD = (long)( sqlite3_value_double( argv[0] ) * 86400000.0 + 0.5 ); + p.validJD = 1; + } + else + { + z = sqlite3_value_text( argv[0] ); + if ( String.IsNullOrEmpty( z ) || parseDateOrTime( context, z, ref p ) != 0 ) + { + return 1; } + } + for ( i = 1; i < argc; i++ ) + { + z = sqlite3_value_text( argv[i] ); + if ( String.IsNullOrEmpty( z ) || parseModifier( context, z, p ) != 0 ) + return 1; + } + return 0; + } - /* - ** The following routines implement the various date and time functions - ** of SQLite. - */ + /* + ** The following routines implement the various date and time functions + ** of SQLite. + */ - /* - ** julianday( TIMESTRING, MOD, MOD, ...) - ** - ** Return the julian day number of the date specified in the arguments - */ - static void juliandayFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - DateTime x = null; - if (isDate(context, argc, argv, ref x) == 0) { - computeJD(x); - sqlite3_result_double(context, x.iJD / 86400000.0); - } - } + /* + ** julianday( TIMESTRING, MOD, MOD, ...) + ** + ** Return the julian day number of the date specified in the arguments + */ + static void juliandayFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + DateTime x = null; + if ( isDate( context, argc, argv, ref x ) == 0 ) + { + computeJD( x ); + sqlite3_result_double( context, x.iJD / 86400000.0 ); + } + } - /* - ** datetime( TIMESTRING, MOD, MOD, ...) - ** - ** Return YYYY-MM-DD HH:MM:SS - */ - static void datetimeFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - DateTime x = null; - if (isDate(context, argc, argv, ref x) == 0) { - zdtBuf.Length = 0; - computeYMD_HMS(x); - sqlite3_snprintf(100, zdtBuf, "%04d-%02d-%02d %02d:%02d:%02d", - x.Y, x.M, x.D, x.h, x.m, (int)(x.s)); - sqlite3_result_text(context, zdtBuf, -1, SQLITE_TRANSIENT); - } - } + /* + ** datetime( TIMESTRING, MOD, MOD, ...) + ** + ** Return YYYY-MM-DD HH:MM:SS + */ + static void datetimeFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + DateTime x = null; + if ( isDate( context, argc, argv, ref x ) == 0 ) + { + zdtBuf.Length = 0; + computeYMD_HMS( x ); + sqlite3_snprintf( 100, zdtBuf, "%04d-%02d-%02d %02d:%02d:%02d", + x.Y, x.M, x.D, x.h, x.m, (int)( x.s ) ); + sqlite3_result_text( context, zdtBuf, -1, SQLITE_TRANSIENT ); + } + } - /* - ** time( TIMESTRING, MOD, MOD, ...) - ** - ** Return HH:MM:SS - */ - static void timeFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - DateTime x = new DateTime(); - if (isDate(context, argc, argv, ref x) == 0) { - zdtBuf.Length = 0; - computeHMS(x); - sqlite3_snprintf(100, zdtBuf, "%02d:%02d:%02d", x.h, x.m, (int)x.s); - sqlite3_result_text(context, zdtBuf, -1, SQLITE_TRANSIENT); - } - } + /* + ** time( TIMESTRING, MOD, MOD, ...) + ** + ** Return HH:MM:SS + */ + static void timeFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + DateTime x = new DateTime(); + if ( isDate( context, argc, argv, ref x ) == 0 ) + { + zdtBuf.Length = 0; + computeHMS( x ); + sqlite3_snprintf( 100, zdtBuf, "%02d:%02d:%02d", x.h, x.m, (int)x.s ); + sqlite3_result_text( context, zdtBuf, -1, SQLITE_TRANSIENT ); + } + } - /* - ** date( TIMESTRING, MOD, MOD, ...) - ** - ** Return YYYY-MM-DD - */ - static void dateFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - DateTime x = null; - if (isDate(context, argc, argv, ref x) == 0) { - StringBuilder zdtBuf = new StringBuilder(100); - computeYMD(x); - sqlite3_snprintf(100, zdtBuf, "%04d-%02d-%02d", x.Y, x.M, x.D); - sqlite3_result_text(context, zdtBuf, -1, SQLITE_TRANSIENT); + /* + ** date( TIMESTRING, MOD, MOD, ...) + ** + ** Return YYYY-MM-DD + */ + static void dateFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + DateTime x = null; + if ( isDate( context, argc, argv, ref x ) == 0 ) + { + StringBuilder zdtBuf = new StringBuilder( 100 ); + computeYMD( x ); + sqlite3_snprintf( 100, zdtBuf, "%04d-%02d-%02d", x.Y, x.M, x.D ); + sqlite3_result_text( context, zdtBuf, -1, SQLITE_TRANSIENT ); + } + } + + /* + ** strftime( FORMAT, TIMESTRING, MOD, MOD, ...) + ** + ** Return a string described by FORMAT. Conversions as follows: + ** + ** %d day of month + ** %f ** fractional seconds SS.SSS + ** %H hour 00-24 + ** %j day of year 000-366 + ** %J ** Julian day number + ** %m month 01-12 + ** %M minute 00-59 + ** %s seconds since 1970-01-01 + ** %S seconds 00-59 + ** %w day of week 0-6 sunday==0 + ** %W week of year 00-53 + ** %Y year 0000-9999 + ** %% % + */ + static void strftimeFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + { + DateTime x = new DateTime(); + u64 n; + int i, j; + StringBuilder z; + sqlite3 db; + string zFmt = sqlite3_value_text( argv[0] ); + StringBuilder zdtBuf = new StringBuilder( 100 ); + sqlite3_value[] argv1 = new sqlite3_value[argc - 1]; + for ( i = 0; i < argc - 1; i++ ) + { + argv[i + 1].CopyTo( ref argv1[i] ); + } + if ( String.IsNullOrEmpty( zFmt ) || isDate( context, argc - 1, argv1, ref x ) != 0 ) + return; + db = sqlite3_context_db_handle( context ); + for ( i = 0, n = 1; i < zFmt.Length; i++, n++ ) + { + if ( zFmt[i] == '%' ) + { + switch ( (char)zFmt[i + 1] ) + { + case 'd': + case 'H': + case 'm': + case 'M': + case 'S': + case 'W': + n++; + break; + /* fall thru */ + case 'w': + case '%': + break; + case 'f': + n += 8; + break; + case 'j': + n += 3; + break; + case 'Y': + n += 8; + break; + case 's': + case 'J': + n += 50; + break; + default: + return; /* ERROR. return a NULL */ } + i++; + } } - - /* - ** strftime( FORMAT, TIMESTRING, MOD, MOD, ...) - ** - ** Return a string described by FORMAT. Conversions as follows: - ** - ** %d day of month - ** %f ** fractional seconds SS.SSS - ** %H hour 00-24 - ** %j day of year 000-366 - ** %J ** Julian day number - ** %m month 01-12 - ** %M minute 00-59 - ** %s seconds since 1970-01-01 - ** %S seconds 00-59 - ** %w day of week 0-6 sunday==0 - ** %W week of year 00-53 - ** %Y year 0000-9999 - ** %% % - */ - static void strftimeFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { + testcase( n == (u64)( zdtBuf.Length - 1 ) ); + testcase( n == (u64)zdtBuf.Length ); + testcase( n == (u64)db.aLimit[SQLITE_LIMIT_LENGTH] + 1 ); + testcase( n == (u64)db.aLimit[SQLITE_LIMIT_LENGTH] ); + if ( n < (u64)zdtBuf.Capacity ) + { + z = zdtBuf; + } + else if ( n > (u64)db.aLimit[SQLITE_LIMIT_LENGTH] ) + { + sqlite3_result_error_toobig( context ); + return; + } + else + { + z = new StringBuilder( (int)n );// sqlite3DbMallocRaw( db, n ); + //if ( z == 0 ) + //{ + // sqlite3_result_error_nomem( context ); + // return; + //} + } + computeJD( x ); + computeYMD_HMS( x ); + for ( i = j = 0; i < zFmt.Length; i++ ) + { + if ( zFmt[i] != '%' ) + { + z.Append( (char)zFmt[i] ); + } + else + { + i++; + zdtTemp.Length = 0; + switch ( (char)zFmt[i] ) { - DateTime x = new DateTime(); - u64 n; - int i, j; - StringBuilder z; - sqlite3 db; - string zFmt = sqlite3_value_text(argv[0]); - StringBuilder zdtBuf = new StringBuilder(100); - sqlite3_value[] argv1 = new sqlite3_value[argc - 1]; - for (i = 0; i < argc - 1; i++) { - argv[i + 1].CopyTo(ref argv1[i]); + case 'd': + sqlite3_snprintf( 3, zdtTemp, "%02d", x.D ); + z.Append( zdtTemp ); + j += 2; + break; + case 'f': + { + double s = x.s; + if ( s > 59.999 ) + s = 59.999; + sqlite3_snprintf( 7, zdtTemp, "%06.3f", s ); + z.Append( zdtTemp ); + j = sqlite3Strlen30( z ); + break; } - if (String.IsNullOrEmpty(zFmt) || isDate(context, argc - 1, argv1, ref x) != 0) - return; - db = sqlite3_context_db_handle(context); - for (i = 0, n = 1; i < zFmt.Length; i++, n++) { - if (zFmt[i] == '%') { - switch ((char)zFmt[i + 1]) { - case 'd': - case 'H': - case 'm': - case 'M': - case 'S': - case 'W': - n++; - break; - /* fall thru */ - case 'w': - case '%': - break; - case 'f': - n += 8; - break; - case 'j': - n += 3; - break; - case 'Y': - n += 8; - break; - case 's': - case 'J': - n += 50; - break; - default: - return; /* ERROR. return a NULL */ - } - i++; - } + case 'H': + sqlite3_snprintf( 3, zdtTemp, "%02d", x.h ); + z.Append( zdtTemp ); + j += 2; + break; + case 'W': /* Fall thru */ + case 'j': + { + int nDay; /* Number of days since 1st day of year */ + DateTime y = new DateTime(); + x.CopyTo( y ); + y.validJD = 0; + y.M = 1; + y.D = 1; + computeJD( y ); + nDay = (int)( ( x.iJD - y.iJD + 43200000 ) / 86400000 ); + if ( zFmt[i] == 'W' ) + { + int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */ + wd = (int)( ( ( x.iJD + 43200000 ) / 86400000 ) % 7 ); + sqlite3_snprintf( 3, zdtTemp, "%02d", ( nDay + 7 - wd ) / 7 ); + z.Append( zdtTemp ); + j += 2; + } + else + { + sqlite3_snprintf( 4, zdtTemp, "%03d", nDay + 1 ); + z.Append( zdtTemp ); + j += 3; + } + break; } - testcase(n == (u64)(zdtBuf.Length - 1)); - testcase(n == (u64)zdtBuf.Length); - testcase(n == (u64)db.aLimit[SQLITE_LIMIT_LENGTH] + 1); - testcase(n == (u64)db.aLimit[SQLITE_LIMIT_LENGTH]); - if (n < (u64)zdtBuf.Capacity) { - z = zdtBuf; - } else if (n > (u64)db.aLimit[SQLITE_LIMIT_LENGTH]) { - sqlite3_result_error_toobig(context); - return; - } else { - z = new StringBuilder((int)n);// sqlite3DbMallocRaw( db, n ); - //if ( z == 0 ) - //{ - // sqlite3_result_error_nomem( context ); - // return; - //} + case 'J': + { + sqlite3_snprintf( 20, zdtTemp, "%.16g", x.iJD / 86400000.0 ); + z.Append( zdtTemp ); + j = sqlite3Strlen30( z ); + break; } - computeJD(x); - computeYMD_HMS(x); - for (i = j = 0; i < zFmt.Length; i++) { - if (zFmt[i] != '%') { - z.Append((char)zFmt[i]); - } else { - i++; - zdtTemp.Length = 0; - switch ((char)zFmt[i]) { - case 'd': - sqlite3_snprintf(3, zdtTemp, "%02d", x.D); - z.Append(zdtTemp); - j += 2; - break; - case 'f': { - double s = x.s; - if (s > 59.999) - s = 59.999; - sqlite3_snprintf(7, zdtTemp, "%06.3f", s); - z.Append(zdtTemp); - j = sqlite3Strlen30(z); - break; - } - case 'H': - sqlite3_snprintf(3, zdtTemp, "%02d", x.h); - z.Append(zdtTemp); - j += 2; - break; - case 'W': /* Fall thru */ - case 'j': { - int nDay; /* Number of days since 1st day of year */ - DateTime y = new DateTime(); - x.CopyTo(y); - y.validJD = 0; - y.M = 1; - y.D = 1; - computeJD(y); - nDay = (int)((x.iJD - y.iJD + 43200000) / 86400000); - if (zFmt[i] == 'W') { - int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */ - wd = (int)(((x.iJD + 43200000) / 86400000) % 7); - sqlite3_snprintf(3, zdtTemp, "%02d", (nDay + 7 - wd) / 7); - z.Append(zdtTemp); - j += 2; - } else { - sqlite3_snprintf(4, zdtTemp, "%03d", nDay + 1); - z.Append(zdtTemp); - j += 3; - } - break; - } - case 'J': { - sqlite3_snprintf(20, zdtTemp, "%.16g", x.iJD / 86400000.0); - z.Append(zdtTemp); - j = sqlite3Strlen30(z); - break; - } - case 'm': - sqlite3_snprintf(3, zdtTemp, "%02d", x.M); - z.Append(zdtTemp); - j += 2; - break; - case 'M': - sqlite3_snprintf(3, zdtTemp, "%02d", x.m); - z.Append(zdtTemp); - j += 2; - break; - case 's': { - sqlite3_snprintf(30, zdtTemp, "%lld", - (i64)(x.iJD / 1000 - 21086676 * (i64)10000)); - z.Append(zdtTemp); - j = sqlite3Strlen30(z); - break; - } - case 'S': - sqlite3_snprintf(3, zdtTemp, "%02d", (int)x.s); - z.Append(zdtTemp); - j += 2; - break; - case 'w': { - z.Append((((x.iJD + 129600000) / 86400000) % 7)); - break; - } - case 'Y': { - sqlite3_snprintf(5, zdtTemp, "%04d", x.Y); - z.Append(zdtTemp); - j = sqlite3Strlen30(z); - break; - } - default: - z.Append('%'); - break; - } - } + case 'm': + sqlite3_snprintf( 3, zdtTemp, "%02d", x.M ); + z.Append( zdtTemp ); + j += 2; + break; + case 'M': + sqlite3_snprintf( 3, zdtTemp, "%02d", x.m ); + z.Append( zdtTemp ); + j += 2; + break; + case 's': + { + sqlite3_snprintf( 30, zdtTemp, "%lld", + (i64)( x.iJD / 1000 - 21086676 * (i64)10000 ) ); + z.Append( zdtTemp ); + j = sqlite3Strlen30( z ); + break; } - //z[j] = 0; - sqlite3_result_text(context, z, -1, - z == zdtBuf ? SQLITE_TRANSIENT : SQLITE_DYNAMIC); + case 'S': + sqlite3_snprintf( 3, zdtTemp, "%02d", (int)x.s ); + z.Append( zdtTemp ); + j += 2; + break; + case 'w': + { + z.Append( ( ( ( x.iJD + 129600000 ) / 86400000 ) % 7 ) ); + break; + } + case 'Y': + { + sqlite3_snprintf( 5, zdtTemp, "%04d", x.Y ); + z.Append( zdtTemp ); + j = sqlite3Strlen30( z ); + break; + } + default: + z.Append( '%' ); + break; } + } } + //z[j] = 0; + sqlite3_result_text( context, z, -1, + z == zdtBuf ? SQLITE_TRANSIENT : SQLITE_DYNAMIC ); + } + } - /* - ** current_time() - ** - ** This function returns the same value as time('now'). - */ - static void ctimeFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] NotUsed2 - ) { - UNUSED_PARAMETER2(NotUsed, NotUsed2); - timeFunc(context, 0, null); - } + /* + ** current_time() + ** + ** This function returns the same value as time('now'). + */ + static void ctimeFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] NotUsed2 + ) + { + UNUSED_PARAMETER2( NotUsed, NotUsed2 ); + timeFunc( context, 0, null ); + } - /* - ** current_date() - ** - ** This function returns the same value as date('now'). - */ - static void cdateFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] NotUsed2 - ) { - UNUSED_PARAMETER2(NotUsed, NotUsed2); - dateFunc(context, 0, null); - } + /* + ** current_date() + ** + ** This function returns the same value as date('now'). + */ + static void cdateFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] NotUsed2 + ) + { + UNUSED_PARAMETER2( NotUsed, NotUsed2 ); + dateFunc( context, 0, null ); + } - /* - ** current_timestamp() - ** - ** This function returns the same value as datetime('now'). - */ - static void ctimestampFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] NotUsed2 - ) { - UNUSED_PARAMETER2(NotUsed, NotUsed2); - datetimeFunc(context, 0, null); - } + /* + ** current_timestamp() + ** + ** This function returns the same value as datetime('now'). + */ + static void ctimestampFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] NotUsed2 + ) + { + UNUSED_PARAMETER2( NotUsed, NotUsed2 ); + datetimeFunc( context, 0, null ); + } #endif // * !SQLITE_OMIT_DATETIME_FUNCS) */ -#if SQLITE_OMIT_DATETIME_FUNCS +#if SQLITE_OMIT_DATETIME_FUNCS /* ** If the library is compiled to omit the full-scale date and time ** handling (to get a smaller binary), the following minimal version @@ -1224,13 +1370,14 @@ sqlite3_value[] NotUsed2 #endif - /* - ** This function registered all of the above C functions as SQL - ** functions. This should be the only routine in this file with - ** external linkage. - */ - static void sqlite3RegisterDateTimeFunctions() { - FuncDef[] aDateTimeFuncs = new FuncDef[] { + /* +** This function registered all of the above C functions as SQL +** functions. This should be the only routine in this file with +** external linkage. +*/ + static void sqlite3RegisterDateTimeFunctions() + { + FuncDef[] aDateTimeFuncs = new FuncDef[] { #if !SQLITE_OMIT_DATETIME_FUNCS FUNCTION("julianday", -1, 0, 0, (dxFunc)juliandayFunc ), FUNCTION("date", -1, 0, 0, (dxFunc)dateFunc ), @@ -1246,17 +1393,18 @@ static void sqlite3RegisterDateTimeFunctions() { STR_FUNCTION("current_timestamp", 0, "%Y-%m-%d %H:%M:%S", 0, currentTimeFunc), #endif }; - int i; + int i; #if SQLITE_OMIT_WSD FuncDefHash pHash = GLOBAL( FuncDefHash, sqlite3GlobalFunctions ); FuncDef[] aFunc = (FuncDef)GLOBAL( FuncDef, aDateTimeFuncs ); #else - FuncDefHash pHash = sqlite3GlobalFunctions; - FuncDef[] aFunc = aDateTimeFuncs; + FuncDefHash pHash = sqlite3GlobalFunctions; + FuncDef[] aFunc = aDateTimeFuncs; #endif - for (i = 0; i < ArraySize(aDateTimeFuncs); i++) { - sqlite3FuncDefInsert(pHash, aFunc[i]); - } - } + for ( i = 0; i < ArraySize( aDateTimeFuncs ); i++ ) + { + sqlite3FuncDefInsert( pHash, aFunc[i] ); + } } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/delete_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/delete_c.cs index abf16d39d..e291faa56 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/delete_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/delete_c.cs @@ -1,139 +1,152 @@ +using System; using System.Diagnostics; +using System.Text; +using u8 = System.Byte; using u32 = System.UInt32; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 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. - ** - ************************************************************************* - ** This file contains C code routines that are called by the parser - ** in order to generate code for DELETE FROM statements. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - - /* - ** While a SrcList can in general represent multiple tables and subqueries - ** (as in the FROM clause of a SELECT statement) in this case it contains - ** the name of a single table, as one might find in an INSERT, DELETE, - ** or UPDATE statement. Look up that table in the symbol table and - ** return a pointer. Set an error message and return NULL if the table - ** name is not found or if any other error occurs. - ** - ** The following fields are initialized appropriate in pSrc: - ** - ** pSrc->a[0].pTab Pointer to the Table object - ** pSrc->a[0].pIndex Pointer to the INDEXED BY index, if there is one - ** - */ - static Table sqlite3SrcListLookup(Parse pParse, SrcList pSrc) { - SrcList_item pItem = pSrc.a[0]; - Table pTab; - Debug.Assert(pItem != null && pSrc.nSrc == 1); - pTab = sqlite3LocateTable(pParse, 0, pItem.zName, pItem.zDatabase); - sqlite3DeleteTable(pParse.db, ref pItem.pTab); - pItem.pTab = pTab; - if (pTab != null) { - pTab.nRef++; - } - if (sqlite3IndexedByLookup(pParse, pItem) != 0) { - pTab = null; - } - return pTab; - } +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 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. + ** + ************************************************************************* + ** This file contains C code routines that are called by the parser + ** in order to generate code for DELETE FROM statements. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + + /* + ** While a SrcList can in general represent multiple tables and subqueries + ** (as in the FROM clause of a SELECT statement) in this case it contains + ** the name of a single table, as one might find in an INSERT, DELETE, + ** or UPDATE statement. Look up that table in the symbol table and + ** return a pointer. Set an error message and return NULL if the table + ** name is not found or if any other error occurs. + ** + ** The following fields are initialized appropriate in pSrc: + ** + ** pSrc->a[0].pTab Pointer to the Table object + ** pSrc->a[0].pIndex Pointer to the INDEXED BY index, if there is one + ** + */ + static Table sqlite3SrcListLookup( Parse pParse, SrcList pSrc ) + { + SrcList_item pItem = pSrc.a[0]; + Table pTab; + Debug.Assert( pItem != null && pSrc.nSrc == 1 ); + pTab = sqlite3LocateTable( pParse, 0, pItem.zName, pItem.zDatabase ); + sqlite3DeleteTable( pParse.db, ref pItem.pTab ); + pItem.pTab = pTab; + if ( pTab != null ) + { + pTab.nRef++; + } + if ( sqlite3IndexedByLookup( pParse, pItem ) != 0 ) + { + pTab = null; + } + return pTab; + } - /* - ** Check to make sure the given table is writable. If it is not - ** writable, generate an error message and return 1. If it is - ** writable return 0; - */ - static bool sqlite3IsReadOnly(Parse pParse, Table pTab, int viewOk) { - /* A table is not writable under the following circumstances: - ** - ** 1) It is a virtual table and no implementation of the xUpdate method - ** has been provided, or - ** 2) It is a system table (i.e. sqlite_master), this call is not - ** part of a nested parse and writable_schema pragma has not - ** been specified. - ** - ** In either case leave an error message in pParse and return non-zero. - */ - if ( - (IsVirtual(pTab) - && sqlite3GetVTable(pParse.db, pTab).pMod.pModule.xUpdate == null) - || ((pTab.tabFlags & TF_Readonly) != 0 - && (pParse.db.flags & SQLITE_WriteSchema) == 0 - && pParse.nested == 0) - ) { - sqlite3ErrorMsg(pParse, "table %s may not be modified", pTab.zName); - return true; - } + /* + ** Check to make sure the given table is writable. If it is not + ** writable, generate an error message and return 1. If it is + ** writable return 0; + */ + static bool sqlite3IsReadOnly( Parse pParse, Table pTab, int viewOk ) + { + /* A table is not writable under the following circumstances: + ** + ** 1) It is a virtual table and no implementation of the xUpdate method + ** has been provided, or + ** 2) It is a system table (i.e. sqlite_master), this call is not + ** part of a nested parse and writable_schema pragma has not + ** been specified. + ** + ** In either case leave an error message in pParse and return non-zero. + */ + if ( + ( IsVirtual( pTab ) + && sqlite3GetVTable( pParse.db, pTab ).pMod.pModule.xUpdate == null ) + || ( ( pTab.tabFlags & TF_Readonly ) != 0 + && ( pParse.db.flags & SQLITE_WriteSchema ) == 0 + && pParse.nested == 0 ) + ) + { + sqlite3ErrorMsg( pParse, "table %s may not be modified", pTab.zName ); + return true; + } #if !SQLITE_OMIT_VIEW - if (viewOk == 0 && pTab.pSelect != null) { - sqlite3ErrorMsg(pParse, "cannot modify %s because it is a view", pTab.zName); - return true; - } + if ( viewOk == 0 && pTab.pSelect != null ) + { + sqlite3ErrorMsg( pParse, "cannot modify %s because it is a view", pTab.zName ); + return true; + } #endif - return false; - } + return false; + } #if !SQLITE_OMIT_VIEW && !SQLITE_OMIT_TRIGGER - /* - ** Evaluate a view and store its result in an ephemeral table. The - ** pWhere argument is an optional WHERE clause that restricts the - ** set of rows in the view that are to be added to the ephemeral table. - */ - static void sqlite3MaterializeView( - Parse pParse, /* Parsing context */ - Table pView, /* View definition */ - Expr pWhere, /* Optional WHERE clause to be added */ - int iCur /* VdbeCursor number for ephemerial table */ - ) { - SelectDest dest = new SelectDest(); - Select pDup; - sqlite3 db = pParse.db; - - pDup = sqlite3SelectDup(db, pView.pSelect, 0); - if (pWhere != null) { - SrcList pFrom; - - pWhere = sqlite3ExprDup(db, pWhere, 0); - pFrom = sqlite3SrcListAppend(db, null, null, null); - //if ( pFrom != null ) - //{ - Debug.Assert(pFrom.nSrc == 1); - pFrom.a[0].zAlias = pView.zName;// sqlite3DbStrDup( db, pView.zName ); - pFrom.a[0].pSelect = pDup; - Debug.Assert(pFrom.a[0].pOn == null); - Debug.Assert(pFrom.a[0].pUsing == null); - //} - //else - //{ - // sqlite3SelectDelete( db, ref pDup ); - //} - pDup = sqlite3SelectNew(pParse, null, pFrom, pWhere, null, null, null, 0, null, null); - } - sqlite3SelectDestInit(dest, SRT_EphemTab, iCur); - sqlite3Select(pParse, pDup, ref dest); - sqlite3SelectDelete(db, ref pDup); - } + /* +** Evaluate a view and store its result in an ephemeral table. The +** pWhere argument is an optional WHERE clause that restricts the +** set of rows in the view that are to be added to the ephemeral table. +*/ + static void sqlite3MaterializeView( + Parse pParse, /* Parsing context */ + Table pView, /* View definition */ + Expr pWhere, /* Optional WHERE clause to be added */ + int iCur /* VdbeCursor number for ephemerial table */ + ) + { + SelectDest dest = new SelectDest(); + Select pDup; + sqlite3 db = pParse.db; + + pDup = sqlite3SelectDup( db, pView.pSelect, 0 ); + if ( pWhere != null ) + { + SrcList pFrom; + + pWhere = sqlite3ExprDup( db, pWhere, 0 ); + pFrom = sqlite3SrcListAppend( db, null, null, null ); + //if ( pFrom != null ) + //{ + Debug.Assert( pFrom.nSrc == 1 ); + pFrom.a[0].zAlias = pView.zName;// sqlite3DbStrDup( db, pView.zName ); + pFrom.a[0].pSelect = pDup; + Debug.Assert( pFrom.a[0].pOn == null ); + Debug.Assert( pFrom.a[0].pUsing == null ); + //} + //else + //{ + // sqlite3SelectDelete( db, ref pDup ); + //} + pDup = sqlite3SelectNew( pParse, null, pFrom, pWhere, null, null, null, 0, null, null ); + } + sqlite3SelectDestInit( dest, SRT_EphemTab, iCur ); + sqlite3Select( pParse, pDup, ref dest ); + sqlite3SelectDelete( db, ref pDup ); + } #endif //* !SQLITE_OMIT_VIEW) && !SQLITE_OMIT_TRIGGER) */ #if (SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !(SQLITE_OMIT_SUBQUERY) @@ -231,60 +244,62 @@ char zStmtType /* Either DELETE or UPDATE. For error messages. */ } #endif //* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) */ - /* - ** Generate code for a DELETE FROM statement. - ** - ** DELETE FROM table_wxyz WHERE a<5 AND b NOT NULL; - ** \________/ \________________/ - ** pTabList pWhere - */ - static void sqlite3DeleteFrom( - Parse pParse, /* The parser context */ - SrcList pTabList, /* The table from which we should delete things */ - Expr pWhere /* The WHERE clause. May be null */ - ) { - Vdbe v; /* The virtual database engine */ - Table pTab; /* The table from which records will be deleted */ - int end, addr = 0; /* A couple addresses of generated code */ - int i; /* Loop counter */ - WhereInfo pWInfo; /* Information about the WHERE clause */ - Index pIdx; /* For looping over indices of the table */ - int iCur; /* VDBE VdbeCursor number for pTab */ - sqlite3 db; /* Main database structure */ - AuthContext sContext; /* Authorization context */ - NameContext sNC; /* Name context to resolve expressions in */ - int iDb; /* Database number */ - int memCnt = -1; /* Memory cell used for change counting */ - int rcauth; /* Value returned by authorization callback */ + /* +** Generate code for a DELETE FROM statement. +** +** DELETE FROM table_wxyz WHERE a<5 AND b NOT NULL; +** \________/ \________________/ +** pTabList pWhere +*/ + static void sqlite3DeleteFrom( + Parse pParse, /* The parser context */ + SrcList pTabList, /* The table from which we should delete things */ + Expr pWhere /* The WHERE clause. May be null */ + ) + { + Vdbe v; /* The virtual database engine */ + Table pTab; /* The table from which records will be deleted */ + int end, addr = 0; /* A couple addresses of generated code */ + int i; /* Loop counter */ + WhereInfo pWInfo; /* Information about the WHERE clause */ + Index pIdx; /* For looping over indices of the table */ + int iCur; /* VDBE VdbeCursor number for pTab */ + sqlite3 db; /* Main database structure */ + AuthContext sContext; /* Authorization context */ + NameContext sNC; /* Name context to resolve expressions in */ + int iDb; /* Database number */ + int memCnt = -1; /* Memory cell used for change counting */ + int rcauth; /* Value returned by authorization callback */ #if !SQLITE_OMIT_TRIGGER - bool isView; /* True if attempting to delete from a view */ - Trigger pTrigger; /* List of table triggers, if required */ + bool isView; /* True if attempting to delete from a view */ + Trigger pTrigger; /* List of table triggers, if required */ #endif - sContext = new AuthContext();//memset(&sContext, 0, sizeof(sContext)); - - db = pParse.db; - if (pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) { - goto delete_from_cleanup; - } - Debug.Assert(pTabList.nSrc == 1); - - /* Locate the table which we want to delete. This table has to be - ** put in an SrcList structure because some of the subroutines we - ** will be calling are designed to work with multiple tables and expect - ** an SrcList* parameter instead of just a Table* parameter. - */ - pTab = sqlite3SrcListLookup(pParse, pTabList); - if (pTab == null) - goto delete_from_cleanup; - - /* Figure out if we have any triggers and if the table being - ** deleted from is a view - */ + sContext = new AuthContext();//memset(&sContext, 0, sizeof(sContext)); + + db = pParse.db; + if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) + { + goto delete_from_cleanup; + } + Debug.Assert( pTabList.nSrc == 1 ); + + /* Locate the table which we want to delete. This table has to be + ** put in an SrcList structure because some of the subroutines we + ** will be calling are designed to work with multiple tables and expect + ** an SrcList* parameter instead of just a Table* parameter. + */ + pTab = sqlite3SrcListLookup( pParse, pTabList ); + if ( pTab == null ) + goto delete_from_cleanup; + + /* Figure out if we have any triggers and if the table being + ** deleted from is a view + */ #if !SQLITE_OMIT_TRIGGER - int iDummy; - pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, null, out iDummy); - isView = pTab.pSelect != null; + int iDummy; + pTrigger = sqlite3TriggersExist( pParse, pTab, TK_DELETE, null, out iDummy ); + isView = pTab.pSelect != null; #else const Trigger pTrigger = null; bool isView = false; @@ -294,36 +309,40 @@ Expr pWhere /* The WHERE clause. May be null */ isView = false; #endif - /* If pTab is really a view, make sure it has been initialized. - */ - if (sqlite3ViewGetColumnNames(pParse, pTab) != 0) { - goto delete_from_cleanup; - } - - if (sqlite3IsReadOnly(pParse, pTab, (pTrigger != null ? 1 : 0))) { - goto delete_from_cleanup; - } - iDb = sqlite3SchemaToIndex(db, pTab.pSchema); - Debug.Assert(iDb < db.nDb); + /* If pTab is really a view, make sure it has been initialized. +*/ + if ( sqlite3ViewGetColumnNames( pParse, pTab ) != 0 ) + { + goto delete_from_cleanup; + } + + if ( sqlite3IsReadOnly( pParse, pTab, ( pTrigger != null ? 1 : 0 ) ) ) + { + goto delete_from_cleanup; + } + iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); + Debug.Assert( iDb < db.nDb ); #if !SQLITE_OMIT_AUTHORIZATION string zDb = db.aDb[iDb].zName; /* Name of database holding pTab */ rcauth = sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb); #else - rcauth = SQLITE_OK; + rcauth = SQLITE_OK; #endif - Debug.Assert(rcauth == SQLITE_OK || rcauth == SQLITE_DENY || rcauth == SQLITE_IGNORE); - if (rcauth == SQLITE_DENY) { - goto delete_from_cleanup; - } - Debug.Assert(!isView || pTrigger != null); - - /* Assign cursor number to the table and all its indices. - */ - Debug.Assert(pTabList.nSrc == 1); - iCur = pTabList.a[0].iCursor = pParse.nTab++; - for (pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext) { - pParse.nTab++; - } + Debug.Assert( rcauth == SQLITE_OK || rcauth == SQLITE_DENY || rcauth == SQLITE_IGNORE ); + if ( rcauth == SQLITE_DENY ) + { + goto delete_from_cleanup; + } + Debug.Assert( !isView || pTrigger != null ); + + /* Assign cursor number to the table and all its indices. + */ + Debug.Assert( pTabList.nSrc == 1 ); + iCur = pTabList.a[0].iCursor = pParse.nTab++; + for ( pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext ) + { + pParse.nTab++; + } #if !SQLITE_OMIT_AUTHORIZATION /* Start the view context @@ -332,363 +351,396 @@ Expr pWhere /* The WHERE clause. May be null */ sqlite3AuthContextPush(pParse, sContext, pTab.zName); } #endif - /* Begin generating code. + /* Begin generating code. +*/ + v = sqlite3GetVdbe( pParse ); + if ( v == null ) + { + goto delete_from_cleanup; + } + if ( pParse.nested == 0 ) + sqlite3VdbeCountChanges( v ); + sqlite3BeginWriteOperation( pParse, 1, iDb ); + + /* If we are trying to delete from a view, realize that view into + ** a ephemeral table. */ - v = sqlite3GetVdbe(pParse); - if (v == null) { - goto delete_from_cleanup; - } - if (pParse.nested == 0) - sqlite3VdbeCountChanges(v); - sqlite3BeginWriteOperation(pParse, 1, iDb); - - /* If we are trying to delete from a view, realize that view into - ** a ephemeral table. - */ #if !(SQLITE_OMIT_VIEW) && !(SQLITE_OMIT_TRIGGER) - if (isView) { - sqlite3MaterializeView(pParse, pTab, pWhere, iCur); - } + if ( isView ) + { + sqlite3MaterializeView( pParse, pTab, pWhere, iCur ); + } #endif - /* Resolve the column names in the WHERE clause. - */ - sNC = new NameContext();// memset( &sNC, 0, sizeof( sNC ) ); - sNC.pParse = pParse; - sNC.pSrcList = pTabList; - if (sqlite3ResolveExprNames(sNC, ref pWhere) != 0) { - goto delete_from_cleanup; - } - - /* Initialize the counter of the number of rows deleted, if - ** we are counting rows. + /* Resolve the column names in the WHERE clause. */ - if ((db.flags & SQLITE_CountRows) != 0) { - memCnt = ++pParse.nMem; - sqlite3VdbeAddOp2(v, OP_Integer, 0, memCnt); - } + sNC = new NameContext();// memset( &sNC, 0, sizeof( sNC ) ); + sNC.pParse = pParse; + sNC.pSrcList = pTabList; + if ( sqlite3ResolveExprNames( sNC, ref pWhere ) != 0 ) + { + goto delete_from_cleanup; + } + + /* Initialize the counter of the number of rows deleted, if +** we are counting rows. +*/ + if ( ( db.flags & SQLITE_CountRows ) != 0 ) + { + memCnt = ++pParse.nMem; + sqlite3VdbeAddOp2( v, OP_Integer, 0, memCnt ); + } #if !SQLITE_OMIT_TRUNCATE_OPTIMIZATION - /* Special case: A DELETE without a WHERE clause deletes everything. - ** It is easier just to erase the whole table. Prior to version 3.6.5, - ** this optimization caused the row change count (the value returned by - ** API function sqlite3_count_changes) to be set incorrectly. */ - if (rcauth == SQLITE_OK && pWhere == null && null == pTrigger && !IsVirtual(pTab) - && 0 == sqlite3FkRequired(pParse, pTab, null, 0) - ) { - Debug.Assert(!isView); - sqlite3VdbeAddOp4(v, OP_Clear, pTab.tnum, iDb, memCnt, - pTab.zName, P4_STATIC); - for (pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext) { - Debug.Assert(pIdx.pSchema == pTab.pSchema); - sqlite3VdbeAddOp2(v, OP_Clear, pIdx.tnum, iDb); - } - } else + /* Special case: A DELETE without a WHERE clause deletes everything. + ** It is easier just to erase the whole table. Prior to version 3.6.5, + ** this optimization caused the row change count (the value returned by + ** API function sqlite3_count_changes) to be set incorrectly. */ + if ( rcauth == SQLITE_OK && pWhere == null && null == pTrigger && !IsVirtual( pTab ) + && 0 == sqlite3FkRequired( pParse, pTab, null, 0 ) + ) + { + Debug.Assert( !isView ); + sqlite3VdbeAddOp4( v, OP_Clear, pTab.tnum, iDb, memCnt, + pTab.zName, P4_STATIC ); + for ( pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext ) + { + Debug.Assert( pIdx.pSchema == pTab.pSchema ); + sqlite3VdbeAddOp2( v, OP_Clear, pIdx.tnum, iDb ); + } + } + else #endif //* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */ - /* The usual case: There is a WHERE clause so we have to scan through - ** the table and pick which records to delete. + /* The usual case: There is a WHERE clause so we have to scan through +** the table and pick which records to delete. +*/ + { + int iRowSet = ++pParse.nMem; /* Register for rowset of rows to delete */ + int iRowid = ++pParse.nMem; /* Used for storing rowid values. */ + int regRowid; /* Actual register containing rowids */ + + /* Collect rowids of every row to be deleted. */ - { - int iRowSet = ++pParse.nMem; /* Register for rowset of rows to delete */ - int iRowid = ++pParse.nMem; /* Used for storing rowid values. */ - int regRowid; /* Actual register containing rowids */ - - /* Collect rowids of every row to be deleted. - */ - sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet); - ExprList elDummy = null; - pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, ref elDummy, WHERE_DUPLICATES_OK); - if (pWInfo == null) - goto delete_from_cleanup; - regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid); - sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, regRowid); - if ((db.flags & SQLITE_CountRows) != 0) { - sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1); - } - - sqlite3WhereEnd(pWInfo); - - /* Delete every item whose key was written to the list during the - ** database scan. We have to delete items after the scan is complete - ** because deleting an item can change the scan order. */ - end = sqlite3VdbeMakeLabel(v); - - /* Unless this is a view, open cursors for the table we are - ** deleting from and all its indices. If this is a view, then the - ** only effect this statement has is to fire the INSTEAD OF - ** triggers. */ - if (!isView) { - sqlite3OpenTableAndIndices(pParse, pTab, iCur, OP_OpenWrite); - } - - addr = sqlite3VdbeAddOp3(v, OP_RowSetRead, iRowSet, end, iRowid); - - /* Delete the row */ + sqlite3VdbeAddOp2( v, OP_Null, 0, iRowSet ); + ExprList elDummy = null; + pWInfo = sqlite3WhereBegin( pParse, pTabList, pWhere, ref elDummy, WHERE_DUPLICATES_OK ); + if ( pWInfo == null ) + goto delete_from_cleanup; + regRowid = sqlite3ExprCodeGetColumn( pParse, pTab, -1, iCur, iRowid ); + sqlite3VdbeAddOp2( v, OP_RowSetAdd, iRowSet, regRowid ); + if ( ( db.flags & SQLITE_CountRows ) != 0 ) + { + sqlite3VdbeAddOp2( v, OP_AddImm, memCnt, 1 ); + } + + sqlite3WhereEnd( pWInfo ); + + /* Delete every item whose key was written to the list during the + ** database scan. We have to delete items after the scan is complete + ** because deleting an item can change the scan order. */ + end = sqlite3VdbeMakeLabel( v ); + + /* Unless this is a view, open cursors for the table we are + ** deleting from and all its indices. If this is a view, then the + ** only effect this statement has is to fire the INSTEAD OF + ** triggers. */ + if ( !isView ) + { + sqlite3OpenTableAndIndices( pParse, pTab, iCur, OP_OpenWrite ); + } + + addr = sqlite3VdbeAddOp3( v, OP_RowSetRead, iRowSet, end, iRowid ); + + /* Delete the row */ #if !SQLITE_OMIT_VIRTUALTABLE - if (IsVirtual(pTab)) { - VTable pVTab = sqlite3GetVTable(db, pTab); - sqlite3VtabMakeWritable(pParse, pTab); - sqlite3VdbeAddOp4(v, OP_VUpdate, 0, 1, iRowid, pVTab, P4_VTAB); - sqlite3VdbeChangeP5(v, OE_Abort); - sqlite3MayAbort(pParse); - } else + if ( IsVirtual( pTab ) ) + { + VTable pVTab = sqlite3GetVTable( db, pTab ); + sqlite3VtabMakeWritable( pParse, pTab ); + sqlite3VdbeAddOp4( v, OP_VUpdate, 0, 1, iRowid, pVTab, P4_VTAB ); + sqlite3VdbeChangeP5( v, OE_Abort ); + sqlite3MayAbort( pParse ); + } + else #endif - { - int count = (pParse.nested == 0) ? 1 : 0; /* True to count changes */ - sqlite3GenerateRowDelete(pParse, pTab, iCur, iRowid, count, pTrigger, OE_Default); - } - - /* End of the delete loop */ - sqlite3VdbeAddOp2(v, OP_Goto, 0, addr); - sqlite3VdbeResolveLabel(v, end); - - /* Close the cursors open on the table and its indexes. */ - if (!isView && !IsVirtual(pTab)) { - for (i = 1, pIdx = pTab.pIndex; pIdx != null; i++, pIdx = pIdx.pNext) { - sqlite3VdbeAddOp2(v, OP_Close, iCur + i, pIdx.tnum); - } - sqlite3VdbeAddOp1(v, OP_Close, iCur); - } - } - - /* Update the sqlite_sequence table by storing the content of the - ** maximum rowid counter values recorded while inserting into - ** autoincrement tables. - */ - if (pParse.nested == 0 && pParse.pTriggerTab == null) { - sqlite3AutoincrementEnd(pParse); - } - - /* Return the number of rows that were deleted. If this routine is - ** generating code because of a call to sqlite3NestedParse(), do not - ** invoke the callback function. - */ - - if ((db.flags & SQLITE_CountRows) != 0 && 0 == pParse.nested && null == pParse.pTriggerTab) { - sqlite3VdbeAddOp2(v, OP_ResultRow, memCnt, 1); - sqlite3VdbeSetNumCols(v, 1); - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows deleted", SQLITE_STATIC); - } - - delete_from_cleanup: + { + int count = ( pParse.nested == 0 ) ? 1 : 0; /* True to count changes */ + sqlite3GenerateRowDelete( pParse, pTab, iCur, iRowid, count, pTrigger, OE_Default ); + } + + /* End of the delete loop */ + sqlite3VdbeAddOp2( v, OP_Goto, 0, addr ); + sqlite3VdbeResolveLabel( v, end ); + + /* Close the cursors open on the table and its indexes. */ + if ( !isView && !IsVirtual( pTab ) ) + { + for ( i = 1, pIdx = pTab.pIndex; pIdx != null; i++, pIdx = pIdx.pNext ) + { + sqlite3VdbeAddOp2( v, OP_Close, iCur + i, pIdx.tnum ); + } + sqlite3VdbeAddOp1( v, OP_Close, iCur ); + } + } + + /* Update the sqlite_sequence table by storing the content of the + ** maximum rowid counter values recorded while inserting into + ** autoincrement tables. + */ + if ( pParse.nested == 0 && pParse.pTriggerTab == null ) + { + sqlite3AutoincrementEnd( pParse ); + } + + /* Return the number of rows that were deleted. If this routine is + ** generating code because of a call to sqlite3NestedParse(), do not + ** invoke the callback function. + */ + + if ( ( db.flags & SQLITE_CountRows ) != 0 && 0 == pParse.nested && null == pParse.pTriggerTab ) + { + sqlite3VdbeAddOp2( v, OP_ResultRow, memCnt, 1 ); + sqlite3VdbeSetNumCols( v, 1 ); + sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "rows deleted", SQLITE_STATIC ); + } + +delete_from_cleanup: #if !SQLITE_OMIT_AUTHORIZATION sqlite3AuthContextPop(sContext); #endif - sqlite3SrcListDelete(db, ref pTabList); - sqlite3ExprDelete(db, ref pWhere); - return; + sqlite3SrcListDelete( db, ref pTabList ); + sqlite3ExprDelete( db, ref pWhere ); + return; + } + + /* Make sure "isView" and other macros defined above are undefined. Otherwise + ** thely may interfere with compilation of other functions in this file + ** (or in another file, if this file becomes part of the amalgamation). */ + //#if isView + // #undef isView + //#endif + //#if pTrigger + // #undef pTrigger + //#endif + + /* + ** This routine generates VDBE code that causes a single row of a + ** single table to be deleted. + ** + ** The VDBE must be in a particular state when this routine is called. + ** These are the requirements: + ** + ** 1. A read/write cursor pointing to pTab, the table containing the row + ** to be deleted, must be opened as cursor number $iCur. + ** + ** 2. Read/write cursors for all indices of pTab must be open as + ** cursor number base+i for the i-th index. + ** + ** 3. The record number of the row to be deleted must be stored in + ** memory cell iRowid. + ** + ** This routine generates code to remove both the table record and all + ** index entries that point to that record. + */ + static void sqlite3GenerateRowDelete( + Parse pParse, /* Parsing context */ + Table pTab, /* Table containing the row to be deleted */ + int iCur, /* VdbeCursor number for the table */ + int iRowid, /* Memory cell that contains the rowid to delete */ + int count, /* If non-zero, increment the row change counter */ + Trigger pTrigger, /* List of triggers to (potentially) fire */ + int onconf /* Default ON CONFLICT policy for triggers */ +) + { + Vdbe v = pParse.pVdbe; /* Vdbe */ + int iOld = 0; /* First register in OLD.* array */ + int iLabel; /* Label resolved to end of generated code */ + + /* Vdbe is guaranteed to have been allocated by this stage. */ + Debug.Assert( v != null ); + + /* Seek cursor iCur to the row to delete. If this row no longer exists + ** (this can happen if a trigger program has already deleted it), do + ** not attempt to delete it or fire any DELETE triggers. */ + iLabel = sqlite3VdbeMakeLabel( v ); + sqlite3VdbeAddOp3( v, OP_NotExists, iCur, iLabel, iRowid ); + + /* If there are any triggers to fire, allocate a range of registers to + ** use for the old.* references in the triggers. */ + if ( sqlite3FkRequired( pParse, pTab, null, 0 ) != 0 || pTrigger != null ) + { + u32 mask; /* Mask of OLD.* columns in use */ + int iCol; /* Iterator used while populating OLD.* */ + + /* TODO: Could use temporary registers here. Also could attempt to + ** avoid copying the contents of the rowid register. */ + mask = sqlite3TriggerColmask( + pParse, pTrigger, null, 0, TRIGGER_BEFORE | TRIGGER_AFTER, pTab, onconf + ); + mask |= sqlite3FkOldmask( pParse, pTab ); + iOld = pParse.nMem + 1; + pParse.nMem += ( 1 + pTab.nCol ); + + /* Populate the OLD.* pseudo-table register array. These values will be + ** used by any BEFORE and AFTER triggers that exist. */ + sqlite3VdbeAddOp2( v, OP_Copy, iRowid, iOld ); + for ( iCol = 0; iCol < pTab.nCol; iCol++ ) + { + if ( mask == 0xffffffff || ( mask & ( 1 << iCol ) ) != 0 ) + { + sqlite3ExprCodeGetColumnOfTable( v, pTab, iCur, iCol, iOld + iCol + 1 ); + } } - /* Make sure "isView" and other macros defined above are undefined. Otherwise - ** thely may interfere with compilation of other functions in this file - ** (or in another file, if this file becomes part of the amalgamation). */ - //#if isView - // #undef isView - //#endif - //#if pTrigger - // #undef pTrigger - //#endif - - /* - ** This routine generates VDBE code that causes a single row of a - ** single table to be deleted. - ** - ** The VDBE must be in a particular state when this routine is called. - ** These are the requirements: - ** - ** 1. A read/write cursor pointing to pTab, the table containing the row - ** to be deleted, must be opened as cursor number $iCur. - ** - ** 2. Read/write cursors for all indices of pTab must be open as - ** cursor number base+i for the i-th index. - ** - ** 3. The record number of the row to be deleted must be stored in - ** memory cell iRowid. - ** - ** This routine generates code to remove both the table record and all - ** index entries that point to that record. - */ - static void sqlite3GenerateRowDelete( - Parse pParse, /* Parsing context */ - Table pTab, /* Table containing the row to be deleted */ - int iCur, /* VdbeCursor number for the table */ - int iRowid, /* Memory cell that contains the rowid to delete */ - int count, /* If non-zero, increment the row change counter */ - Trigger pTrigger, /* List of triggers to (potentially) fire */ - int onconf /* Default ON CONFLICT policy for triggers */ - ) { - Vdbe v = pParse.pVdbe; /* Vdbe */ - int iOld = 0; /* First register in OLD.* array */ - int iLabel; /* Label resolved to end of generated code */ - - /* Vdbe is guaranteed to have been allocated by this stage. */ - Debug.Assert(v != null); - - /* Seek cursor iCur to the row to delete. If this row no longer exists - ** (this can happen if a trigger program has already deleted it), do - ** not attempt to delete it or fire any DELETE triggers. */ - iLabel = sqlite3VdbeMakeLabel(v); - sqlite3VdbeAddOp3(v, OP_NotExists, iCur, iLabel, iRowid); - - /* If there are any triggers to fire, allocate a range of registers to - ** use for the old.* references in the triggers. */ - if (sqlite3FkRequired(pParse, pTab, null, 0) != 0 || pTrigger != null) { - u32 mask; /* Mask of OLD.* columns in use */ - int iCol; /* Iterator used while populating OLD.* */ - - /* TODO: Could use temporary registers here. Also could attempt to - ** avoid copying the contents of the rowid register. */ - mask = sqlite3TriggerColmask( - pParse, pTrigger, null, 0, TRIGGER_BEFORE | TRIGGER_AFTER, pTab, onconf - ); - mask |= sqlite3FkOldmask(pParse, pTab); - iOld = pParse.nMem + 1; - pParse.nMem += (1 + pTab.nCol); - - /* Populate the OLD.* pseudo-table register array. These values will be - ** used by any BEFORE and AFTER triggers that exist. */ - sqlite3VdbeAddOp2(v, OP_Copy, iRowid, iOld); - for (iCol = 0; iCol < pTab.nCol; iCol++) { - if (mask == 0xffffffff || (mask & (1 << iCol)) != 0) { - sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, iCol, iOld + iCol + 1); - } - } - - /* Invoke BEFORE DELETE trigger programs. */ - sqlite3CodeRowTrigger(pParse, pTrigger, - TK_DELETE, null, TRIGGER_BEFORE, pTab, iOld, onconf, iLabel - ); - - /* Seek the cursor to the row to be deleted again. It may be that - ** the BEFORE triggers coded above have already removed the row - ** being deleted. Do not attempt to delete the row a second time, and - ** do not fire AFTER triggers. */ - sqlite3VdbeAddOp3(v, OP_NotExists, iCur, iLabel, iRowid); - - /* Do FK processing. This call checks that any FK constraints that - ** refer to this table (i.e. constraints attached to other tables) - ** are not violated by deleting this row. */ - sqlite3FkCheck(pParse, pTab, iOld, 0); - } - - /* Delete the index and table entries. Skip this step if pTab is really - ** a view (in which case the only effect of the DELETE statement is to - ** fire the INSTEAD OF triggers). */ - if (pTab.pSelect == null) { - sqlite3GenerateRowIndexDelete(pParse, pTab, iCur, 0); - sqlite3VdbeAddOp2(v, OP_Delete, iCur, (count != 0 ? (int)OPFLAG_NCHANGE : 0)); - if (count != 0) { - sqlite3VdbeChangeP4(v, -1, pTab.zName, P4_TRANSIENT); - } - } - - /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to - ** handle rows (possibly in other tables) that refer via a foreign key - ** to the row just deleted. */ - sqlite3FkActions(pParse, pTab, null, iOld); - - /* Invoke AFTER DELETE trigger programs. */ - sqlite3CodeRowTrigger(pParse, pTrigger, - TK_DELETE, null, TRIGGER_AFTER, pTab, iOld, onconf, iLabel - ); - - /* Jump here if the row had already been deleted before any BEFORE - ** trigger programs were invoked. Or if a trigger program throws a - ** RAISE(IGNORE) exception. */ - sqlite3VdbeResolveLabel(v, iLabel); + /* Invoke BEFORE DELETE trigger programs. */ + sqlite3CodeRowTrigger( pParse, pTrigger, + TK_DELETE, null, TRIGGER_BEFORE, pTab, iOld, onconf, iLabel + ); + + /* Seek the cursor to the row to be deleted again. It may be that + ** the BEFORE triggers coded above have already removed the row + ** being deleted. Do not attempt to delete the row a second time, and + ** do not fire AFTER triggers. */ + sqlite3VdbeAddOp3( v, OP_NotExists, iCur, iLabel, iRowid ); + + /* Do FK processing. This call checks that any FK constraints that + ** refer to this table (i.e. constraints attached to other tables) + ** are not violated by deleting this row. */ + sqlite3FkCheck( pParse, pTab, iOld, 0 ); + } + + /* Delete the index and table entries. Skip this step if pTab is really + ** a view (in which case the only effect of the DELETE statement is to + ** fire the INSTEAD OF triggers). */ + if ( pTab.pSelect == null ) + { + sqlite3GenerateRowIndexDelete( pParse, pTab, iCur, 0 ); + sqlite3VdbeAddOp2( v, OP_Delete, iCur, ( count != 0 ? (int)OPFLAG_NCHANGE : 0 ) ); + if ( count != 0 ) + { + sqlite3VdbeChangeP4( v, -1, pTab.zName, P4_TRANSIENT ); } + } + + /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to + ** handle rows (possibly in other tables) that refer via a foreign key + ** to the row just deleted. */ + sqlite3FkActions( pParse, pTab, null, iOld ); + + /* Invoke AFTER DELETE trigger programs. */ + sqlite3CodeRowTrigger( pParse, pTrigger, + TK_DELETE, null, TRIGGER_AFTER, pTab, iOld, onconf, iLabel + ); + + /* Jump here if the row had already been deleted before any BEFORE + ** trigger programs were invoked. Or if a trigger program throws a + ** RAISE(IGNORE) exception. */ + sqlite3VdbeResolveLabel( v, iLabel ); + } - /* - ** This routine generates VDBE code that causes the deletion of all - ** index entries associated with a single row of a single table. - ** - ** The VDBE must be in a particular state when this routine is called. - ** These are the requirements: - ** - ** 1. A read/write cursor pointing to pTab, the table containing the row - ** to be deleted, must be opened as cursor number "iCur". - ** - ** 2. Read/write cursors for all indices of pTab must be open as - ** cursor number iCur+i for the i-th index. - ** - ** 3. The "iCur" cursor must be pointing to the row that is to be - ** deleted. - */ - static void sqlite3GenerateRowIndexDelete( - Parse pParse, /* Parsing and code generating context */ - Table pTab, /* Table containing the row to be deleted */ - int iCur, /* VdbeCursor number for the table */ - int nothing /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */ - ) { - int[] aRegIdx = null; - sqlite3GenerateRowIndexDelete(pParse, pTab, iCur, aRegIdx); + /* + ** This routine generates VDBE code that causes the deletion of all + ** index entries associated with a single row of a single table. + ** + ** The VDBE must be in a particular state when this routine is called. + ** These are the requirements: + ** + ** 1. A read/write cursor pointing to pTab, the table containing the row + ** to be deleted, must be opened as cursor number "iCur". + ** + ** 2. Read/write cursors for all indices of pTab must be open as + ** cursor number iCur+i for the i-th index. + ** + ** 3. The "iCur" cursor must be pointing to the row that is to be + ** deleted. + */ + static void sqlite3GenerateRowIndexDelete( + Parse pParse, /* Parsing and code generating context */ + Table pTab, /* Table containing the row to be deleted */ + int iCur, /* VdbeCursor number for the table */ + int nothing /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */ + ) + { + int[] aRegIdx = null; + sqlite3GenerateRowIndexDelete( pParse, pTab, iCur, aRegIdx ); + } + static void sqlite3GenerateRowIndexDelete( + Parse pParse, /* Parsing and code generating context */ + Table pTab, /* Table containing the row to be deleted */ + int iCur, /* VdbeCursor number for the table */ + int[] aRegIdx /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */ + ) + { + int i; + Index pIdx; + int r1; + + for ( i = 1, pIdx = pTab.pIndex; pIdx != null; i++, pIdx = pIdx.pNext ) + { + if ( aRegIdx != null && aRegIdx[i - 1] == 0 ) + continue; + r1 = sqlite3GenerateIndexKey( pParse, pIdx, iCur, 0, false ); + sqlite3VdbeAddOp3( pParse.pVdbe, OP_IdxDelete, iCur + i, r1, pIdx.nColumn + 1 ); + } + } + + /* + ** Generate code that will assemble an index key and put it in register + ** regOut. The key with be for index pIdx which is an index on pTab. + ** iCur is the index of a cursor open on the pTab table and pointing to + ** the entry that needs indexing. + ** + ** Return a register number which is the first in a block of + ** registers that holds the elements of the index key. The + ** block of registers has already been deallocated by the time + ** this routine returns. + */ + static int sqlite3GenerateIndexKey( + Parse pParse, /* Parsing context */ + Index pIdx, /* The index for which to generate a key */ + int iCur, /* VdbeCursor number for the pIdx.pTable table */ + int regOut, /* Write the new index key to this register */ + bool doMakeRec /* Run the OP_MakeRecord instruction if true */ + ) + { + Vdbe v = pParse.pVdbe; + int j; + Table pTab = pIdx.pTable; + int regBase; + int nCol; + + nCol = pIdx.nColumn; + regBase = sqlite3GetTempRange( pParse, nCol + 1 ); + sqlite3VdbeAddOp2( v, OP_Rowid, iCur, regBase + nCol ); + for ( j = 0; j < nCol; j++ ) + { + int idx = pIdx.aiColumn[j]; + if ( idx == pTab.iPKey ) + { + sqlite3VdbeAddOp2( v, OP_SCopy, regBase + nCol, regBase + j ); } - static void sqlite3GenerateRowIndexDelete( - Parse pParse, /* Parsing and code generating context */ - Table pTab, /* Table containing the row to be deleted */ - int iCur, /* VdbeCursor number for the table */ - int[] aRegIdx /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */ - ) { - int i; - Index pIdx; - int r1; - - for (i = 1, pIdx = pTab.pIndex; pIdx != null; i++, pIdx = pIdx.pNext) { - if (aRegIdx != null && aRegIdx[i - 1] == 0) - continue; - r1 = sqlite3GenerateIndexKey(pParse, pIdx, iCur, 0, false); - sqlite3VdbeAddOp3(pParse.pVdbe, OP_IdxDelete, iCur + i, r1, pIdx.nColumn + 1); - } + else + { + sqlite3VdbeAddOp3( v, OP_Column, iCur, idx, regBase + j ); + sqlite3ColumnDefault( v, pTab, idx, -1 ); } - - /* - ** Generate code that will assemble an index key and put it in register - ** regOut. The key with be for index pIdx which is an index on pTab. - ** iCur is the index of a cursor open on the pTab table and pointing to - ** the entry that needs indexing. - ** - ** Return a register number which is the first in a block of - ** registers that holds the elements of the index key. The - ** block of registers has already been deallocated by the time - ** this routine returns. - */ - static int sqlite3GenerateIndexKey( - Parse pParse, /* Parsing context */ - Index pIdx, /* The index for which to generate a key */ - int iCur, /* VdbeCursor number for the pIdx.pTable table */ - int regOut, /* Write the new index key to this register */ - bool doMakeRec /* Run the OP_MakeRecord instruction if true */ - ) { - Vdbe v = pParse.pVdbe; - int j; - Table pTab = pIdx.pTable; - int regBase; - int nCol; - - nCol = pIdx.nColumn; - regBase = sqlite3GetTempRange(pParse, nCol + 1); - sqlite3VdbeAddOp2(v, OP_Rowid, iCur, regBase + nCol); - for (j = 0; j < nCol; j++) { - int idx = pIdx.aiColumn[j]; - if (idx == pTab.iPKey) { - sqlite3VdbeAddOp2(v, OP_SCopy, regBase + nCol, regBase + j); - } else { - sqlite3VdbeAddOp3(v, OP_Column, iCur, idx, regBase + j); - sqlite3ColumnDefault(v, pTab, idx, -1); - } - } - if (doMakeRec) { - string zAff; - if (pTab.pSelect != null || (pParse.db.flags & SQLITE_IdxRealAsInt) != 0) { - zAff = ""; - } else { - zAff = sqlite3IndexAffinityStr(v, pIdx); - } - sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol + 1, regOut); - sqlite3VdbeChangeP4(v, -1, zAff, P4_TRANSIENT); - } - sqlite3ReleaseTempRange(pParse, regBase, nCol + 1); - return regBase; + } + if ( doMakeRec ) + { + string zAff; + if ( pTab.pSelect != null|| ( pParse.db.flags & SQLITE_IdxRealAsInt ) != 0 ) + { + zAff = ""; + } + else + { + zAff = sqlite3IndexAffinityStr( v, pIdx ); } + sqlite3VdbeAddOp3( v, OP_MakeRecord, regBase, nCol + 1, regOut ); + sqlite3VdbeChangeP4( v, -1, zAff, P4_TRANSIENT ); + } + sqlite3ReleaseTempRange( pParse, regBase, nCol + 1 ); + return regBase; } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/expr_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/expr_c.cs index a8dcd7921..c90409775 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/expr_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/expr_c.cs @@ -2,1061 +2,1209 @@ using System; using System.Diagnostics; +using System.Text; +using Bitmask = System.UInt64; using i64 = System.Int64; using u8 = System.Byte; using u32 = System.UInt32; using u16 = System.UInt16; +using Pgno = System.UInt32; + #if !SQLITE_MAX_VARIABLE_NUMBER using ynVar = System.Int16; #else using ynVar = System.Int32; #endif -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 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. - ** - ************************************************************************* - ** This file contains routines used for analyzing expressions and - ** for generating VDBE code that evaluates expressions in SQLite. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 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. + ** + ************************************************************************* + ** This file contains routines used for analyzing expressions and + ** for generating VDBE code that evaluates expressions in SQLite. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" - /* - ** Return the 'affinity' of the expression pExpr if any. - ** - ** If pExpr is a column, a reference to a column via an 'AS' alias, - ** or a sub-select with a column as the return value, then the - ** affinity of that column is returned. Otherwise, 0x00 is returned, - ** indicating no affinity for the expression. - ** - ** i.e. the WHERE clause expresssions in the following statements all - ** have an affinity: - ** - ** CREATE TABLE t1(a); - ** SELECT * FROM t1 WHERE a; - ** SELECT a AS b FROM t1 WHERE b; - ** SELECT * FROM t1 WHERE (select a from t1); - */ - static char sqlite3ExprAffinity(Expr pExpr) { - int op = pExpr.op; - if (op == TK_SELECT) { - Debug.Assert((pExpr.flags & EP_xIsSelect) != 0); - return sqlite3ExprAffinity(pExpr.x.pSelect.pEList.a[0].pExpr); - } + /* + ** Return the 'affinity' of the expression pExpr if any. + ** + ** If pExpr is a column, a reference to a column via an 'AS' alias, + ** or a sub-select with a column as the return value, then the + ** affinity of that column is returned. Otherwise, 0x00 is returned, + ** indicating no affinity for the expression. + ** + ** i.e. the WHERE clause expresssions in the following statements all + ** have an affinity: + ** + ** CREATE TABLE t1(a); + ** SELECT * FROM t1 WHERE a; + ** SELECT a AS b FROM t1 WHERE b; + ** SELECT * FROM t1 WHERE (select a from t1); + */ + static char sqlite3ExprAffinity( Expr pExpr ) + { + int op = pExpr.op; + if ( op == TK_SELECT ) + { + Debug.Assert( ( pExpr.flags & EP_xIsSelect ) != 0 ); + return sqlite3ExprAffinity( pExpr.x.pSelect.pEList.a[0].pExpr ); + } #if !SQLITE_OMIT_CAST - if (op == TK_CAST) { - Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); - return sqlite3AffinityType(pExpr.u.zToken); - } + if ( op == TK_CAST ) + { + Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); + return sqlite3AffinityType( pExpr.u.zToken ); + } #endif - if ((op == TK_AGG_COLUMN || op == TK_COLUMN || op == TK_REGISTER) - && pExpr.pTab != null - ) { - /* op==TK_REGISTER && pExpr.pTab!=0 happens when pExpr was originally - ** a TK_COLUMN but was previously evaluated and cached in a register */ - int j = pExpr.iColumn; - if (j < 0) - return SQLITE_AFF_INTEGER; - Debug.Assert(pExpr.pTab != null && j < pExpr.pTab.nCol); - return pExpr.pTab.aCol[j].affinity; - } - return pExpr.affinity; - } + if ( ( op == TK_AGG_COLUMN || op == TK_COLUMN || op == TK_REGISTER ) + && pExpr.pTab != null + ) + { + /* op==TK_REGISTER && pExpr.pTab!=0 happens when pExpr was originally + ** a TK_COLUMN but was previously evaluated and cached in a register */ + int j = pExpr.iColumn; + if ( j < 0 ) + return SQLITE_AFF_INTEGER; + Debug.Assert( pExpr.pTab != null && j < pExpr.pTab.nCol ); + return pExpr.pTab.aCol[j].affinity; + } + return pExpr.affinity; + } - /* - ** Set the explicit collating sequence for an expression to the - ** collating sequence supplied in the second argument. - */ - static Expr sqlite3ExprSetColl(Expr pExpr, CollSeq pColl) { - if (pExpr != null && pColl != null) { - pExpr.pColl = pColl; - pExpr.flags |= EP_ExpCollate; - } - return pExpr; - } + /* + ** Set the explicit collating sequence for an expression to the + ** collating sequence supplied in the second argument. + */ + static Expr sqlite3ExprSetColl( Expr pExpr, CollSeq pColl ) + { + if ( pExpr != null && pColl != null ) + { + pExpr.pColl = pColl; + pExpr.flags |= EP_ExpCollate; + } + return pExpr; + } - /* - ** Set the collating sequence for expression pExpr to be the collating - ** sequence named by pToken. Return a pointer to the revised expression. - ** The collating sequence is marked as "explicit" using the EP_ExpCollate - ** flag. An explicit collating sequence will override implicit - ** collating sequences. - */ - static Expr sqlite3ExprSetCollByToken(Parse pParse, Expr pExpr, Token pCollName) { - string zColl; /* Dequoted name of collation sequence */ - CollSeq pColl; + /* + ** Set the collating sequence for expression pExpr to be the collating + ** sequence named by pToken. Return a pointer to the revised expression. + ** The collating sequence is marked as "explicit" using the EP_ExpCollate + ** flag. An explicit collating sequence will override implicit + ** collating sequences. + */ + static Expr sqlite3ExprSetCollByToken( Parse pParse, Expr pExpr, Token pCollName ) + { + string zColl; /* Dequoted name of collation sequence */ + CollSeq pColl; + sqlite3 db = pParse.db; + zColl = sqlite3NameFromToken( db, pCollName ); + pColl = sqlite3LocateCollSeq( pParse, zColl ); + sqlite3ExprSetColl( pExpr, pColl ); + sqlite3DbFree( db, ref zColl ); + return pExpr; + } + + /* + ** Return the default collation sequence for the expression pExpr. If + ** there is no default collation type, return 0. + */ + static CollSeq sqlite3ExprCollSeq( Parse pParse, Expr pExpr ) + { + CollSeq pColl = null; + Expr p = pExpr; + while ( ALWAYS( p ) ) + { + int op; + pColl = pExpr.pColl; + if ( pColl != null ) + break; + op = p.op; + if ( p.pTab != null && ( + op == TK_AGG_COLUMN || op == TK_COLUMN || op == TK_REGISTER || op == TK_TRIGGER + ) ) + { + /* op==TK_REGISTER && p->pTab!=0 happens when pExpr was originally + ** a TK_COLUMN but was previously evaluated and cached in a register */ + string zColl; + int j = p.iColumn; + if ( j >= 0 ) + { sqlite3 db = pParse.db; - zColl = sqlite3NameFromToken(db, pCollName); - pColl = sqlite3LocateCollSeq(pParse, zColl); - sqlite3ExprSetColl(pExpr, pColl); - sqlite3DbFree(db, ref zColl); - return pExpr; + zColl = p.pTab.aCol[j].zColl; + pColl = sqlite3FindCollSeq( db, ENC( db ), zColl, 0 ); + pExpr.pColl = pColl; + } + break; } - - /* - ** Return the default collation sequence for the expression pExpr. If - ** there is no default collation type, return 0. - */ - static CollSeq sqlite3ExprCollSeq(Parse pParse, Expr pExpr) { - CollSeq pColl = null; - Expr p = pExpr; - while (ALWAYS(p)) { - int op; - pColl = pExpr.pColl; - if (pColl != null) - break; - op = p.op; - if (p.pTab != null && ( - op == TK_AGG_COLUMN || op == TK_COLUMN || op == TK_REGISTER || op == TK_TRIGGER - )) { - /* op==TK_REGISTER && p->pTab!=0 happens when pExpr was originally - ** a TK_COLUMN but was previously evaluated and cached in a register */ - string zColl; - int j = p.iColumn; - if (j >= 0) { - sqlite3 db = pParse.db; - zColl = p.pTab.aCol[j].zColl; - pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0); - pExpr.pColl = pColl; - } - break; - } - if (op != TK_CAST && op != TK_UPLUS) { - break; - } - p = p.pLeft; - } - if (sqlite3CheckCollSeq(pParse, pColl) != 0) { - pColl = null; - } - return pColl; + if ( op != TK_CAST && op != TK_UPLUS ) + { + break; } + p = p.pLeft; + } + if ( sqlite3CheckCollSeq( pParse, pColl ) != 0 ) + { + pColl = null; + } + return pColl; + } - /* - ** pExpr is an operand of a comparison operator. aff2 is the - ** type affinity of the other operand. This routine returns the - ** type affinity that should be used for the comparison operator. + /* + ** pExpr is an operand of a comparison operator. aff2 is the + ** type affinity of the other operand. This routine returns the + ** type affinity that should be used for the comparison operator. + */ + static char sqlite3CompareAffinity( Expr pExpr, char aff2 ) + { + char aff1 = sqlite3ExprAffinity( pExpr ); + if ( aff1 != '\0' && aff2 != '\0' ) + { + /* Both sides of the comparison are columns. If one has numeric + ** affinity, use that. Otherwise use no affinity. */ - static char sqlite3CompareAffinity(Expr pExpr, char aff2) { - char aff1 = sqlite3ExprAffinity(pExpr); - if (aff1 != '\0' && aff2 != '\0') { - /* Both sides of the comparison are columns. If one has numeric - ** affinity, use that. Otherwise use no affinity. - */ - if (aff1 >= SQLITE_AFF_NUMERIC || aff2 >= SQLITE_AFF_NUMERIC) - // if (sqlite3IsNumericAffinity(aff1) || sqlite3IsNumericAffinity(aff2)) - { - return SQLITE_AFF_NUMERIC; - } else { - return SQLITE_AFF_NONE; - } - } else if (aff1 == '\0' && aff2 == '\0') { - /* Neither side of the comparison is a column. Compare the - ** results directly. - */ - return SQLITE_AFF_NONE; - } else { - /* One side is a column, the other is not. Use the columns affinity. */ - Debug.Assert(aff1 == 0 || aff2 == 0); - return (aff1 != '\0' ? aff1 : aff2); - } + if ( aff1 >= SQLITE_AFF_NUMERIC || aff2 >= SQLITE_AFF_NUMERIC ) + // if (sqlite3IsNumericAffinity(aff1) || sqlite3IsNumericAffinity(aff2)) + { + return SQLITE_AFF_NUMERIC; } - - /* - ** pExpr is a comparison operator. Return the type affinity that should - ** be applied to both operands prior to doing the comparison. - */ - static char comparisonAffinity(Expr pExpr) { - char aff; - Debug.Assert(pExpr.op == TK_EQ || pExpr.op == TK_IN || pExpr.op == TK_LT || - pExpr.op == TK_GT || pExpr.op == TK_GE || pExpr.op == TK_LE || - pExpr.op == TK_NE || pExpr.op == TK_IS || pExpr.op == TK_ISNOT); - Debug.Assert(pExpr.pLeft != null); - aff = sqlite3ExprAffinity(pExpr.pLeft); - if (pExpr.pRight != null) { - aff = sqlite3CompareAffinity(pExpr.pRight, aff); - } else if (ExprHasProperty(pExpr, EP_xIsSelect)) { - aff = sqlite3CompareAffinity(pExpr.x.pSelect.pEList.a[0].pExpr, aff); - } else if (aff == '\0') { - aff = SQLITE_AFF_NONE; - } - return aff; + else + { + return SQLITE_AFF_NONE; } - - /* - ** pExpr is a comparison expression, eg. '=', '<', IN(...) etc. - ** idx_affinity is the affinity of an indexed column. Return true - ** if the index with affinity idx_affinity may be used to implement - ** the comparison in pExpr. + } + else if ( aff1 == '\0' && aff2 == '\0' ) + { + /* Neither side of the comparison is a column. Compare the + ** results directly. */ - static bool sqlite3IndexAffinityOk(Expr pExpr, char idx_affinity) { - char aff = comparisonAffinity(pExpr); - switch (aff) { - case SQLITE_AFF_NONE: - return true; - case SQLITE_AFF_TEXT: - return idx_affinity == SQLITE_AFF_TEXT; - default: - return idx_affinity >= SQLITE_AFF_NUMERIC;// sqlite3IsNumericAffinity(idx_affinity); - } - } + return SQLITE_AFF_NONE; + } + else + { + /* One side is a column, the other is not. Use the columns affinity. */ + Debug.Assert( aff1 == 0 || aff2 == 0 ); + return ( aff1 != '\0' ? aff1 : aff2 ); + } + } - /* - ** Return the P5 value that should be used for a binary comparison - ** opcode (OP_Eq, OP_Ge etc.) used to compare pExpr1 and pExpr2. - */ - static u8 binaryCompareP5(Expr pExpr1, Expr pExpr2, int jumpIfNull) { - u8 aff = (u8)sqlite3ExprAffinity(pExpr2); - aff = (u8)((u8)sqlite3CompareAffinity(pExpr1, (char)aff) | (u8)jumpIfNull); - return aff; - } + /* + ** pExpr is a comparison operator. Return the type affinity that should + ** be applied to both operands prior to doing the comparison. + */ + static char comparisonAffinity( Expr pExpr ) + { + char aff; + Debug.Assert( pExpr.op == TK_EQ || pExpr.op == TK_IN || pExpr.op == TK_LT || + pExpr.op == TK_GT || pExpr.op == TK_GE || pExpr.op == TK_LE || + pExpr.op == TK_NE || pExpr.op == TK_IS || pExpr.op == TK_ISNOT ); + Debug.Assert( pExpr.pLeft != null ); + aff = sqlite3ExprAffinity( pExpr.pLeft ); + if ( pExpr.pRight != null ) + { + aff = sqlite3CompareAffinity( pExpr.pRight, aff ); + } + else if ( ExprHasProperty( pExpr, EP_xIsSelect ) ) + { + aff = sqlite3CompareAffinity( pExpr.x.pSelect.pEList.a[0].pExpr, aff ); + } + else if ( aff == '\0' ) + { + aff = SQLITE_AFF_NONE; + } + return aff; + } - /* - ** Return a pointer to the collation sequence that should be used by - ** a binary comparison operator comparing pLeft and pRight. - ** - ** If the left hand expression has a collating sequence type, then it is - ** used. Otherwise the collation sequence for the right hand expression - ** is used, or the default (BINARY) if neither expression has a collating - ** type. - ** - ** Argument pRight (but not pLeft) may be a null pointer. In this case, - ** it is not considered. - */ - static CollSeq sqlite3BinaryCompareCollSeq( - Parse pParse, - Expr pLeft, - Expr pRight - ) { - CollSeq pColl; - Debug.Assert(pLeft != null); - if ((pLeft.flags & EP_ExpCollate) != 0) { - Debug.Assert(pLeft.pColl != null); - pColl = pLeft.pColl; - } else if (pRight != null && ((pRight.flags & EP_ExpCollate) != 0)) { - Debug.Assert(pRight.pColl != null); - pColl = pRight.pColl; - } else { - pColl = sqlite3ExprCollSeq(pParse, pLeft); - if (pColl == null) { - pColl = sqlite3ExprCollSeq(pParse, pRight); - } - } - return pColl; - } + /* + ** pExpr is a comparison expression, eg. '=', '<', IN(...) etc. + ** idx_affinity is the affinity of an indexed column. Return true + ** if the index with affinity idx_affinity may be used to implement + ** the comparison in pExpr. + */ + static bool sqlite3IndexAffinityOk( Expr pExpr, char idx_affinity ) + { + char aff = comparisonAffinity( pExpr ); + switch ( aff ) + { + case SQLITE_AFF_NONE: + return true; + case SQLITE_AFF_TEXT: + return idx_affinity == SQLITE_AFF_TEXT; + default: + return idx_affinity >= SQLITE_AFF_NUMERIC;// sqlite3IsNumericAffinity(idx_affinity); + } + } - /* - ** Generate code for a comparison operator. - */ - static int codeCompare( - Parse pParse, /* The parsing (and code generating) context */ - Expr pLeft, /* The left operand */ - Expr pRight, /* The right operand */ - int opcode, /* The comparison opcode */ - int in1, int in2, /* Register holding operands */ - int dest, /* Jump here if true. */ - int jumpIfNull /* If true, jump if either operand is NULL */ - ) { - int p5; - int addr; - CollSeq p4; - - p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight); - p5 = binaryCompareP5(pLeft, pRight, jumpIfNull); - addr = sqlite3VdbeAddOp4(pParse.pVdbe, opcode, in2, dest, in1, - p4, P4_COLLSEQ); - sqlite3VdbeChangeP5(pParse.pVdbe, (u8)p5); - return addr; + /* + ** Return the P5 value that should be used for a binary comparison + ** opcode (OP_Eq, OP_Ge etc.) used to compare pExpr1 and pExpr2. + */ + static u8 binaryCompareP5( Expr pExpr1, Expr pExpr2, int jumpIfNull ) + { + u8 aff = (u8)sqlite3ExprAffinity( pExpr2 ); + aff = (u8)( (u8)sqlite3CompareAffinity( pExpr1, (char)aff ) | (u8)jumpIfNull ); + return aff; + } + + /* + ** Return a pointer to the collation sequence that should be used by + ** a binary comparison operator comparing pLeft and pRight. + ** + ** If the left hand expression has a collating sequence type, then it is + ** used. Otherwise the collation sequence for the right hand expression + ** is used, or the default (BINARY) if neither expression has a collating + ** type. + ** + ** Argument pRight (but not pLeft) may be a null pointer. In this case, + ** it is not considered. + */ + static CollSeq sqlite3BinaryCompareCollSeq( + Parse pParse, + Expr pLeft, + Expr pRight + ) + { + CollSeq pColl; + Debug.Assert( pLeft != null ); + if ( ( pLeft.flags & EP_ExpCollate ) != 0 ) + { + Debug.Assert( pLeft.pColl != null ); + pColl = pLeft.pColl; + } + else if ( pRight != null && ( ( pRight.flags & EP_ExpCollate ) != 0 ) ) + { + Debug.Assert( pRight.pColl != null ); + pColl = pRight.pColl; + } + else + { + pColl = sqlite3ExprCollSeq( pParse, pLeft ); + if ( pColl == null ) + { + pColl = sqlite3ExprCollSeq( pParse, pRight ); } + } + return pColl; + } + + /* + ** Generate code for a comparison operator. + */ + static int codeCompare( + Parse pParse, /* The parsing (and code generating) context */ + Expr pLeft, /* The left operand */ + Expr pRight, /* The right operand */ + int opcode, /* The comparison opcode */ + int in1, int in2, /* Register holding operands */ + int dest, /* Jump here if true. */ + int jumpIfNull /* If true, jump if either operand is NULL */ + ) + { + int p5; + int addr; + CollSeq p4; + + p4 = sqlite3BinaryCompareCollSeq( pParse, pLeft, pRight ); + p5 = binaryCompareP5( pLeft, pRight, jumpIfNull ); + addr = sqlite3VdbeAddOp4( pParse.pVdbe, opcode, in2, dest, in1, + p4, P4_COLLSEQ ); + sqlite3VdbeChangeP5( pParse.pVdbe, (u8)p5 ); + return addr; + } #if SQLITE_MAX_EXPR_DEPTH //>0 - /* - ** Check that argument nHeight is less than or equal to the maximum - ** expression depth allowed. If it is not, leave an error message in - ** pParse. - */ - static int sqlite3ExprCheckHeight(Parse pParse, int nHeight) { - int rc = SQLITE_OK; - int mxHeight = pParse.db.aLimit[SQLITE_LIMIT_EXPR_DEPTH]; - if (nHeight > mxHeight) { - sqlite3ErrorMsg(pParse, - "Expression tree is too large (maximum depth %d)", mxHeight - ); - rc = SQLITE_ERROR; - } - return rc; - } + /* +** Check that argument nHeight is less than or equal to the maximum +** expression depth allowed. If it is not, leave an error message in +** pParse. +*/ + static int sqlite3ExprCheckHeight( Parse pParse, int nHeight ) + { + int rc = SQLITE_OK; + int mxHeight = pParse.db.aLimit[SQLITE_LIMIT_EXPR_DEPTH]; + if ( nHeight > mxHeight ) + { + sqlite3ErrorMsg( pParse, + "Expression tree is too large (maximum depth %d)", mxHeight + ); + rc = SQLITE_ERROR; + } + return rc; + } - /* The following three functions, heightOfExpr(), heightOfExprList() - ** and heightOfSelect(), are used to determine the maximum height - ** of any expression tree referenced by the structure passed as the - ** first argument. - ** - ** If this maximum height is greater than the current value pointed - ** to by pnHeight, the second parameter, then set pnHeight to that - ** value. - */ - static void heightOfExpr(Expr p, ref int pnHeight) { - if (p != null) { - if (p.nHeight > pnHeight) { - pnHeight = p.nHeight; - } - } - } - static void heightOfExprList(ExprList p, ref int pnHeight) { - if (p != null) { - int i; - for (i = 0; i < p.nExpr; i++) { - heightOfExpr(p.a[i].pExpr, ref pnHeight); - } - } + /* The following three functions, heightOfExpr(), heightOfExprList() + ** and heightOfSelect(), are used to determine the maximum height + ** of any expression tree referenced by the structure passed as the + ** first argument. + ** + ** If this maximum height is greater than the current value pointed + ** to by pnHeight, the second parameter, then set pnHeight to that + ** value. + */ + static void heightOfExpr( Expr p, ref int pnHeight ) + { + if ( p != null ) + { + if ( p.nHeight > pnHeight ) + { + pnHeight = p.nHeight; } - static void heightOfSelect(Select p, ref int pnHeight) { - if (p != null) { - heightOfExpr(p.pWhere, ref pnHeight); - heightOfExpr(p.pHaving, ref pnHeight); - heightOfExpr(p.pLimit, ref pnHeight); - heightOfExpr(p.pOffset, ref pnHeight); - heightOfExprList(p.pEList, ref pnHeight); - heightOfExprList(p.pGroupBy, ref pnHeight); - heightOfExprList(p.pOrderBy, ref pnHeight); - heightOfSelect(p.pPrior, ref pnHeight); - } + } + } + static void heightOfExprList( ExprList p, ref int pnHeight ) + { + if ( p != null ) + { + int i; + for ( i = 0; i < p.nExpr; i++ ) + { + heightOfExpr( p.a[i].pExpr, ref pnHeight ); } + } + } + static void heightOfSelect( Select p, ref int pnHeight ) + { + if ( p != null ) + { + heightOfExpr( p.pWhere, ref pnHeight ); + heightOfExpr( p.pHaving, ref pnHeight ); + heightOfExpr( p.pLimit, ref pnHeight ); + heightOfExpr( p.pOffset, ref pnHeight ); + heightOfExprList( p.pEList, ref pnHeight ); + heightOfExprList( p.pGroupBy, ref pnHeight ); + heightOfExprList( p.pOrderBy, ref pnHeight ); + heightOfSelect( p.pPrior, ref pnHeight ); + } + } - /* - ** Set the Expr.nHeight variable in the structure passed as an - ** argument. An expression with no children, Expr.x.pList or - ** Expr.x.pSelect member has a height of 1. Any other expression - ** has a height equal to the maximum height of any other - ** referenced Expr plus one. - */ - static void exprSetHeight(Expr p) { - int nHeight = 0; - heightOfExpr(p.pLeft, ref nHeight); - heightOfExpr(p.pRight, ref nHeight); - if (ExprHasProperty(p, EP_xIsSelect)) { - heightOfSelect(p.x.pSelect, ref nHeight); - } else { - heightOfExprList(p.x.pList, ref nHeight); - } - p.nHeight = nHeight + 1; - } + /* + ** Set the Expr.nHeight variable in the structure passed as an + ** argument. An expression with no children, Expr.x.pList or + ** Expr.x.pSelect member has a height of 1. Any other expression + ** has a height equal to the maximum height of any other + ** referenced Expr plus one. + */ + static void exprSetHeight( Expr p ) + { + int nHeight = 0; + heightOfExpr( p.pLeft, ref nHeight ); + heightOfExpr( p.pRight, ref nHeight ); + if ( ExprHasProperty( p, EP_xIsSelect ) ) + { + heightOfSelect( p.x.pSelect, ref nHeight ); + } + else + { + heightOfExprList( p.x.pList, ref nHeight ); + } + p.nHeight = nHeight + 1; + } - /* - ** Set the Expr.nHeight variable using the exprSetHeight() function. If - ** the height is greater than the maximum allowed expression depth, - ** leave an error in pParse. - */ - static void sqlite3ExprSetHeight(Parse pParse, Expr p) { - exprSetHeight(p); - sqlite3ExprCheckHeight(pParse, p.nHeight); - } + /* + ** Set the Expr.nHeight variable using the exprSetHeight() function. If + ** the height is greater than the maximum allowed expression depth, + ** leave an error in pParse. + */ + static void sqlite3ExprSetHeight( Parse pParse, Expr p ) + { + exprSetHeight( p ); + sqlite3ExprCheckHeight( pParse, p.nHeight ); + } - /* - ** Return the maximum height of any expression tree referenced - ** by the select statement passed as an argument. - */ - static int sqlite3SelectExprHeight(Select p) { - int nHeight = 0; - heightOfSelect(p, ref nHeight); - return nHeight; - } + /* + ** Return the maximum height of any expression tree referenced + ** by the select statement passed as an argument. + */ + static int sqlite3SelectExprHeight( Select p ) + { + int nHeight = 0; + heightOfSelect( p, ref nHeight ); + return nHeight; + } #else //#define exprSetHeight(y) #endif //* SQLITE_MAX_EXPR_DEPTH>0 */ - /* - ** This routine is the core allocator for Expr nodes. - ** - ** Construct a new expression node and return a pointer to it. Memory - ** for this node and for the pToken argument is a single allocation - ** obtained from sqlite3DbMalloc(). The calling function - ** is responsible for making sure the node eventually gets freed. - ** - ** If dequote is true, then the token (if it exists) is dequoted. - ** If dequote is false, no dequoting is performance. The deQuote - ** parameter is ignored if pToken is NULL or if the token does not - ** appear to be quoted. If the quotes were of the form "..." (double-quotes) - ** then the EP_DblQuoted flag is set on the expression node. - ** - ** Special case: If op==TK_INTEGER and pToken points to a string that - ** can be translated into a 32-bit integer, then the token is not - ** stored in u.zToken. Instead, the integer values is written - ** into u.iValue and the EP_IntValue flag is set. No extra storage - ** is allocated to hold the integer text and the dequote flag is ignored. - */ - static Expr sqlite3ExprAlloc( - sqlite3 db, /* Handle for sqlite3DbMallocZero() (may be null) */ - int op, /* Expression opcode */ - Token pToken, /* Token argument. Might be NULL */ - int dequote /* True to dequote */ - ) { - Expr pNew; - int nExtra = 0; - int iValue = 0; - - if (pToken != null) { - if (op != TK_INTEGER || pToken.z == null || pToken.z.Length == 0 - || sqlite3GetInt32(pToken.z.ToString(), ref iValue) == false) { - nExtra = pToken.n + 1; - Debug.Assert(iValue >= 0); - } - } - pNew = new Expr();//sqlite3DbMallocZero(db, sizeof(Expr)+nExtra); - if (pNew != null) { - pNew.op = (u8)op; - pNew.iAgg = -1; - if (pToken != null) { - if (nExtra == 0) { - pNew.flags |= EP_IntValue; - pNew.u.iValue = iValue; - } else { - int c; - //pNew.u.zToken = (char)&pNew[1]; - if (pToken.n > 0) - pNew.u.zToken = pToken.z.Substring(0, pToken.n);//memcpy(pNew.u.zToken, pToken.z, pToken.n); - else if (pToken.n == 0 && string.IsNullOrEmpty(pToken.z)) - pNew.u.zToken = string.Empty; - //pNew.u.zToken[pToken.n] = 0; - if (dequote != 0 && nExtra >= 3 - && ((c = pToken.z[0]) == '\'' || c == '"' || c == '[' || c == '`')) { + /* +** This routine is the core allocator for Expr nodes. +** +** Construct a new expression node and return a pointer to it. Memory +** for this node and for the pToken argument is a single allocation +** obtained from sqlite3DbMalloc(). The calling function +** is responsible for making sure the node eventually gets freed. +** +** If dequote is true, then the token (if it exists) is dequoted. +** If dequote is false, no dequoting is performance. The deQuote +** parameter is ignored if pToken is NULL or if the token does not +** appear to be quoted. If the quotes were of the form "..." (double-quotes) +** then the EP_DblQuoted flag is set on the expression node. +** +** Special case: If op==TK_INTEGER and pToken points to a string that +** can be translated into a 32-bit integer, then the token is not +** stored in u.zToken. Instead, the integer values is written +** into u.iValue and the EP_IntValue flag is set. No extra storage +** is allocated to hold the integer text and the dequote flag is ignored. +*/ + static Expr sqlite3ExprAlloc( + sqlite3 db, /* Handle for sqlite3DbMallocZero() (may be null) */ + int op, /* Expression opcode */ + Token pToken, /* Token argument. Might be NULL */ + int dequote /* True to dequote */ + ) + { + Expr pNew; + int nExtra = 0; + int iValue = 0; + + if ( pToken != null ) + { + if ( op != TK_INTEGER || pToken.z == null || pToken.z.Length == 0 + || sqlite3GetInt32( pToken.z.ToString(), ref iValue ) == false ) + { + nExtra = pToken.n + 1; + Debug.Assert( iValue >= 0 ); + } + } + pNew = new Expr();//sqlite3DbMallocZero(db, sizeof(Expr)+nExtra); + if ( pNew != null ) + { + pNew.op = (u8)op; + pNew.iAgg = -1; + if ( pToken != null ) + { + if ( nExtra == 0 ) + { + pNew.flags |= EP_IntValue; + pNew.u.iValue = iValue; + } + else + { + int c; + //pNew.u.zToken = (char)&pNew[1]; + if ( pToken.n > 0 ) + pNew.u.zToken = pToken.z.Substring( 0, pToken.n );//memcpy(pNew.u.zToken, pToken.z, pToken.n); + else if ( pToken.n == 0 && string.IsNullOrEmpty(pToken.z)) + pNew.u.zToken = string.Empty; + //pNew.u.zToken[pToken.n] = 0; + if ( dequote != 0 && nExtra >= 3 + && ( ( c = pToken.z[0] ) == '\'' || c == '"' || c == '[' || c == '`' ) ) + { #if DEBUG_CLASS_EXPR || DEBUG_CLASS_ALL sqlite3Dequote(ref pNew.u._zToken); #else - sqlite3Dequote(ref pNew.u.zToken); -#endif - if (c == '"') - pNew.flags |= EP_DblQuoted; - } - } - } -#if SQLITE_MAX_EXPR_DEPTH//>0 - pNew.nHeight = 1; + sqlite3Dequote( ref pNew.u.zToken ); #endif + if ( c == '"' ) + pNew.flags |= EP_DblQuoted; } - return pNew; - } - - /* - ** Allocate a new expression node from a zero-terminated token that has - ** already been dequoted. - */ - static Expr sqlite3Expr( - sqlite3 db, /* Handle for sqlite3DbMallocZero() (may be null) */ - int op, /* Expression opcode */ - string zToken /* Token argument. Might be NULL */ - ) { - Token x = new Token(); - x.z = zToken; - x.n = !string.IsNullOrEmpty(zToken) ? sqlite3Strlen30(zToken) : 0; - return sqlite3ExprAlloc(db, op, x, 0); + } } +#if SQLITE_MAX_EXPR_DEPTH//>0 + pNew.nHeight = 1; +#endif + } + return pNew; + } - /* - ** Attach subtrees pLeft and pRight to the Expr node pRoot. - ** - ** If pRoot==NULL that means that a memory allocation error has occurred. - ** In that case, delete the subtrees pLeft and pRight. - */ - static void sqlite3ExprAttachSubtrees( - sqlite3 db, - Expr pRoot, - Expr pLeft, - Expr pRight - ) { - if (pRoot == null) { - //Debug.Assert( db.mallocFailed != 0 ); - sqlite3ExprDelete(db, ref pLeft); - sqlite3ExprDelete(db, ref pRight); - } else { - if (pRight != null) { - pRoot.pRight = pRight; - if ((pRight.flags & EP_ExpCollate) != 0) { - pRoot.flags |= EP_ExpCollate; - pRoot.pColl = pRight.pColl; - } - } - if (pLeft != null) { - pRoot.pLeft = pLeft; - if ((pLeft.flags & EP_ExpCollate) != 0) { - pRoot.flags |= EP_ExpCollate; - pRoot.pColl = pLeft.pColl; - } - } - exprSetHeight(pRoot); - } - } + /* + ** Allocate a new expression node from a zero-terminated token that has + ** already been dequoted. + */ + static Expr sqlite3Expr( + sqlite3 db, /* Handle for sqlite3DbMallocZero() (may be null) */ + int op, /* Expression opcode */ + string zToken /* Token argument. Might be NULL */ + ) + { + Token x = new Token(); + x.z = zToken; + x.n = !string.IsNullOrEmpty( zToken ) ? sqlite3Strlen30( zToken ) : 0; + return sqlite3ExprAlloc( db, op, x, 0 ); + } - /* - ** Allocate a Expr node which joins as many as two subtrees. - ** - ** One or both of the subtrees can be NULL. Return a pointer to the new - ** Expr node. Or, if an OOM error occurs, set pParse->db->mallocFailed, - ** free the subtrees and return NULL. - */ - // OVERLOADS, so I don't need to rewrite parse.c - static Expr sqlite3PExpr(Parse pParse, int op, int null_3, int null_4, int null_5) { - return sqlite3PExpr(pParse, op, null, null, null); - } - static Expr sqlite3PExpr(Parse pParse, int op, int null_3, int null_4, Token pToken) { - return sqlite3PExpr(pParse, op, null, null, pToken); - } - static Expr sqlite3PExpr(Parse pParse, int op, Expr pLeft, int null_4, int null_5) { - return sqlite3PExpr(pParse, op, pLeft, null, null); - } - static Expr sqlite3PExpr(Parse pParse, int op, Expr pLeft, int null_4, Token pToken) { - return sqlite3PExpr(pParse, op, pLeft, null, pToken); - } - static Expr sqlite3PExpr(Parse pParse, int op, Expr pLeft, Expr pRight, int null_5) { - return sqlite3PExpr(pParse, op, pLeft, pRight, null); + /* + ** Attach subtrees pLeft and pRight to the Expr node pRoot. + ** + ** If pRoot==NULL that means that a memory allocation error has occurred. + ** In that case, delete the subtrees pLeft and pRight. + */ + static void sqlite3ExprAttachSubtrees( + sqlite3 db, + Expr pRoot, + Expr pLeft, + Expr pRight + ) + { + if ( pRoot == null ) + { + //Debug.Assert( db.mallocFailed != 0 ); + sqlite3ExprDelete( db, ref pLeft ); + sqlite3ExprDelete( db, ref pRight ); + } + else + { + if ( pRight != null ) + { + pRoot.pRight = pRight; + if ( ( pRight.flags & EP_ExpCollate ) != 0 ) + { + pRoot.flags |= EP_ExpCollate; + pRoot.pColl = pRight.pColl; + } } - static Expr sqlite3PExpr( - Parse pParse, /* Parsing context */ - int op, /* Expression opcode */ - Expr pLeft, /* Left operand */ - Expr pRight, /* Right operand */ - Token pToken /* Argument Token */ - ) { - Expr p = sqlite3ExprAlloc(pParse.db, op, pToken, 1); - sqlite3ExprAttachSubtrees(pParse.db, p, pLeft, pRight); - if (p != null) { - sqlite3ExprCheckHeight(pParse, p.nHeight); - } - return p; + if ( pLeft != null ) + { + pRoot.pLeft = pLeft; + if ( ( pLeft.flags & EP_ExpCollate ) != 0 ) + { + pRoot.flags |= EP_ExpCollate; + pRoot.pColl = pLeft.pColl; + } } + exprSetHeight( pRoot ); + } + } - /* - ** Join two expressions using an AND operator. If either expression is - ** NULL, then just return the other expression. - */ - static Expr sqlite3ExprAnd(sqlite3 db, Expr pLeft, Expr pRight) { - if (pLeft == null) { - return pRight; - } else if (pRight == null) { - return pLeft; - } else { - Expr pNew = sqlite3ExprAlloc(db, TK_AND, null, 0); - sqlite3ExprAttachSubtrees(db, pNew, pLeft, pRight); - return pNew; - } - } + /* + ** Allocate a Expr node which joins as many as two subtrees. + ** + ** One or both of the subtrees can be NULL. Return a pointer to the new + ** Expr node. Or, if an OOM error occurs, set pParse->db->mallocFailed, + ** free the subtrees and return NULL. + */ + // OVERLOADS, so I don't need to rewrite parse.c + static Expr sqlite3PExpr( Parse pParse, int op, int null_3, int null_4, int null_5 ) + { + return sqlite3PExpr( pParse, op, null, null, null ); + } + static Expr sqlite3PExpr( Parse pParse, int op, int null_3, int null_4, Token pToken ) + { + return sqlite3PExpr( pParse, op, null, null, pToken ); + } + static Expr sqlite3PExpr( Parse pParse, int op, Expr pLeft, int null_4, int null_5 ) + { + return sqlite3PExpr( pParse, op, pLeft, null, null ); + } + static Expr sqlite3PExpr( Parse pParse, int op, Expr pLeft, int null_4, Token pToken ) + { + return sqlite3PExpr( pParse, op, pLeft, null, pToken ); + } + static Expr sqlite3PExpr( Parse pParse, int op, Expr pLeft, Expr pRight, int null_5 ) + { + return sqlite3PExpr( pParse, op, pLeft, pRight, null ); + } + static Expr sqlite3PExpr( + Parse pParse, /* Parsing context */ + int op, /* Expression opcode */ + Expr pLeft, /* Left operand */ + Expr pRight, /* Right operand */ + Token pToken /* Argument Token */ + ) + { + Expr p = sqlite3ExprAlloc( pParse.db, op, pToken, 1 ); + sqlite3ExprAttachSubtrees( pParse.db, p, pLeft, pRight ); + if ( p != null ) + { + sqlite3ExprCheckHeight( pParse, p.nHeight ); + } + return p; + } - /* - ** Construct a new expression node for a function with multiple - ** arguments. - */ - // OVERLOADS, so I don't need to rewrite parse.c - static Expr sqlite3ExprFunction(Parse pParse, int null_2, Token pToken) { - return sqlite3ExprFunction(pParse, null, pToken); - } - static Expr sqlite3ExprFunction(Parse pParse, ExprList pList, int null_3) { - return sqlite3ExprFunction(pParse, pList, null); - } - static Expr sqlite3ExprFunction(Parse pParse, ExprList pList, Token pToken) { - Expr pNew; - sqlite3 db = pParse.db; - Debug.Assert(pToken != null); - pNew = sqlite3ExprAlloc(db, TK_FUNCTION, pToken, 1); - if (pNew == null) { - sqlite3ExprListDelete(db, ref pList); /* Avoid memory leak when malloc fails */ - return null; - } - pNew.x.pList = pList; - Debug.Assert(!ExprHasProperty(pNew, EP_xIsSelect)); + /* + ** Join two expressions using an AND operator. If either expression is + ** NULL, then just return the other expression. + */ + static Expr sqlite3ExprAnd( sqlite3 db, Expr pLeft, Expr pRight ) + { + if ( pLeft == null ) + { + return pRight; + } + else if ( pRight == null ) + { + return pLeft; + } + else + { + Expr pNew = sqlite3ExprAlloc( db, TK_AND, null, 0 ); + sqlite3ExprAttachSubtrees( db, pNew, pLeft, pRight ); + return pNew; + } + } - sqlite3ExprSetHeight(pParse, pNew); - return pNew; - } + /* + ** Construct a new expression node for a function with multiple + ** arguments. + */ + // OVERLOADS, so I don't need to rewrite parse.c + static Expr sqlite3ExprFunction( Parse pParse, int null_2, Token pToken ) + { + return sqlite3ExprFunction( pParse, null, pToken ); + } + static Expr sqlite3ExprFunction( Parse pParse, ExprList pList, int null_3 ) + { + return sqlite3ExprFunction( pParse, pList, null ); + } + static Expr sqlite3ExprFunction( Parse pParse, ExprList pList, Token pToken ) + { + Expr pNew; + sqlite3 db = pParse.db; + Debug.Assert( pToken != null ); + pNew = sqlite3ExprAlloc( db, TK_FUNCTION, pToken, 1 ); + if ( pNew == null ) + { + sqlite3ExprListDelete( db, ref pList ); /* Avoid memory leak when malloc fails */ + return null; + } + pNew.x.pList = pList; + Debug.Assert( !ExprHasProperty( pNew, EP_xIsSelect ) ); + + sqlite3ExprSetHeight( pParse, pNew ); + return pNew; + } - /* - ** Assign a variable number to an expression that encodes a wildcard - ** in the original SQL statement. - ** - ** Wildcards consisting of a single "?" are assigned the next sequential - ** variable number. - ** - ** Wildcards of the form "?nnn" are assigned the number "nnn". We make - ** sure "nnn" is not too be to avoid a denial of service attack when - ** the SQL statement comes from an external source. - ** - ** Wildcards of the form ":aaa", "@aaa" or "$aaa" are assigned the same number - ** as the previous instance of the same wildcard. Or if this is the first - ** instance of the wildcard, the next sequenial variable number is - ** assigned. + /* + ** Assign a variable number to an expression that encodes a wildcard + ** in the original SQL statement. + ** + ** Wildcards consisting of a single "?" are assigned the next sequential + ** variable number. + ** + ** Wildcards of the form "?nnn" are assigned the number "nnn". We make + ** sure "nnn" is not too be to avoid a denial of service attack when + ** the SQL statement comes from an external source. + ** + ** Wildcards of the form ":aaa", "@aaa" or "$aaa" are assigned the same number + ** as the previous instance of the same wildcard. Or if this is the first + ** instance of the wildcard, the next sequenial variable number is + ** assigned. + */ + static void sqlite3ExprAssignVarNumber( Parse pParse, Expr pExpr ) + { + sqlite3 db = pParse.db; + string z; + + if ( pExpr == null ) + return; + Debug.Assert( !ExprHasAnyProperty( pExpr, EP_IntValue | EP_Reduced | EP_TokenOnly ) ); + z = pExpr.u.zToken; + Debug.Assert( z != null ); + Debug.Assert( z.Length != 0 ); + if ( z.Length == 1 ) + { + /* Wildcard of the form "?". Assign the next variable number */ + Debug.Assert( z[0] == '?' ); + pExpr.iColumn = (ynVar)( ++pParse.nVar ); + }else{ + ynVar x = 0; + int n = sqlite3Strlen30(z); + if( z[0]=='?' ){ + /* Wildcard of the form "?nnn". Convert "nnn" to an integer and + ** use it as the variable number */ + i64 i = 0; + bool bOk = 0 == sqlite3Atoi64( z.Substring( 1 ), ref i, n - 1, SQLITE_UTF8 ); + pExpr.iColumn = x=(ynVar)i; + testcase( i == 0 ); + testcase( i == 1 ); + testcase( i == db.aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] - 1 ); + testcase( i == db.aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ); + if ( bOk == false || i < 1 || i > db.aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ) + { + sqlite3ErrorMsg( pParse, "variable number must be between ?1 and ?%d", + db.aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ); + x=0; + } + if ( i > pParse.nVar ) + { + pParse.nVar = (int)i; + } + } + else + { + /* Wildcards like ":aaa", "$aaa" or "@aaa". Reuse the same variable + ** number as the prior appearance of the same name, or if the name + ** has never appeared before, reuse the same variable number */ - static void sqlite3ExprAssignVarNumber(Parse pParse, Expr pExpr) { - sqlite3 db = pParse.db; - string z; - - if (pExpr == null) - return; - Debug.Assert(!ExprHasAnyProperty(pExpr, EP_IntValue | EP_Reduced | EP_TokenOnly)); - z = pExpr.u.zToken; - Debug.Assert(z != null); - Debug.Assert(z.Length != 0); - if (z.Length == 1) { - /* Wildcard of the form "?". Assign the next variable number */ - Debug.Assert(z[0] == '?'); - pExpr.iColumn = (ynVar)(++pParse.nVar); - } else { - ynVar x = 0; - int n = sqlite3Strlen30(z); - if (z[0] == '?') { - /* Wildcard of the form "?nnn". Convert "nnn" to an integer and - ** use it as the variable number */ - i64 i = 0; - bool bOk = 0 == sqlite3Atoi64(z.Substring(1), ref i, n - 1, SQLITE_UTF8); - pExpr.iColumn = x = (ynVar)i; - testcase(i == 0); - testcase(i == 1); - testcase(i == db.aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] - 1); - testcase(i == db.aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]); - if (bOk == false || i < 1 || i > db.aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]) { - sqlite3ErrorMsg(pParse, "variable number must be between ?1 and ?%d", - db.aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]); - x = 0; - } - if (i > pParse.nVar) { - pParse.nVar = (int)i; - } - } else { - /* Wildcards like ":aaa", "$aaa" or "@aaa". Reuse the same variable - ** number as the prior appearance of the same name, or if the name - ** has never appeared before, reuse the same variable number - */ - ynVar i; - for (i = 0; i < pParse.nzVar; i++) { - if (pParse.azVar[i] != null && string.Equals(z, pParse.azVar[i], StringComparison.Ordinal)) //memcmp(pParse.azVar[i],z,n+1)==0 ) - { - pExpr.iColumn = x = (ynVar)(i + 1); - break; - } - } - if (x == 0) x = pExpr.iColumn = (ynVar)(++pParse.nVar); - } - if (x > 0) { - if (x > pParse.nzVar) { - //char **a; - //a = sqlite3DbRealloc(db, pParse.azVar, x*sizeof(a[0])); - //if( a==0 ) return; /* Error reported through db.mallocFailed */ - //pParse.azVar = a; - //memset(&a[pParse.nzVar], 0, (x-pParse.nzVar)*sizeof(a[0])); - Array.Resize(ref pParse.azVar, x); - pParse.nzVar = x; - } - if (z[0] != '?' || pParse.azVar[x - 1] == null) { - //sqlite3DbFree(db, pParse.azVar[x-1]); - pParse.azVar[x - 1] = z.Substring(0, n);//sqlite3DbStrNDup( db, z, n ); - } - } - } - if (pParse.nErr == 0 && pParse.nVar > db.aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]) { - sqlite3ErrorMsg(pParse, "too many SQL variables"); - } + ynVar i; + for(i=0; i0 ){ + if( x>pParse.nzVar ){ + //char **a; + //a = sqlite3DbRealloc(db, pParse.azVar, x*sizeof(a[0])); + //if( a==0 ) return; /* Error reported through db.mallocFailed */ + //pParse.azVar = a; + //memset(&a[pParse.nzVar], 0, (x-pParse.nzVar)*sizeof(a[0])); + Array.Resize( ref pParse.azVar, x ); + pParse.nzVar = x; + } + if( z[0]!='?' || pParse.azVar[x-1]==null ) + { + //sqlite3DbFree(db, pParse.azVar[x-1]); + pParse.azVar[x - 1] = z.Substring( 0, n );//sqlite3DbStrNDup( db, z, n ); + } + } + } + if ( pParse.nErr == 0 && pParse.nVar > db.aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ) + { + sqlite3ErrorMsg( pParse, "too many SQL variables" ); + } + } - /* - ** Recursively delete an expression tree. - */ - static void sqlite3ExprDelete(sqlite3 db, ref Expr p) { - if (p == null) - return; - /* Sanity check: Assert that the IntValue is non-negative if it exists */ - Debug.Assert(!ExprHasProperty(p, EP_IntValue) || p.u.iValue >= 0); - if (!ExprHasAnyProperty(p, EP_TokenOnly)) { - sqlite3ExprDelete(db, ref p.pLeft); - sqlite3ExprDelete(db, ref p.pRight); - if (!ExprHasProperty(p, EP_Reduced) && (p.flags2 & EP2_MallocedToken) != 0) { + /* + ** Recursively delete an expression tree. + */ + static void sqlite3ExprDelete( sqlite3 db, ref Expr p ) + { + if ( p == null ) + return; + /* Sanity check: Assert that the IntValue is non-negative if it exists */ + Debug.Assert( !ExprHasProperty( p, EP_IntValue ) || p.u.iValue >= 0 ); + if ( !ExprHasAnyProperty( p, EP_TokenOnly ) ) + { + sqlite3ExprDelete( db, ref p.pLeft ); + sqlite3ExprDelete( db, ref p.pRight ); + if ( !ExprHasProperty( p, EP_Reduced ) && ( p.flags2 & EP2_MallocedToken ) != 0 ) + { #if DEBUG_CLASS_EXPR || DEBUG_CLASS_ALL sqlite3DbFree( db, ref p.u._zToken ); #else - sqlite3DbFree(db, ref p.u.zToken); + sqlite3DbFree( db, ref p.u.zToken ); #endif - } - if (ExprHasProperty(p, EP_xIsSelect)) { - sqlite3SelectDelete(db, ref p.x.pSelect); - } else { - sqlite3ExprListDelete(db, ref p.x.pList); - } - } - if (!ExprHasProperty(p, EP_Static)) { - sqlite3DbFree(db, ref p); - } - } - - /* - ** Return the number of bytes allocated for the expression structure - ** passed as the first argument. This is always one of EXPR_FULLSIZE, - ** EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE. - */ - static int exprStructSize(Expr p) { - if (ExprHasProperty(p, EP_TokenOnly)) - return EXPR_TOKENONLYSIZE; - if (ExprHasProperty(p, EP_Reduced)) - return EXPR_REDUCEDSIZE; - return EXPR_FULLSIZE; } - - /* - ** The dupedExpr*Size() routines each return the number of bytes required - ** to store a copy of an expression or expression tree. They differ in - ** how much of the tree is measured. - ** - ** dupedExprStructSize() Size of only the Expr structure - ** dupedExprNodeSize() Size of Expr + space for token - ** dupedExprSize() Expr + token + subtree components - ** - *************************************************************************** - ** - ** The dupedExprStructSize() function returns two values OR-ed together: - ** (1) the space required for a copy of the Expr structure only and - ** (2) the EP_xxx flags that indicate what the structure size should be. - ** The return values is always one of: - ** - ** EXPR_FULLSIZE - ** EXPR_REDUCEDSIZE | EP_Reduced - ** EXPR_TOKENONLYSIZE | EP_TokenOnly - ** - ** The size of the structure can be found by masking the return value - ** of this routine with 0xfff. The flags can be found by masking the - ** return value with EP_Reduced|EP_TokenOnly. - ** - ** Note that with flags==EXPRDUP_REDUCE, this routines works on full-size - ** (unreduced) Expr objects as they or originally constructed by the parser. - ** During expression analysis, extra information is computed and moved into - ** later parts of teh Expr object and that extra information might get chopped - ** off if the expression is reduced. Note also that it does not work to - ** make a EXPRDUP_REDUCE copy of a reduced expression. It is only legal - ** to reduce a pristine expression tree from the parser. The implementation - ** of dupedExprStructSize() contain multiple Debug.Assert() statements that attempt - ** to enforce this constraint. - */ - static int dupedExprStructSize(Expr p, int flags) { - int nSize; - Debug.Assert(flags == EXPRDUP_REDUCE || flags == 0); /* Only one flag value allowed */ - if (0 == (flags & EXPRDUP_REDUCE)) { - nSize = EXPR_FULLSIZE; - } else { - Debug.Assert(!ExprHasAnyProperty(p, EP_TokenOnly | EP_Reduced)); - Debug.Assert(!ExprHasProperty(p, EP_FromJoin)); - Debug.Assert((p.flags2 & EP2_MallocedToken) == 0); - Debug.Assert((p.flags2 & EP2_Irreducible) == 0); - if (p.pLeft != null || p.pRight != null || p.pColl != null || p.x.pList != null || p.x.pSelect != null) { - nSize = EXPR_REDUCEDSIZE | EP_Reduced; - } else { - nSize = EXPR_TOKENONLYSIZE | EP_TokenOnly; - } - } - return nSize; + if ( ExprHasProperty( p, EP_xIsSelect ) ) + { + sqlite3SelectDelete( db, ref p.x.pSelect ); } - - /* - ** This function returns the space in bytes required to store the copy - ** of the Expr structure and a copy of the Expr.u.zToken string (if that - ** string is defined.) - */ - static int dupedExprNodeSize(Expr p, int flags) { - int nByte = dupedExprStructSize(p, flags) & 0xfff; - if (!ExprHasProperty(p, EP_IntValue) && p.u.zToken != null) { - nByte += sqlite3Strlen30(p.u.zToken) + 1; - } - return ROUND8(nByte); + else + { + sqlite3ExprListDelete( db, ref p.x.pList ); } + } + if ( !ExprHasProperty( p, EP_Static ) ) + { + sqlite3DbFree( db, ref p ); + } + } - /* - ** Return the number of bytes required to create a duplicate of the - ** expression passed as the first argument. The second argument is a - ** mask containing EXPRDUP_XXX flags. - ** - ** The value returned includes space to create a copy of the Expr struct - ** itself and the buffer referred to by Expr.u.zToken, if any. - ** - ** If the EXPRDUP_REDUCE flag is set, then the return value includes - ** space to duplicate all Expr nodes in the tree formed by Expr.pLeft - ** and Expr.pRight variables (but not for any structures pointed to or - ** descended from the Expr.x.pList or Expr.x.pSelect variables). - */ - static int dupedExprSize(Expr p, int flags) { - int nByte = 0; - if (p != null) { - nByte = dupedExprNodeSize(p, flags); - if ((flags & EXPRDUP_REDUCE) != 0) { - nByte += dupedExprSize(p.pLeft, flags) + dupedExprSize(p.pRight, flags); - } - } - return nByte; - } + /* + ** Return the number of bytes allocated for the expression structure + ** passed as the first argument. This is always one of EXPR_FULLSIZE, + ** EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE. + */ + static int exprStructSize( Expr p ) + { + if ( ExprHasProperty( p, EP_TokenOnly ) ) + return EXPR_TOKENONLYSIZE; + if ( ExprHasProperty( p, EP_Reduced ) ) + return EXPR_REDUCEDSIZE; + return EXPR_FULLSIZE; + } - /* - ** This function is similar to sqlite3ExprDup(), except that if pzBuffer - ** is not NULL then *pzBuffer is assumed to point to a buffer large enough - ** to store the copy of expression p, the copies of p->u.zToken - ** (if applicable), and the copies of the p->pLeft and p->pRight expressions, - ** if any. Before returning, *pzBuffer is set to the first byte passed the - ** portion of the buffer copied into by this function. - */ - static Expr exprDup(sqlite3 db, Expr p, int flags, ref Expr pzBuffer) { - Expr pNew = null; /* Value to return */ - if (p != null) { - bool isReduced = (flags & EXPRDUP_REDUCE) != 0; - ////Expr zAlloc = new Expr(); - u32 staticFlag = 0; - - Debug.Assert(pzBuffer == null || isReduced); - - /* Figure out where to write the new Expr structure. */ - //if ( pzBuffer !=null) - //{ - // zAlloc = pzBuffer; - // staticFlag = EP_Static; - //} - //else - //{ - ///Expr zAlloc = new Expr();//sqlite3DbMallocRaw( db, dupedExprSize( p, flags ) ); - //} - // (Expr)zAlloc; - - //if ( pNew != null ) - { - /* Set nNewSize to the size allocated for the structure pointed to - ** by pNew. This is either EXPR_FULLSIZE, EXPR_REDUCEDSIZE or - ** EXPR_TOKENONLYSIZE. nToken is set to the number of bytes consumed - ** by the copy of the p->u.zToken string (if any). - */ - int nStructSize = dupedExprStructSize(p, flags); - ////int nNewSize = nStructSize & 0xfff; - ////int nToken; - ////if ( !ExprHasProperty( p, EP_IntValue ) && !string.IsNullOrEmpty( p.u.zToken ) ) - ////{ - //// nToken = sqlite3Strlen30( p.u.zToken ); - ////} - ////else - ////{ - //// nToken = 0; - ////} - if (isReduced) { - Debug.Assert(!ExprHasProperty(p, EP_Reduced)); - pNew = p.Copy(EXPR_TOKENONLYSIZE);////memcpy( zAlloc, p, nNewSize ); - } else { - ////int nSize = exprStructSize( p ); - ////memcpy( zAlloc, p, nSize ); - pNew = p.Copy(); - ////memset( &zAlloc[nSize], 0, EXPR_FULLSIZE - nSize ); - } + /* + ** The dupedExpr*Size() routines each return the number of bytes required + ** to store a copy of an expression or expression tree. They differ in + ** how much of the tree is measured. + ** + ** dupedExprStructSize() Size of only the Expr structure + ** dupedExprNodeSize() Size of Expr + space for token + ** dupedExprSize() Expr + token + subtree components + ** + *************************************************************************** + ** + ** The dupedExprStructSize() function returns two values OR-ed together: + ** (1) the space required for a copy of the Expr structure only and + ** (2) the EP_xxx flags that indicate what the structure size should be. + ** The return values is always one of: + ** + ** EXPR_FULLSIZE + ** EXPR_REDUCEDSIZE | EP_Reduced + ** EXPR_TOKENONLYSIZE | EP_TokenOnly + ** + ** The size of the structure can be found by masking the return value + ** of this routine with 0xfff. The flags can be found by masking the + ** return value with EP_Reduced|EP_TokenOnly. + ** + ** Note that with flags==EXPRDUP_REDUCE, this routines works on full-size + ** (unreduced) Expr objects as they or originally constructed by the parser. + ** During expression analysis, extra information is computed and moved into + ** later parts of teh Expr object and that extra information might get chopped + ** off if the expression is reduced. Note also that it does not work to + ** make a EXPRDUP_REDUCE copy of a reduced expression. It is only legal + ** to reduce a pristine expression tree from the parser. The implementation + ** of dupedExprStructSize() contain multiple Debug.Assert() statements that attempt + ** to enforce this constraint. + */ + static int dupedExprStructSize( Expr p, int flags ) + { + int nSize; + Debug.Assert( flags == EXPRDUP_REDUCE || flags == 0 ); /* Only one flag value allowed */ + if ( 0 == ( flags & EXPRDUP_REDUCE ) ) + { + nSize = EXPR_FULLSIZE; + } + else + { + Debug.Assert( !ExprHasAnyProperty( p, EP_TokenOnly | EP_Reduced ) ); + Debug.Assert( !ExprHasProperty( p, EP_FromJoin ) ); + Debug.Assert( ( p.flags2 & EP2_MallocedToken ) == 0 ); + Debug.Assert( ( p.flags2 & EP2_Irreducible ) == 0 ); + if ( p.pLeft != null || p.pRight != null || p.pColl != null || p.x.pList != null || p.x.pSelect != null ) + { + nSize = EXPR_REDUCEDSIZE | EP_Reduced; + } + else + { + nSize = EXPR_TOKENONLYSIZE | EP_TokenOnly; + } + } + return nSize; + } - /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */ - unchecked { - pNew.flags &= (ushort)(~(EP_Reduced | EP_TokenOnly | EP_Static)); - } - pNew.flags |= (ushort)(nStructSize & (EP_Reduced | EP_TokenOnly)); - pNew.flags |= (ushort)staticFlag; - - /* Copy the p->u.zToken string, if any. */ - ////if ( nToken != 0 ) - ////{ - //// string zToken;// = pNew.u.zToken = (char)&zAlloc[nNewSize]; - //// zToken = p.u.zToken.Substring( 0, nToken );// memcpy( zToken, p.u.zToken, nToken ); - ////} - - if (0 == ((p.flags | pNew.flags) & EP_TokenOnly)) { - /* Fill in the pNew.x.pSelect or pNew.x.pList member. */ - if (ExprHasProperty(p, EP_xIsSelect)) { - pNew.x.pSelect = sqlite3SelectDup(db, p.x.pSelect, isReduced ? 1 : 0); - } else { - pNew.x.pList = sqlite3ExprListDup(db, p.x.pList, isReduced ? 1 : 0); - } - } + /* + ** This function returns the space in bytes required to store the copy + ** of the Expr structure and a copy of the Expr.u.zToken string (if that + ** string is defined.) + */ + static int dupedExprNodeSize( Expr p, int flags ) + { + int nByte = dupedExprStructSize( p, flags ) & 0xfff; + if ( !ExprHasProperty( p, EP_IntValue ) && p.u.zToken != null ) + { + nByte += sqlite3Strlen30( p.u.zToken ) + 1; + } + return ROUND8( nByte ); + } - /* Fill in pNew.pLeft and pNew.pRight. */ - if (ExprHasAnyProperty(pNew, EP_Reduced | EP_TokenOnly)) { - //zAlloc += dupedExprNodeSize( p, flags ); - if (ExprHasProperty(pNew, EP_Reduced)) { - pNew.pLeft = exprDup(db, p.pLeft, EXPRDUP_REDUCE, ref pzBuffer); - pNew.pRight = exprDup(db, p.pRight, EXPRDUP_REDUCE, ref pzBuffer); - } - //if ( pzBuffer != null ) - //{ - // pzBuffer = zAlloc; - //} - } else { - pNew.flags2 = 0; - if (!ExprHasAnyProperty(p, EP_TokenOnly)) { - pNew.pLeft = sqlite3ExprDup(db, p.pLeft, 0); - pNew.pRight = sqlite3ExprDup(db, p.pRight, 0); - } - } - } - } - return pNew; + /* + ** Return the number of bytes required to create a duplicate of the + ** expression passed as the first argument. The second argument is a + ** mask containing EXPRDUP_XXX flags. + ** + ** The value returned includes space to create a copy of the Expr struct + ** itself and the buffer referred to by Expr.u.zToken, if any. + ** + ** If the EXPRDUP_REDUCE flag is set, then the return value includes + ** space to duplicate all Expr nodes in the tree formed by Expr.pLeft + ** and Expr.pRight variables (but not for any structures pointed to or + ** descended from the Expr.x.pList or Expr.x.pSelect variables). + */ + static int dupedExprSize( Expr p, int flags ) + { + int nByte = 0; + if ( p != null ) + { + nByte = dupedExprNodeSize( p, flags ); + if ( ( flags & EXPRDUP_REDUCE ) != 0 ) + { + nByte += dupedExprSize( p.pLeft, flags ) + dupedExprSize( p.pRight, flags ); } + } + return nByte; + } - /* - ** The following group of routines make deep copies of expressions, - ** expression lists, ID lists, and select statements. The copies can - ** be deleted (by being passed to their respective ...Delete() routines) - ** without effecting the originals. - ** - ** The expression list, ID, and source lists return by sqlite3ExprListDup(), - ** sqlite3IdListDup(), and sqlite3SrcListDup() can not be further expanded - ** by subsequent calls to sqlite*ListAppend() routines. - ** - ** Any tables that the SrcList might point to are not duplicated. - ** - ** The flags parameter contains a combination of the EXPRDUP_XXX flags. - ** If the EXPRDUP_REDUCE flag is set, then the structure returned is a - ** truncated version of the usual Expr structure that will be stored as - ** part of the in-memory representation of the database schema. - */ - static Expr sqlite3ExprDup(sqlite3 db, Expr p, int flags) { - Expr ExprDummy = null; - return exprDup(db, p, flags, ref ExprDummy); - } + /* + ** This function is similar to sqlite3ExprDup(), except that if pzBuffer + ** is not NULL then *pzBuffer is assumed to point to a buffer large enough + ** to store the copy of expression p, the copies of p->u.zToken + ** (if applicable), and the copies of the p->pLeft and p->pRight expressions, + ** if any. Before returning, *pzBuffer is set to the first byte passed the + ** portion of the buffer copied into by this function. + */ + static Expr exprDup( sqlite3 db, Expr p, int flags, ref Expr pzBuffer ) + { + Expr pNew = null; /* Value to return */ + if ( p != null ) + { + bool isReduced = ( flags & EXPRDUP_REDUCE ) != 0; + ////Expr zAlloc = new Expr(); + u32 staticFlag = 0; + + Debug.Assert( pzBuffer == null || isReduced ); + + /* Figure out where to write the new Expr structure. */ + //if ( pzBuffer !=null) + //{ + // zAlloc = pzBuffer; + // staticFlag = EP_Static; + //} + //else + //{ + ///Expr zAlloc = new Expr();//sqlite3DbMallocRaw( db, dupedExprSize( p, flags ) ); + //} + // (Expr)zAlloc; + + //if ( pNew != null ) + { + /* Set nNewSize to the size allocated for the structure pointed to + ** by pNew. This is either EXPR_FULLSIZE, EXPR_REDUCEDSIZE or + ** EXPR_TOKENONLYSIZE. nToken is set to the number of bytes consumed + ** by the copy of the p->u.zToken string (if any). + */ + int nStructSize = dupedExprStructSize( p, flags ); + ////int nNewSize = nStructSize & 0xfff; + ////int nToken; + ////if ( !ExprHasProperty( p, EP_IntValue ) && !string.IsNullOrEmpty( p.u.zToken ) ) + ////{ + //// nToken = sqlite3Strlen30( p.u.zToken ); + ////} + ////else + ////{ + //// nToken = 0; + ////} + if ( isReduced ) + { + Debug.Assert( !ExprHasProperty( p, EP_Reduced ) ); + pNew = p.Copy( EXPR_TOKENONLYSIZE );////memcpy( zAlloc, p, nNewSize ); + } + else + { + ////int nSize = exprStructSize( p ); + ////memcpy( zAlloc, p, nSize ); + pNew = p.Copy(); + ////memset( &zAlloc[nSize], 0, EXPR_FULLSIZE - nSize ); + } - static ExprList sqlite3ExprListDup(sqlite3 db, ExprList p, int flags) { - ExprList pNew; - ExprList_item pItem; - ExprList_item pOldItem; - - if (p == null) - return null; - pNew = new ExprList();//sqlite3DbMallocRaw(db, sizeof(*pNew) ); - //if ( pNew == null ) return null; - pNew.iECursor = 0; - pNew.nExpr = pNew.nAlloc = p.nExpr; - pNew.a = new ExprList_item[p.nExpr];//sqlite3DbMallocRaw(db, p.nExpr*sizeof(p.a[0]) ); - //if( pItem==null ){ - // sqlite3DbFree(db,ref pNew); - // return null; - //} - //pOldItem = p.a; - for (int i = 0; i < p.nExpr; i++) {//pItem++, pOldItem++){ - pItem = pNew.a[i] = new ExprList_item(); - pOldItem = p.a[i]; - Expr pOldExpr = pOldItem.pExpr; - pItem.pExpr = sqlite3ExprDup(db, pOldExpr, flags); - pItem.zName = pOldItem.zName;// sqlite3DbStrDup(db, pOldItem.zName); - pItem.zSpan = pOldItem.zSpan;// sqlite3DbStrDup( db, pOldItem.zSpan ); - pItem.sortOrder = pOldItem.sortOrder; - pItem.done = 0; - pItem.iCol = pOldItem.iCol; - pItem.iAlias = pOldItem.iAlias; - } - return pNew; - } + /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */ + unchecked + { + pNew.flags &= (ushort)( ~( EP_Reduced | EP_TokenOnly | EP_Static ) ); + } + pNew.flags |= (ushort)( nStructSize & ( EP_Reduced | EP_TokenOnly ) ); + pNew.flags |= (ushort)staticFlag; - /* - ** If cursors, triggers, views and subqueries are all omitted from - ** the build, then none of the following routines, except for - ** sqlite3SelectDup(), can be called. sqlite3SelectDup() is sometimes - ** called with a NULL argument. - */ -#if !SQLITE_OMIT_VIEW || !SQLITE_OMIT_TRIGGER || !SQLITE_OMIT_SUBQUERY - static SrcList sqlite3SrcListDup(sqlite3 db, SrcList p, int flags) { - SrcList pNew; - int nByte; - if (p == null) - return null; - //nByte = sizeof(*p) + (p.nSrc>0 ? sizeof(p.a[0]) * (p.nSrc-1) : 0); - pNew = new SrcList();//sqlite3DbMallocRaw(db, nByte ); - if (p.nSrc > 0) - pNew.a = new SrcList_item[p.nSrc]; - if (pNew == null) - return null; - pNew.nSrc = pNew.nAlloc = p.nSrc; - for (int i = 0; i < p.nSrc; i++) { - pNew.a[i] = new SrcList_item(); - SrcList_item pNewItem = pNew.a[i]; - SrcList_item pOldItem = p.a[i]; - Table pTab; - pNewItem.zDatabase = pOldItem.zDatabase;// sqlite3DbStrDup(db, pOldItem.zDatabase); - pNewItem.zName = pOldItem.zName;// sqlite3DbStrDup(db, pOldItem.zName); - pNewItem.zAlias = pOldItem.zAlias;// sqlite3DbStrDup(db, pOldItem.zAlias); - pNewItem.jointype = pOldItem.jointype; - pNewItem.iCursor = pOldItem.iCursor; - pNewItem.isPopulated = pOldItem.isPopulated; - pNewItem.zIndex = pOldItem.zIndex;// sqlite3DbStrDup( db, pOldItem.zIndex ); - pNewItem.notIndexed = pOldItem.notIndexed; - pNewItem.pIndex = pOldItem.pIndex; - pTab = pNewItem.pTab = pOldItem.pTab; - if (pTab != null) { - pTab.nRef++; - } - pNewItem.pSelect = sqlite3SelectDup(db, pOldItem.pSelect, flags); - pNewItem.pOn = sqlite3ExprDup(db, pOldItem.pOn, flags); - pNewItem.pUsing = sqlite3IdListDup(db, pOldItem.pUsing); - pNewItem.colUsed = pOldItem.colUsed; + /* Copy the p->u.zToken string, if any. */ + ////if ( nToken != 0 ) + ////{ + //// string zToken;// = pNew.u.zToken = (char)&zAlloc[nNewSize]; + //// zToken = p.u.zToken.Substring( 0, nToken );// memcpy( zToken, p.u.zToken, nToken ); + ////} + + if ( 0 == ( ( p.flags | pNew.flags ) & EP_TokenOnly ) ) + { + /* Fill in the pNew.x.pSelect or pNew.x.pList member. */ + if ( ExprHasProperty( p, EP_xIsSelect ) ) + { + pNew.x.pSelect = sqlite3SelectDup( db, p.x.pSelect, isReduced ? 1 : 0 ); } - return pNew; - } + else + { + pNew.x.pList = sqlite3ExprListDup( db, p.x.pList, isReduced ? 1 : 0 ); + } + } - static IdList sqlite3IdListDup(sqlite3 db, IdList p) { - IdList pNew; - int i; - if (p == null) - return null; - pNew = new IdList();//sqlite3DbMallocRaw(db, sizeof(*pNew) ); - if (pNew == null) - return null; - pNew.nId = pNew.nAlloc = p.nId; - pNew.a = new IdList_item[p.nId];//sqlite3DbMallocRaw(db, p.nId*sizeof(p.a[0]) ); - if (pNew.a == null) { - sqlite3DbFree(db, ref pNew); - return null; + /* Fill in pNew.pLeft and pNew.pRight. */ + if ( ExprHasAnyProperty( pNew, EP_Reduced | EP_TokenOnly ) ) + { + //zAlloc += dupedExprNodeSize( p, flags ); + if ( ExprHasProperty( pNew, EP_Reduced ) ) + { + pNew.pLeft = exprDup( db, p.pLeft, EXPRDUP_REDUCE, ref pzBuffer ); + pNew.pRight = exprDup( db, p.pRight, EXPRDUP_REDUCE, ref pzBuffer ); } - for (i = 0; i < p.nId; i++) { - pNew.a[i] = new IdList_item(); - IdList_item pNewItem = pNew.a[i]; - IdList_item pOldItem = p.a[i]; - pNewItem.zName = pOldItem.zName;// sqlite3DbStrDup(db, pOldItem.zName); - pNewItem.idx = pOldItem.idx; + //if ( pzBuffer != null ) + //{ + // pzBuffer = zAlloc; + //} + } + else + { + pNew.flags2 = 0; + if ( !ExprHasAnyProperty( p, EP_TokenOnly ) ) + { + pNew.pLeft = sqlite3ExprDup( db, p.pLeft, 0 ); + pNew.pRight = sqlite3ExprDup( db, p.pRight, 0 ); } - return pNew; + } } + } + return pNew; + } + + /* + ** The following group of routines make deep copies of expressions, + ** expression lists, ID lists, and select statements. The copies can + ** be deleted (by being passed to their respective ...Delete() routines) + ** without effecting the originals. + ** + ** The expression list, ID, and source lists return by sqlite3ExprListDup(), + ** sqlite3IdListDup(), and sqlite3SrcListDup() can not be further expanded + ** by subsequent calls to sqlite*ListAppend() routines. + ** + ** Any tables that the SrcList might point to are not duplicated. + ** + ** The flags parameter contains a combination of the EXPRDUP_XXX flags. + ** If the EXPRDUP_REDUCE flag is set, then the structure returned is a + ** truncated version of the usual Expr structure that will be stored as + ** part of the in-memory representation of the database schema. + */ + static Expr sqlite3ExprDup( sqlite3 db, Expr p, int flags ) + { + Expr ExprDummy = null; + return exprDup( db, p, flags, ref ExprDummy ); + } + + static ExprList sqlite3ExprListDup( sqlite3 db, ExprList p, int flags ) + { + ExprList pNew; + ExprList_item pItem; + ExprList_item pOldItem; + + if ( p == null ) + return null; + pNew = new ExprList();//sqlite3DbMallocRaw(db, sizeof(*pNew) ); + //if ( pNew == null ) return null; + pNew.iECursor = 0; + pNew.nExpr = pNew.nAlloc = p.nExpr; + pNew.a = new ExprList_item[p.nExpr];//sqlite3DbMallocRaw(db, p.nExpr*sizeof(p.a[0]) ); + //if( pItem==null ){ + // sqlite3DbFree(db,ref pNew); + // return null; + //} + //pOldItem = p.a; + for (int i = 0; i < p.nExpr; i++ ) + {//pItem++, pOldItem++){ + pItem = pNew.a[i] = new ExprList_item(); + pOldItem = p.a[i]; + Expr pOldExpr = pOldItem.pExpr; + pItem.pExpr = sqlite3ExprDup( db, pOldExpr, flags ); + pItem.zName = pOldItem.zName;// sqlite3DbStrDup(db, pOldItem.zName); + pItem.zSpan = pOldItem.zSpan;// sqlite3DbStrDup( db, pOldItem.zSpan ); + pItem.sortOrder = pOldItem.sortOrder; + pItem.done = 0; + pItem.iCol = pOldItem.iCol; + pItem.iAlias = pOldItem.iAlias; + } + return pNew; + } - static Select sqlite3SelectDup(sqlite3 db, Select p, int flags) { - Select pNew; - if (p == null) - return null; - pNew = new Select();//sqlite3DbMallocRaw(db, sizeof(*p) ); - //if ( pNew == null ) return null; - pNew.pEList = sqlite3ExprListDup(db, p.pEList, flags); - pNew.pSrc = sqlite3SrcListDup(db, p.pSrc, flags); - pNew.pWhere = sqlite3ExprDup(db, p.pWhere, flags); - pNew.pGroupBy = sqlite3ExprListDup(db, p.pGroupBy, flags); - pNew.pHaving = sqlite3ExprDup(db, p.pHaving, flags); - pNew.pOrderBy = sqlite3ExprListDup(db, p.pOrderBy, flags); - pNew.op = p.op; - pNew.pPrior = sqlite3SelectDup(db, p.pPrior, flags); - pNew.pLimit = sqlite3ExprDup(db, p.pLimit, flags); - pNew.pOffset = sqlite3ExprDup(db, p.pOffset, flags); - pNew.iLimit = 0; - pNew.iOffset = 0; - pNew.selFlags = (u16)(p.selFlags & ~SF_UsesEphemeral); - pNew.pRightmost = null; - pNew.addrOpenEphm[0] = -1; - pNew.addrOpenEphm[1] = -1; - pNew.addrOpenEphm[2] = -1; - return pNew; + /* + ** If cursors, triggers, views and subqueries are all omitted from + ** the build, then none of the following routines, except for + ** sqlite3SelectDup(), can be called. sqlite3SelectDup() is sometimes + ** called with a NULL argument. + */ +#if !SQLITE_OMIT_VIEW || !SQLITE_OMIT_TRIGGER || !SQLITE_OMIT_SUBQUERY + static SrcList sqlite3SrcListDup( sqlite3 db, SrcList p, int flags ) + { + SrcList pNew; + int nByte; + if ( p == null ) + return null; + //nByte = sizeof(*p) + (p.nSrc>0 ? sizeof(p.a[0]) * (p.nSrc-1) : 0); + pNew = new SrcList();//sqlite3DbMallocRaw(db, nByte ); + if ( p.nSrc > 0 ) + pNew.a = new SrcList_item[p.nSrc]; + if ( pNew == null ) + return null; + pNew.nSrc = pNew.nAlloc = p.nSrc; + for (int i = 0; i < p.nSrc; i++ ) + { + pNew.a[i] = new SrcList_item(); + SrcList_item pNewItem = pNew.a[i]; + SrcList_item pOldItem = p.a[i]; + Table pTab; + pNewItem.zDatabase = pOldItem.zDatabase;// sqlite3DbStrDup(db, pOldItem.zDatabase); + pNewItem.zName = pOldItem.zName;// sqlite3DbStrDup(db, pOldItem.zName); + pNewItem.zAlias = pOldItem.zAlias;// sqlite3DbStrDup(db, pOldItem.zAlias); + pNewItem.jointype = pOldItem.jointype; + pNewItem.iCursor = pOldItem.iCursor; + pNewItem.isPopulated = pOldItem.isPopulated; + pNewItem.zIndex = pOldItem.zIndex;// sqlite3DbStrDup( db, pOldItem.zIndex ); + pNewItem.notIndexed = pOldItem.notIndexed; + pNewItem.pIndex = pOldItem.pIndex; + pTab = pNewItem.pTab = pOldItem.pTab; + if ( pTab != null ) + { + pTab.nRef++; } + pNewItem.pSelect = sqlite3SelectDup( db, pOldItem.pSelect, flags ); + pNewItem.pOn = sqlite3ExprDup( db, pOldItem.pOn, flags ); + pNewItem.pUsing = sqlite3IdListDup( db, pOldItem.pUsing ); + pNewItem.colUsed = pOldItem.colUsed; + } + return pNew; + } + + static IdList sqlite3IdListDup( sqlite3 db, IdList p ) + { + IdList pNew; + int i; + if ( p == null ) + return null; + pNew = new IdList();//sqlite3DbMallocRaw(db, sizeof(*pNew) ); + if ( pNew == null ) + return null; + pNew.nId = pNew.nAlloc = p.nId; + pNew.a = new IdList_item[p.nId];//sqlite3DbMallocRaw(db, p.nId*sizeof(p.a[0]) ); + if ( pNew.a == null ) + { + sqlite3DbFree( db, ref pNew ); + return null; + } + for ( i = 0; i < p.nId; i++ ) + { + pNew.a[i] = new IdList_item(); + IdList_item pNewItem = pNew.a[i]; + IdList_item pOldItem = p.a[i]; + pNewItem.zName = pOldItem.zName;// sqlite3DbStrDup(db, pOldItem.zName); + pNewItem.idx = pOldItem.idx; + } + return pNew; + } + + static Select sqlite3SelectDup( sqlite3 db, Select p, int flags ) + { + Select pNew; + if ( p == null ) + return null; + pNew = new Select();//sqlite3DbMallocRaw(db, sizeof(*p) ); + //if ( pNew == null ) return null; + pNew.pEList = sqlite3ExprListDup( db, p.pEList, flags ); + pNew.pSrc = sqlite3SrcListDup( db, p.pSrc, flags ); + pNew.pWhere = sqlite3ExprDup( db, p.pWhere, flags ); + pNew.pGroupBy = sqlite3ExprListDup( db, p.pGroupBy, flags ); + pNew.pHaving = sqlite3ExprDup( db, p.pHaving, flags ); + pNew.pOrderBy = sqlite3ExprListDup( db, p.pOrderBy, flags ); + pNew.op = p.op; + pNew.pPrior = sqlite3SelectDup( db, p.pPrior, flags ); + pNew.pLimit = sqlite3ExprDup( db, p.pLimit, flags ); + pNew.pOffset = sqlite3ExprDup( db, p.pOffset, flags ); + pNew.iLimit = 0; + pNew.iOffset = 0; + pNew.selFlags = (u16)( p.selFlags & ~SF_UsesEphemeral ); + pNew.pRightmost = null; + pNew.addrOpenEphm[0] = -1; + pNew.addrOpenEphm[1] = -1; + pNew.addrOpenEphm[2] = -1; + return pNew; + } #else Select sqlite3SelectDup(sqlite3 db, Select p, int flags){ Debug.Assert( p==null ); @@ -1065,1102 +1213,1212 @@ Select sqlite3SelectDup(sqlite3 db, Select p, int flags){ #endif - /* - ** Add a new element to the end of an expression list. If pList is - ** initially NULL, then create a new expression list. + /* +** Add a new element to the end of an expression list. If pList is +** initially NULL, then create a new expression list. +** +** If a memory allocation error occurs, the entire list is freed and +** NULL is returned. If non-NULL is returned, then it is guaranteed +** that the new entry was successfully appended. +*/ + // OVERLOADS, so I don't need to rewrite parse.c + static ExprList sqlite3ExprListAppend( Parse pParse, int null_2, Expr pExpr ) + { + return sqlite3ExprListAppend( pParse, null, pExpr ); + } + static ExprList sqlite3ExprListAppend( + Parse pParse, /* Parsing context */ + ExprList pList, /* List to which to append. Might be NULL */ + Expr pExpr /* Expression to be appended. Might be NULL */ + ) + { + ////sqlite3 db = pParse.db; + if ( pList == null ) + { + pList = new ExprList(); //sqlite3DbMallocZero(db, ExprList).Length; + //if ( pList == null ) + //{ + // goto no_mem; + //} + Debug.Assert( pList.nAlloc == 0 ); + } + if ( pList.nAlloc <= pList.nExpr ) + { + ExprList_item a; + int n = pList.nAlloc * 2 + 4; + //a = sqlite3DbRealloc(db, pList.a, n*sizeof(pList.a[0])); + //if( a==0 ){ + // goto no_mem; + //} + Array.Resize( ref pList.a, n );// = a; + pList.nAlloc = pList.a.Length;// sqlite3DbMallocSize(db, a)/sizeof(a[0]); + } + Debug.Assert( pList.a != null ); + if ( true ) + { + pList.a[pList.nExpr] = new ExprList_item(); + //ExprList_item pItem = pList.a[pList.nExpr++]; + //pItem = new ExprList_item();//memset(pItem, 0, sizeof(*pItem)); + //pItem.pExpr = pExpr; + pList.a[pList.nExpr++].pExpr = pExpr; + } + return pList; + + //no_mem: + // /* Avoid leaking memory if malloc has failed. */ + // sqlite3ExprDelete( db, ref pExpr ); + // sqlite3ExprListDelete( db, ref pList ); + // return null; + } + + /* + ** Set the ExprList.a[].zName element of the most recently added item + ** on the expression list. ** - ** If a memory allocation error occurs, the entire list is freed and - ** NULL is returned. If non-NULL is returned, then it is guaranteed - ** that the new entry was successfully appended. + ** pList might be NULL following an OOM error. But pName should never be + ** NULL. If a memory allocation fails, the pParse.db.mallocFailed flag + ** is set. */ - // OVERLOADS, so I don't need to rewrite parse.c - static ExprList sqlite3ExprListAppend(Parse pParse, int null_2, Expr pExpr) { - return sqlite3ExprListAppend(pParse, null, pExpr); - } - static ExprList sqlite3ExprListAppend( - Parse pParse, /* Parsing context */ - ExprList pList, /* List to which to append. Might be NULL */ - Expr pExpr /* Expression to be appended. Might be NULL */ - ) { - ////sqlite3 db = pParse.db; - if (pList == null) { - pList = new ExprList(); //sqlite3DbMallocZero(db, ExprList).Length; - //if ( pList == null ) - //{ - // goto no_mem; - //} - Debug.Assert(pList.nAlloc == 0); - } - if (pList.nAlloc <= pList.nExpr) { - ExprList_item a; - int n = pList.nAlloc * 2 + 4; - //a = sqlite3DbRealloc(db, pList.a, n*sizeof(pList.a[0])); - //if( a==0 ){ - // goto no_mem; - //} - Array.Resize(ref pList.a, n);// = a; - pList.nAlloc = pList.a.Length;// sqlite3DbMallocSize(db, a)/sizeof(a[0]); - } - Debug.Assert(pList.a != null); - if (true) { - pList.a[pList.nExpr] = new ExprList_item(); - //ExprList_item pItem = pList.a[pList.nExpr++]; - //pItem = new ExprList_item();//memset(pItem, 0, sizeof(*pItem)); - //pItem.pExpr = pExpr; - pList.a[pList.nExpr++].pExpr = pExpr; - } - return pList; + static void sqlite3ExprListSetName( + Parse pParse, /* Parsing context */ + ExprList pList, /* List to which to add the span. */ + Token pName, /* Name to be added */ + int dequote /* True to cause the name to be dequoted */ + ) + { + Debug.Assert( pList != null /* || pParse.db.mallocFailed != 0 */ ); + if ( pList != null ) + { + ExprList_item pItem; + Debug.Assert( pList.nExpr > 0 ); + pItem = pList.a[pList.nExpr - 1]; + Debug.Assert( pItem.zName == null ); + pItem.zName = pName.z.Substring( 0, pName.n );//sqlite3DbStrNDup(pParse.db, pName.z, pName.n); + if ( dequote != 0 && !string.IsNullOrEmpty( pItem.zName ) ) + sqlite3Dequote( ref pItem.zName ); + } + } - //no_mem: - // /* Avoid leaking memory if malloc has failed. */ - // sqlite3ExprDelete( db, ref pExpr ); - // sqlite3ExprListDelete( db, ref pList ); - // return null; - } + /* + ** Set the ExprList.a[].zSpan element of the most recently added item + ** on the expression list. + ** + ** pList might be NULL following an OOM error. But pSpan should never be + ** NULL. If a memory allocation fails, the pParse.db.mallocFailed flag + ** is set. + */ + static void sqlite3ExprListSetSpan( + Parse pParse, /* Parsing context */ + ExprList pList, /* List to which to add the span. */ + ExprSpan pSpan /* The span to be added */ + ) + { + sqlite3 db = pParse.db; + Debug.Assert( pList != null /*|| db.mallocFailed != 0 */ ); + if ( pList != null ) + { + ExprList_item pItem = pList.a[pList.nExpr - 1]; + Debug.Assert( pList.nExpr > 0 ); + Debug.Assert( /* db.mallocFailed != 0 || */ pItem.pExpr == pSpan.pExpr ); + sqlite3DbFree( db, ref pItem.zSpan ); + pItem.zSpan = pSpan.zStart.Substring( 0, pSpan.zStart.Length <= pSpan.zEnd.Length ? pSpan.zStart.Length : pSpan.zStart.Length - pSpan.zEnd.Length );// sqlite3DbStrNDup( db, pSpan.zStart, + //(int)( pSpan.zEnd- pSpan.zStart) ); + } + } - /* - ** Set the ExprList.a[].zName element of the most recently added item - ** on the expression list. - ** - ** pList might be NULL following an OOM error. But pName should never be - ** NULL. If a memory allocation fails, the pParse.db.mallocFailed flag - ** is set. - */ - static void sqlite3ExprListSetName( - Parse pParse, /* Parsing context */ - ExprList pList, /* List to which to add the span. */ - Token pName, /* Name to be added */ - int dequote /* True to cause the name to be dequoted */ - ) { - Debug.Assert(pList != null /* || pParse.db.mallocFailed != 0 */ ); - if (pList != null) { - ExprList_item pItem; - Debug.Assert(pList.nExpr > 0); - pItem = pList.a[pList.nExpr - 1]; - Debug.Assert(pItem.zName == null); - pItem.zName = pName.z.Substring(0, pName.n);//sqlite3DbStrNDup(pParse.db, pName.z, pName.n); - if (dequote != 0 && !string.IsNullOrEmpty(pItem.zName)) - sqlite3Dequote(ref pItem.zName); - } - } + /* + ** If the expression list pEList contains more than iLimit elements, + ** leave an error message in pParse. + */ + static void sqlite3ExprListCheckLength( + Parse pParse, + ExprList pEList, + string zObject + ) + { + int mx = pParse.db.aLimit[SQLITE_LIMIT_COLUMN]; + testcase( pEList != null && pEList.nExpr == mx ); + testcase( pEList != null && pEList.nExpr == mx + 1 ); + if ( pEList != null && pEList.nExpr > mx ) + { + sqlite3ErrorMsg( pParse, "too many columns in %s", zObject ); + } + } - /* - ** Set the ExprList.a[].zSpan element of the most recently added item - ** on the expression list. - ** - ** pList might be NULL following an OOM error. But pSpan should never be - ** NULL. If a memory allocation fails, the pParse.db.mallocFailed flag - ** is set. - */ - static void sqlite3ExprListSetSpan( - Parse pParse, /* Parsing context */ - ExprList pList, /* List to which to add the span. */ - ExprSpan pSpan /* The span to be added */ - ) { - sqlite3 db = pParse.db; - Debug.Assert(pList != null /*|| db.mallocFailed != 0 */ ); - if (pList != null) { - ExprList_item pItem = pList.a[pList.nExpr - 1]; - Debug.Assert(pList.nExpr > 0); - Debug.Assert( /* db.mallocFailed != 0 || */ pItem.pExpr == pSpan.pExpr); - sqlite3DbFree(db, ref pItem.zSpan); - pItem.zSpan = pSpan.zStart.Substring(0, pSpan.zStart.Length <= pSpan.zEnd.Length ? pSpan.zStart.Length : pSpan.zStart.Length - pSpan.zEnd.Length);// sqlite3DbStrNDup( db, pSpan.zStart, - //(int)( pSpan.zEnd- pSpan.zStart) ); - } - } - /* - ** If the expression list pEList contains more than iLimit elements, - ** leave an error message in pParse. - */ - static void sqlite3ExprListCheckLength( - Parse pParse, - ExprList pEList, - string zObject - ) { - int mx = pParse.db.aLimit[SQLITE_LIMIT_COLUMN]; - testcase(pEList != null && pEList.nExpr == mx); - testcase(pEList != null && pEList.nExpr == mx + 1); - if (pEList != null && pEList.nExpr > mx) { - sqlite3ErrorMsg(pParse, "too many columns in %s", zObject); - } + /* + ** Delete an entire expression list. + */ + static void sqlite3ExprListDelete( sqlite3 db, ref ExprList pList ) + { + int i; + ExprList_item pItem; + if ( pList == null ) + return; + Debug.Assert( pList.a != null || ( pList.nExpr == 0 && pList.nAlloc == 0 ) ); + Debug.Assert( pList.nExpr <= pList.nAlloc ); + for ( i = 0; i < pList.nExpr; i++ ) + { + if ( ( pItem = pList.a[i] ) != null ) + { + sqlite3ExprDelete( db, ref pItem.pExpr ); + sqlite3DbFree( db, ref pItem.zName ); + sqlite3DbFree( db, ref pItem.zSpan ); } + } + sqlite3DbFree( db, ref pList.a ); + sqlite3DbFree( db, ref pList ); + } + /* + ** These routines are Walker callbacks. Walker.u.pi is a pointer + ** to an integer. These routines are checking an expression to see + ** if it is a constant. Set *Walker.u.pi to 0 if the expression is + ** not constant. + ** + ** These callback routines are used to implement the following: + ** + ** sqlite3ExprIsConstant() + ** sqlite3ExprIsConstantNotJoin() + ** sqlite3ExprIsConstantOrFunction() + ** + */ + static int exprNodeIsConstant( Walker pWalker, ref 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 && ExprHasAnyProperty( pExpr, EP_FromJoin ) ) + { + pWalker.u.i = 0; + return WRC_Abort; + } + + switch ( pExpr.op ) + { + /* Consider functions to be constant if all their arguments are constant + ** and pWalker.u.i==2 */ + case TK_FUNCTION: + if ( ( pWalker.u.i ) == 2 ) + return 0; + goto case TK_ID; + /* Fall through */ + case TK_ID: + case TK_COLUMN: + case TK_AGG_FUNCTION: + case TK_AGG_COLUMN: + testcase( pExpr.op == TK_ID ); + testcase( pExpr.op == TK_COLUMN ); + testcase( pExpr.op == TK_AGG_FUNCTION ); + testcase( pExpr.op == TK_AGG_COLUMN ); + pWalker.u.i = 0; + return WRC_Abort; + default: + testcase( pExpr.op == TK_SELECT ); /* selectNodeIsConstant will disallow */ + testcase( pExpr.op == TK_EXISTS ); /* selectNodeIsConstant will disallow */ + return WRC_Continue; + } + } - /* - ** Delete an entire expression list. - */ - static void sqlite3ExprListDelete(sqlite3 db, ref ExprList pList) { - int i; - ExprList_item pItem; - if (pList == null) - return; - Debug.Assert(pList.a != null || (pList.nExpr == 0 && pList.nAlloc == 0)); - Debug.Assert(pList.nExpr <= pList.nAlloc); - for (i = 0; i < pList.nExpr; i++) { - if ((pItem = pList.a[i]) != null) { - sqlite3ExprDelete(db, ref pItem.pExpr); - sqlite3DbFree(db, ref pItem.zName); - sqlite3DbFree(db, ref pItem.zSpan); - } - } - sqlite3DbFree(db, ref pList.a); - sqlite3DbFree(db, ref pList); - } + static int selectNodeIsConstant( Walker pWalker, Select NotUsed ) + { + UNUSED_PARAMETER( NotUsed ); + pWalker.u.i = 0; + return WRC_Abort; + } + static int exprIsConst( Expr p, int initFlag ) + { + Walker w = new Walker(); + w.u.i = initFlag; + w.xExprCallback = exprNodeIsConstant; + w.xSelectCallback = selectNodeIsConstant; + sqlite3WalkExpr( w, ref p ); + return w.u.i; + } - /* - ** These routines are Walker callbacks. Walker.u.pi is a pointer - ** to an integer. These routines are checking an expression to see - ** if it is a constant. Set *Walker.u.pi to 0 if the expression is - ** not constant. - ** - ** These callback routines are used to implement the following: - ** - ** sqlite3ExprIsConstant() - ** sqlite3ExprIsConstantNotJoin() - ** sqlite3ExprIsConstantOrFunction() - ** - */ - static int exprNodeIsConstant(Walker pWalker, ref 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 && ExprHasAnyProperty(pExpr, EP_FromJoin)) { - pWalker.u.i = 0; - return WRC_Abort; - } + /* + ** Walk an expression tree. Return 1 if the expression is constant + ** and 0 if it involves variables or function calls. + ** + ** For the purposes of this function, a double-quoted string (ex: "abc") + ** is considered a variable but a single-quoted string (ex: 'abc') is + ** a constant. + */ + static int sqlite3ExprIsConstant( Expr p ) + { + return exprIsConst( p, 1 ); + } + + /* + ** Walk an expression tree. Return 1 if the expression is constant + ** that does no originate from the ON or USING clauses of a join. + ** Return 0 if it involves variables or function calls or terms from + ** an ON or USING clause. + */ + static int sqlite3ExprIsConstantNotJoin( Expr p ) + { + return exprIsConst( p, 3 ); + } - switch (pExpr.op) { - /* Consider functions to be constant if all their arguments are constant - ** and pWalker.u.i==2 */ - case TK_FUNCTION: - if ((pWalker.u.i) == 2) - return 0; - goto case TK_ID; - /* Fall through */ - case TK_ID: - case TK_COLUMN: - case TK_AGG_FUNCTION: - case TK_AGG_COLUMN: - testcase(pExpr.op == TK_ID); - testcase(pExpr.op == TK_COLUMN); - testcase(pExpr.op == TK_AGG_FUNCTION); - testcase(pExpr.op == TK_AGG_COLUMN); - pWalker.u.i = 0; - return WRC_Abort; - default: - testcase(pExpr.op == TK_SELECT); /* selectNodeIsConstant will disallow */ - testcase(pExpr.op == TK_EXISTS); /* selectNodeIsConstant will disallow */ - return WRC_Continue; + /* + ** Walk an expression tree. Return 1 if the expression is constant + ** or a function call with constant arguments. Return and 0 if there + ** are any variables. + ** + ** For the purposes of this function, a double-quoted string (ex: "abc") + ** is considered a variable but a single-quoted string (ex: 'abc') is + ** a constant. + */ + static int sqlite3ExprIsConstantOrFunction( Expr p ) + { + return exprIsConst( p, 2 ); + } + + /* + ** If the expression p codes a constant integer that is small enough + ** to fit in a 32-bit integer, return 1 and put the value of the integer + ** in pValue. If the expression is not an integer or if it is too big + ** to fit in a signed 32-bit integer, return 0 and leave pValue unchanged. + */ + static int sqlite3ExprIsInteger( Expr p, ref int pValue ) + { + int rc = 0; + + /* If an expression is an integer literal that fits in a signed 32-bit + ** integer, then the EP_IntValue flag will have already been set */ + Debug.Assert( p.op != TK_INTEGER || ( p.flags & EP_IntValue ) != 0 + || !sqlite3GetInt32( p.u.zToken, ref rc ) ); + + if ( ( p.flags & EP_IntValue ) != 0 ) + { + pValue = (int)p.u.iValue; + return 1; + } + switch ( p.op ) + { + case TK_UPLUS: + { + rc = sqlite3ExprIsInteger( p.pLeft, ref pValue ); + break; + } + case TK_UMINUS: + { + int v = 0; + if ( sqlite3ExprIsInteger( p.pLeft, ref v ) != 0 ) + { + pValue = -v; + rc = 1; } - } + break; + } + default: + break; + } + return rc; + } - static int selectNodeIsConstant(Walker pWalker, Select NotUsed) { - UNUSED_PARAMETER(NotUsed); - pWalker.u.i = 0; - return WRC_Abort; - } - static int exprIsConst(Expr p, int initFlag) { - Walker w = new Walker(); - w.u.i = initFlag; - w.xExprCallback = exprNodeIsConstant; - w.xSelectCallback = selectNodeIsConstant; - sqlite3WalkExpr(w, ref p); - return w.u.i; - } + /* + ** Return FALSE if there is no chance that the expression can be NULL. + ** + ** If the expression might be NULL or if the expression is too complex + ** to tell return TRUE. + ** + ** This routine is used as an optimization, to skip OP_IsNull opcodes + ** when we know that a value cannot be NULL. Hence, a false positive + ** (returning TRUE when in fact the expression can never be NULL) might + ** be a small performance hit but is otherwise harmless. On the other + ** hand, a false negative (returning FALSE when the result could be NULL) + ** will likely result in an incorrect answer. So when in doubt, return + ** TRUE. + */ + static int sqlite3ExprCanBeNull( Expr p ) + { + u8 op; + while ( p.op == TK_UPLUS || p.op == TK_UMINUS ) + { + p = p.pLeft; + } + op = p.op; + if ( op == TK_REGISTER ) + op = p.op2; + switch ( op ) + { + case TK_INTEGER: + case TK_STRING: + case TK_FLOAT: + case TK_BLOB: + return 0; + default: + return 1; + } + } - /* - ** Walk an expression tree. Return 1 if the expression is constant - ** and 0 if it involves variables or function calls. - ** - ** For the purposes of this function, a double-quoted string (ex: "abc") - ** is considered a variable but a single-quoted string (ex: 'abc') is - ** a constant. - */ - static int sqlite3ExprIsConstant(Expr p) { - return exprIsConst(p, 1); - } + /* + ** Generate an OP_IsNull instruction that tests register iReg and jumps + ** to location iDest if the value in iReg is NULL. The value in iReg + ** was computed by pExpr. If we can look at pExpr at compile-time and + ** determine that it can never generate a NULL, then the OP_IsNull operation + ** can be omitted. + */ + static void sqlite3ExprCodeIsNullJump( + Vdbe v, /* The VDBE under construction */ + Expr pExpr, /* Only generate OP_IsNull if this expr can be NULL */ + int iReg, /* Test the value in this register for NULL */ + int iDest /* Jump here if the value is null */ + ) + { + if ( sqlite3ExprCanBeNull( pExpr ) != 0 ) + { + sqlite3VdbeAddOp2( v, OP_IsNull, iReg, iDest ); + } + } - /* - ** Walk an expression tree. Return 1 if the expression is constant - ** that does no originate from the ON or USING clauses of a join. - ** Return 0 if it involves variables or function calls or terms from - ** an ON or USING clause. - */ - static int sqlite3ExprIsConstantNotJoin(Expr p) { - return exprIsConst(p, 3); - } + /* + ** Return TRUE if the given expression is a constant which would be + ** unchanged by OP_Affinity with the affinity given in the second + ** argument. + ** + ** This routine is used to determine if the OP_Affinity operation + ** can be omitted. When in doubt return FALSE. A false negative + ** is harmless. A false positive, however, can result in the wrong + ** answer. + */ + static int sqlite3ExprNeedsNoAffinityChange( Expr p, char aff ) + { + u8 op; + if ( aff == SQLITE_AFF_NONE ) + return 1; + while ( p.op == TK_UPLUS || p.op == TK_UMINUS ) + { + p = p.pLeft; + } + op = p.op; + if ( op == TK_REGISTER ) + op = p.op2; + switch ( op ) + { + case TK_INTEGER: + { + return ( aff == SQLITE_AFF_INTEGER || aff == SQLITE_AFF_NUMERIC ) ? 1 : 0; + } + case TK_FLOAT: + { + return ( aff == SQLITE_AFF_REAL || aff == SQLITE_AFF_NUMERIC ) ? 1 : 0; + } + case TK_STRING: + { + return ( aff == SQLITE_AFF_TEXT ) ? 1 : 0; + } + case TK_BLOB: + { + return 1; + } + case TK_COLUMN: + { + Debug.Assert( p.iTable >= 0 ); /* p cannot be part of a CHECK constraint */ + return ( p.iColumn < 0 + && ( aff == SQLITE_AFF_INTEGER || aff == SQLITE_AFF_NUMERIC ) ) ? 1 : 0; + } + default: + { + return 0; + } + } + } - /* - ** Walk an expression tree. Return 1 if the expression is constant - ** or a function call with constant arguments. Return and 0 if there - ** are any variables. - ** - ** For the purposes of this function, a double-quoted string (ex: "abc") - ** is considered a variable but a single-quoted string (ex: 'abc') is - ** a constant. - */ - static int sqlite3ExprIsConstantOrFunction(Expr p) { - return exprIsConst(p, 2); - } + /* + ** Return TRUE if the given string is a row-id column name. + */ + static bool sqlite3IsRowid( string z ) + { + if ( z.Equals( "_ROWID_", StringComparison.OrdinalIgnoreCase ) ) + return true; + if ( z.Equals( "ROWID", StringComparison.OrdinalIgnoreCase ) ) + return true; + if ( z.Equals( "OID", StringComparison.OrdinalIgnoreCase ) ) + return true; + return false; + } - /* - ** If the expression p codes a constant integer that is small enough - ** to fit in a 32-bit integer, return 1 and put the value of the integer - ** in pValue. If the expression is not an integer or if it is too big - ** to fit in a signed 32-bit integer, return 0 and leave pValue unchanged. + + /* + ** Return true if we are able to the IN operator optimization on a + ** query of the form + ** + ** x IN (SELECT ...) + ** + ** Where the SELECT... clause is as specified by the parameter to this + ** routine. + ** + ** The Select object passed in has already been preprocessed and no + ** errors have been found. + */ +#if !SQLITE_OMIT_SUBQUERY + static int isCandidateForInOpt( Select p ) + { + SrcList pSrc; + ExprList pEList; + Table pTab; + if ( p == null ) + return 0; /* right-hand side of IN is SELECT */ + if ( p.pPrior != null ) + return 0; /* Not a compound SELECT */ + if ( ( p.selFlags & ( SF_Distinct | SF_Aggregate ) ) != 0 ) + { + testcase( ( p.selFlags & ( SF_Distinct | SF_Aggregate ) ) == SF_Distinct ); + testcase( ( p.selFlags & ( SF_Distinct | SF_Aggregate ) ) == SF_Aggregate ); + return 0; /* No DISTINCT keyword and no aggregate functions */ + } + Debug.Assert( p.pGroupBy == null ); /* Has no GROUP BY clause */ + if ( p.pLimit != null ) + return 0; /* Has no LIMIT clause */ + Debug.Assert( p.pOffset == null ); /* No LIMIT means no OFFSET */ + + if ( p.pWhere != null ) + return 0; /* Has no WHERE clause */ + pSrc = p.pSrc; + Debug.Assert( pSrc != null ); + if ( pSrc.nSrc != 1 ) + return 0; /* Single term in FROM clause */ + if ( pSrc.a[0].pSelect != null ) + return 0; /* FROM is not a subquery or view */ + pTab = pSrc.a[0].pTab; + if ( NEVER( pTab == null ) ) + return 0; + Debug.Assert( pTab.pSelect == null ); /* FROM clause is not a view */ + if ( IsVirtual( pTab ) ) + return 0; /* FROM clause not a virtual table */ + pEList = p.pEList; + if ( pEList.nExpr != 1 ) + return 0; /* One column in the result set */ + if ( pEList.a[0].pExpr.op != TK_COLUMN ) + return 0; /* Result is a column */ + return 1; + } +#endif //* SQLITE_OMIT_SUBQUERY */ + + /* +** This function is used by the implementation of the IN (...) operator. +** It's job is to find or create a b-tree structure that may be used +** either to test for membership of the (...) set or to iterate through +** its members, skipping duplicates. +** +** The index of the cursor opened on the b-tree (database table, database index +** or ephermal table) is stored in pX->iTable before this function returns. +** The returned value of this function indicates the b-tree type, as follows: +** +** IN_INDEX_ROWID - The cursor was opened on a database table. +** IN_INDEX_INDEX - The cursor was opened on a database index. +** IN_INDEX_EPH - The cursor was opened on a specially created and +** populated epheremal table. +** +** An existing b-tree may only be used if the SELECT is of the simple +** form: +** +** SELECT FROM +** +** If the prNotFound parameter is 0, then the b-tree will be used to iterate +** through the set members, skipping any duplicates. In this case an +** epheremal table must be used unless the selected is guaranteed +** to be unique - either because it is an INTEGER PRIMARY KEY or it +** has a UNIQUE constraint or UNIQUE index. +** +** If the prNotFound parameter is not 0, then the b-tree will be used +** for fast set membership tests. In this case an epheremal table must +** be used unless is an INTEGER PRIMARY KEY or an index can +** be found with as its left-most column. +** +** When the b-tree is being used for membership tests, the calling function +** needs to know whether or not the structure contains an SQL NULL +** value in order to correctly evaluate expressions like "X IN (Y, Z)". +** If there is any chance that the (...) might contain a NULL value at +** runtime, then a register is allocated and the register number written +** to *prNotFound. If there is no chance that the (...) contains a +** NULL value, then *prNotFound is left unchanged. +** +** If a register is allocated and its location stored in *prNotFound, then +** its initial value is NULL. If the (...) does not remain constant +** for the duration of the query (i.e. the SELECT within the (...) +** is a correlated subquery) then the value of the allocated register is +** reset to NULL each time the subquery is rerun. This allows the +** caller to use vdbe code equivalent to the following: +** +** if( register==NULL ){ +** has_null = +** register = 1 +** } +** +** in order to avoid running the +** test more often than is necessary. +*/ +#if !SQLITE_OMIT_SUBQUERY + static int sqlite3FindInIndex( Parse pParse, Expr pX, ref int prNotFound ) + { + Select p; /* SELECT to the right of IN operator */ + int eType = 0; /* Type of RHS table. IN_INDEX_* */ + int iTab = pParse.nTab++; /* Cursor of the RHS table */ + bool mustBeUnique = ( prNotFound != 0 ); /* True if RHS must be unique */ + + Debug.Assert( pX.op == TK_IN ); + + /* Check to see if an existing table or index can be used to + ** satisfy the query. This is preferable to generating a new + ** ephemeral table. + */ + p = ( ExprHasProperty( pX, EP_xIsSelect ) ? pX.x.pSelect : null ); + if ( ALWAYS( pParse.nErr == 0 ) && isCandidateForInOpt( p ) != 0 ) + { + sqlite3 db = pParse.db; /* Database connection */ + Expr pExpr = p.pEList.a[0].pExpr; /* Expression */ + int iCol = pExpr.iColumn; /* Index of column */ + Vdbe v = sqlite3GetVdbe( pParse ); /* Virtual machine being coded */ + Table pTab = p.pSrc.a[0].pTab; /* Table
. */ + int iDb; /* Database idx for pTab */ + + /* Code an OP_VerifyCookie and OP_TableLock for
. */ + iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); + sqlite3CodeVerifySchema( pParse, iDb ); + sqlite3TableLock( pParse, iDb, pTab.tnum, 0, pTab.zName ); + + /* This function is only called from two places. In both cases the vdbe + ** has already been allocated. So assume sqlite3GetVdbe() is always + ** successful here. */ - static int sqlite3ExprIsInteger(Expr p, ref int pValue) { - int rc = 0; + Debug.Assert( v != null ); + if ( iCol < 0 ) + { + int iMem = ++pParse.nMem; + int iAddr; - /* If an expression is an integer literal that fits in a signed 32-bit - ** integer, then the EP_IntValue flag will have already been set */ - Debug.Assert(p.op != TK_INTEGER || (p.flags & EP_IntValue) != 0 - || !sqlite3GetInt32(p.u.zToken, ref rc)); + iAddr = sqlite3VdbeAddOp1( v, OP_If, iMem ); + sqlite3VdbeAddOp2( v, OP_Integer, 1, iMem ); - if ((p.flags & EP_IntValue) != 0) { - pValue = (int)p.u.iValue; - return 1; - } - switch (p.op) { - case TK_UPLUS: { - rc = sqlite3ExprIsInteger(p.pLeft, ref pValue); - break; - } - case TK_UMINUS: { - int v = 0; - if (sqlite3ExprIsInteger(p.pLeft, ref v) != 0) { - pValue = -v; - rc = 1; - } - break; - } - default: - break; - } - return rc; - } + sqlite3OpenTable( pParse, iTab, iDb, pTab, OP_OpenRead ); + eType = IN_INDEX_ROWID; - /* - ** Return FALSE if there is no chance that the expression can be NULL. - ** - ** If the expression might be NULL or if the expression is too complex - ** to tell return TRUE. - ** - ** This routine is used as an optimization, to skip OP_IsNull opcodes - ** when we know that a value cannot be NULL. Hence, a false positive - ** (returning TRUE when in fact the expression can never be NULL) might - ** be a small performance hit but is otherwise harmless. On the other - ** hand, a false negative (returning FALSE when the result could be NULL) - ** will likely result in an incorrect answer. So when in doubt, return - ** TRUE. - */ - static int sqlite3ExprCanBeNull(Expr p) { - u8 op; - while (p.op == TK_UPLUS || p.op == TK_UMINUS) { - p = p.pLeft; - } - op = p.op; - if (op == TK_REGISTER) - op = p.op2; - switch (op) { - case TK_INTEGER: - case TK_STRING: - case TK_FLOAT: - case TK_BLOB: - return 0; - default: - return 1; - } + sqlite3VdbeJumpHere( v, iAddr ); } + else + { + Index pIdx; /* Iterator variable */ + /* The collation sequence used by the comparison. If an index is to + ** be used in place of a temp.table, it must be ordered according + ** to this collation sequence. */ + CollSeq pReq = sqlite3BinaryCompareCollSeq( pParse, pX.pLeft, pExpr ); + + /* Check that the affinity that will be used to perform the + ** comparison is the same as the affinity of the column. If + ** it is not, it is not possible to use any index. + */ + char aff = comparisonAffinity( pX ); + bool affinity_ok = ( pTab.aCol[iCol].affinity == aff || aff == SQLITE_AFF_NONE ); + + for ( pIdx = pTab.pIndex; pIdx != null && eType == 0 && affinity_ok; pIdx = pIdx.pNext ) + { + if ( ( pIdx.aiColumn[0] == iCol ) + && ( sqlite3FindCollSeq( db, ENC( db ), pIdx.azColl[0], 0 ) == pReq ) + && ( mustBeUnique == false || ( pIdx.nColumn == 1 && pIdx.onError != OE_None ) ) + ) + { + int iMem = ++pParse.nMem; + int iAddr; + KeyInfo pKey; - /* - ** Generate an OP_IsNull instruction that tests register iReg and jumps - ** to location iDest if the value in iReg is NULL. The value in iReg - ** was computed by pExpr. If we can look at pExpr at compile-time and - ** determine that it can never generate a NULL, then the OP_IsNull operation - ** can be omitted. - */ - static void sqlite3ExprCodeIsNullJump( - Vdbe v, /* The VDBE under construction */ - Expr pExpr, /* Only generate OP_IsNull if this expr can be NULL */ - int iReg, /* Test the value in this register for NULL */ - int iDest /* Jump here if the value is null */ - ) { - if (sqlite3ExprCanBeNull(pExpr) != 0) { - sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iDest); - } - } + pKey = sqlite3IndexKeyinfo( pParse, pIdx ); - /* - ** Return TRUE if the given expression is a constant which would be - ** unchanged by OP_Affinity with the affinity given in the second - ** argument. - ** - ** This routine is used to determine if the OP_Affinity operation - ** can be omitted. When in doubt return FALSE. A false negative - ** is harmless. A false positive, however, can result in the wrong - ** answer. - */ - static int sqlite3ExprNeedsNoAffinityChange(Expr p, char aff) { - u8 op; - if (aff == SQLITE_AFF_NONE) - return 1; - while (p.op == TK_UPLUS || p.op == TK_UMINUS) { - p = p.pLeft; - } - op = p.op; - if (op == TK_REGISTER) - op = p.op2; - switch (op) { - case TK_INTEGER: { - return (aff == SQLITE_AFF_INTEGER || aff == SQLITE_AFF_NUMERIC) ? 1 : 0; - } - case TK_FLOAT: { - return (aff == SQLITE_AFF_REAL || aff == SQLITE_AFF_NUMERIC) ? 1 : 0; - } - case TK_STRING: { - return (aff == SQLITE_AFF_TEXT) ? 1 : 0; - } - case TK_BLOB: { - return 1; - } - case TK_COLUMN: { - Debug.Assert(p.iTable >= 0); /* p cannot be part of a CHECK constraint */ - return (p.iColumn < 0 - && (aff == SQLITE_AFF_INTEGER || aff == SQLITE_AFF_NUMERIC)) ? 1 : 0; - } - default: { - return 0; - } + iAddr = sqlite3VdbeAddOp1( v, OP_If, iMem ); + sqlite3VdbeAddOp2( v, OP_Integer, 1, iMem ); + + sqlite3VdbeAddOp4( v, OP_OpenRead, iTab, pIdx.tnum, iDb, + pKey, P4_KEYINFO_HANDOFF ); +#if SQLITE_DEBUG + VdbeComment( v, "%s", pIdx.zName ); +#endif + eType = IN_INDEX_INDEX; + + sqlite3VdbeJumpHere( v, iAddr ); + if ( //prNotFound != null && -- always exists under C# + pTab.aCol[iCol].notNull == 0 ) + { + prNotFound = ++pParse.nMem; + } } + } } + } - /* - ** Return TRUE if the given string is a row-id column name. + if ( eType == 0 ) + { + /* Could not found an existing table or index to use as the RHS b-tree. + ** We will have to generate an ephemeral table to do the job. */ - static bool sqlite3IsRowid(string z) { - if (z.Equals("_ROWID_", StringComparison.OrdinalIgnoreCase)) - return true; - if (z.Equals("ROWID", StringComparison.OrdinalIgnoreCase)) - return true; - if (z.Equals("OID", StringComparison.OrdinalIgnoreCase)) - return true; - return false; + double savedNQueryLoop = pParse.nQueryLoop; + int rMayHaveNull = 0; + eType = IN_INDEX_EPH; + if ( prNotFound != -1 ) // Klude to show prNotFound not available + { + prNotFound = rMayHaveNull = ++pParse.nMem; } + else + { + testcase( pParse.nQueryLoop > (double)1 ); + pParse.nQueryLoop = (double)1; + if ( pX.pLeft.iColumn < 0 && !ExprHasAnyProperty( pX, EP_xIsSelect ) ) + { + eType = IN_INDEX_ROWID; + } + } + sqlite3CodeSubselect( pParse, pX, rMayHaveNull, eType == IN_INDEX_ROWID ); + pParse.nQueryLoop = savedNQueryLoop; + } + else + { + pX.iTable = iTab; + } + return eType; + } +#endif - - /* - ** Return true if we are able to the IN operator optimization on a - ** query of the form - ** - ** x IN (SELECT ...) - ** - ** Where the SELECT... clause is as specified by the parameter to this - ** routine. - ** - ** The Select object passed in has already been preprocessed and no - ** errors have been found. - */ + /* +** Generate code for scalar subqueries used as a subquery expression, EXISTS, +** or IN operators. Examples: +** +** (SELECT a FROM b) -- subquery +** EXISTS (SELECT a FROM b) -- EXISTS subquery +** x IN (4,5,11) -- IN operator with list on right-hand side +** x IN (SELECT a FROM b) -- IN operator with subquery on the right +** +** The pExpr parameter describes the expression that contains the IN +** operator or subquery. +** +** If parameter isRowid is non-zero, then expression pExpr is guaranteed +** to be of the form " IN (?, ?, ?)", where is a reference +** to some integer key column of a table B-Tree. In this case, use an +** intkey B-Tree to store the set of IN(...) values instead of the usual +** (slower) variable length keys B-Tree. +** +** If rMayHaveNull is non-zero, that means that the operation is an IN +** (not a SELECT or EXISTS) and that the RHS might contains NULLs. +** Furthermore, the IN is in a WHERE clause and that we really want +** to iterate over the RHS of the IN operator in order to quickly locate +** all corresponding LHS elements. All this routine does is initialize +** the register given by rMayHaveNull to NULL. Calling routines will take +** care of changing this register value to non-NULL if the RHS is NULL-free. +** +** If rMayHaveNull is zero, that means that the subquery is being used +** for membership testing only. There is no need to initialize any +** registers to indicate the presense or absence of NULLs on the RHS. +** +** For a SELECT or EXISTS operator, return the register that holds the +** result. For IN operators or if an error occurs, the return value is 0. +*/ #if !SQLITE_OMIT_SUBQUERY - static int isCandidateForInOpt(Select p) { - SrcList pSrc; - ExprList pEList; - Table pTab; - if (p == null) - return 0; /* right-hand side of IN is SELECT */ - if (p.pPrior != null) - return 0; /* Not a compound SELECT */ - if ((p.selFlags & (SF_Distinct | SF_Aggregate)) != 0) { - testcase((p.selFlags & (SF_Distinct | SF_Aggregate)) == SF_Distinct); - testcase((p.selFlags & (SF_Distinct | SF_Aggregate)) == SF_Aggregate); - return 0; /* No DISTINCT keyword and no aggregate functions */ - } - Debug.Assert(p.pGroupBy == null); /* Has no GROUP BY clause */ - if (p.pLimit != null) - return 0; /* Has no LIMIT clause */ - Debug.Assert(p.pOffset == null); /* No LIMIT means no OFFSET */ - - if (p.pWhere != null) - return 0; /* Has no WHERE clause */ - pSrc = p.pSrc; - Debug.Assert(pSrc != null); - if (pSrc.nSrc != 1) - return 0; /* Single term in FROM clause */ - if (pSrc.a[0].pSelect != null) - return 0; /* FROM is not a subquery or view */ - pTab = pSrc.a[0].pTab; - if (NEVER(pTab == null)) - return 0; - Debug.Assert(pTab.pSelect == null); /* FROM clause is not a view */ - if (IsVirtual(pTab)) - return 0; /* FROM clause not a virtual table */ - pEList = p.pEList; - if (pEList.nExpr != 1) - return 0; /* One column in the result set */ - if (pEList.a[0].pExpr.op != TK_COLUMN) - return 0; /* Result is a column */ - return 1; - } -#endif //* SQLITE_OMIT_SUBQUERY */ - - /* - ** This function is used by the implementation of the IN (...) operator. - ** It's job is to find or create a b-tree structure that may be used - ** either to test for membership of the (...) set or to iterate through - ** its members, skipping duplicates. - ** - ** The index of the cursor opened on the b-tree (database table, database index - ** or ephermal table) is stored in pX->iTable before this function returns. - ** The returned value of this function indicates the b-tree type, as follows: - ** - ** IN_INDEX_ROWID - The cursor was opened on a database table. - ** IN_INDEX_INDEX - The cursor was opened on a database index. - ** IN_INDEX_EPH - The cursor was opened on a specially created and - ** populated epheremal table. - ** - ** An existing b-tree may only be used if the SELECT is of the simple - ** form: - ** - ** SELECT FROM
- ** - ** If the prNotFound parameter is 0, then the b-tree will be used to iterate - ** through the set members, skipping any duplicates. In this case an - ** epheremal table must be used unless the selected is guaranteed - ** to be unique - either because it is an INTEGER PRIMARY KEY or it - ** has a UNIQUE constraint or UNIQUE index. - ** - ** If the prNotFound parameter is not 0, then the b-tree will be used - ** for fast set membership tests. In this case an epheremal table must - ** be used unless is an INTEGER PRIMARY KEY or an index can - ** be found with as its left-most column. - ** - ** When the b-tree is being used for membership tests, the calling function - ** needs to know whether or not the structure contains an SQL NULL - ** value in order to correctly evaluate expressions like "X IN (Y, Z)". - ** If there is any chance that the (...) might contain a NULL value at - ** runtime, then a register is allocated and the register number written - ** to *prNotFound. If there is no chance that the (...) contains a - ** NULL value, then *prNotFound is left unchanged. - ** - ** If a register is allocated and its location stored in *prNotFound, then - ** its initial value is NULL. If the (...) does not remain constant - ** for the duration of the query (i.e. the SELECT within the (...) - ** is a correlated subquery) then the value of the allocated register is - ** reset to NULL each time the subquery is rerun. This allows the - ** caller to use vdbe code equivalent to the following: - ** - ** if( register==NULL ){ - ** has_null = - ** register = 1 - ** } - ** - ** in order to avoid running the - ** test more often than is necessary. - */ -#if !SQLITE_OMIT_SUBQUERY - static int sqlite3FindInIndex(Parse pParse, Expr pX, ref int prNotFound) { - Select p; /* SELECT to the right of IN operator */ - int eType = 0; /* Type of RHS table. IN_INDEX_* */ - int iTab = pParse.nTab++; /* Cursor of the RHS table */ - bool mustBeUnique = (prNotFound != 0); /* True if RHS must be unique */ - - Debug.Assert(pX.op == TK_IN); + static int sqlite3CodeSubselect( + Parse pParse, /* Parsing context */ + Expr pExpr, /* The IN, SELECT, or EXISTS operator */ + int rMayHaveNull, /* Register that records whether NULLs exist in RHS */ + bool isRowid /* If true, LHS of IN operator is a rowid */ + ) + { + int testAddr = 0; /* One-time test address */ + int rReg = 0; /* Register storing resulting */ + Vdbe v = sqlite3GetVdbe( pParse ); + if ( NEVER( v == null ) ) + return 0; + sqlite3ExprCachePush( pParse ); + + /* This code must be run in its entirety every time it is encountered + ** if any of the following is true: + ** + ** * The right-hand side is a correlated subquery + ** * The right-hand side is an expression list containing variables + ** * 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 ( !ExprHasAnyProperty( pExpr, EP_VarSelect ) && null == pParse.pTriggerTab ) + { + int mem = ++pParse.nMem; + sqlite3VdbeAddOp1( v, OP_If, mem ); + testAddr = sqlite3VdbeAddOp2( v, OP_Integer, 1, mem ); + Debug.Assert( testAddr > 0 /* || pParse.db.mallocFailed != 0 */ ); + } - /* Check to see if an existing table or index can be used to - ** satisfy the query. This is preferable to generating a new - ** ephemeral table. - */ - p = (ExprHasProperty(pX, EP_xIsSelect) ? pX.x.pSelect : null); - if (ALWAYS(pParse.nErr == 0) && isCandidateForInOpt(p) != 0) { - sqlite3 db = pParse.db; /* Database connection */ - Expr pExpr = p.pEList.a[0].pExpr; /* Expression */ - int iCol = pExpr.iColumn; /* Index of column */ - Vdbe v = sqlite3GetVdbe(pParse); /* Virtual machine being coded */ - Table pTab = p.pSrc.a[0].pTab; /* Table
. */ - int iDb; /* Database idx for pTab */ - - /* Code an OP_VerifyCookie and OP_TableLock for
. */ - iDb = sqlite3SchemaToIndex(db, pTab.pSchema); - sqlite3CodeVerifySchema(pParse, iDb); - sqlite3TableLock(pParse, iDb, pTab.tnum, 0, pTab.zName); - - /* This function is only called from two places. In both cases the vdbe - ** has already been allocated. So assume sqlite3GetVdbe() is always - ** successful here. - */ - Debug.Assert(v != null); - if (iCol < 0) { - int iMem = ++pParse.nMem; - int iAddr; - - iAddr = sqlite3VdbeAddOp1(v, OP_If, iMem); - sqlite3VdbeAddOp2(v, OP_Integer, 1, iMem); - - sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead); - eType = IN_INDEX_ROWID; - - sqlite3VdbeJumpHere(v, iAddr); - } else { - Index pIdx; /* Iterator variable */ - /* The collation sequence used by the comparison. If an index is to - ** be used in place of a temp.table, it must be ordered according - ** to this collation sequence. */ - CollSeq pReq = sqlite3BinaryCompareCollSeq(pParse, pX.pLeft, pExpr); - - /* Check that the affinity that will be used to perform the - ** comparison is the same as the affinity of the column. If - ** it is not, it is not possible to use any index. - */ - char aff = comparisonAffinity(pX); - bool affinity_ok = (pTab.aCol[iCol].affinity == aff || aff == SQLITE_AFF_NONE); - - for (pIdx = pTab.pIndex; pIdx != null && eType == 0 && affinity_ok; pIdx = pIdx.pNext) { - if ((pIdx.aiColumn[0] == iCol) - && (sqlite3FindCollSeq(db, ENC(db), pIdx.azColl[0], 0) == pReq) - && (mustBeUnique == false || (pIdx.nColumn == 1 && pIdx.onError != OE_None)) - ) { - int iMem = ++pParse.nMem; - int iAddr; - KeyInfo pKey; - - pKey = sqlite3IndexKeyinfo(pParse, pIdx); - - iAddr = sqlite3VdbeAddOp1(v, OP_If, iMem); - sqlite3VdbeAddOp2(v, OP_Integer, 1, iMem); - - sqlite3VdbeAddOp4(v, OP_OpenRead, iTab, pIdx.tnum, iDb, - pKey, P4_KEYINFO_HANDOFF); -#if SQLITE_DEBUG - VdbeComment(v, "%s", pIdx.zName); +#if !SQLITE_OMIT_EXPLAIN + if ( pParse.explain == 2 ) + { + string zMsg = sqlite3MPrintf( + pParse.db, "EXECUTE %s%s SUBQUERY %d", testAddr != 0 ? string.Empty : "CORRELATED ", + pExpr.op == TK_IN ? "LIST" : "SCALAR", pParse.iNextSelectId + ); + sqlite3VdbeAddOp4( v, OP_Explain, pParse.iSelectId, 0, 0, zMsg, P4_DYNAMIC ); + } #endif - eType = IN_INDEX_INDEX; - sqlite3VdbeJumpHere(v, iAddr); - if ( //prNotFound != null && -- always exists under C# - pTab.aCol[iCol].notNull == 0) { - prNotFound = ++pParse.nMem; - } - } - } - } - } + switch ( pExpr.op ) + { + case TK_IN: + { + char affinity; /* Affinity of the LHS of the IN */ + KeyInfo keyInfo; /* Keyinfo for the generated table */ + int addr; /* Address of OP_OpenEphemeral instruction */ + Expr pLeft = pExpr.pLeft; /* the LHS of the IN operator */ - if (eType == 0) { - /* Could not found an existing table or index to use as the RHS b-tree. - ** We will have to generate an ephemeral table to do the job. - */ - double savedNQueryLoop = pParse.nQueryLoop; - int rMayHaveNull = 0; - eType = IN_INDEX_EPH; - if (prNotFound != -1) // Klude to show prNotFound not available - { - prNotFound = rMayHaveNull = ++pParse.nMem; - } else { - testcase(pParse.nQueryLoop > (double)1); - pParse.nQueryLoop = (double)1; - if (pX.pLeft.iColumn < 0 && !ExprHasAnyProperty(pX, EP_xIsSelect)) { - eType = IN_INDEX_ROWID; - } - } - sqlite3CodeSubselect(pParse, pX, rMayHaveNull, eType == IN_INDEX_ROWID); - pParse.nQueryLoop = savedNQueryLoop; - } else { - pX.iTable = iTab; + if ( rMayHaveNull != 0 ) + { + sqlite3VdbeAddOp2( v, OP_Null, 0, rMayHaveNull ); } - return eType; - } -#endif - /* - ** Generate code for scalar subqueries used as a subquery expression, EXISTS, - ** or IN operators. Examples: - ** - ** (SELECT a FROM b) -- subquery - ** EXISTS (SELECT a FROM b) -- EXISTS subquery - ** x IN (4,5,11) -- IN operator with list on right-hand side - ** x IN (SELECT a FROM b) -- IN operator with subquery on the right - ** - ** The pExpr parameter describes the expression that contains the IN - ** operator or subquery. - ** - ** If parameter isRowid is non-zero, then expression pExpr is guaranteed - ** to be of the form " IN (?, ?, ?)", where is a reference - ** to some integer key column of a table B-Tree. In this case, use an - ** intkey B-Tree to store the set of IN(...) values instead of the usual - ** (slower) variable length keys B-Tree. - ** - ** If rMayHaveNull is non-zero, that means that the operation is an IN - ** (not a SELECT or EXISTS) and that the RHS might contains NULLs. - ** Furthermore, the IN is in a WHERE clause and that we really want - ** to iterate over the RHS of the IN operator in order to quickly locate - ** all corresponding LHS elements. All this routine does is initialize - ** the register given by rMayHaveNull to NULL. Calling routines will take - ** care of changing this register value to non-NULL if the RHS is NULL-free. - ** - ** If rMayHaveNull is zero, that means that the subquery is being used - ** for membership testing only. There is no need to initialize any - ** registers to indicate the presense or absence of NULLs on the RHS. - ** - ** For a SELECT or EXISTS operator, return the register that holds the - ** result. For IN operators or if an error occurs, the return value is 0. - */ -#if !SQLITE_OMIT_SUBQUERY - static int sqlite3CodeSubselect( - Parse pParse, /* Parsing context */ - Expr pExpr, /* The IN, SELECT, or EXISTS operator */ - int rMayHaveNull, /* Register that records whether NULLs exist in RHS */ - bool isRowid /* If true, LHS of IN operator is a rowid */ - ) { - int testAddr = 0; /* One-time test address */ - int rReg = 0; /* Register storing resulting */ - Vdbe v = sqlite3GetVdbe(pParse); - if (NEVER(v == null)) - return 0; - sqlite3ExprCachePush(pParse); + affinity = sqlite3ExprAffinity( pLeft ); - /* This code must be run in its entirety every time it is encountered - ** if any of the following is true: + /* Whether this is an 'x IN(SELECT...)' or an 'x IN()' + ** expression it is handled the same way. An ephemeral table is + ** filled with single-field index keys representing the results + ** from the SELECT or the . ** - ** * The right-hand side is a correlated subquery - ** * The right-hand side is an expression list containing variables - ** * 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 the 'x' expression is a column value, or the SELECT... + ** statement returns a column value, then the affinity of that + ** column is used to build the index keys. If both 'x' and the + ** SELECT... statement are columns, then numeric affinity is used + ** if either column has NUMERIC or INTEGER affinity. If neither + ** 'x' nor the SELECT... statement are columns, then numeric affinity + ** is used. */ - if (!ExprHasAnyProperty(pExpr, EP_VarSelect) && null == pParse.pTriggerTab) { - int mem = ++pParse.nMem; - sqlite3VdbeAddOp1(v, OP_If, mem); - testAddr = sqlite3VdbeAddOp2(v, OP_Integer, 1, mem); - Debug.Assert(testAddr > 0 /* || pParse.db.mallocFailed != 0 */ ); + pExpr.iTable = pParse.nTab++; + addr = sqlite3VdbeAddOp2( v, OP_OpenEphemeral, (int)pExpr.iTable, !isRowid ); + if ( rMayHaveNull == 0 ) + sqlite3VdbeChangeP5( v, BTREE_UNORDERED ); + keyInfo = new KeyInfo();// memset( &keyInfo, 0, sizeof(keyInfo )); + keyInfo.nField = 1; + + if ( ExprHasProperty( pExpr, EP_xIsSelect ) ) + { + /* Case 1: expr IN (SELECT ...) + ** + ** Generate code to write the results of the select into the temporary + ** table allocated and opened above. + */ + SelectDest dest = new SelectDest(); + ExprList pEList; + + Debug.Assert( !isRowid ); + sqlite3SelectDestInit( dest, SRT_Set, pExpr.iTable ); + dest.affinity = (char)affinity; + Debug.Assert( ( pExpr.iTable & 0x0000FFFF ) == pExpr.iTable ); + pExpr.x.pSelect.iLimit = 0; + if ( sqlite3Select( pParse, pExpr.x.pSelect, ref dest ) != 0 ) + { + return 0; + } + pEList = pExpr.x.pSelect.pEList; + if ( ALWAYS( pEList != null ) && pEList.nExpr > 0 ) + { + keyInfo.aColl[0] = sqlite3BinaryCompareCollSeq( pParse, pExpr.pLeft, + pEList.a[0].pExpr ); + } } + else if ( ALWAYS( pExpr.x.pList != null ) ) + { + /* Case 2: expr IN (exprlist) + ** + ** For each expression, build an index key from the evaluation and + ** store it in the temporary table. If is a column, then use + ** that columns affinity when building index keys. If is not + ** a column, use numeric affinity. + */ + int i; + ExprList pList = pExpr.x.pList; + ExprList_item pItem; + int r1, r2, r3; + + if ( affinity == '\0' ) + { + affinity = SQLITE_AFF_NONE; + } + keyInfo.aColl[0] = sqlite3ExprCollSeq( pParse, pExpr.pLeft ); + + /* Loop through each expression in . */ + r1 = sqlite3GetTempReg( pParse ); + r2 = sqlite3GetTempReg( pParse ); + sqlite3VdbeAddOp2( v, OP_Null, 0, r2 ); + for ( i = 0; i < pList.nExpr; i++ ) + {//, pItem++){ + pItem = pList.a[i]; + Expr pE2 = pItem.pExpr; + int iValToIns = 0; -#if !SQLITE_OMIT_EXPLAIN - if (pParse.explain == 2) { - string zMsg = sqlite3MPrintf( - pParse.db, "EXECUTE %s%s SUBQUERY %d", testAddr != 0 ? string.Empty : "CORRELATED ", - pExpr.op == TK_IN ? "LIST" : "SCALAR", pParse.iNextSelectId - ); - sqlite3VdbeAddOp4(v, OP_Explain, pParse.iSelectId, 0, 0, zMsg, P4_DYNAMIC); - } -#endif + /* If the expression is not constant then we will need to + ** disable the test that was generated above that makes sure + ** this code only executes once. Because for a non-constant + ** expression we need to rerun this code each time. + */ + if ( testAddr != 0 && sqlite3ExprIsConstant( pE2 ) == 0 ) + { + sqlite3VdbeChangeToNoop( v, testAddr - 1, 2 ); + testAddr = 0; + } - switch (pExpr.op) { - case TK_IN: { - char affinity; /* Affinity of the LHS of the IN */ - KeyInfo keyInfo; /* Keyinfo for the generated table */ - int addr; /* Address of OP_OpenEphemeral instruction */ - Expr pLeft = pExpr.pLeft; /* the LHS of the IN operator */ + /* Evaluate the expression and insert it into the temp table */ + if ( isRowid && sqlite3ExprIsInteger( pE2, ref iValToIns ) != 0 ) + { + sqlite3VdbeAddOp3( v, OP_InsertInt, pExpr.iTable, r2, iValToIns ); + } + else + { + r3 = sqlite3ExprCodeTarget( pParse, pE2, r1 ); + if ( isRowid ) + { + sqlite3VdbeAddOp2( v, OP_MustBeInt, r3, + sqlite3VdbeCurrentAddr( v ) + 2 ); + sqlite3VdbeAddOp3( v, OP_Insert, pExpr.iTable, r2, r3 ); + } + else + { + sqlite3VdbeAddOp4( v, OP_MakeRecord, r3, 1, r2, affinity, 1 ); + sqlite3ExprCacheAffinityChange( pParse, r3, 1 ); + sqlite3VdbeAddOp2( v, OP_IdxInsert, pExpr.iTable, r2 ); + } + } + } + sqlite3ReleaseTempReg( pParse, r1 ); + sqlite3ReleaseTempReg( pParse, r2 ); + } + if ( !isRowid ) + { + sqlite3VdbeChangeP4( v, addr, keyInfo, P4_KEYINFO ); + } + break; + } - if (rMayHaveNull != 0) { - sqlite3VdbeAddOp2(v, OP_Null, 0, rMayHaveNull); - } + case TK_EXISTS: + case TK_SELECT: + default: + { + /* If this has to be a scalar SELECT. Generate code to put the + ** value of this select in a memory cell and record the number + ** of the memory cell in iColumn. If this is an EXISTS, write + ** an integer 0 (not exists) or 1 (exists) into a memory cell + ** and record that memory cell in iColumn. + */ + Select pSel; /* SELECT statement to encode */ + SelectDest dest = new SelectDest(); /* How to deal with SELECt result */ - affinity = sqlite3ExprAffinity(pLeft); - - /* Whether this is an 'x IN(SELECT...)' or an 'x IN()' - ** expression it is handled the same way. An ephemeral table is - ** filled with single-field index keys representing the results - ** from the SELECT or the . - ** - ** If the 'x' expression is a column value, or the SELECT... - ** statement returns a column value, then the affinity of that - ** column is used to build the index keys. If both 'x' and the - ** SELECT... statement are columns, then numeric affinity is used - ** if either column has NUMERIC or INTEGER affinity. If neither - ** 'x' nor the SELECT... statement are columns, then numeric affinity - ** is used. - */ - pExpr.iTable = pParse.nTab++; - addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, (int)pExpr.iTable, !isRowid); - if (rMayHaveNull == 0) - sqlite3VdbeChangeP5(v, BTREE_UNORDERED); - keyInfo = new KeyInfo();// memset( &keyInfo, 0, sizeof(keyInfo )); - keyInfo.nField = 1; - - if (ExprHasProperty(pExpr, EP_xIsSelect)) { - /* Case 1: expr IN (SELECT ...) - ** - ** Generate code to write the results of the select into the temporary - ** table allocated and opened above. - */ - SelectDest dest = new SelectDest(); - ExprList pEList; - - Debug.Assert(!isRowid); - sqlite3SelectDestInit(dest, SRT_Set, pExpr.iTable); - dest.affinity = (char)affinity; - Debug.Assert((pExpr.iTable & 0x0000FFFF) == pExpr.iTable); - pExpr.x.pSelect.iLimit = 0; - if (sqlite3Select(pParse, pExpr.x.pSelect, ref dest) != 0) { - return 0; - } - pEList = pExpr.x.pSelect.pEList; - if (ALWAYS(pEList != null) && pEList.nExpr > 0) { - keyInfo.aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr.pLeft, - pEList.a[0].pExpr); - } - } else if (ALWAYS(pExpr.x.pList != null)) { - /* Case 2: expr IN (exprlist) - ** - ** For each expression, build an index key from the evaluation and - ** store it in the temporary table. If is a column, then use - ** that columns affinity when building index keys. If is not - ** a column, use numeric affinity. - */ - int i; - ExprList pList = pExpr.x.pList; - ExprList_item pItem; - int r1, r2, r3; - - if (affinity == '\0') { - affinity = SQLITE_AFF_NONE; - } - keyInfo.aColl[0] = sqlite3ExprCollSeq(pParse, pExpr.pLeft); - - /* Loop through each expression in . */ - r1 = sqlite3GetTempReg(pParse); - r2 = sqlite3GetTempReg(pParse); - sqlite3VdbeAddOp2(v, OP_Null, 0, r2); - for (i = 0; i < pList.nExpr; i++) {//, pItem++){ - pItem = pList.a[i]; - Expr pE2 = pItem.pExpr; - int iValToIns = 0; - - /* If the expression is not constant then we will need to - ** disable the test that was generated above that makes sure - ** this code only executes once. Because for a non-constant - ** expression we need to rerun this code each time. - */ - if (testAddr != 0 && sqlite3ExprIsConstant(pE2) == 0) { - sqlite3VdbeChangeToNoop(v, testAddr - 1, 2); - testAddr = 0; - } - - /* Evaluate the expression and insert it into the temp table */ - if (isRowid && sqlite3ExprIsInteger(pE2, ref iValToIns) != 0) { - sqlite3VdbeAddOp3(v, OP_InsertInt, pExpr.iTable, r2, iValToIns); - } else { - r3 = sqlite3ExprCodeTarget(pParse, pE2, r1); - if (isRowid) { - sqlite3VdbeAddOp2(v, OP_MustBeInt, r3, - sqlite3VdbeCurrentAddr(v) + 2); - sqlite3VdbeAddOp3(v, OP_Insert, pExpr.iTable, r2, r3); - } else { - sqlite3VdbeAddOp4(v, OP_MakeRecord, r3, 1, r2, affinity, 1); - sqlite3ExprCacheAffinityChange(pParse, r3, 1); - sqlite3VdbeAddOp2(v, OP_IdxInsert, pExpr.iTable, r2); - } - } - } - sqlite3ReleaseTempReg(pParse, r1); - sqlite3ReleaseTempReg(pParse, r2); - } - if (!isRowid) { - sqlite3VdbeChangeP4(v, addr, keyInfo, P4_KEYINFO); - } - break; - } + testcase( pExpr.op == TK_EXISTS ); + testcase( pExpr.op == TK_SELECT ); + Debug.Assert( pExpr.op == TK_EXISTS || pExpr.op == TK_SELECT ); - case TK_EXISTS: - case TK_SELECT: - default: { - /* If this has to be a scalar SELECT. Generate code to put the - ** value of this select in a memory cell and record the number - ** of the memory cell in iColumn. If this is an EXISTS, write - ** an integer 0 (not exists) or 1 (exists) into a memory cell - ** and record that memory cell in iColumn. - */ - Select pSel; /* SELECT statement to encode */ - SelectDest dest = new SelectDest(); /* How to deal with SELECt result */ - - testcase(pExpr.op == TK_EXISTS); - testcase(pExpr.op == TK_SELECT); - Debug.Assert(pExpr.op == TK_EXISTS || pExpr.op == TK_SELECT); - - Debug.Assert(ExprHasProperty(pExpr, EP_xIsSelect)); - pSel = pExpr.x.pSelect; - sqlite3SelectDestInit(dest, 0, ++pParse.nMem); - if (pExpr.op == TK_SELECT) { - dest.eDest = SRT_Mem; - sqlite3VdbeAddOp2(v, OP_Null, 0, dest.iParm); + Debug.Assert( ExprHasProperty( pExpr, EP_xIsSelect ) ); + pSel = pExpr.x.pSelect; + sqlite3SelectDestInit( dest, 0, ++pParse.nMem ); + if ( pExpr.op == TK_SELECT ) + { + dest.eDest = SRT_Mem; + sqlite3VdbeAddOp2( v, OP_Null, 0, dest.iParm ); #if SQLITE_DEBUG - VdbeComment(v, "Init subquery result"); + VdbeComment( v, "Init subquery result" ); #endif - } else { - dest.eDest = SRT_Exists; - sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iParm); + } + else + { + dest.eDest = SRT_Exists; + sqlite3VdbeAddOp2( v, OP_Integer, 0, dest.iParm ); #if SQLITE_DEBUG - VdbeComment(v, "Init EXISTS result"); + VdbeComment( v, "Init EXISTS result" ); #endif - } - sqlite3ExprDelete(pParse.db, ref pSel.pLimit); - pSel.pLimit = sqlite3PExpr(pParse, TK_INTEGER, null, null, sqlite3IntTokens[1]); - pSel.iLimit = 0; - if (sqlite3Select(pParse, pSel, ref dest) != 0) { - return 0; - } - rReg = dest.iParm; - ExprSetIrreducible(pExpr); - break; - } } - - if (testAddr != 0) { - sqlite3VdbeJumpHere(v, testAddr - 1); + sqlite3ExprDelete( pParse.db, ref pSel.pLimit ); + pSel.pLimit = sqlite3PExpr( pParse, TK_INTEGER, null, null, sqlite3IntTokens[1] ); + pSel.iLimit = 0; + if ( sqlite3Select( pParse, pSel, ref dest ) != 0 ) + { + return 0; } - sqlite3ExprCachePop(pParse, 1); + rReg = dest.iParm; + ExprSetIrreducible( pExpr ); + break; + } + } - return rReg; - } + if ( testAddr != 0 ) + { + sqlite3VdbeJumpHere( v, testAddr - 1 ); + } + sqlite3ExprCachePop( pParse, 1 ); + + return rReg; + } #endif // * SQLITE_OMIT_SUBQUERY */ #if !SQLITE_OMIT_SUBQUERY - /* - ** Generate code for an IN expression. - ** - ** x IN (SELECT ...) - ** x IN (value, value, ...) - ** - ** The left-hand side (LHS) is a scalar expression. The right-hand side (RHS) - ** is an array of zero or more values. The expression is true if the LHS is - ** contained within the RHS. The value of the expression is unknown (NULL) - ** if the LHS is NULL or if the LHS is not contained within the RHS and the - ** RHS contains one or more NULL values. - ** - ** This routine generates code will jump to destIfFalse if the LHS is not - ** contained within the RHS. If due to NULLs we cannot determine if the LHS - ** is contained in the RHS then jump to destIfNull. If the LHS is contained - ** within the RHS then fall through. - */ - static void sqlite3ExprCodeIN( - Parse pParse, /* Parsing and code generating context */ - Expr pExpr, /* The IN expression */ - int destIfFalse, /* Jump here if LHS is not contained in the RHS */ - int destIfNull /* Jump here if the results are unknown due to NULLs */ - ) { - int rRhsHasNull = 0; /* Register that is true if RHS contains NULL values */ - char affinity; /* Comparison affinity to use */ - int eType; /* Type of the RHS */ - int r1; /* Temporary use register */ - Vdbe v; /* Statement under construction */ - - /* Compute the RHS. After this step, the table with cursor - ** pExpr.iTable will contains the values that make up the RHS. - */ - v = pParse.pVdbe; - Debug.Assert(v != null); /* OOM detected prior to this routine */ - VdbeNoopComment(v, "begin IN expr"); - eType = sqlite3FindInIndex(pParse, pExpr, ref rRhsHasNull); - - /* Figure out the affinity to use to create a key from the results - ** of the expression. affinityStr stores a static string suitable for - ** P4 of OP_MakeRecord. - */ - affinity = comparisonAffinity(pExpr); - - /* Code the LHS, the from " IN (...)". - */ - sqlite3ExprCachePush(pParse); - r1 = sqlite3GetTempReg(pParse); - sqlite3ExprCode(pParse, pExpr.pLeft, r1); - - /* If the LHS is NULL, then the result is either false or NULL depending - ** on whether the RHS is empty or not, respectively. - */ - if (destIfNull == destIfFalse) { - /* Shortcut for the common case where the false and NULL outcomes are - ** the same. */ - sqlite3VdbeAddOp2(v, OP_IsNull, r1, destIfNull); - } else { - int addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, r1); - sqlite3VdbeAddOp2(v, OP_Rewind, pExpr.iTable, destIfFalse); - sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfNull); - sqlite3VdbeJumpHere(v, addr1); - } + /* +** Generate code for an IN expression. +** +** x IN (SELECT ...) +** x IN (value, value, ...) +** +** The left-hand side (LHS) is a scalar expression. The right-hand side (RHS) +** is an array of zero or more values. The expression is true if the LHS is +** contained within the RHS. The value of the expression is unknown (NULL) +** if the LHS is NULL or if the LHS is not contained within the RHS and the +** RHS contains one or more NULL values. +** +** This routine generates code will jump to destIfFalse if the LHS is not +** contained within the RHS. If due to NULLs we cannot determine if the LHS +** is contained in the RHS then jump to destIfNull. If the LHS is contained +** within the RHS then fall through. +*/ + static void sqlite3ExprCodeIN( + Parse pParse, /* Parsing and code generating context */ + Expr pExpr, /* The IN expression */ + int destIfFalse, /* Jump here if LHS is not contained in the RHS */ + int destIfNull /* Jump here if the results are unknown due to NULLs */ + ) + { + int rRhsHasNull = 0; /* Register that is true if RHS contains NULL values */ + char affinity; /* Comparison affinity to use */ + int eType; /* Type of the RHS */ + int r1; /* Temporary use register */ + Vdbe v; /* Statement under construction */ + + /* Compute the RHS. After this step, the table with cursor + ** pExpr.iTable will contains the values that make up the RHS. + */ + v = pParse.pVdbe; + Debug.Assert( v != null ); /* OOM detected prior to this routine */ + VdbeNoopComment( v, "begin IN expr" ); + eType = sqlite3FindInIndex( pParse, pExpr, ref rRhsHasNull ); + + /* Figure out the affinity to use to create a key from the results + ** of the expression. affinityStr stores a static string suitable for + ** P4 of OP_MakeRecord. + */ + affinity = comparisonAffinity( pExpr ); + + /* Code the LHS, the from " IN (...)". + */ + sqlite3ExprCachePush( pParse ); + r1 = sqlite3GetTempReg( pParse ); + sqlite3ExprCode( pParse, pExpr.pLeft, r1 ); + + /* If the LHS is NULL, then the result is either false or NULL depending + ** on whether the RHS is empty or not, respectively. + */ + if ( destIfNull == destIfFalse ) + { + /* Shortcut for the common case where the false and NULL outcomes are + ** the same. */ + sqlite3VdbeAddOp2( v, OP_IsNull, r1, destIfNull ); + } + else + { + int addr1 = sqlite3VdbeAddOp1( v, OP_NotNull, r1 ); + sqlite3VdbeAddOp2( v, OP_Rewind, pExpr.iTable, destIfFalse ); + sqlite3VdbeAddOp2( v, OP_Goto, 0, destIfNull ); + sqlite3VdbeJumpHere( v, addr1 ); + } + + if ( eType == IN_INDEX_ROWID ) + { + /* In this case, the RHS is the ROWID of table b-tree + */ + sqlite3VdbeAddOp2( v, OP_MustBeInt, r1, destIfFalse ); + sqlite3VdbeAddOp3( v, OP_NotExists, pExpr.iTable, destIfFalse, r1 ); + } + else + { + /* In this case, the RHS is an index b-tree. + */ + sqlite3VdbeAddOp4( v, OP_Affinity, r1, 1, 0, affinity, 1 ); - if (eType == IN_INDEX_ROWID) { - /* In this case, the RHS is the ROWID of table b-tree - */ - sqlite3VdbeAddOp2(v, OP_MustBeInt, r1, destIfFalse); - sqlite3VdbeAddOp3(v, OP_NotExists, pExpr.iTable, destIfFalse, r1); - } else { - /* In this case, the RHS is an index b-tree. - */ - sqlite3VdbeAddOp4(v, OP_Affinity, r1, 1, 0, affinity, 1); + /* If the set membership test fails, then the result of the + ** "x IN (...)" expression must be either 0 or NULL. If the set + ** contains no NULL values, then the result is 0. If the set + ** contains one or more NULL values, then the result of the + ** expression is also NULL. + */ + if ( rRhsHasNull == 0 || destIfFalse == destIfNull ) + { + /* This branch runs if it is known at compile time that the RHS + ** cannot contain NULL values. This happens as the result + ** of a "NOT NULL" constraint in the database schema. + ** + ** Also run this branch if NULL is equivalent to FALSE + ** for this particular IN operator. + */ + sqlite3VdbeAddOp4Int( v, OP_NotFound, pExpr.iTable, destIfFalse, r1, 1 ); - /* If the set membership test fails, then the result of the - ** "x IN (...)" expression must be either 0 or NULL. If the set - ** contains no NULL values, then the result is 0. If the set - ** contains one or more NULL values, then the result of the - ** expression is also NULL. - */ - if (rRhsHasNull == 0 || destIfFalse == destIfNull) { - /* This branch runs if it is known at compile time that the RHS - ** cannot contain NULL values. This happens as the result - ** of a "NOT NULL" constraint in the database schema. - ** - ** Also run this branch if NULL is equivalent to FALSE - ** for this particular IN operator. - */ - sqlite3VdbeAddOp4Int(v, OP_NotFound, pExpr.iTable, destIfFalse, r1, 1); - - } else { - /* In this branch, the RHS of the IN might contain a NULL and - ** the presence of a NULL on the RHS makes a difference in the - ** outcome. - */ - int j1, j2, j3; - - /* First check to see if the LHS is contained in the RHS. If so, - ** then the presence of NULLs in the RHS does not matter, so jump - ** over all of the code that follows. - */ - j1 = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr.iTable, 0, r1, 1); - - /* Here we begin generating code that runs if the LHS is not - ** contained within the RHS. Generate additional code that - ** tests the RHS for NULLs. If the RHS contains a NULL then - ** jump to destIfNull. If there are no NULLs in the RHS then - ** jump to destIfFalse. - */ - j2 = sqlite3VdbeAddOp1(v, OP_NotNull, rRhsHasNull); - j3 = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr.iTable, 0, rRhsHasNull, 1); - sqlite3VdbeAddOp2(v, OP_Integer, -1, rRhsHasNull); - sqlite3VdbeJumpHere(v, j3); - sqlite3VdbeAddOp2(v, OP_AddImm, rRhsHasNull, 1); - sqlite3VdbeJumpHere(v, j2); - - /* Jump to the appropriate target depending on whether or not - ** the RHS contains a NULL - */ - sqlite3VdbeAddOp2(v, OP_If, rRhsHasNull, destIfNull); - sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfFalse); - - /* The OP_Found at the top of this branch jumps here when true, - ** causing the overall IN expression evaluation to fall through. - */ - sqlite3VdbeJumpHere(v, j1); - } - } - sqlite3ReleaseTempReg(pParse, r1); - sqlite3ExprCachePop(pParse, 1); - VdbeComment(v, "end IN expr"); } + else + { + /* In this branch, the RHS of the IN might contain a NULL and + ** the presence of a NULL on the RHS makes a difference in the + ** outcome. + */ + int j1, j2, j3; + + /* First check to see if the LHS is contained in the RHS. If so, + ** then the presence of NULLs in the RHS does not matter, so jump + ** over all of the code that follows. + */ + j1 = sqlite3VdbeAddOp4Int( v, OP_Found, pExpr.iTable, 0, r1, 1 ); + + /* Here we begin generating code that runs if the LHS is not + ** contained within the RHS. Generate additional code that + ** tests the RHS for NULLs. If the RHS contains a NULL then + ** jump to destIfNull. If there are no NULLs in the RHS then + ** jump to destIfFalse. + */ + j2 = sqlite3VdbeAddOp1( v, OP_NotNull, rRhsHasNull ); + j3 = sqlite3VdbeAddOp4Int( v, OP_Found, pExpr.iTable, 0, rRhsHasNull, 1 ); + sqlite3VdbeAddOp2( v, OP_Integer, -1, rRhsHasNull ); + sqlite3VdbeJumpHere( v, j3 ); + sqlite3VdbeAddOp2( v, OP_AddImm, rRhsHasNull, 1 ); + sqlite3VdbeJumpHere( v, j2 ); + + /* Jump to the appropriate target depending on whether or not + ** the RHS contains a NULL + */ + sqlite3VdbeAddOp2( v, OP_If, rRhsHasNull, destIfNull ); + sqlite3VdbeAddOp2( v, OP_Goto, 0, destIfFalse ); + + /* The OP_Found at the top of this branch jumps here when true, + ** causing the overall IN expression evaluation to fall through. + */ + sqlite3VdbeJumpHere( v, j1 ); + } + } + sqlite3ReleaseTempReg( pParse, r1 ); + sqlite3ExprCachePop( pParse, 1 ); + VdbeComment( v, "end IN expr" ); + } #endif //* SQLITE_OMIT_SUBQUERY */ - /* - ** Duplicate an 8-byte value - */ - //static char *dup8bytes(Vdbe v, string in){ - // char *out = sqlite3DbMallocRaw(sqlite3VdbeDb(v), 8); - // if( out ){ - // memcpy(out, in, 8); - // } - // return out; - //} + /* +** Duplicate an 8-byte value +*/ + //static char *dup8bytes(Vdbe v, string in){ + // char *out = sqlite3DbMallocRaw(sqlite3VdbeDb(v), 8); + // if( out ){ + // memcpy(out, in, 8); + // } + // return out; + //} #if !SQLITE_OMIT_FLOATING_POINT - /* - ** Generate an instruction that will put the floating point - ** value described by z[0..n-1] into register iMem. - ** - ** The z[] string will probably not be zero-terminated. But the - ** z[n] character is guaranteed to be something that does not look - ** like the continuation of the number. - */ - static void codeReal(Vdbe v, string z, bool negateFlag, int iMem) { - if (ALWAYS(!string.IsNullOrEmpty(z))) { - double value = 0; - //string zV; - sqlite3AtoF(z, ref value, sqlite3Strlen30(z), SQLITE_UTF8); - Debug.Assert(!sqlite3IsNaN(value)); /* The new AtoF never returns NaN */ - if (negateFlag) - value = -value; - //zV = dup8bytes(v, value); - sqlite3VdbeAddOp4(v, OP_Real, 0, iMem, 0, value, P4_REAL); - } - } + /* +** Generate an instruction that will put the floating point +** value described by z[0..n-1] into register iMem. +** +** The z[] string will probably not be zero-terminated. But the +** z[n] character is guaranteed to be something that does not look +** like the continuation of the number. +*/ + static void codeReal( Vdbe v, string z, bool negateFlag, int iMem ) + { + if ( ALWAYS( !string.IsNullOrEmpty( z ) ) ) + { + double value = 0; + //string zV; + sqlite3AtoF( z, ref value, sqlite3Strlen30( z ), SQLITE_UTF8 ); + Debug.Assert( !sqlite3IsNaN( value ) ); /* The new AtoF never returns NaN */ + if ( negateFlag ) + value = -value; + //zV = dup8bytes(v, value); + sqlite3VdbeAddOp4( v, OP_Real, 0, iMem, 0, value, P4_REAL ); + } + } #endif - /* - ** Generate an instruction that will put the integer describe by - ** text z[0..n-1] into register iMem. - ** - ** Expr.u.zToken is always UTF8 and zero-terminated. - */ - static void codeInteger(Parse pParse, Expr pExpr, bool negFlag, int iMem) { - Vdbe v = pParse.pVdbe; - if ((pExpr.flags & EP_IntValue) != 0) { - int i = pExpr.u.iValue; - Debug.Assert(i >= 0); - if (negFlag) - i = -i; - sqlite3VdbeAddOp2(v, OP_Integer, i, iMem); - } else { - int c; - i64 value = 0; - string z = pExpr.u.zToken; - Debug.Assert(!string.IsNullOrEmpty(z)); - c = sqlite3Atoi64(z, ref value, sqlite3Strlen30(z), SQLITE_UTF8); - if (c == 0 || (c == 2 && negFlag)) { - //char* zV; - if (negFlag) { - value = c == 2 ? SMALLEST_INT64 : -value; - } - sqlite3VdbeAddOp4(v, OP_Int64, 0, iMem, 0, value, P4_INT64); - } else { + /* + ** Generate an instruction that will put the integer describe by + ** text z[0..n-1] into register iMem. + ** + ** Expr.u.zToken is always UTF8 and zero-terminated. + */ + static void codeInteger( Parse pParse, Expr pExpr, bool negFlag, int iMem ) + { + Vdbe v = pParse.pVdbe; + if ( ( pExpr.flags & EP_IntValue ) != 0 ) + { + int i = pExpr.u.iValue; + Debug.Assert( i >= 0 ); + if ( negFlag ) + i = -i; + sqlite3VdbeAddOp2( v, OP_Integer, i, iMem ); + } + else + { + int c; + i64 value = 0; + string z = pExpr.u.zToken; + Debug.Assert( !string.IsNullOrEmpty( z ) ); + c = sqlite3Atoi64( z, ref value, sqlite3Strlen30( z ), SQLITE_UTF8 ); + if ( c == 0 || ( c == 2 && negFlag ) ) + { + //char* zV; + if ( negFlag ) + { + value = c == 2 ? SMALLEST_INT64 : -value; + } + sqlite3VdbeAddOp4( v, OP_Int64, 0, iMem, 0, value, P4_INT64 ); + } + else + { #if SQLITE_OMIT_FLOATING_POINT sqlite3ErrorMsg(pParse, "oversized integer: %s%s", negFlag ? "-" : string.Empty, z); #else - codeReal(v, z, negFlag, iMem); + codeReal( v, z, negFlag, iMem ); #endif - } - } } + } + } - /* - ** Clear a cache entry. - */ - static void cacheEntryClear(Parse pParse, yColCache p) { - if (p.tempReg != 0) { - if (pParse.nTempReg < ArraySize(pParse.aTempReg)) { - pParse.aTempReg[pParse.nTempReg++] = p.iReg; - } - p.tempReg = 0; - } + /* + ** Clear a cache entry. + */ + static void cacheEntryClear( Parse pParse, yColCache p ) + { + if ( p.tempReg != 0 ) + { + if ( pParse.nTempReg < ArraySize( pParse.aTempReg ) ) + { + pParse.aTempReg[pParse.nTempReg++] = p.iReg; } + p.tempReg = 0; + } + } - /* - ** Record in the column cache that a particular column from a - ** particular table is stored in a particular register. - */ - static void sqlite3ExprCacheStore(Parse pParse, int iTab, int iCol, int iReg) { - int i; - int minLru; - int idxLru; - yColCache p = new yColCache(); - - Debug.Assert(iReg > 0); /* Register numbers are always positive */ - Debug.Assert(iCol >= -1 && iCol < 32768); /* Finite column numbers */ - - /* The SQLITE_ColumnCache flag disables the column cache. This is used - ** for testing only - to verify that SQLite always gets the same answer - ** with and without the column cache. - */ - if ((pParse.db.flags & SQLITE_ColumnCache) != 0) - return; - - /* First replace any existing entry. - ** - ** Actually, the way the column cache is currently used, we are guaranteed - ** that the object will never already be in cache. Verify this guarantee. - */ + /* + ** Record in the column cache that a particular column from a + ** particular table is stored in a particular register. + */ + static void sqlite3ExprCacheStore( Parse pParse, int iTab, int iCol, int iReg ) + { + int i; + int minLru; + int idxLru; + yColCache p = new yColCache(); + + Debug.Assert( iReg > 0 ); /* Register numbers are always positive */ + Debug.Assert( iCol >= -1 && iCol < 32768 ); /* Finite column numbers */ + + /* The SQLITE_ColumnCache flag disables the column cache. This is used + ** for testing only - to verify that SQLite always gets the same answer + ** with and without the column cache. + */ + if ( ( pParse.db.flags & SQLITE_ColumnCache ) != 0 ) + return; + + /* First replace any existing entry. + ** + ** Actually, the way the column cache is currently used, we are guaranteed + ** that the object will never already be in cache. Verify this guarantee. + */ #if !NDEBUG - for (i = 0; i < SQLITE_N_COLCACHE; i++)//p=pParse.aColCache... p++) - { + for ( i = 0; i < SQLITE_N_COLCACHE; i++ )//p=pParse.aColCache... p++) + { #if FALSE //* This code wold remove the entry from the cache if it existed */ p = pParse.aColCache[i]; if ( p.iReg != 0 && p.iTable == iTab && p.iColumn == iCol ) @@ -2172,1268 +2430,1415 @@ static void sqlite3ExprCacheStore(Parse pParse, int iTab, int iCol, int iReg) { return; } #endif - Debug.Assert(p.iReg == 0 || p.iTable != iTab || p.iColumn != iCol); - } + Debug.Assert( p.iReg == 0 || p.iTable != iTab || p.iColumn != iCol ); + } #endif - /* Find an empty slot and replace it */ - for (i = 0; i < SQLITE_N_COLCACHE; i++)//p=pParse.aColCache... p++) - { - p = pParse.aColCache[i]; - if (p.iReg == 0) { - p.iLevel = pParse.iCacheLevel; - p.iTable = iTab; - p.iColumn = iCol; - p.iReg = iReg; - p.tempReg = 0; - p.lru = pParse.iCacheCnt++; - return; - } - } - - /* Replace the last recently used */ - minLru = 0x7fffffff; - idxLru = -1; - for (i = 0; i < SQLITE_N_COLCACHE; i++)//p=pParse.aColCache..., p++) - { - p = pParse.aColCache[i]; - if (p.lru < minLru) { - idxLru = i; - minLru = p.lru; - } - } - if (ALWAYS(idxLru >= 0)) { - p = pParse.aColCache[idxLru]; - p.iLevel = pParse.iCacheLevel; - p.iTable = iTab; - p.iColumn = iCol; - p.iReg = iReg; - p.tempReg = 0; - p.lru = pParse.iCacheCnt++; - return; - } + /* Find an empty slot and replace it */ + for ( i = 0; i < SQLITE_N_COLCACHE; i++ )//p=pParse.aColCache... p++) + { + p = pParse.aColCache[i]; + if ( p.iReg == 0 ) + { + p.iLevel = pParse.iCacheLevel; + p.iTable = iTab; + p.iColumn = iCol; + p.iReg = iReg; + p.tempReg = 0; + p.lru = pParse.iCacheCnt++; + return; } - - /* - ** Indicate that registers between iReg..iReg+nReg-1 are being overwritten. - ** Purge the range of registers from the column cache. - */ - static void sqlite3ExprCacheRemove(Parse pParse, int iReg, int nReg) { - int i; - int iLast = iReg + nReg - 1; - yColCache p; - for (i = 0; i < SQLITE_N_COLCACHE; i++)//p=pParse.aColCache... p++) - { - p = pParse.aColCache[i]; - int r = p.iReg; - if (r >= iReg && r <= iLast) { - cacheEntryClear(pParse, p); - p.iReg = 0; - } - } - } - - /* - ** Remember the current column cache context. Any new entries added - ** added to the column cache after this call are removed when the - ** corresponding pop occurs. - */ - static void sqlite3ExprCachePush(Parse pParse) { - pParse.iCacheLevel++; + } + + /* Replace the last recently used */ + minLru = 0x7fffffff; + idxLru = -1; + for ( i = 0; i < SQLITE_N_COLCACHE; i++ )//p=pParse.aColCache..., p++) + { + p = pParse.aColCache[i]; + if ( p.lru < minLru ) + { + idxLru = i; + minLru = p.lru; } + } + if ( ALWAYS( idxLru >= 0 ) ) + { + p = pParse.aColCache[idxLru]; + p.iLevel = pParse.iCacheLevel; + p.iTable = iTab; + p.iColumn = iCol; + p.iReg = iReg; + p.tempReg = 0; + p.lru = pParse.iCacheCnt++; + return; + } + } - /* - ** Remove from the column cache any entries that were added since the - ** the previous N Push operations. In other words, restore the cache - ** to the state it was in N Pushes ago. - */ - static void sqlite3ExprCachePop(Parse pParse, int N) { - int i; - yColCache p; - Debug.Assert(N > 0); - Debug.Assert(pParse.iCacheLevel >= N); - pParse.iCacheLevel -= N; - for (i = 0; i < SQLITE_N_COLCACHE; i++)// p++) - { - p = pParse.aColCache[i]; - if (p.iReg != 0 && p.iLevel > pParse.iCacheLevel) { - cacheEntryClear(pParse, p); - p.iReg = 0; - } - } + /* + ** Indicate that registers between iReg..iReg+nReg-1 are being overwritten. + ** Purge the range of registers from the column cache. + */ + static void sqlite3ExprCacheRemove( Parse pParse, int iReg, int nReg ) + { + int i; + int iLast = iReg + nReg - 1; + yColCache p; + for ( i = 0; i < SQLITE_N_COLCACHE; i++ )//p=pParse.aColCache... p++) + { + p = pParse.aColCache[i]; + int r = p.iReg; + if ( r >= iReg && r <= iLast ) + { + cacheEntryClear( pParse, p ); + p.iReg = 0; } + } + } - /* - ** When a cached column is reused, make sure that its register is - ** no longer available as a temp register. ticket #3879: that same - ** register might be in the cache in multiple places, so be sure to - ** get them all. - */ - static void sqlite3ExprCachePinRegister(Parse pParse, int iReg) { - int i; - yColCache p; - for (i = 0; i < SQLITE_N_COLCACHE; i++)//p=pParse->aColCache; i= 0) { - sqlite3ColumnDefault(v, pTab, iCol, regOut); - } + /* + ** Remove from the column cache any entries that were added since the + ** the previous N Push operations. In other words, restore the cache + ** to the state it was in N Pushes ago. + */ + static void sqlite3ExprCachePop( Parse pParse, int N ) + { + int i; + yColCache p; + Debug.Assert( N > 0 ); + Debug.Assert( pParse.iCacheLevel >= N ); + pParse.iCacheLevel -= N; + for ( i = 0; i < SQLITE_N_COLCACHE; i++ )// p++) + { + p = pParse.aColCache[i]; + if ( p.iReg != 0 && p.iLevel > pParse.iCacheLevel ) + { + cacheEntryClear( pParse, p ); + p.iReg = 0; } + } + } - /* - ** Generate code that will extract the iColumn-th column from - ** table pTab and store the column value in a register. An effort - ** is made to store the column value in register iReg, but this is - ** not guaranteed. The location of the column value is returned. - ** - ** There must be an open cursor to pTab in iTable when this routine - ** is called. If iColumn<0 then code is generated that extracts the rowid. - */ - static int sqlite3ExprCodeGetColumn( - Parse pParse, /* Parsing and code generating context */ - Table pTab, /* Description of the table we are reading from */ - int iColumn, /* Index of the table column */ - int iTable, /* The cursor pointing to the table */ - int iReg /* Store results here */ - ) { - Vdbe v = pParse.pVdbe; - int i; - yColCache p; - - for (i = 0; i < SQLITE_N_COLCACHE; i++) {// p=pParse.aColCache, p++ - p = pParse.aColCache[i]; - if (p.iReg > 0 && p.iTable == iTable && p.iColumn == iColumn) { - p.lru = pParse.iCacheCnt++; - sqlite3ExprCachePinRegister(pParse, p.iReg); - return p.iReg; - } - } - Debug.Assert(v != null); - sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg); - sqlite3ExprCacheStore(pParse, iTable, iColumn, iReg); - return iReg; + /* + ** When a cached column is reused, make sure that its register is + ** no longer available as a temp register. ticket #3879: that same + ** register might be in the cache in multiple places, so be sure to + ** get them all. + */ + static void sqlite3ExprCachePinRegister( Parse pParse, int iReg ) + { + int i; + yColCache p; + for ( i = 0; i < SQLITE_N_COLCACHE; i++ )//p=pParse->aColCache; i= 0 ) + { + sqlite3ColumnDefault( v, pTab, iCol, regOut ); + } + } - for (i = 0; i < SQLITE_N_COLCACHE; i++)// p=pParse.aColCache... p++) - { - p = pParse.aColCache[i]; - if (p.iReg != 0) { - cacheEntryClear(pParse, p); - p.iReg = 0; - } - } + /* + ** Generate code that will extract the iColumn-th column from + ** table pTab and store the column value in a register. An effort + ** is made to store the column value in register iReg, but this is + ** not guaranteed. The location of the column value is returned. + ** + ** There must be an open cursor to pTab in iTable when this routine + ** is called. If iColumn<0 then code is generated that extracts the rowid. + */ + static int sqlite3ExprCodeGetColumn( + Parse pParse, /* Parsing and code generating context */ + Table pTab, /* Description of the table we are reading from */ + int iColumn, /* Index of the table column */ + int iTable, /* The cursor pointing to the table */ + int iReg /* Store results here */ + ) + { + Vdbe v = pParse.pVdbe; + int i; + yColCache p; + + for ( i = 0; i < SQLITE_N_COLCACHE; i++ ) + {// p=pParse.aColCache, p++ + p = pParse.aColCache[i]; + if ( p.iReg > 0 && p.iTable == iTable && p.iColumn == iColumn ) + { + p.lru = pParse.iCacheCnt++; + sqlite3ExprCachePinRegister( pParse, p.iReg ); + return p.iReg; } + } + Debug.Assert( v != null ); + sqlite3ExprCodeGetColumnOfTable( v, pTab, iTable, iColumn, iReg ); + sqlite3ExprCacheStore( pParse, iTable, iColumn, iReg ); + return iReg; + } - /* - ** Record the fact that an affinity change has occurred on iCount - ** registers starting with iStart. - */ - static void sqlite3ExprCacheAffinityChange(Parse pParse, int iStart, int iCount) { - sqlite3ExprCacheRemove(pParse, iStart, iCount); + /* + ** Clear all column cache entries. + */ + static void sqlite3ExprCacheClear( Parse pParse ) + { + int i; + yColCache p; + + for ( i = 0; i < SQLITE_N_COLCACHE; i++ )// p=pParse.aColCache... p++) + { + p = pParse.aColCache[i]; + if ( p.iReg != 0 ) + { + cacheEntryClear( pParse, p ); + p.iReg = 0; } + } + } - /* - ** Generate code to move content from registers iFrom...iFrom+nReg-1 - ** over to iTo..iTo+nReg-1. Keep the column cache up-to-date. - */ - static void sqlite3ExprCodeMove(Parse pParse, int iFrom, int iTo, int nReg) { - int i; - yColCache p; - if (NEVER(iFrom == iTo)) - return; - sqlite3VdbeAddOp3(pParse.pVdbe, OP_Move, iFrom, iTo, nReg); - for (i = 0; i < SQLITE_N_COLCACHE; i++)// p=pParse.aColCache... p++) - { - p = pParse.aColCache[i]; - int x = p.iReg; - if (x >= iFrom && x < iFrom + nReg) { - p.iReg += iTo - iFrom; - } - } - } + /* + ** Record the fact that an affinity change has occurred on iCount + ** registers starting with iStart. + */ + static void sqlite3ExprCacheAffinityChange( Parse pParse, int iStart, int iCount ) + { + sqlite3ExprCacheRemove( pParse, iStart, iCount ); + } - /* - ** Generate code to copy content from registers iFrom...iFrom+nReg-1 - ** over to iTo..iTo+nReg-1. - */ - static void sqlite3ExprCodeCopy(Parse pParse, int iFrom, int iTo, int nReg) { - int i; - if (NEVER(iFrom == iTo)) - return; - for (i = 0; i < nReg; i++) { - sqlite3VdbeAddOp2(pParse.pVdbe, OP_Copy, iFrom + i, iTo + i); - } + /* + ** Generate code to move content from registers iFrom...iFrom+nReg-1 + ** over to iTo..iTo+nReg-1. Keep the column cache up-to-date. + */ + static void sqlite3ExprCodeMove( Parse pParse, int iFrom, int iTo, int nReg ) + { + int i; + yColCache p; + if ( NEVER( iFrom == iTo ) ) + return; + sqlite3VdbeAddOp3( pParse.pVdbe, OP_Move, iFrom, iTo, nReg ); + for ( i = 0; i < SQLITE_N_COLCACHE; i++ )// p=pParse.aColCache... p++) + { + p = pParse.aColCache[i]; + int x = p.iReg; + if ( x >= iFrom && x < iFrom + nReg ) + { + p.iReg += iTo - iFrom; } + } + } -#if (SQLITE_DEBUG) || (SQLITE_COVERAGE_TEST) - /* - ** Return true if any register in the range iFrom..iTo (inclusive) - ** is used as part of the column cache. - ** - ** This routine is used within Debug.Assert() and testcase() macros only - ** and does not appear in a normal build. + /* + ** Generate code to copy content from registers iFrom...iFrom+nReg-1 + ** over to iTo..iTo+nReg-1. */ - static int usedAsColumnCache(Parse pParse, int iFrom, int iTo) { - int i; - yColCache p; - for (i = 0; i < SQLITE_N_COLCACHE; i++)//p=pParse.aColCache... p++) - { - p = pParse.aColCache[i]; - int r = p.iReg; - if (r >= iFrom && r <= iTo) - return 1; /*NO_TEST*/ - } - return 0; - } + static void sqlite3ExprCodeCopy( Parse pParse, int iFrom, int iTo, int nReg ) + { + int i; + if ( NEVER( iFrom == iTo ) ) + return; + for ( i = 0; i < nReg; i++ ) + { + sqlite3VdbeAddOp2( pParse.pVdbe, OP_Copy, iFrom + i, iTo + i ); + } + } + +#if (SQLITE_DEBUG) || (SQLITE_COVERAGE_TEST) + /* +** Return true if any register in the range iFrom..iTo (inclusive) +** is used as part of the column cache. +** +** This routine is used within Debug.Assert() and testcase() macros only +** and does not appear in a normal build. +*/ + static int usedAsColumnCache( Parse pParse, int iFrom, int iTo ) + { + int i; + yColCache p; + for ( i = 0; i < SQLITE_N_COLCACHE; i++ )//p=pParse.aColCache... p++) + { + p = pParse.aColCache[i]; + int r = p.iReg; + if ( r >= iFrom && r <= iTo ) + return 1; /*NO_TEST*/ + } + return 0; + } #else static int usedAsColumnCache( Parse pParse, int iFrom, int iTo ){return 0;} #endif //* SQLITE_DEBUG || SQLITE_COVERAGE_TEST */ - /* - ** 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. - ** - ** With this routine, there is no guarantee that results will - ** be stored in target. The result might be stored in some other - ** register if it is convenient to do so. The calling function - ** must check the return code and move the results to the desired - ** register. - */ - static int sqlite3ExprCodeTarget(Parse pParse, Expr pExpr, int target) { - Vdbe v = pParse.pVdbe; /* The VM under construction */ - int op; /* The opcode being coded */ - int inReg = target; /* Results stored in register inReg */ - int regFree1 = 0; /* If non-zero free this temporary register */ - int regFree2 = 0; /* If non-zero free this temporary register */ - int r1 = 0, r2 = 0, r3 = 0, r4 = 0; /* Various register numbers */ - sqlite3 db = pParse.db; /* The database connection */ - - Debug.Assert(target > 0 && target <= pParse.nMem); - if (v == null) { - //Debug.Assert( pParse.db.mallocFailed != 0 ); - return 0; + /* + ** 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. + ** + ** With this routine, there is no guarantee that results will + ** be stored in target. The result might be stored in some other + ** register if it is convenient to do so. The calling function + ** must check the return code and move the results to the desired + ** register. + */ + static int sqlite3ExprCodeTarget( Parse pParse, Expr pExpr, int target ) + { + Vdbe v = pParse.pVdbe; /* The VM under construction */ + int op; /* The opcode being coded */ + int inReg = target; /* Results stored in register inReg */ + int regFree1 = 0; /* If non-zero free this temporary register */ + int regFree2 = 0; /* If non-zero free this temporary register */ + int r1 = 0, r2 = 0, r3 = 0, r4 = 0; /* Various register numbers */ + sqlite3 db = pParse.db; /* The database connection */ + + Debug.Assert( target > 0 && target <= pParse.nMem ); + if ( v == null ) + { + //Debug.Assert( pParse.db.mallocFailed != 0 ); + return 0; + } + + if ( pExpr == null ) + { + op = TK_NULL; + } + else + { + op = pExpr.op; + } + switch ( op ) + { + case TK_AGG_COLUMN: + { + AggInfo pAggInfo = pExpr.pAggInfo; + AggInfo_col pCol = pAggInfo.aCol[pExpr.iAgg]; + if ( pAggInfo.directMode == 0 ) + { + Debug.Assert( pCol.iMem > 0 ); + inReg = pCol.iMem; + break; } - - if (pExpr == null) { - op = TK_NULL; - } else { - op = pExpr.op; + else if ( pAggInfo.useSortingIdx != 0 ) + { + sqlite3VdbeAddOp3( v, OP_Column, pAggInfo.sortingIdx, + pCol.iSorterColumn, target ); + break; } - switch (op) { - case TK_AGG_COLUMN: { - AggInfo pAggInfo = pExpr.pAggInfo; - AggInfo_col pCol = pAggInfo.aCol[pExpr.iAgg]; - if (pAggInfo.directMode == 0) { - Debug.Assert(pCol.iMem > 0); - inReg = pCol.iMem; - break; - } else if (pAggInfo.useSortingIdx != 0) { - sqlite3VdbeAddOp3(v, OP_Column, pAggInfo.sortingIdx, - pCol.iSorterColumn, target); - break; - } - /* Otherwise, fall thru into the TK_COLUMN case */ - } - goto case TK_COLUMN; - case TK_COLUMN: { - if (pExpr.iTable < 0) { - /* This only happens when coding check constraints */ - Debug.Assert(pParse.ckBase > 0); - inReg = pExpr.iColumn + pParse.ckBase; - } else { - inReg = sqlite3ExprCodeGetColumn(pParse, pExpr.pTab, - pExpr.iColumn, pExpr.iTable, target); - } - break; - } - case TK_INTEGER: { - codeInteger(pParse, pExpr, false, target); - break; - } + /* Otherwise, fall thru into the TK_COLUMN case */ + } + goto case TK_COLUMN; + case TK_COLUMN: + { + if ( pExpr.iTable < 0 ) + { + /* This only happens when coding check constraints */ + Debug.Assert( pParse.ckBase > 0 ); + inReg = pExpr.iColumn + pParse.ckBase; + } + else + { + inReg = sqlite3ExprCodeGetColumn( pParse, pExpr.pTab, + pExpr.iColumn, pExpr.iTable, target ); + } + break; + } + case TK_INTEGER: + { + codeInteger( pParse, pExpr, false, target ); + break; + } #if !SQLITE_OMIT_FLOATING_POINT - case TK_FLOAT: { - Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); - codeReal(v, pExpr.u.zToken, false, target); - break; - } + case TK_FLOAT: + { + Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); + codeReal( v, pExpr.u.zToken, false, target ); + break; + } #endif - case TK_STRING: { - Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); - sqlite3VdbeAddOp4(v, OP_String8, 0, target, 0, pExpr.u.zToken, 0); - break; - } - case TK_NULL: { - sqlite3VdbeAddOp2(v, OP_Null, 0, target); - break; - } + case TK_STRING: + { + Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); + sqlite3VdbeAddOp4( v, OP_String8, 0, target, 0, pExpr.u.zToken, 0 ); + break; + } + case TK_NULL: + { + sqlite3VdbeAddOp2( v, OP_Null, 0, target ); + break; + } #if !SQLITE_OMIT_BLOB_LITERAL - case TK_BLOB: { - int n; - string z; - byte[] zBlob; - Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); - Debug.Assert(pExpr.u.zToken[0] == 'x' || pExpr.u.zToken[0] == 'X'); - Debug.Assert(pExpr.u.zToken[1] == '\''); - z = pExpr.u.zToken.Substring(2); - n = sqlite3Strlen30(z) - 1; - Debug.Assert(z[n] == '\''); - zBlob = sqlite3HexToBlob(sqlite3VdbeDb(v), z, n); - sqlite3VdbeAddOp4(v, OP_Blob, n / 2, target, 0, zBlob, P4_DYNAMIC); - break; - } + case TK_BLOB: + { + int n; + string z; + byte[] zBlob; + Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); + Debug.Assert( pExpr.u.zToken[0] == 'x' || pExpr.u.zToken[0] == 'X' ); + Debug.Assert( pExpr.u.zToken[1] == '\'' ); + z = pExpr.u.zToken.Substring( 2 ); + n = sqlite3Strlen30( z ) - 1; + Debug.Assert( z[n] == '\'' ); + zBlob = sqlite3HexToBlob( sqlite3VdbeDb( v ), z, n ); + sqlite3VdbeAddOp4( v, OP_Blob, n / 2, target, 0, zBlob, P4_DYNAMIC ); + break; + } #endif - case TK_VARIABLE: { - Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); - Debug.Assert(pExpr.u.zToken != null); - Debug.Assert(pExpr.u.zToken.Length != 0); - sqlite3VdbeAddOp2(v, OP_Variable, pExpr.iColumn, target); - if (pExpr.u.zToken.Length > 1) { - Debug.Assert(pExpr.u.zToken[0] == '?' - || string.Equals(pExpr.u.zToken, pParse.azVar[pExpr.iColumn - 1], StringComparison.Ordinal)); - sqlite3VdbeChangeP4(v, -1, pParse.azVar[pExpr.iColumn - 1], P4_STATIC); - } - break; - } - case TK_REGISTER: { - inReg = pExpr.iTable; - break; - } - case TK_AS: { - inReg = sqlite3ExprCodeTarget(pParse, pExpr.pLeft, target); - break; - } + case TK_VARIABLE: + { + Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); + Debug.Assert( pExpr.u.zToken != null ); + Debug.Assert( pExpr.u.zToken.Length != 0 ); + sqlite3VdbeAddOp2( v, OP_Variable, pExpr.iColumn, target ); + if ( pExpr.u.zToken.Length > 1 ) + { + Debug.Assert( pExpr.u.zToken[0] == '?' + || string.Equals(pExpr.u.zToken, pParse.azVar[pExpr.iColumn - 1], StringComparison.Ordinal) ); + sqlite3VdbeChangeP4( v, -1, pParse.azVar[pExpr.iColumn - 1], P4_STATIC ); + } + break; + } + case TK_REGISTER: + { + inReg = pExpr.iTable; + break; + } + case TK_AS: + { + inReg = sqlite3ExprCodeTarget( pParse, pExpr.pLeft, target ); + break; + } #if !SQLITE_OMIT_CAST - case TK_CAST: { - /* Expressions of the form: CAST(pLeft AS token) */ - int aff, to_op; - inReg = sqlite3ExprCodeTarget(pParse, pExpr.pLeft, target); - Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); - aff = sqlite3AffinityType(pExpr.u.zToken); - to_op = aff - SQLITE_AFF_TEXT + OP_ToText; - Debug.Assert(to_op == OP_ToText || aff != SQLITE_AFF_TEXT); - Debug.Assert(to_op == OP_ToBlob || aff != SQLITE_AFF_NONE); - Debug.Assert(to_op == OP_ToNumeric || aff != SQLITE_AFF_NUMERIC); - Debug.Assert(to_op == OP_ToInt || aff != SQLITE_AFF_INTEGER); - Debug.Assert(to_op == OP_ToReal || aff != SQLITE_AFF_REAL); - testcase(to_op == OP_ToText); - testcase(to_op == OP_ToBlob); - testcase(to_op == OP_ToNumeric); - testcase(to_op == OP_ToInt); - testcase(to_op == OP_ToReal); - if (inReg != target) { - sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target); - inReg = target; - } - sqlite3VdbeAddOp1(v, to_op, inReg); - testcase(usedAsColumnCache(pParse, inReg, inReg) != 0); - sqlite3ExprCacheAffinityChange(pParse, inReg, 1); - break; - } + case TK_CAST: + { + /* Expressions of the form: CAST(pLeft AS token) */ + int aff, to_op; + inReg = sqlite3ExprCodeTarget( pParse, pExpr.pLeft, target ); + Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); + aff = sqlite3AffinityType( pExpr.u.zToken ); + to_op = aff - SQLITE_AFF_TEXT + OP_ToText; + Debug.Assert( to_op == OP_ToText || aff != SQLITE_AFF_TEXT ); + Debug.Assert( to_op == OP_ToBlob || aff != SQLITE_AFF_NONE ); + Debug.Assert( to_op == OP_ToNumeric || aff != SQLITE_AFF_NUMERIC ); + Debug.Assert( to_op == OP_ToInt || aff != SQLITE_AFF_INTEGER ); + Debug.Assert( to_op == OP_ToReal || aff != SQLITE_AFF_REAL ); + testcase( to_op == OP_ToText ); + testcase( to_op == OP_ToBlob ); + testcase( to_op == OP_ToNumeric ); + testcase( to_op == OP_ToInt ); + testcase( to_op == OP_ToReal ); + if ( inReg != target ) + { + sqlite3VdbeAddOp2( v, OP_SCopy, inReg, target ); + inReg = target; + } + sqlite3VdbeAddOp1( v, to_op, inReg ); + testcase( usedAsColumnCache( pParse, inReg, inReg ) != 0 ); + sqlite3ExprCacheAffinityChange( pParse, inReg, 1 ); + break; + } #endif // * SQLITE_OMIT_CAST */ - case TK_LT: - case TK_LE: - case TK_GT: - case TK_GE: - case TK_NE: - case TK_EQ: { - Debug.Assert(TK_LT == OP_Lt); - Debug.Assert(TK_LE == OP_Le); - Debug.Assert(TK_GT == OP_Gt); - Debug.Assert(TK_GE == OP_Ge); - Debug.Assert(TK_EQ == OP_Eq); - Debug.Assert(TK_NE == OP_Ne); - testcase(op == TK_LT); - testcase(op == TK_LE); - testcase(op == TK_GT); - testcase(op == TK_GE); - testcase(op == TK_EQ); - testcase(op == TK_NE); - r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); - r2 = sqlite3ExprCodeTemp(pParse, pExpr.pRight, ref regFree2); - codeCompare(pParse, pExpr.pLeft, pExpr.pRight, op, - r1, r2, inReg, SQLITE_STOREP2); - testcase(regFree1 == 0); - testcase(regFree2 == 0); - break; - } - case TK_IS: - case TK_ISNOT: { - testcase(op == TK_IS); - testcase(op == TK_ISNOT); - r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); - r2 = sqlite3ExprCodeTemp(pParse, pExpr.pRight, ref regFree2); - op = (op == TK_IS) ? TK_EQ : TK_NE; - codeCompare(pParse, pExpr.pLeft, pExpr.pRight, op, - r1, r2, inReg, SQLITE_STOREP2 | SQLITE_NULLEQ); - testcase(regFree1 == 0); - testcase(regFree2 == 0); - break; - } - case TK_AND: - case TK_OR: - case TK_PLUS: - case TK_STAR: - case TK_MINUS: - case TK_REM: - case TK_BITAND: - case TK_BITOR: - case TK_SLASH: - case TK_LSHIFT: - case TK_RSHIFT: - case TK_CONCAT: { - Debug.Assert(TK_AND == OP_And); - Debug.Assert(TK_OR == OP_Or); - Debug.Assert(TK_PLUS == OP_Add); - Debug.Assert(TK_MINUS == OP_Subtract); - Debug.Assert(TK_REM == OP_Remainder); - Debug.Assert(TK_BITAND == OP_BitAnd); - Debug.Assert(TK_BITOR == OP_BitOr); - Debug.Assert(TK_SLASH == OP_Divide); - Debug.Assert(TK_LSHIFT == OP_ShiftLeft); - Debug.Assert(TK_RSHIFT == OP_ShiftRight); - Debug.Assert(TK_CONCAT == OP_Concat); - testcase(op == TK_AND); - testcase(op == TK_OR); - testcase(op == TK_PLUS); - testcase(op == TK_MINUS); - testcase(op == TK_REM); - testcase(op == TK_BITAND); - testcase(op == TK_BITOR); - testcase(op == TK_SLASH); - testcase(op == TK_LSHIFT); - testcase(op == TK_RSHIFT); - testcase(op == TK_CONCAT); - r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); - r2 = sqlite3ExprCodeTemp(pParse, pExpr.pRight, ref regFree2); - sqlite3VdbeAddOp3(v, op, r2, r1, target); - testcase(regFree1 == 0); - testcase(regFree2 == 0); - break; - } - case TK_UMINUS: { - Expr pLeft = pExpr.pLeft; - Debug.Assert(pLeft != null); - if (pLeft.op == TK_INTEGER) { - codeInteger(pParse, pLeft, true, target); + case TK_LT: + case TK_LE: + case TK_GT: + case TK_GE: + case TK_NE: + case TK_EQ: + { + Debug.Assert( TK_LT == OP_Lt ); + Debug.Assert( TK_LE == OP_Le ); + Debug.Assert( TK_GT == OP_Gt ); + Debug.Assert( TK_GE == OP_Ge ); + Debug.Assert( TK_EQ == OP_Eq ); + Debug.Assert( TK_NE == OP_Ne ); + testcase( op == TK_LT ); + testcase( op == TK_LE ); + testcase( op == TK_GT ); + testcase( op == TK_GE ); + testcase( op == TK_EQ ); + testcase( op == TK_NE ); + r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); + r2 = sqlite3ExprCodeTemp( pParse, pExpr.pRight, ref regFree2 ); + codeCompare( pParse, pExpr.pLeft, pExpr.pRight, op, + r1, r2, inReg, SQLITE_STOREP2 ); + testcase( regFree1 == 0 ); + testcase( regFree2 == 0 ); + break; + } + case TK_IS: + case TK_ISNOT: + { + testcase( op == TK_IS ); + testcase( op == TK_ISNOT ); + r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); + r2 = sqlite3ExprCodeTemp( pParse, pExpr.pRight, ref regFree2 ); + op = ( op == TK_IS ) ? TK_EQ : TK_NE; + codeCompare( pParse, pExpr.pLeft, pExpr.pRight, op, + r1, r2, inReg, SQLITE_STOREP2 | SQLITE_NULLEQ ); + testcase( regFree1 == 0 ); + testcase( regFree2 == 0 ); + break; + } + case TK_AND: + case TK_OR: + case TK_PLUS: + case TK_STAR: + case TK_MINUS: + case TK_REM: + case TK_BITAND: + case TK_BITOR: + case TK_SLASH: + case TK_LSHIFT: + case TK_RSHIFT: + case TK_CONCAT: + { + Debug.Assert( TK_AND == OP_And ); + Debug.Assert( TK_OR == OP_Or ); + Debug.Assert( TK_PLUS == OP_Add ); + Debug.Assert( TK_MINUS == OP_Subtract ); + Debug.Assert( TK_REM == OP_Remainder ); + Debug.Assert( TK_BITAND == OP_BitAnd ); + Debug.Assert( TK_BITOR == OP_BitOr ); + Debug.Assert( TK_SLASH == OP_Divide ); + Debug.Assert( TK_LSHIFT == OP_ShiftLeft ); + Debug.Assert( TK_RSHIFT == OP_ShiftRight ); + Debug.Assert( TK_CONCAT == OP_Concat ); + testcase( op == TK_AND ); + testcase( op == TK_OR ); + testcase( op == TK_PLUS ); + testcase( op == TK_MINUS ); + testcase( op == TK_REM ); + testcase( op == TK_BITAND ); + testcase( op == TK_BITOR ); + testcase( op == TK_SLASH ); + testcase( op == TK_LSHIFT ); + testcase( op == TK_RSHIFT ); + testcase( op == TK_CONCAT ); + r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); + r2 = sqlite3ExprCodeTemp( pParse, pExpr.pRight, ref regFree2 ); + sqlite3VdbeAddOp3( v, op, r2, r1, target ); + testcase( regFree1 == 0 ); + testcase( regFree2 == 0 ); + break; + } + case TK_UMINUS: + { + Expr pLeft = pExpr.pLeft; + Debug.Assert( pLeft != null ); + if ( pLeft.op == TK_INTEGER ) + { + codeInteger( pParse, pLeft, true, target ); #if !SQLITE_OMIT_FLOATING_POINT - } else if (pLeft.op == TK_FLOAT) { - Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); - codeReal(v, pLeft.u.zToken, true, target); + } + else if ( pLeft.op == TK_FLOAT ) + { + Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); + codeReal( v, pLeft.u.zToken, true, target ); #endif - } else { - regFree1 = r1 = sqlite3GetTempReg(pParse); - sqlite3VdbeAddOp2(v, OP_Integer, 0, r1); - r2 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree2); - sqlite3VdbeAddOp3(v, OP_Subtract, r2, r1, target); - testcase(regFree2 == 0); - } - inReg = target; - break; - } - case TK_BITNOT: - case TK_NOT: { - Debug.Assert(TK_BITNOT == OP_BitNot); - Debug.Assert(TK_NOT == OP_Not); - testcase(op == TK_BITNOT); - testcase(op == TK_NOT); - r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); - testcase(regFree1 == 0); - inReg = target; - sqlite3VdbeAddOp2(v, op, r1, inReg); - break; - } - case TK_ISNULL: - case TK_NOTNULL: { - int addr; - Debug.Assert(TK_ISNULL == OP_IsNull); - Debug.Assert(TK_NOTNULL == OP_NotNull); - testcase(op == TK_ISNULL); - testcase(op == TK_NOTNULL); - sqlite3VdbeAddOp2(v, OP_Integer, 1, target); - r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); - testcase(regFree1 == 0); - addr = sqlite3VdbeAddOp1(v, op, r1); - sqlite3VdbeAddOp2(v, OP_AddImm, target, -1); - sqlite3VdbeJumpHere(v, addr); - break; - } - case TK_AGG_FUNCTION: { - AggInfo pInfo = pExpr.pAggInfo; - if (pInfo == null) { - Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); - sqlite3ErrorMsg(pParse, "misuse of aggregate: %s()", pExpr.u.zToken); - } else { - inReg = pInfo.aFunc[pExpr.iAgg].iMem; - } - break; - } - case TK_CONST_FUNC: - case TK_FUNCTION: { - ExprList pFarg; /* List of function arguments */ - int nFarg; /* Number of function arguments */ - FuncDef pDef; /* The function definition object */ - int nId; /* Length of the function name in bytes */ - string zId; /* The function name */ - int constMask = 0; /* Mask of function arguments that are constant */ - int i; /* Loop counter */ - u8 enc = ENC(db); /* The text encoding used by this database */ - CollSeq pColl = null; /* A collating sequence */ - - Debug.Assert(!ExprHasProperty(pExpr, EP_xIsSelect)); - testcase(op == TK_CONST_FUNC); - testcase(op == TK_FUNCTION); - if (ExprHasAnyProperty(pExpr, EP_TokenOnly)) { - pFarg = null; - } else { - pFarg = pExpr.x.pList; - } - nFarg = pFarg != null ? pFarg.nExpr : 0; - Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); - zId = pExpr.u.zToken; - nId = sqlite3Strlen30(zId); - pDef = sqlite3FindFunction(pParse.db, zId, nId, nFarg, enc, 0); - if (pDef == null) { - sqlite3ErrorMsg(pParse, "unknown function: %.*s()", nId, zId); - break; - } + } + else + { + regFree1 = r1 = sqlite3GetTempReg( pParse ); + sqlite3VdbeAddOp2( v, OP_Integer, 0, r1 ); + r2 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree2 ); + sqlite3VdbeAddOp3( v, OP_Subtract, r2, r1, target ); + testcase( regFree2 == 0 ); + } + inReg = target; + break; + } + case TK_BITNOT: + case TK_NOT: + { + Debug.Assert( TK_BITNOT == OP_BitNot ); + Debug.Assert( TK_NOT == OP_Not ); + testcase( op == TK_BITNOT ); + testcase( op == TK_NOT ); + r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); + testcase( regFree1 == 0 ); + inReg = target; + sqlite3VdbeAddOp2( v, op, r1, inReg ); + break; + } + case TK_ISNULL: + case TK_NOTNULL: + { + int addr; + Debug.Assert( TK_ISNULL == OP_IsNull ); + Debug.Assert( TK_NOTNULL == OP_NotNull ); + testcase( op == TK_ISNULL ); + testcase( op == TK_NOTNULL ); + sqlite3VdbeAddOp2( v, OP_Integer, 1, target ); + r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); + testcase( regFree1 == 0 ); + addr = sqlite3VdbeAddOp1( v, op, r1 ); + sqlite3VdbeAddOp2( v, OP_AddImm, target, -1 ); + sqlite3VdbeJumpHere( v, addr ); + break; + } + case TK_AGG_FUNCTION: + { + AggInfo pInfo = pExpr.pAggInfo; + if ( pInfo == null ) + { + Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); + sqlite3ErrorMsg( pParse, "misuse of aggregate: %s()", pExpr.u.zToken ); + } + else + { + inReg = pInfo.aFunc[pExpr.iAgg].iMem; + } + break; + } + case TK_CONST_FUNC: + case TK_FUNCTION: + { + ExprList pFarg; /* List of function arguments */ + int nFarg; /* Number of function arguments */ + FuncDef pDef; /* The function definition object */ + int nId; /* Length of the function name in bytes */ + string zId; /* The function name */ + int constMask = 0; /* Mask of function arguments that are constant */ + int i; /* Loop counter */ + u8 enc = ENC( db ); /* The text encoding used by this database */ + CollSeq pColl = null; /* A collating sequence */ + + Debug.Assert( !ExprHasProperty( pExpr, EP_xIsSelect ) ); + testcase( op == TK_CONST_FUNC ); + testcase( op == TK_FUNCTION ); + if ( ExprHasAnyProperty( pExpr, EP_TokenOnly ) ) + { + pFarg = null; + } + else + { + pFarg = pExpr.x.pList; + } + nFarg = pFarg != null ? pFarg.nExpr : 0; + Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); + zId = pExpr.u.zToken; + nId = sqlite3Strlen30( zId ); + pDef = sqlite3FindFunction( pParse.db, zId, nId, nFarg, enc, 0 ); + if ( pDef == null ) + { + sqlite3ErrorMsg( pParse, "unknown function: %.*s()", nId, zId ); + break; + } - /* Attempt a direct implementation of the built-in COALESCE() and - ** IFNULL() functions. This avoids unnecessary evalation of - ** arguments past the first non-NULL argument. - */ - if ((pDef.flags & SQLITE_FUNC_COALESCE) != 0) { - int endCoalesce = sqlite3VdbeMakeLabel(v); - Debug.Assert(nFarg >= 2); - sqlite3ExprCode(pParse, pFarg.a[0].pExpr, target); - for (i = 1; i < nFarg; i++) { - sqlite3VdbeAddOp2(v, OP_NotNull, target, endCoalesce); - sqlite3ExprCacheRemove(pParse, target, 1); - sqlite3ExprCachePush(pParse); - sqlite3ExprCode(pParse, pFarg.a[i].pExpr, target); - sqlite3ExprCachePop(pParse, 1); - } - sqlite3VdbeResolveLabel(v, endCoalesce); - break; - } + /* Attempt a direct implementation of the built-in COALESCE() and + ** IFNULL() functions. This avoids unnecessary evalation of + ** arguments past the first non-NULL argument. + */ + if ( ( pDef.flags & SQLITE_FUNC_COALESCE ) != 0 ) + { + int endCoalesce = sqlite3VdbeMakeLabel( v ); + Debug.Assert( nFarg >= 2 ); + sqlite3ExprCode( pParse, pFarg.a[0].pExpr, target ); + for ( i = 1; i < nFarg; i++ ) + { + sqlite3VdbeAddOp2( v, OP_NotNull, target, endCoalesce ); + sqlite3ExprCacheRemove( pParse, target, 1 ); + sqlite3ExprCachePush( pParse ); + sqlite3ExprCode( pParse, pFarg.a[i].pExpr, target ); + sqlite3ExprCachePop( pParse, 1 ); + } + sqlite3VdbeResolveLabel( v, endCoalesce ); + break; + } - if (pFarg != null) { - r1 = sqlite3GetTempRange(pParse, nFarg); - sqlite3ExprCachePush(pParse); /* Ticket 2ea2425d34be */ - sqlite3ExprCodeExprList(pParse, pFarg, r1, true); - sqlite3ExprCachePop(pParse, 1); /* Ticket 2ea2425d34be */ - } else { - r1 = 0; - } + if ( pFarg != null ) + { + r1 = sqlite3GetTempRange( pParse, nFarg ); + sqlite3ExprCachePush( pParse ); /* Ticket 2ea2425d34be */ + sqlite3ExprCodeExprList( pParse, pFarg, r1, true ); + sqlite3ExprCachePop( pParse, 1 ); /* Ticket 2ea2425d34be */ + } + else + { + r1 = 0; + } #if !SQLITE_OMIT_VIRTUALTABLE - /* Possibly overload the function if the first argument is - ** a virtual table column. - ** - ** For infix functions (LIKE, GLOB, REGEXP, and MATCH) use the - ** second argument, not the first, as the argument to test to - ** see if it is a column in a virtual table. This is done because - ** the left operand of infix functions (the operand we want to - ** control overloading) ends up as the second argument to the - ** function. The expression "A glob B" is equivalent to - ** "glob(B,A). We want to use the A in "A glob B" to test - ** for function overloading. But we use the B term in "glob(B,A)". - */ - if (nFarg >= 2 && (pExpr.flags & EP_InfixFunc) != 0) { - pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg.a[1].pExpr); - } else if (nFarg > 0) { - pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg.a[0].pExpr); - } +/* Possibly overload the function if the first argument is +** a virtual table column. +** +** For infix functions (LIKE, GLOB, REGEXP, and MATCH) use the +** second argument, not the first, as the argument to test to +** see if it is a column in a virtual table. This is done because +** the left operand of infix functions (the operand we want to +** control overloading) ends up as the second argument to the +** function. The expression "A glob B" is equivalent to +** "glob(B,A). We want to use the A in "A glob B" to test +** for function overloading. But we use the B term in "glob(B,A)". +*/ + if ( nFarg >= 2 && ( pExpr.flags & EP_InfixFunc ) != 0 ) + { + pDef = sqlite3VtabOverloadFunction( db, pDef, nFarg, pFarg.a[1].pExpr ); + } + else if ( nFarg > 0 ) + { + pDef = sqlite3VtabOverloadFunction( db, pDef, nFarg, pFarg.a[0].pExpr ); + } #endif - for (i = 0; i < nFarg; i++) { - if (i < 32 && sqlite3ExprIsConstant(pFarg.a[i].pExpr) != 0) { - constMask |= (1 << i); - } - if ((pDef.flags & SQLITE_FUNC_NEEDCOLL) != 0 && null == pColl) { - pColl = sqlite3ExprCollSeq(pParse, pFarg.a[i].pExpr); - } - } - if ((pDef.flags & SQLITE_FUNC_NEEDCOLL) != 0) { - if (null == pColl) - pColl = db.pDfltColl; - sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, pColl, P4_COLLSEQ); - } - sqlite3VdbeAddOp4(v, OP_Function, constMask, r1, target, - pDef, P4_FUNCDEF); - sqlite3VdbeChangeP5(v, (u8)nFarg); - if (nFarg != 0) { - sqlite3ReleaseTempRange(pParse, r1, nFarg); - } - break; - } + for ( i = 0; i < nFarg; i++ ) + { + if ( i < 32 && sqlite3ExprIsConstant( pFarg.a[i].pExpr ) != 0 ) + { + constMask |= ( 1 << i ); + } + if ( ( pDef.flags & SQLITE_FUNC_NEEDCOLL ) != 0 && null == pColl ) + { + pColl = sqlite3ExprCollSeq( pParse, pFarg.a[i].pExpr ); + } + } + if ( ( pDef.flags & SQLITE_FUNC_NEEDCOLL ) != 0 ) + { + if ( null == pColl ) + pColl = db.pDfltColl; + sqlite3VdbeAddOp4( v, OP_CollSeq, 0, 0, 0, pColl, P4_COLLSEQ ); + } + sqlite3VdbeAddOp4( v, OP_Function, constMask, r1, target, + pDef, P4_FUNCDEF ); + sqlite3VdbeChangeP5( v, (u8)nFarg ); + if ( nFarg != 0 ) + { + sqlite3ReleaseTempRange( pParse, r1, nFarg ); + } + break; + } #if !SQLITE_OMIT_SUBQUERY - case TK_EXISTS: - case TK_SELECT: { - testcase(op == TK_EXISTS); - testcase(op == TK_SELECT); - inReg = sqlite3CodeSubselect(pParse, pExpr, 0, false); - break; - } - case TK_IN: { - int destIfFalse = sqlite3VdbeMakeLabel(v); - int destIfNull = sqlite3VdbeMakeLabel(v); - sqlite3VdbeAddOp2(v, OP_Null, 0, target); - sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull); - sqlite3VdbeAddOp2(v, OP_Integer, 1, target); - sqlite3VdbeResolveLabel(v, destIfFalse); - sqlite3VdbeAddOp2(v, OP_AddImm, target, 0); - sqlite3VdbeResolveLabel(v, destIfNull); - break; - } + case TK_EXISTS: + case TK_SELECT: + { + testcase( op == TK_EXISTS ); + testcase( op == TK_SELECT ); + inReg = sqlite3CodeSubselect( pParse, pExpr, 0, false ); + break; + } + case TK_IN: + { + int destIfFalse = sqlite3VdbeMakeLabel( v ); + int destIfNull = sqlite3VdbeMakeLabel( v ); + sqlite3VdbeAddOp2( v, OP_Null, 0, target ); + sqlite3ExprCodeIN( pParse, pExpr, destIfFalse, destIfNull ); + sqlite3VdbeAddOp2( v, OP_Integer, 1, target ); + sqlite3VdbeResolveLabel( v, destIfFalse ); + sqlite3VdbeAddOp2( v, OP_AddImm, target, 0 ); + sqlite3VdbeResolveLabel( v, destIfNull ); + break; + } #endif //* SQLITE_OMIT_SUBQUERY */ - /* - ** x BETWEEN y AND z + /* +** x BETWEEN y AND z +** +** This is equivalent to +** +** x>=y AND x<=z +** +** X is stored in pExpr.pLeft. +** Y is stored in pExpr.x.pList.a[0].pExpr. +** Z is stored in pExpr.x.pList.a[1].pExpr. +*/ + case TK_BETWEEN: + { + Expr pLeft = pExpr.pLeft; + ExprList_item pLItem = pExpr.x.pList.a[0]; + Expr pRight = pLItem.pExpr; + r1 = sqlite3ExprCodeTemp( pParse, pLeft, ref regFree1 ); + r2 = sqlite3ExprCodeTemp( pParse, pRight, ref regFree2 ); + testcase( regFree1 == 0 ); + testcase( regFree2 == 0 ); + r3 = sqlite3GetTempReg( pParse ); + r4 = sqlite3GetTempReg( pParse ); + codeCompare( pParse, pLeft, pRight, OP_Ge, + r1, r2, r3, SQLITE_STOREP2 ); + pLItem = pExpr.x.pList.a[1];// pLItem++; + pRight = pLItem.pExpr; + sqlite3ReleaseTempReg( pParse, regFree2 ); + r2 = sqlite3ExprCodeTemp( pParse, pRight, ref regFree2 ); + testcase( regFree2 == 0 ); + codeCompare( pParse, pLeft, pRight, OP_Le, r1, r2, r4, SQLITE_STOREP2 ); + sqlite3VdbeAddOp3( v, OP_And, r3, r4, target ); + sqlite3ReleaseTempReg( pParse, r3 ); + sqlite3ReleaseTempReg( pParse, r4 ); + break; + } + case TK_UPLUS: + { + inReg = sqlite3ExprCodeTarget( pParse, pExpr.pLeft, target ); + break; + } + case TK_TRIGGER: + { + /* If the opcode is TK_TRIGGER, then the expression is a reference + ** to a column in the new.* or old.* pseudo-tables available to + ** trigger programs. In this case Expr.iTable is set to 1 for the + ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn + ** is set to the column of the pseudo-table to read, or to -1 to + ** read the rowid field. + ** + ** The expression is implemented using an OP_Param opcode. The p1 + ** parameter is set to 0 for an old.rowid reference, or to (i+1) + ** to reference another column of the old.* pseudo-table, where + ** i is the index of the column. For a new.rowid reference, p1 is + ** set to (n+1), where n is the number of columns in each pseudo-table. + ** For a reference to any other column in the new.* pseudo-table, p1 + ** is set to (n+2+i), where n and i are as defined previously. For + ** example, if the table on which triggers are being fired is + ** declared as: + ** + ** CREATE TABLE t1(a, b); + ** + ** Then p1 is interpreted as follows: + ** + ** p1==0 . old.rowid p1==3 . new.rowid + ** p1==1 . old.a p1==4 . new.a + ** p1==2 . old.b p1==5 . new.b + */ + Table pTab = pExpr.pTab; + int p1 = pExpr.iTable * ( pTab.nCol + 1 ) + 1 + pExpr.iColumn; + + Debug.Assert( pExpr.iTable == 0 || pExpr.iTable == 1 ); + Debug.Assert( pExpr.iColumn >= -1 && pExpr.iColumn < pTab.nCol ); + Debug.Assert( pTab.iPKey < 0 || pExpr.iColumn != pTab.iPKey ); + Debug.Assert( p1 >= 0 && p1 < ( pTab.nCol * 2 + 2 ) ); + + sqlite3VdbeAddOp2( v, OP_Param, p1, target ); + VdbeComment( v, "%s.%s -> $%d", + ( pExpr.iTable != 0 ? "new" : "old" ), + ( pExpr.iColumn < 0 ? "rowid" : pExpr.pTab.aCol[pExpr.iColumn].zName ), + target + ); + + /* If the column has REAL affinity, it may currently be stored as an + ** integer. Use OP_RealAffinity to make sure it is really real. */ + if ( pExpr.iColumn >= 0 + && pTab.aCol[pExpr.iColumn].affinity == SQLITE_AFF_REAL + ) + { + sqlite3VdbeAddOp1( v, OP_RealAffinity, target ); + } + break; + } + + /* + ** Form A: + ** CASE x WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END + ** + ** Form B: + ** CASE WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END ** - ** This is equivalent to + ** 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>=y AND x<=z + ** X (if it exists) is in pExpr.pLeft. + ** 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.x.pList.a[i*2] and Ri is pExpr.x.pList.a[i*2+1]. ** - ** X is stored in pExpr.pLeft. - ** Y is stored in pExpr.x.pList.a[0].pExpr. - ** Z is stored in pExpr.x.pList.a[1].pExpr. + ** 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. */ - case TK_BETWEEN: { - Expr pLeft = pExpr.pLeft; - ExprList_item pLItem = pExpr.x.pList.a[0]; - Expr pRight = pLItem.pExpr; - r1 = sqlite3ExprCodeTemp(pParse, pLeft, ref regFree1); - r2 = sqlite3ExprCodeTemp(pParse, pRight, ref regFree2); - testcase(regFree1 == 0); - testcase(regFree2 == 0); - r3 = sqlite3GetTempReg(pParse); - r4 = sqlite3GetTempReg(pParse); - codeCompare(pParse, pLeft, pRight, OP_Ge, - r1, r2, r3, SQLITE_STOREP2); - pLItem = pExpr.x.pList.a[1];// pLItem++; - pRight = pLItem.pExpr; - sqlite3ReleaseTempReg(pParse, regFree2); - r2 = sqlite3ExprCodeTemp(pParse, pRight, ref regFree2); - testcase(regFree2 == 0); - codeCompare(pParse, pLeft, pRight, OP_Le, r1, r2, r4, SQLITE_STOREP2); - sqlite3VdbeAddOp3(v, OP_And, r3, r4, target); - sqlite3ReleaseTempReg(pParse, r3); - sqlite3ReleaseTempReg(pParse, r4); - break; - } - case TK_UPLUS: { - inReg = sqlite3ExprCodeTarget(pParse, pExpr.pLeft, target); - break; - } - case TK_TRIGGER: { - /* If the opcode is TK_TRIGGER, then the expression is a reference - ** to a column in the new.* or old.* pseudo-tables available to - ** trigger programs. In this case Expr.iTable is set to 1 for the - ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn - ** is set to the column of the pseudo-table to read, or to -1 to - ** read the rowid field. - ** - ** The expression is implemented using an OP_Param opcode. The p1 - ** parameter is set to 0 for an old.rowid reference, or to (i+1) - ** to reference another column of the old.* pseudo-table, where - ** i is the index of the column. For a new.rowid reference, p1 is - ** set to (n+1), where n is the number of columns in each pseudo-table. - ** For a reference to any other column in the new.* pseudo-table, p1 - ** is set to (n+2+i), where n and i are as defined previously. For - ** example, if the table on which triggers are being fired is - ** declared as: - ** - ** CREATE TABLE t1(a, b); - ** - ** Then p1 is interpreted as follows: - ** - ** p1==0 . old.rowid p1==3 . new.rowid - ** p1==1 . old.a p1==4 . new.a - ** p1==2 . old.b p1==5 . new.b - */ - Table pTab = pExpr.pTab; - int p1 = pExpr.iTable * (pTab.nCol + 1) + 1 + pExpr.iColumn; - - Debug.Assert(pExpr.iTable == 0 || pExpr.iTable == 1); - Debug.Assert(pExpr.iColumn >= -1 && pExpr.iColumn < pTab.nCol); - Debug.Assert(pTab.iPKey < 0 || pExpr.iColumn != pTab.iPKey); - Debug.Assert(p1 >= 0 && p1 < (pTab.nCol * 2 + 2)); - - sqlite3VdbeAddOp2(v, OP_Param, p1, target); - VdbeComment(v, "%s.%s -> $%d", - (pExpr.iTable != 0 ? "new" : "old"), - (pExpr.iColumn < 0 ? "rowid" : pExpr.pTab.aCol[pExpr.iColumn].zName), - target - ); - - /* If the column has REAL affinity, it may currently be stored as an - ** integer. Use OP_RealAffinity to make sure it is really real. */ - if (pExpr.iColumn >= 0 - && pTab.aCol[pExpr.iColumn].affinity == SQLITE_AFF_REAL - ) { - sqlite3VdbeAddOp1(v, OP_RealAffinity, target); - } - break; - } - - /* - ** Form A: - ** CASE x WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END - ** - ** Form B: - ** CASE WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END - ** - ** 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 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.x.pList.a[i*2] and Ri is pExpr.x.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. - */ - default: { - Debug.Assert(op == TK_CASE); - int endLabel; /* GOTO label for end of CASE stmt */ - int nextCase; /* GOTO label for next WHEN clause */ - int nExpr; /* 2x number of WHEN terms */ - int i; /* Loop counter */ - ExprList pEList; /* List of WHEN terms */ - ExprList_item[] aListelem; /* Array of WHEN terms */ - Expr opCompare = new Expr(); /* The X==Ei expression */ - Expr cacheX; /* Cached expression X */ - Expr pX; /* The X expression */ - Expr pTest = null; /* X==Ei (form A) or just Ei (form B) */ + default: + { + Debug.Assert( op == TK_CASE ); + int endLabel; /* GOTO label for end of CASE stmt */ + int nextCase; /* GOTO label for next WHEN clause */ + int nExpr; /* 2x number of WHEN terms */ + int i; /* Loop counter */ + ExprList pEList; /* List of WHEN terms */ + ExprList_item[] aListelem; /* Array of WHEN terms */ + Expr opCompare = new Expr(); /* The X==Ei expression */ + Expr cacheX; /* Cached expression X */ + Expr pX; /* The X expression */ + Expr pTest = null; /* X==Ei (form A) or just Ei (form B) */ #if !NDEBUG - int iCacheLevel = pParse.iCacheLevel; - //VVA_ONLY( int iCacheLevel = pParse.iCacheLevel; ) + int iCacheLevel = pParse.iCacheLevel; + //VVA_ONLY( int iCacheLevel = pParse.iCacheLevel; ) #endif - Debug.Assert(!ExprHasProperty(pExpr, EP_xIsSelect) && pExpr.x.pList != null); - Debug.Assert((pExpr.x.pList.nExpr % 2) == 0); - Debug.Assert(pExpr.x.pList.nExpr > 0); - pEList = pExpr.x.pList; - aListelem = pEList.a; - nExpr = pEList.nExpr; - endLabel = sqlite3VdbeMakeLabel(v); - if ((pX = pExpr.pLeft) != null) { - cacheX = pX; - testcase(pX.op == TK_COLUMN); - testcase(pX.op == TK_REGISTER); - cacheX.iTable = sqlite3ExprCodeTemp(pParse, pX, ref regFree1); - 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; i < nExpr; i = i + 2) { - sqlite3ExprCachePush(pParse); - if (pX != null) { - Debug.Assert(pTest != null); - opCompare.pRight = aListelem[i].pExpr; - } else { - pTest = aListelem[i].pExpr; - } - nextCase = sqlite3VdbeMakeLabel(v); - testcase(pTest.op == TK_COLUMN); - sqlite3ExprIfFalse(pParse, pTest, nextCase, SQLITE_JUMPIFNULL); - testcase(aListelem[i + 1].pExpr.op == TK_COLUMN); - testcase(aListelem[i + 1].pExpr.op == TK_REGISTER); - sqlite3ExprCode(pParse, aListelem[i + 1].pExpr, target); - sqlite3VdbeAddOp2(v, OP_Goto, 0, endLabel); - sqlite3ExprCachePop(pParse, 1); - sqlite3VdbeResolveLabel(v, nextCase); - } - if (pExpr.pRight != null) { - sqlite3ExprCachePush(pParse); - sqlite3ExprCode(pParse, pExpr.pRight, target); - sqlite3ExprCachePop(pParse, 1); - } else { - sqlite3VdbeAddOp2(v, OP_Null, 0, target); - } + Debug.Assert( !ExprHasProperty( pExpr, EP_xIsSelect ) && pExpr.x.pList != null ); + Debug.Assert( ( pExpr.x.pList.nExpr % 2 ) == 0 ); + Debug.Assert( pExpr.x.pList.nExpr > 0 ); + pEList = pExpr.x.pList; + aListelem = pEList.a; + nExpr = pEList.nExpr; + endLabel = sqlite3VdbeMakeLabel( v ); + if ( ( pX = pExpr.pLeft ) != null ) + { + cacheX = pX; + testcase( pX.op == TK_COLUMN ); + testcase( pX.op == TK_REGISTER ); + cacheX.iTable = sqlite3ExprCodeTemp( pParse, pX, ref regFree1 ); + 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; i < nExpr; i = i + 2 ) + { + sqlite3ExprCachePush( pParse ); + if ( pX != null ) + { + Debug.Assert( pTest != null ); + opCompare.pRight = aListelem[i].pExpr; + } + else + { + pTest = aListelem[i].pExpr; + } + nextCase = sqlite3VdbeMakeLabel( v ); + testcase( pTest.op == TK_COLUMN ); + sqlite3ExprIfFalse( pParse, pTest, nextCase, SQLITE_JUMPIFNULL ); + testcase( aListelem[i + 1].pExpr.op == TK_COLUMN ); + testcase( aListelem[i + 1].pExpr.op == TK_REGISTER ); + sqlite3ExprCode( pParse, aListelem[i + 1].pExpr, target ); + sqlite3VdbeAddOp2( v, OP_Goto, 0, endLabel ); + sqlite3ExprCachePop( pParse, 1 ); + sqlite3VdbeResolveLabel( v, nextCase ); + } + if ( pExpr.pRight != null ) + { + sqlite3ExprCachePush( pParse ); + sqlite3ExprCode( pParse, pExpr.pRight, target ); + sqlite3ExprCachePop( pParse, 1 ); + } + else + { + sqlite3VdbeAddOp2( v, OP_Null, 0, target ); + } #if !NDEBUG - Debug.Assert( /* db.mallocFailed != 0 || */ pParse.nErr > 0 - || pParse.iCacheLevel == iCacheLevel); + Debug.Assert( /* db.mallocFailed != 0 || */ pParse.nErr > 0 + || pParse.iCacheLevel == iCacheLevel ); #endif - sqlite3VdbeResolveLabel(v, endLabel); - break; - } + sqlite3VdbeResolveLabel( v, endLabel ); + break; + } #if !SQLITE_OMIT_TRIGGER - case TK_RAISE: { - Debug.Assert(pExpr.affinity == OE_Rollback - || pExpr.affinity == OE_Abort - || pExpr.affinity == OE_Fail - || pExpr.affinity == OE_Ignore - ); - if (null == pParse.pTriggerTab) { - sqlite3ErrorMsg(pParse, - "RAISE() may only be used within a trigger-program"); - return 0; - } - if (pExpr.affinity == OE_Abort) { - sqlite3MayAbort(pParse); - } - Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); - if (pExpr.affinity == OE_Ignore) { - sqlite3VdbeAddOp4( - v, OP_Halt, SQLITE_OK, OE_Ignore, 0, pExpr.u.zToken, 0); - } else { - sqlite3HaltConstraint(pParse, pExpr.affinity, pExpr.u.zToken, 0); - } + case TK_RAISE: + { + Debug.Assert( pExpr.affinity == OE_Rollback + || pExpr.affinity == OE_Abort + || pExpr.affinity == OE_Fail + || pExpr.affinity == OE_Ignore + ); + if ( null == pParse.pTriggerTab ) + { + sqlite3ErrorMsg( pParse, + "RAISE() may only be used within a trigger-program" ); + return 0; + } + if ( pExpr.affinity == OE_Abort ) + { + sqlite3MayAbort( pParse ); + } + Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); + if ( pExpr.affinity == OE_Ignore ) + { + sqlite3VdbeAddOp4( + v, OP_Halt, SQLITE_OK, OE_Ignore, 0, pExpr.u.zToken, 0 ); + } + else + { + sqlite3HaltConstraint( pParse, pExpr.affinity, pExpr.u.zToken, 0 ); + } - break; - } + break; + } #endif - } - sqlite3ReleaseTempReg(pParse, regFree1); - sqlite3ReleaseTempReg(pParse, regFree2); - return inReg; - } + } + sqlite3ReleaseTempReg( pParse, regFree1 ); + sqlite3ReleaseTempReg( pParse, regFree2 ); + return inReg; + } - /* - ** Generate code to evaluate an expression and store the results - ** into a register. Return the register number where the results - ** are stored. - ** - ** If the register is a temporary register that can be deallocated, - ** then write its number into pReg. If the result register is not - ** a temporary, then set pReg to zero. - */ - static int sqlite3ExprCodeTemp(Parse pParse, Expr pExpr, ref int pReg) { - int r1 = sqlite3GetTempReg(pParse); - int r2 = sqlite3ExprCodeTarget(pParse, pExpr, r1); - if (r2 == r1) { - pReg = r1; - } else { - sqlite3ReleaseTempReg(pParse, r1); - pReg = 0; - } - return r2; - } + /* + ** Generate code to evaluate an expression and store the results + ** into a register. Return the register number where the results + ** are stored. + ** + ** If the register is a temporary register that can be deallocated, + ** then write its number into pReg. If the result register is not + ** a temporary, then set pReg to zero. + */ + static int sqlite3ExprCodeTemp( Parse pParse, Expr pExpr, ref int pReg ) + { + int r1 = sqlite3GetTempReg( pParse ); + int r2 = sqlite3ExprCodeTarget( pParse, pExpr, r1 ); + if ( r2 == r1 ) + { + pReg = r1; + } + else + { + sqlite3ReleaseTempReg( pParse, r1 ); + pReg = 0; + } + return r2; + } - /* - ** Generate code that will evaluate expression pExpr and store the - ** results in register target. The results are guaranteed to appear - ** in register target. - */ - static int sqlite3ExprCode(Parse pParse, Expr pExpr, int target) { - int inReg; - - Debug.Assert(target > 0 && target <= pParse.nMem); - if (pExpr != null && pExpr.op == TK_REGISTER) { - sqlite3VdbeAddOp2(pParse.pVdbe, OP_Copy, pExpr.iTable, target); - } else { - inReg = sqlite3ExprCodeTarget(pParse, pExpr, target); - Debug.Assert(pParse.pVdbe != null /* || pParse.db.mallocFailed != 0 */ ); - if (inReg != target && pParse.pVdbe != null) { - sqlite3VdbeAddOp2(pParse.pVdbe, OP_SCopy, inReg, target); - } - } - return target; + /* + ** Generate code that will evaluate expression pExpr and store the + ** results in register target. The results are guaranteed to appear + ** in register target. + */ + static int sqlite3ExprCode( Parse pParse, Expr pExpr, int target ) + { + int inReg; + + Debug.Assert( target > 0 && target <= pParse.nMem ); + if ( pExpr != null && pExpr.op == TK_REGISTER ) + { + sqlite3VdbeAddOp2( pParse.pVdbe, OP_Copy, pExpr.iTable, target ); + } + else + { + inReg = sqlite3ExprCodeTarget( pParse, pExpr, target ); + Debug.Assert( pParse.pVdbe != null /* || pParse.db.mallocFailed != 0 */ ); + if ( inReg != target && pParse.pVdbe != null ) + { + sqlite3VdbeAddOp2( pParse.pVdbe, OP_SCopy, inReg, target ); } + } + return target; + } - /* - ** Generate code that evalutes the given expression and puts the result - ** in register target. - ** - ** Also make a copy of the expression results into another "cache" register - ** and modify the expression so that the next time it is evaluated, - ** the result is a copy of the cache register. - ** - ** This routine is used for expressions that are used multiple - ** times. They are evaluated once and the results of the expression - ** are reused. - */ - static int sqlite3ExprCodeAndCache(Parse pParse, Expr pExpr, int target) { - Vdbe v = pParse.pVdbe; - int inReg; - inReg = sqlite3ExprCode(pParse, pExpr, target); - Debug.Assert(target > 0); - /* This routine is called for terms to INSERT or UPDATE. And the only - ** other place where expressions can be converted into TK_REGISTER is - ** in WHERE clause processing. So as currently implemented, there is - ** no way for a TK_REGISTER to exist here. But it seems prudent to - ** keep the ALWAYS() in case the conditions above change with future - ** modifications or enhancements. */ - if (ALWAYS(pExpr.op != TK_REGISTER)) { - int iMem; - iMem = ++pParse.nMem; - sqlite3VdbeAddOp2(v, OP_Copy, inReg, iMem); - pExpr.iTable = iMem; - pExpr.op2 = pExpr.op; - pExpr.op = TK_REGISTER; - } - return inReg; - } + /* + ** Generate code that evalutes the given expression and puts the result + ** in register target. + ** + ** Also make a copy of the expression results into another "cache" register + ** and modify the expression so that the next time it is evaluated, + ** the result is a copy of the cache register. + ** + ** This routine is used for expressions that are used multiple + ** times. They are evaluated once and the results of the expression + ** are reused. + */ + static int sqlite3ExprCodeAndCache( Parse pParse, Expr pExpr, int target ) + { + Vdbe v = pParse.pVdbe; + int inReg; + inReg = sqlite3ExprCode( pParse, pExpr, target ); + Debug.Assert( target > 0 ); + /* This routine is called for terms to INSERT or UPDATE. And the only + ** other place where expressions can be converted into TK_REGISTER is + ** in WHERE clause processing. So as currently implemented, there is + ** no way for a TK_REGISTER to exist here. But it seems prudent to + ** keep the ALWAYS() in case the conditions above change with future + ** modifications or enhancements. */ + if ( ALWAYS( pExpr.op != TK_REGISTER ) ) + { + int iMem; + iMem = ++pParse.nMem; + sqlite3VdbeAddOp2( v, OP_Copy, inReg, iMem ); + pExpr.iTable = iMem; + pExpr.op2 = pExpr.op; + pExpr.op = TK_REGISTER; + } + return inReg; + } - /* - ** Return TRUE if pExpr is an constant expression that is appropriate - ** for factoring out of a loop. Appropriate expressions are: - ** - ** * Any expression that evaluates to two or more opcodes. - ** - ** * Any OP_Integer, OP_Real, OP_String, OP_Blob, OP_Null, - ** or OP_Variable that does not need to be placed in a - ** specific register. - ** - ** There is no point in factoring out single-instruction constant - ** expressions that need to be placed in a particular register. - ** We could factor them out, but then we would end up adding an - ** OP_SCopy instruction to move the value into the correct register - ** later. We might as well just use the original instruction and - ** avoid the OP_SCopy. - */ - static int isAppropriateForFactoring(Expr p) { - if (sqlite3ExprIsConstantNotJoin(p) == 0) { - return 0; /* Only constant expressions are appropriate for factoring */ - } - if ((p.flags & EP_FixedDest) == 0) { - return 1; /* Any constant without a fixed destination is appropriate */ - } - while (p.op == TK_UPLUS) - p = p.pLeft; - switch (p.op) { -#if !SQLITE_OMIT_BLOB_LITERAL - case TK_BLOB: -#endif - case TK_VARIABLE: - case TK_INTEGER: - case TK_FLOAT: - case TK_NULL: - case TK_STRING: { - testcase(p.op == TK_BLOB); - testcase(p.op == TK_VARIABLE); - testcase(p.op == TK_INTEGER); - testcase(p.op == TK_FLOAT); - testcase(p.op == TK_NULL); - testcase(p.op == TK_STRING); - /* Single-instruction constants with a fixed destination are - ** better done in-line. If we factor them, they will just end - ** up generating an OP_SCopy to move the value to the destination - ** register. */ - return 0; - } - case TK_UMINUS: { - if (p.pLeft.op == TK_FLOAT || p.pLeft.op == TK_INTEGER) { - return 0; - } - break; - } - default: { - break; - } + /* + ** Return TRUE if pExpr is an constant expression that is appropriate + ** for factoring out of a loop. Appropriate expressions are: + ** + ** * Any expression that evaluates to two or more opcodes. + ** + ** * Any OP_Integer, OP_Real, OP_String, OP_Blob, OP_Null, + ** or OP_Variable that does not need to be placed in a + ** specific register. + ** + ** There is no point in factoring out single-instruction constant + ** expressions that need to be placed in a particular register. + ** We could factor them out, but then we would end up adding an + ** OP_SCopy instruction to move the value into the correct register + ** later. We might as well just use the original instruction and + ** avoid the OP_SCopy. + */ + static int isAppropriateForFactoring( Expr p ) + { + if ( sqlite3ExprIsConstantNotJoin( p ) == 0 ) + { + return 0; /* Only constant expressions are appropriate for factoring */ + } + if ( ( p.flags & EP_FixedDest ) == 0 ) + { + return 1; /* Any constant without a fixed destination is appropriate */ + } + while ( p.op == TK_UPLUS ) + p = p.pLeft; + switch ( p.op ) + { +#if !SQLITE_OMIT_BLOB_LITERAL + case TK_BLOB: +#endif + case TK_VARIABLE: + case TK_INTEGER: + case TK_FLOAT: + case TK_NULL: + case TK_STRING: + { + testcase( p.op == TK_BLOB ); + testcase( p.op == TK_VARIABLE ); + testcase( p.op == TK_INTEGER ); + testcase( p.op == TK_FLOAT ); + testcase( p.op == TK_NULL ); + testcase( p.op == TK_STRING ); + /* Single-instruction constants with a fixed destination are + ** better done in-line. If we factor them, they will just end + ** up generating an OP_SCopy to move the value to the destination + ** register. */ + return 0; + } + case TK_UMINUS: + { + if ( p.pLeft.op == TK_FLOAT || p.pLeft.op == TK_INTEGER ) + { + return 0; } - return 1; - } + break; + } + default: + { + break; + } + } + return 1; + } - /* - ** If pExpr is a constant expression that is appropriate for - ** factoring out of a loop, then evaluate the expression - ** into a register and convert the expression into a TK_REGISTER - ** expression. - */ - static int evalConstExpr(Walker pWalker, ref Expr pExpr) { - Parse pParse = pWalker.pParse; - switch (pExpr.op) { - case TK_IN: - case TK_REGISTER: { - return WRC_Prune; - } - case TK_FUNCTION: - case TK_AGG_FUNCTION: - case TK_CONST_FUNC: { - /* The arguments to a function have a fixed destination. - ** Mark them this way to avoid generated unneeded OP_SCopy - ** instructions. - */ - ExprList pList = pExpr.x.pList; - Debug.Assert(!ExprHasProperty(pExpr, EP_xIsSelect)); - if (pList != null) { - int i = pList.nExpr; - ExprList_item pItem;//= pList.a; - for (; i > 0; i--) {//, pItem++){ - pItem = pList.a[pList.nExpr - i]; - if (ALWAYS(pItem.pExpr != null)) - pItem.pExpr.flags |= EP_FixedDest; - } - } - break; - } - } - if (isAppropriateForFactoring(pExpr) != 0) { - int r1 = ++pParse.nMem; - int r2; - r2 = sqlite3ExprCodeTarget(pParse, pExpr, r1); - if (NEVER(r1 != r2)) - sqlite3ReleaseTempReg(pParse, r1); - pExpr.op2 = pExpr.op; - pExpr.op = TK_REGISTER; - pExpr.iTable = r2; - return WRC_Prune; + /* + ** If pExpr is a constant expression that is appropriate for + ** factoring out of a loop, then evaluate the expression + ** into a register and convert the expression into a TK_REGISTER + ** expression. + */ + static int evalConstExpr( Walker pWalker, ref Expr pExpr ) + { + Parse pParse = pWalker.pParse; + switch ( pExpr.op ) + { + case TK_IN: + case TK_REGISTER: + { + return WRC_Prune; + } + case TK_FUNCTION: + case TK_AGG_FUNCTION: + case TK_CONST_FUNC: + { + /* The arguments to a function have a fixed destination. + ** Mark them this way to avoid generated unneeded OP_SCopy + ** instructions. + */ + ExprList pList = pExpr.x.pList; + Debug.Assert( !ExprHasProperty( pExpr, EP_xIsSelect ) ); + if ( pList != null ) + { + int i = pList.nExpr; + ExprList_item pItem;//= pList.a; + for ( ; i > 0; i-- ) + {//, pItem++){ + pItem = pList.a[pList.nExpr - i]; + if ( ALWAYS( pItem.pExpr != null ) ) + pItem.pExpr.flags |= EP_FixedDest; + } } - return WRC_Continue; - } + break; + } + } + if ( isAppropriateForFactoring( pExpr ) != 0 ) + { + int r1 = ++pParse.nMem; + int r2; + r2 = sqlite3ExprCodeTarget( pParse, pExpr, r1 ); + if ( NEVER( r1 != r2 ) ) + sqlite3ReleaseTempReg( pParse, r1 ); + pExpr.op2 = pExpr.op; + pExpr.op = TK_REGISTER; + pExpr.iTable = r2; + return WRC_Prune; + } + return WRC_Continue; + } - /* - ** Preevaluate constant subexpressions within pExpr and store the - ** results in registers. Modify pExpr so that the constant subexpresions - ** are TK_REGISTER opcodes that refer to the precomputed values. - ** - ** This routine is a no-op if the jump to the cookie-check code has - ** already occur. Since the cookie-check jump is generated prior to - ** any other serious processing, this check ensures that there is no - ** way to accidently bypass the constant initializations. - ** - ** This routine is also a no-op if the SQLITE_FactorOutConst optimization - ** is disabled via the sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS) - ** interface. This allows test logic to verify that the same answer is - ** obtained for queries regardless of whether or not constants are - ** precomputed into registers or if they are inserted in-line. - */ - static void sqlite3ExprCodeConstants(Parse pParse, Expr pExpr) { - Walker w; - if (pParse.cookieGoto != 0) - return; - if ((pParse.db.flags & SQLITE_FactorOutConst) != 0) - return; - w = new Walker(); - w.xExprCallback = (dxExprCallback)evalConstExpr; - w.xSelectCallback = null; - w.pParse = pParse; - sqlite3WalkExpr(w, ref pExpr); - } + /* + ** Preevaluate constant subexpressions within pExpr and store the + ** results in registers. Modify pExpr so that the constant subexpresions + ** are TK_REGISTER opcodes that refer to the precomputed values. + ** + ** This routine is a no-op if the jump to the cookie-check code has + ** already occur. Since the cookie-check jump is generated prior to + ** any other serious processing, this check ensures that there is no + ** way to accidently bypass the constant initializations. + ** + ** This routine is also a no-op if the SQLITE_FactorOutConst optimization + ** is disabled via the sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS) + ** interface. This allows test logic to verify that the same answer is + ** obtained for queries regardless of whether or not constants are + ** precomputed into registers or if they are inserted in-line. + */ + static void sqlite3ExprCodeConstants( Parse pParse, Expr pExpr ) + { + Walker w; + if ( pParse.cookieGoto != 0 ) + return; + if ( ( pParse.db.flags & SQLITE_FactorOutConst ) != 0 ) + return; + w = new Walker(); + w.xExprCallback = (dxExprCallback)evalConstExpr; + w.xSelectCallback = null; + w.pParse = pParse; + sqlite3WalkExpr( w, ref pExpr ); + } - /* - ** Generate code that pushes the value of every element of the given - ** expression list into a sequence of registers beginning at target. - ** - ** Return the number of elements evaluated. - */ - static int sqlite3ExprCodeExprList( - Parse pParse, /* Parsing context */ - ExprList pList, /* The expression list to be coded */ - int target, /* Where to write results */ - bool doHardCopy /* Make a hard copy of every element */ - ) { - ExprList_item pItem; - int i, n; - Debug.Assert(pList != null); - Debug.Assert(target > 0); - Debug.Assert(pParse.pVdbe != null); /* Never gets this far otherwise */ - n = pList.nExpr; - for (i = 0; i < n; i++)// pItem++) - { - pItem = pList.a[i]; - Expr pExpr = pItem.pExpr; - int inReg = sqlite3ExprCodeTarget(pParse, pExpr, target + i); - if (inReg != target + i) { - sqlite3VdbeAddOp2(pParse.pVdbe, doHardCopy ? OP_Copy : OP_SCopy, - inReg, target + i); - } - } - return n; + /* + ** Generate code that pushes the value of every element of the given + ** expression list into a sequence of registers beginning at target. + ** + ** Return the number of elements evaluated. + */ + static int sqlite3ExprCodeExprList( + Parse pParse, /* Parsing context */ + ExprList pList, /* The expression list to be coded */ + int target, /* Where to write results */ + bool doHardCopy /* Make a hard copy of every element */ + ) + { + ExprList_item pItem; + int i, n; + Debug.Assert( pList != null ); + Debug.Assert( target > 0 ); + Debug.Assert( pParse.pVdbe != null ); /* Never gets this far otherwise */ + n = pList.nExpr; + for ( i = 0; i < n; i++ )// pItem++) + { + pItem = pList.a[i]; + Expr pExpr = pItem.pExpr; + int inReg = sqlite3ExprCodeTarget( pParse, pExpr, target + i ); + if ( inReg != target + i ) + { + sqlite3VdbeAddOp2( pParse.pVdbe, doHardCopy ? OP_Copy : OP_SCopy, + inReg, target + i ); } + } + return n; + } - /* - ** Generate code for a BETWEEN operator. - ** - ** x BETWEEN y AND z - ** - ** The above is equivalent to - ** - ** x>=y AND x<=z - ** - ** Code it as such, taking care to do the common subexpression - ** elementation of x. - */ - static void exprCodeBetween( - Parse pParse, /* Parsing and code generating context */ - Expr pExpr, /* The BETWEEN expression */ - int dest, /* Jump here if the jump is taken */ - int jumpIfTrue, /* Take the jump if the BETWEEN is true */ - int jumpIfNull /* Take the jump if the BETWEEN is NULL */ - ) { - Expr exprAnd = new Expr(); /* The AND operator in x>=y AND x<=z */ - Expr compLeft = new Expr(); /* The x>=y term */ - Expr compRight = new Expr(); /* The x<=z term */ - Expr exprX; /* The x subexpression */ - int regFree1 = 0; /* Temporary use register */ - - Debug.Assert(!ExprHasProperty(pExpr, EP_xIsSelect)); - exprX = pExpr.pLeft.Copy(); - exprAnd.op = TK_AND; - exprAnd.pLeft = compLeft; - exprAnd.pRight = compRight; - compLeft.op = TK_GE; - 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; - exprX.iTable = sqlite3ExprCodeTemp(pParse, exprX, ref regFree1); - exprX.op = TK_REGISTER; - if (jumpIfTrue != 0) { - sqlite3ExprIfTrue(pParse, exprAnd, dest, jumpIfNull); - } else { - sqlite3ExprIfFalse(pParse, exprAnd, dest, jumpIfNull); - } - sqlite3ReleaseTempReg(pParse, regFree1); - - /* Ensure adequate test coverage */ - testcase(jumpIfTrue == 0 && jumpIfNull == 0 && regFree1 == 0); - testcase(jumpIfTrue == 0 && jumpIfNull == 0 && regFree1 != 0); - testcase(jumpIfTrue == 0 && jumpIfNull != 0 && regFree1 == 0); - testcase(jumpIfTrue == 0 && jumpIfNull != 0 && regFree1 != 0); - testcase(jumpIfTrue != 0 && jumpIfNull == 0 && regFree1 == 0); - testcase(jumpIfTrue != 0 && jumpIfNull == 0 && regFree1 != 0); - testcase(jumpIfTrue != 0 && jumpIfNull != 0 && regFree1 == 0); - testcase(jumpIfTrue != 0 && jumpIfNull != 0 && regFree1 != 0); - } - /* - ** Generate code for a boolean expression such that a jump is made - ** to the label "dest" if the expression is true but execution - ** continues straight thru if the expression is false. - ** - ** If the expression evaluates to NULL (neither true nor false), then - ** take the jump if the jumpIfNull flag is SQLITE_JUMPIFNULL. - ** - ** This code depends on the fact that certain token values (ex: TK_EQ) - ** are the same as opcode values (ex: OP_Eq) that implement the corresponding - ** operation. Special comments in vdbe.c and the mkopcodeh.awk script in - ** the make process cause these values to align. Assert()s in the code - ** below verify that the numbers are aligned correctly. - */ - static void sqlite3ExprIfTrue(Parse pParse, Expr pExpr, int dest, int jumpIfNull) { - Vdbe v = pParse.pVdbe; - int op = 0; - int regFree1 = 0; - int regFree2 = 0; - int r1 = 0, r2 = 0; - - Debug.Assert(jumpIfNull == SQLITE_JUMPIFNULL || jumpIfNull == 0); - if (NEVER(v == null)) - return; /* Existance of VDBE checked by caller */ - if (NEVER(pExpr == null)) - return; /* No way this can happen */ - op = pExpr.op; - switch (op) { - case TK_AND: { - int d2 = sqlite3VdbeMakeLabel(v); - testcase(jumpIfNull == 0); - sqlite3ExprCachePush(pParse); - sqlite3ExprIfFalse(pParse, pExpr.pLeft, d2, jumpIfNull ^ SQLITE_JUMPIFNULL); - sqlite3ExprIfTrue(pParse, pExpr.pRight, dest, jumpIfNull); - sqlite3VdbeResolveLabel(v, d2); - sqlite3ExprCachePop(pParse, 1); - break; - } - case TK_OR: { - testcase(jumpIfNull == 0); - sqlite3ExprIfTrue(pParse, pExpr.pLeft, dest, jumpIfNull); - sqlite3ExprIfTrue(pParse, pExpr.pRight, dest, jumpIfNull); - break; - } - case TK_NOT: { - testcase(jumpIfNull == 0); - sqlite3ExprIfFalse(pParse, pExpr.pLeft, dest, jumpIfNull); - break; - } - case TK_LT: - case TK_LE: - case TK_GT: - case TK_GE: - case TK_NE: - case TK_EQ: { - Debug.Assert(TK_LT == OP_Lt); - Debug.Assert(TK_LE == OP_Le); - Debug.Assert(TK_GT == OP_Gt); - Debug.Assert(TK_GE == OP_Ge); - Debug.Assert(TK_EQ == OP_Eq); - Debug.Assert(TK_NE == OP_Ne); - testcase(op == TK_LT); - testcase(op == TK_LE); - testcase(op == TK_GT); - testcase(op == TK_GE); - testcase(op == TK_EQ); - testcase(op == TK_NE); - testcase(jumpIfNull == 0); - r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); - r2 = sqlite3ExprCodeTemp(pParse, pExpr.pRight, ref regFree2); - codeCompare(pParse, pExpr.pLeft, pExpr.pRight, op, - r1, r2, dest, jumpIfNull); - testcase(regFree1 == 0); - testcase(regFree2 == 0); - break; - } - case TK_IS: - case TK_ISNOT: { - testcase(op == TK_IS); - testcase(op == TK_ISNOT); - r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); - r2 = sqlite3ExprCodeTemp(pParse, pExpr.pRight, ref regFree2); - op = (op == TK_IS) ? TK_EQ : TK_NE; - codeCompare(pParse, pExpr.pLeft, pExpr.pRight, op, - r1, r2, dest, SQLITE_NULLEQ); - testcase(regFree1 == 0); - testcase(regFree2 == 0); - break; - } - case TK_ISNULL: - case TK_NOTNULL: { - Debug.Assert(TK_ISNULL == OP_IsNull); - Debug.Assert(TK_NOTNULL == OP_NotNull); - testcase(op == TK_ISNULL); - testcase(op == TK_NOTNULL); - r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); - sqlite3VdbeAddOp2(v, op, r1, dest); - testcase(regFree1 == 0); - break; - } - case TK_BETWEEN: { - testcase(jumpIfNull == 0); - exprCodeBetween(pParse, pExpr, dest, 1, jumpIfNull); - break; - } + /* + ** Generate code for a BETWEEN operator. + ** + ** x BETWEEN y AND z + ** + ** The above is equivalent to + ** + ** x>=y AND x<=z + ** + ** Code it as such, taking care to do the common subexpression + ** elementation of x. + */ + static void exprCodeBetween( + Parse pParse, /* Parsing and code generating context */ + Expr pExpr, /* The BETWEEN expression */ + int dest, /* Jump here if the jump is taken */ + int jumpIfTrue, /* Take the jump if the BETWEEN is true */ + int jumpIfNull /* Take the jump if the BETWEEN is NULL */ + ) + { + Expr exprAnd = new Expr(); /* The AND operator in x>=y AND x<=z */ + Expr compLeft = new Expr(); /* The x>=y term */ + Expr compRight = new Expr(); /* The x<=z term */ + Expr exprX; /* The x subexpression */ + int regFree1 = 0; /* Temporary use register */ + + Debug.Assert( !ExprHasProperty( pExpr, EP_xIsSelect ) ); + exprX = pExpr.pLeft.Copy(); + exprAnd.op = TK_AND; + exprAnd.pLeft = compLeft; + exprAnd.pRight = compRight; + compLeft.op = TK_GE; + 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; + exprX.iTable = sqlite3ExprCodeTemp( pParse, exprX, ref regFree1 ); + exprX.op = TK_REGISTER; + if ( jumpIfTrue != 0 ) + { + sqlite3ExprIfTrue( pParse, exprAnd, dest, jumpIfNull ); + } + else + { + sqlite3ExprIfFalse( pParse, exprAnd, dest, jumpIfNull ); + } + sqlite3ReleaseTempReg( pParse, regFree1 ); + + /* Ensure adequate test coverage */ + testcase( jumpIfTrue == 0 && jumpIfNull == 0 && regFree1 == 0 ); + testcase( jumpIfTrue == 0 && jumpIfNull == 0 && regFree1 != 0 ); + testcase( jumpIfTrue == 0 && jumpIfNull != 0 && regFree1 == 0 ); + testcase( jumpIfTrue == 0 && jumpIfNull != 0 && regFree1 != 0 ); + testcase( jumpIfTrue != 0 && jumpIfNull == 0 && regFree1 == 0 ); + testcase( jumpIfTrue != 0 && jumpIfNull == 0 && regFree1 != 0 ); + testcase( jumpIfTrue != 0 && jumpIfNull != 0 && regFree1 == 0 ); + testcase( jumpIfTrue != 0 && jumpIfNull != 0 && regFree1 != 0 ); + } + /* + ** Generate code for a boolean expression such that a jump is made + ** to the label "dest" if the expression is true but execution + ** continues straight thru if the expression is false. + ** + ** If the expression evaluates to NULL (neither true nor false), then + ** take the jump if the jumpIfNull flag is SQLITE_JUMPIFNULL. + ** + ** This code depends on the fact that certain token values (ex: TK_EQ) + ** are the same as opcode values (ex: OP_Eq) that implement the corresponding + ** operation. Special comments in vdbe.c and the mkopcodeh.awk script in + ** the make process cause these values to align. Assert()s in the code + ** below verify that the numbers are aligned correctly. + */ + static void sqlite3ExprIfTrue( Parse pParse, Expr pExpr, int dest, int jumpIfNull ) + { + Vdbe v = pParse.pVdbe; + int op = 0; + int regFree1 = 0; + int regFree2 = 0; + int r1 = 0, r2 = 0; + + Debug.Assert( jumpIfNull == SQLITE_JUMPIFNULL || jumpIfNull == 0 ); + if ( NEVER( v == null ) ) + return; /* Existance of VDBE checked by caller */ + if ( NEVER( pExpr == null ) ) + return; /* No way this can happen */ + op = pExpr.op; + switch ( op ) + { + case TK_AND: + { + int d2 = sqlite3VdbeMakeLabel( v ); + testcase( jumpIfNull == 0 ); + sqlite3ExprCachePush( pParse ); + sqlite3ExprIfFalse( pParse, pExpr.pLeft, d2, jumpIfNull ^ SQLITE_JUMPIFNULL ); + sqlite3ExprIfTrue( pParse, pExpr.pRight, dest, jumpIfNull ); + sqlite3VdbeResolveLabel( v, d2 ); + sqlite3ExprCachePop( pParse, 1 ); + break; + } + case TK_OR: + { + testcase( jumpIfNull == 0 ); + sqlite3ExprIfTrue( pParse, pExpr.pLeft, dest, jumpIfNull ); + sqlite3ExprIfTrue( pParse, pExpr.pRight, dest, jumpIfNull ); + break; + } + case TK_NOT: + { + testcase( jumpIfNull == 0 ); + sqlite3ExprIfFalse( pParse, pExpr.pLeft, dest, jumpIfNull ); + break; + } + case TK_LT: + case TK_LE: + case TK_GT: + case TK_GE: + case TK_NE: + case TK_EQ: + { + Debug.Assert( TK_LT == OP_Lt ); + Debug.Assert( TK_LE == OP_Le ); + Debug.Assert( TK_GT == OP_Gt ); + Debug.Assert( TK_GE == OP_Ge ); + Debug.Assert( TK_EQ == OP_Eq ); + Debug.Assert( TK_NE == OP_Ne ); + testcase( op == TK_LT ); + testcase( op == TK_LE ); + testcase( op == TK_GT ); + testcase( op == TK_GE ); + testcase( op == TK_EQ ); + testcase( op == TK_NE ); + testcase( jumpIfNull == 0 ); + r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); + r2 = sqlite3ExprCodeTemp( pParse, pExpr.pRight, ref regFree2 ); + codeCompare( pParse, pExpr.pLeft, pExpr.pRight, op, + r1, r2, dest, jumpIfNull ); + testcase( regFree1 == 0 ); + testcase( regFree2 == 0 ); + break; + } + case TK_IS: + case TK_ISNOT: + { + testcase( op == TK_IS ); + testcase( op == TK_ISNOT ); + r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); + r2 = sqlite3ExprCodeTemp( pParse, pExpr.pRight, ref regFree2 ); + op = ( op == TK_IS ) ? TK_EQ : TK_NE; + codeCompare( pParse, pExpr.pLeft, pExpr.pRight, op, + r1, r2, dest, SQLITE_NULLEQ ); + testcase( regFree1 == 0 ); + testcase( regFree2 == 0 ); + break; + } + case TK_ISNULL: + case TK_NOTNULL: + { + Debug.Assert( TK_ISNULL == OP_IsNull ); + Debug.Assert( TK_NOTNULL == OP_NotNull ); + testcase( op == TK_ISNULL ); + testcase( op == TK_NOTNULL ); + r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); + sqlite3VdbeAddOp2( v, op, r1, dest ); + testcase( regFree1 == 0 ); + break; + } + case TK_BETWEEN: + { + testcase( jumpIfNull == 0 ); + exprCodeBetween( pParse, pExpr, dest, 1, jumpIfNull ); + break; + } #if SQLITE_OMIT_SUBQUERY case TK_IN: { @@ -3445,141 +3850,151 @@ static void sqlite3ExprIfTrue(Parse pParse, Expr pExpr, int dest, int jumpIfNull break; } #endif - default: { - r1 = sqlite3ExprCodeTemp(pParse, pExpr, ref regFree1); - sqlite3VdbeAddOp3(v, OP_If, r1, dest, jumpIfNull != 0 ? 1 : 0); - testcase(regFree1 == 0); - testcase(jumpIfNull == 0); - break; - } - } - sqlite3ReleaseTempReg(pParse, regFree1); - sqlite3ReleaseTempReg(pParse, regFree2); - } - - /* - ** Generate code for a boolean expression such that a jump is made - ** to the label "dest" if the expression is false but execution - ** continues straight thru if the expression is true. - ** - ** If the expression evaluates to NULL (neither true nor false) then - ** jump if jumpIfNull is SQLITE_JUMPIFNULL or fall through if jumpIfNull - ** is 0. - */ - static void sqlite3ExprIfFalse(Parse pParse, Expr pExpr, int dest, int jumpIfNull) { - Vdbe v = pParse.pVdbe; - int op = 0; - int regFree1 = 0; - int regFree2 = 0; - int r1 = 0, r2 = 0; - - Debug.Assert(jumpIfNull == SQLITE_JUMPIFNULL || jumpIfNull == 0); - if (NEVER(v == null)) - return; /* Existance of VDBE checked by caller */ - if (pExpr == null) - return; - - /* The value of pExpr.op and op are related as follows: - ** - ** pExpr.op op - ** --------- ---------- - ** TK_ISNULL OP_NotNull - ** TK_NOTNULL OP_IsNull - ** TK_NE OP_Eq - ** TK_EQ OP_Ne - ** TK_GT OP_Le - ** TK_LE OP_Gt - ** TK_GE OP_Lt - ** TK_LT OP_Ge - ** - ** For other values of pExpr.op, op is undefined and unused. - ** The value of TK_ and OP_ constants are arranged such that we - ** can compute the mapping above using the following expression. - ** Assert()s verify that the computation is correct. - */ - op = ((pExpr.op + (TK_ISNULL & 1)) ^ 1) - (TK_ISNULL & 1); + default: + { + r1 = sqlite3ExprCodeTemp( pParse, pExpr, ref regFree1 ); + sqlite3VdbeAddOp3( v, OP_If, r1, dest, jumpIfNull != 0 ? 1 : 0 ); + testcase( regFree1 == 0 ); + testcase( jumpIfNull == 0 ); + break; + } + } + sqlite3ReleaseTempReg( pParse, regFree1 ); + sqlite3ReleaseTempReg( pParse, regFree2 ); + } - /* Verify correct alignment of TK_ and OP_ constants - */ - Debug.Assert(pExpr.op != TK_ISNULL || op == OP_NotNull); - Debug.Assert(pExpr.op != TK_NOTNULL || op == OP_IsNull); - Debug.Assert(pExpr.op != TK_NE || op == OP_Eq); - Debug.Assert(pExpr.op != TK_EQ || op == OP_Ne); - Debug.Assert(pExpr.op != TK_LT || op == OP_Ge); - Debug.Assert(pExpr.op != TK_LE || op == OP_Gt); - Debug.Assert(pExpr.op != TK_GT || op == OP_Le); - Debug.Assert(pExpr.op != TK_GE || op == OP_Lt); - - switch (pExpr.op) { - case TK_AND: { - testcase(jumpIfNull == 0); - sqlite3ExprIfFalse(pParse, pExpr.pLeft, dest, jumpIfNull); - sqlite3ExprIfFalse(pParse, pExpr.pRight, dest, jumpIfNull); - break; - } - case TK_OR: { - int d2 = sqlite3VdbeMakeLabel(v); - testcase(jumpIfNull == 0); - sqlite3ExprCachePush(pParse); - sqlite3ExprIfTrue(pParse, pExpr.pLeft, d2, jumpIfNull ^ SQLITE_JUMPIFNULL); - sqlite3ExprIfFalse(pParse, pExpr.pRight, dest, jumpIfNull); - sqlite3VdbeResolveLabel(v, d2); - sqlite3ExprCachePop(pParse, 1); - break; - } - case TK_NOT: { - testcase(jumpIfNull == 0); - sqlite3ExprIfTrue(pParse, pExpr.pLeft, dest, jumpIfNull); - break; - } - case TK_LT: - case TK_LE: - case TK_GT: - case TK_GE: - case TK_NE: - case TK_EQ: { - testcase(op == TK_LT); - testcase(op == TK_LE); - testcase(op == TK_GT); - testcase(op == TK_GE); - testcase(op == TK_EQ); - testcase(op == TK_NE); - testcase(jumpIfNull == 0); - r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); - r2 = sqlite3ExprCodeTemp(pParse, pExpr.pRight, ref regFree2); - codeCompare(pParse, pExpr.pLeft, pExpr.pRight, op, - r1, r2, dest, jumpIfNull); - testcase(regFree1 == 0); - testcase(regFree2 == 0); - break; - } - case TK_IS: - case TK_ISNOT: { - testcase(pExpr.op == TK_IS); - testcase(pExpr.op == TK_ISNOT); - r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); - r2 = sqlite3ExprCodeTemp(pParse, pExpr.pRight, ref regFree2); - op = (pExpr.op == TK_IS) ? TK_NE : TK_EQ; - codeCompare(pParse, pExpr.pLeft, pExpr.pRight, op, - r1, r2, dest, SQLITE_NULLEQ); - testcase(regFree1 == 0); - testcase(regFree2 == 0); - break; - } - case TK_ISNULL: - case TK_NOTNULL: { - testcase(op == TK_ISNULL); - testcase(op == TK_NOTNULL); - r1 = sqlite3ExprCodeTemp(pParse, pExpr.pLeft, ref regFree1); - sqlite3VdbeAddOp2(v, op, r1, dest); - testcase(regFree1 == 0); - break; - } - case TK_BETWEEN: { - testcase(jumpIfNull == 0); - exprCodeBetween(pParse, pExpr, dest, 0, jumpIfNull); - break; - } + /* + ** Generate code for a boolean expression such that a jump is made + ** to the label "dest" if the expression is false but execution + ** continues straight thru if the expression is true. + ** + ** If the expression evaluates to NULL (neither true nor false) then + ** jump if jumpIfNull is SQLITE_JUMPIFNULL or fall through if jumpIfNull + ** is 0. + */ + static void sqlite3ExprIfFalse( Parse pParse, Expr pExpr, int dest, int jumpIfNull ) + { + Vdbe v = pParse.pVdbe; + int op = 0; + int regFree1 = 0; + int regFree2 = 0; + int r1 = 0, r2 = 0; + + Debug.Assert( jumpIfNull == SQLITE_JUMPIFNULL || jumpIfNull == 0 ); + if ( NEVER( v == null ) ) + return; /* Existance of VDBE checked by caller */ + if ( pExpr == null ) + return; + + /* The value of pExpr.op and op are related as follows: + ** + ** pExpr.op op + ** --------- ---------- + ** TK_ISNULL OP_NotNull + ** TK_NOTNULL OP_IsNull + ** TK_NE OP_Eq + ** TK_EQ OP_Ne + ** TK_GT OP_Le + ** TK_LE OP_Gt + ** TK_GE OP_Lt + ** TK_LT OP_Ge + ** + ** For other values of pExpr.op, op is undefined and unused. + ** The value of TK_ and OP_ constants are arranged such that we + ** can compute the mapping above using the following expression. + ** Assert()s verify that the computation is correct. + */ + op = ( ( pExpr.op + ( TK_ISNULL & 1 ) ) ^ 1 ) - ( TK_ISNULL & 1 ); + + /* Verify correct alignment of TK_ and OP_ constants + */ + Debug.Assert( pExpr.op != TK_ISNULL || op == OP_NotNull ); + Debug.Assert( pExpr.op != TK_NOTNULL || op == OP_IsNull ); + Debug.Assert( pExpr.op != TK_NE || op == OP_Eq ); + Debug.Assert( pExpr.op != TK_EQ || op == OP_Ne ); + Debug.Assert( pExpr.op != TK_LT || op == OP_Ge ); + Debug.Assert( pExpr.op != TK_LE || op == OP_Gt ); + Debug.Assert( pExpr.op != TK_GT || op == OP_Le ); + Debug.Assert( pExpr.op != TK_GE || op == OP_Lt ); + + switch ( pExpr.op ) + { + case TK_AND: + { + testcase( jumpIfNull == 0 ); + sqlite3ExprIfFalse( pParse, pExpr.pLeft, dest, jumpIfNull ); + sqlite3ExprIfFalse( pParse, pExpr.pRight, dest, jumpIfNull ); + break; + } + case TK_OR: + { + int d2 = sqlite3VdbeMakeLabel( v ); + testcase( jumpIfNull == 0 ); + sqlite3ExprCachePush( pParse ); + sqlite3ExprIfTrue( pParse, pExpr.pLeft, d2, jumpIfNull ^ SQLITE_JUMPIFNULL ); + sqlite3ExprIfFalse( pParse, pExpr.pRight, dest, jumpIfNull ); + sqlite3VdbeResolveLabel( v, d2 ); + sqlite3ExprCachePop( pParse, 1 ); + break; + } + case TK_NOT: + { + testcase( jumpIfNull == 0 ); + sqlite3ExprIfTrue( pParse, pExpr.pLeft, dest, jumpIfNull ); + break; + } + case TK_LT: + case TK_LE: + case TK_GT: + case TK_GE: + case TK_NE: + case TK_EQ: + { + testcase( op == TK_LT ); + testcase( op == TK_LE ); + testcase( op == TK_GT ); + testcase( op == TK_GE ); + testcase( op == TK_EQ ); + testcase( op == TK_NE ); + testcase( jumpIfNull == 0 ); + r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); + r2 = sqlite3ExprCodeTemp( pParse, pExpr.pRight, ref regFree2 ); + codeCompare( pParse, pExpr.pLeft, pExpr.pRight, op, + r1, r2, dest, jumpIfNull ); + testcase( regFree1 == 0 ); + testcase( regFree2 == 0 ); + break; + } + case TK_IS: + case TK_ISNOT: + { + testcase( pExpr.op == TK_IS ); + testcase( pExpr.op == TK_ISNOT ); + r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); + r2 = sqlite3ExprCodeTemp( pParse, pExpr.pRight, ref regFree2 ); + op = ( pExpr.op == TK_IS ) ? TK_NE : TK_EQ; + codeCompare( pParse, pExpr.pLeft, pExpr.pRight, op, + r1, r2, dest, SQLITE_NULLEQ ); + testcase( regFree1 == 0 ); + testcase( regFree2 == 0 ); + break; + } + case TK_ISNULL: + case TK_NOTNULL: + { + testcase( op == TK_ISNULL ); + testcase( op == TK_NOTNULL ); + r1 = sqlite3ExprCodeTemp( pParse, pExpr.pLeft, ref regFree1 ); + sqlite3VdbeAddOp2( v, op, r1, dest ); + testcase( regFree1 == 0 ); + break; + } + case TK_BETWEEN: + { + testcase( jumpIfNull == 0 ); + exprCodeBetween( pParse, pExpr, dest, 0, jumpIfNull ); + break; + } #if SQLITE_OMIT_SUBQUERY case TK_IN: { @@ -3596,379 +4011,432 @@ static void sqlite3ExprIfFalse(Parse pParse, Expr pExpr, int dest, int jumpIfNul break; } #endif - default: { - r1 = sqlite3ExprCodeTemp(pParse, pExpr, ref regFree1); - sqlite3VdbeAddOp3(v, OP_IfNot, r1, dest, jumpIfNull != 0 ? 1 : 0); - testcase(regFree1 == 0); - testcase(jumpIfNull == 0); - break; - } - } - sqlite3ReleaseTempReg(pParse, regFree1); - sqlite3ReleaseTempReg(pParse, regFree2); - } + default: + { + r1 = sqlite3ExprCodeTemp( pParse, pExpr, ref regFree1 ); + sqlite3VdbeAddOp3( v, OP_IfNot, r1, dest, jumpIfNull != 0 ? 1 : 0 ); + testcase( regFree1 == 0 ); + testcase( jumpIfNull == 0 ); + break; + } + } + sqlite3ReleaseTempReg( pParse, regFree1 ); + sqlite3ReleaseTempReg( pParse, regFree2 ); + } - /* - ** Do a deep comparison of two expression trees. Return 0 if the two - ** expressions are completely identical. Return 1 if they differ only - ** by a COLLATE operator at the top level. Return 2 if there are differences - ** other than the top-level COLLATE operator. - ** - ** Sometimes this routine will return 2 even if the two expressions - ** really are equivalent. If we cannot prove that the expressions are - ** identical, we return 2 just to be safe. So if this routine - ** returns 2, then you do not really know for certain if the two - ** expressions are the same. But if you get a 0 or 1 return, then you - ** can be sure the expressions are the same. In the places where - ** this routine is used, it does not hurt to get an extra 2 - that - ** just might result in some slightly slower code. But returning - ** an incorrect 0 or 1 could lead to a malfunction. - */ - static int sqlite3ExprCompare(Expr pA, Expr pB) { - if (pA == null || pB == null) { - return pB == pA ? 0 : 2; - } - Debug.Assert(!ExprHasAnyProperty(pA, EP_TokenOnly | EP_Reduced)); - Debug.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) - return 2; - if (sqlite3ExprCompare(pA.pLeft, pB.pLeft) != 0) - return 2; - if (sqlite3ExprCompare(pA.pRight, pB.pRight) != 0) - return 2; - if (sqlite3ExprListCompare(pA.x.pList, pB.x.pList) != 0) - return 2; - if (pA.iTable != pB.iTable || pA.iColumn != pB.iColumn) - return 2; - if (ExprHasProperty(pA, EP_IntValue)) { - if (!ExprHasProperty(pB, EP_IntValue) || pA.u.iValue != pB.u.iValue) { - return 2; - } - } else if (pA.op != TK_COLUMN && pA.u.zToken != null) { - if (ExprHasProperty(pB, EP_IntValue) || NEVER(pB.u.zToken == null)) - return 2; - if (!pA.u.zToken.Equals(pB.u.zToken, StringComparison.OrdinalIgnoreCase)) { - return 2; - } - } - if ((pA.flags & EP_ExpCollate) != (pB.flags & EP_ExpCollate)) - return 1; - if ((pA.flags & EP_ExpCollate) != 0 && pA.pColl != pB.pColl) - return 2; - return 0; + /* + ** Do a deep comparison of two expression trees. Return 0 if the two + ** expressions are completely identical. Return 1 if they differ only + ** by a COLLATE operator at the top level. Return 2 if there are differences + ** other than the top-level COLLATE operator. + ** + ** Sometimes this routine will return 2 even if the two expressions + ** really are equivalent. If we cannot prove that the expressions are + ** identical, we return 2 just to be safe. So if this routine + ** returns 2, then you do not really know for certain if the two + ** expressions are the same. But if you get a 0 or 1 return, then you + ** can be sure the expressions are the same. In the places where + ** this routine is used, it does not hurt to get an extra 2 - that + ** just might result in some slightly slower code. But returning + ** an incorrect 0 or 1 could lead to a malfunction. + */ + static int sqlite3ExprCompare( Expr pA, Expr pB ) + { + if ( pA == null || pB == null ) + { + return pB == pA ? 0 : 2; + } + Debug.Assert( !ExprHasAnyProperty( pA, EP_TokenOnly | EP_Reduced ) ); + Debug.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 ) + return 2; + if ( sqlite3ExprCompare( pA.pLeft, pB.pLeft ) != 0 ) + return 2; + if ( sqlite3ExprCompare( pA.pRight, pB.pRight ) != 0 ) + return 2; + if ( sqlite3ExprListCompare( pA.x.pList, pB.x.pList ) != 0 ) + return 2; + if ( pA.iTable != pB.iTable || pA.iColumn != pB.iColumn ) + return 2; + if ( ExprHasProperty( pA, EP_IntValue ) ) + { + if ( !ExprHasProperty( pB, EP_IntValue ) || pA.u.iValue != pB.u.iValue ) + { + return 2; } - - /* - ** Compare two ExprList objects. Return 0 if they are identical and - ** non-zero if they differ in any way. - ** - ** This routine might return non-zero for equivalent ExprLists. The - ** only consequence will be disabled optimizations. But this routine - ** must never return 0 if the two ExprList objects are different, or - ** a malfunction will result. - ** - ** Two NULL pointers are considered to be the same. But a NULL pointer - ** always differs from a non-NULL pointer. - */ - static int sqlite3ExprListCompare(ExprList pA, ExprList pB) { - int i; - if (pA == null && pB == null) - return 0; - if (pA == null || pB == null) - return 1; - if (pA.nExpr != pB.nExpr) - return 1; - for (i = 0; i < pA.nExpr; i++) { - Expr pExprA = pA.a[i].pExpr; - Expr pExprB = pB.a[i].pExpr; - if (pA.a[i].sortOrder != pB.a[i].sortOrder) - return 1; - if (sqlite3ExprCompare(pExprA, pExprB) != 0) - return 1; - } - return 0; + } + else if ( pA.op != TK_COLUMN && pA.u.zToken != null ) + { + if ( ExprHasProperty( pB, EP_IntValue ) || NEVER( pB.u.zToken == null ) ) + return 2; + if ( !pA.u.zToken.Equals( pB.u.zToken ,StringComparison.OrdinalIgnoreCase ) ) + { + return 2; } + } + if ( ( pA.flags & EP_ExpCollate ) != ( pB.flags & EP_ExpCollate ) ) + return 1; + if ( ( pA.flags & EP_ExpCollate ) != 0 && pA.pColl != pB.pColl ) + return 2; + return 0; + } - /* - ** Add a new element to the pAggInfo.aCol[] array. Return the index of - ** the new element. Return a negative number if malloc fails. - */ - static int addAggInfoColumn(sqlite3 db, AggInfo pInfo) { - int i = 0; - pInfo.aCol = sqlite3ArrayAllocate( - db, - pInfo.aCol, - -1,//sizeof(pInfo.aCol[0]), - 3, - ref pInfo.nColumn, - ref pInfo.nColumnAlloc, - ref i - ); - return i; - } + /* + ** Compare two ExprList objects. Return 0 if they are identical and + ** non-zero if they differ in any way. + ** + ** This routine might return non-zero for equivalent ExprLists. The + ** only consequence will be disabled optimizations. But this routine + ** must never return 0 if the two ExprList objects are different, or + ** a malfunction will result. + ** + ** Two NULL pointers are considered to be the same. But a NULL pointer + ** always differs from a non-NULL pointer. + */ + static int sqlite3ExprListCompare( ExprList pA, ExprList pB ) + { + int i; + if ( pA == null && pB == null ) + return 0; + if ( pA == null || pB == null ) + return 1; + if ( pA.nExpr != pB.nExpr ) + return 1; + for ( i = 0; i < pA.nExpr; i++ ) + { + Expr pExprA = pA.a[i].pExpr; + Expr pExprB = pB.a[i].pExpr; + if ( pA.a[i].sortOrder != pB.a[i].sortOrder ) + return 1; + if ( sqlite3ExprCompare( pExprA, pExprB ) != 0 ) + return 1; + } + return 0; + } - /* - ** Add a new element to the pAggInfo.aFunc[] array. Return the index of - ** the new element. Return a negative number if malloc fails. - */ - static int addAggInfoFunc(sqlite3 db, AggInfo pInfo) { - int i = 0; - pInfo.aFunc = sqlite3ArrayAllocate( - db, - pInfo.aFunc, - -1,//sizeof(pInfo.aFunc[0]), - 3, - ref pInfo.nFunc, - ref pInfo.nFuncAlloc, - ref i - ); - return i; - } + /* + ** Add a new element to the pAggInfo.aCol[] array. Return the index of + ** the new element. Return a negative number if malloc fails. + */ + static int addAggInfoColumn( sqlite3 db, AggInfo pInfo ) + { + int i = 0; + pInfo.aCol = sqlite3ArrayAllocate( + db, + pInfo.aCol, + -1,//sizeof(pInfo.aCol[0]), + 3, + ref pInfo.nColumn, + ref pInfo.nColumnAlloc, + ref i + ); + return i; + } - /* - ** This is the xExprCallback for a tree walker. It is used to - ** implement sqlite3ExprAnalyzeAggregates(). See sqlite3ExprAnalyzeAggregates - ** for additional information. - */ - static int analyzeAggregate(Walker pWalker, ref Expr pExpr) { - int i; - NameContext pNC = pWalker.u.pNC; - Parse pParse = pNC.pParse; - SrcList pSrcList = pNC.pSrcList; - AggInfo pAggInfo = pNC.pAggInfo; - - switch (pExpr.op) { - case TK_AGG_COLUMN: - case TK_COLUMN: { - testcase(pExpr.op == TK_AGG_COLUMN); - testcase(pExpr.op == TK_COLUMN); - /* Check to see if the column is in one of the tables in the FROM - ** clause of the aggregate query */ - if (ALWAYS(pSrcList != null)) { - SrcList_item pItem;// = pSrcList.a; - for (i = 0; i < pSrcList.nSrc; i++) {//, pItem++){ - pItem = pSrcList.a[i]; - AggInfo_col pCol; - Debug.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 - ** is not an entry there already. - */ - int k; - //pCol = pAggInfo.aCol; - for (k = 0; k < pAggInfo.nColumn; k++) {//, pCol++){ - pCol = pAggInfo.aCol[k]; - if (pCol.iTable == pExpr.iTable && - pCol.iColumn == pExpr.iColumn) { - break; - } - } - if ((k >= pAggInfo.nColumn) - && (k = addAggInfoColumn(pParse.db, pAggInfo)) >= 0 - ) { - pCol = pAggInfo.aCol[k]; - pCol.pTab = pExpr.pTab; - pCol.iTable = pExpr.iTable; - pCol.iColumn = pExpr.iColumn; - pCol.iMem = ++pParse.nMem; - pCol.iSorterColumn = -1; - pCol.pExpr = pExpr; - if (pAggInfo.pGroupBy != null) { - int j, n; - ExprList pGB = pAggInfo.pGroupBy; - ExprList_item pTerm;// = pGB.a; - n = pGB.nExpr; - for (j = 0; j < n; j++) {//, pTerm++){ - pTerm = pGB.a[j]; - Expr pE = pTerm.pExpr; - if (pE.op == TK_COLUMN && pE.iTable == pExpr.iTable && - pE.iColumn == pExpr.iColumn) { - pCol.iSorterColumn = j; - break; - } - } - } - if (pCol.iSorterColumn < 0) { - pCol.iSorterColumn = pAggInfo.nSortingColumn++; - } - } - /* 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. - */ - ExprSetIrreducible(pExpr); - pExpr.pAggInfo = pAggInfo; - pExpr.op = TK_AGG_COLUMN; - pExpr.iAgg = (short)k; - break; - } /* endif pExpr.iTable==pItem.iCursor */ - } /* end loop over pSrcList */ - } - return WRC_Prune; + /* + ** Add a new element to the pAggInfo.aFunc[] array. Return the index of + ** the new element. Return a negative number if malloc fails. + */ + static int addAggInfoFunc( sqlite3 db, AggInfo pInfo ) + { + int i = 0; + pInfo.aFunc = sqlite3ArrayAllocate( + db, + pInfo.aFunc, + -1,//sizeof(pInfo.aFunc[0]), + 3, + ref pInfo.nFunc, + ref pInfo.nFuncAlloc, + ref i + ); + return i; + } + + /* + ** This is the xExprCallback for a tree walker. It is used to + ** implement sqlite3ExprAnalyzeAggregates(). See sqlite3ExprAnalyzeAggregates + ** for additional information. + */ + static int analyzeAggregate( Walker pWalker, ref Expr pExpr ) + { + int i; + NameContext pNC = pWalker.u.pNC; + Parse pParse = pNC.pParse; + SrcList pSrcList = pNC.pSrcList; + AggInfo pAggInfo = pNC.pAggInfo; + + switch ( pExpr.op ) + { + case TK_AGG_COLUMN: + case TK_COLUMN: + { + testcase( pExpr.op == TK_AGG_COLUMN ); + testcase( pExpr.op == TK_COLUMN ); + /* Check to see if the column is in one of the tables in the FROM + ** clause of the aggregate query */ + if ( ALWAYS( pSrcList != null ) ) + { + SrcList_item pItem;// = pSrcList.a; + for ( i = 0; i < pSrcList.nSrc; i++ ) + {//, pItem++){ + pItem = pSrcList.a[i]; + AggInfo_col pCol; + Debug.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 + ** is not an entry there already. + */ + int k; + //pCol = pAggInfo.aCol; + for ( k = 0; k < pAggInfo.nColumn; k++ ) + {//, pCol++){ + pCol = pAggInfo.aCol[k]; + if ( pCol.iTable == pExpr.iTable && + pCol.iColumn == pExpr.iColumn ) + { + break; } - case TK_AGG_FUNCTION: { - /* The pNC.nDepth==0 test causes aggregate functions in subqueries - ** to be ignored */ - if (pNC.nDepth == 0) { - /* Check to see if pExpr is a duplicate of another aggregate - ** function that is already in the pAggInfo structure - */ - AggInfo_func pItem;// = pAggInfo.aFunc; - for (i = 0; i < pAggInfo.nFunc; i++) {//, pItem++){ - pItem = pAggInfo.aFunc[i]; - if (sqlite3ExprCompare(pItem.pExpr, pExpr) == 0) { - break; - } - } - if (i >= pAggInfo.nFunc) { - /* pExpr is original. Make a new entry in pAggInfo.aFunc[] - */ - u8 enc = pParse.db.aDbStatic[0].pSchema.enc;// ENC(pParse.db); - i = addAggInfoFunc(pParse.db, pAggInfo); - if (i >= 0) { - Debug.Assert(!ExprHasProperty(pExpr, EP_xIsSelect)); - pItem = pAggInfo.aFunc[i]; - pItem.pExpr = pExpr; - pItem.iMem = ++pParse.nMem; - Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); - pItem.pFunc = sqlite3FindFunction(pParse.db, - pExpr.u.zToken, sqlite3Strlen30(pExpr.u.zToken), - pExpr.x.pList != null ? pExpr.x.pList.nExpr : 0, enc, 0); - if ((pExpr.flags & EP_Distinct) != 0) { - pItem.iDistinct = pParse.nTab++; - } else { - pItem.iDistinct = -1; - } - } - } - /* Make pExpr point to the appropriate pAggInfo.aFunc[] entry - */ - Debug.Assert(!ExprHasAnyProperty(pExpr, EP_TokenOnly | EP_Reduced)); - ExprSetIrreducible(pExpr); - pExpr.iAgg = (short)i; - pExpr.pAggInfo = pAggInfo; - return WRC_Prune; + } + if ( ( k >= pAggInfo.nColumn ) + && ( k = addAggInfoColumn( pParse.db, pAggInfo ) ) >= 0 + ) + { + pCol = pAggInfo.aCol[k]; + pCol.pTab = pExpr.pTab; + pCol.iTable = pExpr.iTable; + pCol.iColumn = pExpr.iColumn; + pCol.iMem = ++pParse.nMem; + pCol.iSorterColumn = -1; + pCol.pExpr = pExpr; + if ( pAggInfo.pGroupBy != null ) + { + int j, n; + ExprList pGB = pAggInfo.pGroupBy; + ExprList_item pTerm;// = pGB.a; + n = pGB.nExpr; + for ( j = 0; j < n; j++ ) + {//, pTerm++){ + pTerm = pGB.a[j]; + Expr pE = pTerm.pExpr; + if ( pE.op == TK_COLUMN && pE.iTable == pExpr.iTable && + pE.iColumn == pExpr.iColumn ) + { + pCol.iSorterColumn = j; + break; } - break; + } + } + if ( pCol.iSorterColumn < 0 ) + { + pCol.iSorterColumn = pAggInfo.nSortingColumn++; } + } + /* 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. + */ + ExprSetIrreducible( pExpr ); + pExpr.pAggInfo = pAggInfo; + pExpr.op = TK_AGG_COLUMN; + pExpr.iAgg = (short)k; + break; + } /* endif pExpr.iTable==pItem.iCursor */ + } /* end loop over pSrcList */ } - return WRC_Continue; - } - - static int analyzeAggregatesInSelect(Walker pWalker, Select pSelect) { - NameContext pNC = pWalker.u.pNC; - if (pNC.nDepth == 0) { - pNC.nDepth++; - sqlite3WalkSelect(pWalker, pSelect); - pNC.nDepth--; - return WRC_Prune; - } else { - return WRC_Continue; + return WRC_Prune; + } + case TK_AGG_FUNCTION: + { + /* The pNC.nDepth==0 test causes aggregate functions in subqueries + ** to be ignored */ + if ( pNC.nDepth == 0 ) + { + /* Check to see if pExpr is a duplicate of another aggregate + ** function that is already in the pAggInfo structure + */ + AggInfo_func pItem;// = pAggInfo.aFunc; + for ( i = 0; i < pAggInfo.nFunc; i++ ) + {//, pItem++){ + pItem = pAggInfo.aFunc[i]; + if ( sqlite3ExprCompare( pItem.pExpr, pExpr ) == 0 ) + { + break; + } + } + if ( i >= pAggInfo.nFunc ) + { + /* pExpr is original. Make a new entry in pAggInfo.aFunc[] + */ + u8 enc = pParse.db.aDbStatic[0].pSchema.enc;// ENC(pParse.db); + i = addAggInfoFunc( pParse.db, pAggInfo ); + if ( i >= 0 ) + { + Debug.Assert( !ExprHasProperty( pExpr, EP_xIsSelect ) ); + pItem = pAggInfo.aFunc[i]; + pItem.pExpr = pExpr; + pItem.iMem = ++pParse.nMem; + Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); + pItem.pFunc = sqlite3FindFunction( pParse.db, + pExpr.u.zToken, sqlite3Strlen30( pExpr.u.zToken ), + pExpr.x.pList != null ? pExpr.x.pList.nExpr : 0, enc, 0 ); + if ( ( pExpr.flags & EP_Distinct ) != 0 ) + { + pItem.iDistinct = pParse.nTab++; + } + else + { + pItem.iDistinct = -1; + } + } + } + /* Make pExpr point to the appropriate pAggInfo.aFunc[] entry + */ + Debug.Assert( !ExprHasAnyProperty( pExpr, EP_TokenOnly | EP_Reduced ) ); + ExprSetIrreducible( pExpr ); + pExpr.iAgg = (short)i; + pExpr.pAggInfo = pAggInfo; + return WRC_Prune; } - } + break; + } + } + return WRC_Continue; + } + static int analyzeAggregatesInSelect( Walker pWalker, Select pSelect ) + { + NameContext pNC = pWalker.u.pNC; + if ( pNC.nDepth == 0 ) + { + pNC.nDepth++; + sqlite3WalkSelect( pWalker, pSelect ); + pNC.nDepth--; + return WRC_Prune; + } + else + { + return WRC_Continue; + } + } - /* - ** Analyze the given expression looking for aggregate functions and - ** for variables that need to be added to the pParse.aAgg[] array. - ** Make additional entries to the pParse.aAgg[] array as necessary. - ** - ** This routine should only be called after the expression has been - ** analyzed by sqlite3ResolveExprNames(). - */ - static void sqlite3ExprAnalyzeAggregates(NameContext pNC, ref Expr pExpr) { - Walker w = new Walker(); - w.xExprCallback = (dxExprCallback)analyzeAggregate; - w.xSelectCallback = (dxSelectCallback)analyzeAggregatesInSelect; - w.u.pNC = pNC; - Debug.Assert(pNC.pSrcList != null); - sqlite3WalkExpr(w, ref pExpr); - } - /* - ** Call sqlite3ExprAnalyzeAggregates() for every expression in an - ** expression list. Return the number of errors. - ** - ** If an error is found, the analysis is cut short. - */ - static void sqlite3ExprAnalyzeAggList(NameContext pNC, ExprList pList) { - ExprList_item pItem; - int i; - if (pList != null) { - for (i = 0; i < pList.nExpr; i++)//, pItem++) - { - pItem = pList.a[i]; - sqlite3ExprAnalyzeAggregates(pNC, ref pItem.pExpr); - } - } - } + /* + ** Analyze the given expression looking for aggregate functions and + ** for variables that need to be added to the pParse.aAgg[] array. + ** Make additional entries to the pParse.aAgg[] array as necessary. + ** + ** This routine should only be called after the expression has been + ** analyzed by sqlite3ResolveExprNames(). + */ + static void sqlite3ExprAnalyzeAggregates( NameContext pNC, ref Expr pExpr ) + { + Walker w = new Walker(); + w.xExprCallback = (dxExprCallback)analyzeAggregate; + w.xSelectCallback = (dxSelectCallback)analyzeAggregatesInSelect; + w.u.pNC = pNC; + Debug.Assert( pNC.pSrcList != null ); + sqlite3WalkExpr( w, ref pExpr ); + } - /* - ** Allocate a single new register for use to hold some intermediate result. - */ - static int sqlite3GetTempReg(Parse pParse) { - if (pParse.nTempReg == 0) { - return ++pParse.nMem; - } - return pParse.aTempReg[--pParse.nTempReg]; + /* + ** Call sqlite3ExprAnalyzeAggregates() for every expression in an + ** expression list. Return the number of errors. + ** + ** If an error is found, the analysis is cut short. + */ + static void sqlite3ExprAnalyzeAggList( NameContext pNC, ExprList pList ) + { + ExprList_item pItem; + int i; + if ( pList != null ) + { + for ( i = 0; i < pList.nExpr; i++ )//, pItem++) + { + pItem = pList.a[i]; + sqlite3ExprAnalyzeAggregates( pNC, ref pItem.pExpr ); } + } + } - /* - ** Deallocate a register, making available for reuse for some other - ** purpose. - ** - ** If a register is currently being used by the column cache, then - ** the dallocation is deferred until the column cache line that uses - ** the register becomes stale. - */ - static void sqlite3ReleaseTempReg(Parse pParse, int iReg) { - if (iReg != 0 && pParse.nTempReg < ArraySize(pParse.aTempReg)) { - int i; - yColCache p; - for (i = 0; i < SQLITE_N_COLCACHE; i++)//p=pParse.aColCache... p++) - { - p = pParse.aColCache[i]; - if (p.iReg == iReg) { - p.tempReg = 1; - return; - } - } - pParse.aTempReg[pParse.nTempReg++] = iReg; - } - } + /* + ** Allocate a single new register for use to hold some intermediate result. + */ + static int sqlite3GetTempReg( Parse pParse ) + { + if ( pParse.nTempReg == 0 ) + { + return ++pParse.nMem; + } + return pParse.aTempReg[--pParse.nTempReg]; + } - /* - ** Allocate or deallocate a block of nReg consecutive registers - */ - static int sqlite3GetTempRange(Parse pParse, int nReg) { - int i, n; - i = pParse.iRangeReg; - n = pParse.nRangeReg; - if (nReg <= n) { - //Debug.Assert( 1 == usedAsColumnCache( pParse, i, i + n - 1 ) ); - pParse.iRangeReg += nReg; - pParse.nRangeReg -= nReg; - } else { - i = pParse.nMem + 1; - pParse.nMem += nReg; - } - return i; - } - static void sqlite3ReleaseTempRange(Parse pParse, int iReg, int nReg) { - sqlite3ExprCacheRemove(pParse, iReg, nReg); - if (nReg > pParse.nRangeReg) { - pParse.nRangeReg = nReg; - pParse.iRangeReg = iReg; - } + /* + ** Deallocate a register, making available for reuse for some other + ** purpose. + ** + ** If a register is currently being used by the column cache, then + ** the dallocation is deferred until the column cache line that uses + ** the register becomes stale. + */ + static void sqlite3ReleaseTempReg( Parse pParse, int iReg ) + { + if ( iReg != 0 && pParse.nTempReg < ArraySize( pParse.aTempReg ) ) + { + int i; + yColCache p; + for ( i = 0; i < SQLITE_N_COLCACHE; i++ )//p=pParse.aColCache... p++) + { + p = pParse.aColCache[i]; + if ( p.iReg == iReg ) + { + p.tempReg = 1; + return; + } } + pParse.aTempReg[pParse.nTempReg++] = iReg; + } + } + + /* + ** Allocate or deallocate a block of nReg consecutive registers + */ + static int sqlite3GetTempRange( Parse pParse, int nReg ) + { + int i, n; + i = pParse.iRangeReg; + n = pParse.nRangeReg; + if ( nReg <= n ) + { + //Debug.Assert( 1 == usedAsColumnCache( pParse, i, i + n - 1 ) ); + pParse.iRangeReg += nReg; + pParse.nRangeReg -= nReg; + } + else + { + i = pParse.nMem + 1; + pParse.nMem += nReg; + } + return i; + } + static void sqlite3ReleaseTempRange( Parse pParse, int iReg, int nReg ) + { + sqlite3ExprCacheRemove( pParse, iReg, nReg ); + if ( nReg > pParse.nRangeReg ) + { + pParse.nRangeReg = nReg; + pParse.iRangeReg = iReg; + } } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/fault_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/fault_c.cs index 2faf4fa51..d94636d7e 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/fault_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/fault_c.cs @@ -1,104 +1,116 @@ -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2008 Jan 22 - ** - ** 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 contains code to support the concept of "benign" - ** malloc failures (when the xMalloc() or xRealloc() method of the - ** sqlite3_mem_methods structure fails to allocate a block of memory - ** and returns 0). - ** - ** Most malloc failures are non-benign. After they occur, SQLite - ** abandons the current operation and returns an error code (usually - ** SQLITE_NOMEM) to the user. However, sometimes a fault is not necessarily - ** fatal. For example, if a malloc fails while resizing a hash table, this - ** is completely recoverable simply by not carrying out the resize. The - ** hash table will continue to function normally. So a malloc failure - ** during a hash table resize is a benign fault. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +using System; +using System.Diagnostics; -#if !SQLITE_OMIT_BUILTIN_TEST - /* - ** Global variables. +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 2008 Jan 22 + ** + ** 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 contains code to support the concept of "benign" + ** malloc failures (when the xMalloc() or xRealloc() method of the + ** sqlite3_mem_methods structure fails to allocate a block of memory + ** and returns 0). + ** + ** Most malloc failures are non-benign. After they occur, SQLite + ** abandons the current operation and returns an error code (usually + ** SQLITE_NOMEM) to the user. However, sometimes a fault is not necessarily + ** fatal. For example, if a malloc fails while resizing a hash table, this + ** is completely recoverable simply by not carrying out the resize. The + ** hash table will continue to function normally. So a malloc failure + ** during a hash table resize is a benign fault. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* */ - //typedef struct BenignMallocHooks BenignMallocHooks; - public struct BenignMallocHooks// - { - public void_function xBenignBegin;//void (*xBenignBegin)(void); - public void_function xBenignEnd; //void (*xBenignEnd)(void); - public BenignMallocHooks(void_function xBenignBegin, void_function xBenignEnd) { - this.xBenignBegin = xBenignBegin; - this.xBenignEnd = xBenignEnd; - } - } - static BenignMallocHooks sqlite3Hooks = new BenignMallocHooks(null, null); + //#include "sqliteInt.h" + +#if !SQLITE_OMIT_BUILTIN_TEST + /* +** Global variables. +*/ + //typedef struct BenignMallocHooks BenignMallocHooks; + public struct BenignMallocHooks// + { + public void_function xBenignBegin;//void (*xBenignBegin)(void); + public void_function xBenignEnd; //void (*xBenignEnd)(void); + public BenignMallocHooks( void_function xBenignBegin, void_function xBenignEnd ) + { + this.xBenignBegin = xBenignBegin; + this.xBenignEnd = xBenignEnd; + } + } + static BenignMallocHooks sqlite3Hooks = new BenignMallocHooks( null, null ); - /* The "wsdHooks" macro will resolve to the appropriate BenignMallocHooks - ** structure. If writable static data is unsupported on the target, - ** we have to locate the state vector at run-time. In the more common - ** case where writable static data is supported, wsdHooks can refer directly - ** to the "sqlite3Hooks" state vector declared above. - */ + /* The "wsdHooks" macro will resolve to the appropriate BenignMallocHooks + ** structure. If writable static data is unsupported on the target, + ** we have to locate the state vector at run-time. In the more common + ** case where writable static data is supported, wsdHooks can refer directly + ** to the "sqlite3Hooks" state vector declared above. + */ #if SQLITE_OMIT_WSD //# define wsdHooksInit \ BenignMallocHooks *x = &GLOBAL(BenignMallocHooks,sqlite3Hooks) //# define wsdHooks x[0] #else - //# define wsdHooksInit - static void wsdHooksInit() { - } - //# define wsdHooks sqlite3Hooks - static BenignMallocHooks wsdHooks = sqlite3Hooks; + //# define wsdHooksInit + static void wsdHooksInit() + { + } + //# define wsdHooks sqlite3Hooks + static BenignMallocHooks wsdHooks = sqlite3Hooks; #endif - /* - ** Register hooks to call when sqlite3BeginBenignMalloc() and - ** sqlite3EndBenignMalloc() are called, respectively. - */ - static void sqlite3BenignMallocHooks( - void_function xBenignBegin, //void (*xBenignBegin)(void), - void_function xBenignEnd //void (*xBenignEnd)(void) - ) { - wsdHooksInit(); - wsdHooks.xBenignBegin = xBenignBegin; - wsdHooks.xBenignEnd = xBenignEnd; - } + /* +** Register hooks to call when sqlite3BeginBenignMalloc() and +** sqlite3EndBenignMalloc() are called, respectively. +*/ + static void sqlite3BenignMallocHooks( + void_function xBenignBegin, //void (*xBenignBegin)(void), + void_function xBenignEnd //void (*xBenignEnd)(void) + ) + { + wsdHooksInit(); + wsdHooks.xBenignBegin = xBenignBegin; + wsdHooks.xBenignEnd = xBenignEnd; + } - /* - ** This (sqlite3EndBenignMalloc()) is called by SQLite code to indicate that - ** subsequent malloc failures are benign. A call to sqlite3EndBenignMalloc() - ** indicates that subsequent malloc failures are non-benign. - */ - static void sqlite3BeginBenignMalloc() { - wsdHooksInit(); - if (wsdHooks.xBenignBegin != null) { - wsdHooks.xBenignBegin(); - } - } - static void sqlite3EndBenignMalloc() { - wsdHooksInit(); - if (wsdHooks.xBenignEnd != null) { - wsdHooks.xBenignEnd(); - } - } -#endif //* SQLITE_OMIT_BUILTIN_TEST */ + /* + ** This (sqlite3EndBenignMalloc()) is called by SQLite code to indicate that + ** subsequent malloc failures are benign. A call to sqlite3EndBenignMalloc() + ** indicates that subsequent malloc failures are non-benign. + */ + static void sqlite3BeginBenignMalloc() + { + wsdHooksInit(); + if ( wsdHooks.xBenignBegin != null ) + { + wsdHooks.xBenignBegin(); + } + } + static void sqlite3EndBenignMalloc() + { + wsdHooksInit(); + if ( wsdHooks.xBenignEnd != null ) + { + wsdHooks.xBenignEnd(); + } } +#endif //* SQLITE_OMIT_BUILTIN_TEST */ + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/fkey_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/fkey_c.cs index 76c124190..fc3a967ec 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/fkey_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/fkey_c.cs @@ -1,786 +1,854 @@ using System; using System.Diagnostics; +using System.Text; -using u32 = System.UInt32; +using Bitmask = System.UInt64; using u8 = System.Byte; +using u32 = System.UInt32; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** - ** 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 contains code used by the compiler to add foreign key - ** support to compiled SQL statements. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* */ - //#include "sqliteInt.h" - -#if !SQLITE_OMIT_FOREIGN_KEY -#if !SQLITE_OMIT_TRIGGER - - /* - ** Deferred and Immediate FKs - ** -------------------------- - ** - ** Foreign keys in SQLite come in two flavours: deferred and immediate. - ** If an immediate foreign key constraint is violated, SQLITE_CONSTRAINT - ** is returned and the current statement transaction rolled back. If a - ** deferred foreign key constraint is violated, no action is taken - ** immediately. However if the application attempts to commit the - ** transaction before fixing the constraint violation, the attempt fails. +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* ** - ** Deferred constraints are implemented using a simple counter associated - ** with the database handle. The counter is set to zero each time a - ** database transaction is opened. Each time a statement is executed - ** that causes a foreign key violation, the counter is incremented. Each - ** time a statement is executed that removes an existing violation from - ** the database, the counter is decremented. When the transaction is - ** committed, the commit fails if the current value of the counter is - ** greater than zero. This scheme has two big drawbacks: + ** The author disclaims copyright to this source code. In place of + ** a legal notice, here is a blessing: ** - ** * When a commit fails due to a deferred foreign key constraint, - ** there is no way to tell which foreign constraint is not satisfied, - ** or which row it is not satisfied for. + ** 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. ** - ** * If the database contains foreign key violations when the - ** transaction is opened, this may cause the mechanism to malfunction. + ************************************************************************* + ** This file contains code used by the compiler to add foreign key + ** support to compiled SQL statements. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library ** - ** Despite these problems, this approach is adopted as it seems simpler - ** than the alternatives. + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 ** - ** INSERT operations: - ** - ** I.1) For each FK for which the table is the child table, search - ** the parent table for a match. If none is found increment the - ** constraint counter. + ************************************************************************* */ + //#include "sqliteInt.h" + +#if !SQLITE_OMIT_FOREIGN_KEY +#if !SQLITE_OMIT_TRIGGER + + /* +** Deferred and Immediate FKs +** -------------------------- +** +** Foreign keys in SQLite come in two flavours: deferred and immediate. +** If an immediate foreign key constraint is violated, SQLITE_CONSTRAINT +** is returned and the current statement transaction rolled back. If a +** deferred foreign key constraint is violated, no action is taken +** immediately. However if the application attempts to commit the +** transaction before fixing the constraint violation, the attempt fails. +** +** Deferred constraints are implemented using a simple counter associated +** with the database handle. The counter is set to zero each time a +** database transaction is opened. Each time a statement is executed +** that causes a foreign key violation, the counter is incremented. Each +** time a statement is executed that removes an existing violation from +** the database, the counter is decremented. When the transaction is +** committed, the commit fails if the current value of the counter is +** greater than zero. This scheme has two big drawbacks: +** +** * When a commit fails due to a deferred foreign key constraint, +** there is no way to tell which foreign constraint is not satisfied, +** or which row it is not satisfied for. +** +** * If the database contains foreign key violations when the +** transaction is opened, this may cause the mechanism to malfunction. +** +** Despite these problems, this approach is adopted as it seems simpler +** than the alternatives. +** +** INSERT operations: +** +** I.1) For each FK for which the table is the child table, search +** the parent table for a match. If none is found increment the +** constraint counter. +** +** I.2) For each FK for which the table is the parent table, +** search the child table for rows that correspond to the new +** row in the parent table. Decrement the counter for each row +** found (as the constraint is now satisfied). +** +** DELETE operations: +** +** D.1) For each FK for which the table is the child table, +** search the parent table for a row that corresponds to the +** deleted row in the child table. If such a row is not found, +** decrement the counter. +** +** D.2) For each FK for which the table is the parent table, search +** the child table for rows that correspond to the deleted row +** in the parent table. For each found increment the counter. +** +** UPDATE operations: +** +** An UPDATE command requires that all 4 steps above are taken, but only +** for FK constraints for which the affected columns are actually +** modified (values must be compared at runtime). +** +** Note that I.1 and D.1 are very similar operations, as are I.2 and D.2. +** This simplifies the implementation a bit. +** +** For the purposes of immediate FK constraints, the OR REPLACE conflict +** resolution is considered to delete rows before the new row is inserted. +** If a delete caused by OR REPLACE violates an FK constraint, an exception +** is thrown, even if the FK constraint would be satisfied after the new +** row is inserted. +** +** Immediate constraints are usually handled similarly. The only difference +** is that the counter used is stored as part of each individual statement +** object (struct Vdbe). If, after the statement has run, its immediate +** constraint counter is greater than zero, it returns SQLITE_CONSTRAINT +** and the statement transaction is rolled back. An exception is an INSERT +** statement that inserts a single row only (no triggers). In this case, +** instead of using a counter, an exception is thrown immediately if the +** INSERT violates a foreign key constraint. This is necessary as such +** an INSERT does not open a statement transaction. +** +** TODO: How should dropping a table be handled? How should renaming a +** table be handled? +** +** +** Query API Notes +** --------------- +** +** Before coding an UPDATE or DELETE row operation, the code-generator +** for those two operations needs to know whether or not the operation +** requires any FK processing and, if so, which columns of the original +** row are required by the FK processing VDBE code (i.e. if FKs were +** implemented using triggers, which of the old.* columns would be +** accessed). No information is required by the code-generator before +** coding an INSERT operation. The functions used by the UPDATE/DELETE +** generation code to query for this information are: +** +** sqlite3FkRequired() - Test to see if FK processing is required. +** sqlite3FkOldmask() - Query for the set of required old.* columns. +** +** +** Externally accessible module functions +** -------------------------------------- +** +** sqlite3FkCheck() - Check for foreign key violations. +** sqlite3FkActions() - Code triggers for ON UPDATE/ON DELETE actions. +** sqlite3FkDelete() - Delete an FKey structure. +*/ + + /* + ** VDBE Calling Convention + ** ----------------------- ** - ** I.2) For each FK for which the table is the parent table, - ** search the child table for rows that correspond to the new - ** row in the parent table. Decrement the counter for each row - ** found (as the constraint is now satisfied). + ** Example: ** - ** DELETE operations: + ** For the following INSERT statement: ** - ** D.1) For each FK for which the table is the child table, - ** search the parent table for a row that corresponds to the - ** deleted row in the child table. If such a row is not found, - ** decrement the counter. + ** CREATE TABLE t1(a, b INTEGER PRIMARY KEY, c); + ** INSERT INTO t1 VALUES(1, 2, 3.1); ** - ** D.2) For each FK for which the table is the parent table, search - ** the child table for rows that correspond to the deleted row - ** in the parent table. For each found increment the counter. + ** Register (x): 2 (type integer) + ** Register (x+1): 1 (type integer) + ** Register (x+2): NULL (type NULL) + ** Register (x+3): 3.1 (type real) + */ + + /* + ** A foreign key constraint requires that the key columns in the parent + ** table are collectively subject to a UNIQUE or PRIMARY KEY constraint. + ** Given that pParent is the parent table for foreign key constraint pFKey, + ** search the schema a unique index on the parent key columns. ** - ** UPDATE operations: + ** If successful, zero is returned. If the parent key is an INTEGER PRIMARY + ** KEY column, then output variable *ppIdx is set to NULL. Otherwise, *ppIdx + ** is set to point to the unique index. + ** + ** If the parent key consists of a single column (the foreign key constraint + ** is not a composite foreign key), refput variable *paiCol is set to NULL. + ** Otherwise, it is set to point to an allocated array of size N, where + ** N is the number of columns in the parent key. The first element of the + ** array is the index of the child table column that is mapped by the FK + ** constraint to the parent table column stored in the left-most column + ** of index *ppIdx. The second element of the array is the index of the + ** child table column that corresponds to the second left-most column of + ** *ppIdx, and so on. ** - ** An UPDATE command requires that all 4 steps above are taken, but only - ** for FK constraints for which the affected columns are actually - ** modified (values must be compared at runtime). + ** If the required index cannot be found, either because: ** - ** Note that I.1 and D.1 are very similar operations, as are I.2 and D.2. - ** This simplifies the implementation a bit. + ** 1) The named parent key columns do not exist, or ** - ** For the purposes of immediate FK constraints, the OR REPLACE conflict - ** resolution is considered to delete rows before the new row is inserted. - ** If a delete caused by OR REPLACE violates an FK constraint, an exception - ** is thrown, even if the FK constraint would be satisfied after the new - ** row is inserted. + ** 2) The named parent key columns do exist, but are not subject to a + ** UNIQUE or PRIMARY KEY constraint, or ** - ** Immediate constraints are usually handled similarly. The only difference - ** is that the counter used is stored as part of each individual statement - ** object (struct Vdbe). If, after the statement has run, its immediate - ** constraint counter is greater than zero, it returns SQLITE_CONSTRAINT - ** and the statement transaction is rolled back. An exception is an INSERT - ** statement that inserts a single row only (no triggers). In this case, - ** instead of using a counter, an exception is thrown immediately if the - ** INSERT violates a foreign key constraint. This is necessary as such - ** an INSERT does not open a statement transaction. + ** 3) No parent key columns were provided explicitly as part of the + ** foreign key definition, and the parent table does not have a + ** PRIMARY KEY, or ** - ** TODO: How should dropping a table be handled? How should renaming a - ** table be handled? + ** 4) No parent key columns were provided explicitly as part of the + ** foreign key definition, and the PRIMARY KEY of the parent table + ** consists of a different number of columns to the child key in + ** the child table. ** + ** then non-zero is returned, and a "foreign key mismatch" error loaded + ** into pParse. If an OOM error occurs, non-zero is returned and the + ** pParse.db.mallocFailed flag is set. + */ + static int locateFkeyIndex( + Parse pParse, /* Parse context to store any error in */ + Table pParent, /* Parent table of FK constraint pFKey */ + FKey pFKey, /* Foreign key to find index for */ + out Index ppIdx, /* OUT: Unique index on parent table */ + out int[] paiCol /* OUT: Map of index columns in pFKey */ + ) + { + Index pIdx = null; /* Value to return via *ppIdx */ + ppIdx = null; + int[] aiCol = null; /* Value to return via *paiCol */ + paiCol = null; + + int nCol = pFKey.nCol; /* Number of columns in parent key */ + string zKey = pFKey.aCol[0].zCol; /* Name of left-most parent key column */ + + /* The caller is responsible for zeroing output parameters. */ + //assert( ppIdx && *ppIdx==0 ); + //assert( !paiCol || *paiCol==0 ); + Debug.Assert( pParse != null ); + + /* If this is a non-composite (single column) foreign key, check if it + ** maps to the INTEGER PRIMARY KEY of table pParent. If so, leave *ppIdx + ** and *paiCol set to zero and return early. + ** + ** Otherwise, for a composite foreign key (more than one column), allocate + ** space for the aiCol array (returned via output parameter *paiCol). + ** Non-composite foreign keys do not require the aiCol array. + */ + if ( nCol == 1 ) + { + /* The FK maps to the IPK if any of the following are true: + ** + ** 1) There is an INTEGER PRIMARY KEY column and the FK is implicitly + ** mapped to the primary key of table pParent, or + ** 2) The FK is explicitly mapped to a column declared as INTEGER + ** PRIMARY KEY. + */ + if ( pParent.iPKey >= 0 ) + { + if ( null == zKey ) + return 0; + if ( pParent.aCol[pParent.iPKey].zName.Equals( zKey ,StringComparison.OrdinalIgnoreCase ) ) + return 0; + } + } + else //if( paiCol ){ + { + Debug.Assert( nCol > 1 ); + aiCol = new int[nCol];// (int*)sqlite3DbMallocRaw( pParse.db, nCol * sizeof( int ) ); + //if( !aiCol ) return 1; + paiCol = aiCol; + } + + for ( pIdx = pParent.pIndex; pIdx != null; pIdx = pIdx.pNext ) + { + if ( pIdx.nColumn == nCol && pIdx.onError != OE_None ) + { + /* pIdx is a UNIQUE index (or a PRIMARY KEY) and has the right number + ** of columns. If each indexed column corresponds to a foreign key + ** column of pFKey, then this index is a winner. */ + + if ( zKey == null ) + { + /* If zKey is NULL, then this foreign key is implicitly mapped to + ** the PRIMARY KEY of table pParent. The PRIMARY KEY index may be + ** identified by the test (Index.autoIndex==2). */ + if ( pIdx.autoIndex == 2 ) + { + if ( aiCol != null ) + { + int i; + for ( i = 0; i < nCol; i++ ) + aiCol[i] = pFKey.aCol[i].iFrom; + } + break; + } + } + else + { + /* If zKey is non-NULL, then this foreign key was declared to + ** map to an explicit list of columns in table pParent. Check if this + ** index matches those columns. Also, check that the index uses + ** the default collation sequences for each column. */ + int i, j; + for ( i = 0; i < nCol; i++ ) + { + int iCol = pIdx.aiColumn[i]; /* Index of column in parent tbl */ + string zDfltColl; /* Def. collation for column */ + string zIdxCol; /* Name of indexed column */ + + /* If the index uses a collation sequence that is different from + ** the default collation sequence for the column, this index is + ** unusable. Bail out early in this case. */ + zDfltColl = pParent.aCol[iCol].zColl; + if ( String.IsNullOrEmpty( zDfltColl ) ) + { + zDfltColl = "BINARY"; + } + if ( !pIdx.azColl[i].Equals( zDfltColl ,StringComparison.OrdinalIgnoreCase ) ) + break; + + zIdxCol = pParent.aCol[iCol].zName; + for ( j = 0; j < nCol; j++ ) + { + if ( pFKey.aCol[j].zCol.Equals( zIdxCol ,StringComparison.OrdinalIgnoreCase ) ) + { + if ( aiCol != null ) + aiCol[i] = pFKey.aCol[j].iFrom; + break; + } + } + if ( j == nCol ) + break; + } + if ( i == nCol ) + break; /* pIdx is usable */ + } + } + } + + if ( null == pIdx ) + { + if ( 0 == pParse.disableTriggers ) + { + sqlite3ErrorMsg( pParse, "foreign key mismatch" ); + } + sqlite3DbFree( pParse.db, ref aiCol ); + return 1; + } + + ppIdx = pIdx; + return 0; + } + + /* + ** This function is called when a row is inserted into or deleted from the + ** child table of foreign key constraint pFKey. If an SQL UPDATE is executed + ** on the child table of pFKey, this function is invoked twice for each row + ** affected - once to "delete" the old row, and then again to "insert" the + ** new row. ** - ** Query API Notes - ** --------------- + ** Each time it is called, this function generates VDBE code to locate the + ** row in the parent table that corresponds to the row being inserted into + ** or deleted from the child table. If the parent row can be found, no + ** special action is taken. Otherwise, if the parent row can *not* be + ** found in the parent table: ** - ** Before coding an UPDATE or DELETE row operation, the code-generator - ** for those two operations needs to know whether or not the operation - ** requires any FK processing and, if so, which columns of the original - ** row are required by the FK processing VDBE code (i.e. if FKs were - ** implemented using triggers, which of the old.* columns would be - ** accessed). No information is required by the code-generator before - ** coding an INSERT operation. The functions used by the UPDATE/DELETE - ** generation code to query for this information are: + ** Operation | FK type | Action taken + ** -------------------------------------------------------------------------- + ** INSERT immediate Increment the "immediate constraint counter". ** - ** sqlite3FkRequired() - Test to see if FK processing is required. - ** sqlite3FkOldmask() - Query for the set of required old.* columns. + ** DELETE immediate Decrement the "immediate constraint counter". ** + ** INSERT deferred Increment the "deferred constraint counter". ** - ** Externally accessible module functions - ** -------------------------------------- + ** DELETE deferred Decrement the "deferred constraint counter". ** - ** sqlite3FkCheck() - Check for foreign key violations. - ** sqlite3FkActions() - Code triggers for ON UPDATE/ON DELETE actions. - ** sqlite3FkDelete() - Delete an FKey structure. + ** These operations are identified in the comment at the top of this file + ** (fkey.c) as "I.1" and "D.1". */ + static void fkLookupParent( + Parse pParse, /* Parse context */ + int iDb, /* Index of database housing pTab */ + Table pTab, /* Parent table of FK pFKey */ + Index pIdx, /* Unique index on parent key columns in pTab */ + FKey pFKey, /* Foreign key constraint */ + int[] aiCol, /* Map from parent key columns to child table columns */ + int regData, /* Address of array containing child table row */ + int nIncr, /* Increment constraint counter by this */ + int isIgnore /* If true, pretend pTab contains all NULL values */ + ) + { + int i; /* Iterator variable */ + Vdbe v = sqlite3GetVdbe( pParse ); /* Vdbe to add code to */ + int iCur = pParse.nTab - 1; /* Cursor number to use */ + int iOk = sqlite3VdbeMakeLabel( v ); /* jump here if parent key found */ + + /* If nIncr is less than zero, then check at runtime if there are any + ** outstanding constraints to resolve. If there are not, there is no need + ** to check if deleting this row resolves any outstanding violations. + ** + ** Check if any of the key columns in the child table row are NULL. If + ** any are, then the constraint is considered satisfied. No need to + ** search for a matching row in the parent table. */ + if ( nIncr < 0 ) + { + sqlite3VdbeAddOp2( v, OP_FkIfZero, pFKey.isDeferred, iOk ); + } + for ( i = 0; i < pFKey.nCol; i++ ) + { + int iReg = aiCol[i] + regData + 1; + sqlite3VdbeAddOp2( v, OP_IsNull, iReg, iOk ); + } - /* - ** VDBE Calling Convention - ** ----------------------- - ** - ** Example: - ** - ** For the following INSERT statement: - ** - ** CREATE TABLE t1(a, b INTEGER PRIMARY KEY, c); - ** INSERT INTO t1 VALUES(1, 2, 3.1); - ** - ** Register (x): 2 (type integer) - ** Register (x+1): 1 (type integer) - ** Register (x+2): NULL (type NULL) - ** Register (x+3): 3.1 (type real) - */ - - /* - ** A foreign key constraint requires that the key columns in the parent - ** table are collectively subject to a UNIQUE or PRIMARY KEY constraint. - ** Given that pParent is the parent table for foreign key constraint pFKey, - ** search the schema a unique index on the parent key columns. - ** - ** If successful, zero is returned. If the parent key is an INTEGER PRIMARY - ** KEY column, then output variable *ppIdx is set to NULL. Otherwise, *ppIdx - ** is set to point to the unique index. - ** - ** If the parent key consists of a single column (the foreign key constraint - ** is not a composite foreign key), refput variable *paiCol is set to NULL. - ** Otherwise, it is set to point to an allocated array of size N, where - ** N is the number of columns in the parent key. The first element of the - ** array is the index of the child table column that is mapped by the FK - ** constraint to the parent table column stored in the left-most column - ** of index *ppIdx. The second element of the array is the index of the - ** child table column that corresponds to the second left-most column of - ** *ppIdx, and so on. - ** - ** If the required index cannot be found, either because: - ** - ** 1) The named parent key columns do not exist, or - ** - ** 2) The named parent key columns do exist, but are not subject to a - ** UNIQUE or PRIMARY KEY constraint, or - ** - ** 3) No parent key columns were provided explicitly as part of the - ** foreign key definition, and the parent table does not have a - ** PRIMARY KEY, or - ** - ** 4) No parent key columns were provided explicitly as part of the - ** foreign key definition, and the PRIMARY KEY of the parent table - ** consists of a different number of columns to the child key in - ** the child table. - ** - ** then non-zero is returned, and a "foreign key mismatch" error loaded - ** into pParse. If an OOM error occurs, non-zero is returned and the - ** pParse.db.mallocFailed flag is set. - */ - static int locateFkeyIndex( - Parse pParse, /* Parse context to store any error in */ - Table pParent, /* Parent table of FK constraint pFKey */ - FKey pFKey, /* Foreign key to find index for */ - out Index ppIdx, /* OUT: Unique index on parent table */ - out int[] paiCol /* OUT: Map of index columns in pFKey */ - ) { - Index pIdx = null; /* Value to return via *ppIdx */ - ppIdx = null; - int[] aiCol = null; /* Value to return via *paiCol */ - paiCol = null; - - int nCol = pFKey.nCol; /* Number of columns in parent key */ - string zKey = pFKey.aCol[0].zCol; /* Name of left-most parent key column */ - - /* The caller is responsible for zeroing output parameters. */ - //assert( ppIdx && *ppIdx==0 ); - //assert( !paiCol || *paiCol==0 ); - Debug.Assert(pParse != null); - - /* If this is a non-composite (single column) foreign key, check if it - ** maps to the INTEGER PRIMARY KEY of table pParent. If so, leave *ppIdx - ** and *paiCol set to zero and return early. - ** - ** Otherwise, for a composite foreign key (more than one column), allocate - ** space for the aiCol array (returned via output parameter *paiCol). - ** Non-composite foreign keys do not require the aiCol array. - */ - if (nCol == 1) { - /* The FK maps to the IPK if any of the following are true: - ** - ** 1) There is an INTEGER PRIMARY KEY column and the FK is implicitly - ** mapped to the primary key of table pParent, or - ** 2) The FK is explicitly mapped to a column declared as INTEGER - ** PRIMARY KEY. - */ - if (pParent.iPKey >= 0) { - if (null == zKey) - return 0; - if (pParent.aCol[pParent.iPKey].zName.Equals(zKey, StringComparison.OrdinalIgnoreCase)) - return 0; - } - } else //if( paiCol ){ + if ( isIgnore == 0 ) + { + if ( pIdx == null ) + { + /* If pIdx is NULL, then the parent key is the INTEGER PRIMARY KEY + ** column of the parent table (table pTab). */ + int iMustBeInt; /* Address of MustBeInt instruction */ + int regTemp = sqlite3GetTempReg( pParse ); + + /* Invoke MustBeInt to coerce the child key value to an integer (i.e. + ** apply the affinity of the parent key). If this fails, then there + ** is no matching parent key. Before using MustBeInt, make a copy of + ** the value. Otherwise, the value inserted into the child key column + ** will have INTEGER affinity applied to it, which may not be correct. */ + sqlite3VdbeAddOp2( v, OP_SCopy, aiCol[0] + 1 + regData, regTemp ); + iMustBeInt = sqlite3VdbeAddOp2( v, OP_MustBeInt, regTemp, 0 ); + + /* If the parent table is the same as the child table, and we are about + ** to increment the constraint-counter (i.e. this is an INSERT operation), + ** then check if the row being inserted matches itself. If so, do not + ** increment the constraint-counter. */ + if ( pTab == pFKey.pFrom && nIncr == 1 ) + { + sqlite3VdbeAddOp3( v, OP_Eq, regData, iOk, regTemp ); + } + + sqlite3OpenTable( pParse, iCur, iDb, pTab, OP_OpenRead ); + sqlite3VdbeAddOp3( v, OP_NotExists, iCur, 0, regTemp ); + sqlite3VdbeAddOp2( v, OP_Goto, 0, iOk ); + sqlite3VdbeJumpHere( v, sqlite3VdbeCurrentAddr( v ) - 2 ); + sqlite3VdbeJumpHere( v, iMustBeInt ); + sqlite3ReleaseTempReg( pParse, regTemp ); + } + else + { + int nCol = pFKey.nCol; + int regTemp = sqlite3GetTempRange( pParse, nCol ); + int regRec = sqlite3GetTempReg( pParse ); + KeyInfo pKey = sqlite3IndexKeyinfo( pParse, pIdx ); + + sqlite3VdbeAddOp3( v, OP_OpenRead, iCur, pIdx.tnum, iDb ); + sqlite3VdbeChangeP4( v, -1, pKey, P4_KEYINFO_HANDOFF ); + for ( i = 0; i < nCol; i++ ) + { + sqlite3VdbeAddOp2( v, OP_Copy, aiCol[i] + 1 + regData, regTemp + i ); + } + + /* If the parent table is the same as the child table, and we are about + ** to increment the constraint-counter (i.e. this is an INSERT operation), + ** then check if the row being inserted matches itself. If so, do not + ** increment the constraint-counter. + ** + ** If any of the parent-key values are NULL, then the row cannot match + ** itself. So set JUMPIFNULL to make sure we do the OP_Found if any + ** of the parent-key values are NULL (at this point it is known that + ** none of the child key values are). + */ + if ( pTab == pFKey.pFrom && nIncr == 1 ) + { + int iJump = sqlite3VdbeCurrentAddr( v ) + nCol + 1; + for ( i = 0; i < nCol; i++ ) + { + int iChild = aiCol[i] + 1 + regData; + int iParent = pIdx.aiColumn[i] + 1 + regData; + Debug.Assert( aiCol[i] != pTab.iPKey ); + if ( pIdx.aiColumn[i] == pTab.iPKey ) { - Debug.Assert(nCol > 1); - aiCol = new int[nCol];// (int*)sqlite3DbMallocRaw( pParse.db, nCol * sizeof( int ) ); - //if( !aiCol ) return 1; - paiCol = aiCol; + /* The parent key is a composite key that includes the IPK column */ + iParent = regData; + } + sqlite3VdbeAddOp3( v, OP_Ne, iChild, iJump, iParent ); + sqlite3VdbeChangeP5( v, SQLITE_JUMPIFNULL ); } + sqlite3VdbeAddOp2( v, OP_Goto, 0, iOk ); + } - for (pIdx = pParent.pIndex; pIdx != null; pIdx = pIdx.pNext) { - if (pIdx.nColumn == nCol && pIdx.onError != OE_None) { - /* pIdx is a UNIQUE index (or a PRIMARY KEY) and has the right number - ** of columns. If each indexed column corresponds to a foreign key - ** column of pFKey, then this index is a winner. */ - - if (zKey == null) { - /* If zKey is NULL, then this foreign key is implicitly mapped to - ** the PRIMARY KEY of table pParent. The PRIMARY KEY index may be - ** identified by the test (Index.autoIndex==2). */ - if (pIdx.autoIndex == 2) { - if (aiCol != null) { - int i; - for (i = 0; i < nCol; i++) - aiCol[i] = pFKey.aCol[i].iFrom; - } - break; - } - } else { - /* If zKey is non-NULL, then this foreign key was declared to - ** map to an explicit list of columns in table pParent. Check if this - ** index matches those columns. Also, check that the index uses - ** the default collation sequences for each column. */ - int i, j; - for (i = 0; i < nCol; i++) { - int iCol = pIdx.aiColumn[i]; /* Index of column in parent tbl */ - string zDfltColl; /* Def. collation for column */ - string zIdxCol; /* Name of indexed column */ - - /* If the index uses a collation sequence that is different from - ** the default collation sequence for the column, this index is - ** unusable. Bail out early in this case. */ - zDfltColl = pParent.aCol[iCol].zColl; - if (String.IsNullOrEmpty(zDfltColl)) { - zDfltColl = "BINARY"; - } - if (!pIdx.azColl[i].Equals(zDfltColl, StringComparison.OrdinalIgnoreCase)) - break; - - zIdxCol = pParent.aCol[iCol].zName; - for (j = 0; j < nCol; j++) { - if (pFKey.aCol[j].zCol.Equals(zIdxCol, StringComparison.OrdinalIgnoreCase)) { - if (aiCol != null) - aiCol[i] = pFKey.aCol[j].iFrom; - break; - } - } - if (j == nCol) - break; - } - if (i == nCol) - break; /* pIdx is usable */ - } - } - } + sqlite3VdbeAddOp3( v, OP_MakeRecord, regTemp, nCol, regRec ); + sqlite3VdbeChangeP4( v, -1, sqlite3IndexAffinityStr( v, pIdx ), P4_TRANSIENT ); + sqlite3VdbeAddOp4Int( v, OP_Found, iCur, iOk, regRec, 0 ); - if (null == pIdx) { - if (0 == pParse.disableTriggers) { - sqlite3ErrorMsg(pParse, "foreign key mismatch"); - } - sqlite3DbFree(pParse.db, ref aiCol); - return 1; - } + sqlite3ReleaseTempReg( pParse, regRec ); + sqlite3ReleaseTempRange( pParse, regTemp, nCol ); + } + } - ppIdx = pIdx; - return 0; + if ( 0 == pFKey.isDeferred && null == pParse.pToplevel && 0 == pParse.isMultiWrite ) + { + /* Special case: If this is an INSERT statement that will insert exactly + ** one row into the table, raise a constraint immediately instead of + ** incrementing a counter. This is necessary as the VM code is being + ** generated for will not open a statement transaction. */ + Debug.Assert( nIncr == 1 ); + sqlite3HaltConstraint( + pParse, OE_Abort, "foreign key constraint failed", P4_STATIC + ); + } + else + { + if ( nIncr > 0 && pFKey.isDeferred == 0 ) + { + sqlite3ParseToplevel( pParse ).mayAbort = 1; } + sqlite3VdbeAddOp2( v, OP_FkCounter, pFKey.isDeferred, nIncr ); + } - /* - ** This function is called when a row is inserted into or deleted from the - ** child table of foreign key constraint pFKey. If an SQL UPDATE is executed - ** on the child table of pFKey, this function is invoked twice for each row - ** affected - once to "delete" the old row, and then again to "insert" the - ** new row. - ** - ** Each time it is called, this function generates VDBE code to locate the - ** row in the parent table that corresponds to the row being inserted into - ** or deleted from the child table. If the parent row can be found, no - ** special action is taken. Otherwise, if the parent row can *not* be - ** found in the parent table: - ** - ** Operation | FK type | Action taken - ** -------------------------------------------------------------------------- - ** INSERT immediate Increment the "immediate constraint counter". - ** - ** DELETE immediate Decrement the "immediate constraint counter". - ** - ** INSERT deferred Increment the "deferred constraint counter". - ** - ** DELETE deferred Decrement the "deferred constraint counter". - ** - ** These operations are identified in the comment at the top of this file - ** (fkey.c) as "I.1" and "D.1". - */ - static void fkLookupParent( - Parse pParse, /* Parse context */ - int iDb, /* Index of database housing pTab */ - Table pTab, /* Parent table of FK pFKey */ - Index pIdx, /* Unique index on parent key columns in pTab */ - FKey pFKey, /* Foreign key constraint */ - int[] aiCol, /* Map from parent key columns to child table columns */ - int regData, /* Address of array containing child table row */ - int nIncr, /* Increment constraint counter by this */ - int isIgnore /* If true, pretend pTab contains all NULL values */ - ) { - int i; /* Iterator variable */ - Vdbe v = sqlite3GetVdbe(pParse); /* Vdbe to add code to */ - int iCur = pParse.nTab - 1; /* Cursor number to use */ - int iOk = sqlite3VdbeMakeLabel(v); /* jump here if parent key found */ - - /* If nIncr is less than zero, then check at runtime if there are any - ** outstanding constraints to resolve. If there are not, there is no need - ** to check if deleting this row resolves any outstanding violations. - ** - ** Check if any of the key columns in the child table row are NULL. If - ** any are, then the constraint is considered satisfied. No need to - ** search for a matching row in the parent table. */ - if (nIncr < 0) { - sqlite3VdbeAddOp2(v, OP_FkIfZero, pFKey.isDeferred, iOk); - } - for (i = 0; i < pFKey.nCol; i++) { - int iReg = aiCol[i] + regData + 1; - sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iOk); - } + sqlite3VdbeResolveLabel( v, iOk ); + sqlite3VdbeAddOp1( v, OP_Close, iCur ); + } - if (isIgnore == 0) { - if (pIdx == null) { - /* If pIdx is NULL, then the parent key is the INTEGER PRIMARY KEY - ** column of the parent table (table pTab). */ - int iMustBeInt; /* Address of MustBeInt instruction */ - int regTemp = sqlite3GetTempReg(pParse); - - /* Invoke MustBeInt to coerce the child key value to an integer (i.e. - ** apply the affinity of the parent key). If this fails, then there - ** is no matching parent key. Before using MustBeInt, make a copy of - ** the value. Otherwise, the value inserted into the child key column - ** will have INTEGER affinity applied to it, which may not be correct. */ - sqlite3VdbeAddOp2(v, OP_SCopy, aiCol[0] + 1 + regData, regTemp); - iMustBeInt = sqlite3VdbeAddOp2(v, OP_MustBeInt, regTemp, 0); - - /* If the parent table is the same as the child table, and we are about - ** to increment the constraint-counter (i.e. this is an INSERT operation), - ** then check if the row being inserted matches itself. If so, do not - ** increment the constraint-counter. */ - if (pTab == pFKey.pFrom && nIncr == 1) { - sqlite3VdbeAddOp3(v, OP_Eq, regData, iOk, regTemp); - } - - sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenRead); - sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regTemp); - sqlite3VdbeAddOp2(v, OP_Goto, 0, iOk); - sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v) - 2); - sqlite3VdbeJumpHere(v, iMustBeInt); - sqlite3ReleaseTempReg(pParse, regTemp); - } else { - int nCol = pFKey.nCol; - int regTemp = sqlite3GetTempRange(pParse, nCol); - int regRec = sqlite3GetTempReg(pParse); - KeyInfo pKey = sqlite3IndexKeyinfo(pParse, pIdx); - - sqlite3VdbeAddOp3(v, OP_OpenRead, iCur, pIdx.tnum, iDb); - sqlite3VdbeChangeP4(v, -1, pKey, P4_KEYINFO_HANDOFF); - for (i = 0; i < nCol; i++) { - sqlite3VdbeAddOp2(v, OP_Copy, aiCol[i] + 1 + regData, regTemp + i); - } - - /* If the parent table is the same as the child table, and we are about - ** to increment the constraint-counter (i.e. this is an INSERT operation), - ** then check if the row being inserted matches itself. If so, do not - ** increment the constraint-counter. - ** - ** If any of the parent-key values are NULL, then the row cannot match - ** itself. So set JUMPIFNULL to make sure we do the OP_Found if any - ** of the parent-key values are NULL (at this point it is known that - ** none of the child key values are). - */ - if (pTab == pFKey.pFrom && nIncr == 1) { - int iJump = sqlite3VdbeCurrentAddr(v) + nCol + 1; - for (i = 0; i < nCol; i++) { - int iChild = aiCol[i] + 1 + regData; - int iParent = pIdx.aiColumn[i] + 1 + regData; - Debug.Assert(aiCol[i] != pTab.iPKey); - if (pIdx.aiColumn[i] == pTab.iPKey) { - /* The parent key is a composite key that includes the IPK column */ - iParent = regData; - } - sqlite3VdbeAddOp3(v, OP_Ne, iChild, iJump, iParent); - sqlite3VdbeChangeP5(v, SQLITE_JUMPIFNULL); - } - sqlite3VdbeAddOp2(v, OP_Goto, 0, iOk); - } - - sqlite3VdbeAddOp3(v, OP_MakeRecord, regTemp, nCol, regRec); - sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), P4_TRANSIENT); - sqlite3VdbeAddOp4Int(v, OP_Found, iCur, iOk, regRec, 0); - - sqlite3ReleaseTempReg(pParse, regRec); - sqlite3ReleaseTempRange(pParse, regTemp, nCol); - } - } + /* + ** This function is called to generate code executed when a row is deleted + ** from the parent table of foreign key constraint pFKey and, if pFKey is + ** deferred, when a row is inserted into the same table. When generating + ** code for an SQL UPDATE operation, this function may be called twice - + ** once to "delete" the old row and once to "insert" the new row. + ** + ** The code generated by this function scans through the rows in the child + ** table that correspond to the parent table row being deleted or inserted. + ** For each child row found, one of the following actions is taken: + ** + ** Operation | FK type | Action taken + ** -------------------------------------------------------------------------- + ** DELETE immediate Increment the "immediate constraint counter". + ** Or, if the ON (UPDATE|DELETE) action is RESTRICT, + ** throw a "foreign key constraint failed" exception. + ** + ** INSERT immediate Decrement the "immediate constraint counter". + ** + ** DELETE deferred Increment the "deferred constraint counter". + ** Or, if the ON (UPDATE|DELETE) action is RESTRICT, + ** throw a "foreign key constraint failed" exception. + ** + ** INSERT deferred Decrement the "deferred constraint counter". + ** + ** These operations are identified in the comment at the top of this file + ** (fkey.c) as "I.2" and "D.2". + */ + static void fkScanChildren( + Parse pParse, /* Parse context */ + SrcList pSrc, /* SrcList containing the table to scan */ + Table pTab, + Index pIdx, /* Foreign key index */ + FKey pFKey, /* Foreign key relationship */ + int[] aiCol, /* Map from pIdx cols to child table cols */ + int regData, /* Referenced table data starts here */ + int nIncr /* Amount to increment deferred counter by */ + ) + { + sqlite3 db = pParse.db; /* Database handle */ + int i; /* Iterator variable */ + Expr pWhere = null; /* WHERE clause to scan with */ + NameContext sNameContext; /* Context used to resolve WHERE clause */ + WhereInfo pWInfo; /* Context used by sqlite3WhereXXX() */ + int iFkIfZero = 0; /* Address of OP_FkIfZero */ + Vdbe v = sqlite3GetVdbe( pParse ); + + Debug.Assert( null == pIdx || pIdx.pTable == pTab ); + + if ( nIncr < 0 ) + { + iFkIfZero = sqlite3VdbeAddOp2( v, OP_FkIfZero, pFKey.isDeferred, 0 ); + } - if (0 == pFKey.isDeferred && null == pParse.pToplevel && 0 == pParse.isMultiWrite) { - /* Special case: If this is an INSERT statement that will insert exactly - ** one row into the table, raise a constraint immediately instead of - ** incrementing a counter. This is necessary as the VM code is being - ** generated for will not open a statement transaction. */ - Debug.Assert(nIncr == 1); - sqlite3HaltConstraint( - pParse, OE_Abort, "foreign key constraint failed", P4_STATIC - ); - } else { - if (nIncr > 0 && pFKey.isDeferred == 0) { - sqlite3ParseToplevel(pParse).mayAbort = 1; - } - sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey.isDeferred, nIncr); - } + /* Create an Expr object representing an SQL expression like: + ** + ** = AND = ... + ** + ** The collation sequence used for the comparison should be that of + ** the parent key columns. The affinity of the parent key column should + ** be applied to each child key value before the comparison takes place. + */ + for ( i = 0; i < pFKey.nCol; i++ ) + { + Expr pLeft; /* Value from parent table row */ + Expr pRight; /* Column ref to child table */ + Expr pEq; /* Expression (pLeft = pRight) */ + int iCol; /* Index of column in child table */ + string zCol; /* Name of column in child table */ + + pLeft = sqlite3Expr( db, TK_REGISTER, null ); + if ( pLeft != null ) + { + /* Set the collation sequence and affinity of the LHS of each TK_EQ + ** expression to the parent key column defaults. */ + if ( pIdx != null ) + { + Column pCol; + iCol = pIdx.aiColumn[i]; + pCol = pTab.aCol[iCol]; + if ( pTab.iPKey == iCol ) + iCol = -1; + pLeft.iTable = regData + iCol + 1; + pLeft.affinity = pCol.affinity; + pLeft.pColl = sqlite3LocateCollSeq( pParse, pCol.zColl ); + } + else + { + pLeft.iTable = regData; + pLeft.affinity = SQLITE_AFF_INTEGER; + } + } + iCol = aiCol != null ? aiCol[i] : pFKey.aCol[0].iFrom; + Debug.Assert( iCol >= 0 ); + zCol = pFKey.pFrom.aCol[iCol].zName; + pRight = sqlite3Expr( db, TK_ID, zCol ); + pEq = sqlite3PExpr( pParse, TK_EQ, pLeft, pRight, 0 ); + pWhere = sqlite3ExprAnd( db, pWhere, pEq ); + } - sqlite3VdbeResolveLabel(v, iOk); - sqlite3VdbeAddOp1(v, OP_Close, iCur); + /* If the child table is the same as the parent table, and this scan + ** is taking place as part of a DELETE operation (operation D.2), omit the + ** row being deleted from the scan by adding ($rowid != rowid) to the WHERE + ** clause, where $rowid is the rowid of the row being deleted. */ + if ( pTab == pFKey.pFrom && nIncr > 0 ) + { + Expr pEq; /* Expression (pLeft = pRight) */ + Expr pLeft; /* Value from parent table row */ + Expr pRight; /* Column ref to child table */ + pLeft = sqlite3Expr( db, TK_REGISTER, null ); + pRight = sqlite3Expr( db, TK_COLUMN, null ); + if ( pLeft != null && pRight != null ) + { + pLeft.iTable = regData; + pLeft.affinity = SQLITE_AFF_INTEGER; + pRight.iTable = pSrc.a[0].iCursor; + pRight.iColumn = -1; } + pEq = sqlite3PExpr( pParse, TK_NE, pLeft, pRight, 0 ); + pWhere = sqlite3ExprAnd( db, pWhere, pEq ); + } - /* - ** This function is called to generate code executed when a row is deleted - ** from the parent table of foreign key constraint pFKey and, if pFKey is - ** deferred, when a row is inserted into the same table. When generating - ** code for an SQL UPDATE operation, this function may be called twice - - ** once to "delete" the old row and once to "insert" the new row. - ** - ** The code generated by this function scans through the rows in the child - ** table that correspond to the parent table row being deleted or inserted. - ** For each child row found, one of the following actions is taken: - ** - ** Operation | FK type | Action taken - ** -------------------------------------------------------------------------- - ** DELETE immediate Increment the "immediate constraint counter". - ** Or, if the ON (UPDATE|DELETE) action is RESTRICT, - ** throw a "foreign key constraint failed" exception. - ** - ** INSERT immediate Decrement the "immediate constraint counter". - ** - ** DELETE deferred Increment the "deferred constraint counter". - ** Or, if the ON (UPDATE|DELETE) action is RESTRICT, - ** throw a "foreign key constraint failed" exception. - ** - ** INSERT deferred Decrement the "deferred constraint counter". - ** - ** These operations are identified in the comment at the top of this file - ** (fkey.c) as "I.2" and "D.2". - */ - static void fkScanChildren( - Parse pParse, /* Parse context */ - SrcList pSrc, /* SrcList containing the table to scan */ - Table pTab, - Index pIdx, /* Foreign key index */ - FKey pFKey, /* Foreign key relationship */ - int[] aiCol, /* Map from pIdx cols to child table cols */ - int regData, /* Referenced table data starts here */ - int nIncr /* Amount to increment deferred counter by */ - ) { - sqlite3 db = pParse.db; /* Database handle */ - int i; /* Iterator variable */ - Expr pWhere = null; /* WHERE clause to scan with */ - NameContext sNameContext; /* Context used to resolve WHERE clause */ - WhereInfo pWInfo; /* Context used by sqlite3WhereXXX() */ - int iFkIfZero = 0; /* Address of OP_FkIfZero */ - Vdbe v = sqlite3GetVdbe(pParse); - - Debug.Assert(null == pIdx || pIdx.pTable == pTab); - - if (nIncr < 0) { - iFkIfZero = sqlite3VdbeAddOp2(v, OP_FkIfZero, pFKey.isDeferred, 0); - } + /* Resolve the references in the WHERE clause. */ + sNameContext = new NameContext();// memset( &sNameContext, 0, sizeof( NameContext ) ); + sNameContext.pSrcList = pSrc; + sNameContext.pParse = pParse; + sqlite3ResolveExprNames( sNameContext, ref pWhere ); + + /* Create VDBE to loop through the entries in pSrc that match the WHERE + ** clause. If the constraint is not deferred, throw an exception for + ** each row found. Otherwise, for deferred constraints, increment the + ** deferred constraint counter by nIncr for each row selected. */ + ExprList elDummy = null; + pWInfo = sqlite3WhereBegin( pParse, pSrc, pWhere, ref elDummy, 0 ); + if ( nIncr > 0 && pFKey.isDeferred == 0 ) + { + sqlite3ParseToplevel( pParse ).mayAbort = 1; + } + sqlite3VdbeAddOp2( v, OP_FkCounter, pFKey.isDeferred, nIncr ); + if ( pWInfo != null ) + { + sqlite3WhereEnd( pWInfo ); + } - /* Create an Expr object representing an SQL expression like: - ** - ** = AND = ... - ** - ** The collation sequence used for the comparison should be that of - ** the parent key columns. The affinity of the parent key column should - ** be applied to each child key value before the comparison takes place. - */ - for (i = 0; i < pFKey.nCol; i++) { - Expr pLeft; /* Value from parent table row */ - Expr pRight; /* Column ref to child table */ - Expr pEq; /* Expression (pLeft = pRight) */ - int iCol; /* Index of column in child table */ - string zCol; /* Name of column in child table */ - - pLeft = sqlite3Expr(db, TK_REGISTER, null); - if (pLeft != null) { - /* Set the collation sequence and affinity of the LHS of each TK_EQ - ** expression to the parent key column defaults. */ - if (pIdx != null) { - Column pCol; - iCol = pIdx.aiColumn[i]; - pCol = pTab.aCol[iCol]; - if (pTab.iPKey == iCol) - iCol = -1; - pLeft.iTable = regData + iCol + 1; - pLeft.affinity = pCol.affinity; - pLeft.pColl = sqlite3LocateCollSeq(pParse, pCol.zColl); - } else { - pLeft.iTable = regData; - pLeft.affinity = SQLITE_AFF_INTEGER; - } - } - iCol = aiCol != null ? aiCol[i] : pFKey.aCol[0].iFrom; - Debug.Assert(iCol >= 0); - zCol = pFKey.pFrom.aCol[iCol].zName; - pRight = sqlite3Expr(db, TK_ID, zCol); - pEq = sqlite3PExpr(pParse, TK_EQ, pLeft, pRight, 0); - pWhere = sqlite3ExprAnd(db, pWhere, pEq); - } + /* Clean up the WHERE clause constructed above. */ + sqlite3ExprDelete( db, ref pWhere ); + if ( iFkIfZero != 0 ) + { + sqlite3VdbeJumpHere( v, iFkIfZero ); + } + } - /* If the child table is the same as the parent table, and this scan - ** is taking place as part of a DELETE operation (operation D.2), omit the - ** row being deleted from the scan by adding ($rowid != rowid) to the WHERE - ** clause, where $rowid is the rowid of the row being deleted. */ - if (pTab == pFKey.pFrom && nIncr > 0) { - Expr pEq; /* Expression (pLeft = pRight) */ - Expr pLeft; /* Value from parent table row */ - Expr pRight; /* Column ref to child table */ - pLeft = sqlite3Expr(db, TK_REGISTER, null); - pRight = sqlite3Expr(db, TK_COLUMN, null); - if (pLeft != null && pRight != null) { - pLeft.iTable = regData; - pLeft.affinity = SQLITE_AFF_INTEGER; - pRight.iTable = pSrc.a[0].iCursor; - pRight.iColumn = -1; - } - pEq = sqlite3PExpr(pParse, TK_NE, pLeft, pRight, 0); - pWhere = sqlite3ExprAnd(db, pWhere, pEq); - } + /* + ** This function returns a pointer to the head of a linked list of FK + ** constraints for which table pTab is the parent table. For example, + ** given the following schema: + ** + ** CREATE TABLE t1(a PRIMARY KEY); + ** CREATE TABLE t2(b REFERENCES t1(a); + ** + ** Calling this function with table "t1" as an argument returns a pointer + ** to the FKey structure representing the foreign key constraint on table + ** "t2". Calling this function with "t2" as the argument would return a + ** NULL pointer (as there are no FK constraints for which t2 is the parent + ** table). + */ + static FKey sqlite3FkReferences( Table pTab ) + { + int nName = sqlite3Strlen30( pTab.zName ); + return sqlite3HashFind( pTab.pSchema.fkeyHash, pTab.zName, nName, (FKey)null ); + } - /* Resolve the references in the WHERE clause. */ - sNameContext = new NameContext();// memset( &sNameContext, 0, sizeof( NameContext ) ); - sNameContext.pSrcList = pSrc; - sNameContext.pParse = pParse; - sqlite3ResolveExprNames(sNameContext, ref pWhere); - - /* Create VDBE to loop through the entries in pSrc that match the WHERE - ** clause. If the constraint is not deferred, throw an exception for - ** each row found. Otherwise, for deferred constraints, increment the - ** deferred constraint counter by nIncr for each row selected. */ - ExprList elDummy = null; - pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, ref elDummy, 0); - if (nIncr > 0 && pFKey.isDeferred == 0) { - sqlite3ParseToplevel(pParse).mayAbort = 1; - } - sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey.isDeferred, nIncr); - if (pWInfo != null) { - sqlite3WhereEnd(pWInfo); - } + /* + ** The second argument is a Trigger structure allocated by the + ** fkActionTrigger() routine. This function deletes the Trigger structure + ** and all of its sub-components. + ** + ** The Trigger structure or any of its sub-components may be allocated from + ** the lookaside buffer belonging to database handle dbMem. + */ + static void fkTriggerDelete( sqlite3 dbMem, Trigger p ) + { + if ( p != null ) + { + TriggerStep pStep = p.step_list; + sqlite3ExprDelete( dbMem, ref pStep.pWhere ); + sqlite3ExprListDelete( dbMem, ref pStep.pExprList ); + sqlite3SelectDelete( dbMem, ref pStep.pSelect ); + sqlite3ExprDelete( dbMem, ref p.pWhen ); + sqlite3DbFree( dbMem, ref p ); + } + } - /* Clean up the WHERE clause constructed above. */ - sqlite3ExprDelete(db, ref pWhere); - if (iFkIfZero != 0) { - sqlite3VdbeJumpHere(v, iFkIfZero); - } + /* + ** This function is called to generate code that runs when table pTab is + ** being dropped from the database. The SrcList passed as the second argument + ** to this function contains a single entry guaranteed to resolve to + ** table pTab. + ** + ** Normally, no code is required. However, if either + ** + ** (a) The table is the parent table of a FK constraint, or + ** (b) The table is the child table of a deferred FK constraint and it is + ** determined at runtime that there are outstanding deferred FK + ** constraint violations in the database, + ** + ** then the equivalent of "DELETE FROM " is executed before dropping + ** the table from the database. Triggers are disabled while running this + ** DELETE, but foreign key actions are not. + */ + static void sqlite3FkDropTable( Parse pParse, SrcList pName, Table pTab ) + { + sqlite3 db = pParse.db; + if ( ( db.flags & SQLITE_ForeignKeys ) != 0 && !IsVirtual( pTab ) && null == pTab.pSelect ) + { + int iSkip = 0; + Vdbe v = sqlite3GetVdbe( pParse ); + + Debug.Assert( v != null ); /* VDBE has already been allocated */ + if ( sqlite3FkReferences( pTab ) == null ) + { + /* Search for a deferred foreign key constraint for which this table + ** is the child table. If one cannot be found, return without + ** 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 != null; p = p.pNextFrom ) + { + if ( p.isDeferred != 0 ) + break; + } + if ( null == p ) + return; + iSkip = sqlite3VdbeMakeLabel( v ); + sqlite3VdbeAddOp2( v, OP_FkIfZero, 1, iSkip ); } - /* - ** This function returns a pointer to the head of a linked list of FK - ** constraints for which table pTab is the parent table. For example, - ** given the following schema: - ** - ** CREATE TABLE t1(a PRIMARY KEY); - ** CREATE TABLE t2(b REFERENCES t1(a); - ** - ** Calling this function with table "t1" as an argument returns a pointer - ** to the FKey structure representing the foreign key constraint on table - ** "t2". Calling this function with "t2" as the argument would return a - ** NULL pointer (as there are no FK constraints for which t2 is the parent - ** table). - */ - static FKey sqlite3FkReferences(Table pTab) { - int nName = sqlite3Strlen30(pTab.zName); - return sqlite3HashFind(pTab.pSchema.fkeyHash, pTab.zName, nName, (FKey)null); + pParse.disableTriggers = 1; + sqlite3DeleteFrom( pParse, sqlite3SrcListDup( db, pName, 0 ), null ); + 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. */ + sqlite3VdbeAddOp2( v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr( v ) + 2 ); + sqlite3HaltConstraint( + pParse, OE_Abort, "foreign key constraint failed", P4_STATIC + ); + + if ( iSkip != 0 ) + { + sqlite3VdbeResolveLabel( v, iSkip ); } + } + } - /* - ** The second argument is a Trigger structure allocated by the - ** fkActionTrigger() routine. This function deletes the Trigger structure - ** and all of its sub-components. - ** - ** The Trigger structure or any of its sub-components may be allocated from - ** the lookaside buffer belonging to database handle dbMem. - */ - static void fkTriggerDelete(sqlite3 dbMem, Trigger p) { - if (p != null) { - TriggerStep pStep = p.step_list; - sqlite3ExprDelete(dbMem, ref pStep.pWhere); - sqlite3ExprListDelete(dbMem, ref pStep.pExprList); - sqlite3SelectDelete(dbMem, ref pStep.pSelect); - sqlite3ExprDelete(dbMem, ref p.pWhen); - sqlite3DbFree(dbMem, ref p); - } + /* + ** This function is called when inserting, deleting or updating a row of + ** table pTab to generate VDBE code to perform foreign key constraint + ** processing for the operation. + ** + ** For a DELETE operation, parameter regOld is passed the index of the + ** first register in an array of (pTab.nCol+1) registers containing the + ** rowid of the row being deleted, followed by each of the column values + ** of the row being deleted, from left to right. Parameter regNew is passed + ** zero in this case. + ** + ** For an INSERT operation, regOld is passed zero and regNew is passed the + ** first register of an array of (pTab.nCol+1) registers containing the new + ** row data. + ** + ** For an UPDATE operation, this function is called twice. Once before + ** the original record is deleted from the table using the calling convention + ** described for DELETE. Then again after the original record is deleted + ** but before the new record is inserted using the INSERT convention. + */ + static void sqlite3FkCheck( + Parse pParse, /* Parse context */ + Table pTab, /* Row is being deleted from this table */ + int regOld, /* Previous row data is stored here */ + int regNew /* New row data is stored here */ + ) + { + sqlite3 db = pParse.db; /* Database handle */ + FKey pFKey; /* Used to iterate through FKs */ + int iDb; /* Index of database containing pTab */ + string zDb; /* Name of database containing pTab */ + int isIgnoreErrors = pParse.disableTriggers; + + /* Exactly one of regOld and regNew should be non-zero. */ + Debug.Assert( ( regOld == 0 ) != ( regNew == 0 ) ); + + /* If foreign-keys are disabled, this function is a no-op. */ + if ( ( db.flags & SQLITE_ForeignKeys ) == 0 ) + return; + + iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); + zDb = db.aDb[iDb].zName; + + /* Loop through all the foreign key constraints for which pTab is the + ** child table (the table that the foreign key definition is part of). */ + for ( pFKey = pTab.pFKey; pFKey != null; pFKey = pFKey.pNextFrom ) + { + Table pTo; /* Parent table of foreign key pFKey */ + Index pIdx = null; /* Index on key columns in pTo */ + int[] aiFree = null; + int[] aiCol; + int iCol; + int i; + int isIgnore = 0; + + /* Find the parent table of this foreign key. Also find a unique index + ** on the parent key columns in the parent table. If either of these + ** schema items cannot be located, set an error in pParse and return + ** early. */ + if ( pParse.disableTriggers != 0 ) + { + pTo = sqlite3FindTable( db, pFKey.zTo, zDb ); } - - /* - ** This function is called to generate code that runs when table pTab is - ** being dropped from the database. The SrcList passed as the second argument - ** to this function contains a single entry guaranteed to resolve to - ** table pTab. - ** - ** Normally, no code is required. However, if either - ** - ** (a) The table is the parent table of a FK constraint, or - ** (b) The table is the child table of a deferred FK constraint and it is - ** determined at runtime that there are outstanding deferred FK - ** constraint violations in the database, - ** - ** then the equivalent of "DELETE FROM " is executed before dropping - ** the table from the database. Triggers are disabled while running this - ** DELETE, but foreign key actions are not. - */ - static void sqlite3FkDropTable(Parse pParse, SrcList pName, Table pTab) { - sqlite3 db = pParse.db; - if ((db.flags & SQLITE_ForeignKeys) != 0 && !IsVirtual(pTab) && null == pTab.pSelect) { - int iSkip = 0; - Vdbe v = sqlite3GetVdbe(pParse); - - Debug.Assert(v != null); /* VDBE has already been allocated */ - if (sqlite3FkReferences(pTab) == null) { - /* Search for a deferred foreign key constraint for which this table - ** is the child table. If one cannot be found, return without - ** 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 != null; p = p.pNextFrom) { - if (p.isDeferred != 0) - break; - } - if (null == p) - return; - iSkip = sqlite3VdbeMakeLabel(v); - sqlite3VdbeAddOp2(v, OP_FkIfZero, 1, iSkip); - } - - pParse.disableTriggers = 1; - sqlite3DeleteFrom(pParse, sqlite3SrcListDup(db, pName, 0), null); - 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. */ - sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v) + 2); - sqlite3HaltConstraint( - pParse, OE_Abort, "foreign key constraint failed", P4_STATIC - ); - - if (iSkip != 0) { - sqlite3VdbeResolveLabel(v, iSkip); - } - } + else + { + pTo = sqlite3LocateTable( pParse, 0, pFKey.zTo, zDb ); } + if ( null == pTo || locateFkeyIndex( pParse, pTo, pFKey, out pIdx, out aiFree ) != 0 ) + { + if ( 0 == isIgnoreErrors /* || db.mallocFailed */) + return; + continue; + } + Debug.Assert( pFKey.nCol == 1 || ( aiFree != null && pIdx != null ) ); - /* - ** This function is called when inserting, deleting or updating a row of - ** table pTab to generate VDBE code to perform foreign key constraint - ** processing for the operation. - ** - ** For a DELETE operation, parameter regOld is passed the index of the - ** first register in an array of (pTab.nCol+1) registers containing the - ** rowid of the row being deleted, followed by each of the column values - ** of the row being deleted, from left to right. Parameter regNew is passed - ** zero in this case. - ** - ** For an INSERT operation, regOld is passed zero and regNew is passed the - ** first register of an array of (pTab.nCol+1) registers containing the new - ** row data. - ** - ** For an UPDATE operation, this function is called twice. Once before - ** the original record is deleted from the table using the calling convention - ** described for DELETE. Then again after the original record is deleted - ** but before the new record is inserted using the INSERT convention. - */ - static void sqlite3FkCheck( - Parse pParse, /* Parse context */ - Table pTab, /* Row is being deleted from this table */ - int regOld, /* Previous row data is stored here */ - int regNew /* New row data is stored here */ - ) { - sqlite3 db = pParse.db; /* Database handle */ - FKey pFKey; /* Used to iterate through FKs */ - int iDb; /* Index of database containing pTab */ - string zDb; /* Name of database containing pTab */ - int isIgnoreErrors = pParse.disableTriggers; - - /* Exactly one of regOld and regNew should be non-zero. */ - Debug.Assert((regOld == 0) != (regNew == 0)); - - /* If foreign-keys are disabled, this function is a no-op. */ - if ((db.flags & SQLITE_ForeignKeys) == 0) - return; - - iDb = sqlite3SchemaToIndex(db, pTab.pSchema); - zDb = db.aDb[iDb].zName; - - /* Loop through all the foreign key constraints for which pTab is the - ** child table (the table that the foreign key definition is part of). */ - for (pFKey = pTab.pFKey; pFKey != null; pFKey = pFKey.pNextFrom) { - Table pTo; /* Parent table of foreign key pFKey */ - Index pIdx = null; /* Index on key columns in pTo */ - int[] aiFree = null; - int[] aiCol; - int iCol; - int i; - int isIgnore = 0; - - /* Find the parent table of this foreign key. Also find a unique index - ** on the parent key columns in the parent table. If either of these - ** schema items cannot be located, set an error in pParse and return - ** early. */ - if (pParse.disableTriggers != 0) { - pTo = sqlite3FindTable(db, pFKey.zTo, zDb); - } else { - pTo = sqlite3LocateTable(pParse, 0, pFKey.zTo, zDb); - } - if (null == pTo || locateFkeyIndex(pParse, pTo, pFKey, out pIdx, out aiFree) != 0) { - if (0 == isIgnoreErrors /* || db.mallocFailed */) - return; - continue; - } - Debug.Assert(pFKey.nCol == 1 || (aiFree != null && pIdx != null)); - - if (aiFree != null) { - aiCol = aiFree; - } else { - iCol = pFKey.aCol[0].iFrom; - aiCol = new int[1]; - aiCol[0] = iCol; - } - for (i = 0; i < pFKey.nCol; i++) { - if (aiCol[i] == pTab.iPKey) { - aiCol[i] = -1; - } + if ( aiFree != null ) + { + aiCol = aiFree; + } + else + { + iCol = pFKey.aCol[0].iFrom; + aiCol = new int[1]; + aiCol[0] = iCol; + } + for ( i = 0; i < pFKey.nCol; i++ ) + { + if ( aiCol[i] == pTab.iPKey ) + { + aiCol[i] = -1; + } #if !SQLITE_OMIT_AUTHORIZATION /* Request permission to read the parent key columns. If the ** authorization callback returns SQLITE_IGNORE, behave as if any @@ -792,463 +860,516 @@ int regNew /* New row data is stored here */ isIgnore = (rcauth==SQLITE_IGNORE); } #endif - } - - /* Take a shared-cache advisory read-lock on the parent table. Allocate - ** a cursor to use to search the unique index on the parent key columns - ** in the parent table. */ - sqlite3TableLock(pParse, iDb, pTo.tnum, 0, pTo.zName); - pParse.nTab++; - - if (regOld != 0) { - /* A row is being removed from the child table. Search for the parent. - ** If the parent does not exist, removing the child row resolves an - ** outstanding foreign key constraint violation. */ - fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regOld, -1, isIgnore); - } - if (regNew != 0) { - /* A row is being added to the child table. If a parent row cannot - ** be found, adding the child row has violated the FK constraint. */ - fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regNew, +1, isIgnore); - } + } - sqlite3DbFree(db, ref aiFree); - } + /* Take a shared-cache advisory read-lock on the parent table. Allocate + ** a cursor to use to search the unique index on the parent key columns + ** in the parent table. */ + sqlite3TableLock( pParse, iDb, pTo.tnum, 0, pTo.zName ); + pParse.nTab++; + + if ( regOld != 0 ) + { + /* A row is being removed from the child table. Search for the parent. + ** If the parent does not exist, removing the child row resolves an + ** outstanding foreign key constraint violation. */ + fkLookupParent( pParse, iDb, pTo, pIdx, pFKey, aiCol, regOld, -1, isIgnore ); + } + if ( regNew != 0 ) + { + /* A row is being added to the child table. If a parent row cannot + ** be found, adding the child row has violated the FK constraint. */ + fkLookupParent( pParse, iDb, pTo, pIdx, pFKey, aiCol, regNew, +1, isIgnore ); + } - /* Loop through all the foreign key constraints that refer to this table */ - for (pFKey = sqlite3FkReferences(pTab); pFKey != null; pFKey = pFKey.pNextTo) { - Index pIdx = null; /* Foreign key index for pFKey */ - SrcList pSrc; - int[] aiCol = null; - - if (0 == pFKey.isDeferred && null == pParse.pToplevel && 0 == pParse.isMultiWrite) { - Debug.Assert(regOld == 0 && regNew != 0); - /* Inserting a single row into a parent table cannot cause an immediate - ** foreign key violation. So do nothing in this case. */ - continue; - } + sqlite3DbFree( db, ref aiFree ); + } - if (locateFkeyIndex(pParse, pTab, pFKey, out pIdx, out aiCol) != 0) { - if (0 == isIgnoreErrors /*|| db.mallocFailed */) - return; - continue; - } - Debug.Assert(aiCol != null || pFKey.nCol == 1); - - /* Create a SrcList structure containing a single table (the table - ** the foreign key that refers to this table is attached to). This - ** is required for the sqlite3WhereXXX() interface. */ - pSrc = sqlite3SrcListAppend(db, 0, null, null); - if (pSrc != null) { - SrcList_item pItem = pSrc.a[0]; - pItem.pTab = pFKey.pFrom; - pItem.zName = pFKey.pFrom.zName; - pItem.pTab.nRef++; - pItem.iCursor = pParse.nTab++; - - if (regNew != 0) { - fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regNew, -1); - } - if (regOld != 0) { - /* If there is a RESTRICT action configured for the current operation - ** on the parent table of this FK, then throw an exception - ** immediately if the FK constraint is violated, even if this is a - ** deferred trigger. That's what RESTRICT means. To defer checking - ** the constraint, the FK should specify NO ACTION (represented - ** using OE_None). NO ACTION is the default. */ - fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1); - } - pItem.zName = null; - sqlite3SrcListDelete(db, ref pSrc); - } - sqlite3DbFree(db, ref aiCol); - } + /* Loop through all the foreign key constraints that refer to this table */ + for ( pFKey = sqlite3FkReferences( pTab ); pFKey != null; pFKey = pFKey.pNextTo ) + { + Index pIdx = null; /* Foreign key index for pFKey */ + SrcList pSrc; + int[] aiCol = null; + + if ( 0 == pFKey.isDeferred && null == pParse.pToplevel && 0 == pParse.isMultiWrite ) + { + Debug.Assert( regOld == 0 && regNew != 0 ); + /* Inserting a single row into a parent table cannot cause an immediate + ** foreign key violation. So do nothing in this case. */ + continue; } - //#define COLUMN_MASK(x) (((x)>31) ? 0xffffffff : ((u32)1<<(x))) - static uint COLUMN_MASK(int x) { - return ((x) > 31) ? 0xffffffff : ((u32)1 << (x)); + if ( locateFkeyIndex( pParse, pTab, pFKey, out pIdx, out aiCol ) != 0 ) + { + if ( 0 == isIgnoreErrors /*|| db.mallocFailed */) + return; + continue; } - - /* - ** This function is called before generating code to update or delete a - ** row contained in table pTab. - */ - static u32 sqlite3FkOldmask( - Parse pParse, /* Parse context */ - Table pTab /* Table being modified */ - ) { - u32 mask = 0; - if ((pParse.db.flags & SQLITE_ForeignKeys) != 0) { - FKey p; - int i; - for (p = pTab.pFKey; p != null; p = p.pNextFrom) { - for (i = 0; i < p.nCol; i++) - mask |= COLUMN_MASK(p.aCol[i].iFrom); - } - for (p = sqlite3FkReferences(pTab); p != null; p = p.pNextTo) { - Index pIdx; - int[] iDummy; - locateFkeyIndex(pParse, pTab, p, out pIdx, out iDummy); - if (pIdx != null) { - for (i = 0; i < pIdx.nColumn; i++) - mask |= COLUMN_MASK(pIdx.aiColumn[i]); - } - } - } - return mask; + Debug.Assert( aiCol != null || pFKey.nCol == 1 ); + + /* Create a SrcList structure containing a single table (the table + ** the foreign key that refers to this table is attached to). This + ** is required for the sqlite3WhereXXX() interface. */ + pSrc = sqlite3SrcListAppend( db, 0, null, null ); + if ( pSrc != null ) + { + SrcList_item pItem = pSrc.a[0]; + pItem.pTab = pFKey.pFrom; + pItem.zName = pFKey.pFrom.zName; + pItem.pTab.nRef++; + pItem.iCursor = pParse.nTab++; + + if ( regNew != 0 ) + { + fkScanChildren( pParse, pSrc, pTab, pIdx, pFKey, aiCol, regNew, -1 ); + } + if ( regOld != 0 ) + { + /* If there is a RESTRICT action configured for the current operation + ** on the parent table of this FK, then throw an exception + ** immediately if the FK constraint is violated, even if this is a + ** deferred trigger. That's what RESTRICT means. To defer checking + ** the constraint, the FK should specify NO ACTION (represented + ** using OE_None). NO ACTION is the default. */ + fkScanChildren( pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1 ); + } + pItem.zName = null; + sqlite3SrcListDelete( db, ref pSrc ); } + sqlite3DbFree( db, ref aiCol ); + } + } - /* - ** This function is called before generating code to update or delete a - ** row contained in table pTab. If the operation is a DELETE, then - ** parameter aChange is passed a NULL value. For an UPDATE, aChange points - ** to an array of size N, where N is the number of columns in table pTab. - ** If the i'th column is not modified by the UPDATE, then the corresponding - ** entry in the aChange[] array is set to -1. If the column is modified, - ** the value is 0 or greater. Parameter chngRowid is set to true if the - ** UPDATE statement modifies the rowid fields of the table. - ** - ** If any foreign key processing will be required, this function returns - ** true. If there is no foreign key related processing, this function - ** returns false. - */ - static int sqlite3FkRequired( - Parse pParse, /* Parse context */ - Table pTab, /* Table being modified */ - int[] aChange, /* Non-NULL for UPDATE operations */ - int chngRowid /* True for UPDATE that affects rowid */ - ) { - if ((pParse.db.flags & SQLITE_ForeignKeys) != 0) { - if (null == aChange) { - /* A DELETE operation. Foreign key processing is required if the - ** table in question is either the child or parent table for any - ** foreign key constraint. */ - return (sqlite3FkReferences(pTab) != null || pTab.pFKey != null) ? 1 : 0; - } else { - /* This is an UPDATE. Foreign key processing is only required if the - ** operation modifies one or more child or parent key columns. */ - int i; - FKey p; - - /* Check if any child key columns are being modified. */ - for (p = pTab.pFKey; p != null; p = p.pNextFrom) { - for (i = 0; i < p.nCol; i++) { - int iChildKey = p.aCol[i].iFrom; - if (aChange[iChildKey] >= 0) - return 1; - if (iChildKey == pTab.iPKey && chngRowid != 0) - return 1; - } - } - - /* Check if any parent key columns are being modified. */ - for (p = sqlite3FkReferences(pTab); p != null; p = p.pNextTo) { - for (i = 0; i < p.nCol; i++) { - string zKey = p.aCol[i].zCol; - int iKey; - for (iKey = 0; iKey < pTab.nCol; iKey++) { - Column pCol = pTab.aCol[iKey]; - if ((!String.IsNullOrEmpty(zKey) ? pCol.zName.Equals(zKey, StringComparison.OrdinalIgnoreCase) : pCol.isPrimKey != 0)) { - if (aChange[iKey] >= 0) - return 1; - if (iKey == pTab.iPKey && chngRowid != 0) - return 1; - } - } - } - } - } - } - return 0; - } + //#define COLUMN_MASK(x) (((x)>31) ? 0xffffffff : ((u32)1<<(x))) + static uint COLUMN_MASK( int x ) + { + return ( ( x ) > 31 ) ? 0xffffffff : ( (u32)1 << ( x ) ); + } - /* - ** This function is called when an UPDATE or DELETE operation is being - ** compiled on table pTab, which is the parent table of foreign-key pFKey. - ** If the current operation is an UPDATE, then the pChanges parameter is - ** passed a pointer to the list of columns being modified. If it is a - ** DELETE, pChanges is passed a NULL pointer. - ** - ** It returns a pointer to a Trigger structure containing a trigger - ** equivalent to the ON UPDATE or ON DELETE action specified by pFKey. - ** If the action is "NO ACTION" or "RESTRICT", then a NULL pointer is - ** returned (these actions require no special handling by the triggers - ** sub-system, code for them is created by fkScanChildren()). - ** - ** For example, if pFKey is the foreign key and pTab is table "p" in - ** the following schema: - ** - ** CREATE TABLE p(pk PRIMARY KEY); - ** CREATE TABLE c(ck REFERENCES p ON DELETE CASCADE); - ** - ** then the returned trigger structure is equivalent to: - ** - ** CREATE TRIGGER ... DELETE ON p BEGIN - ** DELETE FROM c WHERE ck = old.pk; - ** END; - ** - ** The returned pointer is cached as part of the foreign key object. It - ** is eventually freed along with the rest of the foreign key object by - ** sqlite3FkDelete(). - */ - static Trigger fkActionTrigger( - Parse pParse, /* Parse context */ - Table pTab, /* Table being updated or deleted from */ - FKey pFKey, /* Foreign key to get action for */ - ExprList pChanges /* Change-list for UPDATE, NULL for DELETE */ - ) { - sqlite3 db = pParse.db; /* Database handle */ - int action; /* One of OE_None, OE_Cascade etc. */ - Trigger pTrigger; /* Trigger definition to return */ - int iAction = (pChanges != null) ? 1 : 0; /* 1 for UPDATE, 0 for DELETE */ - - action = pFKey.aAction[iAction]; - pTrigger = pFKey.apTrigger[iAction]; - - if (action != OE_None && null == pTrigger) { - u8 enableLookaside; /* Copy of db.lookaside.bEnabled */ - string zFrom; /* Name of child table */ - int nFrom; /* Length in bytes of zFrom */ - Index pIdx = null; /* Parent key index for this FK */ - int[] aiCol = null; /* child table cols . parent key cols */ - TriggerStep pStep = null; /* First (only) step of trigger program */ - Expr pWhere = null; /* WHERE clause of trigger step */ - ExprList pList = null; /* Changes list if ON UPDATE CASCADE */ - Select pSelect = null; /* If RESTRICT, "SELECT RAISE(...)" */ - int i; /* Iterator variable */ - Expr pWhen = null; /* WHEN clause for the trigger */ - - if (locateFkeyIndex(pParse, pTab, pFKey, out pIdx, out aiCol) != 0) - return null; - Debug.Assert(aiCol != null || pFKey.nCol == 1); - - for (i = 0; i < pFKey.nCol; i++) { - Token tOld = new Token("old", 3); /* Literal "old" token */ - Token tNew = new Token("new", 3); /* Literal "new" token */ - Token tFromCol = new Token(); /* Name of column in child table */ - Token tToCol = new Token(); /* Name of column in parent table */ - int iFromCol; /* Idx of column in child table */ - Expr pEq; /* tFromCol = OLD.tToCol */ - - iFromCol = aiCol != null ? aiCol[i] : pFKey.aCol[0].iFrom; - Debug.Assert(iFromCol >= 0); - tToCol.z = pIdx != null ? pTab.aCol[pIdx.aiColumn[i]].zName : "oid"; - tFromCol.z = pFKey.pFrom.aCol[iFromCol].zName; - - tToCol.n = sqlite3Strlen30(tToCol.z); - tFromCol.n = sqlite3Strlen30(tFromCol.z); - - /* Create the expression "OLD.zToCol = zFromCol". It is important - ** that the "OLD.zToCol" term is on the LHS of the = operator, so - ** that the affinity and collation sequence associated with the - ** parent table are used for the comparison. */ - pEq = sqlite3PExpr(pParse, TK_EQ, - sqlite3PExpr(pParse, TK_DOT, - sqlite3PExpr(pParse, TK_ID, null, null, tOld), - sqlite3PExpr(pParse, TK_ID, null, null, tToCol) - , 0), - sqlite3PExpr(pParse, TK_ID, null, null, tFromCol) - , 0); - pWhere = sqlite3ExprAnd(db, pWhere, pEq); - - /* For ON UPDATE, construct the next term of the WHEN clause. - ** The final WHEN clause will be like this: - ** - ** WHEN NOT(old.col1 IS new.col1 AND ... AND old.colN IS new.colN) - */ - if (pChanges != null) { - pEq = sqlite3PExpr(pParse, TK_IS, - sqlite3PExpr(pParse, TK_DOT, - sqlite3PExpr(pParse, TK_ID, null, null, tOld), - sqlite3PExpr(pParse, TK_ID, null, null, tToCol), - 0), - sqlite3PExpr(pParse, TK_DOT, - sqlite3PExpr(pParse, TK_ID, null, null, tNew), - sqlite3PExpr(pParse, TK_ID, null, null, tToCol), - 0), - 0); - pWhen = sqlite3ExprAnd(db, pWhen, pEq); - } - - if (action != OE_Restrict && (action != OE_Cascade || pChanges != null)) { - Expr pNew; - if (action == OE_Cascade) { - pNew = sqlite3PExpr(pParse, TK_DOT, - sqlite3PExpr(pParse, TK_ID, null, null, tNew), - sqlite3PExpr(pParse, TK_ID, null, null, tToCol) - , 0); - } else if (action == OE_SetDflt) { - Expr pDflt = pFKey.pFrom.aCol[iFromCol].pDflt; - if (pDflt != null) { - pNew = sqlite3ExprDup(db, pDflt, 0); - } else { - pNew = sqlite3PExpr(pParse, TK_NULL, 0, 0, 0); - } - } else { - pNew = sqlite3PExpr(pParse, TK_NULL, 0, 0, 0); - } - pList = sqlite3ExprListAppend(pParse, pList, pNew); - sqlite3ExprListSetName(pParse, pList, tFromCol, 0); - } - } - sqlite3DbFree(db, ref aiCol); - - zFrom = pFKey.pFrom.zName; - nFrom = sqlite3Strlen30(zFrom); - - if (action == OE_Restrict) { - Token tFrom = new Token(); - Expr pRaise; - - tFrom.z = zFrom; - tFrom.n = nFrom; - pRaise = sqlite3Expr(db, TK_RAISE, "foreign key constraint failed"); - if (pRaise != null) { - pRaise.affinity = (char)OE_Abort; - } - pSelect = sqlite3SelectNew(pParse, - sqlite3ExprListAppend(pParse, 0, pRaise), - sqlite3SrcListAppend(db, 0, tFrom, null), - pWhere, - null, null, null, 0, null, null - ); - pWhere = null; - } + /* + ** This function is called before generating code to update or delete a + ** row contained in table pTab. + */ + static u32 sqlite3FkOldmask( + Parse pParse, /* Parse context */ + Table pTab /* Table being modified */ + ) + { + u32 mask = 0; + if ( ( pParse.db.flags & SQLITE_ForeignKeys ) != 0 ) + { + FKey p; + int i; + for ( p = pTab.pFKey; p != null; p = p.pNextFrom ) + { + for ( i = 0; i < p.nCol; i++ ) + mask |= COLUMN_MASK( p.aCol[i].iFrom ); + } + for ( p = sqlite3FkReferences( pTab ); p != null; p = p.pNextTo ) + { + Index pIdx; + int[] iDummy; + locateFkeyIndex( pParse, pTab, p, out pIdx, out iDummy ); + if ( pIdx != null ) + { + for ( i = 0; i < pIdx.nColumn; i++ ) + mask |= COLUMN_MASK( pIdx.aiColumn[i] ); + } + } + } + return mask; + } - /* Disable lookaside memory allocation */ - enableLookaside = db.lookaside.bEnabled; - db.lookaside.bEnabled = 0; - - pTrigger = new Trigger(); - //(Trigger*)sqlite3DbMallocZero( db, - // sizeof( Trigger ) + /* struct Trigger */ - // sizeof( TriggerStep ) + /* Single step in trigger program */ - // nFrom + 1 /* Space for pStep.target.z */ - // ); - //if ( pTrigger ) + /* + ** This function is called before generating code to update or delete a + ** row contained in table pTab. If the operation is a DELETE, then + ** parameter aChange is passed a NULL value. For an UPDATE, aChange points + ** to an array of size N, where N is the number of columns in table pTab. + ** If the i'th column is not modified by the UPDATE, then the corresponding + ** entry in the aChange[] array is set to -1. If the column is modified, + ** the value is 0 or greater. Parameter chngRowid is set to true if the + ** UPDATE statement modifies the rowid fields of the table. + ** + ** If any foreign key processing will be required, this function returns + ** true. If there is no foreign key related processing, this function + ** returns false. + */ + static int sqlite3FkRequired( + Parse pParse, /* Parse context */ + Table pTab, /* Table being modified */ + int[] aChange, /* Non-NULL for UPDATE operations */ + int chngRowid /* True for UPDATE that affects rowid */ + ) + { + if ( ( pParse.db.flags & SQLITE_ForeignKeys ) != 0 ) + { + if ( null == aChange ) + { + /* A DELETE operation. Foreign key processing is required if the + ** table in question is either the child or parent table for any + ** foreign key constraint. */ + return ( sqlite3FkReferences( pTab ) != null || pTab.pFKey != null ) ? 1 : 0; + } + else + { + /* This is an UPDATE. Foreign key processing is only required if the + ** operation modifies one or more child or parent key columns. */ + int i; + FKey p; + + /* Check if any child key columns are being modified. */ + for ( p = pTab.pFKey; p != null; p = p.pNextFrom ) + { + for ( i = 0; i < p.nCol; i++ ) + { + int iChildKey = p.aCol[i].iFrom; + if ( aChange[iChildKey] >= 0 ) + return 1; + if ( iChildKey == pTab.iPKey && chngRowid != 0 ) + return 1; + } + } + + /* Check if any parent key columns are being modified. */ + for ( p = sqlite3FkReferences( pTab ); p != null; p = p.pNextTo ) + { + for ( i = 0; i < p.nCol; i++ ) + { + string zKey = p.aCol[i].zCol; + int iKey; + for ( iKey = 0; iKey < pTab.nCol; iKey++ ) + { + Column pCol = pTab.aCol[iKey]; + if ( ( !String.IsNullOrEmpty( zKey ) ? pCol.zName.Equals( zKey, StringComparison.OrdinalIgnoreCase ) : pCol.isPrimKey != 0 ) ) { - - pStep = pTrigger.step_list = new TriggerStep();// = (TriggerStep)pTrigger[1]; - //pStep.target.z = pStep[1]; - pStep.target.n = nFrom; - pStep.target.z = zFrom;// memcpy( (char*)pStep.target.z, zFrom, nFrom ); - - pStep.pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE); - pStep.pExprList = sqlite3ExprListDup(db, pList, EXPRDUP_REDUCE); - pStep.pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE); - if (pWhen != null) { - pWhen = sqlite3PExpr(pParse, TK_NOT, pWhen, 0, 0); - pTrigger.pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE); - } + if ( aChange[iKey] >= 0 ) + return 1; + if ( iKey == pTab.iPKey && chngRowid != 0 ) + return 1; } + } + } + } + } + } + return 0; + } - /* Re-enable the lookaside buffer, if it was disabled earlier. */ - db.lookaside.bEnabled = enableLookaside; - - sqlite3ExprDelete(db, ref pWhere); - sqlite3ExprDelete(db, ref pWhen); - sqlite3ExprListDelete(db, ref pList); - sqlite3SelectDelete(db, ref pSelect); - //if ( db.mallocFailed == 1 ) - //{ - // fkTriggerDelete( db, pTrigger ); - // return 0; - //} - - switch (action) { - case OE_Restrict: - pStep.op = TK_SELECT; - break; - case OE_Cascade: - if (null == pChanges) { - pStep.op = TK_DELETE; - break; - } - goto default; - default: - pStep.op = TK_UPDATE; - break; - } - pStep.pTrig = pTrigger; - pTrigger.pSchema = pTab.pSchema; - pTrigger.pTabSchema = pTab.pSchema; - pFKey.apTrigger[iAction] = pTrigger; - pTrigger.op = (byte)(pChanges != null ? TK_UPDATE : TK_DELETE); + /* + ** This function is called when an UPDATE or DELETE operation is being + ** compiled on table pTab, which is the parent table of foreign-key pFKey. + ** If the current operation is an UPDATE, then the pChanges parameter is + ** passed a pointer to the list of columns being modified. If it is a + ** DELETE, pChanges is passed a NULL pointer. + ** + ** It returns a pointer to a Trigger structure containing a trigger + ** equivalent to the ON UPDATE or ON DELETE action specified by pFKey. + ** If the action is "NO ACTION" or "RESTRICT", then a NULL pointer is + ** returned (these actions require no special handling by the triggers + ** sub-system, code for them is created by fkScanChildren()). + ** + ** For example, if pFKey is the foreign key and pTab is table "p" in + ** the following schema: + ** + ** CREATE TABLE p(pk PRIMARY KEY); + ** CREATE TABLE c(ck REFERENCES p ON DELETE CASCADE); + ** + ** then the returned trigger structure is equivalent to: + ** + ** CREATE TRIGGER ... DELETE ON p BEGIN + ** DELETE FROM c WHERE ck = old.pk; + ** END; + ** + ** The returned pointer is cached as part of the foreign key object. It + ** is eventually freed along with the rest of the foreign key object by + ** sqlite3FkDelete(). + */ + static Trigger fkActionTrigger( + Parse pParse, /* Parse context */ + Table pTab, /* Table being updated or deleted from */ + FKey pFKey, /* Foreign key to get action for */ + ExprList pChanges /* Change-list for UPDATE, NULL for DELETE */ + ) + { + sqlite3 db = pParse.db; /* Database handle */ + int action; /* One of OE_None, OE_Cascade etc. */ + Trigger pTrigger; /* Trigger definition to return */ + int iAction = ( pChanges != null ) ? 1 : 0; /* 1 for UPDATE, 0 for DELETE */ + + action = pFKey.aAction[iAction]; + pTrigger = pFKey.apTrigger[iAction]; + + if ( action != OE_None && null == pTrigger ) + { + u8 enableLookaside; /* Copy of db.lookaside.bEnabled */ + string zFrom; /* Name of child table */ + int nFrom; /* Length in bytes of zFrom */ + Index pIdx = null; /* Parent key index for this FK */ + int[] aiCol = null; /* child table cols . parent key cols */ + TriggerStep pStep = null; /* First (only) step of trigger program */ + Expr pWhere = null; /* WHERE clause of trigger step */ + ExprList pList = null; /* Changes list if ON UPDATE CASCADE */ + Select pSelect = null; /* If RESTRICT, "SELECT RAISE(...)" */ + int i; /* Iterator variable */ + Expr pWhen = null; /* WHEN clause for the trigger */ + + if ( locateFkeyIndex( pParse, pTab, pFKey, out pIdx, out aiCol ) != 0 ) + return null; + Debug.Assert( aiCol != null || pFKey.nCol == 1 ); + + for ( i = 0; i < pFKey.nCol; i++ ) + { + Token tOld = new Token( "old", 3 ); /* Literal "old" token */ + Token tNew = new Token( "new", 3 ); /* Literal "new" token */ + Token tFromCol = new Token(); /* Name of column in child table */ + Token tToCol = new Token(); /* Name of column in parent table */ + int iFromCol; /* Idx of column in child table */ + Expr pEq; /* tFromCol = OLD.tToCol */ + + iFromCol = aiCol != null ? aiCol[i] : pFKey.aCol[0].iFrom; + Debug.Assert( iFromCol >= 0 ); + tToCol.z = pIdx != null ? pTab.aCol[pIdx.aiColumn[i]].zName : "oid"; + tFromCol.z = pFKey.pFrom.aCol[iFromCol].zName; + + tToCol.n = sqlite3Strlen30( tToCol.z ); + tFromCol.n = sqlite3Strlen30( tFromCol.z ); + + /* Create the expression "OLD.zToCol = zFromCol". It is important + ** that the "OLD.zToCol" term is on the LHS of the = operator, so + ** that the affinity and collation sequence associated with the + ** parent table are used for the comparison. */ + pEq = sqlite3PExpr( pParse, TK_EQ, + sqlite3PExpr( pParse, TK_DOT, + sqlite3PExpr( pParse, TK_ID, null, null, tOld ), + sqlite3PExpr( pParse, TK_ID, null, null, tToCol ) + , 0 ), + sqlite3PExpr( pParse, TK_ID, null, null, tFromCol ) + , 0 ); + pWhere = sqlite3ExprAnd( db, pWhere, pEq ); + + /* For ON UPDATE, construct the next term of the WHEN clause. + ** The final WHEN clause will be like this: + ** + ** WHEN NOT(old.col1 IS new.col1 AND ... AND old.colN IS new.colN) + */ + if ( pChanges != null ) + { + pEq = sqlite3PExpr( pParse, TK_IS, + sqlite3PExpr( pParse, TK_DOT, + sqlite3PExpr( pParse, TK_ID, null, null, tOld ), + sqlite3PExpr( pParse, TK_ID, null, null, tToCol ), + 0 ), + sqlite3PExpr( pParse, TK_DOT, + sqlite3PExpr( pParse, TK_ID, null, null, tNew ), + sqlite3PExpr( pParse, TK_ID, null, null, tToCol ), + 0 ), + 0 ); + pWhen = sqlite3ExprAnd( db, pWhen, pEq ); + } + + if ( action != OE_Restrict && ( action != OE_Cascade || pChanges != null ) ) + { + Expr pNew; + if ( action == OE_Cascade ) + { + pNew = sqlite3PExpr( pParse, TK_DOT, + sqlite3PExpr( pParse, TK_ID, null, null, tNew ), + sqlite3PExpr( pParse, TK_ID, null, null, tToCol ) + , 0 ); } + else if ( action == OE_SetDflt ) + { + Expr pDflt = pFKey.pFrom.aCol[iFromCol].pDflt; + if ( pDflt != null ) + { + pNew = sqlite3ExprDup( db, pDflt, 0 ); + } + else + { + pNew = sqlite3PExpr( pParse, TK_NULL, 0, 0, 0 ); + } + } + else + { + pNew = sqlite3PExpr( pParse, TK_NULL, 0, 0, 0 ); + } + pList = sqlite3ExprListAppend( pParse, pList, pNew ); + sqlite3ExprListSetName( pParse, pList, tFromCol, 0 ); + } + } + sqlite3DbFree( db, ref aiCol ); + + zFrom = pFKey.pFrom.zName; + nFrom = sqlite3Strlen30( zFrom ); + + if ( action == OE_Restrict ) + { + Token tFrom = new Token(); + Expr pRaise; + + tFrom.z = zFrom; + tFrom.n = nFrom; + pRaise = sqlite3Expr( db, TK_RAISE, "foreign key constraint failed" ); + if ( pRaise != null ) + { + pRaise.affinity = (char)OE_Abort; + } + pSelect = sqlite3SelectNew( pParse, + sqlite3ExprListAppend( pParse, 0, pRaise ), + sqlite3SrcListAppend( db, 0, tFrom, null ), + pWhere, + null, null, null, 0, null, null + ); + pWhere = null; + } - return pTrigger; + /* Disable lookaside memory allocation */ + enableLookaside = db.lookaside.bEnabled; + db.lookaside.bEnabled = 0; + + pTrigger = new Trigger(); + //(Trigger*)sqlite3DbMallocZero( db, + // sizeof( Trigger ) + /* struct Trigger */ + // sizeof( TriggerStep ) + /* Single step in trigger program */ + // nFrom + 1 /* Space for pStep.target.z */ + // ); + //if ( pTrigger ) + { + + pStep = pTrigger.step_list = new TriggerStep();// = (TriggerStep)pTrigger[1]; + //pStep.target.z = pStep[1]; + pStep.target.n = nFrom; + pStep.target.z = zFrom;// memcpy( (char*)pStep.target.z, zFrom, nFrom ); + + pStep.pWhere = sqlite3ExprDup( db, pWhere, EXPRDUP_REDUCE ); + pStep.pExprList = sqlite3ExprListDup( db, pList, EXPRDUP_REDUCE ); + pStep.pSelect = sqlite3SelectDup( db, pSelect, EXPRDUP_REDUCE ); + if ( pWhen != null ) + { + pWhen = sqlite3PExpr( pParse, TK_NOT, pWhen, 0, 0 ); + pTrigger.pWhen = sqlite3ExprDup( db, pWhen, EXPRDUP_REDUCE ); + } } - /* - ** This function is called when deleting or updating a row to implement - ** any required CASCADE, SET NULL or SET DEFAULT actions. - */ - static void sqlite3FkActions( - Parse pParse, /* Parse context */ - Table pTab, /* Table being updated or deleted from */ - ExprList pChanges, /* Change-list for UPDATE, NULL for DELETE */ - int regOld /* Address of array containing old row */ - ) { - /* If foreign-key support is enabled, iterate through all FKs that - ** refer to table pTab. If there is an action a6ssociated with the FK - ** for this operation (either update or delete), invoke the associated - ** trigger sub-program. */ - if ((pParse.db.flags & SQLITE_ForeignKeys) != 0) { - FKey pFKey; /* Iterator variable */ - for (pFKey = sqlite3FkReferences(pTab); pFKey != null; pFKey = pFKey.pNextTo) { - Trigger pAction = fkActionTrigger(pParse, pTab, pFKey, pChanges); - if (pAction != null) { - sqlite3CodeRowTriggerDirect(pParse, pAction, pTab, regOld, OE_Abort, 0); - } - } + /* Re-enable the lookaside buffer, if it was disabled earlier. */ + db.lookaside.bEnabled = enableLookaside; + + sqlite3ExprDelete( db, ref pWhere ); + sqlite3ExprDelete( db, ref pWhen ); + sqlite3ExprListDelete( db, ref pList ); + sqlite3SelectDelete( db, ref pSelect ); + //if ( db.mallocFailed == 1 ) + //{ + // fkTriggerDelete( db, pTrigger ); + // return 0; + //} + + switch ( action ) + { + case OE_Restrict: + pStep.op = TK_SELECT; + break; + case OE_Cascade: + if ( null == pChanges ) + { + pStep.op = TK_DELETE; + break; } + goto default; + default: + pStep.op = TK_UPDATE; + break; } + pStep.pTrig = pTrigger; + pTrigger.pSchema = pTab.pSchema; + pTrigger.pTabSchema = pTab.pSchema; + pFKey.apTrigger[iAction] = pTrigger; + pTrigger.op = (byte)( pChanges != null ? TK_UPDATE : TK_DELETE ); + } -#endif //* ifndef SQLITE_OMIT_TRIGGER */ + return pTrigger; + } - /* - ** Free all memory associated with foreign key definitions attached to - ** table pTab. Remove the deleted foreign keys from the Schema.fkeyHash - ** hash table. + /* + ** This function is called when deleting or updating a row to implement + ** any required CASCADE, SET NULL or SET DEFAULT actions. */ - static void sqlite3FkDelete(sqlite3 db, Table pTab) { - FKey pFKey; /* Iterator variable */ - FKey pNext; /* Copy of pFKey.pNextFrom */ + static void sqlite3FkActions( + Parse pParse, /* Parse context */ + Table pTab, /* Table being updated or deleted from */ + ExprList pChanges, /* Change-list for UPDATE, NULL for DELETE */ + int regOld /* Address of array containing old row */ + ) + { + /* If foreign-key support is enabled, iterate through all FKs that + ** refer to table pTab. If there is an action a6ssociated with the FK + ** for this operation (either update or delete), invoke the associated + ** trigger sub-program. */ + if ( ( pParse.db.flags & SQLITE_ForeignKeys ) != 0 ) + { + FKey pFKey; /* Iterator variable */ + for ( pFKey = sqlite3FkReferences( pTab ); pFKey != null; pFKey = pFKey.pNextTo ) + { + Trigger pAction = fkActionTrigger( pParse, pTab, pFKey, pChanges ); + if ( pAction != null ) + { + sqlite3CodeRowTriggerDirect( pParse, pAction, pTab, regOld, OE_Abort, 0 ); + } + } + } + } - Debug.Assert(db == null || sqlite3SchemaMutexHeld(db, 0, pTab.pSchema)); - for (pFKey = pTab.pFKey; pFKey != null; pFKey = pNext) { +#endif //* ifndef SQLITE_OMIT_TRIGGER */ - /* Remove the FK from the fkeyHash hash table. */ - //if ( null == db || db.pnBytesFreed == 0 ) - { - if (pFKey.pPrevTo != null) { - pFKey.pPrevTo.pNextTo = pFKey.pNextTo; - } else { - FKey p = pFKey.pNextTo; - string z = (p != null ? pFKey.pNextTo.zTo : pFKey.zTo); - sqlite3HashInsert(ref pTab.pSchema.fkeyHash, z, sqlite3Strlen30(z), p); - } - if (pFKey.pNextTo != null) { - pFKey.pNextTo.pPrevTo = pFKey.pPrevTo; - } - } + /* +** Free all memory associated with foreign key definitions attached to +** table pTab. Remove the deleted foreign keys from the Schema.fkeyHash +** hash table. +*/ + static void sqlite3FkDelete( sqlite3 db, Table pTab ) + { + FKey pFKey; /* Iterator variable */ + FKey pNext; /* Copy of pFKey.pNextFrom */ + + Debug.Assert( db == null || sqlite3SchemaMutexHeld( db, 0, pTab.pSchema ) ); + for ( pFKey = pTab.pFKey; pFKey != null; pFKey = pNext ) + { + + /* Remove the FK from the fkeyHash hash table. */ + //if ( null == db || db.pnBytesFreed == 0 ) + { + if ( pFKey.pPrevTo != null ) + { + pFKey.pPrevTo.pNextTo = pFKey.pNextTo; + } + else + { + FKey p = pFKey.pNextTo; + string z = ( p != null ? pFKey.pNextTo.zTo : pFKey.zTo ); + sqlite3HashInsert( ref pTab.pSchema.fkeyHash, z, sqlite3Strlen30( z ), p ); + } + if ( pFKey.pNextTo != null ) + { + pFKey.pNextTo.pPrevTo = pFKey.pPrevTo; + } + } - /* EV: R-30323-21917 Each foreign key constraint in SQLite is - ** classified as either immediate or deferred. - */ - Debug.Assert(pFKey.isDeferred == 0 || pFKey.isDeferred == 1); + /* EV: R-30323-21917 Each foreign key constraint in SQLite is + ** classified as either immediate or deferred. + */ + Debug.Assert( pFKey.isDeferred == 0 || pFKey.isDeferred == 1 ); - /* Delete any triggers created to implement actions for this FK. */ + /* Delete any triggers created to implement actions for this FK. */ #if !SQLITE_OMIT_TRIGGER - fkTriggerDelete(db, pFKey.apTrigger[0]); - fkTriggerDelete(db, pFKey.apTrigger[1]); + fkTriggerDelete( db, pFKey.apTrigger[0] ); + fkTriggerDelete( db, pFKey.apTrigger[1] ); #endif - pNext = pFKey.pNextFrom; - sqlite3DbFree(db, ref pFKey); - } - } -#endif //* ifndef SQLITE_OMIT_FOREIGN_KEY */ + pNext = pFKey.pNextFrom; + sqlite3DbFree( db, ref pFKey ); + } } +#endif //* ifndef SQLITE_OMIT_FOREIGN_KEY */ + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/func_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/func_c.cs index a55142321..bc4097cda 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/func_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/func_c.cs @@ -2,449 +2,507 @@ using System.Diagnostics; using System.Text; -using i64 = System.Int64; using sqlite3_int64 = System.Int64; -using u32 = System.UInt32; +using i64 = System.Int64; using u8 = System.Byte; +using u32 = System.UInt32; +using u64 = System.UInt64; -namespace Community.CsharpSqlite { - using sqlite_int64 = System.Int64; - using sqlite3_value = Sqlite3.Mem; - - public partial class Sqlite3 { - /* - ** 2002 February 23 - ** - ** 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 contains the C functions that implement various SQL - ** functions of SQLite. - ** - ** There is only one exported symbol in this file - the function - ** sqliteRegisterBuildinFunctions() found at the bottom of the file. - ** All other code has file scope. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include - //#include - //#include "vdbeInt.h" +namespace Community.CsharpSqlite +{ + using sqlite3_value = Sqlite3.Mem; + using sqlite_int64 = System.Int64; + public partial class Sqlite3 + { + /* + ** 2002 February 23 + ** + ** 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 contains the C functions that implement various SQL + ** functions of SQLite. + ** + ** There is only one exported symbol in this file - the function + ** sqliteRegisterBuildinFunctions() found at the bottom of the file. + ** All other code has file scope. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include + //#include + //#include "vdbeInt.h" - /* - ** Return the collating function associated with a function. - */ - static CollSeq sqlite3GetFuncCollSeq(sqlite3_context context) { - return context.pColl; - } - /* - ** Implementation of the non-aggregate min() and max() functions - */ - static void minmaxFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - int i; - int mask; /* 0 for min() or 0xffffffff for max() */ - int iBest; - CollSeq pColl; - - Debug.Assert(argc > 1); - mask = (int)sqlite3_user_data(context) == 0 ? 0 : -1; - pColl = sqlite3GetFuncCollSeq(context); - Debug.Assert(pColl != null); - Debug.Assert(mask == -1 || mask == 0); - testcase(mask == 0); - iBest = 0; - if (sqlite3_value_type(argv[0]) == SQLITE_NULL) - return; - for (i = 1; i < argc; i++) { - if (sqlite3_value_type(argv[i]) == SQLITE_NULL) - return; - if ((sqlite3MemCompare(argv[iBest], argv[i], pColl) ^ mask) >= 0) { - iBest = i; - } - } - sqlite3_result_value(context, argv[iBest]); - } + /* + ** Return the collating function associated with a function. + */ + static CollSeq sqlite3GetFuncCollSeq( sqlite3_context context ) + { + return context.pColl; + } - /* - ** Return the type of the argument. - */ - static void typeofFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] argv - ) { - string z = ""; - UNUSED_PARAMETER(NotUsed); - switch (sqlite3_value_type(argv[0])) { - case SQLITE_INTEGER: - z = "integer"; - break; - case SQLITE_TEXT: - z = "text"; - break; - case SQLITE_FLOAT: - z = "real"; - break; - case SQLITE_BLOB: - z = "blob"; - break; - default: - z = "null"; - break; - } - sqlite3_result_text(context, z, -1, SQLITE_STATIC); + /* + ** Implementation of the non-aggregate min() and max() functions + */ + static void minmaxFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + int i; + int mask; /* 0 for min() or 0xffffffff for max() */ + int iBest; + CollSeq pColl; + + Debug.Assert( argc > 1 ); + mask = (int)sqlite3_user_data( context ) == 0 ? 0 : -1; + pColl = sqlite3GetFuncCollSeq( context ); + Debug.Assert( pColl != null ); + Debug.Assert( mask == -1 || mask == 0 ); + testcase( mask == 0 ); + iBest = 0; + if ( sqlite3_value_type( argv[0] ) == SQLITE_NULL ) + return; + for ( i = 1; i < argc; i++ ) + { + if ( sqlite3_value_type( argv[i] ) == SQLITE_NULL ) + return; + if ( ( sqlite3MemCompare( argv[iBest], argv[i], pColl ) ^ mask ) >= 0 ) + { + iBest = i; } + } + sqlite3_result_value( context, argv[iBest] ); + } + /* + ** Return the type of the argument. + */ + static void typeofFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] argv + ) + { + string z = ""; + UNUSED_PARAMETER( NotUsed ); + switch ( sqlite3_value_type( argv[0] ) ) + { + case SQLITE_INTEGER: + z = "integer"; + break; + case SQLITE_TEXT: + z = "text"; + break; + case SQLITE_FLOAT: + z = "real"; + break; + case SQLITE_BLOB: + z = "blob"; + break; + default: + z = "null"; + break; + } + sqlite3_result_text( context, z, -1, SQLITE_STATIC ); + } - /* - ** Implementation of the length() function - */ - static void lengthFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - int len; - - Debug.Assert(argc == 1); - UNUSED_PARAMETER(argc); - switch (sqlite3_value_type(argv[0])) { - case SQLITE_BLOB: - case SQLITE_INTEGER: - case SQLITE_FLOAT: { - sqlite3_result_int(context, sqlite3_value_bytes(argv[0])); - break; - } - case SQLITE_TEXT: { - byte[] z = sqlite3_value_blob(argv[0]); - if (z == null) - return; - len = 0; - int iz = 0; - while (iz < z.Length && z[iz] != '\0') { - len++; - SQLITE_SKIP_UTF8(z, ref iz); - } - sqlite3_result_int(context, len); - break; - } - default: { - sqlite3_result_null(context); - break; - } - } - } - /* - ** Implementation of the abs() function. - ** - ** IMP: R-23979-26855 The abs(X) function returns the absolute value of - ** the numeric argument X. - */ - static void absFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - Debug.Assert(argc == 1); - UNUSED_PARAMETER(argc); - switch (sqlite3_value_type(argv[0])) { - case SQLITE_INTEGER: { - i64 iVal = sqlite3_value_int64(argv[0]); - if (iVal < 0) { - if ((iVal << 1) == 0) { - /* IMP: R-35460-15084 If X is the integer -9223372036854775807 then - ** abs(X) throws an integer overflow error since there is no - ** equivalent positive 64-bit two complement value. */ - sqlite3_result_error(context, "integer overflow", -1); - return; - } - iVal = -iVal; - } - sqlite3_result_int64(context, iVal); - break; - } - case SQLITE_NULL: { - /* IMP: R-37434-19929 Abs(X) returns NULL if X is NULL. */ - sqlite3_result_null(context); - break; - } - default: { - /* Because sqlite3_value_double() returns 0.0 if the argument is not - ** something that can be converted into a number, we have: - ** IMP: R-57326-31541 Abs(X) return 0.0 if X is a string or blob that - ** cannot be converted to a numeric value. - */ - double rVal = sqlite3_value_double(argv[0]); - if (rVal < 0) - rVal = -rVal; - sqlite3_result_double(context, rVal); - break; - } + /* + ** Implementation of the length() function + */ + static void lengthFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + int len; + + Debug.Assert( argc == 1 ); + UNUSED_PARAMETER( argc ); + switch ( sqlite3_value_type( argv[0] ) ) + { + case SQLITE_BLOB: + case SQLITE_INTEGER: + case SQLITE_FLOAT: + { + sqlite3_result_int( context, sqlite3_value_bytes( argv[0] ) ); + break; + } + case SQLITE_TEXT: + { + byte[] z = sqlite3_value_blob( argv[0] ); + if ( z == null ) + return; + len = 0; + int iz = 0; + while ( iz < z.Length && z[iz] != '\0' ) + { + len++; + SQLITE_SKIP_UTF8( z, ref iz ); } - } + sqlite3_result_int( context, len ); + break; + } + default: + { + sqlite3_result_null( context ); + break; + } + } + } - /* - ** Implementation of the substr() function. - ** - ** substr(x,p1,p2) returns p2 characters of x[] beginning with p1. - ** p1 is 1-indexed. So substr(x,1,1) returns the first character - ** of x. If x is text, then we actually count UTF-8 characters. - ** If x is a blob, then we count bytes. - ** - ** If p1 is negative, then we begin abs(p1) from the end of x[]. - ** - ** If p2 is negative, return the p2 characters preceeding p1. - */ - static void substrFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - string z = ""; - byte[] zBLOB = null; - string z2; - int len; - int p0type; - int p1, p2; - int negP2 = 0; - - Debug.Assert(argc == 3 || argc == 2); - if (sqlite3_value_type(argv[1]) == SQLITE_NULL - || (argc == 3 && sqlite3_value_type(argv[2]) == SQLITE_NULL) - ) { + /* + ** Implementation of the abs() function. + ** + ** IMP: R-23979-26855 The abs(X) function returns the absolute value of + ** the numeric argument X. + */ + static void absFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + Debug.Assert( argc == 1 ); + UNUSED_PARAMETER( argc ); + switch ( sqlite3_value_type( argv[0] ) ) + { + case SQLITE_INTEGER: + { + i64 iVal = sqlite3_value_int64( argv[0] ); + if ( iVal < 0 ) + { + if ( ( iVal << 1 ) == 0 ) + { + /* IMP: R-35460-15084 If X is the integer -9223372036854775807 then + ** abs(X) throws an integer overflow error since there is no + ** equivalent positive 64-bit two complement value. */ + sqlite3_result_error( context, "integer overflow", -1 ); return; + } + iVal = -iVal; } - p0type = sqlite3_value_type(argv[0]); - p1 = sqlite3_value_int(argv[1]); - if (p0type == SQLITE_BLOB) { - len = sqlite3_value_bytes(argv[0]); - zBLOB = argv[0].zBLOB; - if (zBLOB == null) - return; - Debug.Assert(len == zBLOB.Length); - } else { - z = sqlite3_value_text(argv[0]); - if (String.IsNullOrEmpty(z)) - return; - len = 0; - if (p1 < 0) { - len = z.Length; - //for ( z2 = z ; z2 != "" ; len++ ) - //{ - // SQLITE_SKIP_UTF8( ref z2 ); - //} - } - } - if (argc == 3) { - p2 = sqlite3_value_int(argv[2]); - if (p2 < 0) { - p2 = -p2; - negP2 = 1; - } - } else { - p2 = (sqlite3_context_db_handle(context)).aLimit[SQLITE_LIMIT_LENGTH]; - } - if (p1 < 0) { - p1 += len; - if (p1 < 0) { - p2 += p1; - if (p2 < 0) - p2 = 0; - p1 = 0; - } - } else if (p1 > 0) { - p1--; - } else if (p2 > 0) { - p2--; - } - if (negP2 != 0) { - p1 -= p2; - if (p1 < 0) { - p2 += p1; - p1 = 0; - } - } - Debug.Assert(p1 >= 0 && p2 >= 0); - if (p0type != SQLITE_BLOB) { - //while ( z != "" && p1 != 0 ) - //{ - // SQLITE_SKIP_UTF8( ref z ); - // p1--; - //} - //for ( z2 = z ; z2 != "" && p2 != 0 ; p2-- ) - //{ - // SQLITE_SKIP_UTF8( ref z2 ); - //} - sqlite3_result_text(context, z, p1, p2 <= z.Length - p1 ? p2 : z.Length - p1, SQLITE_TRANSIENT); - } else { - if (p1 + p2 > len) { - p2 = len - p1; - if (p2 < 0) - p2 = 0; - } - StringBuilder sb = new StringBuilder(zBLOB.Length); - if (zBLOB.Length == 0 || p1 > zBLOB.Length) - sb.Length = 0; - else { - for (int i = p1; i < p1 + p2; i++) { - sb.Append((char)zBLOB[i]); - } - } + sqlite3_result_int64( context, iVal ); + break; + } + case SQLITE_NULL: + { + /* IMP: R-37434-19929 Abs(X) returns NULL if X is NULL. */ + sqlite3_result_null( context ); + break; + } + default: + { + /* Because sqlite3_value_double() returns 0.0 if the argument is not + ** something that can be converted into a number, we have: + ** IMP: R-57326-31541 Abs(X) return 0.0 if X is a string or blob that + ** cannot be converted to a numeric value. + */ + double rVal = sqlite3_value_double( argv[0] ); + if ( rVal < 0 ) + rVal = -rVal; + sqlite3_result_double( context, rVal ); + break; + } + } + } - sqlite3_result_blob(context, sb.ToString(), (int)p2, SQLITE_TRANSIENT); - } + /* + ** Implementation of the substr() function. + ** + ** substr(x,p1,p2) returns p2 characters of x[] beginning with p1. + ** p1 is 1-indexed. So substr(x,1,1) returns the first character + ** of x. If x is text, then we actually count UTF-8 characters. + ** If x is a blob, then we count bytes. + ** + ** If p1 is negative, then we begin abs(p1) from the end of x[]. + ** + ** If p2 is negative, return the p2 characters preceeding p1. + */ + static void substrFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + string z = ""; + byte[] zBLOB = null; + string z2; + int len; + int p0type; + int p1, p2; + int negP2 = 0; + + Debug.Assert( argc == 3 || argc == 2 ); + if ( sqlite3_value_type( argv[1] ) == SQLITE_NULL + || ( argc == 3 && sqlite3_value_type( argv[2] ) == SQLITE_NULL ) + ) + { + return; + } + p0type = sqlite3_value_type( argv[0] ); + p1 = sqlite3_value_int( argv[1] ); + if ( p0type == SQLITE_BLOB ) + { + len = sqlite3_value_bytes( argv[0] ); + zBLOB = argv[0].zBLOB; + if ( zBLOB == null ) + return; + Debug.Assert( len == zBLOB.Length ); + } + else + { + z = sqlite3_value_text( argv[0] ); + if ( String.IsNullOrEmpty( z ) ) + return; + len = 0; + if ( p1 < 0 ) + { + len = z.Length; + //for ( z2 = z ; z2 != "" ; len++ ) + //{ + // SQLITE_SKIP_UTF8( ref z2 ); + //} + } + } + if ( argc == 3 ) + { + p2 = sqlite3_value_int( argv[2] ); + if ( p2 < 0 ) + { + p2 = -p2; + negP2 = 1; + } + } + else + { + p2 = ( sqlite3_context_db_handle( context ) ).aLimit[SQLITE_LIMIT_LENGTH]; + } + if ( p1 < 0 ) + { + p1 += len; + if ( p1 < 0 ) + { + p2 += p1; + if ( p2 < 0 ) + p2 = 0; + p1 = 0; + } + } + else if ( p1 > 0 ) + { + p1--; + } + else if ( p2 > 0 ) + { + p2--; + } + if ( negP2 != 0 ) + { + p1 -= p2; + if ( p1 < 0 ) + { + p2 += p1; + p1 = 0; + } + } + Debug.Assert( p1 >= 0 && p2 >= 0 ); + if ( p0type != SQLITE_BLOB ) + { + //while ( z != "" && p1 != 0 ) + //{ + // SQLITE_SKIP_UTF8( ref z ); + // p1--; + //} + //for ( z2 = z ; z2 != "" && p2 != 0 ; p2-- ) + //{ + // SQLITE_SKIP_UTF8( ref z2 ); + //} + sqlite3_result_text( context, z, p1, p2 <= z.Length - p1 ? p2 : z.Length - p1, SQLITE_TRANSIENT ); + } + else + { + if ( p1 + p2 > len ) + { + p2 = len - p1; + if ( p2 < 0 ) + p2 = 0; + } + StringBuilder sb = new StringBuilder( zBLOB.Length ); + if ( zBLOB.Length == 0 || p1 > zBLOB.Length ) + sb.Length = 0; + else + { + for ( int i = p1; i < p1 + p2; i++ ) + { + sb.Append( (char)zBLOB[i] ); + } } - /* - ** Implementation of the round() function - */ + sqlite3_result_blob( context, sb.ToString(), (int)p2, SQLITE_TRANSIENT ); + } + } + + /* + ** Implementation of the round() function + */ #if !SQLITE_OMIT_FLOATING_POINT - static void roundFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - int n = 0; - double r; - string zBuf = ""; - Debug.Assert(argc == 1 || argc == 2); - if (argc == 2) { - if (SQLITE_NULL == sqlite3_value_type(argv[1])) - return; - n = sqlite3_value_int(argv[1]); - if (n > 30) - n = 30; - if (n < 0) - n = 0; - } - if (sqlite3_value_type(argv[0]) == SQLITE_NULL) - return; - r = sqlite3_value_double(argv[0]); - /* If Y==0 and X will fit in a 64-bit int, - ** handle the rounding directly, - ** otherwise use printf. - */ - if (n == 0 && r >= 0 && r < LARGEST_INT64 - 1) { - r = (double)((sqlite_int64)(r + 0.5)); - } else if (n == 0 && r < 0 && (-r) < LARGEST_INT64 - 1) { - r = -(double)((sqlite_int64)((-r) + 0.5)); - } else { - zBuf = sqlite3_mprintf("%.*f", n, r); - if (zBuf == null) { - sqlite3_result_error_nomem(context); - return; - } - sqlite3AtoF(zBuf, ref r, sqlite3Strlen30(zBuf), SQLITE_UTF8); - //sqlite3_free( ref zBuf ); - } - sqlite3_result_double(context, r); + static void roundFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + int n = 0; + double r; + string zBuf = ""; + Debug.Assert( argc == 1 || argc == 2 ); + if ( argc == 2 ) + { + if ( SQLITE_NULL == sqlite3_value_type( argv[1] ) ) + return; + n = sqlite3_value_int( argv[1] ); + if ( n > 30 ) + n = 30; + if ( n < 0 ) + n = 0; + } + if ( sqlite3_value_type( argv[0] ) == SQLITE_NULL ) + return; + r = sqlite3_value_double( argv[0] ); + /* If Y==0 and X will fit in a 64-bit int, + ** handle the rounding directly, + ** otherwise use printf. + */ + if ( n == 0 && r >= 0 && r < LARGEST_INT64 - 1 ) + { + r = (double)( (sqlite_int64)( r + 0.5 ) ); + } + else if ( n == 0 && r < 0 && ( -r ) < LARGEST_INT64 - 1 ) + { + r = -(double)( (sqlite_int64)( ( -r ) + 0.5 ) ); + } + else + { + zBuf = sqlite3_mprintf( "%.*f", n, r ); + if ( zBuf == null ) + { + sqlite3_result_error_nomem( context ); + return; } + sqlite3AtoF( zBuf, ref r, sqlite3Strlen30( zBuf ), SQLITE_UTF8 ); + //sqlite3_free( ref zBuf ); + } + sqlite3_result_double( context, r ); + } #endif - /* - ** Allocate nByte bytes of space using sqlite3_malloc(). If the - ** allocation fails, call sqlite3_result_error_nomem() to notify - ** the database handle that malloc() has failed and return NULL. - ** If nByte is larger than the maximum string or blob length, then - ** raise an SQLITE_TOOBIG exception and return NULL. + /* +** Allocate nByte bytes of space using sqlite3_malloc(). If the +** allocation fails, call sqlite3_result_error_nomem() to notify +** the database handle that malloc() has failed and return NULL. +** If nByte is larger than the maximum string or blob length, then +** raise an SQLITE_TOOBIG exception and return NULL. +*/ + //static void* contextMalloc( sqlite3_context* context, i64 nByte ) + //{ + // char* z; + // sqlite3* db = sqlite3_context_db_handle( context ); + // assert( nByte > 0 ); + // testcase( nByte == db->aLimit[SQLITE_LIMIT_LENGTH] ); + // testcase( nByte == db->aLimit[SQLITE_LIMIT_LENGTH] + 1 ); + // if ( nByte > db->aLimit[SQLITE_LIMIT_LENGTH] ) + // { + // sqlite3_result_error_toobig( context ); + // z = 0; + // } + // else + // { + // z = sqlite3Malloc( (int)nByte ); + // if ( !z ) + // { + // sqlite3_result_error_nomem( context ); + // } + // } + // return z; + //} + + /* + ** Implementation of the upper() and lower() SQL functions. */ - //static void* contextMalloc( sqlite3_context* context, i64 nByte ) + static void upperFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + string z1; + string z2; + int i, n; + UNUSED_PARAMETER( argc ); + z2 = sqlite3_value_text( argv[0] ); + n = sqlite3_value_bytes( argv[0] ); + /* Verify that the call to _bytes() does not invalidate the _text() pointer */ + //Debug.Assert( z2 == sqlite3_value_text( argv[0] ) ); + if ( z2 != null ) + { + //z1 = new byte[n];// contextMalloc(context, ((i64)n)+1); + //if ( z1 !=null) //{ - // char* z; - // sqlite3* db = sqlite3_context_db_handle( context ); - // assert( nByte > 0 ); - // testcase( nByte == db->aLimit[SQLITE_LIMIT_LENGTH] ); - // testcase( nByte == db->aLimit[SQLITE_LIMIT_LENGTH] + 1 ); - // if ( nByte > db->aLimit[SQLITE_LIMIT_LENGTH] ) - // { - // sqlite3_result_error_toobig( context ); - // z = 0; - // } - // else + // memcpy( z1, z2, n + 1 ); + //for ( i = 0 ; i< z1.Length ; i++ ) + //{ + //(char)sqlite3Toupper( z1[i] ); + //} + sqlite3_result_text( context, z2.Length == 0 ? "" : z2.Substring( 0, n ).ToUpperInvariant(), -1, null ); //sqlite3_free ); + // } + } + } + + static void lowerFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + string z1; + string z2; + int i, n; + UNUSED_PARAMETER( argc ); + z2 = sqlite3_value_text( argv[0] ); + n = sqlite3_value_bytes( argv[0] ); + /* Verify that the call to _bytes() does not invalidate the _text() pointer */ + //Debug.Assert( z2 == sqlite3_value_text( argv[0] ) ); + if ( z2 != null ) + { + //z1 = contextMalloc(context, ((i64)n)+1); + //if ( z1 ) + //{ + // memcpy( z1, z2, n + 1 ); + // for ( i = 0 ; z1[i] ; i++ ) // { - // z = sqlite3Malloc( (int)nByte ); - // if ( !z ) - // { - // sqlite3_result_error_nomem( context ); - // } + // z1[i] = (char)sqlite3Tolower( z1[i] ); // } - // return z; + sqlite3_result_text( context, z2.Length == 0 ? "" : z2.Substring( 0, n ).ToLowerInvariant(), -1, null );//sqlite3_free ); //} - - /* - ** Implementation of the upper() and lower() SQL functions. - */ - static void upperFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - string z1; - string z2; - int i, n; - UNUSED_PARAMETER(argc); - z2 = sqlite3_value_text(argv[0]); - n = sqlite3_value_bytes(argv[0]); - /* Verify that the call to _bytes() does not invalidate the _text() pointer */ - //Debug.Assert( z2 == sqlite3_value_text( argv[0] ) ); - if (z2 != null) { - //z1 = new byte[n];// contextMalloc(context, ((i64)n)+1); - //if ( z1 !=null) - //{ - // memcpy( z1, z2, n + 1 ); - //for ( i = 0 ; i< z1.Length ; i++ ) - //{ - //(char)sqlite3Toupper( z1[i] ); - //} - sqlite3_result_text(context, z2.Length == 0 ? "" : z2.Substring(0, n).ToUpperInvariant(), -1, null); //sqlite3_free ); - // } - } - } - - static void lowerFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - string z1; - string z2; - int i, n; - UNUSED_PARAMETER(argc); - z2 = sqlite3_value_text(argv[0]); - n = sqlite3_value_bytes(argv[0]); - /* Verify that the call to _bytes() does not invalidate the _text() pointer */ - //Debug.Assert( z2 == sqlite3_value_text( argv[0] ) ); - if (z2 != null) { - //z1 = contextMalloc(context, ((i64)n)+1); - //if ( z1 ) - //{ - // memcpy( z1, z2, n + 1 ); - // for ( i = 0 ; z1[i] ; i++ ) - // { - // z1[i] = (char)sqlite3Tolower( z1[i] ); - // } - sqlite3_result_text(context, z2.Length == 0 ? "" : z2.Substring(0, n).ToLowerInvariant(), -1, null);//sqlite3_free ); - //} - } - } + } + } #if FALSE //* This function is never used. */ /* @@ -475,306 +533,357 @@ sqlite3_value[] argv } } #endif //* NOT USED */ - //#define ifnullFunc versionFunc /* Substitute function - never called */ + //#define ifnullFunc versionFunc /* Substitute function - never called */ - /* - ** Implementation of random(). Return a random integer. + /* + ** Implementation of random(). Return a random integer. + */ + static void randomFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] NotUsed2 + ) + { + sqlite_int64 r = 0; + UNUSED_PARAMETER2( NotUsed, NotUsed2 ); + sqlite3_randomness( sizeof( sqlite_int64 ), ref r ); + if ( r < 0 ) + { + /* We need to prevent a random number of 0x8000000000000000 + ** (or -9223372036854775808) since when you do abs() of that + ** number of you get the same value back again. To do this + ** in a way that is testable, mask the sign bit off of negative + ** values, resulting in a positive value. Then take the + ** 2s complement of that positive value. The end result can + ** therefore be no less than -9223372036854775807. */ - static void randomFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] NotUsed2 - ) { - sqlite_int64 r = 0; - UNUSED_PARAMETER2(NotUsed, NotUsed2); - sqlite3_randomness(sizeof(sqlite_int64), ref r); - if (r < 0) { - /* We need to prevent a random number of 0x8000000000000000 - ** (or -9223372036854775808) since when you do abs() of that - ** number of you get the same value back again. To do this - ** in a way that is testable, mask the sign bit off of negative - ** values, resulting in a positive value. Then take the - ** 2s complement of that positive value. The end result can - ** therefore be no less than -9223372036854775807. - */ - r = -(r ^ (((sqlite3_int64)1) << 63)); - } - sqlite3_result_int64(context, r); + r = -( r ^ ( ( (sqlite3_int64)1 ) << 63 ) ); + } + sqlite3_result_int64( context, r ); + } + + /* + ** Implementation of randomblob(N). Return a random blob + ** that is N bytes long. + */ + static void randomBlob( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + int n; + char[] p; + Debug.Assert( argc == 1 ); + UNUSED_PARAMETER( argc ); + n = sqlite3_value_int( argv[0] ); + if ( n < 1 ) + { + n = 1; + } + if ( n > sqlite3_context_db_handle(context).aLimit[SQLITE_LIMIT_LENGTH] ) + { + sqlite3_result_error_toobig( context ); + p = null; + } + else + { + p = new char[n]; //contextMalloc( context, n ); + } + if ( p != null ) + { + i64 _p = 0; + for ( int i = 0; i < n; i++ ) + { + sqlite3_randomness( sizeof( u8 ), ref _p ); + p[i] = (char)( _p & 0x7F ); } + sqlite3_result_blob( context, new string( p ), n, null );//sqlite3_free ); + } + } - /* - ** Implementation of randomblob(N). Return a random blob - ** that is N bytes long. - */ - static void randomBlob( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - int n; - char[] p; - Debug.Assert(argc == 1); - UNUSED_PARAMETER(argc); - n = sqlite3_value_int(argv[0]); - if (n < 1) { - n = 1; + /* + ** Implementation of the last_insert_rowid() SQL function. The return + ** value is the same as the sqlite3_last_insert_rowid() API function. + */ + static void last_insert_rowid( + sqlite3_context context, + int NotUsed, + sqlite3_value[] NotUsed2 + ) + { + sqlite3 db = sqlite3_context_db_handle( context ); + UNUSED_PARAMETER2( NotUsed, NotUsed2 ); + /* IMP: R-51513-12026 The last_insert_rowid() SQL function is a + ** wrapper around the sqlite3_last_insert_rowid() C/C++ interface + ** function. */ + sqlite3_result_int64( context, sqlite3_last_insert_rowid( db ) ); + } + + /* + ** Implementation of the changes() SQL function. + ** + ** IMP: R-62073-11209 The changes() SQL function is a wrapper + ** around the sqlite3_changes() C/C++ function and hence follows the same + ** rules for counting changes. + */ + static void changes( + sqlite3_context context, + int NotUsed, + sqlite3_value[] NotUsed2 + ) + { + sqlite3 db = sqlite3_context_db_handle( context ); + UNUSED_PARAMETER2( NotUsed, NotUsed2 ); + sqlite3_result_int( context, sqlite3_changes( db ) ); + } + + /* + ** Implementation of the total_changes() SQL function. The return value is + ** the same as the sqlite3_total_changes() API function. + */ + static void total_changes( + sqlite3_context context, + int NotUsed, + sqlite3_value[] NotUsed2 + ) + { + sqlite3 db = (sqlite3)sqlite3_context_db_handle( context ); + UNUSED_PARAMETER2( NotUsed, NotUsed2 ); + /* IMP: R-52756-41993 This function is a wrapper around the + ** sqlite3_total_changes() C/C++ interface. */ + sqlite3_result_int( context, sqlite3_total_changes( db ) ); + } + + /* + ** A structure defining how to do GLOB-style comparisons. + */ + struct compareInfo + { + public char matchAll; + public char matchOne; + public char matchSet; + public bool noCase; + public compareInfo( char matchAll, char matchOne, char matchSet, bool noCase ) + { + this.matchAll = matchAll; + this.matchOne = matchOne; + this.matchSet = matchSet; + this.noCase = noCase; + } + }; + + /* + ** For LIKE and GLOB matching on EBCDIC machines, assume that every + ** character is exactly one byte in size. Also, all characters are + ** 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,C) (*(A++)) + //# define GlogUpperToLower(A) A = sqlite3UpperToLower[A] + //#else + //# define GlogUpperToLower(A) if( !((A)&~0x7f) ){ A = sqlite3UpperToLower[A]; } + //#endif + + static compareInfo globInfo = new compareInfo( '*', '?', '[', false ); + /* The correct SQL-92 behavior is for the LIKE operator to ignore + ** case. Thus 'a' LIKE 'A' would be true. */ + static compareInfo likeInfoNorm = new compareInfo( '%', '_', '\0', true ); + /* If SQLITE_CASE_SENSITIVE_LIKE is defined, then the LIKE operator + ** is case sensitive causing 'a' LIKE 'A' to be false */ + static compareInfo likeInfoAlt = new compareInfo( '%', '_', '\0', false ); + + /* + ** Compare two UTF-8 strings for equality where the first string can + ** potentially be a "glob" expression. Return true (1) if they + ** are the same and false (0) if they are different. + ** + ** Globbing rules: + ** + ** '*' Matches any sequence of zero or more characters. + ** + ** '?' Matches exactly one character. + ** + ** [...] Matches one character from the enclosed list of + ** characters. + ** + ** [^...] Matches one character not in the enclosed list. + ** + ** With the [...] and [^...] matching, a ']' character can be included + ** in the list by making it the first character after '[' or '^'. A + ** range of characters can be specified using '-'. Example: + ** "[a-z]" matches any single lower-case letter. To match a '-', make + ** it the last character in the list. + ** + ** This routine is usually quick, but can be N**2 in the worst case. + ** + ** Hints: to match '*' or '?', put them in "[]". Like this: + ** + ** abc[*]xyz Matches "abc*xyz" only + */ + static bool patternCompare( + string zPattern, /* The glob pattern */ + string zString, /* The string to compare against the glob */ + compareInfo pInfo, /* Information about how to do the compare */ + u32 esc /* The escape character */ + ) + { + u32 c, c2; + int invert; + int seen; + int matchOne = (int)pInfo.matchOne; + int matchAll = (int)pInfo.matchAll; + int matchSet = (int)pInfo.matchSet; + bool noCase = pInfo.noCase; + bool prevEscape = false; /* True if the previous character was 'escape' */ + string inPattern = zPattern; //Entered Pattern + + while ( ( c = sqlite3Utf8Read( zPattern, ref zPattern ) ) != 0 ) + { + if ( !prevEscape && c == matchAll ) + { + while ( ( c = sqlite3Utf8Read( zPattern, ref zPattern ) ) == matchAll + || c == matchOne ) + { + if ( c == matchOne && sqlite3Utf8Read( zString, ref zString ) == 0 ) + { + return false; } - if (n > sqlite3_context_db_handle(context).aLimit[SQLITE_LIMIT_LENGTH]) { - sqlite3_result_error_toobig(context); - p = null; - } else { - p = new char[n]; //contextMalloc( context, n ); + } + if ( c == 0 ) + { + return true; + } + else if ( c == esc ) + { + c = sqlite3Utf8Read( zPattern, ref zPattern ); + if ( c == 0 ) + { + return false; } - if (p != null) { - i64 _p = 0; - for (int i = 0; i < n; i++) { - sqlite3_randomness(sizeof(u8), ref _p); - p[i] = (char)(_p & 0x7F); - } - sqlite3_result_blob(context, new string(p), n, null);//sqlite3_free ); + } + else if ( c == matchSet ) + { + Debug.Assert( esc == 0 ); /* This is GLOB, not LIKE */ + Debug.Assert( matchSet < 0x80 ); /* '[' is a single-byte character */ + int len = 0; + while ( len < zString.Length && patternCompare( inPattern.Substring( inPattern.Length - zPattern.Length - 1 ), zString.Substring( len ), pInfo, esc ) == false ) + { + SQLITE_SKIP_UTF8( zString, ref len ); } + return len < zString.Length; + } + while ( ( c2 = sqlite3Utf8Read( zString, ref zString ) ) != 0 ) + { + if ( noCase ) + { + if( 0==((c2)&~0x7f) ) + c2 = (u32)sqlite3UpperToLower[c2]; //GlogUpperToLower(c2); + if ( 0 == ( ( c ) & ~0x7f ) ) + c = (u32)sqlite3UpperToLower[c]; //GlogUpperToLower(c); + while ( c2 != 0 && c2 != c ) + { + c2 = sqlite3Utf8Read( zString, ref zString ); + if ( 0 == ( ( c2 ) & ~0x7f ) ) + c2 = (u32)sqlite3UpperToLower[c2]; //GlogUpperToLower(c2); + } + } + else + { + while ( c2 != 0 && c2 != c ) + { + c2 = sqlite3Utf8Read( zString, ref zString ); + } + } + if ( c2 == 0 ) + return false; + if ( patternCompare( zPattern, zString, pInfo, esc ) ) + return true; + } + return false; } - - /* - ** Implementation of the last_insert_rowid() SQL function. The return - ** value is the same as the sqlite3_last_insert_rowid() API function. - */ - static void last_insert_rowid( - sqlite3_context context, - int NotUsed, - sqlite3_value[] NotUsed2 - ) { - sqlite3 db = sqlite3_context_db_handle(context); - UNUSED_PARAMETER2(NotUsed, NotUsed2); - /* IMP: R-51513-12026 The last_insert_rowid() SQL function is a - ** wrapper around the sqlite3_last_insert_rowid() C/C++ interface - ** function. */ - sqlite3_result_int64(context, sqlite3_last_insert_rowid(db)); - } - - /* - ** Implementation of the changes() SQL function. - ** - ** IMP: R-62073-11209 The changes() SQL function is a wrapper - ** around the sqlite3_changes() C/C++ function and hence follows the same - ** rules for counting changes. - */ - static void changes( - sqlite3_context context, - int NotUsed, - sqlite3_value[] NotUsed2 - ) { - sqlite3 db = sqlite3_context_db_handle(context); - UNUSED_PARAMETER2(NotUsed, NotUsed2); - sqlite3_result_int(context, sqlite3_changes(db)); - } - - /* - ** Implementation of the total_changes() SQL function. The return value is - ** the same as the sqlite3_total_changes() API function. - */ - static void total_changes( - sqlite3_context context, - int NotUsed, - sqlite3_value[] NotUsed2 - ) { - sqlite3 db = (sqlite3)sqlite3_context_db_handle(context); - UNUSED_PARAMETER2(NotUsed, NotUsed2); - /* IMP: R-52756-41993 This function is a wrapper around the - ** sqlite3_total_changes() C/C++ interface. */ - sqlite3_result_int(context, sqlite3_total_changes(db)); + else if ( !prevEscape && c == matchOne ) + { + if ( sqlite3Utf8Read( zString, ref zString ) == 0 ) + { + return false; + } } - - /* - ** A structure defining how to do GLOB-style comparisons. - */ - struct compareInfo { - public char matchAll; - public char matchOne; - public char matchSet; - public bool noCase; - public compareInfo(char matchAll, char matchOne, char matchSet, bool noCase) { - this.matchAll = matchAll; - this.matchOne = matchOne; - this.matchSet = matchSet; - this.noCase = noCase; + else if ( c == matchSet ) + { + u32 prior_c = 0; + Debug.Assert( esc == 0 ); /* This only occurs for GLOB, not LIKE */ + seen = 0; + invert = 0; + c = sqlite3Utf8Read( zString, ref zString ); + if ( c == 0 ) + return false; + c2 = sqlite3Utf8Read( zPattern, ref zPattern ); + if ( c2 == '^' ) + { + invert = 1; + c2 = sqlite3Utf8Read( zPattern, ref zPattern ); + } + if ( c2 == ']' ) + { + if ( c == ']' ) + seen = 1; + c2 = sqlite3Utf8Read( zPattern, ref zPattern ); + } + while ( c2 != 0 && c2 != ']' ) + { + if ( c2 == '-' && zPattern[0] != ']' && zPattern[0] != 0 && prior_c > 0 ) + { + c2 = sqlite3Utf8Read( zPattern, ref zPattern ); + if ( c >= prior_c && c <= c2 ) + seen = 1; + prior_c = 0; } - }; - - /* - ** For LIKE and GLOB matching on EBCDIC machines, assume that every - ** character is exactly one byte in size. Also, all characters are - ** 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,C) (*(A++)) - //# define GlogUpperToLower(A) A = sqlite3UpperToLower[A] - //#else - //# define GlogUpperToLower(A) if( !((A)&~0x7f) ){ A = sqlite3UpperToLower[A]; } - //#endif - - static compareInfo globInfo = new compareInfo('*', '?', '[', false); - /* The correct SQL-92 behavior is for the LIKE operator to ignore - ** case. Thus 'a' LIKE 'A' would be true. */ - static compareInfo likeInfoNorm = new compareInfo('%', '_', '\0', true); - /* If SQLITE_CASE_SENSITIVE_LIKE is defined, then the LIKE operator - ** is case sensitive causing 'a' LIKE 'A' to be false */ - static compareInfo likeInfoAlt = new compareInfo('%', '_', '\0', false); - - /* - ** Compare two UTF-8 strings for equality where the first string can - ** potentially be a "glob" expression. Return true (1) if they - ** are the same and false (0) if they are different. - ** - ** Globbing rules: - ** - ** '*' Matches any sequence of zero or more characters. - ** - ** '?' Matches exactly one character. - ** - ** [...] Matches one character from the enclosed list of - ** characters. - ** - ** [^...] Matches one character not in the enclosed list. - ** - ** With the [...] and [^...] matching, a ']' character can be included - ** in the list by making it the first character after '[' or '^'. A - ** range of characters can be specified using '-'. Example: - ** "[a-z]" matches any single lower-case letter. To match a '-', make - ** it the last character in the list. - ** - ** This routine is usually quick, but can be N**2 in the worst case. - ** - ** Hints: to match '*' or '?', put them in "[]". Like this: - ** - ** abc[*]xyz Matches "abc*xyz" only - */ - static bool patternCompare( - string zPattern, /* The glob pattern */ - string zString, /* The string to compare against the glob */ - compareInfo pInfo, /* Information about how to do the compare */ - u32 esc /* The escape character */ - ) { - u32 c, c2; - int invert; - int seen; - int matchOne = (int)pInfo.matchOne; - int matchAll = (int)pInfo.matchAll; - int matchSet = (int)pInfo.matchSet; - bool noCase = pInfo.noCase; - bool prevEscape = false; /* True if the previous character was 'escape' */ - string inPattern = zPattern; //Entered Pattern - - while ((c = sqlite3Utf8Read(zPattern, ref zPattern)) != 0) { - if (!prevEscape && c == matchAll) { - while ((c = sqlite3Utf8Read(zPattern, ref zPattern)) == matchAll - || c == matchOne) { - if (c == matchOne && sqlite3Utf8Read(zString, ref zString) == 0) { - return false; - } - } - if (c == 0) { - return true; - } else if (c == esc) { - c = sqlite3Utf8Read(zPattern, ref zPattern); - if (c == 0) { - return false; - } - } else if (c == matchSet) { - Debug.Assert(esc == 0); /* This is GLOB, not LIKE */ - Debug.Assert(matchSet < 0x80); /* '[' is a single-byte character */ - int len = 0; - while (len < zString.Length && patternCompare(inPattern.Substring(inPattern.Length - zPattern.Length - 1), zString.Substring(len), pInfo, esc) == false) { - SQLITE_SKIP_UTF8(zString, ref len); - } - return len < zString.Length; - } - while ((c2 = sqlite3Utf8Read(zString, ref zString)) != 0) { - if (noCase) { - if (0 == ((c2) & ~0x7f)) - c2 = (u32)sqlite3UpperToLower[c2]; //GlogUpperToLower(c2); - if (0 == ((c) & ~0x7f)) - c = (u32)sqlite3UpperToLower[c]; //GlogUpperToLower(c); - while (c2 != 0 && c2 != c) { - c2 = sqlite3Utf8Read(zString, ref zString); - if (0 == ((c2) & ~0x7f)) - c2 = (u32)sqlite3UpperToLower[c2]; //GlogUpperToLower(c2); - } - } else { - while (c2 != 0 && c2 != c) { - c2 = sqlite3Utf8Read(zString, ref zString); - } - } - if (c2 == 0) - return false; - if (patternCompare(zPattern, zString, pInfo, esc)) - return true; - } - return false; - } else if (!prevEscape && c == matchOne) { - if (sqlite3Utf8Read(zString, ref zString) == 0) { - return false; - } - } else if (c == matchSet) { - u32 prior_c = 0; - Debug.Assert(esc == 0); /* This only occurs for GLOB, not LIKE */ - seen = 0; - invert = 0; - c = sqlite3Utf8Read(zString, ref zString); - if (c == 0) - return false; - c2 = sqlite3Utf8Read(zPattern, ref zPattern); - if (c2 == '^') { - invert = 1; - c2 = sqlite3Utf8Read(zPattern, ref zPattern); - } - if (c2 == ']') { - if (c == ']') - seen = 1; - c2 = sqlite3Utf8Read(zPattern, ref zPattern); - } - while (c2 != 0 && c2 != ']') { - if (c2 == '-' && zPattern[0] != ']' && zPattern[0] != 0 && prior_c > 0) { - c2 = sqlite3Utf8Read(zPattern, ref zPattern); - if (c >= prior_c && c <= c2) - seen = 1; - prior_c = 0; - } else { - if (c == c2) { - seen = 1; - } - prior_c = c2; - } - c2 = sqlite3Utf8Read(zPattern, ref zPattern); - } - if (c2 == 0 || (seen ^ invert) == 0) { - return false; - } - } else if (esc == c && !prevEscape) { - prevEscape = true; - } else { - c2 = sqlite3Utf8Read(zString, ref zString); - if (noCase) { - if (c < 0x80) - c = (u32)sqlite3UpperToLower[c]; //GlogUpperToLower(c); - if (c2 < 0x80) - c2 = (u32)sqlite3UpperToLower[c2]; //GlogUpperToLower(c2); - } - if (c != c2) { - return false; - } - prevEscape = false; - } + else + { + if ( c == c2 ) + { + seen = 1; + } + prior_c = c2; } - return zString.Length == 0; + c2 = sqlite3Utf8Read( zPattern, ref zPattern ); + } + if ( c2 == 0 || ( seen ^ invert ) == 0 ) + { + return false; + } + } + else if ( esc == c && !prevEscape ) + { + prevEscape = true; } + else + { + c2 = sqlite3Utf8Read( zString, ref zString ); + if ( noCase ) + { + if ( c < 0x80 ) + c = (u32)sqlite3UpperToLower[c]; //GlogUpperToLower(c); + if ( c2 < 0x80 ) + c2 = (u32)sqlite3UpperToLower[c2]; //GlogUpperToLower(c2); + } + if ( c != c2 ) + { + return false; + } + prevEscape = false; + } + } + return zString.Length == 0; + } - /* - ** Count the number of times that the LIKE operator (or GLOB which is - ** just a variation of LIKE) gets called. This is used for testing - ** only. - */ + /* + ** Count the number of times that the LIKE operator (or GLOB which is + ** just a variation of LIKE) gets called. This is used for testing + ** only. + */ #if SQLITE_TEST #if !TCLSH static int sqlite3_like_count = 0; @@ -784,59 +893,64 @@ u32 esc /* The escape character */ #endif - /* - ** Implementation of the like() SQL function. This function implements - ** the build-in LIKE operator. The first argument to the function is the - ** pattern and the second argument is the string. So, the SQL statements: - ** - ** A LIKE B - ** - ** is implemented as like(B,A). - ** - ** This same function (with a different compareInfo structure) computes - ** the GLOB operator. - */ - static void likeFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - string zA, zB; - u32 escape = 0; - int nPat; - sqlite3 db = sqlite3_context_db_handle(context); - - zB = sqlite3_value_text(argv[0]); - zA = sqlite3_value_text(argv[1]); - - /* Limit the length of the LIKE or GLOB pattern to avoid problems - ** of deep recursion and N*N behavior in patternCompare(). - */ - nPat = sqlite3_value_bytes(argv[0]); - testcase(nPat == db.aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]); - testcase(nPat == db.aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] + 1); - if (nPat > db.aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]) { - sqlite3_result_error(context, "LIKE or GLOB pattern too complex", -1); - return; - } - //Debug.Assert( zB == sqlite3_value_text( argv[0] ) ); /* Encoding did not change */ - - if (argc == 3) { - /* The escape character string must consist of a single UTF-8 character. - ** Otherwise, return an error. - */ - string zEsc = sqlite3_value_text(argv[2]); - if (zEsc == null) - return; - if (sqlite3Utf8CharLen(zEsc, -1) != 1) { - sqlite3_result_error(context, - "ESCAPE expression must be a single character", -1); - return; - } - escape = sqlite3Utf8Read(zEsc, ref zEsc); - } - if (zA != null && zB != null) { - compareInfo pInfo = (compareInfo)sqlite3_user_data(context); + /* +** Implementation of the like() SQL function. This function implements +** the build-in LIKE operator. The first argument to the function is the +** pattern and the second argument is the string. So, the SQL statements: +** +** A LIKE B +** +** is implemented as like(B,A). +** +** This same function (with a different compareInfo structure) computes +** the GLOB operator. +*/ + static void likeFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + string zA, zB; + u32 escape = 0; + int nPat; + sqlite3 db = sqlite3_context_db_handle( context ); + + zB = sqlite3_value_text( argv[0] ); + zA = sqlite3_value_text( argv[1] ); + + /* Limit the length of the LIKE or GLOB pattern to avoid problems + ** of deep recursion and N*N behavior in patternCompare(). + */ + nPat = sqlite3_value_bytes( argv[0] ); + testcase( nPat == db.aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] ); + testcase( nPat == db.aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] + 1 ); + if ( nPat > db.aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] ) + { + sqlite3_result_error( context, "LIKE or GLOB pattern too complex", -1 ); + return; + } + //Debug.Assert( zB == sqlite3_value_text( argv[0] ) ); /* Encoding did not change */ + + if ( argc == 3 ) + { + /* The escape character string must consist of a single UTF-8 character. + ** Otherwise, return an error. + */ + string zEsc = sqlite3_value_text( argv[2] ); + if ( zEsc == null ) + return; + if ( sqlite3Utf8CharLen( zEsc, -1 ) != 1 ) + { + sqlite3_result_error( context, + "ESCAPE expression must be a single character", -1 ); + return; + } + escape = sqlite3Utf8Read( zEsc, ref zEsc ); + } + if ( zA != null && zB != null ) + { + compareInfo pInfo = (compareInfo)sqlite3_user_data( context ); #if SQLITE_TEST #if !TCLSH sqlite3_like_count++; @@ -844,473 +958,530 @@ sqlite3_value[] argv sqlite3_like_count.iValue++; #endif #endif - sqlite3_result_int(context, patternCompare(zB, zA, pInfo, escape) ? 1 : 0); - } - } + sqlite3_result_int( context, patternCompare( zB, zA, pInfo, escape ) ? 1 : 0 ); + } + } - /* - ** Implementation of the NULLIF(x,y) function. The result is the first - ** argument if the arguments are different. The result is NULL if the - ** arguments are equal to each other. - */ - static void nullifFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] argv - ) { - CollSeq pColl = sqlite3GetFuncCollSeq(context); - UNUSED_PARAMETER(NotUsed); - if (sqlite3MemCompare(argv[0], argv[1], pColl) != 0) { - sqlite3_result_value(context, argv[0]); - } - } + /* + ** Implementation of the NULLIF(x,y) function. The result is the first + ** argument if the arguments are different. The result is NULL if the + ** arguments are equal to each other. + */ + static void nullifFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] argv + ) + { + CollSeq pColl = sqlite3GetFuncCollSeq( context ); + UNUSED_PARAMETER( NotUsed ); + if ( sqlite3MemCompare( argv[0], argv[1], pColl ) != 0 ) + { + sqlite3_result_value( context, argv[0] ); + } + } - /* - ** Implementation of the sqlite_version() function. The result is the version - ** of the SQLite library that is running. - */ - static void versionFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] NotUsed2 - ) { - UNUSED_PARAMETER2(NotUsed, NotUsed2); - /* IMP: R-48699-48617 This function is an SQL wrapper around the - ** sqlite3_libversion() C-interface. */ - sqlite3_result_text(context, sqlite3_libversion(), -1, SQLITE_STATIC); - } + /* + ** Implementation of the sqlite_version() function. The result is the version + ** of the SQLite library that is running. + */ + static void versionFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] NotUsed2 + ) + { + UNUSED_PARAMETER2( NotUsed, NotUsed2 ); + /* IMP: R-48699-48617 This function is an SQL wrapper around the + ** sqlite3_libversion() C-interface. */ + sqlite3_result_text( context, sqlite3_libversion(), -1, SQLITE_STATIC ); + } - /* - ** Implementation of the sqlite_source_id() function. The result is a string - ** that identifies the particular version of the source code used to build - ** SQLite. - */ - static void sourceidFunc( - sqlite3_context context, - int NotUsed, - sqlite3_value[] NotUsed2 - ) { - UNUSED_PARAMETER2(NotUsed, NotUsed2); - /* IMP: R-24470-31136 This function is an SQL wrapper around the - ** sqlite3_sourceid() C interface. */ - sqlite3_result_text(context, sqlite3_sourceid(), -1, SQLITE_STATIC); - } + /* + ** Implementation of the sqlite_source_id() function. The result is a string + ** that identifies the particular version of the source code used to build + ** SQLite. + */ + static void sourceidFunc( + sqlite3_context context, + int NotUsed, + sqlite3_value[] NotUsed2 + ) + { + UNUSED_PARAMETER2( NotUsed, NotUsed2 ); + /* IMP: R-24470-31136 This function is an SQL wrapper around the + ** sqlite3_sourceid() C interface. */ + sqlite3_result_text( context, sqlite3_sourceid(), -1, SQLITE_STATIC ); + } - /* - ** Implementation of the sqlite_log() function. This is a wrapper around - ** sqlite3_log(). The return value is NULL. The function exists purely for - ** its side-effects. - */ - static void errlogFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - UNUSED_PARAMETER(argc); - UNUSED_PARAMETER(context); - sqlite3_log(sqlite3_value_int(argv[0]), "%s", sqlite3_value_text(argv[1])); - } + /* + ** Implementation of the sqlite_log() function. This is a wrapper around + ** sqlite3_log(). The return value is NULL. The function exists purely for + ** its side-effects. + */ + static void errlogFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + UNUSED_PARAMETER( argc ); + UNUSED_PARAMETER( context ); + sqlite3_log( sqlite3_value_int( argv[0] ), "%s", sqlite3_value_text( argv[1] ) ); + } - /* - ** Implementation of the sqlite_compileoption_used() function. - ** The result is an integer that identifies if the compiler option - ** was used to build SQLite. - */ + /* + ** Implementation of the sqlite_compileoption_used() function. + ** The result is an integer that identifies if the compiler option + ** was used to build SQLite. + */ #if !SQLITE_OMIT_COMPILEOPTION_DIAGS - static void compileoptionusedFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - string zOptName; - Debug.Assert(argc == 1); - UNUSED_PARAMETER(argc); - /* IMP: R-39564-36305 The sqlite_compileoption_used() SQL - ** function is a wrapper around the sqlite3_compileoption_used() C/C++ - ** function. - */ - if ((zOptName = sqlite3_value_text(argv[0])) != null) { - sqlite3_result_int(context, sqlite3_compileoption_used(zOptName)); - } - } + static void compileoptionusedFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + string zOptName; + Debug.Assert( argc == 1 ); + UNUSED_PARAMETER( argc ); + /* IMP: R-39564-36305 The sqlite_compileoption_used() SQL + ** function is a wrapper around the sqlite3_compileoption_used() C/C++ + ** function. + */ + if ( ( zOptName = sqlite3_value_text( argv[0] ) ) != null ) + { + sqlite3_result_int( context, sqlite3_compileoption_used( zOptName ) ); + } + } #endif //* SQLITE_OMIT_COMPILEOPTION_DIAGS */ - /* - ** Implementation of the sqlite_compileoption_get() function. - ** The result is a string that identifies the compiler options - ** used to build SQLite. - */ + /* +** Implementation of the sqlite_compileoption_get() function. +** The result is a string that identifies the compiler options +** used to build SQLite. +*/ #if !SQLITE_OMIT_COMPILEOPTION_DIAGS - static void compileoptiongetFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - int n; - Debug.Assert(argc == 1); - UNUSED_PARAMETER(argc); - /* IMP: R-04922-24076 The sqlite_compileoption_get() SQL function - ** is a wrapper around the sqlite3_compileoption_get() C/C++ function. - */ - n = sqlite3_value_int(argv[0]); - sqlite3_result_text(context, sqlite3_compileoption_get(n), -1, SQLITE_STATIC); - } + static void compileoptiongetFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + int n; + Debug.Assert( argc == 1 ); + UNUSED_PARAMETER( argc ); + /* IMP: R-04922-24076 The sqlite_compileoption_get() SQL function + ** is a wrapper around the sqlite3_compileoption_get() C/C++ function. + */ + n = sqlite3_value_int( argv[0] ); + sqlite3_result_text( context, sqlite3_compileoption_get( n ), -1, SQLITE_STATIC ); + } #endif //* SQLITE_OMIT_COMPILEOPTION_DIAGS */ - /* Array for converting from half-bytes (nybbles) into ASCII hex - ** digits. */ - static char[] hexdigits = new char[] { + /* Array for converting from half-bytes (nybbles) into ASCII hex +** digits. */ + static char[] hexdigits = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - /* - ** EXPERIMENTAL - This is not an official function. The interface may - ** change. This function may disappear. Do not write code that depends - ** on this function. - ** - ** Implementation of the QUOTE() function. This function takes a single - ** argument. If the argument is numeric, the return value is the same as - ** the argument. If the argument is NULL, the return value is the string - ** "NULL". Otherwise, the argument is enclosed in single quotes with - ** single-quote escapes. - */ - static void quoteFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - Debug.Assert(argc == 1); - UNUSED_PARAMETER(argc); - - switch (sqlite3_value_type(argv[0])) { - case SQLITE_INTEGER: - case SQLITE_FLOAT: { - sqlite3_result_value(context, argv[0]); - break; - } - case SQLITE_BLOB: { - StringBuilder zText; - byte[] zBlob = sqlite3_value_blob(argv[0]); - int nBlob = sqlite3_value_bytes(argv[0]); - Debug.Assert(zBlob.Length == sqlite3_value_blob(argv[0]).Length); /* No encoding change */ - zText = new StringBuilder(2 * nBlob + 4);//(char*)contextMalloc(context, (2*(i64)nBlob)+4); - zText.Append("X'"); - if (zText != null) { - int i; - for (i = 0; i < nBlob; i++) { - zText.Append(hexdigits[(zBlob[i] >> 4) & 0x0F]); - zText.Append(hexdigits[(zBlob[i]) & 0x0F]); - } - zText.Append("'"); - //zText[( nBlob * 2 ) + 2] = '\''; - //zText[( nBlob * 2 ) + 3] = '\0'; - //zText[0] = 'X'; - //zText[1] = '\''; - sqlite3_result_text(context, zText, -1, SQLITE_TRANSIENT); - //sqlite3_free( zText ); - } - break; - } - case SQLITE_TEXT: { - int i, j; - int n; - string zArg = sqlite3_value_text(argv[0]); - StringBuilder z; - - if (zArg == null || zArg.Length == 0) - return; - for (i = 0, n = 0; i < zArg.Length; i++) { - if (zArg[i] == '\'') - n++; - } - z = new StringBuilder(i + n + 3);// contextMalloc(context, ((i64)i)+((i64)n)+3); - if (z != null) { - z.Append('\''); - for (i = 0, j = 1; i < zArg.Length && zArg[i] != 0; i++) { - z.Append((char)zArg[i]); - j++; - if (zArg[i] == '\'') { - z.Append('\''); - j++; - } - } - z.Append('\''); - j++; - //z[j] = '\0'; ; - sqlite3_result_text(context, z, j, null);//sqlite3_free ); - } - break; - } - default: { - Debug.Assert(sqlite3_value_type(argv[0]) == SQLITE_NULL); - sqlite3_result_text(context, "NULL", 4, SQLITE_STATIC); - break; - } + /* + ** EXPERIMENTAL - This is not an official function. The interface may + ** change. This function may disappear. Do not write code that depends + ** on this function. + ** + ** Implementation of the QUOTE() function. This function takes a single + ** argument. If the argument is numeric, the return value is the same as + ** the argument. If the argument is NULL, the return value is the string + ** "NULL". Otherwise, the argument is enclosed in single quotes with + ** single-quote escapes. + */ + static void quoteFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + Debug.Assert( argc == 1 ); + UNUSED_PARAMETER( argc ); + + switch ( sqlite3_value_type( argv[0] ) ) + { + case SQLITE_INTEGER: + case SQLITE_FLOAT: + { + sqlite3_result_value( context, argv[0] ); + break; + } + case SQLITE_BLOB: + { + StringBuilder zText; + byte[] zBlob = sqlite3_value_blob( argv[0] ); + int nBlob = sqlite3_value_bytes( argv[0] ); + Debug.Assert( zBlob.Length == sqlite3_value_blob( argv[0] ).Length ); /* No encoding change */ + zText = new StringBuilder( 2 * nBlob + 4 );//(char*)contextMalloc(context, (2*(i64)nBlob)+4); + zText.Append( "X'" ); + if ( zText != null ) + { + int i; + for ( i = 0; i < nBlob; i++ ) + { + zText.Append( hexdigits[( zBlob[i] >> 4 ) & 0x0F] ); + zText.Append( hexdigits[( zBlob[i] ) & 0x0F] ); + } + zText.Append( "'" ); + //zText[( nBlob * 2 ) + 2] = '\''; + //zText[( nBlob * 2 ) + 3] = '\0'; + //zText[0] = 'X'; + //zText[1] = '\''; + sqlite3_result_text( context, zText, -1, SQLITE_TRANSIENT ); + //sqlite3_free( zText ); } - } - - /* - ** The hex() function. Interpret the argument as a blob. Return - ** a hexadecimal rendering as text. - */ - static void hexFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - int i, n; - byte[] pBlob; - //string zHex, z; - Debug.Assert(argc == 1); - UNUSED_PARAMETER(argc); - pBlob = sqlite3_value_blob(argv[0]); - n = sqlite3_value_bytes(argv[0]); - Debug.Assert(n == (pBlob == null ? 0 : pBlob.Length)); /* No encoding change */ - StringBuilder zHex = new StringBuilder(n * 2 + 1); - // z = zHex = contextMalloc(context, ((i64)n)*2 + 1); - if (zHex != null) { - for (i = 0; i < n; i++) {//, pBlob++){ - byte c = pBlob[i]; - zHex.Append(hexdigits[(c >> 4) & 0xf]); - zHex.Append(hexdigits[c & 0xf]); + break; + } + case SQLITE_TEXT: + { + int i, j; + int n; + string zArg = sqlite3_value_text( argv[0] ); + StringBuilder z; + + if ( zArg == null || zArg.Length == 0 ) + return; + for ( i = 0, n = 0; i < zArg.Length; i++ ) + { + if ( zArg[i] == '\'' ) + n++; + } + z = new StringBuilder( i + n + 3 );// contextMalloc(context, ((i64)i)+((i64)n)+3); + if ( z != null ) + { + z.Append( '\'' ); + for ( i = 0, j = 1; i < zArg.Length && zArg[i] != 0; i++ ) + { + z.Append( (char)zArg[i] ); + j++; + if ( zArg[i] == '\'' ) + { + z.Append( '\'' ); + j++; } - sqlite3_result_text(context, zHex, n * 2, null); //sqlite3_free ); + } + z.Append( '\'' ); + j++; + //z[j] = '\0'; ; + sqlite3_result_text( context, z, j, null );//sqlite3_free ); } + break; + } + default: + { + Debug.Assert( sqlite3_value_type( argv[0] ) == SQLITE_NULL ); + sqlite3_result_text( context, "NULL", 4, SQLITE_STATIC ); + break; + } + } + } + + /* + ** The hex() function. Interpret the argument as a blob. Return + ** a hexadecimal rendering as text. + */ + static void hexFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + int i, n; + byte[] pBlob; + //string zHex, z; + Debug.Assert( argc == 1 ); + UNUSED_PARAMETER( argc ); + pBlob = sqlite3_value_blob( argv[0] ); + n = sqlite3_value_bytes( argv[0] ); + Debug.Assert( n == ( pBlob == null ? 0 : pBlob.Length ) ); /* No encoding change */ + StringBuilder zHex = new StringBuilder( n * 2 + 1 ); + // z = zHex = contextMalloc(context, ((i64)n)*2 + 1); + if ( zHex != null ) + { + for ( i = 0; i < n; i++ ) + {//, pBlob++){ + byte c = pBlob[i]; + zHex.Append( hexdigits[( c >> 4 ) & 0xf] ); + zHex.Append( hexdigits[c & 0xf] ); } + sqlite3_result_text( context, zHex, n * 2, null ); //sqlite3_free ); + } + } - /* - ** The zeroblob(N) function returns a zero-filled blob of size N bytes. - */ - static void zeroblobFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - i64 n; - sqlite3 db = sqlite3_context_db_handle(context); - Debug.Assert(argc == 1); - UNUSED_PARAMETER(argc); - n = sqlite3_value_int64(argv[0]); - testcase(n == db.aLimit[SQLITE_LIMIT_LENGTH]); - testcase(n == db.aLimit[SQLITE_LIMIT_LENGTH] + 1); - if (n > db.aLimit[SQLITE_LIMIT_LENGTH]) { - sqlite3_result_error_toobig(context); - } else { - sqlite3_result_zeroblob(context, (int)n);/* IMP: R-00293-64994 */ - } + /* + ** The zeroblob(N) function returns a zero-filled blob of size N bytes. + */ + static void zeroblobFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + i64 n; + sqlite3 db = sqlite3_context_db_handle( context ); + Debug.Assert( argc == 1 ); + UNUSED_PARAMETER( argc ); + n = sqlite3_value_int64( argv[0] ); + testcase( n == db.aLimit[SQLITE_LIMIT_LENGTH] ); + testcase( n == db.aLimit[SQLITE_LIMIT_LENGTH] + 1 ); + if ( n > db.aLimit[SQLITE_LIMIT_LENGTH] ) + { + sqlite3_result_error_toobig( context ); + } + else + { + sqlite3_result_zeroblob( context, (int)n );/* IMP: R-00293-64994 */ + } + } + + /* + ** The replace() function. Three arguments are all strings: call + ** them A, B, and C. The result is also a string which is derived + ** from A by replacing every occurance of B with C. The match + ** must be exact. Collating sequences are not used. + */ + static void replaceFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + string zStr; /* The input string A */ + string zPattern; /* The pattern string B */ + string zRep; /* The replacement string C */ + string zOut = null; /* The output */ + int nStr; /* Size of zStr */ + int nOut; /* Maximum size of zOut */ + //int loopLimit; /* Last zStr[] that might match zPattern[] */ + int i, j = 0; /* Loop counters */ + + Debug.Assert( argc == 3 ); + UNUSED_PARAMETER( argc ); + zStr = sqlite3_value_text( argv[0] ); + if ( zStr == null ) + return; + nStr = sqlite3_value_bytes( argv[0] ); + Debug.Assert( zStr == sqlite3_value_text( argv[0] ) ); /* No encoding change */ + zPattern = sqlite3_value_text( argv[1] ); + if ( zPattern == null ) + { + Debug.Assert( sqlite3_value_type( argv[1] ) == SQLITE_NULL + //|| sqlite3_context_db_handle( context ).mallocFailed != 0 + ); + return; + } + if ( zPattern == "" ) + { + Debug.Assert( sqlite3_value_type( argv[1] ) != SQLITE_NULL ); + sqlite3_result_value( context, argv[0] ); + return; + } + ////nPattern = sqlite3_value_bytes( argv[1] ); + Debug.Assert( zPattern == sqlite3_value_text( argv[1] ) ); /* No encoding change */ + zRep = sqlite3_value_text( argv[2] ); + if ( zRep == null ) + return; + ////nRep = sqlite3_value_bytes( argv[2] ); + Debug.Assert( zRep == sqlite3_value_text( argv[2] ) ); + nOut = nStr + 1; + Debug.Assert( nOut < SQLITE_MAX_LENGTH ); + if ( nOut <= sqlite3_context_db_handle( context ).aLimit[SQLITE_LIMIT_LENGTH] ) + { + //int nPattern; /* Size of zPattern */ + //int nRep; /* Size of zRep */ + //zOut = contextMalloc(context, (i64)nOut); + //if( zOut==0 ){ + // return; + //} + //loopLimit = nStr - nPattern; + //for(i=j=0; i<=loopLimit; i++){ + // if( zStr[i]!=zPattern[0] || memcmp(&zStr[i], zPattern, nPattern) ){ + // zOut[j++] = zStr[i]; + // }else{ + // u8 *zOld; + // sqlite3 db = sqlite3_context_db_handle( context ); + // nOut += nRep - nPattern; + //testcase( nOut-1==db->aLimit[SQLITE_LIMIT_LENGTH] ); + //testcase( nOut-2==db->aLimit[SQLITE_LIMIT_LENGTH] ); + //if( nOut-1>db->aLimit[SQLITE_LIMIT_LENGTH] ){ + // sqlite3_result_error_toobig(context); + // sqlite3_free(zOut); + // return; + // } + // zOld = zOut; + // zOut = sqlite3_realloc(zOut, (int)nOut); + // if( zOut==0 ){ + // sqlite3_result_error_nomem(context); + // sqlite3_free(zOld); + // return; + // } + // memcpy(&zOut[j], zRep, nRep); + // j += nRep; + // i += nPattern-1; + // } + //} + //Debug.Assert( j+nStr-i+1==nOut ); + //memcpy(&zOut[j], zStr[i], nStr-i); + //j += nStr - i; + //Debug.Assert( j<=nOut ); + //zOut[j] = 0; + try + { + zOut = zStr.Replace( zPattern, zRep ); + j = zOut.Length; } + catch + { + j = 0; + } + } + if ( j == 0 || j > sqlite3_context_db_handle( context ).aLimit[SQLITE_LIMIT_LENGTH] ) + { + sqlite3_result_error_toobig( context ); + } + else + { + sqlite3_result_text( context, zOut, j, null );//sqlite3_free ); + } + } - /* - ** The replace() function. Three arguments are all strings: call - ** them A, B, and C. The result is also a string which is derived - ** from A by replacing every occurance of B with C. The match - ** must be exact. Collating sequences are not used. - */ - static void replaceFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - string zStr; /* The input string A */ - string zPattern; /* The pattern string B */ - string zRep; /* The replacement string C */ - string zOut = null; /* The output */ - int nStr; /* Size of zStr */ - int nOut; /* Maximum size of zOut */ - //int loopLimit; /* Last zStr[] that might match zPattern[] */ - int i, j = 0; /* Loop counters */ - - Debug.Assert(argc == 3); - UNUSED_PARAMETER(argc); - zStr = sqlite3_value_text(argv[0]); - if (zStr == null) - return; - nStr = sqlite3_value_bytes(argv[0]); - Debug.Assert(zStr == sqlite3_value_text(argv[0])); /* No encoding change */ - zPattern = sqlite3_value_text(argv[1]); - if (zPattern == null) { - Debug.Assert(sqlite3_value_type(argv[1]) == SQLITE_NULL - //|| sqlite3_context_db_handle( context ).mallocFailed != 0 - ); - return; - } - if (zPattern == "") { - Debug.Assert(sqlite3_value_type(argv[1]) != SQLITE_NULL); - sqlite3_result_value(context, argv[0]); - return; - } - ////nPattern = sqlite3_value_bytes( argv[1] ); - Debug.Assert(zPattern == sqlite3_value_text(argv[1])); /* No encoding change */ - zRep = sqlite3_value_text(argv[2]); - if (zRep == null) - return; - ////nRep = sqlite3_value_bytes( argv[2] ); - Debug.Assert(zRep == sqlite3_value_text(argv[2])); - nOut = nStr + 1; - Debug.Assert(nOut < SQLITE_MAX_LENGTH); - if (nOut <= sqlite3_context_db_handle(context).aLimit[SQLITE_LIMIT_LENGTH]) { - //int nPattern; /* Size of zPattern */ - //int nRep; /* Size of zRep */ - //zOut = contextMalloc(context, (i64)nOut); - //if( zOut==0 ){ - // return; - //} - //loopLimit = nStr - nPattern; - //for(i=j=0; i<=loopLimit; i++){ - // if( zStr[i]!=zPattern[0] || memcmp(&zStr[i], zPattern, nPattern) ){ - // zOut[j++] = zStr[i]; - // }else{ - // u8 *zOld; - // sqlite3 db = sqlite3_context_db_handle( context ); - // nOut += nRep - nPattern; - //testcase( nOut-1==db->aLimit[SQLITE_LIMIT_LENGTH] ); - //testcase( nOut-2==db->aLimit[SQLITE_LIMIT_LENGTH] ); - //if( nOut-1>db->aLimit[SQLITE_LIMIT_LENGTH] ){ - // sqlite3_result_error_toobig(context); - // sqlite3_free(zOut); - // return; - // } - // zOld = zOut; - // zOut = sqlite3_realloc(zOut, (int)nOut); - // if( zOut==0 ){ - // sqlite3_result_error_nomem(context); - // sqlite3_free(zOld); - // return; - // } - // memcpy(&zOut[j], zRep, nRep); - // j += nRep; - // i += nPattern-1; - // } - //} - //Debug.Assert( j+nStr-i+1==nOut ); - //memcpy(&zOut[j], zStr[i], nStr-i); - //j += nStr - i; - //Debug.Assert( j<=nOut ); - //zOut[j] = 0; - try { - zOut = zStr.Replace(zPattern, zRep); - j = zOut.Length; - } catch { - j = 0; - } + /* + ** Implementation of the TRIM(), LTRIM(), and RTRIM() functions. + ** The userdata is 0x1 for left trim, 0x2 for right trim, 0x3 for both. + */ + static void trimFunc( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + string zIn; /* Input string */ + string zCharSet; /* Set of characters to trim */ + int nIn; /* Number of bytes in input */ + int izIn = 0; /* C# string pointer */ + int flags; /* 1: trimleft 2: trimright 3: trim */ + int i; /* Loop counter */ + int[] aLen = null; /* Length of each character in zCharSet */ + byte[][] azChar = null; /* Individual characters in zCharSet */ + int nChar = 0; /* Number of characters in zCharSet */ + byte[] zBytes = null; + byte[] zBlob = null; + + if ( sqlite3_value_type( argv[0] ) == SQLITE_NULL ) + { + return; + } + zIn = sqlite3_value_text( argv[0] ); + if ( zIn == null ) + return; + nIn = sqlite3_value_bytes( argv[0] ); + zBlob = sqlite3_value_blob( argv[0] ); + //Debug.Assert( zIn == sqlite3_value_text( argv[0] ) ); + if ( argc == 1 ) + { + int[] lenOne = new int[] { 1 }; + byte[] azOne = new byte[] { (u8)' ' };//static unsigned char * const azOne[] = { (u8*)" " }; + nChar = 1; + aLen = lenOne; + azChar = new byte[1][]; + azChar[0] = azOne; + zCharSet = null; + } + else if ( ( zCharSet = sqlite3_value_text( argv[1] ) ) == null ) + { + return; + } + else + { + if ( ( zBytes = sqlite3_value_blob( argv[1] ) ) != null ) + { + int iz = 0; + for ( nChar = 0; iz < zBytes.Length; nChar++ ) + { + SQLITE_SKIP_UTF8( zBytes, ref iz ); + } + if ( nChar > 0 ) + { + azChar = new byte[nChar][];//contextMalloc(context, ((i64)nChar)*(sizeof(char*)+1)); + if ( azChar == null ) + { + return; } - if (j == 0 || j > sqlite3_context_db_handle(context).aLimit[SQLITE_LIMIT_LENGTH]) { - sqlite3_result_error_toobig(context); - } else { - sqlite3_result_text(context, zOut, j, null);//sqlite3_free ); + aLen = new int[nChar]; + + int iz0 = 0; + int iz1 = 0; + for ( int ii = 0; ii < nChar; ii++ ) + { + SQLITE_SKIP_UTF8( zBytes, ref iz1 ); + aLen[ii] = iz1 - iz0; + azChar[ii] = new byte[aLen[ii]]; + Buffer.BlockCopy( zBytes, iz0, azChar[ii], 0, azChar[ii].Length ); + iz0 = iz1; } + } } - - /* - ** Implementation of the TRIM(), LTRIM(), and RTRIM() functions. - ** The userdata is 0x1 for left trim, 0x2 for right trim, 0x3 for both. - */ - static void trimFunc( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - string zIn; /* Input string */ - string zCharSet; /* Set of characters to trim */ - int nIn; /* Number of bytes in input */ - int izIn = 0; /* C# string pointer */ - int flags; /* 1: trimleft 2: trimright 3: trim */ - int i; /* Loop counter */ - int[] aLen = null; /* Length of each character in zCharSet */ - byte[][] azChar = null; /* Individual characters in zCharSet */ - int nChar = 0; /* Number of characters in zCharSet */ - byte[] zBytes = null; - byte[] zBlob = null; - - if (sqlite3_value_type(argv[0]) == SQLITE_NULL) { - return; + } + if ( nChar > 0 ) + { + flags = (int)sqlite3_user_data( context ); // flags = SQLITE_PTR_TO_INT(sqlite3_user_data(context)); + if ( ( flags & 1 ) != 0 ) + { + while ( nIn > 0 ) + { + int len = 0; + for ( i = 0; i < nChar; i++ ) + { + len = aLen[i]; + if ( len <= nIn && memcmp( zBlob, izIn, azChar[i], len ) == 0 ) + break; } - zIn = sqlite3_value_text(argv[0]); - if (zIn == null) - return; - nIn = sqlite3_value_bytes(argv[0]); - zBlob = sqlite3_value_blob(argv[0]); - //Debug.Assert( zIn == sqlite3_value_text( argv[0] ) ); - if (argc == 1) { - int[] lenOne = new int[] { 1 }; - byte[] azOne = new byte[] { (u8)' ' };//static unsigned char * const azOne[] = { (u8*)" " }; - nChar = 1; - aLen = lenOne; - azChar = new byte[1][]; - azChar[0] = azOne; - zCharSet = null; - } else if ((zCharSet = sqlite3_value_text(argv[1])) == null) { - return; - } else { - if ((zBytes = sqlite3_value_blob(argv[1])) != null) { - int iz = 0; - for (nChar = 0; iz < zBytes.Length; nChar++) { - SQLITE_SKIP_UTF8(zBytes, ref iz); - } - if (nChar > 0) { - azChar = new byte[nChar][];//contextMalloc(context, ((i64)nChar)*(sizeof(char*)+1)); - if (azChar == null) { - return; - } - aLen = new int[nChar]; - - int iz0 = 0; - int iz1 = 0; - for (int ii = 0; ii < nChar; ii++) { - SQLITE_SKIP_UTF8(zBytes, ref iz1); - aLen[ii] = iz1 - iz0; - azChar[ii] = new byte[aLen[ii]]; - Buffer.BlockCopy(zBytes, iz0, azChar[ii], 0, azChar[ii].Length); - iz0 = iz1; - } - } - } - } - if (nChar > 0) { - flags = (int)sqlite3_user_data(context); // flags = SQLITE_PTR_TO_INT(sqlite3_user_data(context)); - if ((flags & 1) != 0) { - while (nIn > 0) { - int len = 0; - for (i = 0; i < nChar; i++) { - len = aLen[i]; - if (len <= nIn && memcmp(zBlob, izIn, azChar[i], len) == 0) - break; - } - if (i >= nChar) - break; - izIn += len; - nIn -= len; - } - } - if ((flags & 2) != 0) { - while (nIn > 0) { - int len = 0; - for (i = 0; i < nChar; i++) { - len = aLen[i]; - if (len <= nIn && memcmp(zBlob, izIn + nIn - len, azChar[i], len) == 0) - break; - } - if (i >= nChar) - break; - nIn -= len; - } - } - if (zCharSet != null) { - //sqlite3_free( ref azChar ); - } + if ( i >= nChar ) + break; + izIn += len; + nIn -= len; + } + } + if ( ( flags & 2 ) != 0 ) + { + while ( nIn > 0 ) + { + int len = 0; + for ( i = 0; i < nChar; i++ ) + { + len = aLen[i]; + if ( len <= nIn && memcmp( zBlob, izIn + nIn - len, azChar[i], len ) == 0 ) + break; } - StringBuilder sb = new StringBuilder(nIn); - for (i = 0; i < nIn; i++) - sb.Append((char)zBlob[izIn + i]); - sqlite3_result_text(context, sb, nIn, SQLITE_TRANSIENT); + if ( i >= nChar ) + break; + nIn -= len; + } } + if ( zCharSet != null ) + { + //sqlite3_free( ref azChar ); + } + } + StringBuilder sb = new StringBuilder( nIn ); + for ( i = 0; i < nIn; i++ ) + sb.Append( (char)zBlob[izIn + i] ); + sqlite3_result_text( context, sb, nIn, SQLITE_TRANSIENT ); + } - /* IMP: R-25361-16150 This function is omitted from SQLite by default. It - ** is only available if the SQLITE_SOUNDEX compile-time option is used - ** when SQLite is built. - */ + /* IMP: R-25361-16150 This function is omitted from SQLite by default. It + ** is only available if the SQLITE_SOUNDEX compile-time option is used + ** when SQLite is built. + */ #if SQLITE_SOUNDEX /* ** Compute the soundex encoding of a word. @@ -1370,179 +1541,213 @@ sqlite3_value[] argv #endif //* SQLITE_SOUNDEX */ #if !SQLITE_OMIT_LOAD_EXTENSION - /* - ** A function that loads a shared-library extension then returns NULL. - */ - static void loadExt( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - string zFile = sqlite3_value_text(argv[0]); - string zProc; - sqlite3 db = (sqlite3)sqlite3_context_db_handle(context); - string zErrMsg = ""; - - if (argc == 2) { - zProc = sqlite3_value_text(argv[1]); - } else { - zProc = ""; - } - if (zFile != null && sqlite3_load_extension(db, zFile, zProc, ref zErrMsg) != 0) { - sqlite3_result_error(context, zErrMsg, -1); - sqlite3DbFree(db, ref zErrMsg); - } - } + /* +** A function that loads a shared-library extension then returns NULL. +*/ + static void loadExt( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + string zFile = sqlite3_value_text( argv[0] ); + string zProc; + sqlite3 db = (sqlite3)sqlite3_context_db_handle( context ); + string zErrMsg = ""; + + if ( argc == 2 ) + { + zProc = sqlite3_value_text( argv[1] ); + } + else + { + zProc = ""; + } + if ( zFile != null && sqlite3_load_extension( db, zFile, zProc, ref zErrMsg ) != 0 ) + { + sqlite3_result_error( context, zErrMsg, -1 ); + sqlite3DbFree( db, ref zErrMsg ); + } + } #endif - /* - ** An instance of the following structure holds the context of a - ** sum() or avg() aggregate computation. - */ - //typedef struct SumCtx SumCtx; - public class SumCtx { - public double rSum; /* Floating point sum */ - public i64 iSum; /* Integer sum */ - public i64 cnt; /* Number of elements summed */ - public int overflow; /* True if integer overflow seen */ - public bool approx; /* True if non-integer value was input to the sum */ - public Mem _M; - public Mem Context { - get { - return _M; - } - set { - _M = value; - if (_M == null || _M.z == null) - iSum = 0; - else - iSum = Convert.ToInt64(_M.z); - } - } - }; - - /* - ** Routines used to compute the sum, average, and total. - ** - ** The SUM() function follows the (broken) SQL standard which means - ** that it returns NULL if it sums over no inputs. TOTAL returns - ** 0.0 in that case. In addition, TOTAL always returns a float where - ** SUM might return an integer if it never encounters a floating point - ** value. TOTAL never fails, but SUM might through an exception if - ** it overflows an integer. - */ - static void sumStep( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - SumCtx p; - - int type; - Debug.Assert(argc == 1); - UNUSED_PARAMETER(argc); - Mem pMem = sqlite3_aggregate_context(context, 1);//sizeof(*p)); - if (pMem._SumCtx == null) - pMem._SumCtx = new SumCtx(); - p = pMem._SumCtx; - if (p.Context == null) - p.Context = pMem; - type = sqlite3_value_numeric_type(argv[0]); - if (p != null && type != SQLITE_NULL) { - p.cnt++; - if (type == SQLITE_INTEGER) { - i64 v = sqlite3_value_int64(argv[0]); - p.rSum += v; - if (!(p.approx | p.overflow != 0) && 0 != sqlite3AddInt64(ref p.iSum, v)) { - p.overflow = 1; - } - } else { - p.rSum += sqlite3_value_double(argv[0]); - p.approx = true; - } - } + /* +** An instance of the following structure holds the context of a +** sum() or avg() aggregate computation. +*/ + //typedef struct SumCtx SumCtx; + public class SumCtx + { + public double rSum; /* Floating point sum */ + public i64 iSum; /* Integer sum */ + public i64 cnt; /* Number of elements summed */ + public int overflow; /* True if integer overflow seen */ + public bool approx; /* True if non-integer value was input to the sum */ + public Mem _M; + public Mem Context + { + get + { + return _M; } - static void sumFinalize(sqlite3_context context) { - SumCtx p = null; - Mem pMem = sqlite3_aggregate_context(context, 0); - if (pMem != null) - p = pMem._SumCtx; - if (p != null && p.cnt > 0) { - if (p.overflow != 0) { - sqlite3_result_error(context, "integer overflow", -1); - } else if (p.approx) { - sqlite3_result_double(context, p.rSum); - } else { - sqlite3_result_int64(context, p.iSum); - } - p.cnt = 0; // Reset for C# - } + set + { + _M = value; + if ( _M == null || _M.z == null ) + iSum = 0; + else + iSum = Convert.ToInt64( _M.z ); } + } + }; - static void avgFinalize(sqlite3_context context) { - SumCtx p = null; - Mem pMem = sqlite3_aggregate_context(context, 0); - if (pMem != null) - p = pMem._SumCtx; - if (p != null && p.cnt > 0) { - sqlite3_result_double(context, p.rSum / (double)p.cnt); - } + /* + ** Routines used to compute the sum, average, and total. + ** + ** The SUM() function follows the (broken) SQL standard which means + ** that it returns NULL if it sums over no inputs. TOTAL returns + ** 0.0 in that case. In addition, TOTAL always returns a float where + ** SUM might return an integer if it never encounters a floating point + ** value. TOTAL never fails, but SUM might through an exception if + ** it overflows an integer. + */ + static void sumStep( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + SumCtx p; + + int type; + Debug.Assert( argc == 1 ); + UNUSED_PARAMETER( argc ); + Mem pMem = sqlite3_aggregate_context( context, 1 );//sizeof(*p)); + if ( pMem._SumCtx == null ) + pMem._SumCtx = new SumCtx(); + p = pMem._SumCtx; + if ( p.Context == null ) + p.Context = pMem; + type = sqlite3_value_numeric_type( argv[0] ); + if ( p != null && type != SQLITE_NULL ) + { + p.cnt++; + if ( type == SQLITE_INTEGER ) + { + i64 v = sqlite3_value_int64( argv[0] ); + p.rSum += v; + if ( !( p.approx | p.overflow != 0 ) && 0 != sqlite3AddInt64( ref p.iSum, v ) ) + { + p.overflow = 1; + } } - - static void totalFinalize(sqlite3_context context) { - SumCtx p = null; - Mem pMem = sqlite3_aggregate_context(context, 0); - if (pMem != null) - p = pMem._SumCtx; - /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ - sqlite3_result_double(context, p != null ? p.rSum : (double)0); + else + { + p.rSum += sqlite3_value_double( argv[0] ); + p.approx = true; + } + } + } + static void sumFinalize( sqlite3_context context ) + { + SumCtx p = null; + Mem pMem = sqlite3_aggregate_context( context, 0 ); + if ( pMem != null ) + p = pMem._SumCtx; + if ( p != null && p.cnt > 0 ) + { + if ( p.overflow != 0 ) + { + sqlite3_result_error( context, "integer overflow", -1 ); + } + else if ( p.approx ) + { + sqlite3_result_double( context, p.rSum ); } + else + { + sqlite3_result_int64( context, p.iSum ); + } + p.cnt = 0; // Reset for C# + } + } - /* - ** The following structure keeps track of state information for the - ** count() aggregate function. - */ - //typedef struct CountCtx CountCtx; - public class CountCtx { - i64 _n; - Mem _M; - public Mem Context { - get { - return _M; - } - set { - _M = value; - if (_M == null || _M.z == null) - _n = 0; - else - _n = Convert.ToInt64(_M.z); - } - } - public i64 n { - get { - return _n; - } - set { - _n = value; - if (_M != null) - _M.z = _n.ToString(); - } - } + static void avgFinalize( sqlite3_context context ) + { + SumCtx p = null; + Mem pMem = sqlite3_aggregate_context( context, 0 ); + if ( pMem != null ) + p = pMem._SumCtx; + if ( p != null && p.cnt > 0 ) + { + sqlite3_result_double( context, p.rSum / (double)p.cnt ); + } + } + + static void totalFinalize( sqlite3_context context ) + { + SumCtx p = null; + Mem pMem = sqlite3_aggregate_context( context, 0 ); + if ( pMem != null ) + p = pMem._SumCtx; + /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ + sqlite3_result_double( context, p != null ? p.rSum : (double)0 ); + } + + /* + ** The following structure keeps track of state information for the + ** count() aggregate function. + */ + //typedef struct CountCtx CountCtx; + public class CountCtx + { + i64 _n; + Mem _M; + public Mem Context + { + get + { + return _M; + } + set + { + _M = value; + if ( _M == null || _M.z == null ) + _n = 0; + else + _n = Convert.ToInt64( _M.z ); + } + } + public i64 n + { + get + { + return _n; } + set + { + _n = value; + if ( _M != null ) + _M.z = _n.ToString(); + } + } + } - /* - ** Routines to implement the count() aggregate function. - */ - static void countStep( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - CountCtx p = new CountCtx(); - p.Context = sqlite3_aggregate_context(context, 1);//sizeof(*p)); - if ((argc == 0 || SQLITE_NULL != sqlite3_value_type(argv[0])) && p.Context != null) { - p.n++; - } + /* + ** Routines to implement the count() aggregate function. + */ + static void countStep( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + CountCtx p = new CountCtx(); + p.Context = sqlite3_aggregate_context( context, 1 );//sizeof(*p)); + if ( ( argc == 0 || SQLITE_NULL != sqlite3_value_type( argv[0] ) ) && p.Context != null ) + { + p.n++; + } #if !SQLITE_OMIT_DEPRECATED /* The sqlite3_aggregate_count() function is deprecated. But just to make ** sure it still operates correctly, verify that its count agrees with our @@ -1551,268 +1756,302 @@ sqlite3_value[] argv Debug.Assert( argc == 1 || p == null || p.n > 0x7fffffff || p.n == sqlite3_aggregate_count( context ) ); #endif - } + } - static void countFinalize(sqlite3_context context) { - CountCtx p = new CountCtx(); - p.Context = sqlite3_aggregate_context(context, 0); - sqlite3_result_int64(context, p != null ? p.n : 0); - } + static void countFinalize( sqlite3_context context ) + { + CountCtx p = new CountCtx(); + p.Context = sqlite3_aggregate_context( context, 0 ); + sqlite3_result_int64( context, p != null ? p.n : 0 ); + } - /* - ** Routines to implement min() and max() aggregate functions. + /* + ** Routines to implement min() and max() aggregate functions. + */ + static void minmaxStep( + sqlite3_context context, + int NotUsed, + sqlite3_value[] argv + ) + { + Mem pArg = (Mem)argv[0]; + Mem pBest; + UNUSED_PARAMETER( NotUsed ); + + if ( sqlite3_value_type( argv[0] ) == SQLITE_NULL ) + return; + pBest = (Mem)sqlite3_aggregate_context( context, 1 );//sizeof(*pBest)); + //if ( pBest == null ) return; + + if ( pBest.flags != 0 ) + { + bool max; + int cmp; + CollSeq pColl = sqlite3GetFuncCollSeq( context ); + /* This step function is used for both the min() and max() aggregates, + ** the only difference between the two being that the sense of the + ** comparison is inverted. For the max() aggregate, the + ** sqlite3_context_db_handle() function returns (void *)-1. For min() it + ** returns (void *)db, where db is the sqlite3* database pointer. + ** Therefore the next statement sets variable 'max' to 1 for the max() + ** aggregate, or 0 for min(). */ - static void minmaxStep( - sqlite3_context context, - int NotUsed, - sqlite3_value[] argv - ) { - Mem pArg = (Mem)argv[0]; - Mem pBest; - UNUSED_PARAMETER(NotUsed); - - if (sqlite3_value_type(argv[0]) == SQLITE_NULL) - return; - pBest = (Mem)sqlite3_aggregate_context(context, 1);//sizeof(*pBest)); - //if ( pBest == null ) return; - - if (pBest.flags != 0) { - bool max; - int cmp; - CollSeq pColl = sqlite3GetFuncCollSeq(context); - /* This step function is used for both the min() and max() aggregates, - ** the only difference between the two being that the sense of the - ** comparison is inverted. For the max() aggregate, the - ** sqlite3_context_db_handle() function returns (void *)-1. For min() it - ** returns (void *)db, where db is the sqlite3* database pointer. - ** Therefore the next statement sets variable 'max' to 1 for the max() - ** aggregate, or 0 for min(). - */ - max = sqlite3_context_db_handle(context) != null && (int)sqlite3_user_data(context) != 0; - cmp = sqlite3MemCompare(pBest, pArg, pColl); - if ((max && cmp < 0) || (!max && cmp > 0)) { - sqlite3VdbeMemCopy(pBest, pArg); - } - } else { - sqlite3VdbeMemCopy(pBest, pArg); - } + max = sqlite3_context_db_handle( context ) != null && (int)sqlite3_user_data( context ) != 0; + cmp = sqlite3MemCompare( pBest, pArg, pColl ); + if ( ( max && cmp < 0 ) || ( !max && cmp > 0 ) ) + { + sqlite3VdbeMemCopy( pBest, pArg ); } + } + else + { + sqlite3VdbeMemCopy( pBest, pArg ); + } + } - static void minMaxFinalize(sqlite3_context context) { - sqlite3_value pRes; - pRes = (sqlite3_value)sqlite3_aggregate_context(context, 0); - if (pRes != null) { - if (ALWAYS(pRes.flags != 0)) { - sqlite3_result_value(context, pRes); - } - sqlite3VdbeMemRelease(pRes); - } + static void minMaxFinalize( sqlite3_context context ) + { + sqlite3_value pRes; + pRes = (sqlite3_value)sqlite3_aggregate_context( context, 0 ); + if ( pRes != null ) + { + if ( ALWAYS( pRes.flags != 0 ) ) + { + sqlite3_result_value( context, pRes ); } + sqlite3VdbeMemRelease( pRes ); + } + } - /* - ** group_concat(EXPR, ?SEPARATOR?) - */ - static void groupConcatStep( - sqlite3_context context, - int argc, - sqlite3_value[] argv - ) { - string zVal; - //StrAccum pAccum; - string zSep; - int nVal, nSep; - Debug.Assert(argc == 1 || argc == 2); - if (sqlite3_value_type(argv[0]) == SQLITE_NULL) - return; - Mem pMem = sqlite3_aggregate_context(context, 1);//sizeof(*pAccum)); - if (pMem._StrAccum == null) - pMem._StrAccum = new StrAccum(100); - //pAccum = pMem._StrAccum; - - //if ( pMem._StrAccum != null ) - //{ - sqlite3 db = sqlite3_context_db_handle(context); - //int firstTerm = pMem._StrAccum.useMalloc == 0 ? 1 : 0; - //pMem._StrAccum.useMalloc = 2; - pMem._StrAccum.mxAlloc = db.aLimit[SQLITE_LIMIT_LENGTH]; - if (pMem._StrAccum.Context == null) // first term - pMem._StrAccum.Context = pMem; - else { - if (argc == 2) { - zSep = sqlite3_value_text(argv[1]); - nSep = sqlite3_value_bytes(argv[1]); - } else { - zSep = ","; - nSep = 1; - } - sqlite3StrAccumAppend(pMem._StrAccum, zSep, nSep); - } - zVal = sqlite3_value_text(argv[0]); - nVal = sqlite3_value_bytes(argv[0]); - sqlite3StrAccumAppend(pMem._StrAccum, zVal, nVal); - //} + /* + ** group_concat(EXPR, ?SEPARATOR?) + */ + static void groupConcatStep( + sqlite3_context context, + int argc, + sqlite3_value[] argv + ) + { + string zVal; + //StrAccum pAccum; + string zSep; + int nVal, nSep; + Debug.Assert( argc == 1 || argc == 2 ); + if ( sqlite3_value_type( argv[0] ) == SQLITE_NULL ) + return; + Mem pMem = sqlite3_aggregate_context( context, 1 );//sizeof(*pAccum)); + if ( pMem._StrAccum == null ) + pMem._StrAccum = new StrAccum( 100 ); + //pAccum = pMem._StrAccum; + + //if ( pMem._StrAccum != null ) + //{ + sqlite3 db = sqlite3_context_db_handle( context ); + //int firstTerm = pMem._StrAccum.useMalloc == 0 ? 1 : 0; + //pMem._StrAccum.useMalloc = 2; + pMem._StrAccum.mxAlloc = db.aLimit[SQLITE_LIMIT_LENGTH]; + if ( pMem._StrAccum.Context == null ) // first term + pMem._StrAccum.Context = pMem; + else + { + if ( argc == 2 ) + { + zSep = sqlite3_value_text( argv[1] ); + nSep = sqlite3_value_bytes( argv[1] ); } - - static void groupConcatFinalize(sqlite3_context context) { - //StrAccum pAccum = null; - Mem pMem = sqlite3_aggregate_context(context, 0); - if (pMem != null) { - if (pMem._StrAccum == null) - pMem._StrAccum = new StrAccum(100); - StrAccum pAccum = pMem._StrAccum; - //} - //if ( pAccum != null ) - //{ - if (pAccum.tooBig) { - sqlite3_result_error_toobig(context); - } - //else if ( pAccum.mallocFailed != 0 ) - //{ - // sqlite3_result_error_nomem( context ); - //} - else { - sqlite3_result_text(context, sqlite3StrAccumFinish(pAccum), -1, - null); //sqlite3_free ); - } - } + else + { + zSep = ","; + nSep = 1; } + sqlite3StrAccumAppend( pMem._StrAccum, zSep, nSep ); + } + zVal = sqlite3_value_text( argv[0] ); + nVal = sqlite3_value_bytes( argv[0] ); + sqlite3StrAccumAppend( pMem._StrAccum, zVal, nVal ); + //} + } - /* - ** This routine does per-connection function registration. Most - ** of the built-in functions above are part of the global function set. - ** This routine only deals with those that are not global. - */ - public struct sFuncs { - public string zName; - public sbyte nArg; - public u8 argType; /* 1: 0, 2: 1, 3: 2,... N: N-1. */ - public u8 eTextRep; /* 1: UTF-16. 0: UTF-8 */ - public u8 needCollSeq; - public dxFunc xFunc; //(sqlite3_context*,int,sqlite3_value **); - - // Constructor - public sFuncs(string zName, sbyte nArg, u8 argType, u8 eTextRep, u8 needCollSeq, dxFunc xFunc) { - this.zName = zName; - this.nArg = nArg; - this.argType = argType; - this.eTextRep = eTextRep; - this.needCollSeq = needCollSeq; - this.xFunc = xFunc; - } - }; - - public struct sAggs { - public string zName; - public sbyte nArg; - public u8 argType; - public u8 needCollSeq; - public dxStep xStep; //(sqlite3_context*,int,sqlite3_value**); - public dxFinal xFinalize; //(sqlite3_context*); - // Constructor - public sAggs(string zName, sbyte nArg, u8 argType, u8 needCollSeq, dxStep xStep, dxFinal xFinalize) { - this.zName = zName; - this.nArg = nArg; - this.argType = argType; - this.needCollSeq = needCollSeq; - this.xStep = xStep; - this.xFinalize = xFinalize; - } + static void groupConcatFinalize( sqlite3_context context ) + { + //StrAccum pAccum = null; + Mem pMem = sqlite3_aggregate_context( context, 0 ); + if ( pMem != null ) + { + if ( pMem._StrAccum == null ) + pMem._StrAccum = new StrAccum( 100 ); + StrAccum pAccum = pMem._StrAccum; + //} + //if ( pAccum != null ) + //{ + if ( pAccum.tooBig ) + { + sqlite3_result_error_toobig( context ); } - static void sqlite3RegisterBuiltinFunctions(sqlite3 db) { - int rc = sqlite3_overload_function(db, "MATCH", 2); - Debug.Assert(rc == SQLITE_NOMEM || rc == SQLITE_OK); - if (rc == SQLITE_NOMEM) { - //// db.mallocFailed = 1; - } + //else if ( pAccum.mallocFailed != 0 ) + //{ + // sqlite3_result_error_nomem( context ); + //} + else + { + sqlite3_result_text( context, sqlite3StrAccumFinish( pAccum ), -1, + null ); //sqlite3_free ); } + } + } - /* - ** Set the LIKEOPT flag on the 2-argument function with the given name. - */ - static void setLikeOptFlag(sqlite3 db, string zName, int flagVal) { - FuncDef pDef; - pDef = sqlite3FindFunction(db, zName, sqlite3Strlen30(zName), - 2, SQLITE_UTF8, 0); - if (ALWAYS(pDef != null)) { - pDef.flags = (byte)flagVal; - } - } + /* + ** This routine does per-connection function registration. Most + ** of the built-in functions above are part of the global function set. + ** This routine only deals with those that are not global. + */ + public struct sFuncs + { + public string zName; + public sbyte nArg; + public u8 argType; /* 1: 0, 2: 1, 3: 2,... N: N-1. */ + public u8 eTextRep; /* 1: UTF-16. 0: UTF-8 */ + public u8 needCollSeq; + public dxFunc xFunc; //(sqlite3_context*,int,sqlite3_value **); + + // Constructor + public sFuncs( string zName, sbyte nArg, u8 argType, u8 eTextRep, u8 needCollSeq, dxFunc xFunc ) + { + this.zName = zName; + this.nArg = nArg; + this.argType = argType; + this.eTextRep = eTextRep; + this.needCollSeq = needCollSeq; + this.xFunc = xFunc; + } + }; + + public struct sAggs + { + public string zName; + public sbyte nArg; + public u8 argType; + public u8 needCollSeq; + public dxStep xStep; //(sqlite3_context*,int,sqlite3_value**); + public dxFinal xFinalize; //(sqlite3_context*); + // Constructor + public sAggs( string zName, sbyte nArg, u8 argType, u8 needCollSeq, dxStep xStep, dxFinal xFinalize ) + { + this.zName = zName; + this.nArg = nArg; + this.argType = argType; + this.needCollSeq = needCollSeq; + this.xStep = xStep; + this.xFinalize = xFinalize; + } + } + static void sqlite3RegisterBuiltinFunctions( sqlite3 db ) + { + int rc = sqlite3_overload_function( db, "MATCH", 2 ); + Debug.Assert( rc == SQLITE_NOMEM || rc == SQLITE_OK ); + if ( rc == SQLITE_NOMEM ) + { + //// db.mallocFailed = 1; + } + } - /* - ** Register the built-in LIKE and GLOB functions. The caseSensitive - ** parameter determines whether or not the LIKE operator is case - ** sensitive. GLOB is always case sensitive. - */ - static void sqlite3RegisterLikeFunctions(sqlite3 db, int caseSensitive) { - compareInfo pInfo; - if (caseSensitive != 0) { - pInfo = likeInfoAlt; - } else { - pInfo = likeInfoNorm; - } - sqlite3CreateFunc(db, "like", 2, SQLITE_UTF8, pInfo, (dxFunc)likeFunc, null, null, null); - sqlite3CreateFunc(db, "like", 3, SQLITE_UTF8, pInfo, (dxFunc)likeFunc, null, null, null); - sqlite3CreateFunc(db, "glob", 2, SQLITE_UTF8, - globInfo, (dxFunc)likeFunc, null, null, null); - setLikeOptFlag(db, "glob", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE); - setLikeOptFlag(db, "like", - caseSensitive != 0 ? (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) : SQLITE_FUNC_LIKE); - } + /* + ** Set the LIKEOPT flag on the 2-argument function with the given name. + */ + static void setLikeOptFlag( sqlite3 db, string zName, int flagVal ) + { + FuncDef pDef; + pDef = sqlite3FindFunction( db, zName, sqlite3Strlen30( zName ), + 2, SQLITE_UTF8, 0 ); + if ( ALWAYS( pDef != null ) ) + { + pDef.flags = (byte)flagVal; + } + } - /* - ** pExpr points to an expression which implements a function. If - ** it is appropriate to apply the LIKE optimization to that function - ** then set aWc[0] through aWc[2] to the wildcard characters and - ** return TRUE. If the function is not a LIKE-style function then - ** return FALSE. - */ - static bool sqlite3IsLikeFunction(sqlite3 db, Expr pExpr, ref bool pIsNocase, char[] aWc) { - FuncDef pDef; - if (pExpr.op != TK_FUNCTION - || null == pExpr.x.pList - || pExpr.x.pList.nExpr != 2 - ) { - return false; - } - Debug.Assert(!ExprHasProperty(pExpr, EP_xIsSelect)); - pDef = sqlite3FindFunction(db, pExpr.u.zToken, sqlite3Strlen30(pExpr.u.zToken), - 2, SQLITE_UTF8, 0); - if (NEVER(pDef == null) || (pDef.flags & SQLITE_FUNC_LIKE) == 0) { - return false; - } + /* + ** Register the built-in LIKE and GLOB functions. The caseSensitive + ** parameter determines whether or not the LIKE operator is case + ** sensitive. GLOB is always case sensitive. + */ + static void sqlite3RegisterLikeFunctions( sqlite3 db, int caseSensitive ) + { + compareInfo pInfo; + if ( caseSensitive != 0 ) + { + pInfo = likeInfoAlt; + } + else + { + pInfo = likeInfoNorm; + } + sqlite3CreateFunc( db, "like", 2, SQLITE_UTF8, pInfo, (dxFunc)likeFunc, null, null, null ); + sqlite3CreateFunc( db, "like", 3, SQLITE_UTF8, pInfo, (dxFunc)likeFunc, null, null, null ); + sqlite3CreateFunc( db, "glob", 2, SQLITE_UTF8, + globInfo, (dxFunc)likeFunc, null, null, null ); + setLikeOptFlag( db, "glob", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE ); + setLikeOptFlag( db, "like", + caseSensitive != 0 ? ( SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE ) : SQLITE_FUNC_LIKE ); + } - /* The memcpy() statement assumes that the wildcard characters are - ** the first three statements in the compareInfo structure. The - ** Debug.Asserts() that follow verify that assumption - */ - //memcpy( aWc, pDef.pUserData, 3 ); - aWc[0] = ((compareInfo)pDef.pUserData).matchAll; - aWc[1] = ((compareInfo)pDef.pUserData).matchOne; - aWc[2] = ((compareInfo)pDef.pUserData).matchSet; - // Debug.Assert((char*)&likeInfoAlt == (char*)&likeInfoAlt.matchAll); - // Debug.Assert(&((char*)&likeInfoAlt)[1] == (char*)&likeInfoAlt.matchOne); - // Debug.Assert(&((char*)&likeInfoAlt)[2] == (char*)&likeInfoAlt.matchSet); - pIsNocase = (pDef.flags & SQLITE_FUNC_CASE) == 0; - return true; - } + /* + ** pExpr points to an expression which implements a function. If + ** it is appropriate to apply the LIKE optimization to that function + ** then set aWc[0] through aWc[2] to the wildcard characters and + ** return TRUE. If the function is not a LIKE-style function then + ** return FALSE. + */ + static bool sqlite3IsLikeFunction( sqlite3 db, Expr pExpr, ref bool pIsNocase, char[] aWc ) + { + FuncDef pDef; + if ( pExpr.op != TK_FUNCTION + || null == pExpr.x.pList + || pExpr.x.pList.nExpr != 2 + ) + { + return false; + } + Debug.Assert( !ExprHasProperty( pExpr, EP_xIsSelect ) ); + pDef = sqlite3FindFunction( db, pExpr.u.zToken, sqlite3Strlen30( pExpr.u.zToken ), + 2, SQLITE_UTF8, 0 ); + if ( NEVER( pDef == null ) || ( pDef.flags & SQLITE_FUNC_LIKE ) == 0 ) + { + return false; + } + + /* The memcpy() statement assumes that the wildcard characters are + ** the first three statements in the compareInfo structure. The + ** Debug.Asserts() that follow verify that assumption + */ + //memcpy( aWc, pDef.pUserData, 3 ); + aWc[0] = ( (compareInfo)pDef.pUserData ).matchAll; + aWc[1] = ( (compareInfo)pDef.pUserData ).matchOne; + aWc[2] = ( (compareInfo)pDef.pUserData ).matchSet; + // Debug.Assert((char*)&likeInfoAlt == (char*)&likeInfoAlt.matchAll); + // Debug.Assert(&((char*)&likeInfoAlt)[1] == (char*)&likeInfoAlt.matchOne); + // Debug.Assert(&((char*)&likeInfoAlt)[2] == (char*)&likeInfoAlt.matchSet); + pIsNocase = ( pDef.flags & SQLITE_FUNC_CASE ) == 0; + return true; + } - /* - ** All all of the FuncDef structures in the aBuiltinFunc[] array above - ** to the global function hash table. This occurs at start-time (as - ** a consequence of calling sqlite3_initialize()). - ** - ** After this routine runs - */ - static void sqlite3RegisterGlobalFunctions() { - /* - ** The following array holds FuncDef structures for all of the functions - ** defined in this file. - ** - ** The array cannot be constant since changes are made to the - ** FuncDef.pHash elements at start-time. The elements of this array - ** are read-only after initialization is complete. - */ - FuncDef[] aBuiltinFunc = { + /* + ** All all of the FuncDef structures in the aBuiltinFunc[] array above + ** to the global function hash table. This occurs at start-time (as + ** a consequence of calling sqlite3_initialize()). + ** + ** After this routine runs + */ + static void sqlite3RegisterGlobalFunctions() + { + /* + ** The following array holds FuncDef structures for all of the functions + ** defined in this file. + ** + ** The array cannot be constant since changes are made to the + ** FuncDef.pHash elements at start-time. The elements of this array + ** are read-only after initialization is complete. + */ + FuncDef[] aBuiltinFunc = { FUNCTION("ltrim", 1, 1, 0, trimFunc ), FUNCTION("ltrim", 2, 1, 0, trimFunc ), FUNCTION("rtrim", 1, 2, 0, trimFunc ), @@ -1840,7 +2079,7 @@ static void sqlite3RegisterGlobalFunctions() { FUNCTION("coalesce", 0, 0, 0, null ), /* FUNCTION(coalesce, -1, 0, 0, ifnullFunc ), */ // use versionFunc here just for a dummy placeholder -new FuncDef(-1,SQLITE_UTF8,SQLITE_FUNC_COALESCE,null,null,versionFunc,null,null,"coalesce",null,null), +new FuncDef(-1,SQLITE_UTF8,SQLITE_FUNC_COALESCE,null,null,versionFunc,null,null,"coalesce",null,null), FUNCTION("hex", 1, 0, 0, hexFunc ), /* FUNCTION(ifnull, 2, 0, 0, ifnullFunc ), */ // use versionFunc here just for a dummy placeholder @@ -1887,21 +2126,22 @@ static void sqlite3RegisterGlobalFunctions() { LIKEFUNC("like", 3, likeInfoNorm, SQLITE_FUNC_LIKE), #endif FUNCTION("regexp", 2, 0, 0, regexpFunc ),}; - int i; + int i; #if SQLITE_OMIT_WSD FuncDefHash pHash = GLOBAL( FuncDefHash, sqlite3GlobalFunctions ); FuncDef[] aFunc = (FuncDef[])GLOBAL( FuncDef, aBuiltinFunc ); #else - FuncDefHash pHash = sqlite3GlobalFunctions; - FuncDef[] aFunc = aBuiltinFunc; + FuncDefHash pHash = sqlite3GlobalFunctions; + FuncDef[] aFunc = aBuiltinFunc; #endif - for (i = 0; i < ArraySize(aBuiltinFunc); i++) { - sqlite3FuncDefInsert(pHash, aFunc[i]); - } - sqlite3RegisterDateTimeFunctions(); + for ( i = 0; i < ArraySize( aBuiltinFunc ); i++ ) + { + sqlite3FuncDefInsert( pHash, aFunc[i] ); + } + sqlite3RegisterDateTimeFunctions(); #if !SQLITE_OMIT_ALTERTABLE - sqlite3AlterFunctions(); + sqlite3AlterFunctions(); #endif - } } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/global_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/global_c.cs index 5f48e98be..5b8eb8102 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/global_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/global_c.cs @@ -1,111 +1,119 @@ -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2008 June 13 - ** - ** 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 contains definitions of global variables and contants. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +using System; +using System.Diagnostics; +using System.Text; +namespace Community.CsharpSqlite +{ + using sqlite3_value = Sqlite3.Mem; - /* An array to map all upper-case characters into their corresponding - ** lower-case character. - ** - ** SQLite only considers US-ASCII (or EBCDIC) characters. We do not - ** handle case conversions for the UTF character set since the tables - ** involved are nearly as big or bigger than SQLite itself. - */ - /* An array to map all upper-case characters into their corresponding - ** lower-case character. - */ - // - // Replaced in C# with sqlite3UpperToLower class - // static int[] sqlite3UpperToLower = new int[] { - //#if SQLITE_ASCII - //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, - //18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - //36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - //54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 97, 98, 99,100,101,102,103, - //104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121, - //122, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,102,103,104,105,106,107, - //108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125, - //126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, - //144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161, - //162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179, - //180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197, - //198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215, - //216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233, - //234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251, - //252,253,254,255 - //#endif - //#if SQLITE_EBCDIC - //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 0x */ - //16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 1x */ - //32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 2x */ - //48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 3x */ - //64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 4x */ - //80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 5x */ - //96, 97, 66, 67, 68, 69, 70, 71, 72, 73,106,107,108,109,110,111, /* 6x */ - //112, 81, 82, 83, 84, 85, 86, 87, 88, 89,122,123,124,125,126,127, /* 7x */ - //128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, /* 8x */ - //144,145,146,147,148,149,150,151,152,153,154,155,156,157,156,159, /* 9x */ - //160,161,162,163,164,165,166,167,168,169,170,171,140,141,142,175, /* Ax */ - //176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, /* Bx */ - //192,129,130,131,132,133,134,135,136,137,202,203,204,205,206,207, /* Cx */ - //208,145,146,147,148,149,150,151,152,153,218,219,220,221,222,223, /* Dx */ - //224,225,162,163,164,165,166,167,168,169,232,203,204,205,206,207, /* Ex */ - //239,240,241,242,243,244,245,246,247,248,249,219,220,221,222,255, /* Fx */ - //#endif - //}; + public partial class Sqlite3 + { + /* + ** 2008 June 13 + ** + ** 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 contains definitions of global variables and contants. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + + + /* An array to map all upper-case characters into their corresponding + ** lower-case character. + ** + ** SQLite only considers US-ASCII (or EBCDIC) characters. We do not + ** handle case conversions for the UTF character set since the tables + ** involved are nearly as big or bigger than SQLite itself. + */ + /* An array to map all upper-case characters into their corresponding + ** lower-case character. + */ +// +// Replaced in C# with sqlite3UpperToLower class +// static int[] sqlite3UpperToLower = new int[] { +//#if SQLITE_ASCII +//0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, +//18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, +//36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, +//54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 97, 98, 99,100,101,102,103, +//104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121, +//122, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,102,103,104,105,106,107, +//108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125, +//126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, +//144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161, +//162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179, +//180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197, +//198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215, +//216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233, +//234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251, +//252,253,254,255 +//#endif +//#if SQLITE_EBCDIC +//0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 0x */ +//16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 1x */ +//32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 2x */ +//48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 3x */ +//64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 4x */ +//80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 5x */ +//96, 97, 66, 67, 68, 69, 70, 71, 72, 73,106,107,108,109,110,111, /* 6x */ +//112, 81, 82, 83, 84, 85, 86, 87, 88, 89,122,123,124,125,126,127, /* 7x */ +//128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, /* 8x */ +//144,145,146,147,148,149,150,151,152,153,154,155,156,157,156,159, /* 9x */ +//160,161,162,163,164,165,166,167,168,169,170,171,140,141,142,175, /* Ax */ +//176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, /* Bx */ +//192,129,130,131,132,133,134,135,136,137,202,203,204,205,206,207, /* Cx */ +//208,145,146,147,148,149,150,151,152,153,218,219,220,221,222,223, /* Dx */ +//224,225,162,163,164,165,166,167,168,169,232,203,204,205,206,207, /* Ex */ +//239,240,241,242,243,244,245,246,247,248,249,219,220,221,222,255, /* Fx */ +//#endif +//}; - /* - ** The following 256 byte lookup table is used to support SQLites built-in - ** equivalents to the following standard library functions: - ** - ** isspace() 0x01 - ** isalpha() 0x02 - ** isdigit() 0x04 - ** isalnum() 0x06 - ** isxdigit() 0x08 - ** toupper() 0x20 - ** SQLite identifier character 0x40 - ** - ** Bit 0x20 is set if the mapped character requires translation to upper - ** case. i.e. if the character is a lower-case ASCII character. - ** If x is a lower-case ASCII character, then its upper-case equivalent - ** is (x - 0x20). Therefore toupper() can be implemented as: - ** - ** (x & ~(map[x]&0x20)) - ** - ** Standard function tolower() is implemented using the sqlite3UpperToLower[] - ** array. tolower() is used more often than toupper() by SQLite. - ** - ** Bit 0x40 is set if the character non-alphanumeric and can be used in an - ** SQLite identifier. Identifiers are alphanumerics, "_", "$", and any - ** non-ASCII UTF character. Hence the test for whether or not a character is - ** part of an identifier is 0x46. - ** - ** SQLite's versions are identical to the standard versions assuming a - ** locale of "C". They are implemented as macros in sqliteInt.h. - */ + /* + ** The following 256 byte lookup table is used to support SQLites built-in + ** equivalents to the following standard library functions: + ** + ** isspace() 0x01 + ** isalpha() 0x02 + ** isdigit() 0x04 + ** isalnum() 0x06 + ** isxdigit() 0x08 + ** toupper() 0x20 + ** SQLite identifier character 0x40 + ** + ** Bit 0x20 is set if the mapped character requires translation to upper + ** case. i.e. if the character is a lower-case ASCII character. + ** If x is a lower-case ASCII character, then its upper-case equivalent + ** is (x - 0x20). Therefore toupper() can be implemented as: + ** + ** (x & ~(map[x]&0x20)) + ** + ** Standard function tolower() is implemented using the sqlite3UpperToLower[] + ** array. tolower() is used more often than toupper() by SQLite. + ** + ** Bit 0x40 is set if the character non-alphanumeric and can be used in an + ** SQLite identifier. Identifiers are alphanumerics, "_", "$", and any + ** non-ASCII UTF character. Hence the test for whether or not a character is + ** part of an identifier is 0x46. + ** + ** SQLite's versions are identical to the standard versions assuming a + ** locale of "C". They are implemented as macros in sqliteInt.h. + */ #if SQLITE_ASCII - static byte[] sqlite3CtypeMap = new byte[] { + static byte[] sqlite3CtypeMap = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00..07 ........ */ 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, /* 08..0f ........ */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 10..17 ........ */ @@ -147,92 +155,92 @@ public partial class Sqlite3 { #if SQLITE_USE_URI const bool SQLITE_USE_URI = true; #else - //# define SQLITE_USE_URI 0 - const bool SQLITE_USE_URI = false; +//# define SQLITE_USE_URI 0 + const bool SQLITE_USE_URI = false; #endif - /* - ** The following singleton contains the global configuration for - ** the SQLite library. - */ - static Sqlite3Config sqlite3Config = new Sqlite3Config( - SQLITE_DEFAULT_MEMSTATUS, /* bMemstat */ - 1, /* bCoreMutex */ - SQLITE_THREADSAFE != 0, /* bFullMutex */ - SQLITE_USE_URI, /* bOpenUri */ - 0x7ffffffe, /* mxStrlen */ - 100, /* szLookaside */ - 500, /* nLookaside */ - new sqlite3_mem_methods(), /* m */ - new sqlite3_mutex_methods(null, null, null, null, null, null, null, null, null), /* mutex */ - new sqlite3_pcache_methods(),/* pcache */ - null, /* pHeap */ - 0, /* nHeap */ - 0, 0, /* mnHeap, mxHeap */ - null, /* pScratch */ - 0, /* szScratch */ - 0, /* nScratch */ - null, /* pPage */ - SQLITE_DEFAULT_PAGE_SIZE, /* szPage */ - 0, /* nPage */ - 0, /* mxParserStack */ - false, /* sharedCacheEnabled */ - /* All the rest should always be initialized to zero */ - 0, /* isInit */ - 0, /* inProgress */ - 0, /* isMutexInit */ - 0, /* isMallocInit */ - 0, /* isPCacheInit */ - null, /* pInitMutex */ - 0, /* nRefInitMutex */ - null, /* xLog */ - 0, /* pLogArg */ - false /* bLocaltimeFault */ - ); + /* +** The following singleton contains the global configuration for +** the SQLite library. +*/ + static Sqlite3Config sqlite3Config = new Sqlite3Config( + SQLITE_DEFAULT_MEMSTATUS, /* bMemstat */ + 1, /* bCoreMutex */ + SQLITE_THREADSAFE != 0, /* bFullMutex */ + SQLITE_USE_URI, /* bOpenUri */ + 0x7ffffffe, /* mxStrlen */ + 100, /* szLookaside */ + 500, /* nLookaside */ + new sqlite3_mem_methods(), /* m */ + new sqlite3_mutex_methods( null, null, null, null, null, null, null, null, null ), /* mutex */ + new sqlite3_pcache_methods(),/* pcache */ + null, /* pHeap */ + 0, /* nHeap */ + 0, 0, /* mnHeap, mxHeap */ + null, /* pScratch */ + 0, /* szScratch */ + 0, /* nScratch */ + null, /* pPage */ + SQLITE_DEFAULT_PAGE_SIZE, /* szPage */ + 0, /* nPage */ + 0, /* mxParserStack */ + false, /* sharedCacheEnabled */ + /* All the rest should always be initialized to zero */ + 0, /* isInit */ + 0, /* inProgress */ + 0, /* isMutexInit */ + 0, /* isMallocInit */ + 0, /* isPCacheInit */ + null, /* pInitMutex */ + 0, /* nRefInitMutex */ + null, /* xLog */ + 0, /* pLogArg */ + false /* bLocaltimeFault */ + ); - /* - ** Hash table for global functions - functions common to all - ** database connections. After initialization, this table is - ** read-only. - */ - static FuncDefHash sqlite3GlobalFunctions; - /* - ** Constant tokens for values 0 and 1. - */ - static Token[] sqlite3IntTokens = { + /* + ** Hash table for global functions - functions common to all + ** database connections. After initialization, this table is + ** read-only. + */ + static FuncDefHash sqlite3GlobalFunctions; + /* + ** Constant tokens for values 0 and 1. + */ + static Token[] sqlite3IntTokens = { new Token( "0", 1 ), new Token( "1", 1 ) }; - /* - ** The value of the "pending" byte must be 0x40000000 (1 byte past the - ** 1-gibabyte boundary) in a compatible database. SQLite never uses - ** the database page that contains the pending byte. It never attempts - ** to read or write that page. The pending byte page is set assign - ** for use by the VFS layers as space for managing file locks. - ** - ** During testing, it is often desirable to move the pending byte to - ** a different position in the file. This allows code that has to - ** deal with the pending byte to run on files that are much smaller - ** than 1 GiB. The sqlite3_test_control() interface can be used to - ** move the pending byte. - ** - ** IMPORTANT: Changing the pending byte to any value other than - ** 0x40000000 results in an incompatible database file format! - ** Changing the pending byte during operating results in undefined - ** and dileterious behavior. - */ + /* + ** The value of the "pending" byte must be 0x40000000 (1 byte past the + ** 1-gibabyte boundary) in a compatible database. SQLite never uses + ** the database page that contains the pending byte. It never attempts + ** to read or write that page. The pending byte page is set assign + ** for use by the VFS layers as space for managing file locks. + ** + ** During testing, it is often desirable to move the pending byte to + ** a different position in the file. This allows code that has to + ** deal with the pending byte to run on files that are much smaller + ** than 1 GiB. The sqlite3_test_control() interface can be used to + ** move the pending byte. + ** + ** IMPORTANT: Changing the pending byte to any value other than + ** 0x40000000 results in an incompatible database file format! + ** Changing the pending byte during operating results in undefined + ** and dileterious behavior. + */ #if !SQLITE_OMIT_WSD - static int sqlite3PendingByte = 0x40000000; + static int sqlite3PendingByte = 0x40000000; #endif - //#include "opcodes.h" - /* - ** Properties of opcodes. The OPFLG_INITIALIZER macro is - ** created by mkopcodeh.awk during compilation. Data is obtained - ** from the comments following the "case OP_xxxx:" statements in - ** the vdbe.c file. - */ - public static int[] sqlite3OpcodeProperty; - } + //#include "opcodes.h" + /* + ** Properties of opcodes. The OPFLG_INITIALIZER macro is + ** created by mkopcodeh.awk during compilation. Data is obtained + ** from the comments following the "case OP_xxxx:" statements in + ** the vdbe.c file. + */ + public static int[] sqlite3OpcodeProperty; + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/hash_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/hash_c.cs index f276dde05..6bdc08c51 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/hash_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/hash_c.cs @@ -1,127 +1,148 @@ using System; using System.Diagnostics; +using System.Text; +using u8 = System.Byte; using u32 = System.UInt32; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2001 September 22 - ** - ** 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 is the implementation of generic hash-tables - ** used in SQLite. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 2001 September 22 + ** + ** 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 is the implementation of generic hash-tables + ** used in SQLite. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include - /* Turn bulk memory into a hash table object by initializing the - ** fields of the Hash structure. - ** - ** "pNew" is a pointer to the hash table that is to be initialized. - */ - static void sqlite3HashInit(Hash pNew) { - Debug.Assert(pNew != null); - pNew.first = null; - pNew.count = 0; - pNew.htsize = 0; - pNew.ht = null; - } + /* Turn bulk memory into a hash table object by initializing the + ** fields of the Hash structure. + ** + ** "pNew" is a pointer to the hash table that is to be initialized. + */ + static void sqlite3HashInit( Hash pNew ) + { + Debug.Assert( pNew != null ); + pNew.first = null; + pNew.count = 0; + pNew.htsize = 0; + pNew.ht = null; + } - /* Remove all entries from a hash table. Reclaim all memory. - ** Call this routine to delete a hash table or to reset a hash table - ** to the empty state. - */ - static void sqlite3HashClear(Hash pH) { - HashElem elem; /* For looping over all elements of the table */ + /* Remove all entries from a hash table. Reclaim all memory. + ** Call this routine to delete a hash table or to reset a hash table + ** to the empty state. + */ + static void sqlite3HashClear( Hash pH ) + { + HashElem elem; /* For looping over all elements of the table */ - Debug.Assert(pH != null); - elem = pH.first; - pH.first = null; - //sqlite3_free( ref pH.ht ); - pH.ht = null; - pH.htsize = 0; - while (elem != null) { - HashElem next_elem = elem.next; - ////sqlite3_free(ref elem ); - elem = next_elem; - } - pH.count = 0; - } + Debug.Assert( pH != null ); + elem = pH.first; + pH.first = null; + //sqlite3_free( ref pH.ht ); + pH.ht = null; + pH.htsize = 0; + while ( elem != null ) + { + HashElem next_elem = elem.next; + ////sqlite3_free(ref elem ); + elem = next_elem; + } + pH.count = 0; + } - /* - ** The hashing function. - */ - static u32 strHash(string z, int nKey) { - int h = 0; - Debug.Assert(nKey >= 0); - int _z = 0; - while (nKey > 0) { - h = (h << 3) ^ h ^ ((_z < z.Length) ? (int)sqlite3UpperToLower[(byte)z[_z++]] : 0); - nKey--; - } - return (u32)h; - } + /* + ** The hashing function. + */ + static u32 strHash( string z, int nKey ) + { + int h = 0; + Debug.Assert( nKey >= 0 ); + int _z = 0; + while ( nKey > 0 ) + { + h = ( h << 3 ) ^ h ^ ( ( _z < z.Length ) ? (int)sqlite3UpperToLower[(byte)z[_z++]] : 0 ); + nKey--; + } + return (u32)h; + } - /* Link pNew element into the hash table pH. If pEntry!=0 then also - ** insert pNew into the pEntry hash bucket. - */ - static void insertElement( - Hash pH, /* The complete hash table */ - _ht pEntry, /* The entry into which pNew is inserted */ - HashElem pNew /* The element to be inserted */ - ) { - HashElem pHead; /* First element already in pEntry */ - if (pEntry != null) { - pHead = pEntry.count != 0 ? pEntry.chain : null; - pEntry.count++; - pEntry.chain = pNew; - } else { - pHead = null; - } - if (pHead != null) { - pNew.next = pHead; - pNew.prev = pHead.prev; - if (pHead.prev != null) { - pHead.prev.next = pNew; - } else { - pH.first = pNew; - } - pHead.prev = pNew; - } else { - pNew.next = pH.first; - if (pH.first != null) { - pH.first.prev = pNew; - } - pNew.prev = null; - pH.first = pNew; - } + /* Link pNew element into the hash table pH. If pEntry!=0 then also + ** insert pNew into the pEntry hash bucket. + */ + static void insertElement( + Hash pH, /* The complete hash table */ + _ht pEntry, /* The entry into which pNew is inserted */ + HashElem pNew /* The element to be inserted */ + ) + { + HashElem pHead; /* First element already in pEntry */ + if ( pEntry != null ) + { + pHead = pEntry.count != 0 ? pEntry.chain : null; + pEntry.count++; + pEntry.chain = pNew; + } + else + { + pHead = null; + } + if ( pHead != null ) + { + pNew.next = pHead; + pNew.prev = pHead.prev; + if ( pHead.prev != null ) + { + pHead.prev.next = pNew; + } + else + { + pH.first = pNew; + } + pHead.prev = pNew; + } + else + { + pNew.next = pH.first; + if ( pH.first != null ) + { + pH.first.prev = pNew; } + pNew.prev = null; + pH.first = pNew; + } + } - /* Resize the hash table so that it cantains "new_size" buckets. - ** - ** The hash table might fail to resize if sqlite3_malloc() fails or - ** if the new size is the same as the prior size. - ** Return TRUE if the resize occurs and false if not. - */ - static bool rehash(ref Hash pH, u32 new_size) { - _ht[] new_ht; /* The new hash table */ - HashElem elem; - HashElem next_elem; /* For looping over existing elements */ + /* Resize the hash table so that it cantains "new_size" buckets. + ** + ** The hash table might fail to resize if sqlite3_malloc() fails or + ** if the new size is the same as the prior size. + ** Return TRUE if the resize occurs and false if not. + */ + static bool rehash( ref Hash pH, u32 new_size ) + { + _ht[] new_ht; /* The new hash table */ + HashElem elem; + HashElem next_elem; /* For looping over existing elements */ #if SQLITE_MALLOC_SOFT_LIMIT if( new_size*sizeof(struct _ht)>SQLITE_MALLOC_SOFT_LIMIT ){ @@ -130,181 +151,213 @@ static bool rehash(ref Hash pH, u32 new_size) { if( new_size==pH->htsize ) return false; #endif - /* There is a call to sqlite3Malloc() inside rehash(). If there is - ** already an allocation at pH.ht, then if this malloc() fails it - ** is benign (since failing to resize a hash table is a performance - ** hit only, not a fatal error). - */ - sqlite3BeginBenignMalloc(); - new_ht = new _ht[new_size]; //(struct _ht )sqlite3Malloc( new_size*sizeof(struct _ht) ); - for (int i = 0; i < new_size; i++) - new_ht[i] = new _ht(); - sqlite3EndBenignMalloc(); + /* There is a call to sqlite3Malloc() inside rehash(). If there is +** already an allocation at pH.ht, then if this malloc() fails it +** is benign (since failing to resize a hash table is a performance +** hit only, not a fatal error). +*/ + sqlite3BeginBenignMalloc(); + new_ht = new _ht[new_size]; //(struct _ht )sqlite3Malloc( new_size*sizeof(struct _ht) ); + for ( int i = 0; i < new_size; i++ ) + new_ht[i] = new _ht(); + sqlite3EndBenignMalloc(); - if (new_ht == null) - return false; - //sqlite3_free( ref pH.ht ); - pH.ht = new_ht; - // pH.htsize = new_size = sqlite3MallocSize(new_ht)/sizeof(struct _ht); - //memset(new_ht, 0, new_size*sizeof(struct _ht)); - pH.htsize = new_size; + if ( new_ht == null ) + return false; + //sqlite3_free( ref pH.ht ); + pH.ht = new_ht; + // pH.htsize = new_size = sqlite3MallocSize(new_ht)/sizeof(struct _ht); + //memset(new_ht, 0, new_size*sizeof(struct _ht)); + pH.htsize = new_size; - for (elem = pH.first, pH.first = null; elem != null; elem = next_elem) { - u32 h = strHash(elem.pKey, elem.nKey) % new_size; - next_elem = elem.next; - insertElement(pH, new_ht[h], elem); - } - return true; - } + for ( elem = pH.first, pH.first = null; elem != null; elem = next_elem ) + { + u32 h = strHash( elem.pKey, elem.nKey ) % new_size; + next_elem = elem.next; + insertElement( pH, new_ht[h], elem ); + } + return true; + } - /* This function (for internal use only) locates an element in an - ** hash table that matches the given key. The hash for this key has - ** already been computed and is passed as the 4th parameter. - */ - static HashElem findElementGivenHash( - Hash pH, /* The pH to be searched */ - string pKey, /* The key we are searching for */ - int nKey, /* Bytes in key (not counting zero terminator) */ - u32 h /* The hash for this key. */ - ) { - HashElem elem; /* Used to loop thru the element list */ - int count; /* Number of elements left to test */ + /* This function (for internal use only) locates an element in an + ** hash table that matches the given key. The hash for this key has + ** already been computed and is passed as the 4th parameter. + */ + static HashElem findElementGivenHash( + Hash pH, /* The pH to be searched */ + string pKey, /* The key we are searching for */ + int nKey, /* Bytes in key (not counting zero terminator) */ + u32 h /* The hash for this key. */ + ) + { + HashElem elem; /* Used to loop thru the element list */ + int count; /* Number of elements left to test */ - if (pH.ht != null && pH.ht[h] != null) { - _ht pEntry = pH.ht[h]; - elem = pEntry.chain; - count = (int)pEntry.count; - } else { - elem = pH.first; - count = (int)pH.count; - } - while (count-- > 0 && ALWAYS(elem)) { - if (elem.nKey == nKey && elem.pKey.Equals(pKey, StringComparison.OrdinalIgnoreCase)) { - return elem; - } - elem = elem.next; - } - return null; + if ( pH.ht != null && pH.ht[h] != null ) + { + _ht pEntry = pH.ht[h]; + elem = pEntry.chain; + count = (int)pEntry.count; + } + else + { + elem = pH.first; + count = (int)pH.count; + } + while ( count-- > 0 && ALWAYS( elem ) ) + { + if ( elem.nKey == nKey && elem.pKey.Equals( pKey, StringComparison.OrdinalIgnoreCase ) ) + { + return elem; } + elem = elem.next; + } + return null; + } - /* Remove a single entry from the hash table given a pointer to that - ** element and a hash on the element's key. - */ - static void removeElementGivenHash( - Hash pH, /* The pH containing "elem" */ - ref HashElem elem, /* The element to be removed from the pH */ - u32 h /* Hash value for the element */ - ) { - _ht pEntry; - if (elem.prev != null) { - elem.prev.next = elem.next; - } else { - pH.first = elem.next; - } - if (elem.next != null) { - elem.next.prev = elem.prev; - } - if (pH.ht != null && pH.ht[h] != null) { - pEntry = pH.ht[h]; - if (pEntry.chain == elem) { - pEntry.chain = elem.next; - } - pEntry.count--; - Debug.Assert(pEntry.count >= 0); - } - //sqlite3_free( ref elem ); - pH.count--; - if (pH.count <= 0) { - Debug.Assert(pH.first == null); - Debug.Assert(pH.count == 0); - sqlite3HashClear(pH); - } + /* Remove a single entry from the hash table given a pointer to that + ** element and a hash on the element's key. + */ + static void removeElementGivenHash( + Hash pH, /* The pH containing "elem" */ + ref HashElem elem, /* The element to be removed from the pH */ + u32 h /* Hash value for the element */ + ) + { + _ht pEntry; + if ( elem.prev != null ) + { + elem.prev.next = elem.next; + } + else + { + pH.first = elem.next; + } + if ( elem.next != null ) + { + elem.next.prev = elem.prev; + } + if ( pH.ht != null && pH.ht[h] != null ) + { + pEntry = pH.ht[h]; + if ( pEntry.chain == elem ) + { + pEntry.chain = elem.next; } + pEntry.count--; + Debug.Assert( pEntry.count >= 0 ); + } + //sqlite3_free( ref elem ); + pH.count--; + if ( pH.count <= 0 ) + { + Debug.Assert( pH.first == null ); + Debug.Assert( pH.count == 0 ); + sqlite3HashClear( pH ); + } + } - /* Attempt to locate an element of the hash table pH with a key - ** that matches pKey,nKey. Return the data for this element if it is - ** found, or NULL if there is no match. - */ - static T sqlite3HashFind(Hash pH, string pKey, int nKey, T nullType) where T : class { - HashElem elem; /* The element that matches key */ - u32 h; /* A hash on key */ - - Debug.Assert(pH != null); - Debug.Assert(pKey != null); - Debug.Assert(nKey >= 0); - if (pH.ht != null) { - h = strHash(pKey, nKey) % pH.htsize; - } else { - h = 0; - } - elem = findElementGivenHash(pH, pKey, nKey, h); - return elem != null ? (T)elem.data : nullType; - } + /* Attempt to locate an element of the hash table pH with a key + ** that matches pKey,nKey. Return the data for this element if it is + ** found, or NULL if there is no match. + */ + static T sqlite3HashFind( Hash pH, string pKey, int nKey, T nullType ) where T : class + { + HashElem elem; /* The element that matches key */ + u32 h; /* A hash on key */ - /* Insert an element into the hash table pH. The key is pKey,nKey - ** and the data is "data". - ** - ** If no element exists with a matching key, then a new - ** element is created and NULL is returned. - ** - ** If another element already exists with the same key, then the - ** new data replaces the old data and the old data is returned. - ** The key is not copied in this instance. If a malloc fails, then - ** the new data is returned and the hash table is unchanged. - ** - ** If the "data" parameter to this function is NULL, then the - ** element corresponding to "key" is removed from the hash table. - */ - static T sqlite3HashInsert(ref Hash pH, string pKey, int nKey, T data) where T : class { - u32 h; /* the hash of the key modulo hash table size */ + Debug.Assert( pH != null ); + Debug.Assert( pKey != null ); + Debug.Assert( nKey >= 0 ); + if ( pH.ht != null ) + { + h = strHash( pKey, nKey ) % pH.htsize; + } + else + { + h = 0; + } + elem = findElementGivenHash( pH, pKey, nKey, h ); + return elem != null ? (T)elem.data : nullType; + } - HashElem elem; /* Used to loop thru the element list */ - HashElem new_elem; /* New element added to the pH */ + /* Insert an element into the hash table pH. The key is pKey,nKey + ** and the data is "data". + ** + ** If no element exists with a matching key, then a new + ** element is created and NULL is returned. + ** + ** If another element already exists with the same key, then the + ** new data replaces the old data and the old data is returned. + ** The key is not copied in this instance. If a malloc fails, then + ** the new data is returned and the hash table is unchanged. + ** + ** If the "data" parameter to this function is NULL, then the + ** element corresponding to "key" is removed from the hash table. + */ + static T sqlite3HashInsert( ref Hash pH, string pKey, int nKey, T data ) where T : class + { + u32 h; /* the hash of the key modulo hash table size */ - Debug.Assert(pH != null); - Debug.Assert(pKey != null); - Debug.Assert(nKey >= 0); + HashElem elem; /* Used to loop thru the element list */ + HashElem new_elem; /* New element added to the pH */ - if (pH.htsize != 0) { - h = strHash(pKey, nKey) % pH.htsize; - } else { - h = 0; - } - elem = findElementGivenHash(pH, pKey, nKey, h); - if (elem != null) { - T old_data = (T)elem.data; - if (data == null) { - removeElementGivenHash(pH, ref elem, h); - } else { - elem.data = data; - elem.pKey = pKey; - Debug.Assert(nKey == elem.nKey); - } - return old_data; - } - if (data == null) - return data; - new_elem = new HashElem();//(HashElem)sqlite3Malloc( sizeof(HashElem) ); - if (new_elem == null) - return data; - new_elem.pKey = pKey; - new_elem.nKey = nKey; - new_elem.data = data; - pH.count++; - if (pH.count >= 10 && pH.count > 2 * pH.htsize) { - if (rehash(ref pH, pH.count * 2)) { - Debug.Assert(pH.htsize > 0); - h = strHash(pKey, nKey) % pH.htsize; - } - } - if (pH.ht != null) { - insertElement(pH, pH.ht[h], new_elem); + Debug.Assert( pH != null ); + Debug.Assert( pKey != null ); + Debug.Assert( nKey >= 0 ); - } else { - insertElement(pH, null, new_elem); - } - return null; + if ( pH.htsize != 0 ) + { + h = strHash( pKey, nKey ) % pH.htsize; + } + else + { + h = 0; + } + elem = findElementGivenHash( pH, pKey, nKey, h ); + if ( elem != null ) + { + T old_data = (T)elem.data; + if ( data == null ) + { + removeElementGivenHash( pH, ref elem, h ); + } + else + { + elem.data = data; + elem.pKey = pKey; + Debug.Assert( nKey == elem.nKey ); } + return old_data; + } + if ( data == null ) + return data; + new_elem = new HashElem();//(HashElem)sqlite3Malloc( sizeof(HashElem) ); + if ( new_elem == null ) + return data; + new_elem.pKey = pKey; + new_elem.nKey = nKey; + new_elem.data = data; + pH.count++; + if ( pH.count >= 10 && pH.count > 2 * pH.htsize ) + { + if ( rehash( ref pH, pH.count * 2 ) ) + { + Debug.Assert( pH.htsize > 0 ); + h = strHash( pKey, nKey ) % pH.htsize; + } + } + if ( pH.ht != null ) + { + insertElement( pH, pH.ht[h], new_elem ); + } + else + { + insertElement( pH, null, new_elem ); + } + return null; } + + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/hwtime_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/hwtime_c.cs index 688f21d22..8fcb8ca3a 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/hwtime_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/hwtime_c.cs @@ -1,40 +1,42 @@ -namespace Community.CsharpSqlite { - using sqlite_u3264 = System.UInt64; - - public partial class Sqlite3 { - /* - ** 2008 May 27 - ** - ** 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 contains inline asm code for retrieving "high-performance" - ** counters for x86 class CPUs. - ** - ** $Id: hwtime.h,v 1.3 2008/08/01 14:33:15 shane Exp $ - ** - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ************************************************************************* - */ - //#if !_HWTIME_H_ - //#define _HWTIME_H_ - - /* - ** The following routine only works on pentium-class (or newer) processors. - ** It uses the RDTSC opcode to read the cycle count value out of the - ** processor and returns that value. This can be used for high-res - ** profiling. - */ -#if ((__GNUC__) || (_MSC_VER)) && ((i386) || (__i386__) || (_M_IX86)) +namespace Community.CsharpSqlite +{ + using sqlite_u3264 = System.UInt64; + + public partial class Sqlite3 + { + /* + ** 2008 May 27 + ** + ** 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 contains inline asm code for retrieving "high-performance" + ** counters for x86 class CPUs. + ** + ** $Id: hwtime.h,v 1.3 2008/08/01 14:33:15 shane Exp $ + ** + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ************************************************************************* + */ + //#if !_HWTIME_H_ + //#define _HWTIME_H_ + + /* + ** The following routine only works on pentium-class (or newer) processors. + ** It uses the RDTSC opcode to read the cycle count value out of the + ** processor and returns that value. This can be used for high-res + ** profiling. + */ +#if ((__GNUC__) || (_MSC_VER)) && ((i386) || (__i386__) || (_M_IX86)) #if (__GNUC__) @@ -44,7 +46,7 @@ __inline__ sqlite_u3264 sqlite3Hwtime(void){ return (sqlite_u3264)hi << 32 | lo; } -#elif (_MSC_VER) +#elif (_MSC_VER) __declspec(naked) __inline sqlite_u3264 __cdecl sqlite3Hwtime(void){ __asm { @@ -63,7 +65,7 @@ __inline__ sqlite_u3264 sqlite3Hwtime(void){ return val; } -#elif ((__GNUC__) && (__ppc__)) +#elif ( (__GNUC__) && (__ppc__)) __inline__ sqlite_u3264 sqlite3Hwtime(void){ unsigned long long retval; @@ -80,21 +82,22 @@ bne 1b" #else - //#error Need implementation of sqlite3Hwtime() for your platform. + //#error Need implementation of sqlite3Hwtime() for your platform. - /* - ** To compile without implementing sqlite3Hwtime() for your platform, - ** you can remove the above #error and use the following - ** stub function. You will lose timing support for many - ** of the debugging and testing utilities, but it should at - ** least compile and run. - */ - static sqlite_u3264 sqlite3Hwtime() { - return (sqlite_u3264)System.DateTime.Now.Ticks; - }// (sqlite_u3264)0 ); } + /* + ** To compile without implementing sqlite3Hwtime() for your platform, + ** you can remove the above #error and use the following + ** stub function. You will lose timing support for many + ** of the debugging and testing utilities, but it should at + ** least compile and run. + */ + static sqlite_u3264 sqlite3Hwtime() + { + return (sqlite_u3264)System.DateTime.Now.Ticks; + }// (sqlite_u3264)0 ); } #endif - //#endif //* !_HWTIME_H_) */ - } + //#endif //* !_HWTIME_H_) */ + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/insert_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/insert_c.cs index 81566bb7f..f95558619 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/insert_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/insert_c.cs @@ -2,332 +2,361 @@ using System.Diagnostics; using System.Text; +using Pgno = System.UInt32; using u8 = System.Byte; +using u32 = System.UInt32; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 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. - ** - ************************************************************************* - ** This file contains C code routines that are called by the parser - ** to handle INSERT statements in SQLite. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 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. + ** + ************************************************************************* + ** This file contains C code routines that are called by the parser + ** to handle INSERT statements in SQLite. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" - /* - ** Generate code that will open a table for reading. - */ - static void sqlite3OpenTable( - Parse p, /* Generate code into this VDBE */ - int iCur, /* The cursor number of the table */ - int iDb, /* The database index in sqlite3.aDb[] */ - Table pTab, /* The table to be opened */ - int opcode /* OP_OpenRead or OP_OpenWrite */ - ) { - Vdbe v; - if (IsVirtual(pTab)) - return; - v = sqlite3GetVdbe(p); - Debug.Assert(opcode == OP_OpenWrite || opcode == OP_OpenRead); - sqlite3TableLock(p, iDb, pTab.tnum, (opcode == OP_OpenWrite) ? (byte)1 : (byte)0, pTab.zName); - sqlite3VdbeAddOp3(v, opcode, iCur, pTab.tnum, iDb); - sqlite3VdbeChangeP4(v, -1, (pTab.nCol), P4_INT32);//SQLITE_INT_TO_PTR( pTab.nCol ), P4_INT32 ); - VdbeComment(v, "%s", pTab.zName); - } + /* + ** Generate code that will open a table for reading. + */ + static void sqlite3OpenTable( + Parse p, /* Generate code into this VDBE */ + int iCur, /* The cursor number of the table */ + int iDb, /* The database index in sqlite3.aDb[] */ + Table pTab, /* The table to be opened */ + int opcode /* OP_OpenRead or OP_OpenWrite */ + ) + { + Vdbe v; + if ( IsVirtual( pTab ) ) + return; + v = sqlite3GetVdbe( p ); + Debug.Assert( opcode == OP_OpenWrite || opcode == OP_OpenRead ); + sqlite3TableLock( p, iDb, pTab.tnum, ( opcode == OP_OpenWrite ) ? (byte)1 : (byte)0, pTab.zName ); + sqlite3VdbeAddOp3( v, opcode, iCur, pTab.tnum, iDb ); + sqlite3VdbeChangeP4( v, -1, ( pTab.nCol ), P4_INT32 );//SQLITE_INT_TO_PTR( pTab.nCol ), P4_INT32 ); + VdbeComment( v, "%s", pTab.zName ); + } - /* - ** Return a pointer to the column affinity string associated with index - ** pIdx. A column affinity string has one character for each column in - ** the table, according to the affinity of the column: - ** - ** Character Column affinity - ** ------------------------------ - ** 'a' TEXT - ** 'b' NONE - ** 'c' NUMERIC - ** 'd' INTEGER - ** 'e' REAL - ** - ** An extra 'b' is appended to the end of the string to cover the - ** rowid that appears as the last column in every index. + /* + ** Return a pointer to the column affinity string associated with index + ** pIdx. A column affinity string has one character for each column in + ** the table, according to the affinity of the column: + ** + ** Character Column affinity + ** ------------------------------ + ** 'a' TEXT + ** 'b' NONE + ** 'c' NUMERIC + ** 'd' INTEGER + ** 'e' REAL + ** + ** An extra 'b' is appended to the end of the string to cover the + ** rowid that appears as the last column in every index. + ** + ** Memory for the buffer containing the column index affinity string + ** is managed along with the rest of the Index structure. It will be + ** released when sqlite3DeleteIndex() is called. + */ + static string sqlite3IndexAffinityStr( Vdbe v, Index pIdx ) + { + if ( pIdx.zColAff == null || pIdx.zColAff[0] == '\0' ) + { + /* The first time a column affinity string for a particular index is + ** required, it is allocated and populated here. It is then stored as + ** a member of the Index structure for subsequent use. ** - ** Memory for the buffer containing the column index affinity string - ** is managed along with the rest of the Index structure. It will be - ** released when sqlite3DeleteIndex() is called. + ** The column affinity string will eventually be deleted by + ** sqliteDeleteIndex() when the Index structure itself is cleaned + ** up. */ - static string sqlite3IndexAffinityStr(Vdbe v, Index pIdx) { - if (pIdx.zColAff == null || pIdx.zColAff[0] == '\0') { - /* The first time a column affinity string for a particular index is - ** required, it is allocated and populated here. It is then stored as - ** a member of the Index structure for subsequent use. - ** - ** The column affinity string will eventually be deleted by - ** sqliteDeleteIndex() when the Index structure itself is cleaned - ** up. - */ - int n; - Table pTab = pIdx.pTable; - sqlite3 db = sqlite3VdbeDb(v); - StringBuilder pIdx_zColAff = new StringBuilder(pIdx.nColumn + 2);// (char )sqlite3DbMallocRaw(0, pIdx->nColumn+2); - // if ( pIdx_zColAff == null ) - // { - // db.mallocFailed = 1; - // return null; - // } - for (n = 0; n < pIdx.nColumn; n++) { - pIdx_zColAff.Append(pTab.aCol[pIdx.aiColumn[n]].affinity); - } - pIdx_zColAff.Append(SQLITE_AFF_NONE); - pIdx_zColAff.Append('\0'); - pIdx.zColAff = pIdx_zColAff.ToString(); - } - return pIdx.zColAff; + int n; + Table pTab = pIdx.pTable; + sqlite3 db = sqlite3VdbeDb( v ); + StringBuilder pIdx_zColAff = new StringBuilder( pIdx.nColumn + 2 );// (char )sqlite3DbMallocRaw(0, pIdx->nColumn+2); + // if ( pIdx_zColAff == null ) + // { + // db.mallocFailed = 1; + // return null; + // } + for ( n = 0; n < pIdx.nColumn; n++ ) + { + pIdx_zColAff.Append( pTab.aCol[pIdx.aiColumn[n]].affinity ); } + pIdx_zColAff.Append( SQLITE_AFF_NONE ); + pIdx_zColAff.Append( '\0' ); + pIdx.zColAff = pIdx_zColAff.ToString(); + } + return pIdx.zColAff; + } - /* - ** Set P4 of the most recently inserted opcode to a column affinity - ** string for table pTab. A column affinity string has one character - ** for each column indexed by the index, according to the affinity of the - ** column: - ** - ** Character Column affinity - ** ------------------------------ - ** 'a' TEXT - ** 'b' NONE - ** 'c' NUMERIC - ** 'd' INTEGER - ** 'e' REAL - */ - static void sqlite3TableAffinityStr(Vdbe v, Table pTab) { - /* The first time a column affinity string for a particular table - ** is required, it is allocated and populated here. It is then - ** stored as a member of the Table structure for subsequent use. - ** - ** The column affinity string will eventually be deleted by - ** sqlite3DeleteTable() when the Table structure itself is cleaned up. - */ - if (pTab.zColAff == null) { - StringBuilder zColAff; - int i; - sqlite3 db = sqlite3VdbeDb(v); - - zColAff = new StringBuilder(pTab.nCol + 1);// (char)sqlite3DbMallocRaw(0, pTab->nCol+1); - if (zColAff == null) { - //// db.mallocFailed = 1; - return; - } + /* + ** Set P4 of the most recently inserted opcode to a column affinity + ** string for table pTab. A column affinity string has one character + ** for each column indexed by the index, according to the affinity of the + ** column: + ** + ** Character Column affinity + ** ------------------------------ + ** 'a' TEXT + ** 'b' NONE + ** 'c' NUMERIC + ** 'd' INTEGER + ** 'e' REAL + */ + static void sqlite3TableAffinityStr( Vdbe v, Table pTab ) + { + /* The first time a column affinity string for a particular table + ** is required, it is allocated and populated here. It is then + ** stored as a member of the Table structure for subsequent use. + ** + ** The column affinity string will eventually be deleted by + ** sqlite3DeleteTable() when the Table structure itself is cleaned up. + */ + if ( pTab.zColAff == null ) + { + StringBuilder zColAff; + int i; + sqlite3 db = sqlite3VdbeDb( v ); + + zColAff = new StringBuilder( pTab.nCol + 1 );// (char)sqlite3DbMallocRaw(0, pTab->nCol+1); + if ( zColAff == null ) + { + //// db.mallocFailed = 1; + return; + } - for (i = 0; i < pTab.nCol; i++) { - zColAff.Append(pTab.aCol[i].affinity); - } - //zColAff.Append( '\0' ); + for ( i = 0; i < pTab.nCol; i++ ) + { + zColAff.Append( pTab.aCol[i].affinity ); + } + //zColAff.Append( '\0' ); - pTab.zColAff = zColAff.ToString(); - } + pTab.zColAff = zColAff.ToString(); + } - sqlite3VdbeChangeP4(v, -1, pTab.zColAff, P4_TRANSIENT); - } + sqlite3VdbeChangeP4( v, -1, pTab.zColAff, P4_TRANSIENT ); + } - /* - ** Return non-zero if the table pTab in database iDb or any of its indices - ** have been opened at any point in the VDBE program beginning at location - ** iStartAddr throught the end of the program. This is used to see if - ** a statement of the form "INSERT INTO SELECT ..." can - ** run without using temporary table for the results of the SELECT. - */ - static bool readsTable(Parse p, int iStartAddr, int iDb, Table pTab) { - Vdbe v = sqlite3GetVdbe(p); - int i; - int iEnd = sqlite3VdbeCurrentAddr(v); + /* + ** Return non-zero if the table pTab in database iDb or any of its indices + ** have been opened at any point in the VDBE program beginning at location + ** iStartAddr throught the end of the program. This is used to see if + ** a statement of the form "INSERT INTO SELECT ..." can + ** run without using temporary table for the results of the SELECT. + */ + static bool readsTable( Parse p, int iStartAddr, int iDb, Table pTab ) + { + Vdbe v = sqlite3GetVdbe( p ); + int i; + int iEnd = sqlite3VdbeCurrentAddr( v ); #if !SQLITE_OMIT_VIRTUALTABLE - VTable pVTab = IsVirtual(pTab) ? sqlite3GetVTable(p.db, pTab) : null; + VTable pVTab = IsVirtual( pTab ) ? sqlite3GetVTable( p.db, pTab ) : null; #endif - for (i = iStartAddr; i < iEnd; i++) { - VdbeOp pOp = sqlite3VdbeGetOp(v, i); - Debug.Assert(pOp != null); - if (pOp.opcode == OP_OpenRead && pOp.p3 == iDb) { - Index pIndex; - int tnum = pOp.p2; - if (tnum == pTab.tnum) { - return true; - } - for (pIndex = pTab.pIndex; pIndex != null; pIndex = pIndex.pNext) { - if (tnum == pIndex.tnum) { - return true; - } - } - } -#if !SQLITE_OMIT_VIRTUALTABLE - if (pOp.opcode == OP_VOpen && pOp.p4.pVtab == pVTab) { - Debug.Assert(pOp.p4.pVtab != null); - Debug.Assert(pOp.p4type == P4_VTAB); - return true; - } -#endif + for ( i = iStartAddr; i < iEnd; i++ ) + { + VdbeOp pOp = sqlite3VdbeGetOp( v, i ); + Debug.Assert( pOp != null ); + if ( pOp.opcode == OP_OpenRead && pOp.p3 == iDb ) + { + Index pIndex; + int tnum = pOp.p2; + if ( tnum == pTab.tnum ) + { + return true; + } + for ( pIndex = pTab.pIndex; pIndex != null; pIndex = pIndex.pNext ) + { + if ( tnum == pIndex.tnum ) + { + return true; } - return false; + } + } +#if !SQLITE_OMIT_VIRTUALTABLE + if ( pOp.opcode == OP_VOpen && pOp.p4.pVtab == pVTab ) + { + Debug.Assert( pOp.p4.pVtab != null ); + Debug.Assert( pOp.p4type == P4_VTAB ); + return true; } +#endif + } + return false; + } #if !SQLITE_OMIT_AUTOINCREMENT - /* - ** Locate or create an AutoincInfo structure associated with table pTab - ** which is in database iDb. Return the register number for the register - ** that holds the maximum rowid. - ** - ** There is at most one AutoincInfo structure per table even if the - ** same table is autoincremented multiple times due to inserts within - ** triggers. A new AutoincInfo structure is created if this is the - ** first use of table pTab. On 2nd and subsequent uses, the original - ** AutoincInfo structure is used. - ** - ** Three memory locations are allocated: - ** - ** (1) Register to hold the name of the pTab table. - ** (2) Register to hold the maximum ROWID of pTab. - ** (3) Register to hold the rowid in sqlite_sequence of pTab - ** - ** The 2nd register is the one that is returned. That is all the - ** insert routine needs to know about. - */ - static int autoIncBegin( - Parse pParse, /* Parsing context */ - int iDb, /* Index of the database holding pTab */ - Table pTab /* The table we are writing to */ - ) { - int memId = 0; /* Register holding maximum rowid */ - if ((pTab.tabFlags & TF_Autoincrement) != 0) { - Parse pToplevel = sqlite3ParseToplevel(pParse); - AutoincInfo pInfo; - - pInfo = pToplevel.pAinc; - while (pInfo != null && pInfo.pTab != pTab) { - pInfo = pInfo.pNext; - } - if (pInfo == null) { - pInfo = new AutoincInfo();//sqlite3DbMallocRaw(pParse.db, sizeof(*pInfo)); - //if( pInfo==0 ) return 0; - pInfo.pNext = pToplevel.pAinc; - pToplevel.pAinc = pInfo; - pInfo.pTab = pTab; - pInfo.iDb = iDb; - pToplevel.nMem++; /* Register to hold name of table */ - pInfo.regCtr = ++pToplevel.nMem; /* Max rowid register */ - pToplevel.nMem++; /* Rowid in sqlite_sequence */ - } - memId = pInfo.regCtr; - } - return memId; + /* +** Locate or create an AutoincInfo structure associated with table pTab +** which is in database iDb. Return the register number for the register +** that holds the maximum rowid. +** +** There is at most one AutoincInfo structure per table even if the +** same table is autoincremented multiple times due to inserts within +** triggers. A new AutoincInfo structure is created if this is the +** first use of table pTab. On 2nd and subsequent uses, the original +** AutoincInfo structure is used. +** +** Three memory locations are allocated: +** +** (1) Register to hold the name of the pTab table. +** (2) Register to hold the maximum ROWID of pTab. +** (3) Register to hold the rowid in sqlite_sequence of pTab +** +** The 2nd register is the one that is returned. That is all the +** insert routine needs to know about. +*/ + static int autoIncBegin( + Parse pParse, /* Parsing context */ + int iDb, /* Index of the database holding pTab */ + Table pTab /* The table we are writing to */ + ) + { + int memId = 0; /* Register holding maximum rowid */ + if ( ( pTab.tabFlags & TF_Autoincrement ) != 0 ) + { + Parse pToplevel = sqlite3ParseToplevel( pParse ); + AutoincInfo pInfo; + + pInfo = pToplevel.pAinc; + while ( pInfo != null && pInfo.pTab != pTab ) + { + pInfo = pInfo.pNext; } - - /* - ** This routine generates code that will initialize all of the - ** register used by the autoincrement tracker. - */ - static void sqlite3AutoincrementBegin(Parse pParse) { - AutoincInfo p; /* Information about an AUTOINCREMENT */ - sqlite3 db = pParse.db; /* The database connection */ - Db pDb; /* Database only autoinc table */ - int memId; /* Register holding max rowid */ - int addr; /* A VDBE address */ - Vdbe v = pParse.pVdbe; /* VDBE under construction */ - - /* This routine is never called during trigger-generation. It is - ** only called from the top-level */ - Debug.Assert(pParse.pTriggerTab == null); - Debug.Assert(pParse == sqlite3ParseToplevel(pParse)); - - Debug.Assert(v != null); /* We failed long ago if this is not so */ - for (p = pParse.pAinc; p != null; p = p.pNext) { - pDb = db.aDb[p.iDb]; - memId = p.regCtr; - Debug.Assert(sqlite3SchemaMutexHeld(db, 0, pDb.pSchema)); - sqlite3OpenTable(pParse, 0, p.iDb, pDb.pSchema.pSeqTab, OP_OpenRead); - addr = sqlite3VdbeCurrentAddr(v); - sqlite3VdbeAddOp4(v, OP_String8, 0, memId - 1, 0, p.pTab.zName, 0); - sqlite3VdbeAddOp2(v, OP_Rewind, 0, addr + 9); - sqlite3VdbeAddOp3(v, OP_Column, 0, 0, memId); - sqlite3VdbeAddOp3(v, OP_Ne, memId - 1, addr + 7, memId); - sqlite3VdbeChangeP5(v, SQLITE_JUMPIFNULL); - sqlite3VdbeAddOp2(v, OP_Rowid, 0, memId + 1); - sqlite3VdbeAddOp3(v, OP_Column, 0, 1, memId); - sqlite3VdbeAddOp2(v, OP_Goto, 0, addr + 9); - sqlite3VdbeAddOp2(v, OP_Next, 0, addr + 2); - sqlite3VdbeAddOp2(v, OP_Integer, 0, memId); - sqlite3VdbeAddOp0(v, OP_Close); - } + if ( pInfo == null ) + { + pInfo = new AutoincInfo();//sqlite3DbMallocRaw(pParse.db, sizeof(*pInfo)); + //if( pInfo==0 ) return 0; + pInfo.pNext = pToplevel.pAinc; + pToplevel.pAinc = pInfo; + pInfo.pTab = pTab; + pInfo.iDb = iDb; + pToplevel.nMem++; /* Register to hold name of table */ + pInfo.regCtr = ++pToplevel.nMem; /* Max rowid register */ + pToplevel.nMem++; /* Rowid in sqlite_sequence */ } + memId = pInfo.regCtr; + } + return memId; + } - /* - ** Update the maximum rowid for an autoincrement calculation. - ** - ** This routine should be called when the top of the stack holds a - ** new rowid that is about to be inserted. If that new rowid is - ** larger than the maximum rowid in the memId memory cell, then the - ** memory cell is updated. The stack is unchanged. - */ - static void autoIncStep(Parse pParse, int memId, int regRowid) { - if (memId > 0) { - sqlite3VdbeAddOp2(pParse.pVdbe, OP_MemMax, memId, regRowid); - } - } + /* + ** This routine generates code that will initialize all of the + ** register used by the autoincrement tracker. + */ + static void sqlite3AutoincrementBegin( Parse pParse ) + { + AutoincInfo p; /* Information about an AUTOINCREMENT */ + sqlite3 db = pParse.db; /* The database connection */ + Db pDb; /* Database only autoinc table */ + int memId; /* Register holding max rowid */ + int addr; /* A VDBE address */ + Vdbe v = pParse.pVdbe; /* VDBE under construction */ + + /* This routine is never called during trigger-generation. It is + ** only called from the top-level */ + Debug.Assert( pParse.pTriggerTab == null ); + Debug.Assert( pParse == sqlite3ParseToplevel( pParse ) ); + + Debug.Assert( v != null ); /* We failed long ago if this is not so */ + for ( p = pParse.pAinc; p != null; p = p.pNext ) + { + pDb = db.aDb[p.iDb]; + memId = p.regCtr; + Debug.Assert( sqlite3SchemaMutexHeld( db, 0, pDb.pSchema ) ); + sqlite3OpenTable( pParse, 0, p.iDb, pDb.pSchema.pSeqTab, OP_OpenRead ); + addr = sqlite3VdbeCurrentAddr( v ); + sqlite3VdbeAddOp4( v, OP_String8, 0, memId - 1, 0, p.pTab.zName, 0 ); + sqlite3VdbeAddOp2( v, OP_Rewind, 0, addr + 9 ); + sqlite3VdbeAddOp3( v, OP_Column, 0, 0, memId ); + sqlite3VdbeAddOp3( v, OP_Ne, memId - 1, addr + 7, memId ); + sqlite3VdbeChangeP5( v, SQLITE_JUMPIFNULL ); + sqlite3VdbeAddOp2( v, OP_Rowid, 0, memId + 1 ); + sqlite3VdbeAddOp3( v, OP_Column, 0, 1, memId ); + sqlite3VdbeAddOp2( v, OP_Goto, 0, addr + 9 ); + sqlite3VdbeAddOp2( v, OP_Next, 0, addr + 2 ); + sqlite3VdbeAddOp2( v, OP_Integer, 0, memId ); + sqlite3VdbeAddOp0( v, OP_Close ); + } + } - /* - ** This routine generates the code needed to write autoincrement - ** maximum rowid values back into the sqlite_sequence register. - ** Every statement that might do an INSERT into an autoincrement - ** table (either directly or through triggers) needs to call this - ** routine just before the "exit" code. - */ - static void sqlite3AutoincrementEnd(Parse pParse) { - AutoincInfo p; - Vdbe v = pParse.pVdbe; - sqlite3 db = pParse.db; - - Debug.Assert(v != null); - for (p = pParse.pAinc; p != null; p = p.pNext) { - Db pDb = db.aDb[p.iDb]; - int j1, j2, j3, j4, j5; - int iRec; - int memId = p.regCtr; - - iRec = sqlite3GetTempReg(pParse); - Debug.Assert(sqlite3SchemaMutexHeld(db, 0, pDb.pSchema)); - sqlite3OpenTable(pParse, 0, p.iDb, pDb.pSchema.pSeqTab, OP_OpenWrite); - j1 = sqlite3VdbeAddOp1(v, OP_NotNull, memId + 1); - j2 = sqlite3VdbeAddOp0(v, OP_Rewind); - j3 = sqlite3VdbeAddOp3(v, OP_Column, 0, 0, iRec); - j4 = sqlite3VdbeAddOp3(v, OP_Eq, memId - 1, 0, iRec); - sqlite3VdbeAddOp2(v, OP_Next, 0, j3); - sqlite3VdbeJumpHere(v, j2); - sqlite3VdbeAddOp2(v, OP_NewRowid, 0, memId + 1); - j5 = sqlite3VdbeAddOp0(v, OP_Goto); - sqlite3VdbeJumpHere(v, j4); - sqlite3VdbeAddOp2(v, OP_Rowid, 0, memId + 1); - sqlite3VdbeJumpHere(v, j1); - sqlite3VdbeJumpHere(v, j5); - sqlite3VdbeAddOp3(v, OP_MakeRecord, memId - 1, 2, iRec); - sqlite3VdbeAddOp3(v, OP_Insert, 0, iRec, memId + 1); - sqlite3VdbeChangeP5(v, OPFLAG_APPEND); - sqlite3VdbeAddOp0(v, OP_Close); - sqlite3ReleaseTempReg(pParse, iRec); - } - } + /* + ** Update the maximum rowid for an autoincrement calculation. + ** + ** This routine should be called when the top of the stack holds a + ** new rowid that is about to be inserted. If that new rowid is + ** larger than the maximum rowid in the memId memory cell, then the + ** memory cell is updated. The stack is unchanged. + */ + static void autoIncStep( Parse pParse, int memId, int regRowid ) + { + if ( memId > 0 ) + { + sqlite3VdbeAddOp2( pParse.pVdbe, OP_MemMax, memId, regRowid ); + } + } + + /* + ** This routine generates the code needed to write autoincrement + ** maximum rowid values back into the sqlite_sequence register. + ** Every statement that might do an INSERT into an autoincrement + ** table (either directly or through triggers) needs to call this + ** routine just before the "exit" code. + */ + static void sqlite3AutoincrementEnd( Parse pParse ) + { + AutoincInfo p; + Vdbe v = pParse.pVdbe; + sqlite3 db = pParse.db; + + Debug.Assert( v != null ); + for ( p = pParse.pAinc; p != null; p = p.pNext ) + { + Db pDb = db.aDb[p.iDb]; + int j1, j2, j3, j4, j5; + int iRec; + int memId = p.regCtr; + + iRec = sqlite3GetTempReg( pParse ); + Debug.Assert( sqlite3SchemaMutexHeld( db, 0, pDb.pSchema ) ); + sqlite3OpenTable( pParse, 0, p.iDb, pDb.pSchema.pSeqTab, OP_OpenWrite ); + j1 = sqlite3VdbeAddOp1( v, OP_NotNull, memId + 1 ); + j2 = sqlite3VdbeAddOp0( v, OP_Rewind ); + j3 = sqlite3VdbeAddOp3( v, OP_Column, 0, 0, iRec ); + j4 = sqlite3VdbeAddOp3( v, OP_Eq, memId - 1, 0, iRec ); + sqlite3VdbeAddOp2( v, OP_Next, 0, j3 ); + sqlite3VdbeJumpHere( v, j2 ); + sqlite3VdbeAddOp2( v, OP_NewRowid, 0, memId + 1 ); + j5 = sqlite3VdbeAddOp0( v, OP_Goto ); + sqlite3VdbeJumpHere( v, j4 ); + sqlite3VdbeAddOp2( v, OP_Rowid, 0, memId + 1 ); + sqlite3VdbeJumpHere( v, j1 ); + sqlite3VdbeJumpHere( v, j5 ); + sqlite3VdbeAddOp3( v, OP_MakeRecord, memId - 1, 2, iRec ); + sqlite3VdbeAddOp3( v, OP_Insert, 0, iRec, memId + 1 ); + sqlite3VdbeChangeP5( v, OPFLAG_APPEND ); + sqlite3VdbeAddOp0( v, OP_Close ); + sqlite3ReleaseTempReg( pParse, iRec ); + } + } #else /* ** If SQLITE_OMIT_AUTOINCREMENT is defined, then the three routines @@ -338,195 +367,201 @@ static void sqlite3AutoincrementEnd(Parse pParse) { #endif // * SQLITE_OMIT_AUTOINCREMENT */ - /* Forward declaration */ - //static int xferOptimization( - // Parse pParse, /* Parser context */ - // Table pDest, /* The table we are inserting into */ - // Select pSelect, /* A SELECT statement to use as the data source */ - // int onError, /* How to handle constraint errors */ - // int iDbDest /* The database of pDest */ - //); + /* Forward declaration */ + //static int xferOptimization( + // Parse pParse, /* Parser context */ + // Table pDest, /* The table we are inserting into */ + // Select pSelect, /* A SELECT statement to use as the data source */ + // int onError, /* How to handle constraint errors */ + // int iDbDest /* The database of pDest */ + //); - /* - ** This routine is call to handle SQL of the following forms: - ** - ** insert into TABLE (IDLIST) values(EXPRLIST) - ** insert into TABLE (IDLIST) select - ** - ** The IDLIST following the table name is always optional. If omitted, - ** then a list of all columns for the table is substituted. The IDLIST - ** appears in the pColumn parameter. pColumn is NULL if IDLIST is omitted. - ** - ** The pList parameter holds EXPRLIST in the first form of the INSERT - ** statement above, and pSelect is NULL. For the second form, pList is - ** NULL and pSelect is a pointer to the select statement used to generate - ** data for the insert. - ** - ** The code generated follows one of four templates. For a simple - ** select with data coming from a VALUES clause, the code executes - ** once straight down through. Pseudo-code follows (we call this - ** the "1st template"): - ** - ** open write cursor to
and its indices - ** puts VALUES clause expressions onto the stack - ** write the resulting record into
- ** cleanup - ** - ** The three remaining templates assume the statement is of the form - ** - ** INSERT INTO
SELECT ... - ** - ** If the SELECT clause is of the restricted form "SELECT * FROM " - - ** in other words if the SELECT pulls all columns from a single table - ** and there is no WHERE or LIMIT or GROUP BY or ORDER BY clauses, and - ** if and are distinct tables but have identical - ** schemas, including all the same indices, then a special optimization - ** is invoked that copies raw records from over to . - ** See the xferOptimization() function for the implementation of this - ** template. This is the 2nd template. - ** - ** open a write cursor to
- ** open read cursor on - ** transfer all records in over to
- ** close cursors - ** foreach index on
- ** open a write cursor on the
index - ** open a read cursor on the corresponding index - ** transfer all records from the read to the write cursors - ** close cursors - ** end foreach - ** - ** The 3rd template is for when the second template does not apply - ** and the SELECT clause does not read from
at any time. - ** The generated code follows this template: - ** - ** EOF <- 0 - ** X <- A - ** goto B - ** A: setup for the SELECT - ** loop over the rows in the SELECT - ** load values into registers R..R+n - ** yield X - ** end loop - ** cleanup after the SELECT - ** EOF <- 1 - ** yield X - ** goto A - ** B: open write cursor to
and its indices - ** C: yield X - ** if EOF goto D - ** insert the select result into
from R..R+n - ** goto C - ** D: cleanup - ** - ** The 4th template is used if the insert statement takes its - ** values from a SELECT but the data is being inserted into a table - ** that is also read as part of the SELECT. In the third form, - ** we have to use a intermediate table to store the results of - ** the select. The template is like this: - ** - ** EOF <- 0 - ** X <- A - ** goto B - ** A: setup for the SELECT - ** loop over the tables in the SELECT - ** load value into register R..R+n - ** yield X - ** end loop - ** cleanup after the SELECT - ** EOF <- 1 - ** yield X - ** halt-error - ** B: open temp table - ** L: yield X - ** if EOF goto M - ** insert row from R..R+n into temp table - ** goto L - ** M: open write cursor to
and its indices - ** rewind temp table - ** C: loop over rows of intermediate table - ** transfer values form intermediate table into
- ** end loop - ** D: cleanup - */ - // OVERLOADS, so I don't need to rewrite parse.c - static void sqlite3Insert(Parse pParse, SrcList pTabList, int null_3, int null_4, IdList pColumn, int onError) { - sqlite3Insert(pParse, pTabList, null, null, pColumn, onError); - } - static void sqlite3Insert(Parse pParse, SrcList pTabList, int null_3, Select pSelect, IdList pColumn, int onError) { - sqlite3Insert(pParse, pTabList, null, pSelect, pColumn, onError); - } - static void sqlite3Insert(Parse pParse, SrcList pTabList, ExprList pList, int null_4, IdList pColumn, int onError) { - sqlite3Insert(pParse, pTabList, pList, null, pColumn, onError); - } - static void sqlite3Insert( - Parse pParse, /* Parser context */ - SrcList pTabList, /* Name of table into which we are inserting */ - ExprList pList, /* List of values to be inserted */ - Select pSelect, /* A SELECT statement to use as the data source */ - IdList pColumn, /* Column names corresponding to IDLIST. */ - int onError /* How to handle constraint errors */ - ) { - sqlite3 db; /* The main database structure */ - Table pTab; /* The table to insert into. aka TABLE */ - string zTab; /* Name of the table into which we are inserting */ - int i = 0; - int j = 0; - int idx = 0; /* Loop counters */ - Vdbe v; /* Generate code into this virtual machine */ - Index pIdx; /* For looping over indices of the table */ - int nColumn; /* Number of columns in the data */ - int nHidden = 0; /* Number of hidden columns if TABLE is virtual */ - int baseCur = 0; /* VDBE VdbeCursor number for pTab */ - int keyColumn = -1; /* Column that is the INTEGER PRIMARY KEY */ - int endOfLoop = 0; /* Label for the end of the insertion loop */ - bool useTempTable = false; /* Store SELECT results in intermediate table */ - int srcTab = 0; /* Data comes from this temporary cursor if >=0 */ - int addrInsTop = 0; /* Jump to label "D" */ - int addrCont = 0; /* Top of insert loop. Label "C" in templates 3 and 4 */ - int addrSelect = 0; /* Address of coroutine that implements the SELECT */ - SelectDest dest; /* Destination for SELECT on rhs of INSERT */ - int iDb; /* Index of database holding TABLE */ - Db pDb; /* The database containing table being inserted into */ - bool appendFlag = false; /* True if the insert is likely to be an append */ - - /* Register allocations */ - int regFromSelect = 0; /* Base register for data coming from SELECT */ - int regAutoinc = 0; /* Register holding the AUTOINCREMENT counter */ - int regRowCount = 0; /* Memory cell used for the row counter */ - int regIns; /* Block of regs holding rowid+data being inserted */ - int regRowid; /* registers holding insert rowid */ - int regData; /* register holding first column to insert */ - int regEof = 0; /* Register recording end of SELECT data */ - int[] aRegIdx = null; /* One register allocated to each index */ + /* + ** This routine is call to handle SQL of the following forms: + ** + ** insert into TABLE (IDLIST) values(EXPRLIST) + ** insert into TABLE (IDLIST) select + ** + ** The IDLIST following the table name is always optional. If omitted, + ** then a list of all columns for the table is substituted. The IDLIST + ** appears in the pColumn parameter. pColumn is NULL if IDLIST is omitted. + ** + ** The pList parameter holds EXPRLIST in the first form of the INSERT + ** statement above, and pSelect is NULL. For the second form, pList is + ** NULL and pSelect is a pointer to the select statement used to generate + ** data for the insert. + ** + ** The code generated follows one of four templates. For a simple + ** select with data coming from a VALUES clause, the code executes + ** once straight down through. Pseudo-code follows (we call this + ** the "1st template"): + ** + ** open write cursor to
and its indices + ** puts VALUES clause expressions onto the stack + ** write the resulting record into
+ ** cleanup + ** + ** The three remaining templates assume the statement is of the form + ** + ** INSERT INTO
SELECT ... + ** + ** If the SELECT clause is of the restricted form "SELECT * FROM " - + ** in other words if the SELECT pulls all columns from a single table + ** and there is no WHERE or LIMIT or GROUP BY or ORDER BY clauses, and + ** if and are distinct tables but have identical + ** schemas, including all the same indices, then a special optimization + ** is invoked that copies raw records from over to . + ** See the xferOptimization() function for the implementation of this + ** template. This is the 2nd template. + ** + ** open a write cursor to
+ ** open read cursor on + ** transfer all records in over to
+ ** close cursors + ** foreach index on
+ ** open a write cursor on the
index + ** open a read cursor on the corresponding index + ** transfer all records from the read to the write cursors + ** close cursors + ** end foreach + ** + ** The 3rd template is for when the second template does not apply + ** and the SELECT clause does not read from
at any time. + ** The generated code follows this template: + ** + ** EOF <- 0 + ** X <- A + ** goto B + ** A: setup for the SELECT + ** loop over the rows in the SELECT + ** load values into registers R..R+n + ** yield X + ** end loop + ** cleanup after the SELECT + ** EOF <- 1 + ** yield X + ** goto A + ** B: open write cursor to
and its indices + ** C: yield X + ** if EOF goto D + ** insert the select result into
from R..R+n + ** goto C + ** D: cleanup + ** + ** The 4th template is used if the insert statement takes its + ** values from a SELECT but the data is being inserted into a table + ** that is also read as part of the SELECT. In the third form, + ** we have to use a intermediate table to store the results of + ** the select. The template is like this: + ** + ** EOF <- 0 + ** X <- A + ** goto B + ** A: setup for the SELECT + ** loop over the tables in the SELECT + ** load value into register R..R+n + ** yield X + ** end loop + ** cleanup after the SELECT + ** EOF <- 1 + ** yield X + ** halt-error + ** B: open temp table + ** L: yield X + ** if EOF goto M + ** insert row from R..R+n into temp table + ** goto L + ** M: open write cursor to
and its indices + ** rewind temp table + ** C: loop over rows of intermediate table + ** transfer values form intermediate table into
+ ** end loop + ** D: cleanup + */ + // OVERLOADS, so I don't need to rewrite parse.c + static void sqlite3Insert( Parse pParse, SrcList pTabList, int null_3, int null_4, IdList pColumn, int onError ) + { + sqlite3Insert( pParse, pTabList, null, null, pColumn, onError ); + } + static void sqlite3Insert( Parse pParse, SrcList pTabList, int null_3, Select pSelect, IdList pColumn, int onError ) + { + sqlite3Insert( pParse, pTabList, null, pSelect, pColumn, onError ); + } + static void sqlite3Insert( Parse pParse, SrcList pTabList, ExprList pList, int null_4, IdList pColumn, int onError ) + { + sqlite3Insert( pParse, pTabList, pList, null, pColumn, onError ); + } + static void sqlite3Insert( + Parse pParse, /* Parser context */ + SrcList pTabList, /* Name of table into which we are inserting */ + ExprList pList, /* List of values to be inserted */ + Select pSelect, /* A SELECT statement to use as the data source */ + IdList pColumn, /* Column names corresponding to IDLIST. */ + int onError /* How to handle constraint errors */ + ) + { + sqlite3 db; /* The main database structure */ + Table pTab; /* The table to insert into. aka TABLE */ + string zTab; /* Name of the table into which we are inserting */ + int i = 0; + int j = 0; + int idx = 0; /* Loop counters */ + Vdbe v; /* Generate code into this virtual machine */ + Index pIdx; /* For looping over indices of the table */ + int nColumn; /* Number of columns in the data */ + int nHidden = 0; /* Number of hidden columns if TABLE is virtual */ + int baseCur = 0; /* VDBE VdbeCursor number for pTab */ + int keyColumn = -1; /* Column that is the INTEGER PRIMARY KEY */ + int endOfLoop = 0; /* Label for the end of the insertion loop */ + bool useTempTable = false; /* Store SELECT results in intermediate table */ + int srcTab = 0; /* Data comes from this temporary cursor if >=0 */ + int addrInsTop = 0; /* Jump to label "D" */ + int addrCont = 0; /* Top of insert loop. Label "C" in templates 3 and 4 */ + int addrSelect = 0; /* Address of coroutine that implements the SELECT */ + SelectDest dest; /* Destination for SELECT on rhs of INSERT */ + int iDb; /* Index of database holding TABLE */ + Db pDb; /* The database containing table being inserted into */ + bool appendFlag = false; /* True if the insert is likely to be an append */ + + /* Register allocations */ + int regFromSelect = 0; /* Base register for data coming from SELECT */ + int regAutoinc = 0; /* Register holding the AUTOINCREMENT counter */ + int regRowCount = 0; /* Memory cell used for the row counter */ + int regIns; /* Block of regs holding rowid+data being inserted */ + int regRowid; /* registers holding insert rowid */ + int regData; /* register holding first column to insert */ + int regEof = 0; /* Register recording end of SELECT data */ + int[] aRegIdx = null; /* One register allocated to each index */ #if !SQLITE_OMIT_TRIGGER - bool isView = false; /* True if attempting to insert into a view */ - Trigger pTrigger; /* List of triggers on pTab, if required */ - int tmask = 0; /* Mask of trigger times */ + bool isView = false; /* True if attempting to insert into a view */ + Trigger pTrigger; /* List of triggers on pTab, if required */ + int tmask = 0; /* Mask of trigger times */ #endif - db = pParse.db; - dest = new SelectDest();// memset( &dest, 0, sizeof( dest ) ); + db = pParse.db; + dest = new SelectDest();// memset( &dest, 0, sizeof( dest ) ); - if (pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) { - goto insert_cleanup; - } + if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) + { + goto insert_cleanup; + } - /* Locate the table into which we will be inserting new information. - */ - Debug.Assert(pTabList.nSrc == 1); - zTab = pTabList.a[0].zName; - if (NEVER(zTab == null)) - goto insert_cleanup; - pTab = sqlite3SrcListLookup(pParse, pTabList); - if (pTab == null) { - goto insert_cleanup; - } - iDb = sqlite3SchemaToIndex(db, pTab.pSchema); - Debug.Assert(iDb < db.nDb); - pDb = db.aDb[iDb]; + /* Locate the table into which we will be inserting new information. + */ + Debug.Assert( pTabList.nSrc == 1 ); + zTab = pTabList.a[0].zName; + if ( NEVER( zTab == null ) ) + goto insert_cleanup; + pTab = sqlite3SrcListLookup( pParse, pTabList ); + if ( pTab == null ) + { + goto insert_cleanup; + } + iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); + Debug.Assert( iDb < db.nDb ); + pDb = db.aDb[iDb]; #if !SQLITE_OMIT_AUTHORIZATION string zDb; /* Name of the database holding this table */ zDb = pDb.zName; @@ -534,1053 +569,1209 @@ int onError /* How to handle constraint errors */ goto insert_cleanup; } #endif - /* Figure out if we have any triggers and if the table being - ** inserted into is a view - */ + /* Figure out if we have any triggers and if the table being +** inserted into is a view +*/ #if !SQLITE_OMIT_TRIGGER - pTrigger = sqlite3TriggersExist(pParse, pTab, TK_INSERT, null, out tmask); - isView = pTab.pSelect != null; + pTrigger = sqlite3TriggersExist( pParse, pTab, TK_INSERT, null, out tmask ); + isView = pTab.pSelect != null; #else Trigger pTrigger = null; //# define pTrigger 0 int tmask = 0; //# define tmask 0 bool isView = false; #endif -#if SQLITE_OMIT_VIEW +#if SQLITE_OMIT_VIEW //# undef isView isView = false; #endif #if !SQLITE_OMIT_TRIGGER - Debug.Assert((pTrigger != null && tmask != 0) || (pTrigger == null && tmask == 0)); + Debug.Assert( ( pTrigger != null && tmask != 0 ) || ( pTrigger == null && tmask == 0 ) ); #endif #if !SQLITE_OMIT_VIEW - /* If pTab is really a view, make sure it has been initialized. - ** ViewGetColumnNames() is a no-op if pTab is not a view (or virtual - ** module table). - */ - if (sqlite3ViewGetColumnNames(pParse, pTab) != -0) { - goto insert_cleanup; - } + /* If pTab is really a view, make sure it has been initialized. + ** ViewGetColumnNames() is a no-op if pTab is not a view (or virtual + ** module table). + */ + if ( sqlite3ViewGetColumnNames( pParse, pTab ) != -0 ) + { + goto insert_cleanup; + } #endif - /* Ensure that: - * (a) the table is not read-only, - * (b) that if it is a view then ON INSERT triggers exist - */ - if (sqlite3IsReadOnly(pParse, pTab, tmask)) { - goto insert_cleanup; - } + /* Ensure that: + * (a) the table is not read-only, + * (b) that if it is a view then ON INSERT triggers exist + */ + if ( sqlite3IsReadOnly( pParse, pTab, tmask ) ) + { + goto insert_cleanup; + } - /* Allocate a VDBE - */ - v = sqlite3GetVdbe(pParse); - if (v == null) - goto insert_cleanup; - if (pParse.nested == 0) - sqlite3VdbeCountChanges(v); - sqlite3BeginWriteOperation(pParse, (pSelect != null || pTrigger != null) ? 1 : 0, iDb); + /* Allocate a VDBE + */ + v = sqlite3GetVdbe( pParse ); + if ( v == null ) + goto insert_cleanup; + if ( pParse.nested == 0 ) + sqlite3VdbeCountChanges( v ); + sqlite3BeginWriteOperation( pParse, ( pSelect != null || pTrigger != null ) ? 1 : 0, iDb ); #if !SQLITE_OMIT_XFER_OPT - /* If the statement is of the form - ** - ** INSERT INTO SELECT * FROM ; - ** - ** Then special optimizations can be applied that make the transfer - ** very fast and which reduce fragmentation of indices. - ** - ** This is the 2nd template. - */ - if (pColumn == null && xferOptimization(pParse, pTab, pSelect, onError, iDb) != 0) { - Debug.Assert(null == pTrigger); - Debug.Assert(pList == null); - goto insert_end; - } + /* If the statement is of the form +** +** INSERT INTO SELECT * FROM ; +** +** Then special optimizations can be applied that make the transfer +** very fast and which reduce fragmentation of indices. +** +** This is the 2nd template. +*/ + if ( pColumn == null && xferOptimization( pParse, pTab, pSelect, onError, iDb ) != 0 ) + { + Debug.Assert( null == pTrigger ); + Debug.Assert( pList == null ); + goto insert_end; + } #endif // * SQLITE_OMIT_XFER_OPT */ - /* If this is an AUTOINCREMENT table, look up the sequence number in the - ** sqlite_sequence table and store it in memory cell regAutoinc. + /* If this is an AUTOINCREMENT table, look up the sequence number in the +** sqlite_sequence table and store it in memory cell regAutoinc. +*/ + regAutoinc = autoIncBegin( pParse, iDb, pTab ); + + /* Figure out how many columns of data are supplied. If the data + ** is coming from a SELECT statement, then generate a co-routine that + ** produces a single row of the SELECT on each invocation. The + ** co-routine is the common header to the 3rd and 4th templates. */ - regAutoinc = autoIncBegin(pParse, iDb, pTab); - - /* Figure out how many columns of data are supplied. If the data - ** is coming from a SELECT statement, then generate a co-routine that - ** produces a single row of the SELECT on each invocation. The - ** co-routine is the common header to the 3rd and 4th templates. - */ - if (pSelect != null) { - /* Data is coming from a SELECT. Generate code to implement that SELECT - ** as a co-routine. The code is common to both the 3rd and 4th - ** templates: - ** - ** EOF <- 0 - ** X <- A - ** goto B - ** A: setup for the SELECT - ** loop over the tables in the SELECT - ** load value into register R..R+n - ** yield X - ** end loop - ** cleanup after the SELECT - ** EOF <- 1 - ** yield X - ** halt-error - ** - ** On each invocation of the co-routine, it puts a single row of the - ** SELECT result into registers dest.iMem...dest.iMem+dest.nMem-1. - ** (These output registers are allocated by sqlite3Select().) When - ** the SELECT completes, it sets the EOF flag stored in regEof. - */ - int rc = 0, j1; - - regEof = ++pParse.nMem; - sqlite3VdbeAddOp2(v, OP_Integer, 0, regEof); /* EOF <- 0 */ + if ( pSelect != null ) + { + /* Data is coming from a SELECT. Generate code to implement that SELECT + ** as a co-routine. The code is common to both the 3rd and 4th + ** templates: + ** + ** EOF <- 0 + ** X <- A + ** goto B + ** A: setup for the SELECT + ** loop over the tables in the SELECT + ** load value into register R..R+n + ** yield X + ** end loop + ** cleanup after the SELECT + ** EOF <- 1 + ** yield X + ** halt-error + ** + ** On each invocation of the co-routine, it puts a single row of the + ** SELECT result into registers dest.iMem...dest.iMem+dest.nMem-1. + ** (These output registers are allocated by sqlite3Select().) When + ** the SELECT completes, it sets the EOF flag stored in regEof. + */ + int rc = 0, j1; + + regEof = ++pParse.nMem; + sqlite3VdbeAddOp2( v, OP_Integer, 0, regEof ); /* EOF <- 0 */ #if SQLITE_DEBUG - VdbeComment(v, "SELECT eof flag"); + VdbeComment( v, "SELECT eof flag" ); #endif - sqlite3SelectDestInit(dest, SRT_Coroutine, ++pParse.nMem); - addrSelect = sqlite3VdbeCurrentAddr(v) + 2; - sqlite3VdbeAddOp2(v, OP_Integer, addrSelect - 1, dest.iParm); - j1 = sqlite3VdbeAddOp2(v, OP_Goto, 0, 0); + sqlite3SelectDestInit( dest, SRT_Coroutine, ++pParse.nMem ); + addrSelect = sqlite3VdbeCurrentAddr( v ) + 2; + sqlite3VdbeAddOp2( v, OP_Integer, addrSelect - 1, dest.iParm ); + j1 = sqlite3VdbeAddOp2( v, OP_Goto, 0, 0 ); #if SQLITE_DEBUG - VdbeComment(v, "Jump over SELECT coroutine"); + VdbeComment( v, "Jump over SELECT coroutine" ); #endif - /* Resolve the expressions in the SELECT statement and execute it. */ - rc = sqlite3Select(pParse, pSelect, ref dest); - Debug.Assert(pParse.nErr == 0 || rc != 0); - if (rc != 0 || NEVER(pParse.nErr != 0) /*|| db.mallocFailed != 0 */ ) { - goto insert_cleanup; - } - sqlite3VdbeAddOp2(v, OP_Integer, 1, regEof); /* EOF <- 1 */ - sqlite3VdbeAddOp1(v, OP_Yield, dest.iParm); /* yield X */ - sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_INTERNAL, OE_Abort); + /* Resolve the expressions in the SELECT statement and execute it. */ + rc = sqlite3Select( pParse, pSelect, ref dest ); + Debug.Assert( pParse.nErr == 0 || rc != 0 ); + if ( rc != 0 || NEVER( pParse.nErr != 0 ) /*|| db.mallocFailed != 0 */ ) + { + goto insert_cleanup; + } + sqlite3VdbeAddOp2( v, OP_Integer, 1, regEof ); /* EOF <- 1 */ + sqlite3VdbeAddOp1( v, OP_Yield, dest.iParm ); /* yield X */ + sqlite3VdbeAddOp2( v, OP_Halt, SQLITE_INTERNAL, OE_Abort ); #if SQLITE_DEBUG - VdbeComment(v, "End of SELECT coroutine"); + VdbeComment( v, "End of SELECT coroutine" ); #endif - sqlite3VdbeJumpHere(v, j1); /* label B: */ - - regFromSelect = dest.iMem; - Debug.Assert(pSelect.pEList != null); - nColumn = pSelect.pEList.nExpr; - Debug.Assert(dest.nMem == nColumn); - - /* Set useTempTable to TRUE if the result of the SELECT statement - ** should be written into a temporary table (template 4). Set to - ** FALSE if each* row of the SELECT can be written directly into - ** the destination table (template 3). - ** - ** A temp table must be used if the table being updated is also one - ** of the tables being read by the SELECT statement. Also use a - ** temp table in the case of row triggers. - */ - if (pTrigger != null || readsTable(pParse, addrSelect, iDb, pTab)) { - useTempTable = true; - } + sqlite3VdbeJumpHere( v, j1 ); /* label B: */ - if (useTempTable) { - /* Invoke the coroutine to extract information from the SELECT - ** and add it to a transient table srcTab. The code generated - ** here is from the 4th template: - ** - ** B: open temp table - ** L: yield X - ** if EOF goto M - ** insert row from R..R+n into temp table - ** goto L - ** M: ... - */ - int regRec; /* Register to hold packed record */ - int regTempRowid; /* Register to hold temp table ROWID */ - int addrTop; /* Label "L" */ - int addrIf; /* Address of jump to M */ - - srcTab = pParse.nTab++; - regRec = sqlite3GetTempReg(pParse); - regTempRowid = sqlite3GetTempReg(pParse); - sqlite3VdbeAddOp2(v, OP_OpenEphemeral, srcTab, nColumn); - addrTop = sqlite3VdbeAddOp1(v, OP_Yield, dest.iParm); - addrIf = sqlite3VdbeAddOp1(v, OP_If, regEof); - sqlite3VdbeAddOp3(v, OP_MakeRecord, regFromSelect, nColumn, regRec); - sqlite3VdbeAddOp2(v, OP_NewRowid, srcTab, regTempRowid); - sqlite3VdbeAddOp3(v, OP_Insert, srcTab, regRec, regTempRowid); - sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop); - sqlite3VdbeJumpHere(v, addrIf); - sqlite3ReleaseTempReg(pParse, regRec); - sqlite3ReleaseTempReg(pParse, regTempRowid); - } - } else { - /* This is the case if the data for the INSERT is coming from a VALUES - ** clause - */ - NameContext sNC; - sNC = new NameContext();// memset( &sNC, 0, sNC ).Length; - sNC.pParse = pParse; - srcTab = -1; - Debug.Assert(!useTempTable); - nColumn = pList != null ? pList.nExpr : 0; - for (i = 0; i < nColumn; i++) { - if (sqlite3ResolveExprNames(sNC, ref pList.a[i].pExpr) != 0) { - goto insert_cleanup; - } - } - } + regFromSelect = dest.iMem; + Debug.Assert( pSelect.pEList != null ); + nColumn = pSelect.pEList.nExpr; + Debug.Assert( dest.nMem == nColumn ); - /* Make sure the number of columns in the source data matches the number - ** of columns to be inserted into the table. - */ - if (IsVirtual(pTab)) { - for (i = 0; i < pTab.nCol; i++) { - nHidden += (IsHiddenColumn(pTab.aCol[i]) ? 1 : 0); - } - } - if (pColumn == null && nColumn != 0 && nColumn != (pTab.nCol - nHidden)) { - sqlite3ErrorMsg(pParse, - "table %S has %d columns but %d values were supplied", - pTabList, 0, pTab.nCol - nHidden, nColumn); - goto insert_cleanup; - } - if (pColumn != null && nColumn != pColumn.nId) { - sqlite3ErrorMsg(pParse, "%d values for %d columns", nColumn, pColumn.nId); - goto insert_cleanup; - } + /* Set useTempTable to TRUE if the result of the SELECT statement + ** should be written into a temporary table (template 4). Set to + ** FALSE if each* row of the SELECT can be written directly into + ** the destination table (template 3). + ** + ** A temp table must be used if the table being updated is also one + ** of the tables being read by the SELECT statement. Also use a + ** temp table in the case of row triggers. + */ + if ( pTrigger != null || readsTable( pParse, addrSelect, iDb, pTab ) ) + { + useTempTable = true; + } - /* If the INSERT statement included an IDLIST term, then make sure - ** all elements of the IDLIST really are columns of the table and - ** remember the column indices. - ** - ** If the table has an INTEGER PRIMARY KEY column and that column - ** is named in the IDLIST, then record in the keyColumn variable - ** the index into IDLIST of the primary key column. keyColumn is - ** the index of the primary key as it appears in IDLIST, not as - ** is appears in the original table. (The index of the primary - ** key in the original table is pTab.iPKey.) - */ - if (pColumn != null) { - for (i = 0; i < pColumn.nId; i++) { - pColumn.a[i].idx = -1; - } - for (i = 0; i < pColumn.nId; i++) { - for (j = 0; j < pTab.nCol; j++) { - if (pColumn.a[i].zName.Equals(pTab.aCol[j].zName, StringComparison.OrdinalIgnoreCase)) { - pColumn.a[i].idx = j; - if (j == pTab.iPKey) { - keyColumn = i; - } - break; - } - } - if (j >= pTab.nCol) { - if (sqlite3IsRowid(pColumn.a[i].zName)) { - keyColumn = i; - } else { - sqlite3ErrorMsg(pParse, "table %S has no column named %s", - pTabList, 0, pColumn.a[i].zName); - pParse.checkSchema = 1; - goto insert_cleanup; - } - } - } - } + if ( useTempTable ) + { + /* Invoke the coroutine to extract information from the SELECT + ** and add it to a transient table srcTab. The code generated + ** here is from the 4th template: + ** + ** B: open temp table + ** L: yield X + ** if EOF goto M + ** insert row from R..R+n into temp table + ** goto L + ** M: ... + */ + int regRec; /* Register to hold packed record */ + int regTempRowid; /* Register to hold temp table ROWID */ + int addrTop; /* Label "L" */ + int addrIf; /* Address of jump to M */ + + srcTab = pParse.nTab++; + regRec = sqlite3GetTempReg( pParse ); + regTempRowid = sqlite3GetTempReg( pParse ); + sqlite3VdbeAddOp2( v, OP_OpenEphemeral, srcTab, nColumn ); + addrTop = sqlite3VdbeAddOp1( v, OP_Yield, dest.iParm ); + addrIf = sqlite3VdbeAddOp1( v, OP_If, regEof ); + sqlite3VdbeAddOp3( v, OP_MakeRecord, regFromSelect, nColumn, regRec ); + sqlite3VdbeAddOp2( v, OP_NewRowid, srcTab, regTempRowid ); + sqlite3VdbeAddOp3( v, OP_Insert, srcTab, regRec, regTempRowid ); + sqlite3VdbeAddOp2( v, OP_Goto, 0, addrTop ); + sqlite3VdbeJumpHere( v, addrIf ); + sqlite3ReleaseTempReg( pParse, regRec ); + sqlite3ReleaseTempReg( pParse, regTempRowid ); + } + } + else + { + /* This is the case if the data for the INSERT is coming from a VALUES + ** clause + */ + NameContext sNC; + sNC = new NameContext();// memset( &sNC, 0, sNC ).Length; + sNC.pParse = pParse; + srcTab = -1; + Debug.Assert( !useTempTable ); + nColumn = pList != null ? pList.nExpr : 0; + for ( i = 0; i < nColumn; i++ ) + { + if ( sqlite3ResolveExprNames( sNC, ref pList.a[i].pExpr ) != 0 ) + { + goto insert_cleanup; + } + } + } - /* If there is no IDLIST term but the table has an integer primary - ** key, the set the keyColumn variable to the primary key column index - ** in the original table definition. - */ - if (pColumn == null && nColumn > 0) { - keyColumn = pTab.iPKey; - } + /* Make sure the number of columns in the source data matches the number + ** of columns to be inserted into the table. + */ + if ( IsVirtual( pTab ) ) + { + for ( i = 0; i < pTab.nCol; i++ ) + { + nHidden += ( IsHiddenColumn( pTab.aCol[i] ) ? 1 : 0 ); + } + } + if ( pColumn == null && nColumn != 0 && nColumn != ( pTab.nCol - nHidden ) ) + { + sqlite3ErrorMsg( pParse, + "table %S has %d columns but %d values were supplied", + pTabList, 0, pTab.nCol - nHidden, nColumn ); + goto insert_cleanup; + } + if ( pColumn != null && nColumn != pColumn.nId ) + { + sqlite3ErrorMsg( pParse, "%d values for %d columns", nColumn, pColumn.nId ); + goto insert_cleanup; + } - /* Initialize the count of rows to be inserted - */ - if ((db.flags & SQLITE_CountRows) != 0) { - regRowCount = ++pParse.nMem; - sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount); + /* If the INSERT statement included an IDLIST term, then make sure + ** all elements of the IDLIST really are columns of the table and + ** remember the column indices. + ** + ** If the table has an INTEGER PRIMARY KEY column and that column + ** is named in the IDLIST, then record in the keyColumn variable + ** the index into IDLIST of the primary key column. keyColumn is + ** the index of the primary key as it appears in IDLIST, not as + ** is appears in the original table. (The index of the primary + ** key in the original table is pTab.iPKey.) + */ + if ( pColumn != null ) + { + for ( i = 0; i < pColumn.nId; i++ ) + { + pColumn.a[i].idx = -1; + } + for ( i = 0; i < pColumn.nId; i++ ) + { + for ( j = 0; j < pTab.nCol; j++ ) + { + if ( pColumn.a[i].zName.Equals( pTab.aCol[j].zName ,StringComparison.OrdinalIgnoreCase ) ) + { + pColumn.a[i].idx = j; + if ( j == pTab.iPKey ) + { + keyColumn = i; + } + break; + } + } + if ( j >= pTab.nCol ) + { + if ( sqlite3IsRowid( pColumn.a[i].zName ) ) + { + keyColumn = i; } - - /* If this is not a view, open the table and and all indices */ - if (!isView) { - int nIdx; - - baseCur = pParse.nTab; - nIdx = sqlite3OpenTableAndIndices(pParse, pTab, baseCur, OP_OpenWrite); - aRegIdx = new int[nIdx + 1];// sqlite3DbMallocRaw( db, sizeof( int ) * ( nIdx + 1 ) ); - if (aRegIdx == null) { - goto insert_cleanup; - } - for (i = 0; i < nIdx; i++) { - aRegIdx[i] = ++pParse.nMem; - } + else + { + sqlite3ErrorMsg( pParse, "table %S has no column named %s", + pTabList, 0, pColumn.a[i].zName ); + pParse.checkSchema = 1; + goto insert_cleanup; } + } + } + } - /* This is the top of the main insertion loop */ - if (useTempTable) { - /* This block codes the top of loop only. The complete loop is the - ** following pseudocode (template 4): - ** - ** rewind temp table - ** C: loop over rows of intermediate table - ** transfer values form intermediate table into
- ** end loop - ** D: ... - */ - addrInsTop = sqlite3VdbeAddOp1(v, OP_Rewind, srcTab); - addrCont = sqlite3VdbeCurrentAddr(v); - } else if (pSelect != null) { - /* This block codes the top of loop only. The complete loop is the - ** following pseudocode (template 3): - ** - ** C: yield X - ** if EOF goto D - ** insert the select result into
from R..R+n - ** goto C - ** D: ... - */ - addrCont = sqlite3VdbeAddOp1(v, OP_Yield, dest.iParm); - addrInsTop = sqlite3VdbeAddOp1(v, OP_If, regEof); - } + /* If there is no IDLIST term but the table has an integer primary + ** key, the set the keyColumn variable to the primary key column index + ** in the original table definition. + */ + if ( pColumn == null && nColumn > 0 ) + { + keyColumn = pTab.iPKey; + } - /* Allocate registers for holding the rowid of the new row, - ** the content of the new row, and the assemblied row record. - */ - regRowid = regIns = pParse.nMem + 1; - pParse.nMem += pTab.nCol + 1; - if (IsVirtual(pTab)) { - regRowid++; - pParse.nMem++; - } - regData = regRowid + 1; + /* Initialize the count of rows to be inserted + */ + if ( ( db.flags & SQLITE_CountRows ) != 0 ) + { + regRowCount = ++pParse.nMem; + sqlite3VdbeAddOp2( v, OP_Integer, 0, regRowCount ); + } - /* Run the BEFORE and INSTEAD OF triggers, if there are any - */ - endOfLoop = sqlite3VdbeMakeLabel(v); -#if !SQLITE_OMIT_TRIGGER - if ((tmask & TRIGGER_BEFORE) != 0) { - int regCols = sqlite3GetTempRange(pParse, pTab.nCol + 1); - - /* build the NEW.* reference row. Note that if there is an INTEGER - ** PRIMARY KEY into which a NULL is being inserted, that NULL will be - ** translated into a unique ID for the row. But on a BEFORE trigger, - ** we do not know what the unique ID will be (because the insert has - ** not happened yet) so we substitute a rowid of -1 - */ - if (keyColumn < 0) { - sqlite3VdbeAddOp2(v, OP_Integer, -1, regCols); - } else { - int j1; - if (useTempTable) { - sqlite3VdbeAddOp3(v, OP_Column, srcTab, keyColumn, regCols); - } else { - Debug.Assert(pSelect == null); /* Otherwise useTempTable is true */ - sqlite3ExprCode(pParse, pList.a[keyColumn].pExpr, regCols); - } - j1 = sqlite3VdbeAddOp1(v, OP_NotNull, regCols); - sqlite3VdbeAddOp2(v, OP_Integer, -1, regCols); - sqlite3VdbeJumpHere(v, j1); - sqlite3VdbeAddOp1(v, OP_MustBeInt, regCols); - } - /* Cannot have triggers on a virtual table. If it were possible, - ** this block would have to account for hidden column. - */ - Debug.Assert(!IsVirtual(pTab)); - /* Create the new column data - */ - for (i = 0; i < pTab.nCol; i++) { - if (pColumn == null) { - j = i; - } else { - for (j = 0; j < pColumn.nId; j++) { - if (pColumn.a[j].idx == i) - break; - } - } - if ((!useTempTable && null == pList) || (pColumn != null && j >= pColumn.nId)) { - sqlite3ExprCode(pParse, pTab.aCol[i].pDflt, regCols + i + 1); - } else if (useTempTable) { - sqlite3VdbeAddOp3(v, OP_Column, srcTab, j, regCols + i + 1); - } else { - Debug.Assert(pSelect == null); /* Otherwise useTempTable is true */ - sqlite3ExprCodeAndCache(pParse, pList.a[j].pExpr, regCols + i + 1); - } - } + /* If this is not a view, open the table and and all indices */ + if ( !isView ) + { + int nIdx; + + baseCur = pParse.nTab; + nIdx = sqlite3OpenTableAndIndices( pParse, pTab, baseCur, OP_OpenWrite ); + aRegIdx = new int[nIdx + 1];// sqlite3DbMallocRaw( db, sizeof( int ) * ( nIdx + 1 ) ); + if ( aRegIdx == null ) + { + goto insert_cleanup; + } + for ( i = 0; i < nIdx; i++ ) + { + aRegIdx[i] = ++pParse.nMem; + } + } - /* If this is an INSERT on a view with an INSTEAD OF INSERT trigger, - ** do not attempt any conversions before assembling the record. - ** If this is a real table, attempt conversions as required by the - ** table column affinities. - */ - if (!isView) { - sqlite3VdbeAddOp2(v, OP_Affinity, regCols + 1, pTab.nCol); - sqlite3TableAffinityStr(v, pTab); - } - - /* Fire BEFORE or INSTEAD OF triggers */ - sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, null, TRIGGER_BEFORE, - pTab, regCols - pTab.nCol - 1, onError, endOfLoop); + /* This is the top of the main insertion loop */ + if ( useTempTable ) + { + /* This block codes the top of loop only. The complete loop is the + ** following pseudocode (template 4): + ** + ** rewind temp table + ** C: loop over rows of intermediate table + ** transfer values form intermediate table into
+ ** end loop + ** D: ... + */ + addrInsTop = sqlite3VdbeAddOp1( v, OP_Rewind, srcTab ); + addrCont = sqlite3VdbeCurrentAddr( v ); + } + else if ( pSelect != null ) + { + /* This block codes the top of loop only. The complete loop is the + ** following pseudocode (template 3): + ** + ** C: yield X + ** if EOF goto D + ** insert the select result into
from R..R+n + ** goto C + ** D: ... + */ + addrCont = sqlite3VdbeAddOp1( v, OP_Yield, dest.iParm ); + addrInsTop = sqlite3VdbeAddOp1( v, OP_If, regEof ); + } - sqlite3ReleaseTempRange(pParse, regCols, pTab.nCol + 1); - } -#endif + /* Allocate registers for holding the rowid of the new row, + ** the content of the new row, and the assemblied row record. + */ + regRowid = regIns = pParse.nMem + 1; + pParse.nMem += pTab.nCol + 1; + if ( IsVirtual( pTab ) ) + { + regRowid++; + pParse.nMem++; + } + regData = regRowid + 1; - /* Push the record number for the new entry onto the stack. The - ** record number is a randomly generate integer created by NewRowid - ** except when the table has an INTEGER PRIMARY KEY column, in which - ** case the record number is the same as that column. + /* Run the BEFORE and INSTEAD OF triggers, if there are any */ - if (!isView) { - if (IsVirtual(pTab)) { - /* The row that the VUpdate opcode will delete: none */ - sqlite3VdbeAddOp2(v, OP_Null, 0, regIns); - } - if (keyColumn >= 0) { - if (useTempTable) { - sqlite3VdbeAddOp3(v, OP_Column, srcTab, keyColumn, regRowid); - } else if (pSelect != null) { - sqlite3VdbeAddOp2(v, OP_SCopy, regFromSelect + keyColumn, regRowid); - } else { - VdbeOp pOp; - sqlite3ExprCode(pParse, pList.a[keyColumn].pExpr, regRowid); - pOp = sqlite3VdbeGetOp(v, -1); - if (ALWAYS(pOp != null) && pOp.opcode == OP_Null && !IsVirtual(pTab)) { - appendFlag = true; - pOp.opcode = OP_NewRowid; - pOp.p1 = baseCur; - pOp.p2 = regRowid; - pOp.p3 = regAutoinc; - } - } - /* If the PRIMARY KEY expression is NULL, then use OP_NewRowid - ** to generate a unique primary key value. - */ - if (!appendFlag) { - int j1; - if (!IsVirtual(pTab)) { - j1 = sqlite3VdbeAddOp1(v, OP_NotNull, regRowid); - sqlite3VdbeAddOp3(v, OP_NewRowid, baseCur, regRowid, regAutoinc); - sqlite3VdbeJumpHere(v, j1); - } else { - j1 = sqlite3VdbeCurrentAddr(v); - sqlite3VdbeAddOp2(v, OP_IsNull, regRowid, j1 + 2); - } - sqlite3VdbeAddOp1(v, OP_MustBeInt, regRowid); - } - } else if (IsVirtual(pTab)) { - sqlite3VdbeAddOp2(v, OP_Null, 0, regRowid); - } else { - sqlite3VdbeAddOp3(v, OP_NewRowid, baseCur, regRowid, regAutoinc); - appendFlag = true; - } - autoIncStep(pParse, regAutoinc, regRowid); - - /* Push onto the stack, data for all columns of the new entry, beginning - ** with the first column. - */ - nHidden = 0; - for (i = 0; i < pTab.nCol; i++) { - int iRegStore = regRowid + 1 + i; - if (i == pTab.iPKey) { - /* The value of the INTEGER PRIMARY KEY column is always a NULL. - ** Whenever this column is read, the record number will be substituted - ** in its place. So will fill this column with a NULL to avoid - ** taking up data space with information that will never be used. */ - sqlite3VdbeAddOp2(v, OP_Null, 0, iRegStore); - continue; - } - if (pColumn == null) { - if (IsHiddenColumn(pTab.aCol[i])) { - Debug.Assert(IsVirtual(pTab)); - j = -1; - nHidden++; - } else { - j = i - nHidden; - } - } else { - for (j = 0; j < pColumn.nId; j++) { - if (pColumn.a[j].idx == i) - break; - } - } - if (j < 0 || nColumn == 0 || (pColumn != null && j >= pColumn.nId)) { - sqlite3ExprCode(pParse, pTab.aCol[i].pDflt, iRegStore); - } else if (useTempTable) { - sqlite3VdbeAddOp3(v, OP_Column, srcTab, j, iRegStore); - } else if (pSelect != null) { - sqlite3VdbeAddOp2(v, OP_SCopy, regFromSelect + j, iRegStore); - } else { - sqlite3ExprCode(pParse, pList.a[j].pExpr, iRegStore); - } - } + endOfLoop = sqlite3VdbeMakeLabel( v ); +#if !SQLITE_OMIT_TRIGGER + if ( ( tmask & TRIGGER_BEFORE ) != 0 ) + { + int regCols = sqlite3GetTempRange( pParse, pTab.nCol + 1 ); + + /* build the NEW.* reference row. Note that if there is an INTEGER + ** PRIMARY KEY into which a NULL is being inserted, that NULL will be + ** translated into a unique ID for the row. But on a BEFORE trigger, + ** we do not know what the unique ID will be (because the insert has + ** not happened yet) so we substitute a rowid of -1 + */ + if ( keyColumn < 0 ) + { + sqlite3VdbeAddOp2( v, OP_Integer, -1, regCols ); + } + else + { + int j1; + if ( useTempTable ) + { + sqlite3VdbeAddOp3( v, OP_Column, srcTab, keyColumn, regCols ); + } + else + { + Debug.Assert( pSelect == null ); /* Otherwise useTempTable is true */ + sqlite3ExprCode( pParse, pList.a[keyColumn].pExpr, regCols ); + } + j1 = sqlite3VdbeAddOp1( v, OP_NotNull, regCols ); + sqlite3VdbeAddOp2( v, OP_Integer, -1, regCols ); + sqlite3VdbeJumpHere( v, j1 ); + sqlite3VdbeAddOp1( v, OP_MustBeInt, regCols ); + } + /* Cannot have triggers on a virtual table. If it were possible, + ** this block would have to account for hidden column. + */ + Debug.Assert( !IsVirtual( pTab ) ); + /* Create the new column data + */ + for ( i = 0; i < pTab.nCol; i++ ) + { + if ( pColumn == null ) + { + j = i; + } + else + { + for ( j = 0; j < pColumn.nId; j++ ) + { + if ( pColumn.a[j].idx == i ) + break; + } + } + if ( ( !useTempTable && null == pList ) || ( pColumn != null && j >= pColumn.nId ) ) + { + sqlite3ExprCode( pParse, pTab.aCol[i].pDflt, regCols + i + 1 ); + } + else if ( useTempTable ) + { + sqlite3VdbeAddOp3( v, OP_Column, srcTab, j, regCols + i + 1 ); + } + else + { + Debug.Assert( pSelect == null ); /* Otherwise useTempTable is true */ + sqlite3ExprCodeAndCache( pParse, pList.a[j].pExpr, regCols + i + 1 ); + } + } - /* Generate code to check constraints and generate index keys and - ** do the insertion. - */ -#if !SQLITE_OMIT_VIRTUALTABLE - if (IsVirtual(pTab)) { - VTable pVTab = sqlite3GetVTable(db, pTab); - sqlite3VtabMakeWritable(pParse, pTab); - sqlite3VdbeAddOp4(v, OP_VUpdate, 1, pTab.nCol + 2, regIns, pVTab, P4_VTAB); - sqlite3VdbeChangeP5(v, (byte)(onError == OE_Default ? OE_Abort : onError)); - sqlite3MayAbort(pParse); - } else + /* If this is an INSERT on a view with an INSTEAD OF INSERT trigger, + ** do not attempt any conversions before assembling the record. + ** If this is a real table, attempt conversions as required by the + ** table column affinities. + */ + if ( !isView ) + { + sqlite3VdbeAddOp2( v, OP_Affinity, regCols + 1, pTab.nCol ); + sqlite3TableAffinityStr( v, pTab ); + } + + /* Fire BEFORE or INSTEAD OF triggers */ + sqlite3CodeRowTrigger( pParse, pTrigger, TK_INSERT, null, TRIGGER_BEFORE, + pTab, regCols - pTab.nCol - 1, onError, endOfLoop ); + + sqlite3ReleaseTempRange( pParse, regCols, pTab.nCol + 1 ); + } #endif - { - int isReplace = 0; /* Set to true if constraints may cause a replace */ - sqlite3GenerateConstraintChecks(pParse, pTab, baseCur, regIns, aRegIdx, - keyColumn >= 0 ? 1 : 0, false, onError, endOfLoop, out isReplace - ); - sqlite3FkCheck(pParse, pTab, 0, regIns); - sqlite3CompleteInsertion( - pParse, pTab, baseCur, regIns, aRegIdx, false, appendFlag, isReplace == 0 - ); - } + + /* Push the record number for the new entry onto the stack. The +** record number is a randomly generate integer created by NewRowid +** except when the table has an INTEGER PRIMARY KEY column, in which +** case the record number is the same as that column. +*/ + if ( !isView ) + { + if ( IsVirtual( pTab ) ) + { + /* The row that the VUpdate opcode will delete: none */ + sqlite3VdbeAddOp2( v, OP_Null, 0, regIns ); + } + if ( keyColumn >= 0 ) + { + if ( useTempTable ) + { + sqlite3VdbeAddOp3( v, OP_Column, srcTab, keyColumn, regRowid ); + } + else if ( pSelect != null ) + { + sqlite3VdbeAddOp2( v, OP_SCopy, regFromSelect + keyColumn, regRowid ); + } + else + { + VdbeOp pOp; + sqlite3ExprCode( pParse, pList.a[keyColumn].pExpr, regRowid ); + pOp = sqlite3VdbeGetOp( v, -1 ); + if ( ALWAYS( pOp != null ) && pOp.opcode == OP_Null && !IsVirtual( pTab ) ) + { + appendFlag = true; + pOp.opcode = OP_NewRowid; + pOp.p1 = baseCur; + pOp.p2 = regRowid; + pOp.p3 = regAutoinc; + } + } + /* If the PRIMARY KEY expression is NULL, then use OP_NewRowid + ** to generate a unique primary key value. + */ + if ( !appendFlag ) + { + int j1; + if ( !IsVirtual( pTab ) ) + { + j1 = sqlite3VdbeAddOp1( v, OP_NotNull, regRowid ); + sqlite3VdbeAddOp3( v, OP_NewRowid, baseCur, regRowid, regAutoinc ); + sqlite3VdbeJumpHere( v, j1 ); } + else + { + j1 = sqlite3VdbeCurrentAddr( v ); + sqlite3VdbeAddOp2( v, OP_IsNull, regRowid, j1 + 2 ); + } + sqlite3VdbeAddOp1( v, OP_MustBeInt, regRowid ); + } + } + else if ( IsVirtual( pTab ) ) + { + sqlite3VdbeAddOp2( v, OP_Null, 0, regRowid ); + } + else + { + sqlite3VdbeAddOp3( v, OP_NewRowid, baseCur, regRowid, regAutoinc ); + appendFlag = true; + } + autoIncStep( pParse, regAutoinc, regRowid ); - /* Update the count of rows that are inserted - */ - if ((db.flags & SQLITE_CountRows) != 0) { - sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1); + /* Push onto the stack, data for all columns of the new entry, beginning + ** with the first column. + */ + nHidden = 0; + for ( i = 0; i < pTab.nCol; i++ ) + { + int iRegStore = regRowid + 1 + i; + if ( i == pTab.iPKey ) + { + /* The value of the INTEGER PRIMARY KEY column is always a NULL. + ** Whenever this column is read, the record number will be substituted + ** in its place. So will fill this column with a NULL to avoid + ** taking up data space with information that will never be used. */ + sqlite3VdbeAddOp2( v, OP_Null, 0, iRegStore ); + continue; + } + if ( pColumn == null ) + { + if ( IsHiddenColumn( pTab.aCol[i] ) ) + { + Debug.Assert( IsVirtual( pTab ) ); + j = -1; + nHidden++; } + else + { + j = i - nHidden; + } + } + else + { + for ( j = 0; j < pColumn.nId; j++ ) + { + if ( pColumn.a[j].idx == i ) + break; + } + } + if ( j < 0 || nColumn == 0 || ( pColumn != null && j >= pColumn.nId ) ) + { + sqlite3ExprCode( pParse, pTab.aCol[i].pDflt, iRegStore ); + } + else if ( useTempTable ) + { + sqlite3VdbeAddOp3( v, OP_Column, srcTab, j, iRegStore ); + } + else if ( pSelect != null ) + { + sqlite3VdbeAddOp2( v, OP_SCopy, regFromSelect + j, iRegStore ); + } + else + { + sqlite3ExprCode( pParse, pList.a[j].pExpr, iRegStore ); + } + } + + /* Generate code to check constraints and generate index keys and + ** do the insertion. + */ +#if !SQLITE_OMIT_VIRTUALTABLE + if ( IsVirtual( pTab ) ) + { + VTable pVTab = sqlite3GetVTable( db, pTab ); + sqlite3VtabMakeWritable( pParse, pTab ); + sqlite3VdbeAddOp4( v, OP_VUpdate, 1, pTab.nCol + 2, regIns, pVTab, P4_VTAB ); + sqlite3VdbeChangeP5( v, (byte)( onError == OE_Default ? OE_Abort : onError ) ); + sqlite3MayAbort( pParse ); + } + else +#endif + { + int isReplace = 0; /* Set to true if constraints may cause a replace */ + sqlite3GenerateConstraintChecks( pParse, pTab, baseCur, regIns, aRegIdx, + keyColumn >= 0 ? 1 : 0, false, onError, endOfLoop, out isReplace + ); + sqlite3FkCheck( pParse, pTab, 0, regIns ); + sqlite3CompleteInsertion( + pParse, pTab, baseCur, regIns, aRegIdx, false, appendFlag, isReplace == 0 + ); + } + } + + /* Update the count of rows that are inserted + */ + if ( ( db.flags & SQLITE_CountRows ) != 0 ) + { + sqlite3VdbeAddOp2( v, OP_AddImm, regRowCount, 1 ); + } #if !SQLITE_OMIT_TRIGGER - if (pTrigger != null) { - /* Code AFTER triggers */ - sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, null, TRIGGER_AFTER, - pTab, regData - 2 - pTab.nCol, onError, endOfLoop); - } + if ( pTrigger != null ) + { + /* Code AFTER triggers */ + sqlite3CodeRowTrigger( pParse, pTrigger, TK_INSERT, null, TRIGGER_AFTER, + pTab, regData - 2 - pTab.nCol, onError, endOfLoop ); + } #endif - /* The bottom of the main insertion loop, if the data source - ** is a SELECT statement. + /* The bottom of the main insertion loop, if the data source +** is a SELECT statement. +*/ + sqlite3VdbeResolveLabel( v, endOfLoop ); + if ( useTempTable ) + { + sqlite3VdbeAddOp2( v, OP_Next, srcTab, addrCont ); + sqlite3VdbeJumpHere( v, addrInsTop ); + sqlite3VdbeAddOp1( v, OP_Close, srcTab ); + } + else if ( pSelect != null ) + { + sqlite3VdbeAddOp2( v, OP_Goto, 0, addrCont ); + sqlite3VdbeJumpHere( v, addrInsTop ); + } + + if ( !IsVirtual( pTab ) && !isView ) + { + /* Close all tables opened */ + sqlite3VdbeAddOp1( v, OP_Close, baseCur ); + for ( idx = 1, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, idx++ ) + { + sqlite3VdbeAddOp1( v, OP_Close, idx + baseCur ); + } + } + +insert_end: + /* Update the sqlite_sequence table by storing the content of the + ** maximum rowid counter values recorded while inserting into + ** autoincrement tables. */ - sqlite3VdbeResolveLabel(v, endOfLoop); - if (useTempTable) { - sqlite3VdbeAddOp2(v, OP_Next, srcTab, addrCont); - sqlite3VdbeJumpHere(v, addrInsTop); - sqlite3VdbeAddOp1(v, OP_Close, srcTab); - } else if (pSelect != null) { - sqlite3VdbeAddOp2(v, OP_Goto, 0, addrCont); - sqlite3VdbeJumpHere(v, addrInsTop); - } + if ( pParse.nested == 0 && pParse.pTriggerTab == null ) + { + sqlite3AutoincrementEnd( pParse ); + } - if (!IsVirtual(pTab) && !isView) { - /* Close all tables opened */ - sqlite3VdbeAddOp1(v, OP_Close, baseCur); - for (idx = 1, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, idx++) { - sqlite3VdbeAddOp1(v, OP_Close, idx + baseCur); - } - } + /* + ** Return the number of rows inserted. If this routine is + ** generating code because of a call to sqlite3NestedParse(), do not + ** invoke the callback function. + */ + if ( ( db.flags & SQLITE_CountRows ) != 0 && 0 == pParse.nested && null == pParse.pTriggerTab ) + { + sqlite3VdbeAddOp2( v, OP_ResultRow, regRowCount, 1 ); + sqlite3VdbeSetNumCols( v, 1 ); + sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "rows inserted", SQLITE_STATIC ); + } - insert_end: - /* Update the sqlite_sequence table by storing the content of the - ** maximum rowid counter values recorded while inserting into - ** autoincrement tables. - */ - if (pParse.nested == 0 && pParse.pTriggerTab == null) { - sqlite3AutoincrementEnd(pParse); - } +insert_cleanup: + sqlite3SrcListDelete( db, ref pTabList ); + sqlite3ExprListDelete( db, ref pList ); + sqlite3SelectDelete( db, ref pSelect ); + sqlite3IdListDelete( db, ref pColumn ); + sqlite3DbFree( db, ref aRegIdx ); + } - /* - ** Return the number of rows inserted. If this routine is - ** generating code because of a call to sqlite3NestedParse(), do not - ** invoke the callback function. - */ - if ((db.flags & SQLITE_CountRows) != 0 && 0 == pParse.nested && null == pParse.pTriggerTab) { - sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1); - sqlite3VdbeSetNumCols(v, 1); - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows inserted", SQLITE_STATIC); - } + /* Make sure "isView" and other macros defined above are undefined. Otherwise + ** thely may interfere with compilation of other functions in this file + ** (or in another file, if this file becomes part of the amalgamation). */ + //#if isView + // #undef isView + //#endif + //#if pTrigger + // #undef pTrigger + //#endif + //#if tmask + // #undef tmask + //#endif - insert_cleanup: - sqlite3SrcListDelete(db, ref pTabList); - sqlite3ExprListDelete(db, ref pList); - sqlite3SelectDelete(db, ref pSelect); - sqlite3IdListDelete(db, ref pColumn); - sqlite3DbFree(db, ref aRegIdx); + /* + ** Generate code to do constraint checks prior to an INSERT or an UPDATE. + ** + ** The input is a range of consecutive registers as follows: + ** + ** 1. The rowid of the row after the update. + ** + ** 2. The data in the first column of the entry after the update. + ** + ** i. Data from middle columns... + ** + ** N. The data in the last column of the entry after the update. + ** + ** The regRowid parameter is the index of the register containing (1). + ** + ** If isUpdate is true and rowidChng is non-zero, then rowidChng contains + ** the address of a register containing the rowid before the update takes + ** place. isUpdate is true for UPDATEs and false for INSERTs. If isUpdate + ** is false, indicating an INSERT statement, then a non-zero rowidChng + ** indicates that the rowid was explicitly specified as part of the + ** INSERT statement. If rowidChng is false, it means that the rowid is + ** computed automatically in an insert or that the rowid value is not + ** modified by an update. + ** + ** The code generated by this routine store new index entries into + ** registers identified by aRegIdx[]. No index entry is created for + ** indices where aRegIdx[i]==0. The order of indices in aRegIdx[] is + ** the same as the order of indices on the linked list of indices + ** attached to the table. + ** + ** This routine also generates code to check constraints. NOT NULL, + ** CHECK, and UNIQUE constraints are all checked. If a constraint fails, + ** then the appropriate action is performed. There are five possible + ** actions: ROLLBACK, ABORT, FAIL, REPLACE, and IGNORE. + ** + ** Constraint type Action What Happens + ** --------------- ---------- ---------------------------------------- + ** any ROLLBACK The current transaction is rolled back and + ** sqlite3_exec() returns immediately with a + ** return code of SQLITE_CONSTRAINT. + ** + ** any ABORT Back out changes from the current command + ** only (do not do a complete rollback) then + ** cause sqlite3_exec() to return immediately + ** with SQLITE_CONSTRAINT. + ** + ** any FAIL Sqlite_exec() returns immediately with a + ** return code of SQLITE_CONSTRAINT. The + ** transaction is not rolled back and any + ** prior changes are retained. + ** + ** any IGNORE The record number and data is popped from + ** the stack and there is an immediate jump + ** to label ignoreDest. + ** + ** NOT NULL REPLACE The NULL value is replace by the default + ** value for that column. If the default value + ** is NULL, the action is the same as ABORT. + ** + ** UNIQUE REPLACE The other row that conflicts with the row + ** being inserted is removed. + ** + ** CHECK REPLACE Illegal. The results in an exception. + ** + ** Which action to take is determined by the overrideError parameter. + ** Or if overrideError==OE_Default, then the pParse.onError parameter + ** is used. Or if pParse.onError==OE_Default then the onError value + ** for the constraint is used. + ** + ** The calling routine must open a read/write cursor for pTab with + ** cursor number "baseCur". All indices of pTab must also have open + ** read/write cursors with cursor number baseCur+i for the i-th cursor. + ** Except, if there is no possibility of a REPLACE action then + ** cursors do not need to be open for indices where aRegIdx[i]==0. + */ + static void sqlite3GenerateConstraintChecks( + Parse pParse, /* The parser context */ + Table pTab, /* the table into which we are inserting */ + int baseCur, /* Index of a read/write cursor pointing at pTab */ + int regRowid, /* Index of the range of input registers */ + int[] aRegIdx, /* Register used by each index. 0 for unused indices */ + int rowidChng, /* True if the rowid might collide with existing entry */ + bool isUpdate, /* True for UPDATE, False for INSERT */ + int overrideError, /* Override onError to this if not OE_Default */ + int ignoreDest, /* Jump to this label on an OE_Ignore resolution */ + out int pbMayReplace /* OUT: Set to true if constraint may cause a replace */ + ) + { + + int i; /* loop counter */ + Vdbe v; /* VDBE under constrution */ + int nCol; /* Number of columns */ + int onError; /* Conflict resolution strategy */ + int j1; /* Addresss of jump instruction */ + int j2 = 0, j3; /* Addresses of jump instructions */ + int regData; /* Register containing first data column */ + int iCur; /* Table cursor number */ + Index pIdx; /* Pointer to one of the indices */ + bool seenReplace = false; /* True if REPLACE is used to resolve INT PK conflict */ + int regOldRowid = ( rowidChng != 0 && isUpdate ) ? rowidChng : regRowid; + + v = sqlite3GetVdbe( pParse ); + Debug.Assert( v != null ); + Debug.Assert( pTab.pSelect == null ); /* This table is not a VIEW */ + nCol = pTab.nCol; + regData = regRowid + 1; + + + /* Test all NOT NULL constraints. + */ + for ( i = 0; i < nCol; i++ ) + { + if ( i == pTab.iPKey ) + { + continue; } - - /* Make sure "isView" and other macros defined above are undefined. Otherwise - ** thely may interfere with compilation of other functions in this file - ** (or in another file, if this file becomes part of the amalgamation). */ - //#if isView - // #undef isView - //#endif - //#if pTrigger - // #undef pTrigger - //#endif - //#if tmask - // #undef tmask - //#endif - - /* - ** Generate code to do constraint checks prior to an INSERT or an UPDATE. - ** - ** The input is a range of consecutive registers as follows: - ** - ** 1. The rowid of the row after the update. - ** - ** 2. The data in the first column of the entry after the update. - ** - ** i. Data from middle columns... - ** - ** N. The data in the last column of the entry after the update. - ** - ** The regRowid parameter is the index of the register containing (1). - ** - ** If isUpdate is true and rowidChng is non-zero, then rowidChng contains - ** the address of a register containing the rowid before the update takes - ** place. isUpdate is true for UPDATEs and false for INSERTs. If isUpdate - ** is false, indicating an INSERT statement, then a non-zero rowidChng - ** indicates that the rowid was explicitly specified as part of the - ** INSERT statement. If rowidChng is false, it means that the rowid is - ** computed automatically in an insert or that the rowid value is not - ** modified by an update. - ** - ** The code generated by this routine store new index entries into - ** registers identified by aRegIdx[]. No index entry is created for - ** indices where aRegIdx[i]==0. The order of indices in aRegIdx[] is - ** the same as the order of indices on the linked list of indices - ** attached to the table. - ** - ** This routine also generates code to check constraints. NOT NULL, - ** CHECK, and UNIQUE constraints are all checked. If a constraint fails, - ** then the appropriate action is performed. There are five possible - ** actions: ROLLBACK, ABORT, FAIL, REPLACE, and IGNORE. - ** - ** Constraint type Action What Happens - ** --------------- ---------- ---------------------------------------- - ** any ROLLBACK The current transaction is rolled back and - ** sqlite3_exec() returns immediately with a - ** return code of SQLITE_CONSTRAINT. - ** - ** any ABORT Back out changes from the current command - ** only (do not do a complete rollback) then - ** cause sqlite3_exec() to return immediately - ** with SQLITE_CONSTRAINT. - ** - ** any FAIL Sqlite_exec() returns immediately with a - ** return code of SQLITE_CONSTRAINT. The - ** transaction is not rolled back and any - ** prior changes are retained. - ** - ** any IGNORE The record number and data is popped from - ** the stack and there is an immediate jump - ** to label ignoreDest. - ** - ** NOT NULL REPLACE The NULL value is replace by the default - ** value for that column. If the default value - ** is NULL, the action is the same as ABORT. - ** - ** UNIQUE REPLACE The other row that conflicts with the row - ** being inserted is removed. - ** - ** CHECK REPLACE Illegal. The results in an exception. - ** - ** Which action to take is determined by the overrideError parameter. - ** Or if overrideError==OE_Default, then the pParse.onError parameter - ** is used. Or if pParse.onError==OE_Default then the onError value - ** for the constraint is used. - ** - ** The calling routine must open a read/write cursor for pTab with - ** cursor number "baseCur". All indices of pTab must also have open - ** read/write cursors with cursor number baseCur+i for the i-th cursor. - ** Except, if there is no possibility of a REPLACE action then - ** cursors do not need to be open for indices where aRegIdx[i]==0. - */ - static void sqlite3GenerateConstraintChecks( - Parse pParse, /* The parser context */ - Table pTab, /* the table into which we are inserting */ - int baseCur, /* Index of a read/write cursor pointing at pTab */ - int regRowid, /* Index of the range of input registers */ - int[] aRegIdx, /* Register used by each index. 0 for unused indices */ - int rowidChng, /* True if the rowid might collide with existing entry */ - bool isUpdate, /* True for UPDATE, False for INSERT */ - int overrideError, /* Override onError to this if not OE_Default */ - int ignoreDest, /* Jump to this label on an OE_Ignore resolution */ - out int pbMayReplace /* OUT: Set to true if constraint may cause a replace */ - ) { - - int i; /* loop counter */ - Vdbe v; /* VDBE under constrution */ - int nCol; /* Number of columns */ - int onError; /* Conflict resolution strategy */ - int j1; /* Addresss of jump instruction */ - int j2 = 0, j3; /* Addresses of jump instructions */ - int regData; /* Register containing first data column */ - int iCur; /* Table cursor number */ - Index pIdx; /* Pointer to one of the indices */ - bool seenReplace = false; /* True if REPLACE is used to resolve INT PK conflict */ - int regOldRowid = (rowidChng != 0 && isUpdate) ? rowidChng : regRowid; - - v = sqlite3GetVdbe(pParse); - Debug.Assert(v != null); - Debug.Assert(pTab.pSelect == null); /* This table is not a VIEW */ - nCol = pTab.nCol; - regData = regRowid + 1; - - - /* Test all NOT NULL constraints. - */ - for (i = 0; i < nCol; i++) { - if (i == pTab.iPKey) { - continue; - } - onError = pTab.aCol[i].notNull; - if (onError == OE_None) - continue; - if (overrideError != OE_Default) { - onError = overrideError; - } else if (onError == OE_Default) { - onError = OE_Abort; - } - if (onError == OE_Replace && pTab.aCol[i].pDflt == null) { - onError = OE_Abort; - } - Debug.Assert(onError == OE_Rollback || onError == OE_Abort || onError == OE_Fail - || onError == OE_Ignore || onError == OE_Replace); - switch (onError) { - case OE_Abort: { - sqlite3MayAbort(pParse); - goto case OE_Fail; - } - case OE_Rollback: - case OE_Fail: { - string zMsg; - sqlite3VdbeAddOp3(v, OP_HaltIfNull, - SQLITE_CONSTRAINT, onError, regData + i); - zMsg = sqlite3MPrintf(pParse.db, "%s.%s may not be NULL", - pTab.zName, pTab.aCol[i].zName); - sqlite3VdbeChangeP4(v, -1, zMsg, P4_DYNAMIC); - break; - } - case OE_Ignore: { - sqlite3VdbeAddOp2(v, OP_IsNull, regData + i, ignoreDest); - break; - } - default: { - Debug.Assert(onError == OE_Replace); - j1 = sqlite3VdbeAddOp1(v, OP_NotNull, regData + i); - sqlite3ExprCode(pParse, pTab.aCol[i].pDflt, regData + i); - sqlite3VdbeJumpHere(v, j1); - break; - } - } + onError = pTab.aCol[i].notNull; + if ( onError == OE_None ) + continue; + if ( overrideError != OE_Default ) + { + onError = overrideError; + } + else if ( onError == OE_Default ) + { + onError = OE_Abort; + } + if ( onError == OE_Replace && pTab.aCol[i].pDflt == null ) + { + onError = OE_Abort; + } + Debug.Assert( onError == OE_Rollback || onError == OE_Abort || onError == OE_Fail + || onError == OE_Ignore || onError == OE_Replace ); + switch ( onError ) + { + case OE_Abort: + { + sqlite3MayAbort( pParse ); + goto case OE_Fail; + } + case OE_Rollback: + case OE_Fail: + { + string zMsg; + sqlite3VdbeAddOp3( v, OP_HaltIfNull, + SQLITE_CONSTRAINT, onError, regData + i ); + zMsg = sqlite3MPrintf( pParse.db, "%s.%s may not be NULL", + pTab.zName, pTab.aCol[i].zName ); + sqlite3VdbeChangeP4( v, -1, zMsg, P4_DYNAMIC ); + break; + } + case OE_Ignore: + { + sqlite3VdbeAddOp2( v, OP_IsNull, regData + i, ignoreDest ); + break; + } + default: + { + Debug.Assert( onError == OE_Replace ); + j1 = sqlite3VdbeAddOp1( v, OP_NotNull, regData + i ); + sqlite3ExprCode( pParse, pTab.aCol[i].pDflt, regData + i ); + sqlite3VdbeJumpHere( v, j1 ); + break; } + } + } - /* Test all CHECK constraints - */ + /* Test all CHECK constraints + */ #if !SQLITE_OMIT_CHECK - if (pTab.pCheck != null && (pParse.db.flags & SQLITE_IgnoreChecks) == 0) { - int allOk = sqlite3VdbeMakeLabel(v); - pParse.ckBase = regData; - sqlite3ExprIfTrue(pParse, pTab.pCheck, allOk, SQLITE_JUMPIFNULL); - onError = overrideError != OE_Default ? overrideError : OE_Abort; - if (onError == OE_Ignore) { - sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest); - } else { - if (onError == OE_Replace) - onError = OE_Abort; /* IMP: R-15569-63625 */ - sqlite3HaltConstraint(pParse, onError, (string)null, 0); - } - sqlite3VdbeResolveLabel(v, allOk); - } + if ( pTab.pCheck != null && ( pParse.db.flags & SQLITE_IgnoreChecks ) == 0 ) + { + int allOk = sqlite3VdbeMakeLabel( v ); + pParse.ckBase = regData; + sqlite3ExprIfTrue( pParse, pTab.pCheck, allOk, SQLITE_JUMPIFNULL ); + onError = overrideError != OE_Default ? overrideError : OE_Abort; + if ( onError == OE_Ignore ) + { + sqlite3VdbeAddOp2( v, OP_Goto, 0, ignoreDest ); + } + else + { + if ( onError == OE_Replace ) + onError = OE_Abort; /* IMP: R-15569-63625 */ + sqlite3HaltConstraint( pParse, onError, (string)null, 0 ); + } + sqlite3VdbeResolveLabel( v, allOk ); + } #endif // * !SQLITE_OMIT_CHECK) */ - /* If we have an INTEGER PRIMARY KEY, make sure the primary key - ** of the new record does not previously exist. Except, if this - ** is an UPDATE and the primary key is not changing, that is OK. - */ - if (rowidChng != 0) { - onError = pTab.keyConf; - if (overrideError != OE_Default) { - onError = overrideError; - } else if (onError == OE_Default) { - onError = OE_Abort; - } + /* If we have an INTEGER PRIMARY KEY, make sure the primary key +** of the new record does not previously exist. Except, if this +** is an UPDATE and the primary key is not changing, that is OK. +*/ + if ( rowidChng != 0 ) + { + onError = pTab.keyConf; + if ( overrideError != OE_Default ) + { + onError = overrideError; + } + else if ( onError == OE_Default ) + { + onError = OE_Abort; + } - if (isUpdate) { - j2 = sqlite3VdbeAddOp3(v, OP_Eq, regRowid, 0, rowidChng); - } - j3 = sqlite3VdbeAddOp3(v, OP_NotExists, baseCur, 0, regRowid); - switch (onError) { - default: { - onError = OE_Abort; - /* Fall thru into the next case */ - } - goto case OE_Rollback; - case OE_Rollback: - case OE_Abort: - case OE_Fail: { - sqlite3HaltConstraint( - pParse, onError, "PRIMARY KEY must be unique", P4_STATIC); - break; - } - case OE_Replace: { - /* If there are DELETE triggers on this table and the - ** recursive-triggers flag is set, call GenerateRowDelete() to - ** remove the conflicting row from the the table. This will fire - ** the triggers and remove both the table and index b-tree entries. - ** - ** Otherwise, if there are no triggers or the recursive-triggers - ** flag is not set, but the table has one or more indexes, call - ** GenerateRowIndexDelete(). This removes the index b-tree entries - ** only. The table b-tree entry will be replaced by the new entry - ** when it is inserted. - ** - ** If either GenerateRowDelete() or GenerateRowIndexDelete() is called, - ** also invoke MultiWrite() to indicate that this VDBE may require - ** statement rollback (if the statement is aborted after the delete - ** takes place). Earlier versions called sqlite3MultiWrite() regardless, - ** but being more selective here allows statements like: - ** - ** REPLACE INTO t(rowid) VALUES($newrowid) - ** - ** to run without a statement journal if there are no indexes on the - ** table. - */ - Trigger pTrigger = null; - if ((pParse.db.flags & SQLITE_RecTriggers) != 0) { - int iDummy; - pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, null, out iDummy); - } - if (pTrigger != null || sqlite3FkRequired(pParse, pTab, null, 0) != 0) { - sqlite3MultiWrite(pParse); - sqlite3GenerateRowDelete( - pParse, pTab, baseCur, regRowid, 0, pTrigger, OE_Replace - ); - } else - if (pTab.pIndex != null) { - sqlite3MultiWrite(pParse); - sqlite3GenerateRowIndexDelete(pParse, pTab, baseCur, 0); - } - seenReplace = true; - break; - } - case OE_Ignore: { - Debug.Assert(!seenReplace); - sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest); - break; - } - } - sqlite3VdbeJumpHere(v, j3); - if (isUpdate) { - sqlite3VdbeJumpHere(v, j2); + if ( isUpdate ) + { + j2 = sqlite3VdbeAddOp3( v, OP_Eq, regRowid, 0, rowidChng ); + } + j3 = sqlite3VdbeAddOp3( v, OP_NotExists, baseCur, 0, regRowid ); + switch ( onError ) + { + default: + { + onError = OE_Abort; + /* Fall thru into the next case */ + } + goto case OE_Rollback; + case OE_Rollback: + case OE_Abort: + case OE_Fail: + { + sqlite3HaltConstraint( + pParse, onError, "PRIMARY KEY must be unique", P4_STATIC ); + break; + } + case OE_Replace: + { + /* If there are DELETE triggers on this table and the + ** recursive-triggers flag is set, call GenerateRowDelete() to + ** remove the conflicting row from the the table. This will fire + ** the triggers and remove both the table and index b-tree entries. + ** + ** Otherwise, if there are no triggers or the recursive-triggers + ** flag is not set, but the table has one or more indexes, call + ** GenerateRowIndexDelete(). This removes the index b-tree entries + ** only. The table b-tree entry will be replaced by the new entry + ** when it is inserted. + ** + ** If either GenerateRowDelete() or GenerateRowIndexDelete() is called, + ** also invoke MultiWrite() to indicate that this VDBE may require + ** statement rollback (if the statement is aborted after the delete + ** takes place). Earlier versions called sqlite3MultiWrite() regardless, + ** but being more selective here allows statements like: + ** + ** REPLACE INTO t(rowid) VALUES($newrowid) + ** + ** to run without a statement journal if there are no indexes on the + ** table. + */ + Trigger pTrigger = null; + if ( ( pParse.db.flags & SQLITE_RecTriggers ) != 0 ) + { + int iDummy; + pTrigger = sqlite3TriggersExist( pParse, pTab, TK_DELETE, null, out iDummy ); + } + if ( pTrigger != null || sqlite3FkRequired( pParse, pTab, null, 0 ) != 0 ) + { + sqlite3MultiWrite( pParse ); + sqlite3GenerateRowDelete( + pParse, pTab, baseCur, regRowid, 0, pTrigger, OE_Replace + ); + } + else + if ( pTab.pIndex != null ) + { + sqlite3MultiWrite( pParse ); + sqlite3GenerateRowIndexDelete( pParse, pTab, baseCur, 0 ); } + seenReplace = true; + break; } + case OE_Ignore: + { + Debug.Assert( !seenReplace ); + sqlite3VdbeAddOp2( v, OP_Goto, 0, ignoreDest ); + break; + } + } + sqlite3VdbeJumpHere( v, j3 ); + if ( isUpdate ) + { + sqlite3VdbeJumpHere( v, j2 ); + } + } - /* Test all UNIQUE constraints by creating entries for each UNIQUE - ** index and making sure that duplicate entries do not already exist. - ** Add the new records to the indices as we go. - */ - for (iCur = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, iCur++) { - int regIdx; - int regR; - - if (aRegIdx[iCur] == 0) - continue; /* Skip unused indices */ - - /* Create a key for accessing the index entry */ - regIdx = sqlite3GetTempRange(pParse, pIdx.nColumn + 1); - for (i = 0; i < pIdx.nColumn; i++) { - int idx = pIdx.aiColumn[i]; - if (idx == pTab.iPKey) { - sqlite3VdbeAddOp2(v, OP_SCopy, regRowid, regIdx + i); - } else { - sqlite3VdbeAddOp2(v, OP_SCopy, regData + idx, regIdx + i); - } - } - sqlite3VdbeAddOp2(v, OP_SCopy, regRowid, regIdx + i); - sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx.nColumn + 1, aRegIdx[iCur]); - sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), P4_TRANSIENT); - sqlite3ExprCacheAffinityChange(pParse, regIdx, pIdx.nColumn + 1); - - /* Find out what action to take in case there is an indexing conflict */ - onError = pIdx.onError; - if (onError == OE_None) { - sqlite3ReleaseTempRange(pParse, regIdx, pIdx.nColumn + 1); - continue; /* pIdx is not a UNIQUE index */ - } + /* Test all UNIQUE constraints by creating entries for each UNIQUE + ** index and making sure that duplicate entries do not already exist. + ** Add the new records to the indices as we go. + */ + for ( iCur = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, iCur++ ) + { + int regIdx; + int regR; + + if ( aRegIdx[iCur] == 0 ) + continue; /* Skip unused indices */ + + /* Create a key for accessing the index entry */ + regIdx = sqlite3GetTempRange( pParse, pIdx.nColumn + 1 ); + for ( i = 0; i < pIdx.nColumn; i++ ) + { + int idx = pIdx.aiColumn[i]; + if ( idx == pTab.iPKey ) + { + sqlite3VdbeAddOp2( v, OP_SCopy, regRowid, regIdx + i ); + } + else + { + sqlite3VdbeAddOp2( v, OP_SCopy, regData + idx, regIdx + i ); + } + } + sqlite3VdbeAddOp2( v, OP_SCopy, regRowid, regIdx + i ); + sqlite3VdbeAddOp3( v, OP_MakeRecord, regIdx, pIdx.nColumn + 1, aRegIdx[iCur] ); + sqlite3VdbeChangeP4( v, -1, sqlite3IndexAffinityStr( v, pIdx ), P4_TRANSIENT ); + sqlite3ExprCacheAffinityChange( pParse, regIdx, pIdx.nColumn + 1 ); + + /* Find out what action to take in case there is an indexing conflict */ + onError = pIdx.onError; + if ( onError == OE_None ) + { + sqlite3ReleaseTempRange( pParse, regIdx, pIdx.nColumn + 1 ); + continue; /* pIdx is not a UNIQUE index */ + } - if (overrideError != OE_Default) { - onError = overrideError; - } else if (onError == OE_Default) { - onError = OE_Abort; - } - if (seenReplace) { - if (onError == OE_Ignore) - onError = OE_Replace; - else if (onError == OE_Fail) - onError = OE_Abort; - } + if ( overrideError != OE_Default ) + { + onError = overrideError; + } + else if ( onError == OE_Default ) + { + onError = OE_Abort; + } + if ( seenReplace ) + { + if ( onError == OE_Ignore ) + onError = OE_Replace; + else if ( onError == OE_Fail ) + onError = OE_Abort; + } - /* Check to see if the new index entry will be unique */ - regR = sqlite3GetTempReg(pParse); - sqlite3VdbeAddOp2(v, OP_SCopy, regOldRowid, regR); - j3 = sqlite3VdbeAddOp4(v, OP_IsUnique, baseCur + iCur + 1, 0, - regR, regIdx,//regR, SQLITE_INT_TO_PTR(regIdx), - P4_INT32); - sqlite3ReleaseTempRange(pParse, regIdx, pIdx.nColumn + 1); - - /* Generate code that executes if the new index entry is not unique */ - Debug.Assert(onError == OE_Rollback || onError == OE_Abort || onError == OE_Fail - || onError == OE_Ignore || onError == OE_Replace); - switch (onError) { - case OE_Rollback: - case OE_Abort: - case OE_Fail: { - int j; - StrAccum errMsg = new StrAccum(200); - string zSep; - string zErr; - - sqlite3StrAccumInit(errMsg, null, 0, 200); - errMsg.db = pParse.db; - zSep = pIdx.nColumn > 1 ? "columns " : "column "; - for (j = 0; j < pIdx.nColumn; j++) { - string zCol = pTab.aCol[pIdx.aiColumn[j]].zName; - sqlite3StrAccumAppend(errMsg, zSep, -1); - zSep = ", "; - sqlite3StrAccumAppend(errMsg, zCol, -1); - } - sqlite3StrAccumAppend(errMsg, - pIdx.nColumn > 1 ? " are not unique" : " is not unique", -1); - zErr = sqlite3StrAccumFinish(errMsg); - sqlite3HaltConstraint(pParse, onError, zErr, 0); - sqlite3DbFree(errMsg.db, ref zErr); - break; - } - case OE_Ignore: { - Debug.Assert(!seenReplace); - sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest); - break; - } - default: { - Trigger pTrigger = null; - Debug.Assert(onError == OE_Replace); - sqlite3MultiWrite(pParse); - if ((pParse.db.flags & SQLITE_RecTriggers) != 0) { - int iDummy; - pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, null, out iDummy); - } - sqlite3GenerateRowDelete( - pParse, pTab, baseCur, regR, 0, pTrigger, OE_Replace - ); - seenReplace = true; - break; - } - } - sqlite3VdbeJumpHere(v, j3); - sqlite3ReleaseTempReg(pParse, regR); + /* Check to see if the new index entry will be unique */ + regR = sqlite3GetTempReg( pParse ); + sqlite3VdbeAddOp2( v, OP_SCopy, regOldRowid, regR ); + j3 = sqlite3VdbeAddOp4( v, OP_IsUnique, baseCur + iCur + 1, 0, + regR, regIdx,//regR, SQLITE_INT_TO_PTR(regIdx), + P4_INT32 ); + sqlite3ReleaseTempRange( pParse, regIdx, pIdx.nColumn + 1 ); + + /* Generate code that executes if the new index entry is not unique */ + Debug.Assert( onError == OE_Rollback || onError == OE_Abort || onError == OE_Fail + || onError == OE_Ignore || onError == OE_Replace ); + switch ( onError ) + { + case OE_Rollback: + case OE_Abort: + case OE_Fail: + { + int j; + StrAccum errMsg = new StrAccum( 200 ); + string zSep; + string zErr; + + sqlite3StrAccumInit( errMsg, null, 0, 200 ); + errMsg.db = pParse.db; + zSep = pIdx.nColumn > 1 ? "columns " : "column "; + for ( j = 0; j < pIdx.nColumn; j++ ) + { + string zCol = pTab.aCol[pIdx.aiColumn[j]].zName; + sqlite3StrAccumAppend( errMsg, zSep, -1 ); + zSep = ", "; + sqlite3StrAccumAppend( errMsg, zCol, -1 ); + } + sqlite3StrAccumAppend( errMsg, + pIdx.nColumn > 1 ? " are not unique" : " is not unique", -1 ); + zErr = sqlite3StrAccumFinish( errMsg ); + sqlite3HaltConstraint( pParse, onError, zErr, 0 ); + sqlite3DbFree( errMsg.db, ref zErr ); + break; + } + case OE_Ignore: + { + Debug.Assert( !seenReplace ); + sqlite3VdbeAddOp2( v, OP_Goto, 0, ignoreDest ); + break; } - //if ( pbMayReplace ) + default: { - pbMayReplace = seenReplace ? 1 : 0; + Trigger pTrigger = null; + Debug.Assert( onError == OE_Replace ); + sqlite3MultiWrite( pParse ); + if ( ( pParse.db.flags & SQLITE_RecTriggers ) != 0 ) + { + int iDummy; + pTrigger = sqlite3TriggersExist( pParse, pTab, TK_DELETE, null, out iDummy ); + } + sqlite3GenerateRowDelete( + pParse, pTab, baseCur, regR, 0, pTrigger, OE_Replace + ); + seenReplace = true; + break; } } + sqlite3VdbeJumpHere( v, j3 ); + sqlite3ReleaseTempReg( pParse, regR ); + } + //if ( pbMayReplace ) + { + pbMayReplace = seenReplace ? 1 : 0; + } + } - /* - ** This routine generates code to finish the INSERT or UPDATE operation - ** that was started by a prior call to sqlite3GenerateConstraintChecks. - ** A consecutive range of registers starting at regRowid contains the - ** rowid and the content to be inserted. - ** - ** The arguments to this routine should be the same as the first six - ** arguments to sqlite3GenerateConstraintChecks. - */ - static void sqlite3CompleteInsertion( - Parse pParse, /* The parser context */ - Table pTab, /* the table into which we are inserting */ - int baseCur, /* Index of a read/write cursor pointing at pTab */ - int regRowid, /* Range of content */ - int[] aRegIdx, /* Register used by each index. 0 for unused indices */ - bool isUpdate, /* True for UPDATE, False for INSERT */ - bool appendBias, /* True if this is likely to be an append */ - bool useSeekResult /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */ - ) { - int i; - Vdbe v; - int nIdx; - Index pIdx; - u8 pik_flags; - int regData; - int regRec; - - v = sqlite3GetVdbe(pParse); - Debug.Assert(v != null); - Debug.Assert(pTab.pSelect == null); /* This table is not a VIEW */ - for (nIdx = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, nIdx++) { - } - for (i = nIdx - 1; i >= 0; i--) { - if (aRegIdx[i] == 0) - continue; - sqlite3VdbeAddOp2(v, OP_IdxInsert, baseCur + i + 1, aRegIdx[i]); - if (useSeekResult) { - sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); - } - } - regData = regRowid + 1; - regRec = sqlite3GetTempReg(pParse); - sqlite3VdbeAddOp3(v, OP_MakeRecord, regData, pTab.nCol, regRec); - sqlite3TableAffinityStr(v, pTab); - sqlite3ExprCacheAffinityChange(pParse, regData, pTab.nCol); - if (pParse.nested != 0) { - pik_flags = 0; - } else { - pik_flags = OPFLAG_NCHANGE; - pik_flags |= (isUpdate ? OPFLAG_ISUPDATE : OPFLAG_LASTROWID); - } - if (appendBias) { - pik_flags |= OPFLAG_APPEND; - } - if (useSeekResult) { - pik_flags |= OPFLAG_USESEEKRESULT; - } - sqlite3VdbeAddOp3(v, OP_Insert, baseCur, regRec, regRowid); - if (pParse.nested == 0) { - sqlite3VdbeChangeP4(v, -1, pTab.zName, P4_TRANSIENT); - } - sqlite3VdbeChangeP5(v, pik_flags); + /* + ** This routine generates code to finish the INSERT or UPDATE operation + ** that was started by a prior call to sqlite3GenerateConstraintChecks. + ** A consecutive range of registers starting at regRowid contains the + ** rowid and the content to be inserted. + ** + ** The arguments to this routine should be the same as the first six + ** arguments to sqlite3GenerateConstraintChecks. + */ + static void sqlite3CompleteInsertion( + Parse pParse, /* The parser context */ + Table pTab, /* the table into which we are inserting */ + int baseCur, /* Index of a read/write cursor pointing at pTab */ + int regRowid, /* Range of content */ + int[] aRegIdx, /* Register used by each index. 0 for unused indices */ + bool isUpdate, /* True for UPDATE, False for INSERT */ + bool appendBias, /* True if this is likely to be an append */ + bool useSeekResult /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */ + ) + { + int i; + Vdbe v; + int nIdx; + Index pIdx; + u8 pik_flags; + int regData; + int regRec; + + v = sqlite3GetVdbe( pParse ); + Debug.Assert( v != null ); + Debug.Assert( pTab.pSelect == null ); /* This table is not a VIEW */ + for ( nIdx = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, nIdx++ ) + { + } + for ( i = nIdx - 1; i >= 0; i-- ) + { + if ( aRegIdx[i] == 0 ) + continue; + sqlite3VdbeAddOp2( v, OP_IdxInsert, baseCur + i + 1, aRegIdx[i] ); + if ( useSeekResult ) + { + sqlite3VdbeChangeP5( v, OPFLAG_USESEEKRESULT ); } + } + regData = regRowid + 1; + regRec = sqlite3GetTempReg( pParse ); + sqlite3VdbeAddOp3( v, OP_MakeRecord, regData, pTab.nCol, regRec ); + sqlite3TableAffinityStr( v, pTab ); + sqlite3ExprCacheAffinityChange( pParse, regData, pTab.nCol ); + if ( pParse.nested != 0 ) + { + pik_flags = 0; + } + else + { + pik_flags = OPFLAG_NCHANGE; + pik_flags |= ( isUpdate ? OPFLAG_ISUPDATE : OPFLAG_LASTROWID ); + } + if ( appendBias ) + { + pik_flags |= OPFLAG_APPEND; + } + if ( useSeekResult ) + { + pik_flags |= OPFLAG_USESEEKRESULT; + } + sqlite3VdbeAddOp3( v, OP_Insert, baseCur, regRec, regRowid ); + if ( pParse.nested == 0 ) + { + sqlite3VdbeChangeP4( v, -1, pTab.zName, P4_TRANSIENT ); + } + sqlite3VdbeChangeP5( v, pik_flags ); + } - /* - ** Generate code that will open cursors for a table and for all - ** indices of that table. The "baseCur" parameter is the cursor number used - ** for the table. Indices are opened on subsequent cursors. - ** - ** Return the number of indices on the table. - */ - static int sqlite3OpenTableAndIndices( - Parse pParse, /* Parsing context */ - Table pTab, /* Table to be opened */ - int baseCur, /* VdbeCursor number assigned to the table */ - int op /* OP_OpenRead or OP_OpenWrite */ - ) { - int i; - int iDb; - Index pIdx; - Vdbe v; - - if (IsVirtual(pTab)) - return 0; - iDb = sqlite3SchemaToIndex(pParse.db, pTab.pSchema); - v = sqlite3GetVdbe(pParse); - Debug.Assert(v != null); - sqlite3OpenTable(pParse, baseCur, iDb, pTab, op); - for (i = 1, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, i++) { - KeyInfo pKey = sqlite3IndexKeyinfo(pParse, pIdx); - Debug.Assert(pIdx.pSchema == pTab.pSchema); - sqlite3VdbeAddOp4(v, op, i + baseCur, pIdx.tnum, iDb, - pKey, P4_KEYINFO_HANDOFF); + /* + ** Generate code that will open cursors for a table and for all + ** indices of that table. The "baseCur" parameter is the cursor number used + ** for the table. Indices are opened on subsequent cursors. + ** + ** Return the number of indices on the table. + */ + static int sqlite3OpenTableAndIndices( + Parse pParse, /* Parsing context */ + Table pTab, /* Table to be opened */ + int baseCur, /* VdbeCursor number assigned to the table */ + int op /* OP_OpenRead or OP_OpenWrite */ + ) + { + int i; + int iDb; + Index pIdx; + Vdbe v; + + if ( IsVirtual( pTab ) ) + return 0; + iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema ); + v = sqlite3GetVdbe( pParse ); + Debug.Assert( v != null ); + sqlite3OpenTable( pParse, baseCur, iDb, pTab, op ); + for ( i = 1, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, i++ ) + { + KeyInfo pKey = sqlite3IndexKeyinfo( pParse, pIdx ); + Debug.Assert( pIdx.pSchema == pTab.pSchema ); + sqlite3VdbeAddOp4( v, op, i + baseCur, pIdx.tnum, iDb, + pKey, P4_KEYINFO_HANDOFF ); #if SQLITE_DEBUG - VdbeComment(v, "%s", pIdx.zName); + VdbeComment( v, "%s", pIdx.zName ); #endif - } - if (pParse.nTab < baseCur + i) { - pParse.nTab = baseCur + i; - } - return i - 1; - } + } + if ( pParse.nTab < baseCur + i ) + { + pParse.nTab = baseCur + i; + } + return i - 1; + } -#if SQLITE_TEST +#if SQLITE_TEST /* ** The following global variable is incremented whenever the ** transfer optimization is used. This is used for testing @@ -1596,332 +1787,387 @@ int op /* OP_OpenRead or OP_OpenWrite */ #if !SQLITE_OMIT_XFER_OPT - /* - ** Check to collation names to see if they are compatible. - */ - static bool xferCompatibleCollation(string z1, string z2) { - if (z1 == null) { - return z2 == null; - } - if (z2 == null) { - return false; - } - return z1.Equals(z2, StringComparison.OrdinalIgnoreCase); - } - + /* +** Check to collation names to see if they are compatible. +*/ + static bool xferCompatibleCollation( string z1, string z2 ) + { + if ( z1 == null ) + { + return z2 == null; + } + if ( z2 == null ) + { + return false; + } + return z1.Equals( z2 ,StringComparison.OrdinalIgnoreCase ) ; + } - /* - ** Check to see if index pSrc is compatible as a source of data - ** for index pDest in an insert transfer optimization. The rules - ** for a compatible index: - ** - ** * The index is over the same set of columns - ** * The same DESC and ASC markings occurs on all columns - ** * The same onError processing (OE_Abort, OE_Ignore, etc) - ** * The same collating sequence on each column - */ - static bool xferCompatibleIndex(Index pDest, Index pSrc) { - int i; - Debug.Assert(pDest != null && pSrc != null); - Debug.Assert(pDest.pTable != pSrc.pTable); - if (pDest.nColumn != pSrc.nColumn) { - return false; /* Different number of columns */ - } - if (pDest.onError != pSrc.onError) { - return false; /* Different conflict resolution strategies */ - } - for (i = 0; i < pSrc.nColumn; i++) { - if (pSrc.aiColumn[i] != pDest.aiColumn[i]) { - return false; /* Different columns indexed */ - } - if (pSrc.aSortOrder[i] != pDest.aSortOrder[i]) { - return false; /* Different sort orders */ - } - if (!xferCompatibleCollation(pSrc.azColl[i], pDest.azColl[i])) { - return false; /* Different collating sequences */ - } - } - /* If no test above fails then the indices must be compatible */ - return true; + /* + ** Check to see if index pSrc is compatible as a source of data + ** for index pDest in an insert transfer optimization. The rules + ** for a compatible index: + ** + ** * The index is over the same set of columns + ** * The same DESC and ASC markings occurs on all columns + ** * The same onError processing (OE_Abort, OE_Ignore, etc) + ** * The same collating sequence on each column + */ + static bool xferCompatibleIndex( Index pDest, Index pSrc ) + { + int i; + Debug.Assert( pDest != null && pSrc != null ); + Debug.Assert( pDest.pTable != pSrc.pTable ); + if ( pDest.nColumn != pSrc.nColumn ) + { + return false; /* Different number of columns */ + } + if ( pDest.onError != pSrc.onError ) + { + return false; /* Different conflict resolution strategies */ + } + for ( i = 0; i < pSrc.nColumn; i++ ) + { + if ( pSrc.aiColumn[i] != pDest.aiColumn[i] ) + { + return false; /* Different columns indexed */ } + if ( pSrc.aSortOrder[i] != pDest.aSortOrder[i] ) + { + return false; /* Different sort orders */ + } + if ( !xferCompatibleCollation( pSrc.azColl[i], pDest.azColl[i] ) ) + { + return false; /* Different collating sequences */ + } + } - /* - ** Attempt the transfer optimization on INSERTs of the form - ** - ** INSERT INTO tab1 SELECT * FROM tab2; - ** - ** This optimization is only attempted if - ** - ** (1) tab1 and tab2 have identical schemas including all the - ** same indices and constraints - ** - ** (2) tab1 and tab2 are different tables - ** - ** (3) There must be no triggers on tab1 - ** - ** (4) The result set of the SELECT statement is "*" - ** - ** (5) The SELECT statement has no WHERE, HAVING, ORDER BY, GROUP BY, - ** or LIMIT clause. - ** - ** (6) The SELECT statement is a simple (not a compound) select that - ** contains only tab2 in its FROM clause - ** - ** This method for implementing the INSERT transfers raw records from - ** tab2 over to tab1. The columns are not decoded. Raw records from - ** the indices of tab2 are transfered to tab1 as well. In so doing, - ** the resulting tab1 has much less fragmentation. - ** - ** This routine returns TRUE if the optimization is attempted. If any - ** of the conditions above fail so that the optimization should not - ** be attempted, then this routine returns FALSE. - */ - static int xferOptimization( - Parse pParse, /* Parser context */ - Table pDest, /* The table we are inserting into */ - Select pSelect, /* A SELECT statement to use as the data source */ - int onError, /* How to handle constraint errors */ - int iDbDest /* The database of pDest */ - ) { - ExprList pEList; /* The result set of the SELECT */ - Table pSrc; /* The table in the FROM clause of SELECT */ - Index pSrcIdx, pDestIdx; /* Source and destination indices */ - SrcList_item pItem; /* An element of pSelect.pSrc */ - int i; /* Loop counter */ - int iDbSrc; /* The database of pSrc */ - int iSrc, iDest; /* Cursors from source and destination */ - int addr1, addr2; /* Loop addresses */ - int emptyDestTest; /* Address of test for empty pDest */ - int emptySrcTest; /* Address of test for empty pSrc */ - Vdbe v; /* The VDBE we are building */ - KeyInfo pKey; /* Key information for an index */ - int regAutoinc; /* Memory register used by AUTOINC */ - bool destHasUniqueIdx = false; /* True if pDest has a UNIQUE index */ - int regData, regRowid; /* Registers holding data and rowid */ - - if (pSelect == null) { - return 0; /* Must be of the form INSERT INTO ... SELECT ... */ - } + /* If no test above fails then the indices must be compatible */ + return true; + } + + /* + ** Attempt the transfer optimization on INSERTs of the form + ** + ** INSERT INTO tab1 SELECT * FROM tab2; + ** + ** This optimization is only attempted if + ** + ** (1) tab1 and tab2 have identical schemas including all the + ** same indices and constraints + ** + ** (2) tab1 and tab2 are different tables + ** + ** (3) There must be no triggers on tab1 + ** + ** (4) The result set of the SELECT statement is "*" + ** + ** (5) The SELECT statement has no WHERE, HAVING, ORDER BY, GROUP BY, + ** or LIMIT clause. + ** + ** (6) The SELECT statement is a simple (not a compound) select that + ** contains only tab2 in its FROM clause + ** + ** This method for implementing the INSERT transfers raw records from + ** tab2 over to tab1. The columns are not decoded. Raw records from + ** the indices of tab2 are transfered to tab1 as well. In so doing, + ** the resulting tab1 has much less fragmentation. + ** + ** This routine returns TRUE if the optimization is attempted. If any + ** of the conditions above fail so that the optimization should not + ** be attempted, then this routine returns FALSE. + */ + static int xferOptimization( + Parse pParse, /* Parser context */ + Table pDest, /* The table we are inserting into */ + Select pSelect, /* A SELECT statement to use as the data source */ + int onError, /* How to handle constraint errors */ + int iDbDest /* The database of pDest */ + ) + { + ExprList pEList; /* The result set of the SELECT */ + Table pSrc; /* The table in the FROM clause of SELECT */ + Index pSrcIdx, pDestIdx; /* Source and destination indices */ + SrcList_item pItem; /* An element of pSelect.pSrc */ + int i; /* Loop counter */ + int iDbSrc; /* The database of pSrc */ + int iSrc, iDest; /* Cursors from source and destination */ + int addr1, addr2; /* Loop addresses */ + int emptyDestTest; /* Address of test for empty pDest */ + int emptySrcTest; /* Address of test for empty pSrc */ + Vdbe v; /* The VDBE we are building */ + KeyInfo pKey; /* Key information for an index */ + int regAutoinc; /* Memory register used by AUTOINC */ + bool destHasUniqueIdx = false; /* True if pDest has a UNIQUE index */ + int regData, regRowid; /* Registers holding data and rowid */ + + if ( pSelect == null ) + { + return 0; /* Must be of the form INSERT INTO ... SELECT ... */ + } #if !SQLITE_OMIT_TRIGGER - if (sqlite3TriggerList(pParse, pDest) != null) { - return 0; /* tab1 must not have triggers */ - } + if ( sqlite3TriggerList( pParse, pDest ) != null ) + { + return 0; /* tab1 must not have triggers */ + } #endif - if ((pDest.tabFlags & TF_Virtual) != 0) { - return 0; /* tab1 must not be a virtual table */ - } - if (onError == OE_Default) { - onError = OE_Abort; - } - if (onError != OE_Abort && onError != OE_Rollback) { - return 0; /* Cannot do OR REPLACE or OR IGNORE or OR FAIL */ - } - Debug.Assert(pSelect.pSrc != null); /* allocated even if there is no FROM clause */ - if (pSelect.pSrc.nSrc != 1) { - return 0; /* FROM clause must have exactly one term */ - } - if (pSelect.pSrc.a[0].pSelect != null) { - return 0; /* FROM clause cannot contain a subquery */ - } - if (pSelect.pWhere != null) { - return 0; /* SELECT may not have a WHERE clause */ - } - if (pSelect.pOrderBy != null) { - return 0; /* SELECT may not have an ORDER BY clause */ - } - /* Do not need to test for a HAVING clause. If HAVING is present but - ** there is no ORDER BY, we will get an error. */ - if (pSelect.pGroupBy != null) { - return 0; /* SELECT may not have a GROUP BY clause */ - } - if (pSelect.pLimit != null) { - return 0; /* SELECT may not have a LIMIT clause */ - } - Debug.Assert(pSelect.pOffset == null); /* Must be so if pLimit==0 */ - if (pSelect.pPrior != null) { - return 0; /* SELECT may not be a compound query */ - } - if ((pSelect.selFlags & SF_Distinct) != 0) { - return 0; /* SELECT may not be DISTINCT */ - } - pEList = pSelect.pEList; - Debug.Assert(pEList != null); - if (pEList.nExpr != 1) { - return 0; /* The result set must have exactly one column */ - } - Debug.Assert(pEList.a[0].pExpr != null); - if (pEList.a[0].pExpr.op != TK_ALL) { - return 0; /* The result set must be the special operator "*" */ - } + if ( ( pDest.tabFlags & TF_Virtual ) != 0 ) + { + return 0; /* tab1 must not be a virtual table */ + } + if ( onError == OE_Default ) + { + onError = OE_Abort; + } + if ( onError != OE_Abort && onError != OE_Rollback ) + { + return 0; /* Cannot do OR REPLACE or OR IGNORE or OR FAIL */ + } + Debug.Assert( pSelect.pSrc != null ); /* allocated even if there is no FROM clause */ + if ( pSelect.pSrc.nSrc != 1 ) + { + return 0; /* FROM clause must have exactly one term */ + } + if ( pSelect.pSrc.a[0].pSelect != null ) + { + return 0; /* FROM clause cannot contain a subquery */ + } + if ( pSelect.pWhere != null ) + { + return 0; /* SELECT may not have a WHERE clause */ + } + if ( pSelect.pOrderBy != null ) + { + return 0; /* SELECT may not have an ORDER BY clause */ + } + /* Do not need to test for a HAVING clause. If HAVING is present but + ** there is no ORDER BY, we will get an error. */ + if ( pSelect.pGroupBy != null ) + { + return 0; /* SELECT may not have a GROUP BY clause */ + } + if ( pSelect.pLimit != null ) + { + return 0; /* SELECT may not have a LIMIT clause */ + } + Debug.Assert( pSelect.pOffset == null ); /* Must be so if pLimit==0 */ + if ( pSelect.pPrior != null ) + { + return 0; /* SELECT may not be a compound query */ + } + if ( ( pSelect.selFlags & SF_Distinct ) != 0 ) + { + return 0; /* SELECT may not be DISTINCT */ + } + pEList = pSelect.pEList; + Debug.Assert( pEList != null ); + if ( pEList.nExpr != 1 ) + { + return 0; /* The result set must have exactly one column */ + } + Debug.Assert( pEList.a[0].pExpr != null ); + if ( pEList.a[0].pExpr.op != TK_ALL ) + { + return 0; /* The result set must be the special operator "*" */ + } - /* At this point we have established that the statement is of the - ** correct syntactic form to participate in this optimization. Now - ** we have to check the semantics. - */ - pItem = pSelect.pSrc.a[0]; - pSrc = sqlite3LocateTable(pParse, 0, pItem.zName, pItem.zDatabase); - if (pSrc == null) { - return 0; /* FROM clause does not contain a real table */ - } - if (pSrc == pDest) { - return 0; /* tab1 and tab2 may not be the same table */ - } - if ((pSrc.tabFlags & TF_Virtual) != 0) { - return 0; /* tab2 must not be a virtual table */ - } - if (pSrc.pSelect != null) { - return 0; /* tab2 may not be a view */ - } - if (pDest.nCol != pSrc.nCol) { - return 0; /* Number of columns must be the same in tab1 and tab2 */ - } - if (pDest.iPKey != pSrc.iPKey) { - return 0; /* Both tables must have the same INTEGER PRIMARY KEY */ - } - for (i = 0; i < pDest.nCol; i++) { - if (pDest.aCol[i].affinity != pSrc.aCol[i].affinity) { - return 0; /* Affinity must be the same on all columns */ - } - if (!xferCompatibleCollation(pDest.aCol[i].zColl, pSrc.aCol[i].zColl)) { - return 0; /* Collating sequence must be the same on all columns */ - } - if (pDest.aCol[i].notNull != 0 && pSrc.aCol[i].notNull == 0) { - return 0; /* tab2 must be NOT NULL if tab1 is */ - } - } - for (pDestIdx = pDest.pIndex; pDestIdx != null; pDestIdx = pDestIdx.pNext) { - if (pDestIdx.onError != OE_None) { - destHasUniqueIdx = true; - } - for (pSrcIdx = pSrc.pIndex; pSrcIdx != null; pSrcIdx = pSrcIdx.pNext) { - if (xferCompatibleIndex(pDestIdx, pSrcIdx)) - break; - } - if (pSrcIdx == null) { - return 0; /* pDestIdx has no corresponding index in pSrc */ - } - } + /* At this point we have established that the statement is of the + ** correct syntactic form to participate in this optimization. Now + ** we have to check the semantics. + */ + pItem = pSelect.pSrc.a[0]; + pSrc = sqlite3LocateTable( pParse, 0, pItem.zName, pItem.zDatabase ); + if ( pSrc == null ) + { + return 0; /* FROM clause does not contain a real table */ + } + if ( pSrc == pDest ) + { + return 0; /* tab1 and tab2 may not be the same table */ + } + if ( ( pSrc.tabFlags & TF_Virtual ) != 0 ) + { + return 0; /* tab2 must not be a virtual table */ + } + if ( pSrc.pSelect != null ) + { + return 0; /* tab2 may not be a view */ + } + if ( pDest.nCol != pSrc.nCol ) + { + return 0; /* Number of columns must be the same in tab1 and tab2 */ + } + if ( pDest.iPKey != pSrc.iPKey ) + { + return 0; /* Both tables must have the same INTEGER PRIMARY KEY */ + } + for ( i = 0; i < pDest.nCol; i++ ) + { + if ( pDest.aCol[i].affinity != pSrc.aCol[i].affinity ) + { + return 0; /* Affinity must be the same on all columns */ + } + if ( !xferCompatibleCollation( pDest.aCol[i].zColl, pSrc.aCol[i].zColl ) ) + { + return 0; /* Collating sequence must be the same on all columns */ + } + if ( pDest.aCol[i].notNull != 0 && pSrc.aCol[i].notNull == 0 ) + { + return 0; /* tab2 must be NOT NULL if tab1 is */ + } + } + for ( pDestIdx = pDest.pIndex; pDestIdx != null; pDestIdx = pDestIdx.pNext ) + { + if ( pDestIdx.onError != OE_None ) + { + destHasUniqueIdx = true; + } + for ( pSrcIdx = pSrc.pIndex; pSrcIdx != null; pSrcIdx = pSrcIdx.pNext ) + { + if ( xferCompatibleIndex( pDestIdx, pSrcIdx ) ) + break; + } + if ( pSrcIdx == null ) + { + return 0; /* pDestIdx has no corresponding index in pSrc */ + } + } #if !SQLITE_OMIT_CHECK - if (pDest.pCheck != null && 0 != sqlite3ExprCompare(pSrc.pCheck, pDest.pCheck)) { - return 0; /* Tables have different CHECK constraints. Ticket #2252 */ - } + if ( pDest.pCheck != null && 0 != sqlite3ExprCompare( pSrc.pCheck, pDest.pCheck ) ) + { + return 0; /* Tables have different CHECK constraints. Ticket #2252 */ + } #endif #if !SQLITE_OMIT_FOREIGN_KEY - /* Disallow the transfer optimization if the destination table constains - ** any foreign key constraints. This is more restrictive than necessary. - ** But the main beneficiary of the transfer optimization is the VACUUM - ** command, and the VACUUM command disables foreign key constraints. So - ** the extra complication to make this rule less restrictive is probably - ** not worth the effort. Ticket [6284df89debdfa61db8073e062908af0c9b6118e] - */ - if ((pParse.db.flags & SQLITE_ForeignKeys) != 0 && pDest.pFKey != null) { - return 0; - } + /* Disallow the transfer optimization if the destination table constains + ** any foreign key constraints. This is more restrictive than necessary. + ** But the main beneficiary of the transfer optimization is the VACUUM + ** command, and the VACUUM command disables foreign key constraints. So + ** the extra complication to make this rule less restrictive is probably + ** not worth the effort. Ticket [6284df89debdfa61db8073e062908af0c9b6118e] + */ + if ( ( pParse.db.flags & SQLITE_ForeignKeys ) != 0 && pDest.pFKey != null ) + { + return 0; + } #endif - /* If we get this far, it means either: - ** - ** * We can always do the transfer if the table contains an - ** an integer primary key - ** - ** * We can conditionally do the transfer if the destination - ** table is empty. - */ -#if SQLITE_TEST + /* If we get this far, it means either: + ** + ** * We can always do the transfer if the table contains an + ** an integer primary key + ** + ** * We can conditionally do the transfer if the destination + ** table is empty. + */ +#if SQLITE_TEST #if !TCLSH sqlite3_xferopt_count++; #else sqlite3_xferopt_count.iValue++; #endif #endif - iDbSrc = sqlite3SchemaToIndex(pParse.db, pSrc.pSchema); - v = sqlite3GetVdbe(pParse); - sqlite3CodeVerifySchema(pParse, iDbSrc); - iSrc = pParse.nTab++; - iDest = pParse.nTab++; - regAutoinc = autoIncBegin(pParse, iDbDest, pDest); - sqlite3OpenTable(pParse, iDest, iDbDest, pDest, OP_OpenWrite); - if ((pDest.iPKey < 0 && pDest.pIndex != null) || destHasUniqueIdx) { - /* If tables do not have an INTEGER PRIMARY KEY and there - ** are indices to be copied and the destination is not empty, - ** we have to disallow the transfer optimization because the - ** the rowids might change which will mess up indexing. - ** - ** Or if the destination has a UNIQUE index and is not empty, - ** we also disallow the transfer optimization because we cannot - ** insure that all entries in the union of DEST and SRC will be - ** unique. - */ - addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iDest, 0); - emptyDestTest = sqlite3VdbeAddOp2(v, OP_Goto, 0, 0); - sqlite3VdbeJumpHere(v, addr1); - } else { - emptyDestTest = 0; - } - sqlite3OpenTable(pParse, iSrc, iDbSrc, pSrc, OP_OpenRead); - emptySrcTest = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0); - regData = sqlite3GetTempReg(pParse); - regRowid = sqlite3GetTempReg(pParse); - if (pDest.iPKey >= 0) { - addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid); - addr2 = sqlite3VdbeAddOp3(v, OP_NotExists, iDest, 0, regRowid); - sqlite3HaltConstraint( - pParse, onError, "PRIMARY KEY must be unique", P4_STATIC); - sqlite3VdbeJumpHere(v, addr2); - autoIncStep(pParse, regAutoinc, regRowid); - } else if (pDest.pIndex == null) { - addr1 = sqlite3VdbeAddOp2(v, OP_NewRowid, iDest, regRowid); - } else { - addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid); - Debug.Assert((pDest.tabFlags & TF_Autoincrement) == 0); - } - sqlite3VdbeAddOp2(v, OP_RowData, iSrc, regData); - sqlite3VdbeAddOp3(v, OP_Insert, iDest, regData, regRowid); - sqlite3VdbeChangeP5(v, OPFLAG_NCHANGE | OPFLAG_LASTROWID | OPFLAG_APPEND); - sqlite3VdbeChangeP4(v, -1, pDest.zName, 0); - sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1); - for (pDestIdx = pDest.pIndex; pDestIdx != null; pDestIdx = pDestIdx.pNext) { - for (pSrcIdx = pSrc.pIndex; pSrcIdx != null; pSrcIdx = pSrcIdx.pNext) { - if (xferCompatibleIndex(pDestIdx, pSrcIdx)) - break; - } - Debug.Assert(pSrcIdx != null); - sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0); - sqlite3VdbeAddOp2(v, OP_Close, iDest, 0); - pKey = sqlite3IndexKeyinfo(pParse, pSrcIdx); - sqlite3VdbeAddOp4(v, OP_OpenRead, iSrc, pSrcIdx.tnum, iDbSrc, - pKey, P4_KEYINFO_HANDOFF); + iDbSrc = sqlite3SchemaToIndex( pParse.db, pSrc.pSchema ); + v = sqlite3GetVdbe( pParse ); + sqlite3CodeVerifySchema( pParse, iDbSrc ); + iSrc = pParse.nTab++; + iDest = pParse.nTab++; + regAutoinc = autoIncBegin( pParse, iDbDest, pDest ); + sqlite3OpenTable( pParse, iDest, iDbDest, pDest, OP_OpenWrite ); + if ( ( pDest.iPKey < 0 && pDest.pIndex != null ) || destHasUniqueIdx ) + { + /* If tables do not have an INTEGER PRIMARY KEY and there + ** are indices to be copied and the destination is not empty, + ** we have to disallow the transfer optimization because the + ** the rowids might change which will mess up indexing. + ** + ** Or if the destination has a UNIQUE index and is not empty, + ** we also disallow the transfer optimization because we cannot + ** insure that all entries in the union of DEST and SRC will be + ** unique. + */ + addr1 = sqlite3VdbeAddOp2( v, OP_Rewind, iDest, 0 ); + emptyDestTest = sqlite3VdbeAddOp2( v, OP_Goto, 0, 0 ); + sqlite3VdbeJumpHere( v, addr1 ); + } + else + { + emptyDestTest = 0; + } + sqlite3OpenTable( pParse, iSrc, iDbSrc, pSrc, OP_OpenRead ); + emptySrcTest = sqlite3VdbeAddOp2( v, OP_Rewind, iSrc, 0 ); + regData = sqlite3GetTempReg( pParse ); + regRowid = sqlite3GetTempReg( pParse ); + if ( pDest.iPKey >= 0 ) + { + addr1 = sqlite3VdbeAddOp2( v, OP_Rowid, iSrc, regRowid ); + addr2 = sqlite3VdbeAddOp3( v, OP_NotExists, iDest, 0, regRowid ); + sqlite3HaltConstraint( + pParse, onError, "PRIMARY KEY must be unique", P4_STATIC ); + sqlite3VdbeJumpHere( v, addr2 ); + autoIncStep( pParse, regAutoinc, regRowid ); + } + else if ( pDest.pIndex == null ) + { + addr1 = sqlite3VdbeAddOp2( v, OP_NewRowid, iDest, regRowid ); + } + else + { + addr1 = sqlite3VdbeAddOp2( v, OP_Rowid, iSrc, regRowid ); + Debug.Assert( ( pDest.tabFlags & TF_Autoincrement ) == 0 ); + } + sqlite3VdbeAddOp2( v, OP_RowData, iSrc, regData ); + sqlite3VdbeAddOp3( v, OP_Insert, iDest, regData, regRowid ); + sqlite3VdbeChangeP5( v, OPFLAG_NCHANGE | OPFLAG_LASTROWID | OPFLAG_APPEND ); + sqlite3VdbeChangeP4( v, -1, pDest.zName, 0 ); + sqlite3VdbeAddOp2( v, OP_Next, iSrc, addr1 ); + for ( pDestIdx = pDest.pIndex; pDestIdx != null; pDestIdx = pDestIdx.pNext ) + { + for ( pSrcIdx = pSrc.pIndex; pSrcIdx != null; pSrcIdx = pSrcIdx.pNext ) + { + if ( xferCompatibleIndex( pDestIdx, pSrcIdx ) ) + break; + } + Debug.Assert( pSrcIdx != null ); + sqlite3VdbeAddOp2( v, OP_Close, iSrc, 0 ); + sqlite3VdbeAddOp2( v, OP_Close, iDest, 0 ); + pKey = sqlite3IndexKeyinfo( pParse, pSrcIdx ); + sqlite3VdbeAddOp4( v, OP_OpenRead, iSrc, pSrcIdx.tnum, iDbSrc, + pKey, P4_KEYINFO_HANDOFF ); #if SQLITE_DEBUG - VdbeComment(v, "%s", pSrcIdx.zName); + VdbeComment( v, "%s", pSrcIdx.zName ); #endif - pKey = sqlite3IndexKeyinfo(pParse, pDestIdx); - sqlite3VdbeAddOp4(v, OP_OpenWrite, iDest, pDestIdx.tnum, iDbDest, - pKey, P4_KEYINFO_HANDOFF); + pKey = sqlite3IndexKeyinfo( pParse, pDestIdx ); + sqlite3VdbeAddOp4( v, OP_OpenWrite, iDest, pDestIdx.tnum, iDbDest, + pKey, P4_KEYINFO_HANDOFF ); #if SQLITE_DEBUG - VdbeComment(v, "%s", pDestIdx.zName); + VdbeComment( v, "%s", pDestIdx.zName ); #endif - 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); - sqlite3VdbeJumpHere(v, addr1); - } - sqlite3VdbeJumpHere(v, emptySrcTest); - sqlite3ReleaseTempReg(pParse, regRowid); - sqlite3ReleaseTempReg(pParse, regData); - sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0); - sqlite3VdbeAddOp2(v, OP_Close, iDest, 0); - if (emptyDestTest != 0) { - sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_OK, 0); - sqlite3VdbeJumpHere(v, emptyDestTest); - sqlite3VdbeAddOp2(v, OP_Close, iDest, 0); - return 0; - } else { - return 1; - } - } -#endif // * SQLITE_OMIT_XFER_OPT */ + 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 ); + sqlite3VdbeJumpHere( v, addr1 ); + } + sqlite3VdbeJumpHere( v, emptySrcTest ); + sqlite3ReleaseTempReg( pParse, regRowid ); + sqlite3ReleaseTempReg( pParse, regData ); + sqlite3VdbeAddOp2( v, OP_Close, iSrc, 0 ); + sqlite3VdbeAddOp2( v, OP_Close, iDest, 0 ); + if ( emptyDestTest != 0 ) + { + sqlite3VdbeAddOp2( v, OP_Halt, SQLITE_OK, 0 ); + sqlite3VdbeJumpHere( v, emptyDestTest ); + sqlite3VdbeAddOp2( v, OP_Close, iDest, 0 ); + return 0; + } + else + { + return 1; + } } +#endif // * SQLITE_OMIT_XFER_OPT */ + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/journal_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/journal_c.cs index e95257878..e6aaf7551 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/journal_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/journal_c.cs @@ -1,38 +1,40 @@ -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2007 August 22 - ** - ** 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 implements a special kind of sqlite3_file object used - ** by SQLite to create journal files if the atomic-write optimization - ** is enabled. - ** - ** The distinctive characteristic of this sqlite3_file is that the - ** actual on disk file is created lazily. When the file is created, - ** the caller specifies a buffer size for an in-memory buffer to - ** be used to service read() and write() requests. The actual file - ** on disk is not created or populated until either: - ** - ** 1) The in-memory representation grows too large for the allocated - ** buffer, or - ** 2) The sqlite3JournalCreate() function is called. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 2007 August 22 + ** + ** 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 implements a special kind of sqlite3_file object used + ** by SQLite to create journal files if the atomic-write optimization + ** is enabled. + ** + ** The distinctive characteristic of this sqlite3_file is that the + ** actual on disk file is created lazily. When the file is created, + ** the caller specifies a buffer size for an in-memory buffer to + ** be used to service read() and write() requests. The actual file + ** on disk is not created or populated until either: + ** + ** 1) The in-memory representation grows too large for the allocated + ** buffer, or + ** 2) The sqlite3JournalCreate() function is called. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ #if SQLITE_ENABLE_ATOMIC_WRITE //#include "sqliteInt.h" @@ -244,5 +246,5 @@ int sqlite3JournalSize(sqlite3_vfs pVfs){ return (pVfs->szOsFile+sizeof(JournalFile)); } #endif - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/keywordhash_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/keywordhash_h.cs index 4d26744ef..1e3389a5c 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/keywordhash_h.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/keywordhash_h.cs @@ -1,40 +1,43 @@ +using System.Diagnostics; using System; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /***** This file contains automatically generated code ****** - ** - ** The code in this file has been automatically generated by - ** - ** sqlite/tool/mkkeywordhash.c - ** - ** The code in this file implements a function that determines whether - ** or not a given identifier is really an SQL keyword. The same thing - ** might be implemented more directly using a hand-written hash table. - ** But by using this automatically generated code, the size of the code - ** is substantially reduced. This is important for embedded applications - ** on platforms with limited memory. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - /* Hash score: 175 */ - /* zText[] encodes 811 bytes of keywords in 541 bytes */ - /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */ - /* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */ - /* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */ - /* UNIQUERYATTACHAVINGROUPDATEBEGINNERELEASEBETWEENOTNULLIKE */ - /* CASCADELETECASECOLLATECREATECURRENT_DATEDETACHIMMEDIATEJOIN */ - /* SERTMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMITWHENWHERENAME */ - /* AFTEREPLACEANDEFAULTAUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSS */ - /* CURRENT_TIMESTAMPRIMARYDEFERREDISTINCTDROPFAILFROMFULLGLOBYIF */ - /* ISNULLORDERESTRICTOUTERIGHTROLLBACKROWUNIONUSINGVACUUMVIEW */ - /* INITIALLY */ - static string zText = new string(new char[540] { +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /***** This file contains automatically generated code ****** + ** + ** The code in this file has been automatically generated by + ** + ** sqlite/tool/mkkeywordhash.c + ** + ** The code in this file implements a function that determines whether + ** or not a given identifier is really an SQL keyword. The same thing + ** might be implemented more directly using a hand-written hash table. + ** But by using this automatically generated code, the size of the code + ** is substantially reduced. This is important for embedded applications + ** on platforms with limited memory. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + /* Hash score: 175 */ + /* zText[] encodes 811 bytes of keywords in 541 bytes */ + /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */ + /* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */ + /* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */ + /* UNIQUERYATTACHAVINGROUPDATEBEGINNERELEASEBETWEENOTNULLIKE */ + /* CASCADELETECASECOLLATECREATECURRENT_DATEDETACHIMMEDIATEJOIN */ + /* SERTMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMITWHENWHERENAME */ + /* AFTEREPLACEANDEFAULTAUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSS */ + /* CURRENT_TIMESTAMPRIMARYDEFERREDISTINCTDROPFAILFROMFULLGLOBYIF */ + /* ISNULLORDERESTRICTOUTERIGHTROLLBACKROWUNIONUSINGVACUUMVIEW */ + /* INITIALLY */ +static string zText = new string( new char[540] { 'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H', 'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G', 'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A', @@ -76,9 +79,9 @@ public partial class Sqlite3 { 'T','R','I','C','T','O','U','T','E','R','I','G','H','T','R','O','L','L', 'B','A','C','K','R','O','W','U','N','I','O','N','U','S','I','N','G','V', 'A','C','U','U','M','V','I','E','W','I','N','I','T','I','A','L','L','Y', -}); +} ); - static byte[] aHash = { //aHash[127] +static byte[] aHash = { //aHash[127] 72, 101, 114, 70, 0, 45, 0, 0, 78, 0, 73, 0, 0, 42, 12, 74, 15, 0, 113, 81, 50, 108, 0, 19, 0, 0, 118, 0, 116, 111, 0, 22, 89, 0, 9, 0, 0, 66, 67, @@ -90,7 +93,7 @@ public partial class Sqlite3 { 58, 46, 80, 0, 0, 90, 40, 0, 112, 0, 36, 0, 0, 29, 0, 82, 59, 60, 0, 20, 57, 0, 52, }; - static byte[] aNext = { //aNext[121] +static byte[] aNext = { //aNext[121] 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -102,7 +105,7 @@ public partial class Sqlite3 { 103, 0, 83, 0, 71, 0, 0, 110, 27, 37, 69, 79, 0, 35, 64, 0, 0, }; - static byte[] aLen = { //aLen[121] +static byte[] aLen = { //aLen[121] 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6, 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6, 11, 6, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10, @@ -114,7 +117,7 @@ public partial class Sqlite3 { 4, 4, 2, 2, 6, 5, 8, 5, 5, 8, 3, 5, 5, 6, 4, 9, 3, }; - static int[] aOffset = { //aOffset[121] + static int[] aOffset = { //aOffset[121] 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33, 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81, 86, 91, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152, @@ -126,171 +129,175 @@ public partial class Sqlite3 { 462, 466, 469, 471, 473, 479, 483, 491, 495, 500, 508, 511, 516, 521, 527, 531, 536, }; - static byte[] aCode = { //aCode[121 - TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE, - TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN, - TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD, - TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE, - TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE, - TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW, - TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT, - TK_INTERSECT, TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO, - TK_OFFSET, TK_OF, TK_SET, TK_TEMP, TK_TEMP, - TK_OR, TK_UNIQUE, TK_QUERY, TK_ATTACH, TK_HAVING, - TK_GROUP, TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RELEASE, - TK_BETWEEN, TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, - TK_LIKE_KW, TK_CASCADE, TK_ASC, TK_DELETE, TK_CASE, - TK_COLLATE, TK_CREATE, TK_CTIME_KW, TK_DETACH, TK_IMMEDIATE, - TK_JOIN, TK_INSERT, TK_MATCH, TK_PLAN, TK_ANALYZE, - TK_PRAGMA, TK_ABORT, TK_VALUES, TK_VIRTUAL, TK_LIMIT, - TK_WHEN, TK_WHERE, TK_RENAME, TK_AFTER, TK_REPLACE, - TK_AND, TK_DEFAULT, TK_AUTOINCR, TK_TO, TK_IN, - TK_CAST, TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, - TK_CTIME_KW, TK_CTIME_KW, TK_PRIMARY, TK_DEFERRED, TK_DISTINCT, - TK_IS, TK_DROP, TK_FAIL, TK_FROM, TK_JOIN_KW, - TK_LIKE_KW, TK_BY, TK_IF, TK_ISNULL, TK_ORDER, - TK_RESTRICT, TK_JOIN_KW, TK_JOIN_KW, TK_ROLLBACK, TK_ROW, - TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_INITIALLY, - TK_ALL, +static byte[] aCode = { //aCode[121 + TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE, + TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN, + TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD, + TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE, + TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE, + TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW, + TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT, + TK_INTERSECT, TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO, + TK_OFFSET, TK_OF, TK_SET, TK_TEMP, TK_TEMP, + TK_OR, TK_UNIQUE, TK_QUERY, TK_ATTACH, TK_HAVING, + TK_GROUP, TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RELEASE, + TK_BETWEEN, TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, + TK_LIKE_KW, TK_CASCADE, TK_ASC, TK_DELETE, TK_CASE, + TK_COLLATE, TK_CREATE, TK_CTIME_KW, TK_DETACH, TK_IMMEDIATE, + TK_JOIN, TK_INSERT, TK_MATCH, TK_PLAN, TK_ANALYZE, + TK_PRAGMA, TK_ABORT, TK_VALUES, TK_VIRTUAL, TK_LIMIT, + TK_WHEN, TK_WHERE, TK_RENAME, TK_AFTER, TK_REPLACE, + TK_AND, TK_DEFAULT, TK_AUTOINCR, TK_TO, TK_IN, + TK_CAST, TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, + TK_CTIME_KW, TK_CTIME_KW, TK_PRIMARY, TK_DEFERRED, TK_DISTINCT, + TK_IS, TK_DROP, TK_FAIL, TK_FROM, TK_JOIN_KW, + TK_LIKE_KW, TK_BY, TK_IF, TK_ISNULL, TK_ORDER, + TK_RESTRICT, TK_JOIN_KW, TK_JOIN_KW, TK_ROLLBACK, TK_ROW, + TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_INITIALLY, + TK_ALL, }; - static int keywordCode(string z, int iOffset, int n) { - int h, i; - if (n < 2) - return TK_ID; - h = ((sqlite3UpperToLower[z[iOffset + 0]]) * 4 ^//(charMap(z[iOffset+0]) * 4) ^ - (sqlite3UpperToLower[z[iOffset + n - 1]] * 3) ^ //(charMap(z[iOffset+n - 1]) * 3) ^ - n) % 127; - for (i = (aHash[h]) - 1; i >= 0; i = (aNext[i]) - 1) { - if (aLen[i] == n && String.Compare(zText, aOffset[i], z, iOffset, n, StringComparison.OrdinalIgnoreCase) == 0) { - testcase(i == 0); /* REINDEX */ - testcase(i == 1); /* INDEXED */ - testcase(i == 2); /* INDEX */ - testcase(i == 3); /* DESC */ - testcase(i == 4); /* ESCAPE */ - testcase(i == 5); /* EACH */ - testcase(i == 6); /* CHECK */ - testcase(i == 7); /* KEY */ - testcase(i == 8); /* BEFORE */ - testcase(i == 9); /* FOREIGN */ - testcase(i == 10); /* FOR */ - testcase(i == 11); /* IGNORE */ - testcase(i == 12); /* REGEXP */ - testcase(i == 13); /* EXPLAIN */ - testcase(i == 14); /* INSTEAD */ - testcase(i == 15); /* ADD */ - testcase(i == 16); /* DATABASE */ - testcase(i == 17); /* AS */ - testcase(i == 18); /* SELECT */ - testcase(i == 19); /* TABLE */ - testcase(i == 20); /* LEFT */ - testcase(i == 21); /* THEN */ - testcase(i == 22); /* END */ - testcase(i == 23); /* DEFERRABLE */ - testcase(i == 24); /* ELSE */ - testcase(i == 25); /* EXCEPT */ - testcase(i == 26); /* TRANSACTION */ - testcase(i == 27); /* ACTION */ - testcase(i == 28); /* ON */ - testcase(i == 29); /* NATURAL */ - testcase(i == 30); /* ALTER */ - testcase(i == 31); /* RAISE */ - testcase(i == 32); /* EXCLUSIVE */ - testcase(i == 33); /* EXISTS */ - testcase(i == 34); /* SAVEPOINT */ - testcase(i == 35); /* INTERSECT */ - testcase(i == 36); /* TRIGGER */ - testcase(i == 37); /* REFERENCES */ - testcase(i == 38); /* CONSTRAINT */ - testcase(i == 39); /* INTO */ - testcase(i == 40); /* OFFSET */ - testcase(i == 41); /* OF */ - testcase(i == 42); /* SET */ - testcase(i == 43); /* TEMPORARY */ - testcase(i == 44); /* TEMP */ - testcase(i == 45); /* OR */ - testcase(i == 46); /* UNIQUE */ - testcase(i == 47); /* QUERY */ - testcase(i == 48); /* ATTACH */ - testcase(i == 49); /* HAVING */ - testcase(i == 50); /* GROUP */ - testcase(i == 51); /* UPDATE */ - testcase(i == 52); /* BEGIN */ - testcase(i == 53); /* INNER */ - testcase(i == 54); /* RELEASE */ - testcase(i == 55); /* BETWEEN */ - testcase(i == 56); /* NOTNULL */ - testcase(i == 57); /* NOT */ - testcase(i == 58); /* NO */ - testcase(i == 59); /* NULL */ - testcase(i == 60); /* LIKE */ - testcase(i == 61); /* CASCADE */ - testcase(i == 62); /* ASC */ - testcase(i == 63); /* DELETE */ - testcase(i == 64); /* CASE */ - testcase(i == 65); /* COLLATE */ - testcase(i == 66); /* CREATE */ - testcase(i == 67); /* CURRENT_DATE */ - testcase(i == 68); /* DETACH */ - testcase(i == 69); /* IMMEDIATE */ - testcase(i == 70); /* JOIN */ - testcase(i == 71); /* INSERT */ - testcase(i == 72); /* MATCH */ - testcase(i == 73); /* PLAN */ - testcase(i == 74); /* ANALYZE */ - testcase(i == 75); /* PRAGMA */ - testcase(i == 76); /* ABORT */ - testcase(i == 77); /* VALUES */ - testcase(i == 78); /* VIRTUAL */ - testcase(i == 79); /* LIMIT */ - testcase(i == 80); /* WHEN */ - testcase(i == 81); /* WHERE */ - testcase(i == 82); /* RENAME */ - testcase(i == 83); /* AFTER */ - testcase(i == 84); /* REPLACE */ - testcase(i == 85); /* AND */ - testcase(i == 86); /* DEFAULT */ - testcase(i == 87); /* AUTOINCREMENT */ - testcase(i == 88); /* TO */ - testcase(i == 89); /* IN */ - testcase(i == 90); /* CAST */ - testcase(i == 91); /* COLUMN */ - testcase(i == 92); /* COMMIT */ - testcase(i == 93); /* CONFLICT */ - testcase(i == 94); /* CROSS */ - testcase(i == 95); /* CURRENT_TIMESTAMP */ - testcase(i == 96); /* CURRENT_TIME */ - testcase(i == 97); /* PRIMARY */ - testcase(i == 98); /* DEFERRED */ - testcase(i == 99); /* DISTINCT */ - testcase(i == 100); /* IS */ - testcase(i == 101); /* DROP */ - testcase(i == 102); /* FAIL */ - testcase(i == 103); /* FROM */ - testcase(i == 104); /* FULL */ - testcase(i == 105); /* GLOB */ - testcase(i == 106); /* BY */ - testcase(i == 107); /* IF */ - testcase(i == 108); /* ISNULL */ - testcase(i == 109); /* ORDER */ - testcase(i == 110); /* RESTRICT */ - testcase(i == 111); /* OUTER */ - testcase(i == 112); /* RIGHT */ - testcase(i == 113); /* ROLLBACK */ - testcase(i == 114); /* ROW */ - testcase(i == 115); /* UNION */ - testcase(i == 116); /* USING */ - testcase(i == 117); /* VACUUM */ - testcase(i == 118); /* VIEW */ - testcase(i == 119); /* INITIALLY */ - testcase(i == 120); /* ALL */ - return aCode[i]; - } - } - return TK_ID; +static int keywordCode( string z, int iOffset, int n ) +{ + int h, i; + if ( n < 2 ) + return TK_ID; + h = ( ( sqlite3UpperToLower[z[iOffset + 0]] ) * 4 ^//(charMap(z[iOffset+0]) * 4) ^ + ( sqlite3UpperToLower[z[iOffset + n - 1]] * 3 ) ^ //(charMap(z[iOffset+n - 1]) * 3) ^ + n ) % 127; + for ( i = ( aHash[h] ) - 1; i >= 0; i = ( aNext[i] ) - 1 ) + { + if ( aLen[i] == n && String.Compare( zText, aOffset[i], z, iOffset, n, StringComparison.OrdinalIgnoreCase ) == 0 ) + { + testcase( i == 0 ); /* REINDEX */ + testcase( i == 1 ); /* INDEXED */ + testcase( i == 2 ); /* INDEX */ + testcase( i == 3 ); /* DESC */ + testcase( i == 4 ); /* ESCAPE */ + testcase( i == 5 ); /* EACH */ + testcase( i == 6 ); /* CHECK */ + testcase( i == 7 ); /* KEY */ + testcase( i == 8 ); /* BEFORE */ + testcase( i == 9 ); /* FOREIGN */ + testcase( i == 10 ); /* FOR */ + testcase( i == 11 ); /* IGNORE */ + testcase( i == 12 ); /* REGEXP */ + testcase( i == 13 ); /* EXPLAIN */ + testcase( i == 14 ); /* INSTEAD */ + testcase( i == 15 ); /* ADD */ + testcase( i == 16 ); /* DATABASE */ + testcase( i == 17 ); /* AS */ + testcase( i == 18 ); /* SELECT */ + testcase( i == 19 ); /* TABLE */ + testcase( i == 20 ); /* LEFT */ + testcase( i == 21 ); /* THEN */ + testcase( i == 22 ); /* END */ + testcase( i == 23 ); /* DEFERRABLE */ + testcase( i == 24 ); /* ELSE */ + testcase( i == 25 ); /* EXCEPT */ + testcase( i == 26 ); /* TRANSACTION */ + testcase( i == 27 ); /* ACTION */ + testcase( i == 28 ); /* ON */ + testcase( i == 29 ); /* NATURAL */ + testcase( i == 30 ); /* ALTER */ + testcase( i == 31 ); /* RAISE */ + testcase( i == 32 ); /* EXCLUSIVE */ + testcase( i == 33 ); /* EXISTS */ + testcase( i == 34 ); /* SAVEPOINT */ + testcase( i == 35 ); /* INTERSECT */ + testcase( i == 36 ); /* TRIGGER */ + testcase( i == 37 ); /* REFERENCES */ + testcase( i == 38 ); /* CONSTRAINT */ + testcase( i == 39 ); /* INTO */ + testcase( i == 40 ); /* OFFSET */ + testcase( i == 41 ); /* OF */ + testcase( i == 42 ); /* SET */ + testcase( i == 43 ); /* TEMPORARY */ + testcase( i == 44 ); /* TEMP */ + testcase( i == 45 ); /* OR */ + testcase( i == 46 ); /* UNIQUE */ + testcase( i == 47 ); /* QUERY */ + testcase( i == 48 ); /* ATTACH */ + testcase( i == 49 ); /* HAVING */ + testcase( i == 50 ); /* GROUP */ + testcase( i == 51 ); /* UPDATE */ + testcase( i == 52 ); /* BEGIN */ + testcase( i == 53 ); /* INNER */ + testcase( i == 54 ); /* RELEASE */ + testcase( i == 55 ); /* BETWEEN */ + testcase( i == 56 ); /* NOTNULL */ + testcase( i == 57 ); /* NOT */ + testcase( i == 58 ); /* NO */ + testcase( i == 59 ); /* NULL */ + testcase( i == 60 ); /* LIKE */ + testcase( i == 61 ); /* CASCADE */ + testcase( i == 62 ); /* ASC */ + testcase( i == 63 ); /* DELETE */ + testcase( i == 64 ); /* CASE */ + testcase( i == 65 ); /* COLLATE */ + testcase( i == 66 ); /* CREATE */ + testcase( i == 67 ); /* CURRENT_DATE */ + testcase( i == 68 ); /* DETACH */ + testcase( i == 69 ); /* IMMEDIATE */ + testcase( i == 70 ); /* JOIN */ + testcase( i == 71 ); /* INSERT */ + testcase( i == 72 ); /* MATCH */ + testcase( i == 73 ); /* PLAN */ + testcase( i == 74 ); /* ANALYZE */ + testcase( i == 75 ); /* PRAGMA */ + testcase( i == 76 ); /* ABORT */ + testcase( i == 77 ); /* VALUES */ + testcase( i == 78 ); /* VIRTUAL */ + testcase( i == 79 ); /* LIMIT */ + testcase( i == 80 ); /* WHEN */ + testcase( i == 81 ); /* WHERE */ + testcase( i == 82 ); /* RENAME */ + testcase( i == 83 ); /* AFTER */ + testcase( i == 84 ); /* REPLACE */ + testcase( i == 85 ); /* AND */ + testcase( i == 86 ); /* DEFAULT */ + testcase( i == 87 ); /* AUTOINCREMENT */ + testcase( i == 88 ); /* TO */ + testcase( i == 89 ); /* IN */ + testcase( i == 90 ); /* CAST */ + testcase( i == 91 ); /* COLUMN */ + testcase( i == 92 ); /* COMMIT */ + testcase( i == 93 ); /* CONFLICT */ + testcase( i == 94 ); /* CROSS */ + testcase( i == 95 ); /* CURRENT_TIMESTAMP */ + testcase( i == 96 ); /* CURRENT_TIME */ + testcase( i == 97 ); /* PRIMARY */ + testcase( i == 98 ); /* DEFERRED */ + testcase( i == 99 ); /* DISTINCT */ + testcase( i == 100 ); /* IS */ + testcase( i == 101 ); /* DROP */ + testcase( i == 102 ); /* FAIL */ + testcase( i == 103 ); /* FROM */ + testcase( i == 104 ); /* FULL */ + testcase( i == 105 ); /* GLOB */ + testcase( i == 106 ); /* BY */ + testcase( i == 107 ); /* IF */ + testcase( i == 108 ); /* ISNULL */ + testcase( i == 109 ); /* ORDER */ + testcase( i == 110 ); /* RESTRICT */ + testcase( i == 111 ); /* OUTER */ + testcase( i == 112 ); /* RIGHT */ + testcase( i == 113 ); /* ROLLBACK */ + testcase( i == 114 ); /* ROW */ + testcase( i == 115 ); /* UNION */ + testcase( i == 116 ); /* USING */ + testcase( i == 117 ); /* VACUUM */ + testcase( i == 118 ); /* VIEW */ + testcase( i == 119 ); /* INITIALLY */ + testcase( i == 120 ); /* ALL */ + return aCode[i]; } - static int sqlite3KeywordCode(string z, int n) { - return keywordCode(z, 0, n); - } - public const int SQLITE_N_KEYWORD = 121;//#define SQLITE_N_KEYWORD 121 + } + return TK_ID; + } + static int sqlite3KeywordCode( string z, int n ) + { + return keywordCode( z, 0, n ); } + public const int SQLITE_N_KEYWORD = 121;//#define SQLITE_N_KEYWORD 121 + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/legacy_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/legacy_c.cs index 40fbeb5d5..69f76bef2 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/legacy_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/legacy_c.cs @@ -1,208 +1,235 @@ +using System; using System.Diagnostics; +using System.Text; + +namespace Community.CsharpSqlite +{ + using sqlite3_callback = Sqlite3.dxCallback; + using sqlite3_stmt = Sqlite3.Vdbe; + + public partial class Sqlite3 + { + /* + ** 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. + ** + ************************************************************************* + ** Main file for the SQLite library. The routines in this file + ** implement the programmer interface to the library. Routines in + ** other files are for internal use by SQLite and should not be + ** accessed by users of the library. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + + //#include "sqliteInt.h" + + /* + ** Execute SQL code. Return one of the SQLITE_ success/failure + ** codes. Also write an error message into memory obtained from + ** malloc() and make pzErrMsg point to that message. + ** + ** If the SQL is a query, then for each row in the query result + ** the xCallback() function is called. pArg becomes the first + ** argument to xCallback(). If xCallback=NULL then no callback + ** is invoked, even for queries. + */ + //C# Alias + static public int exec( sqlite3 db, /* The database on which the SQL executes */ string zSql, /* The SQL to be executed */ int NoCallback, int NoArgs, int NoErrors ) + { + string Errors = ""; + return sqlite3_exec( db, zSql, null, null, ref Errors ); + } -namespace Community.CsharpSqlite { - using sqlite3_callback = Sqlite3.dxCallback; - using sqlite3_stmt = Sqlite3.Vdbe; - - public partial class Sqlite3 { - /* - ** 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. - ** - ************************************************************************* - ** Main file for the SQLite library. The routines in this file - ** implement the programmer interface to the library. Routines in - ** other files are for internal use by SQLite and should not be - ** accessed by users of the library. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - - //#include "sqliteInt.h" - - /* - ** Execute SQL code. Return one of the SQLITE_ success/failure - ** codes. Also write an error message into memory obtained from - ** malloc() and make pzErrMsg point to that message. - ** - ** If the SQL is a query, then for each row in the query result - ** the xCallback() function is called. pArg becomes the first - ** argument to xCallback(). If xCallback=NULL then no callback - ** is invoked, even for queries. - */ - //C# Alias - static public int exec(sqlite3 db, /* The database on which the SQL executes */ string zSql, /* The SQL to be executed */ int NoCallback, int NoArgs, int NoErrors) { - string Errors = ""; - return sqlite3_exec(db, zSql, null, null, ref Errors); - } + static public int exec( sqlite3 db, /* The database on which the SQL executes */ string zSql, /* The SQL to be executed */ sqlite3_callback xCallback, /* Invoke this callback routine */ object pArg, /* First argument to xCallback() */ int NoErrors ) + { + string Errors = ""; + return sqlite3_exec( db, zSql, xCallback, pArg, ref Errors ); + } + static public int exec( sqlite3 db, /* The database on which the SQL executes */ string zSql, /* The SQL to be executed */ sqlite3_callback xCallback, /* Invoke this callback routine */ object pArg, /* First argument to xCallback() */ ref string pzErrMsg /* Write error messages here */) + { + return sqlite3_exec( db, zSql, xCallback, pArg, ref pzErrMsg ); + } - static public int exec(sqlite3 db, /* The database on which the SQL executes */ string zSql, /* The SQL to be executed */ sqlite3_callback xCallback, /* Invoke this callback routine */ object pArg, /* First argument to xCallback() */ int NoErrors) { - string Errors = ""; - return sqlite3_exec(db, zSql, xCallback, pArg, ref Errors); - } - static public int exec(sqlite3 db, /* The database on which the SQL executes */ string zSql, /* The SQL to be executed */ sqlite3_callback xCallback, /* Invoke this callback routine */ object pArg, /* First argument to xCallback() */ ref string pzErrMsg /* Write error messages here */) { - return sqlite3_exec(db, zSql, xCallback, pArg, ref pzErrMsg); - } + //OVERLOADS + static public int sqlite3_exec( + sqlite3 db, /* The database on which the SQL executes */ + string zSql, /* The SQL to be executed */ + int NoCallback, int NoArgs, int NoErrors + ) + { + string Errors = ""; + return sqlite3_exec( db, zSql, null, null, ref Errors ); + } - //OVERLOADS - static public int sqlite3_exec( - sqlite3 db, /* The database on which the SQL executes */ - string zSql, /* The SQL to be executed */ - int NoCallback, int NoArgs, int NoErrors - ) { - string Errors = ""; - return sqlite3_exec(db, zSql, null, null, ref Errors); + static public int sqlite3_exec( + sqlite3 db, /* The database on which the SQL executes */ + string zSql, /* The SQL to be executed */ + sqlite3_callback xCallback, /* Invoke this callback routine */ + object pArg, /* First argument to xCallback() */ + int NoErrors + ) + { + string Errors = ""; + return sqlite3_exec( db, zSql, xCallback, pArg, ref Errors ); + } + static public int sqlite3_exec( + sqlite3 db, /* The database on which the SQL executes */ + string zSql, /* The SQL to be executed */ + sqlite3_callback xCallback, /* Invoke this callback routine */ + object pArg, /* First argument to xCallback() */ + ref string pzErrMsg /* Write error messages here */ + ) + { + + int rc = SQLITE_OK; /* Return code */ + string zLeftover = ""; /* Tail of unprocessed SQL */ + sqlite3_stmt pStmt = null; /* The current SQL statement */ + string[] azCols = null; /* Names of result columns */ + int nRetry = 0; /* Number of retry attempts */ + int callbackIsInit; /* True if callback data is initialized */ + + if ( !sqlite3SafetyCheckOk( db ) ) + return SQLITE_MISUSE_BKPT(); + + if ( zSql == null ) + zSql = ""; + + sqlite3_mutex_enter( db.mutex ); + sqlite3Error( db, SQLITE_OK, 0 ); + while ( ( rc == SQLITE_OK || ( rc == SQLITE_SCHEMA && ( ++nRetry ) < 2 ) ) && zSql != "" ) + { + int nCol; + string[] azVals = null; + + pStmt = null; + rc = sqlite3_prepare( db, zSql, -1, ref pStmt, ref zLeftover ); + Debug.Assert( rc == SQLITE_OK || pStmt == null ); + if ( rc != SQLITE_OK ) + { + continue; } - - static public int sqlite3_exec( - sqlite3 db, /* The database on which the SQL executes */ - string zSql, /* The SQL to be executed */ - sqlite3_callback xCallback, /* Invoke this callback routine */ - object pArg, /* First argument to xCallback() */ - int NoErrors - ) { - string Errors = ""; - return sqlite3_exec(db, zSql, xCallback, pArg, ref Errors); + if ( pStmt == null ) + { + /* this happens for a comment or white-space */ + zSql = zLeftover; + continue; } - static public int sqlite3_exec( - sqlite3 db, /* The database on which the SQL executes */ - string zSql, /* The SQL to be executed */ - sqlite3_callback xCallback, /* Invoke this callback routine */ - object pArg, /* First argument to xCallback() */ - ref string pzErrMsg /* Write error messages here */ - ) { - - int rc = SQLITE_OK; /* Return code */ - string zLeftover = ""; /* Tail of unprocessed SQL */ - sqlite3_stmt pStmt = null; /* The current SQL statement */ - string[] azCols = null; /* Names of result columns */ - int nRetry = 0; /* Number of retry attempts */ - int callbackIsInit; /* True if callback data is initialized */ - - if (!sqlite3SafetyCheckOk(db)) - return SQLITE_MISUSE_BKPT(); - - if (zSql == null) - zSql = ""; - - sqlite3_mutex_enter(db.mutex); - sqlite3Error(db, SQLITE_OK, 0); - while ((rc == SQLITE_OK || (rc == SQLITE_SCHEMA && (++nRetry) < 2)) && zSql != "") { - int nCol; - string[] azVals = null; - - pStmt = null; - rc = sqlite3_prepare(db, zSql, -1, ref pStmt, ref zLeftover); - Debug.Assert(rc == SQLITE_OK || pStmt == null); - if (rc != SQLITE_OK) { - continue; - } - if (pStmt == null) { - /* this happens for a comment or white-space */ - zSql = zLeftover; - continue; - } - callbackIsInit = 0; - nCol = sqlite3_column_count(pStmt); - - while (true) { - int i; - rc = sqlite3_step(pStmt); - - /* Invoke the callback function if required */ - if (xCallback != null && (SQLITE_ROW == rc || - (SQLITE_DONE == rc && callbackIsInit == 0 - && (db.flags & SQLITE_NullCallback) != 0))) { - if (0 == callbackIsInit) { - azCols = new string[nCol];//sqlite3DbMallocZero(db, 2*nCol*sizeof(const char*) + 1); - //if ( azCols == null ) - //{ - // goto exec_out; - //} - for (i = 0; i < nCol; i++) { - azCols[i] = sqlite3_column_name(pStmt, i); - /* sqlite3VdbeSetColName() installs column names as UTF8 - ** strings so there is no way for sqlite3_column_name() to fail. */ - Debug.Assert(azCols[i] != null); - } - callbackIsInit = 1; - } - if (rc == SQLITE_ROW) { - azVals = new string[nCol];// azCols[nCol]; - for (i = 0; i < nCol; i++) { - azVals[i] = sqlite3_column_text(pStmt, i); - if (azVals[i] == null && sqlite3_column_type(pStmt, i) != SQLITE_NULL) { - //db.mallocFailed = 1; - //goto exec_out; - } - } - } - if (xCallback(pArg, nCol, azVals, azCols) != 0) { - rc = SQLITE_ABORT; - sqlite3VdbeFinalize(ref pStmt); - pStmt = null; - sqlite3Error(db, SQLITE_ABORT, 0); - goto exec_out; - } - } - - if (rc != SQLITE_ROW) { - rc = sqlite3VdbeFinalize(ref pStmt); - pStmt = null; - if (rc != SQLITE_SCHEMA) { - nRetry = 0; - if ((zSql = zLeftover) != "") { - int zindex = 0; - while (zindex < zSql.Length && sqlite3Isspace(zSql[zindex])) - zindex++; - if (zindex != 0) - zSql = zindex < zSql.Length ? zSql.Substring(zindex) : ""; - } - } - break; - } + callbackIsInit = 0; + nCol = sqlite3_column_count( pStmt ); + + while ( true ) + { + int i; + rc = sqlite3_step( pStmt ); + + /* Invoke the callback function if required */ + if ( xCallback != null && ( SQLITE_ROW == rc || + ( SQLITE_DONE == rc && callbackIsInit == 0 + && ( db.flags & SQLITE_NullCallback ) != 0 ) ) ) + { + if ( 0 == callbackIsInit ) + { + azCols = new string[nCol];//sqlite3DbMallocZero(db, 2*nCol*sizeof(const char*) + 1); + //if ( azCols == null ) + //{ + // goto exec_out; + //} + for ( i = 0; i < nCol; i++ ) + { + azCols[i] = sqlite3_column_name( pStmt, i ); + /* sqlite3VdbeSetColName() installs column names as UTF8 + ** strings so there is no way for sqlite3_column_name() to fail. */ + Debug.Assert( azCols[i] != null ); + } + callbackIsInit = 1; + } + if ( rc == SQLITE_ROW ) + { + azVals = new string[nCol];// azCols[nCol]; + for ( i = 0; i < nCol; i++ ) + { + azVals[i] = sqlite3_column_text( pStmt, i ); + if ( azVals[i] == null && sqlite3_column_type( pStmt, i ) != SQLITE_NULL ) + { + //db.mallocFailed = 1; + //goto exec_out; } - - sqlite3DbFree(db, ref azCols); - azCols = null; + } } - - exec_out: - if (pStmt != null) - sqlite3VdbeFinalize(ref pStmt); - sqlite3DbFree(db, ref azCols); - - rc = sqlite3ApiExit(db, rc); - if (rc != SQLITE_OK && ALWAYS(rc == sqlite3_errcode(db)) && pzErrMsg != null) { - //int nErrMsg = 1 + sqlite3Strlen30(sqlite3_errmsg(db)); - //pzErrMsg = sqlite3Malloc(nErrMsg); - //if (pzErrMsg) - //{ - // memcpy(pzErrMsg, sqlite3_errmsg(db), nErrMsg); - //}else{ - //rc = SQLITE_NOMEM; - //sqlite3Error(db, SQLITE_NOMEM, 0); - //} - pzErrMsg = sqlite3_errmsg(db); - } else if (pzErrMsg != "") { - pzErrMsg = ""; + if ( xCallback( pArg, nCol, azVals, azCols ) != 0 ) + { + rc = SQLITE_ABORT; + sqlite3VdbeFinalize( ref pStmt ); + pStmt = null; + sqlite3Error( db, SQLITE_ABORT, 0 ); + goto exec_out; } - - Debug.Assert((rc & db.errMask) == rc); - sqlite3_mutex_leave(db.mutex); - return rc; + } + + if ( rc != SQLITE_ROW ) + { + rc = sqlite3VdbeFinalize( ref pStmt ); + pStmt = null; + if ( rc != SQLITE_SCHEMA ) + { + nRetry = 0; + if ( ( zSql = zLeftover ) != "" ) + { + int zindex = 0; + while ( zindex < zSql.Length && sqlite3Isspace( zSql[zindex] ) ) + zindex++; + if ( zindex != 0 ) + zSql = zindex < zSql.Length ? zSql.Substring( zindex ) : ""; + } + } + break; + } } + + sqlite3DbFree( db, ref azCols ); + azCols = null; + } + +exec_out: + if ( pStmt != null ) + sqlite3VdbeFinalize( ref pStmt ); + sqlite3DbFree( db, ref azCols ); + + rc = sqlite3ApiExit( db, rc ); + if ( rc != SQLITE_OK && ALWAYS( rc == sqlite3_errcode( db ) ) && pzErrMsg != null ) + { + //int nErrMsg = 1 + sqlite3Strlen30(sqlite3_errmsg(db)); + //pzErrMsg = sqlite3Malloc(nErrMsg); + //if (pzErrMsg) + //{ + // memcpy(pzErrMsg, sqlite3_errmsg(db), nErrMsg); + //}else{ + //rc = SQLITE_NOMEM; + //sqlite3Error(db, SQLITE_NOMEM, 0); + //} + pzErrMsg = sqlite3_errmsg( db ); + } + else if ( pzErrMsg != "" ) + { + pzErrMsg = ""; + } + + Debug.Assert( ( rc & db.errMask ) == rc ); + sqlite3_mutex_leave( db.mutex ); + return rc; } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/loadext_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/loadext_c.cs index 0407eac7f..e9b4bafba 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/loadext_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/loadext_c.cs @@ -1,47 +1,48 @@ using System; using System.Diagnostics; -using System.Text; - using HANDLE = System.IntPtr; +using System.Text; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2006 June 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 contains code used to dynamically load extensions into - ** the SQLite library. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 2006 June 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 contains code used to dynamically load extensions into + ** the SQLite library. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ #if !SQLITE_CORE - //#define SQLITE_CORE 1 /* Disable the API redefinition in sqlite3ext.h */ - const int SQLITE_CORE = 1; + //#define SQLITE_CORE 1 /* Disable the API redefinition in sqlite3ext.h */ + const int SQLITE_CORE = 1; #endif - //#include "sqlite3ext.h" - //#include "sqliteInt.h" - //#include + //#include "sqlite3ext.h" + //#include "sqliteInt.h" + //#include #if !SQLITE_OMIT_LOAD_EXTENSION - /* - ** Some API routines are omitted when various features are - ** excluded from a build of SQLite. Substitute a NULL pointer - ** for any missing APIs. - */ + /* +** Some API routines are omitted when various features are +** excluded from a build of SQLite. Substitute a NULL pointer +** for any missing APIs. +*/ #if !SQLITE_ENABLE_COLUMN_METADATA //# define sqlite3_column_database_name 0 //# define sqlite3_column_database_name16 0 @@ -53,37 +54,39 @@ public partial class Sqlite3 { #endif #if SQLITE_OMIT_AUTHORIZATION - //# define sqlite3_set_authorizer 0 + //# define sqlite3_set_authorizer 0 #endif #if SQLITE_OMIT_UTF16 - //# define sqlite3_bind_text16 0 - //# define sqlite3_collation_needed16 0 - //# define sqlite3_column_decltype16 0 - //# define sqlite3_column_name16 0 - //# define sqlite3_column_text16 0 - //# define sqlite3_complete16 0 - //# define sqlite3_create_collation16 0 - //# define sqlite3_create_function16 0 - //# define sqlite3_errmsg16 0 - static string sqlite3_errmsg16(sqlite3 db) { - return ""; - } - //# define sqlite3_open16 0 - //# define sqlite3_prepare16 0 - //# define sqlite3_prepare16_v2 0 - //# define sqlite3_result_error16 0 - //# define sqlite3_result_text16 0 - static void sqlite3_result_text16(sqlite3_context pCtx, string z, int n, dxDel xDel) { - } - //# define sqlite3_result_text16be 0 - //# define sqlite3_result_text16le 0 - //# define sqlite3_value_text16 0 - //# define sqlite3_value_text16be 0 - //# define sqlite3_value_text16le 0 - //# define sqlite3_column_database_name16 0 - //# define sqlite3_column_table_name16 0 - //# define sqlite3_column_origin_name16 0 + //# define sqlite3_bind_text16 0 + //# define sqlite3_collation_needed16 0 + //# define sqlite3_column_decltype16 0 + //# define sqlite3_column_name16 0 + //# define sqlite3_column_text16 0 + //# define sqlite3_complete16 0 + //# define sqlite3_create_collation16 0 + //# define sqlite3_create_function16 0 + //# define sqlite3_errmsg16 0 + static string sqlite3_errmsg16( sqlite3 db ) + { + return ""; + } + //# define sqlite3_open16 0 + //# define sqlite3_prepare16 0 + //# define sqlite3_prepare16_v2 0 + //# define sqlite3_result_error16 0 + //# define sqlite3_result_text16 0 + static void sqlite3_result_text16( sqlite3_context pCtx, string z, int n, dxDel xDel ) + { + } + //# define sqlite3_result_text16be 0 + //# define sqlite3_result_text16le 0 + //# define sqlite3_value_text16 0 + //# define sqlite3_value_text16be 0 + //# define sqlite3_value_text16le 0 + //# define sqlite3_column_database_name16 0 + //# define sqlite3_column_table_name16 0 + //# define sqlite3_column_origin_name16 0 #endif #if SQLITE_OMIT_COMPLETE @@ -108,7 +111,7 @@ static void sqlite3_progress_handler (sqlite3 db, int nOps, dxProgress xPr #endif #if SQLITE_OMIT_SHARED_CACHE - //# define sqlite3_enable_shared_cache 0 + //# define sqlite3_enable_shared_cache 0 #endif #if SQLITE_OMIT_TRACE @@ -117,230 +120,233 @@ static void sqlite3_progress_handler (sqlite3 db, int nOps, dxProgress xPr #endif #if SQLITE_OMIT_GET_TABLE - //# define //sqlite3_free_table 0 - static public int sqlite3_free_table(ref string[] pazResult) { pazResult = null; return 0; } - - static public int sqlite3_get_table( - sqlite3 db, /* An open database */ - string zSql, /* SQL to be evaluated */ - ref string[] pazResult, /* Results of the query */ - ref int pnRow, /* Number of result rows written here */ - object dummy, - ref string pzErrmsg /* Error msg written here */ - ) { - int iDummy = 0; - return sqlite3_get_table(db, zSql, ref pazResult, ref pnRow, ref iDummy, ref pzErrmsg); - } + //# define //sqlite3_free_table 0 + static public int sqlite3_free_table(ref string[] pazResult) { pazResult = null; return 0; } + + static public int sqlite3_get_table( + sqlite3 db, /* An open database */ + string zSql, /* SQL to be evaluated */ + ref string[] pazResult, /* Results of the query */ + ref int pnRow, /* Number of result rows written here */ + object dummy, + ref string pzErrmsg /* Error msg written here */ + ) + { + int iDummy = 0; + return sqlite3_get_table(db, zSql, ref pazResult, ref pnRow, ref iDummy, ref pzErrmsg); + } //# define sqlite3_get_table 0 - static public int sqlite3_get_table( - sqlite3 db, /* An open database */ - string zSql, /* SQL to be evaluated */ - ref string[] pazResult, /* Results of the query */ - ref int pnRow, /* Number of result rows written here */ - ref int pnColumn, /* Number of result columns written here */ - ref string pzErrmsg /* Error msg written here */ - ) { - return 0; - } + static public int sqlite3_get_table( + sqlite3 db, /* An open database */ + string zSql, /* SQL to be evaluated */ + ref string[] pazResult, /* Results of the query */ + ref int pnRow, /* Number of result rows written here */ + ref int pnColumn, /* Number of result columns written here */ + ref string pzErrmsg /* Error msg written here */ + ) + { + return 0; + } #endif #if SQLITE_OMIT_INCRBLOB - //#define sqlite3_bind_zeroblob 0 - //#define sqlite3_blob_bytes 0 - //#define sqlite3_blob_close 0 - //#define sqlite3_blob_open 0 - //#define sqlite3_blob_read 0 - //#define sqlite3_blob_write 0 + //#define sqlite3_bind_zeroblob 0 + //#define sqlite3_blob_bytes 0 + //#define sqlite3_blob_close 0 + //#define sqlite3_blob_open 0 + //#define sqlite3_blob_read 0 + //#define sqlite3_blob_write 0 #endif - /* - ** The following structure contains pointers to all SQLite API routines. - ** A pointer to this structure is passed into extensions when they are - ** loaded so that the extension can make calls back into the SQLite - ** library. - ** - ** When adding new APIs, add them to the bottom of this structure - ** in order to preserve backwards compatibility. - ** - ** Extensions that use newer APIs should first call the - ** sqlite3_libversion_number() to make sure that the API they - ** intend to use is supported by the library. Extensions should - ** also check to make sure that the pointer to the function is - ** not NULL before calling it. - */ - public class sqlite3_api_routines { - public sqlite3 context_db_handle; - }; - - static sqlite3_api_routines sqlite3Apis = new sqlite3_api_routines(); - //{ - // sqlite3_aggregate_context, + /* +** The following structure contains pointers to all SQLite API routines. +** A pointer to this structure is passed into extensions when they are +** loaded so that the extension can make calls back into the SQLite +** library. +** +** When adding new APIs, add them to the bottom of this structure +** in order to preserve backwards compatibility. +** +** Extensions that use newer APIs should first call the +** sqlite3_libversion_number() to make sure that the API they +** intend to use is supported by the library. Extensions should +** also check to make sure that the pointer to the function is +** not NULL before calling it. +*/ + public class sqlite3_api_routines + { + public sqlite3 context_db_handle; + }; + + static sqlite3_api_routines sqlite3Apis = new sqlite3_api_routines(); + //{ + // sqlite3_aggregate_context, #if !SQLITE_OMIT_DEPRECATED / sqlite3_aggregate_count, #else - // 0, + // 0, #endif - // sqlite3_bind_blob, - // sqlite3_bind_double, - // sqlite3_bind_int, - // sqlite3_bind_int64, - // sqlite3_bind_null, - // sqlite3_bind_parameter_count, - // sqlite3_bind_parameter_index, - // sqlite3_bind_parameter_name, - // sqlite3_bind_text, - // sqlite3_bind_text16, - // sqlite3_bind_value, - // sqlite3_busy_handler, - // sqlite3_busy_timeout, - // sqlite3_changes, - // sqlite3_close, - // sqlite3_collation_needed, - // sqlite3_collation_needed16, - // sqlite3_column_blob, - // sqlite3_column_bytes, - // sqlite3_column_bytes16, - // sqlite3_column_count, - // sqlite3_column_database_name, - // sqlite3_column_database_name16, - // sqlite3_column_decltype, - // sqlite3_column_decltype16, - // sqlite3_column_double, - // sqlite3_column_int, - // sqlite3_column_int64, - // sqlite3_column_name, - // sqlite3_column_name16, - // sqlite3_column_origin_name, - // sqlite3_column_origin_name16, - // sqlite3_column_table_name, - // sqlite3_column_table_name16, - // sqlite3_column_text, - // sqlite3_column_text16, - // sqlite3_column_type, - // sqlite3_column_value, - // sqlite3_commit_hook, - // sqlite3_complete, - // sqlite3_complete16, - // sqlite3_create_collation, - // sqlite3_create_collation16, - // sqlite3_create_function, - // sqlite3_create_function16, - // sqlite3_create_module, - // sqlite3_data_count, - // sqlite3_db_handle, - // sqlite3_declare_vtab, - // sqlite3_enable_shared_cache, - // sqlite3_errcode, - // sqlite3_errmsg, - // sqlite3_errmsg16, - // sqlite3_exec, + // sqlite3_bind_blob, + // sqlite3_bind_double, + // sqlite3_bind_int, + // sqlite3_bind_int64, + // sqlite3_bind_null, + // sqlite3_bind_parameter_count, + // sqlite3_bind_parameter_index, + // sqlite3_bind_parameter_name, + // sqlite3_bind_text, + // sqlite3_bind_text16, + // sqlite3_bind_value, + // sqlite3_busy_handler, + // sqlite3_busy_timeout, + // sqlite3_changes, + // sqlite3_close, + // sqlite3_collation_needed, + // sqlite3_collation_needed16, + // sqlite3_column_blob, + // sqlite3_column_bytes, + // sqlite3_column_bytes16, + // sqlite3_column_count, + // sqlite3_column_database_name, + // sqlite3_column_database_name16, + // sqlite3_column_decltype, + // sqlite3_column_decltype16, + // sqlite3_column_double, + // sqlite3_column_int, + // sqlite3_column_int64, + // sqlite3_column_name, + // sqlite3_column_name16, + // sqlite3_column_origin_name, + // sqlite3_column_origin_name16, + // sqlite3_column_table_name, + // sqlite3_column_table_name16, + // sqlite3_column_text, + // sqlite3_column_text16, + // sqlite3_column_type, + // sqlite3_column_value, + // sqlite3_commit_hook, + // sqlite3_complete, + // sqlite3_complete16, + // sqlite3_create_collation, + // sqlite3_create_collation16, + // sqlite3_create_function, + // sqlite3_create_function16, + // sqlite3_create_module, + // sqlite3_data_count, + // sqlite3_db_handle, + // sqlite3_declare_vtab, + // sqlite3_enable_shared_cache, + // sqlite3_errcode, + // sqlite3_errmsg, + // sqlite3_errmsg16, + // sqlite3_exec, #if !SQLITE_OMIT_DEPRECATED //sqlite3_expired, #else - //0, + //0, #endif - // sqlite3_finalize, - // //sqlite3_free, - // //sqlite3_free_table, - // sqlite3_get_autocommit, - // sqlite3_get_auxdata, - // sqlite3_get_table, - // 0, /* Was sqlite3_global_recover(), but that function is deprecated */ - // sqlite3_interrupt, - // sqlite3_last_insert_rowid, - // sqlite3_libversion, - // sqlite3_libversion_number, - // sqlite3_malloc, - // sqlite3_mprintf, - // sqlite3_open, - // sqlite3_open16, - // sqlite3_prepare, - // sqlite3_prepare16, - // sqlite3_profile, - // sqlite3_progress_handler, - // sqlite3_realloc, - // sqlite3_reset, - // sqlite3_result_blob, - // sqlite3_result_double, - // sqlite3_result_error, - // sqlite3_result_error16, - // sqlite3_result_int, - // sqlite3_result_int64, - // sqlite3_result_null, - // sqlite3_result_text, - // sqlite3_result_text16, - // sqlite3_result_text16be, - // sqlite3_result_text16le, - // sqlite3_result_value, - // sqlite3_rollback_hook, - // sqlite3_set_authorizer, - // sqlite3_set_auxdata, - // sqlite3_snprintf, - // sqlite3_step, - // sqlite3_table_column_metadata, + // sqlite3_finalize, + // //sqlite3_free, + // //sqlite3_free_table, + // sqlite3_get_autocommit, + // sqlite3_get_auxdata, + // sqlite3_get_table, + // 0, /* Was sqlite3_global_recover(), but that function is deprecated */ + // sqlite3_interrupt, + // sqlite3_last_insert_rowid, + // sqlite3_libversion, + // sqlite3_libversion_number, + // sqlite3_malloc, + // sqlite3_mprintf, + // sqlite3_open, + // sqlite3_open16, + // sqlite3_prepare, + // sqlite3_prepare16, + // sqlite3_profile, + // sqlite3_progress_handler, + // sqlite3_realloc, + // sqlite3_reset, + // sqlite3_result_blob, + // sqlite3_result_double, + // sqlite3_result_error, + // sqlite3_result_error16, + // sqlite3_result_int, + // sqlite3_result_int64, + // sqlite3_result_null, + // sqlite3_result_text, + // sqlite3_result_text16, + // sqlite3_result_text16be, + // sqlite3_result_text16le, + // sqlite3_result_value, + // sqlite3_rollback_hook, + // sqlite3_set_authorizer, + // sqlite3_set_auxdata, + // sqlite3_snprintf, + // sqlite3_step, + // sqlite3_table_column_metadata, #if !SQLITE_OMIT_DEPRECATED //sqlite3_thread_cleanup, #else - // 0, + // 0, #endif - // sqlite3_total_changes, - // sqlite3_trace, + // sqlite3_total_changes, + // sqlite3_trace, #if !SQLITE_OMIT_DEPRECATED //sqlite3_transfer_bindings, #else - // 0, + // 0, #endif - // sqlite3_update_hook, - // sqlite3_user_data, - // sqlite3_value_blob, - // sqlite3_value_bytes, - // sqlite3_value_bytes16, - // sqlite3_value_double, - // sqlite3_value_int, - // sqlite3_value_int64, - // sqlite3_value_numeric_type, - // sqlite3_value_text, - // sqlite3_value_text16, - // sqlite3_value_text16be, - // sqlite3_value_text16le, - // sqlite3_value_type, - // sqlite3_vmprintf, - // /* - // ** The original API set ends here. All extensions can call any - // ** of the APIs above provided that the pointer is not NULL. But - // ** before calling APIs that follow, extension should check the - // ** sqlite3_libversion_number() to make sure they are dealing with - // ** a library that is new enough to support that API. - // ************************************************************************* - // */ - // sqlite3_overload_function, - - // /* - // ** Added after 3.3.13 - // */ - // sqlite3_prepare_v2, - // sqlite3_prepare16_v2, - // sqlite3_clear_bindings, - - // /* - // ** Added for 3.4.1 - // */ - // sqlite3_create_module_v2, - - // /* - // ** Added for 3.5.0 - // */ - // sqlite3_bind_zeroblob, - // sqlite3_blob_bytes, - // sqlite3_blob_close, - // sqlite3_blob_open, - // sqlite3_blob_read, - // sqlite3_blob_write, - // sqlite3_create_collation_v2, - // sqlite3_file_control, - // sqlite3_memory_highwater, - // sqlite3_memory_used, + // sqlite3_update_hook, + // sqlite3_user_data, + // sqlite3_value_blob, + // sqlite3_value_bytes, + // sqlite3_value_bytes16, + // sqlite3_value_double, + // sqlite3_value_int, + // sqlite3_value_int64, + // sqlite3_value_numeric_type, + // sqlite3_value_text, + // sqlite3_value_text16, + // sqlite3_value_text16be, + // sqlite3_value_text16le, + // sqlite3_value_type, + // sqlite3_vmprintf, + // /* + // ** The original API set ends here. All extensions can call any + // ** of the APIs above provided that the pointer is not NULL. But + // ** before calling APIs that follow, extension should check the + // ** sqlite3_libversion_number() to make sure they are dealing with + // ** a library that is new enough to support that API. + // ************************************************************************* + // */ + // sqlite3_overload_function, + + // /* + // ** Added after 3.3.13 + // */ + // sqlite3_prepare_v2, + // sqlite3_prepare16_v2, + // sqlite3_clear_bindings, + + // /* + // ** Added for 3.4.1 + // */ + // sqlite3_create_module_v2, + + // /* + // ** Added for 3.5.0 + // */ + // sqlite3_bind_zeroblob, + // sqlite3_blob_bytes, + // sqlite3_blob_close, + // sqlite3_blob_open, + // sqlite3_blob_read, + // sqlite3_blob_write, + // sqlite3_create_collation_v2, + // sqlite3_file_control, + // sqlite3_memory_highwater, + // sqlite3_memory_used, #if SQLITE_MUTEX_OMIT // 0, // 0, @@ -348,381 +354,406 @@ public class sqlite3_api_routines { // 0, // 0, #else - // sqlite3MutexAlloc, - // sqlite3_mutex_enter, - // sqlite3_mutex_free, - // sqlite3_mutex_leave, - // sqlite3_mutex_try, +// sqlite3MutexAlloc, +// sqlite3_mutex_enter, +// sqlite3_mutex_free, +// sqlite3_mutex_leave, +// sqlite3_mutex_try, #endif - // sqlite3_open_v2, - // sqlite3_release_memory, - // sqlite3_result_error_nomem, - // sqlite3_result_error_toobig, - // sqlite3_sleep, - // sqlite3_soft_heap_limit, - // sqlite3_vfs_find, - // sqlite3_vfs_register, - // sqlite3_vfs_unregister, - - // /* - // ** Added for 3.5.8 - // */ - // sqlite3_threadsafe, - // sqlite3_result_zeroblob, - // sqlite3_result_error_code, - // sqlite3_test_control, - // sqlite3_randomness, - // sqlite3_context_db_handle, - - // /* - // ** Added for 3.6.0 - // */ - // sqlite3_extended_result_codes, - // sqlite3_limit, - // sqlite3_next_stmt, - // sqlite3_sql, - // sqlite3_status, - - // /* - // ** Added for 3.7.4 - // */ - // sqlite3_backup_finish, - // sqlite3_backup_init, - // sqlite3_backup_pagecount, - // sqlite3_backup_remaining, - // sqlite3_backup_step, - //#if !SQLITE_OMIT_COMPILEOPTION_DIAGS - // sqlite3_compileoption_get, - // sqlite3_compileoption_used, - //#else - // 0, - // 0, - //#endif - // sqlite3_create_function_v2, - // sqlite3_db_config, - // sqlite3_db_mutex, - // sqlite3_db_status, - // sqlite3_extended_errcode, - // sqlite3_log, - // sqlite3_soft_heap_limit64, - // sqlite3_sourceid, - // sqlite3_stmt_status, - // sqlite3_strnicmp, - //#if SQLITE_ENABLE_UNLOCK_NOTIFY - // sqlite3_unlock_notify, - //#else - // 0, - //#endif - //#if !SQLITE_OMIT_WAL - // sqlite3_wal_autocheckpoint, - // sqlite3_wal_checkpoint, - // sqlite3_wal_hook, - //#else - // 0, - // 0, - // 0, - //#endif - //}; - - /* - ** Attempt to load an SQLite extension library contained in the file - ** zFile. The entry point is zProc. zProc may be 0 in which case a - ** default entry point name (sqlite3_extension_init) is used. Use - ** of the default name is recommended. - ** - ** Return SQLITE_OK on success and SQLITE_ERROR if something goes wrong. - ** - ** If an error occurs and pzErrMsg is not 0, then fill pzErrMsg with - ** error message text. The calling function should free this memory - ** by calling sqlite3DbFree(db, ). - */ - static int sqlite3LoadExtension( - sqlite3 db, /* Load the extension into this database connection */ - string zFile, /* Name of the shared library containing extension */ - string zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */ - ref string pzErrMsg /* Put error message here if not 0 */ - ) { - sqlite3_vfs pVfs = db.pVfs; - HANDLE handle; - dxInit xInit; //int (*xInit)(sqlite3*,char**,const sqlite3_api_routines); - StringBuilder zErrmsg = new StringBuilder(100); - //object aHandle; - const int nMsg = 300; - if (pzErrMsg != null) - pzErrMsg = null; - - - /* Ticket #1863. To avoid a creating security problems for older - ** applications that relink against newer versions of SQLite, the - ** ability to run load_extension is turned off by default. One - ** must call sqlite3_enable_load_extension() to turn on extension - ** loading. Otherwise you get the following error. - */ - if ((db.flags & SQLITE_LoadExtension) == 0) { - //if( pzErrMsg != null){ - pzErrMsg = sqlite3_mprintf("not authorized"); - //} - return SQLITE_ERROR; - } - - if (zProc == null || zProc == "") { - zProc = "sqlite3_extension_init"; - } - - handle = sqlite3OsDlOpen(pVfs, zFile); - if (handle == IntPtr.Zero) { - // if( pzErrMsg ){ - pzErrMsg = "";//*pzErrMsg = zErrmsg = sqlite3_malloc(nMsg); - //if( zErrmsg !=null){ - sqlite3_snprintf(nMsg, zErrmsg, - "unable to open shared library [%s]", zFile); - sqlite3OsDlError(pVfs, nMsg - 1, zErrmsg.ToString()); - return SQLITE_ERROR; - } - //xInit = (int()(sqlite3*,char**,const sqlite3_api_routines)) - // sqlite3OsDlSym(pVfs, handle, zProc); - xInit = (dxInit)sqlite3OsDlSym(pVfs, handle, ref zProc); - Debugger.Break(); // TODO -- - //if( xInit==0 ){ - // if( pzErrMsg ){ - // *pzErrMsg = zErrmsg = sqlite3_malloc(nMsg); - // if( zErrmsg ){ - // sqlite3_snprintf(nMsg, zErrmsg, - // "no entry point [%s] in shared library [%s]", zProc,zFile); - // sqlite3OsDlError(pVfs, nMsg-1, zErrmsg); - // } - // sqlite3OsDlClose(pVfs, handle); - // } - // return SQLITE_ERROR; - // }else if( xInit(db, ref zErrmsg, sqlite3Apis) ){ - //// if( pzErrMsg !=null){ - // pzErrMsg = sqlite3_mprintf("error during initialization: %s", zErrmsg); - // //} - // sqlite3DbFree(db,ref zErrmsg); - // sqlite3OsDlClose(pVfs, ref handle); - // return SQLITE_ERROR; - // } - - // /* Append the new shared library handle to the db.aExtension array. */ - // aHandle = sqlite3DbMallocZero(db, sizeof(handle)*db.nExtension+1); - // if( aHandle==null ){ - // return SQLITE_NOMEM; - // } - // if( db.nExtension>0 ){ - // memcpy(aHandle, db.aExtension, sizeof(handle)*(db.nExtension)); - // } - // sqlite3DbFree(db,ref db.aExtension); - // db.aExtension = aHandle; - - // db.aExtension[db.nExtension++] = handle; - return SQLITE_OK; - } + // sqlite3_open_v2, + // sqlite3_release_memory, + // sqlite3_result_error_nomem, + // sqlite3_result_error_toobig, + // sqlite3_sleep, + // sqlite3_soft_heap_limit, + // sqlite3_vfs_find, + // sqlite3_vfs_register, + // sqlite3_vfs_unregister, + + // /* + // ** Added for 3.5.8 + // */ + // sqlite3_threadsafe, + // sqlite3_result_zeroblob, + // sqlite3_result_error_code, + // sqlite3_test_control, + // sqlite3_randomness, + // sqlite3_context_db_handle, + + // /* + // ** Added for 3.6.0 + // */ + // sqlite3_extended_result_codes, + // sqlite3_limit, + // sqlite3_next_stmt, + // sqlite3_sql, + // sqlite3_status, + + // /* + // ** Added for 3.7.4 + // */ + // sqlite3_backup_finish, + // sqlite3_backup_init, + // sqlite3_backup_pagecount, + // sqlite3_backup_remaining, + // sqlite3_backup_step, + //#if !SQLITE_OMIT_COMPILEOPTION_DIAGS + // sqlite3_compileoption_get, + // sqlite3_compileoption_used, + //#else + // 0, + // 0, + //#endif + // sqlite3_create_function_v2, + // sqlite3_db_config, + // sqlite3_db_mutex, + // sqlite3_db_status, + // sqlite3_extended_errcode, + // sqlite3_log, + // sqlite3_soft_heap_limit64, + // sqlite3_sourceid, + // sqlite3_stmt_status, + // sqlite3_strnicmp, + //#if SQLITE_ENABLE_UNLOCK_NOTIFY + // sqlite3_unlock_notify, + //#else + // 0, + //#endif + //#if !SQLITE_OMIT_WAL + // sqlite3_wal_autocheckpoint, + // sqlite3_wal_checkpoint, + // sqlite3_wal_hook, + //#else + // 0, + // 0, + // 0, + //#endif + //}; + + /* + ** Attempt to load an SQLite extension library contained in the file + ** zFile. The entry point is zProc. zProc may be 0 in which case a + ** default entry point name (sqlite3_extension_init) is used. Use + ** of the default name is recommended. + ** + ** Return SQLITE_OK on success and SQLITE_ERROR if something goes wrong. + ** + ** If an error occurs and pzErrMsg is not 0, then fill pzErrMsg with + ** error message text. The calling function should free this memory + ** by calling sqlite3DbFree(db, ). + */ + static int sqlite3LoadExtension( + sqlite3 db, /* Load the extension into this database connection */ + string zFile, /* Name of the shared library containing extension */ + string zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */ + ref string pzErrMsg /* Put error message here if not 0 */ + ) + { + sqlite3_vfs pVfs = db.pVfs; + HANDLE handle; + dxInit xInit; //int (*xInit)(sqlite3*,char**,const sqlite3_api_routines); + StringBuilder zErrmsg = new StringBuilder( 100 ); + //object aHandle; + const int nMsg = 300; + if ( pzErrMsg != null ) + pzErrMsg = null; + + + /* Ticket #1863. To avoid a creating security problems for older + ** applications that relink against newer versions of SQLite, the + ** ability to run load_extension is turned off by default. One + ** must call sqlite3_enable_load_extension() to turn on extension + ** loading. Otherwise you get the following error. + */ + if ( ( db.flags & SQLITE_LoadExtension ) == 0 ) + { + //if( pzErrMsg != null){ + pzErrMsg = sqlite3_mprintf( "not authorized" ); + //} + return SQLITE_ERROR; + } + + if ( zProc == null || zProc == "" ) + { + zProc = "sqlite3_extension_init"; + } + + handle = sqlite3OsDlOpen( pVfs, zFile ); + if ( handle == IntPtr.Zero ) + { + // if( pzErrMsg ){ + pzErrMsg = "";//*pzErrMsg = zErrmsg = sqlite3_malloc(nMsg); + //if( zErrmsg !=null){ + sqlite3_snprintf( nMsg, zErrmsg, + "unable to open shared library [%s]", zFile ); + sqlite3OsDlError( pVfs, nMsg - 1, zErrmsg.ToString() ); + return SQLITE_ERROR; + } + //xInit = (int()(sqlite3*,char**,const sqlite3_api_routines)) + // sqlite3OsDlSym(pVfs, handle, zProc); + xInit = (dxInit)sqlite3OsDlSym( pVfs, handle, ref zProc ); + Debugger.Break(); // TODO -- + //if( xInit==0 ){ + // if( pzErrMsg ){ + // *pzErrMsg = zErrmsg = sqlite3_malloc(nMsg); + // if( zErrmsg ){ + // sqlite3_snprintf(nMsg, zErrmsg, + // "no entry point [%s] in shared library [%s]", zProc,zFile); + // sqlite3OsDlError(pVfs, nMsg-1, zErrmsg); + // } + // sqlite3OsDlClose(pVfs, handle); + // } + // return SQLITE_ERROR; + // }else if( xInit(db, ref zErrmsg, sqlite3Apis) ){ + //// if( pzErrMsg !=null){ + // pzErrMsg = sqlite3_mprintf("error during initialization: %s", zErrmsg); + // //} + // sqlite3DbFree(db,ref zErrmsg); + // sqlite3OsDlClose(pVfs, ref handle); + // return SQLITE_ERROR; + // } + + // /* Append the new shared library handle to the db.aExtension array. */ + // aHandle = sqlite3DbMallocZero(db, sizeof(handle)*db.nExtension+1); + // if( aHandle==null ){ + // return SQLITE_NOMEM; + // } + // if( db.nExtension>0 ){ + // memcpy(aHandle, db.aExtension, sizeof(handle)*(db.nExtension)); + // } + // sqlite3DbFree(db,ref db.aExtension); + // db.aExtension = aHandle; + + // db.aExtension[db.nExtension++] = handle; + return SQLITE_OK; + } - static public int sqlite3_load_extension( - sqlite3 db, /* Load the extension into this database connection */ - string zFile, /* Name of the shared library containing extension */ - string zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */ - ref string pzErrMsg /* Put error message here if not 0 */ - ) { - int rc; - sqlite3_mutex_enter(db.mutex); - rc = sqlite3LoadExtension(db, zFile, zProc, ref pzErrMsg); - rc = sqlite3ApiExit(db, rc); - sqlite3_mutex_leave(db.mutex); - return rc; - } + static public int sqlite3_load_extension( + sqlite3 db, /* Load the extension into this database connection */ + string zFile, /* Name of the shared library containing extension */ + string zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */ + ref string pzErrMsg /* Put error message here if not 0 */ + ) + { + int rc; + sqlite3_mutex_enter( db.mutex ); + rc = sqlite3LoadExtension( db, zFile, zProc, ref pzErrMsg ); + rc = sqlite3ApiExit( db, rc ); + sqlite3_mutex_leave( db.mutex ); + return rc; + } - /* - ** Call this routine when the database connection is closing in order - ** to clean up loaded extensions - */ - static void sqlite3CloseExtensions(sqlite3 db) { - int i; - Debug.Assert(sqlite3_mutex_held(db.mutex)); - for (i = 0; i < db.nExtension; i++) { - sqlite3OsDlClose(db.pVfs, (HANDLE)db.aExtension[i]); - } - sqlite3DbFree(db, ref db.aExtension); - } + /* + ** Call this routine when the database connection is closing in order + ** to clean up loaded extensions + */ + static void sqlite3CloseExtensions( sqlite3 db ) + { + int i; + Debug.Assert( sqlite3_mutex_held( db.mutex ) ); + for ( i = 0; i < db.nExtension; i++ ) + { + sqlite3OsDlClose( db.pVfs, (HANDLE)db.aExtension[i] ); + } + sqlite3DbFree( db, ref db.aExtension ); + } - /* - ** Enable or disable extension loading. Extension loading is disabled by - ** default so as not to open security holes in older applications. - */ - static public int sqlite3_enable_load_extension(sqlite3 db, int onoff) { - sqlite3_mutex_enter(db.mutex); - if (onoff != 0) { - db.flags |= SQLITE_LoadExtension; - } else { - db.flags &= ~SQLITE_LoadExtension; - } - sqlite3_mutex_leave(db.mutex); - return SQLITE_OK; - } + /* + ** Enable or disable extension loading. Extension loading is disabled by + ** default so as not to open security holes in older applications. + */ + static public int sqlite3_enable_load_extension( sqlite3 db, int onoff ) + { + sqlite3_mutex_enter( db.mutex ); + if ( onoff != 0 ) + { + db.flags |= SQLITE_LoadExtension; + } + else + { + db.flags &= ~SQLITE_LoadExtension; + } + sqlite3_mutex_leave( db.mutex ); + return SQLITE_OK; + } #endif //* SQLITE_OMIT_LOAD_EXTENSION */ - /* - ** The auto-extension code added regardless of whether or not extension - ** loading is supported. We need a dummy sqlite3Apis pointer for that - ** code if regular extension loading is not available. This is that - ** dummy pointer. - */ + /* +** The auto-extension code added regardless of whether or not extension +** loading is supported. We need a dummy sqlite3Apis pointer for that +** code if regular extension loading is not available. This is that +** dummy pointer. +*/ #if SQLITE_OMIT_LOAD_EXTENSION const sqlite3_api_routines sqlite3Apis = null; #endif - /* - ** The following object holds the list of automatically loaded - ** extensions. - ** - ** This list is shared across threads. The SQLITE_MUTEX_STATIC_MASTER - ** mutex must be held while accessing this list. + /* +** The following object holds the list of automatically loaded +** extensions. +** +** This list is shared across threads. The SQLITE_MUTEX_STATIC_MASTER +** mutex must be held while accessing this list. +*/ + //typedef struct sqlite3AutoExtList sqlite3AutoExtList; + public class sqlite3AutoExtList + { + public int nExt = 0; /* Number of entries in aExt[] */ + public dxInit[] aExt = null; /* Pointers to the extension init functions */ + public sqlite3AutoExtList( int nExt, dxInit[] aExt ) + { + this.nExt = nExt; + this.aExt = aExt; + } + } + static sqlite3AutoExtList sqlite3Autoext = new sqlite3AutoExtList( 0, null ); + /* The "wsdAutoext" macro will resolve to the autoextension + ** state vector. If writable static data is unsupported on the target, + ** we have to locate the state vector at run-time. In the more common + ** case where writable static data is supported, wsdStat can refer directly + ** to the "sqlite3Autoext" state vector declared above. */ - //typedef struct sqlite3AutoExtList sqlite3AutoExtList; - public class sqlite3AutoExtList { - public int nExt = 0; /* Number of entries in aExt[] */ - public dxInit[] aExt = null; /* Pointers to the extension init functions */ - public sqlite3AutoExtList(int nExt, dxInit[] aExt) { - this.nExt = nExt; - this.aExt = aExt; - } - } - static sqlite3AutoExtList sqlite3Autoext = new sqlite3AutoExtList(0, null); - /* The "wsdAutoext" macro will resolve to the autoextension - ** state vector. If writable static data is unsupported on the target, - ** we have to locate the state vector at run-time. In the more common - ** case where writable static data is supported, wsdStat can refer directly - ** to the "sqlite3Autoext" state vector declared above. - */ #if SQLITE_OMIT_WSD //# define wsdAutoextInit \ sqlite3AutoExtList *x = &GLOBAL(sqlite3AutoExtList,sqlite3Autoext) //# define wsdAutoext x[0] #else - //# define wsdAutoextInit - static void wsdAutoextInit() { - } - //# define wsdAutoext sqlite3Autoext - static sqlite3AutoExtList wsdAutoext = sqlite3Autoext; + //# define wsdAutoextInit + static void wsdAutoextInit() + { + } + //# define wsdAutoext sqlite3Autoext + static sqlite3AutoExtList wsdAutoext = sqlite3Autoext; #endif - /* - ** Register a statically linked extension that is automatically - ** loaded by every new database connection. - */ - static int sqlite3_auto_extension(dxInit xInit) { - int rc = SQLITE_OK; + /* +** Register a statically linked extension that is automatically +** loaded by every new database connection. +*/ + static int sqlite3_auto_extension( dxInit xInit ) + { + int rc = SQLITE_OK; #if !SQLITE_OMIT_AUTOINIT - rc = sqlite3_initialize(); - if (rc != 0) { - return rc; - } else + rc = sqlite3_initialize(); + if ( rc != 0 ) + { + return rc; + } + else #endif - { - int i; + { + int i; #if SQLITE_THREADSAFE - sqlite3_mutex mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); + sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); #else sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); #endif - wsdAutoextInit(); - sqlite3_mutex_enter(mutex); - for (i = 0; i < wsdAutoext.nExt; i++) { - if (wsdAutoext.aExt[i] == xInit) - break; - } - //if( i==wsdAutoext.nExt ){ - // int nByte = (wsdAutoext.nExt+1)*sizeof(wsdAutoext.aExt[0]); - // void **aNew; - // aNew = sqlite3_realloc(wsdAutoext.aExt, nByte); - // if( aNew==0 ){ - // rc = SQLITE_NOMEM; - // }else{ - Array.Resize(ref wsdAutoext.aExt, wsdAutoext.nExt + 1);// wsdAutoext.aExt = aNew; - wsdAutoext.aExt[wsdAutoext.nExt] = xInit; - wsdAutoext.nExt++; - //} - sqlite3_mutex_leave(mutex); - Debug.Assert((rc & 0xff) == rc); - return rc; - } + wsdAutoextInit(); + sqlite3_mutex_enter( mutex ); + for ( i = 0; i < wsdAutoext.nExt; i++ ) + { + if ( wsdAutoext.aExt[i] == xInit ) + break; } + //if( i==wsdAutoext.nExt ){ + // int nByte = (wsdAutoext.nExt+1)*sizeof(wsdAutoext.aExt[0]); + // void **aNew; + // aNew = sqlite3_realloc(wsdAutoext.aExt, nByte); + // if( aNew==0 ){ + // rc = SQLITE_NOMEM; + // }else{ + Array.Resize( ref wsdAutoext.aExt, wsdAutoext.nExt + 1 );// wsdAutoext.aExt = aNew; + wsdAutoext.aExt[wsdAutoext.nExt] = xInit; + wsdAutoext.nExt++; + //} + sqlite3_mutex_leave( mutex ); + Debug.Assert( ( rc & 0xff ) == rc ); + return rc; + } + } - /* - ** Reset the automatic extension loading mechanism. - */ - static void sqlite3_reset_auto_extension() { + /* + ** Reset the automatic extension loading mechanism. + */ + static void sqlite3_reset_auto_extension() + { #if !SQLITE_OMIT_AUTOINIT - if (sqlite3_initialize() == SQLITE_OK) + if ( sqlite3_initialize() == SQLITE_OK ) #endif - { + { #if SQLITE_THREADSAFE - sqlite3_mutex mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); + sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); #else sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); #endif - wsdAutoextInit(); - sqlite3_mutex_enter(mutex); + wsdAutoextInit(); + sqlite3_mutex_enter( mutex ); #if SQLITE_OMIT_WSD //sqlite3_free( ref wsdAutoext.aExt ); wsdAutoext.aExt = null; wsdAutoext.nExt = 0; #else - //sqlite3_free( ref sqlite3Autoext.aExt ); - sqlite3Autoext.aExt = null; - sqlite3Autoext.nExt = 0; + //sqlite3_free( ref sqlite3Autoext.aExt ); + sqlite3Autoext.aExt = null; + sqlite3Autoext.nExt = 0; #endif - sqlite3_mutex_leave(mutex); - } - } + sqlite3_mutex_leave( mutex ); + } + } + + /* + ** Load all automatic extensions. + ** + ** If anything goes wrong, set an error in the database connection. + */ + static void sqlite3AutoLoadExtensions( sqlite3 db ) + { + int i; + bool go = true; + dxInit xInit;//)(sqlite3*,char**,const sqlite3_api_routines); - /* - ** Load all automatic extensions. - ** - ** If anything goes wrong, set an error in the database connection. - */ - static void sqlite3AutoLoadExtensions(sqlite3 db) { - int i; - bool go = true; - dxInit xInit;//)(sqlite3*,char**,const sqlite3_api_routines); - - wsdAutoextInit(); + wsdAutoextInit(); #if SQLITE_OMIT_WSD if ( wsdAutoext.nExt == 0 ) #else - if (sqlite3Autoext.nExt == 0) + if ( sqlite3Autoext.nExt == 0 ) #endif - { - /* Common case: early out without every having to acquire a mutex */ - return; - } - for (i = 0; go; i++) { - string zErrmsg = ""; + { + /* Common case: early out without every having to acquire a mutex */ + return; + } + for ( i = 0; go; i++ ) + { + string zErrmsg = ""; #if SQLITE_THREADSAFE - sqlite3_mutex mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); + sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); #else sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); #endif - sqlite3_mutex_enter(mutex); - if (i >= wsdAutoext.nExt) { - xInit = null; - go = false; - } else { - xInit = (dxInit) - wsdAutoext.aExt[i]; - } - sqlite3_mutex_leave(mutex); - zErrmsg = ""; - if (xInit != null && xInit(db, ref zErrmsg, (sqlite3_api_routines)sqlite3Apis) != 0) { - sqlite3Error(db, SQLITE_ERROR, - "automatic extension loading failed: %s", zErrmsg); - go = false; - } - sqlite3DbFree(db, ref zErrmsg); - } + sqlite3_mutex_enter( mutex ); + if ( i >= wsdAutoext.nExt ) + { + xInit = null; + go = false; + } + else + { + xInit = (dxInit) + wsdAutoext.aExt[i]; + } + sqlite3_mutex_leave( mutex ); + zErrmsg = ""; + if ( xInit != null && xInit( db, ref zErrmsg, (sqlite3_api_routines)sqlite3Apis ) != 0 ) + { + sqlite3Error( db, SQLITE_ERROR, + "automatic extension loading failed: %s", zErrmsg ); + go = false; } + sqlite3DbFree( db, ref zErrmsg ); + } } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/main_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/main_c.cs index cc817d900..81b995857 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/main_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/main_c.cs @@ -2,39 +2,49 @@ using System.Diagnostics; using System.Text; -using i16 = System.Int16; using sqlite_int64 = System.Int64; -using sqlite3_int64 = System.Int64; -using u32 = System.UInt32; +using unsigned = System.Int32; + +using i16 = System.Int16; using u8 = System.Byte; +using u16 = System.UInt16; +using u32 = System.UInt32; +using u64 = System.UInt64; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 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. - ** - ************************************************************************* - ** Main file for the SQLite library. The routines in this file - ** implement the programmer interface to the library. Routines in - ** other files are for internal use by SQLite and should not be - ** accessed by users of the library. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" -#if SQLITE_ENABLE_FTS3 +using Pgno = System.UInt32; +using sqlite3_int64 = System.Int64; + +namespace Community.CsharpSqlite +{ + using sqlite3_value = Sqlite3.Mem; + + public partial class Sqlite3 + { + /* + ** 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. + ** + ************************************************************************* + ** Main file for the SQLite library. The routines in this file + ** implement the programmer interface to the library. Routines in + ** other files are for internal use by SQLite and should not be + ** accessed by users of the library. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" +#if SQLITE_ENABLE_FTS3 //# include "fts3.h" #endif #if SQLITE_ENABLE_RTREE @@ -45,41 +55,45 @@ public partial class Sqlite3 { #endif #if !SQLITE_AMALGAMATION - /* IMPLEMENTATION-OF: R-46656-45156 The sqlite3_version[] string constant - ** contains the text of SQLITE_VERSION macro. - */ - public static string sqlite3_version = SQLITE_VERSION; + /* IMPLEMENTATION-OF: R-46656-45156 The sqlite3_version[] string constant +** contains the text of SQLITE_VERSION macro. +*/ + public static string sqlite3_version = SQLITE_VERSION; #endif - /* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns - ** a pointer to the to the sqlite3_version[] string constant. - */ - public static string sqlite3_libversion() { - return sqlite3_version; - } + /* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns +** a pointer to the to the sqlite3_version[] string constant. +*/ + public static string sqlite3_libversion() + { + return sqlite3_version; + } - /* IMPLEMENTATION-OF: R-63124-39300 The sqlite3_sourceid() function returns a - ** pointer to a string constant whose value is the same as the - ** SQLITE_SOURCE_ID C preprocessor macro. - */ - public static string sqlite3_sourceid() { - return SQLITE_SOURCE_ID; - } + /* IMPLEMENTATION-OF: R-63124-39300 The sqlite3_sourceid() function returns a + ** pointer to a string constant whose value is the same as the + ** SQLITE_SOURCE_ID C preprocessor macro. + */ + public static string sqlite3_sourceid() + { + return SQLITE_SOURCE_ID; + } - /* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function - ** returns an integer equal to SQLITE_VERSION_NUMBER. - */ - public static int sqlite3_libversion_number() { - return SQLITE_VERSION_NUMBER; - } + /* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function + ** returns an integer equal to SQLITE_VERSION_NUMBER. + */ + public static int sqlite3_libversion_number() + { + return SQLITE_VERSION_NUMBER; + } - /* IMPLEMENTATION-OF: R-54823-41343 The sqlite3_threadsafe() function returns - ** zero if and only if SQLite was compiled mutexing code omitted due to - ** the SQLITE_THREADSAFE compile-time option being set to 0. - */ - public static int sqlite3_threadsafe() { - return SQLITE_THREADSAFE; - } + /* IMPLEMENTATION-OF: R-54823-41343 The sqlite3_threadsafe() function returns + ** zero if and only if SQLite was compiled mutexing code omitted due to + ** the SQLITE_THREADSAFE compile-time option being set to 0. + */ + public static int sqlite3_threadsafe() + { + return SQLITE_THREADSAFE; + } #if !SQLITE_OMIT_TRACE && SQLITE_ENABLE_IOTRACE /* @@ -92,61 +106,62 @@ public static int sqlite3_threadsafe() { static void sqlite3IoTrace( string X, params object[] ap ) { } #endif - /* - ** If the following global variable points to a string which is the - ** name of a directory, then that directory will be used to store - ** temporary files. + /* +** If the following global variable points to a string which is the +** name of a directory, then that directory will be used to store +** temporary files. +** +** See also the "PRAGMA temp_store_directory" SQL command. +*/ + static string sqlite3_temp_directory = "";//string sqlite3_temp_directory = 0; + + /* + ** Initialize SQLite. + ** + ** This routine must be called to initialize the memory allocation, + ** VFS, and mutex subsystems prior to doing any serious work with + ** SQLite. But as long as you do not compile with SQLITE_OMIT_AUTOINIT + ** this routine will be called automatically by key routines such as + ** sqlite3_open(). + ** + ** This routine is a no-op except on its very first call for the process, + ** or for the first call after a call to sqlite3_shutdown. + ** + ** The first thread to call this routine runs the initialization to + ** completion. If subsequent threads call this routine before the first + ** thread has finished the initialization process, then the subsequent + ** threads must block until the first thread finishes with the initialization. + ** + ** The first thread might call this routine recursively. Recursive + ** calls to this routine should not block, of course. Otherwise the + ** initialization process would never complete. + ** + ** Let X be the first thread to enter this routine. Let Y be some other + ** thread. Then while the initial invocation of this routine by X is + ** incomplete, it is required that: ** - ** See also the "PRAGMA temp_store_directory" SQL command. + ** * Calls to this routine from Y must block until the outer-most + ** call by X completes. + ** + ** * Recursive calls to this routine from thread X return immediately + ** without blocking. */ - static string sqlite3_temp_directory = "";//string sqlite3_temp_directory = 0; - - /* - ** Initialize SQLite. - ** - ** This routine must be called to initialize the memory allocation, - ** VFS, and mutex subsystems prior to doing any serious work with - ** SQLite. But as long as you do not compile with SQLITE_OMIT_AUTOINIT - ** this routine will be called automatically by key routines such as - ** sqlite3_open(). - ** - ** This routine is a no-op except on its very first call for the process, - ** or for the first call after a call to sqlite3_shutdown. - ** - ** The first thread to call this routine runs the initialization to - ** completion. If subsequent threads call this routine before the first - ** thread has finished the initialization process, then the subsequent - ** threads must block until the first thread finishes with the initialization. - ** - ** The first thread might call this routine recursively. Recursive - ** calls to this routine should not block, of course. Otherwise the - ** initialization process would never complete. - ** - ** Let X be the first thread to enter this routine. Let Y be some other - ** thread. Then while the initial invocation of this routine by X is - ** incomplete, it is required that: - ** - ** * Calls to this routine from Y must block until the outer-most - ** call by X completes. - ** - ** * Recursive calls to this routine from thread X return immediately - ** without blocking. - */ - static public int sqlite3_initialize() { - //-------------------------------------------------------------------- - // Under C#, Need to initialize some static variables - // - if (sqlite3_version == null) - sqlite3_version = SQLITE_VERSION; - if (sqlite3OpcodeProperty == null) - sqlite3OpcodeProperty = OPFLG_INITIALIZER; - if (sqlite3GlobalConfig == null) - sqlite3GlobalConfig = sqlite3Config; - //-------------------------------------------------------------------- - - - sqlite3_mutex pMaster; /* The main static mutex */ - int rc; /* Result code */ + static public int sqlite3_initialize() + { + //-------------------------------------------------------------------- + // Under C#, Need to initialize some static variables + // + if ( sqlite3_version == null ) + sqlite3_version = SQLITE_VERSION; + if ( sqlite3OpcodeProperty == null ) + sqlite3OpcodeProperty = OPFLG_INITIALIZER; + if ( sqlite3GlobalConfig == null ) + sqlite3GlobalConfig = sqlite3Config; + //-------------------------------------------------------------------- + + + sqlite3_mutex pMaster; /* The main static mutex */ + int rc; /* Result code */ #if SQLITE_OMIT_WSD rc = sqlite3_wsd_init(4096, 24); @@ -154,350 +169,405 @@ static public int sqlite3_initialize() { return rc; } #endif - /* If SQLite is already completely initialized, then this call - ** to sqlite3_initialize() should be a no-op. But the initialization - ** must be complete. So isInit must not be set until the very end - ** of this routine. - */ - if (sqlite3GlobalConfig.isInit != 0) - return SQLITE_OK; - - /* Make sure the mutex subsystem is initialized. If unable to - ** initialize the mutex subsystem, return early with the error. - ** If the system is so sick that we are unable to allocate a mutex, - ** there is not much SQLite is going to be able to do. - ** - ** The mutex subsystem must take care of serializing its own - ** initialization. - */ - rc = sqlite3MutexInit(); - if (rc != 0) - return rc; - - /* Initialize the malloc() system and the recursive pInitMutex mutex. - ** This operation is protected by the STATIC_MASTER mutex. Note that - ** MutexAlloc() is called for a static mutex prior to initializing the - ** malloc subsystem - this implies that the allocation of a static - ** mutex must not require support from the malloc subsystem. - */ - pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); - //sqlite3_mutex_enter( pMaster ); - lock (pMaster) { - sqlite3GlobalConfig.isMutexInit = 1; - if (sqlite3GlobalConfig.isMallocInit == 0) { - rc = sqlite3MallocInit(); - } - if (rc == SQLITE_OK) { - sqlite3GlobalConfig.isMallocInit = 1; - if (sqlite3GlobalConfig.pInitMutex == null) { - sqlite3GlobalConfig.pInitMutex = - sqlite3MutexAlloc(SQLITE_MUTEX_RECURSIVE); - if (sqlite3GlobalConfig.bCoreMutex && sqlite3GlobalConfig.pInitMutex == null) { - rc = SQLITE_NOMEM; - } - } - } - if (rc == SQLITE_OK) { - sqlite3GlobalConfig.nRefInitMutex++; - } - } - //sqlite3_mutex_leave( pMaster ); + /* If SQLite is already completely initialized, then this call +** to sqlite3_initialize() should be a no-op. But the initialization +** must be complete. So isInit must not be set until the very end +** of this routine. +*/ + if ( sqlite3GlobalConfig.isInit != 0 ) + return SQLITE_OK; - /* If rc is not SQLITE_OK at this point, then either the malloc - ** subsystem could not be initialized or the system failed to allocate - ** the pInitMutex mutex. Return an error in either case. */ - if (rc != SQLITE_OK) { - return rc; + /* Make sure the mutex subsystem is initialized. If unable to + ** initialize the mutex subsystem, return early with the error. + ** If the system is so sick that we are unable to allocate a mutex, + ** there is not much SQLite is going to be able to do. + ** + ** The mutex subsystem must take care of serializing its own + ** initialization. + */ + rc = sqlite3MutexInit(); + if ( rc != 0 ) + return rc; + + /* Initialize the malloc() system and the recursive pInitMutex mutex. + ** This operation is protected by the STATIC_MASTER mutex. Note that + ** MutexAlloc() is called for a static mutex prior to initializing the + ** malloc subsystem - this implies that the allocation of a static + ** mutex must not require support from the malloc subsystem. + */ + pMaster = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); + //sqlite3_mutex_enter( pMaster ); + lock ( pMaster ) + { + sqlite3GlobalConfig.isMutexInit = 1; + if ( sqlite3GlobalConfig.isMallocInit == 0 ) + { + rc = sqlite3MallocInit(); + } + if ( rc == SQLITE_OK ) + { + sqlite3GlobalConfig.isMallocInit = 1; + if ( sqlite3GlobalConfig.pInitMutex == null ) + { + sqlite3GlobalConfig.pInitMutex = + sqlite3MutexAlloc( SQLITE_MUTEX_RECURSIVE ); + if ( sqlite3GlobalConfig.bCoreMutex && sqlite3GlobalConfig.pInitMutex == null ) + { + rc = SQLITE_NOMEM; } + } + } + if ( rc == SQLITE_OK ) + { + sqlite3GlobalConfig.nRefInitMutex++; + } + } + //sqlite3_mutex_leave( pMaster ); + + /* If rc is not SQLITE_OK at this point, then either the malloc + ** subsystem could not be initialized or the system failed to allocate + ** the pInitMutex mutex. Return an error in either case. */ + if ( rc != SQLITE_OK ) + { + return rc; + } - /* Do the rest of the initialization under the recursive mutex so - ** that we will be able to handle recursive calls into - ** sqlite3_initialize(). The recursive calls normally come through - ** sqlite3_os_init() when it invokes sqlite3_vfs_register(), but other - ** recursive calls might also be possible. - ** - ** IMPLEMENTATION-OF: R-00140-37445 SQLite automatically serializes calls - ** to the xInit method, so the xInit method need not be threadsafe. - ** - ** The following mutex is what serializes access to the appdef pcache xInit - ** methods. The sqlite3_pcache_methods.xInit() all is embedded in the - ** call to sqlite3PcacheInitialize(). - */ - //sqlite3_mutex_enter( sqlite3GlobalConfig.pInitMutex ); - lock (sqlite3GlobalConfig.pInitMutex) { - if (sqlite3GlobalConfig.isInit == 0 && sqlite3GlobalConfig.inProgress == 0) { - sqlite3GlobalConfig.inProgress = 1; + /* Do the rest of the initialization under the recursive mutex so + ** that we will be able to handle recursive calls into + ** sqlite3_initialize(). The recursive calls normally come through + ** sqlite3_os_init() when it invokes sqlite3_vfs_register(), but other + ** recursive calls might also be possible. + ** + ** IMPLEMENTATION-OF: R-00140-37445 SQLite automatically serializes calls + ** to the xInit method, so the xInit method need not be threadsafe. + ** + ** The following mutex is what serializes access to the appdef pcache xInit + ** methods. The sqlite3_pcache_methods.xInit() all is embedded in the + ** call to sqlite3PcacheInitialize(). + */ + //sqlite3_mutex_enter( sqlite3GlobalConfig.pInitMutex ); + lock ( sqlite3GlobalConfig.pInitMutex ) + { + if ( sqlite3GlobalConfig.isInit == 0 && sqlite3GlobalConfig.inProgress == 0 ) + { + sqlite3GlobalConfig.inProgress = 1; #if SQLITE_OMIT_WSD FuncDefHash *pHash = GLOBAL(FuncDefHash, sqlite3GlobalFunctions); memset( pHash, 0, sizeof( sqlite3GlobalFunctions ) ); #else - sqlite3GlobalFunctions = new FuncDefHash(); - ////FuncDefHash pHash = sqlite3GlobalFunctions; + sqlite3GlobalFunctions = new FuncDefHash(); + ////FuncDefHash pHash = sqlite3GlobalFunctions; #endif - sqlite3RegisterGlobalFunctions(); - if (sqlite3GlobalConfig.isPCacheInit == 0) { - rc = sqlite3PcacheInitialize(); - } - if (rc == SQLITE_OK) { - sqlite3GlobalConfig.isPCacheInit = 1; - rc = sqlite3_os_init(); - } - if (rc == SQLITE_OK) { - sqlite3PCacheBufferSetup(sqlite3GlobalConfig.pPage, - sqlite3GlobalConfig.szPage, sqlite3GlobalConfig.nPage); - sqlite3GlobalConfig.isInit = 1; - } - sqlite3GlobalConfig.inProgress = 0; - } - } - //sqlite3_mutex_leave( sqlite3GlobalConfig.pInitMutex ); - - /* Go back under the static mutex and clean up the recursive - ** mutex to prevent a resource leak. - */ - //sqlite3_mutex_enter( pMaster ); - lock (pMaster) { - sqlite3GlobalConfig.nRefInitMutex--; - if (sqlite3GlobalConfig.nRefInitMutex <= 0) { - Debug.Assert(sqlite3GlobalConfig.nRefInitMutex == 0); - //sqlite3_mutex_free( ref sqlite3GlobalConfig.pInitMutex ); - sqlite3GlobalConfig.pInitMutex = null; - } - } - //sqlite3_mutex_leave( pMaster ); + sqlite3RegisterGlobalFunctions(); + if ( sqlite3GlobalConfig.isPCacheInit == 0 ) + { + rc = sqlite3PcacheInitialize(); + } + if ( rc == SQLITE_OK ) + { + sqlite3GlobalConfig.isPCacheInit = 1; + rc = sqlite3_os_init(); + } + if ( rc == SQLITE_OK ) + { + sqlite3PCacheBufferSetup( sqlite3GlobalConfig.pPage, + sqlite3GlobalConfig.szPage, sqlite3GlobalConfig.nPage ); + sqlite3GlobalConfig.isInit = 1; + } + sqlite3GlobalConfig.inProgress = 0; + } + } + //sqlite3_mutex_leave( sqlite3GlobalConfig.pInitMutex ); - /* The following is just a sanity check to make sure SQLite has - ** been compiled correctly. It is important to run this code, but - ** we don't want to run it too often and soak up CPU cycles for no - ** reason. So we run it once during initialization. - */ + /* Go back under the static mutex and clean up the recursive + ** mutex to prevent a resource leak. + */ + //sqlite3_mutex_enter( pMaster ); + lock ( pMaster ) + { + sqlite3GlobalConfig.nRefInitMutex--; + if ( sqlite3GlobalConfig.nRefInitMutex <= 0 ) + { + Debug.Assert( sqlite3GlobalConfig.nRefInitMutex == 0 ); + //sqlite3_mutex_free( ref sqlite3GlobalConfig.pInitMutex ); + sqlite3GlobalConfig.pInitMutex = null; + } + } + //sqlite3_mutex_leave( pMaster ); + + /* The following is just a sanity check to make sure SQLite has + ** been compiled correctly. It is important to run this code, but + ** we don't want to run it too often and soak up CPU cycles for no + ** reason. So we run it once during initialization. + */ #if !NDEBUG #if !SQLITE_OMIT_FLOATING_POINT - /* This section of code's only "output" is via Debug.Assert() statements. */ - if (rc == SQLITE_OK) { - //u64 x = ( ( (u64)1 ) << 63 ) - 1; - //double y; - //Debug.Assert( sizeof( u64 ) == 8 ); - //Debug.Assert( sizeof( u64 ) == sizeof( double ) ); - //memcpy( &y, x, 8 ); - //Debug.Assert( sqlite3IsNaN( y ) ); - } + /* This section of code's only "output" is via Debug.Assert() statements. */ + if ( rc == SQLITE_OK ) + { + //u64 x = ( ( (u64)1 ) << 63 ) - 1; + //double y; + //Debug.Assert( sizeof( u64 ) == 8 ); + //Debug.Assert( sizeof( u64 ) == sizeof( double ) ); + //memcpy( &y, x, 8 ); + //Debug.Assert( sqlite3IsNaN( y ) ); + } #endif #endif - return rc; - } + return rc; + } - /* - ** Undo the effects of sqlite3_initialize(). Must not be called while - ** there are outstanding database connections or memory allocations or - ** while any part of SQLite is otherwise in use in any thread. This - ** routine is not threadsafe. But it is safe to invoke this routine - ** on when SQLite is already shut down. If SQLite is already shut down - ** when this routine is invoked, then this routine is a harmless no-op. - */ - public static int sqlite3_shutdown() { - if (sqlite3GlobalConfig.isInit != 0) { - sqlite3_os_end(); - sqlite3_reset_auto_extension(); - sqlite3GlobalConfig.isInit = 0; - } - if (sqlite3GlobalConfig.isPCacheInit != 0) { - sqlite3PcacheShutdown(); - sqlite3GlobalConfig.isPCacheInit = 0; - } - if (sqlite3GlobalConfig.isMallocInit != 0) { - sqlite3MallocEnd(); - sqlite3GlobalConfig.isMallocInit = 0; - } - if (sqlite3GlobalConfig.isMutexInit != 0) { - sqlite3MutexEnd(); - sqlite3GlobalConfig.isMutexInit = 0; - } - return SQLITE_OK; - } + /* + ** Undo the effects of sqlite3_initialize(). Must not be called while + ** there are outstanding database connections or memory allocations or + ** while any part of SQLite is otherwise in use in any thread. This + ** routine is not threadsafe. But it is safe to invoke this routine + ** on when SQLite is already shut down. If SQLite is already shut down + ** when this routine is invoked, then this routine is a harmless no-op. + */ + public static int sqlite3_shutdown() + { + if ( sqlite3GlobalConfig.isInit != 0 ) + { + sqlite3_os_end(); + sqlite3_reset_auto_extension(); + sqlite3GlobalConfig.isInit = 0; + } + if ( sqlite3GlobalConfig.isPCacheInit != 0 ) + { + sqlite3PcacheShutdown(); + sqlite3GlobalConfig.isPCacheInit = 0; + } + if ( sqlite3GlobalConfig.isMallocInit != 0 ) + { + sqlite3MallocEnd(); + sqlite3GlobalConfig.isMallocInit = 0; + } + if ( sqlite3GlobalConfig.isMutexInit != 0 ) + { + sqlite3MutexEnd(); + sqlite3GlobalConfig.isMutexInit = 0; + } + return SQLITE_OK; + } - /* - ** This API allows applications to modify the global configuration of - ** the SQLite library at run-time. - ** - ** This routine should only be called when there are no outstanding - ** database connections or memory allocations. This routine is not - ** threadsafe. Failure to heed these warnings can lead to unpredictable - ** behavior. - */ - // Overloads for ap assignments - static public int sqlite3_config(int op, sqlite3_pcache_methods ap) { // va_list ap; - int rc = SQLITE_OK; - switch (op) { - case SQLITE_CONFIG_PCACHE: { - /* Specify an alternative malloc implementation */ - sqlite3GlobalConfig.pcache = ap; //sqlite3GlobalConfig.pcache = (sqlite3_pcache_methods)va_arg(ap, "sqlite3_pcache_methods"); - break; - } - } - return rc; - } + /* + ** This API allows applications to modify the global configuration of + ** the SQLite library at run-time. + ** + ** This routine should only be called when there are no outstanding + ** database connections or memory allocations. This routine is not + ** threadsafe. Failure to heed these warnings can lead to unpredictable + ** behavior. + */ + // Overloads for ap assignments + static public int sqlite3_config( int op, sqlite3_pcache_methods ap ) + { // va_list ap; + int rc = SQLITE_OK; + switch ( op ) + { + case SQLITE_CONFIG_PCACHE: + { + /* Specify an alternative malloc implementation */ + sqlite3GlobalConfig.pcache = ap; //sqlite3GlobalConfig.pcache = (sqlite3_pcache_methods)va_arg(ap, "sqlite3_pcache_methods"); + break; + } + } + return rc; + } - static public int sqlite3_config(int op, ref sqlite3_pcache_methods ap) { // va_list ap; - int rc = SQLITE_OK; - switch (op) { - case SQLITE_CONFIG_GETPCACHE: { - if (sqlite3GlobalConfig.pcache.xInit == null) { - sqlite3PCacheSetDefault(); - } - ap = sqlite3GlobalConfig.pcache;//va_arg(ap, sqlite3_pcache_methods) = sqlite3GlobalConfig.pcache; - break; - } + static public int sqlite3_config(int op, ref sqlite3_pcache_methods ap) + { // va_list ap; + int rc = SQLITE_OK; + switch ( op ) + { + case SQLITE_CONFIG_GETPCACHE: + { + if ( sqlite3GlobalConfig.pcache.xInit == null ) + { + sqlite3PCacheSetDefault(); } - return rc; - } + ap = sqlite3GlobalConfig.pcache;//va_arg(ap, sqlite3_pcache_methods) = sqlite3GlobalConfig.pcache; + break; + } + } + return rc; + } - static public int sqlite3_config(int op, sqlite3_mem_methods ap) { // va_list ap; - int rc = SQLITE_OK; - switch (op) { - case SQLITE_CONFIG_MALLOC: { - /* Specify an alternative malloc implementation */ - sqlite3GlobalConfig.m = ap;// (sqlite3_mem_methods)va_arg( ap, "sqlite3_mem_methods" ); - break; - } - } - return rc; - } + static public int sqlite3_config(int op, sqlite3_mem_methods ap) + { // va_list ap; + int rc = SQLITE_OK; + switch ( op ) + { + case SQLITE_CONFIG_MALLOC: + { + /* Specify an alternative malloc implementation */ + sqlite3GlobalConfig.m = ap;// (sqlite3_mem_methods)va_arg( ap, "sqlite3_mem_methods" ); + break; + } + } + return rc; + } - static public int sqlite3_config(int op, ref sqlite3_mem_methods ap) { // va_list ap; - int rc = SQLITE_OK; - switch (op) { - case SQLITE_CONFIG_GETMALLOC: { - /* Retrieve the current malloc() implementation */ - //if ( sqlite3GlobalConfig.m.xMalloc == null ) sqlite3MemSetDefault(); - ap = sqlite3GlobalConfig.m;//va_arg(ap, sqlite3_mem_methods) = sqlite3GlobalConfig.m; - break; - } - } - return rc; - } + static public int sqlite3_config(int op, ref sqlite3_mem_methods ap) + { // va_list ap; + int rc = SQLITE_OK; + switch ( op ) + { + case SQLITE_CONFIG_GETMALLOC: + { + /* Retrieve the current malloc() implementation */ + //if ( sqlite3GlobalConfig.m.xMalloc == null ) sqlite3MemSetDefault(); + ap = sqlite3GlobalConfig.m;//va_arg(ap, sqlite3_mem_methods) = sqlite3GlobalConfig.m; + break; + } + } + return rc; + } #if SQLITE_THREADSAFE // && SQLITE_THREADSAFE>0 - static public int sqlite3_config(int op, sqlite3_mutex_methods ap) { - // va_list ap; - int rc = SQLITE_OK; - switch (op) { - case SQLITE_CONFIG_MUTEX: { - /* Specify an alternative mutex implementation */ - sqlite3GlobalConfig.mutex = ap;// (sqlite3_mutex_methods)va_arg( ap, "sqlite3_mutex_methods" ); - break; - } - } - return rc; - } + static public int sqlite3_config( int op, sqlite3_mutex_methods ap ) + { + // va_list ap; + int rc = SQLITE_OK; + switch ( op ) + { + case SQLITE_CONFIG_MUTEX: + { + /* Specify an alternative mutex implementation */ + sqlite3GlobalConfig.mutex = ap;// (sqlite3_mutex_methods)va_arg( ap, "sqlite3_mutex_methods" ); + break; + } + } + return rc; + } - static public int sqlite3_config(int op, ref sqlite3_mutex_methods ap) { - // va_list ap; - int rc = SQLITE_OK; - switch (op) { - case SQLITE_CONFIG_GETMUTEX: { - /* Retrieve the current mutex implementation */ - ap = sqlite3GlobalConfig.mutex;// *va_arg(ap, sqlite3_mutex_methods) = sqlite3GlobalConfig.mutex; - break; - } - } - return rc; - } + static public int sqlite3_config( int op, ref sqlite3_mutex_methods ap ) + { + // va_list ap; + int rc = SQLITE_OK; + switch ( op ) + { + case SQLITE_CONFIG_GETMUTEX: + { + /* Retrieve the current mutex implementation */ + ap = sqlite3GlobalConfig.mutex;// *va_arg(ap, sqlite3_mutex_methods) = sqlite3GlobalConfig.mutex; + break; + } + } + return rc; + } #endif - static public int sqlite3_config(int op, params object[] ap) { - // va_list ap; - int rc = SQLITE_OK; + static public int sqlite3_config(int op, params object[] ap) + { + // va_list ap; + int rc = SQLITE_OK; + + /* sqlite3_config() shall return SQLITE_MISUSE if it is invoked while + ** the SQLite library is in use. */ + if ( sqlite3GlobalConfig.isInit != 0 ) + return SQLITE_MISUSE_BKPT(); + + lock ( lock_va_list ) + { + va_start( ap, null ); + switch ( op ) + { + + /* Mutex configuration options are only available in a threadsafe + ** compile. + */ +#if SQLITE_THREADSAFE + case SQLITE_CONFIG_SINGLETHREAD: + { + /* Disable all mutexing */ + sqlite3GlobalConfig.bCoreMutex = false; + sqlite3GlobalConfig.bFullMutex = false; + break; + } + case SQLITE_CONFIG_MULTITHREAD: + { + /* Disable mutexing of database connections */ + /* Enable mutexing of core data structures */ + sqlite3GlobalConfig.bCoreMutex = true; + sqlite3GlobalConfig.bFullMutex = false; + break; + } + case SQLITE_CONFIG_SERIALIZED: + { + /* Enable all mutexing */ + sqlite3GlobalConfig.bCoreMutex = true; + sqlite3GlobalConfig.bFullMutex = true; + break; + } + case SQLITE_CONFIG_MUTEX: + { + /* Specify an alternative mutex implementation */ + sqlite3GlobalConfig.mutex = va_arg( ap, (sqlite3_mutex_methods)null ); + break; + } + case SQLITE_CONFIG_GETMUTEX: + { + /* Retrieve the current mutex implementation */ + // TODO -- *va_arg(ap, sqlite3_mutex_methods) = sqlite3GlobalConfig.mutex; + break; + } +#endif + case SQLITE_CONFIG_MALLOC: + { + /* Specify an alternative malloc implementation */ + // TODO -- sqlite3GlobalConfig.m = va_arg(ap, (sqlite3_mem_methods)null); + break; + } + case SQLITE_CONFIG_GETMALLOC: + { + /* Retrieve the current malloc() implementation */ + //if ( sqlite3GlobalConfig.m.xMalloc == null ) sqlite3MemSetDefault(); + // TODO --//va_arg(ap, sqlite3_mem_methods) = sqlite3GlobalConfig.m; + break; + } + case SQLITE_CONFIG_MEMSTATUS: + { + /* Enable or disable the malloc status collection */ + sqlite3GlobalConfig.bMemstat = va_arg( ap, ( Int32 ) 0 ) != 0; + break; + } + case SQLITE_CONFIG_SCRATCH: + { + /* Designate a buffer for scratch memory space */ + sqlite3GlobalConfig.pScratch = va_arg( ap, (Byte[][])null ); + sqlite3GlobalConfig.szScratch = va_arg( ap, (Int32)0 ); + sqlite3GlobalConfig.nScratch = va_arg( ap, ( Int32 ) 0 ); + break; + } - /* sqlite3_config() shall return SQLITE_MISUSE if it is invoked while - ** the SQLite library is in use. */ - if (sqlite3GlobalConfig.isInit != 0) - return SQLITE_MISUSE_BKPT(); + case SQLITE_CONFIG_PAGECACHE: + { + /* Designate a buffer for page cache memory space */ + sqlite3GlobalConfig.pPage = va_arg( ap, (MemPage) null ); + sqlite3GlobalConfig.szPage = va_arg( ap, ( Int32 ) 0 ); + sqlite3GlobalConfig.nPage = va_arg( ap, ( Int32 ) 0 ); + break; + } - lock (lock_va_list) { - va_start(ap, null); - switch (op) { + case SQLITE_CONFIG_PCACHE: + { + /* Specify an alternative page cache implementation */ + // TODO --sqlite3GlobalConfig.pcache = (sqlite3_pcache_methods)va_arg(ap, "sqlite3_pcache_methods"); + break; + } - /* Mutex configuration options are only available in a threadsafe - ** compile. - */ -#if SQLITE_THREADSAFE - case SQLITE_CONFIG_SINGLETHREAD: { - /* Disable all mutexing */ - sqlite3GlobalConfig.bCoreMutex = false; - sqlite3GlobalConfig.bFullMutex = false; - break; - } - case SQLITE_CONFIG_MULTITHREAD: { - /* Disable mutexing of database connections */ - /* Enable mutexing of core data structures */ - sqlite3GlobalConfig.bCoreMutex = true; - sqlite3GlobalConfig.bFullMutex = false; - break; - } - case SQLITE_CONFIG_SERIALIZED: { - /* Enable all mutexing */ - sqlite3GlobalConfig.bCoreMutex = true; - sqlite3GlobalConfig.bFullMutex = true; - break; - } - case SQLITE_CONFIG_MUTEX: { - /* Specify an alternative mutex implementation */ - sqlite3GlobalConfig.mutex = va_arg(ap, (sqlite3_mutex_methods)null); - break; - } - case SQLITE_CONFIG_GETMUTEX: { - /* Retrieve the current mutex implementation */ - // TODO -- *va_arg(ap, sqlite3_mutex_methods) = sqlite3GlobalConfig.mutex; - break; - } -#endif - case SQLITE_CONFIG_MALLOC: { - /* Specify an alternative malloc implementation */ - // TODO -- sqlite3GlobalConfig.m = va_arg(ap, (sqlite3_mem_methods)null); - break; - } - case SQLITE_CONFIG_GETMALLOC: { - /* Retrieve the current malloc() implementation */ - //if ( sqlite3GlobalConfig.m.xMalloc == null ) sqlite3MemSetDefault(); - // TODO --//va_arg(ap, sqlite3_mem_methods) = sqlite3GlobalConfig.m; - break; - } - case SQLITE_CONFIG_MEMSTATUS: { - /* Enable or disable the malloc status collection */ - sqlite3GlobalConfig.bMemstat = va_arg(ap, (Int32)0) != 0; - break; - } - case SQLITE_CONFIG_SCRATCH: { - /* Designate a buffer for scratch memory space */ - sqlite3GlobalConfig.pScratch = va_arg(ap, (Byte[][])null); - sqlite3GlobalConfig.szScratch = va_arg(ap, (Int32)0); - sqlite3GlobalConfig.nScratch = va_arg(ap, (Int32)0); - break; - } - - case SQLITE_CONFIG_PAGECACHE: { - /* Designate a buffer for page cache memory space */ - sqlite3GlobalConfig.pPage = va_arg(ap, (MemPage)null); - sqlite3GlobalConfig.szPage = va_arg(ap, (Int32)0); - sqlite3GlobalConfig.nPage = va_arg(ap, (Int32)0); - break; - } - - case SQLITE_CONFIG_PCACHE: { - /* Specify an alternative page cache implementation */ - // TODO --sqlite3GlobalConfig.pcache = (sqlite3_pcache_methods)va_arg(ap, "sqlite3_pcache_methods"); - break; - } - - case SQLITE_CONFIG_GETPCACHE: { - if (sqlite3GlobalConfig.pcache.xInit == null) { - sqlite3PCacheSetDefault(); - } - // TODO -- *va_arg(ap, sqlite3_pcache_methods) = sqlite3GlobalConfig.pcache; - break; - } + case SQLITE_CONFIG_GETPCACHE: + { + if ( sqlite3GlobalConfig.pcache.xInit == null ) + { + sqlite3PCacheSetDefault(); + } + // TODO -- *va_arg(ap, sqlite3_pcache_methods) = sqlite3GlobalConfig.pcache; + break; + } #if SQLITE_ENABLE_MEMSYS3 || SQLITE_ENABLE_MEMSYS5 case SQLITE_CONFIG_HEAP: { @@ -536,469 +606,530 @@ static public int sqlite3_config(int op, params object[] ap) { } #endif - case SQLITE_CONFIG_LOOKASIDE: { - sqlite3GlobalConfig.szLookaside = va_arg(ap, (Int32)0); - sqlite3GlobalConfig.nLookaside = va_arg(ap, (Int32)0); - break; - } - - /* Record a pointer to the logger funcction and its first argument. - ** The default is NULL. Logging is disabled if the function pointer is - ** NULL. - */ - case SQLITE_CONFIG_LOG: { - /* MSVC is picky about pulling func ptrs from va lists. - ** http://support.microsoft.com/kb/47961 - ** sqlite3GlobalConfig.xLog = va_arg(ap, void()(void*,int,const char)); - */ - //typedef void(*LOGFUNC_t)(void*,int,const char); - sqlite3GlobalConfig.xLog = va_arg(ap, (dxLog)null);//"LOGFUNC_t" ); - sqlite3GlobalConfig.pLogArg = va_arg(ap, (Object)null); - break; - } - case SQLITE_CONFIG_URI: { - sqlite3GlobalConfig.bOpenUri = va_arg(ap, (Boolean)true); - break; - } - default: { - rc = SQLITE_ERROR; - break; - } - } - va_end(ref ap); + case SQLITE_CONFIG_LOOKASIDE: + { + sqlite3GlobalConfig.szLookaside = va_arg( ap, ( Int32 ) 0 ); + sqlite3GlobalConfig.nLookaside = va_arg( ap, ( Int32 ) 0 ); + break; } - return rc; - } - /* - ** Set up the lookaside buffers for a database connection. - ** Return SQLITE_OK on success. - ** If lookaside is already active, return SQLITE_BUSY. - ** - ** The sz parameter is the number of bytes in each lookaside slot. - ** The cnt parameter is the number of slots. If pStart is NULL the - ** space for the lookaside memory is obtained from sqlite3_malloc(). - ** If pStart is not NULL then it is sz*cnt bytes of memory to use for - ** the lookaside memory. - */ - static int setupLookaside(sqlite3 db, byte[] pBuf, int sz, int cnt) { - //void* pStart; - //if ( db.lookaside.nOut ) - //{ - // return SQLITE_BUSY; - //} - ///* Free any existing lookaside buffer for this handle before - //** allocating a new one so we don't have to have space for - //** both at the same time. - //*/ - //if ( db.lookaside.bMalloced ) - //{ - // //sqlite3_free( db.lookaside.pStart ); - //} - ///* The size of a lookaside slot needs to be larger than a pointer - //** to be useful. - //*/ - //if ( sz <= (int)sizeof( LookasideSlot* ) ) sz = 0; - //if ( cnt < 0 ) cnt = 0; - //if ( sz == 0 || cnt == 0 ) - //{ - // sz = 0; - // pStart = 0; - //} - //else if ( pBuf == 0 ) - //{ - // sz = ROUNDDOWN8(sz); /* IMP: R-33038-09382 */ - // sqlite3BeginBenignMalloc(); - // pStart = sqlite3Malloc( sz*cnt ); /* IMP: R-61949-35727 */ - // sqlite3EndBenignMalloc(); - //}else{ - // sz = ROUNDDOWN8(sz); /* IMP: R-33038-09382 */ - // pStart = pBuf; - //} - //db.lookaside.pStart = pStart; - //db.lookaside.pFree = 0; - //db.lookaside.sz = (u16)sz; - //if ( pStart ) - //{ - // int i; - // LookasideSlot* p; - // Debug.Assert( sz > sizeof( LookasideSlot* ) ); - // p = (LookasideSlot)pStart; - // for ( i = cnt - 1 ; i >= 0 ; i-- ) - // { - // p.pNext = db.lookaside.pFree; - // db.lookaside.pFree = p; - // p = (LookasideSlot)&( (u8)p )[sz]; - // } - // db.lookaside.pEnd = p; - // db.lookaside.bEnabled = 1; - // db.lookaside.bMalloced = pBuf == 0 ? 1 : 0; - //} - //else - //{ - // db.lookaside.pEnd = 0; - // db.lookaside.bEnabled = 0; - // db.lookaside.bMalloced = 0; - //} - return SQLITE_OK; + /* Record a pointer to the logger funcction and its first argument. + ** The default is NULL. Logging is disabled if the function pointer is + ** NULL. + */ + case SQLITE_CONFIG_LOG: + { + /* MSVC is picky about pulling func ptrs from va lists. + ** http://support.microsoft.com/kb/47961 + ** sqlite3GlobalConfig.xLog = va_arg(ap, void()(void*,int,const char)); + */ + //typedef void(*LOGFUNC_t)(void*,int,const char); + sqlite3GlobalConfig.xLog = va_arg( ap, (dxLog)null );//"LOGFUNC_t" ); + sqlite3GlobalConfig.pLogArg = va_arg( ap, (Object)null ); + break; + } + case SQLITE_CONFIG_URI: { + sqlite3GlobalConfig.bOpenUri = va_arg( ap, (Boolean)true ); + break; + } + default: + { + rc = SQLITE_ERROR; + break; + } } + va_end( ref ap ); + } + return rc; + } - /* - ** Return the mutex associated with a database connection. - */ - static sqlite3_mutex sqlite3_db_mutex(sqlite3 db) { - return db.mutex; - } + /* + ** Set up the lookaside buffers for a database connection. + ** Return SQLITE_OK on success. + ** If lookaside is already active, return SQLITE_BUSY. + ** + ** The sz parameter is the number of bytes in each lookaside slot. + ** The cnt parameter is the number of slots. If pStart is NULL the + ** space for the lookaside memory is obtained from sqlite3_malloc(). + ** If pStart is not NULL then it is sz*cnt bytes of memory to use for + ** the lookaside memory. + */ + static int setupLookaside( sqlite3 db, byte[] pBuf, int sz, int cnt ) + { + //void* pStart; + //if ( db.lookaside.nOut ) + //{ + // return SQLITE_BUSY; + //} + ///* Free any existing lookaside buffer for this handle before + //** allocating a new one so we don't have to have space for + //** both at the same time. + //*/ + //if ( db.lookaside.bMalloced ) + //{ + // //sqlite3_free( db.lookaside.pStart ); + //} + ///* The size of a lookaside slot needs to be larger than a pointer + //** to be useful. + //*/ + //if ( sz <= (int)sizeof( LookasideSlot* ) ) sz = 0; + //if ( cnt < 0 ) cnt = 0; + //if ( sz == 0 || cnt == 0 ) + //{ + // sz = 0; + // pStart = 0; + //} + //else if ( pBuf == 0 ) + //{ + // sz = ROUNDDOWN8(sz); /* IMP: R-33038-09382 */ + // sqlite3BeginBenignMalloc(); + // pStart = sqlite3Malloc( sz*cnt ); /* IMP: R-61949-35727 */ + // sqlite3EndBenignMalloc(); + //}else{ + // sz = ROUNDDOWN8(sz); /* IMP: R-33038-09382 */ + // pStart = pBuf; + //} + //db.lookaside.pStart = pStart; + //db.lookaside.pFree = 0; + //db.lookaside.sz = (u16)sz; + //if ( pStart ) + //{ + // int i; + // LookasideSlot* p; + // Debug.Assert( sz > sizeof( LookasideSlot* ) ); + // p = (LookasideSlot)pStart; + // for ( i = cnt - 1 ; i >= 0 ; i-- ) + // { + // p.pNext = db.lookaside.pFree; + // db.lookaside.pFree = p; + // p = (LookasideSlot)&( (u8)p )[sz]; + // } + // db.lookaside.pEnd = p; + // db.lookaside.bEnabled = 1; + // db.lookaside.bMalloced = pBuf == 0 ? 1 : 0; + //} + //else + //{ + // db.lookaside.pEnd = 0; + // db.lookaside.bEnabled = 0; + // db.lookaside.bMalloced = 0; + //} + return SQLITE_OK; + } - public class _aFlagOp { - public int op; /* The opcode */ - public u32 mask; /* Mask of the bit in sqlite3.flags to set/clear */ + /* + ** Return the mutex associated with a database connection. + */ + static sqlite3_mutex sqlite3_db_mutex( sqlite3 db ) + { + return db.mutex; + } - public _aFlagOp(int op, u32 mask) { - this.op = op; - this.mask = mask; - } - } + public class _aFlagOp + { + public int op; /* The opcode */ + public u32 mask; /* Mask of the bit in sqlite3.flags to set/clear */ - /* - ** Configuration settings for an individual database connection - */ - static int sqlite3_db_config(sqlite3 db, int op, params object[] ap) { - int rc; - //va_list ap; - lock (lock_va_list) { - va_start(ap, ""); - switch (op) { - case SQLITE_DBCONFIG_LOOKASIDE: { - byte[] pBuf = va_arg(ap, (byte[])null); /* IMP: R-26835-10964 */ - int sz = va_arg(ap, (Int32)0); /* IMP: R-47871-25994 */ - int cnt = va_arg(ap, (Int32)0); /* IMP: R-04460-53386 */ - rc = setupLookaside(db, pBuf, sz, cnt); - break; - } - default: { - _aFlagOp[] aFlagOp = new _aFlagOp[]{ + public _aFlagOp( int op, u32 mask ) + { + this.op = op; + this.mask = mask; + } + } + + /* + ** Configuration settings for an individual database connection + */ + static int sqlite3_db_config( sqlite3 db, int op, params object[] ap ) + { + int rc; + //va_list ap; + lock ( lock_va_list ) + { + va_start( ap, "" ); + switch ( op ) + { + case SQLITE_DBCONFIG_LOOKASIDE: + { + byte[] pBuf = va_arg( ap, (byte[])null ); /* IMP: R-26835-10964 */ + int sz = va_arg( ap, (Int32)0 ); /* IMP: R-47871-25994 */ + int cnt = va_arg( ap, ( Int32 ) 0 ); /* IMP: R-04460-53386 */ + rc = setupLookaside( db, pBuf, sz, cnt ); + break; + } + default: + { + _aFlagOp[] aFlagOp = new _aFlagOp[]{ new _aFlagOp( SQLITE_DBCONFIG_ENABLE_FKEY, SQLITE_ForeignKeys ), new _aFlagOp( SQLITE_DBCONFIG_ENABLE_TRIGGER, SQLITE_EnableTrigger ), }; - uint i; - - rc = SQLITE_ERROR; /* IMP: R-42790-23372 */ - for (i = 0; i < ArraySize(aFlagOp); i++) { - if (aFlagOp[i].op == op) { - int onoff = va_arg(ap, (Int32)0); - int pRes = va_arg(ap, (Int32)0); - int oldFlags = db.flags; - if (onoff > 0) { - db.flags = (int)((u32)db.flags | aFlagOp[i].mask); - } else if (onoff == 0) { - db.flags = (int)(db.flags & ~aFlagOp[i].mask); - } - if (oldFlags != db.flags) { - sqlite3ExpirePreparedStatements(db); - } - if (pRes != 0) { - pRes = (db.flags & aFlagOp[i].mask) != 0 ? 1 : 0; - } - rc = SQLITE_OK; - break; - } - } - break; - } + uint i; + + rc = SQLITE_ERROR; /* IMP: R-42790-23372 */ + for ( i = 0; i < ArraySize( aFlagOp ); i++ ) + { + if ( aFlagOp[i].op == op ) + { + int onoff = va_arg( ap, ( Int32 ) 0 ); + int pRes = va_arg( ap, (Int32)0 ); + int oldFlags = db.flags; + if ( onoff > 0 ) + { + db.flags = (int)( (u32)db.flags | aFlagOp[i].mask ); + } + else if ( onoff == 0 ) + { + db.flags = (int)( db.flags & ~aFlagOp[i].mask ); + } + if ( oldFlags != db.flags ) + { + sqlite3ExpirePreparedStatements( db ); + } + if ( pRes != 0 ) + { + pRes = ( db.flags & aFlagOp[i].mask ) != 0 ? 1 : 0; + } + rc = SQLITE_OK; + break; } - va_end(ref ap); + } + break; } - return rc; } + va_end( ref ap ); + } + return rc; + } - /* - ** Return true if the buffer z[0..n-1] contains all spaces. - */ - static bool allSpaces(string z, int iStart, int n) { - while (n > 0 && z[iStart + n - 1] == ' ') { - n--; - } - return n == 0; - } + /* + ** Return true if the buffer z[0..n-1] contains all spaces. + */ + static bool allSpaces( string z, int iStart, int n ) + { + while ( n > 0 && z[iStart + n - 1] == ' ' ) + { + n--; + } + return n == 0; + } - /* - ** This is the default collating function named "BINARY" which is always - ** available. - ** - ** If the padFlag argument is not NULL then space padding at the end - ** of strings is ignored. This implements the RTRIM collation. - */ - static int binCollFunc( - object padFlag, - int nKey1, string pKey1, - int nKey2, string pKey2 - ) { - int rc, n; - n = nKey1 < nKey2 ? nKey1 : nKey2; - rc = memcmp(pKey1, pKey2, n); - if (rc == 0) { - if ((int)padFlag != 0 && allSpaces(pKey1, n, nKey1 - n) && allSpaces(pKey2, n, nKey2 - n)) { - /* Leave rc unchanged at 0 */ - } else { - rc = nKey1 - nKey2; - } - } - return rc; + /* + ** This is the default collating function named "BINARY" which is always + ** available. + ** + ** If the padFlag argument is not NULL then space padding at the end + ** of strings is ignored. This implements the RTRIM collation. + */ + static int binCollFunc( + object padFlag, + int nKey1, string pKey1, + int nKey2, string pKey2 + ) + { + int rc, n; + n = nKey1 < nKey2 ? nKey1 : nKey2; + rc = memcmp( pKey1, pKey2, n ); + if ( rc == 0 ) + { + if ( (int)padFlag != 0 && allSpaces( pKey1, n, nKey1 - n ) && allSpaces( pKey2, n, nKey2 - n ) ) + { + /* Leave rc unchanged at 0 */ + } + else + { + rc = nKey1 - nKey2; } + } + return rc; + } - /* - ** Another built-in collating sequence: NOCASE. - ** - ** This collating sequence is intended to be used for "case independant - ** comparison". SQLite's knowledge of upper and lower case equivalents - ** extends only to the 26 characters used in the English language. - ** - ** At the moment there is only a UTF-8 implementation. - */ - static int nocaseCollatingFunc( - object NotUsed, - int nKey1, string pKey1, - int nKey2, string pKey2 - ) { - ////int n = ( nKey1 < nKey2 ) ? nKey1 : nKey2; - int r = sqlite3StrNICmp(pKey1, pKey2, (nKey1 < nKey2) ? nKey1 : nKey2); - UNUSED_PARAMETER(NotUsed); - if (0 == r) { - r = nKey1 - nKey2; - } - return r; - } + /* + ** Another built-in collating sequence: NOCASE. + ** + ** This collating sequence is intended to be used for "case independant + ** comparison". SQLite's knowledge of upper and lower case equivalents + ** extends only to the 26 characters used in the English language. + ** + ** At the moment there is only a UTF-8 implementation. + */ + static int nocaseCollatingFunc( + object NotUsed, + int nKey1, string pKey1, + int nKey2, string pKey2 + ) + { + ////int n = ( nKey1 < nKey2 ) ? nKey1 : nKey2; + int r = sqlite3StrNICmp( pKey1, pKey2, ( nKey1 < nKey2 ) ? nKey1 : nKey2 ); + UNUSED_PARAMETER( NotUsed ); + if ( 0 == r ) + { + r = nKey1 - nKey2; + } + return r; + } - /* - ** Return the ROWID of the most recent insert - */ - static public sqlite_int64 sqlite3_last_insert_rowid(sqlite3 db) { - return db.lastRowid; - } + /* + ** Return the ROWID of the most recent insert + */ + static public sqlite_int64 sqlite3_last_insert_rowid( sqlite3 db ) + { + return db.lastRowid; + } - /* - ** Return the number of changes in the most recent call to sqlite3_exec(). - */ - static public int sqlite3_changes(sqlite3 db) { - return db.nChange; - } + /* + ** Return the number of changes in the most recent call to sqlite3_exec(). + */ + static public int sqlite3_changes( sqlite3 db ) + { + return db.nChange; + } - /* - ** Return the number of changes since the database handle was opened. - */ - static public int sqlite3_total_changes(sqlite3 db) { - return db.nTotalChange; - } + /* + ** Return the number of changes since the database handle was opened. + */ + static public int sqlite3_total_changes( sqlite3 db ) + { + return db.nTotalChange; + } - /* - ** Close all open savepoints. This function only manipulates fields of the - ** database handle object, it does not close any savepoints that may be open - ** at the b-tree/pager level. - */ - static void sqlite3CloseSavepoints(sqlite3 db) { - while (db.pSavepoint != null) { - Savepoint pTmp = db.pSavepoint; - db.pSavepoint = pTmp.pNext; - sqlite3DbFree(db, ref pTmp); - } - db.nSavepoint = 0; - db.nStatement = 0; - db.isTransactionSavepoint = 0; - } + /* + ** Close all open savepoints. This function only manipulates fields of the + ** database handle object, it does not close any savepoints that may be open + ** at the b-tree/pager level. + */ + static void sqlite3CloseSavepoints( sqlite3 db ) + { + while ( db.pSavepoint != null ) + { + Savepoint pTmp = db.pSavepoint; + db.pSavepoint = pTmp.pNext; + sqlite3DbFree( db, ref pTmp ); + } + db.nSavepoint = 0; + db.nStatement = 0; + db.isTransactionSavepoint = 0; + } - /* - ** Invoke the destructor function associated with FuncDef p, if any. Except, - ** if this is not the last copy of the function, do not invoke it. Multiple - ** copies of a single function are created when create_function() is called - ** with SQLITE_ANY as the encoding. - */ - static void functionDestroy(sqlite3 db, FuncDef p) { - FuncDestructor pDestructor = p.pDestructor; - if (pDestructor != null) { - pDestructor.nRef--; - if (pDestructor.nRef == 0) { - //pDestructor.xDestroy( pDestructor.pUserData ); - sqlite3DbFree(db, ref pDestructor); - } - } + /* + ** Invoke the destructor function associated with FuncDef p, if any. Except, + ** if this is not the last copy of the function, do not invoke it. Multiple + ** copies of a single function are created when create_function() is called + ** with SQLITE_ANY as the encoding. + */ + static void functionDestroy( sqlite3 db, FuncDef p ) + { + FuncDestructor pDestructor = p.pDestructor; + if ( pDestructor != null ) + { + pDestructor.nRef--; + if ( pDestructor.nRef == 0 ) + { + //pDestructor.xDestroy( pDestructor.pUserData ); + sqlite3DbFree( db, ref pDestructor ); } + } + } - /* - ** Close an existing SQLite database - */ - public static int sqlite3_close(sqlite3 db) { - HashElem i; /* Hash table iterator */ - int j; + /* + ** Close an existing SQLite database + */ + public static int sqlite3_close( sqlite3 db ) + { + HashElem i; /* Hash table iterator */ + int j; + + if ( db == null ) + { + return SQLITE_OK; + } + if ( !sqlite3SafetyCheckSickOrOk( db ) ) + { + return SQLITE_MISUSE_BKPT(); + } + sqlite3_mutex_enter( db.mutex ); - if (db == null) { - return SQLITE_OK; - } - if (!sqlite3SafetyCheckSickOrOk(db)) { - return SQLITE_MISUSE_BKPT(); - } - sqlite3_mutex_enter(db.mutex); - - /* Force xDestroy calls on all virtual tables */ - sqlite3ResetInternalSchema(db, -1); - - /* If a transaction is open, the ResetInternalSchema() call above - ** will not have called the xDisconnect() method on any virtual - ** tables in the db->aVTrans[] array. The following sqlite3VtabRollback() - ** call will do so. We need to do this before the check for active - ** SQL statements below, as the v-table implementation may be storing - ** some prepared statements internally. - */ - sqlite3VtabRollback(db); - - /* If there are any outstanding VMs, return SQLITE_BUSY. */ - - if (db.pVdbe != null) { - sqlite3Error(db, SQLITE_BUSY, - "unable to close due to unfinalised statements"); - sqlite3_mutex_leave(db.mutex); - return SQLITE_BUSY; - } - Debug.Assert(sqlite3SafetyCheckSickOrOk(db)); - - for (j = 0; j < db.nDb; j++) { - Btree pBt = db.aDb[j].pBt; - if (pBt != null && sqlite3BtreeIsInBackup(pBt)) { - sqlite3Error(db, SQLITE_BUSY, - "unable to close due to unfinished backup operation"); - sqlite3_mutex_leave(db.mutex); - return SQLITE_BUSY; - } - } + /* Force xDestroy calls on all virtual tables */ + sqlite3ResetInternalSchema( db, -1 ); - /* Free any outstanding Savepoint structures. */ - sqlite3CloseSavepoints(db); - - for (j = 0; j < db.nDb; j++) { - Db pDb = db.aDb[j]; - if (pDb.pBt != null) { - sqlite3BtreeClose(ref pDb.pBt); - pDb.pBt = null; - if (j != 1) { - pDb.pSchema = null; - } - } - } - sqlite3ResetInternalSchema(db, -1); - - /* Tell the code in notify.c that the connection no longer holds any - ** locks and does not require any further unlock-notify callbacks. - */ - sqlite3ConnectionClosed(db); - - Debug.Assert(db.nDb <= 2); - Debug.Assert(db.aDb[0].Equals(db.aDbStatic[0])); - for (j = 0; j < ArraySize(db.aFunc.a); j++) { - FuncDef pNext, pHash, p; - for (p = db.aFunc.a[j]; p != null; p = pHash) { - pHash = p.pHash; - while (p != null) { - functionDestroy(db, p); - pNext = p.pNext; - sqlite3DbFree(db, ref p); - p = pNext; - } + /* If a transaction is open, the ResetInternalSchema() call above + ** will not have called the xDisconnect() method on any virtual + ** tables in the db->aVTrans[] array. The following sqlite3VtabRollback() + ** call will do so. We need to do this before the check for active + ** SQL statements below, as the v-table implementation may be storing + ** some prepared statements internally. + */ + sqlite3VtabRollback( db ); - } - } + /* If there are any outstanding VMs, return SQLITE_BUSY. */ - for (i = db.aCollSeq.first; i != null; i = i.next) {//sqliteHashFirst(db.aCollSeq); i!=null; i=sqliteHashNext(i)){ - CollSeq[] pColl = (CollSeq[])i.data;// sqliteHashData(i); - /* Invoke any destructors registered for collation sequence user data. */ - for (j = 0; j < 3; j++) { - if (pColl[j].xDel != null) { - pColl[j].xDel(ref pColl[j].pUser); - } - } - sqlite3DbFree(db, ref pColl); - } - sqlite3HashClear(db.aCollSeq); + if ( db.pVdbe != null ) + { + sqlite3Error( db, SQLITE_BUSY, + "unable to close due to unfinalised statements" ); + sqlite3_mutex_leave( db.mutex ); + return SQLITE_BUSY; + } + Debug.Assert( sqlite3SafetyCheckSickOrOk( db ) ); + + for ( j = 0; j < db.nDb; j++ ) + { + Btree pBt = db.aDb[j].pBt; + if ( pBt != null && sqlite3BtreeIsInBackup( pBt ) ) + { + sqlite3Error( db, SQLITE_BUSY, + "unable to close due to unfinished backup operation" ); + sqlite3_mutex_leave( db.mutex ); + return SQLITE_BUSY; + } + } + + /* Free any outstanding Savepoint structures. */ + sqlite3CloseSavepoints( db ); + + for ( j = 0; j < db.nDb; j++ ) + { + Db pDb = db.aDb[j]; + if ( pDb.pBt != null ) + { + sqlite3BtreeClose( ref pDb.pBt ); + pDb.pBt = null; + if ( j != 1 ) + { + pDb.pSchema = null; + } + } + } + sqlite3ResetInternalSchema( db, -1 ); + + /* Tell the code in notify.c that the connection no longer holds any + ** locks and does not require any further unlock-notify callbacks. + */ + sqlite3ConnectionClosed( db ); + + Debug.Assert( db.nDb <= 2 ); + Debug.Assert( db.aDb[0].Equals( db.aDbStatic[0] ) ); + for ( j = 0; j < ArraySize( db.aFunc.a ); j++ ) + { + FuncDef pNext, pHash, p; + for ( p = db.aFunc.a[j]; p != null; p = pHash ) + { + pHash = p.pHash; + while ( p != null ) + { + functionDestroy( db, p ); + pNext = p.pNext; + sqlite3DbFree( db, ref p ); + p = pNext; + } + + } + } + + for ( i = db.aCollSeq.first; i != null; i = i.next ) + {//sqliteHashFirst(db.aCollSeq); i!=null; i=sqliteHashNext(i)){ + CollSeq[] pColl = (CollSeq[])i.data;// sqliteHashData(i); + /* Invoke any destructors registered for collation sequence user data. */ + for ( j = 0; j < 3; j++ ) + { + if ( pColl[j].xDel != null ) + { + pColl[j].xDel( ref pColl[j].pUser ); + } + } + sqlite3DbFree( db, ref pColl ); + } + sqlite3HashClear( db.aCollSeq ); #if !SQLITE_OMIT_VIRTUALTABLE - for (i = sqliteHashFirst(db.aModule); i != null; i = sqliteHashNext(i)) { - Module pMod = (Module)sqliteHashData(i); - if (pMod.xDestroy != null) { - pMod.xDestroy(ref pMod.pAux); - } - sqlite3DbFree(db, ref pMod); - } - sqlite3HashClear(db.aModule); + for ( i = sqliteHashFirst( db.aModule ); i != null; i = sqliteHashNext( i ) ) + { + Module pMod = (Module)sqliteHashData( i ); + if ( pMod.xDestroy != null ) + { + pMod.xDestroy( ref pMod.pAux ); + } + sqlite3DbFree( db, ref pMod ); + } + sqlite3HashClear( db.aModule ); #endif - sqlite3Error(db, SQLITE_OK, 0); /* Deallocates any cached error strings. */ - if (db.pErr != null) { - sqlite3ValueFree(ref db.pErr); - } + sqlite3Error( db, SQLITE_OK, 0 ); /* Deallocates any cached error strings. */ + if ( db.pErr != null ) + { + sqlite3ValueFree( ref db.pErr ); + } #if !SQLITE_OMIT_LOAD_EXTENSION - sqlite3CloseExtensions(db); + sqlite3CloseExtensions( db ); #endif - db.magic = SQLITE_MAGIC_ERROR; - - /* The temp.database schema is allocated differently from the other schema - ** objects (using sqliteMalloc() directly, instead of sqlite3BtreeSchema()). - ** So it needs to be freed here. Todo: Why not roll the temp schema into - ** the same sqliteMalloc() as the one that allocates the database - ** structure? - */ - sqlite3DbFree(db, ref db.aDb[1].pSchema); - sqlite3_mutex_leave(db.mutex); - db.magic = SQLITE_MAGIC_CLOSED; - sqlite3_mutex_free(db.mutex); - Debug.Assert(db.lookaside.nOut == 0); /* Fails on a lookaside memory leak */ - //if ( db.lookaside.bMalloced ) - //{ - // sqlite3_free( ref db.lookaside.pStart ); - //} - //sqlite3_free( ref db ); - return SQLITE_OK; - } + db.magic = SQLITE_MAGIC_ERROR; - /* - ** Rollback all database files. - */ - static void sqlite3RollbackAll(sqlite3 db) { - int i; - int inTrans = 0; - Debug.Assert(sqlite3_mutex_held(db.mutex)); - sqlite3BeginBenignMalloc(); - for (i = 0; i < db.nDb; i++) { - if (db.aDb[i].pBt != null) { - if (sqlite3BtreeIsInTrans(db.aDb[i].pBt)) { - inTrans = 1; - } - sqlite3BtreeRollback(db.aDb[i].pBt); - db.aDb[i].inTrans = 0; - } - } + /* The temp.database schema is allocated differently from the other schema + ** objects (using sqliteMalloc() directly, instead of sqlite3BtreeSchema()). + ** So it needs to be freed here. Todo: Why not roll the temp schema into + ** the same sqliteMalloc() as the one that allocates the database + ** structure? + */ + sqlite3DbFree( db, ref db.aDb[1].pSchema ); + sqlite3_mutex_leave( db.mutex ); + db.magic = SQLITE_MAGIC_CLOSED; + sqlite3_mutex_free( db.mutex ); + Debug.Assert( db.lookaside.nOut == 0 ); /* Fails on a lookaside memory leak */ + //if ( db.lookaside.bMalloced ) + //{ + // sqlite3_free( ref db.lookaside.pStart ); + //} + //sqlite3_free( ref db ); + return SQLITE_OK; + } - sqlite3VtabRollback(db); - sqlite3EndBenignMalloc(); - if ((db.flags & SQLITE_InternChanges) != 0) { - sqlite3ExpirePreparedStatements(db); - sqlite3ResetInternalSchema(db, -1); - } + /* + ** Rollback all database files. + */ + static void sqlite3RollbackAll( sqlite3 db ) + { + int i; + int inTrans = 0; + Debug.Assert( sqlite3_mutex_held( db.mutex ) ); + sqlite3BeginBenignMalloc(); + for ( i = 0; i < db.nDb; i++ ) + { + if ( db.aDb[i].pBt != null ) + { + if ( sqlite3BtreeIsInTrans( db.aDb[i].pBt ) ) + { + inTrans = 1; + } + sqlite3BtreeRollback( db.aDb[i].pBt ); + db.aDb[i].inTrans = 0; + } + } - /* Any deferred constraint violations have now been resolved. */ - db.nDeferredCons = 0; + sqlite3VtabRollback( db ); + sqlite3EndBenignMalloc(); + if ( ( db.flags & SQLITE_InternChanges ) != 0 ) + { + sqlite3ExpirePreparedStatements( db ); + sqlite3ResetInternalSchema( db, -1 ); + } - /* If one has been configured, invoke the rollback-hook callback */ - if (db.xRollbackCallback != null && (inTrans != 0 || 0 == db.autoCommit)) { - db.xRollbackCallback(db.pRollbackArg); - } - } + /* Any deferred constraint violations have now been resolved. */ + db.nDeferredCons = 0; - /* - ** Return a static string that describes the kind of error specified in the - ** argument. - */ - static string sqlite3ErrStr(int rc) { - string[] aMsg = new string[]{ + /* If one has been configured, invoke the rollback-hook callback */ + if ( db.xRollbackCallback != null && ( inTrans != 0 || 0 == db.autoCommit ) ) + { + db.xRollbackCallback( db.pRollbackArg ); + } + } + + /* + ** Return a static string that describes the kind of error specified in the + ** argument. + */ + static string sqlite3ErrStr( int rc ) + { + string[] aMsg = new string[]{ /* SQLITE_OK */ "not an error", /* SQLITE_ERROR */ "SQL logic error or missing database", /* SQLITE_INTERNAL */ "", @@ -1027,49 +1158,56 @@ static string sqlite3ErrStr(int rc) { /* SQLITE_RANGE */ "bind or column index out of range", /* SQLITE_NOTADB */ "file is encrypted or is not a database", }; - rc &= 0xff; - if (ALWAYS(rc >= 0) && rc < aMsg.Length && aMsg[rc] != "")//(int)(sizeof(aMsg)/sizeof(aMsg[0])) - { - return aMsg[rc]; - } else { - return "unknown error"; - } - } + rc &= 0xff; + if ( ALWAYS( rc >= 0 ) && rc < aMsg.Length && aMsg[rc] != "" )//(int)(sizeof(aMsg)/sizeof(aMsg[0])) + { + return aMsg[rc]; + } + else + { + return "unknown error"; + } + } - /* - ** This routine implements a busy callback that sleeps and tries - ** again until a timeout value is reached. The timeout value is - ** an integer number of milliseconds passed in as the first - ** argument. - */ - static int sqliteDefaultBusyCallback( - object ptr, /* Database connection */ - int count /* Number of times table has been busy */ - ) { + /* + ** This routine implements a busy callback that sleeps and tries + ** again until a timeout value is reached. The timeout value is + ** an integer number of milliseconds passed in as the first + ** argument. + */ + static int sqliteDefaultBusyCallback( + object ptr, /* Database connection */ + int count /* Number of times table has been busy */ + ) + { #if SQLITE_OS_WIN || HAVE_USLEEP - u8[] delays = new u8[] { 1, 2, 5, 10, 15, 20, 25, 25, 25, 50, 50, 100 }; - u8[] totals = new u8[] { 0, 1, 3, 8, 18, 33, 53, 78, 103, 128, 178, 228 }; - //# define NDELAY ArraySize(delays) - int NDELAY = ArraySize(delays); - sqlite3 db = (sqlite3)ptr; - int timeout = db.busyTimeout; - int delay, prior; - - Debug.Assert(count >= 0); - if (count < NDELAY) { - delay = delays[count]; - prior = totals[count]; - } else { - delay = delays[NDELAY - 1]; - prior = totals[NDELAY - 1] + delay * (count - (NDELAY - 1)); - } - if (prior + delay > timeout) { - delay = timeout - prior; - if (delay <= 0) - return 0; - } - sqlite3OsSleep(db.pVfs, delay * 1000); - return 1; + u8[] delays = new u8[] { 1, 2, 5, 10, 15, 20, 25, 25, 25, 50, 50, 100 }; + u8[] totals = new u8[] { 0, 1, 3, 8, 18, 33, 53, 78, 103, 128, 178, 228 }; + //# define NDELAY ArraySize(delays) + int NDELAY = ArraySize( delays ); + sqlite3 db = (sqlite3)ptr; + int timeout = db.busyTimeout; + int delay, prior; + + Debug.Assert( count >= 0 ); + if ( count < NDELAY ) + { + delay = delays[count]; + prior = totals[count]; + } + else + { + delay = delays[NDELAY - 1]; + prior = totals[NDELAY - 1] + delay * ( count - ( NDELAY - 1 ) ); + } + if ( prior + delay > timeout ) + { + delay = timeout - prior; + if ( delay <= 0 ) + return 0; + } + sqlite3OsSleep( db.pVfs, delay * 1000 ); + return 1; #else sqlite3 db = (sqlite3)ptr; int timeout = ( (sqlite3)ptr ).busyTimeout; @@ -1080,123 +1218,139 @@ int count /* Number of times table has been busy */ sqlite3OsSleep( db.pVfs, 1000000 ); return 1; #endif - } + } - /* - ** Invoke the given busy handler. - ** - ** This routine is called when an operation failed with a lock. - ** If this routine returns non-zero, the lock is retried. If it - ** returns 0, the operation aborts with an SQLITE_BUSY error. - */ - static int sqlite3InvokeBusyHandler(BusyHandler p) { - int rc; - if (NEVER(p == null) || p.xFunc == null || p.nBusy < 0) - return 0; - rc = p.xFunc(p.pArg, p.nBusy); - if (rc == 0) { - p.nBusy = -1; - } else { - p.nBusy++; - } - return rc; - } + /* + ** Invoke the given busy handler. + ** + ** This routine is called when an operation failed with a lock. + ** If this routine returns non-zero, the lock is retried. If it + ** returns 0, the operation aborts with an SQLITE_BUSY error. + */ + static int sqlite3InvokeBusyHandler( BusyHandler p ) + { + int rc; + if ( NEVER( p == null ) || p.xFunc == null || p.nBusy < 0 ) + return 0; + rc = p.xFunc( p.pArg, p.nBusy ); + if ( rc == 0 ) + { + p.nBusy = -1; + } + else + { + p.nBusy++; + } + return rc; + } - /* - ** This routine sets the busy callback for an Sqlite database to the - ** given callback function with the given argument. - */ - static int sqlite3_busy_handler( - sqlite3 db, - dxBusy xBusy, - object pArg - ) { - sqlite3_mutex_enter(db.mutex); - db.busyHandler.xFunc = xBusy; - db.busyHandler.pArg = pArg; - db.busyHandler.nBusy = 0; - sqlite3_mutex_leave(db.mutex); - return SQLITE_OK; - } + /* + ** This routine sets the busy callback for an Sqlite database to the + ** given callback function with the given argument. + */ + static int sqlite3_busy_handler( + sqlite3 db, + dxBusy xBusy, + object pArg + ) + { + sqlite3_mutex_enter( db.mutex ); + db.busyHandler.xFunc = xBusy; + db.busyHandler.pArg = pArg; + db.busyHandler.nBusy = 0; + sqlite3_mutex_leave( db.mutex ); + return SQLITE_OK; + } #if !SQLITE_OMIT_PROGRESS_CALLBACK - /* - ** This routine sets the progress callback for an Sqlite database to the - ** given callback function with the given argument. The progress callback will - ** be invoked every nOps opcodes. - */ - static void sqlite3_progress_handler( - sqlite3 db, - int nOps, - dxProgress xProgress, //int (xProgress)(void), - object pArg - ) { - sqlite3_mutex_enter(db.mutex); - if (nOps > 0) { - db.xProgress = xProgress; - db.nProgressOps = nOps; - db.pProgressArg = pArg; - } else { - db.xProgress = null; - db.nProgressOps = 0; - db.pProgressArg = null; - } - sqlite3_mutex_leave(db.mutex); - } + /* +** This routine sets the progress callback for an Sqlite database to the +** given callback function with the given argument. The progress callback will +** be invoked every nOps opcodes. +*/ + static void sqlite3_progress_handler( + sqlite3 db, + int nOps, + dxProgress xProgress, //int (xProgress)(void), + object pArg + ) + { + sqlite3_mutex_enter( db.mutex ); + if ( nOps > 0 ) + { + db.xProgress = xProgress; + db.nProgressOps = nOps; + db.pProgressArg = pArg; + } + else + { + db.xProgress = null; + db.nProgressOps = 0; + db.pProgressArg = null; + } + sqlite3_mutex_leave( db.mutex ); + } #endif - /* - ** This routine installs a default busy handler that waits for the - ** specified number of milliseconds before returning 0. - */ - static public int sqlite3_busy_timeout(sqlite3 db, int ms) { - if (ms > 0) { - db.busyTimeout = ms; - sqlite3_busy_handler(db, sqliteDefaultBusyCallback, db); - } else { - sqlite3_busy_handler(db, null, null); - } - return SQLITE_OK; - } + /* +** This routine installs a default busy handler that waits for the +** specified number of milliseconds before returning 0. +*/ + static public int sqlite3_busy_timeout( sqlite3 db, int ms ) + { + if ( ms > 0 ) + { + db.busyTimeout = ms; + sqlite3_busy_handler( db, sqliteDefaultBusyCallback, db ); + } + else + { + sqlite3_busy_handler( db, null, null ); + } + return SQLITE_OK; + } - /* - ** Cause any pending operation to stop at its earliest opportunity. - */ - public static void sqlite3_interrupt(sqlite3 db) { - db.u1.isInterrupted = true; - } + /* + ** Cause any pending operation to stop at its earliest opportunity. + */ + public static void sqlite3_interrupt( sqlite3 db ) + { + db.u1.isInterrupted = true; + } - /* - ** This function is exactly the same as sqlite3_create_function(), except - ** that it is designed to be called by internal code. The difference is - ** that if a malloc() fails in sqlite3_create_function(), an error code - ** is returned and the mallocFailed flag cleared. - */ - static int sqlite3CreateFunc( - sqlite3 db, - string zFunctionName, - int nArg, - u8 enc, - object pUserData, - dxFunc xFunc, //)(sqlite3_context*,int,sqlite3_value *), - dxStep xStep,//)(sqlite3_context*,int,sqlite3_value *), - dxFinal xFinal, //)(sqlite3_context), - FuncDestructor pDestructor - ) { - FuncDef p; - int nName; - - Debug.Assert(sqlite3_mutex_held(db.mutex)); - if (zFunctionName == null || - (xFunc != null && (xFinal != null || xStep != null)) || - (xFunc == null && (xFinal != null && xStep == null)) || - (xFunc == null && (xFinal == null && xStep != null)) || - (nArg < -1 || nArg > SQLITE_MAX_FUNCTION_ARG) || - (255 < (nName = sqlite3Strlen30(zFunctionName)))) { - return SQLITE_MISUSE_BKPT(); - } + /* + ** This function is exactly the same as sqlite3_create_function(), except + ** that it is designed to be called by internal code. The difference is + ** that if a malloc() fails in sqlite3_create_function(), an error code + ** is returned and the mallocFailed flag cleared. + */ + static int sqlite3CreateFunc( + sqlite3 db, + string zFunctionName, + int nArg, + u8 enc, + object pUserData, + dxFunc xFunc, //)(sqlite3_context*,int,sqlite3_value *), + dxStep xStep,//)(sqlite3_context*,int,sqlite3_value *), + dxFinal xFinal, //)(sqlite3_context), + FuncDestructor pDestructor + ) + { + FuncDef p; + int nName; + + Debug.Assert( sqlite3_mutex_held( db.mutex ) ); + if ( zFunctionName == null || + ( xFunc != null && ( xFinal != null || xStep != null ) ) || + ( xFunc == null && ( xFinal != null && xStep == null ) ) || + ( xFunc == null && ( xFinal == null && xStep != null ) ) || + ( nArg < -1 || nArg > SQLITE_MAX_FUNCTION_ARG ) || + ( 255 < ( nName = sqlite3Strlen30( zFunctionName ) ) ) ) + { + return SQLITE_MISUSE_BKPT(); + } #if !SQLITE_OMIT_UTF16 /* If SQLITE_UTF16 is specified as the encoding type, transform this @@ -1222,101 +1376,110 @@ FuncDestructor pDestructor enc = SQLITE_UTF16BE; } #else - enc = SQLITE_UTF8; + enc = SQLITE_UTF8; #endif - /* Check if an existing function is being overridden or deleted. If so, - ** and there are active VMs, then return SQLITE_BUSY. If a function - ** is being overridden/deleted but there are no active VMs, allow the - ** operation to continue but invalidate all precompiled statements. - */ - p = sqlite3FindFunction(db, zFunctionName, nName, nArg, enc, 0); - if (p != null && p.iPrefEnc == enc && p.nArg == nArg) { - if (db.activeVdbeCnt != 0) { - sqlite3Error(db, SQLITE_BUSY, - "unable to delete/modify user-function due to active statements"); - //Debug.Assert( 0 == db.mallocFailed ); - return SQLITE_BUSY; - } else { - sqlite3ExpirePreparedStatements(db); - } - } + /* Check if an existing function is being overridden or deleted. If so, +** and there are active VMs, then return SQLITE_BUSY. If a function +** is being overridden/deleted but there are no active VMs, allow the +** operation to continue but invalidate all precompiled statements. +*/ + p = sqlite3FindFunction( db, zFunctionName, nName, nArg, enc, 0 ); + if ( p != null && p.iPrefEnc == enc && p.nArg == nArg ) + { + if ( db.activeVdbeCnt != 0 ) + { + sqlite3Error( db, SQLITE_BUSY, + "unable to delete/modify user-function due to active statements" ); + //Debug.Assert( 0 == db.mallocFailed ); + return SQLITE_BUSY; + } + else + { + sqlite3ExpirePreparedStatements( db ); + } + } - p = sqlite3FindFunction(db, zFunctionName, nName, nArg, enc, 1); - Debug.Assert(p != null /*|| db.mallocFailed != 0 */ ); - //if ( p == null ) - //{ - // return SQLITE_NOMEM; - //} + p = sqlite3FindFunction( db, zFunctionName, nName, nArg, enc, 1 ); + Debug.Assert( p != null /*|| db.mallocFailed != 0 */ ); + //if ( p == null ) + //{ + // return SQLITE_NOMEM; + //} - /* If an older version of the function with a configured destructor is - ** being replaced invoke the destructor function here. */ - functionDestroy(db, p); + /* If an older version of the function with a configured destructor is + ** being replaced invoke the destructor function here. */ + functionDestroy( db, p ); - if (pDestructor != null) { - pDestructor.nRef++; - } - p.pDestructor = pDestructor; - p.flags = 0; - p.xFunc = xFunc; - p.xStep = xStep; - p.xFinalize = xFinal; - p.pUserData = pUserData; - p.nArg = (i16)nArg; - return SQLITE_OK; - } + if ( pDestructor != null ) + { + pDestructor.nRef++; + } + p.pDestructor = pDestructor; + p.flags = 0; + p.xFunc = xFunc; + p.xStep = xStep; + p.xFinalize = xFinal; + p.pUserData = pUserData; + p.nArg = (i16)nArg; + return SQLITE_OK; + } - /* - ** Create new user functions. - */ - static public int sqlite3_create_function( - sqlite3 db, - string zFunc, - int nArg, - u8 enc, - object p, - dxFunc xFunc, //)(sqlite3_context*,int,sqlite3_value *), - dxStep xStep,//)(sqlite3_context*,int,sqlite3_value *), - dxFinal xFinal//)(sqlite3_context) - ) { - return sqlite3_create_function_v2(db, zFunc, nArg, enc, p, xFunc, xStep, - xFinal, null); - } + /* + ** Create new user functions. + */ + static public int sqlite3_create_function( + sqlite3 db, + string zFunc, + int nArg, + u8 enc, + object p, + dxFunc xFunc, //)(sqlite3_context*,int,sqlite3_value *), + dxStep xStep,//)(sqlite3_context*,int,sqlite3_value *), + dxFinal xFinal//)(sqlite3_context) + ) + { + return sqlite3_create_function_v2( db, zFunc, nArg, enc, p, xFunc, xStep, + xFinal, null ); + } - static int sqlite3_create_function_v2( - sqlite3 db, - string zFunc, - int nArg, - int enc, - object p, - dxFunc xFunc, //)(sqlite3_context*,int,sqlite3_value *), - dxStep xStep,//)(sqlite3_context*,int,sqlite3_value *), - dxFinal xFinal,//)(sqlite3_context) - dxFDestroy xDestroy//)(void ) - ) { - int rc = SQLITE_ERROR; - FuncDestructor pArg = null; - sqlite3_mutex_enter(db.mutex); - if (xDestroy != null) { - pArg = new FuncDestructor();//(FuncDestructor )sqlite3DbMallocZero(db, sizeof(FuncDestructor)); - //if( null==pArg ){ - // xDestroy(p); - // goto out; - //} - pArg.xDestroy = xDestroy; - pArg.pUserData = p; - } - rc = sqlite3CreateFunc(db, zFunc, nArg, (byte)enc, p, xFunc, xStep, xFinal, pArg); - if (pArg != null && pArg.nRef == 0) { - Debug.Assert(rc != SQLITE_OK); - //xDestroy(p); - sqlite3DbFree(db, ref pArg); - } - //_out: - rc = sqlite3ApiExit(db, rc); - sqlite3_mutex_leave(db.mutex); - return rc; - } + static int sqlite3_create_function_v2( + sqlite3 db, + string zFunc, + int nArg, + int enc, + object p, + dxFunc xFunc, //)(sqlite3_context*,int,sqlite3_value *), + dxStep xStep,//)(sqlite3_context*,int,sqlite3_value *), + dxFinal xFinal,//)(sqlite3_context) + dxFDestroy xDestroy//)(void ) + ) + { + int rc = SQLITE_ERROR; + FuncDestructor pArg = null; + sqlite3_mutex_enter( db.mutex ); + if ( xDestroy != null ) + { + pArg = new FuncDestructor();//(FuncDestructor )sqlite3DbMallocZero(db, sizeof(FuncDestructor)); + //if( null==pArg ){ + // xDestroy(p); + // goto out; + //} + pArg.xDestroy = xDestroy; + pArg.pUserData = p; + } + rc = sqlite3CreateFunc( db, zFunc, nArg, (byte)enc, p, xFunc, xStep, xFinal, pArg ); + if ( pArg != null && pArg.nRef == 0 ) + { + Debug.Assert( rc != SQLITE_OK ); + //xDestroy(p); + sqlite3DbFree( db, ref pArg ); + } + //_out: + rc = sqlite3ApiExit( db, rc ); + sqlite3_mutex_leave( db.mutex ); + return rc; + } #if !SQLITE_OMIT_UTF16 static int sqlite3_create_function16( @@ -1343,131 +1506,138 @@ static int sqlite3_create_function16( #endif - /* - ** Declare that a function has been overloaded by a virtual table. - ** - ** If the function already exists as a regular global function, then - ** this routine is a no-op. If the function does not exist, then create - ** a new one that always throws a run-time error. - ** - ** When virtual tables intend to provide an overloaded function, they - ** should call this routine to make sure the global function exists. - ** A global function must exist in order for name resolution to work - ** properly. - */ - static int sqlite3_overload_function( - sqlite3 db, - string zName, - int nArg - ) { - int nName = sqlite3Strlen30(zName); - int rc; - sqlite3_mutex_enter(db.mutex); - if (sqlite3FindFunction(db, zName, nName, nArg, SQLITE_UTF8, 0) == null) { - sqlite3CreateFunc(db, zName, nArg, SQLITE_UTF8, - 0, (dxFunc)sqlite3InvalidFunction, null, null, null); - } - rc = sqlite3ApiExit(db, SQLITE_OK); - sqlite3_mutex_leave(db.mutex); - return rc; - } + /* +** Declare that a function has been overloaded by a virtual table. +** +** If the function already exists as a regular global function, then +** this routine is a no-op. If the function does not exist, then create +** a new one that always throws a run-time error. +** +** When virtual tables intend to provide an overloaded function, they +** should call this routine to make sure the global function exists. +** A global function must exist in order for name resolution to work +** properly. +*/ + static int sqlite3_overload_function( + sqlite3 db, + string zName, + int nArg + ) + { + int nName = sqlite3Strlen30( zName ); + int rc; + sqlite3_mutex_enter( db.mutex ); + if ( sqlite3FindFunction( db, zName, nName, nArg, SQLITE_UTF8, 0 ) == null ) + { + sqlite3CreateFunc( db, zName, nArg, SQLITE_UTF8, + 0, (dxFunc)sqlite3InvalidFunction, null, null, null ); + } + rc = sqlite3ApiExit( db, SQLITE_OK ); + sqlite3_mutex_leave( db.mutex ); + return rc; + } #if !SQLITE_OMIT_TRACE - /* - ** Register a trace function. The pArg from the previously registered trace - ** is returned. + /* +** Register a trace function. The pArg from the previously registered trace +** is returned. +** +** A NULL trace function means that no tracing is executes. A non-NULL +** trace is a pointer to a function that is invoked at the start of each +** SQL statement. +*/ + static object sqlite3_trace( sqlite3 db, dxTrace xTrace, object pArg ) + {// (*xTrace)(void*,const char), object pArg){ + object pOld; + sqlite3_mutex_enter( db.mutex ); + pOld = db.pTraceArg; + db.xTrace = xTrace; + db.pTraceArg = pArg; + sqlite3_mutex_leave( db.mutex ); + return pOld; + } + /* + ** Register a profile function. The pArg from the previously registered + ** profile function is returned. ** - ** A NULL trace function means that no tracing is executes. A non-NULL - ** trace is a pointer to a function that is invoked at the start of each - ** SQL statement. + ** A NULL profile function means that no profiling is executes. A non-NULL + ** profile is a pointer to a function that is invoked at the conclusion of + ** each SQL statement that is run. */ - static object sqlite3_trace(sqlite3 db, dxTrace xTrace, object pArg) {// (*xTrace)(void*,const char), object pArg){ - object pOld; - sqlite3_mutex_enter(db.mutex); - pOld = db.pTraceArg; - db.xTrace = xTrace; - db.pTraceArg = pArg; - sqlite3_mutex_leave(db.mutex); - return pOld; - } - /* - ** Register a profile function. The pArg from the previously registered - ** profile function is returned. - ** - ** A NULL profile function means that no profiling is executes. A non-NULL - ** profile is a pointer to a function that is invoked at the conclusion of - ** each SQL statement that is run. - */ - static object sqlite3_profile( - sqlite3 db, - dxProfile xProfile,//void (*xProfile)(void*,const char*,sqlite_u3264), - object pArg - ) { - object pOld; - sqlite3_mutex_enter(db.mutex); - pOld = db.pProfileArg; - db.xProfile = xProfile; - db.pProfileArg = pArg; - sqlite3_mutex_leave(db.mutex); - return pOld; - } + static object sqlite3_profile( + sqlite3 db, + dxProfile xProfile,//void (*xProfile)(void*,const char*,sqlite_u3264), + object pArg + ) + { + object pOld; + sqlite3_mutex_enter( db.mutex ); + pOld = db.pProfileArg; + db.xProfile = xProfile; + db.pProfileArg = pArg; + sqlite3_mutex_leave( db.mutex ); + return pOld; + } #endif // * SQLITE_OMIT_TRACE */ - /*** EXPERIMENTAL *** - ** - ** Register a function to be invoked when a transaction comments. - ** If the invoked function returns non-zero, then the commit becomes a - ** rollback. - */ - public static object sqlite3_commit_hook( - sqlite3 db, /* Attach the hook to this database */ - dxCommitCallback xCallback, //int (*xCallback)(void), /* Function to invoke on each commit */ - object pArg /* Argument to the function */ - ) { - object pOld; - sqlite3_mutex_enter(db.mutex); - pOld = db.pCommitArg; - db.xCommitCallback = xCallback; - db.pCommitArg = pArg; - sqlite3_mutex_leave(db.mutex); - return pOld; - } + /*** EXPERIMENTAL *** +** +** Register a function to be invoked when a transaction comments. +** If the invoked function returns non-zero, then the commit becomes a +** rollback. +*/ + public static object sqlite3_commit_hook( + sqlite3 db, /* Attach the hook to this database */ + dxCommitCallback xCallback, //int (*xCallback)(void), /* Function to invoke on each commit */ + object pArg /* Argument to the function */ + ) + { + object pOld; + sqlite3_mutex_enter( db.mutex ); + pOld = db.pCommitArg; + db.xCommitCallback = xCallback; + db.pCommitArg = pArg; + sqlite3_mutex_leave( db.mutex ); + return pOld; + } - /* - ** Register a callback to be invoked each time a row is updated, - ** inserted or deleted using this database connection. - */ - public static object sqlite3_update_hook( - sqlite3 db, /* Attach the hook to this database */ - dxUpdateCallback xCallback, //void (*xCallback)(void*,int,char const *,char const *,sqlite_int64), - object pArg /* Argument to the function */ - ) { - object pRet; - sqlite3_mutex_enter(db.mutex); - pRet = db.pUpdateArg; - db.xUpdateCallback = xCallback; - db.pUpdateArg = pArg; - sqlite3_mutex_leave(db.mutex); - return pRet; - } + /* + ** Register a callback to be invoked each time a row is updated, + ** inserted or deleted using this database connection. + */ + public static object sqlite3_update_hook( + sqlite3 db, /* Attach the hook to this database */ + dxUpdateCallback xCallback, //void (*xCallback)(void*,int,char const *,char const *,sqlite_int64), + object pArg /* Argument to the function */ + ) + { + object pRet; + sqlite3_mutex_enter( db.mutex ); + pRet = db.pUpdateArg; + db.xUpdateCallback = xCallback; + db.pUpdateArg = pArg; + sqlite3_mutex_leave( db.mutex ); + return pRet; + } - /* - ** Register a callback to be invoked each time a transaction is rolled - ** back by this database connection. - */ - public static object sqlite3_rollback_hook( - sqlite3 db, /* Attach the hook to this database */ - dxRollbackCallback xCallback, //void (*xCallback)(void), /* Callback function */ - object pArg /* Argument to the function */ - ) { - object pRet; - sqlite3_mutex_enter(db.mutex); - pRet = db.pRollbackArg; - db.xRollbackCallback = xCallback; - db.pRollbackArg = pArg; - sqlite3_mutex_leave(db.mutex); - return pRet; - } + /* + ** Register a callback to be invoked each time a transaction is rolled + ** back by this database connection. + */ + public static object sqlite3_rollback_hook( + sqlite3 db, /* Attach the hook to this database */ + dxRollbackCallback xCallback, //void (*xCallback)(void), /* Callback function */ + object pArg /* Argument to the function */ + ) + { + object pRet; + sqlite3_mutex_enter( db.mutex ); + pRet = db.pRollbackArg; + db.xRollbackCallback = xCallback; + db.pRollbackArg = pArg; + sqlite3_mutex_leave( db.mutex ); + return pRet; + } #if !SQLITE_OMIT_WAL /* @@ -1491,21 +1661,22 @@ int nFrame /* Size of WAL */ } #endif //* SQLITE_OMIT_WAL */ - /* - ** Configure an sqlite3_wal_hook() callback to automatically checkpoint - ** a database after committing a transaction if there are nFrame or - ** more frames in the log file. Passing zero or a negative value as the - ** nFrame parameter disables automatic checkpoints entirely. - ** - ** The callback registered by this function replaces any existing callback - ** registered using sqlite3_wal_hook(). Likewise, registering a callback - ** using sqlite3_wal_hook() disables the automatic checkpoint mechanism - ** configured by this function. - */ - static int sqlite3_wal_autocheckpoint(sqlite3 db, int nFrame) { + /* +** Configure an sqlite3_wal_hook() callback to automatically checkpoint +** a database after committing a transaction if there are nFrame or +** more frames in the log file. Passing zero or a negative value as the +** nFrame parameter disables automatic checkpoints entirely. +** +** The callback registered by this function replaces any existing callback +** registered using sqlite3_wal_hook(). Likewise, registering a callback +** using sqlite3_wal_hook() disables the automatic checkpoint mechanism +** configured by this function. +*/ + static int sqlite3_wal_autocheckpoint( sqlite3 db, int nFrame ) + { #if SQLITE_OMIT_WAL - UNUSED_PARAMETER(db); - UNUSED_PARAMETER(nFrame); + UNUSED_PARAMETER( db ); + UNUSED_PARAMETER( nFrame ); #else if( nFrame>0 ){ sqlite3_wal_hook(db, sqlite3WalDefaultHook, SQLITE_INT_TO_PTR(nFrame)); @@ -1513,18 +1684,19 @@ static int sqlite3_wal_autocheckpoint(sqlite3 db, int nFrame) { sqlite3_wal_hook(db, 0, 0); } #endif - return SQLITE_OK; - } + return SQLITE_OK; + } - /* - ** Register a callback to be invoked each time a transaction is written - ** into the write-ahead-log by this database connection. - */ - static object sqlite3_wal_hook( - sqlite3 db, /* Attach the hook to this db handle */ - dxWalCallback xCallback, //int(*xCallback)(void *, sqlite3*, const char*, int), - object pArg /* First argument passed to xCallback() */ - ) { + /* + ** Register a callback to be invoked each time a transaction is written + ** into the write-ahead-log by this database connection. + */ + static object sqlite3_wal_hook( + sqlite3 db, /* Attach the hook to this db handle */ + dxWalCallback xCallback, //int(*xCallback)(void *, sqlite3*, const char*, int), + object pArg /* First argument passed to xCallback() */ + ) + { #if !SQLITE_OMIT_WAL void *pRet; sqlite3_mutex_enter(db.mutex); @@ -1534,25 +1706,26 @@ static object sqlite3_wal_hook( sqlite3_mutex_leave(db.mutex); return pRet; #else - return null; + return null; #endif - } + } - /* - ** Checkpoint database zDb. - */ - static int sqlite3_wal_checkpoint_v2( - sqlite3 db, /* Database handle */ - string zDb, /* Name of attached database (or NULL) */ - int eMode, /* SQLITE_CHECKPOINT_* value */ - out int pnLog, /* OUT: Size of WAL log in frames */ - out int pnCkpt /* OUT: Total number of frames checkpointed */ - ) { + /* + ** Checkpoint database zDb. + */ + static int sqlite3_wal_checkpoint_v2( + sqlite3 db, /* Database handle */ + string zDb, /* Name of attached database (or NULL) */ + int eMode, /* SQLITE_CHECKPOINT_* value */ + out int pnLog, /* OUT: Size of WAL log in frames */ + out int pnCkpt /* OUT: Total number of frames checkpointed */ + ) + { #if SQLITE_OMIT_WAL - pnLog = 0; - pnCkpt = 0; - return SQLITE_OK; + pnLog = 0; + pnCkpt = 0; + return SQLITE_OK; #else int rc; /* Return code */ int iDb = SQLITE_MAX_ATTACHED; /* sqlite3.aDb[] index of db to checkpoint */ @@ -1583,18 +1756,19 @@ static int sqlite3_wal_checkpoint_v2( sqlite3_mutex_leave(db->mutex); return rc; #endif - } + } - /* - ** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points - ** to contains a zero-length string, all attached databases are - ** checkpointed. - */ - static int sqlite3_wal_checkpoint(sqlite3 db, string zDb) { - int dummy; - return sqlite3_wal_checkpoint_v2(db, zDb, SQLITE_CHECKPOINT_PASSIVE, out dummy, out dummy); - } + /* + ** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points + ** to contains a zero-length string, all attached databases are + ** checkpointed. + */ + static int sqlite3_wal_checkpoint( sqlite3 db, string zDb ) + { + int dummy; + return sqlite3_wal_checkpoint_v2( db, zDb, SQLITE_CHECKPOINT_PASSIVE, out dummy, out dummy ); + } #if !SQLITE_OMIT_WAL /* @@ -1641,74 +1815,79 @@ int sqlite3Checkpoint(sqlite3 db, int iDb, int eMode, int *pnLog, int *pnCkpt){ } #endif //* SQLITE_OMIT_WAL */ - /* - /* - ** This function returns true if main-memory should be used instead of - ** a temporary file for transient pager files and statement journals. - ** The value returned depends on the value of db->temp_store (runtime - ** parameter) and the compile time value of SQLITE_TEMP_STORE. The - ** following table describes the relationship between these two values - ** and this functions return value. - ** - ** SQLITE_TEMP_STORE db->temp_store Location of temporary database - ** ----------------- -------------- ------------------------------ - ** 0 any file (return 0) - ** 1 1 file (return 0) - ** 1 2 memory (return 1) - ** 1 0 file (return 0) - ** 2 1 file (return 0) - ** 2 2 memory (return 1) - ** 2 0 memory (return 1) - ** 3 any memory (return 1) - */ - static bool sqlite3TempInMemory(sqlite3 db) { - //#if SQLITE_TEMP_STORE==1 - if (SQLITE_TEMP_STORE == 1) - return (db.temp_store == 2); - //#endif - //#if SQLITE_TEMP_STORE==2 - if (SQLITE_TEMP_STORE == 2) - return (db.temp_store != 1); - //#endif - //#if SQLITE_TEMP_STORE==3 - if (SQLITE_TEMP_STORE == 3) - return true; - //#endif - //#if SQLITE_TEMP_STORE<1 || SQLITE_TEMP_STORE>3 - if (SQLITE_TEMP_STORE < 1 || SQLITE_TEMP_STORE > 3) - return false; - //#endif - return false; - } - - /* - ** Return UTF-8 encoded English language explanation of the most recent - ** error. - */ - public static string sqlite3_errmsg(sqlite3 db) { - string z; - if (db == null) { - return sqlite3ErrStr(SQLITE_NOMEM); - } - if (!sqlite3SafetyCheckSickOrOk(db)) { - return sqlite3ErrStr(SQLITE_MISUSE_BKPT()); - } - sqlite3_mutex_enter(db.mutex); - //if ( db.mallocFailed != 0 ) - //{ - // z = sqlite3ErrStr( SQLITE_NOMEM ); - //} - //else - { - z = sqlite3_value_text(db.pErr); - //Debug.Assert( 0 == db.mallocFailed ); - if (String.IsNullOrEmpty(z)) { - z = sqlite3ErrStr(db.errCode); - } - } - sqlite3_mutex_leave(db.mutex); - return z; + /* + /* + ** This function returns true if main-memory should be used instead of + ** a temporary file for transient pager files and statement journals. + ** The value returned depends on the value of db->temp_store (runtime + ** parameter) and the compile time value of SQLITE_TEMP_STORE. The + ** following table describes the relationship between these two values + ** and this functions return value. + ** + ** SQLITE_TEMP_STORE db->temp_store Location of temporary database + ** ----------------- -------------- ------------------------------ + ** 0 any file (return 0) + ** 1 1 file (return 0) + ** 1 2 memory (return 1) + ** 1 0 file (return 0) + ** 2 1 file (return 0) + ** 2 2 memory (return 1) + ** 2 0 memory (return 1) + ** 3 any memory (return 1) + */ + static bool sqlite3TempInMemory( sqlite3 db ) + { + //#if SQLITE_TEMP_STORE==1 + if ( SQLITE_TEMP_STORE == 1 ) + return ( db.temp_store == 2 ); + //#endif + //#if SQLITE_TEMP_STORE==2 + if ( SQLITE_TEMP_STORE == 2 ) + return ( db.temp_store != 1 ); + //#endif + //#if SQLITE_TEMP_STORE==3 + if ( SQLITE_TEMP_STORE == 3 ) + return true; + //#endif + //#if SQLITE_TEMP_STORE<1 || SQLITE_TEMP_STORE>3 + if ( SQLITE_TEMP_STORE < 1 || SQLITE_TEMP_STORE > 3 ) + return false; + //#endif + return false; + } + + /* + ** Return UTF-8 encoded English language explanation of the most recent + ** error. + */ + public static string sqlite3_errmsg( sqlite3 db ) + { + string z; + if ( db == null ) + { + return sqlite3ErrStr( SQLITE_NOMEM ); + } + if ( !sqlite3SafetyCheckSickOrOk( db ) ) + { + return sqlite3ErrStr( SQLITE_MISUSE_BKPT() ); + } + sqlite3_mutex_enter( db.mutex ); + //if ( db.mallocFailed != 0 ) + //{ + // z = sqlite3ErrStr( SQLITE_NOMEM ); + //} + //else + { + z = sqlite3_value_text( db.pErr ); + //Debug.Assert( 0 == db.mallocFailed ); + if ( String.IsNullOrEmpty( z ) ) + { + z = sqlite3ErrStr( db.errCode ); } + } + sqlite3_mutex_leave( db.mutex ); + return z; + } #if !SQLITE_OMIT_UTF16 /* @@ -1757,113 +1936,128 @@ public static string sqlite3_errmsg(sqlite3 db) { } #endif // * SQLITE_OMIT_UTF16 */ - /* - ** Return the most recent error code generated by an SQLite routine. If NULL is - ** passed to this function, we assume a malloc() failed during sqlite3_open(). + /* +** Return the most recent error code generated by an SQLite routine. If NULL is +** passed to this function, we assume a malloc() failed during sqlite3_open(). +*/ + static public int sqlite3_errcode( sqlite3 db ) + { + if ( db != null && !sqlite3SafetyCheckSickOrOk( db ) ) + { + return SQLITE_MISUSE_BKPT(); + } + if ( null == db /*|| db.mallocFailed != 0 */ ) + { + return SQLITE_NOMEM; + } + return db.errCode & db.errMask; + } + static int sqlite3_extended_errcode( sqlite3 db ) + { + if ( db != null && !sqlite3SafetyCheckSickOrOk( db ) ) + { + return SQLITE_MISUSE_BKPT(); + } + if ( null == db /*|| db.mallocFailed != 0 */ ) + { + return SQLITE_NOMEM; + } + return db.errCode; + } + /* + ** Create a new collating function for database "db". The name is zName + ** and the encoding is enc. */ - static public int sqlite3_errcode(sqlite3 db) { - if (db != null && !sqlite3SafetyCheckSickOrOk(db)) { - return SQLITE_MISUSE_BKPT(); - } - if (null == db /*|| db.mallocFailed != 0 */ ) { - return SQLITE_NOMEM; - } - return db.errCode & db.errMask; - } - static int sqlite3_extended_errcode(sqlite3 db) { - if (db != null && !sqlite3SafetyCheckSickOrOk(db)) { - return SQLITE_MISUSE_BKPT(); - } - if (null == db /*|| db.mallocFailed != 0 */ ) { - return SQLITE_NOMEM; - } - return db.errCode; - } - /* - ** Create a new collating function for database "db". The name is zName - ** and the encoding is enc. - */ - static int createCollation( - sqlite3 db, - string zName, - u8 enc, - u8 collType, - object pCtx, - dxCompare xCompare,//)(void*,int,const void*,int,const void), - dxDelCollSeq xDel//)(void) - ) { - CollSeq pColl; - int enc2; - int nName = sqlite3Strlen30(zName); - - Debug.Assert(sqlite3_mutex_held(db.mutex)); - - /* If SQLITE_UTF16 is specified as the encoding type, transform this - ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the - ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally. - */ - enc2 = enc; - testcase(enc2 == SQLITE_UTF16); - testcase(enc2 == SQLITE_UTF16_ALIGNED); - if (enc2 == SQLITE_UTF16 || enc2 == SQLITE_UTF16_ALIGNED) { - enc2 = SQLITE_UTF16NATIVE; - } - if (enc2 < SQLITE_UTF8 || enc2 > SQLITE_UTF16BE) { - return SQLITE_MISUSE_BKPT(); - } + static int createCollation( + sqlite3 db, + string zName, + u8 enc, + u8 collType, + object pCtx, + dxCompare xCompare,//)(void*,int,const void*,int,const void), + dxDelCollSeq xDel//)(void) + ) + { + CollSeq pColl; + int enc2; + int nName = sqlite3Strlen30( zName ); + + Debug.Assert( sqlite3_mutex_held( db.mutex ) ); + + /* If SQLITE_UTF16 is specified as the encoding type, transform this + ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the + ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally. + */ + enc2 = enc; + testcase( enc2 == SQLITE_UTF16 ); + testcase( enc2 == SQLITE_UTF16_ALIGNED ); + if ( enc2 == SQLITE_UTF16 || enc2 == SQLITE_UTF16_ALIGNED ) + { + enc2 = SQLITE_UTF16NATIVE; + } + if ( enc2 < SQLITE_UTF8 || enc2 > SQLITE_UTF16BE ) + { + return SQLITE_MISUSE_BKPT(); + } - /* Check if this call is removing or replacing an existing collation - ** sequence. If so, and there are active VMs, return busy. If there - ** are no active VMs, invalidate any pre-compiled statements. - */ - pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, 0); - if (pColl != null && pColl.xCmp != null) { - if (db.activeVdbeCnt != 0) { - sqlite3Error(db, SQLITE_BUSY, - "unable to delete/modify collation sequence due to active statements"); - return SQLITE_BUSY; - } - sqlite3ExpirePreparedStatements(db); - - /* If collation sequence pColl was created directly by a call to - ** sqlite3_create_collation, and not generated by synthCollSeq(), - ** then any copies made by synthCollSeq() need to be invalidated. - ** Also, collation destructor - CollSeq.xDel() - function may need - ** to be called. - */ - if ((pColl.enc & ~SQLITE_UTF16_ALIGNED) == enc2) { - CollSeq[] aColl = sqlite3HashFind(db.aCollSeq, zName, nName, (CollSeq[])null); - int j; - for (j = 0; j < 3; j++) { - CollSeq p = aColl[j]; - if (p.enc == pColl.enc) { - if (p.xDel != null) { - p.xDel(ref p.pUser); - } - p.xCmp = null; - } - } - } + /* Check if this call is removing or replacing an existing collation + ** sequence. If so, and there are active VMs, return busy. If there + ** are no active VMs, invalidate any pre-compiled statements. + */ + pColl = sqlite3FindCollSeq( db, (u8)enc2, zName, 0 ); + if ( pColl != null && pColl.xCmp != null ) + { + if ( db.activeVdbeCnt != 0 ) + { + sqlite3Error( db, SQLITE_BUSY, + "unable to delete/modify collation sequence due to active statements" ); + return SQLITE_BUSY; + } + sqlite3ExpirePreparedStatements( db ); + + /* If collation sequence pColl was created directly by a call to + ** sqlite3_create_collation, and not generated by synthCollSeq(), + ** then any copies made by synthCollSeq() need to be invalidated. + ** Also, collation destructor - CollSeq.xDel() - function may need + ** to be called. + */ + if ( ( pColl.enc & ~SQLITE_UTF16_ALIGNED ) == enc2 ) + { + CollSeq[] aColl = sqlite3HashFind( db.aCollSeq, zName, nName, (CollSeq[])null ); + int j; + for ( j = 0; j < 3; j++ ) + { + CollSeq p = aColl[j]; + if ( p.enc == pColl.enc ) + { + if ( p.xDel != null ) + { + p.xDel( ref p.pUser ); + } + p.xCmp = null; } - - pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, 1); - //if ( pColl == null ) - // return SQLITE_NOMEM; - pColl.xCmp = xCompare; - pColl.pUser = pCtx; - pColl.xDel = xDel; - pColl.enc = (u8)(enc2 | (enc & SQLITE_UTF16_ALIGNED)); - pColl.type = collType; - sqlite3Error(db, SQLITE_OK, 0); - return SQLITE_OK; + } } + } - /* - ** This array defines hard upper bounds on limit values. The - ** initializer must be kept in sync with the SQLITE_LIMIT_* - ** #defines in sqlite3.h. - */ - static int[] aHardLimit = new int[] { + pColl = sqlite3FindCollSeq( db, (u8)enc2, zName, 1 ); + //if ( pColl == null ) + // return SQLITE_NOMEM; + pColl.xCmp = xCompare; + pColl.pUser = pCtx; + pColl.xDel = xDel; + pColl.enc = (u8)( enc2 | ( enc & SQLITE_UTF16_ALIGNED ) ); + pColl.type = collType; + sqlite3Error( db, SQLITE_OK, 0 ); + return SQLITE_OK; + } + + /* + ** This array defines hard upper bounds on limit values. The + ** initializer must be kept in sync with the SQLITE_LIMIT_* + ** #defines in sqlite3.h. + */ + static int[] aHardLimit = new int[] { SQLITE_MAX_LENGTH, SQLITE_MAX_SQL_LENGTH, SQLITE_MAX_COLUMN, @@ -1877,435 +2071,455 @@ static int createCollation( SQLITE_MAX_TRIGGER_DEPTH, }; - /* - ** Make sure the hard limits are set to reasonable values - */ - //#if SQLITE_MAX_LENGTH<100 - //# error SQLITE_MAX_LENGTH must be at least 100 - //#endif - //#if SQLITE_MAX_SQL_LENGTH<100 - //# error SQLITE_MAX_SQL_LENGTH must be at least 100 - //#endif - //#if SQLITE_MAX_SQL_LENGTH>SQLITE_MAX_LENGTH - //# error SQLITE_MAX_SQL_LENGTH must not be greater than SQLITE_MAX_LENGTH - //#endif - //#if SQLITE_MAX_COMPOUND_SELECT<2 - //# error SQLITE_MAX_COMPOUND_SELECT must be at least 2 - //#endif - //#if SQLITE_MAX_VDBE_OP<40 - //# error SQLITE_MAX_VDBE_OP must be at least 40 - //#endif - //#if SQLITE_MAX_FUNCTION_ARG<0 || SQLITE_MAX_FUNCTION_ARG>1000 - //# error SQLITE_MAX_FUNCTION_ARG must be between 0 and 1000 - //#endif - //#if SQLITE_MAX_ATTACHED<0 || SQLITE_MAX_ATTACHED>62 - //# error SQLITE_MAX_ATTACHED must be between 0 and 62 - //#endif - //#if SQLITE_MAX_LIKE_PATTERN_LENGTH<1 - //# error SQLITE_MAX_LIKE_PATTERN_LENGTH must be at least 1 - //#endif - //#if SQLITE_MAX_COLUMN>32767 - //# error SQLITE_MAX_COLUMN must not exceed 32767 - //#endif - //#if SQLITE_MAX_TRIGGER_DEPTH<1 - //# error SQLITE_MAX_TRIGGER_DEPTH must be at least 1 - //#endif - - /* - ** Change the value of a limit. Report the old value. - ** If an invalid limit index is supplied, report -1. - ** Make no changes but still report the old value if the - ** new limit is negative. - ** - ** A new lower limit does not shrink existing constructs. - ** It merely prevents new constructs that exceed the limit - ** from forming. - */ - static int sqlite3_limit(sqlite3 db, int limitId, int newLimit) { - int oldLimit; - - - /* EVIDENCE-OF: R-30189-54097 For each limit category SQLITE_LIMIT_NAME - ** there is a hard upper bound set at compile-time by a C preprocessor - ** macro called SQLITE_MAX_NAME. (The "_LIMIT_" in the name is changed to - ** "_MAX_".) - */ - Debug.Assert(aHardLimit[SQLITE_LIMIT_LENGTH] == SQLITE_MAX_LENGTH); - Debug.Assert(aHardLimit[SQLITE_LIMIT_SQL_LENGTH] == SQLITE_MAX_SQL_LENGTH); - Debug.Assert(aHardLimit[SQLITE_LIMIT_COLUMN] == SQLITE_MAX_COLUMN); - Debug.Assert(aHardLimit[SQLITE_LIMIT_EXPR_DEPTH] == SQLITE_MAX_EXPR_DEPTH); - Debug.Assert(aHardLimit[SQLITE_LIMIT_COMPOUND_SELECT] == SQLITE_MAX_COMPOUND_SELECT); - Debug.Assert(aHardLimit[SQLITE_LIMIT_VDBE_OP] == SQLITE_MAX_VDBE_OP); - Debug.Assert(aHardLimit[SQLITE_LIMIT_FUNCTION_ARG] == SQLITE_MAX_FUNCTION_ARG); - Debug.Assert(aHardLimit[SQLITE_LIMIT_ATTACHED] == SQLITE_MAX_ATTACHED); - Debug.Assert(aHardLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] == - SQLITE_MAX_LIKE_PATTERN_LENGTH); - Debug.Assert(aHardLimit[SQLITE_LIMIT_VARIABLE_NUMBER] == SQLITE_MAX_VARIABLE_NUMBER); - Debug.Assert(aHardLimit[SQLITE_LIMIT_TRIGGER_DEPTH] == SQLITE_MAX_TRIGGER_DEPTH); - Debug.Assert(SQLITE_LIMIT_TRIGGER_DEPTH == (SQLITE_N_LIMIT - 1)); - - - if (limitId < 0 || limitId >= SQLITE_N_LIMIT) { - return -1; - } - oldLimit = db.aLimit[limitId]; - if (newLimit >= 0) /* IMP: R-52476-28732 */ - { - if (newLimit > aHardLimit[limitId]) { - newLimit = aHardLimit[limitId]; /* IMP: R-51463-25634 */ - } - db.aLimit[limitId] = newLimit; - } - return oldLimit; /* IMP: R-53341-35419 */ - } + /* + ** Make sure the hard limits are set to reasonable values + */ + //#if SQLITE_MAX_LENGTH<100 + //# error SQLITE_MAX_LENGTH must be at least 100 + //#endif + //#if SQLITE_MAX_SQL_LENGTH<100 + //# error SQLITE_MAX_SQL_LENGTH must be at least 100 + //#endif + //#if SQLITE_MAX_SQL_LENGTH>SQLITE_MAX_LENGTH + //# error SQLITE_MAX_SQL_LENGTH must not be greater than SQLITE_MAX_LENGTH + //#endif + //#if SQLITE_MAX_COMPOUND_SELECT<2 + //# error SQLITE_MAX_COMPOUND_SELECT must be at least 2 + //#endif + //#if SQLITE_MAX_VDBE_OP<40 + //# error SQLITE_MAX_VDBE_OP must be at least 40 + //#endif + //#if SQLITE_MAX_FUNCTION_ARG<0 || SQLITE_MAX_FUNCTION_ARG>1000 + //# error SQLITE_MAX_FUNCTION_ARG must be between 0 and 1000 + //#endif + //#if SQLITE_MAX_ATTACHED<0 || SQLITE_MAX_ATTACHED>62 + //# error SQLITE_MAX_ATTACHED must be between 0 and 62 + //#endif + //#if SQLITE_MAX_LIKE_PATTERN_LENGTH<1 + //# error SQLITE_MAX_LIKE_PATTERN_LENGTH must be at least 1 + //#endif + //#if SQLITE_MAX_COLUMN>32767 + //# error SQLITE_MAX_COLUMN must not exceed 32767 + //#endif + //#if SQLITE_MAX_TRIGGER_DEPTH<1 + //# error SQLITE_MAX_TRIGGER_DEPTH must be at least 1 + //#endif + + /* + ** Change the value of a limit. Report the old value. + ** If an invalid limit index is supplied, report -1. + ** Make no changes but still report the old value if the + ** new limit is negative. + ** + ** A new lower limit does not shrink existing constructs. + ** It merely prevents new constructs that exceed the limit + ** from forming. + */ + static int sqlite3_limit( sqlite3 db, int limitId, int newLimit ) + { + int oldLimit; - class OpenMode { - public string z; - public int mode; - public OpenMode(string z, int mode) { - this.z = z; - this.mode = mode; - } - } - /* - ** This function is used to parse both URIs and non-URI filenames passed by the - ** user to API functions sqlite3_open() or sqlite3_open_v2(), and for database - ** URIs specified as part of ATTACH statements. - ** - ** The first argument to this function is the name of the VFS to use (or - ** a NULL to signify the default VFS) if the URI does not contain a "vfs=xxx" - ** query parameter. The second argument contains the URI (or non-URI filename) - ** itself. When this function is called the *pFlags variable should contain - ** the default flags to open the database handle with. The value stored in - ** *pFlags may be updated before returning if the URI filename contains - ** "cache=xxx" or "mode=xxx" query parameters. + /* EVIDENCE-OF: R-30189-54097 For each limit category SQLITE_LIMIT_NAME + ** there is a hard upper bound set at compile-time by a C preprocessor + ** macro called SQLITE_MAX_NAME. (The "_LIMIT_" in the name is changed to + ** "_MAX_".) + */ + Debug.Assert( aHardLimit[SQLITE_LIMIT_LENGTH] == SQLITE_MAX_LENGTH ); + Debug.Assert( aHardLimit[SQLITE_LIMIT_SQL_LENGTH] == SQLITE_MAX_SQL_LENGTH ); + Debug.Assert( aHardLimit[SQLITE_LIMIT_COLUMN] == SQLITE_MAX_COLUMN ); + Debug.Assert( aHardLimit[SQLITE_LIMIT_EXPR_DEPTH] == SQLITE_MAX_EXPR_DEPTH ); + Debug.Assert( aHardLimit[SQLITE_LIMIT_COMPOUND_SELECT] == SQLITE_MAX_COMPOUND_SELECT ); + Debug.Assert( aHardLimit[SQLITE_LIMIT_VDBE_OP] == SQLITE_MAX_VDBE_OP ); + Debug.Assert( aHardLimit[SQLITE_LIMIT_FUNCTION_ARG] == SQLITE_MAX_FUNCTION_ARG ); + Debug.Assert( aHardLimit[SQLITE_LIMIT_ATTACHED] == SQLITE_MAX_ATTACHED ); + Debug.Assert( aHardLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] == + SQLITE_MAX_LIKE_PATTERN_LENGTH ); + Debug.Assert( aHardLimit[SQLITE_LIMIT_VARIABLE_NUMBER] == SQLITE_MAX_VARIABLE_NUMBER ); + Debug.Assert( aHardLimit[SQLITE_LIMIT_TRIGGER_DEPTH] == SQLITE_MAX_TRIGGER_DEPTH ); + Debug.Assert( SQLITE_LIMIT_TRIGGER_DEPTH == ( SQLITE_N_LIMIT - 1 ) ); + + + if ( limitId < 0 || limitId >= SQLITE_N_LIMIT ) + { + return -1; + } + oldLimit = db.aLimit[limitId]; + if ( newLimit >= 0 ) /* IMP: R-52476-28732 */ + { + if ( newLimit > aHardLimit[limitId] ) + { + newLimit = aHardLimit[limitId]; /* IMP: R-51463-25634 */ + } + db.aLimit[limitId] = newLimit; + } + return oldLimit; /* IMP: R-53341-35419 */ + } + + class OpenMode { + public string z; + public int mode; + + public OpenMode(string z, int mode) + { + this.z=z; + this.mode=mode; + } + } + /* +** This function is used to parse both URIs and non-URI filenames passed by the +** user to API functions sqlite3_open() or sqlite3_open_v2(), and for database +** URIs specified as part of ATTACH statements. +** +** The first argument to this function is the name of the VFS to use (or +** a NULL to signify the default VFS) if the URI does not contain a "vfs=xxx" +** query parameter. The second argument contains the URI (or non-URI filename) +** itself. When this function is called the *pFlags variable should contain +** the default flags to open the database handle with. The value stored in +** *pFlags may be updated before returning if the URI filename contains +** "cache=xxx" or "mode=xxx" query parameters. +** +** If successful, SQLITE_OK is returned. In this case *ppVfs is set to point to +** the VFS that should be used to open the database file. *pzFile is set to +** point to a buffer containing the name of the file to open. It is the +** responsibility of the caller to eventually call sqlite3_free() to release +** this buffer. +** +** If an error occurs, then an SQLite error code is returned and *pzErrMsg +** may be set to point to a buffer containing an English language error +** message. It is the responsibility of the caller to eventually release +** this buffer by calling sqlite3_free(). +*/ +static int sqlite3ParseUri( + string zDefaultVfs, /* VFS to use if no "vfs=xxx" query option */ + string zUri, /* Nul-terminated URI to parse */ + ref int pFlags, /* IN/OUT: SQLITE_OPEN_XXX flags */ + ref sqlite3_vfs ppVfs, /* OUT: VFS to use */ + ref string pzFile, /* OUT: Filename component of URI */ + ref string pzErrMsg /* OUT: Error message (if rc!=SQLITE_OK) */ +){ + int rc = SQLITE_OK; + int flags = pFlags; + string zVfs = zDefaultVfs; + StringBuilder zFile = null; + char c; + int nUri = sqlite3Strlen30(zUri); + pzErrMsg = null; + ppVfs = null; + + if( ((flags & SQLITE_OPEN_URI) != 0 || sqlite3GlobalConfig.bOpenUri) + && nUri>=5 && memcmp(zUri, "file:", 5)==0 + ){ + string zOpt; + int eState; /* Parser state when parsing URI */ + int iIn; /* Input character index */ + //int iOut = 0; /* Output character index */ + int nByte = nUri+2; /* Bytes of space to allocate */ + + /* Make sure the SQLITE_OPEN_URI flag is set to indicate to the VFS xOpen + ** method that there may be extra parameters following the file-name. */ + flags |= SQLITE_OPEN_URI; + + for ( iIn = 0; iIn < nUri; iIn++ ) + nByte += ( zUri[iIn] == '&' ) ? 1 : 0; + //zFile = sqlite3_malloc(nByte); + //if( null==zFile ) return SQLITE_NOMEM; + zFile = new StringBuilder( nByte ); + + /* Discard the scheme and authority segments of the URI. */ + if( zUri[5]=='/' && zUri[6]=='/' ){ + iIn = 7; + while ( iIn < nUri && zUri[iIn] != '/' ) + iIn++; + + if ( iIn != 7 && ( iIn != 16 || !string.Equals("localhost", zUri.Substring( 7, 9 ), StringComparison.OrdinalIgnoreCase)) )//memcmp("localhost", &zUri[7], 9)) ) + { + pzErrMsg = sqlite3_mprintf("invalid uri authority: %.*s", + iIn-7, zUri.Substring(7)); + rc = SQLITE_ERROR; + goto parse_uri_out; + } + }else{ + iIn = 5; + } + + /* Copy the filename and any query parameters into the zFile buffer. + ** Decode %HH escape codes along the way. ** - ** If successful, SQLITE_OK is returned. In this case *ppVfs is set to point to - ** the VFS that should be used to open the database file. *pzFile is set to - ** point to a buffer containing the name of the file to open. It is the - ** responsibility of the caller to eventually call sqlite3_free() to release - ** this buffer. + ** Within this loop, variable eState may be set to 0, 1 or 2, depending + ** on the parsing context. As follows: ** - ** If an error occurs, then an SQLite error code is returned and *pzErrMsg - ** may be set to point to a buffer containing an English language error - ** message. It is the responsibility of the caller to eventually release - ** this buffer by calling sqlite3_free(). + ** 0: Parsing file-name. + ** 1: Parsing name section of a name=value query parameter. + ** 2: Parsing value section of a name=value query parameter. */ - static int sqlite3ParseUri( - string zDefaultVfs, /* VFS to use if no "vfs=xxx" query option */ - string zUri, /* Nul-terminated URI to parse */ - ref int pFlags, /* IN/OUT: SQLITE_OPEN_XXX flags */ - ref sqlite3_vfs ppVfs, /* OUT: VFS to use */ - ref string pzFile, /* OUT: Filename component of URI */ - ref string pzErrMsg /* OUT: Error message (if rc!=SQLITE_OK) */ - ) { - int rc = SQLITE_OK; - int flags = pFlags; - string zVfs = zDefaultVfs; - StringBuilder zFile = null; - char c; - int nUri = sqlite3Strlen30(zUri); - pzErrMsg = null; - ppVfs = null; - - if (((flags & SQLITE_OPEN_URI) != 0 || sqlite3GlobalConfig.bOpenUri) - && nUri >= 5 && memcmp(zUri, "file:", 5) == 0 - ) { - string zOpt; - int eState; /* Parser state when parsing URI */ - int iIn; /* Input character index */ - //int iOut = 0; /* Output character index */ - int nByte = nUri + 2; /* Bytes of space to allocate */ - - /* Make sure the SQLITE_OPEN_URI flag is set to indicate to the VFS xOpen - ** method that there may be extra parameters following the file-name. */ - flags |= SQLITE_OPEN_URI; - - for (iIn = 0; iIn < nUri; iIn++) - nByte += (zUri[iIn] == '&') ? 1 : 0; - //zFile = sqlite3_malloc(nByte); - //if( null==zFile ) return SQLITE_NOMEM; - zFile = new StringBuilder(nByte); - - /* Discard the scheme and authority segments of the URI. */ - if (zUri[5] == '/' && zUri[6] == '/') { - iIn = 7; - while (iIn < nUri && zUri[iIn] != '/') - iIn++; - - if (iIn != 7 && (iIn != 16 || !string.Equals("localhost", zUri.Substring(7, 9), StringComparison.OrdinalIgnoreCase)))//memcmp("localhost", &zUri[7], 9)) ) - { - pzErrMsg = sqlite3_mprintf("invalid uri authority: %.*s", - iIn - 7, zUri.Substring(7)); - rc = SQLITE_ERROR; - goto parse_uri_out; - } - } else { - iIn = 5; - } - - /* Copy the filename and any query parameters into the zFile buffer. - ** Decode %HH escape codes along the way. - ** - ** Within this loop, variable eState may be set to 0, 1 or 2, depending - ** on the parsing context. As follows: - ** - ** 0: Parsing file-name. - ** 1: Parsing name section of a name=value query parameter. - ** 2: Parsing value section of a name=value query parameter. - */ - eState = 0; - while (iIn < nUri && (c = zUri[iIn]) != 0 && c != '#') { - iIn++; - if (c == '%' - && sqlite3Isxdigit(zUri[iIn]) - && sqlite3Isxdigit(zUri[iIn + 1]) - ) { - int octet = (sqlite3HexToInt(zUri[iIn++]) << 4); - octet += sqlite3HexToInt(zUri[iIn++]); - - Debug.Assert(octet >= 0 && octet < 256); - if (octet == 0) { - /* This branch is taken when "%00" appears within the URI. In this - ** case we ignore all text in the remainder of the path, name or - ** value currently being parsed. So ignore the current character - ** and skip to the next "?", "=" or "&", as appropriate. */ - while (iIn < nUri && (c = zUri[iIn]) != 0 && c != '#' - && (eState != 0 || c != '?') - && (eState != 1 || (c != '=' && c != '&')) - && (eState != 2 || c != '&') - ) { - iIn++; - } - continue; - } - c = (char)octet; - } else if (eState == 1 && (c == '&' || c == '=')) { - if (zFile[zFile.Length - 1] == '\0') { - /* An empty option name. Ignore this option altogether. */ - while (zUri[iIn] != '\0' && zUri[iIn] != '#' && zUri[iIn - 1] != '&') iIn++; - continue; - } - if (c == '&') { - zFile.Append('\0');//[iOut++] = '\0'; - } else { - eState = 2; - } - c = '\0'; - } else if ((eState == 0 && c == '?') || (eState == 2 && c == '&')) { - c = '\0'; - eState = 1; - } - zFile.Append(c);// zFile[iOut++] = c; - } - if (eState == 1) - zFile.Append('\0');//[iOut++] = '\0'; - zFile.Append('\0');//[iOut++] = '\0'; - zFile.Append('\0');//[iOut++] = '\0'; - - /* Check if there were any options specified that should be interpreted - ** here. Options that are interpreted here include "vfs" and those that - ** correspond to flags that may be passed to the sqlite3_open_v2() - ** method. */ - zOpt = zFile.ToString().Substring(sqlite3Strlen30(zFile) + 1); - while (zOpt.Length > 0) { - int nOpt = sqlite3Strlen30(zOpt); - string zVal = zOpt.Substring(nOpt);//zOpt[nOpt + 1]; - int nVal = sqlite3Strlen30(zVal); - - if (nOpt == 3 && memcmp("vfs", zOpt, 3) == 0) { - zVfs = zVal; - } else { - OpenMode[] aMode = null; - string zModeType = ""; - int mask = 0; - int limit = 0; - - if (nOpt == 5 && memcmp("cache", zOpt, 5) == 0) { - OpenMode[] aCacheMode = new OpenMode[] { + eState = 0; + while ( iIn < nUri&& ( c = zUri[iIn] ) != 0 && c != '#' ) + { + iIn++; + if( c=='%' + && sqlite3Isxdigit(zUri[iIn]) + && sqlite3Isxdigit(zUri[iIn+1]) + ){ + int octet = (sqlite3HexToInt(zUri[iIn++]) << 4); + octet += sqlite3HexToInt(zUri[iIn++]); + + Debug.Assert( octet >= 0 && octet < 256 ); + if ( octet == 0 ) + { + /* This branch is taken when "%00" appears within the URI. In this + ** case we ignore all text in the remainder of the path, name or + ** value currently being parsed. So ignore the current character + ** and skip to the next "?", "=" or "&", as appropriate. */ + while ( iIn < nUri && ( c = zUri[iIn] ) != 0 && c != '#' + && (eState!=0 || c!='?') + && (eState!=1 || (c!='=' && c!='&')) + && (eState!=2 || c!='&') + ){ + iIn++; + } + continue; + } + c = (char)octet; + }else if( eState==1 && (c=='&' || c=='=') ){ + if ( zFile[zFile.Length-1] == '\0' ) + { + /* An empty option name. Ignore this option altogether. */ + while( zUri[iIn] != '\0' && zUri[iIn]!='#' && zUri[iIn-1]!='&' ) iIn++; + continue; + } + if( c=='&' ){ + zFile.Append('\0');//[iOut++] = '\0'; + }else{ + eState = 2; + } + c = '\0'; + }else if( (eState==0 && c=='?') || (eState==2 && c=='&') ){ + c = '\0'; + eState = 1; + } + zFile.Append(c);// zFile[iOut++] = c; + } + if ( eState == 1 ) + zFile.Append( '\0' );//[iOut++] = '\0'; + zFile.Append( '\0' );//[iOut++] = '\0'; + zFile.Append( '\0' );//[iOut++] = '\0'; + + /* Check if there were any options specified that should be interpreted + ** here. Options that are interpreted here include "vfs" and those that + ** correspond to flags that may be passed to the sqlite3_open_v2() + ** method. */ + zOpt = zFile.ToString().Substring(sqlite3Strlen30( zFile ) + 1); + while( zOpt.Length>0 ){ + int nOpt = sqlite3Strlen30(zOpt); + string zVal = zOpt.Substring( nOpt );//zOpt[nOpt + 1]; + int nVal = sqlite3Strlen30(zVal); + + if( nOpt==3 && memcmp("vfs", zOpt, 3)==0 ){ + zVfs = zVal; + }else{ + OpenMode[] aMode = null; + string zModeType = ""; + int mask = 0; + int limit = 0; + + if( nOpt==5 && memcmp("cache", zOpt, 5)==0 ){ + OpenMode[] aCacheMode = new OpenMode[] { new OpenMode( "shared", SQLITE_OPEN_SHAREDCACHE ), new OpenMode( "private", SQLITE_OPEN_PRIVATECACHE ), new OpenMode( null, 0 ) }; - mask = SQLITE_OPEN_SHAREDCACHE | SQLITE_OPEN_PRIVATECACHE; - aMode = aCacheMode; - limit = mask; - zModeType = "cache"; - } - if (nOpt == 4 && memcmp("mode", zOpt, 4) == 0) { - OpenMode[] aOpenMode = new OpenMode[] { + mask = SQLITE_OPEN_SHAREDCACHE|SQLITE_OPEN_PRIVATECACHE; + aMode = aCacheMode; + limit = mask; + zModeType = "cache"; + } + if( nOpt==4 && memcmp("mode", zOpt, 4)==0 ){ + OpenMode[] aOpenMode = new OpenMode[] { new OpenMode( "ro", SQLITE_OPEN_READONLY ), - new OpenMode( "rw", SQLITE_OPEN_READWRITE ), + new OpenMode( "rw", SQLITE_OPEN_READWRITE ), new OpenMode( "rwc", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE ), new OpenMode( null, 0 ) }; - mask = SQLITE_OPEN_READONLY | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; - aMode = aOpenMode; - limit = mask & flags; - zModeType = "access"; - } - - if (aMode != null) { - int i; - int mode = 0; - for (i = 0; aMode[i].z != null; i++) { - string z = aMode[i].z; - if (nVal == sqlite3Strlen30(z) && 0 == memcmp(zVal, z, nVal)) { - mode = aMode[i].mode; - break; - } - } - if (mode == 0) { - pzErrMsg = sqlite3_mprintf("no such %s mode: %s", zModeType, zVal); - rc = SQLITE_ERROR; - goto parse_uri_out; - } - if (mode > limit) { - pzErrMsg = sqlite3_mprintf("%s mode not allowed: %s", - zModeType, zVal); - rc = SQLITE_PERM; - goto parse_uri_out; - } - flags = ((flags & ~mask) | mode); - } - } - - zOpt = zVal.Substring(nVal + 1); - } + mask = SQLITE_OPEN_READONLY|SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE; + aMode = aOpenMode; + limit = mask & flags; + zModeType = "access"; + } + + if( aMode != null){ + int i; + int mode = 0; + for(i=0; aMode[i].z!= null; i++){ + string z = aMode[i].z; + if( nVal==sqlite3Strlen30(z) && 0==memcmp(zVal, z, nVal) ){ + mode = aMode[i].mode; + break; + } + } + if( mode==0 ){ + pzErrMsg = sqlite3_mprintf("no such %s mode: %s", zModeType, zVal); + rc = SQLITE_ERROR; + goto parse_uri_out; + } + if( mode>limit ){ + pzErrMsg = sqlite3_mprintf("%s mode not allowed: %s", + zModeType, zVal); + rc = SQLITE_PERM; + goto parse_uri_out; + } + flags = ((flags & ~mask) | mode); + } + } - } else { - //zFile = sqlite3_malloc(nUri+2); - //if( null==zFile ) return SQLITE_NOMEM; - //memcpy(zFile, zUri, nUri); - zFile = zUri == null ? new StringBuilder() : new StringBuilder(zUri.Substring(0, nUri)); - zFile.Append('\0');//[iOut++] = '\0'; - zFile.Append('\0');//[iOut++] = '\0'; - } + zOpt = zVal.Substring(nVal+1); + } - ppVfs = sqlite3_vfs_find(zVfs); - if (ppVfs == null) { - pzErrMsg = sqlite3_mprintf("no such vfs: %s", zVfs); - rc = SQLITE_ERROR; - } - parse_uri_out: - if (rc != SQLITE_OK) { - //sqlite3_free(zFile); - zFile = null; - } - pFlags = flags; - pzFile = zFile == null ? null : zFile.ToString().Substring(0, sqlite3Strlen30(zFile.ToString())); - return rc; - } + }else{ + //zFile = sqlite3_malloc(nUri+2); + //if( null==zFile ) return SQLITE_NOMEM; + //memcpy(zFile, zUri, nUri); + zFile = zUri == null ? new StringBuilder() : new StringBuilder(zUri.Substring( 0, nUri )); + zFile.Append( '\0' );//[iOut++] = '\0'; + zFile.Append( '\0' );//[iOut++] = '\0'; + } - /* - ** This routine does the work of opening a database on behalf of - ** sqlite3_open() and sqlite3_open16(). The database filename "zFilename" - ** is UTF-8 encoded. - */ - static int openDatabase( - string zFilename, /* Database filename UTF-8 encoded */ - out sqlite3 ppDb, /* OUT: Returned database handle */ - int flags, /* Operational flags */ - string zVfs /* Name of the VFS to use */ - ) { - sqlite3 db; /* Store allocated handle here */ - int rc; /* Return code */ - int isThreadsafe; /* True for threadsafe connections */ - string zOpen = ""; /* Filename argument to pass to BtreeOpen() */ - string zErrMsg = ""; /* Error message from sqlite3ParseUri() */ - - ppDb = null; + ppVfs = sqlite3_vfs_find(zVfs); + if( ppVfs==null ){ + pzErrMsg = sqlite3_mprintf("no such vfs: %s", zVfs); + rc = SQLITE_ERROR; + } + parse_uri_out: + if( rc!=SQLITE_OK ){ + //sqlite3_free(zFile); + zFile = null; + } + pFlags = flags; + pzFile = zFile == null ? null : zFile.ToString().Substring( 0, sqlite3Strlen30( zFile.ToString() ) ); + return rc; +} + + /* + ** This routine does the work of opening a database on behalf of + ** sqlite3_open() and sqlite3_open16(). The database filename "zFilename" + ** is UTF-8 encoded. + */ + static int openDatabase( + string zFilename, /* Database filename UTF-8 encoded */ + out sqlite3 ppDb, /* OUT: Returned database handle */ + int flags, /* Operational flags */ + string zVfs /* Name of the VFS to use */ + ) + { + sqlite3 db; /* Store allocated handle here */ + int rc; /* Return code */ + int isThreadsafe; /* True for threadsafe connections */ + string zOpen = ""; /* Filename argument to pass to BtreeOpen() */ + string zErrMsg = ""; /* Error message from sqlite3ParseUri() */ + + ppDb = null; #if !SQLITE_OMIT_AUTOINIT - rc = sqlite3_initialize(); - if (rc != 0) - return rc; + rc = sqlite3_initialize(); + if ( rc != 0 ) + return rc; #endif - /* Only allow sensible combinations of bits in the flags argument. - ** Throw an error if any non-sense combination is used. If we - ** do not block illegal combinations here, it could trigger - ** Debug.Assert() statements in deeper layers. Sensible combinations - ** are: + /* Only allow sensible combinations of bits in the flags argument. +** Throw an error if any non-sense combination is used. If we +** do not block illegal combinations here, it could trigger +** Debug.Assert() statements in deeper layers. Sensible combinations +** are: +** +** 1: SQLITE_OPEN_READONLY +** 2: SQLITE_OPEN_READWRITE +** 6: SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE +*/ + Debug.Assert( SQLITE_OPEN_READONLY == 0x01 ); + Debug.Assert( SQLITE_OPEN_READWRITE == 0x02 ); + Debug.Assert( SQLITE_OPEN_CREATE == 0x04 ); + testcase( ( 1 << ( flags & 7 ) ) == 0x02 ); /* READONLY */ + testcase( ( 1 << ( flags & 7 ) ) == 0x04 ); /* READWRITE */ + testcase( ( 1 << ( flags & 7 ) ) == 0x40 ); /* READWRITE | CREATE */ + if ( ( ( 1 << ( flags & 7 ) ) & 0x46 ) == 0 ) return SQLITE_MISUSE_BKPT(); + + if ( sqlite3GlobalConfig.bCoreMutex == false ) + { + isThreadsafe = 0; + } + else if ( ( flags & SQLITE_OPEN_NOMUTEX ) != 0 ) + { + isThreadsafe = 0; + } + else if ( ( flags & SQLITE_OPEN_FULLMUTEX ) != 0 ) + { + isThreadsafe = 1; + } + else + { + isThreadsafe = sqlite3GlobalConfig.bFullMutex ? 1 : 0; + } + if ( ( flags & SQLITE_OPEN_PRIVATECACHE ) != 0 ) + { + flags &= ~SQLITE_OPEN_SHAREDCACHE; + } + else if ( sqlite3GlobalConfig.sharedCacheEnabled ) + { + flags |= SQLITE_OPEN_SHAREDCACHE; + } + + /* Remove harmful bits from the flags parameter ** - ** 1: SQLITE_OPEN_READONLY - ** 2: SQLITE_OPEN_READWRITE - ** 6: SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE + ** The SQLITE_OPEN_NOMUTEX and SQLITE_OPEN_FULLMUTEX flags were + ** dealt with in the previous code block. Besides these, the only + ** valid input flags for sqlite3_open_v2() are SQLITE_OPEN_READONLY, + ** SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE, SQLITE_OPEN_SHAREDCACHE, + ** SQLITE_OPEN_PRIVATECACHE, and some reserved bits. Silently mask + ** off all other flags. */ - Debug.Assert(SQLITE_OPEN_READONLY == 0x01); - Debug.Assert(SQLITE_OPEN_READWRITE == 0x02); - Debug.Assert(SQLITE_OPEN_CREATE == 0x04); - testcase((1 << (flags & 7)) == 0x02); /* READONLY */ - testcase((1 << (flags & 7)) == 0x04); /* READWRITE */ - testcase((1 << (flags & 7)) == 0x40); /* READWRITE | CREATE */ - if (((1 << (flags & 7)) & 0x46) == 0) return SQLITE_MISUSE_BKPT(); - - if (sqlite3GlobalConfig.bCoreMutex == false) { - isThreadsafe = 0; - } else if ((flags & SQLITE_OPEN_NOMUTEX) != 0) { - isThreadsafe = 0; - } else if ((flags & SQLITE_OPEN_FULLMUTEX) != 0) { - isThreadsafe = 1; - } else { - isThreadsafe = sqlite3GlobalConfig.bFullMutex ? 1 : 0; - } - if ((flags & SQLITE_OPEN_PRIVATECACHE) != 0) { - flags &= ~SQLITE_OPEN_SHAREDCACHE; - } else if (sqlite3GlobalConfig.sharedCacheEnabled) { - flags |= SQLITE_OPEN_SHAREDCACHE; - } - - /* Remove harmful bits from the flags parameter - ** - ** The SQLITE_OPEN_NOMUTEX and SQLITE_OPEN_FULLMUTEX flags were - ** dealt with in the previous code block. Besides these, the only - ** valid input flags for sqlite3_open_v2() are SQLITE_OPEN_READONLY, - ** SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE, SQLITE_OPEN_SHAREDCACHE, - ** SQLITE_OPEN_PRIVATECACHE, and some reserved bits. Silently mask - ** off all other flags. - */ - flags &= ~(SQLITE_OPEN_DELETEONCLOSE | - SQLITE_OPEN_EXCLUSIVE | - SQLITE_OPEN_MAIN_DB | - SQLITE_OPEN_TEMP_DB | - SQLITE_OPEN_TRANSIENT_DB | - SQLITE_OPEN_MAIN_JOURNAL | - SQLITE_OPEN_TEMP_JOURNAL | - SQLITE_OPEN_SUBJOURNAL | - SQLITE_OPEN_MASTER_JOURNAL | - SQLITE_OPEN_NOMUTEX | - SQLITE_OPEN_FULLMUTEX | - SQLITE_OPEN_WAL - ); - - - /* Allocate the sqlite data structure */ - db = new sqlite3();//sqlite3MallocZero( sqlite3.Length ); - if (db == null) - goto opendb_out; - if (sqlite3GlobalConfig.bFullMutex && isThreadsafe != 0) { - db.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_RECURSIVE); - if (db.mutex == null) { - //sqlite3_free( ref db ); - goto opendb_out; - } - } - sqlite3_mutex_enter(db.mutex); - db.errMask = 0xff; - db.nDb = 2; - db.magic = SQLITE_MAGIC_BUSY; - Array.Copy(db.aDbStatic, db.aDb, db.aDbStatic.Length);// db.aDb = db.aDbStatic; - Debug.Assert(db.aLimit.Length == aHardLimit.Length); - Buffer.BlockCopy(aHardLimit, 0, db.aLimit, 0, aHardLimit.Length * sizeof(int));//memcpy(db.aLimit, aHardLimit, sizeof(db.aLimit)); - db.autoCommit = 1; - db.nextAutovac = -1; - db.nextPagesize = 0; - db.flags |= SQLITE_ShortColNames | SQLITE_AutoIndex | SQLITE_EnableTrigger; - if (SQLITE_DEFAULT_FILE_FORMAT < 4) - db.flags |= SQLITE_LegacyFileFmt -#if SQLITE_ENABLE_LOAD_EXTENSION + flags &= ~( SQLITE_OPEN_DELETEONCLOSE | + SQLITE_OPEN_EXCLUSIVE | + SQLITE_OPEN_MAIN_DB | + SQLITE_OPEN_TEMP_DB | + SQLITE_OPEN_TRANSIENT_DB | + SQLITE_OPEN_MAIN_JOURNAL | + SQLITE_OPEN_TEMP_JOURNAL | + SQLITE_OPEN_SUBJOURNAL | + SQLITE_OPEN_MASTER_JOURNAL | + SQLITE_OPEN_NOMUTEX | + SQLITE_OPEN_FULLMUTEX | + SQLITE_OPEN_WAL + ); + + + /* Allocate the sqlite data structure */ + db = new sqlite3();//sqlite3MallocZero( sqlite3.Length ); + if ( db == null ) + goto opendb_out; + if ( sqlite3GlobalConfig.bFullMutex && isThreadsafe != 0 ) + { + db.mutex = sqlite3MutexAlloc( SQLITE_MUTEX_RECURSIVE ); + if ( db.mutex == null ) + { + //sqlite3_free( ref db ); + goto opendb_out; + } + } + sqlite3_mutex_enter( db.mutex ); + db.errMask = 0xff; + db.nDb = 2; + db.magic = SQLITE_MAGIC_BUSY; + Array.Copy( db.aDbStatic, db.aDb, db.aDbStatic.Length );// db.aDb = db.aDbStatic; + Debug.Assert( db.aLimit.Length == aHardLimit.Length ); + Buffer.BlockCopy( aHardLimit, 0, db.aLimit, 0, aHardLimit.Length * sizeof( int ) );//memcpy(db.aLimit, aHardLimit, sizeof(db.aLimit)); + db.autoCommit = 1; + db.nextAutovac = -1; + db.nextPagesize = 0; + db.flags |= SQLITE_ShortColNames | SQLITE_AutoIndex | SQLITE_EnableTrigger; + if ( SQLITE_DEFAULT_FILE_FORMAT < 4 ) + db.flags |= SQLITE_LegacyFileFmt +#if SQLITE_ENABLE_LOAD_EXTENSION | SQLITE_LoadExtension #endif #if SQLITE_DEFAULT_RECURSIVE_TRIGGERS @@ -2314,112 +2528,115 @@ string zVfs /* Name of the VFS to use */ #if (SQLITE_DEFAULT_FOREIGN_KEYS) //&& SQLITE_DEFAULT_FOREIGN_KEYS | SQLITE_ForeignKeys #endif - ; - sqlite3HashInit(db.aCollSeq); +; + sqlite3HashInit( db.aCollSeq ); #if !SQLITE_OMIT_VIRTUALTABLE - db.aModule = new Hash(); - sqlite3HashInit(db.aModule); + db.aModule = new Hash(); + sqlite3HashInit( db.aModule ); #endif - /* Add the default collation sequence BINARY. BINARY works for both UTF-8 - ** and UTF-16, so add a version for each to avoid any unnecessary - ** conversions. The only error that can occur here is a malloc() failure. - */ - createCollation(db, "BINARY", SQLITE_UTF8, SQLITE_COLL_BINARY, 0, - binCollFunc, null); - createCollation(db, "BINARY", SQLITE_UTF16BE, SQLITE_COLL_BINARY, 0, - binCollFunc, null); - createCollation(db, "BINARY", SQLITE_UTF16LE, SQLITE_COLL_BINARY, 0, - binCollFunc, null); - createCollation(db, "RTRIM", SQLITE_UTF8, SQLITE_COLL_USER, 1, - binCollFunc, null); - //if ( db.mallocFailed != 0 ) - //{ - // goto opendb_out; - //} - db.pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 0); - Debug.Assert(db.pDfltColl != null); - - /* Also add a UTF-8 case-insensitive collation sequence. */ - createCollation(db, "NOCASE", SQLITE_UTF8, SQLITE_COLL_NOCASE, 0, - nocaseCollatingFunc, null); - - /* Parse the filename/URI argument. */ - db.openFlags = flags; - rc = sqlite3ParseUri(zVfs, zFilename, ref flags, ref db.pVfs, ref zOpen, ref zErrMsg); - if (rc != SQLITE_OK) { - //if( rc==SQLITE_NOMEM ) db.mallocFailed = 1; - sqlite3Error(db, rc, zErrMsg.Length > 0 ? "%s" : "", zErrMsg); - //sqlite3_free(zErrMsg); - goto opendb_out; - } + /* Add the default collation sequence BINARY. BINARY works for both UTF-8 + ** and UTF-16, so add a version for each to avoid any unnecessary + ** conversions. The only error that can occur here is a malloc() failure. + */ + createCollation( db, "BINARY", SQLITE_UTF8, SQLITE_COLL_BINARY, 0, + binCollFunc, null ); + createCollation( db, "BINARY", SQLITE_UTF16BE, SQLITE_COLL_BINARY, 0, + binCollFunc, null ); + createCollation( db, "BINARY", SQLITE_UTF16LE, SQLITE_COLL_BINARY, 0, + binCollFunc, null ); + createCollation( db, "RTRIM", SQLITE_UTF8, SQLITE_COLL_USER, 1, + binCollFunc, null ); + //if ( db.mallocFailed != 0 ) + //{ + // goto opendb_out; + //} + db.pDfltColl = sqlite3FindCollSeq( db, SQLITE_UTF8, "BINARY", 0 ); + Debug.Assert( db.pDfltColl != null ); + + /* Also add a UTF-8 case-insensitive collation sequence. */ + createCollation( db, "NOCASE", SQLITE_UTF8, SQLITE_COLL_NOCASE, 0, + nocaseCollatingFunc, null ); + + /* Parse the filename/URI argument. */ + db.openFlags = flags; + rc = sqlite3ParseUri( zVfs, zFilename, ref flags, ref db.pVfs, ref zOpen, ref zErrMsg ); + if( rc!=SQLITE_OK ){ + //if( rc==SQLITE_NOMEM ) db.mallocFailed = 1; + sqlite3Error(db, rc, zErrMsg.Length>0 ? "%s" : "", zErrMsg); + //sqlite3_free(zErrMsg); + goto opendb_out; + } - /* Open the backend database driver */ - rc = sqlite3BtreeOpen(db.pVfs, zOpen, db, ref db.aDb[0].pBt, 0, - flags | SQLITE_OPEN_MAIN_DB); - if (rc != SQLITE_OK) { - if (rc == SQLITE_IOERR_NOMEM) { - rc = SQLITE_NOMEM; - } - sqlite3Error(db, rc, 0); - goto opendb_out; - } - db.aDb[0].pSchema = sqlite3SchemaGet(db, db.aDb[0].pBt); - db.aDb[1].pSchema = sqlite3SchemaGet(db, null); - - - /* The default safety_level for the main database is 'full'; for the temp - ** database it is 'NONE'. This matches the pager layer defaults. - */ - db.aDb[0].zName = "main"; - db.aDb[0].safety_level = 3; - db.aDb[1].zName = "temp"; - db.aDb[1].safety_level = 1; - - db.magic = SQLITE_MAGIC_OPEN; - //if ( db.mallocFailed != 0 ) - //{ - // goto opendb_out; - //} - - /* Register all built-in functions, but do not attempt to read the - ** database schema yet. This is delayed until the first time the database - ** is accessed. - */ - sqlite3Error(db, SQLITE_OK, 0); - sqlite3RegisterBuiltinFunctions(db); - - /* Load automatic extensions - extensions that have been registered - ** using the sqlite3_automatic_extension() API. - */ - sqlite3AutoLoadExtensions(db); - rc = sqlite3_errcode(db); - if (rc != SQLITE_OK) { - goto opendb_out; - } + /* Open the backend database driver */ + rc = sqlite3BtreeOpen(db.pVfs, zOpen, db, ref db.aDb[0].pBt, 0, + flags | SQLITE_OPEN_MAIN_DB); +if ( rc != SQLITE_OK ) + { + if ( rc == SQLITE_IOERR_NOMEM ) + { + rc = SQLITE_NOMEM; + } + sqlite3Error( db, rc, 0 ); + goto opendb_out; + } + db.aDb[0].pSchema = sqlite3SchemaGet( db, db.aDb[0].pBt ); + db.aDb[1].pSchema = sqlite3SchemaGet( db, null ); -#if SQLITE_ENABLE_FTS1 + /* The default safety_level for the main database is 'full'; for the temp + ** database it is 'NONE'. This matches the pager layer defaults. + */ + db.aDb[0].zName = "main"; + db.aDb[0].safety_level = 3; + db.aDb[1].zName = "temp"; + db.aDb[1].safety_level = 1; + + db.magic = SQLITE_MAGIC_OPEN; + //if ( db.mallocFailed != 0 ) + //{ + // goto opendb_out; + //} + + /* Register all built-in functions, but do not attempt to read the + ** database schema yet. This is delayed until the first time the database + ** is accessed. + */ + sqlite3Error( db, SQLITE_OK, 0 ); + sqlite3RegisterBuiltinFunctions( db ); + + /* Load automatic extensions - extensions that have been registered + ** using the sqlite3_automatic_extension() API. + */ + sqlite3AutoLoadExtensions( db ); + rc = sqlite3_errcode( db ); + if ( rc != SQLITE_OK ) + { + goto opendb_out; + } + + +#if SQLITE_ENABLE_FTS1 if( 0==db.mallocFailed ){ extern int sqlite3Fts1Init(sqlite3); rc = sqlite3Fts1Init(db); } #endif -#if SQLITE_ENABLE_FTS2 +#if SQLITE_ENABLE_FTS2 if( 0==db.mallocFailed && rc==SQLITE_OK ){ extern int sqlite3Fts2Init(sqlite3); rc = sqlite3Fts2Init(db); } #endif -#if SQLITE_ENABLE_FTS3 +#if SQLITE_ENABLE_FTS3 if( 0==db.mallocFailed && rc==SQLITE_OK ){ rc = sqlite3Fts3Init(db); } #endif -#if SQLITE_ENABLE_ICU +#if SQLITE_ENABLE_ICU if( 0==db.mallocFailed && rc==SQLITE_OK ){ extern int sqlite3IcuInit(sqlite3); rc = sqlite3IcuInit(db); @@ -2432,60 +2649,66 @@ string zVfs /* Name of the VFS to use */ } #endif - sqlite3Error(db, rc, 0); + sqlite3Error( db, rc, 0 ); - /* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking - ** mode. -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking - ** mode. Doing nothing at all also makes NORMAL the default. - */ -#if SQLITE_DEFAULT_LOCKING_MODE + /* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking + ** mode. -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking + ** mode. Doing nothing at all also makes NORMAL the default. + */ +#if SQLITE_DEFAULT_LOCKING_MODE db.dfltLockMode = SQLITE_DEFAULT_LOCKING_MODE; sqlite3PagerLockingMode(sqlite3BtreePager(db.aDb[0].pBt), SQLITE_DEFAULT_LOCKING_MODE); #endif - /* Enable the lookaside-malloc subsystem */ - setupLookaside(db, null, sqlite3GlobalConfig.szLookaside, - sqlite3GlobalConfig.nLookaside); + /* Enable the lookaside-malloc subsystem */ + setupLookaside( db, null, sqlite3GlobalConfig.szLookaside, + sqlite3GlobalConfig.nLookaside ); - sqlite3_wal_autocheckpoint(db, SQLITE_DEFAULT_WAL_AUTOCHECKPOINT); + sqlite3_wal_autocheckpoint( db, SQLITE_DEFAULT_WAL_AUTOCHECKPOINT ); - opendb_out: - //sqlite3_free(zOpen); - if (db != null) { - Debug.Assert(db.mutex != null || isThreadsafe == 0 || !sqlite3GlobalConfig.bFullMutex); - sqlite3_mutex_leave(db.mutex); - } - rc = sqlite3_errcode(db); - if (rc == SQLITE_NOMEM) { - sqlite3_close(db); - db = null; - } else if (rc != SQLITE_OK) { - db.magic = SQLITE_MAGIC_SICK; - } - ppDb = db; - return sqlite3ApiExit(0, rc); - } +opendb_out: + //sqlite3_free(zOpen); + if ( db != null ) + { + Debug.Assert( db.mutex != null || isThreadsafe == 0 || !sqlite3GlobalConfig.bFullMutex ); + sqlite3_mutex_leave( db.mutex ); + } + rc = sqlite3_errcode( db ); + if ( rc == SQLITE_NOMEM ) + { + sqlite3_close( db ); + db = null; + } + else if ( rc != SQLITE_OK ) + { + db.magic = SQLITE_MAGIC_SICK; + } + ppDb = db; + return sqlite3ApiExit( 0, rc ); + } - /* - ** Open a new database handle. - */ - static public int sqlite3_open( - string zFilename, - out sqlite3 ppDb - ) { - return openDatabase(zFilename, out ppDb, - SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, null); - } + /* + ** Open a new database handle. + */ + static public int sqlite3_open( + string zFilename, + out sqlite3 ppDb + ) + { + return openDatabase( zFilename, out ppDb, + SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, null ); + } - static public int sqlite3_open_v2( - string filename, /* Database filename (UTF-8) */ - out sqlite3 ppDb, /* OUT: SQLite db handle */ - int flags, /* Flags */ - string zVfs /* Name of VFS module to use */ - ) { - return openDatabase(filename, out ppDb, flags, zVfs); - } + static public int sqlite3_open_v2( + string filename, /* Database filename (UTF-8) */ + out sqlite3 ppDb, /* OUT: SQLite db handle */ + int flags, /* Flags */ + string zVfs /* Name of VFS module to use */ + ) + { + return openDatabase( filename, out ppDb, flags, zVfs ); + } #if !SQLITE_OMIT_UTF16 @@ -2526,44 +2749,46 @@ int sqlite3_open16( } #endif // * SQLITE_OMIT_UTF16 */ - /* + /* +** Register a new collation sequence with the database handle db. +*/ + public static int sqlite3_create_collation( + sqlite3 db, + string zName, + int enc, + object pCtx, + dxCompare xCompare + ) + { + int rc; + sqlite3_mutex_enter( db.mutex ); + //Debug.Assert( 0 == db.mallocFailed ); + rc = createCollation( db, zName, (u8)enc, SQLITE_COLL_USER, pCtx, xCompare, null ); + rc = sqlite3ApiExit( db, rc ); + sqlite3_mutex_leave( db.mutex ); + return rc; + } + + /* ** Register a new collation sequence with the database handle db. */ - public static int sqlite3_create_collation( - sqlite3 db, - string zName, - int enc, - object pCtx, - dxCompare xCompare - ) { - int rc; - sqlite3_mutex_enter(db.mutex); - //Debug.Assert( 0 == db.mallocFailed ); - rc = createCollation(db, zName, (u8)enc, SQLITE_COLL_USER, pCtx, xCompare, null); - rc = sqlite3ApiExit(db, rc); - sqlite3_mutex_leave(db.mutex); - return rc; - } - - /* - ** Register a new collation sequence with the database handle db. - */ - static int sqlite3_create_collation_v2( - sqlite3 db, - string zName, - int enc, - object pCtx, - dxCompare xCompare, //int(*xCompare)(void*,int,const void*,int,const void), - dxDelCollSeq xDel //void(*xDel)(void) - ) { - int rc; - sqlite3_mutex_enter(db.mutex); - //Debug.Assert( 0 == db.mallocFailed ); - rc = createCollation(db, zName, (u8)enc, SQLITE_COLL_USER, pCtx, xCompare, xDel); - rc = sqlite3ApiExit(db, rc); - sqlite3_mutex_leave(db.mutex); - return rc; - } + static int sqlite3_create_collation_v2( + sqlite3 db, + string zName, + int enc, + object pCtx, + dxCompare xCompare, //int(*xCompare)(void*,int,const void*,int,const void), + dxDelCollSeq xDel //void(*xDel)(void) + ) + { + int rc; + sqlite3_mutex_enter( db.mutex ); + //Debug.Assert( 0 == db.mallocFailed ); + rc = createCollation( db, zName, (u8)enc, SQLITE_COLL_USER, pCtx, xCompare, xDel ); + rc = sqlite3ApiExit( db, rc ); + sqlite3_mutex_leave( db.mutex ); + return rc; + } #if !SQLITE_OMIT_UTF16 /* @@ -2591,22 +2816,23 @@ static int sqlite3_create_collation_v2( //} #endif // * SQLITE_OMIT_UTF16 */ - /* - ** Register a collation sequence factory callback with the database handle - ** db. Replace any previously installed collation sequence factory. - */ - static int sqlite3_collation_needed( - sqlite3 db, - object pCollNeededArg, - dxCollNeeded xCollNeeded - ) { - sqlite3_mutex_enter(db.mutex); - db.xCollNeeded = xCollNeeded; - db.xCollNeeded16 = null; - db.pCollNeededArg = pCollNeededArg; - sqlite3_mutex_leave(db.mutex); - return SQLITE_OK; - } + /* +** Register a collation sequence factory callback with the database handle +** db. Replace any previously installed collation sequence factory. +*/ + static int sqlite3_collation_needed( + sqlite3 db, + object pCollNeededArg, + dxCollNeeded xCollNeeded + ) + { + sqlite3_mutex_enter( db.mutex ); + db.xCollNeeded = xCollNeeded; + db.xCollNeeded16 = null; + db.pCollNeededArg = pCollNeededArg; + sqlite3_mutex_leave( db.mutex ); + return SQLITE_OK; + } #if !SQLITE_OMIT_UTF16 /* @@ -2638,50 +2864,54 @@ static int sqlite3_global_recover() } #endif - /* - ** Test to see whether or not the database connection is in autocommit - ** mode. Return TRUE if it is and FALSE if not. Autocommit mode is on - ** by default. Autocommit is disabled by a BEGIN statement and reenabled - ** by the next COMMIT or ROLLBACK. + /* +** Test to see whether or not the database connection is in autocommit +** mode. Return TRUE if it is and FALSE if not. Autocommit mode is on +** by default. Autocommit is disabled by a BEGIN statement and reenabled +** by the next COMMIT or ROLLBACK. +** +******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ****** +*/ + static u8 sqlite3_get_autocommit( sqlite3 db ) + { + return db.autoCommit; + } + + /* + ** The following routines are subtitutes for constants SQLITE_CORRUPT, + ** SQLITE_MISUSE, SQLITE_CANTOPEN, SQLITE_IOERR and possibly other error + ** constants. They server two purposes: + ** + ** 1. Serve as a convenient place to set a breakpoint in a debugger + ** to detect when version error conditions occurs. ** - ******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ****** + ** 2. Invoke sqlite3_log() to provide the source code location where + ** a low-level error is first detected. */ - static u8 sqlite3_get_autocommit(sqlite3 db) { - return db.autoCommit; - } - - /* - ** The following routines are subtitutes for constants SQLITE_CORRUPT, - ** SQLITE_MISUSE, SQLITE_CANTOPEN, SQLITE_IOERR and possibly other error - ** constants. They server two purposes: - ** - ** 1. Serve as a convenient place to set a breakpoint in a debugger - ** to detect when version error conditions occurs. - ** - ** 2. Invoke sqlite3_log() to provide the source code location where - ** a low-level error is first detected. - */ - static int sqlite3CorruptError(int lineno) { - testcase(sqlite3GlobalConfig.xLog != null); - sqlite3_log(SQLITE_CORRUPT, - "database corruption at line %d of [%.10s]", - lineno, 20 + sqlite3_sourceid()); - return SQLITE_CORRUPT; - } - static int sqlite3MisuseError(int lineno) { - testcase(sqlite3GlobalConfig.xLog != null); - sqlite3_log(SQLITE_MISUSE, - "misuse at line %d of [%.10s]", - lineno, 20 + sqlite3_sourceid()); - return SQLITE_MISUSE; - } - static int sqlite3CantopenError(int lineno) { - testcase(sqlite3GlobalConfig.xLog != null); - sqlite3_log(SQLITE_CANTOPEN, - "cannot open file at line %d of [%.10s]", - lineno, 20 + sqlite3_sourceid()); - return SQLITE_CANTOPEN; - } + static int sqlite3CorruptError( int lineno ) + { + testcase( sqlite3GlobalConfig.xLog != null ); + sqlite3_log( SQLITE_CORRUPT, + "database corruption at line %d of [%.10s]", + lineno, 20 + sqlite3_sourceid() ); + return SQLITE_CORRUPT; + } + static int sqlite3MisuseError( int lineno ) + { + testcase( sqlite3GlobalConfig.xLog != null ); + sqlite3_log( SQLITE_MISUSE, + "misuse at line %d of [%.10s]", + lineno, 20 + sqlite3_sourceid() ); + return SQLITE_MISUSE; + } + static int sqlite3CantopenError( int lineno ) + { + testcase( sqlite3GlobalConfig.xLog != null ); + sqlite3_log( SQLITE_CANTOPEN, + "cannot open file at line %d of [%.10s]", + lineno, 20 + sqlite3_sourceid() ); + return SQLITE_CANTOPEN; + } #if !SQLITE_OMIT_DEPRECATED /* @@ -2695,459 +2925,505 @@ void sqlite3_thread_cleanup() { } #endif - /* - ** Return meta information about a specific column of a database table. - ** See comment in sqlite3.h (sqlite.h.in) for details. - */ + /* +** Return meta information about a specific column of a database table. +** See comment in sqlite3.h (sqlite.h.in) for details. +*/ #if SQLITE_ENABLE_COLUMN_METADATA - public static int sqlite3_table_column_metadata( - sqlite3 db, /* Connection handle */ - string zDbName, /* Database name or NULL */ - string zTableName, /* Table name */ - string zColumnName, /* Column name */ - ref string pzDataType, /* OUTPUT: Declared data type */ - ref string pzCollSeq, /* OUTPUT: Collation sequence name */ - ref int pNotNull, /* OUTPUT: True if NOT NULL constraint exists */ - ref int pPrimaryKey, /* OUTPUT: True if column part of PK */ - ref int pAutoinc /* OUTPUT: True if column is auto-increment */ - ) { - int rc; - string zErrMsg = ""; - Table pTab = null; - Column pCol = null; - int iCol; - - string zDataType = null; - string zCollSeq = null; - int notnull = 0; - int primarykey = 0; - int autoinc = 0; - - /* Ensure the database schema has been loaded */ - sqlite3_mutex_enter(db.mutex); - sqlite3BtreeEnterAll(db); - rc = sqlite3Init(db, ref zErrMsg); - if (SQLITE_OK != rc) { - goto error_out; - } + public static int sqlite3_table_column_metadata( + sqlite3 db, /* Connection handle */ + string zDbName, /* Database name or NULL */ + string zTableName, /* Table name */ + string zColumnName, /* Column name */ + ref string pzDataType, /* OUTPUT: Declared data type */ + ref string pzCollSeq, /* OUTPUT: Collation sequence name */ + ref int pNotNull, /* OUTPUT: True if NOT NULL constraint exists */ + ref int pPrimaryKey, /* OUTPUT: True if column part of PK */ + ref int pAutoinc /* OUTPUT: True if column is auto-increment */ + ) + { + int rc; + string zErrMsg = ""; + Table pTab = null; + Column pCol = null; + int iCol; + + string zDataType = null; + string zCollSeq = null; + int notnull = 0; + int primarykey = 0; + int autoinc = 0; + + /* Ensure the database schema has been loaded */ + sqlite3_mutex_enter( db.mutex ); + sqlite3BtreeEnterAll( db ); + rc = sqlite3Init( db, ref zErrMsg ); + if ( SQLITE_OK != rc ) + { + goto error_out; + } - /* Locate the table in question */ - pTab = sqlite3FindTable(db, zTableName, zDbName); - if (null == pTab || pTab.pSelect != null) { - pTab = null; - goto error_out; - } + /* Locate the table in question */ + pTab = sqlite3FindTable( db, zTableName, zDbName ); + if ( null == pTab || pTab.pSelect != null ) + { + pTab = null; + goto error_out; + } - /* Find the column for which info is requested */ - if (sqlite3IsRowid(zColumnName)) { - iCol = pTab.iPKey; - if (iCol >= 0) { - pCol = pTab.aCol[iCol]; - } - } else { - for (iCol = 0; iCol < pTab.nCol; iCol++) { - pCol = pTab.aCol[iCol]; - if (pCol.zName.Equals(zColumnName, StringComparison.OrdinalIgnoreCase)) { - break; - } - } - if (iCol == pTab.nCol) { - pTab = null; - goto error_out; - } - } + /* Find the column for which info is requested */ + if ( sqlite3IsRowid( zColumnName ) ) + { + iCol = pTab.iPKey; + if ( iCol >= 0 ) + { + pCol = pTab.aCol[iCol]; + } + } + else + { + for ( iCol = 0; iCol < pTab.nCol; iCol++ ) + { + pCol = pTab.aCol[iCol]; + if ( pCol.zName.Equals( zColumnName, StringComparison.OrdinalIgnoreCase ) ) + { + break; + } + } + if ( iCol == pTab.nCol ) + { + pTab = null; + goto error_out; + } + } - /* The following block stores the meta information that will be returned - ** to the caller in local variables zDataType, zCollSeq, notnull, primarykey - ** and autoinc. At this point there are two possibilities: - ** - ** 1. The specified column name was rowid", "oid" or "_rowid_" - ** and there is no explicitly declared IPK column. - ** - ** 2. The table is not a view and the column name identified an - ** explicitly declared column. Copy meta information from pCol. - */ - if (pCol != null) { - zDataType = pCol.zType; - zCollSeq = pCol.zColl; - notnull = pCol.notNull != 0 ? 1 : 0; - primarykey = pCol.isPrimKey != 0 ? 1 : 0; - autoinc = (pTab.iPKey == iCol && (pTab.tabFlags & TF_Autoincrement) != 0) ? 1 : 0; - } else { - zDataType = "INTEGER"; - primarykey = 1; - } - if (String.IsNullOrEmpty(zCollSeq)) { - zCollSeq = "BINARY"; - } + /* The following block stores the meta information that will be returned + ** to the caller in local variables zDataType, zCollSeq, notnull, primarykey + ** and autoinc. At this point there are two possibilities: + ** + ** 1. The specified column name was rowid", "oid" or "_rowid_" + ** and there is no explicitly declared IPK column. + ** + ** 2. The table is not a view and the column name identified an + ** explicitly declared column. Copy meta information from pCol. + */ + if ( pCol != null ) + { + zDataType = pCol.zType; + zCollSeq = pCol.zColl; + notnull = pCol.notNull != 0 ? 1 : 0; + primarykey = pCol.isPrimKey != 0 ? 1 : 0; + autoinc = ( pTab.iPKey == iCol && ( pTab.tabFlags & TF_Autoincrement ) != 0 ) ? 1 : 0; + } + else + { + zDataType = "INTEGER"; + primarykey = 1; + } + if ( String.IsNullOrEmpty( zCollSeq ) ) + { + zCollSeq = "BINARY"; + } - error_out: - sqlite3BtreeLeaveAll(db); - - /* Whether the function call succeeded or failed, set the output parameters - ** to whatever their local counterparts contain. If an error did occur, - ** this has the effect of zeroing all output parameters. - */ - //if ( pzDataType ) - pzDataType = zDataType; - //if ( pzCollSeq ) - pzCollSeq = zCollSeq; - //if ( pNotNull ) - pNotNull = notnull; - //if ( pPrimaryKey ) - pPrimaryKey = primarykey; - //if ( pAutoinc ) - pAutoinc = autoinc; - - if (SQLITE_OK == rc && null == pTab) { - sqlite3DbFree(db, ref zErrMsg); - zErrMsg = sqlite3MPrintf(db, "no such table column: %s.%s", zTableName, - zColumnName); - rc = SQLITE_ERROR; - } - sqlite3Error(db, rc, (!String.IsNullOrEmpty(zErrMsg) ? "%s" : null), zErrMsg); - sqlite3DbFree(db, ref zErrMsg); - rc = sqlite3ApiExit(db, rc); - sqlite3_mutex_leave(db.mutex); - return rc; - } +error_out: + sqlite3BtreeLeaveAll( db ); + + /* Whether the function call succeeded or failed, set the output parameters + ** to whatever their local counterparts contain. If an error did occur, + ** this has the effect of zeroing all output parameters. + */ + //if ( pzDataType ) + pzDataType = zDataType; + //if ( pzCollSeq ) + pzCollSeq = zCollSeq; + //if ( pNotNull ) + pNotNull = notnull; + //if ( pPrimaryKey ) + pPrimaryKey = primarykey; + //if ( pAutoinc ) + pAutoinc = autoinc; + + if ( SQLITE_OK == rc && null == pTab ) + { + sqlite3DbFree( db, ref zErrMsg ); + zErrMsg = sqlite3MPrintf( db, "no such table column: %s.%s", zTableName, + zColumnName ); + rc = SQLITE_ERROR; + } + sqlite3Error( db, rc, ( !String.IsNullOrEmpty( zErrMsg ) ? "%s" : null ), zErrMsg ); + sqlite3DbFree( db, ref zErrMsg ); + rc = sqlite3ApiExit( db, rc ); + sqlite3_mutex_leave( db.mutex ); + return rc; + } #endif - /* - ** Sleep for a little while. Return the amount of time slept. + /* +** Sleep for a little while. Return the amount of time slept. +*/ + static public int sqlite3_sleep( int ms ) + { + sqlite3_vfs pVfs; + int rc; + pVfs = sqlite3_vfs_find( null ); + if ( pVfs == null ) + return 0; + + /* This function works in milliseconds, but the underlying OsSleep() + ** API uses microseconds. Hence the 1000's. + */ + rc = ( sqlite3OsSleep( pVfs, 1000 * ms ) / 1000 ); + return rc; + } + + /* + ** Enable or disable the extended result codes. */ - static public int sqlite3_sleep(int ms) { - sqlite3_vfs pVfs; - int rc; - pVfs = sqlite3_vfs_find(null); - if (pVfs == null) - return 0; - - /* This function works in milliseconds, but the underlying OsSleep() - ** API uses microseconds. Hence the 1000's. - */ - rc = (sqlite3OsSleep(pVfs, 1000 * ms) / 1000); - return rc; - } + static int sqlite3_extended_result_codes( sqlite3 db, bool onoff ) + { + sqlite3_mutex_enter( db.mutex ); + db.errMask = (int)( onoff ? 0xffffffff : 0xff ); + sqlite3_mutex_leave( db.mutex ); + return SQLITE_OK; + } - /* - ** Enable or disable the extended result codes. - */ - static int sqlite3_extended_result_codes(sqlite3 db, bool onoff) { - sqlite3_mutex_enter(db.mutex); - db.errMask = (int)(onoff ? 0xffffffff : 0xff); - sqlite3_mutex_leave(db.mutex); - return SQLITE_OK; + /* + ** Invoke the xFileControl method on a particular database. + */ + static int sqlite3_file_control( sqlite3 db, string zDbName, int op, ref sqlite3_int64 pArg ) + { + int rc = SQLITE_ERROR; + int iDb; + sqlite3_mutex_enter( db.mutex ); + if ( zDbName == null ) + { + iDb = 0; + } + else + { + for ( iDb = 0; iDb < db.nDb; iDb++ ) + { + if ( db.aDb[iDb].zName == zDbName ) + break; } - - /* - ** Invoke the xFileControl method on a particular database. - */ - static int sqlite3_file_control(sqlite3 db, string zDbName, int op, ref sqlite3_int64 pArg) { - int rc = SQLITE_ERROR; - int iDb; - sqlite3_mutex_enter(db.mutex); - if (zDbName == null) { - iDb = 0; - } else { - for (iDb = 0; iDb < db.nDb; iDb++) { - if (db.aDb[iDb].zName == zDbName) - break; - } - } - if (iDb < db.nDb) { - Btree pBtree = db.aDb[iDb].pBt; - if (pBtree != null) { - Pager pPager; - sqlite3_file fd; - sqlite3BtreeEnter(pBtree); - pPager = sqlite3BtreePager(pBtree); - Debug.Assert(pPager != null); - fd = sqlite3PagerFile(pPager); - Debug.Assert(fd != null); - if (op == SQLITE_FCNTL_FILE_POINTER) { + } + if ( iDb < db.nDb ) + { + Btree pBtree = db.aDb[iDb].pBt; + if ( pBtree != null ) + { + Pager pPager; + sqlite3_file fd; + sqlite3BtreeEnter( pBtree ); + pPager = sqlite3BtreePager( pBtree ); + Debug.Assert( pPager != null ); + fd = sqlite3PagerFile( pPager ); + Debug.Assert( fd != null ); + if ( op == SQLITE_FCNTL_FILE_POINTER ) + { #if (SQLITE_SILVERLIGHT || WINDOWS_MOBILE || SQLITE_WINRT) pArg = (long)-1; // not supported #else - pArg = (long)fd.fs.Handle; + pArg = (long)fd.fs.Handle; #endif - rc = SQLITE_OK; - } else if (fd.pMethods != null) { - rc = sqlite3OsFileControl(fd, (u32)op, ref pArg); - } else { - rc = SQLITE_NOTFOUND; - } - sqlite3BtreeLeave(pBtree); - } - } - sqlite3_mutex_leave(db.mutex); - return rc; + rc = SQLITE_OK; + } + else if ( fd.pMethods != null ) + { + rc = sqlite3OsFileControl( fd, (u32)op, ref pArg ); + } + else + { + rc = SQLITE_NOTFOUND; + } + sqlite3BtreeLeave( pBtree ); } + } + sqlite3_mutex_leave( db.mutex ); + return rc; + } - /* - ** Interface to the testing logic. - */ - static public int sqlite3_test_control(int op, params object[] ap) { - int rc = 0; + /* + ** Interface to the testing logic. + */ + static public int sqlite3_test_control(int op, params object[] ap) + { + int rc = 0; #if !SQLITE_OMIT_BUILTIN_TEST - // va_list ap; - lock (lock_va_list) { - va_start(ap, "op"); - switch (op) { - - /* - ** Save the current state of the PRNG. - */ - case SQLITE_TESTCTRL_PRNG_SAVE: { - sqlite3PrngSaveState(); - break; - } - - /* - ** Restore the state of the PRNG to the last state saved using - ** PRNG_SAVE. If PRNG_SAVE has never before been called, then - ** this verb acts like PRNG_RESET. - */ - case SQLITE_TESTCTRL_PRNG_RESTORE: { - sqlite3PrngRestoreState(); - break; - } - - /* - ** Reset the PRNG back to its uninitialized state. The next call - ** to sqlite3_randomness() will reseed the PRNG using a single call - ** to the xRandomness method of the default VFS. - */ - case SQLITE_TESTCTRL_PRNG_RESET: { - sqlite3PrngResetState(); - break; - } - - /* - ** sqlite3_test_control(BITVEC_TEST, size, program) - ** - ** Run a test against a Bitvec object of size. The program argument - ** is an array of integers that defines the test. Return -1 on a - ** memory allocation error, 0 on success, or non-zero for an error. - ** See the sqlite3BitvecBuiltinTest() for additional information. - */ - case SQLITE_TESTCTRL_BITVEC_TEST: { - int sz = va_arg(ap, (Int32)0); - int[] aProg = va_arg(ap, (Int32[])null); - rc = sqlite3BitvecBuiltinTest((u32)sz, aProg); - break; - } - - /* - ** sqlite3_test_control(BENIGN_MALLOC_HOOKS, xBegin, xEnd) - ** - ** Register hooks to call to indicate which malloc() failures - ** are benign. - */ - case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: { - //typedef void (*void_function)(void); - void_function xBenignBegin; - void_function xBenignEnd; - xBenignBegin = va_arg(ap, (void_function)null); - xBenignEnd = va_arg(ap, (void_function)null); - sqlite3BenignMallocHooks(xBenignBegin, xBenignEnd); - break; - } - /* - ** sqlite3_test_control(SQLITE_TESTCTRL_PENDING_BYTE, unsigned int X) - ** - ** Set the PENDING byte to the value in the argument, if X>0. - ** Make no changes if X==0. Return the value of the pending byte - ** as it existing before this routine was called. - ** - ** IMPORTANT: Changing the PENDING byte from 0x40000000 results in - ** an incompatible database file format. Changing the PENDING byte - ** while any database connection is open results in undefined and - ** dileterious behavior. - */ - case SQLITE_TESTCTRL_PENDING_BYTE: { - rc = PENDING_BYTE; + // va_list ap; + lock ( lock_va_list ) + { + va_start( ap, "op" ); + switch ( op ) + { + + /* + ** Save the current state of the PRNG. + */ + case SQLITE_TESTCTRL_PRNG_SAVE: + { + sqlite3PrngSaveState(); + break; + } + + /* + ** Restore the state of the PRNG to the last state saved using + ** PRNG_SAVE. If PRNG_SAVE has never before been called, then + ** this verb acts like PRNG_RESET. + */ + case SQLITE_TESTCTRL_PRNG_RESTORE: + { + sqlite3PrngRestoreState(); + break; + } + + /* + ** Reset the PRNG back to its uninitialized state. The next call + ** to sqlite3_randomness() will reseed the PRNG using a single call + ** to the xRandomness method of the default VFS. + */ + case SQLITE_TESTCTRL_PRNG_RESET: + { + sqlite3PrngResetState(); + break; + } + + /* + ** sqlite3_test_control(BITVEC_TEST, size, program) + ** + ** Run a test against a Bitvec object of size. The program argument + ** is an array of integers that defines the test. Return -1 on a + ** memory allocation error, 0 on success, or non-zero for an error. + ** See the sqlite3BitvecBuiltinTest() for additional information. + */ + case SQLITE_TESTCTRL_BITVEC_TEST: + { + int sz = va_arg( ap, ( Int32 ) 0 ); + int[] aProg = va_arg( ap, (Int32[])null ); + rc = sqlite3BitvecBuiltinTest( (u32)sz, aProg ); + break; + } + + /* + ** sqlite3_test_control(BENIGN_MALLOC_HOOKS, xBegin, xEnd) + ** + ** Register hooks to call to indicate which malloc() failures + ** are benign. + */ + case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: + { + //typedef void (*void_function)(void); + void_function xBenignBegin; + void_function xBenignEnd; + xBenignBegin = va_arg( ap, (void_function)null ); + xBenignEnd = va_arg( ap, (void_function)null ); + sqlite3BenignMallocHooks( xBenignBegin, xBenignEnd ); + break; + } + /* + ** sqlite3_test_control(SQLITE_TESTCTRL_PENDING_BYTE, unsigned int X) + ** + ** Set the PENDING byte to the value in the argument, if X>0. + ** Make no changes if X==0. Return the value of the pending byte + ** as it existing before this routine was called. + ** + ** IMPORTANT: Changing the PENDING byte from 0x40000000 results in + ** an incompatible database file format. Changing the PENDING byte + ** while any database connection is open results in undefined and + ** dileterious behavior. + */ + case SQLITE_TESTCTRL_PENDING_BYTE: + { + rc = PENDING_BYTE; #if !SQLITE_OMIT_WSD - { - u32 newVal = va_arg(ap, (UInt32)0); - if (newVal != 0) { - if (sqlite3PendingByte != newVal) - sqlite3PendingByte = (int)newVal; + { + u32 newVal = va_arg( ap, (UInt32)0 ); + if ( newVal != 0 ) + { + if ( sqlite3PendingByte != newVal ) + sqlite3PendingByte = (int)newVal; #if DEBUG && TCLSH TCLsqlite3PendingByte.iValue = sqlite3PendingByte; #endif - PENDING_BYTE = sqlite3PendingByte; - } - } + PENDING_BYTE = sqlite3PendingByte; + } + } #endif - break; - } - - /* - ** sqlite3_test_control(SQLITE_TESTCTRL_ASSERT, int X) - ** - ** This action provides a run-time test to see whether or not - ** Debug.Assert() was enabled at compile-time. If X is true and Debug.Assert() - ** is enabled, then the return value is true. If X is true and - ** Debug.Assert() is disabled, then the return value is zero. If X is - ** false and Debug.Assert() is enabled, then the assertion fires and the - ** process aborts. If X is false and Debug.Assert() is disabled, then the - ** return value is zero. - */ - case SQLITE_TESTCTRL_ASSERT: { - int x = 0; - Debug.Assert((x = va_arg(ap, (Int32)0)) != 0); - rc = x; - break; - } - - - /* - ** sqlite3_test_control(SQLITE_TESTCTRL_ALWAYS, int X) - ** - ** This action provides a run-time test to see how the ALWAYS and - ** NEVER macros were defined at compile-time. - ** - ** The return value is ALWAYS(X). - ** - ** The recommended test is X==2. If the return value is 2, that means - ** ALWAYS() and NEVER() are both no-op pass-through macros, which is the - ** default setting. If the return value is 1, then ALWAYS() is either - ** hard-coded to true or else it asserts if its argument is false. - ** The first behavior (hard-coded to true) is the case if - ** SQLITE_TESTCTRL_ASSERT shows that Debug.Assert() is disabled and the second - ** behavior (assert if the argument to ALWAYS() is false) is the case if - ** SQLITE_TESTCTRL_ASSERT shows that Debug.Assert() is enabled. - ** - ** The run-time test procedure might look something like this: - ** - ** if( sqlite3_test_control(SQLITE_TESTCTRL_ALWAYS, 2)==2 ){ - ** // ALWAYS() and NEVER() are no-op pass-through macros - ** }else if( sqlite3_test_control(SQLITE_TESTCTRL_ASSERT, 1) ){ - ** // ALWAYS(x) asserts that x is true. NEVER(x) asserts x is false. - ** }else{ - ** // ALWAYS(x) is a constant 1. NEVER(x) is a constant 0. - ** } - */ - case SQLITE_TESTCTRL_ALWAYS: { - int x = va_arg(ap, (Int32)0); - rc = ALWAYS(x); - break; - } - - /* sqlite3_test_control(SQLITE_TESTCTRL_RESERVE, sqlite3 db, int N) - ** - ** Set the nReserve size to N for the main database on the database - ** connection db. - */ - case SQLITE_TESTCTRL_RESERVE: { - sqlite3 db = va_arg(ap, (sqlite3)null); - int x = va_arg(ap, (Int32)0); - sqlite3_mutex_enter(db.mutex); - sqlite3BtreeSetPageSize(db.aDb[0].pBt, 0, x, 0); - sqlite3_mutex_leave(db.mutex); - break; - } - - /* sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, sqlite3 db, int N) - ** - ** Enable or disable various optimizations for testing purposes. The - ** argument N is a bitmask of optimizations to be disabled. For normal - ** operation N should be 0. The idea is that a test program (like the - ** SQL Logic Test or SLT test module) can run the same SQL multiple times - ** with various optimizations disabled to verify that the same answer - ** is obtained in every case. - */ - case SQLITE_TESTCTRL_OPTIMIZATIONS: { - sqlite3 db = va_arg(ap, (sqlite3)null);//sqlite3 db = va_arg(ap, sqlite3); - int x = va_arg(ap, (Int32)0);//int x = va_arg(ap,int); - db.flags = (x & SQLITE_OptMask) | (db.flags & ~SQLITE_OptMask); - break; - } - - //#if SQLITE_N_KEYWORD - /* sqlite3_test_control(SQLITE_TESTCTRL_ISKEYWORD, const string zWord) - ** - ** If zWord is a keyword recognized by the parser, then return the - ** number of keywords. Or if zWord is not a keyword, return 0. - ** - ** This test feature is only available in the amalgamation since - ** the SQLITE_N_KEYWORD macro is not defined in this file if SQLite - ** is built using separate source files. - */ - case SQLITE_TESTCTRL_ISKEYWORD: { - string zWord = (string)va_arg(ap, "char*"); - int n = sqlite3Strlen30(zWord); - rc = (sqlite3KeywordCode(zWord, n) != TK_ID) ? SQLITE_N_KEYWORD : 0; - break; - } - //#endif - /* sqlite3_test_control(SQLITE_TESTCTRL_PGHDRSZ) - ** - ** Return the size of a pcache header in bytes. - */ - case SQLITE_TESTCTRL_PGHDRSZ: { - rc = -1;// sizeof(PgHdr); - break; - } - - /* sqlite3_test_control(SQLITE_TESTCTRL_SCRATCHMALLOC, sz, &pNew, pFree); - ** - ** Pass pFree into sqlite3ScratchFree(). - ** If sz>0 then allocate a scratch buffer into pNew. - */ - case SQLITE_TESTCTRL_SCRATCHMALLOC: { - //void pFree, *ppNew; - //int sz; - //sz = va_arg(ap, int); - //ppNew = va_arg(ap, void*); - //pFree = va_arg(ap, void); - //if( sz ) *ppNew = sqlite3ScratchMalloc(sz); - //sqlite3ScratchFree(pFree); - break; - } - /* sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, int onoff); - ** - ** If parameter onoff is non-zero, configure the wrappers so that all - ** subsequent calls to localtime() and variants fail. If onoff is zero, - ** undo this setting. - */ - case SQLITE_TESTCTRL_LOCALTIME_FAULT: { - sqlite3GlobalConfig.bLocaltimeFault = va_arg(ap, (Boolean)true); - break; - } + break; + } + + /* + ** sqlite3_test_control(SQLITE_TESTCTRL_ASSERT, int X) + ** + ** This action provides a run-time test to see whether or not + ** Debug.Assert() was enabled at compile-time. If X is true and Debug.Assert() + ** is enabled, then the return value is true. If X is true and + ** Debug.Assert() is disabled, then the return value is zero. If X is + ** false and Debug.Assert() is enabled, then the assertion fires and the + ** process aborts. If X is false and Debug.Assert() is disabled, then the + ** return value is zero. + */ + case SQLITE_TESTCTRL_ASSERT: + { + int x = 0; + Debug.Assert( ( x = va_arg( ap, ( Int32 ) 0 ) ) != 0 ); + rc = x; + break; + } + + + /* + ** sqlite3_test_control(SQLITE_TESTCTRL_ALWAYS, int X) + ** + ** This action provides a run-time test to see how the ALWAYS and + ** NEVER macros were defined at compile-time. + ** + ** The return value is ALWAYS(X). + ** + ** The recommended test is X==2. If the return value is 2, that means + ** ALWAYS() and NEVER() are both no-op pass-through macros, which is the + ** default setting. If the return value is 1, then ALWAYS() is either + ** hard-coded to true or else it asserts if its argument is false. + ** The first behavior (hard-coded to true) is the case if + ** SQLITE_TESTCTRL_ASSERT shows that Debug.Assert() is disabled and the second + ** behavior (assert if the argument to ALWAYS() is false) is the case if + ** SQLITE_TESTCTRL_ASSERT shows that Debug.Assert() is enabled. + ** + ** The run-time test procedure might look something like this: + ** + ** if( sqlite3_test_control(SQLITE_TESTCTRL_ALWAYS, 2)==2 ){ + ** // ALWAYS() and NEVER() are no-op pass-through macros + ** }else if( sqlite3_test_control(SQLITE_TESTCTRL_ASSERT, 1) ){ + ** // ALWAYS(x) asserts that x is true. NEVER(x) asserts x is false. + ** }else{ + ** // ALWAYS(x) is a constant 1. NEVER(x) is a constant 0. + ** } + */ + case SQLITE_TESTCTRL_ALWAYS: + { + int x = va_arg( ap, ( Int32 ) 0 ); + rc = ALWAYS( x ); + break; + } - } - va_end(ref ap); + /* sqlite3_test_control(SQLITE_TESTCTRL_RESERVE, sqlite3 db, int N) + ** + ** Set the nReserve size to N for the main database on the database + ** connection db. + */ + case SQLITE_TESTCTRL_RESERVE: + { + sqlite3 db = va_arg( ap, (sqlite3)null ); + int x = va_arg( ap, ( Int32 ) 0 ); + sqlite3_mutex_enter( db.mutex ); + sqlite3BtreeSetPageSize( db.aDb[0].pBt, 0, x, 0 ); + sqlite3_mutex_leave( db.mutex ); + break; + } + + /* sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, sqlite3 db, int N) + ** + ** Enable or disable various optimizations for testing purposes. The + ** argument N is a bitmask of optimizations to be disabled. For normal + ** operation N should be 0. The idea is that a test program (like the + ** SQL Logic Test or SLT test module) can run the same SQL multiple times + ** with various optimizations disabled to verify that the same answer + ** is obtained in every case. + */ + case SQLITE_TESTCTRL_OPTIMIZATIONS: + { + sqlite3 db = va_arg( ap, (sqlite3)null );//sqlite3 db = va_arg(ap, sqlite3); + int x = va_arg( ap, (Int32)0 );//int x = va_arg(ap,int); + db.flags = ( x & SQLITE_OptMask ) | ( db.flags & ~SQLITE_OptMask ); + break; + } + + //#if SQLITE_N_KEYWORD + /* sqlite3_test_control(SQLITE_TESTCTRL_ISKEYWORD, const string zWord) + ** + ** If zWord is a keyword recognized by the parser, then return the + ** number of keywords. Or if zWord is not a keyword, return 0. + ** + ** This test feature is only available in the amalgamation since + ** the SQLITE_N_KEYWORD macro is not defined in this file if SQLite + ** is built using separate source files. + */ + case SQLITE_TESTCTRL_ISKEYWORD: + { + string zWord = (string)va_arg( ap, "char*" ); + int n = sqlite3Strlen30( zWord ); + rc = ( sqlite3KeywordCode( zWord, n ) != TK_ID ) ? SQLITE_N_KEYWORD : 0; + break; + } + //#endif + /* sqlite3_test_control(SQLITE_TESTCTRL_PGHDRSZ) + ** + ** Return the size of a pcache header in bytes. + */ + case SQLITE_TESTCTRL_PGHDRSZ: + { + rc = -1;// sizeof(PgHdr); + break; } -#endif //* SQLITE_OMIT_BUILTIN_TEST */ - return rc; - } + /* sqlite3_test_control(SQLITE_TESTCTRL_SCRATCHMALLOC, sz, &pNew, pFree); + ** + ** Pass pFree into sqlite3ScratchFree(). + ** If sz>0 then allocate a scratch buffer into pNew. + */ + case SQLITE_TESTCTRL_SCRATCHMALLOC: + { + //void pFree, *ppNew; + //int sz; + //sz = va_arg(ap, int); + //ppNew = va_arg(ap, void*); + //pFree = va_arg(ap, void); + //if( sz ) *ppNew = sqlite3ScratchMalloc(sz); + //sqlite3ScratchFree(pFree); + break; + } + /* sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, int onoff); + ** + ** If parameter onoff is non-zero, configure the wrappers so that all + ** subsequent calls to localtime() and variants fail. If onoff is zero, + ** undo this setting. + */ + case SQLITE_TESTCTRL_LOCALTIME_FAULT: { + sqlite3GlobalConfig.bLocaltimeFault = va_arg( ap, (Boolean)true ); + break; + } - /* - ** This is a utility routine, useful to VFS implementations, that checks - ** to see if a database file was a URI that contained a specific query - ** parameter, and if so obtains the value of the query parameter. - ** - ** The zFilename argument is the filename pointer passed into the xOpen() - ** method of a VFS implementation. The zParam argument is the name of the - ** query parameter we seek. This routine returns the value of the zParam - ** parameter if it exists. If the parameter does not exist, this routine - ** returns a NULL pointer. - */ - static string sqlite3_uri_parameter(string zFilename, string zParam) { - // TODO -- Implement URI - //zFilename += sqlite3Strlen30(zFilename) + 1; - //while( zFilename[0] ){ - // int x = strcmp(zFilename, zParam); - // zFilename += sqlite3Strlen30(zFilename) + 1; - // if( x==0 ) return zFilename; - // zFilename += sqlite3Strlen30(zFilename) + 1; - //} - return null; } - + va_end( ref ap ); + } +#endif //* SQLITE_OMIT_BUILTIN_TEST */ + return rc; } + + +/* +** This is a utility routine, useful to VFS implementations, that checks +** to see if a database file was a URI that contained a specific query +** parameter, and if so obtains the value of the query parameter. +** +** The zFilename argument is the filename pointer passed into the xOpen() +** method of a VFS implementation. The zParam argument is the name of the +** query parameter we seek. This routine returns the value of the zParam +** parameter if it exists. If the parameter does not exist, this routine +** returns a NULL pointer. +*/ +static string sqlite3_uri_parameter(string zFilename, string zParam){ + // TODO -- Implement URI + //zFilename += sqlite3Strlen30(zFilename) + 1; + //while( zFilename[0] ){ + // int x = strcmp(zFilename, zParam); + // zFilename += sqlite3Strlen30(zFilename) + 1; + // if( x==0 ) return zFilename; + // zFilename += sqlite3Strlen30(zFilename) + 1; + //} + return null; +} + +} } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/malloc_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/malloc_c.cs index 554f7b860..2b45c6ce9 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/malloc_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/malloc_c.cs @@ -1,146 +1,156 @@ using System.Diagnostics; +using System.Text; -namespace Community.CsharpSqlite { - using System; - - using sqlite3_int64 = System.Int64; - using u32 = System.UInt32; - - public partial class Sqlite3 { - /* - ** 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. - ** - ************************************************************************* - ** - ** Memory allocation functions used throughout sqlite. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include - - /* - ** Attempt to release up to n bytes of non-essential memory currently - ** held by SQLite. An example of non-essential memory is memory used to - ** cache database pages that are not currently in use. - */ - static int sqlite3_release_memory(int n) { +namespace Community.CsharpSqlite +{ + using sqlite3_int64 = System.Int64; + using i64 = System.Int64; + using sqlite3_uint64 = System.UInt64; + using u32 = System.UInt32; + using System; + + public partial class Sqlite3 + { + /* + ** 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. + ** + ************************************************************************* + ** + ** Memory allocation functions used throughout sqlite. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include + + /* + ** Attempt to release up to n bytes of non-essential memory currently + ** held by SQLite. An example of non-essential memory is memory used to + ** cache database pages that are not currently in use. + */ + static int sqlite3_release_memory( int n ) + { #if SQLITE_ENABLE_MEMORY_MANAGEMENT int nRet = 0; nRet += sqlite3PcacheReleaseMemory(n-nRet); return nRet; #else - UNUSED_PARAMETER(n); - return SQLITE_OK; + UNUSED_PARAMETER( n ); + return SQLITE_OK; #endif - } + } - /* - ** State information local to the memory allocation subsystem. - */ - //static SQLITE_WSD struct Mem0Global { - public class Mem0Global {/* Number of free pages for scratch and page-cache memory */ - public int nScratchFree; - public int nPageFree; - - public sqlite3_mutex mutex; /* Mutex to serialize access */ - - /* - ** The alarm callback and its arguments. The mem0.mutex lock will - ** be held while the callback is running. Recursive calls into - ** the memory subsystem are allowed, but no new callbacks will be - ** issued. - */ - public sqlite3_int64 alarmThreshold; - public dxalarmCallback alarmCallback; // (*alarmCallback)(void*, sqlite3_int64,int); - public object alarmArg; - - /* - ** Pointers to the end of sqlite3GlobalConfig.pScratch and - ** sqlite3GlobalConfig.pPage to a block of memory that records - ** which pages are available. - */ - //u32 *aScratchFree; - /* - ** True if heap is nearly "full" where "full" is defined by the - ** sqlite3_soft_heap_limit() setting. - */ - public bool nearlyFull; - - public byte[][][] aByte; - public int[] aByteSize; - public int[] aByte_used; - public int[][] aInt; - public Mem[] aMem; - public BtCursor[] aBtCursor; - - public struct memstat { - public int alloc; // # of allocation requests - public int dealloc; // # of deallocations - public int cached; // # of cache hits - public int next; // # Next slot to use - public int max; // # Max slot used - } - - public memstat msByte; - public memstat msInt; - public memstat msMem; - public memstat msBtCursor; - - public Mem0Global() { - } - - public Mem0Global(int nScratchFree, int nPageFree, sqlite3_mutex mutex, sqlite3_int64 alarmThreshold, dxalarmCallback alarmCallback, object alarmArg, int Byte_Allocation, int Int_Allocation, int Mem_Allocation, int BtCursor_Allocation) { - this.nScratchFree = nScratchFree; - this.nPageFree = nPageFree; - this.mutex = mutex; - this.alarmThreshold = alarmThreshold; - this.alarmCallback = alarmCallback; - this.alarmArg = alarmArg; - this.msByte.next = -1; - this.msInt.next = -1; - this.msMem.next = -1; - this.aByteSize = new int[] { 32, 256, 1024, 8192, 0 }; - this.aByte_used = new int[] { -1, -1, -1, -1, -1 }; - this.aByte = new byte[this.aByteSize.Length][][]; - for (int i = 0; i < this.aByteSize.Length; i++) - this.aByte[i] = new byte[Byte_Allocation][]; - this.aInt = new int[Int_Allocation][]; - this.aMem = new Mem[Mem_Allocation <= 4 ? 4 : Mem_Allocation]; - this.aBtCursor = new BtCursor[BtCursor_Allocation <= 4 ? 4 : BtCursor_Allocation]; - this.nearlyFull = false; - } - } - //mem0 = { 0, 0, 0, 0, 0, 0, 0, 0 }; - - //#define mem0 GLOBAL(struct Mem0Global, mem0) - static Mem0Global mem0 = new Mem0Global(); - - /* - ** This routine runs when the memory allocator sees that the - ** total memory allocation is about to exceed the soft heap - ** limit. - */ - static void softHeapLimitEnforcer( - object NotUsed, - sqlite3_int64 NotUsed2, - int allocSize - ) { - UNUSED_PARAMETER2(NotUsed, NotUsed2); - sqlite3_release_memory(allocSize); - } + /* + ** State information local to the memory allocation subsystem. + */ + //static SQLITE_WSD struct Mem0Global { + public class Mem0Global + {/* Number of free pages for scratch and page-cache memory */ + public int nScratchFree; + public int nPageFree; + + public sqlite3_mutex mutex; /* Mutex to serialize access */ + + /* + ** The alarm callback and its arguments. The mem0.mutex lock will + ** be held while the callback is running. Recursive calls into + ** the memory subsystem are allowed, but no new callbacks will be + ** issued. + */ + public sqlite3_int64 alarmThreshold; + public dxalarmCallback alarmCallback; // (*alarmCallback)(void*, sqlite3_int64,int); + public object alarmArg; + + /* + ** Pointers to the end of sqlite3GlobalConfig.pScratch and + ** sqlite3GlobalConfig.pPage to a block of memory that records + ** which pages are available. + */ + //u32 *aScratchFree; + /* + ** True if heap is nearly "full" where "full" is defined by the + ** sqlite3_soft_heap_limit() setting. + */ + public bool nearlyFull; + + public byte[][][] aByte; + public int[] aByteSize; + public int[] aByte_used; + public int[][] aInt; + public Mem[] aMem; + public BtCursor[] aBtCursor; + + public struct memstat + { + public int alloc; // # of allocation requests + public int dealloc; // # of deallocations + public int cached; // # of cache hits + public int next; // # Next slot to use + public int max; // # Max slot used + } + + public memstat msByte; + public memstat msInt; + public memstat msMem; + public memstat msBtCursor; + + public Mem0Global() + { + } + + public Mem0Global( int nScratchFree, int nPageFree, sqlite3_mutex mutex, sqlite3_int64 alarmThreshold, dxalarmCallback alarmCallback, object alarmArg, int Byte_Allocation, int Int_Allocation, int Mem_Allocation, int BtCursor_Allocation ) + { + this.nScratchFree = nScratchFree; + this.nPageFree = nPageFree; + this.mutex = mutex; + this.alarmThreshold = alarmThreshold; + this.alarmCallback = alarmCallback; + this.alarmArg = alarmArg; + this.msByte.next = -1; + this.msInt.next = -1; + this.msMem.next = -1; + this.aByteSize = new int[] { 32, 256, 1024, 8192, 0 }; + this.aByte_used = new int[] { -1, -1, -1, -1, -1 }; + this.aByte = new byte[this.aByteSize.Length][][]; + for ( int i = 0; i < this.aByteSize.Length; i++ ) + this.aByte[i] = new byte[Byte_Allocation][]; + this.aInt = new int[Int_Allocation][]; + this.aMem = new Mem[Mem_Allocation <= 4 ? 4 : Mem_Allocation]; + this.aBtCursor = new BtCursor[BtCursor_Allocation <= 4 ? 4 : BtCursor_Allocation]; + this.nearlyFull = false; + } + } + //mem0 = { 0, 0, 0, 0, 0, 0, 0, 0 }; + + //#define mem0 GLOBAL(struct Mem0Global, mem0) + static Mem0Global mem0 = new Mem0Global(); + + /* + ** This routine runs when the memory allocator sees that the + ** total memory allocation is about to exceed the soft heap + ** limit. + */ + static void softHeapLimitEnforcer( + object NotUsed, + sqlite3_int64 NotUsed2, + int allocSize + ) + { + UNUSED_PARAMETER2( NotUsed, NotUsed2 ); + sqlite3_release_memory( allocSize ); + } #if !SQLITE_OMIT_DEPRECATED /* @@ -156,531 +166,614 @@ sqlite3_int64 iThreshold } #endif - /* - ** Set the soft heap-size limit for the library. Passing a zero or - ** negative value indicates no limit. - */ - static sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n) { - sqlite3_int64 priorLimit; - sqlite3_int64 excess; + /* +** Set the soft heap-size limit for the library. Passing a zero or +** negative value indicates no limit. +*/ + static sqlite3_int64 sqlite3_soft_heap_limit64( sqlite3_int64 n ) + { + sqlite3_int64 priorLimit; + sqlite3_int64 excess; #if !SQLITE_OMIT_AUTOINIT - sqlite3_initialize(); + sqlite3_initialize(); #endif - sqlite3_mutex_enter(mem0.mutex); - priorLimit = mem0.alarmThreshold; - sqlite3_mutex_leave(mem0.mutex); - if (n < 0) - return priorLimit; - if (n > 0) { - sqlite3MemoryAlarm(softHeapLimitEnforcer, 0, n); - } else { - sqlite3MemoryAlarm(null, 0, 0); - } - excess = sqlite3_memory_used() - n; - if (excess > 0) - sqlite3_release_memory((int)(excess & 0x7fffffff)); - return priorLimit; - } - void sqlite3_soft_heap_limit(int n) { - if (n < 0) - n = 0; - sqlite3_soft_heap_limit64(n); - } + sqlite3_mutex_enter( mem0.mutex ); + priorLimit = mem0.alarmThreshold; + sqlite3_mutex_leave( mem0.mutex ); + if ( n < 0 ) + return priorLimit; + if ( n > 0 ) + { + sqlite3MemoryAlarm( softHeapLimitEnforcer, 0, n ); + } + else + { + sqlite3MemoryAlarm( null, 0, 0 ); + } + excess = sqlite3_memory_used() - n; + if ( excess > 0 ) + sqlite3_release_memory( (int)( excess & 0x7fffffff ) ); + return priorLimit; + } + void sqlite3_soft_heap_limit( int n ) + { + if ( n < 0 ) + n = 0; + sqlite3_soft_heap_limit64( n ); + } - /* - ** Initialize the memory allocation subsystem. - */ - static int sqlite3MallocInit() { - if (sqlite3GlobalConfig.m.xMalloc == null) { - sqlite3MemSetDefault(); - } - mem0 = new Mem0Global(0, 0, null, 0, null, null, 1, 1, 8, 8); //memset(&mem0, 0, sizeof(mem0)); - if (sqlite3GlobalConfig.bCoreMutex) { - mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); - } - if (sqlite3GlobalConfig.pScratch != null && sqlite3GlobalConfig.szScratch >= 100 - && sqlite3GlobalConfig.nScratch >= 0) { - int i; - sqlite3GlobalConfig.szScratch = ROUNDDOWN8(sqlite3GlobalConfig.szScratch - 4); - //mem0.aScratchFree = (u32)&((char)sqlite3GlobalConfig.pScratch) - // [sqlite3GlobalConfig.szScratch*sqlite3GlobalConfig.nScratch]; - //for(i=0; i= 100 + && sqlite3GlobalConfig.nScratch >= 0 ) + { + int i; + sqlite3GlobalConfig.szScratch = ROUNDDOWN8( sqlite3GlobalConfig.szScratch - 4 ); + //mem0.aScratchFree = (u32)&((char)sqlite3GlobalConfig.pScratch) + // [sqlite3GlobalConfig.szScratch*sqlite3GlobalConfig.nScratch]; + //for(i=0; i 0 && iThreshold <= nUsed); - sqlite3_mutex_leave(mem0.mutex); - return SQLITE_OK; - } + /* + ** Change the alarm callback + */ + static int sqlite3MemoryAlarm( + dxalarmCallback xCallback, //void(*xCallback)(object pArg, sqlite3_int64 used,int N), + object pArg, + sqlite3_int64 iThreshold + ) + { + int nUsed; + sqlite3_mutex_enter( mem0.mutex ); + mem0.alarmCallback = xCallback; + mem0.alarmArg = pArg; + mem0.alarmThreshold = iThreshold; + nUsed = sqlite3StatusValue( SQLITE_STATUS_MEMORY_USED ); + mem0.nearlyFull = ( iThreshold > 0 && iThreshold <= nUsed ); + sqlite3_mutex_leave( mem0.mutex ); + return SQLITE_OK; + } - /* - ** Trigger the alarm - */ - static void sqlite3MallocAlarm(int nByte) { - dxalarmCallback xCallback;//void (*xCallback)(void*,sqlite3_int64,int); - sqlite3_int64 nowUsed; - object pArg;// void* pArg; - if (mem0.alarmCallback == null) - return; - xCallback = mem0.alarmCallback; - nowUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); - pArg = mem0.alarmArg; - mem0.alarmCallback = null; - sqlite3_mutex_leave(mem0.mutex); - xCallback(pArg, nowUsed, nByte); - sqlite3_mutex_enter(mem0.mutex); - mem0.alarmCallback = xCallback; - mem0.alarmArg = pArg; - } + /* + ** Trigger the alarm + */ + static void sqlite3MallocAlarm( int nByte ) + { + dxalarmCallback xCallback;//void (*xCallback)(void*,sqlite3_int64,int); + sqlite3_int64 nowUsed; + object pArg;// void* pArg; + if ( mem0.alarmCallback == null ) + return; + xCallback = mem0.alarmCallback; + nowUsed = sqlite3StatusValue( SQLITE_STATUS_MEMORY_USED ); + pArg = mem0.alarmArg; + mem0.alarmCallback = null; + sqlite3_mutex_leave( mem0.mutex ); + xCallback( pArg, nowUsed, nByte ); + sqlite3_mutex_enter( mem0.mutex ); + mem0.alarmCallback = xCallback; + mem0.alarmArg = pArg; + } - /* - ** Do a memory allocation with statistics and alarms. Assume the - ** lock is already held. - */ - static int mallocWithAlarm(int n, ref int[] pp) { - int nFull; - int[] p; - Debug.Assert(sqlite3_mutex_held(mem0.mutex)); - nFull = sqlite3GlobalConfig.m.xRoundup(n); - sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, n); - if (mem0.alarmCallback != null) { - int nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); - if (nUsed >= mem0.alarmThreshold - nFull) { - mem0.nearlyFull = true; - sqlite3MallocAlarm(nFull); - } else { - mem0.nearlyFull = false; - } - } - p = sqlite3GlobalConfig.m.xMallocInt(nFull); + /* + ** Do a memory allocation with statistics and alarms. Assume the + ** lock is already held. + */ + static int mallocWithAlarm( int n, ref int[] pp ) + { + int nFull; + int[] p; + Debug.Assert( sqlite3_mutex_held( mem0.mutex ) ); + nFull = sqlite3GlobalConfig.m.xRoundup( n ); + sqlite3StatusSet( SQLITE_STATUS_MALLOC_SIZE, n ); + if ( mem0.alarmCallback != null ) + { + int nUsed = sqlite3StatusValue( SQLITE_STATUS_MEMORY_USED ); + if ( nUsed >= mem0.alarmThreshold - nFull ) + { + mem0.nearlyFull = true; + sqlite3MallocAlarm( nFull ); + } + else + { + mem0.nearlyFull = false; + } + } + p = sqlite3GlobalConfig.m.xMallocInt( nFull ); #if SQLITE_ENABLE_MEMORY_MANAGEMENT if( p==null && mem0.alarmCallback!=null ){ sqlite3MallocAlarm(nFull); p = sqlite3GlobalConfig.m.xMalloc(nFull); } #endif - if (p != null) { - nFull = sqlite3MallocSize(p); - sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nFull); - } - pp = p; - return nFull; - } - static int mallocWithAlarm(int n, ref byte[] pp) { - int nFull; - byte[] p; - Debug.Assert(sqlite3_mutex_held(mem0.mutex)); - nFull = sqlite3GlobalConfig.m.xRoundup(n); - sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, n); - if (mem0.alarmCallback != null) { - int nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); - if (nUsed + nFull >= mem0.alarmThreshold) { - sqlite3MallocAlarm(nFull); - } - } - p = sqlite3GlobalConfig.m.xMalloc(nFull); - if (p == null && mem0.alarmCallback != null) { - sqlite3MallocAlarm(nFull); - p = sqlite3GlobalConfig.m.xMalloc(nFull); - } - if (p != null) { - nFull = sqlite3MallocSize(p); - sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nFull); - sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, 1); - } - pp = p; - return nFull; + if ( p != null ) + { + nFull = sqlite3MallocSize( p ); + sqlite3StatusAdd( SQLITE_STATUS_MEMORY_USED, nFull ); + } + pp = p; + return nFull; + } + static int mallocWithAlarm( int n, ref byte[] pp ) + { + int nFull; + byte[] p; + Debug.Assert( sqlite3_mutex_held( mem0.mutex ) ); + nFull = sqlite3GlobalConfig.m.xRoundup( n ); + sqlite3StatusSet( SQLITE_STATUS_MALLOC_SIZE, n ); + if ( mem0.alarmCallback != null ) + { + int nUsed = sqlite3StatusValue( SQLITE_STATUS_MEMORY_USED ); + if ( nUsed + nFull >= mem0.alarmThreshold ) + { + sqlite3MallocAlarm( nFull ); } + } + p = sqlite3GlobalConfig.m.xMalloc( nFull ); + if ( p == null && mem0.alarmCallback != null ) + { + sqlite3MallocAlarm( nFull ); + p = sqlite3GlobalConfig.m.xMalloc( nFull ); + } + if ( p != null ) + { + nFull = sqlite3MallocSize( p ); + sqlite3StatusAdd( SQLITE_STATUS_MEMORY_USED, nFull ); + sqlite3StatusAdd( SQLITE_STATUS_MALLOC_COUNT, 1 ); + } + pp = p; + return nFull; + } - /* - ** Allocate memory. This routine is like sqlite3_malloc() except that it - ** assumes the memory subsystem has already been initialized. - */ - static Mem sqlite3Malloc(Mem pMem) { - return sqlite3GlobalConfig.m.xMallocMem(pMem); - } - static int[] sqlite3Malloc(int[] pInt, u32 n) { - return sqlite3Malloc(pInt, (int)n); - } + /* + ** Allocate memory. This routine is like sqlite3_malloc() except that it + ** assumes the memory subsystem has already been initialized. + */ + static Mem sqlite3Malloc( Mem pMem ) + { + return sqlite3GlobalConfig.m.xMallocMem( pMem ); + } + static int[] sqlite3Malloc( int[] pInt, u32 n ) + { + return sqlite3Malloc( pInt, (int)n ); + } - static int[] sqlite3Malloc(int[] pInt, int n) { - int[] p = null; - if (n < 0 || n >= 0x7fffff00) { - /* A memory allocation of a number of bytes which is near the maximum - ** signed integer value might cause an integer overflow inside of the - ** xMalloc(). Hence we limit the maximum size to 0x7fffff00, giving - ** 255 bytes of overhead. SQLite itself will never use anything near - ** this amount. The only way to reach the limit is with sqlite3_malloc() */ - p = null; - } else if (sqlite3GlobalConfig.bMemstat) { - sqlite3_mutex_enter(mem0.mutex); - mallocWithAlarm(n, ref p); - sqlite3_mutex_leave(mem0.mutex); - } else { - p = sqlite3GlobalConfig.m.xMallocInt(n); - } - return p; - } + static int[] sqlite3Malloc( int[] pInt, int n ) + { + int[] p = null; + if ( n < 0 || n >= 0x7fffff00 ) + { + /* A memory allocation of a number of bytes which is near the maximum + ** signed integer value might cause an integer overflow inside of the + ** xMalloc(). Hence we limit the maximum size to 0x7fffff00, giving + ** 255 bytes of overhead. SQLite itself will never use anything near + ** this amount. The only way to reach the limit is with sqlite3_malloc() */ + p = null; + } + else if ( sqlite3GlobalConfig.bMemstat ) + { + sqlite3_mutex_enter( mem0.mutex ); + mallocWithAlarm( n, ref p ); + sqlite3_mutex_leave( mem0.mutex ); + } + else + { + p = sqlite3GlobalConfig.m.xMallocInt( n ); + } + return p; + } - static byte[] sqlite3Malloc(u32 n) { - return sqlite3Malloc((int)n); - } - static byte[] sqlite3Malloc(int n) { - byte[] p = null; - if (n < 0 || n >= 0x7fffff00) { - /* A memory allocation of a number of bytes which is near the maximum - ** signed integer value might cause an integer overflow inside of the - ** xMalloc(). Hence we limit the maximum size to 0x7fffff00, giving - ** 255 bytes of overhead. SQLite itself will never use anything near - ** this amount. The only way to reach the limit is with sqlite3_malloc() */ - p = null; - } else if (sqlite3GlobalConfig.bMemstat) { - sqlite3_mutex_enter(mem0.mutex); - mallocWithAlarm(n, ref p); - sqlite3_mutex_leave(mem0.mutex); - } else { - p = sqlite3GlobalConfig.m.xMalloc(n); - } - return p; - } + static byte[] sqlite3Malloc( u32 n ) + { + return sqlite3Malloc( (int)n ); + } + static byte[] sqlite3Malloc( int n ) + { + byte[] p = null; + if ( n < 0 || n >= 0x7fffff00 ) + { + /* A memory allocation of a number of bytes which is near the maximum + ** signed integer value might cause an integer overflow inside of the + ** xMalloc(). Hence we limit the maximum size to 0x7fffff00, giving + ** 255 bytes of overhead. SQLite itself will never use anything near + ** this amount. The only way to reach the limit is with sqlite3_malloc() */ + p = null; + } + else if ( sqlite3GlobalConfig.bMemstat ) + { + sqlite3_mutex_enter( mem0.mutex ); + mallocWithAlarm( n, ref p ); + sqlite3_mutex_leave( mem0.mutex ); + } + else + { + p = sqlite3GlobalConfig.m.xMalloc( n ); + } + return p; + } - /* - ** This version of the memory allocation is for use by the application. - ** First make sure the memory subsystem is initialized, then do the - ** allocation. - */ - static public byte[] sqlite3_malloc(int n) { + /* + ** This version of the memory allocation is for use by the application. + ** First make sure the memory subsystem is initialized, then do the + ** allocation. + */ + static public byte[] sqlite3_malloc( int n ) + { #if !SQLITE_OMIT_AUTOINIT - if (sqlite3_initialize() != 0) - return null; + if ( sqlite3_initialize() != 0 ) + return null; #endif - return sqlite3Malloc(n); - } + return sqlite3Malloc( n ); + } - /* - ** Each thread may only have a single outstanding allocation from - ** xScratchMalloc(). We verify this constraint in the single-threaded - ** case by setting scratchAllocOut to 1 when an allocation - ** is outstanding clearing it when the allocation is freed. - */ + /* + ** Each thread may only have a single outstanding allocation from + ** xScratchMalloc(). We verify this constraint in the single-threaded + ** case by setting scratchAllocOut to 1 when an allocation + ** is outstanding clearing it when the allocation is freed. + */ #if SQLITE_THREADSAFE && !(NDEBUG) - static int scratchAllocOut = 0; + static int scratchAllocOut = 0; #endif - /* - ** Allocate memory that is to be used and released right away. - ** This routine is similar to alloca() in that it is not intended - ** for situations where the memory might be held long-term. This - ** routine is intended to get memory to old large transient data - ** structures that would not normally fit on the stack of an - ** embedded processor. - */ - static byte[][] sqlite3ScratchMalloc(byte[][] apCell, int n) { - apCell = sqlite3GlobalConfig.pScratch2; - if (apCell == null) - apCell = new byte[n < 200 ? 200 : n][]; - else if (apCell.Length < n) - Array.Resize(ref apCell, n); - sqlite3GlobalConfig.pScratch2 = null; - return apCell; - } + /* +** Allocate memory that is to be used and released right away. +** This routine is similar to alloca() in that it is not intended +** for situations where the memory might be held long-term. This +** routine is intended to get memory to old large transient data +** structures that would not normally fit on the stack of an +** embedded processor. +*/ + static byte[][] sqlite3ScratchMalloc( byte[][] apCell, int n ) + { + apCell = sqlite3GlobalConfig.pScratch2; + if ( apCell == null ) + apCell = new byte[n < 200 ? 200 : n][]; + else if ( apCell.Length < n ) + Array.Resize( ref apCell, n ); + sqlite3GlobalConfig.pScratch2 = null; + return apCell; + } - static byte[] sqlite3ScratchMalloc(int n) { - byte[] p = null; - Debug.Assert(n > 0); + static byte[] sqlite3ScratchMalloc( int n ) + { + byte[] p = null; + Debug.Assert( n > 0 ); #if SQLITE_THREADSAFE && !(NDEBUG) - /* Verify that no more than two scratch allocation per thread - ** is outstanding at one time. (This is only checked in the - ** single-threaded case since checking in the multi-threaded case - ** would be much more complicated.) */ - Debug.Assert(scratchAllocOut <= 1); + /* Verify that no more than two scratch allocation per thread +** is outstanding at one time. (This is only checked in the +** single-threaded case since checking in the multi-threaded case +** would be much more complicated.) */ + Debug.Assert( scratchAllocOut <= 1 ); #endif - if (sqlite3GlobalConfig.szScratch < n) { - goto scratch_overflow; - } else { - sqlite3_mutex_enter(mem0.mutex); - if (mem0.nScratchFree == 0) { - sqlite3_mutex_leave(mem0.mutex); - goto scratch_overflow; - } else { - int i; - //i = mem0.aScratchFree[--mem0.nScratchFree]; - //i *= sqlite3GlobalConfig.szScratch; - for (i = 0; i < sqlite3GlobalConfig.pScratch.Length; i++) { - if (sqlite3GlobalConfig.pScratch[i] == null || sqlite3GlobalConfig.pScratch[i].Length < n) - continue; - p = sqlite3GlobalConfig.pScratch[i];// (void)&((char)sqlite3GlobalConfig.pScratch)[i]; - sqlite3GlobalConfig.pScratch[i] = null; - break; - } - sqlite3_mutex_leave(mem0.mutex); - if (p == null) - goto scratch_overflow; - sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, 1); - sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n); - //Debug.Assert( (((u8)p - (u8)0) & 7)==0 ); - } - } + if ( sqlite3GlobalConfig.szScratch < n ) + { + goto scratch_overflow; + } + else + { + sqlite3_mutex_enter( mem0.mutex ); + if ( mem0.nScratchFree == 0 ) + { + sqlite3_mutex_leave( mem0.mutex ); + goto scratch_overflow; + } + else + { + int i; + //i = mem0.aScratchFree[--mem0.nScratchFree]; + //i *= sqlite3GlobalConfig.szScratch; + for ( i = 0; i < sqlite3GlobalConfig.pScratch.Length; i++ ) + { + if ( sqlite3GlobalConfig.pScratch[i] == null || sqlite3GlobalConfig.pScratch[i].Length < n ) + continue; + p = sqlite3GlobalConfig.pScratch[i];// (void)&((char)sqlite3GlobalConfig.pScratch)[i]; + sqlite3GlobalConfig.pScratch[i] = null; + break; + } + sqlite3_mutex_leave( mem0.mutex ); + if ( p == null ) + goto scratch_overflow; + sqlite3StatusAdd( SQLITE_STATUS_SCRATCH_USED, 1 ); + sqlite3StatusSet( SQLITE_STATUS_SCRATCH_SIZE, n ); + //Debug.Assert( (((u8)p - (u8)0) & 7)==0 ); + } + } #if SQLITE_THREADSAFE && !(NDEBUG) - scratchAllocOut = (p != null ? 1 : 0); + scratchAllocOut = ( p != null ? 1 : 0 ); #endif - return p; - - scratch_overflow: - if (sqlite3GlobalConfig.bMemstat) { - sqlite3_mutex_enter(mem0.mutex); - sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n); - n = mallocWithAlarm(n, ref p); - if (p != null) - sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, n); - sqlite3_mutex_leave(mem0.mutex); - } else { - p = sqlite3GlobalConfig.m.xMalloc(n); - } - sqlite3MemdebugSetType(p, MEMTYPE_SCRATCH); + return p; + +scratch_overflow: + if ( sqlite3GlobalConfig.bMemstat ) + { + sqlite3_mutex_enter( mem0.mutex ); + sqlite3StatusSet( SQLITE_STATUS_SCRATCH_SIZE, n ); + n = mallocWithAlarm( n, ref p ); + if ( p != null ) + sqlite3StatusAdd( SQLITE_STATUS_SCRATCH_OVERFLOW, n ); + sqlite3_mutex_leave( mem0.mutex ); + } + else + { + p = sqlite3GlobalConfig.m.xMalloc( n ); + } + sqlite3MemdebugSetType( p, MEMTYPE_SCRATCH ); #if SQLITE_THREADSAFE && !(NDEBUG) - scratchAllocOut = (p != null) ? 1 : 0; + scratchAllocOut = ( p != null ) ? 1 : 0; #endif - return p; + return p; + } + static void sqlite3ScratchFree( byte[][] p ) + { + if ( p != null ) + { + + if ( sqlite3GlobalConfig.pScratch2 == null || sqlite3GlobalConfig.pScratch2.Length < p.Length ) + { + Debug.Assert( sqlite3MemdebugHasType( p, MEMTYPE_SCRATCH ) ); + Debug.Assert( sqlite3MemdebugNoType( p, ~MEMTYPE_SCRATCH ) ); + sqlite3MemdebugSetType( p, MEMTYPE_HEAP ); + if ( sqlite3GlobalConfig.bMemstat ) + { + int iSize = sqlite3MallocSize( p ); + sqlite3_mutex_enter( mem0.mutex ); + sqlite3StatusAdd( SQLITE_STATUS_SCRATCH_OVERFLOW, -iSize ); + sqlite3StatusAdd( SQLITE_STATUS_MEMORY_USED, -iSize ); + sqlite3StatusAdd( SQLITE_STATUS_MALLOC_COUNT, -1 ); + sqlite3GlobalConfig.pScratch2 = p;// sqlite3GlobalConfig.m.xFree(ref p); + sqlite3_mutex_leave( mem0.mutex ); + } + else + { + sqlite3GlobalConfig.pScratch2 = p;//sqlite3GlobalConfig.m.xFree(ref p); + } } - static void sqlite3ScratchFree(byte[][] p) { - if (p != null) { - - if (sqlite3GlobalConfig.pScratch2 == null || sqlite3GlobalConfig.pScratch2.Length < p.Length) { - Debug.Assert(sqlite3MemdebugHasType(p, MEMTYPE_SCRATCH)); - Debug.Assert(sqlite3MemdebugNoType(p, ~MEMTYPE_SCRATCH)); - sqlite3MemdebugSetType(p, MEMTYPE_HEAP); - if (sqlite3GlobalConfig.bMemstat) { - int iSize = sqlite3MallocSize(p); - sqlite3_mutex_enter(mem0.mutex); - sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, -iSize); - sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -iSize); - sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, -1); - sqlite3GlobalConfig.pScratch2 = p;// sqlite3GlobalConfig.m.xFree(ref p); - sqlite3_mutex_leave(mem0.mutex); - } else { - sqlite3GlobalConfig.pScratch2 = p;//sqlite3GlobalConfig.m.xFree(ref p); - } - } else // larger Scratch 2 already in use, let the C# GC handle - { - //int i; - //i = (int)((u8)p - (u8)sqlite3GlobalConfig.pScratch); - //i /= sqlite3GlobalConfig.szScratch; - //Debug.Assert(i >= 0 && i < sqlite3GlobalConfig.nScratch); - //sqlite3_mutex_enter(mem0.mutex); - //Debug.Assert(mem0.nScratchFree < (u32)sqlite3GlobalConfig.nScratch); - //mem0.aScratchFree[mem0.nScratchFree++] = i; - //sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, -1); - //sqlite3_mutex_leave(mem0.mutex); + else // larger Scratch 2 already in use, let the C# GC handle + { + //int i; + //i = (int)((u8)p - (u8)sqlite3GlobalConfig.pScratch); + //i /= sqlite3GlobalConfig.szScratch; + //Debug.Assert(i >= 0 && i < sqlite3GlobalConfig.nScratch); + //sqlite3_mutex_enter(mem0.mutex); + //Debug.Assert(mem0.nScratchFree < (u32)sqlite3GlobalConfig.nScratch); + //mem0.aScratchFree[mem0.nScratchFree++] = i; + //sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, -1); + //sqlite3_mutex_leave(mem0.mutex); #if SQLITE_THREADSAFE && !(NDEBUG) - /* Verify that no more than two scratch allocation per thread - ** is outstanding at one time. (This is only checked in the - ** single-threaded case since checking in the multi-threaded case - ** would be much more complicated.) */ - Debug.Assert(scratchAllocOut >= 1 && scratchAllocOut <= 2); - scratchAllocOut = 0; + /* Verify that no more than two scratch allocation per thread +** is outstanding at one time. (This is only checked in the +** single-threaded case since checking in the multi-threaded case +** would be much more complicated.) */ + Debug.Assert( scratchAllocOut >= 1 && scratchAllocOut <= 2 ); + scratchAllocOut = 0; #endif - } - //if( p>=sqlite3GlobalConfig.pScratch && ppNext = mem0.pScratchFree; - // mem0.pScratchFree = pSlot; - // mem0.nScratchFree++; - // Debug.Assert( mem0.nScratchFree <= (u32)sqlite3GlobalConfig.nScratch ); - // sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, -1); - // sqlite3_mutex_leave(mem0.mutex); - //}else{ - // /* Release memory back to the heap */ - // Debug.Assert( sqlite3MemdebugHasType(p, MEMTYPE_SCRATCH) ); - // Debug.Assert( sqlite3MemdebugNoType(p, ~MEMTYPE_SCRATCH) ); - // sqlite3MemdebugSetType(p, MEMTYPE_HEAP); - // if( sqlite3GlobalConfig.bMemstat ){ - // int iSize = sqlite3MallocSize(p); - // sqlite3_mutex_enter(mem0.mutex); - // sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, -iSize); - // sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -iSize); - // sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, -1); - // sqlite3GlobalConfig.m.xFree(p); - // sqlite3_mutex_leave(mem0.mutex); - // }else{ - // sqlite3GlobalConfig.m.xFree(p); - // } - p = null; - } } + //if( p>=sqlite3GlobalConfig.pScratch && ppNext = mem0.pScratchFree; + // mem0.pScratchFree = pSlot; + // mem0.nScratchFree++; + // Debug.Assert( mem0.nScratchFree <= (u32)sqlite3GlobalConfig.nScratch ); + // sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, -1); + // sqlite3_mutex_leave(mem0.mutex); + //}else{ + // /* Release memory back to the heap */ + // Debug.Assert( sqlite3MemdebugHasType(p, MEMTYPE_SCRATCH) ); + // Debug.Assert( sqlite3MemdebugNoType(p, ~MEMTYPE_SCRATCH) ); + // sqlite3MemdebugSetType(p, MEMTYPE_HEAP); + // if( sqlite3GlobalConfig.bMemstat ){ + // int iSize = sqlite3MallocSize(p); + // sqlite3_mutex_enter(mem0.mutex); + // sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, -iSize); + // sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -iSize); + // sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, -1); + // sqlite3GlobalConfig.m.xFree(p); + // sqlite3_mutex_leave(mem0.mutex); + // }else{ + // sqlite3GlobalConfig.m.xFree(p); + // } + p = null; + } + } - /* - ** TRUE if p is a lookaside memory allocation from db - */ + /* + ** TRUE if p is a lookaside memory allocation from db + */ #if !SQLITE_OMIT_LOOKASIDE static int isLookaside(sqlite3 db, object *p){ return p && p>=db.lookaside.pStart && p= 0x7fffff00) { - /* The 0x7ffff00 limit term is explained in comments on sqlite3Malloc() */ - return null; - } - nOld = sqlite3MallocSize(pOld); - nNew = sqlite3GlobalConfig.m.xRoundup(nBytes); - if (nOld == nNew) { - pNew = pOld; - } else if (sqlite3GlobalConfig.bMemstat) { - sqlite3_mutex_enter(mem0.mutex); - sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, nBytes); - nDiff = nNew - nOld; - if (sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED) >= - mem0.alarmThreshold - nDiff) { - sqlite3MallocAlarm(nDiff); - } - Debug.Assert(sqlite3MemdebugHasType(pOld, MEMTYPE_HEAP)); - Debug.Assert(sqlite3MemdebugNoType(pOld, ~MEMTYPE_HEAP)); - pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew); - if (pNew == null && mem0.alarmCallback != null) { - sqlite3MallocAlarm(nBytes); - pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew); - } - if (pNew != null) { - nNew = sqlite3MallocSize(pNew); - sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nNew - nOld); - } - sqlite3_mutex_leave(mem0.mutex); - } else { - pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew); - } - return pNew; + /* + ** Change the size of an existing memory allocation + */ + static byte[] sqlite3Realloc( byte[] pOld, int nBytes ) + { + int nOld, nNew, nDiff; + byte[] pNew; + if ( pOld == null ) + { + pOld = sqlite3Malloc( nBytes ); + return pOld; + } + if ( nBytes < 0 ) + { + sqlite3_free( ref pOld ); + return null; + } + if ( nBytes >= 0x7fffff00 ) + { + /* The 0x7ffff00 limit term is explained in comments on sqlite3Malloc() */ + return null; + } + nOld = sqlite3MallocSize( pOld ); + nNew = sqlite3GlobalConfig.m.xRoundup( nBytes ); + if ( nOld == nNew ) + { + pNew = pOld; + } + else if ( sqlite3GlobalConfig.bMemstat ) + { + sqlite3_mutex_enter( mem0.mutex ); + sqlite3StatusSet( SQLITE_STATUS_MALLOC_SIZE, nBytes ); + nDiff = nNew - nOld; + if ( sqlite3StatusValue( SQLITE_STATUS_MEMORY_USED ) >= + mem0.alarmThreshold - nDiff ) + { + sqlite3MallocAlarm( nDiff ); + } + Debug.Assert( sqlite3MemdebugHasType( pOld, MEMTYPE_HEAP ) ); + Debug.Assert( sqlite3MemdebugNoType( pOld, ~MEMTYPE_HEAP ) ); + pNew = sqlite3GlobalConfig.m.xRealloc( pOld, nNew ); + if ( pNew == null && mem0.alarmCallback != null ) + { + sqlite3MallocAlarm( nBytes ); + pNew = sqlite3GlobalConfig.m.xRealloc( pOld, nNew ); + } + if ( pNew != null ) + { + nNew = sqlite3MallocSize( pNew ); + sqlite3StatusAdd( SQLITE_STATUS_MEMORY_USED, nNew - nOld ); } + sqlite3_mutex_leave( mem0.mutex ); + } + else + { + pNew = sqlite3GlobalConfig.m.xRealloc( pOld, nNew ); + } + return pNew; + } - /* - ** The public interface to sqlite3Realloc. Make sure that the memory - ** subsystem is initialized prior to invoking sqliteRealloc. - */ - static byte[] sqlite3_realloc(byte[] pOld, int n) { + /* + ** The public interface to sqlite3Realloc. Make sure that the memory + ** subsystem is initialized prior to invoking sqliteRealloc. + */ + static byte[] sqlite3_realloc( byte[] pOld, int n ) + { #if !SQLITE_OMIT_AUTOINIT - if (sqlite3_initialize() != 0) - return null; + if ( sqlite3_initialize() != 0 ) + return null; #endif - return sqlite3Realloc(pOld, n); - } + return sqlite3Realloc( pOld, n ); + } - /* - ** Allocate and zero memory. - */ - static byte[] sqlite3MallocZero(int n) { - byte[] p = sqlite3Malloc(n); - if (p != null) { - Array.Clear(p, 0, n);// memset(p, 0, n); - } - return p; - } + /* + ** Allocate and zero memory. + */ + static byte[] sqlite3MallocZero( int n ) + { + byte[] p = sqlite3Malloc( n ); + if ( p != null ) + { + Array.Clear( p, 0, n );// memset(p, 0, n); + } + return p; + } - /* - ** Allocate and zero memory. If the allocation fails, make - ** the mallocFailed flag in the connection pointer. - */ - static Mem sqlite3DbMallocZero(sqlite3 db, Mem m) { - return new Mem(); - } + /* + ** Allocate and zero memory. If the allocation fails, make + ** the mallocFailed flag in the connection pointer. + */ + static Mem sqlite3DbMallocZero( sqlite3 db, Mem m ) + { + return new Mem(); + } - static byte[] sqlite3DbMallocZero(sqlite3 db, int n) { - byte[] p = sqlite3DbMallocRaw(db, n); - if (p != null) { - Array.Clear(p, 0, n);// memset(p, 0, n); - } - return p; - } + static byte[] sqlite3DbMallocZero( sqlite3 db, int n ) + { + byte[] p = sqlite3DbMallocRaw( db, n ); + if ( p != null ) + { + Array.Clear( p, 0, n );// memset(p, 0, n); + } + return p; + } - /* - ** Allocate and zero memory. If the allocation fails, make - ** the mallocFailed flag in the connection pointer. - ** - ** If db!=0 and db->mallocFailed is true (indicating a prior malloc - ** failure on the same database connection) then always return 0. - ** Hence for a particular database connection, once malloc starts - ** failing, it fails consistently until mallocFailed is reset. - ** This is an important assumption. There are many places in the - ** code that do things like this: - ** - ** int *a = (int)sqlite3DbMallocRaw(db, 100); - ** int *b = (int)sqlite3DbMallocRaw(db, 200); - ** if( b ) a[10] = 9; - ** - ** In other words, if a subsequent malloc (ex: "b") worked, it is assumed - ** that all prior mallocs (ex: "a") worked too. - */ - static byte[] sqlite3DbMallocRaw(sqlite3 db, int n) { - byte[] p; - Debug.Assert(db == null || sqlite3_mutex_held(db.mutex)); - Debug.Assert(db == null || db.pnBytesFreed == 0); + /* + ** Allocate and zero memory. If the allocation fails, make + ** the mallocFailed flag in the connection pointer. + ** + ** If db!=0 and db->mallocFailed is true (indicating a prior malloc + ** failure on the same database connection) then always return 0. + ** Hence for a particular database connection, once malloc starts + ** failing, it fails consistently until mallocFailed is reset. + ** This is an important assumption. There are many places in the + ** code that do things like this: + ** + ** int *a = (int)sqlite3DbMallocRaw(db, 100); + ** int *b = (int)sqlite3DbMallocRaw(db, 200); + ** if( b ) a[10] = 9; + ** + ** In other words, if a subsequent malloc (ex: "b") worked, it is assumed + ** that all prior mallocs (ex: "a") worked too. + */ + static byte[] sqlite3DbMallocRaw( sqlite3 db, int n ) + { + byte[] p; + Debug.Assert( db == null || sqlite3_mutex_held( db.mutex ) ); + Debug.Assert( db == null || db.pnBytesFreed == 0 ); #if !SQLITE_OMIT_LOOKASIDE if( db ){ LookasideSlot *pBuf; @@ -832,33 +944,35 @@ static byte[] sqlite3DbMallocRaw(sqlite3 db, int n) { } } #else - //if( db && db->mallocFailed ){ - // return 0; - //} + //if( db && db->mallocFailed ){ + // return 0; + //} #endif - p = sqlite3Malloc(n); - //if( null==p && db ){ - // db->mallocFailed = 1; - //} + p = sqlite3Malloc( n ); + //if( null==p && db ){ + // db->mallocFailed = 1; + //} #if !SQLITE_OMIT_LOOKASIDE sqlite3MemdebugSetType(p, MEMTYPE_DB | ((db !=null && db.lookaside.bEnabled) ? MEMTYPE_LOOKASIDE : MEMTYPE_HEAP)); #endif - return p; - } + return p; + } - /* - ** Resize the block of memory pointed to by p to n bytes. If the - ** resize fails, set the mallocFailed flag in the connection object. - */ - static byte[] sqlite3DbRealloc(sqlite3 db, byte[] p, int n) { - byte[] pNew = null; - Debug.Assert(db != null); - Debug.Assert(sqlite3_mutex_held(db.mutex)); - //if( db->mallocFailed==0 ){ - if (p == null) { - return sqlite3DbMallocRaw(db, n); - } + /* + ** Resize the block of memory pointed to by p to n bytes. If the + ** resize fails, set the mallocFailed flag in the connection object. + */ + static byte[] sqlite3DbRealloc( sqlite3 db, byte[] p, int n ) + { + byte[] pNew = null; + Debug.Assert( db != null ); + Debug.Assert( sqlite3_mutex_held( db.mutex ) ); + //if( db->mallocFailed==0 ){ + if ( p == null ) + { + return sqlite3DbMallocRaw( db, n ); + } #if !SQLITE_OMIT_LOOKASIDE if( isLookaside(db, p) ){ if( n<=db->lookaside.sz ){ @@ -871,124 +985,131 @@ static byte[] sqlite3DbRealloc(sqlite3 db, byte[] p, int n) { } }else #else - { - { + { + { #endif - Debug.Assert(sqlite3MemdebugHasType(p, MEMTYPE_DB)); - Debug.Assert(sqlite3MemdebugHasType(p, MEMTYPE_LOOKASIDE | MEMTYPE_HEAP)); - sqlite3MemdebugSetType(p, MEMTYPE_HEAP); - pNew = sqlite3_realloc(p, n); - //if( null==pNew ){ - //sqlite3MemdebugSetType(p, MEMTYPE_DB|MEMTYPE_HEAP); - // db->mallocFailed = 1; - //} + Debug.Assert( sqlite3MemdebugHasType( p, MEMTYPE_DB ) ); + Debug.Assert( sqlite3MemdebugHasType( p, MEMTYPE_LOOKASIDE | MEMTYPE_HEAP ) ); + sqlite3MemdebugSetType( p, MEMTYPE_HEAP ); + pNew = sqlite3_realloc( p, n ); + //if( null==pNew ){ + //sqlite3MemdebugSetType(p, MEMTYPE_DB|MEMTYPE_HEAP); + // db->mallocFailed = 1; + //} #if !SQLITE_OMIT_LOOKASIDE sqlite3MemdebugSetType(pNew, MEMTYPE_DB | (db.lookaside.bEnabled ? MEMTYPE_LOOKASIDE : MEMTYPE_HEAP)); #endif - } - } - return pNew; } + } + return pNew; + } - /* - ** Attempt to reallocate p. If the reallocation fails, then free p - ** and set the mallocFailed flag in the database connection. - */ - static byte[] sqlite3DbReallocOrFree(sqlite3 db, byte[] p, int n) { - byte[] pNew; - pNew = sqlite3DbRealloc(db, p, n); - if (null == pNew) { - sqlite3DbFree(db, ref p); - } - return pNew; - } + /* + ** Attempt to reallocate p. If the reallocation fails, then free p + ** and set the mallocFailed flag in the database connection. + */ + static byte[] sqlite3DbReallocOrFree( sqlite3 db, byte[] p, int n ) + { + byte[] pNew; + pNew = sqlite3DbRealloc( db, p, n ); + if ( null == pNew ) + { + sqlite3DbFree( db, ref p ); + } + return pNew; + } - /* - ** Make a copy of a string in memory obtained from sqliteMalloc(). These - ** functions call sqlite3MallocRaw() directly instead of sqliteMalloc(). This - ** is because when memory debugging is turned on, these two functions are - ** called via macros that record the current file and line number in the - ** ThreadData structure. - */ - //char *sqlite3DbStrDup(sqlite3 db, string z){ - // string zNew; - // size_t n; - // if( z==0 ){ - // return 0; - // } - // n = sqlite3Strlen30(z) + 1; - // Debug.Assert( (n&0x7fffffff)==n ); - // zNew = sqlite3DbMallocRaw(db, (int)n); - // if( zNew ){ - // memcpy(zNew, z, n); - // } - // return zNew; - //} - //char *sqlite3DbStrNDup(sqlite3 db, string z, int n){ - // string zNew; - // if( z==0 ){ - // return 0; - // } - // Debug.Assert( (n&0x7fffffff)==n ); - // zNew = sqlite3DbMallocRaw(db, n+1); - // if( zNew ){ - // memcpy(zNew, z, n); - // zNew[n] = 0; - // } - // return zNew; - //} + /* + ** Make a copy of a string in memory obtained from sqliteMalloc(). These + ** functions call sqlite3MallocRaw() directly instead of sqliteMalloc(). This + ** is because when memory debugging is turned on, these two functions are + ** called via macros that record the current file and line number in the + ** ThreadData structure. + */ + //char *sqlite3DbStrDup(sqlite3 db, string z){ + // string zNew; + // size_t n; + // if( z==0 ){ + // return 0; + // } + // n = sqlite3Strlen30(z) + 1; + // Debug.Assert( (n&0x7fffffff)==n ); + // zNew = sqlite3DbMallocRaw(db, (int)n); + // if( zNew ){ + // memcpy(zNew, z, n); + // } + // return zNew; + //} + //char *sqlite3DbStrNDup(sqlite3 db, string z, int n){ + // string zNew; + // if( z==0 ){ + // return 0; + // } + // Debug.Assert( (n&0x7fffffff)==n ); + // zNew = sqlite3DbMallocRaw(db, n+1); + // if( zNew ){ + // memcpy(zNew, z, n); + // zNew[n] = 0; + // } + // return zNew; + //} - /* - ** Create a string from the zFromat argument and the va_list that follows. - ** Store the string in memory obtained from sqliteMalloc() and make pz - ** point to that string. - */ - static void sqlite3SetString(ref string pz, sqlite3 db, string zFormat, params string[] ap) { - //va_list ap; - lock (lock_va_list) { - string z; + /* + ** Create a string from the zFromat argument and the va_list that follows. + ** Store the string in memory obtained from sqliteMalloc() and make pz + ** point to that string. + */ + static void sqlite3SetString( ref string pz, sqlite3 db, string zFormat, params string[] ap ) + { + //va_list ap; + lock ( lock_va_list ) + { + string z; - va_start(ap, zFormat); - z = sqlite3VMPrintf(db, zFormat, ap); - va_end(ref ap); - sqlite3DbFree(db, ref pz); - pz = z; - } - } + va_start( ap, zFormat ); + z = sqlite3VMPrintf( db, zFormat, ap ); + va_end( ref ap ); + sqlite3DbFree( db, ref pz ); + pz = z; + } + } - /* - ** This function must be called before exiting any API function (i.e. - ** returning control to the user) that has called sqlite3_malloc or - ** sqlite3_realloc. - ** - ** The returned value is normally a copy of the second argument to this - ** function. However, if a malloc() failure has occurred since the previous - ** invocation SQLITE_NOMEM is returned instead. - ** - ** If the first argument, db, is not NULL and a malloc() error has occurred, - ** then the connection error-code (the value returned by sqlite3_errcode()) - ** is set to SQLITE_NOMEM. - */ - static int sqlite3ApiExit(int zero, int rc) { - sqlite3 db = null; - return sqlite3ApiExit(db, rc); - } + /* + ** This function must be called before exiting any API function (i.e. + ** returning control to the user) that has called sqlite3_malloc or + ** sqlite3_realloc. + ** + ** The returned value is normally a copy of the second argument to this + ** function. However, if a malloc() failure has occurred since the previous + ** invocation SQLITE_NOMEM is returned instead. + ** + ** If the first argument, db, is not NULL and a malloc() error has occurred, + ** then the connection error-code (the value returned by sqlite3_errcode()) + ** is set to SQLITE_NOMEM. + */ + static int sqlite3ApiExit( int zero, int rc ) + { + sqlite3 db = null; + return sqlite3ApiExit( db, rc ); + } - static int sqlite3ApiExit(sqlite3 db, int rc) { - /* If the db handle is not NULL, then we must hold the connection handle - ** mutex here. Otherwise the read (and possible write) of db.mallocFailed - ** is unsafe, as is the call to sqlite3Error(). - */ - Debug.Assert(db == null || sqlite3_mutex_held(db.mutex)); - if ( /*db != null && db.mallocFailed != 0 || */ rc == SQLITE_IOERR_NOMEM) { - sqlite3Error(db, SQLITE_NOMEM, ""); - //db.mallocFailed = 0; - rc = SQLITE_NOMEM; - } - return rc & (db != null ? db.errMask : 0xff); - } + static int sqlite3ApiExit( sqlite3 db, int rc ) + { + /* If the db handle is not NULL, then we must hold the connection handle + ** mutex here. Otherwise the read (and possible write) of db.mallocFailed + ** is unsafe, as is the call to sqlite3Error(). + */ + Debug.Assert( db == null || sqlite3_mutex_held( db.mutex ) ); + if ( /*db != null && db.mallocFailed != 0 || */ rc == SQLITE_IOERR_NOMEM ) + { + sqlite3Error( db, SQLITE_NOMEM, "" ); + //db.mallocFailed = 0; + rc = SQLITE_NOMEM; + } + return rc & ( db != null ? db.errMask : 0xff ); } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/mem_Pool.cs b/src/extensions/IronPython.SQLite/c#sqlite/mem_Pool.cs index 3e5d2f5b1..bd4986555 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/mem_Pool.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/mem_Pool.cs @@ -1,26 +1,34 @@ using System; +using System.Diagnostics; +using System.Runtime.InteropServices; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ************************************************************************* - ** - ** This file contains low-level memory & pool allocation drivers - ** - ** This file contains implementations of the low-level memory allocation - ** routines specified in the sqlite3_mem_methods object. - ** - ************************************************************************* - */ +using sqlite3_int64 = System.Int64; +using u32 = System.UInt32; +using System.Text; - /* - ** Like malloc(), but remember the size of the allocation - ** so that we can find it later using sqlite3MemSize(). - ** - ** For this low-level routine, we are guaranteed that nByte>0 because - ** cases of nByte<=0 will be intercepted and dealt with by higher level - ** routines. - */ +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ************************************************************************* + ** + ** This file contains low-level memory & pool allocation drivers + ** + ** This file contains implementations of the low-level memory allocation + ** routines specified in the sqlite3_mem_methods object. + ** + ************************************************************************* + */ + + /* + ** Like malloc(), but remember the size of the allocation + ** so that we can find it later using sqlite3MemSize(). + ** + ** For this low-level routine, we are guaranteed that nByte>0 because + ** cases of nByte<=0 will be intercepted and dealt with by higher level + ** routines. + */ #if SQLITE_POOL_MEM #if TRUE static byte[] sqlite3MemMalloc( u32 nByte ) @@ -141,26 +149,28 @@ static BtCursor sqlite3MemMallocBtCursor( BtCursor dummy ) return pBtCursor; } #endif - /* - ** Free memory. - */ - // -- overloads --------------------------------------- - static void sqlite3MemFree(ref T x) where T : class { - x = null; - } - static void sqlite3MemFree(ref string x) { - x = null; - } - // + /* + ** Free memory. + */ + // -- overloads --------------------------------------- + static void sqlite3MemFree( ref T x ) where T : class + { + x = null; + } + static void sqlite3MemFree( ref string x ) + { + x = null; + } + // - /* - ** Like free() but works for allocations obtained from sqlite3MemMalloc() - ** or sqlite3MemRealloc(). - ** - ** For this low-level routine, we already know that pPrior!=0 since - ** cases where pPrior==0 will have been intecepted and dealt with - ** by higher-level routines. - */ + /* + ** Like free() but works for allocations obtained from sqlite3MemMalloc() + ** or sqlite3MemRealloc(). + ** + ** For this low-level routine, we already know that pPrior!=0 since + ** cases where pPrior==0 will have been intecepted and dealt with + ** by higher-level routines. + */ #if SQLITE_POOL_MEM #if TRUE static void sqlite3MemFreeInt( ref int[] pPrior ) @@ -311,108 +321,120 @@ static byte[] sqlite3MemRealloc( ref byte[] pPrior, int nByte ) return pPrior; } #else - /* - ** No-op versions of all memory allocation routines - */ - static byte[] sqlite3MemMalloc(int nByte) { return new byte[nByte]; } - static int[] sqlite3MemMallocInt(int nInt) { return new int[nInt]; } - static Mem sqlite3MemMallocMem(Mem pMem) { return new Mem(); } - static void sqlite3MemFree(ref byte[] pPrior) { pPrior = null; } - static void sqlite3MemFreeInt(ref int[] pPrior) { pPrior = null; } - static void sqlite3MemFreeMem(ref Mem pPrior) { pPrior = null; } - static int sqlite3MemInit() { return SQLITE_OK; } - static void sqlite3MemShutdown() { } - static BtCursor sqlite3MemMallocBtCursor(BtCursor dummy) { return new BtCursor(); } - static void sqlite3MemFreeBtCursor(ref BtCursor pPrior) { pPrior = null; } + /* +** No-op versions of all memory allocation routines +*/ +static byte[] sqlite3MemMalloc(int nByte) { return new byte[nByte]; } +static int[] sqlite3MemMallocInt(int nInt) { return new int[nInt]; } +static Mem sqlite3MemMallocMem( Mem pMem) { return new Mem(); } +static void sqlite3MemFree( ref byte[] pPrior ) { pPrior = null; } +static void sqlite3MemFreeInt( ref int[] pPrior ) { pPrior = null; } +static void sqlite3MemFreeMem(ref Mem pPrior) { pPrior = null; } +static int sqlite3MemInit() { return SQLITE_OK; } +static void sqlite3MemShutdown() { } +static BtCursor sqlite3MemMallocBtCursor( BtCursor dummy ){return new BtCursor();} +static void sqlite3MemFreeBtCursor(ref BtCursor pPrior) { pPrior = null; } #endif - static byte[] sqlite3MemRealloc(byte[] pPrior, int nByte) { - Array.Resize(ref pPrior, nByte); - return pPrior; - } + static byte[] sqlite3MemRealloc( byte[] pPrior, int nByte ) + { + Array.Resize( ref pPrior, nByte ); + return pPrior; + } - /* - ** Report the allocated size of a prior return from xMalloc() - ** or xRealloc(). - */ - static int sqlite3MemSize(byte[] pPrior) { - // sqlite3_int64 p; - // if( pPrior==0 ) return 0; - // p = (sqlite3_int64*)pPrior; - // p--; - // return p[0]; - return pPrior == null ? 0 : (int)pPrior.Length; - } + /* + ** Report the allocated size of a prior return from xMalloc() + ** or xRealloc(). + */ + static int sqlite3MemSize( byte[] pPrior ) + { + // sqlite3_int64 p; + // if( pPrior==0 ) return 0; + // p = (sqlite3_int64*)pPrior; + // p--; + // return p[0]; + return pPrior == null ? 0 : (int)pPrior.Length; + } - /* - ** Round up a request size to the next valid allocation size. - */ - static int sqlite3MemRoundup(int n) { - return n;// ROUND8( n ); - } + /* + ** Round up a request size to the next valid allocation size. + */ + static int sqlite3MemRoundup( int n ) + { + return n;// ROUND8( n ); + } - /* - ** Initialize this module. - */ - static int sqlite3MemInit(object NotUsed) { - UNUSED_PARAMETER(NotUsed); - if (!sqlite3GlobalConfig.bMemstat) { - /* If memory status is enabled, then the malloc.c wrapper will already - ** hold the STATIC_MEM mutex when the routines here are invoked. */ - mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); - } - return SQLITE_OK; - } + /* + ** Initialize this module. + */ + static int sqlite3MemInit( object NotUsed ) + { + UNUSED_PARAMETER( NotUsed ); + if ( !sqlite3GlobalConfig.bMemstat ) + { + /* If memory status is enabled, then the malloc.c wrapper will already + ** hold the STATIC_MEM mutex when the routines here are invoked. */ + mem0.mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MEM ); + } + return SQLITE_OK; + } - /* - ** Deinitialize this module. - */ - static void sqlite3MemShutdown(object NotUsed) { + /* + ** Deinitialize this module. + */ + static void sqlite3MemShutdown( object NotUsed ) + { - UNUSED_PARAMETER(NotUsed); - return; - } + UNUSED_PARAMETER( NotUsed ); + return; + } - /* - ** This routine is the only routine in this file with external linkage. - ** - ** Populate the low-level memory allocation function pointers in - ** sqlite3GlobalConfig.m with pointers to the routines in this file. - */ - static void sqlite3MemSetDefault() { - sqlite3_mem_methods defaultMethods = new sqlite3_mem_methods( - sqlite3MemMalloc, - sqlite3MemMallocInt, - sqlite3MemMallocMem, - sqlite3MemFree, - sqlite3MemFreeInt, - sqlite3MemFreeMem, - sqlite3MemRealloc, - sqlite3MemSize, - sqlite3MemRoundup, - (dxMemInit)sqlite3MemInit, - (dxMemShutdown)sqlite3MemShutdown, - 0 - ); - sqlite3_config(SQLITE_CONFIG_MALLOC, defaultMethods); - } + /* + ** This routine is the only routine in this file with external linkage. + ** + ** Populate the low-level memory allocation function pointers in + ** sqlite3GlobalConfig.m with pointers to the routines in this file. + */ + static void sqlite3MemSetDefault() + { + sqlite3_mem_methods defaultMethods = new sqlite3_mem_methods( + sqlite3MemMalloc, + sqlite3MemMallocInt, + sqlite3MemMallocMem, + sqlite3MemFree, + sqlite3MemFreeInt, + sqlite3MemFreeMem, + sqlite3MemRealloc, + sqlite3MemSize, + sqlite3MemRoundup, + (dxMemInit)sqlite3MemInit, + (dxMemShutdown)sqlite3MemShutdown, + 0 + ); + sqlite3_config( SQLITE_CONFIG_MALLOC, defaultMethods ); + } - static void sqlite3DbFree(sqlite3 db, ref int[] pPrior) { - if (pPrior != null) - sqlite3MemFreeInt(ref pPrior); - } - static void sqlite3DbFree(sqlite3 db, ref Mem pPrior) { - if (pPrior != null) - sqlite3MemFreeMem(ref pPrior); - } - static void sqlite3DbFree(sqlite3 db, ref Mem[] pPrior) { - if (pPrior != null) - for (int i = 0; i < pPrior.Length; i++) - sqlite3MemFreeMem(ref pPrior[i]); - } - static void sqlite3DbFree(sqlite3 db, ref T pT) where T : class { - } - static void sqlite3DbFree(sqlite3 db, ref string pString) { - } + static void sqlite3DbFree( sqlite3 db, ref int[] pPrior ) + { + if ( pPrior != null ) + sqlite3MemFreeInt( ref pPrior ); + } + static void sqlite3DbFree( sqlite3 db, ref Mem pPrior ) + { + if ( pPrior != null ) + sqlite3MemFreeMem( ref pPrior ); + } + static void sqlite3DbFree( sqlite3 db, ref Mem[] pPrior ) + { + if ( pPrior != null ) + for ( int i = 0; i < pPrior.Length; i++ ) + sqlite3MemFreeMem( ref pPrior[i] ); + } + static void sqlite3DbFree( sqlite3 db, ref T pT ) where T : class + { + } + static void sqlite3DbFree( sqlite3 db, ref string pString ) + { } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/memjournal_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/memjournal_c.cs index 1a61baa15..bc7423ae9 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/memjournal_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/memjournal_c.cs @@ -1,290 +1,321 @@ using System; using System.Diagnostics; +using System.Text; +using Bitmask = System.UInt64; +using u8 = System.Byte; +using u16 = System.UInt16; using u32 = System.UInt32; -namespace Community.CsharpSqlite { - using MemJournal = Sqlite3.sqlite3_file; - using sqlite3_int64 = System.Int64; +namespace Community.CsharpSqlite +{ + using sqlite3_int64 = System.Int64; + using MemJournal = Sqlite3.sqlite3_file; - public partial class Sqlite3 { - /* - ** 2007 August 22 - ** - ** 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 contains code use to implement an in-memory rollback journal. - ** The in-memory rollback journal is used to journal transactions for - ** ":memory:" databases and when the journal_mode=MEMORY pragma is used. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-12-07 20:14:09 a586a4deeb25330037a49df295b36aaf624d0f45 - ** - ************************************************************************* - */ + public partial class Sqlite3 + { + /* + ** 2007 August 22 + ** + ** 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 contains code use to implement an in-memory rollback journal. + ** The in-memory rollback journal is used to journal transactions for + ** ":memory:" databases and when the journal_mode=MEMORY pragma is used. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-12-07 20:14:09 a586a4deeb25330037a49df295b36aaf624d0f45 + ** + ************************************************************************* + */ - //#include "sqliteInt.h" + //#include "sqliteInt.h" - /* Forward references to internal structures */ - //typedef struct MemJournal MemJournal; - //typedef struct FilePoint FilePoint; - //typedef struct FileChunk FileChunk; + /* Forward references to internal structures */ + //typedef struct MemJournal MemJournal; + //typedef struct FilePoint FilePoint; + //typedef struct FileChunk FileChunk; - /* Space to hold the rollback journal is allocated in increments of - ** this many bytes. - ** - ** The size chosen is a little less than a power of two. That way, - ** the FileChunk object will have a size that almost exactly fills - ** a power-of-two allocation. This mimimizes wasted space in power-of-two - ** memory allocators. - */ - //#define JOURNAL_CHUNKSIZE ((int)(1024-sizeof(FileChunk*))) - const int JOURNAL_CHUNKSIZE = 4096; + /* Space to hold the rollback journal is allocated in increments of + ** this many bytes. + ** + ** The size chosen is a little less than a power of two. That way, + ** the FileChunk object will have a size that almost exactly fills + ** a power-of-two allocation. This mimimizes wasted space in power-of-two + ** memory allocators. + */ + //#define JOURNAL_CHUNKSIZE ((int)(1024-sizeof(FileChunk*))) + const int JOURNAL_CHUNKSIZE = 4096; - /* Macro to find the minimum of two numeric values. - */ - //#if !MIN - //# define MIN(x,y) ((x)<(y)?(x):(y)) - //#endif - static int MIN(int x, int y) { - return (x < y) ? x : y; - } - static int MIN(int x, u32 y) { - return (x < y) ? x : (int)y; - } - - /* - ** The rollback journal is composed of a linked list of these structures. - */ - public class FileChunk { - public FileChunk pNext; /* Next chunk in the journal */ - public byte[] zChunk = new byte[JOURNAL_CHUNKSIZE]; /* Content of this chunk */ - }; - - /* - ** An instance of this object serves as a cursor into the rollback journal. - ** The cursor can be either for reading or writing. - */ - public class FilePoint { - public long iOffset; /* Offset from the beginning of the file */ - public FileChunk pChunk; /* Specific chunk into which cursor points */ - }; + /* Macro to find the minimum of two numeric values. + */ + //#if !MIN + //# define MIN(x,y) ((x)<(y)?(x):(y)) + //#endif + static int MIN( int x, int y ) + { + return ( x < y ) ? x : y; + } + static int MIN( int x, u32 y ) + { + return ( x < y ) ? x : (int)y; + } - /* - ** This subclass is a subclass of sqlite3_file. Each open memory-journal - ** is an instance of this class. - */ - public partial class sqlite3_file { - //public sqlite3_io_methods pMethods; /* Parent class. MUST BE FIRST */ - public FileChunk pFirst; /* Head of in-memory chunk-list */ - public FilePoint endpoint; /* Pointer to the end of the file */ - public FilePoint readpoint; /* Pointer to the end of the last xRead() */ - }; + /* + ** The rollback journal is composed of a linked list of these structures. + */ + public class FileChunk + { + public FileChunk pNext; /* Next chunk in the journal */ + public byte[] zChunk = new byte[JOURNAL_CHUNKSIZE]; /* Content of this chunk */ + }; - /* - ** Read data from the in-memory journal file. This is the implementation - ** of the sqlite3_vfs.xRead method. - */ - static int memjrnlRead( - sqlite3_file pJfd, /* The journal file from which to read */ - byte[] zBuf, /* Put the results here */ - int iAmt, /* Number of bytes to read */ - sqlite3_int64 iOfst /* Begin reading at this offset */ - ) { - MemJournal p = (MemJournal)pJfd; - byte[] zOut = zBuf; - int nRead = iAmt; - int iChunkOffset; - FileChunk pChunk; + /* + ** An instance of this object serves as a cursor into the rollback journal. + ** The cursor can be either for reading or writing. + */ + public class FilePoint + { + public long iOffset; /* Offset from the beginning of the file */ + public FileChunk pChunk; /* Specific chunk into which cursor points */ + }; - /* SQLite never tries to read past the end of a rollback journal file */ - Debug.Assert(iOfst + iAmt <= p.endpoint.iOffset); + /* + ** This subclass is a subclass of sqlite3_file. Each open memory-journal + ** is an instance of this class. + */ + public partial class sqlite3_file + { + //public sqlite3_io_methods pMethods; /* Parent class. MUST BE FIRST */ + public FileChunk pFirst; /* Head of in-memory chunk-list */ + public FilePoint endpoint; /* Pointer to the end of the file */ + public FilePoint readpoint; /* Pointer to the end of the last xRead() */ + }; - if (p.readpoint.iOffset != iOfst || iOfst == 0) { - int iOff = 0; - for (pChunk = p.pFirst; - ALWAYS(pChunk != null) && (iOff + JOURNAL_CHUNKSIZE) <= iOfst; - pChunk = pChunk.pNext - ) { - iOff += JOURNAL_CHUNKSIZE; - } - } else { - pChunk = p.readpoint.pChunk; - } + /* + ** Read data from the in-memory journal file. This is the implementation + ** of the sqlite3_vfs.xRead method. + */ + static int memjrnlRead( + sqlite3_file pJfd, /* The journal file from which to read */ + byte[] zBuf, /* Put the results here */ + int iAmt, /* Number of bytes to read */ + sqlite3_int64 iOfst /* Begin reading at this offset */ + ) + { + MemJournal p = (MemJournal)pJfd; + byte[] zOut = zBuf; + int nRead = iAmt; + int iChunkOffset; + FileChunk pChunk; - iChunkOffset = (int)(iOfst % JOURNAL_CHUNKSIZE); - int izOut = 0; - do { - int iSpace = JOURNAL_CHUNKSIZE - iChunkOffset; - int nCopy = MIN(nRead, (JOURNAL_CHUNKSIZE - iChunkOffset)); - Buffer.BlockCopy(pChunk.zChunk, iChunkOffset, zOut, izOut, nCopy); //memcpy( zOut, pChunk.zChunk[iChunkOffset], nCopy ); - izOut += nCopy;// zOut += nCopy; - nRead -= iSpace; - iChunkOffset = 0; - } while (nRead >= 0 && (pChunk = pChunk.pNext) != null && nRead > 0); - p.readpoint.iOffset = (int)(iOfst + iAmt); - p.readpoint.pChunk = pChunk; + /* SQLite never tries to read past the end of a rollback journal file */ + Debug.Assert( iOfst + iAmt <= p.endpoint.iOffset ); - return SQLITE_OK; + if ( p.readpoint.iOffset != iOfst || iOfst == 0 ) + { + int iOff = 0; + for ( pChunk = p.pFirst; + ALWAYS( pChunk != null ) && ( iOff + JOURNAL_CHUNKSIZE ) <= iOfst; + pChunk = pChunk.pNext + ) + { + iOff += JOURNAL_CHUNKSIZE; } + } + else + { + pChunk = p.readpoint.pChunk; + } - /* - ** Write data to the file. - */ - static int memjrnlWrite( - sqlite3_file pJfd, /* The journal file into which to write */ - byte[] zBuf, /* Take data to be written from here */ - int iAmt, /* Number of bytes to write */ - sqlite3_int64 iOfst /* Begin writing at this offset into the file */ - ) { - MemJournal p = (MemJournal)pJfd; - int nWrite = iAmt; - byte[] zWrite = zBuf; - int izWrite = 0; + iChunkOffset = (int)( iOfst % JOURNAL_CHUNKSIZE ); + int izOut = 0; + do + { + int iSpace = JOURNAL_CHUNKSIZE - iChunkOffset; + int nCopy = MIN( nRead, ( JOURNAL_CHUNKSIZE - iChunkOffset ) ); + Buffer.BlockCopy( pChunk.zChunk, iChunkOffset, zOut, izOut, nCopy ); //memcpy( zOut, pChunk.zChunk[iChunkOffset], nCopy ); + izOut += nCopy;// zOut += nCopy; + nRead -= iSpace; + iChunkOffset = 0; + } while ( nRead >= 0 && ( pChunk = pChunk.pNext ) != null && nRead > 0 ); + p.readpoint.iOffset = (int)( iOfst + iAmt ); + p.readpoint.pChunk = pChunk; - /* An in-memory journal file should only ever be appended to. Random - ** access writes are not required by sqlite. - */ - Debug.Assert(iOfst == p.endpoint.iOffset); - UNUSED_PARAMETER(iOfst); + return SQLITE_OK; + } - while (nWrite > 0) { - FileChunk pChunk = p.endpoint.pChunk; - int iChunkOffset = (int)(p.endpoint.iOffset % JOURNAL_CHUNKSIZE); - int iSpace = MIN(nWrite, JOURNAL_CHUNKSIZE - iChunkOffset); + /* + ** Write data to the file. + */ + static int memjrnlWrite( + sqlite3_file pJfd, /* The journal file into which to write */ + byte[] zBuf, /* Take data to be written from here */ + int iAmt, /* Number of bytes to write */ + sqlite3_int64 iOfst /* Begin writing at this offset into the file */ + ) + { + MemJournal p = (MemJournal)pJfd; + int nWrite = iAmt; + byte[] zWrite = zBuf; + int izWrite = 0; - if (iChunkOffset == 0) { - /* New chunk is required to extend the file. */ - FileChunk pNew = new FileChunk();// sqlite3_malloc( sizeof( FileChunk ) ); - if (null == pNew) { - return SQLITE_IOERR_NOMEM; - } - pNew.pNext = null; - if (pChunk != null) { - Debug.Assert(p.pFirst != null); - pChunk.pNext = pNew; - } else { - Debug.Assert(null == p.pFirst); - p.pFirst = pNew; - } - p.endpoint.pChunk = pNew; - } + /* An in-memory journal file should only ever be appended to. Random + ** access writes are not required by sqlite. + */ + Debug.Assert( iOfst == p.endpoint.iOffset ); + UNUSED_PARAMETER( iOfst ); - Buffer.BlockCopy(zWrite, izWrite, p.endpoint.pChunk.zChunk, iChunkOffset, iSpace); //memcpy( &p.endpoint.pChunk.zChunk[iChunkOffset], zWrite, iSpace ); - izWrite += iSpace;//zWrite += iSpace; - nWrite -= iSpace; - p.endpoint.iOffset += iSpace; - } + while ( nWrite > 0 ) + { + FileChunk pChunk = p.endpoint.pChunk; + int iChunkOffset = (int)( p.endpoint.iOffset % JOURNAL_CHUNKSIZE ); + int iSpace = MIN( nWrite, JOURNAL_CHUNKSIZE - iChunkOffset ); - return SQLITE_OK; + if ( iChunkOffset == 0 ) + { + /* New chunk is required to extend the file. */ + FileChunk pNew = new FileChunk();// sqlite3_malloc( sizeof( FileChunk ) ); + if ( null == pNew ) + { + return SQLITE_IOERR_NOMEM; + } + pNew.pNext = null; + if ( pChunk != null ) + { + Debug.Assert( p.pFirst != null ); + pChunk.pNext = pNew; + } + else + { + Debug.Assert( null == p.pFirst ); + p.pFirst = pNew; + } + p.endpoint.pChunk = pNew; } - /* - ** Truncate the file. - */ - static int memjrnlTruncate(sqlite3_file pJfd, sqlite3_int64 size) { - MemJournal p = (MemJournal)pJfd; - ////FileChunk pChunk; - Debug.Assert(size == 0); - UNUSED_PARAMETER(size); - ////pChunk = p.pFirst; - ////while ( pChunk != null ) - ////{ - ////FileChunk pTmp = pChunk; - ////pChunk = pChunk.pNext; - ////sqlite3_free( ref pTmp ); - ////} - sqlite3MemJournalOpen(pJfd); - return SQLITE_OK; - } + Buffer.BlockCopy( zWrite, izWrite, p.endpoint.pChunk.zChunk, iChunkOffset, iSpace ); //memcpy( &p.endpoint.pChunk.zChunk[iChunkOffset], zWrite, iSpace ); + izWrite += iSpace;//zWrite += iSpace; + nWrite -= iSpace; + p.endpoint.iOffset += iSpace; + } - /* - ** Close the file. - */ - static int memjrnlClose(MemJournal pJfd) { - memjrnlTruncate(pJfd, 0); - return SQLITE_OK; - } + return SQLITE_OK; + } - /* - ** Sync the file. - ** - ** Syncing an in-memory journal is a no-op. And, in fact, this routine - ** is never called in a working implementation. This implementation - ** exists purely as a contingency, in case some malfunction in some other - ** part of SQLite causes Sync to be called by mistake. - */ - static int memjrnlSync(sqlite3_file NotUsed, int NotUsed2) { - UNUSED_PARAMETER2(NotUsed, NotUsed2); - return SQLITE_OK; - } + /* + ** Truncate the file. + */ + static int memjrnlTruncate( sqlite3_file pJfd, sqlite3_int64 size ) + { + MemJournal p = (MemJournal)pJfd; + ////FileChunk pChunk; + Debug.Assert( size == 0 ); + UNUSED_PARAMETER( size ); + ////pChunk = p.pFirst; + ////while ( pChunk != null ) + ////{ + ////FileChunk pTmp = pChunk; + ////pChunk = pChunk.pNext; + ////sqlite3_free( ref pTmp ); + ////} + sqlite3MemJournalOpen( pJfd ); + return SQLITE_OK; + } - /* - ** Query the size of the file in bytes. - */ - static int memjrnlFileSize(sqlite3_file pJfd, ref long pSize) { - MemJournal p = (MemJournal)pJfd; - pSize = p.endpoint.iOffset; - return SQLITE_OK; - } + /* + ** Close the file. + */ + static int memjrnlClose( MemJournal pJfd ) + { + memjrnlTruncate( pJfd, 0 ); + return SQLITE_OK; + } - /* - ** Table of methods for MemJournal sqlite3_file object. - */ - static sqlite3_io_methods MemJournalMethods = new sqlite3_io_methods( - 1, /* iVersion */ - (dxClose)memjrnlClose, /* xClose */ - (dxRead)memjrnlRead, /* xRead */ - (dxWrite)memjrnlWrite, /* xWrite */ - (dxTruncate)memjrnlTruncate, /* xTruncate */ - (dxSync)memjrnlSync, /* xSync */ - (dxFileSize)memjrnlFileSize, /* xFileSize */ - null, /* xLock */ - null, /* xUnlock */ - null, /* xCheckReservedLock */ - null, /* xFileControl */ - null, /* xSectorSize */ - null, /* xDeviceCharacteristics */ - null, /* xShmMap */ - null, /* xShmLock */ - null, /* xShmBarrier */ - null /* xShmUnlock */ - ); + /* + ** Sync the file. + ** + ** Syncing an in-memory journal is a no-op. And, in fact, this routine + ** is never called in a working implementation. This implementation + ** exists purely as a contingency, in case some malfunction in some other + ** part of SQLite causes Sync to be called by mistake. + */ + static int memjrnlSync( sqlite3_file NotUsed, int NotUsed2 ) + { + UNUSED_PARAMETER2( NotUsed, NotUsed2 ); + return SQLITE_OK; + } - /* - ** Open a journal file. - */ - static void sqlite3MemJournalOpen(sqlite3_file pJfd) { - MemJournal p = (MemJournal)pJfd; - //memset( p, 0, sqlite3MemJournalSize() ); - p.pFirst = null; - p.endpoint = new FilePoint(); - p.readpoint = new FilePoint(); - p.pMethods = MemJournalMethods;//(sqlite3_io_methods*)&MemJournalMethods; - } + /* + ** Query the size of the file in bytes. + */ + static int memjrnlFileSize( sqlite3_file pJfd, ref long pSize ) + { + MemJournal p = (MemJournal)pJfd; + pSize = p.endpoint.iOffset; + return SQLITE_OK; + } - /* - ** Return true if the file-handle passed as an argument is - ** an in-memory journal - */ - static bool sqlite3IsMemJournal(sqlite3_file pJfd) { - return pJfd.pMethods == MemJournalMethods; - } + /* + ** Table of methods for MemJournal sqlite3_file object. + */ + static sqlite3_io_methods MemJournalMethods = new sqlite3_io_methods( + 1, /* iVersion */ + (dxClose)memjrnlClose, /* xClose */ + (dxRead)memjrnlRead, /* xRead */ + (dxWrite)memjrnlWrite, /* xWrite */ + (dxTruncate)memjrnlTruncate, /* xTruncate */ + (dxSync)memjrnlSync, /* xSync */ + (dxFileSize)memjrnlFileSize, /* xFileSize */ + null, /* xLock */ + null, /* xUnlock */ + null, /* xCheckReservedLock */ + null, /* xFileControl */ + null, /* xSectorSize */ + null, /* xDeviceCharacteristics */ + null, /* xShmMap */ + null, /* xShmLock */ + null, /* xShmBarrier */ + null /* xShmUnlock */ + ); - /* - ** Return the number of bytes required to store a MemJournal file descriptor. - */ - static int sqlite3MemJournalSize() { - return 3096; // sizeof( MemJournal ); - } + /* + ** Open a journal file. + */ + static void sqlite3MemJournalOpen( sqlite3_file pJfd ) + { + MemJournal p = (MemJournal)pJfd; + //memset( p, 0, sqlite3MemJournalSize() ); + p.pFirst = null; + p.endpoint = new FilePoint(); + p.readpoint = new FilePoint(); + p.pMethods = MemJournalMethods;//(sqlite3_io_methods*)&MemJournalMethods; + } + + /* + ** Return true if the file-handle passed as an argument is + ** an in-memory journal + */ + static bool sqlite3IsMemJournal( sqlite3_file pJfd ) + { + return pJfd.pMethods == MemJournalMethods; + } + + /* + ** Return the number of bytes required to store a MemJournal file descriptor. + */ + static int sqlite3MemJournalSize() + { + return 3096; // sizeof( MemJournal ); } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/mutex_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/mutex_c.cs index b09628257..09824d576 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/mutex_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/mutex_c.cs @@ -1,165 +1,169 @@ +using System; using System.Diagnostics; - -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2007 August 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 file contains the C functions that implement mutexes. - ** - ** This file contains code that is common across all mutex implementations. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +using System.Threading; + +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 2007 August 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 file contains the C functions that implement mutexes. + ** + ** This file contains code that is common across all mutex implementations. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ + //#include "sqliteInt.h" #if (SQLITE_DEBUG) && !(SQLITE_MUTEX_OMIT) - /* - ** For debugging purposes, record when the mutex subsystem is initialized - ** and uninitialized so that we can assert() if there is an attempt to - ** allocate a mutex while the system is uninitialized. - */ - static int mutexIsInit = 0; +/* +** For debugging purposes, record when the mutex subsystem is initialized +** and uninitialized so that we can assert() if there is an attempt to +** allocate a mutex while the system is uninitialized. +*/ +static int mutexIsInit = 0; #endif //* SQLITE_DEBUG */ #if !SQLITE_MUTEX_OMIT - /* - ** Initialize the mutex system. - */ - static int sqlite3MutexInit() { - int rc = SQLITE_OK; - if (null == sqlite3GlobalConfig.mutex.xMutexAlloc) { - /* If the xMutexAlloc method has not been set, then the user did not - ** install a mutex implementation via sqlite3_config() prior to - ** sqlite3_initialize() being called. This block copies pointers to - ** the default implementation into the sqlite3GlobalConfig structure. - */ - sqlite3_mutex_methods pFrom; - sqlite3_mutex_methods pTo = sqlite3GlobalConfig.mutex; - - if (sqlite3GlobalConfig.bCoreMutex) { - pFrom = sqlite3DefaultMutex(); - } else { - pFrom = sqlite3NoopMutex(); - } - //memcpy(pTo, pFrom, offsetof(sqlite3_mutex_methods, xMutexAlloc)); - //memcpy(pTo.xMutexFree, pFrom.xMutexFree, - // sizeof(*pTo) - offsetof(sqlite3_mutex_methods, xMutexFree)); - pTo.Copy(pFrom); - } - rc = sqlite3GlobalConfig.mutex.xMutexInit(); +/* +** Initialize the mutex system. +*/ +static int sqlite3MutexInit(){ + int rc = SQLITE_OK; + if( null==sqlite3GlobalConfig.mutex.xMutexAlloc ){ + /* If the xMutexAlloc method has not been set, then the user did not + ** install a mutex implementation via sqlite3_config() prior to + ** sqlite3_initialize() being called. This block copies pointers to + ** the default implementation into the sqlite3GlobalConfig structure. + */ + sqlite3_mutex_methods pFrom; + sqlite3_mutex_methods pTo = sqlite3GlobalConfig.mutex; + + if( sqlite3GlobalConfig.bCoreMutex ){ + pFrom = sqlite3DefaultMutex(); + }else{ + pFrom = sqlite3NoopMutex(); + } + //memcpy(pTo, pFrom, offsetof(sqlite3_mutex_methods, xMutexAlloc)); + //memcpy(pTo.xMutexFree, pFrom.xMutexFree, + // sizeof(*pTo) - offsetof(sqlite3_mutex_methods, xMutexFree)); + pTo.Copy(pFrom); + } + rc = sqlite3GlobalConfig.mutex.xMutexInit(); #if SQLITE_DEBUG - mutexIsInit = 1; //GLOBAL(int, mutexIsInit) = 1; + mutexIsInit = 1; //GLOBAL(int, mutexIsInit) = 1; #endif - return rc; - } - - /* - ** Shutdown the mutex system. This call frees resources allocated by - ** sqlite3MutexInit(). - */ - static int sqlite3MutexEnd() { - int rc = SQLITE_OK; - if (sqlite3GlobalConfig.mutex.xMutexEnd != null) { - rc = sqlite3GlobalConfig.mutex.xMutexEnd(); - } + return rc; +} -#if SQLITE_DEBUG - mutexIsInit = 0;//GLOBAL(int, mutexIsInit) = 0; +/* +** Shutdown the mutex system. This call frees resources allocated by +** sqlite3MutexInit(). +*/ +static int sqlite3MutexEnd(){ + int rc = SQLITE_OK; + if( sqlite3GlobalConfig.mutex.xMutexEnd !=null){ + rc = sqlite3GlobalConfig.mutex.xMutexEnd(); + } + +#if SQLITE_DEBUG + mutexIsInit = 0;//GLOBAL(int, mutexIsInit) = 0; #endif - return rc; - } + return rc; +} - /* - ** Retrieve a pointer to a static mutex or allocate a new dynamic one. - */ - static sqlite3_mutex sqlite3_mutex_alloc(int id) { +/* +** Retrieve a pointer to a static mutex or allocate a new dynamic one. +*/ +static sqlite3_mutex sqlite3_mutex_alloc(int id){ #if !SQLITE_OMIT_AUTOINIT - if (sqlite3_initialize() != 0) return null; + if( sqlite3_initialize()!=0 ) return null; #endif - return sqlite3GlobalConfig.mutex.xMutexAlloc(id); - } - - static sqlite3_mutex sqlite3MutexAlloc(int id) { - if (!sqlite3GlobalConfig.bCoreMutex) { - return null; - } - Debug.Assert(mutexIsInit != 0);//assert( GLOBAL(int, mutexIsInit) ); - return sqlite3GlobalConfig.mutex.xMutexAlloc(id); - } - - /* - ** Free a dynamic mutex. - */ - static void sqlite3_mutex_free(sqlite3_mutex p) { - if (p != null) { - sqlite3GlobalConfig.mutex.xMutexFree(p); - } - } - - /* - ** Obtain the mutex p. If some other thread already has the mutex, block - ** until it can be obtained. - */ - static void sqlite3_mutex_enter(sqlite3_mutex p) { - if (p != null) { - sqlite3GlobalConfig.mutex.xMutexEnter(p); - } - } - - /* - ** Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another - ** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY. - */ - static int sqlite3_mutex_try(sqlite3_mutex p) { - int rc = SQLITE_OK; - if (p != null) { - return sqlite3GlobalConfig.mutex.xMutexTry(p); - } - return rc; - } - - /* - ** The sqlite3_mutex_leave() routine exits a mutex that was previously - ** entered by the same thread. The behavior is undefined if the mutex - ** is not currently entered. If a NULL pointer is passed as an argument - ** this function is a no-op. - */ - static void sqlite3_mutex_leave(sqlite3_mutex p) { - if (p != null) { - sqlite3GlobalConfig.mutex.xMutexLeave(p); - } - } + return sqlite3GlobalConfig.mutex.xMutexAlloc(id); +} + +static sqlite3_mutex sqlite3MutexAlloc(int id){ + if( !sqlite3GlobalConfig.bCoreMutex ){ + return null; + } + Debug.Assert( mutexIsInit !=0 );//assert( GLOBAL(int, mutexIsInit) ); + return sqlite3GlobalConfig.mutex.xMutexAlloc(id); +} + +/* +** Free a dynamic mutex. +*/ +static void sqlite3_mutex_free( sqlite3_mutex p){ + if( p!=null ){ + sqlite3GlobalConfig.mutex.xMutexFree( p); + } +} + +/* +** Obtain the mutex p. If some other thread already has the mutex, block +** until it can be obtained. +*/ +static void sqlite3_mutex_enter(sqlite3_mutex p){ + if( p !=null){ + sqlite3GlobalConfig.mutex.xMutexEnter(p); + } +} + +/* +** Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another +** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY. +*/ +static int sqlite3_mutex_try(sqlite3_mutex p){ + int rc = SQLITE_OK; + if( p!=null ){ + return sqlite3GlobalConfig.mutex.xMutexTry(p); + } + return rc; +} + +/* +** The sqlite3_mutex_leave() routine exits a mutex that was previously +** entered by the same thread. The behavior is undefined if the mutex +** is not currently entered. If a NULL pointer is passed as an argument +** this function is a no-op. +*/ +static void sqlite3_mutex_leave(sqlite3_mutex p){ + if( p !=null){ + sqlite3GlobalConfig.mutex.xMutexLeave(p); + } +} #if !NDEBUG - /* - ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are - ** intended for use inside assert() statements. - */ - static bool sqlite3_mutex_held(sqlite3_mutex p) { - return p == null || sqlite3GlobalConfig.mutex.xMutexHeld(p); - } - - static bool sqlite3_mutex_notheld(sqlite3_mutex p) { - return p == null || sqlite3GlobalConfig.mutex.xMutexNotheld(p); - } +/* +** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are +** intended for use inside assert() statements. +*/ +static bool sqlite3_mutex_held(sqlite3_mutex p){ + return p==null || sqlite3GlobalConfig.mutex.xMutexHeld(p); +} + + static bool sqlite3_mutex_notheld(sqlite3_mutex p){ + return p == null || sqlite3GlobalConfig.mutex.xMutexNotheld( p ); +} #else static bool sqlite3_mutex_held(sqlite3_mutex p) { return true; @@ -171,5 +175,5 @@ static bool sqlite3_mutex_notheld(sqlite3_mutex p) { #endif #endif //* SQLITE_MUTEX_OMIT */ - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/mutex_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/mutex_h.cs index 63f206adb..30318869b 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/mutex_h.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/mutex_h.cs @@ -1,70 +1,72 @@ #define SQLITE_OS_WIN -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2007 August 28 - ** - ** 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 contains the common header for all mutex implementations. - ** The sqliteInt.h header #includes this file so that it is available - ** to all source files. We break it out in an effort to keep the code - ** better organized. - ** - ** NOTE: source files should *not* #include this header file directly. - ** Source files should #include the sqliteInt.h file and let that file - ** include this one indirectly. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-12-07 20:14:09 a586a4deeb25330037a49df295b36aaf624d0f45 - ** - ************************************************************************* - */ +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 2007 August 28 + ** + ** 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 contains the common header for all mutex implementations. + ** The sqliteInt.h header #includes this file so that it is available + ** to all source files. We break it out in an effort to keep the code + ** better organized. + ** + ** NOTE: source files should *not* #include this header file directly. + ** Source files should #include the sqliteInt.h file and let that file + ** include this one indirectly. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-12-07 20:14:09 a586a4deeb25330037a49df295b36aaf624d0f45 + ** + ************************************************************************* + */ - /* - ** Figure out what version of the code to use. The choices are - ** - ** SQLITE_MUTEX_OMIT No mutex logic. Not even stubs. The - ** mutexes implemention cannot be overridden - ** at start-time. - ** - ** SQLITE_MUTEX_NOOP For single-threaded applications. No - ** mutual exclusion is provided. But this - ** implementation can be overridden at - ** start-time. - ** - ** SQLITE_MUTEX_PTHREADS For multi-threaded applications on Unix. - ** - ** SQLITE_MUTEX_W32 For multi-threaded applications on Win32. - ** - ** SQLITE_MUTEX_OS2 For multi-threaded applications on OS/2. - */ + /* + ** Figure out what version of the code to use. The choices are + ** + ** SQLITE_MUTEX_OMIT No mutex logic. Not even stubs. The + ** mutexes implemention cannot be overridden + ** at start-time. + ** + ** SQLITE_MUTEX_NOOP For single-threaded applications. No + ** mutual exclusion is provided. But this + ** implementation can be overridden at + ** start-time. + ** + ** SQLITE_MUTEX_PTHREADS For multi-threaded applications on Unix. + ** + ** SQLITE_MUTEX_W32 For multi-threaded applications on Win32. + ** + ** SQLITE_MUTEX_OS2 For multi-threaded applications on OS/2. + */ - //#if !SQLITE_THREADSAFE - //# define SQLITE_MUTEX_OMIT - //#endif - //#if SQLITE_THREADSAFE && !defined(SQLITE_MUTEX_NOOP) - //# if SQLITE_OS_UNIX - //# define SQLITE_MUTEX_PTHREADS - //# elif SQLITE_OS_WIN - //# define SQLITE_MUTEX_W32 - //# elif SQLITE_OS_OS2 - //# define SQLITE_MUTEX_OS2 - //# else - //# define SQLITE_MUTEX_NOOP - //# endif - //#endif + //#if !SQLITE_THREADSAFE + //# define SQLITE_MUTEX_OMIT + //#endif + //#if SQLITE_THREADSAFE && !defined(SQLITE_MUTEX_NOOP) + //# if SQLITE_OS_UNIX + //# define SQLITE_MUTEX_PTHREADS + //# elif SQLITE_OS_WIN + //# define SQLITE_MUTEX_W32 + //# elif SQLITE_OS_OS2 + //# define SQLITE_MUTEX_OS2 + //# else + //# define SQLITE_MUTEX_NOOP + //# endif + //#endif #if WINDOWS_PHONE && SQLITE_THREADSAFE #error Cannot compile with both WINDOWS_PHONE and SQLITE_THREADSAFE @@ -143,5 +145,5 @@ static void sqlite3MutexEnd() { } //#define sqlite3MutexEnd() #endif //* defined(SQLITE_MUTEX_OMIT) */ - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/mutex_noop_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/mutex_noop_c.cs index bceb47f2a..225a24b28 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/mutex_noop_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/mutex_noop_c.cs @@ -1,42 +1,46 @@ +using System; using System.Diagnostics; - -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2008 October 07 - ** - ** 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 contains the C functions that implement mutexes. - ** - ** This implementation in this file does not provide any mutual - ** exclusion and is thus suitable for use only in applications - ** that use SQLite in a single thread. The routines defined - ** here are place-holders. Applications can substitute working - ** mutex routines at start-time using the - ** - ** sqlite3_config(SQLITE_CONFIG_MUTEX,...) - ** - ** interface. - ** - ** If compiled with SQLITE_DEBUG, then additional logic is inserted - ** that does error checking on mutexes to make sure they are being - ** called correctly. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2009-12-07 16:39:13 1ed88e9d01e9eda5cbc622e7614277f29bcc551c - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +using System.Threading; + +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 2008 October 07 + ** + ** 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 contains the C functions that implement mutexes. + ** + ** This implementation in this file does not provide any mutual + ** exclusion and is thus suitable for use only in applications + ** that use SQLite in a single thread. The routines defined + ** here are place-holders. Applications can substitute working + ** mutex routines at start-time using the + ** + ** sqlite3_config(SQLITE_CONFIG_MUTEX,...) + ** + ** interface. + ** + ** If compiled with SQLITE_DEBUG, then additional logic is inserted + ** that does error checking on mutexes to make sure they are being + ** called correctly. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2009-12-07 16:39:13 1ed88e9d01e9eda5cbc622e7614277f29bcc551c + ** + ************************************************************************* + */ + //#include "sqliteInt.h" #if !SQLITE_DEBUG @@ -78,146 +82,161 @@ sqlite3_mutex_methods sqlite3NoopMutex(){ #endif //* !SQLITE_DEBUG */ #if SQLITE_DEBUG && !SQLITE_MUTEX_OMIT - /* - ** In this implementation, error checking is provided for testing - ** and debugging purposes. The mutexes still do not provide any - ** mutual exclusion. + /* +** In this implementation, error checking is provided for testing +** and debugging purposes. The mutexes still do not provide any +** mutual exclusion. +*/ + + /* + ** The mutex object */ + public class sqlite3_debug_mutex : sqlite3_mutex + { + //public int id; /* The mutex type */ + public int cnt; /* Number of entries without a matching leave */ + }; + + /* + ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are + ** intended for use inside Debug.Assert() statements. + */ + static bool debugMutexHeld( sqlite3_mutex pX ) + { + sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; + return p == null || p.cnt > 0; + } + static bool debugMutexNotheld( sqlite3_mutex pX ) + { + sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; + return p == null || p.cnt == 0; + } - /* - ** The mutex object - */ - public class sqlite3_debug_mutex : sqlite3_mutex { - //public int id; /* The mutex type */ - public int cnt; /* Number of entries without a matching leave */ - }; - - /* - ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are - ** intended for use inside Debug.Assert() statements. - */ - static bool debugMutexHeld(sqlite3_mutex pX) { - sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; - return p == null || p.cnt > 0; - } - static bool debugMutexNotheld(sqlite3_mutex pX) { - sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; - return p == null || p.cnt == 0; - } - - /* - ** Initialize and deinitialize the mutex subsystem. - */ - static int debugMutexInit() { - return SQLITE_OK; - } - static int debugMutexEnd() { - return SQLITE_OK; - } - - /* - ** The sqlite3_mutex_alloc() routine allocates a new - ** mutex and returns a pointer to it. If it returns NULL - ** that means that a mutex could not be allocated. - */ - static sqlite3_mutex debugMutexAlloc(int id) { - sqlite3_debug_mutex[] aStatic = new sqlite3_debug_mutex[6]; - sqlite3_debug_mutex pNew = null; - switch (id) { - case SQLITE_MUTEX_FAST: - case SQLITE_MUTEX_RECURSIVE: { - pNew = new sqlite3_debug_mutex();//sqlite3Malloc(sizeof(*pNew)); - if (pNew != null) { - pNew.id = id; - pNew.cnt = 0; - } - break; - } - default: { - Debug.Assert(id - 2 >= 0); - Debug.Assert(id - 2 < aStatic.Length);//(int)(sizeof(aStatic)/sizeof(aStatic[0])) ); - pNew = aStatic[id - 2]; - pNew.id = id; - break; - } + /* + ** Initialize and deinitialize the mutex subsystem. + */ + static int debugMutexInit() + { + return SQLITE_OK; + } + static int debugMutexEnd() + { + return SQLITE_OK; + } + + /* + ** The sqlite3_mutex_alloc() routine allocates a new + ** mutex and returns a pointer to it. If it returns NULL + ** that means that a mutex could not be allocated. + */ + static sqlite3_mutex debugMutexAlloc( int id ) + { + sqlite3_debug_mutex[] aStatic = new sqlite3_debug_mutex[6]; + sqlite3_debug_mutex pNew = null; + switch ( id ) + { + case SQLITE_MUTEX_FAST: + case SQLITE_MUTEX_RECURSIVE: + { + pNew = new sqlite3_debug_mutex();//sqlite3Malloc(sizeof(*pNew)); + if ( pNew != null ) + { + pNew.id = id; + pNew.cnt = 0; } - return pNew; - } - - /* - ** This routine deallocates a previously allocated mutex. - */ - static void debugMutexFree(sqlite3_mutex pX) { - sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; - Debug.Assert(p.cnt == 0); - Debug.Assert(p.id == SQLITE_MUTEX_FAST || p.id == SQLITE_MUTEX_RECURSIVE); - //sqlite3_free(ref p); - } - - /* - ** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt - ** to enter a mutex. If another thread is already within the mutex, - ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return - ** SQLITE_BUSY. The sqlite3_mutex_try() interface returns SQLITE_OK - ** upon successful entry. Mutexes created using SQLITE_MUTEX_RECURSIVE can - ** be entered multiple times by the same thread. In such cases the, - ** mutex must be exited an equal number of times before another thread - ** can enter. If the same thread tries to enter any other kind of mutex - ** more than once, the behavior is undefined. - */ - static void debugMutexEnter(sqlite3_mutex pX) { - sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; - Debug.Assert(p.id == SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(p)); - p.cnt++; - } - - static int debugMutexTry(sqlite3_mutex pX) { - sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; - Debug.Assert(p.id == SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(p)); - p.cnt++; - return SQLITE_OK; - } - - /* - ** The sqlite3_mutex_leave() routine exits a mutex that was - ** previously entered by the same thread. The behavior - ** is undefined if the mutex is not currently entered or - ** is not currently allocated. SQLite will never do either. - */ - static void debugMutexLeave(sqlite3_mutex pX) { - sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; - Debug.Assert(debugMutexHeld(p)); - p.cnt--; - Debug.Assert(p.id == SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(p)); - } - - static sqlite3_mutex_methods sqlite3NoopMutex() { - sqlite3_mutex_methods sMutex = new sqlite3_mutex_methods( - (dxMutexInit)debugMutexInit, - (dxMutexEnd)debugMutexEnd, - (dxMutexAlloc)debugMutexAlloc, - (dxMutexFree)debugMutexFree, - (dxMutexEnter)debugMutexEnter, - (dxMutexTry)debugMutexTry, - (dxMutexLeave)debugMutexLeave, - - (dxMutexHeld)debugMutexHeld, - (dxMutexNotheld)debugMutexNotheld - ); - - return sMutex; - } -#endif //* SQLITE_DEBUG */ + break; + } + default: + { + Debug.Assert( id - 2 >= 0 ); + Debug.Assert( id - 2 < aStatic.Length );//(int)(sizeof(aStatic)/sizeof(aStatic[0])) ); + pNew = aStatic[id - 2]; + pNew.id = id; + break; + } + } + return pNew; + } - /* - ** If compiled with SQLITE_MUTEX_NOOP, then the no-op mutex implementation - ** is used regardless of the run-time threadsafety setting. + /* + ** This routine deallocates a previously allocated mutex. */ + static void debugMutexFree( sqlite3_mutex pX ) + { + sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; + Debug.Assert( p.cnt == 0 ); + Debug.Assert( p.id == SQLITE_MUTEX_FAST || p.id == SQLITE_MUTEX_RECURSIVE ); + //sqlite3_free(ref p); + } + + /* + ** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt + ** to enter a mutex. If another thread is already within the mutex, + ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return + ** SQLITE_BUSY. The sqlite3_mutex_try() interface returns SQLITE_OK + ** upon successful entry. Mutexes created using SQLITE_MUTEX_RECURSIVE can + ** be entered multiple times by the same thread. In such cases the, + ** mutex must be exited an equal number of times before another thread + ** can enter. If the same thread tries to enter any other kind of mutex + ** more than once, the behavior is undefined. + */ + static void debugMutexEnter( sqlite3_mutex pX ) + { + sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; + Debug.Assert( p.id == SQLITE_MUTEX_RECURSIVE || debugMutexNotheld( p ) ); + p.cnt++; + } + + static int debugMutexTry( sqlite3_mutex pX ) + { + sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; + Debug.Assert( p.id == SQLITE_MUTEX_RECURSIVE || debugMutexNotheld( p ) ); + p.cnt++; + return SQLITE_OK; + } + + /* + ** The sqlite3_mutex_leave() routine exits a mutex that was + ** previously entered by the same thread. The behavior + ** is undefined if the mutex is not currently entered or + ** is not currently allocated. SQLite will never do either. + */ + static void debugMutexLeave( sqlite3_mutex pX ) + { + sqlite3_debug_mutex p = (sqlite3_debug_mutex)pX; + Debug.Assert( debugMutexHeld( p ) ); + p.cnt--; + Debug.Assert( p.id == SQLITE_MUTEX_RECURSIVE || debugMutexNotheld( p ) ); + } + + static sqlite3_mutex_methods sqlite3NoopMutex() + { + sqlite3_mutex_methods sMutex = new sqlite3_mutex_methods( + (dxMutexInit)debugMutexInit, + (dxMutexEnd)debugMutexEnd, + (dxMutexAlloc)debugMutexAlloc, + (dxMutexFree)debugMutexFree, + (dxMutexEnter)debugMutexEnter, + (dxMutexTry)debugMutexTry, + (dxMutexLeave)debugMutexLeave, + + (dxMutexHeld)debugMutexHeld, + (dxMutexNotheld)debugMutexNotheld + ); + + return sMutex; + } +#endif //* SQLITE_DEBUG */ + + /* +** If compiled with SQLITE_MUTEX_NOOP, then the no-op mutex implementation +** is used regardless of the run-time threadsafety setting. +*/ #if SQLITE_MUTEX_NOOP sqlite3_mutex_methods const sqlite3DefaultMutex(void){ return sqlite3NoopMutex(); } #endif //* SQLITE_MUTEX_NOOP */ - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/mutex_w32.cs b/src/extensions/IronPython.SQLite/c#sqlite/mutex_w32.cs index 96dce6757..16d114d3c 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/mutex_w32.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/mutex_w32.cs @@ -1,96 +1,100 @@ -using System; using System.Diagnostics; -using System.Threading; - using DWORD = System.Int32; +using System.Threading; +using System; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2007 August 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 file contains the C functions that implement mutexes for win32 - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-03-09 19:31:43 4ae453ea7be69018d8c16eb8dabe05617397dc4d - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 2007 August 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 file contains the C functions that implement mutexes for win32 + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-03-09 19:31:43 4ae453ea7be69018d8c16eb8dabe05617397dc4d + ** + ************************************************************************* + */ + //#include "sqliteInt.h" - /* - ** The code in this file is only used if we are compiling multithreaded - ** on a win32 system. - */ + /* + ** The code in this file is only used if we are compiling multithreaded + ** on a win32 system. + */ #if SQLITE_MUTEX_W32 - /* - ** Each recursive mutex is an instance of the following structure. - */ - public partial class sqlite3_mutex { - public Object mutex; /* Mutex controlling the lock */ - public int id; /* Mutex type */ - public int nRef; /* Number of enterances */ - public DWORD owner; /* Thread holding this mutex */ + /* +** Each recursive mutex is an instance of the following structure. +*/ + public partial class sqlite3_mutex + { + public Object mutex; /* Mutex controlling the lock */ + public int id; /* Mutex type */ + public int nRef; /* Number of enterances */ + public DWORD owner; /* Thread holding this mutex */ #if SQLITE_DEBUG - public int trace; /* True to trace changes */ + public int trace; /* True to trace changes */ #endif - public sqlite3_mutex() { - mutex = new Object(); - } + public sqlite3_mutex() + { + mutex = new Object(); + } - public sqlite3_mutex(Mutex mutex, int id, int nRef, DWORD owner + public sqlite3_mutex( Mutex mutex, int id, int nRef, DWORD owner #if SQLITE_DEBUG - , int trace +, int trace #endif - ) { - this.mutex = mutex; - this.id = id; - this.nRef = nRef; - this.owner = owner; + ) + { + this.mutex = mutex; + this.id = id; + this.nRef = nRef; + this.owner = owner; #if SQLITE_DEBUG - this.trace = 0; + this.trace = 0; #endif - } - }; + } + }; - //#define SQLITE_W32_MUTEX_INITIALIZER { 0 } - static Mutex SQLITE_W32_MUTEX_INITIALIZER = null; + //#define SQLITE_W32_MUTEX_INITIALIZER { 0 } + static Mutex SQLITE_W32_MUTEX_INITIALIZER = null; #if SQLITE_DEBUG - //#define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER, 0, 0L, (DWORD)0, 0 } + //#define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER, 0, 0L, (DWORD)0, 0 } #else //#define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER, 0, 0L, (DWORD)0 } #endif - /* - ** Return true (non-zero) if we are running under WinNT, Win2K, WinXP, - ** or WinCE. Return false (zero) for Win95, Win98, or WinME. - ** - ** Here is an interesting observation: Win95, Win98, and WinME lack - ** the LockFileEx() API. But we can still statically link against that - ** API as long as we don't call it win 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. - ** - ** mutexIsNT() is only used for the TryEnterCriticalSection() API call, - ** which is only available if your application was compiled with - ** _WIN32_WINNT defined to a value >= 0x0400. Currently, the only - ** call to TryEnterCriticalSection() is #ifdef'ed out, so #if - ** this out as well. - */ + /* +** Return true (non-zero) if we are running under WinNT, Win2K, WinXP, +** or WinCE. Return false (zero) for Win95, Win98, or WinME. +** +** Here is an interesting observation: Win95, Win98, and WinME lack +** the LockFileEx() API. But we can still statically link against that +** API as long as we don't call it win 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. +** +** mutexIsNT() is only used for the TryEnterCriticalSection() API call, +** which is only available if your application was compiled with +** _WIN32_WINNT defined to a value >= 0x0400. Currently, the only +** call to TryEnterCriticalSection() is #ifdef'ed out, so #if +** this out as well. +*/ #if FALSE #if SQLITE_OS_WINCE //# define mutexIsNT() (1) @@ -109,28 +113,31 @@ static int mutexIsNT(void){ #endif #if SQLITE_DEBUG - /* - ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are - ** intended for use only inside Debug.Assert() statements. - */ - static bool winMutexHeld(sqlite3_mutex p) { - return p.nRef != 0 && p.owner == GetCurrentThreadId(); - } - static bool winMutexNotheld2(sqlite3_mutex p, DWORD tid) { - return p.nRef == 0 || p.owner != tid; - } - static bool winMutexNotheld(sqlite3_mutex p) { - DWORD tid = GetCurrentThreadId(); - return winMutexNotheld2(p, tid); - } + /* +** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are +** intended for use only inside Debug.Assert() statements. +*/ + static bool winMutexHeld( sqlite3_mutex p ) + { + return p.nRef != 0 && p.owner == GetCurrentThreadId(); + } + static bool winMutexNotheld2( sqlite3_mutex p, DWORD tid ) + { + return p.nRef == 0 || p.owner != tid; + } + static bool winMutexNotheld( sqlite3_mutex p ) + { + DWORD tid = GetCurrentThreadId(); + return winMutexNotheld2( p, tid ); + } #endif - /* - ** Initialize and deinitialize the mutex subsystem. - */ - //No MACROS under C#; Cannot use SQLITE3_MUTEX_INITIALIZER, - static sqlite3_mutex[] winMutex_staticMutexes = new sqlite3_mutex[]{ + /* +** Initialize and deinitialize the mutex subsystem. +*/ + //No MACROS under C#; Cannot use SQLITE3_MUTEX_INITIALIZER, + static sqlite3_mutex[] winMutex_staticMutexes = new sqlite3_mutex[]{ new sqlite3_mutex( SQLITE_W32_MUTEX_INITIALIZER, 0, 0, (DWORD)0 #if SQLITE_DEBUG , 0 @@ -162,175 +169,190 @@ static bool winMutexNotheld(sqlite3_mutex p) { #endif ),// SQLITE3_MUTEX_INITIALIZER, }; - static int winMutex_isInit = 0; - /* As winMutexInit() and winMutexEnd() are called as part - ** of the sqlite3_initialize and sqlite3_shutdown() - ** processing, the "interlocked" magic is probably not - ** strictly necessary. - */ - static long winMutex_lock = 0; + static int winMutex_isInit = 0; + /* As winMutexInit() and winMutexEnd() are called as part + ** of the sqlite3_initialize and sqlite3_shutdown() + ** processing, the "interlocked" magic is probably not + ** strictly necessary. + */ + static long winMutex_lock = 0; - private static System.Object lockThis = new System.Object(); - static int winMutexInit() { - /* The first to increment to 1 does actual initialization */ + private static System.Object lockThis = new System.Object(); + static int winMutexInit() + { + /* The first to increment to 1 does actual initialization */ - lock (lockThis) - //if ( Interlocked.CompareExchange(ref winMutex_lock, 1, 0 ) == 0 ) - { - int i; - for (i = 0; i < ArraySize(winMutex_staticMutexes); i++) { - if (winMutex_staticMutexes[i].mutex == null) winMutex_staticMutexes[i].mutex = new Mutex(); - //InitializeCriticalSection( winMutex_staticMutexes[i].mutex ); - } - winMutex_isInit = 1; - } - //else - //{ - // /* Someone else is in the process of initing the static mutexes */ - // while ( 0 == winMutex_isInit ) - // { - // Thread.Sleep( 1 ); - // } - //} - return SQLITE_OK; + lock ( lockThis ) + //if ( Interlocked.CompareExchange(ref winMutex_lock, 1, 0 ) == 0 ) + { + int i; + for ( i = 0; i < ArraySize( winMutex_staticMutexes ); i++ ) + { + if (winMutex_staticMutexes[i].mutex== null) winMutex_staticMutexes[i].mutex = new Mutex(); + //InitializeCriticalSection( winMutex_staticMutexes[i].mutex ); } + winMutex_isInit = 1; + } + //else + //{ + // /* Someone else is in the process of initing the static mutexes */ + // while ( 0 == winMutex_isInit ) + // { + // Thread.Sleep( 1 ); + // } + //} + return SQLITE_OK; + } - static int winMutexEnd() { - /* The first to decrement to 0 does actual shutdown - ** (which should be the last to shutdown.) */ - if (Interlocked.CompareExchange(ref winMutex_lock, 0, 1) == 1) { - if (winMutex_isInit == 1) { - int i; - for (i = 0; i < ArraySize(winMutex_staticMutexes); i++) { - DeleteCriticalSection(winMutex_staticMutexes[i].mutex); - } - winMutex_isInit = 0; - } - } - return SQLITE_OK; + static int winMutexEnd() + { + /* The first to decrement to 0 does actual shutdown + ** (which should be the last to shutdown.) */ + if ( Interlocked.CompareExchange( ref winMutex_lock, 0, 1 ) == 1 ) + { + if ( winMutex_isInit == 1 ) + { + int i; + for ( i = 0; i < ArraySize( winMutex_staticMutexes ); i++ ) + { + DeleteCriticalSection( winMutex_staticMutexes[i].mutex ); + } + winMutex_isInit = 0; } + } + return SQLITE_OK; + } - /* - ** The sqlite3_mutex_alloc() routine allocates a new - ** mutex and returns a pointer to it. If it returns NULL - ** that means that a mutex could not be allocated. SQLite - ** will unwind its stack and return an error. The argument - ** to sqlite3_mutex_alloc() is one of these integer constants: - ** - **
    - **
  • SQLITE_MUTEX_FAST - **
  • SQLITE_MUTEX_RECURSIVE - **
  • SQLITE_MUTEX_STATIC_MASTER - **
  • SQLITE_MUTEX_STATIC_MEM - **
  • SQLITE_MUTEX_STATIC_MEM2 - **
  • SQLITE_MUTEX_STATIC_PRNG - **
  • SQLITE_MUTEX_STATIC_LRU - **
  • SQLITE_MUTEX_STATIC_LRU2 - **
- ** - ** The first two constants cause sqlite3_mutex_alloc() to create - ** a new mutex. The new mutex is recursive when SQLITE_MUTEX_RECURSIVE - ** is used but not necessarily so when SQLITE_MUTEX_FAST is used. - ** The mutex implementation does not need to make a distinction - ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does - ** not want to. But SQLite will only request a recursive mutex in - ** cases where it really needs one. If a faster non-recursive mutex - ** implementation is available on the host platform, the mutex subsystem - ** might return such a mutex in response to SQLITE_MUTEX_FAST. - ** - ** The other allowed parameters to sqlite3_mutex_alloc() each return - ** a pointer to a static preexisting mutex. Six static mutexes are - ** used by the current version of SQLite. Future versions of SQLite - ** may add additional static mutexes. Static mutexes are for internal - ** use by SQLite only. Applications that use SQLite mutexes should - ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or - ** SQLITE_MUTEX_RECURSIVE. - ** - ** Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST - ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() - ** returns a different mutex on every call. But for the static - ** mutex types, the same mutex is returned on every call that has - ** the same type number. - */ - static sqlite3_mutex winMutexAlloc(int iType) { - sqlite3_mutex p; + /* + ** The sqlite3_mutex_alloc() routine allocates a new + ** mutex and returns a pointer to it. If it returns NULL + ** that means that a mutex could not be allocated. SQLite + ** will unwind its stack and return an error. The argument + ** to sqlite3_mutex_alloc() is one of these integer constants: + ** + **
    + **
  • SQLITE_MUTEX_FAST + **
  • SQLITE_MUTEX_RECURSIVE + **
  • SQLITE_MUTEX_STATIC_MASTER + **
  • SQLITE_MUTEX_STATIC_MEM + **
  • SQLITE_MUTEX_STATIC_MEM2 + **
  • SQLITE_MUTEX_STATIC_PRNG + **
  • SQLITE_MUTEX_STATIC_LRU + **
  • SQLITE_MUTEX_STATIC_LRU2 + **
+ ** + ** The first two constants cause sqlite3_mutex_alloc() to create + ** a new mutex. The new mutex is recursive when SQLITE_MUTEX_RECURSIVE + ** is used but not necessarily so when SQLITE_MUTEX_FAST is used. + ** The mutex implementation does not need to make a distinction + ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does + ** not want to. But SQLite will only request a recursive mutex in + ** cases where it really needs one. If a faster non-recursive mutex + ** implementation is available on the host platform, the mutex subsystem + ** might return such a mutex in response to SQLITE_MUTEX_FAST. + ** + ** The other allowed parameters to sqlite3_mutex_alloc() each return + ** a pointer to a static preexisting mutex. Six static mutexes are + ** used by the current version of SQLite. Future versions of SQLite + ** may add additional static mutexes. Static mutexes are for internal + ** use by SQLite only. Applications that use SQLite mutexes should + ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or + ** SQLITE_MUTEX_RECURSIVE. + ** + ** Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST + ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() + ** returns a different mutex on every call. But for the static + ** mutex types, the same mutex is returned on every call that has + ** the same type number. + */ + static sqlite3_mutex winMutexAlloc( int iType ) + { + sqlite3_mutex p; - switch (iType) { - case SQLITE_MUTEX_FAST: - case SQLITE_MUTEX_RECURSIVE: { - p = new sqlite3_mutex();//sqlite3MallocZero( sizeof(*p) ); - if (p != null) { - p.id = iType; - InitializeCriticalSection(p.mutex); - } - break; - } - default: { - Debug.Assert(winMutex_isInit == 1); - Debug.Assert(iType - 2 >= 0); - Debug.Assert(iType - 2 < ArraySize(winMutex_staticMutexes)); - p = winMutex_staticMutexes[iType - 2]; - p.id = iType; - break; - } + switch ( iType ) + { + case SQLITE_MUTEX_FAST: + case SQLITE_MUTEX_RECURSIVE: + { + p = new sqlite3_mutex();//sqlite3MallocZero( sizeof(*p) ); + if ( p != null ) + { + p.id = iType; + InitializeCriticalSection( p.mutex ); } - return p; - } + break; + } + default: + { + Debug.Assert( winMutex_isInit == 1 ); + Debug.Assert( iType - 2 >= 0 ); + Debug.Assert( iType - 2 < ArraySize( winMutex_staticMutexes ) ); + p = winMutex_staticMutexes[iType - 2]; + p.id = iType; + break; + } + } + return p; + } - /* - ** This routine deallocates a previously - ** allocated mutex. SQLite is careful to deallocate every - ** mutex that it allocates. - */ - static void winMutexFree(sqlite3_mutex p) { - Debug.Assert(p != null); - Debug.Assert(p.nRef == 0); - Debug.Assert(p.id == SQLITE_MUTEX_FAST || p.id == SQLITE_MUTEX_RECURSIVE); - DeleteCriticalSection(p.mutex); - p.owner = 0; - //sqlite3_free( p ); - } + /* + ** This routine deallocates a previously + ** allocated mutex. SQLite is careful to deallocate every + ** mutex that it allocates. + */ + static void winMutexFree( sqlite3_mutex p ) + { + Debug.Assert( p != null ); + Debug.Assert( p.nRef == 0 ); + Debug.Assert( p.id == SQLITE_MUTEX_FAST || p.id == SQLITE_MUTEX_RECURSIVE ); + DeleteCriticalSection( p.mutex ); + p.owner = 0; + //sqlite3_free( p ); + } - /* - ** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt - ** to enter a mutex. If another thread is already within the mutex, - ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return - ** SQLITE_BUSY. The sqlite3_mutex_try() interface returns SQLITE_OK - ** upon successful entry. Mutexes created using SQLITE_MUTEX_RECURSIVE can - ** be entered multiple times by the same thread. In such cases the, - ** mutex must be exited an equal number of times before another thread - ** can enter. If the same thread tries to enter any other kind of mutex - ** more than once, the behavior is undefined. - */ - static void winMutexEnter(sqlite3_mutex p) { - DWORD tid = GetCurrentThreadId(); - Debug.Assert(p.id == SQLITE_MUTEX_RECURSIVE || winMutexNotheld2(p, tid)); - EnterCriticalSection(p.mutex); - p.owner = tid; - p.nRef++; + /* + ** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt + ** to enter a mutex. If another thread is already within the mutex, + ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return + ** SQLITE_BUSY. The sqlite3_mutex_try() interface returns SQLITE_OK + ** upon successful entry. Mutexes created using SQLITE_MUTEX_RECURSIVE can + ** be entered multiple times by the same thread. In such cases the, + ** mutex must be exited an equal number of times before another thread + ** can enter. If the same thread tries to enter any other kind of mutex + ** more than once, the behavior is undefined. + */ + static void winMutexEnter( sqlite3_mutex p ) + { + DWORD tid = GetCurrentThreadId(); + Debug.Assert( p.id == SQLITE_MUTEX_RECURSIVE || winMutexNotheld2( p, tid ) ); + EnterCriticalSection( p.mutex ); + p.owner = tid; + p.nRef++; #if SQLITE_DEBUG - if (p.trace != 0) { - printf("enter mutex {0} ({1}) with nRef={2}\n", p.GetHashCode(), p.owner, p.nRef); - } + if ( p.trace != 0 ) + { + printf( "enter mutex {0} ({1}) with nRef={2}\n", p.GetHashCode(), p.owner, p.nRef ); + } #endif - } + } - static int winMutexTry(sqlite3_mutex p) { - DWORD tid = GetCurrentThreadId(); - int rc = SQLITE_BUSY; - Debug.Assert(p.id == SQLITE_MUTEX_RECURSIVE || winMutexNotheld2(p, tid)); - /* - ** The sqlite3_mutex_try() routine is very rarely used, and when it - ** is used it is merely an optimization. So it is OK for it to always - ** fail. - ** - ** The TryEnterCriticalSection() interface is only available on WinNT. - ** And some windows compilers complain if you try to use it without - ** first doing some #defines that prevent SQLite from building on Win98. - ** For that reason, we will omit this optimization for now. See - ** ticket #2685. - */ + static int winMutexTry( sqlite3_mutex p ) + { + DWORD tid = GetCurrentThreadId(); + int rc = SQLITE_BUSY; + Debug.Assert( p.id == SQLITE_MUTEX_RECURSIVE || winMutexNotheld2( p, tid ) ); + /* + ** The sqlite3_mutex_try() routine is very rarely used, and when it + ** is used it is merely an optimization. So it is OK for it to always + ** fail. + ** + ** The TryEnterCriticalSection() interface is only available on WinNT. + ** And some windows compilers complain if you try to use it without + ** first doing some #defines that prevent SQLite from building on Win98. + ** For that reason, we will omit this optimization for now. See + ** ticket #2685. + */ #if FALSE if( mutexIsNT() && TryEnterCriticalSection(p.mutex) ){ p.owner = tid; @@ -338,58 +360,62 @@ static int winMutexTry(sqlite3_mutex p) { rc = SQLITE_OK; } #else - UNUSED_PARAMETER(p); + UNUSED_PARAMETER( p ); #endif #if SQLITE_DEBUG - if (rc == SQLITE_OK && p.trace != 0) { - printf("try mutex {0} ({1}) with nRef={2}\n", p.GetHashCode(), p.owner, p.nRef); - } + if ( rc == SQLITE_OK && p.trace != 0 ) + { + printf( "try mutex {0} ({1}) with nRef={2}\n", p.GetHashCode(), p.owner, p.nRef ); + } #endif - return rc; - } + return rc; + } - /* - ** The sqlite3_mutex_leave() routine exits a mutex that was - ** previously entered by the same thread. The behavior - ** is undefined if the mutex is not currently entered or - ** is not currently allocated. SQLite will never do either. - */ - static void winMutexLeave(sqlite3_mutex p) { - DWORD tid = GetCurrentThreadId(); - Debug.Assert(p.nRef > 0); - Debug.Assert(p.owner == tid); - p.nRef--; - Debug.Assert(p.nRef == 0 || p.id == SQLITE_MUTEX_RECURSIVE); - if (p.nRef == 0) p.owner = 0; - LeaveCriticalSection(p.mutex); + /* + ** The sqlite3_mutex_leave() routine exits a mutex that was + ** previously entered by the same thread. The behavior + ** is undefined if the mutex is not currently entered or + ** is not currently allocated. SQLite will never do either. + */ + static void winMutexLeave( sqlite3_mutex p ) + { + DWORD tid = GetCurrentThreadId(); + Debug.Assert( p.nRef > 0 ); + Debug.Assert( p.owner == tid ); + p.nRef--; + Debug.Assert( p.nRef == 0 || p.id == SQLITE_MUTEX_RECURSIVE ); + if ( p.nRef == 0 ) p.owner = 0; + LeaveCriticalSection( p.mutex ); #if SQLITE_DEBUG - if (p.trace != 0) { - printf("leave mutex {0} ({1}) with nRef={2}\n", p.GetHashCode(), p.owner, p.nRef); - } + if ( p.trace != 0 ) + { + printf( "leave mutex {0} ({1}) with nRef={2}\n", p.GetHashCode(), p.owner, p.nRef ); + } #endif - } + } - static sqlite3_mutex_methods sqlite3DefaultMutex() { - sqlite3_mutex_methods sMutex = new sqlite3_mutex_methods( - (dxMutexInit)winMutexInit, - (dxMutexEnd)winMutexEnd, - (dxMutexAlloc)winMutexAlloc, - (dxMutexFree)winMutexFree, - (dxMutexEnter)winMutexEnter, - (dxMutexTry)winMutexTry, - (dxMutexLeave)winMutexLeave, + static sqlite3_mutex_methods sqlite3DefaultMutex() + { + sqlite3_mutex_methods sMutex = new sqlite3_mutex_methods ( +(dxMutexInit)winMutexInit, +(dxMutexEnd)winMutexEnd, +(dxMutexAlloc)winMutexAlloc, +(dxMutexFree)winMutexFree, +(dxMutexEnter)winMutexEnter, +(dxMutexTry)winMutexTry, +(dxMutexLeave)winMutexLeave, #if SQLITE_DEBUG - (dxMutexHeld)winMutexHeld, - (dxMutexNotheld)winMutexNotheld +(dxMutexHeld)winMutexHeld, +(dxMutexNotheld)winMutexNotheld #else null, null #endif - ); +); - return sMutex; - } -#endif // * SQLITE_MUTEX_W32 */ + return sMutex; } +#endif // * SQLITE_MUTEX_W32 */ + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/notify_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/notify_c.cs index 6eabfc6d4..983341169 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/notify_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/notify_c.cs @@ -1,31 +1,35 @@ -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2009 March 3 - ** - ** 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 contains the implementation of the sqlite3_unlock_notify() - ** API method and its associated functionality. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2009-12-07 16:39:13 1ed88e9d01e9eda5cbc622e7614277f29bcc551c - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include "btreeInt.h" +using System.Diagnostics; - /* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */ +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 2009 March 3 + ** + ** 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 contains the implementation of the sqlite3_unlock_notify() + ** API method and its associated functionality. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2009-12-07 16:39:13 1ed88e9d01e9eda5cbc622e7614277f29bcc551c + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include "btreeInt.h" + + /* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */ #if SQLITE_ENABLE_UNLOCK_NOTIFY /* @@ -338,5 +342,5 @@ void sqlite3ConnectionClosed(sqlite3 *db){ leaveMutex(); } #endif - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/opcodes_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/opcodes_c.cs index 73484e952..593f10853 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/opcodes_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/opcodes_c.cs @@ -7,13 +7,16 @@ ** ************************************************************************* */ -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* Automatically generated. Do not edit */ - /* See the mkopcodec.awk script for details. */ +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* Automatically generated. Do not edit */ + /* See the mkopcodec.awk script for details. */ #if !SQLITE_OMIT_EXPLAIN || !NDEBUG || VDBE_PROFILE || SQLITE_DEBUG - static string sqlite3OpcodeName(int i) { - string[] azName = { "?", + static string sqlite3OpcodeName( int i ) + { + string[] azName = { "?", /* 1 */ "Goto", /* 2 */ "Gosub", /* 3 */ "Return", @@ -160,8 +163,8 @@ static string sqlite3OpcodeName(int i) { /* 144 */ "ToInt", /* 145 */ "ToReal", }; - return azName[i]; - } -#endif + return azName[i]; } +#endif + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/opcodes_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/opcodes_h.cs index aeb7c4a24..a723c6124 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/opcodes_h.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/opcodes_h.cs @@ -1,327 +1,329 @@ -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* Automatically generated. Do not edit */ - /* See the mkopcodeh.awk script for details */ - /* Automatically generated. Do not edit */ - /* See the mkopcodeh.awk script for details */ - //#define OP_Goto 1 - //#define OP_Gosub 2 - //#define OP_Return 3 - //#define OP_Yield 4 - //#define OP_HaltIfNull 5 - //#define OP_Halt 6 - //#define OP_Integer 7 - //#define OP_Int64 8 - //#define OP_Real 130 /* same as TK_FLOAT */ - //#define OP_String8 94 /* same as TK_STRING */ - //#define OP_String 9 - //#define OP_Null 10 - //#define OP_Blob 11 - //#define OP_Variable 12 - //#define OP_Move 13 - //#define OP_Copy 14 - //#define OP_SCopy 15 - //#define OP_ResultRow 16 - //#define OP_Concat 91 /* same as TK_CONCAT */ - //#define OP_Add 86 /* same as TK_PLUS */ - //#define OP_Subtract 87 /* same as TK_MINUS */ - //#define OP_Multiply 88 /* same as TK_STAR */ - //#define OP_Divide 89 /* same as TK_SLASH */ - //#define OP_Remainder 90 /* same as TK_REM */ - //#define OP_CollSeq 17 - //#define OP_Function 18 - //#define OP_BitAnd 82 /* same as TK_BITAND */ - //#define OP_BitOr 83 /* same as TK_BITOR */ - //#define OP_ShiftLeft 84 /* same as TK_LSHIFT */ - //#define OP_ShiftRight 85 /* same as TK_RSHIFT */ - //#define OP_AddImm 20 - //#define OP_MustBeInt 21 - //#define OP_RealAffinity 22 - //#define OP_ToText 141 /* same as TK_TO_TEXT */ - //#define OP_ToBlob 142 /* same as TK_TO_BLOB */ - //#define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/ - //#define OP_ToInt 144 /* same as TK_TO_INT */ - //#define OP_ToReal 145 /* same as TK_TO_REAL */ - //#define OP_Eq 76 /* same as TK_EQ */ - //#define OP_Ne 75 /* same as TK_NE */ - //#define OP_Lt 79 /* same as TK_LT */ - //#define OP_Le 78 /* same as TK_LE */ - //#define OP_Gt 77 /* same as TK_GT */ - //#define OP_Ge 80 /* same as TK_GE */ - //#define OP_Permutation 23 - //#define OP_Compare 24 - //#define OP_Jump 25 - //#define OP_And 69 /* same as TK_AND */ - //#define OP_Or 68 /* same as TK_OR */ - //#define OP_Not 19 /* same as TK_NOT */ - //#define OP_BitNot 93 /* same as TK_BITNOT */ - //#define OP_If 26 - //#define OP_IfNot 27 - //#define OP_IsNull 73 /* same as TK_ISNULL */ - //#define OP_NotNull 74 /* same as TK_NOTNULL */ - //#define OP_Column 28 - //#define OP_Affinity 29 - //#define OP_MakeRecord 30 - //#define OP_Count 31 - //#define OP_Savepoint 32 - //#define OP_AutoCommit 33 - //#define OP_Transaction 34 - //#define OP_ReadCookie 35 - //#define OP_SetCookie 36 - //#define OP_VerifyCookie 37 - //#define OP_OpenRead 38 - //#define OP_OpenWrite 39 - //#define OP_OpenAutoindex 40 - //#define OP_OpenEphemeral 41 - //#define OP_OpenPseudo 42 - //#define OP_Close 43 - //#define OP_SeekLt 44 - //#define OP_SeekLe 45 - //#define OP_SeekGe 46 - //#define OP_SeekGt 47 - //#define OP_Seek 48 - //#define OP_NotFound 49 - //#define OP_Found 50 - //#define OP_IsUnique 51 - //#define OP_NotExists 52 - //#define OP_Sequence 53 - //#define OP_NewRowid 54 - //#define OP_Insert 55 - //#define OP_InsertInt 56 - //#define OP_Delete 57 - //#define OP_ResetCount 58 - //#define OP_RowKey 59 - //#define OP_RowData 60 - //#define OP_Rowid 61 - //#define OP_NullRow 62 - //#define OP_Last 63 - //#define OP_Sort 64 - //#define OP_Rewind 65 - //#define OP_Prev 66 - //#define OP_Next 67 - //#define OP_IdxInsert 70 - //#define OP_IdxDelete 71 - //#define OP_IdxRowid 72 - //#define OP_IdxLT 81 - //#define OP_IdxGE 92 - //#define OP_Destroy 95 - //#define OP_Clear 96 - //#define OP_CreateIndex 97 - //#define OP_CreateTable 98 - //#define OP_ParseSchema 99 - //#define OP_LoadAnalysis 100 - //#define OP_DropTable 101 - //#define OP_DropIndex 102 - //#define OP_DropTrigger 103 - //#define OP_IntegrityCk 104 - //#define OP_RowSetAdd 105 - //#define OP_RowSetRead 106 - //#define OP_RowSetTest 107 - //#define OP_Program 108 - //#define OP_Param 109 - //#define OP_FkCounter 110 - //#define OP_FkIfZero 111 - //#define OP_MemMax 112 - //#define OP_IfPos 113 - //#define OP_IfNeg 114 - //#define OP_IfZero 115 - //#define OP_AggStep 116 - //#define OP_AggFinal 117 - //#define OP_Checkpoint 118 - //#define OP_JournalMode 119 - //#define OP_Vacuum 120 - //#define OP_IncrVacuum 121 - //#define OP_Expire 122 - //#define OP_TableLock 123 - //#define OP_VBegin 124 - //#define OP_VCreate 125 - //#define OP_VDestroy 126 - //#define OP_VOpen 127 - //#define OP_VFilter 128 - //#define OP_VColumn 129 - //#define OP_VNext 131 - //#define OP_VRename 132 - //#define OP_VUpdate 133 - //#define OP_Pagecount 134 - //#define OP_MaxPgcnt 135 - //#define OP_Trace 136 - //#define OP_Noop 137 - //#define OP_Explain 138 +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* Automatically generated. Do not edit */ + /* See the mkopcodeh.awk script for details */ + /* Automatically generated. Do not edit */ + /* See the mkopcodeh.awk script for details */ + //#define OP_Goto 1 + //#define OP_Gosub 2 + //#define OP_Return 3 + //#define OP_Yield 4 + //#define OP_HaltIfNull 5 + //#define OP_Halt 6 + //#define OP_Integer 7 + //#define OP_Int64 8 + //#define OP_Real 130 /* same as TK_FLOAT */ + //#define OP_String8 94 /* same as TK_STRING */ + //#define OP_String 9 + //#define OP_Null 10 + //#define OP_Blob 11 + //#define OP_Variable 12 + //#define OP_Move 13 + //#define OP_Copy 14 + //#define OP_SCopy 15 + //#define OP_ResultRow 16 + //#define OP_Concat 91 /* same as TK_CONCAT */ + //#define OP_Add 86 /* same as TK_PLUS */ + //#define OP_Subtract 87 /* same as TK_MINUS */ + //#define OP_Multiply 88 /* same as TK_STAR */ + //#define OP_Divide 89 /* same as TK_SLASH */ + //#define OP_Remainder 90 /* same as TK_REM */ + //#define OP_CollSeq 17 + //#define OP_Function 18 + //#define OP_BitAnd 82 /* same as TK_BITAND */ + //#define OP_BitOr 83 /* same as TK_BITOR */ + //#define OP_ShiftLeft 84 /* same as TK_LSHIFT */ + //#define OP_ShiftRight 85 /* same as TK_RSHIFT */ + //#define OP_AddImm 20 + //#define OP_MustBeInt 21 + //#define OP_RealAffinity 22 + //#define OP_ToText 141 /* same as TK_TO_TEXT */ + //#define OP_ToBlob 142 /* same as TK_TO_BLOB */ + //#define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/ + //#define OP_ToInt 144 /* same as TK_TO_INT */ + //#define OP_ToReal 145 /* same as TK_TO_REAL */ + //#define OP_Eq 76 /* same as TK_EQ */ + //#define OP_Ne 75 /* same as TK_NE */ + //#define OP_Lt 79 /* same as TK_LT */ + //#define OP_Le 78 /* same as TK_LE */ + //#define OP_Gt 77 /* same as TK_GT */ + //#define OP_Ge 80 /* same as TK_GE */ + //#define OP_Permutation 23 + //#define OP_Compare 24 + //#define OP_Jump 25 + //#define OP_And 69 /* same as TK_AND */ + //#define OP_Or 68 /* same as TK_OR */ + //#define OP_Not 19 /* same as TK_NOT */ + //#define OP_BitNot 93 /* same as TK_BITNOT */ + //#define OP_If 26 + //#define OP_IfNot 27 + //#define OP_IsNull 73 /* same as TK_ISNULL */ + //#define OP_NotNull 74 /* same as TK_NOTNULL */ + //#define OP_Column 28 + //#define OP_Affinity 29 + //#define OP_MakeRecord 30 + //#define OP_Count 31 + //#define OP_Savepoint 32 + //#define OP_AutoCommit 33 + //#define OP_Transaction 34 + //#define OP_ReadCookie 35 + //#define OP_SetCookie 36 + //#define OP_VerifyCookie 37 + //#define OP_OpenRead 38 + //#define OP_OpenWrite 39 + //#define OP_OpenAutoindex 40 + //#define OP_OpenEphemeral 41 + //#define OP_OpenPseudo 42 + //#define OP_Close 43 + //#define OP_SeekLt 44 + //#define OP_SeekLe 45 + //#define OP_SeekGe 46 + //#define OP_SeekGt 47 + //#define OP_Seek 48 + //#define OP_NotFound 49 + //#define OP_Found 50 + //#define OP_IsUnique 51 + //#define OP_NotExists 52 + //#define OP_Sequence 53 + //#define OP_NewRowid 54 + //#define OP_Insert 55 + //#define OP_InsertInt 56 + //#define OP_Delete 57 + //#define OP_ResetCount 58 + //#define OP_RowKey 59 + //#define OP_RowData 60 + //#define OP_Rowid 61 + //#define OP_NullRow 62 + //#define OP_Last 63 + //#define OP_Sort 64 + //#define OP_Rewind 65 + //#define OP_Prev 66 + //#define OP_Next 67 + //#define OP_IdxInsert 70 + //#define OP_IdxDelete 71 + //#define OP_IdxRowid 72 + //#define OP_IdxLT 81 + //#define OP_IdxGE 92 + //#define OP_Destroy 95 + //#define OP_Clear 96 + //#define OP_CreateIndex 97 + //#define OP_CreateTable 98 + //#define OP_ParseSchema 99 + //#define OP_LoadAnalysis 100 + //#define OP_DropTable 101 + //#define OP_DropIndex 102 + //#define OP_DropTrigger 103 + //#define OP_IntegrityCk 104 + //#define OP_RowSetAdd 105 + //#define OP_RowSetRead 106 + //#define OP_RowSetTest 107 + //#define OP_Program 108 + //#define OP_Param 109 + //#define OP_FkCounter 110 + //#define OP_FkIfZero 111 + //#define OP_MemMax 112 + //#define OP_IfPos 113 + //#define OP_IfNeg 114 + //#define OP_IfZero 115 + //#define OP_AggStep 116 + //#define OP_AggFinal 117 + //#define OP_Checkpoint 118 + //#define OP_JournalMode 119 + //#define OP_Vacuum 120 + //#define OP_IncrVacuum 121 + //#define OP_Expire 122 + //#define OP_TableLock 123 + //#define OP_VBegin 124 + //#define OP_VCreate 125 + //#define OP_VDestroy 126 + //#define OP_VOpen 127 + //#define OP_VFilter 128 + //#define OP_VColumn 129 + //#define OP_VNext 131 + //#define OP_VRename 132 + //#define OP_VUpdate 133 + //#define OP_Pagecount 134 + //#define OP_MaxPgcnt 135 + //#define OP_Trace 136 + //#define OP_Noop 137 + //#define OP_Explain 138 - public const int OP_Goto = 1; - public const int OP_Gosub = 2; - public const int OP_Return = 3; - public const int OP_Yield = 4; - public const int OP_HaltIfNull = 5; - public const int OP_Halt = 6; - public const int OP_Integer = 7; - public const int OP_Int64 = 8; - public const int OP_Real = 130 /* same as TK_FLOAT */; - public const int OP_String8 = 94 /* same as TK_STRING */; - public const int OP_String = 9; - public const int OP_Null = 10; - public const int OP_Blob = 11; - public const int OP_Variable = 12; - public const int OP_Move = 13; - public const int OP_Copy = 14; - public const int OP_SCopy = 15; - public const int OP_ResultRow = 16; - public const int OP_Concat = 91 /* same as TK_CONCAT */; - public const int OP_Add = 86 /* same as TK_PLUS */; - public const int OP_Subtract = 87 /* same as TK_MINUS */; - public const int OP_Multiply = 88 /* same as TK_STAR */; - public const int OP_Divide = 89 /* same as TK_SLASH */; - public const int OP_Remainder = 90 /* same as TK_REM */; - public const int OP_CollSeq = 17; - public const int OP_Function = 18; - public const int OP_BitAnd = 82 /* same as TK_BITAND */; - public const int OP_BitOr = 83 /* same as TK_BITOR */; - public const int OP_ShiftLeft = 84 /* same as TK_LSHIFT */; - public const int OP_ShiftRight = 85 /* same as TK_RSHIFT */; - public const int OP_AddImm = 20; - public const int OP_MustBeInt = 21; - public const int OP_RealAffinity = 22; - public const int OP_ToText = 141 /* same as TK_TO_TEXT */; - public const int OP_ToBlob = 142 /* same as TK_TO_BLOB */; - public const int OP_ToNumeric = 143 /* same as TK_TO_NUMERIC*/; - public const int OP_ToInt = 144 /* same as TK_TO_INT */; - public const int OP_ToReal = 145 /* same as TK_TO_REAL */; - public const int OP_Eq = 76 /* same as TK_EQ */; - public const int OP_Ne = 75 /* same as TK_NE */; - public const int OP_Lt = 79 /* same as TK_LT */; - public const int OP_Le = 78 /* same as TK_LE */; - public const int OP_Gt = 77 /* same as TK_GT */; - public const int OP_Ge = 80 /* same as TK_GE */; - public const int OP_Permutation = 23; - public const int OP_Compare = 24; - public const int OP_Jump = 25; - public const int OP_And = 69 /* same as TK_AND */; - public const int OP_Or = 68 /* same as TK_OR */; - public const int OP_Not = 19 /* same as TK_NOT */; - public const int OP_BitNot = 93 /* same as TK_BITNOT */; - public const int OP_If = 26; - public const int OP_IfNot = 27; - public const int OP_IsNull = 73 /* same as TK_ISNULL */; - public const int OP_NotNull = 74 /* same as TK_NOTNULL */; - public const int OP_Column = 28; - public const int OP_Affinity = 29; - public const int OP_MakeRecord = 30; - public const int OP_Count = 31; - public const int OP_Savepoint = 32; - public const int OP_AutoCommit = 33; - public const int OP_Transaction = 34; - public const int OP_ReadCookie = 35; - public const int OP_SetCookie = 36; - public const int OP_VerifyCookie = 37; - public const int OP_OpenRead = 38; - public const int OP_OpenWrite = 39; - public const int OP_OpenAutoindex = 40; - public const int OP_OpenEphemeral = 41; - public const int OP_OpenPseudo = 42; - public const int OP_Close = 43; - public const int OP_SeekLt = 44; - public const int OP_SeekLe = 45; - public const int OP_SeekGe = 46; - public const int OP_SeekGt = 47; - public const int OP_Seek = 48; - public const int OP_NotFound = 49; - public const int OP_Found = 50; - public const int OP_IsUnique = 51; - public const int OP_NotExists = 52; - public const int OP_Sequence = 53; - public const int OP_NewRowid = 54; - public const int OP_Insert = 55; - public const int OP_InsertInt = 56; - public const int OP_Delete = 57; - public const int OP_ResetCount = 58; - public const int OP_RowKey = 59; - public const int OP_RowData = 60; - public const int OP_Rowid = 61; - public const int OP_NullRow = 62; - public const int OP_Last = 63; - public const int OP_Sort = 64; - public const int OP_Rewind = 65; - public const int OP_Prev = 66; - public const int OP_Next = 67; - public const int OP_IdxInsert = 70; - public const int OP_IdxDelete = 71; - public const int OP_IdxRowid = 72; - public const int OP_IdxLT = 81; - public const int OP_IdxGE = 92; - public const int OP_Destroy = 95; - public const int OP_Clear = 96; - public const int OP_CreateIndex = 97; - public const int OP_CreateTable = 98; - public const int OP_ParseSchema = 99; - public const int OP_LoadAnalysis = 100; - public const int OP_DropTable = 101; - public const int OP_DropIndex = 102; - public const int OP_DropTrigger = 103; - public const int OP_IntegrityCk = 104; - public const int OP_RowSetAdd = 105; - public const int OP_RowSetRead = 106; - public const int OP_RowSetTest = 107; - public const int OP_Program = 108; - public const int OP_Param = 109; - public const int OP_FkCounter = 110; - public const int OP_FkIfZero = 111; - public const int OP_MemMax = 112; - public const int OP_IfPos = 113; - public const int OP_IfNeg = 114; - public const int OP_IfZero = 115; - public const int OP_AggStep = 116; - public const int OP_AggFinal = 117; - public const int OP_Checkpoint = 118; - public const int OP_JournalMode = 119; - public const int OP_Vacuum = 120; - public const int OP_IncrVacuum = 121; - public const int OP_Expire = 122; - public const int OP_TableLock = 123; - public const int OP_VBegin = 124; - public const int OP_VCreate = 125; - public const int OP_VDestroy = 126; - public const int OP_VOpen = 127; - public const int OP_VFilter = 128; - public const int OP_VColumn = 129; - public const int OP_VNext = 131; - public const int OP_VRename = 132; - public const int OP_VUpdate = 133; - public const int OP_Pagecount = 134; - public const int OP_MaxPgcnt = 135; - public const int OP_Trace = 136; - public const int OP_Noop = 137; - public const int OP_Explain = 138; + public const int OP_Goto = 1; + public const int OP_Gosub = 2; + public const int OP_Return = 3; + public const int OP_Yield = 4; + public const int OP_HaltIfNull = 5; + public const int OP_Halt = 6; + public const int OP_Integer = 7; + public const int OP_Int64 = 8; + public const int OP_Real = 130 /* same as TK_FLOAT */; + public const int OP_String8 = 94 /* same as TK_STRING */; + public const int OP_String = 9; + public const int OP_Null = 10; + public const int OP_Blob = 11; + public const int OP_Variable = 12; + public const int OP_Move = 13; + public const int OP_Copy = 14; + public const int OP_SCopy = 15; + public const int OP_ResultRow = 16; + public const int OP_Concat = 91 /* same as TK_CONCAT */; + public const int OP_Add = 86 /* same as TK_PLUS */; + public const int OP_Subtract = 87 /* same as TK_MINUS */; + public const int OP_Multiply = 88 /* same as TK_STAR */; + public const int OP_Divide = 89 /* same as TK_SLASH */; + public const int OP_Remainder = 90 /* same as TK_REM */; + public const int OP_CollSeq = 17; + public const int OP_Function = 18; + public const int OP_BitAnd = 82 /* same as TK_BITAND */; + public const int OP_BitOr = 83 /* same as TK_BITOR */; + public const int OP_ShiftLeft = 84 /* same as TK_LSHIFT */; + public const int OP_ShiftRight = 85 /* same as TK_RSHIFT */; + public const int OP_AddImm = 20; + public const int OP_MustBeInt = 21; + public const int OP_RealAffinity = 22; + public const int OP_ToText = 141 /* same as TK_TO_TEXT */; + public const int OP_ToBlob = 142 /* same as TK_TO_BLOB */; + public const int OP_ToNumeric = 143 /* same as TK_TO_NUMERIC*/; + public const int OP_ToInt = 144 /* same as TK_TO_INT */; + public const int OP_ToReal = 145 /* same as TK_TO_REAL */; + public const int OP_Eq = 76 /* same as TK_EQ */; + public const int OP_Ne = 75 /* same as TK_NE */; + public const int OP_Lt = 79 /* same as TK_LT */; + public const int OP_Le = 78 /* same as TK_LE */; + public const int OP_Gt = 77 /* same as TK_GT */; + public const int OP_Ge = 80 /* same as TK_GE */; + public const int OP_Permutation = 23; + public const int OP_Compare = 24; + public const int OP_Jump = 25; + public const int OP_And = 69 /* same as TK_AND */; + public const int OP_Or = 68 /* same as TK_OR */; + public const int OP_Not = 19 /* same as TK_NOT */; + public const int OP_BitNot = 93 /* same as TK_BITNOT */; + public const int OP_If = 26; + public const int OP_IfNot = 27; + public const int OP_IsNull = 73 /* same as TK_ISNULL */; + public const int OP_NotNull = 74 /* same as TK_NOTNULL */; + public const int OP_Column = 28; + public const int OP_Affinity = 29; + public const int OP_MakeRecord = 30; + public const int OP_Count = 31; + public const int OP_Savepoint = 32; + public const int OP_AutoCommit = 33; + public const int OP_Transaction = 34; + public const int OP_ReadCookie = 35; + public const int OP_SetCookie = 36; + public const int OP_VerifyCookie = 37; + public const int OP_OpenRead = 38; + public const int OP_OpenWrite = 39; + public const int OP_OpenAutoindex = 40; + public const int OP_OpenEphemeral = 41; + public const int OP_OpenPseudo = 42; + public const int OP_Close = 43; + public const int OP_SeekLt = 44; + public const int OP_SeekLe = 45; + public const int OP_SeekGe = 46; + public const int OP_SeekGt = 47; + public const int OP_Seek = 48; + public const int OP_NotFound = 49; + public const int OP_Found = 50; + public const int OP_IsUnique = 51; + public const int OP_NotExists = 52; + public const int OP_Sequence = 53; + public const int OP_NewRowid = 54; + public const int OP_Insert = 55; + public const int OP_InsertInt = 56; + public const int OP_Delete = 57; + public const int OP_ResetCount = 58; + public const int OP_RowKey = 59; + public const int OP_RowData = 60; + public const int OP_Rowid = 61; + public const int OP_NullRow = 62; + public const int OP_Last = 63; + public const int OP_Sort = 64; + public const int OP_Rewind = 65; + public const int OP_Prev = 66; + public const int OP_Next = 67; + public const int OP_IdxInsert = 70; + public const int OP_IdxDelete = 71; + public const int OP_IdxRowid = 72; + public const int OP_IdxLT = 81; + public const int OP_IdxGE = 92; + public const int OP_Destroy = 95; + public const int OP_Clear = 96; + public const int OP_CreateIndex = 97; + public const int OP_CreateTable = 98; + public const int OP_ParseSchema = 99; + public const int OP_LoadAnalysis = 100; + public const int OP_DropTable = 101; + public const int OP_DropIndex = 102; + public const int OP_DropTrigger = 103; + public const int OP_IntegrityCk = 104; + public const int OP_RowSetAdd = 105; + public const int OP_RowSetRead = 106; + public const int OP_RowSetTest = 107; + public const int OP_Program = 108; + public const int OP_Param = 109; + public const int OP_FkCounter = 110; + public const int OP_FkIfZero = 111; + public const int OP_MemMax = 112; + public const int OP_IfPos = 113; + public const int OP_IfNeg = 114; + public const int OP_IfZero = 115; + public const int OP_AggStep = 116; + public const int OP_AggFinal = 117; + public const int OP_Checkpoint = 118; + public const int OP_JournalMode = 119; + public const int OP_Vacuum = 120; + public const int OP_IncrVacuum = 121; + public const int OP_Expire = 122; + public const int OP_TableLock = 123; + public const int OP_VBegin = 124; + public const int OP_VCreate = 125; + public const int OP_VDestroy = 126; + public const int OP_VOpen = 127; + public const int OP_VFilter = 128; + public const int OP_VColumn = 129; + public const int OP_VNext = 131; + public const int OP_VRename = 132; + public const int OP_VUpdate = 133; + public const int OP_Pagecount = 134; + public const int OP_MaxPgcnt = 135; + public const int OP_Trace = 136; + public const int OP_Noop = 137; + public const int OP_Explain = 138; - /* The following opcode values are never used */ - //#define OP_NotUsed_139 139 - //#define OP_NotUsed_140 140 + /* The following opcode values are never used */ + //#define OP_NotUsed_139 139 + //#define OP_NotUsed_140 140 - /* The following opcode values are never used */ - public const int OP_NotUsed_138 = 138; - public const int OP_NotUsed_139 = 139; - public const int OP_NotUsed_140 = 140; + /* The following opcode values are never used */ + public const int OP_NotUsed_138 = 138; + public const int OP_NotUsed_139 = 139; + public const int OP_NotUsed_140 = 140; - /* Properties such as "out2" or "jump" that are specified in - ** comments following the "case" for each opcode in the vdbe.c - ** are encoded into bitvectors as follows: - */ - //#define OPFLG_JUMP 0x0001 /* jump: P2 holds jmp target */ - //#define OPFLG_OUT2_PRERELEASE 0x0002 /* out2-prerelease: */ - //#define OPFLG_IN1 0x0004 /* in1: P1 is an input */ - //#define OPFLG_IN2 0x0008 /* in2: P2 is an input */ - //#define OPFLG_IN3 0x0010 /* in3: P3 is an input */ - //#define OPFLG_OUT2 0x0020 /* out2: P2 is an output */ - //#define OPFLG_OUT3 0x0040 /* out3: P3 is an output */ + /* Properties such as "out2" or "jump" that are specified in + ** comments following the "case" for each opcode in the vdbe.c + ** are encoded into bitvectors as follows: + */ + //#define OPFLG_JUMP 0x0001 /* jump: P2 holds jmp target */ + //#define OPFLG_OUT2_PRERELEASE 0x0002 /* out2-prerelease: */ + //#define OPFLG_IN1 0x0004 /* in1: P1 is an input */ + //#define OPFLG_IN2 0x0008 /* in2: P2 is an input */ + //#define OPFLG_IN3 0x0010 /* in3: P3 is an input */ + //#define OPFLG_OUT2 0x0020 /* out2: P2 is an output */ + //#define OPFLG_OUT3 0x0040 /* out3: P3 is an output */ - public const int OPFLG_JUMP = 0x0001; /* jump: P2 holds jmp target */ - public const int OPFLG_OUT2_PRERELEASE = 0x0002; /* out2-prerelease: */ - public const int OPFLG_IN1 = 0x0004; /* in1: P1 is an input */ - public const int OPFLG_IN2 = 0x0008; /* in2: P2 is an input */ - public const int OPFLG_IN3 = 0x0010; /* in3: P3 is an input */ - public const int OPFLG_OUT2 = 0x0020; /* out2: P2 is an output */ - public const int OPFLG_OUT3 = 0x0040; /* out3: P3 is an output */ - public static int[] OPFLG_INITIALIZER = new int[]{ + public const int OPFLG_JUMP = 0x0001; /* jump: P2 holds jmp target */ + public const int OPFLG_OUT2_PRERELEASE = 0x0002; /* out2-prerelease: */ + public const int OPFLG_IN1 = 0x0004; /* in1: P1 is an input */ + public const int OPFLG_IN2 = 0x0008; /* in2: P2 is an input */ + public const int OPFLG_IN3 = 0x0010; /* in3: P3 is an input */ + public const int OPFLG_OUT2 = 0x0020; /* out2: P2 is an output */ + public const int OPFLG_OUT3 = 0x0040; /* out3: P3 is an output */ + public static int[] OPFLG_INITIALIZER = new int[]{ /* 0 */ 0x00, 0x01, 0x05, 0x04, 0x04, 0x10, 0x00, 0x02, /* 8 */ 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x24, 0x24, /* 16 */ 0x00, 0x00, 0x00, 0x24, 0x04, 0x05, 0x04, 0x00, @@ -342,5 +344,5 @@ public partial class Sqlite3 { /* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, /* 144 */ 0x04, 0x04 }; - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/os_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/os_c.cs index 6bd1c4aaf..c396dfbe3 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/os_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/os_c.cs @@ -3,55 +3,57 @@ using HANDLE = System.IntPtr; using i64 = System.Int64; -using sqlite3_int64 = System.Int64; using u32 = System.UInt32; +using sqlite3_int64 = System.Int64; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { - /* - ** 2005 November 29 - ** - ** 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 contains OS interface code that is common to all - ** architectures. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-12-07 20:14:09 a586a4deeb25330037a49df295b36aaf624d0f45 - ** - ************************************************************************* - */ - //#define _SQLITE_OS_C_ 1 - //#include "sqliteInt.h" - //#undef _SQLITE_OS_C_ + /* + ** 2005 November 29 + ** + ** 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 contains OS interface code that is common to all + ** architectures. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-12-07 20:14:09 a586a4deeb25330037a49df295b36aaf624d0f45 + ** + ************************************************************************* + */ + //#define _SQLITE_OS_C_ 1 + //#include "sqliteInt.h" + //#undef _SQLITE_OS_C_ - /* - ** The default SQLite sqlite3_vfs implementations do not allocate - ** memory (actually, os_unix.c allocates a small amount of memory - ** from within OsOpen()), but some third-party implementations may. - ** So we test the effects of a malloc() failing and the sqlite3OsXXX() - ** function returning SQLITE_IOERR_NOMEM using the DO_OS_MALLOC_TEST macro. - ** - ** The following functions are instrumented for malloc() failure - ** testing: - ** - ** sqlite3OsOpen() - ** sqlite3OsRead() - ** sqlite3OsWrite() - ** sqlite3OsSync() - ** sqlite3OsLock() - ** - */ + /* + ** The default SQLite sqlite3_vfs implementations do not allocate + ** memory (actually, os_unix.c allocates a small amount of memory + ** from within OsOpen()), but some third-party implementations may. + ** So we test the effects of a malloc() failing and the sqlite3OsXXX() + ** function returning SQLITE_IOERR_NOMEM using the DO_OS_MALLOC_TEST macro. + ** + ** The following functions are instrumented for malloc() failure + ** testing: + ** + ** sqlite3OsOpen() + ** sqlite3OsRead() + ** sqlite3OsWrite() + ** sqlite3OsSync() + ** sqlite3OsLock() + ** + */ #if (SQLITE_TEST) static int sqlite3_memdebug_vfs_oom_test = 1; @@ -65,300 +67,353 @@ static void DO_OS_MALLOC_TEST( sqlite3_file x ) { } #else - //#define DO_OS_MALLOC_TEST(x) - static void DO_OS_MALLOC_TEST(sqlite3_file x) { } + //#define DO_OS_MALLOC_TEST(x) + static void DO_OS_MALLOC_TEST( sqlite3_file x ) { } #endif - /* - ** The following routines are convenience wrappers around methods - ** of the sqlite3_file object. This is mostly just syntactic sugar. All - ** of this would be completely automatic if SQLite were coded using - ** C++ instead of plain old C. - */ - static int sqlite3OsClose(sqlite3_file pId) { - int rc = SQLITE_OK; - if (pId.pMethods != null) { - rc = pId.pMethods.xClose(pId); - pId.pMethods = null; - } - return rc; - } - static int sqlite3OsRead(sqlite3_file id, byte[] pBuf, int amt, i64 offset) { - DO_OS_MALLOC_TEST(id); - if (pBuf == null) - pBuf = sqlite3Malloc(amt); - return id.pMethods.xRead(id, pBuf, amt, offset); - } - static int sqlite3OsWrite(sqlite3_file id, byte[] pBuf, int amt, i64 offset) { - DO_OS_MALLOC_TEST(id); - return id.pMethods.xWrite(id, pBuf, amt, offset); - } - static int sqlite3OsTruncate(sqlite3_file id, i64 size) { - return id.pMethods.xTruncate(id, size); - } - static int sqlite3OsSync(sqlite3_file id, int flags) { - DO_OS_MALLOC_TEST(id); - return id.pMethods.xSync(id, flags); - } - static int sqlite3OsFileSize(sqlite3_file id, ref long pSize) { - return id.pMethods.xFileSize(id, ref pSize); - } - static int sqlite3OsLock(sqlite3_file id, int lockType) { - DO_OS_MALLOC_TEST(id); - return id.pMethods.xLock(id, lockType); - } - static int sqlite3OsUnlock(sqlite3_file id, int lockType) { - return id.pMethods.xUnlock(id, lockType); - } - static int sqlite3OsCheckReservedLock(sqlite3_file id, ref int pResOut) { - DO_OS_MALLOC_TEST(id); - return id.pMethods.xCheckReservedLock(id, ref pResOut); - } - static int sqlite3OsFileControl(sqlite3_file id, u32 op, ref sqlite3_int64 pArg) { - return id.pMethods.xFileControl(id, (int)op, ref pArg); - } + /* +** The following routines are convenience wrappers around methods +** of the sqlite3_file object. This is mostly just syntactic sugar. All +** of this would be completely automatic if SQLite were coded using +** C++ instead of plain old C. +*/ + static int sqlite3OsClose( sqlite3_file pId ) + { + int rc = SQLITE_OK; + if ( pId.pMethods != null ) + { + rc = pId.pMethods.xClose( pId ); + pId.pMethods = null; + } + return rc; + } + static int sqlite3OsRead( sqlite3_file id, byte[] pBuf, int amt, i64 offset ) + { + DO_OS_MALLOC_TEST( id ); + if ( pBuf == null ) + pBuf = sqlite3Malloc( amt ); + return id.pMethods.xRead( id, pBuf, amt, offset ); + } + static int sqlite3OsWrite( sqlite3_file id, byte[] pBuf, int amt, i64 offset ) + { + DO_OS_MALLOC_TEST( id ); + return id.pMethods.xWrite( id, pBuf, amt, offset ); + } + static int sqlite3OsTruncate( sqlite3_file id, i64 size ) + { + return id.pMethods.xTruncate( id, size ); + } + static int sqlite3OsSync( sqlite3_file id, int flags ) + { + DO_OS_MALLOC_TEST( id ); + return id.pMethods.xSync( id, flags ); + } + static int sqlite3OsFileSize( sqlite3_file id, ref long pSize ) + { + return id.pMethods.xFileSize( id, ref pSize ); + } + static int sqlite3OsLock( sqlite3_file id, int lockType ) + { + DO_OS_MALLOC_TEST( id ); + return id.pMethods.xLock( id, lockType ); + } + static int sqlite3OsUnlock( sqlite3_file id, int lockType ) + { + return id.pMethods.xUnlock( id, lockType ); + } + static int sqlite3OsCheckReservedLock( sqlite3_file id, ref int pResOut ) + { + DO_OS_MALLOC_TEST( id ); + return id.pMethods.xCheckReservedLock( id, ref pResOut ); + } + static int sqlite3OsFileControl( sqlite3_file id, u32 op, ref sqlite3_int64 pArg ) + { + return id.pMethods.xFileControl( id, (int)op, ref pArg ); + } - static int sqlite3OsSectorSize(sqlite3_file id) { - dxSectorSize xSectorSize = id.pMethods.xSectorSize; - return (xSectorSize != null ? xSectorSize(id) : SQLITE_DEFAULT_SECTOR_SIZE); - } - static int sqlite3OsDeviceCharacteristics(sqlite3_file id) { - return id.pMethods.xDeviceCharacteristics(id); - } + static int sqlite3OsSectorSize( sqlite3_file id ) + { + dxSectorSize xSectorSize = id.pMethods.xSectorSize; + return ( xSectorSize != null ? xSectorSize( id ) : SQLITE_DEFAULT_SECTOR_SIZE ); + } + static int sqlite3OsDeviceCharacteristics( sqlite3_file id ) + { + return id.pMethods.xDeviceCharacteristics( id ); + } - static int sqlite3OsShmLock(sqlite3_file id, int offset, int n, int flags) { - return id.pMethods.xShmLock(id, offset, n, flags); - } - static void sqlite3OsShmBarrier(sqlite3_file id) { - id.pMethods.xShmBarrier(id); - } + static int sqlite3OsShmLock( sqlite3_file id, int offset, int n, int flags ) + { + return id.pMethods.xShmLock( id, offset, n, flags ); + } + static void sqlite3OsShmBarrier( sqlite3_file id ) + { + id.pMethods.xShmBarrier( id ); + } - static int sqlite3OsShmUnmap(sqlite3_file id, int deleteFlag) { - return id.pMethods.xShmUnmap(id, deleteFlag); - } - static int sqlite3OsShmMap( - sqlite3_file id, /* Database file handle */ - int iPage, - int pgsz, - int bExtend, /* True to extend file if necessary */ - out object pp /* OUT: Pointer to mapping */ - ) { - return id.pMethods.xShmMap(id, iPage, pgsz, bExtend, out pp); - } + static int sqlite3OsShmUnmap( sqlite3_file id, int deleteFlag ) + { + return id.pMethods.xShmUnmap( id, deleteFlag ); + } + static int sqlite3OsShmMap( +sqlite3_file id, /* Database file handle */ +int iPage, +int pgsz, +int bExtend, /* True to extend file if necessary */ +out object pp /* OUT: Pointer to mapping */ +) + { + return id.pMethods.xShmMap( id, iPage, pgsz, bExtend, out pp ); + } - /* - ** The next group of routines are convenience wrappers around the - ** VFS methods. - */ - static int sqlite3OsOpen( - sqlite3_vfs pVfs, - string zPath, - sqlite3_file pFile, - int flags, - ref int pFlagsOut - ) { - int rc; - DO_OS_MALLOC_TEST(null); - /* 0x87f3f is a mask of SQLITE_OPEN_ flags that are valid to be passed - ** down into the VFS layer. Some SQLITE_OPEN_ flags (for example, - ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before - ** reaching the VFS. */ - rc = pVfs.xOpen(pVfs, zPath, pFile, flags & 0x87f3f, out pFlagsOut); - Debug.Assert(rc == SQLITE_OK || pFile.pMethods == null); - return rc; - } - static int sqlite3OsDelete(sqlite3_vfs pVfs, string zPath, int dirSync) { - return pVfs.xDelete(pVfs, zPath, dirSync); - } - static int sqlite3OsAccess(sqlite3_vfs pVfs, string zPath, int flags, ref int pResOut) { - DO_OS_MALLOC_TEST(null); - return pVfs.xAccess(pVfs, zPath, flags, out pResOut); - } - static int sqlite3OsFullPathname( - sqlite3_vfs pVfs, - string zPath, - int nPathOut, - StringBuilder zPathOut - ) { - zPathOut.Length = 0;//zPathOut[0] = 0; - return pVfs.xFullPathname(pVfs, zPath, nPathOut, zPathOut); - } + /* + ** The next group of routines are convenience wrappers around the + ** VFS methods. + */ + static int sqlite3OsOpen( + sqlite3_vfs pVfs, + string zPath, + sqlite3_file pFile, + int flags, + ref int pFlagsOut + ) + { + int rc; + DO_OS_MALLOC_TEST( null ); + /* 0x87f3f is a mask of SQLITE_OPEN_ flags that are valid to be passed + ** down into the VFS layer. Some SQLITE_OPEN_ flags (for example, + ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before + ** reaching the VFS. */ + rc = pVfs.xOpen( pVfs, zPath, pFile, flags & 0x87f3f, out pFlagsOut ); + Debug.Assert( rc == SQLITE_OK || pFile.pMethods == null ); + return rc; + } + static int sqlite3OsDelete( sqlite3_vfs pVfs, string zPath, int dirSync ) + { + return pVfs.xDelete( pVfs, zPath, dirSync ); + } + static int sqlite3OsAccess( sqlite3_vfs pVfs, string zPath, int flags, ref int pResOut ) + { + DO_OS_MALLOC_TEST( null ); + return pVfs.xAccess( pVfs, zPath, flags, out pResOut ); + } + static int sqlite3OsFullPathname( + sqlite3_vfs pVfs, + string zPath, + int nPathOut, + StringBuilder zPathOut + ) + { + zPathOut.Length = 0;//zPathOut[0] = 0; + return pVfs.xFullPathname( pVfs, zPath, nPathOut, zPathOut ); + } #if !SQLITE_OMIT_LOAD_EXTENSION - static HANDLE sqlite3OsDlOpen(sqlite3_vfs pVfs, string zPath) { - return pVfs.xDlOpen(pVfs, zPath); - } + static HANDLE sqlite3OsDlOpen( sqlite3_vfs pVfs, string zPath ) + { + return pVfs.xDlOpen( pVfs, zPath ); + } - static void sqlite3OsDlError(sqlite3_vfs pVfs, int nByte, string zBufOut) { - pVfs.xDlError(pVfs, nByte, zBufOut); - } - static object sqlite3OsDlSym(sqlite3_vfs pVfs, HANDLE pHdle, ref string zSym) { - return pVfs.xDlSym(pVfs, pHdle, zSym); - } - static void sqlite3OsDlClose(sqlite3_vfs pVfs, HANDLE pHandle) { - pVfs.xDlClose(pVfs, pHandle); - } + static void sqlite3OsDlError( sqlite3_vfs pVfs, int nByte, string zBufOut ) + { + pVfs.xDlError( pVfs, nByte, zBufOut ); + } + static object sqlite3OsDlSym( sqlite3_vfs pVfs, HANDLE pHdle, ref string zSym ) + { + return pVfs.xDlSym( pVfs, pHdle, zSym ); + } + static void sqlite3OsDlClose( sqlite3_vfs pVfs, HANDLE pHandle ) + { + pVfs.xDlClose( pVfs, pHandle ); + } #endif - static int sqlite3OsRandomness(sqlite3_vfs pVfs, int nByte, byte[] zBufOut) { - return pVfs.xRandomness(pVfs, nByte, zBufOut); - } - static int sqlite3OsSleep(sqlite3_vfs pVfs, int nMicro) { - return pVfs.xSleep(pVfs, nMicro); - } + static int sqlite3OsRandomness( sqlite3_vfs pVfs, int nByte, byte[] zBufOut ) + { + return pVfs.xRandomness( pVfs, nByte, zBufOut ); + } + static int sqlite3OsSleep( sqlite3_vfs pVfs, int nMicro ) + { + return pVfs.xSleep( pVfs, nMicro ); + } - static int sqlite3OsCurrentTimeInt64(sqlite3_vfs pVfs, ref sqlite3_int64 pTimeOut) { - int rc; - /* IMPLEMENTATION-OF: R-49045-42493 SQLite will use the xCurrentTimeInt64() - ** method to get the current date and time if that method is available - ** (if iVersion is 2 or greater and the function pointer is not NULL) and - ** will fall back to xCurrentTime() if xCurrentTimeInt64() is - ** unavailable. - */ - if (pVfs.iVersion >= 2 && pVfs.xCurrentTimeInt64 != null) { - rc = pVfs.xCurrentTimeInt64(pVfs, ref pTimeOut); - } else { - double r = 0; - rc = pVfs.xCurrentTime(pVfs, ref r); - pTimeOut = (sqlite3_int64)(r * 86400000.0); - } - return rc; - } + static int sqlite3OsCurrentTimeInt64( sqlite3_vfs pVfs, ref sqlite3_int64 pTimeOut ) + { + int rc; + /* IMPLEMENTATION-OF: R-49045-42493 SQLite will use the xCurrentTimeInt64() + ** method to get the current date and time if that method is available + ** (if iVersion is 2 or greater and the function pointer is not NULL) and + ** will fall back to xCurrentTime() if xCurrentTimeInt64() is + ** unavailable. + */ + if ( pVfs.iVersion >= 2 && pVfs.xCurrentTimeInt64 != null ) + { + rc = pVfs.xCurrentTimeInt64( pVfs, ref pTimeOut ); + } + else + { + double r = 0; + rc = pVfs.xCurrentTime( pVfs, ref r ); + pTimeOut = (sqlite3_int64)( r * 86400000.0 ); + } + return rc; + } - static int sqlite3OsOpenMalloc( - ref sqlite3_vfs pVfs, - string zFile, - ref sqlite3_file ppFile, - int flags, - ref int pOutFlags - ) { - int rc = SQLITE_NOMEM; - sqlite3_file pFile; - pFile = new sqlite3_file(); //sqlite3Malloc(ref pVfs.szOsFile); - if (pFile != null) { - rc = sqlite3OsOpen(pVfs, zFile, pFile, flags, ref pOutFlags); - if (rc != SQLITE_OK) { - pFile = null; // was sqlite3DbFree(db,ref pFile); - } else { - ppFile = pFile; - } - } - return rc; - } - static int sqlite3OsCloseFree(sqlite3_file pFile) { - int rc = SQLITE_OK; - Debug.Assert(pFile != null); - rc = sqlite3OsClose(pFile); - //sqlite3_free( ref pFile ); - return rc; - } + static int sqlite3OsOpenMalloc( + ref sqlite3_vfs pVfs, + string zFile, + ref sqlite3_file ppFile, + int flags, + ref int pOutFlags + ) + { + int rc = SQLITE_NOMEM; + sqlite3_file pFile; + pFile = new sqlite3_file(); //sqlite3Malloc(ref pVfs.szOsFile); + if ( pFile != null ) + { + rc = sqlite3OsOpen( pVfs, zFile, pFile, flags, ref pOutFlags ); + if ( rc != SQLITE_OK ) + { + pFile = null; // was sqlite3DbFree(db,ref pFile); + } + else + { + ppFile = pFile; + } + } + return rc; + } + static int sqlite3OsCloseFree( sqlite3_file pFile ) + { + int rc = SQLITE_OK; + Debug.Assert( pFile != null ); + rc = sqlite3OsClose( pFile ); + //sqlite3_free( ref pFile ); + return rc; + } - /* - ** This function is a wrapper around the OS specific implementation of - ** sqlite3_os_init(). The purpose of the wrapper is to provide the - ** ability to simulate a malloc failure, so that the handling of an - ** error in sqlite3_os_init() by the upper layers can be tested. - */ - static int sqlite3OsInit() { - //void *p = sqlite3_malloc(10); - //if( p==null ) return SQLITE_NOMEM; - //sqlite3_free(ref p); - return sqlite3_os_init(); - } - /* - ** The list of all registered VFS implementations. - */ - static sqlite3_vfs vfsList; - //#define vfsList GLOBAL(sqlite3_vfs *, vfsList) + /* + ** This function is a wrapper around the OS specific implementation of + ** sqlite3_os_init(). The purpose of the wrapper is to provide the + ** ability to simulate a malloc failure, so that the handling of an + ** error in sqlite3_os_init() by the upper layers can be tested. + */ + static int sqlite3OsInit() + { + //void *p = sqlite3_malloc(10); + //if( p==null ) return SQLITE_NOMEM; + //sqlite3_free(ref p); + return sqlite3_os_init(); + } + /* + ** The list of all registered VFS implementations. + */ + static sqlite3_vfs vfsList; + //#define vfsList GLOBAL(sqlite3_vfs *, vfsList) - /* - ** Locate a VFS by name. If no name is given, simply return the - ** first VFS on the list. - */ - static bool isInit = false; + /* + ** Locate a VFS by name. If no name is given, simply return the + ** first VFS on the list. + */ + static bool isInit = false; - static public sqlite3_vfs sqlite3_vfs_find(string zVfs) { - sqlite3_vfs pVfs = null; + static public sqlite3_vfs sqlite3_vfs_find(string zVfs) + { + sqlite3_vfs pVfs = null; #if SQLITE_THREADSAFE - sqlite3_mutex mutex; + sqlite3_mutex mutex; #endif #if !SQLITE_OMIT_AUTOINIT - int rc = sqlite3_initialize(); - if (rc != 0) - return null; + int rc = sqlite3_initialize(); + if ( rc != 0 ) + return null; #endif #if SQLITE_THREADSAFE - mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); + mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); #endif - sqlite3_mutex_enter(mutex); - for (pVfs = vfsList; pVfs != null; pVfs = pVfs.pNext) { - if (zVfs == null || zVfs == "") - break; - if (zVfs == pVfs.zName) - break; //strcmp(zVfs, pVfs.zName) == null) break; - } - sqlite3_mutex_leave(mutex); - return pVfs; - } + sqlite3_mutex_enter( mutex ); + for ( pVfs = vfsList; pVfs != null; pVfs = pVfs.pNext ) + { + if ( zVfs == null || zVfs == "" ) + break; + if ( zVfs == pVfs.zName ) + break; //strcmp(zVfs, pVfs.zName) == null) break; + } + sqlite3_mutex_leave( mutex ); + return pVfs; + } - /* - ** Unlink a VFS from the linked list - */ - static void vfsUnlink(sqlite3_vfs pVfs) { - Debug.Assert(sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER))); - if (pVfs == null) { - /* No-op */ - } else if (vfsList == pVfs) { - vfsList = pVfs.pNext; - } else if (vfsList != null) { - sqlite3_vfs p = vfsList; - while (p.pNext != null && p.pNext != pVfs) { - p = p.pNext; - } - if (p.pNext == pVfs) { - p.pNext = pVfs.pNext; - } - } - } + /* + ** Unlink a VFS from the linked list + */ + static void vfsUnlink( sqlite3_vfs pVfs ) + { + Debug.Assert( sqlite3_mutex_held( sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ) ) ); + if ( pVfs == null ) + { + /* No-op */ + } + else if ( vfsList == pVfs ) + { + vfsList = pVfs.pNext; + } + else if ( vfsList != null ) + { + sqlite3_vfs p = vfsList; + while ( p.pNext != null && p.pNext != pVfs ) + { + p = p.pNext; + } + if ( p.pNext == pVfs ) + { + p.pNext = pVfs.pNext; + } + } + } - /* - ** Register a VFS with the system. It is harmless to register the same - ** VFS multiple times. The new VFS becomes the default if makeDflt is - ** true. - */ - static public int sqlite3_vfs_register(sqlite3_vfs pVfs, int makeDflt) { - sqlite3_mutex mutex; + /* + ** Register a VFS with the system. It is harmless to register the same + ** VFS multiple times. The new VFS becomes the default if makeDflt is + ** true. + */ + static public int sqlite3_vfs_register( sqlite3_vfs pVfs, int makeDflt ) + { + sqlite3_mutex mutex; #if !SQLITE_OMIT_AUTOINIT - int rc = sqlite3_initialize(); - if (rc != 0) - return rc; + int rc = sqlite3_initialize(); + if ( rc != 0 ) + return rc; #endif - mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); - sqlite3_mutex_enter(mutex); - vfsUnlink(pVfs); - if (makeDflt != 0 || vfsList == null) { - pVfs.pNext = vfsList; - vfsList = pVfs; - } else { - pVfs.pNext = vfsList.pNext; - vfsList.pNext = pVfs; - } - Debug.Assert(vfsList != null); - sqlite3_mutex_leave(mutex); - return SQLITE_OK; - } + mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); + sqlite3_mutex_enter( mutex ); + vfsUnlink( pVfs ); + if ( makeDflt != 0 || vfsList == null ) + { + pVfs.pNext = vfsList; + vfsList = pVfs; + } + else + { + pVfs.pNext = vfsList.pNext; + vfsList.pNext = pVfs; + } + Debug.Assert( vfsList != null ); + sqlite3_mutex_leave( mutex ); + return SQLITE_OK; + } - /* - ** Unregister a VFS so that it is no longer accessible. - */ - static int sqlite3_vfs_unregister(sqlite3_vfs pVfs) { + /* + ** Unregister a VFS so that it is no longer accessible. + */ + static int sqlite3_vfs_unregister( sqlite3_vfs pVfs ) + { #if SQLITE_THREADSAFE - sqlite3_mutex mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); + sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ); #endif - sqlite3_mutex_enter(mutex); - vfsUnlink(pVfs); - sqlite3_mutex_leave(mutex); - return SQLITE_OK; - } + sqlite3_mutex_enter( mutex ); + vfsUnlink( pVfs ); + sqlite3_mutex_leave( mutex ); + return SQLITE_OK; } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/os_common_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/os_common_h.cs index 92a64782a..2f7567d31 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/os_common_h.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/os_common_h.cs @@ -1,60 +1,64 @@ +using System.Diagnostics; using va_list = System.Object; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2004 May 22 - ** - ** 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 contains macros and a little bit of code that is common to - ** all of the platform-specific files (os_*.c) and is #included into those - ** files. - ** - ** This file should be #included by the os_*.c files only. It is not a - ** general purpose header file. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#if !_OS_COMMON_H_ - //#define _OS_COMMON_H_ - /* - ** At least two bugs have slipped in because we changed the MEMORY_DEBUG - ** macro to SQLITE_DEBUG and some older makefiles have not yet made the - ** switch. The following code should catch this problem at compile-time. - */ +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 2004 May 22 + ** + ** 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 contains macros and a little bit of code that is common to + ** all of the platform-specific files (os_*.c) and is #included into those + ** files. + ** + ** This file should be #included by the os_*.c files only. It is not a + ** general purpose header file. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + //#if !_OS_COMMON_H_ + //#define _OS_COMMON_H_ + /* + ** At least two bugs have slipped in because we changed the MEMORY_DEBUG + ** macro to SQLITE_DEBUG and some older makefiles have not yet made the + ** switch. The following code should catch this problem at compile-time. + */ #if MEMORY_DEBUG //# error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead." #endif #if SQLITE_DEBUG || TRACE - static bool sqlite3OsTrace = false; - //#define OSTRACE(X) if( sqlite3OSTrace ) sqlite3DebugPrintf X - static void OSTRACE(string X, params va_list[] ap) { - if (sqlite3OsTrace) - sqlite3DebugPrintf(X, ap); - } + static bool sqlite3OsTrace = false; + //#define OSTRACE(X) if( sqlite3OSTrace ) sqlite3DebugPrintf X + static void OSTRACE( string X, params va_list[] ap ) + { + if ( sqlite3OsTrace ) + sqlite3DebugPrintf( X, ap ); + } #else //#define OSTRACE(X) static void OSTRACE( string X, params object[] ap) { } #endif - /* - ** Macros for performance tracing. Normally turned off. Only works - ** on i486 hardware. - */ + /* +** Macros for performance tracing. Normally turned off. Only works +** on i486 hardware. +*/ #if SQLITE_PERFORMANCE_TRACE /* @@ -69,16 +73,16 @@ static void OSTRACE( string X, params object[] ap) { } //#define TIMER_END g_elapsed=sqlite3Hwtime()-g_start //#define TIMER_ELAPSED g_elapsed #else - const int TIMER_START = 0; //#define TIMER_START - const int TIMER_END = 0; //#define TIMER_END - const int TIMER_ELAPSED = 0; //#define TIMER_ELAPSED ((sqlite_u3264)0) + const int TIMER_START = 0; //#define TIMER_START + const int TIMER_END = 0; //#define TIMER_END + const int TIMER_ELAPSED = 0; //#define TIMER_ELAPSED ((sqlite_u3264)0) #endif - /* - ** If we compile with the SQLITE_TEST macro set, then the following block - ** of code will give us the ability to simulate a disk I/O error. This - ** is used for testing the I/O recovery logic. - */ + /* +** If we compile with the SQLITE_TEST macro set, then the following block +** of code will give us the ability to simulate a disk I/O error. This +** is used for testing the I/O recovery logic. +*/ #if SQLITE_TEST #if !TCLSH @@ -187,17 +191,17 @@ static bool SimulateDiskfullError() return false; } #else - static bool SimulateIOError() { return false; } - //#define SimulateIOErrorBenign(X) - static void SimulateIOErrorBenign(int x) { } + static bool SimulateIOError() { return false; } +//#define SimulateIOErrorBenign(X) + static void SimulateIOErrorBenign( int x ) { } - //#define SimulateIOError(A) - //#define SimulateDiskfullError(A) +//#define SimulateIOError(A) +//#define SimulateDiskfullError(A) #endif - /* - ** When testing, keep a count of the number of open files. - */ + /* +** When testing, keep a count of the number of open files. +*/ #if SQLITE_TEST #if !TCLSH static int sqlite3_open_file_count = 0; @@ -214,8 +218,8 @@ static void OpenCounter( int X ) #endif } #else - //#define OpenCounter(X) +//#define OpenCounter(X) #endif - //#endif //* !_OS_COMMON_H_) */ - } + //#endif //* !_OS_COMMON_H_) */ + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/os_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/os_h.cs index f48b14312..2c54c9de8 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/os_h.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/os_h.cs @@ -1,107 +1,109 @@ #define SQLITE_OS_WIN using u32 = System.UInt32; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2001 September 16 - ** - ** 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 header file (together with is companion C source-code file - ** "os.c") attempt to abstract the underlying operating system so that - ** the SQLite library will work on both POSIX and windows systems. - ** - ** This header file is #include-ed by sqliteInt.h and thus ends up - ** being included by every source file. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 2001 September 16 + ** + ** 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 header file (together with is companion C source-code file + ** "os.c") attempt to abstract the underlying operating system so that + ** the SQLite library will work on both POSIX and windows systems. + ** + ** This header file is #include-ed by sqliteInt.h and thus ends up + ** being included by every source file. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ #if !_SQLITE_OS_H_ - //#define _SQLITE_OS_H_ + //#define _SQLITE_OS_H_ - /* - ** Figure out if we are dealing with Unix, Windows, or some other - ** operating system. After the following block of preprocess macros, - ** all of SQLITE_OS_UNIX, SQLITE_OS_WIN, SQLITE_OS_OS2, and SQLITE_OS_OTHER - ** will defined to either 1 or 0. One of the four will be 1. The other - ** three will be 0. - */ - //#if (SQLITE_OS_OTHER) - //# if SQLITE_OS_OTHER==1 - //# undef SQLITE_OS_UNIX - //# define SQLITE_OS_UNIX 0 - //# undef SQLITE_OS_WIN - //# define SQLITE_OS_WIN 0 - //# undef SQLITE_OS_OS2 - //# define SQLITE_OS_OS2 0 - //# else - //# undef SQLITE_OS_OTHER - //# endif - //#endif - //#if !(SQLITE_OS_UNIX) && !SQLITE_OS_OTHER) - //# define SQLITE_OS_OTHER 0 - //# ifndef SQLITE_OS_WIN - //# if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__) - //# define SQLITE_OS_WIN 1 - //# define SQLITE_OS_UNIX 0 - //# define SQLITE_OS_OS2 0 - //# elif defined(__EMX__) || defined(_OS2) || defined(OS2) || defined(_OS2_) || defined(__OS2__) - //# define SQLITE_OS_WIN 0 - //# define SQLITE_OS_UNIX 0 - //# define SQLITE_OS_OS2 1 - //# else - //# define SQLITE_OS_WIN 0 - //# define SQLITE_OS_UNIX 1 - //# define SQLITE_OS_OS2 0 - //# endif - //# else - //# define SQLITE_OS_UNIX 0 - //# define SQLITE_OS_OS2 0 - //# endif - //#else - //# ifndef SQLITE_OS_WIN - //# define SQLITE_OS_WIN 0 - //# endif - //#endif + /* + ** Figure out if we are dealing with Unix, Windows, or some other + ** operating system. After the following block of preprocess macros, + ** all of SQLITE_OS_UNIX, SQLITE_OS_WIN, SQLITE_OS_OS2, and SQLITE_OS_OTHER + ** will defined to either 1 or 0. One of the four will be 1. The other + ** three will be 0. + */ + //#if (SQLITE_OS_OTHER) + //# if SQLITE_OS_OTHER==1 + //# undef SQLITE_OS_UNIX + //# define SQLITE_OS_UNIX 0 + //# undef SQLITE_OS_WIN + //# define SQLITE_OS_WIN 0 + //# undef SQLITE_OS_OS2 + //# define SQLITE_OS_OS2 0 + //# else + //# undef SQLITE_OS_OTHER + //# endif + //#endif + //#if !(SQLITE_OS_UNIX) && !SQLITE_OS_OTHER) + //# define SQLITE_OS_OTHER 0 + //# ifndef SQLITE_OS_WIN + //# if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__) + //# define SQLITE_OS_WIN 1 + //# define SQLITE_OS_UNIX 0 + //# define SQLITE_OS_OS2 0 + //# elif defined(__EMX__) || defined(_OS2) || defined(OS2) || defined(_OS2_) || defined(__OS2__) + //# define SQLITE_OS_WIN 0 + //# define SQLITE_OS_UNIX 0 + //# define SQLITE_OS_OS2 1 + //# else + //# define SQLITE_OS_WIN 0 + //# define SQLITE_OS_UNIX 1 + //# define SQLITE_OS_OS2 0 + //# endif + //# else + //# define SQLITE_OS_UNIX 0 + //# define SQLITE_OS_OS2 0 + //# endif + //#else + //# ifndef SQLITE_OS_WIN + //# define SQLITE_OS_WIN 0 + //# endif + //#endif - const bool SQLITE_OS_WIN = true; - const bool SQLITE_OS_UNIX = false; - const bool SQLITE_OS_OS2 = false; + const bool SQLITE_OS_WIN = true; + const bool SQLITE_OS_UNIX = false; + const bool SQLITE_OS_OS2 = false; - /* - ** Determine if we are dealing with WindowsCE - which has a much - ** reduced API. - */ - //#if (_WIN32_WCE) - //# define SQLITE_OS_WINCE 1 - //#else - //# define SQLITE_OS_WINCE 0 - //#endif + /* + ** Determine if we are dealing with WindowsCE - which has a much + ** reduced API. + */ + //#if (_WIN32_WCE) + //# define SQLITE_OS_WINCE 1 + //#else + //# define SQLITE_OS_WINCE 0 + //#endif - /* - ** Define the maximum size of a temporary filename - */ + /* + ** Define the maximum size of a temporary filename + */ #if SQLITE_OS_WIN - //# include - const int MAX_PATH = 260; - const int SQLITE_TEMPNAME_SIZE = (MAX_PATH + 50); //# define SQLITE_TEMPNAME_SIZE (MAX_PATH+50) + //# include + const int MAX_PATH = 260; + const int SQLITE_TEMPNAME_SIZE = ( MAX_PATH + 50 ); //# define SQLITE_TEMPNAME_SIZE (MAX_PATH+50) #elif SQLITE_OS_OS2 -#if FALSE //(__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 3) && OS2_HIGH_MEMORY) +# if FALSE //(__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 3) && OS2_HIGH_MEMORY) //# include /* has to be included before os2.h for linking to work */ -#endif +# endif //# define INCL_DOSDATETIME //# define INCL_DOSFILEMGR //# define INCL_DOSERRORS @@ -116,187 +118,187 @@ public partial class Sqlite3 { //# define SQLITE_TEMPNAME_SIZE 200 #endif - /* If the SET_FULLSYNC macro is not defined above, then make it - ** a no-op - */ - //#if !SET_FULLSYNC - //# define SET_FULLSYNC(x,y) - //#endif + /* If the SET_FULLSYNC macro is not defined above, then make it +** a no-op +*/ + //#if !SET_FULLSYNC + //# define SET_FULLSYNC(x,y) + //#endif - /* - ** The default size of a disk sector - */ + /* + ** The default size of a disk sector + */ #if !SQLITE_DEFAULT_SECTOR_SIZE - const int SQLITE_DEFAULT_SECTOR_SIZE = 512;//# define SQLITE_DEFAULT_SECTOR_SIZE 512 + const int SQLITE_DEFAULT_SECTOR_SIZE = 512;//# define SQLITE_DEFAULT_SECTOR_SIZE 512 #endif - /* - ** Temporary files are named starting with this prefix followed by 16 random - ** alphanumeric characters, and no file extension. They are stored in the - ** OS's standard temporary file directory, and are deleted prior to exit. - ** If sqlite is being embedded in another program, you may wish to change the - ** prefix to reflect your program's name, so that if your program exits - ** prematurely, old temporary files can be easily identified. This can be done - ** using -DSQLITE_TEMP_FILE_PREFIX=myprefix_ on the compiler command line. - ** - ** 2006-10-31: The default prefix used to be "sqlite_". But then - ** Mcafee started using SQLite in their anti-virus product and it - ** started putting files with the "sqlite" name in the c:/temp folder. - ** This annoyed many windows users. Those users would then do a - ** Google search for "sqlite", find the telephone numbers of the - ** developers and call to wake them up at night and complain. - ** For this reason, the default name prefix is changed to be "sqlite" - ** spelled backwards. So the temp files are still identified, but - ** anybody smart enough to figure out the code is also likely smart - ** enough to know that calling the developer will not help get rid - ** of the file. - */ + /* +** Temporary files are named starting with this prefix followed by 16 random +** alphanumeric characters, and no file extension. They are stored in the +** OS's standard temporary file directory, and are deleted prior to exit. +** If sqlite is being embedded in another program, you may wish to change the +** prefix to reflect your program's name, so that if your program exits +** prematurely, old temporary files can be easily identified. This can be done +** using -DSQLITE_TEMP_FILE_PREFIX=myprefix_ on the compiler command line. +** +** 2006-10-31: The default prefix used to be "sqlite_". But then +** Mcafee started using SQLite in their anti-virus product and it +** started putting files with the "sqlite" name in the c:/temp folder. +** This annoyed many windows users. Those users would then do a +** Google search for "sqlite", find the telephone numbers of the +** developers and call to wake them up at night and complain. +** For this reason, the default name prefix is changed to be "sqlite" +** spelled backwards. So the temp files are still identified, but +** anybody smart enough to figure out the code is also likely smart +** enough to know that calling the developer will not help get rid +** of the file. +*/ #if !SQLITE_TEMP_FILE_PREFIX - const string SQLITE_TEMP_FILE_PREFIX = "etilqs_"; //# define SQLITE_TEMP_FILE_PREFIX "etilqs_" + const string SQLITE_TEMP_FILE_PREFIX = "etilqs_"; //# define SQLITE_TEMP_FILE_PREFIX "etilqs_" #endif - /* - ** The following values may be passed as the second argument to - ** sqlite3OsLock(). The various locks exhibit the following semantics: + /* +** The following values may be passed as the second argument to +** sqlite3OsLock(). The various locks exhibit the following semantics: +** +** SHARED: Any number of processes may hold a SHARED lock simultaneously. +** RESERVED: A single process may hold a RESERVED lock on a file at +** any time. Other processes may hold and obtain new SHARED locks. +** PENDING: A single process may hold a PENDING lock on a file at +** any one time. Existing SHARED locks may persist, but no new +** SHARED locks may be obtained by other processes. +** EXCLUSIVE: An EXCLUSIVE lock precludes all other locks. +** +** PENDING_LOCK may not be passed directly to sqlite3OsLock(). Instead, a +** process that requests an EXCLUSIVE lock may actually obtain a PENDING +** lock. This can be upgraded to an EXCLUSIVE lock by a subsequent call to +** sqlite3OsLock(). +*/ + const int NO_LOCK = 0; + const int SHARED_LOCK = 1; + const int RESERVED_LOCK = 2; + const int PENDING_LOCK = 3; + const int EXCLUSIVE_LOCK = 4; + + /* + ** File Locking Notes: (Mostly about windows but also some info for Unix) + ** + ** We cannot use LockFileEx() or UnlockFileEx() on Win95/98/ME because + ** those functions are not available. So we use only LockFile() and + ** UnlockFile(). + ** + ** LockFile() prevents not just writing but also reading by other processes. + ** A SHARED_LOCK is obtained by locking a single randomly-chosen + ** byte out of a specific range of bytes. The lock byte is obtained at + ** random so two separate readers can probably access the file at the + ** same time, unless they are unlucky and choose the same lock byte. + ** An EXCLUSIVE_LOCK is obtained by locking all bytes in the range. + ** There can only be one writer. A RESERVED_LOCK is obtained by locking + ** a single byte of the file that is designated as the reserved lock byte. + ** A PENDING_LOCK is obtained by locking a designated byte different from + ** the RESERVED_LOCK byte. + ** + ** On WinNT/2K/XP systems, LockFileEx() and UnlockFileEx() are available, + ** which means we can use reader/writer locks. When reader/writer locks + ** are used, the lock is placed on the same range of bytes that is used + ** for probabilistic locking in Win95/98/ME. Hence, the locking scheme + ** will support two or more Win95 readers or two or more WinNT readers. + ** But a single Win95 reader will lock out all WinNT readers and a single + ** WinNT reader will lock out all other Win95 readers. + ** + ** The following #defines specify the range of bytes used for locking. + ** SHARED_SIZE is the number of bytes available in the pool from which + ** a random byte is selected for a shared lock. The pool of bytes for + ** shared locks begins at SHARED_FIRST. ** - ** SHARED: Any number of processes may hold a SHARED lock simultaneously. - ** RESERVED: A single process may hold a RESERVED lock on a file at - ** any time. Other processes may hold and obtain new SHARED locks. - ** PENDING: A single process may hold a PENDING lock on a file at - ** any one time. Existing SHARED locks may persist, but no new - ** SHARED locks may be obtained by other processes. - ** EXCLUSIVE: An EXCLUSIVE lock precludes all other locks. + ** The same locking strategy and + ** byte ranges are used for Unix. This leaves open the possiblity of having + ** clients on win95, winNT, and unix all talking to the same shared file + ** and all locking correctly. To do so would require that samba (or whatever + ** tool is being used for file sharing) implements locks correctly between + ** windows and unix. I'm guessing that isn't likely to happen, but by + ** using the same locking range we are at least open to the possibility. + ** + ** Locking in windows is manditory. For this reason, we cannot store + ** actual data in the bytes used for locking. The pager never allocates + ** the pages involved in locking therefore. SHARED_SIZE is selected so + ** that all locks will fit on a single page even at the minimum page size. + ** PENDING_BYTE defines the beginning of the locks. By default PENDING_BYTE + ** is set high so that we don't have to allocate an unused page except + ** for very large databases. But one should test the page skipping logic + ** by setting PENDING_BYTE low and running the entire regression suite. + ** + ** Changing the value of PENDING_BYTE results in a subtly incompatible + ** file format. Depending on how it is changed, you might not notice + ** the incompatibility right away, even running a full regression test. + ** The default location of PENDING_BYTE is the first byte past the + ** 1GB boundary. ** - ** PENDING_LOCK may not be passed directly to sqlite3OsLock(). Instead, a - ** process that requests an EXCLUSIVE lock may actually obtain a PENDING - ** lock. This can be upgraded to an EXCLUSIVE lock by a subsequent call to - ** sqlite3OsLock(). */ - const int NO_LOCK = 0; - const int SHARED_LOCK = 1; - const int RESERVED_LOCK = 2; - const int PENDING_LOCK = 3; - const int EXCLUSIVE_LOCK = 4; - - /* - ** File Locking Notes: (Mostly about windows but also some info for Unix) - ** - ** We cannot use LockFileEx() or UnlockFileEx() on Win95/98/ME because - ** those functions are not available. So we use only LockFile() and - ** UnlockFile(). - ** - ** LockFile() prevents not just writing but also reading by other processes. - ** A SHARED_LOCK is obtained by locking a single randomly-chosen - ** byte out of a specific range of bytes. The lock byte is obtained at - ** random so two separate readers can probably access the file at the - ** same time, unless they are unlucky and choose the same lock byte. - ** An EXCLUSIVE_LOCK is obtained by locking all bytes in the range. - ** There can only be one writer. A RESERVED_LOCK is obtained by locking - ** a single byte of the file that is designated as the reserved lock byte. - ** A PENDING_LOCK is obtained by locking a designated byte different from - ** the RESERVED_LOCK byte. - ** - ** On WinNT/2K/XP systems, LockFileEx() and UnlockFileEx() are available, - ** which means we can use reader/writer locks. When reader/writer locks - ** are used, the lock is placed on the same range of bytes that is used - ** for probabilistic locking in Win95/98/ME. Hence, the locking scheme - ** will support two or more Win95 readers or two or more WinNT readers. - ** But a single Win95 reader will lock out all WinNT readers and a single - ** WinNT reader will lock out all other Win95 readers. - ** - ** The following #defines specify the range of bytes used for locking. - ** SHARED_SIZE is the number of bytes available in the pool from which - ** a random byte is selected for a shared lock. The pool of bytes for - ** shared locks begins at SHARED_FIRST. - ** - ** The same locking strategy and - ** byte ranges are used for Unix. This leaves open the possiblity of having - ** clients on win95, winNT, and unix all talking to the same shared file - ** and all locking correctly. To do so would require that samba (or whatever - ** tool is being used for file sharing) implements locks correctly between - ** windows and unix. I'm guessing that isn't likely to happen, but by - ** using the same locking range we are at least open to the possibility. - ** - ** Locking in windows is manditory. For this reason, we cannot store - ** actual data in the bytes used for locking. The pager never allocates - ** the pages involved in locking therefore. SHARED_SIZE is selected so - ** that all locks will fit on a single page even at the minimum page size. - ** PENDING_BYTE defines the beginning of the locks. By default PENDING_BYTE - ** is set high so that we don't have to allocate an unused page except - ** for very large databases. But one should test the page skipping logic - ** by setting PENDING_BYTE low and running the entire regression suite. - ** - ** Changing the value of PENDING_BYTE results in a subtly incompatible - ** file format. Depending on how it is changed, you might not notice - ** the incompatibility right away, even running a full regression test. - ** The default location of PENDING_BYTE is the first byte past the - ** 1GB boundary. - ** - */ #if SQLITE_OMIT_WSD //# define PENDING_BYTE (0x40000000) static int PENDING_BYTE = 0x40000000; #else - //# define PENDING_BYTE sqlite3PendingByte - static int PENDING_BYTE = 0x40000000; + //# define PENDING_BYTE sqlite3PendingByte + static int PENDING_BYTE = 0x40000000; #endif - static int RESERVED_BYTE = (PENDING_BYTE + 1); - static int SHARED_FIRST = (PENDING_BYTE + 2); - static int SHARED_SIZE = 510; + static int RESERVED_BYTE = ( PENDING_BYTE + 1 ); + static int SHARED_FIRST = ( PENDING_BYTE + 2 ); + static int SHARED_SIZE = 510; - /* - ** Wrapper around OS specific sqlite3_os_init() function. - */ - //int sqlite3OsInit(void); + /* + ** Wrapper around OS specific sqlite3_os_init() function. + */ + //int sqlite3OsInit(void); - /* - ** Functions for accessing sqlite3_file methods - */ - //int sqlite3OsClose(sqlite3_file); - //int sqlite3OsRead(sqlite3_file*, void*, int amt, i64 offset); - //int sqlite3OsWrite(sqlite3_file*, const void*, int amt, i64 offset); - //int sqlite3OsTruncate(sqlite3_file*, i64 size); - //int sqlite3OsSync(sqlite3_file*, int); - //int sqlite3OsFileSize(sqlite3_file*, i64 pSize); - //int sqlite3OsLock(sqlite3_file*, int); - //int sqlite3OsUnlock(sqlite3_file*, int); - //int sqlite3OsCheckReservedLock(sqlite3_file *id, int pResOut); - //int sqlite3OsFileControl(sqlite3_file*,int,void); - //#define SQLITE_FCNTL_DB_UNCHANGED 0xca093fa0 - const u32 SQLITE_FCNTL_DB_UNCHANGED = 0xca093fa0; + /* + ** Functions for accessing sqlite3_file methods + */ + //int sqlite3OsClose(sqlite3_file); + //int sqlite3OsRead(sqlite3_file*, void*, int amt, i64 offset); + //int sqlite3OsWrite(sqlite3_file*, const void*, int amt, i64 offset); + //int sqlite3OsTruncate(sqlite3_file*, i64 size); + //int sqlite3OsSync(sqlite3_file*, int); + //int sqlite3OsFileSize(sqlite3_file*, i64 pSize); + //int sqlite3OsLock(sqlite3_file*, int); + //int sqlite3OsUnlock(sqlite3_file*, int); + //int sqlite3OsCheckReservedLock(sqlite3_file *id, int pResOut); + //int sqlite3OsFileControl(sqlite3_file*,int,void); + //#define SQLITE_FCNTL_DB_UNCHANGED 0xca093fa0 + const u32 SQLITE_FCNTL_DB_UNCHANGED = 0xca093fa0; - //int sqlite3OsSectorSize(sqlite3_file *id); - //int sqlite3OsDeviceCharacteristics(sqlite3_file *id); - //int sqlite3OsShmMap(sqlite3_file *,int,int,int,object volatile *); - //int sqlite3OsShmLock(sqlite3_file *id, int, int, int); - //void sqlite3OsShmBarrier(sqlite3_file *id); - //int sqlite3OsShmUnmap(sqlite3_file *id, int); + //int sqlite3OsSectorSize(sqlite3_file *id); + //int sqlite3OsDeviceCharacteristics(sqlite3_file *id); + //int sqlite3OsShmMap(sqlite3_file *,int,int,int,object volatile *); + //int sqlite3OsShmLock(sqlite3_file *id, int, int, int); + //void sqlite3OsShmBarrier(sqlite3_file *id); + //int sqlite3OsShmUnmap(sqlite3_file *id, int); - /* - ** Functions for accessing sqlite3_vfs methods - */ - //int sqlite3OsOpen(sqlite3_vfs *, string , sqlite3_file*, int, int ); - //int sqlite3OsDelete(sqlite3_vfs *, string , int); - //int sqlite3OsAccess(sqlite3_vfs *, string , int, int pResOut); - //int sqlite3OsFullPathname(sqlite3_vfs *, string , int, char ); + /* + ** Functions for accessing sqlite3_vfs methods + */ + //int sqlite3OsOpen(sqlite3_vfs *, string , sqlite3_file*, int, int ); + //int sqlite3OsDelete(sqlite3_vfs *, string , int); + //int sqlite3OsAccess(sqlite3_vfs *, string , int, int pResOut); + //int sqlite3OsFullPathname(sqlite3_vfs *, string , int, char ); #if !SQLITE_OMIT_LOAD_EXTENSION - //void *sqlite3OsDlOpen(sqlite3_vfs *, string ); - //void sqlite3OsDlError(sqlite3_vfs *, int, char ); - //void (*sqlite3OsDlSym(sqlite3_vfs *, object *, string ))(void); - //void sqlite3OsDlClose(sqlite3_vfs *, object ); + //void *sqlite3OsDlOpen(sqlite3_vfs *, string ); + //void sqlite3OsDlError(sqlite3_vfs *, int, char ); + //void (*sqlite3OsDlSym(sqlite3_vfs *, object *, string ))(void); + //void sqlite3OsDlClose(sqlite3_vfs *, object ); #endif - //int sqlite3OsRandomness(sqlite3_vfs *, int, char ); - //int sqlite3OsSleep(sqlite3_vfs *, int); - //int sqlite3OsCurrentTimeInt64(sqlite3_vfs *, sqlite3_int64); + //int sqlite3OsRandomness(sqlite3_vfs *, int, char ); + //int sqlite3OsSleep(sqlite3_vfs *, int); + //int sqlite3OsCurrentTimeInt64(sqlite3_vfs *, sqlite3_int64); - /* - ** Convenience functions for opening and closing files using - ** sqlite3Malloc() to obtain space for the file-handle structure. - */ - //int sqlite3OsOpenMalloc(sqlite3_vfs *, string , sqlite3_file **, int,int); - //int sqlite3OsCloseFree(sqlite3_file ); + /* + ** Convenience functions for opening and closing files using + ** sqlite3Malloc() to obtain space for the file-handle structure. + */ + //int sqlite3OsOpenMalloc(sqlite3_vfs *, string , sqlite3_file **, int,int); + //int sqlite3OsCloseFree(sqlite3_file ); #endif // * _SQLITE_OS_H_ */ - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/os_win_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/os_win_c.cs index 2e691efd0..014b0a2da 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/os_win_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/os_win_c.cs @@ -4,9 +4,9 @@ using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; +using System.Runtime.Versioning; using System.Text; using System.Threading; - using DWORD = System.UInt64; using HANDLE = System.IntPtr; using i64 = System.Int64; @@ -21,101 +21,103 @@ #elif WINDOWS_PHONE || SQLITE_SILVERLIGHT using System.IO.IsolatedStorage; #endif -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2004 May 22 - ** - ** 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 contains code that is specific to windows. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" -#if SQLITE_OS_WIN // * This file is used for windows only */ - - /* - ** A Note About Memory Allocation: +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 2004 May 22 + ** + ** 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 driver uses malloc()/free() directly rather than going through - ** the SQLite-wrappers sqlite3Malloc()/sqlite3DbFree(db,ref ). Those wrappers - ** are designed for use on embedded systems where memory is scarce and - ** malloc failures happen frequently. Win32 does not typically run on - ** embedded systems, and when it does the developers normally have bigger - ** problems to worry about than running out of memory. So there is not - ** a compelling need to use the wrappers. + ****************************************************************************** ** - ** But there is a good reason to not use the wrappers. If we use the - ** wrappers then we will get simulated malloc() failures within this - ** driver. And that causes all kinds of problems for our tests. We - ** could enhance SQLite to deal with simulated malloc failures within - ** the OS driver, but the code to deal with those failure would not - ** be exercised on Linux (which does not need to malloc() in the driver) - ** and so we would have difficulty writing coverage tests for that - ** code. Better to leave the code out, we think. + ** This file contains code that is specific to windows. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library ** - ** The point of this discussion is as follows: When creating a new - ** OS layer for an embedded system, if you use this file as an example, - ** avoid the use of malloc()/free(). Those routines work ok on windows - ** desktops but not so well in embedded systems. + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* */ + //#include "sqliteInt.h" +#if SQLITE_OS_WIN // * This file is used for windows only */ + + /* +** A Note About Memory Allocation: +** +** This driver uses malloc()/free() directly rather than going through +** the SQLite-wrappers sqlite3Malloc()/sqlite3DbFree(db,ref ). Those wrappers +** are designed for use on embedded systems where memory is scarce and +** malloc failures happen frequently. Win32 does not typically run on +** embedded systems, and when it does the developers normally have bigger +** problems to worry about than running out of memory. So there is not +** a compelling need to use the wrappers. +** +** But there is a good reason to not use the wrappers. If we use the +** wrappers then we will get simulated malloc() failures within this +** driver. And that causes all kinds of problems for our tests. We +** could enhance SQLite to deal with simulated malloc failures within +** the OS driver, but the code to deal with those failure would not +** be exercised on Linux (which does not need to malloc() in the driver) +** and so we would have difficulty writing coverage tests for that +** code. Better to leave the code out, we think. +** +** The point of this discussion is as follows: When creating a new +** OS layer for an embedded system, if you use this file as an example, +** avoid the use of malloc()/free(). Those routines work ok on windows +** desktops but not so well in embedded systems. +*/ - //#include + //#include #if __CYGWIN__ //# include #endif - /* - ** Macros used to determine whether or not to use threads. - */ + /* +** Macros used to determine whether or not to use threads. +*/ #if THREADSAFE //# define SQLITE_W32_THREADS 1 #endif - /* - ** Include code that is common to all os_*.c files - */ - //#include "os_common.h" + /* +** Include code that is common to all os_*.c files +*/ + //#include "os_common.h" - /* - ** Some microsoft compilers lack this definition. - */ + /* + ** Some microsoft compilers lack this definition. + */ #if !INVALID_FILE_ATTRIBUTES - //# define INVALID_FILE_ATTRIBUTES ((DWORD)-1) - const int INVALID_FILE_ATTRIBUTES = -1; + //# define INVALID_FILE_ATTRIBUTES ((DWORD)-1) + const int INVALID_FILE_ATTRIBUTES = -1; #endif - /* - ** Determine if we are dealing with WindowsCE - which has a much - ** reduced API. - */ + /* +** Determine if we are dealing with WindowsCE - which has a much +** reduced API. +*/ #if SQLITE_OS_WINCE //# define AreFileApisANSI() 1 //# define GetDiskFreeSpaceW() 0 #endif - /* Forward references */ - //typedef struct winShm winShm; /* A connection to shared-memory */ - //typedef struct winShmNode winShmNode; /* A region of shared-memory */ + /* Forward references */ + //typedef struct winShm winShm; /* A connection to shared-memory */ + //typedef struct winShmNode winShmNode; /* A region of shared-memory */ - /* - ** WinCE lacks native support for file locking so we have to fake it - ** with some code of our own. - */ + /* + ** WinCE lacks native support for file locking so we have to fake it + ** with some code of our own. + */ #if SQLITE_OS_WINCE typedef struct winceLock { int nReaders; /* Number of reader locks obtained */ @@ -125,32 +127,33 @@ typedef struct winceLock { } winceLock; #endif - private static LockingStrategy lockingStrategy = HelperMethods.IsRunningMediumTrust() ? new MediumTrustLockingStrategy() : new LockingStrategy(); + private static LockingStrategy lockingStrategy = HelperMethods.IsRunningMediumTrust() ? new MediumTrustLockingStrategy() : new LockingStrategy(); - /* - ** The winFile structure is a subclass of sqlite3_file* specific to the win32 - ** portability layer. - */ - //typedef struct sqlite3_file sqlite3_file; - public partial class sqlite3_file { - public sqlite3_vfs pVfs; /* The VFS used to open this file */ + /* + ** The winFile structure is a subclass of sqlite3_file* specific to the win32 + ** portability layer. + */ + //typedef struct sqlite3_file sqlite3_file; + public partial class sqlite3_file + { + public sqlite3_vfs pVfs; /* The VFS used to open this file */ #if SQLITE_WINRT public IRandomAccessStream fs; #else - public FileStream fs; /* Filestream access to this file*/ + public FileStream fs; /* Filestream access to this file*/ #endif - // public HANDLE h; /* Handle for accessing the file */ - public int locktype; /* Type of lock currently held on this file */ - public int sharedLockByte; /* Randomly chosen byte used as a shared lock */ - public DWORD lastErrno; /* The Windows errno from the last I/O error */ - public DWORD sectorSize; /* Sector size of the device file is on */ + // public HANDLE h; /* Handle for accessing the file */ + public int locktype; /* Type of lock currently held on this file */ + public int sharedLockByte; /* Randomly chosen byte used as a shared lock */ + public DWORD lastErrno; /* The Windows errno from the last I/O error */ + public DWORD sectorSize; /* Sector size of the device file is on */ #if !SQLITE_OMIT_WAL public winShm pShm; /* Instance of shared memory on this file */ #else - public object pShm; /* DUMMY Instance of shared memory on this file */ + public object pShm; /* DUMMY Instance of shared memory on this file */ #endif - public string zPath; /* Full pathname of this file */ - public int szChunk; /* Chunk size configured by FCNTL_CHUNK_SIZE */ + public string zPath; /* Full pathname of this file */ + public int szChunk; /* Chunk size configured by FCNTL_CHUNK_SIZE */ #if SQLITE_OS_WINCE Wstring zDeleteOnClose; /* Name of file to delete when closing */ HANDLE hMutex; /* Mutex used to control access to shared lock */ @@ -159,317 +162,321 @@ public partial class sqlite3_file { winceLock *shared; /* Global shared lock memory for the file */ #endif - public void Clear() { - pMethods = null; - fs = null; - locktype = 0; - sharedLockByte = 0; - lastErrno = 0; - sectorSize = 0; - } - }; + public void Clear() + { + pMethods = null; + fs = null; + locktype = 0; + sharedLockByte = 0; + lastErrno = 0; + sectorSize = 0; + } + }; - /* - ** Forward prototypes. - */ - //static int getSectorSize( - // sqlite3_vfs *pVfs, - // string zRelative /* UTF-8 file name */ - //); + /* + ** Forward prototypes. + */ + //static int getSectorSize( + // sqlite3_vfs *pVfs, + // string zRelative /* UTF-8 file name */ + //); - /* - ** The following variable is (normally) set once and never changes - ** thereafter. It records whether the operating system is Win95 - ** or WinNT. - ** - ** 0: Operating system unknown. - ** 1: Operating system is Win95. - ** 2: Operating system is WinNT. - ** - ** In order to facilitate testing on a WinNT system, the test fixture - ** can manually set this value to 1 to emulate Win98 behavior. - */ + /* + ** The following variable is (normally) set once and never changes + ** thereafter. It records whether the operating system is Win95 + ** or WinNT. + ** + ** 0: Operating system unknown. + ** 1: Operating system is Win95. + ** 2: Operating system is WinNT. + ** + ** In order to facilitate testing on a WinNT system, the test fixture + ** can manually set this value to 1 to emulate Win98 behavior. + */ #if SQLITE_TEST int sqlite3_os_type = 0; #else - static int sqlite3_os_type = 0; +static int sqlite3_os_type = 0; #endif - /* - ** Return true (non-zero) if we are running under WinNT, Win2K, WinXP, - ** or WinCE. Return false (zero) for Win95, Win98, or WinME. - ** - ** Here is an interesting observation: Win95, Win98, and WinME lack - ** the LockFileEx() API. But we can still statically link against that - ** 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. - */ + /* +** Return true (non-zero) if we are running under WinNT, Win2K, WinXP, +** or WinCE. Return false (zero) for Win95, Win98, or WinME. +** +** Here is an interesting observation: Win95, Win98, and WinME lack +** the LockFileEx() API. But we can still statically link against that +** 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. +*/ #if SQLITE_OS_WINCE //# define isNT() (1) #elif SQLITE_WINRT static bool isNT() { return true; } #else - static bool isNT() { - //if (sqlite3_os_type == 0) - //{ - // OSVERSIONINFO sInfo; - // sInfo.dwOSVersionInfoSize = sInfo.Length; - // GetVersionEx(&sInfo); - // sqlite3_os_type = sInfo.dwPlatformId == VER_PLATFORM_WIN32_NT ? 2 : 1; - //} - //return sqlite3_os_type == 2; - return Environment.OSVersion.Platform == PlatformID.Win32NT || Environment.OSVersion.Platform == PlatformID.Unix; - } + static bool isNT() + { + //if (sqlite3_os_type == 0) + //{ + // OSVERSIONINFO sInfo; + // sInfo.dwOSVersionInfoSize = sInfo.Length; + // GetVersionEx(&sInfo); + // sqlite3_os_type = sInfo.dwPlatformId == VER_PLATFORM_WIN32_NT ? 2 : 1; + //} + //return sqlite3_os_type == 2; + return Environment.OSVersion.Platform == PlatformID.Win32NT || Environment.OSVersion.Platform == PlatformID.Unix; + } #endif // * SQLITE_OS_WINCE */ - /* - ** Convert a UTF-8 string to microsoft unicode (UTF-16?). - ** - ** Space to hold the returned string is obtained from malloc. - */ - //static WCHAR *utf8ToUnicode(string zFilename){ - // int nChar; - // Wstring zWideFilename; - - // nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0); - // zWideFilename = malloc( nChar*sizeof(zWideFilename[0]) ); - // if( zWideFilename==0 ){ - // return 0; - // } - // nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, zWideFilename, nChar); - // if( nChar==0 ){ - // free(zWideFilename); - // zWideFileName = ""; - // } - // return zWideFilename; - //} - - /* - ** Convert microsoft unicode to UTF-8. Space to hold the returned string is - ** obtained from malloc(). - */ - //static char *unicodeToUtf8(const Wstring zWideFilename){ - // int nByte; - // string zFilename; - - // nByte = WideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, 0, 0, 0, 0); - // zFilename = malloc( nByte ); - // if( zFilename==0 ){ - // return 0; - // } - // nByte = WideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, zFilename, nByte, - // 0, 0); - // if( nByte == 0 ){ - // free(zFilename); - // zFileName = ""; - // } - // return zFilename; - //} + /* +** Convert a UTF-8 string to microsoft unicode (UTF-16?). +** +** Space to hold the returned string is obtained from malloc. +*/ + //static WCHAR *utf8ToUnicode(string zFilename){ + // int nChar; + // Wstring zWideFilename; + + // nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0); + // zWideFilename = malloc( nChar*sizeof(zWideFilename[0]) ); + // if( zWideFilename==0 ){ + // return 0; + // } + // nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, zWideFilename, nChar); + // if( nChar==0 ){ + // free(zWideFilename); + // zWideFileName = ""; + // } + // return zWideFilename; + //} - /* - ** Convert an ansi string to microsoft unicode, based on the - ** current codepage settings for file apis. - ** - ** Space to hold the returned string is obtained - ** from malloc. - */ - //static WCHAR *mbcsToUnicode(string zFilename){ - // int nByte; - // Wstring zMbcsFilename; - // int codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP; - - // nByte = MultiByteToWideChar(codepage, 0, zFilename, -1, NULL,0)*WCHAR.Length; - // zMbcsFilename = malloc( nByte*sizeof(zMbcsFilename[0]) ); - // if( zMbcsFilename==0 ){ - // return 0; - // } - // nByte = MultiByteToWideChar(codepage, 0, zFilename, -1, zMbcsFilename, nByte); - // if( nByte==0 ){ - // free(zMbcsFilename); - // zMbcsFileName = ""; - // } - // return zMbcsFilename; - //} + /* + ** Convert microsoft unicode to UTF-8. Space to hold the returned string is + ** obtained from malloc(). + */ + //static char *unicodeToUtf8(const Wstring zWideFilename){ + // int nByte; + // string zFilename; + + // nByte = WideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, 0, 0, 0, 0); + // zFilename = malloc( nByte ); + // if( zFilename==0 ){ + // return 0; + // } + // nByte = WideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, zFilename, nByte, + // 0, 0); + // if( nByte == 0 ){ + // free(zFilename); + // zFileName = ""; + // } + // return zFilename; + //} - /* - ** Convert microsoft unicode to multibyte character string, based on the - ** user's Ansi codepage. - ** - ** Space to hold the returned string is obtained from - ** malloc(). - */ - //static char *unicodeToMbcs(const Wstring zWideFilename){ - // int nByte; - // string zFilename; - // int codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP; - - // nByte = WideCharToMultiByte(codepage, 0, zWideFilename, -1, 0, 0, 0, 0); - // zFilename = malloc( nByte ); - // if( zFilename==0 ){ - // return 0; - // } - // nByte = WideCharToMultiByte(codepage, 0, zWideFilename, -1, zFilename, nByte, - // 0, 0); - // if( nByte == 0 ){ - // free(zFilename); - // zFileName = ""; - // } - // return zFilename; - //} + /* + ** Convert an ansi string to microsoft unicode, based on the + ** current codepage settings for file apis. + ** + ** Space to hold the returned string is obtained + ** from malloc. + */ + //static WCHAR *mbcsToUnicode(string zFilename){ + // int nByte; + // Wstring zMbcsFilename; + // int codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP; + + // nByte = MultiByteToWideChar(codepage, 0, zFilename, -1, NULL,0)*WCHAR.Length; + // zMbcsFilename = malloc( nByte*sizeof(zMbcsFilename[0]) ); + // if( zMbcsFilename==0 ){ + // return 0; + // } + // nByte = MultiByteToWideChar(codepage, 0, zFilename, -1, zMbcsFilename, nByte); + // if( nByte==0 ){ + // free(zMbcsFilename); + // zMbcsFileName = ""; + // } + // return zMbcsFilename; + //} - /* - ** Convert multibyte character string to UTF-8. Space to hold the - ** returned string is obtained from malloc(). - */ - //static char *sqlite3_win32_mbcs_to_utf8(string zFilename){ - // string zFilenameUtf8; - // Wstring zTmpWide; - - // zTmpWide = mbcsToUnicode(zFilename); - // if( zTmpWide==0 ){ - // return 0; - // } - // zFilenameUtf8 = unicodeToUtf8(zTmpWide); - // free(zTmpWide); - // return zFilenameUtf8; - //} + /* + ** Convert microsoft unicode to multibyte character string, based on the + ** user's Ansi codepage. + ** + ** Space to hold the returned string is obtained from + ** malloc(). + */ + //static char *unicodeToMbcs(const Wstring zWideFilename){ + // int nByte; + // string zFilename; + // int codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP; + + // nByte = WideCharToMultiByte(codepage, 0, zWideFilename, -1, 0, 0, 0, 0); + // zFilename = malloc( nByte ); + // if( zFilename==0 ){ + // return 0; + // } + // nByte = WideCharToMultiByte(codepage, 0, zWideFilename, -1, zFilename, nByte, + // 0, 0); + // if( nByte == 0 ){ + // free(zFilename); + // zFileName = ""; + // } + // return zFilename; + //} - /* - ** Convert UTF-8 to multibyte character string. Space to hold the - ** returned string is obtained from malloc(). - */ - //char *sqlite3_win32_utf8_to_mbcs(string zFilename){ - // string zFilenameMbcs; - // Wstring zTmpWide; - - // zTmpWide = utf8ToUnicode(zFilename); - // if( zTmpWide==0 ){ - // return 0; - // } - // zFilenameMbcs = unicodeToMbcs(zTmpWide); - // free(zTmpWide); - // return zFilenameMbcs; - //} + /* + ** Convert multibyte character string to UTF-8. Space to hold the + ** returned string is obtained from malloc(). + */ + //static char *sqlite3_win32_mbcs_to_utf8(string zFilename){ + // string zFilenameUtf8; + // Wstring zTmpWide; + + // zTmpWide = mbcsToUnicode(zFilename); + // if( zTmpWide==0 ){ + // return 0; + // } + // zFilenameUtf8 = unicodeToUtf8(zTmpWide); + // free(zTmpWide); + // return zFilenameUtf8; + //} - /* - ** The return value of getLastErrorMsg - ** is zero if the error message fits in the buffer, or non-zero - ** otherwise (if the message was truncated). - */ - static int getLastErrorMsg(int nBuf, ref string zBuf) { - /* FormatMessage returns 0 on failure. Otherwise it - ** returns the number of TCHARs written to the output - ** buffer, excluding the terminating null char. - */ - //DWORD error = GetLastError(); - //DWORD dwLen = 0; - //string zOut = ""; - - //if( isNT() ){ - //Wstring zTempWide = NULL; - //dwLen = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - // NULL, - // error, - // 0, - // (LPWSTR) &zTempWide, - // 0, - // 0); - zBuf = HelperMethods.GetLastError().ToString();//new Win32Exception( Marshal.GetLastWin32Error() ).Message; - - //if( dwLen > 0 ){ - // /* allocate a buffer and convert to UTF8 */ - // zOut = unicodeToUtf8(zTempWide); - // /* free the system buffer allocated by FormatMessage */ - // LocalFree(zTempWide); - //} - /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. - ** Since the ASCII version of these Windows API do not exist for WINCE, - ** it's important to not reference them for WINCE builds. - */ - //#if !SQLITE_OS_WINCE //==0 - // }else{ - // string zTemp = null; - // dwLen = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - // null, - // error, - // 0, - // ref zTemp, - // 0, - // 0); - // if( dwLen > 0 ){ - // /* allocate a buffer and convert to UTF8 */ - // zOut = sqlite3_win32_mbcs_to_utf8(zTemp); - // /* free the system buffer allocated by FormatMessage */ - // LocalFree(zTemp); - // } - //#endif - // } - //if( 0 == dwLen ){ - // sqlite3_snprintf(nBuf, zBuf, "OsError 0x%x (%u)", error, error); - //}else{ - // /* copy a maximum of nBuf chars to output buffer */ - // sqlite3_snprintf(nBuf, zBuf, "%s", zOut); - // /* free the UTF8 buffer */ - // free(zOut); - //} - return 0; - } + /* + ** Convert UTF-8 to multibyte character string. Space to hold the + ** returned string is obtained from malloc(). + */ + //char *sqlite3_win32_utf8_to_mbcs(string zFilename){ + // string zFilenameMbcs; + // Wstring zTmpWide; + + // zTmpWide = utf8ToUnicode(zFilename); + // if( zTmpWide==0 ){ + // return 0; + // } + // zFilenameMbcs = unicodeToMbcs(zTmpWide); + // free(zTmpWide); + // return zFilenameMbcs; + //} - /* - ** - ** This function - winLogErrorAtLine() - is only ever called via the macro - ** winLogError(). - ** - ** This routine is invoked after an error occurs in an OS function. - ** It logs a message using sqlite3_log() containing the current value of - ** error code and, if possible, the human-readable equivalent from - ** FormatMessage. - ** - ** The first argument passed to the macro should be the error code that - ** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN). - ** The two subsequent arguments should be the name of the OS function that - ** failed and the the associated file-system path, if any. - */ - //#define winLogError(a,b,c) winLogErrorAtLine(a,b,c,__LINE__) - static int winLogError(int a, string b, string c) { - StackTrace st = new StackTrace(new StackFrame(true)); - StackFrame sf = st.GetFrame(0); +/* +** The return value of getLastErrorMsg +** is zero if the error message fits in the buffer, or non-zero +** otherwise (if the message was truncated). +*/ +static int getLastErrorMsg(int nBuf, ref string zBuf){ + /* FormatMessage returns 0 on failure. Otherwise it + ** returns the number of TCHARs written to the output + ** buffer, excluding the terminating null char. + */ + //DWORD error = GetLastError(); + //DWORD dwLen = 0; + //string zOut = ""; + + //if( isNT() ){ + //Wstring zTempWide = NULL; + //dwLen = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + // NULL, + // error, + // 0, + // (LPWSTR) &zTempWide, + // 0, + // 0); + zBuf = HelperMethods.GetLastError().ToString();//new Win32Exception( Marshal.GetLastWin32Error() ).Message; + + //if( dwLen > 0 ){ + // /* allocate a buffer and convert to UTF8 */ + // zOut = unicodeToUtf8(zTempWide); + // /* free the system buffer allocated by FormatMessage */ + // LocalFree(zTempWide); + //} +/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. +** Since the ASCII version of these Windows API do not exist for WINCE, +** it's important to not reference them for WINCE builds. +*/ +//#if !SQLITE_OS_WINCE //==0 +// }else{ +// string zTemp = null; +// dwLen = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, +// null, +// error, +// 0, +// ref zTemp, +// 0, +// 0); +// if( dwLen > 0 ){ +// /* allocate a buffer and convert to UTF8 */ +// zOut = sqlite3_win32_mbcs_to_utf8(zTemp); +// /* free the system buffer allocated by FormatMessage */ +// LocalFree(zTemp); +// } +//#endif +// } + //if( 0 == dwLen ){ + // sqlite3_snprintf(nBuf, zBuf, "OsError 0x%x (%u)", error, error); + //}else{ + // /* copy a maximum of nBuf chars to output buffer */ + // sqlite3_snprintf(nBuf, zBuf, "%s", zOut); + // /* free the UTF8 buffer */ + // free(zOut); + //} + return 0; +} - return winLogErrorAtLine(a, b, c, sf.GetFileLineNumber()); - } +/* +** +** This function - winLogErrorAtLine() - is only ever called via the macro +** winLogError(). +** +** This routine is invoked after an error occurs in an OS function. +** It logs a message using sqlite3_log() containing the current value of +** error code and, if possible, the human-readable equivalent from +** FormatMessage. +** +** The first argument passed to the macro should be the error code that +** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN). +** The two subsequent arguments should be the name of the OS function that +** failed and the the associated file-system path, if any. +*/ +//#define winLogError(a,b,c) winLogErrorAtLine(a,b,c,__LINE__) +static int winLogError( int a, string b, string c ) +{ + StackTrace st = new StackTrace( new StackFrame( true ) ); + StackFrame sf = st.GetFrame( 0 ); + + return winLogErrorAtLine( a, b, c, sf.GetFileLineNumber() ); +} - static int winLogErrorAtLine( - int errcode, /* SQLite error code */ - string zFunc, /* Name of OS function that failed */ - string zPath, /* File path associated with error */ - int iLine /* Source line number where error occurred */ - ) { - string zMsg = null; /* Human readable error text */ - int i; /* Loop counter */ - DWORD iErrno;// = GetLastError(); /* Error code */ +static int winLogErrorAtLine( + int errcode, /* SQLite error code */ + string zFunc, /* Name of OS function that failed */ + string zPath, /* File path associated with error */ + int iLine /* Source line number where error occurred */ +){ + string zMsg = null; /* Human readable error text */ + int i; /* Loop counter */ + DWORD iErrno;// = GetLastError(); /* Error code */ #if SQLITE_SILVERLIGHT || SQLITE_WINRT iErrno = (int)ERROR_NOT_SUPPORTED; #else - iErrno = (u32)HelperMethods.GetLastError(); + iErrno = (u32)HelperMethods.GetLastError(); #endif - //zMsg[0] = 0; - getLastErrorMsg(500, ref zMsg); - Debug.Assert(errcode != SQLITE_OK); - if (zPath == null) - zPath = ""; - for (i = 0; i < zMsg.Length && zMsg[i] != '\r' && zMsg[i] != '\n'; i++) { - } - zMsg = zMsg.Substring(0, i); - sqlite3_log(errcode, - "os_win.c:%d: (%d) %s(%s) - %s", - iLine, iErrno, zFunc, zPath, zMsg - ); + //zMsg[0] = 0; + getLastErrorMsg( 500, ref zMsg ); + Debug.Assert( errcode != SQLITE_OK ); + if ( zPath == null ) + zPath = ""; + for ( i = 0; i < zMsg.Length && zMsg[i] != '\r' && zMsg[i] != '\n'; i++ ) + { + } + zMsg = zMsg.Substring( 0, i ); + sqlite3_log(errcode, + "os_win.c:%d: (%d) %s(%s) - %s", + iLine, iErrno, zFunc, zPath, zMsg + ); - return errcode; - } + return errcode; +} #if SQLITE_OS_WINCE @@ -792,95 +799,101 @@ LPOVERLAPPED lpOverlapped *****************************************************************************/ #endif // * SQLITE_OS_WINCE */ - /***************************************************************************** - ** The next group of routines implement the I/O methods specified - ** by the sqlite3_io_methods object. - ******************************************************************************/ + /***************************************************************************** +** The next group of routines implement the I/O methods specified +** by the sqlite3_io_methods object. +******************************************************************************/ - /* - ** Some microsoft compilers lack this definition. - */ + /* + ** Some microsoft compilers lack this definition. + */ #if !INVALID_SET_FILE_POINTER - //# define INVALID_SET_FILE_POINTER ((DWORD)-1) - const int INVALID_SET_FILE_POINTER = -1; + //# define INVALID_SET_FILE_POINTER ((DWORD)-1) + const int INVALID_SET_FILE_POINTER = -1; #endif - /* - ** Move the current position of the file handle passed as the first - ** argument to offset iOffset within the file. If successful, return 0. - ** Otherwise, set pFile->lastErrno and return non-zero. - */ - static int seekWinFile(sqlite3_file id, sqlite3_int64 iOffset) { - //LONG upperBits; /* Most sig. 32 bits of new offset */ - //LONG lowerBits; /* Least sig. 32 bits of new offset */ - DWORD dwRet; /* Value returned by SetFilePointer() */ - sqlite3_file pFile = id; - - //upperBits = (LONG)((iOffset>>32) & 0x7fffffff); - //lowerBits = (LONG)(iOffset & 0xffffffff); - - /* API oddity: If successful, SetFilePointer() returns a dword - ** containing the lower 32-bits of the new file-offset. Or, if it fails, - ** it returns INVALID_SET_FILE_POINTER. However according to MSDN, - ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine - ** whether an error has actually occured, it is also necessary to call - ** GetLastError(). - */ - //dwRet = SetFilePointer(id, lowerBits, &upperBits, FILE_BEGIN); - //if( (dwRet==INVALID_SET_FILE_POINTER && GetLastError()!=NO_ERROR) ){ - // pFile->lastErrno = GetLastError(); - // winLogError(SQLITE_IOERR_SEEK, "seekWinFile", pFile->zPath); - try { + /* +** Move the current position of the file handle passed as the first +** argument to offset iOffset within the file. If successful, return 0. +** Otherwise, set pFile->lastErrno and return non-zero. +*/ + static int seekWinFile( sqlite3_file id, sqlite3_int64 iOffset ) + { + //LONG upperBits; /* Most sig. 32 bits of new offset */ + //LONG lowerBits; /* Least sig. 32 bits of new offset */ + DWORD dwRet; /* Value returned by SetFilePointer() */ + sqlite3_file pFile = id; + + //upperBits = (LONG)((iOffset>>32) & 0x7fffffff); + //lowerBits = (LONG)(iOffset & 0xffffffff); + + /* API oddity: If successful, SetFilePointer() returns a dword + ** containing the lower 32-bits of the new file-offset. Or, if it fails, + ** it returns INVALID_SET_FILE_POINTER. However according to MSDN, + ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine + ** whether an error has actually occured, it is also necessary to call + ** GetLastError(). + */ + //dwRet = SetFilePointer(id, lowerBits, &upperBits, FILE_BEGIN); + //if( (dwRet==INVALID_SET_FILE_POINTER && GetLastError()!=NO_ERROR) ){ + // pFile->lastErrno = GetLastError(); + // winLogError(SQLITE_IOERR_SEEK, "seekWinFile", pFile->zPath); + try + { #if SQLITE_WINRT id.fs.Seek( (ulong)iOffset ); // SetFilePointer(pFile.fs.Name, lowerBits, upperBits, FILE_BEGIN); #else - id.fs.Seek(iOffset, SeekOrigin.Begin); // SetFilePointer(pFile.fs.Name, lowerBits, upperBits, FILE_BEGIN); + id.fs.Seek( iOffset, SeekOrigin.Begin ); // SetFilePointer(pFile.fs.Name, lowerBits, upperBits, FILE_BEGIN); #endif - } catch (Exception e) { + } + catch ( Exception e ) + { #if SQLITE_SILVERLIGHT || SQLITE_WINRT pFile.lastErrno = 1; #else - pFile.lastErrno = (u32)HelperMethods.GetLastError(); + pFile.lastErrno = (u32)HelperMethods.GetLastError(); #endif - winLogError(SQLITE_IOERR_SEEK, "seekWinFile", pFile.zPath); - return 1; - } + winLogError(SQLITE_IOERR_SEEK, "seekWinFile", pFile.zPath); + return 1; + } - return 0; - } + return 0; + } - /* - ** Close a file. - ** - ** It is reported that an attempt to close a handle might sometimes - ** fail. This is a very unreasonable result, but windows is notorious - ** for being unreasonable so I do not doubt that it might happen. If - ** the close fails, we pause for 100 milliseconds and try again. As - ** many as MX_CLOSE_ATTEMPT attempts to close the handle are made before - ** giving up and returning an error. - */ - public static int MX_CLOSE_ATTEMPT = 3; - static int winClose(sqlite3_file id) { - bool rc; - int cnt = 0; - sqlite3_file pFile = (sqlite3_file)id; - - Debug.Assert(id != null); - Debug.Assert(pFile.pShm == null); + /* + ** Close a file. + ** + ** It is reported that an attempt to close a handle might sometimes + ** fail. This is a very unreasonable result, but windows is notorious + ** for being unreasonable so I do not doubt that it might happen. If + ** the close fails, we pause for 100 milliseconds and try again. As + ** many as MX_CLOSE_ATTEMPT attempts to close the handle are made before + ** giving up and returning an error. + */ + public static int MX_CLOSE_ATTEMPT = 3; + static int winClose( sqlite3_file id ) + { + bool rc; + int cnt = 0; + sqlite3_file pFile = (sqlite3_file)id; + + Debug.Assert( id != null ); + Debug.Assert( pFile.pShm == null ); #if SQLITE_DEBUG - OSTRACE("CLOSE %d (%s)\n", pFile.fs.GetHashCode(), pFile.fs.Name); + OSTRACE( "CLOSE %d (%s)\n", pFile.fs.GetHashCode(), pFile.fs.Name ); #endif - do { + do + { #if SQLITE_WINRT pFile.fs.Dispose(); #else - pFile.fs.Close(); + pFile.fs.Close(); #endif - rc = true; - // rc = CloseHandle(pFile.h); - /* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */ - // if (!rc && ++cnt < MX_CLOSE_ATTEMPT) Thread.Sleep(100); //, 1) ); - } while (!rc && ++cnt < MX_CLOSE_ATTEMPT); //, 1) ); + rc = true; + // rc = CloseHandle(pFile.h); + /* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */ + // if (!rc && ++cnt < MX_CLOSE_ATTEMPT) Thread.Sleep(100); //, 1) ); + } while ( !rc && ++cnt < MX_CLOSE_ATTEMPT ); //, 1) ); #if SQLITE_OS_WINCE //#define WINCE_DELETION_ATTEMPTS 3 winceDestroyLock(pFile); @@ -900,41 +913,44 @@ static int winClose(sqlite3_file id) { OSTRACE( "CLOSE %d %s\n", pFile.fs.GetHashCode(), rc ? "ok" : "failed" ); OpenCounter( -1 ); #endif - return rc ? SQLITE_OK : winLogError(SQLITE_IOERR_CLOSE, "winClose", pFile.zPath); - } + return rc ? SQLITE_OK : winLogError(SQLITE_IOERR_CLOSE, "winClose", pFile.zPath); + } - /* - ** Read data from a file into a buffer. Return SQLITE_OK if all - ** bytes were read successfully and SQLITE_IOERR if anything goes - ** wrong. - */ - static int winRead( - sqlite3_file id, /* File to read from */ - byte[] pBuf, /* Write content into this buffer */ - int amt, /* Number of bytes to read */ - sqlite3_int64 offset /* Begin reading at this offset */ - ) { - - long rc; - sqlite3_file pFile = id; - int nRead; /* Number of bytes actually read from file */ - - Debug.Assert(id != null); + /* + ** Read data from a file into a buffer. Return SQLITE_OK if all + ** bytes were read successfully and SQLITE_IOERR if anything goes + ** wrong. + */ + static int winRead( + sqlite3_file id, /* File to read from */ + byte[] pBuf, /* Write content into this buffer */ + int amt, /* Number of bytes to read */ + sqlite3_int64 offset /* Begin reading at this offset */ + ) + { + + long rc; + sqlite3_file pFile = id; + int nRead; /* Number of bytes actually read from file */ + + Debug.Assert( id != null ); #if SQLITE_TEST if ( SimulateIOError() ) return SQLITE_IOERR_READ; #endif #if SQLITE_DEBUG - OSTRACE("READ %d lock=%d\n", pFile.fs.GetHashCode(), pFile.locktype); + OSTRACE( "READ %d lock=%d\n", pFile.fs.GetHashCode(), pFile.locktype ); #endif - if (!id.fs.CanRead) - return SQLITE_IOERR_READ; - if (seekWinFile(pFile, offset) != 0) { - return SQLITE_FULL; - } + if ( !id.fs.CanRead ) + return SQLITE_IOERR_READ; + if ( seekWinFile( pFile, offset ) != 0 ) + { + return SQLITE_FULL; + } - try { + try + { #if SQLITE_WINRT using (IInputStream inputStream = id.fs.GetInputStreamAt((ulong)offset)) { @@ -943,39 +959,43 @@ sqlite3_int64 offset /* Begin reading at this offset */ nRead = (int)buffer.Length; } #else - nRead = id.fs.Read(pBuf, 0, amt); // i if( null==ReadFile(pFile->h, pBuf, amt, &nRead, 0) ){ + nRead = id.fs.Read( pBuf, 0, amt ); // i if( null==ReadFile(pFile->h, pBuf, amt, &nRead, 0) ){ #endif - } catch (Exception e) { + } + catch ( Exception e ) + { #if SQLITE_SILVERLIGHT || SQLITE_WINRT pFile.lastErrno = 1; #else - pFile.lastErrno = (u32)HelperMethods.GetLastError(); + pFile.lastErrno = (u32)HelperMethods.GetLastError(); #endif - return winLogError(SQLITE_IOERR_READ, "winRead", pFile.zPath); - } - if (nRead < amt) { - /* Unread parts of the buffer must be zero-filled */ - Array.Clear(pBuf, (int)nRead, (int)(amt - nRead)); // memset(&((char)pBuf)[nRead], 0, amt-nRead); - return SQLITE_IOERR_SHORT_READ; - } - return SQLITE_OK; - } + return winLogError(SQLITE_IOERR_READ, "winRead", pFile.zPath); + } + if ( nRead < amt ) + { + /* Unread parts of the buffer must be zero-filled */ + Array.Clear( pBuf, (int)nRead, (int)( amt - nRead ) ); // memset(&((char)pBuf)[nRead], 0, amt-nRead); + return SQLITE_IOERR_SHORT_READ; + } + return SQLITE_OK; + } - /* - ** Write data from a buffer into a file. Return SQLITE_OK on success - ** or some other error code on failure. - */ - static int winWrite( - sqlite3_file id, /* File to write into */ - byte[] pBuf, /* The bytes to be written */ - int amt, /* Number of bytes to write */ - sqlite3_int64 offset /* Offset into the file to begin writing at */ - ) { - int rc; /* True if error has occured, else false */ - sqlite3_file pFile = id; /* File handle */ - - Debug.Assert(amt > 0); - Debug.Assert(pFile != null); + /* + ** Write data from a buffer into a file. Return SQLITE_OK on success + ** or some other error code on failure. + */ + static int winWrite( + sqlite3_file id, /* File to write into */ + byte[] pBuf, /* The bytes to be written */ + int amt, /* Number of bytes to write */ + sqlite3_int64 offset /* Offset into the file to begin writing at */ + ) + { + int rc; /* True if error has occured, else false */ + sqlite3_file pFile = id; /* File handle */ + + Debug.Assert( amt > 0 ); + Debug.Assert( pFile != null ); #if SQLITE_TEST if ( SimulateIOError() ) @@ -984,25 +1004,26 @@ sqlite3_int64 offset /* Offset into the file to begin writing at */ return SQLITE_FULL; #endif #if SQLITE_DEBUG - OSTRACE("WRITE %d lock=%d\n", id.fs.GetHashCode(), id.locktype); -#endif - rc = seekWinFile(pFile, offset); - //if( rc==0 ){ - // u8 *aRem = (u8 )pBuf; /* Data yet to be written */ - // int nRem = amt; /* Number of bytes yet to be written */ - // DWORD nWrite; /* Bytes written by each WriteFile() call */ - - // while( nRem>0 && WriteFile(pFile->h, aRem, nRem, &nWrite, 0) && nWrite>0 ){ - // aRem += nWrite; - // nRem -= nWrite; - // } + OSTRACE( "WRITE %d lock=%d\n", id.fs.GetHashCode(), id.locktype ); +#endif + rc = seekWinFile( pFile, offset ); + //if( rc==0 ){ + // u8 *aRem = (u8 )pBuf; /* Data yet to be written */ + // int nRem = amt; /* Number of bytes yet to be written */ + // DWORD nWrite; /* Bytes written by each WriteFile() call */ + + // while( nRem>0 && WriteFile(pFile->h, aRem, nRem, &nWrite, 0) && nWrite>0 ){ + // aRem += nWrite; + // nRem -= nWrite; + // } #if SQLITE_WINRT ulong wrote = id.fs.Position; #else - long wrote = id.fs.Position; + long wrote = id.fs.Position; #endif - try { - Debug.Assert(pBuf.Length >= amt); + try + { + Debug.Assert( pBuf.Length >= amt ); #if SQLITE_WINRT using (IOutputStream outStream = id.fs.GetOutputStreamAt((ulong)offset)) { @@ -1011,43 +1032,50 @@ sqlite3_int64 offset /* Offset into the file to begin writing at */ wrote = (ulong)amt; } #else - id.fs.Write(pBuf, 0, amt); - wrote = id.fs.Position - wrote; + id.fs.Write( pBuf, 0, amt ); + wrote = id.fs.Position - wrote; #endif - rc = 1;// Success - } catch (IOException e) { - return SQLITE_READONLY; - } + rc = 1;// Success + } + catch ( IOException e ) + { + return SQLITE_READONLY; + } - if (rc == 0 || amt > (int)wrote) { + if ( rc == 0 || amt > (int)wrote ) + { #if SQLITE_SILVERLIGHT || SQLITE_WINRT id.lastErrno = 1; #else - id.lastErrno = (u32)HelperMethods.GetLastError(); + id.lastErrno = (u32)HelperMethods.GetLastError(); #endif - if ((id.lastErrno == ERROR_HANDLE_DISK_FULL) - || (id.lastErrno == ERROR_DISK_FULL)) { - return SQLITE_FULL; - } else { - return winLogError(SQLITE_IOERR_WRITE, "winWrite", pFile.zPath); - } - } - return SQLITE_OK; + if (( id.lastErrno == ERROR_HANDLE_DISK_FULL ) + || ( id.lastErrno == ERROR_DISK_FULL )) + { + return SQLITE_FULL; + } + else + { + return winLogError(SQLITE_IOERR_WRITE, "winWrite", pFile.zPath); } + } + return SQLITE_OK; + } - /* - ** Truncate an open file to a specified size - */ - static int winTruncate(sqlite3_file id, sqlite3_int64 nByte) { - sqlite3_file pFile = id; /* File handle object */ - int rc = SQLITE_OK; /* Return code for this function */ + /* + ** Truncate an open file to a specified size + */ + static int winTruncate( sqlite3_file id, sqlite3_int64 nByte ) + { + sqlite3_file pFile = id; /* File handle object */ + int rc = SQLITE_OK; /* Return code for this function */ - Debug.Assert(pFile != null); + Debug.Assert( pFile != null ); #if SQLITE_DEBUG #if WINDOWS_PHONE || SQLITE_SILVERLIGHT OSTRACE( "TRUNCATE %d %lld\n", id.fs.GetHashCode(), nByte ); #else - OSTRACE("TRUNCATE %s %lld\n", id.fs.Name, nByte); + OSTRACE( "TRUNCATE %s %lld\n", id.fs.Name, nByte ); #endif #endif #if SQLITE_TEST @@ -1057,43 +1085,47 @@ static int winTruncate(sqlite3_file id, sqlite3_int64 nByte) { return SQLITE_IOERR_TRUNCATE; #endif - /* If the user has configured a chunk-size for this file, truncate the - ** file so that it consists of an integer number of chunks (i.e. the - ** actual file size after the operation may be larger than the requested - ** size). - */ + /* If the user has configured a chunk-size for this file, truncate the +** file so that it consists of an integer number of chunks (i.e. the +** actual file size after the operation may be larger than the requested +** size). +*/ - if (pFile.szChunk != 0) { - nByte = ((nByte + pFile.szChunk - 1) / pFile.szChunk) * pFile.szChunk; - } + if ( pFile.szChunk != 0 ) + { + nByte = ( ( nByte + pFile.szChunk - 1 ) / pFile.szChunk ) * pFile.szChunk; + } - /* SetEndOfFile() returns non-zero when successful, or zero when it fails. */ - //if ( seekWinFile( pFile, nByte ) ) - //{ - // rc = winLogError(SQLITE_IOERR_TRUNCATE, "winTruncate1", pFile->zPath); - //} - //else if( 0==SetEndOfFile(pFile->h) ){ - // pFile->lastErrno = GetLastError(); - // rc = winLogError(SQLITE_IOERR_TRUNCATE, "winTruncate2", pFile->zPath); - //} - try { + /* SetEndOfFile() returns non-zero when successful, or zero when it fails. */ + //if ( seekWinFile( pFile, nByte ) ) + //{ + // rc = winLogError(SQLITE_IOERR_TRUNCATE, "winTruncate1", pFile->zPath); + //} + //else if( 0==SetEndOfFile(pFile->h) ){ + // pFile->lastErrno = GetLastError(); + // rc = winLogError(SQLITE_IOERR_TRUNCATE, "winTruncate2", pFile->zPath); + //} + try + { #if SQLITE_WINRT id.fs.Size = (ulong)nByte; #else - id.fs.SetLength(nByte); + id.fs.SetLength( nByte ); #endif - rc = SQLITE_OK; - } catch (IOException e) { + rc = SQLITE_OK; + } + catch ( IOException e ) + { #if SQLITE_SILVERLIGHT || SQLITE_WINRT id.lastErrno = 1; #else - id.lastErrno = (u32)HelperMethods.GetLastError(); + id.lastErrno = (u32)HelperMethods.GetLastError(); #endif - rc = winLogError(SQLITE_IOERR_TRUNCATE, "winTruncate2", pFile.zPath); - } - OSTRACE("TRUNCATE %d %lld %s\n", id.fs.GetHashCode(), nByte, rc == SQLITE_OK ? "ok" : "failed"); - return rc; - } + rc = winLogError(SQLITE_IOERR_TRUNCATE, "winTruncate2", pFile.zPath); + } + OSTRACE( "TRUNCATE %d %lld %s\n", id.fs.GetHashCode(), nByte, rc == SQLITE_OK ? "ok" : "failed" ); + return rc; + } #if SQLITE_TEST /* @@ -1109,33 +1141,34 @@ static int winTruncate(sqlite3_file id, sqlite3_int64 nByte) { #endif #endif - /* - ** Make sure all writes to a particular file are committed to disk. - */ - static int winSync(sqlite3_file id, int flags) { + /* +** Make sure all writes to a particular file are committed to disk. +*/ + static int winSync( sqlite3_file id, int flags ) + { #if !(NDEBUG) || !(SQLITE_NO_SYNC) || (SQLITE_DEBUG) - sqlite3_file pFile = (sqlite3_file)id; - bool rc; + sqlite3_file pFile = (sqlite3_file)id; + bool rc; #else UNUSED_PARAMETER(id); #endif - Debug.Assert(pFile != null); - /* Check that one of SQLITE_SYNC_NORMAL or FULL was passed */ - Debug.Assert((flags & 0x0F) == SQLITE_SYNC_NORMAL - || (flags & 0x0F) == SQLITE_SYNC_FULL - ); + Debug.Assert( pFile != null ); + /* Check that one of SQLITE_SYNC_NORMAL or FULL was passed */ + Debug.Assert( ( flags & 0x0F ) == SQLITE_SYNC_NORMAL + || ( flags & 0x0F ) == SQLITE_SYNC_FULL + ); - OSTRACE("SYNC %d lock=%d\n", pFile.fs.GetHashCode(), pFile.locktype); + OSTRACE( "SYNC %d lock=%d\n", pFile.fs.GetHashCode(), pFile.locktype ); - /* Unix cannot, but some systems may return SQLITE_FULL from here. This - ** line is to test that doing so does not cause any problems. - */ + /* Unix cannot, but some systems may return SQLITE_FULL from here. This + ** line is to test that doing so does not cause any problems. + */ #if SQLITE_TEST if ( SimulateDiskfullError() ) return SQLITE_FULL; #endif #if !SQLITE_TEST - UNUSED_PARAMETER(flags); +UNUSED_PARAMETER(flags); #else if ( (flags&0x0F)==SQLITE_SYNC_FULL ) { @@ -1151,9 +1184,9 @@ static int winSync(sqlite3_file id, int flags) { #endif - /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a - ** no-op - */ + /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a +** no-op +*/ #if SQLITE_NO_SYNC return SQLITE_OK; #else @@ -1161,444 +1194,511 @@ static int winSync(sqlite3_file id, int flags) { Stream stream = pFile.fs.AsStreamForWrite(); stream.Flush(); #else - pFile.fs.Flush(); + pFile.fs.Flush(); #endif - return SQLITE_OK; - //rc = FlushFileBuffers(pFile->h); - //SimulateIOError( rc=FALSE ); - //if( rc ){ - // return SQLITE_OK; - //}else{ - // pFile->lastErrno = GetLastError(); - // return winLogError(SQLITE_IOERR_FSYNC, "winSync", pFile->zPath); - //} + return SQLITE_OK; + //rc = FlushFileBuffers(pFile->h); + //SimulateIOError( rc=FALSE ); + //if( rc ){ + // return SQLITE_OK; + //}else{ + // pFile->lastErrno = GetLastError(); + // return winLogError(SQLITE_IOERR_FSYNC, "winSync", pFile->zPath); + //} #endif - } + } - /* - ** Determine the current size of a file in bytes - */ - static int winFileSize(sqlite3_file id, ref long pSize) { - //DWORD upperBits; - //DWORD lowerBits; - // sqlite3_file pFile = (sqlite3_file)id; - // DWORD error; - Debug.Assert(id != null); + /* + ** Determine the current size of a file in bytes + */ + static int winFileSize( sqlite3_file id, ref long pSize ) + { + //DWORD upperBits; + //DWORD lowerBits; + // sqlite3_file pFile = (sqlite3_file)id; + // DWORD error; + Debug.Assert( id != null ); #if SQLITE_TEST if ( SimulateIOError() ) return SQLITE_IOERR_FSTAT; #endif - //lowerBits = GetFileSize(pFile.fs.Name, upperBits); - //if ( ( lowerBits == INVALID_FILE_SIZE ) - // && ( ( error = GetLastError() ) != NO_ERROR ) ) - //{ - // pFile.lastErrno = error; - // return winLogError(SQLITE_IOERR_FSTAT, "winFileSize", pFile->zPath); - //} - //pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits; + //lowerBits = GetFileSize(pFile.fs.Name, upperBits); + //if ( ( lowerBits == INVALID_FILE_SIZE ) + // && ( ( error = GetLastError() ) != NO_ERROR ) ) + //{ + // pFile.lastErrno = error; + // return winLogError(SQLITE_IOERR_FSTAT, "winFileSize", pFile->zPath); + //} + //pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits; #if SQLITE_WINRT pSize = id.fs.CanRead ? (long)id.fs.Size : 0; #else - pSize = id.fs.CanRead ? id.fs.Length : 0; + pSize = id.fs.CanRead ? id.fs.Length : 0; #endif - return SQLITE_OK; - } + return SQLITE_OK; + } - /* - ** Acquire a reader lock. - ** Different API routines are called depending on whether or not this - ** is Win95 or WinNT. - */ - static int getReadLock(sqlite3_file pFile) { - int res = 0; - if (isNT()) { - res = lockingStrategy.SharedLockFile(pFile, SHARED_FIRST, SHARED_SIZE); - } - /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. - */ + /* + ** Acquire a reader lock. + ** Different API routines are called depending on whether or not this + ** is Win95 or WinNT. + */ + static int getReadLock( sqlite3_file pFile ) + { + int res = 0; + if ( isNT() ) + { + res = lockingStrategy.SharedLockFile( pFile, SHARED_FIRST, SHARED_SIZE ); + } + /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. + */ #if !SQLITE_OS_WINCE - //else - //{ - // int lk; - // sqlite3_randomness(lk.Length, lk); - // pFile.sharedLockByte = (u16)((lk & 0x7fffffff)%(SHARED_SIZE - 1)); - // res = pFile.fs.Lock( SHARED_FIRST + pFile.sharedLockByte, 0, 1, 0); -#endif - //} - if (res == 0) { - pFile.lastErrno = (u32)HelperMethods.GetLastError(); - } - /* No need to log a failure to lock */ - return res; + //else + //{ + // int lk; + // sqlite3_randomness(lk.Length, lk); + // pFile.sharedLockByte = (u16)((lk & 0x7fffffff)%(SHARED_SIZE - 1)); + // res = pFile.fs.Lock( SHARED_FIRST + pFile.sharedLockByte, 0, 1, 0); +#endif + //} + if (res == 0) { + pFile.lastErrno = (u32)HelperMethods.GetLastError(); } + /* No need to log a failure to lock */ + return res; + } - /* - ** Undo a readlock - */ - static int unlockReadLock(sqlite3_file pFile) { - int res = 1; - if (isNT()) { - try { - lockingStrategy.UnlockFile(pFile, SHARED_FIRST, SHARED_SIZE); // res = UnlockFile(pFile.h, SHARED_FIRST, 0, SHARED_SIZE, 0); - } catch (Exception e) { - res = 0; - } - } - /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. - */ + /* + ** Undo a readlock + */ + static int unlockReadLock( sqlite3_file pFile ) + { + int res = 1; + if ( isNT() ) + { + try + { + lockingStrategy.UnlockFile( pFile, SHARED_FIRST, SHARED_SIZE ); // res = UnlockFile(pFile.h, SHARED_FIRST, 0, SHARED_SIZE, 0); + } + catch ( Exception e ) + { + res = 0; + } + } + /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. + */ #if !SQLITE_OS_WINCE - else { - Debugger.Break(); // res = UnlockFile(pFile.h, SHARED_FIRST + pFilE.sharedLockByte, 0, 1, 0); - } + else + { + Debugger.Break(); // res = UnlockFile(pFile.h, SHARED_FIRST + pFilE.sharedLockByte, 0, 1, 0); + } #endif - if (res == 0) { - pFile.lastErrno = (u32)HelperMethods.GetLastError(); - - winLogError(SQLITE_IOERR_UNLOCK, "unlockReadLock", pFile.zPath); - } + if (res == 0) { + pFile.lastErrno = (u32)HelperMethods.GetLastError(); - return res; + winLogError(SQLITE_IOERR_UNLOCK, "unlockReadLock", pFile.zPath); } - /* - ** Lock the file with the lock specified by parameter locktype - one - ** of the following: - ** - ** (1) SHARED_LOCK - ** (2) RESERVED_LOCK - ** (3) PENDING_LOCK - ** (4) EXCLUSIVE_LOCK - ** - ** Sometimes when requesting one lock state, additional lock states - ** are inserted in between. The locking might fail on one of the later - ** transitions leaving the lock state different from what it started but - ** still short of its goal. The following chart shows the allowed - ** transitions and the inserted intermediate states: - ** - ** UNLOCKED . SHARED - ** SHARED . RESERVED - ** SHARED . (PENDING) . EXCLUSIVE - ** RESERVED . (PENDING) . EXCLUSIVE - ** PENDING . EXCLUSIVE - ** - ** This routine will only increase a lock. The winUnlock() routine - ** erases all locks at once and returns us immediately to locking level 0. - ** It is not possible to lower the locking level one step at a time. You - ** must go straight to locking level 0. - */ - static int winLock(sqlite3_file id, int locktype) { - int rc = SQLITE_OK; /* Return code from subroutines */ - int res = 1; /* Result of a windows lock call */ - int newLocktype; /* Set pFile.locktype to this value before exiting */ - bool gotPendingLock = false;/* True if we acquired a PENDING lock this time */ - sqlite3_file pFile = (sqlite3_file)id; - DWORD error = NO_ERROR; - - Debug.Assert(id != null); + return res; + } + + /* + ** Lock the file with the lock specified by parameter locktype - one + ** of the following: + ** + ** (1) SHARED_LOCK + ** (2) RESERVED_LOCK + ** (3) PENDING_LOCK + ** (4) EXCLUSIVE_LOCK + ** + ** Sometimes when requesting one lock state, additional lock states + ** are inserted in between. The locking might fail on one of the later + ** transitions leaving the lock state different from what it started but + ** still short of its goal. The following chart shows the allowed + ** transitions and the inserted intermediate states: + ** + ** UNLOCKED . SHARED + ** SHARED . RESERVED + ** SHARED . (PENDING) . EXCLUSIVE + ** RESERVED . (PENDING) . EXCLUSIVE + ** PENDING . EXCLUSIVE + ** + ** This routine will only increase a lock. The winUnlock() routine + ** erases all locks at once and returns us immediately to locking level 0. + ** It is not possible to lower the locking level one step at a time. You + ** must go straight to locking level 0. + */ + static int winLock( sqlite3_file id, int locktype ) + { + int rc = SQLITE_OK; /* Return code from subroutines */ + int res = 1; /* Result of a windows lock call */ + int newLocktype; /* Set pFile.locktype to this value before exiting */ + bool gotPendingLock = false;/* True if we acquired a PENDING lock this time */ + sqlite3_file pFile = (sqlite3_file)id; + DWORD error = NO_ERROR; + + Debug.Assert( id != null ); #if SQLITE_DEBUG - OSTRACE("LOCK %d %d was %d(%d)\n", - pFile.fs.GetHashCode(), locktype, pFile.locktype, pFile.sharedLockByte); + OSTRACE( "LOCK %d %d was %d(%d)\n", + pFile.fs.GetHashCode(), locktype, pFile.locktype, pFile.sharedLockByte ); #endif - /* If there is already a lock of this type or more restrictive on the - ** OsFile, do nothing. Don't use the end_lock: exit path, as - ** sqlite3OsEnterMutex() hasn't been called yet. - */ - if (pFile.locktype >= locktype) { - return SQLITE_OK; - } + /* If there is already a lock of this type or more restrictive on the +** OsFile, do nothing. Don't use the end_lock: exit path, as +** sqlite3OsEnterMutex() hasn't been called yet. +*/ + if ( pFile.locktype >= locktype ) + { + return SQLITE_OK; + } - /* Make sure the locking sequence is correct - */ - Debug.Assert(pFile.locktype != NO_LOCK || locktype == SHARED_LOCK); - Debug.Assert(locktype != PENDING_LOCK); - Debug.Assert(locktype != RESERVED_LOCK || pFile.locktype == SHARED_LOCK); + /* Make sure the locking sequence is correct + */ + Debug.Assert( pFile.locktype != NO_LOCK || locktype == SHARED_LOCK ); + Debug.Assert( locktype != PENDING_LOCK ); + Debug.Assert( locktype != RESERVED_LOCK || pFile.locktype == SHARED_LOCK ); - /* Lock the PENDING_LOCK byte if we need to acquire a PENDING lock or - ** a SHARED lock. If we are acquiring a SHARED lock, the acquisition of - ** the PENDING_LOCK byte is temporary. + /* Lock the PENDING_LOCK byte if we need to acquire a PENDING lock or + ** a SHARED lock. If we are acquiring a SHARED lock, the acquisition of + ** the PENDING_LOCK byte is temporary. + */ + newLocktype = pFile.locktype; + if ( pFile.locktype == NO_LOCK + || ( ( locktype == EXCLUSIVE_LOCK ) + && ( pFile.locktype == RESERVED_LOCK ) ) + ) + { + int cnt = 3; + res = 0; + while ( cnt-- > 0 && res == 0 )//(res = LockFile(pFile.fs.SafeFileHandle.DangerousGetHandle().ToInt32(), PENDING_BYTE, 0, 1, 0)) == 0) + { + try + { + lockingStrategy.LockFile( pFile, PENDING_BYTE, 1 ); + res = 1; + } + catch ( Exception e ) + { + /* Try 3 times to get the pending lock. The pending lock might be + ** held by another reader process who will release it momentarily. */ - newLocktype = pFile.locktype; - if (pFile.locktype == NO_LOCK - || ((locktype == EXCLUSIVE_LOCK) - && (pFile.locktype == RESERVED_LOCK)) - ) { - int cnt = 3; - res = 0; - while (cnt-- > 0 && res == 0)//(res = LockFile(pFile.fs.SafeFileHandle.DangerousGetHandle().ToInt32(), PENDING_BYTE, 0, 1, 0)) == 0) - { - try { - lockingStrategy.LockFile(pFile, PENDING_BYTE, 1); - res = 1; - } catch (Exception e) { - /* Try 3 times to get the pending lock. The pending lock might be - ** held by another reader process who will release it momentarily. - */ #if SQLITE_DEBUG - OSTRACE("could not get a PENDING lock. cnt=%d\n", cnt); + OSTRACE( "could not get a PENDING lock. cnt=%d\n", cnt ); #endif #if SQLITE_WINRT System.Threading.Tasks.Task.Delay(1).Wait(); #else - Thread.Sleep(1); + Thread.Sleep( 1 ); #endif - } - } - gotPendingLock = (res != 0); - if (0 == res) { + } + } + gotPendingLock = ( res != 0 ); + if ( 0 == res ) + { #if SQLITE_SILVERLIGHT || SQLITE_WINRT error = 1; #else - error = (u32)HelperMethods.GetLastError(); + error = (u32)HelperMethods.GetLastError(); #endif - } - } + } + } - /* Acquire a shared lock - */ - if (locktype == SHARED_LOCK && res != 0) { - Debug.Assert(pFile.locktype == NO_LOCK); - res = getReadLock(pFile); - if (res != 0) { - newLocktype = SHARED_LOCK; - } else { + /* Acquire a shared lock + */ + if ( locktype == SHARED_LOCK && res != 0 ) + { + Debug.Assert( pFile.locktype == NO_LOCK ); + res = getReadLock( pFile ); + if ( res != 0 ) + { + newLocktype = SHARED_LOCK; + } + else + { #if SQLITE_SILVERLIGHT || SQLITE_WINRT error = 1; #else - error = (u32)HelperMethods.GetLastError(); + error = (u32)HelperMethods.GetLastError(); #endif - } - } + } + } - /* Acquire a RESERVED lock - */ - if ((locktype == RESERVED_LOCK) && res != 0) { - Debug.Assert(pFile.locktype == SHARED_LOCK); - try { - lockingStrategy.LockFile(pFile, RESERVED_BYTE, 1);//res = LockFile(pFile.fs.SafeFileHandle.DangerousGetHandle().ToInt32(), RESERVED_BYTE, 0, 1, 0); - newLocktype = RESERVED_LOCK; - res = 1; - } catch (Exception e) { - res = 0; + /* Acquire a RESERVED lock + */ + if ( ( locktype == RESERVED_LOCK ) && res != 0 ) + { + Debug.Assert( pFile.locktype == SHARED_LOCK ); + try + { + lockingStrategy.LockFile( pFile, RESERVED_BYTE, 1 );//res = LockFile(pFile.fs.SafeFileHandle.DangerousGetHandle().ToInt32(), RESERVED_BYTE, 0, 1, 0); + newLocktype = RESERVED_LOCK; + res = 1; + } + catch ( Exception e ) + { + res = 0; #if SQLITE_SILVERLIGHT || SQLITE_WINRT error = 1; #else - error = (u32)HelperMethods.GetLastError(); + error = (u32)HelperMethods.GetLastError(); #endif - } - if (res != 0) { - newLocktype = RESERVED_LOCK; - } else { + } + if ( res != 0 ) + { + newLocktype = RESERVED_LOCK; + } + else + { #if SQLITE_SILVERLIGHT error = 1; #else - error = (u32)HelperMethods.GetLastError(); + error = (u32)HelperMethods.GetLastError(); #endif - } - } + } + } - /* Acquire a PENDING lock - */ - if (locktype == EXCLUSIVE_LOCK && res != 0) { - newLocktype = PENDING_LOCK; - gotPendingLock = false; - } + /* Acquire a PENDING lock + */ + if ( locktype == EXCLUSIVE_LOCK && res != 0 ) + { + newLocktype = PENDING_LOCK; + gotPendingLock = false; + } - /* Acquire an EXCLUSIVE lock - */ - if (locktype == EXCLUSIVE_LOCK && res != 0) { - Debug.Assert(pFile.locktype >= SHARED_LOCK); - res = unlockReadLock(pFile); + /* Acquire an EXCLUSIVE lock + */ + if ( locktype == EXCLUSIVE_LOCK && res != 0 ) + { + Debug.Assert( pFile.locktype >= SHARED_LOCK ); + res = unlockReadLock( pFile ); #if SQLITE_DEBUG - OSTRACE("unreadlock = %d\n", res); -#endif - //res = LockFile(pFile.fs.SafeFileHandle.DangerousGetHandle().ToInt32(), SHARED_FIRST, 0, SHARED_SIZE, 0); - try { - lockingStrategy.LockFile(pFile, SHARED_FIRST, SHARED_SIZE); - newLocktype = EXCLUSIVE_LOCK; - res = 1; - } catch (Exception e) { - res = 0; - } - if (res != 0) { - newLocktype = EXCLUSIVE_LOCK; - } else { + OSTRACE( "unreadlock = %d\n", res ); +#endif + //res = LockFile(pFile.fs.SafeFileHandle.DangerousGetHandle().ToInt32(), SHARED_FIRST, 0, SHARED_SIZE, 0); + try + { + lockingStrategy.LockFile( pFile, SHARED_FIRST, SHARED_SIZE ); + newLocktype = EXCLUSIVE_LOCK; + res = 1; + } + catch ( Exception e ) + { + res = 0; + } + if ( res != 0 ) + { + newLocktype = EXCLUSIVE_LOCK; + } + else + { #if SQLITE_SILVERLIGHT || SQLITE_WINRT error = 1; #else - error = (u32)HelperMethods.GetLastError(); + error = (u32)HelperMethods.GetLastError(); #endif #if SQLITE_DEBUG - OSTRACE("error-code = %d\n", error); + OSTRACE( "error-code = %d\n", error ); #endif - getReadLock(pFile); - } - } + getReadLock( pFile ); + } + } - /* If we are holding a PENDING lock that ought to be released, then - ** release it now. - */ - if (gotPendingLock && locktype == SHARED_LOCK) { - lockingStrategy.UnlockFile(pFile, PENDING_BYTE, 1); - } + /* If we are holding a PENDING lock that ought to be released, then + ** release it now. + */ + if ( gotPendingLock && locktype == SHARED_LOCK ) + { + lockingStrategy.UnlockFile( pFile, PENDING_BYTE, 1 ); + } - /* Update the state of the lock has held in the file descriptor then - ** return the appropriate result code. - */ - if (res != 0) { - rc = SQLITE_OK; - } else { + /* Update the state of the lock has held in the file descriptor then + ** return the appropriate result code. + */ + if ( res != 0 ) + { + rc = SQLITE_OK; + } + else + { #if SQLITE_DEBUG - OSTRACE("LOCK FAILED %d trying for %d but got %d\n", pFile.fs.GetHashCode(), - locktype, newLocktype); + OSTRACE( "LOCK FAILED %d trying for %d but got %d\n", pFile.fs.GetHashCode(), + locktype, newLocktype ); #endif - pFile.lastErrno = error; - rc = SQLITE_BUSY; - } - pFile.locktype = (u8)newLocktype; - return rc; - } + pFile.lastErrno = error; + rc = SQLITE_BUSY; + } + pFile.locktype = (u8)newLocktype; + return rc; + } - /* - ** This routine checks if there is a RESERVED lock held on the specified - ** file by this or any other process. If such a lock is held, return - ** non-zero, otherwise zero. - */ - static int winCheckReservedLock(sqlite3_file id, ref int pResOut) { - int rc; - sqlite3_file pFile = (sqlite3_file)id; + /* + ** This routine checks if there is a RESERVED lock held on the specified + ** file by this or any other process. If such a lock is held, return + ** non-zero, otherwise zero. + */ + static int winCheckReservedLock( sqlite3_file id, ref int pResOut ) + { + int rc; + sqlite3_file pFile = (sqlite3_file)id; - if (SimulateIOError()) - return SQLITE_IOERR_CHECKRESERVEDLOCK; + if ( SimulateIOError() ) + return SQLITE_IOERR_CHECKRESERVEDLOCK; - Debug.Assert(id != null); - if (pFile.locktype >= RESERVED_LOCK) { - rc = 1; -#if SQLITE_DEBUG - OSTRACE("TEST WR-LOCK %s %d (local)\n", pFile.fs.Name, rc); -#endif - } else { - try { - lockingStrategy.LockFile(pFile, RESERVED_BYTE, 1); - lockingStrategy.UnlockFile(pFile, RESERVED_BYTE, 1); - rc = 1; - } catch (IOException e) { - rc = 0; - } - rc = 1 - rc; // !rc + Debug.Assert( id != null ); + if ( pFile.locktype >= RESERVED_LOCK ) + { + rc = 1; #if SQLITE_DEBUG - OSTRACE("TEST WR-LOCK %d %d (remote)\n", pFile.fs.GetHashCode(), rc); + OSTRACE( "TEST WR-LOCK %s %d (local)\n", pFile.fs.Name, rc ); #endif - } - pResOut = rc; - return SQLITE_OK; + } + else + { + try + { + lockingStrategy.LockFile( pFile, RESERVED_BYTE, 1 ); + lockingStrategy.UnlockFile( pFile, RESERVED_BYTE, 1 ); + rc = 1; + } + catch ( IOException e ) + { + rc = 0; } + rc = 1 - rc; // !rc +#if SQLITE_DEBUG + OSTRACE( "TEST WR-LOCK %d %d (remote)\n", pFile.fs.GetHashCode(), rc ); +#endif + } + pResOut = rc; + return SQLITE_OK; + } - /* - ** Lower the locking level on file descriptor id to locktype. locktype - ** must be either NO_LOCK or SHARED_LOCK. - ** - ** If the locking level of the file descriptor is already at or below - ** the requested locking level, this routine is a no-op. - ** - ** It is not possible for this routine to fail if the second argument - ** is NO_LOCK. If the second argument is SHARED_LOCK then this routine - ** might return SQLITE_IOERR; - */ - static int winUnlock(sqlite3_file id, int locktype) { - int type; - sqlite3_file pFile = (sqlite3_file)id; - int rc = SQLITE_OK; - Debug.Assert(pFile != null); - Debug.Assert(locktype <= SHARED_LOCK); + /* + ** Lower the locking level on file descriptor id to locktype. locktype + ** must be either NO_LOCK or SHARED_LOCK. + ** + ** If the locking level of the file descriptor is already at or below + ** the requested locking level, this routine is a no-op. + ** + ** It is not possible for this routine to fail if the second argument + ** is NO_LOCK. If the second argument is SHARED_LOCK then this routine + ** might return SQLITE_IOERR; + */ + static int winUnlock( sqlite3_file id, int locktype ) + { + int type; + sqlite3_file pFile = (sqlite3_file)id; + int rc = SQLITE_OK; + Debug.Assert( pFile != null ); + Debug.Assert( locktype <= SHARED_LOCK ); #if SQLITE_DEBUG - OSTRACE("UNLOCK %d to %d was %d(%d)\n", pFile.fs.GetHashCode(), locktype, - pFile.locktype, pFile.sharedLockByte); -#endif - type = pFile.locktype; - if (type >= EXCLUSIVE_LOCK) { - lockingStrategy.UnlockFile(pFile, SHARED_FIRST, SHARED_SIZE); // UnlockFile(pFile.h, SHARED_FIRST, 0, SHARED_SIZE, 0); - if (locktype == SHARED_LOCK && getReadLock(pFile) == 0) { - /* This should never happen. We should always be able to - ** reacquire the read lock */ - rc = winLogError(SQLITE_IOERR_UNLOCK, "winUnlock", pFile.zPath); - } - } - if (type >= RESERVED_LOCK) { - try { - lockingStrategy.UnlockFile(pFile, RESERVED_BYTE, 1);// UnlockFile(pFile.h, RESERVED_BYTE, 0, 1, 0); - } catch (Exception e) { - } - } - if (locktype == NO_LOCK && type >= SHARED_LOCK) { - unlockReadLock(pFile); - } - if (type >= PENDING_LOCK) { - try { - lockingStrategy.UnlockFile(pFile, PENDING_BYTE, 1);// UnlockFile(pFile.h, PENDING_BYTE, 0, 1, 0); - } catch (Exception e) { - } - } - pFile.locktype = (u8)locktype; - return rc; + OSTRACE( "UNLOCK %d to %d was %d(%d)\n", pFile.fs.GetHashCode(), locktype, + pFile.locktype, pFile.sharedLockByte ); +#endif + type = pFile.locktype; + if ( type >= EXCLUSIVE_LOCK ) + { + lockingStrategy.UnlockFile( pFile, SHARED_FIRST, SHARED_SIZE ); // UnlockFile(pFile.h, SHARED_FIRST, 0, SHARED_SIZE, 0); + if ( locktype == SHARED_LOCK && getReadLock( pFile ) == 0 ) + { + /* This should never happen. We should always be able to + ** reacquire the read lock */ + rc = winLogError(SQLITE_IOERR_UNLOCK, "winUnlock", pFile.zPath); } - - /* - ** Control and query of the open file handle. - */ - static int winFileControl(sqlite3_file id, int op, ref sqlite3_int64 pArg) { - switch (op) { - case SQLITE_FCNTL_LOCKSTATE: { - pArg = (int)((sqlite3_file)id).locktype; - return SQLITE_OK; - } - case SQLITE_LAST_ERRNO: { - pArg = (int)((sqlite3_file)id).lastErrno; - return SQLITE_OK; - } - case SQLITE_FCNTL_CHUNK_SIZE: { - ((sqlite3_file)id).szChunk = (int)pArg; - return SQLITE_OK; - } - case SQLITE_FCNTL_SIZE_HINT: { - sqlite3_int64 sz = (sqlite3_int64)pArg; - SimulateIOErrorBenign(1); - winTruncate(id, sz); - SimulateIOErrorBenign(0); - return SQLITE_OK; - } - case SQLITE_FCNTL_SYNC_OMITTED: { - return SQLITE_OK; - } - } - return SQLITE_NOTFOUND; + } + if ( type >= RESERVED_LOCK ) + { + try + { + lockingStrategy.UnlockFile( pFile, RESERVED_BYTE, 1 );// UnlockFile(pFile.h, RESERVED_BYTE, 0, 1, 0); } - - /* - ** Return the sector size in bytes of the underlying block device for - ** the specified file. This is almost always 512 bytes, but may be - ** larger for some devices. - ** - ** SQLite code assumes this function cannot fail. It also assumes that - ** if two files are created in the same file-system directory (i.e. - ** a database and its journal file) that the sector size will be the - ** same for both. - */ - static int winSectorSize(sqlite3_file id) { - Debug.Assert(id != null); - return (int)(id.sectorSize); + catch ( Exception e ) + { } - - /* - ** Return a vector of device characteristics. - */ - static int winDeviceCharacteristics(sqlite3_file id) { - UNUSED_PARAMETER(id); - return 0; + } + if ( locktype == NO_LOCK && type >= SHARED_LOCK ) + { + unlockReadLock( pFile ); + } + if ( type >= PENDING_LOCK ) + { + try + { + lockingStrategy.UnlockFile( pFile, PENDING_BYTE, 1 );// UnlockFile(pFile.h, PENDING_BYTE, 0, 1, 0); + } + catch ( Exception e ) + { } + } + pFile.locktype = (u8)locktype; + return rc; + } + + /* + ** Control and query of the open file handle. + */ + static int winFileControl( sqlite3_file id, int op, ref sqlite3_int64 pArg ) + { + switch ( op ) + { + case SQLITE_FCNTL_LOCKSTATE: + { + pArg = (int)( (sqlite3_file)id ).locktype; + return SQLITE_OK; + } + case SQLITE_LAST_ERRNO: + { + pArg = (int)( (sqlite3_file)id ).lastErrno; + return SQLITE_OK; + } + case SQLITE_FCNTL_CHUNK_SIZE: + { + ( (sqlite3_file)id ).szChunk = (int)pArg; + return SQLITE_OK; + } + case SQLITE_FCNTL_SIZE_HINT: + { + sqlite3_int64 sz = (sqlite3_int64)pArg; + SimulateIOErrorBenign( 1 ); + winTruncate( id, sz ); + SimulateIOErrorBenign( 0 ); + return SQLITE_OK; + } + case SQLITE_FCNTL_SYNC_OMITTED: + { + return SQLITE_OK; + } + } + return SQLITE_NOTFOUND; + } + + /* + ** Return the sector size in bytes of the underlying block device for + ** the specified file. This is almost always 512 bytes, but may be + ** larger for some devices. + ** + ** SQLite code assumes this function cannot fail. It also assumes that + ** if two files are created in the same file-system directory (i.e. + ** a database and its journal file) that the sector size will be the + ** same for both. + */ + static int winSectorSize( sqlite3_file id ) + { + Debug.Assert( id != null ); + return (int)( id.sectorSize ); + } + + /* + ** Return a vector of device characteristics. + */ + static int winDeviceCharacteristics( sqlite3_file id ) + { + UNUSED_PARAMETER( id ); + return 0; + } #if !SQLITE_OMIT_WAL @@ -2224,361 +2324,384 @@ struct ShmRegion *apNew; /* New aRegion[] array */ } #else - //# define winShmMap 0 - static int winShmMap( - sqlite3_file fd, /* Handle open on database file */ - int iRegion, /* Region to retrieve */ - int szRegion, /* Size of regions */ - int isWrite, /* True to extend file if necessary */ - out object pp /* OUT: Mapped memory */ - ) { - pp = null; - return 0; - } + //# define winShmMap 0 + static int winShmMap( + sqlite3_file fd, /* Handle open on database file */ + int iRegion, /* Region to retrieve */ + int szRegion, /* Size of regions */ + int isWrite, /* True to extend file if necessary */ + out object pp /* OUT: Mapped memory */ + ) + { + pp = null; + return 0; + } - //# define winShmLock 0 - static int winShmLock( - sqlite3_file fd, /* Database file holding the shared memory */ - int ofst, /* First lock to acquire or release */ - int n, /* Number of locks to acquire or release */ - int flags /* What to do with the lock */ - ) { - return 0; - } + //# define winShmLock 0 + static int winShmLock( + sqlite3_file fd, /* Database file holding the shared memory */ + int ofst, /* First lock to acquire or release */ + int n, /* Number of locks to acquire or release */ + int flags /* What to do with the lock */ + ) + { + return 0; + } - //# define winShmBarrier 0 - static void winShmBarrier( - sqlite3_file fd /* Database holding the shared memory */ - ) { - } + //# define winShmBarrier 0 + static void winShmBarrier( + sqlite3_file fd /* Database holding the shared memory */ + ) + { + } - //# define winShmUnmap 0 - static int winShmUnmap( - sqlite3_file fd, /* Database holding shared memory */ - int deleteFlag /* Delete after closing if true */ - ) { - return 0; - } + //# define winShmUnmap 0 + static int winShmUnmap( + sqlite3_file fd, /* Database holding shared memory */ + int deleteFlag /* Delete after closing if true */ + ) + { + return 0; + } #endif //* #if !SQLITE_OMIT_WAL */ - /* - ** Here ends the implementation of all sqlite3_file methods. - ** - ********************** End sqlite3_file Methods ******************************* - ******************************************************************************/ + /* +** Here ends the implementation of all sqlite3_file methods. +** +********************** End sqlite3_file Methods ******************************* +******************************************************************************/ - /* - ** This vector defines all the methods that can operate on an - ** sqlite3_file for win32. - */ - static sqlite3_io_methods winIoMethod = new sqlite3_io_methods( - 2, /* iVersion */ - (dxClose)winClose, /* xClose */ - (dxRead)winRead, /* xRead */ - (dxWrite)winWrite, /* xWrite */ - (dxTruncate)winTruncate, /* xTruncate */ - (dxSync)winSync, /* xSync */ - (dxFileSize)winFileSize, /* xFileSize */ - (dxLock)winLock, /* xLock */ - (dxUnlock)winUnlock, /* xUnlock */ - (dxCheckReservedLock)winCheckReservedLock, /* xCheckReservedLock */ - (dxFileControl)winFileControl, /* xFileControl */ - (dxSectorSize)winSectorSize, /* xSectorSize */ - (dxDeviceCharacteristics)winDeviceCharacteristics, /* xDeviceCharacteristics */ - (dxShmMap)winShmMap, /* xShmMap */ - (dxShmLock)winShmLock, /* xShmLock */ - (dxShmBarrier)winShmBarrier, /* xShmBarrier */ - (dxShmUnmap)winShmUnmap /* xShmUnmap */ - ); + /* + ** This vector defines all the methods that can operate on an + ** sqlite3_file for win32. + */ + static sqlite3_io_methods winIoMethod = new sqlite3_io_methods( + 2, /* iVersion */ + (dxClose)winClose, /* xClose */ + (dxRead)winRead, /* xRead */ + (dxWrite)winWrite, /* xWrite */ + (dxTruncate)winTruncate, /* xTruncate */ + (dxSync)winSync, /* xSync */ + (dxFileSize)winFileSize, /* xFileSize */ + (dxLock)winLock, /* xLock */ + (dxUnlock)winUnlock, /* xUnlock */ + (dxCheckReservedLock)winCheckReservedLock, /* xCheckReservedLock */ + (dxFileControl)winFileControl, /* xFileControl */ + (dxSectorSize)winSectorSize, /* xSectorSize */ + (dxDeviceCharacteristics)winDeviceCharacteristics, /* xDeviceCharacteristics */ + (dxShmMap)winShmMap, /* xShmMap */ + (dxShmLock)winShmLock, /* xShmLock */ + (dxShmBarrier)winShmBarrier, /* xShmBarrier */ + (dxShmUnmap)winShmUnmap /* xShmUnmap */ + ); - /**************************************************************************** - **************************** sqlite3_vfs methods **************************** - ** - ** This division contains the implementation of methods on the - ** sqlite3_vfs object. - */ + /**************************************************************************** + **************************** sqlite3_vfs methods **************************** + ** + ** This division contains the implementation of methods on the + ** sqlite3_vfs object. + */ - /* - ** Convert a UTF-8 filename into whatever form the underlying - ** operating system wants filenames in. Space to hold the result - ** is obtained from malloc and must be freed by the calling - ** function. - */ - static string convertUtf8Filename(string zFilename) { - return zFilename; - // string zConverted = ""; - //if (isNT()) - //{ - // zConverted = utf8ToUnicode(zFilename); - /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. - */ + /* + ** Convert a UTF-8 filename into whatever form the underlying + ** operating system wants filenames in. Space to hold the result + ** is obtained from malloc and must be freed by the calling + ** function. + */ + static string convertUtf8Filename( string zFilename ) + { + return zFilename; + // string zConverted = ""; + //if (isNT()) + //{ + // zConverted = utf8ToUnicode(zFilename); + /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. + */ #if !SQLITE_OS_WINCE - //} - //else - //{ - // zConverted = sqlite3_win32_utf8_to_mbcs(zFilename); -#endif - //} - /* caller will handle out of memory */ - //return zConverted; - } + //} + //else + //{ + // zConverted = sqlite3_win32_utf8_to_mbcs(zFilename); +#endif + //} + /* caller will handle out of memory */ + //return zConverted; + } - /* - ** Create a temporary file name in zBuf. zBuf must be big enough to - ** hold at pVfs.mxPathname characters. - */ - static int getTempname(int nBuf, StringBuilder zBuf) { - const string zChars = "abcdefghijklmnopqrstuvwxyz0123456789"; - //static char zChars[] = - // "abcdefghijklmnopqrstuvwxyz" - // "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - // "0123456789"; - //size_t i, j; - //char zTempPath[MAX_PATH+1]; - - /* It's odd to simulate an io-error here, but really this is just - ** using the io-error infrastructure to test that SQLite handles this - ** function failing. - */ + /* + ** Create a temporary file name in zBuf. zBuf must be big enough to + ** hold at pVfs.mxPathname characters. + */ + static int getTempname( int nBuf, StringBuilder zBuf ) + { + const string zChars = "abcdefghijklmnopqrstuvwxyz0123456789"; + //static char zChars[] = + // "abcdefghijklmnopqrstuvwxyz" + // "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // "0123456789"; + //size_t i, j; + //char zTempPath[MAX_PATH+1]; + + /* It's odd to simulate an io-error here, but really this is just + ** using the io-error infrastructure to test that SQLite handles this + ** function failing. + */ #if SQLITE_TEST if ( SimulateIOError() ) return SQLITE_IOERR; #endif - //if( sqlite3_temp_directory ){ - // sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory); - //}else if( isNT() ){ - // string zMulti; - // WCHAR zWidePath[MAX_PATH]; - // GetTempPathW(MAX_PATH-30, zWidePath); - // zMulti = unicodeToUtf8(zWidePath); - // if( zMulti ){ - // sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti); - // free(zMulti); - // }else{ - // return SQLITE_NOMEM; - // } - /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. - ** Since the ASCII version of these Windows API do not exist for WINCE, - ** it's important to not reference them for WINCE builds. - */ + //if( sqlite3_temp_directory ){ + // sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory); + //}else if( isNT() ){ + // string zMulti; + // WCHAR zWidePath[MAX_PATH]; + // GetTempPathW(MAX_PATH-30, zWidePath); + // zMulti = unicodeToUtf8(zWidePath); + // if( zMulti ){ + // sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti); + // free(zMulti); + // }else{ + // return SQLITE_NOMEM; + // } + /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. + ** Since the ASCII version of these Windows API do not exist for WINCE, + ** it's important to not reference them for WINCE builds. + */ #if !SQLITE_OS_WINCE - //}else{ - // string zUtf8; - // char zMbcsPath[MAX_PATH]; - // GetTempPathA(MAX_PATH-30, zMbcsPath); - // zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath); - // if( zUtf8 ){ - // sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8); - // free(zUtf8); - // }else{ - // return SQLITE_NOMEM; - // } -#endif - //} - - /* Check that the output buffer is large enough for the temporary file - ** name. If it is not, return SQLITE_ERROR. - */ - //if( (sqlite3Strlen30(zTempPath) + sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX) + 17) >= nBuf ){ - // return SQLITE_ERROR; - //} - - StringBuilder zRandom = new StringBuilder(20); - i64 iRandom = 0; - for (int i = 0; i < 15; i++) { - sqlite3_randomness(1, ref iRandom); - zRandom.Append((char)zChars[(int)(iRandom % (zChars.Length - 1))]); - } - // zBuf[j] = 0; + //}else{ + // string zUtf8; + // char zMbcsPath[MAX_PATH]; + // GetTempPathA(MAX_PATH-30, zMbcsPath); + // zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath); + // if( zUtf8 ){ + // sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8); + // free(zUtf8); + // }else{ + // return SQLITE_NOMEM; + // } +#endif + //} + + /* Check that the output buffer is large enough for the temporary file + ** name. If it is not, return SQLITE_ERROR. + */ + //if( (sqlite3Strlen30(zTempPath) + sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX) + 17) >= nBuf ){ + // return SQLITE_ERROR; + //} + + StringBuilder zRandom = new StringBuilder( 20 ); + i64 iRandom = 0; + for ( int i = 0; i < 15; i++ ) + { + sqlite3_randomness( 1, ref iRandom ); + zRandom.Append( (char)zChars[(int)( iRandom % ( zChars.Length - 1 ) )] ); + } + // zBuf[j] = 0; #if SQLITE_WINRT zBuf.Append( Path.Combine(ApplicationData.Current.LocalFolder.Path, SQLITE_TEMP_FILE_PREFIX + zRandom.ToString()) ); #else - zBuf.Append(Path.GetTempPath() + SQLITE_TEMP_FILE_PREFIX + zRandom.ToString()); -#endif - //for(i=sqlite3Strlen30(zTempPath); i>0 && zTempPath[i-1]=='\\'; i--){} - //zTempPath[i] = 0; - //sqlite3_snprintf(nBuf-17, zBuf, - // "%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPath); - //j = sqlite3Strlen30(zBuf); - //sqlite3_randomness(15, zBuf[j]); - //for(i=0; i<15; i++, j++){ - // zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; - //} - //zBuf[j] = 0; + zBuf.Append( Path.GetTempPath() + SQLITE_TEMP_FILE_PREFIX + zRandom.ToString() ); +#endif + //for(i=sqlite3Strlen30(zTempPath); i>0 && zTempPath[i-1]=='\\'; i--){} + //zTempPath[i] = 0; + //sqlite3_snprintf(nBuf-17, zBuf, + // "%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPath); + //j = sqlite3Strlen30(zBuf); + //sqlite3_randomness(15, zBuf[j]); + //for(i=0; i<15; i++, j++){ + // zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; + //} + //zBuf[j] = 0; #if SQLITE_DEBUG - OSTRACE("TEMP FILENAME: %s\n", zBuf.ToString()); + OSTRACE( "TEMP FILENAME: %s\n", zBuf.ToString() ); #endif - return SQLITE_OK; - } + return SQLITE_OK; + } - /* - ** Open a file. - */ - static int winOpen( - sqlite3_vfs pVfs, /* Not used */ - string zName, /* Name of the file (UTF-8) */ - sqlite3_file pFile, /* Write the SQLite file handle here */ - int flags, /* Open mode flags */ - out int pOutFlags /* Status return flags */ - ) { - //HANDLE h; + /* + ** Open a file. + */ + static int winOpen( + sqlite3_vfs pVfs, /* Not used */ + string zName, /* Name of the file (UTF-8) */ + sqlite3_file pFile, /* Write the SQLite file handle here */ + int flags, /* Open mode flags */ + out int pOutFlags /* Status return flags */ + ) + { + //HANDLE h; #if SQLITE_WINRT IRandomAccessStream fs = null; DWORD dwDesiredAccess = 0; #else - FileStream fs = null; - FileAccess dwDesiredAccess; - FileShare dwShareMode; - FileMode dwCreationDisposition; + FileStream fs = null; + FileAccess dwDesiredAccess; + FileShare dwShareMode; + FileMode dwCreationDisposition; #endif #if !(SQLITE_SILVERLIGHT || WINDOWS_MOBILE || SQLITE_WINRT) - FileOptions dwFlagsAndAttributes; + FileOptions dwFlagsAndAttributes; #endif #if SQLITE_OS_WINCE int isTemp = 0; #endif - //winFile* pFile = (winFile)id; - string zConverted; /* Filename in OS encoding */ - string zUtf8Name = zName; /* Filename in UTF-8 encoding */ - pOutFlags = 0; + //winFile* pFile = (winFile)id; + string zConverted; /* Filename in OS encoding */ + string zUtf8Name = zName; /* Filename in UTF-8 encoding */ + pOutFlags = 0; - /* If argument zPath is a NULL pointer, this function is required to open - ** a temporary file. Use this buffer to store the file name in. - */ - StringBuilder zTmpname = new StringBuilder(MAX_PATH + 1); /* Buffer used to create temp filename */ - - int rc = SQLITE_OK; /* Function Return Code */ - int eType = (int)(flags & 0xFFFFFF00); /* Type of file to open */ - bool isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE) != 0; - bool isDelete = (flags & SQLITE_OPEN_DELETEONCLOSE) != 0; - bool isCreate = (flags & SQLITE_OPEN_CREATE) != 0; - bool isReadonly = (flags & SQLITE_OPEN_READONLY) != 0; - bool isReadWrite = (flags & SQLITE_OPEN_READWRITE) != 0; - bool isOpenJournal = (isCreate && ( - eType == SQLITE_OPEN_MASTER_JOURNAL - || eType == SQLITE_OPEN_MAIN_JOURNAL - || eType == SQLITE_OPEN_WAL - )); - - /* Check the following statements are true: - ** - ** (a) Exactly one of the READWRITE and READONLY flags must be set, and - ** (b) if CREATE is set, then READWRITE must also be set, and - ** (c) if EXCLUSIVE is set, then CREATE must also be set. - ** (d) if DELETEONCLOSE is set, then CREATE must also be set. + /* If argument zPath is a NULL pointer, this function is required to open + ** a temporary file. Use this buffer to store the file name in. */ - Debug.Assert((isReadonly == false || isReadWrite == false) && (isReadWrite || isReadonly)); - Debug.Assert(isCreate == false || isReadWrite); - Debug.Assert(isExclusive == false || isCreate); - Debug.Assert(isDelete == false || isCreate); - - /* The main DB, main journal, WAL file and master journal are never - ** automatically deleted. Nor are they ever temporary files. */ - //Debug.Assert( ( !isDelete && !String.IsNullOrEmpty(zName) ) || eType != SQLITE_OPEN_MAIN_DB ); - Debug.Assert((!isDelete && !String.IsNullOrEmpty(zName)) || eType != SQLITE_OPEN_MAIN_JOURNAL); - Debug.Assert((!isDelete && !String.IsNullOrEmpty(zName)) || eType != SQLITE_OPEN_MASTER_JOURNAL); - Debug.Assert((!isDelete && !String.IsNullOrEmpty(zName)) || eType != SQLITE_OPEN_WAL); - - /* Assert that the upper layer has set one of the "file-type" flags. */ - Debug.Assert(eType == SQLITE_OPEN_MAIN_DB || eType == SQLITE_OPEN_TEMP_DB - || eType == SQLITE_OPEN_MAIN_JOURNAL || eType == SQLITE_OPEN_TEMP_JOURNAL - || eType == SQLITE_OPEN_SUBJOURNAL || eType == SQLITE_OPEN_MASTER_JOURNAL - || eType == SQLITE_OPEN_TRANSIENT_DB || eType == SQLITE_OPEN_WAL - ); - - //assert( id!=0 ); - UNUSED_PARAMETER(pVfs); - - pFile.fs = null;//.h = INVALID_HANDLE_VALUE; - - /* If the second argument to this function is NULL, generate a - ** temporary file name to use - */ - if (String.IsNullOrEmpty(zUtf8Name)) { - Debug.Assert(isDelete && !isOpenJournal); - rc = getTempname(MAX_PATH + 1, zTmpname); - if (rc != SQLITE_OK) { - return rc; - } - zUtf8Name = zTmpname.ToString(); - } - - // /* Convert the filename to the system encoding. */ - zConverted = zUtf8Name;// convertUtf8Filename( zUtf8Name ); - //if ( zConverted.StartsWith( "/", StringComparison.Ordinal ) && !zConverted.StartsWith( "//", StringComparison.Ordinal ) ) - // zConverted = zConverted.Substring( 1 ); - //if ( String.IsNullOrEmpty( zConverted ) ) - //{ - // return SQLITE_NOMEM; - //} -#if !SQLITE_WINRT - if (isReadWrite) { - dwDesiredAccess = FileAccess.Read | FileAccess.Write; // GENERIC_READ | GENERIC_WRITE; - } else { - dwDesiredAccess = FileAccess.Read; // GENERIC_READ; - } - - /* SQLITE_OPEN_EXCLUSIVE is used to make sure that a new file is - ** created. SQLite doesn't use it to indicate "exclusive access" - ** as it is usually understood. - */ - if (isExclusive) { - /* Creates a new file, only if it does not already exist. */ - /* If the file exists, it fails. */ - dwCreationDisposition = FileMode.CreateNew;// CREATE_NEW; - } else if (isCreate) { - /* Open existing file, or create if it doesn't exist */ - dwCreationDisposition = FileMode.OpenOrCreate;// OPEN_ALWAYS; - } else { - /* Opens a file, only if it exists. */ - dwCreationDisposition = FileMode.Open;//OPEN_EXISTING; - } + StringBuilder zTmpname = new StringBuilder( MAX_PATH + 1 ); /* Buffer used to create temp filename */ + + int rc = SQLITE_OK; /* Function Return Code */ + int eType = (int)( flags & 0xFFFFFF00 ); /* Type of file to open */ + bool isExclusive = ( flags & SQLITE_OPEN_EXCLUSIVE ) != 0; + bool isDelete = ( flags & SQLITE_OPEN_DELETEONCLOSE ) != 0; + bool isCreate = ( flags & SQLITE_OPEN_CREATE ) != 0; + bool isReadonly = ( flags & SQLITE_OPEN_READONLY ) != 0; + bool isReadWrite = ( flags & SQLITE_OPEN_READWRITE ) != 0; + bool isOpenJournal = ( isCreate && ( + eType == SQLITE_OPEN_MASTER_JOURNAL + || eType == SQLITE_OPEN_MAIN_JOURNAL + || eType == SQLITE_OPEN_WAL + ) ); + + /* Check the following statements are true: +** +** (a) Exactly one of the READWRITE and READONLY flags must be set, and +** (b) if CREATE is set, then READWRITE must also be set, and +** (c) if EXCLUSIVE is set, then CREATE must also be set. +** (d) if DELETEONCLOSE is set, then CREATE must also be set. +*/ + Debug.Assert( ( isReadonly == false || isReadWrite == false ) && ( isReadWrite || isReadonly ) ); + Debug.Assert( isCreate == false || isReadWrite ); + Debug.Assert( isExclusive == false || isCreate ); + Debug.Assert( isDelete == false || isCreate ); + + /* The main DB, main journal, WAL file and master journal are never + ** automatically deleted. Nor are they ever temporary files. */ + //Debug.Assert( ( !isDelete && !String.IsNullOrEmpty(zName) ) || eType != SQLITE_OPEN_MAIN_DB ); + Debug.Assert( ( !isDelete && !String.IsNullOrEmpty( zName ) ) || eType != SQLITE_OPEN_MAIN_JOURNAL ); + Debug.Assert( ( !isDelete && !String.IsNullOrEmpty( zName ) ) || eType != SQLITE_OPEN_MASTER_JOURNAL ); + Debug.Assert( ( !isDelete && !String.IsNullOrEmpty( zName ) ) || eType != SQLITE_OPEN_WAL ); + + /* Assert that the upper layer has set one of the "file-type" flags. */ + Debug.Assert( eType == SQLITE_OPEN_MAIN_DB || eType == SQLITE_OPEN_TEMP_DB + || eType == SQLITE_OPEN_MAIN_JOURNAL || eType == SQLITE_OPEN_TEMP_JOURNAL + || eType == SQLITE_OPEN_SUBJOURNAL || eType == SQLITE_OPEN_MASTER_JOURNAL + || eType == SQLITE_OPEN_TRANSIENT_DB || eType == SQLITE_OPEN_WAL + ); - dwShareMode = FileShare.Read | FileShare.Write;// FILE_SHARE_READ | FILE_SHARE_WRITE; -#endif - if (isDelete) { -#if SQLITE_OS_WINCE -dwFlagsAndAttributes = FILE_ATTRIBUTE_HIDDEN; -isTemp = 1; -#else -#if !(SQLITE_SILVERLIGHT || WINDOWS_MOBILE || SQLITE_WINRT) - dwFlagsAndAttributes = FileOptions.DeleteOnClose; // FILE_ATTRIBUTE_TEMPORARY - //| FILE_ATTRIBUTE_HIDDEN - //| FILE_FLAG_DELETE_ON_CLOSE; -#endif -#endif - } else { -#if !(SQLITE_SILVERLIGHT || WINDOWS_MOBILE || SQLITE_WINRT) - dwFlagsAndAttributes = FileOptions.None; // FILE_ATTRIBUTE_NORMAL; -#endif - } - /* Reports from the internet are that performance is always - ** better if FILE_FLAG_RANDOM_ACCESS is used. Ticket #2699. */ -#if SQLITE_OS_WINCE -dwFlagsAndAttributes |= FileOptions.RandomAccess; // FILE_FLAG_RANDOM_ACCESS; -#endif + //assert( id!=0 ); + UNUSED_PARAMETER( pVfs ); - if (isNT()) { - //h = CreateFileW((WCHAR)zConverted, - // dwDesiredAccess, - // dwShareMode, - // NULL, - // dwCreationDisposition, - // dwFlagsAndAttributes, - // NULL - //); - - // - // retry opening the file a few times; this is because of a racing condition between a delete and open call to the FS - // - int retries = 3; - while ((fs == null) && (retries > 0)) - try { - retries--; -#if SQLITE_WINRT + pFile.fs = null;//.h = INVALID_HANDLE_VALUE; + + /* If the second argument to this function is NULL, generate a + ** temporary file name to use + */ + if ( String.IsNullOrEmpty( zUtf8Name ) ) + { + Debug.Assert( isDelete && !isOpenJournal ); + rc = getTempname( MAX_PATH + 1, zTmpname ); + if ( rc != SQLITE_OK ) + { + return rc; + } + zUtf8Name = zTmpname.ToString(); + } + + // /* Convert the filename to the system encoding. */ + zConverted = zUtf8Name;// convertUtf8Filename( zUtf8Name ); + //if ( zConverted.StartsWith( "/", StringComparison.Ordinal ) && !zConverted.StartsWith( "//", StringComparison.Ordinal ) ) + // zConverted = zConverted.Substring( 1 ); + //if ( String.IsNullOrEmpty( zConverted ) ) + //{ + // return SQLITE_NOMEM; + //} +#if !SQLITE_WINRT + if ( isReadWrite ) + { + dwDesiredAccess = FileAccess.Read | FileAccess.Write; // GENERIC_READ | GENERIC_WRITE; + } + else + { + dwDesiredAccess = FileAccess.Read; // GENERIC_READ; + } + + /* SQLITE_OPEN_EXCLUSIVE is used to make sure that a new file is + ** created. SQLite doesn't use it to indicate "exclusive access" + ** as it is usually understood. + */ + if ( isExclusive ) + { + /* Creates a new file, only if it does not already exist. */ + /* If the file exists, it fails. */ + dwCreationDisposition = FileMode.CreateNew;// CREATE_NEW; + } + else if ( isCreate ) + { + /* Open existing file, or create if it doesn't exist */ + dwCreationDisposition = FileMode.OpenOrCreate;// OPEN_ALWAYS; + } + else + { + /* Opens a file, only if it exists. */ + dwCreationDisposition = FileMode.Open;//OPEN_EXISTING; + } + + dwShareMode = FileShare.Read | FileShare.Write;// FILE_SHARE_READ | FILE_SHARE_WRITE; +#endif + if ( isDelete ) + { +#if SQLITE_OS_WINCE +dwFlagsAndAttributes = FILE_ATTRIBUTE_HIDDEN; +isTemp = 1; +#else +#if !(SQLITE_SILVERLIGHT || WINDOWS_MOBILE || SQLITE_WINRT) + dwFlagsAndAttributes = FileOptions.DeleteOnClose; // FILE_ATTRIBUTE_TEMPORARY + //| FILE_ATTRIBUTE_HIDDEN + //| FILE_FLAG_DELETE_ON_CLOSE; +#endif +#endif + } + else + { +#if !(SQLITE_SILVERLIGHT || WINDOWS_MOBILE || SQLITE_WINRT) + dwFlagsAndAttributes = FileOptions.None; // FILE_ATTRIBUTE_NORMAL; +#endif + } + /* Reports from the internet are that performance is always + ** better if FILE_FLAG_RANDOM_ACCESS is used. Ticket #2699. */ +#if SQLITE_OS_WINCE +dwFlagsAndAttributes |= FileOptions.RandomAccess; // FILE_FLAG_RANDOM_ACCESS; +#endif + + if ( isNT() ) + { + //h = CreateFileW((WCHAR)zConverted, + // dwDesiredAccess, + // dwShareMode, + // NULL, + // dwCreationDisposition, + // dwFlagsAndAttributes, + // NULL + //); + + // + // retry opening the file a few times; this is because of a racing condition between a delete and open call to the FS + // + int retries = 3; + while ( ( fs == null ) && ( retries > 0 ) ) + try + { + retries--; +#if SQLITE_WINRT Task fileTask = null; if(isExclusive) @@ -2616,10 +2739,10 @@ static int winOpen( Task streamTask = fileTask.Result.OpenAsync(FileAccessMode.ReadWrite).AsTask(); streamTask.Wait(); fs = streamTask.Result; -#elif WINDOWS_PHONE || SQLITE_SILVERLIGHT +#elif WINDOWS_PHONE || SQLITE_SILVERLIGHT fs = new IsolatedStorageFileStream(zConverted, dwCreationDisposition, dwDesiredAccess, dwShareMode, IsolatedStorageFile.GetUserStoreForApplication()); #elif !(SQLITE_SILVERLIGHT || WINDOWS_MOBILE) - fs = new FileStream(zConverted, dwCreationDisposition, dwDesiredAccess, dwShareMode, 4096, dwFlagsAndAttributes); + fs = new FileStream( zConverted, dwCreationDisposition, dwDesiredAccess, dwShareMode, 4096, dwFlagsAndAttributes ); #else fs = new FileStream( zConverted, dwCreationDisposition, dwDesiredAccess, dwShareMode, 4096); #endif @@ -2628,81 +2751,91 @@ static int winOpen( #if WINDOWS_PHONE || SQLITE_SILVERLIGHT OSTRACE( "OPEN %d (%s)\n", fs.GetHashCode(), zName ); #else - OSTRACE("OPEN %d (%s)\n", fs.GetHashCode(), fs.Name); + OSTRACE("OPEN %d (%s)\n", fs.GetHashCode(), fs.Name); #endif #endif - } catch (Exception e) { + } + catch ( Exception e ) + { #if SQLITE_WINRT System.Threading.Tasks.Task.Delay(100).Wait(); #else - Thread.Sleep(100); + Thread.Sleep(100); #endif - } + } - /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. - ** Since the ASCII version of these Windows API do not exist for WINCE, - ** it's important to not reference them for WINCE builds. - */ + /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. + ** Since the ASCII version of these Windows API do not exist for WINCE, + ** it's important to not reference them for WINCE builds. + */ #if !SQLITE_OS_WINCE - } else { - Debugger.Break(); // Not NT - //h = CreateFileA((char)zConverted, - // dwDesiredAccess, - // dwShareMode, - // NULL, - // dwCreationDisposition, - // dwFlagsAndAttributes, - // NULL - //); + } + else + { + Debugger.Break(); // Not NT + //h = CreateFileA((char)zConverted, + // dwDesiredAccess, + // dwShareMode, + // NULL, + // dwCreationDisposition, + // dwFlagsAndAttributes, + // NULL + //); #endif - } + } - OSTRACE("OPEN %d %s 0x%lx %s\n", - pFile.GetHashCode(), zName, dwDesiredAccess, - fs == null ? "failed" : "ok"); - if (fs == null - || + OSTRACE( "OPEN %d %s 0x%lx %s\n", + pFile.GetHashCode(), zName, dwDesiredAccess, + fs == null ? "failed" : "ok" ); + if ( fs == null + || #if !(SQLITE_SILVERLIGHT || WINDOWS_MOBILE || SQLITE_WINRT) - fs.SafeFileHandle.IsInvalid + fs.SafeFileHandle.IsInvalid #else !fs.CanRead #endif - ) //(h == INVALID_HANDLE_VALUE) - { + ) //(h == INVALID_HANDLE_VALUE) + { #if SQLITE_SILVERLIGHT || SQLITE_WINRT pFile.lastErrno = 1; #else - // pFile.lastErrno = GetLastError(); - pFile.lastErrno = (u32)HelperMethods.GetLastError(); -#endif - winLogError(SQLITE_CANTOPEN, "winOpen", zUtf8Name); - // free(zConverted); - if (isReadWrite) { - return winOpen(pVfs, zName, pFile, - ((flags | SQLITE_OPEN_READONLY) & ~(SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE)), out pOutFlags); - } else { - return SQLITE_CANTOPEN_BKPT(); - } - } + // pFile.lastErrno = GetLastError(); + pFile.lastErrno = (u32)HelperMethods.GetLastError(); +#endif + winLogError(SQLITE_CANTOPEN, "winOpen", zUtf8Name); + // free(zConverted); + if ( isReadWrite ) + { + return winOpen( pVfs, zName, pFile, + ( ( flags | SQLITE_OPEN_READONLY ) & ~( SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE ) ), out pOutFlags ); + } + else + { + return SQLITE_CANTOPEN_BKPT(); + } + } - //if ( pOutFlags ) - //{ - if (isReadWrite) { - pOutFlags = SQLITE_OPEN_READWRITE; - } else { - pOutFlags = SQLITE_OPEN_READONLY; - } - //} - - pFile.Clear(); // memset(pFile, 0, sizeof(*pFile)); - pFile.pMethods = winIoMethod; - pFile.fs = fs; - pFile.lastErrno = NO_ERROR; - pFile.pVfs = pVfs; - pFile.pShm = null; - pFile.zPath = zName; - pFile.sectorSize = (ulong)getSectorSize(pVfs, zUtf8Name); + //if ( pOutFlags ) + //{ + if ( isReadWrite ) + { + pOutFlags = SQLITE_OPEN_READWRITE; + } + else + { + pOutFlags = SQLITE_OPEN_READONLY; + } + //} + + pFile.Clear(); // memset(pFile, 0, sizeof(*pFile)); + pFile.pMethods = winIoMethod; + pFile.fs = fs; + pFile.lastErrno = NO_ERROR; + pFile.pVfs = pVfs; + pFile.pShm = null; + pFile.zPath = zName; + pFile.sectorSize = (ulong)getSectorSize( pVfs, zUtf8Name ); #if SQLITE_OS_WINCE if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB && !winceCreateLock(zName, pFile) @@ -2715,70 +2848,73 @@ static int winOpen( pFile.zDeleteOnClose = zConverted; }else #endif - { - // free(zConverted); - } + { + // free(zConverted); + } #if SQLITE_TEST OpenCounter( +1 ); #endif - return rc; - } + return rc; + } - /* - ** Delete the named file. - ** - ** Note that windows does not allow a file to be deleted if some other - ** process has it open. Sometimes a virus scanner or indexing program - ** will open a journal file shortly after it is created in order to do - ** whatever it does. While this other process is holding the - ** file open, we will be unable to delete it. To work around this - ** problem, we delay 100 milliseconds and try to delete again. Up - ** to MX_DELETION_ATTEMPTs deletion attempts are run before giving - ** up and returning an error. - */ - static int MX_DELETION_ATTEMPTS = 5; - static int winDelete( - sqlite3_vfs pVfs, /* Not used on win32 */ - string zFilename, /* Name of file to delete */ - int syncDir /* Not used on win32 */ - ) { - int cnt = 0; - int rc = SQLITE_ERROR; - int error; - string zConverted; - UNUSED_PARAMETER(pVfs); - UNUSED_PARAMETER(syncDir); + /* + ** Delete the named file. + ** + ** Note that windows does not allow a file to be deleted if some other + ** process has it open. Sometimes a virus scanner or indexing program + ** will open a journal file shortly after it is created in order to do + ** whatever it does. While this other process is holding the + ** file open, we will be unable to delete it. To work around this + ** problem, we delay 100 milliseconds and try to delete again. Up + ** to MX_DELETION_ATTEMPTs deletion attempts are run before giving + ** up and returning an error. + */ + static int MX_DELETION_ATTEMPTS = 5; + static int winDelete( + sqlite3_vfs pVfs, /* Not used on win32 */ + string zFilename, /* Name of file to delete */ + int syncDir /* Not used on win32 */ + ) + { + int cnt = 0; + int rc = SQLITE_ERROR; + int error; + string zConverted; + UNUSED_PARAMETER( pVfs ); + UNUSED_PARAMETER( syncDir ); #if SQLITE_TEST if ( SimulateIOError() ) return SQLITE_IOERR_DELETE; #endif - zConverted = convertUtf8Filename(zFilename); - //if ( zConverted == null || zConverted == "" ) - //{ - // return SQLITE_NOMEM; - //} - if (isNT()) { - do - // DeleteFileW(zConverted); - //}while( ( ((rc = GetFileAttributesW(zConverted)) != INVALID_FILE_ATTRIBUTES) - // || ((error = GetLastError()) == ERROR_ACCESS_DENIED)) - // && (++cnt < MX_DELETION_ATTEMPTS) - // && (Sleep(100), 1) ); - { + zConverted = convertUtf8Filename( zFilename ); + //if ( zConverted == null || zConverted == "" ) + //{ + // return SQLITE_NOMEM; + //} + if ( isNT() ) + { + do + // DeleteFileW(zConverted); + //}while( ( ((rc = GetFileAttributesW(zConverted)) != INVALID_FILE_ATTRIBUTES) + // || ((error = GetLastError()) == ERROR_ACCESS_DENIED)) + // && (++cnt < MX_DELETION_ATTEMPTS) + // && (Sleep(100), 1) ); + { #if SQLITE_WINRT if(!HelperMethods.FileExists(zFilename)) #elif WINDOWS_PHONE if ( !System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication().FileExists( zFilename ) ) #else - if (!File.Exists(zFilename)) + if ( !File.Exists( zFilename ) ) #endif - { - rc = SQLITE_IOERR; - break; - } - try { + { + rc = SQLITE_IOERR; + break; + } + try + { #if SQLITE_WINRT Task fileTask = StorageFile.GetFileFromPathAsync(zConverted).AsTask(); fileTask.Wait(); @@ -2788,72 +2924,82 @@ int syncDir /* Not used on win32 */ #elif SQLITE_SILVERLIGHT IsolatedStorageFile.GetUserStoreForApplication().DeleteFile(zFilename); #else - File.Delete(zConverted); + File.Delete( zConverted ); #endif - rc = SQLITE_OK; - } catch (IOException e) { - rc = SQLITE_IOERR; + rc = SQLITE_OK; + } + catch ( IOException e ) + { + rc = SQLITE_IOERR; #if SQLITE_WINRT System.Threading.Tasks.Task.Delay(100).Wait(); #else - Thread.Sleep(100); -#endif - } - } while (rc != SQLITE_OK && ++cnt < MX_DELETION_ATTEMPTS); - /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. - ** Since the ASCII version of these Windows API do not exist for WINCE, - ** it's important to not reference them for WINCE builds. - */ + Thread.Sleep(100); +#endif + } + } while ( rc != SQLITE_OK && ++cnt < MX_DELETION_ATTEMPTS ); + /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. + ** Since the ASCII version of these Windows API do not exist for WINCE, + ** it's important to not reference them for WINCE builds. + */ #if !SQLITE_OS_WINCE && !SQLITE_WINRT - } else { - do { - //DeleteFileA( zConverted ); - //}while( ( ((rc = GetFileAttributesA(zConverted)) != INVALID_FILE_ATTRIBUTES) - // || ((error = GetLastError()) == ERROR_ACCESS_DENIED)) - // && (cnt++ < MX_DELETION_ATTEMPTS) - // && (Sleep(100), 1) ); - if (!File.Exists(zFilename)) { - rc = SQLITE_IOERR; - break; - } - try { - File.Delete(zConverted); - rc = SQLITE_OK; - } catch (IOException e) { - rc = SQLITE_IOERR; - Thread.Sleep(100); - } - } while (rc != SQLITE_OK && cnt++ < MX_DELETION_ATTEMPTS); + } + else + { + do + { + //DeleteFileA( zConverted ); + //}while( ( ((rc = GetFileAttributesA(zConverted)) != INVALID_FILE_ATTRIBUTES) + // || ((error = GetLastError()) == ERROR_ACCESS_DENIED)) + // && (cnt++ < MX_DELETION_ATTEMPTS) + // && (Sleep(100), 1) ); + if ( !File.Exists( zFilename ) ) + { + rc = SQLITE_IOERR; + break; + } + try + { + File.Delete( zConverted ); + rc = SQLITE_OK; + } + catch ( IOException e ) + { + rc = SQLITE_IOERR; + Thread.Sleep( 100 ); + } + } while ( rc != SQLITE_OK && cnt++ < MX_DELETION_ATTEMPTS ); #endif - } - //free(zConverted); + } + //free(zConverted); #if SQLITE_DEBUG - OSTRACE("DELETE \"%s\"\n", zFilename); + OSTRACE( "DELETE \"%s\"\n", zFilename ); #endif - if (rc == SQLITE_OK) - return rc; + if ( rc == SQLITE_OK ) + return rc; - error = HelperMethods.GetLastError(); + error = HelperMethods.GetLastError(); - return ((rc == INVALID_FILE_ATTRIBUTES) - && (error == ERROR_FILE_NOT_FOUND)) ? SQLITE_OK : - winLogError(SQLITE_IOERR_DELETE, "winDelete", zFilename); - } + return ( ( rc == INVALID_FILE_ATTRIBUTES ) + && ( error == ERROR_FILE_NOT_FOUND ) ) ? SQLITE_OK : + winLogError(SQLITE_IOERR_DELETE, "winDelete", zFilename); + } - /* - ** Check the existence and status of a file. - */ - static int winAccess( - sqlite3_vfs pVfs, /* Not used on win32 */ - string zFilename, /* Name of file to check */ - int flags, /* Type of test to make on this file */ - out int pResOut /* OUT: Result */ - ) { - FileAttributes attr = 0; // DWORD attr; - int rc = 0; - // void *zConverted; - UNUSED_PARAMETER(pVfs); + /* + ** Check the existence and status of a file. + */ + static int winAccess( + sqlite3_vfs pVfs, /* Not used on win32 */ + string zFilename, /* Name of file to check */ + int flags, /* Type of test to make on this file */ + out int pResOut /* OUT: Result */ + ) + { + FileAttributes attr = 0; // DWORD attr; + int rc = 0; + // void *zConverted; + UNUSED_PARAMETER( pVfs ); #if SQLITE_TEST if ( SimulateIOError() ) @@ -2862,15 +3008,16 @@ static int winAccess( return SQLITE_IOERR_ACCESS; } #endif - //zConverted = convertUtf8Filename(zFilename); - // if( zConverted==0 ){ - // return SQLITE_NOMEM; - // } - //if ( isNT() ) - //{ - // - // Do a quick test to prevent the try/catch block - if (flags == SQLITE_ACCESS_EXISTS) { + //zConverted = convertUtf8Filename(zFilename); + // if( zConverted==0 ){ + // return SQLITE_NOMEM; + // } + //if ( isNT() ) + //{ + // + // Do a quick test to prevent the try/catch block + if ( flags == SQLITE_ACCESS_EXISTS ) + { #if SQLITE_WINRT pResOut = HelperMethods.FileExists(zFilename) ? 1 : 0; #elif WINDOWS_PHONE @@ -2878,36 +3025,37 @@ static int winAccess( #elif SQLITE_SILVERLIGHT pResOut = IsolatedStorageFile.GetUserStoreForApplication().FileExists(zFilename) ? 1 : 0; #else - pResOut = File.Exists(zFilename) ? 1 : 0; + pResOut = File.Exists( zFilename ) ? 1 : 0; #endif - return SQLITE_OK; - } - // - try { - //WIN32_FILE_ATTRIBUTE_DATA sAttrData; - //memset(&sAttrData, 0, sizeof(sAttrData)); - //if( GetFileAttributesExW((WCHAR)zConverted, - // GetFileExInfoStandard, - // &sAttrData) ){ - // /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file - // ** as if it does not exist. - // */ - // if( flags==SQLITE_ACCESS_EXISTS - // && sAttrData.nFileSizeHigh==0 - // && sAttrData.nFileSizeLow==0 ){ - // attr = INVALID_FILE_ATTRIBUTES; - // }else{ - // attr = sAttrData.dwFileAttributes; - // } - //}else{ - // if( GetLastError()!=ERROR_FILE_NOT_FOUND ){ - // winLogError(SQLITE_IOERR_ACCESS, "winAccess", zFilename); - // free(zConverted); - // return SQLITE_IOERR_ACCESS; - // }else{ - // attr = INVALID_FILE_ATTRIBUTES; - // } - //} + return SQLITE_OK; + } + // + try + { + //WIN32_FILE_ATTRIBUTE_DATA sAttrData; + //memset(&sAttrData, 0, sizeof(sAttrData)); + //if( GetFileAttributesExW((WCHAR)zConverted, + // GetFileExInfoStandard, + // &sAttrData) ){ + // /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file + // ** as if it does not exist. + // */ + // if( flags==SQLITE_ACCESS_EXISTS + // && sAttrData.nFileSizeHigh==0 + // && sAttrData.nFileSizeLow==0 ){ + // attr = INVALID_FILE_ATTRIBUTES; + // }else{ + // attr = sAttrData.dwFileAttributes; + // } + //}else{ + // if( GetLastError()!=ERROR_FILE_NOT_FOUND ){ + // winLogError(SQLITE_IOERR_ACCESS, "winAccess", zFilename); + // free(zConverted); + // return SQLITE_IOERR_ACCESS; + // }else{ + // attr = INVALID_FILE_ATTRIBUTES; + // } + //} #if SQLITE_WINRT attr = FileAttributes.Normal; } @@ -2919,13 +3067,14 @@ static int winAccess( #elif WINDOWS_PHONE || SQLITE_SILVERLIGHT if (System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication().DirectoryExists(zFilename)) #else - if (Directory.Exists(zFilename)) + if (Directory.Exists( zFilename )) #endif - { - try { - var tempName = new StringBuilder(); - getTempname(MAX_PATH + 1, tempName); - string name = Path.Combine(zFilename, Path.GetFileNameWithoutExtension(tempName.ToString())); + { + try + { + var tempName = new StringBuilder(); + getTempname(MAX_PATH + 1, tempName); + string name = Path.Combine(zFilename, Path.GetFileNameWithoutExtension(tempName.ToString())); #if SQLITE_WINRT Task fileTask = StorageFolder.GetFolderFromPathAsync(path).AsTask(); @@ -2936,68 +3085,73 @@ static int winAccess( stream.Close(); IsolatedStorageFile.GetUserStoreForApplication().DeleteFile(name); #else - FileStream fs = File.Create(name); - fs.Close(); - File.Delete(name); -#endif - attr = FileAttributes.Normal; - } catch (IOException e) { - attr = FileAttributes.ReadOnly; - } - } - } - /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. - ** Since the ASCII version of these Windows API do not exist for WINCE, - ** it's important to not reference them for WINCE builds. - */ + FileStream fs = File.Create( name ); + fs.Close(); + File.Delete( name ); +#endif + attr = FileAttributes.Normal; + } + catch ( IOException e ) + { + attr = FileAttributes.ReadOnly; + } + } + } + /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. + ** Since the ASCII version of these Windows API do not exist for WINCE, + ** it's important to not reference them for WINCE builds. + */ #if !SQLITE_OS_WINCE - //} - //else - //{ - // attr = GetFileAttributesA( (char)zConverted ); + //} + //else + //{ + // attr = GetFileAttributesA( (char)zConverted ); #endif #endif - //} - catch (IOException e) { - winLogError(SQLITE_IOERR_ACCESS, "winAccess", zFilename); - } - // free(zConverted); - switch (flags) { - case SQLITE_ACCESS_READ: - case SQLITE_ACCESS_EXISTS: -#if SQLITE_WINRT + //} + catch ( IOException e ) + { + winLogError(SQLITE_IOERR_ACCESS, "winAccess", zFilename); + } + // free(zConverted); + switch ( flags ) + { + case SQLITE_ACCESS_READ: + case SQLITE_ACCESS_EXISTS: +#if SQLITE_WINRT rc = attr == FileAttributes.Normal ? 1 : 0;// != INVALID_FILE_ATTRIBUTES; #else - rc = attr != 0 ? 1 : 0;// != INVALID_FILE_ATTRIBUTES; + rc = attr != 0 ? 1 : 0;// != INVALID_FILE_ATTRIBUTES; #endif - break; - case SQLITE_ACCESS_READWRITE: -#if SQLITE_WINRT + break; + case SQLITE_ACCESS_READWRITE: +#if SQLITE_WINRT rc = attr != FileAttributes.Normal ? 0 : (int)( attr & FileAttributes.ReadOnly ) != 0 ? 0 : 1; //FILE_ATTRIBUTE_READONLY ) == 0; #else - rc = attr == 0 ? 0 : (int)(attr & FileAttributes.ReadOnly) != 0 ? 0 : 1; //FILE_ATTRIBUTE_READONLY ) == 0; + rc = attr == 0 ? 0 : (int)( attr & FileAttributes.ReadOnly ) != 0 ? 0 : 1; //FILE_ATTRIBUTE_READONLY ) == 0; #endif - break; - default: - Debug.Assert("" == "Invalid flags argument"); - rc = 0; - break; - } - pResOut = rc; - return SQLITE_OK; - } + break; + default: + Debug.Assert( "" == "Invalid flags argument" ); + rc = 0; + break; + } + pResOut = rc; + return SQLITE_OK; + } - /* - ** Turn a relative pathname into a full pathname. Write the full - ** pathname into zOut[]. zOut[] will be at least pVfs.mxPathname - ** bytes in size. - */ - static int winFullPathname( - sqlite3_vfs pVfs, /* Pointer to vfs object */ - string zRelative, /* Possibly relative input path */ - int nFull, /* Size of output buffer in bytes */ - StringBuilder zFull /* Output buffer */ - ) { + /* + ** Turn a relative pathname into a full pathname. Write the full + ** pathname into zOut[]. zOut[] will be at least pVfs.mxPathname + ** bytes in size. + */ + static int winFullPathname( + sqlite3_vfs pVfs, /* Pointer to vfs object */ + string zRelative, /* Possibly relative input path */ + int nFull, /* Size of output buffer in bytes */ + StringBuilder zFull /* Output buffer */ + ) + { #if __CYGWIN__ SimulateIOError( return SQLITE_ERROR ); @@ -3015,97 +3169,110 @@ StringBuilder zFull /* Output buffer */ #endif #if !SQLITE_OS_WINCE && !__CYGWIN__ - int nByte; - //string zConverted; - string zOut = null; + int nByte; + //string zConverted; + string zOut = null; - /* If this path name begins with "/X:", where "X" is any alphabetic - ** character, discard the initial "/" from the pathname. - */ - if (zRelative.Length >= 3 && zRelative[0] == '/' && Char.IsLetter(zRelative[1]) && zRelative[2] == ':') { - zRelative = zRelative.Substring(1); - } + /* If this path name begins with "/X:", where "X" is any alphabetic + ** character, discard the initial "/" from the pathname. + */ + if( zRelative.Length >= 3 && zRelative[0]=='/' && Char.IsLetter(zRelative[1]) && zRelative[2]==':' ){ + zRelative = zRelative.Substring(1); + } - /* It's odd to simulate an io-error here, but really this is just - ** using the io-error infrastructure to test that SQLite handles this - ** function failing. This function could fail if, for example, the - ** current working directory has been unlinked. - */ + /* It's odd to simulate an io-error here, but really this is just + ** using the io-error infrastructure to test that SQLite handles this + ** function failing. This function could fail if, for example, the + ** current working directory has been unlinked. + */ #if SQLITE_TEST if ( SimulateIOError() ) return SQLITE_ERROR; #endif - UNUSED_PARAMETER(nFull); - //convertUtf8Filename(zRelative)); - if (isNT()) { - //string zTemp; - //nByte = GetFullPathNameW( zConverted, 0, 0, 0) + 3; - //zTemp = malloc( nByte*sizeof(zTemp[0]) ); - //if( zTemp==0 ){ - // free(zConverted); - // return SQLITE_NOMEM; - //} - //zTemp = GetFullPathNameW(zConverted, nByte, zTemp, 0); - // will happen on exit; was free(zConverted); - try { -#if WINDOWS_PHONE || SQLITE_SILVERLIGHT || SQLITE_WINRT + UNUSED_PARAMETER( nFull ); + //convertUtf8Filename(zRelative)); + if ( isNT() ) + { + //string zTemp; + //nByte = GetFullPathNameW( zConverted, 0, 0, 0) + 3; + //zTemp = malloc( nByte*sizeof(zTemp[0]) ); + //if( zTemp==0 ){ + // free(zConverted); + // return SQLITE_NOMEM; + //} + //zTemp = GetFullPathNameW(zConverted, nByte, zTemp, 0); + // will happen on exit; was free(zConverted); + try + { +#if WINDOWS_PHONE || SQLITE_SILVERLIGHT || SQLITE_WINRT zOut = zRelative; #else - if (Environment.OSVersion.Platform == PlatformID.Unix - && zRelative.Length > 2 && zRelative[0] == '~' && (zRelative[1] == '/' || zRelative[1] == '\\')) { - string home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); - zOut = Path.GetFullPath(home + zRelative.Substring(1)); - } else { - zOut = Path.GetFullPath(zRelative); // was unicodeToUtf8(zTemp); - } -#endif - } catch (Exception e) { - zOut = zRelative; - } - // will happen on exit; was free(zTemp); - /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. - ** Since the ASCII version of these Windows API do not exist for WINCE, - ** it's important to not reference them for WINCE builds. - */ + if (Environment.OSVersion.Platform == PlatformID.Unix + && zRelative.Length > 2 && zRelative[0] == '~' && (zRelative[1] == '/' || zRelative[1] == '\\')) + { + string home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); + zOut = Path.GetFullPath(home + zRelative.Substring(1)); + } + else + { + zOut = Path.GetFullPath( zRelative ); // was unicodeToUtf8(zTemp); + } +#endif + } + catch ( Exception e ) + { + zOut = zRelative; + } + // will happen on exit; was free(zTemp); + /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. + ** Since the ASCII version of these Windows API do not exist for WINCE, + ** it's important to not reference them for WINCE builds. + */ #if !SQLITE_OS_WINCE - } else { - Debugger.Break(); // -- Not Running under NT - //string zTemp; - //nByte = GetFullPathNameA(zConverted, 0, 0, 0) + 3; - //zTemp = malloc( nByte*sizeof(zTemp[0]) ); - //if( zTemp==0 ){ - // free(zConverted); - // return SQLITE_NOMEM; - //} - //GetFullPathNameA( zConverted, nByte, zTemp, 0); - // free(zConverted); - //zOut = sqlite3_win32_mbcs_to_utf8(zTemp); - // free(zTemp); + } + else + { + Debugger.Break(); // -- Not Running under NT + //string zTemp; + //nByte = GetFullPathNameA(zConverted, 0, 0, 0) + 3; + //zTemp = malloc( nByte*sizeof(zTemp[0]) ); + //if( zTemp==0 ){ + // free(zConverted); + // return SQLITE_NOMEM; + //} + //GetFullPathNameA( zConverted, nByte, zTemp, 0); + // free(zConverted); + //zOut = sqlite3_win32_mbcs_to_utf8(zTemp); + // free(zTemp); #endif - } - if (zOut != null) { - // sqlite3_snprintf(pVfs.mxPathname, zFull, "%s", zOut); - if (zFull.Length > pVfs.mxPathname) - zFull.Length = pVfs.mxPathname; - zFull.Append(zOut); - - // will happen on exit; was free(zOut); - return SQLITE_OK; - } else { - return SQLITE_NOMEM; - } + } + if ( zOut != null ) + { + // sqlite3_snprintf(pVfs.mxPathname, zFull, "%s", zOut); + if ( zFull.Length > pVfs.mxPathname ) + zFull.Length = pVfs.mxPathname; + zFull.Append( zOut ); + + // will happen on exit; was free(zOut); + return SQLITE_OK; + } + else + { + return SQLITE_NOMEM; + } #endif - } + } - /* - ** Get the sector size of the device used to store - ** file. - */ - static int getSectorSize( - sqlite3_vfs pVfs, - string zRelative /* UTF-8 file name */ - ) { + /* + ** Get the sector size of the device used to store + ** file. + */ + static int getSectorSize( + sqlite3_vfs pVfs, + string zRelative /* UTF-8 file name */ + ) + { #if FALSE int bytesPerSector = SQLITE_DEFAULT_SECTOR_SIZE; /* GetDiskFreeSpace is not supported under WINCE */ @@ -3189,72 +3356,76 @@ string zRelative /* UTF-8 file name */ #endif return bytesPerSector == 0 ? SQLITE_DEFAULT_SECTOR_SIZE : bytesPerSector; #endif - return SQLITE_DEFAULT_SECTOR_SIZE; - } + return SQLITE_DEFAULT_SECTOR_SIZE; + } #if !SQLITE_OMIT_LOAD_EXTENSION - /* + /* +** Interfaces for opening a shared library, finding entry points +** within the shared library, and closing the shared library. +*/ + /* ** Interfaces for opening a shared library, finding entry points ** within the shared library, and closing the shared library. */ - /* - ** Interfaces for opening a shared library, finding entry points - ** within the shared library, and closing the shared library. - */ - //static void winDlOpen(sqlite3_vfs pVfs, string zFilename){ - // HANDLE h; - // void *zConverted = convertUtf8Filename(zFilename); - // UNUSED_PARAMETER(pVfs); - // if( zConverted==0 ){ - // return 0; - // } - // if( isNT() ){ - // h = LoadLibraryW((WCHAR)zConverted); - /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. - ** Since the ASCII version of these Windows API do not exist for WINCE, - ** it's important to not reference them for WINCE builds. - */ + //static void winDlOpen(sqlite3_vfs pVfs, string zFilename){ + // HANDLE h; + // void *zConverted = convertUtf8Filename(zFilename); + // UNUSED_PARAMETER(pVfs); + // if( zConverted==0 ){ + // return 0; + // } + // if( isNT() ){ + // h = LoadLibraryW((WCHAR)zConverted); + /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. + ** Since the ASCII version of these Windows API do not exist for WINCE, + ** it's important to not reference them for WINCE builds. + */ #if !SQLITE_OS_WINCE - // }else{ - // h = LoadLibraryA((char)zConverted); -#endif - // } - // free(zConverted); - // return (void)h; - //} - //static void winDlError(sqlite3_vfs pVfs, int nBuf, string zBufOut){ - // UNUSED_PARAMETER(pVfs); - // getLastErrorMsg(nBuf, zBufOut); - //} - // static object winDlSym(sqlite3_vfs pVfs, HANDLE pHandle, String zSymbol){ - // UNUSED_PARAMETER(pVfs); - //#if SQLITE_OS_WINCE - // /* The GetProcAddressA() routine is only available on wince. */ - // return GetProcAddressA((HANDLE)pHandle, zSymbol); - //#else - // /* All other windows platforms expect GetProcAddress() to take - // ** an Ansi string regardless of the _UNICODE setting */ - // return GetProcAddress((HANDLE)pHandle, zSymbol); - //#endif - // } - // static void winDlClose( sqlite3_vfs pVfs, HANDLE pHandle ) - // { - // UNUSED_PARAMETER(pVfs); - // FreeLibrary((HANDLE)pHandle); - // } - //TODO -- Fix This - static HANDLE winDlOpen(sqlite3_vfs vfs, string zFilename) { - return new HANDLE(); - } - static int winDlError(sqlite3_vfs vfs, int nByte, string zErrMsg) { - return 0; - } - static HANDLE winDlSym(sqlite3_vfs vfs, HANDLE data, string zSymbol) { - return new HANDLE(); - } - static int winDlClose(sqlite3_vfs vfs, HANDLE data) { - return 0; - } + // }else{ + // h = LoadLibraryA((char)zConverted); +#endif + // } + // free(zConverted); + // return (void)h; + //} + //static void winDlError(sqlite3_vfs pVfs, int nBuf, string zBufOut){ + // UNUSED_PARAMETER(pVfs); + // getLastErrorMsg(nBuf, zBufOut); + //} + // static object winDlSym(sqlite3_vfs pVfs, HANDLE pHandle, String zSymbol){ + // UNUSED_PARAMETER(pVfs); + //#if SQLITE_OS_WINCE + // /* The GetProcAddressA() routine is only available on wince. */ + // return GetProcAddressA((HANDLE)pHandle, zSymbol); + //#else + // /* All other windows platforms expect GetProcAddress() to take + // ** an Ansi string regardless of the _UNICODE setting */ + // return GetProcAddress((HANDLE)pHandle, zSymbol); + //#endif + // } + // static void winDlClose( sqlite3_vfs pVfs, HANDLE pHandle ) + // { + // UNUSED_PARAMETER(pVfs); + // FreeLibrary((HANDLE)pHandle); + // } + //TODO -- Fix This + static HANDLE winDlOpen( sqlite3_vfs vfs, string zFilename ) + { + return new HANDLE(); + } + static int winDlError( sqlite3_vfs vfs, int nByte, string zErrMsg ) + { + return 0; + } + static HANDLE winDlSym( sqlite3_vfs vfs, HANDLE data, string zSymbol ) + { + return new HANDLE(); + } + static int winDlClose( sqlite3_vfs vfs, HANDLE data ) + { + return 0; + } #else // * if SQLITE_OMIT_LOAD_EXTENSION is defined: */ static object winDlOpen(ref sqlite3_vfs vfs, string zFilename) { return null; } static int winDlError(ref sqlite3_vfs vfs, int nByte, ref string zErrMsg) { return 0; } @@ -3263,87 +3434,92 @@ static int winDlClose(sqlite3_vfs vfs, HANDLE data) { #endif - /* - ** Write up to nBuf bytes of randomness into zBuf. - */ - - //[StructLayout( LayoutKind.Explicit, Size = 16, CharSet = CharSet.Ansi )] - //public class _SYSTEMTIME - //{ - // [FieldOffset( 0 )] - // public u32 byte_0_3; - // [FieldOffset( 4 )] - // public u32 byte_4_7; - // [FieldOffset( 8 )] - // public u32 byte_8_11; - // [FieldOffset( 12 )] - // public u32 byte_12_15; - //} - //[DllImport( "Kernel32.dll" )] - //private static extern bool QueryPerformanceCounter( out long lpPerformanceCount ); + /* +** Write up to nBuf bytes of randomness into zBuf. +*/ - static int winRandomness(sqlite3_vfs pVfs, int nBuf, byte[] zBuf) { - int n = 0; - UNUSED_PARAMETER(pVfs); + //[StructLayout( LayoutKind.Explicit, Size = 16, CharSet = CharSet.Ansi )] + //public class _SYSTEMTIME + //{ + // [FieldOffset( 0 )] + // public u32 byte_0_3; + // [FieldOffset( 4 )] + // public u32 byte_4_7; + // [FieldOffset( 8 )] + // public u32 byte_8_11; + // [FieldOffset( 12 )] + // public u32 byte_12_15; + //} + //[DllImport( "Kernel32.dll" )] + //private static extern bool QueryPerformanceCounter( out long lpPerformanceCount ); + + static int winRandomness( sqlite3_vfs pVfs, int nBuf, byte[] zBuf ) + { + int n = 0; + UNUSED_PARAMETER( pVfs ); #if (SQLITE_TEST) n = nBuf; Array.Clear( zBuf, 0, n );// memset( zBuf, 0, nBuf ); #else - byte[] sBuf = BitConverter.GetBytes(System.DateTime.Now.Ticks); - zBuf[0] = sBuf[0]; - zBuf[1] = sBuf[1]; - zBuf[2] = sBuf[2]; - zBuf[3] = sBuf[3]; - ;// memcpy(&zBuf[n], x, sizeof(x)) - n += 16;// sizeof(x); - if (sizeof(DWORD) <= nBuf - n) { - //DWORD pid = GetCurrentProcessId(); - u32 processId; +byte[] sBuf = BitConverter.GetBytes(System.DateTime.Now.Ticks); +zBuf[0] = sBuf[0]; +zBuf[1] = sBuf[1]; +zBuf[2] = sBuf[2]; +zBuf[3] = sBuf[3]; +;// memcpy(&zBuf[n], x, sizeof(x)) +n += 16;// sizeof(x); +if ( sizeof( DWORD ) <= nBuf - n ) +{ +//DWORD pid = GetCurrentProcessId(); +u32 processId; #if !(SQLITE_SILVERLIGHT || SQLITE_WINRT) - processId = (u32)Process.GetCurrentProcess().Id; +processId = (u32)Process.GetCurrentProcess().Id; #else processId = 28376023; #endif - put32bits(zBuf, n, processId);//(memcpy(&zBuf[n], pid, sizeof(pid)); - n += 4;// sizeof(pid); - } - if (sizeof(DWORD) <= nBuf - n) { - //DWORD cnt = GetTickCount(); - System.DateTime dt = new System.DateTime(); - put32bits(zBuf, n, (u32)dt.Ticks);// memcpy(&zBuf[n], cnt, sizeof(cnt)); - n += 4;// cnt.Length; - } - if (sizeof(long) <= nBuf - n) { - long i; - i = System.DateTime.UtcNow.Millisecond;// QueryPerformanceCounter(out i); - put32bits(zBuf, n, (u32)(i & 0xFFFFFFFF));//memcpy(&zBuf[n], i, sizeof(i)); - put32bits(zBuf, n, (u32)(i >> 32)); - n += sizeof(long); - } +put32bits( zBuf, n, processId);//(memcpy(&zBuf[n], pid, sizeof(pid)); +n += 4;// sizeof(pid); +} +if ( sizeof( DWORD ) <= nBuf - n ) +{ +//DWORD cnt = GetTickCount(); +System.DateTime dt = new System.DateTime(); +put32bits( zBuf, n, (u32)dt.Ticks );// memcpy(&zBuf[n], cnt, sizeof(cnt)); +n += 4;// cnt.Length; +} +if ( sizeof( long ) <= nBuf - n ) +{ +long i; +i = System.DateTime.UtcNow.Millisecond;// QueryPerformanceCounter(out i); +put32bits( zBuf, n, (u32)( i & 0xFFFFFFFF ) );//memcpy(&zBuf[n], i, sizeof(i)); +put32bits( zBuf, n, (u32)( i >> 32 ) ); +n += sizeof( long ); +} #endif - return n; - } + return n; + } - /* - ** Sleep for a little while. Return the amount of time slept. - */ - static int winSleep(sqlite3_vfs pVfs, int microsec) { + /* + ** Sleep for a little while. Return the amount of time slept. + */ + static int winSleep( sqlite3_vfs pVfs, int microsec ) + { #if SQLITE_WINRT System.Threading.Tasks.Task.Delay(((microsec + 999) / 1000)).Wait(); #else - Thread.Sleep(((microsec + 999) / 1000)); + Thread.Sleep(((microsec + 999) / 1000)); #endif - UNUSED_PARAMETER(pVfs); - return ((microsec + 999) / 1000) * 1000; - } + UNUSED_PARAMETER( pVfs ); + return ( ( microsec + 999 ) / 1000 ) * 1000; + } - /* - ** The following variable, if set to a non-zero value, is interpreted as - ** the number of seconds since 1970 and is used to set the result of - ** sqlite3OsCurrentTime() during testing. - */ + /* + ** The following variable, if set to a non-zero value, is interpreted as + ** the number of seconds since 1970 and is used to set the result of + ** sqlite3OsCurrentTime() during testing. + */ #if SQLITE_TEST #if !TCLSH static int sqlite3_current_time = 0;// /* Fake system time in seconds since 1970. */ @@ -3352,52 +3528,53 @@ static int winSleep(sqlite3_vfs pVfs, int microsec) { #endif #endif - /* - ** Find the current time (in Universal Coordinated Time). Write into *piNow - ** the current time and date as a Julian Day number times 86_400_000. In - ** other words, write into *piNow the number of milliseconds since the Julian - ** epoch of noon in Greenwich on November 24, 4714 B.C according to the - ** proleptic Gregorian calendar. - ** - ** On success, return 0. Return 1 if the time and date cannot be found. - */ - static int winCurrentTimeInt64(sqlite3_vfs pVfs, ref sqlite3_int64 piNow) { - /* FILETIME structure is a 64-bit value representing the number of - 100-nanosecond intervals since January 1, 1601 (= JD 2305813.5). - */ - //var ft = new FILETIME(); + /* +** Find the current time (in Universal Coordinated Time). Write into *piNow +** the current time and date as a Julian Day number times 86_400_000. In +** other words, write into *piNow the number of milliseconds since the Julian +** epoch of noon in Greenwich on November 24, 4714 B.C according to the +** proleptic Gregorian calendar. +** +** On success, return 0. Return 1 if the time and date cannot be found. +*/ + static int winCurrentTimeInt64( sqlite3_vfs pVfs, ref sqlite3_int64 piNow ) + { + /* FILETIME structure is a 64-bit value representing the number of + 100-nanosecond intervals since January 1, 1601 (= JD 2305813.5). + */ + //var ft = new FILETIME(); #if SQLITE_WINRT const sqlite3_int64 winRtEpoc = 17214255 * (sqlite3_int64)8640000; #else - const sqlite3_int64 winFiletimeEpoch = 23058135 * (sqlite3_int64)8640000; + const sqlite3_int64 winFiletimeEpoch = 23058135 * (sqlite3_int64)8640000; #endif #if SQLITE_TEST const sqlite3_int64 unixEpoch = 24405875 * (sqlite3_int64)8640000; #endif - ///* 2^32 - to avoid use of LL and warnings in gcc */ - //const sqlite3_int64 max32BitValue = - //(sqlite3_int64)2000000000 + (sqlite3_int64)2000000000 + (sqlite3_int64)294967296; - - //#if SQLITE_OS_WINCE - //SYSTEMTIME time; - //GetSystemTime(&time); - ///* if SystemTimeToFileTime() fails, it returns zero. */ - //if (!SystemTimeToFileTime(&time,&ft)){ - //return 1; - //} - //#else - // GetSystemTimeAsFileTime( ref ft ); - // ft = System.DateTime.UtcNow.ToFileTime(); - //#endif - //sqlite3_int64 ft = System.DateTime.UtcNow.ToFileTime(); - //piNow = winFiletimeEpoch + ft; - //((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) + - // (sqlite3_int64)ft.dwLowDateTime)/(sqlite3_int64)10000; + ///* 2^32 - to avoid use of LL and warnings in gcc */ + //const sqlite3_int64 max32BitValue = + //(sqlite3_int64)2000000000 + (sqlite3_int64)2000000000 + (sqlite3_int64)294967296; + + //#if SQLITE_OS_WINCE + //SYSTEMTIME time; + //GetSystemTime(&time); + ///* if SystemTimeToFileTime() fails, it returns zero. */ + //if (!SystemTimeToFileTime(&time,&ft)){ + //return 1; + //} + //#else + // GetSystemTimeAsFileTime( ref ft ); + // ft = System.DateTime.UtcNow.ToFileTime(); + //#endif + //sqlite3_int64 ft = System.DateTime.UtcNow.ToFileTime(); + //piNow = winFiletimeEpoch + ft; + //((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) + + // (sqlite3_int64)ft.dwLowDateTime)/(sqlite3_int64)10000; #if SQLITE_WINRT piNow = winRtEpoc + System.DateTime.UtcNow.Ticks / (sqlite3_int64)10000; #else - piNow = winFiletimeEpoch + System.DateTime.UtcNow.ToFileTimeUtc() / (sqlite3_int64)10000; + piNow = winFiletimeEpoch + System.DateTime.UtcNow.ToFileTimeUtc() / (sqlite3_int64)10000; #endif #if SQLITE_TEST #if !TCLSH @@ -3412,91 +3589,95 @@ static int winCurrentTimeInt64(sqlite3_vfs pVfs, ref sqlite3_int64 piNow) { } #endif #endif - UNUSED_PARAMETER(pVfs); - return 0; - } + UNUSED_PARAMETER( pVfs ); + return 0; + } - /* - ** Find the current time (in Universal Coordinated Time). Write the - ** current time and date as a Julian Day number into *prNow and - ** return 0. Return 1 if the time and date cannot be found. - */ - static int winCurrentTime(sqlite3_vfs pVfs, ref double prNow) { - int rc; - sqlite3_int64 i = 0; - rc = winCurrentTimeInt64(pVfs, ref i); - if (0 == rc) { - prNow = i / 86400000.0; - } - return rc; - } + /* + ** Find the current time (in Universal Coordinated Time). Write the + ** current time and date as a Julian Day number into *prNow and + ** return 0. Return 1 if the time and date cannot be found. + */ + static int winCurrentTime( sqlite3_vfs pVfs, ref double prNow ) + { + int rc; + sqlite3_int64 i = 0; + rc = winCurrentTimeInt64( pVfs, ref i ); + if ( 0 == rc ) + { + prNow = i / 86400000.0; + } + return rc; + } - /* - ** The idea is that this function works like a combination of - ** GetLastError() and FormatMessage() on windows (or errno and - ** strerror_r() on unix). After an error is returned by an OS - ** function, SQLite calls this function with zBuf pointing to - ** a buffer of nBuf bytes. The OS layer should populate the - ** buffer with a nul-terminated UTF-8 encoded error message - ** describing the last IO error to have occurred within the calling - ** thread. - ** - ** If the error message is too large for the supplied buffer, - ** it should be truncated. The return value of xGetLastError - ** is zero if the error message fits in the buffer, or non-zero - ** otherwise (if the message was truncated). If non-zero is returned, - ** then it is not necessary to include the nul-terminator character - ** in the output buffer. - ** - ** Not supplying an error message will have no adverse effect - ** on SQLite. It is fine to have an implementation that never - ** returns an error message: - ** - ** int xGetLastError(sqlite3_vfs pVfs, int nBuf, string zBuf){ - ** Debug.Assert(zBuf[0]=='\0'); - ** return 0; - ** } - ** - ** However if an error message is supplied, it will be incorporated - ** by sqlite into the error message available to the user using - ** sqlite3_errmsg(), possibly making IO errors easier to debug. - */ - static int winGetLastError(sqlite3_vfs pVfs, int nBuf, ref string zBuf) { - UNUSED_PARAMETER(pVfs); - return getLastErrorMsg(nBuf, ref zBuf); - } + /* + ** The idea is that this function works like a combination of + ** GetLastError() and FormatMessage() on windows (or errno and + ** strerror_r() on unix). After an error is returned by an OS + ** function, SQLite calls this function with zBuf pointing to + ** a buffer of nBuf bytes. The OS layer should populate the + ** buffer with a nul-terminated UTF-8 encoded error message + ** describing the last IO error to have occurred within the calling + ** thread. + ** + ** If the error message is too large for the supplied buffer, + ** it should be truncated. The return value of xGetLastError + ** is zero if the error message fits in the buffer, or non-zero + ** otherwise (if the message was truncated). If non-zero is returned, + ** then it is not necessary to include the nul-terminator character + ** in the output buffer. + ** + ** Not supplying an error message will have no adverse effect + ** on SQLite. It is fine to have an implementation that never + ** returns an error message: + ** + ** int xGetLastError(sqlite3_vfs pVfs, int nBuf, string zBuf){ + ** Debug.Assert(zBuf[0]=='\0'); + ** return 0; + ** } + ** + ** However if an error message is supplied, it will be incorporated + ** by sqlite into the error message available to the user using + ** sqlite3_errmsg(), possibly making IO errors easier to debug. + */ + static int winGetLastError( sqlite3_vfs pVfs, int nBuf, ref string zBuf ) + { + UNUSED_PARAMETER( pVfs ); + return getLastErrorMsg( nBuf, ref zBuf ); + } - static sqlite3_vfs winVfs = new sqlite3_vfs( - 3, /* iVersion */ - -1, //sqlite3_file.Length, /* szOsFile */ - MAX_PATH, /* mxPathname */ - null, /* pNext */ - "win32", /* zName */ - 0, /* pAppData */ - - (dxOpen)winOpen, /* xOpen */ - (dxDelete)winDelete, /* xDelete */ - (dxAccess)winAccess, /* xAccess */ - (dxFullPathname)winFullPathname,/* xFullPathname */ - (dxDlOpen)winDlOpen, /* xDlOpen */ - (dxDlError)winDlError, /* xDlError */ - (dxDlSym)winDlSym, /* xDlSym */ - (dxDlClose)winDlClose, /* xDlClose */ - (dxRandomness)winRandomness, /* xRandomness */ - (dxSleep)winSleep, /* xSleep */ - (dxCurrentTime)winCurrentTime, /* xCurrentTime */ - (dxGetLastError)winGetLastError,/* xGetLastError */ - (dxCurrentTimeInt64)winCurrentTimeInt64, /* xCurrentTimeInt64 */ - null, /* xSetSystemCall */ - null, /* xGetSystemCall */ - null /* xNextSystemCall */ - ); + static sqlite3_vfs winVfs = new sqlite3_vfs( + 3, /* iVersion */ + -1, //sqlite3_file.Length, /* szOsFile */ + MAX_PATH, /* mxPathname */ + null, /* pNext */ + "win32", /* zName */ + 0, /* pAppData */ + + (dxOpen)winOpen, /* xOpen */ + (dxDelete)winDelete, /* xDelete */ + (dxAccess)winAccess, /* xAccess */ + (dxFullPathname)winFullPathname,/* xFullPathname */ + (dxDlOpen)winDlOpen, /* xDlOpen */ + (dxDlError)winDlError, /* xDlError */ + (dxDlSym)winDlSym, /* xDlSym */ + (dxDlClose)winDlClose, /* xDlClose */ + (dxRandomness)winRandomness, /* xRandomness */ + (dxSleep)winSleep, /* xSleep */ + (dxCurrentTime)winCurrentTime, /* xCurrentTime */ + (dxGetLastError)winGetLastError,/* xGetLastError */ + (dxCurrentTimeInt64)winCurrentTimeInt64, /* xCurrentTimeInt64 */ + null, /* xSetSystemCall */ + null, /* xGetSystemCall */ + null /* xNextSystemCall */ + ); - /* - ** Initialize and deinitialize the operating system interface. - */ - static int sqlite3_os_init() { + /* + ** Initialize and deinitialize the operating system interface. + */ + static int sqlite3_os_init() + { #if !SQLITE_OMIT_WAL /* get memory map allocation granularity */ memset(&winSysInfo, 0, sizeof(SYSTEM_INFO)); @@ -3504,93 +3685,104 @@ static int sqlite3_os_init() { Debug.Assert(winSysInfo.dwAllocationGranularity > 0); #endif - sqlite3_vfs_register(winVfs, 1); - return SQLITE_OK; - } + sqlite3_vfs_register( winVfs, 1 ); + return SQLITE_OK; + } - static int sqlite3_os_end() { - return SQLITE_OK; - } + static int sqlite3_os_end() + { + return SQLITE_OK; + } #endif // * SQLITE_OS_WIN */ - // - // Windows DLL definitions - // - - const int NO_ERROR = 0; - /// - /// Basic locking strategy for Console/Winform applications - /// - private class LockingStrategy { + // + // Windows DLL definitions + // + + const int NO_ERROR = 0; + /// + /// Basic locking strategy for Console/Winform applications + /// + private class LockingStrategy + { #if !(SQLITE_SILVERLIGHT || WINDOWS_MOBILE || SQLITE_WINRT) - [DllImport("kernel32.dll")] - static extern bool LockFileEx(IntPtr hFile, uint dwFlags, uint dwReserved, - uint nNumberOfBytesToLockLow, uint nNumberOfBytesToLockHigh, - [In] ref System.Threading.NativeOverlapped lpOverlapped); + [DllImport( "kernel32.dll" )] + static extern bool LockFileEx( IntPtr hFile, uint dwFlags, uint dwReserved, + uint nNumberOfBytesToLockLow, uint nNumberOfBytesToLockHigh, + [In] ref System.Threading.NativeOverlapped lpOverlapped ); - const int LOCKFILE_FAIL_IMMEDIATELY = 1; + const int LOCKFILE_FAIL_IMMEDIATELY = 1; #endif - public virtual void LockFile(sqlite3_file pFile, long offset, long length) { + public virtual void LockFile( sqlite3_file pFile, long offset, long length ) + { #pragma warning disable CA1416 // Validate platform compatibility - pFile.fs.Lock(offset, length); + pFile.fs.Lock( offset, length ); #pragma warning restore CA1416 // Validate platform compatibility - } + } - public virtual int SharedLockFile(sqlite3_file pFile, long offset, long length) { + public virtual int SharedLockFile( sqlite3_file pFile, long offset, long length ) + { #if !(SQLITE_SILVERLIGHT || WINDOWS_MOBILE || SQLITE_WINRT) #if FEATURE_RUNTIMEINFORMATION - Debug.Assert(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); + Debug.Assert(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); #endif - Debug.Assert(length == SHARED_SIZE); - Debug.Assert(offset == SHARED_FIRST); - NativeOverlapped ovlp = new NativeOverlapped(); - ovlp.OffsetLow = (int)offset; - ovlp.OffsetHigh = 0; - ovlp.EventHandle = IntPtr.Zero; + Debug.Assert( length == SHARED_SIZE ); + Debug.Assert( offset == SHARED_FIRST ); + NativeOverlapped ovlp = new NativeOverlapped(); + ovlp.OffsetLow = (int)offset; + ovlp.OffsetHigh = 0; + ovlp.EventHandle = IntPtr.Zero; - return LockFileEx(pFile.fs.Handle, LOCKFILE_FAIL_IMMEDIATELY, 0, (uint)length, 0, ref ovlp) ? 1 : 0; + return LockFileEx( pFile.fs.Handle, LOCKFILE_FAIL_IMMEDIATELY, 0, (uint)length, 0, ref ovlp ) ? 1 : 0; #else return 1; #endif - } + } - public virtual void UnlockFile(sqlite3_file pFile, long offset, long length) { + public virtual void UnlockFile( sqlite3_file pFile, long offset, long length ) + { #if !(SQLITE_SILVERLIGHT || WINDOWS_MOBILE || SQLITE_WINRT) #pragma warning disable CA1416 // Validate platform compatibility - pFile.fs.Unlock(offset, length); + pFile.fs.Unlock( offset, length ); #pragma warning restore CA1416 // Validate platform compatibility #endif - } - } + } + } - /// - /// Locking strategy for Medium Trust. It uses the same trick used in the native code for WIN_CE - /// which doesn't support LockFileEx as well. - /// - private class MediumTrustLockingStrategy : LockingStrategy { - public override int SharedLockFile(sqlite3_file pFile, long offset, long length) { + /// + /// Locking strategy for Medium Trust. It uses the same trick used in the native code for WIN_CE + /// which doesn't support LockFileEx as well. + /// + private class MediumTrustLockingStrategy : LockingStrategy + { + public override int SharedLockFile( sqlite3_file pFile, long offset, long length ) + { #if !(SQLITE_SILVERLIGHT || WINDOWS_MOBILE || SQLITE_WINRT) - Debug.Assert(length == SHARED_SIZE); - Debug.Assert(offset == SHARED_FIRST); - try { + Debug.Assert( length == SHARED_SIZE ); + Debug.Assert( offset == SHARED_FIRST ); + try + { #pragma warning disable CA1416 // Validate platform compatibility - pFile.fs.Lock(offset + pFile.sharedLockByte, 1); + pFile.fs.Lock( offset + pFile.sharedLockByte, 1 ); #pragma warning restore CA1416 // Validate platform compatibility - } catch (IOException) { - return 0; - } -#endif - return 1; - } } - } - internal static class HelperMethods { - public static bool IsRunningMediumTrust() { - // placeholder method - // this is where it needs to check if it's running in an ASP.Net MediumTrust or lower environment - // in order to pick the appropriate locking strategy - return Environment.OSVersion.Platform == PlatformID.Unix; + catch ( IOException ) + { + return 0; } +#endif + return 1; + } + } + } + internal static class HelperMethods + { + public static bool IsRunningMediumTrust() { + // placeholder method + // this is where it needs to check if it's running in an ASP.Net MediumTrust or lower environment + // in order to pick the appropriate locking strategy + return Environment.OSVersion.Platform == PlatformID.Unix; + } #if SQLITE_WINRT public static bool FileExists(string path) @@ -3611,8 +3803,9 @@ public static bool FileExists(string path) } #endif - public static int GetLastError() { - return Marshal.GetLastWin32Error(); - } + public static int GetLastError() + { + return Marshal.GetLastWin32Error(); } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/pager_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/pager_c.cs index d1c33acd3..5f1d731ea 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/pager_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/pager_c.cs @@ -1,146 +1,150 @@ using System; using System.Diagnostics; +using System.IO; using i16 = System.Int16; using i64 = System.Int64; -using Pgno = System.UInt32; -using sqlite3_int64 = System.Int64; + +using u8 = System.Byte; using u16 = System.UInt16; using u32 = System.UInt32; -using u8 = System.Byte; -namespace Community.CsharpSqlite { - using System.Text; +using Pgno = System.UInt32; +using sqlite3_int64 = System.Int64; - using DbPage = Sqlite3.PgHdr; - public partial class Sqlite3 { - /* - ** 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. - ** - ************************************************************************* - ** This is the implementation of the page cache subsystem or "pager". - ** - ** The pager is used to access a database disk file. It implements - ** atomic commit and rollback through the use of a journal file that - ** is separate from the database file. The pager also implements file - ** locking to prevent two processes from writing the same database - ** file simultaneously, or one process from reading the database while - ** another is writing. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ +namespace Community.CsharpSqlite +{ + using System.Text; + using DbPage = Sqlite3.PgHdr; + public partial class Sqlite3 + { + /* + ** 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. + ** + ************************************************************************* + ** This is the implementation of the page cache subsystem or "pager". + ** + ** The pager is used to access a database disk file. It implements + ** atomic commit and rollback through the use of a journal file that + ** is separate from the database file. The pager also implements file + ** locking to prevent two processes from writing the same database + ** file simultaneously, or one process from reading the database while + ** another is writing. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ #if !SQLITE_OMIT_DISKIO - //#include "sqliteInt.h" - //#include "wal.h" + //#include "sqliteInt.h" + //#include "wal.h" - /******************* NOTES ON THE DESIGN OF THE PAGER ************************ - ** - ** This comment block describes invariants that hold when using a rollback - ** journal. These invariants do not apply for journal_mode=WAL, - ** journal_mode=MEMORY, or journal_mode=OFF. - ** - ** Within this comment block, a page is deemed to have been synced - ** automatically as soon as it is written when PRAGMA synchronous=OFF. - ** Otherwise, the page is not synced until the xSync method of the VFS - ** is called successfully on the file containing the page. - ** - ** Definition: A page of the database file is said to be "overwriteable" if - ** one or more of the following are true about the page: - ** - ** (a) The original content of the page as it was at the beginning of - ** the transaction has been written into the rollback journal and - ** synced. - ** - ** (b) The page was a freelist leaf page at the start of the transaction. - ** - ** (c) The page number is greater than the largest page that existed in - ** the database file at the start of the transaction. - ** - ** (1) A page of the database file is never overwritten unless one of the - ** following are true: - ** - ** (a) The page and all other pages on the same sector are overwriteable. - ** - ** (b) The atomic page write optimization is enabled, and the entire - ** transaction other than the update of the transaction sequence - ** number consists of a single page change. - ** - ** (2) The content of a page written into the rollback journal exactly matches - ** both the content in the database when the rollback journal was written - ** and the content in the database at the beginning of the current - ** transaction. - ** - ** (3) Writes to the database file are an integer multiple of the page size - ** in length and are aligned on a page boundary. - ** - ** (4) Reads from the database file are either aligned on a page boundary and - ** an integer multiple of the page size in length or are taken from the - ** first 100 bytes of the database file. - ** - ** (5) All writes to the database file are synced prior to the rollback journal - ** being deleted, truncated, or zeroed. - ** - ** (6) If a master journal file is used, then all writes to the database file - ** are synced prior to the master journal being deleted. - ** - ** Definition: Two databases (or the same database at two points it time) - ** are said to be "logically equivalent" if they give the same answer to - ** all queries. Note in particular the the content of freelist leaf - ** pages can be changed arbitarily without effecting the logical equivalence - ** of the database. - ** - ** (7) At any time, if any subset, including the empty set and the total set, - ** of the unsynced changes to a rollback journal are removed and the - ** journal is rolled back, the resulting database file will be logical - ** equivalent to the database file at the beginning of the transaction. - ** - ** (8) When a transaction is rolled back, the xTruncate method of the VFS - ** is called to restore the database file to the same size it was at - ** the beginning of the transaction. (In some VFSes, the xTruncate - ** method is a no-op, but that does not change the fact the SQLite will - ** invoke it.) - ** - ** (9) Whenever the database file is modified, at least one bit in the range - ** of bytes from 24 through 39 inclusive will be changed prior to releasing - ** the EXCLUSIVE lock, thus signaling other connections on the same - ** database to flush their caches. - ** - ** (10) The pattern of bits in bytes 24 through 39 shall not repeat in less - ** than one billion transactions. - ** - ** (11) A database file is well-formed at the beginning and at the conclusion - ** of every transaction. - ** - ** (12) An EXCLUSIVE lock is held on the database file when writing to - ** the database file. - ** - ** (13) A SHARED lock is held on the database file while reading any - ** content out of the database file. - ** - ******************************************************************************/ + /******************* NOTES ON THE DESIGN OF THE PAGER ************************ + ** + ** This comment block describes invariants that hold when using a rollback + ** journal. These invariants do not apply for journal_mode=WAL, + ** journal_mode=MEMORY, or journal_mode=OFF. + ** + ** Within this comment block, a page is deemed to have been synced + ** automatically as soon as it is written when PRAGMA synchronous=OFF. + ** Otherwise, the page is not synced until the xSync method of the VFS + ** is called successfully on the file containing the page. + ** + ** Definition: A page of the database file is said to be "overwriteable" if + ** one or more of the following are true about the page: + ** + ** (a) The original content of the page as it was at the beginning of + ** the transaction has been written into the rollback journal and + ** synced. + ** + ** (b) The page was a freelist leaf page at the start of the transaction. + ** + ** (c) The page number is greater than the largest page that existed in + ** the database file at the start of the transaction. + ** + ** (1) A page of the database file is never overwritten unless one of the + ** following are true: + ** + ** (a) The page and all other pages on the same sector are overwriteable. + ** + ** (b) The atomic page write optimization is enabled, and the entire + ** transaction other than the update of the transaction sequence + ** number consists of a single page change. + ** + ** (2) The content of a page written into the rollback journal exactly matches + ** both the content in the database when the rollback journal was written + ** and the content in the database at the beginning of the current + ** transaction. + ** + ** (3) Writes to the database file are an integer multiple of the page size + ** in length and are aligned on a page boundary. + ** + ** (4) Reads from the database file are either aligned on a page boundary and + ** an integer multiple of the page size in length or are taken from the + ** first 100 bytes of the database file. + ** + ** (5) All writes to the database file are synced prior to the rollback journal + ** being deleted, truncated, or zeroed. + ** + ** (6) If a master journal file is used, then all writes to the database file + ** are synced prior to the master journal being deleted. + ** + ** Definition: Two databases (or the same database at two points it time) + ** are said to be "logically equivalent" if they give the same answer to + ** all queries. Note in particular the the content of freelist leaf + ** pages can be changed arbitarily without effecting the logical equivalence + ** of the database. + ** + ** (7) At any time, if any subset, including the empty set and the total set, + ** of the unsynced changes to a rollback journal are removed and the + ** journal is rolled back, the resulting database file will be logical + ** equivalent to the database file at the beginning of the transaction. + ** + ** (8) When a transaction is rolled back, the xTruncate method of the VFS + ** is called to restore the database file to the same size it was at + ** the beginning of the transaction. (In some VFSes, the xTruncate + ** method is a no-op, but that does not change the fact the SQLite will + ** invoke it.) + ** + ** (9) Whenever the database file is modified, at least one bit in the range + ** of bytes from 24 through 39 inclusive will be changed prior to releasing + ** the EXCLUSIVE lock, thus signaling other connections on the same + ** database to flush their caches. + ** + ** (10) The pattern of bits in bytes 24 through 39 shall not repeat in less + ** than one billion transactions. + ** + ** (11) A database file is well-formed at the beginning and at the conclusion + ** of every transaction. + ** + ** (12) An EXCLUSIVE lock is held on the database file when writing to + ** the database file. + ** + ** (13) A SHARED lock is held on the database file while reading any + ** content out of the database file. + ** + ******************************************************************************/ - /* - ** Macros for troubleshooting. Normally turned off - */ + /* + ** Macros for troubleshooting. Normally turned off + */ #if TRACE - static bool sqlite3PagerTrace = false; /* True to enable tracing */ - //#define sqlite3DebugPrintf printf - //#define PAGERTRACE(X) if( sqlite3PagerTrace ){ sqlite3DebugPrintf X; } - static void PAGERTRACE(string T, params object[] ap) { if (sqlite3PagerTrace) sqlite3DebugPrintf(T, ap); } +static bool sqlite3PagerTrace = false; /* True to enable tracing */ +//#define sqlite3DebugPrintf printf +//#define PAGERTRACE(X) if( sqlite3PagerTrace ){ sqlite3DebugPrintf X; } +static void PAGERTRACE( string T, params object[] ap ) { if ( sqlite3PagerTrace )sqlite3DebugPrintf( T, ap ); } #else //#define PAGERTRACE(X) static void PAGERTRACE( string T, params object[] ap ) @@ -148,315 +152,317 @@ static void PAGERTRACE( string T, params object[] ap ) } #endif - /* - ** The following two macros are used within the PAGERTRACE() macros above - ** to print out file-descriptors. - ** - ** PAGERID() takes a pointer to a Pager struct as its argument. The - ** associated file-descriptor is returned. FILEHANDLEID() takes an sqlite3_file - ** struct as its argument. - */ - //#define PAGERID(p) ((int)(p.fd)) - static int PAGERID(Pager p) { - return p.GetHashCode(); - } + /* +** The following two macros are used within the PAGERTRACE() macros above +** to print out file-descriptors. +** +** PAGERID() takes a pointer to a Pager struct as its argument. The +** associated file-descriptor is returned. FILEHANDLEID() takes an sqlite3_file +** struct as its argument. +*/ + //#define PAGERID(p) ((int)(p.fd)) + static int PAGERID( Pager p ) + { + return p.GetHashCode(); + } - //#define FILEHANDLEID(fd) ((int)fd) - static int FILEHANDLEID(sqlite3_file fd) { - return fd.GetHashCode(); - } + //#define FILEHANDLEID(fd) ((int)fd) + static int FILEHANDLEID( sqlite3_file fd ) + { + return fd.GetHashCode(); + } - /* - ** The Pager.eState variable stores the current 'state' of a pager. A - ** pager may be in any one of the seven states shown in the following - ** state diagram. - ** - ** OPEN <------+------+ - ** | | | - ** V | | - ** +---------> READER-------+ | - ** | | | - ** | V | - ** |<-------WRITER_LOCKED------> ERROR - ** | | ^ - ** | V | - ** |<------WRITER_CACHEMOD-------->| - ** | | | - ** | V | - ** |<-------WRITER_DBMOD---------->| - ** | | | - ** | V | - ** +<------WRITER_FINISHED-------->+ - ** - ** - ** List of state transitions and the C [function] that performs each: - ** - ** OPEN -> READER [sqlite3PagerSharedLock] - ** READER -> OPEN [pager_unlock] - ** - ** READER -> WRITER_LOCKED [sqlite3PagerBegin] - ** WRITER_LOCKED -> WRITER_CACHEMOD [pager_open_journal] - ** WRITER_CACHEMOD -> WRITER_DBMOD [syncJournal] - ** WRITER_DBMOD -> WRITER_FINISHED [sqlite3PagerCommitPhaseOne] - ** WRITER_*** -> READER [pager_end_transaction] - ** - ** WRITER_*** -> ERROR [pager_error] - ** ERROR -> OPEN [pager_unlock] - ** - ** - ** OPEN: - ** - ** The pager starts up in this state. Nothing is guaranteed in this - ** state - the file may or may not be locked and the database size is - ** unknown. The database may not be read or written. - ** - ** * No read or write transaction is active. - ** * Any lock, or no lock at all, may be held on the database file. - ** * The dbSize, dbOrigSize and dbFileSize variables may not be trusted. - ** - ** READER: - ** - ** In this state all the requirements for reading the database in - ** rollback (non-WAL) mode are met. Unless the pager is (or recently - ** was) in exclusive-locking mode, a user-level read transaction is - ** open. The database size is known in this state. - ** - ** A connection running with locking_mode=normal enters this state when - ** it opens a read-transaction on the database and returns to state - ** OPEN after the read-transaction is completed. However a connection - ** running in locking_mode=exclusive (including temp databases) remains in - ** this state even after the read-transaction is closed. The only way - ** a locking_mode=exclusive connection can transition from READER to OPEN - ** is via the ERROR state (see below). - ** - ** * A read transaction may be active (but a write-transaction cannot). - ** * A SHARED or greater lock is held on the database file. - ** * The dbSize variable may be trusted (even if a user-level read - ** transaction is not active). The dbOrigSize and dbFileSize variables - ** may not be trusted at this point. - ** * If the database is a WAL database, then the WAL connection is open. - ** * Even if a read-transaction is not open, it is guaranteed that - ** there is no hot-journal in the file-system. - ** - ** WRITER_LOCKED: - ** - ** The pager moves to this state from READER when a write-transaction - ** is first opened on the database. In WRITER_LOCKED state, all locks - ** required to start a write-transaction are held, but no actual - ** modifications to the cache or database have taken place. - ** - ** In rollback mode, a RESERVED or (if the transaction was opened with - ** BEGIN EXCLUSIVE) EXCLUSIVE lock is obtained on the database file when - ** moving to this state, but the journal file is not written to or opened - ** to in this state. If the transaction is committed or rolled back while - ** in WRITER_LOCKED state, all that is required is to unlock the database - ** file. - ** - ** IN WAL mode, WalBeginWriteTransaction() is called to lock the log file. - ** If the connection is running with locking_mode=exclusive, an attempt - ** is made to obtain an EXCLUSIVE lock on the database file. - ** - ** * A write transaction is active. - ** * If the connection is open in rollback-mode, a RESERVED or greater - ** lock is held on the database file. - ** * If the connection is open in WAL-mode, a WAL write transaction - ** is open (i.e. sqlite3WalBeginWriteTransaction() has been successfully - ** called). - ** * The dbSize, dbOrigSize and dbFileSize variables are all valid. - ** * The contents of the pager cache have not been modified. - ** * The journal file may or may not be open. - ** * Nothing (not even the first header) has been written to the journal. - ** - ** WRITER_CACHEMOD: - ** - ** A pager moves from WRITER_LOCKED state to this state when a page is - ** first modified by the upper layer. In rollback mode the journal file - ** is opened (if it is not already open) and a header written to the - ** start of it. The database file on disk has not been modified. - ** - ** * A write transaction is active. - ** * A RESERVED or greater lock is held on the database file. - ** * The journal file is open and the first header has been written - ** to it, but the header has not been synced to disk. - ** * The contents of the page cache have been modified. - ** - ** WRITER_DBMOD: - ** - ** The pager transitions from WRITER_CACHEMOD into WRITER_DBMOD state - ** when it modifies the contents of the database file. WAL connections - ** never enter this state (since they do not modify the database file, - ** just the log file). - ** - ** * A write transaction is active. - ** * An EXCLUSIVE or greater lock is held on the database file. - ** * The journal file is open and the first header has been written - ** and synced to disk. - ** * The contents of the page cache have been modified (and possibly - ** written to disk). - ** - ** WRITER_FINISHED: - ** - ** It is not possible for a WAL connection to enter this state. - ** - ** A rollback-mode pager changes to WRITER_FINISHED state from WRITER_DBMOD - ** state after the entire transaction has been successfully written into the - ** database file. In this state the transaction may be committed simply - ** by finalizing the journal file. Once in WRITER_FINISHED state, it is - ** not possible to modify the database further. At this point, the upper - ** layer must either commit or rollback the transaction. - ** - ** * A write transaction is active. - ** * An EXCLUSIVE or greater lock is held on the database file. - ** * All writing and syncing of journal and database data has finished. - ** If no error occured, all that remains is to finalize the journal to - ** commit the transaction. If an error did occur, the caller will need - ** to rollback the transaction. - ** - ** ERROR: - ** - ** The ERROR state is entered when an IO or disk-full error (including - ** SQLITE_IOERR_NOMEM) occurs at a point in the code that makes it - ** difficult to be sure that the in-memory pager state (cache contents, - ** db size etc.) are consistent with the contents of the file-system. - ** - ** Temporary pager files may enter the ERROR state, but in-memory pagers - ** cannot. - ** - ** For example, if an IO error occurs while performing a rollback, - ** the contents of the page-cache may be left in an inconsistent state. - ** At this point it would be dangerous to change back to READER state - ** (as usually happens after a rollback). Any subsequent readers might - ** report database corruption (due to the inconsistent cache), and if - ** they upgrade to writers, they may inadvertently corrupt the database - ** file. To avoid this hazard, the pager switches into the ERROR state - ** instead of READER following such an error. - ** - ** Once it has entered the ERROR state, any attempt to use the pager - ** to read or write data returns an error. Eventually, once all - ** outstanding transactions have been abandoned, the pager is able to - ** transition back to OPEN state, discarding the contents of the - ** page-cache and any other in-memory state at the same time. Everything - ** is reloaded from disk (and, if necessary, hot-journal rollback peformed) - ** when a read-transaction is next opened on the pager (transitioning - ** the pager into READER state). At that point the system has recovered - ** from the error. - ** - ** Specifically, the pager jumps into the ERROR state if: - ** - ** 1. An error occurs while attempting a rollback. This happens in - ** function sqlite3PagerRollback(). - ** - ** 2. An error occurs while attempting to finalize a journal file - ** following a commit in function sqlite3PagerCommitPhaseTwo(). - ** - ** 3. An error occurs while attempting to write to the journal or - ** database file in function pagerStress() in order to free up - ** memory. - ** - ** In other cases, the error is returned to the b-tree layer. The b-tree - ** layer then attempts a rollback operation. If the error condition - ** persists, the pager enters the ERROR state via condition (1) above. - ** - ** Condition (3) is necessary because it can be triggered by a read-only - ** statement executed within a transaction. In this case, if the error - ** code were simply returned to the user, the b-tree layer would not - ** automatically attempt a rollback, as it assumes that an error in a - ** read-only statement cannot leave the pager in an internally inconsistent - ** state. - ** - ** * The Pager.errCode variable is set to something other than SQLITE_OK. - ** * There are one or more outstanding references to pages (after the - ** last reference is dropped the pager should move back to OPEN state). - ** * The pager is not an in-memory pager. - ** - ** - ** Notes: - ** - ** * A pager is never in WRITER_DBMOD or WRITER_FINISHED state if the - ** connection is open in WAL mode. A WAL connection is always in one - ** of the first four states. - ** - ** * Normally, a connection open in exclusive mode is never in PAGER_OPEN - ** state. There are two exceptions: immediately after exclusive-mode has - ** been turned on (and before any read or write transactions are - ** executed), and when the pager is leaving the "error state". - ** - ** * See also: assert_pager_state(). - */ + /* + ** The Pager.eState variable stores the current 'state' of a pager. A + ** pager may be in any one of the seven states shown in the following + ** state diagram. + ** + ** OPEN <------+------+ + ** | | | + ** V | | + ** +---------> READER-------+ | + ** | | | + ** | V | + ** |<-------WRITER_LOCKED------> ERROR + ** | | ^ + ** | V | + ** |<------WRITER_CACHEMOD-------->| + ** | | | + ** | V | + ** |<-------WRITER_DBMOD---------->| + ** | | | + ** | V | + ** +<------WRITER_FINISHED-------->+ + ** + ** + ** List of state transitions and the C [function] that performs each: + ** + ** OPEN -> READER [sqlite3PagerSharedLock] + ** READER -> OPEN [pager_unlock] + ** + ** READER -> WRITER_LOCKED [sqlite3PagerBegin] + ** WRITER_LOCKED -> WRITER_CACHEMOD [pager_open_journal] + ** WRITER_CACHEMOD -> WRITER_DBMOD [syncJournal] + ** WRITER_DBMOD -> WRITER_FINISHED [sqlite3PagerCommitPhaseOne] + ** WRITER_*** -> READER [pager_end_transaction] + ** + ** WRITER_*** -> ERROR [pager_error] + ** ERROR -> OPEN [pager_unlock] + ** + ** + ** OPEN: + ** + ** The pager starts up in this state. Nothing is guaranteed in this + ** state - the file may or may not be locked and the database size is + ** unknown. The database may not be read or written. + ** + ** * No read or write transaction is active. + ** * Any lock, or no lock at all, may be held on the database file. + ** * The dbSize, dbOrigSize and dbFileSize variables may not be trusted. + ** + ** READER: + ** + ** In this state all the requirements for reading the database in + ** rollback (non-WAL) mode are met. Unless the pager is (or recently + ** was) in exclusive-locking mode, a user-level read transaction is + ** open. The database size is known in this state. + ** + ** A connection running with locking_mode=normal enters this state when + ** it opens a read-transaction on the database and returns to state + ** OPEN after the read-transaction is completed. However a connection + ** running in locking_mode=exclusive (including temp databases) remains in + ** this state even after the read-transaction is closed. The only way + ** a locking_mode=exclusive connection can transition from READER to OPEN + ** is via the ERROR state (see below). + ** + ** * A read transaction may be active (but a write-transaction cannot). + ** * A SHARED or greater lock is held on the database file. + ** * The dbSize variable may be trusted (even if a user-level read + ** transaction is not active). The dbOrigSize and dbFileSize variables + ** may not be trusted at this point. + ** * If the database is a WAL database, then the WAL connection is open. + ** * Even if a read-transaction is not open, it is guaranteed that + ** there is no hot-journal in the file-system. + ** + ** WRITER_LOCKED: + ** + ** The pager moves to this state from READER when a write-transaction + ** is first opened on the database. In WRITER_LOCKED state, all locks + ** required to start a write-transaction are held, but no actual + ** modifications to the cache or database have taken place. + ** + ** In rollback mode, a RESERVED or (if the transaction was opened with + ** BEGIN EXCLUSIVE) EXCLUSIVE lock is obtained on the database file when + ** moving to this state, but the journal file is not written to or opened + ** to in this state. If the transaction is committed or rolled back while + ** in WRITER_LOCKED state, all that is required is to unlock the database + ** file. + ** + ** IN WAL mode, WalBeginWriteTransaction() is called to lock the log file. + ** If the connection is running with locking_mode=exclusive, an attempt + ** is made to obtain an EXCLUSIVE lock on the database file. + ** + ** * A write transaction is active. + ** * If the connection is open in rollback-mode, a RESERVED or greater + ** lock is held on the database file. + ** * If the connection is open in WAL-mode, a WAL write transaction + ** is open (i.e. sqlite3WalBeginWriteTransaction() has been successfully + ** called). + ** * The dbSize, dbOrigSize and dbFileSize variables are all valid. + ** * The contents of the pager cache have not been modified. + ** * The journal file may or may not be open. + ** * Nothing (not even the first header) has been written to the journal. + ** + ** WRITER_CACHEMOD: + ** + ** A pager moves from WRITER_LOCKED state to this state when a page is + ** first modified by the upper layer. In rollback mode the journal file + ** is opened (if it is not already open) and a header written to the + ** start of it. The database file on disk has not been modified. + ** + ** * A write transaction is active. + ** * A RESERVED or greater lock is held on the database file. + ** * The journal file is open and the first header has been written + ** to it, but the header has not been synced to disk. + ** * The contents of the page cache have been modified. + ** + ** WRITER_DBMOD: + ** + ** The pager transitions from WRITER_CACHEMOD into WRITER_DBMOD state + ** when it modifies the contents of the database file. WAL connections + ** never enter this state (since they do not modify the database file, + ** just the log file). + ** + ** * A write transaction is active. + ** * An EXCLUSIVE or greater lock is held on the database file. + ** * The journal file is open and the first header has been written + ** and synced to disk. + ** * The contents of the page cache have been modified (and possibly + ** written to disk). + ** + ** WRITER_FINISHED: + ** + ** It is not possible for a WAL connection to enter this state. + ** + ** A rollback-mode pager changes to WRITER_FINISHED state from WRITER_DBMOD + ** state after the entire transaction has been successfully written into the + ** database file. In this state the transaction may be committed simply + ** by finalizing the journal file. Once in WRITER_FINISHED state, it is + ** not possible to modify the database further. At this point, the upper + ** layer must either commit or rollback the transaction. + ** + ** * A write transaction is active. + ** * An EXCLUSIVE or greater lock is held on the database file. + ** * All writing and syncing of journal and database data has finished. + ** If no error occured, all that remains is to finalize the journal to + ** commit the transaction. If an error did occur, the caller will need + ** to rollback the transaction. + ** + ** ERROR: + ** + ** The ERROR state is entered when an IO or disk-full error (including + ** SQLITE_IOERR_NOMEM) occurs at a point in the code that makes it + ** difficult to be sure that the in-memory pager state (cache contents, + ** db size etc.) are consistent with the contents of the file-system. + ** + ** Temporary pager files may enter the ERROR state, but in-memory pagers + ** cannot. + ** + ** For example, if an IO error occurs while performing a rollback, + ** the contents of the page-cache may be left in an inconsistent state. + ** At this point it would be dangerous to change back to READER state + ** (as usually happens after a rollback). Any subsequent readers might + ** report database corruption (due to the inconsistent cache), and if + ** they upgrade to writers, they may inadvertently corrupt the database + ** file. To avoid this hazard, the pager switches into the ERROR state + ** instead of READER following such an error. + ** + ** Once it has entered the ERROR state, any attempt to use the pager + ** to read or write data returns an error. Eventually, once all + ** outstanding transactions have been abandoned, the pager is able to + ** transition back to OPEN state, discarding the contents of the + ** page-cache and any other in-memory state at the same time. Everything + ** is reloaded from disk (and, if necessary, hot-journal rollback peformed) + ** when a read-transaction is next opened on the pager (transitioning + ** the pager into READER state). At that point the system has recovered + ** from the error. + ** + ** Specifically, the pager jumps into the ERROR state if: + ** + ** 1. An error occurs while attempting a rollback. This happens in + ** function sqlite3PagerRollback(). + ** + ** 2. An error occurs while attempting to finalize a journal file + ** following a commit in function sqlite3PagerCommitPhaseTwo(). + ** + ** 3. An error occurs while attempting to write to the journal or + ** database file in function pagerStress() in order to free up + ** memory. + ** + ** In other cases, the error is returned to the b-tree layer. The b-tree + ** layer then attempts a rollback operation. If the error condition + ** persists, the pager enters the ERROR state via condition (1) above. + ** + ** Condition (3) is necessary because it can be triggered by a read-only + ** statement executed within a transaction. In this case, if the error + ** code were simply returned to the user, the b-tree layer would not + ** automatically attempt a rollback, as it assumes that an error in a + ** read-only statement cannot leave the pager in an internally inconsistent + ** state. + ** + ** * The Pager.errCode variable is set to something other than SQLITE_OK. + ** * There are one or more outstanding references to pages (after the + ** last reference is dropped the pager should move back to OPEN state). + ** * The pager is not an in-memory pager. + ** + ** + ** Notes: + ** + ** * A pager is never in WRITER_DBMOD or WRITER_FINISHED state if the + ** connection is open in WAL mode. A WAL connection is always in one + ** of the first four states. + ** + ** * Normally, a connection open in exclusive mode is never in PAGER_OPEN + ** state. There are two exceptions: immediately after exclusive-mode has + ** been turned on (and before any read or write transactions are + ** executed), and when the pager is leaving the "error state". + ** + ** * See also: assert_pager_state(). + */ - //#define PAGER_OPEN 0 - //#define PAGER_READER 1 - //#define PAGER_WRITER_LOCKED 2 - //#define PAGER_WRITER_CACHEMOD 3 - //#define PAGER_WRITER_DBMOD 4 - //#define PAGER_WRITER_FINISHED 5 - //#define PAGER_ERROR 6 - const int PAGER_OPEN = 0; - const int PAGER_READER = 1; - const int PAGER_WRITER_LOCKED = 2; - const int PAGER_WRITER_CACHEMOD = 3; - const int PAGER_WRITER_DBMOD = 4; - const int PAGER_WRITER_FINISHED = 5; - const int PAGER_ERROR = 6; + //#define PAGER_OPEN 0 + //#define PAGER_READER 1 + //#define PAGER_WRITER_LOCKED 2 + //#define PAGER_WRITER_CACHEMOD 3 + //#define PAGER_WRITER_DBMOD 4 + //#define PAGER_WRITER_FINISHED 5 + //#define PAGER_ERROR 6 + const int PAGER_OPEN = 0; + const int PAGER_READER = 1; + const int PAGER_WRITER_LOCKED = 2; + const int PAGER_WRITER_CACHEMOD = 3; + const int PAGER_WRITER_DBMOD = 4; + const int PAGER_WRITER_FINISHED = 5; + const int PAGER_ERROR = 6; - /* - ** The Pager.eLock variable is almost always set to one of the - ** following locking-states, according to the lock currently held on - ** the database file: NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK. - ** This variable is kept up to date as locks are taken and released by - ** the pagerLockDb() and pagerUnlockDb() wrappers. - ** - ** If the VFS xLock() or xUnlock() returns an error other than SQLITE_BUSY - ** (i.e. one of the SQLITE_IOERR subtypes), it is not clear whether or not - ** the operation was successful. In these circumstances pagerLockDb() and - ** pagerUnlockDb() take a conservative approach - eLock is always updated - ** when unlocking the file, and only updated when locking the file if the - ** VFS call is successful. This way, the Pager.eLock variable may be set - ** to a less exclusive (lower) value than the lock that is actually held - ** at the system level, but it is never set to a more exclusive value. - ** - ** This is usually safe. If an xUnlock fails or appears to fail, there may - ** be a few redundant xLock() calls or a lock may be held for longer than - ** required, but nothing really goes wrong. - ** - ** The exception is when the database file is unlocked as the pager moves - ** from ERROR to OPEN state. At this point there may be a hot-journal file - ** in the file-system that needs to be rolled back (as part of a OPEN->SHARED - ** transition, by the same pager or any other). If the call to xUnlock() - ** fails at this point and the pager is left holding an EXCLUSIVE lock, this - ** can confuse the call to xCheckReservedLock() call made later as part - ** of hot-journal detection. - ** - ** xCheckReservedLock() is defined as returning true "if there is a RESERVED - ** lock held by this process or any others". So xCheckReservedLock may - ** return true because the caller itself is holding an EXCLUSIVE lock (but - ** doesn't know it because of a previous error in xUnlock). If this happens - ** a hot-journal may be mistaken for a journal being created by an active - ** transaction in another process, causing SQLite to read from the database - ** without rolling it back. - ** - ** To work around this, if a call to xUnlock() fails when unlocking the - ** database in the ERROR state, Pager.eLock is set to UNKNOWN_LOCK. It - ** is only changed back to a real locking state after a successful call - ** to xLock(EXCLUSIVE). Also, the code to do the OPEN->SHARED state transition - ** omits the check for a hot-journal if Pager.eLock is set to UNKNOWN_LOCK - ** lock. Instead, it assumes a hot-journal exists and obtains an EXCLUSIVE - ** lock on the database file before attempting to roll it back. See function - ** PagerSharedLock() for more detail. - ** - ** Pager.eLock may only be set to UNKNOWN_LOCK when the pager is in - ** PAGER_OPEN state. - */ - //#define UNKNOWN_LOCK (EXCLUSIVE_LOCK+1) - const int UNKNOWN_LOCK = (EXCLUSIVE_LOCK + 1); + /* + ** The Pager.eLock variable is almost always set to one of the + ** following locking-states, according to the lock currently held on + ** the database file: NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK. + ** This variable is kept up to date as locks are taken and released by + ** the pagerLockDb() and pagerUnlockDb() wrappers. + ** + ** If the VFS xLock() or xUnlock() returns an error other than SQLITE_BUSY + ** (i.e. one of the SQLITE_IOERR subtypes), it is not clear whether or not + ** the operation was successful. In these circumstances pagerLockDb() and + ** pagerUnlockDb() take a conservative approach - eLock is always updated + ** when unlocking the file, and only updated when locking the file if the + ** VFS call is successful. This way, the Pager.eLock variable may be set + ** to a less exclusive (lower) value than the lock that is actually held + ** at the system level, but it is never set to a more exclusive value. + ** + ** This is usually safe. If an xUnlock fails or appears to fail, there may + ** be a few redundant xLock() calls or a lock may be held for longer than + ** required, but nothing really goes wrong. + ** + ** The exception is when the database file is unlocked as the pager moves + ** from ERROR to OPEN state. At this point there may be a hot-journal file + ** in the file-system that needs to be rolled back (as part of a OPEN->SHARED + ** transition, by the same pager or any other). If the call to xUnlock() + ** fails at this point and the pager is left holding an EXCLUSIVE lock, this + ** can confuse the call to xCheckReservedLock() call made later as part + ** of hot-journal detection. + ** + ** xCheckReservedLock() is defined as returning true "if there is a RESERVED + ** lock held by this process or any others". So xCheckReservedLock may + ** return true because the caller itself is holding an EXCLUSIVE lock (but + ** doesn't know it because of a previous error in xUnlock). If this happens + ** a hot-journal may be mistaken for a journal being created by an active + ** transaction in another process, causing SQLite to read from the database + ** without rolling it back. + ** + ** To work around this, if a call to xUnlock() fails when unlocking the + ** database in the ERROR state, Pager.eLock is set to UNKNOWN_LOCK. It + ** is only changed back to a real locking state after a successful call + ** to xLock(EXCLUSIVE). Also, the code to do the OPEN->SHARED state transition + ** omits the check for a hot-journal if Pager.eLock is set to UNKNOWN_LOCK + ** lock. Instead, it assumes a hot-journal exists and obtains an EXCLUSIVE + ** lock on the database file before attempting to roll it back. See function + ** PagerSharedLock() for more detail. + ** + ** Pager.eLock may only be set to UNKNOWN_LOCK when the pager is in + ** PAGER_OPEN state. + */ + //#define UNKNOWN_LOCK (EXCLUSIVE_LOCK+1) + const int UNKNOWN_LOCK = ( EXCLUSIVE_LOCK + 1 ); - /* - ** A macro used for invoking the codec if there is one - */ + /* + ** A macro used for invoking the codec if there is one + */ - // The E parameter is what executes when there is an error, - // cannot implement here, since this is not really a macro - // calling code must be modified to call E when truen + // The E parameter is what executes when there is an error, + // cannot implement here, since this is not really a macro + // calling code must be modified to call E when truen #if SQLITE_HAS_CODEC //# define CODEC1(P,D,N,X,E) \ @@ -486,300 +492,303 @@ static bool CODEC2( Pager P, byte[] D, uint N, int X, ref byte[] O ) } } #else - //# define CODEC1(P,D,N,X,E) /* NO-OP */ - static bool CODEC1(Pager P, byte[] D, uint N /* page number */, int X /* E (moved to caller */) { return false; } - //# define CODEC2(P,D,N,X,E,O) O=(char*)D - static bool CODEC2(Pager P, byte[] D, uint N, int X, ref byte[] O) { O = D; return false; } +//# define CODEC1(P,D,N,X,E) /* NO-OP */ +static bool CODEC1 (Pager P, byte[] D, uint N /* page number */, int X /* E (moved to caller */) { return false; } +//# define CODEC2(P,D,N,X,E,O) O=(char*)D +static bool CODEC2( Pager P, byte[] D, uint N, int X, ref byte[] O ) { O = D; return false; } #endif - /* - ** The maximum allowed sector size. 64KiB. If the xSectorsize() method - ** returns a value larger than this, then MAX_SECTOR_SIZE is used instead. - ** This could conceivably cause corruption following a power failure on - ** such a system. This is currently an undocumented limit. - */ - //#define MAX_SECTOR_SIZE 0x10000 - const int MAX_SECTOR_SIZE = 0x10000; + /* +** The maximum allowed sector size. 64KiB. If the xSectorsize() method +** returns a value larger than this, then MAX_SECTOR_SIZE is used instead. +** This could conceivably cause corruption following a power failure on +** such a system. This is currently an undocumented limit. +*/ + //#define MAX_SECTOR_SIZE 0x10000 + const int MAX_SECTOR_SIZE = 0x10000; - /* - ** An instance of the following structure is allocated for each active - ** savepoint and statement transaction in the system. All such structures - ** are stored in the Pager.aSavepoint[] array, which is allocated and - ** resized using sqlite3Realloc(). - ** - ** When a savepoint is created, the PagerSavepoint.iHdrOffset field is - ** set to 0. If a journal-header is written into the main journal while - ** the savepoint is active, then iHdrOffset is set to the byte offset - ** immediately following the last journal record written into the main - ** journal before the journal-header. This is required during savepoint - ** rollback (see pagerPlaybackSavepoint()). - */ - //typedef struct PagerSavepoint PagerSavepoint; - public class PagerSavepoint { - public i64 iOffset; /* Starting offset in main journal */ - public i64 iHdrOffset; /* See above */ - public Bitvec pInSavepoint; /* Set of pages in this savepoint */ - public Pgno nOrig; /* Original number of pages in file */ - public Pgno iSubRec; /* Index of first record in sub-journal */ + /* + ** An instance of the following structure is allocated for each active + ** savepoint and statement transaction in the system. All such structures + ** are stored in the Pager.aSavepoint[] array, which is allocated and + ** resized using sqlite3Realloc(). + ** + ** When a savepoint is created, the PagerSavepoint.iHdrOffset field is + ** set to 0. If a journal-header is written into the main journal while + ** the savepoint is active, then iHdrOffset is set to the byte offset + ** immediately following the last journal record written into the main + ** journal before the journal-header. This is required during savepoint + ** rollback (see pagerPlaybackSavepoint()). + */ + //typedef struct PagerSavepoint PagerSavepoint; + public class PagerSavepoint + { + public i64 iOffset; /* Starting offset in main journal */ + public i64 iHdrOffset; /* See above */ + public Bitvec pInSavepoint; /* Set of pages in this savepoint */ + public Pgno nOrig; /* Original number of pages in file */ + public Pgno iSubRec; /* Index of first record in sub-journal */ #if !SQLITE_OMIT_WAL public u32 aWalData[WAL_SAVEPOINT_NDATA]; /* WAL savepoint context */ #else - public object aWalData = null; /* Used for C# convenience */ + public object aWalData = null; /* Used for C# convenience */ #endif - public static implicit operator bool(PagerSavepoint b) { - return (b != null); - } - }; - + public static implicit operator bool( PagerSavepoint b ) + { + return ( b != null ); + } + }; - /* - ** A open page cache is an instance of struct Pager. A description of - ** some of the more important member variables follows: - ** - ** eState - ** - ** The current 'state' of the pager object. See the comment and state - ** diagram above for a description of the pager state. - ** - ** eLock - ** - ** For a real on-disk database, the current lock held on the database file - - ** NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK. - ** - ** For a temporary or in-memory database (neither of which require any - ** locks), this variable is always set to EXCLUSIVE_LOCK. Since such - ** databases always have Pager.exclusiveMode==1, this tricks the pager - ** logic into thinking that it already has all the locks it will ever - ** need (and no reason to release them). - ** - ** In some (obscure) circumstances, this variable may also be set to - ** UNKNOWN_LOCK. See the comment above the #define of UNKNOWN_LOCK for - ** details. - ** - ** changeCountDone - ** - ** This boolean variable is used to make sure that the change-counter - ** (the 4-byte header field at byte offset 24 of the database file) is - ** not updated more often than necessary. - ** - ** It is set to true when the change-counter field is updated, which - ** can only happen if an exclusive lock is held on the database file. - ** It is cleared (set to false) whenever an exclusive lock is - ** relinquished on the database file. Each time a transaction is committed, - ** The changeCountDone flag is inspected. If it is true, the work of - ** updating the change-counter is omitted for the current transaction. - ** - ** This mechanism means that when running in exclusive mode, a connection - ** need only update the change-counter once, for the first transaction - ** committed. - ** - ** setMaster - ** - ** When PagerCommitPhaseOne() is called to commit a transaction, it may - ** (or may not) specify a master-journal name to be written into the - ** journal file before it is synced to disk. - ** - ** Whether or not a journal file contains a master-journal pointer affects - ** the way in which the journal file is finalized after the transaction is - ** committed or rolled back when running in "journal_mode=PERSIST" mode. - ** If a journal file does not contain a master-journal pointer, it is - ** finalized by overwriting the first journal header with zeroes. If - ** it does contain a master-journal pointer the journal file is finalized - ** by truncating it to zero bytes, just as if the connection were - ** running in "journal_mode=truncate" mode. - ** - ** Journal files that contain master journal pointers cannot be finalized - ** simply by overwriting the first journal-header with zeroes, as the - ** master journal pointer could interfere with hot-journal rollback of any - ** subsequently interrupted transaction that reuses the journal file. - ** - ** The flag is cleared as soon as the journal file is finalized (either - ** by PagerCommitPhaseTwo or PagerRollback). If an IO error prevents the - ** journal file from being successfully finalized, the setMaster flag - ** is cleared anyway (and the pager will move to ERROR state). - ** - ** doNotSpill, doNotSyncSpill - ** - ** These two boolean variables control the behaviour of cache-spills - ** (calls made by the pcache module to the pagerStress() routine to - ** write cached data to the file-system in order to free up memory). - ** - ** When doNotSpill is non-zero, writing to the database from pagerStress() - ** is disabled altogether. This is done in a very obscure case that - ** comes up during savepoint rollback that requires the pcache module - ** to allocate a new page to prevent the journal file from being written - ** while it is being traversed by code in pager_playback(). - ** - ** If doNotSyncSpill is non-zero, writing to the database from pagerStress() - ** is permitted, but syncing the journal file is not. This flag is set - ** by sqlite3PagerWrite() when the file-system sector-size is larger than - ** the database page-size in order to prevent a journal sync from happening - ** in between the journalling of two pages on the same sector. - ** - ** subjInMemory - ** - ** This is a boolean variable. If true, then any required sub-journal - ** is opened as an in-memory journal file. If false, then in-memory - ** sub-journals are only used for in-memory pager files. - ** - ** This variable is updated by the upper layer each time a new - ** write-transaction is opened. - ** - ** dbSize, dbOrigSize, dbFileSize - ** - ** Variable dbSize is set to the number of pages in the database file. - ** It is valid in PAGER_READER and higher states (all states except for - ** OPEN and ERROR). - ** - ** dbSize is set based on the size of the database file, which may be - ** larger than the size of the database (the value stored at offset - ** 28 of the database header by the btree). If the size of the file - ** is not an integer multiple of the page-size, the value stored in - ** dbSize is rounded down (i.e. a 5KB file with 2K page-size has dbSize==2). - ** Except, any file that is greater than 0 bytes in size is considered - ** to have at least one page. (i.e. a 1KB file with 2K page-size leads - ** to dbSize==1). - ** - ** During a write-transaction, if pages with page-numbers greater than - ** dbSize are modified in the cache, dbSize is updated accordingly. - ** Similarly, if the database is truncated using PagerTruncateImage(), - ** dbSize is updated. - ** - ** Variables dbOrigSize and dbFileSize are valid in states - ** PAGER_WRITER_LOCKED and higher. dbOrigSize is a copy of the dbSize - ** variable at the start of the transaction. It is used during rollback, - ** and to determine whether or not pages need to be journalled before - ** being modified. - ** - ** Throughout a write-transaction, dbFileSize contains the size of - ** the file on disk in pages. It is set to a copy of dbSize when the - ** write-transaction is first opened, and updated when VFS calls are made - ** to write or truncate the database file on disk. - ** - ** The only reason the dbFileSize variable is required is to suppress - ** unnecessary calls to xTruncate() after committing a transaction. If, - ** when a transaction is committed, the dbFileSize variable indicates - ** that the database file is larger than the database image (Pager.dbSize), - ** pager_truncate() is called. The pager_truncate() call uses xFilesize() - ** to measure the database file on disk, and then truncates it if required. - ** dbFileSize is not used when rolling back a transaction. In this case - ** pager_truncate() is called unconditionally (which means there may be - ** a call to xFilesize() that is not strictly required). In either case, - ** pager_truncate() may cause the file to become smaller or larger. - ** - ** dbHintSize - ** - ** The dbHintSize variable is used to limit the number of calls made to - ** the VFS xFileControl(FCNTL_SIZE_HINT) method. - ** - ** dbHintSize is set to a copy of the dbSize variable when a - ** write-transaction is opened (at the same time as dbFileSize and - ** dbOrigSize). If the xFileControl(FCNTL_SIZE_HINT) method is called, - ** dbHintSize is increased to the number of pages that correspond to the - ** size-hint passed to the method call. See pager_write_pagelist() for - ** details. - ** - ** errCode - ** - ** The Pager.errCode variable is only ever used in PAGER_ERROR state. It - ** is set to zero in all other states. In PAGER_ERROR state, Pager.errCode - ** is always set to SQLITE_FULL, SQLITE_IOERR or one of the SQLITE_IOERR_XXX - ** sub-codes. - */ - public class Pager { - public sqlite3_vfs pVfs; /* OS functions to use for IO */ - public bool exclusiveMode; /* Boolean. True if locking_mode==EXCLUSIVE */ - public u8 journalMode; /* One of the PAGER_JOURNALMODE_* values */ - public u8 useJournal; /* Use a rollback journal on this file */ - public u8 noReadlock; /* Do not bother to obtain readlocks */ - public bool noSync; /* Do not sync the journal if true */ - public bool fullSync; /* Do extra syncs of the journal for robustness */ - public u8 ckptSyncFlags; /* SYNC_NORMAL or SYNC_FULL for checkpoint */ - public u8 syncFlags; /* SYNC_NORMAL or SYNC_FULL otherwise */ - public bool tempFile; /* zFilename is a temporary file */ - public bool readOnly; /* True for a read-only database */ - public bool alwaysRollback; /* Disable DontRollback() for all pages */ - public u8 memDb; /* True to inhibit all file I/O */ - /************************************************************************** - ** The following block contains those class members that change during - ** routine opertion. Class members not in this block are either fixed - ** when the pager is first created or else only change when there is a - ** significant mode change (such as changing the page_size, locking_mode, - ** or the journal_mode). From another view, these class members describe - ** the "state" of the pager, while other class members describe the - ** "configuration" of the pager. - */ - public u8 eState; /* Pager state (OPEN, READER, WRITER_LOCKED..) */ - public u8 eLock; /* Current lock held on database file */ - public bool changeCountDone; /* Set after incrementing the change-counter */ - public int setMaster; /* True if a m-j name has been written to jrnl */ - public u8 doNotSpill; /* Do not spill the cache when non-zero */ - public u8 doNotSyncSpill; /* Do not do a spill that requires jrnl sync */ - public u8 subjInMemory; /* True to use in-memory sub-journals */ - public Pgno dbSize; /* Number of pages in the database */ - public Pgno dbOrigSize; /* dbSize before the current transaction */ - public Pgno dbFileSize; /* Number of pages in the database file */ - public Pgno dbHintSize; /* Value passed to FCNTL_SIZE_HINT call */ - public int errCode; /* One of several kinds of errors */ - public int nRec; /* Pages journalled since last j-header written */ - public u32 cksumInit; /* Quasi-random value added to every checksum */ - public u32 nSubRec; /* Number of records written to sub-journal */ - public Bitvec pInJournal; /* One bit for each page in the database file */ - public sqlite3_file fd; /* File descriptor for database */ - public sqlite3_file jfd; /* File descriptor for main journal */ - public sqlite3_file sjfd; /* File descriptor for sub-journal */ - public i64 journalOff; /* Current write offset in the journal file */ - public i64 journalHdr; /* Byte offset to previous journal header */ - public sqlite3_backup pBackup; /* Pointer to list of ongoing backup processes */ - public PagerSavepoint[] aSavepoint;/* Array of active savepoints */ - public int nSavepoint; /* Number of elements in aSavepoint[] */ - public u8[] dbFileVers = new u8[16];/* Changes whenever database file changes */ - /* - ** End of the routinely-changing class members - ***************************************************************************/ - - public u16 nExtra; /* Add this many bytes to each in-memory page */ - public i16 nReserve; /* Number of unused bytes at end of each page */ - public u32 vfsFlags; /* Flags for sqlite3_vfs.xOpen() */ - public u32 sectorSize; /* Assumed sector size during rollback */ - public int pageSize; /* Number of bytes in a page */ - public Pgno mxPgno; /* Maximum allowed size of the database */ - public i64 journalSizeLimit; /* Size limit for persistent journal files */ - public string zFilename; /* Name of the database file */ - public string zJournal; /* Name of the journal file */ - public dxBusyHandler xBusyHandler; /* Function to call when busy */ - public object pBusyHandlerArg; /* Context argument for xBusyHandler */ -#if SQLITE_TEST || DEBUG - public int nHit, nMiss; /* Cache hits and missing */ - public int nRead, nWrite; /* Database pages read/written */ -#else -public int nHit; -#endif - public dxReiniter xReiniter; //(DbPage*,int);/* Call this routine when reloading pages */ -#if SQLITE_HAS_CODEC - //void *(*xCodec)(void*,void*,Pgno,int); - public dxCodec xCodec; /* Routine for en/decoding data */ - //void (*xCodecSizeChng)(void*,int,int); - public dxCodecSizeChng xCodecSizeChng; /* Notify of page size changes */ - //void (*xCodecFree)(void*); - public dxCodecFree xCodecFree; /* Destructor for the codec */ - public codec_ctx pCodec; /* First argument to xCodec... methods */ -#endif - public byte[] pTmpSpace; /* Pager.pageSize bytes of space for tmp use */ - public PCache pPCache; /* Pointer to page cache object */ -#if !SQLITE_OMIT_WAL -public Wal pWal; /* Write-ahead log used by "journal_mode=wal" */ -public string zWal; /* File name for write-ahead log */ -#else - public sqlite3_vfs pWal = null; /* Having this dummy here makes C# easier */ -#endif - }; - /* - ** The following global variables hold counters used for - ** testing purposes only. These variables do not exist in - ** a non-testing build. These variables are not thread-safe. - */ + /* + ** A open page cache is an instance of struct Pager. A description of + ** some of the more important member variables follows: + ** + ** eState + ** + ** The current 'state' of the pager object. See the comment and state + ** diagram above for a description of the pager state. + ** + ** eLock + ** + ** For a real on-disk database, the current lock held on the database file - + ** NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK. + ** + ** For a temporary or in-memory database (neither of which require any + ** locks), this variable is always set to EXCLUSIVE_LOCK. Since such + ** databases always have Pager.exclusiveMode==1, this tricks the pager + ** logic into thinking that it already has all the locks it will ever + ** need (and no reason to release them). + ** + ** In some (obscure) circumstances, this variable may also be set to + ** UNKNOWN_LOCK. See the comment above the #define of UNKNOWN_LOCK for + ** details. + ** + ** changeCountDone + ** + ** This boolean variable is used to make sure that the change-counter + ** (the 4-byte header field at byte offset 24 of the database file) is + ** not updated more often than necessary. + ** + ** It is set to true when the change-counter field is updated, which + ** can only happen if an exclusive lock is held on the database file. + ** It is cleared (set to false) whenever an exclusive lock is + ** relinquished on the database file. Each time a transaction is committed, + ** The changeCountDone flag is inspected. If it is true, the work of + ** updating the change-counter is omitted for the current transaction. + ** + ** This mechanism means that when running in exclusive mode, a connection + ** need only update the change-counter once, for the first transaction + ** committed. + ** + ** setMaster + ** + ** When PagerCommitPhaseOne() is called to commit a transaction, it may + ** (or may not) specify a master-journal name to be written into the + ** journal file before it is synced to disk. + ** + ** Whether or not a journal file contains a master-journal pointer affects + ** the way in which the journal file is finalized after the transaction is + ** committed or rolled back when running in "journal_mode=PERSIST" mode. + ** If a journal file does not contain a master-journal pointer, it is + ** finalized by overwriting the first journal header with zeroes. If + ** it does contain a master-journal pointer the journal file is finalized + ** by truncating it to zero bytes, just as if the connection were + ** running in "journal_mode=truncate" mode. + ** + ** Journal files that contain master journal pointers cannot be finalized + ** simply by overwriting the first journal-header with zeroes, as the + ** master journal pointer could interfere with hot-journal rollback of any + ** subsequently interrupted transaction that reuses the journal file. + ** + ** The flag is cleared as soon as the journal file is finalized (either + ** by PagerCommitPhaseTwo or PagerRollback). If an IO error prevents the + ** journal file from being successfully finalized, the setMaster flag + ** is cleared anyway (and the pager will move to ERROR state). + ** + ** doNotSpill, doNotSyncSpill + ** + ** These two boolean variables control the behaviour of cache-spills + ** (calls made by the pcache module to the pagerStress() routine to + ** write cached data to the file-system in order to free up memory). + ** + ** When doNotSpill is non-zero, writing to the database from pagerStress() + ** is disabled altogether. This is done in a very obscure case that + ** comes up during savepoint rollback that requires the pcache module + ** to allocate a new page to prevent the journal file from being written + ** while it is being traversed by code in pager_playback(). + ** + ** If doNotSyncSpill is non-zero, writing to the database from pagerStress() + ** is permitted, but syncing the journal file is not. This flag is set + ** by sqlite3PagerWrite() when the file-system sector-size is larger than + ** the database page-size in order to prevent a journal sync from happening + ** in between the journalling of two pages on the same sector. + ** + ** subjInMemory + ** + ** This is a boolean variable. If true, then any required sub-journal + ** is opened as an in-memory journal file. If false, then in-memory + ** sub-journals are only used for in-memory pager files. + ** + ** This variable is updated by the upper layer each time a new + ** write-transaction is opened. + ** + ** dbSize, dbOrigSize, dbFileSize + ** + ** Variable dbSize is set to the number of pages in the database file. + ** It is valid in PAGER_READER and higher states (all states except for + ** OPEN and ERROR). + ** + ** dbSize is set based on the size of the database file, which may be + ** larger than the size of the database (the value stored at offset + ** 28 of the database header by the btree). If the size of the file + ** is not an integer multiple of the page-size, the value stored in + ** dbSize is rounded down (i.e. a 5KB file with 2K page-size has dbSize==2). + ** Except, any file that is greater than 0 bytes in size is considered + ** to have at least one page. (i.e. a 1KB file with 2K page-size leads + ** to dbSize==1). + ** + ** During a write-transaction, if pages with page-numbers greater than + ** dbSize are modified in the cache, dbSize is updated accordingly. + ** Similarly, if the database is truncated using PagerTruncateImage(), + ** dbSize is updated. + ** + ** Variables dbOrigSize and dbFileSize are valid in states + ** PAGER_WRITER_LOCKED and higher. dbOrigSize is a copy of the dbSize + ** variable at the start of the transaction. It is used during rollback, + ** and to determine whether or not pages need to be journalled before + ** being modified. + ** + ** Throughout a write-transaction, dbFileSize contains the size of + ** the file on disk in pages. It is set to a copy of dbSize when the + ** write-transaction is first opened, and updated when VFS calls are made + ** to write or truncate the database file on disk. + ** + ** The only reason the dbFileSize variable is required is to suppress + ** unnecessary calls to xTruncate() after committing a transaction. If, + ** when a transaction is committed, the dbFileSize variable indicates + ** that the database file is larger than the database image (Pager.dbSize), + ** pager_truncate() is called. The pager_truncate() call uses xFilesize() + ** to measure the database file on disk, and then truncates it if required. + ** dbFileSize is not used when rolling back a transaction. In this case + ** pager_truncate() is called unconditionally (which means there may be + ** a call to xFilesize() that is not strictly required). In either case, + ** pager_truncate() may cause the file to become smaller or larger. + ** + ** dbHintSize + ** + ** The dbHintSize variable is used to limit the number of calls made to + ** the VFS xFileControl(FCNTL_SIZE_HINT) method. + ** + ** dbHintSize is set to a copy of the dbSize variable when a + ** write-transaction is opened (at the same time as dbFileSize and + ** dbOrigSize). If the xFileControl(FCNTL_SIZE_HINT) method is called, + ** dbHintSize is increased to the number of pages that correspond to the + ** size-hint passed to the method call. See pager_write_pagelist() for + ** details. + ** + ** errCode + ** + ** The Pager.errCode variable is only ever used in PAGER_ERROR state. It + ** is set to zero in all other states. In PAGER_ERROR state, Pager.errCode + ** is always set to SQLITE_FULL, SQLITE_IOERR or one of the SQLITE_IOERR_XXX + ** sub-codes. + */ + public class Pager + { + public sqlite3_vfs pVfs; /* OS functions to use for IO */ + public bool exclusiveMode; /* Boolean. True if locking_mode==EXCLUSIVE */ + public u8 journalMode; /* One of the PAGER_JOURNALMODE_* values */ + public u8 useJournal; /* Use a rollback journal on this file */ + public u8 noReadlock; /* Do not bother to obtain readlocks */ + public bool noSync; /* Do not sync the journal if true */ + public bool fullSync; /* Do extra syncs of the journal for robustness */ + public u8 ckptSyncFlags; /* SYNC_NORMAL or SYNC_FULL for checkpoint */ + public u8 syncFlags; /* SYNC_NORMAL or SYNC_FULL otherwise */ + public bool tempFile; /* zFilename is a temporary file */ + public bool readOnly; /* True for a read-only database */ + public bool alwaysRollback; /* Disable DontRollback() for all pages */ + public u8 memDb; /* True to inhibit all file I/O */ + /************************************************************************** + ** The following block contains those class members that change during + ** routine opertion. Class members not in this block are either fixed + ** when the pager is first created or else only change when there is a + ** significant mode change (such as changing the page_size, locking_mode, + ** or the journal_mode). From another view, these class members describe + ** the "state" of the pager, while other class members describe the + ** "configuration" of the pager. + */ + public u8 eState; /* Pager state (OPEN, READER, WRITER_LOCKED..) */ + public u8 eLock; /* Current lock held on database file */ + public bool changeCountDone; /* Set after incrementing the change-counter */ + public int setMaster; /* True if a m-j name has been written to jrnl */ + public u8 doNotSpill; /* Do not spill the cache when non-zero */ + public u8 doNotSyncSpill; /* Do not do a spill that requires jrnl sync */ + public u8 subjInMemory; /* True to use in-memory sub-journals */ + public Pgno dbSize; /* Number of pages in the database */ + public Pgno dbOrigSize; /* dbSize before the current transaction */ + public Pgno dbFileSize; /* Number of pages in the database file */ + public Pgno dbHintSize; /* Value passed to FCNTL_SIZE_HINT call */ + public int errCode; /* One of several kinds of errors */ + public int nRec; /* Pages journalled since last j-header written */ + public u32 cksumInit; /* Quasi-random value added to every checksum */ + public u32 nSubRec; /* Number of records written to sub-journal */ + public Bitvec pInJournal; /* One bit for each page in the database file */ + public sqlite3_file fd; /* File descriptor for database */ + public sqlite3_file jfd; /* File descriptor for main journal */ + public sqlite3_file sjfd; /* File descriptor for sub-journal */ + public i64 journalOff; /* Current write offset in the journal file */ + public i64 journalHdr; /* Byte offset to previous journal header */ + public sqlite3_backup pBackup; /* Pointer to list of ongoing backup processes */ + public PagerSavepoint[] aSavepoint;/* Array of active savepoints */ + public int nSavepoint; /* Number of elements in aSavepoint[] */ + public u8[] dbFileVers = new u8[16];/* Changes whenever database file changes */ + /* + ** End of the routinely-changing class members + ***************************************************************************/ + + public u16 nExtra; /* Add this many bytes to each in-memory page */ + public i16 nReserve; /* Number of unused bytes at end of each page */ + public u32 vfsFlags; /* Flags for sqlite3_vfs.xOpen() */ + public u32 sectorSize; /* Assumed sector size during rollback */ + public int pageSize; /* Number of bytes in a page */ + public Pgno mxPgno; /* Maximum allowed size of the database */ + public i64 journalSizeLimit; /* Size limit for persistent journal files */ + public string zFilename; /* Name of the database file */ + public string zJournal; /* Name of the journal file */ + public dxBusyHandler xBusyHandler; /* Function to call when busy */ + public object pBusyHandlerArg; /* Context argument for xBusyHandler */ +#if SQLITE_TEST || DEBUG + public int nHit, nMiss; /* Cache hits and missing */ + public int nRead, nWrite; /* Database pages read/written */ +#else +public int nHit; +#endif + public dxReiniter xReiniter; //(DbPage*,int);/* Call this routine when reloading pages */ +#if SQLITE_HAS_CODEC + //void *(*xCodec)(void*,void*,Pgno,int); + public dxCodec xCodec; /* Routine for en/decoding data */ + //void (*xCodecSizeChng)(void*,int,int); + public dxCodecSizeChng xCodecSizeChng; /* Notify of page size changes */ + //void (*xCodecFree)(void*); + public dxCodecFree xCodecFree; /* Destructor for the codec */ + public codec_ctx pCodec; /* First argument to xCodec... methods */ +#endif + public byte[] pTmpSpace; /* Pager.pageSize bytes of space for tmp use */ + public PCache pPCache; /* Pointer to page cache object */ +#if !SQLITE_OMIT_WAL +public Wal pWal; /* Write-ahead log used by "journal_mode=wal" */ +public string zWal; /* File name for write-ahead log */ +#else + public sqlite3_vfs pWal = null; /* Having this dummy here makes C# easier */ +#endif + }; + + /* + ** The following global variables hold counters used for + ** testing purposes only. These variables do not exist in + ** a non-testing build. These variables are not thread-safe. + */ #if SQLITE_TEST #if !TCLSH static int sqlite3_pager_readdb_count = 0; /* Number of full pages read from DB */ @@ -795,119 +804,127 @@ static void PAGER_INCR( ref int v ) v++; } #else - //# define PAGER_INCR(v) - static void PAGER_INCR(ref int v) { } +//# define PAGER_INCR(v) +static void PAGER_INCR(ref int v) {} #endif - /* - ** Journal files begin with the following magic string. The data - ** was obtained from /dev/random. It is used only as a sanity check. - ** - ** Since version 2.8.0, the journal format contains additional sanity - ** checking information. If the power fails while the journal is being - ** written, semi-random garbage data might appear in the journal - ** file after power is restored. If an attempt is then made - ** to roll the journal back, the database could be corrupted. The additional - ** sanity checking data is an attempt to discover the garbage in the - ** journal and ignore it. - ** - ** The sanity checking information for the new journal format consists - ** of a 32-bit checksum on each page of data. The checksum covers both - ** the page number and the pPager.pageSize bytes of data for the page. - ** This cksum is initialized to a 32-bit random value that appears in the - ** journal file right after the header. The random initializer is important, - ** because garbage data that appears at the end of a journal is likely - ** data that was once in other files that have now been deleted. If the - ** garbage data came from an obsolete journal file, the checksums might - ** be correct. But by initializing the checksum to random value which - ** is different for every journal, we minimize that risk. - */ - static byte[] aJournalMagic = new byte[] { + /* +** Journal files begin with the following magic string. The data +** was obtained from /dev/random. It is used only as a sanity check. +** +** Since version 2.8.0, the journal format contains additional sanity +** checking information. If the power fails while the journal is being +** written, semi-random garbage data might appear in the journal +** file after power is restored. If an attempt is then made +** to roll the journal back, the database could be corrupted. The additional +** sanity checking data is an attempt to discover the garbage in the +** journal and ignore it. +** +** The sanity checking information for the new journal format consists +** of a 32-bit checksum on each page of data. The checksum covers both +** the page number and the pPager.pageSize bytes of data for the page. +** This cksum is initialized to a 32-bit random value that appears in the +** journal file right after the header. The random initializer is important, +** because garbage data that appears at the end of a journal is likely +** data that was once in other files that have now been deleted. If the +** garbage data came from an obsolete journal file, the checksums might +** be correct. But by initializing the checksum to random value which +** is different for every journal, we minimize that risk. +*/ + static byte[] aJournalMagic = new byte[] { 0xd9, 0xd5, 0x05, 0xf9, 0x20, 0xa1, 0x63, 0xd7, }; - /* - ** The size of the of each page record in the journal is given by - ** the following macro. - */ - //#define JOURNAL_PG_SZ(pPager) ((pPager.pageSize) + 8) - static int JOURNAL_PG_SZ(Pager pPager) { - return (pPager.pageSize + 8); - } + /* + ** The size of the of each page record in the journal is given by + ** the following macro. + */ + //#define JOURNAL_PG_SZ(pPager) ((pPager.pageSize) + 8) + static int JOURNAL_PG_SZ( Pager pPager ) + { + return ( pPager.pageSize + 8 ); + } - /* - ** The journal header size for this pager. This is usually the same - ** size as a single disk sector. See also setSectorSize(). - */ - //#define JOURNAL_HDR_SZ(pPager) (pPager.sectorSize) - static u32 JOURNAL_HDR_SZ(Pager pPager) { - return (pPager.sectorSize); - } + /* + ** The journal header size for this pager. This is usually the same + ** size as a single disk sector. See also setSectorSize(). + */ + //#define JOURNAL_HDR_SZ(pPager) (pPager.sectorSize) + static u32 JOURNAL_HDR_SZ( Pager pPager ) + { + return ( pPager.sectorSize ); + } - /* - ** The macro MEMDB is true if we are dealing with an in-memory database. - ** We do this as a macro so that if the SQLITE_OMIT_MEMORYDB macro is set, - ** the value of MEMDB will be a constant and the compiler will optimize - ** out code that would never execute. - */ + /* + ** The macro MEMDB is true if we are dealing with an in-memory database. + ** We do this as a macro so that if the SQLITE_OMIT_MEMORYDB macro is set, + ** the value of MEMDB will be a constant and the compiler will optimize + ** out code that would never execute. + */ #if SQLITE_OMIT_MEMORYDB //# define MEMDB 0 const int MEMDB = 0; #else - //# define MEMDB pPager.memDb + //# define MEMDB pPager.memDb #endif - /* - ** The maximum legal page number is (2^31 - 1). - */ - //#define PAGER_MAX_PGNO 2147483647 - const int PAGER_MAX_PGNO = 2147483647; + /* +** The maximum legal page number is (2^31 - 1). +*/ + //#define PAGER_MAX_PGNO 2147483647 + const int PAGER_MAX_PGNO = 2147483647; - /* - ** The argument to this macro is a file descriptor (type sqlite3_file*). - ** Return 0 if it is not open, or non-zero (but not 1) if it is. - ** - ** This is so that expressions can be written as: - ** - ** if( isOpen(pPager.jfd) ){ ... - ** - ** instead of - ** - ** if( pPager.jfd->pMethods ){ ... - */ - //#define isOpen(pFd) ((pFd)->pMethods) - static bool isOpen(sqlite3_file pFd) { - return pFd.pMethods != null; - } + /* + ** The argument to this macro is a file descriptor (type sqlite3_file*). + ** Return 0 if it is not open, or non-zero (but not 1) if it is. + ** + ** This is so that expressions can be written as: + ** + ** if( isOpen(pPager.jfd) ){ ... + ** + ** instead of + ** + ** if( pPager.jfd->pMethods ){ ... + */ + //#define isOpen(pFd) ((pFd)->pMethods) + static bool isOpen( sqlite3_file pFd ) + { + return pFd.pMethods != null; + } - /* - ** Return true if this pager uses a write-ahead log instead of the usual - ** rollback journal. Otherwise false. - */ + /* + ** Return true if this pager uses a write-ahead log instead of the usual + ** rollback journal. Otherwise false. + */ #if !SQLITE_OMIT_WAL static int pagerUseWal(Pager *pPager){ return (pPager->pWal!=0); } #else - //# define pagerUseWal(x) 0 - static bool pagerUseWal(Pager x) { - return false; - } - //# define pagerRollbackWal(x) 0 - static int pagerRollbackWal(Pager x) { - return 0; - } - //# define pagerWalFrames(v,w,x,y,z) 0 - static int pagerWalFrames(Pager v, PgHdr w, Pgno x, int y, int z) { - return 0; - } - //# define pagerOpenWalIfPresent(z) SQLITE_OK - static int pagerOpenWalIfPresent(Pager z) { - return SQLITE_OK; - } - //# define pagerBeginReadTransaction(z) SQLITE_OK - static int pagerBeginReadTransaction(Pager z) { - return SQLITE_OK; - } + //# define pagerUseWal(x) 0 + static bool pagerUseWal( Pager x ) + { + return false; + } + //# define pagerRollbackWal(x) 0 + static int pagerRollbackWal( Pager x ) + { + return 0; + } + //# define pagerWalFrames(v,w,x,y,z) 0 + static int pagerWalFrames( Pager v, PgHdr w, Pgno x, int y, int z ) + { + return 0; + } + //# define pagerOpenWalIfPresent(z) SQLITE_OK + static int pagerOpenWalIfPresent( Pager z ) + { + return SQLITE_OK; + } + //# define pagerBeginReadTransaction(z) SQLITE_OK + static int pagerBeginReadTransaction( Pager z ) + { + return SQLITE_OK; + } #endif #if NDEBUG @@ -1064,217 +1081,239 @@ static bool assert_pager_state( Pager p ) return true; } #else - static bool assert_pager_state(Pager pPager) { - return true; - } + static bool assert_pager_state( Pager pPager ) + { + return true; + } #endif //* ifndef NDEBUG */ #if SQLITE_DEBUG - /* - ** Return a pointer to a human readable string in a static buffer - ** containing the state of the Pager object passed as an argument. This - ** is intended to be used within debuggers. For example, as an alternative - ** to "print *pPager" in gdb: - ** - ** (gdb) printf "%s", print_pager_state(pPager) - */ - static string print_pager_state(Pager p) { - StringBuilder zRet = new StringBuilder(1024); - - sqlite3_snprintf(1024, zRet, - "Filename: %s\n" + - "State: %s errCode=%d\n" + - "Lock: %s\n" + - "Locking mode: locking_mode=%s\n" + - "Journal mode: journal_mode=%s\n" + - "Backing store: tempFile=%d memDb=%d useJournal=%d\n" + - "Journal: journalOff=%lld journalHdr=%lld\n" + - "Size: dbsize=%d dbOrigSize=%d dbFileSize=%d\n" - , p.zFilename - , p.eState == PAGER_OPEN ? "OPEN" : - p.eState == PAGER_READER ? "READER" : - p.eState == PAGER_WRITER_LOCKED ? "WRITER_LOCKED" : - p.eState == PAGER_WRITER_CACHEMOD ? "WRITER_CACHEMOD" : - p.eState == PAGER_WRITER_DBMOD ? "WRITER_DBMOD" : - p.eState == PAGER_WRITER_FINISHED ? "WRITER_FINISHED" : - p.eState == PAGER_ERROR ? "ERROR" : "?error?" - , (int)p.errCode - , p.eLock == NO_LOCK ? "NO_LOCK" : - p.eLock == RESERVED_LOCK ? "RESERVED" : - p.eLock == EXCLUSIVE_LOCK ? "EXCLUSIVE" : - p.eLock == SHARED_LOCK ? "SHARED" : - p.eLock == UNKNOWN_LOCK ? "UNKNOWN" : "?error?" - , p.exclusiveMode ? "exclusive" : "normal" - , p.journalMode == PAGER_JOURNALMODE_MEMORY ? "memory" : - p.journalMode == PAGER_JOURNALMODE_OFF ? "off" : - p.journalMode == PAGER_JOURNALMODE_DELETE ? "delete" : - p.journalMode == PAGER_JOURNALMODE_PERSIST ? "persist" : - p.journalMode == PAGER_JOURNALMODE_TRUNCATE ? "truncate" : - p.journalMode == PAGER_JOURNALMODE_WAL ? "wal" : "?error?" - , p.tempFile ? 1 : 0, (int)p.memDb, (int)p.useJournal - , p.journalOff, p.journalHdr - , (int)p.dbSize, (int)p.dbOrigSize, (int)p.dbFileSize - ); + /* +** Return a pointer to a human readable string in a static buffer +** containing the state of the Pager object passed as an argument. This +** is intended to be used within debuggers. For example, as an alternative +** to "print *pPager" in gdb: +** +** (gdb) printf "%s", print_pager_state(pPager) +*/ + static string print_pager_state( Pager p ) + { + StringBuilder zRet = new StringBuilder( 1024 ); + + sqlite3_snprintf( 1024, zRet, + "Filename: %s\n" + + "State: %s errCode=%d\n" + + "Lock: %s\n" + + "Locking mode: locking_mode=%s\n" + + "Journal mode: journal_mode=%s\n" + + "Backing store: tempFile=%d memDb=%d useJournal=%d\n" + + "Journal: journalOff=%lld journalHdr=%lld\n" + + "Size: dbsize=%d dbOrigSize=%d dbFileSize=%d\n" + , p.zFilename + , p.eState == PAGER_OPEN ? "OPEN" : + p.eState == PAGER_READER ? "READER" : + p.eState == PAGER_WRITER_LOCKED ? "WRITER_LOCKED" : + p.eState == PAGER_WRITER_CACHEMOD ? "WRITER_CACHEMOD" : + p.eState == PAGER_WRITER_DBMOD ? "WRITER_DBMOD" : + p.eState == PAGER_WRITER_FINISHED ? "WRITER_FINISHED" : + p.eState == PAGER_ERROR ? "ERROR" : "?error?" + , (int)p.errCode + , p.eLock == NO_LOCK ? "NO_LOCK" : + p.eLock == RESERVED_LOCK ? "RESERVED" : + p.eLock == EXCLUSIVE_LOCK ? "EXCLUSIVE" : + p.eLock == SHARED_LOCK ? "SHARED" : + p.eLock == UNKNOWN_LOCK ? "UNKNOWN" : "?error?" + , p.exclusiveMode ? "exclusive" : "normal" + , p.journalMode == PAGER_JOURNALMODE_MEMORY ? "memory" : + p.journalMode == PAGER_JOURNALMODE_OFF ? "off" : + p.journalMode == PAGER_JOURNALMODE_DELETE ? "delete" : + p.journalMode == PAGER_JOURNALMODE_PERSIST ? "persist" : + p.journalMode == PAGER_JOURNALMODE_TRUNCATE ? "truncate" : + p.journalMode == PAGER_JOURNALMODE_WAL ? "wal" : "?error?" + , p.tempFile ? 1 : 0, (int)p.memDb, (int)p.useJournal + , p.journalOff, p.journalHdr + , (int)p.dbSize, (int)p.dbOrigSize, (int)p.dbFileSize + ); - return zRet.ToString(); - } + return zRet.ToString(); + } #endif - /* - ** Return true if it is necessary to write page *pPg into the sub-journal. - ** A page needs to be written into the sub-journal if there exists one - ** or more open savepoints for which: - ** - ** * The page-number is less than or equal to PagerSavepoint.nOrig, and - ** * The bit corresponding to the page-number is not set in - ** PagerSavepoint.pInSavepoint. - */ - static bool subjRequiresPage(PgHdr pPg) { - u32 pgno = pPg.pgno; - Pager pPager = pPg.pPager; - int i; - for (i = 0; i < pPager.nSavepoint; i++) { - PagerSavepoint p = pPager.aSavepoint[i]; - if (p.nOrig >= pgno && 0 == sqlite3BitvecTest(p.pInSavepoint, pgno)) { - return true; - } - } - return false; + /* +** Return true if it is necessary to write page *pPg into the sub-journal. +** A page needs to be written into the sub-journal if there exists one +** or more open savepoints for which: +** +** * The page-number is less than or equal to PagerSavepoint.nOrig, and +** * The bit corresponding to the page-number is not set in +** PagerSavepoint.pInSavepoint. +*/ + static bool subjRequiresPage( PgHdr pPg ) + { + u32 pgno = pPg.pgno; + Pager pPager = pPg.pPager; + int i; + for ( i = 0; i < pPager.nSavepoint; i++ ) + { + PagerSavepoint p = pPager.aSavepoint[i]; + if ( p.nOrig >= pgno && 0 == sqlite3BitvecTest( p.pInSavepoint, pgno ) ) + { + return true; } + } + return false; + } - /* - ** Return true if the page is already in the journal file. - */ - static bool pageInJournal(PgHdr pPg) { - return sqlite3BitvecTest(pPg.pPager.pInJournal, pPg.pgno) != 0; - } + /* + ** Return true if the page is already in the journal file. + */ + static bool pageInJournal( PgHdr pPg ) + { + return sqlite3BitvecTest( pPg.pPager.pInJournal, pPg.pgno ) != 0; + } - /* - ** Read a 32-bit integer from the given file descriptor. Store the integer - ** that is read in pRes. Return SQLITE_OK if everything worked, or an - ** error code is something goes wrong. - ** - ** All values are stored on disk as big-endian. - */ - static int read32bits(sqlite3_file fd, int offset, ref int pRes) { - u32 u32_pRes = 0; - int rc = read32bits(fd, offset, ref u32_pRes); - pRes = (int)u32_pRes; - return rc; - } - static int read32bits(sqlite3_file fd, i64 offset, ref u32 pRes) { - int rc = read32bits(fd, (int)offset, ref pRes); - return rc; - } - static int read32bits(sqlite3_file fd, int offset, ref u32 pRes) { - byte[] ac = new byte[4]; - int rc = sqlite3OsRead(fd, ac, ac.Length, offset); - if (rc == SQLITE_OK) { - pRes = sqlite3Get4byte(ac); - } else - pRes = 0; - return rc; - } + /* + ** Read a 32-bit integer from the given file descriptor. Store the integer + ** that is read in pRes. Return SQLITE_OK if everything worked, or an + ** error code is something goes wrong. + ** + ** All values are stored on disk as big-endian. + */ + static int read32bits( sqlite3_file fd, int offset, ref int pRes ) + { + u32 u32_pRes = 0; + int rc = read32bits( fd, offset, ref u32_pRes ); + pRes = (int)u32_pRes; + return rc; + } + static int read32bits( sqlite3_file fd, i64 offset, ref u32 pRes ) + { + int rc = read32bits( fd, (int)offset, ref pRes ); + return rc; + } + static int read32bits( sqlite3_file fd, int offset, ref u32 pRes ) + { + byte[] ac = new byte[4]; + int rc = sqlite3OsRead( fd, ac, ac.Length, offset ); + if ( rc == SQLITE_OK ) + { + pRes = sqlite3Get4byte( ac ); + } + else + pRes = 0; + return rc; + } - /* - ** Write a 32-bit integer into a string buffer in big-endian byte order. - */ - //#define put32bits(A,B) sqlite3sqlite3Put4byte((u8*)A,B) - static void put32bits(string ac, int offset, int val) { - byte[] A = new byte[4]; - A[0] = (byte)ac[offset + 0]; - A[1] = (byte)ac[offset + 1]; - A[2] = (byte)ac[offset + 2]; - A[3] = (byte)ac[offset + 3]; - sqlite3Put4byte(A, 0, val); - } - static void put32bits(byte[] ac, int offset, int val) { - sqlite3Put4byte(ac, offset, (u32)val); - } - static void put32bits(byte[] ac, u32 val) { - sqlite3Put4byte(ac, 0U, val); - } - static void put32bits(byte[] ac, int offset, u32 val) { - sqlite3Put4byte(ac, offset, val); - } + /* + ** Write a 32-bit integer into a string buffer in big-endian byte order. + */ + //#define put32bits(A,B) sqlite3sqlite3Put4byte((u8*)A,B) + static void put32bits( string ac, int offset, int val ) + { + byte[] A = new byte[4]; + A[0] = (byte)ac[offset + 0]; + A[1] = (byte)ac[offset + 1]; + A[2] = (byte)ac[offset + 2]; + A[3] = (byte)ac[offset + 3]; + sqlite3Put4byte( A, 0, val ); + } + static void put32bits( byte[] ac, int offset, int val ) + { + sqlite3Put4byte( ac, offset, (u32)val ); + } + static void put32bits( byte[] ac, u32 val ) + { + sqlite3Put4byte( ac, 0U, val ); + } + static void put32bits( byte[] ac, int offset, u32 val ) + { + sqlite3Put4byte( ac, offset, val ); + } - /* - ** Write a 32-bit integer into the given file descriptor. Return SQLITE_OK - ** on success or an error code is something goes wrong. - */ - static int write32bits(sqlite3_file fd, i64 offset, u32 val) { - byte[] ac = new byte[4]; - put32bits(ac, val); - return sqlite3OsWrite(fd, ac, 4, offset); - } + /* + ** Write a 32-bit integer into the given file descriptor. Return SQLITE_OK + ** on success or an error code is something goes wrong. + */ + static int write32bits( sqlite3_file fd, i64 offset, u32 val ) + { + byte[] ac = new byte[4]; + put32bits( ac, val ); + return sqlite3OsWrite( fd, ac, 4, offset ); + } - /* - ** Unlock the database file to level eLock, which must be either NO_LOCK - ** or SHARED_LOCK. Regardless of whether or not the call to xUnlock() - ** succeeds, set the Pager.eLock variable to match the (attempted) new lock. - ** - ** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is - ** called, do not modify it. See the comment above the #define of - ** UNKNOWN_LOCK for an explanation of this. - */ - static int pagerUnlockDb(Pager pPager, int eLock) { - int rc = SQLITE_OK; + /* + ** Unlock the database file to level eLock, which must be either NO_LOCK + ** or SHARED_LOCK. Regardless of whether or not the call to xUnlock() + ** succeeds, set the Pager.eLock variable to match the (attempted) new lock. + ** + ** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is + ** called, do not modify it. See the comment above the #define of + ** UNKNOWN_LOCK for an explanation of this. + */ + static int pagerUnlockDb( Pager pPager, int eLock ) + { + int rc = SQLITE_OK; - Debug.Assert(!pPager.exclusiveMode || pPager.eLock == eLock); - Debug.Assert(eLock == NO_LOCK || eLock == SHARED_LOCK); - Debug.Assert(eLock != NO_LOCK || pagerUseWal(pPager) == false); - if (isOpen(pPager.fd)) { - Debug.Assert(pPager.eLock >= eLock); - rc = sqlite3OsUnlock(pPager.fd, eLock); - if (pPager.eLock != UNKNOWN_LOCK) { - pPager.eLock = (u8)eLock; - } - IOTRACE("UNLOCK %p %d\n", pPager, eLock); - } - return rc; + Debug.Assert( !pPager.exclusiveMode || pPager.eLock == eLock ); + Debug.Assert( eLock == NO_LOCK || eLock == SHARED_LOCK ); + Debug.Assert( eLock != NO_LOCK || pagerUseWal( pPager ) == false ); + if ( isOpen( pPager.fd ) ) + { + Debug.Assert( pPager.eLock >= eLock ); + rc = sqlite3OsUnlock( pPager.fd, eLock ); + if ( pPager.eLock != UNKNOWN_LOCK ) + { + pPager.eLock = (u8)eLock; } + IOTRACE( "UNLOCK %p %d\n", pPager, eLock ); + } + return rc; + } - /* - ** Lock the database file to level eLock, which must be either SHARED_LOCK, - ** RESERVED_LOCK or EXCLUSIVE_LOCK. If the caller is successful, set the - ** Pager.eLock variable to the new locking state. - ** - ** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is - ** called, do not modify it unless the new locking state is EXCLUSIVE_LOCK. - ** See the comment above the #define of UNKNOWN_LOCK for an explanation - ** of this. - */ - static int pagerLockDb(Pager pPager, int eLock) { - int rc = SQLITE_OK; + /* + ** Lock the database file to level eLock, which must be either SHARED_LOCK, + ** RESERVED_LOCK or EXCLUSIVE_LOCK. If the caller is successful, set the + ** Pager.eLock variable to the new locking state. + ** + ** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is + ** called, do not modify it unless the new locking state is EXCLUSIVE_LOCK. + ** See the comment above the #define of UNKNOWN_LOCK for an explanation + ** of this. + */ + static int pagerLockDb( Pager pPager, int eLock ) + { + int rc = SQLITE_OK; - Debug.Assert(eLock == SHARED_LOCK || eLock == RESERVED_LOCK || eLock == EXCLUSIVE_LOCK); - if (pPager.eLock < eLock || pPager.eLock == UNKNOWN_LOCK) { - rc = sqlite3OsLock(pPager.fd, eLock); - if (rc == SQLITE_OK && (pPager.eLock != UNKNOWN_LOCK || eLock == EXCLUSIVE_LOCK)) { - pPager.eLock = (u8)eLock; - IOTRACE("LOCK %p %d\n", pPager, eLock); - } - } - return rc; + Debug.Assert( eLock == SHARED_LOCK || eLock == RESERVED_LOCK || eLock == EXCLUSIVE_LOCK ); + if ( pPager.eLock < eLock || pPager.eLock == UNKNOWN_LOCK ) + { + rc = sqlite3OsLock( pPager.fd, eLock ); + if ( rc == SQLITE_OK && ( pPager.eLock != UNKNOWN_LOCK || eLock == EXCLUSIVE_LOCK ) ) + { + pPager.eLock = (u8)eLock; + IOTRACE( "LOCK %p %d\n", pPager, eLock ); } + } + return rc; + } - /* - ** This function determines whether or not the atomic-write optimization - ** can be used with this pager. The optimization can be used if: - ** - ** (a) the value returned by OsDeviceCharacteristics() indicates that - ** a database page may be written atomically, and - ** (b) the value returned by OsSectorSize() is less than or equal - ** to the page size. - ** - ** The optimization is also always enabled for temporary files. It is - ** an error to call this function if pPager is opened on an in-memory - ** database. - ** - ** If the optimization cannot be used, 0 is returned. If it can be used, - ** then the value returned is the size of the journal file when it - ** contains rollback data for exactly one page. - */ + /* + ** This function determines whether or not the atomic-write optimization + ** can be used with this pager. The optimization can be used if: + ** + ** (a) the value returned by OsDeviceCharacteristics() indicates that + ** a database page may be written atomically, and + ** (b) the value returned by OsSectorSize() is less than or equal + ** to the page size. + ** + ** The optimization is also always enabled for temporary files. It is + ** an error to call this function if pPager is opened on an in-memory + ** database. + ** + ** If the optimization cannot be used, 0 is returned. If it can be used, + ** then the value returned is the size of the journal file when it + ** contains rollback data for exactly one page. + */ #if SQLITE_ENABLE_ATOMIC_WRITE static int jrnlBufferSize(Pager *pPager){ Debug.Assert( 0==MEMDB ); @@ -1299,11 +1338,11 @@ static int jrnlBufferSize(Pager *pPager){ } #endif - /* - ** If SQLITE_CHECK_PAGES is defined then we do some sanity checking - ** on the cache using a hash function. This is used for testing - ** and debugging only. - */ + /* +** If SQLITE_CHECK_PAGES is defined then we do some sanity checking +** on the cache using a hash function. This is used for testing +** and debugging only. +*/ #if SQLITE_CHECK_PAGES /* ** Return a 32-bit hash of the page data for pPage. @@ -1336,809 +1375,882 @@ static void checkPage(PgHdr pPg){ } #else - //#define pager_datahash(X,Y) 0 - static int pager_datahash(int X, byte[] Y) { - return 0; - } + //#define pager_datahash(X,Y) 0 + static int pager_datahash( int X, byte[] Y ) + { + return 0; + } - //#define pager_pagehash(X) 0 - static int pager_pagehash(PgHdr X) { - return 0; - } + //#define pager_pagehash(X) 0 + static int pager_pagehash( PgHdr X ) + { + return 0; + } - //#define pager_set_pagehash(X) - static void pager_set_pagehash(PgHdr X) { - } + //#define pager_set_pagehash(X) + static void pager_set_pagehash( PgHdr X ) + { + } - //#define CHECK_PAGE(x) + //#define CHECK_PAGE(x) #endif //* SQLITE_CHECK_PAGES */ - /* - ** When this is called the journal file for pager pPager must be open. - ** This function attempts to read a master journal file name from the - ** end of the file and, if successful, copies it into memory supplied - ** by the caller. See comments above writeMasterJournal() for the format - ** used to store a master journal file name at the end of a journal file. - ** - ** zMaster must point to a buffer of at least nMaster bytes allocated by - ** the caller. This should be sqlite3_vfs.mxPathname+1 (to ensure there is - ** enough space to write the master journal name). If the master journal - ** name in the journal is longer than nMaster bytes (including a - ** nul-terminator), then this is handled as if no master journal name - ** were present in the journal. - ** - ** If a master journal file name is present at the end of the journal - ** file, then it is copied into the buffer pointed to by zMaster. A - ** nul-terminator byte is appended to the buffer following the master - ** journal file name. - ** - ** If it is determined that no master journal file name is present - ** zMaster[0] is set to 0 and SQLITE_OK returned. - ** - ** If an error occurs while reading from the journal file, an SQLite - ** error code is returned. - */ - static int readMasterJournal(sqlite3_file pJrnl, byte[] zMaster, u32 nMaster) { - int rc; /* Return code */ - int len = 0; /* Length in bytes of master journal name */ - i64 szJ = 0; /* Total size in bytes of journal file pJrnl */ - u32 cksum = 0; /* MJ checksum value read from journal */ - int u; /* Unsigned loop counter */ - byte[] aMagic = new byte[8]; /* A buffer to hold the magic header */ - - zMaster[0] = 0; - - if (SQLITE_OK != (rc = sqlite3OsFileSize(pJrnl, ref szJ)) - || szJ < 16 - || SQLITE_OK != (rc = read32bits(pJrnl, (int)(szJ - 16), ref len)) - || len >= nMaster - || SQLITE_OK != (rc = read32bits(pJrnl, szJ - 12, ref cksum)) - || SQLITE_OK != (rc = sqlite3OsRead(pJrnl, aMagic, 8, szJ - 8)) - || memcmp(aMagic, aJournalMagic, 8) != 0 - || SQLITE_OK != (rc = sqlite3OsRead(pJrnl, zMaster, len, (long)(szJ - 16 - len))) - ) { - return rc; - } - - /* See if the checksum matches the master journal name */ - for (u = 0; u < len; u++) { - cksum -= zMaster[u]; - } - if (cksum != 0) { - /* If the checksum doesn't add up, then one or more of the disk sectors - ** containing the master journal filename is corrupted. This means - ** definitely roll back, so just return SQLITE_OK and report a (nul) - ** master-journal filename. - */ - len = 0; - } - if (len == 0) - zMaster[0] = 0; - - return SQLITE_OK; - } + /* +** When this is called the journal file for pager pPager must be open. +** This function attempts to read a master journal file name from the +** end of the file and, if successful, copies it into memory supplied +** by the caller. See comments above writeMasterJournal() for the format +** used to store a master journal file name at the end of a journal file. +** +** zMaster must point to a buffer of at least nMaster bytes allocated by +** the caller. This should be sqlite3_vfs.mxPathname+1 (to ensure there is +** enough space to write the master journal name). If the master journal +** name in the journal is longer than nMaster bytes (including a +** nul-terminator), then this is handled as if no master journal name +** were present in the journal. +** +** If a master journal file name is present at the end of the journal +** file, then it is copied into the buffer pointed to by zMaster. A +** nul-terminator byte is appended to the buffer following the master +** journal file name. +** +** If it is determined that no master journal file name is present +** zMaster[0] is set to 0 and SQLITE_OK returned. +** +** If an error occurs while reading from the journal file, an SQLite +** error code is returned. +*/ + static int readMasterJournal( sqlite3_file pJrnl, byte[] zMaster, u32 nMaster ) + { + int rc; /* Return code */ + int len = 0; /* Length in bytes of master journal name */ + i64 szJ = 0; /* Total size in bytes of journal file pJrnl */ + u32 cksum = 0; /* MJ checksum value read from journal */ + int u; /* Unsigned loop counter */ + byte[] aMagic = new byte[8]; /* A buffer to hold the magic header */ + + zMaster[0] = 0; + + if ( SQLITE_OK != ( rc = sqlite3OsFileSize( pJrnl, ref szJ ) ) + || szJ < 16 + || SQLITE_OK != ( rc = read32bits( pJrnl, (int)( szJ - 16 ), ref len ) ) + || len >= nMaster + || SQLITE_OK != ( rc = read32bits( pJrnl, szJ - 12, ref cksum ) ) + || SQLITE_OK != ( rc = sqlite3OsRead( pJrnl, aMagic, 8, szJ - 8 ) ) + || memcmp( aMagic, aJournalMagic, 8 ) != 0 + || SQLITE_OK != ( rc = sqlite3OsRead( pJrnl, zMaster, len, (long)( szJ - 16 - len ) ) ) + ) + { + return rc; + } - /* - ** Return the offset of the sector boundary at or immediately - ** following the value in pPager.journalOff, assuming a sector - ** size of pPager.sectorSize bytes. - ** - ** i.e for a sector size of 512: - ** - ** Pager.journalOff Return value - ** --------------------------------------- - ** 0 0 - ** 512 512 - ** 100 512 - ** 2000 2048 - ** + /* See if the checksum matches the master journal name */ + for ( u = 0; u < len; u++ ) + { + cksum -= zMaster[u]; + } + if ( cksum != 0 ) + { + /* If the checksum doesn't add up, then one or more of the disk sectors + ** containing the master journal filename is corrupted. This means + ** definitely roll back, so just return SQLITE_OK and report a (nul) + ** master-journal filename. */ - static i64 journalHdrOffset(Pager pPager) { - i64 offset = 0; - i64 c = pPager.journalOff; - if (c != 0) { - offset = (int)(((c - 1) / pPager.sectorSize + 1) * pPager.sectorSize);//offset = ((c-1)/JOURNAL_HDR_SZ(pPager) + 1) * JOURNAL_HDR_SZ(pPager); - } - Debug.Assert(offset % pPager.sectorSize == 0); //Debug.Assert(offset % JOURNAL_HDR_SZ(pPager) == 0); - Debug.Assert(offset >= c); - Debug.Assert((offset - c) < pPager.sectorSize);//Debug.Assert( (offset-c)= c ); + Debug.Assert( ( offset - c ) < pPager.sectorSize );//Debug.Assert( (offset-c) 0 ) + { + i64 sz = 0; + rc = sqlite3OsFileSize( pPager.jfd, ref sz ); + if ( rc == SQLITE_OK && sz > iLimit ) + { + rc = sqlite3OsTruncate( pPager.jfd, iLimit ); + } + } + } + return rc; + } - /* At this point the transaction is committed but the write lock - ** is still held on the file. If there is a size limit configured for - ** the persistent journal and the journal file currently consumes more - ** space than that limit allows for, truncate it now. There is no need - ** to sync the file following this operation. - */ - if (rc == SQLITE_OK && iLimit > 0) { - i64 sz = 0; - rc = sqlite3OsFileSize(pPager.jfd, ref sz); - if (rc == SQLITE_OK && sz > iLimit) { - rc = sqlite3OsTruncate(pPager.jfd, iLimit); - } - } - } - return rc; + /* + ** The journal file must be open when this routine is called. A journal + ** header (JOURNAL_HDR_SZ bytes) is written into the journal file at the + ** current location. + ** + ** The format for the journal header is as follows: + ** - 8 bytes: Magic identifying journal format. + ** - 4 bytes: Number of records in journal, or -1 no-sync mode is on. + ** - 4 bytes: Random number used for page hash. + ** - 4 bytes: Initial database page count. + ** - 4 bytes: Sector size used by the process that wrote this journal. + ** - 4 bytes: Database page size. + ** + ** Followed by (JOURNAL_HDR_SZ - 28) bytes of unused space. + */ + static int writeJournalHdr( Pager pPager ) + { + + int rc = SQLITE_OK; /* Return code */ + byte[] zHeader = pPager.pTmpSpace; /* Temporary space used to build header */ + u32 nHeader = (u32)pPager.pageSize; /* Size of buffer pointed to by zHeader */ + u32 nWrite; /* Bytes of header sector written */ + int ii; /* Loop counter */ + + Debug.Assert( isOpen( pPager.jfd ) ); /* Journal file must be open. */ + + if ( nHeader > JOURNAL_HDR_SZ( pPager ) ) + { + nHeader = JOURNAL_HDR_SZ( pPager ); + } + /* If there are active savepoints and any of them were created + ** since the most recent journal header was written, update the + ** PagerSavepoint.iHdrOffset fields now. + */ + for ( ii = 0; ii < pPager.nSavepoint; ii++ ) + { + if ( pPager.aSavepoint[ii].iHdrOffset == 0 ) + { + pPager.aSavepoint[ii].iHdrOffset = pPager.journalOff; } + } + pPager.journalHdr = pPager.journalOff = journalHdrOffset( pPager ); + + /* + ** Write the nRec Field - the number of page records that follow this + ** journal header. Normally, zero is written to this value at this time. + ** After the records are added to the journal (and the journal synced, + ** if in full-sync mode), the zero is overwritten with the true number + ** of records (see syncJournal()). + ** + ** A faster alternative is to write 0xFFFFFFFF to the nRec field. When + ** reading the journal this value tells SQLite to assume that the + ** rest of the journal file contains valid page records. This assumption + ** is dangerous, as if a failure occurred whilst writing to the journal + ** file it may contain some garbage data. There are two scenarios + ** where this risk can be ignored: + ** + ** * When the pager is in no-sync mode. Corruption can follow a + ** power failure in this case anyway. + ** + ** * When the SQLITE_IOCAP_SAFE_APPEND flag is set. This guarantees + ** that garbage data is never appended to the journal file. + */ + Debug.Assert( isOpen( pPager.fd ) || pPager.noSync ); + if ( pPager.noSync || ( pPager.journalMode == PAGER_JOURNALMODE_MEMORY ) + || ( sqlite3OsDeviceCharacteristics( pPager.fd ) & SQLITE_IOCAP_SAFE_APPEND ) != 0 + ) + { + aJournalMagic.CopyTo( zHeader, 0 );// memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic)); + put32bits( zHeader, aJournalMagic.Length, 0xffffffff ); + } + else + { + Array.Clear( zHeader, 0, aJournalMagic.Length + 4 );//memset(zHeader, 0, sizeof(aJournalMagic)+4); + } - /* - ** The journal file must be open when this routine is called. A journal - ** header (JOURNAL_HDR_SZ bytes) is written into the journal file at the - ** current location. - ** - ** The format for the journal header is as follows: - ** - 8 bytes: Magic identifying journal format. - ** - 4 bytes: Number of records in journal, or -1 no-sync mode is on. - ** - 4 bytes: Random number used for page hash. - ** - 4 bytes: Initial database page count. - ** - 4 bytes: Sector size used by the process that wrote this journal. - ** - 4 bytes: Database page size. - ** - ** Followed by (JOURNAL_HDR_SZ - 28) bytes of unused space. - */ - static int writeJournalHdr(Pager pPager) { + /* The random check-hash initialiser */ + i64 i64Temp = 0; + sqlite3_randomness( sizeof( i64 ), ref i64Temp ); + pPager.cksumInit = (u32)i64Temp; + put32bits( zHeader, aJournalMagic.Length + 4, pPager.cksumInit ); + /* The initial database size */ + put32bits( zHeader, aJournalMagic.Length + 8, pPager.dbOrigSize ); + /* The assumed sector size for this process */ + put32bits( zHeader, aJournalMagic.Length + 12, pPager.sectorSize ); + /* The page size */ + put32bits( zHeader, aJournalMagic.Length + 16, (u32)pPager.pageSize ); + + /* Initializing the tail of the buffer is not necessary. Everything + ** works find if the following memset() is omitted. But initializing + ** the memory prevents valgrind from complaining, so we are willing to + ** take the performance hit. + */ + // memset(&zHeader[sizeof(aJournalMagic)+20], 0, + // nHeader-(sizeof(aJournalMagic)+20)); + Array.Clear( zHeader, aJournalMagic.Length + 20, (int)nHeader - ( aJournalMagic.Length + 20 ) ); + + /* In theory, it is only necessary to write the 28 bytes that the + ** journal header consumes to the journal file here. Then increment the + ** Pager.journalOff variable by JOURNAL_HDR_SZ so that the next + ** record is written to the following sector (leaving a gap in the file + ** that will be implicitly filled in by the OS). + ** + ** However it has been discovered that on some systems this pattern can + ** be significantly slower than contiguously writing data to the file, + ** even if that means explicitly writing data to the block of + ** (JOURNAL_HDR_SZ - 28) bytes that will not be used. So that is what + ** is done. + ** + ** The loop is required here in case the sector-size is larger than the + ** database page size. Since the zHeader buffer is only Pager.pageSize + ** bytes in size, more than one call to sqlite3OsWrite() may be required + ** to populate the entire journal header sector. + */ + for ( nWrite = 0; rc == SQLITE_OK && nWrite < JOURNAL_HDR_SZ( pPager ); nWrite += nHeader ) + { + IOTRACE( "JHDR %p %lld %d\n", pPager, pPager.journalHdr, nHeader ); + rc = sqlite3OsWrite( pPager.jfd, zHeader, (int)nHeader, pPager.journalOff ); + Debug.Assert( pPager.journalHdr <= pPager.journalOff ); + pPager.journalOff += (int)nHeader; + } + return rc; + } - int rc = SQLITE_OK; /* Return code */ - byte[] zHeader = pPager.pTmpSpace; /* Temporary space used to build header */ - u32 nHeader = (u32)pPager.pageSize; /* Size of buffer pointed to by zHeader */ - u32 nWrite; /* Bytes of header sector written */ - int ii; /* Loop counter */ + /* + ** The journal file must be open when this is called. A journal header file + ** (JOURNAL_HDR_SZ bytes) is read from the current location in the journal + ** file. The current location in the journal file is given by + ** pPager.journalOff. See comments above function writeJournalHdr() for + ** a description of the journal header format. + ** + ** If the header is read successfully, *pNRec is set to the number of + ** page records following this header and *pDbSize is set to the size of the + ** database before the transaction began, in pages. Also, pPager.cksumInit + ** is set to the value read from the journal header. SQLITE_OK is returned + ** in this case. + ** + ** If the journal header file appears to be corrupted, SQLITE_DONE is + ** returned and *pNRec and *PDbSize are undefined. If JOURNAL_HDR_SZ bytes + ** cannot be read from the journal file an error code is returned. + */ + static int readJournalHdr( + Pager pPager, /* Pager object */ + int isHot, + i64 journalSize, /* Size of the open journal file in bytes */ + out u32 pNRec, /* OUT: Value read from the nRec field */ + out u32 pDbSize /* OUT: Value of original database size field */ + ) + { + int rc; /* Return code */ + byte[] aMagic = new byte[8]; /* A buffer to hold the magic header */ + i64 iHdrOff; /* Offset of journal header being read */ - Debug.Assert(isOpen(pPager.jfd)); /* Journal file must be open. */ + Debug.Assert( isOpen( pPager.jfd ) ); /* Journal file must be open. */ - if (nHeader > JOURNAL_HDR_SZ(pPager)) { - nHeader = JOURNAL_HDR_SZ(pPager); - } - /* If there are active savepoints and any of them were created - ** since the most recent journal header was written, update the - ** PagerSavepoint.iHdrOffset fields now. - */ - for (ii = 0; ii < pPager.nSavepoint; ii++) { - if (pPager.aSavepoint[ii].iHdrOffset == 0) { - pPager.aSavepoint[ii].iHdrOffset = pPager.journalOff; - } - } - pPager.journalHdr = pPager.journalOff = journalHdrOffset(pPager); - - /* - ** Write the nRec Field - the number of page records that follow this - ** journal header. Normally, zero is written to this value at this time. - ** After the records are added to the journal (and the journal synced, - ** if in full-sync mode), the zero is overwritten with the true number - ** of records (see syncJournal()). - ** - ** A faster alternative is to write 0xFFFFFFFF to the nRec field. When - ** reading the journal this value tells SQLite to assume that the - ** rest of the journal file contains valid page records. This assumption - ** is dangerous, as if a failure occurred whilst writing to the journal - ** file it may contain some garbage data. There are two scenarios - ** where this risk can be ignored: - ** - ** * When the pager is in no-sync mode. Corruption can follow a - ** power failure in this case anyway. - ** - ** * When the SQLITE_IOCAP_SAFE_APPEND flag is set. This guarantees - ** that garbage data is never appended to the journal file. - */ - Debug.Assert(isOpen(pPager.fd) || pPager.noSync); - if (pPager.noSync || (pPager.journalMode == PAGER_JOURNALMODE_MEMORY) - || (sqlite3OsDeviceCharacteristics(pPager.fd) & SQLITE_IOCAP_SAFE_APPEND) != 0 - ) { - aJournalMagic.CopyTo(zHeader, 0);// memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic)); - put32bits(zHeader, aJournalMagic.Length, 0xffffffff); - } else { - Array.Clear(zHeader, 0, aJournalMagic.Length + 4);//memset(zHeader, 0, sizeof(aJournalMagic)+4); - } + pNRec = 0; + pDbSize = 0; - /* The random check-hash initialiser */ - i64 i64Temp = 0; - sqlite3_randomness(sizeof(i64), ref i64Temp); - pPager.cksumInit = (u32)i64Temp; - put32bits(zHeader, aJournalMagic.Length + 4, pPager.cksumInit); - /* The initial database size */ - put32bits(zHeader, aJournalMagic.Length + 8, pPager.dbOrigSize); - /* The assumed sector size for this process */ - put32bits(zHeader, aJournalMagic.Length + 12, pPager.sectorSize); - /* The page size */ - put32bits(zHeader, aJournalMagic.Length + 16, (u32)pPager.pageSize); - - /* Initializing the tail of the buffer is not necessary. Everything - ** works find if the following memset() is omitted. But initializing - ** the memory prevents valgrind from complaining, so we are willing to - ** take the performance hit. - */ - // memset(&zHeader[sizeof(aJournalMagic)+20], 0, - // nHeader-(sizeof(aJournalMagic)+20)); - Array.Clear(zHeader, aJournalMagic.Length + 20, (int)nHeader - (aJournalMagic.Length + 20)); - - /* In theory, it is only necessary to write the 28 bytes that the - ** journal header consumes to the journal file here. Then increment the - ** Pager.journalOff variable by JOURNAL_HDR_SZ so that the next - ** record is written to the following sector (leaving a gap in the file - ** that will be implicitly filled in by the OS). - ** - ** However it has been discovered that on some systems this pattern can - ** be significantly slower than contiguously writing data to the file, - ** even if that means explicitly writing data to the block of - ** (JOURNAL_HDR_SZ - 28) bytes that will not be used. So that is what - ** is done. - ** - ** The loop is required here in case the sector-size is larger than the - ** database page size. Since the zHeader buffer is only Pager.pageSize - ** bytes in size, more than one call to sqlite3OsWrite() may be required - ** to populate the entire journal header sector. - */ - for (nWrite = 0; rc == SQLITE_OK && nWrite < JOURNAL_HDR_SZ(pPager); nWrite += nHeader) { - IOTRACE("JHDR %p %lld %d\n", pPager, pPager.journalHdr, nHeader); - rc = sqlite3OsWrite(pPager.jfd, zHeader, (int)nHeader, pPager.journalOff); - Debug.Assert(pPager.journalHdr <= pPager.journalOff); - pPager.journalOff += (int)nHeader; - } - return rc; + /* Advance Pager.journalOff to the start of the next sector. If the + ** journal file is too small for there to be a header stored at this + ** point, return SQLITE_DONE. + */ + pPager.journalOff = journalHdrOffset( pPager ); + if ( pPager.journalOff + JOURNAL_HDR_SZ( pPager ) > journalSize ) + { + return SQLITE_DONE; + } + iHdrOff = pPager.journalOff; + + /* Read in the first 8 bytes of the journal header. If they do not match + ** the magic string found at the start of each journal header, return + ** SQLITE_DONE. If an IO error occurs, return an error code. Otherwise, + ** proceed. + */ + if ( isHot != 0 || iHdrOff != pPager.journalHdr ) + { + rc = sqlite3OsRead( pPager.jfd, aMagic, aMagic.Length, iHdrOff ); + if ( rc != 0 ) + { + return rc; + } + if ( memcmp( aMagic, aJournalMagic, aMagic.Length ) != 0 ) + { + return SQLITE_DONE; + } + } + /* Read the first three 32-bit fields of the journal header: The nRec + ** field, the checksum-initializer and the database size at the start + ** of the transaction. Return an error code if anything goes wrong. + */ + if ( SQLITE_OK != ( rc = read32bits( pPager.jfd, iHdrOff + 8, ref pNRec ) ) + || SQLITE_OK != ( rc = read32bits( pPager.jfd, iHdrOff + 12, ref pPager.cksumInit ) ) + || SQLITE_OK != ( rc = read32bits( pPager.jfd, iHdrOff + 16, ref pDbSize ) ) + ) + { + return rc; + } + + if ( pPager.journalOff == 0 ) + { + u32 iPageSize = 0; /* Page-size field of journal header */ + u32 iSectorSize = 0; /* Sector-size field of journal header */ + + /* Read the page-size and sector-size journal header fields. */ + if ( SQLITE_OK != ( rc = read32bits( pPager.jfd, iHdrOff + 20, ref iSectorSize ) ) + || SQLITE_OK != ( rc = read32bits( pPager.jfd, iHdrOff + 24, ref iPageSize ) ) + ) + { + return rc; } - /* - ** The journal file must be open when this is called. A journal header file - ** (JOURNAL_HDR_SZ bytes) is read from the current location in the journal - ** file. The current location in the journal file is given by - ** pPager.journalOff. See comments above function writeJournalHdr() for - ** a description of the journal header format. - ** - ** If the header is read successfully, *pNRec is set to the number of - ** page records following this header and *pDbSize is set to the size of the - ** database before the transaction began, in pages. Also, pPager.cksumInit - ** is set to the value read from the journal header. SQLITE_OK is returned - ** in this case. - ** - ** If the journal header file appears to be corrupted, SQLITE_DONE is - ** returned and *pNRec and *PDbSize are undefined. If JOURNAL_HDR_SZ bytes - ** cannot be read from the journal file an error code is returned. + /* Versions of SQLite prior to 3.5.8 set the page-size field of the + ** journal header to zero. In this case, assume that the Pager.pageSize + ** variable is already set to the correct page size. */ - static int readJournalHdr( - Pager pPager, /* Pager object */ - int isHot, - i64 journalSize, /* Size of the open journal file in bytes */ - out u32 pNRec, /* OUT: Value read from the nRec field */ - out u32 pDbSize /* OUT: Value of original database size field */ - ) { - int rc; /* Return code */ - byte[] aMagic = new byte[8]; /* A buffer to hold the magic header */ - i64 iHdrOff; /* Offset of journal header being read */ - - Debug.Assert(isOpen(pPager.jfd)); /* Journal file must be open. */ - - pNRec = 0; - pDbSize = 0; - - /* Advance Pager.journalOff to the start of the next sector. If the - ** journal file is too small for there to be a header stored at this - ** point, return SQLITE_DONE. - */ - pPager.journalOff = journalHdrOffset(pPager); - if (pPager.journalOff + JOURNAL_HDR_SZ(pPager) > journalSize) { - return SQLITE_DONE; - } - iHdrOff = pPager.journalOff; + if ( iPageSize == 0 ) + { + iPageSize = (u32)pPager.pageSize; + } - /* Read in the first 8 bytes of the journal header. If they do not match - ** the magic string found at the start of each journal header, return - ** SQLITE_DONE. If an IO error occurs, return an error code. Otherwise, - ** proceed. - */ - if (isHot != 0 || iHdrOff != pPager.journalHdr) { - rc = sqlite3OsRead(pPager.jfd, aMagic, aMagic.Length, iHdrOff); - if (rc != 0) { - return rc; - } - if (memcmp(aMagic, aJournalMagic, aMagic.Length) != 0) { - return SQLITE_DONE; - } - } - /* Read the first three 32-bit fields of the journal header: The nRec - ** field, the checksum-initializer and the database size at the start - ** of the transaction. Return an error code if anything goes wrong. - */ - if (SQLITE_OK != (rc = read32bits(pPager.jfd, iHdrOff + 8, ref pNRec)) - || SQLITE_OK != (rc = read32bits(pPager.jfd, iHdrOff + 12, ref pPager.cksumInit)) - || SQLITE_OK != (rc = read32bits(pPager.jfd, iHdrOff + 16, ref pDbSize)) - ) { - return rc; - } + /* Check that the values read from the page-size and sector-size fields + ** are within range. To be 'in range', both values need to be a power + ** of two greater than or equal to 512 or 32, and not greater than their + ** respective compile time maximum limits. + */ + if ( iPageSize < 512 || iSectorSize < 32 + || iPageSize > SQLITE_MAX_PAGE_SIZE || iSectorSize > MAX_SECTOR_SIZE + || ( ( iPageSize - 1 ) & iPageSize ) != 0 || ( ( iSectorSize - 1 ) & iSectorSize ) != 0 + ) + { + /* If the either the page-size or sector-size in the journal-header is + ** invalid, then the process that wrote the journal-header must have + ** crashed before the header was synced. In this case stop reading + ** the journal file here. + */ + return SQLITE_DONE; + } - if (pPager.journalOff == 0) { - u32 iPageSize = 0; /* Page-size field of journal header */ - u32 iSectorSize = 0; /* Sector-size field of journal header */ + /* Update the page-size to match the value read from the journal. + ** Use a testcase() macro to make sure that malloc failure within + ** PagerSetPagesize() is tested. + */ + rc = sqlite3PagerSetPagesize( pPager, ref iPageSize, -1 ); + testcase( rc != SQLITE_OK ); + + /* Update the assumed sector-size to match the value used by + ** the process that created this journal. If this journal was + ** created by a process other than this one, then this routine + ** is being called from within pager_playback(). The local value + ** of Pager.sectorSize is restored at the end of that routine. + */ + pPager.sectorSize = iSectorSize; + } - /* Read the page-size and sector-size journal header fields. */ - if (SQLITE_OK != (rc = read32bits(pPager.jfd, iHdrOff + 20, ref iSectorSize)) - || SQLITE_OK != (rc = read32bits(pPager.jfd, iHdrOff + 24, ref iPageSize)) - ) { - return rc; - } + pPager.journalOff += (int)JOURNAL_HDR_SZ( pPager ); + return rc; + } - /* Versions of SQLite prior to 3.5.8 set the page-size field of the - ** journal header to zero. In this case, assume that the Pager.pageSize - ** variable is already set to the correct page size. - */ - if (iPageSize == 0) { - iPageSize = (u32)pPager.pageSize; - } + /* + ** Write the supplied master journal name into the journal file for pager + ** pPager at the current location. The master journal name must be the last + ** thing written to a journal file. If the pager is in full-sync mode, the + ** journal file descriptor is advanced to the next sector boundary before + ** anything is written. The format is: + ** + ** + 4 bytes: PAGER_MJ_PGNO. + ** + N bytes: Master journal filename in utf-8. + ** + 4 bytes: N (length of master journal name in bytes, no nul-terminator). + ** + 4 bytes: Master journal name checksum. + ** + 8 bytes: aJournalMagic[]. + ** + ** The master journal page checksum is the sum of the bytes in the master + ** journal name, where each byte is interpreted as a signed 8-bit integer. + ** + ** If zMaster is a NULL pointer (occurs for a single database transaction), + ** this call is a no-op. + */ + static int writeMasterJournal( Pager pPager, string zMaster ) + { + int rc; /* Return code */ + int nMaster; /* Length of string zMaster */ + i64 iHdrOff; /* Offset of header in journal file */ + i64 jrnlSize = 0; /* Size of journal file on disk */ + u32 cksum = 0; /* Checksum of string zMaster */ + + Debug.Assert( pPager.setMaster == 0 ); + Debug.Assert( !pagerUseWal( pPager ) ); + if ( null == zMaster + || pPager.journalMode == PAGER_JOURNALMODE_MEMORY + || pPager.journalMode == PAGER_JOURNALMODE_OFF + ) + { + return SQLITE_OK; + } - /* Check that the values read from the page-size and sector-size fields - ** are within range. To be 'in range', both values need to be a power - ** of two greater than or equal to 512 or 32, and not greater than their - ** respective compile time maximum limits. - */ - if (iPageSize < 512 || iSectorSize < 32 - || iPageSize > SQLITE_MAX_PAGE_SIZE || iSectorSize > MAX_SECTOR_SIZE - || ((iPageSize - 1) & iPageSize) != 0 || ((iSectorSize - 1) & iSectorSize) != 0 - ) { - /* If the either the page-size or sector-size in the journal-header is - ** invalid, then the process that wrote the journal-header must have - ** crashed before the header was synced. In this case stop reading - ** the journal file here. - */ - return SQLITE_DONE; - } + pPager.setMaster = 1; + Debug.Assert( isOpen( pPager.jfd ) ); + Debug.Assert( pPager.journalHdr <= pPager.journalOff ); - /* Update the page-size to match the value read from the journal. - ** Use a testcase() macro to make sure that malloc failure within - ** PagerSetPagesize() is tested. - */ - rc = sqlite3PagerSetPagesize(pPager, ref iPageSize, -1); - testcase(rc != SQLITE_OK); - - /* Update the assumed sector-size to match the value used by - ** the process that created this journal. If this journal was - ** created by a process other than this one, then this routine - ** is being called from within pager_playback(). The local value - ** of Pager.sectorSize is restored at the end of that routine. - */ - pPager.sectorSize = iSectorSize; - } + /* Calculate the length in bytes and the checksum of zMaster */ + for ( nMaster = 0; nMaster < zMaster.Length && zMaster[nMaster] != 0; nMaster++ ) + { + cksum += zMaster[nMaster]; + } - pPager.journalOff += (int)JOURNAL_HDR_SZ(pPager); - return rc; - } + /* If in full-sync mode, advance to the next disk sector before writing + ** the master journal name. This is in case the previous page written to + ** the journal has already been synced. + */ + if ( pPager.fullSync ) + { + pPager.journalOff = journalHdrOffset( pPager ); + } + iHdrOff = pPager.journalOff; + /* Write the master journal data to the end of the journal file. If + ** an error occurs, return the error code to the caller. + */ + if ( ( 0 != ( rc = write32bits( pPager.jfd, iHdrOff, (u32)PAGER_MJ_PGNO( pPager ) ) ) ) + || ( 0 != ( rc = sqlite3OsWrite( pPager.jfd, Encoding.UTF8.GetBytes( zMaster ), nMaster, iHdrOff + 4 ) ) ) + || ( 0 != ( rc = write32bits( pPager.jfd, iHdrOff + 4 + nMaster, (u32)nMaster ) ) ) + || ( 0 != ( rc = write32bits( pPager.jfd, iHdrOff + 4 + nMaster + 4, cksum ) ) ) + || ( 0 != ( rc = sqlite3OsWrite( pPager.jfd, aJournalMagic, 8, iHdrOff + 4 + nMaster + 8 ) ) ) + ) + { + return rc; + } + pPager.journalOff += ( nMaster + 20 ); + + /* If the pager is in peristent-journal mode, then the physical + ** journal-file may extend past the end of the master-journal name + ** and 8 bytes of magic data just written to the file. This is + ** dangerous because the code to rollback a hot-journal file + ** will not be able to find the master-journal name to determine + ** whether or not the journal is hot. + ** + ** Easiest thing to do in this scenario is to truncate the journal + ** file to the required size. + */ + if ( SQLITE_OK == ( rc = sqlite3OsFileSize( pPager.jfd, ref jrnlSize ) ) + && jrnlSize > pPager.journalOff + ) + { + rc = sqlite3OsTruncate( pPager.jfd, pPager.journalOff ); + } - /* - ** Write the supplied master journal name into the journal file for pager - ** pPager at the current location. The master journal name must be the last - ** thing written to a journal file. If the pager is in full-sync mode, the - ** journal file descriptor is advanced to the next sector boundary before - ** anything is written. The format is: - ** - ** + 4 bytes: PAGER_MJ_PGNO. - ** + N bytes: Master journal filename in utf-8. - ** + 4 bytes: N (length of master journal name in bytes, no nul-terminator). - ** + 4 bytes: Master journal name checksum. - ** + 8 bytes: aJournalMagic[]. - ** - ** The master journal page checksum is the sum of the bytes in the master - ** journal name, where each byte is interpreted as a signed 8-bit integer. - ** - ** If zMaster is a NULL pointer (occurs for a single database transaction), - ** this call is a no-op. - */ - static int writeMasterJournal(Pager pPager, string zMaster) { - int rc; /* Return code */ - int nMaster; /* Length of string zMaster */ - i64 iHdrOff; /* Offset of header in journal file */ - i64 jrnlSize = 0; /* Size of journal file on disk */ - u32 cksum = 0; /* Checksum of string zMaster */ - - Debug.Assert(pPager.setMaster == 0); - Debug.Assert(!pagerUseWal(pPager)); - if (null == zMaster - || pPager.journalMode == PAGER_JOURNALMODE_MEMORY - || pPager.journalMode == PAGER_JOURNALMODE_OFF - ) { - return SQLITE_OK; - } + return rc; + } - pPager.setMaster = 1; - Debug.Assert(isOpen(pPager.jfd)); - Debug.Assert(pPager.journalHdr <= pPager.journalOff); + /* + ** Find a page in the hash table given its page number. Return + ** a pointer to the page or NULL if the requested page is not + ** already in memory. + */ + static PgHdr pager_lookup( Pager pPager, u32 pgno ) + { + PgHdr p = null; /* Return value */ + /* It is not possible for a call to PcacheFetch() with createFlag==0 to + ** fail, since no attempt to allocate dynamic memory will be made. + */ + sqlite3PcacheFetch( pPager.pPCache, pgno, 0, ref p ); + return p; + } - /* Calculate the length in bytes and the checksum of zMaster */ - for (nMaster = 0; nMaster < zMaster.Length && zMaster[nMaster] != 0; nMaster++) { - cksum += zMaster[nMaster]; - } + /* + ** Discard the entire contents of the in-memory page-cache. + */ + static void pager_reset( Pager pPager ) + { + sqlite3BackupRestart( pPager.pBackup ); + sqlite3PcacheClear( pPager.pPCache ); + } - /* If in full-sync mode, advance to the next disk sector before writing - ** the master journal name. This is in case the previous page written to - ** the journal has already been synced. - */ - if (pPager.fullSync) { - pPager.journalOff = journalHdrOffset(pPager); - } - iHdrOff = pPager.journalOff; - /* Write the master journal data to the end of the journal file. If - ** an error occurs, return the error code to the caller. - */ - if ((0 != (rc = write32bits(pPager.jfd, iHdrOff, (u32)PAGER_MJ_PGNO(pPager)))) - || (0 != (rc = sqlite3OsWrite(pPager.jfd, Encoding.UTF8.GetBytes(zMaster), nMaster, iHdrOff + 4))) - || (0 != (rc = write32bits(pPager.jfd, iHdrOff + 4 + nMaster, (u32)nMaster))) - || (0 != (rc = write32bits(pPager.jfd, iHdrOff + 4 + nMaster + 4, cksum))) - || (0 != (rc = sqlite3OsWrite(pPager.jfd, aJournalMagic, 8, iHdrOff + 4 + nMaster + 8))) - ) { - return rc; - } - pPager.journalOff += (nMaster + 20); - - /* If the pager is in peristent-journal mode, then the physical - ** journal-file may extend past the end of the master-journal name - ** and 8 bytes of magic data just written to the file. This is - ** dangerous because the code to rollback a hot-journal file - ** will not be able to find the master-journal name to determine - ** whether or not the journal is hot. - ** - ** Easiest thing to do in this scenario is to truncate the journal - ** file to the required size. - */ - if (SQLITE_OK == (rc = sqlite3OsFileSize(pPager.jfd, ref jrnlSize)) - && jrnlSize > pPager.journalOff - ) { - rc = sqlite3OsTruncate(pPager.jfd, pPager.journalOff); - } + /* + ** Free all structures in the Pager.aSavepoint[] array and set both + ** Pager.aSavepoint and Pager.nSavepoint to zero. Close the sub-journal + ** if it is open and the pager is not in exclusive mode. + */ + static void releaseAllSavepoints( Pager pPager ) + { + int ii; /* Iterator for looping through Pager.aSavepoint */ + for ( ii = 0; ii < pPager.nSavepoint; ii++ ) + { + sqlite3BitvecDestroy( ref pPager.aSavepoint[ii].pInSavepoint ); + } + if ( !pPager.exclusiveMode || sqlite3IsMemJournal( pPager.sjfd ) ) + { + sqlite3OsClose( pPager.sjfd ); + } + //sqlite3_free( ref pPager.aSavepoint ); + pPager.aSavepoint = null; + pPager.nSavepoint = 0; + pPager.nSubRec = 0; + } - return rc; - } + /* + ** Set the bit number pgno in the PagerSavepoint.pInSavepoint + ** bitvecs of all open savepoints. Return SQLITE_OK if successful + ** or SQLITE_NOMEM if a malloc failure occurs. + */ + static int addToSavepointBitvecs( Pager pPager, u32 pgno ) + { + int ii; /* Loop counter */ + int rc = SQLITE_OK; /* Result code */ - /* - ** Find a page in the hash table given its page number. Return - ** a pointer to the page or NULL if the requested page is not - ** already in memory. - */ - static PgHdr pager_lookup(Pager pPager, u32 pgno) { - PgHdr p = null; /* Return value */ - /* It is not possible for a call to PcacheFetch() with createFlag==0 to - ** fail, since no attempt to allocate dynamic memory will be made. - */ - sqlite3PcacheFetch(pPager.pPCache, pgno, 0, ref p); - return p; + for ( ii = 0; ii < pPager.nSavepoint; ii++ ) + { + PagerSavepoint p = pPager.aSavepoint[ii]; + if ( pgno <= p.nOrig ) + { + rc |= sqlite3BitvecSet( p.pInSavepoint, pgno ); + testcase( rc == SQLITE_NOMEM ); + Debug.Assert( rc == SQLITE_OK || rc == SQLITE_NOMEM ); } + } + return rc; + } - /* - ** Discard the entire contents of the in-memory page-cache. - */ - static void pager_reset(Pager pPager) { - sqlite3BackupRestart(pPager.pBackup); - sqlite3PcacheClear(pPager.pPCache); - } + /* + ** This function is a no-op if the pager is in exclusive mode and not + ** in the ERROR state. Otherwise, it switches the pager to PAGER_OPEN + ** state. + ** + ** If the pager is not in exclusive-access mode, the database file is + ** completely unlocked. If the file is unlocked and the file-system does + ** not exhibit the UNDELETABLE_WHEN_OPEN property, the journal file is + ** closed (if it is open). + ** + ** If the pager is in ERROR state when this function is called, the + ** contents of the pager cache are discarded before switching back to + ** the OPEN state. Regardless of whether the pager is in exclusive-mode + ** or not, any journal file left in the file-system will be treated + ** as a hot-journal and rolled back the next time a read-transaction + ** is opened (by this or by any other connection). + */ + static void pager_unlock( Pager pPager ) + { - /* - ** Free all structures in the Pager.aSavepoint[] array and set both - ** Pager.aSavepoint and Pager.nSavepoint to zero. Close the sub-journal - ** if it is open and the pager is not in exclusive mode. + Debug.Assert( pPager.eState == PAGER_READER + || pPager.eState == PAGER_OPEN + || pPager.eState == PAGER_ERROR + ); + + sqlite3BitvecDestroy( ref pPager.pInJournal ); + pPager.pInJournal = null; + releaseAllSavepoints( pPager ); + + if ( pagerUseWal( pPager ) ) + { + Debug.Assert( !isOpen( pPager.jfd ) ); + sqlite3WalEndReadTransaction( pPager.pWal ); + pPager.eState = PAGER_OPEN; + } + else if ( !pPager.exclusiveMode ) + { + int rc; /* Error code returned by pagerUnlockDb() */ + int iDc = isOpen( pPager.fd ) ? sqlite3OsDeviceCharacteristics( pPager.fd ) : 0; + + /* If the operating system support deletion of open files, then + ** close the journal file when dropping the database lock. Otherwise + ** another connection with journal_mode=delete might delete the file + ** out from under us. */ - static void releaseAllSavepoints(Pager pPager) { - int ii; /* Iterator for looping through Pager.aSavepoint */ - for (ii = 0; ii < pPager.nSavepoint; ii++) { - sqlite3BitvecDestroy(ref pPager.aSavepoint[ii].pInSavepoint); - } - if (!pPager.exclusiveMode || sqlite3IsMemJournal(pPager.sjfd)) { - sqlite3OsClose(pPager.sjfd); - } - //sqlite3_free( ref pPager.aSavepoint ); - pPager.aSavepoint = null; - pPager.nSavepoint = 0; - pPager.nSubRec = 0; + Debug.Assert( ( PAGER_JOURNALMODE_MEMORY & 5 ) != 1 ); + Debug.Assert( ( PAGER_JOURNALMODE_OFF & 5 ) != 1 ); + Debug.Assert( ( PAGER_JOURNALMODE_WAL & 5 ) != 1 ); + Debug.Assert( ( PAGER_JOURNALMODE_DELETE & 5 ) != 1 ); + Debug.Assert( ( PAGER_JOURNALMODE_TRUNCATE & 5 ) == 1 ); + Debug.Assert( ( PAGER_JOURNALMODE_PERSIST & 5 ) == 1 ); + if ( 0 == ( iDc & SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN ) + || 1 != ( pPager.journalMode & 5 ) + ) + { + sqlite3OsClose( pPager.jfd ); } - /* - ** Set the bit number pgno in the PagerSavepoint.pInSavepoint - ** bitvecs of all open savepoints. Return SQLITE_OK if successful - ** or SQLITE_NOMEM if a malloc failure occurs. + + /* If the pager is in the ERROR state and the call to unlock the database + ** file fails, set the current lock to UNKNOWN_LOCK. See the comment + ** above the #define for UNKNOWN_LOCK for an explanation of why this + ** is necessary. */ - static int addToSavepointBitvecs(Pager pPager, u32 pgno) { - int ii; /* Loop counter */ - int rc = SQLITE_OK; /* Result code */ - - for (ii = 0; ii < pPager.nSavepoint; ii++) { - PagerSavepoint p = pPager.aSavepoint[ii]; - if (pgno <= p.nOrig) { - rc |= sqlite3BitvecSet(p.pInSavepoint, pgno); - testcase(rc == SQLITE_NOMEM); - Debug.Assert(rc == SQLITE_OK || rc == SQLITE_NOMEM); - } - } - return rc; + rc = pagerUnlockDb( pPager, NO_LOCK ); + if ( rc != SQLITE_OK && pPager.eState == PAGER_ERROR ) + { + pPager.eLock = UNKNOWN_LOCK; } - /* - ** This function is a no-op if the pager is in exclusive mode and not - ** in the ERROR state. Otherwise, it switches the pager to PAGER_OPEN - ** state. - ** - ** If the pager is not in exclusive-access mode, the database file is - ** completely unlocked. If the file is unlocked and the file-system does - ** not exhibit the UNDELETABLE_WHEN_OPEN property, the journal file is - ** closed (if it is open). - ** - ** If the pager is in ERROR state when this function is called, the - ** contents of the pager cache are discarded before switching back to - ** the OPEN state. Regardless of whether the pager is in exclusive-mode - ** or not, any journal file left in the file-system will be treated - ** as a hot-journal and rolled back the next time a read-transaction - ** is opened (by this or by any other connection). + /* The pager state may be changed from PAGER_ERROR to PAGER_OPEN here + ** without clearing the error code. This is intentional - the error + ** code is cleared and the cache reset in the block below. */ - static void pager_unlock(Pager pPager) { - - Debug.Assert(pPager.eState == PAGER_READER - || pPager.eState == PAGER_OPEN - || pPager.eState == PAGER_ERROR - ); - - sqlite3BitvecDestroy(ref pPager.pInJournal); - pPager.pInJournal = null; - releaseAllSavepoints(pPager); - - if (pagerUseWal(pPager)) { - Debug.Assert(!isOpen(pPager.jfd)); - sqlite3WalEndReadTransaction(pPager.pWal); - pPager.eState = PAGER_OPEN; - } else if (!pPager.exclusiveMode) { - int rc; /* Error code returned by pagerUnlockDb() */ - int iDc = isOpen(pPager.fd) ? sqlite3OsDeviceCharacteristics(pPager.fd) : 0; - - /* If the operating system support deletion of open files, then - ** close the journal file when dropping the database lock. Otherwise - ** another connection with journal_mode=delete might delete the file - ** out from under us. - */ - Debug.Assert((PAGER_JOURNALMODE_MEMORY & 5) != 1); - Debug.Assert((PAGER_JOURNALMODE_OFF & 5) != 1); - Debug.Assert((PAGER_JOURNALMODE_WAL & 5) != 1); - Debug.Assert((PAGER_JOURNALMODE_DELETE & 5) != 1); - Debug.Assert((PAGER_JOURNALMODE_TRUNCATE & 5) == 1); - Debug.Assert((PAGER_JOURNALMODE_PERSIST & 5) == 1); - if (0 == (iDc & SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN) - || 1 != (pPager.journalMode & 5) - ) { - sqlite3OsClose(pPager.jfd); - } - - - /* If the pager is in the ERROR state and the call to unlock the database - ** file fails, set the current lock to UNKNOWN_LOCK. See the comment - ** above the #define for UNKNOWN_LOCK for an explanation of why this - ** is necessary. - */ - rc = pagerUnlockDb(pPager, NO_LOCK); - if (rc != SQLITE_OK && pPager.eState == PAGER_ERROR) { - pPager.eLock = UNKNOWN_LOCK; - } - - /* The pager state may be changed from PAGER_ERROR to PAGER_OPEN here - ** without clearing the error code. This is intentional - the error - ** code is cleared and the cache reset in the block below. - */ - Debug.Assert(pPager.errCode != 0 || pPager.eState != PAGER_ERROR); - pPager.changeCountDone = false; - pPager.eState = PAGER_OPEN; - } + Debug.Assert( pPager.errCode != 0 || pPager.eState != PAGER_ERROR ); + pPager.changeCountDone = false; + pPager.eState = PAGER_OPEN; + } - /* If Pager.errCode is set, the contents of the pager cache cannot be - ** trusted. Now that there are no outstanding references to the pager, - ** it can safely move back to PAGER_OPEN state. This happens in both - ** normal and exclusive-locking mode. - */ - if (pPager.errCode != 0) { - Debug.Assert( + /* If Pager.errCode is set, the contents of the pager cache cannot be + ** trusted. Now that there are no outstanding references to the pager, + ** it can safely move back to PAGER_OPEN state. This happens in both + ** normal and exclusive-locking mode. + */ + if ( pPager.errCode != 0 ) + { + Debug.Assert( #if SQLITE_OMIT_MEMORYDB 0==MEMDB #else - 0 == pPager.memDb + 0 == pPager.memDb #endif - ); - pager_reset(pPager); - pPager.changeCountDone = pPager.tempFile; - pPager.eState = PAGER_OPEN; - pPager.errCode = SQLITE_OK; - } + ); + pager_reset( pPager ); + pPager.changeCountDone = pPager.tempFile; + pPager.eState = PAGER_OPEN; + pPager.errCode = SQLITE_OK; + } - pPager.journalOff = 0; - pPager.journalHdr = 0; - pPager.setMaster = 0; - } + pPager.journalOff = 0; + pPager.journalHdr = 0; + pPager.setMaster = 0; + } - /* - ** This function is called whenever an IOERR or FULL error that requires - ** the pager to transition into the ERROR state may ahve occurred. - ** The first argument is a pointer to the pager structure, the second - ** the error-code about to be returned by a pager API function. The - ** value returned is a copy of the second argument to this function. - ** - ** If the second argument is SQLITE_FULL, SQLITE_IOERR or one of the - ** IOERR sub-codes, the pager enters the ERROR state and the error code - ** is stored in Pager.errCode. While the pager remains in the ERROR state, - ** all major API calls on the Pager will immediately return Pager.errCode. - ** - ** The ERROR state indicates that the contents of the pager-cache - ** cannot be trusted. This state can be cleared by completely discarding - ** the contents of the pager-cache. If a transaction was active when - ** the persistent error occurred, then the rollback journal may need - ** to be replayed to restore the contents of the database file (as if - ** it were a hot-journal). - */ - static int pager_error(Pager pPager, int rc) { - int rc2 = rc & 0xff; - Debug.Assert(rc == SQLITE_OK || + /* + ** This function is called whenever an IOERR or FULL error that requires + ** the pager to transition into the ERROR state may ahve occurred. + ** The first argument is a pointer to the pager structure, the second + ** the error-code about to be returned by a pager API function. The + ** value returned is a copy of the second argument to this function. + ** + ** If the second argument is SQLITE_FULL, SQLITE_IOERR or one of the + ** IOERR sub-codes, the pager enters the ERROR state and the error code + ** is stored in Pager.errCode. While the pager remains in the ERROR state, + ** all major API calls on the Pager will immediately return Pager.errCode. + ** + ** The ERROR state indicates that the contents of the pager-cache + ** cannot be trusted. This state can be cleared by completely discarding + ** the contents of the pager-cache. If a transaction was active when + ** the persistent error occurred, then the rollback journal may need + ** to be replayed to restore the contents of the database file (as if + ** it were a hot-journal). + */ + static int pager_error( Pager pPager, int rc ) + { + int rc2 = rc & 0xff; + Debug.Assert( rc == SQLITE_OK || #if SQLITE_OMIT_MEMORYDB 0==MEMDB #else - 0 == pPager.memDb + 0 == pPager.memDb #endif - ); - Debug.Assert( - pPager.errCode == SQLITE_FULL || - pPager.errCode == SQLITE_OK || - (pPager.errCode & 0xff) == SQLITE_IOERR - ); - if ( - rc2 == SQLITE_FULL || rc2 == SQLITE_IOERR) { - pPager.errCode = rc; - pPager.eState = PAGER_ERROR; - } - return rc; - } + ); + Debug.Assert( + pPager.errCode == SQLITE_FULL || + pPager.errCode == SQLITE_OK || + ( pPager.errCode & 0xff ) == SQLITE_IOERR + ); + if ( + rc2 == SQLITE_FULL || rc2 == SQLITE_IOERR ) + { + pPager.errCode = rc; + pPager.eState = PAGER_ERROR; + } + return rc; + } - /* - ** This routine ends a transaction. A transaction is usually ended by - ** either a COMMIT or a ROLLBACK operation. This routine may be called - ** after rollback of a hot-journal, or if an error occurs while opening - ** the journal file or writing the very first journal-header of a - ** database transaction. - ** - ** This routine is never called in PAGER_ERROR state. If it is called - ** in PAGER_NONE or PAGER_SHARED state and the lock held is less - ** exclusive than a RESERVED lock, it is a no-op. - ** - ** Otherwise, any active savepoints are released. - ** - ** If the journal file is open, then it is "finalized". Once a journal - ** file has been finalized it is not possible to use it to roll back a - ** transaction. Nor will it be considered to be a hot-journal by this - ** or any other database connection. Exactly how a journal is finalized - ** depends on whether or not the pager is running in exclusive mode and - ** the current journal-mode (Pager.journalMode value), as follows: - ** - ** journalMode==MEMORY - ** Journal file descriptor is simply closed. This destroys an - ** in-memory journal. - ** - ** journalMode==TRUNCATE - ** Journal file is truncated to zero bytes in size. - ** - ** journalMode==PERSIST - ** The first 28 bytes of the journal file are zeroed. This invalidates - ** the first journal header in the file, and hence the entire journal - ** file. An invalid journal file cannot be rolled back. - ** - ** journalMode==DELETE - ** The journal file is closed and deleted using sqlite3OsDelete(). - ** - ** If the pager is running in exclusive mode, this method of finalizing - ** the journal file is never used. Instead, if the journalMode is - ** DELETE and the pager is in exclusive mode, the method described under - ** journalMode==PERSIST is used instead. - ** - ** After the journal is finalized, the pager moves to PAGER_READER state. - ** If running in non-exclusive rollback mode, the lock on the file is - ** downgraded to a SHARED_LOCK. - ** - ** SQLITE_OK is returned if no error occurs. If an error occurs during - ** any of the IO operations to finalize the journal file or unlock the - ** database then the IO error code is returned to the user. If the - ** operation to finalize the journal file fails, then the code still - ** tries to unlock the database file if not in exclusive mode. If the - ** unlock operation fails as well, then the first error code related - ** to the first error encountered (the journal finalization one) is - ** returned. - */ - static int pager_end_transaction(Pager pPager, int hasMaster) { - int rc = SQLITE_OK; /* Error code from journal finalization operation */ - int rc2 = SQLITE_OK; /* Error code from db file unlock operation */ - /* Do nothing if the pager does not have an open write transaction - ** or at least a RESERVED lock. This function may be called when there - ** is no write-transaction active but a RESERVED or greater lock is - ** held under two circumstances: - ** - ** 1. After a successful hot-journal rollback, it is called with - ** eState==PAGER_NONE and eLock==EXCLUSIVE_LOCK. - ** - ** 2. If a connection with locking_mode=exclusive holding an EXCLUSIVE - ** lock switches back to locking_mode=normal and then executes a - ** read-transaction, this function is called with eState==PAGER_READER - ** and eLock==EXCLUSIVE_LOCK when the read-transaction is closed. - */ - Debug.Assert(assert_pager_state(pPager)); - Debug.Assert(pPager.eState != PAGER_ERROR); - if (pPager.eState < PAGER_WRITER_LOCKED && pPager.eLock < RESERVED_LOCK) { - return SQLITE_OK; - } + /* + ** This routine ends a transaction. A transaction is usually ended by + ** either a COMMIT or a ROLLBACK operation. This routine may be called + ** after rollback of a hot-journal, or if an error occurs while opening + ** the journal file or writing the very first journal-header of a + ** database transaction. + ** + ** This routine is never called in PAGER_ERROR state. If it is called + ** in PAGER_NONE or PAGER_SHARED state and the lock held is less + ** exclusive than a RESERVED lock, it is a no-op. + ** + ** Otherwise, any active savepoints are released. + ** + ** If the journal file is open, then it is "finalized". Once a journal + ** file has been finalized it is not possible to use it to roll back a + ** transaction. Nor will it be considered to be a hot-journal by this + ** or any other database connection. Exactly how a journal is finalized + ** depends on whether or not the pager is running in exclusive mode and + ** the current journal-mode (Pager.journalMode value), as follows: + ** + ** journalMode==MEMORY + ** Journal file descriptor is simply closed. This destroys an + ** in-memory journal. + ** + ** journalMode==TRUNCATE + ** Journal file is truncated to zero bytes in size. + ** + ** journalMode==PERSIST + ** The first 28 bytes of the journal file are zeroed. This invalidates + ** the first journal header in the file, and hence the entire journal + ** file. An invalid journal file cannot be rolled back. + ** + ** journalMode==DELETE + ** The journal file is closed and deleted using sqlite3OsDelete(). + ** + ** If the pager is running in exclusive mode, this method of finalizing + ** the journal file is never used. Instead, if the journalMode is + ** DELETE and the pager is in exclusive mode, the method described under + ** journalMode==PERSIST is used instead. + ** + ** After the journal is finalized, the pager moves to PAGER_READER state. + ** If running in non-exclusive rollback mode, the lock on the file is + ** downgraded to a SHARED_LOCK. + ** + ** SQLITE_OK is returned if no error occurs. If an error occurs during + ** any of the IO operations to finalize the journal file or unlock the + ** database then the IO error code is returned to the user. If the + ** operation to finalize the journal file fails, then the code still + ** tries to unlock the database file if not in exclusive mode. If the + ** unlock operation fails as well, then the first error code related + ** to the first error encountered (the journal finalization one) is + ** returned. + */ + static int pager_end_transaction( Pager pPager, int hasMaster ) + { + int rc = SQLITE_OK; /* Error code from journal finalization operation */ + int rc2 = SQLITE_OK; /* Error code from db file unlock operation */ + /* Do nothing if the pager does not have an open write transaction + ** or at least a RESERVED lock. This function may be called when there + ** is no write-transaction active but a RESERVED or greater lock is + ** held under two circumstances: + ** + ** 1. After a successful hot-journal rollback, it is called with + ** eState==PAGER_NONE and eLock==EXCLUSIVE_LOCK. + ** + ** 2. If a connection with locking_mode=exclusive holding an EXCLUSIVE + ** lock switches back to locking_mode=normal and then executes a + ** read-transaction, this function is called with eState==PAGER_READER + ** and eLock==EXCLUSIVE_LOCK when the read-transaction is closed. + */ + Debug.Assert( assert_pager_state( pPager ) ); + Debug.Assert( pPager.eState != PAGER_ERROR ); + if ( pPager.eState < PAGER_WRITER_LOCKED && pPager.eLock < RESERVED_LOCK ) + { + return SQLITE_OK; + } - releaseAllSavepoints(pPager); - Debug.Assert(isOpen(pPager.jfd) || pPager.pInJournal == null); - if (isOpen(pPager.jfd)) { - Debug.Assert(!pagerUseWal(pPager)); - - /* Finalize the journal file. */ - if (sqlite3IsMemJournal(pPager.jfd)) { - Debug.Assert(pPager.journalMode == PAGER_JOURNALMODE_MEMORY); - sqlite3OsClose(pPager.jfd); - } else if (pPager.journalMode == PAGER_JOURNALMODE_TRUNCATE) { - if (pPager.journalOff == 0) { - rc = SQLITE_OK; - } else { - rc = sqlite3OsTruncate(pPager.jfd, 0); - } - pPager.journalOff = 0; - } else if (pPager.journalMode == PAGER_JOURNALMODE_PERSIST - || (pPager.exclusiveMode && pPager.journalMode != PAGER_JOURNALMODE_WAL) - ) { - rc = zeroJournalHdr(pPager, hasMaster); - pPager.journalOff = 0; - } else { - /* This branch may be executed with Pager.journalMode==MEMORY if - ** a hot-journal was just rolled back. In this case the journal - ** file should be closed and deleted. If this connection writes to - ** the database file, it will do so using an in-memory journal. - */ - Debug.Assert(pPager.journalMode == PAGER_JOURNALMODE_DELETE - || pPager.journalMode == PAGER_JOURNALMODE_MEMORY - || pPager.journalMode == PAGER_JOURNALMODE_WAL - ); - sqlite3OsClose(pPager.jfd); - if (!pPager.tempFile) { - rc = sqlite3OsDelete(pPager.pVfs, pPager.zJournal, 0); - } - } - } + releaseAllSavepoints( pPager ); + Debug.Assert( isOpen( pPager.jfd ) || pPager.pInJournal == null ); + if ( isOpen( pPager.jfd ) ) + { + Debug.Assert( !pagerUseWal( pPager ) ); + + /* Finalize the journal file. */ + if ( sqlite3IsMemJournal( pPager.jfd ) ) + { + Debug.Assert( pPager.journalMode == PAGER_JOURNALMODE_MEMORY ); + sqlite3OsClose( pPager.jfd ); + } + else if ( pPager.journalMode == PAGER_JOURNALMODE_TRUNCATE ) + { + if ( pPager.journalOff == 0 ) + { + rc = SQLITE_OK; + } + else + { + rc = sqlite3OsTruncate( pPager.jfd, 0 ); + } + pPager.journalOff = 0; + } + else if ( pPager.journalMode == PAGER_JOURNALMODE_PERSIST + || ( pPager.exclusiveMode && pPager.journalMode != PAGER_JOURNALMODE_WAL ) + ) + { + rc = zeroJournalHdr( pPager, hasMaster ); + pPager.journalOff = 0; + } + else + { + /* This branch may be executed with Pager.journalMode==MEMORY if + ** a hot-journal was just rolled back. In this case the journal + ** file should be closed and deleted. If this connection writes to + ** the database file, it will do so using an in-memory journal. + */ + Debug.Assert( pPager.journalMode == PAGER_JOURNALMODE_DELETE + || pPager.journalMode == PAGER_JOURNALMODE_MEMORY + || pPager.journalMode == PAGER_JOURNALMODE_WAL + ); + sqlite3OsClose( pPager.jfd ); + if ( !pPager.tempFile ) + { + rc = sqlite3OsDelete( pPager.pVfs, pPager.zJournal, 0 ); + } + } + } #if SQLITE_CHECK_PAGES sqlite3PcacheIterateDirty(pPager.pPCache, pager_set_pagehash); if( pPager.dbSize==0 && sqlite3PcacheRefCount(pPager.pPCache)>0 ){ @@ -2149,933 +2261,1008 @@ static int pager_end_transaction(Pager pPager, int hasMaster) { } } #endif - sqlite3BitvecDestroy(ref pPager.pInJournal); - pPager.pInJournal = null; - pPager.nRec = 0; - sqlite3PcacheCleanAll(pPager.pPCache); - sqlite3PcacheTruncate(pPager.pPCache, pPager.dbSize); + sqlite3BitvecDestroy( ref pPager.pInJournal ); + pPager.pInJournal = null; + pPager.nRec = 0; + sqlite3PcacheCleanAll( pPager.pPCache ); + sqlite3PcacheTruncate( pPager.pPCache, pPager.dbSize ); - if (pagerUseWal(pPager)) { - /* Drop the WAL write-lock, if any. Also, if the connection was in - ** locking_mode=exclusive mode but is no longer, drop the EXCLUSIVE - ** lock held on the database file. - */ - rc2 = sqlite3WalEndWriteTransaction(pPager.pWal); - Debug.Assert(rc2 == SQLITE_OK); - } - if (!pPager.exclusiveMode - && (!pagerUseWal(pPager) || sqlite3WalExclusiveMode(pPager.pWal, 0)) - ) { - rc2 = pagerUnlockDb(pPager, SHARED_LOCK); - pPager.changeCountDone = false; - } - pPager.eState = PAGER_READER; - pPager.setMaster = 0; + if ( pagerUseWal( pPager ) ) + { + /* Drop the WAL write-lock, if any. Also, if the connection was in + ** locking_mode=exclusive mode but is no longer, drop the EXCLUSIVE + ** lock held on the database file. + */ + rc2 = sqlite3WalEndWriteTransaction( pPager.pWal ); + Debug.Assert( rc2 == SQLITE_OK ); + } + if ( !pPager.exclusiveMode + && ( !pagerUseWal( pPager ) || sqlite3WalExclusiveMode( pPager.pWal, 0 ) ) + ) + { + rc2 = pagerUnlockDb( pPager, SHARED_LOCK ); + pPager.changeCountDone = false; + } + pPager.eState = PAGER_READER; + pPager.setMaster = 0; + + return ( rc == SQLITE_OK ? rc2 : rc ); + } - return (rc == SQLITE_OK ? rc2 : rc); + /* + ** Execute a rollback if a transaction is active and unlock the + ** database file. + ** + ** If the pager has already entered the ERROR state, do not attempt + ** the rollback at this time. Instead, pager_unlock() is called. The + ** call to pager_unlock() will discard all in-memory pages, unlock + ** the database file and move the pager back to OPEN state. If this + ** means that there is a hot-journal left in the file-system, the next + ** connection to obtain a shared lock on the pager (which may be this one) + ** will roll it back. + ** + ** If the pager has not already entered the ERROR state, but an IO or + ** malloc error occurs during a rollback, then this will itself cause + ** the pager to enter the ERROR state. Which will be cleared by the + ** call to pager_unlock(), as described above. + */ + static void pagerUnlockAndRollback( Pager pPager ) + { + if ( pPager.eState != PAGER_ERROR && pPager.eState != PAGER_OPEN ) + { + Debug.Assert( assert_pager_state( pPager ) ); + if ( pPager.eState >= PAGER_WRITER_LOCKED ) + { + sqlite3BeginBenignMalloc(); + sqlite3PagerRollback( pPager ); + sqlite3EndBenignMalloc(); } + else if ( !pPager.exclusiveMode ) + { + Debug.Assert( pPager.eState == PAGER_READER ); + pager_end_transaction( pPager, 0 ); + } + } + pager_unlock( pPager ); + } - /* - ** Execute a rollback if a transaction is active and unlock the - ** database file. - ** - ** If the pager has already entered the ERROR state, do not attempt - ** the rollback at this time. Instead, pager_unlock() is called. The - ** call to pager_unlock() will discard all in-memory pages, unlock - ** the database file and move the pager back to OPEN state. If this - ** means that there is a hot-journal left in the file-system, the next - ** connection to obtain a shared lock on the pager (which may be this one) - ** will roll it back. - ** - ** If the pager has not already entered the ERROR state, but an IO or - ** malloc error occurs during a rollback, then this will itself cause - ** the pager to enter the ERROR state. Which will be cleared by the - ** call to pager_unlock(), as described above. + /* + ** Parameter aData must point to a buffer of pPager.pageSize bytes + ** of data. Compute and return a checksum based ont the contents of the + ** page of data and the current value of pPager.cksumInit. + ** + ** This is not a real checksum. It is really just the sum of the + ** random initial value (pPager.cksumInit) and every 200th byte + ** of the page data, starting with byte offset (pPager.pageSize%200). + ** Each byte is interpreted as an 8-bit unsigned integer. + ** + ** Changing the formula used to compute this checksum results in an + ** incompatible journal file format. + ** + ** If journal corruption occurs due to a power failure, the most likely + ** scenario is that one end or the other of the record will be changed. + ** It is much less likely that the two ends of the journal record will be + ** correct and the middle be corrupt. Thus, this "checksum" scheme, + ** though fast and simple, catches the mostly likely kind of corruption. + */ + static u32 pager_cksum( Pager pPager, byte[] aData ) + { + u32 cksum = pPager.cksumInit; /* Checksum value to return */ + int i = pPager.pageSize - 200; /* Loop counter */ + while ( i > 0 ) + { + cksum += aData[i]; + i -= 200; + } + return cksum; + } + + /* + ** Report the current page size and number of reserved bytes back + ** to the codec. + */ +#if SQLITE_HAS_CODEC + static void pagerReportSize( Pager pPager ) + { + if ( pPager.xCodecSizeChng != null ) + { + pPager.xCodecSizeChng( pPager.pCodec, pPager.pageSize, + pPager.nReserve ); + } + } +#else +//# define pagerReportSize(X) /* No-op if we do not support a codec */ +static void pagerReportSize(Pager X){} +#endif + + /* +** Read a single page from either the journal file (if isMainJrnl==1) or +** from the sub-journal (if isMainJrnl==0) and playback that page. +** The page begins at offset *pOffset into the file. The *pOffset +** value is increased to the start of the next page in the journal. +** +** The main rollback journal uses checksums - the statement journal does +** not. +** +** If the page number of the page record read from the (sub-)journal file +** is greater than the current value of Pager.dbSize, then playback is +** skipped and SQLITE_OK is returned. +** +** If pDone is not NULL, then it is a record of pages that have already +** been played back. If the page at *pOffset has already been played back +** (if the corresponding pDone bit is set) then skip the playback. +** Make sure the pDone bit corresponding to the *pOffset page is set +** prior to returning. +** +** If the page record is successfully read from the (sub-)journal file +** and played back, then SQLITE_OK is returned. If an IO error occurs +** while reading the record from the (sub-)journal file or while writing +** to the database file, then the IO error code is returned. If data +** is successfully read from the (sub-)journal file but appears to be +** corrupted, SQLITE_DONE is returned. Data is considered corrupted in +** two circumstances: +** +** * If the record page-number is illegal (0 or PAGER_MJ_PGNO), or +** * If the record is being rolled back from the main journal file +** and the checksum field does not match the record content. +** +** Neither of these two scenarios are possible during a savepoint rollback. +** +** If this is a savepoint rollback, then memory may have to be dynamically +** allocated by this function. If this is the case and an allocation fails, +** SQLITE_NOMEM is returned. +*/ + static int pager_playback_one_page( + Pager pPager, /* The pager being played back */ + ref i64 pOffset, /* Offset of record to playback */ + Bitvec pDone, /* Bitvec of pages already played back */ + int isMainJrnl, /* True for main rollback journal. False for Stmt jrnl */ + int isSavepnt /* True for a savepoint rollback */ + ) + { + int rc; + PgHdr pPg; /* An existing page in the cache */ + Pgno pgno = 0; /* The page number of a page in journal */ + u32 cksum = 0; /* Checksum used for sanity checking */ + byte[] aData; /* Temporary storage for the page */ + sqlite3_file jfd; /* The file descriptor for the journal file */ + bool isSynced; /* True if journal page is synced */ + + Debug.Assert( ( isMainJrnl & ~1 ) == 0 ); /* isMainJrnl is 0 or 1 */ + Debug.Assert( ( isSavepnt & ~1 ) == 0 ); /* isSavepnt is 0 or 1 */ + Debug.Assert( isMainJrnl != 0 || pDone != null ); /* pDone always used on sub-journals */ + Debug.Assert( isSavepnt != 0 || pDone == null ); /* pDone never used on non-savepoint */ + + aData = pPager.pTmpSpace; + Debug.Assert( aData != null ); /* Temp storage must have already been allocated */ + Debug.Assert( pagerUseWal( pPager ) == false || ( 0 == isMainJrnl && isSavepnt != 0 ) ); + + /* Either the state is greater than PAGER_WRITER_CACHEMOD (a transaction + ** or savepoint rollback done at the request of the caller) or this is + ** a hot-journal rollback. If it is a hot-journal rollback, the pager + ** is in state OPEN and holds an EXCLUSIVE lock. Hot-journal rollback + ** only reads from the main journal, not the sub-journal. + */ + Debug.Assert( pPager.eState >= PAGER_WRITER_CACHEMOD + || ( pPager.eState == PAGER_OPEN && pPager.eLock == EXCLUSIVE_LOCK ) + ); + Debug.Assert( pPager.eState >= PAGER_WRITER_CACHEMOD || isMainJrnl != 0 ); + + /* Read the page number and page data from the journal or sub-journal + ** file. Return an error code to the caller if an IO error occurs. + */ + jfd = isMainJrnl != 0 ? pPager.jfd : pPager.sjfd; + + rc = read32bits( jfd, pOffset, ref pgno ); + if ( rc != SQLITE_OK ) + return rc; + rc = sqlite3OsRead( jfd, aData, pPager.pageSize, ( pOffset ) + 4 ); + if ( rc != SQLITE_OK ) + return rc; + pOffset += pPager.pageSize + 4 + isMainJrnl * 4; + + /* Sanity checking on the page. This is more important that I originally + ** thought. If a power failure occurs while the journal is being written, + ** it could cause invalid data to be written into the journal. We need to + ** detect this invalid data (with high probability) and ignore it. + */ + if ( pgno == 0 || pgno == PAGER_MJ_PGNO( pPager ) ) + { + Debug.Assert( 0 == isSavepnt ); + return SQLITE_DONE; + } + if ( pgno > pPager.dbSize || sqlite3BitvecTest( pDone, pgno ) != 0 ) + { + return SQLITE_OK; + } + if ( isMainJrnl != 0 ) + { + rc = read32bits( jfd, ( pOffset ) - 4, ref cksum ); + if ( rc != 0 ) + return rc; + if ( 0 == isSavepnt && pager_cksum( pPager, aData ) != cksum ) + { + return SQLITE_DONE; + } + } + + /* If this page has already been played by before during the current + ** rollback, then don't bother to play it back again. + */ + if ( pDone != null && ( rc = sqlite3BitvecSet( pDone, pgno ) ) != SQLITE_OK ) + { + return rc; + } + + /* When playing back page 1, restore the nReserve setting + */ + if ( pgno == 1 && pPager.nReserve != ( aData )[20] ) + { + pPager.nReserve = ( aData )[20]; + pagerReportSize( pPager ); + } + + /* If the pager is in CACHEMOD state, then there must be a copy of this + ** page in the pager cache. In this case just update the pager cache, + ** not the database file. The page is left marked dirty in this case. + ** + ** An exception to the above rule: If the database is in no-sync mode + ** and a page is moved during an incremental vacuum then the page may + ** not be in the pager cache. Later: if a malloc() or IO error occurs + ** during a Movepage() call, then the page may not be in the cache + ** either. So the condition described in the above paragraph is not + ** assert()able. + ** + ** If in WRITER_DBMOD, WRITER_FINISHED or OPEN state, then we update the + ** pager cache if it exists and the main file. The page is then marked + ** not dirty. Since this code is only executed in PAGER_OPEN state for + ** a hot-journal rollback, it is guaranteed that the page-cache is empty + ** if the pager is in OPEN state. + ** + ** Ticket #1171: The statement journal might contain page content that is + ** different from the page content at the start of the transaction. + ** This occurs when a page is changed prior to the start of a statement + ** then changed again within the statement. When rolling back such a + ** statement we must not write to the original database unless we know + ** for certain that original page contents are synced into the main rollback + ** journal. Otherwise, a power loss might leave modified data in the + ** database file without an entry in the rollback journal that can + ** restore the database to its original form. Two conditions must be + ** met before writing to the database files. (1) the database must be + ** locked. (2) we know that the original page content is fully synced + ** in the main journal either because the page is not in cache or else + ** the page is marked as needSync==0. + ** + ** 2008-04-14: When attempting to vacuum a corrupt database file, it + ** is possible to fail a statement on a database that does not yet exist. + ** Do not attempt to write if database file has never been opened. + */ + if ( pagerUseWal( pPager ) ) + { + pPg = null; + } + else + { + pPg = pager_lookup( pPager, pgno ); + } + Debug.Assert( pPg != null || +#if SQLITE_OMIT_MEMORYDB +0==MEMDB +#else + pPager.memDb == 0 +#endif + ); + Debug.Assert( pPager.eState != PAGER_OPEN || pPg == null ); + + PAGERTRACE( "PLAYBACK %d page %d hash(%08x) %s\n", + PAGERID( pPager ), pgno, pager_datahash( pPager.pageSize, aData ), + ( isMainJrnl != 0 ? "main-journal" : "sub-journal" ) + ); + if ( isMainJrnl != 0 ) + { + isSynced = pPager.noSync || ( pOffset <= pPager.journalHdr ); + } + else + { + isSynced = ( pPg == null || 0 == ( pPg.flags & PGHDR_NEED_SYNC ) ); + } + if ( isOpen( pPager.fd ) + && ( pPager.eState >= PAGER_WRITER_DBMOD || pPager.eState == PAGER_OPEN ) + && isSynced + ) + { + i64 ofst = ( pgno - 1 ) * pPager.pageSize; + testcase( 0 == isSavepnt && pPg != null && ( pPg.flags & PGHDR_NEED_SYNC ) != 0 ); + Debug.Assert( !pagerUseWal( pPager ) ); + rc = sqlite3OsWrite( pPager.fd, aData, pPager.pageSize, ofst ); + if ( pgno > pPager.dbFileSize ) + { + pPager.dbFileSize = pgno; + } + if ( pPager.pBackup != null ) + { + if ( CODEC1( pPager, aData, pgno, SQLITE_DECRYPT ) ) + rc = SQLITE_NOMEM; // CODEC1( pPager, aData, pgno, 3, rc = SQLITE_NOMEM ); + sqlite3BackupUpdate( pPager.pBackup, pgno, (u8[])aData ); + if ( CODEC2( pPager, aData, pgno, SQLITE_ENCRYPT_READ_CTX, ref aData ) ) + rc = SQLITE_NOMEM;//CODEC2( pPager, aData, pgno, 7, rc = SQLITE_NOMEM, aData); + } + } + else if ( 0 == isMainJrnl && pPg == null ) + { + /* If this is a rollback of a savepoint and data was not written to + ** the database and the page is not in-memory, there is a potential + ** problem. When the page is next fetched by the b-tree layer, it + ** will be read from the database file, which may or may not be + ** current. + ** + ** There are a couple of different ways this can happen. All are quite + ** obscure. When running in synchronous mode, this can only happen + ** if the page is on the free-list at the start of the transaction, then + ** populated, then moved using sqlite3PagerMovepage(). + ** + ** The solution is to add an in-memory page to the cache containing + ** the data just read from the sub-journal. Mark the page as dirty + ** and if the pager requires a journal-sync, then mark the page as + ** requiring a journal-sync before it is written. + */ + Debug.Assert( isSavepnt != 0 ); + Debug.Assert( pPager.doNotSpill == 0 ); + pPager.doNotSpill++; + rc = sqlite3PagerAcquire( pPager, pgno, ref pPg, 1 ); + Debug.Assert( pPager.doNotSpill == 1 ); + pPager.doNotSpill--; + if ( rc != SQLITE_OK ) + return rc; + pPg.flags &= ~PGHDR_NEED_READ; + sqlite3PcacheMakeDirty( pPg ); + } + if ( pPg != null ) + { + /* No page should ever be explicitly rolled back that is in use, except + ** for page 1 which is held in use in order to keep the lock on the + ** database active. However such a page may be rolled back as a result + ** of an internal error resulting in an automatic call to + ** sqlite3PagerRollback(). */ - static void pagerUnlockAndRollback(Pager pPager) { - if (pPager.eState != PAGER_ERROR && pPager.eState != PAGER_OPEN) { - Debug.Assert(assert_pager_state(pPager)); - if (pPager.eState >= PAGER_WRITER_LOCKED) { - sqlite3BeginBenignMalloc(); - sqlite3PagerRollback(pPager); - sqlite3EndBenignMalloc(); - } else if (!pPager.exclusiveMode) { - Debug.Assert(pPager.eState == PAGER_READER); - pager_end_transaction(pPager, 0); - } - } - pager_unlock(pPager); + byte[] pData = pPg.pData; + Buffer.BlockCopy( aData, 0, pData, 0, pPager.pageSize );// memcpy(pData, (u8[])aData, pPager.pageSize); + pPager.xReiniter( pPg ); + if ( isMainJrnl != 0 && ( 0 == isSavepnt || pOffset <= pPager.journalHdr ) ) + { + /* If the contents of this page were just restored from the main + ** journal file, then its content must be as they were when the + ** transaction was first opened. In this case we can mark the page + ** as clean, since there will be no need to write it out to the + ** database. + ** + ** There is one exception to this rule. If the page is being rolled + ** back as part of a savepoint (or statement) rollback from an + ** unsynced portion of the main journal file, then it is not safe + ** to mark the page as clean. This is because marking the page as + ** clean will clear the PGHDR_NEED_SYNC flag. Since the page is + ** already in the journal file (recorded in Pager.pInJournal) and + ** the PGHDR_NEED_SYNC flag is cleared, if the page is written to + ** again within this transaction, it will be marked as dirty but + ** the PGHDR_NEED_SYNC flag will not be set. It could then potentially + ** be written out into the database file before its journal file + ** segment is synced. If a crash occurs during or following this, + ** database corruption may ensue. + */ + Debug.Assert( !pagerUseWal( pPager ) ); + sqlite3PcacheMakeClean( pPg ); } - - /* - ** Parameter aData must point to a buffer of pPager.pageSize bytes - ** of data. Compute and return a checksum based ont the contents of the - ** page of data and the current value of pPager.cksumInit. - ** - ** This is not a real checksum. It is really just the sum of the - ** random initial value (pPager.cksumInit) and every 200th byte - ** of the page data, starting with byte offset (pPager.pageSize%200). - ** Each byte is interpreted as an 8-bit unsigned integer. - ** - ** Changing the formula used to compute this checksum results in an - ** incompatible journal file format. - ** - ** If journal corruption occurs due to a power failure, the most likely - ** scenario is that one end or the other of the record will be changed. - ** It is much less likely that the two ends of the journal record will be - ** correct and the middle be corrupt. Thus, this "checksum" scheme, - ** though fast and simple, catches the mostly likely kind of corruption. - */ - static u32 pager_cksum(Pager pPager, byte[] aData) { - u32 cksum = pPager.cksumInit; /* Checksum value to return */ - int i = pPager.pageSize - 200; /* Loop counter */ - while (i > 0) { - cksum += aData[i]; - i -= 200; - } - return cksum; + pager_set_pagehash( pPg ); + /* If this was page 1, then restore the value of Pager.dbFileVers. + ** Do this before any decoding. */ + if ( pgno == 1 ) + { + Buffer.BlockCopy( pData, 24, pPager.dbFileVers, 0, pPager.dbFileVers.Length ); //memcpy(pPager.dbFileVers, ((u8*)pData)[24], sizeof(pPager.dbFileVers)); } - /* - ** Report the current page size and number of reserved bytes back - ** to the codec. - */ -#if SQLITE_HAS_CODEC - static void pagerReportSize( Pager pPager ) - { - if ( pPager.xCodecSizeChng != null ) - { - pPager.xCodecSizeChng( pPager.pCodec, pPager.pageSize, - pPager.nReserve ); + /* Decode the page just read from disk */ + if ( CODEC1( pPager, pData, pPg.pgno, SQLITE_DECRYPT ) ) + rc = SQLITE_NOMEM; //CODEC1(pPager, pData, pPg.pgno, 3, rc=SQLITE_NOMEM); + sqlite3PcacheRelease( pPg ); } + return rc; } -#else - //# define pagerReportSize(X) /* No-op if we do not support a codec */ - static void pagerReportSize(Pager X) { } -#endif - /* - ** Read a single page from either the journal file (if isMainJrnl==1) or - ** from the sub-journal (if isMainJrnl==0) and playback that page. - ** The page begins at offset *pOffset into the file. The *pOffset - ** value is increased to the start of the next page in the journal. - ** - ** The main rollback journal uses checksums - the statement journal does - ** not. - ** - ** If the page number of the page record read from the (sub-)journal file - ** is greater than the current value of Pager.dbSize, then playback is - ** skipped and SQLITE_OK is returned. - ** - ** If pDone is not NULL, then it is a record of pages that have already - ** been played back. If the page at *pOffset has already been played back - ** (if the corresponding pDone bit is set) then skip the playback. - ** Make sure the pDone bit corresponding to the *pOffset page is set - ** prior to returning. - ** - ** If the page record is successfully read from the (sub-)journal file - ** and played back, then SQLITE_OK is returned. If an IO error occurs - ** while reading the record from the (sub-)journal file or while writing - ** to the database file, then the IO error code is returned. If data - ** is successfully read from the (sub-)journal file but appears to be - ** corrupted, SQLITE_DONE is returned. Data is considered corrupted in - ** two circumstances: - ** - ** * If the record page-number is illegal (0 or PAGER_MJ_PGNO), or - ** * If the record is being rolled back from the main journal file - ** and the checksum field does not match the record content. + /* + ** Parameter zMaster is the name of a master journal file. A single journal + ** file that referred to the master journal file has just been rolled back. + ** This routine checks if it is possible to delete the master journal file, + ** and does so if it is. + ** + ** Argument zMaster may point to Pager.pTmpSpace. So that buffer is not + ** available for use within this function. + ** + ** When a master journal file is created, it is populated with the names + ** of all of its child journals, one after another, formatted as utf-8 + ** encoded text. The end of each child journal file is marked with a + ** nul-terminator byte (0x00). i.e. the entire contents of a master journal + ** file for a transaction involving two databases might be: + ** + ** "/home/bill/a.db-journal\x00/home/bill/b.db-journal\x00" + ** + ** A master journal file may only be deleted once all of its child + ** journals have been rolled back. + ** + ** This function reads the contents of the master-journal file into + ** memory and loops through each of the child journal names. For + ** each child journal, it checks if: ** - ** Neither of these two scenarios are possible during a savepoint rollback. + ** * if the child journal exists, and if so + ** * if the child journal contains a reference to master journal + ** file zMaster ** - ** If this is a savepoint rollback, then memory may have to be dynamically - ** allocated by this function. If this is the case and an allocation fails, - ** SQLITE_NOMEM is returned. + ** If a child journal can be found that matches both of the criteria + ** above, this function returns without doing anything. Otherwise, if + ** no such child journal can be found, file zMaster is deleted from + ** the file-system using sqlite3OsDelete(). + ** + ** If an IO error within this function, an error code is returned. This + ** function allocates memory by calling sqlite3Malloc(). If an allocation + ** fails, SQLITE_NOMEM is returned. Otherwise, if no IO or malloc errors + ** occur, SQLITE_OK is returned. + ** + ** TODO: This function allocates a single block of memory to load + ** the entire contents of the master journal file. This could be + ** a couple of kilobytes or so - potentially larger than the page + ** size. */ - static int pager_playback_one_page( - Pager pPager, /* The pager being played back */ - ref i64 pOffset, /* Offset of record to playback */ - Bitvec pDone, /* Bitvec of pages already played back */ - int isMainJrnl, /* True for main rollback journal. False for Stmt jrnl */ - int isSavepnt /* True for a savepoint rollback */ - ) { - int rc; - PgHdr pPg; /* An existing page in the cache */ - Pgno pgno = 0; /* The page number of a page in journal */ - u32 cksum = 0; /* Checksum used for sanity checking */ - byte[] aData; /* Temporary storage for the page */ - sqlite3_file jfd; /* The file descriptor for the journal file */ - bool isSynced; /* True if journal page is synced */ - - Debug.Assert((isMainJrnl & ~1) == 0); /* isMainJrnl is 0 or 1 */ - Debug.Assert((isSavepnt & ~1) == 0); /* isSavepnt is 0 or 1 */ - Debug.Assert(isMainJrnl != 0 || pDone != null); /* pDone always used on sub-journals */ - Debug.Assert(isSavepnt != 0 || pDone == null); /* pDone never used on non-savepoint */ - - aData = pPager.pTmpSpace; - Debug.Assert(aData != null); /* Temp storage must have already been allocated */ - Debug.Assert(pagerUseWal(pPager) == false || (0 == isMainJrnl && isSavepnt != 0)); - - /* Either the state is greater than PAGER_WRITER_CACHEMOD (a transaction - ** or savepoint rollback done at the request of the caller) or this is - ** a hot-journal rollback. If it is a hot-journal rollback, the pager - ** is in state OPEN and holds an EXCLUSIVE lock. Hot-journal rollback - ** only reads from the main journal, not the sub-journal. - */ - Debug.Assert(pPager.eState >= PAGER_WRITER_CACHEMOD - || (pPager.eState == PAGER_OPEN && pPager.eLock == EXCLUSIVE_LOCK) - ); - Debug.Assert(pPager.eState >= PAGER_WRITER_CACHEMOD || isMainJrnl != 0); - - /* Read the page number and page data from the journal or sub-journal - ** file. Return an error code to the caller if an IO error occurs. - */ - jfd = isMainJrnl != 0 ? pPager.jfd : pPager.sjfd; - - rc = read32bits(jfd, pOffset, ref pgno); - if (rc != SQLITE_OK) - return rc; - rc = sqlite3OsRead(jfd, aData, pPager.pageSize, (pOffset) + 4); - if (rc != SQLITE_OK) - return rc; - pOffset += pPager.pageSize + 4 + isMainJrnl * 4; + static int pager_delmaster( Pager pPager, string zMaster ) + { + sqlite3_vfs pVfs = pPager.pVfs; + int rc; /* Return code */ + sqlite3_file pMaster; /* Malloc'd master-journal file descriptor */ + sqlite3_file pJournal; /* Malloc'd child-journal file descriptor */ + //string zMasterJournal = null; /* Contents of master journal file */ + i64 nMasterJournal; /* Size of master journal file */ + string zJournal; /* Pointer to one journal within MJ file */ + string zMasterPtr; /* Space to hold MJ filename from a journal file */ + int nMasterPtr; /* Amount of space allocated to zMasterPtr[] */ + + /* Allocate space for both the pJournal and pMaster file descriptors. + ** If successful, open the master journal file for reading. + */ + pMaster = new sqlite3_file();// (sqlite3_file*)sqlite3MallocZero( pVfs.szOsFile * 2 ); + pJournal = new sqlite3_file();// (sqlite3_file*)( ( (u8*)pMaster ) + pVfs.szOsFile ); + //if ( null == pMaster ) + //{ + // rc = SQLITE_NOMEM; + //} + //else + { + const int flags = ( SQLITE_OPEN_READONLY | SQLITE_OPEN_MASTER_JOURNAL ); + int iDummy = 0; + rc = sqlite3OsOpen( pVfs, zMaster, pMaster, flags, ref iDummy ); + } + if ( rc != SQLITE_OK ) + goto delmaster_out; - /* Sanity checking on the page. This is more important that I originally - ** thought. If a power failure occurs while the journal is being written, - ** it could cause invalid data to be written into the journal. We need to - ** detect this invalid data (with high probability) and ignore it. - */ - if (pgno == 0 || pgno == PAGER_MJ_PGNO(pPager)) { - Debug.Assert(0 == isSavepnt); - return SQLITE_DONE; - } - if (pgno > pPager.dbSize || sqlite3BitvecTest(pDone, pgno) != 0) { - return SQLITE_OK; - } - if (isMainJrnl != 0) { - rc = read32bits(jfd, (pOffset) - 4, ref cksum); - if (rc != 0) - return rc; - if (0 == isSavepnt && pager_cksum(pPager, aData) != cksum) { - return SQLITE_DONE; - } - } + Debugger.Break(); //TODO -- - /* If this page has already been played by before during the current - ** rollback, then don't bother to play it back again. - */ - if (pDone != null && (rc = sqlite3BitvecSet(pDone, pgno)) != SQLITE_OK) { - return rc; - } + /* Load the entire master journal file into space obtained from + ** sqlite3_malloc() and pointed to by zMasterJournal. Also obtain + ** sufficient space (in zMasterPtr) to hold the names of master + ** journal files extracted from regular rollback-journals. + */ + //rc = sqlite3OsFileSize(pMaster, &nMasterJournal); + //if (rc != SQLITE_OK) goto delmaster_out; + //nMasterPtr = pVfs.mxPathname + 1; + // zMasterJournal = sqlite3Malloc((int)nMasterJournal + nMasterPtr + 1); + // if ( !zMasterJournal ) + // { + // rc = SQLITE_NOMEM; + // goto delmaster_out; + // } + // zMasterPtr = &zMasterJournal[nMasterJournal+1]; + // rc = sqlite3OsRead( pMaster, zMasterJournal, (int)nMasterJournal, 0 ); + // if ( rc != SQLITE_OK ) goto delmaster_out; + // zMasterJournal[nMasterJournal] = 0; + + + // zJournal = zMasterJournal; + // while ( ( zJournal - zMasterJournal ) < nMasterJournal ) + // { + // int exists; + // rc = sqlite3OsAccess( pVfs, zJournal, SQLITE_ACCESS_EXISTS, &exists ); + // if ( rc != SQLITE_OK ) + // { + // goto delmaster_out; + // } + // if ( exists ) + // { + // /* One of the journals pointed to by the master journal exists. + // ** Open it and check if it points at the master journal. If + // ** so, return without deleting the master journal file. + // */ + // int c; + // int flags = ( SQLITE_OPEN_READONLY | SQLITE_OPEN_MAIN_JOURNAL ); + // rc = sqlite3OsOpen( pVfs, zJournal, pJournal, flags, 0 ); + // if ( rc != SQLITE_OK ) + // { + // goto delmaster_out; + // } + + // rc = readMasterJournal( pJournal, zMasterPtr, nMasterPtr ); + // sqlite3OsClose( pJournal ); + // if ( rc != SQLITE_OK ) + // { + // goto delmaster_out; + // } + + // c = zMasterPtr[0] != 0 && strcmp( zMasterPtr, zMaster ) == 0; + // if ( c ) + // { + // /* We have a match. Do not delete the master journal file. */ + // goto delmaster_out; + // } + // } + // zJournal += ( sqlite3Strlen30( zJournal ) + 1 ); + // } + // + //sqlite3OsClose(pMaster); + //rc = sqlite3OsDelete( pVfs, zMaster, 0 ); + + + goto delmaster_out; +delmaster_out: + //sqlite3_free( ref zMasterJournal ); + if ( pMaster != null ) + { + sqlite3OsClose( pMaster ); + Debug.Assert( !isOpen( pJournal ) ); + //sqlite3_free( ref pMaster ); + } + return rc; + } - /* When playing back page 1, restore the nReserve setting - */ - if (pgno == 1 && pPager.nReserve != (aData)[20]) { - pPager.nReserve = (aData)[20]; - pagerReportSize(pPager); - } - /* If the pager is in CACHEMOD state, then there must be a copy of this - ** page in the pager cache. In this case just update the pager cache, - ** not the database file. The page is left marked dirty in this case. - ** - ** An exception to the above rule: If the database is in no-sync mode - ** and a page is moved during an incremental vacuum then the page may - ** not be in the pager cache. Later: if a malloc() or IO error occurs - ** during a Movepage() call, then the page may not be in the cache - ** either. So the condition described in the above paragraph is not - ** assert()able. - ** - ** If in WRITER_DBMOD, WRITER_FINISHED or OPEN state, then we update the - ** pager cache if it exists and the main file. The page is then marked - ** not dirty. Since this code is only executed in PAGER_OPEN state for - ** a hot-journal rollback, it is guaranteed that the page-cache is empty - ** if the pager is in OPEN state. - ** - ** Ticket #1171: The statement journal might contain page content that is - ** different from the page content at the start of the transaction. - ** This occurs when a page is changed prior to the start of a statement - ** then changed again within the statement. When rolling back such a - ** statement we must not write to the original database unless we know - ** for certain that original page contents are synced into the main rollback - ** journal. Otherwise, a power loss might leave modified data in the - ** database file without an entry in the rollback journal that can - ** restore the database to its original form. Two conditions must be - ** met before writing to the database files. (1) the database must be - ** locked. (2) we know that the original page content is fully synced - ** in the main journal either because the page is not in cache or else - ** the page is marked as needSync==0. - ** - ** 2008-04-14: When attempting to vacuum a corrupt database file, it - ** is possible to fail a statement on a database that does not yet exist. - ** Do not attempt to write if database file has never been opened. - */ - if (pagerUseWal(pPager)) { - pPg = null; - } else { - pPg = pager_lookup(pPager, pgno); - } - Debug.Assert(pPg != null || -#if SQLITE_OMIT_MEMORYDB -0==MEMDB -#else - pPager.memDb == 0 -#endif - ); - Debug.Assert(pPager.eState != PAGER_OPEN || pPg == null); - PAGERTRACE("PLAYBACK %d page %d hash(%08x) %s\n", - PAGERID(pPager), pgno, pager_datahash(pPager.pageSize, aData), - (isMainJrnl != 0 ? "main-journal" : "sub-journal") - ); - if (isMainJrnl != 0) { - isSynced = pPager.noSync || (pOffset <= pPager.journalHdr); - } else { - isSynced = (pPg == null || 0 == (pPg.flags & PGHDR_NEED_SYNC)); - } - if (isOpen(pPager.fd) - && (pPager.eState >= PAGER_WRITER_DBMOD || pPager.eState == PAGER_OPEN) - && isSynced - ) { - i64 ofst = (pgno - 1) * pPager.pageSize; - testcase(0 == isSavepnt && pPg != null && (pPg.flags & PGHDR_NEED_SYNC) != 0); - Debug.Assert(!pagerUseWal(pPager)); - rc = sqlite3OsWrite(pPager.fd, aData, pPager.pageSize, ofst); - if (pgno > pPager.dbFileSize) { - pPager.dbFileSize = pgno; - } - if (pPager.pBackup != null) { - if (CODEC1(pPager, aData, pgno, SQLITE_DECRYPT)) - rc = SQLITE_NOMEM; // CODEC1( pPager, aData, pgno, 3, rc = SQLITE_NOMEM ); - sqlite3BackupUpdate(pPager.pBackup, pgno, (u8[])aData); - if (CODEC2(pPager, aData, pgno, SQLITE_ENCRYPT_READ_CTX, ref aData)) - rc = SQLITE_NOMEM;//CODEC2( pPager, aData, pgno, 7, rc = SQLITE_NOMEM, aData); - } - } else if (0 == isMainJrnl && pPg == null) { - /* If this is a rollback of a savepoint and data was not written to - ** the database and the page is not in-memory, there is a potential - ** problem. When the page is next fetched by the b-tree layer, it - ** will be read from the database file, which may or may not be - ** current. - ** - ** There are a couple of different ways this can happen. All are quite - ** obscure. When running in synchronous mode, this can only happen - ** if the page is on the free-list at the start of the transaction, then - ** populated, then moved using sqlite3PagerMovepage(). - ** - ** The solution is to add an in-memory page to the cache containing - ** the data just read from the sub-journal. Mark the page as dirty - ** and if the pager requires a journal-sync, then mark the page as - ** requiring a journal-sync before it is written. - */ - Debug.Assert(isSavepnt != 0); - Debug.Assert(pPager.doNotSpill == 0); - pPager.doNotSpill++; - rc = sqlite3PagerAcquire(pPager, pgno, ref pPg, 1); - Debug.Assert(pPager.doNotSpill == 1); - pPager.doNotSpill--; - if (rc != SQLITE_OK) - return rc; - pPg.flags &= ~PGHDR_NEED_READ; - sqlite3PcacheMakeDirty(pPg); - } - if (pPg != null) { - /* No page should ever be explicitly rolled back that is in use, except - ** for page 1 which is held in use in order to keep the lock on the - ** database active. However such a page may be rolled back as a result - ** of an internal error resulting in an automatic call to - ** sqlite3PagerRollback(). - */ - byte[] pData = pPg.pData; - Buffer.BlockCopy(aData, 0, pData, 0, pPager.pageSize);// memcpy(pData, (u8[])aData, pPager.pageSize); - pPager.xReiniter(pPg); - if (isMainJrnl != 0 && (0 == isSavepnt || pOffset <= pPager.journalHdr)) { - /* If the contents of this page were just restored from the main - ** journal file, then its content must be as they were when the - ** transaction was first opened. In this case we can mark the page - ** as clean, since there will be no need to write it out to the - ** database. - ** - ** There is one exception to this rule. If the page is being rolled - ** back as part of a savepoint (or statement) rollback from an - ** unsynced portion of the main journal file, then it is not safe - ** to mark the page as clean. This is because marking the page as - ** clean will clear the PGHDR_NEED_SYNC flag. Since the page is - ** already in the journal file (recorded in Pager.pInJournal) and - ** the PGHDR_NEED_SYNC flag is cleared, if the page is written to - ** again within this transaction, it will be marked as dirty but - ** the PGHDR_NEED_SYNC flag will not be set. It could then potentially - ** be written out into the database file before its journal file - ** segment is synced. If a crash occurs during or following this, - ** database corruption may ensue. - */ - Debug.Assert(!pagerUseWal(pPager)); - sqlite3PcacheMakeClean(pPg); - } - pager_set_pagehash(pPg); - /* If this was page 1, then restore the value of Pager.dbFileVers. - ** Do this before any decoding. */ - if (pgno == 1) { - Buffer.BlockCopy(pData, 24, pPager.dbFileVers, 0, pPager.dbFileVers.Length); //memcpy(pPager.dbFileVers, ((u8*)pData)[24], sizeof(pPager.dbFileVers)); - } + /* + ** This function is used to change the actual size of the database + ** file in the file-system. This only happens when committing a transaction, + ** or rolling back a transaction (including rolling back a hot-journal). + ** + ** If the main database file is not open, or the pager is not in either + ** DBMOD or OPEN state, this function is a no-op. Otherwise, the size + ** of the file is changed to nPage pages (nPage*pPager.pageSize bytes). + ** If the file on disk is currently larger than nPage pages, then use the VFS + ** xTruncate() method to truncate it. + ** + ** Or, it might might be the case that the file on disk is smaller than + ** nPage pages. Some operating system implementations can get confused if + ** you try to truncate a file to some size that is larger than it + ** currently is, so detect this case and write a single zero byte to + ** the end of the new file instead. + ** + ** If successful, return SQLITE_OK. If an IO error occurs while modifying + ** the database file, return the error code to the caller. + */ + static int pager_truncate( Pager pPager, u32 nPage ) + { + int rc = SQLITE_OK; + Debug.Assert( pPager.eState != PAGER_ERROR ); + Debug.Assert( pPager.eState != PAGER_READER ); - /* Decode the page just read from disk */ - if (CODEC1(pPager, pData, pPg.pgno, SQLITE_DECRYPT)) - rc = SQLITE_NOMEM; //CODEC1(pPager, pData, pPg.pgno, 3, rc=SQLITE_NOMEM); - sqlite3PcacheRelease(pPg); - } - return rc; + if ( isOpen( pPager.fd ) + && ( pPager.eState >= PAGER_WRITER_DBMOD || pPager.eState == PAGER_OPEN ) + ) + { + i64 currentSize = 0, newSize; + int szPage = pPager.pageSize; + Debug.Assert( pPager.eLock == EXCLUSIVE_LOCK ); + /* TODO: Is it safe to use Pager.dbFileSize here? */ + rc = sqlite3OsFileSize( pPager.fd, ref currentSize ); + newSize = szPage * nPage; + if ( rc == SQLITE_OK && currentSize != newSize ) + { + if ( currentSize > newSize ) + { + rc = sqlite3OsTruncate( pPager.fd, newSize ); + } + else + { + byte[] pTmp = pPager.pTmpSpace; + Array.Clear( pTmp, 0, szPage );//memset( pTmp, 0, szPage ); + testcase( ( newSize - szPage ) < currentSize ); + testcase( ( newSize - szPage ) == currentSize ); + testcase( ( newSize - szPage ) > currentSize ); + rc = sqlite3OsWrite( pPager.fd, pTmp, szPage, newSize - szPage ); + } + if ( rc == SQLITE_OK ) + { + pPager.dbSize = nPage; + } } + } + return rc; + } - /* - ** Parameter zMaster is the name of a master journal file. A single journal - ** file that referred to the master journal file has just been rolled back. - ** This routine checks if it is possible to delete the master journal file, - ** and does so if it is. - ** - ** Argument zMaster may point to Pager.pTmpSpace. So that buffer is not - ** available for use within this function. - ** - ** When a master journal file is created, it is populated with the names - ** of all of its child journals, one after another, formatted as utf-8 - ** encoded text. The end of each child journal file is marked with a - ** nul-terminator byte (0x00). i.e. the entire contents of a master journal - ** file for a transaction involving two databases might be: - ** - ** "/home/bill/a.db-journal\x00/home/bill/b.db-journal\x00" - ** - ** A master journal file may only be deleted once all of its child - ** journals have been rolled back. - ** - ** This function reads the contents of the master-journal file into - ** memory and loops through each of the child journal names. For - ** each child journal, it checks if: - ** - ** * if the child journal exists, and if so - ** * if the child journal contains a reference to master journal - ** file zMaster - ** - ** If a child journal can be found that matches both of the criteria - ** above, this function returns without doing anything. Otherwise, if - ** no such child journal can be found, file zMaster is deleted from - ** the file-system using sqlite3OsDelete(). - ** - ** If an IO error within this function, an error code is returned. This - ** function allocates memory by calling sqlite3Malloc(). If an allocation - ** fails, SQLITE_NOMEM is returned. Otherwise, if no IO or malloc errors - ** occur, SQLITE_OK is returned. - ** - ** TODO: This function allocates a single block of memory to load - ** the entire contents of the master journal file. This could be - ** a couple of kilobytes or so - potentially larger than the page - ** size. + /* + ** Set the value of the Pager.sectorSize variable for the given + ** pager based on the value returned by the xSectorSize method + ** of the open database file. The sector size will be used used + ** to determine the size and alignment of journal header and + ** master journal pointers within created journal files. + ** + ** For temporary files the effective sector size is always 512 bytes. + ** + ** Otherwise, for non-temporary files, the effective sector size is + ** the value returned by the xSectorSize() method rounded up to 512 if + ** it is less than 32, or rounded down to MAX_SECTOR_SIZE if it + ** is greater than MAX_SECTOR_SIZE. + */ + static void setSectorSize( Pager pPager ) + { + Debug.Assert( isOpen( pPager.fd ) || pPager.tempFile ); + if ( !pPager.tempFile ) + { + /* Sector size doesn't matter for temporary files. Also, the file + ** may not have been opened yet, in which case the OsSectorSize() + ** call will segfault. */ - static int pager_delmaster(Pager pPager, string zMaster) { - sqlite3_vfs pVfs = pPager.pVfs; - int rc; /* Return code */ - sqlite3_file pMaster; /* Malloc'd master-journal file descriptor */ - sqlite3_file pJournal; /* Malloc'd child-journal file descriptor */ - //string zMasterJournal = null; /* Contents of master journal file */ - i64 nMasterJournal; /* Size of master journal file */ - string zJournal; /* Pointer to one journal within MJ file */ - string zMasterPtr; /* Space to hold MJ filename from a journal file */ - int nMasterPtr; /* Amount of space allocated to zMasterPtr[] */ - - /* Allocate space for both the pJournal and pMaster file descriptors. - ** If successful, open the master journal file for reading. - */ - pMaster = new sqlite3_file();// (sqlite3_file*)sqlite3MallocZero( pVfs.szOsFile * 2 ); - pJournal = new sqlite3_file();// (sqlite3_file*)( ( (u8*)pMaster ) + pVfs.szOsFile ); - //if ( null == pMaster ) - //{ - // rc = SQLITE_NOMEM; - //} - //else - { - const int flags = (SQLITE_OPEN_READONLY | SQLITE_OPEN_MASTER_JOURNAL); - int iDummy = 0; - rc = sqlite3OsOpen(pVfs, zMaster, pMaster, flags, ref iDummy); - } - if (rc != SQLITE_OK) - goto delmaster_out; + pPager.sectorSize = (u32)sqlite3OsSectorSize( pPager.fd ); + } + if ( pPager.sectorSize < 32 ) + { + Debug.Assert( MAX_SECTOR_SIZE >= 512 ); + pPager.sectorSize = 512; + } + if ( pPager.sectorSize > MAX_SECTOR_SIZE ) + { + pPager.sectorSize = MAX_SECTOR_SIZE; + } + } - Debugger.Break(); //TODO -- - /* Load the entire master journal file into space obtained from - ** sqlite3_malloc() and pointed to by zMasterJournal. Also obtain - ** sufficient space (in zMasterPtr) to hold the names of master - ** journal files extracted from regular rollback-journals. - */ - //rc = sqlite3OsFileSize(pMaster, &nMasterJournal); - //if (rc != SQLITE_OK) goto delmaster_out; - //nMasterPtr = pVfs.mxPathname + 1; - // zMasterJournal = sqlite3Malloc((int)nMasterJournal + nMasterPtr + 1); - // if ( !zMasterJournal ) - // { - // rc = SQLITE_NOMEM; - // goto delmaster_out; - // } - // zMasterPtr = &zMasterJournal[nMasterJournal+1]; - // rc = sqlite3OsRead( pMaster, zMasterJournal, (int)nMasterJournal, 0 ); - // if ( rc != SQLITE_OK ) goto delmaster_out; - // zMasterJournal[nMasterJournal] = 0; - - - // zJournal = zMasterJournal; - // while ( ( zJournal - zMasterJournal ) < nMasterJournal ) - // { - // int exists; - // rc = sqlite3OsAccess( pVfs, zJournal, SQLITE_ACCESS_EXISTS, &exists ); - // if ( rc != SQLITE_OK ) - // { - // goto delmaster_out; - // } - // if ( exists ) - // { - // /* One of the journals pointed to by the master journal exists. - // ** Open it and check if it points at the master journal. If - // ** so, return without deleting the master journal file. - // */ - // int c; - // int flags = ( SQLITE_OPEN_READONLY | SQLITE_OPEN_MAIN_JOURNAL ); - // rc = sqlite3OsOpen( pVfs, zJournal, pJournal, flags, 0 ); - // if ( rc != SQLITE_OK ) - // { - // goto delmaster_out; - // } - - // rc = readMasterJournal( pJournal, zMasterPtr, nMasterPtr ); - // sqlite3OsClose( pJournal ); - // if ( rc != SQLITE_OK ) - // { - // goto delmaster_out; - // } - - // c = zMasterPtr[0] != 0 && strcmp( zMasterPtr, zMaster ) == 0; - // if ( c ) - // { - // /* We have a match. Do not delete the master journal file. */ - // goto delmaster_out; - // } - // } - // zJournal += ( sqlite3Strlen30( zJournal ) + 1 ); - // } - // - //sqlite3OsClose(pMaster); - //rc = sqlite3OsDelete( pVfs, zMaster, 0 ); - - - goto delmaster_out; - delmaster_out: - //sqlite3_free( ref zMasterJournal ); - if (pMaster != null) { - sqlite3OsClose(pMaster); - Debug.Assert(!isOpen(pJournal)); - //sqlite3_free( ref pMaster ); - } - return rc; - } + /* + ** Playback the journal and thus restore the database file to + ** the state it was in before we started making changes. + ** + ** The journal file format is as follows: + ** + ** (1) 8 byte prefix. A copy of aJournalMagic[]. + ** (2) 4 byte big-endian integer which is the number of valid page records + ** in the journal. If this value is 0xffffffff, then compute the + ** number of page records from the journal size. + ** (3) 4 byte big-endian integer which is the initial value for the + ** sanity checksum. + ** (4) 4 byte integer which is the number of pages to truncate the + ** database to during a rollback. + ** (5) 4 byte big-endian integer which is the sector size. The header + ** is this many bytes in size. + ** (6) 4 byte big-endian integer which is the page size. + ** (7) zero padding out to the next sector size. + ** (8) Zero or more pages instances, each as follows: + ** + ** When we speak of the journal header, we mean the first 7 items above. + ** Each entry in the journal is an instance of the 8th item. + ** + ** Call the value from the second bullet "nRec". nRec is the number of + ** valid page entries in the journal. In most cases, you can compute the + ** value of nRec from the size of the journal file. But if a power + ** failure occurred while the journal was being written, it could be the + ** case that the size of the journal file had already been increased but + ** the extra entries had not yet made it safely to disk. In such a case, + ** the value of nRec computed from the file size would be too large. For + ** that reason, we always use the nRec value in the header. + ** + ** If the nRec value is 0xffffffff it means that nRec should be computed + ** from the file size. This value is used when the user selects the + ** no-sync option for the journal. A power failure could lead to corruption + ** in this case. But for things like temporary table (which will be + ** deleted when the power is restored) we don't care. + ** + ** If the file opened as the journal file is not a well-formed + ** journal file then all pages up to the first corrupted page are rolled + ** back (or no pages if the journal header is corrupted). The journal file + ** is then deleted and SQLITE_OK returned, just as if no corruption had + ** been encountered. + ** + ** If an I/O or malloc() error occurs, the journal-file is not deleted + ** and an error code is returned. + ** + ** The isHot parameter indicates that we are trying to rollback a journal + ** that might be a hot journal. Or, it could be that the journal is + ** preserved because of JOURNALMODE_PERSIST or JOURNALMODE_TRUNCATE. + ** If the journal really is hot, reset the pager cache prior rolling + ** back any content. If the journal is merely persistent, no reset is + ** needed. + */ + static int pager_playback( Pager pPager, int isHot ) + { + sqlite3_vfs pVfs = pPager.pVfs; + i64 szJ = 0; /* Size of the journal file in bytes */ + u32 nRec = 0; /* Number of Records in the journal */ + u32 u; /* Unsigned loop counter */ + u32 mxPg = 0; /* Size of the original file in pages */ + int rc; /* Result code of a subroutine */ + int res = 1; /* Value returned by sqlite3OsAccess() */ + byte[] zMaster = null; /* Name of master journal file if any */ + int needPagerReset; /* True to reset page prior to first page rollback */ + + /* Figure out how many records are in the journal. Abort early if + ** the journal is empty. + */ + Debug.Assert( isOpen( pPager.jfd ) ); + rc = sqlite3OsFileSize( pPager.jfd, ref szJ ); + if ( rc != SQLITE_OK ) + { + goto end_playback; + } + /* Read the master journal name from the journal, if it is present. + ** If a master journal file name is specified, but the file is not + ** present on disk, then the journal is not hot and does not need to be + ** played back. + ** + ** TODO: Technically the following is an error because it assumes that + ** buffer Pager.pTmpSpace is (mxPathname+1) bytes or larger. i.e. that + ** (pPager.pageSize >= pPager.pVfs.mxPathname+1). Using os_unix.c, + ** mxPathname is 512, which is the same as the minimum allowable value + ** for pageSize. + */ + zMaster = new byte[pPager.pVfs.mxPathname + 1];// pPager.pTmpSpace ); + rc = readMasterJournal( pPager.jfd, zMaster, (u32)pPager.pVfs.mxPathname + 1 ); + if ( rc == SQLITE_OK && zMaster[0] != 0 ) + { + rc = sqlite3OsAccess( pVfs, Encoding.UTF8.GetString( zMaster, 0, zMaster.Length ), SQLITE_ACCESS_EXISTS, ref res ); + } + zMaster = null; + if ( rc != SQLITE_OK || res == 0 ) + { + goto end_playback; + } + pPager.journalOff = 0; + needPagerReset = isHot; + /* This loop terminates either when a readJournalHdr() or + ** pager_playback_one_page() call returns SQLITE_DONE or an IO error + ** occurs. + */ + while ( true ) + { - /* - ** This function is used to change the actual size of the database - ** file in the file-system. This only happens when committing a transaction, - ** or rolling back a transaction (including rolling back a hot-journal). - ** - ** If the main database file is not open, or the pager is not in either - ** DBMOD or OPEN state, this function is a no-op. Otherwise, the size - ** of the file is changed to nPage pages (nPage*pPager.pageSize bytes). - ** If the file on disk is currently larger than nPage pages, then use the VFS - ** xTruncate() method to truncate it. - ** - ** Or, it might might be the case that the file on disk is smaller than - ** nPage pages. Some operating system implementations can get confused if - ** you try to truncate a file to some size that is larger than it - ** currently is, so detect this case and write a single zero byte to - ** the end of the new file instead. - ** - ** If successful, return SQLITE_OK. If an IO error occurs while modifying - ** the database file, return the error code to the caller. + /* Read the next journal header from the journal file. If there are + ** not enough bytes left in the journal file for a complete header, or + ** it is corrupted, then a process must have failed while writing it. + ** This indicates nothing more needs to be rolled back. */ - static int pager_truncate(Pager pPager, u32 nPage) { - int rc = SQLITE_OK; - Debug.Assert(pPager.eState != PAGER_ERROR); - Debug.Assert(pPager.eState != PAGER_READER); - - if (isOpen(pPager.fd) - && (pPager.eState >= PAGER_WRITER_DBMOD || pPager.eState == PAGER_OPEN) - ) { - i64 currentSize = 0, newSize; - int szPage = pPager.pageSize; - Debug.Assert(pPager.eLock == EXCLUSIVE_LOCK); - /* TODO: Is it safe to use Pager.dbFileSize here? */ - rc = sqlite3OsFileSize(pPager.fd, ref currentSize); - newSize = szPage * nPage; - if (rc == SQLITE_OK && currentSize != newSize) { - if (currentSize > newSize) { - rc = sqlite3OsTruncate(pPager.fd, newSize); - } else { - byte[] pTmp = pPager.pTmpSpace; - Array.Clear(pTmp, 0, szPage);//memset( pTmp, 0, szPage ); - testcase((newSize - szPage) < currentSize); - testcase((newSize - szPage) == currentSize); - testcase((newSize - szPage) > currentSize); - rc = sqlite3OsWrite(pPager.fd, pTmp, szPage, newSize - szPage); - } - if (rc == SQLITE_OK) { - pPager.dbSize = nPage; - } - } - } - return rc; + rc = readJournalHdr( pPager, isHot, szJ, out nRec, out mxPg ); + if ( rc != SQLITE_OK ) + { + if ( rc == SQLITE_DONE ) + { + rc = SQLITE_OK; + } + goto end_playback; } - /* - ** Set the value of the Pager.sectorSize variable for the given - ** pager based on the value returned by the xSectorSize method - ** of the open database file. The sector size will be used used - ** to determine the size and alignment of journal header and - ** master journal pointers within created journal files. - ** - ** For temporary files the effective sector size is always 512 bytes. - ** - ** Otherwise, for non-temporary files, the effective sector size is - ** the value returned by the xSectorSize() method rounded up to 512 if - ** it is less than 32, or rounded down to MAX_SECTOR_SIZE if it - ** is greater than MAX_SECTOR_SIZE. + /* If nRec is 0xffffffff, then this journal was created by a process + ** working in no-sync mode. This means that the rest of the journal + ** file consists of pages, there are no more journal headers. Compute + ** the value of nRec based on this assumption. */ - static void setSectorSize(Pager pPager) { - Debug.Assert(isOpen(pPager.fd) || pPager.tempFile); - if (!pPager.tempFile) { - /* Sector size doesn't matter for temporary files. Also, the file - ** may not have been opened yet, in which case the OsSectorSize() - ** call will segfault. - */ - pPager.sectorSize = (u32)sqlite3OsSectorSize(pPager.fd); - } - if (pPager.sectorSize < 32) { - Debug.Assert(MAX_SECTOR_SIZE >= 512); - pPager.sectorSize = 512; - } - if (pPager.sectorSize > MAX_SECTOR_SIZE) { - pPager.sectorSize = MAX_SECTOR_SIZE; - } + if ( nRec == 0xffffffff ) + { + Debug.Assert( pPager.journalOff == JOURNAL_HDR_SZ( pPager ) ); + nRec = (u32)( ( szJ - JOURNAL_HDR_SZ( pPager ) ) / JOURNAL_PG_SZ( pPager ) ); } + /* If nRec is 0 and this rollback is of a transaction created by this + ** process and if this is the final header in the journal, then it means + ** that this part of the journal was being filled but has not yet been + ** synced to disk. Compute the number of pages based on the remaining + ** size of the file. + ** + ** The third term of the test was added to fix ticket #2565. + ** When rolling back a hot journal, nRec==0 always means that the next + ** chunk of the journal contains zero pages to be rolled back. But + ** when doing a ROLLBACK and the nRec==0 chunk is the last chunk in + ** the journal, it means that the journal might contain additional + ** pages that need to be rolled back and that the number of pages + ** should be computed based on the journal file size. + */ + if ( nRec == 0 && 0 == isHot && + pPager.journalHdr + JOURNAL_HDR_SZ( pPager ) == pPager.journalOff ) + { + nRec = (u32)( ( szJ - pPager.journalOff ) / JOURNAL_PG_SZ( pPager ) ); + } - /* - ** Playback the journal and thus restore the database file to - ** the state it was in before we started making changes. - ** - ** The journal file format is as follows: - ** - ** (1) 8 byte prefix. A copy of aJournalMagic[]. - ** (2) 4 byte big-endian integer which is the number of valid page records - ** in the journal. If this value is 0xffffffff, then compute the - ** number of page records from the journal size. - ** (3) 4 byte big-endian integer which is the initial value for the - ** sanity checksum. - ** (4) 4 byte integer which is the number of pages to truncate the - ** database to during a rollback. - ** (5) 4 byte big-endian integer which is the sector size. The header - ** is this many bytes in size. - ** (6) 4 byte big-endian integer which is the page size. - ** (7) zero padding out to the next sector size. - ** (8) Zero or more pages instances, each as follows: - ** - ** When we speak of the journal header, we mean the first 7 items above. - ** Each entry in the journal is an instance of the 8th item. - ** - ** Call the value from the second bullet "nRec". nRec is the number of - ** valid page entries in the journal. In most cases, you can compute the - ** value of nRec from the size of the journal file. But if a power - ** failure occurred while the journal was being written, it could be the - ** case that the size of the journal file had already been increased but - ** the extra entries had not yet made it safely to disk. In such a case, - ** the value of nRec computed from the file size would be too large. For - ** that reason, we always use the nRec value in the header. - ** - ** If the nRec value is 0xffffffff it means that nRec should be computed - ** from the file size. This value is used when the user selects the - ** no-sync option for the journal. A power failure could lead to corruption - ** in this case. But for things like temporary table (which will be - ** deleted when the power is restored) we don't care. - ** - ** If the file opened as the journal file is not a well-formed - ** journal file then all pages up to the first corrupted page are rolled - ** back (or no pages if the journal header is corrupted). The journal file - ** is then deleted and SQLITE_OK returned, just as if no corruption had - ** been encountered. - ** - ** If an I/O or malloc() error occurs, the journal-file is not deleted - ** and an error code is returned. - ** - ** The isHot parameter indicates that we are trying to rollback a journal - ** that might be a hot journal. Or, it could be that the journal is - ** preserved because of JOURNALMODE_PERSIST or JOURNALMODE_TRUNCATE. - ** If the journal really is hot, reset the pager cache prior rolling - ** back any content. If the journal is merely persistent, no reset is - ** needed. + /* If this is the first header read from the journal, truncate the + ** database file back to its original size. */ - static int pager_playback(Pager pPager, int isHot) { - sqlite3_vfs pVfs = pPager.pVfs; - i64 szJ = 0; /* Size of the journal file in bytes */ - u32 nRec = 0; /* Number of Records in the journal */ - u32 u; /* Unsigned loop counter */ - u32 mxPg = 0; /* Size of the original file in pages */ - int rc; /* Result code of a subroutine */ - int res = 1; /* Value returned by sqlite3OsAccess() */ - byte[] zMaster = null; /* Name of master journal file if any */ - int needPagerReset; /* True to reset page prior to first page rollback */ - - /* Figure out how many records are in the journal. Abort early if - ** the journal is empty. - */ - Debug.Assert(isOpen(pPager.jfd)); - rc = sqlite3OsFileSize(pPager.jfd, ref szJ); - if (rc != SQLITE_OK) { - goto end_playback; - } + if ( pPager.journalOff == JOURNAL_HDR_SZ( pPager ) ) + { + rc = pager_truncate( pPager, mxPg ); + if ( rc != SQLITE_OK ) + { + goto end_playback; + } + pPager.dbSize = mxPg; + } - /* Read the master journal name from the journal, if it is present. - ** If a master journal file name is specified, but the file is not - ** present on disk, then the journal is not hot and does not need to be - ** played back. - ** - ** TODO: Technically the following is an error because it assumes that - ** buffer Pager.pTmpSpace is (mxPathname+1) bytes or larger. i.e. that - ** (pPager.pageSize >= pPager.pVfs.mxPathname+1). Using os_unix.c, - ** mxPathname is 512, which is the same as the minimum allowable value - ** for pageSize. - */ - zMaster = new byte[pPager.pVfs.mxPathname + 1];// pPager.pTmpSpace ); - rc = readMasterJournal(pPager.jfd, zMaster, (u32)pPager.pVfs.mxPathname + 1); - if (rc == SQLITE_OK && zMaster[0] != 0) { - rc = sqlite3OsAccess(pVfs, Encoding.UTF8.GetString(zMaster, 0, zMaster.Length), SQLITE_ACCESS_EXISTS, ref res); + /* Copy original pages out of the journal and back into the + ** database file and/or page cache. + */ + for ( u = 0; u < nRec; u++ ) + { + if ( needPagerReset != 0 ) + { + pager_reset( pPager ); + needPagerReset = 0; + } + rc = pager_playback_one_page( pPager, ref pPager.journalOff, null, 1, 0 ); + if ( rc != SQLITE_OK ) + { + if ( rc == SQLITE_DONE ) + { + rc = SQLITE_OK; + pPager.journalOff = szJ; + break; } - zMaster = null; - if (rc != SQLITE_OK || res == 0) { - goto end_playback; + else if ( rc == SQLITE_IOERR_SHORT_READ ) + { + /* If the journal has been truncated, simply stop reading and + ** processing the journal. This might happen if the journal was + ** not completely written and synced prior to a crash. In that + ** case, the database should have never been written in the + ** first place so it is OK to simply abandon the rollback. */ + rc = SQLITE_OK; + goto end_playback; + } + else + { + /* If we are unable to rollback, quit and return the error + ** code. This will cause the pager to enter the error state + ** so that no further harm will be done. Perhaps the next + ** process to come along will be able to rollback the database. + */ + goto end_playback; } - pPager.journalOff = 0; - needPagerReset = isHot; - - /* This loop terminates either when a readJournalHdr() or - ** pager_playback_one_page() call returns SQLITE_DONE or an IO error - ** occurs. - */ - while (true) { - - /* Read the next journal header from the journal file. If there are - ** not enough bytes left in the journal file for a complete header, or - ** it is corrupted, then a process must have failed while writing it. - ** This indicates nothing more needs to be rolled back. - */ - rc = readJournalHdr(pPager, isHot, szJ, out nRec, out mxPg); - if (rc != SQLITE_OK) { - if (rc == SQLITE_DONE) { - rc = SQLITE_OK; - } - goto end_playback; - } - - /* If nRec is 0xffffffff, then this journal was created by a process - ** working in no-sync mode. This means that the rest of the journal - ** file consists of pages, there are no more journal headers. Compute - ** the value of nRec based on this assumption. - */ - if (nRec == 0xffffffff) { - Debug.Assert(pPager.journalOff == JOURNAL_HDR_SZ(pPager)); - nRec = (u32)((szJ - JOURNAL_HDR_SZ(pPager)) / JOURNAL_PG_SZ(pPager)); - } - - /* If nRec is 0 and this rollback is of a transaction created by this - ** process and if this is the final header in the journal, then it means - ** that this part of the journal was being filled but has not yet been - ** synced to disk. Compute the number of pages based on the remaining - ** size of the file. - ** - ** The third term of the test was added to fix ticket #2565. - ** When rolling back a hot journal, nRec==0 always means that the next - ** chunk of the journal contains zero pages to be rolled back. But - ** when doing a ROLLBACK and the nRec==0 chunk is the last chunk in - ** the journal, it means that the journal might contain additional - ** pages that need to be rolled back and that the number of pages - ** should be computed based on the journal file size. - */ - if (nRec == 0 && 0 == isHot && - pPager.journalHdr + JOURNAL_HDR_SZ(pPager) == pPager.journalOff) { - nRec = (u32)((szJ - pPager.journalOff) / JOURNAL_PG_SZ(pPager)); - } - - /* If this is the first header read from the journal, truncate the - ** database file back to its original size. - */ - if (pPager.journalOff == JOURNAL_HDR_SZ(pPager)) { - rc = pager_truncate(pPager, mxPg); - if (rc != SQLITE_OK) { - goto end_playback; - } - pPager.dbSize = mxPg; - } + } + } + } +/*NOTREACHED*/ - /* Copy original pages out of the journal and back into the - ** database file and/or page cache. - */ - for (u = 0; u < nRec; u++) { - if (needPagerReset != 0) { - pager_reset(pPager); - needPagerReset = 0; - } - rc = pager_playback_one_page(pPager, ref pPager.journalOff, null, 1, 0); - if (rc != SQLITE_OK) { - if (rc == SQLITE_DONE) { - rc = SQLITE_OK; - pPager.journalOff = szJ; - break; - } else if (rc == SQLITE_IOERR_SHORT_READ) { - /* If the journal has been truncated, simply stop reading and - ** processing the journal. This might happen if the journal was - ** not completely written and synced prior to a crash. In that - ** case, the database should have never been written in the - ** first place so it is OK to simply abandon the rollback. */ - rc = SQLITE_OK; - goto end_playback; - } else { - /* If we are unable to rollback, quit and return the error - ** code. This will cause the pager to enter the error state - ** so that no further harm will be done. Perhaps the next - ** process to come along will be able to rollback the database. - */ - goto end_playback; - } - } - } - } - /*NOTREACHED*/ + end_playback: + /* Following a rollback, the database file should be back in its original + ** state prior to the start of the transaction, so invoke the + ** SQLITE_FCNTL_DB_UNCHANGED file-control method to disable the + ** assertion that the transaction counter was modified. + */ + sqlite3_int64 iDummy = 0; + Debug.Assert( + pPager.fd.pMethods == null || + sqlite3OsFileControl( pPager.fd, SQLITE_FCNTL_DB_UNCHANGED, ref iDummy ) >= SQLITE_OK + ); - end_playback: - /* Following a rollback, the database file should be back in its original - ** state prior to the start of the transaction, so invoke the - ** SQLITE_FCNTL_DB_UNCHANGED file-control method to disable the - ** assertion that the transaction counter was modified. - */ - sqlite3_int64 iDummy = 0; - Debug.Assert( - pPager.fd.pMethods == null || - sqlite3OsFileControl(pPager.fd, SQLITE_FCNTL_DB_UNCHANGED, ref iDummy) >= SQLITE_OK - ); + /* If this playback is happening automatically as a result of an IO or + ** malloc error that occurred after the change-counter was updated but + ** before the transaction was committed, then the change-counter + ** modification may just have been reverted. If this happens in exclusive + ** mode, then subsequent transactions performed by the connection will not + ** update the change-counter at all. This may lead to cache inconsistency + ** problems for other processes at some point in the future. So, just + ** in case this has happened, clear the changeCountDone flag now. + */ + pPager.changeCountDone = pPager.tempFile; - /* If this playback is happening automatically as a result of an IO or - ** malloc error that occurred after the change-counter was updated but - ** before the transaction was committed, then the change-counter - ** modification may just have been reverted. If this happens in exclusive - ** mode, then subsequent transactions performed by the connection will not - ** update the change-counter at all. This may lead to cache inconsistency - ** problems for other processes at some point in the future. So, just - ** in case this has happened, clear the changeCountDone flag now. - */ - pPager.changeCountDone = pPager.tempFile; + if ( rc == SQLITE_OK ) + { + zMaster = new byte[pPager.pVfs.mxPathname + 1];//pPager.pTmpSpace ); + rc = readMasterJournal( pPager.jfd, zMaster, (u32)pPager.pVfs.mxPathname + 1 ); + testcase( rc != SQLITE_OK ); + } + if ( rc == SQLITE_OK + && ( pPager.eState >= PAGER_WRITER_DBMOD || pPager.eState == PAGER_OPEN ) + ) + { + rc = sqlite3PagerSync( pPager ); + } + if ( rc == SQLITE_OK ) + { + rc = pager_end_transaction( pPager, zMaster[0] != '\0' ? 1 : 0 ); + testcase( rc != SQLITE_OK ); + } + if ( rc == SQLITE_OK && zMaster[0] != '\0' && res != 0 ) + { + /* If there was a master journal and this routine will return success, + ** see if it is possible to delete the master journal. + */ + rc = pager_delmaster( pPager, Encoding.UTF8.GetString( zMaster, 0, zMaster.Length ) ); + testcase( rc != SQLITE_OK ); + } - if (rc == SQLITE_OK) { - zMaster = new byte[pPager.pVfs.mxPathname + 1];//pPager.pTmpSpace ); - rc = readMasterJournal(pPager.jfd, zMaster, (u32)pPager.pVfs.mxPathname + 1); - testcase(rc != SQLITE_OK); - } - if (rc == SQLITE_OK - && (pPager.eState >= PAGER_WRITER_DBMOD || pPager.eState == PAGER_OPEN) - ) { - rc = sqlite3PagerSync(pPager); - } - if (rc == SQLITE_OK) { - rc = pager_end_transaction(pPager, zMaster[0] != '\0' ? 1 : 0); - testcase(rc != SQLITE_OK); - } - if (rc == SQLITE_OK && zMaster[0] != '\0' && res != 0) { - /* If there was a master journal and this routine will return success, - ** see if it is possible to delete the master journal. - */ - rc = pager_delmaster(pPager, Encoding.UTF8.GetString(zMaster, 0, zMaster.Length)); - testcase(rc != SQLITE_OK); - } + /* The Pager.sectorSize variable may have been updated while rolling + ** back a journal created by a process with a different sector size + ** value. Reset it to the correct value for this process. + */ + setSectorSize( pPager ); + return rc; + } - /* The Pager.sectorSize variable may have been updated while rolling - ** back a journal created by a process with a different sector size - ** value. Reset it to the correct value for this process. - */ - setSectorSize(pPager); - return rc; - } + /* + ** Read the content for page pPg out of the database file and into + ** pPg.pData. A shared lock or greater must be held on the database + ** file before this function is called. + ** + ** If page 1 is read, then the value of Pager.dbFileVers[] is set to + ** the value read from the database file. + ** + ** If an IO error occurs, then the IO error is returned to the caller. + ** Otherwise, SQLITE_OK is returned. + */ + static int readDbPage( PgHdr pPg ) + { + Pager pPager = pPg.pPager; /* Pager object associated with page pPg */ + Pgno pgno = pPg.pgno; /* Page number to read */ + int rc = SQLITE_OK; /* Return code */ + int isInWal = 0; /* True if page is in log file */ + int pgsz = pPager.pageSize; /* Number of bytes to read */ - /* - ** Read the content for page pPg out of the database file and into - ** pPg.pData. A shared lock or greater must be held on the database - ** file before this function is called. - ** - ** If page 1 is read, then the value of Pager.dbFileVers[] is set to - ** the value read from the database file. - ** - ** If an IO error occurs, then the IO error is returned to the caller. - ** Otherwise, SQLITE_OK is returned. - */ - static int readDbPage(PgHdr pPg) { - Pager pPager = pPg.pPager; /* Pager object associated with page pPg */ - Pgno pgno = pPg.pgno; /* Page number to read */ - int rc = SQLITE_OK; /* Return code */ - int isInWal = 0; /* True if page is in log file */ - int pgsz = pPager.pageSize; /* Number of bytes to read */ - - Debug.Assert(pPager.eState >= PAGER_READER && + Debug.Assert( pPager.eState >= PAGER_READER && #if SQLITE_OMIT_MEMORYDB 0 == MEMDB #else - 0 == pPager.memDb + 0 == pPager.memDb #endif - ); - Debug.Assert(isOpen(pPager.fd)); + ); + Debug.Assert( isOpen( pPager.fd ) ); - if (NEVER(!isOpen(pPager.fd))) { - Debug.Assert(pPager.tempFile); - Array.Clear(pPg.pData, 0, pPager.pageSize);// memset(pPg.pData, 0, pPager.pageSize); - return SQLITE_OK; - } + if ( NEVER( !isOpen( pPager.fd ) ) ) + { + Debug.Assert( pPager.tempFile ); + Array.Clear( pPg.pData, 0, pPager.pageSize );// memset(pPg.pData, 0, pPager.pageSize); + return SQLITE_OK; + } - if (pagerUseWal(pPager)) { - /* Try to pull the page from the write-ahead log. */ - rc = sqlite3WalRead(pPager.pWal, pgno, ref isInWal, pgsz, pPg.pData); - } - if (rc == SQLITE_OK && 0 == isInWal) { - i64 iOffset = (pgno - 1) * (i64)pPager.pageSize; - rc = sqlite3OsRead(pPager.fd, pPg.pData, pgsz, iOffset); - if (rc == SQLITE_IOERR_SHORT_READ) { - rc = SQLITE_OK; - } - } + if ( pagerUseWal( pPager ) ) + { + /* Try to pull the page from the write-ahead log. */ + rc = sqlite3WalRead( pPager.pWal, pgno, ref isInWal, pgsz, pPg.pData ); + } + if ( rc == SQLITE_OK && 0 == isInWal ) + { + i64 iOffset = ( pgno - 1 ) * (i64)pPager.pageSize; + rc = sqlite3OsRead( pPager.fd, pPg.pData, pgsz, iOffset ); + if ( rc == SQLITE_IOERR_SHORT_READ ) + { + rc = SQLITE_OK; + } + } - if (pgno == 1) { - if (rc != 0) { - /* If the read is unsuccessful, set the dbFileVers[] to something - ** that will never be a valid file version. dbFileVers[] is a copy - ** of bytes 24..39 of the database. Bytes 28..31 should always be - ** zero or the size of the database in page. Bytes 32..35 and 35..39 - ** should be page numbers which are never 0xffffffff. So filling - ** pPager.dbFileVers[] with all 0xff bytes should suffice. - ** - ** For an encrypted database, the situation is more complex: bytes - ** 24..39 of the database are white noise. But the probability of - ** white noising equaling 16 bytes of 0xff is vanishingly small so - ** we should still be ok. - */ - for (int i = 0; i < pPager.dbFileVers.Length; pPager.dbFileVers[i++] = 0xff) - ; // memset(pPager.dbFileVers, 0xff, sizeof(pPager.dbFileVers)); - } else { - //u8[] dbFileVers = pPg.pData[24]; - Buffer.BlockCopy(pPg.pData, 24, pPager.dbFileVers, 0, pPager.dbFileVers.Length); //memcpy(&pPager.dbFileVers, dbFileVers, sizeof(pPager.dbFileVers)); - } - } - if (CODEC1(pPager, pPg.pData, pgno, SQLITE_DECRYPT)) - rc = SQLITE_NOMEM;//CODEC1(pPager, pPg.pData, pgno, 3, rc = SQLITE_NOMEM); + if ( pgno == 1 ) + { + if ( rc != 0 ) + { + /* If the read is unsuccessful, set the dbFileVers[] to something + ** that will never be a valid file version. dbFileVers[] is a copy + ** of bytes 24..39 of the database. Bytes 28..31 should always be + ** zero or the size of the database in page. Bytes 32..35 and 35..39 + ** should be page numbers which are never 0xffffffff. So filling + ** pPager.dbFileVers[] with all 0xff bytes should suffice. + ** + ** For an encrypted database, the situation is more complex: bytes + ** 24..39 of the database are white noise. But the probability of + ** white noising equaling 16 bytes of 0xff is vanishingly small so + ** we should still be ok. + */ + for ( int i = 0; i < pPager.dbFileVers.Length; pPager.dbFileVers[i++] = 0xff ) + ; // memset(pPager.dbFileVers, 0xff, sizeof(pPager.dbFileVers)); + } + else + { + //u8[] dbFileVers = pPg.pData[24]; + Buffer.BlockCopy( pPg.pData, 24, pPager.dbFileVers, 0, pPager.dbFileVers.Length ); //memcpy(&pPager.dbFileVers, dbFileVers, sizeof(pPager.dbFileVers)); + } + } + if ( CODEC1( pPager, pPg.pData, pgno, SQLITE_DECRYPT ) ) + rc = SQLITE_NOMEM;//CODEC1(pPager, pPg.pData, pgno, 3, rc = SQLITE_NOMEM); #if SQLITE_TEST // PAGER_INCR(ref sqlite3_pager_readdb_count); @@ -3090,34 +3277,35 @@ static int readDbPage(PgHdr pPg) { PAGER_INCR( ref pPager.nRead ); #endif - IOTRACE("PGIN %p %d\n", pPager, pgno); - PAGERTRACE("FETCH %d page %d hash(%08x)\n", - PAGERID(pPager), pgno, pager_pagehash(pPg)); + IOTRACE( "PGIN %p %d\n", pPager, pgno ); + PAGERTRACE( "FETCH %d page %d hash(%08x)\n", + PAGERID( pPager ), pgno, pager_pagehash( pPg ) ); - return rc; - } + return rc; + } - /* - ** Update the value of the change-counter at offsets 24 and 92 in - ** the header and the sqlite version number at offset 96. - ** - ** This is an unconditional update. See also the pager_incr_changecounter() - ** routine which only updates the change-counter if the update is actually - ** needed, as determined by the pPager.changeCountDone state variable. - */ - static void pager_write_changecounter(PgHdr pPg) { - u32 change_counter; - - /* Increment the value just read and write it back to byte 24. */ - change_counter = sqlite3Get4byte(pPg.pPager.dbFileVers, 0) + 1; - put32bits(pPg.pData, 24, change_counter); - - /* Also store the SQLite version number in bytes 96..99 and in - ** bytes 92..95 store the change counter for which the version number - ** is valid. */ - put32bits(pPg.pData, 92, change_counter); - put32bits(pPg.pData, 96, SQLITE_VERSION_NUMBER); - } + /* + ** Update the value of the change-counter at offsets 24 and 92 in + ** the header and the sqlite version number at offset 96. + ** + ** This is an unconditional update. See also the pager_incr_changecounter() + ** routine which only updates the change-counter if the update is actually + ** needed, as determined by the pPager.changeCountDone state variable. + */ + static void pager_write_changecounter( PgHdr pPg ) + { + u32 change_counter; + + /* Increment the value just read and write it back to byte 24. */ + change_counter = sqlite3Get4byte( pPg.pPager.dbFileVers, 0 ) + 1; + put32bits( pPg.pData, 24, change_counter ); + + /* Also store the SQLite version number in bytes 96..99 and in + ** bytes 92..95 store the change counter for which the version number + ** is valid. */ + put32bits( pPg.pData, 92, change_counter ); + put32bits( pPg.pData, 96, SQLITE_VERSION_NUMBER ); + } #if !SQLITE_OMIT_WAL /* @@ -3285,60 +3473,66 @@ static int pagerBeginReadTransaction(Pager *pPager){ } #endif - /* - ** This function is called as part of the transition from PAGER_OPEN - ** to PAGER_READER state to determine the size of the database file - ** in pages (assuming the page size currently stored in Pager.pageSize). - ** - ** If no error occurs, SQLITE_OK is returned and the size of the database - ** in pages is stored in *pnPage. Otherwise, an error code (perhaps - ** SQLITE_IOERR_FSTAT) is returned and *pnPage is left unmodified. - */ - static int pagerPagecount(Pager pPager, ref Pgno pnPage) { - Pgno nPage; /* Value to return via *pnPage */ - - /* Query the WAL sub-system for the database size. The WalDbsize() - ** function returns zero if the WAL is not open (i.e. Pager.pWal==0), or - ** if the database size is not available. The database size is not - ** available from the WAL sub-system if the log file is empty or - ** contains no valid committed transactions. - */ - Debug.Assert(pPager.eState == PAGER_OPEN); - Debug.Assert(pPager.eLock >= SHARED_LOCK || pPager.noReadlock != 0); - nPage = sqlite3WalDbsize(pPager.pWal); - - /* If the database size was not available from the WAL sub-system, - ** determine it based on the size of the database file. If the size - ** of the database file is not an integer multiple of the page-size, - ** round down to the nearest page. Except, any file larger than 0 - ** bytes in size is considered to contain at least one page. - */ - if (nPage == 0) { - i64 n = 0; /* Size of db file in bytes */ - Debug.Assert(isOpen(pPager.fd) || pPager.tempFile); - if (isOpen(pPager.fd)) { - int rc = sqlite3OsFileSize(pPager.fd, ref n); - if (rc != SQLITE_OK) { - return rc; - } - } - nPage = (Pgno)(n / pPager.pageSize); - if (nPage == 0 && n > 0) { - nPage = 1; - } - } - - /* If the current number of pages in the file is greater than the - ** configured maximum pager number, increase the allowed limit so - ** that the file can be read. - */ - if (nPage > pPager.mxPgno) { - pPager.mxPgno = (Pgno)nPage; - } + /* + ** This function is called as part of the transition from PAGER_OPEN + ** to PAGER_READER state to determine the size of the database file + ** in pages (assuming the page size currently stored in Pager.pageSize). + ** + ** If no error occurs, SQLITE_OK is returned and the size of the database + ** in pages is stored in *pnPage. Otherwise, an error code (perhaps + ** SQLITE_IOERR_FSTAT) is returned and *pnPage is left unmodified. + */ + static int pagerPagecount( Pager pPager, ref Pgno pnPage ) + { + Pgno nPage; /* Value to return via *pnPage */ - pnPage = nPage; - return SQLITE_OK; + /* Query the WAL sub-system for the database size. The WalDbsize() + ** function returns zero if the WAL is not open (i.e. Pager.pWal==0), or + ** if the database size is not available. The database size is not + ** available from the WAL sub-system if the log file is empty or + ** contains no valid committed transactions. + */ + Debug.Assert( pPager.eState == PAGER_OPEN ); + Debug.Assert( pPager.eLock >= SHARED_LOCK || pPager.noReadlock != 0 ); + nPage = sqlite3WalDbsize( pPager.pWal ); + + /* If the database size was not available from the WAL sub-system, + ** determine it based on the size of the database file. If the size + ** of the database file is not an integer multiple of the page-size, + ** round down to the nearest page. Except, any file larger than 0 + ** bytes in size is considered to contain at least one page. + */ + if ( nPage == 0 ) + { + i64 n = 0; /* Size of db file in bytes */ + Debug.Assert( isOpen( pPager.fd ) || pPager.tempFile ); + if ( isOpen( pPager.fd ) ) + { + int rc = sqlite3OsFileSize( pPager.fd, ref n ); + if ( rc != SQLITE_OK ) + { + return rc; + } } + nPage = (Pgno)( n / pPager.pageSize ); + if ( nPage == 0 && n > 0 ) + { + nPage = 1; + } + } + + /* If the current number of pages in the file is greater than the + ** configured maximum pager number, increase the allowed limit so + ** that the file can be read. + */ + if ( nPage > pPager.mxPgno ) + { + pPager.mxPgno = (Pgno)nPage; + } + + pnPage = nPage; + return SQLITE_OK; + } #if !SQLITE_OMIT_WAL @@ -3392,232 +3586,255 @@ static int pagerOpenWalIfPresent(Pager *pPager){ } #endif - /* - ** Playback savepoint pSavepoint. Or, if pSavepoint==NULL, then playback - ** the entire master journal file. The case pSavepoint==NULL occurs when - ** a ROLLBACK TO command is invoked on a SAVEPOINT that is a transaction - ** savepoint. - ** - ** When pSavepoint is not NULL (meaning a non-transaction savepoint is - ** being rolled back), then the rollback consists of up to three stages, - ** performed in the order specified: - ** - ** * Pages are played back from the main journal starting at byte - ** offset PagerSavepoint.iOffset and continuing to - ** PagerSavepoint.iHdrOffset, or to the end of the main journal - ** file if PagerSavepoint.iHdrOffset is zero. - ** - ** * If PagerSavepoint.iHdrOffset is not zero, then pages are played - ** back starting from the journal header immediately following - ** PagerSavepoint.iHdrOffset to the end of the main journal file. - ** - ** * Pages are then played back from the sub-journal file, starting - ** with the PagerSavepoint.iSubRec and continuing to the end of - ** the journal file. - ** - ** Throughout the rollback process, each time a page is rolled back, the - ** corresponding bit is set in a bitvec structure (variable pDone in the - ** implementation below). This is used to ensure that a page is only - ** rolled back the first time it is encountered in either journal. - ** - ** If pSavepoint is NULL, then pages are only played back from the main - ** journal file. There is no need for a bitvec in this case. - ** - ** In either case, before playback commences the Pager.dbSize variable - ** is reset to the value that it held at the start of the savepoint - ** (or transaction). No page with a page-number greater than this value - ** is played back. If one is encountered it is simply skipped. - */ - static int pagerPlaybackSavepoint(Pager pPager, PagerSavepoint pSavepoint) { - i64 szJ; /* Effective size of the main journal */ - i64 iHdrOff; /* End of first segment of main-journal records */ - int rc = SQLITE_OK; /* Return code */ - Bitvec pDone = null; /* Bitvec to ensure pages played back only once */ - - Debug.Assert(pPager.eState != PAGER_ERROR); - Debug.Assert(pPager.eState >= PAGER_WRITER_LOCKED); - - - /* Allocate a bitvec to use to store the set of pages rolled back */ - if (pSavepoint != null) { - pDone = sqlite3BitvecCreate(pSavepoint.nOrig); - //if ( null == pDone ) - //{ - // return SQLITE_NOMEM; - //} - } + /* +** Playback savepoint pSavepoint. Or, if pSavepoint==NULL, then playback +** the entire master journal file. The case pSavepoint==NULL occurs when +** a ROLLBACK TO command is invoked on a SAVEPOINT that is a transaction +** savepoint. +** +** When pSavepoint is not NULL (meaning a non-transaction savepoint is +** being rolled back), then the rollback consists of up to three stages, +** performed in the order specified: +** +** * Pages are played back from the main journal starting at byte +** offset PagerSavepoint.iOffset and continuing to +** PagerSavepoint.iHdrOffset, or to the end of the main journal +** file if PagerSavepoint.iHdrOffset is zero. +** +** * If PagerSavepoint.iHdrOffset is not zero, then pages are played +** back starting from the journal header immediately following +** PagerSavepoint.iHdrOffset to the end of the main journal file. +** +** * Pages are then played back from the sub-journal file, starting +** with the PagerSavepoint.iSubRec and continuing to the end of +** the journal file. +** +** Throughout the rollback process, each time a page is rolled back, the +** corresponding bit is set in a bitvec structure (variable pDone in the +** implementation below). This is used to ensure that a page is only +** rolled back the first time it is encountered in either journal. +** +** If pSavepoint is NULL, then pages are only played back from the main +** journal file. There is no need for a bitvec in this case. +** +** In either case, before playback commences the Pager.dbSize variable +** is reset to the value that it held at the start of the savepoint +** (or transaction). No page with a page-number greater than this value +** is played back. If one is encountered it is simply skipped. +*/ + static int pagerPlaybackSavepoint( Pager pPager, PagerSavepoint pSavepoint ) + { + i64 szJ; /* Effective size of the main journal */ + i64 iHdrOff; /* End of first segment of main-journal records */ + int rc = SQLITE_OK; /* Return code */ + Bitvec pDone = null; /* Bitvec to ensure pages played back only once */ - /* Set the database size back to the value it was before the savepoint - ** being reverted was opened. - */ - pPager.dbSize = pSavepoint != null ? pSavepoint.nOrig : pPager.dbOrigSize; - pPager.changeCountDone = pPager.tempFile; + Debug.Assert( pPager.eState != PAGER_ERROR ); + Debug.Assert( pPager.eState >= PAGER_WRITER_LOCKED ); - if (!pSavepoint && pagerUseWal(pPager)) { - return pagerRollbackWal(pPager); - } - /* Use pPager.journalOff as the effective size of the main rollback - ** journal. The actual file might be larger than this in - ** PAGER_JOURNALMODE_TRUNCATE or PAGER_JOURNALMODE_PERSIST. But anything - ** past pPager.journalOff is off-limits to us. - */ - szJ = pPager.journalOff; - Debug.Assert(pagerUseWal(pPager) == false || szJ == 0); - - /* Begin by rolling back records from the main journal starting at - ** PagerSavepoint.iOffset and continuing to the next journal header. - ** There might be records in the main journal that have a page number - ** greater than the current database size (pPager.dbSize) but those - ** will be skipped automatically. Pages are added to pDone as they - ** are played back. - */ - if (pSavepoint != null && !pagerUseWal(pPager)) { - iHdrOff = pSavepoint.iHdrOffset != 0 ? pSavepoint.iHdrOffset : szJ; - pPager.journalOff = pSavepoint.iOffset; - while (rc == SQLITE_OK && pPager.journalOff < iHdrOff) { - rc = pager_playback_one_page(pPager, ref pPager.journalOff, pDone, 1, 1); - } - Debug.Assert(rc != SQLITE_DONE); - } else { - pPager.journalOff = 0; - } + /* Allocate a bitvec to use to store the set of pages rolled back */ + if ( pSavepoint != null ) + { + pDone = sqlite3BitvecCreate( pSavepoint.nOrig ); + //if ( null == pDone ) + //{ + // return SQLITE_NOMEM; + //} + } - /* Continue rolling back records out of the main journal starting at - ** the first journal header seen and continuing until the effective end - ** of the main journal file. Continue to skip out-of-range pages and - ** continue adding pages rolled back to pDone. - */ - while (rc == SQLITE_OK && pPager.journalOff < szJ) { - u32 ii; /* Loop counter */ - u32 nJRec; /* Number of Journal Records */ - u32 dummy; - rc = readJournalHdr(pPager, 0, (int)szJ, out nJRec, out dummy); - Debug.Assert(rc != SQLITE_DONE); - - /* - ** The "pPager.journalHdr+JOURNAL_HDR_SZ(pPager)==pPager.journalOff" - ** test is related to ticket #2565. See the discussion in the - ** pager_playback() function for additional information. - */ - if (nJRec == 0 - && pPager.journalHdr + JOURNAL_HDR_SZ(pPager) >= pPager.journalOff - ) { - nJRec = (u32)((szJ - pPager.journalOff) / JOURNAL_PG_SZ(pPager)); - } - for (ii = 0; rc == SQLITE_OK && ii < nJRec && pPager.journalOff < szJ; ii++) { - rc = pager_playback_one_page(pPager, ref pPager.journalOff, pDone, 1, 1); - } - Debug.Assert(rc != SQLITE_DONE); - } - Debug.Assert(rc != SQLITE_OK || pPager.journalOff >= szJ); + /* Set the database size back to the value it was before the savepoint + ** being reverted was opened. + */ + pPager.dbSize = pSavepoint != null ? pSavepoint.nOrig : pPager.dbOrigSize; + pPager.changeCountDone = pPager.tempFile; - /* Finally, rollback pages from the sub-journal. Page that were - ** previously rolled back out of the main journal (and are hence in pDone) - ** will be skipped. Out-of-range pages are also skipped. - */ - if (pSavepoint != null) { - u32 ii; /* Loop counter */ - i64 offset = pSavepoint.iSubRec * (4 + pPager.pageSize); - if (pagerUseWal(pPager)) { - rc = sqlite3WalSavepointUndo(pPager.pWal, pSavepoint.aWalData); - } - for (ii = pSavepoint.iSubRec; rc == SQLITE_OK && ii < pPager.nSubRec; ii++) { - Debug.Assert(offset == ii * (4 + pPager.pageSize)); - rc = pager_playback_one_page(pPager, ref offset, pDone, 0, 1); - } - Debug.Assert(rc != SQLITE_DONE); - } + if ( !pSavepoint && pagerUseWal( pPager ) ) + { + return pagerRollbackWal( pPager ); + } - sqlite3BitvecDestroy(ref pDone); - if (rc == SQLITE_OK) { - pPager.journalOff = (int)szJ; - } - return rc; + /* Use pPager.journalOff as the effective size of the main rollback + ** journal. The actual file might be larger than this in + ** PAGER_JOURNALMODE_TRUNCATE or PAGER_JOURNALMODE_PERSIST. But anything + ** past pPager.journalOff is off-limits to us. + */ + szJ = pPager.journalOff; + Debug.Assert( pagerUseWal( pPager ) == false || szJ == 0 ); + + /* Begin by rolling back records from the main journal starting at + ** PagerSavepoint.iOffset and continuing to the next journal header. + ** There might be records in the main journal that have a page number + ** greater than the current database size (pPager.dbSize) but those + ** will be skipped automatically. Pages are added to pDone as they + ** are played back. + */ + if ( pSavepoint != null && !pagerUseWal( pPager ) ) + { + iHdrOff = pSavepoint.iHdrOffset != 0 ? pSavepoint.iHdrOffset : szJ; + pPager.journalOff = pSavepoint.iOffset; + while ( rc == SQLITE_OK && pPager.journalOff < iHdrOff ) + { + rc = pager_playback_one_page( pPager, ref pPager.journalOff, pDone, 1, 1 ); } + Debug.Assert( rc != SQLITE_DONE ); + } + else + { + pPager.journalOff = 0; + } + + /* Continue rolling back records out of the main journal starting at + ** the first journal header seen and continuing until the effective end + ** of the main journal file. Continue to skip out-of-range pages and + ** continue adding pages rolled back to pDone. + */ + while ( rc == SQLITE_OK && pPager.journalOff < szJ ) + { + u32 ii; /* Loop counter */ + u32 nJRec; /* Number of Journal Records */ + u32 dummy; + rc = readJournalHdr( pPager, 0, (int)szJ, out nJRec, out dummy ); + Debug.Assert( rc != SQLITE_DONE ); /* - ** Change the maximum number of in-memory pages that are allowed. + ** The "pPager.journalHdr+JOURNAL_HDR_SZ(pPager)==pPager.journalOff" + ** test is related to ticket #2565. See the discussion in the + ** pager_playback() function for additional information. */ - static void sqlite3PagerSetCachesize(Pager pPager, int mxPage) { - sqlite3PcacheSetCachesize(pPager.pPCache, mxPage); + if ( nJRec == 0 + && pPager.journalHdr + JOURNAL_HDR_SZ( pPager ) >= pPager.journalOff + ) + { + nJRec = (u32)( ( szJ - pPager.journalOff ) / JOURNAL_PG_SZ( pPager ) ); + } + for ( ii = 0; rc == SQLITE_OK && ii < nJRec && pPager.journalOff < szJ; ii++ ) + { + rc = pager_playback_one_page( pPager, ref pPager.journalOff, pDone, 1, 1 ); } + Debug.Assert( rc != SQLITE_DONE ); + } + Debug.Assert( rc != SQLITE_OK || pPager.journalOff >= szJ ); - /* - ** Adjust the robustness of the database to damage due to OS crashes - ** or power failures by changing the number of syncs()s when writing - ** the rollback journal. There are three levels: - ** - ** OFF sqlite3OsSync() is never called. This is the default - ** for temporary and transient files. - ** - ** NORMAL The journal is synced once before writes begin on the - ** database. This is normally adequate protection, but - ** it is theoretically possible, though very unlikely, - ** that an inopertune power failure could leave the journal - ** in a state which would cause damage to the database - ** when it is rolled back. - ** - ** FULL The journal is synced twice before writes begin on the - ** database (with some additional information - the nRec field - ** of the journal header - being written in between the two - ** syncs). If we assume that writing a - ** single disk sector is atomic, then this mode provides - ** assurance that the journal will not be corrupted to the - ** point of causing damage to the database during rollback. - ** - ** The above is for a rollback-journal mode. For WAL mode, OFF continues - ** to mean that no syncs ever occur. NORMAL means that the WAL is synced - ** prior to the start of checkpoint and that the database file is synced - ** at the conclusion of the checkpoint if the entire content of the WAL - ** was written back into the database. But no sync operations occur for - ** an ordinary commit in NORMAL mode with WAL. FULL means that the WAL - ** file is synced following each commit operation, in addition to the - ** syncs associated with NORMAL. - ** - ** Do not confuse synchronous=FULL with SQLITE_SYNC_FULL. The - ** SQLITE_SYNC_FULL macro means to use the MacOSX-style full-fsync - ** using fcntl(F_FULLFSYNC). SQLITE_SYNC_NORMAL means to do an - ** ordinary fsync() call. There is no difference between SQLITE_SYNC_FULL - ** and SQLITE_SYNC_NORMAL on platforms other than MacOSX. But the - ** synchronous=FULL versus synchronous=NORMAL setting determines when - ** the xSync primitive is called and is relevant to all platforms. - ** - ** Numeric values associated with these states are OFF==1, NORMAL=2, - ** and FULL=3. - */ -#if !SQLITE_OMIT_PAGER_PRAGMAS - static void sqlite3PagerSetSafetyLevel( - Pager pPager, /* The pager to set safety level for */ - int level, /* PRAGMA synchronous. 1=OFF, 2=NORMAL, 3=FULL */ - int bFullFsync, /* PRAGMA fullfsync */ - int bCkptFullFsync /* PRAGMA checkpoint_fullfsync */ - ) { - Debug.Assert(level >= 1 && level <= 3); - - pPager.noSync = (level == 1 || pPager.tempFile); - pPager.fullSync = (level == 3 && !pPager.tempFile); - if (pPager.noSync) { - pPager.syncFlags = 0; - pPager.ckptSyncFlags = 0; - } else if (bFullFsync != 0) { - pPager.syncFlags = SQLITE_SYNC_FULL; - pPager.ckptSyncFlags = SQLITE_SYNC_FULL; - } else if (bCkptFullFsync != 0) { - pPager.syncFlags = SQLITE_SYNC_NORMAL; - pPager.ckptSyncFlags = SQLITE_SYNC_FULL; - } else { - pPager.syncFlags = SQLITE_SYNC_NORMAL; - pPager.ckptSyncFlags = SQLITE_SYNC_NORMAL; - } + /* Finally, rollback pages from the sub-journal. Page that were + ** previously rolled back out of the main journal (and are hence in pDone) + ** will be skipped. Out-of-range pages are also skipped. + */ + if ( pSavepoint != null ) + { + u32 ii; /* Loop counter */ + i64 offset = pSavepoint.iSubRec * ( 4 + pPager.pageSize ); + if ( pagerUseWal( pPager ) ) + { + rc = sqlite3WalSavepointUndo( pPager.pWal, pSavepoint.aWalData ); + } + for ( ii = pSavepoint.iSubRec; rc == SQLITE_OK && ii < pPager.nSubRec; ii++ ) + { + Debug.Assert( offset == ii * ( 4 + pPager.pageSize ) ); + rc = pager_playback_one_page( pPager, ref offset, pDone, 0, 1 ); } + Debug.Assert( rc != SQLITE_DONE ); + } + + sqlite3BitvecDestroy( ref pDone ); + if ( rc == SQLITE_OK ) + { + pPager.journalOff = (int)szJ; + } + return rc; + } + + /* + ** Change the maximum number of in-memory pages that are allowed. + */ + static void sqlite3PagerSetCachesize( Pager pPager, int mxPage ) + { + sqlite3PcacheSetCachesize( pPager.pPCache, mxPage ); + } + + /* + ** Adjust the robustness of the database to damage due to OS crashes + ** or power failures by changing the number of syncs()s when writing + ** the rollback journal. There are three levels: + ** + ** OFF sqlite3OsSync() is never called. This is the default + ** for temporary and transient files. + ** + ** NORMAL The journal is synced once before writes begin on the + ** database. This is normally adequate protection, but + ** it is theoretically possible, though very unlikely, + ** that an inopertune power failure could leave the journal + ** in a state which would cause damage to the database + ** when it is rolled back. + ** + ** FULL The journal is synced twice before writes begin on the + ** database (with some additional information - the nRec field + ** of the journal header - being written in between the two + ** syncs). If we assume that writing a + ** single disk sector is atomic, then this mode provides + ** assurance that the journal will not be corrupted to the + ** point of causing damage to the database during rollback. + ** + ** The above is for a rollback-journal mode. For WAL mode, OFF continues + ** to mean that no syncs ever occur. NORMAL means that the WAL is synced + ** prior to the start of checkpoint and that the database file is synced + ** at the conclusion of the checkpoint if the entire content of the WAL + ** was written back into the database. But no sync operations occur for + ** an ordinary commit in NORMAL mode with WAL. FULL means that the WAL + ** file is synced following each commit operation, in addition to the + ** syncs associated with NORMAL. + ** + ** Do not confuse synchronous=FULL with SQLITE_SYNC_FULL. The + ** SQLITE_SYNC_FULL macro means to use the MacOSX-style full-fsync + ** using fcntl(F_FULLFSYNC). SQLITE_SYNC_NORMAL means to do an + ** ordinary fsync() call. There is no difference between SQLITE_SYNC_FULL + ** and SQLITE_SYNC_NORMAL on platforms other than MacOSX. But the + ** synchronous=FULL versus synchronous=NORMAL setting determines when + ** the xSync primitive is called and is relevant to all platforms. + ** + ** Numeric values associated with these states are OFF==1, NORMAL=2, + ** and FULL=3. + */ +#if !SQLITE_OMIT_PAGER_PRAGMAS + static void sqlite3PagerSetSafetyLevel( + Pager pPager, /* The pager to set safety level for */ + int level, /* PRAGMA synchronous. 1=OFF, 2=NORMAL, 3=FULL */ + int bFullFsync, /* PRAGMA fullfsync */ + int bCkptFullFsync /* PRAGMA checkpoint_fullfsync */ + ) + { + Debug.Assert( level >= 1 && level <= 3 ); + + pPager.noSync = ( level == 1 || pPager.tempFile ); + pPager.fullSync = ( level == 3 && !pPager.tempFile ); + if ( pPager.noSync ) + { + pPager.syncFlags = 0; + pPager.ckptSyncFlags = 0; + } + else if ( bFullFsync != 0 ) + { + pPager.syncFlags = SQLITE_SYNC_FULL; + pPager.ckptSyncFlags = SQLITE_SYNC_FULL; + } + else if ( bCkptFullFsync != 0 ) + { + pPager.syncFlags = SQLITE_SYNC_NORMAL; + pPager.ckptSyncFlags = SQLITE_SYNC_FULL; + } + else + { + pPager.syncFlags = SQLITE_SYNC_NORMAL; + pPager.ckptSyncFlags = SQLITE_SYNC_NORMAL; + } + } #endif - /* - ** The following global variable is incremented whenever the library - ** attempts to open a temporary file. This information is used for - ** testing and analysis only. - */ +/* +** The following global variable is incremented whenever the library +** attempts to open a temporary file. This information is used for +** testing and analysis only. +*/ #if SQLITE_TEST #if !TCLSH static int sqlite3_opentemp_count = 0; @@ -3626,27 +3843,28 @@ int bCkptFullFsync /* PRAGMA checkpoint_fullfsync */ #endif #endif - /* - ** Open a temporary file. - ** - ** Write the file descriptor into *pFile. Return SQLITE_OK on success - ** or some other error code if we fail. The OS will automatically - ** delete the temporary file when it is closed. - ** - ** The flags passed to the VFS layer xOpen() call are those specified - ** by parameter vfsFlags ORed with the following: - ** - ** SQLITE_OPEN_READWRITE - ** SQLITE_OPEN_CREATE - ** SQLITE_OPEN_EXCLUSIVE - ** SQLITE_OPEN_DELETEONCLOSE - */ - static int pagerOpentemp( - Pager pPager, /* The pager object */ - ref sqlite3_file pFile, /* Write the file descriptor here */ - int vfsFlags /* Flags passed through to the VFS */ - ) { - int rc; /* Return code */ + /* +** Open a temporary file. +** +** Write the file descriptor into *pFile. Return SQLITE_OK on success +** or some other error code if we fail. The OS will automatically +** delete the temporary file when it is closed. +** +** The flags passed to the VFS layer xOpen() call are those specified +** by parameter vfsFlags ORed with the following: +** +** SQLITE_OPEN_READWRITE +** SQLITE_OPEN_CREATE +** SQLITE_OPEN_EXCLUSIVE +** SQLITE_OPEN_DELETEONCLOSE +*/ + static int pagerOpentemp( + Pager pPager, /* The pager object */ + ref sqlite3_file pFile, /* Write the file descriptor here */ + int vfsFlags /* Flags passed through to the VFS */ + ) + { + int rc; /* Return code */ #if SQLITE_TEST #if !TCLSH @@ -3656,163 +3874,172 @@ int vfsFlags /* Flags passed through to the VFS */ #endif #endif - vfsFlags |= SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | - SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE; - int dummy = 0; - rc = sqlite3OsOpen(pPager.pVfs, null, pFile, vfsFlags, ref dummy); - Debug.Assert(rc != SQLITE_OK || isOpen(pFile)); - return rc; - } + vfsFlags |= SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | + SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE; + int dummy = 0; + rc = sqlite3OsOpen( pPager.pVfs, null, pFile, vfsFlags, ref dummy ); + Debug.Assert( rc != SQLITE_OK || isOpen( pFile ) ); + return rc; + } - /* - ** Set the busy handler function. - ** - ** The pager invokes the busy-handler if sqlite3OsLock() returns - ** SQLITE_BUSY when trying to upgrade from no-lock to a SHARED lock, - ** or when trying to upgrade from a RESERVED lock to an EXCLUSIVE - ** lock. It does *not* invoke the busy handler when upgrading from - ** SHARED to RESERVED, or when upgrading from SHARED to EXCLUSIVE - ** (which occurs during hot-journal rollback). Summary: - ** - ** Transition | Invokes xBusyHandler - ** -------------------------------------------------------- - ** NO_LOCK . SHARED_LOCK | Yes - ** SHARED_LOCK . RESERVED_LOCK | No - ** SHARED_LOCK . EXCLUSIVE_LOCK | No - ** RESERVED_LOCK . EXCLUSIVE_LOCK | Yes - ** - ** If the busy-handler callback returns non-zero, the lock is - ** retried. If it returns zero, then the SQLITE_BUSY error is - ** returned to the caller of the pager API function. - */ + /* + ** Set the busy handler function. + ** + ** The pager invokes the busy-handler if sqlite3OsLock() returns + ** SQLITE_BUSY when trying to upgrade from no-lock to a SHARED lock, + ** or when trying to upgrade from a RESERVED lock to an EXCLUSIVE + ** lock. It does *not* invoke the busy handler when upgrading from + ** SHARED to RESERVED, or when upgrading from SHARED to EXCLUSIVE + ** (which occurs during hot-journal rollback). Summary: + ** + ** Transition | Invokes xBusyHandler + ** -------------------------------------------------------- + ** NO_LOCK . SHARED_LOCK | Yes + ** SHARED_LOCK . RESERVED_LOCK | No + ** SHARED_LOCK . EXCLUSIVE_LOCK | No + ** RESERVED_LOCK . EXCLUSIVE_LOCK | Yes + ** + ** If the busy-handler callback returns non-zero, the lock is + ** retried. If it returns zero, then the SQLITE_BUSY error is + ** returned to the caller of the pager API function. + */ - static void sqlite3PagerSetBusyhandler( - Pager pPager, /* Pager object */ - dxBusyHandler xBusyHandler, /* Pointer to busy-handler function */ - //int (*xBusyHandler)(void *), - object pBusyHandlerArg /* Argument to pass to xBusyHandler */ - ) { - pPager.xBusyHandler = xBusyHandler; - pPager.pBusyHandlerArg = pBusyHandlerArg; - } + static void sqlite3PagerSetBusyhandler( + Pager pPager, /* Pager object */ + dxBusyHandler xBusyHandler, /* Pointer to busy-handler function */ + //int (*xBusyHandler)(void *), + object pBusyHandlerArg /* Argument to pass to xBusyHandler */ + ) + { + pPager.xBusyHandler = xBusyHandler; + pPager.pBusyHandlerArg = pBusyHandlerArg; + } - /* - ** Change the page size used by the Pager object. The new page size - ** is passed in *pPageSize. - ** - ** If the pager is in the error state when this function is called, it - ** is a no-op. The value returned is the error state error code (i.e. - ** one of SQLITE_IOERR, an SQLITE_IOERR_xxx sub-code or SQLITE_FULL). - ** - ** Otherwise, if all of the following are true: - ** - ** * the new page size (value of *pPageSize) is valid (a power - ** of two between 512 and SQLITE_MAX_PAGE_SIZE, inclusive), and - ** - ** * there are no outstanding page references, and - ** - ** * the database is either not an in-memory database or it is - ** an in-memory database that currently consists of zero pages. - ** - ** then the pager object page size is set to *pPageSize. - ** - ** If the page size is changed, then this function uses sqlite3PagerMalloc() - ** to obtain a new Pager.pTmpSpace buffer. If this allocation attempt - ** fails, SQLITE_NOMEM is returned and the page size remains unchanged. - ** In all other cases, SQLITE_OK is returned. - ** - ** If the page size is not changed, either because one of the enumerated - ** conditions above is not true, the pager was in error state when this - ** function was called, or because the memory allocation attempt failed, - ** then *pPageSize is set to the old, retained page size before returning. - */ - static int sqlite3PagerSetPagesize(Pager pPager, ref u32 pPageSize, int nReserve) { - int rc = SQLITE_OK; - /* It is not possible to do a full assert_pager_state() here, as this - ** function may be called from within PagerOpen(), before the state - ** of the Pager object is internally consistent. - ** - ** At one point this function returned an error if the pager was in - ** PAGER_ERROR state. But since PAGER_ERROR state guarantees that - ** there is at least one outstanding page reference, this function - ** is a no-op for that case anyhow. - */ + /* + ** Change the page size used by the Pager object. The new page size + ** is passed in *pPageSize. + ** + ** If the pager is in the error state when this function is called, it + ** is a no-op. The value returned is the error state error code (i.e. + ** one of SQLITE_IOERR, an SQLITE_IOERR_xxx sub-code or SQLITE_FULL). + ** + ** Otherwise, if all of the following are true: + ** + ** * the new page size (value of *pPageSize) is valid (a power + ** of two between 512 and SQLITE_MAX_PAGE_SIZE, inclusive), and + ** + ** * there are no outstanding page references, and + ** + ** * the database is either not an in-memory database or it is + ** an in-memory database that currently consists of zero pages. + ** + ** then the pager object page size is set to *pPageSize. + ** + ** If the page size is changed, then this function uses sqlite3PagerMalloc() + ** to obtain a new Pager.pTmpSpace buffer. If this allocation attempt + ** fails, SQLITE_NOMEM is returned and the page size remains unchanged. + ** In all other cases, SQLITE_OK is returned. + ** + ** If the page size is not changed, either because one of the enumerated + ** conditions above is not true, the pager was in error state when this + ** function was called, or because the memory allocation attempt failed, + ** then *pPageSize is set to the old, retained page size before returning. + */ + static int sqlite3PagerSetPagesize( Pager pPager, ref u32 pPageSize, int nReserve ) + { + int rc = SQLITE_OK; + /* It is not possible to do a full assert_pager_state() here, as this + ** function may be called from within PagerOpen(), before the state + ** of the Pager object is internally consistent. + ** + ** At one point this function returned an error if the pager was in + ** PAGER_ERROR state. But since PAGER_ERROR state guarantees that + ** there is at least one outstanding page reference, this function + ** is a no-op for that case anyhow. + */ - u32 pageSize = pPageSize; - Debug.Assert(pageSize == 0 || (pageSize >= 512 && pageSize <= SQLITE_MAX_PAGE_SIZE)); - if ((pPager.memDb == 0 || pPager.dbSize == 0) - && sqlite3PcacheRefCount(pPager.pPCache) == 0 - && pageSize != 0 && pageSize != (u32)pPager.pageSize - ) { - //char *pNew = NULL; /* New temp space */ - i64 nByte = 0; - - if (pPager.eState > PAGER_OPEN && isOpen(pPager.fd)) { - rc = sqlite3OsFileSize(pPager.fd, ref nByte); - } - //if ( rc == SQLITE_OK ) - //{ - //pNew = (char *)sqlite3PageMalloc(pageSize); - //if( !pNew ) rc = SQLITE_NOMEM; - //} - if (rc == SQLITE_OK) { - pager_reset(pPager); - pPager.dbSize = (Pgno)(nByte / pageSize); - pPager.pageSize = (int)pageSize; - sqlite3PageFree(ref pPager.pTmpSpace); - - pPager.pTmpSpace = sqlite3Malloc(pageSize);// pNew; - sqlite3PcacheSetPageSize(pPager.pPCache, (int)pageSize); - } - } - pPageSize = (u32)pPager.pageSize; - if (rc == SQLITE_OK) { - if (nReserve < 0) - nReserve = pPager.nReserve; - Debug.Assert(nReserve >= 0 && nReserve < 1000); - pPager.nReserve = (i16)nReserve; - pagerReportSize(pPager); - } - return rc; - } + u32 pageSize = pPageSize; + Debug.Assert( pageSize == 0 || ( pageSize >= 512 && pageSize <= SQLITE_MAX_PAGE_SIZE ) ); + if ( ( pPager.memDb == 0 || pPager.dbSize == 0 ) + && sqlite3PcacheRefCount( pPager.pPCache ) == 0 + && pageSize != 0 && pageSize != (u32)pPager.pageSize + ) + { + //char *pNew = NULL; /* New temp space */ + i64 nByte = 0; - /* - ** Return a pointer to the "temporary page" buffer held internally - ** by the pager. This is a buffer that is big enough to hold the - ** entire content of a database page. This buffer is used internally - ** during rollback and will be overwritten whenever a rollback - ** occurs. But other modules are free to use it too, as long as - ** no rollbacks are happening. - */ - static byte[] sqlite3PagerTempSpace(Pager pPager) { - return pPager.pTmpSpace; + if ( pPager.eState > PAGER_OPEN && isOpen( pPager.fd ) ) + { + rc = sqlite3OsFileSize( pPager.fd, ref nByte ); } - - /* - ** Attempt to set the maximum database page count if mxPage is positive. - ** Make no changes if mxPage is zero or negative. And never reduce the - ** maximum page count below the current size of the database. - ** - ** Regardless of mxPage, return the current maximum page count. - */ - static Pgno sqlite3PagerMaxPageCount(Pager pPager, int mxPage) { - if (mxPage > 0) { - pPager.mxPgno = (Pgno)mxPage; - } - Debug.Assert(pPager.eState != PAGER_OPEN); /* Called only by OP_MaxPgcnt */ - Debug.Assert(pPager.mxPgno >= pPager.dbSize); /* OP_MaxPgcnt enforces this */ - return pPager.mxPgno; + //if ( rc == SQLITE_OK ) + //{ + //pNew = (char *)sqlite3PageMalloc(pageSize); + //if( !pNew ) rc = SQLITE_NOMEM; + //} + if ( rc == SQLITE_OK ) + { + pager_reset( pPager ); + pPager.dbSize = (Pgno)( nByte / pageSize ); + pPager.pageSize = (int)pageSize; + sqlite3PageFree( ref pPager.pTmpSpace ); + + pPager.pTmpSpace = sqlite3Malloc( pageSize );// pNew; + sqlite3PcacheSetPageSize( pPager.pPCache, (int)pageSize ); } + } + pPageSize = (u32)pPager.pageSize; + if ( rc == SQLITE_OK ) + { + if ( nReserve < 0 ) + nReserve = pPager.nReserve; + Debug.Assert( nReserve >= 0 && nReserve < 1000 ); + pPager.nReserve = (i16)nReserve; + pagerReportSize( pPager ); + } + return rc; + } - /* - ** The following set of routines are used to disable the simulated - ** I/O error mechanism. These routines are used to avoid simulated - ** errors in places where we do not care about errors. - ** - ** Unless -DSQLITE_TEST=1 is used, these routines are all no-ops - ** and generate no code. - */ + /* + ** Return a pointer to the "temporary page" buffer held internally + ** by the pager. This is a buffer that is big enough to hold the + ** entire content of a database page. This buffer is used internally + ** during rollback and will be overwritten whenever a rollback + ** occurs. But other modules are free to use it too, as long as + ** no rollbacks are happening. + */ + static byte[] sqlite3PagerTempSpace( Pager pPager ) + { + return pPager.pTmpSpace; + } + + /* + ** Attempt to set the maximum database page count if mxPage is positive. + ** Make no changes if mxPage is zero or negative. And never reduce the + ** maximum page count below the current size of the database. + ** + ** Regardless of mxPage, return the current maximum page count. + */ + static Pgno sqlite3PagerMaxPageCount( Pager pPager, int mxPage ) + { + if ( mxPage > 0 ) + { + pPager.mxPgno = (Pgno)mxPage; + } + Debug.Assert( pPager.eState != PAGER_OPEN ); /* Called only by OP_MaxPgcnt */ + Debug.Assert( pPager.mxPgno >= pPager.dbSize ); /* OP_MaxPgcnt enforces this */ + return pPager.mxPgno; + } + + /* + ** The following set of routines are used to disable the simulated + ** I/O error mechanism. These routines are used to avoid simulated + ** errors in places where we do not care about errors. + ** + ** Unless -DSQLITE_TEST=1 is used, these routines are all no-ops + ** and generate no code. + */ #if SQLITE_TEST //extern int sqlite3_io_error_pending; //extern int sqlite3_io_error_hit; @@ -3837,506 +4064,542 @@ static void enable_simulated_io_errors() #endif } #else - //# define disable_simulated_io_errors() - //# define enable_simulated_io_errors() +//# define disable_simulated_io_errors() +//# define enable_simulated_io_errors() #endif - /* - ** Read the first N bytes from the beginning of the file into memory - ** that pDest points to. - ** - ** If the pager was opened on a transient file (zFilename==""), or - ** opened on a file less than N bytes in size, the output buffer is - ** zeroed and SQLITE_OK returned. The rationale for this is that this - ** function is used to read database headers, and a new transient or - ** zero sized database has a header than consists entirely of zeroes. - ** - ** If any IO error apart from SQLITE_IOERR_SHORT_READ is encountered, - ** the error code is returned to the caller and the contents of the - ** output buffer undefined. - */ - static int sqlite3PagerReadFileheader(Pager pPager, int N, byte[] pDest) { - int rc = SQLITE_OK; - Array.Clear(pDest, 0, N); //memset(pDest, 0, N); - Debug.Assert(isOpen(pPager.fd) || pPager.tempFile); - - /* This routine is only called by btree immediately after creating - ** the Pager object. There has not been an opportunity to transition - ** to WAL mode yet. - */ - Debug.Assert(!pagerUseWal(pPager)); + /* +** Read the first N bytes from the beginning of the file into memory +** that pDest points to. +** +** If the pager was opened on a transient file (zFilename==""), or +** opened on a file less than N bytes in size, the output buffer is +** zeroed and SQLITE_OK returned. The rationale for this is that this +** function is used to read database headers, and a new transient or +** zero sized database has a header than consists entirely of zeroes. +** +** If any IO error apart from SQLITE_IOERR_SHORT_READ is encountered, +** the error code is returned to the caller and the contents of the +** output buffer undefined. +*/ + static int sqlite3PagerReadFileheader( Pager pPager, int N, byte[] pDest ) + { + int rc = SQLITE_OK; + Array.Clear( pDest, 0, N ); //memset(pDest, 0, N); + Debug.Assert( isOpen( pPager.fd ) || pPager.tempFile ); - if (isOpen(pPager.fd)) { - IOTRACE("DBHDR %p 0 %d\n", pPager, N); - rc = sqlite3OsRead(pPager.fd, pDest, N, 0); - if (rc == SQLITE_IOERR_SHORT_READ) { - rc = SQLITE_OK; - } - } - return rc; - } + /* This routine is only called by btree immediately after creating + ** the Pager object. There has not been an opportunity to transition + ** to WAL mode yet. + */ + Debug.Assert( !pagerUseWal( pPager ) ); - /* - ** This function may only be called when a read-transaction is open on - ** the pager. It returns the total number of pages in the database. - ** - ** However, if the file is between 1 and bytes in size, then - ** this is considered a 1 page file. - */ - static void sqlite3PagerPagecount(Pager pPager, out Pgno pnPage) { - Debug.Assert(pPager.eState >= PAGER_READER); - Debug.Assert(pPager.eState != PAGER_WRITER_FINISHED); - pnPage = pPager.dbSize; + if ( isOpen( pPager.fd ) ) + { + IOTRACE( "DBHDR %p 0 %d\n", pPager, N ); + rc = sqlite3OsRead( pPager.fd, pDest, N, 0 ); + if ( rc == SQLITE_IOERR_SHORT_READ ) + { + rc = SQLITE_OK; } + } + return rc; + } - /* - ** Try to obtain a lock of type locktype on the database file. If - ** a similar or greater lock is already held, this function is a no-op - ** (returning SQLITE_OK immediately). - ** - ** Otherwise, attempt to obtain the lock using sqlite3OsLock(). Invoke - ** the busy callback if the lock is currently not available. Repeat - ** until the busy callback returns false or until the attempt to - ** obtain the lock succeeds. - ** - ** Return SQLITE_OK on success and an error code if we cannot obtain - ** the lock. If the lock is obtained successfully, set the Pager.state - ** variable to locktype before returning. - */ - static int pager_wait_on_lock(Pager pPager, int locktype) { - int rc; /* Return code */ + /* + ** This function may only be called when a read-transaction is open on + ** the pager. It returns the total number of pages in the database. + ** + ** However, if the file is between 1 and bytes in size, then + ** this is considered a 1 page file. + */ + static void sqlite3PagerPagecount( Pager pPager, out Pgno pnPage ) + { + Debug.Assert( pPager.eState >= PAGER_READER ); + Debug.Assert( pPager.eState != PAGER_WRITER_FINISHED ); + pnPage = pPager.dbSize; + } - /* Check that this is either a no-op (because the requested lock is - ** already held, or one of the transistions that the busy-handler - ** may be invoked during, according to the comment above - ** sqlite3PagerSetBusyhandler(). - */ - Debug.Assert((pPager.eLock >= locktype) - || (pPager.eLock == NO_LOCK && locktype == SHARED_LOCK) - || (pPager.eLock == RESERVED_LOCK && locktype == EXCLUSIVE_LOCK) - ); + /* + ** Try to obtain a lock of type locktype on the database file. If + ** a similar or greater lock is already held, this function is a no-op + ** (returning SQLITE_OK immediately). + ** + ** Otherwise, attempt to obtain the lock using sqlite3OsLock(). Invoke + ** the busy callback if the lock is currently not available. Repeat + ** until the busy callback returns false or until the attempt to + ** obtain the lock succeeds. + ** + ** Return SQLITE_OK on success and an error code if we cannot obtain + ** the lock. If the lock is obtained successfully, set the Pager.state + ** variable to locktype before returning. + */ + static int pager_wait_on_lock( Pager pPager, int locktype ) + { + int rc; /* Return code */ - do { - rc = pagerLockDb(pPager, locktype); - } while (rc == SQLITE_BUSY && pPager.xBusyHandler(pPager.pBusyHandlerArg) != 0); - return rc; - } + /* Check that this is either a no-op (because the requested lock is + ** already held, or one of the transistions that the busy-handler + ** may be invoked during, according to the comment above + ** sqlite3PagerSetBusyhandler(). + */ + Debug.Assert( ( pPager.eLock >= locktype ) + || ( pPager.eLock == NO_LOCK && locktype == SHARED_LOCK ) + || ( pPager.eLock == RESERVED_LOCK && locktype == EXCLUSIVE_LOCK ) + ); - /* - ** Function assertTruncateConstraint(pPager) checks that one of the - ** following is true for all dirty pages currently in the page-cache: - ** - ** a) The page number is less than or equal to the size of the - ** current database image, in pages, OR - ** - ** b) if the page content were written at this time, it would not - ** be necessary to write the current content out to the sub-journal - ** (as determined by function subjRequiresPage()). - ** - ** If the condition asserted by this function were not true, and the - ** dirty page were to be discarded from the cache via the pagerStress() - ** routine, pagerStress() would not write the current page content to - ** the database file. If a savepoint transaction were rolled back after - ** this happened, the correct behaviour would be to restore the current - ** content of the page. However, since this content is not present in either - ** the database file or the portion of the rollback journal and - ** sub-journal rolled back the content could not be restored and the - ** database image would become corrupt. It is therefore fortunate that - ** this circumstance cannot arise. - */ + do + { + rc = pagerLockDb( pPager, locktype ); + } while ( rc == SQLITE_BUSY && pPager.xBusyHandler( pPager.pBusyHandlerArg ) != 0 ); + return rc; + } + + /* + ** Function assertTruncateConstraint(pPager) checks that one of the + ** following is true for all dirty pages currently in the page-cache: + ** + ** a) The page number is less than or equal to the size of the + ** current database image, in pages, OR + ** + ** b) if the page content were written at this time, it would not + ** be necessary to write the current content out to the sub-journal + ** (as determined by function subjRequiresPage()). + ** + ** If the condition asserted by this function were not true, and the + ** dirty page were to be discarded from the cache via the pagerStress() + ** routine, pagerStress() would not write the current page content to + ** the database file. If a savepoint transaction were rolled back after + ** this happened, the correct behaviour would be to restore the current + ** content of the page. However, since this content is not present in either + ** the database file or the portion of the rollback journal and + ** sub-journal rolled back the content could not be restored and the + ** database image would become corrupt. It is therefore fortunate that + ** this circumstance cannot arise. + */ #if SQLITE_DEBUG - static void assertTruncateConstraintCb(PgHdr pPg) { - Debug.Assert((pPg.flags & PGHDR_DIRTY) != 0); - Debug.Assert(!subjRequiresPage(pPg) || pPg.pgno <= pPg.pPager.dbSize); - } - static void assertTruncateConstraint(Pager pPager) { - sqlite3PcacheIterateDirty(pPager.pPCache, assertTruncateConstraintCb); - } + static void assertTruncateConstraintCb( PgHdr pPg ) + { + Debug.Assert( ( pPg.flags & PGHDR_DIRTY ) != 0 ); + Debug.Assert( !subjRequiresPage( pPg ) || pPg.pgno <= pPg.pPager.dbSize ); + } + static void assertTruncateConstraint( Pager pPager ) + { + sqlite3PcacheIterateDirty( pPager.pPCache, assertTruncateConstraintCb ); + } #else //# define assertTruncateConstraint(pPager) static void assertTruncateConstraintCb(PgHdr pPg) { } static void assertTruncateConstraint(Pager pPager) { } #endif - /* - ** Truncate the in-memory database file image to nPage pages. This - ** function does not actually modify the database file on disk. It - ** just sets the internal state of the pager object so that the - ** truncation will be done when the current transaction is committed. - */ - static void sqlite3PagerTruncateImage(Pager pPager, u32 nPage) { - Debug.Assert(pPager.dbSize >= nPage); - Debug.Assert(pPager.eState >= PAGER_WRITER_CACHEMOD); - pPager.dbSize = nPage; - assertTruncateConstraint(pPager); - } + /* +** Truncate the in-memory database file image to nPage pages. This +** function does not actually modify the database file on disk. It +** just sets the internal state of the pager object so that the +** truncation will be done when the current transaction is committed. +*/ + static void sqlite3PagerTruncateImage( Pager pPager, u32 nPage ) + { + Debug.Assert( pPager.dbSize >= nPage ); + Debug.Assert( pPager.eState >= PAGER_WRITER_CACHEMOD ); + pPager.dbSize = nPage; + assertTruncateConstraint( pPager ); + } - /* - ** This function is called before attempting a hot-journal rollback. It - ** syncs the journal file to disk, then sets pPager.journalHdr to the - ** size of the journal file so that the pager_playback() routine knows - ** that the entire journal file has been synced. - ** - ** Syncing a hot-journal to disk before attempting to roll it back ensures - ** that if a power-failure occurs during the rollback, the process that - ** attempts rollback following system recovery sees the same journal - ** content as this process. - ** - ** If everything goes as planned, SQLITE_OK is returned. Otherwise, - ** an SQLite error code. - */ - static int pagerSyncHotJournal(Pager pPager) { - int rc = SQLITE_OK; - if (!pPager.noSync) { - rc = sqlite3OsSync(pPager.jfd, SQLITE_SYNC_NORMAL); - } - if (rc == SQLITE_OK) { - rc = sqlite3OsFileSize(pPager.jfd, ref pPager.journalHdr); - } - return rc; - } + /* + ** This function is called before attempting a hot-journal rollback. It + ** syncs the journal file to disk, then sets pPager.journalHdr to the + ** size of the journal file so that the pager_playback() routine knows + ** that the entire journal file has been synced. + ** + ** Syncing a hot-journal to disk before attempting to roll it back ensures + ** that if a power-failure occurs during the rollback, the process that + ** attempts rollback following system recovery sees the same journal + ** content as this process. + ** + ** If everything goes as planned, SQLITE_OK is returned. Otherwise, + ** an SQLite error code. + */ + static int pagerSyncHotJournal( Pager pPager ) + { + int rc = SQLITE_OK; + if ( !pPager.noSync ) + { + rc = sqlite3OsSync( pPager.jfd, SQLITE_SYNC_NORMAL ); + } + if ( rc == SQLITE_OK ) + { + rc = sqlite3OsFileSize( pPager.jfd, ref pPager.journalHdr ); + } + return rc; + } - /* - ** Shutdown the page cache. Free all memory and close all files. - ** - ** If a transaction was in progress when this routine is called, that - ** transaction is rolled back. All outstanding pages are invalidated - ** and their memory is freed. Any attempt to use a page associated - ** with this page cache after this function returns will likely - ** result in a coredump. - ** - ** This function always succeeds. If a transaction is active an attempt - ** is made to roll it back. If an error occurs during the rollback - ** a hot journal may be left in the filesystem but no error is returned - ** to the caller. - */ - static int sqlite3PagerClose(Pager pPager) { + /* + ** Shutdown the page cache. Free all memory and close all files. + ** + ** If a transaction was in progress when this routine is called, that + ** transaction is rolled back. All outstanding pages are invalidated + ** and their memory is freed. Any attempt to use a page associated + ** with this page cache after this function returns will likely + ** result in a coredump. + ** + ** This function always succeeds. If a transaction is active an attempt + ** is made to roll it back. If an error occurs during the rollback + ** a hot journal may be left in the filesystem but no error is returned + ** to the caller. + */ + static int sqlite3PagerClose( Pager pPager ) + { #if SQLITE_TEST disable_simulated_io_errors(); #endif - sqlite3BeginBenignMalloc(); - /* pPager.errCode = 0; */ - pPager.exclusiveMode = false; + sqlite3BeginBenignMalloc(); + /* pPager.errCode = 0; */ + pPager.exclusiveMode = false; #if !SQLITE_OMIT_WAL u8[] pTmp = pPager.pTmpSpace; sqlite3WalClose(pPager->pWal, pPager->ckptSyncFlags, pPager->pageSize, pTmp); pPager.pWal = 0; #endif - pager_reset(pPager); + pager_reset( pPager ); #if SQLITE_OMIT_MEMORYDB if ( 1 == MEMDB ) #else - if (1 == pPager.memDb) + if ( 1 == pPager.memDb ) #endif - { - pager_unlock(pPager); - } else { - /* If it is open, sync the journal file before calling UnlockAndRollback. - ** If this is not done, then an unsynced portion of the open journal - ** file may be played back into the database. If a power failure occurs - ** while this is happening, the database could become corrupt. - ** - ** If an error occurs while trying to sync the journal, shift the pager - ** into the ERROR state. This causes UnlockAndRollback to unlock the - ** database and close the journal file without attempting to roll it - ** back or finalize it. The next database user will have to do hot-journal - ** rollback before accessing the database file. - */ - if (isOpen(pPager.jfd)) { - pager_error(pPager, pagerSyncHotJournal(pPager)); - } - pagerUnlockAndRollback(pPager); - } - sqlite3EndBenignMalloc(); + { + pager_unlock( pPager ); + } + else + { + /* If it is open, sync the journal file before calling UnlockAndRollback. + ** If this is not done, then an unsynced portion of the open journal + ** file may be played back into the database. If a power failure occurs + ** while this is happening, the database could become corrupt. + ** + ** If an error occurs while trying to sync the journal, shift the pager + ** into the ERROR state. This causes UnlockAndRollback to unlock the + ** database and close the journal file without attempting to roll it + ** back or finalize it. The next database user will have to do hot-journal + ** rollback before accessing the database file. + */ + if ( isOpen( pPager.jfd ) ) + { + pager_error( pPager, pagerSyncHotJournal( pPager ) ); + } + pagerUnlockAndRollback( pPager ); + } + sqlite3EndBenignMalloc(); #if SQLITE_TEST enable_simulated_io_errors(); #endif - PAGERTRACE("CLOSE %d\n", PAGERID(pPager)); - IOTRACE("CLOSE %p\n", pPager); - sqlite3OsClose(pPager.jfd); - sqlite3OsClose(pPager.fd); - //sqlite3_free( ref pTmp ); - sqlite3PcacheClose(pPager.pPCache); + PAGERTRACE( "CLOSE %d\n", PAGERID( pPager ) ); + IOTRACE( "CLOSE %p\n", pPager ); + sqlite3OsClose( pPager.jfd ); + sqlite3OsClose( pPager.fd ); + //sqlite3_free( ref pTmp ); + sqlite3PcacheClose( pPager.pPCache ); #if SQLITE_HAS_CODEC if ( pPager.xCodecFree != null ) pPager.xCodecFree( ref pPager.pCodec ); #endif - Debug.Assert(null == pPager.aSavepoint && !pPager.pInJournal); - Debug.Assert(!isOpen(pPager.jfd) && !isOpen(pPager.sjfd)); + Debug.Assert( null == pPager.aSavepoint && !pPager.pInJournal ); + Debug.Assert( !isOpen( pPager.jfd ) && !isOpen( pPager.sjfd ) ); - //sqlite3_free( ref pPager ); - return SQLITE_OK; - } + //sqlite3_free( ref pPager ); + return SQLITE_OK; + } #if !NDEBUG || SQLITE_TEST - /* - ** Return the page number for page pPg. - */ - static Pgno sqlite3PagerPagenumber(DbPage pPg) { - return pPg.pgno; - } + /* +** Return the page number for page pPg. +*/ + static Pgno sqlite3PagerPagenumber( DbPage pPg ) + { + return pPg.pgno; + } #else static Pgno sqlite3PagerPagenumber( DbPage pPg ) { return pPg.pgno; } #endif - /* - ** Increment the reference count for page pPg. + /* +** Increment the reference count for page pPg. +*/ + static void sqlite3PagerRef( DbPage pPg ) + { + sqlite3PcacheRef( pPg ); + } + + /* + ** Sync the journal. In other words, make sure all the pages that have + ** been written to the journal have actually reached the surface of the + ** disk and can be restored in the event of a hot-journal rollback. + ** + ** If the Pager.noSync flag is set, then this function is a no-op. + ** Otherwise, the actions required depend on the journal-mode and the + ** device characteristics of the the file-system, as follows: + ** + ** * If the journal file is an in-memory journal file, no action need + ** be taken. + ** + ** * Otherwise, if the device does not support the SAFE_APPEND property, + ** then the nRec field of the most recently written journal header + ** is updated to contain the number of journal records that have + ** been written following it. If the pager is operating in full-sync + ** mode, then the journal file is synced before this field is updated. + ** + ** * If the device does not support the SEQUENTIAL property, then + ** journal file is synced. + ** + ** Or, in pseudo-code: + ** + ** if( NOT ){ + ** if( NOT SAFE_APPEND ){ + ** if( ) xSync(); + ** + ** } + ** if( NOT SEQUENTIAL ) xSync(); + ** } + ** + ** If successful, this routine clears the PGHDR_NEED_SYNC flag of every + ** page currently held in memory before returning SQLITE_OK. If an IO + ** error is encountered, then the IO error code is returned to the caller. */ - static void sqlite3PagerRef(DbPage pPg) { - sqlite3PcacheRef(pPg); - } + static int syncJournal( Pager pPager, int newHdr ) + { + int rc = SQLITE_OK; + Debug.Assert( pPager.eState == PAGER_WRITER_CACHEMOD + || pPager.eState == PAGER_WRITER_DBMOD + ); + Debug.Assert( assert_pager_state( pPager ) ); + Debug.Assert( !pagerUseWal( pPager ) ); - /* - ** Sync the journal. In other words, make sure all the pages that have - ** been written to the journal have actually reached the surface of the - ** disk and can be restored in the event of a hot-journal rollback. - ** - ** If the Pager.noSync flag is set, then this function is a no-op. - ** Otherwise, the actions required depend on the journal-mode and the - ** device characteristics of the the file-system, as follows: - ** - ** * If the journal file is an in-memory journal file, no action need - ** be taken. - ** - ** * Otherwise, if the device does not support the SAFE_APPEND property, - ** then the nRec field of the most recently written journal header - ** is updated to contain the number of journal records that have - ** been written following it. If the pager is operating in full-sync - ** mode, then the journal file is synced before this field is updated. - ** - ** * If the device does not support the SEQUENTIAL property, then - ** journal file is synced. - ** - ** Or, in pseudo-code: - ** - ** if( NOT ){ - ** if( NOT SAFE_APPEND ){ - ** if( ) xSync(); - ** - ** } - ** if( NOT SEQUENTIAL ) xSync(); - ** } - ** - ** If successful, this routine clears the PGHDR_NEED_SYNC flag of every - ** page currently held in memory before returning SQLITE_OK. If an IO - ** error is encountered, then the IO error code is returned to the caller. - */ - static int syncJournal(Pager pPager, int newHdr) { - int rc = SQLITE_OK; - Debug.Assert(pPager.eState == PAGER_WRITER_CACHEMOD - || pPager.eState == PAGER_WRITER_DBMOD - ); - Debug.Assert(assert_pager_state(pPager)); - Debug.Assert(!pagerUseWal(pPager)); + rc = sqlite3PagerExclusiveLock( pPager ); + if ( rc != SQLITE_OK ) + return rc; - rc = sqlite3PagerExclusiveLock(pPager); - if (rc != SQLITE_OK) - return rc; + if ( !pPager.noSync ) + { + Debug.Assert( !pPager.tempFile ); + if ( isOpen( pPager.jfd ) && pPager.journalMode != PAGER_JOURNALMODE_MEMORY ) + { + int iDc = sqlite3OsDeviceCharacteristics( pPager.fd ); + Debug.Assert( isOpen( pPager.jfd ) ); - if (!pPager.noSync) { - Debug.Assert(!pPager.tempFile); - if (isOpen(pPager.jfd) && pPager.journalMode != PAGER_JOURNALMODE_MEMORY) { - int iDc = sqlite3OsDeviceCharacteristics(pPager.fd); - Debug.Assert(isOpen(pPager.jfd)); - - if (0 == (iDc & SQLITE_IOCAP_SAFE_APPEND)) { - /* This block deals with an obscure problem. If the last connection - ** that wrote to this database was operating in persistent-journal - ** mode, then the journal file may at this point actually be larger - ** than Pager.journalOff bytes. If the next thing in the journal - ** file happens to be a journal-header (written as part of the - ** previous connection's transaction), and a crash or power-failure - ** occurs after nRec is updated but before this connection writes - ** anything else to the journal file (or commits/rolls back its - ** transaction), then SQLite may become confused when doing the - ** hot-journal rollback following recovery. It may roll back all - ** of this connections data, then proceed to rolling back the old, - ** out-of-date data that follows it. Database corruption. - ** - ** To work around this, if the journal file does appear to contain - ** a valid header following Pager.journalOff, then write a 0x00 - ** byte to the start of it to prevent it from being recognized. - ** - ** Variable iNextHdrOffset is set to the offset at which this - ** problematic header will occur, if it exists. aMagic is used - ** as a temporary buffer to inspect the first couple of bytes of - ** the potential journal header. - */ - i64 iNextHdrOffset; - u8[] aMagic = new u8[8]; - u8[] zHeader = new u8[aJournalMagic.Length + 4]; - aJournalMagic.CopyTo(zHeader, 0);// memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic)); - put32bits(zHeader, aJournalMagic.Length, pPager.nRec); - iNextHdrOffset = journalHdrOffset(pPager); - rc = sqlite3OsRead(pPager.jfd, aMagic, 8, iNextHdrOffset); - if (rc == SQLITE_OK && 0 == memcmp(aMagic, aJournalMagic, 8)) { - u8[] zerobyte = new u8[1]; - rc = sqlite3OsWrite(pPager.jfd, zerobyte, 1, iNextHdrOffset); - } - if (rc != SQLITE_OK && rc != SQLITE_IOERR_SHORT_READ) { - return rc; - } - - /* Write the nRec value into the journal file header. If in - ** full-synchronous mode, sync the journal first. This ensures that - ** all data has really hit the disk before nRec is updated to mark - ** it as a candidate for rollback. - ** - ** This is not required if the persistent media supports the - ** SAFE_APPEND property. Because in this case it is not possible - ** for garbage data to be appended to the file, the nRec field - ** is populated with 0xFFFFFFFF when the journal header is written - ** and never needs to be updated. - */ - if (pPager.fullSync && 0 == (iDc & SQLITE_IOCAP_SEQUENTIAL)) { - - PAGERTRACE("SYNC journal of %d\n", PAGERID(pPager)); - IOTRACE("JSYNC %p\n", pPager); - rc = sqlite3OsSync(pPager.jfd, pPager.syncFlags); - if (rc != SQLITE_OK) - return rc; - } - IOTRACE("JHDR %p %lld\n", pPager, pPager.journalHdr); - rc = sqlite3OsWrite( - pPager.jfd, zHeader, zHeader.Length, pPager.journalHdr - ); - if (rc != SQLITE_OK) - return rc; - } - if (0 == (iDc & SQLITE_IOCAP_SEQUENTIAL)) { - - PAGERTRACE("SYNC journal of %d\n", PAGERID(pPager)); - IOTRACE("JSYNC %p\n", pPager); - rc = sqlite3OsSync(pPager.jfd, pPager.syncFlags | - (pPager.syncFlags == SQLITE_SYNC_FULL ? SQLITE_SYNC_DATAONLY : 0) - ); - if (rc != SQLITE_OK) - return rc; - } - pPager.journalHdr = pPager.journalOff; - if (newHdr != 0 && 0 == (iDc & SQLITE_IOCAP_SAFE_APPEND)) { - pPager.nRec = 0; - rc = writeJournalHdr(pPager); - if (rc != SQLITE_OK) - return rc; - } - } else { - pPager.journalHdr = pPager.journalOff; - } + if ( 0 == ( iDc & SQLITE_IOCAP_SAFE_APPEND ) ) + { + /* This block deals with an obscure problem. If the last connection + ** that wrote to this database was operating in persistent-journal + ** mode, then the journal file may at this point actually be larger + ** than Pager.journalOff bytes. If the next thing in the journal + ** file happens to be a journal-header (written as part of the + ** previous connection's transaction), and a crash or power-failure + ** occurs after nRec is updated but before this connection writes + ** anything else to the journal file (or commits/rolls back its + ** transaction), then SQLite may become confused when doing the + ** hot-journal rollback following recovery. It may roll back all + ** of this connections data, then proceed to rolling back the old, + ** out-of-date data that follows it. Database corruption. + ** + ** To work around this, if the journal file does appear to contain + ** a valid header following Pager.journalOff, then write a 0x00 + ** byte to the start of it to prevent it from being recognized. + ** + ** Variable iNextHdrOffset is set to the offset at which this + ** problematic header will occur, if it exists. aMagic is used + ** as a temporary buffer to inspect the first couple of bytes of + ** the potential journal header. + */ + i64 iNextHdrOffset; + u8[] aMagic = new u8[8]; + u8[] zHeader = new u8[aJournalMagic.Length + 4]; + aJournalMagic.CopyTo( zHeader, 0 );// memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic)); + put32bits( zHeader, aJournalMagic.Length, pPager.nRec ); + iNextHdrOffset = journalHdrOffset( pPager ); + rc = sqlite3OsRead( pPager.jfd, aMagic, 8, iNextHdrOffset ); + if ( rc == SQLITE_OK && 0 == memcmp( aMagic, aJournalMagic, 8 ) ) + { + u8[] zerobyte = new u8[1]; + rc = sqlite3OsWrite( pPager.jfd, zerobyte, 1, iNextHdrOffset ); + } + if ( rc != SQLITE_OK && rc != SQLITE_IOERR_SHORT_READ ) + { + return rc; } - /* Unless the pager is in noSync mode, the journal file was just - ** successfully synced. Either way, clear the PGHDR_NEED_SYNC flag on - ** all pages. + + /* Write the nRec value into the journal file header. If in + ** full-synchronous mode, sync the journal first. This ensures that + ** all data has really hit the disk before nRec is updated to mark + ** it as a candidate for rollback. + ** + ** This is not required if the persistent media supports the + ** SAFE_APPEND property. Because in this case it is not possible + ** for garbage data to be appended to the file, the nRec field + ** is populated with 0xFFFFFFFF when the journal header is written + ** and never needs to be updated. */ - sqlite3PcacheClearSyncFlags(pPager.pPCache); - pPager.eState = PAGER_WRITER_DBMOD; - Debug.Assert(assert_pager_state(pPager)); - return SQLITE_OK; + if ( pPager.fullSync && 0 == ( iDc & SQLITE_IOCAP_SEQUENTIAL ) ) + { + + PAGERTRACE( "SYNC journal of %d\n", PAGERID( pPager ) ); + IOTRACE( "JSYNC %p\n", pPager ); + rc = sqlite3OsSync( pPager.jfd, pPager.syncFlags ); + if ( rc != SQLITE_OK ) + return rc; + } + IOTRACE( "JHDR %p %lld\n", pPager, pPager.journalHdr ); + rc = sqlite3OsWrite( + pPager.jfd, zHeader, zHeader.Length, pPager.journalHdr + ); + if ( rc != SQLITE_OK ) + return rc; + } + if ( 0 == ( iDc & SQLITE_IOCAP_SEQUENTIAL ) ) + { + + PAGERTRACE( "SYNC journal of %d\n", PAGERID( pPager ) ); + IOTRACE( "JSYNC %p\n", pPager ); + rc = sqlite3OsSync( pPager.jfd, pPager.syncFlags | + ( pPager.syncFlags == SQLITE_SYNC_FULL ? SQLITE_SYNC_DATAONLY : 0 ) + ); + if ( rc != SQLITE_OK ) + return rc; + } + pPager.journalHdr = pPager.journalOff; + if ( newHdr != 0 && 0 == ( iDc & SQLITE_IOCAP_SAFE_APPEND ) ) + { + pPager.nRec = 0; + rc = writeJournalHdr( pPager ); + if ( rc != SQLITE_OK ) + return rc; + } } + else + { + pPager.journalHdr = pPager.journalOff; + } + } + /* Unless the pager is in noSync mode, the journal file was just + ** successfully synced. Either way, clear the PGHDR_NEED_SYNC flag on + ** all pages. + */ + sqlite3PcacheClearSyncFlags( pPager.pPCache ); + pPager.eState = PAGER_WRITER_DBMOD; + Debug.Assert( assert_pager_state( pPager ) ); + return SQLITE_OK; + } - /* - ** The argument is the first in a linked list of dirty pages connected - ** by the PgHdr.pDirty pointer. This function writes each one of the - ** in-memory pages in the list to the database file. The argument may - ** be NULL, representing an empty list. In this case this function is - ** a no-op. - ** - ** The pager must hold at least a RESERVED lock when this function - ** is called. Before writing anything to the database file, this lock - ** is upgraded to an EXCLUSIVE lock. If the lock cannot be obtained, - ** SQLITE_BUSY is returned and no data is written to the database file. - ** - ** If the pager is a temp-file pager and the actual file-system file - ** is not yet open, it is created and opened before any data is - ** written out. - ** - ** Once the lock has been upgraded and, if necessary, the file opened, - ** the pages are written out to the database file in list order. Writing - ** a page is skipped if it meets either of the following criteria: - ** - ** * The page number is greater than Pager.dbSize, or - ** * The PGHDR_DONT_WRITE flag is set on the page. - ** - ** If writing out a page causes the database file to grow, Pager.dbFileSize - ** is updated accordingly. If page 1 is written out, then the value cached - ** in Pager.dbFileVers[] is updated to match the new value stored in - ** the database file. + /* + ** The argument is the first in a linked list of dirty pages connected + ** by the PgHdr.pDirty pointer. This function writes each one of the + ** in-memory pages in the list to the database file. The argument may + ** be NULL, representing an empty list. In this case this function is + ** a no-op. + ** + ** The pager must hold at least a RESERVED lock when this function + ** is called. Before writing anything to the database file, this lock + ** is upgraded to an EXCLUSIVE lock. If the lock cannot be obtained, + ** SQLITE_BUSY is returned and no data is written to the database file. + ** + ** If the pager is a temp-file pager and the actual file-system file + ** is not yet open, it is created and opened before any data is + ** written out. + ** + ** Once the lock has been upgraded and, if necessary, the file opened, + ** the pages are written out to the database file in list order. Writing + ** a page is skipped if it meets either of the following criteria: + ** + ** * The page number is greater than Pager.dbSize, or + ** * The PGHDR_DONT_WRITE flag is set on the page. + ** + ** If writing out a page causes the database file to grow, Pager.dbFileSize + ** is updated accordingly. If page 1 is written out, then the value cached + ** in Pager.dbFileVers[] is updated to match the new value stored in + ** the database file. + ** + ** If everything is successful, SQLITE_OK is returned. If an IO error + ** occurs, an IO error code is returned. Or, if the EXCLUSIVE lock cannot + ** be obtained, SQLITE_BUSY is returned. + */ + static int pager_write_pagelist( Pager pPager, PgHdr pList ) + { + int rc = SQLITE_OK; /* Return code */ + + /* This function is only called for rollback pagers in WRITER_DBMOD state. */ + Debug.Assert( !pagerUseWal( pPager ) ); + Debug.Assert( pPager.eState == PAGER_WRITER_DBMOD ); + Debug.Assert( pPager.eLock == EXCLUSIVE_LOCK ); + /* If the file is a temp-file has not yet been opened, open it now. It + ** is not possible for rc to be other than SQLITE_OK if this branch + ** is taken, as pager_wait_on_lock() is a no-op for temp-files. + */ + if ( !isOpen( pPager.fd ) ) + { + Debug.Assert( pPager.tempFile && rc == SQLITE_OK ); + rc = pagerOpentemp( pPager, ref pPager.fd, (int)pPager.vfsFlags ); + } + + /* Before the first write, give the VFS a hint of what the final + ** file size will be. + */ + Debug.Assert( rc != SQLITE_OK || isOpen( pPager.fd ) ); + if ( rc == SQLITE_OK && pPager.dbSize > pPager.dbHintSize ) + { + sqlite3_int64 szFile = pPager.pageSize * (sqlite3_int64)pPager.dbSize; + sqlite3OsFileControl( pPager.fd, SQLITE_FCNTL_SIZE_HINT, ref szFile ); + pPager.dbHintSize = pPager.dbSize; + } + while ( rc == SQLITE_OK && pList ) + { + Pgno pgno = pList.pgno; + + /* If there are dirty pages in the page cache with page numbers greater + ** than Pager.dbSize, this means sqlite3PagerTruncateImage() was called to + ** make the file smaller (presumably by auto-vacuum code). Do not write + ** any such pages to the file. ** - ** If everything is successful, SQLITE_OK is returned. If an IO error - ** occurs, an IO error code is returned. Or, if the EXCLUSIVE lock cannot - ** be obtained, SQLITE_BUSY is returned. + ** Also, do not write out any page that has the PGHDR_DONT_WRITE flag + ** set (set by sqlite3PagerDontWrite()). */ - static int pager_write_pagelist(Pager pPager, PgHdr pList) { - int rc = SQLITE_OK; /* Return code */ - - /* This function is only called for rollback pagers in WRITER_DBMOD state. */ - Debug.Assert(!pagerUseWal(pPager)); - Debug.Assert(pPager.eState == PAGER_WRITER_DBMOD); - Debug.Assert(pPager.eLock == EXCLUSIVE_LOCK); - /* If the file is a temp-file has not yet been opened, open it now. It - ** is not possible for rc to be other than SQLITE_OK if this branch - ** is taken, as pager_wait_on_lock() is a no-op for temp-files. - */ - if (!isOpen(pPager.fd)) { - Debug.Assert(pPager.tempFile && rc == SQLITE_OK); - rc = pagerOpentemp(pPager, ref pPager.fd, (int)pPager.vfsFlags); - } + if ( pList.pgno <= pPager.dbSize && 0 == ( pList.flags & PGHDR_DONT_WRITE ) ) + { + i64 offset = ( pList.pgno - 1 ) * (i64)pPager.pageSize; /* Offset to write */ + byte[] pData = null; /* Data to write */ + + Debug.Assert( ( pList.flags & PGHDR_NEED_SYNC ) == 0 ); + if ( pList.pgno == 1 ) + pager_write_changecounter( pList ); + + /* Encode the database */ + if ( CODEC2( pPager, pList.pData, pgno, SQLITE_ENCRYPT_WRITE_CTX, ref pData ) ) + return SQLITE_NOMEM;// CODEC2(pPager, pList.pData, pgno, 6, return SQLITE_NOMEM, pData); + + /* Write out the page data. */ + rc = sqlite3OsWrite( pPager.fd, pData, pPager.pageSize, offset ); + /* If page 1 was just written, update Pager.dbFileVers to match + ** the value now stored in the database file. If writing this + ** page caused the database file to grow, update dbFileSize. + */ + if ( pgno == 1 ) + { + Buffer.BlockCopy( pData, 24, pPager.dbFileVers, 0, pPager.dbFileVers.Length );// memcpy(pPager.dbFileVers, pData[24], pPager.dbFileVers).Length; + } + if ( pgno > pPager.dbFileSize ) + { + pPager.dbFileSize = pgno; + } + /* Update any backup objects copying the contents of this pager. */ + sqlite3BackupUpdate( pPager.pBackup, pgno, pList.pData ); - /* Before the first write, give the VFS a hint of what the final - ** file size will be. - */ - Debug.Assert(rc != SQLITE_OK || isOpen(pPager.fd)); - if (rc == SQLITE_OK && pPager.dbSize > pPager.dbHintSize) { - sqlite3_int64 szFile = pPager.pageSize * (sqlite3_int64)pPager.dbSize; - sqlite3OsFileControl(pPager.fd, SQLITE_FCNTL_SIZE_HINT, ref szFile); - pPager.dbHintSize = pPager.dbSize; - } - while (rc == SQLITE_OK && pList) { - Pgno pgno = pList.pgno; - - /* If there are dirty pages in the page cache with page numbers greater - ** than Pager.dbSize, this means sqlite3PagerTruncateImage() was called to - ** make the file smaller (presumably by auto-vacuum code). Do not write - ** any such pages to the file. - ** - ** Also, do not write out any page that has the PGHDR_DONT_WRITE flag - ** set (set by sqlite3PagerDontWrite()). - */ - if (pList.pgno <= pPager.dbSize && 0 == (pList.flags & PGHDR_DONT_WRITE)) { - i64 offset = (pList.pgno - 1) * (i64)pPager.pageSize; /* Offset to write */ - byte[] pData = null; /* Data to write */ - - Debug.Assert((pList.flags & PGHDR_NEED_SYNC) == 0); - if (pList.pgno == 1) - pager_write_changecounter(pList); - - /* Encode the database */ - if (CODEC2(pPager, pList.pData, pgno, SQLITE_ENCRYPT_WRITE_CTX, ref pData)) - return SQLITE_NOMEM;// CODEC2(pPager, pList.pData, pgno, 6, return SQLITE_NOMEM, pData); - - /* Write out the page data. */ - rc = sqlite3OsWrite(pPager.fd, pData, pPager.pageSize, offset); - /* If page 1 was just written, update Pager.dbFileVers to match - ** the value now stored in the database file. If writing this - ** page caused the database file to grow, update dbFileSize. - */ - if (pgno == 1) { - Buffer.BlockCopy(pData, 24, pPager.dbFileVers, 0, pPager.dbFileVers.Length);// memcpy(pPager.dbFileVers, pData[24], pPager.dbFileVers).Length; - } - if (pgno > pPager.dbFileSize) { - pPager.dbFileSize = pgno; - } - /* Update any backup objects copying the contents of this pager. */ - sqlite3BackupUpdate(pPager.pBackup, pgno, pList.pData); - - - PAGERTRACE("STORE %d page %d hash(%08x)\n", - PAGERID(pPager), pgno, pager_pagehash(pList)); - IOTRACE("PGOUT %p %d\n", pPager, pgno); + + PAGERTRACE( "STORE %d page %d hash(%08x)\n", + PAGERID( pPager ), pgno, pager_pagehash( pList ) ); + IOTRACE( "PGOUT %p %d\n", pPager, pgno ); #if SQLITE_TEST #if !TCLSH PAGER_INCR( ref sqlite3_pager_writedb_count ); @@ -4349,367 +4612,399 @@ static int pager_write_pagelist(Pager pPager, PgHdr pList) { PAGER_INCR( ref pPager.nWrite ); #endif - } else { - - PAGERTRACE("NOSTORE %d page %d\n", PAGERID(pPager), pgno); - } - pager_set_pagehash(pList); - pList = pList.pDirty; - } - return rc; } + else + { - /* - ** Ensure that the sub-journal file is open. If it is already open, this - ** function is a no-op. - ** - ** SQLITE_OK is returned if everything goes according to plan. An - ** SQLITE_IOERR_XXX error code is returned if a call to sqlite3OsOpen() - ** fails. - */ - static int openSubJournal(Pager pPager) { - int rc = SQLITE_OK; - if (!isOpen(pPager.sjfd)) { - if (pPager.journalMode == PAGER_JOURNALMODE_MEMORY || pPager.subjInMemory != 0) { - sqlite3MemJournalOpen(pPager.sjfd); - } else { - rc = pagerOpentemp(pPager, ref pPager.sjfd, SQLITE_OPEN_SUBJOURNAL); - } - } - return rc; + PAGERTRACE( "NOSTORE %d page %d\n", PAGERID( pPager ), pgno ); } + pager_set_pagehash( pList ); + pList = pList.pDirty; + } + return rc; + } - /* - ** Append a record of the current state of page pPg to the sub-journal. - ** It is the callers responsibility to use subjRequiresPage() to check - ** that it is really required before calling this function. - ** - ** If successful, set the bit corresponding to pPg.pgno in the bitvecs - ** for all open savepoints before returning. - ** - ** This function returns SQLITE_OK if everything is successful, an IO - ** error code if the attempt to write to the sub-journal fails, or - ** SQLITE_NOMEM if a malloc fails while setting a bit in a savepoint - ** bitvec. - */ - static int subjournalPage(PgHdr pPg) { - int rc = SQLITE_OK; - Pager pPager = pPg.pPager; - if (pPager.journalMode != PAGER_JOURNALMODE_OFF) { - - /* Open the sub-journal, if it has not already been opened */ - Debug.Assert(pPager.useJournal != 0); - Debug.Assert(isOpen(pPager.jfd) || pagerUseWal(pPager)); - Debug.Assert(isOpen(pPager.sjfd) || pPager.nSubRec == 0); - Debug.Assert(pagerUseWal(pPager) - || pageInJournal(pPg) - || pPg.pgno > pPager.dbOrigSize - ); - rc = openSubJournal(pPager); - - /* If the sub-journal was opened successfully (or was already open), - ** write the journal record into the file. */ - if (rc == SQLITE_OK) { - byte[] pData = pPg.pData; - i64 offset = pPager.nSubRec * (4 + pPager.pageSize); - byte[] pData2 = null; - - if (CODEC2(pPager, pData, pPg.pgno, SQLITE_ENCRYPT_READ_CTX, ref pData2)) - return SQLITE_NOMEM;//CODEC2(pPager, pData, pPg.pgno, 7, return SQLITE_NOMEM, pData2); - PAGERTRACE("STMT-JOURNAL %d page %d\n", PAGERID(pPager), pPg.pgno); - rc = write32bits(pPager.sjfd, offset, pPg.pgno); - if (rc == SQLITE_OK) { - rc = sqlite3OsWrite(pPager.sjfd, pData2, pPager.pageSize, offset + 4); - } - } - } - if (rc == SQLITE_OK) { - pPager.nSubRec++; - Debug.Assert(pPager.nSavepoint > 0); - rc = addToSavepointBitvecs(pPager, pPg.pgno); - } - return rc; + /* + ** Ensure that the sub-journal file is open. If it is already open, this + ** function is a no-op. + ** + ** SQLITE_OK is returned if everything goes according to plan. An + ** SQLITE_IOERR_XXX error code is returned if a call to sqlite3OsOpen() + ** fails. + */ + static int openSubJournal( Pager pPager ) + { + int rc = SQLITE_OK; + if ( !isOpen( pPager.sjfd ) ) + { + if ( pPager.journalMode == PAGER_JOURNALMODE_MEMORY || pPager.subjInMemory != 0 ) + { + sqlite3MemJournalOpen( pPager.sjfd ); } + else + { + rc = pagerOpentemp( pPager, ref pPager.sjfd, SQLITE_OPEN_SUBJOURNAL ); + } + } + return rc; + } - /* - ** This function is called by the pcache layer when it has reached some - ** soft memory limit. The first argument is a pointer to a Pager object - ** (cast as a void*). The pager is always 'purgeable' (not an in-memory - ** database). The second argument is a reference to a page that is - ** currently dirty but has no outstanding references. The page - ** is always associated with the Pager object passed as the first - ** argument. - ** - ** The job of this function is to make pPg clean by writing its contents - ** out to the database file, if possible. This may involve syncing the - ** journal file. - ** - ** If successful, sqlite3PcacheMakeClean() is called on the page and - ** SQLITE_OK returned. If an IO error occurs while trying to make the - ** page clean, the IO error code is returned. If the page cannot be - ** made clean for some other reason, but no error occurs, then SQLITE_OK - ** is returned by sqlite3PcacheMakeClean() is not called. - */ - static int pagerStress(object p, PgHdr pPg) { - Pager pPager = (Pager)p; - int rc = SQLITE_OK; + /* + ** Append a record of the current state of page pPg to the sub-journal. + ** It is the callers responsibility to use subjRequiresPage() to check + ** that it is really required before calling this function. + ** + ** If successful, set the bit corresponding to pPg.pgno in the bitvecs + ** for all open savepoints before returning. + ** + ** This function returns SQLITE_OK if everything is successful, an IO + ** error code if the attempt to write to the sub-journal fails, or + ** SQLITE_NOMEM if a malloc fails while setting a bit in a savepoint + ** bitvec. + */ + static int subjournalPage( PgHdr pPg ) + { + int rc = SQLITE_OK; + Pager pPager = pPg.pPager; + if ( pPager.journalMode != PAGER_JOURNALMODE_OFF ) + { + + /* Open the sub-journal, if it has not already been opened */ + Debug.Assert( pPager.useJournal != 0 ); + Debug.Assert( isOpen( pPager.jfd ) || pagerUseWal( pPager ) ); + Debug.Assert( isOpen( pPager.sjfd ) || pPager.nSubRec == 0 ); + Debug.Assert( pagerUseWal( pPager ) + || pageInJournal( pPg ) + || pPg.pgno > pPager.dbOrigSize + ); + rc = openSubJournal( pPager ); + + /* If the sub-journal was opened successfully (or was already open), + ** write the journal record into the file. */ + if ( rc == SQLITE_OK ) + { + byte[] pData = pPg.pData; + i64 offset = pPager.nSubRec * ( 4 + pPager.pageSize ); + byte[] pData2 = null; + + if ( CODEC2( pPager, pData, pPg.pgno, SQLITE_ENCRYPT_READ_CTX, ref pData2 ) ) + return SQLITE_NOMEM;//CODEC2(pPager, pData, pPg.pgno, 7, return SQLITE_NOMEM, pData2); + PAGERTRACE( "STMT-JOURNAL %d page %d\n", PAGERID( pPager ), pPg.pgno ); + rc = write32bits( pPager.sjfd, offset, pPg.pgno ); + if ( rc == SQLITE_OK ) + { + rc = sqlite3OsWrite( pPager.sjfd, pData2, pPager.pageSize, offset + 4 ); + } + } + } + if ( rc == SQLITE_OK ) + { + pPager.nSubRec++; + Debug.Assert( pPager.nSavepoint > 0 ); + rc = addToSavepointBitvecs( pPager, pPg.pgno ); + } + return rc; + } - Debug.Assert(pPg.pPager == pPager); - Debug.Assert((pPg.flags & PGHDR_DIRTY) != 0); + /* + ** This function is called by the pcache layer when it has reached some + ** soft memory limit. The first argument is a pointer to a Pager object + ** (cast as a void*). The pager is always 'purgeable' (not an in-memory + ** database). The second argument is a reference to a page that is + ** currently dirty but has no outstanding references. The page + ** is always associated with the Pager object passed as the first + ** argument. + ** + ** The job of this function is to make pPg clean by writing its contents + ** out to the database file, if possible. This may involve syncing the + ** journal file. + ** + ** If successful, sqlite3PcacheMakeClean() is called on the page and + ** SQLITE_OK returned. If an IO error occurs while trying to make the + ** page clean, the IO error code is returned. If the page cannot be + ** made clean for some other reason, but no error occurs, then SQLITE_OK + ** is returned by sqlite3PcacheMakeClean() is not called. + */ + static int pagerStress( object p, PgHdr pPg ) + { + Pager pPager = (Pager)p; + int rc = SQLITE_OK; - /* The doNotSyncSpill flag is set during times when doing a sync of - ** journal (and adding a new header) is not allowed. This occurs - ** during calls to sqlite3PagerWrite() while trying to journal multiple - ** pages belonging to the same sector. - ** - ** The doNotSpill flag inhibits all cache spilling regardless of whether - ** or not a sync is required. This is set during a rollback. - ** - ** Spilling is also prohibited when in an error state since that could - ** lead to database corruption. In the current implementaton it - ** is impossible for sqlite3PCacheFetch() to be called with createFlag==1 - ** while in the error state, hence it is impossible for this routine to - ** be called in the error state. Nevertheless, we include a NEVER() - ** test for the error state as a safeguard against future changes. - */ - if (NEVER(pPager.errCode != 0)) - return SQLITE_OK; - if (pPager.doNotSpill != 0) - return SQLITE_OK; - if (pPager.doNotSyncSpill != 0 && (pPg.flags & PGHDR_NEED_SYNC) != 0) { - return SQLITE_OK; - } - pPg.pDirty = null; - if (pagerUseWal(pPager)) { - /* Write a single frame for this page to the log. */ - if (subjRequiresPage(pPg)) { - rc = subjournalPage(pPg); - } - if (rc == SQLITE_OK) { - rc = pagerWalFrames(pPager, pPg, 0, 0, 0); - } - } else { + Debug.Assert( pPg.pPager == pPager ); + Debug.Assert( ( pPg.flags & PGHDR_DIRTY ) != 0 ); - /* Sync the journal file if required. */ - if ((pPg.flags & PGHDR_NEED_SYNC) != 0 - || pPager.eState == PAGER_WRITER_CACHEMOD - ) { - rc = syncJournal(pPager, 1); - } + /* The doNotSyncSpill flag is set during times when doing a sync of + ** journal (and adding a new header) is not allowed. This occurs + ** during calls to sqlite3PagerWrite() while trying to journal multiple + ** pages belonging to the same sector. + ** + ** The doNotSpill flag inhibits all cache spilling regardless of whether + ** or not a sync is required. This is set during a rollback. + ** + ** Spilling is also prohibited when in an error state since that could + ** lead to database corruption. In the current implementaton it + ** is impossible for sqlite3PCacheFetch() to be called with createFlag==1 + ** while in the error state, hence it is impossible for this routine to + ** be called in the error state. Nevertheless, we include a NEVER() + ** test for the error state as a safeguard against future changes. + */ + if ( NEVER( pPager.errCode != 0 ) ) + return SQLITE_OK; + if ( pPager.doNotSpill != 0 ) + return SQLITE_OK; + if ( pPager.doNotSyncSpill != 0 && ( pPg.flags & PGHDR_NEED_SYNC ) != 0 ) + { + return SQLITE_OK; + } + pPg.pDirty = null; + if ( pagerUseWal( pPager ) ) + { + /* Write a single frame for this page to the log. */ + if ( subjRequiresPage( pPg ) ) + { + rc = subjournalPage( pPg ); + } + if ( rc == SQLITE_OK ) + { + rc = pagerWalFrames( pPager, pPg, 0, 0, 0 ); + } + } + else + { - /* If the page number of this page is larger than the current size of - ** the database image, it may need to be written to the sub-journal. - ** This is because the call to pager_write_pagelist() below will not - ** actually write data to the file in this case. - ** - ** Consider the following sequence of events: - ** - ** BEGIN; - ** - ** - ** SAVEPOINT sp; - ** - ** pagerStress(page X) - ** ROLLBACK TO sp; - ** - ** If (X>Y), then when pagerStress is called page X will not be written - ** out to the database file, but will be dropped from the cache. Then, - ** following the "ROLLBACK TO sp" statement, reading page X will read - ** data from the database file. This will be the copy of page X as it - ** was when the transaction started, not as it was when "SAVEPOINT sp" - ** was executed. - ** - ** The solution is to write the current data for page X into the - ** sub-journal file now (if it is not already there), so that it will - ** be restored to its current value when the "ROLLBACK TO sp" is - ** executed. - */ - if (NEVER( - rc == SQLITE_OK && pPg.pgno > pPager.dbSize && subjRequiresPage(pPg) - )) { - rc = subjournalPage(pPg); - } + /* Sync the journal file if required. */ + if ( ( pPg.flags & PGHDR_NEED_SYNC ) != 0 + || pPager.eState == PAGER_WRITER_CACHEMOD + ) + { + rc = syncJournal( pPager, 1 ); + } - /* Write the contents of the page out to the database file. */ - if (rc == SQLITE_OK) { - Debug.Assert((pPg.flags & PGHDR_NEED_SYNC) == 0); - rc = pager_write_pagelist(pPager, pPg); - } - } - /* Mark the page as clean. */ - if (rc == SQLITE_OK) { - PAGERTRACE("STRESS %d page %d\n", PAGERID(pPager), pPg.pgno); - sqlite3PcacheMakeClean(pPg); - } + /* If the page number of this page is larger than the current size of + ** the database image, it may need to be written to the sub-journal. + ** This is because the call to pager_write_pagelist() below will not + ** actually write data to the file in this case. + ** + ** Consider the following sequence of events: + ** + ** BEGIN; + ** + ** + ** SAVEPOINT sp; + ** + ** pagerStress(page X) + ** ROLLBACK TO sp; + ** + ** If (X>Y), then when pagerStress is called page X will not be written + ** out to the database file, but will be dropped from the cache. Then, + ** following the "ROLLBACK TO sp" statement, reading page X will read + ** data from the database file. This will be the copy of page X as it + ** was when the transaction started, not as it was when "SAVEPOINT sp" + ** was executed. + ** + ** The solution is to write the current data for page X into the + ** sub-journal file now (if it is not already there), so that it will + ** be restored to its current value when the "ROLLBACK TO sp" is + ** executed. + */ + if ( NEVER( + rc == SQLITE_OK && pPg.pgno > pPager.dbSize && subjRequiresPage( pPg ) + ) ) + { + rc = subjournalPage( pPg ); + } - return pager_error(pPager, rc); + /* Write the contents of the page out to the database file. */ + if ( rc == SQLITE_OK ) + { + Debug.Assert( ( pPg.flags & PGHDR_NEED_SYNC ) == 0 ); + rc = pager_write_pagelist( pPager, pPg ); } + } + /* Mark the page as clean. */ + if ( rc == SQLITE_OK ) + { + PAGERTRACE( "STRESS %d page %d\n", PAGERID( pPager ), pPg.pgno ); + sqlite3PcacheMakeClean( pPg ); + } + return pager_error( pPager, rc ); + } - /* - ** Allocate and initialize a new Pager object and put a pointer to it - ** in *ppPager. The pager should eventually be freed by passing it - ** to sqlite3PagerClose(). - ** - ** The zFilename argument is the path to the database file to open. - ** If zFilename is NULL then a randomly-named temporary file is created - ** and used as the file to be cached. Temporary files are be deleted - ** automatically when they are closed. If zFilename is ":memory:" then - ** all information is held in cache. It is never written to disk. - ** This can be used to implement an in-memory database. - ** - ** The nExtra parameter specifies the number of bytes of space allocated - ** along with each page reference. This space is available to the user - ** via the sqlite3PagerGetExtra() API. - ** - ** The flags argument is used to specify properties that affect the - ** operation of the pager. It should be passed some bitwise combination - ** of the PAGER_OMIT_JOURNAL and PAGER_NO_READLOCK flags. - ** - ** The vfsFlags parameter is a bitmask to pass to the flags parameter - ** of the xOpen() method of the supplied VFS when opening files. - ** - ** If the pager object is allocated and the specified file opened - ** successfully, SQLITE_OK is returned and *ppPager set to point to - ** the new pager object. If an error occurs, *ppPager is set to NULL - ** and error code returned. This function may return SQLITE_NOMEM - ** (sqlite3Malloc() is used to allocate memory), SQLITE_CANTOPEN or - ** various SQLITE_IO_XXX errors. - */ - static int sqlite3PagerOpen( - sqlite3_vfs pVfs, /* The virtual file system to use */ - out Pager ppPager, /* OUT: Return the Pager structure here */ - string zFilename, /* Name of the database file to open */ - int nExtra, /* Extra bytes append to each in-memory page */ - int flags, /* flags controlling this file */ - int vfsFlags, /* flags passed through to sqlite3_vfs.xOpen() */ - dxReiniter xReinit /* Function to reinitialize pages */ - ) { - u8 pPtr; - Pager pPager = null; /* Pager object to allocate and return */ - int rc = SQLITE_OK; /* Return code */ - u8 tempFile = 0; /* True for temp files (incl. in-memory files) */ // Needs to be u8 for later tests - u8 memDb = 0; /* True if this is an in-memory file */ - bool readOnly = false; /* True if this is a read-only file */ - int journalFileSize; /* Bytes to allocate for each journal fd */ - StringBuilder zPathname = null; /* Full path to database file */ - int nPathname = 0; /* Number of bytes in zPathname */ - bool useJournal = (flags & PAGER_OMIT_JOURNAL) == 0; /* False to omit journal */ - bool noReadlock = (flags & PAGER_NO_READLOCK) != 0; /* True to omit read-lock */ - int pcacheSize = sqlite3PcacheSize(); /* Bytes to allocate for PCache */ - u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE; /* Default page size */ - string zUri = null; /* URI args to copy */ - int nUri = 0; /* Number of bytes of URI args at *zUri */ - - /* Figure out how much space is required for each journal file-handle - ** (there are two of them, the main journal and the sub-journal). This - ** is the maximum space required for an in-memory journal file handle - ** and a regular journal file-handle. Note that a "regular journal-handle" - ** may be a wrapper capable of caching the first portion of the journal - ** file in memory to implement the atomic-write optimization (see - ** source file journal.c). - */ - if (sqlite3JournalSize(pVfs) > sqlite3MemJournalSize()) { - journalFileSize = ROUND8(sqlite3JournalSize(pVfs)); - } else { - journalFileSize = ROUND8(sqlite3MemJournalSize()); - } - /* Set the output variable to NULL in case an error occurs. */ - ppPager = null; + /* + ** Allocate and initialize a new Pager object and put a pointer to it + ** in *ppPager. The pager should eventually be freed by passing it + ** to sqlite3PagerClose(). + ** + ** The zFilename argument is the path to the database file to open. + ** If zFilename is NULL then a randomly-named temporary file is created + ** and used as the file to be cached. Temporary files are be deleted + ** automatically when they are closed. If zFilename is ":memory:" then + ** all information is held in cache. It is never written to disk. + ** This can be used to implement an in-memory database. + ** + ** The nExtra parameter specifies the number of bytes of space allocated + ** along with each page reference. This space is available to the user + ** via the sqlite3PagerGetExtra() API. + ** + ** The flags argument is used to specify properties that affect the + ** operation of the pager. It should be passed some bitwise combination + ** of the PAGER_OMIT_JOURNAL and PAGER_NO_READLOCK flags. + ** + ** The vfsFlags parameter is a bitmask to pass to the flags parameter + ** of the xOpen() method of the supplied VFS when opening files. + ** + ** If the pager object is allocated and the specified file opened + ** successfully, SQLITE_OK is returned and *ppPager set to point to + ** the new pager object. If an error occurs, *ppPager is set to NULL + ** and error code returned. This function may return SQLITE_NOMEM + ** (sqlite3Malloc() is used to allocate memory), SQLITE_CANTOPEN or + ** various SQLITE_IO_XXX errors. + */ + static int sqlite3PagerOpen( + sqlite3_vfs pVfs, /* The virtual file system to use */ + out Pager ppPager, /* OUT: Return the Pager structure here */ + string zFilename, /* Name of the database file to open */ + int nExtra, /* Extra bytes append to each in-memory page */ + int flags, /* flags controlling this file */ + int vfsFlags, /* flags passed through to sqlite3_vfs.xOpen() */ + dxReiniter xReinit /* Function to reinitialize pages */ + ) + { + u8 pPtr; + Pager pPager = null; /* Pager object to allocate and return */ + int rc = SQLITE_OK; /* Return code */ + u8 tempFile = 0; /* True for temp files (incl. in-memory files) */ // Needs to be u8 for later tests + u8 memDb = 0; /* True if this is an in-memory file */ + bool readOnly = false; /* True if this is a read-only file */ + int journalFileSize; /* Bytes to allocate for each journal fd */ + StringBuilder zPathname = null; /* Full path to database file */ + int nPathname = 0; /* Number of bytes in zPathname */ + bool useJournal = ( flags & PAGER_OMIT_JOURNAL ) == 0; /* False to omit journal */ + bool noReadlock = ( flags & PAGER_NO_READLOCK ) != 0; /* True to omit read-lock */ + int pcacheSize = sqlite3PcacheSize(); /* Bytes to allocate for PCache */ + u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE; /* Default page size */ + string zUri = null; /* URI args to copy */ + int nUri = 0; /* Number of bytes of URI args at *zUri */ + + /* Figure out how much space is required for each journal file-handle + ** (there are two of them, the main journal and the sub-journal). This + ** is the maximum space required for an in-memory journal file handle + ** and a regular journal file-handle. Note that a "regular journal-handle" + ** may be a wrapper capable of caching the first portion of the journal + ** file in memory to implement the atomic-write optimization (see + ** source file journal.c). + */ + if ( sqlite3JournalSize( pVfs ) > sqlite3MemJournalSize() ) + { + journalFileSize = ROUND8( sqlite3JournalSize( pVfs ) ); + } + else + { + journalFileSize = ROUND8( sqlite3MemJournalSize() ); + } + + /* Set the output variable to NULL in case an error occurs. */ + ppPager = null; #if !SQLITE_OMIT_MEMORYDB - if ((flags & PAGER_MEMORY) != 0) { - memDb = 1; - zFilename = null; - } + if ( ( flags & PAGER_MEMORY ) != 0 ) + { + memDb = 1; + zFilename = null; + } #endif - /* Compute and store the full pathname in an allocated buffer pointed - ** to by zPathname, length nPathname. Or, if this is a temporary file, - ** leave both nPathname and zPathname set to 0. - */ - if (!String.IsNullOrEmpty(zFilename)) { - nPathname = pVfs.mxPathname + 1; - zPathname = new StringBuilder(nPathname * 2);// sqlite3Malloc( nPathname * 2 ); - //if ( zPathname == null ) - //{ - // return SQLITE_NOMEM; - //} - //zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */ - rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname); - - nPathname = sqlite3Strlen30(zPathname); - zUri = zFilename; - //string z = zUri = zFilename;//.Substring(sqlite3Strlen30( zFilename ) ); - //while ( *z ) - //{ - // z += sqlite3Strlen30( z ) + 1; - // z += sqlite3Strlen30( z ) + 1; - //} - //nUri = zUri.Length;// &z[1] - zUri; - if (rc == SQLITE_OK && nPathname + 8 > pVfs.mxPathname) { - /* This branch is taken when the journal path required by - ** the database being opened will be more than pVfs.mxPathname - ** bytes in length. This means the database cannot be opened, - ** as it will not be possible to open the journal file or even - ** check for a hot-journal before reading. - */ - rc = SQLITE_CANTOPEN_BKPT(); - } - if (rc != SQLITE_OK) { - //sqlite3_free( ref zPathname ); - return rc; - } - } + /* Compute and store the full pathname in an allocated buffer pointed + ** to by zPathname, length nPathname. Or, if this is a temporary file, + ** leave both nPathname and zPathname set to 0. + */ + if ( !String.IsNullOrEmpty( zFilename ) ) + { + nPathname = pVfs.mxPathname + 1; + zPathname = new StringBuilder( nPathname * 2 );// sqlite3Malloc( nPathname * 2 ); + //if ( zPathname == null ) + //{ + // return SQLITE_NOMEM; + //} + //zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */ + rc = sqlite3OsFullPathname( pVfs, zFilename, nPathname, zPathname ); + + nPathname = sqlite3Strlen30( zPathname ); + zUri = zFilename; + //string z = zUri = zFilename;//.Substring(sqlite3Strlen30( zFilename ) ); + //while ( *z ) + //{ + // z += sqlite3Strlen30( z ) + 1; + // z += sqlite3Strlen30( z ) + 1; + //} + //nUri = zUri.Length;// &z[1] - zUri; + if ( rc == SQLITE_OK && nPathname + 8 > pVfs.mxPathname ) + { + /* This branch is taken when the journal path required by + ** the database being opened will be more than pVfs.mxPathname + ** bytes in length. This means the database cannot be opened, + ** as it will not be possible to open the journal file or even + ** check for a hot-journal before reading. + */ + rc = SQLITE_CANTOPEN_BKPT(); + } + if ( rc != SQLITE_OK ) + { + //sqlite3_free( ref zPathname ); + return rc; + } + } - /* Allocate memory for the Pager structure, PCache object, the - ** three file descriptors, the database file name and the journal - ** file name. The layout in memory is as follows: - ** - ** Pager object (sizeof(Pager) bytes) - ** PCache object (sqlite3PcacheSize() bytes) - ** Database file handle (pVfs.szOsFile bytes) - ** Sub-journal file handle (journalFileSize bytes) - ** Main journal file handle (journalFileSize bytes) - ** Database file name (nPathname+1 bytes) - ** Journal file name (nPathname+8+1 bytes) - */ - //pPtr = (u8 *)sqlite3MallocZero( - // ROUND8(sizeof(*pPager)) + /* Pager structure */ - // ROUND8(pcacheSize) + /* PCache object */ - // ROUND8(pVfs.szOsFile) + /* The main db file */ - // journalFileSize * 2 + /* The two journal files */ - // nPathname + 1 + nUri + /* zFilename */ - // nPathname + 8 + 1 /* zJournal */ - //#if !SQLITE_OMIT_WAL - // + nPathname + 4 + 1 /* zWal */ - //#endif - //); - // Debug.Assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize))); - //if( !pPtr ){ - // //sqlite3_free(zPathname); - // return SQLITE_NOMEM; - //} - pPager = new Pager();//(Pager*)(pPtr); - pPager.pPCache = new PCache();//(PCache*)(pPtr += ROUND8(sizeof(*pPager))); - pPager.fd = new sqlite3_file();//(sqlite3_file*)(pPtr += ROUND8(pcacheSize)); - pPager.sjfd = new sqlite3_file();//(sqlite3_file*)(pPtr += ROUND8(pVfs.szOsFile)); - pPager.jfd = new sqlite3_file();//(sqlite3_file*)(pPtr += journalFileSize); - //pPager.zFilename = (char*)(pPtr += journalFileSize); - //Debug.Assert( EIGHT_BYTE_ALIGNMENT(pPager.jfd) ); - - /* Fill in the Pager.zFilename and Pager.zJournal buffers, if required. */ - if (zPathname != null) { - Debug.Assert(nPathname > 0); - //pPager.zJournal = (char*)(pPtr += nPathname + 1 + nUri); - //memcpy(pPager.zFilename, zPathname, nPathname); - pPager.zFilename = zPathname.ToString(); - zUri = pPager.zFilename;//.Substring( nPathname + 1 );//memcpy( &pPager.zFilename[nPathname + 1], zUri, nUri ); - //memcpy(pPager.zJournal, zPathname, nPathname); - //memcpy(&pPager.zJournal[nPathname], "-journal", 8); - pPager.zJournal = pPager.zFilename + "-journal"; - sqlite3FileSuffix3(pPager.zFilename, pPager.zJournal); + /* Allocate memory for the Pager structure, PCache object, the + ** three file descriptors, the database file name and the journal + ** file name. The layout in memory is as follows: + ** + ** Pager object (sizeof(Pager) bytes) + ** PCache object (sqlite3PcacheSize() bytes) + ** Database file handle (pVfs.szOsFile bytes) + ** Sub-journal file handle (journalFileSize bytes) + ** Main journal file handle (journalFileSize bytes) + ** Database file name (nPathname+1 bytes) + ** Journal file name (nPathname+8+1 bytes) + */ + //pPtr = (u8 *)sqlite3MallocZero( + // ROUND8(sizeof(*pPager)) + /* Pager structure */ + // ROUND8(pcacheSize) + /* PCache object */ + // ROUND8(pVfs.szOsFile) + /* The main db file */ + // journalFileSize * 2 + /* The two journal files */ + // nPathname + 1 + nUri + /* zFilename */ + // nPathname + 8 + 1 /* zJournal */ + //#if !SQLITE_OMIT_WAL + // + nPathname + 4 + 1 /* zWal */ + //#endif + //); + // Debug.Assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize))); + //if( !pPtr ){ + // //sqlite3_free(zPathname); + // return SQLITE_NOMEM; + //} + pPager = new Pager();//(Pager*)(pPtr); + pPager.pPCache = new PCache();//(PCache*)(pPtr += ROUND8(sizeof(*pPager))); + pPager.fd = new sqlite3_file();//(sqlite3_file*)(pPtr += ROUND8(pcacheSize)); + pPager.sjfd = new sqlite3_file();//(sqlite3_file*)(pPtr += ROUND8(pVfs.szOsFile)); + pPager.jfd = new sqlite3_file();//(sqlite3_file*)(pPtr += journalFileSize); + //pPager.zFilename = (char*)(pPtr += journalFileSize); + //Debug.Assert( EIGHT_BYTE_ALIGNMENT(pPager.jfd) ); + + /* Fill in the Pager.zFilename and Pager.zJournal buffers, if required. */ + if ( zPathname != null ) + { + Debug.Assert( nPathname > 0 ); + //pPager.zJournal = (char*)(pPtr += nPathname + 1 + nUri); + //memcpy(pPager.zFilename, zPathname, nPathname); + pPager.zFilename = zPathname.ToString(); + zUri = pPager.zFilename;//.Substring( nPathname + 1 );//memcpy( &pPager.zFilename[nPathname + 1], zUri, nUri ); + //memcpy(pPager.zJournal, zPathname, nPathname); + //memcpy(&pPager.zJournal[nPathname], "-journal", 8); + pPager.zJournal = pPager.zFilename + "-journal"; + sqlite3FileSuffix3( pPager.zFilename, pPager.zJournal ); #if !SQLITE_OMIT_WAL pPager.zWal = &pPager.zJournal[nPathname+8+1]; memcpy(pPager.zWal, zPathname, nPathname); @@ -4717,39 +5012,47 @@ dxReiniter xReinit /* Function to reinitialize pages */ sqlite3FileSuffix3(pPager.zFilename, pPager.zWal); #endif - //sqlite3_free( ref zPathname ); - } else { - pPager.zFilename = ""; - } - pPager.pVfs = pVfs; - pPager.vfsFlags = (u32)vfsFlags; + //sqlite3_free( ref zPathname ); + } + else + { + pPager.zFilename = ""; + } + pPager.pVfs = pVfs; + pPager.vfsFlags = (u32)vfsFlags; - /* Open the pager file. - */ - if (!String.IsNullOrEmpty(pPager.zFilename)) { - int fout = 0; /* VFS flags returned by xOpen() */ - rc = sqlite3OsOpen(pVfs, pPager.zFilename, pPager.fd, vfsFlags, ref fout); - Debug.Assert(0 == memDb); - readOnly = (fout & SQLITE_OPEN_READONLY) != 0; - - /* If the file was successfully opened for read/write access, - ** choose a default page size in case we have to create the - ** database file. The default page size is the maximum of: - ** - ** + SQLITE_DEFAULT_PAGE_SIZE, - ** + The value returned by sqlite3OsSectorSize() - ** + The largest page size that can be written atomically. - */ - if (rc == SQLITE_OK && !readOnly) { - setSectorSize(pPager); - Debug.Assert(SQLITE_DEFAULT_PAGE_SIZE <= SQLITE_MAX_DEFAULT_PAGE_SIZE); - if (szPageDflt < pPager.sectorSize) { - if (pPager.sectorSize > SQLITE_MAX_DEFAULT_PAGE_SIZE) { - szPageDflt = SQLITE_MAX_DEFAULT_PAGE_SIZE; - } else { - szPageDflt = (u32)pPager.sectorSize; - } - } + /* Open the pager file. + */ + if ( !String.IsNullOrEmpty( pPager.zFilename ) ) + { + int fout = 0; /* VFS flags returned by xOpen() */ + rc = sqlite3OsOpen( pVfs, pPager.zFilename, pPager.fd, vfsFlags, ref fout ); + Debug.Assert( 0 == memDb ); + readOnly = ( fout & SQLITE_OPEN_READONLY ) != 0; + + /* If the file was successfully opened for read/write access, + ** choose a default page size in case we have to create the + ** database file. The default page size is the maximum of: + ** + ** + SQLITE_DEFAULT_PAGE_SIZE, + ** + The value returned by sqlite3OsSectorSize() + ** + The largest page size that can be written atomically. + */ + if ( rc == SQLITE_OK && !readOnly ) + { + setSectorSize( pPager ); + Debug.Assert( SQLITE_DEFAULT_PAGE_SIZE <= SQLITE_MAX_DEFAULT_PAGE_SIZE ); + if ( szPageDflt < pPager.sectorSize ) + { + if ( pPager.sectorSize > SQLITE_MAX_DEFAULT_PAGE_SIZE ) + { + szPageDflt = SQLITE_MAX_DEFAULT_PAGE_SIZE; + } + else + { + szPageDflt = (u32)pPager.sectorSize; + } + } #if SQLITE_ENABLE_ATOMIC_WRITE { int iDc = sqlite3OsDeviceCharacteristics(pPager.fd); @@ -4764,978 +5067,1078 @@ dxReiniter xReinit /* Function to reinitialize pages */ } } #endif - } - } else { - /* If a temporary file is requested, it is not opened immediately. - ** In this case we accept the default page size and delay actually - ** opening the file until the first call to OsWrite(). - ** - ** This branch is also run for an in-memory database. An in-memory - ** database is the same as a temp-file that is never written out to - ** disk and uses an in-memory rollback journal. - */ - tempFile = 1; - pPager.eState = PAGER_READER; - pPager.eLock = EXCLUSIVE_LOCK; - readOnly = (vfsFlags & SQLITE_OPEN_READONLY) != 0; - } + } + } + else + { + /* If a temporary file is requested, it is not opened immediately. + ** In this case we accept the default page size and delay actually + ** opening the file until the first call to OsWrite(). + ** + ** This branch is also run for an in-memory database. An in-memory + ** database is the same as a temp-file that is never written out to + ** disk and uses an in-memory rollback journal. + */ + tempFile = 1; + pPager.eState = PAGER_READER; + pPager.eLock = EXCLUSIVE_LOCK; + readOnly = ( vfsFlags & SQLITE_OPEN_READONLY ) != 0; + } - /* The following call to PagerSetPagesize() serves to set the value of - ** Pager.pageSize and to allocate the Pager.pTmpSpace buffer. - */ - if (rc == SQLITE_OK) { - Debug.Assert(pPager.memDb == 0); - rc = sqlite3PagerSetPagesize(pPager, ref szPageDflt, -1); - testcase(rc != SQLITE_OK); - } + /* The following call to PagerSetPagesize() serves to set the value of + ** Pager.pageSize and to allocate the Pager.pTmpSpace buffer. + */ + if ( rc == SQLITE_OK ) + { + Debug.Assert( pPager.memDb == 0 ); + rc = sqlite3PagerSetPagesize( pPager, ref szPageDflt, -1 ); + testcase( rc != SQLITE_OK ); + } - /* If an error occurred in either of the blocks above, free the - ** Pager structure and close the file. - */ - if (rc != SQLITE_OK) { - Debug.Assert(null == pPager.pTmpSpace); - sqlite3OsClose(pPager.fd); - //sqlite3_free( ref pPager ); - return rc; - } + /* If an error occurred in either of the blocks above, free the + ** Pager structure and close the file. + */ + if ( rc != SQLITE_OK ) + { + Debug.Assert( null == pPager.pTmpSpace ); + sqlite3OsClose( pPager.fd ); + //sqlite3_free( ref pPager ); + return rc; + } - /* Initialize the PCache object. */ - Debug.Assert(nExtra < 1000); - nExtra = ROUND8(nExtra); - sqlite3PcacheOpen((int)szPageDflt, nExtra, 0 == memDb, - 0 == memDb ? (dxStress)pagerStress : null, pPager, pPager.pPCache); - - PAGERTRACE("OPEN %d %s\n", FILEHANDLEID(pPager.fd), pPager.zFilename); - IOTRACE("OPEN %p %s\n", pPager, pPager.zFilename); - pPager.useJournal = (u8)(useJournal ? 1 : 0); - pPager.noReadlock = (u8)(noReadlock && readOnly ? 1 : 0); - /* pPager.stmtOpen = 0; */ - /* pPager.stmtInUse = 0; */ - /* pPager.nRef = 0; */ - /* pPager.stmtSize = 0; */ - /* pPager.stmtJSize = 0; */ - /* pPager.nPage = 0; */ - pPager.mxPgno = SQLITE_MAX_PAGE_COUNT; - /* pPager.state = PAGER_UNLOCK; */ + /* Initialize the PCache object. */ + Debug.Assert( nExtra < 1000 ); + nExtra = ROUND8( nExtra ); + sqlite3PcacheOpen( (int)szPageDflt, nExtra, 0 == memDb, + 0 == memDb ? (dxStress)pagerStress : null, pPager, pPager.pPCache ); + + PAGERTRACE( "OPEN %d %s\n", FILEHANDLEID( pPager.fd ), pPager.zFilename ); + IOTRACE( "OPEN %p %s\n", pPager, pPager.zFilename ); + pPager.useJournal = (u8)( useJournal ? 1 : 0 ); + pPager.noReadlock = (u8)( noReadlock && readOnly ? 1 : 0 ); + /* pPager.stmtOpen = 0; */ + /* pPager.stmtInUse = 0; */ + /* pPager.nRef = 0; */ + /* pPager.stmtSize = 0; */ + /* pPager.stmtJSize = 0; */ + /* pPager.nPage = 0; */ + pPager.mxPgno = SQLITE_MAX_PAGE_COUNT; + /* pPager.state = PAGER_UNLOCK; */ #if FALSE Debug.Assert(pPager.state == (tempFile != 0 ? PAGER_EXCLUSIVE : PAGER_UNLOCK)); #endif - /* pPager.errMask = 0; */ - pPager.tempFile = tempFile != 0; - Debug.Assert(tempFile == PAGER_LOCKINGMODE_NORMAL - || tempFile == PAGER_LOCKINGMODE_EXCLUSIVE); - Debug.Assert(PAGER_LOCKINGMODE_EXCLUSIVE == 1); - pPager.exclusiveMode = tempFile != 0; - pPager.changeCountDone = pPager.tempFile; - pPager.memDb = memDb; - pPager.readOnly = readOnly; - Debug.Assert(useJournal || pPager.tempFile); - pPager.noSync = pPager.tempFile; - pPager.fullSync = pPager.noSync; - pPager.syncFlags = (byte)(pPager.noSync ? 0 : SQLITE_SYNC_NORMAL); - pPager.ckptSyncFlags = pPager.syncFlags; - /* pPager.pFirst = 0; */ - /* pPager.pFirstSynced = 0; */ - /* pPager.pLast = 0; */ - pPager.nExtra = (u16)nExtra; - pPager.journalSizeLimit = SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT; - Debug.Assert(isOpen(pPager.fd) || tempFile != 0); - setSectorSize(pPager); - if (!useJournal) { - pPager.journalMode = PAGER_JOURNALMODE_OFF; - } else if (memDb != 0) { - pPager.journalMode = PAGER_JOURNALMODE_MEMORY; - } - /* pPager.xBusyHandler = 0; */ - /* pPager.pBusyHandlerArg = 0; */ - pPager.xReiniter = xReinit; - /* memset(pPager.aHash, 0, sizeof(pPager.aHash)); */ - ppPager = pPager; - return SQLITE_OK; - } + /* pPager.errMask = 0; */ + pPager.tempFile = tempFile != 0; + Debug.Assert( tempFile == PAGER_LOCKINGMODE_NORMAL + || tempFile == PAGER_LOCKINGMODE_EXCLUSIVE ); + Debug.Assert( PAGER_LOCKINGMODE_EXCLUSIVE == 1 ); + pPager.exclusiveMode = tempFile != 0; + pPager.changeCountDone = pPager.tempFile; + pPager.memDb = memDb; + pPager.readOnly = readOnly; + Debug.Assert( useJournal || pPager.tempFile ); + pPager.noSync = pPager.tempFile; + pPager.fullSync = pPager.noSync; + pPager.syncFlags = (byte)( pPager.noSync ? 0 : SQLITE_SYNC_NORMAL ); + pPager.ckptSyncFlags = pPager.syncFlags; + /* pPager.pFirst = 0; */ + /* pPager.pFirstSynced = 0; */ + /* pPager.pLast = 0; */ + pPager.nExtra = (u16)nExtra; + pPager.journalSizeLimit = SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT; + Debug.Assert( isOpen( pPager.fd ) || tempFile != 0 ); + setSectorSize( pPager ); + if ( !useJournal ) + { + pPager.journalMode = PAGER_JOURNALMODE_OFF; + } + else if ( memDb != 0 ) + { + pPager.journalMode = PAGER_JOURNALMODE_MEMORY; + } + /* pPager.xBusyHandler = 0; */ + /* pPager.pBusyHandlerArg = 0; */ + pPager.xReiniter = xReinit; + /* memset(pPager.aHash, 0, sizeof(pPager.aHash)); */ + ppPager = pPager; + return SQLITE_OK; + } - /* - ** This function is called after transitioning from PAGER_UNLOCK to - ** PAGER_SHARED state. It tests if there is a hot journal present in - ** the file-system for the given pager. A hot journal is one that - ** needs to be played back. According to this function, a hot-journal - ** file exists if the following criteria are met: - ** - ** * The journal file exists in the file system, and - ** * No process holds a RESERVED or greater lock on the database file, and - ** * The database file itself is greater than 0 bytes in size, and - ** * The first byte of the journal file exists and is not 0x00. - ** - ** If the current size of the database file is 0 but a journal file - ** exists, that is probably an old journal left over from a prior - ** database with the same name. In this case the journal file is - ** just deleted using OsDelete, *pExists is set to 0 and SQLITE_OK - ** is returned. - ** - ** This routine does not check if there is a master journal filename - ** at the end of the file. If there is, and that master journal file - ** does not exist, then the journal file is not really hot. In this - ** case this routine will return a false-positive. The pager_playback() - ** routine will discover that the journal file is not really hot and - ** will not roll it back. - ** - ** If a hot-journal file is found to exist, *pExists is set to 1 and - ** SQLITE_OK returned. If no hot-journal file is present, *pExists is - ** set to 0 and SQLITE_OK returned. If an IO error occurs while trying - ** to determine whether or not a hot-journal file exists, the IO error - ** code is returned and the value of *pExists is undefined. - */ - static int hasHotJournal(Pager pPager, ref int pExists) { - sqlite3_vfs pVfs = pPager.pVfs; - int rc = SQLITE_OK; /* Return code */ - int exists = 1; /* True if a journal file is present */ - int jrnlOpen = isOpen(pPager.jfd) ? 1 : 0; - Debug.Assert(pPager.useJournal != 0); - Debug.Assert(isOpen(pPager.fd)); - Debug.Assert(pPager.eState == PAGER_OPEN); + /* + ** This function is called after transitioning from PAGER_UNLOCK to + ** PAGER_SHARED state. It tests if there is a hot journal present in + ** the file-system for the given pager. A hot journal is one that + ** needs to be played back. According to this function, a hot-journal + ** file exists if the following criteria are met: + ** + ** * The journal file exists in the file system, and + ** * No process holds a RESERVED or greater lock on the database file, and + ** * The database file itself is greater than 0 bytes in size, and + ** * The first byte of the journal file exists and is not 0x00. + ** + ** If the current size of the database file is 0 but a journal file + ** exists, that is probably an old journal left over from a prior + ** database with the same name. In this case the journal file is + ** just deleted using OsDelete, *pExists is set to 0 and SQLITE_OK + ** is returned. + ** + ** This routine does not check if there is a master journal filename + ** at the end of the file. If there is, and that master journal file + ** does not exist, then the journal file is not really hot. In this + ** case this routine will return a false-positive. The pager_playback() + ** routine will discover that the journal file is not really hot and + ** will not roll it back. + ** + ** If a hot-journal file is found to exist, *pExists is set to 1 and + ** SQLITE_OK returned. If no hot-journal file is present, *pExists is + ** set to 0 and SQLITE_OK returned. If an IO error occurs while trying + ** to determine whether or not a hot-journal file exists, the IO error + ** code is returned and the value of *pExists is undefined. + */ + static int hasHotJournal( Pager pPager, ref int pExists ) + { + sqlite3_vfs pVfs = pPager.pVfs; + int rc = SQLITE_OK; /* Return code */ + int exists = 1; /* True if a journal file is present */ + int jrnlOpen = isOpen( pPager.jfd ) ? 1 : 0; + Debug.Assert( pPager.useJournal != 0 ); + Debug.Assert( isOpen( pPager.fd ) ); + Debug.Assert( pPager.eState == PAGER_OPEN ); - Debug.Assert(jrnlOpen == 0 || (sqlite3OsDeviceCharacteristics(pPager.jfd) & - SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN - ) != 0); + Debug.Assert( jrnlOpen == 0 || ( sqlite3OsDeviceCharacteristics( pPager.jfd ) & + SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN + ) != 0 ); - pExists = 0; + pExists = 0; - if (0 == jrnlOpen) { - rc = sqlite3OsAccess(pVfs, pPager.zJournal, SQLITE_ACCESS_EXISTS, ref exists); - } - if (rc == SQLITE_OK && exists != 0) { - int locked = 0; /* True if some process holds a RESERVED lock */ - - /* Race condition here: Another process might have been holding the - ** the RESERVED lock and have a journal open at the sqlite3OsAccess() - ** call above, but then delete the journal and drop the lock before - ** we get to the following sqlite3OsCheckReservedLock() call. If that - ** is the case, this routine might think there is a hot journal when - ** in fact there is none. This results in a false-positive which will - ** be dealt with by the playback routine. Ticket #3883. - */ - rc = sqlite3OsCheckReservedLock(pPager.fd, ref locked); - if (rc == SQLITE_OK && locked == 0) { - Pgno nPage = 0; /* Number of pages in database file */ - - /* Check the size of the database file. If it consists of 0 pages, - ** then delete the journal file. See the header comment above for - ** the reasoning here. Delete the obsolete journal file under - ** a RESERVED lock to avoid race conditions and to avoid violating - ** [H33020]. - */ - rc = pagerPagecount(pPager, ref nPage); - if (rc == SQLITE_OK) { - if (nPage == 0) { - sqlite3BeginBenignMalloc(); - if (pagerLockDb(pPager, RESERVED_LOCK) == SQLITE_OK) { - sqlite3OsDelete(pVfs, pPager.zJournal, 0); - if (!pPager.exclusiveMode) - pagerUnlockDb(pPager, SHARED_LOCK); - } - sqlite3EndBenignMalloc(); - } else { - /* The journal file exists and no other connection has a reserved - ** or greater lock on the database file. Now check that there is - ** at least one non-zero bytes at the start of the journal file. - ** If there is, then we consider this journal to be hot. If not, - ** it can be ignored. - */ - if (0 == jrnlOpen) { - int f = SQLITE_OPEN_READONLY | SQLITE_OPEN_MAIN_JOURNAL; - rc = sqlite3OsOpen(pVfs, pPager.zJournal, pPager.jfd, f, ref f); - } - if (rc == SQLITE_OK) { - u8[] first = new u8[1]; - rc = sqlite3OsRead(pPager.jfd, first, 1, 0); - if (rc == SQLITE_IOERR_SHORT_READ) { - rc = SQLITE_OK; - } - if (0 == jrnlOpen) { - sqlite3OsClose(pPager.jfd); - } - pExists = (first[0] != 0) ? 1 : 0; - } else if (rc == SQLITE_CANTOPEN) { - /* If we cannot open the rollback journal file in order to see if - ** its has a zero header, that might be due to an I/O error, or - ** it might be due to the race condition described above and in - ** ticket #3883. Either way, assume that the journal is hot. - ** This might be a false positive. But if it is, then the - ** automatic journal playback and recovery mechanism will deal - ** with it under an EXCLUSIVE lock where we do not need to - ** worry so much with race conditions. - */ - pExists = 1; - rc = SQLITE_OK; - } - } - } + if ( 0 == jrnlOpen ) + { + rc = sqlite3OsAccess( pVfs, pPager.zJournal, SQLITE_ACCESS_EXISTS, ref exists ); + } + if ( rc == SQLITE_OK && exists != 0 ) + { + int locked = 0; /* True if some process holds a RESERVED lock */ + + /* Race condition here: Another process might have been holding the + ** the RESERVED lock and have a journal open at the sqlite3OsAccess() + ** call above, but then delete the journal and drop the lock before + ** we get to the following sqlite3OsCheckReservedLock() call. If that + ** is the case, this routine might think there is a hot journal when + ** in fact there is none. This results in a false-positive which will + ** be dealt with by the playback routine. Ticket #3883. + */ + rc = sqlite3OsCheckReservedLock( pPager.fd, ref locked ); + if ( rc == SQLITE_OK && locked == 0 ) + { + Pgno nPage = 0; /* Number of pages in database file */ + + /* Check the size of the database file. If it consists of 0 pages, + ** then delete the journal file. See the header comment above for + ** the reasoning here. Delete the obsolete journal file under + ** a RESERVED lock to avoid race conditions and to avoid violating + ** [H33020]. + */ + rc = pagerPagecount( pPager, ref nPage ); + if ( rc == SQLITE_OK ) + { + if ( nPage == 0 ) + { + sqlite3BeginBenignMalloc(); + if ( pagerLockDb( pPager, RESERVED_LOCK ) == SQLITE_OK ) + { + sqlite3OsDelete( pVfs, pPager.zJournal, 0 ); + if ( !pPager.exclusiveMode ) + pagerUnlockDb( pPager, SHARED_LOCK ); + } + sqlite3EndBenignMalloc(); + } + else + { + /* The journal file exists and no other connection has a reserved + ** or greater lock on the database file. Now check that there is + ** at least one non-zero bytes at the start of the journal file. + ** If there is, then we consider this journal to be hot. If not, + ** it can be ignored. + */ + if ( 0 == jrnlOpen ) + { + int f = SQLITE_OPEN_READONLY | SQLITE_OPEN_MAIN_JOURNAL; + rc = sqlite3OsOpen( pVfs, pPager.zJournal, pPager.jfd, f, ref f ); + } + if ( rc == SQLITE_OK ) + { + u8[] first = new u8[1]; + rc = sqlite3OsRead( pPager.jfd, first, 1, 0 ); + if ( rc == SQLITE_IOERR_SHORT_READ ) + { + rc = SQLITE_OK; + } + if ( 0 == jrnlOpen ) + { + sqlite3OsClose( pPager.jfd ); } + pExists = ( first[0] != 0 ) ? 1 : 0; + } + else if ( rc == SQLITE_CANTOPEN ) + { + /* If we cannot open the rollback journal file in order to see if + ** its has a zero header, that might be due to an I/O error, or + ** it might be due to the race condition described above and in + ** ticket #3883. Either way, assume that the journal is hot. + ** This might be a false positive. But if it is, then the + ** automatic journal playback and recovery mechanism will deal + ** with it under an EXCLUSIVE lock where we do not need to + ** worry so much with race conditions. + */ + pExists = 1; + rc = SQLITE_OK; + } } - return rc; + } } + } + return rc; + } - /* - ** This function is called to obtain a shared lock on the database file. - ** It is illegal to call sqlite3PagerAcquire() until after this function - ** has been successfully called. If a shared-lock is already held when - ** this function is called, it is a no-op. - ** - ** The following operations are also performed by this function. - ** - ** 1) If the pager is currently in PAGER_OPEN state (no lock held - ** on the database file), then an attempt is made to obtain a - ** SHARED lock on the database file. Immediately after obtaining - ** the SHARED lock, the file-system is checked for a hot-journal, - ** which is played back if present. Following any hot-journal - ** rollback, the contents of the cache are validated by checking - ** the 'change-counter' field of the database file header and - ** discarded if they are found to be invalid. - ** - ** 2) If the pager is running in exclusive-mode, and there are currently - ** no outstanding references to any pages, and is in the error state, - ** then an attempt is made to clear the error state by discarding - ** the contents of the page cache and rolling back any open journal - ** file. - ** - ** If everything is successful, SQLITE_OK is returned. If an IO error - ** occurs while locking the database, checking for a hot-journal file or - ** rolling back a journal file, the IO error code is returned. - */ - static int sqlite3PagerSharedLock(Pager pPager) { - int rc = SQLITE_OK; /* Return code */ + /* + ** This function is called to obtain a shared lock on the database file. + ** It is illegal to call sqlite3PagerAcquire() until after this function + ** has been successfully called. If a shared-lock is already held when + ** this function is called, it is a no-op. + ** + ** The following operations are also performed by this function. + ** + ** 1) If the pager is currently in PAGER_OPEN state (no lock held + ** on the database file), then an attempt is made to obtain a + ** SHARED lock on the database file. Immediately after obtaining + ** the SHARED lock, the file-system is checked for a hot-journal, + ** which is played back if present. Following any hot-journal + ** rollback, the contents of the cache are validated by checking + ** the 'change-counter' field of the database file header and + ** discarded if they are found to be invalid. + ** + ** 2) If the pager is running in exclusive-mode, and there are currently + ** no outstanding references to any pages, and is in the error state, + ** then an attempt is made to clear the error state by discarding + ** the contents of the page cache and rolling back any open journal + ** file. + ** + ** If everything is successful, SQLITE_OK is returned. If an IO error + ** occurs while locking the database, checking for a hot-journal file or + ** rolling back a journal file, the IO error code is returned. + */ + static int sqlite3PagerSharedLock( Pager pPager ) + { + int rc = SQLITE_OK; /* Return code */ - /* This routine is only called from b-tree and only when there are no - ** outstanding pages. This implies that the pager state should either - ** be OPEN or READER. READER is only possible if the pager is or was in - ** exclusive access mode. - */ - Debug.Assert(sqlite3PcacheRefCount(pPager.pPCache) == 0); - Debug.Assert(assert_pager_state(pPager)); - Debug.Assert(pPager.eState == PAGER_OPEN || pPager.eState == PAGER_READER); - if (NEVER( + /* This routine is only called from b-tree and only when there are no + ** outstanding pages. This implies that the pager state should either + ** be OPEN or READER. READER is only possible if the pager is or was in + ** exclusive access mode. + */ + Debug.Assert( sqlite3PcacheRefCount( pPager.pPCache ) == 0 ); + Debug.Assert( assert_pager_state( pPager ) ); + Debug.Assert( pPager.eState == PAGER_OPEN || pPager.eState == PAGER_READER ); + if ( NEVER( #if SQLITE_OMIT_MEMORYDB 0!=MEMDB #else - 0 != pPager.memDb + 0 != pPager.memDb #endif - && pPager.errCode != 0)) { - return pPager.errCode; - } + && pPager.errCode != 0 ) ) + { + return pPager.errCode; + } - if (!pagerUseWal(pPager) && pPager.eState == PAGER_OPEN) { - int bHotJournal = 1; /* True if there exists a hot journal-file */ + if ( !pagerUseWal( pPager ) && pPager.eState == PAGER_OPEN ) + { + int bHotJournal = 1; /* True if there exists a hot journal-file */ - Debug.Assert( + Debug.Assert( #if SQLITE_OMIT_MEMORYDB 0==MEMDB #else - 0 == pPager.memDb + 0 == pPager.memDb #endif - ); - Debug.Assert(pPager.noReadlock == 0 || pPager.readOnly); - - if (pPager.noReadlock == 0) { - rc = pager_wait_on_lock(pPager, SHARED_LOCK); - if (rc != SQLITE_OK) { - Debug.Assert(pPager.eLock == NO_LOCK || pPager.eLock == UNKNOWN_LOCK); - goto failed; - } - } + ); + Debug.Assert( pPager.noReadlock == 0 || pPager.readOnly ); - /* If a journal file exists, and there is no RESERVED lock on the - ** database file, then it either needs to be played back or deleted. - */ - if (pPager.eLock <= SHARED_LOCK) { - rc = hasHotJournal(pPager, ref bHotJournal); - } - if (rc != SQLITE_OK) { - goto failed; - } - if (bHotJournal != 0) { - /* Get an EXCLUSIVE lock on the database file. At this point it is - ** important that a RESERVED lock is not obtained on the way to the - ** EXCLUSIVE lock. If it were, another process might open the - ** database file, detect the RESERVED lock, and conclude that the - ** database is safe to read while this process is still rolling the - ** hot-journal back. - ** - ** Because the intermediate RESERVED lock is not requested, any - ** other process attempting to access the database file will get to - ** this point in the code and fail to obtain its own EXCLUSIVE lock - ** on the database file. - ** - ** Unless the pager is in locking_mode=exclusive mode, the lock is - ** downgraded to SHARED_LOCK before this function returns. - */ - rc = pagerLockDb(pPager, EXCLUSIVE_LOCK); - if (rc != SQLITE_OK) { - goto failed; - } - - /* If it is not already open and the file exists on disk, open the - ** journal for read/write access. Write access is required because - ** in exclusive-access mode the file descriptor will be kept open - ** and possibly used for a transaction later on. Also, write-access - ** is usually required to finalize the journal in journal_mode=persist - ** mode (and also for journal_mode=truncate on some systems). - ** - ** If the journal does not exist, it usually means that some - ** other connection managed to get in and roll it back before - ** this connection obtained the exclusive lock above. Or, it - ** may mean that the pager was in the error-state when this - ** function was called and the journal file does not exist. - */ - if (!isOpen(pPager.jfd)) { - sqlite3_vfs pVfs = pPager.pVfs; - int bExists = 0; /* True if journal file exists */ - rc = sqlite3OsAccess( - pVfs, pPager.zJournal, SQLITE_ACCESS_EXISTS, ref bExists); - if (rc == SQLITE_OK && bExists != 0) { - int fout = 0; - int f = SQLITE_OPEN_READWRITE | SQLITE_OPEN_MAIN_JOURNAL; - Debug.Assert(!pPager.tempFile); - rc = sqlite3OsOpen(pVfs, pPager.zJournal, pPager.jfd, f, ref fout); - Debug.Assert(rc != SQLITE_OK || isOpen(pPager.jfd)); - if (rc == SQLITE_OK && (fout & SQLITE_OPEN_READONLY) != 0) { - rc = SQLITE_CANTOPEN_BKPT(); - sqlite3OsClose(pPager.jfd); - } - } - } - - /* Playback and delete the journal. Drop the database write - ** lock and reacquire the read lock. Purge the cache before - ** playing back the hot-journal so that we don't end up with - ** an inconsistent cache. Sync the hot journal before playing - ** it back since the process that crashed and left the hot journal - ** probably did not sync it and we are required to always sync - ** the journal before playing it back. - */ - if (isOpen(pPager.jfd)) { - Debug.Assert(rc == SQLITE_OK); - rc = pagerSyncHotJournal(pPager); - if (rc == SQLITE_OK) { - rc = pager_playback(pPager, 1); - pPager.eState = PAGER_OPEN; - } - } else if (!pPager.exclusiveMode) { - pagerUnlockDb(pPager, SHARED_LOCK); - } - - if (rc != SQLITE_OK) { - /* This branch is taken if an error occurs while trying to open - ** or roll back a hot-journal while holding an EXCLUSIVE lock. The - ** pager_unlock() routine will be called before returning to unlock - ** the file. If the unlock attempt fails, then Pager.eLock must be - ** set to UNKNOWN_LOCK (see the comment above the #define for - ** UNKNOWN_LOCK above for an explanation). - ** - ** In order to get pager_unlock() to do this, set Pager.eState to - ** PAGER_ERROR now. This is not actually counted as a transition - ** to ERROR state in the state diagram at the top of this file, - ** since we know that the same call to pager_unlock() will very - ** shortly transition the pager object to the OPEN state. Calling - ** assert_pager_state() would fail now, as it should not be possible - ** to be in ERROR state when there are zero outstanding page - ** references. - */ - pager_error(pPager, rc); - goto failed; - } - - Debug.Assert(pPager.eState == PAGER_OPEN); - Debug.Assert((pPager.eLock == SHARED_LOCK) - || (pPager.exclusiveMode && pPager.eLock > SHARED_LOCK) - ); - } + if ( pPager.noReadlock == 0 ) + { + rc = pager_wait_on_lock( pPager, SHARED_LOCK ); + if ( rc != SQLITE_OK ) + { + Debug.Assert( pPager.eLock == NO_LOCK || pPager.eLock == UNKNOWN_LOCK ); + goto failed; + } + } - if (!pPager.tempFile - && (pPager.pBackup != null || sqlite3PcachePagecount(pPager.pPCache) > 0) - ) { - /* The shared-lock has just been acquired on the database file - ** and there are already pages in the cache (from a previous - ** read or write transaction). Check to see if the database - ** has been modified. If the database has changed, flush the - ** cache. - ** - ** Database changes is detected by looking at 15 bytes beginning - ** at offset 24 into the file. The first 4 of these 16 bytes are - ** a 32-bit counter that is incremented with each change. The - ** other bytes change randomly with each file change when - ** a codec is in use. - ** - ** There is a vanishingly small chance that a change will not be - ** detected. The chance of an undetected change is so small that - ** it can be neglected. - */ - Pgno nPage = 0; - byte[] dbFileVers = new byte[pPager.dbFileVers.Length]; - - rc = pagerPagecount(pPager, ref nPage); - if (rc != 0) - goto failed; - - if (nPage > 0) { - IOTRACE("CKVERS %p %d\n", pPager, dbFileVers.Length); - rc = sqlite3OsRead(pPager.fd, dbFileVers, dbFileVers.Length, 24); - if (rc != SQLITE_OK) { - goto failed; - } - } else { - Array.Clear(dbFileVers, 0, dbFileVers.Length);// memset( dbFileVers, 0, sizeof( dbFileVers ) ); - } - - if (memcmp(pPager.dbFileVers, dbFileVers, dbFileVers.Length) != 0) { - pager_reset(pPager); - } - } + /* If a journal file exists, and there is no RESERVED lock on the + ** database file, then it either needs to be played back or deleted. + */ + if ( pPager.eLock <= SHARED_LOCK ) + { + rc = hasHotJournal( pPager, ref bHotJournal ); + } + if ( rc != SQLITE_OK ) + { + goto failed; + } + if ( bHotJournal != 0 ) + { + /* Get an EXCLUSIVE lock on the database file. At this point it is + ** important that a RESERVED lock is not obtained on the way to the + ** EXCLUSIVE lock. If it were, another process might open the + ** database file, detect the RESERVED lock, and conclude that the + ** database is safe to read while this process is still rolling the + ** hot-journal back. + ** + ** Because the intermediate RESERVED lock is not requested, any + ** other process attempting to access the database file will get to + ** this point in the code and fail to obtain its own EXCLUSIVE lock + ** on the database file. + ** + ** Unless the pager is in locking_mode=exclusive mode, the lock is + ** downgraded to SHARED_LOCK before this function returns. + */ + rc = pagerLockDb( pPager, EXCLUSIVE_LOCK ); + if ( rc != SQLITE_OK ) + { + goto failed; + } - /* If there is a WAL file in the file-system, open this database in WAL - ** mode. Otherwise, the following function call is a no-op. - */ - rc = pagerOpenWalIfPresent(pPager); -#if !SQLITE_OMIT_WAL -Debug.Assert( pPager.pWal == null || rc == SQLITE_OK ); -#endif + /* If it is not already open and the file exists on disk, open the + ** journal for read/write access. Write access is required because + ** in exclusive-access mode the file descriptor will be kept open + ** and possibly used for a transaction later on. Also, write-access + ** is usually required to finalize the journal in journal_mode=persist + ** mode (and also for journal_mode=truncate on some systems). + ** + ** If the journal does not exist, it usually means that some + ** other connection managed to get in and roll it back before + ** this connection obtained the exclusive lock above. Or, it + ** may mean that the pager was in the error-state when this + ** function was called and the journal file does not exist. + */ + if ( !isOpen( pPager.jfd ) ) + { + sqlite3_vfs pVfs = pPager.pVfs; + int bExists = 0; /* True if journal file exists */ + rc = sqlite3OsAccess( + pVfs, pPager.zJournal, SQLITE_ACCESS_EXISTS, ref bExists ); + if ( rc == SQLITE_OK && bExists != 0 ) + { + int fout = 0; + int f = SQLITE_OPEN_READWRITE | SQLITE_OPEN_MAIN_JOURNAL; + Debug.Assert( !pPager.tempFile ); + rc = sqlite3OsOpen( pVfs, pPager.zJournal, pPager.jfd, f, ref fout ); + Debug.Assert( rc != SQLITE_OK || isOpen( pPager.jfd ) ); + if ( rc == SQLITE_OK && ( fout & SQLITE_OPEN_READONLY ) != 0 ) + { + rc = SQLITE_CANTOPEN_BKPT(); + sqlite3OsClose( pPager.jfd ); + } } + } - if (pagerUseWal(pPager)) { - Debug.Assert(rc == SQLITE_OK); - rc = pagerBeginReadTransaction(pPager); + /* Playback and delete the journal. Drop the database write + ** lock and reacquire the read lock. Purge the cache before + ** playing back the hot-journal so that we don't end up with + ** an inconsistent cache. Sync the hot journal before playing + ** it back since the process that crashed and left the hot journal + ** probably did not sync it and we are required to always sync + ** the journal before playing it back. + */ + if ( isOpen( pPager.jfd ) ) + { + Debug.Assert( rc == SQLITE_OK ); + rc = pagerSyncHotJournal( pPager ); + if ( rc == SQLITE_OK ) + { + rc = pager_playback( pPager, 1 ); + pPager.eState = PAGER_OPEN; } + } + else if ( !pPager.exclusiveMode ) + { + pagerUnlockDb( pPager, SHARED_LOCK ); + } + + if ( rc != SQLITE_OK ) + { + /* This branch is taken if an error occurs while trying to open + ** or roll back a hot-journal while holding an EXCLUSIVE lock. The + ** pager_unlock() routine will be called before returning to unlock + ** the file. If the unlock attempt fails, then Pager.eLock must be + ** set to UNKNOWN_LOCK (see the comment above the #define for + ** UNKNOWN_LOCK above for an explanation). + ** + ** In order to get pager_unlock() to do this, set Pager.eState to + ** PAGER_ERROR now. This is not actually counted as a transition + ** to ERROR state in the state diagram at the top of this file, + ** since we know that the same call to pager_unlock() will very + ** shortly transition the pager object to the OPEN state. Calling + ** assert_pager_state() would fail now, as it should not be possible + ** to be in ERROR state when there are zero outstanding page + ** references. + */ + pager_error( pPager, rc ); + goto failed; + } + + Debug.Assert( pPager.eState == PAGER_OPEN ); + Debug.Assert( ( pPager.eLock == SHARED_LOCK ) + || ( pPager.exclusiveMode && pPager.eLock > SHARED_LOCK ) + ); + } + + if ( !pPager.tempFile + && ( pPager.pBackup != null || sqlite3PcachePagecount( pPager.pPCache ) > 0 ) + ) + { + /* The shared-lock has just been acquired on the database file + ** and there are already pages in the cache (from a previous + ** read or write transaction). Check to see if the database + ** has been modified. If the database has changed, flush the + ** cache. + ** + ** Database changes is detected by looking at 15 bytes beginning + ** at offset 24 into the file. The first 4 of these 16 bytes are + ** a 32-bit counter that is incremented with each change. The + ** other bytes change randomly with each file change when + ** a codec is in use. + ** + ** There is a vanishingly small chance that a change will not be + ** detected. The chance of an undetected change is so small that + ** it can be neglected. + */ + Pgno nPage = 0; + byte[] dbFileVers = new byte[pPager.dbFileVers.Length]; + + rc = pagerPagecount( pPager, ref nPage ); + if ( rc != 0 ) + goto failed; - if (pPager.eState == PAGER_OPEN && rc == SQLITE_OK) { - rc = pagerPagecount(pPager, ref pPager.dbSize); + if ( nPage > 0 ) + { + IOTRACE( "CKVERS %p %d\n", pPager, dbFileVers.Length ); + rc = sqlite3OsRead( pPager.fd, dbFileVers, dbFileVers.Length, 24 ); + if ( rc != SQLITE_OK ) + { + goto failed; } + } + else + { + Array.Clear( dbFileVers, 0, dbFileVers.Length );// memset( dbFileVers, 0, sizeof( dbFileVers ) ); + } + + if ( memcmp( pPager.dbFileVers, dbFileVers, dbFileVers.Length ) != 0 ) + { + pager_reset( pPager ); + } + } + + /* If there is a WAL file in the file-system, open this database in WAL + ** mode. Otherwise, the following function call is a no-op. + */ + rc = pagerOpenWalIfPresent( pPager ); +#if !SQLITE_OMIT_WAL +Debug.Assert( pPager.pWal == null || rc == SQLITE_OK ); +#endif + } + + if ( pagerUseWal( pPager ) ) + { + Debug.Assert( rc == SQLITE_OK ); + rc = pagerBeginReadTransaction( pPager ); + } + + if ( pPager.eState == PAGER_OPEN && rc == SQLITE_OK ) + { + rc = pagerPagecount( pPager, ref pPager.dbSize ); + } + +failed: + if ( rc != SQLITE_OK ) + { + Debug.Assert( +#if SQLITE_OMIT_MEMORYDB +0==MEMDB +#else + 0 == pPager.memDb +#endif + ); + pager_unlock( pPager ); + Debug.Assert( pPager.eState == PAGER_OPEN ); + } + else + { + pPager.eState = PAGER_READER; + } + return rc; + } + + /* + ** If the reference count has reached zero, rollback any active + ** transaction and unlock the pager. + ** + ** Except, in locking_mode=EXCLUSIVE when there is nothing to in + ** the rollback journal, the unlock is not performed and there is + ** nothing to rollback, so this routine is a no-op. + */ + static void pagerUnlockIfUnused( Pager pPager ) + { + if ( sqlite3PcacheRefCount( pPager.pPCache ) == 0 ) + { + pagerUnlockAndRollback( pPager ); + } + } + + /* + ** Acquire a reference to page number pgno in pager pPager (a page + ** reference has type DbPage*). If the requested reference is + ** successfully obtained, it is copied to *ppPage and SQLITE_OK returned. + ** + ** If the requested page is already in the cache, it is returned. + ** Otherwise, a new page object is allocated and populated with data + ** read from the database file. In some cases, the pcache module may + ** choose not to allocate a new page object and may reuse an existing + ** object with no outstanding references. + ** + ** The extra data appended to a page is always initialized to zeros the + ** first time a page is loaded into memory. If the page requested is + ** already in the cache when this function is called, then the extra + ** data is left as it was when the page object was last used. + ** + ** If the database image is smaller than the requested page or if a + ** non-zero value is passed as the noContent parameter and the + ** requested page is not already stored in the cache, then no + ** actual disk read occurs. In this case the memory image of the + ** page is initialized to all zeros. + ** + ** If noContent is true, it means that we do not care about the contents + ** of the page. This occurs in two seperate scenarios: + ** + ** a) When reading a free-list leaf page from the database, and + ** + ** b) When a savepoint is being rolled back and we need to load + ** a new page into the cache to be filled with the data read + ** from the savepoint journal. + ** + ** If noContent is true, then the data returned is zeroed instead of + ** being read from the database. Additionally, the bits corresponding + ** to pgno in Pager.pInJournal (bitvec of pages already written to the + ** journal file) and the PagerSavepoint.pInSavepoint bitvecs of any open + ** savepoints are set. This means if the page is made writable at any + ** point in the future, using a call to sqlite3PagerWrite(), its contents + ** will not be journaled. This saves IO. + ** + ** The acquisition might fail for several reasons. In all cases, + ** an appropriate error code is returned and *ppPage is set to NULL. + ** + ** See also sqlite3PagerLookup(). Both this routine and Lookup() attempt + ** to find a page in the in-memory cache first. If the page is not already + ** in memory, this routine goes to disk to read it in whereas Lookup() + ** just returns 0. This routine acquires a read-lock the first time it + ** has to go to disk, and could also playback an old journal if necessary. + ** Since Lookup() never goes to disk, it never has to deal with locks + ** or journal files. + */ - failed: - if (rc != SQLITE_OK) { - Debug.Assert( -#if SQLITE_OMIT_MEMORYDB -0==MEMDB -#else - 0 == pPager.memDb -#endif - ); - pager_unlock(pPager); - Debug.Assert(pPager.eState == PAGER_OPEN); - } else { - pPager.eState = PAGER_READER; - } - return rc; - } + // Under C# from the header file + //#define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0) - /* - ** If the reference count has reached zero, rollback any active - ** transaction and unlock the pager. - ** - ** Except, in locking_mode=EXCLUSIVE when there is nothing to in - ** the rollback journal, the unlock is not performed and there is - ** nothing to rollback, so this routine is a no-op. - */ - static void pagerUnlockIfUnused(Pager pPager) { - if (sqlite3PcacheRefCount(pPager.pPCache) == 0) { - pagerUnlockAndRollback(pPager); - } - } + static int sqlite3PagerGet( + Pager pPager, /* The pager open on the database file */ + u32 pgno, /* Page number to fetch */ + ref DbPage ppPage /* Write a pointer to the page here */ + ) + { + return sqlite3PagerAcquire( pPager, pgno, ref ppPage, 0 ); + } - /* - ** Acquire a reference to page number pgno in pager pPager (a page - ** reference has type DbPage*). If the requested reference is - ** successfully obtained, it is copied to *ppPage and SQLITE_OK returned. - ** - ** If the requested page is already in the cache, it is returned. - ** Otherwise, a new page object is allocated and populated with data - ** read from the database file. In some cases, the pcache module may - ** choose not to allocate a new page object and may reuse an existing - ** object with no outstanding references. - ** - ** The extra data appended to a page is always initialized to zeros the - ** first time a page is loaded into memory. If the page requested is - ** already in the cache when this function is called, then the extra - ** data is left as it was when the page object was last used. - ** - ** If the database image is smaller than the requested page or if a - ** non-zero value is passed as the noContent parameter and the - ** requested page is not already stored in the cache, then no - ** actual disk read occurs. In this case the memory image of the - ** page is initialized to all zeros. - ** - ** If noContent is true, it means that we do not care about the contents - ** of the page. This occurs in two seperate scenarios: - ** - ** a) When reading a free-list leaf page from the database, and - ** - ** b) When a savepoint is being rolled back and we need to load - ** a new page into the cache to be filled with the data read - ** from the savepoint journal. - ** - ** If noContent is true, then the data returned is zeroed instead of - ** being read from the database. Additionally, the bits corresponding - ** to pgno in Pager.pInJournal (bitvec of pages already written to the - ** journal file) and the PagerSavepoint.pInSavepoint bitvecs of any open - ** savepoints are set. This means if the page is made writable at any - ** point in the future, using a call to sqlite3PagerWrite(), its contents - ** will not be journaled. This saves IO. - ** - ** The acquisition might fail for several reasons. In all cases, - ** an appropriate error code is returned and *ppPage is set to NULL. - ** - ** See also sqlite3PagerLookup(). Both this routine and Lookup() attempt - ** to find a page in the in-memory cache first. If the page is not already - ** in memory, this routine goes to disk to read it in whereas Lookup() - ** just returns 0. This routine acquires a read-lock the first time it - ** has to go to disk, and could also playback an old journal if necessary. - ** Since Lookup() never goes to disk, it never has to deal with locks - ** or journal files. - */ + static int sqlite3PagerAcquire( + Pager pPager, /* The pager open on the database file */ + u32 pgno, /* Page number to fetch */ + ref DbPage ppPage, /* Write a pointer to the page here */ + u8 noContent /* Do not bother reading content from disk if true */ + ) + { + int rc; + PgHdr pPg = null; - // Under C# from the header file - //#define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0) + Debug.Assert( pPager.eState >= PAGER_READER ); + Debug.Assert( assert_pager_state( pPager ) ); + if ( pgno == 0 ) + { + return SQLITE_CORRUPT_BKPT(); + } - static int sqlite3PagerGet( - Pager pPager, /* The pager open on the database file */ - u32 pgno, /* Page number to fetch */ - ref DbPage ppPage /* Write a pointer to the page here */ - ) { - return sqlite3PagerAcquire(pPager, pgno, ref ppPage, 0); - } + /* If the pager is in the error state, return an error immediately. + ** Otherwise, request the page from the PCache layer. */ + if ( pPager.errCode != SQLITE_OK ) + { + rc = pPager.errCode; + } + else + { + rc = sqlite3PcacheFetch( pPager.pPCache, pgno, 1, ref ppPage ); + } - static int sqlite3PagerAcquire( - Pager pPager, /* The pager open on the database file */ - u32 pgno, /* Page number to fetch */ - ref DbPage ppPage, /* Write a pointer to the page here */ - u8 noContent /* Do not bother reading content from disk if true */ - ) { - int rc; - PgHdr pPg = null; - - Debug.Assert(pPager.eState >= PAGER_READER); - Debug.Assert(assert_pager_state(pPager)); - if (pgno == 0) { - return SQLITE_CORRUPT_BKPT(); - } + if ( rc != SQLITE_OK ) + { + /* Either the call to sqlite3PcacheFetch() returned an error or the + ** pager was already in the error-state when this function was called. + ** Set pPg to 0 and jump to the exception handler. */ + pPg = null; + goto pager_acquire_err; + } + Debug.Assert( ( ppPage ).pgno == pgno ); + Debug.Assert( ( ppPage ).pPager == pPager || ( ppPage ).pPager == null ); - /* If the pager is in the error state, return an error immediately. - ** Otherwise, request the page from the PCache layer. */ - if (pPager.errCode != SQLITE_OK) { - rc = pPager.errCode; - } else { - rc = sqlite3PcacheFetch(pPager.pPCache, pgno, 1, ref ppPage); - } + if ( ( ppPage ).pPager != null && 0 == noContent ) + { + /* In this case the pcache already contains an initialized copy of + ** the page. Return without further ado. */ + Debug.Assert( pgno <= PAGER_MAX_PGNO && pgno != PAGER_MJ_PGNO( pPager ) ); + PAGER_INCR( ref pPager.nHit ); + return SQLITE_OK; - if (rc != SQLITE_OK) { - /* Either the call to sqlite3PcacheFetch() returned an error or the - ** pager was already in the error-state when this function was called. - ** Set pPg to 0 and jump to the exception handler. */ - pPg = null; - goto pager_acquire_err; - } - Debug.Assert((ppPage).pgno == pgno); - Debug.Assert((ppPage).pPager == pPager || (ppPage).pPager == null); - - if ((ppPage).pPager != null && 0 == noContent) { - /* In this case the pcache already contains an initialized copy of - ** the page. Return without further ado. */ - Debug.Assert(pgno <= PAGER_MAX_PGNO && pgno != PAGER_MJ_PGNO(pPager)); - PAGER_INCR(ref pPager.nHit); - return SQLITE_OK; - - } else { - /* The pager cache has created a new page. Its content needs to - ** be initialized. */ + } + else + { + /* The pager cache has created a new page. Its content needs to + ** be initialized. */ #if SQLITE_TEST PAGER_INCR( ref pPager.nMiss ); #endif - pPg = ppPage; - pPg.pPager = pPager; - pPg.pExtra = new MemPage();//memset(pPg.pExtra, 0, pPager.nExtra); - - /* The maximum page number is 2^31. Return SQLITE_CORRUPT if a page - ** number greater than this, or the unused locking-page, is requested. */ - if (pgno > PAGER_MAX_PGNO || pgno == PAGER_MJ_PGNO(pPager)) { - rc = SQLITE_CORRUPT_BKPT(); - goto pager_acquire_err; - } - if ( + pPg = ppPage; + pPg.pPager = pPager; + pPg.pExtra = new MemPage();//memset(pPg.pExtra, 0, pPager.nExtra); + + /* The maximum page number is 2^31. Return SQLITE_CORRUPT if a page + ** number greater than this, or the unused locking-page, is requested. */ + if ( pgno > PAGER_MAX_PGNO || pgno == PAGER_MJ_PGNO( pPager ) ) + { + rc = SQLITE_CORRUPT_BKPT(); + goto pager_acquire_err; + } + if ( #if SQLITE_OMIT_MEMORYDB 1==MEMDB #else - pPager.memDb != 0 + pPager.memDb != 0 #endif - || pPager.dbSize < pgno || noContent != 0 || !isOpen(pPager.fd)) { - if (pgno > pPager.mxPgno) { - rc = SQLITE_FULL; - goto pager_acquire_err; - } - if (noContent != 0) { - /* Failure to set the bits in the InJournal bit-vectors is benign. - ** It merely means that we might do some extra work to journal a - ** page that does not need to be journaled. Nevertheless, be sure - ** to test the case where a malloc error occurs while trying to set - ** a bit in a bit vector. - */ - sqlite3BeginBenignMalloc(); - if (pgno <= pPager.dbOrigSize) { + || pPager.dbSize < pgno || noContent != 0 || !isOpen( pPager.fd ) ) + { + if ( pgno > pPager.mxPgno ) + { + rc = SQLITE_FULL; + goto pager_acquire_err; + } + if ( noContent != 0 ) + { + /* Failure to set the bits in the InJournal bit-vectors is benign. + ** It merely means that we might do some extra work to journal a + ** page that does not need to be journaled. Nevertheless, be sure + ** to test the case where a malloc error occurs while trying to set + ** a bit in a bit vector. + */ + sqlite3BeginBenignMalloc(); + if ( pgno <= pPager.dbOrigSize ) + { #if !NDEBUG || SQLITE_COVERAGE_TEST - rc = sqlite3BitvecSet(pPager.pInJournal, pgno); //TESTONLY( rc = ) sqlite3BitvecSet(pPager.pInJournal, pgno); + rc = sqlite3BitvecSet( pPager.pInJournal, pgno ); //TESTONLY( rc = ) sqlite3BitvecSet(pPager.pInJournal, pgno); #else sqlite3BitvecSet(pPager.pInJournal, pgno); #endif - testcase(rc == SQLITE_NOMEM); - } + testcase( rc == SQLITE_NOMEM ); + } #if !NDEBUG || SQLITE_COVERAGE_TEST - rc = addToSavepointBitvecs(pPager, pgno); //TESTONLY( rc = ) addToSavepointBitvecs(pPager, pgno); + rc = addToSavepointBitvecs( pPager, pgno ); //TESTONLY( rc = ) addToSavepointBitvecs(pPager, pgno); #else addToSavepointBitvecs(pPager, pgno); #endif - testcase(rc == SQLITE_NOMEM); - sqlite3EndBenignMalloc(); - } - //memset(pPg.pData, 0, pPager.pageSize); - Array.Clear(pPg.pData, 0, pPager.pageSize); - IOTRACE("ZERO %p %d\n", pPager, pgno); - } else { - Debug.Assert(pPg.pPager == pPager); - rc = readDbPage(pPg); - if (rc != SQLITE_OK) { - goto pager_acquire_err; - } - } + testcase( rc == SQLITE_NOMEM ); + sqlite3EndBenignMalloc(); + } + //memset(pPg.pData, 0, pPager.pageSize); + Array.Clear( pPg.pData, 0, pPager.pageSize ); + IOTRACE( "ZERO %p %d\n", pPager, pgno ); + } + else + { + Debug.Assert( pPg.pPager == pPager ); + rc = readDbPage( pPg ); + if ( rc != SQLITE_OK ) + { + goto pager_acquire_err; + } + } - pager_set_pagehash(pPg); - } - return SQLITE_OK; + pager_set_pagehash( pPg ); + } + return SQLITE_OK; - pager_acquire_err: - Debug.Assert(rc != SQLITE_OK); - if (pPg != null) { - sqlite3PcacheDrop(pPg); - } - pagerUnlockIfUnused(pPager); +pager_acquire_err: + Debug.Assert( rc != SQLITE_OK ); + if ( pPg != null ) + { + sqlite3PcacheDrop( pPg ); + } + pagerUnlockIfUnused( pPager ); - ppPage = null; - return rc; - } + ppPage = null; + return rc; + } - /* - ** Acquire a page if it is already in the in-memory cache. Do - ** not read the page from disk. Return a pointer to the page, - ** or 0 if the page is not in cache. - ** - ** See also sqlite3PagerGet(). The difference between this routine - ** and sqlite3PagerGet() is that _get() will go to the disk and read - ** in the page if the page is not already in cache. This routine - ** returns NULL if the page is not in cache or if a disk I/O error - ** has ever happened. - */ - static DbPage sqlite3PagerLookup(Pager pPager, u32 pgno) { - PgHdr pPg = null; + /* + ** Acquire a page if it is already in the in-memory cache. Do + ** not read the page from disk. Return a pointer to the page, + ** or 0 if the page is not in cache. + ** + ** See also sqlite3PagerGet(). The difference between this routine + ** and sqlite3PagerGet() is that _get() will go to the disk and read + ** in the page if the page is not already in cache. This routine + ** returns NULL if the page is not in cache or if a disk I/O error + ** has ever happened. + */ + static DbPage sqlite3PagerLookup( Pager pPager, u32 pgno ) + { + PgHdr pPg = null; - Debug.Assert(pPager != null); - Debug.Assert(pgno != 0); - Debug.Assert(pPager.pPCache != null); - Debug.Assert(pPager.eState >= PAGER_READER && pPager.eState != PAGER_ERROR); - sqlite3PcacheFetch(pPager.pPCache, pgno, 0, ref pPg); + Debug.Assert( pPager != null ); + Debug.Assert( pgno != 0 ); + Debug.Assert( pPager.pPCache != null ); + Debug.Assert( pPager.eState >= PAGER_READER && pPager.eState != PAGER_ERROR ); + sqlite3PcacheFetch( pPager.pPCache, pgno, 0, ref pPg ); - return pPg; - } + return pPg; + } - /* - ** Release a page reference. - ** - ** If the number of references to the page drop to zero, then the - ** page is added to the LRU list. When all references to all pages - ** are released, a rollback occurs and the lock on the database is - ** removed. - */ - static void sqlite3PagerUnref(DbPage pPg) { - if (pPg != null) { - Pager pPager = pPg.pPager; - sqlite3PcacheRelease(pPg); - pagerUnlockIfUnused(pPager); - } - } + /* + ** Release a page reference. + ** + ** If the number of references to the page drop to zero, then the + ** page is added to the LRU list. When all references to all pages + ** are released, a rollback occurs and the lock on the database is + ** removed. + */ + static void sqlite3PagerUnref( DbPage pPg ) + { + if ( pPg != null ) + { + Pager pPager = pPg.pPager; + sqlite3PcacheRelease( pPg ); + pagerUnlockIfUnused( pPager ); + } + } - /* - ** This function is called at the start of every write transaction. - ** There must already be a RESERVED or EXCLUSIVE lock on the database - ** file when this routine is called. - ** - ** Open the journal file for pager pPager and write a journal header - ** to the start of it. If there are active savepoints, open the sub-journal - ** as well. This function is only used when the journal file is being - ** opened to write a rollback log for a transaction. It is not used - ** when opening a hot journal file to roll it back. - ** - ** If the journal file is already open (as it may be in exclusive mode), - ** then this function just writes a journal header to the start of the - ** already open file. - ** - ** Whether or not the journal file is opened by this function, the - ** Pager.pInJournal bitvec structure is allocated. - ** - ** Return SQLITE_OK if everything is successful. Otherwise, return - ** SQLITE_NOMEM if the attempt to allocate Pager.pInJournal fails, or - ** an IO error code if opening or writing the journal file fails. - */ - static int pager_open_journal(Pager pPager) { - int rc = SQLITE_OK; /* Return code */ - sqlite3_vfs pVfs = pPager.pVfs; /* Local cache of vfs pointer */ - - Debug.Assert(pPager.eState == PAGER_WRITER_LOCKED); - Debug.Assert(assert_pager_state(pPager)); - Debug.Assert(pPager.pInJournal == null); - - /* If already in the error state, this function is a no-op. But on - ** the other hand, this routine is never called if we are already in - ** an error state. */ - if (NEVER(pPager.errCode) != 0) - return pPager.errCode; - - if (!pagerUseWal(pPager) && pPager.journalMode != PAGER_JOURNALMODE_OFF) { - pPager.pInJournal = sqlite3BitvecCreate(pPager.dbSize); - //if (pPager.pInJournal == null) - //{ - // return SQLITE_NOMEM; - //} - - /* Open the journal file if it is not already open. */ - if (!isOpen(pPager.jfd)) { - if (pPager.journalMode == PAGER_JOURNALMODE_MEMORY) { - sqlite3MemJournalOpen(pPager.jfd); - } else { - int flags = /* VFS flags to open journal file */ - SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | - (pPager.tempFile ? - (SQLITE_OPEN_DELETEONCLOSE | SQLITE_OPEN_TEMP_JOURNAL) : - (SQLITE_OPEN_MAIN_JOURNAL) - ); + /* + ** This function is called at the start of every write transaction. + ** There must already be a RESERVED or EXCLUSIVE lock on the database + ** file when this routine is called. + ** + ** Open the journal file for pager pPager and write a journal header + ** to the start of it. If there are active savepoints, open the sub-journal + ** as well. This function is only used when the journal file is being + ** opened to write a rollback log for a transaction. It is not used + ** when opening a hot journal file to roll it back. + ** + ** If the journal file is already open (as it may be in exclusive mode), + ** then this function just writes a journal header to the start of the + ** already open file. + ** + ** Whether or not the journal file is opened by this function, the + ** Pager.pInJournal bitvec structure is allocated. + ** + ** Return SQLITE_OK if everything is successful. Otherwise, return + ** SQLITE_NOMEM if the attempt to allocate Pager.pInJournal fails, or + ** an IO error code if opening or writing the journal file fails. + */ + static int pager_open_journal( Pager pPager ) + { + int rc = SQLITE_OK; /* Return code */ + sqlite3_vfs pVfs = pPager.pVfs; /* Local cache of vfs pointer */ + + Debug.Assert( pPager.eState == PAGER_WRITER_LOCKED ); + Debug.Assert( assert_pager_state( pPager ) ); + Debug.Assert( pPager.pInJournal == null ); + + /* If already in the error state, this function is a no-op. But on + ** the other hand, this routine is never called if we are already in + ** an error state. */ + if ( NEVER( pPager.errCode ) != 0 ) + return pPager.errCode; + + if ( !pagerUseWal( pPager ) && pPager.journalMode != PAGER_JOURNALMODE_OFF ) + { + pPager.pInJournal = sqlite3BitvecCreate( pPager.dbSize ); + //if (pPager.pInJournal == null) + //{ + // return SQLITE_NOMEM; + //} + + /* Open the journal file if it is not already open. */ + if ( !isOpen( pPager.jfd ) ) + { + if ( pPager.journalMode == PAGER_JOURNALMODE_MEMORY ) + { + sqlite3MemJournalOpen( pPager.jfd ); + } + else + { + int flags = /* VFS flags to open journal file */ + SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | + ( pPager.tempFile ? + ( SQLITE_OPEN_DELETEONCLOSE | SQLITE_OPEN_TEMP_JOURNAL ) : + ( SQLITE_OPEN_MAIN_JOURNAL ) + ); #if SQLITE_ENABLE_ATOMIC_WRITE rc = sqlite3JournalOpen( pVfs, pPager.zJournal, pPager.jfd, flags, jrnlBufferSize(pPager) ); #else - int int0 = 0; - rc = sqlite3OsOpen(pVfs, pPager.zJournal, pPager.jfd, flags, ref int0); + int int0 = 0; + rc = sqlite3OsOpen( pVfs, pPager.zJournal, pPager.jfd, flags, ref int0 ); #endif - } - Debug.Assert(rc != SQLITE_OK || isOpen(pPager.jfd)); - } - - /* Write the first journal header to the journal file and open - ** the sub-journal if necessary. - */ - if (rc == SQLITE_OK) { - /* TODO: Check if all of these are really required. */ - pPager.nRec = 0; - pPager.journalOff = 0; - pPager.setMaster = 0; - pPager.journalHdr = 0; - rc = writeJournalHdr(pPager); - } - } - if (rc != SQLITE_OK) { - sqlite3BitvecDestroy(ref pPager.pInJournal); - pPager.pInJournal = null; - } else { - Debug.Assert(pPager.eState == PAGER_WRITER_LOCKED); - pPager.eState = PAGER_WRITER_CACHEMOD; - } - return rc; + } + Debug.Assert( rc != SQLITE_OK || isOpen( pPager.jfd ) ); } - /* - ** Begin a write-transaction on the specified pager object. If a - ** write-transaction has already been opened, this function is a no-op. - ** - ** If the exFlag argument is false, then acquire at least a RESERVED - ** lock on the database file. If exFlag is true, then acquire at least - ** an EXCLUSIVE lock. If such a lock is already held, no locking - ** functions need be called. - ** - ** If the subjInMemory argument is non-zero, then any sub-journal opened - ** within this transaction will be opened as an in-memory file. This - ** has no effect if the sub-journal is already opened (as it may be when - ** running in exclusive mode) or if the transaction does not require a - ** sub-journal. If the subjInMemory argument is zero, then any required - ** sub-journal is implemented in-memory if pPager is an in-memory database, - ** or using a temporary file otherwise. + /* Write the first journal header to the journal file and open + ** the sub-journal if necessary. */ - static int sqlite3PagerBegin(Pager pPager, bool exFlag, int subjInMemory) { - int rc = SQLITE_OK; - if (pPager.errCode != 0) - return pPager.errCode; - Debug.Assert(pPager.eState >= PAGER_READER && pPager.eState < PAGER_ERROR); - pPager.subjInMemory = (u8)subjInMemory; - if (ALWAYS(pPager.eState == PAGER_READER)) { - Debug.Assert(pPager.pInJournal == null); - if (pagerUseWal(pPager)) { - /* If the pager is configured to use locking_mode=exclusive, and an - ** exclusive lock on the database is not already held, obtain it now. - */ - if (pPager.exclusiveMode && sqlite3WalExclusiveMode(pPager.pWal, -1)) { - rc = pagerLockDb(pPager, EXCLUSIVE_LOCK); - if (rc != SQLITE_OK) { - return rc; - } - sqlite3WalExclusiveMode(pPager.pWal, 1); - } - - /* Grab the write lock on the log file. If successful, upgrade to - ** PAGER_RESERVED state. Otherwise, return an error code to the caller. - ** The busy-handler is not invoked if another connection already - ** holds the write-lock. If possible, the upper layer will call it. - */ - rc = sqlite3WalBeginWriteTransaction(pPager.pWal); - } else { - /* Obtain a RESERVED lock on the database file. If the exFlag parameter - ** is true, then immediately upgrade this to an EXCLUSIVE lock. The - ** busy-handler callback can be used when upgrading to the EXCLUSIVE - ** lock, but not when obtaining the RESERVED lock. - */ - rc = pagerLockDb(pPager, RESERVED_LOCK); - if (rc == SQLITE_OK && exFlag) { - rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK); - } - } - - if (rc == SQLITE_OK) { - /* Change to WRITER_LOCKED state. - ** - ** WAL mode sets Pager.eState to PAGER_WRITER_LOCKED or CACHEMOD - ** when it has an open transaction, but never to DBMOD or FINISHED. - ** This is because in those states the code to roll back savepoint - ** transactions may copy data from the sub-journal into the database - ** file as well as into the page cache. Which would be incorrect in - ** WAL mode. - */ - pPager.eState = PAGER_WRITER_LOCKED; - pPager.dbHintSize = pPager.dbSize; - pPager.dbFileSize = pPager.dbSize; - pPager.dbOrigSize = pPager.dbSize; - pPager.journalOff = 0; - } + if ( rc == SQLITE_OK ) + { + /* TODO: Check if all of these are really required. */ + pPager.nRec = 0; + pPager.journalOff = 0; + pPager.setMaster = 0; + pPager.journalHdr = 0; + rc = writeJournalHdr( pPager ); + } + } + if ( rc != SQLITE_OK ) + { + sqlite3BitvecDestroy( ref pPager.pInJournal ); + pPager.pInJournal = null; + } + else + { + Debug.Assert( pPager.eState == PAGER_WRITER_LOCKED ); + pPager.eState = PAGER_WRITER_CACHEMOD; + } + return rc; + } - Debug.Assert(rc == SQLITE_OK || pPager.eState == PAGER_READER); - Debug.Assert(rc != SQLITE_OK || pPager.eState == PAGER_WRITER_LOCKED); - Debug.Assert(assert_pager_state(pPager)); + /* + ** Begin a write-transaction on the specified pager object. If a + ** write-transaction has already been opened, this function is a no-op. + ** + ** If the exFlag argument is false, then acquire at least a RESERVED + ** lock on the database file. If exFlag is true, then acquire at least + ** an EXCLUSIVE lock. If such a lock is already held, no locking + ** functions need be called. + ** + ** If the subjInMemory argument is non-zero, then any sub-journal opened + ** within this transaction will be opened as an in-memory file. This + ** has no effect if the sub-journal is already opened (as it may be when + ** running in exclusive mode) or if the transaction does not require a + ** sub-journal. If the subjInMemory argument is zero, then any required + ** sub-journal is implemented in-memory if pPager is an in-memory database, + ** or using a temporary file otherwise. + */ + static int sqlite3PagerBegin( Pager pPager, bool exFlag, int subjInMemory ) + { + int rc = SQLITE_OK; + if ( pPager.errCode != 0 ) + return pPager.errCode; + Debug.Assert( pPager.eState >= PAGER_READER && pPager.eState < PAGER_ERROR ); + pPager.subjInMemory = (u8)subjInMemory; + if ( ALWAYS( pPager.eState == PAGER_READER ) ) + { + Debug.Assert( pPager.pInJournal == null ); + if ( pagerUseWal( pPager ) ) + { + /* If the pager is configured to use locking_mode=exclusive, and an + ** exclusive lock on the database is not already held, obtain it now. + */ + if ( pPager.exclusiveMode && sqlite3WalExclusiveMode( pPager.pWal, -1 ) ) + { + rc = pagerLockDb( pPager, EXCLUSIVE_LOCK ); + if ( rc != SQLITE_OK ) + { + return rc; } + sqlite3WalExclusiveMode( pPager.pWal, 1 ); + } - PAGERTRACE("TRANSACTION %d\n", PAGERID(pPager)); - return rc; + /* Grab the write lock on the log file. If successful, upgrade to + ** PAGER_RESERVED state. Otherwise, return an error code to the caller. + ** The busy-handler is not invoked if another connection already + ** holds the write-lock. If possible, the upper layer will call it. + */ + rc = sqlite3WalBeginWriteTransaction( pPager.pWal ); + } + else + { + /* Obtain a RESERVED lock on the database file. If the exFlag parameter + ** is true, then immediately upgrade this to an EXCLUSIVE lock. The + ** busy-handler callback can be used when upgrading to the EXCLUSIVE + ** lock, but not when obtaining the RESERVED lock. + */ + rc = pagerLockDb( pPager, RESERVED_LOCK ); + if ( rc == SQLITE_OK && exFlag ) + { + rc = pager_wait_on_lock( pPager, EXCLUSIVE_LOCK ); + } } + if ( rc == SQLITE_OK ) + { + /* Change to WRITER_LOCKED state. + ** + ** WAL mode sets Pager.eState to PAGER_WRITER_LOCKED or CACHEMOD + ** when it has an open transaction, but never to DBMOD or FINISHED. + ** This is because in those states the code to roll back savepoint + ** transactions may copy data from the sub-journal into the database + ** file as well as into the page cache. Which would be incorrect in + ** WAL mode. + */ + pPager.eState = PAGER_WRITER_LOCKED; + pPager.dbHintSize = pPager.dbSize; + pPager.dbFileSize = pPager.dbSize; + pPager.dbOrigSize = pPager.dbSize; + pPager.journalOff = 0; + } - /* - ** Mark a single data page as writeable. The page is written into the - ** main journal or sub-journal as required. If the page is written into - ** one of the journals, the corresponding bit is set in the - ** Pager.pInJournal bitvec and the PagerSavepoint.pInSavepoint bitvecs - ** of any open savepoints as appropriate. - */ - static int pager_write(PgHdr pPg) { - byte[] pData = pPg.pData; - Pager pPager = pPg.pPager; - int rc = SQLITE_OK; + Debug.Assert( rc == SQLITE_OK || pPager.eState == PAGER_READER ); + Debug.Assert( rc != SQLITE_OK || pPager.eState == PAGER_WRITER_LOCKED ); + Debug.Assert( assert_pager_state( pPager ) ); + } - /* This routine is not called unless a write-transaction has already - ** been started. The journal file may or may not be open at this point. - ** It is never called in the ERROR state. - */ - Debug.Assert(pPager.eState == PAGER_WRITER_LOCKED - || pPager.eState == PAGER_WRITER_CACHEMOD - || pPager.eState == PAGER_WRITER_DBMOD - ); - Debug.Assert(assert_pager_state(pPager)); + PAGERTRACE( "TRANSACTION %d\n", PAGERID( pPager ) ); + return rc; + } + + + /* + ** Mark a single data page as writeable. The page is written into the + ** main journal or sub-journal as required. If the page is written into + ** one of the journals, the corresponding bit is set in the + ** Pager.pInJournal bitvec and the PagerSavepoint.pInSavepoint bitvecs + ** of any open savepoints as appropriate. + */ + static int pager_write( PgHdr pPg ) + { + byte[] pData = pPg.pData; + Pager pPager = pPg.pPager; + int rc = SQLITE_OK; + + /* This routine is not called unless a write-transaction has already + ** been started. The journal file may or may not be open at this point. + ** It is never called in the ERROR state. + */ + Debug.Assert( pPager.eState == PAGER_WRITER_LOCKED + || pPager.eState == PAGER_WRITER_CACHEMOD + || pPager.eState == PAGER_WRITER_DBMOD + ); + Debug.Assert( assert_pager_state( pPager ) ); - /* If an error has been previously detected, report the same error - ** again. This should not happen, but the check provides robustness. */ - if (NEVER(pPager.errCode) != 0) - return pPager.errCode; + /* If an error has been previously detected, report the same error + ** again. This should not happen, but the check provides robustness. */ + if ( NEVER( pPager.errCode ) != 0 ) + return pPager.errCode; - /* Higher-level routines never call this function if database is not - ** writable. But check anyway, just for robustness. */ - if (NEVER(pPager.readOnly)) - return SQLITE_PERM; + /* Higher-level routines never call this function if database is not + ** writable. But check anyway, just for robustness. */ + if ( NEVER( pPager.readOnly ) ) + return SQLITE_PERM; #if SQLITE_CHECK_PAGES CHECK_PAGE(pPg); #endif - /* The journal file needs to be opened. Higher level routines have already - ** obtained the necessary locks to begin the write-transaction, but the - ** rollback journal might not yet be open. Open it now if this is the case. - ** - ** This is done before calling sqlite3PcacheMakeDirty() on the page. - ** Otherwise, if it were done after calling sqlite3PcacheMakeDirty(), then - ** an error might occur and the pager would end up in WRITER_LOCKED state - ** with pages marked as dirty in the cache. - */ - if (pPager.eState == PAGER_WRITER_LOCKED) { - rc = pager_open_journal(pPager); - if (rc != SQLITE_OK) - return rc; - } - Debug.Assert(pPager.eState >= PAGER_WRITER_CACHEMOD); - Debug.Assert(assert_pager_state(pPager)); + /* The journal file needs to be opened. Higher level routines have already +** obtained the necessary locks to begin the write-transaction, but the +** rollback journal might not yet be open. Open it now if this is the case. +** +** This is done before calling sqlite3PcacheMakeDirty() on the page. +** Otherwise, if it were done after calling sqlite3PcacheMakeDirty(), then +** an error might occur and the pager would end up in WRITER_LOCKED state +** with pages marked as dirty in the cache. +*/ + if ( pPager.eState == PAGER_WRITER_LOCKED ) + { + rc = pager_open_journal( pPager ); + if ( rc != SQLITE_OK ) + return rc; + } + Debug.Assert( pPager.eState >= PAGER_WRITER_CACHEMOD ); + Debug.Assert( assert_pager_state( pPager ) ); - /* Mark the page as dirty. If the page has already been written - ** to the journal then we can return right away. + /* Mark the page as dirty. If the page has already been written + ** to the journal then we can return right away. + */ + sqlite3PcacheMakeDirty( pPg ); + if ( pageInJournal( pPg ) && !subjRequiresPage( pPg ) ) + { + Debug.Assert( !pagerUseWal( pPager ) ); + } + else + { + /* The transaction journal now exists and we have a RESERVED or an + ** EXCLUSIVE lock on the main database file. Write the current page to + ** the transaction journal if it is not there already. + */ + if ( !pageInJournal( pPg ) && !pagerUseWal( pPager ) ) + { + Debug.Assert( pagerUseWal( pPager ) == false ); + if ( pPg.pgno <= pPager.dbOrigSize && isOpen( pPager.jfd ) ) + { + u32 cksum; + byte[] pData2 = null; + i64 iOff = pPager.journalOff; + + /* We should never write to the journal file the page that + ** contains the database locks. The following Debug.Assert verifies + ** that we do not. */ + Debug.Assert( pPg.pgno != ( ( PENDING_BYTE / ( pPager.pageSize ) ) + 1 ) );//PAGER_MJ_PGNO(pPager) ); + + Debug.Assert( pPager.journalHdr <= pPager.journalOff ); + if ( CODEC2( pPager, pData, pPg.pgno, SQLITE_ENCRYPT_READ_CTX, ref pData2 ) ) + return SQLITE_NOMEM; // CODEC2(pPager, pData, pPg.pgno, 7, return SQLITE_NOMEM, pData2); + cksum = pager_cksum( pPager, pData2 ); + + /* Even if an IO or diskfull error occurred while journalling the + ** page in the block above, set the need-sync flag for the page. + ** Otherwise, when the transaction is rolled back, the logic in + ** playback_one_page() will think that the page needs to be restored + ** in the database file. And if an IO error occurs while doing so, + ** then corruption may follow. */ - sqlite3PcacheMakeDirty(pPg); - if (pageInJournal(pPg) && !subjRequiresPage(pPg)) { - Debug.Assert(!pagerUseWal(pPager)); - } else { - /* The transaction journal now exists and we have a RESERVED or an - ** EXCLUSIVE lock on the main database file. Write the current page to - ** the transaction journal if it is not there already. - */ - if (!pageInJournal(pPg) && !pagerUseWal(pPager)) { - Debug.Assert(pagerUseWal(pPager) == false); - if (pPg.pgno <= pPager.dbOrigSize && isOpen(pPager.jfd)) { - u32 cksum; - byte[] pData2 = null; - i64 iOff = pPager.journalOff; - - /* We should never write to the journal file the page that - ** contains the database locks. The following Debug.Assert verifies - ** that we do not. */ - Debug.Assert(pPg.pgno != ((PENDING_BYTE / (pPager.pageSize)) + 1));//PAGER_MJ_PGNO(pPager) ); - - Debug.Assert(pPager.journalHdr <= pPager.journalOff); - if (CODEC2(pPager, pData, pPg.pgno, SQLITE_ENCRYPT_READ_CTX, ref pData2)) - return SQLITE_NOMEM; // CODEC2(pPager, pData, pPg.pgno, 7, return SQLITE_NOMEM, pData2); - cksum = pager_cksum(pPager, pData2); - - /* Even if an IO or diskfull error occurred while journalling the - ** page in the block above, set the need-sync flag for the page. - ** Otherwise, when the transaction is rolled back, the logic in - ** playback_one_page() will think that the page needs to be restored - ** in the database file. And if an IO error occurs while doing so, - ** then corruption may follow. - */ - - pPg.flags |= PGHDR_NEED_SYNC; - - rc = write32bits(pPager.jfd, iOff, pPg.pgno); - if (rc != SQLITE_OK) - return rc; - rc = sqlite3OsWrite(pPager.jfd, pData2, pPager.pageSize, iOff + 4); - if (rc != SQLITE_OK) - return rc; - rc = write32bits(pPager.jfd, iOff + pPager.pageSize + 4, cksum); - if (rc != SQLITE_OK) - return rc; - - IOTRACE("JOUT %p %d %lld %d\n", pPager, pPg.pgno, - pPager.journalOff, pPager.pageSize); + + pPg.flags |= PGHDR_NEED_SYNC; + + rc = write32bits( pPager.jfd, iOff, pPg.pgno ); + if ( rc != SQLITE_OK ) + return rc; + rc = sqlite3OsWrite( pPager.jfd, pData2, pPager.pageSize, iOff + 4 ); + if ( rc != SQLITE_OK ) + return rc; + rc = write32bits( pPager.jfd, iOff + pPager.pageSize + 4, cksum ); + if ( rc != SQLITE_OK ) + return rc; + + IOTRACE( "JOUT %p %d %lld %d\n", pPager, pPg.pgno, + pPager.journalOff, pPager.pageSize ); #if SQLITE_TEST #if !TCLSH PAGER_INCR( ref sqlite3_pager_writej_count ); @@ -5745,466 +6148,519 @@ static int pager_write(PgHdr pPg) { sqlite3_pager_writej_count.iValue = iValue; #endif #endif - PAGERTRACE("JOURNAL %d page %d needSync=%d hash(%08x)\n", - PAGERID(pPager), pPg.pgno, - ((pPg.flags & PGHDR_NEED_SYNC) != 0 ? 1 : 0), pager_pagehash(pPg)); - - pPager.journalOff += 8 + pPager.pageSize; - pPager.nRec++; - Debug.Assert(pPager.pInJournal != null); - rc = sqlite3BitvecSet(pPager.pInJournal, pPg.pgno); - testcase(rc == SQLITE_NOMEM); - Debug.Assert(rc == SQLITE_OK || rc == SQLITE_NOMEM); - rc |= addToSavepointBitvecs(pPager, pPg.pgno); - if (rc != SQLITE_OK) { - Debug.Assert(rc == SQLITE_NOMEM); - return rc; - } - } else { - if (pPager.eState != PAGER_WRITER_DBMOD) { - pPg.flags |= PGHDR_NEED_SYNC; - } - PAGERTRACE("APPEND %d page %d needSync=%d\n", - PAGERID(pPager), pPg.pgno, - ((pPg.flags & PGHDR_NEED_SYNC) != 0 ? 1 : 0)); - } - } - - /* If the statement journal is open and the page is not in it, - ** then write the current page to the statement journal. Note that - ** the statement journal format differs from the standard journal format - ** in that it omits the checksums and the header. - */ - if (subjRequiresPage(pPg)) { - rc = subjournalPage(pPg); - } + PAGERTRACE( "JOURNAL %d page %d needSync=%d hash(%08x)\n", + PAGERID( pPager ), pPg.pgno, + ( ( pPg.flags & PGHDR_NEED_SYNC ) != 0 ? 1 : 0 ), pager_pagehash( pPg ) ); + + pPager.journalOff += 8 + pPager.pageSize; + pPager.nRec++; + Debug.Assert( pPager.pInJournal != null ); + rc = sqlite3BitvecSet( pPager.pInJournal, pPg.pgno ); + testcase( rc == SQLITE_NOMEM ); + Debug.Assert( rc == SQLITE_OK || rc == SQLITE_NOMEM ); + rc |= addToSavepointBitvecs( pPager, pPg.pgno ); + if ( rc != SQLITE_OK ) + { + Debug.Assert( rc == SQLITE_NOMEM ); + return rc; } - - /* Update the database size and return. - */ - if (pPager.dbSize < pPg.pgno) { - pPager.dbSize = pPg.pgno; + } + else + { + if ( pPager.eState != PAGER_WRITER_DBMOD ) + { + pPg.flags |= PGHDR_NEED_SYNC; } - return rc; + PAGERTRACE( "APPEND %d page %d needSync=%d\n", + PAGERID( pPager ), pPg.pgno, + ( ( pPg.flags & PGHDR_NEED_SYNC ) != 0 ? 1 : 0 ) ); + } } - /* - ** Mark a data page as writeable. This routine must be called before - ** making changes to a page. The caller must check the return value - ** of this function and be careful not to change any page data unless - ** this routine returns SQLITE_OK. - ** - ** The difference between this function and pager_write() is that this - ** function also deals with the special case where 2 or more pages - ** fit on a single disk sector. In this case all co-resident pages - ** must have been written to the journal file before returning. - ** - ** If an error occurs, SQLITE_NOMEM or an IO error code is returned - ** as appropriate. Otherwise, SQLITE_OK. + /* If the statement journal is open and the page is not in it, + ** then write the current page to the statement journal. Note that + ** the statement journal format differs from the standard journal format + ** in that it omits the checksums and the header. */ - static int sqlite3PagerWrite(DbPage pDbPage) { - int rc = SQLITE_OK; + if ( subjRequiresPage( pPg ) ) + { + rc = subjournalPage( pPg ); + } + } + + /* Update the database size and return. + */ + if ( pPager.dbSize < pPg.pgno ) + { + pPager.dbSize = pPg.pgno; + } + return rc; + } - PgHdr pPg = pDbPage; - Pager pPager = pPg.pPager; - u32 nPagePerSector = (u32)(pPager.sectorSize / pPager.pageSize); + /* + ** Mark a data page as writeable. This routine must be called before + ** making changes to a page. The caller must check the return value + ** of this function and be careful not to change any page data unless + ** this routine returns SQLITE_OK. + ** + ** The difference between this function and pager_write() is that this + ** function also deals with the special case where 2 or more pages + ** fit on a single disk sector. In this case all co-resident pages + ** must have been written to the journal file before returning. + ** + ** If an error occurs, SQLITE_NOMEM or an IO error code is returned + ** as appropriate. Otherwise, SQLITE_OK. + */ + static int sqlite3PagerWrite( DbPage pDbPage ) + { + int rc = SQLITE_OK; - Debug.Assert(pPager.eState >= PAGER_WRITER_LOCKED); - Debug.Assert(pPager.eState != PAGER_ERROR); - Debug.Assert(assert_pager_state(pPager)); + PgHdr pPg = pDbPage; + Pager pPager = pPg.pPager; + u32 nPagePerSector = (u32)( pPager.sectorSize / pPager.pageSize ); - if (nPagePerSector > 1) { - Pgno nPageCount = 0; /* Total number of pages in database file */ - Pgno pg1; /* First page of the sector pPg is located on. */ - Pgno nPage = 0; /* Number of pages starting at pg1 to journal */ - int ii; /* Loop counter */ - bool needSync = false; /* True if any page has PGHDR_NEED_SYNC */ + Debug.Assert( pPager.eState >= PAGER_WRITER_LOCKED ); + Debug.Assert( pPager.eState != PAGER_ERROR ); + Debug.Assert( assert_pager_state( pPager ) ); - /* Set the doNotSyncSpill flag to 1. This is because we cannot allow - ** a journal header to be written between the pages journaled by - ** this function. - */ - Debug.Assert( + if ( nPagePerSector > 1 ) + { + Pgno nPageCount = 0; /* Total number of pages in database file */ + Pgno pg1; /* First page of the sector pPg is located on. */ + Pgno nPage = 0; /* Number of pages starting at pg1 to journal */ + int ii; /* Loop counter */ + bool needSync = false; /* True if any page has PGHDR_NEED_SYNC */ + + /* Set the doNotSyncSpill flag to 1. This is because we cannot allow + ** a journal header to be written between the pages journaled by + ** this function. + */ + Debug.Assert( #if SQLITE_OMIT_MEMORYDB 0==MEMDB #else - 0 == pPager.memDb + 0 == pPager.memDb #endif - ); - Debug.Assert(pPager.doNotSyncSpill == 0); - pPager.doNotSyncSpill++; + ); + Debug.Assert( pPager.doNotSyncSpill == 0 ); + pPager.doNotSyncSpill++; - /* This trick assumes that both the page-size and sector-size are - ** an integer power of 2. It sets variable pg1 to the identifier - ** of the first page of the sector pPg is located on. - */ - pg1 = (u32)((pPg.pgno - 1) & ~(nPagePerSector - 1)) + 1; - - nPageCount = pPager.dbSize; - if (pPg.pgno > nPageCount) { - nPage = (pPg.pgno - pg1) + 1; - } else if ((pg1 + nPagePerSector - 1) > nPageCount) { - nPage = nPageCount + 1 - pg1; - } else { - nPage = nPagePerSector; - } - Debug.Assert(nPage > 0); - Debug.Assert(pg1 <= pPg.pgno); - Debug.Assert((pg1 + nPage) > pPg.pgno); - - for (ii = 0; ii < nPage && rc == SQLITE_OK; ii++) { - u32 pg = (u32)(pg1 + ii); - PgHdr pPage = new PgHdr(); - if (pg == pPg.pgno || sqlite3BitvecTest(pPager.pInJournal, pg) == 0) { - if (pg != ((PENDING_BYTE / (pPager.pageSize)) + 1)) //PAGER_MJ_PGNO(pPager)) - { - rc = sqlite3PagerGet(pPager, pg, ref pPage); - if (rc == SQLITE_OK) { - rc = pager_write(pPage); - if ((pPage.flags & PGHDR_NEED_SYNC) != 0) { - needSync = true; - } - sqlite3PagerUnref(pPage); - } - } - } else if ((pPage = pager_lookup(pPager, pg)) != null) { - if ((pPage.flags & PGHDR_NEED_SYNC) != 0) { - needSync = true; - } - sqlite3PagerUnref(pPage); - } + /* This trick assumes that both the page-size and sector-size are + ** an integer power of 2. It sets variable pg1 to the identifier + ** of the first page of the sector pPg is located on. + */ + pg1 = (u32)( ( pPg.pgno - 1 ) & ~( nPagePerSector - 1 ) ) + 1; + + nPageCount = pPager.dbSize; + if ( pPg.pgno > nPageCount ) + { + nPage = ( pPg.pgno - pg1 ) + 1; + } + else if ( ( pg1 + nPagePerSector - 1 ) > nPageCount ) + { + nPage = nPageCount + 1 - pg1; + } + else + { + nPage = nPagePerSector; + } + Debug.Assert( nPage > 0 ); + Debug.Assert( pg1 <= pPg.pgno ); + Debug.Assert( ( pg1 + nPage ) > pPg.pgno ); + + for ( ii = 0; ii < nPage && rc == SQLITE_OK; ii++ ) + { + u32 pg = (u32)( pg1 + ii ); + PgHdr pPage = new PgHdr(); + if ( pg == pPg.pgno || sqlite3BitvecTest( pPager.pInJournal, pg ) == 0 ) + { + if ( pg != ( ( PENDING_BYTE / ( pPager.pageSize ) ) + 1 ) ) //PAGER_MJ_PGNO(pPager)) + { + rc = sqlite3PagerGet( pPager, pg, ref pPage ); + if ( rc == SQLITE_OK ) + { + rc = pager_write( pPage ); + if ( ( pPage.flags & PGHDR_NEED_SYNC ) != 0 ) + { + needSync = true; } + sqlite3PagerUnref( pPage ); + } + } + } + else if ( ( pPage = pager_lookup( pPager, pg ) ) != null ) + { + if ( ( pPage.flags & PGHDR_NEED_SYNC ) != 0 ) + { + needSync = true; + } + sqlite3PagerUnref( pPage ); + } + } - /* If the PGHDR_NEED_SYNC flag is set for any of the nPage pages - ** starting at pg1, then it needs to be set for all of them. Because - ** writing to any of these nPage pages may damage the others, the - ** journal file must contain sync()ed copies of all of them - ** before any of them can be written out to the database file. - */ - if (rc == SQLITE_OK && needSync) { - Debug.Assert( + /* If the PGHDR_NEED_SYNC flag is set for any of the nPage pages + ** starting at pg1, then it needs to be set for all of them. Because + ** writing to any of these nPage pages may damage the others, the + ** journal file must contain sync()ed copies of all of them + ** before any of them can be written out to the database file. + */ + if ( rc == SQLITE_OK && needSync ) + { + Debug.Assert( #if SQLITE_OMIT_MEMORYDB 0==MEMDB #else - 0 == pPager.memDb + 0 == pPager.memDb #endif - ); - for (ii = 0; ii < nPage; ii++) { - PgHdr pPage = pager_lookup(pPager, (u32)(pg1 + ii)); - if (pPage != null) { - pPage.flags |= PGHDR_NEED_SYNC; - sqlite3PagerUnref(pPage); - } - } - } - - Debug.Assert(pPager.doNotSyncSpill == 1); - pPager.doNotSyncSpill--; - } else { - rc = pager_write(pDbPage); + ); + for ( ii = 0; ii < nPage; ii++ ) + { + PgHdr pPage = pager_lookup( pPager, (u32)( pg1 + ii ) ); + if ( pPage != null ) + { + pPage.flags |= PGHDR_NEED_SYNC; + sqlite3PagerUnref( pPage ); } - return rc; + } } - /* - ** Return TRUE if the page given in the argument was previously passed - ** to sqlite3PagerWrite(). In other words, return TRUE if it is ok - ** to change the content of the page. - */ + Debug.Assert( pPager.doNotSyncSpill == 1 ); + pPager.doNotSyncSpill--; + } + else + { + rc = pager_write( pDbPage ); + } + return rc; + } + + /* + ** Return TRUE if the page given in the argument was previously passed + ** to sqlite3PagerWrite(). In other words, return TRUE if it is ok + ** to change the content of the page. + */ #if !NDEBUG - static bool sqlite3PagerIswriteable(DbPage pPg) { - return (pPg.flags & PGHDR_DIRTY) != 0; - } + static bool sqlite3PagerIswriteable( DbPage pPg ) + { + return ( pPg.flags & PGHDR_DIRTY ) != 0; + } #else static bool sqlite3PagerIswriteable( DbPage pPg ) { return true; } #endif - /* - ** A call to this routine tells the pager that it is not necessary to - ** write the information on page pPg back to the disk, even though - ** that page might be marked as dirty. This happens, for example, when - ** the page has been added as a leaf of the freelist and so its - ** content no longer matters. - ** - ** The overlying software layer calls this routine when all of the data - ** on the given page is unused. The pager marks the page as clean so - ** that it does not get written to disk. - ** - ** Tests show that this optimization can quadruple the speed of large - ** DELETE operations. - */ - static void sqlite3PagerDontWrite(PgHdr pPg) { - Pager pPager = pPg.pPager; - - if ((pPg.flags & PGHDR_DIRTY) != 0 && pPager.nSavepoint == 0) { - PAGERTRACE("DONT_WRITE page %d of %d\n", pPg.pgno, PAGERID(pPager)); - IOTRACE("CLEAN %p %d\n", pPager, pPg.pgno); - pPg.flags |= PGHDR_DONT_WRITE; - pager_set_pagehash(pPg); - } - } + /* +** A call to this routine tells the pager that it is not necessary to +** write the information on page pPg back to the disk, even though +** that page might be marked as dirty. This happens, for example, when +** the page has been added as a leaf of the freelist and so its +** content no longer matters. +** +** The overlying software layer calls this routine when all of the data +** on the given page is unused. The pager marks the page as clean so +** that it does not get written to disk. +** +** Tests show that this optimization can quadruple the speed of large +** DELETE operations. +*/ + static void sqlite3PagerDontWrite( PgHdr pPg ) + { + Pager pPager = pPg.pPager; - /* - ** This routine is called to increment the value of the database file - ** change-counter, stored as a 4-byte big-endian integer starting at - ** byte offset 24 of the pager file. The secondary change counter at - ** 92 is also updated, as is the SQLite version number at offset 96. - ** - ** But this only happens if the pPager.changeCountDone flag is false. - ** To avoid excess churning of page 1, the update only happens once. - ** See also the pager_write_changecounter() routine that does an - ** unconditional update of the change counters. - ** - ** If the isDirectMode flag is zero, then this is done by calling - ** sqlite3PagerWrite() on page 1, then modifying the contents of the - ** page data. In this case the file will be updated when the current - ** transaction is committed. - ** - ** The isDirectMode flag may only be non-zero if the library was compiled - ** with the SQLITE_ENABLE_ATOMIC_WRITE macro defined. In this case, - ** if isDirect is non-zero, then the database file is updated directly - ** by writing an updated version of page 1 using a call to the - ** sqlite3OsWrite() function. - */ - static int pager_incr_changecounter(Pager pPager, bool isDirectMode) { - int rc = SQLITE_OK; + if ( ( pPg.flags & PGHDR_DIRTY ) != 0 && pPager.nSavepoint == 0 ) + { + PAGERTRACE( "DONT_WRITE page %d of %d\n", pPg.pgno, PAGERID( pPager ) ); + IOTRACE( "CLEAN %p %d\n", pPager, pPg.pgno ); + pPg.flags |= PGHDR_DONT_WRITE; + pager_set_pagehash( pPg ); + } + } - Debug.Assert(pPager.eState == PAGER_WRITER_CACHEMOD - || pPager.eState == PAGER_WRITER_DBMOD - ); - Debug.Assert(assert_pager_state(pPager)); + /* + ** This routine is called to increment the value of the database file + ** change-counter, stored as a 4-byte big-endian integer starting at + ** byte offset 24 of the pager file. The secondary change counter at + ** 92 is also updated, as is the SQLite version number at offset 96. + ** + ** But this only happens if the pPager.changeCountDone flag is false. + ** To avoid excess churning of page 1, the update only happens once. + ** See also the pager_write_changecounter() routine that does an + ** unconditional update of the change counters. + ** + ** If the isDirectMode flag is zero, then this is done by calling + ** sqlite3PagerWrite() on page 1, then modifying the contents of the + ** page data. In this case the file will be updated when the current + ** transaction is committed. + ** + ** The isDirectMode flag may only be non-zero if the library was compiled + ** with the SQLITE_ENABLE_ATOMIC_WRITE macro defined. In this case, + ** if isDirect is non-zero, then the database file is updated directly + ** by writing an updated version of page 1 using a call to the + ** sqlite3OsWrite() function. + */ + static int pager_incr_changecounter( Pager pPager, bool isDirectMode ) + { + int rc = SQLITE_OK; - /* Declare and initialize constant integer 'isDirect'. If the - ** atomic-write optimization is enabled in this build, then isDirect - ** is initialized to the value passed as the isDirectMode parameter - ** to this function. Otherwise, it is always set to zero. - ** - ** The idea is that if the atomic-write optimization is not - ** enabled at compile time, the compiler can omit the tests of - ** 'isDirect' below, as well as the block enclosed in the - ** "if( isDirect )" condition. - */ + Debug.Assert( pPager.eState == PAGER_WRITER_CACHEMOD + || pPager.eState == PAGER_WRITER_DBMOD + ); + Debug.Assert( assert_pager_state( pPager ) ); + + /* Declare and initialize constant integer 'isDirect'. If the + ** atomic-write optimization is enabled in this build, then isDirect + ** is initialized to the value passed as the isDirectMode parameter + ** to this function. Otherwise, it is always set to zero. + ** + ** The idea is that if the atomic-write optimization is not + ** enabled at compile time, the compiler can omit the tests of + ** 'isDirect' below, as well as the block enclosed in the + ** "if( isDirect )" condition. + */ #if !SQLITE_ENABLE_ATOMIC_WRITE - //# define DIRECT_MODE 0 - bool DIRECT_MODE = false; - Debug.Assert(isDirectMode == false); - UNUSED_PARAMETER(isDirectMode); + //# define DIRECT_MODE 0 + bool DIRECT_MODE = false; + Debug.Assert( isDirectMode == false ); + UNUSED_PARAMETER( isDirectMode ); #else //# define DIRECT_MODE isDirectMode int DIRECT_MODE = isDirectMode; #endif - if (!pPager.changeCountDone && pPager.dbSize > 0) { - PgHdr pPgHdr = null; /* Reference to page 1 */ + if ( !pPager.changeCountDone && pPager.dbSize > 0 ) + { + PgHdr pPgHdr = null; /* Reference to page 1 */ - Debug.Assert(!pPager.tempFile && isOpen(pPager.fd)); + Debug.Assert( !pPager.tempFile && isOpen( pPager.fd ) ); - /* Open page 1 of the file for writing. */ - rc = sqlite3PagerGet(pPager, 1, ref pPgHdr); - Debug.Assert(pPgHdr == null || rc == SQLITE_OK); + /* Open page 1 of the file for writing. */ + rc = sqlite3PagerGet( pPager, 1, ref pPgHdr ); + Debug.Assert( pPgHdr == null || rc == SQLITE_OK ); - /* If page one was fetched successfully, and this function is not - ** operating in direct-mode, make page 1 writable. When not in - ** direct mode, page 1 is always held in cache and hence the PagerGet() - ** above is always successful - hence the ALWAYS on rc==SQLITE_OK. - */ - if (!DIRECT_MODE && ALWAYS(rc == SQLITE_OK)) { - rc = sqlite3PagerWrite(pPgHdr); - } + /* If page one was fetched successfully, and this function is not + ** operating in direct-mode, make page 1 writable. When not in + ** direct mode, page 1 is always held in cache and hence the PagerGet() + ** above is always successful - hence the ALWAYS on rc==SQLITE_OK. + */ + if ( !DIRECT_MODE && ALWAYS( rc == SQLITE_OK ) ) + { + rc = sqlite3PagerWrite( pPgHdr ); + } - if (rc == SQLITE_OK) { - /* Actually do the update of the change counter */ - pager_write_changecounter(pPgHdr); - - /* If running in direct mode, write the contents of page 1 to the file. */ - if (DIRECT_MODE) { - u8[] zBuf = null; - Debug.Assert(pPager.dbFileSize > 0); - if (CODEC2(pPager, pPgHdr.pData, 1, SQLITE_ENCRYPT_WRITE_CTX, ref zBuf)) - return rc = SQLITE_NOMEM;//CODEC2(pPager, pPgHdr.pData, 1, 6, rc=SQLITE_NOMEM, zBuf); - if (rc == SQLITE_OK) { - rc = sqlite3OsWrite(pPager.fd, zBuf, pPager.pageSize, 0); - } - - if (rc == SQLITE_OK) { - pPager.changeCountDone = true; - } - } else { - pPager.changeCountDone = true; - } - } + if ( rc == SQLITE_OK ) + { + /* Actually do the update of the change counter */ + pager_write_changecounter( pPgHdr ); - /* Release the page reference. */ - sqlite3PagerUnref(pPgHdr); + /* If running in direct mode, write the contents of page 1 to the file. */ + if ( DIRECT_MODE ) + { + u8[] zBuf = null; + Debug.Assert( pPager.dbFileSize > 0 ); + if ( CODEC2( pPager, pPgHdr.pData, 1, SQLITE_ENCRYPT_WRITE_CTX, ref zBuf ) ) + return rc = SQLITE_NOMEM;//CODEC2(pPager, pPgHdr.pData, 1, 6, rc=SQLITE_NOMEM, zBuf); + if ( rc == SQLITE_OK ) + { + rc = sqlite3OsWrite( pPager.fd, zBuf, pPager.pageSize, 0 ); } - return rc; + + if ( rc == SQLITE_OK ) + { + pPager.changeCountDone = true; + } + } + else + { + pPager.changeCountDone = true; + } } - /* - ** Sync the database file to disk. This is a no-op for in-memory databases - ** or pages with the Pager.noSync flag set. - ** - ** If successful, or if called on a pager for which it is a no-op, this - ** function returns SQLITE_OK. Otherwise, an IO error code is returned. - */ - static int sqlite3PagerSync(Pager pPager) { - long rc = SQLITE_OK; - if (!pPager.noSync) { - Debug.Assert( + /* Release the page reference. */ + sqlite3PagerUnref( pPgHdr ); + } + return rc; + } + + /* + ** Sync the database file to disk. This is a no-op for in-memory databases + ** or pages with the Pager.noSync flag set. + ** + ** If successful, or if called on a pager for which it is a no-op, this + ** function returns SQLITE_OK. Otherwise, an IO error code is returned. + */ + static int sqlite3PagerSync( Pager pPager ) + { + long rc = SQLITE_OK; + if ( !pPager.noSync ) + { + Debug.Assert( #if SQLITE_OMIT_MEMORYDB 0 == MEMDB #else - 0 == pPager.memDb + 0 == pPager.memDb #endif - ); - rc = sqlite3OsSync(pPager.fd, pPager.syncFlags); - } else if (isOpen(pPager.fd)) { - Debug.Assert( + ); + rc = sqlite3OsSync( pPager.fd, pPager.syncFlags ); + } + else if ( isOpen( pPager.fd ) ) + { + Debug.Assert( #if SQLITE_OMIT_MEMORYDB 0 == MEMDB #else - 0 == pPager.memDb + 0 == pPager.memDb #endif - ); - sqlite3OsFileControl(pPager.fd, SQLITE_FCNTL_SYNC_OMITTED, ref rc); - } - return (int)rc; - } + ); + sqlite3OsFileControl( pPager.fd, SQLITE_FCNTL_SYNC_OMITTED, ref rc ); + } + return (int)rc; + } - /* - ** This function may only be called while a write-transaction is active in - ** rollback. If the connection is in WAL mode, this call is a no-op. - ** Otherwise, if the connection does not already have an EXCLUSIVE lock on - ** the database file, an attempt is made to obtain one. - ** - ** If the EXCLUSIVE lock is already held or the attempt to obtain it is - ** successful, or the connection is in WAL mode, SQLITE_OK is returned. - ** Otherwise, either SQLITE_BUSY or an SQLITE_IOERR_XXX error code is - ** returned. - */ - static int sqlite3PagerExclusiveLock(Pager pPager) { - int rc = SQLITE_OK; - Debug.Assert(pPager.eState == PAGER_WRITER_CACHEMOD - || pPager.eState == PAGER_WRITER_DBMOD - || pPager.eState == PAGER_WRITER_LOCKED - ); - Debug.Assert(assert_pager_state(pPager)); - if (false == pagerUseWal(pPager)) { - rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK); - } - return rc; - } + /* + ** This function may only be called while a write-transaction is active in + ** rollback. If the connection is in WAL mode, this call is a no-op. + ** Otherwise, if the connection does not already have an EXCLUSIVE lock on + ** the database file, an attempt is made to obtain one. + ** + ** If the EXCLUSIVE lock is already held or the attempt to obtain it is + ** successful, or the connection is in WAL mode, SQLITE_OK is returned. + ** Otherwise, either SQLITE_BUSY or an SQLITE_IOERR_XXX error code is + ** returned. + */ + static int sqlite3PagerExclusiveLock( Pager pPager ) + { + int rc = SQLITE_OK; + Debug.Assert( pPager.eState == PAGER_WRITER_CACHEMOD + || pPager.eState == PAGER_WRITER_DBMOD + || pPager.eState == PAGER_WRITER_LOCKED + ); + Debug.Assert( assert_pager_state( pPager ) ); + if ( false == pagerUseWal( pPager ) ) + { + rc = pager_wait_on_lock( pPager, EXCLUSIVE_LOCK ); + } + return rc; + } - /* - ** Sync the database file for the pager pPager. zMaster points to the name - ** of a master journal file that should be written into the individual - ** journal file. zMaster may be NULL, which is interpreted as no master - ** journal (a single database transaction). - ** - ** This routine ensures that: - ** - ** * The database file change-counter is updated, - ** * the journal is synced (unless the atomic-write optimization is used), - ** * all dirty pages are written to the database file, - ** * the database file is truncated (if required), and - ** * the database file synced. - ** - ** The only thing that remains to commit the transaction is to finalize - ** (delete, truncate or zero the first part of) the journal file (or - ** delete the master journal file if specified). - ** - ** Note that if zMaster==NULL, this does not overwrite a previous value - ** passed to an sqlite3PagerCommitPhaseOne() call. - ** - ** If the final parameter - noSync - is true, then the database file itself - ** is not synced. The caller must call sqlite3PagerSync() directly to - ** sync the database file before calling CommitPhaseTwo() to delete the - ** journal file in this case. - */ - static int sqlite3PagerCommitPhaseOne( - Pager pPager, /* Pager object */ - string zMaster, /* If not NULL, the master journal name */ - bool noSync /* True to omit the xSync on the db file */ - ) { - int rc = SQLITE_OK; /* Return code */ - - Debug.Assert(pPager.eState == PAGER_WRITER_LOCKED - || pPager.eState == PAGER_WRITER_CACHEMOD - || pPager.eState == PAGER_WRITER_DBMOD - || pPager.eState == PAGER_ERROR - ); - Debug.Assert(assert_pager_state(pPager)); + /* + ** Sync the database file for the pager pPager. zMaster points to the name + ** of a master journal file that should be written into the individual + ** journal file. zMaster may be NULL, which is interpreted as no master + ** journal (a single database transaction). + ** + ** This routine ensures that: + ** + ** * The database file change-counter is updated, + ** * the journal is synced (unless the atomic-write optimization is used), + ** * all dirty pages are written to the database file, + ** * the database file is truncated (if required), and + ** * the database file synced. + ** + ** The only thing that remains to commit the transaction is to finalize + ** (delete, truncate or zero the first part of) the journal file (or + ** delete the master journal file if specified). + ** + ** Note that if zMaster==NULL, this does not overwrite a previous value + ** passed to an sqlite3PagerCommitPhaseOne() call. + ** + ** If the final parameter - noSync - is true, then the database file itself + ** is not synced. The caller must call sqlite3PagerSync() directly to + ** sync the database file before calling CommitPhaseTwo() to delete the + ** journal file in this case. + */ + static int sqlite3PagerCommitPhaseOne( + Pager pPager, /* Pager object */ + string zMaster, /* If not NULL, the master journal name */ + bool noSync /* True to omit the xSync on the db file */ + ) + { + int rc = SQLITE_OK; /* Return code */ - /* If a prior error occurred, report that error again. */ - if (NEVER(pPager.errCode != 0)) - return pPager.errCode; + Debug.Assert( pPager.eState == PAGER_WRITER_LOCKED + || pPager.eState == PAGER_WRITER_CACHEMOD + || pPager.eState == PAGER_WRITER_DBMOD + || pPager.eState == PAGER_ERROR + ); + Debug.Assert( assert_pager_state( pPager ) ); + + /* If a prior error occurred, report that error again. */ + if ( NEVER( pPager.errCode != 0 ) ) + return pPager.errCode; - PAGERTRACE("DATABASE SYNC: File=%s zMaster=%s nSize=%d\n", - pPager.zFilename, zMaster, pPager.dbSize); + PAGERTRACE( "DATABASE SYNC: File=%s zMaster=%s nSize=%d\n", + pPager.zFilename, zMaster, pPager.dbSize ); - /* If no database changes have been made, return early. */ - if (pPager.eState < PAGER_WRITER_CACHEMOD) - return SQLITE_OK; + /* If no database changes have been made, return early. */ + if ( pPager.eState < PAGER_WRITER_CACHEMOD ) + return SQLITE_OK; - if ( + if ( #if SQLITE_OMIT_MEMORYDB 0 != MEMDB #else - 0 != pPager.memDb + 0 != pPager.memDb #endif - ) { - /* If this is an in-memory db, or no pages have been written to, or this - ** function has already been called, it is mostly a no-op. However, any - ** backup in progress needs to be restarted. - */ - sqlite3BackupRestart(pPager.pBackup); - } else { - if (pagerUseWal(pPager)) { - PgHdr pList = sqlite3PcacheDirtyList(pPager.pPCache); - PgHdr pPageOne = null; - if (pList == null) { - /* Must have at least one page for the WAL commit flag. - ** Ticket [2d1a5c67dfc2363e44f29d9bbd57f] 2null11-null5-18 */ - rc = sqlite3PagerGet(pPager, 1, ref pPageOne); - pList = pPageOne; - pList.pDirty = null; - } - Debug.Assert(rc == SQLITE_OK); - if (ALWAYS(pList)) { - - rc = pagerWalFrames(pPager, pList, pPager.dbSize, 1, - (pPager.fullSync ? pPager.syncFlags : (byte)0) - ); - } - sqlite3PagerUnref(pPageOne); - if (rc == SQLITE_OK) { - sqlite3PcacheCleanAll(pPager.pPCache); - } - } else { - - /* The following block updates the change-counter. Exactly how it - ** does this depends on whether or not the atomic-update optimization - ** was enabled at compile time, and if this transaction meets the - ** runtime criteria to use the operation: - ** - ** * The file-system supports the atomic-write property for - ** blocks of size page-size, and - ** * This commit is not part of a multi-file transaction, and - ** * Exactly one page has been modified and store in the journal file. - ** - ** If the optimization was not enabled at compile time, then the - ** pager_incr_changecounter() function is called to update the change - ** counter in 'indirect-mode'. If the optimization is compiled in but - ** is not applicable to this transaction, call sqlite3JournalCreate() - ** to make sure the journal file has actually been created, then call - ** pager_incr_changecounter() to update the change-counter in indirect - ** mode. - ** - ** Otherwise, if the optimization is both enabled and applicable, - ** then call pager_incr_changecounter() to update the change-counter - ** in 'direct' mode. In this case the journal file will never be - ** created for this transaction. - */ + ) + { + /* If this is an in-memory db, or no pages have been written to, or this + ** function has already been called, it is mostly a no-op. However, any + ** backup in progress needs to be restarted. + */ + sqlite3BackupRestart( pPager.pBackup ); + } + else + { + if ( pagerUseWal( pPager ) ) + { + PgHdr pList = sqlite3PcacheDirtyList( pPager.pPCache ); + PgHdr pPageOne = null; + if ( pList == null ) + { + /* Must have at least one page for the WAL commit flag. + ** Ticket [2d1a5c67dfc2363e44f29d9bbd57f] 2null11-null5-18 */ + rc = sqlite3PagerGet( pPager, 1, ref pPageOne ); + pList = pPageOne; + pList.pDirty = null; + } + Debug.Assert( rc == SQLITE_OK ); + if ( ALWAYS( pList ) ) + { + + rc = pagerWalFrames( pPager, pList, pPager.dbSize, 1, + ( pPager.fullSync ? pPager.syncFlags : (byte)0 ) + ); + } + sqlite3PagerUnref( pPageOne ); + if ( rc == SQLITE_OK ) + { + sqlite3PcacheCleanAll( pPager.pPCache ); + } + } + else + { + + /* The following block updates the change-counter. Exactly how it + ** does this depends on whether or not the atomic-update optimization + ** was enabled at compile time, and if this transaction meets the + ** runtime criteria to use the operation: + ** + ** * The file-system supports the atomic-write property for + ** blocks of size page-size, and + ** * This commit is not part of a multi-file transaction, and + ** * Exactly one page has been modified and store in the journal file. + ** + ** If the optimization was not enabled at compile time, then the + ** pager_incr_changecounter() function is called to update the change + ** counter in 'indirect-mode'. If the optimization is compiled in but + ** is not applicable to this transaction, call sqlite3JournalCreate() + ** to make sure the journal file has actually been created, then call + ** pager_incr_changecounter() to update the change-counter in indirect + ** mode. + ** + ** Otherwise, if the optimization is both enabled and applicable, + ** then call pager_incr_changecounter() to update the change-counter + ** in 'direct' mode. In this case the journal file will never be + ** created for this transaction. + */ #if SQLITE_ENABLE_ATOMIC_WRITE PgHdr *pPg; Debug.Assert( isOpen(pPager.jfd) @@ -6230,269 +6686,289 @@ bool noSync /* True to omit the xSync on the db file */ } } #else - rc = pager_incr_changecounter(pPager, false); + rc = pager_incr_changecounter( pPager, false ); #endif - if (rc != SQLITE_OK) - goto commit_phase_one_exit; - - /* If this transaction has made the database smaller, then all pages - ** being discarded by the truncation must be written to the journal - ** file. This can only happen in auto-vacuum mode. - ** - ** Before reading the pages with page numbers larger than the - ** current value of Pager.dbSize, set dbSize back to the value - ** that it took at the start of the transaction. Otherwise, the - ** calls to sqlite3PagerGet() return zeroed pages instead of - ** reading data from the database file. - */ + if ( rc != SQLITE_OK ) + goto commit_phase_one_exit; + + /* If this transaction has made the database smaller, then all pages + ** being discarded by the truncation must be written to the journal + ** file. This can only happen in auto-vacuum mode. + ** + ** Before reading the pages with page numbers larger than the + ** current value of Pager.dbSize, set dbSize back to the value + ** that it took at the start of the transaction. Otherwise, the + ** calls to sqlite3PagerGet() return zeroed pages instead of + ** reading data from the database file. + */ #if !SQLITE_OMIT_AUTOVACUUM - if (pPager.dbSize < pPager.dbOrigSize - && pPager.journalMode != PAGER_JOURNALMODE_OFF - ) { - Pgno i; /* Iterator variable */ - Pgno iSkip = PAGER_MJ_PGNO(pPager); /* Pending lock page */ - Pgno dbSize = pPager.dbSize; /* Database image size */ - pPager.dbSize = pPager.dbOrigSize; - for (i = dbSize + 1; i <= pPager.dbOrigSize; i++) { - if (0 == sqlite3BitvecTest(pPager.pInJournal, i) && i != iSkip) { - PgHdr pPage = null; /* Page to journal */ - rc = sqlite3PagerGet(pPager, i, ref pPage); - if (rc != SQLITE_OK) - goto commit_phase_one_exit; - rc = sqlite3PagerWrite(pPage); - sqlite3PagerUnref(pPage); - if (rc != SQLITE_OK) - goto commit_phase_one_exit; - } - } - pPager.dbSize = dbSize; - } + if ( pPager.dbSize < pPager.dbOrigSize + && pPager.journalMode != PAGER_JOURNALMODE_OFF + ) + { + Pgno i; /* Iterator variable */ + Pgno iSkip = PAGER_MJ_PGNO( pPager ); /* Pending lock page */ + Pgno dbSize = pPager.dbSize; /* Database image size */ + pPager.dbSize = pPager.dbOrigSize; + for ( i = dbSize + 1; i <= pPager.dbOrigSize; i++ ) + { + if ( 0 == sqlite3BitvecTest( pPager.pInJournal, i ) && i != iSkip ) + { + PgHdr pPage = null; /* Page to journal */ + rc = sqlite3PagerGet( pPager, i, ref pPage ); + if ( rc != SQLITE_OK ) + goto commit_phase_one_exit; + rc = sqlite3PagerWrite( pPage ); + sqlite3PagerUnref( pPage ); + if ( rc != SQLITE_OK ) + goto commit_phase_one_exit; + } + } + pPager.dbSize = dbSize; + } #endif - /* Write the master journal name into the journal file. If a master - ** journal file name has already been written to the journal file, - ** or if zMaster is NULL (no master journal), then this call is a no-op. + /* Write the master journal name into the journal file. If a master +** journal file name has already been written to the journal file, +** or if zMaster is NULL (no master journal), then this call is a no-op. +*/ + rc = writeMasterJournal( pPager, zMaster ); + if ( rc != SQLITE_OK ) + goto commit_phase_one_exit; + + /* Sync the journal file and write all dirty pages to the database. + ** If the atomic-update optimization is being used, this sync will not + ** create the journal file or perform any real IO. + ** + ** Because the change-counter page was just modified, unless the + ** atomic-update optimization is used it is almost certain that the + ** journal requires a sync here. However, in locking_mode=exclusive + ** on a system under memory pressure it is just possible that this is + ** not the case. In this case it is likely enough that the redundant + ** xSync() call will be changed to a no-op by the OS anyhow. */ - rc = writeMasterJournal(pPager, zMaster); - if (rc != SQLITE_OK) - goto commit_phase_one_exit; - - /* Sync the journal file and write all dirty pages to the database. - ** If the atomic-update optimization is being used, this sync will not - ** create the journal file or perform any real IO. - ** - ** Because the change-counter page was just modified, unless the - ** atomic-update optimization is used it is almost certain that the - ** journal requires a sync here. However, in locking_mode=exclusive - ** on a system under memory pressure it is just possible that this is - ** not the case. In this case it is likely enough that the redundant - ** xSync() call will be changed to a no-op by the OS anyhow. - */ - rc = syncJournal(pPager, 0); - if (rc != SQLITE_OK) - goto commit_phase_one_exit; - - rc = pager_write_pagelist(pPager, sqlite3PcacheDirtyList(pPager.pPCache)); - if (rc != SQLITE_OK) { - Debug.Assert(rc != SQLITE_IOERR_BLOCKED); - goto commit_phase_one_exit; - } - sqlite3PcacheCleanAll(pPager.pPCache); - - /* If the file on disk is not the same size as the database image, - ** then use pager_truncate to grow or shrink the file here. - */ - if (pPager.dbSize != pPager.dbFileSize) { - Pgno nNew = (Pgno)(pPager.dbSize - (pPager.dbSize == PAGER_MJ_PGNO(pPager) ? 1 : 0)); - Debug.Assert(pPager.eState >= PAGER_WRITER_DBMOD); - rc = pager_truncate(pPager, nNew); - if (rc != SQLITE_OK) - goto commit_phase_one_exit; - } - - /* Finally, sync the database file. */ - if (!noSync) { - rc = sqlite3PagerSync(pPager); - } - IOTRACE("DBSYNC %p\n", pPager); - } - } + rc = syncJournal( pPager, 0 ); + if ( rc != SQLITE_OK ) + goto commit_phase_one_exit; - commit_phase_one_exit: - if (rc == SQLITE_OK && !pagerUseWal(pPager)) { - pPager.eState = PAGER_WRITER_FINISHED; - } - return rc; + rc = pager_write_pagelist( pPager, sqlite3PcacheDirtyList( pPager.pPCache ) ); + if ( rc != SQLITE_OK ) + { + Debug.Assert( rc != SQLITE_IOERR_BLOCKED ); + goto commit_phase_one_exit; + } + sqlite3PcacheCleanAll( pPager.pPCache ); + + /* If the file on disk is not the same size as the database image, + ** then use pager_truncate to grow or shrink the file here. + */ + if ( pPager.dbSize != pPager.dbFileSize ) + { + Pgno nNew = (Pgno)( pPager.dbSize - ( pPager.dbSize == PAGER_MJ_PGNO( pPager ) ? 1 : 0 ) ); + Debug.Assert( pPager.eState >= PAGER_WRITER_DBMOD ); + rc = pager_truncate( pPager, nNew ); + if ( rc != SQLITE_OK ) + goto commit_phase_one_exit; + } + + /* Finally, sync the database file. */ + if ( !noSync ) + { + rc = sqlite3PagerSync( pPager ); + } + IOTRACE( "DBSYNC %p\n", pPager ); } + } +commit_phase_one_exit: + if ( rc == SQLITE_OK && !pagerUseWal( pPager ) ) + { + pPager.eState = PAGER_WRITER_FINISHED; + } + return rc; + } - /* - ** When this function is called, the database file has been completely - ** updated to reflect the changes made by the current transaction and - ** synced to disk. The journal file still exists in the file-system - ** though, and if a failure occurs at this point it will eventually - ** be used as a hot-journal and the current transaction rolled back. - ** - ** This function finalizes the journal file, either by deleting, - ** truncating or partially zeroing it, so that it cannot be used - ** for hot-journal rollback. Once this is done the transaction is - ** irrevocably committed. - ** - ** If an error occurs, an IO error code is returned and the pager - ** moves into the error state. Otherwise, SQLITE_OK is returned. - */ - static int sqlite3PagerCommitPhaseTwo(Pager pPager) { - int rc = SQLITE_OK; /* Return code */ - - /* This routine should not be called if a prior error has occurred. - ** But if (due to a coding error elsewhere in the system) it does get - ** called, just return the same error code without doing anything. */ - if (NEVER(pPager.errCode) != 0) - return pPager.errCode; - - Debug.Assert(pPager.eState == PAGER_WRITER_LOCKED - || pPager.eState == PAGER_WRITER_FINISHED - || (pagerUseWal(pPager) && pPager.eState == PAGER_WRITER_CACHEMOD) - ); - Debug.Assert(assert_pager_state(pPager)); - /* An optimization. If the database was not actually modified during - ** this transaction, the pager is running in exclusive-mode and is - ** using persistent journals, then this function is a no-op. - ** - ** The start of the journal file currently contains a single journal - ** header with the nRec field set to 0. If such a journal is used as - ** a hot-journal during hot-journal rollback, 0 changes will be made - ** to the database file. So there is no need to zero the journal - ** header. Since the pager is in exclusive mode, there is no need - ** to drop any locks either. - */ - if (pPager.eState == PAGER_WRITER_LOCKED - && pPager.exclusiveMode - && pPager.journalMode == PAGER_JOURNALMODE_PERSIST - ) { - Debug.Assert(pPager.journalOff == JOURNAL_HDR_SZ(pPager) || 0 == pPager.journalOff); - pPager.eState = PAGER_READER; - return SQLITE_OK; - } + /* + ** When this function is called, the database file has been completely + ** updated to reflect the changes made by the current transaction and + ** synced to disk. The journal file still exists in the file-system + ** though, and if a failure occurs at this point it will eventually + ** be used as a hot-journal and the current transaction rolled back. + ** + ** This function finalizes the journal file, either by deleting, + ** truncating or partially zeroing it, so that it cannot be used + ** for hot-journal rollback. Once this is done the transaction is + ** irrevocably committed. + ** + ** If an error occurs, an IO error code is returned and the pager + ** moves into the error state. Otherwise, SQLITE_OK is returned. + */ + static int sqlite3PagerCommitPhaseTwo( Pager pPager ) + { + int rc = SQLITE_OK; /* Return code */ - PAGERTRACE("COMMIT %d\n", PAGERID(pPager)); - rc = pager_end_transaction(pPager, pPager.setMaster); - return pager_error(pPager, rc); - } + /* This routine should not be called if a prior error has occurred. + ** But if (due to a coding error elsewhere in the system) it does get + ** called, just return the same error code without doing anything. */ + if ( NEVER( pPager.errCode ) != 0 ) + return pPager.errCode; - /* - ** If a write transaction is open, then all changes made within the - ** transaction are reverted and the current write-transaction is closed. - ** The pager falls back to PAGER_READER state if successful, or PAGER_ERROR - ** state if an error occurs. - ** - ** If the pager is already in PAGER_ERROR state when this function is called, - ** it returns Pager.errCode immediately. No work is performed in this case. - ** - ** Otherwise, in rollback mode, this function performs two functions: - ** - ** 1) It rolls back the journal file, restoring all database file and - ** in-memory cache pages to the state they were in when the transaction - ** was opened, and - ** - ** 2) It finalizes the journal file, so that it is not used for hot - ** rollback at any point in the future. - ** - ** Finalization of the journal file (task 2) is only performed if the - ** rollback is successful. - ** - ** In WAL mode, all cache-entries containing data modified within the - ** current transaction are either expelled from the cache or reverted to - ** their pre-transaction state by re-reading data from the database or - ** WAL files. The WAL transaction is then closed. - */ - static int sqlite3PagerRollback(Pager pPager) { - int rc = SQLITE_OK; /* Return code */ - PAGERTRACE("ROLLBACK %d\n", PAGERID(pPager)); + Debug.Assert( pPager.eState == PAGER_WRITER_LOCKED + || pPager.eState == PAGER_WRITER_FINISHED + || ( pagerUseWal( pPager ) && pPager.eState == PAGER_WRITER_CACHEMOD ) + ); + Debug.Assert( assert_pager_state( pPager ) ); - /* PagerRollback() is a no-op if called in READER or OPEN state. If - ** the pager is already in the ERROR state, the rollback is not - ** attempted here. Instead, the error code is returned to the caller. - */ - Debug.Assert(assert_pager_state(pPager)); - if (pPager.eState == PAGER_ERROR) - return pPager.errCode; - if (pPager.eState <= PAGER_READER) - return SQLITE_OK; - - if (pagerUseWal(pPager)) { - int rc2; - - rc = sqlite3PagerSavepoint(pPager, SAVEPOINT_ROLLBACK, -1); - rc2 = pager_end_transaction(pPager, pPager.setMaster); - if (rc == SQLITE_OK) - rc = rc2; - rc = pager_error(pPager, rc); - } else if (!isOpen(pPager.jfd) || pPager.eState == PAGER_WRITER_LOCKED) { - int eState = pPager.eState; - rc = pager_end_transaction(pPager, 0); - if ( + /* An optimization. If the database was not actually modified during + ** this transaction, the pager is running in exclusive-mode and is + ** using persistent journals, then this function is a no-op. + ** + ** The start of the journal file currently contains a single journal + ** header with the nRec field set to 0. If such a journal is used as + ** a hot-journal during hot-journal rollback, 0 changes will be made + ** to the database file. So there is no need to zero the journal + ** header. Since the pager is in exclusive mode, there is no need + ** to drop any locks either. + */ + if ( pPager.eState == PAGER_WRITER_LOCKED + && pPager.exclusiveMode + && pPager.journalMode == PAGER_JOURNALMODE_PERSIST + ) + { + Debug.Assert( pPager.journalOff == JOURNAL_HDR_SZ( pPager ) || 0 == pPager.journalOff ); + pPager.eState = PAGER_READER; + return SQLITE_OK; + } + + PAGERTRACE( "COMMIT %d\n", PAGERID( pPager ) ); + rc = pager_end_transaction( pPager, pPager.setMaster ); + return pager_error( pPager, rc ); + } + + /* + ** If a write transaction is open, then all changes made within the + ** transaction are reverted and the current write-transaction is closed. + ** The pager falls back to PAGER_READER state if successful, or PAGER_ERROR + ** state if an error occurs. + ** + ** If the pager is already in PAGER_ERROR state when this function is called, + ** it returns Pager.errCode immediately. No work is performed in this case. + ** + ** Otherwise, in rollback mode, this function performs two functions: + ** + ** 1) It rolls back the journal file, restoring all database file and + ** in-memory cache pages to the state they were in when the transaction + ** was opened, and + ** + ** 2) It finalizes the journal file, so that it is not used for hot + ** rollback at any point in the future. + ** + ** Finalization of the journal file (task 2) is only performed if the + ** rollback is successful. + ** + ** In WAL mode, all cache-entries containing data modified within the + ** current transaction are either expelled from the cache or reverted to + ** their pre-transaction state by re-reading data from the database or + ** WAL files. The WAL transaction is then closed. + */ + static int sqlite3PagerRollback( Pager pPager ) + { + int rc = SQLITE_OK; /* Return code */ + PAGERTRACE( "ROLLBACK %d\n", PAGERID( pPager ) ); + + /* PagerRollback() is a no-op if called in READER or OPEN state. If + ** the pager is already in the ERROR state, the rollback is not + ** attempted here. Instead, the error code is returned to the caller. + */ + Debug.Assert( assert_pager_state( pPager ) ); + if ( pPager.eState == PAGER_ERROR ) + return pPager.errCode; + if ( pPager.eState <= PAGER_READER ) + return SQLITE_OK; + + if ( pagerUseWal( pPager ) ) + { + int rc2; + + rc = sqlite3PagerSavepoint( pPager, SAVEPOINT_ROLLBACK, -1 ); + rc2 = pager_end_transaction( pPager, pPager.setMaster ); + if ( rc == SQLITE_OK ) + rc = rc2; + rc = pager_error( pPager, rc ); + } + else if ( !isOpen( pPager.jfd ) || pPager.eState == PAGER_WRITER_LOCKED ) + { + int eState = pPager.eState; + rc = pager_end_transaction( pPager, 0 ); + if ( #if SQLITE_OMIT_MEMORYDB 0==MEMDB #else - 0 == pPager.memDb + 0 == pPager.memDb #endif - && eState > PAGER_WRITER_LOCKED) { - /* This can happen using journal_mode=off. Move the pager to the error - ** state to indicate that the contents of the cache may not be trusted. - ** Any active readers will get SQLITE_ABORT. - */ - pPager.errCode = SQLITE_ABORT; - pPager.eState = PAGER_ERROR; - return rc; - } - } else { - rc = pager_playback(pPager, 0); - } + && eState > PAGER_WRITER_LOCKED ) + { + /* This can happen using journal_mode=off. Move the pager to the error + ** state to indicate that the contents of the cache may not be trusted. + ** Any active readers will get SQLITE_ABORT. + */ + pPager.errCode = SQLITE_ABORT; + pPager.eState = PAGER_ERROR; + return rc; + } + } + else + { + rc = pager_playback( pPager, 0 ); + } - Debug.Assert(pPager.eState == PAGER_READER || rc != SQLITE_OK); - Debug.Assert(rc == SQLITE_OK || rc == SQLITE_FULL || (rc & 0xFF) == SQLITE_IOERR); + Debug.Assert( pPager.eState == PAGER_READER || rc != SQLITE_OK ); + Debug.Assert( rc == SQLITE_OK || rc == SQLITE_FULL || ( rc & 0xFF ) == SQLITE_IOERR ); - /* If an error occurs during a ROLLBACK, we can no longer trust the pager - ** cache. So call pager_error() on the way out to make any error persistent. - */ - return pager_error(pPager, rc); - } + /* If an error occurs during a ROLLBACK, we can no longer trust the pager + ** cache. So call pager_error() on the way out to make any error persistent. + */ + return pager_error( pPager, rc ); + } - /* - ** Return TRUE if the database file is opened read-only. Return FALSE - ** if the database is (in theory) writable. - */ - static bool sqlite3PagerIsreadonly(Pager pPager) { - return pPager.readOnly; - } + /* + ** Return TRUE if the database file is opened read-only. Return FALSE + ** if the database is (in theory) writable. + */ + static bool sqlite3PagerIsreadonly( Pager pPager ) + { + return pPager.readOnly; + } - /* - ** Return the number of references to the pager. - */ - static int sqlite3PagerRefcount(Pager pPager) { - return sqlite3PcacheRefCount(pPager.pPCache); - } + /* + ** Return the number of references to the pager. + */ + static int sqlite3PagerRefcount( Pager pPager ) + { + return sqlite3PcacheRefCount( pPager.pPCache ); + } - /* - ** Return the approximate number of bytes of memory currently - ** used by the pager and its associated cache. - */ - static int sqlite3PagerMemUsed(Pager pPager) { - int perPageSize = pPager.pageSize + pPager.nExtra + 20; //+ sizeof(PgHdr) + 5*sizeof(void*); - return perPageSize * sqlite3PcachePagecount(pPager.pPCache) - + 0// Not readily available under C#// sqlite3MallocSize(pPager); - + pPager.pageSize; - } + /* + ** Return the approximate number of bytes of memory currently + ** used by the pager and its associated cache. + */ + static int sqlite3PagerMemUsed( Pager pPager ) + { + int perPageSize = pPager.pageSize + pPager.nExtra + 20; //+ sizeof(PgHdr) + 5*sizeof(void*); + return perPageSize * sqlite3PcachePagecount( pPager.pPCache ) + + 0// Not readily available under C#// sqlite3MallocSize(pPager); + + pPager.pageSize; + } - /* - ** Return the number of references to the specified page. - */ - static int sqlite3PagerPageRefcount(DbPage pPage) { - return sqlite3PcachePageRefcount(pPage); - } + /* + ** Return the number of references to the specified page. + */ + static int sqlite3PagerPageRefcount( DbPage pPage ) + { + return sqlite3PcachePageRefcount( pPage ); + } #if SQLITE_TEST @@ -6517,193 +6993,213 @@ static int[] sqlite3PagerStats( Pager pPager ) } #endif - /* - ** Return true if this is an in-memory pager. - */ - static bool sqlite3PagerIsMemdb(Pager pPager) { + /* +** Return true if this is an in-memory pager. +*/ + static bool sqlite3PagerIsMemdb( Pager pPager ) + { #if SQLITE_OMIT_MEMORYDB return MEMDB != 0; #else - return pPager.memDb != 0; + return pPager.memDb != 0; #endif + } + + /* + ** Check that there are at least nSavepoint savepoints open. If there are + ** currently less than nSavepoints open, then open one or more savepoints + ** to make up the difference. If the number of savepoints is already + ** equal to nSavepoint, then this function is a no-op. + ** + ** If a memory allocation fails, SQLITE_NOMEM is returned. If an error + ** occurs while opening the sub-journal file, then an IO error code is + ** returned. Otherwise, SQLITE_OK. + */ + static int sqlite3PagerOpenSavepoint( Pager pPager, int nSavepoint ) + { + int rc = SQLITE_OK; /* Return code */ + int nCurrent = pPager.nSavepoint; /* Current number of savepoints */ + + Debug.Assert( pPager.eState >= PAGER_WRITER_LOCKED ); + Debug.Assert( assert_pager_state( pPager ) ); + + if ( nSavepoint > nCurrent && pPager.useJournal != 0 ) + { + int ii; /* Iterator variable */ + PagerSavepoint[] aNew; /* New Pager.aSavepoint array */ + + /* Grow the Pager.aSavepoint array using realloc(). Return SQLITE_NOMEM + ** if the allocation fails. Otherwise, zero the new portion in case a + ** malloc failure occurs while populating it in the for(...) loop below. + */ + //aNew = (PagerSavepoint *)sqlite3Realloc( + // pPager.aSavepoint, sizeof(PagerSavepoint)*nSavepoint + //); + Array.Resize( ref pPager.aSavepoint, nSavepoint ); + aNew = pPager.aSavepoint; + //if( null==aNew ){ + // return SQLITE_NOMEM; + //} + // memset(&aNew[nCurrent], 0, (nSavepoint-nCurrent) * sizeof(PagerSavepoint)); + // pPager.aSavepoint = aNew; + + /* Populate the PagerSavepoint structures just allocated. */ + for ( ii = nCurrent; ii < nSavepoint; ii++ ) + { + aNew[ii] = new PagerSavepoint(); + aNew[ii].nOrig = pPager.dbSize; + if ( isOpen( pPager.jfd ) && pPager.journalOff > 0 ) + { + aNew[ii].iOffset = pPager.journalOff; + } + else + { + aNew[ii].iOffset = (int)JOURNAL_HDR_SZ( pPager ); + } + aNew[ii].iSubRec = pPager.nSubRec; + aNew[ii].pInSavepoint = sqlite3BitvecCreate( pPager.dbSize ); + //if ( null == aNew[ii].pInSavepoint ) + //{ + // return SQLITE_NOMEM; + //} + if ( pagerUseWal( pPager ) ) + { + sqlite3WalSavepoint( pPager.pWal, aNew[ii].aWalData ); + } + pPager.nSavepoint = ii + 1; } + Debug.Assert( pPager.nSavepoint == nSavepoint ); + assertTruncateConstraint( pPager ); + } - /* - ** Check that there are at least nSavepoint savepoints open. If there are - ** currently less than nSavepoints open, then open one or more savepoints - ** to make up the difference. If the number of savepoints is already - ** equal to nSavepoint, then this function is a no-op. - ** - ** If a memory allocation fails, SQLITE_NOMEM is returned. If an error - ** occurs while opening the sub-journal file, then an IO error code is - ** returned. Otherwise, SQLITE_OK. - */ - static int sqlite3PagerOpenSavepoint(Pager pPager, int nSavepoint) { - int rc = SQLITE_OK; /* Return code */ - int nCurrent = pPager.nSavepoint; /* Current number of savepoints */ - - Debug.Assert(pPager.eState >= PAGER_WRITER_LOCKED); - Debug.Assert(assert_pager_state(pPager)); + return rc; + } - if (nSavepoint > nCurrent && pPager.useJournal != 0) { - int ii; /* Iterator variable */ - PagerSavepoint[] aNew; /* New Pager.aSavepoint array */ + /* + ** This function is called to rollback or release (commit) a savepoint. + ** The savepoint to release or rollback need not be the most recently + ** created savepoint. + ** + ** Parameter op is always either SAVEPOINT_ROLLBACK or SAVEPOINT_RELEASE. + ** If it is SAVEPOINT_RELEASE, then release and destroy the savepoint with + ** index iSavepoint. If it is SAVEPOINT_ROLLBACK, then rollback all changes + ** that have occurred since the specified savepoint was created. + ** + ** The savepoint to rollback or release is identified by parameter + ** iSavepoint. A value of 0 means to operate on the outermost savepoint + ** (the first created). A value of (Pager.nSavepoint-1) means operate + ** on the most recently created savepoint. If iSavepoint is greater than + ** (Pager.nSavepoint-1), then this function is a no-op. + ** + ** If a negative value is passed to this function, then the current + ** transaction is rolled back. This is different to calling + ** sqlite3PagerRollback() because this function does not terminate + ** the transaction or unlock the database, it just restores the + ** contents of the database to its original state. + ** + ** In any case, all savepoints with an index greater than iSavepoint + ** are destroyed. If this is a release operation (op==SAVEPOINT_RELEASE), + ** then savepoint iSavepoint is also destroyed. + ** + ** This function may return SQLITE_NOMEM if a memory allocation fails, + ** or an IO error code if an IO error occurs while rolling back a + ** savepoint. If no errors occur, SQLITE_OK is returned. + */ + static int sqlite3PagerSavepoint( Pager pPager, int op, int iSavepoint ) + { + int rc = pPager.errCode; /* Return code */ - /* Grow the Pager.aSavepoint array using realloc(). Return SQLITE_NOMEM - ** if the allocation fails. Otherwise, zero the new portion in case a - ** malloc failure occurs while populating it in the for(...) loop below. - */ - //aNew = (PagerSavepoint *)sqlite3Realloc( - // pPager.aSavepoint, sizeof(PagerSavepoint)*nSavepoint - //); - Array.Resize(ref pPager.aSavepoint, nSavepoint); - aNew = pPager.aSavepoint; - //if( null==aNew ){ - // return SQLITE_NOMEM; - //} - // memset(&aNew[nCurrent], 0, (nSavepoint-nCurrent) * sizeof(PagerSavepoint)); - // pPager.aSavepoint = aNew; - - /* Populate the PagerSavepoint structures just allocated. */ - for (ii = nCurrent; ii < nSavepoint; ii++) { - aNew[ii] = new PagerSavepoint(); - aNew[ii].nOrig = pPager.dbSize; - if (isOpen(pPager.jfd) && pPager.journalOff > 0) { - aNew[ii].iOffset = pPager.journalOff; - } else { - aNew[ii].iOffset = (int)JOURNAL_HDR_SZ(pPager); - } - aNew[ii].iSubRec = pPager.nSubRec; - aNew[ii].pInSavepoint = sqlite3BitvecCreate(pPager.dbSize); - //if ( null == aNew[ii].pInSavepoint ) - //{ - // return SQLITE_NOMEM; - //} - if (pagerUseWal(pPager)) { - sqlite3WalSavepoint(pPager.pWal, aNew[ii].aWalData); - } - pPager.nSavepoint = ii + 1; - } - Debug.Assert(pPager.nSavepoint == nSavepoint); - assertTruncateConstraint(pPager); - } + Debug.Assert( op == SAVEPOINT_RELEASE || op == SAVEPOINT_ROLLBACK ); + Debug.Assert( iSavepoint >= 0 || op == SAVEPOINT_ROLLBACK ); - return rc; - } + if ( rc == SQLITE_OK && iSavepoint < pPager.nSavepoint ) + { + int ii; /* Iterator variable */ + int nNew; /* Number of remaining savepoints after this op. */ - /* - ** This function is called to rollback or release (commit) a savepoint. - ** The savepoint to release or rollback need not be the most recently - ** created savepoint. - ** - ** Parameter op is always either SAVEPOINT_ROLLBACK or SAVEPOINT_RELEASE. - ** If it is SAVEPOINT_RELEASE, then release and destroy the savepoint with - ** index iSavepoint. If it is SAVEPOINT_ROLLBACK, then rollback all changes - ** that have occurred since the specified savepoint was created. - ** - ** The savepoint to rollback or release is identified by parameter - ** iSavepoint. A value of 0 means to operate on the outermost savepoint - ** (the first created). A value of (Pager.nSavepoint-1) means operate - ** on the most recently created savepoint. If iSavepoint is greater than - ** (Pager.nSavepoint-1), then this function is a no-op. - ** - ** If a negative value is passed to this function, then the current - ** transaction is rolled back. This is different to calling - ** sqlite3PagerRollback() because this function does not terminate - ** the transaction or unlock the database, it just restores the - ** contents of the database to its original state. - ** - ** In any case, all savepoints with an index greater than iSavepoint - ** are destroyed. If this is a release operation (op==SAVEPOINT_RELEASE), - ** then savepoint iSavepoint is also destroyed. - ** - ** This function may return SQLITE_NOMEM if a memory allocation fails, - ** or an IO error code if an IO error occurs while rolling back a - ** savepoint. If no errors occur, SQLITE_OK is returned. + /* Figure out how many savepoints will still be active after this + ** operation. Store this value in nNew. Then free resources associated + ** with any savepoints that are destroyed by this operation. */ - static int sqlite3PagerSavepoint(Pager pPager, int op, int iSavepoint) { - int rc = pPager.errCode; /* Return code */ - - Debug.Assert(op == SAVEPOINT_RELEASE || op == SAVEPOINT_ROLLBACK); - Debug.Assert(iSavepoint >= 0 || op == SAVEPOINT_ROLLBACK); - - if (rc == SQLITE_OK && iSavepoint < pPager.nSavepoint) { - int ii; /* Iterator variable */ - int nNew; /* Number of remaining savepoints after this op. */ + nNew = iSavepoint + ( ( op == SAVEPOINT_RELEASE ) ? 0 : 1 ); + for ( ii = nNew; ii < pPager.nSavepoint; ii++ ) + { + sqlite3BitvecDestroy( ref pPager.aSavepoint[ii].pInSavepoint ); + } + pPager.nSavepoint = nNew; - /* Figure out how many savepoints will still be active after this - ** operation. Store this value in nNew. Then free resources associated - ** with any savepoints that are destroyed by this operation. - */ - nNew = iSavepoint + ((op == SAVEPOINT_RELEASE) ? 0 : 1); - for (ii = nNew; ii < pPager.nSavepoint; ii++) { - sqlite3BitvecDestroy(ref pPager.aSavepoint[ii].pInSavepoint); - } - pPager.nSavepoint = nNew; - - /* If this is a release of the outermost savepoint, truncate - ** the sub-journal to zero bytes in size. */ - if (op == SAVEPOINT_RELEASE) { - if (nNew == 0 && isOpen(pPager.sjfd)) { - /* Only truncate if it is an in-memory sub-journal. */ - if (sqlite3IsMemJournal(pPager.sjfd)) { - rc = sqlite3OsTruncate(pPager.sjfd, 0); - Debug.Assert(rc == SQLITE_OK); - } - pPager.nSubRec = 0; - } - } - /* Else this is a rollback operation, playback the specified savepoint. - ** If this is a temp-file, it is possible that the journal file has - ** not yet been opened. In this case there have been no changes to - ** the database file, so the playback operation can be skipped. - */ - else if (pagerUseWal(pPager) || isOpen(pPager.jfd)) { - PagerSavepoint pSavepoint = (nNew == 0) ? null : pPager.aSavepoint[nNew - 1]; - rc = pagerPlaybackSavepoint(pPager, pSavepoint); - Debug.Assert(rc != SQLITE_DONE); - } + /* If this is a release of the outermost savepoint, truncate + ** the sub-journal to zero bytes in size. */ + if ( op == SAVEPOINT_RELEASE ) + { + if ( nNew == 0 && isOpen( pPager.sjfd ) ) + { + /* Only truncate if it is an in-memory sub-journal. */ + if ( sqlite3IsMemJournal( pPager.sjfd ) ) + { + rc = sqlite3OsTruncate( pPager.sjfd, 0 ); + Debug.Assert( rc == SQLITE_OK ); } - return rc; + pPager.nSubRec = 0; + } } - - /* - ** Return the full pathname of the database file. + /* Else this is a rollback operation, playback the specified savepoint. + ** If this is a temp-file, it is possible that the journal file has + ** not yet been opened. In this case there have been no changes to + ** the database file, so the playback operation can be skipped. */ - static string sqlite3PagerFilename(Pager pPager) { - return pPager.zFilename; + else if ( pagerUseWal( pPager ) || isOpen( pPager.jfd ) ) + { + PagerSavepoint pSavepoint = ( nNew == 0 ) ? null : pPager.aSavepoint[nNew - 1]; + rc = pagerPlaybackSavepoint( pPager, pSavepoint ); + Debug.Assert( rc != SQLITE_DONE ); } + } + return rc; + } - /* - ** Return the VFS structure for the pager. - */ - static sqlite3_vfs sqlite3PagerVfs(Pager pPager) { - return pPager.pVfs; - } + /* + ** Return the full pathname of the database file. + */ + static string sqlite3PagerFilename( Pager pPager ) + { + return pPager.zFilename; + } - /* - ** Return the file handle for the database file associated - ** with the pager. This might return NULL if the file has - ** not yet been opened. - */ - static sqlite3_file sqlite3PagerFile(Pager pPager) { - return pPager.fd; - } + /* + ** Return the VFS structure for the pager. + */ + static sqlite3_vfs sqlite3PagerVfs( Pager pPager ) + { + return pPager.pVfs; + } - /* - ** Return the full pathname of the journal file. - */ - static string sqlite3PagerJournalname(Pager pPager) { - return pPager.zJournal; - } + /* + ** Return the file handle for the database file associated + ** with the pager. This might return NULL if the file has + ** not yet been opened. + */ + static sqlite3_file sqlite3PagerFile( Pager pPager ) + { + return pPager.fd; + } - /* - ** Return true if fsync() calls are disabled for this pager. Return FALSE - ** if fsync()s are executed normally. - */ - static bool sqlite3PagerNosync(Pager pPager) { - return pPager.noSync; - } + /* + ** Return the full pathname of the journal file. + */ + static string sqlite3PagerJournalname( Pager pPager ) + { + return pPager.zJournal; + } + + /* + ** Return true if fsync() calls are disabled for this pager. Return FALSE + ** if fsync()s are executed normally. + */ + static bool sqlite3PagerNosync( Pager pPager ) + { + return pPager.noSync; + } #if SQLITE_HAS_CODEC /* @@ -6733,378 +7229,413 @@ static object sqlite3PagerGetCodec( Pager pPager ) #endif #if !SQLITE_OMIT_AUTOVACUUM - /* - ** Move the page pPg to location pgno in the file. - ** - ** There must be no references to the page previously located at - ** pgno (which we call pPgOld) though that page is allowed to be - ** in cache. If the page previously located at pgno is not already - ** in the rollback journal, it is not put there by by this routine. - ** - ** References to the page pPg remain valid. Updating any - ** meta-data associated with pPg (i.e. data stored in the nExtra bytes - ** allocated along with the page) is the responsibility of the caller. - ** - ** A transaction must be active when this routine is called. It used to be - ** required that a statement transaction was not active, but this restriction - ** has been removed (CREATE INDEX needs to move a page when a statement - ** transaction is active). - ** - ** If the fourth argument, isCommit, is non-zero, then this page is being - ** moved as part of a database reorganization just before the transaction - ** is being committed. In this case, it is guaranteed that the database page - ** pPg refers to will not be written to again within this transaction. - ** - ** This function may return SQLITE_NOMEM or an IO error code if an error - ** occurs. Otherwise, it returns SQLITE_OK. - */ - static int sqlite3PagerMovepage(Pager pPager, DbPage pPg, u32 pgno, int isCommit) { - PgHdr pPgOld; /* The page being overwritten. */ - u32 needSyncPgno = 0; /* Old value of pPg.pgno, if sync is required */ - int rc; /* Return code */ - Pgno origPgno; /* The original page number */ - - Debug.Assert(pPg.nRef > 0); - Debug.Assert(pPager.eState == PAGER_WRITER_CACHEMOD - || pPager.eState == PAGER_WRITER_DBMOD - ); - Debug.Assert(assert_pager_state(pPager)); + /* +** Move the page pPg to location pgno in the file. +** +** There must be no references to the page previously located at +** pgno (which we call pPgOld) though that page is allowed to be +** in cache. If the page previously located at pgno is not already +** in the rollback journal, it is not put there by by this routine. +** +** References to the page pPg remain valid. Updating any +** meta-data associated with pPg (i.e. data stored in the nExtra bytes +** allocated along with the page) is the responsibility of the caller. +** +** A transaction must be active when this routine is called. It used to be +** required that a statement transaction was not active, but this restriction +** has been removed (CREATE INDEX needs to move a page when a statement +** transaction is active). +** +** If the fourth argument, isCommit, is non-zero, then this page is being +** moved as part of a database reorganization just before the transaction +** is being committed. In this case, it is guaranteed that the database page +** pPg refers to will not be written to again within this transaction. +** +** This function may return SQLITE_NOMEM or an IO error code if an error +** occurs. Otherwise, it returns SQLITE_OK. +*/ + static int sqlite3PagerMovepage( Pager pPager, DbPage pPg, u32 pgno, int isCommit ) + { + PgHdr pPgOld; /* The page being overwritten. */ + u32 needSyncPgno = 0; /* Old value of pPg.pgno, if sync is required */ + int rc; /* Return code */ + Pgno origPgno; /* The original page number */ + + Debug.Assert( pPg.nRef > 0 ); + Debug.Assert( pPager.eState == PAGER_WRITER_CACHEMOD + || pPager.eState == PAGER_WRITER_DBMOD + ); + Debug.Assert( assert_pager_state( pPager ) ); - /* In order to be able to rollback, an in-memory database must journal - ** the page we are moving from. - */ - if ( + /* In order to be able to rollback, an in-memory database must journal + ** the page we are moving from. + */ + if ( #if SQLITE_OMIT_MEMORYDB 1==MEMDB #else - pPager.memDb != 0 + pPager.memDb != 0 #endif - ) { - rc = sqlite3PagerWrite(pPg); - if (rc != 0) - return rc; - } + ) + { + rc = sqlite3PagerWrite( pPg ); + if ( rc != 0 ) + return rc; + } - /* If the page being moved is dirty and has not been saved by the latest - ** savepoint, then save the current contents of the page into the - ** sub-journal now. This is required to handle the following scenario: - ** - ** BEGIN; - ** - ** SAVEPOINT one; - ** - ** ROLLBACK TO one; - ** - ** If page X were not written to the sub-journal here, it would not - ** be possible to restore its contents when the "ROLLBACK TO one" - ** statement were is processed. - ** - ** subjournalPage() may need to allocate space to store pPg.pgno into - ** one or more savepoint bitvecs. This is the reason this function - ** may return SQLITE_NOMEM. - */ - if ((pPg.flags & PGHDR_DIRTY) != 0 - && subjRequiresPage(pPg) - && SQLITE_OK != (rc = subjournalPage(pPg)) - ) { - return rc; - } + /* If the page being moved is dirty and has not been saved by the latest + ** savepoint, then save the current contents of the page into the + ** sub-journal now. This is required to handle the following scenario: + ** + ** BEGIN; + ** + ** SAVEPOINT one; + ** + ** ROLLBACK TO one; + ** + ** If page X were not written to the sub-journal here, it would not + ** be possible to restore its contents when the "ROLLBACK TO one" + ** statement were is processed. + ** + ** subjournalPage() may need to allocate space to store pPg.pgno into + ** one or more savepoint bitvecs. This is the reason this function + ** may return SQLITE_NOMEM. + */ + if ( ( pPg.flags & PGHDR_DIRTY ) != 0 + && subjRequiresPage( pPg ) + && SQLITE_OK != ( rc = subjournalPage( pPg ) ) + ) + { + return rc; + } - PAGERTRACE("MOVE %d page %d (needSync=%d) moves to %d\n", - PAGERID(pPager), pPg.pgno, (pPg.flags & PGHDR_NEED_SYNC) != 0 ? 1 : 0, pgno); - IOTRACE("MOVE %p %d %d\n", pPager, pPg.pgno, pgno); + PAGERTRACE( "MOVE %d page %d (needSync=%d) moves to %d\n", + PAGERID( pPager ), pPg.pgno, ( pPg.flags & PGHDR_NEED_SYNC ) != 0 ? 1 : 0, pgno ); + IOTRACE( "MOVE %p %d %d\n", pPager, pPg.pgno, pgno ); - /* If the journal needs to be sync()ed before page pPg.pgno can - ** be written to, store pPg.pgno in local variable needSyncPgno. - ** - ** If the isCommit flag is set, there is no need to remember that - ** the journal needs to be sync()ed before database page pPg.pgno - ** can be written to. The caller has already promised not to write to it. - */ - if (((pPg.flags & PGHDR_NEED_SYNC) != 0) && 0 == isCommit) { - needSyncPgno = pPg.pgno; - Debug.Assert(pageInJournal(pPg) || pPg.pgno > pPager.dbOrigSize); - Debug.Assert((pPg.flags & PGHDR_DIRTY) != 0); - } + /* If the journal needs to be sync()ed before page pPg.pgno can + ** be written to, store pPg.pgno in local variable needSyncPgno. + ** + ** If the isCommit flag is set, there is no need to remember that + ** the journal needs to be sync()ed before database page pPg.pgno + ** can be written to. The caller has already promised not to write to it. + */ + if ( ( ( pPg.flags & PGHDR_NEED_SYNC ) != 0 ) && 0 == isCommit ) + { + needSyncPgno = pPg.pgno; + Debug.Assert( pageInJournal( pPg ) || pPg.pgno > pPager.dbOrigSize ); + Debug.Assert( ( pPg.flags & PGHDR_DIRTY ) != 0 ); + } - /* If the cache contains a page with page-number pgno, remove it - ** from its hash chain. Also, if the PGHDR_NEED_SYNC was set for - ** page pgno before the 'move' operation, it needs to be retained - ** for the page moved there. - */ - pPg.flags &= ~PGHDR_NEED_SYNC; - pPgOld = pager_lookup(pPager, pgno); - Debug.Assert(null == pPgOld || pPgOld.nRef == 1); - if (pPgOld != null) { - pPg.flags |= (pPgOld.flags & PGHDR_NEED_SYNC); - if ( + /* If the cache contains a page with page-number pgno, remove it + ** from its hash chain. Also, if the PGHDR_NEED_SYNC was set for + ** page pgno before the 'move' operation, it needs to be retained + ** for the page moved there. + */ + pPg.flags &= ~PGHDR_NEED_SYNC; + pPgOld = pager_lookup( pPager, pgno ); + Debug.Assert( null == pPgOld || pPgOld.nRef == 1 ); + if ( pPgOld != null ) + { + pPg.flags |= ( pPgOld.flags & PGHDR_NEED_SYNC ); + if ( #if SQLITE_OMIT_MEMORYDB 1==MEMDB #else - pPager.memDb != 0 + pPager.memDb != 0 #endif - ) { - /* Do not discard pages from an in-memory database since we might - ** need to rollback later. Just move the page out of the way. */ - sqlite3PcacheMove(pPgOld, pPager.dbSize + 1); - } else { - sqlite3PcacheDrop(pPgOld); - } - } - origPgno = pPg.pgno; - sqlite3PcacheMove(pPg, pgno); - sqlite3PcacheMakeDirty(pPg); + ) + { + /* Do not discard pages from an in-memory database since we might + ** need to rollback later. Just move the page out of the way. */ + sqlite3PcacheMove( pPgOld, pPager.dbSize + 1 ); + } + else + { + sqlite3PcacheDrop( pPgOld ); + } + } + origPgno = pPg.pgno; + sqlite3PcacheMove( pPg, pgno ); + sqlite3PcacheMakeDirty( pPg ); - /* For an in-memory database, make sure the original page continues - ** to exist, in case the transaction needs to roll back. Use pPgOld - ** as the original page since it has already been allocated. - */ - if ( + /* For an in-memory database, make sure the original page continues + ** to exist, in case the transaction needs to roll back. Use pPgOld + ** as the original page since it has already been allocated. + */ + if ( #if SQLITE_OMIT_MEMORYDB 0!=MEMDB #else - 0 != pPager.memDb + 0 != pPager.memDb #endif - ) { - Debug.Assert(pPgOld); - sqlite3PcacheMove(pPgOld, origPgno); - sqlite3PagerUnref(pPgOld); - } + ) + { + Debug.Assert( pPgOld ); + sqlite3PcacheMove( pPgOld, origPgno ); + sqlite3PagerUnref( pPgOld ); + } - if (needSyncPgno != 0) { - /* If needSyncPgno is non-zero, then the journal file needs to be - ** sync()ed before any data is written to database file page needSyncPgno. - ** Currently, no such page exists in the page-cache and the - ** "is journaled" bitvec flag has been set. This needs to be remedied by - ** loading the page into the pager-cache and setting the PGHDR_NEED_SYNC - ** flag. - ** - ** If the attempt to load the page into the page-cache fails, (due - ** to a malloc() or IO failure), clear the bit in the pInJournal[] - ** array. Otherwise, if the page is loaded and written again in - ** this transaction, it may be written to the database file before - ** it is synced into the journal file. This way, it may end up in - ** the journal file twice, but that is not a problem. - */ - PgHdr pPgHdr = null; - rc = sqlite3PagerGet(pPager, needSyncPgno, ref pPgHdr); - if (rc != SQLITE_OK) { - if (needSyncPgno <= pPager.dbOrigSize) { - Debug.Assert(pPager.pTmpSpace != null); - u32[] pTemp = new u32[pPager.pTmpSpace.Length]; - sqlite3BitvecClear(pPager.pInJournal, needSyncPgno, pTemp);//pPager.pTmpSpace ); - } - return rc; - } - pPgHdr.flags |= PGHDR_NEED_SYNC; - sqlite3PcacheMakeDirty(pPgHdr); - sqlite3PagerUnref(pPgHdr); - } - return SQLITE_OK; + if ( needSyncPgno != 0 ) + { + /* If needSyncPgno is non-zero, then the journal file needs to be + ** sync()ed before any data is written to database file page needSyncPgno. + ** Currently, no such page exists in the page-cache and the + ** "is journaled" bitvec flag has been set. This needs to be remedied by + ** loading the page into the pager-cache and setting the PGHDR_NEED_SYNC + ** flag. + ** + ** If the attempt to load the page into the page-cache fails, (due + ** to a malloc() or IO failure), clear the bit in the pInJournal[] + ** array. Otherwise, if the page is loaded and written again in + ** this transaction, it may be written to the database file before + ** it is synced into the journal file. This way, it may end up in + ** the journal file twice, but that is not a problem. + */ + PgHdr pPgHdr = null; + rc = sqlite3PagerGet( pPager, needSyncPgno, ref pPgHdr ); + if ( rc != SQLITE_OK ) + { + if ( needSyncPgno <= pPager.dbOrigSize ) + { + Debug.Assert( pPager.pTmpSpace != null ); + u32[] pTemp = new u32[pPager.pTmpSpace.Length]; + sqlite3BitvecClear( pPager.pInJournal, needSyncPgno, pTemp );//pPager.pTmpSpace ); + } + return rc; } + pPgHdr.flags |= PGHDR_NEED_SYNC; + sqlite3PcacheMakeDirty( pPgHdr ); + sqlite3PagerUnref( pPgHdr ); + } + return SQLITE_OK; + } #endif - /* - ** Return a pointer to the data for the specified page. - */ - static byte[] sqlite3PagerGetData(DbPage pPg) { - Debug.Assert(pPg.nRef > 0 || pPg.pPager.memDb != 0); - return pPg.pData; - } + /* +** Return a pointer to the data for the specified page. +*/ + static byte[] sqlite3PagerGetData( DbPage pPg ) + { + Debug.Assert( pPg.nRef > 0 || pPg.pPager.memDb != 0 ); + return pPg.pData; + } - /* - ** Return a pointer to the Pager.nExtra bytes of "extra" space - ** allocated along with the specified page. - */ - static MemPage sqlite3PagerGetExtra(DbPage pPg) { - return pPg.pExtra; - } + /* + ** Return a pointer to the Pager.nExtra bytes of "extra" space + ** allocated along with the specified page. + */ + static MemPage sqlite3PagerGetExtra( DbPage pPg ) + { + return pPg.pExtra; + } - /* - ** Get/set the locking-mode for this pager. Parameter eMode must be one - ** of PAGER_LOCKINGMODE_QUERY, PAGER_LOCKINGMODE_NORMAL or - ** PAGER_LOCKINGMODE_EXCLUSIVE. If the parameter is not _QUERY, then - ** the locking-mode is set to the value specified. - ** - ** The returned value is either PAGER_LOCKINGMODE_NORMAL or - ** PAGER_LOCKINGMODE_EXCLUSIVE, indicating the current (possibly updated) - ** locking-mode. - */ - static bool sqlite3PagerLockingMode(Pager pPager, int eMode) { - Debug.Assert(eMode == PAGER_LOCKINGMODE_QUERY - || eMode == PAGER_LOCKINGMODE_NORMAL - || eMode == PAGER_LOCKINGMODE_EXCLUSIVE); - Debug.Assert(PAGER_LOCKINGMODE_QUERY < 0); - Debug.Assert(PAGER_LOCKINGMODE_NORMAL >= 0 && PAGER_LOCKINGMODE_EXCLUSIVE >= 0); - Debug.Assert(pPager.exclusiveMode || false == sqlite3WalHeapMemory(pPager.pWal)); - if (eMode >= 0 && !pPager.tempFile && !sqlite3WalHeapMemory(pPager.pWal)) { - pPager.exclusiveMode = eMode != 0; - } - return pPager.exclusiveMode; - } + /* + ** Get/set the locking-mode for this pager. Parameter eMode must be one + ** of PAGER_LOCKINGMODE_QUERY, PAGER_LOCKINGMODE_NORMAL or + ** PAGER_LOCKINGMODE_EXCLUSIVE. If the parameter is not _QUERY, then + ** the locking-mode is set to the value specified. + ** + ** The returned value is either PAGER_LOCKINGMODE_NORMAL or + ** PAGER_LOCKINGMODE_EXCLUSIVE, indicating the current (possibly updated) + ** locking-mode. + */ + static bool sqlite3PagerLockingMode( Pager pPager, int eMode ) + { + Debug.Assert( eMode == PAGER_LOCKINGMODE_QUERY + || eMode == PAGER_LOCKINGMODE_NORMAL + || eMode == PAGER_LOCKINGMODE_EXCLUSIVE ); + Debug.Assert( PAGER_LOCKINGMODE_QUERY < 0 ); + Debug.Assert( PAGER_LOCKINGMODE_NORMAL >= 0 && PAGER_LOCKINGMODE_EXCLUSIVE >= 0 ); + Debug.Assert( pPager.exclusiveMode || false == sqlite3WalHeapMemory( pPager.pWal ) ); + if ( eMode >= 0 && !pPager.tempFile && !sqlite3WalHeapMemory( pPager.pWal ) ) + { + pPager.exclusiveMode = eMode != 0; + } + return pPager.exclusiveMode; + } - /* - ** Set the journal-mode for this pager. Parameter eMode must be one of: - ** - ** PAGER_JOURNALMODE_DELETE - ** PAGER_JOURNALMODE_TRUNCATE - ** PAGER_JOURNALMODE_PERSIST - ** PAGER_JOURNALMODE_OFF - ** PAGER_JOURNALMODE_MEMORY - ** PAGER_JOURNALMODE_WAL - ** - ** The journalmode is set to the value specified if the change is allowed. - ** The change may be disallowed for the following reasons: - ** - ** * An in-memory database can only have its journal_mode set to _OFF - ** or _MEMORY. - ** - ** * Temporary databases cannot have _WAL journalmode. - ** - ** The returned indicate the current (possibly updated) journal-mode. - */ - static int sqlite3PagerSetJournalMode(Pager pPager, int eMode) { - u8 eOld = pPager.journalMode; /* Prior journalmode */ + /* + ** Set the journal-mode for this pager. Parameter eMode must be one of: + ** + ** PAGER_JOURNALMODE_DELETE + ** PAGER_JOURNALMODE_TRUNCATE + ** PAGER_JOURNALMODE_PERSIST + ** PAGER_JOURNALMODE_OFF + ** PAGER_JOURNALMODE_MEMORY + ** PAGER_JOURNALMODE_WAL + ** + ** The journalmode is set to the value specified if the change is allowed. + ** The change may be disallowed for the following reasons: + ** + ** * An in-memory database can only have its journal_mode set to _OFF + ** or _MEMORY. + ** + ** * Temporary databases cannot have _WAL journalmode. + ** + ** The returned indicate the current (possibly updated) journal-mode. + */ + static int sqlite3PagerSetJournalMode( Pager pPager, int eMode ) + { + u8 eOld = pPager.journalMode; /* Prior journalmode */ #if SQLITE_DEBUG - /* The print_pager_state() routine is intended to be used by the debugger - ** only. We invoke it once here to suppress a compiler warning. */ - print_pager_state(pPager); + /* The print_pager_state() routine is intended to be used by the debugger +** only. We invoke it once here to suppress a compiler warning. */ + print_pager_state( pPager ); #endif - /* The eMode parameter is always valid */ - Debug.Assert(eMode == PAGER_JOURNALMODE_DELETE - || eMode == PAGER_JOURNALMODE_TRUNCATE - || eMode == PAGER_JOURNALMODE_PERSIST - || eMode == PAGER_JOURNALMODE_OFF - || eMode == PAGER_JOURNALMODE_WAL - || eMode == PAGER_JOURNALMODE_MEMORY); - - /* This routine is only called from the OP_JournalMode opcode, and - ** the logic there will never allow a temporary file to be changed - ** to WAL mode. - */ - Debug.Assert(pPager.tempFile == false || eMode != PAGER_JOURNALMODE_WAL); + /* The eMode parameter is always valid */ + Debug.Assert( eMode == PAGER_JOURNALMODE_DELETE + || eMode == PAGER_JOURNALMODE_TRUNCATE + || eMode == PAGER_JOURNALMODE_PERSIST + || eMode == PAGER_JOURNALMODE_OFF + || eMode == PAGER_JOURNALMODE_WAL + || eMode == PAGER_JOURNALMODE_MEMORY ); + + /* This routine is only called from the OP_JournalMode opcode, and + ** the logic there will never allow a temporary file to be changed + ** to WAL mode. + */ + Debug.Assert( pPager.tempFile == false || eMode != PAGER_JOURNALMODE_WAL ); - /* Do allow the journalmode of an in-memory database to be set to - ** anything other than MEMORY or OFF - */ - if ( + /* Do allow the journalmode of an in-memory database to be set to + ** anything other than MEMORY or OFF + */ + if ( #if SQLITE_OMIT_MEMORYDB 1==MEMDB #else - 1 == pPager.memDb + 1 == pPager.memDb #endif - ) { - Debug.Assert(eOld == PAGER_JOURNALMODE_MEMORY || eOld == PAGER_JOURNALMODE_OFF); - if (eMode != PAGER_JOURNALMODE_MEMORY && eMode != PAGER_JOURNALMODE_OFF) { - eMode = eOld; - } - } + ) + { + Debug.Assert( eOld == PAGER_JOURNALMODE_MEMORY || eOld == PAGER_JOURNALMODE_OFF ); + if ( eMode != PAGER_JOURNALMODE_MEMORY && eMode != PAGER_JOURNALMODE_OFF ) + { + eMode = eOld; + } + } - if (eMode != eOld) { - /* Change the journal mode. */ - Debug.Assert(pPager.eState != PAGER_ERROR); - pPager.journalMode = (u8)eMode; + if ( eMode != eOld ) + { + /* Change the journal mode. */ + Debug.Assert( pPager.eState != PAGER_ERROR ); + pPager.journalMode = (u8)eMode; - /* When transistioning from TRUNCATE or PERSIST to any other journal - ** mode except WAL, unless the pager is in locking_mode=exclusive mode, - ** delete the journal file. - */ - Debug.Assert((PAGER_JOURNALMODE_TRUNCATE & 5) == 1); - Debug.Assert((PAGER_JOURNALMODE_PERSIST & 5) == 1); - Debug.Assert((PAGER_JOURNALMODE_DELETE & 5) == 0); - Debug.Assert((PAGER_JOURNALMODE_MEMORY & 5) == 4); - Debug.Assert((PAGER_JOURNALMODE_OFF & 5) == 0); - Debug.Assert((PAGER_JOURNALMODE_WAL & 5) == 5); - - Debug.Assert(isOpen(pPager.fd) || pPager.exclusiveMode); - if (!pPager.exclusiveMode && (eOld & 5) == 1 && (eMode & 1) == 0) { - - /* In this case we would like to delete the journal file. If it is - ** not possible, then that is not a problem. Deleting the journal file - ** here is an optimization only. - ** - ** Before deleting the journal file, obtain a RESERVED lock on the - ** database file. This ensures that the journal file is not deleted - ** while it is in use by some other client. - */ - sqlite3OsClose(pPager.jfd); - if (pPager.eLock >= RESERVED_LOCK) { - sqlite3OsDelete(pPager.pVfs, pPager.zJournal, 0); - } else { - int rc = SQLITE_OK; - int state = pPager.eState; - Debug.Assert(state == PAGER_OPEN || state == PAGER_READER); - if (state == PAGER_OPEN) { - rc = sqlite3PagerSharedLock(pPager); - } - if (pPager.eState == PAGER_READER) { - Debug.Assert(rc == SQLITE_OK); - rc = pagerLockDb(pPager, RESERVED_LOCK); - } - if (rc == SQLITE_OK) { - sqlite3OsDelete(pPager.pVfs, pPager.zJournal, 0); - } - if (rc == SQLITE_OK && state == PAGER_READER) { - pagerUnlockDb(pPager, SHARED_LOCK); - } else if (state == PAGER_OPEN) { - pager_unlock(pPager); - } - Debug.Assert(state == pPager.eState); - } - } + /* When transistioning from TRUNCATE or PERSIST to any other journal + ** mode except WAL, unless the pager is in locking_mode=exclusive mode, + ** delete the journal file. + */ + Debug.Assert( ( PAGER_JOURNALMODE_TRUNCATE & 5 ) == 1 ); + Debug.Assert( ( PAGER_JOURNALMODE_PERSIST & 5 ) == 1 ); + Debug.Assert( ( PAGER_JOURNALMODE_DELETE & 5 ) == 0 ); + Debug.Assert( ( PAGER_JOURNALMODE_MEMORY & 5 ) == 4 ); + Debug.Assert( ( PAGER_JOURNALMODE_OFF & 5 ) == 0 ); + Debug.Assert( ( PAGER_JOURNALMODE_WAL & 5 ) == 5 ); + + Debug.Assert( isOpen( pPager.fd ) || pPager.exclusiveMode ); + if ( !pPager.exclusiveMode && ( eOld & 5 ) == 1 && ( eMode & 1 ) == 0 ) + { + + /* In this case we would like to delete the journal file. If it is + ** not possible, then that is not a problem. Deleting the journal file + ** here is an optimization only. + ** + ** Before deleting the journal file, obtain a RESERVED lock on the + ** database file. This ensures that the journal file is not deleted + ** while it is in use by some other client. + */ + sqlite3OsClose( pPager.jfd ); + if ( pPager.eLock >= RESERVED_LOCK ) + { + sqlite3OsDelete( pPager.pVfs, pPager.zJournal, 0 ); + } + else + { + int rc = SQLITE_OK; + int state = pPager.eState; + Debug.Assert( state == PAGER_OPEN || state == PAGER_READER ); + if ( state == PAGER_OPEN ) + { + rc = sqlite3PagerSharedLock( pPager ); } - - /* Return the new journal mode */ - return (int)pPager.journalMode; + if ( pPager.eState == PAGER_READER ) + { + Debug.Assert( rc == SQLITE_OK ); + rc = pagerLockDb( pPager, RESERVED_LOCK ); + } + if ( rc == SQLITE_OK ) + { + sqlite3OsDelete( pPager.pVfs, pPager.zJournal, 0 ); + } + if ( rc == SQLITE_OK && state == PAGER_READER ) + { + pagerUnlockDb( pPager, SHARED_LOCK ); + } + else if ( state == PAGER_OPEN ) + { + pager_unlock( pPager ); + } + Debug.Assert( state == pPager.eState ); + } } + } - /* - ** Return the current journal mode. - */ - static int sqlite3PagerGetJournalMode(Pager pPager) { - return (int)pPager.journalMode; - } + /* Return the new journal mode */ + return (int)pPager.journalMode; + } - /* - ** Return TRUE if the pager is in a state where it is OK to change the - ** journalmode. Journalmode changes can only happen when the database - ** is unmodified. - */ - static int sqlite3PagerOkToChangeJournalMode(Pager pPager) { - Debug.Assert(assert_pager_state(pPager)); - if (pPager.eState >= PAGER_WRITER_CACHEMOD) - return 0; - if (NEVER(isOpen(pPager.jfd) && pPager.journalOff > 0)) - return 0; - return 1; - } + /* + ** Return the current journal mode. + */ + static int sqlite3PagerGetJournalMode( Pager pPager ) + { + return (int)pPager.journalMode; + } + /* + ** Return TRUE if the pager is in a state where it is OK to change the + ** journalmode. Journalmode changes can only happen when the database + ** is unmodified. + */ + static int sqlite3PagerOkToChangeJournalMode( Pager pPager ) + { + Debug.Assert( assert_pager_state( pPager ) ); + if ( pPager.eState >= PAGER_WRITER_CACHEMOD ) + return 0; + if ( NEVER( isOpen( pPager.jfd ) && pPager.journalOff > 0 ) ) + return 0; + return 1; + } - /* - ** Get/set the size-limit used for persistent journal files. - ** - ** Setting the size limit to -1 means no limit is enforced. - ** An attempt to set a limit smaller than -1 is a no-op. - */ - static i64 sqlite3PagerJournalSizeLimit(Pager pPager, i64 iLimit) { - if (iLimit >= -1) { - pPager.journalSizeLimit = iLimit; - sqlite3WalLimit(pPager.pWal, iLimit); - } - return pPager.journalSizeLimit; - } - /* - ** Return a pointer to the pPager.pBackup variable. The backup module - ** in backup.c maintains the content of this variable. This module - ** uses it opaquely as an argument to sqlite3BackupRestart() and - ** sqlite3BackupUpdate() only. - */ - static sqlite3_backup sqlite3PagerBackupPtr(Pager pPager) { - return pPager.pBackup; - } + /* + ** Get/set the size-limit used for persistent journal files. + ** + ** Setting the size limit to -1 means no limit is enforced. + ** An attempt to set a limit smaller than -1 is a no-op. + */ + static i64 sqlite3PagerJournalSizeLimit( Pager pPager, i64 iLimit ) + { + if ( iLimit >= -1 ) + { + pPager.journalSizeLimit = iLimit; + sqlite3WalLimit( pPager.pWal, iLimit ); + } + return pPager.journalSizeLimit; + } + + /* + ** Return a pointer to the pPager.pBackup variable. The backup module + ** in backup.c maintains the content of this variable. This module + ** uses it opaquely as an argument to sqlite3BackupRestart() and + ** sqlite3BackupUpdate() only. + */ + static sqlite3_backup sqlite3PagerBackupPtr( Pager pPager ) + { + return pPager.pBackup; + } #if !SQLITE_OMIT_WAL /* @@ -7300,5 +7831,5 @@ void sqlite3PagerCodec(PgHdr *pPg){ #endif //* !SQLITE_OMIT_WAL */ #endif // * SQLITE_OMIT_DISKIO */ - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/pager_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/pager_h.cs index a488d730b..be85989a9 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/pager_h.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/pager_h.cs @@ -1,205 +1,208 @@ using Pgno = System.UInt32; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 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. - ** - ************************************************************************* - ** This header file defines the interface that the sqlite page cache - ** subsystem. The page cache subsystem reads and writes a file a page - ** at a time and provides a journal for rollback. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ - //#if !_PAGER_H_ - //#define _PAGER_H_ - - /* - ** Default maximum size for persistent journal files. A negative - ** value means no limit. This value may be overridden using the - ** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit". - */ +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 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. + ** + ************************************************************************* + ** This header file defines the interface that the sqlite page cache + ** subsystem. The page cache subsystem reads and writes a file a page + ** at a time and provides a journal for rollback. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ + //#if !_PAGER_H_ + //#define _PAGER_H_ + + /* + ** Default maximum size for persistent journal files. A negative + ** value means no limit. This value may be overridden using the + ** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit". + */ #if !SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT - const int SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT = -1;//#define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT -1 + const int SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT = -1;//#define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT -1 #endif - /* - ** The type used to represent a page number. The first page in a file - ** is called page 1. 0 is used to represent "not a page". + /* +** The type used to represent a page number. The first page in a file +** is called page 1. 0 is used to represent "not a page". +*/ + //typedef u32 Pgno; + + /* + ** Each open file is managed by a separate instance of the "Pager" structure. + */ + //typedef struct Pager Pager; + + /* + ** Handle type for pages. */ - //typedef u32 Pgno; - - /* - ** Each open file is managed by a separate instance of the "Pager" structure. - */ - //typedef struct Pager Pager; - - /* - ** Handle type for pages. - */ - //typedef struct PgHdr DbPage; - - /* - ** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is - ** reserved for working around a windows/posix incompatibility). It is - ** used in the journal to signify that the remainder of the journal file - ** is devoted to storing a master journal name - there are no more pages to - ** roll back. See comments for function writeMasterJournal() in pager.c - ** for details. - */ - //#define PAGER_MJ_PGNO(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1)) - static Pgno PAGER_MJ_PGNO(Pager x) { - return ((Pgno)((PENDING_BYTE / ((x).pageSize)) + 1)); - } - /* - ** Allowed values for the flags parameter to sqlite3PagerOpen(). - ** - ** NOTE: These values must match the corresponding BTREE_ values in btree.h. - */ - //#define PAGER_OMIT_JOURNAL 0x0001 /* Do not use a rollback journal */ - //#define PAGER_NO_READLOCK 0x0002 /* Omit readlocks on readonly files */ - //#define PAGER_MEMORY 0x0004 /* In-memory database */ - const int PAGER_OMIT_JOURNAL = 0x0001; - const int PAGER_NO_READLOCK = 0x0002; - const int PAGER_MEMORY = 0x0004; - - /* - ** Valid values for the second argument to sqlite3PagerLockingMode(). - */ - //#define PAGER_LOCKINGMODE_QUERY -1 - //#define PAGER_LOCKINGMODE_NORMAL 0 - //#define PAGER_LOCKINGMODE_EXCLUSIVE 1 - static int PAGER_LOCKINGMODE_QUERY = -1; - static int PAGER_LOCKINGMODE_NORMAL = 0; - static int PAGER_LOCKINGMODE_EXCLUSIVE = 1; - - /* - ** Numeric constants that encode the journalmode. - */ - //#define PAGER_JOURNALMODE_QUERY (-1) /* Query the value of journalmode */ - //#define PAGER_JOURNALMODE_DELETE 0 /* Commit by deleting journal file */ - //#define PAGER_JOURNALMODE_PERSIST 1 /* Commit by zeroing journal header */ - //#define PAGER_JOURNALMODE_OFF 2 /* Journal omitted. */ - //#define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */ - //#define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */ - //#define PAGER_JOURNALMODE_WAL 5 /* Use write-ahead logging */ - const int PAGER_JOURNALMODE_QUERY = -1; - const int PAGER_JOURNALMODE_DELETE = 0; - const int PAGER_JOURNALMODE_PERSIST = 1; - const int PAGER_JOURNALMODE_OFF = 2; - const int PAGER_JOURNALMODE_TRUNCATE = 3; - const int PAGER_JOURNALMODE_MEMORY = 4; - const int PAGER_JOURNALMODE_WAL = 5; - - /* - ** The remainder of this file contains the declarations of the functions - ** that make up the Pager sub-system API. See source code comments for - ** a detailed description of each routine. - */ - /* Open and close a Pager connection. */ - //int sqlite3PagerOpen( - // sqlite3_vfs*, - // Pager **ppPager, - // const char*, - // int, - // int, - // int, - //// void()(DbPage) - //); - //int sqlite3PagerClose(Pager *pPager); - //int sqlite3PagerReadFileheader(Pager*, int, unsigned char); - - /* Functions used to configure a Pager object. */ - //void sqlite3PagerSetBusyhandler(Pager*, int()(void ), object ); - //int sqlite3PagerSetPagesize(Pager*, u32*, int); - //int sqlite3PagerMaxPageCount(Pager*, int); - //void sqlite3PagerSetCachesize(Pager*, int); - //void sqlite3PagerSetSafetyLevel(Pager*,int,int,int); - //int sqlite3PagerLockingMode(Pager *, int); - //int sqlite3PagerSetJournalMode(Pager *, int); - //int sqlite3PagerGetJournalMode(Pager); - //int sqlite3PagerOkToChangeJournalMode(Pager); - //i64 sqlite3PagerJournalSizeLimit(Pager *, i64); - //sqlite3_backup **sqlite3PagerBackupPtr(Pager); - - /* Functions used to obtain and release page references. */ - //int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag); - //#define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0) - //DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno); - //void sqlite3PagerRef(DbPage); - //void sqlite3PagerUnref(DbPage); - - /* Operations on page references. */ - //int sqlite3PagerWrite(DbPage); - //void sqlite3PagerDontWrite(DbPage); - //int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int); - //int sqlite3PagerPageRefcount(DbPage); - //void *sqlite3PagerGetData(DbPage ); - //void *sqlite3PagerGetExtra(DbPage ); - - /* Functions used to manage pager transactions and savepoints. */ - //void sqlite3PagerPagecount(Pager*, int); - //int sqlite3PagerBegin(Pager*, int exFlag, int); - //int sqlite3PagerCommitPhaseOne(Pager*,string zMaster, int); - //int sqlite3PagerExclusiveLock(Pager); - //int sqlite3PagerSync(Pager *pPager); - //int sqlite3PagerCommitPhaseTwo(Pager); - //int sqlite3PagerRollback(Pager); - //int sqlite3PagerOpenSavepoint(Pager *pPager, int n); - //int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint); - //int sqlite3PagerSharedLock(Pager *pPager); - - //int sqlite3PagerCheckpoint(Pager *pPager, int, int*, int); - //int sqlite3PagerWalSupported(Pager* pPager); - //int sqlite3PagerWalCallback(Pager* pPager); - //int sqlite3PagerOpenWal(Pager* pPager, int* pisOpen); - //int sqlite3PagerCloseWal(Pager* pPager); - - /* Functions used to query pager state and configuration. */ - //u8 sqlite3PagerIsreadonly(Pager); - //int sqlite3PagerRefcount(Pager); - //int sqlite3PagerMemUsed(Pager); - //string sqlite3PagerFilename(Pager); - //const sqlite3_vfs *sqlite3PagerVfs(Pager); - //sqlite3_file *sqlite3PagerFile(Pager); - //string sqlite3PagerJournalname(Pager); - //int sqlite3PagerNosync(Pager); - //void *sqlite3PagerTempSpace(Pager); - //int sqlite3PagerIsMemdb(Pager); - - /* Functions used to truncate the database file. */ - //void sqlite3PagerTruncateImage(Pager*,Pgno); - - //#if (SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL) - //void *sqlite3PagerCodec(DbPage ); - //#endif - - /* Functions to support testing and debugging. */ - //#if !NDEBUG || SQLITE_TEST - // Pgno sqlite3PagerPagenumber(DbPage); - // int sqlite3PagerIswriteable(DbPage); - //#endif - //#if SQLITE_TEST - // int *sqlite3PagerStats(Pager); - // void sqlite3PagerRefdump(Pager); - // void disable_simulated_io_errors(void); - // void enable_simulated_io_errors(void); - //#else - //# define disable_simulated_io_errors() - //# define enable_simulated_io_errors() - //#endif + //typedef struct PgHdr DbPage; + + /* + ** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is + ** reserved for working around a windows/posix incompatibility). It is + ** used in the journal to signify that the remainder of the journal file + ** is devoted to storing a master journal name - there are no more pages to + ** roll back. See comments for function writeMasterJournal() in pager.c + ** for details. + */ + //#define PAGER_MJ_PGNO(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1)) + static Pgno PAGER_MJ_PGNO( Pager x ) + { + return ( (Pgno)( ( PENDING_BYTE / ( ( x ).pageSize ) ) + 1 ) ); } + /* + ** Allowed values for the flags parameter to sqlite3PagerOpen(). + ** + ** NOTE: These values must match the corresponding BTREE_ values in btree.h. + */ + //#define PAGER_OMIT_JOURNAL 0x0001 /* Do not use a rollback journal */ + //#define PAGER_NO_READLOCK 0x0002 /* Omit readlocks on readonly files */ + //#define PAGER_MEMORY 0x0004 /* In-memory database */ + const int PAGER_OMIT_JOURNAL = 0x0001; + const int PAGER_NO_READLOCK = 0x0002; + const int PAGER_MEMORY = 0x0004; + + /* + ** Valid values for the second argument to sqlite3PagerLockingMode(). + */ + //#define PAGER_LOCKINGMODE_QUERY -1 + //#define PAGER_LOCKINGMODE_NORMAL 0 + //#define PAGER_LOCKINGMODE_EXCLUSIVE 1 + static int PAGER_LOCKINGMODE_QUERY = -1; + static int PAGER_LOCKINGMODE_NORMAL = 0; + static int PAGER_LOCKINGMODE_EXCLUSIVE = 1; + + /* + ** Numeric constants that encode the journalmode. + */ + //#define PAGER_JOURNALMODE_QUERY (-1) /* Query the value of journalmode */ + //#define PAGER_JOURNALMODE_DELETE 0 /* Commit by deleting journal file */ + //#define PAGER_JOURNALMODE_PERSIST 1 /* Commit by zeroing journal header */ + //#define PAGER_JOURNALMODE_OFF 2 /* Journal omitted. */ + //#define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */ + //#define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */ + //#define PAGER_JOURNALMODE_WAL 5 /* Use write-ahead logging */ + const int PAGER_JOURNALMODE_QUERY = -1; + const int PAGER_JOURNALMODE_DELETE = 0; + const int PAGER_JOURNALMODE_PERSIST = 1; + const int PAGER_JOURNALMODE_OFF = 2; + const int PAGER_JOURNALMODE_TRUNCATE = 3; + const int PAGER_JOURNALMODE_MEMORY = 4; + const int PAGER_JOURNALMODE_WAL = 5; + + /* + ** The remainder of this file contains the declarations of the functions + ** that make up the Pager sub-system API. See source code comments for + ** a detailed description of each routine. + */ + /* Open and close a Pager connection. */ + //int sqlite3PagerOpen( + // sqlite3_vfs*, + // Pager **ppPager, + // const char*, + // int, + // int, + // int, + //// void()(DbPage) + //); + //int sqlite3PagerClose(Pager *pPager); + //int sqlite3PagerReadFileheader(Pager*, int, unsigned char); + + /* Functions used to configure a Pager object. */ + //void sqlite3PagerSetBusyhandler(Pager*, int()(void ), object ); + //int sqlite3PagerSetPagesize(Pager*, u32*, int); + //int sqlite3PagerMaxPageCount(Pager*, int); + //void sqlite3PagerSetCachesize(Pager*, int); + //void sqlite3PagerSetSafetyLevel(Pager*,int,int,int); + //int sqlite3PagerLockingMode(Pager *, int); + //int sqlite3PagerSetJournalMode(Pager *, int); + //int sqlite3PagerGetJournalMode(Pager); + //int sqlite3PagerOkToChangeJournalMode(Pager); + //i64 sqlite3PagerJournalSizeLimit(Pager *, i64); + //sqlite3_backup **sqlite3PagerBackupPtr(Pager); + + /* Functions used to obtain and release page references. */ + //int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag); + //#define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0) + //DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno); + //void sqlite3PagerRef(DbPage); + //void sqlite3PagerUnref(DbPage); + + /* Operations on page references. */ + //int sqlite3PagerWrite(DbPage); + //void sqlite3PagerDontWrite(DbPage); + //int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int); + //int sqlite3PagerPageRefcount(DbPage); + //void *sqlite3PagerGetData(DbPage ); + //void *sqlite3PagerGetExtra(DbPage ); + + /* Functions used to manage pager transactions and savepoints. */ + //void sqlite3PagerPagecount(Pager*, int); + //int sqlite3PagerBegin(Pager*, int exFlag, int); + //int sqlite3PagerCommitPhaseOne(Pager*,string zMaster, int); + //int sqlite3PagerExclusiveLock(Pager); + //int sqlite3PagerSync(Pager *pPager); + //int sqlite3PagerCommitPhaseTwo(Pager); + //int sqlite3PagerRollback(Pager); + //int sqlite3PagerOpenSavepoint(Pager *pPager, int n); + //int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint); + //int sqlite3PagerSharedLock(Pager *pPager); + + //int sqlite3PagerCheckpoint(Pager *pPager, int, int*, int); + //int sqlite3PagerWalSupported(Pager* pPager); + //int sqlite3PagerWalCallback(Pager* pPager); + //int sqlite3PagerOpenWal(Pager* pPager, int* pisOpen); + //int sqlite3PagerCloseWal(Pager* pPager); + + /* Functions used to query pager state and configuration. */ + //u8 sqlite3PagerIsreadonly(Pager); + //int sqlite3PagerRefcount(Pager); + //int sqlite3PagerMemUsed(Pager); + //string sqlite3PagerFilename(Pager); + //const sqlite3_vfs *sqlite3PagerVfs(Pager); + //sqlite3_file *sqlite3PagerFile(Pager); + //string sqlite3PagerJournalname(Pager); + //int sqlite3PagerNosync(Pager); + //void *sqlite3PagerTempSpace(Pager); + //int sqlite3PagerIsMemdb(Pager); + + /* Functions used to truncate the database file. */ + //void sqlite3PagerTruncateImage(Pager*,Pgno); + + //#if (SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL) + //void *sqlite3PagerCodec(DbPage ); + //#endif + + /* Functions to support testing and debugging. */ + //#if !NDEBUG || SQLITE_TEST + // Pgno sqlite3PagerPagenumber(DbPage); + // int sqlite3PagerIswriteable(DbPage); + //#endif + //#if SQLITE_TEST + // int *sqlite3PagerStats(Pager); + // void sqlite3PagerRefdump(Pager); + // void disable_simulated_io_errors(void); + // void enable_simulated_io_errors(void); + //#else + //# define disable_simulated_io_errors() + //# define enable_simulated_io_errors() + //#endif + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/parse_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/parse_c.cs index 7addf10fa..6875b2568 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/parse_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/parse_c.cs @@ -1,329 +1,349 @@ +using System; using System.Diagnostics; using System.IO; +using System.Text; using u8 = System.Byte; -using YYACTIONTYPE = System.Int32; + + using YYCODETYPE = System.Int32; +using YYACTIONTYPE = System.Int32; -namespace Community.CsharpSqlite { - using sqlite3ParserTOKENTYPE = Sqlite3.Token; +namespace Community.CsharpSqlite +{ + using sqlite3ParserTOKENTYPE = Sqlite3.Token; - public partial class Sqlite3 { - /* - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ + public partial class Sqlite3 + { + /* + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ - /* Driver template for the LEMON parser generator. - ** The author disclaims copyright to this source code. - ** - ** This version of "lempar.c" is modified, slightly, for use by SQLite. - ** The only modifications are the addition of a couple of NEVER() - ** macros to disable tests that are needed in the case of a general - ** LALR(1) grammar but which are always false in the - ** specific grammar used by SQLite. - */ - /* First off, code is included that follows the "include" declaration - ** in the input grammar file. */ - //#include - //#line 51 "parse.y" + /* Driver template for the LEMON parser generator. + ** The author disclaims copyright to this source code. + ** + ** This version of "lempar.c" is modified, slightly, for use by SQLite. + ** The only modifications are the addition of a couple of NEVER() + ** macros to disable tests that are needed in the case of a general + ** LALR(1) grammar but which are always false in the + ** specific grammar used by SQLite. + */ + /* First off, code is included that follows the "include" declaration + ** in the input grammar file. */ + //#include + //#line 51 "parse.y" - //#include "sqliteInt.h" - /* - ** Disable all error recovery processing in the parser push-down - ** automaton. - */ - //#define YYNOERRORRECOVERY 1 - const int YYNOERRORRECOVERY = 1; + //#include "sqliteInt.h" + /* + ** Disable all error recovery processing in the parser push-down + ** automaton. + */ + //#define YYNOERRORRECOVERY 1 + const int YYNOERRORRECOVERY = 1; - /* - ** Make yytestcase() the same as testcase() - */ - //#define yytestcase(X) testcase(X) - static void yytestcase(T X) { - testcase(X); - } + /* + ** Make yytestcase() the same as testcase() + */ + //#define yytestcase(X) testcase(X) + static void yytestcase( T X ) + { + testcase( X ); + } - /* - ** An instance of this structure holds information about the - ** LIMIT clause of a SELECT statement. - */ - public struct LimitVal { - public Expr pLimit; /* The LIMIT expression. NULL if there is no limit */ - public Expr pOffset; /* The OFFSET expression. NULL if there is none */ - }; + /* + ** An instance of this structure holds information about the + ** LIMIT clause of a SELECT statement. + */ + public struct LimitVal + { + public Expr pLimit; /* The LIMIT expression. NULL if there is no limit */ + public Expr pOffset; /* The OFFSET expression. NULL if there is none */ + }; - /* - ** An instance of this structure is used to store the LIKE, - ** GLOB, NOT LIKE, and NOT GLOB operators. - */ - public struct LikeOp { - public Token eOperator; /* "like" or "glob" or "regexp" */ - public bool not; /* True if the NOT keyword is present */ - }; + /* + ** An instance of this structure is used to store the LIKE, + ** GLOB, NOT LIKE, and NOT GLOB operators. + */ + public struct LikeOp + { + public Token eOperator; /* "like" or "glob" or "regexp" */ + public bool not; /* True if the NOT keyword is present */ + }; - /* - ** An instance of the following structure describes the event of a - ** TRIGGER. "a" is the event type, one of TK_UPDATE, TK_INSERT, - ** TK_DELETE, or TK_INSTEAD. If the event is of the form - ** - ** UPDATE ON (a,b,c) - ** - ** Then the "b" IdList records the list "a,b,c". - */ - public struct TrigEvent { - public int a; - public IdList b; - }; - /* - ** An instance of this structure holds the ATTACH key and the key type. - */ - public struct AttachKey { - public int type; - public Token key; - }; + /* + ** An instance of the following structure describes the event of a + ** TRIGGER. "a" is the event type, one of TK_UPDATE, TK_INSERT, + ** TK_DELETE, or TK_INSTEAD. If the event is of the form + ** + ** UPDATE ON (a,b,c) + ** + ** Then the "b" IdList records the list "a,b,c". + */ + public struct TrigEvent + { + public int a; + public IdList b; + }; + /* + ** An instance of this structure holds the ATTACH key and the key type. + */ + public struct AttachKey + { + public int type; + public Token key; + }; - //#line 722 "parse.y" + //#line 722 "parse.y" - /* This is a utility routine used to set the ExprSpan.zStart and - ** ExprSpan.zEnd values of pOut so that the span covers the complete - ** range of text beginning with pStart and going to the end of pEnd. - */ - static void spanSet(ExprSpan pOut, Token pStart, Token pEnd) { - pOut.zStart = pStart.z; - pOut.zEnd = pEnd.z.Substring(pEnd.n); - } + /* This is a utility routine used to set the ExprSpan.zStart and + ** ExprSpan.zEnd values of pOut so that the span covers the complete + ** range of text beginning with pStart and going to the end of pEnd. + */ + static void spanSet( ExprSpan pOut, Token pStart, Token pEnd ) + { + pOut.zStart = pStart.z; + pOut.zEnd = pEnd.z.Substring( pEnd.n ); + } - /* Construct a new Expr object from a single identifier. Use the - ** new Expr to populate pOut. Set the span of pOut to be the identifier - ** that created the expression. - */ - static void spanExpr(ExprSpan pOut, Parse pParse, int op, Token pValue) { - pOut.pExpr = sqlite3PExpr(pParse, op, 0, 0, pValue); - pOut.zStart = pValue.z; - pOut.zEnd = pValue.z.Substring(pValue.n); - } - //#line 817 "parse.y" + /* Construct a new Expr object from a single identifier. Use the + ** new Expr to populate pOut. Set the span of pOut to be the identifier + ** that created the expression. + */ + static void spanExpr( ExprSpan pOut, Parse pParse, int op, Token pValue ) + { + pOut.pExpr = sqlite3PExpr( pParse, op, 0, 0, pValue ); + pOut.zStart = pValue.z; + pOut.zEnd = pValue.z.Substring( pValue.n ); + } + //#line 817 "parse.y" - /* This routine constructs a binary expression node out of two ExprSpan - ** objects and uses the result to populate a new ExprSpan object. - */ - static void spanBinaryExpr( - ExprSpan pOut, /* Write the result here */ - Parse pParse, /* The parsing context. Errors accumulate here */ - int op, /* The binary operation */ - ExprSpan pLeft, /* The left operand */ - ExprSpan pRight /* The right operand */ - ) { - pOut.pExpr = sqlite3PExpr(pParse, op, pLeft.pExpr, pRight.pExpr, 0); - pOut.zStart = pLeft.zStart; - pOut.zEnd = pRight.zEnd; - } - //#line 873 "parse.y" + /* This routine constructs a binary expression node out of two ExprSpan + ** objects and uses the result to populate a new ExprSpan object. + */ + static void spanBinaryExpr( + ExprSpan pOut, /* Write the result here */ + Parse pParse, /* The parsing context. Errors accumulate here */ + int op, /* The binary operation */ + ExprSpan pLeft, /* The left operand */ + ExprSpan pRight /* The right operand */ + ) + { + pOut.pExpr = sqlite3PExpr( pParse, op, pLeft.pExpr, pRight.pExpr, 0 ); + pOut.zStart = pLeft.zStart; + pOut.zEnd = pRight.zEnd; + } + //#line 873 "parse.y" - /* Construct an expression node for a unary postfix operator - */ - static void spanUnaryPostfix( - ExprSpan pOut, /* Write the new expression node here */ - Parse pParse, /* Parsing context to record errors */ - int op, /* The operator */ - ExprSpan pOperand, /* The operand */ - Token pPostOp /* The operand token for setting the span */ - ) { - pOut.pExpr = sqlite3PExpr(pParse, op, pOperand.pExpr, 0, 0); - pOut.zStart = pOperand.zStart; - pOut.zEnd = pPostOp.z.Substring(pPostOp.n); - } - //#line 892 "parse.y" + /* Construct an expression node for a unary postfix operator + */ + static void spanUnaryPostfix( + ExprSpan pOut, /* Write the new expression node here */ + Parse pParse, /* Parsing context to record errors */ + int op, /* The operator */ + ExprSpan pOperand, /* The operand */ + Token pPostOp /* The operand token for setting the span */ + ) + { + pOut.pExpr = sqlite3PExpr( pParse, op, pOperand.pExpr, 0, 0 ); + pOut.zStart = pOperand.zStart; + pOut.zEnd = pPostOp.z.Substring( pPostOp.n ); + } + //#line 892 "parse.y" - /* A routine to convert a binary TK_IS or TK_ISNOT expression into a - ** unary TK_ISNULL or TK_NOTNULL expression. */ - static void binaryToUnaryIfNull(Parse pParse, Expr pY, Expr pA, int op) { - sqlite3 db = pParse.db; - if ( /*db.mallocFailed == null && */pY.op == TK_NULL) { - pA.op = (u8)op; - sqlite3ExprDelete(db, ref pA.pRight); - pA.pRight = null; - } - } - //#line 920 "parse.y" + /* A routine to convert a binary TK_IS or TK_ISNOT expression into a + ** unary TK_ISNULL or TK_NOTNULL expression. */ + static void binaryToUnaryIfNull( Parse pParse, Expr pY, Expr pA, int op ) + { + sqlite3 db = pParse.db; + if ( /*db.mallocFailed == null && */pY.op == TK_NULL ) + { + pA.op = (u8)op; + sqlite3ExprDelete( db, ref pA.pRight ); + pA.pRight = null; + } + } + //#line 920 "parse.y" - /* Construct an expression node for a unary prefix operator - */ - static void spanUnaryPrefix( - ExprSpan pOut, /* Write the new expression node here */ - Parse pParse, /* Parsing context to record errors */ - int op, /* The operator */ - ExprSpan pOperand, /* The operand */ - Token pPreOp /* The operand token for setting the span */ - ) { - pOut.pExpr = sqlite3PExpr(pParse, op, pOperand.pExpr, 0, 0); - pOut.zStart = pPreOp.z; - pOut.zEnd = pOperand.zEnd; - } - //#line 141 "parse.c" - /* Next is all token values, in a form suitable for use by makeheaders. - ** This section will be null unless lemon is run with the -m switch. - */ - /* - ** These constants (all generated automatically by the parser generator) - ** specify the various kinds of tokens (terminals) that the parser - ** understands. - ** - ** Each symbol here is a terminal symbol in the grammar. - */ - /* Make sure the INTERFACE macro is defined. - */ + /* Construct an expression node for a unary prefix operator + */ + static void spanUnaryPrefix( + ExprSpan pOut, /* Write the new expression node here */ + Parse pParse, /* Parsing context to record errors */ + int op, /* The operator */ + ExprSpan pOperand, /* The operand */ + Token pPreOp /* The operand token for setting the span */ + ) + { + pOut.pExpr = sqlite3PExpr( pParse, op, pOperand.pExpr, 0, 0 ); + pOut.zStart = pPreOp.z; + pOut.zEnd = pOperand.zEnd; + } + //#line 141 "parse.c" + /* Next is all token values, in a form suitable for use by makeheaders. + ** This section will be null unless lemon is run with the -m switch. + */ + /* + ** These constants (all generated automatically by the parser generator) + ** specify the various kinds of tokens (terminals) that the parser + ** understands. + ** + ** Each symbol here is a terminal symbol in the grammar. + */ + /* Make sure the INTERFACE macro is defined. + */ #if !INTERFACE - //# define INTERFACE 1 + //# define INTERFACE 1 #endif - /* The next thing included is series of defines which control - ** various aspects of the generated parser. - ** YYCODETYPE is the data type used for storing terminal - ** and nonterminal numbers. "unsigned char" is - ** used if there are fewer than 250 terminals - ** and nonterminals. "int" is used otherwise. - ** YYNOCODE is a number of type YYCODETYPE which corresponds - ** to no legal terminal or nonterminal number. This - ** number is used to fill in empty slots of the hash - ** table. - ** YYFALLBACK If defined, this indicates that one or more tokens - ** have fall-back values which should be used if the - ** original value of the token will not parse. - ** YYACTIONTYPE is the data type used for storing terminal - ** and nonterminal numbers. "unsigned char" is - ** used if there are fewer than 250 rules and - ** states combined. "int" is used otherwise. - ** sqlite3ParserTOKENTYPE is the data type used for minor tokens given - ** directly to the parser from the tokenizer. - ** YYMINORTYPE is the data type used for all minor tokens. - ** This is typically a union of many types, one of - ** which is sqlite3ParserTOKENTYPE. The entry in the union - ** for base tokens is called "yy0". - ** YYSTACKDEPTH is the maximum depth of the parser's stack. If - ** zero the stack is dynamically sized using realloc() - ** sqlite3ParserARG_SDECL A static variable declaration for the %extra_argument - ** sqlite3ParserARG_PDECL A parameter declaration for the %extra_argument - ** sqlite3ParserARG_STORE Code to store %extra_argument into yypParser - ** sqlite3ParserARG_FETCH Code to extract %extra_argument from yypParser - ** YYNSTATE the combined number of states. - ** YYNRULE the number of rules in the grammar - ** YYERRORSYMBOL is the code number of the error symbol. If not - ** defined, then do no error processing. - */ - //#define YYCODETYPE unsigned short char - const int YYNOCODE = 253; - //#define YYACTIONTYPE unsigned short int - const int YYWILDCARD = 67; - //#define sqlite3ParserTOKENTYPE Token - public class YYMINORTYPE { - public int yyinit; - public sqlite3ParserTOKENTYPE yy0 = new sqlite3ParserTOKENTYPE(); - public int yy4; - public TrigEvent yy90; - public ExprSpan yy118 = new ExprSpan(); - public TriggerStep yy203; - public u8 yy210; - public struct _yy215 { - public int value; - public int mask; - } - public _yy215 yy215; - public SrcList yy259; - public LimitVal yy292; - public Expr yy314; - public ExprList yy322; - public LikeOp yy342; - public IdList yy384; - public Select yy387; - } + /* The next thing included is series of defines which control +** various aspects of the generated parser. +** YYCODETYPE is the data type used for storing terminal +** and nonterminal numbers. "unsigned char" is +** used if there are fewer than 250 terminals +** and nonterminals. "int" is used otherwise. +** YYNOCODE is a number of type YYCODETYPE which corresponds +** to no legal terminal or nonterminal number. This +** number is used to fill in empty slots of the hash +** table. +** YYFALLBACK If defined, this indicates that one or more tokens +** have fall-back values which should be used if the +** original value of the token will not parse. +** YYACTIONTYPE is the data type used for storing terminal +** and nonterminal numbers. "unsigned char" is +** used if there are fewer than 250 rules and +** states combined. "int" is used otherwise. +** sqlite3ParserTOKENTYPE is the data type used for minor tokens given +** directly to the parser from the tokenizer. +** YYMINORTYPE is the data type used for all minor tokens. +** This is typically a union of many types, one of +** which is sqlite3ParserTOKENTYPE. The entry in the union +** for base tokens is called "yy0". +** YYSTACKDEPTH is the maximum depth of the parser's stack. If +** zero the stack is dynamically sized using realloc() +** sqlite3ParserARG_SDECL A static variable declaration for the %extra_argument +** sqlite3ParserARG_PDECL A parameter declaration for the %extra_argument +** sqlite3ParserARG_STORE Code to store %extra_argument into yypParser +** sqlite3ParserARG_FETCH Code to extract %extra_argument from yypParser +** YYNSTATE the combined number of states. +** YYNRULE the number of rules in the grammar +** YYERRORSYMBOL is the code number of the error symbol. If not +** defined, then do no error processing. +*/ + //#define YYCODETYPE unsigned short char + const int YYNOCODE = 253; + //#define YYACTIONTYPE unsigned short int + const int YYWILDCARD = 67; + //#define sqlite3ParserTOKENTYPE Token + public class YYMINORTYPE + { + public int yyinit; + public sqlite3ParserTOKENTYPE yy0 = new sqlite3ParserTOKENTYPE(); + public int yy4; + public TrigEvent yy90; + public ExprSpan yy118 = new ExprSpan(); + public TriggerStep yy203; + public u8 yy210; + public struct _yy215 + { + public int value; + public int mask; + } + public _yy215 yy215; + public SrcList yy259; + public LimitVal yy292; + public Expr yy314; + public ExprList yy322; + public LikeOp yy342; + public IdList yy384; + public Select yy387; + } #if !YYSTACKDEPTH - const int YYSTACKDEPTH = 100; + const int YYSTACKDEPTH = 100; #endif - //#define sqlite3ParserARG_SDECL Parse pParse; - //#define sqlite3ParserARG_PDECL ,Parse pParse - //#define sqlite3ParserARG_FETCH Parse pParse = yypParser.pParse - //#define sqlite3ParserARG_STORE yypParser.pParse = pParse - const int YYNSTATE = 630; - const int YYNRULE = 329; - //#define YYFALLBACK 1 - const int YYFALLBACK = 1; - const int YY_NO_ACTION = (YYNSTATE + YYNRULE + 2); - const int YY_ACCEPT_ACTION = (YYNSTATE + YYNRULE + 1); - const int YY_ERROR_ACTION = (YYNSTATE + YYNRULE); + //#define sqlite3ParserARG_SDECL Parse pParse; + //#define sqlite3ParserARG_PDECL ,Parse pParse + //#define sqlite3ParserARG_FETCH Parse pParse = yypParser.pParse + //#define sqlite3ParserARG_STORE yypParser.pParse = pParse + const int YYNSTATE = 630; + const int YYNRULE = 329; + //#define YYFALLBACK 1 + const int YYFALLBACK = 1; + const int YY_NO_ACTION = ( YYNSTATE + YYNRULE + 2 ); + const int YY_ACCEPT_ACTION = ( YYNSTATE + YYNRULE + 1 ); + const int YY_ERROR_ACTION = ( YYNSTATE + YYNRULE ); - /* The yyzerominor constant is used to initialize instances of - ** YYMINORTYPE objects to zero. */ - YYMINORTYPE yyzerominor = new YYMINORTYPE();//static const YYMINORTYPE yyzerominor = { 0 }; + /* The yyzerominor constant is used to initialize instances of + ** YYMINORTYPE objects to zero. */ + YYMINORTYPE yyzerominor = new YYMINORTYPE();//static const YYMINORTYPE yyzerominor = { 0 }; - /* Define the yytestcase() macro to be a no-op if is not already defined - ** otherwise. - ** - ** Applications can choose to define yytestcase() in the %include section - ** to a macro that can assist in verifying code coverage. For production - ** code the yytestcase() macro should be turned off. But it is useful - ** for testing. - */ - //#if !yytestcase - //# define yytestcase(X) - //#endif + /* Define the yytestcase() macro to be a no-op if is not already defined + ** otherwise. + ** + ** Applications can choose to define yytestcase() in the %include section + ** to a macro that can assist in verifying code coverage. For production + ** code the yytestcase() macro should be turned off. But it is useful + ** for testing. + */ + //#if !yytestcase + //# define yytestcase(X) + //#endif - /* Next are the tables used to determine what action to take based on the - ** current state and lookahead token. These tables are used to implement - ** functions that take a state number and lookahead value and return an - ** action integer. - ** - ** Suppose the action integer is N. Then the action is determined as - ** follows - ** - ** 0 <= N < YYNSTATE Shift N. That is, push the lookahead - ** token onto the stack and goto state N. - ** - ** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE. - ** - ** N == YYNSTATE+YYNRULE A syntax error has occurred. - ** - ** N == YYNSTATE+YYNRULE+1 The parser accepts its input. - ** - ** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused - ** slots in the yy_action[] table. - ** - ** The action table is constructed as a single large table named yy_action[]. - ** Given state S and lookahead X, the action is computed as - ** - ** yy_action[ yy_shift_ofst[S] + X ] - ** - ** If the index value yy_shift_ofst[S]+X is out of range or if the value - ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] - ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table - ** and that yy_default[S] should be used instead. - ** - ** The formula above is for computing the action when the lookahead is - ** a terminal symbol. If the lookahead is a non-terminal (as occurs after - ** a reduce action) then the yy_reduce_ofst[] array is used in place of - ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of - ** YY_SHIFT_USE_DFLT. - ** - ** The following are the tables generated in this section: - ** - ** yy_action[] A single table containing all actions. - ** yy_lookahead[] A table containing the lookahead for each entry in - ** yy_action. Used to detect hash collisions. - ** yy_shift_ofst[] For each state, the offset into yy_action for - ** shifting terminals. - ** yy_reduce_ofst[] For each state, the offset into yy_action for - ** shifting non-terminals after a reduce. - ** yy_default[] Default action for each state. - */ - //#define YY_ACTTAB_COUNT (1557) - const int YY_ACTTAB_COUNT = 1557; - static YYACTIONTYPE[] yy_action = new YYACTIONTYPE[]{ + /* Next are the tables used to determine what action to take based on the + ** current state and lookahead token. These tables are used to implement + ** functions that take a state number and lookahead value and return an + ** action integer. + ** + ** Suppose the action integer is N. Then the action is determined as + ** follows + ** + ** 0 <= N < YYNSTATE Shift N. That is, push the lookahead + ** token onto the stack and goto state N. + ** + ** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE. + ** + ** N == YYNSTATE+YYNRULE A syntax error has occurred. + ** + ** N == YYNSTATE+YYNRULE+1 The parser accepts its input. + ** + ** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused + ** slots in the yy_action[] table. + ** + ** The action table is constructed as a single large table named yy_action[]. + ** Given state S and lookahead X, the action is computed as + ** + ** yy_action[ yy_shift_ofst[S] + X ] + ** + ** If the index value yy_shift_ofst[S]+X is out of range or if the value + ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] + ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table + ** and that yy_default[S] should be used instead. + ** + ** The formula above is for computing the action when the lookahead is + ** a terminal symbol. If the lookahead is a non-terminal (as occurs after + ** a reduce action) then the yy_reduce_ofst[] array is used in place of + ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of + ** YY_SHIFT_USE_DFLT. + ** + ** The following are the tables generated in this section: + ** + ** yy_action[] A single table containing all actions. + ** yy_lookahead[] A table containing the lookahead for each entry in + ** yy_action. Used to detect hash collisions. + ** yy_shift_ofst[] For each state, the offset into yy_action for + ** shifting terminals. + ** yy_reduce_ofst[] For each state, the offset into yy_action for + ** shifting non-terminals after a reduce. + ** yy_default[] Default action for each state. + */ + //#define YY_ACTTAB_COUNT (1557) + const int YY_ACTTAB_COUNT = 1557; + static YYACTIONTYPE[] yy_action = new YYACTIONTYPE[]{ /* 0 */ 313, 960, 186, 419, 2, 172, 627, 597, 55, 55, /* 10 */ 55, 55, 48, 53, 53, 53, 53, 52, 52, 51, /* 20 */ 51, 51, 50, 238, 302, 283, 623, 622, 516, 515, @@ -481,7 +501,7 @@ public struct _yy215 { /* 1540 */ 490, 356, 256, 961, 483, 961, 961, 961, 961, 961, /* 1550 */ 961, 961, 961, 961, 961, 961, 370, }; - static YYCODETYPE[] yy_lookahead = new YYCODETYPE[]{ + static YYCODETYPE[] yy_lookahead = new YYCODETYPE[]{ /* 0 */ 19, 142, 143, 144, 145, 24, 1, 26, 77, 78, /* 10 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, /* 20 */ 89, 90, 91, 92, 15, 98, 26, 27, 7, 8, @@ -640,12 +660,12 @@ public struct _yy215 { /* 1550 */ 252, 252, 252, 252, 252, 252, 236, }; - const int YY_SHIFT_USE_DFLT = -74;//#define YY_SHIFT_USE_DFLT (-74) - const int YY_SHIFT_COUNT = 418; //#define YY_SHIFT_COUNT (418) - const int YY_SHIFT_MIN = -73; //#define YY_SHIFT_MIN (-73) - const int YY_SHIFT_MAX = 1468; //#define YY_SHIFT_MAX (1468) + const int YY_SHIFT_USE_DFLT = -74;//#define YY_SHIFT_USE_DFLT (-74) + const int YY_SHIFT_COUNT = 418; //#define YY_SHIFT_COUNT (418) + const int YY_SHIFT_MIN = -73; //#define YY_SHIFT_MIN (-73) + const int YY_SHIFT_MAX = 1468; //#define YY_SHIFT_MAX (1468) - static short[] yy_shift_ofst = new short[]{ + static short[] yy_shift_ofst = new short[]{ /* 0 */ 975, 1114, 1343, 1114, 1213, 1213, 90, 90, 0, -19, /* 10 */ 1213, 1213, 1213, 1213, 1213, 345, 445, 721, 1091, 1213, /* 20 */ 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, @@ -690,12 +710,12 @@ public struct _yy215 { /* 410 */ 240, 224, 143, 62, 18, 71, 39, 9, 5, }; - const int YY_REDUCE_USE_DFLT = -142; //#define YY_REDUCE_USE_DFLT (-142) - const int YY_REDUCE_COUNT = 312; //#define YY_REDUCE_COUNT (312) - const int YY_REDUCE_MIN = -141; //#define YY_REDUCE_MIN (-141) - const int YY_REDUCE_MAX = 1369; //#define YY_REDUCE_MAX (1369) + const int YY_REDUCE_USE_DFLT = -142; //#define YY_REDUCE_USE_DFLT (-142) + const int YY_REDUCE_COUNT = 312; //#define YY_REDUCE_COUNT (312) + const int YY_REDUCE_MIN = -141; //#define YY_REDUCE_MIN (-141) + const int YY_REDUCE_MAX = 1369; //#define YY_REDUCE_MAX (1369) - static short[] yy_reduce_ofst = new short[]{ + static short[] yy_reduce_ofst = new short[]{ /* 0 */ -141, 994, 1118, 223, 157, -53, 93, 89, 83, 375, /* 10 */ 386, 381, 379, 308, 295, 325, -47, 27, 1240, 1234, /* 20 */ 1228, 1221, 1208, 1187, 1151, 1111, 1109, 1077, 1054, 1022, @@ -729,7 +749,7 @@ public struct _yy215 { /* 300 */ 1112, 1115, 1086, 1105, 1092, 1087, 1068, 962, 955, 957, /* 310 */ 1031, 1023, 1030, }; - static YYACTIONTYPE[] yy_default = new YYACTIONTYPE[] { + static YYACTIONTYPE[] yy_default = new YYACTIONTYPE[] { /* 0 */ 635, 870, 959, 959, 959, 870, 899, 899, 959, 759, /* 10 */ 959, 959, 959, 959, 868, 959, 959, 933, 959, 959, /* 20 */ 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, @@ -795,18 +815,18 @@ public struct _yy215 { /* 620 */ 672, 671, 669, 668, 642, 639, 638, 634, 633, 631, }; - /* The next table maps tokens into fallback tokens. If a construct - ** like the following: - ** - ** %fallback ID X Y Z. - ** - ** appears in the grammar, then ID becomes a fallback token for X, Y, - ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser - ** but it does not parse, the type of the token is changed to ID and - ** the parse is retried before an error is thrown. - */ + /* The next table maps tokens into fallback tokens. If a construct + ** like the following: + ** + ** %fallback ID X Y Z. + ** + ** appears in the grammar, then ID becomes a fallback token for X, Y, + ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser + ** but it does not parse, the type of the token is changed to ID and + ** the parse is retried before an error is thrown. + */ #if YYFALLBACK || TRUE - static YYCODETYPE[] yyFallback = new YYCODETYPE[]{ + static YYCODETYPE[] yyFallback = new YYCODETYPE[]{ 0, /* $ => nothing */ 0, /* SEMI => nothing */ 26, /* EXPLAIN => ID */ @@ -877,153 +897,156 @@ public struct _yy215 { }; #endif // * YYFALLBACK */ - /* The following structure represents a single element of the - ** parser's stack. Information stored includes: - ** - ** + The state number for the parser at this level of the stack. - ** - ** + The value of the token stored at this level of the stack. - ** (In other words, the "major" token.) - ** - ** + The semantic value stored at this level of the stack. This is - ** the information used by the action routines in the grammar. - ** It is sometimes called the "minor" token. - */ - public class yyStackEntry { - public YYACTIONTYPE stateno; /* The state-number */ - public YYCODETYPE major; /* The major token value. This is the code + /* The following structure represents a single element of the +** parser's stack. Information stored includes: +** +** + The state number for the parser at this level of the stack. +** +** + The value of the token stored at this level of the stack. +** (In other words, the "major" token.) +** +** + The semantic value stored at this level of the stack. This is +** the information used by the action routines in the grammar. +** It is sometimes called the "minor" token. +*/ + public class yyStackEntry + { + public YYACTIONTYPE stateno; /* The state-number */ + public YYCODETYPE major; /* The major token value. This is the code ** number for the token at this stack level */ - public YYMINORTYPE minor; /* The user-supplied minor token value. This + public YYMINORTYPE minor; /* The user-supplied minor token value. This ** is the value of the token */ - }; - //typedef struct yyStackEntry yyStackEntry; + }; + //typedef struct yyStackEntry yyStackEntry; - /* The state of the parser is completely contained in an instance of - ** the following structure */ - public class yyParser { - public int yyidx; /* Index of top element in stack */ + /* The state of the parser is completely contained in an instance of + ** the following structure */ + public class yyParser + { + public int yyidx; /* Index of top element in stack */ #if YYTRACKMAXSTACKDEPTH int yyidxMax; /* Maximum value of yyidx */ #endif - public int yyerrcnt; /* Shifts left before out of the error */ - public Parse pParse; // sqlite3ParserARG_SDECL /* A place to hold %extra_argument */ + public int yyerrcnt; /* Shifts left before out of the error */ + public Parse pParse; // sqlite3ParserARG_SDECL /* A place to hold %extra_argument */ #if YYSTACKDEPTH//<=0 public int yystksz; /* Current side of the stack */ public yyStackEntry *yystack; /* The parser's stack */ #else - public yyStackEntry[] yystack = new yyStackEntry[YYSTACKDEPTH]; /* The parser's stack */ + public yyStackEntry[] yystack = new yyStackEntry[YYSTACKDEPTH]; /* The parser's stack */ #endif - }; - //typedef struct yyParser yyParser; + }; + //typedef struct yyParser yyParser; #if !NDEBUG - //#include - static TextWriter yyTraceFILE = null; - static string yyTracePrompt = ""; + //#include + static TextWriter yyTraceFILE = null; + static string yyTracePrompt = ""; #endif // * NDEBUG */ #if !NDEBUG - /* - ** Turn parser tracing on by giving a stream to which to write the trace - ** and a prompt to preface each trace message. Tracing is turned off - ** by making either argument NULL - ** - ** Inputs: - **
    - **
  • A FILE* to which trace output should be written. - ** If NULL, then tracing is turned off. - **
  • A prefix string written at the beginning of every - ** line of trace output. If NULL, then tracing is - ** turned off. - **
- ** - ** Outputs: - ** None. - */ - static void sqlite3ParserTrace(TextWriter TraceFILE, string zTracePrompt) { - yyTraceFILE = TraceFILE; - yyTracePrompt = zTracePrompt; - if (yyTraceFILE == null) - yyTracePrompt = ""; - else if (yyTracePrompt == "") - yyTraceFILE = null; - } + /* +** Turn parser tracing on by giving a stream to which to write the trace +** and a prompt to preface each trace message. Tracing is turned off +** by making either argument NULL +** +** Inputs: +**
    +**
  • A FILE* to which trace output should be written. +** If NULL, then tracing is turned off. +**
  • A prefix string written at the beginning of every +** line of trace output. If NULL, then tracing is +** turned off. +**
+** +** Outputs: +** None. +*/ + static void sqlite3ParserTrace( TextWriter TraceFILE, string zTracePrompt ) + { + yyTraceFILE = TraceFILE; + yyTracePrompt = zTracePrompt; + if ( yyTraceFILE == null ) + yyTracePrompt = ""; + else if ( yyTracePrompt == "" ) + yyTraceFILE = null; + } #endif // * NDEBUG */ #if !NDEBUG - /* For tracing shifts, the names of all terminals and nonterminals - ** are required. The following table supplies these names */ - static string[] yyTokenName = { -"$", "SEMI", "EXPLAIN", "QUERY", -"PLAN", "BEGIN", "TRANSACTION", "DEFERRED", -"IMMEDIATE", "EXCLUSIVE", "COMMIT", "END", -"ROLLBACK", "SAVEPOINT", "RELEASE", "TO", -"TABLE", "CREATE", "IF", "NOT", -"EXISTS", "TEMP", "LP", "RP", -"AS", "COMMA", "ID", "INDEXED", -"ABORT", "ACTION", "AFTER", "ANALYZE", -"ASC", "ATTACH", "BEFORE", "BY", -"CASCADE", "CAST", "COLUMNKW", "CONFLICT", -"DATABASE", "DESC", "DETACH", "EACH", -"FAIL", "FOR", "IGNORE", "INITIALLY", -"INSTEAD", "LIKE_KW", "MATCH", "NO", -"KEY", "OF", "OFFSET", "PRAGMA", -"RAISE", "REPLACE", "RESTRICT", "ROW", -"TRIGGER", "VACUUM", "VIEW", "VIRTUAL", -"REINDEX", "RENAME", "CTIME_KW", "ANY", -"OR", "AND", "IS", "BETWEEN", -"IN", "ISNULL", "NOTNULL", "NE", -"EQ", "GT", "LE", "LT", -"GE", "ESCAPE", "BITAND", "BITOR", -"LSHIFT", "RSHIFT", "PLUS", "MINUS", -"STAR", "SLASH", "REM", "CONCAT", -"COLLATE", "BITNOT", "STRING", "JOIN_KW", -"CONSTRAINT", "DEFAULT", "NULL", "PRIMARY", -"UNIQUE", "CHECK", "REFERENCES", "AUTOINCR", -"ON", "INSERT", "DELETE", "UPDATE", -"SET", "DEFERRABLE", "FOREIGN", "DROP", -"UNION", "ALL", "EXCEPT", "INTERSECT", -"SELECT", "DISTINCT", "DOT", "FROM", -"JOIN", "USING", "ORDER", "GROUP", -"HAVING", "LIMIT", "WHERE", "INTO", -"VALUES", "INTEGER", "FLOAT", "BLOB", -"REGISTER", "VARIABLE", "CASE", "WHEN", -"THEN", "ELSE", "INDEX", "ALTER", -"ADD", "error", "input", "cmdlist", -"ecmd", "explain", "cmdx", "cmd", + /* For tracing shifts, the names of all terminals and nonterminals +** are required. The following table supplies these names */ + static string[] yyTokenName = { +"$", "SEMI", "EXPLAIN", "QUERY", +"PLAN", "BEGIN", "TRANSACTION", "DEFERRED", +"IMMEDIATE", "EXCLUSIVE", "COMMIT", "END", +"ROLLBACK", "SAVEPOINT", "RELEASE", "TO", +"TABLE", "CREATE", "IF", "NOT", +"EXISTS", "TEMP", "LP", "RP", +"AS", "COMMA", "ID", "INDEXED", +"ABORT", "ACTION", "AFTER", "ANALYZE", +"ASC", "ATTACH", "BEFORE", "BY", +"CASCADE", "CAST", "COLUMNKW", "CONFLICT", +"DATABASE", "DESC", "DETACH", "EACH", +"FAIL", "FOR", "IGNORE", "INITIALLY", +"INSTEAD", "LIKE_KW", "MATCH", "NO", +"KEY", "OF", "OFFSET", "PRAGMA", +"RAISE", "REPLACE", "RESTRICT", "ROW", +"TRIGGER", "VACUUM", "VIEW", "VIRTUAL", +"REINDEX", "RENAME", "CTIME_KW", "ANY", +"OR", "AND", "IS", "BETWEEN", +"IN", "ISNULL", "NOTNULL", "NE", +"EQ", "GT", "LE", "LT", +"GE", "ESCAPE", "BITAND", "BITOR", +"LSHIFT", "RSHIFT", "PLUS", "MINUS", +"STAR", "SLASH", "REM", "CONCAT", +"COLLATE", "BITNOT", "STRING", "JOIN_KW", +"CONSTRAINT", "DEFAULT", "NULL", "PRIMARY", +"UNIQUE", "CHECK", "REFERENCES", "AUTOINCR", +"ON", "INSERT", "DELETE", "UPDATE", +"SET", "DEFERRABLE", "FOREIGN", "DROP", +"UNION", "ALL", "EXCEPT", "INTERSECT", +"SELECT", "DISTINCT", "DOT", "FROM", +"JOIN", "USING", "ORDER", "GROUP", +"HAVING", "LIMIT", "WHERE", "INTO", +"VALUES", "INTEGER", "FLOAT", "BLOB", +"REGISTER", "VARIABLE", "CASE", "WHEN", +"THEN", "ELSE", "INDEX", "ALTER", +"ADD", "error", "input", "cmdlist", +"ecmd", "explain", "cmdx", "cmd", "transtype", "trans_opt", "nm", "savepoint_opt", -"create_table", "create_table_args", "createkw", "temp", +"create_table", "create_table_args", "createkw", "temp", "ifnotexists", "dbnm", "columnlist", "conslist_opt", -"select", "column", "columnid", "type", -"carglist", "id", "ids", "typetoken", -"typename", "signed", "plus_num", "minus_num", -"carg", "ccons", "term", "expr", -"onconf", "sortorder", "autoinc", "idxlist_opt", -"refargs", "defer_subclause", "refarg", "refact", -"init_deferred_pred_opt", "conslist", "tcons", "idxlist", -"defer_subclause_opt", "orconf", "resolvetype", "raisetype", +"select", "column", "columnid", "type", +"carglist", "id", "ids", "typetoken", +"typename", "signed", "plus_num", "minus_num", +"carg", "ccons", "term", "expr", +"onconf", "sortorder", "autoinc", "idxlist_opt", +"refargs", "defer_subclause", "refarg", "refact", +"init_deferred_pred_opt", "conslist", "tcons", "idxlist", +"defer_subclause_opt", "orconf", "resolvetype", "raisetype", "ifexists", "fullname", "oneselect", "multiselect_op", -"distinct", "selcollist", "from", "where_opt", -"groupby_opt", "having_opt", "orderby_opt", "limit_opt", -"sclp", "as", "seltablist", "stl_prefix", -"joinop", "indexed_opt", "on_opt", "using_opt", -"joinop2", "inscollist", "sortlist", "sortitem", +"distinct", "selcollist", "from", "where_opt", +"groupby_opt", "having_opt", "orderby_opt", "limit_opt", +"sclp", "as", "seltablist", "stl_prefix", +"joinop", "indexed_opt", "on_opt", "using_opt", +"joinop2", "inscollist", "sortlist", "sortitem", "nexprlist", "setlist", "insert_cmd", "inscollist_opt", -"itemlist", "exprlist", "likeop", "between_op", -"in_op", "case_operand", "case_exprlist", "case_else", -"uniqueflag", "collate", "nmnum", "plus_opt", +"itemlist", "exprlist", "likeop", "between_op", +"in_op", "case_operand", "case_exprlist", "case_else", +"uniqueflag", "collate", "nmnum", "plus_opt", "number", "trigger_decl", "trigger_cmd_list", "trigger_time", -"trigger_event", "foreach_clause", "when_clause", "trigger_cmd", -"trnm", "tridxby", "database_kw_opt", "key_opt", -"add_column_fullname", "kwcolumn_opt", "create_vtab", "vtabarglist", -"vtabarg", "vtabargtoken", "lp", "anylist", +"trigger_event", "foreach_clause", "when_clause", "trigger_cmd", +"trnm", "tridxby", "database_kw_opt", "key_opt", +"add_column_fullname", "kwcolumn_opt", "create_vtab", "vtabarglist", +"vtabarg", "vtabargtoken", "lp", "anylist", }; #endif // * NDEBUG */ #if !NDEBUG - /* For tracing reduce actions, the names of all rules are required. - */ - static string[] yyRuleName = { + /* For tracing reduce actions, the names of all rules are required. +*/ + static string[] yyRuleName = { /* 0 */ "input ::= cmdlist", /* 1 */ "cmdlist ::= cmdlist ecmd", /* 2 */ "cmdlist ::= ecmd", @@ -1380,23 +1403,25 @@ static void yyGrowStack(yyParser p){ } #endif - /* - ** This function allocates a new parser. - ** The only argument is a pointer to a function which works like - ** malloc. - ** - ** Inputs: - ** A pointer to the function used to allocate memory. - ** - ** Outputs: - ** A pointer to a parser. This pointer is used in subsequent calls - ** to sqlite3Parser and sqlite3ParserFree. - */ - static yyParser sqlite3ParserAlloc() {//void *(*mallocProc)(size_t)){ - yyParser pParser = new yyParser(); - //pParser = (yyParser*)(*mallocProc)( (size_t)yyParser.Length ); - if (pParser != null) { - pParser.yyidx = -1; + /* +** This function allocates a new parser. +** The only argument is a pointer to a function which works like +** malloc. +** +** Inputs: +** A pointer to the function used to allocate memory. +** +** Outputs: +** A pointer to a parser. This pointer is used in subsequent calls +** to sqlite3Parser and sqlite3ParserFree. +*/ + static yyParser sqlite3ParserAlloc() + {//void *(*mallocProc)(size_t)){ + yyParser pParser = new yyParser(); + //pParser = (yyParser*)(*mallocProc)( (size_t)yyParser.Length ); + if ( pParser != null ) + { + pParser.yyidx = -1; #if YYTRACKMAXSTACKDEPTH pParser.yyidxMax=0; #endif @@ -1406,180 +1431,185 @@ static yyParser sqlite3ParserAlloc() {//void *(*mallocProc)(size_t)){ pParser.yystksz = null; yyGrowStack(pParser); #endif - } - return pParser; - } - - /* The following function deletes the value associated with a - ** symbol. The symbol can be either a terminal or nonterminal. - ** "yymajor" is the symbol code, and "yypminor" is a pointer to - ** the value. - */ - static void yy_destructor( - yyParser yypParser, /* The parser */ - YYCODETYPE yymajor, /* Type code for object to destroy */ - YYMINORTYPE yypminor /* The object to be destroyed */ - ) { - Parse pParse = yypParser.pParse; // sqlite3ParserARG_FETCH; - switch (yymajor) { - /* Here is inserted the actions which take place when a - ** terminal or non-terminal is destroyed. This can happen - ** when the symbol is popped from the stack during a - ** reduce or during error processing or when a parser is - ** being destroyed before it is finished parsing. - ** - ** Note: during a reduce, the only symbols destroyed are those - ** which appear on the RHS of the rule, but which are not used - ** inside the C code. - */ - case 160: /* select */ - case 194: /* oneselect */ - { - //#line 403 "parse.y" - sqlite3SelectDelete(pParse.db, ref (yypminor.yy387)); - //#line 1399 "parse.c" - } - break; - case 174: /* term */ - case 175: /* Expr */ - { - //#line 720 "parse.y" - sqlite3ExprDelete(pParse.db, ref (yypminor.yy118).pExpr); - //#line 1407 "parse.c" - } - break; - case 179: /* idxlist_opt */ - case 187: /* idxlist */ - case 197: /* selcollist */ - case 200: /* groupby_opt */ - case 202: /* orderby_opt */ - case 204: /* sclp */ - case 214: /* sortlist */ - case 216: /* nexprlist */ - case 217: /* setlist */ - case 220: /* itemlist */ - case 221: /* exprlist */ - case 226: /* case_exprlist */ - { - //#line 1103 "parse.y" - sqlite3ExprListDelete(pParse.db, ref (yypminor.yy322)); - //#line 1425 "parse.c" - } - break; - case 193: /* fullname */ - case 198: /* from */ - case 206: /* seltablist */ - case 207: /* stl_prefix */ - { - //#line 534 "parse.y" - sqlite3SrcListDelete(pParse.db, ref (yypminor.yy259)); - //#line 1435 "parse.c" - } - break; - case 199: /* where_opt */ - case 201: /* having_opt */ - case 210: /* on_opt */ - case 215: /* sortitem */ - case 225: /* case_operand */ - case 227: /* case_else */ - case 238: /* when_clause */ - case 243: /* key_opt */ - { - //#line 644 "parse.y" - sqlite3ExprDelete(pParse.db, ref (yypminor.yy314)); - //#line 1449 "parse.c" - } - break; - case 211: /* using_opt */ - case 213: /* inscollist */ - case 219: /* inscollist_opt */ - { - //#line 566 "parse.y" - sqlite3IdListDelete(pParse.db, ref (yypminor.yy384)); - //#line 1458 "parse.c" - } - break; - case 234: /* trigger_cmd_list */ - case 239: /* trigger_cmd */ - { - //#line 1210"parse.y" - sqlite3DeleteTriggerStep(pParse.db, ref (yypminor.yy203)); - //#line 1466 "parse.c" - } - break; - case 236: /* trigger_event */ - { - //#line 1196 "parse.y" - sqlite3IdListDelete(pParse.db, ref (yypminor.yy90).b); - //#line 1473 "parse.c" - } - break; - default: - break; /* If no destructor action specified: do nothing */ - } - } + } + return pParser; + } - /* - ** Pop the parser's stack once. - ** - ** If there is a destructor routine associated with the token which - ** is popped from the stack, then call it. + /* The following function deletes the value associated with a + ** symbol. The symbol can be either a terminal or nonterminal. + ** "yymajor" is the symbol code, and "yypminor" is a pointer to + ** the value. + */ + static void yy_destructor( + yyParser yypParser, /* The parser */ + YYCODETYPE yymajor, /* Type code for object to destroy */ + YYMINORTYPE yypminor /* The object to be destroyed */ + ) + { + Parse pParse = yypParser.pParse; // sqlite3ParserARG_FETCH; + switch ( yymajor ) + { + /* Here is inserted the actions which take place when a + ** terminal or non-terminal is destroyed. This can happen + ** when the symbol is popped from the stack during a + ** reduce or during error processing or when a parser is + ** being destroyed before it is finished parsing. ** - ** Return the major token number for the symbol popped. + ** Note: during a reduce, the only symbols destroyed are those + ** which appear on the RHS of the rule, but which are not used + ** inside the C code. */ - static int yy_pop_parser_stack(yyParser pParser) { - YYCODETYPE yymajor; - yyStackEntry yytos = pParser.yystack[pParser.yyidx]; + case 160: /* select */ + case 194: /* oneselect */ + { + //#line 403 "parse.y" + sqlite3SelectDelete( pParse.db, ref ( yypminor.yy387 ) ); + //#line 1399 "parse.c" + } + break; + case 174: /* term */ + case 175: /* Expr */ + { + //#line 720 "parse.y" + sqlite3ExprDelete( pParse.db, ref ( yypminor.yy118 ).pExpr ); + //#line 1407 "parse.c" + } + break; + case 179: /* idxlist_opt */ + case 187: /* idxlist */ + case 197: /* selcollist */ + case 200: /* groupby_opt */ + case 202: /* orderby_opt */ + case 204: /* sclp */ + case 214: /* sortlist */ + case 216: /* nexprlist */ + case 217: /* setlist */ + case 220: /* itemlist */ + case 221: /* exprlist */ + case 226: /* case_exprlist */ + { + //#line 1103 "parse.y" + sqlite3ExprListDelete( pParse.db, ref ( yypminor.yy322 ) ); + //#line 1425 "parse.c" + } + break; + case 193: /* fullname */ + case 198: /* from */ + case 206: /* seltablist */ + case 207: /* stl_prefix */ + { + //#line 534 "parse.y" + sqlite3SrcListDelete( pParse.db, ref ( yypminor.yy259 ) ); + //#line 1435 "parse.c" + } + break; + case 199: /* where_opt */ + case 201: /* having_opt */ + case 210: /* on_opt */ + case 215: /* sortitem */ + case 225: /* case_operand */ + case 227: /* case_else */ + case 238: /* when_clause */ + case 243: /* key_opt */ + { + //#line 644 "parse.y" + sqlite3ExprDelete( pParse.db, ref ( yypminor.yy314 ) ); + //#line 1449 "parse.c" + } + break; + case 211: /* using_opt */ + case 213: /* inscollist */ + case 219: /* inscollist_opt */ + { + //#line 566 "parse.y" + sqlite3IdListDelete( pParse.db, ref ( yypminor.yy384 ) ); + //#line 1458 "parse.c" + } + break; + case 234: /* trigger_cmd_list */ + case 239: /* trigger_cmd */ + { + //#line 1210"parse.y" + sqlite3DeleteTriggerStep( pParse.db, ref ( yypminor.yy203 ) ); + //#line 1466 "parse.c" + } + break; + case 236: /* trigger_event */ + { + //#line 1196 "parse.y" + sqlite3IdListDelete( pParse.db, ref ( yypminor.yy90 ).b ); + //#line 1473 "parse.c" + } + break; + default: + break; /* If no destructor action specified: do nothing */ + } + } - /* There is no mechanism by which the parser stack can be popped below - ** empty in SQLite. */ - if (NEVER(pParser.yyidx < 0)) - return 0; + /* + ** Pop the parser's stack once. + ** + ** If there is a destructor routine associated with the token which + ** is popped from the stack, then call it. + ** + ** Return the major token number for the symbol popped. + */ + static int yy_pop_parser_stack( yyParser pParser ) + { + YYCODETYPE yymajor; + yyStackEntry yytos = pParser.yystack[pParser.yyidx]; + + /* There is no mechanism by which the parser stack can be popped below + ** empty in SQLite. */ + if ( NEVER( pParser.yyidx < 0 ) ) + return 0; #if !NDEBUG - if (yyTraceFILE != null && pParser.yyidx >= 0) { - fprintf(yyTraceFILE, "%sPopping %s\n", - yyTracePrompt, - yyTokenName[yytos.major]); - } + if ( yyTraceFILE != null && pParser.yyidx >= 0 ) + { + fprintf( yyTraceFILE, "%sPopping %s\n", + yyTracePrompt, + yyTokenName[yytos.major] ); + } #endif - yymajor = yytos.major; - yy_destructor(pParser, yymajor, yytos.minor); - pParser.yyidx--; - return yymajor; - } + yymajor = yytos.major; + yy_destructor( pParser, yymajor, yytos.minor ); + pParser.yyidx--; + return yymajor; + } - /* - ** Deallocate and destroy a parser. Destructors are all called for - ** all stack elements before shutting the parser down. - ** - ** Inputs: - **
    - **
  • A pointer to the parser. This should be a pointer - ** obtained from sqlite3ParserAlloc. - **
  • A pointer to a function used to reclaim memory obtained - ** from malloc. - **
- */ - static void sqlite3ParserFree( - yyParser p, /* The parser to be deleted */ - dxDel freeProc//)(void*) /* Function used to reclaim memory */ - ) { - yyParser pParser = p; - /* In SQLite, we never try to destroy a parser that was not successfully - ** created in the first place. */ - if (NEVER(pParser == null)) - return; - while (pParser.yyidx >= 0) - yy_pop_parser_stack(pParser); + /* + ** Deallocate and destroy a parser. Destructors are all called for + ** all stack elements before shutting the parser down. + ** + ** Inputs: + **
    + **
  • A pointer to the parser. This should be a pointer + ** obtained from sqlite3ParserAlloc. + **
  • A pointer to a function used to reclaim memory obtained + ** from malloc. + **
+ */ + static void sqlite3ParserFree( + yyParser p, /* The parser to be deleted */ + dxDel freeProc//)(void*) /* Function used to reclaim memory */ + ) + { + yyParser pParser = p; + /* In SQLite, we never try to destroy a parser that was not successfully + ** created in the first place. */ + if ( NEVER( pParser == null ) ) + return; + while ( pParser.yyidx >= 0 ) + yy_pop_parser_stack( pParser ); #if YYSTACKDEPTH//<=0 pParser.yystack = null;//free(pParser.yystack); #endif - pParser = null;// freeProc(ref pParser); - } + pParser = null;// freeProc(ref pParser); + } - /* - ** Return the peak depth of the stack for a parser. - */ + /* + ** Return the peak depth of the stack for a parser. + */ #if YYTRACKMAXSTACKDEPTH int sqlite3ParserStackPeak(void p){ yyParser pParser = (yyParser*)p; @@ -1587,153 +1617,168 @@ int sqlite3ParserStackPeak(void p){ } #endif - /* - ** Find the appropriate action for a parser given the terminal - ** look-ahead token iLookAhead. - ** - ** If the look-ahead token is YYNOCODE, then check to see if the action is - ** independent of the look-ahead. If it is, return the action, otherwise - ** return YY_NO_ACTION. - */ - static int yy_find_shift_action( - yyParser pParser, /* The parser */ - YYCODETYPE iLookAhead /* The look-ahead token */ - ) { - int i; - int stateno = pParser.yystack[pParser.yyidx].stateno; + /* +** Find the appropriate action for a parser given the terminal +** look-ahead token iLookAhead. +** +** If the look-ahead token is YYNOCODE, then check to see if the action is +** independent of the look-ahead. If it is, return the action, otherwise +** return YY_NO_ACTION. +*/ + static int yy_find_shift_action( + yyParser pParser, /* The parser */ + YYCODETYPE iLookAhead /* The look-ahead token */ + ) + { + int i; + int stateno = pParser.yystack[pParser.yyidx].stateno; - if (stateno > YY_SHIFT_COUNT - || (i = yy_shift_ofst[stateno]) == YY_SHIFT_USE_DFLT) { - return yy_default[stateno]; - } - Debug.Assert(iLookAhead != YYNOCODE); - i += iLookAhead; - if (i < 0 || i >= YY_ACTTAB_COUNT || yy_lookahead[i] != iLookAhead) { - if (iLookAhead > 0) { - //#if YYFALLBACK - YYCODETYPE iFallback; /* Fallback token */ - if (iLookAhead < yyFallback.Length //yyFallback.Length/sizeof(yyFallback[0]) - && (iFallback = yyFallback[iLookAhead]) != 0) { + if ( stateno > YY_SHIFT_COUNT + || ( i = yy_shift_ofst[stateno] ) == YY_SHIFT_USE_DFLT ) + { + return yy_default[stateno]; + } + Debug.Assert( iLookAhead != YYNOCODE ); + i += iLookAhead; + if ( i < 0 || i >= YY_ACTTAB_COUNT || yy_lookahead[i] != iLookAhead ) + { + if ( iLookAhead > 0 ) + { + //#if YYFALLBACK + YYCODETYPE iFallback; /* Fallback token */ + if ( iLookAhead < yyFallback.Length //yyFallback.Length/sizeof(yyFallback[0]) + && ( iFallback = yyFallback[iLookAhead] ) != 0 ) + { #if !NDEBUG - if (yyTraceFILE != null) { - fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n", - yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); - } + if ( yyTraceFILE != null ) + { + fprintf( yyTraceFILE, "%sFALLBACK %s => %s\n", + yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback] ); + } #endif - return yy_find_shift_action(pParser, iFallback); - } - //#endif - //#if YYWILDCARD - { - int j = i - iLookAhead + YYWILDCARD; - if ( - //#if YY_SHIFT_MIN+YYWILDCARD<0 - j >= 0 && - //#endif - //#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT - j < YY_ACTTAB_COUNT && - //#endif - yy_lookahead[j] == YYWILDCARD - ) { + return yy_find_shift_action( pParser, iFallback ); + } + //#endif + //#if YYWILDCARD + { + int j = i - iLookAhead + YYWILDCARD; + if ( + //#if YY_SHIFT_MIN+YYWILDCARD<0 + j >= 0 && + //#endif + //#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT + j < YY_ACTTAB_COUNT && + //#endif + yy_lookahead[j] == YYWILDCARD + ) + { #if !NDEBUG - if (yyTraceFILE != null) { - Debugger.Break(); // TODO -- - //fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", - // yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); - } + if ( yyTraceFILE != null ) + { + Debugger.Break(); // TODO -- + //fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", + // yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); + } #endif // * NDEBUG */ - return yy_action[j]; - } - } - //#endif // * YYWILDCARD */ - } - return yy_default[stateno]; - } else { - return yy_action[i]; + return yy_action[j]; } + } + //#endif // * YYWILDCARD */ } + return yy_default[stateno]; + } + else + { + return yy_action[i]; + } + } - /* - ** Find the appropriate action for a parser given the non-terminal - ** look-ahead token iLookAhead. - ** - ** If the look-ahead token is YYNOCODE, then check to see if the action is - ** independent of the look-ahead. If it is, return the action, otherwise - ** return YY_NO_ACTION. - */ - static int yy_find_reduce_action( - int stateno, /* Current state number */ - YYCODETYPE iLookAhead /* The look-ahead token */ - ) { - int i; + /* + ** Find the appropriate action for a parser given the non-terminal + ** look-ahead token iLookAhead. + ** + ** If the look-ahead token is YYNOCODE, then check to see if the action is + ** independent of the look-ahead. If it is, return the action, otherwise + ** return YY_NO_ACTION. + */ + static int yy_find_reduce_action( + int stateno, /* Current state number */ + YYCODETYPE iLookAhead /* The look-ahead token */ + ) + { + int i; #if YYERRORSYMBOL if( stateno>YY_REDUCE_COUNT ){ return yy_default[stateno]; } #else - Debug.Assert(stateno <= YY_REDUCE_COUNT); + Debug.Assert( stateno <= YY_REDUCE_COUNT ); #endif - i = yy_reduce_ofst[stateno]; - Debug.Assert(i != YY_REDUCE_USE_DFLT); - Debug.Assert(iLookAhead != YYNOCODE); - i += iLookAhead; + i = yy_reduce_ofst[stateno]; + Debug.Assert( i != YY_REDUCE_USE_DFLT ); + Debug.Assert( iLookAhead != YYNOCODE ); + i += iLookAhead; #if YYERRORSYMBOL if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ return yy_default[stateno]; } #else - Debug.Assert(i >= 0 && i < YY_ACTTAB_COUNT); - Debug.Assert(yy_lookahead[i] == iLookAhead); + Debug.Assert( i >= 0 && i < YY_ACTTAB_COUNT ); + Debug.Assert( yy_lookahead[i] == iLookAhead ); #endif - return yy_action[i]; - } + return yy_action[i]; + } - /* - ** The following routine is called if the stack overflows. - */ - static void yyStackOverflow(yyParser yypParser, YYMINORTYPE yypMinor) { - Parse pParse = yypParser.pParse; // sqlite3ParserARG_FETCH; - yypParser.yyidx--; + /* + ** The following routine is called if the stack overflows. + */ + static void yyStackOverflow( yyParser yypParser, YYMINORTYPE yypMinor ) + { + Parse pParse = yypParser.pParse; // sqlite3ParserARG_FETCH; + yypParser.yyidx--; #if !NDEBUG - if (yyTraceFILE != null) { - Debugger.Break(); // TODO -- - //fprintf(yyTraceFILE, "%sStack Overflow!\n", yyTracePrompt); - } + if ( yyTraceFILE != null ) + { + Debugger.Break(); // TODO -- + //fprintf(yyTraceFILE, "%sStack Overflow!\n", yyTracePrompt); + } #endif - while (yypParser.yyidx >= 0) - yy_pop_parser_stack(yypParser); - /* Here code is inserted which will execute if the parser - ** stack every overflows */ - //#line 38 "parse.y" + while ( yypParser.yyidx >= 0 ) + yy_pop_parser_stack( yypParser ); + /* Here code is inserted which will execute if the parser + ** stack every overflows */ + //#line 38 "parse.y" - UNUSED_PARAMETER(yypMinor); /* Silence some compiler warnings */ - sqlite3ErrorMsg(pParse, "parser stack overflow"); - pParse.parseError = 1; - //#line 1664 "parse.c" - yypParser.pParse = pParse;// sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument var */ - } + UNUSED_PARAMETER( yypMinor ); /* Silence some compiler warnings */ + sqlite3ErrorMsg( pParse, "parser stack overflow" ); + pParse.parseError = 1; + //#line 1664 "parse.c" + yypParser.pParse = pParse;// sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument var */ + } - /* - ** Perform a shift action. - */ - static void yy_shift( - yyParser yypParser, /* The parser to be shifted */ - int yyNewState, /* The new state to shift in */ - int yyMajor, /* The major token to shift in */ - YYMINORTYPE yypMinor /* Pointer to the minor token to shift in */ - ) { - yyStackEntry yytos = new yyStackEntry(); - yypParser.yyidx++; + /* + ** Perform a shift action. + */ + static void yy_shift( + yyParser yypParser, /* The parser to be shifted */ + int yyNewState, /* The new state to shift in */ + int yyMajor, /* The major token to shift in */ + YYMINORTYPE yypMinor /* Pointer to the minor token to shift in */ + ) + { + yyStackEntry yytos = new yyStackEntry(); + yypParser.yyidx++; #if YYTRACKMAXSTACKDEPTH if( yypParser.yyidx>yypParser.yyidxMax ){ yypParser.yyidxMax = yypParser.yyidx; } #endif #if !YYSTACKDEPTH//was YYSTACKDEPTH>0 - if (yypParser.yyidx >= YYSTACKDEPTH) { - yyStackOverflow(yypParser, yypMinor); - return; - } + if ( yypParser.yyidx >= YYSTACKDEPTH ) + { + yyStackOverflow( yypParser, yypMinor ); + return; + } #else if( yypParser.yyidx>=yypParser.yystksz ){ yyGrowStack(yypParser); @@ -1743,34 +1788,37 @@ YYMINORTYPE yypMinor /* Pointer to the minor token to shift in */ } } #endif - yypParser.yystack[yypParser.yyidx] = yytos;//yytos = yypParser.yystack[yypParser.yyidx]; - yytos.stateno = (YYACTIONTYPE)yyNewState; - yytos.major = (YYCODETYPE)yyMajor; - yytos.minor = yypMinor; + yypParser.yystack[yypParser.yyidx] = yytos;//yytos = yypParser.yystack[yypParser.yyidx]; + yytos.stateno = (YYACTIONTYPE)yyNewState; + yytos.major = (YYCODETYPE)yyMajor; + yytos.minor = yypMinor; #if !NDEBUG - if (yyTraceFILE != null && yypParser.yyidx > 0) { - int i; - fprintf(yyTraceFILE, "%sShift %d\n", yyTracePrompt, yyNewState); - fprintf(yyTraceFILE, "%sStack:", yyTracePrompt); - for (i = 1; i <= yypParser.yyidx; i++) - fprintf(yyTraceFILE, " %s", yyTokenName[yypParser.yystack[i].major]); - fprintf(yyTraceFILE, "\n"); - } + if ( yyTraceFILE != null && yypParser.yyidx > 0 ) + { + int i; + fprintf( yyTraceFILE, "%sShift %d\n", yyTracePrompt, yyNewState ); + fprintf( yyTraceFILE, "%sStack:", yyTracePrompt ); + for ( i = 1; i <= yypParser.yyidx; i++ ) + fprintf( yyTraceFILE, " %s", yyTokenName[yypParser.yystack[i].major] ); + fprintf( yyTraceFILE, "\n" ); + } #endif - } - /* The following table contains information about every rule that - ** is used during the reduce. - */ - public struct _yyRuleInfo { - public YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ - public byte nrhs; /* Number of right-hand side symbols in the rule */ - public _yyRuleInfo(YYCODETYPE lhs, byte nrhs) { - this.lhs = lhs; - this.nrhs = nrhs; - } + } + /* The following table contains information about every rule that + ** is used during the reduce. + */ + public struct _yyRuleInfo + { + public YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ + public byte nrhs; /* Number of right-hand side symbols in the rule */ + public _yyRuleInfo( YYCODETYPE lhs, byte nrhs ) + { + this.lhs = lhs; + this.nrhs = nrhs; + } - } - static _yyRuleInfo[] yyRuleInfo = new _yyRuleInfo[]{ + } + static _yyRuleInfo[] yyRuleInfo = new _yyRuleInfo[]{ new _yyRuleInfo( 142, 1 ), new _yyRuleInfo( 143, 2 ), new _yyRuleInfo( 143, 1 ), @@ -2102,1880 +2150,1924 @@ public _yyRuleInfo(YYCODETYPE lhs, byte nrhs) { new _yyRuleInfo( 251, 2 ), }; - //static void yy_accept(yyParser*); /* Forward Declaration */ + //static void yy_accept(yyParser*); /* Forward Declaration */ - /* - ** Perform a reduce action and the shift that must immediately - ** follow the reduce. - */ - static void yy_reduce( - yyParser yypParser, /* The parser */ - int yyruleno /* Number of the rule by which to reduce */ - ) { - int yygoto; /* The next state */ - int yyact; /* The next action */ - YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ - yymsp yymsp; // yyStackEntry[] yymsp = new yyStackEntry[0]; /* The top of the parser's stack */ - int yysize; /* Amount to pop the stack */ - Parse pParse = yypParser.pParse; //sqlite3ParserARG_FETCH; + /* + ** Perform a reduce action and the shift that must immediately + ** follow the reduce. + */ + static void yy_reduce( + yyParser yypParser, /* The parser */ + int yyruleno /* Number of the rule by which to reduce */ + ) + { + int yygoto; /* The next state */ + int yyact; /* The next action */ + YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ + yymsp yymsp; // yyStackEntry[] yymsp = new yyStackEntry[0]; /* The top of the parser's stack */ + int yysize; /* Amount to pop the stack */ + Parse pParse = yypParser.pParse; //sqlite3ParserARG_FETCH; - yymsp = new yymsp(ref yypParser, yypParser.yyidx); // yymsp[0] = yypParser.yystack[yypParser.yyidx]; + yymsp = new yymsp( ref yypParser, yypParser.yyidx ); // yymsp[0] = yypParser.yystack[yypParser.yyidx]; #if !NDEBUG - if (yyTraceFILE != null && yyruleno >= 0 - && yyruleno < yyRuleName.Length) { //(int)(yyRuleName.Length/sizeof(yyRuleName[0])) ){ - fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, - yyRuleName[yyruleno]); - } + if ( yyTraceFILE != null && yyruleno >= 0 + && yyruleno < yyRuleName.Length ) + { //(int)(yyRuleName.Length/sizeof(yyRuleName[0])) ){ + fprintf( yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, + yyRuleName[yyruleno] ); + } #endif // * NDEBUG */ - /* Silence complaints from purify about yygotominor being uninitialized - ** in some cases when it is copied into the stack after the following - ** switch. yygotominor is uninitialized when a rule reduces that does - ** not set the value of its left-hand side nonterminal. Leaving the - ** value of the nonterminal uninitialized is utterly harmless as long - ** as the value is never used. So really the only thing this code - ** accomplishes is to quieten purify. - ** - ** 2007-01-16: The wireshark project (www.wireshark.org) reports that - ** without this code, their parser segfaults. I'm not sure what there - ** parser is doing to make this happen. This is the second bug report - ** from wireshark this week. Clearly they are stressing Lemon in ways - ** that it has not been previously stressed... (SQLite ticket #2172) - */ - yygotominor = new YYMINORTYPE(); //memset(yygotominor, 0, yygotominor).Length; - switch (yyruleno) { - /* Beginning here are the reduction cases. A typical example - ** follows: - ** case 0: - ** //#line - ** { ... } // User supplied code - ** //#line - ** break; - */ - case 5: /* explain ::= */ - //#line 107 "parse.y" - { - sqlite3BeginParse(pParse, 0); - } - //#line 2107 "parse.c" - break; - case 6: /* explain ::= EXPLAIN */ - //#line 109 "parse.y" - { - sqlite3BeginParse(pParse, 1); - } - //#line 2112 "parse.c" - break; - case 7: /* explain ::= EXPLAIN QUERY PLAN */ - //#line 110 "parse.y" - { - sqlite3BeginParse(pParse, 2); - } - //#line 2117 "parse.c" - break; - case 8: /* cmdx ::= cmd */ - //#line 112 "parse.y" - { - sqlite3FinishCoding(pParse); - } - //#line 2122 "parse.c" - break; - case 9: /* cmd ::= BEGIN transtype trans_opt */ - //#line 117 "parse.y" - { - sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy4); - } - //#line 2127 "parse.c" - break; - case 13: /* transtype ::= */ - //#line 122 "parse.y" - { - yygotominor.yy4 = TK_DEFERRED; - } - //#line 2132 "parse.c" - break; - case 14: /* transtype ::= DEFERRED */ - case 15: /* transtype ::= IMMEDIATE */ //yytestcase(yyruleno==15); - case 16: /* transtype ::= EXCLUSIVE */ //yytestcase(yyruleno==16); - case 115: /* multiselect_op ::= UNION */ //yytestcase(yyruleno==114); - case 117: /* multiselect_op ::= EXCEPT|INTERSECT */ //yytestcase(yyruleno==116); - //#line 123 "parse.y" - { - yygotominor.yy4 = yymsp[0].major; - } - //#line 2141 "parse.c" - break; - case 17: /* cmd ::= COMMIT trans_opt */ - case 18: /* cmd ::= END trans_opt */ //yytestcase(yyruleno==18); - //#line 126 "parse.y" - { - sqlite3CommitTransaction(pParse); - } - //#line 2147 "parse.c" - break; - case 19: /* cmd ::= ROLLBACK trans_opt */ - //#line 128 "parse.y" - { - sqlite3RollbackTransaction(pParse); - } - //#line 2152 "parse.c" - break; - case 22: /* cmd ::= SAVEPOINT nm */ - //#line 132 "parse.y" - { - sqlite3Savepoint(pParse, SAVEPOINT_BEGIN, yymsp[0].minor.yy0); - } - //#line 2159 "parse.c" - break; - case 23: /* cmd ::= RELEASE savepoint_opt nm */ - //#line 135 "parse.y" - { - sqlite3Savepoint(pParse, SAVEPOINT_RELEASE, yymsp[0].minor.yy0); - } - //#line 2166 "parse.c" - break; - case 24: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ - //#line 138 "parse.y" - { - sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, yymsp[0].minor.yy0); - } - //#line 2173 "parse.c" - break; - case 26: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ - //#line 145 "parse.y" - { - sqlite3StartTable(pParse, yymsp[-1].minor.yy0, yymsp[0].minor.yy0, yymsp[-4].minor.yy4, 0, 0, yymsp[-2].minor.yy4); - } - //#line 2180 "parse.c" - break; - case 27: /* createkw ::= CREATE */ - //#line 148 "parse.y" - { - pParse.db.lookaside.bEnabled = 0; - yygotominor.yy0 = yymsp[0].minor.yy0; - } - //#line 2188 "parse.c" - break; - case 28: /* ifnotexists ::= */ - case 31: /* temp ::= */ //yytestcase(yyruleno == 31); - case 70: /* autoinc ::= */ //yytestcase(yyruleno == 70); - case 83: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ //yytestcase(yyruleno == 83); - case 85: /* init_deferred_pred_opt ::= */ //yytestcase(yyruleno == 85); - case 87: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ //yytestcase(yyruleno == 87); - case 98: /* defer_subclause_opt ::= */ //yytestcase(yyruleno == 98); - case 109: /* ifexists ::= */ //yytestcase(yyruleno == 109); - case 120: /* distinct ::= ALL */ //yytestcase(yyruleno == 120); - case 121: /* distinct ::= */ //yytestcase(yyruleno == 121); - case 222: /* between_op ::= BETWEEN */ //yytestcase(yyruleno == 223); - case 225: /* in_op ::= IN */ //yytestcase(yyruleno == 226); - //#line 153 "parse.y" - { - yygotominor.yy4 = 0; - } - //#line 2204 "parse.c" - break; - case 29: /* ifnotexists ::= IF NOT EXISTS */ - case 30: /* temp ::= TEMP */ //yytestcase(yyruleno == 30); - case 71: /* autoinc ::= AUTOINCR */ //yytestcase(yyruleno == 71); - case 86: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ //yytestcase(yyruleno == 86); - case 108: /* ifexists ::= IF EXISTS */ //yytestcase(yyruleno == 108); - case 119: /* distinct ::= DISTINCT */ //yytestcase(yyruleno == 119); - case 223: /* between_op ::= NOT BETWEEN */ //yytestcase(yyruleno == 224); - case 226: /* in_op ::= NOT IN */ //yytestcase(yyruleno == 227); - //#line 154 "parse.y" - { - yygotominor.yy4 = 1; - } - //#line 2216 "parse.c" - break; - case 32: /* create_table_args ::= LP columnlist conslist_opt RP */ - //#line 160 "parse.y" - { - sqlite3EndTable(pParse, yymsp[-1].minor.yy0, yymsp[0].minor.yy0, 0); - } - //#line 2223 "parse.c" - break; - case 33: /* create_table_args ::= AS select */ - //#line 163 "parse.y" - { - sqlite3EndTable(pParse, 0, 0, yymsp[0].minor.yy387); - sqlite3SelectDelete(pParse.db, ref yymsp[0].minor.yy387); - } - //#line 2231 "parse.c" - break; - case 36: /* column ::= columnid type carglist */ - //#line 175 "parse.y" - { - //yygotominor.yy0.z = yymsp[-2].minor.yy0.z; - //yygotominor.yy0.n = (int)( pParse.sLastToken.z - yymsp[-2].minor.yy0.z ) + pParse.sLastToken.n; - yygotominor.yy0.n = (int)(yymsp[-2].minor.yy0.z.Length - pParse.sLastToken.z.Length) + pParse.sLastToken.n; - yygotominor.yy0.z = yymsp[-2].minor.yy0.z.Substring(0, yygotominor.yy0.n); - } - //#line 2239 "parse.c" - break; - case 37: /* columnid ::= nm */ - //#line 179 "parse.y" - { - sqlite3AddColumn(pParse, yymsp[0].minor.yy0); - yygotominor.yy0 = yymsp[0].minor.yy0; - } - //#line 2247 "parse.c" - break; - case 38: /* id ::= ID */ - case 39: /* id ::= INDEXED */ //yytestcase(yyruleno==39); - case 40: /* ids ::= ID|STRING */ //yytestcase(yyruleno==40); - case 41: /* nm ::= id */ //yytestcase(yyruleno==41); - case 42: /* nm ::= STRING */ //yytestcase(yyruleno==42); - case 43: /* nm ::= JOIN_KW */ //yytestcase(yyruleno==43); - case 46: /* typetoken ::= typename */ //yytestcase(yyruleno==46); - case 49: /* typename ::= ids */ //yytestcase(yyruleno==49); - case 127: /* as ::= AS nm */ ////yytestcase(yyruleno == 127); - case 128: /* as ::= ids */ ////yytestcase(yyruleno == 128); - case 138: /* dbnm ::= DOT nm */ ////yytestcase(yyruleno == 138); - case 147: /* indexed_opt ::= INDEXED BY nm */ ////yytestcase(yyruleno == 147); - case 251: /* collate ::= COLLATE ids */ //testcase(yyruleno == 251); - case 260: /* nmnum ::= plus_num */ //testcase(yyruleno == 260); - case 261: /* nmnum ::= nm */ //testcase(yyruleno == 261); - case 262: /* nmnum ::= ON */ //testcase(yyruleno == 262); - case 263: /* nmnum ::= DELETE */ //testcase(yyruleno == 263); - case 264: /* nmnum ::= DEFAULT */ //testcase(yyruleno == 264); - case 265: /* plus_num ::= plus_opt number */ //testcase(yyruleno == 265); - case 266: /* minus_num ::= MINUS number */ //testcase(yyruleno == 266); - case 267: /* number ::= INTEGER|FLOAT */ //testcase(yyruleno == 267); - case 285: /* trnm ::= nm */ //testcase(yyruleno == 285); - //#line 189 "parse.y" - { - yygotominor.yy0 = yymsp[0].minor.yy0; - } - //#line 2273 "parse.c" - break; - case 45: /* type ::= typetoken */ - //#line 251 "parse.y" - { - sqlite3AddColumnType(pParse, yymsp[0].minor.yy0); - } - //#line 2278 "parse.c" - break; - case 47: /* typetoken ::= typename LP signed RP */ - //#line 253 "parse.y" - { - //yygotominor.yy0.z = yymsp[-3].minor.yy0.z; - //yygotominor.yy0.n = (int)( &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z ); - yygotominor.yy0.n = yymsp[-3].minor.yy0.z.Length - yymsp[0].minor.yy0.z.Length + yymsp[0].minor.yy0.n; - yygotominor.yy0.z = yymsp[-3].minor.yy0.z.Substring(0, yygotominor.yy0.n); - } - //#line 2286 "parse.c" - break; - case 48: /* typetoken ::= typename LP signed COMMA signed RP */ - //#line 257 "parse.y" - { - //yygotominor.yy0.z = yymsp[-5].minor.yy0.z; - //yygotominor.yy0.n = (int)( &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z ); - yygotominor.yy0.n = yymsp[-5].minor.yy0.z.Length - yymsp[0].minor.yy0.z.Length + 1; - yygotominor.yy0.z = yymsp[-5].minor.yy0.z.Substring(0, yygotominor.yy0.n); - } - //#line 2294 "parse.c" - break; - case 50: /* typename ::= typename ids */ - //#line 263 "parse.y" - { - //yygotominor.yy0.z=yymsp[-1].minor.yy0.z; yygotominor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z); - yygotominor.yy0.z = yymsp[-1].minor.yy0.z; - yygotominor.yy0.n = yymsp[0].minor.yy0.n + (int)(yymsp[-1].minor.yy0.z.Length - yymsp[0].minor.yy0.z.Length); - } - //#line 2299 "parse.c" - break; - case 57: /* ccons ::= DEFAULT term */ - case 59: /* ccons ::= DEFAULT PLUS term */ //yytestcase(yyruleno==59); - //#line 274 "parse.y" - { - sqlite3AddDefaultValue(pParse, yymsp[0].minor.yy118); - } - //#line 2308 "parse.c" - break; - case 58: /* ccons ::= DEFAULT LP expr RP */ - //#line 275 "parse.y" - { - sqlite3AddDefaultValue(pParse, yymsp[-1].minor.yy118); - } - //#line 2310 "parse.c" - break; - case 60: /* ccons ::= DEFAULT MINUS term */ - //#line 277 "parse.y" - { - ExprSpan v = new ExprSpan(); - v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy118.pExpr, 0, 0); - v.zStart = yymsp[-1].minor.yy0.z; - v.zEnd = yymsp[0].minor.yy118.zEnd; - sqlite3AddDefaultValue(pParse, v); - } - //#line 2321 "parse.c" - break; - case 61: /* ccons ::= DEFAULT id */ - //#line 284 "parse.y" - { - ExprSpan v = new ExprSpan(); - spanExpr(v, pParse, TK_STRING, yymsp[0].minor.yy0); - sqlite3AddDefaultValue(pParse, v); - } - //#line 2330 "parse.c" - break; - case 63: /* ccons ::= NOT NULL onconf */ - //#line 294 "parse.y" - { - sqlite3AddNotNull(pParse, yymsp[0].minor.yy4); - } - //#line 2335 "parse.c" - break; - case 64: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ - //#line 296 "parse.y" - { - sqlite3AddPrimaryKey(pParse, 0, yymsp[-1].minor.yy4, yymsp[0].minor.yy4, yymsp[-2].minor.yy4); - } - //#line 2340 "parse.c" - break; - case 65: /* ccons ::= UNIQUE onconf */ - //#line 297 "parse.y" - { - sqlite3CreateIndex(pParse, 0, 0, 0, 0, yymsp[0].minor.yy4, 0, 0, 0, 0); - } - //#line 2345 "parse.c" - break; - case 66: /* ccons ::= CHECK LP expr RP */ - //#line 298 "parse.y" - { - sqlite3AddCheckConstraint(pParse, yymsp[-1].minor.yy118.pExpr); - } - //#line 2350 "parse.c" - break; - case 67: /* ccons ::= REFERENCES nm idxlist_opt refargs */ - //#line 300 "parse.y" - { - sqlite3CreateForeignKey(pParse, 0, yymsp[-2].minor.yy0, yymsp[-1].minor.yy322, yymsp[0].minor.yy4); - } - //#line 2355 "parse.c" - break; - case 68: /* ccons ::= defer_subclause */ - //#line 301 "parse.y" - { - sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy4); - } - //#line 2360 "parse.c" - break; - case 69: /* ccons ::= COLLATE ids */ - //#line 302 "parse.y" - { - sqlite3AddCollateType(pParse, yymsp[0].minor.yy0); - } - //#line 2365 "parse.c" - break; - case 72: /* refargs ::= */ - //#line 315 "parse.y" - { - yygotominor.yy4 = OE_None * 0x0101; /* EV: R-19803-45884 */ - } - //#line 2370 "parse.c" - break; - case 73: /* refargs ::= refargs refarg */ - //#line 316 "parse.y" - { - yygotominor.yy4 = (yymsp[-1].minor.yy4 & ~yymsp[0].minor.yy215.mask) | yymsp[0].minor.yy215.value; - } - //#line 2375 "parse.c" - break; - case 74: /* refarg ::= MATCH nm */ - case 75: /* refarg ::= ON INSERT refact */ //yytestcase(yyruleno==75); - //#line 318 "parse.y" - { - yygotominor.yy215.value = 0; - yygotominor.yy215.mask = 0x000000; - } - //#line 2381 "parse.c" - break; - case 76: /* refarg ::= ON DELETE refact */ - //#line 320 "parse.y" - { - yygotominor.yy215.value = yymsp[0].minor.yy4; - yygotominor.yy215.mask = 0x0000ff; - } - //#line 2386 "parse.c" - break; - case 77: /* refarg ::= ON UPDATE refact */ - //#line 321 "parse.y" - { - yygotominor.yy215.value = yymsp[0].minor.yy4 << 8; - yygotominor.yy215.mask = 0x00ff00; - } - //#line 2391 "parse.c" - break; - case 78: /* refact ::= SET NULL */ - //#line 323 "parse.y" - { - yygotominor.yy4 = OE_SetNull; /* EV: R-33326-45252 */ - } - //#line 2396 "parse.c" - break; - case 79: /* refact ::= SET DEFAULT */ - //#line 324 "parse.y" - { - yygotominor.yy4 = OE_SetDflt; /* EV: R-33326-45252 */ - } - //#line 2401 "parse.c" - break; - case 80: /* refact ::= CASCADE */ - //#line 325 "parse.y" - { - yygotominor.yy4 = OE_Cascade; /* EV: R-33326-45252 */ - } - //#line 2406 "parse.c" - break; - case 81: /* refact ::= RESTRICT */ - //#line 326 "parse.y" - { - yygotominor.yy4 = OE_Restrict; /* EV: R-33326-45252 */ - } - //#line 2411 "parse.c" - break; - case 82: /* refact ::= NO ACTION */ - //#line 327 "parse.y" - { - yygotominor.yy4 = OE_None; /* EV: R-33326-45252 */ - } - //#line 2416 "parse.c" - break; - case 84: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ - case 99: /* defer_subclause_opt ::= defer_subclause */ //yytestcase(yyruleno==99); - case 101: /* onconf ::= ON CONFLICT resolvetype */ //yytestcase(yyruleno==101); - case 104: /* resolvetype ::= raisetype */ //yytestcase(yyruleno==104); - //#line 330 "parse.y" - { - yygotominor.yy4 = yymsp[0].minor.yy4; - } - //#line 2424 "parse.c" - break; - case 88: /* conslist_opt ::= */ - //#line 339 "parse.y" - { - yygotominor.yy0.n = 0; - yygotominor.yy0.z = null; - } - //#line 2429 "parse.c" - break; - case 89: /* conslist_opt ::= COMMA conslist */ - //#line 340 "parse.y" - { - yygotominor.yy0 = yymsp[-1].minor.yy0; - } - //#line 2434 "parse.c" - break; - case 94: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */ - //#line 346 "parse.y" - { - sqlite3AddPrimaryKey(pParse, yymsp[-3].minor.yy322, yymsp[0].minor.yy4, yymsp[-2].minor.yy4, 0); - } - //#line 2439 "parse.c" - break; - case 95: /* tcons ::= UNIQUE LP idxlist RP onconf */ - //#line 348 "parse.y" - { - sqlite3CreateIndex(pParse, 0, 0, 0, yymsp[-2].minor.yy322, yymsp[0].minor.yy4, 0, 0, 0, 0); - } - //#line 2444 "parse.c" - break; - case 96: /* tcons ::= CHECK LP expr RP onconf */ - //#line 350 "parse.y" - { - sqlite3AddCheckConstraint(pParse, yymsp[-2].minor.yy118.pExpr); - } - //#line 2449 "parse.c" - break; - case 97: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */ - //#line 352 "parse.y" - { - sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy322, yymsp[-3].minor.yy0, yymsp[-2].minor.yy322, yymsp[-1].minor.yy4); - sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy4); - } - //#line 2457 "parse.c" - break; - case 100: /* onconf ::= */ - //#line 366 "parse.y" - { - yygotominor.yy4 = OE_Default; - } - //#line 2462 "parse.c" - break; - case 102: /* orconf ::= */ - //#line 368 "parse.y" - { - yygotominor.yy210 = OE_Default; - } - //#line 2467 "parse.c" - break; - case 103: /* orconf ::= OR resolvetype */ - //#line 369 "parse.y" - { - yygotominor.yy210 = (u8)yymsp[0].minor.yy4; - } - //#line 2472 "parse.c" - break; - case 105: /* resolvetype ::= IGNORE */ - //#line 371 "parse.y" - { - yygotominor.yy4 = OE_Ignore; - } - //#line 2477 "parse.c" - break; - case 106: /* resolvetype ::= REPLACE */ - //#line 372 "parse.y" - { - yygotominor.yy4 = OE_Replace; - } - //#line 2482 "parse.c" - break; - case 107: /* cmd ::= DROP TABLE ifexists fullname */ - //#line 376 "parse.y" - { - sqlite3DropTable(pParse, yymsp[0].minor.yy259, 0, yymsp[-1].minor.yy4); - } - //#line 2489 "parse.c" - break; - case 110: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */ - //#line 386 "parse.y" - { - sqlite3CreateView(pParse, yymsp[-7].minor.yy0, yymsp[-3].minor.yy0, yymsp[-2].minor.yy0, yymsp[0].minor.yy387, yymsp[-6].minor.yy4, yymsp[-4].minor.yy4); - } - //#line 2496 "parse.c" - break; - case 111: /* cmd ::= DROP VIEW ifexists fullname */ - //#line 389 "parse.y" - { - sqlite3DropTable(pParse, yymsp[0].minor.yy259, 1, yymsp[-1].minor.yy4); - } - //#line 2503 "parse.c" - break; - case 112: /* cmd ::= select */ - //#line 396 "parse.y" - { - SelectDest dest = new SelectDest(SRT_Output, '\0', 0, 0, 0); - sqlite3Select(pParse, yymsp[0].minor.yy387, ref dest); - sqlite3SelectDelete(pParse.db, ref yymsp[0].minor.yy387); - } - //#line 2512 "parse.c" - break; - case 113: /* select ::= oneselect */ - //#line 407 "parse.y" - { - yygotominor.yy387 = yymsp[0].minor.yy387; - } - //#line 2517 "parse.c" - break; - case 114: /* select ::= select multiselect_op oneselect */ - //#line 409 "parse.y" - { - if (yymsp[0].minor.yy387 != null) { - yymsp[0].minor.yy387.op = (u8)yymsp[-1].minor.yy4; - yymsp[0].minor.yy387.pPrior = yymsp[-2].minor.yy387; - } else { - sqlite3SelectDelete(pParse.db, ref yymsp[-2].minor.yy387); - } - yygotominor.yy387 = yymsp[0].minor.yy387; - } - //#line 2530 "parse.c" - break; - case 116: /* multiselect_op ::= UNION ALL */ - //#line 420 "parse.y" - { - yygotominor.yy4 = TK_ALL; - } - //#line 2535 "parse.c" - break; - case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ - //#line 424 "parse.y" - { - yygotominor.yy387 = sqlite3SelectNew(pParse, yymsp[-6].minor.yy322, yymsp[-5].minor.yy259, yymsp[-4].minor.yy314, yymsp[-3].minor.yy322, yymsp[-2].minor.yy314, yymsp[-1].minor.yy322, yymsp[-7].minor.yy4, yymsp[0].minor.yy292.pLimit, yymsp[0].minor.yy292.pOffset); - } - //#line 2542 "parse.c" - break; - case 122: /* sclp ::= selcollist COMMA */ - case 247: /* idxlist_opt ::= LP idxlist RP */ //yytestcase(yyruleno==247); - //#line 445 "parse.y" - { - yygotominor.yy322 = yymsp[-1].minor.yy322; - } - //#line 2548 "parse.c" - break; - case 123: /* sclp ::= */ - case 151: /* orderby_opt ::= */ //yytestcase(yyruleno==151); - case 159: /* groupby_opt ::= */ //yytestcase(yyruleno==159); - case 240: /* exprlist ::= */ //yytestcase(yyruleno==240); - case 246: /* idxlist_opt ::= */ //yytestcase(yyruleno==246); - //#line 446 "parse.y" - { - yygotominor.yy322 = null; - } - //#line 2557 "parse.c" - break; - case 124: /* selcollist ::= sclp expr as */ - //#line 447 "parse.y" - { - yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy322, yymsp[-1].minor.yy118.pExpr); - if (yymsp[0].minor.yy0.n > 0) - sqlite3ExprListSetName(pParse, yygotominor.yy322, yymsp[0].minor.yy0, 1); - sqlite3ExprListSetSpan(pParse, yygotominor.yy322, yymsp[-1].minor.yy118); - } - //#line 2566 "parse.c" - break; - case 125: /* selcollist ::= sclp STAR */ - //#line 452 "parse.y" - { - Expr p = sqlite3Expr(pParse.db, TK_ALL, null); - yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy322, p); - } - //#line 2574 "parse.c" - break; - case 126: /* selcollist ::= sclp nm DOT STAR */ - //#line 456 "parse.y" - { - Expr pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, yymsp[0].minor.yy0); - Expr pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, yymsp[-2].minor.yy0); - Expr pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0); - yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy322, pDot); - } - //#line 2584 "parse.c" - break; - case 129: /* as ::= */ - //#line 469 "parse.y" - { - yygotominor.yy0.n = 0; - } - //#line 2589 "parse.c" - break; - case 130: /* from ::= */ - //#line 481 "parse.y" - { - yygotominor.yy259 = new SrcList(); - }//sqlite3DbMallocZero(pParse.db, sizeof(*yygotominor.yy259));} - //#line 2594 "parse.c" - break; - case 131: /* from ::= FROM seltablist */ - //#line 482 "parse.y" - { - yygotominor.yy259 = yymsp[0].minor.yy259; - sqlite3SrcListShiftJoinType(yygotominor.yy259); - } - //#line 2602 "parse.c" - break; - case 132: /* stl_prefix ::= seltablist joinop */ - //#line 490 "parse.y" - { - yygotominor.yy259 = yymsp[-1].minor.yy259; - if (ALWAYS(yygotominor.yy259 != null && yygotominor.yy259.nSrc > 0)) - yygotominor.yy259.a[yygotominor.yy259.nSrc - 1].jointype = (u8)yymsp[0].minor.yy4; - } - //#line 2610 "parse.c" - break; - case 133: /* stl_prefix ::= */ - //#line 494 "parse.y" - { - yygotominor.yy259 = null; - } - //#line 2615 "parse.c" - break; - case 134: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ - //#line 495 "parse.y" - { - yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse, yymsp[-6].minor.yy259, yymsp[-5].minor.yy0, yymsp[-4].minor.yy0, yymsp[-3].minor.yy0, 0, yymsp[-1].minor.yy314, yymsp[0].minor.yy384); - sqlite3SrcListIndexedBy(pParse, yygotominor.yy259, yymsp[-2].minor.yy0); - } - //#line 2623 "parse.c" - break; - case 135: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ - //#line 501 "parse.y" - { - yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse, yymsp[-6].minor.yy259, 0, 0, yymsp[-2].minor.yy0, yymsp[-4].minor.yy387, yymsp[-1].minor.yy314, yymsp[0].minor.yy384); - } - //#line 2630 "parse.c" - break; - case 136: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ - //#line 505 "parse.y" - { - if (yymsp[-6].minor.yy259 == null && yymsp[-2].minor.yy0.n == 0 && yymsp[-1].minor.yy314 == null && yymsp[0].minor.yy384 == null) { - yygotominor.yy259 = yymsp[-4].minor.yy259; - } else { - Select pSubquery; - sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy259); - pSubquery = sqlite3SelectNew(pParse, 0, yymsp[-4].minor.yy259, 0, 0, 0, 0, 0, 0, 0); - yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse, yymsp[-6].minor.yy259, 0, 0, yymsp[-2].minor.yy0, pSubquery, yymsp[-1].minor.yy314, yymsp[0].minor.yy384); - } - } - //#line 2644 "parse.c" - break; - case 137: /* dbnm ::= */ - case 146: /* indexed_opt ::= */ //yytestcase(yyruleno==146); - //#line 530 "parse.y" - { - yygotominor.yy0.z = null; - yygotominor.yy0.n = 0; - } - //#line 2650 "parse.c" - break; - case 139: /* fullname ::= nm dbnm */ - //#line 535 "parse.y" - { - yygotominor.yy259 = sqlite3SrcListAppend(pParse.db, 0, yymsp[-1].minor.yy0, yymsp[0].minor.yy0); - } - //#line 2655 "parse.c" - break; - case 140: /* joinop ::= COMMA|JOIN */ - //#line 539 "parse.y" - { - yygotominor.yy4 = JT_INNER; - } - //#line 2660 "parse.c" - break; - case 141: /* joinop ::= JOIN_KW JOIN */ - //#line 540 "parse.y" - { - yygotominor.yy4 = sqlite3JoinType(pParse, yymsp[-1].minor.yy0, 0, 0); - } - //#line 2665 "parse.c" - break; - case 142: /* joinop ::= JOIN_KW nm JOIN */ - //#line 541 "parse.y" - { - yygotominor.yy4 = sqlite3JoinType(pParse, yymsp[-2].minor.yy0, yymsp[-1].minor.yy0, 0); - } - //#line 2670 "parse.c" - break; - case 143: /* joinop ::= JOIN_KW nm nm JOIN */ - //#line 543 "parse.y" - { - yygotominor.yy4 = sqlite3JoinType(pParse, yymsp[-3].minor.yy0, yymsp[-2].minor.yy0, yymsp[-1].minor.yy0); - } - //#line 2675 "parse.c" - break; - case 144: /* on_opt ::= ON expr */ - case 155: /* sortitem ::= expr */ //yytestcase(yyruleno==155); - case 162: /* having_opt ::= HAVING expr */ //yytestcase(yyruleno==162); - case 169: /* where_opt ::= WHERE expr */ //yytestcase(yyruleno==169); - case 235: /* case_else ::= ELSE expr */ //yytestcase(yyruleno==235); - case 237: /* case_operand ::= expr */ //yytestcase(yyruleno==237); - //#line 547 "parse.y" - { - yygotominor.yy314 = yymsp[0].minor.yy118.pExpr; - } - //#line 2685 "parse.c" - break; - case 145: /* on_opt ::= */ - case 161: /* having_opt ::= */ //yytestcase(yyruleno==161); - case 168: /* where_opt ::= */ //yytestcase(yyruleno==168); - case 236: /* case_else ::= */ //yytestcase(yyruleno==236); - case 238: /* case_operand ::= */ //yytestcase(yyruleno==238); - //#line 548 "parse.y" - { - yygotominor.yy314 = null; - } - //#line 2694 "parse.c" - break; - case 148: /* indexed_opt ::= NOT INDEXED */ - //#line 563 "parse.y" - { - yygotominor.yy0.z = null; - yygotominor.yy0.n = 1; - } - //#line 2699 "parse.c" - break; - case 149: /* using_opt ::= USING LP inscollist RP */ - case 181: /* inscollist_opt ::= LP inscollist RP */ //yytestcase(yyruleno==181); - //#line 567 "parse.y" - { - yygotominor.yy384 = yymsp[-1].minor.yy384; - } - //#line 2705 "parse.c" - break; - case 150: /* using_opt ::= */ - case 180: /* inscollist_opt ::= */ //yytestcase(yyruleno==180); - //#line 568 "parse.y" - { - yygotominor.yy384 = null; - } - //#line 2711 "parse.c" - break; - case 152: /* orderby_opt ::= ORDER BY sortlist */ - case 160: /* groupby_opt ::= GROUP BY nexprlist */ //yytestcase(yyruleno==160); - case 239: /* exprlist ::= nexprlist */ //yytestcase(yyruleno==239); - //#line 579 "parse.y" - { - yygotominor.yy322 = yymsp[0].minor.yy322; - } - //#line 2718 "parse.c" - break; - case 153: /* sortlist ::= sortlist COMMA sortitem sortorder */ - //#line 580 "parse.y" - { - yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy322, yymsp[-1].minor.yy314); - if (yygotominor.yy322 != null) - yygotominor.yy322.a[yygotominor.yy322.nExpr - 1].sortOrder = (u8)yymsp[0].minor.yy4; - } - //#line 2726 "parse.c" - break; - case 154: /* sortlist ::= sortitem sortorder */ - //#line 584 "parse.y" - { - yygotominor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[-1].minor.yy314); - if (yygotominor.yy322 != null && ALWAYS(yygotominor.yy322.a != null)) - yygotominor.yy322.a[0].sortOrder = (u8)yymsp[0].minor.yy4; - } - //#line 2734 "parse.c" - break; - case 156: /* sortorder ::= ASC */ - case 158: /* sortorder ::= */ //yytestcase(yyruleno==158); - //#line 592 "parse.y" - { - yygotominor.yy4 = SQLITE_SO_ASC; - } - //#line 2740 "parse.c" - break; - case 157: /* sortorder ::= DESC */ - //#line 593 "parse.y" - { - yygotominor.yy4 = SQLITE_SO_DESC; - } - //#line 2745 "parse.c" - break; - case 163: /* limit_opt ::= */ - //#line 619 "parse.y" - { - yygotominor.yy292.pLimit = null; - yygotominor.yy292.pOffset = null; - } - //#line 2750 "parse.c" - break; - case 164: /* limit_opt ::= LIMIT expr */ - //#line 620 "parse.y" - { - yygotominor.yy292.pLimit = yymsp[0].minor.yy118.pExpr; - yygotominor.yy292.pOffset = null; - } - //#line 2755 "parse.c" - break; - case 165: /* limit_opt ::= LIMIT expr OFFSET expr */ - //#line 622 "parse.y" - { - yygotominor.yy292.pLimit = yymsp[-2].minor.yy118.pExpr; - yygotominor.yy292.pOffset = yymsp[0].minor.yy118.pExpr; - } - //#line 2760 "parse.c" - break; - case 166: /* limit_opt ::= LIMIT expr COMMA expr */ - //#line 624 "parse.y" - { - yygotominor.yy292.pOffset = yymsp[-2].minor.yy118.pExpr; - yygotominor.yy292.pLimit = yymsp[0].minor.yy118.pExpr; - } - //#line 2765 "parse.c" - break; - case 167: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */ - //#line 637 "parse.y" - { - sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy259, yymsp[-1].minor.yy0); - sqlite3DeleteFrom(pParse, yymsp[-2].minor.yy259, yymsp[0].minor.yy314); - } - //#line 2773 "parse.c" - break; - case 170: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */ - //#line 660 "parse.y" - { - sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy259, yymsp[-3].minor.yy0); - sqlite3ExprListCheckLength(pParse, yymsp[-1].minor.yy322, "set list"); - sqlite3Update(pParse, yymsp[-4].minor.yy259, yymsp[-1].minor.yy322, yymsp[0].minor.yy314, yymsp[-5].minor.yy210); - } - //#line 2782 "parse.c" - break; - case 171: /* setlist ::= setlist COMMA nm EQ expr */ - //#line 670 "parse.y" - { - yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[0].minor.yy118.pExpr); - sqlite3ExprListSetName(pParse, yygotominor.yy322, yymsp[-2].minor.yy0, 1); - } - //#line 2790 "parse.c" - break; - case 172: /* setlist ::= nm EQ expr */ - //#line 674 "parse.y" - { - yygotominor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy118.pExpr); - sqlite3ExprListSetName(pParse, yygotominor.yy322, yymsp[-2].minor.yy0, 1); - } - //#line 2798 "parse.c" - break; - case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP */ - //#line 683 "parse.y" - { - sqlite3Insert(pParse, yymsp[-5].minor.yy259, yymsp[-1].minor.yy322, 0, yymsp[-4].minor.yy384, yymsp[-7].minor.yy210); - } - //#line 2803 "parse.c" - break; - case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */ - //#line 685 "parse.y" - { - sqlite3Insert(pParse, yymsp[-2].minor.yy259, 0, yymsp[0].minor.yy387, yymsp[-1].minor.yy384, yymsp[-4].minor.yy210); - } - //#line 2808 "parse.c" - break; - case 175: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */ - //#line 687 "parse.y" - { - sqlite3Insert(pParse, yymsp[-3].minor.yy259, 0, 0, yymsp[-2].minor.yy384, yymsp[-5].minor.yy210); - } - //#line 2813 "parse.c" - break; - case 176: /* insert_cmd ::= INSERT orconf */ - //#line 690 "parse.y" - { - yygotominor.yy210 = yymsp[0].minor.yy210; - } - //#line 2818 "parse.c" - break; - case 177: /* insert_cmd ::= REPLACE */ - //#line 691 "parse.y" - { - yygotominor.yy210 = OE_Replace; - } - //#line 2823 "parse.c" - break; - case 178: /* itemlist ::= itemlist COMMA expr */ - case 241: /* nexprlist ::= nexprlist COMMA expr */ //yytestcase(yyruleno==241); - //#line 698 "parse.y" - { - yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy322, yymsp[0].minor.yy118.pExpr); - } - //#line 2829 "parse.c" - break; - case 179: /* itemlist ::= expr */ - case 242: /* nexprlist ::= expr */ //yytestcase(yyruleno==242); - //#line 700 "parse.y" - { - yygotominor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy118.pExpr); - } - //#line 2835 "parse.c" - break; - case 182: /* inscollist ::= inscollist COMMA nm */ - //#line 710 "parse.y" - { - yygotominor.yy384 = sqlite3IdListAppend(pParse.db, yymsp[-2].minor.yy384, yymsp[0].minor.yy0); - } - //#line 2840 "parse.c" - break; - case 183: /* inscollist ::= nm */ - //#line 712 "parse.y" - { - yygotominor.yy384 = sqlite3IdListAppend(pParse.db, 0, yymsp[0].minor.yy0); - } - //#line 2845 "parse.c" - break; - case 184: /* expr ::= term */ - //#line 743 "parse.y" - { - yygotominor.yy118 = yymsp[0].minor.yy118; - } - //#line 2850 "parse.c" - break; - case 185: /* expr ::= LP expr RP */ - //#line 744 "parse.y" - { - yygotominor.yy118.pExpr = yymsp[-1].minor.yy118.pExpr; - spanSet(yygotominor.yy118, yymsp[-2].minor.yy0, yymsp[0].minor.yy0); - } - //#line 2855 "parse.c" - break; - case 186: /* term ::= NULL */ - case 191: /* term ::= INTEGER|FLOAT|BLOB */ //yytestcase(yyruleno==191); - case 192: /* term ::= STRING */ //yytestcase(yyruleno==192); - //#line 745 "parse.y" - { - spanExpr(yygotominor.yy118, pParse, yymsp[0].major, yymsp[0].minor.yy0); - } - //#line 2862 "parse.c" - break; - case 187: /* expr ::= id */ - case 188: /* expr ::= JOIN_KW */ //yytestcase(yyruleno==188); - //#line 746 "parse.y" - { - spanExpr(yygotominor.yy118, pParse, TK_ID, yymsp[0].minor.yy0); - } - //#line 2868 "parse.c" - break; - case 189: /* expr ::= nm DOT nm */ - //#line 748 "parse.y" - { - Expr temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, yymsp[-2].minor.yy0); - Expr temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, yymsp[0].minor.yy0); - yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0); - spanSet(yygotominor.yy118, yymsp[-2].minor.yy0, yymsp[0].minor.yy0); - } - //#line 2878 "parse.c" - break; - case 190: /* expr ::= nm DOT nm DOT nm */ - //#line 754 "parse.y" - { - Expr temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, yymsp[-4].minor.yy0); - Expr temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, yymsp[-2].minor.yy0); - Expr temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, yymsp[0].minor.yy0); - Expr temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0); - yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0); - spanSet(yygotominor.yy118, yymsp[-4].minor.yy0, yymsp[0].minor.yy0); - } - //#line 2890 "parse.c" - break; - case 193: /* expr ::= REGISTER */ - //#line 764 "parse.y" - { - /* When doing a nested parse, one can include terms in an expression - ** that look like this: #1 #2 ... These terms refer to registers - ** in the virtual machine. #N is the N-th register. */ - if (pParse.nested == 0) { - sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", yymsp[0].minor.yy0); - yygotominor.yy118.pExpr = null; - } else { - yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, yymsp[0].minor.yy0); - if (yygotominor.yy118.pExpr != null) - sqlite3GetInt32(yymsp[0].minor.yy0.z, 1, ref yygotominor.yy118.pExpr.iTable); - } - spanSet(yygotominor.yy118, yymsp[0].minor.yy0, yymsp[0].minor.yy0); - } - //#line 2907 "parse.c" - break; - case 194: /* expr ::= VARIABLE */ - //#line 777 "parse.y" - { - spanExpr(yygotominor.yy118, pParse, TK_VARIABLE, yymsp[0].minor.yy0); - sqlite3ExprAssignVarNumber(pParse, yygotominor.yy118.pExpr); - spanSet(yygotominor.yy118, yymsp[0].minor.yy0, yymsp[0].minor.yy0); - } - //#line 2916 "parse.c" - break; - case 195: /* expr ::= expr COLLATE ids */ - //#line 782 "parse.y" - { - yygotominor.yy118.pExpr = sqlite3ExprSetCollByToken(pParse, yymsp[-2].minor.yy118.pExpr, yymsp[0].minor.yy0); - yygotominor.yy118.zStart = yymsp[-2].minor.yy118.zStart; - yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring(yymsp[0].minor.yy0.n);//z[yymsp[0].minor.yy0.n]; - } - //#line 2925 "parse.c" - break; - case 196: /* expr ::= CAST LP expr AS typetoken RP */ - //#line 788 "parse.y" - { - yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy118.pExpr, 0, yymsp[-1].minor.yy0); - spanSet(yygotominor.yy118, yymsp[-5].minor.yy0, yymsp[0].minor.yy0); - } - //#line 2933 "parse.c" - break; - case 197: /* expr ::= ID LP distinct exprlist RP */ - //#line 793 "parse.y" - { - if (yymsp[-1].minor.yy322 != null && yymsp[-1].minor.yy322.nExpr > pParse.db.aLimit[SQLITE_LIMIT_FUNCTION_ARG]) { - sqlite3ErrorMsg(pParse, "too many arguments on function %T", yymsp[-4].minor.yy0); - } - yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy322, yymsp[-4].minor.yy0); - spanSet(yygotominor.yy118, yymsp[-4].minor.yy0, yymsp[0].minor.yy0); - if (yymsp[-2].minor.yy4 != 0 && yygotominor.yy118.pExpr != null) { - yygotominor.yy118.pExpr.flags |= EP_Distinct; - } - } - //#line 2947 "parse.c" - break; - case 198: /* expr ::= ID LP STAR RP */ - //#line 803 "parse.y" - { - yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, 0, yymsp[-3].minor.yy0); - spanSet(yygotominor.yy118, yymsp[-3].minor.yy0, yymsp[0].minor.yy0); - } - //#line 2955 "parse.c" - break; - case 199: /* term ::= CTIME_KW */ - //#line 807 "parse.y" - { - /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are - ** treated as functions that return constants */ - yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, 0, yymsp[0].minor.yy0); - if (yygotominor.yy118.pExpr != null) { - yygotominor.yy118.pExpr.op = TK_CONST_FUNC; - } - spanSet(yygotominor.yy118, yymsp[0].minor.yy0, yymsp[0].minor.yy0); - } - //#line 2968 "parse.c" - break; - case 200: /* expr ::= expr AND expr */ - case 201: /* expr ::= expr OR expr */ //yytestcase(yyruleno==201); - case 202: /* expr ::= expr LT|GT|GE|LE expr */ //yytestcase(yyruleno==202); - case 203: /* expr ::= expr EQ|NE expr */ //yytestcase(yyruleno==203); - case 204: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ //yytestcase(yyruleno==204); - case 205: /* expr ::= expr PLUS|MINUS expr */ //yytestcase(yyruleno==205); - case 206: /* expr ::= expr STAR|SLASH|REM expr */ //yytestcase(yyruleno==206); - case 207: /* expr ::= expr CONCAT expr */ //yytestcase(yyruleno==207); - //#line 834 "parse.y" - { - spanBinaryExpr(yygotominor.yy118, pParse, yymsp[-1].major, yymsp[-2].minor.yy118, yymsp[0].minor.yy118); - } - //#line 2980 "parse.c" - break; - case 208: /* likeop ::= LIKE_KW */ - case 210: /* likeop ::= MATCH */ //yytestcase(yyruleno==210); - //#line 847 "parse.y" - { - yygotominor.yy342.eOperator = yymsp[0].minor.yy0; - yygotominor.yy342.not = false; - } - //#line 2986 "parse.c" - break; - case 209: /* likeop ::= NOT LIKE_KW */ - case 211: /* likeop ::= NOT MATCH */ //yytestcase(yyruleno==211); - //#line 848 "parse.y" - { - yygotominor.yy342.eOperator = yymsp[0].minor.yy0; - yygotominor.yy342.not = true; - } - //#line 2992 "parse.c" - break; - case 212: /* expr ::= expr likeop expr */ - //#line 851 "parse.y" - { - ExprList pList; - pList = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy118.pExpr); - pList = sqlite3ExprListAppend(pParse, pList, yymsp[-2].minor.yy118.pExpr); - yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, pList, yymsp[-1].minor.yy342.eOperator); - if (yymsp[-1].minor.yy342.not) - yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); - yygotominor.yy118.zStart = yymsp[-2].minor.yy118.zStart; - yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; - if (yygotominor.yy118.pExpr != null) - yygotominor.yy118.pExpr.flags |= EP_InfixFunc; - } - //#line 3006 "parse.c" - break; - case 213: /* expr ::= expr likeop expr ESCAPE expr */ - //#line 861 "parse.y" - { - ExprList pList; - pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy118.pExpr); - pList = sqlite3ExprListAppend(pParse, pList, yymsp[-4].minor.yy118.pExpr); - pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy118.pExpr); - yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, pList, yymsp[-3].minor.yy342.eOperator); - if (yymsp[-3].minor.yy342.not) - yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); - yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; - yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; - if (yygotominor.yy118.pExpr != null) - yygotominor.yy118.pExpr.flags |= EP_InfixFunc; - } - //#line 3021 "parse.c" - break; - case 214: /* expr ::= expr ISNULL|NOTNULL */ - //#line 889 "parse.y" - { - spanUnaryPostfix(yygotominor.yy118, pParse, yymsp[0].major, yymsp[-1].minor.yy118, yymsp[0].minor.yy0); - } - //#line 3026 "parse.c" - break; - case 215: /* expr ::= expr NOT NULL */ - //#line 890 "parse.y" - { - spanUnaryPostfix(yygotominor.yy118, pParse, TK_NOTNULL, yymsp[-2].minor.yy118, yymsp[0].minor.yy0); - } - //#line 3031 "parse.c" - break; - case 216: /* expr ::= expr IS expr */ - //#line 911 "parse.y" - { - spanBinaryExpr(yygotominor.yy118, pParse, TK_IS, yymsp[-2].minor.yy118, yymsp[0].minor.yy118); - binaryToUnaryIfNull(pParse, yymsp[0].minor.yy118.pExpr, yygotominor.yy118.pExpr, TK_ISNULL); - } - //#line 3039 "parse.c" - break; - case 217: /* expr ::= expr IS NOT expr */ - //#line 915 "parse.y" - { - spanBinaryExpr(yygotominor.yy118, pParse, TK_ISNOT, yymsp[-3].minor.yy118, yymsp[0].minor.yy118); - binaryToUnaryIfNull(pParse, yymsp[0].minor.yy118.pExpr, yygotominor.yy118.pExpr, TK_NOTNULL); - } - //#line 3047 "parse.c" - break; - case 218: /* expr ::= NOT expr */ - case 219: /* expr ::= BITNOT expr */ //yytestcase(yyruleno==219); - //#line 938 "parse.y" - { - spanUnaryPrefix(yygotominor.yy118, pParse, yymsp[-1].major, yymsp[0].minor.yy118, yymsp[-1].minor.yy0); - } - //#line 3053 "parse.c" - break; - case 220: /* expr ::= MINUS expr */ - //#line 941 "parse.y" - { - spanUnaryPrefix(yygotominor.yy118, pParse, TK_UMINUS, yymsp[0].minor.yy118, yymsp[-1].minor.yy0); - } - //#line 3058 "parse.c" - break; - case 221: /* expr ::= PLUS expr */ - //#line 943 "parse.y" - { - spanUnaryPrefix(yygotominor.yy118, pParse, TK_UPLUS, yymsp[0].minor.yy118, yymsp[-1].minor.yy0); - } - //#line 3063 "parse.c" - break; - case 224: /* expr ::= expr between_op expr AND expr */ - //#line 948 "parse.y" - { - ExprList pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy118.pExpr); - pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy118.pExpr); - yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy118.pExpr, 0, 0); - if (yygotominor.yy118.pExpr != null) { - yygotominor.yy118.pExpr.x.pList = pList; - } else { - sqlite3ExprListDelete(pParse.db, ref pList); - } - if (yymsp[-3].minor.yy4 != 0) - yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); - yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; - yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; - } - //#line 3080 "parse.c" - break; - case 227: /* expr ::= expr in_op LP exprlist RP */ - //#line 965 "parse.y" - { - if (yymsp[-1].minor.yy322 == null) { - /* Expressions of the form - ** - ** expr1 IN () - ** expr1 NOT IN () - ** - ** simplify to constants 0 (false) and 1 (true), respectively, - ** regardless of the value of expr1. - */ - yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, sqlite3IntTokens[yymsp[-3].minor.yy4]); - sqlite3ExprDelete(pParse.db, ref yymsp[-4].minor.yy118.pExpr); - } else { - yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy118.pExpr, 0, 0); - if (yygotominor.yy118.pExpr != null) { - yygotominor.yy118.pExpr.x.pList = yymsp[-1].minor.yy322; - sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr); - } else { - sqlite3ExprListDelete(pParse.db, ref yymsp[-1].minor.yy322); - } - if (yymsp[-3].minor.yy4 != 0) - yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); - } - yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; - yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring(yymsp[0].minor.yy0.n);//[yymsp[0].minor.yy0.n]; - } - //#line 3109 "parse.c" - break; - case 228: /* expr ::= LP select RP */ - //#line 990 "parse.y" - { - yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0); - if (yygotominor.yy118.pExpr != null) { - yygotominor.yy118.pExpr.x.pSelect = yymsp[-1].minor.yy387; - ExprSetProperty(yygotominor.yy118.pExpr, EP_xIsSelect); - sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr); - } else { - sqlite3SelectDelete(pParse.db, ref yymsp[-1].minor.yy387); - } - yygotominor.yy118.zStart = yymsp[-2].minor.yy0.z; - yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring(yymsp[0].minor.yy0.n);//z[yymsp[0].minor.yy0.n]; - } - //#line 3125 "parse.c" - break; - case 229: /* expr ::= expr in_op LP select RP */ - //#line 1002 "parse.y" - { - yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy118.pExpr, 0, 0); - if (yygotominor.yy118.pExpr != null) { - yygotominor.yy118.pExpr.x.pSelect = yymsp[-1].minor.yy387; - ExprSetProperty(yygotominor.yy118.pExpr, EP_xIsSelect); - sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr); - } else { - sqlite3SelectDelete(pParse.db, ref yymsp[-1].minor.yy387); - } - if (yymsp[-3].minor.yy4 != 0) - yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); - yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; - yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring(yymsp[0].minor.yy0.n);//z[yymsp[0].minor.yy0.n]; - } - //#line 3142 "parse.c" - break; - case 230: /* expr ::= expr in_op nm dbnm */ - //#line 1015 "parse.y" - { - SrcList pSrc = sqlite3SrcListAppend(pParse.db, 0, yymsp[-1].minor.yy0, yymsp[0].minor.yy0); - yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy118.pExpr, 0, 0); - if (yygotominor.yy118.pExpr != null) { - yygotominor.yy118.pExpr.x.pSelect = sqlite3SelectNew(pParse, 0, pSrc, 0, 0, 0, 0, 0, 0, 0); - ExprSetProperty(yygotominor.yy118.pExpr, EP_xIsSelect); - sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr); - } else { - sqlite3SrcListDelete(pParse.db, ref pSrc); - } - if (yymsp[-2].minor.yy4 != 0) - yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); - yygotominor.yy118.zStart = yymsp[-3].minor.yy118.zStart; - yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z != null ? yymsp[0].minor.yy0.z.Substring(yymsp[0].minor.yy0.n) : yymsp[-1].minor.yy0.z.Substring(yymsp[-1].minor.yy0.n); - } - //#line 3160 "parse.c" - break; - case 231: /* expr ::= EXISTS LP select RP */ - //#line 1029 "parse.y" - { - Expr p = yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0); - if (p != null) { - p.x.pSelect = yymsp[-1].minor.yy387; - ExprSetProperty(p, EP_xIsSelect); - sqlite3ExprSetHeight(pParse, p); - } else { - sqlite3SelectDelete(pParse.db, ref yymsp[-1].minor.yy387); - } - yygotominor.yy118.zStart = yymsp[-3].minor.yy0.z; - yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring(yymsp[0].minor.yy0.n); //z[yymsp[0].minor.yy0.n]; - } - //#line 3176 "parse.c" - break; - case 232: /* expr ::= CASE case_operand case_exprlist case_else END */ - //#line 1044 "parse.y" - { - yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy314, yymsp[-1].minor.yy314, 0); - if (yygotominor.yy118.pExpr != null) { - yygotominor.yy118.pExpr.x.pList = yymsp[-2].minor.yy322; - sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr); - } else { - sqlite3ExprListDelete(pParse.db, ref yymsp[-2].minor.yy322); - } - yygotominor.yy118.zStart = yymsp[-4].minor.yy0.z; - yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring(yymsp[0].minor.yy0.n);//z[yymsp[0].minor.yy0.n]; - } - //#line 3191 "parse.c" - break; - case 233: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ - //#line 1057 "parse.y" - { - yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[-2].minor.yy118.pExpr); - yygotominor.yy322 = sqlite3ExprListAppend(pParse, yygotominor.yy322, yymsp[0].minor.yy118.pExpr); - } - //#line 3199 "parse.c" - break; - case 234: /* case_exprlist ::= WHEN expr THEN expr */ - //#line 1061 "parse.y" - { - yygotominor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy118.pExpr); - yygotominor.yy322 = sqlite3ExprListAppend(pParse, yygotominor.yy322, yymsp[0].minor.yy118.pExpr); - } - //#line 3207 "parse.c" - break; - case 243: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */ - //#line 1090 "parse.y" - { - sqlite3CreateIndex(pParse, yymsp[-6].minor.yy0, yymsp[-5].minor.yy0, - sqlite3SrcListAppend(pParse.db, 0, yymsp[-3].minor.yy0, 0), yymsp[-1].minor.yy322, yymsp[-9].minor.yy4, - yymsp[-10].minor.yy0, yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy4); - } - //#line 3216 "parse.c" - break; - case 244: /* uniqueflag ::= UNIQUE */ - case 298: /* raisetype ::= ABORT */ //yytestcase(yyruleno==298); - //#line 1097 "parse.y" - { - yygotominor.yy4 = OE_Abort; - } - //#line 3222 "parse.c" - break; - case 245: /* uniqueflag ::= */ - //#line 1098 "parse.y" - { - yygotominor.yy4 = OE_None; - } - //#line 3227 "parse.c" - break; - case 248: /* idxlist ::= idxlist COMMA nm collate sortorder */ - //#line 1107 "parse.y" - { - Expr p = null; - if (yymsp[-1].minor.yy0.n > 0) { - p = sqlite3Expr(pParse.db, TK_COLUMN, null); - sqlite3ExprSetCollByToken(pParse, p, yymsp[-1].minor.yy0); - } - yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, p); - sqlite3ExprListSetName(pParse, yygotominor.yy322, yymsp[-2].minor.yy0, 1); - sqlite3ExprListCheckLength(pParse, yygotominor.yy322, "index"); - if (yygotominor.yy322 != null) - yygotominor.yy322.a[yygotominor.yy322.nExpr - 1].sortOrder = (u8)yymsp[0].minor.yy4; - } - //#line 3242 "parse.c" - break; - case 249: /* idxlist ::= nm collate sortorder */ - //#line 1118 "parse.y" - { - Expr p = null; - if (yymsp[-1].minor.yy0.n > 0) { - p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0); - sqlite3ExprSetCollByToken(pParse, p, yymsp[-1].minor.yy0); - } - yygotominor.yy322 = sqlite3ExprListAppend(pParse, 0, p); - sqlite3ExprListSetName(pParse, yygotominor.yy322, yymsp[-2].minor.yy0, 1); - sqlite3ExprListCheckLength(pParse, yygotominor.yy322, "index"); - if (yygotominor.yy322 != null) - yygotominor.yy322.a[yygotominor.yy322.nExpr - 1].sortOrder = (u8)yymsp[0].minor.yy4; - } - //#line 3257 "parse.c" - break; - case 250: /* collate ::= */ - //#line 1131 "parse.y" - { - yygotominor.yy0.z = null; - yygotominor.yy0.n = 0; - } - //#line 3262 "parse.c" - break; - case 252: /* cmd ::= DROP INDEX ifexists fullname */ - //#line 1137 "parse.y" - { - sqlite3DropIndex(pParse, yymsp[0].minor.yy259, yymsp[-1].minor.yy4); - } - //#line 3267 "parse.c" - break; - case 253: /* cmd ::= VACUUM */ - case 254: /* cmd ::= VACUUM nm */ //yytestcase(yyruleno==254); - //#line 1143 "parse.y" - { - sqlite3Vacuum(pParse); - } - //#line 3273 "parse.c" - break; - case 255: /* cmd ::= PRAGMA nm dbnm */ - //#line 1151 "parse.y" - { - sqlite3Pragma(pParse, yymsp[-1].minor.yy0, yymsp[0].minor.yy0, 0, 0); - } - //#line 3278 "parse.c" - break; - case 256: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ - //#line 1152 "parse.y" - { - sqlite3Pragma(pParse, yymsp[-3].minor.yy0, yymsp[-2].minor.yy0, yymsp[0].minor.yy0, 0); - } - //#line 3283 "parse.c" - break; - case 257: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ - //#line 1153 "parse.y" - { - sqlite3Pragma(pParse, yymsp[-4].minor.yy0, yymsp[-3].minor.yy0, yymsp[-1].minor.yy0, 0); - } - //#line 3288 "parse.c" - break; - case 258: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ - //#line 1155 "parse.y" - { - sqlite3Pragma(pParse, yymsp[-3].minor.yy0, yymsp[-2].minor.yy0, yymsp[0].minor.yy0, 1); - } - //#line 3293 "parse.c" - break; - case 259: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ - //#line 1157 "parse.y" - { - sqlite3Pragma(pParse, yymsp[-4].minor.yy0, yymsp[-3].minor.yy0, yymsp[-1].minor.yy0, 1); - } - //#line 3298 "parse.c" - break; - case 270: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ - //#line 1175 "parse.y" - { - Token all = new Token(); - //all.z = yymsp[-3].minor.yy0.z; - //all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; - all.n = (int)(yymsp[-3].minor.yy0.z.Length - yymsp[0].minor.yy0.z.Length) + yymsp[0].minor.yy0.n; - all.z = yymsp[-3].minor.yy0.z.Substring(0, all.n); - sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy203, all); - } - //#line 3308 "parse.c" - break; - case 271: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ - //#line 1184 "parse.y" - { - sqlite3BeginTrigger(pParse, yymsp[-7].minor.yy0, yymsp[-6].minor.yy0, yymsp[-5].minor.yy4, yymsp[-4].minor.yy90.a, yymsp[-4].minor.yy90.b, yymsp[-2].minor.yy259, yymsp[0].minor.yy314, yymsp[-10].minor.yy4, yymsp[-8].minor.yy4); - yygotominor.yy0 = (yymsp[-6].minor.yy0.n == 0 ? yymsp[-7].minor.yy0 : yymsp[-6].minor.yy0); - } - //#line 3316 "parse.c" - break; - case 272: /* trigger_time ::= BEFORE */ - case 275: /* trigger_time ::= */ //yytestcase(yyruleno==275); - //#line 1190 "parse.y" - { - yygotominor.yy4 = TK_BEFORE; - } - //#line 3322 "parse.c" - break; - case 273: /* trigger_time ::= AFTER */ - //#line 1191 "parse.y" - { - yygotominor.yy4 = TK_AFTER; - } - //#line 3327 "parse.c" - break; - case 274: /* trigger_time ::= INSTEAD OF */ - //#line 1192 "parse.y" - { - yygotominor.yy4 = TK_INSTEAD; - } - //#line 3332 "parse.c" - break; - case 276: /* trigger_event ::= DELETE|INSERT */ - case 277: /* trigger_event ::= UPDATE */ //yytestcase(yyruleno==277); - //#line 1197 "parse.y" - { - yygotominor.yy90.a = yymsp[0].major; - yygotominor.yy90.b = null; - } - //#line 3338 "parse.c" - break; - case 278: /* trigger_event ::= UPDATE OF inscollist */ - //#line 1199 "parse.y" - { - yygotominor.yy90.a = TK_UPDATE; - yygotominor.yy90.b = yymsp[0].minor.yy384; - } - //#line 3343 "parse.c" - break; - case 281: /* when_clause ::= */ - case 303: /* key_opt ::= */ //yytestcase(yyruleno==303); - //#line 1206 "parse.y" - { - yygotominor.yy314 = null; - } - //#line 3349 "parse.c" - break; - case 282: /* when_clause ::= WHEN expr */ - case 304: /* key_opt ::= KEY expr */ //yytestcase(yyruleno==304); - //#line 1207 "parse.y" - { - yygotominor.yy314 = yymsp[0].minor.yy118.pExpr; - } - //#line 3355 "parse.c" - break; - case 283: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ - //#line 1211 "parse.y" - { - Debug.Assert(yymsp[-2].minor.yy203 != null); - yymsp[-2].minor.yy203.pLast.pNext = yymsp[-1].minor.yy203; - yymsp[-2].minor.yy203.pLast = yymsp[-1].minor.yy203; - yygotominor.yy203 = yymsp[-2].minor.yy203; - } - //#line 3365 "parse.c" - break; - case 284: /* trigger_cmd_list ::= trigger_cmd SEMI */ - //#line 1217 "parse.y" - { - Debug.Assert(yymsp[-1].minor.yy203 != null); - yymsp[-1].minor.yy203.pLast = yymsp[-1].minor.yy203; - yygotominor.yy203 = yymsp[-1].minor.yy203; - } - //#line 3374 "parse.c" - break; - case 286: /* trnm ::= nm DOT nm */ - //#line 1229 "parse.y" - { - yygotominor.yy0 = yymsp[0].minor.yy0; - sqlite3ErrorMsg(pParse, - "qualified table names are not allowed on INSERT, UPDATE, and DELETE " + - "statements within triggers"); - } - //#line 3384 "parse.c" - break; - case 288: /* tridxby ::= INDEXED BY nm */ - //#line 1241 "parse.y" - { - sqlite3ErrorMsg(pParse, - "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " + - "within triggers"); - } - //#line 3393 "parse.c" - break; - case 289: /* tridxby ::= NOT INDEXED */ - //#line 1246 "parse.y" - { - sqlite3ErrorMsg(pParse, - "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " + - "within triggers"); - } - //#line 3402 "parse.c" - break; - case 290: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */ - //#line 1259 "parse.y" - { - yygotominor.yy203 = sqlite3TriggerUpdateStep(pParse.db, yymsp[-4].minor.yy0, yymsp[-1].minor.yy322, yymsp[0].minor.yy314, yymsp[-5].minor.yy210); - } - //#line 3407 "parse.c" - break; - case 291: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt VALUES LP itemlist RP */ - //#line 1264 "parse.y" - { - yygotominor.yy203 = sqlite3TriggerInsertStep(pParse.db, yymsp[-5].minor.yy0, yymsp[-4].minor.yy384, yymsp[-1].minor.yy322, 0, yymsp[-7].minor.yy210); - } - //#line 3412 "parse.c" - break; - case 292: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */ - //#line 1267 "parse.y" - { - yygotominor.yy203 = sqlite3TriggerInsertStep(pParse.db, yymsp[-2].minor.yy0, yymsp[-1].minor.yy384, 0, yymsp[0].minor.yy387, yymsp[-4].minor.yy210); - } - //#line 3417 "parse.c" - break; - case 293: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */ - //#line 1271 "parse.y" - { - yygotominor.yy203 = sqlite3TriggerDeleteStep(pParse.db, yymsp[-2].minor.yy0, yymsp[0].minor.yy314); - } - //#line 3422 "parse.c" - break; - case 294: /* trigger_cmd ::= select */ - //#line 1274 "parse.y" - { - yygotominor.yy203 = sqlite3TriggerSelectStep(pParse.db, yymsp[0].minor.yy387); - } - //#line 3427 "parse.c" - break; - case 295: /* expr ::= RAISE LP IGNORE RP */ - //#line 1277 "parse.y" - { - yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0); - if (yygotominor.yy118.pExpr != null) { - yygotominor.yy118.pExpr.affinity = (char)OE_Ignore; - } - yygotominor.yy118.zStart = yymsp[-3].minor.yy0.z; - yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring(yymsp[0].minor.yy0.n);//z[yymsp[0].minor.yy0.n]; - } - //#line 3439 "parse.c" - break; - case 296: /* expr ::= RAISE LP raisetype COMMA nm RP */ - //#line 1285 "parse.y" - { - yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, yymsp[-1].minor.yy0); - if (yygotominor.yy118.pExpr != null) { - yygotominor.yy118.pExpr.affinity = (char)yymsp[-3].minor.yy4; - } - yygotominor.yy118.zStart = yymsp[-5].minor.yy0.z; - yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring(yymsp[0].minor.yy0.n);//z[yymsp[0].minor.yy0.n]; - } - //#line 3451 "parse.c" - break; - case 297: /* raisetype ::= ROLLBACK */ - //#line 1296 "parse.y" - { - yygotominor.yy4 = OE_Rollback; - } - //#line 3456 "parse.c" - break; - case 299: /* raisetype ::= FAIL */ - //#line 1298 "parse.y" - { - yygotominor.yy4 = OE_Fail; - } - //#line 3461 "parse.c" - break; - case 300: /* cmd ::= DROP TRIGGER ifexists fullname */ - //#line 1303 "parse.y" - { - sqlite3DropTrigger(pParse, yymsp[0].minor.yy259, yymsp[-1].minor.yy4); - } - //#line 3468 "parse.c" - break; - case 301: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ - //#line 1310 "parse.y" - { - sqlite3Attach(pParse, yymsp[-3].minor.yy118.pExpr, yymsp[-1].minor.yy118.pExpr, yymsp[0].minor.yy314); - } - //#line 3475 "parse.c" - break; - case 302: /* cmd ::= DETACH database_kw_opt expr */ - //#line 1313 "parse.y" - { - sqlite3Detach(pParse, yymsp[0].minor.yy118.pExpr); - } - //#line 3482 "parse.c" - break; - case 307: /* cmd ::= REINDEX */ - //#line 1328 "parse.y" - { - sqlite3Reindex(pParse, 0, 0); - } - //#line 3487 "parse.c" - break; - case 308: /* cmd ::= REINDEX nm dbnm */ - //#line 1329 "parse.y" - { - sqlite3Reindex(pParse, yymsp[-1].minor.yy0, yymsp[0].minor.yy0); - } - //#line 3492 "parse.c" - break; - case 309: /* cmd ::= ANALYZE */ - //#line 1334 "parse.y" - { - sqlite3Analyze(pParse, 0, 0); - } - //#line 3497 "parse.c" - break; - case 310: /* cmd ::= ANALYZE nm dbnm */ - //#line 1335 "parse.y" - { - sqlite3Analyze(pParse, yymsp[-1].minor.yy0, yymsp[0].minor.yy0); - } - //#line 3502 "parse.c" - break; - case 311: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ - //#line 1340 "parse.y" - { - sqlite3AlterRenameTable(pParse, yymsp[-3].minor.yy259, yymsp[0].minor.yy0); - } - //#line 3509 "parse.c" - break; - case 312: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */ - //#line 1343 "parse.y" - { - sqlite3AlterFinishAddColumn(pParse, yymsp[0].minor.yy0); - } - //#line 3516 "parse.c" - break; - case 313: /* add_column_fullname ::= fullname */ - //#line 1346 "parse.y" - { - pParse.db.lookaside.bEnabled = 0; - sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy259); - } - //#line 3524 "parse.c" - break; - case 316: /* cmd ::= create_vtab */ - //#line 1356 "parse.y" - { - sqlite3VtabFinishParse(pParse, (Token)null); - } - //#line 3529 "parse.c" - break; - case 317: /* cmd ::= create_vtab LP vtabarglist RP */ - //#line 1357 "parse.y" - { - sqlite3VtabFinishParse(pParse, yymsp[0].minor.yy0); - } - //#line 3534 "parse.c" - break; - case 318: /* create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm */ - //#line 1358 "parse.y" - { - sqlite3VtabBeginParse(pParse, yymsp[-3].minor.yy0, yymsp[-2].minor.yy0, yymsp[0].minor.yy0); - } - //#line 3541 "parse.c" - break; - case 321: /* vtabarg ::= */ - //#line 1363 "parse.y" - { - sqlite3VtabArgInit(pParse); - } - //#line 3546 "parse.c" - break; - case 323: /* vtabargtoken ::= ANY */ - case 324: /* vtabargtoken ::= lp anylist RP */ //yytestcase(yyruleno==324); - case 325: /* lp ::= LP */ //yytestcase(yyruleno==325); - //#line 1365 "parse.y" - { - sqlite3VtabArgExtend(pParse, yymsp[0].minor.yy0); - } - //#line 3553 "parse.c" - break; - default: - /* (0) input ::= cmdlist */ - //yytestcase(yyruleno==0); - /* (1) cmdlist ::= cmdlist ecmd */ - //yytestcase(yyruleno==1); - /* (2) cmdlist ::= ecmd */ - //yytestcase(yyruleno==2); - /* (3) ecmd ::= SEMI */ - //yytestcase(yyruleno==3); - /* (4) ecmd ::= explain cmdx SEMI */ - //yytestcase(yyruleno==4); - /* (10) trans_opt ::= */ - //yytestcase(yyruleno==10); - /* (11) trans_opt ::= TRANSACTION */ - //yytestcase(yyruleno==11); - /* (12) trans_opt ::= TRANSACTION nm */ - //yytestcase(yyruleno==12); - /* (20) savepoint_opt ::= SAVEPOINT */ - //yytestcase(yyruleno==20); - /* (21) savepoint_opt ::= */ - //yytestcase(yyruleno==21); - /* (25) cmd ::= create_table create_table_args */ - //yytestcase(yyruleno==25); - /* (34) columnlist ::= columnlist COMMA column */ - //yytestcase(yyruleno==34); - /* (35) columnlist ::= column */ - //yytestcase(yyruleno==35); - /* (44) type ::= */ - //yytestcase(yyruleno==44); - /* (51) signed ::= plus_num */ - //yytestcase(yyruleno==51); - /* (52) signed ::= minus_num */ - //yytestcase(yyruleno==52); - /* (53) carglist ::= carglist carg */ - //yytestcase(yyruleno==53); - /* (54) carglist ::= */ - //yytestcase(yyruleno==54); - /* (55) carg ::= CONSTRAINT nm ccons */ - //yytestcase(yyruleno==55); - /* (56) carg ::= ccons */ - //yytestcase(yyruleno==56); - /* (62) ccons ::= NULL onconf */ - //yytestcase(yyruleno==62); - /* (90) conslist ::= conslist COMMA tcons */ - //yytestcase(yyruleno==90); - /* (91) conslist ::= conslist tcons */ - //yytestcase(yyruleno==91); - /* (92) conslist ::= tcons */ - //yytestcase(yyruleno==92); - /* (93) tcons ::= CONSTRAINT nm */ - //yytestcase(yyruleno==93); - /* (268) plus_opt ::= PLUS */ - //yytestcase(yyruleno==268); - /* (269) plus_opt ::= */ - //yytestcase(yyruleno==269); - /* (279) foreach_clause ::= */ - //yytestcase(yyruleno==279); - /* (280) foreach_clause ::= FOR EACH ROW */ - //yytestcase(yyruleno==280); - /* (287) tridxby ::= */ - //yytestcase(yyruleno==287); - /* (305) database_kw_opt ::= DATABASE */ - //yytestcase(yyruleno==305); - /* (306) database_kw_opt ::= */ - //yytestcase(yyruleno==306); - /* (314) kwcolumn_opt ::= */ - //yytestcase(yyruleno==314); - /* (315) kwcolumn_opt ::= COLUMNKW */ - //yytestcase(yyruleno==315); - /* (319) vtabarglist ::= vtabarg */ - //yytestcase(yyruleno==319); - /* (320) vtabarglist ::= vtabarglist COMMA vtabarg */ - //yytestcase(yyruleno==320); - /* (322) vtabarg ::= vtabarg vtabargtoken */ - //yytestcase(yyruleno==322); - /* (326) anylist ::= */ - //yytestcase(yyruleno==326); - /* (327) anylist ::= anylist LP anylist RP */ - //yytestcase(yyruleno==327); - /* (328) anylist ::= anylist ANY */ - //yytestcase(yyruleno==328); - break; - }; - yygoto = yyRuleInfo[yyruleno].lhs; - yysize = yyRuleInfo[yyruleno].nrhs; - yypParser.yyidx -= yysize; - yyact = yy_find_reduce_action(yymsp[-yysize].stateno, (YYCODETYPE)yygoto); - if (yyact < YYNSTATE) { + /* Silence complaints from purify about yygotominor being uninitialized +** in some cases when it is copied into the stack after the following +** switch. yygotominor is uninitialized when a rule reduces that does +** not set the value of its left-hand side nonterminal. Leaving the +** value of the nonterminal uninitialized is utterly harmless as long +** as the value is never used. So really the only thing this code +** accomplishes is to quieten purify. +** +** 2007-01-16: The wireshark project (www.wireshark.org) reports that +** without this code, their parser segfaults. I'm not sure what there +** parser is doing to make this happen. This is the second bug report +** from wireshark this week. Clearly they are stressing Lemon in ways +** that it has not been previously stressed... (SQLite ticket #2172) +*/ + yygotominor = new YYMINORTYPE(); //memset(yygotominor, 0, yygotominor).Length; + switch ( yyruleno ) + { + /* Beginning here are the reduction cases. A typical example + ** follows: + ** case 0: + ** //#line + ** { ... } // User supplied code + ** //#line + ** break; + */ + case 5: /* explain ::= */ + //#line 107 "parse.y" + { + sqlite3BeginParse( pParse, 0 ); + } + //#line 2107 "parse.c" + break; + case 6: /* explain ::= EXPLAIN */ + //#line 109 "parse.y" + { + sqlite3BeginParse( pParse, 1 ); + } + //#line 2112 "parse.c" + break; + case 7: /* explain ::= EXPLAIN QUERY PLAN */ + //#line 110 "parse.y" + { + sqlite3BeginParse( pParse, 2 ); + } + //#line 2117 "parse.c" + break; + case 8: /* cmdx ::= cmd */ + //#line 112 "parse.y" + { + sqlite3FinishCoding( pParse ); + } + //#line 2122 "parse.c" + break; + case 9: /* cmd ::= BEGIN transtype trans_opt */ + //#line 117 "parse.y" + { + sqlite3BeginTransaction( pParse, yymsp[-1].minor.yy4 ); + } + //#line 2127 "parse.c" + break; + case 13: /* transtype ::= */ + //#line 122 "parse.y" + { + yygotominor.yy4 = TK_DEFERRED; + } + //#line 2132 "parse.c" + break; + case 14: /* transtype ::= DEFERRED */ + case 15: /* transtype ::= IMMEDIATE */ //yytestcase(yyruleno==15); + case 16: /* transtype ::= EXCLUSIVE */ //yytestcase(yyruleno==16); + case 115: /* multiselect_op ::= UNION */ //yytestcase(yyruleno==114); + case 117: /* multiselect_op ::= EXCEPT|INTERSECT */ //yytestcase(yyruleno==116); + //#line 123 "parse.y" + { + yygotominor.yy4 = yymsp[0].major; + } + //#line 2141 "parse.c" + break; + case 17: /* cmd ::= COMMIT trans_opt */ + case 18: /* cmd ::= END trans_opt */ //yytestcase(yyruleno==18); + //#line 126 "parse.y" + { + sqlite3CommitTransaction( pParse ); + } + //#line 2147 "parse.c" + break; + case 19: /* cmd ::= ROLLBACK trans_opt */ + //#line 128 "parse.y" + { + sqlite3RollbackTransaction( pParse ); + } + //#line 2152 "parse.c" + break; + case 22: /* cmd ::= SAVEPOINT nm */ + //#line 132 "parse.y" + { + sqlite3Savepoint( pParse, SAVEPOINT_BEGIN, yymsp[0].minor.yy0 ); + } + //#line 2159 "parse.c" + break; + case 23: /* cmd ::= RELEASE savepoint_opt nm */ + //#line 135 "parse.y" + { + sqlite3Savepoint( pParse, SAVEPOINT_RELEASE, yymsp[0].minor.yy0 ); + } + //#line 2166 "parse.c" + break; + case 24: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ + //#line 138 "parse.y" + { + sqlite3Savepoint( pParse, SAVEPOINT_ROLLBACK, yymsp[0].minor.yy0 ); + } + //#line 2173 "parse.c" + break; + case 26: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ + //#line 145 "parse.y" + { + sqlite3StartTable( pParse, yymsp[-1].minor.yy0, yymsp[0].minor.yy0, yymsp[-4].minor.yy4, 0, 0, yymsp[-2].minor.yy4 ); + } + //#line 2180 "parse.c" + break; + case 27: /* createkw ::= CREATE */ + //#line 148 "parse.y" + { + pParse.db.lookaside.bEnabled = 0; + yygotominor.yy0 = yymsp[0].minor.yy0; + } + //#line 2188 "parse.c" + break; + case 28: /* ifnotexists ::= */ + case 31: /* temp ::= */ //yytestcase(yyruleno == 31); + case 70: /* autoinc ::= */ //yytestcase(yyruleno == 70); + case 83: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ //yytestcase(yyruleno == 83); + case 85: /* init_deferred_pred_opt ::= */ //yytestcase(yyruleno == 85); + case 87: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ //yytestcase(yyruleno == 87); + case 98: /* defer_subclause_opt ::= */ //yytestcase(yyruleno == 98); + case 109: /* ifexists ::= */ //yytestcase(yyruleno == 109); + case 120: /* distinct ::= ALL */ //yytestcase(yyruleno == 120); + case 121: /* distinct ::= */ //yytestcase(yyruleno == 121); + case 222: /* between_op ::= BETWEEN */ //yytestcase(yyruleno == 223); + case 225: /* in_op ::= IN */ //yytestcase(yyruleno == 226); + //#line 153 "parse.y" + { + yygotominor.yy4 = 0; + } + //#line 2204 "parse.c" + break; + case 29: /* ifnotexists ::= IF NOT EXISTS */ + case 30: /* temp ::= TEMP */ //yytestcase(yyruleno == 30); + case 71: /* autoinc ::= AUTOINCR */ //yytestcase(yyruleno == 71); + case 86: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ //yytestcase(yyruleno == 86); + case 108: /* ifexists ::= IF EXISTS */ //yytestcase(yyruleno == 108); + case 119: /* distinct ::= DISTINCT */ //yytestcase(yyruleno == 119); + case 223: /* between_op ::= NOT BETWEEN */ //yytestcase(yyruleno == 224); + case 226: /* in_op ::= NOT IN */ //yytestcase(yyruleno == 227); + //#line 154 "parse.y" + { + yygotominor.yy4 = 1; + } + //#line 2216 "parse.c" + break; + case 32: /* create_table_args ::= LP columnlist conslist_opt RP */ + //#line 160 "parse.y" + { + sqlite3EndTable( pParse, yymsp[-1].minor.yy0, yymsp[0].minor.yy0, 0 ); + } + //#line 2223 "parse.c" + break; + case 33: /* create_table_args ::= AS select */ + //#line 163 "parse.y" + { + sqlite3EndTable( pParse, 0, 0, yymsp[0].minor.yy387 ); + sqlite3SelectDelete( pParse.db, ref yymsp[0].minor.yy387 ); + } + //#line 2231 "parse.c" + break; + case 36: /* column ::= columnid type carglist */ + //#line 175 "parse.y" + { + //yygotominor.yy0.z = yymsp[-2].minor.yy0.z; + //yygotominor.yy0.n = (int)( pParse.sLastToken.z - yymsp[-2].minor.yy0.z ) + pParse.sLastToken.n; + yygotominor.yy0.n = (int)( yymsp[-2].minor.yy0.z.Length - pParse.sLastToken.z.Length ) + pParse.sLastToken.n; + yygotominor.yy0.z = yymsp[-2].minor.yy0.z.Substring( 0, yygotominor.yy0.n ); + } + //#line 2239 "parse.c" + break; + case 37: /* columnid ::= nm */ + //#line 179 "parse.y" + { + sqlite3AddColumn( pParse, yymsp[0].minor.yy0 ); + yygotominor.yy0 = yymsp[0].minor.yy0; + } + //#line 2247 "parse.c" + break; + case 38: /* id ::= ID */ + case 39: /* id ::= INDEXED */ //yytestcase(yyruleno==39); + case 40: /* ids ::= ID|STRING */ //yytestcase(yyruleno==40); + case 41: /* nm ::= id */ //yytestcase(yyruleno==41); + case 42: /* nm ::= STRING */ //yytestcase(yyruleno==42); + case 43: /* nm ::= JOIN_KW */ //yytestcase(yyruleno==43); + case 46: /* typetoken ::= typename */ //yytestcase(yyruleno==46); + case 49: /* typename ::= ids */ //yytestcase(yyruleno==49); + case 127: /* as ::= AS nm */ ////yytestcase(yyruleno == 127); + case 128: /* as ::= ids */ ////yytestcase(yyruleno == 128); + case 138: /* dbnm ::= DOT nm */ ////yytestcase(yyruleno == 138); + case 147: /* indexed_opt ::= INDEXED BY nm */ ////yytestcase(yyruleno == 147); + case 251: /* collate ::= COLLATE ids */ //testcase(yyruleno == 251); + case 260: /* nmnum ::= plus_num */ //testcase(yyruleno == 260); + case 261: /* nmnum ::= nm */ //testcase(yyruleno == 261); + case 262: /* nmnum ::= ON */ //testcase(yyruleno == 262); + case 263: /* nmnum ::= DELETE */ //testcase(yyruleno == 263); + case 264: /* nmnum ::= DEFAULT */ //testcase(yyruleno == 264); + case 265: /* plus_num ::= plus_opt number */ //testcase(yyruleno == 265); + case 266: /* minus_num ::= MINUS number */ //testcase(yyruleno == 266); + case 267: /* number ::= INTEGER|FLOAT */ //testcase(yyruleno == 267); + case 285: /* trnm ::= nm */ //testcase(yyruleno == 285); + //#line 189 "parse.y" + { + yygotominor.yy0 = yymsp[0].minor.yy0; + } + //#line 2273 "parse.c" + break; + case 45: /* type ::= typetoken */ + //#line 251 "parse.y" + { + sqlite3AddColumnType( pParse, yymsp[0].minor.yy0 ); + } + //#line 2278 "parse.c" + break; + case 47: /* typetoken ::= typename LP signed RP */ + //#line 253 "parse.y" + { + //yygotominor.yy0.z = yymsp[-3].minor.yy0.z; + //yygotominor.yy0.n = (int)( &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z ); + yygotominor.yy0.n = yymsp[-3].minor.yy0.z.Length - yymsp[0].minor.yy0.z.Length + yymsp[0].minor.yy0.n; + yygotominor.yy0.z = yymsp[-3].minor.yy0.z.Substring( 0, yygotominor.yy0.n ); + } + //#line 2286 "parse.c" + break; + case 48: /* typetoken ::= typename LP signed COMMA signed RP */ + //#line 257 "parse.y" + { + //yygotominor.yy0.z = yymsp[-5].minor.yy0.z; + //yygotominor.yy0.n = (int)( &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z ); + yygotominor.yy0.n = yymsp[-5].minor.yy0.z.Length - yymsp[0].minor.yy0.z.Length + 1; + yygotominor.yy0.z = yymsp[-5].minor.yy0.z.Substring( 0, yygotominor.yy0.n ); + } + //#line 2294 "parse.c" + break; + case 50: /* typename ::= typename ids */ + //#line 263 "parse.y" + { + //yygotominor.yy0.z=yymsp[-1].minor.yy0.z; yygotominor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z); + yygotominor.yy0.z = yymsp[-1].minor.yy0.z; + yygotominor.yy0.n = yymsp[0].minor.yy0.n + (int)( yymsp[-1].minor.yy0.z.Length - yymsp[0].minor.yy0.z.Length ); + } + //#line 2299 "parse.c" + break; + case 57: /* ccons ::= DEFAULT term */ + case 59: /* ccons ::= DEFAULT PLUS term */ //yytestcase(yyruleno==59); + //#line 274 "parse.y" + { + sqlite3AddDefaultValue( pParse, yymsp[0].minor.yy118 ); + } + //#line 2308 "parse.c" + break; + case 58: /* ccons ::= DEFAULT LP expr RP */ + //#line 275 "parse.y" + { + sqlite3AddDefaultValue( pParse, yymsp[-1].minor.yy118 ); + } + //#line 2310 "parse.c" + break; + case 60: /* ccons ::= DEFAULT MINUS term */ + //#line 277 "parse.y" + { + ExprSpan v = new ExprSpan(); + v.pExpr = sqlite3PExpr( pParse, TK_UMINUS, yymsp[0].minor.yy118.pExpr, 0, 0 ); + v.zStart = yymsp[-1].minor.yy0.z; + v.zEnd = yymsp[0].minor.yy118.zEnd; + sqlite3AddDefaultValue( pParse, v ); + } + //#line 2321 "parse.c" + break; + case 61: /* ccons ::= DEFAULT id */ + //#line 284 "parse.y" + { + ExprSpan v = new ExprSpan(); + spanExpr( v, pParse, TK_STRING, yymsp[0].minor.yy0 ); + sqlite3AddDefaultValue( pParse, v ); + } + //#line 2330 "parse.c" + break; + case 63: /* ccons ::= NOT NULL onconf */ + //#line 294 "parse.y" + { + sqlite3AddNotNull( pParse, yymsp[0].minor.yy4 ); + } + //#line 2335 "parse.c" + break; + case 64: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ + //#line 296 "parse.y" + { + sqlite3AddPrimaryKey( pParse, 0, yymsp[-1].minor.yy4, yymsp[0].minor.yy4, yymsp[-2].minor.yy4 ); + } + //#line 2340 "parse.c" + break; + case 65: /* ccons ::= UNIQUE onconf */ + //#line 297 "parse.y" + { + sqlite3CreateIndex( pParse, 0, 0, 0, 0, yymsp[0].minor.yy4, 0, 0, 0, 0 ); + } + //#line 2345 "parse.c" + break; + case 66: /* ccons ::= CHECK LP expr RP */ + //#line 298 "parse.y" + { + sqlite3AddCheckConstraint( pParse, yymsp[-1].minor.yy118.pExpr ); + } + //#line 2350 "parse.c" + break; + case 67: /* ccons ::= REFERENCES nm idxlist_opt refargs */ + //#line 300 "parse.y" + { + sqlite3CreateForeignKey( pParse, 0, yymsp[-2].minor.yy0, yymsp[-1].minor.yy322, yymsp[0].minor.yy4 ); + } + //#line 2355 "parse.c" + break; + case 68: /* ccons ::= defer_subclause */ + //#line 301 "parse.y" + { + sqlite3DeferForeignKey( pParse, yymsp[0].minor.yy4 ); + } + //#line 2360 "parse.c" + break; + case 69: /* ccons ::= COLLATE ids */ + //#line 302 "parse.y" + { + sqlite3AddCollateType( pParse, yymsp[0].minor.yy0 ); + } + //#line 2365 "parse.c" + break; + case 72: /* refargs ::= */ + //#line 315 "parse.y" + { + yygotominor.yy4 = OE_None * 0x0101; /* EV: R-19803-45884 */ + } + //#line 2370 "parse.c" + break; + case 73: /* refargs ::= refargs refarg */ + //#line 316 "parse.y" + { + yygotominor.yy4 = ( yymsp[-1].minor.yy4 & ~yymsp[0].minor.yy215.mask ) | yymsp[0].minor.yy215.value; + } + //#line 2375 "parse.c" + break; + case 74: /* refarg ::= MATCH nm */ + case 75: /* refarg ::= ON INSERT refact */ //yytestcase(yyruleno==75); + //#line 318 "parse.y" + { + yygotominor.yy215.value = 0; + yygotominor.yy215.mask = 0x000000; + } + //#line 2381 "parse.c" + break; + case 76: /* refarg ::= ON DELETE refact */ + //#line 320 "parse.y" + { + yygotominor.yy215.value = yymsp[0].minor.yy4; + yygotominor.yy215.mask = 0x0000ff; + } + //#line 2386 "parse.c" + break; + case 77: /* refarg ::= ON UPDATE refact */ + //#line 321 "parse.y" + { + yygotominor.yy215.value = yymsp[0].minor.yy4 << 8; + yygotominor.yy215.mask = 0x00ff00; + } + //#line 2391 "parse.c" + break; + case 78: /* refact ::= SET NULL */ + //#line 323 "parse.y" + { + yygotominor.yy4 = OE_SetNull; /* EV: R-33326-45252 */ + } + //#line 2396 "parse.c" + break; + case 79: /* refact ::= SET DEFAULT */ + //#line 324 "parse.y" + { + yygotominor.yy4 = OE_SetDflt; /* EV: R-33326-45252 */ + } + //#line 2401 "parse.c" + break; + case 80: /* refact ::= CASCADE */ + //#line 325 "parse.y" + { + yygotominor.yy4 = OE_Cascade; /* EV: R-33326-45252 */ + } + //#line 2406 "parse.c" + break; + case 81: /* refact ::= RESTRICT */ + //#line 326 "parse.y" + { + yygotominor.yy4 = OE_Restrict; /* EV: R-33326-45252 */ + } + //#line 2411 "parse.c" + break; + case 82: /* refact ::= NO ACTION */ + //#line 327 "parse.y" + { + yygotominor.yy4 = OE_None; /* EV: R-33326-45252 */ + } + //#line 2416 "parse.c" + break; + case 84: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ + case 99: /* defer_subclause_opt ::= defer_subclause */ //yytestcase(yyruleno==99); + case 101: /* onconf ::= ON CONFLICT resolvetype */ //yytestcase(yyruleno==101); + case 104: /* resolvetype ::= raisetype */ //yytestcase(yyruleno==104); + //#line 330 "parse.y" + { + yygotominor.yy4 = yymsp[0].minor.yy4; + } + //#line 2424 "parse.c" + break; + case 88: /* conslist_opt ::= */ + //#line 339 "parse.y" + { + yygotominor.yy0.n = 0; + yygotominor.yy0.z = null; + } + //#line 2429 "parse.c" + break; + case 89: /* conslist_opt ::= COMMA conslist */ + //#line 340 "parse.y" + { + yygotominor.yy0 = yymsp[-1].minor.yy0; + } + //#line 2434 "parse.c" + break; + case 94: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */ + //#line 346 "parse.y" + { + sqlite3AddPrimaryKey( pParse, yymsp[-3].minor.yy322, yymsp[0].minor.yy4, yymsp[-2].minor.yy4, 0 ); + } + //#line 2439 "parse.c" + break; + case 95: /* tcons ::= UNIQUE LP idxlist RP onconf */ + //#line 348 "parse.y" + { + sqlite3CreateIndex( pParse, 0, 0, 0, yymsp[-2].minor.yy322, yymsp[0].minor.yy4, 0, 0, 0, 0 ); + } + //#line 2444 "parse.c" + break; + case 96: /* tcons ::= CHECK LP expr RP onconf */ + //#line 350 "parse.y" + { + sqlite3AddCheckConstraint( pParse, yymsp[-2].minor.yy118.pExpr ); + } + //#line 2449 "parse.c" + break; + case 97: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */ + //#line 352 "parse.y" + { + sqlite3CreateForeignKey( pParse, yymsp[-6].minor.yy322, yymsp[-3].minor.yy0, yymsp[-2].minor.yy322, yymsp[-1].minor.yy4 ); + sqlite3DeferForeignKey( pParse, yymsp[0].minor.yy4 ); + } + //#line 2457 "parse.c" + break; + case 100: /* onconf ::= */ + //#line 366 "parse.y" + { + yygotominor.yy4 = OE_Default; + } + //#line 2462 "parse.c" + break; + case 102: /* orconf ::= */ + //#line 368 "parse.y" + { + yygotominor.yy210 = OE_Default; + } + //#line 2467 "parse.c" + break; + case 103: /* orconf ::= OR resolvetype */ + //#line 369 "parse.y" + { + yygotominor.yy210 = (u8)yymsp[0].minor.yy4; + } + //#line 2472 "parse.c" + break; + case 105: /* resolvetype ::= IGNORE */ + //#line 371 "parse.y" + { + yygotominor.yy4 = OE_Ignore; + } + //#line 2477 "parse.c" + break; + case 106: /* resolvetype ::= REPLACE */ + //#line 372 "parse.y" + { + yygotominor.yy4 = OE_Replace; + } + //#line 2482 "parse.c" + break; + case 107: /* cmd ::= DROP TABLE ifexists fullname */ + //#line 376 "parse.y" + { + sqlite3DropTable( pParse, yymsp[0].minor.yy259, 0, yymsp[-1].minor.yy4 ); + } + //#line 2489 "parse.c" + break; + case 110: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */ + //#line 386 "parse.y" + { + sqlite3CreateView( pParse, yymsp[-7].minor.yy0, yymsp[-3].minor.yy0, yymsp[-2].minor.yy0, yymsp[0].minor.yy387, yymsp[-6].minor.yy4, yymsp[-4].minor.yy4 ); + } + //#line 2496 "parse.c" + break; + case 111: /* cmd ::= DROP VIEW ifexists fullname */ + //#line 389 "parse.y" + { + sqlite3DropTable( pParse, yymsp[0].minor.yy259, 1, yymsp[-1].minor.yy4 ); + } + //#line 2503 "parse.c" + break; + case 112: /* cmd ::= select */ + //#line 396 "parse.y" + { + SelectDest dest = new SelectDest( SRT_Output, '\0', 0, 0, 0 ); + sqlite3Select( pParse, yymsp[0].minor.yy387, ref dest ); + sqlite3SelectDelete( pParse.db, ref yymsp[0].minor.yy387 ); + } + //#line 2512 "parse.c" + break; + case 113: /* select ::= oneselect */ + //#line 407 "parse.y" + { + yygotominor.yy387 = yymsp[0].minor.yy387; + } + //#line 2517 "parse.c" + break; + case 114: /* select ::= select multiselect_op oneselect */ + //#line 409 "parse.y" + { + if ( yymsp[0].minor.yy387 != null ) + { + yymsp[0].minor.yy387.op = (u8)yymsp[-1].minor.yy4; + yymsp[0].minor.yy387.pPrior = yymsp[-2].minor.yy387; + } + else + { + sqlite3SelectDelete( pParse.db, ref yymsp[-2].minor.yy387 ); + } + yygotominor.yy387 = yymsp[0].minor.yy387; + } + //#line 2530 "parse.c" + break; + case 116: /* multiselect_op ::= UNION ALL */ + //#line 420 "parse.y" + { + yygotominor.yy4 = TK_ALL; + } + //#line 2535 "parse.c" + break; + case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ + //#line 424 "parse.y" + { + yygotominor.yy387 = sqlite3SelectNew( pParse, yymsp[-6].minor.yy322, yymsp[-5].minor.yy259, yymsp[-4].minor.yy314, yymsp[-3].minor.yy322, yymsp[-2].minor.yy314, yymsp[-1].minor.yy322, yymsp[-7].minor.yy4, yymsp[0].minor.yy292.pLimit, yymsp[0].minor.yy292.pOffset ); + } + //#line 2542 "parse.c" + break; + case 122: /* sclp ::= selcollist COMMA */ + case 247: /* idxlist_opt ::= LP idxlist RP */ //yytestcase(yyruleno==247); + //#line 445 "parse.y" + { + yygotominor.yy322 = yymsp[-1].minor.yy322; + } + //#line 2548 "parse.c" + break; + case 123: /* sclp ::= */ + case 151: /* orderby_opt ::= */ //yytestcase(yyruleno==151); + case 159: /* groupby_opt ::= */ //yytestcase(yyruleno==159); + case 240: /* exprlist ::= */ //yytestcase(yyruleno==240); + case 246: /* idxlist_opt ::= */ //yytestcase(yyruleno==246); + //#line 446 "parse.y" + { + yygotominor.yy322 = null; + } + //#line 2557 "parse.c" + break; + case 124: /* selcollist ::= sclp expr as */ + //#line 447 "parse.y" + { + yygotominor.yy322 = sqlite3ExprListAppend( pParse, yymsp[-2].minor.yy322, yymsp[-1].minor.yy118.pExpr ); + if ( yymsp[0].minor.yy0.n > 0 ) + sqlite3ExprListSetName( pParse, yygotominor.yy322, yymsp[0].minor.yy0, 1 ); + sqlite3ExprListSetSpan( pParse, yygotominor.yy322, yymsp[-1].minor.yy118 ); + } + //#line 2566 "parse.c" + break; + case 125: /* selcollist ::= sclp STAR */ + //#line 452 "parse.y" + { + Expr p = sqlite3Expr( pParse.db, TK_ALL, null ); + yygotominor.yy322 = sqlite3ExprListAppend( pParse, yymsp[-1].minor.yy322, p ); + } + //#line 2574 "parse.c" + break; + case 126: /* selcollist ::= sclp nm DOT STAR */ + //#line 456 "parse.y" + { + Expr pRight = sqlite3PExpr( pParse, TK_ALL, 0, 0, yymsp[0].minor.yy0 ); + Expr pLeft = sqlite3PExpr( pParse, TK_ID, 0, 0, yymsp[-2].minor.yy0 ); + Expr pDot = sqlite3PExpr( pParse, TK_DOT, pLeft, pRight, 0 ); + yygotominor.yy322 = sqlite3ExprListAppend( pParse, yymsp[-3].minor.yy322, pDot ); + } + //#line 2584 "parse.c" + break; + case 129: /* as ::= */ + //#line 469 "parse.y" + { + yygotominor.yy0.n = 0; + } + //#line 2589 "parse.c" + break; + case 130: /* from ::= */ + //#line 481 "parse.y" + { + yygotominor.yy259 = new SrcList(); + }//sqlite3DbMallocZero(pParse.db, sizeof(*yygotominor.yy259));} + //#line 2594 "parse.c" + break; + case 131: /* from ::= FROM seltablist */ + //#line 482 "parse.y" + { + yygotominor.yy259 = yymsp[0].minor.yy259; + sqlite3SrcListShiftJoinType( yygotominor.yy259 ); + } + //#line 2602 "parse.c" + break; + case 132: /* stl_prefix ::= seltablist joinop */ + //#line 490 "parse.y" + { + yygotominor.yy259 = yymsp[-1].minor.yy259; + if ( ALWAYS( yygotominor.yy259 != null && yygotominor.yy259.nSrc > 0 ) ) + yygotominor.yy259.a[yygotominor.yy259.nSrc - 1].jointype = (u8)yymsp[0].minor.yy4; + } + //#line 2610 "parse.c" + break; + case 133: /* stl_prefix ::= */ + //#line 494 "parse.y" + { + yygotominor.yy259 = null; + } + //#line 2615 "parse.c" + break; + case 134: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ + //#line 495 "parse.y" + { + yygotominor.yy259 = sqlite3SrcListAppendFromTerm( pParse, yymsp[-6].minor.yy259, yymsp[-5].minor.yy0, yymsp[-4].minor.yy0, yymsp[-3].minor.yy0, 0, yymsp[-1].minor.yy314, yymsp[0].minor.yy384 ); + sqlite3SrcListIndexedBy( pParse, yygotominor.yy259, yymsp[-2].minor.yy0 ); + } + //#line 2623 "parse.c" + break; + case 135: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ + //#line 501 "parse.y" + { + yygotominor.yy259 = sqlite3SrcListAppendFromTerm( pParse, yymsp[-6].minor.yy259, 0, 0, yymsp[-2].minor.yy0, yymsp[-4].minor.yy387, yymsp[-1].minor.yy314, yymsp[0].minor.yy384 ); + } + //#line 2630 "parse.c" + break; + case 136: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ + //#line 505 "parse.y" + { + if ( yymsp[-6].minor.yy259 == null && yymsp[-2].minor.yy0.n == 0 && yymsp[-1].minor.yy314 == null && yymsp[0].minor.yy384 == null ) + { + yygotominor.yy259 = yymsp[-4].minor.yy259; + } + else + { + Select pSubquery; + sqlite3SrcListShiftJoinType( yymsp[-4].minor.yy259 ); + pSubquery = sqlite3SelectNew( pParse, 0, yymsp[-4].minor.yy259, 0, 0, 0, 0, 0, 0, 0 ); + yygotominor.yy259 = sqlite3SrcListAppendFromTerm( pParse, yymsp[-6].minor.yy259, 0, 0, yymsp[-2].minor.yy0, pSubquery, yymsp[-1].minor.yy314, yymsp[0].minor.yy384 ); + } + } + //#line 2644 "parse.c" + break; + case 137: /* dbnm ::= */ + case 146: /* indexed_opt ::= */ //yytestcase(yyruleno==146); + //#line 530 "parse.y" + { + yygotominor.yy0.z = null; + yygotominor.yy0.n = 0; + } + //#line 2650 "parse.c" + break; + case 139: /* fullname ::= nm dbnm */ + //#line 535 "parse.y" + { + yygotominor.yy259 = sqlite3SrcListAppend( pParse.db, 0, yymsp[-1].minor.yy0, yymsp[0].minor.yy0 ); + } + //#line 2655 "parse.c" + break; + case 140: /* joinop ::= COMMA|JOIN */ + //#line 539 "parse.y" + { + yygotominor.yy4 = JT_INNER; + } + //#line 2660 "parse.c" + break; + case 141: /* joinop ::= JOIN_KW JOIN */ + //#line 540 "parse.y" + { + yygotominor.yy4 = sqlite3JoinType( pParse, yymsp[-1].minor.yy0, 0, 0 ); + } + //#line 2665 "parse.c" + break; + case 142: /* joinop ::= JOIN_KW nm JOIN */ + //#line 541 "parse.y" + { + yygotominor.yy4 = sqlite3JoinType( pParse, yymsp[-2].minor.yy0, yymsp[-1].minor.yy0, 0 ); + } + //#line 2670 "parse.c" + break; + case 143: /* joinop ::= JOIN_KW nm nm JOIN */ + //#line 543 "parse.y" + { + yygotominor.yy4 = sqlite3JoinType( pParse, yymsp[-3].minor.yy0, yymsp[-2].minor.yy0, yymsp[-1].minor.yy0 ); + } + //#line 2675 "parse.c" + break; + case 144: /* on_opt ::= ON expr */ + case 155: /* sortitem ::= expr */ //yytestcase(yyruleno==155); + case 162: /* having_opt ::= HAVING expr */ //yytestcase(yyruleno==162); + case 169: /* where_opt ::= WHERE expr */ //yytestcase(yyruleno==169); + case 235: /* case_else ::= ELSE expr */ //yytestcase(yyruleno==235); + case 237: /* case_operand ::= expr */ //yytestcase(yyruleno==237); + //#line 547 "parse.y" + { + yygotominor.yy314 = yymsp[0].minor.yy118.pExpr; + } + //#line 2685 "parse.c" + break; + case 145: /* on_opt ::= */ + case 161: /* having_opt ::= */ //yytestcase(yyruleno==161); + case 168: /* where_opt ::= */ //yytestcase(yyruleno==168); + case 236: /* case_else ::= */ //yytestcase(yyruleno==236); + case 238: /* case_operand ::= */ //yytestcase(yyruleno==238); + //#line 548 "parse.y" + { + yygotominor.yy314 = null; + } + //#line 2694 "parse.c" + break; + case 148: /* indexed_opt ::= NOT INDEXED */ + //#line 563 "parse.y" + { + yygotominor.yy0.z = null; + yygotominor.yy0.n = 1; + } + //#line 2699 "parse.c" + break; + case 149: /* using_opt ::= USING LP inscollist RP */ + case 181: /* inscollist_opt ::= LP inscollist RP */ //yytestcase(yyruleno==181); + //#line 567 "parse.y" + { + yygotominor.yy384 = yymsp[-1].minor.yy384; + } + //#line 2705 "parse.c" + break; + case 150: /* using_opt ::= */ + case 180: /* inscollist_opt ::= */ //yytestcase(yyruleno==180); + //#line 568 "parse.y" + { + yygotominor.yy384 = null; + } + //#line 2711 "parse.c" + break; + case 152: /* orderby_opt ::= ORDER BY sortlist */ + case 160: /* groupby_opt ::= GROUP BY nexprlist */ //yytestcase(yyruleno==160); + case 239: /* exprlist ::= nexprlist */ //yytestcase(yyruleno==239); + //#line 579 "parse.y" + { + yygotominor.yy322 = yymsp[0].minor.yy322; + } + //#line 2718 "parse.c" + break; + case 153: /* sortlist ::= sortlist COMMA sortitem sortorder */ + //#line 580 "parse.y" + { + yygotominor.yy322 = sqlite3ExprListAppend( pParse, yymsp[-3].minor.yy322, yymsp[-1].minor.yy314 ); + if ( yygotominor.yy322 != null ) + yygotominor.yy322.a[yygotominor.yy322.nExpr - 1].sortOrder = (u8)yymsp[0].minor.yy4; + } + //#line 2726 "parse.c" + break; + case 154: /* sortlist ::= sortitem sortorder */ + //#line 584 "parse.y" + { + yygotominor.yy322 = sqlite3ExprListAppend( pParse, 0, yymsp[-1].minor.yy314 ); + if ( yygotominor.yy322 != null && ALWAYS( yygotominor.yy322.a != null ) ) + yygotominor.yy322.a[0].sortOrder = (u8)yymsp[0].minor.yy4; + } + //#line 2734 "parse.c" + break; + case 156: /* sortorder ::= ASC */ + case 158: /* sortorder ::= */ //yytestcase(yyruleno==158); + //#line 592 "parse.y" + { + yygotominor.yy4 = SQLITE_SO_ASC; + } + //#line 2740 "parse.c" + break; + case 157: /* sortorder ::= DESC */ + //#line 593 "parse.y" + { + yygotominor.yy4 = SQLITE_SO_DESC; + } + //#line 2745 "parse.c" + break; + case 163: /* limit_opt ::= */ + //#line 619 "parse.y" + { + yygotominor.yy292.pLimit = null; + yygotominor.yy292.pOffset = null; + } + //#line 2750 "parse.c" + break; + case 164: /* limit_opt ::= LIMIT expr */ + //#line 620 "parse.y" + { + yygotominor.yy292.pLimit = yymsp[0].minor.yy118.pExpr; + yygotominor.yy292.pOffset = null; + } + //#line 2755 "parse.c" + break; + case 165: /* limit_opt ::= LIMIT expr OFFSET expr */ + //#line 622 "parse.y" + { + yygotominor.yy292.pLimit = yymsp[-2].minor.yy118.pExpr; + yygotominor.yy292.pOffset = yymsp[0].minor.yy118.pExpr; + } + //#line 2760 "parse.c" + break; + case 166: /* limit_opt ::= LIMIT expr COMMA expr */ + //#line 624 "parse.y" + { + yygotominor.yy292.pOffset = yymsp[-2].minor.yy118.pExpr; + yygotominor.yy292.pLimit = yymsp[0].minor.yy118.pExpr; + } + //#line 2765 "parse.c" + break; + case 167: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */ + //#line 637 "parse.y" + { + sqlite3SrcListIndexedBy( pParse, yymsp[-2].minor.yy259, yymsp[-1].minor.yy0 ); + sqlite3DeleteFrom( pParse, yymsp[-2].minor.yy259, yymsp[0].minor.yy314 ); + } + //#line 2773 "parse.c" + break; + case 170: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */ + //#line 660 "parse.y" + { + sqlite3SrcListIndexedBy( pParse, yymsp[-4].minor.yy259, yymsp[-3].minor.yy0 ); + sqlite3ExprListCheckLength( pParse, yymsp[-1].minor.yy322, "set list" ); + sqlite3Update( pParse, yymsp[-4].minor.yy259, yymsp[-1].minor.yy322, yymsp[0].minor.yy314, yymsp[-5].minor.yy210 ); + } + //#line 2782 "parse.c" + break; + case 171: /* setlist ::= setlist COMMA nm EQ expr */ + //#line 670 "parse.y" + { + yygotominor.yy322 = sqlite3ExprListAppend( pParse, yymsp[-4].minor.yy322, yymsp[0].minor.yy118.pExpr ); + sqlite3ExprListSetName( pParse, yygotominor.yy322, yymsp[-2].minor.yy0, 1 ); + } + //#line 2790 "parse.c" + break; + case 172: /* setlist ::= nm EQ expr */ + //#line 674 "parse.y" + { + yygotominor.yy322 = sqlite3ExprListAppend( pParse, 0, yymsp[0].minor.yy118.pExpr ); + sqlite3ExprListSetName( pParse, yygotominor.yy322, yymsp[-2].minor.yy0, 1 ); + } + //#line 2798 "parse.c" + break; + case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP */ + //#line 683 "parse.y" + { + sqlite3Insert( pParse, yymsp[-5].minor.yy259, yymsp[-1].minor.yy322, 0, yymsp[-4].minor.yy384, yymsp[-7].minor.yy210 ); + } + //#line 2803 "parse.c" + break; + case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */ + //#line 685 "parse.y" + { + sqlite3Insert( pParse, yymsp[-2].minor.yy259, 0, yymsp[0].minor.yy387, yymsp[-1].minor.yy384, yymsp[-4].minor.yy210 ); + } + //#line 2808 "parse.c" + break; + case 175: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */ + //#line 687 "parse.y" + { + sqlite3Insert( pParse, yymsp[-3].minor.yy259, 0, 0, yymsp[-2].minor.yy384, yymsp[-5].minor.yy210 ); + } + //#line 2813 "parse.c" + break; + case 176: /* insert_cmd ::= INSERT orconf */ + //#line 690 "parse.y" + { + yygotominor.yy210 = yymsp[0].minor.yy210; + } + //#line 2818 "parse.c" + break; + case 177: /* insert_cmd ::= REPLACE */ + //#line 691 "parse.y" + { + yygotominor.yy210 = OE_Replace; + } + //#line 2823 "parse.c" + break; + case 178: /* itemlist ::= itemlist COMMA expr */ + case 241: /* nexprlist ::= nexprlist COMMA expr */ //yytestcase(yyruleno==241); + //#line 698 "parse.y" + { + yygotominor.yy322 = sqlite3ExprListAppend( pParse, yymsp[-2].minor.yy322, yymsp[0].minor.yy118.pExpr ); + } + //#line 2829 "parse.c" + break; + case 179: /* itemlist ::= expr */ + case 242: /* nexprlist ::= expr */ //yytestcase(yyruleno==242); + //#line 700 "parse.y" + { + yygotominor.yy322 = sqlite3ExprListAppend( pParse, 0, yymsp[0].minor.yy118.pExpr ); + } + //#line 2835 "parse.c" + break; + case 182: /* inscollist ::= inscollist COMMA nm */ + //#line 710 "parse.y" + { + yygotominor.yy384 = sqlite3IdListAppend( pParse.db, yymsp[-2].minor.yy384, yymsp[0].minor.yy0 ); + } + //#line 2840 "parse.c" + break; + case 183: /* inscollist ::= nm */ + //#line 712 "parse.y" + { + yygotominor.yy384 = sqlite3IdListAppend( pParse.db, 0, yymsp[0].minor.yy0 ); + } + //#line 2845 "parse.c" + break; + case 184: /* expr ::= term */ + //#line 743 "parse.y" + { + yygotominor.yy118 = yymsp[0].minor.yy118; + } + //#line 2850 "parse.c" + break; + case 185: /* expr ::= LP expr RP */ + //#line 744 "parse.y" + { + yygotominor.yy118.pExpr = yymsp[-1].minor.yy118.pExpr; + spanSet( yygotominor.yy118, yymsp[-2].minor.yy0, yymsp[0].minor.yy0 ); + } + //#line 2855 "parse.c" + break; + case 186: /* term ::= NULL */ + case 191: /* term ::= INTEGER|FLOAT|BLOB */ //yytestcase(yyruleno==191); + case 192: /* term ::= STRING */ //yytestcase(yyruleno==192); + //#line 745 "parse.y" + { + spanExpr( yygotominor.yy118, pParse, yymsp[0].major, yymsp[0].minor.yy0 ); + } + //#line 2862 "parse.c" + break; + case 187: /* expr ::= id */ + case 188: /* expr ::= JOIN_KW */ //yytestcase(yyruleno==188); + //#line 746 "parse.y" + { + spanExpr( yygotominor.yy118, pParse, TK_ID, yymsp[0].minor.yy0 ); + } + //#line 2868 "parse.c" + break; + case 189: /* expr ::= nm DOT nm */ + //#line 748 "parse.y" + { + Expr temp1 = sqlite3PExpr( pParse, TK_ID, 0, 0, yymsp[-2].minor.yy0 ); + Expr temp2 = sqlite3PExpr( pParse, TK_ID, 0, 0, yymsp[0].minor.yy0 ); + yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_DOT, temp1, temp2, 0 ); + spanSet( yygotominor.yy118, yymsp[-2].minor.yy0, yymsp[0].minor.yy0 ); + } + //#line 2878 "parse.c" + break; + case 190: /* expr ::= nm DOT nm DOT nm */ + //#line 754 "parse.y" + { + Expr temp1 = sqlite3PExpr( pParse, TK_ID, 0, 0, yymsp[-4].minor.yy0 ); + Expr temp2 = sqlite3PExpr( pParse, TK_ID, 0, 0, yymsp[-2].minor.yy0 ); + Expr temp3 = sqlite3PExpr( pParse, TK_ID, 0, 0, yymsp[0].minor.yy0 ); + Expr temp4 = sqlite3PExpr( pParse, TK_DOT, temp2, temp3, 0 ); + yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_DOT, temp1, temp4, 0 ); + spanSet( yygotominor.yy118, yymsp[-4].minor.yy0, yymsp[0].minor.yy0 ); + } + //#line 2890 "parse.c" + break; + case 193: /* expr ::= REGISTER */ + //#line 764 "parse.y" + { + /* When doing a nested parse, one can include terms in an expression + ** that look like this: #1 #2 ... These terms refer to registers + ** in the virtual machine. #N is the N-th register. */ + if ( pParse.nested == 0 ) + { + sqlite3ErrorMsg( pParse, "near \"%T\": syntax error", yymsp[0].minor.yy0 ); + yygotominor.yy118.pExpr = null; + } + else + { + yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_REGISTER, 0, 0, yymsp[0].minor.yy0 ); + if ( yygotominor.yy118.pExpr != null ) + sqlite3GetInt32( yymsp[0].minor.yy0.z, 1, ref yygotominor.yy118.pExpr.iTable ); + } + spanSet( yygotominor.yy118, yymsp[0].minor.yy0, yymsp[0].minor.yy0 ); + } + //#line 2907 "parse.c" + break; + case 194: /* expr ::= VARIABLE */ + //#line 777 "parse.y" + { + spanExpr( yygotominor.yy118, pParse, TK_VARIABLE, yymsp[0].minor.yy0 ); + sqlite3ExprAssignVarNumber( pParse, yygotominor.yy118.pExpr ); + spanSet( yygotominor.yy118, yymsp[0].minor.yy0, yymsp[0].minor.yy0 ); + } + //#line 2916 "parse.c" + break; + case 195: /* expr ::= expr COLLATE ids */ + //#line 782 "parse.y" + { + yygotominor.yy118.pExpr = sqlite3ExprSetCollByToken( pParse, yymsp[-2].minor.yy118.pExpr, yymsp[0].minor.yy0 ); + yygotominor.yy118.zStart = yymsp[-2].minor.yy118.zStart; + yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring( yymsp[0].minor.yy0.n );//z[yymsp[0].minor.yy0.n]; + } + //#line 2925 "parse.c" + break; + case 196: /* expr ::= CAST LP expr AS typetoken RP */ + //#line 788 "parse.y" + { + yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_CAST, yymsp[-3].minor.yy118.pExpr, 0, yymsp[-1].minor.yy0 ); + spanSet( yygotominor.yy118, yymsp[-5].minor.yy0, yymsp[0].minor.yy0 ); + } + //#line 2933 "parse.c" + break; + case 197: /* expr ::= ID LP distinct exprlist RP */ + //#line 793 "parse.y" + { + if ( yymsp[-1].minor.yy322 != null && yymsp[-1].minor.yy322.nExpr > pParse.db.aLimit[SQLITE_LIMIT_FUNCTION_ARG] ) + { + sqlite3ErrorMsg( pParse, "too many arguments on function %T", yymsp[-4].minor.yy0 ); + } + yygotominor.yy118.pExpr = sqlite3ExprFunction( pParse, yymsp[-1].minor.yy322, yymsp[-4].minor.yy0 ); + spanSet( yygotominor.yy118, yymsp[-4].minor.yy0, yymsp[0].minor.yy0 ); + if ( yymsp[-2].minor.yy4 != 0 && yygotominor.yy118.pExpr != null ) + { + yygotominor.yy118.pExpr.flags |= EP_Distinct; + } + } + //#line 2947 "parse.c" + break; + case 198: /* expr ::= ID LP STAR RP */ + //#line 803 "parse.y" + { + yygotominor.yy118.pExpr = sqlite3ExprFunction( pParse, 0, yymsp[-3].minor.yy0 ); + spanSet( yygotominor.yy118, yymsp[-3].minor.yy0, yymsp[0].minor.yy0 ); + } + //#line 2955 "parse.c" + break; + case 199: /* term ::= CTIME_KW */ + //#line 807 "parse.y" + { + /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are + ** treated as functions that return constants */ + yygotominor.yy118.pExpr = sqlite3ExprFunction( pParse, 0, yymsp[0].minor.yy0 ); + if ( yygotominor.yy118.pExpr != null ) + { + yygotominor.yy118.pExpr.op = TK_CONST_FUNC; + } + spanSet( yygotominor.yy118, yymsp[0].minor.yy0, yymsp[0].minor.yy0 ); + } + //#line 2968 "parse.c" + break; + case 200: /* expr ::= expr AND expr */ + case 201: /* expr ::= expr OR expr */ //yytestcase(yyruleno==201); + case 202: /* expr ::= expr LT|GT|GE|LE expr */ //yytestcase(yyruleno==202); + case 203: /* expr ::= expr EQ|NE expr */ //yytestcase(yyruleno==203); + case 204: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ //yytestcase(yyruleno==204); + case 205: /* expr ::= expr PLUS|MINUS expr */ //yytestcase(yyruleno==205); + case 206: /* expr ::= expr STAR|SLASH|REM expr */ //yytestcase(yyruleno==206); + case 207: /* expr ::= expr CONCAT expr */ //yytestcase(yyruleno==207); + //#line 834 "parse.y" + { + spanBinaryExpr( yygotominor.yy118, pParse, yymsp[-1].major, yymsp[-2].minor.yy118, yymsp[0].minor.yy118 ); + } + //#line 2980 "parse.c" + break; + case 208: /* likeop ::= LIKE_KW */ + case 210: /* likeop ::= MATCH */ //yytestcase(yyruleno==210); + //#line 847 "parse.y" + { + yygotominor.yy342.eOperator = yymsp[0].minor.yy0; + yygotominor.yy342.not = false; + } + //#line 2986 "parse.c" + break; + case 209: /* likeop ::= NOT LIKE_KW */ + case 211: /* likeop ::= NOT MATCH */ //yytestcase(yyruleno==211); + //#line 848 "parse.y" + { + yygotominor.yy342.eOperator = yymsp[0].minor.yy0; + yygotominor.yy342.not = true; + } + //#line 2992 "parse.c" + break; + case 212: /* expr ::= expr likeop expr */ + //#line 851 "parse.y" + { + ExprList pList; + pList = sqlite3ExprListAppend( pParse, 0, yymsp[0].minor.yy118.pExpr ); + pList = sqlite3ExprListAppend( pParse, pList, yymsp[-2].minor.yy118.pExpr ); + yygotominor.yy118.pExpr = sqlite3ExprFunction( pParse, pList, yymsp[-1].minor.yy342.eOperator ); + if ( yymsp[-1].minor.yy342.not ) + yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0 ); + yygotominor.yy118.zStart = yymsp[-2].minor.yy118.zStart; + yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; + if ( yygotominor.yy118.pExpr != null ) + yygotominor.yy118.pExpr.flags |= EP_InfixFunc; + } + //#line 3006 "parse.c" + break; + case 213: /* expr ::= expr likeop expr ESCAPE expr */ + //#line 861 "parse.y" + { + ExprList pList; + pList = sqlite3ExprListAppend( pParse, 0, yymsp[-2].minor.yy118.pExpr ); + pList = sqlite3ExprListAppend( pParse, pList, yymsp[-4].minor.yy118.pExpr ); + pList = sqlite3ExprListAppend( pParse, pList, yymsp[0].minor.yy118.pExpr ); + yygotominor.yy118.pExpr = sqlite3ExprFunction( pParse, pList, yymsp[-3].minor.yy342.eOperator ); + if ( yymsp[-3].minor.yy342.not ) + yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0 ); + yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; + yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; + if ( yygotominor.yy118.pExpr != null ) + yygotominor.yy118.pExpr.flags |= EP_InfixFunc; + } + //#line 3021 "parse.c" + break; + case 214: /* expr ::= expr ISNULL|NOTNULL */ + //#line 889 "parse.y" + { + spanUnaryPostfix( yygotominor.yy118, pParse, yymsp[0].major, yymsp[-1].minor.yy118, yymsp[0].minor.yy0 ); + } + //#line 3026 "parse.c" + break; + case 215: /* expr ::= expr NOT NULL */ + //#line 890 "parse.y" + { + spanUnaryPostfix( yygotominor.yy118, pParse, TK_NOTNULL, yymsp[-2].minor.yy118, yymsp[0].minor.yy0 ); + } + //#line 3031 "parse.c" + break; + case 216: /* expr ::= expr IS expr */ + //#line 911 "parse.y" + { + spanBinaryExpr( yygotominor.yy118, pParse, TK_IS, yymsp[-2].minor.yy118, yymsp[0].minor.yy118 ); + binaryToUnaryIfNull( pParse, yymsp[0].minor.yy118.pExpr, yygotominor.yy118.pExpr, TK_ISNULL ); + } + //#line 3039 "parse.c" + break; + case 217: /* expr ::= expr IS NOT expr */ + //#line 915 "parse.y" + { + spanBinaryExpr( yygotominor.yy118, pParse, TK_ISNOT, yymsp[-3].minor.yy118, yymsp[0].minor.yy118 ); + binaryToUnaryIfNull( pParse, yymsp[0].minor.yy118.pExpr, yygotominor.yy118.pExpr, TK_NOTNULL ); + } + //#line 3047 "parse.c" + break; + case 218: /* expr ::= NOT expr */ + case 219: /* expr ::= BITNOT expr */ //yytestcase(yyruleno==219); + //#line 938 "parse.y" + { + spanUnaryPrefix( yygotominor.yy118, pParse, yymsp[-1].major, yymsp[0].minor.yy118, yymsp[-1].minor.yy0 ); + } + //#line 3053 "parse.c" + break; + case 220: /* expr ::= MINUS expr */ + //#line 941 "parse.y" + { + spanUnaryPrefix( yygotominor.yy118, pParse, TK_UMINUS, yymsp[0].minor.yy118, yymsp[-1].minor.yy0 ); + } + //#line 3058 "parse.c" + break; + case 221: /* expr ::= PLUS expr */ + //#line 943 "parse.y" + { + spanUnaryPrefix( yygotominor.yy118, pParse, TK_UPLUS, yymsp[0].minor.yy118, yymsp[-1].minor.yy0 ); + } + //#line 3063 "parse.c" + break; + case 224: /* expr ::= expr between_op expr AND expr */ + //#line 948 "parse.y" + { + ExprList pList = sqlite3ExprListAppend( pParse, 0, yymsp[-2].minor.yy118.pExpr ); + pList = sqlite3ExprListAppend( pParse, pList, yymsp[0].minor.yy118.pExpr ); + yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_BETWEEN, yymsp[-4].minor.yy118.pExpr, 0, 0 ); + if ( yygotominor.yy118.pExpr != null ) + { + yygotominor.yy118.pExpr.x.pList = pList; + } + else + { + sqlite3ExprListDelete( pParse.db, ref pList ); + } + if ( yymsp[-3].minor.yy4 != 0 ) + yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0 ); + yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; + yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; + } + //#line 3080 "parse.c" + break; + case 227: /* expr ::= expr in_op LP exprlist RP */ + //#line 965 "parse.y" + { + if ( yymsp[-1].minor.yy322 == null ) + { + /* Expressions of the form + ** + ** expr1 IN () + ** expr1 NOT IN () + ** + ** simplify to constants 0 (false) and 1 (true), respectively, + ** regardless of the value of expr1. + */ + yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_INTEGER, 0, 0, sqlite3IntTokens[yymsp[-3].minor.yy4] ); + sqlite3ExprDelete( pParse.db, ref yymsp[-4].minor.yy118.pExpr ); + } + else + { + yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_IN, yymsp[-4].minor.yy118.pExpr, 0, 0 ); + if ( yygotominor.yy118.pExpr != null ) + { + yygotominor.yy118.pExpr.x.pList = yymsp[-1].minor.yy322; + sqlite3ExprSetHeight( pParse, yygotominor.yy118.pExpr ); + } + else + { + sqlite3ExprListDelete( pParse.db, ref yymsp[-1].minor.yy322 ); + } + if ( yymsp[-3].minor.yy4 != 0 ) + yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0 ); + } + yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; + yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring( yymsp[0].minor.yy0.n );//[yymsp[0].minor.yy0.n]; + } + //#line 3109 "parse.c" + break; + case 228: /* expr ::= LP select RP */ + //#line 990 "parse.y" + { + yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_SELECT, 0, 0, 0 ); + if ( yygotominor.yy118.pExpr != null ) + { + yygotominor.yy118.pExpr.x.pSelect = yymsp[-1].minor.yy387; + ExprSetProperty( yygotominor.yy118.pExpr, EP_xIsSelect ); + sqlite3ExprSetHeight( pParse, yygotominor.yy118.pExpr ); + } + else + { + sqlite3SelectDelete( pParse.db, ref yymsp[-1].minor.yy387 ); + } + yygotominor.yy118.zStart = yymsp[-2].minor.yy0.z; + yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring( yymsp[0].minor.yy0.n );//z[yymsp[0].minor.yy0.n]; + } + //#line 3125 "parse.c" + break; + case 229: /* expr ::= expr in_op LP select RP */ + //#line 1002 "parse.y" + { + yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_IN, yymsp[-4].minor.yy118.pExpr, 0, 0 ); + if ( yygotominor.yy118.pExpr != null ) + { + yygotominor.yy118.pExpr.x.pSelect = yymsp[-1].minor.yy387; + ExprSetProperty( yygotominor.yy118.pExpr, EP_xIsSelect ); + sqlite3ExprSetHeight( pParse, yygotominor.yy118.pExpr ); + } + else + { + sqlite3SelectDelete( pParse.db, ref yymsp[-1].minor.yy387 ); + } + if ( yymsp[-3].minor.yy4 != 0 ) + yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0 ); + yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; + yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring( yymsp[0].minor.yy0.n );//z[yymsp[0].minor.yy0.n]; + } + //#line 3142 "parse.c" + break; + case 230: /* expr ::= expr in_op nm dbnm */ + //#line 1015 "parse.y" + { + SrcList pSrc = sqlite3SrcListAppend( pParse.db, 0, yymsp[-1].minor.yy0, yymsp[0].minor.yy0 ); + yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_IN, yymsp[-3].minor.yy118.pExpr, 0, 0 ); + if ( yygotominor.yy118.pExpr != null ) + { + yygotominor.yy118.pExpr.x.pSelect = sqlite3SelectNew( pParse, 0, pSrc, 0, 0, 0, 0, 0, 0, 0 ); + ExprSetProperty( yygotominor.yy118.pExpr, EP_xIsSelect ); + sqlite3ExprSetHeight( pParse, yygotominor.yy118.pExpr ); + } + else + { + sqlite3SrcListDelete( pParse.db, ref pSrc ); + } + if ( yymsp[-2].minor.yy4 != 0 ) + yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0 ); + yygotominor.yy118.zStart = yymsp[-3].minor.yy118.zStart; + yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z != null ? yymsp[0].minor.yy0.z.Substring( yymsp[0].minor.yy0.n ) : yymsp[-1].minor.yy0.z.Substring( yymsp[-1].minor.yy0.n ); + } + //#line 3160 "parse.c" + break; + case 231: /* expr ::= EXISTS LP select RP */ + //#line 1029 "parse.y" + { + Expr p = yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_EXISTS, 0, 0, 0 ); + if ( p != null ) + { + p.x.pSelect = yymsp[-1].minor.yy387; + ExprSetProperty( p, EP_xIsSelect ); + sqlite3ExprSetHeight( pParse, p ); + } + else + { + sqlite3SelectDelete( pParse.db, ref yymsp[-1].minor.yy387 ); + } + yygotominor.yy118.zStart = yymsp[-3].minor.yy0.z; + yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring( yymsp[0].minor.yy0.n ); //z[yymsp[0].minor.yy0.n]; + } + //#line 3176 "parse.c" + break; + case 232: /* expr ::= CASE case_operand case_exprlist case_else END */ + //#line 1044 "parse.y" + { + yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_CASE, yymsp[-3].minor.yy314, yymsp[-1].minor.yy314, 0 ); + if ( yygotominor.yy118.pExpr != null ) + { + yygotominor.yy118.pExpr.x.pList = yymsp[-2].minor.yy322; + sqlite3ExprSetHeight( pParse, yygotominor.yy118.pExpr ); + } + else + { + sqlite3ExprListDelete( pParse.db, ref yymsp[-2].minor.yy322 ); + } + yygotominor.yy118.zStart = yymsp[-4].minor.yy0.z; + yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring( yymsp[0].minor.yy0.n );//z[yymsp[0].minor.yy0.n]; + } + //#line 3191 "parse.c" + break; + case 233: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ + //#line 1057 "parse.y" + { + yygotominor.yy322 = sqlite3ExprListAppend( pParse, yymsp[-4].minor.yy322, yymsp[-2].minor.yy118.pExpr ); + yygotominor.yy322 = sqlite3ExprListAppend( pParse, yygotominor.yy322, yymsp[0].minor.yy118.pExpr ); + } + //#line 3199 "parse.c" + break; + case 234: /* case_exprlist ::= WHEN expr THEN expr */ + //#line 1061 "parse.y" + { + yygotominor.yy322 = sqlite3ExprListAppend( pParse, 0, yymsp[-2].minor.yy118.pExpr ); + yygotominor.yy322 = sqlite3ExprListAppend( pParse, yygotominor.yy322, yymsp[0].minor.yy118.pExpr ); + } + //#line 3207 "parse.c" + break; + case 243: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */ + //#line 1090 "parse.y" + { + sqlite3CreateIndex( pParse, yymsp[-6].minor.yy0, yymsp[-5].minor.yy0, + sqlite3SrcListAppend( pParse.db, 0, yymsp[-3].minor.yy0, 0 ), yymsp[-1].minor.yy322, yymsp[-9].minor.yy4, + yymsp[-10].minor.yy0, yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy4 ); + } + //#line 3216 "parse.c" + break; + case 244: /* uniqueflag ::= UNIQUE */ + case 298: /* raisetype ::= ABORT */ //yytestcase(yyruleno==298); + //#line 1097 "parse.y" + { + yygotominor.yy4 = OE_Abort; + } + //#line 3222 "parse.c" + break; + case 245: /* uniqueflag ::= */ + //#line 1098 "parse.y" + { + yygotominor.yy4 = OE_None; + } + //#line 3227 "parse.c" + break; + case 248: /* idxlist ::= idxlist COMMA nm collate sortorder */ + //#line 1107 "parse.y" + { + Expr p = null; + if ( yymsp[-1].minor.yy0.n > 0 ) + { + p = sqlite3Expr( pParse.db, TK_COLUMN, null ); + sqlite3ExprSetCollByToken( pParse, p, yymsp[-1].minor.yy0 ); + } + yygotominor.yy322 = sqlite3ExprListAppend( pParse, yymsp[-4].minor.yy322, p ); + sqlite3ExprListSetName( pParse, yygotominor.yy322, yymsp[-2].minor.yy0, 1 ); + sqlite3ExprListCheckLength( pParse, yygotominor.yy322, "index" ); + if ( yygotominor.yy322 != null ) + yygotominor.yy322.a[yygotominor.yy322.nExpr - 1].sortOrder = (u8)yymsp[0].minor.yy4; + } + //#line 3242 "parse.c" + break; + case 249: /* idxlist ::= nm collate sortorder */ + //#line 1118 "parse.y" + { + Expr p = null; + if ( yymsp[-1].minor.yy0.n > 0 ) + { + p = sqlite3PExpr( pParse, TK_COLUMN, 0, 0, 0 ); + sqlite3ExprSetCollByToken( pParse, p, yymsp[-1].minor.yy0 ); + } + yygotominor.yy322 = sqlite3ExprListAppend( pParse, 0, p ); + sqlite3ExprListSetName( pParse, yygotominor.yy322, yymsp[-2].minor.yy0, 1 ); + sqlite3ExprListCheckLength( pParse, yygotominor.yy322, "index" ); + if ( yygotominor.yy322 != null ) + yygotominor.yy322.a[yygotominor.yy322.nExpr - 1].sortOrder = (u8)yymsp[0].minor.yy4; + } + //#line 3257 "parse.c" + break; + case 250: /* collate ::= */ + //#line 1131 "parse.y" + { + yygotominor.yy0.z = null; + yygotominor.yy0.n = 0; + } + //#line 3262 "parse.c" + break; + case 252: /* cmd ::= DROP INDEX ifexists fullname */ + //#line 1137 "parse.y" + { + sqlite3DropIndex( pParse, yymsp[0].minor.yy259, yymsp[-1].minor.yy4 ); + } + //#line 3267 "parse.c" + break; + case 253: /* cmd ::= VACUUM */ + case 254: /* cmd ::= VACUUM nm */ //yytestcase(yyruleno==254); + //#line 1143 "parse.y" + { + sqlite3Vacuum( pParse ); + } + //#line 3273 "parse.c" + break; + case 255: /* cmd ::= PRAGMA nm dbnm */ + //#line 1151 "parse.y" + { + sqlite3Pragma( pParse, yymsp[-1].minor.yy0, yymsp[0].minor.yy0, 0, 0 ); + } + //#line 3278 "parse.c" + break; + case 256: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ + //#line 1152 "parse.y" + { + sqlite3Pragma( pParse, yymsp[-3].minor.yy0, yymsp[-2].minor.yy0, yymsp[0].minor.yy0, 0 ); + } + //#line 3283 "parse.c" + break; + case 257: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ + //#line 1153 "parse.y" + { + sqlite3Pragma( pParse, yymsp[-4].minor.yy0, yymsp[-3].minor.yy0, yymsp[-1].minor.yy0, 0 ); + } + //#line 3288 "parse.c" + break; + case 258: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ + //#line 1155 "parse.y" + { + sqlite3Pragma( pParse, yymsp[-3].minor.yy0, yymsp[-2].minor.yy0, yymsp[0].minor.yy0, 1 ); + } + //#line 3293 "parse.c" + break; + case 259: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ + //#line 1157 "parse.y" + { + sqlite3Pragma( pParse, yymsp[-4].minor.yy0, yymsp[-3].minor.yy0, yymsp[-1].minor.yy0, 1 ); + } + //#line 3298 "parse.c" + break; + case 270: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ + //#line 1175 "parse.y" + { + Token all = new Token(); + //all.z = yymsp[-3].minor.yy0.z; + //all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; + all.n = (int)( yymsp[-3].minor.yy0.z.Length - yymsp[0].minor.yy0.z.Length ) + yymsp[0].minor.yy0.n; + all.z = yymsp[-3].minor.yy0.z.Substring( 0, all.n ); + sqlite3FinishTrigger( pParse, yymsp[-1].minor.yy203, all ); + } + //#line 3308 "parse.c" + break; + case 271: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ + //#line 1184 "parse.y" + { + sqlite3BeginTrigger( pParse, yymsp[-7].minor.yy0, yymsp[-6].minor.yy0, yymsp[-5].minor.yy4, yymsp[-4].minor.yy90.a, yymsp[-4].minor.yy90.b, yymsp[-2].minor.yy259, yymsp[0].minor.yy314, yymsp[-10].minor.yy4, yymsp[-8].minor.yy4 ); + yygotominor.yy0 = ( yymsp[-6].minor.yy0.n == 0 ? yymsp[-7].minor.yy0 : yymsp[-6].minor.yy0 ); + } + //#line 3316 "parse.c" + break; + case 272: /* trigger_time ::= BEFORE */ + case 275: /* trigger_time ::= */ //yytestcase(yyruleno==275); + //#line 1190 "parse.y" + { + yygotominor.yy4 = TK_BEFORE; + } + //#line 3322 "parse.c" + break; + case 273: /* trigger_time ::= AFTER */ + //#line 1191 "parse.y" + { + yygotominor.yy4 = TK_AFTER; + } + //#line 3327 "parse.c" + break; + case 274: /* trigger_time ::= INSTEAD OF */ + //#line 1192 "parse.y" + { + yygotominor.yy4 = TK_INSTEAD; + } + //#line 3332 "parse.c" + break; + case 276: /* trigger_event ::= DELETE|INSERT */ + case 277: /* trigger_event ::= UPDATE */ //yytestcase(yyruleno==277); + //#line 1197 "parse.y" + { + yygotominor.yy90.a = yymsp[0].major; + yygotominor.yy90.b = null; + } + //#line 3338 "parse.c" + break; + case 278: /* trigger_event ::= UPDATE OF inscollist */ + //#line 1199 "parse.y" + { + yygotominor.yy90.a = TK_UPDATE; + yygotominor.yy90.b = yymsp[0].minor.yy384; + } + //#line 3343 "parse.c" + break; + case 281: /* when_clause ::= */ + case 303: /* key_opt ::= */ //yytestcase(yyruleno==303); + //#line 1206 "parse.y" + { + yygotominor.yy314 = null; + } + //#line 3349 "parse.c" + break; + case 282: /* when_clause ::= WHEN expr */ + case 304: /* key_opt ::= KEY expr */ //yytestcase(yyruleno==304); + //#line 1207 "parse.y" + { + yygotominor.yy314 = yymsp[0].minor.yy118.pExpr; + } + //#line 3355 "parse.c" + break; + case 283: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ + //#line 1211 "parse.y" + { + Debug.Assert( yymsp[-2].minor.yy203 != null ); + yymsp[-2].minor.yy203.pLast.pNext = yymsp[-1].minor.yy203; + yymsp[-2].minor.yy203.pLast = yymsp[-1].minor.yy203; + yygotominor.yy203 = yymsp[-2].minor.yy203; + } + //#line 3365 "parse.c" + break; + case 284: /* trigger_cmd_list ::= trigger_cmd SEMI */ + //#line 1217 "parse.y" + { + Debug.Assert( yymsp[-1].minor.yy203 != null ); + yymsp[-1].minor.yy203.pLast = yymsp[-1].minor.yy203; + yygotominor.yy203 = yymsp[-1].minor.yy203; + } + //#line 3374 "parse.c" + break; + case 286: /* trnm ::= nm DOT nm */ + //#line 1229 "parse.y" + { + yygotominor.yy0 = yymsp[0].minor.yy0; + sqlite3ErrorMsg( pParse, + "qualified table names are not allowed on INSERT, UPDATE, and DELETE " + + "statements within triggers" ); + } + //#line 3384 "parse.c" + break; + case 288: /* tridxby ::= INDEXED BY nm */ + //#line 1241 "parse.y" + { + sqlite3ErrorMsg( pParse, + "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " + + "within triggers" ); + } + //#line 3393 "parse.c" + break; + case 289: /* tridxby ::= NOT INDEXED */ + //#line 1246 "parse.y" + { + sqlite3ErrorMsg( pParse, + "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " + + "within triggers" ); + } + //#line 3402 "parse.c" + break; + case 290: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */ + //#line 1259 "parse.y" + { + yygotominor.yy203 = sqlite3TriggerUpdateStep( pParse.db, yymsp[-4].minor.yy0, yymsp[-1].minor.yy322, yymsp[0].minor.yy314, yymsp[-5].minor.yy210 ); + } + //#line 3407 "parse.c" + break; + case 291: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt VALUES LP itemlist RP */ + //#line 1264 "parse.y" + { + yygotominor.yy203 = sqlite3TriggerInsertStep( pParse.db, yymsp[-5].minor.yy0, yymsp[-4].minor.yy384, yymsp[-1].minor.yy322, 0, yymsp[-7].minor.yy210 ); + } + //#line 3412 "parse.c" + break; + case 292: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */ + //#line 1267 "parse.y" + { + yygotominor.yy203 = sqlite3TriggerInsertStep( pParse.db, yymsp[-2].minor.yy0, yymsp[-1].minor.yy384, 0, yymsp[0].minor.yy387, yymsp[-4].minor.yy210 ); + } + //#line 3417 "parse.c" + break; + case 293: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */ + //#line 1271 "parse.y" + { + yygotominor.yy203 = sqlite3TriggerDeleteStep( pParse.db, yymsp[-2].minor.yy0, yymsp[0].minor.yy314 ); + } + //#line 3422 "parse.c" + break; + case 294: /* trigger_cmd ::= select */ + //#line 1274 "parse.y" + { + yygotominor.yy203 = sqlite3TriggerSelectStep( pParse.db, yymsp[0].minor.yy387 ); + } + //#line 3427 "parse.c" + break; + case 295: /* expr ::= RAISE LP IGNORE RP */ + //#line 1277 "parse.y" + { + yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_RAISE, 0, 0, 0 ); + if ( yygotominor.yy118.pExpr != null ) + { + yygotominor.yy118.pExpr.affinity = (char)OE_Ignore; + } + yygotominor.yy118.zStart = yymsp[-3].minor.yy0.z; + yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring( yymsp[0].minor.yy0.n );//z[yymsp[0].minor.yy0.n]; + } + //#line 3439 "parse.c" + break; + case 296: /* expr ::= RAISE LP raisetype COMMA nm RP */ + //#line 1285 "parse.y" + { + yygotominor.yy118.pExpr = sqlite3PExpr( pParse, TK_RAISE, 0, 0, yymsp[-1].minor.yy0 ); + if ( yygotominor.yy118.pExpr != null ) + { + yygotominor.yy118.pExpr.affinity = (char)yymsp[-3].minor.yy4; + } + yygotominor.yy118.zStart = yymsp[-5].minor.yy0.z; + yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z.Substring( yymsp[0].minor.yy0.n );//z[yymsp[0].minor.yy0.n]; + } + //#line 3451 "parse.c" + break; + case 297: /* raisetype ::= ROLLBACK */ + //#line 1296 "parse.y" + { + yygotominor.yy4 = OE_Rollback; + } + //#line 3456 "parse.c" + break; + case 299: /* raisetype ::= FAIL */ + //#line 1298 "parse.y" + { + yygotominor.yy4 = OE_Fail; + } + //#line 3461 "parse.c" + break; + case 300: /* cmd ::= DROP TRIGGER ifexists fullname */ + //#line 1303 "parse.y" + { + sqlite3DropTrigger( pParse, yymsp[0].minor.yy259, yymsp[-1].minor.yy4 ); + } + //#line 3468 "parse.c" + break; + case 301: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ + //#line 1310 "parse.y" + { + sqlite3Attach( pParse, yymsp[-3].minor.yy118.pExpr, yymsp[-1].minor.yy118.pExpr, yymsp[0].minor.yy314 ); + } + //#line 3475 "parse.c" + break; + case 302: /* cmd ::= DETACH database_kw_opt expr */ + //#line 1313 "parse.y" + { + sqlite3Detach( pParse, yymsp[0].minor.yy118.pExpr ); + } + //#line 3482 "parse.c" + break; + case 307: /* cmd ::= REINDEX */ + //#line 1328 "parse.y" + { + sqlite3Reindex( pParse, 0, 0 ); + } + //#line 3487 "parse.c" + break; + case 308: /* cmd ::= REINDEX nm dbnm */ + //#line 1329 "parse.y" + { + sqlite3Reindex( pParse, yymsp[-1].minor.yy0, yymsp[0].minor.yy0 ); + } + //#line 3492 "parse.c" + break; + case 309: /* cmd ::= ANALYZE */ + //#line 1334 "parse.y" + { + sqlite3Analyze( pParse, 0, 0 ); + } + //#line 3497 "parse.c" + break; + case 310: /* cmd ::= ANALYZE nm dbnm */ + //#line 1335 "parse.y" + { + sqlite3Analyze( pParse, yymsp[-1].minor.yy0, yymsp[0].minor.yy0 ); + } + //#line 3502 "parse.c" + break; + case 311: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ + //#line 1340 "parse.y" + { + sqlite3AlterRenameTable( pParse, yymsp[-3].minor.yy259, yymsp[0].minor.yy0 ); + } + //#line 3509 "parse.c" + break; + case 312: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */ + //#line 1343 "parse.y" + { + sqlite3AlterFinishAddColumn( pParse, yymsp[0].minor.yy0 ); + } + //#line 3516 "parse.c" + break; + case 313: /* add_column_fullname ::= fullname */ + //#line 1346 "parse.y" + { + pParse.db.lookaside.bEnabled = 0; + sqlite3AlterBeginAddColumn( pParse, yymsp[0].minor.yy259 ); + } + //#line 3524 "parse.c" + break; + case 316: /* cmd ::= create_vtab */ + //#line 1356 "parse.y" + { + sqlite3VtabFinishParse( pParse, (Token)null ); + } + //#line 3529 "parse.c" + break; + case 317: /* cmd ::= create_vtab LP vtabarglist RP */ + //#line 1357 "parse.y" + { + sqlite3VtabFinishParse( pParse, yymsp[0].minor.yy0 ); + } + //#line 3534 "parse.c" + break; + case 318: /* create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm */ + //#line 1358 "parse.y" + { + sqlite3VtabBeginParse( pParse, yymsp[-3].minor.yy0, yymsp[-2].minor.yy0, yymsp[0].minor.yy0 ); + } + //#line 3541 "parse.c" + break; + case 321: /* vtabarg ::= */ + //#line 1363 "parse.y" + { + sqlite3VtabArgInit( pParse ); + } + //#line 3546 "parse.c" + break; + case 323: /* vtabargtoken ::= ANY */ + case 324: /* vtabargtoken ::= lp anylist RP */ //yytestcase(yyruleno==324); + case 325: /* lp ::= LP */ //yytestcase(yyruleno==325); + //#line 1365 "parse.y" + { + sqlite3VtabArgExtend( pParse, yymsp[0].minor.yy0 ); + } + //#line 3553 "parse.c" + break; + default: + /* (0) input ::= cmdlist */ + //yytestcase(yyruleno==0); + /* (1) cmdlist ::= cmdlist ecmd */ + //yytestcase(yyruleno==1); + /* (2) cmdlist ::= ecmd */ + //yytestcase(yyruleno==2); + /* (3) ecmd ::= SEMI */ + //yytestcase(yyruleno==3); + /* (4) ecmd ::= explain cmdx SEMI */ + //yytestcase(yyruleno==4); + /* (10) trans_opt ::= */ + //yytestcase(yyruleno==10); + /* (11) trans_opt ::= TRANSACTION */ + //yytestcase(yyruleno==11); + /* (12) trans_opt ::= TRANSACTION nm */ + //yytestcase(yyruleno==12); + /* (20) savepoint_opt ::= SAVEPOINT */ + //yytestcase(yyruleno==20); + /* (21) savepoint_opt ::= */ + //yytestcase(yyruleno==21); + /* (25) cmd ::= create_table create_table_args */ + //yytestcase(yyruleno==25); + /* (34) columnlist ::= columnlist COMMA column */ + //yytestcase(yyruleno==34); + /* (35) columnlist ::= column */ + //yytestcase(yyruleno==35); + /* (44) type ::= */ + //yytestcase(yyruleno==44); + /* (51) signed ::= plus_num */ + //yytestcase(yyruleno==51); + /* (52) signed ::= minus_num */ + //yytestcase(yyruleno==52); + /* (53) carglist ::= carglist carg */ + //yytestcase(yyruleno==53); + /* (54) carglist ::= */ + //yytestcase(yyruleno==54); + /* (55) carg ::= CONSTRAINT nm ccons */ + //yytestcase(yyruleno==55); + /* (56) carg ::= ccons */ + //yytestcase(yyruleno==56); + /* (62) ccons ::= NULL onconf */ + //yytestcase(yyruleno==62); + /* (90) conslist ::= conslist COMMA tcons */ + //yytestcase(yyruleno==90); + /* (91) conslist ::= conslist tcons */ + //yytestcase(yyruleno==91); + /* (92) conslist ::= tcons */ + //yytestcase(yyruleno==92); + /* (93) tcons ::= CONSTRAINT nm */ + //yytestcase(yyruleno==93); + /* (268) plus_opt ::= PLUS */ + //yytestcase(yyruleno==268); + /* (269) plus_opt ::= */ + //yytestcase(yyruleno==269); + /* (279) foreach_clause ::= */ + //yytestcase(yyruleno==279); + /* (280) foreach_clause ::= FOR EACH ROW */ + //yytestcase(yyruleno==280); + /* (287) tridxby ::= */ + //yytestcase(yyruleno==287); + /* (305) database_kw_opt ::= DATABASE */ + //yytestcase(yyruleno==305); + /* (306) database_kw_opt ::= */ + //yytestcase(yyruleno==306); + /* (314) kwcolumn_opt ::= */ + //yytestcase(yyruleno==314); + /* (315) kwcolumn_opt ::= COLUMNKW */ + //yytestcase(yyruleno==315); + /* (319) vtabarglist ::= vtabarg */ + //yytestcase(yyruleno==319); + /* (320) vtabarglist ::= vtabarglist COMMA vtabarg */ + //yytestcase(yyruleno==320); + /* (322) vtabarg ::= vtabarg vtabargtoken */ + //yytestcase(yyruleno==322); + /* (326) anylist ::= */ + //yytestcase(yyruleno==326); + /* (327) anylist ::= anylist LP anylist RP */ + //yytestcase(yyruleno==327); + /* (328) anylist ::= anylist ANY */ + //yytestcase(yyruleno==328); + break; + }; + yygoto = yyRuleInfo[yyruleno].lhs; + yysize = yyRuleInfo[yyruleno].nrhs; + yypParser.yyidx -= yysize; + yyact = yy_find_reduce_action( yymsp[-yysize].stateno, (YYCODETYPE)yygoto ); + if ( yyact < YYNSTATE ) + { #if NDEBUG /* If we are not debugging and the reduce action popped at least ** one element off the stack, then we can push the new element back @@ -3989,111 +4081,120 @@ int yyruleno /* Number of the rule by which to reduce */ yymsp[0].minor = yygotominor; }else #endif - { - yy_shift(yypParser, yyact, yygoto, yygotominor); - } - } else { - Debug.Assert(yyact == YYNSTATE + YYNRULE + 1); - yy_accept(yypParser); - } + { + yy_shift( yypParser, yyact, yygoto, yygotominor ); } + } + else + { + Debug.Assert( yyact == YYNSTATE + YYNRULE + 1 ); + yy_accept( yypParser ); + } + } - /* - ** The following code executes when the parse fails - */ + /* + ** The following code executes when the parse fails + */ #if !YYNOERRORRECOVERY - static void yy_parse_failed( - yyParser yypParser /* The parser */ - ) { - Parse pParse = yypParser.pParse; // sqlite3ParserARG_FETCH; + static void yy_parse_failed( + yyParser yypParser /* The parser */ + ) + { + Parse pParse = yypParser.pParse; // sqlite3ParserARG_FETCH; #if !NDEBUG - if (yyTraceFILE != null) { - Debugger.Break(); // TODO -- fprintf(yyTraceFILE, "%sFail!\n", yyTracePrompt); - } + if ( yyTraceFILE != null ) + { + Debugger.Break(); // TODO -- fprintf(yyTraceFILE, "%sFail!\n", yyTracePrompt); + } #endif - while (yypParser.yyidx >= 0) - yy_pop_parser_stack(yypParser); - /* Here code is inserted which will be executed whenever the - ** parser fails */ - yypParser.pParse = pParse;// sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ - } + while ( yypParser.yyidx >= 0 ) + yy_pop_parser_stack( yypParser ); + /* Here code is inserted which will be executed whenever the + ** parser fails */ + yypParser.pParse = pParse;// sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ + } #endif //* YYNOERRORRECOVERY */ - /* - ** The following code executes when a syntax error first occurs. - */ - static void yy_syntax_error( - yyParser yypParser, /* The parser */ - int yymajor, /* The major type of the error token */ - YYMINORTYPE yyminor /* The minor type of the error token */ - ) { - Parse pParse = yypParser.pParse; // sqlite3ParserARG_FETCH; - //#define TOKEN (yyminor.yy0) - //#line 32 "parse.y" + /* +** The following code executes when a syntax error first occurs. +*/ + static void yy_syntax_error( + yyParser yypParser, /* The parser */ + int yymajor, /* The major type of the error token */ + YYMINORTYPE yyminor /* The minor type of the error token */ + ) + { + Parse pParse = yypParser.pParse; // sqlite3ParserARG_FETCH; + //#define TOKEN (yyminor.yy0) + //#line 32 "parse.y" - UNUSED_PARAMETER(yymajor); /* Silence some compiler warnings */ - Debug.Assert(yyminor.yy0.z.Length > 0); //TOKEN.z[0]); /* The tokenizer always gives us a token */ - sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", yyminor.yy0);//&TOKEN); - pParse.parseError = 1; - //#line 3661 "parse.c" - yypParser.pParse = pParse; // sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ - } + UNUSED_PARAMETER( yymajor ); /* Silence some compiler warnings */ + Debug.Assert( yyminor.yy0.z.Length > 0 ); //TOKEN.z[0]); /* The tokenizer always gives us a token */ + sqlite3ErrorMsg( pParse, "near \"%T\": syntax error", yyminor.yy0 );//&TOKEN); + pParse.parseError = 1; + //#line 3661 "parse.c" + yypParser.pParse = pParse; // sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ + } - /* - ** The following is executed when the parser accepts - */ - static void yy_accept( - yyParser yypParser /* The parser */ - ) { - Parse pParse = yypParser.pParse; // sqlite3ParserARG_FETCH; + /* + ** The following is executed when the parser accepts + */ + static void yy_accept( + yyParser yypParser /* The parser */ + ) + { + Parse pParse = yypParser.pParse; // sqlite3ParserARG_FETCH; #if !NDEBUG - if (yyTraceFILE != null) { - fprintf(yyTraceFILE, "%sAccept!\n", yyTracePrompt); - } + if ( yyTraceFILE != null ) + { + fprintf( yyTraceFILE, "%sAccept!\n", yyTracePrompt ); + } #endif - while (yypParser.yyidx >= 0) - yy_pop_parser_stack(yypParser); - /* Here code is inserted which will be executed whenever the - ** parser accepts */ - yypParser.pParse = pParse;// sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ - } + while ( yypParser.yyidx >= 0 ) + yy_pop_parser_stack( yypParser ); + /* Here code is inserted which will be executed whenever the + ** parser accepts */ + yypParser.pParse = pParse;// sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ + } - /* The main parser program. - ** The first argument is a pointer to a structure obtained from - ** "sqlite3ParserAlloc" which describes the current state of the parser. - ** The second argument is the major token number. The third is - ** the minor token. The fourth optional argument is whatever the - ** user wants (and specified in the grammar) and is available for - ** use by the action routines. - ** - ** Inputs: - **
    - **
  • A pointer to the parser (an opaque structure.) - **
  • The major token number. - **
  • The minor token number. - **
  • An option argument of a grammar-specified type. - **
- ** - ** Outputs: - ** None. - */ - static void sqlite3Parser( - yyParser yyp, /* The parser */ - int yymajor, /* The major token code number */ - sqlite3ParserTOKENTYPE yyminor /* The value for the token */ - , Parse pParse //sqlite3ParserARG_PDECL /* Optional %extra_argument parameter */ - ) { - YYMINORTYPE yyminorunion = new YYMINORTYPE(); - int yyact; /* The parser action. */ - bool yyendofinput; /* True if we are at the end of input */ + /* The main parser program. + ** The first argument is a pointer to a structure obtained from + ** "sqlite3ParserAlloc" which describes the current state of the parser. + ** The second argument is the major token number. The third is + ** the minor token. The fourth optional argument is whatever the + ** user wants (and specified in the grammar) and is available for + ** use by the action routines. + ** + ** Inputs: + **
    + **
  • A pointer to the parser (an opaque structure.) + **
  • The major token number. + **
  • The minor token number. + **
  • An option argument of a grammar-specified type. + **
+ ** + ** Outputs: + ** None. + */ + static void sqlite3Parser( + yyParser yyp, /* The parser */ + int yymajor, /* The major token code number */ + sqlite3ParserTOKENTYPE yyminor /* The value for the token */ + , Parse pParse //sqlite3ParserARG_PDECL /* Optional %extra_argument parameter */ + ) + { + YYMINORTYPE yyminorunion = new YYMINORTYPE(); + int yyact; /* The parser action. */ + bool yyendofinput; /* True if we are at the end of input */ #if YYERRORSYMBOL int yyerrorhit = null; /* True if yymajor has invoked an error */ #endif - yyParser yypParser; /* The parser */ + yyParser yypParser; /* The parser */ - /* (re)initialize the parser, if necessary */ - yypParser = yyp; - if (yypParser.yyidx < 0) { + /* (re)initialize the parser, if necessary */ + yypParser = yyp; + if ( yypParser.yyidx < 0 ) + { #if YYSTACKDEPTH//<=0 if( yypParser.yystksz <=0 ){ memset(yyminorunion, 0, yyminorunion).Length; @@ -4101,40 +4202,48 @@ static void sqlite3Parser( return; } #endif - yypParser.yyidx = 0; - yypParser.yyerrcnt = -1; - yypParser.yystack[0] = new yyStackEntry(); - yypParser.yystack[0].stateno = 0; - yypParser.yystack[0].major = 0; - } - yyminorunion.yy0 = yyminor.Copy(); - yyendofinput = (yymajor == 0); - yypParser.pParse = pParse;// sqlite3ParserARG_STORE; + yypParser.yyidx = 0; + yypParser.yyerrcnt = -1; + yypParser.yystack[0] = new yyStackEntry(); + yypParser.yystack[0].stateno = 0; + yypParser.yystack[0].major = 0; + } + yyminorunion.yy0 = yyminor.Copy(); + yyendofinput = ( yymajor == 0 ); + yypParser.pParse = pParse;// sqlite3ParserARG_STORE; #if !NDEBUG - if (yyTraceFILE != null) { - fprintf(yyTraceFILE, "%sInput %s\n", yyTracePrompt, yyTokenName[yymajor]); - } + if ( yyTraceFILE != null ) + { + fprintf( yyTraceFILE, "%sInput %s\n", yyTracePrompt, yyTokenName[yymajor] ); + } #endif - do { - yyact = yy_find_shift_action(yypParser, (YYCODETYPE)yymajor); - if (yyact < YYNSTATE) { - Debug.Assert(!yyendofinput); /* Impossible to shift the $ token */ - yy_shift(yypParser, yyact, yymajor, yyminorunion); - yypParser.yyerrcnt--; - yymajor = YYNOCODE; - } else if (yyact < YYNSTATE + YYNRULE) { - yy_reduce(yypParser, yyact - YYNSTATE); - } else { - Debug.Assert(yyact == YY_ERROR_ACTION); + do + { + yyact = yy_find_shift_action( yypParser, (YYCODETYPE)yymajor ); + if ( yyact < YYNSTATE ) + { + Debug.Assert( !yyendofinput ); /* Impossible to shift the $ token */ + yy_shift( yypParser, yyact, yymajor, yyminorunion ); + yypParser.yyerrcnt--; + yymajor = YYNOCODE; + } + else if ( yyact < YYNSTATE + YYNRULE ) + { + yy_reduce( yypParser, yyact - YYNSTATE ); + } + else + { + Debug.Assert( yyact == YY_ERROR_ACTION ); #if YYERRORSYMBOL int yymx; #endif #if !NDEBUG - if (yyTraceFILE != null) { - Debugger.Break(); // TODO -- fprintf(yyTraceFILE, "%sSyntax Error!\n", yyTracePrompt); - } + if ( yyTraceFILE != null ) + { + Debugger.Break(); // TODO -- fprintf(yyTraceFILE, "%sSyntax Error!\n", yyTracePrompt); + } #endif #if YYERRORSYMBOL /* A syntax error has occurred. @@ -4203,44 +4312,49 @@ static void sqlite3Parser( yy_destructor(yypParser,(YYCODETYPE)yymajor,yyminorunion); yymajor = YYNOCODE; #else // * YYERRORSYMBOL is not defined */ - /* This is what we do if the grammar does not define ERROR: - ** - ** * Report an error message, and throw away the input token. - ** - ** * If the input token is $, then fail the parse. - ** - ** As before, subsequent error messages are suppressed until - ** three input tokens have been successfully shifted. - */ - if (yypParser.yyerrcnt <= 0) { - yy_syntax_error(yypParser, yymajor, yyminorunion); - } - yypParser.yyerrcnt = 3; - yy_destructor(yypParser, (YYCODETYPE)yymajor, yyminorunion); - if (yyendofinput) { - yy_parse_failed(yypParser); - } - yymajor = YYNOCODE; + /* This is what we do if the grammar does not define ERROR: +** +** * Report an error message, and throw away the input token. +** +** * If the input token is $, then fail the parse. +** +** As before, subsequent error messages are suppressed until +** three input tokens have been successfully shifted. +*/ + if ( yypParser.yyerrcnt <= 0 ) + { + yy_syntax_error( yypParser, yymajor, yyminorunion ); + } + yypParser.yyerrcnt = 3; + yy_destructor( yypParser, (YYCODETYPE)yymajor, yyminorunion ); + if ( yyendofinput ) + { + yy_parse_failed( yypParser ); + } + yymajor = YYNOCODE; #endif - } - } while (yymajor != YYNOCODE && yypParser.yyidx >= 0); - return; } - public class yymsp { - public yyParser _yyParser; - public int _yyidx; - // CONSTRUCTOR - public yymsp(ref yyParser pointer_to_yyParser, int yyidx) //' Parser and Stack Index - { - this._yyParser = pointer_to_yyParser; - this._yyidx = yyidx; - } - // Default Value - public yyStackEntry this[int offset] { - get { - return _yyParser.yystack[_yyidx + offset]; - } - } + } while ( yymajor != YYNOCODE && yypParser.yyidx >= 0 ); + return; + } + public class yymsp + { + public yyParser _yyParser; + public int _yyidx; + // CONSTRUCTOR + public yymsp( ref yyParser pointer_to_yyParser, int yyidx ) //' Parser and Stack Index + { + this._yyParser = pointer_to_yyParser; + this._yyidx = yyidx; + } + // Default Value + public yyStackEntry this[int offset] + { + get + { + return _yyParser.yystack[_yyidx + offset]; } + } } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/parse_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/parse_h.cs index 383cfab7e..8e08e31aa 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/parse_h.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/parse_h.cs @@ -8,321 +8,323 @@ ************************************************************************* */ -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - //#define TK_SEMI 1 - //#define TK_EXPLAIN 2 - //#define TK_QUERY 3 - //#define TK_PLAN 4 - //#define TK_BEGIN 5 - //#define TK_TRANSACTION 6 - //#define TK_DEFERRED 7 - //#define TK_IMMEDIATE 8 - //#define TK_EXCLUSIVE 9 - //#define TK_COMMIT 10 - //#define TK_END 11 - //#define TK_ROLLBACK 12 - //#define TK_SAVEPOINT 13 - //#define TK_RELEASE 14 - //#define TK_TO 15 - //#define TK_TABLE 16 - //#define TK_CREATE 17 - //#define TK_IF 18 - //#define TK_NOT 19 - //#define TK_EXISTS 20 - //#define TK_TEMP 21 - //#define TK_LP 22 - //#define TK_RP 23 - //#define TK_AS 24 - //#define TK_COMMA 25 - //#define TK_ID 26 - //#define TK_INDEXED 27 - //#define TK_ABORT 28 - //#define TK_ACTION 29 - //#define TK_AFTER 30 - //#define TK_ANALYZE 31 - //#define TK_ASC 32 - //#define TK_ATTACH 33 - //#define TK_BEFORE 34 - //#define TK_BY 35 - //#define TK_CASCADE 36 - //#define TK_CAST 37 - //#define TK_COLUMNKW 38 - //#define TK_CONFLICT 39 - //#define TK_DATABASE 40 - //#define TK_DESC 41 - //#define TK_DETACH 42 - //#define TK_EACH 43 - //#define TK_FAIL 44 - //#define TK_FOR 45 - //#define TK_IGNORE 46 - //#define TK_INITIALLY 47 - //#define TK_INSTEAD 48 - //#define TK_LIKE_KW 49 - //#define TK_MATCH 50 - //#define TK_NO 51 - //#define TK_KEY 52 - //#define TK_OF 53 - //#define TK_OFFSET 54 - //#define TK_PRAGMA 55 - //#define TK_RAISE 56 - //#define TK_REPLACE 57 - //#define TK_RESTRICT 58 - //#define TK_ROW 59 - //#define TK_TRIGGER 60 - //#define TK_VACUUM 61 - //#define TK_VIEW 62 - //#define TK_VIRTUAL 63 - //#define TK_REINDEX 64 - //#define TK_RENAME 65 - //#define TK_CTIME_KW 66 - //#define TK_ANY 67 - //#define TK_OR 68 - //#define TK_AND 69 - //#define TK_IS 70 - //#define TK_BETWEEN 71 - //#define TK_IN 72 - //#define TK_ISNULL 73 - //#define TK_NOTNULL 74 - //#define TK_NE 75 - //#define TK_EQ 76 - //#define TK_GT 77 - //#define TK_LE 78 - //#define TK_LT 79 - //#define TK_GE 80 - //#define TK_ESCAPE 81 - //#define TK_BITAND 82 - //#define TK_BITOR 83 - //#define TK_LSHIFT 84 - //#define TK_RSHIFT 85 - //#define TK_PLUS 86 - //#define TK_MINUS 87 - //#define TK_STAR 88 - //#define TK_SLASH 89 - //#define TK_REM 90 - //#define TK_CONCAT 91 - //#define TK_COLLATE 92 - //#define TK_BITNOT 93 - //#define TK_STRING 94 - //#define TK_JOIN_KW 95 - //#define TK_CONSTRAINT 96 - //#define TK_DEFAULT 97 - //#define TK_NULL 98 - //#define TK_PRIMARY 99 - //#define TK_UNIQUE 100 - //#define TK_CHECK 101 - //#define TK_REFERENCES 102 - //#define TK_AUTOINCR 103 - //#define TK_ON 104 - //#define TK_INSERT 105 - //#define TK_DELETE 106 - //#define TK_UPDATE 107 - //#define TK_SET 108 - //#define TK_DEFERRABLE 109 - //#define TK_FOREIGN 110 - //#define TK_DROP 111 - //#define TK_UNION 112 - //#define TK_ALL 113 - //#define TK_EXCEPT 114 - //#define TK_INTERSECT 115 - //#define TK_SELECT 116 - //#define TK_DISTINCT 117 - //#define TK_DOT 118 - //#define TK_FROM 119 - //#define TK_JOIN 120 - //#define TK_USING 121 - //#define TK_ORDER 122 - //#define TK_GROUP 123 - //#define TK_HAVING 124 - //#define TK_LIMIT 125 - //#define TK_WHERE 126 - //#define TK_INTO 127 - //#define TK_VALUES 128 - //#define TK_INTEGER 129 - //#define TK_FLOAT 130 - //#define TK_BLOB 131 - //#define TK_REGISTER 132 - //#define TK_VARIABLE 133 - //#define TK_CASE 134 - //#define TK_WHEN 135 - //#define TK_THEN 136 - //#define TK_ELSE 137 - //#define TK_INDEX 138 - //#define TK_ALTER 139 - //#define TK_ADD 140 - //#define TK_TO_TEXT 141 - //#define TK_TO_BLOB 142 - //#define TK_TO_NUMERIC 143 - //#define TK_TO_INT 144 - //#define TK_TO_REAL 145 - //#define TK_ISNOT 146 - //#define TK_END_OF_FILE 147 - //#define TK_ILLEGAL 148 - //#define TK_SPACE 149 - //#define TK_UNCLOSED_STRING 150 - //#define TK_FUNCTION 151 - //#define TK_COLUMN 152 - //#define TK_AGG_FUNCTION 153 - //#define TK_AGG_COLUMN 154 - //#define TK_CONST_FUNC 155 - //#define TK_UMINUS 156 - //#define TK_UPLUS 157 - public const int TK_SEMI = 1; - public const int TK_EXPLAIN = 2; - public const int TK_QUERY = 3; - public const int TK_PLAN = 4; - public const int TK_BEGIN = 5; - public const int TK_TRANSACTION = 6; - public const int TK_DEFERRED = 7; - public const int TK_IMMEDIATE = 8; - public const int TK_EXCLUSIVE = 9; - public const int TK_COMMIT = 10; - public const int TK_END = 11; - public const int TK_ROLLBACK = 12; - public const int TK_SAVEPOINT = 13; - public const int TK_RELEASE = 14; - public const int TK_TO = 15; - public const int TK_TABLE = 16; - public const int TK_CREATE = 17; - public const int TK_IF = 18; - public const int TK_NOT = 19; - public const int TK_EXISTS = 20; - public const int TK_TEMP = 21; - public const int TK_LP = 22; - public const int TK_RP = 23; - public const int TK_AS = 24; - public const int TK_COMMA = 25; - public const int TK_ID = 26; - public const int TK_INDEXED = 27; - public const int TK_ABORT = 28; - public const int TK_ACTION = 29; - public const int TK_AFTER = 30; - public const int TK_ANALYZE = 31; - public const int TK_ASC = 32; - public const int TK_ATTACH = 33; - public const int TK_BEFORE = 34; - public const int TK_BY = 35; - public const int TK_CASCADE = 36; - public const int TK_CAST = 37; - public const int TK_COLUMNKW = 38; - public const int TK_CONFLICT = 39; - public const int TK_DATABASE = 40; - public const int TK_DESC = 41; - public const int TK_DETACH = 42; - public const int TK_EACH = 43; - public const int TK_FAIL = 44; - public const int TK_FOR = 45; - public const int TK_IGNORE = 46; - public const int TK_INITIALLY = 47; - public const int TK_INSTEAD = 48; - public const int TK_LIKE_KW = 49; - public const int TK_MATCH = 50; - public const int TK_NO = 51; - public const int TK_KEY = 52; - public const int TK_OF = 53; - public const int TK_OFFSET = 54; - public const int TK_PRAGMA = 55; - public const int TK_RAISE = 56; - public const int TK_REPLACE = 57; - public const int TK_RESTRICT = 58; - public const int TK_ROW = 59; - public const int TK_TRIGGER = 60; - public const int TK_VACUUM = 61; - public const int TK_VIEW = 62; - public const int TK_VIRTUAL = 63; - public const int TK_REINDEX = 64; - public const int TK_RENAME = 65; - public const int TK_CTIME_KW = 66; - public const int TK_ANY = 67; - public const int TK_OR = 68; - public const int TK_AND = 69; - public const int TK_IS = 70; - public const int TK_BETWEEN = 71; - public const int TK_IN = 72; - public const int TK_ISNULL = 73; - public const int TK_NOTNULL = 74; - public const int TK_NE = 75; - public const int TK_EQ = 76; - public const int TK_GT = 77; - public const int TK_LE = 78; - public const int TK_LT = 79; - public const int TK_GE = 80; - public const int TK_ESCAPE = 81; - public const int TK_BITAND = 82; - public const int TK_BITOR = 83; - public const int TK_LSHIFT = 84; - public const int TK_RSHIFT = 85; - public const int TK_PLUS = 86; - public const int TK_MINUS = 87; - public const int TK_STAR = 88; - public const int TK_SLASH = 89; - public const int TK_REM = 90; - public const int TK_CONCAT = 91; - public const int TK_COLLATE = 92; - public const int TK_BITNOT = 93; - public const int TK_STRING = 94; - public const int TK_JOIN_KW = 95; - public const int TK_CONSTRAINT = 96; - public const int TK_DEFAULT = 97; - public const int TK_NULL = 98; - public const int TK_PRIMARY = 99; - public const int TK_UNIQUE = 100; - public const int TK_CHECK = 101; - public const int TK_REFERENCES = 102; - public const int TK_AUTOINCR = 103; - public const int TK_ON = 104; - public const int TK_INSERT = 105; - public const int TK_DELETE = 106; - public const int TK_UPDATE = 107; - public const int TK_SET = 108; - public const int TK_DEFERRABLE = 109; - public const int TK_FOREIGN = 110; - public const int TK_DROP = 111; - public const int TK_UNION = 112; - public const int TK_ALL = 113; - public const int TK_EXCEPT = 114; - public const int TK_INTERSECT = 115; - public const int TK_SELECT = 116; - public const int TK_DISTINCT = 117; - public const int TK_DOT = 118; - public const int TK_FROM = 119; - public const int TK_JOIN = 120; - public const int TK_USING = 121; - public const int TK_ORDER = 122; - public const int TK_GROUP = 123; - public const int TK_HAVING = 124; - public const int TK_LIMIT = 125; - public const int TK_WHERE = 126; - public const int TK_INTO = 127; - public const int TK_VALUES = 128; - public const int TK_INTEGER = 129; - public const int TK_FLOAT = 130; - public const int TK_BLOB = 131; - public const int TK_REGISTER = 132; - public const int TK_VARIABLE = 133; - public const int TK_CASE = 134; - public const int TK_WHEN = 135; - public const int TK_THEN = 136; - public const int TK_ELSE = 137; - public const int TK_INDEX = 138; - public const int TK_ALTER = 139; - public const int TK_ADD = 140; - public const int TK_TO_TEXT = 141; - public const int TK_TO_BLOB = 142; - public const int TK_TO_NUMERIC = 143; - public const int TK_TO_INT = 144; - public const int TK_TO_REAL = 145; - public const int TK_ISNOT = 146; - public const int TK_END_OF_FILE = 147; - public const int TK_ILLEGAL = 148; - public const int TK_SPACE = 149; - public const int TK_UNCLOSED_STRING = 150; - public const int TK_FUNCTION = 151; - public const int TK_COLUMN = 152; - public const int TK_AGG_FUNCTION = 153; - public const int TK_AGG_COLUMN = 154; - public const int TK_CONST_FUNC = 155; - public const int TK_UMINUS = 156; - public const int TK_UPLUS = 157; - } +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + //#define TK_SEMI 1 + //#define TK_EXPLAIN 2 + //#define TK_QUERY 3 + //#define TK_PLAN 4 + //#define TK_BEGIN 5 + //#define TK_TRANSACTION 6 + //#define TK_DEFERRED 7 + //#define TK_IMMEDIATE 8 + //#define TK_EXCLUSIVE 9 + //#define TK_COMMIT 10 + //#define TK_END 11 + //#define TK_ROLLBACK 12 + //#define TK_SAVEPOINT 13 + //#define TK_RELEASE 14 + //#define TK_TO 15 + //#define TK_TABLE 16 + //#define TK_CREATE 17 + //#define TK_IF 18 + //#define TK_NOT 19 + //#define TK_EXISTS 20 + //#define TK_TEMP 21 + //#define TK_LP 22 + //#define TK_RP 23 + //#define TK_AS 24 + //#define TK_COMMA 25 + //#define TK_ID 26 + //#define TK_INDEXED 27 + //#define TK_ABORT 28 + //#define TK_ACTION 29 + //#define TK_AFTER 30 + //#define TK_ANALYZE 31 + //#define TK_ASC 32 + //#define TK_ATTACH 33 + //#define TK_BEFORE 34 + //#define TK_BY 35 + //#define TK_CASCADE 36 + //#define TK_CAST 37 + //#define TK_COLUMNKW 38 + //#define TK_CONFLICT 39 + //#define TK_DATABASE 40 + //#define TK_DESC 41 + //#define TK_DETACH 42 + //#define TK_EACH 43 + //#define TK_FAIL 44 + //#define TK_FOR 45 + //#define TK_IGNORE 46 + //#define TK_INITIALLY 47 + //#define TK_INSTEAD 48 + //#define TK_LIKE_KW 49 + //#define TK_MATCH 50 + //#define TK_NO 51 + //#define TK_KEY 52 + //#define TK_OF 53 + //#define TK_OFFSET 54 + //#define TK_PRAGMA 55 + //#define TK_RAISE 56 + //#define TK_REPLACE 57 + //#define TK_RESTRICT 58 + //#define TK_ROW 59 + //#define TK_TRIGGER 60 + //#define TK_VACUUM 61 + //#define TK_VIEW 62 + //#define TK_VIRTUAL 63 + //#define TK_REINDEX 64 + //#define TK_RENAME 65 + //#define TK_CTIME_KW 66 + //#define TK_ANY 67 + //#define TK_OR 68 + //#define TK_AND 69 + //#define TK_IS 70 + //#define TK_BETWEEN 71 + //#define TK_IN 72 + //#define TK_ISNULL 73 + //#define TK_NOTNULL 74 + //#define TK_NE 75 + //#define TK_EQ 76 + //#define TK_GT 77 + //#define TK_LE 78 + //#define TK_LT 79 + //#define TK_GE 80 + //#define TK_ESCAPE 81 + //#define TK_BITAND 82 + //#define TK_BITOR 83 + //#define TK_LSHIFT 84 + //#define TK_RSHIFT 85 + //#define TK_PLUS 86 + //#define TK_MINUS 87 + //#define TK_STAR 88 + //#define TK_SLASH 89 + //#define TK_REM 90 + //#define TK_CONCAT 91 + //#define TK_COLLATE 92 + //#define TK_BITNOT 93 + //#define TK_STRING 94 + //#define TK_JOIN_KW 95 + //#define TK_CONSTRAINT 96 + //#define TK_DEFAULT 97 + //#define TK_NULL 98 + //#define TK_PRIMARY 99 + //#define TK_UNIQUE 100 + //#define TK_CHECK 101 + //#define TK_REFERENCES 102 + //#define TK_AUTOINCR 103 + //#define TK_ON 104 + //#define TK_INSERT 105 + //#define TK_DELETE 106 + //#define TK_UPDATE 107 + //#define TK_SET 108 + //#define TK_DEFERRABLE 109 + //#define TK_FOREIGN 110 + //#define TK_DROP 111 + //#define TK_UNION 112 + //#define TK_ALL 113 + //#define TK_EXCEPT 114 + //#define TK_INTERSECT 115 + //#define TK_SELECT 116 + //#define TK_DISTINCT 117 + //#define TK_DOT 118 + //#define TK_FROM 119 + //#define TK_JOIN 120 + //#define TK_USING 121 + //#define TK_ORDER 122 + //#define TK_GROUP 123 + //#define TK_HAVING 124 + //#define TK_LIMIT 125 + //#define TK_WHERE 126 + //#define TK_INTO 127 + //#define TK_VALUES 128 + //#define TK_INTEGER 129 + //#define TK_FLOAT 130 + //#define TK_BLOB 131 + //#define TK_REGISTER 132 + //#define TK_VARIABLE 133 + //#define TK_CASE 134 + //#define TK_WHEN 135 + //#define TK_THEN 136 + //#define TK_ELSE 137 + //#define TK_INDEX 138 + //#define TK_ALTER 139 + //#define TK_ADD 140 + //#define TK_TO_TEXT 141 + //#define TK_TO_BLOB 142 + //#define TK_TO_NUMERIC 143 + //#define TK_TO_INT 144 + //#define TK_TO_REAL 145 + //#define TK_ISNOT 146 + //#define TK_END_OF_FILE 147 + //#define TK_ILLEGAL 148 + //#define TK_SPACE 149 + //#define TK_UNCLOSED_STRING 150 + //#define TK_FUNCTION 151 + //#define TK_COLUMN 152 + //#define TK_AGG_FUNCTION 153 + //#define TK_AGG_COLUMN 154 + //#define TK_CONST_FUNC 155 + //#define TK_UMINUS 156 + //#define TK_UPLUS 157 + public const int TK_SEMI = 1; + public const int TK_EXPLAIN = 2; + public const int TK_QUERY = 3; + public const int TK_PLAN = 4; + public const int TK_BEGIN = 5; + public const int TK_TRANSACTION = 6; + public const int TK_DEFERRED = 7; + public const int TK_IMMEDIATE = 8; + public const int TK_EXCLUSIVE = 9; + public const int TK_COMMIT = 10; + public const int TK_END = 11; + public const int TK_ROLLBACK = 12; + public const int TK_SAVEPOINT = 13; + public const int TK_RELEASE = 14; + public const int TK_TO = 15; + public const int TK_TABLE = 16; + public const int TK_CREATE = 17; + public const int TK_IF = 18; + public const int TK_NOT = 19; + public const int TK_EXISTS = 20; + public const int TK_TEMP = 21; + public const int TK_LP = 22; + public const int TK_RP = 23; + public const int TK_AS = 24; + public const int TK_COMMA = 25; + public const int TK_ID = 26; + public const int TK_INDEXED = 27; + public const int TK_ABORT = 28; + public const int TK_ACTION = 29; + public const int TK_AFTER = 30; + public const int TK_ANALYZE = 31; + public const int TK_ASC = 32; + public const int TK_ATTACH = 33; + public const int TK_BEFORE = 34; + public const int TK_BY = 35; + public const int TK_CASCADE = 36; + public const int TK_CAST = 37; + public const int TK_COLUMNKW = 38; + public const int TK_CONFLICT = 39; + public const int TK_DATABASE = 40; + public const int TK_DESC = 41; + public const int TK_DETACH = 42; + public const int TK_EACH = 43; + public const int TK_FAIL = 44; + public const int TK_FOR = 45; + public const int TK_IGNORE = 46; + public const int TK_INITIALLY = 47; + public const int TK_INSTEAD = 48; + public const int TK_LIKE_KW = 49; + public const int TK_MATCH = 50; + public const int TK_NO = 51; + public const int TK_KEY = 52; + public const int TK_OF = 53; + public const int TK_OFFSET = 54; + public const int TK_PRAGMA = 55; + public const int TK_RAISE = 56; + public const int TK_REPLACE = 57; + public const int TK_RESTRICT = 58; + public const int TK_ROW = 59; + public const int TK_TRIGGER = 60; + public const int TK_VACUUM = 61; + public const int TK_VIEW = 62; + public const int TK_VIRTUAL = 63; + public const int TK_REINDEX = 64; + public const int TK_RENAME = 65; + public const int TK_CTIME_KW = 66; + public const int TK_ANY = 67; + public const int TK_OR = 68; + public const int TK_AND = 69; + public const int TK_IS = 70; + public const int TK_BETWEEN = 71; + public const int TK_IN = 72; + public const int TK_ISNULL = 73; + public const int TK_NOTNULL = 74; + public const int TK_NE = 75; + public const int TK_EQ = 76; + public const int TK_GT = 77; + public const int TK_LE = 78; + public const int TK_LT = 79; + public const int TK_GE = 80; + public const int TK_ESCAPE = 81; + public const int TK_BITAND = 82; + public const int TK_BITOR = 83; + public const int TK_LSHIFT = 84; + public const int TK_RSHIFT = 85; + public const int TK_PLUS = 86; + public const int TK_MINUS = 87; + public const int TK_STAR = 88; + public const int TK_SLASH = 89; + public const int TK_REM = 90; + public const int TK_CONCAT = 91; + public const int TK_COLLATE = 92; + public const int TK_BITNOT = 93; + public const int TK_STRING = 94; + public const int TK_JOIN_KW = 95; + public const int TK_CONSTRAINT = 96; + public const int TK_DEFAULT = 97; + public const int TK_NULL = 98; + public const int TK_PRIMARY = 99; + public const int TK_UNIQUE = 100; + public const int TK_CHECK = 101; + public const int TK_REFERENCES = 102; + public const int TK_AUTOINCR = 103; + public const int TK_ON = 104; + public const int TK_INSERT = 105; + public const int TK_DELETE = 106; + public const int TK_UPDATE = 107; + public const int TK_SET = 108; + public const int TK_DEFERRABLE = 109; + public const int TK_FOREIGN = 110; + public const int TK_DROP = 111; + public const int TK_UNION = 112; + public const int TK_ALL = 113; + public const int TK_EXCEPT = 114; + public const int TK_INTERSECT = 115; + public const int TK_SELECT = 116; + public const int TK_DISTINCT = 117; + public const int TK_DOT = 118; + public const int TK_FROM = 119; + public const int TK_JOIN = 120; + public const int TK_USING = 121; + public const int TK_ORDER = 122; + public const int TK_GROUP = 123; + public const int TK_HAVING = 124; + public const int TK_LIMIT = 125; + public const int TK_WHERE = 126; + public const int TK_INTO = 127; + public const int TK_VALUES = 128; + public const int TK_INTEGER = 129; + public const int TK_FLOAT = 130; + public const int TK_BLOB = 131; + public const int TK_REGISTER = 132; + public const int TK_VARIABLE = 133; + public const int TK_CASE = 134; + public const int TK_WHEN = 135; + public const int TK_THEN = 136; + public const int TK_ELSE = 137; + public const int TK_INDEX = 138; + public const int TK_ALTER = 139; + public const int TK_ADD = 140; + public const int TK_TO_TEXT = 141; + public const int TK_TO_BLOB = 142; + public const int TK_TO_NUMERIC = 143; + public const int TK_TO_INT = 144; + public const int TK_TO_REAL = 145; + public const int TK_ISNOT = 146; + public const int TK_END_OF_FILE = 147; + public const int TK_ILLEGAL = 148; + public const int TK_SPACE = 149; + public const int TK_UNCLOSED_STRING = 150; + public const int TK_FUNCTION = 151; + public const int TK_COLUMN = 152; + public const int TK_AGG_FUNCTION = 153; + public const int TK_AGG_COLUMN = 154; + public const int TK_CONST_FUNC = 155; + public const int TK_UMINUS = 156; + public const int TK_UPLUS = 157; + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/pcache1_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/pcache1_c.cs index 9d834aa74..34e4ab00b 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/pcache1_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/pcache1_c.cs @@ -1,332 +1,358 @@ using System.Diagnostics; +using u32 = System.UInt32; using Pgno = System.UInt32; -namespace Community.CsharpSqlite { - using sqlite3_pcache = Sqlite3.PCache1; - public partial class Sqlite3 { - /* - ** 2008 November 05 - ** - ** 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 implements the default page cache implementation (the - ** sqlite3_pcache interface). It also contains part of the implementation - ** of the SQLITE_CONFIG_PAGECACHE and sqlite3_release_memory() features. - ** If the default page cache implementation is overriden, then neither of - ** these two features are available. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ +namespace Community.CsharpSqlite +{ + using sqlite3_pcache = Sqlite3.PCache1; + public partial class Sqlite3 + { + /* + ** 2008 November 05 + ** + ** 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 implements the default page cache implementation (the + ** sqlite3_pcache interface). It also contains part of the implementation + ** of the SQLITE_CONFIG_PAGECACHE and sqlite3_release_memory() features. + ** If the default page cache implementation is overriden, then neither of + ** these two features are available. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ - //#include "sqliteInt.h" - - //typedef struct PCache1 PCache1; - //typedef struct PgHdr1 PgHdr1; - //typedef struct PgFreeslot PgFreeslot; - //typedef struct PGroup PGroup; - - /* Each page cache (or PCache) belongs to a PGroup. A PGroup is a set - ** of one or more PCaches that are able to recycle each others unpinned - ** pages when they are under memory pressure. A PGroup is an instance of - ** the following object. - ** - ** This page cache implementation works in one of two modes: - ** - ** (1) Every PCache is the sole member of its own PGroup. There is - ** one PGroup per PCache. - ** - ** (2) There is a single global PGroup that all PCaches are a member - ** of. - ** - ** Mode 1 uses more memory (since PCache instances are not able to rob - ** unused pages from other PCaches) but it also operates without a mutex, - ** and is therefore often faster. Mode 2 requires a mutex in order to be - ** threadsafe, but is able recycle pages more efficient. - ** - ** For mode (1), PGroup.mutex is NULL. For mode (2) there is only a single - ** PGroup which is the pcache1.grp global variable and its mutex is - ** SQLITE_MUTEX_STATIC_LRU. - */ - public class PGroup { - public sqlite3_mutex mutex; /* MUTEX_STATIC_LRU or NULL */ - public int nMaxPage; /* Sum of nMax for purgeable caches */ - public int nMinPage; /* Sum of nMin for purgeable caches */ - public int mxPinned; /* nMaxpage + 10 - nMinPage */ - public int nCurrentPage; /* Number of purgeable pages allocated */ - public PgHdr1 pLruHead, pLruTail; /* LRU list of unpinned pages */ - // C# - public PGroup() { - mutex = new sqlite3_mutex(); - } - }; - - /* Each page cache is an instance of the following object. Every - ** open database file (including each in-memory database and each - ** temporary or transient database) has a single page cache which - ** is an instance of this object. - ** - ** Pointers to structures of this type are cast and returned as - ** opaque sqlite3_pcache* handles. - */ - public class PCache1 { - /* Cache configuration parameters. Page size (szPage) and the purgeable - ** flag (bPurgeable) are set when the cache is created. nMax may be - ** modified at any time by a call to the pcache1CacheSize() method. - ** The PGroup mutex must be held when accessing nMax. - */ - public PGroup pGroup; /* PGroup this cache belongs to */ - public int szPage; /* Size of allocated pages in bytes */ - public bool bPurgeable; /* True if cache is purgeable */ - public int nMin; /* Minimum number of pages reserved */ - public int nMax; /* Configured "cache_size" value */ - public int n90pct; /* nMax*9/10 */ - - /* Hash table of all pages. The following variables may only be accessed - ** when the accessor is holding the PGroup mutex. - */ - public int nRecyclable; /* Number of pages in the LRU list */ - public int nPage; /* Total number of pages in apHash */ - public int nHash; /* Number of slots in apHash[] */ - public PgHdr1[] apHash; /* Hash table for fast lookup by key */ - - public Pgno iMaxKey; /* Largest key seen since xTruncate() */ - - public void Clear() { - nRecyclable = 0; - nPage = 0; - nHash = 0; - apHash = null; - iMaxKey = 0; - } - }; - - /* - ** Each cache entry is represented by an instance of the following - ** structure. A buffer of PgHdr1.pCache.szPage bytes is allocated - ** directly before this structure in memory (see the PGHDR1_TO_PAGE() - ** macro below). - */ - public class PgHdr1 { - public Pgno iKey; /* Key value (page number) */ - public PgHdr1 pNext; /* Next in hash table chain */ - public PCache1 pCache; /* Cache that currently owns this page */ - public PgHdr1 pLruNext; /* Next in LRU list of unpinned pages */ - public PgHdr1 pLruPrev; /* Previous in LRU list of unpinned pages */ - - // For C# - public PgHdr pPgHdr = new PgHdr(); /* Pointer to Actual Page Header */ - - public void Clear() { - this.iKey = 0; - this.pNext = null; - this.pCache = null; - this.pPgHdr.Clear(); - } - - }; - - /* - ** Free slots in the allocator used to divide up the buffer provided using - ** the SQLITE_CONFIG_PAGECACHE mechanism. - */ - public class PgFreeslot { - public PgFreeslot pNext; /* Next free slot */ - public PgHdr _PgHdr; /* Next Free Header */ - }; + //#include "sqliteInt.h" + + //typedef struct PCache1 PCache1; + //typedef struct PgHdr1 PgHdr1; + //typedef struct PgFreeslot PgFreeslot; + //typedef struct PGroup PGroup; + + /* Each page cache (or PCache) belongs to a PGroup. A PGroup is a set + ** of one or more PCaches that are able to recycle each others unpinned + ** pages when they are under memory pressure. A PGroup is an instance of + ** the following object. + ** + ** This page cache implementation works in one of two modes: + ** + ** (1) Every PCache is the sole member of its own PGroup. There is + ** one PGroup per PCache. + ** + ** (2) There is a single global PGroup that all PCaches are a member + ** of. + ** + ** Mode 1 uses more memory (since PCache instances are not able to rob + ** unused pages from other PCaches) but it also operates without a mutex, + ** and is therefore often faster. Mode 2 requires a mutex in order to be + ** threadsafe, but is able recycle pages more efficient. + ** + ** For mode (1), PGroup.mutex is NULL. For mode (2) there is only a single + ** PGroup which is the pcache1.grp global variable and its mutex is + ** SQLITE_MUTEX_STATIC_LRU. + */ + public class PGroup + { + public sqlite3_mutex mutex; /* MUTEX_STATIC_LRU or NULL */ + public int nMaxPage; /* Sum of nMax for purgeable caches */ + public int nMinPage; /* Sum of nMin for purgeable caches */ + public int mxPinned; /* nMaxpage + 10 - nMinPage */ + public int nCurrentPage; /* Number of purgeable pages allocated */ + public PgHdr1 pLruHead, pLruTail; /* LRU list of unpinned pages */ + // C# + public PGroup() + { + mutex = new sqlite3_mutex(); + } + }; + + /* Each page cache is an instance of the following object. Every + ** open database file (including each in-memory database and each + ** temporary or transient database) has a single page cache which + ** is an instance of this object. + ** + ** Pointers to structures of this type are cast and returned as + ** opaque sqlite3_pcache* handles. + */ + public class PCache1 + { + /* Cache configuration parameters. Page size (szPage) and the purgeable + ** flag (bPurgeable) are set when the cache is created. nMax may be + ** modified at any time by a call to the pcache1CacheSize() method. + ** The PGroup mutex must be held when accessing nMax. + */ + public PGroup pGroup; /* PGroup this cache belongs to */ + public int szPage; /* Size of allocated pages in bytes */ + public bool bPurgeable; /* True if cache is purgeable */ + public int nMin; /* Minimum number of pages reserved */ + public int nMax; /* Configured "cache_size" value */ + public int n90pct; /* nMax*9/10 */ + + /* Hash table of all pages. The following variables may only be accessed + ** when the accessor is holding the PGroup mutex. + */ + public int nRecyclable; /* Number of pages in the LRU list */ + public int nPage; /* Total number of pages in apHash */ + public int nHash; /* Number of slots in apHash[] */ + public PgHdr1[] apHash; /* Hash table for fast lookup by key */ + + public Pgno iMaxKey; /* Largest key seen since xTruncate() */ + + public void Clear() + { + nRecyclable = 0; + nPage = 0; + nHash = 0; + apHash = null; + iMaxKey = 0; + } + }; - /* - ** Global data used by this cache. - */ - public class PCacheGlobal { - public PGroup grp; /* The global PGroup for mode (2) */ - - /* Variables related to SQLITE_CONFIG_PAGECACHE settings. The - ** szSlot, nSlot, pStart, pEnd, nReserve, and isInit values are all - ** fixed at sqlite3_initialize() time and do not require mutex protection. - ** The nFreeSlot and pFree values do require mutex protection. - */ - public bool isInit; /* True if initialized */ - public int szSlot; /* Size of each free slot */ - public int nSlot; /* The number of pcache slots */ - public int nReserve; /* Try to keep nFreeSlot above this */ - public object pStart, pEnd; /* Bounds of pagecache malloc range */ - /* Above requires no mutex. Use mutex below for variable that follow. */ - public sqlite3_mutex mutex; /* Mutex for accessing the following: */ - public int nFreeSlot; /* Number of unused pcache slots */ - public PgFreeslot pFree; /* Free page blocks */ - /* The following value requires a mutex to change. We skip the mutex on - ** reading because (1) most platforms read a 32-bit integer atomically and - ** (2) even if an incorrect value is read, no great harm is done since this - ** is really just an optimization. */ - public bool bUnderPressure; /* True if low on PAGECACHE memory */ - - // C# - public PCacheGlobal() { - grp = new PGroup(); - } - } - static PCacheGlobal pcache = new PCacheGlobal(); + /* + ** Each cache entry is represented by an instance of the following + ** structure. A buffer of PgHdr1.pCache.szPage bytes is allocated + ** directly before this structure in memory (see the PGHDR1_TO_PAGE() + ** macro below). + */ + public class PgHdr1 + { + public Pgno iKey; /* Key value (page number) */ + public PgHdr1 pNext; /* Next in hash table chain */ + public PCache1 pCache; /* Cache that currently owns this page */ + public PgHdr1 pLruNext; /* Next in LRU list of unpinned pages */ + public PgHdr1 pLruPrev; /* Previous in LRU list of unpinned pages */ - /* - ** All code in this file should access the global structure above via the - ** alias "pcache1". This ensures that the WSD emulation is used when - ** compiling for systems that do not support real WSD. - */ - //#define pcache1 (GLOBAL(struct PCacheGlobal, pcache1_g)) - static PCacheGlobal pcache1 = pcache; - - /* - ** When a PgHdr1 structure is allocated, the associated PCache1.szPage - ** bytes of data are located directly before it in memory (i.e. the total - ** size of the allocation is sizeof(PgHdr1)+PCache1.szPage byte). The - ** PGHDR1_TO_PAGE() macro takes a pointer to a PgHdr1 structure as - ** an argument and returns a pointer to the associated block of szPage - ** bytes. The PAGE_TO_PGHDR1() macro does the opposite: its argument is - ** a pointer to a block of szPage bytes of data and the return value is - ** a pointer to the associated PgHdr1 structure. - ** - ** Debug.Assert( PGHDR1_TO_PAGE(PAGE_TO_PGHDR1(pCache, X))==X ); - */ - //#define PGHDR1_TO_PAGE(p) (void)(((char)p) - p.pCache.szPage) - static PgHdr PGHDR1_TO_PAGE(PgHdr1 p) { - return p.pPgHdr; - } + // For C# + public PgHdr pPgHdr = new PgHdr(); /* Pointer to Actual Page Header */ - //#define PAGE_TO_PGHDR1(c, p) (PgHdr1)(((char)p) + c.szPage) - static PgHdr1 PAGE_TO_PGHDR1(PCache1 c, PgHdr p) { - return p.pPgHdr1; - } + public void Clear() + { + this.iKey = 0; + this.pNext = null; + this.pCache = null; + this.pPgHdr.Clear(); + } - /* - ** Macros to enter and leave the PCache LRU mutex. - */ - //#define pcache1EnterMutex(X) sqlite3_mutex_enter((X).mutex) - static void pcache1EnterMutex(PGroup X) { - sqlite3_mutex_enter(X.mutex); - } - //#define pcache1LeaveMutex(X) sqlite3_mutex_leave((X).mutex) - static void pcache1LeaveMutex(PGroup X) { - sqlite3_mutex_leave(X.mutex); - } + }; - /******************************************************************************/ - /******** Page Allocation/SQLITE_CONFIG_PCACHE Related Functions **************/ - - /* - ** This function is called during initialization if a static buffer is - ** supplied to use for the page-cache by passing the SQLITE_CONFIG_PAGECACHE - ** verb to sqlite3_config(). Parameter pBuf points to an allocation large - ** enough to contain 'n' buffers of 'sz' bytes each. - ** - ** This routine is called from sqlite3_initialize() and so it is guaranteed - ** to be serialized already. There is no need for further mutexing. - */ - static void sqlite3PCacheBufferSetup(object pBuf, int sz, int n) { - if (pcache1.isInit) { - PgFreeslot p; - sz = ROUNDDOWN8(sz); - pcache1.szSlot = sz; - pcache1.nSlot = pcache1.nFreeSlot = n; - pcache1.nReserve = n > 90 ? 10 : (n / 10 + 1); - pcache1.pStart = null; - pcache1.pEnd = null; - pcache1.pFree = null; - pcache1.bUnderPressure = false; - while (n-- > 0) { - p = new PgFreeslot();// (PgFreeslot)pBuf; - p._PgHdr = new PgHdr(); - p.pNext = pcache1.pFree; - pcache1.pFree = p; - //pBuf = (void)&((char)pBuf)[sz]; - } - pcache1.pEnd = pBuf; - } - } + /* + ** Free slots in the allocator used to divide up the buffer provided using + ** the SQLITE_CONFIG_PAGECACHE mechanism. + */ + public class PgFreeslot + { + public PgFreeslot pNext; /* Next free slot */ + public PgHdr _PgHdr; /* Next Free Header */ + }; - /* - ** Malloc function used within this file to allocate space from the buffer - ** configured using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no - ** such buffer exists or there is no space left in it, this function falls - ** back to sqlite3Malloc(). - ** - ** Multiple threads can run this routine at the same time. Global variables - ** in pcache1 need to be protected via mutex. - */ - static PgHdr pcache1Alloc(int nByte) { - PgHdr p = null; - Debug.Assert(sqlite3_mutex_notheld(pcache1.grp.mutex)); - sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte); - if (nByte <= pcache1.szSlot) { - sqlite3_mutex_enter(pcache1.mutex); - p = pcache1.pFree._PgHdr; - if (p != null) { - pcache1.pFree = pcache1.pFree.pNext; - pcache1.nFreeSlot--; - pcache1.bUnderPressure = pcache1.nFreeSlot < pcache1.nReserve; - Debug.Assert(pcache1.nFreeSlot >= 0); - sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, 1); - } - sqlite3_mutex_leave(pcache1.mutex); - } - if (p == null) { - /* Memory is not available in the SQLITE_CONFIG_PAGECACHE pool. Get - ** it from sqlite3Malloc instead. - */ - p = new PgHdr();// sqlite3Malloc( nByte ); - //if ( p != null ) - { - int sz = nByte;//sqlite3MallocSize( p ); - sqlite3_mutex_enter(pcache1.mutex); - sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz); - sqlite3_mutex_leave(pcache1.mutex); - } - sqlite3MemdebugSetType(p, MEMTYPE_PCACHE); - } - return p; + /* + ** Global data used by this cache. + */ + public class PCacheGlobal + { + public PGroup grp; /* The global PGroup for mode (2) */ + + /* Variables related to SQLITE_CONFIG_PAGECACHE settings. The + ** szSlot, nSlot, pStart, pEnd, nReserve, and isInit values are all + ** fixed at sqlite3_initialize() time and do not require mutex protection. + ** The nFreeSlot and pFree values do require mutex protection. + */ + public bool isInit; /* True if initialized */ + public int szSlot; /* Size of each free slot */ + public int nSlot; /* The number of pcache slots */ + public int nReserve; /* Try to keep nFreeSlot above this */ + public object pStart, pEnd; /* Bounds of pagecache malloc range */ + /* Above requires no mutex. Use mutex below for variable that follow. */ + public sqlite3_mutex mutex; /* Mutex for accessing the following: */ + public int nFreeSlot; /* Number of unused pcache slots */ + public PgFreeslot pFree; /* Free page blocks */ + /* The following value requires a mutex to change. We skip the mutex on + ** reading because (1) most platforms read a 32-bit integer atomically and + ** (2) even if an incorrect value is read, no great harm is done since this + ** is really just an optimization. */ + public bool bUnderPressure; /* True if low on PAGECACHE memory */ + + // C# + public PCacheGlobal() + { + grp = new PGroup(); + } + } + static PCacheGlobal pcache = new PCacheGlobal(); + + /* + ** All code in this file should access the global structure above via the + ** alias "pcache1". This ensures that the WSD emulation is used when + ** compiling for systems that do not support real WSD. + */ + //#define pcache1 (GLOBAL(struct PCacheGlobal, pcache1_g)) + static PCacheGlobal pcache1 = pcache; + + /* + ** When a PgHdr1 structure is allocated, the associated PCache1.szPage + ** bytes of data are located directly before it in memory (i.e. the total + ** size of the allocation is sizeof(PgHdr1)+PCache1.szPage byte). The + ** PGHDR1_TO_PAGE() macro takes a pointer to a PgHdr1 structure as + ** an argument and returns a pointer to the associated block of szPage + ** bytes. The PAGE_TO_PGHDR1() macro does the opposite: its argument is + ** a pointer to a block of szPage bytes of data and the return value is + ** a pointer to the associated PgHdr1 structure. + ** + ** Debug.Assert( PGHDR1_TO_PAGE(PAGE_TO_PGHDR1(pCache, X))==X ); + */ + //#define PGHDR1_TO_PAGE(p) (void)(((char)p) - p.pCache.szPage) + static PgHdr PGHDR1_TO_PAGE( PgHdr1 p ) + { + return p.pPgHdr; + } + + //#define PAGE_TO_PGHDR1(c, p) (PgHdr1)(((char)p) + c.szPage) + static PgHdr1 PAGE_TO_PGHDR1( PCache1 c, PgHdr p ) + { + return p.pPgHdr1; + } + + /* + ** Macros to enter and leave the PCache LRU mutex. + */ + //#define pcache1EnterMutex(X) sqlite3_mutex_enter((X).mutex) + static void pcache1EnterMutex( PGroup X ) + { + sqlite3_mutex_enter( X.mutex ); + } + //#define pcache1LeaveMutex(X) sqlite3_mutex_leave((X).mutex) + static void pcache1LeaveMutex( PGroup X ) + { + sqlite3_mutex_leave( X.mutex ); + } + + /******************************************************************************/ + /******** Page Allocation/SQLITE_CONFIG_PCACHE Related Functions **************/ + + /* + ** This function is called during initialization if a static buffer is + ** supplied to use for the page-cache by passing the SQLITE_CONFIG_PAGECACHE + ** verb to sqlite3_config(). Parameter pBuf points to an allocation large + ** enough to contain 'n' buffers of 'sz' bytes each. + ** + ** This routine is called from sqlite3_initialize() and so it is guaranteed + ** to be serialized already. There is no need for further mutexing. + */ + static void sqlite3PCacheBufferSetup( object pBuf, int sz, int n ) + { + if ( pcache1.isInit ) + { + PgFreeslot p; + sz = ROUNDDOWN8( sz ); + pcache1.szSlot = sz; + pcache1.nSlot = pcache1.nFreeSlot = n; + pcache1.nReserve = n > 90 ? 10 : ( n / 10 + 1 ); + pcache1.pStart = null; + pcache1.pEnd = null; + pcache1.pFree = null; + pcache1.bUnderPressure = false; + while ( n-- > 0 ) + { + p = new PgFreeslot();// (PgFreeslot)pBuf; + p._PgHdr = new PgHdr(); + p.pNext = pcache1.pFree; + pcache1.pFree = p; + //pBuf = (void)&((char)pBuf)[sz]; } + pcache1.pEnd = pBuf; + } + } - /* - ** Free an allocated buffer obtained from pcache1Alloc(). + /* + ** Malloc function used within this file to allocate space from the buffer + ** configured using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no + ** such buffer exists or there is no space left in it, this function falls + ** back to sqlite3Malloc(). + ** + ** Multiple threads can run this routine at the same time. Global variables + ** in pcache1 need to be protected via mutex. + */ + static PgHdr pcache1Alloc( int nByte ) + { + PgHdr p = null; + Debug.Assert( sqlite3_mutex_notheld( pcache1.grp.mutex ) ); + sqlite3StatusSet( SQLITE_STATUS_PAGECACHE_SIZE, nByte ); + if ( nByte <= pcache1.szSlot ) + { + sqlite3_mutex_enter( pcache1.mutex ); + p = pcache1.pFree._PgHdr; + if ( p != null ) + { + pcache1.pFree = pcache1.pFree.pNext; + pcache1.nFreeSlot--; + pcache1.bUnderPressure = pcache1.nFreeSlot < pcache1.nReserve; + Debug.Assert( pcache1.nFreeSlot >= 0 ); + sqlite3StatusAdd( SQLITE_STATUS_PAGECACHE_USED, 1 ); + } + sqlite3_mutex_leave( pcache1.mutex ); + } + if ( p == null ) + { + /* Memory is not available in the SQLITE_CONFIG_PAGECACHE pool. Get + ** it from sqlite3Malloc instead. */ - static void pcache1Free(ref PgHdr p) { - if (p == null) - return; - if (p.CacheAllocated)//if ( p >= pcache1.pStart && p < pcache1.pEnd ) - { - PgFreeslot pSlot = new PgFreeslot(); - sqlite3_mutex_enter(pcache1.mutex); - sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, -1); - pSlot._PgHdr = p;// pSlot = (PgFreeslot)p; - pSlot.pNext = pcache1.pFree; - pcache1.pFree = pSlot; - pcache1.nFreeSlot++; - pcache1.bUnderPressure = pcache1.nFreeSlot < pcache1.nReserve; - Debug.Assert(pcache1.nFreeSlot <= pcache1.nSlot); - sqlite3_mutex_leave(pcache1.mutex); - } else { - int iSize; - Debug.Assert(sqlite3MemdebugHasType(p, MEMTYPE_PCACHE)); - sqlite3MemdebugSetType(p, MEMTYPE_HEAP); - iSize = sqlite3MallocSize(p.pData); - sqlite3_mutex_enter(pcache1.mutex); - sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, -iSize); - sqlite3_mutex_leave(pcache1.mutex); - sqlite3_free(ref p.pData); - } + p = new PgHdr();// sqlite3Malloc( nByte ); + //if ( p != null ) + { + int sz = nByte;//sqlite3MallocSize( p ); + sqlite3_mutex_enter( pcache1.mutex ); + sqlite3StatusAdd( SQLITE_STATUS_PAGECACHE_OVERFLOW, sz ); + sqlite3_mutex_leave( pcache1.mutex ); } + sqlite3MemdebugSetType( p, MEMTYPE_PCACHE ); + } + return p; + } + + /* + ** Free an allocated buffer obtained from pcache1Alloc(). + */ + static void pcache1Free( ref PgHdr p ) + { + if ( p == null ) + return; + if ( p.CacheAllocated )//if ( p >= pcache1.pStart && p < pcache1.pEnd ) + { + PgFreeslot pSlot = new PgFreeslot(); + sqlite3_mutex_enter( pcache1.mutex ); + sqlite3StatusAdd( SQLITE_STATUS_PAGECACHE_USED, -1 ); + pSlot._PgHdr = p;// pSlot = (PgFreeslot)p; + pSlot.pNext = pcache1.pFree; + pcache1.pFree = pSlot; + pcache1.nFreeSlot++; + pcache1.bUnderPressure = pcache1.nFreeSlot < pcache1.nReserve; + Debug.Assert( pcache1.nFreeSlot <= pcache1.nSlot ); + sqlite3_mutex_leave( pcache1.mutex ); + } + else + { + int iSize; + Debug.Assert( sqlite3MemdebugHasType( p, MEMTYPE_PCACHE ) ); + sqlite3MemdebugSetType( p, MEMTYPE_HEAP ); + iSize = sqlite3MallocSize( p.pData ); + sqlite3_mutex_enter( pcache1.mutex ); + sqlite3StatusAdd( SQLITE_STATUS_PAGECACHE_OVERFLOW, -iSize ); + sqlite3_mutex_leave( pcache1.mutex ); + sqlite3_free( ref p.pData ); + } + } #if SQLITE_ENABLE_MEMORY_MANAGEMENT /* @@ -346,678 +372,748 @@ static int pcache1MemSize(object p){ } #endif //* SQLITE_ENABLE_MEMORY_MANAGEMENT */ - /* - ** Allocate a new page object initially associated with cache pCache. - */ - static PgHdr1 pcache1AllocPage(PCache1 pCache) { - //int nByte = sizeof( PgHdr1 ) + pCache.szPage; - PgHdr pPg = pcache1Alloc(pCache.szPage);//nByte ); - PgHdr1 p = null; - //if ( pPg !=null) - { - //PAGE_TO_PGHDR1( pCache, pPg ); - p = new PgHdr1(); - p.pCache = pCache; - p.pPgHdr = pPg; - if (pCache.bPurgeable) { - pCache.pGroup.nCurrentPage++; - } - } - //else - //{ - // p = 0; - //} - return p; + /* +** Allocate a new page object initially associated with cache pCache. +*/ + static PgHdr1 pcache1AllocPage( PCache1 pCache ) + { + //int nByte = sizeof( PgHdr1 ) + pCache.szPage; + PgHdr pPg = pcache1Alloc( pCache.szPage );//nByte ); + PgHdr1 p = null; + //if ( pPg !=null) + { + //PAGE_TO_PGHDR1( pCache, pPg ); + p = new PgHdr1(); + p.pCache = pCache; + p.pPgHdr = pPg; + if ( pCache.bPurgeable ) + { + pCache.pGroup.nCurrentPage++; } + } + //else + //{ + // p = 0; + //} + return p; + } - /* - ** Free a page object allocated by pcache1AllocPage(). - ** - ** The pointer is allowed to be NULL, which is prudent. But it turns out - ** that the current implementation happens to never call this routine - ** with a NULL pointer, so we mark the NULL test with ALWAYS(). - */ - static void pcache1FreePage(ref PgHdr1 p) { - if (ALWAYS(p)) { - PCache1 pCache = p.pCache; - if (pCache.bPurgeable) { - pCache.pGroup.nCurrentPage--; - } - pcache1Free(ref p.pPgHdr);//PGHDR1_TO_PAGE( p ); - } + /* + ** Free a page object allocated by pcache1AllocPage(). + ** + ** The pointer is allowed to be NULL, which is prudent. But it turns out + ** that the current implementation happens to never call this routine + ** with a NULL pointer, so we mark the NULL test with ALWAYS(). + */ + static void pcache1FreePage( ref PgHdr1 p ) + { + if ( ALWAYS( p ) ) + { + PCache1 pCache = p.pCache; + if ( pCache.bPurgeable ) + { + pCache.pGroup.nCurrentPage--; } + pcache1Free( ref p.pPgHdr );//PGHDR1_TO_PAGE( p ); + } + } - /* - ** Malloc function used by SQLite to obtain space from the buffer configured - ** using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no such buffer - ** exists, this function falls back to sqlite3Malloc(). - */ - static PgHdr sqlite3PageMalloc(int sz) { - return pcache1Alloc(sz); - } + /* + ** Malloc function used by SQLite to obtain space from the buffer configured + ** using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no such buffer + ** exists, this function falls back to sqlite3Malloc(). + */ + static PgHdr sqlite3PageMalloc( int sz ) + { + return pcache1Alloc( sz ); + } - /* - ** Free an allocated buffer obtained from sqlite3PageMalloc(). - */ - static void sqlite3PageFree(ref byte[] p) { - if (p != null) { - sqlite3_free(ref p); - p = null; - } - } - static void sqlite3PageFree(ref PgHdr p) { - pcache1Free(ref p); - } + /* + ** Free an allocated buffer obtained from sqlite3PageMalloc(). + */ + static void sqlite3PageFree( ref byte[] p ) + { + if ( p != null ) + { + sqlite3_free( ref p ); + p = null; + } + } + static void sqlite3PageFree( ref PgHdr p ) + { + pcache1Free( ref p ); + } - /* - ** Return true if it desirable to avoid allocating a new page cache - ** entry. - ** - ** If memory was allocated specifically to the page cache using - ** SQLITE_CONFIG_PAGECACHE but that memory has all been used, then - ** it is desirable to avoid allocating a new page cache entry because - ** presumably SQLITE_CONFIG_PAGECACHE was suppose to be sufficient - ** for all page cache needs and we should not need to spill the - ** allocation onto the heap. - ** - ** Or, the heap is used for all page cache memory put the heap is - ** under memory pressure, then again it is desirable to avoid - ** allocating a new page cache entry in order to avoid stressing - ** the heap even further. - */ - static bool pcache1UnderMemoryPressure(PCache1 pCache) { - if (pcache1.nSlot != 0 && pCache.szPage <= pcache1.szSlot) { - return pcache1.bUnderPressure; - } else { - return sqlite3HeapNearlyFull(); - } - } + /* + ** Return true if it desirable to avoid allocating a new page cache + ** entry. + ** + ** If memory was allocated specifically to the page cache using + ** SQLITE_CONFIG_PAGECACHE but that memory has all been used, then + ** it is desirable to avoid allocating a new page cache entry because + ** presumably SQLITE_CONFIG_PAGECACHE was suppose to be sufficient + ** for all page cache needs and we should not need to spill the + ** allocation onto the heap. + ** + ** Or, the heap is used for all page cache memory put the heap is + ** under memory pressure, then again it is desirable to avoid + ** allocating a new page cache entry in order to avoid stressing + ** the heap even further. + */ + static bool pcache1UnderMemoryPressure( PCache1 pCache ) + { + if ( pcache1.nSlot != 0 && pCache.szPage <= pcache1.szSlot ) + { + return pcache1.bUnderPressure; + } + else + { + return sqlite3HeapNearlyFull(); + } + } - /******************************************************************************/ - /******** General Implementation Functions ************************************/ + /******************************************************************************/ + /******** General Implementation Functions ************************************/ - /* - ** This function is used to resize the hash table used by the cache passed - ** as the first argument. - ** - ** The PCache mutex must be held when this function is called. - */ - static int pcache1ResizeHash(PCache1 p) { - PgHdr1[] apNew; - int nNew; - int i; - - Debug.Assert(sqlite3_mutex_held(p.pGroup.mutex)); - - nNew = p.nHash * 2; - if (nNew < 256) { - nNew = 256; - } - - pcache1LeaveMutex(p.pGroup); - if (p.nHash != 0) { - sqlite3BeginBenignMalloc(); - } - apNew = new PgHdr1[nNew];//(PgHdr1 *)sqlite3_malloc(sizeof(PgHdr1 )*nNew); - if (p.nHash != 0) { - sqlite3EndBenignMalloc(); - } - pcache1EnterMutex(p.pGroup); - if (apNew != null) { - //memset(apNew, 0, sizeof(PgHdr1 )*nNew); - for (i = 0; i < p.nHash; i++) { - PgHdr1 pPage; - PgHdr1 pNext = p.apHash[i]; - while ((pPage = pNext) != null) { - Pgno h = (Pgno)(pPage.iKey % nNew); - pNext = pPage.pNext; - pPage.pNext = apNew[h]; - apNew[h] = pPage; - } - } - //sqlite3_free( p.apHash ); - p.apHash = apNew; - p.nHash = nNew; - } - - return (p.apHash != null ? SQLITE_OK : SQLITE_NOMEM); - } + /* + ** This function is used to resize the hash table used by the cache passed + ** as the first argument. + ** + ** The PCache mutex must be held when this function is called. + */ + static int pcache1ResizeHash( PCache1 p ) + { + PgHdr1[] apNew; + int nNew; + int i; - /* - ** This function is used internally to remove the page pPage from the - ** PGroup LRU list, if is part of it. If pPage is not part of the PGroup - ** LRU list, then this function is a no-op. - ** - ** The PGroup mutex must be held when this function is called. - ** - ** If pPage is NULL then this routine is a no-op. - */ - static void pcache1PinPage(PgHdr1 pPage) { - PCache1 pCache; - PGroup pGroup; - - if (pPage == null) - return; - pCache = pPage.pCache; - pGroup = pCache.pGroup; - Debug.Assert(sqlite3_mutex_held(pGroup.mutex)); - if (pPage.pLruNext != null || pPage == pGroup.pLruTail) { - if (pPage.pLruPrev != null) { - pPage.pLruPrev.pLruNext = pPage.pLruNext; - } - if (pPage.pLruNext != null) { - pPage.pLruNext.pLruPrev = pPage.pLruPrev; - } - if (pGroup.pLruHead == pPage) { - pGroup.pLruHead = pPage.pLruNext; - } - if (pGroup.pLruTail == pPage) { - pGroup.pLruTail = pPage.pLruPrev; - } - pPage.pLruNext = null; - pPage.pLruPrev = null; - pPage.pCache.nRecyclable--; - } - } + Debug.Assert( sqlite3_mutex_held( p.pGroup.mutex ) ); + nNew = p.nHash * 2; + if ( nNew < 256 ) + { + nNew = 256; + } - /* - ** Remove the page supplied as an argument from the hash table - ** (PCache1.apHash structure) that it is currently stored in. - ** - ** The PGroup mutex must be held when this function is called. - */ - static void pcache1RemoveFromHash(PgHdr1 pPage) { - int h; - PCache1 pCache = pPage.pCache; - PgHdr1 pp; - PgHdr1 pPrev = null; - - Debug.Assert(sqlite3_mutex_held(pCache.pGroup.mutex)); - h = (int)(pPage.iKey % pCache.nHash); - for (pp = pCache.apHash[h]; pp != pPage; pPrev = pp, pp = pp.pNext) - ; - if (pPrev == null) - pCache.apHash[h] = pp.pNext; - else - pPrev.pNext = pp.pNext; // pCache.apHash[h] = pp.pNext; - pCache.nPage--; + pcache1LeaveMutex( p.pGroup ); + if ( p.nHash != 0 ) + { + sqlite3BeginBenignMalloc(); + } + apNew = new PgHdr1[nNew];//(PgHdr1 *)sqlite3_malloc(sizeof(PgHdr1 )*nNew); + if ( p.nHash != 0 ) + { + sqlite3EndBenignMalloc(); + } + pcache1EnterMutex( p.pGroup ); + if ( apNew != null ) + { + //memset(apNew, 0, sizeof(PgHdr1 )*nNew); + for ( i = 0; i < p.nHash; i++ ) + { + PgHdr1 pPage; + PgHdr1 pNext = p.apHash[i]; + while ( ( pPage = pNext ) != null ) + { + Pgno h = (Pgno)( pPage.iKey % nNew ); + pNext = pPage.pNext; + pPage.pNext = apNew[h]; + apNew[h] = pPage; + } } + //sqlite3_free( p.apHash ); + p.apHash = apNew; + p.nHash = nNew; + } - /* - ** If there are currently more than nMaxPage pages allocated, try - ** to recycle pages to reduce the number allocated to nMaxPage. - */ - static void pcache1EnforceMaxPage(PGroup pGroup) { - Debug.Assert(sqlite3_mutex_held(pGroup.mutex)); - while (pGroup.nCurrentPage > pGroup.nMaxPage && pGroup.pLruTail != null) { - PgHdr1 p = pGroup.pLruTail; - Debug.Assert(p.pCache.pGroup == pGroup); - pcache1PinPage(p); - pcache1RemoveFromHash(p); - pcache1FreePage(ref p); - } + return ( p.apHash != null ? SQLITE_OK : SQLITE_NOMEM ); + } + + /* + ** This function is used internally to remove the page pPage from the + ** PGroup LRU list, if is part of it. If pPage is not part of the PGroup + ** LRU list, then this function is a no-op. + ** + ** The PGroup mutex must be held when this function is called. + ** + ** If pPage is NULL then this routine is a no-op. + */ + static void pcache1PinPage( PgHdr1 pPage ) + { + PCache1 pCache; + PGroup pGroup; + + if ( pPage == null ) + return; + pCache = pPage.pCache; + pGroup = pCache.pGroup; + Debug.Assert( sqlite3_mutex_held( pGroup.mutex ) ); + if ( pPage.pLruNext != null || pPage == pGroup.pLruTail ) + { + if ( pPage.pLruPrev != null ) + { + pPage.pLruPrev.pLruNext = pPage.pLruNext; + } + if ( pPage.pLruNext != null ) + { + pPage.pLruNext.pLruPrev = pPage.pLruPrev; + } + if ( pGroup.pLruHead == pPage ) + { + pGroup.pLruHead = pPage.pLruNext; } + if ( pGroup.pLruTail == pPage ) + { + pGroup.pLruTail = pPage.pLruPrev; + } + pPage.pLruNext = null; + pPage.pLruPrev = null; + pPage.pCache.nRecyclable--; + } + } - /* - ** Discard all pages from cache pCache with a page number (key value) - ** greater than or equal to iLimit. Any pinned pages that meet this - ** criteria are unpinned before they are discarded. - ** - ** The PCache mutex must be held when this function is called. - */ - static void pcache1TruncateUnsafe( - PCache1 pCache, /* The cache to truncate */ - uint iLimit /* Drop pages with this pgno or larger */ - ) { + + /* + ** Remove the page supplied as an argument from the hash table + ** (PCache1.apHash structure) that it is currently stored in. + ** + ** The PGroup mutex must be held when this function is called. + */ + static void pcache1RemoveFromHash( PgHdr1 pPage ) + { + int h; + PCache1 pCache = pPage.pCache; + PgHdr1 pp; + PgHdr1 pPrev = null; + + Debug.Assert( sqlite3_mutex_held( pCache.pGroup.mutex ) ); + h = (int)( pPage.iKey % pCache.nHash ); + for ( pp = pCache.apHash[h]; pp != pPage; pPrev = pp, pp = pp.pNext ) + ; + if ( pPrev == null ) + pCache.apHash[h] = pp.pNext; + else + pPrev.pNext = pp.pNext; // pCache.apHash[h] = pp.pNext; + pCache.nPage--; + } + + /* + ** If there are currently more than nMaxPage pages allocated, try + ** to recycle pages to reduce the number allocated to nMaxPage. + */ + static void pcache1EnforceMaxPage( PGroup pGroup ) + { + Debug.Assert( sqlite3_mutex_held( pGroup.mutex ) ); + while ( pGroup.nCurrentPage > pGroup.nMaxPage && pGroup.pLruTail != null ) + { + PgHdr1 p = pGroup.pLruTail; + Debug.Assert( p.pCache.pGroup == pGroup ); + pcache1PinPage( p ); + pcache1RemoveFromHash( p ); + pcache1FreePage( ref p ); + } + } + + /* + ** Discard all pages from cache pCache with a page number (key value) + ** greater than or equal to iLimit. Any pinned pages that meet this + ** criteria are unpinned before they are discarded. + ** + ** The PCache mutex must be held when this function is called. + */ + static void pcache1TruncateUnsafe( + PCache1 pCache, /* The cache to truncate */ + uint iLimit /* Drop pages with this pgno or larger */ + ) + { #if !NDEBUG || SQLITE_COVERAGE_TEST //TESTONLY( uint nPage = 0; ) /* To assert pCache.nPage is correct */ - uint nPage = 0; + uint nPage = 0; #endif - uint h; - Debug.Assert(sqlite3_mutex_held(pCache.pGroup.mutex)); - for (h = 0; h < pCache.nHash; h++) { - PgHdr1 pPrev = null; - PgHdr1 pp = pCache.apHash[h]; - PgHdr1 pPage; - while ((pPage = pp) != null) { - if (pPage.iKey >= iLimit) { - pCache.nPage--; - pp = pPage.pNext; - pcache1PinPage(pPage); - if (pCache.apHash[h] == pPage) - pCache.apHash[h] = pPage.pNext; - else - pPrev.pNext = pp; - pcache1FreePage(ref pPage); - } else { - pp = pPage.pNext; + uint h; + Debug.Assert( sqlite3_mutex_held( pCache.pGroup.mutex ) ); + for ( h = 0; h < pCache.nHash; h++ ) + { + PgHdr1 pPrev = null; + PgHdr1 pp = pCache.apHash[h]; + PgHdr1 pPage; + while ( ( pPage = pp ) != null ) + { + if ( pPage.iKey >= iLimit ) + { + pCache.nPage--; + pp = pPage.pNext; + pcache1PinPage( pPage ); + if ( pCache.apHash[h] == pPage ) + pCache.apHash[h] = pPage.pNext; + else + pPrev.pNext = pp; + pcache1FreePage( ref pPage ); + } + else + { + pp = pPage.pNext; #if !NDEBUG || SQLITE_COVERAGE_TEST //TESTONLY( nPage++; ) - nPage++; + nPage++; #endif - } - pPrev = pPage; - } - } + } + pPrev = pPage; + } + } #if !NDEBUG || SQLITE_COVERAGE_TEST - Debug.Assert(pCache.nPage == nPage); + Debug.Assert( pCache.nPage == nPage ); #endif - } + } - /******************************************************************************/ - /******** sqlite3_pcache Methods **********************************************/ + /******************************************************************************/ + /******** sqlite3_pcache Methods **********************************************/ - /* - ** Implementation of the sqlite3_pcache.xInit method. - */ - static int pcache1Init(T NotUsed) { - UNUSED_PARAMETER(NotUsed); - Debug.Assert(pcache1.isInit == false); - pcache1 = new PCacheGlobal();//memset(&pcache1, 0, sizeof(pcache1)); - if (sqlite3GlobalConfig.bCoreMutex) { - pcache1.grp.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU); - pcache1.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_PMEM); - } - pcache1.grp.mxPinned = 10; - pcache1.isInit = true; - return SQLITE_OK; - } + /* + ** Implementation of the sqlite3_pcache.xInit method. + */ + static int pcache1Init( T NotUsed ) + { + UNUSED_PARAMETER( NotUsed ); + Debug.Assert( pcache1.isInit == false ); + pcache1 = new PCacheGlobal();//memset(&pcache1, 0, sizeof(pcache1)); + if ( sqlite3GlobalConfig.bCoreMutex ) + { + pcache1.grp.mutex = sqlite3_mutex_alloc( SQLITE_MUTEX_STATIC_LRU ); + pcache1.mutex = sqlite3_mutex_alloc( SQLITE_MUTEX_STATIC_PMEM ); + } + pcache1.grp.mxPinned = 10; + pcache1.isInit = true; + return SQLITE_OK; + } - /* - ** Implementation of the sqlite3_pcache.xShutdown method. - ** Note that the static mutex allocated in xInit does - ** not need to be freed. - */ - static void pcache1Shutdown(T NotUsed) { - UNUSED_PARAMETER(NotUsed); - Debug.Assert(pcache1.isInit); - pcache1 = new PCacheGlobal();//;memset( &pcache1, 0, sizeof( pcache1 ) ); - } + /* + ** Implementation of the sqlite3_pcache.xShutdown method. + ** Note that the static mutex allocated in xInit does + ** not need to be freed. + */ + static void pcache1Shutdown( T NotUsed ) + { + UNUSED_PARAMETER( NotUsed ); + Debug.Assert( pcache1.isInit ); + pcache1 = new PCacheGlobal();//;memset( &pcache1, 0, sizeof( pcache1 ) ); + } - /* - ** Implementation of the sqlite3_pcache.xCreate method. - ** - ** Allocate a new cache. - */ - static sqlite3_pcache pcache1Create(int szPage, bool bPurgeable) { - PCache1 pCache; /* The newly created page cache */ - PGroup pGroup; /* The group the new page cache will belong to */ - int sz; /* Bytes of memory required to allocate the new cache */ - - /* - ** The seperateCache variable is true if each PCache has its own private - ** PGroup. In other words, separateCache is true for mode (1) where no - ** mutexing is required. - ** - ** * Always use a unified cache (mode-2) if ENABLE_MEMORY_MANAGEMENT - ** - ** * Always use a unified cache in single-threaded applications - ** - ** * Otherwise (if multi-threaded and ENABLE_MEMORY_MANAGEMENT is off) - ** use separate caches (mode-1) - */ + /* + ** Implementation of the sqlite3_pcache.xCreate method. + ** + ** Allocate a new cache. + */ + static sqlite3_pcache pcache1Create( int szPage, bool bPurgeable ) + { + PCache1 pCache; /* The newly created page cache */ + PGroup pGroup; /* The group the new page cache will belong to */ + int sz; /* Bytes of memory required to allocate the new cache */ + + /* + ** The seperateCache variable is true if each PCache has its own private + ** PGroup. In other words, separateCache is true for mode (1) where no + ** mutexing is required. + ** + ** * Always use a unified cache (mode-2) if ENABLE_MEMORY_MANAGEMENT + ** + ** * Always use a unified cache in single-threaded applications + ** + ** * Otherwise (if multi-threaded and ENABLE_MEMORY_MANAGEMENT is off) + ** use separate caches (mode-1) + */ #if (SQLITE_ENABLE_MEMORY_MANAGEMENT) || !SQLITE_THREADSAF - const int separateCache = 0; + const int separateCache = 0; #else int separateCache = sqlite3GlobalConfig.bCoreMutex>0; #endif - //sz = sizeof( PCache1 ) + sizeof( PGroup ) * separateCache; - pCache = new PCache1();//(PCache1)sqlite3_malloc( sz ); - //if ( pCache != null ) - //{ - //memset( pCache, 0, sz ); - if (separateCache == 0) { - pGroup = pcache1.grp; - } - ////else - ////{ - ////pGroup = new PGroup();//(PGroup)pCache[1]; - ////pGroup.mxPinned = 10; - ////} - - pCache.pGroup = pGroup; - pCache.szPage = szPage; - pCache.bPurgeable = bPurgeable;//( bPurgeable ? 1 : 0 ); - if (bPurgeable) { - pCache.nMin = 10; - pcache1EnterMutex(pGroup); - pGroup.nMinPage += (int)pCache.nMin; - pGroup.mxPinned = pGroup.nMaxPage + 10 - pGroup.nMinPage; - pcache1LeaveMutex(pGroup); - } - //} - return (sqlite3_pcache)pCache; + //sz = sizeof( PCache1 ) + sizeof( PGroup ) * separateCache; + pCache = new PCache1();//(PCache1)sqlite3_malloc( sz ); + //if ( pCache != null ) + //{ + //memset( pCache, 0, sz ); + if ( separateCache == 0 ) + { + pGroup = pcache1.grp; } - - /* - ** Implementation of the sqlite3_pcache.xCachesize method. - ** - ** Configure the cache_size limit for a cache. - */ - static void pcache1Cachesize(sqlite3_pcache p, int nMax) { - PCache1 pCache = (PCache1)p; - if (pCache.bPurgeable) { - PGroup pGroup = pCache.pGroup; - pcache1EnterMutex(pGroup); - pGroup.nMaxPage += nMax - pCache.nMax; - pGroup.mxPinned = pGroup.nMaxPage + 10 - pGroup.nMinPage; - pCache.nMax = nMax; - pCache.n90pct = pCache.nMax * 9 / 10; - pcache1EnforceMaxPage(pGroup); - pcache1LeaveMutex(pGroup); - } + ////else + ////{ + ////pGroup = new PGroup();//(PGroup)pCache[1]; + ////pGroup.mxPinned = 10; + ////} + + pCache.pGroup = pGroup; + pCache.szPage = szPage; + pCache.bPurgeable = bPurgeable;//( bPurgeable ? 1 : 0 ); + if ( bPurgeable ) + { + pCache.nMin = 10; + pcache1EnterMutex( pGroup ); + pGroup.nMinPage += (int)pCache.nMin; + pGroup.mxPinned = pGroup.nMaxPage + 10 - pGroup.nMinPage; + pcache1LeaveMutex( pGroup ); } + //} + return (sqlite3_pcache)pCache; + } - /* - ** Implementation of the sqlite3_pcache.xPagecount method. - */ - static int pcache1Pagecount(sqlite3_pcache p) { - int n; - PCache1 pCache = (PCache1)p; - pcache1EnterMutex(pCache.pGroup); - n = (int)pCache.nPage; - pcache1LeaveMutex(pCache.pGroup); - return n; - } + /* + ** Implementation of the sqlite3_pcache.xCachesize method. + ** + ** Configure the cache_size limit for a cache. + */ + static void pcache1Cachesize( sqlite3_pcache p, int nMax ) + { + PCache1 pCache = (PCache1)p; + if ( pCache.bPurgeable ) + { + PGroup pGroup = pCache.pGroup; + pcache1EnterMutex( pGroup ); + pGroup.nMaxPage += nMax - pCache.nMax; + pGroup.mxPinned = pGroup.nMaxPage + 10 - pGroup.nMinPage; + pCache.nMax = nMax; + pCache.n90pct = pCache.nMax * 9 / 10; + pcache1EnforceMaxPage( pGroup ); + pcache1LeaveMutex( pGroup ); + } + } - /* - ** Implementation of the sqlite3_pcache.xFetch method. - ** - ** Fetch a page by key value. - ** - ** Whether or not a new page may be allocated by this function depends on - ** the value of the createFlag argument. 0 means do not allocate a new - ** page. 1 means allocate a new page if space is easily available. 2 - ** means to try really hard to allocate a new page. - ** - ** For a non-purgeable cache (a cache used as the storage for an in-memory - ** database) there is really no difference between createFlag 1 and 2. So - ** the calling function (pcache.c) will never have a createFlag of 1 on - ** a non-purgable cache. - ** - ** There are three different approaches to obtaining space for a page, - ** depending on the value of parameter createFlag (which may be 0, 1 or 2). - ** - ** 1. Regardless of the value of createFlag, the cache is searched for a - ** copy of the requested page. If one is found, it is returned. - ** - ** 2. If createFlag==0 and the page is not already in the cache, NULL is - ** returned. - ** - ** 3. If createFlag is 1, and the page is not already in the cache, then - ** return NULL (do not allocate a new page) if any of the following - ** conditions are true: - ** - ** (a) the number of pages pinned by the cache is greater than - ** PCache1.nMax, or - ** - ** (b) the number of pages pinned by the cache is greater than - ** the sum of nMax for all purgeable caches, less the sum of - ** nMin for all other purgeable caches, or - ** - ** 4. If none of the first three conditions apply and the cache is marked - ** as purgeable, and if one of the following is true: - ** - ** (a) The number of pages allocated for the cache is already - ** PCache1.nMax, or - ** - ** (b) The number of pages allocated for all purgeable caches is - ** already equal to or greater than the sum of nMax for all - ** purgeable caches, - ** - ** (c) The system is under memory pressure and wants to avoid - ** unnecessary pages cache entry allocations - ** - ** then attempt to recycle a page from the LRU list. If it is the right - ** size, return the recycled buffer. Otherwise, free the buffer and - ** proceed to step 5. - ** - ** 5. Otherwise, allocate and return a new page buffer. - */ - static PgHdr pcache1Fetch(sqlite3_pcache p, Pgno iKey, int createFlag) { - int nPinned; - PCache1 pCache = (PCache1)p; - PGroup pGroup; - PgHdr1 pPage = null; - - Debug.Assert(pCache.bPurgeable || createFlag != 1); - Debug.Assert(pCache.bPurgeable || pCache.nMin == 0); - Debug.Assert(pCache.bPurgeable == false || pCache.nMin == 10); - Debug.Assert(pCache.nMin == 0 || pCache.bPurgeable); - pcache1EnterMutex(pGroup = pCache.pGroup); - - /* Step 1: Search the hash table for an existing entry. */ - if (pCache.nHash > 0) { - int h = (int)(iKey % pCache.nHash); - for (pPage = pCache.apHash[h]; pPage != null && pPage.iKey != iKey; pPage = pPage.pNext) - ; - } - - /* Step 2: Abort if no existing page is found and createFlag is 0 */ - if (pPage != null || createFlag == 0) { - pcache1PinPage(pPage); - goto fetch_out; - } - - /* The pGroup local variable will normally be initialized by the - ** pcache1EnterMutex() macro above. But if SQLITE_MUTEX_OMIT is defined, - ** then pcache1EnterMutex() is a no-op, so we have to initialize the - ** local variable here. Delaying the initialization of pGroup is an - ** optimization: The common case is to exit the module before reaching - ** this point. - */ -#if SQLITE_MUTEX_OMIT + /* + ** Implementation of the sqlite3_pcache.xPagecount method. + */ + static int pcache1Pagecount( sqlite3_pcache p ) + { + int n; + PCache1 pCache = (PCache1)p; + pcache1EnterMutex( pCache.pGroup ); + n = (int)pCache.nPage; + pcache1LeaveMutex( pCache.pGroup ); + return n; + } + + /* + ** Implementation of the sqlite3_pcache.xFetch method. + ** + ** Fetch a page by key value. + ** + ** Whether or not a new page may be allocated by this function depends on + ** the value of the createFlag argument. 0 means do not allocate a new + ** page. 1 means allocate a new page if space is easily available. 2 + ** means to try really hard to allocate a new page. + ** + ** For a non-purgeable cache (a cache used as the storage for an in-memory + ** database) there is really no difference between createFlag 1 and 2. So + ** the calling function (pcache.c) will never have a createFlag of 1 on + ** a non-purgable cache. + ** + ** There are three different approaches to obtaining space for a page, + ** depending on the value of parameter createFlag (which may be 0, 1 or 2). + ** + ** 1. Regardless of the value of createFlag, the cache is searched for a + ** copy of the requested page. If one is found, it is returned. + ** + ** 2. If createFlag==0 and the page is not already in the cache, NULL is + ** returned. + ** + ** 3. If createFlag is 1, and the page is not already in the cache, then + ** return NULL (do not allocate a new page) if any of the following + ** conditions are true: + ** + ** (a) the number of pages pinned by the cache is greater than + ** PCache1.nMax, or + ** + ** (b) the number of pages pinned by the cache is greater than + ** the sum of nMax for all purgeable caches, less the sum of + ** nMin for all other purgeable caches, or + ** + ** 4. If none of the first three conditions apply and the cache is marked + ** as purgeable, and if one of the following is true: + ** + ** (a) The number of pages allocated for the cache is already + ** PCache1.nMax, or + ** + ** (b) The number of pages allocated for all purgeable caches is + ** already equal to or greater than the sum of nMax for all + ** purgeable caches, + ** + ** (c) The system is under memory pressure and wants to avoid + ** unnecessary pages cache entry allocations + ** + ** then attempt to recycle a page from the LRU list. If it is the right + ** size, return the recycled buffer. Otherwise, free the buffer and + ** proceed to step 5. + ** + ** 5. Otherwise, allocate and return a new page buffer. + */ + static PgHdr pcache1Fetch( sqlite3_pcache p, Pgno iKey, int createFlag ) + { + int nPinned; + PCache1 pCache = (PCache1)p; + PGroup pGroup; + PgHdr1 pPage = null; + + Debug.Assert( pCache.bPurgeable || createFlag != 1 ); + Debug.Assert( pCache.bPurgeable || pCache.nMin == 0 ); + Debug.Assert( pCache.bPurgeable == false || pCache.nMin == 10 ); + Debug.Assert( pCache.nMin == 0 || pCache.bPurgeable ); + pcache1EnterMutex( pGroup = pCache.pGroup ); + + /* Step 1: Search the hash table for an existing entry. */ + if ( pCache.nHash > 0 ) + { + int h = (int)( iKey % pCache.nHash ); + for ( pPage = pCache.apHash[h]; pPage != null && pPage.iKey != iKey; pPage = pPage.pNext ) + ; + } + + /* Step 2: Abort if no existing page is found and createFlag is 0 */ + if ( pPage != null || createFlag == 0 ) + { + pcache1PinPage( pPage ); + goto fetch_out; + } + + /* The pGroup local variable will normally be initialized by the + ** pcache1EnterMutex() macro above. But if SQLITE_MUTEX_OMIT is defined, + ** then pcache1EnterMutex() is a no-op, so we have to initialize the + ** local variable here. Delaying the initialization of pGroup is an + ** optimization: The common case is to exit the module before reaching + ** this point. + */ +#if SQLITE_MUTEX_OMIT pGroup = pCache.pGroup; #endif - /* Step 3: Abort if createFlag is 1 but the cache is nearly full */ - nPinned = pCache.nPage - pCache.nRecyclable; - Debug.Assert(nPinned >= 0); - Debug.Assert(pGroup.mxPinned == pGroup.nMaxPage + 10 - pGroup.nMinPage); - Debug.Assert(pCache.n90pct == pCache.nMax * 9 / 10); - if (createFlag == 1 && ( - nPinned >= pGroup.mxPinned - || nPinned >= (int)pCache.n90pct - || pcache1UnderMemoryPressure(pCache) - )) { - goto fetch_out; - } - - if (pCache.nPage >= pCache.nHash && pcache1ResizeHash(pCache) != 0) { - goto fetch_out; - } - - /* Step 4. Try to recycle a page. */ - if (pCache.bPurgeable && pGroup.pLruTail != null && ( - (pCache.nPage + 1 >= pCache.nMax) - || pGroup.nCurrentPage >= pGroup.nMaxPage - || pcache1UnderMemoryPressure(pCache) - )) { - PCache1 pOtherCache; - pPage = pGroup.pLruTail; - pcache1RemoveFromHash(pPage); - pcache1PinPage(pPage); - if ((pOtherCache = pPage.pCache).szPage != pCache.szPage) { - pcache1FreePage(ref pPage); - pPage = null; - } else { - pGroup.nCurrentPage -= - (pOtherCache.bPurgeable ? 1 : 0) - (pCache.bPurgeable ? 1 : 0); - } - } - - /* Step 5. If a usable page buffer has still not been found, - ** attempt to allocate a new one. - */ - if (null == pPage) { - if (createFlag == 1) - sqlite3BeginBenignMalloc(); - pcache1LeaveMutex(pGroup); - pPage = pcache1AllocPage(pCache); - pcache1EnterMutex(pGroup); - if (createFlag == 1) - sqlite3EndBenignMalloc(); - } - - if (pPage != null) { - int h = (int)(iKey % pCache.nHash); - pCache.nPage++; - pPage.iKey = iKey; - pPage.pNext = pCache.apHash[h]; - pPage.pCache = pCache; - pPage.pLruPrev = null; - pPage.pLruNext = null; - PGHDR1_TO_PAGE(pPage).Clear();// *(void **)(PGHDR1_TO_PAGE(pPage)) = 0; - pPage.pPgHdr.pPgHdr1 = pPage; - pCache.apHash[h] = pPage; - } - - fetch_out: - if (pPage != null && iKey > pCache.iMaxKey) { - pCache.iMaxKey = iKey; - } - pcache1LeaveMutex(pGroup); - return (pPage != null ? PGHDR1_TO_PAGE(pPage) : null); - } + /* Step 3: Abort if createFlag is 1 but the cache is nearly full */ + nPinned = pCache.nPage - pCache.nRecyclable; + Debug.Assert( nPinned >= 0 ); + Debug.Assert( pGroup.mxPinned == pGroup.nMaxPage + 10 - pGroup.nMinPage ); + Debug.Assert( pCache.n90pct == pCache.nMax * 9 / 10 ); + if ( createFlag == 1 && ( + nPinned >= pGroup.mxPinned + || nPinned >= (int)pCache.n90pct + || pcache1UnderMemoryPressure( pCache ) + ) ) + { + goto fetch_out; + } + if ( pCache.nPage >= pCache.nHash && pcache1ResizeHash( pCache ) != 0 ) + { + goto fetch_out; + } - /* - ** Implementation of the sqlite3_pcache.xUnpin method. - ** - ** Mark a page as unpinned (eligible for asynchronous recycling). - */ - static void pcache1Unpin(sqlite3_pcache p, PgHdr pPg, bool reuseUnlikely) { - PCache1 pCache = (PCache1)p; - PgHdr1 pPage = PAGE_TO_PGHDR1(pCache, pPg); - PGroup pGroup = pCache.pGroup; - - Debug.Assert(pPage.pCache == pCache); - pcache1EnterMutex(pGroup); - - /* It is an error to call this function if the page is already - ** part of the PGroup LRU list. - */ - Debug.Assert(pPage.pLruPrev == null && pPage.pLruNext == null); - Debug.Assert(pGroup.pLruHead != pPage && pGroup.pLruTail != pPage); - - if (reuseUnlikely || pGroup.nCurrentPage > pGroup.nMaxPage) { - pcache1RemoveFromHash(pPage); - pcache1FreePage(ref pPage); - } else { - /* Add the page to the PGroup LRU list. */ - if (pGroup.pLruHead != null) { - pGroup.pLruHead.pLruPrev = pPage; - pPage.pLruNext = pGroup.pLruHead; - pGroup.pLruHead = pPage; - } else { - pGroup.pLruTail = pPage; - pGroup.pLruHead = pPage; - } - pCache.nRecyclable++; - } - - pcache1LeaveMutex(pCache.pGroup); + /* Step 4. Try to recycle a page. */ + if ( pCache.bPurgeable && pGroup.pLruTail != null && ( + ( pCache.nPage + 1 >= pCache.nMax ) + || pGroup.nCurrentPage >= pGroup.nMaxPage + || pcache1UnderMemoryPressure( pCache ) + ) ) + { + PCache1 pOtherCache; + pPage = pGroup.pLruTail; + pcache1RemoveFromHash( pPage ); + pcache1PinPage( pPage ); + if ( ( pOtherCache = pPage.pCache ).szPage != pCache.szPage ) + { + pcache1FreePage( ref pPage ); + pPage = null; + } + else + { + pGroup.nCurrentPage -= + ( pOtherCache.bPurgeable ? 1 : 0 ) - ( pCache.bPurgeable ? 1 : 0 ); } + } - /* - ** Implementation of the sqlite3_pcache.xRekey method. - */ - static void pcache1Rekey( - sqlite3_pcache p, - PgHdr pPg, - Pgno iOld, - Pgno iNew - ) { - PCache1 pCache = (PCache1)p; - PgHdr1 pPage = PAGE_TO_PGHDR1(pCache, pPg); - PgHdr1 pp; - int h; - Debug.Assert(pPage.iKey == iOld); - Debug.Assert(pPage.pCache == pCache); - - pcache1EnterMutex(pCache.pGroup); - - h = (int)(iOld % pCache.nHash); - pp = pCache.apHash[h]; - while ((pp) != pPage) { - pp = (pp).pNext; - } - if (pp == pCache.apHash[h]) - pCache.apHash[h] = pp.pNext; - else - pp.pNext = pPage.pNext; + /* Step 5. If a usable page buffer has still not been found, + ** attempt to allocate a new one. + */ + if ( null == pPage ) + { + if ( createFlag == 1 ) + sqlite3BeginBenignMalloc(); + pcache1LeaveMutex( pGroup ); + pPage = pcache1AllocPage( pCache ); + pcache1EnterMutex( pGroup ); + if ( createFlag == 1 ) + sqlite3EndBenignMalloc(); + } - h = (int)(iNew % pCache.nHash); - pPage.iKey = iNew; - pPage.pNext = pCache.apHash[h]; - pCache.apHash[h] = pPage; - if (iNew > pCache.iMaxKey) { - pCache.iMaxKey = iNew; - } + if ( pPage != null ) + { + int h = (int)( iKey % pCache.nHash ); + pCache.nPage++; + pPage.iKey = iKey; + pPage.pNext = pCache.apHash[h]; + pPage.pCache = pCache; + pPage.pLruPrev = null; + pPage.pLruNext = null; + PGHDR1_TO_PAGE( pPage ).Clear();// *(void **)(PGHDR1_TO_PAGE(pPage)) = 0; + pPage.pPgHdr.pPgHdr1 = pPage; + pCache.apHash[h] = pPage; + } - pcache1LeaveMutex(pCache.pGroup); - } +fetch_out: + if ( pPage != null && iKey > pCache.iMaxKey ) + { + pCache.iMaxKey = iKey; + } + pcache1LeaveMutex( pGroup ); + return ( pPage != null ? PGHDR1_TO_PAGE( pPage ) : null ); + } - /* - ** Implementation of the sqlite3_pcache.xTruncate method. - ** - ** Discard all unpinned pages in the cache with a page number equal to - ** or greater than parameter iLimit. Any pinned pages with a page number - ** equal to or greater than iLimit are implicitly unpinned. - */ - static void pcache1Truncate(sqlite3_pcache p, Pgno iLimit) { - PCache1 pCache = (PCache1)p; - pcache1EnterMutex(pCache.pGroup); - if (iLimit <= pCache.iMaxKey) { - pcache1TruncateUnsafe(pCache, iLimit); - pCache.iMaxKey = iLimit - 1; - } - pcache1LeaveMutex(pCache.pGroup); - } - /* - ** Implementation of the sqlite3_pcache.xDestroy method. - ** - ** Destroy a cache allocated using pcache1Create(). - */ - static void pcache1Destroy(ref sqlite3_pcache p) { - PCache1 pCache = (PCache1)p; - PGroup pGroup = pCache.pGroup; - Debug.Assert(pCache.bPurgeable || (pCache.nMax == 0 && pCache.nMin == 0)); - pcache1EnterMutex(pGroup); - pcache1TruncateUnsafe(pCache, 0); - pGroup.nMaxPage -= pCache.nMax; - pGroup.nMinPage -= pCache.nMin; - pGroup.mxPinned = pGroup.nMaxPage + 10 - pGroup.nMinPage; - pcache1EnforceMaxPage(pGroup); - pcache1LeaveMutex(pGroup); - //sqlite3_free( pCache.apHash ); - //sqlite3_free( pCache ); - p = null; - } + /* + ** Implementation of the sqlite3_pcache.xUnpin method. + ** + ** Mark a page as unpinned (eligible for asynchronous recycling). + */ + static void pcache1Unpin( sqlite3_pcache p, PgHdr pPg, bool reuseUnlikely ) + { + PCache1 pCache = (PCache1)p; + PgHdr1 pPage = PAGE_TO_PGHDR1( pCache, pPg ); + PGroup pGroup = pCache.pGroup; - /* - ** This function is called during initialization (sqlite3_initialize()) to - ** install the default pluggable cache module, assuming the user has not - ** already provided an alternative. - */ - static void sqlite3PCacheSetDefault() { - sqlite3_pcache_methods defaultMethods = new sqlite3_pcache_methods( - 0, /* pArg */ - (dxPC_Init)pcache1Init, /* xInit */ - (dxPC_Shutdown)pcache1Shutdown, /* xShutdown */ - (dxPC_Create)pcache1Create, /* xCreate */ - (dxPC_Cachesize)pcache1Cachesize, /* xCachesize */ - (dxPC_Pagecount)pcache1Pagecount, /* xPagecount */ - (dxPC_Fetch)pcache1Fetch, /* xFetch */ - (dxPC_Unpin)pcache1Unpin, /* xUnpin */ - (dxPC_Rekey)pcache1Rekey, /* xRekey */ - (dxPC_Truncate)pcache1Truncate, /* xTruncate */ - (dxPC_Destroy)pcache1Destroy /* xDestroy */ - ); - sqlite3_config(SQLITE_CONFIG_PCACHE, defaultMethods); + Debug.Assert( pPage.pCache == pCache ); + pcache1EnterMutex( pGroup ); + + /* It is an error to call this function if the page is already + ** part of the PGroup LRU list. + */ + Debug.Assert( pPage.pLruPrev == null && pPage.pLruNext == null ); + Debug.Assert( pGroup.pLruHead != pPage && pGroup.pLruTail != pPage ); + + if ( reuseUnlikely || pGroup.nCurrentPage > pGroup.nMaxPage ) + { + pcache1RemoveFromHash( pPage ); + pcache1FreePage( ref pPage ); + } + else + { + /* Add the page to the PGroup LRU list. */ + if ( pGroup.pLruHead != null ) + { + pGroup.pLruHead.pLruPrev = pPage; + pPage.pLruNext = pGroup.pLruHead; + pGroup.pLruHead = pPage; + } + else + { + pGroup.pLruTail = pPage; + pGroup.pLruHead = pPage; } + pCache.nRecyclable++; + } + + pcache1LeaveMutex( pCache.pGroup ); + } + + /* + ** Implementation of the sqlite3_pcache.xRekey method. + */ + static void pcache1Rekey( + sqlite3_pcache p, + PgHdr pPg, + Pgno iOld, + Pgno iNew + ) + { + PCache1 pCache = (PCache1)p; + PgHdr1 pPage = PAGE_TO_PGHDR1( pCache, pPg ); + PgHdr1 pp; + int h; + Debug.Assert( pPage.iKey == iOld ); + Debug.Assert( pPage.pCache == pCache ); + + pcache1EnterMutex( pCache.pGroup ); + + h = (int)( iOld % pCache.nHash ); + pp = pCache.apHash[h]; + while ( ( pp ) != pPage ) + { + pp = ( pp ).pNext; + } + if ( pp == pCache.apHash[h] ) + pCache.apHash[h] = pp.pNext; + else + pp.pNext = pPage.pNext; + + h = (int)( iNew % pCache.nHash ); + pPage.iKey = iNew; + pPage.pNext = pCache.apHash[h]; + pCache.apHash[h] = pPage; + if ( iNew > pCache.iMaxKey ) + { + pCache.iMaxKey = iNew; + } + + pcache1LeaveMutex( pCache.pGroup ); + } + + /* + ** Implementation of the sqlite3_pcache.xTruncate method. + ** + ** Discard all unpinned pages in the cache with a page number equal to + ** or greater than parameter iLimit. Any pinned pages with a page number + ** equal to or greater than iLimit are implicitly unpinned. + */ + static void pcache1Truncate( sqlite3_pcache p, Pgno iLimit ) + { + PCache1 pCache = (PCache1)p; + pcache1EnterMutex( pCache.pGroup ); + if ( iLimit <= pCache.iMaxKey ) + { + pcache1TruncateUnsafe( pCache, iLimit ); + pCache.iMaxKey = iLimit - 1; + } + pcache1LeaveMutex( pCache.pGroup ); + } + + /* + ** Implementation of the sqlite3_pcache.xDestroy method. + ** + ** Destroy a cache allocated using pcache1Create(). + */ + static void pcache1Destroy( ref sqlite3_pcache p ) + { + PCache1 pCache = (PCache1)p; + PGroup pGroup = pCache.pGroup; + Debug.Assert( pCache.bPurgeable || ( pCache.nMax == 0 && pCache.nMin == 0 ) ); + pcache1EnterMutex( pGroup ); + pcache1TruncateUnsafe( pCache, 0 ); + pGroup.nMaxPage -= pCache.nMax; + pGroup.nMinPage -= pCache.nMin; + pGroup.mxPinned = pGroup.nMaxPage + 10 - pGroup.nMinPage; + pcache1EnforceMaxPage( pGroup ); + pcache1LeaveMutex( pGroup ); + //sqlite3_free( pCache.apHash ); + //sqlite3_free( pCache ); + p = null; + } + + /* + ** This function is called during initialization (sqlite3_initialize()) to + ** install the default pluggable cache module, assuming the user has not + ** already provided an alternative. + */ + static void sqlite3PCacheSetDefault() + { + sqlite3_pcache_methods defaultMethods = new sqlite3_pcache_methods( + 0, /* pArg */ + (dxPC_Init)pcache1Init, /* xInit */ + (dxPC_Shutdown)pcache1Shutdown, /* xShutdown */ + (dxPC_Create)pcache1Create, /* xCreate */ + (dxPC_Cachesize)pcache1Cachesize, /* xCachesize */ + (dxPC_Pagecount)pcache1Pagecount, /* xPagecount */ + (dxPC_Fetch)pcache1Fetch, /* xFetch */ + (dxPC_Unpin)pcache1Unpin, /* xUnpin */ + (dxPC_Rekey)pcache1Rekey, /* xRekey */ + (dxPC_Truncate)pcache1Truncate, /* xTruncate */ + (dxPC_Destroy)pcache1Destroy /* xDestroy */ + ); + sqlite3_config( SQLITE_CONFIG_PCACHE, defaultMethods ); + } #if SQLITE_ENABLE_MEMORY_MANAGEMENT /* @@ -1072,5 +1168,5 @@ static void sqlite3PcacheStats( pnRecyclable = nRecyclable; } #endif - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/pcache_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/pcache_c.cs index b008e9088..34f171c3c 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/pcache_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/pcache_c.cs @@ -1,84 +1,93 @@ +using System; using System.Diagnostics; +using System.Text; -using Pgno = System.UInt32; using u32 = System.UInt32; +using Pgno = System.UInt32; -namespace Community.CsharpSqlite { - using sqlite3_pcache = Sqlite3.PCache1; - - public partial class Sqlite3 { - /* - ** 2008 August 05 - ** - ** 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 implements that page cache. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +namespace Community.CsharpSqlite +{ + using sqlite3_value = Sqlite3.Mem; + using sqlite3_pcache = Sqlite3.PCache1; - /* - ** A complete page cache is an instance of this structure. - */ - public class PCache { - public PgHdr pDirty, pDirtyTail; /* List of dirty pages in LRU order */ - public PgHdr pSynced; /* Last synced page in dirty page list */ - public int _nRef; /* Number of referenced pages */ - public int nMax; /* Configured cache size */ - public int szPage; /* Size of every page in this cache */ - public int szExtra; /* Size of extra space for each page */ - public bool bPurgeable; /* True if pages are on backing store */ - public dxStress xStress; //int (*xStress)(void*,PgHdr*); /* Call to try make a page clean */ - public object pStress; /* Argument to xStress */ - public sqlite3_pcache pCache; /* Pluggable cache module */ - public PgHdr pPage1; /* Reference to page 1 */ - - public int nRef /* Number of referenced pages */ - { - get { - return _nRef; - } - set { - _nRef = value; - } - } - - public void Clear() { - pDirty = null; - pDirtyTail = null; - pSynced = null; - nRef = 0; - } - }; - - /* - ** Some of the Debug.Assert() macros in this code are too expensive to run - ** even during normal debugging. Use them only rarely on long-running - ** tests. Enable the expensive asserts using the - ** -DSQLITE_ENABLE_EXPENSIVE_ASSERT=1 compile-time option. - */ + public partial class Sqlite3 + { + /* + ** 2008 August 05 + ** + ** 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 implements that page cache. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + + /* + ** A complete page cache is an instance of this structure. + */ + public class PCache + { + public PgHdr pDirty, pDirtyTail; /* List of dirty pages in LRU order */ + public PgHdr pSynced; /* Last synced page in dirty page list */ + public int _nRef; /* Number of referenced pages */ + public int nMax; /* Configured cache size */ + public int szPage; /* Size of every page in this cache */ + public int szExtra; /* Size of extra space for each page */ + public bool bPurgeable; /* True if pages are on backing store */ + public dxStress xStress; //int (*xStress)(void*,PgHdr*); /* Call to try make a page clean */ + public object pStress; /* Argument to xStress */ + public sqlite3_pcache pCache; /* Pluggable cache module */ + public PgHdr pPage1; /* Reference to page 1 */ + + public int nRef /* Number of referenced pages */ + { + get + { + return _nRef; + } + set + { + _nRef = value; + } + } + + public void Clear() + { + pDirty = null; + pDirtyTail = null; + pSynced = null; + nRef = 0; + } + }; + + /* + ** Some of the Debug.Assert() macros in this code are too expensive to run + ** even during normal debugging. Use them only rarely on long-running + ** tests. Enable the expensive asserts using the + ** -DSQLITE_ENABLE_EXPENSIVE_ASSERT=1 compile-time option. + */ #if SQLITE_ENABLE_EXPENSIVE_ASSERT //# define expensive_assert(X) Debug.Assert(X) static void expensive_assert( bool x ) { Debug.Assert( x ); } #else - //# define expensive_assert(X) + //# define expensive_assert(X) #endif - /********************************** Linked List Management ********************/ + /********************************** Linked List Management ********************/ -#if !NDEBUG && SQLITE_ENABLE_EXPENSIVE_ASSERT +#if !NDEBUG && SQLITE_ENABLE_EXPENSIVE_ASSERT /* ** Check that the pCache.pSynced variable is set correctly. If it ** is not, either fail an Debug.Assert or return zero. Otherwise, return @@ -95,209 +104,239 @@ static int pcacheCheckSynced(PCache pCache){ } #endif //* !NDEBUG && SQLITE_ENABLE_EXPENSIVE_ASSERT */ - /* - ** Remove page pPage from the list of dirty pages. - */ - static void pcacheRemoveFromDirtyList(PgHdr pPage) { - PCache p = pPage.pCache; - - Debug.Assert(pPage.pDirtyNext != null || pPage == p.pDirtyTail); - Debug.Assert(pPage.pDirtyPrev != null || pPage == p.pDirty); - - /* Update the PCache1.pSynced variable if necessary. */ - if (p.pSynced == pPage) { - PgHdr pSynced = pPage.pDirtyPrev; - while (pSynced != null && (pSynced.flags & PGHDR_NEED_SYNC) != 0) { - pSynced = pSynced.pDirtyPrev; - } - p.pSynced = pSynced; - } - - if (pPage.pDirtyNext != null) { - pPage.pDirtyNext.pDirtyPrev = pPage.pDirtyPrev; - } else { - Debug.Assert(pPage == p.pDirtyTail); - p.pDirtyTail = pPage.pDirtyPrev; - } - if (pPage.pDirtyPrev != null) { - pPage.pDirtyPrev.pDirtyNext = pPage.pDirtyNext; - } else { - Debug.Assert(pPage == p.pDirty); - p.pDirty = pPage.pDirtyNext; - } - pPage.pDirtyNext = null; - pPage.pDirtyPrev = null; + /* +** Remove page pPage from the list of dirty pages. +*/ + static void pcacheRemoveFromDirtyList( PgHdr pPage ) + { + PCache p = pPage.pCache; + + Debug.Assert( pPage.pDirtyNext != null || pPage == p.pDirtyTail ); + Debug.Assert( pPage.pDirtyPrev != null || pPage == p.pDirty ); + + /* Update the PCache1.pSynced variable if necessary. */ + if ( p.pSynced == pPage ) + { + PgHdr pSynced = pPage.pDirtyPrev; + while ( pSynced != null && ( pSynced.flags & PGHDR_NEED_SYNC ) != 0 ) + { + pSynced = pSynced.pDirtyPrev; + } + p.pSynced = pSynced; + } + + if ( pPage.pDirtyNext != null ) + { + pPage.pDirtyNext.pDirtyPrev = pPage.pDirtyPrev; + } + else + { + Debug.Assert( pPage == p.pDirtyTail ); + p.pDirtyTail = pPage.pDirtyPrev; + } + if ( pPage.pDirtyPrev != null ) + { + pPage.pDirtyPrev.pDirtyNext = pPage.pDirtyNext; + } + else + { + Debug.Assert( pPage == p.pDirty ); + p.pDirty = pPage.pDirtyNext; + } + pPage.pDirtyNext = null; + pPage.pDirtyPrev = null; #if SQLITE_ENABLE_EXPENSIVE_ASSERT expensive_assert( pcacheCheckSynced(p) ); #endif - } + } - /* - ** Add page pPage to the head of the dirty list (PCache1.pDirty is set to - ** pPage). - */ - static void pcacheAddToDirtyList(PgHdr pPage) { - PCache p = pPage.pCache; - - Debug.Assert(pPage.pDirtyNext == null && pPage.pDirtyPrev == null && p.pDirty != pPage); - - pPage.pDirtyNext = p.pDirty; - if (pPage.pDirtyNext != null) { - Debug.Assert(pPage.pDirtyNext.pDirtyPrev == null); - pPage.pDirtyNext.pDirtyPrev = pPage; - } - p.pDirty = pPage; - if (null == p.pDirtyTail) { - p.pDirtyTail = pPage; - } - if (null == p.pSynced && 0 == (pPage.flags & PGHDR_NEED_SYNC)) { - p.pSynced = pPage; - } + /* + ** Add page pPage to the head of the dirty list (PCache1.pDirty is set to + ** pPage). + */ + static void pcacheAddToDirtyList( PgHdr pPage ) + { + PCache p = pPage.pCache; + + Debug.Assert( pPage.pDirtyNext == null && pPage.pDirtyPrev == null && p.pDirty != pPage ); + + pPage.pDirtyNext = p.pDirty; + if ( pPage.pDirtyNext != null ) + { + Debug.Assert( pPage.pDirtyNext.pDirtyPrev == null ); + pPage.pDirtyNext.pDirtyPrev = pPage; + } + p.pDirty = pPage; + if ( null == p.pDirtyTail ) + { + p.pDirtyTail = pPage; + } + if ( null == p.pSynced && 0 == ( pPage.flags & PGHDR_NEED_SYNC ) ) + { + p.pSynced = pPage; + } #if SQLITE_ENABLE_EXPENSIVE_ASSERT expensive_assert( pcacheCheckSynced(p) ); #endif - } + } - /* - ** Wrapper around the pluggable caches xUnpin method. If the cache is - ** being used for an in-memory database, this function is a no-op. - */ - static void pcacheUnpin(PgHdr p) { - PCache pCache = p.pCache; - if (pCache.bPurgeable) { - if (p.pgno == 1) { - pCache.pPage1 = null; - } - sqlite3GlobalConfig.pcache.xUnpin(pCache.pCache, p, false); - } + /* + ** Wrapper around the pluggable caches xUnpin method. If the cache is + ** being used for an in-memory database, this function is a no-op. + */ + static void pcacheUnpin( PgHdr p ) + { + PCache pCache = p.pCache; + if ( pCache.bPurgeable ) + { + if ( p.pgno == 1 ) + { + pCache.pPage1 = null; } + sqlite3GlobalConfig.pcache.xUnpin( pCache.pCache, p, false ); + } + } - /*************************************************** General Interfaces ****** - ** - ** Initialize and shutdown the page cache subsystem. Neither of these - ** functions are threadsafe. - */ - static int sqlite3PcacheInitialize() { - if (sqlite3GlobalConfig.pcache.xInit == null) { - /* IMPLEMENTATION-OF: R-26801-64137 If the xInit() method is NULL, then the - ** built-in default page cache is used instead of the application defined - ** page cache. */ - sqlite3PCacheSetDefault(); - } - return sqlite3GlobalConfig.pcache.xInit(sqlite3GlobalConfig.pcache.pArg); - } - static void sqlite3PcacheShutdown() { - if (sqlite3GlobalConfig.pcache.xShutdown != null) { - /* IMPLEMENTATION-OF: R-26000-56589 The xShutdown() method may be NULL. */ - sqlite3GlobalConfig.pcache.xShutdown(sqlite3GlobalConfig.pcache.pArg); - } - } + /*************************************************** General Interfaces ****** + ** + ** Initialize and shutdown the page cache subsystem. Neither of these + ** functions are threadsafe. + */ + static int sqlite3PcacheInitialize() + { + if ( sqlite3GlobalConfig.pcache.xInit == null ) + { + /* IMPLEMENTATION-OF: R-26801-64137 If the xInit() method is NULL, then the + ** built-in default page cache is used instead of the application defined + ** page cache. */ + sqlite3PCacheSetDefault(); + } + return sqlite3GlobalConfig.pcache.xInit( sqlite3GlobalConfig.pcache.pArg ); + } + static void sqlite3PcacheShutdown() + { + if ( sqlite3GlobalConfig.pcache.xShutdown != null ) + { + /* IMPLEMENTATION-OF: R-26000-56589 The xShutdown() method may be NULL. */ + sqlite3GlobalConfig.pcache.xShutdown( sqlite3GlobalConfig.pcache.pArg ); + } + } - /* - ** Return the size in bytes of a PCache object. - */ - static int sqlite3PcacheSize() { - return 4; - }// sizeof( PCache ); } - - /* - ** Create a new PCache object. Storage space to hold the object - ** has already been allocated and is passed in as the p pointer. - ** The caller discovers how much space needs to be allocated by - ** calling sqlite3PcacheSize(). - */ - static void sqlite3PcacheOpen( - int szPage, /* Size of every page */ - int szExtra, /* Extra space associated with each page */ - bool bPurgeable, /* True if pages are on backing store */ - dxStress xStress,//int (*xStress)(void*,PgHdr*),/* Call to try to make pages clean */ - object pStress, /* Argument to xStress */ - PCache p /* Preallocated space for the PCache */ - ) { - p.Clear();//memset(p, 0, sizeof(PCache)); - p.szPage = szPage; - p.szExtra = szExtra; - p.bPurgeable = bPurgeable; - p.xStress = xStress; - p.pStress = pStress; - p.nMax = 100; - } + /* + ** Return the size in bytes of a PCache object. + */ + static int sqlite3PcacheSize() + { + return 4; + }// sizeof( PCache ); } - /* - ** Change the page size for PCache object. The caller must ensure that there - ** are no outstanding page references when this function is called. - */ - static void sqlite3PcacheSetPageSize(PCache pCache, int szPage) { - Debug.Assert(pCache.nRef == 0 && pCache.pDirty == null); - if (pCache.pCache != null) { - sqlite3GlobalConfig.pcache.xDestroy(ref pCache.pCache); - pCache.pCache = null; - } - pCache.szPage = szPage; - } + /* + ** Create a new PCache object. Storage space to hold the object + ** has already been allocated and is passed in as the p pointer. + ** The caller discovers how much space needs to be allocated by + ** calling sqlite3PcacheSize(). + */ + static void sqlite3PcacheOpen( + int szPage, /* Size of every page */ + int szExtra, /* Extra space associated with each page */ + bool bPurgeable, /* True if pages are on backing store */ + dxStress xStress,//int (*xStress)(void*,PgHdr*),/* Call to try to make pages clean */ + object pStress, /* Argument to xStress */ + PCache p /* Preallocated space for the PCache */ + ) + { + p.Clear();//memset(p, 0, sizeof(PCache)); + p.szPage = szPage; + p.szExtra = szExtra; + p.bPurgeable = bPurgeable; + p.xStress = xStress; + p.pStress = pStress; + p.nMax = 100; + } - /* - ** Try to obtain a page from the cache. + /* + ** Change the page size for PCache object. The caller must ensure that there + ** are no outstanding page references when this function is called. + */ + static void sqlite3PcacheSetPageSize( PCache pCache, int szPage ) + { + Debug.Assert( pCache.nRef == 0 && pCache.pDirty == null ); + if ( pCache.pCache != null ) + { + sqlite3GlobalConfig.pcache.xDestroy( ref pCache.pCache ); + pCache.pCache = null; + } + pCache.szPage = szPage; + } + + /* + ** Try to obtain a page from the cache. + */ + static int sqlite3PcacheFetch( + PCache pCache, /* Obtain the page from this cache */ + u32 pgno, /* Page number to obtain */ + int createFlag, /* If true, create page if it does not exist already */ + ref PgHdr ppPage /* Write the page here */ + ) + { + PgHdr pPage = null; + int eCreate; + + Debug.Assert( pCache != null ); + Debug.Assert( createFlag == 1 || createFlag == 0 ); + Debug.Assert( pgno > 0 ); + + /* If the pluggable cache (sqlite3_pcache*) has not been allocated, + ** allocate it now. + */ + if ( null == pCache.pCache && createFlag != 0 ) + { + sqlite3_pcache p; + int nByte; + nByte = pCache.szPage + pCache.szExtra + 0;// sizeof( PgHdr ); + p = sqlite3GlobalConfig.pcache.xCreate( nByte, pCache.bPurgeable ); + //if ( null == p ) + //{ + // return SQLITE_NOMEM; + //} + sqlite3GlobalConfig.pcache.xCachesize( p, pCache.nMax ); + pCache.pCache = p; + } + + eCreate = createFlag * ( 1 + ( ( !pCache.bPurgeable || null == pCache.pDirty ) ? 1 : 0 ) ); + + if ( pCache.pCache != null ) + { + pPage = sqlite3GlobalConfig.pcache.xFetch( pCache.pCache, pgno, eCreate ); + } + + if ( null == pPage && eCreate == 1 ) + { + PgHdr pPg; + + /* Find a dirty page to write-out and recycle. First try to find a + ** page that does not require a journal-sync (one with PGHDR_NEED_SYNC + ** cleared), but if that is not possible settle for any other + ** unreferenced dirty page. */ - static int sqlite3PcacheFetch( - PCache pCache, /* Obtain the page from this cache */ - u32 pgno, /* Page number to obtain */ - int createFlag, /* If true, create page if it does not exist already */ - ref PgHdr ppPage /* Write the page here */ - ) { - PgHdr pPage = null; - int eCreate; - - Debug.Assert(pCache != null); - Debug.Assert(createFlag == 1 || createFlag == 0); - Debug.Assert(pgno > 0); - - /* If the pluggable cache (sqlite3_pcache*) has not been allocated, - ** allocate it now. - */ - if (null == pCache.pCache && createFlag != 0) { - sqlite3_pcache p; - int nByte; - nByte = pCache.szPage + pCache.szExtra + 0;// sizeof( PgHdr ); - p = sqlite3GlobalConfig.pcache.xCreate(nByte, pCache.bPurgeable); - //if ( null == p ) - //{ - // return SQLITE_NOMEM; - //} - sqlite3GlobalConfig.pcache.xCachesize(p, pCache.nMax); - pCache.pCache = p; - } - - eCreate = createFlag * (1 + ((!pCache.bPurgeable || null == pCache.pDirty) ? 1 : 0)); - - if (pCache.pCache != null) { - pPage = sqlite3GlobalConfig.pcache.xFetch(pCache.pCache, pgno, eCreate); - } - - if (null == pPage && eCreate == 1) { - PgHdr pPg; - - /* Find a dirty page to write-out and recycle. First try to find a - ** page that does not require a journal-sync (one with PGHDR_NEED_SYNC - ** cleared), but if that is not possible settle for any other - ** unreferenced dirty page. - */ #if SQLITE_ENABLE_EXPENSIVE_ASSERT expensive_assert( pcacheCheckSynced(pCache) ); #endif - for (pPg = pCache.pSynced; - pPg != null && (pPg.nRef != 0 || (pPg.flags & PGHDR_NEED_SYNC) != 0); - pPg = pPg.pDirtyPrev - ) - ; - pCache.pSynced = pPg; - if (null == pPg) { - for (pPg = pCache.pDirtyTail; pPg != null && pPg.nRef != 0; pPg = pPg.pDirtyPrev) - ; - } - if (pPg != null) { - int rc; + for ( pPg = pCache.pSynced; + pPg != null && ( pPg.nRef != 0 || ( pPg.flags & PGHDR_NEED_SYNC ) != 0 ); + pPg = pPg.pDirtyPrev + ) + ; + pCache.pSynced = pPg; + if ( null == pPg ) + { + for ( pPg = pCache.pDirtyTail; pPg != null && pPg.nRef != 0; pPg = pPg.pDirtyPrev ) + ; + } + if ( pPg != null ) + { + int rc; #if SQLITE_LOG_CACHE_SPILL sqlite3_log(SQLITE_FULL, "spill page %d making room for %d - cache used: %d/%d", @@ -305,309 +344,366 @@ ref PgHdr ppPage /* Write the page here */ sqlite3GlobalConfig.pcache.xPagecount(pCache->pCache), pCache->nMax); #endif - rc = pCache.xStress(pCache.pStress, pPg); - if (rc != SQLITE_OK && rc != SQLITE_BUSY) { - return rc; - } - } - - pPage = sqlite3GlobalConfig.pcache.xFetch(pCache.pCache, pgno, 2); - } - - if (pPage != null) { - if (null == pPage.pData) { - // memset(pPage, 0, sizeof(PgHdr)); - pPage.pData = sqlite3Malloc(pCache.szPage);// pPage->pData = (void*)&pPage[1]; - //pPage->pExtra = (void*)&((char*)pPage->pData)[pCache->szPage]; - //memset(pPage->pExtra, 0, pCache->szExtra); - pPage.pCache = pCache; - pPage.pgno = pgno; - } - Debug.Assert(pPage.pCache == pCache); - Debug.Assert(pPage.pgno == pgno); - //assert(pPage->pData == (void*)&pPage[1]); - //assert(pPage->pExtra == (void*)&((char*)&pPage[1])[pCache->szPage]); - if (0 == pPage.nRef) { - pCache.nRef++; - } - pPage.nRef++; - if (pgno == 1) { - pCache.pPage1 = pPage; - } - } - ppPage = pPage; - return (pPage == null && eCreate != 0) ? SQLITE_NOMEM : SQLITE_OK; + rc = pCache.xStress( pCache.pStress, pPg ); + if ( rc != SQLITE_OK && rc != SQLITE_BUSY ) + { + return rc; + } } - /* - ** Decrement the reference count on a page. If the page is clean and the - ** reference count drops to 0, then it is made elible for recycling. - */ - static void sqlite3PcacheRelease(PgHdr p) { - Debug.Assert(p.nRef > 0); - p.nRef--; - if (p.nRef == 0) { - PCache pCache = p.pCache; - pCache.nRef--; - if ((p.flags & PGHDR_DIRTY) == 0) { - pcacheUnpin(p); - } else { - /* Move the page to the head of the dirty list. */ - pcacheRemoveFromDirtyList(p); - pcacheAddToDirtyList(p); - } - } + pPage = sqlite3GlobalConfig.pcache.xFetch( pCache.pCache, pgno, 2 ); + } + + if ( pPage != null ) + { + if ( null == pPage.pData ) + { + // memset(pPage, 0, sizeof(PgHdr)); + pPage.pData = sqlite3Malloc( pCache.szPage );// pPage->pData = (void*)&pPage[1]; + //pPage->pExtra = (void*)&((char*)pPage->pData)[pCache->szPage]; + //memset(pPage->pExtra, 0, pCache->szExtra); + pPage.pCache = pCache; + pPage.pgno = pgno; } - - /* - ** Increase the reference count of a supplied page by 1. - */ - static void sqlite3PcacheRef(PgHdr p) { - Debug.Assert(p.nRef > 0); - p.nRef++; + Debug.Assert( pPage.pCache == pCache ); + Debug.Assert( pPage.pgno == pgno ); + //assert(pPage->pData == (void*)&pPage[1]); + //assert(pPage->pExtra == (void*)&((char*)&pPage[1])[pCache->szPage]); + if ( 0 == pPage.nRef ) + { + pCache.nRef++; } - - /* - ** Drop a page from the cache. There must be exactly one reference to the - ** page. This function deletes that reference, so after it returns the - ** page pointed to by p is invalid. - */ - static void sqlite3PcacheDrop(PgHdr p) { - PCache pCache; - Debug.Assert(p.nRef == 1); - if ((p.flags & PGHDR_DIRTY) != 0) { - pcacheRemoveFromDirtyList(p); - } - pCache = p.pCache; - pCache.nRef--; - if (p.pgno == 1) { - pCache.pPage1 = null; - } - sqlite3GlobalConfig.pcache.xUnpin(pCache.pCache, p, true); + pPage.nRef++; + if ( pgno == 1 ) + { + pCache.pPage1 = pPage; } + } + ppPage = pPage; + return ( pPage == null && eCreate != 0 ) ? SQLITE_NOMEM : SQLITE_OK; + } - /* - ** Make sure the page is marked as dirty. If it isn't dirty already, - ** make it so. - */ - static void sqlite3PcacheMakeDirty(PgHdr p) { - p.flags &= ~PGHDR_DONT_WRITE; - Debug.Assert(p.nRef > 0); - if (0 == (p.flags & PGHDR_DIRTY)) { - p.flags |= PGHDR_DIRTY; - pcacheAddToDirtyList(p); - } + /* + ** Decrement the reference count on a page. If the page is clean and the + ** reference count drops to 0, then it is made elible for recycling. + */ + static void sqlite3PcacheRelease( PgHdr p ) + { + Debug.Assert( p.nRef > 0 ); + p.nRef--; + if ( p.nRef == 0 ) + { + PCache pCache = p.pCache; + pCache.nRef--; + if ( ( p.flags & PGHDR_DIRTY ) == 0 ) + { + pcacheUnpin( p ); } - - /* - ** Make sure the page is marked as clean. If it isn't clean already, - ** make it so. - */ - static void sqlite3PcacheMakeClean(PgHdr p) { - if ((p.flags & PGHDR_DIRTY) != 0) { - pcacheRemoveFromDirtyList(p); - p.flags &= ~(PGHDR_DIRTY | PGHDR_NEED_SYNC); - if (p.nRef == 0) { - pcacheUnpin(p); - } - } + else + { + /* Move the page to the head of the dirty list. */ + pcacheRemoveFromDirtyList( p ); + pcacheAddToDirtyList( p ); } + } + } - /* - ** Make every page in the cache clean. - */ - static void sqlite3PcacheCleanAll(PCache pCache) { - PgHdr p; - while ((p = pCache.pDirty) != null) { - sqlite3PcacheMakeClean(p); - } - } + /* + ** Increase the reference count of a supplied page by 1. + */ + static void sqlite3PcacheRef( PgHdr p ) + { + Debug.Assert( p.nRef > 0 ); + p.nRef++; + } - /* - ** Clear the PGHDR_NEED_SYNC flag from all dirty pages. - */ - static void sqlite3PcacheClearSyncFlags(PCache pCache) { - PgHdr p; - for (p = pCache.pDirty; p != null; p = p.pDirtyNext) { - p.flags &= ~PGHDR_NEED_SYNC; - } - pCache.pSynced = pCache.pDirtyTail; - } + /* + ** Drop a page from the cache. There must be exactly one reference to the + ** page. This function deletes that reference, so after it returns the + ** page pointed to by p is invalid. + */ + static void sqlite3PcacheDrop( PgHdr p ) + { + PCache pCache; + Debug.Assert( p.nRef == 1 ); + if ( ( p.flags & PGHDR_DIRTY ) != 0 ) + { + pcacheRemoveFromDirtyList( p ); + } + pCache = p.pCache; + pCache.nRef--; + if ( p.pgno == 1 ) + { + pCache.pPage1 = null; + } + sqlite3GlobalConfig.pcache.xUnpin( pCache.pCache, p, true ); + } - /* - ** Change the page number of page p to newPgno. - */ - static void sqlite3PcacheMove(PgHdr p, Pgno newPgno) { - PCache pCache = p.pCache; - Debug.Assert(p.nRef > 0); - Debug.Assert(newPgno > 0); - sqlite3GlobalConfig.pcache.xRekey(pCache.pCache, p, p.pgno, newPgno); - p.pgno = newPgno; - if ((p.flags & PGHDR_DIRTY) != 0 && (p.flags & PGHDR_NEED_SYNC) != 0) { - pcacheRemoveFromDirtyList(p); - pcacheAddToDirtyList(p); - } - } + /* + ** Make sure the page is marked as dirty. If it isn't dirty already, + ** make it so. + */ + static void sqlite3PcacheMakeDirty( PgHdr p ) + { + p.flags &= ~PGHDR_DONT_WRITE; + Debug.Assert( p.nRef > 0 ); + if ( 0 == ( p.flags & PGHDR_DIRTY ) ) + { + p.flags |= PGHDR_DIRTY; + pcacheAddToDirtyList( p ); + } + } - /* - ** Drop every cache entry whose page number is greater than "pgno". The - ** caller must ensure that there are no outstanding references to any pages - ** other than page 1 with a page number greater than pgno. - ** - ** If there is a reference to page 1 and the pgno parameter passed to this - ** function is 0, then the data area associated with page 1 is zeroed, but - ** the page object is not dropped. - */ - static void sqlite3PcacheTruncate(PCache pCache, u32 pgno) { - if (pCache.pCache != null) { - PgHdr p; - PgHdr pNext; - for (p = pCache.pDirty; p != null; p = pNext) { - pNext = p.pDirtyNext; - /* This routine never gets call with a positive pgno except right - ** after sqlite3PcacheCleanAll(). So if there are dirty pages, - ** it must be that pgno==0. - */ - Debug.Assert(p.pgno > 0); - if (ALWAYS(p.pgno > pgno)) { - Debug.Assert((p.flags & PGHDR_DIRTY) != 0); - sqlite3PcacheMakeClean(p); - } - } - if (pgno == 0 && pCache.pPage1 != null) { - // memset( pCache.pPage1.pData, 0, pCache.szPage ); - pCache.pPage1.pData = sqlite3Malloc(pCache.szPage); - pgno = 1; - } - sqlite3GlobalConfig.pcache.xTruncate(pCache.pCache, pgno + 1); - } + /* + ** Make sure the page is marked as clean. If it isn't clean already, + ** make it so. + */ + static void sqlite3PcacheMakeClean( PgHdr p ) + { + if ( ( p.flags & PGHDR_DIRTY ) != 0 ) + { + pcacheRemoveFromDirtyList( p ); + p.flags &= ~( PGHDR_DIRTY | PGHDR_NEED_SYNC ); + if ( p.nRef == 0 ) + { + pcacheUnpin( p ); } + } + } - /* - ** Close a cache. - */ - static void sqlite3PcacheClose(PCache pCache) { - if (pCache.pCache != null) { - sqlite3GlobalConfig.pcache.xDestroy(ref pCache.pCache); - } - } + /* + ** Make every page in the cache clean. + */ + static void sqlite3PcacheCleanAll( PCache pCache ) + { + PgHdr p; + while ( ( p = pCache.pDirty ) != null ) + { + sqlite3PcacheMakeClean( p ); + } + } - /* - ** Discard the contents of the cache. - */ - static void sqlite3PcacheClear(PCache pCache) { - sqlite3PcacheTruncate(pCache, 0); - } + /* + ** Clear the PGHDR_NEED_SYNC flag from all dirty pages. + */ + static void sqlite3PcacheClearSyncFlags( PCache pCache ) + { + PgHdr p; + for ( p = pCache.pDirty; p != null; p = p.pDirtyNext ) + { + p.flags &= ~PGHDR_NEED_SYNC; + } + pCache.pSynced = pCache.pDirtyTail; + } + /* + ** Change the page number of page p to newPgno. + */ + static void sqlite3PcacheMove( PgHdr p, Pgno newPgno ) + { + PCache pCache = p.pCache; + Debug.Assert( p.nRef > 0 ); + Debug.Assert( newPgno > 0 ); + sqlite3GlobalConfig.pcache.xRekey( pCache.pCache, p, p.pgno, newPgno ); + p.pgno = newPgno; + if ( ( p.flags & PGHDR_DIRTY ) != 0 && ( p.flags & PGHDR_NEED_SYNC ) != 0 ) + { + pcacheRemoveFromDirtyList( p ); + pcacheAddToDirtyList( p ); + } + } - /* - ** Merge two lists of pages connected by pDirty and in pgno order. - ** Do not both fixing the pDirtyPrev pointers. - */ - static PgHdr pcacheMergeDirtyList(PgHdr pA, PgHdr pB) { - PgHdr result = new PgHdr(); - PgHdr pTail = result; - while (pA != null && pB != null) { - if (pA.pgno < pB.pgno) { - pTail.pDirty = pA; - pTail = pA; - pA = pA.pDirty; - } else { - pTail.pDirty = pB; - pTail = pB; - pB = pB.pDirty; - } - } - if (pA != null) { - pTail.pDirty = pA; - } else if (pB != null) { - pTail.pDirty = pB; - } else { - pTail.pDirty = null; - } - return result.pDirty; + /* + ** Drop every cache entry whose page number is greater than "pgno". The + ** caller must ensure that there are no outstanding references to any pages + ** other than page 1 with a page number greater than pgno. + ** + ** If there is a reference to page 1 and the pgno parameter passed to this + ** function is 0, then the data area associated with page 1 is zeroed, but + ** the page object is not dropped. + */ + static void sqlite3PcacheTruncate( PCache pCache, u32 pgno ) + { + if ( pCache.pCache != null ) + { + PgHdr p; + PgHdr pNext; + for ( p = pCache.pDirty; p != null; p = pNext ) + { + pNext = p.pDirtyNext; + /* This routine never gets call with a positive pgno except right + ** after sqlite3PcacheCleanAll(). So if there are dirty pages, + ** it must be that pgno==0. + */ + Debug.Assert( p.pgno > 0 ); + if ( ALWAYS( p.pgno > pgno ) ) + { + Debug.Assert( ( p.flags & PGHDR_DIRTY ) != 0 ); + sqlite3PcacheMakeClean( p ); + } } - - /* - ** Sort the list of pages in accending order by pgno. Pages are - ** connected by pDirty pointers. The pDirtyPrev pointers are - ** corrupted by this sort. - ** - ** Since there cannot be more than 2^31 distinct pages in a database, - ** there cannot be more than 31 buckets required by the merge sorter. - ** One extra bucket is added to catch overflow in case something - ** ever changes to make the previous sentence incorrect. - */ - //#define N_SORT_BUCKET 32 - const int N_SORT_BUCKET = 32; - - static PgHdr pcacheSortDirtyList(PgHdr pIn) { - PgHdr[] a; - PgHdr p;//a[N_SORT_BUCKET], p; - int i; - a = new PgHdr[N_SORT_BUCKET];//memset(a, 0, sizeof(a)); - while (pIn != null) { - p = pIn; - pIn = p.pDirty; - p.pDirty = null; - for (i = 0; ALWAYS(i < N_SORT_BUCKET - 1); i++) { - if (a[i] == null) { - a[i] = p; - break; - } else { - p = pcacheMergeDirtyList(a[i], p); - a[i] = null; - } - } - if (NEVER(i == N_SORT_BUCKET - 1)) { - /* To get here, there need to be 2^(N_SORT_BUCKET) elements in - ** the input list. But that is impossible. - */ - a[i] = pcacheMergeDirtyList(a[i], p); - } - } - p = a[0]; - for (i = 1; i < N_SORT_BUCKET; i++) { - p = pcacheMergeDirtyList(p, a[i]); - } - return p; + if ( pgno == 0 && pCache.pPage1 != null ) + { + // memset( pCache.pPage1.pData, 0, pCache.szPage ); + pCache.pPage1.pData = sqlite3Malloc( pCache.szPage ); + pgno = 1; } + sqlite3GlobalConfig.pcache.xTruncate( pCache.pCache, pgno + 1 ); + } + } - /* - ** Return a list of all dirty pages in the cache, sorted by page number. - */ - static PgHdr sqlite3PcacheDirtyList(PCache pCache) { - PgHdr p; - for (p = pCache.pDirty; p != null; p = p.pDirtyNext) { - p.pDirty = p.pDirtyNext; - } - return pcacheSortDirtyList(pCache.pDirty); - } + /* + ** Close a cache. + */ + static void sqlite3PcacheClose( PCache pCache ) + { + if ( pCache.pCache != null ) + { + sqlite3GlobalConfig.pcache.xDestroy( ref pCache.pCache ); + } + } - /* - ** Return the total number of referenced pages held by the cache. - */ - static int sqlite3PcacheRefCount(PCache pCache) { - return pCache.nRef; - } + /* + ** Discard the contents of the cache. + */ + static void sqlite3PcacheClear( PCache pCache ) + { + sqlite3PcacheTruncate( pCache, 0 ); + } - /* - ** Return the number of references to the page supplied as an argument. - */ - static int sqlite3PcachePageRefcount(PgHdr p) { - return p.nRef; + + /* + ** Merge two lists of pages connected by pDirty and in pgno order. + ** Do not both fixing the pDirtyPrev pointers. + */ + static PgHdr pcacheMergeDirtyList( PgHdr pA, PgHdr pB ) + { + PgHdr result = new PgHdr(); + PgHdr pTail = result; + while ( pA != null && pB != null ) + { + if ( pA.pgno < pB.pgno ) + { + pTail.pDirty = pA; + pTail = pA; + pA = pA.pDirty; } + else + { + pTail.pDirty = pB; + pTail = pB; + pB = pB.pDirty; + } + } + if ( pA != null ) + { + pTail.pDirty = pA; + } + else if ( pB != null ) + { + pTail.pDirty = pB; + } + else + { + pTail.pDirty = null; + } + return result.pDirty; + } - /* - ** Return the total number of pages in the cache. - */ - static int sqlite3PcachePagecount(PCache pCache) { - int nPage = 0; - if (pCache.pCache != null) { - nPage = sqlite3GlobalConfig.pcache.xPagecount(pCache.pCache); - } - return nPage; + /* + ** Sort the list of pages in accending order by pgno. Pages are + ** connected by pDirty pointers. The pDirtyPrev pointers are + ** corrupted by this sort. + ** + ** Since there cannot be more than 2^31 distinct pages in a database, + ** there cannot be more than 31 buckets required by the merge sorter. + ** One extra bucket is added to catch overflow in case something + ** ever changes to make the previous sentence incorrect. + */ + //#define N_SORT_BUCKET 32 + const int N_SORT_BUCKET = 32; + + static PgHdr pcacheSortDirtyList( PgHdr pIn ) + { + PgHdr[] a; + PgHdr p;//a[N_SORT_BUCKET], p; + int i; + a = new PgHdr[N_SORT_BUCKET];//memset(a, 0, sizeof(a)); + while ( pIn != null ) + { + p = pIn; + pIn = p.pDirty; + p.pDirty = null; + for ( i = 0; ALWAYS( i < N_SORT_BUCKET - 1 ); i++ ) + { + if ( a[i] == null ) + { + a[i] = p; + break; + } + else + { + p = pcacheMergeDirtyList( a[i], p ); + a[i] = null; + } + } + if ( NEVER( i == N_SORT_BUCKET - 1 ) ) + { + /* To get here, there need to be 2^(N_SORT_BUCKET) elements in + ** the input list. But that is impossible. + */ + a[i] = pcacheMergeDirtyList( a[i], p ); } + } + p = a[0]; + for ( i = 1; i < N_SORT_BUCKET; i++ ) + { + p = pcacheMergeDirtyList( p, a[i] ); + } + return p; + } + + /* + ** Return a list of all dirty pages in the cache, sorted by page number. + */ + static PgHdr sqlite3PcacheDirtyList( PCache pCache ) + { + PgHdr p; + for ( p = pCache.pDirty; p != null; p = p.pDirtyNext ) + { + p.pDirty = p.pDirtyNext; + } + return pcacheSortDirtyList( pCache.pDirty ); + } + + /* + ** Return the total number of referenced pages held by the cache. + */ + static int sqlite3PcacheRefCount( PCache pCache ) + { + return pCache.nRef; + } + + /* + ** Return the number of references to the page supplied as an argument. + */ + static int sqlite3PcachePageRefcount( PgHdr p ) + { + return p.nRef; + } + + /* + ** Return the total number of pages in the cache. + */ + static int sqlite3PcachePagecount( PCache pCache ) + { + int nPage = 0; + if ( pCache.pCache != null ) + { + nPage = sqlite3GlobalConfig.pcache.xPagecount( pCache.pCache ); + } + return nPage; + } #if SQLITE_TEST /* @@ -619,28 +715,32 @@ static int sqlite3PcacheGetCachesize( PCache pCache ) } #endif - /* - ** Set the suggested cache-size value. - */ - static void sqlite3PcacheSetCachesize(PCache pCache, int mxPage) { - pCache.nMax = mxPage; - if (pCache.pCache != null) { - sqlite3GlobalConfig.pcache.xCachesize(pCache.pCache, mxPage); - } - } + /* +** Set the suggested cache-size value. +*/ + static void sqlite3PcacheSetCachesize( PCache pCache, int mxPage ) + { + pCache.nMax = mxPage; + if ( pCache.pCache != null ) + { + sqlite3GlobalConfig.pcache.xCachesize( pCache.pCache, mxPage ); + } + } -#if SQLITE_CHECK_PAGES || (SQLITE_DEBUG) - /* - ** For all dirty pages currently in the cache, invoke the specified - ** callback. This is only used if the SQLITE_CHECK_PAGES macro is - ** defined. - */ - static void sqlite3PcacheIterateDirty(PCache pCache, dxIter xIter) { - PgHdr pDirty; - for (pDirty = pCache.pDirty; pDirty != null; pDirty = pDirty.pDirtyNext) { - xIter(pDirty); - } - } -#endif +#if SQLITE_CHECK_PAGES || (SQLITE_DEBUG) + /* +** For all dirty pages currently in the cache, invoke the specified +** callback. This is only used if the SQLITE_CHECK_PAGES macro is +** defined. +*/ + static void sqlite3PcacheIterateDirty( PCache pCache, dxIter xIter ) + { + PgHdr pDirty; + for ( pDirty = pCache.pDirty; pDirty != null; pDirty = pDirty.pDirtyNext ) + { + xIter( pDirty ); + } } +#endif + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/pcache_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/pcache_h.cs index 8f34c21f5..e51a4004d 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/pcache_h.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/pcache_h.cs @@ -1,170 +1,181 @@ +using System; +using System.Diagnostics; +using System.IO; + +using i16 = System.Int16; +using u32 = System.UInt32; using Pgno = System.UInt32; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2008 August 05 - ** - ** 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 header file defines the interface that the sqlite page cache - ** subsystem. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 2008 August 05 + ** + ** 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 header file defines the interface that the sqlite page cache + ** subsystem. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ #if !_PCACHE_H_ - //typedef struct PgHdr PgHdr; - //typedef struct PCache PCache; - - /* - ** Every page in the cache is controlled by an instance of the following - ** structure. - */ - public class PgHdr { - public byte[] pData; /* Content of this page */ - public MemPage pExtra; /* Extra content */ - public PgHdr pDirty; /* Transient list of dirty pages */ - public Pgno pgno; /* The page number for this page */ - public Pager pPager; /* The pager to which this page belongs */ + //typedef struct PgHdr PgHdr; + //typedef struct PCache PCache; + + /* + ** Every page in the cache is controlled by an instance of the following + ** structure. + */ + public class PgHdr + { + public byte[] pData; /* Content of this page */ + public MemPage pExtra; /* Extra content */ + public PgHdr pDirty; /* Transient list of dirty pages */ + public Pgno pgno; /* The page number for this page */ + public Pager pPager; /* The pager to which this page belongs */ #if SQLITE_CHECK_PAGES || (SQLITE_DEBUG) - public int pageHash; /* Hash of page content */ + public int pageHash; /* Hash of page content */ #endif - public int flags; /* PGHDR flags defined below */ - /********************************************************************** - ** Elements above are public. All that follows is private to pcache.c - ** and should not be accessed by other modules. - */ - public int nRef; /* Number of users of this page */ - public PCache pCache; /* Cache that owns this page */ - public bool CacheAllocated; /* True, if allocated from cache */ - - public PgHdr pDirtyNext; /* Next element in list of dirty pages */ - public PgHdr pDirtyPrev; /* Previous element in list of dirty pages */ - public PgHdr1 pPgHdr1; /* Cache page header this this page */ - - public static implicit operator bool(PgHdr b) { - return (b != null); - } - - - public void Clear() { - sqlite3_free(ref this.pData); - this.pData = null; - this.pExtra = null; - this.pDirty = null; - this.pgno = 0; - this.pPager = null; + public int flags; /* PGHDR flags defined below */ + /********************************************************************** + ** Elements above are public. All that follows is private to pcache.c + ** and should not be accessed by other modules. + */ + public int nRef; /* Number of users of this page */ + public PCache pCache; /* Cache that owns this page */ + public bool CacheAllocated; /* True, if allocated from cache */ + + public PgHdr pDirtyNext; /* Next element in list of dirty pages */ + public PgHdr pDirtyPrev; /* Previous element in list of dirty pages */ + public PgHdr1 pPgHdr1; /* Cache page header this this page */ + + public static implicit operator bool( PgHdr b ) + { + return ( b != null ); + } + + + public void Clear() + { + sqlite3_free( ref this.pData ); + this.pData = null; + this.pExtra = null; + this.pDirty = null; + this.pgno = 0; + this.pPager = null; #if SQLITE_CHECK_PAGES this.pageHash=0; #endif - this.flags = 0; - this.nRef = 0; - this.CacheAllocated = false; - this.pCache = null; - this.pDirtyNext = null; - this.pDirtyPrev = null; - this.pPgHdr1 = null; - } - }; - - /* Bit values for PgHdr.flags */ - //#define PGHDR_DIRTY 0x002 /* Page has changed */ - //#define PGHDR_NEED_SYNC 0x004 /* Fsync the rollback journal before - // ** writing this page to the database */ - //#define PGHDR_NEED_READ 0x008 /* Content is unread */ - //#define PGHDR_REUSE_UNLIKELY 0x010 /* A hint that reuse is unlikely */ - //#define PGHDR_DONT_WRITE 0x020 /* Do not write content to disk */ - - const int PGHDR_DIRTY = 0x002; /* Page has changed */ - const int PGHDR_NEED_SYNC = 0x004;/* Fsync the rollback journal before + this.flags = 0; + this.nRef = 0; + this.CacheAllocated = false; + this.pCache = null; + this.pDirtyNext = null; + this.pDirtyPrev = null; + this.pPgHdr1 = null; + } + }; + + /* Bit values for PgHdr.flags */ + //#define PGHDR_DIRTY 0x002 /* Page has changed */ + //#define PGHDR_NEED_SYNC 0x004 /* Fsync the rollback journal before + // ** writing this page to the database */ + //#define PGHDR_NEED_READ 0x008 /* Content is unread */ + //#define PGHDR_REUSE_UNLIKELY 0x010 /* A hint that reuse is unlikely */ + //#define PGHDR_DONT_WRITE 0x020 /* Do not write content to disk */ + + const int PGHDR_DIRTY = 0x002; /* Page has changed */ + const int PGHDR_NEED_SYNC = 0x004;/* Fsync the rollback journal before ** writing this page to the database */ - const int PGHDR_NEED_READ = 0x008;/* Content is unread */ - const int PGHDR_REUSE_UNLIKELY = 0x010;/* A hint that reuse is unlikely */ - const int PGHDR_DONT_WRITE = 0x020;/* Do not write content to disk */ + const int PGHDR_NEED_READ = 0x008;/* Content is unread */ + const int PGHDR_REUSE_UNLIKELY = 0x010;/* A hint that reuse is unlikely */ + const int PGHDR_DONT_WRITE = 0x020;/* Do not write content to disk */ - /* Initialize and shutdown the page cache subsystem */ - //int sqlite3PcacheInitialize(void); - //void sqlite3PcacheShutdown(void); + /* Initialize and shutdown the page cache subsystem */ + //int sqlite3PcacheInitialize(void); + //void sqlite3PcacheShutdown(void); - /* Page cache buffer management: - ** These routines implement SQLITE_CONFIG_PAGECACHE. - */ - //void sqlite3PCacheBufferSetup(void *, int sz, int n); - - /* Create a new pager cache. - ** Under memory stress, invoke xStress to try to make pages clean. - ** Only clean and unpinned pages can be reclaimed. - */ - //void sqlite3PcacheOpen( - // int szPage, /* Size of every page */ - // int szExtra, /* Extra space associated with each page */ - // int bPurgeable, /* True if pages are on backing store */ - // int (*xStress)(void*, PgHdr*), /* Call to try to make pages clean */ - // void pStress, /* Argument to xStress */ - // PCache pToInit /* Preallocated space for the PCache */ - //); - - /* Modify the page-size after the cache has been created. */ - //void sqlite3PcacheSetPageSize(PCache *, int); + /* Page cache buffer management: + ** These routines implement SQLITE_CONFIG_PAGECACHE. + */ + //void sqlite3PCacheBufferSetup(void *, int sz, int n); - /* Return the size in bytes of a PCache object. Used to preallocate - ** storage space. - */ - //int sqlite3PcacheSize(void); + /* Create a new pager cache. + ** Under memory stress, invoke xStress to try to make pages clean. + ** Only clean and unpinned pages can be reclaimed. + */ + //void sqlite3PcacheOpen( + // int szPage, /* Size of every page */ + // int szExtra, /* Extra space associated with each page */ + // int bPurgeable, /* True if pages are on backing store */ + // int (*xStress)(void*, PgHdr*), /* Call to try to make pages clean */ + // void pStress, /* Argument to xStress */ + // PCache pToInit /* Preallocated space for the PCache */ + //); + + /* Modify the page-size after the cache has been created. */ + //void sqlite3PcacheSetPageSize(PCache *, int); + + /* Return the size in bytes of a PCache object. Used to preallocate + ** storage space. + */ + //int sqlite3PcacheSize(void); - /* One release per successful fetch. Page is pinned until released. - ** Reference counted. - */ - //int sqlite3PcacheFetch(PCache*, Pgno, int createFlag, PgHdr**); - //void sqlite3PcacheRelease(PgHdr*); + /* One release per successful fetch. Page is pinned until released. + ** Reference counted. + */ + //int sqlite3PcacheFetch(PCache*, Pgno, int createFlag, PgHdr**); + //void sqlite3PcacheRelease(PgHdr*); - //void sqlite3PcacheDrop(PgHdr*); /* Remove page from cache */ - //void sqlite3PcacheMakeDirty(PgHdr*); /* Make sure page is marked dirty */ - //void sqlite3PcacheMakeClean(PgHdr*); /* Mark a single page as clean */ - //void sqlite3PcacheCleanAll(PCache*); /* Mark all dirty list pages as clean */ + //void sqlite3PcacheDrop(PgHdr*); /* Remove page from cache */ + //void sqlite3PcacheMakeDirty(PgHdr*); /* Make sure page is marked dirty */ + //void sqlite3PcacheMakeClean(PgHdr*); /* Mark a single page as clean */ + //void sqlite3PcacheCleanAll(PCache*); /* Mark all dirty list pages as clean */ - /* Change a page number. Used by incr-vacuum. */ - //void sqlite3PcacheMove(PgHdr*, Pgno); + /* Change a page number. Used by incr-vacuum. */ + //void sqlite3PcacheMove(PgHdr*, Pgno); - /* Remove all pages with pgno>x. Reset the cache if x==0 */ - //void sqlite3PcacheTruncate(PCache*, Pgno x); + /* Remove all pages with pgno>x. Reset the cache if x==0 */ + //void sqlite3PcacheTruncate(PCache*, Pgno x); - /* Get a list of all dirty pages in the cache, sorted by page number */ - //PgHdr *sqlite3PcacheDirtyList(PCache*); + /* Get a list of all dirty pages in the cache, sorted by page number */ + //PgHdr *sqlite3PcacheDirtyList(PCache*); - /* Reset and close the cache object */ - //void sqlite3PcacheClose(PCache*); + /* Reset and close the cache object */ + //void sqlite3PcacheClose(PCache*); - /* Clear flags from pages of the page cache */ - //void sqlite3PcacheClearSyncFlags(PCache *); + /* Clear flags from pages of the page cache */ + //void sqlite3PcacheClearSyncFlags(PCache *); - /* Discard the contents of the cache */ - //void sqlite3PcacheClear(PCache*); + /* Discard the contents of the cache */ + //void sqlite3PcacheClear(PCache*); - /* Return the total number of outstanding page references */ - //int sqlite3PcacheRefCount(PCache*); + /* Return the total number of outstanding page references */ + //int sqlite3PcacheRefCount(PCache*); - /* Increment the reference count of an existing page */ - //void sqlite3PcacheRef(PgHdr*); + /* Increment the reference count of an existing page */ + //void sqlite3PcacheRef(PgHdr*); - //int sqlite3PcachePageRefcount(PgHdr*); + //int sqlite3PcachePageRefcount(PgHdr*); - /* Return the total number of pages stored in the cache */ - //int sqlite3PcachePagecount(PCache*); + /* Return the total number of pages stored in the cache */ + //int sqlite3PcachePagecount(PCache*); #if SQLITE_CHECK_PAGES /* Iterate through all dirty pages currently stored in the cache. This @@ -175,13 +186,13 @@ public void Clear() { //void sqlite3PcacheIterateDirty(PCache pCache, void (*xIter)(PgHdr *)); #endif - /* Set and get the suggested cache-size for the specified pager-cache. - ** - ** If no global maximum is configured, then the system attempts to limit - ** the total number of pages cached by purgeable pager-caches to the sum - ** of the suggested cache-sizes. - */ - //void sqlite3PcacheSetCachesize(PCache *, int); + /* Set and get the suggested cache-size for the specified pager-cache. +** +** If no global maximum is configured, then the system attempts to limit +** the total number of pages cached by purgeable pager-caches to the sum +** of the suggested cache-sizes. +*/ + //void sqlite3PcacheSetCachesize(PCache *, int); #if SQLITE_TEST //int sqlite3PcacheGetCachesize(PCache *); #endif @@ -195,8 +206,8 @@ public void Clear() { //void sqlite3PcacheStats(int*,int*,int*,int*); #endif - //void sqlite3PCacheSetDefault(void); + //void sqlite3PCacheSetDefault(void); #endif //* _PCACHE_H_ */ - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/pragma_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/pragma_c.cs index 15fbe5acb..5c551c945 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/pragma_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/pragma_c.cs @@ -1,202 +1,232 @@ using System; using System.Diagnostics; +using System.Text; using i64 = System.Int64; -using sqlite3_int64 = System.Int64; using u8 = System.Byte; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2003 April 6 - ** - ** 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 contains code used to implement the PRAGMA command. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +using Pgno = System.UInt32; +using sqlite3_int64 = System.Int64; +using System.Globalization; - /* - ** 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. +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 2003 April 6 ** - ** Note that the values returned are one less that the values that - ** should be passed into sqlite3BtreeSetSafetyLevel(). The is done - ** to support legacy SQL code. The safety level used to be boolean - ** and older scripts may have used numbers 0 for OFF and 1 for ON. + ** 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 contains code used to implement the PRAGMA command. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* */ - static u8 getSafetyLevel(string z) { - // /* 123456789 123456789 */ - string zText = "onoffalseyestruefull"; - int[] iOffset = new int[] { 0, 1, 2, 4, 9, 12, 16 }; - int[] iLength = new int[] { 2, 2, 3, 5, 3, 4, 4 }; - u8[] iValue = new u8[] { 1, 0, 0, 0, 1, 1, 2 }; - int i, n; - if (sqlite3Isdigit(z[0])) { - return (u8)sqlite3Atoi(z); - } - n = sqlite3Strlen30(z); - for (i = 0; i < ArraySize(iLength); i++) { - if (iLength[i] == n && sqlite3StrNICmp(zText.Substring(iOffset[i]), z, n) == 0) { - return iValue[i]; - } - } - return 1; - } + //#include "sqliteInt.h" - /* - ** Interpret the given string as a boolean value. - */ - static u8 sqlite3GetBoolean(string z) { - return (u8)(getSafetyLevel(z) & 1);//return getSafetyLevel(z)&1; + /* +** 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. +** +** Note that the values returned are one less that the values that +** should be passed into sqlite3BtreeSetSafetyLevel(). The is done +** to support legacy SQL code. The safety level used to be boolean +** and older scripts may have used numbers 0 for OFF and 1 for ON. +*/ + static u8 getSafetyLevel( string z ) + { + // /* 123456789 123456789 */ + string zText = "onoffalseyestruefull"; + int[] iOffset = new int[] { 0, 1, 2, 4, 9, 12, 16 }; + int[] iLength = new int[] { 2, 2, 3, 5, 3, 4, 4 }; + u8[] iValue = new u8[] { 1, 0, 0, 0, 1, 1, 2 }; + int i, n; + if ( sqlite3Isdigit( z[0] ) ) + { + return (u8)sqlite3Atoi( z ); + } + n = sqlite3Strlen30( z ); + for ( i = 0; i < ArraySize( iLength ); i++ ) + { + if ( iLength[i] == n && sqlite3StrNICmp( zText.Substring( iOffset[i] ), z, n ) == 0 ) + { + return iValue[i]; } + } + return 1; + } - /* The sqlite3GetBoolean() function is used by other modules but the - ** remainder of this file is specific to PRAGMA processing. So omit - ** the rest of the file if PRAGMAs are omitted from the build. - */ + /* + ** Interpret the given string as a boolean value. + */ + static u8 sqlite3GetBoolean(string z){ + return (u8)( getSafetyLevel( z ) & 1 );//return getSafetyLevel(z)&1; +} + +/* The sqlite3GetBoolean() function is used by other modules but the +** remainder of this file is specific to PRAGMA processing. So omit +** the rest of the file if PRAGMAs are omitted from the build. +*/ #if !(SQLITE_OMIT_PRAGMA) - /* - ** Interpret the given string as a locking mode value. - */ - static int getLockingMode(string z) { - if (z != null) { - if (z.Equals("exclusive", StringComparison.OrdinalIgnoreCase)) - return PAGER_LOCKINGMODE_EXCLUSIVE; - if (z.Equals("normal", StringComparison.OrdinalIgnoreCase)) - return PAGER_LOCKINGMODE_NORMAL; - } - return PAGER_LOCKINGMODE_QUERY; - } + /* + ** Interpret the given string as a locking mode value. + */ + static int getLockingMode( string z ) + { + if ( z != null ) + { + if ( z.Equals( "exclusive", StringComparison.OrdinalIgnoreCase ) ) + return PAGER_LOCKINGMODE_EXCLUSIVE; + if ( z.Equals( "normal", StringComparison.OrdinalIgnoreCase ) ) + return PAGER_LOCKINGMODE_NORMAL; + } + return PAGER_LOCKINGMODE_QUERY; + } #if !SQLITE_OMIT_AUTOVACUUM - /* - ** Interpret the given string as an auto-vacuum mode value. - ** - ** The following strings, "none", "full" and "incremental" are - ** acceptable, as are their numeric equivalents: 0, 1 and 2 respectively. - */ - static u8 getAutoVacuum(string z) { - int i; - if (z.Equals("none", StringComparison.OrdinalIgnoreCase)) - return BTREE_AUTOVACUUM_NONE; - if (z.Equals("full", StringComparison.OrdinalIgnoreCase)) - return BTREE_AUTOVACUUM_FULL; - if (z.Equals("incremental", StringComparison.OrdinalIgnoreCase)) - return BTREE_AUTOVACUUM_INCR; - i = atoi(z); - return (u8)((i >= 0 && i <= 2) ? i : 0); - } + /* +** Interpret the given string as an auto-vacuum mode value. +** +** The following strings, "none", "full" and "incremental" are +** acceptable, as are their numeric equivalents: 0, 1 and 2 respectively. +*/ + static u8 getAutoVacuum( string z ) + { + int i; + if ( z.Equals( "none", StringComparison.OrdinalIgnoreCase ) ) + return BTREE_AUTOVACUUM_NONE; + if ( z.Equals( "full", StringComparison.OrdinalIgnoreCase ) ) + return BTREE_AUTOVACUUM_FULL; + if ( z.Equals( "incremental", StringComparison.OrdinalIgnoreCase ) ) + return BTREE_AUTOVACUUM_INCR; + i = atoi( z ); + return (u8)( ( i >= 0 && i <= 2 ) ? i : 0 ); + } #endif // * if !SQLITE_OMIT_AUTOVACUUM */ #if !SQLITE_OMIT_PAGER_PRAGMAS - /* - ** Interpret the given string as a temp db location. Return 1 for file - ** backed temporary databases, 2 for the Red-Black tree in memory database - ** and 0 to use the compile-time default. - */ - static int getTempStore(string z) { - if (z[0] >= '0' && z[0] <= '2') { - return z[0] - '0'; - } else if (z.Equals("file", StringComparison.OrdinalIgnoreCase)) { - return 1; - } else if (z.Equals("memory", StringComparison.OrdinalIgnoreCase)) { - return 2; - } else { - return 0; - } - } + /* +** Interpret the given string as a temp db location. Return 1 for file +** backed temporary databases, 2 for the Red-Black tree in memory database +** and 0 to use the compile-time default. +*/ + static int getTempStore( string z ) + { + if ( z[0] >= '0' && z[0] <= '2' ) + { + return z[0] - '0'; + } + else if ( z.Equals( "file", StringComparison.OrdinalIgnoreCase ) ) + { + return 1; + } + else if ( z.Equals( "memory", StringComparison.OrdinalIgnoreCase ) ) + { + return 2; + } + else + { + return 0; + } + } #endif // * SQLITE_PAGER_PRAGMAS */ #if !SQLITE_OMIT_PAGER_PRAGMAS - /* - ** Invalidate temp storage, either when the temp storage is changed - ** from default, or when 'file' and the temp_store_directory has changed - */ - static int invalidateTempStorage(Parse pParse) { - sqlite3 db = pParse.db; - if (db.aDb[1].pBt != null) { - if (0 == db.autoCommit || sqlite3BtreeIsInReadTrans(db.aDb[1].pBt)) { - sqlite3ErrorMsg(pParse, "temporary storage cannot be changed " + - "from within a transaction"); - return SQLITE_ERROR; - } - sqlite3BtreeClose(ref db.aDb[1].pBt); - db.aDb[1].pBt = null; - sqlite3ResetInternalSchema(db, -1); - } - return SQLITE_OK; + /* +** Invalidate temp storage, either when the temp storage is changed +** from default, or when 'file' and the temp_store_directory has changed +*/ + static int invalidateTempStorage( Parse pParse ) + { + sqlite3 db = pParse.db; + if ( db.aDb[1].pBt != null ) + { + if ( 0 == db.autoCommit || sqlite3BtreeIsInReadTrans( db.aDb[1].pBt ) ) + { + sqlite3ErrorMsg( pParse, "temporary storage cannot be changed " + + "from within a transaction" ); + return SQLITE_ERROR; } + sqlite3BtreeClose( ref db.aDb[1].pBt ); + db.aDb[1].pBt = null; + sqlite3ResetInternalSchema( db, -1 ); + } + return SQLITE_OK; + } #endif // * SQLITE_PAGER_PRAGMAS */ #if !SQLITE_OMIT_PAGER_PRAGMAS - /* - ** If the TEMP database is open, close it and mark the database schema - ** as needing reloading. This must be done when using the SQLITE_TEMP_STORE - ** or DEFAULT_TEMP_STORE pragmas. - */ - static int changeTempStorage(Parse pParse, string zStorageType) { - int ts = getTempStore(zStorageType); - sqlite3 db = pParse.db; - if (db.temp_store == ts) - return SQLITE_OK; - if (invalidateTempStorage(pParse) != SQLITE_OK) { - return SQLITE_ERROR; - } - db.temp_store = (u8)ts; - return SQLITE_OK; - } + /* +** If the TEMP database is open, close it and mark the database schema +** as needing reloading. This must be done when using the SQLITE_TEMP_STORE +** or DEFAULT_TEMP_STORE pragmas. +*/ + static int changeTempStorage( Parse pParse, string zStorageType ) + { + int ts = getTempStore( zStorageType ); + sqlite3 db = pParse.db; + if ( db.temp_store == ts ) + return SQLITE_OK; + if ( invalidateTempStorage( pParse ) != SQLITE_OK ) + { + return SQLITE_ERROR; + } + db.temp_store = (u8)ts; + return SQLITE_OK; + } #endif // * SQLITE_PAGER_PRAGMAS */ - /* - ** Generate code to return a single integer value. - */ - static void returnSingleInt(Parse pParse, string zLabel, i64 value) { - Vdbe v = sqlite3GetVdbe(pParse); - int mem = ++pParse.nMem; - //i64* pI64 = sqlite3DbMallocRaw( pParse->db, sizeof( value ) ); - //if ( pI64 ) - //{ - // memcpy( pI64, &value, sizeof( value ) ); - //} - //sqlite3VdbeAddOp4( v, OP_Int64, 0, mem, 0, (char*)pI64, P4_INT64 ); - sqlite3VdbeAddOp4(v, OP_Int64, 0, mem, 0, value, P4_INT64); - sqlite3VdbeSetNumCols(v, 1); - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLabel, SQLITE_STATIC); - sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1); - } + /* +** Generate code to return a single integer value. +*/ + static void returnSingleInt( Parse pParse, string zLabel, i64 value ) + { + Vdbe v = sqlite3GetVdbe( pParse ); + int mem = ++pParse.nMem; + //i64* pI64 = sqlite3DbMallocRaw( pParse->db, sizeof( value ) ); + //if ( pI64 ) + //{ + // memcpy( pI64, &value, sizeof( value ) ); + //} + //sqlite3VdbeAddOp4( v, OP_Int64, 0, mem, 0, (char*)pI64, P4_INT64 ); + sqlite3VdbeAddOp4( v, OP_Int64, 0, mem, 0, value, P4_INT64 ); + sqlite3VdbeSetNumCols( v, 1 ); + sqlite3VdbeSetColName( v, 0, COLNAME_NAME, zLabel, SQLITE_STATIC ); + sqlite3VdbeAddOp2( v, OP_ResultRow, mem, 1 ); + } #if !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. - */ - struct sPragmaType { - public string zName; /* Name of the pragma */ - public int mask; /* Mask for the db.flags value */ - public sPragmaType(string zName, int mask) { - this.zName = zName; - this.mask = mask; - } - } - static int flagPragma(Parse pParse, string zLeft, string zRight) { - sPragmaType[] aPragma = new sPragmaType[]{ + /* +** 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. +*/ + struct sPragmaType + { + public string zName; /* Name of the pragma */ + public int mask; /* Mask for the db.flags value */ + public sPragmaType( string zName, int mask ) + { + this.zName = zName; + this.mask = mask; + } + } + static int flagPragma( Parse pParse, string zLeft, string zRight ) + { + sPragmaType[] aPragma = new sPragmaType[]{ new sPragmaType( "full_column_names", SQLITE_FullColNames ), new sPragmaType( "short_column_names", SQLITE_ShortColNames ), new sPragmaType( "count_changes", SQLITE_CountRows ), @@ -231,126 +261,140 @@ static int flagPragma(Parse pParse, string zLeft, string zRight) { new sPragmaType( "foreign_keys", SQLITE_ForeignKeys ), #endif }; - int i; - sPragmaType p; - for (i = 0; i < ArraySize(aPragma); i++)//, p++) + int i; + sPragmaType p; + for ( i = 0; i < ArraySize( aPragma ); i++ )//, p++) + { + p = aPragma[i]; + if ( zLeft.Equals( p.zName ,StringComparison.OrdinalIgnoreCase ) ) + { + sqlite3 db = pParse.db; + Vdbe v; + v = sqlite3GetVdbe( pParse ); + Debug.Assert( v != null ); /* Already allocated by sqlite3Pragma() */ + if ( ALWAYS( v ) ) + { + if ( null == zRight ) { - p = aPragma[i]; - if (zLeft.Equals(p.zName, StringComparison.OrdinalIgnoreCase)) { - sqlite3 db = pParse.db; - Vdbe v; - v = sqlite3GetVdbe(pParse); - Debug.Assert(v != null); /* Already allocated by sqlite3Pragma() */ - if (ALWAYS(v)) { - if (null == zRight) { - returnSingleInt(pParse, p.zName, ((db.flags & p.mask) != 0) ? 1 : 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; - } - - /* 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; - } + returnSingleInt( pParse, p.zName, ( ( db.flags & p.mask ) != 0 ) ? 1 : 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; + } + + /* 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 0; + } + + return 1; } + } + return 0; + } #endif // * SQLITE_OMIT_FLAG_PRAGMAS */ - /* - ** Return a human-readable name for a constraint resolution action. - */ + /* +** Return a human-readable name for a constraint resolution action. +*/ #if !SQLITE_OMIT_FOREIGN_KEY - static string actionName(int action) { - string zName; - switch (action) { - case OE_SetNull: - zName = "SET NULL"; - break; - case OE_SetDflt: - zName = "SET DEFAULT"; - break; - case OE_Cascade: - zName = "CASCADE"; - break; - case OE_Restrict: - zName = "RESTRICT"; - break; - default: - zName = "NO ACTION"; - Debug.Assert(action == OE_None); - break; - } - return zName; - } + static string actionName( int action ) + { + string zName; + switch ( action ) + { + case OE_SetNull: + zName = "SET NULL"; + break; + case OE_SetDflt: + zName = "SET DEFAULT"; + break; + case OE_Cascade: + zName = "CASCADE"; + break; + case OE_Restrict: + zName = "RESTRICT"; + break; + default: + zName = "NO ACTION"; + Debug.Assert( action == OE_None ); + break; + } + return zName; + } #endif - /* - ** Parameter eMode must be one of the PAGER_JOURNALMODE_XXX constants - ** defined in pager.h. This function returns the associated lowercase - ** journal-mode name. - */ - static string sqlite3JournalModename(int eMode) { - string[] azModeName = { + /* +** Parameter eMode must be one of the PAGER_JOURNALMODE_XXX constants +** defined in pager.h. This function returns the associated lowercase +** journal-mode name. +*/ + static string sqlite3JournalModename( int eMode ) + { + string[] azModeName = { "delete", "persist", "off", "truncate", "memory" #if !SQLITE_OMIT_WAL , "wal" #endif }; - Debug.Assert(PAGER_JOURNALMODE_DELETE == 0); - Debug.Assert(PAGER_JOURNALMODE_PERSIST == 1); - Debug.Assert(PAGER_JOURNALMODE_OFF == 2); - Debug.Assert(PAGER_JOURNALMODE_TRUNCATE == 3); - Debug.Assert(PAGER_JOURNALMODE_MEMORY == 4); - Debug.Assert(PAGER_JOURNALMODE_WAL == 5); - Debug.Assert(eMode >= 0 && eMode <= ArraySize(azModeName)); - - if (eMode == ArraySize(azModeName)) - return null; - return azModeName[eMode]; - } - - /* - ** Process a pragma statement. - ** - ** Pragmas are of this form: - ** - ** PRAGMA [database.]id [= value] - ** - ** The identifier might also be a string. The value is a string, and - ** identifier, or a number. If minusFlag is true, then the value is - ** a number that was preceded by a minus sign. - ** - ** If the left side is "database.id" then pId1 is the database name - ** and pId2 is the id. If the left side is just "id" then pId1 is the - ** id and pId2 is any empty string. - */ - class EncName { - public string zName; - public u8 enc; + Debug.Assert( PAGER_JOURNALMODE_DELETE == 0 ); + Debug.Assert( PAGER_JOURNALMODE_PERSIST == 1 ); + Debug.Assert( PAGER_JOURNALMODE_OFF == 2 ); + Debug.Assert( PAGER_JOURNALMODE_TRUNCATE == 3 ); + Debug.Assert( PAGER_JOURNALMODE_MEMORY == 4 ); + Debug.Assert( PAGER_JOURNALMODE_WAL == 5 ); + Debug.Assert( eMode >= 0 && eMode <= ArraySize( azModeName ) ); + + if ( eMode == ArraySize( azModeName ) ) + return null; + return azModeName[eMode]; + } - public EncName(string zName, u8 enc) { - this.zName = zName; - this.enc = enc; - } - }; + /* + ** Process a pragma statement. + ** + ** Pragmas are of this form: + ** + ** PRAGMA [database.]id [= value] + ** + ** The identifier might also be a string. The value is a string, and + ** identifier, or a number. If minusFlag is true, then the value is + ** a number that was preceded by a minus sign. + ** + ** If the left side is "database.id" then pId1 is the database name + ** and pId2 is the id. If the left side is just "id" then pId1 is the + ** id and pId2 is any empty string. + */ + class EncName + { + public string zName; + public u8 enc; + + public EncName( string zName, u8 enc ) + { + this.zName = zName; + this.enc = enc; + } + }; - static EncName[] encnames = new EncName[] { + static EncName[] encnames = new EncName[] { new EncName( "UTF8", SQLITE_UTF8 ), new EncName( "UTF-8", SQLITE_UTF8 ),/* Must be element [1] */ new EncName( "UTF-16le (not supported)", SQLITE_UTF16LE ),/* Must be element [2] */ @@ -361,56 +405,62 @@ public EncName(string zName, u8 enc) { new EncName( "UTF16", 0 ), /* SQLITE_UTF16NATIVE */ new EncName( null, 0 ) }; + + // OVERLOADS, so I don't need to rewrite parse.c + static void sqlite3Pragma( Parse pParse, Token pId1, Token pId2, int null_4, int minusFlag ) + { + sqlite3Pragma( pParse, pId1, pId2, null, minusFlag ); + } + static void sqlite3Pragma( + Parse pParse, + Token pId1, /* First part of [database.]id field */ + Token pId2, /* Second part of [database.]id field, or NULL */ + Token pValue, /* Token for , or NULL */ + int minusFlag /* True if a '-' sign preceded */ + ) + { + string zLeft = null; /* Nul-terminated UTF-8 string */ + string zRight = null; /* Nul-terminated UTF-8 string , or NULL */ + string zDb = null; /* The database name */ + Token pId = new Token();/* Pointer to token */ + int iDb; /* Database index for */ + sqlite3 db = pParse.db; + Db pDb; + Vdbe v = pParse.pVdbe = sqlite3VdbeCreate( db ); + if ( v == null ) + return; + sqlite3VdbeRunOnlyOnce( v ); + pParse.nMem = 2; + + /* Interpret the [database.] part of the pragma statement. iDb is the + ** index of the database this pragma is being applied to in db.aDb[]. */ + iDb = sqlite3TwoPartName( pParse, pId1, pId2, ref pId ); + if ( iDb < 0 ) + return; + pDb = db.aDb[iDb]; + + /* If the temp database has been explicitly named as part of the + ** pragma, make sure it is open. + */ + if ( iDb == 1 && sqlite3OpenTempDatabase( pParse ) != 0 ) + { + return; + } - // OVERLOADS, so I don't need to rewrite parse.c - static void sqlite3Pragma(Parse pParse, Token pId1, Token pId2, int null_4, int minusFlag) { - sqlite3Pragma(pParse, pId1, pId2, null, minusFlag); - } - static void sqlite3Pragma( - Parse pParse, - Token pId1, /* First part of [database.]id field */ - Token pId2, /* Second part of [database.]id field, or NULL */ - Token pValue, /* Token for , or NULL */ - int minusFlag /* True if a '-' sign preceded */ - ) { - string zLeft = null; /* Nul-terminated UTF-8 string */ - string zRight = null; /* Nul-terminated UTF-8 string , or NULL */ - string zDb = null; /* The database name */ - Token pId = new Token();/* Pointer to token */ - int iDb; /* Database index for */ - sqlite3 db = pParse.db; - Db pDb; - Vdbe v = pParse.pVdbe = sqlite3VdbeCreate(db); - if (v == null) - return; - sqlite3VdbeRunOnlyOnce(v); - pParse.nMem = 2; - - /* Interpret the [database.] part of the pragma statement. iDb is the - ** index of the database this pragma is being applied to in db.aDb[]. */ - iDb = sqlite3TwoPartName(pParse, pId1, pId2, ref pId); - if (iDb < 0) - return; - pDb = db.aDb[iDb]; - - /* If the temp database has been explicitly named as part of the - ** pragma, make sure it is open. - */ - if (iDb == 1 && sqlite3OpenTempDatabase(pParse) != 0) { - return; - } - - zLeft = sqlite3NameFromToken(db, pId); - if (String.IsNullOrEmpty(zLeft)) - return; - if (minusFlag != 0) { - zRight = (pValue == null) ? "" : sqlite3MPrintf(db, "-%T", pValue); - } else { - zRight = sqlite3NameFromToken(db, pValue); - } + zLeft = sqlite3NameFromToken( db, pId ); + if ( String.IsNullOrEmpty(zLeft)) + return; + if ( minusFlag != 0 ) + { + zRight = ( pValue == null ) ? "" : sqlite3MPrintf( db, "-%T", pValue ); + } + else + { + zRight = sqlite3NameFromToken( db, pValue ); + } - Debug.Assert(pId2 != null); - zDb = pId2.n > 0 ? pDb.zName : null; + Debug.Assert( pId2 != null ); + zDb = pId2.n > 0 ? pDb.zName : null; #if !SQLITE_OMIT_AUTHORIZATION if ( sqlite3AuthCheck( pParse, SQLITE_PRAGMA, zLeft, zRight, zDb ) ) { @@ -418,24 +468,25 @@ static void sqlite3Pragma( } #endif #if !SQLITE_OMIT_PAGER_PRAGMAS - /* - ** PRAGMA [database.]default_cache_size - ** PRAGMA [database.]default_cache_size=N - ** - ** The first form reports the current persistent setting for the - ** page cache size. The value returned is the maximum number of - ** pages in the page cache. The second form sets both the current - ** page cache size value and the persistent page cache size value - ** stored in the database file. - ** - ** Older versions of SQLite would set the default cache size to a - ** 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. - */ - if (zLeft.Equals("default_cache_size", StringComparison.OrdinalIgnoreCase)) { - VdbeOpList[] getCacheSize = new VdbeOpList[]{ + /* +** PRAGMA [database.]default_cache_size +** PRAGMA [database.]default_cache_size=N +** +** The first form reports the current persistent setting for the +** page cache size. The value returned is the maximum number of +** pages in the page cache. The second form sets both the current +** page cache size value and the persistent page cache size value +** stored in the database file. +** +** Older versions of SQLite would set the default cache size to a +** 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. +*/ + if ( zLeft.Equals( "default_cache_size", StringComparison.OrdinalIgnoreCase ) ) + { + VdbeOpList[] getCacheSize = new VdbeOpList[]{ new VdbeOpList( OP_Transaction, 0, 0, 0), /* 0 */ new VdbeOpList( OP_ReadCookie, 0, 1, BTREE_DEFAULT_CACHE_SIZE), /* 1 */ new VdbeOpList( OP_IfPos, 1, 7, 0), @@ -445,283 +496,337 @@ static void sqlite3Pragma( new VdbeOpList( OP_Integer, 0, 1, 0), /* 6 */ new VdbeOpList( OP_ResultRow, 1, 1, 0), }; - int addr; - if (sqlite3ReadSchema(pParse) != 0) - goto pragma_out; - sqlite3VdbeUsesBtree(v, iDb); - if (null == zRight) { - sqlite3VdbeSetNumCols(v, 1); - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "cache_size", SQLITE_STATIC); - pParse.nMem += 2; - addr = sqlite3VdbeAddOpList(v, getCacheSize.Length, getCacheSize); - sqlite3VdbeChangeP1(v, addr, iDb); - sqlite3VdbeChangeP1(v, addr + 1, iDb); - sqlite3VdbeChangeP1(v, addr + 6, SQLITE_DEFAULT_CACHE_SIZE); - } else { - int size = sqlite3AbsInt32(sqlite3Atoi(zRight)); - sqlite3BeginWriteOperation(pParse, 0, iDb); - sqlite3VdbeAddOp2(v, OP_Integer, size, 1); - sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_DEFAULT_CACHE_SIZE, 1); - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); - pDb.pSchema.cache_size = size; - sqlite3BtreeSetCacheSize(pDb.pBt, pDb.pSchema.cache_size); - } - } else + int addr; + if ( sqlite3ReadSchema( pParse ) != 0 ) + goto pragma_out; + sqlite3VdbeUsesBtree( v, iDb ); + if ( null == zRight ) + { + sqlite3VdbeSetNumCols( v, 1 ); + sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "cache_size", SQLITE_STATIC ); + pParse.nMem += 2; + addr = sqlite3VdbeAddOpList( v, getCacheSize.Length, getCacheSize ); + sqlite3VdbeChangeP1( v, addr, iDb ); + sqlite3VdbeChangeP1( v, addr + 1, iDb ); + sqlite3VdbeChangeP1( v, addr + 6, SQLITE_DEFAULT_CACHE_SIZE ); + } + else + { + int size = sqlite3AbsInt32(sqlite3Atoi( zRight )); + sqlite3BeginWriteOperation( pParse, 0, iDb ); + sqlite3VdbeAddOp2( v, OP_Integer, size, 1 ); + sqlite3VdbeAddOp3( v, OP_SetCookie, iDb, BTREE_DEFAULT_CACHE_SIZE, 1 ); + Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); + pDb.pSchema.cache_size = size; + sqlite3BtreeSetCacheSize( pDb.pBt, pDb.pSchema.cache_size ); + } + } + else + + /* + ** PRAGMA [database.]page_size + ** PRAGMA [database.]page_size=N + ** + ** 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. + */ + if ( zLeft.Equals( "page_size", StringComparison.OrdinalIgnoreCase ) ) + { + Btree pBt = pDb.pBt; + Debug.Assert( pBt != null ); + if ( null == zRight ) + { + int size = ALWAYS( pBt ) ? sqlite3BtreeGetPageSize( pBt ) : 0; + returnSingleInt( pParse, "page_size", size ); + } + else + { + /* Malloc may fail when setting the page-size, as there is an internal + ** buffer that the pager module resizes using sqlite3_realloc(). + */ + db.nextPagesize = sqlite3Atoi( zRight ); + if ( SQLITE_NOMEM == sqlite3BtreeSetPageSize( pBt, db.nextPagesize, -1, 0 ) ) + { + //// db.mallocFailed = 1; + } + } + } + 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. + */ + if ( zLeft.Equals( "secure_delete", StringComparison.OrdinalIgnoreCase ) ) + { + Btree pBt = pDb.pBt; + int b = -1; + Debug.Assert( pBt != null ); + if ( zRight != null ) + { + b = sqlite3GetBoolean( zRight ); + } + if ( pId2.n == 0 && b >= 0 ) + { + int ii; + for ( ii = 0; ii < db.nDb; ii++ ) + { + sqlite3BtreeSecureDelete( db.aDb[ii].pBt, b ); + } + } + b = sqlite3BtreeSecureDelete( pBt, b ); + returnSingleInt( pParse, "secure_delete", b ); + } + else + /* + ** PRAGMA [database.]max_page_count + ** PRAGMA [database.]max_page_count=N + ** + ** The first form reports the current setting for the + ** maximum number of pages in the database file. The + ** second form attempts to change this setting. Both + ** forms return the current setting. + ** + ** PRAGMA [database.]page_count + ** + ** Return the number of pages in the specified database. + */ + if ( zLeft.Equals( "page_count", StringComparison.OrdinalIgnoreCase ) + || zLeft.Equals( "max_page_count", StringComparison.OrdinalIgnoreCase ) + ) + { + int iReg; + if ( sqlite3ReadSchema( pParse ) != 0 ) + goto pragma_out; + sqlite3CodeVerifySchema( pParse, iDb ); + iReg = ++pParse.nMem; + if ( zLeft[0] == 'p' ) + { + sqlite3VdbeAddOp2( v, OP_Pagecount, iDb, iReg ); + } + else + { + sqlite3VdbeAddOp3( v, OP_MaxPgcnt, iDb, iReg, sqlite3Atoi( zRight ) ); + } + sqlite3VdbeAddOp2( v, OP_ResultRow, iReg, 1 ); + sqlite3VdbeSetNumCols( v, 1 ); + sqlite3VdbeSetColName( v, 0, COLNAME_NAME, zLeft, SQLITE_TRANSIENT ); + } + else /* - ** PRAGMA [database.]page_size - ** PRAGMA [database.]page_size=N + ** PRAGMA [database.]page_count ** - ** 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. + ** Return the number of pages in the specified database. */ - if (zLeft.Equals("page_size", StringComparison.OrdinalIgnoreCase)) { - Btree pBt = pDb.pBt; - Debug.Assert(pBt != null); - if (null == zRight) { - int size = ALWAYS(pBt) ? sqlite3BtreeGetPageSize(pBt) : 0; - returnSingleInt(pParse, "page_size", size); - } else { - /* Malloc may fail when setting the page-size, as there is an internal - ** buffer that the pager module resizes using sqlite3_realloc(). - */ - db.nextPagesize = sqlite3Atoi(zRight); - if (SQLITE_NOMEM == sqlite3BtreeSetPageSize(pBt, db.nextPagesize, -1, 0)) { - //// db.mallocFailed = 1; - } - } - } 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. - */ - if (zLeft.Equals("secure_delete", StringComparison.OrdinalIgnoreCase)) { - Btree pBt = pDb.pBt; - int b = -1; - Debug.Assert(pBt != null); - if (zRight != null) { - b = sqlite3GetBoolean(zRight); - } - if (pId2.n == 0 && b >= 0) { - int ii; - for (ii = 0; ii < db.nDb; ii++) { - sqlite3BtreeSecureDelete(db.aDb[ii].pBt, b); - } - } - b = sqlite3BtreeSecureDelete(pBt, b); - returnSingleInt(pParse, "secure_delete", b); - } else - /* - ** PRAGMA [database.]max_page_count - ** PRAGMA [database.]max_page_count=N - ** - ** The first form reports the current setting for the - ** maximum number of pages in the database file. The - ** second form attempts to change this setting. Both - ** forms return the current setting. - ** - ** PRAGMA [database.]page_count - ** - ** Return the number of pages in the specified database. - */ - if (zLeft.Equals("page_count", StringComparison.OrdinalIgnoreCase) - || zLeft.Equals("max_page_count", StringComparison.OrdinalIgnoreCase) - ) { - int iReg; - if (sqlite3ReadSchema(pParse) != 0) - goto pragma_out; - sqlite3CodeVerifySchema(pParse, iDb); - iReg = ++pParse.nMem; - if (zLeft[0] == 'p') { - sqlite3VdbeAddOp2(v, OP_Pagecount, iDb, iReg); - } else { - sqlite3VdbeAddOp3(v, OP_MaxPgcnt, iDb, iReg, sqlite3Atoi(zRight)); - } - sqlite3VdbeAddOp2(v, OP_ResultRow, iReg, 1); - sqlite3VdbeSetNumCols(v, 1); - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLeft, SQLITE_TRANSIENT); - } else - - /* - ** PRAGMA [database.]page_count - ** - ** Return the number of pages in the specified database. - */ - if (zLeft.Equals("page_count", StringComparison.OrdinalIgnoreCase)) { + if ( zLeft.Equals( "page_count", StringComparison.OrdinalIgnoreCase ) ) + { Vdbe _v; int iReg; - _v = sqlite3GetVdbe(pParse); - if (_v == null || sqlite3ReadSchema(pParse) != 0) - goto pragma_out; - sqlite3CodeVerifySchema(pParse, iDb); + _v = sqlite3GetVdbe( pParse ); + if ( _v == null || sqlite3ReadSchema( pParse ) != 0 ) + goto pragma_out; + sqlite3CodeVerifySchema( pParse, iDb ); iReg = ++pParse.nMem; - sqlite3VdbeAddOp2(_v, OP_Pagecount, iDb, iReg); - sqlite3VdbeAddOp2(_v, OP_ResultRow, iReg, 1); - sqlite3VdbeSetNumCols(_v, 1); - sqlite3VdbeSetColName(_v, 0, COLNAME_NAME, "page_count", SQLITE_STATIC); - } else + sqlite3VdbeAddOp2( _v, OP_Pagecount, iDb, iReg ); + sqlite3VdbeAddOp2( _v, OP_ResultRow, iReg, 1 ); + sqlite3VdbeSetNumCols( _v, 1 ); + sqlite3VdbeSetColName( _v, 0, COLNAME_NAME, "page_count", SQLITE_STATIC ); + } + else - /* - ** PRAGMA [database.]locking_mode - ** PRAGMA [database.]locking_mode = (normal|exclusive) - */ - if (zLeft.Equals("locking_mode", StringComparison.OrdinalIgnoreCase)) { - string zRet = "normal"; - int eMode = getLockingMode(zRight); + /* + ** PRAGMA [database.]locking_mode + ** PRAGMA [database.]locking_mode = (normal|exclusive) + */ + if ( zLeft.Equals( "locking_mode", StringComparison.OrdinalIgnoreCase ) ) + { + string zRet = "normal"; + int eMode = getLockingMode( zRight ); - if (pId2.n == 0 && eMode == PAGER_LOCKINGMODE_QUERY) { + if ( pId2.n == 0 && eMode == PAGER_LOCKINGMODE_QUERY ) + { /* Simple "PRAGMA locking_mode;" statement. This is a query for ** the current default locking mode (which may be different to ** the locking-mode of the main database). */ eMode = db.dfltLockMode; - } else { + } + else + { Pager pPager; - if (pId2.n == 0) { - /* This indicates that no database name was specified as part - ** of the PRAGMA command. In this case the locking-mode must be - ** set on all attached databases, as well as the main db file. - ** - ** Also, the sqlite3.dfltLockMode variable is set so that - ** any subsequently attached databases also use the specified - ** locking mode. - */ - int ii; - Debug.Assert(pDb == db.aDb[0]); - for (ii = 2; ii < db.nDb; ii++) { - pPager = sqlite3BtreePager(db.aDb[ii].pBt); - sqlite3PagerLockingMode(pPager, eMode); - } - db.dfltLockMode = (u8)eMode; + if ( pId2.n == 0 ) + { + /* This indicates that no database name was specified as part + ** of the PRAGMA command. In this case the locking-mode must be + ** set on all attached databases, as well as the main db file. + ** + ** Also, the sqlite3.dfltLockMode variable is set so that + ** any subsequently attached databases also use the specified + ** locking mode. + */ + int ii; + Debug.Assert( pDb == db.aDb[0] ); + for ( ii = 2; ii < db.nDb; ii++ ) + { + pPager = sqlite3BtreePager( db.aDb[ii].pBt ); + sqlite3PagerLockingMode( pPager, eMode ); + } + db.dfltLockMode = (u8)eMode; } - pPager = sqlite3BtreePager(pDb.pBt); - eMode = sqlite3PagerLockingMode(pPager, eMode) ? 1 : 0; - } + pPager = sqlite3BtreePager( pDb.pBt ); + eMode = sqlite3PagerLockingMode( pPager, eMode ) ? 1 : 0; + } - Debug.Assert(eMode == PAGER_LOCKINGMODE_NORMAL || eMode == PAGER_LOCKINGMODE_EXCLUSIVE); - if (eMode == PAGER_LOCKINGMODE_EXCLUSIVE) { + Debug.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 ); } - 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); - } else - /* - ** PRAGMA [database.]journal_mode - ** PRAGMA [database.]journal_mode = - ** (delete|persist|off|truncate|memory|wal|off) - */ - if (zLeft.Equals("journal_mode", StringComparison.OrdinalIgnoreCase)) { - int eMode; /* One of the PAGER_JOURNALMODE_XXX symbols */ - int ii; /* Loop counter */ - - /* Force the schema to be loaded on all databases. This cases all - ** database files to be opened and the journal_modes set. */ - if (sqlite3ReadSchema(pParse) != 0) { - goto pragma_out; - } + else + /* + ** PRAGMA [database.]journal_mode + ** PRAGMA [database.]journal_mode = + ** (delete|persist|off|truncate|memory|wal|off) + */ + if ( zLeft.Equals("journal_mode", StringComparison.OrdinalIgnoreCase ) ) + { + int eMode; /* One of the PAGER_JOURNALMODE_XXX symbols */ + int ii; /* Loop counter */ + + /* Force the schema to be loaded on all databases. This cases all + ** database files to be opened and the journal_modes set. */ + if ( sqlite3ReadSchema( pParse ) != 0 ) + { + goto pragma_out; + } - sqlite3VdbeSetNumCols(v, 1); - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "journal_mode", SQLITE_STATIC); - if (null == zRight) { - /* If there is no "=MODE" part of the pragma, do a query for the - ** current mode */ - eMode = PAGER_JOURNALMODE_QUERY; - } else { - string zMode; - int n = sqlite3Strlen30(zRight); - for (eMode = 0; (zMode = sqlite3JournalModename(eMode)) != null; eMode++) { - if (sqlite3StrNICmp(zRight, zMode, n) == 0) - break; + sqlite3VdbeSetNumCols( v, 1 ); + sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "journal_mode", SQLITE_STATIC ); + if ( null == zRight ) + { + /* If there is no "=MODE" part of the pragma, do a query for the + ** current mode */ + eMode = PAGER_JOURNALMODE_QUERY; } - if (null == zMode) { + else + { + string zMode; + int n = sqlite3Strlen30( zRight ); + for ( eMode = 0; ( zMode = sqlite3JournalModename( eMode ) ) != null; eMode++ ) + { + if ( sqlite3StrNICmp( zRight, zMode, n ) == 0 ) + break; + } + if ( null == zMode ) + { /* If the "=MODE" part does not match any known journal mode, ** then do a query */ eMode = PAGER_JOURNALMODE_QUERY; + } } - } - if (eMode == PAGER_JOURNALMODE_QUERY && pId2.n == 0) { - /* Convert "PRAGMA journal_mode" into "PRAGMA main.journal_mode" */ - iDb = 0; - pId2.n = 1; - } - for (ii = db.nDb - 1; ii >= 0; ii--) { - if (db.aDb[ii].pBt != null && (ii == iDb || pId2.n == 0)) { - sqlite3VdbeUsesBtree(v, ii); - sqlite3VdbeAddOp3(v, OP_JournalMode, ii, 1, eMode); + if ( eMode == PAGER_JOURNALMODE_QUERY && pId2.n == 0 ) + { + /* Convert "PRAGMA journal_mode" into "PRAGMA main.journal_mode" */ + iDb = 0; + pId2.n = 1; } - } - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); - } else + for ( ii = db.nDb - 1; ii >= 0; ii-- ) + { + if ( db.aDb[ii].pBt != null && ( ii == iDb || pId2.n == 0 ) ) + { + sqlite3VdbeUsesBtree( v, ii ); + sqlite3VdbeAddOp3( v, OP_JournalMode, ii, 1, eMode ); + } + } + sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 1 ); + } + else - /* - ** PRAGMA [database.]journal_size_limit - ** PRAGMA [database.]journal_size_limit=N - ** - ** Get or set the size limit on rollback journal files. - */ - if (zLeft.Equals("journal_size_limit", StringComparison.OrdinalIgnoreCase)) { - Pager pPager = sqlite3BtreePager(pDb.pBt); - i64 iLimit = -2; - if (!String.IsNullOrEmpty(zRight)) { - sqlite3Atoi64(zRight, ref iLimit, 1000000, SQLITE_UTF8); - if (iLimit < -1) - iLimit = -1; - } - iLimit = sqlite3PagerJournalSizeLimit(pPager, iLimit); - returnSingleInt(pParse, "journal_size_limit", iLimit); - } else + /* + ** PRAGMA [database.]journal_size_limit + ** PRAGMA [database.]journal_size_limit=N + ** + ** Get or set the size limit on rollback journal files. + */ + if ( zLeft.Equals( "journal_size_limit", StringComparison.OrdinalIgnoreCase ) ) + { + Pager pPager = sqlite3BtreePager( pDb.pBt ); + i64 iLimit = -2; + if ( !String.IsNullOrEmpty( zRight ) ) + { + sqlite3Atoi64( zRight, ref iLimit, 1000000, SQLITE_UTF8 ); + if ( iLimit < -1 ) + iLimit = -1; + } + iLimit = sqlite3PagerJournalSizeLimit( pPager, iLimit ); + returnSingleInt( pParse, "journal_size_limit", iLimit ); + } + else #endif // * SQLITE_OMIT_PAGER_PRAGMAS */ - /* - ** PRAGMA [database.]auto_vacuum - ** PRAGMA [database.]auto_vacuum=N - ** - ** Get or set the value of the database 'auto-vacuum' parameter. - ** The value is one of: 0 NONE 1 FULL 2 INCREMENTAL - */ + /* +** PRAGMA [database.]auto_vacuum +** PRAGMA [database.]auto_vacuum=N +** +** Get or set the value of the database 'auto-vacuum' parameter. +** The value is one of: 0 NONE 1 FULL 2 INCREMENTAL +*/ #if !SQLITE_OMIT_AUTOVACUUM - if (zLeft.Equals("auto_vacuum", StringComparison.OrdinalIgnoreCase)) { - Btree pBt = pDb.pBt; - Debug.Assert(pBt != null); - if (sqlite3ReadSchema(pParse) != 0) { - goto pragma_out; - } - if (null == zRight) { - 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); - Debug.Assert(eAuto >= 0 && eAuto <= 2); - db.nextAutovac = (u8)eAuto; - 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. - */ - int 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. + if ( zLeft.Equals( "auto_vacuum", StringComparison.OrdinalIgnoreCase ) ) + { + Btree pBt = pDb.pBt; + Debug.Assert( pBt != null ); + if ( sqlite3ReadSchema( pParse ) != 0 ) + { + goto pragma_out; + } + if ( null == zRight ) + { + 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 ); + Debug.Assert( eAuto >= 0 && eAuto <= 2 ); + db.nextAutovac = (u8)eAuto; + 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. */ - VdbeOpList[] setMeta6 = new VdbeOpList[] { + int 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. + */ + VdbeOpList[] setMeta6 = new VdbeOpList[] { new VdbeOpList( OP_Transaction, 0, 1, 0), /* 0 */ new VdbeOpList( OP_ReadCookie, 0, 1, BTREE_LARGEST_ROOT_PAGE), /* 1 */ new VdbeOpList( OP_If, 1, 0, 0), /* 2 */ @@ -729,143 +834,170 @@ static void sqlite3Pragma( new VdbeOpList( OP_Integer, 0, 1, 0), /* 4 */ new VdbeOpList( 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); + 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 + } + else #endif - /* - ** PRAGMA [database.]incremental_vacuum(N) - ** - ** Do N steps of incremental vacuuming on a database. - */ + /* +** PRAGMA [database.]incremental_vacuum(N) +** +** Do N steps of incremental vacuuming on a database. +*/ #if !SQLITE_OMIT_AUTOVACUUM - if (zLeft.Equals("incremental_vacuum", StringComparison.OrdinalIgnoreCase)) { - int iLimit = 0, addr; - if (sqlite3ReadSchema(pParse) != 0) { - goto pragma_out; - } - if (zRight == null || !sqlite3GetInt32(zRight, ref iLimit) || iLimit <= 0) { - iLimit = 0x7fffffff; - } - sqlite3BeginWriteOperation(pParse, 0, iDb); - sqlite3VdbeAddOp2(v, OP_Integer, iLimit, 1); - 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); - } else + if ( zLeft.Equals( "incremental_vacuum", StringComparison.OrdinalIgnoreCase ) ) + { + int iLimit = 0, addr; + if ( sqlite3ReadSchema( pParse ) != 0 ) + { + goto pragma_out; + } + if ( zRight == null || !sqlite3GetInt32( zRight, ref iLimit ) || iLimit <= 0 ) + { + iLimit = 0x7fffffff; + } + sqlite3BeginWriteOperation( pParse, 0, iDb ); + sqlite3VdbeAddOp2( v, OP_Integer, iLimit, 1 ); + 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 ); + } + else #endif #if !SQLITE_OMIT_PAGER_PRAGMAS - /* - ** PRAGMA [database.]cache_size - ** PRAGMA [database.]cache_size=N - ** - ** The first form reports the current local setting for the - ** page cache size. The local setting can be different from - ** the persistent cache size value that is stored in the database - ** file itself. The value returned is the maximum number of - ** pages in the page cache. The second form sets the local - ** page cache size value. It does not change the persistent - ** cache size stored on the disk so the cache size will revert - ** to its default value when the database is closed and reopened. - ** N should be a positive integer. - */ - if (zLeft.Equals("cache_size", StringComparison.OrdinalIgnoreCase)) { - if (sqlite3ReadSchema(pParse) != 0) - goto pragma_out; - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); - if (null == zRight) { - returnSingleInt(pParse, "cache_size", pDb.pSchema.cache_size); - } else { - int size = sqlite3AbsInt32(sqlite3Atoi(zRight)); - pDb.pSchema.cache_size = size; - sqlite3BtreeSetCacheSize(pDb.pBt, pDb.pSchema.cache_size); - } - } else - - /* - ** PRAGMA temp_store - ** PRAGMA temp_store = "default"|"memory"|"file" - ** - ** Return or set the local value of the temp_store 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. - ** - ** Note that it is possible for the library compile-time options to - ** override this setting - */ - if (zLeft.Equals("temp_store", StringComparison.OrdinalIgnoreCase)) { - if (zRight == null) { - returnSingleInt(pParse, "temp_store", db.temp_store); - } else { - changeTempStorage(pParse, zRight); - } - } else + /* +** PRAGMA [database.]cache_size +** PRAGMA [database.]cache_size=N +** +** The first form reports the current local setting for the +** page cache size. The local setting can be different from +** the persistent cache size value that is stored in the database +** file itself. The value returned is the maximum number of +** pages in the page cache. The second form sets the local +** page cache size value. It does not change the persistent +** cache size stored on the disk so the cache size will revert +** to its default value when the database is closed and reopened. +** N should be a positive integer. +*/ + if ( zLeft.Equals( "cache_size", StringComparison.OrdinalIgnoreCase ) ) + { + if ( sqlite3ReadSchema( pParse ) != 0 ) + goto pragma_out; + Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); + if ( null == zRight ) + { + returnSingleInt( pParse, "cache_size", pDb.pSchema.cache_size ); + } + else + { + int size = sqlite3AbsInt32(sqlite3Atoi( zRight )); + pDb.pSchema.cache_size = size; + sqlite3BtreeSetCacheSize( pDb.pBt, pDb.pSchema.cache_size ); + } + } + else - /* - ** PRAGMA temp_store_directory - ** PRAGMA temp_store_directory = ""|"directory_name" - ** - ** Return or set the local value of the temp_store_directory flag. Changing - ** 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. - ** - */ - if (zLeft.Equals("temp_store_directory", StringComparison.OrdinalIgnoreCase)) { - if (null == zRight) { - if (sqlite3_temp_directory != "") { - sqlite3VdbeSetNumCols(v, 1); - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, - "temp_store_directory", SQLITE_STATIC); - sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, sqlite3_temp_directory, 0); - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); - } - } else { + /* + ** PRAGMA temp_store + ** PRAGMA temp_store = "default"|"memory"|"file" + ** + ** Return or set the local value of the temp_store 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. + ** + ** Note that it is possible for the library compile-time options to + ** override this setting + */ + if ( zLeft.Equals( "temp_store", StringComparison.OrdinalIgnoreCase ) ) + { + if ( zRight == null ) + { + returnSingleInt( pParse, "temp_store", db.temp_store ); + } + else + { + changeTempStorage( pParse, zRight ); + } + } + else + + /* + ** PRAGMA temp_store_directory + ** PRAGMA temp_store_directory = ""|"directory_name" + ** + ** Return or set the local value of the temp_store_directory flag. Changing + ** 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. + ** + */ + if ( zLeft.Equals( "temp_store_directory", StringComparison.OrdinalIgnoreCase ) ) + { + if ( null == zRight ) + { + if ( sqlite3_temp_directory != "" ) + { + sqlite3VdbeSetNumCols( v, 1 ); + sqlite3VdbeSetColName( v, 0, COLNAME_NAME, + "temp_store_directory", SQLITE_STATIC ); + sqlite3VdbeAddOp4( v, OP_String8, 0, 1, 0, sqlite3_temp_directory, 0 ); + sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 1 ); + } + } + else + { #if !SQLITE_OMIT_WSD - if (zRight.Length > 0) { - int rc; - int res = 0; - rc = sqlite3OsAccess(db.pVfs, zRight, SQLITE_ACCESS_READWRITE, ref res); - if (rc != SQLITE_OK || res == 0) { - sqlite3ErrorMsg(pParse, "not a writable directory"); - goto pragma_out; - } - } - if (SQLITE_TEMP_STORE == 0 - || (SQLITE_TEMP_STORE == 1 && db.temp_store <= 1) - || (SQLITE_TEMP_STORE == 2 && db.temp_store == 1) - ) { - invalidateTempStorage(pParse); - } - //sqlite3_free( ref sqlite3_temp_directory ); - if (zRight.Length > 0) { - sqlite3_temp_directory = zRight;//sqlite3_mprintf("%s", zRight); - } else { - sqlite3_temp_directory = ""; - } + if ( zRight.Length > 0 ) + { + int rc; + int res = 0; + rc = sqlite3OsAccess( db.pVfs, zRight, SQLITE_ACCESS_READWRITE, ref res ); + if ( rc != SQLITE_OK || res == 0 ) + { + sqlite3ErrorMsg( pParse, "not a writable directory" ); + goto pragma_out; + } + } + if ( SQLITE_TEMP_STORE == 0 + || ( SQLITE_TEMP_STORE == 1 && db.temp_store <= 1 ) + || ( SQLITE_TEMP_STORE == 2 && db.temp_store == 1 ) + ) + { + invalidateTempStorage( pParse ); + } + //sqlite3_free( ref sqlite3_temp_directory ); + if ( zRight.Length > 0 ) + { + sqlite3_temp_directory = zRight;//sqlite3_mprintf("%s", zRight); + } + else + { + sqlite3_temp_directory = ""; + } #endif //* SQLITE_OMIT_WSD */ - } - } else + } + } + else #if !(SQLITE_ENABLE_LOCKING_STYLE) -#if (__APPLE__) +# if (__APPLE__) //# define SQLITE_ENABLE_LOCKING_STYLE 1 -#else - //# define SQLITE_ENABLE_LOCKING_STYLE 0 -#endif +# else + //# define SQLITE_ENABLE_LOCKING_STYLE 0 +# endif #endif #if SQLITE_ENABLE_LOCKING_STYLE /* @@ -922,366 +1054,421 @@ static void sqlite3Pragma( else #endif //* SQLITE_ENABLE_LOCKING_STYLE */ - /* - ** PRAGMA [database.]synchronous - ** PRAGMA [database.]synchronous=OFF|ON|NORMAL|FULL - ** - ** 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. - */ - if (zLeft.Equals("synchronous", StringComparison.OrdinalIgnoreCase)) { - if (sqlite3ReadSchema(pParse) != 0) - goto pragma_out; - if (null == zRight) { - returnSingleInt(pParse, "synchronous", pDb.safety_level - 1); - } else { - if (0 == db.autoCommit) { - sqlite3ErrorMsg(pParse, - "Safety level may not be changed inside a transaction"); - } else { - pDb.safety_level = (byte)(getSafetyLevel(zRight) + 1); - } - } - } else + /* +** PRAGMA [database.]synchronous +** PRAGMA [database.]synchronous=OFF|ON|NORMAL|FULL +** +** 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. +*/ + if ( zLeft.Equals( "synchronous", StringComparison.OrdinalIgnoreCase ) ) + { + if ( sqlite3ReadSchema( pParse ) != 0 ) + goto pragma_out; + if ( null == zRight ) + { + returnSingleInt( pParse, "synchronous", pDb.safety_level - 1 ); + } + else + { + if ( 0 == db.autoCommit ) + { + sqlite3ErrorMsg( pParse, + "Safety level may not be changed inside a transaction" ); + } + else + { + pDb.safety_level = (byte)( getSafetyLevel( zRight ) + 1 ); + } + } + } + else #endif // * SQLITE_OMIT_PAGER_PRAGMAS */ #if !SQLITE_OMIT_FLAG_PRAGMAS - if (flagPragma(pParse, zLeft, zRight) != 0) { - /* The flagPragma() subroutine also generates any necessary code - ** there is nothing more to do here */ - } else + if ( flagPragma( pParse, zLeft, zRight ) != 0 ) + { + /* The flagPragma() subroutine also generates any necessary code + ** there is nothing more to do here */ + } + else #endif // * SQLITE_OMIT_FLAG_PRAGMAS */ #if !SQLITE_OMIT_SCHEMA_PRAGMAS - /* - ** PRAGMA table_info(
) - ** - ** Return a single row for each column of the named table. The columns of - ** the returned data set are: - ** - ** cid: Column id (numbered from left to right, starting at 0) - ** 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. - */ - if (zLeft.Equals("table_info", StringComparison.OrdinalIgnoreCase) && zRight != null) { - Table pTab; - if (sqlite3ReadSchema(pParse) != 0) - goto pragma_out; - pTab = sqlite3FindTable(db, zRight, zDb); - if (pTab != null) { - int i; - int nHidden = 0; - Column pCol; - sqlite3VdbeSetNumCols(v, 6); - pParse.nMem = 6; - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "cid", SQLITE_STATIC); - sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC); - sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "type", SQLITE_STATIC); - sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "notnull", SQLITE_STATIC); - sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "dflt_value", SQLITE_STATIC); - sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "pk", SQLITE_STATIC); - sqlite3ViewGetColumnNames(pParse, pTab); - for (i = 0; i < pTab.nCol; i++)//, pCol++) - { - pCol = pTab.aCol[i]; - if (IsHiddenColumn(pCol)) { - nHidden++; - continue; - } - sqlite3VdbeAddOp2(v, OP_Integer, i - nHidden, 1); - sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pCol.zName, 0); - sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, - pCol.zType != null ? pCol.zType : "", 0); - sqlite3VdbeAddOp2(v, OP_Integer, (pCol.notNull != 0 ? 1 : 0), 4); - if (pCol.zDflt != null) { - sqlite3VdbeAddOp4(v, OP_String8, 0, 5, 0, pCol.zDflt, 0); - } else { - sqlite3VdbeAddOp2(v, OP_Null, 0, 5); - } - sqlite3VdbeAddOp2(v, OP_Integer, pCol.isPrimKey != 0 ? 1 : 0, 6); - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6); - } - } - } else - - if (zLeft.Equals("index_info", StringComparison.OrdinalIgnoreCase) && zRight != null) { - Index pIdx; - Table pTab; - if (sqlite3ReadSchema(pParse) != 0) - goto pragma_out; - pIdx = sqlite3FindIndex(db, zRight, zDb); - if (pIdx != null) { - int i; - pTab = pIdx.pTable; - sqlite3VdbeSetNumCols(v, 3); - pParse.nMem = 3; - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seqno", SQLITE_STATIC); - sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "cid", SQLITE_STATIC); - sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "name", SQLITE_STATIC); - for (i = 0; i < pIdx.nColumn; i++) { - int cnum = pIdx.aiColumn[i]; - sqlite3VdbeAddOp2(v, OP_Integer, i, 1); - sqlite3VdbeAddOp2(v, OP_Integer, cnum, 2); - Debug.Assert(pTab.nCol > cnum); - sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pTab.aCol[cnum].zName, 0); - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3); - } - } - } else - - if (zLeft.Equals("index_list", StringComparison.OrdinalIgnoreCase) && zRight != null) { - Index pIdx; - Table pTab; - if (sqlite3ReadSchema(pParse) != 0) - goto pragma_out; - pTab = sqlite3FindTable(db, zRight, zDb); - if (pTab != null) { - v = sqlite3GetVdbe(pParse); - pIdx = pTab.pIndex; - if (pIdx != null) { - int i = 0; - 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, "unique", SQLITE_STATIC); - while (pIdx != null) { - sqlite3VdbeAddOp2(v, OP_Integer, i, 1); - sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx.zName, 0); - sqlite3VdbeAddOp2(v, OP_Integer, (pIdx.onError != OE_None) ? 1 : 0, 3); - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3); - ++i; - pIdx = pIdx.pNext; - } - } - } - } else - - if (zLeft.Equals("database_list", StringComparison.OrdinalIgnoreCase)) { - int i; - if (sqlite3ReadSchema(pParse) != 0) - 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); - for (i = 0; i < db.nDb; i++) { - if (db.aDb[i].pBt == null) - continue; - Debug.Assert(db.aDb[i].zName != null); - sqlite3VdbeAddOp2(v, OP_Integer, i, 1); - 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); - } - } else - - if (zLeft.Equals("collation_list", StringComparison.OrdinalIgnoreCase)) { - int i = 0; - HashElem p; - sqlite3VdbeSetNumCols(v, 2); - pParse.nMem = 2; - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC); - sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC); - for (p = db.aCollSeq.first; p != null; p = p.next)//( p = sqliteHashFirst( db.aCollSeq ) ; p; p = sqliteHashNext( p ) ) - { - CollSeq pColl = ((CollSeq[])p.data)[0];// sqliteHashData( p ); - sqlite3VdbeAddOp2(v, OP_Integer, i++, 1); - sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pColl.zName, 0); - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2); - } - } else + /* +** PRAGMA table_info(
) +** +** Return a single row for each column of the named table. The columns of +** the returned data set are: +** +** cid: Column id (numbered from left to right, starting at 0) +** 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. +*/ + if ( zLeft.Equals( "table_info", StringComparison.OrdinalIgnoreCase ) && zRight != null ) + { + Table pTab; + if ( sqlite3ReadSchema( pParse ) != 0 ) + goto pragma_out; + pTab = sqlite3FindTable( db, zRight, zDb ); + if ( pTab != null ) + { + int i; + int nHidden = 0; + Column pCol; + sqlite3VdbeSetNumCols( v, 6 ); + pParse.nMem = 6; + sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "cid", SQLITE_STATIC ); + sqlite3VdbeSetColName( v, 1, COLNAME_NAME, "name", SQLITE_STATIC ); + sqlite3VdbeSetColName( v, 2, COLNAME_NAME, "type", SQLITE_STATIC ); + sqlite3VdbeSetColName( v, 3, COLNAME_NAME, "notnull", SQLITE_STATIC ); + sqlite3VdbeSetColName( v, 4, COLNAME_NAME, "dflt_value", SQLITE_STATIC ); + sqlite3VdbeSetColName( v, 5, COLNAME_NAME, "pk", SQLITE_STATIC ); + sqlite3ViewGetColumnNames( pParse, pTab ); + for ( i = 0; i < pTab.nCol; i++ )//, pCol++) + { + pCol = pTab.aCol[i]; + if ( IsHiddenColumn( pCol ) ) + { + nHidden++; + continue; + } + sqlite3VdbeAddOp2( v, OP_Integer, i - nHidden, 1 ); + sqlite3VdbeAddOp4( v, OP_String8, 0, 2, 0, pCol.zName, 0 ); + sqlite3VdbeAddOp4( v, OP_String8, 0, 3, 0, + pCol.zType != null ? pCol.zType : "", 0 ); + sqlite3VdbeAddOp2( v, OP_Integer, ( pCol.notNull != 0 ? 1 : 0 ), 4 ); + if ( pCol.zDflt != null ) + { + sqlite3VdbeAddOp4( v, OP_String8, 0, 5, 0, pCol.zDflt, 0 ); + } + else + { + sqlite3VdbeAddOp2( v, OP_Null, 0, 5 ); + } + sqlite3VdbeAddOp2( v, OP_Integer, pCol.isPrimKey != 0 ? 1 : 0, 6 ); + sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 6 ); + } + } + } + else + + if ( zLeft.Equals( "index_info", StringComparison.OrdinalIgnoreCase ) && zRight != null ) + { + Index pIdx; + Table pTab; + if ( sqlite3ReadSchema( pParse ) != 0 ) + goto pragma_out; + pIdx = sqlite3FindIndex( db, zRight, zDb ); + if ( pIdx != null ) + { + int i; + pTab = pIdx.pTable; + sqlite3VdbeSetNumCols( v, 3 ); + pParse.nMem = 3; + sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "seqno", SQLITE_STATIC ); + sqlite3VdbeSetColName( v, 1, COLNAME_NAME, "cid", SQLITE_STATIC ); + sqlite3VdbeSetColName( v, 2, COLNAME_NAME, "name", SQLITE_STATIC ); + for ( i = 0; i < pIdx.nColumn; i++ ) + { + int cnum = pIdx.aiColumn[i]; + sqlite3VdbeAddOp2( v, OP_Integer, i, 1 ); + sqlite3VdbeAddOp2( v, OP_Integer, cnum, 2 ); + Debug.Assert( pTab.nCol > cnum ); + sqlite3VdbeAddOp4( v, OP_String8, 0, 3, 0, pTab.aCol[cnum].zName, 0 ); + sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 3 ); + } + } + } + else + + if ( zLeft.Equals( "index_list", StringComparison.OrdinalIgnoreCase ) && zRight != null ) + { + Index pIdx; + Table pTab; + if ( sqlite3ReadSchema( pParse ) != 0 ) + goto pragma_out; + pTab = sqlite3FindTable( db, zRight, zDb ); + if ( pTab != null ) + { + v = sqlite3GetVdbe( pParse ); + pIdx = pTab.pIndex; + if ( pIdx != null ) + { + int i = 0; + 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, "unique", SQLITE_STATIC ); + while ( pIdx != null ) + { + sqlite3VdbeAddOp2( v, OP_Integer, i, 1 ); + sqlite3VdbeAddOp4( v, OP_String8, 0, 2, 0, pIdx.zName, 0 ); + sqlite3VdbeAddOp2( v, OP_Integer, ( pIdx.onError != OE_None ) ? 1 : 0, 3 ); + sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 3 ); + ++i; + pIdx = pIdx.pNext; + } + } + } + } + else + + if ( zLeft.Equals( "database_list", StringComparison.OrdinalIgnoreCase ) ) + { + int i; + if ( sqlite3ReadSchema( pParse ) != 0 ) + 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 ); + for ( i = 0; i < db.nDb; i++ ) + { + if ( db.aDb[i].pBt == null ) + continue; + Debug.Assert( db.aDb[i].zName != null ); + sqlite3VdbeAddOp2( v, OP_Integer, i, 1 ); + 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 ); + } + } + else + + if ( zLeft.Equals( "collation_list", StringComparison.OrdinalIgnoreCase ) ) + { + int i = 0; + HashElem p; + sqlite3VdbeSetNumCols( v, 2 ); + pParse.nMem = 2; + sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "seq", SQLITE_STATIC ); + sqlite3VdbeSetColName( v, 1, COLNAME_NAME, "name", SQLITE_STATIC ); + for ( p = db.aCollSeq.first; p != null; p = p.next )//( p = sqliteHashFirst( db.aCollSeq ) ; p; p = sqliteHashNext( p ) ) + { + CollSeq pColl = ( (CollSeq[])p.data )[0];// sqliteHashData( p ); + sqlite3VdbeAddOp2( v, OP_Integer, i++, 1 ); + sqlite3VdbeAddOp4( v, OP_String8, 0, 2, 0, pColl.zName, 0 ); + sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 2 ); + } + } + else #endif // * SQLITE_OMIT_SCHEMA_PRAGMAS */ #if !SQLITE_OMIT_FOREIGN_KEY - if (zLeft.Equals("foreign_key_list", StringComparison.OrdinalIgnoreCase) && zRight != null) { - FKey pFK; - Table pTab; - if (sqlite3ReadSchema(pParse) != 0) - goto pragma_out; - pTab = sqlite3FindTable(db, zRight, zDb); - if (pTab != null) { - v = sqlite3GetVdbe(pParse); - pFK = pTab.pFKey; - if (pFK != null) { - int i = 0; - sqlite3VdbeSetNumCols(v, 8); - pParse.nMem = 8; - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "id", SQLITE_STATIC); - sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "seq", SQLITE_STATIC); - sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "table", SQLITE_STATIC); - sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "from", SQLITE_STATIC); - sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "to", SQLITE_STATIC); - sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "on_update", SQLITE_STATIC); - sqlite3VdbeSetColName(v, 6, COLNAME_NAME, "on_delete", SQLITE_STATIC); - sqlite3VdbeSetColName(v, 7, COLNAME_NAME, "match", SQLITE_STATIC); - while (pFK != null) { - int j; - for (j = 0; j < pFK.nCol; j++) { - string zCol = pFK.aCol[j].zCol; - string zOnDelete = actionName(pFK.aAction[0]); - string zOnUpdate = actionName(pFK.aAction[1]); - sqlite3VdbeAddOp2(v, OP_Integer, i, 1); - sqlite3VdbeAddOp2(v, OP_Integer, j, 2); - sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pFK.zTo, 0); - sqlite3VdbeAddOp4(v, OP_String8, 0, 4, 0, - pTab.aCol[pFK.aCol[j].iFrom].zName, 0); - sqlite3VdbeAddOp4(v, zCol != null ? OP_String8 : OP_Null, 0, 5, 0, zCol, 0); - sqlite3VdbeAddOp4(v, OP_String8, 0, 6, 0, zOnUpdate, 0); - sqlite3VdbeAddOp4(v, OP_String8, 0, 7, 0, zOnDelete, 0); - sqlite3VdbeAddOp4(v, OP_String8, 0, 8, 0, "NONE", 0); - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 8); - } - ++i; - pFK = pFK.pNextFrom; - } - } - } - } else + if ( zLeft.Equals( "foreign_key_list", StringComparison.OrdinalIgnoreCase ) && zRight != null ) + { + FKey pFK; + Table pTab; + if ( sqlite3ReadSchema( pParse ) != 0 ) + goto pragma_out; + pTab = sqlite3FindTable( db, zRight, zDb ); + if ( pTab != null ) + { + v = sqlite3GetVdbe( pParse ); + pFK = pTab.pFKey; + if ( pFK != null ) + { + int i = 0; + sqlite3VdbeSetNumCols( v, 8 ); + pParse.nMem = 8; + sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "id", SQLITE_STATIC ); + sqlite3VdbeSetColName( v, 1, COLNAME_NAME, "seq", SQLITE_STATIC ); + sqlite3VdbeSetColName( v, 2, COLNAME_NAME, "table", SQLITE_STATIC ); + sqlite3VdbeSetColName( v, 3, COLNAME_NAME, "from", SQLITE_STATIC ); + sqlite3VdbeSetColName( v, 4, COLNAME_NAME, "to", SQLITE_STATIC ); + sqlite3VdbeSetColName( v, 5, COLNAME_NAME, "on_update", SQLITE_STATIC ); + sqlite3VdbeSetColName( v, 6, COLNAME_NAME, "on_delete", SQLITE_STATIC ); + sqlite3VdbeSetColName( v, 7, COLNAME_NAME, "match", SQLITE_STATIC ); + while ( pFK != null ) + { + int j; + for ( j = 0; j < pFK.nCol; j++ ) + { + string zCol = pFK.aCol[j].zCol; + string zOnDelete = actionName( pFK.aAction[0] ); + string zOnUpdate = actionName( pFK.aAction[1] ); + sqlite3VdbeAddOp2( v, OP_Integer, i, 1 ); + sqlite3VdbeAddOp2( v, OP_Integer, j, 2 ); + sqlite3VdbeAddOp4( v, OP_String8, 0, 3, 0, pFK.zTo, 0 ); + sqlite3VdbeAddOp4( v, OP_String8, 0, 4, 0, + pTab.aCol[pFK.aCol[j].iFrom].zName, 0 ); + sqlite3VdbeAddOp4( v, zCol != null ? OP_String8 : OP_Null, 0, 5, 0, zCol, 0 ); + sqlite3VdbeAddOp4( v, OP_String8, 0, 6, 0, zOnUpdate, 0 ); + sqlite3VdbeAddOp4( v, OP_String8, 0, 7, 0, zOnDelete, 0 ); + sqlite3VdbeAddOp4( v, OP_String8, 0, 8, 0, "NONE", 0 ); + sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 8 ); + } + ++i; + pFK = pFK.pNextFrom; + } + } + } + } + else #endif // * !SQLITE_OMIT_FOREIGN_KEY) */ #if !NDEBUG - if (zLeft.Equals("parser_trace", StringComparison.OrdinalIgnoreCase)) { - if (zRight != null) { - if (sqlite3GetBoolean(zRight) != 0) { - sqlite3ParserTrace(Console.Out, "parser: "); - } else { - sqlite3ParserTrace(null, ""); - } - } - } else + if ( zLeft.Equals( "parser_trace", StringComparison.OrdinalIgnoreCase ) ) + { + if ( zRight != null ) + { + if ( sqlite3GetBoolean( zRight ) != 0 ) + { + sqlite3ParserTrace( Console.Out, "parser: " ); + } + else + { + sqlite3ParserTrace( null, "" ); + } + } + } + else #endif - /* Reinstall the LIKE and GLOB functions. The variant of LIKE - ** used will be case sensitive or not depending on the RHS. - */ - if (zLeft.Equals("case_sensitive_like", StringComparison.OrdinalIgnoreCase)) { - if (zRight != null) { - sqlite3RegisterLikeFunctions(db, sqlite3GetBoolean(zRight)); - } - } else + /* Reinstall the LIKE and GLOB functions. The variant of LIKE +** used will be case sensitive or not depending on the RHS. +*/ + if ( zLeft.Equals( "case_sensitive_like", StringComparison.OrdinalIgnoreCase ) ) + { + if ( zRight != null ) + { + sqlite3RegisterLikeFunctions( db, sqlite3GetBoolean( zRight ) ); + } + } + else #if !SQLITE_INTEGRITY_CHECK_ERROR_MAX - //const int SQLITE_INTEGRITY_CHECK_ERROR_MAX = 100; + //const int SQLITE_INTEGRITY_CHECK_ERROR_MAX = 100; #endif #if !SQLITE_OMIT_INTEGRITY_CHECK - /* Pragma "quick_check" is an experimental reduced version of - ** integrity_check designed to detect most database corruption - ** without most of the overhead of a full integrity-check. - */ - if (zLeft.Equals("integrity_check", StringComparison.OrdinalIgnoreCase) - || zLeft.Equals("quick_check", StringComparison.OrdinalIgnoreCase) - ) { - const int SQLITE_INTEGRITY_CHECK_ERROR_MAX = 100; - int i, j, addr, mxErr; - - /* Code that appears at the end of the integrity check. If no error - ** messages have been generated, refput OK. Otherwise output the - ** error message - */ - VdbeOpList[] endCode = new VdbeOpList[] { + /* Pragma "quick_check" is an experimental reduced version of +** integrity_check designed to detect most database corruption +** without most of the overhead of a full integrity-check. +*/ + if ( zLeft.Equals( "integrity_check", StringComparison.OrdinalIgnoreCase ) + || zLeft.Equals( "quick_check", StringComparison.OrdinalIgnoreCase ) + ) + { + const int SQLITE_INTEGRITY_CHECK_ERROR_MAX = 100; + int i, j, addr, mxErr; + + /* Code that appears at the end of the integrity check. If no error + ** messages have been generated, refput OK. Otherwise output the + ** error message + */ + VdbeOpList[] endCode = new VdbeOpList[] { new VdbeOpList( OP_AddImm, 1, 0, 0), /* 0 */ new VdbeOpList( OP_IfNeg, 1, 0, 0), /* 1 */ new VdbeOpList( OP_String8, 0, 3, 0), /* 2 */ new VdbeOpList( OP_ResultRow, 3, 1, 0), }; - bool isQuick = (zLeft[0] == 'q'); - - /* Initialize the VDBE program */ - if (sqlite3ReadSchema(pParse) != 0) - goto pragma_out; - pParse.nMem = 6; - sqlite3VdbeSetNumCols(v, 1); - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "integrity_check", SQLITE_STATIC); - - /* Set the maximum error count */ - mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX; - if (zRight != null) { - sqlite3GetInt32(zRight, ref mxErr); - if (mxErr <= 0) { - mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX; - } - } - sqlite3VdbeAddOp2(v, OP_Integer, mxErr, 1); /* reg[1] holds errors left */ - - /* Do an integrity check on each database file */ - for (i = 0; i < db.nDb; i++) { - HashElem x; - Hash pTbls; - int cnt = 0; - - if (OMIT_TEMPDB != 0 && i == 1) - continue; - - sqlite3CodeVerifySchema(pParse, i); - addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Halt if out of errors */ - sqlite3VdbeAddOp2(v, OP_Halt, 0, 0); - sqlite3VdbeJumpHere(v, addr); - - /* Do an integrity check of the B-Tree - ** - ** Begin by filling registers 2, 3, ... with the root pages numbers - ** for all tables and indices in the database. - */ - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); - pTbls = db.aDb[i].pSchema.tblHash; - for (x = pTbls.first; x != null; x = x.next) {// for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){ - Table pTab = (Table)x.data;// sqliteHashData( x ); - Index pIdx; - sqlite3VdbeAddOp2(v, OP_Integer, pTab.tnum, 2 + cnt); - cnt++; - for (pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext) { - sqlite3VdbeAddOp2(v, OP_Integer, pIdx.tnum, 2 + cnt); - cnt++; - } - } - - /* Make sure sufficient number of registers have been allocated */ - if (pParse.nMem < cnt + 4) { - pParse.nMem = cnt + 4; - } - - /* Do the b-tree integrity checks */ - sqlite3VdbeAddOp3(v, OP_IntegrityCk, 2, cnt, 1); - sqlite3VdbeChangeP5(v, (u8)i); - addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); - sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, - sqlite3MPrintf(db, "*** in database %s ***\n", db.aDb[i].zName), - P4_DYNAMIC); - sqlite3VdbeAddOp3(v, OP_Move, 2, 4, 1); - sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 2); - sqlite3VdbeAddOp2(v, OP_ResultRow, 2, 1); - sqlite3VdbeJumpHere(v, addr); - - /* Make sure all the indices are constructed correctly. - */ - for (x = pTbls.first; x != null && !isQuick; x = x.next) { - ;// for(x=sqliteHashFirst(pTbls); x && !isQuick; x=sqliteHashNext(x)){ - Table pTab = (Table)x.data;// sqliteHashData( x ); - Index pIdx; - int loopTop; - - if (pTab.pIndex == null) - continue; - addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Stop if out of errors */ - sqlite3VdbeAddOp2(v, OP_Halt, 0, 0); - sqlite3VdbeJumpHere(v, addr); - sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead); - sqlite3VdbeAddOp2(v, OP_Integer, 0, 2); /* reg(2) will count entries */ - loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0); - sqlite3VdbeAddOp2(v, OP_AddImm, 2, 1); /* increment entry count */ - for (j = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, j++) { - int jmp2; - int r1; - VdbeOpList[] idxErr = new VdbeOpList[] { + bool isQuick = ( zLeft[0] == 'q' ); + + /* Initialize the VDBE program */ + if ( sqlite3ReadSchema( pParse ) != 0 ) + goto pragma_out; + pParse.nMem = 6; + sqlite3VdbeSetNumCols( v, 1 ); + sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "integrity_check", SQLITE_STATIC ); + + /* Set the maximum error count */ + mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX; + if ( zRight != null ) + { + sqlite3GetInt32( zRight, ref mxErr ); + if ( mxErr <= 0 ) + { + mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX; + } + } + sqlite3VdbeAddOp2( v, OP_Integer, mxErr, 1 ); /* reg[1] holds errors left */ + + /* Do an integrity check on each database file */ + for ( i = 0; i < db.nDb; i++ ) + { + HashElem x; + Hash pTbls; + int cnt = 0; + + if ( OMIT_TEMPDB != 0 && i == 1 ) + continue; + + sqlite3CodeVerifySchema( pParse, i ); + addr = sqlite3VdbeAddOp1( v, OP_IfPos, 1 ); /* Halt if out of errors */ + sqlite3VdbeAddOp2( v, OP_Halt, 0, 0 ); + sqlite3VdbeJumpHere( v, addr ); + + /* Do an integrity check of the B-Tree + ** + ** Begin by filling registers 2, 3, ... with the root pages numbers + ** for all tables and indices in the database. + */ + Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); + pTbls = db.aDb[i].pSchema.tblHash; + for ( x = pTbls.first; x != null; x = x.next ) + {// for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){ + Table pTab = (Table)x.data;// sqliteHashData( x ); + Index pIdx; + sqlite3VdbeAddOp2( v, OP_Integer, pTab.tnum, 2 + cnt ); + cnt++; + for ( pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext ) + { + sqlite3VdbeAddOp2( v, OP_Integer, pIdx.tnum, 2 + cnt ); + cnt++; + } + } + + /* Make sure sufficient number of registers have been allocated */ + if ( pParse.nMem < cnt + 4 ) + { + pParse.nMem = cnt + 4; + } + + /* Do the b-tree integrity checks */ + sqlite3VdbeAddOp3( v, OP_IntegrityCk, 2, cnt, 1 ); + sqlite3VdbeChangeP5( v, (u8)i ); + addr = sqlite3VdbeAddOp1( v, OP_IsNull, 2 ); + sqlite3VdbeAddOp4( v, OP_String8, 0, 3, 0, + sqlite3MPrintf( db, "*** in database %s ***\n", db.aDb[i].zName ), + P4_DYNAMIC ); + sqlite3VdbeAddOp3( v, OP_Move, 2, 4, 1 ); + sqlite3VdbeAddOp3( v, OP_Concat, 4, 3, 2 ); + sqlite3VdbeAddOp2( v, OP_ResultRow, 2, 1 ); + sqlite3VdbeJumpHere( v, addr ); + + /* Make sure all the indices are constructed correctly. + */ + for ( x = pTbls.first; x != null && !isQuick; x = x.next ) + { + ;// for(x=sqliteHashFirst(pTbls); x && !isQuick; x=sqliteHashNext(x)){ + Table pTab = (Table)x.data;// sqliteHashData( x ); + Index pIdx; + int loopTop; + + if ( pTab.pIndex == null ) + continue; + addr = sqlite3VdbeAddOp1( v, OP_IfPos, 1 ); /* Stop if out of errors */ + sqlite3VdbeAddOp2( v, OP_Halt, 0, 0 ); + sqlite3VdbeJumpHere( v, addr ); + sqlite3OpenTableAndIndices( pParse, pTab, 1, OP_OpenRead ); + sqlite3VdbeAddOp2( v, OP_Integer, 0, 2 ); /* reg(2) will count entries */ + loopTop = sqlite3VdbeAddOp2( v, OP_Rewind, 1, 0 ); + sqlite3VdbeAddOp2( v, OP_AddImm, 2, 1 ); /* increment entry count */ + for ( j = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, j++ ) + { + int jmp2; + int r1; + VdbeOpList[] idxErr = new VdbeOpList[] { new VdbeOpList( OP_AddImm, 1, -1, 0), new VdbeOpList( OP_String8, 0, 3, 0), /* 1 */ new VdbeOpList( OP_Rowid, 1, 4, 0), @@ -1294,19 +1481,20 @@ static void sqlite3Pragma( new VdbeOpList( OP_IfPos, 1, 0, 0), /* 9 */ new VdbeOpList( OP_Halt, 0, 0, 0), }; - r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, false); - jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, j + 2, 0, r1, pIdx.nColumn + 1); - addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr); - sqlite3VdbeChangeP4(v, addr + 1, "rowid ", SQLITE_STATIC); - sqlite3VdbeChangeP4(v, addr + 3, " missing from index ", SQLITE_STATIC); - sqlite3VdbeChangeP4(v, addr + 4, pIdx.zName, P4_TRANSIENT); - sqlite3VdbeJumpHere(v, addr + 9); - sqlite3VdbeJumpHere(v, jmp2); - } - sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop + 1); - sqlite3VdbeJumpHere(v, loopTop); - for (j = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, j++) { - VdbeOpList[] cntIdx = new VdbeOpList[] { + r1 = sqlite3GenerateIndexKey( pParse, pIdx, 1, 3, false ); + jmp2 = sqlite3VdbeAddOp4Int( v, OP_Found, j + 2, 0, r1, pIdx.nColumn + 1 ); + addr = sqlite3VdbeAddOpList( v, ArraySize( idxErr ), idxErr ); + sqlite3VdbeChangeP4( v, addr + 1, "rowid ", SQLITE_STATIC ); + sqlite3VdbeChangeP4( v, addr + 3, " missing from index ", SQLITE_STATIC ); + sqlite3VdbeChangeP4( v, addr + 4, pIdx.zName, P4_TRANSIENT ); + sqlite3VdbeJumpHere( v, addr + 9 ); + sqlite3VdbeJumpHere( v, jmp2 ); + } + sqlite3VdbeAddOp2( v, OP_Next, 1, loopTop + 1 ); + sqlite3VdbeJumpHere( v, loopTop ); + for ( j = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, j++ ) + { + VdbeOpList[] cntIdx = new VdbeOpList[] { new VdbeOpList( OP_Integer, 0, 3, 0), new VdbeOpList( OP_Rewind, 0, 0, 0), /* 1 */ new VdbeOpList( OP_AddImm, 3, 1, 0), @@ -1318,67 +1506,71 @@ static void sqlite3Pragma( new VdbeOpList( OP_Concat, 3, 2, 2), new VdbeOpList( OP_ResultRow, 2, 1, 0), }; - addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); - sqlite3VdbeAddOp2(v, OP_Halt, 0, 0); - sqlite3VdbeJumpHere(v, addr); - addr = sqlite3VdbeAddOpList(v, ArraySize(cntIdx), cntIdx); - sqlite3VdbeChangeP1(v, addr + 1, j + 2); - sqlite3VdbeChangeP2(v, addr + 1, addr + 4); - sqlite3VdbeChangeP1(v, addr + 3, j + 2); - sqlite3VdbeChangeP2(v, addr + 3, addr + 2); - sqlite3VdbeJumpHere(v, addr + 4); - sqlite3VdbeChangeP4(v, addr + 6, - "wrong # of entries in index ", P4_STATIC); - sqlite3VdbeChangeP4(v, addr + 7, pIdx.zName, P4_TRANSIENT); - } - } - } - addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode); - sqlite3VdbeChangeP2(v, addr, -mxErr); - sqlite3VdbeJumpHere(v, addr + 1); - sqlite3VdbeChangeP4(v, addr + 2, "ok", P4_STATIC); - } else + addr = sqlite3VdbeAddOp1( v, OP_IfPos, 1 ); + sqlite3VdbeAddOp2( v, OP_Halt, 0, 0 ); + sqlite3VdbeJumpHere( v, addr ); + addr = sqlite3VdbeAddOpList( v, ArraySize( cntIdx ), cntIdx ); + sqlite3VdbeChangeP1( v, addr + 1, j + 2 ); + sqlite3VdbeChangeP2( v, addr + 1, addr + 4 ); + sqlite3VdbeChangeP1( v, addr + 3, j + 2 ); + sqlite3VdbeChangeP2( v, addr + 3, addr + 2 ); + sqlite3VdbeJumpHere( v, addr + 4 ); + sqlite3VdbeChangeP4( v, addr + 6, + "wrong # of entries in index ", P4_STATIC ); + sqlite3VdbeChangeP4( v, addr + 7, pIdx.zName, P4_TRANSIENT ); + } + } + } + addr = sqlite3VdbeAddOpList( v, ArraySize( endCode ), endCode ); + sqlite3VdbeChangeP2( v, addr, -mxErr ); + sqlite3VdbeJumpHere( v, addr + 1 ); + sqlite3VdbeChangeP4( v, addr + 2, "ok", P4_STATIC ); + } + else #endif // * SQLITE_OMIT_INTEGRITY_CHECK */ - /* - ** PRAGMA encoding - ** PRAGMA encoding = "utf-8"|"utf-16"|"utf-16le"|"utf-16be" - ** - ** In its first form, this pragma returns the encoding of the main - ** database. If the database is not initialized, it is initialized now. - ** - ** The second form of this pragma is a no-op if the main database file - ** has not already been initialized. In this case it sets the default - ** encoding that will be used for the main database file if a new file - ** is created. If an existing main database file is opened, then the - ** default text encoding for the existing database is used. - ** - ** In all cases new databases created using the ATTACH command are - ** created to use the same default text encoding as the main database. If - ** the main database has not been initialized and/or created when ATTACH - ** is executed, this is done before the ATTACH operation. - ** - ** 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 - */ - if (zLeft.Equals("encoding", StringComparison.OrdinalIgnoreCase)) { - int iEnc; - if (null == zRight) { /* "PRAGMA encoding" */ - if (sqlite3ReadSchema(pParse) != 0) { - pParse.nErr = 0; - pParse.zErrMsg = null; - pParse.rc = 0;// reset errors goto pragma_out; - } - sqlite3VdbeSetNumCols(v, 1); - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "encoding", SQLITE_STATIC); - sqlite3VdbeAddOp2(v, OP_String8, 0, 1); - Debug.Assert(encnames[SQLITE_UTF8].enc == SQLITE_UTF8); - Debug.Assert(encnames[SQLITE_UTF16LE].enc == SQLITE_UTF16LE); - Debug.Assert(encnames[SQLITE_UTF16BE].enc == SQLITE_UTF16BE); - sqlite3VdbeChangeP4(v, -1, encnames[ENC(pParse.db)].zName, P4_STATIC); - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); - } + /* +** PRAGMA encoding +** PRAGMA encoding = "utf-8"|"utf-16"|"utf-16le"|"utf-16be" +** +** In its first form, this pragma returns the encoding of the main +** database. If the database is not initialized, it is initialized now. +** +** The second form of this pragma is a no-op if the main database file +** has not already been initialized. In this case it sets the default +** encoding that will be used for the main database file if a new file +** is created. If an existing main database file is opened, then the +** default text encoding for the existing database is used. +** +** In all cases new databases created using the ATTACH command are +** created to use the same default text encoding as the main database. If +** the main database has not been initialized and/or created when ATTACH +** is executed, this is done before the ATTACH operation. +** +** 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 +*/ + if ( zLeft.Equals( "encoding", StringComparison.OrdinalIgnoreCase ) ) + { + int iEnc; + if ( null == zRight ) + { /* "PRAGMA encoding" */ + if ( sqlite3ReadSchema( pParse ) != 0 ) + { + pParse.nErr = 0; + pParse.zErrMsg = null; + pParse.rc = 0;// reset errors goto pragma_out; + } + sqlite3VdbeSetNumCols( v, 1 ); + sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "encoding", SQLITE_STATIC ); + sqlite3VdbeAddOp2( v, OP_String8, 0, 1 ); + Debug.Assert( encnames[SQLITE_UTF8].enc == SQLITE_UTF8 ); + Debug.Assert( encnames[SQLITE_UTF16LE].enc == SQLITE_UTF16LE ); + Debug.Assert( encnames[SQLITE_UTF16BE].enc == SQLITE_UTF16BE ); + sqlite3VdbeChangeP4( v, -1, encnames[ENC( pParse.db )].zName, P4_STATIC ); + sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 1 ); + } #if !SQLITE_OMIT_UTF16 else { /* "PRAGMA encoding = XXX" */ @@ -1408,107 +1600,121 @@ static void sqlite3Pragma( } } #endif - } else + } + else #if !SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS - /* - ** PRAGMA [database.]schema_version - ** PRAGMA [database.]schema_version = - ** - ** PRAGMA [database.]user_version - ** PRAGMA [database.]user_version = - ** - ** The pragma's schema_version and user_version are used to set or get - ** the value of the schema-version and user-version, respectively. Both - ** the schema-version and the user-version are 32-bit signed integers - ** stored in the database header. - ** - ** The schema-cookie is usually only manipulated internally by SQLite. It - ** is incremented by SQLite whenever the database schema is modified (by - ** creating or dropping a table or index). The schema version is used by - ** SQLite each time a query is executed to ensure that the internal cache - ** of the schema used when compiling the SQL query matches the schema of - ** the database against which the compiled query is actually executed. - ** Subverting this mechanism by using "PRAGMA schema_version" to modify - ** the schema-version is potentially dangerous and may lead to program - ** 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. - */ - if (zLeft.Equals("schema_version", StringComparison.OrdinalIgnoreCase) - || zLeft.Equals("user_version", StringComparison.OrdinalIgnoreCase) - || zLeft.Equals("freelist_count", StringComparison.OrdinalIgnoreCase) - ) { - int iCookie; /* Cookie index. 1 for schema-cookie, 6 for user-cookie. */ - sqlite3VdbeUsesBtree(v, iDb); - switch (zLeft[0]) { - case 'f': - case 'F': - iCookie = BTREE_FREE_PAGE_COUNT; - break; - case 's': - case 'S': - iCookie = BTREE_SCHEMA_VERSION; - break; - default: - iCookie = BTREE_USER_VERSION; - break; - } - - if (zRight != null && iCookie != BTREE_FREE_PAGE_COUNT) { - /* Write the specified cookie value */ - VdbeOpList[] setCookie = new VdbeOpList[] { + /* +** PRAGMA [database.]schema_version +** PRAGMA [database.]schema_version = +** +** PRAGMA [database.]user_version +** PRAGMA [database.]user_version = +** +** The pragma's schema_version and user_version are used to set or get +** the value of the schema-version and user-version, respectively. Both +** the schema-version and the user-version are 32-bit signed integers +** stored in the database header. +** +** The schema-cookie is usually only manipulated internally by SQLite. It +** is incremented by SQLite whenever the database schema is modified (by +** creating or dropping a table or index). The schema version is used by +** SQLite each time a query is executed to ensure that the internal cache +** of the schema used when compiling the SQL query matches the schema of +** the database against which the compiled query is actually executed. +** Subverting this mechanism by using "PRAGMA schema_version" to modify +** the schema-version is potentially dangerous and may lead to program +** 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. +*/ + if ( zLeft.Equals( "schema_version", StringComparison.OrdinalIgnoreCase ) + || zLeft.Equals( "user_version", StringComparison.OrdinalIgnoreCase ) + || zLeft.Equals( "freelist_count", StringComparison.OrdinalIgnoreCase ) + ) + { + int iCookie; /* Cookie index. 1 for schema-cookie, 6 for user-cookie. */ + sqlite3VdbeUsesBtree( v, iDb ); + switch ( zLeft[0] ) + { + case 'f': + case 'F': + iCookie = BTREE_FREE_PAGE_COUNT; + break; + case 's': + case 'S': + iCookie = BTREE_SCHEMA_VERSION; + break; + default: + iCookie = BTREE_USER_VERSION; + break; + } + + if ( zRight != null && iCookie != BTREE_FREE_PAGE_COUNT ) + { + /* Write the specified cookie value */ + VdbeOpList[] setCookie = new VdbeOpList[] { new VdbeOpList( OP_Transaction, 0, 1, 0), /* 0 */ new VdbeOpList( OP_Integer, 0, 1, 0), /* 1 */ new VdbeOpList( OP_SetCookie, 0, 0, 1), /* 2 */ }; - int addr = sqlite3VdbeAddOpList(v, ArraySize(setCookie), setCookie); - sqlite3VdbeChangeP1(v, addr, iDb); - sqlite3VdbeChangeP1(v, addr + 1, sqlite3Atoi(zRight)); - sqlite3VdbeChangeP1(v, addr + 2, iDb); - sqlite3VdbeChangeP2(v, addr + 2, iCookie); - } else { - /* Read the specified cookie value */ - VdbeOpList[] readCookie = new VdbeOpList[] { + int addr = sqlite3VdbeAddOpList( v, ArraySize( setCookie ), setCookie ); + sqlite3VdbeChangeP1( v, addr, iDb ); + sqlite3VdbeChangeP1( v, addr + 1, sqlite3Atoi( zRight ) ); + sqlite3VdbeChangeP1( v, addr + 2, iDb ); + sqlite3VdbeChangeP2( v, addr + 2, iCookie ); + } + else + { + /* Read the specified cookie value */ + VdbeOpList[] readCookie = new VdbeOpList[] { new VdbeOpList( OP_Transaction, 0, 0, 0), /* 0 */ new VdbeOpList( OP_ReadCookie, 0, 1, 0), /* 1 */ new VdbeOpList( OP_ResultRow, 1, 1, 0) }; - int addr = sqlite3VdbeAddOpList(v, readCookie.Length, readCookie);// ArraySize(readCookie), readCookie); - sqlite3VdbeChangeP1(v, addr, iDb); - sqlite3VdbeChangeP1(v, addr + 1, iDb); - sqlite3VdbeChangeP3(v, addr + 1, iCookie); - sqlite3VdbeSetNumCols(v, 1); - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLeft, SQLITE_TRANSIENT); - } - } else if (zLeft.Equals("reload_schema", StringComparison.OrdinalIgnoreCase)) { - /* force schema reloading*/ - sqlite3ResetInternalSchema(db, -1); - } else if (zLeft.Equals("file_format", StringComparison.OrdinalIgnoreCase)) { - pDb.pSchema.file_format = (u8)atoi(zRight); - sqlite3ResetInternalSchema(db, -1); - } else + int addr = sqlite3VdbeAddOpList( v, readCookie.Length, readCookie );// ArraySize(readCookie), readCookie); + sqlite3VdbeChangeP1( v, addr, iDb ); + sqlite3VdbeChangeP1( v, addr + 1, iDb ); + sqlite3VdbeChangeP3( v, addr + 1, iCookie ); + sqlite3VdbeSetNumCols( v, 1 ); + sqlite3VdbeSetColName( v, 0, COLNAME_NAME, zLeft, SQLITE_TRANSIENT ); + } + } + else if ( zLeft.Equals( "reload_schema", StringComparison.OrdinalIgnoreCase ) ) + { + /* force schema reloading*/ + sqlite3ResetInternalSchema( db, -1 ); + } + else if ( zLeft.Equals( "file_format", StringComparison.OrdinalIgnoreCase ) ) + { + pDb.pSchema.file_format = (u8)atoi( zRight ); + sqlite3ResetInternalSchema( db, -1 ); + } + else #endif // * SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS */ #if !SQLITE_OMIT_COMPILEOPTION_DIAGS - /* + /* ** PRAGMA compile_options ** ** Return the names of all compile-time options used in this build, ** one option per row. */ - if (zLeft.Equals("compile_options", StringComparison.OrdinalIgnoreCase)) { - int i = 0; - string zOpt; - sqlite3VdbeSetNumCols(v, 1); - pParse.nMem = 1; - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "compile_option", SQLITE_STATIC); - while ((zOpt = sqlite3_compileoption_get(i++)) != null) { - sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, zOpt, 0); - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); - } - } else + if ( zLeft.Equals( "compile_options", StringComparison.OrdinalIgnoreCase ) ) + { + int i = 0; + string zOpt; + sqlite3VdbeSetNumCols( v, 1 ); + pParse.nMem = 1; + sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "compile_option", SQLITE_STATIC ); + while ( ( zOpt = sqlite3_compileoption_get( i++ ) ) != null ) + { + sqlite3VdbeAddOp4( v, OP_String8, 0, 1, 0, zOpt, 0 ); + sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 1 ); + } + } + else #endif //* SQLITE_OMIT_COMPILEOPTION_DIAGS */ @@ -1558,37 +1764,43 @@ static void sqlite3Pragma( #endif #if SQLITE_DEBUG || SQLITE_TEST - /* + /* ** Report the current state of file logs for all databases */ - if (zLeft.Equals("lock_status", StringComparison.OrdinalIgnoreCase)) { - string[] azLockName = { + if ( zLeft.Equals( "lock_status", StringComparison.OrdinalIgnoreCase ) ) + { + string[] azLockName = { "unlocked", "shared", "reserved", "pending", "exclusive" }; - int i; - sqlite3VdbeSetNumCols(v, 2); - pParse.nMem = 2; - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "database", SQLITE_STATIC); - sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "status", SQLITE_STATIC); - for (i = 0; i < db.nDb; i++) { - Btree pBt; - Pager pPager; - string zState = "unknown"; - sqlite3_int64 j = 0; - if (db.aDb[i].zName == null) - continue; - sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, db.aDb[i].zName, P4_STATIC); - pBt = db.aDb[i].pBt; - if (pBt == null || (pPager = sqlite3BtreePager(pBt)) == null) { - zState = "closed"; - } else if (sqlite3_file_control(db, i != 0 ? db.aDb[i].zName : null, - SQLITE_FCNTL_LOCKSTATE, ref j) == SQLITE_OK) { - zState = azLockName[j]; - } - sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, zState, P4_STATIC); - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2); - } - } else + int i; + sqlite3VdbeSetNumCols( v, 2 ); + pParse.nMem = 2; + sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "database", SQLITE_STATIC ); + sqlite3VdbeSetColName( v, 1, COLNAME_NAME, "status", SQLITE_STATIC ); + for ( i = 0; i < db.nDb; i++ ) + { + Btree pBt; + Pager pPager; + string zState = "unknown"; + sqlite3_int64 j = 0; + if ( db.aDb[i].zName == null ) + continue; + sqlite3VdbeAddOp4( v, OP_String8, 0, 1, 0, db.aDb[i].zName, P4_STATIC ); + pBt = db.aDb[i].pBt; + if ( pBt == null || ( pPager = sqlite3BtreePager( pBt ) ) == null ) + { + zState = "closed"; + } + else if ( sqlite3_file_control( db, i != 0 ? db.aDb[i].zName : null, + SQLITE_FCNTL_LOCKSTATE, ref j ) == SQLITE_OK ) + { + zState = azLockName[j]; + } + sqlite3VdbeAddOp4( v, OP_String8, 0, 2, 0, zState, P4_STATIC ); + sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 2 ); + } + } + else #endif #if SQLITE_HAS_CODEC @@ -1649,26 +1861,27 @@ static void sqlite3Pragma( } else #endif - { /* Empty ELSE clause */ - } + { /* Empty ELSE clause */ + } - /* - ** Reset the safety level, in case the fullfsync flag or synchronous - ** setting changed. - */ + /* + ** Reset the safety level, in case the fullfsync flag or synchronous + ** setting changed. + */ #if !SQLITE_OMIT_PAGER_PRAGMAS - if (db.autoCommit != 0) { - sqlite3BtreeSetSafetyLevel(pDb.pBt, pDb.safety_level, - ((db.flags & SQLITE_FullFSync) != 0) ? 1 : 0, - ((db.flags & SQLITE_CkptFullFSync) != 0) ? 1 : 0); - } + if ( db.autoCommit != 0 ) + { + sqlite3BtreeSetSafetyLevel( pDb.pBt, pDb.safety_level, + ( ( db.flags & SQLITE_FullFSync ) != 0 ) ? 1 : 0, + ( ( db.flags & SQLITE_CkptFullFSync ) != 0 ) ? 1 : 0 ); + } #endif - pragma_out: - sqlite3DbFree(db, ref zLeft); - sqlite3DbFree(db, ref zRight); - ; - } +pragma_out: + sqlite3DbFree( db, ref zLeft ); + sqlite3DbFree( db, ref zRight ); + ; + } #endif // * SQLITE_OMIT_PRAGMA - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/prepare_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/prepare_c.cs index 68e80a38e..d36fd8ffd 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/prepare_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/prepare_c.cs @@ -2,899 +2,1006 @@ using System.Diagnostics; using System.Text; -using sqlite3_int64 = System.Int64; -using u32 = System.UInt32; using u8 = System.Byte; +using u16 = System.UInt16; +using u32 = System.UInt32; +using sqlite3_int64 = System.Int64; -namespace Community.CsharpSqlite { - using sqlite3_stmt = Sqlite3.Vdbe; - - public partial class Sqlite3 { - /* - ** 2005 May 25 - ** - ** 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 contains the implementation of the sqlite3_prepare() - ** interface, and routines that contribute to loading the database schema - ** from disk. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +namespace Community.CsharpSqlite +{ + using sqlite3_stmt = Sqlite3.Vdbe; - /* - ** Fill the InitData structure with an error message that indicates - ** that the database is corrupt. - */ - static void corruptSchema( - InitData pData, /* Initialization context */ - string zObj, /* Object being parsed at the point of error */ - string zExtra /* Error information */ - ) { - sqlite3 db = pData.db; - if ( /* 0 == db.mallocFailed && */ (db.flags & SQLITE_RecoveryMode) == 0) { - { - if (zObj == null) { - zObj = "?"; + public partial class Sqlite3 + { + /* + ** 2005 May 25 + ** + ** 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 contains the implementation of the sqlite3_prepare() + ** interface, and routines that contribute to loading the database schema + ** from disk. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + + /* + ** Fill the InitData structure with an error message that indicates + ** that the database is corrupt. + */ + static void corruptSchema( + InitData pData, /* Initialization context */ + string zObj, /* Object being parsed at the point of error */ + string zExtra /* Error information */ + ) + { + sqlite3 db = pData.db; + if ( /* 0 == db.mallocFailed && */ ( db.flags & SQLITE_RecoveryMode ) == 0 ) + { + { + if ( zObj == null ) + { + zObj = "?"; #if SQLITE_OMIT_UTF16 - if (ENC(db) != SQLITE_UTF8) - zObj = encnames[(ENC(db))].zName; + if (ENC(db) != SQLITE_UTF8) + zObj =encnames[(ENC(db))].zName; #endif - } - sqlite3SetString(ref pData.pzErrMsg, db, - "malformed database schema (%s)", zObj); - if (!String.IsNullOrEmpty(zExtra)) { - pData.pzErrMsg = sqlite3MAppendf(db, pData.pzErrMsg - , "%s - %s", pData.pzErrMsg, zExtra); - } - } - pData.rc = //db.mallocFailed != 0 ? SQLITE_NOMEM : - SQLITE_CORRUPT_BKPT(); - } + } + sqlite3SetString( ref pData.pzErrMsg, db, + "malformed database schema (%s)", zObj ); + if ( !String.IsNullOrEmpty( zExtra ) ) + { + pData.pzErrMsg = sqlite3MAppendf( db, pData.pzErrMsg + , "%s - %s", pData.pzErrMsg, zExtra ); + } } + pData.rc = //db.mallocFailed != 0 ? SQLITE_NOMEM : + SQLITE_CORRUPT_BKPT(); + } + } - /* - ** This is the callback routine for the code that initializes the - ** database. See sqlite3Init() below for additional information. - ** This routine is also called from the OP_ParseSchema opcode of the VDBE. - ** - ** Each callback contains the following information: - ** - ** argv[0] = name of thing being created - ** argv[1] = root page number for table or index. 0 for trigger or view. - ** argv[2] = SQL text for the CREATE statement. - ** - */ - static int sqlite3InitCallback(object pInit, sqlite3_int64 argc, object p2, object NotUsed) { - string[] argv = (string[])p2; - InitData pData = (InitData)pInit; - sqlite3 db = pData.db; - int iDb = pData.iDb; - - Debug.Assert(argc == 3); - UNUSED_PARAMETER2(NotUsed, argc); - Debug.Assert(sqlite3_mutex_held(db.mutex)); - DbClearProperty(db, iDb, DB_Empty); - //if ( db.mallocFailed != 0 ) - //{ - // corruptSchema( pData, argv[0], "" ); - // return 1; - //} + /* + ** This is the callback routine for the code that initializes the + ** database. See sqlite3Init() below for additional information. + ** This routine is also called from the OP_ParseSchema opcode of the VDBE. + ** + ** Each callback contains the following information: + ** + ** argv[0] = name of thing being created + ** argv[1] = root page number for table or index. 0 for trigger or view. + ** argv[2] = SQL text for the CREATE statement. + ** + */ + static int sqlite3InitCallback( object pInit, sqlite3_int64 argc, object p2, object NotUsed ) + { + string[] argv = (string[])p2; + InitData pData = (InitData)pInit; + sqlite3 db = pData.db; + int iDb = pData.iDb; - Debug.Assert(iDb >= 0 && iDb < db.nDb); - if (argv == null) - return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */ - if (argv[1] == null) { - corruptSchema(pData, argv[0], ""); - } else if (!String.IsNullOrEmpty(argv[2])) { - /* Call the parser to process a CREATE TABLE, INDEX or VIEW. - ** But because db.init.busy is set to 1, no VDBE code is generated - ** or executed. All the parser does is build the internal data - ** structures that describe the table, index, or view. - */ - int rc; - sqlite3_stmt pStmt = null; + Debug.Assert( argc == 3 ); + UNUSED_PARAMETER2( NotUsed, argc ); + Debug.Assert( sqlite3_mutex_held( db.mutex ) ); + DbClearProperty( db, iDb, DB_Empty ); + //if ( db.mallocFailed != 0 ) + //{ + // corruptSchema( pData, argv[0], "" ); + // return 1; + //} + + Debug.Assert( iDb >= 0 && iDb < db.nDb ); + if ( argv == null ) + return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */ + if ( argv[1] == null ) + { + corruptSchema( pData, argv[0], "" ); + } + else if ( !String.IsNullOrEmpty( argv[2] ) ) + { + /* Call the parser to process a CREATE TABLE, INDEX or VIEW. + ** But because db.init.busy is set to 1, no VDBE code is generated + ** or executed. All the parser does is build the internal data + ** structures that describe the table, index, or view. + */ + int rc; + sqlite3_stmt pStmt = null; #if !NDEBUG || SQLITE_COVERAGE_TEST - //TESTONLY(int rcp); /* Return code from sqlite3_prepare() */ - int rcp; + //TESTONLY(int rcp); /* Return code from sqlite3_prepare() */ + int rcp; #endif - Debug.Assert(db.init.busy != 0); - db.init.iDb = iDb; - db.init.newTnum = sqlite3Atoi(argv[1]); - db.init.orphanTrigger = 0; - //TESTONLY(rcp = ) sqlite3_prepare(db, argv[2], -1, &pStmt, 0); + Debug.Assert( db.init.busy != 0 ); + db.init.iDb = iDb; + db.init.newTnum = sqlite3Atoi( argv[1] ); + db.init.orphanTrigger = 0; + //TESTONLY(rcp = ) sqlite3_prepare(db, argv[2], -1, &pStmt, 0); #if !NDEBUG || SQLITE_COVERAGE_TEST - rcp = sqlite3_prepare(db, argv[2], -1, ref pStmt, 0); + rcp = sqlite3_prepare( db, argv[2], -1, ref pStmt, 0 ); #else sqlite3_prepare(db, argv[2], -1, ref pStmt, 0); #endif - rc = db.errCode; + rc = db.errCode; #if !NDEBUG || SQLITE_COVERAGE_TEST - Debug.Assert((rc & 0xFF) == (rcp & 0xFF)); + Debug.Assert( ( rc & 0xFF ) == ( rcp & 0xFF ) ); #endif - db.init.iDb = 0; - if (SQLITE_OK != rc) { - if (db.init.orphanTrigger != 0) { - Debug.Assert(iDb == 1); - } else { - pData.rc = rc; - //if ( rc == SQLITE_NOMEM ) - //{ - // // db.mallocFailed = 1; - //} - //else - if (rc != SQLITE_INTERRUPT && (rc & 0xFF) != SQLITE_LOCKED) { - corruptSchema(pData, argv[0], sqlite3_errmsg(db)); - } - } - } - sqlite3_finalize(pStmt); - } else if (argv[0] == null || argv[0] == "") { - corruptSchema(pData, null, null); - } else { - /* If the SQL column is blank it means this is an index that - ** was created to be the PRIMARY KEY or to fulfill a UNIQUE - ** constraint for a CREATE TABLE. The index should have already - ** been created when we processed the CREATE TABLE. All we have - ** to do here is record the root page number for that index. - */ - Index pIndex; - pIndex = sqlite3FindIndex(db, argv[0], db.aDb[iDb].zName); - if (pIndex == null) { - /* This can occur if there exists an index on a TEMP table which - ** has the same name as another index on a permanent index. Since - ** the permanent table is hidden by the TEMP table, we can also - ** safely ignore the index on the permanent table. - */ - /* Do Nothing */ - ; - } else if (sqlite3GetInt32(argv[1], ref pIndex.tnum) == false) { - corruptSchema(pData, argv[0], "invalid rootpage"); - } + db.init.iDb = 0; + if ( SQLITE_OK != rc ) + { + if ( db.init.orphanTrigger != 0 ) + { + Debug.Assert( iDb == 1 ); + } + else + { + pData.rc = rc; + //if ( rc == SQLITE_NOMEM ) + //{ + // // db.mallocFailed = 1; + //} + //else + if ( rc != SQLITE_INTERRUPT && ( rc & 0xFF ) != SQLITE_LOCKED ) + { + corruptSchema( pData, argv[0], sqlite3_errmsg( db ) ); } - return 0; + } } - - /* - ** Attempt to read the database schema and initialize internal - ** data structures for a single database file. The index of the - ** database file is given by iDb. iDb==0 is used for the main - ** database. iDb==1 should never be used. iDb>=2 is used for - ** auxiliary databases. Return one of the SQLITE_ error codes to - ** indicate success or failure. + sqlite3_finalize( pStmt ); + } + else if ( argv[0] == null || argv[0] == "" ) + { + corruptSchema( pData, null, null ); + } + else + { + /* If the SQL column is blank it means this is an index that + ** was created to be the PRIMARY KEY or to fulfill a UNIQUE + ** constraint for a CREATE TABLE. The index should have already + ** been created when we processed the CREATE TABLE. All we have + ** to do here is record the root page number for that index. */ - static int sqlite3InitOne(sqlite3 db, int iDb, ref string pzErrMsg) { - int rc; - int i; - int size; - Table pTab; - Db pDb; - string[] azArg = new string[4]; - u32[] meta = new u32[5]; - InitData initData = new InitData(); - string zMasterSchema; - string zMasterName; - int openedTransaction = 0; - - /* - ** The master database table has a structure like this - */ - string master_schema = - "CREATE TABLE sqlite_master(\n" + - " type text,\n" + - " name text,\n" + - " tbl_name text,\n" + - " rootpage integer,\n" + - " sql text\n" + - ")" - ; + Index pIndex; + pIndex = sqlite3FindIndex( db, argv[0], db.aDb[iDb].zName ); + if ( pIndex == null ) + { + /* This can occur if there exists an index on a TEMP table which + ** has the same name as another index on a permanent index. Since + ** the permanent table is hidden by the TEMP table, we can also + ** safely ignore the index on the permanent table. + */ + /* Do Nothing */ + ; + } + else if ( sqlite3GetInt32( argv[1], ref pIndex.tnum ) == false ) + { + corruptSchema( pData, argv[0], "invalid rootpage" ); + } + } + return 0; + } + + /* + ** Attempt to read the database schema and initialize internal + ** data structures for a single database file. The index of the + ** database file is given by iDb. iDb==0 is used for the main + ** database. iDb==1 should never be used. iDb>=2 is used for + ** auxiliary databases. Return one of the SQLITE_ error codes to + ** indicate success or failure. + */ + static int sqlite3InitOne( sqlite3 db, int iDb, ref string pzErrMsg ) + { + int rc; + int i; + int size; + Table pTab; + Db pDb; + string[] azArg = new string[4]; + u32[] meta = new u32[5]; + InitData initData = new InitData(); + string zMasterSchema; + string zMasterName; + int openedTransaction = 0; + + /* + ** The master database table has a structure like this + */ + string master_schema = + "CREATE TABLE sqlite_master(\n" + + " type text,\n" + + " name text,\n" + + " tbl_name text,\n" + + " rootpage integer,\n" + + " sql text\n" + + ")" + ; #if !SQLITE_OMIT_TEMPDB - string temp_master_schema = - "CREATE TEMP TABLE sqlite_temp_master(\n" + - " type text,\n" + - " name text,\n" + - " tbl_name text,\n" + - " rootpage integer,\n" + - " sql text\n" + - ")" - ; + string temp_master_schema = + "CREATE TEMP TABLE sqlite_temp_master(\n" + + " type text,\n" + + " name text,\n" + + " tbl_name text,\n" + + " rootpage integer,\n" + + " sql text\n" + + ")" + ; #else //#define temp_master_schema 0 #endif - Debug.Assert(iDb >= 0 && iDb < db.nDb); - Debug.Assert(db.aDb[iDb].pSchema != null); - Debug.Assert(sqlite3_mutex_held(db.mutex)); - Debug.Assert(iDb == 1 || sqlite3BtreeHoldsMutex(db.aDb[iDb].pBt)); - - /* zMasterSchema and zInitScript are set to point at the master schema - ** and initialisation script appropriate for the database being - ** initialised. zMasterName is the name of the master table. - */ - if (OMIT_TEMPDB == 0 && iDb == 1) { - zMasterSchema = temp_master_schema; - } else { - zMasterSchema = master_schema; - } - zMasterName = SCHEMA_TABLE(iDb); - - /* Construct the schema tables. */ - azArg[0] = zMasterName; - azArg[1] = "1"; - azArg[2] = zMasterSchema; - azArg[3] = ""; - initData.db = db; - initData.iDb = iDb; - initData.rc = SQLITE_OK; - initData.pzErrMsg = pzErrMsg; - sqlite3InitCallback(initData, 3, azArg, null); - if (initData.rc != 0) { - rc = initData.rc; - goto error_out; - } - pTab = sqlite3FindTable(db, zMasterName, db.aDb[iDb].zName); - if (ALWAYS(pTab)) { - pTab.tabFlags |= TF_Readonly; - } + Debug.Assert( iDb >= 0 && iDb < db.nDb ); + Debug.Assert( db.aDb[iDb].pSchema != null ); + Debug.Assert( sqlite3_mutex_held( db.mutex ) ); + Debug.Assert( iDb == 1 || sqlite3BtreeHoldsMutex( db.aDb[iDb].pBt ) ); - /* Create a cursor to hold the database open - */ - pDb = db.aDb[iDb]; - if (pDb.pBt == null) { - if (OMIT_TEMPDB == 0 && ALWAYS(iDb == 1)) { - DbSetProperty(db, 1, DB_SchemaLoaded); - } - return SQLITE_OK; - } + /* zMasterSchema and zInitScript are set to point at the master schema + ** and initialisation script appropriate for the database being + ** initialised. zMasterName is the name of the master table. + */ + if ( OMIT_TEMPDB == 0 && iDb == 1 ) + { + zMasterSchema = temp_master_schema; + } + else + { + zMasterSchema = master_schema; + } + zMasterName = SCHEMA_TABLE( iDb ); + + /* Construct the schema tables. */ + azArg[0] = zMasterName; + azArg[1] = "1"; + azArg[2] = zMasterSchema; + azArg[3] = ""; + initData.db = db; + initData.iDb = iDb; + initData.rc = SQLITE_OK; + initData.pzErrMsg = pzErrMsg; + sqlite3InitCallback( initData, 3, azArg, null ); + if ( initData.rc != 0 ) + { + rc = initData.rc; + goto error_out; + } + pTab = sqlite3FindTable( db, zMasterName, db.aDb[iDb].zName ); + if ( ALWAYS( pTab ) ) + { + pTab.tabFlags |= TF_Readonly; + } - /* If there is not already a read-only (or read-write) transaction opened - ** on the b-tree database, open one now. If a transaction is opened, it - ** will be closed before this function returns. */ - sqlite3BtreeEnter(pDb.pBt); - if (!sqlite3BtreeIsInReadTrans(pDb.pBt)) { - rc = sqlite3BtreeBeginTrans(pDb.pBt, 0); - if (rc != SQLITE_OK) { + /* Create a cursor to hold the database open + */ + pDb = db.aDb[iDb]; + if ( pDb.pBt == null ) + { + if ( OMIT_TEMPDB == 0 && ALWAYS( iDb == 1 ) ) + { + DbSetProperty( db, 1, DB_SchemaLoaded ); + } + return SQLITE_OK; + } + + /* If there is not already a read-only (or read-write) transaction opened + ** on the b-tree database, open one now. If a transaction is opened, it + ** will be closed before this function returns. */ + sqlite3BtreeEnter( pDb.pBt ); + if ( !sqlite3BtreeIsInReadTrans( pDb.pBt ) ) + { + rc = sqlite3BtreeBeginTrans( pDb.pBt, 0 ); + if ( rc != SQLITE_OK ) + { #if SQLITE_OMIT_WAL - if (pDb.pBt.pBt.pSchema.file_format == 2) - sqlite3SetString(ref pzErrMsg, db, "%s (wal format detected)", sqlite3ErrStr(rc)); - else - sqlite3SetString(ref pzErrMsg, db, "%s", sqlite3ErrStr(rc)); + if (pDb.pBt.pBt.pSchema.file_format == 2) + sqlite3SetString( ref pzErrMsg, db, "%s (wal format detected)", sqlite3ErrStr( rc ) ); + else + sqlite3SetString( ref pzErrMsg, db, "%s", sqlite3ErrStr( rc ) ); #else sqlite3SetString( ref pzErrMsg, db, "%s", sqlite3ErrStr( rc ) ); #endif - goto initone_error_out; - } - openedTransaction = 1; - } + goto initone_error_out; + } + openedTransaction = 1; + } - /* Get the database meta information. - ** - ** Meta values are as follows: - ** meta[0] Schema cookie. Changes with each schema change. - ** meta[1] File format of schema layer. - ** meta[2] Size of the page cache. - ** meta[3] Largest rootpage (auto/incr_vacuum mode) - ** meta[4] Db text encoding. 1:UTF-8 2:UTF-16LE 3:UTF-16BE - ** meta[5] User version - ** meta[6] Incremental vacuum mode - ** meta[7] unused - ** meta[8] unused - ** meta[9] unused - ** - ** Note: The #defined SQLITE_UTF* symbols in sqliteInt.h correspond to - ** the possible values of meta[BTREE_TEXT_ENCODING-1]. - */ - for (i = 0; i < ArraySize(meta); i++) { - sqlite3BtreeGetMeta(pDb.pBt, i + 1, ref meta[i]); - } - pDb.pSchema.schema_cookie = (int)meta[BTREE_SCHEMA_VERSION - 1]; - - /* If opening a non-empty database, check the text encoding. For the - ** main database, set sqlite3.enc to the encoding of the main database. - ** For an attached db, it is an error if the encoding is not the same - ** as sqlite3.enc. - */ - if (meta[BTREE_TEXT_ENCODING - 1] != 0) { /* text encoding */ - if (iDb == 0) { - u8 encoding; - /* If opening the main database, set ENC(db). */ - encoding = (u8)(meta[BTREE_TEXT_ENCODING - 1] & 3); - if (encoding == 0) - encoding = SQLITE_UTF8; - db.aDb[0].pSchema.enc = encoding; //ENC( db ) = encoding; - db.pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 0); - } else { - /* If opening an attached database, the encoding much match ENC(db) */ - if (meta[BTREE_TEXT_ENCODING - 1] != ENC(db)) { - sqlite3SetString(ref pzErrMsg, db, "attached databases must use the same" + - " text encoding as main database"); - rc = SQLITE_ERROR; - goto initone_error_out; - } - } - } else { - DbSetProperty(db, iDb, DB_Empty); - } - pDb.pSchema.enc = ENC(db); - - if (pDb.pSchema.cache_size == 0) { - size = sqlite3AbsInt32((int)meta[BTREE_DEFAULT_CACHE_SIZE - 1]); - if (size == 0) { - size = SQLITE_DEFAULT_CACHE_SIZE; - } - pDb.pSchema.cache_size = size; - sqlite3BtreeSetCacheSize(pDb.pBt, pDb.pSchema.cache_size); - } + /* Get the database meta information. + ** + ** Meta values are as follows: + ** meta[0] Schema cookie. Changes with each schema change. + ** meta[1] File format of schema layer. + ** meta[2] Size of the page cache. + ** meta[3] Largest rootpage (auto/incr_vacuum mode) + ** meta[4] Db text encoding. 1:UTF-8 2:UTF-16LE 3:UTF-16BE + ** meta[5] User version + ** meta[6] Incremental vacuum mode + ** meta[7] unused + ** meta[8] unused + ** meta[9] unused + ** + ** Note: The #defined SQLITE_UTF* symbols in sqliteInt.h correspond to + ** the possible values of meta[BTREE_TEXT_ENCODING-1]. + */ + for ( i = 0; i < ArraySize( meta ); i++ ) + { + sqlite3BtreeGetMeta( pDb.pBt, i + 1, ref meta[i] ); + } + pDb.pSchema.schema_cookie = (int)meta[BTREE_SCHEMA_VERSION - 1]; - /* - ** file_format==1 Version 3.0.0. - ** file_format==2 Version 3.1.3. // ALTER TABLE ADD COLUMN - ** file_format==3 Version 3.1.4. // ditto but with non-NULL defaults - ** file_format==4 Version 3.3.0. // DESC indices. Boolean constants - */ - pDb.pSchema.file_format = (u8)meta[BTREE_FILE_FORMAT - 1]; - if (pDb.pSchema.file_format == 0) { - pDb.pSchema.file_format = 1; - } - if (pDb.pSchema.file_format > SQLITE_MAX_FILE_FORMAT) { - sqlite3SetString(ref pzErrMsg, db, "unsupported file format"); - rc = SQLITE_ERROR; - goto initone_error_out; - } + /* If opening a non-empty database, check the text encoding. For the + ** main database, set sqlite3.enc to the encoding of the main database. + ** For an attached db, it is an error if the encoding is not the same + ** as sqlite3.enc. + */ + if ( meta[BTREE_TEXT_ENCODING - 1] != 0 ) + { /* text encoding */ + if ( iDb == 0 ) + { + u8 encoding; + /* If opening the main database, set ENC(db). */ + encoding = (u8)( meta[BTREE_TEXT_ENCODING - 1] & 3 ); + if ( encoding == 0 ) + encoding = SQLITE_UTF8; + db.aDb[0].pSchema.enc = encoding; //ENC( db ) = encoding; + db.pDfltColl = sqlite3FindCollSeq( db, SQLITE_UTF8, "BINARY", 0 ); + } + else + { + /* If opening an attached database, the encoding much match ENC(db) */ + if ( meta[BTREE_TEXT_ENCODING - 1] != ENC( db ) ) + { + sqlite3SetString( ref pzErrMsg, db, "attached databases must use the same" + + " text encoding as main database" ); + rc = SQLITE_ERROR; + goto initone_error_out; + } + } + } + else + { + DbSetProperty( db, iDb, DB_Empty ); + } + pDb.pSchema.enc = ENC( db ); - /* Ticket #2804: When we open a database in the newer file format, - ** clear the legacy_file_format pragma flag so that a VACUUM will - ** not downgrade the database and thus invalidate any descending - ** indices that the user might have created. - */ - if (iDb == 0 && meta[BTREE_FILE_FORMAT - 1] >= 4) { - db.flags &= ~SQLITE_LegacyFileFmt; - } + if ( pDb.pSchema.cache_size == 0 ) + { + size = sqlite3AbsInt32((int)meta[BTREE_DEFAULT_CACHE_SIZE - 1]); + if ( size == 0 ) + { + size = SQLITE_DEFAULT_CACHE_SIZE; + } + pDb.pSchema.cache_size = size; + sqlite3BtreeSetCacheSize( pDb.pBt, pDb.pSchema.cache_size ); + } - /* Read the schema information out of the schema tables - */ - Debug.Assert(db.init.busy != 0); - { - string zSql; - zSql = sqlite3MPrintf(db, - "SELECT name, rootpage, sql FROM '%q'.%s ORDER BY rowid", - db.aDb[iDb].zName, zMasterName); + /* + ** file_format==1 Version 3.0.0. + ** file_format==2 Version 3.1.3. // ALTER TABLE ADD COLUMN + ** file_format==3 Version 3.1.4. // ditto but with non-NULL defaults + ** file_format==4 Version 3.3.0. // DESC indices. Boolean constants + */ + pDb.pSchema.file_format = (u8)meta[BTREE_FILE_FORMAT - 1]; + if ( pDb.pSchema.file_format == 0 ) + { + pDb.pSchema.file_format = 1; + } + if ( pDb.pSchema.file_format > SQLITE_MAX_FILE_FORMAT ) + { + sqlite3SetString( ref pzErrMsg, db, "unsupported file format" ); + rc = SQLITE_ERROR; + goto initone_error_out; + } + + /* Ticket #2804: When we open a database in the newer file format, + ** clear the legacy_file_format pragma flag so that a VACUUM will + ** not downgrade the database and thus invalidate any descending + ** indices that the user might have created. + */ + if ( iDb == 0 && meta[BTREE_FILE_FORMAT - 1] >= 4 ) + { + db.flags &= ~SQLITE_LegacyFileFmt; + } + + /* Read the schema information out of the schema tables + */ + Debug.Assert( db.init.busy != 0 ); + { + string zSql; + zSql = sqlite3MPrintf( db, + "SELECT name, rootpage, sql FROM '%q'.%s ORDER BY rowid", + db.aDb[iDb].zName, zMasterName ); #if !SQLITE_OMIT_AUTHORIZATION { int (*xAuth)(void*,int,const char*,const char*,const char*,const char*); xAuth = db.xAuth; db.xAuth = 0; #endif - rc = sqlite3_exec(db, zSql, (dxCallback)sqlite3InitCallback, initData, 0); - pzErrMsg = initData.pzErrMsg; + rc = sqlite3_exec( db, zSql, (dxCallback)sqlite3InitCallback, initData, 0 ); + pzErrMsg = initData.pzErrMsg; #if !SQLITE_OMIT_AUTHORIZATION db.xAuth = xAuth; } #endif - if (rc == SQLITE_OK) - rc = initData.rc; - sqlite3DbFree(db, ref zSql); + if ( rc == SQLITE_OK ) + rc = initData.rc; + sqlite3DbFree( db, ref zSql ); #if !SQLITE_OMIT_ANALYZE - if (rc == SQLITE_OK) { - sqlite3AnalysisLoad(db, iDb); - } + if ( rc == SQLITE_OK ) + { + sqlite3AnalysisLoad( db, iDb ); + } #endif - } - //if ( db.mallocFailed != 0 ) - //{ - // rc = SQLITE_NOMEM; - // sqlite3ResetInternalSchema( db, -1 ); - //} - if (rc == SQLITE_OK || (db.flags & SQLITE_RecoveryMode) != 0) { - /* Black magic: If the SQLITE_RecoveryMode flag is set, then consider - ** the schema loaded, even if errors occurred. In this situation the - ** current sqlite3_prepare() operation will fail, but the following one - ** will attempt to compile the supplied statement against whatever subset - ** of the schema was loaded before the error occurred. The primary - ** purpose of this is to allow access to the sqlite_master table - ** even when its contents have been corrupted. - */ - DbSetProperty(db, iDb, DB_SchemaLoaded); - rc = SQLITE_OK; - } - /* Jump here for an error that occurs after successfully allocating - ** curMain and calling sqlite3BtreeEnter(). For an error that occurs - ** before that point, jump to error_out. + } + //if ( db.mallocFailed != 0 ) + //{ + // rc = SQLITE_NOMEM; + // sqlite3ResetInternalSchema( db, -1 ); + //} + if ( rc == SQLITE_OK || ( db.flags & SQLITE_RecoveryMode ) != 0 ) + { + /* Black magic: If the SQLITE_RecoveryMode flag is set, then consider + ** the schema loaded, even if errors occurred. In this situation the + ** current sqlite3_prepare() operation will fail, but the following one + ** will attempt to compile the supplied statement against whatever subset + ** of the schema was loaded before the error occurred. The primary + ** purpose of this is to allow access to the sqlite_master table + ** even when its contents have been corrupted. */ - initone_error_out: - if (openedTransaction != 0) { - sqlite3BtreeCommit(pDb.pBt); - } - sqlite3BtreeLeave(pDb.pBt); + DbSetProperty( db, iDb, DB_SchemaLoaded ); + rc = SQLITE_OK; + } +/* Jump here for an error that occurs after successfully allocating +** curMain and calling sqlite3BtreeEnter(). For an error that occurs +** before that point, jump to error_out. +*/ +initone_error_out: + if ( openedTransaction != 0 ) + { + sqlite3BtreeCommit( pDb.pBt ); + } + sqlite3BtreeLeave( pDb.pBt ); - error_out: - if (rc == SQLITE_NOMEM || rc == SQLITE_IOERR_NOMEM) { - // db.mallocFailed = 1; - } - return rc; - } +error_out: + if ( rc == SQLITE_NOMEM || rc == SQLITE_IOERR_NOMEM ) + { + // db.mallocFailed = 1; + } + return rc; + } - /* - ** Initialize all database files - the main database file, the file - ** used to store temporary tables, and any additional database files - ** created using ATTACH statements. Return a success code. If an - ** error occurs, write an error message into pzErrMsg. - ** - ** After a database is initialized, the DB_SchemaLoaded bit is set - ** bit is set in the flags field of the Db structure. If the database - ** file was of zero-length, then the DB_Empty flag is also set. - */ - static int sqlite3Init(sqlite3 db, ref string pzErrMsg) { - int i, rc; - bool commit_internal = !((db.flags & SQLITE_InternChanges) != 0); - - Debug.Assert(sqlite3_mutex_held(db.mutex)); - rc = SQLITE_OK; - db.init.busy = 1; - for (i = 0; rc == SQLITE_OK && i < db.nDb; i++) { - if (DbHasProperty(db, i, DB_SchemaLoaded) || i == 1) - continue; - rc = sqlite3InitOne(db, i, ref pzErrMsg); - if (rc != 0) { - sqlite3ResetInternalSchema(db, i); - } - } + /* + ** Initialize all database files - the main database file, the file + ** used to store temporary tables, and any additional database files + ** created using ATTACH statements. Return a success code. If an + ** error occurs, write an error message into pzErrMsg. + ** + ** After a database is initialized, the DB_SchemaLoaded bit is set + ** bit is set in the flags field of the Db structure. If the database + ** file was of zero-length, then the DB_Empty flag is also set. + */ + static int sqlite3Init( sqlite3 db, ref string pzErrMsg ) + { + int i, rc; + bool commit_internal = !( ( db.flags & SQLITE_InternChanges ) != 0 ); + + Debug.Assert( sqlite3_mutex_held( db.mutex ) ); + rc = SQLITE_OK; + db.init.busy = 1; + for ( i = 0; rc == SQLITE_OK && i < db.nDb; i++ ) + { + if ( DbHasProperty( db, i, DB_SchemaLoaded ) || i == 1 ) + continue; + rc = sqlite3InitOne( db, i, ref pzErrMsg ); + if ( rc != 0 ) + { + sqlite3ResetInternalSchema( db, i ); + } + } - /* Once all the other databases have been initialised, load the schema - ** for the TEMP database. This is loaded last, as the TEMP database - ** schema may contain references to objects in other databases. - */ + /* Once all the other databases have been initialised, load the schema + ** for the TEMP database. This is loaded last, as the TEMP database + ** schema may contain references to objects in other databases. + */ #if !SQLITE_OMIT_TEMPDB - if (rc == SQLITE_OK && ALWAYS(db.nDb > 1) - && !DbHasProperty(db, 1, DB_SchemaLoaded)) { - rc = sqlite3InitOne(db, 1, ref pzErrMsg); - if (rc != 0) { - sqlite3ResetInternalSchema(db, 1); - } - } + if ( rc == SQLITE_OK && ALWAYS( db.nDb > 1 ) + && !DbHasProperty( db, 1, DB_SchemaLoaded ) ) + { + rc = sqlite3InitOne( db, 1, ref pzErrMsg ); + if ( rc != 0 ) + { + sqlite3ResetInternalSchema( db, 1 ); + } + } #endif - db.init.busy = 0; - if (rc == SQLITE_OK && commit_internal) { - sqlite3CommitInternalChanges(db); - } + db.init.busy = 0; + if ( rc == SQLITE_OK && commit_internal ) + { + sqlite3CommitInternalChanges( db ); + } + + return rc; + } - return rc; + /* + ** This routine is a no-op if the database schema is already initialised. + ** Otherwise, the schema is loaded. An error code is returned. + */ + static int sqlite3ReadSchema( Parse pParse ) + { + int rc = SQLITE_OK; + sqlite3 db = pParse.db; + Debug.Assert( sqlite3_mutex_held( db.mutex ) ); + if ( 0 == db.init.busy ) + { + rc = sqlite3Init( db, ref pParse.zErrMsg ); + } + if ( rc != SQLITE_OK ) + { + pParse.rc = rc; + pParse.nErr++; + } + return rc; + } + + + /* + ** Check schema cookies in all databases. If any cookie is out + ** of date set pParse->rc to SQLITE_SCHEMA. If all schema cookies + ** make no changes to pParse->rc. + */ + static void schemaIsValid( Parse pParse ) + { + sqlite3 db = pParse.db; + int iDb; + int rc; + u32 cookie = 0; + + Debug.Assert( pParse.checkSchema != 0 ); + Debug.Assert( sqlite3_mutex_held( db.mutex ) ); + for ( iDb = 0; iDb < db.nDb; iDb++ ) + { + int openedTransaction = 0; /* True if a transaction is opened */ + Btree pBt = db.aDb[iDb].pBt; /* Btree database to read cookie from */ + if ( pBt == null ) + continue; + + /* If there is not already a read-only (or read-write) transaction opened + ** on the b-tree database, open one now. If a transaction is opened, it + ** will be closed immediately after reading the meta-value. */ + if ( !sqlite3BtreeIsInReadTrans( pBt ) ) + { + rc = sqlite3BtreeBeginTrans( pBt, 0 ); + //if ( rc == SQLITE_NOMEM || rc == SQLITE_IOERR_NOMEM ) + //{ + // db.mallocFailed = 1; + //} + if ( rc != SQLITE_OK ) + return; + openedTransaction = 1; } - /* - ** This routine is a no-op if the database schema is already initialised. - ** Otherwise, the schema is loaded. An error code is returned. - */ - static int sqlite3ReadSchema(Parse pParse) { - int rc = SQLITE_OK; - sqlite3 db = pParse.db; - Debug.Assert(sqlite3_mutex_held(db.mutex)); - if (0 == db.init.busy) { - rc = sqlite3Init(db, ref pParse.zErrMsg); - } - if (rc != SQLITE_OK) { - pParse.rc = rc; - pParse.nErr++; - } - return rc; + /* Read the schema cookie from the database. If it does not match the + ** value stored as part of the in-memory schema representation, + ** set Parse.rc to SQLITE_SCHEMA. */ + sqlite3BtreeGetMeta( pBt, BTREE_SCHEMA_VERSION, ref cookie ); + Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); + if ( cookie != db.aDb[iDb].pSchema.schema_cookie ) + { + sqlite3ResetInternalSchema( db, iDb ); + pParse.rc = SQLITE_SCHEMA; } + /* Close the transaction, if one was opened. */ + if ( openedTransaction != 0 ) + { + sqlite3BtreeCommit( pBt ); + } + } + } - /* - ** Check schema cookies in all databases. If any cookie is out - ** of date set pParse->rc to SQLITE_SCHEMA. If all schema cookies - ** make no changes to pParse->rc. - */ - static void schemaIsValid(Parse pParse) { - sqlite3 db = pParse.db; - int iDb; - int rc; - u32 cookie = 0; - - Debug.Assert(pParse.checkSchema != 0); - Debug.Assert(sqlite3_mutex_held(db.mutex)); - for (iDb = 0; iDb < db.nDb; iDb++) { - int openedTransaction = 0; /* True if a transaction is opened */ - Btree pBt = db.aDb[iDb].pBt; /* Btree database to read cookie from */ - if (pBt == null) - continue; - - /* If there is not already a read-only (or read-write) transaction opened - ** on the b-tree database, open one now. If a transaction is opened, it - ** will be closed immediately after reading the meta-value. */ - if (!sqlite3BtreeIsInReadTrans(pBt)) { - rc = sqlite3BtreeBeginTrans(pBt, 0); - //if ( rc == SQLITE_NOMEM || rc == SQLITE_IOERR_NOMEM ) - //{ - // db.mallocFailed = 1; - //} - if (rc != SQLITE_OK) - return; - openedTransaction = 1; - } - - /* Read the schema cookie from the database. If it does not match the - ** value stored as part of the in-memory schema representation, - ** set Parse.rc to SQLITE_SCHEMA. */ - sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, ref cookie); - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); - if (cookie != db.aDb[iDb].pSchema.schema_cookie) { - sqlite3ResetInternalSchema(db, iDb); - pParse.rc = SQLITE_SCHEMA; - } - - /* Close the transaction, if one was opened. */ - if (openedTransaction != 0) { - sqlite3BtreeCommit(pBt); - } - } + /* + ** Convert a schema pointer into the iDb index that indicates + ** which database file in db.aDb[] the schema refers to. + ** + ** If the same database is attached more than once, the first + ** attached database is returned. + */ + static int sqlite3SchemaToIndex( sqlite3 db, Schema pSchema ) + { + int i = -1000000; + + /* If pSchema is NULL, then return -1000000. This happens when code in + ** expr.c is trying to resolve a reference to a transient table (i.e. one + ** created by a sub-select). In this case the return value of this + ** function should never be used. + ** + ** We return -1000000 instead of the more usual -1 simply because using + ** -1000000 as the incorrect index into db->aDb[] is much + ** more likely to cause a segfault than -1 (of course there are assert() + ** statements too, but it never hurts to play the odds). + */ + Debug.Assert( sqlite3_mutex_held( db.mutex ) ); + if ( pSchema != null ) + { + for ( i = 0; ALWAYS( i < db.nDb ); i++ ) + { + if ( db.aDb[i].pSchema == pSchema ) + { + break; + } } + Debug.Assert( i >= 0 && i < db.nDb ); + } + return i; + } - /* - ** Convert a schema pointer into the iDb index that indicates - ** which database file in db.aDb[] the schema refers to. - ** - ** If the same database is attached more than once, the first - ** attached database is returned. - */ - static int sqlite3SchemaToIndex(sqlite3 db, Schema pSchema) { - int i = -1000000; - - /* If pSchema is NULL, then return -1000000. This happens when code in - ** expr.c is trying to resolve a reference to a transient table (i.e. one - ** created by a sub-select). In this case the return value of this - ** function should never be used. - ** - ** We return -1000000 instead of the more usual -1 simply because using - ** -1000000 as the incorrect index into db->aDb[] is much - ** more likely to cause a segfault than -1 (of course there are assert() - ** statements too, but it never hurts to play the odds). - */ - Debug.Assert(sqlite3_mutex_held(db.mutex)); - if (pSchema != null) { - for (i = 0; ALWAYS(i < db.nDb); i++) { - if (db.aDb[i].pSchema == pSchema) { - break; - } - } - Debug.Assert(i >= 0 && i < db.nDb); - } - return i; + /* + ** Compile the UTF-8 encoded SQL statement zSql into a statement handle. + */ + static int sqlite3Prepare( + sqlite3 db, /* Database handle. */ + string zSql, /* UTF-8 encoded SQL statement. */ + int nBytes, /* Length of zSql in bytes. */ + int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */ + Vdbe pReprepare, /* VM being reprepared */ + ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ + ref string pzTail /* OUT: End of parsed string */ + ) + { + Parse pParse; /* Parsing context */ + string zErrMsg = ""; /* Error message */ + int rc = SQLITE_OK; /* Result code */ + int i; /* Loop counter */ + + ppStmt = null; + pzTail = null; + + /* Allocate the parsing context */ + pParse = new Parse();//sqlite3StackAllocZero(db, sizeof(*pParse)); + //if ( pParse == null ) + //{ + // rc = SQLITE_NOMEM; + // goto end_prepare; + //} + pParse.pReprepare = pReprepare; + pParse.sLastToken.z = ""; + + // assert( ppStmt && *ppStmt==0 ); + //Debug.Assert( 0 == db.mallocFailed ); + Debug.Assert( sqlite3_mutex_held( db.mutex ) ); + + /* Check to verify that it is possible to get a read lock on all + ** database schemas. The inability to get a read lock indicates that + ** some other database connection is holding a write-lock, which in + ** turn means that the other connection has made uncommitted changes + ** to the schema. + ** + ** Were we to proceed and prepare the statement against the uncommitted + ** schema changes and if those schema changes are subsequently rolled + ** back and different changes are made in their place, then when this + ** prepared statement goes to run the schema cookie would fail to detect + ** the schema change. Disaster would follow. + ** + ** This thread is currently holding mutexes on all Btrees (because + ** of the sqlite3BtreeEnterAll() in sqlite3LockAndPrepare()) so it + ** is not possible for another thread to start a new schema change + ** while this routine is running. Hence, we do not need to hold + ** locks on the schema, we just need to make sure nobody else is + ** holding them. + ** + ** Note that setting READ_UNCOMMITTED overrides most lock detection, + ** but it does *not* override schema lock detection, so this all still + ** works even if READ_UNCOMMITTED is set. + */ + for ( i = 0; i < db.nDb; i++ ) + { + Btree pBt = db.aDb[i].pBt; + if ( pBt != null ) + { + Debug.Assert( sqlite3BtreeHoldsMutex( pBt ) ); + rc = sqlite3BtreeSchemaLocked( pBt ); + if ( rc != 0 ) + { + string zDb = db.aDb[i].zName; + sqlite3Error( db, rc, "database schema is locked: %s", zDb ); + testcase( db.flags & SQLITE_ReadUncommitted ); + goto end_prepare; + } } + } - /* - ** Compile the UTF-8 encoded SQL statement zSql into a statement handle. - */ - static int sqlite3Prepare( - sqlite3 db, /* Database handle. */ - string zSql, /* UTF-8 encoded SQL statement. */ - int nBytes, /* Length of zSql in bytes. */ - int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */ - Vdbe pReprepare, /* VM being reprepared */ - ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ - ref string pzTail /* OUT: End of parsed string */ - ) { - Parse pParse; /* Parsing context */ - string zErrMsg = ""; /* Error message */ - int rc = SQLITE_OK; /* Result code */ - int i; /* Loop counter */ - - ppStmt = null; - pzTail = null; - - /* Allocate the parsing context */ - pParse = new Parse();//sqlite3StackAllocZero(db, sizeof(*pParse)); - //if ( pParse == null ) - //{ - // rc = SQLITE_NOMEM; - // goto end_prepare; - //} - pParse.pReprepare = pReprepare; - pParse.sLastToken.z = ""; - - // assert( ppStmt && *ppStmt==0 ); - //Debug.Assert( 0 == db.mallocFailed ); - Debug.Assert(sqlite3_mutex_held(db.mutex)); - - /* Check to verify that it is possible to get a read lock on all - ** database schemas. The inability to get a read lock indicates that - ** some other database connection is holding a write-lock, which in - ** turn means that the other connection has made uncommitted changes - ** to the schema. - ** - ** Were we to proceed and prepare the statement against the uncommitted - ** schema changes and if those schema changes are subsequently rolled - ** back and different changes are made in their place, then when this - ** prepared statement goes to run the schema cookie would fail to detect - ** the schema change. Disaster would follow. - ** - ** This thread is currently holding mutexes on all Btrees (because - ** of the sqlite3BtreeEnterAll() in sqlite3LockAndPrepare()) so it - ** is not possible for another thread to start a new schema change - ** while this routine is running. Hence, we do not need to hold - ** locks on the schema, we just need to make sure nobody else is - ** holding them. - ** - ** Note that setting READ_UNCOMMITTED overrides most lock detection, - ** but it does *not* override schema lock detection, so this all still - ** works even if READ_UNCOMMITTED is set. - */ - for (i = 0; i < db.nDb; i++) { - Btree pBt = db.aDb[i].pBt; - if (pBt != null) { - Debug.Assert(sqlite3BtreeHoldsMutex(pBt)); - rc = sqlite3BtreeSchemaLocked(pBt); - if (rc != 0) { - string zDb = db.aDb[i].zName; - sqlite3Error(db, rc, "database schema is locked: %s", zDb); - testcase(db.flags & SQLITE_ReadUncommitted); - goto end_prepare; - } - } - } + sqlite3VtabUnlockList( db ); - sqlite3VtabUnlockList(db); - - pParse.db = db; - pParse.nQueryLoop = (double)1; - if (nBytes >= 0 && (nBytes == 0 || zSql[nBytes - 1] != 0)) { - string zSqlCopy; - int mxLen = db.aLimit[SQLITE_LIMIT_SQL_LENGTH]; - testcase(nBytes == mxLen); - testcase(nBytes == mxLen + 1); - if (nBytes > mxLen) { - sqlite3Error(db, SQLITE_TOOBIG, "statement too long"); - rc = sqlite3ApiExit(db, SQLITE_TOOBIG); - goto end_prepare; - } - zSqlCopy = zSql.Substring(0, nBytes);// sqlite3DbStrNDup(db, zSql, nBytes); - if (zSqlCopy != null) { - sqlite3RunParser(pParse, zSqlCopy, ref zErrMsg); - sqlite3DbFree(db, ref zSqlCopy); - //pParse->zTail = &zSql[pParse->zTail-zSqlCopy]; - } else { - //pParse->zTail = &zSql[nBytes]; - } - } else { - sqlite3RunParser(pParse, zSql, ref zErrMsg); - } - Debug.Assert(1 == (int)pParse.nQueryLoop); + pParse.db = db; + pParse.nQueryLoop = (double)1; + if ( nBytes >= 0 && ( nBytes == 0 || zSql[nBytes - 1] != 0 ) ) + { + string zSqlCopy; + int mxLen = db.aLimit[SQLITE_LIMIT_SQL_LENGTH]; + testcase( nBytes == mxLen ); + testcase( nBytes == mxLen + 1 ); + if ( nBytes > mxLen ) + { + sqlite3Error( db, SQLITE_TOOBIG, "statement too long" ); + rc = sqlite3ApiExit( db, SQLITE_TOOBIG ); + goto end_prepare; + } + zSqlCopy = zSql.Substring( 0, nBytes );// sqlite3DbStrNDup(db, zSql, nBytes); + if ( zSqlCopy != null ) + { + sqlite3RunParser( pParse, zSqlCopy, ref zErrMsg ); + sqlite3DbFree( db, ref zSqlCopy ); + //pParse->zTail = &zSql[pParse->zTail-zSqlCopy]; + } + else + { + //pParse->zTail = &zSql[nBytes]; + } + } + else + { + sqlite3RunParser( pParse, zSql, ref zErrMsg ); + } + Debug.Assert( 1 == (int)pParse.nQueryLoop ); - //if ( db.mallocFailed != 0 ) - //{ - // pParse.rc = SQLITE_NOMEM; - //} - if (pParse.rc == SQLITE_DONE) - pParse.rc = SQLITE_OK; - if (pParse.checkSchema != 0) { - schemaIsValid(pParse); - } - //if ( db.mallocFailed != 0 ) - //{ - // pParse.rc = SQLITE_NOMEM; - //} - //if (pzTail != null) - { - pzTail = pParse.zTail == null ? "" : pParse.zTail.ToString(); - } - rc = pParse.rc; + //if ( db.mallocFailed != 0 ) + //{ + // pParse.rc = SQLITE_NOMEM; + //} + if ( pParse.rc == SQLITE_DONE ) + pParse.rc = SQLITE_OK; + if ( pParse.checkSchema != 0 ) + { + schemaIsValid( pParse ); + } + //if ( db.mallocFailed != 0 ) + //{ + // pParse.rc = SQLITE_NOMEM; + //} + //if (pzTail != null) + { + pzTail = pParse.zTail == null ? "" : pParse.zTail.ToString(); + } + rc = pParse.rc; #if !SQLITE_OMIT_EXPLAIN - if (rc == SQLITE_OK && pParse.pVdbe != null && pParse.explain != 0) { - string[] azColName = new string[] { + if ( rc == SQLITE_OK && pParse.pVdbe != null && pParse.explain != 0 ) + { + string[] azColName = new string[] { "addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment", "selectid", "order", "from", "detail" }; - int iFirst, mx; - if (pParse.explain == 2) { - sqlite3VdbeSetNumCols(pParse.pVdbe, 4); - iFirst = 8; - mx = 12; - } else { - sqlite3VdbeSetNumCols(pParse.pVdbe, 8); - iFirst = 0; - mx = 8; - } - for (i = iFirst; i < mx; i++) { - sqlite3VdbeSetColName(pParse.pVdbe, i - iFirst, COLNAME_NAME, - azColName[i], SQLITE_STATIC); - } - } + int iFirst, mx; + if ( pParse.explain == 2 ) + { + sqlite3VdbeSetNumCols( pParse.pVdbe, 4 ); + iFirst = 8; + mx = 12; + } + else + { + sqlite3VdbeSetNumCols( pParse.pVdbe, 8 ); + iFirst = 0; + mx = 8; + } + for ( i = iFirst; i < mx; i++ ) + { + sqlite3VdbeSetColName( pParse.pVdbe, i - iFirst, COLNAME_NAME, + azColName[i], SQLITE_STATIC ); + } + } #endif - Debug.Assert(db.init.busy == 0 || saveSqlFlag == 0); - if (db.init.busy == 0) { - Vdbe pVdbe = pParse.pVdbe; - sqlite3VdbeSetSql(pVdbe, zSql, (int)(zSql.Length - (pParse.zTail == null ? 0 : pParse.zTail.Length)), saveSqlFlag); - } - if (pParse.pVdbe != null && (rc != SQLITE_OK /*|| db.mallocFailed != 0 */ )) { - sqlite3VdbeFinalize(ref pParse.pVdbe); - //Debug.Assert( ppStmt == null ); - } else { - ppStmt = pParse.pVdbe; - } + Debug.Assert( db.init.busy == 0 || saveSqlFlag == 0 ); + if ( db.init.busy == 0 ) + { + Vdbe pVdbe = pParse.pVdbe; + sqlite3VdbeSetSql( pVdbe, zSql, (int)( zSql.Length - ( pParse.zTail == null ? 0 : pParse.zTail.Length ) ), saveSqlFlag ); + } + if ( pParse.pVdbe != null && ( rc != SQLITE_OK /*|| db.mallocFailed != 0 */ ) ) + { + sqlite3VdbeFinalize( ref pParse.pVdbe ); + //Debug.Assert( ppStmt == null ); + } + else + { + ppStmt = pParse.pVdbe; + } - if (zErrMsg != "") { - sqlite3Error(db, rc, "%s", zErrMsg); - sqlite3DbFree(db, ref zErrMsg); - } else { - sqlite3Error(db, rc, 0); - } + if ( zErrMsg != "" ) + { + sqlite3Error( db, rc, "%s", zErrMsg ); + sqlite3DbFree( db, ref zErrMsg ); + } + else + { + sqlite3Error( db, rc, 0 ); + } - /* Delete any TriggerPrg structures allocated while parsing this statement. */ - while (pParse.pTriggerPrg != null) { - TriggerPrg pT = pParse.pTriggerPrg; - pParse.pTriggerPrg = pT.pNext; - sqlite3DbFree(db, ref pT); - } + /* Delete any TriggerPrg structures allocated while parsing this statement. */ + while ( pParse.pTriggerPrg != null ) + { + TriggerPrg pT = pParse.pTriggerPrg; + pParse.pTriggerPrg = pT.pNext; + sqlite3DbFree( db, ref pT ); + } - end_prepare: +end_prepare: - //sqlite3StackFree( db, pParse ); - rc = sqlite3ApiExit(db, rc); - Debug.Assert((rc & db.errMask) == rc); - return rc; - } + //sqlite3StackFree( db, pParse ); + rc = sqlite3ApiExit( db, rc ); + Debug.Assert( ( rc & db.errMask ) == rc ); + return rc; + } - //C# Version w/o End of Parsed String - static int sqlite3LockAndPrepare( - sqlite3 db, /* Database handle. */ - string zSql, /* UTF-8 encoded SQL statement. */ - int nBytes, /* Length of zSql in bytes. */ - int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */ - Vdbe pOld, /* VM being reprepared */ - ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ - int dummy /* OUT: End of parsed string */ - ) { - string sOut = null; - return sqlite3LockAndPrepare(db, zSql, nBytes, saveSqlFlag, pOld, ref ppStmt, ref sOut); - } + //C# Version w/o End of Parsed String + static int sqlite3LockAndPrepare( + sqlite3 db, /* Database handle. */ + string zSql, /* UTF-8 encoded SQL statement. */ + int nBytes, /* Length of zSql in bytes. */ + int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */ + Vdbe pOld, /* VM being reprepared */ + ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ + int dummy /* OUT: End of parsed string */ + ) + { + string sOut = null; + return sqlite3LockAndPrepare( db, zSql, nBytes, saveSqlFlag, pOld, ref ppStmt, ref sOut ); + } - static int sqlite3LockAndPrepare( - sqlite3 db, /* Database handle. */ - string zSql, /* UTF-8 encoded SQL statement. */ - int nBytes, /* Length of zSql in bytes. */ - int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */ - Vdbe pOld, /* VM being reprepared */ - ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ - ref string pzTail /* OUT: End of parsed string */ - ) { - int rc; - // assert( ppStmt!=0 ); - if (!sqlite3SafetyCheckOk(db)) { - ppStmt = null; - pzTail = null; - return SQLITE_MISUSE_BKPT(); - } - sqlite3_mutex_enter(db.mutex); - sqlite3BtreeEnterAll(db); - rc = sqlite3Prepare(db, zSql, nBytes, saveSqlFlag, pOld, ref ppStmt, ref pzTail); - if (rc == SQLITE_SCHEMA) { - sqlite3_finalize(ppStmt); - rc = sqlite3Prepare(db, zSql, nBytes, saveSqlFlag, pOld, ref ppStmt, ref pzTail); - } - sqlite3BtreeLeaveAll(db); - sqlite3_mutex_leave(db.mutex); - return rc; - } + static int sqlite3LockAndPrepare( + sqlite3 db, /* Database handle. */ + string zSql, /* UTF-8 encoded SQL statement. */ + int nBytes, /* Length of zSql in bytes. */ + int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */ + Vdbe pOld, /* VM being reprepared */ + ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ + ref string pzTail /* OUT: End of parsed string */ + ) + { + int rc; + // assert( ppStmt!=0 ); + if ( !sqlite3SafetyCheckOk( db ) ) + { + ppStmt = null; + pzTail = null; + return SQLITE_MISUSE_BKPT(); + } + sqlite3_mutex_enter( db.mutex ); + sqlite3BtreeEnterAll( db ); + rc = sqlite3Prepare( db, zSql, nBytes, saveSqlFlag, pOld, ref ppStmt, ref pzTail ); + if ( rc == SQLITE_SCHEMA ) + { + sqlite3_finalize( ppStmt ); + rc = sqlite3Prepare( db, zSql, nBytes, saveSqlFlag, pOld, ref ppStmt, ref pzTail ); + } + sqlite3BtreeLeaveAll( db ); + sqlite3_mutex_leave( db.mutex ); + return rc; + } - /* - ** Rerun the compilation of a statement after a schema change. - ** - ** If the statement is successfully recompiled, return SQLITE_OK. Otherwise, - ** if the statement cannot be recompiled because another connection has - ** locked the sqlite3_master table, return SQLITE_LOCKED. If any other error - ** occurs, return SQLITE_SCHEMA. - */ - static int sqlite3Reprepare(Vdbe p) { - int rc; - sqlite3_stmt pNew = new sqlite3_stmt(); - string zSql; - sqlite3 db; - - Debug.Assert(sqlite3_mutex_held(sqlite3VdbeDb(p).mutex)); - zSql = sqlite3_sql((sqlite3_stmt)p); - Debug.Assert(zSql != null); /* Reprepare only called for prepare_v2() statements */ - db = sqlite3VdbeDb(p); - Debug.Assert(sqlite3_mutex_held(db.mutex)); - rc = sqlite3LockAndPrepare(db, zSql, -1, 0, p, ref pNew, 0); - if (rc != 0) { - if (rc == SQLITE_NOMEM) { - // db.mallocFailed = 1; - } - Debug.Assert(pNew == null); - return rc; - } else { - Debug.Assert(pNew != null); - } - sqlite3VdbeSwap((Vdbe)pNew, p); - sqlite3TransferBindings(pNew, (sqlite3_stmt)p); - sqlite3VdbeResetStepResult((Vdbe)pNew); - sqlite3VdbeFinalize(ref pNew); - return SQLITE_OK; + /* + ** Rerun the compilation of a statement after a schema change. + ** + ** If the statement is successfully recompiled, return SQLITE_OK. Otherwise, + ** if the statement cannot be recompiled because another connection has + ** locked the sqlite3_master table, return SQLITE_LOCKED. If any other error + ** occurs, return SQLITE_SCHEMA. + */ + static int sqlite3Reprepare( Vdbe p ) + { + int rc; + sqlite3_stmt pNew = new sqlite3_stmt(); + string zSql; + sqlite3 db; + + Debug.Assert( sqlite3_mutex_held( sqlite3VdbeDb( p ).mutex ) ); + zSql = sqlite3_sql( (sqlite3_stmt)p ); + Debug.Assert( zSql != null ); /* Reprepare only called for prepare_v2() statements */ + db = sqlite3VdbeDb( p ); + Debug.Assert( sqlite3_mutex_held( db.mutex ) ); + rc = sqlite3LockAndPrepare( db, zSql, -1, 0, p, ref pNew, 0 ); + if ( rc != 0 ) + { + if ( rc == SQLITE_NOMEM ) + { + // db.mallocFailed = 1; } + Debug.Assert( pNew == null ); + return rc; + } + else + { + Debug.Assert( pNew != null ); + } + sqlite3VdbeSwap( (Vdbe)pNew, p ); + sqlite3TransferBindings( pNew, (sqlite3_stmt)p ); + sqlite3VdbeResetStepResult( (Vdbe)pNew ); + sqlite3VdbeFinalize( ref pNew ); + return SQLITE_OK; + } - //C# Overload for ignore error out - static public int sqlite3_prepare( - sqlite3 db, /* Database handle. */ - string zSql, /* UTF-8 encoded SQL statement. */ - int nBytes, /* Length of zSql in bytes. */ - ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ - int dummy /* OUT: End of parsed string */ - ) { - string sOut = null; - return sqlite3_prepare(db, zSql, nBytes, ref ppStmt, ref sOut); - } - static public int sqlite3_prepare( - sqlite3 db, /* Database handle. */ - StringBuilder zSql, /* UTF-8 encoded SQL statement. */ - int nBytes, /* Length of zSql in bytes. */ - ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ - int dummy /* OUT: End of parsed string */ - ) { - string sOut = null; - return sqlite3_prepare(db, zSql.ToString(), nBytes, ref ppStmt, ref sOut); - } - /* - ** Two versions of the official API. Legacy and new use. In the legacy - ** version, the original SQL text is not saved in the prepared statement - ** and so if a schema change occurs, SQLITE_SCHEMA is returned by - ** sqlite3_step(). In the new version, the original SQL text is retained - ** and the statement is automatically recompiled if an schema change - ** occurs. - */ - static public int sqlite3_prepare( - sqlite3 db, /* Database handle. */ - string zSql, /* UTF-8 encoded SQL statement. */ - int nBytes, /* Length of zSql in bytes. */ - ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ - ref string pzTail /* OUT: End of parsed string */ - ) { - int rc; - rc = sqlite3LockAndPrepare(db, zSql, nBytes, 0, null, ref ppStmt, ref pzTail); - Debug.Assert(rc == SQLITE_OK || ppStmt == null); /* VERIFY: F13021 */ - return rc; - } + //C# Overload for ignore error out + static public int sqlite3_prepare( + sqlite3 db, /* Database handle. */ + string zSql, /* UTF-8 encoded SQL statement. */ + int nBytes, /* Length of zSql in bytes. */ + ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ + int dummy /* OUT: End of parsed string */ + ) + { + string sOut = null; + return sqlite3_prepare( db, zSql, nBytes, ref ppStmt, ref sOut ); + } + static public int sqlite3_prepare( + sqlite3 db, /* Database handle. */ + StringBuilder zSql, /* UTF-8 encoded SQL statement. */ + int nBytes, /* Length of zSql in bytes. */ + ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ + int dummy /* OUT: End of parsed string */ + ) + { + string sOut = null; + return sqlite3_prepare(db, zSql.ToString(), nBytes, ref ppStmt, ref sOut); + } + /* + ** Two versions of the official API. Legacy and new use. In the legacy + ** version, the original SQL text is not saved in the prepared statement + ** and so if a schema change occurs, SQLITE_SCHEMA is returned by + ** sqlite3_step(). In the new version, the original SQL text is retained + ** and the statement is automatically recompiled if an schema change + ** occurs. + */ + static public int sqlite3_prepare( + sqlite3 db, /* Database handle. */ + string zSql, /* UTF-8 encoded SQL statement. */ + int nBytes, /* Length of zSql in bytes. */ + ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ + ref string pzTail /* OUT: End of parsed string */ + ) + { + int rc; + rc = sqlite3LockAndPrepare( db, zSql, nBytes, 0, null, ref ppStmt, ref pzTail ); + Debug.Assert( rc == SQLITE_OK || ppStmt == null ); /* VERIFY: F13021 */ + return rc; + } - public static int sqlite3_prepare_v2( - sqlite3 db, /* Database handle. */ - string zSql, /* UTF-8 encoded SQL statement. */ - int nBytes, /* Length of zSql in bytes. */ - ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ - int dummy /* ( No string passed) */ - ) { - string pzTail = null; - int rc; - rc = sqlite3LockAndPrepare(db, zSql, nBytes, 1, null, ref ppStmt, ref pzTail); - Debug.Assert(rc == SQLITE_OK || ppStmt == null); /* VERIFY: F13021 */ - return rc; - } + public static int sqlite3_prepare_v2( + sqlite3 db, /* Database handle. */ + string zSql, /* UTF-8 encoded SQL statement. */ + int nBytes, /* Length of zSql in bytes. */ + ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ + int dummy /* ( No string passed) */ + ) + { + string pzTail = null; + int rc; + rc = sqlite3LockAndPrepare( db, zSql, nBytes, 1, null, ref ppStmt, ref pzTail ); + Debug.Assert( rc == SQLITE_OK || ppStmt == null ); /* VERIFY: F13021 */ + return rc; + } - public static int sqlite3_prepare_v2( - sqlite3 db, /* Database handle. */ - string zSql, /* UTF-8 encoded SQL statement. */ - int nBytes, /* Length of zSql in bytes. */ - ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ - ref string pzTail /* OUT: End of parsed string */ - ) { - int rc; - rc = sqlite3LockAndPrepare(db, zSql, nBytes, 1, null, ref ppStmt, ref pzTail); - Debug.Assert(rc == SQLITE_OK || ppStmt == null); /* VERIFY: F13021 */ - return rc; - } + public static int sqlite3_prepare_v2( + sqlite3 db, /* Database handle. */ + string zSql, /* UTF-8 encoded SQL statement. */ + int nBytes, /* Length of zSql in bytes. */ + ref sqlite3_stmt ppStmt, /* OUT: A pointer to the prepared statement */ + ref string pzTail /* OUT: End of parsed string */ + ) + { + int rc; + rc = sqlite3LockAndPrepare( db, zSql, nBytes, 1, null, ref ppStmt, ref pzTail ); + Debug.Assert( rc == SQLITE_OK || ppStmt == null ); /* VERIFY: F13021 */ + return rc; + } #if !SQLITE_OMIT_UTF16 @@ -980,5 +1087,5 @@ public static int sqlite3_prepare16_v2( } #endif // * SQLITE_OMIT_UTF16 */ - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/printf_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/printf_c.cs index 7600f5202..6d4ea59eb 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/printf_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/printf_c.cs @@ -1,172 +1,178 @@ using System; using System.Diagnostics; +using System.Runtime.InteropServices; using System.Text; -namespace Community.CsharpSqlite { - using etByte = System.Boolean; - using i64 = System.Int64; - using LONGDOUBLE_TYPE = System.Double; - using u64 = System.UInt64; - using va_list = System.Object; +namespace Community.CsharpSqlite +{ + using etByte = System.Boolean; + using i64 = System.Int64; + using u64 = System.UInt64; + using LONGDOUBLE_TYPE = System.Double; + using sqlite_u3264 = System.UInt64; + using va_list = System.Object; - public partial class Sqlite3 { - /* - ** The "printf" code that follows dates from the 1980's. It is in - ** the public domain. The original comments are included here for - ** completeness. They are very out-of-date but might be useful as - ** an historical reference. Most of the "enhancements" have been backed - ** out so that the functionality is now the same as standard printf(). - ** - ************************************************************************** - ** - ** The following modules is an enhanced replacement for the "printf" subroutines - ** found in the standard C library. The following enhancements are - ** supported: - ** - ** + Additional functions. The standard set of "printf" functions - ** includes printf, fprintf, sprintf, vprintf, vfprintf, and - ** vsprintf. This module adds the following: - ** - ** * snprintf -- Works like sprintf, but has an extra argument - ** which is the size of the buffer written to. - ** - ** * mprintf -- Similar to sprintf. Writes output to memory - ** obtained from malloc. - ** - ** * xprintf -- Calls a function to dispose of output. - ** - ** * nprintf -- No output, but returns the number of characters - ** that would have been output by printf. - ** - ** * A v- version (ex: vsnprintf) of every function is also - ** supplied. - ** - ** + A few extensions to the formatting notation are supported: - ** - ** * The "=" flag (similar to "-") causes the output to be - ** be centered in the appropriately sized field. - ** - ** * The %b field outputs an integer in binary notation. - ** - ** * The %c field now accepts a precision. The character output - ** is repeated by the number of times the precision specifies. - ** - ** * The %' field works like %c, but takes as its character the - ** next character of the format string, instead of the next - ** argument. For example, printf("%.78'-") prints 78 minus - ** signs, the same as printf("%.78c",'-'). - ** - ** + When compiled using GCC on a SPARC, this version of printf is - ** faster than the library printf for SUN OS 4.1. - ** - ** + All functions are fully reentrant. - ** - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ - //#include "sqliteInt.h" + public partial class Sqlite3 + { + /* + ** The "printf" code that follows dates from the 1980's. It is in + ** the public domain. The original comments are included here for + ** completeness. They are very out-of-date but might be useful as + ** an historical reference. Most of the "enhancements" have been backed + ** out so that the functionality is now the same as standard printf(). + ** + ************************************************************************** + ** + ** The following modules is an enhanced replacement for the "printf" subroutines + ** found in the standard C library. The following enhancements are + ** supported: + ** + ** + Additional functions. The standard set of "printf" functions + ** includes printf, fprintf, sprintf, vprintf, vfprintf, and + ** vsprintf. This module adds the following: + ** + ** * snprintf -- Works like sprintf, but has an extra argument + ** which is the size of the buffer written to. + ** + ** * mprintf -- Similar to sprintf. Writes output to memory + ** obtained from malloc. + ** + ** * xprintf -- Calls a function to dispose of output. + ** + ** * nprintf -- No output, but returns the number of characters + ** that would have been output by printf. + ** + ** * A v- version (ex: vsnprintf) of every function is also + ** supplied. + ** + ** + A few extensions to the formatting notation are supported: + ** + ** * The "=" flag (similar to "-") causes the output to be + ** be centered in the appropriately sized field. + ** + ** * The %b field outputs an integer in binary notation. + ** + ** * The %c field now accepts a precision. The character output + ** is repeated by the number of times the precision specifies. + ** + ** * The %' field works like %c, but takes as its character the + ** next character of the format string, instead of the next + ** argument. For example, printf("%.78'-") prints 78 minus + ** signs, the same as printf("%.78c",'-'). + ** + ** + When compiled using GCC on a SPARC, this version of printf is + ** faster than the library printf for SUN OS 4.1. + ** + ** + All functions are fully reentrant. + ** + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ + //#include "sqliteInt.h" - /* - ** Conversion types fall into various categories as defined by the - ** following enumeration. - */ - //#define etRADIX 1 /* Integer types. %d, %x, %o, and so forth */ - //#define etFLOAT 2 /* Floating point. %f */ - //#define etEXP 3 /* Exponentional notation. %e and %E */ - //#define etGENERIC 4 /* Floating or exponential, depending on exponent. %g */ - //#define etSIZE 5 /* Return number of characters processed so far. %n */ - //#define etSTRING 6 /* Strings. %s */ - //#define etDYNSTRING 7 /* Dynamically allocated strings. %z */ - //#define etPERCENT 8 /* Percent symbol. %% */ - //#define etCHARX 9 /* Characters. %c */ - ///* The rest are extensions, not normally found in printf() */ - //#define etSQLESCAPE 10 /* Strings with '\'' doubled. %q */ - //#define etSQLESCAPE2 11 /* Strings with '\'' doubled and enclosed in '', - // NULL pointers replaced by SQL NULL. %Q */ - //#define etTOKEN 12 /* a pointer to a Token structure */ - //#define etSRCLIST 13 /* a pointer to a SrcList */ - //#define etPOINTER 14 /* The %p conversion */ - //#define etSQLESCAPE3 15 /* %w -> Strings with '\"' doubled */ - //#define etORDINAL 16 /* %r -> 1st, 2nd, 3rd, 4th, etc. English only */ + /* + ** Conversion types fall into various categories as defined by the + ** following enumeration. + */ + //#define etRADIX 1 /* Integer types. %d, %x, %o, and so forth */ + //#define etFLOAT 2 /* Floating point. %f */ + //#define etEXP 3 /* Exponentional notation. %e and %E */ + //#define etGENERIC 4 /* Floating or exponential, depending on exponent. %g */ + //#define etSIZE 5 /* Return number of characters processed so far. %n */ + //#define etSTRING 6 /* Strings. %s */ + //#define etDYNSTRING 7 /* Dynamically allocated strings. %z */ + //#define etPERCENT 8 /* Percent symbol. %% */ + //#define etCHARX 9 /* Characters. %c */ + ///* The rest are extensions, not normally found in printf() */ + //#define etSQLESCAPE 10 /* Strings with '\'' doubled. %q */ + //#define etSQLESCAPE2 11 /* Strings with '\'' doubled and enclosed in '', + // NULL pointers replaced by SQL NULL. %Q */ + //#define etTOKEN 12 /* a pointer to a Token structure */ + //#define etSRCLIST 13 /* a pointer to a SrcList */ + //#define etPOINTER 14 /* The %p conversion */ + //#define etSQLESCAPE3 15 /* %w -> Strings with '\"' doubled */ + //#define etORDINAL 16 /* %r -> 1st, 2nd, 3rd, 4th, etc. English only */ - //#define etINVALID 0 /* Any unrecognized conversion type */ + //#define etINVALID 0 /* Any unrecognized conversion type */ - const int etRADIX = 1; /* Integer types. %d, %x, %o, and so forth */ - const int etFLOAT = 2; /* Floating point. %f */ - const int etEXP = 3; /* Exponentional notation. %e and %E */ - const int etGENERIC = 4; /* Floating or exponential, depending on exponent. %g */ - const int etSIZE = 5; /* Return number of characters processed so far. %n */ - const int etSTRING = 6; /* Strings. %s */ - const int etDYNSTRING = 7; /* Dynamically allocated strings. %z */ - const int etPERCENT = 8; /* Percent symbol. %% */ - const int etCHARX = 9; /* Characters. %c */ - /* The rest are extensions, not normally found in printf() */ - const int etSQLESCAPE = 10; /* Strings with '\'' doubled. %q */ - const int etSQLESCAPE2 = 11; /* Strings with '\'' doubled and enclosed in '', + const int etRADIX = 1; /* Integer types. %d, %x, %o, and so forth */ + const int etFLOAT = 2; /* Floating point. %f */ + const int etEXP = 3; /* Exponentional notation. %e and %E */ + const int etGENERIC = 4; /* Floating or exponential, depending on exponent. %g */ + const int etSIZE = 5; /* Return number of characters processed so far. %n */ + const int etSTRING = 6; /* Strings. %s */ + const int etDYNSTRING = 7; /* Dynamically allocated strings. %z */ + const int etPERCENT = 8; /* Percent symbol. %% */ + const int etCHARX = 9; /* Characters. %c */ + /* The rest are extensions, not normally found in printf() */ + const int etSQLESCAPE = 10; /* Strings with '\'' doubled. %q */ + const int etSQLESCAPE2 = 11; /* Strings with '\'' doubled and enclosed in '', NULL pointers replaced by SQL NULL. %Q */ - const int etTOKEN = 12; /* a pointer to a Token structure */ - const int etSRCLIST = 13; /* a pointer to a SrcList */ - const int etPOINTER = 14; /* The %p conversion */ - const int etSQLESCAPE3 = 15; /* %w . Strings with '\"' doubled */ - const int etORDINAL = 16; /* %r . 1st, 2nd, 3rd, 4th, etc. English only */ - const int etINVALID = 0; /* Any unrecognized conversion type */ + const int etTOKEN = 12; /* a pointer to a Token structure */ + const int etSRCLIST = 13; /* a pointer to a SrcList */ + const int etPOINTER = 14; /* The %p conversion */ + const int etSQLESCAPE3 = 15; /* %w . Strings with '\"' doubled */ + const int etORDINAL = 16; /* %r . 1st, 2nd, 3rd, 4th, etc. English only */ + const int etINVALID = 0; /* Any unrecognized conversion type */ - /* - ** An "etByte" is an 8-bit unsigned value. - */ - //typedef unsigned char etByte; + /* + ** An "etByte" is an 8-bit unsigned value. + */ + //typedef unsigned char etByte; - /* - ** Each builtin conversion character (ex: the 'd' in "%d") is described - ** by an instance of the following structure - */ - public class et_info { /* Information about each format field */ - public char fmttype; /* The format field code letter */ - public byte _base; /* The _base for radix conversion */ - public byte flags; /* One or more of FLAG_ constants below */ - public byte type; /* Conversion paradigm */ - public byte charset; /* Offset into aDigits[] of the digits string */ - public byte prefix; /* Offset into aPrefix[] of the prefix string */ - /* - * Constructor - */ - public et_info(char fmttype, - byte _base, - byte flags, - byte type, - byte charset, - byte prefix - ) { - this.fmttype = fmttype; - this._base = _base; - this.flags = flags; - this.type = type; - this.charset = charset; - this.prefix = prefix; - } + /* + ** Each builtin conversion character (ex: the 'd' in "%d") is described + ** by an instance of the following structure + */ + public class et_info + { /* Information about each format field */ + public char fmttype; /* The format field code letter */ + public byte _base; /* The _base for radix conversion */ + public byte flags; /* One or more of FLAG_ constants below */ + public byte type; /* Conversion paradigm */ + public byte charset; /* Offset into aDigits[] of the digits string */ + public byte prefix; /* Offset into aPrefix[] of the prefix string */ + /* + * Constructor + */ + public et_info( char fmttype, + byte _base, + byte flags, + byte type, + byte charset, + byte prefix + ) + { + this.fmttype = fmttype; + this._base = _base; + this.flags = flags; + this.type = type; + this.charset = charset; + this.prefix = prefix; + } - } + } - /* - ** Allowed values for et_info.flags - */ - const byte FLAG_SIGNED = 1; /* True if the value to convert is signed */ - const byte FLAG_INTERN = 2; /* True if for internal use only */ - const byte FLAG_STRING = 4; /* Allow infinity precision */ + /* + ** Allowed values for et_info.flags + */ + const byte FLAG_SIGNED = 1; /* True if the value to convert is signed */ + const byte FLAG_INTERN = 2; /* True if for internal use only */ + const byte FLAG_STRING = 4; /* Allow infinity precision */ - /* - ** The following table is searched linearly, so it is good to put the - ** most frequently used conversion types first. - */ - static string aDigits = "0123456789ABCDEF0123456789abcdef"; - static string aPrefix = "-x0\000X0"; - static et_info[] fmtinfo = new et_info[] { + /* + ** The following table is searched linearly, so it is good to put the + ** most frequently used conversion types first. + */ + static string aDigits = "0123456789ABCDEF0123456789abcdef"; + static string aPrefix = "-x0\000X0"; + static et_info[] fmtinfo = new et_info[] { new et_info( 'd', 10, 1, etRADIX, 0, 0 ), new et_info( 's', 0, 4, etSTRING, 0, 0 ), new et_info( 'g', 0, 1, etGENERIC, 30, 0 ), @@ -196,1085 +202,1247 @@ byte prefix new et_info( 'S', 0, 2, etSRCLIST, 0, 0 ), new et_info( 'r', 10, 3, etORDINAL, 0, 0 ), }; - /* - ** If SQLITE_OMIT_FLOATING_POINT is defined, then none of the floating point - ** conversions will work. - */ -#if !SQLITE_OMIT_FLOATING_POINT - /* - ** "*val" is a double such that 0.1 <= *val < 10.0 - ** Return the ascii code for the leading digit of *val, then - ** multiply "*val" by 10.0 to renormalize. - ** - ** Example: - ** input: *val = 3.14159 - ** output: *val = 1.4159 function return = '3' - ** - ** The counter *cnt is incremented each time. After counter exceeds - ** 16 (the number of significant digits in a 64-bit float) '0' is - ** always returned. + /* + ** If SQLITE_OMIT_FLOATING_POINT is defined, then none of the floating point + ** conversions will work. */ - static char et_getdigit(ref LONGDOUBLE_TYPE val, ref int cnt) { - int digit; - LONGDOUBLE_TYPE d; - if (cnt++ >= 16) - return '\0'; - digit = (int)val; - d = digit; - //digit += '0'; - val = (val - d) * 10.0; - return (char)digit; - } +#if !SQLITE_OMIT_FLOATING_POINT + /* +** "*val" is a double such that 0.1 <= *val < 10.0 +** Return the ascii code for the leading digit of *val, then +** multiply "*val" by 10.0 to renormalize. +** +** Example: +** input: *val = 3.14159 +** output: *val = 1.4159 function return = '3' +** +** The counter *cnt is incremented each time. After counter exceeds +** 16 (the number of significant digits in a 64-bit float) '0' is +** always returned. +*/ + static char et_getdigit( ref LONGDOUBLE_TYPE val, ref int cnt ) + { + int digit; + LONGDOUBLE_TYPE d; + if ( cnt++ >= 16 ) + return '\0'; + digit = (int)val; + d = digit; + //digit += '0'; + val = ( val - d ) * 10.0; + return (char)digit; + } #endif // * SQLITE_OMIT_FLOATING_POINT */ - /* - ** Append N space characters to the given string buffer. - */ - static void appendSpace(StrAccum pAccum, int N) { - //static const char zSpaces[] = " "; - //while( N>=zSpaces.Length-1 ){ - // sqlite3StrAccumAppend(pAccum, zSpaces, zSpaces.Length-1); - // N -= zSpaces.Length-1; - //} - //if( N>0 ){ - // sqlite3StrAccumAppend(pAccum, zSpaces, N); - //} - pAccum.zText.AppendFormat("{0," + N + "}", ""); - } + /* +** Append N space characters to the given string buffer. +*/ + static void appendSpace( StrAccum pAccum, int N ) + { + //static const char zSpaces[] = " "; + //while( N>=zSpaces.Length-1 ){ + // sqlite3StrAccumAppend(pAccum, zSpaces, zSpaces.Length-1); + // N -= zSpaces.Length-1; + //} + //if( N>0 ){ + // sqlite3StrAccumAppend(pAccum, zSpaces, N); + //} + pAccum.zText.AppendFormat( "{0," + N + "}", "" ); + } - /* - ** On machines with a small stack size, you can redefine the - ** SQLITE_PRINT_BUF_SIZE to be less than 350. - */ + /* + ** On machines with a small stack size, you can redefine the + ** SQLITE_PRINT_BUF_SIZE to be less than 350. + */ #if !SQLITE_PRINT_BUF_SIZE -#if (SQLITE_SMALL_STACK) +# if (SQLITE_SMALL_STACK) const int SQLITE_PRINT_BUF_SIZE = 50; -#else - const int SQLITE_PRINT_BUF_SIZE = 350; +# else + const int SQLITE_PRINT_BUF_SIZE = 350; #endif #endif - const int etBUFSIZE = SQLITE_PRINT_BUF_SIZE; /* Size of the output buffer */ + const int etBUFSIZE = SQLITE_PRINT_BUF_SIZE; /* Size of the output buffer */ - /* - ** The root program. All variations call this core. - ** - ** INPUTS: - ** func This is a pointer to a function taking three arguments - ** 1. A pointer to anything. Same as the "arg" parameter. - ** 2. A pointer to the list of characters to be output - ** (Note, this list is NOT null terminated.) - ** 3. An integer number of characters to be output. - ** (Note: This number might be zero.) - ** - ** arg This is the pointer to anything which will be passed as the - ** first argument to "func". Use it for whatever you like. - ** - ** fmt This is the format string, as in the usual print. - ** - ** ap This is a pointer to a list of arguments. Same as in - ** vfprint. - ** - ** OUTPUTS: - ** The return value is the total number of characters sent to - ** the function "func". Returns -1 on a error. - ** - ** Note that the order in which automatic variables are declared below - ** seems to make a big difference in determining how fast this beast - ** will run. - */ - static char[] buf = new char[etBUFSIZE]; /* Conversion buffer */ - static void sqlite3VXPrintf( - StrAccum pAccum, /* Accumulate results here */ - int useExtended, /* Allow extended %-conversions */ - string fmt, /* Format string */ - va_list[] ap /* arguments */ - ) { - int c; /* Next character in the format string */ - int bufpt; /* Pointer to the conversion buffer */ - int precision; /* Precision of the current field */ - int length; /* Length of the field */ - int idx; /* A general purpose loop counter */ - int width; /* Width of the current field */ - etByte flag_leftjustify; /* True if "-" flag is present */ - etByte flag_plussign; /* True if "+" flag is present */ - etByte flag_blanksign; /* True if " " flag is present */ - etByte flag_alternateform; /* True if "#" flag is present */ - etByte flag_altform2; /* True if "!" flag is present */ - etByte flag_zeropad; /* True if field width constant starts with zero */ - etByte flag_long; /* True if "l" flag is present */ - etByte flag_longlong; /* True if the "ll" flag is present */ - etByte done; /* Loop termination flag */ - i64 longvalue; - LONGDOUBLE_TYPE realvalue; /* Value for real types */ - et_info infop; /* Pointer to the appropriate info structure */ - char[] buf = new char[etBUFSIZE]; /* Conversion buffer */ - char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */ - byte xtype = 0; /* Conversion paradigm */ - // Not used in C# -- string zExtra; /* Extra memory used for etTCLESCAPE conversions */ + /* + ** The root program. All variations call this core. + ** + ** INPUTS: + ** func This is a pointer to a function taking three arguments + ** 1. A pointer to anything. Same as the "arg" parameter. + ** 2. A pointer to the list of characters to be output + ** (Note, this list is NOT null terminated.) + ** 3. An integer number of characters to be output. + ** (Note: This number might be zero.) + ** + ** arg This is the pointer to anything which will be passed as the + ** first argument to "func". Use it for whatever you like. + ** + ** fmt This is the format string, as in the usual print. + ** + ** ap This is a pointer to a list of arguments. Same as in + ** vfprint. + ** + ** OUTPUTS: + ** The return value is the total number of characters sent to + ** the function "func". Returns -1 on a error. + ** + ** Note that the order in which automatic variables are declared below + ** seems to make a big difference in determining how fast this beast + ** will run. + */ + static char[] buf = new char[etBUFSIZE]; /* Conversion buffer */ + static void sqlite3VXPrintf( + StrAccum pAccum, /* Accumulate results here */ + int useExtended, /* Allow extended %-conversions */ + string fmt, /* Format string */ + va_list[] ap /* arguments */ + ) + { + int c; /* Next character in the format string */ + int bufpt; /* Pointer to the conversion buffer */ + int precision; /* Precision of the current field */ + int length; /* Length of the field */ + int idx; /* A general purpose loop counter */ + int width; /* Width of the current field */ + etByte flag_leftjustify; /* True if "-" flag is present */ + etByte flag_plussign; /* True if "+" flag is present */ + etByte flag_blanksign; /* True if " " flag is present */ + etByte flag_alternateform; /* True if "#" flag is present */ + etByte flag_altform2; /* True if "!" flag is present */ + etByte flag_zeropad; /* True if field width constant starts with zero */ + etByte flag_long; /* True if "l" flag is present */ + etByte flag_longlong; /* True if the "ll" flag is present */ + etByte done; /* Loop termination flag */ + i64 longvalue; + LONGDOUBLE_TYPE realvalue; /* Value for real types */ + et_info infop; /* Pointer to the appropriate info structure */ + char[] buf = new char[etBUFSIZE]; /* Conversion buffer */ + char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */ + byte xtype = 0; /* Conversion paradigm */ + // Not used in C# -- string zExtra; /* Extra memory used for etTCLESCAPE conversions */ #if !SQLITE_OMIT_FLOATING_POINT - int exp, e2; /* exponent of real numbers */ - double rounder; /* Used for rounding floating point values */ - etByte flag_dp; /* True if decimal point should be shown */ - etByte flag_rtz; /* True if trailing zeros should be removed */ - etByte flag_exp; /* True to force display of the exponent */ - int nsd; /* Number of significant digits returned */ + int exp, e2; /* exponent of real numbers */ + double rounder; /* Used for rounding floating point values */ + etByte flag_dp; /* True if decimal point should be shown */ + etByte flag_rtz; /* True if trailing zeros should be removed */ + etByte flag_exp; /* True to force display of the exponent */ + int nsd; /* Number of significant digits returned */ #endif - length = 0; - bufpt = 0; - int _fmt = 0; // Work around string pointer - fmt += '\0'; + length = 0; + bufpt = 0; + int _fmt = 0; // Work around string pointer + fmt += '\0'; - for (; _fmt <= fmt.Length && (c = fmt[_fmt]) != 0; ++_fmt) { - if (c != '%') { - int amt; - bufpt = _fmt; - amt = 1; - while (_fmt < fmt.Length && (c = (fmt[++_fmt])) != '%' && c != 0) - amt++; - sqlite3StrAccumAppend(pAccum, fmt.Substring(bufpt, amt), amt); - if (c == 0) - break; - } - if (_fmt < fmt.Length && (c = (fmt[++_fmt])) == 0) { - sqlite3StrAccumAppend(pAccum, "%", 1); - break; - } - /* Find out what flags are present */ - flag_leftjustify = flag_plussign = flag_blanksign = - flag_alternateform = flag_altform2 = flag_zeropad = false; - done = false; - do { - switch (c) { - case '-': - flag_leftjustify = true; - break; - case '+': - flag_plussign = true; - break; - case ' ': - flag_blanksign = true; - break; - case '#': - flag_alternateform = true; - break; - case '!': - flag_altform2 = true; - break; - case '0': - flag_zeropad = true; - break; - default: - done = true; - break; - } - } while (!done && _fmt < fmt.Length - 1 && (c = (fmt[++_fmt])) != 0); - /* Get the field width */ - width = 0; - if (c == '*') { - width = va_arg(ap, (Int32)0); - if (width < 0) { - flag_leftjustify = true; - width = -width; - } - c = fmt[++_fmt]; - } else { - while (c >= '0' && c <= '9') { - width = width * 10 + c - '0'; - c = fmt[++_fmt]; - } - } - if (width > etBUFSIZE - 10) { - width = etBUFSIZE - 12; - } - /* Get the precision */ - if (c == '.') { - precision = 0; - c = fmt[++_fmt]; - if (c == '*') { - precision = va_arg(ap, (Int32)0); - if (precision < 0) - precision = -precision; - c = fmt[++_fmt]; - } else { - while (c >= '0' && c <= '9') { - precision = precision * 10 + c - '0'; - c = fmt[++_fmt]; - } - } - } else { - precision = -1; - } - /* Get the conversion type modifier */ - if (c == 'l') { - flag_long = true; - c = fmt[++_fmt]; - if (c == 'l') { - flag_longlong = true; - c = fmt[++_fmt]; - } else { - flag_longlong = false; - } - } else { - flag_long = flag_longlong = false; - } - /* Fetch the info entry for the field */ - infop = fmtinfo[0]; - xtype = etINVALID; - for (idx = 0; idx < ArraySize(fmtinfo); idx++) { - if (c == fmtinfo[idx].fmttype) { - infop = fmtinfo[idx]; - if (useExtended != 0 || (infop.flags & FLAG_INTERN) == 0) { - xtype = infop.type; - } else { - return; - } - break; - } - } - //zExtra = null; + for ( ; _fmt <= fmt.Length && ( c = fmt[_fmt] ) != 0; ++_fmt ) + { + if ( c != '%' ) + { + int amt; + bufpt = _fmt; + amt = 1; + while ( _fmt < fmt.Length && ( c = ( fmt[++_fmt] ) ) != '%' && c != 0 ) + amt++; + sqlite3StrAccumAppend( pAccum, fmt.Substring( bufpt, amt ), amt ); + if ( c == 0 ) + break; + } + if ( _fmt < fmt.Length && ( c = ( fmt[++_fmt] ) ) == 0 ) + { + sqlite3StrAccumAppend( pAccum, "%", 1 ); + break; + } + /* Find out what flags are present */ + flag_leftjustify = flag_plussign = flag_blanksign = + flag_alternateform = flag_altform2 = flag_zeropad = false; + done = false; + do + { + switch ( c ) + { + case '-': + flag_leftjustify = true; + break; + case '+': + flag_plussign = true; + break; + case ' ': + flag_blanksign = true; + break; + case '#': + flag_alternateform = true; + break; + case '!': + flag_altform2 = true; + break; + case '0': + flag_zeropad = true; + break; + default: + done = true; + break; + } + } while ( !done && _fmt < fmt.Length - 1 && ( c = ( fmt[++_fmt] ) ) != 0 ); + /* Get the field width */ + width = 0; + if ( c == '*' ) + { + width = va_arg( ap, (Int32)0 ); + if ( width < 0 ) + { + flag_leftjustify = true; + width = -width; + } + c = fmt[++_fmt]; + } + else + { + while ( c >= '0' && c <= '9' ) + { + width = width * 10 + c - '0'; + c = fmt[++_fmt]; + } + } + if ( width > etBUFSIZE - 10 ) + { + width = etBUFSIZE - 12; + } + /* Get the precision */ + if ( c == '.' ) + { + precision = 0; + c = fmt[++_fmt]; + if ( c == '*' ) + { + precision = va_arg( ap, (Int32)0 ); + if ( precision < 0 ) + precision = -precision; + c = fmt[++_fmt]; + } + else + { + while ( c >= '0' && c <= '9' ) + { + precision = precision * 10 + c - '0'; + c = fmt[++_fmt]; + } + } + } + else + { + precision = -1; + } + /* Get the conversion type modifier */ + if ( c == 'l' ) + { + flag_long = true; + c = fmt[++_fmt]; + if ( c == 'l' ) + { + flag_longlong = true; + c = fmt[++_fmt]; + } + else + { + flag_longlong = false; + } + } + else + { + flag_long = flag_longlong = false; + } + /* Fetch the info entry for the field */ + infop = fmtinfo[0]; + xtype = etINVALID; + for ( idx = 0; idx < ArraySize( fmtinfo ); idx++ ) + { + if ( c == fmtinfo[idx].fmttype ) + { + infop = fmtinfo[idx]; + if ( useExtended != 0 || ( infop.flags & FLAG_INTERN ) == 0 ) + { + xtype = infop.type; + } + else + { + return; + } + break; + } + } + //zExtra = null; - /* Limit the precision to prevent overflowing buf[] during conversion */ - if (precision > etBUFSIZE - 40 && (infop.flags & FLAG_STRING) == 0) { - precision = etBUFSIZE - 40; - } + /* Limit the precision to prevent overflowing buf[] during conversion */ + if ( precision > etBUFSIZE - 40 && ( infop.flags & FLAG_STRING ) == 0 ) + { + precision = etBUFSIZE - 40; + } - /* - ** At this point, variables are initialized as follows: - ** - ** flag_alternateform TRUE if a '#' is present. - ** flag_altform2 TRUE if a '!' is present. - ** flag_plussign TRUE if a '+' is present. - ** flag_leftjustify TRUE if a '-' is present or if the - ** field width was negative. - ** flag_zeropad TRUE if the width began with 0. - ** flag_long TRUE if the letter 'l' (ell) prefixed - ** the conversion character. - ** flag_longlong TRUE if the letter 'll' (ell ell) prefixed - ** the conversion character. - ** flag_blanksign TRUE if a ' ' is present. - ** width The specified field width. This is - ** always non-negative. Zero is the default. - ** precision The specified precision. The default - ** is -1. - ** xtype The class of the conversion. - ** infop Pointer to the appropriate info struct. - */ - switch (xtype) { - case etPOINTER: - flag_longlong = true;// char*.Length == sizeof(i64); - flag_long = false;// char*.Length == sizeof(long); - /* Fall through into the next case */ - goto case etRADIX; - case etORDINAL: - case etRADIX: - if ((infop.flags & FLAG_SIGNED) != 0) { - i64 v; - if (flag_longlong) { - v = (Int64)va_arg(ap, (Int64)0); - } else if (flag_long) { - v = (Int64)va_arg(ap, (Int64)0); - } else { - v = (Int32)va_arg(ap, (Int32)0); - } - if (v < 0) { - if (v == SMALLEST_INT64) { - longvalue = ((long)((u64)1) << 63); - } else { - longvalue = -v; - } - prefix = '-'; - } else { - longvalue = v; - if (flag_plussign) - prefix = '+'; - else if (flag_blanksign) - prefix = ' '; - else - prefix = '\0'; - } - } else { - if (flag_longlong) { - longvalue = va_arg(ap, (Int64)0); - } else if (flag_long) { - longvalue = va_arg(ap, (Int64)0); - } else { - longvalue = va_arg(ap, (Int64)0); - } - prefix = '\0'; - } - if (longvalue == 0) - flag_alternateform = false; - if (flag_zeropad && precision < width - ((prefix != '\0') ? 1 : 0)) { - precision = width - ((prefix != '\0') ? 1 : 0); - } - bufpt = buf.Length;//[etBUFSIZE-1]; - char[] _bufOrd = null; - if (xtype == etORDINAL) { - char[] zOrd = "thstndrd".ToCharArray(); - int x = (int)(longvalue % 10); - if (x >= 4 || (longvalue / 10) % 10 == 1) { - x = 0; - } - _bufOrd = new char[2]; - _bufOrd[0] = zOrd[x * 2]; - _bufOrd[1] = zOrd[x * 2 + 1]; - //bufpt -= 2; - } { + /* + ** At this point, variables are initialized as follows: + ** + ** flag_alternateform TRUE if a '#' is present. + ** flag_altform2 TRUE if a '!' is present. + ** flag_plussign TRUE if a '+' is present. + ** flag_leftjustify TRUE if a '-' is present or if the + ** field width was negative. + ** flag_zeropad TRUE if the width began with 0. + ** flag_long TRUE if the letter 'l' (ell) prefixed + ** the conversion character. + ** flag_longlong TRUE if the letter 'll' (ell ell) prefixed + ** the conversion character. + ** flag_blanksign TRUE if a ' ' is present. + ** width The specified field width. This is + ** always non-negative. Zero is the default. + ** precision The specified precision. The default + ** is -1. + ** xtype The class of the conversion. + ** infop Pointer to the appropriate info struct. + */ + switch ( xtype ) + { + case etPOINTER: + flag_longlong = true;// char*.Length == sizeof(i64); + flag_long = false;// char*.Length == sizeof(long); + /* Fall through into the next case */ + goto case etRADIX; + case etORDINAL: + case etRADIX: + if ( ( infop.flags & FLAG_SIGNED ) != 0 ) + { + i64 v; + if ( flag_longlong ) + { + v = (Int64)va_arg( ap, (Int64)0 ); + } + else if ( flag_long ) + { + v = (Int64)va_arg( ap, (Int64)0 ); + } + else + { + v = (Int32)va_arg( ap, (Int32)0 ); + } + if ( v < 0 ) + { + if ( v == SMALLEST_INT64 ) + { + longvalue = ( (long)( (u64)1 ) << 63 ); + } + else + { + longvalue = -v; + } + prefix = '-'; + } + else + { + longvalue = v; + if ( flag_plussign ) + prefix = '+'; + else if ( flag_blanksign ) + prefix = ' '; + else + prefix = '\0'; + } + } + else + { + if ( flag_longlong ) + { + longvalue = va_arg( ap, (Int64)0 ); + } + else if ( flag_long ) + { + longvalue = va_arg( ap, (Int64)0 ); + } + else + { + longvalue = va_arg( ap, (Int64)0 ); + } + prefix = '\0'; + } + if ( longvalue == 0 ) + flag_alternateform = false; + if ( flag_zeropad && precision < width - ( ( prefix != '\0' ) ? 1 : 0 ) ) + { + precision = width - ( ( prefix != '\0' ) ? 1 : 0 ); + } + bufpt = buf.Length;//[etBUFSIZE-1]; + char[] _bufOrd = null; + if ( xtype == etORDINAL ) + { + char[] zOrd = "thstndrd".ToCharArray(); + int x = (int)( longvalue % 10 ); + if ( x >= 4 || ( longvalue / 10 ) % 10 == 1 ) + { + x = 0; + } + _bufOrd = new char[2]; + _bufOrd[0] = zOrd[x * 2]; + _bufOrd[1] = zOrd[x * 2 + 1]; + //bufpt -= 2; + } + { - char[] _buf; - switch (infop._base) { - case 16: - _buf = longvalue.ToString("x").ToCharArray(); - break; - case 8: - _buf = Convert.ToString((long)longvalue, 8).ToCharArray(); - break; - default: { - if (flag_zeropad) - _buf = longvalue.ToString(new string('0', width - ((prefix != '\0') ? 1 : 0))).ToCharArray(); - else - _buf = longvalue.ToString().ToCharArray(); - } - break; - } - bufpt = buf.Length - _buf.Length - (_bufOrd == null ? 0 : 2); - Array.Copy(_buf, 0, buf, bufpt, _buf.Length); - if (_bufOrd != null) { - buf[buf.Length - 1] = _bufOrd[1]; - buf[buf.Length - 2] = _bufOrd[0]; - } - //char* cset; /* Use registers for speed */ - //int _base; - //cset = aDigits[infop.charset]; - //_base = infop._base; - //do - //{ /* Convert to ascii */ - // *(--bufpt) = cset[longvalue % (ulong)_base]; - // longvalue = longvalue / (ulong)_base; - //} while (longvalue > 0); - } - length = buf.Length - bufpt;//length = (int)(&buf[etBUFSIZE-1]-bufpt); - for (idx = precision - length; idx > 0; idx--) { - buf[(--bufpt)] = '0'; /* Zero pad */ - } - if (prefix != '\0') - buf[--bufpt] = prefix; /* Add sign */ - if (flag_alternateform && infop.prefix != 0) { /* Add "0" or "0x" */ - int pre; - char x; - pre = infop.prefix; - for (; (x = aPrefix[pre]) != 0; pre++) - buf[--bufpt] = x; - } - length = buf.Length - bufpt;//length = (int)(&buf[etBUFSIZE-1]-bufpt); - break; - case etFLOAT: - case etEXP: - case etGENERIC: - realvalue = va_arg(ap, (Double)0); + char[] _buf; + switch ( infop._base ) + { + case 16: + _buf = longvalue.ToString( "x" ).ToCharArray(); + break; + case 8: + _buf = Convert.ToString( (long)longvalue, 8 ).ToCharArray(); + break; + default: + { + if ( flag_zeropad ) + _buf = longvalue.ToString( new string( '0', width - ( ( prefix != '\0' ) ? 1 : 0 ) ) ).ToCharArray(); + else + _buf = longvalue.ToString().ToCharArray(); + } + break; + } + bufpt = buf.Length - _buf.Length - ( _bufOrd == null ? 0 : 2 ); + Array.Copy( _buf, 0, buf, bufpt, _buf.Length ); + if ( _bufOrd != null ) + { + buf[buf.Length - 1] = _bufOrd[1]; + buf[buf.Length - 2] = _bufOrd[0]; + } + //char* cset; /* Use registers for speed */ + //int _base; + //cset = aDigits[infop.charset]; + //_base = infop._base; + //do + //{ /* Convert to ascii */ + // *(--bufpt) = cset[longvalue % (ulong)_base]; + // longvalue = longvalue / (ulong)_base; + //} while (longvalue > 0); + } + length = buf.Length - bufpt;//length = (int)(&buf[etBUFSIZE-1]-bufpt); + for ( idx = precision - length; idx > 0; idx-- ) + { + buf[( --bufpt )] = '0'; /* Zero pad */ + } + if ( prefix != '\0' ) + buf[--bufpt] = prefix; /* Add sign */ + if ( flag_alternateform && infop.prefix != 0 ) + { /* Add "0" or "0x" */ + int pre; + char x; + pre = infop.prefix; + for ( ; ( x = aPrefix[pre] ) != 0; pre++ ) + buf[--bufpt] = x; + } + length = buf.Length - bufpt;//length = (int)(&buf[etBUFSIZE-1]-bufpt); + break; + case etFLOAT: + case etEXP: + case etGENERIC: + realvalue = va_arg( ap, (Double)0 ); #if SQLITE_OMIT_FLOATING_POINT length = 0; #else - if (precision < 0) - precision = 6; /* Set default precision */ - if (precision > etBUFSIZE / 2 - 10) - precision = etBUFSIZE / 2 - 10; - if (realvalue < 0.0) { - realvalue = -realvalue; - prefix = '-'; - } else { - if (flag_plussign) - prefix = '+'; - else if (flag_blanksign) - prefix = ' '; - else - prefix = '\0'; - } - if (xtype == etGENERIC && precision > 0) - precision--; + if ( precision < 0 ) + precision = 6; /* Set default precision */ + if ( precision > etBUFSIZE / 2 - 10 ) + precision = etBUFSIZE / 2 - 10; + if ( realvalue < 0.0 ) + { + realvalue = -realvalue; + prefix = '-'; + } + else + { + if ( flag_plussign ) + prefix = '+'; + else if ( flag_blanksign ) + prefix = ' '; + else + prefix = '\0'; + } + if ( xtype == etGENERIC && precision > 0 ) + precision--; #if FALSE /* Rounding works like BSD when the constant 0.4999 is used. Wierd! */ for(idx=precision, rounder=0.4999; idx>0; idx--, rounder*=0.1); #else - /* It makes more sense to use 0.5 */ - for (idx = precision, rounder = 0.5; idx > 0; idx--, rounder *= 0.1) { - } + /* It makes more sense to use 0.5 */ + for ( idx = precision, rounder = 0.5; idx > 0; idx--, rounder *= 0.1 ) + { + } #endif - if (xtype == etFLOAT) - realvalue += rounder; - /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */ - exp = 0; - double d = 0; + if ( xtype == etFLOAT ) + realvalue += rounder; + /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */ + exp = 0; + double d = 0; #if WINDOWS_MOBILE //alxwest: Tryparse doesn't exist on Windows Moble and what will Tryparsing a double do? if ( Double.IsNaN( realvalue )) #else - if (Double.IsNaN(realvalue) || !(Double.TryParse(Convert.ToString(realvalue), out d)))//if( sqlite3IsNaN((double)realvalue) ) + if ( Double.IsNaN( realvalue ) || !( Double.TryParse( Convert.ToString( realvalue ), out d ) ) )//if( sqlite3IsNaN((double)realvalue) ) #endif - { - buf[0] = 'N'; - buf[1] = 'a'; - buf[2] = 'N';// "NaN" - length = 3; - break; - } - if (realvalue > 0.0) { - while (realvalue >= 1e32 && exp <= 350) { - realvalue *= 1e-32; - exp += 32; - } - while (realvalue >= 1e8 && exp <= 350) { - realvalue *= 1e-8; - exp += 8; - } - while (realvalue >= 10.0 && exp <= 350) { - realvalue *= 0.1; - exp++; - } - while (realvalue < 1e-8) { - realvalue *= 1e8; - exp -= 8; - } - while (realvalue < 1.0) { - realvalue *= 10.0; - exp--; - } - if (exp > 350) { - if (prefix == '-') { - buf[0] = '-'; - buf[1] = 'I'; - buf[2] = 'n'; - buf[3] = 'f';// "-Inf" - bufpt = 4; - } else if (prefix == '+') { - buf[0] = '+'; - buf[1] = 'I'; - buf[2] = 'n'; - buf[3] = 'f';// "+Inf" - bufpt = 4; - } else { - buf[0] = 'I'; - buf[1] = 'n'; - buf[2] = 'f';// "Inf" - bufpt = 3; - } - length = sqlite3Strlen30(bufpt);// sqlite3Strlen30(bufpt); - bufpt = 0; - break; - } - } - bufpt = 0; - /* - ** If the field type is etGENERIC, then convert to either etEXP - ** or etFLOAT, as appropriate. - */ - flag_exp = xtype == etEXP; - if (xtype != etFLOAT) { - realvalue += rounder; - if (realvalue >= 10.0) { - realvalue *= 0.1; - exp++; - } - } - if (xtype == etGENERIC) { - flag_rtz = !flag_alternateform; - if (exp < -4 || exp > precision) { - xtype = etEXP; - } else { - precision = precision - exp; - xtype = etFLOAT; - } - } else { - flag_rtz = false; - } - if (xtype == etEXP) { - e2 = 0; - } else { - e2 = exp; - } - nsd = 0; - flag_dp = (precision > 0 ? true : false) | flag_alternateform | flag_altform2; - /* The sign in front of the number */ - if (prefix != '\0') { - buf[bufpt++] = prefix; - } - /* Digits prior to the decimal point */ - if (e2 < 0) { - buf[bufpt++] = '0'; - } else { - for (; e2 >= 0; e2--) { - buf[bufpt++] = (char)(et_getdigit(ref realvalue, ref nsd) + '0'); // *(bufpt++) = et_getdigit(ref realvalue, ref nsd); - } - - } - /* The decimal point */ - if (flag_dp) { - buf[bufpt++] = '.'; - } - /* "0" digits after the decimal point but before the first - ** significant digit of the number */ - for (e2++; e2 < 0; precision--, e2++) { - Debug.Assert(precision > 0); - buf[bufpt++] = '0'; - } - /* Significant digits after the decimal point */ - while ((precision--) > 0) { - buf[bufpt++] = (char)(et_getdigit(ref realvalue, ref nsd) + '0'); // *(bufpt++) = et_getdigit(&realvalue, nsd); - } - /* Remove trailing zeros and the "." if no digits follow the "." */ - if (flag_rtz && flag_dp) { - while (buf[bufpt - 1] == '0') - buf[--bufpt] = '\0'; - Debug.Assert(bufpt > 0); - if (buf[bufpt - 1] == '.') { - if (flag_altform2) { - buf[(bufpt++)] = '0'; - } else { - buf[(--bufpt)] = '0'; - } - } - } - /* Add the "eNNN" suffix */ - if (flag_exp || xtype == etEXP) { - buf[bufpt++] = aDigits[infop.charset]; - if (exp < 0) { - buf[bufpt++] = '-'; - exp = -exp; - } else { - buf[bufpt++] = '+'; - } - if (exp >= 100) { - buf[bufpt++] = (char)(exp / 100 + '0'); /* 100's digit */ - exp %= 100; - } - buf[bufpt++] = (char)(exp / 10 + '0'); /* 10's digit */ - buf[bufpt++] = (char)(exp % 10 + '0'); /* 1's digit */ - } - //bufpt = 0; - - /* The converted number is in buf[] and zero terminated. Output it. - ** Note that the number is in the usual order, not reversed as with - ** integer conversions. */ - length = bufpt;//length = (int)(bufpt-buf); - bufpt = 0; - - /* Special case: Add leading zeros if the flag_zeropad flag is - ** set and we are not left justified */ - if (flag_zeropad && !flag_leftjustify && length < width) { - int i; - int nPad = width - length; - for (i = width; i >= nPad; i--) { - buf[bufpt + i] = buf[bufpt + i - nPad]; - } - i = (prefix != '\0' ? 1 : 0); - while (nPad-- != 0) - buf[(bufpt++) + i] = '0'; - length = width; - bufpt = 0; - } -#endif //* !defined(SQLITE_OMIT_FLOATING_POINT) */ - break; - case etSIZE: - ap[0] = pAccum.nChar; // *(va_arg(ap,int)) = pAccum.nChar; - length = width = 0; - break; - case etPERCENT: - buf[0] = '%'; - bufpt = 0; - length = 1; - break; - case etCHARX: - c = va_arg(ap, (Char)0); - buf[0] = (char)c; - if (precision >= 0) { - for (idx = 1; idx < precision; idx++) - buf[idx] = (char)c; - length = precision; - } else { - length = 1; - } - bufpt = 0; - break; - case etSTRING: - case etDYNSTRING: - bufpt = 0;// - string bufStr = (string)va_arg(ap, "string"); - if (bufStr.Length > buf.Length) - buf = new char[bufStr.Length]; - bufStr.ToCharArray().CopyTo(buf, 0); - bufpt = bufStr.Length; - if (bufpt == 0) { - buf[0] = '\0'; - } else if (xtype == etDYNSTRING) { - // zExtra = bufpt; - } - if (precision >= 0) { - for (length = 0; length < precision && length < bufStr.Length && buf[length] != 0; length++) { - } - //length += precision; - } else { - length = sqlite3Strlen30(bufpt); - } - bufpt = 0; - break; - case etSQLESCAPE: - case etSQLESCAPE2: - case etSQLESCAPE3: { - int i; - int j; - int k; - int n; - bool isnull; - bool needQuote; - char ch; - char q = ((xtype == etSQLESCAPE3) ? '"' : '\''); /* Quote character */ - string escarg = (string)va_arg(ap, "char*") + '\0'; - isnull = (escarg == "" || escarg == "NULL\0"); - if (isnull) - escarg = (xtype == etSQLESCAPE2) ? "NULL\0" : "(NULL)\0"; - k = precision; - for (i = n = 0; k != 0 && (ch = escarg[i]) != 0; i++, k--) { - if (ch == q) - n++; - } - needQuote = !isnull && (xtype == etSQLESCAPE2); - n += i + 1 + (needQuote ? 2 : 0); - if (n > etBUFSIZE) { - buf = new char[n];//bufpt = zExtra = sqlite3Malloc(n); - //if ( bufpt == 0 ) - //{ - // pAccum->mallocFailed = 1; - // return; - //} - bufpt = 0; //Start of Buffer - } else { - //bufpt = buf; - bufpt = 0; //Start of Buffer - } - j = 0; - if (needQuote) - buf[bufpt + j++] = q; - k = i; - for (i = 0; i < k; i++) { - buf[bufpt + j++] = ch = escarg[i]; - if (ch == q) - buf[bufpt + j++] = ch; - } - if (needQuote) - buf[bufpt + j++] = q; - buf[bufpt + j] = '\0'; - length = j; - /* The precision in %q and %Q means how many input characters to - ** consume, not the length of the output... - ** if( precision>=0 && precision= 0 && k < pSrc.nSrc); - if (pItem.zDatabase != null) { - sqlite3StrAccumAppend(pAccum, pItem.zDatabase, -1); - sqlite3StrAccumAppend(pAccum, ".", 1); - } - sqlite3StrAccumAppend(pAccum, pItem.zName, -1); - length = width = 0; - break; - } - default: { - Debug.Assert(xtype == etINVALID); - return; - } - }/* End switch over the format type */ - /* - ** The text of the conversion is pointed to by "bufpt" and is - ** "length" characters long. The field width is "width". Do - ** the output. - */ - if (!flag_leftjustify) { - int nspace; - nspace = width - length;// -2; - if (nspace > 0) { - appendSpace(pAccum, nspace); - } + { + buf[0] = 'N'; + buf[1] = 'a'; + buf[2] = 'N';// "NaN" + length = 3; + break; + } + if ( realvalue > 0.0 ) + { + while ( realvalue >= 1e32 && exp <= 350 ) + { + realvalue *= 1e-32; + exp += 32; + } + while ( realvalue >= 1e8 && exp <= 350 ) + { + realvalue *= 1e-8; + exp += 8; + } + while ( realvalue >= 10.0 && exp <= 350 ) + { + realvalue *= 0.1; + exp++; + } + while ( realvalue < 1e-8 ) + { + realvalue *= 1e8; + exp -= 8; + } + while ( realvalue < 1.0 ) + { + realvalue *= 10.0; + exp--; + } + if ( exp > 350 ) + { + if ( prefix == '-' ) + { + buf[0] = '-'; + buf[1] = 'I'; + buf[2] = 'n'; + buf[3] = 'f';// "-Inf" + bufpt = 4; } - if (length > 0) { - sqlite3StrAccumAppend(pAccum, new string(buf, bufpt, length), length); + else if ( prefix == '+' ) + { + buf[0] = '+'; + buf[1] = 'I'; + buf[2] = 'n'; + buf[3] = 'f';// "+Inf" + bufpt = 4; } - if (flag_leftjustify) { - int nspace; - nspace = width - length; - if (nspace > 0) { - appendSpace(pAccum, nspace); - } + else + { + buf[0] = 'I'; + buf[1] = 'n'; + buf[2] = 'f';// "Inf" + bufpt = 3; } - //if( zExtra ){ - // sqlite3DbFree(db,ref zExtra); - //} - }/* End for loop over the format string */ - } /* End of function */ - - /* - ** Append N bytes of text from z to the StrAccum object. - */ + length = sqlite3Strlen30( bufpt );// sqlite3Strlen30(bufpt); + bufpt = 0; + break; + } + } + bufpt = 0; + /* + ** If the field type is etGENERIC, then convert to either etEXP + ** or etFLOAT, as appropriate. + */ + flag_exp = xtype == etEXP; + if ( xtype != etFLOAT ) + { + realvalue += rounder; + if ( realvalue >= 10.0 ) + { + realvalue *= 0.1; + exp++; + } + } + if ( xtype == etGENERIC ) + { + flag_rtz = !flag_alternateform; + if ( exp < -4 || exp > precision ) + { + xtype = etEXP; + } + else + { + precision = precision - exp; + xtype = etFLOAT; + } + } + else + { + flag_rtz = false; + } + if ( xtype == etEXP ) + { + e2 = 0; + } + else + { + e2 = exp; + } + nsd = 0; + flag_dp = ( precision > 0 ? true : false ) | flag_alternateform | flag_altform2; + /* The sign in front of the number */ + if ( prefix != '\0' ) + { + buf[bufpt++] = prefix; + } + /* Digits prior to the decimal point */ + if ( e2 < 0 ) + { + buf[bufpt++] = '0'; + } + else + { + for ( ; e2 >= 0; e2-- ) + { + buf[bufpt++] = (char)( et_getdigit( ref realvalue, ref nsd ) + '0' ); // *(bufpt++) = et_getdigit(ref realvalue, ref nsd); + } - static void sqlite3StrAccumAppend(StrAccum p, string z, int N) { - Debug.Assert(z != null || N == 0); - if (p.tooBig)//|| p.mallocFailed != 0 ) + } + /* The decimal point */ + if ( flag_dp ) { - testcase(p.tooBig); - //testcase( p.mallocFailed ); - return; + buf[bufpt++] = '.'; } - if (N < 0) { - N = sqlite3Strlen30(z); + /* "0" digits after the decimal point but before the first + ** significant digit of the number */ + for ( e2++; e2 < 0; precision--, e2++ ) + { + Debug.Assert( precision > 0 ); + buf[bufpt++] = '0'; } - if (N == 0 || NEVER(z == null)) { - return; + /* Significant digits after the decimal point */ + while ( ( precision-- ) > 0 ) + { + buf[bufpt++] = (char)( et_getdigit( ref realvalue, ref nsd ) + '0' ); // *(bufpt++) = et_getdigit(&realvalue, nsd); } - //if( p->nChar+N >= p->nAlloc ){ - // string zNew; - // if( null==p->useMalloc ){ - // p->tooBig = 1; - // N = p->nAlloc - p->nChar - 1; - // if( N<=0 ){ - // return; - // } - // }else{ - // string zOld = (p->zText==p->zBase ? 0 : p->zText); - // i64 szNew = p->nChar; - // szNew += N + 1; - // if( szNew > p->mxAlloc ){ - // sqlite3StrAccumReset(p); - // p->tooBig = 1; - // return; - // }else{ - // p->nAlloc = (int)szNew; - // } - // if( p->useMalloc==1 ){ - // zNew = sqlite3DbRealloc(p->db, zOld, p->nAlloc); - // }else{ - // zNew = sqlite3_realloc(zOld, p->nAlloc); - // } - // if( zNew ){ - // if( zOld==0 ) memcpy(zNew, p->zText, p->nChar); - // p->zText = zNew; - // }else{ - // p->mallocFailed = 1; - // sqlite3StrAccumReset(p); - // return; - // } - // } - //} - //memcpy(&p->zText[p->nChar], z, N); - p.zText.Append(z.Substring(0, N <= z.Length ? N : z.Length)); - //p.nChar += N; - } + /* Remove trailing zeros and the "." if no digits follow the "." */ + if ( flag_rtz && flag_dp ) + { + while ( buf[bufpt - 1] == '0' ) + buf[--bufpt] = '\0'; + Debug.Assert( bufpt > 0 ); + if ( buf[bufpt - 1] == '.' ) + { + if ( flag_altform2 ) + { + buf[( bufpt++ )] = '0'; + } + else + { + buf[( --bufpt )] = '0'; + } + } + } + /* Add the "eNNN" suffix */ + if ( flag_exp || xtype == etEXP ) + { + buf[bufpt++] = aDigits[infop.charset]; + if ( exp < 0 ) + { + buf[bufpt++] = '-'; + exp = -exp; + } + else + { + buf[bufpt++] = '+'; + } + if ( exp >= 100 ) + { + buf[bufpt++] = (char)( exp / 100 + '0' ); /* 100's digit */ + exp %= 100; + } + buf[bufpt++] = (char)( exp / 10 + '0' ); /* 10's digit */ + buf[bufpt++] = (char)( exp % 10 + '0' ); /* 1's digit */ + } + //bufpt = 0; - /* - ** Finish off a string by making sure it is zero-terminated. - ** Return a pointer to the resulting string. Return a NULL - ** pointer if any kind of error was encountered. - */ - static string sqlite3StrAccumFinish(StrAccum p) { - //if ( p->zText ) - //{ - // p->zText[p->nChar] = 0; - // if ( p->useMalloc && p->zText == p->zBase ) - // { - // if ( p->useMalloc == 1 ) - // { - // p->zText = sqlite3DbMallocRaw( p->db, p->nChar + 1 ); - // } - // else - // { - // p->zText = sqlite3_malloc( p->nChar + 1 ); - // } - // if ( p->zText ) - // { - // memcpy( p->zText, p->zBase, p->nChar + 1 ); - // } - // else - // { - // p->mallocFailed = 1; - // } - // } - //} - return p.zText.ToString(); - } + /* The converted number is in buf[] and zero terminated. Output it. + ** Note that the number is in the usual order, not reversed as with + ** integer conversions. */ + length = bufpt;//length = (int)(bufpt-buf); + bufpt = 0; + /* Special case: Add leading zeros if the flag_zeropad flag is + ** set and we are not left justified */ + if ( flag_zeropad && !flag_leftjustify && length < width ) + { + int i; + int nPad = width - length; + for ( i = width; i >= nPad; i-- ) + { + buf[bufpt + i] = buf[bufpt + i - nPad]; + } + i = ( prefix != '\0' ? 1 : 0 ); + while ( nPad-- != 0 ) + buf[( bufpt++ ) + i] = '0'; + length = width; + bufpt = 0; + } +#endif //* !defined(SQLITE_OMIT_FLOATING_POINT) */ + break; + case etSIZE: + ap[0] = pAccum.nChar; // *(va_arg(ap,int)) = pAccum.nChar; + length = width = 0; + break; + case etPERCENT: + buf[0] = '%'; + bufpt = 0; + length = 1; + break; + case etCHARX: + c = va_arg( ap, (Char) 0); + buf[0] = (char)c; + if ( precision >= 0 ) + { + for ( idx = 1; idx < precision; idx++ ) + buf[idx] = (char)c; + length = precision; + } + else + { + length = 1; + } + bufpt = 0; + break; + case etSTRING: + case etDYNSTRING: + bufpt = 0;// + string bufStr = (string)va_arg( ap, "string" ); + if ( bufStr.Length > buf.Length ) + buf = new char[bufStr.Length]; + bufStr.ToCharArray().CopyTo( buf, 0 ); + bufpt = bufStr.Length; + if ( bufpt == 0 ) + { + buf[0] = '\0'; + } + else if ( xtype == etDYNSTRING ) + { + // zExtra = bufpt; + } + if ( precision >= 0 ) + { + for ( length = 0; length < precision && length < bufStr.Length && buf[length] != 0; length++ ) + { + } + //length += precision; + } + else + { + length = sqlite3Strlen30( bufpt ); + } + bufpt = 0; + break; + case etSQLESCAPE: + case etSQLESCAPE2: + case etSQLESCAPE3: + { + int i; + int j; + int k; + int n; + bool isnull; + bool needQuote; + char ch; + char q = ( ( xtype == etSQLESCAPE3 ) ? '"' : '\'' ); /* Quote character */ + string escarg = (string)va_arg( ap, "char*" ) + '\0'; + isnull = ( escarg == "" || escarg == "NULL\0" ); + if ( isnull ) + escarg = ( xtype == etSQLESCAPE2 ) ? "NULL\0" : "(NULL)\0"; + k = precision; + for ( i = n = 0; k != 0 && ( ch = escarg[i] ) != 0; i++, k-- ) + { + if ( ch == q ) + n++; + } + needQuote = !isnull && ( xtype == etSQLESCAPE2 ); + n += i + 1 + ( needQuote ? 2 : 0 ); + if ( n > etBUFSIZE ) + { + buf = new char[n];//bufpt = zExtra = sqlite3Malloc(n); + //if ( bufpt == 0 ) + //{ + // pAccum->mallocFailed = 1; + // return; + //} + bufpt = 0; //Start of Buffer + } + else + { + //bufpt = buf; + bufpt = 0; //Start of Buffer + } + j = 0; + if ( needQuote ) + buf[bufpt + j++] = q; + k = i; + for ( i = 0; i < k; i++ ) + { + buf[bufpt + j++] = ch = escarg[i]; + if ( ch == q ) + buf[bufpt + j++] = ch; + } + if ( needQuote ) + buf[bufpt + j++] = q; + buf[bufpt + j] = '\0'; + length = j; + /* The precision in %q and %Q means how many input characters to + ** consume, not the length of the output... + ** if( precision>=0 && precision= 0 && k < pSrc.nSrc ); + if ( pItem.zDatabase != null ) + { + sqlite3StrAccumAppend( pAccum, pItem.zDatabase, -1 ); + sqlite3StrAccumAppend( pAccum, ".", 1 ); + } + sqlite3StrAccumAppend( pAccum, pItem.zName, -1 ); + length = width = 0; + break; + } + default: + { + Debug.Assert( xtype == etINVALID ); + return; + } + }/* End switch over the format type */ /* - ** Reset an StrAccum string. Reclaim all malloced memory. + ** The text of the conversion is pointed to by "bufpt" and is + ** "length" characters long. The field width is "width". Do + ** the output. */ - static void sqlite3StrAccumReset(StrAccum p) { - //if ( p.zText.ToString() != p.zBase.ToString() ) - //{ - // if ( p.useMalloc == 1 ) - // { - // sqlite3DbFree( p.db, ref p.zText ); - // } - // else - // { - // sqlite3_free( ref p.zText ); - // } - //} - p.zText.Length = 0; + if ( !flag_leftjustify ) + { + int nspace; + nspace = width - length;// -2; + if ( nspace > 0 ) + { + appendSpace( pAccum, nspace ); + } } - - /* - ** Initialize a string accumulator - */ - static void sqlite3StrAccumInit(StrAccum p, StringBuilder zBase, int n, int mx) { - //p.zBase.Length = 0; - //if ( p.zBase.Capacity < n ) - // p.zBase.Capacity = n; - p.zText.Length = 0; - if (p.zText.Capacity < n) - p.zText.Capacity = n; - p.db = null; - //p.nChar = 0; - //p.nAlloc = n; - p.mxAlloc = mx; - //p.useMalloc = 1; - //p.tooBig = 0; - //p.mallocFailed = 0; + if ( length > 0 ) + { + sqlite3StrAccumAppend( pAccum, new string( buf, bufpt, length ), length ); } - /* - ** Print into memory obtained from sqliteMalloc(). Use the internal - ** %-conversion extensions. - */ - static StrAccum acc = new StrAccum(SQLITE_PRINT_BUF_SIZE); - static string sqlite3VMPrintf(sqlite3 db, string zFormat, params va_list[] ap) { - if (zFormat == null) - return null; - if (ap.Length == 0) - return zFormat; - //string z; - Debug.Assert(db != null); - sqlite3StrAccumInit(acc, null, SQLITE_PRINT_BUF_SIZE, - db.aLimit[SQLITE_LIMIT_LENGTH]); - acc.db = db; - acc.zText.Length = 0; - sqlite3VXPrintf(acc, 1, zFormat, ap); - // if ( acc.mallocFailed != 0 ) - // { - ////// db.mallocFailed = 1; - // } - return sqlite3StrAccumFinish(acc); + if ( flag_leftjustify ) + { + int nspace; + nspace = width - length; + if ( nspace > 0 ) + { + appendSpace( pAccum, nspace ); + } } + //if( zExtra ){ + // sqlite3DbFree(db,ref zExtra); + //} + }/* End for loop over the format string */ + } /* End of function */ - /* - ** Print into memory obtained from sqliteMalloc(). Use the internal - ** %-conversion extensions. - */ - static string sqlite3MPrintf(sqlite3 db, string zFormat, params va_list[] ap) { - string z; - //va_list ap; - lock (lock_va_list) { - va_start(ap, zFormat); - z = sqlite3VMPrintf(db, zFormat, ap); - va_end(ref ap); - } - return z; - } + /* + ** Append N bytes of text from z to the StrAccum object. + */ - /* - ** Like sqlite3MPrintf(), but call sqlite3DbFree() on zStr after formatting - ** the string and before returnning. This routine is intended to be used - ** to modify an existing string. For example: - ** - ** x = sqlite3MPrintf(db, x, "prefix %s suffix", x); - ** - */ - static string sqlite3MAppendf(sqlite3 db, string zStr, string zFormat, params va_list[] ap) { - string z; - //va_list ap; - lock (lock_va_list) { - va_start(ap, zFormat); - z = sqlite3VMPrintf(db, zFormat, ap); - va_end(ref ap); - sqlite3DbFree(db, ref zStr); - } - return z; - } + static void sqlite3StrAccumAppend( StrAccum p, string z, int N ) + { + Debug.Assert( z != null || N == 0 ); + if ( p.tooBig )//|| p.mallocFailed != 0 ) + { + testcase( p.tooBig ); + //testcase( p.mallocFailed ); + return; + } + if ( N < 0 ) + { + N = sqlite3Strlen30( z ); + } + if ( N == 0 || NEVER( z == null ) ) + { + return; + } + //if( p->nChar+N >= p->nAlloc ){ + // string zNew; + // if( null==p->useMalloc ){ + // p->tooBig = 1; + // N = p->nAlloc - p->nChar - 1; + // if( N<=0 ){ + // return; + // } + // }else{ + // string zOld = (p->zText==p->zBase ? 0 : p->zText); + // i64 szNew = p->nChar; + // szNew += N + 1; + // if( szNew > p->mxAlloc ){ + // sqlite3StrAccumReset(p); + // p->tooBig = 1; + // return; + // }else{ + // p->nAlloc = (int)szNew; + // } + // if( p->useMalloc==1 ){ + // zNew = sqlite3DbRealloc(p->db, zOld, p->nAlloc); + // }else{ + // zNew = sqlite3_realloc(zOld, p->nAlloc); + // } + // if( zNew ){ + // if( zOld==0 ) memcpy(zNew, p->zText, p->nChar); + // p->zText = zNew; + // }else{ + // p->mallocFailed = 1; + // sqlite3StrAccumReset(p); + // return; + // } + // } + //} + //memcpy(&p->zText[p->nChar], z, N); + p.zText.Append( z.Substring( 0, N <= z.Length ? N : z.Length ) ); + //p.nChar += N; + } - /* - ** Print into memory obtained from sqlite3Malloc(). Omit the internal - ** %-conversion extensions. - */ - static string sqlite3_vmprintf(string zFormat, params va_list[] ap) { - //StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); + /* + ** Finish off a string by making sure it is zero-terminated. + ** Return a pointer to the resulting string. Return a NULL + ** pointer if any kind of error was encountered. + */ + static string sqlite3StrAccumFinish( StrAccum p ) + { + //if ( p->zText ) + //{ + // p->zText[p->nChar] = 0; + // if ( p->useMalloc && p->zText == p->zBase ) + // { + // if ( p->useMalloc == 1 ) + // { + // p->zText = sqlite3DbMallocRaw( p->db, p->nChar + 1 ); + // } + // else + // { + // p->zText = sqlite3_malloc( p->nChar + 1 ); + // } + // if ( p->zText ) + // { + // memcpy( p->zText, p->zBase, p->nChar + 1 ); + // } + // else + // { + // p->mallocFailed = 1; + // } + // } + //} + return p.zText.ToString(); + } + + /* + ** Reset an StrAccum string. Reclaim all malloced memory. + */ + static void sqlite3StrAccumReset( StrAccum p ) + { + //if ( p.zText.ToString() != p.zBase.ToString() ) + //{ + // if ( p.useMalloc == 1 ) + // { + // sqlite3DbFree( p.db, ref p.zText ); + // } + // else + // { + // sqlite3_free( ref p.zText ); + // } + //} + p.zText.Length = 0; + } + + /* + ** Initialize a string accumulator + */ + static void sqlite3StrAccumInit( StrAccum p, StringBuilder zBase, int n, int mx ) + { + //p.zBase.Length = 0; + //if ( p.zBase.Capacity < n ) + // p.zBase.Capacity = n; + p.zText.Length = 0; + if ( p.zText.Capacity < n ) + p.zText.Capacity = n; + p.db = null; + //p.nChar = 0; + //p.nAlloc = n; + p.mxAlloc = mx; + //p.useMalloc = 1; + //p.tooBig = 0; + //p.mallocFailed = 0; + } + /* + ** Print into memory obtained from sqliteMalloc(). Use the internal + ** %-conversion extensions. + */ + static StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); + static string sqlite3VMPrintf( sqlite3 db, string zFormat, params va_list[] ap ) + { + if ( zFormat == null ) + return null; + if ( ap.Length == 0 ) + return zFormat; + //string z; + Debug.Assert( db != null ); + sqlite3StrAccumInit( acc, null, SQLITE_PRINT_BUF_SIZE, + db.aLimit[SQLITE_LIMIT_LENGTH] ); + acc.db = db; + acc.zText.Length = 0; + sqlite3VXPrintf( acc, 1, zFormat, ap ); + // if ( acc.mallocFailed != 0 ) + // { + ////// db.mallocFailed = 1; + // } + return sqlite3StrAccumFinish( acc ); + } + + /* + ** Print into memory obtained from sqliteMalloc(). Use the internal + ** %-conversion extensions. + */ + static string sqlite3MPrintf( sqlite3 db, string zFormat, params va_list[] ap ) + { + string z; + //va_list ap; + lock ( lock_va_list ) + { + va_start( ap, zFormat ); + z = sqlite3VMPrintf( db, zFormat, ap ); + va_end( ref ap ); + } + return z; + } + + /* + ** Like sqlite3MPrintf(), but call sqlite3DbFree() on zStr after formatting + ** the string and before returnning. This routine is intended to be used + ** to modify an existing string. For example: + ** + ** x = sqlite3MPrintf(db, x, "prefix %s suffix", x); + ** + */ + static string sqlite3MAppendf( sqlite3 db, string zStr, string zFormat, params va_list[] ap ) + { + string z; + //va_list ap; + lock ( lock_va_list ) + { + va_start( ap, zFormat ); + z = sqlite3VMPrintf( db, zFormat, ap ); + va_end( ref ap ); + sqlite3DbFree( db, ref zStr ); + } + return z; + } + + /* + ** Print into memory obtained from sqlite3Malloc(). Omit the internal + ** %-conversion extensions. + */ + static string sqlite3_vmprintf( string zFormat, params va_list[] ap ) + { + //StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); #if !SQLITE_OMIT_AUTOINIT - if (sqlite3_initialize() != 0) - return ""; + if ( sqlite3_initialize() != 0 ) + return ""; #endif - sqlite3StrAccumInit(acc, null, SQLITE_PRINT_BUF_SIZE, SQLITE_PRINT_BUF_SIZE);//zBase).Length; - //acc.useMalloc = 2; - sqlite3VXPrintf(acc, 0, zFormat, ap); - return sqlite3StrAccumFinish(acc); - } + sqlite3StrAccumInit( acc, null, SQLITE_PRINT_BUF_SIZE, SQLITE_PRINT_BUF_SIZE );//zBase).Length; + //acc.useMalloc = 2; + sqlite3VXPrintf( acc, 0, zFormat, ap ); + return sqlite3StrAccumFinish( acc ); + } - /* - ** Print into memory obtained from sqlite3Malloc()(). Omit the internal - ** %-conversion extensions. - */ - static public string sqlite3_mprintf(string zFormat, params va_list[] ap) { //, ...){ - string z; -#if !SQLITE_OMIT_AUTOINIT - if (sqlite3_initialize() != 0) - return ""; + /* + ** Print into memory obtained from sqlite3Malloc()(). Omit the internal + ** %-conversion extensions. + */ + static public string sqlite3_mprintf( string zFormat, params va_list[] ap ) + { //, ...){ + string z; +#if !SQLITE_OMIT_AUTOINIT + if ( sqlite3_initialize() != 0 ) + return ""; #endif - //va_list ap; - lock (lock_va_list) { - va_start(ap, zFormat); - z = sqlite3_vmprintf(zFormat, ap); - va_end(ref ap); - } - return z; - } + //va_list ap; + lock ( lock_va_list ) + { + va_start( ap, zFormat ); + z = sqlite3_vmprintf( zFormat, ap ); + va_end( ref ap ); + } + return z; + } - /* - ** sqlite3_snprintf() works like snprintf() except that it ignores the - ** current locale settings. This is important for SQLite because we - ** are not able to use a "," as the decimal point in place of "." as - ** specified by some locales. - ** - ** Oops: The first two arguments of sqlite3_snprintf() are backwards - ** from the snprintf() standard. Unfortunately, it is too late to change - ** this without breaking compatibility, so we just have to live with the - ** mistake. - ** - ** sqlite3_vsnprintf() is the varargs version. - */ - static public void sqlite3_vsnprintf(int n, StringBuilder zBuf, string zFormat, params va_list[] ap) { - //StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); - if (n <= 0) - return; - sqlite3StrAccumInit(acc, null, n, 0); - //acc.useMalloc = 0; - sqlite3VXPrintf(acc, 0, zFormat, ap); - zBuf.Length = 0; - if (n > 1 && n <= acc.zText.Length) - acc.zText.Length = n - 1; - zBuf.Append(sqlite3StrAccumFinish(acc)); - return; - } + /* + ** sqlite3_snprintf() works like snprintf() except that it ignores the + ** current locale settings. This is important for SQLite because we + ** are not able to use a "," as the decimal point in place of "." as + ** specified by some locales. + ** + ** Oops: The first two arguments of sqlite3_snprintf() are backwards + ** from the snprintf() standard. Unfortunately, it is too late to change + ** this without breaking compatibility, so we just have to live with the + ** mistake. + ** + ** sqlite3_vsnprintf() is the varargs version. + */ + static public void sqlite3_vsnprintf( int n, StringBuilder zBuf, string zFormat, params va_list[] ap ) + { + //StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); + if ( n <= 0 ) + return; + sqlite3StrAccumInit( acc, null, n, 0 ); + //acc.useMalloc = 0; + sqlite3VXPrintf( acc, 0, zFormat, ap ); + zBuf.Length = 0; + if ( n > 1 && n <= acc.zText.Length ) + acc.zText.Length = n - 1; + zBuf.Append( sqlite3StrAccumFinish( acc ) ); + return; + } - static public void sqlite3_snprintf(int n, StringBuilder zBuf, string zFormat, params va_list[] ap) { - //string z; - //va_list ap; - lock (lock_va_list) {//StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); - zBuf.EnsureCapacity(SQLITE_PRINT_BUF_SIZE); - va_start(ap, zFormat); - sqlite3_vsnprintf(n, zBuf, zFormat, ap); - va_end(ref ap); - } - return; - } + static public void sqlite3_snprintf( int n, StringBuilder zBuf, string zFormat, params va_list[] ap ) + { + //string z; + //va_list ap; + lock ( lock_va_list ) + {//StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); + zBuf.EnsureCapacity( SQLITE_PRINT_BUF_SIZE ); + va_start( ap, zFormat ); + sqlite3_vsnprintf( n, zBuf, zFormat, ap ); + va_end( ref ap ); + } + return; + } - //static public string sqlite3_snprintf( int n, ref string zBuf, string zFormat, params va_list[] ap ) - //{ - // string z; - // //va_list ap; - // StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); + //static public string sqlite3_snprintf( int n, ref string zBuf, string zFormat, params va_list[] ap ) + //{ + // string z; + // //va_list ap; + // StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); - // if ( n <= 0 ) - // { - // return zBuf; - // } - // sqlite3StrAccumInit( acc, null, n, 0 ); - // //acc.useMalloc = 0; - // va_start( ap, zFormat ); - // sqlite3VXPrintf( acc, 0, zFormat, ap ); - // va_end( ap ); - // z = sqlite3StrAccumFinish( acc ); - // return ( zBuf = z ); - //} + // if ( n <= 0 ) + // { + // return zBuf; + // } + // sqlite3StrAccumInit( acc, null, n, 0 ); + // //acc.useMalloc = 0; + // va_start( ap, zFormat ); + // sqlite3VXPrintf( acc, 0, zFormat, ap ); + // va_end( ap ); + // z = sqlite3StrAccumFinish( acc ); + // return ( zBuf = z ); + //} - /* - ** This is the routine that actually formats the sqlite3_log() message. - ** We house it in a separate routine from sqlite3_log() to avoid using - ** stack space on small-stack systems when logging is disabled. - ** - ** sqlite3_log() must render into a static buffer. It cannot dynamically - ** allocate memory because it might be called while the memory allocator - ** mutex is held. - */ - static void renderLogMsg(int iErrCode, string zFormat, params object[] ap) { - //StrAccum acc; /* String accumulator */ - //char zMsg[SQLITE_PRINT_BUF_SIZE*3]; /* Complete log message */ + /* + ** This is the routine that actually formats the sqlite3_log() message. + ** We house it in a separate routine from sqlite3_log() to avoid using + ** stack space on small-stack systems when logging is disabled. + ** + ** sqlite3_log() must render into a static buffer. It cannot dynamically + ** allocate memory because it might be called while the memory allocator + ** mutex is held. + */ + static void renderLogMsg( int iErrCode, string zFormat, params object[] ap ) + { + //StrAccum acc; /* String accumulator */ + //char zMsg[SQLITE_PRINT_BUF_SIZE*3]; /* Complete log message */ - sqlite3StrAccumInit(acc, null, SQLITE_PRINT_BUF_SIZE * 3, 0); - //acc.useMalloc = 0; - sqlite3VXPrintf(acc, 0, zFormat, ap); - sqlite3GlobalConfig.xLog(sqlite3GlobalConfig.pLogArg, iErrCode, - sqlite3StrAccumFinish(acc)); - } + sqlite3StrAccumInit( acc, null, SQLITE_PRINT_BUF_SIZE * 3, 0 ); + //acc.useMalloc = 0; + sqlite3VXPrintf( acc, 0, zFormat, ap ); + sqlite3GlobalConfig.xLog( sqlite3GlobalConfig.pLogArg, iErrCode, + sqlite3StrAccumFinish( acc ) ); + } - /* - ** Format and write a message to the log if logging is enabled. - */ - static void sqlite3_log(int iErrCode, string zFormat, params va_list[] ap) { - if (sqlite3GlobalConfig != null && sqlite3GlobalConfig.xLog != null) { - //va_list ap; /* Vararg list */ - lock (lock_va_list) { - va_start(ap, zFormat); - renderLogMsg(iErrCode, zFormat, ap); - va_end(ref ap); - } - } + /* + ** Format and write a message to the log if logging is enabled. + */ + static void sqlite3_log( int iErrCode, string zFormat, params va_list[] ap ) + { + if (sqlite3GlobalConfig != null && sqlite3GlobalConfig.xLog != null) + { + //va_list ap; /* Vararg list */ + lock ( lock_va_list ) + { + va_start( ap, zFormat ); + renderLogMsg( iErrCode, zFormat, ap ); + va_end( ref ap ); } + } + } #if SQLITE_DEBUG || DEBUG || TRACE - /* - ** A version of printf() that understands %lld. Used for debugging. - ** The printf() built into some versions of windows does not understand %lld - ** and segfaults if you give it a long long int. - */ - static void sqlite3DebugPrintf(string zFormat, params va_list[] ap) { - //va_list ap; - lock (lock_va_list) { - //StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); - sqlite3StrAccumInit(acc, null, SQLITE_PRINT_BUF_SIZE, 0); - //acc.useMalloc = 0; - va_start(ap, zFormat); - sqlite3VXPrintf(acc, 0, zFormat, ap); - va_end(ref ap); - } + /* +** A version of printf() that understands %lld. Used for debugging. +** The printf() built into some versions of windows does not understand %lld +** and segfaults if you give it a long long int. +*/ + static void sqlite3DebugPrintf( string zFormat, params va_list[] ap ) + { + //va_list ap; + lock ( lock_va_list ) + { + //StrAccum acc = new StrAccum( SQLITE_PRINT_BUF_SIZE ); + sqlite3StrAccumInit( acc, null, SQLITE_PRINT_BUF_SIZE, 0 ); + //acc.useMalloc = 0; + va_start( ap, zFormat ); + sqlite3VXPrintf( acc, 0, zFormat, ap ); + va_end( ref ap ); + } #if !SQLITE_WINRT - Console.Write(sqlite3StrAccumFinish(acc)); + Console.Write( sqlite3StrAccumFinish( acc ) ); #endif - //fflush(stdout); - } + //fflush(stdout); + } #endif #if !SQLITE_OMIT_TRACE - /* - ** variable-argument wrapper around sqlite3VXPrintf(). - */ - static void sqlite3XPrintf(StrAccum p, string zFormat, params object[] ap) { - //va_list ap; - lock (lock_va_list) { - va_start(ap, zFormat); - sqlite3VXPrintf(p, 1, zFormat, ap); - va_end(ref ap); - } - } + /* +** variable-argument wrapper around sqlite3VXPrintf(). +*/ + static void sqlite3XPrintf( StrAccum p, string zFormat, params object[] ap ) + { + //va_list ap; + lock ( lock_va_list ) + { + va_start( ap, zFormat ); + sqlite3VXPrintf( p, 1, zFormat, ap ); + va_end( ref ap ); + } + } #endif - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/random_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/random_c.cs index 1aab77f64..254076e35 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/random_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/random_c.cs @@ -1,186 +1,203 @@ using System; +using System.Diagnostics; using i64 = System.Int64; -using u32 = System.UInt32; using u8 = System.Byte; +using u32 = System.UInt32; +using u64 = System.UInt64; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 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. - ** - ************************************************************************* - ** This file contains code to implement a pseudo-random number - ** generator (PRNG) for SQLite. - ** - ** Random numbers are used by some of the database backends in order - ** to generate random integer keys for tables or random filenames. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 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. + ** + ************************************************************************* + ** This file contains code to implement a pseudo-random number + ** generator (PRNG) for SQLite. + ** + ** Random numbers are used by some of the database backends in order + ** to generate random integer keys for tables or random filenames. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" - /* All threads share a single random number generator. - ** This structure is the current state of the generator. - */ - public class sqlite3PrngType { - public bool isInit; /* True if initialized */ - public int i; - public int j; /* State variables */ - public u8[] s = new u8[256]; /* State variables */ + /* All threads share a single random number generator. + ** This structure is the current state of the generator. + */ + public class sqlite3PrngType + { + public bool isInit; /* True if initialized */ + public int i; + public int j; /* State variables */ + public u8[] s = new u8[256]; /* State variables */ - public sqlite3PrngType Copy() { - sqlite3PrngType cp = (sqlite3PrngType)MemberwiseClone(); - cp.s = new u8[s.Length]; - Array.Copy(s, cp.s, s.Length); - return cp; - } - } - public static sqlite3PrngType sqlite3Prng = new sqlite3PrngType(); - /* - ** Get a single 8-bit random value from the RC4 PRNG. The Mutex - ** must be held while executing this routine. - ** - ** Why not just use a library random generator like lrand48() for this? - ** Because the OP_NewRowid opcode in the VDBE depends on having a very - ** good source of random numbers. The lrand48() library function may - ** well be good enough. But maybe not. Or maybe lrand48() has some - ** subtle problems on some systems that could cause problems. It is hard - ** to know. To minimize the risk of problems due to bad lrand48() - ** implementations, SQLite uses this random number generator based - ** on RC4, which we know works very well. - ** - ** (Later): Actually, OP_NewRowid does not depend on a good source of - ** randomness any more. But we will leave this code in all the same. - */ - static u8 randomu8() { - u8 t; + public sqlite3PrngType Copy() + { + sqlite3PrngType cp = (sqlite3PrngType)MemberwiseClone(); + cp.s = new u8[s.Length]; + Array.Copy( s, cp.s, s.Length ); + return cp; + } + } + public static sqlite3PrngType sqlite3Prng = new sqlite3PrngType(); + /* + ** Get a single 8-bit random value from the RC4 PRNG. The Mutex + ** must be held while executing this routine. + ** + ** Why not just use a library random generator like lrand48() for this? + ** Because the OP_NewRowid opcode in the VDBE depends on having a very + ** good source of random numbers. The lrand48() library function may + ** well be good enough. But maybe not. Or maybe lrand48() has some + ** subtle problems on some systems that could cause problems. It is hard + ** to know. To minimize the risk of problems due to bad lrand48() + ** implementations, SQLite uses this random number generator based + ** on RC4, which we know works very well. + ** + ** (Later): Actually, OP_NewRowid does not depend on a good source of + ** randomness any more. But we will leave this code in all the same. + */ + static u8 randomu8() + { + u8 t; - /* The "wsdPrng" macro will resolve to the pseudo-random number generator - ** state vector. If writable static data is unsupported on the target, - ** we have to locate the state vector at run-time. In the more common - ** case where writable static data is supported, wsdPrng can refer directly - ** to the "sqlite3Prng" state vector declared above. - */ + /* The "wsdPrng" macro will resolve to the pseudo-random number generator + ** state vector. If writable static data is unsupported on the target, + ** we have to locate the state vector at run-time. In the more common + ** case where writable static data is supported, wsdPrng can refer directly + ** to the "sqlite3Prng" state vector declared above. + */ #if SQLITE_OMIT_WSD struct sqlite3PrngType *p = &GLOBAL(struct sqlite3PrngType, sqlite3Prng); //# define wsdPrng p[0] #else - //# define wsdPrng sqlite3Prng - sqlite3PrngType wsdPrng = sqlite3Prng; + //# define wsdPrng sqlite3Prng + sqlite3PrngType wsdPrng = sqlite3Prng; #endif - /* Initialize the state of the random number generator once, - ** the first time this routine is called. The seed value does - ** not need to contain a lot of randomness since we are not - ** trying to do secure encryption or anything like that... - ** - ** Nothing in this file or anywhere else in SQLite does any kind of - ** encryption. The RC4 algorithm is being used as a PRNG (pseudo-random - ** number generator) not as an encryption device. - */ - if (!wsdPrng.isInit) { - int i; - u8[] k = new u8[256]; - wsdPrng.j = 0; - wsdPrng.i = 0; - sqlite3OsRandomness(sqlite3_vfs_find(""), 256, k); - for (i = 0; i < 255; i++) { - wsdPrng.s[i] = (u8)i; - } - for (i = 0; i < 255; i++) { - wsdPrng.j = (u8)(wsdPrng.j + wsdPrng.s[i] + k[i]); - t = wsdPrng.s[wsdPrng.j]; - wsdPrng.s[wsdPrng.j] = wsdPrng.s[i]; - wsdPrng.s[i] = t; - } - wsdPrng.isInit = true; - } - - /* Generate and return single random u8 - */ - wsdPrng.i++; - t = wsdPrng.s[(u8)wsdPrng.i]; - wsdPrng.j = (u8)(wsdPrng.j + t); - wsdPrng.s[(u8)wsdPrng.i] = wsdPrng.s[wsdPrng.j]; - wsdPrng.s[wsdPrng.j] = t; - t += wsdPrng.s[(u8)wsdPrng.i]; - return wsdPrng.s[t]; + /* Initialize the state of the random number generator once, +** the first time this routine is called. The seed value does +** not need to contain a lot of randomness since we are not +** trying to do secure encryption or anything like that... +** +** Nothing in this file or anywhere else in SQLite does any kind of +** encryption. The RC4 algorithm is being used as a PRNG (pseudo-random +** number generator) not as an encryption device. +*/ + if ( !wsdPrng.isInit ) + { + int i; + u8[] k = new u8[256]; + wsdPrng.j = 0; + wsdPrng.i = 0; + sqlite3OsRandomness( sqlite3_vfs_find( "" ), 256, k ); + for ( i = 0; i < 255; i++ ) + { + wsdPrng.s[i] = (u8)i; } + for ( i = 0; i < 255; i++ ) + { + wsdPrng.j = (u8)( wsdPrng.j + wsdPrng.s[i] + k[i] ); + t = wsdPrng.s[wsdPrng.j]; + wsdPrng.s[wsdPrng.j] = wsdPrng.s[i]; + wsdPrng.s[i] = t; + } + wsdPrng.isInit = true; + } - /* - ** Return N random u8s. - */ - static void sqlite3_randomness(int N, ref i64 pBuf) { - //u8[] zBuf = new u8[N]; - pBuf = 0; + /* Generate and return single random u8 + */ + wsdPrng.i++; + t = wsdPrng.s[(u8)wsdPrng.i]; + wsdPrng.j = (u8)( wsdPrng.j + t ); + wsdPrng.s[(u8)wsdPrng.i] = wsdPrng.s[wsdPrng.j]; + wsdPrng.s[wsdPrng.j] = t; + t += wsdPrng.s[(u8)wsdPrng.i]; + return wsdPrng.s[t]; + } + + /* + ** Return N random u8s. + */ + static void sqlite3_randomness( int N, ref i64 pBuf ) + { + //u8[] zBuf = new u8[N]; + pBuf = 0; #if SQLITE_THREADSAFE - sqlite3_mutex mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PRNG); + sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_PRNG ); #endif - sqlite3_mutex_enter(mutex); - while (N-- > 0) { - pBuf = (u32)((pBuf << 8) + randomu8());// zBuf[N] = randomu8(); - } - sqlite3_mutex_leave(mutex); - } + sqlite3_mutex_enter( mutex ); + while ( N-- > 0 ) + { + pBuf = (u32)( ( pBuf << 8 ) + randomu8() );// zBuf[N] = randomu8(); + } + sqlite3_mutex_leave( mutex ); + } - static void sqlite3_randomness(byte[] pBuf, int Offset, int N) { - i64 iBuf = System.DateTime.Now.Ticks; + static void sqlite3_randomness( byte[] pBuf, int Offset, int N ) + { + i64 iBuf = System.DateTime.Now.Ticks; #if SQLITE_THREADSAFE - sqlite3_mutex mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PRNG); + sqlite3_mutex mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PRNG); #endif - sqlite3_mutex_enter(mutex); - while (N-- > 0) { - iBuf = (u32)((iBuf << 8) + randomu8());// zBuf[N] = randomu8(); - pBuf[Offset++] = (byte)iBuf; - } - sqlite3_mutex_leave(mutex); - } + sqlite3_mutex_enter( mutex ); + while ( N-- > 0 ) + { + iBuf = (u32)( ( iBuf << 8 ) + randomu8() );// zBuf[N] = randomu8(); + pBuf[Offset++] = (byte)iBuf; + } + sqlite3_mutex_leave( mutex ); + } #if !SQLITE_OMIT_BUILTIN_TEST - /* - ** For testing purposes, we sometimes want to preserve the state of - ** PRNG and restore the PRNG to its saved state at a later time, or - ** to reset the PRNG to its initial state. These routines accomplish - ** those tasks. - ** - ** The sqlite3_test_control() interface calls these routines to - ** control the PRNG. - */ - static sqlite3PrngType sqlite3SavedPrng = null; - static void sqlite3PrngSaveState() { - sqlite3SavedPrng = sqlite3Prng.Copy(); - // memcpy( - // &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng), - // &GLOBAL(struct sqlite3PrngType, sqlite3Prng), - // sizeof(sqlite3Prng) - //); - } - static void sqlite3PrngRestoreState() { - sqlite3Prng = sqlite3SavedPrng.Copy(); - //memcpy( - // &GLOBAL(struct sqlite3PrngType, sqlite3Prng), - // &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng), - // sizeof(sqlite3Prng) - //); - } - static void sqlite3PrngResetState() { - sqlite3Prng.isInit = false;// GLOBAL(struct sqlite3PrngType, sqlite3Prng).isInit = 0; - } -#endif //* SQLITE_OMIT_BUILTIN_TEST */ + /* +** For testing purposes, we sometimes want to preserve the state of +** PRNG and restore the PRNG to its saved state at a later time, or +** to reset the PRNG to its initial state. These routines accomplish +** those tasks. +** +** The sqlite3_test_control() interface calls these routines to +** control the PRNG. +*/ + static sqlite3PrngType sqlite3SavedPrng = null; + static void sqlite3PrngSaveState() + { + sqlite3SavedPrng = sqlite3Prng.Copy(); + // memcpy( + // &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng), + // &GLOBAL(struct sqlite3PrngType, sqlite3Prng), + // sizeof(sqlite3Prng) + //); + } + static void sqlite3PrngRestoreState() + { + sqlite3Prng = sqlite3SavedPrng.Copy(); + //memcpy( + // &GLOBAL(struct sqlite3PrngType, sqlite3Prng), + // &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng), + // sizeof(sqlite3Prng) + //); } + static void sqlite3PrngResetState() + { + sqlite3Prng.isInit = false;// GLOBAL(struct sqlite3PrngType, sqlite3Prng).isInit = 0; + } +#endif //* SQLITE_OMIT_BUILTIN_TEST */ + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/resolve_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/resolve_c.cs index ee2c6f246..a8bc5e437 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/resolve_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/resolve_c.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics; +using System.Text; using Bitmask = System.UInt64; using i16 = System.Int16; @@ -13,487 +14,556 @@ using ynVar = System.Int32; #endif -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2008 August 18 - ** - ** 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 contains routines used for walking the parser tree and - ** resolve all identifiers by associating them with a particular - ** table and column. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include - //#include +namespace Community.CsharpSqlite +{ + using sqlite3_value = Sqlite3.Mem; + + public partial class Sqlite3 + { + /* + ** 2008 August 18 + ** + ** 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 contains routines used for walking the parser tree and + ** resolve all identifiers by associating them with a particular + ** table and column. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include + //#include + + /* + ** Turn the pExpr expression into an alias for the iCol-th column of the + ** result set in pEList. + ** + ** If the result set column is a simple column reference, then this routine + ** makes an exact copy. But for any other kind of expression, this + ** routine make a copy of the result set column as the argument to the + ** TK_AS operator. The TK_AS operator causes the expression to be + ** evaluated just once and then reused for each alias. + ** + ** The reason for suppressing the TK_AS term when the expression is a simple + ** column reference is so that the column reference will be recognized as + ** usable by indices within the WHERE clause processing logic. + ** + ** Hack: The TK_AS operator is inhibited if zType[0]=='G'. This means + ** that in a GROUP BY clause, the expression is evaluated twice. Hence: + ** + ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY x + ** + ** Is equivalent to: + ** + ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY random()%5 + ** + ** The result of random()%5 in the GROUP BY clause is probably different + ** from the result in the result-set. We might fix this someday. Or + ** then again, we might not... + */ + static void resolveAlias( + Parse pParse, /* Parsing context */ + ExprList pEList, /* A result set */ + int iCol, /* A column in the result set. 0..pEList.nExpr-1 */ + Expr pExpr, /* Transform this into an alias to the result set */ + string zType /* "GROUP" or "ORDER" or "" */ + ) + { + Expr pOrig; /* The iCol-th column of the result set */ + Expr pDup; /* Copy of pOrig */ + sqlite3 db; /* The database connection */ + + Debug.Assert( iCol >= 0 && iCol < pEList.nExpr ); + pOrig = pEList.a[iCol].pExpr; + Debug.Assert( pOrig != null ); + Debug.Assert( ( pOrig.flags & EP_Resolved ) != 0 ); + db = pParse.db; + if ( pOrig.op != TK_COLUMN && ( zType.Length == 0 || zType[0] != 'G' ) ) + { + pDup = sqlite3ExprDup( db, pOrig, 0 ); + pDup = sqlite3PExpr( pParse, TK_AS, pDup, null, null ); + if ( pDup == null ) + return; + if ( pEList.a[iCol].iAlias == 0 ) + { + pEList.a[iCol].iAlias = (u16)( ++pParse.nAlias ); + } + pDup.iTable = pEList.a[iCol].iAlias; + } + else if ( ExprHasProperty( pOrig, EP_IntValue ) || pOrig.u.zToken == null ) + { + pDup = sqlite3ExprDup( db, pOrig, 0 ); + if ( pDup == null ) + return; + } + else + { + string zToken = pOrig.u.zToken; + Debug.Assert( zToken != null ); + pOrig.u.zToken = null; + pDup = sqlite3ExprDup( db, pOrig, 0 ); + pOrig.u.zToken = zToken; + if ( pDup == null ) + return; + Debug.Assert( ( pDup.flags & ( EP_Reduced | EP_TokenOnly ) ) == 0 ); + pDup.flags2 |= EP2_MallocedToken; + pDup.u.zToken = zToken;// sqlite3DbStrDup( db, zToken ); + } + if ( ( pExpr.flags & EP_ExpCollate ) != 0 ) + { + pDup.pColl = pExpr.pColl; + pDup.flags |= EP_ExpCollate; + } + + /* Before calling sqlite3ExprDelete(), set the EP_Static flag. This + ** prevents ExprDelete() from deleting the Expr structure itself, + ** allowing it to be repopulated by the memcpy() on the following line. + */ + ExprSetProperty( pExpr, EP_Static ); + sqlite3ExprDelete( db, ref pExpr ); + pExpr.CopyFrom( pDup ); //memcpy(pExpr, pDup, sizeof(*pExpr)); + sqlite3DbFree( db, ref pDup ); + } - /* - ** Turn the pExpr expression into an alias for the iCol-th column of the - ** result set in pEList. - ** - ** If the result set column is a simple column reference, then this routine - ** makes an exact copy. But for any other kind of expression, this - ** routine make a copy of the result set column as the argument to the - ** TK_AS operator. The TK_AS operator causes the expression to be - ** evaluated just once and then reused for each alias. - ** - ** The reason for suppressing the TK_AS term when the expression is a simple - ** column reference is so that the column reference will be recognized as - ** usable by indices within the WHERE clause processing logic. - ** - ** Hack: The TK_AS operator is inhibited if zType[0]=='G'. This means - ** that in a GROUP BY clause, the expression is evaluated twice. Hence: - ** - ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY x - ** - ** Is equivalent to: - ** - ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY random()%5 - ** - ** The result of random()%5 in the GROUP BY clause is probably different - ** from the result in the result-set. We might fix this someday. Or - ** then again, we might not... - */ - static void resolveAlias( - Parse pParse, /* Parsing context */ - ExprList pEList, /* A result set */ - int iCol, /* A column in the result set. 0..pEList.nExpr-1 */ - Expr pExpr, /* Transform this into an alias to the result set */ - string zType /* "GROUP" or "ORDER" or "" */ - ) { - Expr pOrig; /* The iCol-th column of the result set */ - Expr pDup; /* Copy of pOrig */ - sqlite3 db; /* The database connection */ - - Debug.Assert(iCol >= 0 && iCol < pEList.nExpr); - pOrig = pEList.a[iCol].pExpr; - Debug.Assert(pOrig != null); - Debug.Assert((pOrig.flags & EP_Resolved) != 0); - db = pParse.db; - if (pOrig.op != TK_COLUMN && (zType.Length == 0 || zType[0] != 'G')) { - pDup = sqlite3ExprDup(db, pOrig, 0); - pDup = sqlite3PExpr(pParse, TK_AS, pDup, null, null); - if (pDup == null) - return; - if (pEList.a[iCol].iAlias == 0) { - pEList.a[iCol].iAlias = (u16)(++pParse.nAlias); + /* + ** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up + ** that name in the set of source tables in pSrcList and make the pExpr + ** expression node refer back to that source column. The following changes + ** are made to pExpr: + ** + ** pExpr->iDb Set the index in db->aDb[] of the database X + ** (even if X is implied). + ** pExpr->iTable Set to the cursor number for the table obtained + ** from pSrcList. + ** pExpr->pTab Points to the Table structure of X.Y (even if + ** X and/or Y are implied.) + ** pExpr->iColumn Set to the column number within the table. + ** pExpr->op Set to TK_COLUMN. + ** pExpr->pLeft Any expression this points to is deleted + ** pExpr->pRight Any expression this points to is deleted. + ** + ** The zDb variable is the name of the database (the "X"). This value may be + ** NULL meaning that name is of the form Y.Z or Z. Any available database + ** can be used. The zTable variable is the name of the table (the "Y"). This + ** value can be NULL if zDb is also NULL. If zTable is NULL it + ** means that the form of the name is Z and that columns from any table + ** can be used. + ** + ** If the name cannot be resolved unambiguously, leave an error message + ** in pParse and return WRC_Abort. Return WRC_Prune on success. + */ + static int lookupName( + Parse pParse, /* The parsing context */ + string zDb, /* Name of the database containing table, or NULL */ + string zTab, /* Name of table containing column, or NULL */ + string zCol, /* Name of the column. */ + NameContext pNC, /* The name context used to resolve the name */ + Expr pExpr /* Make this EXPR node point to the selected column */ + ) + { + int i, j; /* Loop counters */ + int cnt = 0; /* Number of matching column names */ + int cntTab = 0; /* Number of matching table names */ + sqlite3 db = pParse.db; /* The database connection */ + SrcList_item pItem; /* Use for looping over pSrcList items */ + SrcList_item pMatch = null; /* The matching pSrcList item */ + NameContext pTopNC = pNC; /* First namecontext in the list */ + Schema pSchema = null; /* Schema of the expression */ + int isTrigger = 0; + + Debug.Assert( pNC != null ); /* the name context cannot be NULL. */ + Debug.Assert( zCol != null ); /* The Z in X.Y.Z cannot be NULL */ + Debug.Assert( !ExprHasAnyProperty( pExpr, EP_TokenOnly | EP_Reduced ) ); + + /* Initialize the node to no-match */ + pExpr.iTable = -1; + pExpr.pTab = null; + ExprSetIrreducible( pExpr ); + + /* Start at the inner-most context and move outward until a match is found */ + while ( pNC != null && cnt == 0 ) + { + ExprList pEList; + SrcList pSrcList = pNC.pSrcList; + + if ( pSrcList != null ) + { + for ( i = 0; i < pSrcList.nSrc; i++ )//, pItem++ ) + { + pItem = pSrcList.a[i]; + Table pTab; + int iDb; + Column pCol; + + pTab = pItem.pTab; + Debug.Assert( pTab != null && pTab.zName != null ); + iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); + Debug.Assert( pTab.nCol > 0 ); + if ( zTab != null ) + { + if ( pItem.zAlias != null ) + { + string zTabName = pItem.zAlias; + if ( !zTabName.Equals( zTab, StringComparison.OrdinalIgnoreCase ) ) + continue; + } + else + { + string zTabName = pTab.zName; + if ( NEVER( zTabName == null ) || !zTabName.Equals( zTab ,StringComparison.OrdinalIgnoreCase ) ) + { + continue; + } + if ( zDb != null && !db.aDb[iDb].zName.Equals( zDb ,StringComparison.OrdinalIgnoreCase ) ) + { + continue; } - pDup.iTable = pEList.a[iCol].iAlias; - } else if (ExprHasProperty(pOrig, EP_IntValue) || pOrig.u.zToken == null) { - pDup = sqlite3ExprDup(db, pOrig, 0); - if (pDup == null) - return; - } else { - string zToken = pOrig.u.zToken; - Debug.Assert(zToken != null); - pOrig.u.zToken = null; - pDup = sqlite3ExprDup(db, pOrig, 0); - pOrig.u.zToken = zToken; - if (pDup == null) - return; - Debug.Assert((pDup.flags & (EP_Reduced | EP_TokenOnly)) == 0); - pDup.flags2 |= EP2_MallocedToken; - pDup.u.zToken = zToken;// sqlite3DbStrDup( db, zToken ); + } } - if ((pExpr.flags & EP_ExpCollate) != 0) { - pDup.pColl = pExpr.pColl; - pDup.flags |= EP_ExpCollate; + if ( 0 == ( cntTab++ ) ) + { + pExpr.iTable = pItem.iCursor; + pExpr.pTab = pTab; + pSchema = pTab.pSchema; + pMatch = pItem; } - - /* Before calling sqlite3ExprDelete(), set the EP_Static flag. This - ** prevents ExprDelete() from deleting the Expr structure itself, - ** allowing it to be repopulated by the memcpy() on the following line. - */ - ExprSetProperty(pExpr, EP_Static); - sqlite3ExprDelete(db, ref pExpr); - pExpr.CopyFrom(pDup); //memcpy(pExpr, pDup, sizeof(*pExpr)); - sqlite3DbFree(db, ref pDup); - } - - /* - ** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up - ** that name in the set of source tables in pSrcList and make the pExpr - ** expression node refer back to that source column. The following changes - ** are made to pExpr: - ** - ** pExpr->iDb Set the index in db->aDb[] of the database X - ** (even if X is implied). - ** pExpr->iTable Set to the cursor number for the table obtained - ** from pSrcList. - ** pExpr->pTab Points to the Table structure of X.Y (even if - ** X and/or Y are implied.) - ** pExpr->iColumn Set to the column number within the table. - ** pExpr->op Set to TK_COLUMN. - ** pExpr->pLeft Any expression this points to is deleted - ** pExpr->pRight Any expression this points to is deleted. - ** - ** The zDb variable is the name of the database (the "X"). This value may be - ** NULL meaning that name is of the form Y.Z or Z. Any available database - ** can be used. The zTable variable is the name of the table (the "Y"). This - ** value can be NULL if zDb is also NULL. If zTable is NULL it - ** means that the form of the name is Z and that columns from any table - ** can be used. - ** - ** If the name cannot be resolved unambiguously, leave an error message - ** in pParse and return WRC_Abort. Return WRC_Prune on success. - */ - static int lookupName( - Parse pParse, /* The parsing context */ - string zDb, /* Name of the database containing table, or NULL */ - string zTab, /* Name of table containing column, or NULL */ - string zCol, /* Name of the column. */ - NameContext pNC, /* The name context used to resolve the name */ - Expr pExpr /* Make this EXPR node point to the selected column */ - ) { - int i, j; /* Loop counters */ - int cnt = 0; /* Number of matching column names */ - int cntTab = 0; /* Number of matching table names */ - sqlite3 db = pParse.db; /* The database connection */ - SrcList_item pItem; /* Use for looping over pSrcList items */ - SrcList_item pMatch = null; /* The matching pSrcList item */ - NameContext pTopNC = pNC; /* First namecontext in the list */ - Schema pSchema = null; /* Schema of the expression */ - int isTrigger = 0; - - Debug.Assert(pNC != null); /* the name context cannot be NULL. */ - Debug.Assert(zCol != null); /* The Z in X.Y.Z cannot be NULL */ - Debug.Assert(!ExprHasAnyProperty(pExpr, EP_TokenOnly | EP_Reduced)); - - /* Initialize the node to no-match */ - pExpr.iTable = -1; - pExpr.pTab = null; - ExprSetIrreducible(pExpr); - - /* Start at the inner-most context and move outward until a match is found */ - while (pNC != null && cnt == 0) { - ExprList pEList; - SrcList pSrcList = pNC.pSrcList; - - if (pSrcList != null) { - for (i = 0; i < pSrcList.nSrc; i++)//, pItem++ ) + for ( j = 0; j < pTab.nCol; j++ )//, pCol++ ) + { + pCol = pTab.aCol[j]; + if ( pCol.zName.Equals( zCol, StringComparison.OrdinalIgnoreCase ) ) + { + IdList pUsing; + cnt++; + pExpr.iTable = pItem.iCursor; + pExpr.pTab = pTab; + pMatch = pItem; + pSchema = pTab.pSchema; + /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */ + pExpr.iColumn = (short)( j == pTab.iPKey ? -1 : j ); + if ( i < pSrcList.nSrc - 1 ) + { + if ( ( pSrcList.a[i + 1].jointype & JT_NATURAL ) != 0 )// pItem[1].jointype + { + /* If this match occurred in the left table of a natural join, + ** then skip the right table to avoid a duplicate match */ + //pItem++; + i++; + } + else if ( ( pUsing = pSrcList.a[i + 1].pUsing ) != null )//pItem[1].pUsing + { + /* If this match occurs on a column that is in the USING clause + ** of a join, skip the search of the right table of the join + ** to avoid a duplicate match there. */ + int k; + for ( k = 0; k < pUsing.nId; k++ ) { - pItem = pSrcList.a[i]; - Table pTab; - int iDb; - Column pCol; - - pTab = pItem.pTab; - Debug.Assert(pTab != null && pTab.zName != null); - iDb = sqlite3SchemaToIndex(db, pTab.pSchema); - Debug.Assert(pTab.nCol > 0); - if (zTab != null) { - if (pItem.zAlias != null) { - string zTabName = pItem.zAlias; - if (!zTabName.Equals(zTab, StringComparison.OrdinalIgnoreCase)) - continue; - } else { - string zTabName = pTab.zName; - if (NEVER(zTabName == null) || !zTabName.Equals(zTab, StringComparison.OrdinalIgnoreCase)) { - continue; - } - if (zDb != null && !db.aDb[iDb].zName.Equals(zDb, StringComparison.OrdinalIgnoreCase)) { - continue; - } - } - } - if (0 == (cntTab++)) { - pExpr.iTable = pItem.iCursor; - pExpr.pTab = pTab; - pSchema = pTab.pSchema; - pMatch = pItem; - } - for (j = 0; j < pTab.nCol; j++)//, pCol++ ) - { - pCol = pTab.aCol[j]; - if (pCol.zName.Equals(zCol, StringComparison.OrdinalIgnoreCase)) { - IdList pUsing; - cnt++; - pExpr.iTable = pItem.iCursor; - pExpr.pTab = pTab; - pMatch = pItem; - pSchema = pTab.pSchema; - /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */ - pExpr.iColumn = (short)(j == pTab.iPKey ? -1 : j); - if (i < pSrcList.nSrc - 1) { - if ((pSrcList.a[i + 1].jointype & JT_NATURAL) != 0)// pItem[1].jointype - { - /* If this match occurred in the left table of a natural join, - ** then skip the right table to avoid a duplicate match */ - //pItem++; - i++; - } else if ((pUsing = pSrcList.a[i + 1].pUsing) != null)//pItem[1].pUsing - { - /* If this match occurs on a column that is in the USING clause - ** of a join, skip the search of the right table of the join - ** to avoid a duplicate match there. */ - int k; - for (k = 0; k < pUsing.nId; k++) { - if (pUsing.a[k].zName.Equals(zCol, StringComparison.OrdinalIgnoreCase)) { - //pItem++; - i++; - break; - } - } - } - } - break; - } - } - } - } - -#if !SQLITE_OMIT_TRIGGER - /* If we have not already resolved the name, then maybe - ** it is a new.* or old.* trigger argument reference - */ - if (zDb == null && zTab != null && cnt == 0 && pParse.pTriggerTab != null) { - int op = pParse.eTriggerOp; - Table pTab = null; - Debug.Assert(op == TK_DELETE || op == TK_UPDATE || op == TK_INSERT); - if (op != TK_DELETE && "new".Equals(zTab, StringComparison.OrdinalIgnoreCase)) { - pExpr.iTable = 1; - pTab = pParse.pTriggerTab; - } else if (op != TK_INSERT && "old".Equals(zTab, StringComparison.OrdinalIgnoreCase)) { - pExpr.iTable = 0; - pTab = pParse.pTriggerTab; - } - - if (pTab != null) { - int iCol; - pSchema = pTab.pSchema; - cntTab++; - for (iCol = 0; iCol < pTab.nCol; iCol++) { - Column pCol = pTab.aCol[iCol]; - if (pCol.zName.Equals(zCol, StringComparison.OrdinalIgnoreCase)) { - if (iCol == pTab.iPKey) { - iCol = -1; - } - break; - } - } - if (iCol >= pTab.nCol && sqlite3IsRowid(zCol)) { - iCol = -1; /* IMP: R-44911-55124 */ - } - if (iCol < pTab.nCol) { - cnt++; - if (iCol < 0) { - pExpr.affinity = SQLITE_AFF_INTEGER; - } else if (pExpr.iTable == 0) { - testcase(iCol == 31); - testcase(iCol == 32); - pParse.oldmask |= (iCol >= 32 ? 0xffffffff : (((u32)1) << iCol)); - } else { - testcase(iCol == 31); - testcase(iCol == 32); - pParse.newmask |= (iCol >= 32 ? 0xffffffff : (((u32)1) << iCol)); - } - pExpr.iColumn = (i16)iCol; - pExpr.pTab = pTab; - isTrigger = 1; - } - } - } -#endif //* !SQLITE_OMIT_TRIGGER) */ - - /* - ** Perhaps the name is a reference to the ROWID - */ - if (cnt == 0 && cntTab == 1 && sqlite3IsRowid(zCol)) { - cnt = 1; - pExpr.iColumn = -1; /* IMP: R-44911-55124 */ - pExpr.affinity = SQLITE_AFF_INTEGER; - } - - /* - ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z - ** might refer to an result-set alias. This happens, for example, when - ** we are resolving names in the WHERE clause of the following command: - ** - ** SELECT a+b AS x FROM table WHERE x<10; - ** - ** In cases like this, replace pExpr with a copy of the expression that - ** forms the result set entry ("a+b" in the example) and return immediately. - ** Note that the expression in the result set should have already been - ** resolved by the time the WHERE clause is resolved. - */ - if (cnt == 0 && (pEList = pNC.pEList) != null && zTab == null) { - for (j = 0; j < pEList.nExpr; j++) { - string zAs = pEList.a[j].zName; - if (zAs != null && zAs.Equals(zCol, StringComparison.OrdinalIgnoreCase)) { - Expr pOrig; - Debug.Assert(pExpr.pLeft == null && pExpr.pRight == null); - Debug.Assert(pExpr.x.pList == null); - Debug.Assert(pExpr.x.pSelect == null); - pOrig = pEList.a[j].pExpr; - if (0 == pNC.allowAgg && ExprHasProperty(pOrig, EP_Agg)) { - sqlite3ErrorMsg(pParse, "misuse of aliased aggregate %s", zAs); - return WRC_Abort; - } - resolveAlias(pParse, pEList, j, pExpr, ""); - cnt = 1; - pMatch = null; - Debug.Assert(zTab == null && zDb == null); - goto lookupname_end; - } + if ( pUsing.a[k].zName.Equals( zCol ,StringComparison.OrdinalIgnoreCase ) ) + { + //pItem++; + i++; + break; + } } + } } - - /* Advance to the next name context. The loop will exit when either - ** we have a match (cnt>0) or when we run out of name contexts. - */ - if (cnt == 0) { - pNC = pNC.pNext; - } - } - - /* - ** If X and Y are NULL (in other words if only the column name Z is - ** supplied) and the value of Z is enclosed in double-quotes, then - ** Z is a string literal if it doesn't match any column names. In that - ** case, we need to return right away and not make any changes to - ** pExpr. - ** - ** Because no reference was made to outer contexts, the pNC.nRef - ** fields are not changed in any context. - */ - if (cnt == 0 && zTab == null && ExprHasProperty(pExpr, EP_DblQuoted)) { - pExpr.op = TK_STRING; - pExpr.pTab = null; - return WRC_Prune; + break; + } } + } + } - /* - ** cnt==0 means there was not match. cnt>1 means there were two or - ** more matches. Either way, we have an error. - */ - if (cnt != 1) { - string zErr; - zErr = cnt == 0 ? "no such column" : "ambiguous column name"; - if (zDb != null) { - sqlite3ErrorMsg(pParse, "%s: %s.%s.%s", zErr, zDb, zTab, zCol); - } else if (zTab != null) { - sqlite3ErrorMsg(pParse, "%s: %s.%s", zErr, zTab, zCol); - } else { - sqlite3ErrorMsg(pParse, "%s: %s", zErr, zCol); +#if !SQLITE_OMIT_TRIGGER + /* If we have not already resolved the name, then maybe + ** it is a new.* or old.* trigger argument reference + */ + if ( zDb == null && zTab != null && cnt == 0 && pParse.pTriggerTab != null ) + { + int op = pParse.eTriggerOp; + Table pTab = null; + Debug.Assert( op == TK_DELETE || op == TK_UPDATE || op == TK_INSERT ); + if ( op != TK_DELETE && "new".Equals( zTab ,StringComparison.OrdinalIgnoreCase ) ) + { + pExpr.iTable = 1; + pTab = pParse.pTriggerTab; + } + else if ( op != TK_INSERT && "old".Equals( zTab ,StringComparison.OrdinalIgnoreCase ) ) + { + pExpr.iTable = 0; + pTab = pParse.pTriggerTab; + } + + if ( pTab != null ) + { + int iCol; + pSchema = pTab.pSchema; + cntTab++; + for ( iCol = 0; iCol < pTab.nCol; iCol++ ) + { + Column pCol = pTab.aCol[iCol]; + if ( pCol.zName.Equals( zCol ,StringComparison.OrdinalIgnoreCase ) ) + { + if ( iCol == pTab.iPKey ) + { + iCol = -1; } - pParse.checkSchema = 1; - pTopNC.nErr++; + break; + } } - - /* If a column from a table in pSrcList is referenced, then record - ** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes - ** bit 0 to be set. Column 1 sets bit 1. And so forth. If the - ** column number is greater than the number of bits in the bitmask - ** then set the high-order bit of the bitmask. - */ - if (pExpr.iColumn >= 0 && pMatch != null) { - int n = pExpr.iColumn; - testcase(n == BMS - 1); - if (n >= BMS) { - n = BMS - 1; - } - Debug.Assert(pMatch.iCursor == pExpr.iTable); - pMatch.colUsed |= ((Bitmask)1) << n; + if ( iCol >= pTab.nCol && sqlite3IsRowid( zCol ) ) + { + iCol = -1; /* IMP: R-44911-55124 */ } - - /* Clean up and return - */ - sqlite3ExprDelete(db, ref pExpr.pLeft); - pExpr.pLeft = null; - sqlite3ExprDelete(db, ref pExpr.pRight); - pExpr.pRight = null; - pExpr.op = (u8)(isTrigger != 0 ? TK_TRIGGER : TK_COLUMN); - lookupname_end: - if (cnt == 1) { - Debug.Assert(pNC != null); - sqlite3AuthRead(pParse, pExpr, pSchema, pNC.pSrcList); - /* Increment the nRef value on all name contexts from TopNC up to - ** the point where the name matched. */ - for (; ; ) - { - Debug.Assert(pTopNC != null); - pTopNC.nRef++; - if (pTopNC == pNC) - break; - pTopNC = pTopNC.pNext; - } - return WRC_Prune; - } else { - return WRC_Abort; + if ( iCol < pTab.nCol ) + { + cnt++; + if ( iCol < 0 ) + { + pExpr.affinity = SQLITE_AFF_INTEGER; + } + else if ( pExpr.iTable == 0 ) + { + testcase( iCol == 31 ); + testcase( iCol == 32 ); + pParse.oldmask |= ( iCol >= 32 ? 0xffffffff : ( ( (u32)1 ) << iCol ) ); + } + else + { + testcase( iCol == 31 ); + testcase( iCol == 32 ); + pParse.newmask |= ( iCol >= 32 ? 0xffffffff : ( ( (u32)1 ) << iCol ) ); + } + pExpr.iColumn = (i16)iCol; + pExpr.pTab = pTab; + isTrigger = 1; } + } } +#endif //* !SQLITE_OMIT_TRIGGER) */ /* - ** Allocate and return a pointer to an expression to load the column iCol - ** from datasource iSrc in SrcList pSrc. + ** Perhaps the name is a reference to the ROWID */ - static Expr sqlite3CreateColumnExpr(sqlite3 db, SrcList pSrc, int iSrc, int iCol) { - Expr p = sqlite3ExprAlloc(db, TK_COLUMN, null, 0); - if (p != null) { - SrcList_item pItem = pSrc.a[iSrc]; - p.pTab = pItem.pTab; - p.iTable = pItem.iCursor; - if (p.pTab.iPKey == iCol) { - p.iColumn = -1; - } else { - p.iColumn = (ynVar)iCol; - testcase(iCol == BMS); - testcase(iCol == BMS - 1); - pItem.colUsed |= ((Bitmask)1) << (iCol >= BMS ? BMS - 1 : iCol); - } - ExprSetProperty(p, EP_Resolved); - } - return p; + if ( cnt == 0 && cntTab == 1 && sqlite3IsRowid( zCol ) ) + { + cnt = 1; + pExpr.iColumn = -1; /* IMP: R-44911-55124 */ + pExpr.affinity = SQLITE_AFF_INTEGER; } /* - ** This routine is callback for sqlite3WalkExpr(). + ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z + ** might refer to an result-set alias. This happens, for example, when + ** we are resolving names in the WHERE clause of the following command: ** - ** Resolve symbolic names into TK_COLUMN operators for the current - ** node in the expression tree. Return 0 to continue the search down - ** the tree or 2 to abort the tree walk. + ** SELECT a+b AS x FROM table WHERE x<10; ** - ** This routine also does error checking and name resolution for - ** function names. The operator for aggregate functions is changed - ** to TK_AGG_FUNCTION. + ** In cases like this, replace pExpr with a copy of the expression that + ** forms the result set entry ("a+b" in the example) and return immediately. + ** Note that the expression in the result set should have already been + ** resolved by the time the WHERE clause is resolved. */ - static int resolveExprStep(Walker pWalker, ref Expr pExpr) { - NameContext pNC; - Parse pParse; - - pNC = pWalker.u.pNC; - Debug.Assert(pNC != null); - pParse = pNC.pParse; - Debug.Assert(pParse == pWalker.pParse); - - if (ExprHasAnyProperty(pExpr, EP_Resolved)) - return WRC_Prune; - ExprSetProperty(pExpr, EP_Resolved); -#if !NDEBUG - if (pNC.pSrcList != null && pNC.pSrcList.nAlloc > 0) { - SrcList pSrcList = pNC.pSrcList; - int i; - for (i = 0; i < pNC.pSrcList.nSrc; i++) { - Debug.Assert(pSrcList.a[i].iCursor >= 0 && pSrcList.a[i].iCursor < pParse.nTab); - } + if ( cnt == 0 && ( pEList = pNC.pEList ) != null && zTab == null ) + { + for ( j = 0; j < pEList.nExpr; j++ ) + { + string zAs = pEList.a[j].zName; + if ( zAs != null && zAs.Equals( zCol ,StringComparison.OrdinalIgnoreCase ) ) + { + Expr pOrig; + Debug.Assert( pExpr.pLeft == null && pExpr.pRight == null ); + Debug.Assert( pExpr.x.pList == null ); + Debug.Assert( pExpr.x.pSelect == null ); + pOrig = pEList.a[j].pExpr; + if ( 0 == pNC.allowAgg && ExprHasProperty( pOrig, EP_Agg ) ) + { + sqlite3ErrorMsg( pParse, "misuse of aliased aggregate %s", zAs ); + return WRC_Abort; + } + resolveAlias( pParse, pEList, j, pExpr, "" ); + cnt = 1; + pMatch = null; + Debug.Assert( zTab == null && zDb == null ); + goto lookupname_end; } + } + } + + /* Advance to the next name context. The loop will exit when either + ** we have a match (cnt>0) or when we run out of name contexts. + */ + if ( cnt == 0 ) + { + pNC = pNC.pNext; + } + } + + /* + ** If X and Y are NULL (in other words if only the column name Z is + ** supplied) and the value of Z is enclosed in double-quotes, then + ** Z is a string literal if it doesn't match any column names. In that + ** case, we need to return right away and not make any changes to + ** pExpr. + ** + ** Because no reference was made to outer contexts, the pNC.nRef + ** fields are not changed in any context. + */ + if ( cnt == 0 && zTab == null && ExprHasProperty( pExpr, EP_DblQuoted ) ) + { + pExpr.op = TK_STRING; + pExpr.pTab = null; + return WRC_Prune; + } + + /* + ** cnt==0 means there was not match. cnt>1 means there were two or + ** more matches. Either way, we have an error. + */ + if ( cnt != 1 ) + { + string zErr; + zErr = cnt == 0 ? "no such column" : "ambiguous column name"; + if ( zDb != null ) + { + sqlite3ErrorMsg( pParse, "%s: %s.%s.%s", zErr, zDb, zTab, zCol ); + } + else if ( zTab != null ) + { + sqlite3ErrorMsg( pParse, "%s: %s.%s", zErr, zTab, zCol ); + } + else + { + sqlite3ErrorMsg( pParse, "%s: %s", zErr, zCol ); + } + pParse.checkSchema = 1; + pTopNC.nErr++; + } + + /* If a column from a table in pSrcList is referenced, then record + ** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes + ** bit 0 to be set. Column 1 sets bit 1. And so forth. If the + ** column number is greater than the number of bits in the bitmask + ** then set the high-order bit of the bitmask. + */ + if ( pExpr.iColumn >= 0 && pMatch != null ) + { + int n = pExpr.iColumn; + testcase( n == BMS - 1 ); + if ( n >= BMS ) + { + n = BMS - 1; + } + Debug.Assert( pMatch.iCursor == pExpr.iTable ); + pMatch.colUsed |= ( (Bitmask)1 ) << n; + } + + /* Clean up and return + */ + sqlite3ExprDelete( db, ref pExpr.pLeft ); + pExpr.pLeft = null; + sqlite3ExprDelete( db, ref pExpr.pRight ); + pExpr.pRight = null; + pExpr.op = (u8)( isTrigger != 0 ? TK_TRIGGER : TK_COLUMN ); +lookupname_end: + if ( cnt == 1 ) + { + Debug.Assert( pNC != null ); + sqlite3AuthRead( pParse, pExpr, pSchema, pNC.pSrcList ); + /* Increment the nRef value on all name contexts from TopNC up to + ** the point where the name matched. */ + for ( ; ; ) + { + Debug.Assert( pTopNC != null ); + pTopNC.nRef++; + if ( pTopNC == pNC ) + break; + pTopNC = pTopNC.pNext; + } + return WRC_Prune; + } + else + { + return WRC_Abort; + } + } + + /* + ** Allocate and return a pointer to an expression to load the column iCol + ** from datasource iSrc in SrcList pSrc. + */ + static Expr sqlite3CreateColumnExpr( sqlite3 db, SrcList pSrc, int iSrc, int iCol ) + { + Expr p = sqlite3ExprAlloc( db, TK_COLUMN, null, 0 ); + if ( p != null ) + { + SrcList_item pItem = pSrc.a[iSrc]; + p.pTab = pItem.pTab; + p.iTable = pItem.iCursor; + if ( p.pTab.iPKey == iCol ) + { + p.iColumn = -1; + } + else + { + p.iColumn = (ynVar)iCol; + testcase( iCol == BMS ); + testcase( iCol == BMS - 1 ); + pItem.colUsed |= ( (Bitmask)1 ) << ( iCol >= BMS ? BMS - 1 : iCol ); + } + ExprSetProperty( p, EP_Resolved ); + } + return p; + } + + /* + ** This routine is callback for sqlite3WalkExpr(). + ** + ** Resolve symbolic names into TK_COLUMN operators for the current + ** node in the expression tree. Return 0 to continue the search down + ** the tree or 2 to abort the tree walk. + ** + ** This routine also does error checking and name resolution for + ** function names. The operator for aggregate functions is changed + ** to TK_AGG_FUNCTION. + */ + static int resolveExprStep( Walker pWalker, ref Expr pExpr ) + { + NameContext pNC; + Parse pParse; + + pNC = pWalker.u.pNC; + Debug.Assert( pNC != null ); + pParse = pNC.pParse; + Debug.Assert( pParse == pWalker.pParse ); + + if ( ExprHasAnyProperty( pExpr, EP_Resolved ) ) + return WRC_Prune; + ExprSetProperty( pExpr, EP_Resolved ); +#if !NDEBUG + if ( pNC.pSrcList != null && pNC.pSrcList.nAlloc > 0 ) + { + SrcList pSrcList = pNC.pSrcList; + int i; + for ( i = 0; i < pNC.pSrcList.nSrc; i++ ) + { + Debug.Assert( pSrcList.a[i].iCursor >= 0 && pSrcList.a[i].iCursor < pParse.nTab ); + } + } #endif - switch (pExpr.op) { + switch ( pExpr.op ) + { #if (SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !(SQLITE_OMIT_SUBQUERY) /* The special operator TK_ROW means use the rowid for the first @@ -514,66 +584,78 @@ static int resolveExprStep(Walker pWalker, ref Expr pExpr) { } #endif //* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) / - /* A lone identifier is the name of a column. - */ - case TK_ID: { - return lookupName(pParse, null, null, pExpr.u.zToken, pNC, pExpr); - } + /* A lone identifier is the name of a column. +*/ + case TK_ID: + { + return lookupName( pParse, null, null, pExpr.u.zToken, pNC, pExpr ); + } - /* A table name and column name: ID.ID - ** Or a database, table and column: ID.ID.ID - */ - case TK_DOT: { - string zColumn; - string zTable; - string zDb; - Expr pRight; - - /* if( pSrcList==0 ) break; */ - pRight = pExpr.pRight; - if (pRight.op == TK_ID) { - zDb = null; - zTable = pExpr.pLeft.u.zToken; - zColumn = pRight.u.zToken; - } else { - Debug.Assert(pRight.op == TK_DOT); - zDb = pExpr.pLeft.u.zToken; - zTable = pRight.pLeft.u.zToken; - zColumn = pRight.pRight.u.zToken; - } - return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr); - } + /* A table name and column name: ID.ID + ** Or a database, table and column: ID.ID.ID + */ + case TK_DOT: + { + string zColumn; + string zTable; + string zDb; + Expr pRight; + + /* if( pSrcList==0 ) break; */ + pRight = pExpr.pRight; + if ( pRight.op == TK_ID ) + { + zDb = null; + zTable = pExpr.pLeft.u.zToken; + zColumn = pRight.u.zToken; + } + else + { + Debug.Assert( pRight.op == TK_DOT ); + zDb = pExpr.pLeft.u.zToken; + zTable = pRight.pLeft.u.zToken; + zColumn = pRight.pRight.u.zToken; + } + return lookupName( pParse, zDb, zTable, zColumn, pNC, pExpr ); + } - /* Resolve function names - */ - case TK_CONST_FUNC: - case TK_FUNCTION: { - ExprList pList = pExpr.x.pList; /* The argument list */ - int n = pList != null ? pList.nExpr : 0; /* Number of arguments */ - bool no_such_func = false; /* True if no such function exists */ - bool wrong_num_args = false; /* True if wrong number of arguments */ - bool is_agg = false; /* True if is an aggregate function */ - int auth; /* Authorization to use the function */ - int nId; /* Number of characters in function name */ - string zId; /* The function name. */ - FuncDef pDef; /* Information about the function */ - u8 enc = (u8)pParse.db.aDbStatic[0].pSchema.enc;// ENC( pParse.db ); /* The database encoding */ - - testcase(pExpr.op == TK_CONST_FUNC); - Debug.Assert(!ExprHasProperty(pExpr, EP_xIsSelect)); - zId = pExpr.u.zToken; - nId = sqlite3Strlen30(zId); - pDef = sqlite3FindFunction(pParse.db, zId, nId, n, enc, 0); - if (pDef == null) { - pDef = sqlite3FindFunction(pParse.db, zId, nId, -1, enc, 0); - if (pDef == null) { - no_such_func = true; - } else { - wrong_num_args = true; - } - } else { - is_agg = pDef.xFunc == null; - } + /* Resolve function names + */ + case TK_CONST_FUNC: + case TK_FUNCTION: + { + ExprList pList = pExpr.x.pList; /* The argument list */ + int n = pList != null ? pList.nExpr : 0; /* Number of arguments */ + bool no_such_func = false; /* True if no such function exists */ + bool wrong_num_args = false; /* True if wrong number of arguments */ + bool is_agg = false; /* True if is an aggregate function */ + int auth; /* Authorization to use the function */ + int nId; /* Number of characters in function name */ + string zId; /* The function name. */ + FuncDef pDef; /* Information about the function */ + u8 enc = (u8)pParse.db.aDbStatic[0].pSchema.enc;// ENC( pParse.db ); /* The database encoding */ + + testcase( pExpr.op == TK_CONST_FUNC ); + Debug.Assert( !ExprHasProperty( pExpr, EP_xIsSelect ) ); + zId = pExpr.u.zToken; + nId = sqlite3Strlen30( zId ); + pDef = sqlite3FindFunction( pParse.db, zId, nId, n, enc, 0 ); + if ( pDef == null ) + { + pDef = sqlite3FindFunction( pParse.db, zId, nId, -1, enc, 0 ); + if ( pDef == null ) + { + no_such_func = true; + } + else + { + wrong_num_args = true; + } + } + else + { + is_agg = pDef.xFunc == null; + } #if !SQLITE_OMIT_AUTHORIZATION if( pDef ){ auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0, pDef.zName, 0); @@ -588,624 +670,688 @@ static int resolveExprStep(Walker pWalker, ref Expr pExpr) { } } #endif - if (is_agg && 0 == pNC.allowAgg) { - sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId, zId); - pNC.nErr++; - is_agg = false; - } else if (no_such_func) { - sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId); - pNC.nErr++; - } else if (wrong_num_args) { - sqlite3ErrorMsg(pParse, "wrong number of arguments to function %.*s()", - nId, zId); - pNC.nErr++; - } - if (is_agg) { - pExpr.op = TK_AGG_FUNCTION; - pNC.hasAgg = 1; - } - if (is_agg) - pNC.allowAgg = 0; - sqlite3WalkExprList(pWalker, pList); - if (is_agg) - pNC.allowAgg = 1; - /* FIX ME: Compute pExpr.affinity based on the expected return - ** type of the function - */ - return WRC_Prune; - } + if ( is_agg && 0 == pNC.allowAgg ) + { + sqlite3ErrorMsg( pParse, "misuse of aggregate function %.*s()", nId, zId ); + pNC.nErr++; + is_agg = false; + } + else if ( no_such_func ) + { + sqlite3ErrorMsg( pParse, "no such function: %.*s", nId, zId ); + pNC.nErr++; + } + else if ( wrong_num_args ) + { + sqlite3ErrorMsg( pParse, "wrong number of arguments to function %.*s()", + nId, zId ); + pNC.nErr++; + } + if ( is_agg ) + { + pExpr.op = TK_AGG_FUNCTION; + pNC.hasAgg = 1; + } + if ( is_agg ) + pNC.allowAgg = 0; + sqlite3WalkExprList( pWalker, pList ); + if ( is_agg ) + pNC.allowAgg = 1; + /* FIX ME: Compute pExpr.affinity based on the expected return + ** type of the function + */ + return WRC_Prune; + } #if !SQLITE_OMIT_SUBQUERY - case TK_SELECT: - case TK_EXISTS: { - testcase(pExpr.op == TK_EXISTS); - goto case TK_IN; - } + case TK_SELECT: + case TK_EXISTS: + { + testcase( pExpr.op == TK_EXISTS ); + goto case TK_IN; + } #endif - case TK_IN: { - testcase(pExpr.op == TK_IN); - if (ExprHasProperty(pExpr, EP_xIsSelect)) { - int nRef = pNC.nRef; + case TK_IN: + { + testcase( pExpr.op == TK_IN ); + if ( ExprHasProperty( pExpr, EP_xIsSelect ) ) + { + int nRef = pNC.nRef; #if !SQLITE_OMIT_CHECK - if (pNC.isCheck != 0) { - sqlite3ErrorMsg(pParse, "subqueries prohibited in CHECK constraints"); - } + if ( pNC.isCheck != 0 ) + { + sqlite3ErrorMsg( pParse, "subqueries prohibited in CHECK constraints" ); + } #endif - sqlite3WalkSelect(pWalker, pExpr.x.pSelect); - Debug.Assert(pNC.nRef >= nRef); - if (nRef != pNC.nRef) { - ExprSetProperty(pExpr, EP_VarSelect); - } - } - break; - } + sqlite3WalkSelect( pWalker, pExpr.x.pSelect ); + Debug.Assert( pNC.nRef >= nRef ); + if ( nRef != pNC.nRef ) + { + ExprSetProperty( pExpr, EP_VarSelect ); + } + } + break; + } #if !SQLITE_OMIT_CHECK - case TK_VARIABLE: { - if (pNC.isCheck != 0) { - sqlite3ErrorMsg(pParse, "parameters prohibited in CHECK constraints"); - } - break; - } -#endif + case TK_VARIABLE: + { + if ( pNC.isCheck != 0 ) + { + sqlite3ErrorMsg( pParse, "parameters prohibited in CHECK constraints" ); } - return (pParse.nErr != 0 /* || pParse.db.mallocFailed != 0 */ ) ? WRC_Abort : WRC_Continue; + break; + } +#endif + } + return ( pParse.nErr != 0 /* || pParse.db.mallocFailed != 0 */ ) ? WRC_Abort : WRC_Continue; + } + + /* + ** pEList is a list of expressions which are really the result set of the + ** a SELECT statement. pE is a term in an ORDER BY or GROUP BY clause. + ** This routine checks to see if pE is a simple identifier which corresponds + ** to the AS-name of one of the terms of the expression list. If it is, + ** this routine return an integer between 1 and N where N is the number of + ** elements in pEList, corresponding to the matching entry. If there is + ** no match, or if pE is not a simple identifier, then this routine + ** return 0. + ** + ** pEList has been resolved. pE has not. + */ + static int resolveAsName( + Parse pParse, /* Parsing context for error messages */ + ExprList pEList, /* List of expressions to scan */ + Expr pE /* Expression we are trying to match */ + ) + { + int i; /* Loop counter */ + + UNUSED_PARAMETER( pParse ); + + if ( pE.op == TK_ID ) + { + string zCol = pE.u.zToken; + + for ( i = 0; i < pEList.nExpr; i++ ) + { + string zAs = pEList.a[i].zName; + if ( zAs != null && zAs.Equals( zCol ,StringComparison.OrdinalIgnoreCase ) ) + { + return i + 1; + } } + } + return 0; + } - /* - ** pEList is a list of expressions which are really the result set of the - ** a SELECT statement. pE is a term in an ORDER BY or GROUP BY clause. - ** This routine checks to see if pE is a simple identifier which corresponds - ** to the AS-name of one of the terms of the expression list. If it is, - ** this routine return an integer between 1 and N where N is the number of - ** elements in pEList, corresponding to the matching entry. If there is - ** no match, or if pE is not a simple identifier, then this routine - ** return 0. - ** - ** pEList has been resolved. pE has not. - */ - static int resolveAsName( - Parse pParse, /* Parsing context for error messages */ - ExprList pEList, /* List of expressions to scan */ - Expr pE /* Expression we are trying to match */ - ) { - int i; /* Loop counter */ - - UNUSED_PARAMETER(pParse); - - if (pE.op == TK_ID) { - string zCol = pE.u.zToken; - - for (i = 0; i < pEList.nExpr; i++) { - string zAs = pEList.a[i].zName; - if (zAs != null && zAs.Equals(zCol, StringComparison.OrdinalIgnoreCase)) { - return i + 1; - } - } - } - return 0; + /* + ** pE is a pointer to an expression which is a single term in the + ** ORDER BY of a compound SELECT. The expression has not been + ** name resolved. + ** + ** At the point this routine is called, we already know that the + ** ORDER BY term is not an integer index into the result set. That + ** case is handled by the calling routine. + ** + ** Attempt to match pE against result set columns in the left-most + ** SELECT statement. Return the index i of the matching column, + ** as an indication to the caller that it should sort by the i-th column. + ** The left-most column is 1. In other words, the value returned is the + ** same integer value that would be used in the SQL statement to indicate + ** the column. + ** + ** If there is no match, return 0. Return -1 if an error occurs. + */ + static int resolveOrderByTermToExprList( + Parse pParse, /* Parsing context for error messages */ + Select pSelect, /* The SELECT statement with the ORDER BY clause */ + Expr pE /* The specific ORDER BY term */ + ) + { + int i = 0; /* Loop counter */ + ExprList pEList; /* The columns of the result set */ + NameContext nc; /* Name context for resolving pE */ + sqlite3 db; /* Database connection */ + int rc; /* Return code from subprocedures */ + u8 savedSuppErr; /* Saved value of db->suppressErr */ + + Debug.Assert( sqlite3ExprIsInteger( pE, ref i ) == 0 ); + pEList = pSelect.pEList; + + /* Resolve all names in the ORDER BY term expression + */ + nc = new NameContext();// memset( &nc, 0, sizeof( nc ) ); + nc.pParse = pParse; + nc.pSrcList = pSelect.pSrc; + nc.pEList = pEList; + nc.allowAgg = 1; + nc.nErr = 0; + db = pParse.db; + savedSuppErr = db.suppressErr; + db.suppressErr = 1; + rc = sqlite3ResolveExprNames( nc, ref pE ); + db.suppressErr = savedSuppErr; + if ( rc != 0 ) + return 0; + + /* Try to match the ORDER BY expression against an expression + ** in the result set. Return an 1-based index of the matching + ** result-set entry. + */ + for ( i = 0; i < pEList.nExpr; i++ ) + { + if ( sqlite3ExprCompare( pEList.a[i].pExpr, pE ) < 2 ) + { + return i + 1; } + } - /* - ** pE is a pointer to an expression which is a single term in the - ** ORDER BY of a compound SELECT. The expression has not been - ** name resolved. - ** - ** At the point this routine is called, we already know that the - ** ORDER BY term is not an integer index into the result set. That - ** case is handled by the calling routine. - ** - ** Attempt to match pE against result set columns in the left-most - ** SELECT statement. Return the index i of the matching column, - ** as an indication to the caller that it should sort by the i-th column. - ** The left-most column is 1. In other words, the value returned is the - ** same integer value that would be used in the SQL statement to indicate - ** the column. - ** - ** If there is no match, return 0. Return -1 if an error occurs. - */ - static int resolveOrderByTermToExprList( - Parse pParse, /* Parsing context for error messages */ - Select pSelect, /* The SELECT statement with the ORDER BY clause */ - Expr pE /* The specific ORDER BY term */ - ) { - int i = 0; /* Loop counter */ - ExprList pEList; /* The columns of the result set */ - NameContext nc; /* Name context for resolving pE */ - sqlite3 db; /* Database connection */ - int rc; /* Return code from subprocedures */ - u8 savedSuppErr; /* Saved value of db->suppressErr */ - - Debug.Assert(sqlite3ExprIsInteger(pE, ref i) == 0); - pEList = pSelect.pEList; - - /* Resolve all names in the ORDER BY term expression - */ - nc = new NameContext();// memset( &nc, 0, sizeof( nc ) ); - nc.pParse = pParse; - nc.pSrcList = pSelect.pSrc; - nc.pEList = pEList; - nc.allowAgg = 1; - nc.nErr = 0; - db = pParse.db; - savedSuppErr = db.suppressErr; - db.suppressErr = 1; - rc = sqlite3ResolveExprNames(nc, ref pE); - db.suppressErr = savedSuppErr; - if (rc != 0) - return 0; - - /* Try to match the ORDER BY expression against an expression - ** in the result set. Return an 1-based index of the matching - ** result-set entry. - */ - for (i = 0; i < pEList.nExpr; i++) { - if (sqlite3ExprCompare(pEList.a[i].pExpr, pE) < 2) { - return i + 1; - } + /* If no match, return 0. */ + return 0; + } + + /* + ** Generate an ORDER BY or GROUP BY term out-of-range error. + */ + static void resolveOutOfRangeError( + Parse pParse, /* The error context into which to write the error */ + string zType, /* "ORDER" or "GROUP" */ + int i, /* The index (1-based) of the term out of range */ + int mx /* Largest permissible value of i */ + ) + { + sqlite3ErrorMsg( pParse, + "%r %s BY term out of range - should be " + + "between 1 and %d", i, zType, mx ); + } + + /* + ** Analyze the ORDER BY clause in a compound SELECT statement. Modify + ** each term of the ORDER BY clause is a constant integer between 1 + ** and N where N is the number of columns in the compound SELECT. + ** + ** ORDER BY terms that are already an integer between 1 and N are + ** unmodified. ORDER BY terms that are integers outside the range of + ** 1 through N generate an error. ORDER BY terms that are expressions + ** are matched against result set expressions of compound SELECT + ** beginning with the left-most SELECT and working toward the right. + ** At the first match, the ORDER BY expression is transformed into + ** the integer column number. + ** + ** Return the number of errors seen. + */ + static int resolveCompoundOrderBy( + Parse pParse, /* Parsing context. Leave error messages here */ + Select pSelect /* The SELECT statement containing the ORDER BY */ + ) + { + int i; + ExprList pOrderBy; + ExprList pEList; + sqlite3 db; + int moreToDo = 1; + + pOrderBy = pSelect.pOrderBy; + if ( pOrderBy == null ) + return 0; + db = pParse.db; +//#if SQLITE_MAX_COLUMN + if ( pOrderBy.nExpr > db.aLimit[SQLITE_LIMIT_COLUMN] ) + { + sqlite3ErrorMsg( pParse, "too many terms in ORDER BY clause" ); + return 1; + } +//#endif + for ( i = 0; i < pOrderBy.nExpr; i++ ) + { + pOrderBy.a[i].done = 0; + } + pSelect.pNext = null; + while ( pSelect.pPrior != null ) + { + pSelect.pPrior.pNext = pSelect; + pSelect = pSelect.pPrior; + } + while ( pSelect != null && moreToDo != 0 ) + { + ExprList_item pItem; + moreToDo = 0; + pEList = pSelect.pEList; + Debug.Assert( pEList != null ); + for ( i = 0; i < pOrderBy.nExpr; i++ )//, pItem++) + { + pItem = pOrderBy.a[i]; + int iCol = -1; + Expr pE, pDup; + if ( pItem.done != 0 ) + continue; + pE = pItem.pExpr; + if ( sqlite3ExprIsInteger( pE, ref iCol ) != 0 ) + { + if ( iCol <= 0 || iCol > pEList.nExpr ) + { + resolveOutOfRangeError( pParse, "ORDER", i + 1, pEList.nExpr ); + return 1; + } + } + else + { + iCol = resolveAsName( pParse, pEList, pE ); + if ( iCol == 0 ) + { + pDup = sqlite3ExprDup( db, pE, 0 ); + ////if ( 0 == db.mallocFailed ) + { + Debug.Assert( pDup != null ); + iCol = resolveOrderByTermToExprList( pParse, pSelect, pDup ); + } + sqlite3ExprDelete( db, ref pDup ); } + } + if ( iCol > 0 ) + { + CollSeq pColl = pE.pColl; + int flags = pE.flags & EP_ExpCollate; + sqlite3ExprDelete( db, ref pE ); + pItem.pExpr = pE = sqlite3Expr( db, TK_INTEGER, null ); + if ( pE == null ) + return 1; + pE.pColl = pColl; + pE.flags = (u16)( pE.flags | EP_IntValue | flags ); + pE.u.iValue = iCol; + pItem.iCol = (u16)iCol; + pItem.done = 1; + } + else + { + moreToDo = 1; + } + } + pSelect = pSelect.pNext; + } + for ( i = 0; i < pOrderBy.nExpr; i++ ) + { + if ( pOrderBy.a[i].done == 0 ) + { + sqlite3ErrorMsg( pParse, "%r ORDER BY term does not match any " + + "column in the result set", i + 1 ); + return 1; + } + } + return 0; + } - /* If no match, return 0. */ - return 0; + /* + ** Check every term in the ORDER BY or GROUP BY clause pOrderBy of + ** the SELECT statement pSelect. If any term is reference to a + ** result set expression (as determined by the ExprList.a.iCol field) + ** then convert that term into a copy of the corresponding result set + ** column. + ** + ** If any errors are detected, add an error message to pParse and + ** return non-zero. Return zero if no errors are seen. + */ + static int sqlite3ResolveOrderGroupBy( + Parse pParse, /* Parsing context. Leave error messages here */ + Select pSelect, /* The SELECT statement containing the clause */ + ExprList pOrderBy, /* The ORDER BY or GROUP BY clause to be processed */ + string zType /* "ORDER" or "GROUP" */ + ) + { + int i; + sqlite3 db = pParse.db; + ExprList pEList; + ExprList_item pItem; + + if ( pOrderBy == null /* || pParse.db.mallocFailed != 0 */ ) + return 0; +//#if SQLITE_MAX_COLUMN + if ( pOrderBy.nExpr > db.aLimit[SQLITE_LIMIT_COLUMN] ) + { + sqlite3ErrorMsg( pParse, "too many terms in %s BY clause", zType ); + return 1; + } +//#endif + pEList = pSelect.pEList; + Debug.Assert( pEList != null ); /* sqlite3SelectNew() guarantees this */ + for ( i = 0; i < pOrderBy.nExpr; i++ )//, pItem++) + { + pItem = pOrderBy.a[i]; + if ( pItem.iCol != 0 ) + { + if ( pItem.iCol > pEList.nExpr ) + { + resolveOutOfRangeError( pParse, zType, i + 1, pEList.nExpr ); + return 1; + } + resolveAlias( pParse, pEList, pItem.iCol - 1, pItem.pExpr, zType ); } + } + return 0; + } - /* - ** Generate an ORDER BY or GROUP BY term out-of-range error. - */ - static void resolveOutOfRangeError( - Parse pParse, /* The error context into which to write the error */ - string zType, /* "ORDER" or "GROUP" */ - int i, /* The index (1-based) of the term out of range */ - int mx /* Largest permissible value of i */ - ) { - sqlite3ErrorMsg(pParse, - "%r %s BY term out of range - should be " + - "between 1 and %d", i, zType, mx); + /* + ** pOrderBy is an ORDER BY or GROUP BY clause in SELECT statement pSelect. + ** The Name context of the SELECT statement is pNC. zType is either + ** "ORDER" or "GROUP" depending on which type of clause pOrderBy is. + ** + ** This routine resolves each term of the clause into an expression. + ** If the order-by term is an integer I between 1 and N (where N is the + ** number of columns in the result set of the SELECT) then the expression + ** in the resolution is a copy of the I-th result-set expression. If + ** the order-by term is an identify that corresponds to the AS-name of + ** a result-set expression, then the term resolves to a copy of the + ** result-set expression. Otherwise, the expression is resolved in + ** the usual way - using sqlite3ResolveExprNames(). + ** + ** This routine returns the number of errors. If errors occur, then + ** an appropriate error message might be left in pParse. (OOM errors + ** excepted.) + */ + static int resolveOrderGroupBy( + NameContext pNC, /* The name context of the SELECT statement */ + Select pSelect, /* The SELECT statement holding pOrderBy */ + ExprList pOrderBy, /* An ORDER BY or GROUP BY clause to resolve */ + string zType /* Either "ORDER" or "GROUP", as appropriate */ + ) + { + int i; /* Loop counter */ + int iCol; /* Column number */ + ExprList_item pItem; /* A term of the ORDER BY clause */ + Parse pParse; /* Parsing context */ + int nResult; /* Number of terms in the result set */ + + if ( pOrderBy == null ) + return 0; + nResult = pSelect.pEList.nExpr; + pParse = pNC.pParse; + for ( i = 0; i < pOrderBy.nExpr; i++ )//, pItem++ ) + { + pItem = pOrderBy.a[i]; + Expr pE = pItem.pExpr; + iCol = resolveAsName( pParse, pSelect.pEList, pE ); + if ( iCol > 0 ) + { + /* If an AS-name match is found, mark this ORDER BY column as being + ** a copy of the iCol-th result-set column. The subsequent call to + ** sqlite3ResolveOrderGroupBy() will convert the expression to a + ** copy of the iCol-th result-set expression. */ + pItem.iCol = (u16)iCol; + continue; + } + if ( sqlite3ExprIsInteger( pE, ref iCol ) != 0 ) + { + /* The ORDER BY term is an integer constant. Again, set the column + ** number so that sqlite3ResolveOrderGroupBy() will convert the + ** order-by term to a copy of the result-set expression */ + if ( iCol < 1 ) + { + resolveOutOfRangeError( pParse, zType, i + 1, nResult ); + return 1; + } + pItem.iCol = (u16)iCol; + continue; } - /* - ** Analyze the ORDER BY clause in a compound SELECT statement. Modify - ** each term of the ORDER BY clause is a constant integer between 1 - ** and N where N is the number of columns in the compound SELECT. - ** - ** ORDER BY terms that are already an integer between 1 and N are - ** unmodified. ORDER BY terms that are integers outside the range of - ** 1 through N generate an error. ORDER BY terms that are expressions - ** are matched against result set expressions of compound SELECT - ** beginning with the left-most SELECT and working toward the right. - ** At the first match, the ORDER BY expression is transformed into - ** the integer column number. - ** - ** Return the number of errors seen. - */ - static int resolveCompoundOrderBy( - Parse pParse, /* Parsing context. Leave error messages here */ - Select pSelect /* The SELECT statement containing the ORDER BY */ - ) { - int i; - ExprList pOrderBy; - ExprList pEList; - sqlite3 db; - int moreToDo = 1; - - pOrderBy = pSelect.pOrderBy; - if (pOrderBy == null) - return 0; - db = pParse.db; - //#if SQLITE_MAX_COLUMN - if (pOrderBy.nExpr > db.aLimit[SQLITE_LIMIT_COLUMN]) { - sqlite3ErrorMsg(pParse, "too many terms in ORDER BY clause"); - return 1; - } - //#endif - for (i = 0; i < pOrderBy.nExpr; i++) { - pOrderBy.a[i].done = 0; - } - pSelect.pNext = null; - while (pSelect.pPrior != null) { - pSelect.pPrior.pNext = pSelect; - pSelect = pSelect.pPrior; - } - while (pSelect != null && moreToDo != 0) { - ExprList_item pItem; - moreToDo = 0; - pEList = pSelect.pEList; - Debug.Assert(pEList != null); - for (i = 0; i < pOrderBy.nExpr; i++)//, pItem++) - { - pItem = pOrderBy.a[i]; - int iCol = -1; - Expr pE, pDup; - if (pItem.done != 0) - continue; - pE = pItem.pExpr; - if (sqlite3ExprIsInteger(pE, ref iCol) != 0) { - if (iCol <= 0 || iCol > pEList.nExpr) { - resolveOutOfRangeError(pParse, "ORDER", i + 1, pEList.nExpr); - return 1; - } - } else { - iCol = resolveAsName(pParse, pEList, pE); - if (iCol == 0) { - pDup = sqlite3ExprDup(db, pE, 0); - ////if ( 0 == db.mallocFailed ) - { - Debug.Assert(pDup != null); - iCol = resolveOrderByTermToExprList(pParse, pSelect, pDup); - } - sqlite3ExprDelete(db, ref pDup); - } - } - if (iCol > 0) { - CollSeq pColl = pE.pColl; - int flags = pE.flags & EP_ExpCollate; - sqlite3ExprDelete(db, ref pE); - pItem.pExpr = pE = sqlite3Expr(db, TK_INTEGER, null); - if (pE == null) - return 1; - pE.pColl = pColl; - pE.flags = (u16)(pE.flags | EP_IntValue | flags); - pE.u.iValue = iCol; - pItem.iCol = (u16)iCol; - pItem.done = 1; - } else { - moreToDo = 1; - } - } - pSelect = pSelect.pNext; - } - for (i = 0; i < pOrderBy.nExpr; i++) { - if (pOrderBy.a[i].done == 0) { - sqlite3ErrorMsg(pParse, "%r ORDER BY term does not match any " + - "column in the result set", i + 1); - return 1; - } - } - return 0; + /* Otherwise, treat the ORDER BY term as an ordinary expression */ + pItem.iCol = 0; + if ( sqlite3ResolveExprNames( pNC, ref pE ) != 0 ) + { + return 1; } + } + return sqlite3ResolveOrderGroupBy( pParse, pSelect, pOrderBy, zType ); + } - /* - ** Check every term in the ORDER BY or GROUP BY clause pOrderBy of - ** the SELECT statement pSelect. If any term is reference to a - ** result set expression (as determined by the ExprList.a.iCol field) - ** then convert that term into a copy of the corresponding result set - ** column. - ** - ** If any errors are detected, add an error message to pParse and - ** return non-zero. Return zero if no errors are seen. + /* + ** Resolve names in the SELECT statement p and all of its descendents. + */ + static int resolveSelectStep( Walker pWalker, Select p ) + { + NameContext pOuterNC; /* Context that contains this SELECT */ + NameContext sNC; /* Name context of this SELECT */ + bool isCompound; /* True if p is a compound select */ + int nCompound; /* Number of compound terms processed so far */ + Parse pParse; /* Parsing context */ + ExprList pEList; /* Result set expression list */ + int i; /* Loop counter */ + ExprList pGroupBy; /* The GROUP BY clause */ + Select pLeftmost; /* Left-most of SELECT of a compound */ + + Debug.Assert( p != null ); + if ( ( p.selFlags & SF_Resolved ) != 0 ) + { + return WRC_Prune; + } + pOuterNC = pWalker.u.pNC; + pParse = pWalker.pParse; + //sqlite3 db = pParse.db; + + /* Normally sqlite3SelectExpand() will be called first and will have + ** already expanded this SELECT. However, if this is a subquery within + ** an expression, sqlite3ResolveExprNames() will be called without a + ** prior call to sqlite3SelectExpand(). When that happens, let + ** sqlite3SelectPrep() do all of the processing for this SELECT. + ** sqlite3SelectPrep() will invoke both sqlite3SelectExpand() and + ** this routine in the correct order. + */ + if ( ( p.selFlags & SF_Expanded ) == 0 ) + { + sqlite3SelectPrep( pParse, p, pOuterNC ); + return ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) ? WRC_Abort : WRC_Prune; + } + + isCompound = p.pPrior != null; + nCompound = 0; + pLeftmost = p; + while ( p != null ) + { + Debug.Assert( ( p.selFlags & SF_Expanded ) != 0 ); + Debug.Assert( ( p.selFlags & SF_Resolved ) == 0 ); + p.selFlags |= SF_Resolved; + + /* Resolve the expressions in the LIMIT and OFFSET clauses. These + ** are not allowed to refer to any names, so pass an empty NameContext. */ - static int sqlite3ResolveOrderGroupBy( - Parse pParse, /* Parsing context. Leave error messages here */ - Select pSelect, /* The SELECT statement containing the clause */ - ExprList pOrderBy, /* The ORDER BY or GROUP BY clause to be processed */ - string zType /* "ORDER" or "GROUP" */ - ) { - int i; - sqlite3 db = pParse.db; - ExprList pEList; - ExprList_item pItem; - - if (pOrderBy == null /* || pParse.db.mallocFailed != 0 */ ) - return 0; - //#if SQLITE_MAX_COLUMN - if (pOrderBy.nExpr > db.aLimit[SQLITE_LIMIT_COLUMN]) { - sqlite3ErrorMsg(pParse, "too many terms in %s BY clause", zType); - return 1; - } - //#endif - pEList = pSelect.pEList; - Debug.Assert(pEList != null); /* sqlite3SelectNew() guarantees this */ - for (i = 0; i < pOrderBy.nExpr; i++)//, pItem++) - { - pItem = pOrderBy.a[i]; - if (pItem.iCol != 0) { - if (pItem.iCol > pEList.nExpr) { - resolveOutOfRangeError(pParse, zType, i + 1, pEList.nExpr); - return 1; - } - resolveAlias(pParse, pEList, pItem.iCol - 1, pItem.pExpr, zType); - } - } - return 0; + sNC = new NameContext();// memset( &sNC, 0, sizeof( sNC ) ); + sNC.pParse = pParse; + if ( sqlite3ResolveExprNames( sNC, ref p.pLimit ) != 0 || + sqlite3ResolveExprNames( sNC, ref p.pOffset ) != 0 ) + { + return WRC_Abort; } - /* - ** pOrderBy is an ORDER BY or GROUP BY clause in SELECT statement pSelect. - ** The Name context of the SELECT statement is pNC. zType is either - ** "ORDER" or "GROUP" depending on which type of clause pOrderBy is. - ** - ** This routine resolves each term of the clause into an expression. - ** If the order-by term is an integer I between 1 and N (where N is the - ** number of columns in the result set of the SELECT) then the expression - ** in the resolution is a copy of the I-th result-set expression. If - ** the order-by term is an identify that corresponds to the AS-name of - ** a result-set expression, then the term resolves to a copy of the - ** result-set expression. Otherwise, the expression is resolved in - ** the usual way - using sqlite3ResolveExprNames(). - ** - ** This routine returns the number of errors. If errors occur, then - ** an appropriate error message might be left in pParse. (OOM errors - ** excepted.) + /* Set up the local name-context to pass to sqlite3ResolveExprNames() to + ** resolve the result-set expression list. */ - static int resolveOrderGroupBy( - NameContext pNC, /* The name context of the SELECT statement */ - Select pSelect, /* The SELECT statement holding pOrderBy */ - ExprList pOrderBy, /* An ORDER BY or GROUP BY clause to resolve */ - string zType /* Either "ORDER" or "GROUP", as appropriate */ - ) { - int i; /* Loop counter */ - int iCol; /* Column number */ - ExprList_item pItem; /* A term of the ORDER BY clause */ - Parse pParse; /* Parsing context */ - int nResult; /* Number of terms in the result set */ - - if (pOrderBy == null) - return 0; - nResult = pSelect.pEList.nExpr; - pParse = pNC.pParse; - for (i = 0; i < pOrderBy.nExpr; i++)//, pItem++ ) - { - pItem = pOrderBy.a[i]; - Expr pE = pItem.pExpr; - iCol = resolveAsName(pParse, pSelect.pEList, pE); - if (iCol > 0) { - /* If an AS-name match is found, mark this ORDER BY column as being - ** a copy of the iCol-th result-set column. The subsequent call to - ** sqlite3ResolveOrderGroupBy() will convert the expression to a - ** copy of the iCol-th result-set expression. */ - pItem.iCol = (u16)iCol; - continue; - } - if (sqlite3ExprIsInteger(pE, ref iCol) != 0) { - /* The ORDER BY term is an integer constant. Again, set the column - ** number so that sqlite3ResolveOrderGroupBy() will convert the - ** order-by term to a copy of the result-set expression */ - if (iCol < 1) { - resolveOutOfRangeError(pParse, zType, i + 1, nResult); - return 1; - } - pItem.iCol = (u16)iCol; - continue; - } - - /* Otherwise, treat the ORDER BY term as an ordinary expression */ - pItem.iCol = 0; - if (sqlite3ResolveExprNames(pNC, ref pE) != 0) { - return 1; - } - } - return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType); + sNC.allowAgg = 1; + sNC.pSrcList = p.pSrc; + sNC.pNext = pOuterNC; + + /* Resolve names in the result set. */ + pEList = p.pEList; + Debug.Assert( pEList != null ); + for ( i = 0; i < pEList.nExpr; i++ ) + { + Expr pX = pEList.a[i].pExpr; + if ( sqlite3ResolveExprNames( sNC, ref pX ) != 0 ) + { + return WRC_Abort; + } } - /* - ** Resolve names in the SELECT statement p and all of its descendents. + /* Recursively resolve names in all subqueries */ - static int resolveSelectStep(Walker pWalker, Select p) { - NameContext pOuterNC; /* Context that contains this SELECT */ - NameContext sNC; /* Name context of this SELECT */ - bool isCompound; /* True if p is a compound select */ - int nCompound; /* Number of compound terms processed so far */ - Parse pParse; /* Parsing context */ - ExprList pEList; /* Result set expression list */ - int i; /* Loop counter */ - ExprList pGroupBy; /* The GROUP BY clause */ - Select pLeftmost; /* Left-most of SELECT of a compound */ - - Debug.Assert(p != null); - if ((p.selFlags & SF_Resolved) != 0) { - return WRC_Prune; - } - pOuterNC = pWalker.u.pNC; - pParse = pWalker.pParse; - //sqlite3 db = pParse.db; - - /* Normally sqlite3SelectExpand() will be called first and will have - ** already expanded this SELECT. However, if this is a subquery within - ** an expression, sqlite3ResolveExprNames() will be called without a - ** prior call to sqlite3SelectExpand(). When that happens, let - ** sqlite3SelectPrep() do all of the processing for this SELECT. - ** sqlite3SelectPrep() will invoke both sqlite3SelectExpand() and - ** this routine in the correct order. - */ - if ((p.selFlags & SF_Expanded) == 0) { - sqlite3SelectPrep(pParse, p, pOuterNC); - return (pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) ? WRC_Abort : WRC_Prune; - } - - isCompound = p.pPrior != null; - nCompound = 0; - pLeftmost = p; - while (p != null) { - Debug.Assert((p.selFlags & SF_Expanded) != 0); - Debug.Assert((p.selFlags & SF_Resolved) == 0); - p.selFlags |= SF_Resolved; - - /* Resolve the expressions in the LIMIT and OFFSET clauses. These - ** are not allowed to refer to any names, so pass an empty NameContext. - */ - sNC = new NameContext();// memset( &sNC, 0, sizeof( sNC ) ); - sNC.pParse = pParse; - if (sqlite3ResolveExprNames(sNC, ref p.pLimit) != 0 || - sqlite3ResolveExprNames(sNC, ref p.pOffset) != 0) { - return WRC_Abort; - } - - /* Set up the local name-context to pass to sqlite3ResolveExprNames() to - ** resolve the result-set expression list. - */ - sNC.allowAgg = 1; - sNC.pSrcList = p.pSrc; - sNC.pNext = pOuterNC; - - /* Resolve names in the result set. */ - pEList = p.pEList; - Debug.Assert(pEList != null); - for (i = 0; i < pEList.nExpr; i++) { - Expr pX = pEList.a[i].pExpr; - if (sqlite3ResolveExprNames(sNC, ref pX) != 0) { - return WRC_Abort; - } - } - - /* Recursively resolve names in all subqueries - */ - for (i = 0; i < p.pSrc.nSrc; i++) { - SrcList_item pItem = p.pSrc.a[i]; - if (pItem.pSelect != null) { - string zSavedContext = pParse.zAuthContext; - if (pItem.zName != null) - pParse.zAuthContext = pItem.zName; - sqlite3ResolveSelectNames(pParse, pItem.pSelect, pOuterNC); - pParse.zAuthContext = zSavedContext; - if (pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) - return WRC_Abort; - } - } + for ( i = 0; i < p.pSrc.nSrc; i++ ) + { + SrcList_item pItem = p.pSrc.a[i]; + if ( pItem.pSelect != null ) + { + string zSavedContext = pParse.zAuthContext; + if ( pItem.zName != null ) + pParse.zAuthContext = pItem.zName; + sqlite3ResolveSelectNames( pParse, pItem.pSelect, pOuterNC ); + pParse.zAuthContext = zSavedContext; + if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) + return WRC_Abort; + } + } - /* If there are no aggregate functions in the result-set, and no GROUP BY - ** expression, do not allow aggregates in any of the other expressions. - */ - Debug.Assert((p.selFlags & SF_Aggregate) == 0); - pGroupBy = p.pGroupBy; - if (pGroupBy != null || sNC.hasAgg != 0) { - p.selFlags |= SF_Aggregate; - } else { - sNC.allowAgg = 0; - } + /* If there are no aggregate functions in the result-set, and no GROUP BY + ** expression, do not allow aggregates in any of the other expressions. + */ + Debug.Assert( ( p.selFlags & SF_Aggregate ) == 0 ); + pGroupBy = p.pGroupBy; + if ( pGroupBy != null || sNC.hasAgg != 0 ) + { + p.selFlags |= SF_Aggregate; + } + else + { + sNC.allowAgg = 0; + } - /* If a HAVING clause is present, then there must be a GROUP BY clause. - */ - if (p.pHaving != null && pGroupBy == null) { - sqlite3ErrorMsg(pParse, "a GROUP BY clause is required before HAVING"); - return WRC_Abort; - } + /* If a HAVING clause is present, then there must be a GROUP BY clause. + */ + if ( p.pHaving != null && pGroupBy == null ) + { + sqlite3ErrorMsg( pParse, "a GROUP BY clause is required before HAVING" ); + return WRC_Abort; + } - /* Add the expression list to the name-context before parsing the - ** other expressions in the SELECT statement. This is so that - ** expressions in the WHERE clause (etc.) can refer to expressions by - ** aliases in the result set. - ** - ** Minor point: If this is the case, then the expression will be - ** re-evaluated for each reference to it. - */ - sNC.pEList = p.pEList; - if (sqlite3ResolveExprNames(sNC, ref p.pWhere) != 0 || - sqlite3ResolveExprNames(sNC, ref p.pHaving) != 0 - ) { - return WRC_Abort; - } + /* Add the expression list to the name-context before parsing the + ** other expressions in the SELECT statement. This is so that + ** expressions in the WHERE clause (etc.) can refer to expressions by + ** aliases in the result set. + ** + ** Minor point: If this is the case, then the expression will be + ** re-evaluated for each reference to it. + */ + sNC.pEList = p.pEList; + if ( sqlite3ResolveExprNames( sNC, ref p.pWhere ) != 0 || + sqlite3ResolveExprNames( sNC, ref p.pHaving ) != 0 + ) + { + return WRC_Abort; + } - /* The ORDER BY and GROUP BY clauses may not refer to terms in - ** outer queries - */ - sNC.pNext = null; - sNC.allowAgg = 1; - - /* Process the ORDER BY clause for singleton SELECT statements. - ** The ORDER BY clause for compounds SELECT statements is handled - ** below, after all of the result-sets for all of the elements of - ** the compound have been resolved. - */ - if (!isCompound && resolveOrderGroupBy(sNC, p, p.pOrderBy, "ORDER") != 0) { - return WRC_Abort; - } - //if ( db.mallocFailed != 0 ) - //{ - // return WRC_Abort; - //} - - /* Resolve the GROUP BY clause. At the same time, make sure - ** the GROUP BY clause does not contain aggregate functions. - */ - if (pGroupBy != null) { - ExprList_item pItem; - - if (resolveOrderGroupBy(sNC, p, pGroupBy, "GROUP") != 0 /*|| db.mallocFailed != 0 */ ) { - return WRC_Abort; - } - for (i = 0; i < pGroupBy.nExpr; i++)//, pItem++) - { - pItem = pGroupBy.a[i]; - if ((pItem.pExpr.flags & EP_Agg) != 0)//HasProperty(pItem.pExpr, EP_Agg) ) - { - sqlite3ErrorMsg(pParse, "aggregate functions are not allowed in " + - "the GROUP BY clause"); - return WRC_Abort; - } - } - } + /* The ORDER BY and GROUP BY clauses may not refer to terms in + ** outer queries + */ + sNC.pNext = null; + sNC.allowAgg = 1; - /* Advance to the next term of the compound - */ - p = p.pPrior; - nCompound++; - } + /* Process the ORDER BY clause for singleton SELECT statements. + ** The ORDER BY clause for compounds SELECT statements is handled + ** below, after all of the result-sets for all of the elements of + ** the compound have been resolved. + */ + if ( !isCompound && resolveOrderGroupBy( sNC, p, p.pOrderBy, "ORDER" ) != 0 ) + { + return WRC_Abort; + } + //if ( db.mallocFailed != 0 ) + //{ + // return WRC_Abort; + //} - /* Resolve the ORDER BY on a compound SELECT after all terms of - ** the compound have been resolved. - */ - if (isCompound && resolveCompoundOrderBy(pParse, pLeftmost) != 0) { - return WRC_Abort; + /* Resolve the GROUP BY clause. At the same time, make sure + ** the GROUP BY clause does not contain aggregate functions. + */ + if ( pGroupBy != null ) + { + ExprList_item pItem; + + if ( resolveOrderGroupBy( sNC, p, pGroupBy, "GROUP" ) != 0 /*|| db.mallocFailed != 0 */ ) + { + return WRC_Abort; + } + for ( i = 0; i < pGroupBy.nExpr; i++ )//, pItem++) + { + pItem = pGroupBy.a[i]; + if ( ( pItem.pExpr.flags & EP_Agg ) != 0 )//HasProperty(pItem.pExpr, EP_Agg) ) + { + sqlite3ErrorMsg( pParse, "aggregate functions are not allowed in " + + "the GROUP BY clause" ); + return WRC_Abort; } - - return WRC_Prune; + } } - /* - ** This routine walks an expression tree and resolves references to - ** table columns and result-set columns. At the same time, do error - ** checking on function usage and set a flag if any aggregate functions - ** are seen. - ** - ** To resolve table columns references we look for nodes (or subtrees) of the - ** form X.Y.Z or Y.Z or just Z where - ** - ** X: The name of a database. Ex: "main" or "temp" or - ** the symbolic name assigned to an ATTACH-ed database. - ** - ** Y: The name of a table in a FROM clause. Or in a trigger - ** one of the special names "old" or "new". - ** - ** Z: The name of a column in table Y. - ** - ** The node at the root of the subtree is modified as follows: - ** - ** Expr.op Changed to TK_COLUMN - ** Expr.pTab Points to the Table object for X.Y - ** Expr.iColumn The column index in X.Y. -1 for the rowid. - ** Expr.iTable The VDBE cursor number for X.Y - ** - ** - ** To resolve result-set references, look for expression nodes of the - ** form Z (with no X and Y prefix) where the Z matches the right-hand - ** size of an AS clause in the result-set of a SELECT. The Z expression - ** is replaced by a copy of the left-hand side of the result-set expression. - ** Table-name and function resolution occurs on the substituted expression - ** tree. For example, in: - ** - ** SELECT a+b AS x, c+d AS y FROM t1 ORDER BY x; - ** - ** The "x" term of the order by is replaced by "a+b" to render: - ** - ** SELECT a+b AS x, c+d AS y FROM t1 ORDER BY a+b; - ** - ** Function calls are checked to make sure that the function is - ** defined and that the correct number of arguments are specified. - ** If the function is an aggregate function, then the pNC.hasAgg is - ** set and the opcode is changed from TK_FUNCTION to TK_AGG_FUNCTION. - ** If an expression contains aggregate functions then the EP_Agg - ** property on the expression is set. - ** - ** An error message is left in pParse if anything is amiss. The number - ** if errors is returned. + /* Advance to the next term of the compound */ - static int sqlite3ResolveExprNames( - NameContext pNC, /* Namespace to resolve expressions in. */ - ref Expr pExpr /* The expression to be analyzed. */ - ) { - u8 savedHasAgg; - Walker w = new Walker(); - - if (pExpr == null) - return 0; + p = p.pPrior; + nCompound++; + } + + /* Resolve the ORDER BY on a compound SELECT after all terms of + ** the compound have been resolved. + */ + if ( isCompound && resolveCompoundOrderBy( pParse, pLeftmost ) != 0 ) + { + return WRC_Abort; + } + + return WRC_Prune; + } + + /* + ** This routine walks an expression tree and resolves references to + ** table columns and result-set columns. At the same time, do error + ** checking on function usage and set a flag if any aggregate functions + ** are seen. + ** + ** To resolve table columns references we look for nodes (or subtrees) of the + ** form X.Y.Z or Y.Z or just Z where + ** + ** X: The name of a database. Ex: "main" or "temp" or + ** the symbolic name assigned to an ATTACH-ed database. + ** + ** Y: The name of a table in a FROM clause. Or in a trigger + ** one of the special names "old" or "new". + ** + ** Z: The name of a column in table Y. + ** + ** The node at the root of the subtree is modified as follows: + ** + ** Expr.op Changed to TK_COLUMN + ** Expr.pTab Points to the Table object for X.Y + ** Expr.iColumn The column index in X.Y. -1 for the rowid. + ** Expr.iTable The VDBE cursor number for X.Y + ** + ** + ** To resolve result-set references, look for expression nodes of the + ** form Z (with no X and Y prefix) where the Z matches the right-hand + ** size of an AS clause in the result-set of a SELECT. The Z expression + ** is replaced by a copy of the left-hand side of the result-set expression. + ** Table-name and function resolution occurs on the substituted expression + ** tree. For example, in: + ** + ** SELECT a+b AS x, c+d AS y FROM t1 ORDER BY x; + ** + ** The "x" term of the order by is replaced by "a+b" to render: + ** + ** SELECT a+b AS x, c+d AS y FROM t1 ORDER BY a+b; + ** + ** Function calls are checked to make sure that the function is + ** defined and that the correct number of arguments are specified. + ** If the function is an aggregate function, then the pNC.hasAgg is + ** set and the opcode is changed from TK_FUNCTION to TK_AGG_FUNCTION. + ** If an expression contains aggregate functions then the EP_Agg + ** property on the expression is set. + ** + ** An error message is left in pParse if anything is amiss. The number + ** if errors is returned. + */ + static int sqlite3ResolveExprNames( + NameContext pNC, /* Namespace to resolve expressions in. */ + ref Expr pExpr /* The expression to be analyzed. */ + ) + { + u8 savedHasAgg; + Walker w = new Walker(); + + if ( pExpr == null ) + return 0; #if SQLITE_MAX_EXPR_DEPTH//>0 { Parse pParse = pNC.pParse; @@ -1215,53 +1361,58 @@ ref Expr pExpr /* The expression to be analyzed. */ pParse.nHeight += pExpr.nHeight; } #endif - savedHasAgg = pNC.hasAgg; - pNC.hasAgg = 0; - w.xExprCallback = resolveExprStep; - w.xSelectCallback = resolveSelectStep; - w.pParse = pNC.pParse; - w.u.pNC = pNC; - sqlite3WalkExpr(w, ref pExpr); + savedHasAgg = pNC.hasAgg; + pNC.hasAgg = 0; + w.xExprCallback = resolveExprStep; + w.xSelectCallback = resolveSelectStep; + w.pParse = pNC.pParse; + w.u.pNC = pNC; + sqlite3WalkExpr( w, ref pExpr ); #if SQLITE_MAX_EXPR_DEPTH//>0 pNC.pParse.nHeight -= pExpr.nHeight; #endif - if (pNC.nErr > 0 || w.pParse.nErr > 0) { - ExprSetProperty(pExpr, EP_Error); - } - if (pNC.hasAgg != 0) { - ExprSetProperty(pExpr, EP_Agg); - } else if (savedHasAgg != 0) { - pNC.hasAgg = 1; - } - return ExprHasProperty(pExpr, EP_Error) ? 1 : 0; - } + if ( pNC.nErr > 0 || w.pParse.nErr > 0 ) + { + ExprSetProperty( pExpr, EP_Error ); + } + if ( pNC.hasAgg != 0 ) + { + ExprSetProperty( pExpr, EP_Agg ); + } + else if ( savedHasAgg != 0 ) + { + pNC.hasAgg = 1; + } + return ExprHasProperty( pExpr, EP_Error ) ? 1 : 0; + } - /* - ** Resolve all names in all expressions of a SELECT and in all - ** decendents of the SELECT, including compounds off of p.pPrior, - ** subqueries in expressions, and subqueries used as FROM clause - ** terms. - ** - ** See sqlite3ResolveExprNames() for a description of the kinds of - ** transformations that occur. - ** - ** All SELECT statements should have been expanded using - ** sqlite3SelectExpand() prior to invoking this routine. - */ - static void sqlite3ResolveSelectNames( - Parse pParse, /* The parser context */ - Select p, /* The SELECT statement being coded. */ - NameContext pOuterNC /* Name context for parent SELECT statement */ - ) { - Walker w = new Walker(); - - Debug.Assert(p != null); - w.xExprCallback = resolveExprStep; - w.xSelectCallback = resolveSelectStep; - w.pParse = pParse; - w.u.pNC = pOuterNC; - sqlite3WalkSelect(w, p); - } + /* + ** Resolve all names in all expressions of a SELECT and in all + ** decendents of the SELECT, including compounds off of p.pPrior, + ** subqueries in expressions, and subqueries used as FROM clause + ** terms. + ** + ** See sqlite3ResolveExprNames() for a description of the kinds of + ** transformations that occur. + ** + ** All SELECT statements should have been expanded using + ** sqlite3SelectExpand() prior to invoking this routine. + */ + static void sqlite3ResolveSelectNames( + Parse pParse, /* The parser context */ + Select p, /* The SELECT statement being coded. */ + NameContext pOuterNC /* Name context for parent SELECT statement */ + ) + { + Walker w = new Walker(); + + Debug.Assert( p != null ); + w.xExprCallback = resolveExprStep; + w.xSelectCallback = resolveSelectStep; + w.pParse = pParse; + w.u.pNC = pOuterNC; + sqlite3WalkSelect( w, p ); } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/rowset_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/rowset_c.cs index 6da122537..d28509751 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/rowset_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/rowset_c.cs @@ -1,456 +1,519 @@ +using System; using System.Diagnostics; +using System.Text; using i64 = System.Int64; -using u32 = System.UInt32; using u8 = System.Byte; +using u32 = System.UInt32; -namespace Community.CsharpSqlite { - using sqlite3_int64 = System.Int64; +using Pgno = System.UInt32; - public partial class Sqlite3 { - /* - ** 2008 December 3 - ** - ** 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 module implements an object we call a "RowSet". - ** - ** The RowSet object is a collection of rowids. Rowids - ** are inserted into the RowSet in an arbitrary order. Inserts - ** can be intermixed with tests to see if a given rowid has been - ** previously inserted into the RowSet. - ** - ** After all inserts are finished, it is possible to extract the - ** elements of the RowSet in sorted order. Once this extraction - ** process has started, no new elements may be inserted. - ** - ** Hence, the primitive operations for a RowSet are: - ** - ** CREATE - ** INSERT - ** TEST - ** SMALLEST - ** DESTROY - ** - ** The CREATE and DESTROY primitives are the constructor and destructor, - ** obviously. The INSERT primitive adds a new element to the RowSet. - ** TEST checks to see if an element is already in the RowSet. SMALLEST - ** extracts the least value from the RowSet. - ** - ** The INSERT primitive might allocate additional memory. Memory is - ** allocated in chunks so most INSERTs do no allocation. There is an - ** upper bound on the size of allocated memory. No memory is freed - ** until DESTROY. - ** - ** The TEST primitive includes a "batch" number. The TEST primitive - ** will only see elements that were inserted before the last change - ** in the batch number. In other words, if an INSERT occurs between - ** two TESTs where the TESTs have the same batch nubmer, then the - ** value added by the INSERT will not be visible to the second TEST. - ** The initial batch number is zero, so if the very first TEST contains - ** a non-zero batch number, it will see all prior INSERTs. - ** - ** No INSERTs may occurs after a SMALLEST. An assertion will fail if - ** that is attempted. - ** - ** The cost of an INSERT is roughly constant. (Sometime new memory - ** has to be allocated on an INSERT.) The cost of a TEST with a new - ** batch number is O(NlogN) where N is the number of elements in the RowSet. - ** The cost of a TEST using the same batch number is O(logN). The cost - ** of the first SMALLEST is O(NlogN). Second and subsequent SMALLEST - ** primitives are constant time. The cost of DESTROY is O(N). - ** - ** There is an added cost of O(N) when switching between TEST and - ** SMALLEST primitives. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +namespace Community.CsharpSqlite +{ + using sqlite3_int64 = System.Int64; - /* - ** Target size for allocation chunks. - */ - //#define ROWSET_ALLOCATION_SIZE 1024 - const int ROWSET_ALLOCATION_SIZE = 1024; - /* - ** The number of rowset entries per allocation chunk. - */ - //#define ROWSET_ENTRY_PER_CHUNK \ - // ((ROWSET_ALLOCATION_SIZE-8)/sizeof(struct RowSetEntry)) - const int ROWSET_ENTRY_PER_CHUNK = 63; + public partial class Sqlite3 + { + /* + ** 2008 December 3 + ** + ** 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 module implements an object we call a "RowSet". + ** + ** The RowSet object is a collection of rowids. Rowids + ** are inserted into the RowSet in an arbitrary order. Inserts + ** can be intermixed with tests to see if a given rowid has been + ** previously inserted into the RowSet. + ** + ** After all inserts are finished, it is possible to extract the + ** elements of the RowSet in sorted order. Once this extraction + ** process has started, no new elements may be inserted. + ** + ** Hence, the primitive operations for a RowSet are: + ** + ** CREATE + ** INSERT + ** TEST + ** SMALLEST + ** DESTROY + ** + ** The CREATE and DESTROY primitives are the constructor and destructor, + ** obviously. The INSERT primitive adds a new element to the RowSet. + ** TEST checks to see if an element is already in the RowSet. SMALLEST + ** extracts the least value from the RowSet. + ** + ** The INSERT primitive might allocate additional memory. Memory is + ** allocated in chunks so most INSERTs do no allocation. There is an + ** upper bound on the size of allocated memory. No memory is freed + ** until DESTROY. + ** + ** The TEST primitive includes a "batch" number. The TEST primitive + ** will only see elements that were inserted before the last change + ** in the batch number. In other words, if an INSERT occurs between + ** two TESTs where the TESTs have the same batch nubmer, then the + ** value added by the INSERT will not be visible to the second TEST. + ** The initial batch number is zero, so if the very first TEST contains + ** a non-zero batch number, it will see all prior INSERTs. + ** + ** No INSERTs may occurs after a SMALLEST. An assertion will fail if + ** that is attempted. + ** + ** The cost of an INSERT is roughly constant. (Sometime new memory + ** has to be allocated on an INSERT.) The cost of a TEST with a new + ** batch number is O(NlogN) where N is the number of elements in the RowSet. + ** The cost of a TEST using the same batch number is O(logN). The cost + ** of the first SMALLEST is O(NlogN). Second and subsequent SMALLEST + ** primitives are constant time. The cost of DESTROY is O(N). + ** + ** There is an added cost of O(N) when switching between TEST and + ** SMALLEST primitives. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" - /* - ** Each entry in a RowSet is an instance of the following object. - */ - public class RowSetEntry { - public i64 v; /* ROWID value for this entry */ - public RowSetEntry pRight; /* Right subtree (larger entries) or list */ - public RowSetEntry pLeft; /* Left subtree (smaller entries) */ - }; + /* + ** Target size for allocation chunks. + */ + //#define ROWSET_ALLOCATION_SIZE 1024 + const int ROWSET_ALLOCATION_SIZE = 1024; + /* + ** The number of rowset entries per allocation chunk. + */ + //#define ROWSET_ENTRY_PER_CHUNK \ + // ((ROWSET_ALLOCATION_SIZE-8)/sizeof(struct RowSetEntry)) + const int ROWSET_ENTRY_PER_CHUNK = 63; - /* - ** Index entries are allocated in large chunks (instances of the - ** following structure) to reduce memory allocation overhead. The - ** chunks are kept on a linked list so that they can be deallocated - ** when the RowSet is destroyed. - */ - public class RowSetChunk { - public RowSetChunk pNextChunk; /* Next chunk on list of them all */ - public RowSetEntry[] aEntry = new RowSetEntry[ROWSET_ENTRY_PER_CHUNK]; /* Allocated entries */ - }; + /* + ** Each entry in a RowSet is an instance of the following object. + */ + public class RowSetEntry + { + public i64 v; /* ROWID value for this entry */ + public RowSetEntry pRight; /* Right subtree (larger entries) or list */ + public RowSetEntry pLeft; /* Left subtree (smaller entries) */ + }; - /* - ** A RowSet in an instance of the following structure. - ** - ** A typedef of this structure if found in sqliteInt.h. - */ - public class RowSet { - public RowSetChunk pChunk; /* List of all chunk allocations */ - public sqlite3 db; /* The database connection */ - public RowSetEntry pEntry; /* /* List of entries using pRight */ - public RowSetEntry pLast; /* Last entry on the pEntry list */ - public RowSetEntry[] pFresh; /* Source of new entry objects */ - public RowSetEntry pTree; /* Binary tree of entries */ - public int nFresh; /* Number of objects on pFresh */ - public bool isSorted; /* True if pEntry is sorted */ - public u8 iBatch; /* Current insert batch */ + /* + ** Index entries are allocated in large chunks (instances of the + ** following structure) to reduce memory allocation overhead. The + ** chunks are kept on a linked list so that they can be deallocated + ** when the RowSet is destroyed. + */ + public class RowSetChunk + { + public RowSetChunk pNextChunk; /* Next chunk on list of them all */ + public RowSetEntry[] aEntry = new RowSetEntry[ROWSET_ENTRY_PER_CHUNK]; /* Allocated entries */ + }; - public RowSet(sqlite3 db, int N) { - this.pChunk = null; - this.db = db; - this.pEntry = null; - this.pLast = null; - this.pFresh = new RowSetEntry[N]; - this.pTree = null; - this.nFresh = N; - this.isSorted = true; - this.iBatch = 0; - } - }; + /* + ** A RowSet in an instance of the following structure. + ** + ** A typedef of this structure if found in sqliteInt.h. + */ + public class RowSet + { + public RowSetChunk pChunk; /* List of all chunk allocations */ + public sqlite3 db; /* The database connection */ + public RowSetEntry pEntry; /* /* List of entries using pRight */ + public RowSetEntry pLast; /* Last entry on the pEntry list */ + public RowSetEntry[] pFresh; /* Source of new entry objects */ + public RowSetEntry pTree; /* Binary tree of entries */ + public int nFresh; /* Number of objects on pFresh */ + public bool isSorted; /* True if pEntry is sorted */ + public u8 iBatch; /* Current insert batch */ - /* - ** Turn bulk memory into a RowSet object. N bytes of memory - ** are available at pSpace. The db pointer is used as a memory context - ** for any subsequent allocations that need to occur. - ** Return a pointer to the new RowSet object. - ** - ** It must be the case that N is sufficient to make a Rowset. If not - ** an assertion fault occurs. - ** - ** If N is larger than the minimum, use the surplus as an initial - ** allocation of entries available to be filled. - */ - static RowSet sqlite3RowSetInit(sqlite3 db, object pSpace, u32 N) { - RowSet p = new RowSet(db, (int)N); - //Debug.Assert(N >= ROUND8(sizeof(*p)) ); - // p = pSpace; - // p.pChunk = 0; - // p.db = db; - // p.pEntry = 0; - // p.pLast = 0; - // p.pTree = 0; - // p.pFresh =(struct RowSetEntry*)(ROUND8(sizeof(*p)) + (char*)p); - // p.nFresh = (u16)((N - ROUND8(sizeof(*p)))/sizeof(struct RowSetEntry)); - // p.isSorted = 1; - // p.iBatch = 0; - return p; - } + public RowSet( sqlite3 db, int N ) + { + this.pChunk = null; + this.db = db; + this.pEntry = null; + this.pLast = null; + this.pFresh = new RowSetEntry[N]; + this.pTree = null; + this.nFresh = N; + this.isSorted = true; + this.iBatch = 0; + } + }; - /* - ** Deallocate all chunks from a RowSet. This frees all memory that - ** the RowSet has allocated over its lifetime. This routine is - ** the destructor for the RowSet. - */ - static void sqlite3RowSetClear(RowSet p) { - RowSetChunk pChunk, pNextChunk; - for (pChunk = p.pChunk; pChunk != null; pChunk = pNextChunk) { - pNextChunk = pChunk.pNextChunk; - sqlite3DbFree(p.db, ref pChunk); - } - p.pChunk = null; - p.nFresh = 0; - p.pEntry = null; - p.pLast = null; - p.pTree = null; - p.isSorted = true; - } + /* + ** Turn bulk memory into a RowSet object. N bytes of memory + ** are available at pSpace. The db pointer is used as a memory context + ** for any subsequent allocations that need to occur. + ** Return a pointer to the new RowSet object. + ** + ** It must be the case that N is sufficient to make a Rowset. If not + ** an assertion fault occurs. + ** + ** If N is larger than the minimum, use the surplus as an initial + ** allocation of entries available to be filled. + */ + static RowSet sqlite3RowSetInit( sqlite3 db, object pSpace, u32 N ) + { + RowSet p = new RowSet( db, (int)N ); + //Debug.Assert(N >= ROUND8(sizeof(*p)) ); + // p = pSpace; + // p.pChunk = 0; + // p.db = db; + // p.pEntry = 0; + // p.pLast = 0; + // p.pTree = 0; + // p.pFresh =(struct RowSetEntry*)(ROUND8(sizeof(*p)) + (char*)p); + // p.nFresh = (u16)((N - ROUND8(sizeof(*p)))/sizeof(struct RowSetEntry)); + // p.isSorted = 1; + // p.iBatch = 0; + return p; + } + + /* + ** Deallocate all chunks from a RowSet. This frees all memory that + ** the RowSet has allocated over its lifetime. This routine is + ** the destructor for the RowSet. + */ + static void sqlite3RowSetClear( RowSet p ) + { + RowSetChunk pChunk, pNextChunk; + for ( pChunk = p.pChunk; pChunk != null; pChunk = pNextChunk ) + { + pNextChunk = pChunk.pNextChunk; + sqlite3DbFree( p.db, ref pChunk ); + } + p.pChunk = null; + p.nFresh = 0; + p.pEntry = null; + p.pLast = null; + p.pTree = null; + p.isSorted = true; + } - /* - ** Insert a new value into a RowSet. - ** - ** The mallocFailed flag of the database connection is set if a - ** memory allocation fails. - */ - static void sqlite3RowSetInsert(RowSet p, i64 rowid) { - RowSetEntry pEntry; /* The new entry */ - RowSetEntry pLast; /* The last prior entry */ - Debug.Assert(p != null); - if (p.nFresh == 0) { - RowSetChunk pNew; - pNew = new RowSetChunk();//sqlite3DbMallocRaw(p.db, sizeof(*pNew)); - if (pNew == null) { - return; - } - pNew.pNextChunk = p.pChunk; - p.pChunk = pNew; - p.pFresh = pNew.aEntry; - p.nFresh = ROWSET_ENTRY_PER_CHUNK; - } - p.pFresh[p.pFresh.Length - p.nFresh] = new RowSetEntry(); - pEntry = p.pFresh[p.pFresh.Length - p.nFresh]; - p.nFresh--; - pEntry.v = rowid; - pEntry.pRight = null; - pLast = p.pLast; - if (pLast != null) { - if (p.isSorted && rowid <= pLast.v) { - p.isSorted = false; - } - pLast.pRight = pEntry; - } else { - Debug.Assert(p.pEntry == null);/* Fires if INSERT after SMALLEST */ - p.pEntry = pEntry; - } - p.pLast = pEntry; + /* + ** Insert a new value into a RowSet. + ** + ** The mallocFailed flag of the database connection is set if a + ** memory allocation fails. + */ + static void sqlite3RowSetInsert( RowSet p, i64 rowid ) + { + RowSetEntry pEntry; /* The new entry */ + RowSetEntry pLast; /* The last prior entry */ + Debug.Assert( p != null ); + if ( p.nFresh == 0 ) + { + RowSetChunk pNew; + pNew = new RowSetChunk();//sqlite3DbMallocRaw(p.db, sizeof(*pNew)); + if ( pNew == null ) + { + return; } + pNew.pNextChunk = p.pChunk; + p.pChunk = pNew; + p.pFresh = pNew.aEntry; + p.nFresh = ROWSET_ENTRY_PER_CHUNK; + } + p.pFresh[p.pFresh.Length - p.nFresh] = new RowSetEntry(); + pEntry = p.pFresh[p.pFresh.Length - p.nFresh]; + p.nFresh--; + pEntry.v = rowid; + pEntry.pRight = null; + pLast = p.pLast; + if ( pLast != null ) + { + if ( p.isSorted && rowid <= pLast.v ) + { + p.isSorted = false; + } + pLast.pRight = pEntry; + } + else + { + Debug.Assert( p.pEntry == null );/* Fires if INSERT after SMALLEST */ + p.pEntry = pEntry; + } + p.pLast = pEntry; + } - /* - ** Merge two lists of RowSetEntry objects. Remove duplicates. - ** - ** The input lists are connected via pRight pointers and are - ** assumed to each already be in sorted order. - */ - static RowSetEntry rowSetMerge( - RowSetEntry pA, /* First sorted list to be merged */ - RowSetEntry pB /* Second sorted list to be merged */ - ) { - RowSetEntry head = new RowSetEntry(); - RowSetEntry pTail; + /* + ** Merge two lists of RowSetEntry objects. Remove duplicates. + ** + ** The input lists are connected via pRight pointers and are + ** assumed to each already be in sorted order. + */ + static RowSetEntry rowSetMerge( + RowSetEntry pA, /* First sorted list to be merged */ + RowSetEntry pB /* Second sorted list to be merged */ + ) + { + RowSetEntry head = new RowSetEntry(); + RowSetEntry pTail; - pTail = head; - while (pA != null && pB != null) { - Debug.Assert(pA.pRight == null || pA.v <= pA.pRight.v); - Debug.Assert(pB.pRight == null || pB.v <= pB.pRight.v); - if (pA.v < pB.v) { - pTail.pRight = pA; - pA = pA.pRight; - pTail = pTail.pRight; - } else if (pB.v < pA.v) { - pTail.pRight = pB; - pB = pB.pRight; - pTail = pTail.pRight; - } else { - pA = pA.pRight; - } - } - if (pA != null) { - Debug.Assert(pA.pRight == null || pA.v <= pA.pRight.v); - pTail.pRight = pA; - } else { - Debug.Assert(pB == null || pB.pRight == null || pB.v <= pB.pRight.v); - pTail.pRight = pB; - } - return head.pRight; + pTail = head; + while ( pA != null && pB != null ) + { + Debug.Assert( pA.pRight == null || pA.v <= pA.pRight.v ); + Debug.Assert( pB.pRight == null || pB.v <= pB.pRight.v ); + if ( pA.v < pB.v ) + { + pTail.pRight = pA; + pA = pA.pRight; + pTail = pTail.pRight; + } + else if ( pB.v < pA.v ) + { + pTail.pRight = pB; + pB = pB.pRight; + pTail = pTail.pRight; + } + else + { + pA = pA.pRight; } + } + if ( pA != null ) + { + Debug.Assert( pA.pRight == null || pA.v <= pA.pRight.v ); + pTail.pRight = pA; + } + else + { + Debug.Assert( pB == null || pB.pRight == null || pB.v <= pB.pRight.v ); + pTail.pRight = pB; + } + return head.pRight; + } - /* - ** Sort all elements on the pEntry list of the RowSet into ascending order. - */ - static void rowSetSort(RowSet p) { - u32 i; - RowSetEntry pEntry; - RowSetEntry[] aBucket = new RowSetEntry[40]; + /* + ** Sort all elements on the pEntry list of the RowSet into ascending order. + */ + static void rowSetSort( RowSet p ) + { + u32 i; + RowSetEntry pEntry; + RowSetEntry[] aBucket = new RowSetEntry[40]; - Debug.Assert(p.isSorted == false); - //memset(aBucket, 0, sizeof(aBucket)); - while (p.pEntry != null) { - pEntry = p.pEntry; - p.pEntry = pEntry.pRight; - pEntry.pRight = null; - for (i = 0; aBucket[i] != null; i++) { - pEntry = rowSetMerge(aBucket[i], pEntry); - aBucket[i] = null; - } - aBucket[i] = pEntry; - } - pEntry = null; - for (i = 0; i < aBucket.Length; i++)//sizeof(aBucket)/sizeof(aBucket[0]) - { - pEntry = rowSetMerge(pEntry, aBucket[i]); - } - p.pEntry = pEntry; - p.pLast = null; - p.isSorted = true; + Debug.Assert( p.isSorted == false ); + //memset(aBucket, 0, sizeof(aBucket)); + while ( p.pEntry != null ) + { + pEntry = p.pEntry; + p.pEntry = pEntry.pRight; + pEntry.pRight = null; + for ( i = 0; aBucket[i] != null; i++ ) + { + pEntry = rowSetMerge( aBucket[i], pEntry ); + aBucket[i] = null; } + aBucket[i] = pEntry; + } + pEntry = null; + for ( i = 0; i < aBucket.Length; i++ )//sizeof(aBucket)/sizeof(aBucket[0]) + { + pEntry = rowSetMerge( pEntry, aBucket[i] ); + } + p.pEntry = pEntry; + p.pLast = null; + p.isSorted = true; + } - /* - ** The input, pIn, is a binary tree (or subtree) of RowSetEntry objects. - ** Convert this tree into a linked list connected by the pRight pointers - ** and return pointers to the first and last elements of the new list. - */ - static void rowSetTreeToList( - RowSetEntry pIn, /* Root of the input tree */ - ref RowSetEntry ppFirst, /* Write head of the output list here */ - ref RowSetEntry ppLast /* Write tail of the output list here */ - ) { - Debug.Assert(pIn != null); - if (pIn.pLeft != null) { - RowSetEntry p = new RowSetEntry(); - rowSetTreeToList(pIn.pLeft, ref ppFirst, ref p); - p.pRight = pIn; - } else { - ppFirst = pIn; - } - if (pIn.pRight != null) { - rowSetTreeToList(pIn.pRight, ref pIn.pRight, ref ppLast); - } else { - ppLast = pIn; - } - Debug.Assert((ppLast).pRight == null); - } + /* + ** The input, pIn, is a binary tree (or subtree) of RowSetEntry objects. + ** Convert this tree into a linked list connected by the pRight pointers + ** and return pointers to the first and last elements of the new list. + */ + static void rowSetTreeToList( + RowSetEntry pIn, /* Root of the input tree */ + ref RowSetEntry ppFirst, /* Write head of the output list here */ + ref RowSetEntry ppLast /* Write tail of the output list here */ + ) + { + Debug.Assert( pIn != null ); + if ( pIn.pLeft != null ) + { + RowSetEntry p = new RowSetEntry(); + rowSetTreeToList( pIn.pLeft, ref ppFirst, ref p ); + p.pRight = pIn; + } + else + { + ppFirst = pIn; + } + if ( pIn.pRight != null ) + { + rowSetTreeToList( pIn.pRight, ref pIn.pRight, ref ppLast ); + } + else + { + ppLast = pIn; + } + Debug.Assert( ( ppLast ).pRight == null ); + } - /* - ** Convert a sorted list of elements (connected by pRight) into a binary - ** tree with depth of iDepth. A depth of 1 means the tree contains a single - ** node taken from the head of *ppList. A depth of 2 means a tree with - ** three nodes. And so forth. - ** - ** Use as many entries from the input list as required and update the - ** *ppList to point to the unused elements of the list. If the input - ** list contains too few elements, then construct an incomplete tree - ** and leave *ppList set to NULL. - ** - ** Return a pointer to the root of the constructed binary tree. - */ - static RowSetEntry rowSetNDeepTree( - ref RowSetEntry ppList, - int iDepth - ) { - RowSetEntry p; /* Root of the new tree */ - RowSetEntry pLeft; /* Left subtree */ - if (ppList == null) { - return null; - } - if (iDepth == 1) { - p = ppList; - ppList = p.pRight; - p.pLeft = p.pRight = null; - return p; - } - pLeft = rowSetNDeepTree(ref ppList, iDepth - 1); - p = ppList; - if (p == null) { - return pLeft; - } - p.pLeft = pLeft; - ppList = p.pRight; - p.pRight = rowSetNDeepTree(ref ppList, iDepth - 1); - return p; - } + /* + ** Convert a sorted list of elements (connected by pRight) into a binary + ** tree with depth of iDepth. A depth of 1 means the tree contains a single + ** node taken from the head of *ppList. A depth of 2 means a tree with + ** three nodes. And so forth. + ** + ** Use as many entries from the input list as required and update the + ** *ppList to point to the unused elements of the list. If the input + ** list contains too few elements, then construct an incomplete tree + ** and leave *ppList set to NULL. + ** + ** Return a pointer to the root of the constructed binary tree. + */ + static RowSetEntry rowSetNDeepTree( + ref RowSetEntry ppList, + int iDepth + ) + { + RowSetEntry p; /* Root of the new tree */ + RowSetEntry pLeft; /* Left subtree */ + if ( ppList == null ) + { + return null; + } + if ( iDepth == 1 ) + { + p = ppList; + ppList = p.pRight; + p.pLeft = p.pRight = null; + return p; + } + pLeft = rowSetNDeepTree( ref ppList, iDepth - 1 ); + p = ppList; + if ( p == null ) + { + return pLeft; + } + p.pLeft = pLeft; + ppList = p.pRight; + p.pRight = rowSetNDeepTree( ref ppList, iDepth - 1 ); + return p; + } - /* - ** Convert a sorted list of elements into a binary tree. Make the tree - ** as deep as it needs to be in order to contain the entire list. - */ - static RowSetEntry rowSetListToTree(RowSetEntry pList) { - int iDepth; /* Depth of the tree so far */ - RowSetEntry p; /* Current tree root */ - RowSetEntry pLeft; /* Left subtree */ + /* + ** Convert a sorted list of elements into a binary tree. Make the tree + ** as deep as it needs to be in order to contain the entire list. + */ + static RowSetEntry rowSetListToTree( RowSetEntry pList ) + { + int iDepth; /* Depth of the tree so far */ + RowSetEntry p; /* Current tree root */ + RowSetEntry pLeft; /* Left subtree */ - Debug.Assert(pList != null); - p = pList; - pList = p.pRight; - p.pLeft = p.pRight = null; - for (iDepth = 1; pList != null; iDepth++) { - pLeft = p; - p = pList; - pList = p.pRight; - p.pLeft = pLeft; - p.pRight = rowSetNDeepTree(ref pList, iDepth); - } - return p; - } + Debug.Assert( pList != null ); + p = pList; + pList = p.pRight; + p.pLeft = p.pRight = null; + for ( iDepth = 1; pList != null; iDepth++ ) + { + pLeft = p; + p = pList; + pList = p.pRight; + p.pLeft = pLeft; + p.pRight = rowSetNDeepTree( ref pList, iDepth ); + } + return p; + } - /* - ** Convert the list in p.pEntry into a sorted list if it is not - ** sorted already. If there is a binary tree on p.pTree, then - ** convert it into a list too and merge it into the p.pEntry list. - */ - static void rowSetToList(RowSet p) { - if (!p.isSorted) { - rowSetSort(p); - } - if (p.pTree != null) { - RowSetEntry pHead = new RowSetEntry(); - RowSetEntry pTail = new RowSetEntry(); - rowSetTreeToList(p.pTree, ref pHead, ref pTail); - p.pTree = null; - p.pEntry = rowSetMerge(p.pEntry, pHead); - } - } + /* + ** Convert the list in p.pEntry into a sorted list if it is not + ** sorted already. If there is a binary tree on p.pTree, then + ** convert it into a list too and merge it into the p.pEntry list. + */ + static void rowSetToList( RowSet p ) + { + if ( !p.isSorted ) + { + rowSetSort( p ); + } + if ( p.pTree != null ) + { + RowSetEntry pHead = new RowSetEntry(); + RowSetEntry pTail = new RowSetEntry(); + rowSetTreeToList( p.pTree, ref pHead, ref pTail ); + p.pTree = null; + p.pEntry = rowSetMerge( p.pEntry, pHead ); + } + } - /* - ** Extract the smallest element from the RowSet. - ** Write the element into *pRowid. Return 1 on success. Return - ** 0 if the RowSet is already empty. - ** - ** After this routine has been called, the sqlite3RowSetInsert() - ** routine may not be called again. - */ - static int sqlite3RowSetNext(RowSet p, ref i64 pRowid) { - rowSetToList(p); - if (p.pEntry != null) { - pRowid = p.pEntry.v; - p.pEntry = p.pEntry.pRight; - if (p.pEntry == null) { - sqlite3RowSetClear(p); - } - return 1; - } else { - return 0; - } + /* + ** Extract the smallest element from the RowSet. + ** Write the element into *pRowid. Return 1 on success. Return + ** 0 if the RowSet is already empty. + ** + ** After this routine has been called, the sqlite3RowSetInsert() + ** routine may not be called again. + */ + static int sqlite3RowSetNext( RowSet p, ref i64 pRowid ) + { + rowSetToList( p ); + if ( p.pEntry != null ) + { + pRowid = p.pEntry.v; + p.pEntry = p.pEntry.pRight; + if ( p.pEntry == null ) + { + sqlite3RowSetClear( p ); } + return 1; + } + else + { + return 0; + } + } - /* - ** Check to see if element iRowid was inserted into the the rowset as - ** part of any insert batch prior to iBatch. Return 1 or 0. - */ - static int sqlite3RowSetTest(RowSet pRowSet, u8 iBatch, sqlite3_int64 iRowid) { - RowSetEntry p; - if (iBatch != pRowSet.iBatch) { - if (pRowSet.pEntry != null) { - rowSetToList(pRowSet); - pRowSet.pTree = rowSetListToTree(pRowSet.pEntry); - pRowSet.pEntry = null; - pRowSet.pLast = null; - } - pRowSet.iBatch = iBatch; - } - p = pRowSet.pTree; - while (p != null) { - if (p.v < iRowid) { - p = p.pRight; - } else if (p.v > iRowid) { - p = p.pLeft; - } else { - return 1; - } - } - return 0; + /* + ** Check to see if element iRowid was inserted into the the rowset as + ** part of any insert batch prior to iBatch. Return 1 or 0. + */ + static int sqlite3RowSetTest( RowSet pRowSet, u8 iBatch, sqlite3_int64 iRowid ) + { + RowSetEntry p; + if ( iBatch != pRowSet.iBatch ) + { + if ( pRowSet.pEntry != null ) + { + rowSetToList( pRowSet ); + pRowSet.pTree = rowSetListToTree( pRowSet.pEntry ); + pRowSet.pEntry = null; + pRowSet.pLast = null; } - + pRowSet.iBatch = iBatch; + } + p = pRowSet.pTree; + while ( p != null ) + { + if ( p.v < iRowid ) + { + p = p.pRight; + } + else if ( p.v > iRowid ) + { + p = p.pLeft; + } + else + { + return 1; + } + } + return 0; } + + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/select_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/select_c.cs index c759fc952..99f2975ae 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/select_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/select_c.cs @@ -1,176 +1,194 @@ #define SQLITE_MAX_EXPR_DEPTH using System; using System.Diagnostics; +using System.Text; using i16 = System.Int16; -using u16 = System.UInt16; using u8 = System.Byte; +using u16 = System.UInt16; +using u32 = System.UInt32; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 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. - ** - ************************************************************************* - ** This file contains C code routines that are called by the parser - ** to handle SELECT statements in SQLite. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +using Pgno = System.UInt32; +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 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. + ** + ************************************************************************* + ** This file contains C code routines that are called by the parser + ** to handle SELECT statements in SQLite. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" - /* - ** Delete all the content of a Select structure but do not deallocate - ** the select structure itself. - */ - static void clearSelect(sqlite3 db, Select p) { - sqlite3ExprListDelete(db, ref p.pEList); - sqlite3SrcListDelete(db, ref p.pSrc); - sqlite3ExprDelete(db, ref p.pWhere); - sqlite3ExprListDelete(db, ref p.pGroupBy); - sqlite3ExprDelete(db, ref p.pHaving); - sqlite3ExprListDelete(db, ref p.pOrderBy); - sqlite3SelectDelete(db, ref p.pPrior); - sqlite3ExprDelete(db, ref p.pLimit); - sqlite3ExprDelete(db, ref p.pOffset); - } - /* - ** Initialize a SelectDest structure. - */ - static void sqlite3SelectDestInit(SelectDest pDest, int eDest, int iParm) { - pDest.eDest = (u8)eDest; - pDest.iParm = iParm; - pDest.affinity = '\0'; - pDest.iMem = 0; - pDest.nMem = 0; - } + /* + ** Delete all the content of a Select structure but do not deallocate + ** the select structure itself. + */ + static void clearSelect( sqlite3 db, Select p ) + { + sqlite3ExprListDelete( db, ref p.pEList ); + sqlite3SrcListDelete( db, ref p.pSrc ); + sqlite3ExprDelete( db, ref p.pWhere ); + sqlite3ExprListDelete( db, ref p.pGroupBy ); + sqlite3ExprDelete( db, ref p.pHaving ); + sqlite3ExprListDelete( db, ref p.pOrderBy ); + sqlite3SelectDelete( db, ref p.pPrior ); + sqlite3ExprDelete( db, ref p.pLimit ); + sqlite3ExprDelete( db, ref p.pOffset ); + } + /* + ** Initialize a SelectDest structure. + */ + static void sqlite3SelectDestInit( SelectDest pDest, int eDest, int iParm ) + { + pDest.eDest = (u8)eDest; + pDest.iParm = iParm; + pDest.affinity = '\0'; + pDest.iMem = 0; + pDest.nMem = 0; + } - /* - ** Allocate a new Select structure and return a pointer to that - ** structure. - */ - // OVERLOADS, so I don't need to rewrite parse.c - static Select sqlite3SelectNew(Parse pParse, int null_2, SrcList pSrc, int null_4, int null_5, int null_6, int null_7, int isDistinct, int null_9, int null_10) { - return sqlite3SelectNew(pParse, null, pSrc, null, null, null, null, isDistinct, null, null); - } - static Select sqlite3SelectNew( - Parse pParse, /* Parsing context */ - ExprList pEList, /* which columns to include in the result */ - SrcList pSrc, /* the FROM clause -- which tables to scan */ - Expr pWhere, /* the WHERE clause */ - ExprList pGroupBy, /* the GROUP BY clause */ - Expr pHaving, /* the HAVING clause */ - ExprList pOrderBy, /* the ORDER BY clause */ - int isDistinct, /* true if the DISTINCT keyword is present */ - Expr pLimit, /* LIMIT value. NULL means not used */ - Expr pOffset /* OFFSET value. NULL means no offset */ - ) { - Select pNew; - // Select standin; - sqlite3 db = pParse.db; - pNew = new Select();//sqlite3DbMallocZero(db, sizeof(*pNew) ); - Debug.Assert( //db.mallocFailed != 0 || - null == pOffset || pLimit != null); /* OFFSET implies LIMIT */ - //if( pNew==null ){ - // pNew = standin; - // memset(pNew, 0, sizeof(*pNew)); - //} - if (pEList == null) { - pEList = sqlite3ExprListAppend(pParse, null, sqlite3Expr(db, TK_ALL, null)); - } - pNew.pEList = pEList; - pNew.pSrc = pSrc; - pNew.pWhere = pWhere; - pNew.pGroupBy = pGroupBy; - pNew.pHaving = pHaving; - pNew.pOrderBy = pOrderBy; - pNew.selFlags = (u16)(isDistinct != 0 ? SF_Distinct : 0); - pNew.op = TK_SELECT; - pNew.pLimit = pLimit; - pNew.pOffset = pOffset; - Debug.Assert(pOffset == null || pLimit != null); - pNew.addrOpenEphm[0] = -1; - pNew.addrOpenEphm[1] = -1; - pNew.addrOpenEphm[2] = -1; - //if ( db.mallocFailed != 0 ) - //{ - // clearSelect( db, pNew ); - // //if ( pNew != standin ) sqlite3DbFree( db, ref pNew ); - // pNew = null; - //} - return pNew; - } - /* - ** Delete the given Select structure and all of its substructures. - */ - static void sqlite3SelectDelete(sqlite3 db, ref Select p) { - if (p != null) { - clearSelect(db, p); - sqlite3DbFree(db, ref p); - } - } + /* + ** Allocate a new Select structure and return a pointer to that + ** structure. + */ + // OVERLOADS, so I don't need to rewrite parse.c + static Select sqlite3SelectNew( Parse pParse, int null_2, SrcList pSrc, int null_4, int null_5, int null_6, int null_7, int isDistinct, int null_9, int null_10 ) + { + return sqlite3SelectNew( pParse, null, pSrc, null, null, null, null, isDistinct, null, null ); + } + static Select sqlite3SelectNew( + Parse pParse, /* Parsing context */ + ExprList pEList, /* which columns to include in the result */ + SrcList pSrc, /* the FROM clause -- which tables to scan */ + Expr pWhere, /* the WHERE clause */ + ExprList pGroupBy, /* the GROUP BY clause */ + Expr pHaving, /* the HAVING clause */ + ExprList pOrderBy, /* the ORDER BY clause */ + int isDistinct, /* true if the DISTINCT keyword is present */ + Expr pLimit, /* LIMIT value. NULL means not used */ + Expr pOffset /* OFFSET value. NULL means no offset */ + ) + { + Select pNew; + // Select standin; + sqlite3 db = pParse.db; + pNew = new Select();//sqlite3DbMallocZero(db, sizeof(*pNew) ); + Debug.Assert( //db.mallocFailed != 0 || + null == pOffset || pLimit != null ); /* OFFSET implies LIMIT */ + //if( pNew==null ){ + // pNew = standin; + // memset(pNew, 0, sizeof(*pNew)); + //} + if ( pEList == null ) + { + pEList = sqlite3ExprListAppend( pParse, null, sqlite3Expr( db, TK_ALL, null ) ); + } + pNew.pEList = pEList; + pNew.pSrc = pSrc; + pNew.pWhere = pWhere; + pNew.pGroupBy = pGroupBy; + pNew.pHaving = pHaving; + pNew.pOrderBy = pOrderBy; + pNew.selFlags = (u16)( isDistinct != 0 ? SF_Distinct : 0 ); + pNew.op = TK_SELECT; + pNew.pLimit = pLimit; + pNew.pOffset = pOffset; + Debug.Assert( pOffset == null || pLimit != null ); + pNew.addrOpenEphm[0] = -1; + pNew.addrOpenEphm[1] = -1; + pNew.addrOpenEphm[2] = -1; + //if ( db.mallocFailed != 0 ) + //{ + // clearSelect( db, pNew ); + // //if ( pNew != standin ) sqlite3DbFree( db, ref pNew ); + // pNew = null; + //} + return pNew; + } - /* - ** Given 1 to 3 identifiers preceeding the JOIN keyword, determine the - ** type of join. Return an integer constant that expresses that type - ** in terms of the following bit values: - ** - ** JT_INNER - ** JT_CROSS - ** JT_OUTER - ** JT_NATURAL - ** JT_LEFT - ** JT_RIGHT - ** - ** A full outer join is the combination of JT_LEFT and JT_RIGHT. - ** - ** If an illegal or unsupported join type is seen, then still return - ** a join type, but put an error in the pParse structure. - */ + /* + ** Delete the given Select structure and all of its substructures. + */ + static void sqlite3SelectDelete( sqlite3 db, ref Select p ) + { + if ( p != null ) + { + clearSelect( db, p ); + sqlite3DbFree( db, ref p ); + } + } - class Keyword { - public u8 i; /* Beginning of keyword text in zKeyText[] */ - public u8 nChar; /* Length of the keyword in characters */ - public u8 code; /* Join type mask */ - public Keyword(u8 i, u8 nChar, u8 code) { - this.i = i; - this.nChar = nChar; - this.code = code; - } - } + /* + ** Given 1 to 3 identifiers preceeding the JOIN keyword, determine the + ** type of join. Return an integer constant that expresses that type + ** in terms of the following bit values: + ** + ** JT_INNER + ** JT_CROSS + ** JT_OUTER + ** JT_NATURAL + ** JT_LEFT + ** JT_RIGHT + ** + ** A full outer join is the combination of JT_LEFT and JT_RIGHT. + ** + ** If an illegal or unsupported join type is seen, then still return + ** a join type, but put an error in the pParse structure. + */ - // OVERLOADS, so I don't need to rewrite parse.c - static int sqlite3JoinType(Parse pParse, Token pA, int null_3, int null_4) { - return sqlite3JoinType(pParse, pA, null, null); - } - static int sqlite3JoinType(Parse pParse, Token pA, Token pB, int null_4) { - return sqlite3JoinType(pParse, pA, pB, null); - } - static int sqlite3JoinType(Parse pParse, Token pA, Token pB, Token pC) { - int jointype = 0; - Token[] apAll = new Token[3]; - Token p; + class Keyword + { + public u8 i; /* Beginning of keyword text in zKeyText[] */ + public u8 nChar; /* Length of the keyword in characters */ + public u8 code; /* Join type mask */ + public Keyword( u8 i, u8 nChar, u8 code ) + { + this.i = i; + this.nChar = nChar; + this.code = code; + } + } + + // OVERLOADS, so I don't need to rewrite parse.c + static int sqlite3JoinType( Parse pParse, Token pA, int null_3, int null_4 ) + { + return sqlite3JoinType( pParse, pA, null, null ); + } + static int sqlite3JoinType( Parse pParse, Token pA, Token pB, int null_4 ) + { + return sqlite3JoinType( pParse, pA, pB, null ); + } + static int sqlite3JoinType( Parse pParse, Token pA, Token pB, Token pC ) + { + int jointype = 0; + Token[] apAll = new Token[3]; + Token p; - /* 0123456789 123456789 123456789 123 */ - string zKeyText = "naturaleftouterightfullinnercross"; + /* 0123456789 123456789 123456789 123 */ + string zKeyText = "naturaleftouterightfullinnercross"; - Keyword[] aKeyword = new Keyword[]{ + Keyword[] aKeyword = new Keyword[]{ /* natural */ new Keyword( 0, 7, JT_NATURAL ), /* left */ new Keyword( 6, 4, JT_LEFT|JT_OUTER ), /* outer */ new Keyword( 10, 5, JT_OUTER ), @@ -179,711 +197,799 @@ static int sqlite3JoinType(Parse pParse, Token pA, Token pB, Token pC) { /* inner */ new Keyword( 23, 5, JT_INNER ), /* cross */ new Keyword( 28, 5, JT_INNER|JT_CROSS ), }; - int i, j; - apAll[0] = pA; - apAll[1] = pB; - apAll[2] = pC; - for (i = 0; i < 3 && apAll[i] != null; i++) { - p = apAll[i]; - for (j = 0; j < ArraySize(aKeyword); j++) { - if (p.n == aKeyword[j].nChar - && p.z.StartsWith(zKeyText.Substring(aKeyword[j].i, aKeyword[j].nChar), StringComparison.OrdinalIgnoreCase)) { - jointype |= aKeyword[j].code; - break; - } - } - testcase(j == 0 || j == 1 || j == 2 || j == 3 || j == 4 || j == 5 || j == 6); - if (j >= ArraySize(aKeyword)) { - jointype |= JT_ERROR; - break; - } - } - if ( - (jointype & (JT_INNER | JT_OUTER)) == (JT_INNER | JT_OUTER) || - (jointype & JT_ERROR) != 0 - ) { - string zSp = " "; - Debug.Assert(pB != null); - if (pC == null) { - zSp = ""; - } - sqlite3ErrorMsg(pParse, "unknown or unsupported join type: " + - "%T %T%s%T", pA, pB, zSp, pC); - jointype = JT_INNER; - } else if ((jointype & JT_OUTER) != 0 - && (jointype & (JT_LEFT | JT_RIGHT)) != JT_LEFT) { - sqlite3ErrorMsg(pParse, - "RIGHT and FULL OUTER JOINs are not currently supported"); - jointype = JT_INNER; - } - return jointype; + int i, j; + apAll[0] = pA; + apAll[1] = pB; + apAll[2] = pC; + for ( i = 0; i < 3 && apAll[i] != null; i++ ) + { + p = apAll[i]; + for ( j = 0; j < ArraySize( aKeyword ); j++ ) + { + if ( p.n == aKeyword[j].nChar + && p.z.StartsWith( zKeyText.Substring( aKeyword[j].i, aKeyword[j].nChar ), StringComparison.OrdinalIgnoreCase ) ) + { + jointype |= aKeyword[j].code; + break; + } } - - /* - ** Return the index of a column in a table. Return -1 if the column - ** is not contained in the table. - */ - static int columnIndex(Table pTab, string zCol) { - int i; - for (i = 0; i < pTab.nCol; i++) { - if (pTab.aCol[i].zName.Equals(zCol, StringComparison.OrdinalIgnoreCase)) - return i; - } - return -1; + testcase( j == 0 || j == 1 || j == 2 || j == 3 || j == 4 || j == 5 || j == 6 ); + if ( j >= ArraySize( aKeyword ) ) + { + jointype |= JT_ERROR; + break; } + } + if ( + ( jointype & ( JT_INNER | JT_OUTER ) ) == ( JT_INNER | JT_OUTER ) || + ( jointype & JT_ERROR ) != 0 + ) + { + string zSp = " "; + Debug.Assert( pB != null ); + if ( pC == null ) + { + zSp = ""; + } + sqlite3ErrorMsg( pParse, "unknown or unsupported join type: " + + "%T %T%s%T", pA, pB, zSp, pC ); + jointype = JT_INNER; + } + else if ( ( jointype & JT_OUTER ) != 0 + && ( jointype & ( JT_LEFT | JT_RIGHT ) ) != JT_LEFT ) + { + sqlite3ErrorMsg( pParse, + "RIGHT and FULL OUTER JOINs are not currently supported" ); + jointype = JT_INNER; + } + return jointype; + } + /* + ** Return the index of a column in a table. Return -1 if the column + ** is not contained in the table. + */ + static int columnIndex( Table pTab, string zCol ) + { + int i; + for ( i = 0; i < pTab.nCol; i++ ) + { + if ( pTab.aCol[i].zName.Equals( zCol, StringComparison.OrdinalIgnoreCase ) ) + return i; + } + return -1; + } - /* - ** Search the first N tables in pSrc, from left to right, looking for a - ** table that has a column named zCol. - ** - ** When found, set *piTab and *piCol to the table index and column index - ** of the matching column and return TRUE. - ** - ** If not found, return FALSE. - */ - static int tableAndColumnIndex( - SrcList pSrc, /* Array of tables to search */ - int N, /* Number of tables in pSrc.a[] to search */ - string zCol, /* Name of the column we are looking for */ - ref int piTab, /* Write index of pSrc.a[] here */ - ref int piCol /* Write index of pSrc.a[*piTab].pTab.aCol[] here */ - ) { - int i; /* For looping over tables in pSrc */ - int iCol; /* Index of column matching zCol */ - - Debug.Assert((piTab == 0) == (piCol == 0)); /* Both or neither are NULL */ - for (i = 0; i < N; i++) { - iCol = columnIndex(pSrc.a[i].pTab, zCol); - if (iCol >= 0) { - //if( piTab ) - { - piTab = i; - piCol = iCol; - } - return 1; - } - } - return 0; - } - /* - ** This function is used to add terms implied by JOIN syntax to the - ** WHERE clause expression of a SELECT statement. The new term, which - ** is ANDed with the existing WHERE clause, is of the form: - ** - ** (vtab1.col1 = tab2.col2) - ** - ** where tab1 is the iSrc'th table in SrcList pSrc and tab2 is the - ** (iSrc+1)'th. Column col1 is column iColLeft of tab1, and col2 is - ** column iColRight of tab2. - */ - static void addWhereTerm( - Parse pParse, /* Parsing context */ - SrcList pSrc, /* List of tables in FROM clause */ - int iLeft, /* Index of first table to join in pSrc */ - int iColLeft, /* Index of column in first table */ - int iRight, /* Index of second table in pSrc */ - int iColRight, /* Index of column in second table */ - int isOuterJoin, /* True if this is an OUTER join */ - ref Expr ppWhere /* IN/OUT: The WHERE clause to add to */ - ) { - sqlite3 db = pParse.db; - Expr pE1; - Expr pE2; - Expr pEq; - - Debug.Assert(iLeft < iRight); - Debug.Assert(pSrc.nSrc > iRight); - Debug.Assert(pSrc.a[iLeft].pTab != null); - Debug.Assert(pSrc.a[iRight].pTab != null); - - pE1 = sqlite3CreateColumnExpr(db, pSrc, iLeft, iColLeft); - pE2 = sqlite3CreateColumnExpr(db, pSrc, iRight, iColRight); - - pEq = sqlite3PExpr(pParse, TK_EQ, pE1, pE2, 0); - if (pEq != null && isOuterJoin != 0) { - ExprSetProperty(pEq, EP_FromJoin); - Debug.Assert(!ExprHasAnyProperty(pEq, EP_TokenOnly | EP_Reduced)); - ExprSetIrreducible(pEq); - pEq.iRightJoinTable = (i16)pE2.iTable; - } - ppWhere = sqlite3ExprAnd(db, ppWhere, pEq); + /* + ** Search the first N tables in pSrc, from left to right, looking for a + ** table that has a column named zCol. + ** + ** When found, set *piTab and *piCol to the table index and column index + ** of the matching column and return TRUE. + ** + ** If not found, return FALSE. + */ + static int tableAndColumnIndex( + SrcList pSrc, /* Array of tables to search */ + int N, /* Number of tables in pSrc.a[] to search */ + string zCol, /* Name of the column we are looking for */ + ref int piTab, /* Write index of pSrc.a[] here */ + ref int piCol /* Write index of pSrc.a[*piTab].pTab.aCol[] here */ + ) + { + int i; /* For looping over tables in pSrc */ + int iCol; /* Index of column matching zCol */ + + Debug.Assert( ( piTab == 0 ) == ( piCol == 0 ) ); /* Both or neither are NULL */ + for ( i = 0; i < N; i++ ) + { + iCol = columnIndex( pSrc.a[i].pTab, zCol ); + if ( iCol >= 0 ) + { + //if( piTab ) + { + piTab = i; + piCol = iCol; + } + return 1; } + } + return 0; + } - /* - ** Set the EP_FromJoin property on all terms of the given expression. - ** And set the Expr.iRightJoinTable to iTable for every term in the - ** expression. - ** - ** The EP_FromJoin property is used on terms of an expression to tell - ** the LEFT OUTER JOIN processing logic that this term is part of the - ** join restriction specified in the ON or USING clause and not a part - ** of the more general WHERE clause. These terms are moved over to the - ** WHERE clause during join processing but we need to remember that they - ** originated in the ON or USING clause. - ** - ** The Expr.iRightJoinTable tells the WHERE clause processing that the - ** expression depends on table iRightJoinTable even if that table is not - ** explicitly mentioned in the expression. That information is needed - ** for cases like this: - ** - ** SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.b AND t1.x=5 - ** - ** The where clause needs to defer the handling of the t1.x=5 - ** term until after the t2 loop of the join. In that way, a - ** NULL t2 row will be inserted whenever t1.x!=5. If we do not - ** defer the handling of t1.x=5, it will be processed immediately - ** after the t1 loop and rows with t1.x!=5 will never appear in - ** the output, which is incorrect. + /* + ** This function is used to add terms implied by JOIN syntax to the + ** WHERE clause expression of a SELECT statement. The new term, which + ** is ANDed with the existing WHERE clause, is of the form: + ** + ** (vtab1.col1 = tab2.col2) + ** + ** where tab1 is the iSrc'th table in SrcList pSrc and tab2 is the + ** (iSrc+1)'th. Column col1 is column iColLeft of tab1, and col2 is + ** column iColRight of tab2. + */ + static void addWhereTerm( + Parse pParse, /* Parsing context */ + SrcList pSrc, /* List of tables in FROM clause */ + int iLeft, /* Index of first table to join in pSrc */ + int iColLeft, /* Index of column in first table */ + int iRight, /* Index of second table in pSrc */ + int iColRight, /* Index of column in second table */ + int isOuterJoin, /* True if this is an OUTER join */ + ref Expr ppWhere /* IN/OUT: The WHERE clause to add to */ + ) + { + sqlite3 db = pParse.db; + Expr pE1; + Expr pE2; + Expr pEq; + + Debug.Assert( iLeft < iRight ); + Debug.Assert( pSrc.nSrc > iRight ); + Debug.Assert( pSrc.a[iLeft].pTab != null ); + Debug.Assert( pSrc.a[iRight].pTab != null ); + + pE1 = sqlite3CreateColumnExpr( db, pSrc, iLeft, iColLeft ); + pE2 = sqlite3CreateColumnExpr( db, pSrc, iRight, iColRight ); + + pEq = sqlite3PExpr( pParse, TK_EQ, pE1, pE2, 0 ); + if ( pEq != null && isOuterJoin != 0 ) + { + ExprSetProperty( pEq, EP_FromJoin ); + Debug.Assert( !ExprHasAnyProperty( pEq, EP_TokenOnly | EP_Reduced ) ); + ExprSetIrreducible( pEq ); + pEq.iRightJoinTable = (i16)pE2.iTable; + } + ppWhere = sqlite3ExprAnd( db, ppWhere, pEq ); + } + + /* + ** Set the EP_FromJoin property on all terms of the given expression. + ** And set the Expr.iRightJoinTable to iTable for every term in the + ** expression. + ** + ** The EP_FromJoin property is used on terms of an expression to tell + ** the LEFT OUTER JOIN processing logic that this term is part of the + ** join restriction specified in the ON or USING clause and not a part + ** of the more general WHERE clause. These terms are moved over to the + ** WHERE clause during join processing but we need to remember that they + ** originated in the ON or USING clause. + ** + ** The Expr.iRightJoinTable tells the WHERE clause processing that the + ** expression depends on table iRightJoinTable even if that table is not + ** explicitly mentioned in the expression. That information is needed + ** for cases like this: + ** + ** SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.b AND t1.x=5 + ** + ** The where clause needs to defer the handling of the t1.x=5 + ** term until after the t2 loop of the join. In that way, a + ** NULL t2 row will be inserted whenever t1.x!=5. If we do not + ** defer the handling of t1.x=5, it will be processed immediately + ** after the t1 loop and rows with t1.x!=5 will never appear in + ** the output, which is incorrect. + */ + static void setJoinExpr( Expr p, int iTable ) + { + while ( p != null ) + { + ExprSetProperty( p, EP_FromJoin ); + Debug.Assert( !ExprHasAnyProperty( p, EP_TokenOnly | EP_Reduced ) ); + ExprSetIrreducible( p ); + p.iRightJoinTable = (i16)iTable; + setJoinExpr( p.pLeft, iTable ); + p = p.pRight; + } + } + + /* + ** This routine processes the join information for a SELECT statement. + ** ON and USING clauses are converted into extra terms of the WHERE clause. + ** NATURAL joins also create extra WHERE clause terms. + ** + ** The terms of a FROM clause are contained in the Select.pSrc structure. + ** The left most table is the first entry in Select.pSrc. The right-most + ** table is the last entry. The join operator is held in the entry to + ** the left. Thus entry 0 contains the join operator for the join between + ** entries 0 and 1. Any ON or USING clauses associated with the join are + ** also attached to the left entry. + ** + ** This routine returns the number of errors encountered. + */ + static int sqliteProcessJoin( Parse pParse, Select p ) + { + SrcList pSrc; /* All tables in the FROM clause */ + int i; + int j; /* Loop counters */ + SrcList_item pLeft; /* Left table being joined */ + SrcList_item pRight; /* Right table being joined */ + + pSrc = p.pSrc; + //pLeft = pSrc.a[0]; + //pRight = pLeft[1]; + for ( i = 0; i < pSrc.nSrc - 1; i++ ) + { + pLeft = pSrc.a[i]; // pLeft ++ + pRight = pSrc.a[i + 1];//Right++, + Table pLeftTab = pLeft.pTab; + Table pRightTab = pRight.pTab; + bool isOuter; + + if ( NEVER( pLeftTab == null || pRightTab == null ) ) + continue; + isOuter = ( pRight.jointype & JT_OUTER ) != 0; + + /* When the NATURAL keyword is present, add WHERE clause terms for + ** every column that the two tables have in common. */ - static void setJoinExpr(Expr p, int iTable) { - while (p != null) { - ExprSetProperty(p, EP_FromJoin); - Debug.Assert(!ExprHasAnyProperty(p, EP_TokenOnly | EP_Reduced)); - ExprSetIrreducible(p); - p.iRightJoinTable = (i16)iTable; - setJoinExpr(p.pLeft, iTable); - p = p.pRight; + if ( ( pRight.jointype & JT_NATURAL ) != 0 ) + { + if ( pRight.pOn != null || pRight.pUsing != null ) + { + sqlite3ErrorMsg( pParse, "a NATURAL join may not have " + + "an ON or USING clause", "" ); + return 1; + } + for ( j = 0; j < pRightTab.nCol; j++ ) + { + string zName; /* Name of column in the right table */ + int iLeft = 0; /* Matching left table */ + int iLeftCol = 0; /* Matching column in the left table */ + + zName = pRightTab.aCol[j].zName; + int iRightCol = columnIndex( pRightTab, zName ); + if ( tableAndColumnIndex( pSrc, i + 1, zName, ref iLeft, ref iLeftCol ) != 0 ) + { + addWhereTerm( pParse, pSrc, iLeft, iLeftCol, i + 1, j, + isOuter ? 1 : 0, ref p.pWhere ); } + } } - /* - ** This routine processes the join information for a SELECT statement. - ** ON and USING clauses are converted into extra terms of the WHERE clause. - ** NATURAL joins also create extra WHERE clause terms. - ** - ** The terms of a FROM clause are contained in the Select.pSrc structure. - ** The left most table is the first entry in Select.pSrc. The right-most - ** table is the last entry. The join operator is held in the entry to - ** the left. Thus entry 0 contains the join operator for the join between - ** entries 0 and 1. Any ON or USING clauses associated with the join are - ** also attached to the left entry. - ** - ** This routine returns the number of errors encountered. + /* Disallow both ON and USING clauses in the same join */ - static int sqliteProcessJoin(Parse pParse, Select p) { - SrcList pSrc; /* All tables in the FROM clause */ - int i; - int j; /* Loop counters */ - SrcList_item pLeft; /* Left table being joined */ - SrcList_item pRight; /* Right table being joined */ - - pSrc = p.pSrc; - //pLeft = pSrc.a[0]; - //pRight = pLeft[1]; - for (i = 0; i < pSrc.nSrc - 1; i++) { - pLeft = pSrc.a[i]; // pLeft ++ - pRight = pSrc.a[i + 1];//Right++, - Table pLeftTab = pLeft.pTab; - Table pRightTab = pRight.pTab; - bool isOuter; - - if (NEVER(pLeftTab == null || pRightTab == null)) - continue; - isOuter = (pRight.jointype & JT_OUTER) != 0; - - /* When the NATURAL keyword is present, add WHERE clause terms for - ** every column that the two tables have in common. - */ - if ((pRight.jointype & JT_NATURAL) != 0) { - if (pRight.pOn != null || pRight.pUsing != null) { - sqlite3ErrorMsg(pParse, "a NATURAL join may not have " + - "an ON or USING clause", ""); - return 1; - } - for (j = 0; j < pRightTab.nCol; j++) { - string zName; /* Name of column in the right table */ - int iLeft = 0; /* Matching left table */ - int iLeftCol = 0; /* Matching column in the left table */ - - zName = pRightTab.aCol[j].zName; - int iRightCol = columnIndex(pRightTab, zName); - if (tableAndColumnIndex(pSrc, i + 1, zName, ref iLeft, ref iLeftCol) != 0) { - addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i + 1, j, - isOuter ? 1 : 0, ref p.pWhere); - } - } - } - - /* Disallow both ON and USING clauses in the same join - */ - if (pRight.pOn != null && pRight.pUsing != null) { - sqlite3ErrorMsg(pParse, "cannot have both ON and USING " + - "clauses in the same join"); - return 1; - } - - /* Add the ON clause to the end of the WHERE clause, connected by - ** an AND operator. - */ - if (pRight.pOn != null) { - if (isOuter) - setJoinExpr(pRight.pOn, pRight.iCursor); - p.pWhere = sqlite3ExprAnd(pParse.db, p.pWhere, pRight.pOn); - pRight.pOn = null; - } - - /* Create extra terms on the WHERE clause for each column named - ** in the USING clause. Example: If the two tables to be joined are - ** A and B and the USING clause names X, Y, and Z, then add this - ** to the WHERE clause: A.X=B.X AND A.Y=B.Y AND A.Z=B.Z - ** Report an error if any column mentioned in the USING clause is - ** not contained in both tables to be joined. - */ - if (pRight.pUsing != null) { - IdList pList = pRight.pUsing; - for (j = 0; j < pList.nId; j++) { - string zName; /* Name of the term in the USING clause */ - int iLeft = 0; /* Table on the left with matching column name */ - int iLeftCol = 0; /* Column number of matching column on the left */ - int iRightCol; /* Column number of matching column on the right */ - - zName = pList.a[j].zName; - iRightCol = columnIndex(pRightTab, zName); - if (iRightCol < 0 - || 0 == tableAndColumnIndex(pSrc, i + 1, zName, ref iLeft, ref iLeftCol) - ) { - sqlite3ErrorMsg(pParse, "cannot join using column %s - column " + - "not present in both tables", zName); - return 1; - } - addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i + 1, iRightCol, - isOuter ? 1 : 0, ref p.pWhere); - } - } - } - return 0; + if ( pRight.pOn != null && pRight.pUsing != null ) + { + sqlite3ErrorMsg( pParse, "cannot have both ON and USING " + + "clauses in the same join" ); + return 1; } - /* - ** Insert code into "v" that will push the record on the top of the - ** stack into the sorter. + /* Add the ON clause to the end of the WHERE clause, connected by + ** an AND operator. */ - static void pushOntoSorter( - Parse pParse, /* Parser context */ - ExprList pOrderBy, /* The ORDER BY clause */ - Select pSelect, /* The whole SELECT statement */ - int regData /* Register holding data to be sorted */ - ) { - Vdbe v = pParse.pVdbe; - int nExpr = pOrderBy.nExpr; - int regBase = sqlite3GetTempRange(pParse, nExpr + 2); - int regRecord = sqlite3GetTempReg(pParse); - sqlite3ExprCacheClear(pParse); - sqlite3ExprCodeExprList(pParse, pOrderBy, regBase, false); - sqlite3VdbeAddOp2(v, OP_Sequence, pOrderBy.iECursor, regBase + nExpr); - sqlite3ExprCodeMove(pParse, regData, regBase + nExpr + 1, 1); - sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nExpr + 2, regRecord); - sqlite3VdbeAddOp2(v, OP_IdxInsert, pOrderBy.iECursor, regRecord); - sqlite3ReleaseTempReg(pParse, regRecord); - sqlite3ReleaseTempRange(pParse, regBase, nExpr + 2); - if (pSelect.iLimit != 0) { - int addr1, addr2; - int iLimit; - if (pSelect.iOffset != 0) { - iLimit = pSelect.iOffset + 1; - } else { - iLimit = pSelect.iLimit; - } - addr1 = sqlite3VdbeAddOp1(v, OP_IfZero, iLimit); - sqlite3VdbeAddOp2(v, OP_AddImm, iLimit, -1); - addr2 = sqlite3VdbeAddOp0(v, OP_Goto); - sqlite3VdbeJumpHere(v, addr1); - sqlite3VdbeAddOp1(v, OP_Last, pOrderBy.iECursor); - sqlite3VdbeAddOp1(v, OP_Delete, pOrderBy.iECursor); - sqlite3VdbeJumpHere(v, addr2); - } + if ( pRight.pOn != null ) + { + if ( isOuter ) + setJoinExpr( pRight.pOn, pRight.iCursor ); + p.pWhere = sqlite3ExprAnd( pParse.db, p.pWhere, pRight.pOn ); + pRight.pOn = null; } - /* - ** Add code to implement the OFFSET + /* Create extra terms on the WHERE clause for each column named + ** in the USING clause. Example: If the two tables to be joined are + ** A and B and the USING clause names X, Y, and Z, then add this + ** to the WHERE clause: A.X=B.X AND A.Y=B.Y AND A.Z=B.Z + ** Report an error if any column mentioned in the USING clause is + ** not contained in both tables to be joined. */ - static void codeOffset( - Vdbe v, /* Generate code into this VM */ - Select p, /* The SELECT statement being coded */ - int iContinue /* Jump here to skip the current record */ - ) { - if (p.iOffset != 0 && iContinue != 0) { - int addr; - sqlite3VdbeAddOp2(v, OP_AddImm, p.iOffset, -1); - addr = sqlite3VdbeAddOp1(v, OP_IfNeg, p.iOffset); - sqlite3VdbeAddOp2(v, OP_Goto, 0, iContinue); -#if SQLITE_DEBUG - VdbeComment(v, "skip OFFSET records"); -#endif - sqlite3VdbeJumpHere(v, addr); + if ( pRight.pUsing != null ) + { + IdList pList = pRight.pUsing; + for ( j = 0; j < pList.nId; j++ ) + { + string zName; /* Name of the term in the USING clause */ + int iLeft = 0; /* Table on the left with matching column name */ + int iLeftCol = 0; /* Column number of matching column on the left */ + int iRightCol; /* Column number of matching column on the right */ + + zName = pList.a[j].zName; + iRightCol = columnIndex( pRightTab, zName ); + if ( iRightCol < 0 + || 0 == tableAndColumnIndex( pSrc, i + 1, zName, ref iLeft, ref iLeftCol ) + ) + { + sqlite3ErrorMsg( pParse, "cannot join using column %s - column " + + "not present in both tables", zName ); + return 1; } + addWhereTerm( pParse, pSrc, iLeft, iLeftCol, i + 1, iRightCol, + isOuter ? 1 : 0, ref p.pWhere ); + } } + } + return 0; + } - /* - ** Add code that will check to make sure the N registers starting at iMem - ** form a distinct entry. iTab is a sorting index that holds previously - ** seen combinations of the N values. A new entry is made in iTab - ** if the current N values are new. - ** - ** A jump to addrRepeat is made and the N+1 values are popped from the - ** stack if the top N elements are not distinct. - */ - static void codeDistinct( - Parse pParse, /* Parsing and code generating context */ - int iTab, /* A sorting index used to test for distinctness */ - int addrRepeat, /* Jump to here if not distinct */ - int N, /* Number of elements */ - int iMem /* First element */ - ) { - Vdbe v; - int r1; - - v = pParse.pVdbe; - r1 = sqlite3GetTempReg(pParse); - sqlite3VdbeAddOp4Int(v, OP_Found, iTab, addrRepeat, iMem, N); - sqlite3VdbeAddOp3(v, OP_MakeRecord, iMem, N, r1); - sqlite3VdbeAddOp2(v, OP_IdxInsert, iTab, r1); - sqlite3ReleaseTempReg(pParse, r1); + /* + ** Insert code into "v" that will push the record on the top of the + ** stack into the sorter. + */ + static void pushOntoSorter( + Parse pParse, /* Parser context */ + ExprList pOrderBy, /* The ORDER BY clause */ + Select pSelect, /* The whole SELECT statement */ + int regData /* Register holding data to be sorted */ + ) + { + Vdbe v = pParse.pVdbe; + int nExpr = pOrderBy.nExpr; + int regBase = sqlite3GetTempRange( pParse, nExpr + 2 ); + int regRecord = sqlite3GetTempReg( pParse ); + sqlite3ExprCacheClear( pParse ); + sqlite3ExprCodeExprList( pParse, pOrderBy, regBase, false ); + sqlite3VdbeAddOp2( v, OP_Sequence, pOrderBy.iECursor, regBase + nExpr ); + sqlite3ExprCodeMove( pParse, regData, regBase + nExpr + 1, 1 ); + sqlite3VdbeAddOp3( v, OP_MakeRecord, regBase, nExpr + 2, regRecord ); + sqlite3VdbeAddOp2( v, OP_IdxInsert, pOrderBy.iECursor, regRecord ); + sqlite3ReleaseTempReg( pParse, regRecord ); + sqlite3ReleaseTempRange( pParse, regBase, nExpr + 2 ); + if ( pSelect.iLimit != 0 ) + { + int addr1, addr2; + int iLimit; + if ( pSelect.iOffset != 0 ) + { + iLimit = pSelect.iOffset + 1; } + else + { + iLimit = pSelect.iLimit; + } + addr1 = sqlite3VdbeAddOp1( v, OP_IfZero, iLimit ); + sqlite3VdbeAddOp2( v, OP_AddImm, iLimit, -1 ); + addr2 = sqlite3VdbeAddOp0( v, OP_Goto ); + sqlite3VdbeJumpHere( v, addr1 ); + sqlite3VdbeAddOp1( v, OP_Last, pOrderBy.iECursor ); + sqlite3VdbeAddOp1( v, OP_Delete, pOrderBy.iECursor ); + sqlite3VdbeJumpHere( v, addr2 ); + } + } -#if !SQLITE_OMIT_SUBQUERY - /* - ** Generate an error message when a SELECT is used within a subexpression - ** (example: "a IN (SELECT * FROM table)") but it has more than 1 result - ** column. We do this in a subroutine because the error used to occur - ** in multiple places. (The error only occurs in one place now, but we - ** retain the subroutine to minimize code disruption.) + /* + ** Add code to implement the OFFSET */ - static bool checkForMultiColumnSelectError( - Parse pParse, /* Parse context. */ - SelectDest pDest, /* Destination of SELECT results */ - int nExpr /* Number of result columns returned by SELECT */ - ) { - int eDest = pDest.eDest; - if (nExpr > 1 && (eDest == SRT_Mem || eDest == SRT_Set)) { - sqlite3ErrorMsg(pParse, "only a single result allowed for " + - "a SELECT that is part of an expression"); - return true; - } else { - return false; - } - } + static void codeOffset( + Vdbe v, /* Generate code into this VM */ + Select p, /* The SELECT statement being coded */ + int iContinue /* Jump here to skip the current record */ + ) + { + if ( p.iOffset != 0 && iContinue != 0 ) + { + int addr; + sqlite3VdbeAddOp2( v, OP_AddImm, p.iOffset, -1 ); + addr = sqlite3VdbeAddOp1( v, OP_IfNeg, p.iOffset ); + sqlite3VdbeAddOp2( v, OP_Goto, 0, iContinue ); +#if SQLITE_DEBUG + VdbeComment( v, "skip OFFSET records" ); #endif + sqlite3VdbeJumpHere( v, addr ); + } + } - /* - ** This routine generates the code for the inside of the inner loop - ** of a SELECT. + /* + ** Add code that will check to make sure the N registers starting at iMem + ** form a distinct entry. iTab is a sorting index that holds previously + ** seen combinations of the N values. A new entry is made in iTab + ** if the current N values are new. ** - ** If srcTab and nColumn are both zero, then the pEList expressions - ** are evaluated in order to get the data for this row. If nColumn>0 - ** then data is pulled from srcTab and pEList is used only to get the - ** datatypes for each column. + ** A jump to addrRepeat is made and the N+1 values are popped from the + ** stack if the top N elements are not distinct. */ - static void selectInnerLoop( - Parse pParse, /* The parser context */ - Select p, /* The complete select statement being coded */ - ExprList pEList, /* List of values being extracted */ - int srcTab, /* Pull data from this table */ - int nColumn, /* Number of columns in the source table */ - ExprList pOrderBy, /* If not NULL, sort results using this key */ - int distinct, /* If >=0, make sure results are distinct */ - SelectDest pDest, /* How to dispose of the results */ - int iContinue, /* Jump here to continue with next row */ - int iBreak /* Jump here to break out of the inner loop */ - ) { - Vdbe v = pParse.pVdbe; - int i; - bool hasDistinct; /* True if the DISTINCT keyword is present */ - int regResult; /* Start of memory holding result set */ - int eDest = pDest.eDest; /* How to dispose of results */ - int iParm = pDest.iParm; /* First argument to disposal method */ - int nResultCol; /* Number of result columns */ - - Debug.Assert(v != null); - if (NEVER(v == null)) - return; - Debug.Assert(pEList != null); - hasDistinct = distinct >= 0; - if (pOrderBy == null && !hasDistinct) { - codeOffset(v, p, iContinue); - } + static void codeDistinct( + Parse pParse, /* Parsing and code generating context */ + int iTab, /* A sorting index used to test for distinctness */ + int addrRepeat, /* Jump to here if not distinct */ + int N, /* Number of elements */ + int iMem /* First element */ + ) + { + Vdbe v; + int r1; + + v = pParse.pVdbe; + r1 = sqlite3GetTempReg( pParse ); + sqlite3VdbeAddOp4Int( v, OP_Found, iTab, addrRepeat, iMem, N ); + sqlite3VdbeAddOp3( v, OP_MakeRecord, iMem, N, r1 ); + sqlite3VdbeAddOp2( v, OP_IdxInsert, iTab, r1 ); + sqlite3ReleaseTempReg( pParse, r1 ); + } - /* Pull the requested columns. - */ - if (nColumn > 0) { - nResultCol = nColumn; - } else { - nResultCol = pEList.nExpr; - } - if (pDest.iMem == 0) { - pDest.iMem = pParse.nMem + 1; - pDest.nMem = nResultCol; - pParse.nMem += nResultCol; - } else { - Debug.Assert(pDest.nMem == nResultCol); - } - regResult = pDest.iMem; - if (nColumn > 0) { - for (i = 0; i < nColumn; i++) { - sqlite3VdbeAddOp3(v, OP_Column, srcTab, i, regResult + i); - } - } else if (eDest != SRT_Exists) { - /* If the destination is an EXISTS(...) expression, the actual - ** values returned by the SELECT are not required. - */ - sqlite3ExprCacheClear(pParse); - sqlite3ExprCodeExprList(pParse, pEList, regResult, eDest == SRT_Output); - } - nColumn = nResultCol; +#if !SQLITE_OMIT_SUBQUERY + /* +** Generate an error message when a SELECT is used within a subexpression +** (example: "a IN (SELECT * FROM table)") but it has more than 1 result +** column. We do this in a subroutine because the error used to occur +** in multiple places. (The error only occurs in one place now, but we +** retain the subroutine to minimize code disruption.) +*/ + static bool checkForMultiColumnSelectError( + Parse pParse, /* Parse context. */ + SelectDest pDest, /* Destination of SELECT results */ + int nExpr /* Number of result columns returned by SELECT */ + ) + { + int eDest = pDest.eDest; + if ( nExpr > 1 && ( eDest == SRT_Mem || eDest == SRT_Set ) ) + { + sqlite3ErrorMsg( pParse, "only a single result allowed for " + + "a SELECT that is part of an expression" ); + return true; + } + else + { + return false; + } + } +#endif - /* If the DISTINCT keyword was present on the SELECT statement - ** and this row has been seen before, then do not make this row - ** part of the result. - */ - if (hasDistinct) { - Debug.Assert(pEList != null); - Debug.Assert(pEList.nExpr == nColumn); - codeDistinct(pParse, distinct, iContinue, nColumn, regResult); - if (pOrderBy == null) { - codeOffset(v, p, iContinue); - } - } + /* +** This routine generates the code for the inside of the inner loop +** of a SELECT. +** +** If srcTab and nColumn are both zero, then the pEList expressions +** are evaluated in order to get the data for this row. If nColumn>0 +** then data is pulled from srcTab and pEList is used only to get the +** datatypes for each column. +*/ + static void selectInnerLoop( + Parse pParse, /* The parser context */ + Select p, /* The complete select statement being coded */ + ExprList pEList, /* List of values being extracted */ + int srcTab, /* Pull data from this table */ + int nColumn, /* Number of columns in the source table */ + ExprList pOrderBy, /* If not NULL, sort results using this key */ + int distinct, /* If >=0, make sure results are distinct */ + SelectDest pDest, /* How to dispose of the results */ + int iContinue, /* Jump here to continue with next row */ + int iBreak /* Jump here to break out of the inner loop */ + ) + { + Vdbe v = pParse.pVdbe; + int i; + bool hasDistinct; /* True if the DISTINCT keyword is present */ + int regResult; /* Start of memory holding result set */ + int eDest = pDest.eDest; /* How to dispose of results */ + int iParm = pDest.iParm; /* First argument to disposal method */ + int nResultCol; /* Number of result columns */ + + Debug.Assert( v != null ); + if ( NEVER( v == null ) ) + return; + Debug.Assert( pEList != null ); + hasDistinct = distinct >= 0; + if ( pOrderBy == null && !hasDistinct ) + { + codeOffset( v, p, iContinue ); + } + + /* Pull the requested columns. + */ + if ( nColumn > 0 ) + { + nResultCol = nColumn; + } + else + { + nResultCol = pEList.nExpr; + } + if ( pDest.iMem == 0 ) + { + pDest.iMem = pParse.nMem + 1; + pDest.nMem = nResultCol; + pParse.nMem += nResultCol; + } + else + { + Debug.Assert( pDest.nMem == nResultCol ); + } + regResult = pDest.iMem; + if ( nColumn > 0 ) + { + for ( i = 0; i < nColumn; i++ ) + { + sqlite3VdbeAddOp3( v, OP_Column, srcTab, i, regResult + i ); + } + } + else if ( eDest != SRT_Exists ) + { + /* If the destination is an EXISTS(...) expression, the actual + ** values returned by the SELECT are not required. + */ + sqlite3ExprCacheClear( pParse ); + sqlite3ExprCodeExprList( pParse, pEList, regResult, eDest == SRT_Output ); + } + nColumn = nResultCol; + + /* If the DISTINCT keyword was present on the SELECT statement + ** and this row has been seen before, then do not make this row + ** part of the result. + */ + if ( hasDistinct ) + { + Debug.Assert( pEList != null ); + Debug.Assert( pEList.nExpr == nColumn ); + codeDistinct( pParse, distinct, iContinue, nColumn, regResult ); + if ( pOrderBy == null ) + { + codeOffset( v, p, iContinue ); + } + } - switch (eDest) { - /* In this mode, write each query result to the key of the temporary - ** table iParm. - */ + switch ( eDest ) + { + /* In this mode, write each query result to the key of the temporary + ** table iParm. + */ #if !SQLITE_OMIT_COMPOUND_SELECT - case SRT_Union: { - int r1; - r1 = sqlite3GetTempReg(pParse); - sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nColumn, r1); - sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm, r1); - sqlite3ReleaseTempReg(pParse, r1); - break; - } - - /* Construct a record from the query result, but instead of - ** saving that record, use it as a key to delete elements from - ** the temporary table iParm. - */ - case SRT_Except: { - sqlite3VdbeAddOp3(v, OP_IdxDelete, iParm, regResult, nColumn); - break; - } + case SRT_Union: + { + int r1; + r1 = sqlite3GetTempReg( pParse ); + sqlite3VdbeAddOp3( v, OP_MakeRecord, regResult, nColumn, r1 ); + sqlite3VdbeAddOp2( v, OP_IdxInsert, iParm, r1 ); + sqlite3ReleaseTempReg( pParse, r1 ); + break; + } + + /* Construct a record from the query result, but instead of + ** saving that record, use it as a key to delete elements from + ** the temporary table iParm. + */ + case SRT_Except: + { + sqlite3VdbeAddOp3( v, OP_IdxDelete, iParm, regResult, nColumn ); + break; + } #endif - /* Store the result as data using a unique key. - */ - case SRT_Table: - case SRT_EphemTab: { - int r1 = sqlite3GetTempReg(pParse); - testcase(eDest == SRT_Table); - testcase(eDest == SRT_EphemTab); - sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nColumn, r1); - if (pOrderBy != null) { - pushOntoSorter(pParse, pOrderBy, p, r1); - } else { - int r2 = sqlite3GetTempReg(pParse); - sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, r2); - sqlite3VdbeAddOp3(v, OP_Insert, iParm, r1, r2); - sqlite3VdbeChangeP5(v, OPFLAG_APPEND); - sqlite3ReleaseTempReg(pParse, r2); - } - sqlite3ReleaseTempReg(pParse, r1); - break; - } + /* Store the result as data using a unique key. +*/ + case SRT_Table: + case SRT_EphemTab: + { + int r1 = sqlite3GetTempReg( pParse ); + testcase( eDest == SRT_Table ); + testcase( eDest == SRT_EphemTab ); + sqlite3VdbeAddOp3( v, OP_MakeRecord, regResult, nColumn, r1 ); + if ( pOrderBy != null ) + { + pushOntoSorter( pParse, pOrderBy, p, r1 ); + } + else + { + int r2 = sqlite3GetTempReg( pParse ); + sqlite3VdbeAddOp2( v, OP_NewRowid, iParm, r2 ); + sqlite3VdbeAddOp3( v, OP_Insert, iParm, r1, r2 ); + sqlite3VdbeChangeP5( v, OPFLAG_APPEND ); + sqlite3ReleaseTempReg( pParse, r2 ); + } + sqlite3ReleaseTempReg( pParse, r1 ); + break; + } #if !SQLITE_OMIT_SUBQUERY - /* If we are creating a set for an "expr IN (SELECT ...)" construct, - ** then there should be a single item on the stack. Write this - ** item into the set table with bogus data. - */ - case SRT_Set: { - Debug.Assert(nColumn == 1); - p.affinity = sqlite3CompareAffinity(pEList.a[0].pExpr, pDest.affinity); - if (pOrderBy != null) { - /* At first glance you would think we could optimize out the - ** ORDER BY in this case since the order of entries in the set - ** does not matter. But there might be a LIMIT clause, in which - ** case the order does matter */ - pushOntoSorter(pParse, pOrderBy, p, regResult); - } else { - int r1 = sqlite3GetTempReg(pParse); - sqlite3VdbeAddOp4(v, OP_MakeRecord, regResult, 1, r1, p.affinity, 1); - sqlite3ExprCacheAffinityChange(pParse, regResult, 1); - sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm, r1); - sqlite3ReleaseTempReg(pParse, r1); - } - break; - } - - /* If any row exist in the result set, record that fact and abort. - */ - case SRT_Exists: { - sqlite3VdbeAddOp2(v, OP_Integer, 1, iParm); - /* The LIMIT clause will terminate the loop for us */ - break; - } - - /* If this is a scalar select that is part of an expression, then - ** store the results in the appropriate memory cell and break out - ** of the scan loop. - */ - case SRT_Mem: { - Debug.Assert(nColumn == 1); - if (pOrderBy != null) { - pushOntoSorter(pParse, pOrderBy, p, regResult); - } else { - sqlite3ExprCodeMove(pParse, regResult, iParm, 1); - /* The LIMIT clause will jump out of the loop for us */ - } - break; - } -#endif // * #if !SQLITE_OMIT_SUBQUERY */ + /* If we are creating a set for an "expr IN (SELECT ...)" construct, +** then there should be a single item on the stack. Write this +** item into the set table with bogus data. +*/ + case SRT_Set: + { + Debug.Assert( nColumn == 1 ); + p.affinity = sqlite3CompareAffinity( pEList.a[0].pExpr, pDest.affinity ); + if ( pOrderBy != null ) + { + /* At first glance you would think we could optimize out the + ** ORDER BY in this case since the order of entries in the set + ** does not matter. But there might be a LIMIT clause, in which + ** case the order does matter */ + pushOntoSorter( pParse, pOrderBy, p, regResult ); + } + else + { + int r1 = sqlite3GetTempReg( pParse ); + sqlite3VdbeAddOp4( v, OP_MakeRecord, regResult, 1, r1, p.affinity, 1 ); + sqlite3ExprCacheAffinityChange( pParse, regResult, 1 ); + sqlite3VdbeAddOp2( v, OP_IdxInsert, iParm, r1 ); + sqlite3ReleaseTempReg( pParse, r1 ); + } + break; + } - /* Send the data to the callback function or to a subroutine. In the - ** case of a subroutine, the subroutine itself is responsible for - ** popping the data from the stack. + /* If any row exist in the result set, record that fact and abort. */ - case SRT_Coroutine: - case SRT_Output: { - testcase(eDest == SRT_Coroutine); - testcase(eDest == SRT_Output); - if (pOrderBy != null) { - int r1 = sqlite3GetTempReg(pParse); - sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nColumn, r1); - pushOntoSorter(pParse, pOrderBy, p, r1); - sqlite3ReleaseTempReg(pParse, r1); - } else if (eDest == SRT_Coroutine) { - sqlite3VdbeAddOp1(v, OP_Yield, pDest.iParm); - } else { - sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, nColumn); - sqlite3ExprCacheAffinityChange(pParse, regResult, nColumn); - } - break; - } - -#if !SQLITE_OMIT_TRIGGER - /* Discard the results. This is used for SELECT statements inside - ** the body of a TRIGGER. The purpose of such selects is to call - ** user-defined functions that have side effects. We do not care - ** about the actual results of the select. + case SRT_Exists: + { + sqlite3VdbeAddOp2( v, OP_Integer, 1, iParm ); + /* The LIMIT clause will terminate the loop for us */ + break; + } + + /* If this is a scalar select that is part of an expression, then + ** store the results in the appropriate memory cell and break out + ** of the scan loop. */ - default: { - Debug.Assert(eDest == SRT_Discard); - break; - } -#endif + case SRT_Mem: + { + Debug.Assert( nColumn == 1 ); + if ( pOrderBy != null ) + { + pushOntoSorter( pParse, pOrderBy, p, regResult ); + } + else + { + sqlite3ExprCodeMove( pParse, regResult, iParm, 1 ); + /* The LIMIT clause will jump out of the loop for us */ } + break; + } +#endif // * #if !SQLITE_OMIT_SUBQUERY */ - /* Jump to the end of the loop if the LIMIT is reached. Except, if - ** there is a sorter, in which case the sorter has already limited - ** the output for us. - */ - if (pOrderBy == null && p.iLimit != 0) { - sqlite3VdbeAddOp3(v, OP_IfZero, p.iLimit, iBreak, -1); + /* Send the data to the callback function or to a subroutine. In the +** case of a subroutine, the subroutine itself is responsible for +** popping the data from the stack. +*/ + case SRT_Coroutine: + case SRT_Output: + { + testcase( eDest == SRT_Coroutine ); + testcase( eDest == SRT_Output ); + if ( pOrderBy != null ) + { + int r1 = sqlite3GetTempReg( pParse ); + sqlite3VdbeAddOp3( v, OP_MakeRecord, regResult, nColumn, r1 ); + pushOntoSorter( pParse, pOrderBy, p, r1 ); + sqlite3ReleaseTempReg( pParse, r1 ); } - } + else if ( eDest == SRT_Coroutine ) + { + sqlite3VdbeAddOp1( v, OP_Yield, pDest.iParm ); + } + else + { + sqlite3VdbeAddOp2( v, OP_ResultRow, regResult, nColumn ); + sqlite3ExprCacheAffinityChange( pParse, regResult, nColumn ); + } + break; + } - /* - ** Given an expression list, generate a KeyInfo structure that records - ** the collating sequence for each expression in that expression list. - ** - ** If the ExprList is an ORDER BY or GROUP BY clause then the resulting - ** KeyInfo structure is appropriate for initializing a virtual index to - ** implement that clause. If the ExprList is the result set of a SELECT - ** then the KeyInfo structure is appropriate for initializing a virtual - ** index to implement a DISTINCT test. - ** - ** Space to hold the KeyInfo structure is obtain from malloc. The calling - ** function is responsible for seeing that this structure is eventually - ** freed. Add the KeyInfo structure to the P4 field of an opcode using - ** P4_KEYINFO_HANDOFF is the usual way of dealing with this. - */ - static KeyInfo keyInfoFromExprList(Parse pParse, ExprList pList) { - sqlite3 db = pParse.db; - int nExpr; - KeyInfo pInfo; - ExprList_item pItem; - int i; +#if !SQLITE_OMIT_TRIGGER + /* Discard the results. This is used for SELECT statements inside +** the body of a TRIGGER. The purpose of such selects is to call +** user-defined functions that have side effects. We do not care +** about the actual results of the select. +*/ + default: + { + Debug.Assert( eDest == SRT_Discard ); + break; + } +#endif + } - nExpr = pList.nExpr; - pInfo = new KeyInfo();//sqlite3DbMallocZero(db, sizeof(*pInfo) + nExpr*(CollSeq*.Length+1) ); - if (pInfo != null) { - pInfo.aSortOrder = new byte[nExpr];// pInfo.aColl[nExpr]; - pInfo.aColl = new CollSeq[nExpr]; - pInfo.nField = (u16)nExpr; - pInfo.enc = db.aDbStatic[0].pSchema.enc;// ENC(db); - pInfo.db = db; - for (i = 0; i < nExpr; i++) {//, pItem++){ - pItem = pList.a[i]; - CollSeq pColl; - pColl = sqlite3ExprCollSeq(pParse, pItem.pExpr); - if (pColl == null) { - pColl = db.pDfltColl; - } - pInfo.aColl[i] = pColl; - pInfo.aSortOrder[i] = (byte)pItem.sortOrder; - } - } - return pInfo; - } + /* Jump to the end of the loop if the LIMIT is reached. Except, if + ** there is a sorter, in which case the sorter has already limited + ** the output for us. + */ + if ( pOrderBy == null && p.iLimit != 0 ) + { + sqlite3VdbeAddOp3( v, OP_IfZero, p.iLimit, iBreak, -1 ); + } + } -#if !SQLITE_OMIT_COMPOUND_SELECT - /* - ** Name of the connection operator, used for error messages. + /* + ** Given an expression list, generate a KeyInfo structure that records + ** the collating sequence for each expression in that expression list. + ** + ** If the ExprList is an ORDER BY or GROUP BY clause then the resulting + ** KeyInfo structure is appropriate for initializing a virtual index to + ** implement that clause. If the ExprList is the result set of a SELECT + ** then the KeyInfo structure is appropriate for initializing a virtual + ** index to implement a DISTINCT test. + ** + ** Space to hold the KeyInfo structure is obtain from malloc. The calling + ** function is responsible for seeing that this structure is eventually + ** freed. Add the KeyInfo structure to the P4 field of an opcode using + ** P4_KEYINFO_HANDOFF is the usual way of dealing with this. */ - static string selectOpName(int id) { - string z; - switch (id) { - case TK_ALL: - z = "UNION ALL"; - break; - case TK_INTERSECT: - z = "INTERSECT"; - break; - case TK_EXCEPT: - z = "EXCEPT"; - break; - default: - z = "UNION"; - break; - } - return z; + static KeyInfo keyInfoFromExprList( Parse pParse, ExprList pList ) + { + sqlite3 db = pParse.db; + int nExpr; + KeyInfo pInfo; + ExprList_item pItem; + int i; + + nExpr = pList.nExpr; + pInfo = new KeyInfo();//sqlite3DbMallocZero(db, sizeof(*pInfo) + nExpr*(CollSeq*.Length+1) ); + if ( pInfo != null ) + { + pInfo.aSortOrder = new byte[nExpr];// pInfo.aColl[nExpr]; + pInfo.aColl = new CollSeq[nExpr]; + pInfo.nField = (u16)nExpr; + pInfo.enc = db.aDbStatic[0].pSchema.enc;// ENC(db); + pInfo.db = db; + for ( i = 0; i < nExpr; i++ ) + {//, pItem++){ + pItem = pList.a[i]; + CollSeq pColl; + pColl = sqlite3ExprCollSeq( pParse, pItem.pExpr ); + if ( pColl == null ) + { + pColl = db.pDfltColl; + } + pInfo.aColl[i] = pColl; + pInfo.aSortOrder[i] = (byte)pItem.sortOrder; } + } + return pInfo; + } + +#if !SQLITE_OMIT_COMPOUND_SELECT + /* +** Name of the connection operator, used for error messages. +*/ + static string selectOpName( int id ) + { + string z; + switch ( id ) + { + case TK_ALL: + z = "UNION ALL"; + break; + case TK_INTERSECT: + z = "INTERSECT"; + break; + case TK_EXCEPT: + z = "EXCEPT"; + break; + default: + z = "UNION"; + break; + } + return z; + } #endif //* SQLITE_OMIT_COMPOUND_SELECT */ #if !SQLITE_OMIT_EXPLAIN - /* - ** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function - ** is a no-op. Otherwise, it adds a single row of output to the EQP result, - ** where the caption is of the form: - ** - ** "USE TEMP B-TREE FOR xxx" - ** - ** where xxx is one of "DISTINCT", "ORDER BY" or "GROUP BY". Exactly which - ** is determined by the zUsage argument. - */ - static void explainTempTable(Parse pParse, string zUsage) { - if (pParse.explain == 2) { - Vdbe v = pParse.pVdbe; - string zMsg = sqlite3MPrintf(pParse.db, "USE TEMP B-TREE FOR %s", zUsage); - sqlite3VdbeAddOp4(v, OP_Explain, pParse.iSelectId, 0, 0, zMsg, P4_DYNAMIC); - } - } + /* +** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function +** is a no-op. Otherwise, it adds a single row of output to the EQP result, +** where the caption is of the form: +** +** "USE TEMP B-TREE FOR xxx" +** +** where xxx is one of "DISTINCT", "ORDER BY" or "GROUP BY". Exactly which +** is determined by the zUsage argument. +*/ + static void explainTempTable( Parse pParse, string zUsage ) + { + if ( pParse.explain == 2 ) + { + Vdbe v = pParse.pVdbe; + string zMsg = sqlite3MPrintf( pParse.db, "USE TEMP B-TREE FOR %s", zUsage ); + sqlite3VdbeAddOp4( v, OP_Explain, pParse.iSelectId, 0, 0, zMsg, P4_DYNAMIC ); + } + } - /* - ** Assign expression b to lvalue a. A second, no-op, version of this macro - ** is provided when SQLITE_OMIT_EXPLAIN is defined. This allows the code - ** in sqlite3Select() to assign values to structure member variables that - ** only exist if SQLITE_OMIT_EXPLAIN is not defined without polluting the - ** code with #if !directives. - */ - //# define explainSetInteger(a, b) a = b - static void explainSetInteger(ref int a, int b) { - a = b; - } - static void explainSetInteger(ref byte a, int b) { - a = (byte)b; - } +/* +** Assign expression b to lvalue a. A second, no-op, version of this macro +** is provided when SQLITE_OMIT_EXPLAIN is defined. This allows the code +** in sqlite3Select() to assign values to structure member variables that +** only exist if SQLITE_OMIT_EXPLAIN is not defined without polluting the +** code with #if !directives. +*/ +//# define explainSetInteger(a, b) a = b + static void explainSetInteger( ref int a, int b ) + { + a = b; + } + static void explainSetInteger( ref byte a, int b ) +{ + a = (byte)b; +} #else /* No-op versions of the explainXXX() functions and macros. */ //# define explainTempTable(y,z) @@ -894,37 +1000,39 @@ static void explainSetInteger(ref byte a, int b) { #endif #if !(SQLITE_OMIT_EXPLAIN) && !(SQLITE_OMIT_COMPOUND_SELECT) - /* - ** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function - ** is a no-op. Otherwise, it adds a single row of output to the EQP result, - ** where the caption is of one of the two forms: - ** - ** "COMPOSITE SUBQUERIES iSub1 and iSub2 (op)" - ** "COMPOSITE SUBQUERIES iSub1 and iSub2 USING TEMP B-TREE (op)" - ** - ** where iSub1 and iSub2 are the integers passed as the corresponding - ** function parameters, and op is the text representation of the parameter - ** of the same name. The parameter "op" must be one of TK_UNION, TK_EXCEPT, - ** TK_INTERSECT or TK_ALL. The first form is used if argument bUseTmp is - ** false, or the second form if it is true. - */ - static void explainComposite( - Parse pParse, /* Parse context */ - int op, /* One of TK_UNION, TK_EXCEPT etc. */ - int iSub1, /* Subquery id 1 */ - int iSub2, /* Subquery id 2 */ - bool bUseTmp /* True if a temp table was used */ - ) { - Debug.Assert(op == TK_UNION || op == TK_EXCEPT || op == TK_INTERSECT || op == TK_ALL); - if (pParse.explain == 2) { - Vdbe v = pParse.pVdbe; - string zMsg = sqlite3MPrintf( - pParse.db, "COMPOUND SUBQUERIES %d AND %d %s(%s)", iSub1, iSub2, - bUseTmp ? "USING TEMP B-TREE " : "", selectOpName(op) - ); - sqlite3VdbeAddOp4(v, OP_Explain, pParse.iSelectId, 0, 0, zMsg, P4_DYNAMIC); - } - } +/* + ** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function + ** is a no-op. Otherwise, it adds a single row of output to the EQP result, + ** where the caption is of one of the two forms: + ** + ** "COMPOSITE SUBQUERIES iSub1 and iSub2 (op)" + ** "COMPOSITE SUBQUERIES iSub1 and iSub2 USING TEMP B-TREE (op)" + ** + ** where iSub1 and iSub2 are the integers passed as the corresponding + ** function parameters, and op is the text representation of the parameter + ** of the same name. The parameter "op" must be one of TK_UNION, TK_EXCEPT, + ** TK_INTERSECT or TK_ALL. The first form is used if argument bUseTmp is + ** false, or the second form if it is true. + */ + static void explainComposite( + Parse pParse, /* Parse context */ + int op, /* One of TK_UNION, TK_EXCEPT etc. */ + int iSub1, /* Subquery id 1 */ + int iSub2, /* Subquery id 2 */ + bool bUseTmp /* True if a temp table was used */ + ) + { + Debug.Assert( op == TK_UNION || op == TK_EXCEPT || op == TK_INTERSECT || op == TK_ALL ); + if ( pParse.explain == 2 ) + { + Vdbe v = pParse.pVdbe; + string zMsg = sqlite3MPrintf( + pParse.db, "COMPOUND SUBQUERIES %d AND %d %s(%s)", iSub1, iSub2, + bUseTmp ? "USING TEMP B-TREE " : "", selectOpName( op ) + ); + sqlite3VdbeAddOp4( v, OP_Explain, pParse.iSelectId, 0, 0, zMsg, P4_DYNAMIC ); + } + } #else /* No-op versions of the explainXXX() functions and macros. */ @@ -933,1163 +1041,1282 @@ static void explainComposite(Parse v, int w,int x,int y,bool z) {} #endif - /* - ** If the inner loop was generated using a non-null pOrderBy argument, - ** then the results were placed in a sorter. After the loop is terminated - ** we need to run the sorter and output the results. The following - ** routine generates the code needed to do that. - */ - static void generateSortTail( - Parse pParse, /* Parsing context */ - Select p, /* The SELECT statement */ - Vdbe v, /* Generate code into this VDBE */ - int nColumn, /* Number of columns of data */ - SelectDest pDest /* Write the sorted results here */ - ) { - int addrBreak = sqlite3VdbeMakeLabel(v); /* Jump here to exit loop */ - int addrContinue = sqlite3VdbeMakeLabel(v); /* Jump here for next cycle */ - int addr; - int iTab; - int pseudoTab = 0; - ExprList pOrderBy = p.pOrderBy; - - int eDest = pDest.eDest; - int iParm = pDest.iParm; - - int regRow; - int regRowid; - - iTab = pOrderBy.iECursor; - regRow = sqlite3GetTempReg(pParse); - if (eDest == SRT_Output || eDest == SRT_Coroutine) { - pseudoTab = pParse.nTab++; - sqlite3VdbeAddOp3(v, OP_OpenPseudo, pseudoTab, regRow, nColumn); - regRowid = 0; - } else { - regRowid = sqlite3GetTempReg(pParse); - } - addr = 1 + sqlite3VdbeAddOp2(v, OP_Sort, iTab, addrBreak); - codeOffset(v, p, addrContinue); - sqlite3VdbeAddOp3(v, OP_Column, iTab, pOrderBy.nExpr + 1, regRow); - switch (eDest) { - case SRT_Table: - case SRT_EphemTab: { - testcase(eDest == SRT_Table); - testcase(eDest == SRT_EphemTab); - sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, regRowid); - sqlite3VdbeAddOp3(v, OP_Insert, iParm, regRow, regRowid); - sqlite3VdbeChangeP5(v, OPFLAG_APPEND); - break; - } + /* +** If the inner loop was generated using a non-null pOrderBy argument, +** then the results were placed in a sorter. After the loop is terminated +** we need to run the sorter and output the results. The following +** routine generates the code needed to do that. +*/ + static void generateSortTail( + Parse pParse, /* Parsing context */ + Select p, /* The SELECT statement */ + Vdbe v, /* Generate code into this VDBE */ + int nColumn, /* Number of columns of data */ + SelectDest pDest /* Write the sorted results here */ + ) + { + int addrBreak = sqlite3VdbeMakeLabel( v ); /* Jump here to exit loop */ + int addrContinue = sqlite3VdbeMakeLabel( v ); /* Jump here for next cycle */ + int addr; + int iTab; + int pseudoTab = 0; + ExprList pOrderBy = p.pOrderBy; + + int eDest = pDest.eDest; + int iParm = pDest.iParm; + + int regRow; + int regRowid; + + iTab = pOrderBy.iECursor; + regRow = sqlite3GetTempReg( pParse ); + if ( eDest == SRT_Output || eDest == SRT_Coroutine ) + { + pseudoTab = pParse.nTab++; + sqlite3VdbeAddOp3( v, OP_OpenPseudo, pseudoTab, regRow, nColumn ); + regRowid = 0; + } + else + { + regRowid = sqlite3GetTempReg( pParse ); + } + addr = 1 + sqlite3VdbeAddOp2( v, OP_Sort, iTab, addrBreak ); + codeOffset( v, p, addrContinue ); + sqlite3VdbeAddOp3( v, OP_Column, iTab, pOrderBy.nExpr + 1, regRow ); + switch ( eDest ) + { + case SRT_Table: + case SRT_EphemTab: + { + testcase( eDest == SRT_Table ); + testcase( eDest == SRT_EphemTab ); + sqlite3VdbeAddOp2( v, OP_NewRowid, iParm, regRowid ); + sqlite3VdbeAddOp3( v, OP_Insert, iParm, regRow, regRowid ); + sqlite3VdbeChangeP5( v, OPFLAG_APPEND ); + break; + } #if !SQLITE_OMIT_SUBQUERY - case SRT_Set: { - Debug.Assert(nColumn == 1); - sqlite3VdbeAddOp4(v, OP_MakeRecord, regRow, 1, regRowid, p.affinity, 1); - sqlite3ExprCacheAffinityChange(pParse, regRow, 1); - sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm, regRowid); - break; - } - case SRT_Mem: { - Debug.Assert(nColumn == 1); - sqlite3ExprCodeMove(pParse, regRow, iParm, 1); - /* The LIMIT clause will terminate the loop for us */ - break; - } + case SRT_Set: + { + Debug.Assert( nColumn == 1 ); + sqlite3VdbeAddOp4( v, OP_MakeRecord, regRow, 1, regRowid, p.affinity, 1 ); + sqlite3ExprCacheAffinityChange( pParse, regRow, 1 ); + sqlite3VdbeAddOp2( v, OP_IdxInsert, iParm, regRowid ); + break; + } + case SRT_Mem: + { + Debug.Assert( nColumn == 1 ); + sqlite3ExprCodeMove( pParse, regRow, iParm, 1 ); + /* The LIMIT clause will terminate the loop for us */ + break; + } #endif - default: { - int i; - Debug.Assert(eDest == SRT_Output || eDest == SRT_Coroutine); - testcase(eDest == SRT_Output); - testcase(eDest == SRT_Coroutine); - for (i = 0; i < nColumn; i++) { - Debug.Assert(regRow != pDest.iMem + i); - sqlite3VdbeAddOp3(v, OP_Column, pseudoTab, i, pDest.iMem + i); - if (i == 0) { - sqlite3VdbeChangeP5(v, OPFLAG_CLEARCACHE); - } - } - if (eDest == SRT_Output) { - sqlite3VdbeAddOp2(v, OP_ResultRow, pDest.iMem, nColumn); - sqlite3ExprCacheAffinityChange(pParse, pDest.iMem, nColumn); - } else { - sqlite3VdbeAddOp1(v, OP_Yield, pDest.iParm); - } - break; - } + default: + { + int i; + Debug.Assert( eDest == SRT_Output || eDest == SRT_Coroutine ); + testcase( eDest == SRT_Output ); + testcase( eDest == SRT_Coroutine ); + for ( i = 0; i < nColumn; i++ ) + { + Debug.Assert( regRow != pDest.iMem + i ); + sqlite3VdbeAddOp3( v, OP_Column, pseudoTab, i, pDest.iMem + i ); + if ( i == 0 ) + { + sqlite3VdbeChangeP5( v, OPFLAG_CLEARCACHE ); + } + } + if ( eDest == SRT_Output ) + { + sqlite3VdbeAddOp2( v, OP_ResultRow, pDest.iMem, nColumn ); + sqlite3ExprCacheAffinityChange( pParse, pDest.iMem, nColumn ); + } + else + { + sqlite3VdbeAddOp1( v, OP_Yield, pDest.iParm ); } - sqlite3ReleaseTempReg(pParse, regRow); - sqlite3ReleaseTempReg(pParse, regRowid); + break; + } + } + sqlite3ReleaseTempReg( pParse, regRow ); + sqlite3ReleaseTempReg( pParse, regRowid ); + + /* The bottom of the loop + */ + sqlite3VdbeResolveLabel( v, addrContinue ); + sqlite3VdbeAddOp2( v, OP_Next, iTab, addr ); + sqlite3VdbeResolveLabel( v, addrBreak ); + if ( eDest == SRT_Output || eDest == SRT_Coroutine ) + { + sqlite3VdbeAddOp2( v, OP_Close, pseudoTab, 0 ); + } + + } - /* The bottom of the loop + /* + ** Return a pointer to a string containing the 'declaration type' of the + ** expression pExpr. The string may be treated as static by the caller. + ** + ** 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 + ** considered a column by this function. + ** + ** SELECT col FROM tbl; + ** 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. + */ + static string columnType( + NameContext pNC, + Expr pExpr, + ref string pzOriginDb, + ref string pzOriginTab, + ref string pzOriginCol + ) + { + string zType = null; + string zOriginDb = null; + string zOriginTab = null; + string zOriginCol = null; + int j; + if ( NEVER( pExpr == null ) || pNC.pSrcList == null ) + return null; + + 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 + ** database table or a subquery. */ - sqlite3VdbeResolveLabel(v, addrContinue); - sqlite3VdbeAddOp2(v, OP_Next, iTab, addr); - sqlite3VdbeResolveLabel(v, addrBreak); - if (eDest == SRT_Output || eDest == SRT_Coroutine) { - sqlite3VdbeAddOp2(v, OP_Close, pseudoTab, 0); + Table pTab = null; /* Table structure column is extracted from */ + Select pS = null; /* Select the column is extracted from */ + int iCol = pExpr.iColumn; /* Index of column in pTab */ + testcase( pExpr.op == TK_AGG_COLUMN ); + testcase( pExpr.op == TK_COLUMN ); + while ( pNC != null && pTab == null ) + { + SrcList pTabList = pNC.pSrcList; + for ( j = 0; j < pTabList.nSrc && pTabList.a[j].iCursor != pExpr.iTable; j++ ) + ; + if ( j < pTabList.nSrc ) + { + pTab = pTabList.a[j].pTab; + pS = pTabList.a[j].pSelect; + } + else + { + pNC = pNC.pNext; + } } - } - - /* - ** Return a pointer to a string containing the 'declaration type' of the - ** expression pExpr. The string may be treated as static by the caller. - ** - ** 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 - ** considered a column by this function. - ** - ** SELECT col FROM tbl; - ** 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. - */ - static string columnType( - NameContext pNC, - Expr pExpr, - ref string pzOriginDb, - ref string pzOriginTab, - ref string pzOriginCol - ) { - string zType = null; - string zOriginDb = null; - string zOriginTab = null; - string zOriginCol = null; - int j; - if (NEVER(pExpr == null) || pNC.pSrcList == null) - return null; - - 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 - ** database table or a subquery. - */ - Table pTab = null; /* Table structure column is extracted from */ - Select pS = null; /* Select the column is extracted from */ - int iCol = pExpr.iColumn; /* Index of column in pTab */ - testcase(pExpr.op == TK_AGG_COLUMN); - testcase(pExpr.op == TK_COLUMN); - while (pNC != null && pTab == null) { - SrcList pTabList = pNC.pSrcList; - for (j = 0; j < pTabList.nSrc && pTabList.a[j].iCursor != pExpr.iTable; j++) - ; - if (j < pTabList.nSrc) { - pTab = pTabList.a[j].pTab; - pS = pTabList.a[j].pSelect; - } else { - pNC = pNC.pNext; - } - } - - if (pTab == null) { - /* At one time, code such as "SELECT new.x" within a trigger would - ** cause this condition to run. Since then, we have restructured how - ** trigger code is generated and so this condition is no longer - ** possible. However, it can still be true for statements like - ** the following: - ** - ** CREATE TABLE t1(col INTEGER); - ** SELECT (SELECT t1.col) FROM FROM t1; - ** - ** when columnType() is called on the expression "t1.col" in the - ** sub-select. In this case, set the column type to NULL, even - ** though it should really be "INTEGER". - ** - ** This is not a problem, as the column type of "t1.col" is never - ** used. When columnType() is called on the expression - ** "(SELECT t1.col)", the correct type is returned (see the TK_SELECT - ** branch below. */ - break; - } - - //Debug.Assert( pTab != null && pExpr.pTab == pTab ); - if (pS != null) { - /* The "table" is actually a sub-select or a view in the FROM clause - ** of the SELECT statement. Return the declaration type and origin - ** data for the result-set column of the sub-select. - */ - if (iCol >= 0 && ALWAYS(iCol < pS.pEList.nExpr)) { - /* If iCol is less than zero, then the expression requests the - ** rowid of the sub-select or view. This expression is legal (see - ** test case misc2.2.2) - it always evaluates to NULL. - */ - NameContext sNC = new NameContext(); - Expr p = pS.pEList.a[iCol].pExpr; - sNC.pSrcList = pS.pSrc; - sNC.pNext = pNC; - sNC.pParse = pNC.pParse; - zType = columnType(sNC, p, ref zOriginDb, ref zOriginTab, ref zOriginCol); - } - } else if (ALWAYS(pTab.pSchema)) { - /* A real table */ - Debug.Assert(pS == null); - if (iCol < 0) - iCol = pTab.iPKey; - Debug.Assert(iCol == -1 || (iCol >= 0 && iCol < pTab.nCol)); - if (iCol < 0) { - zType = "INTEGER"; - zOriginCol = "rowid"; - } else { - zType = pTab.aCol[iCol].zType; - zOriginCol = pTab.aCol[iCol].zName; - } - zOriginTab = pTab.zName; - if (pNC.pParse != null) { - int iDb = sqlite3SchemaToIndex(pNC.pParse.db, pTab.pSchema); - zOriginDb = pNC.pParse.db.aDb[iDb].zName; - } - } - break; - } -#if !SQLITE_OMIT_SUBQUERY - case TK_SELECT: { - /* The expression is a sub-select. Return the declaration type and - ** origin info for the single column in the result set of the SELECT - ** statement. - */ - NameContext sNC = new NameContext(); - Select pS = pExpr.x.pSelect; - Expr p = pS.pEList.a[0].pExpr; - Debug.Assert(ExprHasProperty(pExpr, EP_xIsSelect)); - sNC.pSrcList = pS.pSrc; - sNC.pNext = pNC; - sNC.pParse = pNC.pParse; - zType = columnType(sNC, p, ref zOriginDb, ref zOriginTab, ref zOriginCol); - break; - } -#endif + if ( pTab == null ) + { + /* At one time, code such as "SELECT new.x" within a trigger would + ** cause this condition to run. Since then, we have restructured how + ** trigger code is generated and so this condition is no longer + ** possible. However, it can still be true for statements like + ** the following: + ** + ** CREATE TABLE t1(col INTEGER); + ** SELECT (SELECT t1.col) FROM FROM t1; + ** + ** when columnType() is called on the expression "t1.col" in the + ** sub-select. In this case, set the column type to NULL, even + ** though it should really be "INTEGER". + ** + ** This is not a problem, as the column type of "t1.col" is never + ** used. When columnType() is called on the expression + ** "(SELECT t1.col)", the correct type is returned (see the TK_SELECT + ** branch below. */ + break; } - //if ( pzOriginDb != null ) + //Debug.Assert( pTab != null && pExpr.pTab == pTab ); + if ( pS != null ) { - //Debug.Assert( pzOriginTab != null && pzOriginCol != null ); - pzOriginDb = zOriginDb; - pzOriginTab = zOriginTab; - pzOriginCol = zOriginCol; + /* The "table" is actually a sub-select or a view in the FROM clause + ** of the SELECT statement. Return the declaration type and origin + ** data for the result-set column of the sub-select. + */ + if ( iCol >= 0 && ALWAYS( iCol < pS.pEList.nExpr ) ) + { + /* If iCol is less than zero, then the expression requests the + ** rowid of the sub-select or view. This expression is legal (see + ** test case misc2.2.2) - it always evaluates to NULL. + */ + NameContext sNC = new NameContext(); + Expr p = pS.pEList.a[iCol].pExpr; + sNC.pSrcList = pS.pSrc; + sNC.pNext = pNC; + sNC.pParse = pNC.pParse; + zType = columnType( sNC, p, ref zOriginDb, ref zOriginTab, ref zOriginCol ); + } } - return zType; - } + else if ( ALWAYS( pTab.pSchema ) ) + { + /* A real table */ + Debug.Assert( pS == null ); + if ( iCol < 0 ) + iCol = pTab.iPKey; + Debug.Assert( iCol == -1 || ( iCol >= 0 && iCol < pTab.nCol ) ); + if ( iCol < 0 ) + { + zType = "INTEGER"; + zOriginCol = "rowid"; + } + else + { + zType = pTab.aCol[iCol].zType; + zOriginCol = pTab.aCol[iCol].zName; + } + zOriginTab = pTab.zName; + if ( pNC.pParse != null ) + { + int iDb = sqlite3SchemaToIndex( pNC.pParse.db, pTab.pSchema ); + zOriginDb = pNC.pParse.db.aDb[iDb].zName; + } + } + break; + } +#if !SQLITE_OMIT_SUBQUERY + case TK_SELECT: + { + /* The expression is a sub-select. Return the declaration type and + ** origin info for the single column in the result set of the SELECT + ** statement. + */ + NameContext sNC = new NameContext(); + Select pS = pExpr.x.pSelect; + Expr p = pS.pEList.a[0].pExpr; + Debug.Assert( ExprHasProperty( pExpr, EP_xIsSelect ) ); + sNC.pSrcList = pS.pSrc; + sNC.pNext = pNC; + sNC.pParse = pNC.pParse; + zType = columnType( sNC, p, ref zOriginDb, ref zOriginTab, ref zOriginCol ); + break; + } +#endif + } + + //if ( pzOriginDb != null ) + { + //Debug.Assert( pzOriginTab != null && pzOriginCol != null ); + pzOriginDb = zOriginDb; + pzOriginTab = zOriginTab; + pzOriginCol = zOriginCol; + } + return zType; + } - /* - ** Generate code that will tell the VDBE the declaration types of columns - ** in the result set. - */ - static void generateColumnTypes( - Parse pParse, /* Parser context */ - SrcList pTabList, /* List of tables */ - ExprList pEList /* Expressions defining the result set */ - ) { + /* + ** Generate code that will tell the VDBE the declaration types of columns + ** in the result set. + */ + static void generateColumnTypes( + Parse pParse, /* Parser context */ + SrcList pTabList, /* List of tables */ + ExprList pEList /* Expressions defining the result set */ + ) + { #if !SQLITE_OMIT_DECLTYPE - Vdbe v = pParse.pVdbe; - int i; - NameContext sNC = new NameContext(); - sNC.pSrcList = pTabList; - sNC.pParse = pParse; - for (i = 0; i < pEList.nExpr; i++) { - Expr p = pEList.a[i].pExpr; - string zType; + Vdbe v = pParse.pVdbe; + int i; + NameContext sNC = new NameContext(); + sNC.pSrcList = pTabList; + sNC.pParse = pParse; + for ( i = 0; i < pEList.nExpr; i++ ) + { + Expr p = pEList.a[i].pExpr; + string zType; #if SQLITE_ENABLE_COLUMN_METADATA - string zOrigDb = null; - string zOrigTab = null; - string zOrigCol = null; - zType = columnType(sNC, p, ref zOrigDb, ref zOrigTab, ref 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); + string zOrigDb = null; + string zOrigTab = null; + string zOrigCol = null; + zType = columnType( sNC, p, ref zOrigDb, ref zOrigTab, ref 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 string sDummy = null; zType = columnType( sNC, p, ref sDummy, ref sDummy, ref sDummy ); #endif - sqlite3VdbeSetColName(v, i, COLNAME_DECLTYPE, zType, SQLITE_TRANSIENT); - } + sqlite3VdbeSetColName( v, i, COLNAME_DECLTYPE, zType, SQLITE_TRANSIENT ); + } #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 - ** azCol[] values in the callback. - */ - static void generateColumnNames( - Parse pParse, /* Parser context */ - SrcList pTabList, /* List of tables */ - ExprList pEList /* Expressions defining the result set */ - ) { - Vdbe v = pParse.pVdbe; - int i, j; - sqlite3 db = pParse.db; - bool fullNames; - bool shortNames; + /* + ** Generate code that will tell the VDBE the names of columns + ** in the result set. This information is used to provide the + ** azCol[] values in the callback. + */ + static void generateColumnNames( + Parse pParse, /* Parser context */ + SrcList pTabList, /* List of tables */ + ExprList pEList /* Expressions defining the result set */ + ) + { + Vdbe v = pParse.pVdbe; + int i, j; + sqlite3 db = pParse.db; + bool fullNames; + bool shortNames; #if !SQLITE_OMIT_EXPLAIN - /* If this is an EXPLAIN, skip this step */ - if (pParse.explain != 0) { - return; - } + /* If this is an EXPLAIN, skip this step */ + if ( pParse.explain != 0 ) + { + return; + } #endif - if (pParse.colNamesSet != 0 || NEVER(v == null) /*|| db.mallocFailed != 0 */ ) - return; - pParse.colNamesSet = 1; - fullNames = (db.flags & SQLITE_FullColNames) != 0; - shortNames = (db.flags & SQLITE_ShortColNames) != 0; - sqlite3VdbeSetNumCols(v, pEList.nExpr); - for (i = 0; i < pEList.nExpr; i++) { - Expr p; - p = pEList.a[i].pExpr; - if (NEVER(p == null)) - continue; - if (pEList.a[i].zName != null) { - string zName = pEList.a[i].zName; - sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_TRANSIENT); - } else if ((p.op == TK_COLUMN || p.op == TK_AGG_COLUMN) && pTabList != null) { - Table pTab; - string zCol; - int iCol = p.iColumn; - for (j = 0; ALWAYS(j < pTabList.nSrc); j++) { - if (pTabList.a[j].iCursor == p.iTable) - break; - } - Debug.Assert(j < pTabList.nSrc); - pTab = pTabList.a[j].pTab; - if (iCol < 0) - iCol = pTab.iPKey; - Debug.Assert(iCol == -1 || (iCol >= 0 && iCol < pTab.nCol)); - if (iCol < 0) { - zCol = "rowid"; - } else { - zCol = pTab.aCol[iCol].zName; - } - if (!shortNames && !fullNames) { - sqlite3VdbeSetColName(v, i, COLNAME_NAME, - pEList.a[i].zSpan, SQLITE_DYNAMIC);//sqlite3DbStrDup(db, pEList->a[i].zSpan), SQLITE_DYNAMIC); - } else if (fullNames) { - string zName; - zName = sqlite3MPrintf(db, "%s.%s", pTab.zName, zCol); - sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_DYNAMIC); - } else { - sqlite3VdbeSetColName(v, i, COLNAME_NAME, zCol, SQLITE_TRANSIENT); - } - } else { - sqlite3VdbeSetColName(v, i, COLNAME_NAME, - pEList.a[i].zSpan, SQLITE_DYNAMIC);//sqlite3DbStrDup(db, pEList->a[i].zSpan), SQLITE_DYNAMIC); - } - } - generateColumnTypes(pParse, pTabList, pEList); + if ( pParse.colNamesSet != 0 || NEVER( v == null ) /*|| db.mallocFailed != 0 */ ) + return; + pParse.colNamesSet = 1; + fullNames = ( db.flags & SQLITE_FullColNames ) != 0; + shortNames = ( db.flags & SQLITE_ShortColNames ) != 0; + sqlite3VdbeSetNumCols( v, pEList.nExpr ); + for ( i = 0; i < pEList.nExpr; i++ ) + { + Expr p; + p = pEList.a[i].pExpr; + if ( NEVER( p == null ) ) + continue; + if ( pEList.a[i].zName != null ) + { + string zName = pEList.a[i].zName; + sqlite3VdbeSetColName( v, i, COLNAME_NAME, zName, SQLITE_TRANSIENT ); + } + else if ( ( p.op == TK_COLUMN || p.op == TK_AGG_COLUMN ) && pTabList != null ) + { + Table pTab; + string zCol; + int iCol = p.iColumn; + for ( j = 0; ALWAYS( j < pTabList.nSrc ); j++ ) + { + if ( pTabList.a[j].iCursor == p.iTable ) + break; + } + Debug.Assert( j < pTabList.nSrc ); + pTab = pTabList.a[j].pTab; + if ( iCol < 0 ) + iCol = pTab.iPKey; + Debug.Assert( iCol == -1 || ( iCol >= 0 && iCol < pTab.nCol ) ); + if ( iCol < 0 ) + { + zCol = "rowid"; + } + else + { + zCol = pTab.aCol[iCol].zName; + } + if ( !shortNames && !fullNames ) + { + sqlite3VdbeSetColName( v, i, COLNAME_NAME, + pEList.a[i].zSpan, SQLITE_DYNAMIC );//sqlite3DbStrDup(db, pEList->a[i].zSpan), SQLITE_DYNAMIC); + } + else if ( fullNames ) + { + string zName; + zName = sqlite3MPrintf( db, "%s.%s", pTab.zName, zCol ); + sqlite3VdbeSetColName( v, i, COLNAME_NAME, zName, SQLITE_DYNAMIC ); + } + else + { + sqlite3VdbeSetColName( v, i, COLNAME_NAME, zCol, SQLITE_TRANSIENT ); + } + } + else + { + sqlite3VdbeSetColName( v, i, COLNAME_NAME, + pEList.a[i].zSpan, SQLITE_DYNAMIC );//sqlite3DbStrDup(db, pEList->a[i].zSpan), SQLITE_DYNAMIC); } + } + generateColumnTypes( pParse, pTabList, pEList ); + } - /* - ** Given a an expression list (which is really the list of expressions - ** that form the result set of a SELECT statement) compute appropriate - ** column names for a table that would hold the expression list. - ** - ** All column names will be unique. - ** - ** Only the column names are computed. Column.zType, Column.zColl, - ** and other fields of Column are zeroed. - ** - ** Return SQLITE_OK on success. If a memory allocation error occurs, - ** store NULL in paCol and 0 in pnCol and return SQLITE_NOMEM. + /* + ** Given a an expression list (which is really the list of expressions + ** that form the result set of a SELECT statement) compute appropriate + ** column names for a table that would hold the expression list. + ** + ** All column names will be unique. + ** + ** Only the column names are computed. Column.zType, Column.zColl, + ** and other fields of Column are zeroed. + ** + ** Return SQLITE_OK on success. If a memory allocation error occurs, + ** store NULL in paCol and 0 in pnCol and return SQLITE_NOMEM. + */ + static int selectColumnsFromExprList( + Parse pParse, /* Parsing context */ + ExprList pEList, /* Expr list from which to derive column names */ + ref int pnCol, /* Write the number of columns here */ + ref Column[] paCol /* Write the new column list here */ + ) + { + sqlite3 db = pParse.db; /* Database connection */ + int i, j; /* Loop counters */ + int cnt; /* Index added to make the name unique */ + Column[] aCol; + Column pCol; /* For looping over result columns */ + int nCol; /* Number of columns in the result set */ + Expr p; /* Expression for a single result column */ + string zName; /* Column name */ + int nName; /* Size of name in zName[] */ + + + pnCol = nCol = pEList.nExpr; + aCol = paCol = new Column[nCol];//sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol); + //if ( aCol == null ) + // return SQLITE_NOMEM; + for ( i = 0; i < nCol; i++ )//, pCol++) + { + if ( aCol[i] == null ) + aCol[i] = new Column(); + pCol = aCol[i]; + /* Get an appropriate name for the column */ - static int selectColumnsFromExprList( - Parse pParse, /* Parsing context */ - ExprList pEList, /* Expr list from which to derive column names */ - ref int pnCol, /* Write the number of columns here */ - ref Column[] paCol /* Write the new column list here */ - ) { - sqlite3 db = pParse.db; /* Database connection */ - int i, j; /* Loop counters */ - int cnt; /* Index added to make the name unique */ - Column[] aCol; - Column pCol; /* For looping over result columns */ - int nCol; /* Number of columns in the result set */ - Expr p; /* Expression for a single result column */ - string zName; /* Column name */ - int nName; /* Size of name in zName[] */ - - - pnCol = nCol = pEList.nExpr; - aCol = paCol = new Column[nCol];//sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol); - //if ( aCol == null ) - // return SQLITE_NOMEM; - for (i = 0; i < nCol; i++)//, pCol++) - { - if (aCol[i] == null) - aCol[i] = new Column(); - pCol = aCol[i]; - /* Get an appropriate name for the column - */ - p = pEList.a[i].pExpr; - Debug.Assert(p.pRight == null || ExprHasProperty(p.pRight, EP_IntValue) - || p.pRight.u.zToken == null || p.pRight.u.zToken.Length > 0); - if (pEList.a[i].zName != null && (zName = pEList.a[i].zName) != "") { - /* If the column contains an "AS " phrase, use as the name */ - //zName = sqlite3DbStrDup(db, zName); - } else { - Expr pColExpr = p; /* The expression that is the result column name */ - Table pTab; /* Table associated with this expression */ - while (pColExpr.op == TK_DOT) - pColExpr = pColExpr.pRight; - if (pColExpr.op == TK_COLUMN && ALWAYS(pColExpr.pTab != null)) { - /* For columns use the column name name */ - int iCol = pColExpr.iColumn; - pTab = pColExpr.pTab; - if (iCol < 0) - iCol = pTab.iPKey; - zName = sqlite3MPrintf(db, "%s", - iCol >= 0 ? pTab.aCol[iCol].zName : "rowid"); - } else if (pColExpr.op == TK_ID) { - Debug.Assert(!ExprHasProperty(pColExpr, EP_IntValue)); - zName = sqlite3MPrintf(db, "%s", pColExpr.u.zToken); - } else { - /* Use the original text of the column expression as its name */ - zName = sqlite3MPrintf(db, "%s", pEList.a[i].zSpan); - } - } - //if ( db.mallocFailed != 0 ) - //{ - // sqlite3DbFree( db, ref zName ); - // break; - //} - - /* Make sure the column name is unique. If the name is not unique, - ** append a integer to the name so that it becomes unique. - */ - nName = sqlite3Strlen30(zName); - for (j = cnt = 0; j < i; j++) { - if (aCol[j].zName.Equals(zName, StringComparison.OrdinalIgnoreCase)) { - string zNewName; - //zName[nName] = 0; - zNewName = sqlite3MPrintf(db, "%s:%d", zName.Substring(0, nName), ++cnt); - sqlite3DbFree(db, ref zName); - zName = zNewName; - j = -1; - if (zName == "") - break; - } - } - pCol.zName = zName; - } - //if ( db.mallocFailed != 0 ) - //{ - // for ( j = 0 ; j < i ; j++ ) - // { - // sqlite3DbFree( db, aCol[j].zName ); - // } - // sqlite3DbFree( db, aCol ); - // paCol = null; - // pnCol = 0; - // return SQLITE_NOMEM; - //} - return SQLITE_OK; + p = pEList.a[i].pExpr; + Debug.Assert( p.pRight == null || ExprHasProperty( p.pRight, EP_IntValue ) + || p.pRight.u.zToken == null || p.pRight.u.zToken.Length > 0 ); + if ( pEList.a[i].zName != null && ( zName = pEList.a[i].zName ) != "" ) + { + /* If the column contains an "AS " phrase, use as the name */ + //zName = sqlite3DbStrDup(db, zName); } - - /* - ** Add type and collation information to a column list based on - ** a SELECT statement. - ** - ** The column list presumably came from selectColumnNamesFromExprList(). - ** The column list has only names, not types or collations. This - ** routine goes through and adds the types and collations. - ** - ** This routine requires that all identifiers in the SELECT - ** statement be resolved. + else + { + Expr pColExpr = p; /* The expression that is the result column name */ + Table pTab; /* Table associated with this expression */ + while ( pColExpr.op == TK_DOT ) + pColExpr = pColExpr.pRight; + if ( pColExpr.op == TK_COLUMN && ALWAYS( pColExpr.pTab != null ) ) + { + /* For columns use the column name name */ + int iCol = pColExpr.iColumn; + pTab = pColExpr.pTab; + if ( iCol < 0 ) + iCol = pTab.iPKey; + zName = sqlite3MPrintf( db, "%s", + iCol >= 0 ? pTab.aCol[iCol].zName : "rowid" ); + } + else if ( pColExpr.op == TK_ID ) + { + Debug.Assert( !ExprHasProperty( pColExpr, EP_IntValue ) ); + zName = sqlite3MPrintf( db, "%s", pColExpr.u.zToken ); + } + else + { + /* Use the original text of the column expression as its name */ + zName = sqlite3MPrintf( db, "%s", pEList.a[i].zSpan ); + } + } + //if ( db.mallocFailed != 0 ) + //{ + // sqlite3DbFree( db, ref zName ); + // break; + //} + + /* Make sure the column name is unique. If the name is not unique, + ** append a integer to the name so that it becomes unique. */ - static void selectAddColumnTypeAndCollation( - Parse pParse, /* Parsing contexts */ - 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; - ExprList_item[] a; - - Debug.Assert(pSelect != null); - Debug.Assert((pSelect.selFlags & SF_Resolved) != 0); - Debug.Assert(nCol == pSelect.pEList.nExpr /*|| db.mallocFailed != 0 */ ); - // if ( db.mallocFailed != 0 ) return; - sNC = new NameContext();// memset( &sNC, 0, sizeof( sNC ) ); - sNC.pSrcList = pSelect.pSrc; - a = pSelect.pEList.a; - for (i = 0; i < nCol; i++)//, pCol++ ) - { - pCol = aCol[i]; - p = a[i].pExpr; - string bDummy = null; - pCol.zType = columnType(sNC, p, ref bDummy, ref bDummy, ref bDummy);// 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 != null) { - pCol.zColl = pColl.zName;// sqlite3DbStrDup( db, pColl.zName ); - } - } + nName = sqlite3Strlen30( zName ); + for ( j = cnt = 0; j < i; j++ ) + { + if ( aCol[j].zName.Equals( zName, StringComparison.OrdinalIgnoreCase ) ) + { + string zNewName; + //zName[nName] = 0; + zNewName = sqlite3MPrintf( db, "%s:%d", zName.Substring( 0, nName ), ++cnt ); + sqlite3DbFree( db, ref zName ); + zName = zNewName; + j = -1; + if ( zName == "" ) + break; + } } + pCol.zName = zName; + } + //if ( db.mallocFailed != 0 ) + //{ + // for ( j = 0 ; j < i ; j++ ) + // { + // sqlite3DbFree( db, aCol[j].zName ); + // } + // sqlite3DbFree( db, aCol ); + // paCol = null; + // pnCol = 0; + // return SQLITE_NOMEM; + //} + return SQLITE_OK; + } - /* - ** Given a SELECT statement, generate a Table structure that describes - ** the result set of that SELECT. - */ - static Table sqlite3ResultSetOfSelect(Parse pParse, Select pSelect) { - Table pTab; - sqlite3 db = pParse.db; - int savedFlags; - - savedFlags = db.flags; - db.flags &= ~SQLITE_FullColNames; - db.flags |= SQLITE_ShortColNames; - sqlite3SelectPrep(pParse, pSelect, null); - if (pParse.nErr != 0) - return null; - while (pSelect.pPrior != null) - pSelect = pSelect.pPrior; - db.flags = savedFlags; - pTab = new Table();// sqlite3DbMallocZero( db, sizeof( Table ) ); - if (pTab == null) { - return null; - } - /* The sqlite3ResultSetOfSelect() is only used n contexts where lookaside - ** is disabled */ - Debug.Assert(db.lookaside.bEnabled == 0); - pTab.nRef = 1; - pTab.zName = null; - pTab.nRowEst = 1000000; - selectColumnsFromExprList(pParse, pSelect.pEList, ref pTab.nCol, ref pTab.aCol); - selectAddColumnTypeAndCollation(pParse, pTab.nCol, pTab.aCol, pSelect); - pTab.iPKey = -1; - //if ( db.mallocFailed != 0 ) - //{ - // sqlite3DeleteTable(db, ref pTab ); - // return null; - //} - return pTab; + /* + ** Add type and collation information to a column list based on + ** a SELECT statement. + ** + ** The column list presumably came from selectColumnNamesFromExprList(). + ** The column list has only names, not types or collations. This + ** routine goes through and adds the types and collations. + ** + ** This routine requires that all identifiers in the SELECT + ** statement be resolved. + */ + static void selectAddColumnTypeAndCollation( + Parse pParse, /* Parsing contexts */ + 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; + ExprList_item[] a; + + Debug.Assert( pSelect != null ); + Debug.Assert( ( pSelect.selFlags & SF_Resolved ) != 0 ); + Debug.Assert( nCol == pSelect.pEList.nExpr /*|| db.mallocFailed != 0 */ ); + // if ( db.mallocFailed != 0 ) return; + sNC = new NameContext();// memset( &sNC, 0, sizeof( sNC ) ); + sNC.pSrcList = pSelect.pSrc; + a = pSelect.pEList.a; + for ( i = 0; i < nCol; i++ )//, pCol++ ) + { + pCol = aCol[i]; + p = a[i].pExpr; + string bDummy = null; + pCol.zType = columnType( sNC, p, ref bDummy, ref bDummy, ref bDummy );// 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 != null ) + { + pCol.zColl = pColl.zName;// sqlite3DbStrDup( db, pColl.zName ); } + } + } - /* - ** Get a VDBE for the given parser context. Create a new one if necessary. - ** If an error occurs, return NULL and leave a message in pParse. - */ - static Vdbe sqlite3GetVdbe(Parse pParse) { - Vdbe v = pParse.pVdbe; - if (v == null) { - v = pParse.pVdbe = sqlite3VdbeCreate(pParse.db); + /* + ** Given a SELECT statement, generate a Table structure that describes + ** the result set of that SELECT. + */ + static Table sqlite3ResultSetOfSelect( Parse pParse, Select pSelect ) + { + Table pTab; + sqlite3 db = pParse.db; + int savedFlags; + + savedFlags = db.flags; + db.flags &= ~SQLITE_FullColNames; + db.flags |= SQLITE_ShortColNames; + sqlite3SelectPrep( pParse, pSelect, null ); + if ( pParse.nErr != 0 ) + return null; + while ( pSelect.pPrior != null ) + pSelect = pSelect.pPrior; + db.flags = savedFlags; + pTab = new Table();// sqlite3DbMallocZero( db, sizeof( Table ) ); + if ( pTab == null ) + { + return null; + } + /* The sqlite3ResultSetOfSelect() is only used n contexts where lookaside + ** is disabled */ + Debug.Assert( db.lookaside.bEnabled == 0 ); + pTab.nRef = 1; + pTab.zName = null; + pTab.nRowEst = 1000000; + selectColumnsFromExprList( pParse, pSelect.pEList, ref pTab.nCol, ref pTab.aCol ); + selectAddColumnTypeAndCollation( pParse, pTab.nCol, pTab.aCol, pSelect ); + pTab.iPKey = -1; + //if ( db.mallocFailed != 0 ) + //{ + // sqlite3DeleteTable(db, ref pTab ); + // return null; + //} + return pTab; + } + + /* + ** Get a VDBE for the given parser context. Create a new one if necessary. + ** If an error occurs, return NULL and leave a message in pParse. + */ + static Vdbe sqlite3GetVdbe( Parse pParse ) + { + Vdbe v = pParse.pVdbe; + if ( v == null ) + { + v = pParse.pVdbe = sqlite3VdbeCreate( pParse.db ); #if !SQLITE_OMIT_TRACE - if (v != null) { - sqlite3VdbeAddOp0(v, OP_Trace); - } -#endif - } - return v; + if ( v != null ) + { + sqlite3VdbeAddOp0( v, OP_Trace ); } +#endif + } + return v; + } - /* - ** Compute the iLimit and iOffset fields of the SELECT based on the - ** pLimit and pOffset expressions. pLimit and pOffset hold the expressions - ** that appear in the original SQL statement after the LIMIT and OFFSET - ** keywords. Or NULL if those keywords are omitted. iLimit and iOffset - ** are the integer memory register numbers for counters used to compute - ** the limit and offset. If there is no limit and/or offset, then - ** iLimit and iOffset are negative. - ** - ** This routine changes the values of iLimit and iOffset only if - ** a limit or offset is defined by pLimit and pOffset. iLimit and - ** iOffset should have been preset to appropriate default values - ** (usually but not always -1) prior to calling this routine. - ** Only if pLimit!=0 or pOffset!=0 do the limit registers get - ** redefined. The UNION ALL operator uses this property to force - ** the reuse of the same limit and offset registers across multiple - ** SELECT statements. - */ - static void computeLimitRegisters(Parse pParse, Select p, int iBreak) { - Vdbe v = null; - int iLimit = 0; - int iOffset; - int addr1, n = 0; - if (p.iLimit != 0) - return; - - /* - ** "LIMIT -1" always shows all rows. There is some - ** contraversy about what the correct behavior should be. - ** The current implementation interprets "LIMIT 0" to mean - ** no rows. - */ - sqlite3ExprCacheClear(pParse); - Debug.Assert(p.pOffset == null || p.pLimit != null); - if (p.pLimit != null) { - p.iLimit = iLimit = ++pParse.nMem; - v = sqlite3GetVdbe(pParse); - if (NEVER(v == null)) - return; /* VDBE should have already been allocated */ - if (sqlite3ExprIsInteger(p.pLimit, ref n) != 0) { - sqlite3VdbeAddOp2(v, OP_Integer, n, iLimit); - VdbeComment(v, "LIMIT counter"); - if (n == 0) { - sqlite3VdbeAddOp2(v, OP_Goto, 0, iBreak); - } else { - if (p.nSelectRow > (double)n) - p.nSelectRow = (double)n; - } - } else { - sqlite3ExprCode(pParse, p.pLimit, iLimit); - sqlite3VdbeAddOp1(v, OP_MustBeInt, iLimit); + /* + ** Compute the iLimit and iOffset fields of the SELECT based on the + ** pLimit and pOffset expressions. pLimit and pOffset hold the expressions + ** that appear in the original SQL statement after the LIMIT and OFFSET + ** keywords. Or NULL if those keywords are omitted. iLimit and iOffset + ** are the integer memory register numbers for counters used to compute + ** the limit and offset. If there is no limit and/or offset, then + ** iLimit and iOffset are negative. + ** + ** This routine changes the values of iLimit and iOffset only if + ** a limit or offset is defined by pLimit and pOffset. iLimit and + ** iOffset should have been preset to appropriate default values + ** (usually but not always -1) prior to calling this routine. + ** Only if pLimit!=0 or pOffset!=0 do the limit registers get + ** redefined. The UNION ALL operator uses this property to force + ** the reuse of the same limit and offset registers across multiple + ** SELECT statements. + */ + static void computeLimitRegisters( Parse pParse, Select p, int iBreak ) + { + Vdbe v = null; + int iLimit = 0; + int iOffset; + int addr1, n = 0; + if ( p.iLimit != 0 ) + return; + + /* + ** "LIMIT -1" always shows all rows. There is some + ** contraversy about what the correct behavior should be. + ** The current implementation interprets "LIMIT 0" to mean + ** no rows. + */ + sqlite3ExprCacheClear( pParse ); + Debug.Assert( p.pOffset == null || p.pLimit != null ); + if ( p.pLimit != null ) + { + p.iLimit = iLimit = ++pParse.nMem; + v = sqlite3GetVdbe( pParse ); + if ( NEVER( v == null ) ) + return; /* VDBE should have already been allocated */ + if ( sqlite3ExprIsInteger( p.pLimit, ref n ) != 0 ) + { + sqlite3VdbeAddOp2( v, OP_Integer, n, iLimit ); + VdbeComment( v, "LIMIT counter" ); + if ( n == 0 ) + { + sqlite3VdbeAddOp2( v, OP_Goto, 0, iBreak ); + } + else + { + if ( p.nSelectRow > (double)n ) + p.nSelectRow = (double)n; + } + } + else + { + sqlite3ExprCode( pParse, p.pLimit, iLimit ); + sqlite3VdbeAddOp1( v, OP_MustBeInt, iLimit ); #if SQLITE_DEBUG - VdbeComment(v, "LIMIT counter"); + VdbeComment( v, "LIMIT counter" ); #endif - sqlite3VdbeAddOp2(v, OP_IfZero, iLimit, iBreak); - } - if (p.pOffset != null) { - p.iOffset = iOffset = ++pParse.nMem; - pParse.nMem++; /* Allocate an extra register for limit+offset */ - sqlite3ExprCode(pParse, p.pOffset, iOffset); - sqlite3VdbeAddOp1(v, OP_MustBeInt, iOffset); + sqlite3VdbeAddOp2( v, OP_IfZero, iLimit, iBreak ); + } + if ( p.pOffset != null ) + { + p.iOffset = iOffset = ++pParse.nMem; + pParse.nMem++; /* Allocate an extra register for limit+offset */ + sqlite3ExprCode( pParse, p.pOffset, iOffset ); + sqlite3VdbeAddOp1( v, OP_MustBeInt, iOffset ); #if SQLITE_DEBUG - VdbeComment(v, "OFFSET counter"); + VdbeComment( v, "OFFSET counter" ); #endif - addr1 = sqlite3VdbeAddOp1(v, OP_IfPos, iOffset); - sqlite3VdbeAddOp2(v, OP_Integer, 0, iOffset); - sqlite3VdbeJumpHere(v, addr1); - sqlite3VdbeAddOp3(v, OP_Add, iLimit, iOffset, iOffset + 1); + addr1 = sqlite3VdbeAddOp1( v, OP_IfPos, iOffset ); + sqlite3VdbeAddOp2( v, OP_Integer, 0, iOffset ); + sqlite3VdbeJumpHere( v, addr1 ); + sqlite3VdbeAddOp3( v, OP_Add, iLimit, iOffset, iOffset + 1 ); #if SQLITE_DEBUG - VdbeComment(v, "LIMIT+OFFSET"); + VdbeComment( v, "LIMIT+OFFSET" ); #endif - addr1 = sqlite3VdbeAddOp1(v, OP_IfPos, iLimit); - sqlite3VdbeAddOp2(v, OP_Integer, -1, iOffset + 1); - sqlite3VdbeJumpHere(v, addr1); - } - } + addr1 = sqlite3VdbeAddOp1( v, OP_IfPos, iLimit ); + sqlite3VdbeAddOp2( v, OP_Integer, -1, iOffset + 1 ); + sqlite3VdbeJumpHere( v, addr1 ); } + } + } #if !SQLITE_OMIT_COMPOUND_SELECT - /* - ** Return the appropriate collating sequence for the iCol-th column of - ** the result set for the compound-select statement "p". Return NULL if - ** the column has no default collating sequence. - ** - ** The collating sequence for the compound select is taken from the - ** left-most term of the select that has a collating sequence. - */ - static CollSeq multiSelectCollSeq(Parse pParse, Select p, int iCol) { - CollSeq pRet; - if (p.pPrior != null) { - pRet = multiSelectCollSeq(pParse, p.pPrior, iCol); - } else { - pRet = null; - } - Debug.Assert(iCol >= 0); - if (pRet == null && iCol < p.pEList.nExpr) { - pRet = sqlite3ExprCollSeq(pParse, p.pEList.a[iCol].pExpr); - } - return pRet; - } + /* +** Return the appropriate collating sequence for the iCol-th column of +** the result set for the compound-select statement "p". Return NULL if +** the column has no default collating sequence. +** +** The collating sequence for the compound select is taken from the +** left-most term of the select that has a collating sequence. +*/ + static CollSeq multiSelectCollSeq( Parse pParse, Select p, int iCol ) + { + CollSeq pRet; + if ( p.pPrior != null ) + { + pRet = multiSelectCollSeq( pParse, p.pPrior, iCol ); + } + else + { + pRet = null; + } + Debug.Assert( iCol >= 0 ); + if ( pRet == null && iCol < p.pEList.nExpr ) + { + pRet = sqlite3ExprCollSeq( pParse, p.pEList.a[iCol].pExpr ); + } + return pRet; + } #endif // * SQLITE_OMIT_COMPOUND_SELECT */ - /* Forward reference */ - //static int multiSelectOrderBy( - // Parse* pParse, /* Parsing context */ - // Select* p, /* The right-most of SELECTs to be coded */ - // SelectDest* pDest /* What to do with query results */ - //); + /* Forward reference */ + //static int multiSelectOrderBy( + // Parse* pParse, /* Parsing context */ + // Select* p, /* The right-most of SELECTs to be coded */ + // SelectDest* pDest /* What to do with query results */ + //); #if !SQLITE_OMIT_COMPOUND_SELECT - /* - ** This routine is called to process a compound query form from - ** two or more separate queries using UNION, UNION ALL, EXCEPT, or - ** INTERSECT - ** - ** "p" points to the right-most of the two queries. the query on the - ** left is p.pPrior. The left query could also be a compound query - ** in which case this routine will be called recursively. - ** - ** The results of the total query are to be written into a destination - ** of type eDest with parameter iParm. - ** - ** Example 1: Consider a three-way compound SQL statement. - ** - ** SELECT a FROM t1 UNION SELECT b FROM t2 UNION SELECT c FROM t3 - ** - ** This statement is parsed up as follows: - ** - ** SELECT c FROM t3 - ** | - ** `----. SELECT b FROM t2 - ** | - ** `-----. SELECT a FROM t1 - ** - ** The arrows in the diagram above represent the Select.pPrior pointer. - ** So if this routine is called with p equal to the t3 query, then - ** pPrior will be the t2 query. p.op will be TK_UNION in this case. - ** - ** Notice that because of the way SQLite parses compound SELECTs, the - ** individual selects always group from left to right. - */ - static int multiSelect( - Parse pParse, /* Parsing context */ - Select p, /* The right-most of SELECTs to be coded */ - SelectDest pDest /* What to do with query results */ - ) { - int rc = SQLITE_OK; /* Success code from a subroutine */ - Select pPrior; /* Another SELECT immediately to our left */ - Vdbe v; /* Generate code to this VDBE */ - SelectDest dest = new SelectDest(); /* Alternative data destination */ - Select pDelete = null; /* Chain of simple selects to delete */ - sqlite3 db; /* Database connection */ + /* +** This routine is called to process a compound query form from +** two or more separate queries using UNION, UNION ALL, EXCEPT, or +** INTERSECT +** +** "p" points to the right-most of the two queries. the query on the +** left is p.pPrior. The left query could also be a compound query +** in which case this routine will be called recursively. +** +** The results of the total query are to be written into a destination +** of type eDest with parameter iParm. +** +** Example 1: Consider a three-way compound SQL statement. +** +** SELECT a FROM t1 UNION SELECT b FROM t2 UNION SELECT c FROM t3 +** +** This statement is parsed up as follows: +** +** SELECT c FROM t3 +** | +** `----. SELECT b FROM t2 +** | +** `-----. SELECT a FROM t1 +** +** The arrows in the diagram above represent the Select.pPrior pointer. +** So if this routine is called with p equal to the t3 query, then +** pPrior will be the t2 query. p.op will be TK_UNION in this case. +** +** Notice that because of the way SQLite parses compound SELECTs, the +** individual selects always group from left to right. +*/ + static int multiSelect( + Parse pParse, /* Parsing context */ + Select p, /* The right-most of SELECTs to be coded */ + SelectDest pDest /* What to do with query results */ + ) + { + int rc = SQLITE_OK; /* Success code from a subroutine */ + Select pPrior; /* Another SELECT immediately to our left */ + Vdbe v; /* Generate code to this VDBE */ + SelectDest dest = new SelectDest(); /* Alternative data destination */ + Select pDelete = null; /* Chain of simple selects to delete */ + sqlite3 db; /* Database connection */ #if !SQLITE_OMIT_EXPLAIN - int iSub1 = 0; /* EQP id of left-hand query */ - int iSub2 = 0; /* EQP id of right-hand query */ + int iSub1 = 0; /* EQP id of left-hand query */ + int iSub2 = 0; /* EQP id of right-hand query */ #endif - /* Make sure there is no ORDER BY or LIMIT clause on prior SELECTs. Only - ** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT. + /* Make sure there is no ORDER BY or LIMIT clause on prior SELECTs. Only +** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT. +*/ + Debug.Assert( p != null && p.pPrior != null ); /* Calling function guarantees this much */ + db = pParse.db; + pPrior = p.pPrior; + Debug.Assert( pPrior.pRightmost != pPrior ); + Debug.Assert( pPrior.pRightmost == p.pRightmost ); + dest = pDest; + if ( pPrior.pOrderBy != null ) + { + sqlite3ErrorMsg( pParse, "ORDER BY clause should come after %s not before", + selectOpName( p.op ) ); + rc = 1; + goto multi_select_end; + } + if ( pPrior.pLimit != null ) + { + sqlite3ErrorMsg( pParse, "LIMIT clause should come after %s not before", + selectOpName( p.op ) ); + rc = 1; + goto multi_select_end; + } + + v = sqlite3GetVdbe( pParse ); + Debug.Assert( v != null ); /* The VDBE already created by calling function */ + + /* Create the destination temporary table if necessary + */ + if ( dest.eDest == SRT_EphemTab ) + { + Debug.Assert( p.pEList != null ); + sqlite3VdbeAddOp2( v, OP_OpenEphemeral, dest.iParm, p.pEList.nExpr ); + sqlite3VdbeChangeP5( v, BTREE_UNORDERED ); + dest.eDest = SRT_Table; + } + + /* Make sure all SELECTs in the statement have the same number of elements + ** in their result sets. + */ + Debug.Assert( p.pEList != null && pPrior.pEList != null ); + if ( p.pEList.nExpr != pPrior.pEList.nExpr ) + { + sqlite3ErrorMsg( pParse, "SELECTs to the left and right of %s" + + " do not have the same number of result columns", selectOpName( p.op ) ); + rc = 1; + goto multi_select_end; + } + + /* Compound SELECTs that have an ORDER BY clause are handled separately. + */ + if ( p.pOrderBy != null ) + { + return multiSelectOrderBy( pParse, p, pDest ); + } + + /* Generate code for the left and right SELECT statements. */ - Debug.Assert(p != null && p.pPrior != null); /* Calling function guarantees this much */ - db = pParse.db; - pPrior = p.pPrior; - Debug.Assert(pPrior.pRightmost != pPrior); - Debug.Assert(pPrior.pRightmost == p.pRightmost); - dest = pDest; - if (pPrior.pOrderBy != null) { - sqlite3ErrorMsg(pParse, "ORDER BY clause should come after %s not before", - selectOpName(p.op)); - rc = 1; - goto multi_select_end; + switch ( p.op ) + { + case TK_ALL: + { + int addr = 0; + int nLimit = 0; + Debug.Assert( pPrior.pLimit == null ); + pPrior.pLimit = p.pLimit; + pPrior.pOffset = p.pOffset; + explainSetInteger( ref iSub1, pParse.iNextSelectId ); + rc = sqlite3Select( pParse, pPrior, ref dest ); + p.pLimit = null; + p.pOffset = null; + if ( rc != 0 ) + { + goto multi_select_end; + } + p.pPrior = null; + p.iLimit = pPrior.iLimit; + p.iOffset = pPrior.iOffset; + if ( p.iLimit != 0 ) + { + addr = sqlite3VdbeAddOp1( v, OP_IfZero, p.iLimit ); +#if SQLITE_DEBUG + VdbeComment( v, "Jump ahead if LIMIT reached" ); +#endif + } + explainSetInteger( ref iSub2, pParse.iNextSelectId ); + rc = sqlite3Select( pParse, p, ref dest ); + testcase( rc != SQLITE_OK ); + pDelete = p.pPrior; + p.pPrior = pPrior; + p.nSelectRow += pPrior.nSelectRow; + if ( pPrior.pLimit != null + && sqlite3ExprIsInteger( pPrior.pLimit, ref nLimit ) != 0 + && p.nSelectRow > (double)nLimit + ) + { + p.nSelectRow = (double)nLimit; } - if (pPrior.pLimit != null) { - sqlite3ErrorMsg(pParse, "LIMIT clause should come after %s not before", - selectOpName(p.op)); - rc = 1; - goto multi_select_end; + if ( addr != 0 ) + { + sqlite3VdbeJumpHere( v, addr ); } + break; + } + case TK_EXCEPT: + case TK_UNION: + { + int unionTab; /* VdbeCursor number of the temporary table holding result */ + u8 op = 0; /* One of the SRT_ operations to apply to self */ + int priorOp; /* The SRT_ operation to apply to prior selects */ + Expr pLimit, pOffset; /* Saved values of p.nLimit and p.nOffset */ + int addr; + SelectDest uniondest = new SelectDest(); - v = sqlite3GetVdbe(pParse); - Debug.Assert(v != null); /* The VDBE already created by calling function */ + testcase( p.op == TK_EXCEPT ); + testcase( p.op == TK_UNION ); + priorOp = SRT_Union; + if ( dest.eDest == priorOp && ALWAYS( null == p.pLimit && null == p.pOffset ) ) + { + /* We can reuse a temporary table generated by a SELECT to our + ** right. + */ + Debug.Assert( p.pRightmost != p ); /* Can only happen for leftward elements +** of a 3-way or more compound */ + Debug.Assert( p.pLimit == null ); /* Not allowed on leftward elements */ + Debug.Assert( p.pOffset == null ); /* Not allowed on leftward elements */ + unionTab = dest.iParm; + } + else + { + /* We will need to create our own temporary table to hold the + ** intermediate results. + */ + unionTab = pParse.nTab++; + Debug.Assert( p.pOrderBy == null ); + addr = sqlite3VdbeAddOp2( v, OP_OpenEphemeral, unionTab, 0 ); + Debug.Assert( p.addrOpenEphm[0] == -1 ); + p.addrOpenEphm[0] = addr; + p.pRightmost.selFlags |= SF_UsesEphemeral; + Debug.Assert( p.pEList != null ); + } - /* Create the destination temporary table if necessary + /* Code the SELECT statements to our left */ - if (dest.eDest == SRT_EphemTab) { - Debug.Assert(p.pEList != null); - sqlite3VdbeAddOp2(v, OP_OpenEphemeral, dest.iParm, p.pEList.nExpr); - sqlite3VdbeChangeP5(v, BTREE_UNORDERED); - dest.eDest = SRT_Table; + Debug.Assert( pPrior.pOrderBy == null ); + sqlite3SelectDestInit( uniondest, priorOp, unionTab ); + explainSetInteger( ref iSub1, pParse.iNextSelectId ); + rc = sqlite3Select( pParse, pPrior, ref uniondest ); + if ( rc != 0 ) + { + goto multi_select_end; } - /* Make sure all SELECTs in the statement have the same number of elements - ** in their result sets. + /* Code the current SELECT statement */ - Debug.Assert(p.pEList != null && pPrior.pEList != null); - if (p.pEList.nExpr != pPrior.pEList.nExpr) { - sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s" + - " do not have the same number of result columns", selectOpName(p.op)); - rc = 1; - goto multi_select_end; + if ( p.op == TK_EXCEPT ) + { + op = SRT_Except; + } + else + { + Debug.Assert( p.op == TK_UNION ); + op = SRT_Union; } + p.pPrior = null; + pLimit = p.pLimit; + p.pLimit = null; + pOffset = p.pOffset; + p.pOffset = null; + uniondest.eDest = op; + explainSetInteger( ref iSub2, pParse.iNextSelectId ); + rc = sqlite3Select( pParse, p, ref uniondest ); + testcase( rc != SQLITE_OK ); + /* Query flattening in sqlite3Select() might refill p.pOrderBy. + ** Be sure to delete p.pOrderBy, therefore, to avoid a memory leak. */ + sqlite3ExprListDelete( db, ref p.pOrderBy ); + pDelete = p.pPrior; + p.pPrior = pPrior; + p.pOrderBy = null; + if ( p.op == TK_UNION ) + p.nSelectRow += pPrior.nSelectRow; + sqlite3ExprDelete( db, ref p.pLimit ); + p.pLimit = pLimit; + p.pOffset = pOffset; + p.iLimit = 0; + p.iOffset = 0; - /* Compound SELECTs that have an ORDER BY clause are handled separately. + /* Convert the data in the temporary table into whatever form + ** it is that we currently need. */ - if (p.pOrderBy != null) { - return multiSelectOrderBy(pParse, p, pDest); + Debug.Assert( unionTab == dest.iParm || dest.eDest != priorOp ); + if ( dest.eDest != priorOp ) + { + int iCont, iBreak, iStart; + Debug.Assert( p.pEList != null ); + if ( dest.eDest == SRT_Output ) + { + Select pFirst = p; + while ( pFirst.pPrior != null ) + pFirst = pFirst.pPrior; + generateColumnNames( pParse, null, pFirst.pEList ); + } + iBreak = sqlite3VdbeMakeLabel( v ); + iCont = sqlite3VdbeMakeLabel( v ); + computeLimitRegisters( pParse, p, iBreak ); + sqlite3VdbeAddOp2( v, OP_Rewind, unionTab, iBreak ); + iStart = sqlite3VdbeCurrentAddr( v ); + selectInnerLoop( pParse, p, p.pEList, unionTab, p.pEList.nExpr, + null, -1, dest, iCont, iBreak ); + sqlite3VdbeResolveLabel( v, iCont ); + sqlite3VdbeAddOp2( v, OP_Next, unionTab, iStart ); + sqlite3VdbeResolveLabel( v, iBreak ); + sqlite3VdbeAddOp2( v, OP_Close, unionTab, 0 ); } + break; + } + default: + Debug.Assert( p.op == TK_INTERSECT ); + { + int tab1, tab2; + int iCont, iBreak, iStart; + Expr pLimit, pOffset; + int addr; + SelectDest intersectdest = new SelectDest(); + int r1; - /* Generate code for the left and right SELECT statements. + /* INTERSECT is different from the others since it requires + ** two temporary tables. Hence it has its own case. Begin + ** by allocating the tables we will need. */ - switch (p.op) { - case TK_ALL: { - int addr = 0; - int nLimit = 0; - Debug.Assert(pPrior.pLimit == null); - pPrior.pLimit = p.pLimit; - pPrior.pOffset = p.pOffset; - explainSetInteger(ref iSub1, pParse.iNextSelectId); - rc = sqlite3Select(pParse, pPrior, ref dest); - p.pLimit = null; - p.pOffset = null; - if (rc != 0) { - goto multi_select_end; - } - p.pPrior = null; - p.iLimit = pPrior.iLimit; - p.iOffset = pPrior.iOffset; - if (p.iLimit != 0) { - addr = sqlite3VdbeAddOp1(v, OP_IfZero, p.iLimit); -#if SQLITE_DEBUG - VdbeComment(v, "Jump ahead if LIMIT reached"); -#endif - } - explainSetInteger(ref iSub2, pParse.iNextSelectId); - rc = sqlite3Select(pParse, p, ref dest); - testcase(rc != SQLITE_OK); - pDelete = p.pPrior; - p.pPrior = pPrior; - p.nSelectRow += pPrior.nSelectRow; - if (pPrior.pLimit != null - && sqlite3ExprIsInteger(pPrior.pLimit, ref nLimit) != 0 - && p.nSelectRow > (double)nLimit - ) { - p.nSelectRow = (double)nLimit; - } - if (addr != 0) { - sqlite3VdbeJumpHere(v, addr); - } - break; - } - case TK_EXCEPT: - case TK_UNION: { - int unionTab; /* VdbeCursor number of the temporary table holding result */ - u8 op = 0; /* One of the SRT_ operations to apply to self */ - int priorOp; /* The SRT_ operation to apply to prior selects */ - Expr pLimit, pOffset; /* Saved values of p.nLimit and p.nOffset */ - int addr; - SelectDest uniondest = new SelectDest(); - - testcase(p.op == TK_EXCEPT); - testcase(p.op == TK_UNION); - priorOp = SRT_Union; - if (dest.eDest == priorOp && ALWAYS(null == p.pLimit && null == p.pOffset)) { - /* We can reuse a temporary table generated by a SELECT to our - ** right. - */ - Debug.Assert(p.pRightmost != p); /* Can only happen for leftward elements -** of a 3-way or more compound */ - Debug.Assert(p.pLimit == null); /* Not allowed on leftward elements */ - Debug.Assert(p.pOffset == null); /* Not allowed on leftward elements */ - unionTab = dest.iParm; - } else { - /* We will need to create our own temporary table to hold the - ** intermediate results. - */ - unionTab = pParse.nTab++; - Debug.Assert(p.pOrderBy == null); - addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, unionTab, 0); - Debug.Assert(p.addrOpenEphm[0] == -1); - p.addrOpenEphm[0] = addr; - p.pRightmost.selFlags |= SF_UsesEphemeral; - Debug.Assert(p.pEList != null); - } - - /* Code the SELECT statements to our left - */ - Debug.Assert(pPrior.pOrderBy == null); - sqlite3SelectDestInit(uniondest, priorOp, unionTab); - explainSetInteger(ref iSub1, pParse.iNextSelectId); - rc = sqlite3Select(pParse, pPrior, ref uniondest); - if (rc != 0) { - goto multi_select_end; - } - - /* Code the current SELECT statement - */ - if (p.op == TK_EXCEPT) { - op = SRT_Except; - } else { - Debug.Assert(p.op == TK_UNION); - op = SRT_Union; - } - p.pPrior = null; - pLimit = p.pLimit; - p.pLimit = null; - pOffset = p.pOffset; - p.pOffset = null; - uniondest.eDest = op; - explainSetInteger(ref iSub2, pParse.iNextSelectId); - rc = sqlite3Select(pParse, p, ref uniondest); - testcase(rc != SQLITE_OK); - /* Query flattening in sqlite3Select() might refill p.pOrderBy. - ** Be sure to delete p.pOrderBy, therefore, to avoid a memory leak. */ - sqlite3ExprListDelete(db, ref p.pOrderBy); - pDelete = p.pPrior; - p.pPrior = pPrior; - p.pOrderBy = null; - if (p.op == TK_UNION) - p.nSelectRow += pPrior.nSelectRow; - sqlite3ExprDelete(db, ref p.pLimit); - p.pLimit = pLimit; - p.pOffset = pOffset; - p.iLimit = 0; - p.iOffset = 0; - - /* Convert the data in the temporary table into whatever form - ** it is that we currently need. - */ - Debug.Assert(unionTab == dest.iParm || dest.eDest != priorOp); - if (dest.eDest != priorOp) { - int iCont, iBreak, iStart; - Debug.Assert(p.pEList != null); - if (dest.eDest == SRT_Output) { - Select pFirst = p; - while (pFirst.pPrior != null) - pFirst = pFirst.pPrior; - generateColumnNames(pParse, null, pFirst.pEList); - } - iBreak = sqlite3VdbeMakeLabel(v); - iCont = sqlite3VdbeMakeLabel(v); - computeLimitRegisters(pParse, p, iBreak); - sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak); - iStart = sqlite3VdbeCurrentAddr(v); - selectInnerLoop(pParse, p, p.pEList, unionTab, p.pEList.nExpr, - null, -1, dest, iCont, iBreak); - sqlite3VdbeResolveLabel(v, iCont); - sqlite3VdbeAddOp2(v, OP_Next, unionTab, iStart); - sqlite3VdbeResolveLabel(v, iBreak); - sqlite3VdbeAddOp2(v, OP_Close, unionTab, 0); - } - break; - } - default: - Debug.Assert(p.op == TK_INTERSECT); { - int tab1, tab2; - int iCont, iBreak, iStart; - Expr pLimit, pOffset; - int addr; - SelectDest intersectdest = new SelectDest(); - int r1; - - /* INTERSECT is different from the others since it requires - ** two temporary tables. Hence it has its own case. Begin - ** by allocating the tables we will need. - */ - tab1 = pParse.nTab++; - tab2 = pParse.nTab++; - Debug.Assert(p.pOrderBy == null); - - addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab1, 0); - Debug.Assert(p.addrOpenEphm[0] == -1); - p.addrOpenEphm[0] = addr; - p.pRightmost.selFlags |= SF_UsesEphemeral; - Debug.Assert(p.pEList != null); - - /* Code the SELECTs to our left into temporary table "tab1". - */ - sqlite3SelectDestInit(intersectdest, SRT_Union, tab1); - explainSetInteger(ref iSub1, pParse.iNextSelectId); - rc = sqlite3Select(pParse, pPrior, ref intersectdest); - if (rc != 0) { - goto multi_select_end; - } - - /* Code the current SELECT into temporary table "tab2" - */ - addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab2, 0); - Debug.Assert(p.addrOpenEphm[1] == -1); - p.addrOpenEphm[1] = addr; - p.pPrior = null; - pLimit = p.pLimit; - p.pLimit = null; - pOffset = p.pOffset; - p.pOffset = null; - intersectdest.iParm = tab2; - explainSetInteger(ref iSub2, pParse.iNextSelectId); - rc = sqlite3Select(pParse, p, ref intersectdest); - testcase(rc != SQLITE_OK); - p.pPrior = pPrior; - if (p.nSelectRow > pPrior.nSelectRow) - p.nSelectRow = pPrior.nSelectRow; - sqlite3ExprDelete(db, ref p.pLimit); - p.pLimit = pLimit; - p.pOffset = pOffset; - - /* Generate code to take the intersection of the two temporary - ** tables. - */ - Debug.Assert(p.pEList != null); - if (dest.eDest == SRT_Output) { - Select pFirst = p; - while (pFirst.pPrior != null) - pFirst = pFirst.pPrior; - generateColumnNames(pParse, null, pFirst.pEList); - } - iBreak = sqlite3VdbeMakeLabel(v); - iCont = sqlite3VdbeMakeLabel(v); - computeLimitRegisters(pParse, p, iBreak); - sqlite3VdbeAddOp2(v, OP_Rewind, tab1, iBreak); - r1 = sqlite3GetTempReg(pParse); - iStart = sqlite3VdbeAddOp2(v, OP_RowKey, tab1, r1); - sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0); - sqlite3ReleaseTempReg(pParse, r1); - selectInnerLoop(pParse, p, p.pEList, tab1, p.pEList.nExpr, - null, -1, dest, iCont, iBreak); - sqlite3VdbeResolveLabel(v, iCont); - sqlite3VdbeAddOp2(v, OP_Next, tab1, iStart); - sqlite3VdbeResolveLabel(v, iBreak); - sqlite3VdbeAddOp2(v, OP_Close, tab2, 0); - sqlite3VdbeAddOp2(v, OP_Close, tab1, 0); - break; - } - } + tab1 = pParse.nTab++; + tab2 = pParse.nTab++; + Debug.Assert( p.pOrderBy == null ); - explainComposite(pParse, p.op, iSub1, iSub2, p.op != TK_ALL); + addr = sqlite3VdbeAddOp2( v, OP_OpenEphemeral, tab1, 0 ); + Debug.Assert( p.addrOpenEphm[0] == -1 ); + p.addrOpenEphm[0] = addr; + p.pRightmost.selFlags |= SF_UsesEphemeral; + Debug.Assert( p.pEList != null ); - /* Compute collating sequences used by - ** temporary tables needed to implement the compound select. - ** Attach the KeyInfo structure to all temporary tables. - ** - ** This section is run by the right-most SELECT statement only. - ** SELECT statements to the left always skip this part. The right-most - ** SELECT might also skip this part if it has no ORDER BY clause and - ** no temp tables are required. + /* Code the SELECTs to our left into temporary table "tab1". */ - if ((p.selFlags & SF_UsesEphemeral) != 0) { - int i; /* Loop counter */ - KeyInfo pKeyInfo; /* Collating sequence for the result set */ - Select pLoop; /* For looping through SELECT statements */ - CollSeq apColl; /* For looping through pKeyInfo.aColl[] */ - int nCol; /* Number of columns in result set */ - - Debug.Assert(p.pRightmost == p); - nCol = p.pEList.nExpr; - pKeyInfo = new KeyInfo(); //sqlite3DbMallocZero(db, - pKeyInfo.aColl = new CollSeq[nCol]; //sizeof(*pKeyInfo)+nCol*(CollSeq*.Length + 1)); - //if ( pKeyInfo == null ) - //{ - // rc = SQLITE_NOMEM; - // goto multi_select_end; - //} - - pKeyInfo.enc = db.aDbStatic[0].pSchema.enc;// ENC( pParse.db ); - pKeyInfo.nField = (u16)nCol; - - for (i = 0; i < nCol; i++) {//, apColl++){ - apColl = multiSelectCollSeq(pParse, p, i); - if (null == apColl) { - apColl = db.pDfltColl; - } - pKeyInfo.aColl[i] = apColl; - } - - for (pLoop = p; pLoop != null; pLoop = pLoop.pPrior) { - for (i = 0; i < 2; i++) { - int addr = pLoop.addrOpenEphm[i]; - if (addr < 0) { - /* If [0] is unused then [1] is also unused. So we can - ** always safely abort as soon as the first unused slot is found */ - Debug.Assert(pLoop.addrOpenEphm[1] < 0); - break; - } - sqlite3VdbeChangeP2(v, addr, nCol); - sqlite3VdbeChangeP4(v, addr, pKeyInfo, P4_KEYINFO); - pLoop.addrOpenEphm[i] = -1; - } - } - sqlite3DbFree(db, ref pKeyInfo); + sqlite3SelectDestInit( intersectdest, SRT_Union, tab1 ); + explainSetInteger( ref iSub1, pParse.iNextSelectId ); + rc = sqlite3Select( pParse, pPrior, ref intersectdest ); + if ( rc != 0 ) + { + goto multi_select_end; } - multi_select_end: - pDest.iMem = dest.iMem; - pDest.nMem = dest.nMem; - sqlite3SelectDelete(db, ref pDelete); - return rc; + /* Code the current SELECT into temporary table "tab2" + */ + addr = sqlite3VdbeAddOp2( v, OP_OpenEphemeral, tab2, 0 ); + Debug.Assert( p.addrOpenEphm[1] == -1 ); + p.addrOpenEphm[1] = addr; + p.pPrior = null; + pLimit = p.pLimit; + p.pLimit = null; + pOffset = p.pOffset; + p.pOffset = null; + intersectdest.iParm = tab2; + explainSetInteger( ref iSub2, pParse.iNextSelectId ); + rc = sqlite3Select( pParse, p, ref intersectdest ); + testcase( rc != SQLITE_OK ); + p.pPrior = pPrior; + if ( p.nSelectRow > pPrior.nSelectRow ) + p.nSelectRow = pPrior.nSelectRow; + sqlite3ExprDelete( db, ref p.pLimit ); + p.pLimit = pLimit; + p.pOffset = pOffset; + + /* Generate code to take the intersection of the two temporary + ** tables. + */ + Debug.Assert( p.pEList != null ); + if ( dest.eDest == SRT_Output ) + { + Select pFirst = p; + while ( pFirst.pPrior != null ) + pFirst = pFirst.pPrior; + generateColumnNames( pParse, null, pFirst.pEList ); + } + iBreak = sqlite3VdbeMakeLabel( v ); + iCont = sqlite3VdbeMakeLabel( v ); + computeLimitRegisters( pParse, p, iBreak ); + sqlite3VdbeAddOp2( v, OP_Rewind, tab1, iBreak ); + r1 = sqlite3GetTempReg( pParse ); + iStart = sqlite3VdbeAddOp2( v, OP_RowKey, tab1, r1 ); + sqlite3VdbeAddOp4Int( v, OP_NotFound, tab2, iCont, r1, 0 ); + sqlite3ReleaseTempReg( pParse, r1 ); + selectInnerLoop( pParse, p, p.pEList, tab1, p.pEList.nExpr, + null, -1, dest, iCont, iBreak ); + sqlite3VdbeResolveLabel( v, iCont ); + sqlite3VdbeAddOp2( v, OP_Next, tab1, iStart ); + sqlite3VdbeResolveLabel( v, iBreak ); + sqlite3VdbeAddOp2( v, OP_Close, tab2, 0 ); + sqlite3VdbeAddOp2( v, OP_Close, tab1, 0 ); + break; + } + } + + explainComposite( pParse, p.op, iSub1, iSub2, p.op != TK_ALL ); + + /* Compute collating sequences used by + ** temporary tables needed to implement the compound select. + ** Attach the KeyInfo structure to all temporary tables. + ** + ** This section is run by the right-most SELECT statement only. + ** SELECT statements to the left always skip this part. The right-most + ** SELECT might also skip this part if it has no ORDER BY clause and + ** no temp tables are required. + */ + if ( ( p.selFlags & SF_UsesEphemeral ) != 0 ) + { + int i; /* Loop counter */ + KeyInfo pKeyInfo; /* Collating sequence for the result set */ + Select pLoop; /* For looping through SELECT statements */ + CollSeq apColl; /* For looping through pKeyInfo.aColl[] */ + int nCol; /* Number of columns in result set */ + + Debug.Assert( p.pRightmost == p ); + nCol = p.pEList.nExpr; + pKeyInfo = new KeyInfo(); //sqlite3DbMallocZero(db, + pKeyInfo.aColl = new CollSeq[nCol]; //sizeof(*pKeyInfo)+nCol*(CollSeq*.Length + 1)); + //if ( pKeyInfo == null ) + //{ + // rc = SQLITE_NOMEM; + // goto multi_select_end; + //} + + pKeyInfo.enc = db.aDbStatic[0].pSchema.enc;// ENC( pParse.db ); + pKeyInfo.nField = (u16)nCol; + + for ( i = 0; i < nCol; i++ ) + {//, apColl++){ + apColl = multiSelectCollSeq( pParse, p, i ); + if ( null == apColl ) + { + apColl = db.pDfltColl; + } + pKeyInfo.aColl[i] = apColl; } -#endif // * SQLITE_OMIT_COMPOUND_SELECT */ - - /* - ** Code an output subroutine for a coroutine implementation of a - ** SELECT statment. - ** - ** The data to be output is contained in pIn.iMem. There are - ** pIn.nMem columns to be output. pDest is where the output should - ** be sent. - ** - ** regReturn is the number of the register holding the subroutine - ** return address. - ** - ** If regPrev>0 then it is the first register in a vector that - ** records the previous output. mem[regPrev] is a flag that is false - ** if there has been no previous output. If regPrev>0 then code is - ** generated to suppress duplicates. pKeyInfo is used for comparing - ** keys. - ** - ** If the LIMIT found in p.iLimit is reached, jump immediately to - ** iBreak. - */ - static int generateOutputSubroutine( - Parse pParse, /* Parsing context */ - Select p, /* The SELECT statement */ - SelectDest pIn, /* Coroutine supplying data */ - SelectDest pDest, /* Where to send the data */ - int regReturn, /* The return address register */ - int regPrev, /* Previous result register. No uniqueness if 0 */ - KeyInfo pKeyInfo, /* For comparing with previous entry */ - int p4type, /* The p4 type for pKeyInfo */ - int iBreak /* Jump here if we hit the LIMIT */ - ) { - Vdbe v = pParse.pVdbe; - int iContinue; - int addr; - - addr = sqlite3VdbeCurrentAddr(v); - iContinue = sqlite3VdbeMakeLabel(v); - /* Suppress duplicates for UNION, EXCEPT, and INTERSECT - */ - if (regPrev != 0) { - int j1, j2; - j1 = sqlite3VdbeAddOp1(v, OP_IfNot, regPrev); - j2 = sqlite3VdbeAddOp4(v, OP_Compare, pIn.iMem, regPrev + 1, pIn.nMem, - pKeyInfo, p4type); - sqlite3VdbeAddOp3(v, OP_Jump, j2 + 2, iContinue, j2 + 2); - sqlite3VdbeJumpHere(v, j1); - sqlite3ExprCodeCopy(pParse, pIn.iMem, regPrev + 1, pIn.nMem); - sqlite3VdbeAddOp2(v, OP_Integer, 1, regPrev); + for ( pLoop = p; pLoop != null; pLoop = pLoop.pPrior ) + { + for ( i = 0; i < 2; i++ ) + { + int addr = pLoop.addrOpenEphm[i]; + if ( addr < 0 ) + { + /* If [0] is unused then [1] is also unused. So we can + ** always safely abort as soon as the first unused slot is found */ + Debug.Assert( pLoop.addrOpenEphm[1] < 0 ); + break; } - //if ( pParse.db.mallocFailed != 0 ) return 0; + sqlite3VdbeChangeP2( v, addr, nCol ); + sqlite3VdbeChangeP4( v, addr, pKeyInfo, P4_KEYINFO ); + pLoop.addrOpenEphm[i] = -1; + } + } + sqlite3DbFree( db, ref pKeyInfo ); + } + +multi_select_end: + pDest.iMem = dest.iMem; + pDest.nMem = dest.nMem; + sqlite3SelectDelete( db, ref pDelete ); + return rc; + } +#endif // * SQLITE_OMIT_COMPOUND_SELECT */ - /* Suppress the the first OFFSET entries if there is an OFFSET clause - */ - codeOffset(v, p, iContinue); + /* +** Code an output subroutine for a coroutine implementation of a +** SELECT statment. +** +** The data to be output is contained in pIn.iMem. There are +** pIn.nMem columns to be output. pDest is where the output should +** be sent. +** +** regReturn is the number of the register holding the subroutine +** return address. +** +** If regPrev>0 then it is the first register in a vector that +** records the previous output. mem[regPrev] is a flag that is false +** if there has been no previous output. If regPrev>0 then code is +** generated to suppress duplicates. pKeyInfo is used for comparing +** keys. +** +** If the LIMIT found in p.iLimit is reached, jump immediately to +** iBreak. +*/ + static int generateOutputSubroutine( + Parse pParse, /* Parsing context */ + Select p, /* The SELECT statement */ + SelectDest pIn, /* Coroutine supplying data */ + SelectDest pDest, /* Where to send the data */ + int regReturn, /* The return address register */ + int regPrev, /* Previous result register. No uniqueness if 0 */ + KeyInfo pKeyInfo, /* For comparing with previous entry */ + int p4type, /* The p4 type for pKeyInfo */ + int iBreak /* Jump here if we hit the LIMIT */ + ) + { + Vdbe v = pParse.pVdbe; + int iContinue; + int addr; + + addr = sqlite3VdbeCurrentAddr( v ); + iContinue = sqlite3VdbeMakeLabel( v ); + + /* Suppress duplicates for UNION, EXCEPT, and INTERSECT + */ + if ( regPrev != 0 ) + { + int j1, j2; + j1 = sqlite3VdbeAddOp1( v, OP_IfNot, regPrev ); + j2 = sqlite3VdbeAddOp4( v, OP_Compare, pIn.iMem, regPrev + 1, pIn.nMem, + pKeyInfo, p4type ); + sqlite3VdbeAddOp3( v, OP_Jump, j2 + 2, iContinue, j2 + 2 ); + sqlite3VdbeJumpHere( v, j1 ); + sqlite3ExprCodeCopy( pParse, pIn.iMem, regPrev + 1, pIn.nMem ); + sqlite3VdbeAddOp2( v, OP_Integer, 1, regPrev ); + } + //if ( pParse.db.mallocFailed != 0 ) return 0; + + /* Suppress the the first OFFSET entries if there is an OFFSET clause + */ + codeOffset( v, p, iContinue ); - switch (pDest.eDest) { - /* Store the result as data using a unique key. - */ - case SRT_Table: - case SRT_EphemTab: { - int r1 = sqlite3GetTempReg(pParse); - int r2 = sqlite3GetTempReg(pParse); - testcase(pDest.eDest == SRT_Table); - testcase(pDest.eDest == SRT_EphemTab); - sqlite3VdbeAddOp3(v, OP_MakeRecord, pIn.iMem, pIn.nMem, r1); - sqlite3VdbeAddOp2(v, OP_NewRowid, pDest.iParm, r2); - sqlite3VdbeAddOp3(v, OP_Insert, pDest.iParm, r1, r2); - sqlite3VdbeChangeP5(v, OPFLAG_APPEND); - sqlite3ReleaseTempReg(pParse, r2); - sqlite3ReleaseTempReg(pParse, r1); - break; - } + switch ( pDest.eDest ) + { + /* Store the result as data using a unique key. + */ + case SRT_Table: + case SRT_EphemTab: + { + int r1 = sqlite3GetTempReg( pParse ); + int r2 = sqlite3GetTempReg( pParse ); + testcase( pDest.eDest == SRT_Table ); + testcase( pDest.eDest == SRT_EphemTab ); + sqlite3VdbeAddOp3( v, OP_MakeRecord, pIn.iMem, pIn.nMem, r1 ); + sqlite3VdbeAddOp2( v, OP_NewRowid, pDest.iParm, r2 ); + sqlite3VdbeAddOp3( v, OP_Insert, pDest.iParm, r1, r2 ); + sqlite3VdbeChangeP5( v, OPFLAG_APPEND ); + sqlite3ReleaseTempReg( pParse, r2 ); + sqlite3ReleaseTempReg( pParse, r1 ); + break; + } #if !SQLITE_OMIT_SUBQUERY - /* If we are creating a set for an "expr IN (SELECT ...)" construct, - ** then there should be a single item on the stack. Write this - ** item into the set table with bogus data. - */ - case SRT_Set: { - int r1; - Debug.Assert(pIn.nMem == 1); - p.affinity = - sqlite3CompareAffinity(p.pEList.a[0].pExpr, pDest.affinity); - r1 = sqlite3GetTempReg(pParse); - sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn.iMem, 1, r1, p.affinity, 1); - sqlite3ExprCacheAffinityChange(pParse, pIn.iMem, 1); - sqlite3VdbeAddOp2(v, OP_IdxInsert, pDest.iParm, r1); - sqlite3ReleaseTempReg(pParse, r1); - break; - } + /* If we are creating a set for an "expr IN (SELECT ...)" construct, +** then there should be a single item on the stack. Write this +** item into the set table with bogus data. +*/ + case SRT_Set: + { + int r1; + Debug.Assert( pIn.nMem == 1 ); + p.affinity = + sqlite3CompareAffinity( p.pEList.a[0].pExpr, pDest.affinity ); + r1 = sqlite3GetTempReg( pParse ); + sqlite3VdbeAddOp4( v, OP_MakeRecord, pIn.iMem, 1, r1, p.affinity, 1 ); + sqlite3ExprCacheAffinityChange( pParse, pIn.iMem, 1 ); + sqlite3VdbeAddOp2( v, OP_IdxInsert, pDest.iParm, r1 ); + sqlite3ReleaseTempReg( pParse, r1 ); + break; + } #if FALSE //* Never occurs on an ORDER BY query */ /* If any row exist in the result set, record that fact and abort. @@ -2101,2591 +2328,2846 @@ static int generateOutputSubroutine( } #endif - /* If this is a scalar select that is part of an expression, then - ** store the results in the appropriate memory cell and break out - ** of the scan loop. - */ - case SRT_Mem: { - Debug.Assert(pIn.nMem == 1); - sqlite3ExprCodeMove(pParse, pIn.iMem, pDest.iParm, 1); - /* The LIMIT clause will jump out of the loop for us */ - break; - } + /* If this is a scalar select that is part of an expression, then +** store the results in the appropriate memory cell and break out +** of the scan loop. +*/ + case SRT_Mem: + { + Debug.Assert( pIn.nMem == 1 ); + sqlite3ExprCodeMove( pParse, pIn.iMem, pDest.iParm, 1 ); + /* The LIMIT clause will jump out of the loop for us */ + break; + } #endif //* #if !SQLITE_OMIT_SUBQUERY */ - /* The results are stored in a sequence of registers - ** starting at pDest.iMem. Then the co-routine yields. - */ - case SRT_Coroutine: { - if (pDest.iMem == 0) { - pDest.iMem = sqlite3GetTempRange(pParse, pIn.nMem); - pDest.nMem = pIn.nMem; - } - sqlite3ExprCodeMove(pParse, pIn.iMem, pDest.iMem, pDest.nMem); - sqlite3VdbeAddOp1(v, OP_Yield, pDest.iParm); - break; - } - - /* If none of the above, then the result destination must be - ** SRT_Output. This routine is never called with any other - ** destination other than the ones handled above or SRT_Output. - ** - ** For SRT_Output, results are stored in a sequence of registers. - ** Then the OP_ResultRow opcode is used to cause sqlite3_step() to - ** return the next row of result. - */ - default: { - Debug.Assert(pDest.eDest == SRT_Output); - sqlite3VdbeAddOp2(v, OP_ResultRow, pIn.iMem, pIn.nMem); - sqlite3ExprCacheAffinityChange(pParse, pIn.iMem, pIn.nMem); - break; - } - } - - /* Jump to the end of the loop if the LIMIT is reached. - */ - if (p.iLimit != 0) { - sqlite3VdbeAddOp3(v, OP_IfZero, p.iLimit, iBreak, -1); + /* The results are stored in a sequence of registers +** starting at pDest.iMem. Then the co-routine yields. +*/ + case SRT_Coroutine: + { + if ( pDest.iMem == 0 ) + { + pDest.iMem = sqlite3GetTempRange( pParse, pIn.nMem ); + pDest.nMem = pIn.nMem; } + sqlite3ExprCodeMove( pParse, pIn.iMem, pDest.iMem, pDest.nMem ); + sqlite3VdbeAddOp1( v, OP_Yield, pDest.iParm ); + break; + } + + /* If none of the above, then the result destination must be + ** SRT_Output. This routine is never called with any other + ** destination other than the ones handled above or SRT_Output. + ** + ** For SRT_Output, results are stored in a sequence of registers. + ** Then the OP_ResultRow opcode is used to cause sqlite3_step() to + ** return the next row of result. + */ + default: + { + Debug.Assert( pDest.eDest == SRT_Output ); + sqlite3VdbeAddOp2( v, OP_ResultRow, pIn.iMem, pIn.nMem ); + sqlite3ExprCacheAffinityChange( pParse, pIn.iMem, pIn.nMem ); + break; + } + } + + /* Jump to the end of the loop if the LIMIT is reached. + */ + if ( p.iLimit != 0 ) + { + sqlite3VdbeAddOp3( v, OP_IfZero, p.iLimit, iBreak, -1 ); + } - /* Generate the subroutine return - */ - sqlite3VdbeResolveLabel(v, iContinue); - sqlite3VdbeAddOp1(v, OP_Return, regReturn); + /* Generate the subroutine return + */ + sqlite3VdbeResolveLabel( v, iContinue ); + sqlite3VdbeAddOp1( v, OP_Return, regReturn ); - return addr; - } + return addr; + } - /* - ** Alternative compound select code generator for cases when there - ** is an ORDER BY clause. - ** - ** We assume a query of the following form: - ** - ** ORDER BY - ** - ** is one of UNION ALL, UNION, EXCEPT, or INTERSECT. The idea - ** is to code both and with the ORDER BY clause as - ** co-routines. Then run the co-routines in parallel and merge the results - ** into the output. In addition to the two coroutines (called selectA and - ** selectB) there are 7 subroutines: - ** - ** outA: Move the output of the selectA coroutine into the output - ** of the compound query. - ** - ** outB: Move the output of the selectB coroutine into the output - ** of the compound query. (Only generated for UNION and - ** UNION ALL. EXCEPT and INSERTSECT never output a row that - ** appears only in B.) - ** - ** AltB: Called when there is data from both coroutines and AB. - ** - ** EofA: Called when data is exhausted from selectA. - ** - ** EofB: Called when data is exhausted from selectB. - ** - ** The implementation of the latter five subroutines depend on which - ** is used: - ** - ** - ** UNION ALL UNION EXCEPT INTERSECT - ** ------------- ----------------- -------------- ----------------- - ** AltB: outA, nextA outA, nextA outA, nextA nextA - ** - ** AeqB: outA, nextA nextA nextA outA, nextA - ** - ** AgtB: outB, nextB outB, nextB nextB nextB - ** - ** EofA: outB, nextB outB, nextB halt halt - ** - ** EofB: outA, nextA outA, nextA outA, nextA halt - ** - ** In the AltB, AeqB, and AgtB subroutines, an EOF on A following nextA - ** causes an immediate jump to EofA and an EOF on B following nextB causes - ** an immediate jump to EofB. Within EofA and EofB, and EOF on entry or - ** following nextX causes a jump to the end of the select processing. - ** - ** Duplicate removal in the UNION, EXCEPT, and INTERSECT cases is handled - ** within the output subroutine. The regPrev register set holds the previously - ** output value. A comparison is made against this value and the output - ** is skipped if the next results would be the same as the previous. - ** - ** The implementation plan is to implement the two coroutines and seven - ** subroutines first, then put the control logic at the bottom. Like this: - ** - ** goto Init - ** coA: coroutine for left query (A) - ** coB: coroutine for right query (B) - ** outA: output one row of A - ** outB: output one row of B (UNION and UNION ALL only) - ** EofA: ... - ** EofB: ... - ** AltB: ... - ** AeqB: ... - ** AgtB: ... - ** Init: initialize coroutine registers - ** yield coA - ** if eof(A) goto EofA - ** yield coB - ** if eof(B) goto EofB - ** Cmpr: Compare A, B - ** Jump AltB, AeqB, AgtB - ** End: ... - ** - ** We call AltB, AeqB, AgtB, EofA, and EofB "subroutines" but they are not - ** actually called using Gosub and they do not Return. EofA and EofB loop - ** until all data is exhausted then jump to the "end" labe. AltB, AeqB, - ** and AgtB jump to either L2 or to one of EofA or EofB. - */ -#if !SQLITE_OMIT_COMPOUND_SELECT - static int multiSelectOrderBy( - Parse pParse, /* Parsing context */ - Select p, /* The right-most of SELECTs to be coded */ - SelectDest pDest /* What to do with query results */ - ) { - int i, j; /* Loop counters */ - Select pPrior; /* Another SELECT immediately to our left */ - Vdbe v; /* Generate code to this VDBE */ - SelectDest destA = new SelectDest(); /* Destination for coroutine A */ - SelectDest destB = new SelectDest(); /* Destination for coroutine B */ - int regAddrA; /* Address register for select-A coroutine */ - int regEofA; /* Flag to indicate when select-A is complete */ - int regAddrB; /* Address register for select-B coroutine */ - int regEofB; /* Flag to indicate when select-B is complete */ - int addrSelectA; /* Address of the select-A coroutine */ - int addrSelectB; /* Address of the select-B coroutine */ - int regOutA; /* Address register for the output-A subroutine */ - int regOutB; /* Address register for the output-B subroutine */ - int addrOutA; /* Address of the output-A subroutine */ - int addrOutB = 0; /* Address of the output-B subroutine */ - int addrEofA; /* Address of the select-A-exhausted subroutine */ - int addrEofB; /* Address of the select-B-exhausted subroutine */ - int addrAltB; /* Address of the AB subroutine */ - int regLimitA; /* Limit register for select-A */ - int regLimitB; /* Limit register for select-A */ - int regPrev; /* A range of registers to hold previous output */ - int savedLimit; /* Saved value of p.iLimit */ - int savedOffset; /* Saved value of p.iOffset */ - int labelCmpr; /* Label for the start of the merge algorithm */ - int labelEnd; /* Label for the end of the overall SELECT stmt */ - int j1; /* Jump instructions that get retargetted */ - int op; /* One of TK_ALL, TK_UNION, TK_EXCEPT, TK_INTERSECT */ - KeyInfo pKeyDup = null; /* Comparison information for duplicate removal */ - KeyInfo pKeyMerge; /* Comparison information for merging rows */ - sqlite3 db; /* Database connection */ - ExprList pOrderBy; /* The ORDER BY clause */ - int nOrderBy; /* Number of terms in the ORDER BY clause */ - int[] aPermute; /* Mapping from ORDER BY terms to result set columns */ -#if !SQLITE_OMIT_EXPLAIN - int iSub1 = 0; /* EQP id of left-hand query */ - int iSub2 = 0; /* EQP id of right-hand query */ -#endif - - Debug.Assert(p.pOrderBy != null); - Debug.Assert(pKeyDup == null); /* "Managed" code needs this. Ticket #3382. */ - db = pParse.db; - v = pParse.pVdbe; - Debug.Assert(v != null); /* Already thrown the error if VDBE alloc failed */ - labelEnd = sqlite3VdbeMakeLabel(v); - labelCmpr = sqlite3VdbeMakeLabel(v); - - - /* Patch up the ORDER BY clause - */ - op = p.op; - pPrior = p.pPrior; - Debug.Assert(pPrior.pOrderBy == null); - pOrderBy = p.pOrderBy; - Debug.Assert(pOrderBy != null); - nOrderBy = pOrderBy.nExpr; - - /* For operators other than UNION ALL we have to make sure that - ** the ORDER BY clause covers every term of the result set. Add - ** terms to the ORDER BY clause as necessary. - */ - if (op != TK_ALL) { - for (i = 1; /* db.mallocFailed == 0 && */ i <= p.pEList.nExpr; i++) { - ExprList_item pItem; - for (j = 0; j < nOrderBy; j++)//, pItem++) - { - pItem = pOrderBy.a[j]; - Debug.Assert(pItem.iCol > 0); - if (pItem.iCol == i) - break; - } - if (j == nOrderBy) { - Expr pNew = sqlite3Expr(db, TK_INTEGER, null); - //if ( pNew == null ) - // return SQLITE_NOMEM; - pNew.flags |= EP_IntValue; - pNew.u.iValue = i; - pOrderBy = sqlite3ExprListAppend(pParse, pOrderBy, pNew); - pOrderBy.a[nOrderBy++].iCol = (u16)i; - } - } - } - - /* Compute the comparison permutation and keyinfo that is used with - ** the permutation used to determine if the next - ** row of results comes from selectA or selectB. Also add explicit - ** collations to the ORDER BY clause terms so that when the subqueries - ** to the right and the left are evaluated, they use the correct - ** collation. - */ - aPermute = new int[nOrderBy];// sqlite3DbMallocRaw( db, sizeof( int ) * nOrderBy ); - if (aPermute != null) { - ExprList_item pItem; - for (i = 0; i < nOrderBy; i++)//, pItem++) - { - pItem = pOrderBy.a[i]; - Debug.Assert(pItem.iCol > 0 && pItem.iCol <= p.pEList.nExpr); - aPermute[i] = pItem.iCol - 1; - } - pKeyMerge = new KeyInfo();// sqlite3DbMallocRaw(db, sizeof(*pKeyMerge)+nOrderBy*(sizeof(CollSeq)+1)); - if (pKeyMerge != null) { - pKeyMerge.aColl = new CollSeq[nOrderBy]; - pKeyMerge.aSortOrder = new byte[nOrderBy];//(u8)&pKeyMerge.aColl[nOrderBy]; - pKeyMerge.nField = (u16)nOrderBy; - pKeyMerge.enc = ENC(db); - for (i = 0; i < nOrderBy; i++) { - CollSeq pColl; - Expr pTerm = pOrderBy.a[i].pExpr; - if ((pTerm.flags & EP_ExpCollate) != 0) { - pColl = pTerm.pColl; - } else { - pColl = multiSelectCollSeq(pParse, p, aPermute[i]); - pTerm.flags |= EP_ExpCollate; - pTerm.pColl = pColl; - } - pKeyMerge.aColl[i] = pColl; - pKeyMerge.aSortOrder[i] = (byte)pOrderBy.a[i].sortOrder; - } - } - } else { - pKeyMerge = null; - } - - /* Reattach the ORDER BY clause to the query. - */ - p.pOrderBy = pOrderBy; - pPrior.pOrderBy = sqlite3ExprListDup(pParse.db, pOrderBy, 0); - - /* Allocate a range of temporary registers and the KeyInfo needed - ** for the logic that removes duplicate result rows when the - ** operator is UNION, EXCEPT, or INTERSECT (but not UNION ALL). - */ - if (op == TK_ALL) { - regPrev = 0; - } else { - int nExpr = p.pEList.nExpr; - Debug.Assert(nOrderBy >= nExpr /*|| db.mallocFailed != 0 */ ); - regPrev = sqlite3GetTempRange(pParse, nExpr + 1); - sqlite3VdbeAddOp2(v, OP_Integer, 0, regPrev); - pKeyDup = new KeyInfo();//sqlite3DbMallocZero(db, - //sizeof(*pKeyDup) + nExpr*(sizeof(CollSeq)+1) ); - if (pKeyDup != null) { - pKeyDup.aColl = new CollSeq[nExpr]; - pKeyDup.aSortOrder = new byte[nExpr];//(u8)&pKeyDup.aColl[nExpr]; - pKeyDup.nField = (u16)nExpr; - pKeyDup.enc = ENC(db); - for (i = 0; i < nExpr; i++) { - pKeyDup.aColl[i] = multiSelectCollSeq(pParse, p, i); - pKeyDup.aSortOrder[i] = 0; - } - } - } - - /* Separate the left and the right query from one another - */ - p.pPrior = null; - sqlite3ResolveOrderGroupBy(pParse, p, p.pOrderBy, "ORDER"); - if (pPrior.pPrior == null) { - sqlite3ResolveOrderGroupBy(pParse, pPrior, pPrior.pOrderBy, "ORDER"); - } - - /* Compute the limit registers */ - computeLimitRegisters(pParse, p, labelEnd); - if (p.iLimit != 0 && op == TK_ALL) { - regLimitA = ++pParse.nMem; - regLimitB = ++pParse.nMem; - sqlite3VdbeAddOp2(v, OP_Copy, (p.iOffset != 0) ? p.iOffset + 1 : p.iLimit, - regLimitA); - sqlite3VdbeAddOp2(v, OP_Copy, regLimitA, regLimitB); - } else { - regLimitA = regLimitB = 0; - } - sqlite3ExprDelete(db, ref p.pLimit); - p.pLimit = null; - sqlite3ExprDelete(db, ref p.pOffset); - p.pOffset = null; - - regAddrA = ++pParse.nMem; - regEofA = ++pParse.nMem; - regAddrB = ++pParse.nMem; - regEofB = ++pParse.nMem; - regOutA = ++pParse.nMem; - regOutB = ++pParse.nMem; - sqlite3SelectDestInit(destA, SRT_Coroutine, regAddrA); - sqlite3SelectDestInit(destB, SRT_Coroutine, regAddrB); - - /* Jump past the various subroutines and coroutines to the main - ** merge loop - */ - j1 = sqlite3VdbeAddOp0(v, OP_Goto); - addrSelectA = sqlite3VdbeCurrentAddr(v); - - - /* Generate a coroutine to evaluate the SELECT statement to the - ** left of the compound operator - the "A" select. - */ - VdbeNoopComment(v, "Begin coroutine for left SELECT"); - pPrior.iLimit = regLimitA; - explainSetInteger(ref iSub1, pParse.iNextSelectId); - sqlite3Select(pParse, pPrior, ref destA); - sqlite3VdbeAddOp2(v, OP_Integer, 1, regEofA); - sqlite3VdbeAddOp1(v, OP_Yield, regAddrA); - VdbeNoopComment(v, "End coroutine for left SELECT"); - - /* Generate a coroutine to evaluate the SELECT statement on - ** the right - the "B" select - */ - addrSelectB = sqlite3VdbeCurrentAddr(v); - VdbeNoopComment(v, "Begin coroutine for right SELECT"); - savedLimit = p.iLimit; - savedOffset = p.iOffset; - p.iLimit = regLimitB; - p.iOffset = 0; - explainSetInteger(ref iSub2, pParse.iNextSelectId); - sqlite3Select(pParse, p, ref destB); - p.iLimit = savedLimit; - p.iOffset = savedOffset; - sqlite3VdbeAddOp2(v, OP_Integer, 1, regEofB); - sqlite3VdbeAddOp1(v, OP_Yield, regAddrB); - VdbeNoopComment(v, "End coroutine for right SELECT"); - - /* Generate a subroutine that outputs the current row of the A - ** select as the next output row of the compound select. - */ - VdbeNoopComment(v, "Output routine for A"); - addrOutA = generateOutputSubroutine(pParse, - p, destA, pDest, regOutA, - regPrev, pKeyDup, P4_KEYINFO_HANDOFF, labelEnd); - - /* Generate a subroutine that outputs the current row of the B - ** select as the next output row of the compound select. - */ - if (op == TK_ALL || op == TK_UNION) { - VdbeNoopComment(v, "Output routine for B"); - addrOutB = generateOutputSubroutine(pParse, - p, destB, pDest, regOutB, - regPrev, pKeyDup, P4_KEYINFO_STATIC, labelEnd); - } - - /* Generate a subroutine to run when the results from select A - ** are exhausted and only data in select B remains. - */ - VdbeNoopComment(v, "eof-A subroutine"); - if (op == TK_EXCEPT || op == TK_INTERSECT) { - addrEofA = sqlite3VdbeAddOp2(v, OP_Goto, 0, labelEnd); - } else { - addrEofA = sqlite3VdbeAddOp2(v, OP_If, regEofB, labelEnd); - sqlite3VdbeAddOp2(v, OP_Gosub, regOutB, addrOutB); - sqlite3VdbeAddOp1(v, OP_Yield, regAddrB); - sqlite3VdbeAddOp2(v, OP_Goto, 0, addrEofA); - p.nSelectRow += pPrior.nSelectRow; - } - - /* Generate a subroutine to run when the results from select B - ** are exhausted and only data in select A remains. - */ - if (op == TK_INTERSECT) { - addrEofB = addrEofA; - if (p.nSelectRow > pPrior.nSelectRow) - p.nSelectRow = pPrior.nSelectRow; - } else { - VdbeNoopComment(v, "eof-B subroutine"); - addrEofB = sqlite3VdbeAddOp2(v, OP_If, regEofA, labelEnd); - sqlite3VdbeAddOp2(v, OP_Gosub, regOutA, addrOutA); - sqlite3VdbeAddOp1(v, OP_Yield, regAddrA); - sqlite3VdbeAddOp2(v, OP_Goto, 0, addrEofB); - } - - /* Generate code to handle the case of AB - */ - VdbeNoopComment(v, "A-gt-B subroutine"); - addrAgtB = sqlite3VdbeCurrentAddr(v); - if (op == TK_ALL || op == TK_UNION) { - sqlite3VdbeAddOp2(v, OP_Gosub, regOutB, addrOutB); - } - sqlite3VdbeAddOp1(v, OP_Yield, regAddrB); - sqlite3VdbeAddOp2(v, OP_If, regEofB, addrEofB); - sqlite3VdbeAddOp2(v, OP_Goto, 0, labelCmpr); - - /* This code runs once to initialize everything. - */ - sqlite3VdbeJumpHere(v, j1); - sqlite3VdbeAddOp2(v, OP_Integer, 0, regEofA); - sqlite3VdbeAddOp2(v, OP_Integer, 0, regEofB); - sqlite3VdbeAddOp2(v, OP_Gosub, regAddrA, addrSelectA); - sqlite3VdbeAddOp2(v, OP_Gosub, regAddrB, addrSelectB); - sqlite3VdbeAddOp2(v, OP_If, regEofA, addrEofA); - sqlite3VdbeAddOp2(v, OP_If, regEofB, addrEofB); - - /* Implement the main merge loop - */ - sqlite3VdbeResolveLabel(v, labelCmpr); - sqlite3VdbeAddOp4(v, OP_Permutation, 0, 0, 0, aPermute, P4_INTARRAY); - sqlite3VdbeAddOp4(v, OP_Compare, destA.iMem, destB.iMem, nOrderBy, - pKeyMerge, P4_KEYINFO_HANDOFF); - sqlite3VdbeAddOp3(v, OP_Jump, addrAltB, addrAeqB, addrAgtB); - - /* Release temporary registers - */ - if (regPrev != 0) { - sqlite3ReleaseTempRange(pParse, regPrev, nOrderBy + 1); - } - - /* Jump to the this point in order to terminate the query. - */ - sqlite3VdbeResolveLabel(v, labelEnd); - - /* Set the number of output columns - */ - if (pDest.eDest == SRT_Output) { - Select pFirst = pPrior; - while (pFirst.pPrior != null) - pFirst = pFirst.pPrior; - generateColumnNames(pParse, null, pFirst.pEList); - } - - /* Reassembly the compound query so that it will be freed correctly - ** by the calling function */ - if (p.pPrior != null) { - sqlite3SelectDelete(db, ref p.pPrior); - } - p.pPrior = pPrior; - - /*** TBD: Insert subroutine calls to close cursors on incomplete - **** subqueries ****/ - explainComposite(pParse, p.op, iSub1, iSub2, false); - return SQLITE_OK; - } -#endif -#if !(SQLITE_OMIT_SUBQUERY) || !(SQLITE_OMIT_VIEW) - /* Forward Declarations */ - //static void substExprList(sqlite3*, ExprList*, int, ExprList); - //static void substSelect(sqlite3*, Select *, int, ExprList ); - - /* - ** Scan through the expression pExpr. Replace every reference to - ** a column in table number iTable with a copy of the iColumn-th - ** entry in pEList. (But leave references to the ROWID column - ** unchanged.) - ** - ** This routine is part of the flattening procedure. A subquery - ** whose result set is defined by pEList appears as entry in the - ** FROM clause of a SELECT such that the VDBE cursor assigned to that - ** FORM clause entry is iTable. This routine make the necessary - ** changes to pExpr so that it refers directly to the source table - ** of the subquery rather the result set of the subquery. - */ - static Expr substExpr( - sqlite3 db, /* Report malloc errors to this connection */ - Expr pExpr, /* Expr in which substitution occurs */ - int iTable, /* Table to be substituted */ - ExprList pEList /* Substitute expressions */ - ) { - if (pExpr == null) - return null; - if (pExpr.op == TK_COLUMN && pExpr.iTable == iTable) { - if (pExpr.iColumn < 0) { - pExpr.op = TK_NULL; - } else { - Expr pNew; - Debug.Assert(pEList != null && pExpr.iColumn < pEList.nExpr); - Debug.Assert(pExpr.pLeft == null && pExpr.pRight == null); - pNew = sqlite3ExprDup(db, pEList.a[pExpr.iColumn].pExpr, 0); - if (pExpr.pColl != null) { - pNew.pColl = pExpr.pColl; - } - sqlite3ExprDelete(db, ref pExpr); - pExpr = pNew; - } - } else { - pExpr.pLeft = substExpr(db, pExpr.pLeft, iTable, pEList); - pExpr.pRight = substExpr(db, pExpr.pRight, iTable, pEList); - if (ExprHasProperty(pExpr, EP_xIsSelect)) { - substSelect(db, pExpr.x.pSelect, iTable, pEList); - } else { - substExprList(db, pExpr.x.pList, iTable, pEList); - } - } - return pExpr; - } - - static void substExprList( - sqlite3 db, /* Report malloc errors here */ - ExprList pList, /* List to scan and in which to make substitutes */ - int iTable, /* Table to be substituted */ - ExprList pEList /* Substitute values */ - ) { - int i; - if (pList == null) - return; - for (i = 0; i < pList.nExpr; i++) { - pList.a[i].pExpr = substExpr(db, pList.a[i].pExpr, iTable, pEList); - } - } - - static void substSelect( - sqlite3 db, /* Report malloc errors here */ - Select p, /* SELECT statement in which to make substitutions */ - int iTable, /* Table to be replaced */ - ExprList pEList /* Substitute values */ - ) { - SrcList pSrc; - SrcList_item pItem; - int i; - if (p == null) - return; - substExprList(db, p.pEList, iTable, pEList); - substExprList(db, p.pGroupBy, iTable, pEList); - substExprList(db, p.pOrderBy, iTable, pEList); - p.pHaving = substExpr(db, p.pHaving, iTable, pEList); - p.pWhere = substExpr(db, p.pWhere, iTable, pEList); - substSelect(db, p.pPrior, iTable, pEList); - pSrc = p.pSrc; - Debug.Assert(pSrc != null); /* Even for (SELECT 1) we have: pSrc!=0 but pSrc->nSrc==0 */ - if (ALWAYS(pSrc)) { - for (i = pSrc.nSrc; i > 0; i--)//, pItem++ ) - { - pItem = pSrc.a[pSrc.nSrc - i]; - substSelect(db, pItem.pSelect, iTable, pEList); - } - } - } -#endif //* !SQLITE_OMIT_SUBQUERY) || !SQLITE_OMIT_VIEW) */ - -#if !(SQLITE_OMIT_SUBQUERY) || !(SQLITE_OMIT_VIEW) - /* - ** This routine attempts to flatten subqueries in order to speed - ** execution. It returns 1 if it makes changes and 0 if no flattening - ** occurs. - ** - ** To understand the concept of flattening, consider the following - ** query: - ** - ** SELECT a FROM (SELECT x+y AS a FROM t1 WHERE z<100) WHERE a>5 + /* + ** Alternative compound select code generator for cases when there + ** is an ORDER BY clause. ** - ** The default way of implementing this query is to execute the - ** subquery first and store the results in a temporary table, then - ** run the outer query on that temporary table. This requires two - ** passes over the data. Furthermore, because the temporary table - ** has no indices, the WHERE clause on the outer query cannot be - ** optimized. + ** We assume a query of the following form: ** - ** This routine attempts to rewrite queries such as the above into - ** a single flat select, like this: + ** ORDER BY ** - ** SELECT x+y AS a FROM t1 WHERE z<100 AND a>5 + ** is one of UNION ALL, UNION, EXCEPT, or INTERSECT. The idea + ** is to code both and with the ORDER BY clause as + ** co-routines. Then run the co-routines in parallel and merge the results + ** into the output. In addition to the two coroutines (called selectA and + ** selectB) there are 7 subroutines: ** - ** The code generated for this simpification gives the same result - ** but only has to scan the data once. And because indices might - ** exist on the table t1, a complete scan of the data might be - ** avoided. + ** outA: Move the output of the selectA coroutine into the output + ** of the compound query. ** - ** Flattening is only attempted if all of the following are true: + ** outB: Move the output of the selectB coroutine into the output + ** of the compound query. (Only generated for UNION and + ** UNION ALL. EXCEPT and INSERTSECT never output a row that + ** appears only in B.) ** - ** (1) The subquery and the outer query do not both use aggregates. + ** AltB: Called when there is data from both coroutines and AB. ** - ** (4) The subquery is not DISTINCT. + ** EofA: Called when data is exhausted from selectA. ** - ** (*) At one point restrictions (4) and (5) defined a subset of DISTINCT - ** sub-queries that were excluded from this optimization. Restriction - ** (4) has since been expanded to exclude all DISTINCT subqueries. + ** EofB: Called when data is exhausted from selectB. ** - ** (6) The subquery does not use aggregates or the outer query is not - ** DISTINCT. + ** The implementation of the latter five subroutines depend on which + ** is used: ** - ** (7) The subquery has a FROM clause. ** - ** (8) The subquery does not use LIMIT or the outer query is not a join. + ** UNION ALL UNION EXCEPT INTERSECT + ** ------------- ----------------- -------------- ----------------- + ** AltB: outA, nextA outA, nextA outA, nextA nextA ** - ** (9) The subquery does not use LIMIT or the outer query does not use - ** aggregates. + ** AeqB: outA, nextA nextA nextA outA, nextA ** - ** (10) The subquery does not use aggregates or the outer query does not - ** use LIMIT. + ** AgtB: outB, nextB outB, nextB nextB nextB ** - ** (11) The subquery and the outer query do not both have ORDER BY clauses. + ** EofA: outB, nextB outB, nextB halt halt ** - ** (*) Not implemented. Subsumed into restriction (3). Was previously - ** a separate restriction deriving from ticket #350. + ** EofB: outA, nextA outA, nextA outA, nextA halt ** - ** (13) The subquery and outer query do not both use LIMIT. + ** In the AltB, AeqB, and AgtB subroutines, an EOF on A following nextA + ** causes an immediate jump to EofA and an EOF on B following nextB causes + ** an immediate jump to EofB. Within EofA and EofB, and EOF on entry or + ** following nextX causes a jump to the end of the select processing. ** - ** (14) The subquery does not use OFFSET. + ** Duplicate removal in the UNION, EXCEPT, and INTERSECT cases is handled + ** within the output subroutine. The regPrev register set holds the previously + ** output value. A comparison is made against this value and the output + ** is skipped if the next results would be the same as the previous. ** - ** (15) The outer query is not part of a compound select or the - ** subquery does not have a LIMIT clause. - ** (See ticket #2339 and ticket [02a8e81d44]). + ** The implementation plan is to implement the two coroutines and seven + ** subroutines first, then put the control logic at the bottom. Like this: ** - ** (16) The outer query is not an aggregate or the subquery does - ** not contain ORDER BY. (Ticket #2942) This used to not matter - ** until we introduced the group_concat() function. + ** goto Init + ** coA: coroutine for left query (A) + ** coB: coroutine for right query (B) + ** outA: output one row of A + ** outB: output one row of B (UNION and UNION ALL only) + ** EofA: ... + ** EofB: ... + ** AltB: ... + ** AeqB: ... + ** AgtB: ... + ** Init: initialize coroutine registers + ** yield coA + ** if eof(A) goto EofA + ** yield coB + ** if eof(B) goto EofB + ** Cmpr: Compare A, B + ** Jump AltB, AeqB, AgtB + ** End: ... ** - ** (17) The sub-query is not a compound select, or it is a UNION ALL - ** compound clause made up entirely of non-aggregate queries, and - ** the parent query: - ** - ** * is not itself part of a compound select, - ** * is not an aggregate or DISTINCT query, and - ** * has no other tables or sub-selects in the FROM clause. - ** - ** The parent and sub-query may contain WHERE clauses. Subject to - ** rules (11), (13) and (14), they may also contain ORDER BY, - ** LIMIT and OFFSET clauses. - ** - ** (18) If the sub-query is a compound select, then all terms of the - ** ORDER by clause of the parent must be simple references to - ** columns of the sub-query. - ** - ** (19) The subquery does not use LIMIT or the outer query does not - ** have a WHERE clause. - ** - ** (20) If the sub-query is a compound select, then it must not use - ** an ORDER BY clause. Ticket #3773. We could relax this constraint - ** somewhat by saying that the terms of the ORDER BY clause must - ** appear as unmodified result columns in the outer query. But - ** have other optimizations in mind to deal with that case. - ** - ** (21) The subquery does not use LIMIT or the outer query is not - ** DISTINCT. (See ticket [752e1646fc]). - ** - ** In this routine, the "p" parameter is a pointer to the outer query. - ** The subquery is p.pSrc.a[iFrom]. isAgg is true if the outer query - ** uses aggregates and subqueryIsAgg is true if the subquery uses aggregates. - ** - ** If flattening is not attempted, this routine is a no-op and returns 0. - ** If flattening is attempted this routine returns 1. - ** - ** All of the expression analysis must occur on both the outer query and - ** the subquery before this routine runs. + ** We call AltB, AeqB, AgtB, EofA, and EofB "subroutines" but they are not + ** actually called using Gosub and they do not Return. EofA and EofB loop + ** until all data is exhausted then jump to the "end" labe. AltB, AeqB, + ** and AgtB jump to either L2 or to one of EofA or EofB. */ - static int flattenSubquery( - Parse pParse, /* Parsing context */ - Select p, /* The parent or outer SELECT statement */ - int iFrom, /* Index in p.pSrc.a[] of the inner subquery */ - bool isAgg, /* True if outer SELECT uses aggregate functions */ - bool subqueryIsAgg /* True if the subquery uses aggregate functions */ - ) { - string zSavedAuthContext = pParse.zAuthContext; - Select pParent; - Select pSub; /* The inner query or "subquery" */ - Select pSub1; /* Pointer to the rightmost select in sub-query */ - SrcList pSrc; /* The FROM clause of the outer query */ - SrcList pSubSrc; /* The FROM clause of the subquery */ - ExprList pList; /* The result set of the outer query */ - int iParent; /* VDBE cursor number of the pSub result set temp table */ - int i; /* Loop counter */ - Expr pWhere; /* The WHERE clause */ - SrcList_item pSubitem;/* The subquery */ - sqlite3 db = pParse.db; - - /* Check to see if flattening is permitted. Return 0 if not. - */ - Debug.Assert(p != null); - Debug.Assert(p.pPrior == null); /* Unable to flatten compound queries */ - if ((db.flags & SQLITE_QueryFlattener) != 0) - return 0; - pSrc = p.pSrc; - Debug.Assert(pSrc != null && iFrom >= 0 && iFrom < pSrc.nSrc); - pSubitem = pSrc.a[iFrom]; - iParent = pSubitem.iCursor; - pSub = pSubitem.pSelect; - Debug.Assert(pSub != null); - if (isAgg && subqueryIsAgg) - return 0; /* Restriction (1) */ - if (subqueryIsAgg && pSrc.nSrc > 1) - return 0; /* Restriction (2) */ - pSubSrc = pSub.pSrc; - Debug.Assert(pSubSrc != null); - /* Prior to version 3.1.2, when LIMIT and OFFSET had to be simple constants, - ** not arbitrary expresssions, we allowed some combining of LIMIT and OFFSET - ** because they could be computed at compile-time. But when LIMIT and OFFSET - ** became arbitrary expressions, we were forced to add restrictions (13) - ** and (14). */ - if (pSub.pLimit != null && p.pLimit != null) - return 0; /* Restriction (13) */ - if (pSub.pOffset != null) - return 0; /* Restriction (14) */ - if (p.pRightmost != null && pSub.pLimit != null) { - return 0; /* Restriction (15) */ - } - if (pSubSrc.nSrc == 0) - return 0; /* Restriction (7) */ - if ((pSub.selFlags & SF_Distinct) != 0) - return 0; /* Restriction (5) */ - if (pSub.pLimit != null && (pSrc.nSrc > 1 || isAgg)) { - return 0; /* Restrictions (8)(9) */ - } - if ((p.selFlags & SF_Distinct) != 0 && subqueryIsAgg) { - return 0; /* Restriction (6) */ - } - if (p.pOrderBy != null && pSub.pOrderBy != null) { - return 0; /* Restriction (11) */ - } - if (isAgg && pSub.pOrderBy != null) - return 0; /* Restriction (16) */ - if (pSub.pLimit != null && p.pWhere != null) - return 0; /* Restriction (19) */ - if (pSub.pLimit != null && (p.selFlags & SF_Distinct) != 0) { - return 0; /* Restriction (21) */ - } +#if !SQLITE_OMIT_COMPOUND_SELECT + static int multiSelectOrderBy( + Parse pParse, /* Parsing context */ + Select p, /* The right-most of SELECTs to be coded */ + SelectDest pDest /* What to do with query results */ + ) + { + int i, j; /* Loop counters */ + Select pPrior; /* Another SELECT immediately to our left */ + Vdbe v; /* Generate code to this VDBE */ + SelectDest destA = new SelectDest(); /* Destination for coroutine A */ + SelectDest destB = new SelectDest(); /* Destination for coroutine B */ + int regAddrA; /* Address register for select-A coroutine */ + int regEofA; /* Flag to indicate when select-A is complete */ + int regAddrB; /* Address register for select-B coroutine */ + int regEofB; /* Flag to indicate when select-B is complete */ + int addrSelectA; /* Address of the select-A coroutine */ + int addrSelectB; /* Address of the select-B coroutine */ + int regOutA; /* Address register for the output-A subroutine */ + int regOutB; /* Address register for the output-B subroutine */ + int addrOutA; /* Address of the output-A subroutine */ + int addrOutB = 0; /* Address of the output-B subroutine */ + int addrEofA; /* Address of the select-A-exhausted subroutine */ + int addrEofB; /* Address of the select-B-exhausted subroutine */ + int addrAltB; /* Address of the AB subroutine */ + int regLimitA; /* Limit register for select-A */ + int regLimitB; /* Limit register for select-A */ + int regPrev; /* A range of registers to hold previous output */ + int savedLimit; /* Saved value of p.iLimit */ + int savedOffset; /* Saved value of p.iOffset */ + int labelCmpr; /* Label for the start of the merge algorithm */ + int labelEnd; /* Label for the end of the overall SELECT stmt */ + int j1; /* Jump instructions that get retargetted */ + int op; /* One of TK_ALL, TK_UNION, TK_EXCEPT, TK_INTERSECT */ + KeyInfo pKeyDup = null; /* Comparison information for duplicate removal */ + KeyInfo pKeyMerge; /* Comparison information for merging rows */ + sqlite3 db; /* Database connection */ + ExprList pOrderBy; /* The ORDER BY clause */ + int nOrderBy; /* Number of terms in the ORDER BY clause */ + int[] aPermute; /* Mapping from ORDER BY terms to result set columns */ +#if !SQLITE_OMIT_EXPLAIN + int iSub1 = 0; /* EQP id of left-hand query */ + int iSub2 = 0; /* EQP id of right-hand query */ +#endif - /* OBSOLETE COMMENT 1: - ** Restriction 3: If the subquery is a join, make sure the subquery is - ** not used as the right operand of an outer join. Examples of why this - ** is not allowed: - ** - ** t1 LEFT OUTER JOIN (t2 JOIN t3) - ** - ** If we flatten the above, we would get - ** - ** (t1 LEFT OUTER JOIN t2) JOIN t3 - ** - ** which is not at all the same thing. - ** - ** OBSOLETE COMMENT 2: - ** Restriction 12: If the subquery is the right operand of a left outer + Debug.Assert( p.pOrderBy != null ); + Debug.Assert( pKeyDup == null ); /* "Managed" code needs this. Ticket #3382. */ + db = pParse.db; + v = pParse.pVdbe; + Debug.Assert( v != null ); /* Already thrown the error if VDBE alloc failed */ + labelEnd = sqlite3VdbeMakeLabel( v ); + labelCmpr = sqlite3VdbeMakeLabel( v ); - /* Restriction 12: If the subquery is the right operand of a left outer - ** join, make sure the subquery has no WHERE clause. - ** An examples of why this is not allowed: - ** - ** t1 LEFT OUTER JOIN (SELECT * FROM t2 WHERE t2.x>0) - ** - ** If we flatten the above, we would get - ** - ** (t1 LEFT OUTER JOIN t2) WHERE t2.x>0 - ** - ** But the t2.x>0 test will always fail on a NULL row of t2, which - ** effectively converts the OUTER JOIN into an INNER JOIN. - ** - ** THIS OVERRIDES OBSOLETE COMMENTS 1 AND 2 ABOVE: - ** Ticket #3300 shows that flattening the right term of a LEFT JOIN - ** is fraught with danger. Best to avoid the whole thing. If the - ** subquery is the right term of a LEFT JOIN, then do not flatten. - */ - if ((pSubitem.jointype & JT_OUTER) != 0) { - return 0; - } - /* Restriction 17: If the sub-query is a compound SELECT, then it must - ** use only the UNION ALL operator. And none of the simple select queries - ** that make up the compound SELECT are allowed to be aggregate or distinct - ** queries. - */ - if (pSub.pPrior != null) { - if (pSub.pOrderBy != null) { - return 0; /* Restriction 20 */ - } - if (isAgg || (p.selFlags & SF_Distinct) != 0 || pSrc.nSrc != 1) { - return 0; - } - for (pSub1 = pSub; pSub1 != null; pSub1 = pSub1.pPrior) { - testcase((pSub1.selFlags & (SF_Distinct | SF_Aggregate)) == SF_Distinct); - testcase((pSub1.selFlags & (SF_Distinct | SF_Aggregate)) == SF_Aggregate); - if ((pSub1.selFlags & (SF_Distinct | SF_Aggregate)) != 0 - || (pSub1.pPrior != null && pSub1.op != TK_ALL) - || NEVER(pSub1.pSrc == null) || pSub1.pSrc.nSrc != 1 - ) { - return 0; - } - } - - /* Restriction 18. */ - if (p.pOrderBy != null) { - int ii; - for (ii = 0; ii < p.pOrderBy.nExpr; ii++) { - if (p.pOrderBy.a[ii].iCol == 0) - return 0; - } - } + /* Patch up the ORDER BY clause + */ + op = p.op; + pPrior = p.pPrior; + Debug.Assert( pPrior.pOrderBy == null ); + pOrderBy = p.pOrderBy; + Debug.Assert( pOrderBy != null ); + nOrderBy = pOrderBy.nExpr; + + /* For operators other than UNION ALL we have to make sure that + ** the ORDER BY clause covers every term of the result set. Add + ** terms to the ORDER BY clause as necessary. + */ + if ( op != TK_ALL ) + { + for ( i = 1; /* db.mallocFailed == 0 && */ i <= p.pEList.nExpr; i++ ) + { + ExprList_item pItem; + for ( j = 0; j < nOrderBy; j++ )//, pItem++) + { + pItem = pOrderBy.a[j]; + Debug.Assert( pItem.iCol > 0 ); + if ( pItem.iCol == i ) + break; + } + if ( j == nOrderBy ) + { + Expr pNew = sqlite3Expr( db, TK_INTEGER, null ); + //if ( pNew == null ) + // return SQLITE_NOMEM; + pNew.flags |= EP_IntValue; + pNew.u.iValue = i; + pOrderBy = sqlite3ExprListAppend( pParse, pOrderBy, pNew ); + pOrderBy.a[nOrderBy++].iCol = (u16)i; + } + } + } + + /* Compute the comparison permutation and keyinfo that is used with + ** the permutation used to determine if the next + ** row of results comes from selectA or selectB. Also add explicit + ** collations to the ORDER BY clause terms so that when the subqueries + ** to the right and the left are evaluated, they use the correct + ** collation. + */ + aPermute = new int[nOrderBy];// sqlite3DbMallocRaw( db, sizeof( int ) * nOrderBy ); + if ( aPermute != null ) + { + ExprList_item pItem; + for ( i = 0; i < nOrderBy; i++ )//, pItem++) + { + pItem = pOrderBy.a[i]; + Debug.Assert( pItem.iCol > 0 && pItem.iCol <= p.pEList.nExpr ); + aPermute[i] = pItem.iCol - 1; + } + pKeyMerge = new KeyInfo();// sqlite3DbMallocRaw(db, sizeof(*pKeyMerge)+nOrderBy*(sizeof(CollSeq)+1)); + if ( pKeyMerge != null ) + { + pKeyMerge.aColl = new CollSeq[nOrderBy]; + pKeyMerge.aSortOrder = new byte[nOrderBy];//(u8)&pKeyMerge.aColl[nOrderBy]; + pKeyMerge.nField = (u16)nOrderBy; + pKeyMerge.enc = ENC( db ); + for ( i = 0; i < nOrderBy; i++ ) + { + CollSeq pColl; + Expr pTerm = pOrderBy.a[i].pExpr; + if ( ( pTerm.flags & EP_ExpCollate ) != 0 ) + { + pColl = pTerm.pColl; } + else + { + pColl = multiSelectCollSeq( pParse, p, aPermute[i] ); + pTerm.flags |= EP_ExpCollate; + pTerm.pColl = pColl; + } + pKeyMerge.aColl[i] = pColl; + pKeyMerge.aSortOrder[i] = (byte)pOrderBy.a[i].sortOrder; + } + } + } + else + { + pKeyMerge = null; + } - /***** If we reach this point, flattening is permitted. *****/ + /* Reattach the ORDER BY clause to the query. + */ + p.pOrderBy = pOrderBy; + pPrior.pOrderBy = sqlite3ExprListDup( pParse.db, pOrderBy, 0 ); - /* Authorize the subquery */ - pParse.zAuthContext = pSubitem.zName; - sqlite3AuthCheck(pParse, SQLITE_SELECT, null, null, null); - pParse.zAuthContext = zSavedAuthContext; + /* Allocate a range of temporary registers and the KeyInfo needed + ** for the logic that removes duplicate result rows when the + ** operator is UNION, EXCEPT, or INTERSECT (but not UNION ALL). + */ + if ( op == TK_ALL ) + { + regPrev = 0; + } + else + { + int nExpr = p.pEList.nExpr; + Debug.Assert( nOrderBy >= nExpr /*|| db.mallocFailed != 0 */ ); + regPrev = sqlite3GetTempRange( pParse, nExpr + 1 ); + sqlite3VdbeAddOp2( v, OP_Integer, 0, regPrev ); + pKeyDup = new KeyInfo();//sqlite3DbMallocZero(db, + //sizeof(*pKeyDup) + nExpr*(sizeof(CollSeq)+1) ); + if ( pKeyDup != null ) + { + pKeyDup.aColl = new CollSeq[nExpr]; + pKeyDup.aSortOrder = new byte[nExpr];//(u8)&pKeyDup.aColl[nExpr]; + pKeyDup.nField = (u16)nExpr; + pKeyDup.enc = ENC( db ); + for ( i = 0; i < nExpr; i++ ) + { + pKeyDup.aColl[i] = multiSelectCollSeq( pParse, p, i ); + pKeyDup.aSortOrder[i] = 0; + } + } + } - /* If the sub-query is a compound SELECT statement, then (by restrictions - ** 17 and 18 above) it must be a UNION ALL and the parent query must - ** be of the form: - ** - ** SELECT FROM () - ** - ** followed by any ORDER BY, LIMIT and/or OFFSET clauses. This block - ** creates N-1 copies of the parent query without any ORDER BY, LIMIT or - ** OFFSET clauses and joins them to the left-hand-side of the original - ** using UNION ALL operators. In this case N is the number of simple - ** select statements in the compound sub-query. - ** - ** Example: - ** - ** SELECT a+1 FROM ( - ** SELECT x FROM tab - ** UNION ALL - ** SELECT y FROM tab - ** UNION ALL - ** SELECT abs(z*2) FROM tab2 - ** ) WHERE a!=5 ORDER BY 1 - ** - ** Transformed into: - ** - ** SELECT x+1 FROM tab WHERE x+1!=5 - ** UNION ALL - ** SELECT y+1 FROM tab WHERE y+1!=5 - ** UNION ALL - ** SELECT abs(z*2)+1 FROM tab2 WHERE abs(z*2)+1!=5 - ** ORDER BY 1 - ** - ** We call this the "compound-subquery flattening". - */ - for (pSub = pSub.pPrior; pSub != null; pSub = pSub.pPrior) { - Select pNew; - ExprList pOrderBy = p.pOrderBy; - Expr pLimit = p.pLimit; - Select pPrior = p.pPrior; - p.pOrderBy = null; - p.pSrc = null; - p.pPrior = null; - p.pLimit = null; - pNew = sqlite3SelectDup(db, p, 0); - p.pLimit = pLimit; - p.pOrderBy = pOrderBy; - p.pSrc = pSrc; - p.op = TK_ALL; - p.pRightmost = null; - if (pNew == null) { - pNew = pPrior; - } else { - pNew.pPrior = pPrior; - pNew.pRightmost = null; - } - p.pPrior = pNew; - // if ( db.mallocFailed != 0 ) return 1; - } + /* Separate the left and the right query from one another + */ + p.pPrior = null; + sqlite3ResolveOrderGroupBy( pParse, p, p.pOrderBy, "ORDER" ); + if ( pPrior.pPrior == null ) + { + sqlite3ResolveOrderGroupBy( pParse, pPrior, pPrior.pOrderBy, "ORDER" ); + } + + /* Compute the limit registers */ + computeLimitRegisters( pParse, p, labelEnd ); + if ( p.iLimit != 0 && op == TK_ALL ) + { + regLimitA = ++pParse.nMem; + regLimitB = ++pParse.nMem; + sqlite3VdbeAddOp2( v, OP_Copy, ( p.iOffset != 0 ) ? p.iOffset + 1 : p.iLimit, + regLimitA ); + sqlite3VdbeAddOp2( v, OP_Copy, regLimitA, regLimitB ); + } + else + { + regLimitA = regLimitB = 0; + } + sqlite3ExprDelete( db, ref p.pLimit ); + p.pLimit = null; + sqlite3ExprDelete( db, ref p.pOffset ); + p.pOffset = null; + + regAddrA = ++pParse.nMem; + regEofA = ++pParse.nMem; + regAddrB = ++pParse.nMem; + regEofB = ++pParse.nMem; + regOutA = ++pParse.nMem; + regOutB = ++pParse.nMem; + sqlite3SelectDestInit( destA, SRT_Coroutine, regAddrA ); + sqlite3SelectDestInit( destB, SRT_Coroutine, regAddrB ); + + /* Jump past the various subroutines and coroutines to the main + ** merge loop + */ + j1 = sqlite3VdbeAddOp0( v, OP_Goto ); + addrSelectA = sqlite3VdbeCurrentAddr( v ); - /* Begin flattening the iFrom-th entry of the FROM clause - ** in the outer query. - */ - pSub = pSub1 = pSubitem.pSelect; - /* Delete the transient table structure associated with the - ** subquery - */ - sqlite3DbFree(db, ref pSubitem.zDatabase); - sqlite3DbFree(db, ref pSubitem.zName); - sqlite3DbFree(db, ref pSubitem.zAlias); - pSubitem.zDatabase = null; - pSubitem.zName = null; - pSubitem.zAlias = null; - pSubitem.pSelect = null; - /* Defer deleting the Table object associated with the - ** subquery until code generation is - ** complete, since there may still exist Expr.pTab entries that - ** refer to the subquery even after flattening. Ticket #3346. - ** - ** pSubitem->pTab is always non-NULL by test restrictions and tests above. - */ - if (ALWAYS(pSubitem.pTab != null)) { - Table pTabToDel = pSubitem.pTab; - if (pTabToDel.nRef == 1) { - Parse pToplevel = sqlite3ParseToplevel(pParse); - pTabToDel.pNextZombie = pToplevel.pZombieTab; - pToplevel.pZombieTab = pTabToDel; - } else { - pTabToDel.nRef--; - } - pSubitem.pTab = null; - } + /* Generate a coroutine to evaluate the SELECT statement to the + ** left of the compound operator - the "A" select. + */ + VdbeNoopComment( v, "Begin coroutine for left SELECT" ); + pPrior.iLimit = regLimitA; + explainSetInteger( ref iSub1, pParse.iNextSelectId ); + sqlite3Select( pParse, pPrior, ref destA ); + sqlite3VdbeAddOp2( v, OP_Integer, 1, regEofA ); + sqlite3VdbeAddOp1( v, OP_Yield, regAddrA ); + VdbeNoopComment( v, "End coroutine for left SELECT" ); + + /* Generate a coroutine to evaluate the SELECT statement on + ** the right - the "B" select + */ + addrSelectB = sqlite3VdbeCurrentAddr( v ); + VdbeNoopComment( v, "Begin coroutine for right SELECT" ); + savedLimit = p.iLimit; + savedOffset = p.iOffset; + p.iLimit = regLimitB; + p.iOffset = 0; + explainSetInteger( ref iSub2, pParse.iNextSelectId ); + sqlite3Select( pParse, p, ref destB ); + p.iLimit = savedLimit; + p.iOffset = savedOffset; + sqlite3VdbeAddOp2( v, OP_Integer, 1, regEofB ); + sqlite3VdbeAddOp1( v, OP_Yield, regAddrB ); + VdbeNoopComment( v, "End coroutine for right SELECT" ); + + /* Generate a subroutine that outputs the current row of the A + ** select as the next output row of the compound select. + */ + VdbeNoopComment( v, "Output routine for A" ); + addrOutA = generateOutputSubroutine( pParse, + p, destA, pDest, regOutA, + regPrev, pKeyDup, P4_KEYINFO_HANDOFF, labelEnd ); - /* The following loop runs once for each term in a compound-subquery - ** flattening (as described above). If we are doing a different kind - ** of flattening - a flattening other than a compound-subquery flattening - - ** then this loop only runs once. - ** - ** This loop moves all of the FROM elements of the subquery into the - ** the FROM clause of the outer query. Before doing this, remember - ** the cursor number for the original outer query FROM element in - ** iParent. The iParent cursor will never be used. Subsequent code - ** will scan expressions looking for iParent references and replace - ** those references with expressions that resolve to the subquery FROM - ** elements we are now copying in. - */ - for (pParent = p; pParent != null; pParent = pParent.pPrior, pSub = pSub.pPrior) { - int nSubSrc; - u8 jointype = 0; - pSubSrc = pSub.pSrc; /* FROM clause of subquery */ - nSubSrc = pSubSrc.nSrc; /* Number of terms in subquery FROM clause */ - pSrc = pParent.pSrc; /* FROM clause of the outer query */ - - if (pSrc != null) { - Debug.Assert(pParent == p); /* First time through the loop */ - jointype = pSubitem.jointype; - } else { - Debug.Assert(pParent != p); /* 2nd and subsequent times through the loop */ - pSrc = pParent.pSrc = sqlite3SrcListAppend(db, null, null, null); - //if ( pSrc == null ) - //{ - // //Debug.Assert( db.mallocFailed != 0 ); - // break; - //} - } + /* Generate a subroutine that outputs the current row of the B + ** select as the next output row of the compound select. + */ + if ( op == TK_ALL || op == TK_UNION ) + { + VdbeNoopComment( v, "Output routine for B" ); + addrOutB = generateOutputSubroutine( pParse, + p, destB, pDest, regOutB, + regPrev, pKeyDup, P4_KEYINFO_STATIC, labelEnd ); + } + + /* Generate a subroutine to run when the results from select A + ** are exhausted and only data in select B remains. + */ + VdbeNoopComment( v, "eof-A subroutine" ); + if ( op == TK_EXCEPT || op == TK_INTERSECT ) + { + addrEofA = sqlite3VdbeAddOp2( v, OP_Goto, 0, labelEnd ); + } + else + { + addrEofA = sqlite3VdbeAddOp2( v, OP_If, regEofB, labelEnd ); + sqlite3VdbeAddOp2( v, OP_Gosub, regOutB, addrOutB ); + sqlite3VdbeAddOp1( v, OP_Yield, regAddrB ); + sqlite3VdbeAddOp2( v, OP_Goto, 0, addrEofA ); + p.nSelectRow += pPrior.nSelectRow; + } + + /* Generate a subroutine to run when the results from select B + ** are exhausted and only data in select A remains. + */ + if ( op == TK_INTERSECT ) + { + addrEofB = addrEofA; + if ( p.nSelectRow > pPrior.nSelectRow ) + p.nSelectRow = pPrior.nSelectRow; + } + else + { + VdbeNoopComment( v, "eof-B subroutine" ); + addrEofB = sqlite3VdbeAddOp2( v, OP_If, regEofA, labelEnd ); + sqlite3VdbeAddOp2( v, OP_Gosub, regOutA, addrOutA ); + sqlite3VdbeAddOp1( v, OP_Yield, regAddrA ); + sqlite3VdbeAddOp2( v, OP_Goto, 0, addrEofB ); + } + + /* Generate code to handle the case of A 1) { - pParent.pSrc = pSrc = sqlite3SrcListEnlarge(db, pSrc, nSubSrc - 1, iFrom + 1); - //if ( db.mallocFailed != 0 ) - //{ - // break; - //} - } + /* Generate code to handle the case of A==B + */ + if ( op == TK_ALL ) + { + addrAeqB = addrAltB; + } + else if ( op == TK_INTERSECT ) + { + addrAeqB = addrAltB; + addrAltB++; + } + else + { + VdbeNoopComment( v, "A-eq-B subroutine" ); + addrAeqB = + sqlite3VdbeAddOp1( v, OP_Yield, regAddrA ); + sqlite3VdbeAddOp2( v, OP_If, regEofA, addrEofA ); + sqlite3VdbeAddOp2( v, OP_Goto, 0, labelCmpr ); + } + + /* Generate code to handle the case of A>B + */ + VdbeNoopComment( v, "A-gt-B subroutine" ); + addrAgtB = sqlite3VdbeCurrentAddr( v ); + if ( op == TK_ALL || op == TK_UNION ) + { + sqlite3VdbeAddOp2( v, OP_Gosub, regOutB, addrOutB ); + } + sqlite3VdbeAddOp1( v, OP_Yield, regAddrB ); + sqlite3VdbeAddOp2( v, OP_If, regEofB, addrEofB ); + sqlite3VdbeAddOp2( v, OP_Goto, 0, labelCmpr ); + + /* This code runs once to initialize everything. + */ + sqlite3VdbeJumpHere( v, j1 ); + sqlite3VdbeAddOp2( v, OP_Integer, 0, regEofA ); + sqlite3VdbeAddOp2( v, OP_Integer, 0, regEofB ); + sqlite3VdbeAddOp2( v, OP_Gosub, regAddrA, addrSelectA ); + sqlite3VdbeAddOp2( v, OP_Gosub, regAddrB, addrSelectB ); + sqlite3VdbeAddOp2( v, OP_If, regEofA, addrEofA ); + sqlite3VdbeAddOp2( v, OP_If, regEofB, addrEofB ); + + /* Implement the main merge loop + */ + sqlite3VdbeResolveLabel( v, labelCmpr ); + sqlite3VdbeAddOp4( v, OP_Permutation, 0, 0, 0, aPermute, P4_INTARRAY ); + sqlite3VdbeAddOp4( v, OP_Compare, destA.iMem, destB.iMem, nOrderBy, + pKeyMerge, P4_KEYINFO_HANDOFF ); + sqlite3VdbeAddOp3( v, OP_Jump, addrAltB, addrAeqB, addrAgtB ); - /* Transfer the FROM clause terms from the subquery into the - ** outer query. - */ - for (i = 0; i < nSubSrc; i++) { - sqlite3IdListDelete(db, ref pSrc.a[i + iFrom].pUsing); - pSrc.a[i + iFrom] = pSubSrc.a[i]; - pSubSrc.a[i] = new SrcList_item();//memset(pSubSrc.a[i], 0, sizeof(pSubSrc.a[i])); - } - pSubitem = pSrc.a[iFrom]; // Reset for C# - pSrc.a[iFrom].jointype = jointype; - - /* Now begin substituting subquery result set expressions for - ** references to the iParent in the outer query. - ** - ** Example: - ** - ** SELECT a+5, b*10 FROM (SELECT x*3 AS a, y+10 AS b FROM t1) WHERE a>b; - ** \ \_____________ subquery __________/ / - ** \_____________________ outer query ______________________________/ - ** - ** We look at every expression in the outer query and every place we see - ** "a" we substitute "x*3" and every place we see "b" we substitute "y+10". - */ - pList = pParent.pEList; - for (i = 0; i < pList.nExpr; i++) { - if (pList.a[i].zName == null) { - string zSpan = pList.a[i].zSpan; - if (ALWAYS(zSpan)) { - pList.a[i].zName = zSpan;// sqlite3DbStrDup( db, zSpan ); - } - } - } - substExprList(db, pParent.pEList, iParent, pSub.pEList); - if (isAgg) { - substExprList(db, pParent.pGroupBy, iParent, pSub.pEList); - pParent.pHaving = substExpr(db, pParent.pHaving, iParent, pSub.pEList); - } - if (pSub.pOrderBy != null) { - Debug.Assert(pParent.pOrderBy == null); - pParent.pOrderBy = pSub.pOrderBy; - pSub.pOrderBy = null; - } else if (pParent.pOrderBy != null) { - substExprList(db, pParent.pOrderBy, iParent, pSub.pEList); - } - if (pSub.pWhere != null) { - pWhere = sqlite3ExprDup(db, pSub.pWhere, 0); - } else { - pWhere = null; - } - if (subqueryIsAgg) { - Debug.Assert(pParent.pHaving == null); - pParent.pHaving = pParent.pWhere; - pParent.pWhere = pWhere; - pParent.pHaving = substExpr(db, pParent.pHaving, iParent, pSub.pEList); - pParent.pHaving = sqlite3ExprAnd(db, pParent.pHaving, - sqlite3ExprDup(db, pSub.pHaving, 0)); - Debug.Assert(pParent.pGroupBy == null); - pParent.pGroupBy = sqlite3ExprListDup(db, pSub.pGroupBy, 0); - } else { - pParent.pWhere = substExpr(db, pParent.pWhere, iParent, pSub.pEList); - pParent.pWhere = sqlite3ExprAnd(db, pParent.pWhere, pWhere); - } + /* Release temporary registers + */ + if ( regPrev != 0 ) + { + sqlite3ReleaseTempRange( pParse, regPrev, nOrderBy + 1 ); + } - /* The flattened query is distinct if either the inner or the - ** outer query is distinct. - */ - pParent.selFlags = (u16)(pParent.selFlags | pSub.selFlags & SF_Distinct); + /* Jump to the this point in order to terminate the query. + */ + sqlite3VdbeResolveLabel( v, labelEnd ); - /* - ** SELECT ... FROM (SELECT ... LIMIT a OFFSET b) LIMIT x OFFSET y; - ** - ** One is tempted to try to add a and b to combine the limits. But this - ** does not work if either limit is negative. - */ - if (pSub.pLimit != null) { - pParent.pLimit = pSub.pLimit; - pSub.pLimit = null; - } - } + /* Set the number of output columns + */ + if ( pDest.eDest == SRT_Output ) + { + Select pFirst = pPrior; + while ( pFirst.pPrior != null ) + pFirst = pFirst.pPrior; + generateColumnNames( pParse, null, pFirst.pEList ); + } + + /* Reassembly the compound query so that it will be freed correctly + ** by the calling function */ + if ( p.pPrior != null ) + { + sqlite3SelectDelete( db, ref p.pPrior ); + } + p.pPrior = pPrior; + + /*** TBD: Insert subroutine calls to close cursors on incomplete + **** subqueries ****/ + explainComposite( pParse, p.op, iSub1, iSub2, false ); + return SQLITE_OK; + } +#endif +#if !(SQLITE_OMIT_SUBQUERY) || !(SQLITE_OMIT_VIEW) + /* Forward Declarations */ + //static void substExprList(sqlite3*, ExprList*, int, ExprList); + //static void substSelect(sqlite3*, Select *, int, ExprList ); + + /* + ** Scan through the expression pExpr. Replace every reference to + ** a column in table number iTable with a copy of the iColumn-th + ** entry in pEList. (But leave references to the ROWID column + ** unchanged.) + ** + ** This routine is part of the flattening procedure. A subquery + ** whose result set is defined by pEList appears as entry in the + ** FROM clause of a SELECT such that the VDBE cursor assigned to that + ** FORM clause entry is iTable. This routine make the necessary + ** changes to pExpr so that it refers directly to the source table + ** of the subquery rather the result set of the subquery. + */ + static Expr substExpr( + sqlite3 db, /* Report malloc errors to this connection */ + Expr pExpr, /* Expr in which substitution occurs */ + int iTable, /* Table to be substituted */ + ExprList pEList /* Substitute expressions */ + ) + { + if ( pExpr == null ) + return null; + if ( pExpr.op == TK_COLUMN && pExpr.iTable == iTable ) + { + if ( pExpr.iColumn < 0 ) + { + pExpr.op = TK_NULL; + } + else + { + Expr pNew; + Debug.Assert( pEList != null && pExpr.iColumn < pEList.nExpr ); + Debug.Assert( pExpr.pLeft == null && pExpr.pRight == null ); + pNew = sqlite3ExprDup( db, pEList.a[pExpr.iColumn].pExpr, 0 ); + if ( pExpr.pColl != null ) + { + pNew.pColl = pExpr.pColl; + } + sqlite3ExprDelete( db, ref pExpr ); + pExpr = pNew; + } + } + else + { + pExpr.pLeft = substExpr( db, pExpr.pLeft, iTable, pEList ); + pExpr.pRight = substExpr( db, pExpr.pRight, iTable, pEList ); + if ( ExprHasProperty( pExpr, EP_xIsSelect ) ) + { + substSelect( db, pExpr.x.pSelect, iTable, pEList ); + } + else + { + substExprList( db, pExpr.x.pList, iTable, pEList ); + } + } + return pExpr; + } - /* Finially, delete what is left of the subquery and return - ** success. - */ - sqlite3SelectDelete(db, ref pSub); - sqlite3SelectDelete(db, ref pSub1); - return 1; + static void substExprList( + sqlite3 db, /* Report malloc errors here */ + ExprList pList, /* List to scan and in which to make substitutes */ + int iTable, /* Table to be substituted */ + ExprList pEList /* Substitute values */ + ) + { + int i; + if ( pList == null ) + return; + for ( i = 0; i < pList.nExpr; i++ ) + { + pList.a[i].pExpr = substExpr( db, pList.a[i].pExpr, iTable, pEList ); + } + } + + static void substSelect( + sqlite3 db, /* Report malloc errors here */ + Select p, /* SELECT statement in which to make substitutions */ + int iTable, /* Table to be replaced */ + ExprList pEList /* Substitute values */ + ) + { + SrcList pSrc; + SrcList_item pItem; + int i; + if ( p == null ) + return; + substExprList( db, p.pEList, iTable, pEList ); + substExprList( db, p.pGroupBy, iTable, pEList ); + substExprList( db, p.pOrderBy, iTable, pEList ); + p.pHaving = substExpr( db, p.pHaving, iTable, pEList ); + p.pWhere = substExpr( db, p.pWhere, iTable, pEList ); + substSelect( db, p.pPrior, iTable, pEList ); + pSrc = p.pSrc; + Debug.Assert( pSrc != null ); /* Even for (SELECT 1) we have: pSrc!=0 but pSrc->nSrc==0 */ + if ( ALWAYS( pSrc ) ) + { + for ( i = pSrc.nSrc; i > 0; i-- )//, pItem++ ) + { + pItem = pSrc.a[pSrc.nSrc - i]; + substSelect( db, pItem.pSelect, iTable, pEList ); } + } + } #endif //* !SQLITE_OMIT_SUBQUERY) || !SQLITE_OMIT_VIEW) */ - /* - ** Analyze the SELECT statement passed as an argument to see if it - ** is a min() or max() query. Return WHERE_ORDERBY_MIN or WHERE_ORDERBY_MAX if - ** it is, or 0 otherwise. At present, a query is considered to be - ** a min()/max() query if: - ** - ** 1. There is a single object in the FROM clause. - ** - ** 2. There is a single expression in the result set, and it is - ** either min(x) or max(x), where x is a column reference. - */ - static u8 minMaxQuery(Select p) { - Expr pExpr; - ExprList pEList = p.pEList; - - if (pEList.nExpr != 1) - return WHERE_ORDERBY_NORMAL; - pExpr = pEList.a[0].pExpr; - if (pExpr.op != TK_AGG_FUNCTION) - return 0; - if (NEVER(ExprHasProperty(pExpr, EP_xIsSelect))) - return 0; - pEList = pExpr.x.pList; - if (pEList == null || pEList.nExpr != 1) - return 0; - if (pEList.a[0].pExpr.op != TK_AGG_COLUMN) - return WHERE_ORDERBY_NORMAL; - Debug.Assert(!ExprHasProperty(pExpr, EP_IntValue)); - if (pExpr.u.zToken.Equals("min", StringComparison.OrdinalIgnoreCase)) { - return WHERE_ORDERBY_MIN; - } else if (pExpr.u.zToken.Equals("max", StringComparison.OrdinalIgnoreCase)) { - return WHERE_ORDERBY_MAX; - } - return WHERE_ORDERBY_NORMAL; +#if !(SQLITE_OMIT_SUBQUERY) || !(SQLITE_OMIT_VIEW) + /* +** This routine attempts to flatten subqueries in order to speed +** execution. It returns 1 if it makes changes and 0 if no flattening +** occurs. +** +** To understand the concept of flattening, consider the following +** query: +** +** SELECT a FROM (SELECT x+y AS a FROM t1 WHERE z<100) WHERE a>5 +** +** The default way of implementing this query is to execute the +** subquery first and store the results in a temporary table, then +** run the outer query on that temporary table. This requires two +** passes over the data. Furthermore, because the temporary table +** has no indices, the WHERE clause on the outer query cannot be +** optimized. +** +** This routine attempts to rewrite queries such as the above into +** a single flat select, like this: +** +** SELECT x+y AS a FROM t1 WHERE z<100 AND a>5 +** +** The code generated for this simpification gives the same result +** but only has to scan the data once. And because indices might +** exist on the table t1, a complete scan of the data might be +** avoided. +** +** Flattening is only attempted if all of the following are true: +** +** (1) The subquery and the outer query do not both use aggregates. +** +** (2) The subquery is not an aggregate or the outer query is not a join. +** +** (3) The subquery is not the right operand of a left outer join +** (Originally ticket #306. Strengthened by ticket #3300) +** +** (4) The subquery is not DISTINCT. +** +** (*) At one point restrictions (4) and (5) defined a subset of DISTINCT +** sub-queries that were excluded from this optimization. Restriction +** (4) has since been expanded to exclude all DISTINCT subqueries. +** +** (6) The subquery does not use aggregates or the outer query is not +** DISTINCT. +** +** (7) The subquery has a FROM clause. +** +** (8) The subquery does not use LIMIT or the outer query is not a join. +** +** (9) The subquery does not use LIMIT or the outer query does not use +** aggregates. +** +** (10) The subquery does not use aggregates or the outer query does not +** use LIMIT. +** +** (11) The subquery and the outer query do not both have ORDER BY clauses. +** +** (*) Not implemented. Subsumed into restriction (3). Was previously +** a separate restriction deriving from ticket #350. +** +** (13) The subquery and outer query do not both use LIMIT. +** +** (14) The subquery does not use OFFSET. +** +** (15) The outer query is not part of a compound select or the +** subquery does not have a LIMIT clause. +** (See ticket #2339 and ticket [02a8e81d44]). +** +** (16) The outer query is not an aggregate or the subquery does +** not contain ORDER BY. (Ticket #2942) This used to not matter +** until we introduced the group_concat() function. +** +** (17) The sub-query is not a compound select, or it is a UNION ALL +** compound clause made up entirely of non-aggregate queries, and +** the parent query: +** +** * is not itself part of a compound select, +** * is not an aggregate or DISTINCT query, and +** * has no other tables or sub-selects in the FROM clause. +** +** The parent and sub-query may contain WHERE clauses. Subject to +** rules (11), (13) and (14), they may also contain ORDER BY, +** LIMIT and OFFSET clauses. +** +** (18) If the sub-query is a compound select, then all terms of the +** ORDER by clause of the parent must be simple references to +** columns of the sub-query. +** +** (19) The subquery does not use LIMIT or the outer query does not +** have a WHERE clause. +** +** (20) If the sub-query is a compound select, then it must not use +** an ORDER BY clause. Ticket #3773. We could relax this constraint +** somewhat by saying that the terms of the ORDER BY clause must +** appear as unmodified result columns in the outer query. But +** have other optimizations in mind to deal with that case. +** +** (21) The subquery does not use LIMIT or the outer query is not +** DISTINCT. (See ticket [752e1646fc]). +** +** In this routine, the "p" parameter is a pointer to the outer query. +** The subquery is p.pSrc.a[iFrom]. isAgg is true if the outer query +** uses aggregates and subqueryIsAgg is true if the subquery uses aggregates. +** +** If flattening is not attempted, this routine is a no-op and returns 0. +** If flattening is attempted this routine returns 1. +** +** All of the expression analysis must occur on both the outer query and +** the subquery before this routine runs. +*/ + static int flattenSubquery( + Parse pParse, /* Parsing context */ + Select p, /* The parent or outer SELECT statement */ + int iFrom, /* Index in p.pSrc.a[] of the inner subquery */ + bool isAgg, /* True if outer SELECT uses aggregate functions */ + bool subqueryIsAgg /* True if the subquery uses aggregate functions */ + ) + { + string zSavedAuthContext = pParse.zAuthContext; + Select pParent; + Select pSub; /* The inner query or "subquery" */ + Select pSub1; /* Pointer to the rightmost select in sub-query */ + SrcList pSrc; /* The FROM clause of the outer query */ + SrcList pSubSrc; /* The FROM clause of the subquery */ + ExprList pList; /* The result set of the outer query */ + int iParent; /* VDBE cursor number of the pSub result set temp table */ + int i; /* Loop counter */ + Expr pWhere; /* The WHERE clause */ + SrcList_item pSubitem;/* The subquery */ + sqlite3 db = pParse.db; + + /* Check to see if flattening is permitted. Return 0 if not. + */ + Debug.Assert( p != null ); + Debug.Assert( p.pPrior == null ); /* Unable to flatten compound queries */ + if ( ( db.flags & SQLITE_QueryFlattener ) != 0 ) + return 0; + pSrc = p.pSrc; + Debug.Assert( pSrc != null && iFrom >= 0 && iFrom < pSrc.nSrc ); + pSubitem = pSrc.a[iFrom]; + iParent = pSubitem.iCursor; + pSub = pSubitem.pSelect; + Debug.Assert( pSub != null ); + if ( isAgg && subqueryIsAgg ) + return 0; /* Restriction (1) */ + if ( subqueryIsAgg && pSrc.nSrc > 1 ) + return 0; /* Restriction (2) */ + pSubSrc = pSub.pSrc; + Debug.Assert( pSubSrc != null ); + /* Prior to version 3.1.2, when LIMIT and OFFSET had to be simple constants, + ** not arbitrary expresssions, we allowed some combining of LIMIT and OFFSET + ** because they could be computed at compile-time. But when LIMIT and OFFSET + ** became arbitrary expressions, we were forced to add restrictions (13) + ** and (14). */ + if ( pSub.pLimit != null && p.pLimit != null ) + return 0; /* Restriction (13) */ + if ( pSub.pOffset != null ) + return 0; /* Restriction (14) */ + if ( p.pRightmost != null && pSub.pLimit != null ) + { + return 0; /* Restriction (15) */ + } + if ( pSubSrc.nSrc == 0 ) + return 0; /* Restriction (7) */ + if ( ( pSub.selFlags & SF_Distinct ) != 0 ) + return 0; /* Restriction (5) */ + if ( pSub.pLimit != null && ( pSrc.nSrc > 1 || isAgg ) ) + { + return 0; /* Restrictions (8)(9) */ + } + if ( ( p.selFlags & SF_Distinct ) != 0 && subqueryIsAgg ) + { + return 0; /* Restriction (6) */ + } + if ( p.pOrderBy != null && pSub.pOrderBy != null ) + { + return 0; /* Restriction (11) */ + } + if ( isAgg && pSub.pOrderBy != null ) + return 0; /* Restriction (16) */ + if ( pSub.pLimit != null && p.pWhere != null ) + return 0; /* Restriction (19) */ + if ( pSub.pLimit != null && ( p.selFlags & SF_Distinct ) != 0 ) + { + return 0; /* Restriction (21) */ + } + + /* OBSOLETE COMMENT 1: + ** Restriction 3: If the subquery is a join, make sure the subquery is + ** not used as the right operand of an outer join. Examples of why this + ** is not allowed: + ** + ** t1 LEFT OUTER JOIN (t2 JOIN t3) + ** + ** If we flatten the above, we would get + ** + ** (t1 LEFT OUTER JOIN t2) JOIN t3 + ** + ** which is not at all the same thing. + ** + ** OBSOLETE COMMENT 2: + ** Restriction 12: If the subquery is the right operand of a left outer + + /* Restriction 12: If the subquery is the right operand of a left outer + ** join, make sure the subquery has no WHERE clause. + ** An examples of why this is not allowed: + ** + ** t1 LEFT OUTER JOIN (SELECT * FROM t2 WHERE t2.x>0) + ** + ** If we flatten the above, we would get + ** + ** (t1 LEFT OUTER JOIN t2) WHERE t2.x>0 + ** + ** But the t2.x>0 test will always fail on a NULL row of t2, which + ** effectively converts the OUTER JOIN into an INNER JOIN. + ** + ** THIS OVERRIDES OBSOLETE COMMENTS 1 AND 2 ABOVE: + ** Ticket #3300 shows that flattening the right term of a LEFT JOIN + ** is fraught with danger. Best to avoid the whole thing. If the + ** subquery is the right term of a LEFT JOIN, then do not flatten. + */ + if ( ( pSubitem.jointype & JT_OUTER ) != 0 ) + { + return 0; + } + + /* Restriction 17: If the sub-query is a compound SELECT, then it must + ** use only the UNION ALL operator. And none of the simple select queries + ** that make up the compound SELECT are allowed to be aggregate or distinct + ** queries. + */ + if ( pSub.pPrior != null ) + { + if ( pSub.pOrderBy != null ) + { + return 0; /* Restriction 20 */ + } + if ( isAgg || ( p.selFlags & SF_Distinct ) != 0 || pSrc.nSrc != 1 ) + { + return 0; + } + for ( pSub1 = pSub; pSub1 != null; pSub1 = pSub1.pPrior ) + { + testcase( ( pSub1.selFlags & ( SF_Distinct | SF_Aggregate ) ) == SF_Distinct ); + testcase( ( pSub1.selFlags & ( SF_Distinct | SF_Aggregate ) ) == SF_Aggregate ); + if ( ( pSub1.selFlags & ( SF_Distinct | SF_Aggregate ) ) != 0 + || ( pSub1.pPrior != null && pSub1.op != TK_ALL ) + || NEVER( pSub1.pSrc == null ) || pSub1.pSrc.nSrc != 1 + ) + { + return 0; + } } - /* - ** The select statement passed as the first argument is an aggregate query. - ** The second argment is the associated aggregate-info object. This - ** function tests if the SELECT is of the form: + /* Restriction 18. */ + if ( p.pOrderBy != null ) + { + int ii; + for ( ii = 0; ii < p.pOrderBy.nExpr; ii++ ) + { + if ( p.pOrderBy.a[ii].iCol == 0 ) + return 0; + } + } + } + + /***** If we reach this point, flattening is permitted. *****/ + + /* Authorize the subquery */ + pParse.zAuthContext = pSubitem.zName; + sqlite3AuthCheck( pParse, SQLITE_SELECT, null, null, null ); + pParse.zAuthContext = zSavedAuthContext; + + /* If the sub-query is a compound SELECT statement, then (by restrictions + ** 17 and 18 above) it must be a UNION ALL and the parent query must + ** be of the form: + ** + ** SELECT FROM () + ** + ** followed by any ORDER BY, LIMIT and/or OFFSET clauses. This block + ** creates N-1 copies of the parent query without any ORDER BY, LIMIT or + ** OFFSET clauses and joins them to the left-hand-side of the original + ** using UNION ALL operators. In this case N is the number of simple + ** select statements in the compound sub-query. + ** + ** Example: + ** + ** SELECT a+1 FROM ( + ** SELECT x FROM tab + ** UNION ALL + ** SELECT y FROM tab + ** UNION ALL + ** SELECT abs(z*2) FROM tab2 + ** ) WHERE a!=5 ORDER BY 1 + ** + ** Transformed into: + ** + ** SELECT x+1 FROM tab WHERE x+1!=5 + ** UNION ALL + ** SELECT y+1 FROM tab WHERE y+1!=5 + ** UNION ALL + ** SELECT abs(z*2)+1 FROM tab2 WHERE abs(z*2)+1!=5 + ** ORDER BY 1 + ** + ** We call this the "compound-subquery flattening". + */ + for ( pSub = pSub.pPrior; pSub != null; pSub = pSub.pPrior ) + { + Select pNew; + ExprList pOrderBy = p.pOrderBy; + Expr pLimit = p.pLimit; + Select pPrior = p.pPrior; + p.pOrderBy = null; + p.pSrc = null; + p.pPrior = null; + p.pLimit = null; + pNew = sqlite3SelectDup( db, p, 0 ); + p.pLimit = pLimit; + p.pOrderBy = pOrderBy; + p.pSrc = pSrc; + p.op = TK_ALL; + p.pRightmost = null; + if ( pNew == null ) + { + pNew = pPrior; + } + else + { + pNew.pPrior = pPrior; + pNew.pRightmost = null; + } + p.pPrior = pNew; + // if ( db.mallocFailed != 0 ) return 1; + } + + /* Begin flattening the iFrom-th entry of the FROM clause + ** in the outer query. + */ + pSub = pSub1 = pSubitem.pSelect; + /* Delete the transient table structure associated with the + ** subquery + */ + + sqlite3DbFree( db, ref pSubitem.zDatabase ); + sqlite3DbFree( db, ref pSubitem.zName ); + sqlite3DbFree( db, ref pSubitem.zAlias ); + pSubitem.zDatabase = null; + pSubitem.zName = null; + pSubitem.zAlias = null; + pSubitem.pSelect = null; + /* Defer deleting the Table object associated with the + ** subquery until code generation is + ** complete, since there may still exist Expr.pTab entries that + ** refer to the subquery even after flattening. Ticket #3346. + ** + ** pSubitem->pTab is always non-NULL by test restrictions and tests above. + */ + if ( ALWAYS( pSubitem.pTab != null ) ) + { + Table pTabToDel = pSubitem.pTab; + if ( pTabToDel.nRef == 1 ) + { + Parse pToplevel = sqlite3ParseToplevel( pParse ); + pTabToDel.pNextZombie = pToplevel.pZombieTab; + pToplevel.pZombieTab = pTabToDel; + } + else + { + pTabToDel.nRef--; + } + pSubitem.pTab = null; + } + + /* The following loop runs once for each term in a compound-subquery + ** flattening (as described above). If we are doing a different kind + ** of flattening - a flattening other than a compound-subquery flattening - + ** then this loop only runs once. + ** + ** This loop moves all of the FROM elements of the subquery into the + ** the FROM clause of the outer query. Before doing this, remember + ** the cursor number for the original outer query FROM element in + ** iParent. The iParent cursor will never be used. Subsequent code + ** will scan expressions looking for iParent references and replace + ** those references with expressions that resolve to the subquery FROM + ** elements we are now copying in. + */ + for ( pParent = p; pParent != null; pParent = pParent.pPrior, pSub = pSub.pPrior ) + { + int nSubSrc; + u8 jointype = 0; + pSubSrc = pSub.pSrc; /* FROM clause of subquery */ + nSubSrc = pSubSrc.nSrc; /* Number of terms in subquery FROM clause */ + pSrc = pParent.pSrc; /* FROM clause of the outer query */ + + if ( pSrc != null ) + { + Debug.Assert( pParent == p ); /* First time through the loop */ + jointype = pSubitem.jointype; + } + else + { + Debug.Assert( pParent != p ); /* 2nd and subsequent times through the loop */ + pSrc = pParent.pSrc = sqlite3SrcListAppend( db, null, null, null ); + //if ( pSrc == null ) + //{ + // //Debug.Assert( db.mallocFailed != 0 ); + // break; + //} + } + + /* The subquery uses a single slot of the FROM clause of the outer + ** query. If the subquery has more than one element in its FROM clause, + ** then expand the outer query to make space for it to hold all elements + ** of the subquery. + ** + ** Example: ** - ** SELECT count() FROM + ** SELECT * FROM tabA, (SELECT * FROM sub1, sub2), tabB; ** - ** where table is a database table, not a sub-select or view. If the query - ** does match this pattern, then a pointer to the Table object representing - ** is returned. Otherwise, 0 is returned. + ** The outer query has 3 slots in its FROM clause. One slot of the + ** outer query (the middle slot) is used by the subquery. The next + ** block of code will expand the out query to 4 slots. The middle + ** slot is expanded to two slots in order to make space for the + ** two elements in the FROM clause of the subquery. */ - static Table isSimpleCount(Select p, AggInfo pAggInfo) { - Table pTab; - Expr pExpr; - - Debug.Assert(null == p.pGroupBy); - - if (p.pWhere != null || p.pEList.nExpr != 1 - || p.pSrc.nSrc != 1 || p.pSrc.a[0].pSelect != null - ) { - return null; - } - pTab = p.pSrc.a[0].pTab; - pExpr = p.pEList.a[0].pExpr; - Debug.Assert(pTab != null && null == pTab.pSelect && pExpr != null); - - if (IsVirtual(pTab)) - return null; - if (pExpr.op != TK_AGG_FUNCTION) - return null; - if ((pAggInfo.aFunc[0].pFunc.flags & SQLITE_FUNC_COUNT) == 0) - return null; - if ((pExpr.flags & EP_Distinct) != 0) - return null; - - return pTab; + if ( nSubSrc > 1 ) + { + pParent.pSrc = pSrc = sqlite3SrcListEnlarge( db, pSrc, nSubSrc - 1, iFrom + 1 ); + //if ( db.mallocFailed != 0 ) + //{ + // break; + //} } - /* - ** If the source-list item passed as an argument was augmented with an - ** INDEXED BY clause, then try to locate the specified index. If there - ** was such a clause and the named index cannot be found, return - ** SQLITE_ERROR and leave an error in pParse. Otherwise, populate - ** pFrom.pIndex and return SQLITE_OK. + /* Transfer the FROM clause terms from the subquery into the + ** outer query. */ - static int sqlite3IndexedByLookup(Parse pParse, SrcList_item pFrom) { - if (pFrom.pTab != null && pFrom.zIndex != null && pFrom.zIndex.Length != 0) { - Table pTab = pFrom.pTab; - string zIndex = pFrom.zIndex; - Index pIdx; - for (pIdx = pTab.pIndex; - pIdx != null && !pIdx.zName.Equals(zIndex, StringComparison.OrdinalIgnoreCase); - pIdx = pIdx.pNext - ) - ; - if (null == pIdx) { - sqlite3ErrorMsg(pParse, "no such index: %s", zIndex); - pParse.checkSchema = 1; - return SQLITE_ERROR; - } - pFrom.pIndex = pIdx; - } - return SQLITE_OK; + for ( i = 0; i < nSubSrc; i++ ) + { + sqlite3IdListDelete( db, ref pSrc.a[i + iFrom].pUsing ); + pSrc.a[i + iFrom] = pSubSrc.a[i]; + pSubSrc.a[i] = new SrcList_item();//memset(pSubSrc.a[i], 0, sizeof(pSubSrc.a[i])); } + pSubitem = pSrc.a[iFrom]; // Reset for C# + pSrc.a[iFrom].jointype = jointype; - /* - ** This routine is a Walker callback for "expanding" a SELECT statement. - ** "Expanding" means to do the following: - ** - ** (1) Make sure VDBE cursor numbers have been assigned to every - ** element of the FROM clause. - ** - ** (2) Fill in the pTabList.a[].pTab fields in the SrcList that - ** defines FROM clause. When views appear in the FROM clause, - ** fill pTabList.a[].x.pSelect with a copy of the SELECT statement - ** that implements the view. A copy is made of the view's SELECT - ** statement so that we can freely modify or delete that statement - ** without worrying about messing up the presistent representation - ** of the view. + /* Now begin substituting subquery result set expressions for + ** references to the iParent in the outer query. ** - ** (3) Add terms to the WHERE clause to accomodate the NATURAL keyword - ** on joins and the ON and USING clause of joins. + ** Example: ** - ** (4) Scan the list of columns in the result set (pEList) looking - ** for instances of the "*" operator or the TABLE.* operator. - ** If found, expand each "*" to be every column in every table - ** and TABLE.* to be every column in TABLE. + ** SELECT a+5, b*10 FROM (SELECT x*3 AS a, y+10 AS b FROM t1) WHERE a>b; + ** \ \_____________ subquery __________/ / + ** \_____________________ outer query ______________________________/ ** + ** We look at every expression in the outer query and every place we see + ** "a" we substitute "x*3" and every place we see "b" we substitute "y+10". */ - static int selectExpander(Walker pWalker, Select p) { - Parse pParse = pWalker.pParse; - int i, j, k; - SrcList pTabList; - ExprList pEList; - SrcList_item pFrom; - sqlite3 db = pParse.db; - - //if ( db.mallocFailed != 0 ) - //{ - // return WRC_Abort; - //} - if (NEVER(p.pSrc == null) || (p.selFlags & SF_Expanded) != 0) { - return WRC_Prune; + pList = pParent.pEList; + for ( i = 0; i < pList.nExpr; i++ ) + { + if ( pList.a[i].zName == null ) + { + string zSpan = pList.a[i].zSpan; + if ( ALWAYS( zSpan ) ) + { + pList.a[i].zName = zSpan;// sqlite3DbStrDup( db, zSpan ); } - p.selFlags |= SF_Expanded; - pTabList = p.pSrc; - pEList = p.pEList; + } + } + substExprList( db, pParent.pEList, iParent, pSub.pEList ); + if ( isAgg ) + { + substExprList( db, pParent.pGroupBy, iParent, pSub.pEList ); + pParent.pHaving = substExpr( db, pParent.pHaving, iParent, pSub.pEList ); + } + if ( pSub.pOrderBy != null ) + { + Debug.Assert( pParent.pOrderBy == null ); + pParent.pOrderBy = pSub.pOrderBy; + pSub.pOrderBy = null; + } + else if ( pParent.pOrderBy != null ) + { + substExprList( db, pParent.pOrderBy, iParent, pSub.pEList ); + } + if ( pSub.pWhere != null ) + { + pWhere = sqlite3ExprDup( db, pSub.pWhere, 0 ); + } + else + { + pWhere = null; + } + if ( subqueryIsAgg ) + { + Debug.Assert( pParent.pHaving == null ); + pParent.pHaving = pParent.pWhere; + pParent.pWhere = pWhere; + pParent.pHaving = substExpr( db, pParent.pHaving, iParent, pSub.pEList ); + pParent.pHaving = sqlite3ExprAnd( db, pParent.pHaving, + sqlite3ExprDup( db, pSub.pHaving, 0 ) ); + Debug.Assert( pParent.pGroupBy == null ); + pParent.pGroupBy = sqlite3ExprListDup( db, pSub.pGroupBy, 0 ); + } + else + { + pParent.pWhere = substExpr( db, pParent.pWhere, iParent, pSub.pEList ); + pParent.pWhere = sqlite3ExprAnd( db, pParent.pWhere, pWhere ); + } - /* Make sure cursor numbers have been assigned to all entries in - ** the FROM clause of the SELECT statement. - */ - sqlite3SrcListAssignCursors(pParse, pTabList); + /* The flattened query is distinct if either the inner or the + ** outer query is distinct. + */ + pParent.selFlags = (u16)( pParent.selFlags | pSub.selFlags & SF_Distinct ); - /* Look up every table named in the FROM clause of the select. If - ** an entry of the FROM clause is a subquery instead of a table or view, - ** then create a transient table ure to describe the subquery. - */ - for (i = 0; i < pTabList.nSrc; i++)// pFrom++ ) - { - pFrom = pTabList.a[i]; - Table pTab; - if (pFrom.pTab != null) { - /* This statement has already been prepared. There is no need - ** to go further. */ - Debug.Assert(i == 0); - return WRC_Prune; - } - if (pFrom.zName == null) { + /* + ** SELECT ... FROM (SELECT ... LIMIT a OFFSET b) LIMIT x OFFSET y; + ** + ** One is tempted to try to add a and b to combine the limits. But this + ** does not work if either limit is negative. + */ + if ( pSub.pLimit != null ) + { + pParent.pLimit = pSub.pLimit; + pSub.pLimit = null; + } + } + + /* Finially, delete what is left of the subquery and return + ** success. + */ + sqlite3SelectDelete( db, ref pSub ); + sqlite3SelectDelete( db, ref pSub1 ); + return 1; + } +#endif //* !SQLITE_OMIT_SUBQUERY) || !SQLITE_OMIT_VIEW) */ + + /* +** Analyze the SELECT statement passed as an argument to see if it +** is a min() or max() query. Return WHERE_ORDERBY_MIN or WHERE_ORDERBY_MAX if +** it is, or 0 otherwise. At present, a query is considered to be +** a min()/max() query if: +** +** 1. There is a single object in the FROM clause. +** +** 2. There is a single expression in the result set, and it is +** either min(x) or max(x), where x is a column reference. +*/ + static u8 minMaxQuery( Select p ) + { + Expr pExpr; + ExprList pEList = p.pEList; + + if ( pEList.nExpr != 1 ) + return WHERE_ORDERBY_NORMAL; + pExpr = pEList.a[0].pExpr; + if ( pExpr.op != TK_AGG_FUNCTION ) + return 0; + if ( NEVER( ExprHasProperty( pExpr, EP_xIsSelect ) ) ) + return 0; + pEList = pExpr.x.pList; + if ( pEList == null || pEList.nExpr != 1 ) + return 0; + if ( pEList.a[0].pExpr.op != TK_AGG_COLUMN ) + return WHERE_ORDERBY_NORMAL; + Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) ); + if ( pExpr.u.zToken.Equals( "min", StringComparison.OrdinalIgnoreCase ) ) + { + return WHERE_ORDERBY_MIN; + } + else if ( pExpr.u.zToken.Equals( "max", StringComparison.OrdinalIgnoreCase ) ) + { + return WHERE_ORDERBY_MAX; + } + return WHERE_ORDERBY_NORMAL; + } + + /* + ** The select statement passed as the first argument is an aggregate query. + ** The second argment is the associated aggregate-info object. This + ** function tests if the SELECT is of the form: + ** + ** SELECT count() FROM + ** + ** where table is a database table, not a sub-select or view. If the query + ** does match this pattern, then a pointer to the Table object representing + ** is returned. Otherwise, 0 is returned. + */ + static Table isSimpleCount( Select p, AggInfo pAggInfo ) + { + Table pTab; + Expr pExpr; + + Debug.Assert( null == p.pGroupBy ); + + if ( p.pWhere != null || p.pEList.nExpr != 1 + || p.pSrc.nSrc != 1 || p.pSrc.a[0].pSelect != null + ) + { + return null; + } + pTab = p.pSrc.a[0].pTab; + pExpr = p.pEList.a[0].pExpr; + Debug.Assert( pTab != null && null == pTab.pSelect && pExpr != null ); + + if ( IsVirtual( pTab ) ) + return null; + if ( pExpr.op != TK_AGG_FUNCTION ) + return null; + if ( ( pAggInfo.aFunc[0].pFunc.flags & SQLITE_FUNC_COUNT ) == 0 ) + return null; + if ( ( pExpr.flags & EP_Distinct ) != 0 ) + return null; + + return pTab; + } + + /* + ** If the source-list item passed as an argument was augmented with an + ** INDEXED BY clause, then try to locate the specified index. If there + ** was such a clause and the named index cannot be found, return + ** SQLITE_ERROR and leave an error in pParse. Otherwise, populate + ** pFrom.pIndex and return SQLITE_OK. + */ + static int sqlite3IndexedByLookup( Parse pParse, SrcList_item pFrom ) + { + if ( pFrom.pTab != null && pFrom.zIndex != null && pFrom.zIndex.Length != 0 ) + { + Table pTab = pFrom.pTab; + string zIndex = pFrom.zIndex; + Index pIdx; + for ( pIdx = pTab.pIndex; + pIdx != null && !pIdx.zName.Equals( zIndex, StringComparison.OrdinalIgnoreCase ); + pIdx = pIdx.pNext + ) + ; + if ( null == pIdx ) + { + sqlite3ErrorMsg( pParse, "no such index: %s", zIndex ); + pParse.checkSchema = 1; + return SQLITE_ERROR; + } + pFrom.pIndex = pIdx; + } + return SQLITE_OK; + } + + /* + ** This routine is a Walker callback for "expanding" a SELECT statement. + ** "Expanding" means to do the following: + ** + ** (1) Make sure VDBE cursor numbers have been assigned to every + ** element of the FROM clause. + ** + ** (2) Fill in the pTabList.a[].pTab fields in the SrcList that + ** defines FROM clause. When views appear in the FROM clause, + ** fill pTabList.a[].x.pSelect with a copy of the SELECT statement + ** that implements the view. A copy is made of the view's SELECT + ** statement so that we can freely modify or delete that statement + ** without worrying about messing up the presistent representation + ** of the view. + ** + ** (3) Add terms to the WHERE clause to accomodate the NATURAL keyword + ** on joins and the ON and USING clause of joins. + ** + ** (4) Scan the list of columns in the result set (pEList) looking + ** for instances of the "*" operator or the TABLE.* operator. + ** If found, expand each "*" to be every column in every table + ** and TABLE.* to be every column in TABLE. + ** + */ + static int selectExpander( Walker pWalker, Select p ) + { + Parse pParse = pWalker.pParse; + int i, j, k; + SrcList pTabList; + ExprList pEList; + SrcList_item pFrom; + sqlite3 db = pParse.db; + + //if ( db.mallocFailed != 0 ) + //{ + // return WRC_Abort; + //} + if ( NEVER( p.pSrc == null ) || ( p.selFlags & SF_Expanded ) != 0 ) + { + return WRC_Prune; + } + p.selFlags |= SF_Expanded; + pTabList = p.pSrc; + pEList = p.pEList; + + /* Make sure cursor numbers have been assigned to all entries in + ** the FROM clause of the SELECT statement. + */ + sqlite3SrcListAssignCursors( pParse, pTabList ); + + /* Look up every table named in the FROM clause of the select. If + ** an entry of the FROM clause is a subquery instead of a table or view, + ** then create a transient table ure to describe the subquery. + */ + for ( i = 0; i < pTabList.nSrc; i++ )// pFrom++ ) + { + pFrom = pTabList.a[i]; + Table pTab; + if ( pFrom.pTab != null ) + { + /* This statement has already been prepared. There is no need + ** to go further. */ + Debug.Assert( i == 0 ); + return WRC_Prune; + } + if ( pFrom.zName == null ) + { #if !SQLITE_OMIT_SUBQUERY - Select pSel = pFrom.pSelect; - /* A sub-query in the FROM clause of a SELECT */ - Debug.Assert(pSel != null); - Debug.Assert(pFrom.pTab == null); - sqlite3WalkSelect(pWalker, pSel); - pFrom.pTab = pTab = new Table();// sqlite3DbMallocZero( db, sizeof( Table ) ); - if (pTab == null) - return WRC_Abort; - pTab.nRef = 1; - pTab.zName = sqlite3MPrintf(db, "sqlite_subquery_%p_", pTab); - while (pSel.pPrior != null) { - pSel = pSel.pPrior; - } - selectColumnsFromExprList(pParse, pSel.pEList, ref pTab.nCol, ref pTab.aCol); - pTab.iPKey = -1; - pTab.nRowEst = 1000000; - pTab.tabFlags |= TF_Ephemeral; + Select pSel = pFrom.pSelect; + /* A sub-query in the FROM clause of a SELECT */ + Debug.Assert( pSel != null ); + Debug.Assert( pFrom.pTab == null ); + sqlite3WalkSelect( pWalker, pSel ); + pFrom.pTab = pTab = new Table();// sqlite3DbMallocZero( db, sizeof( Table ) ); + if ( pTab == null ) + return WRC_Abort; + pTab.nRef = 1; + pTab.zName = sqlite3MPrintf( db, "sqlite_subquery_%p_", pTab ); + while ( pSel.pPrior != null ) + { + pSel = pSel.pPrior; + } + selectColumnsFromExprList( pParse, pSel.pEList, ref pTab.nCol, ref pTab.aCol ); + pTab.iPKey = -1; + pTab.nRowEst = 1000000; + pTab.tabFlags |= TF_Ephemeral; #endif - } else { - /* An ordinary table or view name in the FROM clause */ - Debug.Assert(pFrom.pTab == null); - pFrom.pTab = pTab = - sqlite3LocateTable(pParse, 0, pFrom.zName, pFrom.zDatabase); - if (pTab == null) - return WRC_Abort; - pTab.nRef++; + } + else + { + /* An ordinary table or view name in the FROM clause */ + Debug.Assert( pFrom.pTab == null ); + pFrom.pTab = pTab = + sqlite3LocateTable( pParse, 0, pFrom.zName, pFrom.zDatabase ); + if ( pTab == null ) + return WRC_Abort; + pTab.nRef++; #if !(SQLITE_OMIT_VIEW) || !(SQLITE_OMIT_VIRTUALTABLE) - if (pTab.pSelect != null || IsVirtual(pTab)) { - /* We reach here if the named table is a really a view */ - if (sqlite3ViewGetColumnNames(pParse, pTab) != 0) - return WRC_Abort; - - pFrom.pSelect = sqlite3SelectDup(db, pTab.pSelect, 0); - sqlite3WalkSelect(pWalker, pFrom.pSelect); - } + if ( pTab.pSelect != null || IsVirtual( pTab ) ) + { + /* We reach here if the named table is a really a view */ + if ( sqlite3ViewGetColumnNames( pParse, pTab ) != 0 ) + return WRC_Abort; + + pFrom.pSelect = sqlite3SelectDup( db, pTab.pSelect, 0 ); + sqlite3WalkSelect( pWalker, pFrom.pSelect ); + } #endif - } - /* Locate the index named by the INDEXED BY clause, if any. */ - if (sqlite3IndexedByLookup(pParse, pFrom) != 0) { - return WRC_Abort; - } - } + } + /* Locate the index named by the INDEXED BY clause, if any. */ + if ( sqlite3IndexedByLookup( pParse, pFrom ) != 0 ) + { + return WRC_Abort; + } + } - /* Process NATURAL keywords, and ON and USING clauses of joins. + /* Process NATURAL keywords, and ON and USING clauses of joins. + */ + if ( /* db.mallocFailed != 0 || */ sqliteProcessJoin( pParse, p ) != 0 ) + { + return WRC_Abort; + } + + /* For every "*" that occurs in the column list, insert the names of + ** all columns in all tables. And for every TABLE.* insert the names + ** of all columns in TABLE. The parser inserted a special expression + ** with the TK_ALL operator for each "*" that it found in the column list. + ** The following code just has to locate the TK_ALL expressions and expand + ** each one to the list of all columns in all tables. + ** + ** The first loop just checks to see if there are any "*" operators + ** that need expanding. + */ + for ( k = 0; k < pEList.nExpr; k++ ) + { + Expr pE = pEList.a[k].pExpr; + if ( pE.op == TK_ALL ) + break; + Debug.Assert( pE.op != TK_DOT || pE.pRight != null ); + Debug.Assert( pE.op != TK_DOT || ( pE.pLeft != null && pE.pLeft.op == TK_ID ) ); + if ( pE.op == TK_DOT && pE.pRight.op == TK_ALL ) + break; + } + if ( k < pEList.nExpr ) + { + /* + ** If we get here it means the result set contains one or more "*" + ** operators that need to be expanded. Loop through each expression + ** in the result set and expand them one by one. + */ + ExprList_item[] a = pEList.a; + ExprList pNew = null; + int flags = pParse.db.flags; + bool longNames = ( flags & SQLITE_FullColNames ) != 0 + && ( flags & SQLITE_ShortColNames ) == 0; + + for ( k = 0; k < pEList.nExpr; k++ ) + { + Expr pE = a[k].pExpr; + Debug.Assert( pE.op != TK_DOT || pE.pRight != null ); + if ( pE.op != TK_ALL && ( pE.op != TK_DOT || pE.pRight.op != TK_ALL ) ) + { + /* This particular expression does not need to be expanded. */ - if ( /* db.mallocFailed != 0 || */ sqliteProcessJoin(pParse, p) != 0) { - return WRC_Abort; + pNew = sqlite3ExprListAppend( pParse, pNew, a[k].pExpr ); + if ( pNew != null ) + { + pNew.a[pNew.nExpr - 1].zName = a[k].zName; + pNew.a[pNew.nExpr - 1].zSpan = a[k].zSpan; + a[k].zName = null; + a[k].zSpan = null; } - - /* For every "*" that occurs in the column list, insert the names of - ** all columns in all tables. And for every TABLE.* insert the names - ** of all columns in TABLE. The parser inserted a special expression - ** with the TK_ALL operator for each "*" that it found in the column list. - ** The following code just has to locate the TK_ALL expressions and expand - ** each one to the list of all columns in all tables. - ** - ** The first loop just checks to see if there are any "*" operators - ** that need expanding. - */ - for (k = 0; k < pEList.nExpr; k++) { - Expr pE = pEList.a[k].pExpr; - if (pE.op == TK_ALL) - break; - Debug.Assert(pE.op != TK_DOT || pE.pRight != null); - Debug.Assert(pE.op != TK_DOT || (pE.pLeft != null && pE.pLeft.op == TK_ID)); - if (pE.op == TK_DOT && pE.pRight.op == TK_ALL) - break; + a[k].pExpr = null; + } + else + { + /* This expression is a "*" or a "TABLE.*" and needs to be + ** expanded. */ + int tableSeen = 0; /* Set to 1 when TABLE matches */ + string zTName; /* text of name of TABLE */ + if ( pE.op == TK_DOT ) + { + Debug.Assert( pE.pLeft != null ); + Debug.Assert( !ExprHasProperty( pE.pLeft, EP_IntValue ) ); + zTName = pE.pLeft.u.zToken; } - if (k < pEList.nExpr) { - /* - ** If we get here it means the result set contains one or more "*" - ** operators that need to be expanded. Loop through each expression - ** in the result set and expand them one by one. + else + { + zTName = null; + } + for ( i = 0; i < pTabList.nSrc; i++ )//, pFrom++ ) + { + pFrom = pTabList.a[i]; + Table pTab = pFrom.pTab; + string zTabName = pFrom.zAlias; + if ( zTabName == null ) + { + zTabName = pTab.zName; + } + ///if ( db.mallocFailed != 0 ) break; + if ( zTName != null && !zTName.Equals( zTabName, StringComparison.OrdinalIgnoreCase ) ) + { + continue; + } + tableSeen = 1; + for ( j = 0; j < pTab.nCol; j++ ) + { + Expr pExpr, pRight; + string zName = pTab.aCol[j].zName; + string zColname; /* The computed column name */ + string zToFree; /* Malloced string that needs to be freed */ + Token sColname = new Token(); /* Computed column name as a token */ + + /* If a column is marked as 'hidden' (currently only possible + ** for virtual tables), do not include it in the expanded + ** result-set list. */ - ExprList_item[] a = pEList.a; - ExprList pNew = null; - int flags = pParse.db.flags; - bool longNames = (flags & SQLITE_FullColNames) != 0 - && (flags & SQLITE_ShortColNames) == 0; - - for (k = 0; k < pEList.nExpr; k++) { - Expr pE = a[k].pExpr; - Debug.Assert(pE.op != TK_DOT || pE.pRight != null); - if (pE.op != TK_ALL && (pE.op != TK_DOT || pE.pRight.op != TK_ALL)) { - /* This particular expression does not need to be expanded. - */ - pNew = sqlite3ExprListAppend(pParse, pNew, a[k].pExpr); - if (pNew != null) { - pNew.a[pNew.nExpr - 1].zName = a[k].zName; - pNew.a[pNew.nExpr - 1].zSpan = a[k].zSpan; - a[k].zName = null; - a[k].zSpan = null; - } - a[k].pExpr = null; - } else { - /* This expression is a "*" or a "TABLE.*" and needs to be - ** expanded. */ - int tableSeen = 0; /* Set to 1 when TABLE matches */ - string zTName; /* text of name of TABLE */ - if (pE.op == TK_DOT) { - Debug.Assert(pE.pLeft != null); - Debug.Assert(!ExprHasProperty(pE.pLeft, EP_IntValue)); - zTName = pE.pLeft.u.zToken; - } else { - zTName = null; - } - for (i = 0; i < pTabList.nSrc; i++)//, pFrom++ ) - { - pFrom = pTabList.a[i]; - Table pTab = pFrom.pTab; - string zTabName = pFrom.zAlias; - if (zTabName == null) { - zTabName = pTab.zName; - } - ///if ( db.mallocFailed != 0 ) break; - if (zTName != null && !zTName.Equals(zTabName, StringComparison.OrdinalIgnoreCase)) { - continue; - } - tableSeen = 1; - for (j = 0; j < pTab.nCol; j++) { - Expr pExpr, pRight; - string zName = pTab.aCol[j].zName; - string zColname; /* The computed column name */ - string zToFree; /* Malloced string that needs to be freed */ - Token sColname = new Token(); /* Computed column name as a token */ - - /* If a column is marked as 'hidden' (currently only possible - ** for virtual tables), do not include it in the expanded - ** result-set list. - */ - if (IsHiddenColumn(pTab.aCol[j])) { - Debug.Assert(IsVirtual(pTab)); - continue; - } - - if (i > 0 && (zTName == null || zTName.Length == 0)) { - int iDummy = 0; - if ((pFrom.jointype & JT_NATURAL) != 0 - && tableAndColumnIndex(pTabList, i, zName, ref iDummy, ref iDummy) != 0 - ) { - /* In a NATURAL join, omit the join columns from the - ** table to the right of the join */ - continue; - } - if (sqlite3IdListIndex(pFrom.pUsing, zName) >= 0) { - /* In a join with a USING clause, omit columns in the - ** using clause from the table on the right. */ - continue; - } - } - pRight = sqlite3Expr(db, TK_ID, zName); - zColname = zName; - zToFree = ""; - if (longNames || pTabList.nSrc > 1) { - Expr pLeft; - pLeft = sqlite3Expr(db, TK_ID, zTabName); - pExpr = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0); - if (longNames) { - zColname = sqlite3MPrintf(db, "%s.%s", zTabName, zName); - zToFree = zColname; - } - } else { - pExpr = pRight; - } - pNew = sqlite3ExprListAppend(pParse, pNew, pExpr); - sColname.z = zColname; - sColname.n = sqlite3Strlen30(zColname); - sqlite3ExprListSetName(pParse, pNew, sColname, 0); - sqlite3DbFree(db, ref zToFree); - } - } - if (tableSeen == 0) { - if (zTName != null) { - sqlite3ErrorMsg(pParse, "no such table: %s", zTName); - } else { - sqlite3ErrorMsg(pParse, "no tables specified"); - } - } - } + if ( IsHiddenColumn( pTab.aCol[j] ) ) + { + Debug.Assert( IsVirtual( pTab ) ); + continue; + } + + if ( i > 0 && ( zTName == null || zTName.Length == 0 ) ) + { + int iDummy = 0; + if ( ( pFrom.jointype & JT_NATURAL ) != 0 + && tableAndColumnIndex( pTabList, i, zName, ref iDummy, ref iDummy ) != 0 + ) + { + /* In a NATURAL join, omit the join columns from the + ** table to the right of the join */ + continue; + } + if ( sqlite3IdListIndex( pFrom.pUsing, zName ) >= 0 ) + { + /* In a join with a USING clause, omit columns in the + ** using clause from the table on the right. */ + continue; + } + } + pRight = sqlite3Expr( db, TK_ID, zName ); + zColname = zName; + zToFree = ""; + if ( longNames || pTabList.nSrc > 1 ) + { + Expr pLeft; + pLeft = sqlite3Expr( db, TK_ID, zTabName ); + pExpr = sqlite3PExpr( pParse, TK_DOT, pLeft, pRight, 0 ); + if ( longNames ) + { + zColname = sqlite3MPrintf( db, "%s.%s", zTabName, zName ); + zToFree = zColname; + } } - sqlite3ExprListDelete(db, ref pEList); - p.pEList = pNew; + else + { + pExpr = pRight; + } + pNew = sqlite3ExprListAppend( pParse, pNew, pExpr ); + sColname.z = zColname; + sColname.n = sqlite3Strlen30( zColname ); + sqlite3ExprListSetName( pParse, pNew, sColname, 0 ); + sqlite3DbFree( db, ref zToFree ); + } } - //#if SQLITE_MAX_COLUMN - if (p.pEList != null && p.pEList.nExpr > db.aLimit[SQLITE_LIMIT_COLUMN]) { - sqlite3ErrorMsg(pParse, "too many columns in result set"); + if ( tableSeen == 0 ) + { + if ( zTName != null ) + { + sqlite3ErrorMsg( pParse, "no such table: %s", zTName ); + } + else + { + sqlite3ErrorMsg( pParse, "no tables specified" ); + } } - //#endif - return WRC_Continue; + } } + sqlite3ExprListDelete( db, ref pEList ); + p.pEList = pNew; + } +//#if SQLITE_MAX_COLUMN + if ( p.pEList != null && p.pEList.nExpr > db.aLimit[SQLITE_LIMIT_COLUMN] ) + { + sqlite3ErrorMsg( pParse, "too many columns in result set" ); + } +//#endif + return WRC_Continue; + } - /* - ** No-op routine for the parse-tree walker. - ** - ** When this routine is the Walker.xExprCallback then expression trees - ** are walked without any actions being taken at each node. Presumably, - ** when this routine is used for Walker.xExprCallback then - ** Walker.xSelectCallback is set to do something useful for every - ** subquery in the parser tree. - */ - static int exprWalkNoop(Walker NotUsed, ref Expr NotUsed2) { - UNUSED_PARAMETER2(NotUsed, NotUsed2); - return WRC_Continue; - } + /* + ** No-op routine for the parse-tree walker. + ** + ** When this routine is the Walker.xExprCallback then expression trees + ** are walked without any actions being taken at each node. Presumably, + ** when this routine is used for Walker.xExprCallback then + ** Walker.xSelectCallback is set to do something useful for every + ** subquery in the parser tree. + */ + static int exprWalkNoop( Walker NotUsed, ref Expr NotUsed2 ) + { + UNUSED_PARAMETER2( NotUsed, NotUsed2 ); + return WRC_Continue; + } - /* - ** This routine "expands" a SELECT statement and all of its subqueries. - ** For additional information on what it means to "expand" a SELECT - ** statement, see the comment on the selectExpand worker callback above. - ** - ** Expanding a SELECT statement is the first step in processing a - ** SELECT statement. The SELECT statement must be expanded before - ** name resolution is performed. - ** - ** If anything goes wrong, an error message is written into pParse. - ** The calling function can detect the problem by looking at pParse.nErr - ** and/or pParse.db.mallocFailed. - */ - static void sqlite3SelectExpand(Parse pParse, Select pSelect) { - Walker w = new Walker(); - w.xSelectCallback = selectExpander; - w.xExprCallback = exprWalkNoop; - w.pParse = pParse; - sqlite3WalkSelect(w, pSelect); + /* + ** This routine "expands" a SELECT statement and all of its subqueries. + ** For additional information on what it means to "expand" a SELECT + ** statement, see the comment on the selectExpand worker callback above. + ** + ** Expanding a SELECT statement is the first step in processing a + ** SELECT statement. The SELECT statement must be expanded before + ** name resolution is performed. + ** + ** If anything goes wrong, an error message is written into pParse. + ** The calling function can detect the problem by looking at pParse.nErr + ** and/or pParse.db.mallocFailed. + */ + static void sqlite3SelectExpand( Parse pParse, Select pSelect ) + { + Walker w = new Walker(); + w.xSelectCallback = selectExpander; + w.xExprCallback = exprWalkNoop; + w.pParse = pParse; + sqlite3WalkSelect( w, pSelect ); + } + + +#if !SQLITE_OMIT_SUBQUERY + /* +** This is a Walker.xSelectCallback callback for the sqlite3SelectTypeInfo() +** interface. +** +** For each FROM-clause subquery, add Column.zType and Column.zColl +** information to the Table ure that represents the result set +** of that subquery. +** +** The Table ure that represents the result set was coned +** by selectExpander() but the type and collation information was omitted +** at that point because identifiers had not yet been resolved. This +** routine is called after identifier resolution. +*/ + static int selectAddSubqueryTypeInfo( Walker pWalker, Select p ) + { + Parse pParse; + int i; + SrcList pTabList; + SrcList_item pFrom; + + Debug.Assert( ( p.selFlags & SF_Resolved ) != 0 ); + if ( ( p.selFlags & SF_HasTypeInfo ) == 0 ) + { + p.selFlags |= SF_HasTypeInfo; + pParse = pWalker.pParse; + pTabList = p.pSrc; + for ( i = 0; i < pTabList.nSrc; i++ )//, pFrom++ ) + { + pFrom = pTabList.a[i]; + Table pTab = pFrom.pTab; + if ( ALWAYS( pTab != null ) && ( pTab.tabFlags & TF_Ephemeral ) != 0 ) + { + /* A sub-query in the FROM clause of a SELECT */ + Select pSel = pFrom.pSelect; + Debug.Assert( pSel != null ); + while ( pSel.pPrior != null ) + pSel = pSel.pPrior; + selectAddColumnTypeAndCollation( pParse, pTab.nCol, pTab.aCol, pSel ); + } } + } + return WRC_Continue; + } +#endif + + + /* +** This routine adds datatype and collating sequence information to +** the Table ures of all FROM-clause subqueries in a +** SELECT statement. +** +** Use this routine after name resolution. +*/ + static void sqlite3SelectAddTypeInfo( Parse pParse, Select pSelect ) + { +#if !SQLITE_OMIT_SUBQUERY + Walker w = new Walker(); + w.xSelectCallback = selectAddSubqueryTypeInfo; + w.xExprCallback = exprWalkNoop; + w.pParse = pParse; + sqlite3WalkSelect( w, pSelect ); +#endif + } -#if !SQLITE_OMIT_SUBQUERY - /* - ** This is a Walker.xSelectCallback callback for the sqlite3SelectTypeInfo() - ** interface. + /* + ** This routine sets of a SELECT statement for processing. The + ** following is accomplished: ** - ** For each FROM-clause subquery, add Column.zType and Column.zColl - ** information to the Table ure that represents the result set - ** of that subquery. + ** * VDBE VdbeCursor numbers are assigned to all FROM-clause terms. + ** * Ephemeral Table objects are created for all FROM-clause subqueries. + ** * ON and USING clauses are shifted into WHERE statements + ** * Wildcards "*" and "TABLE.*" in result sets are expanded. + ** * Identifiers in expression are matched to tables. ** - ** The Table ure that represents the result set was coned - ** by selectExpander() but the type and collation information was omitted - ** at that point because identifiers had not yet been resolved. This - ** routine is called after identifier resolution. + ** This routine acts recursively on all subqueries within the SELECT. */ - static int selectAddSubqueryTypeInfo(Walker pWalker, Select p) { - Parse pParse; - int i; - SrcList pTabList; - SrcList_item pFrom; - - Debug.Assert((p.selFlags & SF_Resolved) != 0); - if ((p.selFlags & SF_HasTypeInfo) == 0) { - p.selFlags |= SF_HasTypeInfo; - pParse = pWalker.pParse; - pTabList = p.pSrc; - for (i = 0; i < pTabList.nSrc; i++)//, pFrom++ ) - { - pFrom = pTabList.a[i]; - Table pTab = pFrom.pTab; - if (ALWAYS(pTab != null) && (pTab.tabFlags & TF_Ephemeral) != 0) { - /* A sub-query in the FROM clause of a SELECT */ - Select pSel = pFrom.pSelect; - Debug.Assert(pSel != null); - while (pSel.pPrior != null) - pSel = pSel.pPrior; - selectAddColumnTypeAndCollation(pParse, pTab.nCol, pTab.aCol, pSel); - } - } - } - return WRC_Continue; - } -#endif - + static void sqlite3SelectPrep( + Parse pParse, /* The parser context */ + Select p, /* The SELECT statement being coded. */ + NameContext pOuterNC /* Name context for container */ + ) + { + if ( NEVER( p == null ) ) + return; + //sqlite3 db = pParse.db; + if ( ( p.selFlags & SF_HasTypeInfo ) != 0 ) + return; + sqlite3SelectExpand( pParse, p ); + if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) + return; + sqlite3ResolveSelectNames( pParse, p, pOuterNC ); + if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) + return; + sqlite3SelectAddTypeInfo( pParse, p ); + } - /* - ** This routine adds datatype and collating sequence information to - ** the Table ures of all FROM-clause subqueries in a - ** SELECT statement. + /* + ** Reset the aggregate accumulator. ** - ** Use this routine after name resolution. + ** The aggregate accumulator is a set of memory cells that hold + ** intermediate results while calculating an aggregate. This + ** routine simply stores NULLs in all of those memory cells. */ - static void sqlite3SelectAddTypeInfo(Parse pParse, Select pSelect) { -#if !SQLITE_OMIT_SUBQUERY - Walker w = new Walker(); - w.xSelectCallback = selectAddSubqueryTypeInfo; - w.xExprCallback = exprWalkNoop; - w.pParse = pParse; - sqlite3WalkSelect(w, pSelect); -#endif + static void resetAccumulator( Parse pParse, AggInfo pAggInfo ) + { + Vdbe v = pParse.pVdbe; + int i; + AggInfo_func pFunc; + if ( pAggInfo.nFunc + pAggInfo.nColumn == 0 ) + { + return; + } + for ( i = 0; i < pAggInfo.nColumn; i++ ) + { + sqlite3VdbeAddOp2( v, OP_Null, 0, pAggInfo.aCol[i].iMem ); + } + for ( i = 0; i < pAggInfo.nFunc; i++ ) + {//, pFunc++){ + pFunc = pAggInfo.aFunc[i]; + sqlite3VdbeAddOp2( v, OP_Null, 0, pFunc.iMem ); + if ( pFunc.iDistinct >= 0 ) + { + Expr pE = pFunc.pExpr; + Debug.Assert( !ExprHasProperty( pE, EP_xIsSelect ) ); + if ( pE.x.pList == null || pE.x.pList.nExpr != 1 ) + { + sqlite3ErrorMsg( pParse, "DISTINCT aggregates must have exactly one " + + "argument" ); + pFunc.iDistinct = -1; + } + else + { + KeyInfo pKeyInfo = keyInfoFromExprList( pParse, pE.x.pList ); + sqlite3VdbeAddOp4( v, OP_OpenEphemeral, pFunc.iDistinct, 0, 0, + pKeyInfo, P4_KEYINFO_HANDOFF ); + } } + } + } + /* + ** Invoke the OP_AggFinalize opcode for every aggregate function + ** in the AggInfo structure. + */ + static void finalizeAggFunctions( Parse pParse, AggInfo pAggInfo ) + { + Vdbe v = pParse.pVdbe; + int i; + AggInfo_func pF; + for ( i = 0; i < pAggInfo.nFunc; i++ ) + {//, pF++){ + pF = pAggInfo.aFunc[i]; + ExprList pList = pF.pExpr.x.pList; + Debug.Assert( !ExprHasProperty( pF.pExpr, EP_xIsSelect ) ); + sqlite3VdbeAddOp4( v, OP_AggFinal, pF.iMem, pList != null ? pList.nExpr : 0, 0, + pF.pFunc, P4_FUNCDEF ); + } + } - /* - ** This routine sets of a SELECT statement for processing. The - ** following is accomplished: - ** - ** * VDBE VdbeCursor numbers are assigned to all FROM-clause terms. - ** * Ephemeral Table objects are created for all FROM-clause subqueries. - ** * ON and USING clauses are shifted into WHERE statements - ** * Wildcards "*" and "TABLE.*" in result sets are expanded. - ** * Identifiers in expression are matched to tables. - ** - ** This routine acts recursively on all subqueries within the SELECT. - */ - static void sqlite3SelectPrep( - Parse pParse, /* The parser context */ - Select p, /* The SELECT statement being coded. */ - NameContext pOuterNC /* Name context for container */ - ) { - if (NEVER(p == null)) - return; - //sqlite3 db = pParse.db; - if ((p.selFlags & SF_HasTypeInfo) != 0) - return; - sqlite3SelectExpand(pParse, p); - if (pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) - return; - sqlite3ResolveSelectNames(pParse, p, pOuterNC); - if (pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) - return; - sqlite3SelectAddTypeInfo(pParse, p); + /* + ** Update the accumulator memory cells for an aggregate based on + ** the current cursor position. + */ + static void updateAccumulator( Parse pParse, AggInfo pAggInfo ) + { + Vdbe v = pParse.pVdbe; + int i; + AggInfo_func pF; + AggInfo_col pC; + + pAggInfo.directMode = 1; + sqlite3ExprCacheClear( pParse ); + for ( i = 0; i < pAggInfo.nFunc; i++ ) + {//, pF++){ + pF = pAggInfo.aFunc[i]; + int nArg; + int addrNext = 0; + int regAgg; + Debug.Assert( !ExprHasProperty( pF.pExpr, EP_xIsSelect ) ); + ExprList pList = pF.pExpr.x.pList; + if ( pList != null ) + { + nArg = pList.nExpr; + regAgg = sqlite3GetTempRange( pParse, nArg ); + sqlite3ExprCodeExprList( pParse, pList, regAgg, true ); } - - /* - ** Reset the aggregate accumulator. - ** - ** The aggregate accumulator is a set of memory cells that hold - ** intermediate results while calculating an aggregate. This - ** routine simply stores NULLs in all of those memory cells. - */ - static void resetAccumulator(Parse pParse, AggInfo pAggInfo) { - Vdbe v = pParse.pVdbe; - int i; - AggInfo_func pFunc; - if (pAggInfo.nFunc + pAggInfo.nColumn == 0) { - return; - } - for (i = 0; i < pAggInfo.nColumn; i++) { - sqlite3VdbeAddOp2(v, OP_Null, 0, pAggInfo.aCol[i].iMem); - } - for (i = 0; i < pAggInfo.nFunc; i++) {//, pFunc++){ - pFunc = pAggInfo.aFunc[i]; - sqlite3VdbeAddOp2(v, OP_Null, 0, pFunc.iMem); - if (pFunc.iDistinct >= 0) { - Expr pE = pFunc.pExpr; - Debug.Assert(!ExprHasProperty(pE, EP_xIsSelect)); - if (pE.x.pList == null || pE.x.pList.nExpr != 1) { - sqlite3ErrorMsg(pParse, "DISTINCT aggregates must have exactly one " + - "argument"); - pFunc.iDistinct = -1; - } else { - KeyInfo pKeyInfo = keyInfoFromExprList(pParse, pE.x.pList); - sqlite3VdbeAddOp4(v, OP_OpenEphemeral, pFunc.iDistinct, 0, 0, - pKeyInfo, P4_KEYINFO_HANDOFF); - } - } - } + else + { + nArg = 0; + regAgg = 0; } - - /* - ** Invoke the OP_AggFinalize opcode for every aggregate function - ** in the AggInfo structure. - */ - static void finalizeAggFunctions(Parse pParse, AggInfo pAggInfo) { - Vdbe v = pParse.pVdbe; - int i; - AggInfo_func pF; - for (i = 0; i < pAggInfo.nFunc; i++) {//, pF++){ - pF = pAggInfo.aFunc[i]; - ExprList pList = pF.pExpr.x.pList; - Debug.Assert(!ExprHasProperty(pF.pExpr, EP_xIsSelect)); - sqlite3VdbeAddOp4(v, OP_AggFinal, pF.iMem, pList != null ? pList.nExpr : 0, 0, - pF.pFunc, P4_FUNCDEF); - } + if ( pF.iDistinct >= 0 ) + { + addrNext = sqlite3VdbeMakeLabel( v ); + Debug.Assert( nArg == 1 ); + codeDistinct( pParse, pF.iDistinct, addrNext, 1, regAgg ); } - - /* - ** Update the accumulator memory cells for an aggregate based on - ** the current cursor position. - */ - static void updateAccumulator(Parse pParse, AggInfo pAggInfo) { - Vdbe v = pParse.pVdbe; - int i; - AggInfo_func pF; - AggInfo_col pC; - - pAggInfo.directMode = 1; - sqlite3ExprCacheClear(pParse); - for (i = 0; i < pAggInfo.nFunc; i++) {//, pF++){ - pF = pAggInfo.aFunc[i]; - int nArg; - int addrNext = 0; - int regAgg; - Debug.Assert(!ExprHasProperty(pF.pExpr, EP_xIsSelect)); - ExprList pList = pF.pExpr.x.pList; - if (pList != null) { - nArg = pList.nExpr; - regAgg = sqlite3GetTempRange(pParse, nArg); - sqlite3ExprCodeExprList(pParse, pList, regAgg, true); - } else { - nArg = 0; - regAgg = 0; - } - if (pF.iDistinct >= 0) { - addrNext = sqlite3VdbeMakeLabel(v); - Debug.Assert(nArg == 1); - codeDistinct(pParse, pF.iDistinct, addrNext, 1, regAgg); - } - if ((pF.pFunc.flags & SQLITE_FUNC_NEEDCOLL) != 0) { - CollSeq pColl = null; - ExprList_item pItem; - int j; - Debug.Assert(pList != null); /* pList!=0 if pF->pFunc has NEEDCOLL */ - for (j = 0; pColl == null && j < nArg; j++) {//, pItem++){ - pItem = pList.a[j]; - pColl = sqlite3ExprCollSeq(pParse, pItem.pExpr); - } - if (pColl == null) { - pColl = pParse.db.pDfltColl; - } - sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, pColl, P4_COLLSEQ); - } - sqlite3VdbeAddOp4(v, OP_AggStep, 0, regAgg, pF.iMem, - pF.pFunc, P4_FUNCDEF); - sqlite3VdbeChangeP5(v, (u8)nArg); - sqlite3ExprCacheAffinityChange(pParse, regAgg, nArg); - sqlite3ReleaseTempRange(pParse, regAgg, nArg); - if (addrNext != 0) { - sqlite3VdbeResolveLabel(v, addrNext); - sqlite3ExprCacheClear(pParse); - } - } - - /* Before populating the accumulator registers, clear the column cache. - ** Otherwise, if any of the required column values are already present - ** in registers, sqlite3ExprCode() may use OP_SCopy to copy the value - ** to pC->iMem. But by the time the value is used, the original register - ** may have been used, invalidating the underlying buffer holding the - ** text or blob value. See ticket [883034dcb5]. - ** - ** Another solution would be to change the OP_SCopy used to copy cached - ** values to an OP_Copy. - */ - sqlite3ExprCacheClear(pParse); - for (i = 0; i < pAggInfo.nAccumulator; i++)//, pC++) - { - pC = pAggInfo.aCol[i]; - sqlite3ExprCode(pParse, pC.pExpr, pC.iMem); - } - pAggInfo.directMode = 0; - sqlite3ExprCacheClear(pParse); + if ( ( pF.pFunc.flags & SQLITE_FUNC_NEEDCOLL ) != 0 ) + { + CollSeq pColl = null; + ExprList_item pItem; + int j; + Debug.Assert( pList != null ); /* pList!=0 if pF->pFunc has NEEDCOLL */ + for ( j = 0; pColl == null && j < nArg; j++ ) + {//, pItem++){ + pItem = pList.a[j]; + pColl = sqlite3ExprCollSeq( pParse, pItem.pExpr ); + } + if ( pColl == null ) + { + pColl = pParse.db.pDfltColl; + } + sqlite3VdbeAddOp4( v, OP_CollSeq, 0, 0, 0, pColl, P4_COLLSEQ ); } + sqlite3VdbeAddOp4( v, OP_AggStep, 0, regAgg, pF.iMem, + pF.pFunc, P4_FUNCDEF ); + sqlite3VdbeChangeP5( v, (u8)nArg ); + sqlite3ExprCacheAffinityChange( pParse, regAgg, nArg ); + sqlite3ReleaseTempRange( pParse, regAgg, nArg ); + if ( addrNext != 0 ) + { + sqlite3VdbeResolveLabel( v, addrNext ); + sqlite3ExprCacheClear( pParse ); + } + } + + /* Before populating the accumulator registers, clear the column cache. + ** Otherwise, if any of the required column values are already present + ** in registers, sqlite3ExprCode() may use OP_SCopy to copy the value + ** to pC->iMem. But by the time the value is used, the original register + ** may have been used, invalidating the underlying buffer holding the + ** text or blob value. See ticket [883034dcb5]. + ** + ** Another solution would be to change the OP_SCopy used to copy cached + ** values to an OP_Copy. + */ + sqlite3ExprCacheClear( pParse ); + for ( i = 0; i < pAggInfo.nAccumulator; i++ )//, pC++) + { + pC = pAggInfo.aCol[i]; + sqlite3ExprCode( pParse, pC.pExpr, pC.iMem ); + } + pAggInfo.directMode = 0; + sqlite3ExprCacheClear( pParse ); + } - /* - ** Add a single OP_Explain instruction to the VDBE to explain a simple - ** count() query ("SELECT count() FROM pTab"). - */ + /* + ** Add a single OP_Explain instruction to the VDBE to explain a simple + ** count() query ("SELECT count() FROM pTab"). + */ #if !SQLITE_OMIT_EXPLAIN - static void explainSimpleCount( - Parse pParse, /* Parse context */ - Table pTab, /* Table being queried */ - Index pIdx /* Index used to optimize scan, or NULL */ - ) { - if (pParse.explain == 2) { - string zEqp = sqlite3MPrintf(pParse.db, "SCAN TABLE %s %s%s(~%d rows)", - pTab.zName, - pIdx != null ? "USING COVERING INDEX " : "", - pIdx != null ? pIdx.zName : "", - pTab.nRowEst - ); - sqlite3VdbeAddOp4( - pParse.pVdbe, OP_Explain, pParse.iSelectId, 0, 0, zEqp, P4_DYNAMIC - ); - } - } + static void explainSimpleCount( + Parse pParse, /* Parse context */ + Table pTab, /* Table being queried */ + Index pIdx /* Index used to optimize scan, or NULL */ + ) + { + if ( pParse.explain == 2 ) + { + string zEqp = sqlite3MPrintf( pParse.db, "SCAN TABLE %s %s%s(~%d rows)", + pTab.zName, + pIdx != null ? "USING COVERING INDEX " : "", + pIdx != null ? pIdx.zName : "", + pTab.nRowEst + ); + sqlite3VdbeAddOp4( + pParse.pVdbe, OP_Explain, pParse.iSelectId, 0, 0, zEqp, P4_DYNAMIC + ); + } + } #else //# define explainSimpleCount(a,b,c) static void explainSimpleCount(Parse a, Table b, Index c){} #endif - /* - ** Generate code for the SELECT statement given in the p argument. - ** - ** The results are distributed in various ways depending on the - ** contents of the SelectDest structure pointed to by argument pDest - ** as follows: - ** - ** pDest.eDest Result - ** ------------ ------------------------------------------- - ** SRT_Output Generate a row of output (using the OP_ResultRow - ** opcode) for each row in the result set. - ** - ** SRT_Mem Only valid if the result is a single column. - ** Store the first column of the first result row - ** in register pDest.iParm then abandon the rest - ** of the query. This destination implies "LIMIT 1". - ** - ** SRT_Set The result must be a single column. Store each - ** row of result as the key in table pDest.iParm. - ** Apply the affinity pDest.affinity before storing - ** results. Used to implement "IN (SELECT ...)". - ** - ** SRT_Union Store results as a key in a temporary table pDest.iParm. - ** - ** SRT_Except Remove results from the temporary table pDest.iParm. - ** - ** SRT_Table Store results in temporary table pDest.iParm. - ** This is like SRT_EphemTab except that the table - ** is assumed to already be open. - ** - ** SRT_EphemTab Create an temporary table pDest.iParm and store - ** the result there. The cursor is left open after - ** returning. This is like SRT_Table except that - ** this destination uses OP_OpenEphemeral to create - ** the table first. - ** - ** SRT_Coroutine Generate a co-routine that returns a new row of - ** results each time it is invoked. The entry point - ** of the co-routine is stored in register pDest.iParm. - ** - ** SRT_Exists Store a 1 in memory cell pDest.iParm if the result - ** set is not empty. - ** - ** SRT_Discard Throw the results away. This is used by SELECT - ** statements within triggers whose only purpose is - ** the side-effects of functions. - ** - ** This routine returns the number of errors. If any errors are - ** encountered, then an appropriate error message is left in - ** pParse.zErrMsg. - ** - ** This routine does NOT free the Select structure passed in. The - ** calling function needs to do that. - */ - static SelectDest sdDummy = null; - static bool bDummy = false; - - static int sqlite3Select( - Parse pParse, /* The parser context */ - Select p, /* The SELECT statement being coded. */ - ref SelectDest pDest /* What to do with the query results */ - ) { - int i, j; /* Loop counters */ - WhereInfo pWInfo; /* Return from sqlite3WhereBegin() */ - Vdbe v; /* The virtual machine under construction */ - bool isAgg; /* True for select lists like "count()" */ - ExprList pEList = new ExprList(); /* List of columns to extract. */ - SrcList pTabList = new SrcList(); /* List of tables to select from */ - Expr pWhere; /* The WHERE clause. May be NULL */ - ExprList pOrderBy; /* The ORDER BY clause. May be NULL */ - ExprList pGroupBy; /* The GROUP BY clause. May be NULL */ - Expr pHaving; /* The HAVING clause. May be NULL */ - bool isDistinct; /* True if the DISTINCT keyword is present */ - int distinct; /* Table to use for the distinct set */ - int rc = 1; /* Value to return from this function */ - int addrSortIndex; /* Address of an OP_OpenEphemeral instruction */ - AggInfo sAggInfo; /* Information used by aggregate queries */ - int iEnd; /* Address of the end of the query */ - sqlite3 db; /* The database connection */ + /* + ** Generate code for the SELECT statement given in the p argument. + ** + ** The results are distributed in various ways depending on the + ** contents of the SelectDest structure pointed to by argument pDest + ** as follows: + ** + ** pDest.eDest Result + ** ------------ ------------------------------------------- + ** SRT_Output Generate a row of output (using the OP_ResultRow + ** opcode) for each row in the result set. + ** + ** SRT_Mem Only valid if the result is a single column. + ** Store the first column of the first result row + ** in register pDest.iParm then abandon the rest + ** of the query. This destination implies "LIMIT 1". + ** + ** SRT_Set The result must be a single column. Store each + ** row of result as the key in table pDest.iParm. + ** Apply the affinity pDest.affinity before storing + ** results. Used to implement "IN (SELECT ...)". + ** + ** SRT_Union Store results as a key in a temporary table pDest.iParm. + ** + ** SRT_Except Remove results from the temporary table pDest.iParm. + ** + ** SRT_Table Store results in temporary table pDest.iParm. + ** This is like SRT_EphemTab except that the table + ** is assumed to already be open. + ** + ** SRT_EphemTab Create an temporary table pDest.iParm and store + ** the result there. The cursor is left open after + ** returning. This is like SRT_Table except that + ** this destination uses OP_OpenEphemeral to create + ** the table first. + ** + ** SRT_Coroutine Generate a co-routine that returns a new row of + ** results each time it is invoked. The entry point + ** of the co-routine is stored in register pDest.iParm. + ** + ** SRT_Exists Store a 1 in memory cell pDest.iParm if the result + ** set is not empty. + ** + ** SRT_Discard Throw the results away. This is used by SELECT + ** statements within triggers whose only purpose is + ** the side-effects of functions. + ** + ** This routine returns the number of errors. If any errors are + ** encountered, then an appropriate error message is left in + ** pParse.zErrMsg. + ** + ** This routine does NOT free the Select structure passed in. The + ** calling function needs to do that. + */ + static SelectDest sdDummy = null; + static bool bDummy = false; + + static int sqlite3Select( + Parse pParse, /* The parser context */ + Select p, /* The SELECT statement being coded. */ + ref SelectDest pDest /* What to do with the query results */ + ) + { + int i, j; /* Loop counters */ + WhereInfo pWInfo; /* Return from sqlite3WhereBegin() */ + Vdbe v; /* The virtual machine under construction */ + bool isAgg; /* True for select lists like "count()" */ + ExprList pEList = new ExprList(); /* List of columns to extract. */ + SrcList pTabList = new SrcList(); /* List of tables to select from */ + Expr pWhere; /* The WHERE clause. May be NULL */ + ExprList pOrderBy; /* The ORDER BY clause. May be NULL */ + ExprList pGroupBy; /* The GROUP BY clause. May be NULL */ + Expr pHaving; /* The HAVING clause. May be NULL */ + bool isDistinct; /* True if the DISTINCT keyword is present */ + int distinct; /* Table to use for the distinct set */ + int rc = 1; /* Value to return from this function */ + int addrSortIndex; /* Address of an OP_OpenEphemeral instruction */ + AggInfo sAggInfo; /* Information used by aggregate queries */ + int iEnd; /* Address of the end of the query */ + sqlite3 db; /* The database connection */ #if !SQLITE_OMIT_EXPLAIN - int iRestoreSelectId = pParse.iSelectId; - pParse.iSelectId = pParse.iNextSelectId++; + int iRestoreSelectId = pParse.iSelectId; + pParse.iSelectId = pParse.iNextSelectId++; #endif - db = pParse.db; - if (p == null /*|| db.mallocFailed != 0 */ || pParse.nErr != 0) { - return 1; - } + db = pParse.db; + if ( p == null /*|| db.mallocFailed != 0 */ || pParse.nErr != 0 ) + { + return 1; + } #if !SQLITE_OMIT_AUTHORIZATION if (sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0)) return 1; #endif - sAggInfo = new AggInfo();// memset(sAggInfo, 0, sAggInfo).Length; - - if (pDest.eDest <= SRT_Discard) //IgnorableOrderby(pDest)) - { - Debug.Assert(pDest.eDest == SRT_Exists || pDest.eDest == SRT_Union || - pDest.eDest == SRT_Except || pDest.eDest == SRT_Discard); - /* If ORDER BY makes no difference in the output then neither does - ** DISTINCT so it can be removed too. */ - sqlite3ExprListDelete(db, ref p.pOrderBy); - p.pOrderBy = null; - p.selFlags = (u16)(p.selFlags & ~SF_Distinct); - } - sqlite3SelectPrep(pParse, p, null); - pOrderBy = p.pOrderBy; - pTabList = p.pSrc; - pEList = p.pEList; - if (pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) { - goto select_end; - } - isAgg = (p.selFlags & SF_Aggregate) != 0; - Debug.Assert(pEList != null); - - /* Begin generating code. - */ - v = sqlite3GetVdbe(pParse); - if (v == null) - goto select_end; + sAggInfo = new AggInfo();// memset(sAggInfo, 0, sAggInfo).Length; + + if ( pDest.eDest <= SRT_Discard ) //IgnorableOrderby(pDest)) + { + Debug.Assert( pDest.eDest == SRT_Exists || pDest.eDest == SRT_Union || + pDest.eDest == SRT_Except || pDest.eDest == SRT_Discard ); + /* If ORDER BY makes no difference in the output then neither does + ** DISTINCT so it can be removed too. */ + sqlite3ExprListDelete( db, ref p.pOrderBy ); + p.pOrderBy = null; + p.selFlags = (u16)( p.selFlags & ~SF_Distinct ); + } + sqlite3SelectPrep( pParse, p, null ); + pOrderBy = p.pOrderBy; + pTabList = p.pSrc; + pEList = p.pEList; + if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) + { + goto select_end; + } + isAgg = ( p.selFlags & SF_Aggregate ) != 0; + Debug.Assert( pEList != null ); + + /* Begin generating code. + */ + v = sqlite3GetVdbe( pParse ); + if ( v == null ) + goto select_end; - /* If writing to memory or generating a set - ** only a single column may be output. - */ + /* If writing to memory or generating a set + ** only a single column may be output. + */ #if !SQLITE_OMIT_SUBQUERY - if (checkForMultiColumnSelectError(pParse, pDest, pEList.nExpr)) { - goto select_end; - } + if ( checkForMultiColumnSelectError( pParse, pDest, pEList.nExpr ) ) + { + goto select_end; + } #endif - /* Generate code for all sub-queries in the FROM clause - */ + /* Generate code for all sub-queries in the FROM clause +*/ #if !SQLITE_OMIT_SUBQUERY || !SQLITE_OMIT_VIEW - for (i = 0; p.pPrior == null && i < pTabList.nSrc; i++) { - SrcList_item pItem = pTabList.a[i]; - SelectDest dest = new SelectDest(); - Select pSub = pItem.pSelect; - bool isAggSub; - - if (pSub == null || pItem.isPopulated != 0) - continue; - - /* Increment Parse.nHeight by the height of the largest expression - ** tree refered to by this, the parent select. The child select - ** may contain expression trees of at most - ** (SQLITE_MAX_EXPR_DEPTH-Parse.nHeight) height. This is a bit - ** more conservative than necessary, but much easier than enforcing - ** an exact limit. - */ - pParse.nHeight += sqlite3SelectExprHeight(p); - - /* Check to see if the subquery can be absorbed into the parent. */ - isAggSub = (pSub.selFlags & SF_Aggregate) != 0; - if (flattenSubquery(pParse, p, i, isAgg, isAggSub) != 0) { - if (isAggSub) { - isAgg = true; - p.selFlags |= SF_Aggregate; - } - i = -1; - } else { - sqlite3SelectDestInit(dest, SRT_EphemTab, pItem.iCursor); - Debug.Assert(0 == pItem.isPopulated); - explainSetInteger(ref pItem.iSelectId, (int)pParse.iNextSelectId); - sqlite3Select(pParse, pSub, ref dest); - pItem.isPopulated = 1; - pItem.pTab.nRowEst = (uint)pSub.nSelectRow; - } - //if ( /* pParse.nErr != 0 || */ db.mallocFailed != 0 ) - //{ - // goto select_end; - //} - pParse.nHeight -= sqlite3SelectExprHeight(p); - pTabList = p.pSrc; - if (!(pDest.eDest <= SRT_Discard))// if( null==IgnorableOrderby(pDest) ) - { - pOrderBy = p.pOrderBy; - } - } - pEList = p.pEList; + for ( i = 0; p.pPrior == null && i < pTabList.nSrc; i++ ) + { + SrcList_item pItem = pTabList.a[i]; + SelectDest dest = new SelectDest(); + Select pSub = pItem.pSelect; + bool isAggSub; + + if ( pSub == null || pItem.isPopulated != 0 ) + continue; + + /* Increment Parse.nHeight by the height of the largest expression + ** tree refered to by this, the parent select. The child select + ** may contain expression trees of at most + ** (SQLITE_MAX_EXPR_DEPTH-Parse.nHeight) height. This is a bit + ** more conservative than necessary, but much easier than enforcing + ** an exact limit. + */ + pParse.nHeight += sqlite3SelectExprHeight( p ); + + /* Check to see if the subquery can be absorbed into the parent. */ + isAggSub = ( pSub.selFlags & SF_Aggregate ) != 0; + if ( flattenSubquery( pParse, p, i, isAgg, isAggSub ) != 0 ) + { + if ( isAggSub ) + { + isAgg = true; + p.selFlags |= SF_Aggregate; + } + i = -1; + } + else + { + sqlite3SelectDestInit( dest, SRT_EphemTab, pItem.iCursor ); + Debug.Assert( 0 == pItem.isPopulated ); + explainSetInteger( ref pItem.iSelectId, (int)pParse.iNextSelectId ); + sqlite3Select( pParse, pSub, ref dest ); + pItem.isPopulated = 1; + pItem.pTab.nRowEst = (uint)pSub.nSelectRow; + } + //if ( /* pParse.nErr != 0 || */ db.mallocFailed != 0 ) + //{ + // goto select_end; + //} + pParse.nHeight -= sqlite3SelectExprHeight( p ); + pTabList = p.pSrc; + if ( !( pDest.eDest <= SRT_Discard ) )// if( null==IgnorableOrderby(pDest) ) + { + pOrderBy = p.pOrderBy; + } + } + pEList = p.pEList; #endif - pWhere = p.pWhere; - pGroupBy = p.pGroupBy; - pHaving = p.pHaving; - isDistinct = (p.selFlags & SF_Distinct) != 0; + pWhere = p.pWhere; + pGroupBy = p.pGroupBy; + pHaving = p.pHaving; + isDistinct = ( p.selFlags & SF_Distinct ) != 0; -#if !SQLITE_OMIT_COMPOUND_SELECT - /* If there is are a sequence of queries, do the earlier ones first. - */ - if (p.pPrior != null) { - if (p.pRightmost == null) { - Select pLoop, pRight = null; - int cnt = 0; - int mxSelect; - for (pLoop = p; pLoop != null; pLoop = pLoop.pPrior, cnt++) { - pLoop.pRightmost = p; - pLoop.pNext = pRight; - pRight = pLoop; - } - mxSelect = db.aLimit[SQLITE_LIMIT_COMPOUND_SELECT]; - if (mxSelect != 0 && cnt > mxSelect) { - sqlite3ErrorMsg(pParse, "too many terms in compound SELECT"); - goto select_end; - } - } - rc = multiSelect(pParse, p, pDest); - explainSetInteger(ref pParse.iSelectId, iRestoreSelectId); - return rc; - } +#if !SQLITE_OMIT_COMPOUND_SELECT + /* If there is are a sequence of queries, do the earlier ones first. +*/ + if ( p.pPrior != null ) + { + if ( p.pRightmost == null ) + { + Select pLoop, pRight = null; + int cnt = 0; + int mxSelect; + for ( pLoop = p; pLoop != null; pLoop = pLoop.pPrior, cnt++ ) + { + pLoop.pRightmost = p; + pLoop.pNext = pRight; + pRight = pLoop; + } + mxSelect = db.aLimit[SQLITE_LIMIT_COMPOUND_SELECT]; + if ( mxSelect != 0 && cnt > mxSelect ) + { + sqlite3ErrorMsg( pParse, "too many terms in compound SELECT" ); + goto select_end; + } + } + rc = multiSelect( pParse, p, pDest ); + explainSetInteger( ref pParse.iSelectId, iRestoreSelectId ); + return rc; + } #endif - /* If possible, rewrite the query to use GROUP BY instead of DISTINCT. - ** GROUP BY might use an index, DISTINCT never does. + /* If possible, rewrite the query to use GROUP BY instead of DISTINCT. +** GROUP BY might use an index, DISTINCT never does. +*/ + Debug.Assert( p.pGroupBy == null || ( p.selFlags & SF_Aggregate ) != 0 ); + if ( ( p.selFlags & ( SF_Distinct | SF_Aggregate ) ) == SF_Distinct ) + { + p.pGroupBy = sqlite3ExprListDup( db, p.pEList, 0 ); + pGroupBy = p.pGroupBy; + p.selFlags = (u16)( p.selFlags & ~SF_Distinct ); + } + + /* If there is both a GROUP BY and an ORDER BY clause and they are + ** identical, then disable the ORDER BY clause since the GROUP BY + ** will cause elements to come out in the correct order. This is + ** an optimization - the correct answer should result regardless. + ** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER + ** to disable this optimization for testing purposes. */ - Debug.Assert(p.pGroupBy == null || (p.selFlags & SF_Aggregate) != 0); - if ((p.selFlags & (SF_Distinct | SF_Aggregate)) == SF_Distinct) { - p.pGroupBy = sqlite3ExprListDup(db, p.pEList, 0); - pGroupBy = p.pGroupBy; - p.selFlags = (u16)(p.selFlags & ~SF_Distinct); - } - - /* If there is both a GROUP BY and an ORDER BY clause and they are - ** identical, then disable the ORDER BY clause since the GROUP BY - ** will cause elements to come out in the correct order. This is - ** an optimization - the correct answer should result regardless. - ** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER - ** to disable this optimization for testing purposes. - */ - if (sqlite3ExprListCompare(p.pGroupBy, pOrderBy) == 0 - && (db.flags & SQLITE_GroupByOrder) == 0) { - pOrderBy = null; - } - - /* If there is an ORDER BY clause, then this sorting - ** index might end up being unused if the data can be - ** extracted in pre-sorted order. If that is the case, then the - ** OP_OpenEphemeral instruction will be changed to an OP_Noop once - ** we figure out that the sorting index is not needed. The addrSortIndex - ** variable is used to facilitate that change. - */ - if (pOrderBy != null) { - KeyInfo pKeyInfo; - pKeyInfo = keyInfoFromExprList(pParse, pOrderBy); - pOrderBy.iECursor = pParse.nTab++; - p.addrOpenEphm[2] = addrSortIndex = - sqlite3VdbeAddOp4(v, OP_OpenEphemeral, - pOrderBy.iECursor, pOrderBy.nExpr + 2, 0, - pKeyInfo, P4_KEYINFO_HANDOFF); - } else { - addrSortIndex = -1; - } - - /* If the output is destined for a temporary table, open that table. - */ - if (pDest.eDest == SRT_EphemTab) { - sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pDest.iParm, pEList.nExpr); - } - - /* Set the limiter. - */ - iEnd = sqlite3VdbeMakeLabel(v); - p.nSelectRow = (double)LARGEST_INT64; - computeLimitRegisters(pParse, p, iEnd); + if ( sqlite3ExprListCompare( p.pGroupBy, pOrderBy ) == 0 + && ( db.flags & SQLITE_GroupByOrder ) == 0 ) + { + pOrderBy = null; + } + + /* If there is an ORDER BY clause, then this sorting + ** index might end up being unused if the data can be + ** extracted in pre-sorted order. If that is the case, then the + ** OP_OpenEphemeral instruction will be changed to an OP_Noop once + ** we figure out that the sorting index is not needed. The addrSortIndex + ** variable is used to facilitate that change. + */ + if ( pOrderBy != null ) + { + KeyInfo pKeyInfo; + pKeyInfo = keyInfoFromExprList( pParse, pOrderBy ); + pOrderBy.iECursor = pParse.nTab++; + p.addrOpenEphm[2] = addrSortIndex = + sqlite3VdbeAddOp4( v, OP_OpenEphemeral, + pOrderBy.iECursor, pOrderBy.nExpr + 2, 0, + pKeyInfo, P4_KEYINFO_HANDOFF ); + } + else + { + addrSortIndex = -1; + } + + /* If the output is destined for a temporary table, open that table. + */ + if ( pDest.eDest == SRT_EphemTab ) + { + sqlite3VdbeAddOp2( v, OP_OpenEphemeral, pDest.iParm, pEList.nExpr ); + } - /* Open a virtual index to use for the distinct set. - */ - if ((p.selFlags & SF_Distinct) != 0) { - KeyInfo pKeyInfo; - Debug.Assert(isAgg || pGroupBy != null); - distinct = pParse.nTab++; - pKeyInfo = keyInfoFromExprList(pParse, p.pEList); - sqlite3VdbeAddOp4(v, OP_OpenEphemeral, distinct, 0, 0, - pKeyInfo, P4_KEYINFO_HANDOFF); - sqlite3VdbeChangeP5(v, BTREE_UNORDERED); - } else { - distinct = -1; - } + /* Set the limiter. + */ + iEnd = sqlite3VdbeMakeLabel( v ); + p.nSelectRow = (double)LARGEST_INT64; + computeLimitRegisters( pParse, p, iEnd ); - /* Aggregate and non-aggregate queries are handled differently */ - if (!isAgg && pGroupBy == null) { - /* This case is for non-aggregate queries - ** Begin the database scan - */ - pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, ref pOrderBy, 0); - if (pWInfo == null) - goto select_end; - if (pWInfo.nRowOut < p.nSelectRow) - p.nSelectRow = pWInfo.nRowOut; - - /* If sorting index that was created by a prior OP_OpenEphemeral - ** instruction ended up not being needed, then change the OP_OpenEphemeral - ** into an OP_Noop. - */ - if (addrSortIndex >= 0 && pOrderBy == null) { - sqlite3VdbeChangeToNoop(v, addrSortIndex, 1); - p.addrOpenEphm[2] = -1; - } + /* Open a virtual index to use for the distinct set. + */ + if ( ( p.selFlags & SF_Distinct ) != 0 ) + { + KeyInfo pKeyInfo; + Debug.Assert( isAgg || pGroupBy != null ); + distinct = pParse.nTab++; + pKeyInfo = keyInfoFromExprList( pParse, p.pEList ); + sqlite3VdbeAddOp4( v, OP_OpenEphemeral, distinct, 0, 0, + pKeyInfo, P4_KEYINFO_HANDOFF ); + sqlite3VdbeChangeP5( v, BTREE_UNORDERED ); + } + else + { + distinct = -1; + } + + /* Aggregate and non-aggregate queries are handled differently */ + if ( !isAgg && pGroupBy == null ) + { + /* This case is for non-aggregate queries + ** Begin the database scan + */ + pWInfo = sqlite3WhereBegin( pParse, pTabList, pWhere, ref pOrderBy, 0 ); + if ( pWInfo == null ) + goto select_end; + if ( pWInfo.nRowOut < p.nSelectRow ) + p.nSelectRow = pWInfo.nRowOut; + + /* If sorting index that was created by a prior OP_OpenEphemeral + ** instruction ended up not being needed, then change the OP_OpenEphemeral + ** into an OP_Noop. + */ + if ( addrSortIndex >= 0 && pOrderBy == null ) + { + sqlite3VdbeChangeToNoop( v, addrSortIndex, 1 ); + p.addrOpenEphm[2] = -1; + } - /* Use the standard inner loop - */ - Debug.Assert(!isDistinct); - selectInnerLoop(pParse, p, pEList, 0, 0, pOrderBy, -1, pDest, - pWInfo.iContinue, pWInfo.iBreak); + /* Use the standard inner loop + */ + Debug.Assert( !isDistinct ); + selectInnerLoop( pParse, p, pEList, 0, 0, pOrderBy, -1, pDest, + pWInfo.iContinue, pWInfo.iBreak ); - /* End the database scan loop. - */ - sqlite3WhereEnd(pWInfo); - } else { - /* This is the processing for aggregate queries */ - NameContext sNC; /* Name context for processing aggregate information */ - int iAMem; /* First Mem address for storing current GROUP BY */ - int iBMem; /* First Mem address for previous GROUP BY */ - int iUseFlag; /* Mem address holding flag indicating that at least + /* End the database scan loop. + */ + sqlite3WhereEnd( pWInfo ); + } + else + { + /* This is the processing for aggregate queries */ + NameContext sNC; /* Name context for processing aggregate information */ + int iAMem; /* First Mem address for storing current GROUP BY */ + int iBMem; /* First Mem address for previous GROUP BY */ + int iUseFlag; /* Mem address holding flag indicating that at least ** one row of the input to the aggregator has been ** processed */ - int iAbortFlag; /* Mem address which causes query abort if positive */ - int groupBySort; /* Rows come from source in GR BY' clause thanROUP BY order */ + int iAbortFlag; /* Mem address which causes query abort if positive */ + int groupBySort; /* Rows come from source in GR BY' clause thanROUP BY order */ - int addrEnd; /* End of processing for this SELECT */ + int addrEnd; /* End of processing for this SELECT */ - /* Remove any and all aliases between the result set and the - ** GROUP BY clause. - */ - if (pGroupBy != null) { - int k; /* Loop counter */ - ExprList_item pItem; /* For looping over expression in a list */ - - for (k = p.pEList.nExpr; k > 0; k--)//, pItem++) - { - pItem = p.pEList.a[p.pEList.nExpr - k]; - pItem.iAlias = 0; - } - for (k = pGroupBy.nExpr; k > 0; k--)//, pItem++ ) - { - pItem = pGroupBy.a[pGroupBy.nExpr - k]; - pItem.iAlias = 0; - } - if (p.nSelectRow > (double)100) - p.nSelectRow = (double)100; - } else { - p.nSelectRow = (double)1; - } + /* Remove any and all aliases between the result set and the + ** GROUP BY clause. + */ + if ( pGroupBy != null ) + { + int k; /* Loop counter */ + ExprList_item pItem; /* For looping over expression in a list */ + + for ( k = p.pEList.nExpr; k > 0; k-- )//, pItem++) + { + pItem = p.pEList.a[p.pEList.nExpr - k]; + pItem.iAlias = 0; + } + for ( k = pGroupBy.nExpr; k > 0; k-- )//, pItem++ ) + { + pItem = pGroupBy.a[pGroupBy.nExpr - k]; + pItem.iAlias = 0; + } + if ( p.nSelectRow > (double)100 ) + p.nSelectRow = (double)100; + } + else + { + p.nSelectRow = (double)1; + } - /* Create a label to jump to when we want to abort the query */ - addrEnd = sqlite3VdbeMakeLabel(v); + /* Create a label to jump to when we want to abort the query */ + addrEnd = sqlite3VdbeMakeLabel( v ); - /* Convert TK_COLUMN nodes into TK_AGG_COLUMN and make entries in - ** sAggInfo for all TK_AGG_FUNCTION nodes in expressions of the - ** SELECT statement. - */ - sNC = new NameContext(); // memset(sNC, 0, sNC).Length; - sNC.pParse = pParse; - sNC.pSrcList = pTabList; - sNC.pAggInfo = sAggInfo; - sAggInfo.nSortingColumn = pGroupBy != null ? pGroupBy.nExpr + 1 : 0; - sAggInfo.pGroupBy = pGroupBy; - sqlite3ExprAnalyzeAggList(sNC, pEList); - sqlite3ExprAnalyzeAggList(sNC, pOrderBy); - if (pHaving != null) { - sqlite3ExprAnalyzeAggregates(sNC, ref pHaving); - } - sAggInfo.nAccumulator = sAggInfo.nColumn; - for (i = 0; i < sAggInfo.nFunc; i++) { - Debug.Assert(!ExprHasProperty(sAggInfo.aFunc[i].pExpr, EP_xIsSelect)); - sqlite3ExprAnalyzeAggList(sNC, sAggInfo.aFunc[i].pExpr.x.pList); - } - // if ( db.mallocFailed != 0 ) goto select_end; + /* Convert TK_COLUMN nodes into TK_AGG_COLUMN and make entries in + ** sAggInfo for all TK_AGG_FUNCTION nodes in expressions of the + ** SELECT statement. + */ + sNC = new NameContext(); // memset(sNC, 0, sNC).Length; + sNC.pParse = pParse; + sNC.pSrcList = pTabList; + sNC.pAggInfo = sAggInfo; + sAggInfo.nSortingColumn = pGroupBy != null ? pGroupBy.nExpr + 1 : 0; + sAggInfo.pGroupBy = pGroupBy; + sqlite3ExprAnalyzeAggList( sNC, pEList ); + sqlite3ExprAnalyzeAggList( sNC, pOrderBy ); + if ( pHaving != null ) + { + sqlite3ExprAnalyzeAggregates( sNC, ref pHaving ); + } + sAggInfo.nAccumulator = sAggInfo.nColumn; + for ( i = 0; i < sAggInfo.nFunc; i++ ) + { + Debug.Assert( !ExprHasProperty( sAggInfo.aFunc[i].pExpr, EP_xIsSelect ) ); + sqlite3ExprAnalyzeAggList( sNC, sAggInfo.aFunc[i].pExpr.x.pList ); + } + // if ( db.mallocFailed != 0 ) goto select_end; - /* Processing for aggregates with GROUP BY is very different and - ** much more complex than aggregates without a GROUP BY. - */ - if (pGroupBy != null) { - KeyInfo pKeyInfo; /* Keying information for the group by clause */ - int j1; /* A-vs-B comparision jump */ - int addrOutputRow; /* Start of subroutine that outputs a result row */ - int regOutputRow; /* Return address register for output subroutine */ - int addrSetAbort; /* Set the abort flag and return */ - int addrTopOfLoop; /* Top of the input loop */ - int addrSortingIdx; /* The OP_OpenEphemeral for the sorting index */ - int addrReset; /* Subroutine for resetting the accumulator */ - int regReset; /* Return address register for reset subroutine */ - - /* If there is a GROUP BY clause we might need a sorting index to - ** implement it. Allocate that sorting index now. If it turns out - ** that we do not need it after all, the OpenEphemeral instruction - ** will be converted into a Noop. - */ - sAggInfo.sortingIdx = pParse.nTab++; - pKeyInfo = keyInfoFromExprList(pParse, pGroupBy); - addrSortingIdx = sqlite3VdbeAddOp4(v, OP_OpenEphemeral, - sAggInfo.sortingIdx, sAggInfo.nSortingColumn, - 0, pKeyInfo, P4_KEYINFO_HANDOFF); - - /* Initialize memory locations used by GROUP BY aggregate processing - */ - iUseFlag = ++pParse.nMem; - iAbortFlag = ++pParse.nMem; - regOutputRow = ++pParse.nMem; - addrOutputRow = sqlite3VdbeMakeLabel(v); - regReset = ++pParse.nMem; - addrReset = sqlite3VdbeMakeLabel(v); - iAMem = pParse.nMem + 1; - pParse.nMem += pGroupBy.nExpr; - iBMem = pParse.nMem + 1; - pParse.nMem += pGroupBy.nExpr; - sqlite3VdbeAddOp2(v, OP_Integer, 0, iAbortFlag); + /* Processing for aggregates with GROUP BY is very different and + ** much more complex than aggregates without a GROUP BY. + */ + if ( pGroupBy != null ) + { + KeyInfo pKeyInfo; /* Keying information for the group by clause */ + int j1; /* A-vs-B comparision jump */ + int addrOutputRow; /* Start of subroutine that outputs a result row */ + int regOutputRow; /* Return address register for output subroutine */ + int addrSetAbort; /* Set the abort flag and return */ + int addrTopOfLoop; /* Top of the input loop */ + int addrSortingIdx; /* The OP_OpenEphemeral for the sorting index */ + int addrReset; /* Subroutine for resetting the accumulator */ + int regReset; /* Return address register for reset subroutine */ + + /* If there is a GROUP BY clause we might need a sorting index to + ** implement it. Allocate that sorting index now. If it turns out + ** that we do not need it after all, the OpenEphemeral instruction + ** will be converted into a Noop. + */ + sAggInfo.sortingIdx = pParse.nTab++; + pKeyInfo = keyInfoFromExprList( pParse, pGroupBy ); + addrSortingIdx = sqlite3VdbeAddOp4( v, OP_OpenEphemeral, + sAggInfo.sortingIdx, sAggInfo.nSortingColumn, + 0, pKeyInfo, P4_KEYINFO_HANDOFF ); + + /* Initialize memory locations used by GROUP BY aggregate processing + */ + iUseFlag = ++pParse.nMem; + iAbortFlag = ++pParse.nMem; + regOutputRow = ++pParse.nMem; + addrOutputRow = sqlite3VdbeMakeLabel( v ); + regReset = ++pParse.nMem; + addrReset = sqlite3VdbeMakeLabel( v ); + iAMem = pParse.nMem + 1; + pParse.nMem += pGroupBy.nExpr; + iBMem = pParse.nMem + 1; + pParse.nMem += pGroupBy.nExpr; + sqlite3VdbeAddOp2( v, OP_Integer, 0, iAbortFlag ); #if SQLITE_DEBUG - VdbeComment(v, "clear abort flag"); + VdbeComment( v, "clear abort flag" ); #endif - sqlite3VdbeAddOp2(v, OP_Integer, 0, iUseFlag); + sqlite3VdbeAddOp2( v, OP_Integer, 0, iUseFlag ); #if SQLITE_DEBUG - VdbeComment(v, "indicate accumulator empty"); + VdbeComment( v, "indicate accumulator empty" ); #endif - /* Begin a loop that will extract all source rows in GROUP BY order. - ** This might involve two separate loops with an OP_Sort in between, or - ** it might be a single loop that uses an index to extract information - ** in the right order to begin with. - */ - sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset); - pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, ref pGroupBy, 0); - if (pWInfo == null) - goto select_end; - if (pGroupBy == null) { - /* The optimizer is able to deliver rows in group by order so - ** we do not have to sort. The OP_OpenEphemeral table will be - ** cancelled later because we still need to use the pKeyInfo - */ - pGroupBy = p.pGroupBy; - groupBySort = 0; - } else { - /* Rows are coming out in undetermined order. We have to push - ** each row into a sorting index, terminate the first loop, - ** then loop over the sorting index in order to get the output - ** in sorted order - */ - int regBase; - int regRecord; - int nCol; - int nGroupBy; - - explainTempTable(pParse, - isDistinct && 0 == (p.selFlags & SF_Distinct) ? "DISTINCT" : "GROUP BY"); - - groupBySort = 1; - nGroupBy = pGroupBy.nExpr; - nCol = nGroupBy + 1; - j = nGroupBy + 1; - for (i = 0; i < sAggInfo.nColumn; i++) { - if (sAggInfo.aCol[i].iSorterColumn >= j) { - nCol++; - j++; - } - } - regBase = sqlite3GetTempRange(pParse, nCol); - sqlite3ExprCacheClear(pParse); - sqlite3ExprCodeExprList(pParse, pGroupBy, regBase, false); - sqlite3VdbeAddOp2(v, OP_Sequence, sAggInfo.sortingIdx, regBase + nGroupBy); - j = nGroupBy + 1; - for (i = 0; i < sAggInfo.nColumn; i++) { - AggInfo_col pCol = sAggInfo.aCol[i]; - if (pCol.iSorterColumn >= j) { - int r1 = j + regBase; - int r2; - r2 = sqlite3ExprCodeGetColumn(pParse, - pCol.pTab, pCol.iColumn, pCol.iTable, r1); - if (r1 != r2) { - sqlite3VdbeAddOp2(v, OP_SCopy, r2, r1); - } - j++; - } - } - regRecord = sqlite3GetTempReg(pParse); - sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regRecord); - sqlite3VdbeAddOp2(v, OP_IdxInsert, sAggInfo.sortingIdx, regRecord); - sqlite3ReleaseTempReg(pParse, regRecord); - sqlite3ReleaseTempRange(pParse, regBase, nCol); - sqlite3WhereEnd(pWInfo); - sqlite3VdbeAddOp2(v, OP_Sort, sAggInfo.sortingIdx, addrEnd); + /* Begin a loop that will extract all source rows in GROUP BY order. +** This might involve two separate loops with an OP_Sort in between, or +** it might be a single loop that uses an index to extract information +** in the right order to begin with. +*/ + sqlite3VdbeAddOp2( v, OP_Gosub, regReset, addrReset ); + pWInfo = sqlite3WhereBegin( pParse, pTabList, pWhere, ref pGroupBy, 0 ); + if ( pWInfo == null ) + goto select_end; + if ( pGroupBy == null ) + { + /* The optimizer is able to deliver rows in group by order so + ** we do not have to sort. The OP_OpenEphemeral table will be + ** cancelled later because we still need to use the pKeyInfo + */ + pGroupBy = p.pGroupBy; + groupBySort = 0; + } + else + { + /* Rows are coming out in undetermined order. We have to push + ** each row into a sorting index, terminate the first loop, + ** then loop over the sorting index in order to get the output + ** in sorted order + */ + int regBase; + int regRecord; + int nCol; + int nGroupBy; + + explainTempTable( pParse, + isDistinct && 0 == ( p.selFlags & SF_Distinct ) ? "DISTINCT" : "GROUP BY" ); + + groupBySort = 1; + nGroupBy = pGroupBy.nExpr; + nCol = nGroupBy + 1; + j = nGroupBy + 1; + for ( i = 0; i < sAggInfo.nColumn; i++ ) + { + if ( sAggInfo.aCol[i].iSorterColumn >= j ) + { + nCol++; + j++; + } + } + regBase = sqlite3GetTempRange( pParse, nCol ); + sqlite3ExprCacheClear( pParse ); + sqlite3ExprCodeExprList( pParse, pGroupBy, regBase, false ); + sqlite3VdbeAddOp2( v, OP_Sequence, sAggInfo.sortingIdx, regBase + nGroupBy ); + j = nGroupBy + 1; + for ( i = 0; i < sAggInfo.nColumn; i++ ) + { + AggInfo_col pCol = sAggInfo.aCol[i]; + if ( pCol.iSorterColumn >= j ) + { + int r1 = j + regBase; + int r2; + r2 = sqlite3ExprCodeGetColumn( pParse, + pCol.pTab, pCol.iColumn, pCol.iTable, r1 ); + if ( r1 != r2 ) + { + sqlite3VdbeAddOp2( v, OP_SCopy, r2, r1 ); + } + j++; + } + } + regRecord = sqlite3GetTempReg( pParse ); + sqlite3VdbeAddOp3( v, OP_MakeRecord, regBase, nCol, regRecord ); + sqlite3VdbeAddOp2( v, OP_IdxInsert, sAggInfo.sortingIdx, regRecord ); + sqlite3ReleaseTempReg( pParse, regRecord ); + sqlite3ReleaseTempRange( pParse, regBase, nCol ); + sqlite3WhereEnd( pWInfo ); + sqlite3VdbeAddOp2( v, OP_Sort, sAggInfo.sortingIdx, addrEnd ); #if SQLITE_DEBUG - VdbeComment(v, "GROUP BY sort"); + VdbeComment( v, "GROUP BY sort" ); #endif - sAggInfo.useSortingIdx = 1; - sqlite3ExprCacheClear(pParse); - } - - /* Evaluate the current GROUP BY terms and store in b0, b1, b2... - ** (b0 is memory location iBMem+0, b1 is iBMem+1, and so forth) - ** Then compare the current GROUP BY terms against the GROUP BY terms - ** from the previous row currently stored in a0, a1, a2... - */ - addrTopOfLoop = sqlite3VdbeCurrentAddr(v); - sqlite3ExprCacheClear(pParse); - for (j = 0; j < pGroupBy.nExpr; j++) { - if (groupBySort != 0) { - sqlite3VdbeAddOp3(v, OP_Column, sAggInfo.sortingIdx, j, iBMem + j); - } else { - sAggInfo.directMode = 1; - sqlite3ExprCode(pParse, pGroupBy.a[j].pExpr, iBMem + j); - } - } - sqlite3VdbeAddOp4(v, OP_Compare, iAMem, iBMem, pGroupBy.nExpr, - pKeyInfo, P4_KEYINFO); - j1 = sqlite3VdbeCurrentAddr(v); - sqlite3VdbeAddOp3(v, OP_Jump, j1 + 1, 0, j1 + 1); - - /* Generate code that runs whenever the GROUP BY changes. - ** Changes in the GROUP BY are detected by the previous code - ** block. If there were no changes, this block is skipped. - ** - ** This code copies current group by terms in b0,b1,b2,... - ** over to a0,a1,a2. It then calls the output subroutine - ** and resets the aggregate accumulator registers in preparation - ** for the next GROUP BY batch. - */ - sqlite3ExprCodeMove(pParse, iBMem, iAMem, pGroupBy.nExpr); - sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow); + sAggInfo.useSortingIdx = 1; + sqlite3ExprCacheClear( pParse ); + } + + /* Evaluate the current GROUP BY terms and store in b0, b1, b2... + ** (b0 is memory location iBMem+0, b1 is iBMem+1, and so forth) + ** Then compare the current GROUP BY terms against the GROUP BY terms + ** from the previous row currently stored in a0, a1, a2... + */ + addrTopOfLoop = sqlite3VdbeCurrentAddr( v ); + sqlite3ExprCacheClear( pParse ); + for ( j = 0; j < pGroupBy.nExpr; j++ ) + { + if ( groupBySort != 0 ) + { + sqlite3VdbeAddOp3( v, OP_Column, sAggInfo.sortingIdx, j, iBMem + j ); + } + else + { + sAggInfo.directMode = 1; + sqlite3ExprCode( pParse, pGroupBy.a[j].pExpr, iBMem + j ); + } + } + sqlite3VdbeAddOp4( v, OP_Compare, iAMem, iBMem, pGroupBy.nExpr, + pKeyInfo, P4_KEYINFO ); + j1 = sqlite3VdbeCurrentAddr( v ); + sqlite3VdbeAddOp3( v, OP_Jump, j1 + 1, 0, j1 + 1 ); + + /* Generate code that runs whenever the GROUP BY changes. + ** Changes in the GROUP BY are detected by the previous code + ** block. If there were no changes, this block is skipped. + ** + ** This code copies current group by terms in b0,b1,b2,... + ** over to a0,a1,a2. It then calls the output subroutine + ** and resets the aggregate accumulator registers in preparation + ** for the next GROUP BY batch. + */ + sqlite3ExprCodeMove( pParse, iBMem, iAMem, pGroupBy.nExpr ); + sqlite3VdbeAddOp2( v, OP_Gosub, regOutputRow, addrOutputRow ); #if SQLITE_DEBUG - VdbeComment(v, "output one row"); + VdbeComment( v, "output one row" ); #endif - sqlite3VdbeAddOp2(v, OP_IfPos, iAbortFlag, addrEnd); + sqlite3VdbeAddOp2( v, OP_IfPos, iAbortFlag, addrEnd ); #if SQLITE_DEBUG - VdbeComment(v, "check abort flag"); + VdbeComment( v, "check abort flag" ); #endif - sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset); + sqlite3VdbeAddOp2( v, OP_Gosub, regReset, addrReset ); #if SQLITE_DEBUG - VdbeComment(v, "reset accumulator"); + VdbeComment( v, "reset accumulator" ); #endif - /* Update the aggregate accumulators based on the content of - ** the current row - */ - sqlite3VdbeJumpHere(v, j1); - updateAccumulator(pParse, sAggInfo); - sqlite3VdbeAddOp2(v, OP_Integer, 1, iUseFlag); + /* Update the aggregate accumulators based on the content of +** the current row +*/ + sqlite3VdbeJumpHere( v, j1 ); + updateAccumulator( pParse, sAggInfo ); + sqlite3VdbeAddOp2( v, OP_Integer, 1, iUseFlag ); #if SQLITE_DEBUG - VdbeComment(v, "indicate data in accumulator"); + VdbeComment( v, "indicate data in accumulator" ); #endif - /* End of the loop + /* End of the loop +*/ + if ( groupBySort != 0 ) + { + sqlite3VdbeAddOp2( v, OP_Next, sAggInfo.sortingIdx, addrTopOfLoop ); + } + else + { + sqlite3WhereEnd( pWInfo ); + sqlite3VdbeChangeToNoop( v, addrSortingIdx, 1 ); + } + + /* Output the final row of result */ - if (groupBySort != 0) { - sqlite3VdbeAddOp2(v, OP_Next, sAggInfo.sortingIdx, addrTopOfLoop); - } else { - sqlite3WhereEnd(pWInfo); - sqlite3VdbeChangeToNoop(v, addrSortingIdx, 1); - } - - /* Output the final row of result - */ - sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow); + sqlite3VdbeAddOp2( v, OP_Gosub, regOutputRow, addrOutputRow ); #if SQLITE_DEBUG - VdbeComment(v, "output final row"); + VdbeComment( v, "output final row" ); #endif - /* Jump over the subroutines + /* Jump over the subroutines +*/ + sqlite3VdbeAddOp2( v, OP_Goto, 0, addrEnd ); + + /* Generate a subroutine that outputs a single row of the result + ** set. This subroutine first looks at the iUseFlag. If iUseFlag + ** is less than or equal to zero, the subroutine is a no-op. If + ** the processing calls for the query to abort, this subroutine + ** increments the iAbortFlag memory location before returning in + ** order to signal the caller to abort. */ - sqlite3VdbeAddOp2(v, OP_Goto, 0, addrEnd); - - /* Generate a subroutine that outputs a single row of the result - ** set. This subroutine first looks at the iUseFlag. If iUseFlag - ** is less than or equal to zero, the subroutine is a no-op. If - ** the processing calls for the query to abort, this subroutine - ** increments the iAbortFlag memory location before returning in - ** order to signal the caller to abort. - */ - addrSetAbort = sqlite3VdbeCurrentAddr(v); - sqlite3VdbeAddOp2(v, OP_Integer, 1, iAbortFlag); - VdbeComment(v, "set abort flag"); - sqlite3VdbeAddOp1(v, OP_Return, regOutputRow); - sqlite3VdbeResolveLabel(v, addrOutputRow); - addrOutputRow = sqlite3VdbeCurrentAddr(v); - sqlite3VdbeAddOp2(v, OP_IfPos, iUseFlag, addrOutputRow + 2); - VdbeComment(v, "Groupby result generator entry point"); - sqlite3VdbeAddOp1(v, OP_Return, regOutputRow); - finalizeAggFunctions(pParse, sAggInfo); - sqlite3ExprIfFalse(pParse, pHaving, addrOutputRow + 1, SQLITE_JUMPIFNULL); - selectInnerLoop(pParse, p, p.pEList, 0, 0, pOrderBy, - distinct, pDest, - addrOutputRow + 1, addrSetAbort); - sqlite3VdbeAddOp1(v, OP_Return, regOutputRow); - VdbeComment(v, "end groupby result generator"); - - /* Generate a subroutine that will reset the group-by accumulator - */ - sqlite3VdbeResolveLabel(v, addrReset); - resetAccumulator(pParse, sAggInfo); - sqlite3VdbeAddOp1(v, OP_Return, regReset); - - } /* endif pGroupBy. Begin aggregate queries without GROUP BY: */ - else { - ExprList pDel = null; + addrSetAbort = sqlite3VdbeCurrentAddr( v ); + sqlite3VdbeAddOp2( v, OP_Integer, 1, iAbortFlag ); + VdbeComment( v, "set abort flag" ); + sqlite3VdbeAddOp1( v, OP_Return, regOutputRow ); + sqlite3VdbeResolveLabel( v, addrOutputRow ); + addrOutputRow = sqlite3VdbeCurrentAddr( v ); + sqlite3VdbeAddOp2( v, OP_IfPos, iUseFlag, addrOutputRow + 2 ); + VdbeComment( v, "Groupby result generator entry point" ); + sqlite3VdbeAddOp1( v, OP_Return, regOutputRow ); + finalizeAggFunctions( pParse, sAggInfo ); + sqlite3ExprIfFalse( pParse, pHaving, addrOutputRow + 1, SQLITE_JUMPIFNULL ); + selectInnerLoop( pParse, p, p.pEList, 0, 0, pOrderBy, + distinct, pDest, + addrOutputRow + 1, addrSetAbort ); + sqlite3VdbeAddOp1( v, OP_Return, regOutputRow ); + VdbeComment( v, "end groupby result generator" ); + + /* Generate a subroutine that will reset the group-by accumulator + */ + sqlite3VdbeResolveLabel( v, addrReset ); + resetAccumulator( pParse, sAggInfo ); + sqlite3VdbeAddOp1( v, OP_Return, regReset ); + + } /* endif pGroupBy. Begin aggregate queries without GROUP BY: */ + else + { + ExprList pDel = null; #if !SQLITE_OMIT_BTREECOUNT - Table pTab; - if ((pTab = isSimpleCount(p, sAggInfo)) != null) { - /* If isSimpleCount() returns a pointer to a Table structure, then - ** the SQL statement is of the form: - ** - ** SELECT count() FROM - ** - ** where the Table structure returned represents table . - ** - ** This statement is so common that it is optimized specially. The - ** OP_Count instruction is executed either on the intkey table that - ** contains the data for table or on one of its indexes. It - ** is better to execute the op on an index, as indexes are almost - ** always spread across less pages than their corresponding tables. - */ - int iDb = sqlite3SchemaToIndex(pParse.db, pTab.pSchema); - int iCsr = pParse.nTab++; /* Cursor to scan b-tree */ - Index pIdx; /* Iterator variable */ - KeyInfo pKeyInfo = null; /* Keyinfo for scanned index */ - Index pBest = null; /* Best index found so far */ - 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 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. - ** - ** In practice the KeyInfo structure will not be used. It is only - ** passed to keep OP_OpenRead happy. - */ - for (pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext) { - if (pIdx.bUnordered == 0 && (null == pBest || pIdx.nColumn < pBest.nColumn)) { - pBest = pIdx; - } - } - if (pBest != null && pBest.nColumn < pTab.nCol) { - iRoot = pBest.tnum; - pKeyInfo = sqlite3IndexKeyinfo(pParse, pBest); - } - - /* Open a read-only cursor, execute the OP_Count, close the cursor. */ - sqlite3VdbeAddOp3(v, OP_OpenRead, iCsr, iRoot, iDb); - if (pKeyInfo != null) { - sqlite3VdbeChangeP4(v, -1, pKeyInfo, P4_KEYINFO_HANDOFF); - } - sqlite3VdbeAddOp2(v, OP_Count, iCsr, sAggInfo.aFunc[0].iMem); - sqlite3VdbeAddOp1(v, OP_Close, iCsr); - explainSimpleCount(pParse, pTab, pBest); - } else + Table pTab; + if ( ( pTab = isSimpleCount( p, sAggInfo ) ) != null ) + { + /* If isSimpleCount() returns a pointer to a Table structure, then + ** the SQL statement is of the form: + ** + ** SELECT count() FROM + ** + ** where the Table structure returned represents table . + ** + ** This statement is so common that it is optimized specially. The + ** OP_Count instruction is executed either on the intkey table that + ** contains the data for table or on one of its indexes. It + ** is better to execute the op on an index, as indexes are almost + ** always spread across less pages than their corresponding tables. + */ + int iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema ); + int iCsr = pParse.nTab++; /* Cursor to scan b-tree */ + Index pIdx; /* Iterator variable */ + KeyInfo pKeyInfo = null; /* Keyinfo for scanned index */ + Index pBest = null; /* Best index found so far */ + 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 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. + ** + ** In practice the KeyInfo structure will not be used. It is only + ** passed to keep OP_OpenRead happy. + */ + for ( pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext ) + { + if ( pIdx.bUnordered == 0 && ( null == pBest || pIdx.nColumn < pBest.nColumn ) ) + { + pBest = pIdx; + } + } + if ( pBest != null && pBest.nColumn < pTab.nCol ) + { + iRoot = pBest.tnum; + pKeyInfo = sqlite3IndexKeyinfo( pParse, pBest ); + } + + /* Open a read-only cursor, execute the OP_Count, close the cursor. */ + sqlite3VdbeAddOp3( v, OP_OpenRead, iCsr, iRoot, iDb ); + if ( pKeyInfo != null ) + { + sqlite3VdbeChangeP4( v, -1, pKeyInfo, P4_KEYINFO_HANDOFF ); + } + sqlite3VdbeAddOp2( v, OP_Count, iCsr, sAggInfo.aFunc[0].iMem ); + sqlite3VdbeAddOp1( v, OP_Close, iCsr ); + explainSimpleCount( pParse, pTab, pBest ); + } + else #endif //* SQLITE_OMIT_BTREECOUNT */ - { - - /* Check if the query is of one of the following forms: - ** - ** SELECT min(x) FROM ... - ** SELECT max(x) FROM ... - ** - ** If it is, then ask the code in where.c to attempt to sort results - ** as if there was an "ORDER ON x" or "ORDER ON x DESC" clause. - ** If where.c is able to produce results sorted in this order, then - ** add vdbe code to break out of the processing loop after the - ** first iteration (since the first iteration of the loop is - ** guaranteed to operate on the row with the minimum or maximum - ** value of x, the only row required). - ** - ** A special flag must be passed to sqlite3WhereBegin() to slightly - ** modify behavior as follows: - ** - ** + If the query is a "SELECT min(x)", then the loop coded by - ** where.c should not iterate over any values with a NULL value - ** for x. - ** - ** + The optimizer code in where.c (the thing that decides which - ** index or indices to use) should place a different priority on - ** satisfying the 'ORDER BY' clause than it does in other cases. - ** Refer to code and comments in where.c for details. - */ - ExprList pMinMax = null; - int flag = minMaxQuery(p); - if (flag != 0) { - Debug.Assert(!ExprHasProperty(p.pEList.a[0].pExpr, EP_xIsSelect)); - pMinMax = sqlite3ExprListDup(db, p.pEList.a[0].pExpr.x.pList, 0); - pDel = pMinMax; - if (pMinMax != null)///* && 0 == db.mallocFailed */ ) - { - pMinMax.a[0].sortOrder = (u8)(flag != WHERE_ORDERBY_MIN ? 1 : 0); - pMinMax.a[0].pExpr.op = TK_COLUMN; - } - } - - /* This case runs if the aggregate has no GROUP BY clause. The - ** processing is much simpler since there is only a single row - ** of output. - */ - resetAccumulator(pParse, sAggInfo); - pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, ref pMinMax, (byte)flag); - if (pWInfo == null) { - sqlite3ExprListDelete(db, ref pDel); - goto select_end; - } - updateAccumulator(pParse, sAggInfo); - if (pMinMax == null && flag != 0) { - sqlite3VdbeAddOp2(v, OP_Goto, 0, pWInfo.iBreak); + { + + /* Check if the query is of one of the following forms: + ** + ** SELECT min(x) FROM ... + ** SELECT max(x) FROM ... + ** + ** If it is, then ask the code in where.c to attempt to sort results + ** as if there was an "ORDER ON x" or "ORDER ON x DESC" clause. + ** If where.c is able to produce results sorted in this order, then + ** add vdbe code to break out of the processing loop after the + ** first iteration (since the first iteration of the loop is + ** guaranteed to operate on the row with the minimum or maximum + ** value of x, the only row required). + ** + ** A special flag must be passed to sqlite3WhereBegin() to slightly + ** modify behavior as follows: + ** + ** + If the query is a "SELECT min(x)", then the loop coded by + ** where.c should not iterate over any values with a NULL value + ** for x. + ** + ** + The optimizer code in where.c (the thing that decides which + ** index or indices to use) should place a different priority on + ** satisfying the 'ORDER BY' clause than it does in other cases. + ** Refer to code and comments in where.c for details. + */ + ExprList pMinMax = null; + int flag = minMaxQuery( p ); + if ( flag != 0 ) + { + Debug.Assert( !ExprHasProperty( p.pEList.a[0].pExpr, EP_xIsSelect ) ); + pMinMax = sqlite3ExprListDup( db, p.pEList.a[0].pExpr.x.pList, 0 ); + pDel = pMinMax; + if ( pMinMax != null )///* && 0 == db.mallocFailed */ ) + { + pMinMax.a[0].sortOrder = (u8)( flag != WHERE_ORDERBY_MIN ? 1 : 0 ); + pMinMax.a[0].pExpr.op = TK_COLUMN; + } + } + + /* This case runs if the aggregate has no GROUP BY clause. The + ** processing is much simpler since there is only a single row + ** of output. + */ + resetAccumulator( pParse, sAggInfo ); + pWInfo = sqlite3WhereBegin( pParse, pTabList, pWhere, ref pMinMax, (byte)flag ); + if ( pWInfo == null ) + { + sqlite3ExprListDelete( db, ref pDel ); + goto select_end; + } + updateAccumulator( pParse, sAggInfo ); + if ( pMinMax == null && flag != 0 ) + { + sqlite3VdbeAddOp2( v, OP_Goto, 0, pWInfo.iBreak ); #if SQLITE_DEBUG - VdbeComment(v, "%s() by index", - (flag == WHERE_ORDERBY_MIN ? "min" : "max")); + VdbeComment( v, "%s() by index", + ( flag == WHERE_ORDERBY_MIN ? "min" : "max" ) ); #endif - } - sqlite3WhereEnd(pWInfo); - finalizeAggFunctions(pParse, sAggInfo); - } - - pOrderBy = null; - sqlite3ExprIfFalse(pParse, pHaving, addrEnd, SQLITE_JUMPIFNULL); - selectInnerLoop(pParse, p, p.pEList, 0, 0, null, -1, - pDest, addrEnd, addrEnd); + } + sqlite3WhereEnd( pWInfo ); + finalizeAggFunctions( pParse, sAggInfo ); + } - sqlite3ExprListDelete(db, ref pDel); - } - sqlite3VdbeResolveLabel(v, addrEnd); + pOrderBy = null; + sqlite3ExprIfFalse( pParse, pHaving, addrEnd, SQLITE_JUMPIFNULL ); + selectInnerLoop( pParse, p, p.pEList, 0, 0, null, -1, + pDest, addrEnd, addrEnd ); - } /* endif aggregate query */ + sqlite3ExprListDelete( db, ref pDel ); + } + sqlite3VdbeResolveLabel( v, addrEnd ); - if (distinct >= 0) { - explainTempTable(pParse, "DISTINCT"); - } + } /* endif aggregate query */ - /* If there is an ORDER BY clause, then we need to sort the results - ** and send them to the callback one by one. - */ - if (pOrderBy != null) { - explainTempTable(pParse, "ORDER BY"); - generateSortTail(pParse, p, v, pEList.nExpr, pDest); - } + if ( distinct >= 0 ) + { + explainTempTable( pParse, "DISTINCT" ); + } - /* Jump here to skip this query - */ - sqlite3VdbeResolveLabel(v, iEnd); + /* If there is an ORDER BY clause, then we need to sort the results + ** and send them to the callback one by one. + */ + if ( pOrderBy != null ) + { + explainTempTable( pParse, "ORDER BY" ); + generateSortTail( pParse, p, v, pEList.nExpr, pDest ); + } - /* The SELECT was successfully coded. Set the return code to 0 - ** to indicate no errors. - */ - rc = 0; + /* Jump here to skip this query + */ + sqlite3VdbeResolveLabel( v, iEnd ); - /* Control jumps to here if an error is encountered above, or upon - ** successful coding of the SELECT. - */ - select_end: - explainSetInteger(ref pParse.iSelectId, iRestoreSelectId); + /* The SELECT was successfully coded. Set the return code to 0 + ** to indicate no errors. + */ + rc = 0; - /* Identify column names if results of the SELECT are to be output. - */ - if (rc == SQLITE_OK && pDest.eDest == SRT_Output) { - generateColumnNames(pParse, pTabList, pEList); - } + /* Control jumps to here if an error is encountered above, or upon + ** successful coding of the SELECT. + */ +select_end: + explainSetInteger( ref pParse.iSelectId, iRestoreSelectId ); - sqlite3DbFree(db, ref sAggInfo.aCol); - sqlite3DbFree(db, ref sAggInfo.aFunc); - return rc; - } + /* Identify column names if results of the SELECT are to be output. + */ + if ( rc == SQLITE_OK && pDest.eDest == SRT_Output ) + { + generateColumnNames( pParse, pTabList, pEList ); + } + + sqlite3DbFree( db, ref sAggInfo.aCol ); + sqlite3DbFree( db, ref sAggInfo.aFunc ); + return rc; + } #if SQLITE_DEBUG - /* - ******************************************************************************* - ** The following code is used for testing and debugging only. The code - ** that follows does not appear in normal builds. - ** - ** These routines are used to print out the content of all or part of a - ** parse structures such as Select or Expr. Such printouts are useful - ** for helping to understand what is happening inside the code generator - ** during the execution of complex SELECT statements. - ** - ** These routine are not called anywhere from within the normal - ** code base. Then are intended to be called from within the debugger - ** or from temporary "printf" statements inserted for debugging. - */ - void sqlite3PrintExpr(Expr p) { - if (!ExprHasProperty(p, EP_IntValue) && p.u.zToken != null) { - sqlite3DebugPrintf("(%s", p.u.zToken); - } else { - sqlite3DebugPrintf("(%d", p.op); - } - if (p.pLeft != null) { - sqlite3DebugPrintf(" "); - sqlite3PrintExpr(p.pLeft); - } - if (p.pRight != null) { - sqlite3DebugPrintf(" "); - sqlite3PrintExpr(p.pRight); - } - sqlite3DebugPrintf(")"); - } - void sqlite3PrintExprList(ExprList pList) { - int i; - for (i = 0; i < pList.nExpr; i++) { - sqlite3PrintExpr(pList.a[i].pExpr); - if (i < pList.nExpr - 1) { - sqlite3DebugPrintf(", "); - } - } + /* +******************************************************************************* +** The following code is used for testing and debugging only. The code +** that follows does not appear in normal builds. +** +** These routines are used to print out the content of all or part of a +** parse structures such as Select or Expr. Such printouts are useful +** for helping to understand what is happening inside the code generator +** during the execution of complex SELECT statements. +** +** These routine are not called anywhere from within the normal +** code base. Then are intended to be called from within the debugger +** or from temporary "printf" statements inserted for debugging. +*/ + void sqlite3PrintExpr( Expr p ) + { + if ( !ExprHasProperty( p, EP_IntValue ) && p.u.zToken != null ) + { + sqlite3DebugPrintf( "(%s", p.u.zToken ); + } + else + { + sqlite3DebugPrintf( "(%d", p.op ); + } + if ( p.pLeft != null ) + { + sqlite3DebugPrintf( " " ); + sqlite3PrintExpr( p.pLeft ); + } + if ( p.pRight != null ) + { + sqlite3DebugPrintf( " " ); + sqlite3PrintExpr( p.pRight ); + } + sqlite3DebugPrintf( ")" ); + } + void sqlite3PrintExprList( ExprList pList ) + { + int i; + for ( i = 0; i < pList.nExpr; i++ ) + { + sqlite3PrintExpr( pList.a[i].pExpr ); + if ( i < pList.nExpr - 1 ) + { + sqlite3DebugPrintf( ", " ); } - void sqlite3PrintSelect(Select p, int indent) { - sqlite3DebugPrintf("%*sSELECT(%p) ", indent, "", p); - sqlite3PrintExprList(p.pEList); - sqlite3DebugPrintf("\n"); - if (p.pSrc != null) { - string zPrefix; - int i; - zPrefix = "FROM"; - for (i = 0; i < p.pSrc.nSrc; i++) { - SrcList_item pItem = p.pSrc.a[i]; - sqlite3DebugPrintf("%*s ", indent + 6, zPrefix); - zPrefix = ""; - if (pItem.pSelect != null) { - sqlite3DebugPrintf("(\n"); - sqlite3PrintSelect(pItem.pSelect, indent + 10); - sqlite3DebugPrintf("%*s)", indent + 8, ""); - } else if (pItem.zName != null) { - sqlite3DebugPrintf("%s", pItem.zName); - } - if (pItem.pTab != null) { - sqlite3DebugPrintf("(vtable: %s)", pItem.pTab.zName); - } - if (pItem.zAlias != null) { - sqlite3DebugPrintf(" AS %s", pItem.zAlias); - } - if (i < p.pSrc.nSrc - 1) { - sqlite3DebugPrintf(","); - } - sqlite3DebugPrintf("\n"); - } - } - if (p.pWhere != null) { - sqlite3DebugPrintf("%*s WHERE ", indent, ""); - sqlite3PrintExpr(p.pWhere); - sqlite3DebugPrintf("\n"); - } - if (p.pGroupBy != null) { - sqlite3DebugPrintf("%*s GROUP BY ", indent, ""); - sqlite3PrintExprList(p.pGroupBy); - sqlite3DebugPrintf("\n"); - } - if (p.pHaving != null) { - sqlite3DebugPrintf("%*s HAVING ", indent, ""); - sqlite3PrintExpr(p.pHaving); - sqlite3DebugPrintf("\n"); - } - if (p.pOrderBy != null) { - sqlite3DebugPrintf("%*s ORDER BY ", indent, ""); - sqlite3PrintExprList(p.pOrderBy); - sqlite3DebugPrintf("\n"); - } + } + } + void sqlite3PrintSelect( Select p, int indent ) + { + sqlite3DebugPrintf( "%*sSELECT(%p) ", indent, "", p ); + sqlite3PrintExprList( p.pEList ); + sqlite3DebugPrintf( "\n" ); + if ( p.pSrc != null ) + { + string zPrefix; + int i; + zPrefix = "FROM"; + for ( i = 0; i < p.pSrc.nSrc; i++ ) + { + SrcList_item pItem = p.pSrc.a[i]; + sqlite3DebugPrintf( "%*s ", indent + 6, zPrefix ); + zPrefix = ""; + if ( pItem.pSelect != null ) + { + sqlite3DebugPrintf( "(\n" ); + sqlite3PrintSelect( pItem.pSelect, indent + 10 ); + sqlite3DebugPrintf( "%*s)", indent + 8, "" ); + } + else if ( pItem.zName != null ) + { + sqlite3DebugPrintf( "%s", pItem.zName ); + } + if ( pItem.pTab != null ) + { + sqlite3DebugPrintf( "(vtable: %s)", pItem.pTab.zName ); + } + if ( pItem.zAlias != null ) + { + sqlite3DebugPrintf( " AS %s", pItem.zAlias ); + } + if ( i < p.pSrc.nSrc - 1 ) + { + sqlite3DebugPrintf( "," ); + } + sqlite3DebugPrintf( "\n" ); } - /* End of the structure debug printing code - *****************************************************************************/ -#endif // * defined(SQLITE_TEST) || defined(SQLITE_DEBUG) */ + } + if ( p.pWhere != null ) + { + sqlite3DebugPrintf( "%*s WHERE ", indent, "" ); + sqlite3PrintExpr( p.pWhere ); + sqlite3DebugPrintf( "\n" ); + } + if ( p.pGroupBy != null ) + { + sqlite3DebugPrintf( "%*s GROUP BY ", indent, "" ); + sqlite3PrintExprList( p.pGroupBy ); + sqlite3DebugPrintf( "\n" ); + } + if ( p.pHaving != null ) + { + sqlite3DebugPrintf( "%*s HAVING ", indent, "" ); + sqlite3PrintExpr( p.pHaving ); + sqlite3DebugPrintf( "\n" ); + } + if ( p.pOrderBy != null ) + { + sqlite3DebugPrintf( "%*s ORDER BY ", indent, "" ); + sqlite3PrintExprList( p.pOrderBy ); + sqlite3DebugPrintf( "\n" ); + } } + /* End of the structure debug printing code + *****************************************************************************/ +#endif // * defined(SQLITE_TEST) || defined(SQLITE_DEBUG) */ + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/sqlite3_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/sqlite3_h.cs index 5b84c4e85..c3a2b1e69 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/sqlite3_h.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/sqlite3_h.cs @@ -1,703 +1,705 @@ -using System.Diagnostics; - using u8 = System.Byte; +using System.Diagnostics; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 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. - ** - ************************************************************************* - ** This header file defines the interface that the SQLite library - ** presents to client programs. If a C-function, structure, datatype, - ** or constant definition does not appear in this file, then it is - ** not a published API of SQLite, is subject to change without - ** notice, and should not be referenced by programs that use SQLite. - ** - ** Some of the definitions that are in this file are marked as - ** "experimental". Experimental interfaces are normally new - ** features recently added to SQLite. We do not anticipate changes - ** to experimental interfaces but reserve the right to make minor changes - ** if experience from use "in the wild" suggest such changes are prudent. - ** - ** The official C-language API documentation for SQLite is derived - ** from comments in this file. This file is the authoritative source - ** on how SQLite interfaces are suppose to operate. - ** - ** The name of this file under configuration management is "sqlite.h.in". - ** The makefile makes some minor changes to this file (such as inserting - ** the version number) and changes its name to "sqlite3.h" as - ** part of the build process. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#if !_SQLITE3_H_ - //#define _SQLITE3_H_ - //#include /* Needed for the definition of va_list */ - - /* - ** Make sure we can call this stuff from C++. - */ - //#if __cplusplus - //extern "C" { - //#endif - - - /* - ** Add the ability to override 'extern' - */ - //#if !SQLITE_EXTERN - //# define SQLITE_EXTERN extern - //#endif - - //#if !SQLITE_API - //# define SQLITE_API - //#endif - - - /* - ** These no-op macros are used in front of interfaces to mark those - ** interfaces as either deprecated or experimental. New applications - ** should not use deprecated interfaces - they are support for backwards - ** compatibility only. Application writers should be aware that - ** experimental interfaces are subject to change in point releases. - ** - ** These macros used to resolve to various kinds of compiler magic that - ** would generate warning messages when they were used. But that - ** compiler magic ended up generating such a flurry of bug reports - ** that we have taken it all out and gone back to using simple - ** noop macros. - */ - //#define SQLITE_DEPRECATED - //#define SQLITE_EXPERIMENTAL - - /* - ** Ensure these symbols were not defined by some previous header file. - */ - //#if SQLITE_VERSION - //# undef SQLITE_VERSION - //#endif - //#if SQLITE_VERSION_NUMBER - //# undef SQLITE_VERSION_NUMBER - //#endif - - /* - ** CAPI3REF: Compile-Time Library Version Numbers - ** - ** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header - ** evaluates to a string literal that is the SQLite version in the - ** format "X.Y.Z" where X is the major version number (always 3 for - ** SQLite3) and Y is the minor version number and Z is the release number.)^ - ** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer - ** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same - ** numbers used in [SQLITE_VERSION].)^ - ** The SQLITE_VERSION_NUMBER for any given release of SQLite will also - ** be larger than the release from which it is derived. Either Y will - ** be held constant and Z will be incremented or else Y will be incremented - ** and Z will be reset to zero. - ** - ** Since version 3.6.18, SQLite source code has been stored in the - ** Fossil configuration management - ** system. ^The SQLITE_SOURCE_ID macro evaluates to - ** a string which identifies a particular check-in of SQLite - ** within its configuration management system. ^The SQLITE_SOURCE_ID - ** string contains the date and time of the check-in (UTC) and an SHA1 - ** hash of the entire source tree. - ** - ** See also: [sqlite3_libversion()], - ** [sqlite3_libversion_number()], [sqlite3_sourceid()], - ** [sqlite_version()] and [sqlite_source_id()]. - */ - //#define SQLITE_VERSION "3.7.7" - //#define SQLITE_VERSION_NUMBER 3007007 - //#define SQLITE_SOURCE_ID "2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2" - public const string SQLITE_VERSION = "3.7.7(C#)"; - public const int SQLITE_VERSION_NUMBER = 300700701; - public const string SQLITE_SOURCE_ID = "2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2"; - - /* - ** CAPI3REF: Run-Time Library Version Numbers - ** KEYWORDS: sqlite3_version, sqlite3_sourceid - ** - ** These interfaces provide the same information as the [SQLITE_VERSION], - ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros - ** but are associated with the library instead of the header file. ^(Cautious - ** programmers might include Debug.Assert() statements in their application to - ** verify that values returned by these interfaces match the macros in - ** the header, and thus insure that the application is - ** compiled with matching library and header files. - ** - **
-        ** Debug.Assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
-        ** Debug.Assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
-        ** Debug.Assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
-        ** 
)^ - ** - ** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION] - ** macro. ^The sqlite3_libversion() function returns a pointer to the - ** to the sqlite3_version[] string constant. The sqlite3_libversion() - ** function is provided for use in DLLs since DLL users usually do not have - ** direct access to string constants within the DLL. ^The - ** sqlite3_libversion_number() function returns an integer equal to - ** [SQLITE_VERSION_NUMBER]. ^The sqlite3_sourceid() function returns - ** a pointer to a string constant whose value is the same as the - ** [SQLITE_SOURCE_ID] C preprocessor macro. - ** - ** See also: [sqlite_version()] and [sqlite_source_id()]. - */ - //SQLITE_API SQLITE_EXTERN const char sqlite3_version[]; - //SQLITE_API string sqlite3_libversion(void); - //SQLITE_API string sqlite3_sourceid(void); - //SQLITE_API int sqlite3_libversion_number(void); - - /* - ** CAPI3REF: Run-Time Library Compilation Options Diagnostics - ** - ** ^The sqlite3_compileoption_used() function returns 0 or 1 - ** indicating whether the specified option was defined at - ** compile time. ^The SQLITE_ prefix may be omitted from the - ** option name passed to sqlite3_compileoption_used(). - ** - ** ^The sqlite3_compileoption_get() function allows iterating - ** over the list of options that were defined at compile time by - ** returning the N-th compile time option string. ^If N is out of range, - ** sqlite3_compileoption_get() returns a NULL pointer. ^The SQLITE_ - ** prefix is omitted from any strings returned by - ** sqlite3_compileoption_get(). - ** - ** ^Support for the diagnostic functions sqlite3_compileoption_used() - ** and sqlite3_compileoption_get() may be omitted by specifying the - ** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time. - ** - ** See also: SQL functions [sqlite_compileoption_used()] and - ** [sqlite_compileoption_get()] and the [compile_options pragma]. - */ - //#if !SQLITE_OMIT_COMPILEOPTION_DIAGS - //SQLITE_API int sqlite3_compileoption_used(string zOptName); - //SQLITE_API string sqlite3_compileoption_get(int N); - //#endif - - /* - ** CAPI3REF: Test To See If The Library Is Threadsafe - ** - ** ^The sqlite3_threadsafe() function returns zero if and only if - ** SQLite was compiled mutexing code omitted due to the - ** [SQLITE_THREADSAFE] compile-time option being set to 0. - ** - ** SQLite can be compiled with or without mutexes. When - ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes - ** are enabled and SQLite is threadsafe. When the - ** [SQLITE_THREADSAFE] macro is 0, - ** the mutexes are omitted. Without the mutexes, it is not safe - ** to use SQLite concurrently from more than one thread. - ** - ** Enabling mutexes incurs a measurable performance penalty. - ** So if speed is of utmost importance, it makes sense to disable - ** the mutexes. But for maximum safety, mutexes should be enabled. - ** ^The default behavior is for mutexes to be enabled. - ** - ** This interface can be used by an application to make sure that the - ** version of SQLite that it is linking against was compiled with - ** the desired setting of the [SQLITE_THREADSAFE] macro. - ** - ** This interface only reports on the compile-time mutex setting - ** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with - ** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but - ** can be fully or partially disabled using a call to [sqlite3_config()] - ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD], - ** or [SQLITE_CONFIG_MUTEX]. ^(The return value of the - ** sqlite3_threadsafe() function shows only the compile-time setting of - ** thread safety, not any run-time changes to that setting made by - ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe() - ** is unchanged by calls to sqlite3_config().)^ - ** - ** See the [threading mode] documentation for additional information. - */ - //SQLITE_API int sqlite3_threadsafe(void); - - /* - ** CAPI3REF: Database Connection Handle - ** KEYWORDS: {database connection} {database connections} - ** - ** Each open SQLite database is represented by a pointer to an instance of - ** the opaque structure named "sqlite3". It is useful to think of an sqlite3 - ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and - ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()] - ** is its destructor. There are many other interfaces (such as - ** [sqlite3_prepare_v2()], [sqlite3_create_function()], and - ** [sqlite3_busy_timeout()] to name but three) that are methods on an - ** sqlite3 object. - */ - //typedef struct sqlite3 sqlite3; - - /* - ** CAPI3REF: 64-Bit Integer Types - ** KEYWORDS: sqlite_int64 sqlite_uint64 - ** - ** Because there is no cross-platform way to specify 64-bit integer types - ** SQLite includes typedefs for 64-bit signed and unsigned integers. - ** - ** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions. - ** The sqlite_int64 and sqlite_uint64 types are supported for backwards - ** compatibility only. - ** - ** ^The sqlite3_int64 and sqlite_int64 types can store integer values - ** between -9223372036854775808 and +9223372036854775807 inclusive. ^The - ** sqlite3_uint64 and sqlite_uint64 types can store integer values - ** between 0 and +18446744073709551615 inclusive. - */ - //#if SQLITE_INT64_TYPE - // typedef SQLITE_INT64_TYPE sqlite_int64; - // typedef unsigned SQLITE_INT64_TYPE sqlite_uint64; - //#elif defined(_MSC_VER) || defined(__BORLANDC__) - // typedef __int64 sqlite_int64; - // typedef unsigned __int64 sqlite_uint64; - //#else - // typedef long long int sqlite_int64; - // typedef unsigned long long int sqlite_uint64; - //#endif - //typedef sqlite_int64 sqlite3_int64; - //typedef sqlite_uint64 sqlite3_uint64; - - /* - ** If compiling for a processor that lacks floating point support, - ** substitute integer for floating-point. - */ - //#if SQLITE_OMIT_FLOATING_POINT - //# define double sqlite3_int64 - //#endif - - /* - ** CAPI3REF: Closing A Database Connection - ** - ** ^The sqlite3_close() routine is the destructor for the [sqlite3] object. - ** ^Calls to sqlite3_close() return SQLITE_OK if the [sqlite3] object is - ** successfully destroyed and all associated resources are deallocated. - ** - ** Applications must [sqlite3_finalize | finalize] all [prepared statements] - ** and [sqlite3_blob_close | close] all [BLOB handles] associated with - ** the [sqlite3] object prior to attempting to close the object. ^If - ** sqlite3_close() is called on a [database connection] that still has - ** outstanding [prepared statements] or [BLOB handles], then it returns - ** SQLITE_BUSY. - ** - ** ^If [sqlite3_close()] is invoked while a transaction is open, - ** the transaction is automatically rolled back. - ** - ** The C parameter to [sqlite3_close(C)] must be either a NULL - ** pointer or an [sqlite3] object pointer obtained - ** from [sqlite3_open()], [sqlite3_open16()], or - ** [sqlite3_open_v2()], and not previously closed. - ** ^Calling sqlite3_close() with a NULL pointer argument is a - ** harmless no-op. - */ - //SQLITE_API int sqlite3_close(sqlite3 ); - - /* - ** The type for a callback function. - ** This is legacy and deprecated. It is included for historical - ** compatibility and is not documented. - */ - //typedef int (*sqlite3_callback)(void*,int,char**, char*); - - /* - ** CAPI3REF: One-Step Query Execution Interface - ** - ** The sqlite3_exec() interface is a convenience wrapper around - ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()], - ** that allows an application to run multiple statements of SQL - ** without having to use a lot of C code. - ** - ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded, - ** semicolon-separate SQL statements passed into its 2nd argument, - ** in the context of the [database connection] passed in as its 1st - ** argument. ^If the callback function of the 3rd argument to - ** sqlite3_exec() is not NULL, then it is invoked for each result row - ** coming out of the evaluated SQL statements. ^The 4th argument to - ** sqlite3_exec() is relayed through to the 1st argument of each - ** callback invocation. ^If the callback pointer to sqlite3_exec() - ** is NULL, then no callback is ever invoked and result rows are - ** ignored. - ** - ** ^If an error occurs while evaluating the SQL statements passed into - ** sqlite3_exec(), then execution of the current statement stops and - ** subsequent statements are skipped. ^If the 5th parameter to sqlite3_exec() - ** is not NULL then any error message is written into memory obtained - ** from [sqlite3_malloc()] and passed back through the 5th parameter. - ** To avoid memory leaks, the application should invoke [sqlite3_free()] - ** on error message strings returned through the 5th parameter of - ** of sqlite3_exec() after the error message string is no longer needed. - ** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors - ** occur, then sqlite3_exec() sets the pointer in its 5th parameter to - ** NULL before returning. - ** - ** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec() - ** routine returns SQLITE_ABORT without invoking the callback again and - ** without running any subsequent SQL statements. - ** - ** ^The 2nd argument to the sqlite3_exec() callback function is the - ** number of columns in the result. ^The 3rd argument to the sqlite3_exec() - ** callback is an array of pointers to strings obtained as if from - ** [sqlite3_column_text()], one for each column. ^If an element of a - ** result row is NULL then the corresponding string pointer for the - ** sqlite3_exec() callback is a NULL pointer. ^The 4th argument to the - ** sqlite3_exec() callback is an array of pointers to strings where each - ** entry represents the name of corresponding result column as obtained - ** from [sqlite3_column_name()]. - ** - ** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer - ** to an empty string, or a pointer that contains only whitespace and/or - ** SQL comments, then no SQL statements are evaluated and the database - ** is not changed. - ** - ** Restrictions: - ** - **
    - **
  • The application must insure that the 1st parameter to sqlite3_exec() - ** is a valid and open [database connection]. - **
  • The application must not close [database connection] specified by - ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running. - **
  • The application must not modify the SQL statement text passed into - ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running. - **
- */ - //SQLITE_API int sqlite3_exec( - // sqlite3*, /* An open database */ - // string sql, /* SQL to be evaluated */ - // int (*callback)(void*,int,char**,char*), /* Callback function */ - // void *, /* 1st argument to callback */ - // char **errmsg /* Error msg written here */ - //); - - /* - ** CAPI3REF: Result Codes - ** KEYWORDS: SQLITE_OK {error code} {error codes} - ** KEYWORDS: {result code} {result codes} - ** - ** Many SQLite functions return an integer result code from the set shown - ** here in order to indicates success or failure. - ** - ** New error codes may be added in future versions of SQLite. - ** - ** See also: [SQLITE_IOERR_READ | extended result codes], - ** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes]. - */ - //#define SQLITE_OK 0 /* Successful result */ - ///* beginning-of-error-codes */ - //#define SQLITE_ERROR 1 /* SQL error or missing database */ - //#define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */ - //#define SQLITE_PERM 3 /* Access permission denied */ - //#define SQLITE_ABORT 4 /* Callback routine requested an abort */ - //#define SQLITE_BUSY 5 /* The database file is locked */ - //#define SQLITE_LOCKED 6 /* A table in the database is locked */ - //#define SQLITE_NOMEM 7 /* A malloc() failed */ - //#define SQLITE_READONLY 8 /* Attempt to write a readonly database */ - //#define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/ - //#define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */ - //#define SQLITE_CORRUPT 11 /* The database disk image is malformed */ - //#define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */ - //#define SQLITE_FULL 13 /* Insertion failed because database is full */ - //#define SQLITE_CANTOPEN 14 /* Unable to open the database file */ - //#define SQLITE_PROTOCOL 15 /* Database lock protocol error */ - //#define SQLITE_EMPTY 16 /* Database is empty */ - //#define SQLITE_SCHEMA 17 /* The database schema changed */ - //#define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */ - //#define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */ - //#define SQLITE_MISMATCH 20 /* Data type mismatch */ - //#define SQLITE_MISUSE 21 /* Library used incorrectly */ - //#define SQLITE_NOLFS 22 /* Uses OS features not supported on host */ - //#define SQLITE_AUTH 23 /* Authorization denied */ - //#define SQLITE_FORMAT 24 /* Auxiliary database format error */ - //#define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */ - //#define SQLITE_NOTADB 26 /* File opened that is not a database file */ - //#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */ - //#define SQLITE_DONE 101 /* sqlite3_step() has finished executing */ - /* end-of-error-codes */ - public const int SQLITE_OK = 0; - public const int SQLITE_ERROR = 1; - public const int SQLITE_INTERNAL = 2; - public const int SQLITE_PERM = 3; - public const int SQLITE_ABORT = 4; - public const int SQLITE_BUSY = 5; - public const int SQLITE_LOCKED = 6; - public const int SQLITE_NOMEM = 7; - public const int SQLITE_READONLY = 8; - public const int SQLITE_INTERRUPT = 9; - public const int SQLITE_IOERR = 10; - public const int SQLITE_CORRUPT = 11; - public const int SQLITE_NOTFOUND = 12; - public const int SQLITE_FULL = 13; - public const int SQLITE_CANTOPEN = 14; - public const int SQLITE_PROTOCOL = 15; - public const int SQLITE_EMPTY = 16; - public const int SQLITE_SCHEMA = 17; - public const int SQLITE_TOOBIG = 18; - public const int SQLITE_CONSTRAINT = 19; - public const int SQLITE_MISMATCH = 20; - public const int SQLITE_MISUSE = 21; - public const int SQLITE_NOLFS = 22; - public const int SQLITE_AUTH = 23; - public const int SQLITE_FORMAT = 24; - public const int SQLITE_RANGE = 25; - public const int SQLITE_NOTADB = 26; - public const int SQLITE_ROW = 100; - public const int SQLITE_DONE = 101; - - /* - ** CAPI3REF: Extended Result Codes - ** KEYWORDS: {extended error code} {extended error codes} - ** KEYWORDS: {extended result code} {extended result codes} - ** - ** In its default configuration, SQLite API routines return one of 26 integer - ** [SQLITE_OK | result codes]. However, experience has shown that many of - ** these result codes are too coarse-grained. They do not provide as - ** much information about problems as programmers might like. In an effort to - ** address this, newer versions of SQLite (version 3.3.8 and later) include - ** support for additional result codes that provide more detailed information - ** about errors. The extended result codes are enabled or disabled - ** on a per database connection basis using the - ** [sqlite3_extended_result_codes()] API. - ** - ** Some of the available extended result codes are listed here. - ** One may expect the number of extended result codes will be expand - ** over time. Software that uses extended result codes should expect - ** to see new result codes in future releases of SQLite. - ** - ** The SQLITE_OK result code will never be extended. It will always - ** be exactly zero. - */ - //#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8)) - //#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8)) - //#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8)) - //#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8)) - //#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8)) - //#define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8)) - //#define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8)) - //#define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8)) - //#define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8)) - //#define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8)) - //#define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8)) - //#define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8)) - //#define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8)) - //#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8)) - //#define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8)) - //#define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8)) - //#define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8)) - //#define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8)) - //#define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8)) - //#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8)) - //#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8)) - //#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8)) - //#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) - //#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) - //#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) - //#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8)) - //#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8)) - //#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8)) - const int SQLITE_IOERR_READ = (SQLITE_IOERR | (1 << 8)); - const int SQLITE_IOERR_SHORT_READ = (SQLITE_IOERR | (2 << 8)); - const int SQLITE_IOERR_WRITE = (SQLITE_IOERR | (3 << 8)); - const int SQLITE_IOERR_FSYNC = (SQLITE_IOERR | (4 << 8)); - const int SQLITE_IOERR_DIR_FSYNC = (SQLITE_IOERR | (5 << 8)); - const int SQLITE_IOERR_TRUNCATE = (SQLITE_IOERR | (6 << 8)); - const int SQLITE_IOERR_FSTAT = (SQLITE_IOERR | (7 << 8)); - const int SQLITE_IOERR_UNLOCK = (SQLITE_IOERR | (8 << 8)); - const int SQLITE_IOERR_RDLOCK = (SQLITE_IOERR | (9 << 8)); - const int SQLITE_IOERR_DELETE = (SQLITE_IOERR | (10 << 8)); - const int SQLITE_IOERR_BLOCKED = (SQLITE_IOERR | (11 << 8)); - const int SQLITE_IOERR_NOMEM = (SQLITE_IOERR | (12 << 8)); - const int SQLITE_IOERR_ACCESS = (SQLITE_IOERR | (13 << 8)); - const int SQLITE_IOERR_CHECKRESERVEDLOCK = (SQLITE_IOERR | (14 << 8)); - const int SQLITE_IOERR_LOCK = (SQLITE_IOERR | (15 << 8)); - const int SQLITE_IOERR_CLOSE = (SQLITE_IOERR | (16 << 8)); - const int SQLITE_IOERR_DIR_CLOSE = (SQLITE_IOERR | (17 << 8)); - const int SQLITE_IOERR_SHMOPEN = (SQLITE_IOERR | (18 << 8)); - const int SQLITE_IOERR_SHMSIZE = (SQLITE_IOERR | (19 << 8)); - const int SQLITE_IOERR_SHMLOCK = (SQLITE_IOERR | (20 << 8)); - const int SQLITE_IOERR_SHMMAP = (SQLITE_IOERR | (21 << 8)); - const int SQLITE_IOERR_SEEK = (SQLITE_IOERR | (22 << 8)); - const int SQLITE_LOCKED_SHAREDCACHE = (SQLITE_LOCKED | (1 << 8)); - const int SQLITE_BUSY_RECOVERY = (SQLITE_BUSY | (1 << 8)); - const int SQLITE_CANTOPEN_NOTEMPDIR = (SQLITE_CANTOPEN | (1 << 8)); - const int SQLITE_CORRUPT_VTAB = (SQLITE_CORRUPT | (1 << 8)); - const int SQLITE_READONLY_RECOVERY = (SQLITE_READONLY | (1 << 8)); - const int SQLITE_READONLY_CANTLOCK = (SQLITE_READONLY | (2 << 8)); - - /* - ** CAPI3REF: Flags For File Open Operations - ** - ** These bit values are intended for use in the - ** 3rd parameter to the [sqlite3_open_v2()] interface and - ** in the 4th parameter to the [sqlite3_vfs.xOpen] method. - */ - //#define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */ - //#define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */ - //#define SQLITE_OPEN_CREATE 0x00000004 /* Ok for sqlite3_open_v2() */ - //#define SQLITE_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */ - //#define SQLITE_OPEN_EXCLUSIVE 0x00000010 /* VFS only */ - //#define SQLITE_OPEN_AUTOPROXY 0x00000020 /* VFS only */ - //#define SQLITE_OPEN_URI 0x00000040 /* Ok for sqlite3_open_v2() */ - //#define SQLITE_OPEN_MAIN_DB 0x00000100 /* VFS only */ - //#define SQLITE_OPEN_TEMP_DB 0x00000200 /* VFS only */ - //#define SQLITE_OPEN_TRANSIENT_DB 0x00000400 /* VFS only */ - //#define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 /* VFS only */ - //#define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 /* VFS only */ - //#define SQLITE_OPEN_SUBJOURNAL 0x00002000 /* VFS only */ - //#define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */ - //#define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */ - //#define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */ - //#define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ - //#define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ - //#define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ - - /* Reserved: 0x00F00000 */ - - public const int SQLITE_OPEN_READONLY = 0x00000001; - public const int SQLITE_OPEN_READWRITE = 0x00000002; - public const int SQLITE_OPEN_CREATE = 0x00000004; - public const int SQLITE_OPEN_DELETEONCLOSE = 0x00000008; - public const int SQLITE_OPEN_EXCLUSIVE = 0x00000010; - public const int SQLITE_OPEN_AUTOPROXY = 0x00000020; - public const int SQLITE_OPEN_URI = 0x00000040; - public const int SQLITE_OPEN_MAIN_DB = 0x00000100; - public const int SQLITE_OPEN_TEMP_DB = 0x00000200; - public const int SQLITE_OPEN_TRANSIENT_DB = 0x00000400; - public const int SQLITE_OPEN_MAIN_JOURNAL = 0x00000800; - public const int SQLITE_OPEN_TEMP_JOURNAL = 0x00001000; - public const int SQLITE_OPEN_SUBJOURNAL = 0x00002000; - public const int SQLITE_OPEN_MASTER_JOURNAL = 0x00004000; - public const int SQLITE_OPEN_NOMUTEX = 0x00008000; - public const int SQLITE_OPEN_FULLMUTEX = 0x00010000; - public const int SQLITE_OPEN_SHAREDCACHE = 0x00020000; - public const int SQLITE_OPEN_PRIVATECACHE = 0x00040000; - public const int SQLITE_OPEN_WAL = 0x00080000; - - /* - ** CAPI3REF: Device Characteristics - ** - ** The xDeviceCharacteristics method of the [sqlite3_io_methods] - ** object returns an integer which is a vector of the these - ** bit values expressing I/O characteristics of the mass storage - ** device that holds the file that the [sqlite3_io_methods] - ** refers to. - ** - ** The SQLITE_IOCAP_ATOMIC property means that all writes of - ** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values - ** mean that writes of blocks that are nnn bytes in size and - ** are aligned to an address which is an integer multiple of - ** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means - ** that when data is appended to a file, the data is appended - ** first then the size of the file is extended, never the other - ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that - ** information is written to disk in the same order as calls - ** to xWrite(). - */ - //#define SQLITE_IOCAP_ATOMIC 0x00000001 - //#define SQLITE_IOCAP_ATOMIC512 0x00000002 - //#define SQLITE_IOCAP_ATOMIC1K 0x00000004 - //#define SQLITE_IOCAP_ATOMIC2K 0x00000008 - //#define SQLITE_IOCAP_ATOMIC4K 0x00000010 - //#define SQLITE_IOCAP_ATOMIC8K 0x00000020 - //#define SQLITE_IOCAP_ATOMIC16K 0x00000040 - //#define SQLITE_IOCAP_ATOMIC32K 0x00000080 - //#define SQLITE_IOCAP_ATOMIC64K 0x00000100 - //#define SQLITE_IOCAP_SAFE_APPEND 0x00000200 - //#define SQLITE_IOCAP_SEQUENTIAL 0x00000400 - //#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800 - const int SQLITE_IOCAP_ATOMIC = 0x00000001; - const int SQLITE_IOCAP_ATOMIC512 = 0x00000002; - const int SQLITE_IOCAP_ATOMIC1K = 0x00000004; - const int SQLITE_IOCAP_ATOMIC2K = 0x00000008; - const int SQLITE_IOCAP_ATOMIC4K = 0x00000010; - const int SQLITE_IOCAP_ATOMIC8K = 0x00000020; - const int SQLITE_IOCAP_ATOMIC16K = 0x00000040; - const int SQLITE_IOCAP_ATOMIC32K = 0x00000080; - const int SQLITE_IOCAP_ATOMIC64K = 0x00000100; - const int SQLITE_IOCAP_SAFE_APPEND = 0x00000200; - const int SQLITE_IOCAP_SEQUENTIAL = 0x00000400; - const int SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN = 0x00000800; - - /* - ** CAPI3REF: File Locking Levels - ** - ** SQLite uses one of these integer values as the second - ** argument to calls it makes to the xLock() and xUnlock() methods - ** of an [sqlite3_io_methods] object. - */ - //#define SQLITE_LOCK_NONE 0 - //#define SQLITE_LOCK_SHARED 1 - //#define SQLITE_LOCK_RESERVED 2 - //#define SQLITE_LOCK_PENDING 3 - //#define SQLITE_LOCK_EXCLUSIVE 4 - const int SQLITE_LOCK_NONE = 0; - const int SQLITE_LOCK_SHARED = 1; - const int SQLITE_LOCK_RESERVED = 2; - const int SQLITE_LOCK_PENDING = 3; - const int SQLITE_LOCK_EXCLUSIVE = 4; - - /* - ** CAPI3REF: Synchronization Type Flags - ** - ** When SQLite invokes the xSync() method of an - ** [sqlite3_io_methods] object it uses a combination of - ** these integer values as the second argument. - ** - ** When the SQLITE_SYNC_DATAONLY flag is used, it means that the - ** sync operation only needs to flush data to mass storage. Inode - ** information need not be flushed. If the lower four bits of the flag - ** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics. - ** If the lower four bits equal SQLITE_SYNC_FULL, that means - ** to use Mac OS X style fullsync instead of fsync(). - ** - ** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags - ** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL - ** settings. The [synchronous pragma] determines when calls to the - ** xSync VFS method occur and applies uniformly across all platforms. - ** The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how - ** energetic or rigorous or forceful the sync operations are and - ** only make a difference on Mac OSX for the default SQLite code. - ** (Third-party VFS implementations might also make the distinction - ** between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the - ** operating systems natively supported by SQLite, only Mac OSX - ** cares about the difference.) - */ - //#define SQLITE_SYNC_NORMAL 0x00002 - //#define SQLITE_SYNC_FULL 0x00003 - //#define SQLITE_SYNC_DATAONLY 0x00010 - const int SQLITE_SYNC_NORMAL = 0x00002; - const int SQLITE_SYNC_FULL = 0x00003; - const int SQLITE_SYNC_DATAONLY = 0x00010; - - /* - ** CAPI3REF: OS Interface Open File Handle - ** - ** An [sqlite3_file] object represents an open file in the - ** [sqlite3_vfs | OS interface layer]. Individual OS interface - ** implementations will - ** want to subclass this object by appending additional fields - ** for their own use. The pMethods entry is a pointer to an - ** [sqlite3_io_methods] object that defines methods for performing - ** I/O operations on the open file. - */ - //typedef struct sqlite3_file sqlite3_file; - //struct sqlite3_file { - // const struct sqlite3_io_methods *pMethods; /* Methods for an open file */ - //}; - public partial class sqlite3_file { - public sqlite3_io_methods pMethods;/* Must be first */ - } +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 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. + ** + ************************************************************************* + ** This header file defines the interface that the SQLite library + ** presents to client programs. If a C-function, structure, datatype, + ** or constant definition does not appear in this file, then it is + ** not a published API of SQLite, is subject to change without + ** notice, and should not be referenced by programs that use SQLite. + ** + ** Some of the definitions that are in this file are marked as + ** "experimental". Experimental interfaces are normally new + ** features recently added to SQLite. We do not anticipate changes + ** to experimental interfaces but reserve the right to make minor changes + ** if experience from use "in the wild" suggest such changes are prudent. + ** + ** The official C-language API documentation for SQLite is derived + ** from comments in this file. This file is the authoritative source + ** on how SQLite interfaces are suppose to operate. + ** + ** The name of this file under configuration management is "sqlite.h.in". + ** The makefile makes some minor changes to this file (such as inserting + ** the version number) and changes its name to "sqlite3.h" as + ** part of the build process. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#if !_SQLITE3_H_ + //#define _SQLITE3_H_ + //#include /* Needed for the definition of va_list */ + + /* + ** Make sure we can call this stuff from C++. + */ + //#if __cplusplus + //extern "C" { + //#endif + + + /* + ** Add the ability to override 'extern' + */ + //#if !SQLITE_EXTERN + //# define SQLITE_EXTERN extern + //#endif + + //#if !SQLITE_API + //# define SQLITE_API + //#endif + + + /* + ** These no-op macros are used in front of interfaces to mark those + ** interfaces as either deprecated or experimental. New applications + ** should not use deprecated interfaces - they are support for backwards + ** compatibility only. Application writers should be aware that + ** experimental interfaces are subject to change in point releases. + ** + ** These macros used to resolve to various kinds of compiler magic that + ** would generate warning messages when they were used. But that + ** compiler magic ended up generating such a flurry of bug reports + ** that we have taken it all out and gone back to using simple + ** noop macros. + */ + //#define SQLITE_DEPRECATED + //#define SQLITE_EXPERIMENTAL + + /* + ** Ensure these symbols were not defined by some previous header file. + */ + //#if SQLITE_VERSION + //# undef SQLITE_VERSION + //#endif + //#if SQLITE_VERSION_NUMBER + //# undef SQLITE_VERSION_NUMBER + //#endif + + /* + ** CAPI3REF: Compile-Time Library Version Numbers + ** + ** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header + ** evaluates to a string literal that is the SQLite version in the + ** format "X.Y.Z" where X is the major version number (always 3 for + ** SQLite3) and Y is the minor version number and Z is the release number.)^ + ** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer + ** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same + ** numbers used in [SQLITE_VERSION].)^ + ** The SQLITE_VERSION_NUMBER for any given release of SQLite will also + ** be larger than the release from which it is derived. Either Y will + ** be held constant and Z will be incremented or else Y will be incremented + ** and Z will be reset to zero. + ** + ** Since version 3.6.18, SQLite source code has been stored in the + ** Fossil configuration management + ** system. ^The SQLITE_SOURCE_ID macro evaluates to + ** a string which identifies a particular check-in of SQLite + ** within its configuration management system. ^The SQLITE_SOURCE_ID + ** string contains the date and time of the check-in (UTC) and an SHA1 + ** hash of the entire source tree. + ** + ** See also: [sqlite3_libversion()], + ** [sqlite3_libversion_number()], [sqlite3_sourceid()], + ** [sqlite_version()] and [sqlite_source_id()]. + */ + //#define SQLITE_VERSION "3.7.7" + //#define SQLITE_VERSION_NUMBER 3007007 + //#define SQLITE_SOURCE_ID "2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2" + public const string SQLITE_VERSION = "3.7.7(C#)"; + public const int SQLITE_VERSION_NUMBER = 300700701; + public const string SQLITE_SOURCE_ID = "2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2"; + + /* + ** CAPI3REF: Run-Time Library Version Numbers + ** KEYWORDS: sqlite3_version, sqlite3_sourceid + ** + ** These interfaces provide the same information as the [SQLITE_VERSION], + ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros + ** but are associated with the library instead of the header file. ^(Cautious + ** programmers might include Debug.Assert() statements in their application to + ** verify that values returned by these interfaces match the macros in + ** the header, and thus insure that the application is + ** compiled with matching library and header files. + ** + **
+    ** Debug.Assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
+    ** Debug.Assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
+    ** Debug.Assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
+    ** 
)^ + ** + ** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION] + ** macro. ^The sqlite3_libversion() function returns a pointer to the + ** to the sqlite3_version[] string constant. The sqlite3_libversion() + ** function is provided for use in DLLs since DLL users usually do not have + ** direct access to string constants within the DLL. ^The + ** sqlite3_libversion_number() function returns an integer equal to + ** [SQLITE_VERSION_NUMBER]. ^The sqlite3_sourceid() function returns + ** a pointer to a string constant whose value is the same as the + ** [SQLITE_SOURCE_ID] C preprocessor macro. + ** + ** See also: [sqlite_version()] and [sqlite_source_id()]. + */ + //SQLITE_API SQLITE_EXTERN const char sqlite3_version[]; + //SQLITE_API string sqlite3_libversion(void); + //SQLITE_API string sqlite3_sourceid(void); + //SQLITE_API int sqlite3_libversion_number(void); + + /* + ** CAPI3REF: Run-Time Library Compilation Options Diagnostics + ** + ** ^The sqlite3_compileoption_used() function returns 0 or 1 + ** indicating whether the specified option was defined at + ** compile time. ^The SQLITE_ prefix may be omitted from the + ** option name passed to sqlite3_compileoption_used(). + ** + ** ^The sqlite3_compileoption_get() function allows iterating + ** over the list of options that were defined at compile time by + ** returning the N-th compile time option string. ^If N is out of range, + ** sqlite3_compileoption_get() returns a NULL pointer. ^The SQLITE_ + ** prefix is omitted from any strings returned by + ** sqlite3_compileoption_get(). + ** + ** ^Support for the diagnostic functions sqlite3_compileoption_used() + ** and sqlite3_compileoption_get() may be omitted by specifying the + ** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time. + ** + ** See also: SQL functions [sqlite_compileoption_used()] and + ** [sqlite_compileoption_get()] and the [compile_options pragma]. + */ + //#if !SQLITE_OMIT_COMPILEOPTION_DIAGS + //SQLITE_API int sqlite3_compileoption_used(string zOptName); + //SQLITE_API string sqlite3_compileoption_get(int N); + //#endif + + /* + ** CAPI3REF: Test To See If The Library Is Threadsafe + ** + ** ^The sqlite3_threadsafe() function returns zero if and only if + ** SQLite was compiled mutexing code omitted due to the + ** [SQLITE_THREADSAFE] compile-time option being set to 0. + ** + ** SQLite can be compiled with or without mutexes. When + ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes + ** are enabled and SQLite is threadsafe. When the + ** [SQLITE_THREADSAFE] macro is 0, + ** the mutexes are omitted. Without the mutexes, it is not safe + ** to use SQLite concurrently from more than one thread. + ** + ** Enabling mutexes incurs a measurable performance penalty. + ** So if speed is of utmost importance, it makes sense to disable + ** the mutexes. But for maximum safety, mutexes should be enabled. + ** ^The default behavior is for mutexes to be enabled. + ** + ** This interface can be used by an application to make sure that the + ** version of SQLite that it is linking against was compiled with + ** the desired setting of the [SQLITE_THREADSAFE] macro. + ** + ** This interface only reports on the compile-time mutex setting + ** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with + ** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but + ** can be fully or partially disabled using a call to [sqlite3_config()] + ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD], + ** or [SQLITE_CONFIG_MUTEX]. ^(The return value of the + ** sqlite3_threadsafe() function shows only the compile-time setting of + ** thread safety, not any run-time changes to that setting made by + ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe() + ** is unchanged by calls to sqlite3_config().)^ + ** + ** See the [threading mode] documentation for additional information. + */ + //SQLITE_API int sqlite3_threadsafe(void); + + /* + ** CAPI3REF: Database Connection Handle + ** KEYWORDS: {database connection} {database connections} + ** + ** Each open SQLite database is represented by a pointer to an instance of + ** the opaque structure named "sqlite3". It is useful to think of an sqlite3 + ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and + ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()] + ** is its destructor. There are many other interfaces (such as + ** [sqlite3_prepare_v2()], [sqlite3_create_function()], and + ** [sqlite3_busy_timeout()] to name but three) that are methods on an + ** sqlite3 object. + */ + //typedef struct sqlite3 sqlite3; + + /* + ** CAPI3REF: 64-Bit Integer Types + ** KEYWORDS: sqlite_int64 sqlite_uint64 + ** + ** Because there is no cross-platform way to specify 64-bit integer types + ** SQLite includes typedefs for 64-bit signed and unsigned integers. + ** + ** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions. + ** The sqlite_int64 and sqlite_uint64 types are supported for backwards + ** compatibility only. + ** + ** ^The sqlite3_int64 and sqlite_int64 types can store integer values + ** between -9223372036854775808 and +9223372036854775807 inclusive. ^The + ** sqlite3_uint64 and sqlite_uint64 types can store integer values + ** between 0 and +18446744073709551615 inclusive. + */ + //#if SQLITE_INT64_TYPE + // typedef SQLITE_INT64_TYPE sqlite_int64; + // typedef unsigned SQLITE_INT64_TYPE sqlite_uint64; + //#elif defined(_MSC_VER) || defined(__BORLANDC__) + // typedef __int64 sqlite_int64; + // typedef unsigned __int64 sqlite_uint64; + //#else + // typedef long long int sqlite_int64; + // typedef unsigned long long int sqlite_uint64; + //#endif + //typedef sqlite_int64 sqlite3_int64; + //typedef sqlite_uint64 sqlite3_uint64; + + /* + ** If compiling for a processor that lacks floating point support, + ** substitute integer for floating-point. + */ + //#if SQLITE_OMIT_FLOATING_POINT + //# define double sqlite3_int64 + //#endif + + /* + ** CAPI3REF: Closing A Database Connection + ** + ** ^The sqlite3_close() routine is the destructor for the [sqlite3] object. + ** ^Calls to sqlite3_close() return SQLITE_OK if the [sqlite3] object is + ** successfully destroyed and all associated resources are deallocated. + ** + ** Applications must [sqlite3_finalize | finalize] all [prepared statements] + ** and [sqlite3_blob_close | close] all [BLOB handles] associated with + ** the [sqlite3] object prior to attempting to close the object. ^If + ** sqlite3_close() is called on a [database connection] that still has + ** outstanding [prepared statements] or [BLOB handles], then it returns + ** SQLITE_BUSY. + ** + ** ^If [sqlite3_close()] is invoked while a transaction is open, + ** the transaction is automatically rolled back. + ** + ** The C parameter to [sqlite3_close(C)] must be either a NULL + ** pointer or an [sqlite3] object pointer obtained + ** from [sqlite3_open()], [sqlite3_open16()], or + ** [sqlite3_open_v2()], and not previously closed. + ** ^Calling sqlite3_close() with a NULL pointer argument is a + ** harmless no-op. + */ + //SQLITE_API int sqlite3_close(sqlite3 ); + + /* + ** The type for a callback function. + ** This is legacy and deprecated. It is included for historical + ** compatibility and is not documented. + */ + //typedef int (*sqlite3_callback)(void*,int,char**, char*); + + /* + ** CAPI3REF: One-Step Query Execution Interface + ** + ** The sqlite3_exec() interface is a convenience wrapper around + ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()], + ** that allows an application to run multiple statements of SQL + ** without having to use a lot of C code. + ** + ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded, + ** semicolon-separate SQL statements passed into its 2nd argument, + ** in the context of the [database connection] passed in as its 1st + ** argument. ^If the callback function of the 3rd argument to + ** sqlite3_exec() is not NULL, then it is invoked for each result row + ** coming out of the evaluated SQL statements. ^The 4th argument to + ** sqlite3_exec() is relayed through to the 1st argument of each + ** callback invocation. ^If the callback pointer to sqlite3_exec() + ** is NULL, then no callback is ever invoked and result rows are + ** ignored. + ** + ** ^If an error occurs while evaluating the SQL statements passed into + ** sqlite3_exec(), then execution of the current statement stops and + ** subsequent statements are skipped. ^If the 5th parameter to sqlite3_exec() + ** is not NULL then any error message is written into memory obtained + ** from [sqlite3_malloc()] and passed back through the 5th parameter. + ** To avoid memory leaks, the application should invoke [sqlite3_free()] + ** on error message strings returned through the 5th parameter of + ** of sqlite3_exec() after the error message string is no longer needed. + ** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors + ** occur, then sqlite3_exec() sets the pointer in its 5th parameter to + ** NULL before returning. + ** + ** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec() + ** routine returns SQLITE_ABORT without invoking the callback again and + ** without running any subsequent SQL statements. + ** + ** ^The 2nd argument to the sqlite3_exec() callback function is the + ** number of columns in the result. ^The 3rd argument to the sqlite3_exec() + ** callback is an array of pointers to strings obtained as if from + ** [sqlite3_column_text()], one for each column. ^If an element of a + ** result row is NULL then the corresponding string pointer for the + ** sqlite3_exec() callback is a NULL pointer. ^The 4th argument to the + ** sqlite3_exec() callback is an array of pointers to strings where each + ** entry represents the name of corresponding result column as obtained + ** from [sqlite3_column_name()]. + ** + ** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer + ** to an empty string, or a pointer that contains only whitespace and/or + ** SQL comments, then no SQL statements are evaluated and the database + ** is not changed. + ** + ** Restrictions: + ** + **
    + **
  • The application must insure that the 1st parameter to sqlite3_exec() + ** is a valid and open [database connection]. + **
  • The application must not close [database connection] specified by + ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running. + **
  • The application must not modify the SQL statement text passed into + ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running. + **
+ */ + //SQLITE_API int sqlite3_exec( + // sqlite3*, /* An open database */ + // string sql, /* SQL to be evaluated */ + // int (*callback)(void*,int,char**,char*), /* Callback function */ + // void *, /* 1st argument to callback */ + // char **errmsg /* Error msg written here */ + //); + + /* + ** CAPI3REF: Result Codes + ** KEYWORDS: SQLITE_OK {error code} {error codes} + ** KEYWORDS: {result code} {result codes} + ** + ** Many SQLite functions return an integer result code from the set shown + ** here in order to indicates success or failure. + ** + ** New error codes may be added in future versions of SQLite. + ** + ** See also: [SQLITE_IOERR_READ | extended result codes], + ** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes]. + */ + //#define SQLITE_OK 0 /* Successful result */ + ///* beginning-of-error-codes */ + //#define SQLITE_ERROR 1 /* SQL error or missing database */ + //#define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */ + //#define SQLITE_PERM 3 /* Access permission denied */ + //#define SQLITE_ABORT 4 /* Callback routine requested an abort */ + //#define SQLITE_BUSY 5 /* The database file is locked */ + //#define SQLITE_LOCKED 6 /* A table in the database is locked */ + //#define SQLITE_NOMEM 7 /* A malloc() failed */ + //#define SQLITE_READONLY 8 /* Attempt to write a readonly database */ + //#define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/ + //#define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */ + //#define SQLITE_CORRUPT 11 /* The database disk image is malformed */ + //#define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */ + //#define SQLITE_FULL 13 /* Insertion failed because database is full */ + //#define SQLITE_CANTOPEN 14 /* Unable to open the database file */ + //#define SQLITE_PROTOCOL 15 /* Database lock protocol error */ + //#define SQLITE_EMPTY 16 /* Database is empty */ + //#define SQLITE_SCHEMA 17 /* The database schema changed */ + //#define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */ + //#define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */ + //#define SQLITE_MISMATCH 20 /* Data type mismatch */ + //#define SQLITE_MISUSE 21 /* Library used incorrectly */ + //#define SQLITE_NOLFS 22 /* Uses OS features not supported on host */ + //#define SQLITE_AUTH 23 /* Authorization denied */ + //#define SQLITE_FORMAT 24 /* Auxiliary database format error */ + //#define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */ + //#define SQLITE_NOTADB 26 /* File opened that is not a database file */ + //#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */ + //#define SQLITE_DONE 101 /* sqlite3_step() has finished executing */ + /* end-of-error-codes */ + public const int SQLITE_OK = 0; + public const int SQLITE_ERROR = 1; + public const int SQLITE_INTERNAL = 2; + public const int SQLITE_PERM = 3; + public const int SQLITE_ABORT = 4; + public const int SQLITE_BUSY = 5; + public const int SQLITE_LOCKED = 6; + public const int SQLITE_NOMEM = 7; + public const int SQLITE_READONLY = 8; + public const int SQLITE_INTERRUPT = 9; + public const int SQLITE_IOERR = 10; + public const int SQLITE_CORRUPT = 11; + public const int SQLITE_NOTFOUND = 12; + public const int SQLITE_FULL = 13; + public const int SQLITE_CANTOPEN = 14; + public const int SQLITE_PROTOCOL = 15; + public const int SQLITE_EMPTY = 16; + public const int SQLITE_SCHEMA = 17; + public const int SQLITE_TOOBIG = 18; + public const int SQLITE_CONSTRAINT = 19; + public const int SQLITE_MISMATCH = 20; + public const int SQLITE_MISUSE = 21; + public const int SQLITE_NOLFS = 22; + public const int SQLITE_AUTH = 23; + public const int SQLITE_FORMAT = 24; + public const int SQLITE_RANGE = 25; + public const int SQLITE_NOTADB = 26; + public const int SQLITE_ROW = 100; + public const int SQLITE_DONE = 101; + + /* + ** CAPI3REF: Extended Result Codes + ** KEYWORDS: {extended error code} {extended error codes} + ** KEYWORDS: {extended result code} {extended result codes} + ** + ** In its default configuration, SQLite API routines return one of 26 integer + ** [SQLITE_OK | result codes]. However, experience has shown that many of + ** these result codes are too coarse-grained. They do not provide as + ** much information about problems as programmers might like. In an effort to + ** address this, newer versions of SQLite (version 3.3.8 and later) include + ** support for additional result codes that provide more detailed information + ** about errors. The extended result codes are enabled or disabled + ** on a per database connection basis using the + ** [sqlite3_extended_result_codes()] API. + ** + ** Some of the available extended result codes are listed here. + ** One may expect the number of extended result codes will be expand + ** over time. Software that uses extended result codes should expect + ** to see new result codes in future releases of SQLite. + ** + ** The SQLITE_OK result code will never be extended. It will always + ** be exactly zero. + */ + //#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8)) + //#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8)) + //#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8)) + //#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8)) + //#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8)) + //#define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8)) + //#define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8)) + //#define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8)) + //#define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8)) + //#define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8)) + //#define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8)) + //#define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8)) + //#define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8)) + //#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8)) + //#define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8)) + //#define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8)) + //#define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8)) + //#define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8)) + //#define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8)) + //#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8)) + //#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8)) + //#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8)) + //#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) + //#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) + //#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) + //#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8)) + //#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8)) + //#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8)) + const int SQLITE_IOERR_READ = ( SQLITE_IOERR | ( 1 << 8 ) ); + const int SQLITE_IOERR_SHORT_READ = ( SQLITE_IOERR | ( 2 << 8 ) ); + const int SQLITE_IOERR_WRITE = ( SQLITE_IOERR | ( 3 << 8 ) ); + const int SQLITE_IOERR_FSYNC = ( SQLITE_IOERR | ( 4 << 8 ) ); + const int SQLITE_IOERR_DIR_FSYNC = ( SQLITE_IOERR | ( 5 << 8 ) ); + const int SQLITE_IOERR_TRUNCATE = ( SQLITE_IOERR | ( 6 << 8 ) ); + const int SQLITE_IOERR_FSTAT = ( SQLITE_IOERR | ( 7 << 8 ) ); + const int SQLITE_IOERR_UNLOCK = ( SQLITE_IOERR | ( 8 << 8 ) ); + const int SQLITE_IOERR_RDLOCK = ( SQLITE_IOERR | ( 9 << 8 ) ); + const int SQLITE_IOERR_DELETE = ( SQLITE_IOERR | ( 10 << 8 ) ); + const int SQLITE_IOERR_BLOCKED = ( SQLITE_IOERR | ( 11 << 8 ) ); + const int SQLITE_IOERR_NOMEM = ( SQLITE_IOERR | ( 12 << 8 ) ); + const int SQLITE_IOERR_ACCESS = ( SQLITE_IOERR | ( 13 << 8 ) ); + const int SQLITE_IOERR_CHECKRESERVEDLOCK = ( SQLITE_IOERR | ( 14 << 8 ) ); + const int SQLITE_IOERR_LOCK = ( SQLITE_IOERR | ( 15 << 8 ) ); + const int SQLITE_IOERR_CLOSE = ( SQLITE_IOERR | ( 16 << 8 ) ); + const int SQLITE_IOERR_DIR_CLOSE = ( SQLITE_IOERR | ( 17 << 8 ) ); + const int SQLITE_IOERR_SHMOPEN = ( SQLITE_IOERR | ( 18 << 8 ) ); + const int SQLITE_IOERR_SHMSIZE = ( SQLITE_IOERR | ( 19 << 8 ) ); + const int SQLITE_IOERR_SHMLOCK = ( SQLITE_IOERR | ( 20 << 8 ) ); + const int SQLITE_IOERR_SHMMAP = ( SQLITE_IOERR | ( 21 << 8 ) ); + const int SQLITE_IOERR_SEEK = ( SQLITE_IOERR | ( 22 << 8 ) ); + const int SQLITE_LOCKED_SHAREDCACHE = ( SQLITE_LOCKED | ( 1 << 8 ) ); + const int SQLITE_BUSY_RECOVERY = ( SQLITE_BUSY | ( 1 << 8 ) ); + const int SQLITE_CANTOPEN_NOTEMPDIR = ( SQLITE_CANTOPEN | ( 1 << 8 ) ); + const int SQLITE_CORRUPT_VTAB = ( SQLITE_CORRUPT | ( 1 << 8 ) ); + const int SQLITE_READONLY_RECOVERY = ( SQLITE_READONLY | ( 1 << 8 ) ); + const int SQLITE_READONLY_CANTLOCK = ( SQLITE_READONLY | ( 2 << 8 ) ); + + /* + ** CAPI3REF: Flags For File Open Operations + ** + ** These bit values are intended for use in the + ** 3rd parameter to the [sqlite3_open_v2()] interface and + ** in the 4th parameter to the [sqlite3_vfs.xOpen] method. + */ + //#define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */ + //#define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */ + //#define SQLITE_OPEN_CREATE 0x00000004 /* Ok for sqlite3_open_v2() */ + //#define SQLITE_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */ + //#define SQLITE_OPEN_EXCLUSIVE 0x00000010 /* VFS only */ + //#define SQLITE_OPEN_AUTOPROXY 0x00000020 /* VFS only */ + //#define SQLITE_OPEN_URI 0x00000040 /* Ok for sqlite3_open_v2() */ + //#define SQLITE_OPEN_MAIN_DB 0x00000100 /* VFS only */ + //#define SQLITE_OPEN_TEMP_DB 0x00000200 /* VFS only */ + //#define SQLITE_OPEN_TRANSIENT_DB 0x00000400 /* VFS only */ + //#define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 /* VFS only */ + //#define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 /* VFS only */ + //#define SQLITE_OPEN_SUBJOURNAL 0x00002000 /* VFS only */ + //#define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */ + //#define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */ + //#define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */ + //#define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ + //#define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ + //#define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ + + /* Reserved: 0x00F00000 */ + + public const int SQLITE_OPEN_READONLY = 0x00000001; + public const int SQLITE_OPEN_READWRITE = 0x00000002; + public const int SQLITE_OPEN_CREATE = 0x00000004; + public const int SQLITE_OPEN_DELETEONCLOSE = 0x00000008; + public const int SQLITE_OPEN_EXCLUSIVE = 0x00000010; + public const int SQLITE_OPEN_AUTOPROXY = 0x00000020; + public const int SQLITE_OPEN_URI = 0x00000040; + public const int SQLITE_OPEN_MAIN_DB = 0x00000100; + public const int SQLITE_OPEN_TEMP_DB = 0x00000200; + public const int SQLITE_OPEN_TRANSIENT_DB = 0x00000400; + public const int SQLITE_OPEN_MAIN_JOURNAL = 0x00000800; + public const int SQLITE_OPEN_TEMP_JOURNAL = 0x00001000; + public const int SQLITE_OPEN_SUBJOURNAL = 0x00002000; + public const int SQLITE_OPEN_MASTER_JOURNAL = 0x00004000; + public const int SQLITE_OPEN_NOMUTEX = 0x00008000; + public const int SQLITE_OPEN_FULLMUTEX = 0x00010000; + public const int SQLITE_OPEN_SHAREDCACHE = 0x00020000; + public const int SQLITE_OPEN_PRIVATECACHE = 0x00040000; + public const int SQLITE_OPEN_WAL = 0x00080000; + + /* + ** CAPI3REF: Device Characteristics + ** + ** The xDeviceCharacteristics method of the [sqlite3_io_methods] + ** object returns an integer which is a vector of the these + ** bit values expressing I/O characteristics of the mass storage + ** device that holds the file that the [sqlite3_io_methods] + ** refers to. + ** + ** The SQLITE_IOCAP_ATOMIC property means that all writes of + ** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values + ** mean that writes of blocks that are nnn bytes in size and + ** are aligned to an address which is an integer multiple of + ** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means + ** that when data is appended to a file, the data is appended + ** first then the size of the file is extended, never the other + ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that + ** information is written to disk in the same order as calls + ** to xWrite(). + */ + //#define SQLITE_IOCAP_ATOMIC 0x00000001 + //#define SQLITE_IOCAP_ATOMIC512 0x00000002 + //#define SQLITE_IOCAP_ATOMIC1K 0x00000004 + //#define SQLITE_IOCAP_ATOMIC2K 0x00000008 + //#define SQLITE_IOCAP_ATOMIC4K 0x00000010 + //#define SQLITE_IOCAP_ATOMIC8K 0x00000020 + //#define SQLITE_IOCAP_ATOMIC16K 0x00000040 + //#define SQLITE_IOCAP_ATOMIC32K 0x00000080 + //#define SQLITE_IOCAP_ATOMIC64K 0x00000100 + //#define SQLITE_IOCAP_SAFE_APPEND 0x00000200 + //#define SQLITE_IOCAP_SEQUENTIAL 0x00000400 + //#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800 + const int SQLITE_IOCAP_ATOMIC = 0x00000001; + const int SQLITE_IOCAP_ATOMIC512 = 0x00000002; + const int SQLITE_IOCAP_ATOMIC1K = 0x00000004; + const int SQLITE_IOCAP_ATOMIC2K = 0x00000008; + const int SQLITE_IOCAP_ATOMIC4K = 0x00000010; + const int SQLITE_IOCAP_ATOMIC8K = 0x00000020; + const int SQLITE_IOCAP_ATOMIC16K = 0x00000040; + const int SQLITE_IOCAP_ATOMIC32K = 0x00000080; + const int SQLITE_IOCAP_ATOMIC64K = 0x00000100; + const int SQLITE_IOCAP_SAFE_APPEND = 0x00000200; + const int SQLITE_IOCAP_SEQUENTIAL = 0x00000400; + const int SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN = 0x00000800; + + /* + ** CAPI3REF: File Locking Levels + ** + ** SQLite uses one of these integer values as the second + ** argument to calls it makes to the xLock() and xUnlock() methods + ** of an [sqlite3_io_methods] object. + */ + //#define SQLITE_LOCK_NONE 0 + //#define SQLITE_LOCK_SHARED 1 + //#define SQLITE_LOCK_RESERVED 2 + //#define SQLITE_LOCK_PENDING 3 + //#define SQLITE_LOCK_EXCLUSIVE 4 + const int SQLITE_LOCK_NONE = 0; + const int SQLITE_LOCK_SHARED = 1; + const int SQLITE_LOCK_RESERVED = 2; + const int SQLITE_LOCK_PENDING = 3; + const int SQLITE_LOCK_EXCLUSIVE = 4; + + /* + ** CAPI3REF: Synchronization Type Flags + ** + ** When SQLite invokes the xSync() method of an + ** [sqlite3_io_methods] object it uses a combination of + ** these integer values as the second argument. + ** + ** When the SQLITE_SYNC_DATAONLY flag is used, it means that the + ** sync operation only needs to flush data to mass storage. Inode + ** information need not be flushed. If the lower four bits of the flag + ** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics. + ** If the lower four bits equal SQLITE_SYNC_FULL, that means + ** to use Mac OS X style fullsync instead of fsync(). + ** + ** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags + ** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL + ** settings. The [synchronous pragma] determines when calls to the + ** xSync VFS method occur and applies uniformly across all platforms. + ** The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how + ** energetic or rigorous or forceful the sync operations are and + ** only make a difference on Mac OSX for the default SQLite code. + ** (Third-party VFS implementations might also make the distinction + ** between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the + ** operating systems natively supported by SQLite, only Mac OSX + ** cares about the difference.) + */ + //#define SQLITE_SYNC_NORMAL 0x00002 + //#define SQLITE_SYNC_FULL 0x00003 + //#define SQLITE_SYNC_DATAONLY 0x00010 + const int SQLITE_SYNC_NORMAL = 0x00002; + const int SQLITE_SYNC_FULL = 0x00003; + const int SQLITE_SYNC_DATAONLY = 0x00010; + + /* + ** CAPI3REF: OS Interface Open File Handle + ** + ** An [sqlite3_file] object represents an open file in the + ** [sqlite3_vfs | OS interface layer]. Individual OS interface + ** implementations will + ** want to subclass this object by appending additional fields + ** for their own use. The pMethods entry is a pointer to an + ** [sqlite3_io_methods] object that defines methods for performing + ** I/O operations on the open file. + */ + //typedef struct sqlite3_file sqlite3_file; + //struct sqlite3_file { + // const struct sqlite3_io_methods *pMethods; /* Methods for an open file */ + //}; + public partial class sqlite3_file + { + public sqlite3_io_methods pMethods;/* Must be first */ + } /* ** CAPI3REF: OS Interface File Virtual Methods Object @@ -789,6670 +791,6695 @@ public partial class sqlite3_file { ** failure to zero-fill short reads will eventually lead to ** database corruption. */ - //typedef struct sqlite3_io_methods sqlite3_io_methods; - //struct sqlite3_io_methods { - // int iVersion; - // int (*xClose)(sqlite3_file); - // int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst); - // int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst); - // int (*xTruncate)(sqlite3_file*, sqlite3_int64 size); - // int (*xSync)(sqlite3_file*, int flags); - // int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize); - // int (*xLock)(sqlite3_file*, int); - // int (*xUnlock)(sqlite3_file*, int); - // int (*xCheckReservedLock)(sqlite3_file*, int *pResOut); - // int (*xFileControl)(sqlite3_file*, int op, object *pArg); - // int (*xSectorSize)(sqlite3_file); - // int (*xDeviceCharacteristics)(sqlite3_file); - // /* Methods above are valid for version 1 */ - // int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, object volatile*); - // int (*xShmLock)(sqlite3_file*, int offset, int n, int flags); - // void (*xShmBarrier)(sqlite3_file); - // int (*xShmUnmap)(sqlite3_file*, int deleteFlag); - // /* Methods above are valid for version 2 */ - // /* Additional methods may be added in future releases */ - //}; - public class sqlite3_io_methods { - public int iVersion; - public dxClose xClose; - public dxRead xRead; - public dxWrite xWrite; - public dxTruncate xTruncate; - public dxSync xSync; - public dxFileSize xFileSize; - public dxLock xLock; - public dxUnlock xUnlock; - public dxCheckReservedLock xCheckReservedLock; - public dxFileControl xFileControl; - public dxSectorSize xSectorSize; - public dxDeviceCharacteristics xDeviceCharacteristics; - public dxShmMap xShmMap;//int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, object volatile*); - public dxShmLock xShmLock;//int (*xShmLock)(sqlite3_file*, int offset, int n, int flags); - public dxShmBarrier xShmBarrier;//void (*xShmBarrier)(sqlite3_file); - public dxShmUnmap xShmUnmap;//int (*xShmUnmap)(sqlite3_file*, int deleteFlag); - /* Additional methods may be added in future releases */ - - public sqlite3_io_methods(int iVersion, - dxClose xClose, - dxRead xRead, - dxWrite xWrite, - dxTruncate xTruncate, - dxSync xSync, - dxFileSize xFileSize, - dxLock xLock, - dxUnlock xUnlock, - dxCheckReservedLock xCheckReservedLock, - dxFileControl xFileControl, - dxSectorSize xSectorSize, - dxDeviceCharacteristics xDeviceCharacteristics, - dxShmMap xShmMap, - dxShmLock xShmLock, - dxShmBarrier xShmBarrier, - dxShmUnmap xShmUnmap - ) { - this.iVersion = iVersion; - this.xClose = xClose; - this.xRead = xRead; - this.xWrite = xWrite; - this.xTruncate = xTruncate; - this.xSync = xSync; - this.xFileSize = xFileSize; - this.xLock = xLock; - this.xUnlock = xUnlock; - this.xCheckReservedLock = xCheckReservedLock; - this.xFileControl = xFileControl; - this.xSectorSize = xSectorSize; - this.xDeviceCharacteristics = xDeviceCharacteristics; - this.xShmMap = xShmMap; - this.xShmLock = xShmLock; - this.xShmBarrier = xShmBarrier; - this.xShmUnmap = xShmUnmap; - } - } - - /* - ** CAPI3REF: Standard File Control Opcodes - ** - ** These integer constants are opcodes for the xFileControl method - ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()] - ** interface. - ** - ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This - ** opcode causes the xFileControl method to write the current state of - ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED], - ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE]) - ** into an integer that the pArg argument points to. This capability - ** is used during testing and only needs to be supported when SQLITE_TEST - ** is defined. - ** - ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS - ** layer a hint of how large the database file will grow to be during the - ** current transaction. This hint is not guaranteed to be accurate but it - ** is often close. The underlying VFS might choose to preallocate database - ** file space based on this hint in order to help writes to the database - ** file run faster. - ** - ** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS - ** extends and truncates the database file in chunks of a size specified - ** by the user. The fourth argument to [sqlite3_file_control()] should - ** point to an integer (type int) containing the new chunk-size to use - ** for the nominated database. Allocating database file space in large - ** chunks (say 1MB at a time), may reduce file-system fragmentation and - ** improve performance on some systems. - ** - ** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer - ** to the [sqlite3_file] object associated with a particular database - ** connection. See the [sqlite3_file_control()] documentation for - ** additional information. - ** - ** ^(The [SQLITE_FCNTL_SYNC_OMITTED] opcode is generated internally by - ** SQLite and sent to all VFSes in place of a call to the xSync method - ** when the database connection has [PRAGMA synchronous] set to OFF.)^ - ** Some specialized VFSes need this signal in order to operate correctly - ** when [PRAGMA synchronous | PRAGMA synchronous=OFF] is set, but most - ** VFSes do not need this signal and should silently ignore this opcode. - ** Applications should not call [sqlite3_file_control()] with this - ** opcode as doing so may disrupt the operation of the specialized VFSes - ** that do require it. - */ - //#define SQLITE_FCNTL_LOCKSTATE 1 - //#define SQLITE_GET_LOCKPROXYFILE 2 - //#define SQLITE_SET_LOCKPROXYFILE 3 - //#define SQLITE_LAST_ERRNO 4 - //#define SQLITE_FCNTL_SIZE_HINT 5 - //#define SQLITE_FCNTL_CHUNK_SIZE 6 - //#define SQLITE_FCNTL_FILE_POINTER 7 - //#define SQLITE_FCNTL_SYNC_OMITTED 8 - - const int SQLITE_FCNTL_LOCKSTATE = 1; - const int SQLITE_GET_LOCKPROXYFILE = 2; - const int SQLITE_SET_LOCKPROXYFILE = 3; - const int SQLITE_LAST_ERRNO = 4; - const int SQLITE_FCNTL_SIZE_HINT = 5; - const int SQLITE_FCNTL_CHUNK_SIZE = 6; - const int SQLITE_FCNTL_FILE_POINTER = 7; - const int SQLITE_FCNTL_SYNC_OMITTED = 8; - - /* - ** CAPI3REF: Mutex Handle - ** - ** The mutex module within SQLite defines [sqlite3_mutex] to be an - ** abstract type for a mutex object. The SQLite core never looks - ** at the internal representation of an [sqlite3_mutex]. It only - ** deals with pointers to the [sqlite3_mutex] object. - ** - ** Mutexes are created using [sqlite3_mutex_alloc()]. - */ - //typedef struct sqlite3_mutex sqlite3_mutex; - - /* - ** CAPI3REF: OS Interface Object - ** - ** An instance of the sqlite3_vfs object defines the interface between - ** the SQLite core and the underlying operating system. The "vfs" - ** in the name of the object stands for "virtual file system". See - ** the [VFS | VFS documentation] for further information. - ** - ** The value of the iVersion field is initially 1 but may be larger in - ** future versions of SQLite. Additional fields may be appended to this - ** object when the iVersion value is increased. Note that the structure - ** of the sqlite3_vfs object changes in the transaction between - ** SQLite version 3.5.9 and 3.6.0 and yet the iVersion field was not - ** modified. - ** - ** The szOsFile field is the size of the subclassed [sqlite3_file] - ** structure used by this VFS. mxPathname is the maximum length of - ** a pathname in this VFS. - ** - ** Registered sqlite3_vfs objects are kept on a linked list formed by - ** the pNext pointer. The [sqlite3_vfs_register()] - ** and [sqlite3_vfs_unregister()] interfaces manage this list - ** in a thread-safe way. The [sqlite3_vfs_find()] interface - ** searches the list. Neither the application code nor the VFS - ** implementation should use the pNext pointer. - ** - ** The pNext field is the only field in the sqlite3_vfs - ** structure that SQLite will ever modify. SQLite will only access - ** or modify this field while holding a particular static mutex. - ** The application should never modify anything within the sqlite3_vfs - ** object once the object has been registered. - ** - ** The zName field holds the name of the VFS module. The name must - ** be unique across all VFS modules. - ** - ** [[sqlite3_vfs.xOpen] - ** ^SQLite guarantees that the zFilename parameter to xOpen - ** is either a NULL pointer or string obtained - ** from xFullPathname() with an optional suffix added. - ** ^If a suffix is added to the zFilename parameter, it will - ** consist of a single "-" character followed by no more than - ** 10 alphanumeric and/or "-" characters. - ** ^SQLite further guarantees that - ** the string will be valid and unchanged until xClose() is - ** called. Because of the previous sentence, - ** the [sqlite3_file] can safely store a pointer to the - ** filename if it needs to remember the filename for some reason. - ** If the zFilename parameter to xOpen is a NULL pointer then xOpen - ** must invent its own temporary name for the file. ^Whenever the - ** xFilename parameter is NULL it will also be the case that the - ** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE]. - ** - ** The flags argument to xOpen() includes all bits set in - ** the flags argument to [sqlite3_open_v2()]. Or if [sqlite3_open()] - ** or [sqlite3_open16()] is used, then flags includes at least - ** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. - ** If xOpen() opens a file read-only then it sets *pOutFlags to - ** include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be set. - ** - ** ^(SQLite will also add one of the following flags to the xOpen() - ** call, depending on the object being opened: - ** - **
    - **
  • [SQLITE_OPEN_MAIN_DB] - **
  • [SQLITE_OPEN_MAIN_JOURNAL] - **
  • [SQLITE_OPEN_TEMP_DB] - **
  • [SQLITE_OPEN_TEMP_JOURNAL] - **
  • [SQLITE_OPEN_TRANSIENT_DB] - **
  • [SQLITE_OPEN_SUBJOURNAL] - **
  • [SQLITE_OPEN_MASTER_JOURNAL] - **
  • [SQLITE_OPEN_WAL] - **
)^ - ** - ** The file I/O implementation can use the object type flags to - ** change the way it deals with files. For example, an application - ** that does not care about crash recovery or rollback might make - ** the open of a journal file a no-op. Writes to this journal would - ** also be no-ops, and any attempt to read the journal would return - ** SQLITE_IOERR. Or the implementation might recognize that a database - ** file will be doing page-aligned sector reads and writes in a random - ** order and set up its I/O subsystem accordingly. - ** - ** SQLite might also add one of the following flags to the xOpen method: - ** - **
    - **
  • [SQLITE_OPEN_DELETEONCLOSE] - **
  • [SQLITE_OPEN_EXCLUSIVE] - **
- ** - ** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be - ** deleted when it is closed. ^The [SQLITE_OPEN_DELETEONCLOSE] - ** will be set for TEMP databases and their journals, transient - ** databases, and subjournals. - ** - ** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction - ** with the [SQLITE_OPEN_CREATE] flag, which are both directly - ** analogous to the O_EXCL and O_CREAT flags of the POSIX open() - ** API. The SQLITE_OPEN_EXCLUSIVE flag, when paired with the - ** SQLITE_OPEN_CREATE, is used to indicate that file should always - ** be created, and that it is an error if it already exists. - ** It is not used to indicate the file should be opened - ** for exclusive access. - ** - ** ^At least szOsFile bytes of memory are allocated by SQLite - ** to hold the [sqlite3_file] structure passed as the third - ** argument to xOpen. The xOpen method does not have to - ** allocate the structure; it should just fill it in. Note that - ** the xOpen method must set the sqlite3_file.pMethods to either - ** a valid [sqlite3_io_methods] object or to NULL. xOpen must do - ** this even if the open fails. SQLite expects that the sqlite3_file.pMethods - ** element will be valid after xOpen returns regardless of the success - ** or failure of the xOpen call. - ** - ** [[sqlite3_vfs.xAccess] - ** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS] - ** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to - ** test whether a file is readable and writable, or [SQLITE_ACCESS_READ] - ** to test whether a file is at least readable. The file can be a - ** directory. - ** - ** ^SQLite will always allocate at least mxPathname+1 bytes for the - ** output buffer xFullPathname. The exact size of the output buffer - ** is also passed as a parameter to both methods. If the output buffer - ** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is - ** handled as a fatal error by SQLite, vfs implementations should endeavor - ** to prevent this by setting mxPathname to a sufficiently large value. - ** - ** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64() - ** interfaces are not strictly a part of the filesystem, but they are - ** included in the VFS structure for completeness. - ** The xRandomness() function attempts to return nBytes bytes - ** of good-quality randomness into zOut. The return value is - ** the actual number of bytes of randomness obtained. - ** The xSleep() method causes the calling thread to sleep for at - ** least the number of microseconds given. ^The xCurrentTime() - ** method returns a Julian Day Number for the current date and time as - ** a floating point value. - ** ^The xCurrentTimeInt64() method returns, as an integer, the Julian - ** Day Number multiplied by 86400000 (the number of milliseconds in - ** a 24-hour day). - ** ^SQLite will use the xCurrentTimeInt64() method to get the current - ** date and time if that method is available (if iVersion is 2 or - ** greater and the function pointer is not NULL) and will fall back - ** to xCurrentTime() if xCurrentTimeInt64() is unavailable. - ** - ** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces - ** are not used by the SQLite core. These optional interfaces are provided - ** by some VFSes to facilitate testing of the VFS code. By overriding - ** system calls with functions under its control, a test program can - ** simulate faults and error conditions that would otherwise be difficult - ** or impossible to induce. The set of system calls that can be overridden - ** varies from one VFS to another, and from one version of the same VFS to the - ** next. Applications that use these interfaces must be prepared for any - ** or all of these interfaces to be NULL or for their behavior to change - ** from one release to the next. Applications must not attempt to access - ** any of these methods if the iVersion of the VFS is less than 3. - */ - //typedef struct sqlite3_vfs sqlite3_vfs; - //typedef void (*sqlite3_syscall_ptr)(void); - //struct sqlite3_vfs { - // int iVersion; /* Structure version number (currently 3) */ - // int szOsFile; /* Size of subclassed sqlite3_file */ - // int mxPathname; /* Maximum file pathname length */ - // sqlite3_vfs *pNext; /* Next registered VFS */ - // string zName; /* Name of this virtual file system */ - // void *pAppData; /* Pointer to application-specific data */ - // int (*xOpen)(sqlite3_vfs*, string zName, sqlite3_file*, - // int flags, int *pOutFlags); - // int (*xDelete)(sqlite3_vfs*, string zName, int syncDir); - // int (*xAccess)(sqlite3_vfs*, string zName, int flags, int *pResOut); - // int (*xFullPathname)(sqlite3_vfs*, string zName, int nOut, string zOut); - // void *(*xDlOpen)(sqlite3_vfs*, string zFilename); - // void (*xDlError)(sqlite3_vfs*, int nByte, string zErrMsg); - // void (*(*xDlSym)(sqlite3_vfs*,void*, string zSymbol))(void); - // void (*xDlClose)(sqlite3_vfs*, void); - // int (*xRandomness)(sqlite3_vfs*, int nByte, string zOut); - // int (*xSleep)(sqlite3_vfs*, int microseconds); - // int (*xCurrentTime)(sqlite3_vfs*, double); - // int (*xGetLastError)(sqlite3_vfs*, int, char ); - // /* - // ** The methods above are in version 1 of the sqlite_vfs object - // ** definition. Those that follow are added in version 2 or later - // */ - // int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64); - // /* - // ** The methods above are in versions 1 and 2 of the sqlite_vfs object. - // ** New fields may be appended in figure versions. The iVersion - // ** value will increment whenever this happens. - // */ - //}; - public class sqlite3_vfs { - public int iVersion; /* Structure version number (currently 3) */ - public int szOsFile; /* Size of subclassed sqlite3_file */ - public int mxPathname; /* Maximum file pathname length */ - public sqlite3_vfs pNext; /* Next registered VFS */ - public string zName; /* Name of this virtual file system */ - public object pAppData; /* Pointer to application-specific data */ - public dxOpen xOpen; - public dxDelete xDelete; - public dxAccess xAccess; - public dxFullPathname xFullPathname; - public dxDlOpen xDlOpen; - public dxDlError xDlError; - public dxDlSym xDlSym; - public dxDlClose xDlClose; - public dxRandomness xRandomness; - public dxSleep xSleep; - public dxCurrentTime xCurrentTime; - public dxGetLastError xGetLastError; - /* - ** The methods above are in version 1 of the sqlite_vfs object - ** definition. Those that follow are added in version 2 or later - */ - public dxCurrentTimeInt64 xCurrentTimeInt64; - /* - ** The methods above are in versions 1 and 2 of the sqlite_vfs object. - ** Those below are for version 3 and greater. - */ - //int (*xSetSystemCall)(sqlite3_vfs*, string zName, sqlite3_syscall_ptr); - public dxSetSystemCall xSetSystemCall; - //sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, string zName); - public dxGetSystemCall xGetSystemCall; - //string (*xNextSystemCall)(sqlite3_vfs*, string zName); - public dxNextSystemCall xNextSystemCall; - /* - ** The methods above are in versions 1 through 3 of the sqlite_vfs object. - ** New fields may be appended in figure versions. The iVersion - ** value will increment whenever this happens. - */ - /* New fields may be appended in figure versions. The iVersion - ** value will increment whenever this happens. */ - - public sqlite3_vfs() { - } - - public sqlite3_vfs(int iVersion, - int szOsFile, - int mxPathname, - sqlite3_vfs pNext, - string zName, - object pAppData, - dxOpen xOpen, - dxDelete xDelete, - dxAccess xAccess, - dxFullPathname xFullPathname, - dxDlOpen xDlOpen, - dxDlError xDlError, - dxDlSym xDlSym, - dxDlClose xDlClose, - dxRandomness xRandomness, - dxSleep xSleep, - dxCurrentTime xCurrentTime, - dxGetLastError xGetLastError, - dxCurrentTimeInt64 xCurrentTimeInt64, - dxSetSystemCall xSetSystemCall, - dxGetSystemCall xGetSystemCall, - dxNextSystemCall xNextSystemCall) { - this.iVersion = iVersion; - this.szOsFile = szOsFile; - this.mxPathname = mxPathname; - this.pNext = pNext; - this.zName = zName; - this.pAppData = pAppData; - this.xOpen = xOpen; - this.xDelete = xDelete; - this.xAccess = xAccess; - this.xFullPathname = xFullPathname; - this.xDlOpen = xDlOpen; - this.xDlError = xDlError; - this.xDlSym = xDlSym; - this.xDlClose = xDlClose; - this.xRandomness = xRandomness; - this.xSleep = xSleep; - this.xCurrentTime = xCurrentTime; - this.xGetLastError = xGetLastError; - this.xCurrentTimeInt64 = xCurrentTimeInt64; - } - public void CopyTo(sqlite3_vfs ct) { - ct.iVersion = this.iVersion; - ct.szOsFile = this.szOsFile; - ct.mxPathname = this.mxPathname; - ct.pNext = this.pNext; - ct.zName = this.zName; - ct.pAppData = this.pAppData; - ct.xOpen = this.xOpen; - ct.xDelete = this.xDelete; - ct.xAccess = this.xAccess; - ct.xFullPathname = this.xFullPathname; - ct.xDlOpen = this.xDlOpen; - ct.xDlError = this.xDlError; - ct.xDlSym = this.xDlSym; - ct.xDlClose = this.xDlClose; - ct.xRandomness = this.xRandomness; - ct.xSleep = this.xSleep; - ct.xCurrentTime = this.xCurrentTime; - ct.xGetLastError = this.xGetLastError; - ct.xCurrentTimeInt64 = this.xCurrentTimeInt64; - } - } - - - /* - ** CAPI3REF: Flags for the xAccess VFS method - ** - ** These integer constants can be used as the third parameter to - ** the xAccess method of an [sqlite3_vfs] object. They determine - ** what kind of permissions the xAccess method is looking for. - ** With SQLITE_ACCESS_EXISTS, the xAccess method - ** simply checks whether the file exists. - ** With SQLITE_ACCESS_READWRITE, the xAccess method - ** checks whether the named directory is both readable and writable - ** (in other words, if files can be added, removed, and renamed within - ** the directory). - ** The SQLITE_ACCESS_READWRITE constant is currently used only by the - ** [temp_store_directory pragma], though this could change in a future - ** release of SQLite. - ** With SQLITE_ACCESS_READ, the xAccess method - ** checks whether the file is readable. The SQLITE_ACCESS_READ constant is - ** currently unused, though it might be used in a future release of - ** SQLite. - */ - //#define SQLITE_ACCESS_EXISTS 0 - //#define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */ - //#define SQLITE_ACCESS_READ 2 /* Unused */ - const int SQLITE_ACCESS_EXISTS = 0; - const int SQLITE_ACCESS_READWRITE = 1; - const int SQLITE_ACCESS_READ = 2; - - - /* - ** CAPI3REF: Flags for the xShmLock VFS method - ** - ** These integer constants define the various locking operations - ** allowed by the xShmLock method of [sqlite3_io_methods]. The - ** following are the only legal combinations of flags to the - ** xShmLock method: - ** - **
    - **
  • SQLITE_SHM_LOCK | SQLITE_SHM_SHARED - **
  • SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE - **
  • SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED - **
  • SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE - **
- ** - ** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as - ** was given no the corresponding lock. - ** - ** The xShmLock method can transition between unlocked and SHARED or - ** between unlocked and EXCLUSIVE. It cannot transition between SHARED - ** and EXCLUSIVE. - */ - //#define SQLITE_SHM_UNLOCK 1 - //#define SQLITE_SHM_LOCK 2 - //#define SQLITE_SHM_SHARED 4 - //#define SQLITE_SHM_EXCLUSIVE 8 - const int SQLITE_SHM_UNLOCK = 1; - const int SQLITE_SHM_LOCK = 2; - const int SQLITE_SHM_SHARED = 4; - const int SQLITE_SHM_EXCLUSIVE = 8; + //typedef struct sqlite3_io_methods sqlite3_io_methods; + //struct sqlite3_io_methods { + // int iVersion; + // int (*xClose)(sqlite3_file); + // int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst); + // int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst); + // int (*xTruncate)(sqlite3_file*, sqlite3_int64 size); + // int (*xSync)(sqlite3_file*, int flags); + // int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize); + // int (*xLock)(sqlite3_file*, int); + // int (*xUnlock)(sqlite3_file*, int); + // int (*xCheckReservedLock)(sqlite3_file*, int *pResOut); + // int (*xFileControl)(sqlite3_file*, int op, object *pArg); + // int (*xSectorSize)(sqlite3_file); + // int (*xDeviceCharacteristics)(sqlite3_file); + // /* Methods above are valid for version 1 */ + // int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, object volatile*); + // int (*xShmLock)(sqlite3_file*, int offset, int n, int flags); + // void (*xShmBarrier)(sqlite3_file); + // int (*xShmUnmap)(sqlite3_file*, int deleteFlag); + // /* Methods above are valid for version 2 */ + // /* Additional methods may be added in future releases */ + //}; + public class sqlite3_io_methods + { + public int iVersion; + public dxClose xClose; + public dxRead xRead; + public dxWrite xWrite; + public dxTruncate xTruncate; + public dxSync xSync; + public dxFileSize xFileSize; + public dxLock xLock; + public dxUnlock xUnlock; + public dxCheckReservedLock xCheckReservedLock; + public dxFileControl xFileControl; + public dxSectorSize xSectorSize; + public dxDeviceCharacteristics xDeviceCharacteristics; + public dxShmMap xShmMap;//int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, object volatile*); + public dxShmLock xShmLock;//int (*xShmLock)(sqlite3_file*, int offset, int n, int flags); + public dxShmBarrier xShmBarrier;//void (*xShmBarrier)(sqlite3_file); + public dxShmUnmap xShmUnmap;//int (*xShmUnmap)(sqlite3_file*, int deleteFlag); + /* Additional methods may be added in future releases */ + + public sqlite3_io_methods( int iVersion, + dxClose xClose, + dxRead xRead, + dxWrite xWrite, + dxTruncate xTruncate, + dxSync xSync, + dxFileSize xFileSize, + dxLock xLock, + dxUnlock xUnlock, + dxCheckReservedLock xCheckReservedLock, + dxFileControl xFileControl, + dxSectorSize xSectorSize, + dxDeviceCharacteristics xDeviceCharacteristics, + dxShmMap xShmMap, + dxShmLock xShmLock, + dxShmBarrier xShmBarrier, + dxShmUnmap xShmUnmap + ) + { + this.iVersion = iVersion; + this.xClose = xClose; + this.xRead = xRead; + this.xWrite = xWrite; + this.xTruncate = xTruncate; + this.xSync = xSync; + this.xFileSize = xFileSize; + this.xLock = xLock; + this.xUnlock = xUnlock; + this.xCheckReservedLock = xCheckReservedLock; + this.xFileControl = xFileControl; + this.xSectorSize = xSectorSize; + this.xDeviceCharacteristics = xDeviceCharacteristics; + this.xShmMap = xShmMap; + this.xShmLock = xShmLock; + this.xShmBarrier = xShmBarrier; + this.xShmUnmap = xShmUnmap; + } + } + /* + ** CAPI3REF: Standard File Control Opcodes + ** + ** These integer constants are opcodes for the xFileControl method + ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()] + ** interface. + ** + ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This + ** opcode causes the xFileControl method to write the current state of + ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED], + ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE]) + ** into an integer that the pArg argument points to. This capability + ** is used during testing and only needs to be supported when SQLITE_TEST + ** is defined. + ** + ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS + ** layer a hint of how large the database file will grow to be during the + ** current transaction. This hint is not guaranteed to be accurate but it + ** is often close. The underlying VFS might choose to preallocate database + ** file space based on this hint in order to help writes to the database + ** file run faster. + ** + ** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS + ** extends and truncates the database file in chunks of a size specified + ** by the user. The fourth argument to [sqlite3_file_control()] should + ** point to an integer (type int) containing the new chunk-size to use + ** for the nominated database. Allocating database file space in large + ** chunks (say 1MB at a time), may reduce file-system fragmentation and + ** improve performance on some systems. + ** + ** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer + ** to the [sqlite3_file] object associated with a particular database + ** connection. See the [sqlite3_file_control()] documentation for + ** additional information. + ** + ** ^(The [SQLITE_FCNTL_SYNC_OMITTED] opcode is generated internally by + ** SQLite and sent to all VFSes in place of a call to the xSync method + ** when the database connection has [PRAGMA synchronous] set to OFF.)^ + ** Some specialized VFSes need this signal in order to operate correctly + ** when [PRAGMA synchronous | PRAGMA synchronous=OFF] is set, but most + ** VFSes do not need this signal and should silently ignore this opcode. + ** Applications should not call [sqlite3_file_control()] with this + ** opcode as doing so may disrupt the operation of the specialized VFSes + ** that do require it. + */ + //#define SQLITE_FCNTL_LOCKSTATE 1 + //#define SQLITE_GET_LOCKPROXYFILE 2 + //#define SQLITE_SET_LOCKPROXYFILE 3 + //#define SQLITE_LAST_ERRNO 4 + //#define SQLITE_FCNTL_SIZE_HINT 5 + //#define SQLITE_FCNTL_CHUNK_SIZE 6 + //#define SQLITE_FCNTL_FILE_POINTER 7 + //#define SQLITE_FCNTL_SYNC_OMITTED 8 + + const int SQLITE_FCNTL_LOCKSTATE = 1; + const int SQLITE_GET_LOCKPROXYFILE = 2; + const int SQLITE_SET_LOCKPROXYFILE = 3; + const int SQLITE_LAST_ERRNO = 4; + const int SQLITE_FCNTL_SIZE_HINT = 5; + const int SQLITE_FCNTL_CHUNK_SIZE = 6; + const int SQLITE_FCNTL_FILE_POINTER = 7; + const int SQLITE_FCNTL_SYNC_OMITTED = 8; + + /* + ** CAPI3REF: Mutex Handle + ** + ** The mutex module within SQLite defines [sqlite3_mutex] to be an + ** abstract type for a mutex object. The SQLite core never looks + ** at the internal representation of an [sqlite3_mutex]. It only + ** deals with pointers to the [sqlite3_mutex] object. + ** + ** Mutexes are created using [sqlite3_mutex_alloc()]. + */ + //typedef struct sqlite3_mutex sqlite3_mutex; + + /* + ** CAPI3REF: OS Interface Object + ** + ** An instance of the sqlite3_vfs object defines the interface between + ** the SQLite core and the underlying operating system. The "vfs" + ** in the name of the object stands for "virtual file system". See + ** the [VFS | VFS documentation] for further information. + ** + ** The value of the iVersion field is initially 1 but may be larger in + ** future versions of SQLite. Additional fields may be appended to this + ** object when the iVersion value is increased. Note that the structure + ** of the sqlite3_vfs object changes in the transaction between + ** SQLite version 3.5.9 and 3.6.0 and yet the iVersion field was not + ** modified. + ** + ** The szOsFile field is the size of the subclassed [sqlite3_file] + ** structure used by this VFS. mxPathname is the maximum length of + ** a pathname in this VFS. + ** + ** Registered sqlite3_vfs objects are kept on a linked list formed by + ** the pNext pointer. The [sqlite3_vfs_register()] + ** and [sqlite3_vfs_unregister()] interfaces manage this list + ** in a thread-safe way. The [sqlite3_vfs_find()] interface + ** searches the list. Neither the application code nor the VFS + ** implementation should use the pNext pointer. + ** + ** The pNext field is the only field in the sqlite3_vfs + ** structure that SQLite will ever modify. SQLite will only access + ** or modify this field while holding a particular static mutex. + ** The application should never modify anything within the sqlite3_vfs + ** object once the object has been registered. + ** + ** The zName field holds the name of the VFS module. The name must + ** be unique across all VFS modules. + ** + ** [[sqlite3_vfs.xOpen] + ** ^SQLite guarantees that the zFilename parameter to xOpen + ** is either a NULL pointer or string obtained + ** from xFullPathname() with an optional suffix added. + ** ^If a suffix is added to the zFilename parameter, it will + ** consist of a single "-" character followed by no more than + ** 10 alphanumeric and/or "-" characters. + ** ^SQLite further guarantees that + ** the string will be valid and unchanged until xClose() is + ** called. Because of the previous sentence, + ** the [sqlite3_file] can safely store a pointer to the + ** filename if it needs to remember the filename for some reason. + ** If the zFilename parameter to xOpen is a NULL pointer then xOpen + ** must invent its own temporary name for the file. ^Whenever the + ** xFilename parameter is NULL it will also be the case that the + ** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE]. + ** + ** The flags argument to xOpen() includes all bits set in + ** the flags argument to [sqlite3_open_v2()]. Or if [sqlite3_open()] + ** or [sqlite3_open16()] is used, then flags includes at least + ** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. + ** If xOpen() opens a file read-only then it sets *pOutFlags to + ** include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be set. + ** + ** ^(SQLite will also add one of the following flags to the xOpen() + ** call, depending on the object being opened: + ** + **
    + **
  • [SQLITE_OPEN_MAIN_DB] + **
  • [SQLITE_OPEN_MAIN_JOURNAL] + **
  • [SQLITE_OPEN_TEMP_DB] + **
  • [SQLITE_OPEN_TEMP_JOURNAL] + **
  • [SQLITE_OPEN_TRANSIENT_DB] + **
  • [SQLITE_OPEN_SUBJOURNAL] + **
  • [SQLITE_OPEN_MASTER_JOURNAL] + **
  • [SQLITE_OPEN_WAL] + **
)^ + ** + ** The file I/O implementation can use the object type flags to + ** change the way it deals with files. For example, an application + ** that does not care about crash recovery or rollback might make + ** the open of a journal file a no-op. Writes to this journal would + ** also be no-ops, and any attempt to read the journal would return + ** SQLITE_IOERR. Or the implementation might recognize that a database + ** file will be doing page-aligned sector reads and writes in a random + ** order and set up its I/O subsystem accordingly. + ** + ** SQLite might also add one of the following flags to the xOpen method: + ** + **
    + **
  • [SQLITE_OPEN_DELETEONCLOSE] + **
  • [SQLITE_OPEN_EXCLUSIVE] + **
+ ** + ** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be + ** deleted when it is closed. ^The [SQLITE_OPEN_DELETEONCLOSE] + ** will be set for TEMP databases and their journals, transient + ** databases, and subjournals. + ** + ** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction + ** with the [SQLITE_OPEN_CREATE] flag, which are both directly + ** analogous to the O_EXCL and O_CREAT flags of the POSIX open() + ** API. The SQLITE_OPEN_EXCLUSIVE flag, when paired with the + ** SQLITE_OPEN_CREATE, is used to indicate that file should always + ** be created, and that it is an error if it already exists. + ** It is not used to indicate the file should be opened + ** for exclusive access. + ** + ** ^At least szOsFile bytes of memory are allocated by SQLite + ** to hold the [sqlite3_file] structure passed as the third + ** argument to xOpen. The xOpen method does not have to + ** allocate the structure; it should just fill it in. Note that + ** the xOpen method must set the sqlite3_file.pMethods to either + ** a valid [sqlite3_io_methods] object or to NULL. xOpen must do + ** this even if the open fails. SQLite expects that the sqlite3_file.pMethods + ** element will be valid after xOpen returns regardless of the success + ** or failure of the xOpen call. + ** + ** [[sqlite3_vfs.xAccess] + ** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS] + ** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to + ** test whether a file is readable and writable, or [SQLITE_ACCESS_READ] + ** to test whether a file is at least readable. The file can be a + ** directory. + ** + ** ^SQLite will always allocate at least mxPathname+1 bytes for the + ** output buffer xFullPathname. The exact size of the output buffer + ** is also passed as a parameter to both methods. If the output buffer + ** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is + ** handled as a fatal error by SQLite, vfs implementations should endeavor + ** to prevent this by setting mxPathname to a sufficiently large value. + ** + ** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64() + ** interfaces are not strictly a part of the filesystem, but they are + ** included in the VFS structure for completeness. + ** The xRandomness() function attempts to return nBytes bytes + ** of good-quality randomness into zOut. The return value is + ** the actual number of bytes of randomness obtained. + ** The xSleep() method causes the calling thread to sleep for at + ** least the number of microseconds given. ^The xCurrentTime() + ** method returns a Julian Day Number for the current date and time as + ** a floating point value. + ** ^The xCurrentTimeInt64() method returns, as an integer, the Julian + ** Day Number multiplied by 86400000 (the number of milliseconds in + ** a 24-hour day). + ** ^SQLite will use the xCurrentTimeInt64() method to get the current + ** date and time if that method is available (if iVersion is 2 or + ** greater and the function pointer is not NULL) and will fall back + ** to xCurrentTime() if xCurrentTimeInt64() is unavailable. + ** + ** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces + ** are not used by the SQLite core. These optional interfaces are provided + ** by some VFSes to facilitate testing of the VFS code. By overriding + ** system calls with functions under its control, a test program can + ** simulate faults and error conditions that would otherwise be difficult + ** or impossible to induce. The set of system calls that can be overridden + ** varies from one VFS to another, and from one version of the same VFS to the + ** next. Applications that use these interfaces must be prepared for any + ** or all of these interfaces to be NULL or for their behavior to change + ** from one release to the next. Applications must not attempt to access + ** any of these methods if the iVersion of the VFS is less than 3. + */ + //typedef struct sqlite3_vfs sqlite3_vfs; + //typedef void (*sqlite3_syscall_ptr)(void); + //struct sqlite3_vfs { + // int iVersion; /* Structure version number (currently 3) */ + // int szOsFile; /* Size of subclassed sqlite3_file */ + // int mxPathname; /* Maximum file pathname length */ + // sqlite3_vfs *pNext; /* Next registered VFS */ + // string zName; /* Name of this virtual file system */ + // void *pAppData; /* Pointer to application-specific data */ + // int (*xOpen)(sqlite3_vfs*, string zName, sqlite3_file*, + // int flags, int *pOutFlags); + // int (*xDelete)(sqlite3_vfs*, string zName, int syncDir); + // int (*xAccess)(sqlite3_vfs*, string zName, int flags, int *pResOut); + // int (*xFullPathname)(sqlite3_vfs*, string zName, int nOut, string zOut); + // void *(*xDlOpen)(sqlite3_vfs*, string zFilename); + // void (*xDlError)(sqlite3_vfs*, int nByte, string zErrMsg); + // void (*(*xDlSym)(sqlite3_vfs*,void*, string zSymbol))(void); + // void (*xDlClose)(sqlite3_vfs*, void); + // int (*xRandomness)(sqlite3_vfs*, int nByte, string zOut); + // int (*xSleep)(sqlite3_vfs*, int microseconds); + // int (*xCurrentTime)(sqlite3_vfs*, double); + // int (*xGetLastError)(sqlite3_vfs*, int, char ); + // /* + // ** The methods above are in version 1 of the sqlite_vfs object + // ** definition. Those that follow are added in version 2 or later + // */ + // int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64); + // /* + // ** The methods above are in versions 1 and 2 of the sqlite_vfs object. + // ** New fields may be appended in figure versions. The iVersion + // ** value will increment whenever this happens. + // */ + //}; + public class sqlite3_vfs + { + public int iVersion; /* Structure version number (currently 3) */ + public int szOsFile; /* Size of subclassed sqlite3_file */ + public int mxPathname; /* Maximum file pathname length */ + public sqlite3_vfs pNext; /* Next registered VFS */ + public string zName; /* Name of this virtual file system */ + public object pAppData; /* Pointer to application-specific data */ + public dxOpen xOpen; + public dxDelete xDelete; + public dxAccess xAccess; + public dxFullPathname xFullPathname; + public dxDlOpen xDlOpen; + public dxDlError xDlError; + public dxDlSym xDlSym; + public dxDlClose xDlClose; + public dxRandomness xRandomness; + public dxSleep xSleep; + public dxCurrentTime xCurrentTime; + public dxGetLastError xGetLastError; + /* + ** The methods above are in version 1 of the sqlite_vfs object + ** definition. Those that follow are added in version 2 or later + */ + public dxCurrentTimeInt64 xCurrentTimeInt64; + /* + ** The methods above are in versions 1 and 2 of the sqlite_vfs object. + ** Those below are for version 3 and greater. + */ + //int (*xSetSystemCall)(sqlite3_vfs*, string zName, sqlite3_syscall_ptr); + public dxSetSystemCall xSetSystemCall; + //sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, string zName); + public dxGetSystemCall xGetSystemCall; + //string (*xNextSystemCall)(sqlite3_vfs*, string zName); + public dxNextSystemCall xNextSystemCall; + /* + ** The methods above are in versions 1 through 3 of the sqlite_vfs object. + ** New fields may be appended in figure versions. The iVersion + ** value will increment whenever this happens. + */ + /* New fields may be appended in figure versions. The iVersion + ** value will increment whenever this happens. */ + + public sqlite3_vfs() + { + } + + public sqlite3_vfs( int iVersion, + int szOsFile, + int mxPathname, + sqlite3_vfs pNext, + string zName, + object pAppData, + dxOpen xOpen, + dxDelete xDelete, + dxAccess xAccess, + dxFullPathname xFullPathname, + dxDlOpen xDlOpen, + dxDlError xDlError, + dxDlSym xDlSym, + dxDlClose xDlClose, + dxRandomness xRandomness, + dxSleep xSleep, + dxCurrentTime xCurrentTime, + dxGetLastError xGetLastError, + dxCurrentTimeInt64 xCurrentTimeInt64, + dxSetSystemCall xSetSystemCall, + dxGetSystemCall xGetSystemCall, + dxNextSystemCall xNextSystemCall) + { + this.iVersion = iVersion; + this.szOsFile = szOsFile; + this.mxPathname = mxPathname; + this.pNext = pNext; + this.zName = zName; + this.pAppData = pAppData; + this.xOpen = xOpen; + this.xDelete = xDelete; + this.xAccess = xAccess; + this.xFullPathname = xFullPathname; + this.xDlOpen = xDlOpen; + this.xDlError = xDlError; + this.xDlSym = xDlSym; + this.xDlClose = xDlClose; + this.xRandomness = xRandomness; + this.xSleep = xSleep; + this.xCurrentTime = xCurrentTime; + this.xGetLastError = xGetLastError; + this.xCurrentTimeInt64 = xCurrentTimeInt64; + } + public void CopyTo(sqlite3_vfs ct) + { + ct.iVersion = this.iVersion; + ct.szOsFile = this.szOsFile; + ct.mxPathname = this.mxPathname; + ct.pNext = this.pNext; + ct.zName = this.zName; + ct.pAppData = this.pAppData; + ct.xOpen = this.xOpen; + ct.xDelete = this.xDelete; + ct.xAccess = this.xAccess; + ct.xFullPathname = this.xFullPathname; + ct.xDlOpen = this.xDlOpen; + ct.xDlError = this.xDlError; + ct.xDlSym = this.xDlSym; + ct.xDlClose = this.xDlClose; + ct.xRandomness = this.xRandomness; + ct.xSleep = this.xSleep; + ct.xCurrentTime = this.xCurrentTime; + ct.xGetLastError = this.xGetLastError; + ct.xCurrentTimeInt64 = this.xCurrentTimeInt64; + } + } - /* - ** CAPI3REF: Maximum xShmLock index - ** - ** The xShmLock method on [sqlite3_io_methods] may use values - ** between 0 and this upper bound as its "offset" argument. - ** The SQLite core will never attempt to acquire or release a - ** lock outside of this range - */ - //#define SQLITE_SHM_NLOCK 8 - const int SQLITE_SHM_NLOCK = 8; - /* - ** CAPI3REF: Initialize The SQLite Library - ** - ** ^The sqlite3_initialize() routine initializes the - ** SQLite library. ^The sqlite3_shutdown() routine - ** deallocates any resources that were allocated by sqlite3_initialize(). - ** These routines are designed to aid in process initialization and - ** shutdown on embedded systems. Workstation applications using - ** SQLite normally do not need to invoke either of these routines. - ** - ** A call to sqlite3_initialize() is an "effective" call if it is - ** the first time sqlite3_initialize() is invoked during the lifetime of - ** the process, or if it is the first time sqlite3_initialize() is invoked - ** following a call to sqlite3_shutdown(). ^(Only an effective call - ** of sqlite3_initialize() does any initialization. All other calls - ** are harmless no-ops.)^ - ** - ** A call to sqlite3_shutdown() is an "effective" call if it is the first - ** call to sqlite3_shutdown() since the last sqlite3_initialize(). ^(Only - ** an effective call to sqlite3_shutdown() does any deinitialization. - ** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^ - ** - ** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown() - ** is not. The sqlite3_shutdown() interface must only be called from a - ** single thread. All open [database connections] must be closed and all - ** other SQLite resources must be deallocated prior to invoking - ** sqlite3_shutdown(). - ** - ** Among other things, ^sqlite3_initialize() will invoke - ** sqlite3_os_init(). Similarly, ^sqlite3_shutdown() - ** will invoke sqlite3_os_end(). - ** - ** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success. - ** ^If for some reason, sqlite3_initialize() is unable to initialize - ** the library (perhaps it is unable to allocate a needed resource such - ** as a mutex) it returns an [error code] other than [SQLITE_OK]. - ** - ** ^The sqlite3_initialize() routine is called internally by many other - ** SQLite interfaces so that an application usually does not need to - ** invoke sqlite3_initialize() directly. For example, [sqlite3_open()] - ** calls sqlite3_initialize() so the SQLite library will be automatically - ** initialized when [sqlite3_open()] is called if it has not be initialized - ** already. ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT] - ** compile-time option, then the automatic calls to sqlite3_initialize() - ** are omitted and the application must call sqlite3_initialize() directly - ** prior to using any other SQLite interface. For maximum portability, - ** it is recommended that applications always invoke sqlite3_initialize() - ** directly prior to using any other SQLite interface. Future releases - ** of SQLite may require this. In other words, the behavior exhibited - ** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the - ** default behavior in some future release of SQLite. - ** - ** The sqlite3_os_init() routine does operating-system specific - ** initialization of the SQLite library. The sqlite3_os_end() - ** routine undoes the effect of sqlite3_os_init(). Typical tasks - ** performed by these routines include allocation or deallocation - ** of static resources, initialization of global variables, - ** setting up a default [sqlite3_vfs] module, or setting up - ** a default configuration using [sqlite3_config()]. - ** - ** The application should never invoke either sqlite3_os_init() - ** or sqlite3_os_end() directly. The application should only invoke - ** sqlite3_initialize() and sqlite3_shutdown(). The sqlite3_os_init() - ** interface is called automatically by sqlite3_initialize() and - ** sqlite3_os_end() is called by sqlite3_shutdown(). Appropriate - ** implementations for sqlite3_os_init() and sqlite3_os_end() - ** are built into SQLite when it is compiled for Unix, Windows, or OS/2. - ** When [custom builds | built for other platforms] - ** (using the [SQLITE_OS_OTHER=1] compile-time - ** option) the application must supply a suitable implementation for - ** sqlite3_os_init() and sqlite3_os_end(). An application-supplied - ** implementation of sqlite3_os_init() or sqlite3_os_end() - ** must return [SQLITE_OK] on success and some other [error code] upon - ** failure. - */ - //SQLITE_API int sqlite3_initialize(void); - //SQLITE_API int sqlite3_shutdown(void); - //SQLITE_API int sqlite3_os_init(void); - //SQLITE_API int sqlite3_os_end(void); + /* + ** CAPI3REF: Flags for the xAccess VFS method + ** + ** These integer constants can be used as the third parameter to + ** the xAccess method of an [sqlite3_vfs] object. They determine + ** what kind of permissions the xAccess method is looking for. + ** With SQLITE_ACCESS_EXISTS, the xAccess method + ** simply checks whether the file exists. + ** With SQLITE_ACCESS_READWRITE, the xAccess method + ** checks whether the named directory is both readable and writable + ** (in other words, if files can be added, removed, and renamed within + ** the directory). + ** The SQLITE_ACCESS_READWRITE constant is currently used only by the + ** [temp_store_directory pragma], though this could change in a future + ** release of SQLite. + ** With SQLITE_ACCESS_READ, the xAccess method + ** checks whether the file is readable. The SQLITE_ACCESS_READ constant is + ** currently unused, though it might be used in a future release of + ** SQLite. + */ + //#define SQLITE_ACCESS_EXISTS 0 + //#define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */ + //#define SQLITE_ACCESS_READ 2 /* Unused */ + const int SQLITE_ACCESS_EXISTS = 0; + const int SQLITE_ACCESS_READWRITE = 1; + const int SQLITE_ACCESS_READ = 2; + + + /* + ** CAPI3REF: Flags for the xShmLock VFS method + ** + ** These integer constants define the various locking operations + ** allowed by the xShmLock method of [sqlite3_io_methods]. The + ** following are the only legal combinations of flags to the + ** xShmLock method: + ** + **
    + **
  • SQLITE_SHM_LOCK | SQLITE_SHM_SHARED + **
  • SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE + **
  • SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED + **
  • SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE + **
+ ** + ** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as + ** was given no the corresponding lock. + ** + ** The xShmLock method can transition between unlocked and SHARED or + ** between unlocked and EXCLUSIVE. It cannot transition between SHARED + ** and EXCLUSIVE. + */ + //#define SQLITE_SHM_UNLOCK 1 + //#define SQLITE_SHM_LOCK 2 + //#define SQLITE_SHM_SHARED 4 + //#define SQLITE_SHM_EXCLUSIVE 8 + const int SQLITE_SHM_UNLOCK = 1; + const int SQLITE_SHM_LOCK = 2; + const int SQLITE_SHM_SHARED = 4; + const int SQLITE_SHM_EXCLUSIVE = 8; + + + /* + ** CAPI3REF: Maximum xShmLock index + ** + ** The xShmLock method on [sqlite3_io_methods] may use values + ** between 0 and this upper bound as its "offset" argument. + ** The SQLite core will never attempt to acquire or release a + ** lock outside of this range + */ + //#define SQLITE_SHM_NLOCK 8 + const int SQLITE_SHM_NLOCK = 8; + + /* + ** CAPI3REF: Initialize The SQLite Library + ** + ** ^The sqlite3_initialize() routine initializes the + ** SQLite library. ^The sqlite3_shutdown() routine + ** deallocates any resources that were allocated by sqlite3_initialize(). + ** These routines are designed to aid in process initialization and + ** shutdown on embedded systems. Workstation applications using + ** SQLite normally do not need to invoke either of these routines. + ** + ** A call to sqlite3_initialize() is an "effective" call if it is + ** the first time sqlite3_initialize() is invoked during the lifetime of + ** the process, or if it is the first time sqlite3_initialize() is invoked + ** following a call to sqlite3_shutdown(). ^(Only an effective call + ** of sqlite3_initialize() does any initialization. All other calls + ** are harmless no-ops.)^ + ** + ** A call to sqlite3_shutdown() is an "effective" call if it is the first + ** call to sqlite3_shutdown() since the last sqlite3_initialize(). ^(Only + ** an effective call to sqlite3_shutdown() does any deinitialization. + ** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^ + ** + ** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown() + ** is not. The sqlite3_shutdown() interface must only be called from a + ** single thread. All open [database connections] must be closed and all + ** other SQLite resources must be deallocated prior to invoking + ** sqlite3_shutdown(). + ** + ** Among other things, ^sqlite3_initialize() will invoke + ** sqlite3_os_init(). Similarly, ^sqlite3_shutdown() + ** will invoke sqlite3_os_end(). + ** + ** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success. + ** ^If for some reason, sqlite3_initialize() is unable to initialize + ** the library (perhaps it is unable to allocate a needed resource such + ** as a mutex) it returns an [error code] other than [SQLITE_OK]. + ** + ** ^The sqlite3_initialize() routine is called internally by many other + ** SQLite interfaces so that an application usually does not need to + ** invoke sqlite3_initialize() directly. For example, [sqlite3_open()] + ** calls sqlite3_initialize() so the SQLite library will be automatically + ** initialized when [sqlite3_open()] is called if it has not be initialized + ** already. ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT] + ** compile-time option, then the automatic calls to sqlite3_initialize() + ** are omitted and the application must call sqlite3_initialize() directly + ** prior to using any other SQLite interface. For maximum portability, + ** it is recommended that applications always invoke sqlite3_initialize() + ** directly prior to using any other SQLite interface. Future releases + ** of SQLite may require this. In other words, the behavior exhibited + ** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the + ** default behavior in some future release of SQLite. + ** + ** The sqlite3_os_init() routine does operating-system specific + ** initialization of the SQLite library. The sqlite3_os_end() + ** routine undoes the effect of sqlite3_os_init(). Typical tasks + ** performed by these routines include allocation or deallocation + ** of static resources, initialization of global variables, + ** setting up a default [sqlite3_vfs] module, or setting up + ** a default configuration using [sqlite3_config()]. + ** + ** The application should never invoke either sqlite3_os_init() + ** or sqlite3_os_end() directly. The application should only invoke + ** sqlite3_initialize() and sqlite3_shutdown(). The sqlite3_os_init() + ** interface is called automatically by sqlite3_initialize() and + ** sqlite3_os_end() is called by sqlite3_shutdown(). Appropriate + ** implementations for sqlite3_os_init() and sqlite3_os_end() + ** are built into SQLite when it is compiled for Unix, Windows, or OS/2. + ** When [custom builds | built for other platforms] + ** (using the [SQLITE_OS_OTHER=1] compile-time + ** option) the application must supply a suitable implementation for + ** sqlite3_os_init() and sqlite3_os_end(). An application-supplied + ** implementation of sqlite3_os_init() or sqlite3_os_end() + ** must return [SQLITE_OK] on success and some other [error code] upon + ** failure. + */ + //SQLITE_API int sqlite3_initialize(void); + //SQLITE_API int sqlite3_shutdown(void); + //SQLITE_API int sqlite3_os_init(void); + //SQLITE_API int sqlite3_os_end(void); + + /* + ** CAPI3REF: Configuring The SQLite Library + ** + ** The sqlite3_config() interface is used to make global configuration + ** changes to SQLite in order to tune SQLite to the specific needs of + ** the application. The default configuration is recommended for most + ** applications and so this routine is usually not necessary. It is + ** provided to support rare applications with unusual needs. + ** + ** The sqlite3_config() interface is not threadsafe. The application + ** must insure that no other SQLite interfaces are invoked by other + ** threads while sqlite3_config() is running. Furthermore, sqlite3_config() + ** may only be invoked prior to library initialization using + ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()]. + ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before + ** [sqlite3_shutdown()] then it will return SQLITE_MISUSE. + ** Note, however, that ^sqlite3_config() can be called as part of the + ** implementation of an application-defined [sqlite3_os_init()]. + ** + ** The first argument to sqlite3_config() is an integer + ** [configuration option] that determines + ** what property of SQLite is to be configured. Subsequent arguments + ** vary depending on the [configuration option] + ** in the first argument. + ** + ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK]. + ** ^If the option is unknown or SQLite is unable to set the option + ** then this routine returns a non-zero [error code]. + */ + //SQLITE_API int sqlite3_config(int, ...); + + /* + ** CAPI3REF: Configure database connections + ** + ** The sqlite3_db_config() interface is used to make configuration + ** changes to a [database connection]. The interface is similar to + ** [sqlite3_config()] except that the changes apply to a single + ** [database connection] (specified in the first argument). + ** + ** The second argument to sqlite3_db_config(D,V,...) is the + ** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code + ** that indicates what aspect of the [database connection] is being configured. + ** Subsequent arguments vary depending on the configuration verb. + ** + ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if + ** the call is considered successful. + */ + //SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...); + + /* + ** CAPI3REF: Memory Allocation Routines + ** + ** An instance of this object defines the interface between SQLite + ** and low-level memory allocation routines. + ** + ** This object is used in only one place in the SQLite interface. + ** A pointer to an instance of this object is the argument to + ** [sqlite3_config()] when the configuration option is + ** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC]. + ** By creating an instance of this object + ** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC]) + ** during configuration, an application can specify an alternative + ** memory allocation subsystem for SQLite to use for all of its + ** dynamic memory needs. + ** + ** Note that SQLite comes with several [built-in memory allocators] + ** that are perfectly adequate for the overwhelming majority of applications + ** and that this object is only useful to a tiny minority of applications + ** with specialized memory allocation requirements. This object is + ** also used during testing of SQLite in order to specify an alternative + ** memory allocator that simulates memory out-of-memory conditions in + ** order to verify that SQLite recovers gracefully from such + ** conditions. + ** + ** The xMalloc and xFree methods must work like the + ** malloc() and free() functions from the standard C library. + ** The xRealloc method must work like realloc() from the standard C library + ** with the exception that if the second argument to xRealloc is zero, + ** xRealloc must be a no-op - it must not perform any allocation or + ** deallocation. ^SQLite guarantees that the second argument to + ** xRealloc is always a value returned by a prior call to xRoundup. + ** And so in cases where xRoundup always returns a positive number, + ** xRealloc can perform exactly as the standard library realloc() and + ** still be in compliance with this specification. + ** + ** xSize should return the allocated size of a memory allocation + ** previously obtained from xMalloc or xRealloc. The allocated size + ** is always at least as big as the requested size but may be larger. + ** + ** The xRoundup method returns what would be the allocated size of + ** a memory allocation given a particular requested size. Most memory + ** allocators round up memory allocations at least to the next multiple + ** of 8. Some allocators round up to a larger multiple or to a power of 2. + ** Every memory allocation request coming in through [sqlite3_malloc()] + ** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0, + ** that causes the corresponding memory allocation to fail. + ** + ** The xInit method initializes the memory allocator. (For example, + ** it might allocate any require mutexes or initialize internal data + ** structures. The xShutdown method is invoked (indirectly) by + ** [sqlite3_shutdown()] and should deallocate any resources acquired + ** by xInit. The pAppData pointer is used as the only parameter to + ** xInit and xShutdown. + ** + ** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes + ** the xInit method, so the xInit method need not be threadsafe. The + ** xShutdown method is only called from [sqlite3_shutdown()] so it does + ** not need to be threadsafe either. For all other methods, SQLite + ** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the + ** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which + ** it is by default) and so the methods are automatically serialized. + ** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other + ** methods must be threadsafe or else make their own arrangements for + ** serialization. + ** + ** SQLite will never invoke xInit() more than once without an intervening + ** call to xShutdown(). + */ + //typedef struct sqlite3_mem_methods sqlite3_mem_methods; + //struct sqlite3_mem_methods { + // void *(*xMalloc)(int); /* Memory allocation function */ + // void (*xFree)(void); /* Free a prior allocation */ + // void *(*xRealloc)(void*,int); /* Resize an allocation */ + // int (*xSize)(void); /* Return the size of an allocation */ + // int (*xRoundup)(int); /* Round up request size to allocation size */ + // int (*xInit)(void); /* Initialize the memory allocator */ + // void (*xShutdown)(void); /* Deinitialize the memory allocator */ + // void *pAppData; /* Argument to xInit() and xShutdown() */ + //}; + public class sqlite3_mem_methods + { + public dxMalloc xMalloc; //void *(*xMalloc)(int); /* Memory allocation function */ + public dxMallocInt xMallocInt; //void *(*xMalloc)(int); /* Memory allocation function */ + public dxMallocMem xMallocMem; //void *(*xMalloc)(int); /* Memory allocation function */ + public dxFree xFree; //void (*xFree)(void); /* Free a prior allocation */ + public dxFreeInt xFreeInt; //void (*xFree)(void); /* Free a prior allocation */ + public dxFreeMem xFreeMem; //void (*xFree)(void); /* Free a prior allocation */ + public dxRealloc xRealloc; //void *(*xRealloc)(void*,int); /* Resize an allocation */ + public dxSize xSize; //int (*xSize)(void); /* Return the size of an allocation */ + public dxRoundup xRoundup; //int (*xRoundup)(int); /* Round up request size to allocation size */ + public dxMemInit xInit; //int (*xInit)(void); /* Initialize the memory allocator */ + public dxMemShutdown xShutdown; //void (*xShutdown)(void); /* Deinitialize the memory allocator */ + public object pAppData; /* Argument to xInit() and xShutdown() */ + + public sqlite3_mem_methods() + { + } + + public sqlite3_mem_methods( + dxMalloc xMalloc, + dxMallocInt xMallocInt, + dxMallocMem xMallocMem, + dxFree xFree, + dxFreeInt xFreeInt, + dxFreeMem xFreeMem, + dxRealloc xRealloc, + dxSize xSize, + dxRoundup xRoundup, + dxMemInit xInit, + dxMemShutdown xShutdown, + object pAppData + ) + { + this.xMalloc = xMalloc; + this.xMallocInt = xMallocInt; + this.xMallocMem = xMallocMem; + this.xFree = xFree; + this.xFreeInt = xFreeInt; + this.xFreeMem = xFreeMem; + this.xRealloc = xRealloc; + this.xSize = xSize; + this.xRoundup = xRoundup; + this.xInit = xInit; + this.xShutdown = xShutdown; + this.pAppData = pAppData; + } + } - /* - ** CAPI3REF: Configuring The SQLite Library - ** - ** The sqlite3_config() interface is used to make global configuration - ** changes to SQLite in order to tune SQLite to the specific needs of - ** the application. The default configuration is recommended for most - ** applications and so this routine is usually not necessary. It is - ** provided to support rare applications with unusual needs. - ** - ** The sqlite3_config() interface is not threadsafe. The application - ** must insure that no other SQLite interfaces are invoked by other - ** threads while sqlite3_config() is running. Furthermore, sqlite3_config() - ** may only be invoked prior to library initialization using - ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()]. - ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before - ** [sqlite3_shutdown()] then it will return SQLITE_MISUSE. - ** Note, however, that ^sqlite3_config() can be called as part of the - ** implementation of an application-defined [sqlite3_os_init()]. - ** - ** The first argument to sqlite3_config() is an integer - ** [configuration option] that determines - ** what property of SQLite is to be configured. Subsequent arguments - ** vary depending on the [configuration option] - ** in the first argument. - ** - ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK]. - ** ^If the option is unknown or SQLite is unable to set the option - ** then this routine returns a non-zero [error code]. - */ - //SQLITE_API int sqlite3_config(int, ...); - /* - ** CAPI3REF: Configure database connections - ** - ** The sqlite3_db_config() interface is used to make configuration - ** changes to a [database connection]. The interface is similar to - ** [sqlite3_config()] except that the changes apply to a single - ** [database connection] (specified in the first argument). - ** - ** The second argument to sqlite3_db_config(D,V,...) is the - ** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code - ** that indicates what aspect of the [database connection] is being configured. - ** Subsequent arguments vary depending on the configuration verb. - ** - ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if - ** the call is considered successful. - */ - //SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...); + /* + ** CAPI3REF: Configuration Options + ** KEYWORDS: {configuration option} + ** + ** These constants are the available integer configuration options that + ** can be passed as the first argument to the [sqlite3_config()] interface. + ** + ** New configuration options may be added in future releases of SQLite. + ** Existing configuration options might be discontinued. Applications + ** should check the return code from [sqlite3_config()] to make sure that + ** the call worked. The [sqlite3_config()] interface will return a + ** non-zero [error code] if a discontinued or unsupported configuration option + ** is invoked. + ** + **
+ ** [[SQLITE_CONFIG_SINGLETHREAD]]
SQLITE_CONFIG_SINGLETHREAD
+ **
There are no arguments to this option. ^This option sets the + ** [threading mode] to Single-thread. In other words, it disables + ** all mutexing and puts SQLite into a mode where it can only be used + ** by a single thread. ^If SQLite is compiled with + ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then + ** it is not possible to change the [threading mode] from its default + ** value of Single-thread and so [sqlite3_config()] will return + ** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD + ** configuration option.
+ ** + ** [[SQLITE_CONFIG_MULTITHREAD]]
SQLITE_CONFIG_MULTITHREAD
+ **
There are no arguments to this option. ^This option sets the + ** [threading mode] to Multi-thread. In other words, it disables + ** mutexing on [database connection] and [prepared statement] objects. + ** The application is responsible for serializing access to + ** [database connections] and [prepared statements]. But other mutexes + ** are enabled so that SQLite will be safe to use in a multi-threaded + ** environment as long as no two threads attempt to use the same + ** [database connection] at the same time. ^If SQLite is compiled with + ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then + ** it is not possible to set the Multi-thread [threading mode] and + ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the + ** SQLITE_CONFIG_MULTITHREAD configuration option.
+ ** + ** [[SQLITE_CONFIG_SERIALIZED]]
SQLITE_CONFIG_SERIALIZED
+ **
There are no arguments to this option. ^This option sets the + ** [threading mode] to Serialized. In other words, this option enables + ** all mutexes including the recursive + ** mutexes on [database connection] and [prepared statement] objects. + ** In this mode (which is the default when SQLite is compiled with + ** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access + ** to [database connections] and [prepared statements] so that the + ** application is free to use the same [database connection] or the + ** same [prepared statement] in different threads at the same time. + ** ^If SQLite is compiled with + ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then + ** it is not possible to set the Serialized [threading mode] and + ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the + ** SQLITE_CONFIG_SERIALIZED configuration option.
+ ** + ** [[SQLITE_CONFIG_MALLOC]]
SQLITE_CONFIG_MALLOC
+ **
^(This option takes a single argument which is a pointer to an + ** instance of the [sqlite3_mem_methods] structure. The argument specifies + ** alternative low-level memory allocation routines to be used in place of + ** the memory allocation routines built into SQLite.)^ ^SQLite makes + ** its own private copy of the content of the [sqlite3_mem_methods] structure + ** before the [sqlite3_config()] call returns.
+ ** + ** [[SQLITE_CONFIG_GETMALLOC]]
SQLITE_CONFIG_GETMALLOC
+ **
^(This option takes a single argument which is a pointer to an + ** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods] + ** structure is filled with the currently defined memory allocation routines.)^ + ** This option can be used to overload the default memory allocation + ** routines with a wrapper that simulations memory allocation failure or + ** tracks memory usage, for example.
+ ** + ** [[SQLITE_CONFIG_MEMSTATUS]]
SQLITE_CONFIG_MEMSTATUS
+ **
^This option takes single argument of type int, interpreted as a + ** boolean, which enables or disables the collection of memory allocation + ** statistics. ^(When memory allocation statistics are disabled, the + ** following SQLite interfaces become non-operational: + **
    + **
  • [sqlite3_memory_used()] + **
  • [sqlite3_memory_highwater()] + **
  • [sqlite3_soft_heap_limit64()] + **
  • [sqlite3_status()] + **
)^ + ** ^Memory allocation statistics are enabled by default unless SQLite is + ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory + ** allocation statistics are disabled by default. + **
+ ** + ** [[SQLITE_CONFIG_SCRATCH]]
SQLITE_CONFIG_SCRATCH
+ **
^This option specifies a static memory buffer that SQLite can use for + ** scratch memory. There are three arguments: A pointer an 8-byte + ** aligned memory buffer from which the scratch allocations will be + ** drawn, the size of each scratch allocation (sz), + ** and the maximum number of scratch allocations (N). The sz + ** argument must be a multiple of 16. + ** The first argument must be a pointer to an 8-byte aligned buffer + ** of at least sz*N bytes of memory. + ** ^SQLite will use no more than two scratch buffers per thread. So + ** N should be set to twice the expected maximum number of threads. + ** ^SQLite will never require a scratch buffer that is more than 6 + ** times the database page size. ^If SQLite needs needs additional + ** scratch memory beyond what is provided by this configuration option, then + ** [sqlite3_malloc()] will be used to obtain the memory needed.
+ ** + ** [[SQLITE_CONFIG_PAGECACHE]]
SQLITE_CONFIG_PAGECACHE
+ **
^This option specifies a static memory buffer that SQLite can use for + ** the database page cache with the default page cache implementation. + ** This configuration should not be used if an application-define page + ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option. + ** There are three arguments to this option: A pointer to 8-byte aligned + ** memory, the size of each page buffer (sz), and the number of pages (N). + ** The sz argument should be the size of the largest database page + ** (a power of two between 512 and 32768) plus a little extra for each + ** page header. ^The page header size is 20 to 40 bytes depending on + ** the host architecture. ^It is harmless, apart from the wasted memory, + ** to make sz a little too large. The first + ** argument should point to an allocation of at least sz*N bytes of memory. + ** ^SQLite will use the memory provided by the first argument to satisfy its + ** memory needs for the first N pages that it adds to cache. ^If additional + ** page cache memory is needed beyond what is provided by this option, then + ** SQLite goes to [sqlite3_malloc()] for the additional storage space. + ** The pointer in the first argument must + ** be aligned to an 8-byte boundary or subsequent behavior of SQLite + ** will be undefined.
+ ** + ** [[SQLITE_CONFIG_HEAP]]
SQLITE_CONFIG_HEAP
+ **
^This option specifies a static memory buffer that SQLite will use + ** for all of its dynamic memory allocation needs beyond those provided + ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE]. + ** There are three arguments: An 8-byte aligned pointer to the memory, + ** the number of bytes in the memory buffer, and the minimum allocation size. + ** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts + ** to using its default memory allocator (the system malloc() implementation), + ** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. ^If the + ** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or + ** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory + ** allocator is engaged to handle all of SQLites memory allocation needs. + ** The first pointer (the memory pointer) must be aligned to an 8-byte + ** boundary or subsequent behavior of SQLite will be undefined. + ** The minimum allocation size is capped at 2^12. Reasonable values + ** for the minimum allocation size are 2^5 through 2^8.
+ ** + ** [[SQLITE_CONFIG_MUTEX]]
SQLITE_CONFIG_MUTEX
+ **
^(This option takes a single argument which is a pointer to an + ** instance of the [sqlite3_mutex_methods] structure. The argument specifies + ** alternative low-level mutex routines to be used in place + ** the mutex routines built into SQLite.)^ ^SQLite makes a copy of the + ** content of the [sqlite3_mutex_methods] structure before the call to + ** [sqlite3_config()] returns. ^If SQLite is compiled with + ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then + ** the entire mutexing subsystem is omitted from the build and hence calls to + ** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will + ** return [SQLITE_ERROR].
+ ** + ** [[SQLITE_CONFIG_GETMUTEX]]
SQLITE_CONFIG_GETMUTEX
+ **
^(This option takes a single argument which is a pointer to an + ** instance of the [sqlite3_mutex_methods] structure. The + ** [sqlite3_mutex_methods] + ** structure is filled with the currently defined mutex routines.)^ + ** This option can be used to overload the default mutex allocation + ** routines with a wrapper used to track mutex usage for performance + ** profiling or testing, for example. ^If SQLite is compiled with + ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then + ** the entire mutexing subsystem is omitted from the build and hence calls to + ** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will + ** return [SQLITE_ERROR].
+ ** + ** [[SQLITE_CONFIG_LOOKASIDE]]
SQLITE_CONFIG_LOOKASIDE
+ **
^(This option takes two arguments that determine the default + ** memory allocation for the lookaside memory allocator on each + ** [database connection]. The first argument is the + ** size of each lookaside buffer slot and the second is the number of + ** slots allocated to each database connection.)^ ^(This option sets the + ** default lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE] + ** verb to [sqlite3_db_config()] can be used to change the lookaside + ** configuration on individual connections.)^
+ ** + ** [[SQLITE_CONFIG_PCACHE]]
SQLITE_CONFIG_PCACHE
+ **
^(This option takes a single argument which is a pointer to + ** an [sqlite3_pcache_methods] object. This object specifies the interface + ** to a custom page cache implementation.)^ ^SQLite makes a copy of the + ** object and uses it for page cache memory allocations.
+ ** + ** [[SQLITE_CONFIG_GETPCACHE]]
SQLITE_CONFIG_GETPCACHE
+ **
^(This option takes a single argument which is a pointer to an + ** [sqlite3_pcache_methods] object. SQLite copies of the current + ** page cache implementation into that object.)^
+ ** + ** [[SQLITE_CONFIG_LOG]]
SQLITE_CONFIG_LOG
+ **
^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a + ** function with a call signature of void()(void*,int,const char), + ** and a pointer to void. ^If the function pointer is not NULL, it is + ** invoked by [sqlite3_log()] to process each logging event. ^If the + ** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op. + ** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is + ** passed through as the first parameter to the application-defined logger + ** function whenever that function is invoked. ^The second parameter to + ** the logger function is a copy of the first parameter to the corresponding + ** [sqlite3_log()] call and is intended to be a [result code] or an + ** [extended result code]. ^The third parameter passed to the logger is + ** log message after formatting via [sqlite3_snprintf()]. + ** The SQLite logging interface is not reentrant; the logger function + ** 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 + ** URI handling is globally enabled. If the parameter is zero, then URI handling + ** 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 + ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the + ** 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. + **
+ */ + //#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ + //#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ + //#define SQLITE_CONFIG_SERIALIZED 3 /* nil */ + //#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ + //#define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ + //#define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */ + //#define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */ + //#define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */ + //#define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */ + //#define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */ + //#define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */ + ///* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ + //#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ + //#define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */ + //#define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */ + //#define SQLITE_CONFIG_LOG 16 /* xFunc, void* */ + //#define SQLITE_CONFIG_URI 17 /* int */ + public const int SQLITE_CONFIG_SINGLETHREAD = 1; + public const int SQLITE_CONFIG_MULTITHREAD = 2; + public const int SQLITE_CONFIG_SERIALIZED = 3; + public const int SQLITE_CONFIG_MALLOC = 4; + public const int SQLITE_CONFIG_GETMALLOC = 5; + public const int SQLITE_CONFIG_SCRATCH = 6; + public const int SQLITE_CONFIG_PAGECACHE = 7; + public const int SQLITE_CONFIG_HEAP = 8; + public const int SQLITE_CONFIG_MEMSTATUS = 9; + public const int SQLITE_CONFIG_MUTEX = 10; + public const int SQLITE_CONFIG_GETMUTEX = 11; + public const int SQLITE_CONFIG_LOOKASIDE = 13; + public const int SQLITE_CONFIG_PCACHE = 14; + public const int SQLITE_CONFIG_GETPCACHE = 15; + public const int SQLITE_CONFIG_LOG = 16; + public const int SQLITE_CONFIG_URI = 17; + + /* + ** CAPI3REF: Database Connection Configuration Options + ** + ** These constants are the available integer configuration options that + ** can be passed as the second argument to the [sqlite3_db_config()] interface. + ** + ** New configuration options may be added in future releases of SQLite. + ** Existing configuration options might be discontinued. Applications + ** should check the return code from [sqlite3_db_config()] to make sure that + ** the call worked. ^The [sqlite3_db_config()] interface will return a + ** non-zero [error code] if a discontinued or unsupported configuration option + ** is invoked. + ** + **
+ **
SQLITE_DBCONFIG_LOOKASIDE
+ **
^This option takes three additional arguments that determine the + ** [lookaside memory allocator] configuration for the [database connection]. + ** ^The first argument (the third parameter to [sqlite3_db_config()] is a + ** pointer to a memory buffer to use for lookaside memory. + ** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb + ** may be NULL in which case SQLite will allocate the + ** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the + ** size of each lookaside buffer slot. ^The third argument is the number of + ** slots. The size of the buffer in the first argument must be greater than + ** or equal to the product of the second and third arguments. The buffer + ** must be aligned to an 8-byte boundary. ^If the second argument to + ** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally + ** rounded down to the next smaller multiple of 8. ^(The lookaside memory + ** configuration for a database connection can only be changed when that + ** connection is not currently using lookaside memory, or in other words + ** when the "current value" returned by + ** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero. + ** Any attempt to change the lookaside memory configuration when lookaside + ** memory is in use leaves the configuration unchanged and returns + ** [SQLITE_BUSY].)^
+ ** + **
SQLITE_DBCONFIG_ENABLE_FKEY
+ **
^This option is used to enable or disable the enforcement of + ** [foreign key constraints]. There should be two additional arguments. + ** The first argument is an integer which is 0 to disable FK enforcement, + ** positive to enable FK enforcement or negative to leave FK enforcement + ** unchanged. The second parameter is a pointer to an integer into which + ** is written 0 or 1 to indicate whether FK enforcement is off or on + ** following this call. The second parameter may be a NULL pointer, in + ** which case the FK enforcement setting is not reported back.
+ ** + **
SQLITE_DBCONFIG_ENABLE_TRIGGER
+ **
^This option is used to enable or disable [CREATE TRIGGER | triggers]. + ** There should be two additional arguments. + ** The first argument is an integer which is 0 to disable triggers, + ** positive to enable triggers or negative to leave the setting unchanged. + ** The second parameter is a pointer to an integer into which + ** is written 0 or 1 to indicate whether triggers are disabled or enabled + ** following this call. The second parameter may be a NULL pointer, in + ** which case the trigger setting is not reported back.
+ ** + **
+ */ + //#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ + //#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */ + //#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */ + const int SQLITE_DBCONFIG_LOOKASIDE = 1001; + const int SQLITE_DBCONFIG_ENABLE_FKEY = 1002; + const int SQLITE_DBCONFIG_ENABLE_TRIGGER = 1003; + + /* + ** CAPI3REF: Enable Or Disable Extended Result Codes + ** + ** ^The sqlite3_extended_result_codes() routine enables or disables the + ** [extended result codes] feature of SQLite. ^The extended result + ** codes are disabled by default for historical compatibility. + */ + //SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff); + + /* + ** CAPI3REF: Last Insert Rowid + ** + ** ^Each entry in an SQLite table has a unique 64-bit signed + ** integer key called the [ROWID | "rowid"]. ^The rowid is always available + ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those + ** names are not also used by explicitly declared columns. ^If + ** the table has a column of type [INTEGER PRIMARY KEY] then that column + ** is another alias for the rowid. + ** + ** ^This routine returns the [rowid] of the most recent + ** successful [INSERT] into the database from the [database connection] + ** in the first argument. ^As of SQLite version 3.7.7, this routines + ** records the last insert rowid of both ordinary tables and [virtual tables]. + ** ^If no successful [INSERT]s + ** have ever occurred on that database connection, zero is returned. + ** + ** ^(If an [INSERT] occurs within a trigger or within a [virtual table] + ** method, then this routine will return the [rowid] of the inserted + ** row as long as the trigger or virtual table method is running. + ** But once the trigger or virtual table method ends, the value returned + ** by this routine reverts to what it was before the trigger or virtual + ** table method began.)^ + ** + ** ^An [INSERT] that fails due to a constraint violation is not a + ** successful [INSERT] and does not change the value returned by this + ** routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK, + ** and INSERT OR ABORT make no changes to the return value of this + ** routine when their insertion fails. ^(When INSERT OR REPLACE + ** encounters a constraint violation, it does not fail. The + ** INSERT continues to completion after deleting rows that caused + ** the constraint problem so INSERT OR REPLACE will always change + ** the return value of this interface.)^ + ** + ** ^For the purposes of this routine, an [INSERT] is considered to + ** be successful even if it is subsequently rolled back. + ** + ** This function is accessible to SQL statements via the + ** [last_insert_rowid() SQL function]. + ** + ** If a separate thread performs a new [INSERT] on the same + ** database connection while the [sqlite3_last_insert_rowid()] + ** function is running and thus changes the last insert [rowid], + ** then the value returned by [sqlite3_last_insert_rowid()] is + ** unpredictable and might not equal either the old or the new + ** last insert [rowid]. + */ + //SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3); + + /* + ** CAPI3REF: Count The Number Of Rows Modified + ** + ** ^This function returns the number of database rows that were changed + ** or inserted or deleted by the most recently completed SQL statement + ** on the [database connection] specified by the first parameter. + ** ^(Only changes that are directly specified by the [INSERT], [UPDATE], + ** or [DELETE] statement are counted. Auxiliary changes caused by + ** triggers or [foreign key actions] are not counted.)^ Use the + ** [sqlite3_total_changes()] function to find the total number of changes + ** including changes caused by triggers and foreign key actions. + ** + ** ^Changes to a view that are simulated by an [INSTEAD OF trigger] + ** are not counted. Only real table changes are counted. + ** + ** ^(A "row change" is a change to a single row of a single table + ** caused by an INSERT, DELETE, or UPDATE statement. Rows that + ** are changed as side effects of [REPLACE] constraint resolution, + ** rollback, ABORT processing, [DROP TABLE], or by any other + ** mechanisms do not count as direct row changes.)^ + ** + ** A "trigger context" is a scope of execution that begins and + ** ends with the script of a [CREATE TRIGGER | trigger]. + ** Most SQL statements are + ** evaluated outside of any trigger. This is the "top level" + ** trigger context. If a trigger fires from the top level, a + ** new trigger context is entered for the duration of that one + ** trigger. Subtriggers create subcontexts for their duration. + ** + ** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does + ** not create a new trigger context. + ** + ** ^This function returns the number of direct row changes in the + ** most recent INSERT, UPDATE, or DELETE statement within the same + ** trigger context. + ** + ** ^Thus, when called from the top level, this function returns the + ** number of changes in the most recent INSERT, UPDATE, or DELETE + ** that also occurred at the top level. ^(Within the body of a trigger, + ** the sqlite3_changes() interface can be called to find the number of + ** changes in the most recently completed INSERT, UPDATE, or DELETE + ** statement within the body of the same trigger. + ** However, the number returned does not include changes + ** caused by subtriggers since those have their own context.)^ + ** + ** See also the [sqlite3_total_changes()] interface, the + ** [count_changes pragma], and the [changes() SQL function]. + ** + ** If a separate thread makes changes on the same database connection + ** while [sqlite3_changes()] is running then the value returned + ** is unpredictable and not meaningful. + */ + //SQLITE_API int sqlite3_changes(sqlite3); + + /* + ** CAPI3REF: Total Number Of Rows Modified + ** + ** ^This function returns the number of row changes caused by [INSERT], + ** [UPDATE] or [DELETE] statements since the [database connection] was opened. + ** ^(The count returned by sqlite3_total_changes() includes all changes + ** from all [CREATE TRIGGER | trigger] contexts and changes made by + ** [foreign key actions]. However, + ** the count does not include changes used to implement [REPLACE] constraints, + ** do rollbacks or ABORT processing, or [DROP TABLE] processing. The + ** count does not include rows of views that fire an [INSTEAD OF trigger], + ** though if the INSTEAD OF trigger makes changes of its own, those changes + ** are counted.)^ + ** ^The sqlite3_total_changes() function counts the changes as soon as + ** the statement that makes them is completed (when the statement handle + ** is passed to [sqlite3_reset()] or [sqlite3_finalize()]). + ** + ** See also the [sqlite3_changes()] interface, the + ** [count_changes pragma], and the [total_changes() SQL function]. + ** + ** If a separate thread makes changes on the same database connection + ** while [sqlite3_total_changes()] is running then the value + ** returned is unpredictable and not meaningful. + */ + //SQLITE_API int sqlite3_total_changes(sqlite3); + + /* + ** CAPI3REF: Interrupt A Long-Running Query + ** + ** ^This function causes any pending database operation to abort and + ** return at its earliest opportunity. This routine is typically + ** called in response to a user action such as pressing "Cancel" + ** or Ctrl-C where the user wants a long query operation to halt + ** immediately. + ** + ** ^It is safe to call this routine from a thread different from the + ** thread that is currently running the database operation. But it + ** is not safe to call this routine with a [database connection] that + ** is closed or might close before sqlite3_interrupt() returns. + ** + ** ^If an SQL operation is very nearly finished at the time when + ** sqlite3_interrupt() is called, then it might not have an opportunity + ** to be interrupted and might continue to completion. + ** + ** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT]. + ** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE + ** that is inside an explicit transaction, then the entire transaction + ** will be rolled back automatically. + ** + ** ^The sqlite3_interrupt(D) call is in effect until all currently running + ** SQL statements on [database connection] D complete. ^Any new SQL statements + ** that are started after the sqlite3_interrupt() call and before the + ** running statements reaches zero are interrupted as if they had been + ** running prior to the sqlite3_interrupt() call. ^New SQL statements + ** that are started after the running statement count reaches zero are + ** not effected by the sqlite3_interrupt(). + ** ^A call to sqlite3_interrupt(D) that occurs when there are no running + ** SQL statements is a no-op and has no effect on SQL statements + ** that are started after the sqlite3_interrupt() call returns. + ** + ** If the database connection closes while [sqlite3_interrupt()] + ** is running then bad things will likely happen. + */ + //SQLITE_API void sqlite3_interrupt(sqlite3); + + /* + ** CAPI3REF: Determine If An SQL Statement Is Complete + ** + ** These routines are useful during command-line input to determine if the + ** currently entered text seems to form a complete SQL statement or + ** if additional input is needed before sending the text into + ** SQLite for parsing. ^These routines return 1 if the input string + ** appears to be a complete SQL statement. ^A statement is judged to be + ** complete if it ends with a semicolon token and is not a prefix of a + ** well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within + ** string literals or quoted identifier names or comments are not + ** independent tokens (they are part of the token in which they are + ** embedded) and thus do not count as a statement terminator. ^Whitespace + ** and comments that follow the final semicolon are ignored. + ** + ** ^These routines return 0 if the statement is incomplete. ^If a + ** memory allocation fails, then SQLITE_NOMEM is returned. + ** + ** ^These routines do not parse the SQL statements thus + ** will not detect syntactically incorrect SQL. + ** + ** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior + ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked + ** automatically by sqlite3_complete16(). If that initialization fails, + ** then the return value from sqlite3_complete16() will be non-zero + ** regardless of whether or not the input SQL is complete.)^ + ** + ** The input to [sqlite3_complete()] must be a zero-terminated + ** UTF-8 string. + ** + ** The input to [sqlite3_complete16()] must be a zero-terminated + ** UTF-16 string in native byte order. + */ + //SQLITE_API int sqlite3_complete(string sql); + //SQLITE_API int sqlite3_complete16(const void *sql); + + /* + ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors + ** + ** ^This routine sets a callback function that might be invoked whenever + ** an attempt is made to open a database table that another thread + ** or process has locked. + ** + ** ^If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] + ** is returned immediately upon encountering the lock. ^If the busy callback + ** is not NULL, then the callback might be invoked with two arguments. + ** + ** ^The first argument to the busy handler is a copy of the void* pointer which + ** is the third argument to sqlite3_busy_handler(). ^The second argument to + ** the busy handler callback is the number of times that the busy handler has + ** been invoked for this locking event. ^If the + ** busy callback returns 0, then no additional attempts are made to + ** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned. + ** ^If the callback returns non-zero, then another attempt + ** is made to open the database for reading and the cycle repeats. + ** + ** The presence of a busy handler does not guarantee that it will be invoked + ** when there is lock contention. ^If SQLite determines that invoking the busy + ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY] + ** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler. + ** Consider a scenario where one process is holding a read lock that + ** it is trying to promote to a reserved lock and + ** a second process is holding a reserved lock that it is trying + ** to promote to an exclusive lock. The first process cannot proceed + ** because it is blocked by the second and the second process cannot + ** proceed because it is blocked by the first. If both processes + ** invoke the busy handlers, neither will make any progress. Therefore, + ** SQLite returns [SQLITE_BUSY] for the first process, hoping that this + ** will induce the first process to release its read lock and allow + ** the second process to proceed. + ** + ** ^The default busy callback is NULL. + ** + ** ^The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED] + ** when SQLite is in the middle of a large transaction where all the + ** changes will not fit into the in-memory cache. SQLite will + ** already hold a RESERVED lock on the database file, but it needs + ** to promote this lock to EXCLUSIVE so that it can spill cache + ** pages into the database file without harm to concurrent + ** readers. ^If it is unable to promote the lock, then the in-memory + ** cache will be left in an inconsistent state and so the error + ** code is promoted from the relatively benign [SQLITE_BUSY] to + ** the more severe [SQLITE_IOERR_BLOCKED]. ^This error code promotion + ** forces an automatic rollback of the changes. See the + ** + ** CorruptionFollowingBusyError wiki page for a discussion of why + ** this is important. + ** + ** ^(There can only be a single busy handler defined for each + ** [database connection]. Setting a new busy handler clears any + ** previously set handler.)^ ^Note that calling [sqlite3_busy_timeout()] + ** will also set or clear the busy handler. + ** + ** The busy callback should not take any actions which modify the + ** database connection that invoked the busy handler. Any such actions + ** result in undefined behavior. + ** + ** A busy handler must not close the database connection + ** or [prepared statement] that invoked the busy handler. + */ + //SQLITE_API int sqlite3_busy_handler(sqlite3*, int()(void*,int), void); + + /* + ** CAPI3REF: Set A Busy Timeout + ** + ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps + ** for a specified amount of time when a table is locked. ^The handler + ** will sleep multiple times until at least "ms" milliseconds of sleeping + ** have accumulated. ^After at least "ms" milliseconds of sleeping, + ** the handler returns 0 which causes [sqlite3_step()] to return + ** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]. + ** + ** ^Calling this routine with an argument less than or equal to zero + ** turns off all busy handlers. + ** + ** ^(There can only be a single busy handler for a particular + ** [database connection] any any given moment. If another busy handler + ** was defined (using [sqlite3_busy_handler()]) prior to calling + ** this routine, that other busy handler is cleared.)^ + */ + //SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms); + + /* + ** CAPI3REF: Convenience Routines For Running Queries + ** + ** This is a legacy interface that is preserved for backwards compatibility. + ** Use of this interface is not recommended. + ** + ** Definition: A result table is memory data structure created by the + ** [sqlite3_get_table()] interface. A result table records the + ** complete query results from one or more queries. + ** + ** The table conceptually has a number of rows and columns. But + ** these numbers are not part of the result table itself. These + ** numbers are obtained separately. Let N be the number of rows + ** and M be the number of columns. + ** + ** A result table is an array of pointers to zero-terminated UTF-8 strings. + ** There are (N+1)*M elements in the array. The first M pointers point + ** to zero-terminated strings that contain the names of the columns. + ** The remaining entries all point to query results. NULL values result + ** in NULL pointers. All other values are in their UTF-8 zero-terminated + ** string representation as returned by [sqlite3_column_text()]. + ** + ** A result table might consist of one or more memory allocations. + ** It is not safe to pass a result table directly to [sqlite3_free()]. + ** A result table should be deallocated using [sqlite3_free_table()]. + ** + ** ^(As an example of the result table format, suppose a query result + ** is as follows: + ** + **
+    **        Name        | Age
+    **        -----------------------
+    **        Alice       | 43
+    **        Bob         | 28
+    **        Cindy       | 21
+    ** 
+ ** + ** There are two column (M==2) and three rows (N==3). Thus the + ** result table has 8 entries. Suppose the result table is stored + ** in an array names azResult. Then azResult holds this content: + ** + **
+    **        azResult[0] = "Name";
+    **        azResult[1] = "Age";
+    **        azResult[2] = "Alice";
+    **        azResult[3] = "43";
+    **        azResult[4] = "Bob";
+    **        azResult[5] = "28";
+    **        azResult[6] = "Cindy";
+    **        azResult[7] = "21";
+    ** 
)^ + ** + ** ^The sqlite3_get_table() function evaluates one or more + ** semicolon-separated SQL statements in the zero-terminated UTF-8 + ** string of its 2nd parameter and returns a result table to the + ** pointer given in its 3rd parameter. + ** + ** After the application has finished with the result from sqlite3_get_table(), + ** it must pass the result table pointer to sqlite3_free_table() in order to + ** release the memory that was malloced. Because of the way the + ** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling + ** function must not try to call [sqlite3_free()] directly. Only + ** [sqlite3_free_table()] is able to release the memory properly and safely. + ** + ** The sqlite3_get_table() interface is implemented as a wrapper around + ** [sqlite3_exec()]. The sqlite3_get_table() routine does not have access + ** to any internal data structures of SQLite. It uses only the public + ** interface defined here. As a consequence, errors that occur in the + ** wrapper layer outside of the internal [sqlite3_exec()] call are not + ** reflected in subsequent calls to [sqlite3_errcode()] or + ** [sqlite3_errmsg()]. + */ + //SQLITE_API int sqlite3_get_table( + // sqlite3 db, /* An open database */ + // string zSql, /* SQL to be evaluated */ + // char ***pazResult, /* Results of the query */ + // int *pnRow, /* Number of result rows written here */ + // int *pnColumn, /* Number of result columns written here */ + // char **pzErrmsg /* Error msg written here */ + //); + //SQLITE_API void sqlite3_free_table(char **result); + + /* + ** CAPI3REF: Formatted String Printing Functions + ** + ** These routines are work-alikes of the "printf()" family of functions + ** from the standard C library. + ** + ** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their + ** results into memory obtained from [sqlite3_malloc()]. + ** The strings returned by these two routines should be + ** released by [sqlite3_free()]. ^Both routines return a + ** NULL pointer if [sqlite3_malloc()] is unable to allocate enough + ** memory to hold the resulting string. + ** + ** ^(The sqlite3_snprintf() routine is similar to "snprintf()" from + ** the standard C library. The result is written into the + ** buffer supplied as the second parameter whose size is given by + ** the first parameter. Note that the order of the + ** first two parameters is reversed from snprintf().)^ This is an + ** historical accident that cannot be fixed without breaking + ** backwards compatibility. ^(Note also that sqlite3_snprintf() + ** returns a pointer to its buffer instead of the number of + ** characters actually written into the buffer.)^ We admit that + ** the number of characters written would be a more useful return + ** value but we cannot change the implementation of sqlite3_snprintf() + ** now without breaking compatibility. + ** + ** ^As long as the buffer size is greater than zero, sqlite3_snprintf() + ** guarantees that the buffer is always zero-terminated. ^The first + ** parameter "n" is the total size of the buffer, including space for + ** the zero terminator. So the longest string that can be completely + ** written will be n-1 characters. + ** + ** ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf(). + ** + ** These routines all implement some additional formatting + ** options that are useful for constructing SQL statements. + ** All of the usual printf() formatting options apply. In addition, there + ** is are "%q", "%Q", and "%z" options. + ** + ** ^(The %q option works like %s in that it substitutes a null-terminated + ** string from the argument list. But %q also doubles every '\'' character. + ** %q is designed for use inside a string literal.)^ By doubling each '\'' + ** character it escapes that character and allows it to be inserted into + ** the string. + ** + ** For example, assume the string variable zText contains text as follows: + ** + **
+    **  string zText = "It's a happy day!";
+    ** 
+ ** + ** One can use this text in an SQL statement as follows: + ** + **
+    **  string zSQL = sqlite3_mprintf("INSERT INTO table VALUES('%q')", zText);
+    **  sqlite3_exec(db, zSQL, 0, 0, 0);
+    **  sqlite3_free(zSQL);
+    ** 
+ ** + ** Because the %q format string is used, the '\'' character in zText + ** is escaped and the SQL generated is as follows: + ** + **
+    **  INSERT INTO table1 VALUES('It''s a happy day!')
+    ** 
+ ** + ** This is correct. Had we used %s instead of %q, the generated SQL + ** would have looked like this: + ** + **
+    **  INSERT INTO table1 VALUES('It's a happy day!');
+    ** 
+ ** + ** This second example is an SQL syntax error. As a general rule you should + ** always use %q instead of %s when inserting text into a string literal. + ** + ** ^(The %Q option works like %q except it also adds single quotes around + ** the outside of the total string. Additionally, if the parameter in the + ** argument list is a NULL pointer, %Q substitutes the text "NULL" (without + ** single quotes).)^ So, for example, one could say: + ** + **
+    **  string zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
+    **  sqlite3_exec(db, zSQL, 0, 0, 0);
+    **  sqlite3_free(zSQL);
+    ** 
+ ** + ** The code above will render a correct SQL statement in the zSQL + ** variable even if the zText variable is a NULL pointer. + ** + ** ^(The "%z" formatting option works like "%s" but with the + ** addition that after the string has been read and copied into + ** the result, [sqlite3_free()] is called on the input string.)^ + */ + //SQLITE_API char *sqlite3_mprintf(const char*,...); + //SQLITE_API char *sqlite3_vmprintf(const char*, va_list); + //SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...); + //SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list); + + + /* + ** CAPI3REF: Memory Allocation Subsystem + ** + ** The SQLite core uses these three routines for all of its own + ** internal memory allocation needs. "Core" in the previous sentence + ** does not include operating-system specific VFS implementation. The + ** Windows VFS uses native malloc() and free() for some operations. + ** + ** ^The sqlite3_malloc() routine returns a pointer to a block + ** of memory at least N bytes in length, where N is the parameter. + ** ^If sqlite3_malloc() is unable to obtain sufficient free + ** memory, it returns a NULL pointer. ^If the parameter N to + ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns + ** a NULL pointer. + ** + ** ^Calling sqlite3_free() with a pointer previously returned + ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so + ** that it might be reused. ^The sqlite3_free() routine is + ** a no-op if is called with a NULL pointer. Passing a NULL pointer + ** to sqlite3_free() is harmless. After being freed, memory + ** should neither be read nor written. Even reading previously freed + ** memory might result in a segmentation fault or other severe error. + ** Memory corruption, a segmentation fault, or other severe error + ** might result if sqlite3_free() is called with a non-NULL pointer that + ** was not obtained from sqlite3_malloc() or sqlite3_realloc(). + ** + ** ^(The sqlite3_realloc() interface attempts to resize a + ** prior memory allocation to be at least N bytes, where N is the + ** second parameter. The memory allocation to be resized is the first + ** parameter.)^ ^ If the first parameter to sqlite3_realloc() + ** is a NULL pointer then its behavior is identical to calling + ** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc(). + ** ^If the second parameter to sqlite3_realloc() is zero or + ** negative then the behavior is exactly the same as calling + ** sqlite3_free(P) where P is the first parameter to sqlite3_realloc(). + ** ^sqlite3_realloc() returns a pointer to a memory allocation + ** of at least N bytes in size or NULL if sufficient memory is unavailable. + ** ^If M is the size of the prior allocation, then min(N,M) bytes + ** of the prior allocation are copied into the beginning of buffer returned + ** by sqlite3_realloc() and the prior allocation is freed. + ** ^If sqlite3_realloc() returns NULL, then the prior allocation + ** is not freed. + ** + ** ^The memory returned by sqlite3_malloc() and sqlite3_realloc() + ** is always aligned to at least an 8 byte boundary, or to a + ** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time + ** option is used. + ** + ** In SQLite version 3.5.0 and 3.5.1, it was possible to define + ** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in + ** implementation of these routines to be omitted. That capability + ** is no longer provided. Only built-in memory allocators can be used. + ** + ** The Windows OS interface layer calls + ** the system malloc() and free() directly when converting + ** filenames between the UTF-8 encoding used by SQLite + ** and whatever filename encoding is used by the particular Windows + ** installation. Memory allocation errors are detected, but + ** they are reported back as [SQLITE_CANTOPEN] or + ** [SQLITE_IOERR] rather than [SQLITE_NOMEM]. + ** + ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()] + ** must be either NULL or else pointers obtained from a prior + ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have + ** not yet been released. + ** + ** The application must not read or write any part of + ** a block of memory after it has been released using + ** [sqlite3_free()] or [sqlite3_realloc()]. + */ + //SQLITE_API void *sqlite3_malloc(int); + //SQLITE_API void *sqlite3_realloc(void*, int); + //SQLITE_API void sqlite3_free(void); + + /* + ** CAPI3REF: Memory Allocator Statistics + ** + ** SQLite provides these two interfaces for reporting on the status + ** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()] + ** routines, which form the built-in memory allocation subsystem. + ** + ** ^The [sqlite3_memory_used()] routine returns the number of bytes + ** of memory currently outstanding (malloced but not freed). + ** ^The [sqlite3_memory_highwater()] routine returns the maximum + ** value of [sqlite3_memory_used()] since the high-water mark + ** was last reset. ^The values returned by [sqlite3_memory_used()] and + ** [sqlite3_memory_highwater()] include any overhead + ** added by SQLite in its implementation of [sqlite3_malloc()], + ** but not overhead added by the any underlying system library + ** routines that [sqlite3_malloc()] may call. + ** + ** ^The memory high-water mark is reset to the current value of + ** [sqlite3_memory_used()] if and only if the parameter to + ** [sqlite3_memory_highwater()] is true. ^The value returned + ** by [sqlite3_memory_highwater(1)] is the high-water mark + ** prior to the reset. + */ + //SQLITE_API sqlite3_int64 sqlite3_memory_used(void); + //SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag); + + /* + ** CAPI3REF: Pseudo-Random Number Generator + ** + ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to + ** select random [ROWID | ROWIDs] when inserting new records into a table that + ** already uses the largest possible [ROWID]. The PRNG is also used for + ** the build-in random() and randomblob() SQL functions. This interface allows + ** applications to access the same PRNG for other purposes. + ** + ** ^A call to this routine stores N bytes of randomness into buffer P. + ** + ** ^The first time this routine is invoked (either internally or by + ** the application) the PRNG is seeded using randomness obtained + ** from the xRandomness method of the default [sqlite3_vfs] object. + ** ^On all subsequent invocations, the pseudo-randomness is generated + ** internally and without recourse to the [sqlite3_vfs] xRandomness + ** method. + */ + //SQLITE_API void sqlite3_randomness(int N, object *P); + + /* + ** CAPI3REF: Compile-Time Authorization Callbacks + ** + ** ^This routine registers an authorizer callback with a particular + ** [database connection], supplied in the first argument. + ** ^The authorizer callback is invoked as SQL statements are being compiled + ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()], + ** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various + ** points during the compilation process, as logic is being created + ** to perform various actions, the authorizer callback is invoked to + ** see if those actions are allowed. ^The authorizer callback should + ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the + ** specific action but allow the SQL statement to continue to be + ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be + ** rejected with an error. ^If the authorizer callback returns + ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY] + ** then the [sqlite3_prepare_v2()] or equivalent call that triggered + ** the authorizer will fail with an error message. + ** + ** When the callback returns [SQLITE_OK], that means the operation + ** requested is ok. ^When the callback returns [SQLITE_DENY], the + ** [sqlite3_prepare_v2()] or equivalent call that triggered the + ** authorizer will fail with an error message explaining that + ** access is denied. + ** + ** ^The first parameter to the authorizer callback is a copy of the third + ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter + ** to the callback is an integer [SQLITE_COPY | action code] that specifies + ** the particular action to be authorized. ^The third through sixth parameters + ** to the callback are zero-terminated strings that contain additional + ** details about the action to be authorized. + ** + ** ^If the action code is [SQLITE_READ] + ** and the callback returns [SQLITE_IGNORE] then the + ** [prepared statement] statement is constructed to substitute + ** a NULL value in place of the table column that would have + ** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE] + ** return can be used to deny an untrusted user access to individual + ** columns of a table. + ** ^If the action code is [SQLITE_DELETE] and the callback returns + ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the + ** [truncate optimization] is disabled and all rows are deleted individually. + ** + ** An authorizer is used when [sqlite3_prepare | preparing] + ** SQL statements from an untrusted source, to ensure that the SQL statements + ** do not try to access data they are not allowed to see, or that they do not + ** try to execute malicious statements that damage the database. For + ** example, an application may allow a user to enter arbitrary + ** SQL queries for evaluation by a database. But the application does + ** not want the user to be able to make arbitrary changes to the + ** database. An authorizer could then be put in place while the + ** user-entered SQL is being [sqlite3_prepare | prepared] that + ** disallows everything except [SELECT] statements. + ** + ** Applications that need to process SQL from untrusted sources + ** might also consider lowering resource limits using [sqlite3_limit()] + ** and limiting database size using the [max_page_count] [PRAGMA] + ** in addition to using an authorizer. + ** + ** ^(Only a single authorizer can be in place on a database connection + ** at a time. Each call to sqlite3_set_authorizer overrides the + ** previous call.)^ ^Disable the authorizer by installing a NULL callback. + ** The authorizer is disabled by default. + ** + ** The authorizer callback must not do anything that will modify + ** the database connection that invoked the authorizer callback. + ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their + ** database connections for the meaning of "modify" in this paragraph. + ** + ** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the + ** statement might be re-prepared during [sqlite3_step()] due to a + ** schema change. Hence, the application should ensure that the + ** correct authorizer callback remains in place during the [sqlite3_step()]. + ** + ** ^Note that the authorizer callback is invoked only during + ** [sqlite3_prepare()] or its variants. Authorization is not + ** performed during statement evaluation in [sqlite3_step()], unless + ** as stated in the previous paragraph, sqlite3_step() invokes + ** sqlite3_prepare_v2() to reprepare a statement after a schema change. + */ + //SQLITE_API int sqlite3_set_authorizer( + // sqlite3*, + // int (*xAuth)(void*,int,const char*,const char*,const char*,const char), + // void *pUserData + //); + + /* + ** CAPI3REF: Authorizer Return Codes + ** + ** The [sqlite3_set_authorizer | authorizer callback function] must + ** return either [SQLITE_OK] or one of these two constants in order + ** to signal SQLite whether or not the action is permitted. See the + ** [sqlite3_set_authorizer | authorizer documentation] for additional + ** information. + ** + ** Note that SQLITE_IGNORE is also used as a [SQLITE_ROLLBACK | return code] + ** from the [sqlite3_vtab_on_conflict()] interface. + */ + //#define SQLITE_DENY 1 /* Abort the SQL statement with an error */ + //#define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */ + const int SQLITE_DENY = 1; + const int SQLITE_IGNORE = 2; + + /* + ** CAPI3REF: Authorizer Action Codes + ** + ** The [sqlite3_set_authorizer()] interface registers a callback function + ** that is invoked to authorize certain SQL statement actions. The + ** second parameter to the callback is an integer code that specifies + ** what action is being authorized. These are the integer action codes that + ** the authorizer callback may be passed. + ** + ** These action code values signify what kind of operation is to be + ** authorized. The 3rd and 4th parameters to the authorization + ** callback function will be parameters or NULL depending on which of these + ** codes is used as the second parameter. ^(The 5th parameter to the + ** authorizer callback is the name of the database ("main", "temp", + ** etc.) if applicable.)^ ^The 6th parameter to the authorizer callback + ** is the name of the inner-most trigger or view that is responsible for + ** the access attempt or NULL if this access attempt is directly from + ** top-level SQL code. + */ + /******************************************* 3rd ************ 4th ***********/ + //#define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */ + //#define SQLITE_CREATE_TABLE 2 /* Table Name NULL */ + //#define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */ + //#define SQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */ + //#define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */ + //#define SQLITE_CREATE_TEMP_VIEW 6 /* View Name NULL */ + //#define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */ + //#define SQLITE_CREATE_VIEW 8 /* View Name NULL */ + //#define SQLITE_DELETE 9 /* Table Name NULL */ + //#define SQLITE_DROP_INDEX 10 /* Index Name Table Name */ + //#define SQLITE_DROP_TABLE 11 /* Table Name NULL */ + //#define SQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */ + //#define SQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */ + //#define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */ + //#define SQLITE_DROP_TEMP_VIEW 15 /* View Name NULL */ + //#define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */ + //#define SQLITE_DROP_VIEW 17 /* View Name NULL */ + //#define SQLITE_INSERT 18 /* Table Name NULL */ + //#define SQLITE_PRAGMA 19 /* Pragma Name 1st arg or NULL */ + //#define SQLITE_READ 20 /* Table Name Column Name */ + //#define SQLITE_SELECT 21 /* NULL NULL */ + //#define SQLITE_TRANSACTION 22 /* Operation NULL */ + //#define SQLITE_UPDATE 23 /* Table Name Column Name */ + //#define SQLITE_ATTACH 24 /* Filename NULL */ + //#define SQLITE_DETACH 25 /* Database Name NULL */ + //#define SQLITE_ALTER_TABLE 26 /* Database Name Table Name */ + //#define SQLITE_REINDEX 27 /* Index Name NULL */ + //#define SQLITE_ANALYZE 28 /* Table Name NULL */ + //#define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */ + //#define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */ + //#define SQLITE_FUNCTION 31 /* NULL Function Name */ + //#define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */ + //#define SQLITE_COPY 0 /* No longer used */ + const int SQLITE_CREATE_INDEX = 1; + const int SQLITE_CREATE_TABLE = 2; + const int SQLITE_CREATE_TEMP_INDEX = 3; + const int SQLITE_CREATE_TEMP_TABLE = 4; + const int SQLITE_CREATE_TEMP_TRIGGER = 5; + const int SQLITE_CREATE_TEMP_VIEW = 6; + const int SQLITE_CREATE_TRIGGER = 7; + const int SQLITE_CREATE_VIEW = 8; + const int SQLITE_DELETE = 9; + const int SQLITE_DROP_INDEX = 10; + const int SQLITE_DROP_TABLE = 11; + const int SQLITE_DROP_TEMP_INDEX = 12; + const int SQLITE_DROP_TEMP_TABLE = 13; + const int SQLITE_DROP_TEMP_TRIGGER = 14; + const int SQLITE_DROP_TEMP_VIEW = 15; + const int SQLITE_DROP_TRIGGER = 16; + const int SQLITE_DROP_VIEW = 17; + const int SQLITE_INSERT = 18; + const int SQLITE_PRAGMA = 19; + const int SQLITE_READ = 20; + const int SQLITE_SELECT = 21; + const int SQLITE_TRANSACTION = 22; + const int SQLITE_UPDATE = 23; + const int SQLITE_ATTACH = 24; + const int SQLITE_DETACH = 25; + const int SQLITE_ALTER_TABLE = 26; + const int SQLITE_REINDEX = 27; + const int SQLITE_ANALYZE = 28; + const int SQLITE_CREATE_VTABLE = 29; + const int SQLITE_DROP_VTABLE = 30; + const int SQLITE_FUNCTION = 31; + const int SQLITE_SAVEPOINT = 32; + const int SQLITE_COPY = 0; + + /* + ** CAPI3REF: Tracing And Profiling Functions + ** + ** These routines register callback functions that can be used for + ** tracing and profiling the execution of SQL statements. + ** + ** ^The callback function registered by sqlite3_trace() is invoked at + ** various times when an SQL statement is being run by [sqlite3_step()]. + ** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the + ** SQL statement text as the statement first begins executing. + ** ^(Additional sqlite3_trace() callbacks might occur + ** as each triggered subprogram is entered. The callbacks for triggers + ** contain a UTF-8 SQL comment that identifies the trigger.)^ + ** + ** ^The callback function registered by sqlite3_profile() is invoked + ** as each SQL statement finishes. ^The profile callback contains + ** the original statement text and an estimate of wall-clock time + ** of how long that statement took to run. ^The profile callback + ** time is in units of nanoseconds, however the current implementation + ** is only capable of millisecond resolution so the six least significant + ** digits in the time are meaningless. Future versions of SQLite + ** might provide greater resolution on the profiler callback. The + ** sqlite3_profile() function is considered experimental and is + ** subject to change in future versions of SQLite. + */ + //SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char), void); + //SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*, + // void(*xProfile)(void*,const char*,sqlite3_uint64), void); + + /* + ** CAPI3REF: Query Progress Callbacks + ** + ** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback + ** function X to be invoked periodically during long running calls to + ** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for + ** database connection D. An example use for this + ** interface is to keep a GUI updated during a large query. + ** + ** ^The parameter P is passed through as the only parameter to the + ** callback function X. ^The parameter N is the number of + ** [virtual machine instructions] that are evaluated between successive + ** invocations of the callback X. + ** + ** ^Only a single progress handler may be defined at one time per + ** [database connection]; setting a new progress handler cancels the + ** old one. ^Setting parameter X to NULL disables the progress handler. + ** ^The progress handler is also disabled by setting N to a value less + ** than 1. + ** + ** ^If the progress callback returns non-zero, the operation is + ** interrupted. This feature can be used to implement a + ** "Cancel" button on a GUI progress dialog box. + ** + ** The progress handler callback must not do anything that will modify + ** the database connection that invoked the progress handler. + ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their + ** database connections for the meaning of "modify" in this paragraph. + ** + */ + //SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int()(void), void); + + /* + ** CAPI3REF: Opening A New Database Connection + ** + ** ^These routines open an SQLite database file as specified by the + ** filename argument. ^The filename argument is interpreted as UTF-8 for + ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte + ** order for sqlite3_open16(). ^(A [database connection] handle is usually + ** returned in *ppDb, even if an error occurs. The only exception is that + ** if SQLite is unable to allocate memory to hold the [sqlite3] object, + ** a NULL will be written into *ppDb instead of a pointer to the [sqlite3] + ** object.)^ ^(If the database is opened (and/or created) successfully, then + ** [SQLITE_OK] is returned. Otherwise an [error code] is returned.)^ ^The + ** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain + ** an English language description of the error following a failure of any + ** of the sqlite3_open() routines. + ** + ** ^The default encoding for the database will be UTF-8 if + ** sqlite3_open() or sqlite3_open_v2() is called and + ** UTF-16 in the native byte order if sqlite3_open16() is used. + ** + ** Whether or not an error occurs when it is opened, resources + ** associated with the [database connection] handle should be released by + ** passing it to [sqlite3_close()] when it is no longer required. + ** + ** The sqlite3_open_v2() interface works like sqlite3_open() + ** except that it accepts two additional parameters for additional control + ** over the new database connection. ^(The flags parameter to + ** sqlite3_open_v2() can take one of + ** the following three values, optionally combined with the + ** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE], + ** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^ + ** + **
+ ** ^(
[SQLITE_OPEN_READONLY]
+ **
The database is opened in read-only mode. If the database does not + ** already exist, an error is returned.
)^ + ** + ** ^(
[SQLITE_OPEN_READWRITE]
+ **
The database is opened for reading and writing if possible, or reading + ** only if the file is write protected by the operating system. In either + ** case the database must already exist, otherwise an error is returned.
)^ + ** + ** ^(
[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]
+ **
The database is opened for reading and writing, and is created if + ** it does not already exist. This is the behavior that is always used for + ** sqlite3_open() and sqlite3_open16().
)^ + **
+ ** + ** If the 3rd parameter to sqlite3_open_v2() is not one of the + ** combinations shown above optionally combined with other + ** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits] + ** then the behavior is undefined. + ** + ** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection + ** opens in the multi-thread [threading mode] as long as the single-thread + ** mode has not been set at compile-time or start-time. ^If the + ** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens + ** in the serialized [threading mode] unless single-thread was + ** previously selected at compile-time or start-time. + ** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be + ** eligible to use [shared cache mode], regardless of whether or not shared + ** cache is enabled using [sqlite3_enable_shared_cache()]. ^The + ** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not + ** participate in [shared cache mode] even if it is enabled. + ** + ** ^The fourth parameter to sqlite3_open_v2() is the name of the + ** [sqlite3_vfs] object that defines the operating system interface that + ** the new database connection should use. ^If the fourth parameter is + ** a NULL pointer then the default [sqlite3_vfs] object is used. + ** + ** ^If the filename is ":memory:", then a private, temporary in-memory database + ** is created for the connection. ^This in-memory database will vanish when + ** the database connection is closed. Future versions of SQLite might + ** make use of additional special filenames that begin with the ":" character. + ** It is recommended that when a database filename actually does begin with + ** a ":" character you should prefix the filename with a pathname such as + ** "./" to avoid ambiguity. + ** + ** ^If the filename is an empty string, then a private, temporary + ** on-disk database will be created. ^This private database will be + ** automatically deleted as soon as the database connection is closed. + ** + ** [[URI filenames in sqlite3_open()]]

URI Filenames

+ ** + ** ^If [URI filename] interpretation is enabled, and the filename argument + ** begins with "file:", then the filename is interpreted as a URI. ^URI + ** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is + ** set in the fourth argument to sqlite3_open_v2(), or if it has + ** been enabled globally using the [SQLITE_CONFIG_URI] option with the + ** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option. + ** As of SQLite version 3.7.7, URI filename interpretation is turned off + ** by default, but future releases of SQLite might enable URI filename + ** interpretation by default. See "[URI filenames]" for additional + ** information. + ** + ** URI filenames are parsed according to RFC 3986. ^If the URI contains an + ** authority, then it must be either an empty string or the string + ** "localhost". ^If the authority is not an empty string or "localhost", an + ** error is returned to the caller. ^The fragment component of a URI, if + ** present, is ignored. + ** + ** ^SQLite uses the path component of the URI as the name of the disk file + ** which contains the database. ^If the path begins with a '/' character, + ** then it is interpreted as an absolute path. ^If the path does not begin + ** with a '/' (meaning that the authority section is omitted from the URI) + ** then the path is interpreted as a relative path. + ** ^On windows, the first component of an absolute path + ** is a drive specification (e.g. "C:"). + ** + ** [[core URI query parameters]] + ** The query component of a URI may contain parameters that are interpreted + ** either by SQLite itself, or by a [VFS | custom VFS implementation]. + ** SQLite interprets the following three query parameters: + ** + **
    + **
  • vfs: ^The "vfs" parameter may be used to specify the name of + ** a VFS object that provides the operating system interface that should + ** be used to access the database file on disk. ^If this option is set to + ** an empty string the default VFS object is used. ^Specifying an unknown + ** VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is + ** present, then the VFS specified by the option takes precedence over + ** the value passed as the fourth parameter to sqlite3_open_v2(). + ** + **
  • mode: ^(The mode parameter may be set to either "ro", "rw" or + ** "rwc". Attempting to set it to any other value is an error)^. + ** ^If "ro" is specified, then the database is opened for read-only + ** access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the + ** third argument to sqlite3_prepare_v2(). ^If the mode option is set to + ** "rw", then the database is opened for read-write (but not create) + ** access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had + ** been set. ^Value "rwc" is equivalent to setting both + ** SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE. ^If sqlite3_open_v2() is + ** used, it is an error to specify a value for the mode parameter that is + ** less restrictive than that specified by the flags passed as the third + ** parameter. + ** + **
  • cache: ^The cache parameter may be set to either "shared" or + ** "private". ^Setting it to "shared" is equivalent to setting the + ** SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to + ** sqlite3_open_v2(). ^Setting the cache parameter to "private" is + ** equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit. + ** ^If sqlite3_open_v2() is used and the "cache" parameter is present in + ** a URI filename, its value overrides any behaviour requested by setting + ** SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag. + **
+ ** + ** ^Specifying an unknown parameter in the query component of a URI is not an + ** error. Future versions of SQLite might understand additional query + ** parameters. See "[query parameters with special meaning to SQLite]" for + ** additional information. + ** + ** [[URI filename examples]]

URI filename examples

+ ** + **
+ **
URI filenames Results + **
file:data.db + ** Open the file "data.db" in the current directory. + **
file:/home/fred/data.db
+ ** file:///home/fred/data.db
+ ** file://localhost/home/fred/data.db
+ ** Open the database file "/home/fred/data.db". + **
file://darkstar/home/fred/data.db + ** An error. "darkstar" is not a recognized authority. + **
+ ** file:///C:/Documents%20and%20Settings/fred/Desktop/data.db + ** Windows only: Open the file "data.db" on fred's desktop on drive + ** C:. Note that the %20 escaping in this example is not strictly + ** necessary - space characters can be used literally + ** in URI filenames. + **
file:data.db?mode=ro&cache=private + ** Open file "data.db" in the current directory for read-only access. + ** Regardless of whether or not shared-cache mode is enabled by + ** default, use a private cache. + **
file:/home/fred/data.db?vfs=unix-nolock + ** Open file "/home/fred/data.db". Use the special VFS "unix-nolock". + **
file:data.db?mode=readonly + ** An error. "readonly" is not a valid option for the "mode" parameter. + **
+ ** + ** ^URI hexadecimal escape sequences (%HH) are supported within the path and + ** query components of a URI. A hexadecimal escape sequence consists of a + ** percent sign - "%" - followed by exactly two hexadecimal digits + ** specifying an octet value. ^Before the path or query components of a + ** URI filename are interpreted, they are encoded using UTF-8 and all + ** hexadecimal escape sequences replaced by a single byte containing the + ** corresponding octet. If this process generates an invalid UTF-8 encoding, + ** the results are undefined. + ** + ** Note to Windows users: The encoding used for the filename argument + ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever + ** codepage is currently defined. Filenames containing international + ** characters must be converted to UTF-8 prior to passing them into + ** sqlite3_open() or sqlite3_open_v2(). + */ + //SQLITE_API int sqlite3_open( + // string filename, /* Database filename (UTF-8) */ + // sqlite3 **ppDb /* OUT: SQLite db handle */ + //); + //SQLITE_API int sqlite3_open16( + // const void *filename, /* Database filename (UTF-16) */ + // sqlite3 **ppDb /* OUT: SQLite db handle */ + //); + //SQLITE_API int sqlite3_open_v2( + // string filename, /* Database filename (UTF-8) */ + // sqlite3 **ppDb, /* OUT: SQLite db handle */ + // int flags, /* Flags */ + // string zVfs /* Name of VFS module to use */ + //); + + /* + ** CAPI3REF: Obtain Values For URI Parameters + ** + ** This is a utility routine, useful to VFS implementations, that checks + ** to see if a database file was a URI that contained a specific query + ** parameter, and if so obtains the value of the query parameter. + ** + ** The zFilename argument is the filename pointer passed into the xOpen() + ** method of a VFS implementation. The zParam argument is the name of the + ** query parameter we seek. This routine returns the value of the zParam + ** parameter if it exists. If the parameter does not exist, this routine + ** returns a NULL pointer. + ** + ** If the zFilename argument to this function is not a pointer that SQLite + ** passed into the xOpen VFS method, then the behavior of this routine + ** is undefined and probably undesirable. + */ + //SQLITE_API string sqlite3_uri_parameter(string zFilename, string zParam); + + + /* + ** CAPI3REF: Error Codes And Messages + ** + ** ^The sqlite3_errcode() interface returns the numeric [result code] or + ** [extended result code] for the most recent failed sqlite3_* API call + ** associated with a [database connection]. If a prior API call failed + ** but the most recent API call succeeded, the return value from + ** sqlite3_errcode() is undefined. ^The sqlite3_extended_errcode() + ** interface is the same except that it always returns the + ** [extended result code] even when extended result codes are + ** disabled. + ** + ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language + ** text that describes the error, as either UTF-8 or UTF-16 respectively. + ** ^(Memory to hold the error message string is managed internally. + ** The application does not need to worry about freeing the result. + ** However, the error string might be overwritten or deallocated by + ** subsequent calls to other SQLite interface functions.)^ + ** + ** When the serialized [threading mode] is in use, it might be the + ** case that a second error occurs on a separate thread in between + ** the time of the first error and the call to these interfaces. + ** When that happens, the second error will be reported since these + ** interfaces always report the most recent result. To avoid + ** this, each thread can obtain exclusive use of the [database connection] D + ** by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning + ** to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after + ** all calls to the interfaces listed here are completed. + ** + ** If an interface fails with SQLITE_MISUSE, that means the interface + ** was invoked incorrectly by the application. In that case, the + ** error code and message may or may not be set. + */ + //SQLITE_API int sqlite3_errcode(sqlite3 db); + //SQLITE_API int sqlite3_extended_errcode(sqlite3 db); + //SQLITE_API string sqlite3_errmsg(sqlite3); + //SQLITE_API const void *sqlite3_errmsg16(sqlite3); + + /* + ** CAPI3REF: SQL Statement Object + ** KEYWORDS: {prepared statement} {prepared statements} + ** + ** An instance of this object represents a single SQL statement. + ** This object is variously known as a "prepared statement" or a + ** "compiled SQL statement" or simply as a "statement". + ** + ** The life of a statement object goes something like this: + ** + **
    + **
  1. Create the object using [sqlite3_prepare_v2()] or a related + ** function. + **
  2. Bind values to [host parameters] using the sqlite3_bind_*() + ** interfaces. + **
  3. Run the SQL by calling [sqlite3_step()] one or more times. + **
  4. Reset the statement using [sqlite3_reset()] then go back + ** to step 2. Do this zero or more times. + **
  5. Destroy the object using [sqlite3_finalize()]. + **
+ ** + ** Refer to documentation on individual methods above for additional + ** information. + */ + //typedef struct sqlite3_stmt sqlite3_stmt; + + /* + ** CAPI3REF: Run-time Limits + ** + ** ^(This interface allows the size of various constructs to be limited + ** on a connection by connection basis. The first parameter is the + ** [database connection] whose limit is to be set or queried. The + ** second parameter is one of the [limit categories] that define a + ** class of constructs to be size limited. The third parameter is the + ** new limit for that construct.)^ + ** + ** ^If the new limit is a negative number, the limit is unchanged. + ** ^(For each limit category SQLITE_LIMIT_NAME there is a + ** [limits | hard upper bound] + ** set at compile-time by a C preprocessor macro called + ** [limits | SQLITE_MAX_NAME]. + ** (The "_LIMIT_" in the name is changed to "_MAX_".))^ + ** ^Attempts to increase a limit above its hard upper bound are + ** silently truncated to the hard upper bound. + ** + ** ^Regardless of whether or not the limit was changed, the + ** [sqlite3_limit()] interface returns the prior value of the limit. + ** ^Hence, to find the current value of a limit without changing it, + ** simply invoke this interface with the third parameter set to -1. + ** + ** Run-time limits are intended for use in applications that manage + ** both their own internal database and also databases that are controlled + ** by untrusted external sources. An example application might be a + ** web browser that has its own databases for storing history and + ** separate databases controlled by JavaScript applications downloaded + ** off the Internet. The internal databases can be given the + ** large, default limits. Databases managed by external sources can + ** be given much smaller limits designed to prevent a denial of service + ** attack. Developers might also want to use the [sqlite3_set_authorizer()] + ** interface to further control untrusted SQL. The size of the database + ** created by an untrusted script can be contained using the + ** [max_page_count] [PRAGMA]. + ** + ** New run-time limit categories may be added in future releases. + */ + //SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); + + /* + ** CAPI3REF: Run-Time Limit Categories + ** KEYWORDS: {limit category} {*limit categories} + ** + ** These constants define various performance limits + ** that can be lowered at run-time using [sqlite3_limit()]. + ** The synopsis of the meanings of the various limits is shown below. + ** Additional information is available at [limits | Limits in SQLite]. + ** + **
+ ** [[SQLITE_LIMIT_LENGTH]] ^(
SQLITE_LIMIT_LENGTH
+ **
The maximum size of any string or BLOB or table row, in bytes.
)^ + ** + ** [[SQLITE_LIMIT_SQL_LENGTH]] ^(
SQLITE_LIMIT_SQL_LENGTH
+ **
The maximum length of an SQL statement, in bytes.
)^ + ** + ** [[SQLITE_LIMIT_COLUMN]] ^(
SQLITE_LIMIT_COLUMN
+ **
The maximum number of columns in a table definition or in the + ** result set of a [SELECT] or the maximum number of columns in an index + ** or in an ORDER BY or GROUP BY clause.
)^ + ** + ** [[SQLITE_LIMIT_EXPR_DEPTH]] ^(
SQLITE_LIMIT_EXPR_DEPTH
+ **
The maximum depth of the parse tree on any expression.
)^ + ** + ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(
SQLITE_LIMIT_COMPOUND_SELECT
+ **
The maximum number of terms in a compound SELECT statement.
)^ + ** + ** [[SQLITE_LIMIT_VDBE_OP]] ^(
SQLITE_LIMIT_VDBE_OP
+ **
The maximum number of instructions in a virtual machine program + ** used to implement an SQL statement. This limit is not currently + ** enforced, though that might be added in some future release of + ** SQLite.
)^ + ** + ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(
SQLITE_LIMIT_FUNCTION_ARG
+ **
The maximum number of arguments on a function.
)^ + ** + ** [[SQLITE_LIMIT_ATTACHED]] ^(
SQLITE_LIMIT_ATTACHED
+ **
The maximum number of [ATTACH | attached databases].)^
+ ** + ** [[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]] + ** ^(
SQLITE_LIMIT_LIKE_PATTERN_LENGTH
+ **
The maximum length of the pattern argument to the [LIKE] or + ** [GLOB] operators.
)^ + ** + ** [[SQLITE_LIMIT_VARIABLE_NUMBER]] + ** ^(
SQLITE_LIMIT_VARIABLE_NUMBER
+ **
The maximum index number of any [parameter] in an SQL statement.)^ + ** + ** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(
SQLITE_LIMIT_TRIGGER_DEPTH
+ **
The maximum depth of recursion for triggers.
)^ + **
+ */ + //#define SQLITE_LIMIT_LENGTH 0 + //#define SQLITE_LIMIT_SQL_LENGTH 1 + //#define SQLITE_LIMIT_COLUMN 2 + //#define SQLITE_LIMIT_EXPR_DEPTH 3 + //#define SQLITE_LIMIT_COMPOUND_SELECT 4 + //#define SQLITE_LIMIT_VDBE_OP 5 + //#define SQLITE_LIMIT_FUNCTION_ARG 6 + //#define SQLITE_LIMIT_ATTACHED 7 + //#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8 + //#define SQLITE_LIMIT_VARIABLE_NUMBER 9 + //#define SQLITE_LIMIT_TRIGGER_DEPTH 10 + const int SQLITE_LIMIT_LENGTH = 0; + const int SQLITE_LIMIT_SQL_LENGTH = 1; + const int SQLITE_LIMIT_COLUMN = 2; + const int SQLITE_LIMIT_EXPR_DEPTH = 3; + const int SQLITE_LIMIT_COMPOUND_SELECT = 4; + const int SQLITE_LIMIT_VDBE_OP = 5; + const int SQLITE_LIMIT_FUNCTION_ARG = 6; + const int SQLITE_LIMIT_ATTACHED = 7; + const int SQLITE_LIMIT_LIKE_PATTERN_LENGTH = 8; + const int SQLITE_LIMIT_VARIABLE_NUMBER = 9; + const int SQLITE_LIMIT_TRIGGER_DEPTH = 10; + + /* + ** CAPI3REF: Compiling An SQL Statement + ** KEYWORDS: {SQL statement compiler} + ** + ** To execute an SQL query, it must first be compiled into a byte-code + ** program using one of these routines. + ** + ** The first argument, "db", is a [database connection] obtained from a + ** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or + ** [sqlite3_open16()]. The database connection must not have been closed. + ** + ** The second argument, "zSql", is the statement to be compiled, encoded + ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() + ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2() + ** use UTF-16. + ** + ** ^If the nByte argument is less than zero, then zSql is read up to the + ** first zero terminator. ^If nByte is non-negative, then it is the maximum + ** number of bytes read from zSql. ^When nByte is non-negative, the + ** zSql string ends at either the first '\000' or '\u0000' character or + ** the nByte-th byte, whichever comes first. If the caller knows + ** that the supplied string is nul-terminated, then there is a small + ** performance advantage to be gained by passing an nByte parameter that + ** is equal to the number of bytes in the input string including + ** the nul-terminator bytes. + ** + ** ^If pzTail is not NULL then *pzTail is made to point to the first byte + ** past the end of the first SQL statement in zSql. These routines only + ** compile the first statement in zSql, so *pzTail is left pointing to + ** what remains uncompiled. + ** + ** ^*ppStmt is left pointing to a compiled [prepared statement] that can be + ** executed using [sqlite3_step()]. ^If there is an error, *ppStmt is set + ** to NULL. ^If the input text contains no SQL (if the input is an empty + ** string or a comment) then *ppStmt is set to NULL. + ** The calling procedure is responsible for deleting the compiled + ** SQL statement using [sqlite3_finalize()] after it has finished with it. + ** ppStmt may not be NULL. + ** + ** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK]; + ** otherwise an [error code] is returned. + ** + ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are + ** recommended for all new programs. The two older interfaces are retained + ** for backwards compatibility, but their use is discouraged. + ** ^In the "v2" interfaces, the prepared statement + ** that is returned (the [sqlite3_stmt] object) contains a copy of the + ** original SQL text. This causes the [sqlite3_step()] interface to + ** behave differently in three ways: + ** + **
    + **
  1. + ** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it + ** always used to do, [sqlite3_step()] will automatically recompile the SQL + ** statement and try to run it again. + **
  2. + ** + **
  3. + ** ^When an error occurs, [sqlite3_step()] will return one of the detailed + ** [error codes] or [extended error codes]. ^The legacy behavior was that + ** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code + ** and the application would have to make a second call to [sqlite3_reset()] + ** in order to find the underlying cause of the problem. With the "v2" prepare + ** interfaces, the underlying reason for the error is returned immediately. + **
  4. + ** + **
  5. + ** ^If the specific value bound to [parameter | host parameter] in the + ** WHERE clause might influence the choice of query plan for a statement, + ** then the statement will be automatically recompiled, as if there had been + ** a schema change, on the first [sqlite3_step()] call following any change + ** to the [sqlite3_bind_text | bindings] of that [parameter]. + ** ^The specific value of WHERE-clause [parameter] might influence the + ** choice of query plan if the parameter is the left-hand side of a [LIKE] + ** or [GLOB] operator or if the parameter is compared to an indexed column + ** and the [SQLITE_ENABLE_STAT2] compile-time option is enabled. + ** the + **
  6. + **
+ */ + //SQLITE_API int sqlite3_prepare( + // sqlite3 db, /* Database handle */ + // string zSql, /* SQL statement, UTF-8 encoded */ + // int nByte, /* Maximum length of zSql in bytes. */ + // sqlite3_stmt **ppStmt, /* OUT: Statement handle */ + // string *pzTail /* OUT: Pointer to unused portion of zSql */ + //); + //SQLITE_API int sqlite3_prepare_v2( + // sqlite3 db, /* Database handle */ + // string zSql, /* SQL statement, UTF-8 encoded */ + // int nByte, /* Maximum length of zSql in bytes. */ + // sqlite3_stmt **ppStmt, /* OUT: Statement handle */ + // string *pzTail /* OUT: Pointer to unused portion of zSql */ + //); + //SQLITE_API int sqlite3_prepare16( + // sqlite3 db, /* Database handle */ + // string zSql, /* SQL statement, UTF-16 encoded */ + // int nByte, /* Maximum length of zSql in bytes. */ + // sqlite3_stmt **ppStmt, /* OUT: Statement handle */ + // const void **pzTail /* OUT: Pointer to unused portion of zSql */ + //); + //SQLITE_API int sqlite3_prepare16_v2( + // sqlite3 db, /* Database handle */ + // string zSql, /* SQL statement, UTF-16 encoded */ + // int nByte, /* Maximum length of zSql in bytes. */ + // sqlite3_stmt **ppStmt, /* OUT: Statement handle */ + // const void **pzTail /* OUT: Pointer to unused portion of zSql */ + //); + + /* + ** CAPI3REF: Retrieving Statement SQL + ** + ** ^This interface can be used to retrieve a saved copy of the original + ** SQL text used to create a [prepared statement] if that statement was + ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()]. + */ + //SQLITE_API string sqlite3_sql(sqlite3_stmt *pStmt); + + /* + ** CAPI3REF: Determine If An SQL Statement Writes The Database + ** + ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if + ** and only if the [prepared statement] X makes no direct changes to + ** the content of the database file. + ** + ** Note that [application-defined SQL functions] or + ** [virtual tables] might change the database indirectly as a side effect. + ** ^(For example, if an application defines a function "eval()" that + ** calls [sqlite3_exec()], then the following SQL statement would + ** change the database file through side-effects: + ** + **
+    **    SELECT eval('DELETE FROM t1') FROM t2;
+    ** 
+ ** + ** But because the [SELECT] statement does not change the database file + ** directly, sqlite3_stmt_readonly() would still return true.)^ + ** + ** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK], + ** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true, + ** since the statements themselves do not actually modify the database but + ** rather they control the timing of when other statements modify the + ** database. ^The [ATTACH] and [DETACH] statements also cause + ** sqlite3_stmt_readonly() to return true since, while those statements + ** change the configuration of a database connection, they do not make + ** changes to the content of the database files on disk. + */ + //SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); + + /* + ** CAPI3REF: Dynamically Typed Value Object + ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value} + ** + ** SQLite uses the sqlite3_value object to represent all values + ** that can be stored in a database table. SQLite uses dynamic typing + ** for the values it stores. ^Values stored in sqlite3_value objects + ** can be integers, floating point values, strings, BLOBs, or NULL. + ** + ** An sqlite3_value object may be either "protected" or "unprotected". + ** Some interfaces require a protected sqlite3_value. Other interfaces + ** will accept either a protected or an unprotected sqlite3_value. + ** Every interface that accepts sqlite3_value arguments specifies + ** whether or not it requires a protected sqlite3_value. + ** + ** The terms "protected" and "unprotected" refer to whether or not + ** a mutex is held. An internal mutex is held for a protected + ** sqlite3_value object but no mutex is held for an unprotected + ** sqlite3_value object. If SQLite is compiled to be single-threaded + ** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0) + ** or if SQLite is run in one of reduced mutex modes + ** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD] + ** then there is no distinction between protected and unprotected + ** sqlite3_value objects and they can be used interchangeably. However, + ** for maximum code portability it is recommended that applications + ** still make the distinction between protected and unprotected + ** sqlite3_value objects even when not strictly required. + ** + ** ^The sqlite3_value objects that are passed as parameters into the + ** implementation of [application-defined SQL functions] are protected. + ** ^The sqlite3_value object returned by + ** [sqlite3_column_value()] is unprotected. + ** Unprotected sqlite3_value objects may only be used with + ** [sqlite3_result_value()] and [sqlite3_bind_value()]. + ** The [sqlite3_value_blob | sqlite3_value_type()] family of + ** interfaces require protected sqlite3_value objects. + */ + //typedef struct Mem sqlite3_value; + + /* + ** CAPI3REF: SQL Function Context Object + ** + ** The context in which an SQL function executes is stored in an + ** sqlite3_context object. ^A pointer to an sqlite3_context object + ** is always first parameter to [application-defined SQL functions]. + ** The application-defined SQL function implementation will pass this + ** pointer through into calls to [sqlite3_result_int | sqlite3_result()], + ** [sqlite3_aggregate_context()], [sqlite3_user_data()], + ** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()], + ** and/or [sqlite3_set_auxdata()]. + */ + //typedef struct sqlite3_context sqlite3_context; + + /* + ** CAPI3REF: Binding Values To Prepared Statements + ** KEYWORDS: {host parameter} {host parameters} {host parameter name} + ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding} + ** + ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants, + ** literals may be replaced by a [parameter] that matches one of following + ** templates: + ** + **
    + **
  • ? + **
  • ?NNN + **
  • :VVV + **
  • @VVV + **
  • $VVV + **
+ ** + ** In the templates above, NNN represents an integer literal, + ** and VVV represents an alphanumeric identifier.)^ ^The values of these + ** parameters (also called "host parameter names" or "SQL parameters") + ** can be set using the sqlite3_bind_*() routines defined here. + ** + ** ^The first argument to the sqlite3_bind_*() routines is always + ** a pointer to the [sqlite3_stmt] object returned from + ** [sqlite3_prepare_v2()] or its variants. + ** + ** ^The second argument is the index of the SQL parameter to be set. + ** ^The leftmost SQL parameter has an index of 1. ^When the same named + ** SQL parameter is used more than once, second and subsequent + ** occurrences have the same index as the first occurrence. + ** ^The index for named parameters can be looked up using the + ** [sqlite3_bind_parameter_index()] API if desired. ^The index + ** for "?NNN" parameters is the value of NNN. + ** ^The NNN value must be between 1 and the [sqlite3_limit()] + ** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999). + ** + ** ^The third argument is the value to bind to the parameter. + ** + ** ^(In those routines that have a fourth argument, its value is the + ** number of bytes in the parameter. To be clear: the value is the + ** number of bytes in the value, not the number of characters.)^ + ** ^If the fourth parameter is negative, the length of the string is + ** the number of bytes up to the first zero terminator. + ** + ** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and + ** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or + ** string after SQLite has finished with it. ^The destructor is called + ** to dispose of the BLOB or string even if the call to sqlite3_bind_blob(), + ** sqlite3_bind_text(), or sqlite3_bind_text16() fails. + ** ^If the fifth argument is + ** the special value [SQLITE_STATIC], then SQLite assumes that the + ** information is in static, unmanaged space and does not need to be freed. + ** ^If the fifth argument has the value [SQLITE_TRANSIENT], then + ** SQLite makes its own private copy of the data immediately, before + ** the sqlite3_bind_*() routine returns. + ** + ** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that + ** is filled with zeroes. ^A zeroblob uses a fixed amount of memory + ** (just an integer to hold its size) while it is being processed. + ** Zeroblobs are intended to serve as placeholders for BLOBs whose + ** content is later written using + ** [sqlite3_blob_open | incremental BLOB I/O] routines. + ** ^A negative value for the zeroblob results in a zero-length BLOB. + ** + ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer + ** for the [prepared statement] or with a prepared statement for which + ** [sqlite3_step()] has been called more recently than [sqlite3_reset()], + ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() + ** routine is passed a [prepared statement] that has been finalized, the + ** result is undefined and probably harmful. + ** + ** ^Bindings are not cleared by the [sqlite3_reset()] routine. + ** ^Unbound parameters are interpreted as NULL. + ** + ** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an + ** [error code] if anything goes wrong. + ** ^[SQLITE_RANGE] is returned if the parameter + ** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails. + ** + ** See also: [sqlite3_bind_parameter_count()], + ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()]. + */ + //SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void()(void)); + //SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double); + //SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int); + //SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); + //SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int); + //SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void()(void)); + //SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void()(void)); + //SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value); + //SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); + + /* + ** CAPI3REF: Number Of SQL Parameters + ** + ** ^This routine can be used to find the number of [SQL parameters] + ** in a [prepared statement]. SQL parameters are tokens of the + ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as + ** placeholders for values that are [sqlite3_bind_blob | bound] + ** to the parameters at a later time. + ** + ** ^(This routine actually returns the index of the largest (rightmost) + ** parameter. For all forms except ?NNN, this will correspond to the + ** number of unique parameters. If parameters of the ?NNN form are used, + ** there may be gaps in the list.)^ + ** + ** See also: [sqlite3_bind_blob|sqlite3_bind()], + ** [sqlite3_bind_parameter_name()], and + ** [sqlite3_bind_parameter_index()]. + */ + //SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt); + + /* + ** CAPI3REF: Name Of A Host Parameter + ** + ** ^The sqlite3_bind_parameter_name(P,N) interface returns + ** the name of the N-th [SQL parameter] in the [prepared statement] P. + ** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA" + ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA" + ** respectively. + ** In other words, the initial ":" or "$" or "@" or "?" + ** is included as part of the name.)^ + ** ^Parameters of the form "?" without a following integer have no name + ** and are referred to as "nameless" or "anonymous parameters". + ** + ** ^The first host parameter has an index of 1, not 0. + ** + ** ^If the value N is out of range or if the N-th parameter is + ** nameless, then NULL is returned. ^The returned string is + ** always in UTF-8 encoding even if the named parameter was + ** originally specified as UTF-16 in [sqlite3_prepare16()] or + ** [sqlite3_prepare16_v2()]. + ** + ** See also: [sqlite3_bind_blob|sqlite3_bind()], + ** [sqlite3_bind_parameter_count()], and + ** [sqlite3_bind_parameter_index()]. + */ + //SQLITE_API string sqlite3_bind_parameter_name(sqlite3_stmt*, int); + + /* + ** CAPI3REF: Index Of A Parameter With A Given Name + ** + ** ^Return the index of an SQL parameter given its name. ^The + ** index value returned is suitable for use as the second + ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero + ** is returned if no matching parameter is found. ^The parameter + ** name must be given in UTF-8 even if the original statement + ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()]. + ** + ** See also: [sqlite3_bind_blob|sqlite3_bind()], + ** [sqlite3_bind_parameter_count()], and + ** [sqlite3_bind_parameter_index()]. + */ + //SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, string zName); + + /* + ** CAPI3REF: Reset All Bindings On A Prepared Statement + ** + ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset + ** the [sqlite3_bind_blob | bindings] on a [prepared statement]. + ** ^Use this routine to reset all host parameters to NULL. + */ + //SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt); + + /* + ** CAPI3REF: Number Of Columns In A Result Set + ** + ** ^Return the number of columns in the result set returned by the + ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL + ** statement that does not return data (for example an [UPDATE]). + ** + ** See also: [sqlite3_data_count()] + */ + //SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt); + + /* + ** CAPI3REF: Column Names In A Result Set + ** + ** ^These routines return the name assigned to a particular column + ** in the result set of a [SELECT] statement. ^The sqlite3_column_name() + ** interface returns a pointer to a zero-terminated UTF-8 string + ** and sqlite3_column_name16() returns a pointer to a zero-terminated + ** UTF-16 string. ^The first parameter is the [prepared statement] + ** that implements the [SELECT] statement. ^The second parameter is the + ** column number. ^The leftmost column is number 0. + ** + ** ^The returned string pointer is valid until either the [prepared statement] + ** is destroyed by [sqlite3_finalize()] or until the statement is automatically + ** reprepared by the first call to [sqlite3_step()] for a particular run + ** or until the next call to + ** sqlite3_column_name() or sqlite3_column_name16() on the same column. + ** + ** ^If sqlite3_malloc() fails during the processing of either routine + ** (for example during a conversion from UTF-8 to UTF-16) then a + ** NULL pointer is returned. + ** + ** ^The name of a result column is the value of the "AS" clause for + ** that column, if there is an AS clause. If there is no AS clause + ** then the name of the column is unspecified and may change from + ** one release of SQLite to the next. + */ + //SQLITE_API string sqlite3_column_name(sqlite3_stmt*, int N); + //SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N); + + /* + ** CAPI3REF: Source Of Data In A Query Result + ** + ** ^These routines provide a means to determine the database, table, and + ** table column that is the origin of a particular result column in + ** [SELECT] statement. + ** ^The name of the database or table or column can be returned as + ** either a UTF-8 or UTF-16 string. ^The _database_ routines return + ** the database name, the _table_ routines return the table name, and + ** the origin_ routines return the column name. + ** ^The returned string is valid until the [prepared statement] is destroyed + ** using [sqlite3_finalize()] or until the statement is automatically + ** reprepared by the first call to [sqlite3_step()] for a particular run + ** or until the same information is requested + ** again in a different encoding. + ** + ** ^The names returned are the original un-aliased names of the + ** database, table, and column. + ** + ** ^The first argument to these interfaces is a [prepared statement]. + ** ^These functions return information about the Nth result column returned by + ** the statement, where N is the second function argument. + ** ^The left-most column is column 0 for these routines. + ** + ** ^If the Nth column returned by the statement is an expression or + ** subquery and is not a column value, then all of these functions return + ** NULL. ^These routine might also return NULL if a memory allocation error + ** occurs. ^Otherwise, they return the name of the attached database, table, + ** or column that query result column was extracted from. + ** + ** ^As with all other SQLite APIs, those whose names end with "16" return + ** UTF-16 encoded strings and the other functions return UTF-8. + ** + ** ^These APIs are only available if the library was compiled with the + ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol. + ** + ** If two or more threads call one or more of these routines against the same + ** prepared statement and column at the same time then the results are + ** undefined. + ** + ** If two or more threads call one or more + ** [sqlite3_column_database_name | column metadata interfaces] + ** for the same [prepared statement] and result column + ** at the same time then the results are undefined. + */ + //SQLITE_API string sqlite3_column_database_name(sqlite3_stmt*,int); + //SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int); + //SQLITE_API string sqlite3_column_table_name(sqlite3_stmt*,int); + //SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int); + //SQLITE_API string sqlite3_column_origin_name(sqlite3_stmt*,int); + //SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int); + + /* + ** CAPI3REF: Declared Datatype Of A Query Result + ** + ** ^(The first parameter is a [prepared statement]. + ** If this statement is a [SELECT] statement and the Nth column of the + ** returned result set of that [SELECT] is a table column (not an + ** expression or subquery) then the declared type of the table + ** column is returned.)^ ^If the Nth column of the result set is an + ** expression or subquery, then a NULL pointer is returned. + ** ^The returned string is always UTF-8 encoded. + ** + ** ^(For example, given the database schema: + ** + ** CREATE TABLE t1(c1 VARIANT); + ** + ** and the following statement to be compiled: + ** + ** SELECT c1 + 1, c1 FROM t1; + ** + ** this routine would return the string "VARIANT" for the second result + ** column (i==1), and a NULL pointer for the first result column (i==0).)^ + ** + ** ^SQLite uses dynamic run-time typing. ^So just because a column + ** is declared to contain a particular type does not mean that the + ** data stored in that column is of the declared type. SQLite is + ** strongly typed, but the typing is dynamic not static. ^Type + ** is associated with individual values, not with the containers + ** used to hold those values. + */ + //SQLITE_API string sqlite3_column_decltype(sqlite3_stmt*,int); + //SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int); + + /* + ** CAPI3REF: Evaluate An SQL Statement + ** + ** After a [prepared statement] has been prepared using either + ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy + ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function + ** must be called one or more times to evaluate the statement. + ** + ** The details of the behavior of the sqlite3_step() interface depend + ** on whether the statement was prepared using the newer "v2" interface + ** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy + ** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the + ** new "v2" interface is recommended for new applications but the legacy + ** interface will continue to be supported. + ** + ** ^In the legacy interface, the return value will be either [SQLITE_BUSY], + ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE]. + ** ^With the "v2" interface, any of the other [result codes] or + ** [extended result codes] might be returned as well. + ** + ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the + ** database locks it needs to do its job. ^If the statement is a [COMMIT] + ** or occurs outside of an explicit transaction, then you can retry the + ** statement. If the statement is not a [COMMIT] and occurs within an + ** explicit transaction then you should rollback the transaction before + ** continuing. + ** + ** ^[SQLITE_DONE] means that the statement has finished executing + ** successfully. sqlite3_step() should not be called again on this virtual + ** machine without first calling [sqlite3_reset()] to reset the virtual + ** machine back to its initial state. + ** + ** ^If the SQL statement being executed returns any data, then [SQLITE_ROW] + ** is returned each time a new row of data is ready for processing by the + ** caller. The values may be accessed using the [column access functions]. + ** sqlite3_step() is called again to retrieve the next row of data. + ** + ** ^[SQLITE_ERROR] means that a run-time error (such as a constraint + ** violation) has occurred. sqlite3_step() should not be called again on + ** the VM. More information may be found by calling [sqlite3_errmsg()]. + ** ^With the legacy interface, a more specific error code (for example, + ** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth) + ** can be obtained by calling [sqlite3_reset()] on the + ** [prepared statement]. ^In the "v2" interface, + ** the more specific error code is returned directly by sqlite3_step(). + ** + ** [SQLITE_MISUSE] means that the this routine was called inappropriately. + ** Perhaps it was called on a [prepared statement] that has + ** already been [sqlite3_finalize | finalized] or on one that had + ** previously returned [SQLITE_ERROR] or [SQLITE_DONE]. Or it could + ** be the case that the same database connection is being used by two or + ** more threads at the same moment in time. + ** + ** For all versions of SQLite up to and including 3.6.23.1, a call to + ** [sqlite3_reset()] was required after sqlite3_step() returned anything + ** other than [SQLITE_ROW] before any subsequent invocation of + ** sqlite3_step(). Failure to reset the prepared statement using + ** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from + ** sqlite3_step(). But after version 3.6.23.1, sqlite3_step() began + ** calling [sqlite3_reset()] automatically in this circumstance rather + ** than returning [SQLITE_MISUSE]. This is not considered a compatibility + ** break because any application that ever receives an SQLITE_MISUSE error + ** is broken by definition. The [SQLITE_OMIT_AUTORESET] compile-time option + ** can be used to restore the legacy behavior. + ** + ** Goofy Interface Alert: In the legacy interface, the sqlite3_step() + ** API always returns a generic error code, [SQLITE_ERROR], following any + ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call + ** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the + ** specific [error codes] that better describes the error. + ** We admit that this is a goofy design. The problem has been fixed + ** with the "v2" interface. If you prepare all of your SQL statements + ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead + ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces, + ** then the more specific [error codes] are returned directly + ** by sqlite3_step(). The use of the "v2" interface is recommended. + */ + //SQLITE_API int sqlite3_step(sqlite3_stmt); + + /* + ** CAPI3REF: Number of columns in a result set + ** + ** ^The sqlite3_data_count(P) interface returns the number of columns in the + ** current row of the result set of [prepared statement] P. + ** ^If prepared statement P does not have results ready to return + ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of + ** interfaces) then sqlite3_data_count(P) returns 0. + ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer. + ** + ** See also: [sqlite3_column_count()] + */ + //SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); + + /* + ** CAPI3REF: Fundamental Datatypes + ** KEYWORDS: SQLITE_TEXT + ** + ** ^(Every value in SQLite has one of five fundamental datatypes: + ** + **
    + **
  • 64-bit signed integer + **
  • 64-bit IEEE floating point number + **
  • string + **
  • BLOB + **
  • NULL + **
)^ + ** + ** These constants are codes for each of those types. + ** + ** Note that the SQLITE_TEXT constant was also used in SQLite version 2 + ** for a completely different meaning. Software that links against both + ** SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, not + ** SQLITE_TEXT. + */ + //#define SQLITE_INTEGER 1 + //#define SQLITE_FLOAT 2 + //#define SQLITE_BLOB 4 + //#define SQLITE_NULL 5 + //#if SQLITE_TEXT + //# undef SQLITE_TEXT + //#else + //# define SQLITE_TEXT 3 + //#endif + //#define SQLITE3_TEXT 3 + public const u8 SQLITE_INTEGER = 1; + public const u8 SQLITE_FLOAT = 2; + public const u8 SQLITE_BLOB = 4; + public const u8 SQLITE_NULL = 5; + public const u8 SQLITE_TEXT = 3; + public const u8 SQLITE3_TEXT = 3; + + /* + ** CAPI3REF: Result Values From A Query + ** KEYWORDS: {column access functions} + ** + ** These routines form the "result set" interface. + ** + ** ^These routines return information about a single column of the current + ** result row of a query. ^In every case the first argument is a pointer + ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*] + ** that was returned from [sqlite3_prepare_v2()] or one of its variants) + ** and the second argument is the index of the column for which information + ** should be returned. ^The leftmost column of the result set has the index 0. + ** ^The number of columns in the result can be determined using + ** [sqlite3_column_count()]. + ** + ** If the SQL statement does not currently point to a valid row, or if the + ** column index is out of range, the result is undefined. + ** These routines may only be called when the most recent call to + ** [sqlite3_step()] has returned [SQLITE_ROW] and neither + ** [sqlite3_reset()] nor [sqlite3_finalize()] have been called subsequently. + ** If any of these routines are called after [sqlite3_reset()] or + ** [sqlite3_finalize()] or after [sqlite3_step()] has returned + ** something other than [SQLITE_ROW], the results are undefined. + ** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()] + ** are called from a different thread while any of these routines + ** are pending, then the results are undefined. + ** + ** ^The sqlite3_column_type() routine returns the + ** [SQLITE_INTEGER | datatype code] for the initial data type + ** of the result column. ^The returned value is one of [SQLITE_INTEGER], + ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value + ** returned by sqlite3_column_type() is only meaningful if no type + ** conversions have occurred as described below. After a type conversion, + ** the value returned by sqlite3_column_type() is undefined. Future + ** versions of SQLite may change the behavior of sqlite3_column_type() + ** following a type conversion. + ** + ** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes() + ** routine returns the number of bytes in that BLOB or string. + ** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts + ** the string to UTF-8 and then returns the number of bytes. + ** ^If the result is a numeric value then sqlite3_column_bytes() uses + ** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns + ** the number of bytes in that string. + ** ^If the result is NULL, then sqlite3_column_bytes() returns zero. + ** + ** ^If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16() + ** routine returns the number of bytes in that BLOB or string. + ** ^If the result is a UTF-8 string, then sqlite3_column_bytes16() converts + ** the string to UTF-16 and then returns the number of bytes. + ** ^If the result is a numeric value then sqlite3_column_bytes16() uses + ** [sqlite3_snprintf()] to convert that value to a UTF-16 string and returns + ** the number of bytes in that string. + ** ^If the result is NULL, then sqlite3_column_bytes16() returns zero. + ** + ** ^The values returned by [sqlite3_column_bytes()] and + ** [sqlite3_column_bytes16()] do not include the zero terminators at the end + ** of the string. ^For clarity: the values returned by + ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of + ** bytes in the string, not the number of characters. + ** + ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(), + ** even empty strings, are always zero terminated. ^The return + ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer. + ** + ** ^The object returned by [sqlite3_column_value()] is an + ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object + ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()]. + ** If the [unprotected sqlite3_value] object returned by + ** [sqlite3_column_value()] is used in any other way, including calls + ** to routines like [sqlite3_value_int()], [sqlite3_value_text()], + ** or [sqlite3_value_bytes()], then the behavior is undefined. + ** + ** These routines attempt to convert the value where appropriate. ^For + ** example, if the internal representation is FLOAT and a text result + ** is requested, [sqlite3_snprintf()] is used internally to perform the + ** conversion automatically. ^(The following table details the conversions + ** that are applied: + ** + **
+ ** + **
Internal
Type
Requested
Type
Conversion + ** + **
NULL INTEGER Result is 0 + **
NULL FLOAT Result is 0.0 + **
NULL TEXT Result is NULL pointer + **
NULL BLOB Result is NULL pointer + **
INTEGER FLOAT Convert from integer to float + **
INTEGER TEXT ASCII rendering of the integer + **
INTEGER BLOB Same as INTEGER->TEXT + **
FLOAT INTEGER Convert from float to integer + **
FLOAT TEXT ASCII rendering of the float + **
FLOAT BLOB Same as FLOAT->TEXT + **
TEXT INTEGER Use atoi() + **
TEXT FLOAT Use atof() + **
TEXT BLOB No change + **
BLOB INTEGER Convert to TEXT then use atoi() + **
BLOB FLOAT Convert to TEXT then use atof() + **
BLOB TEXT Add a zero terminator if needed + **
+ **
)^ + ** + ** The table above makes reference to standard C library functions atoi() + ** and atof(). SQLite does not really use these functions. It has its + ** own equivalent internal routines. The atoi() and atof() names are + ** used in the table for brevity and because they are familiar to most + ** C programmers. + ** + ** Note that when type conversions occur, pointers returned by prior + ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or + ** sqlite3_column_text16() may be invalidated. + ** Type conversions and pointer invalidations might occur + ** in the following cases: + ** + **
    + **
  • The initial content is a BLOB and sqlite3_column_text() or + ** sqlite3_column_text16() is called. A zero-terminator might + ** need to be added to the string.
  • + **
  • The initial content is UTF-8 text and sqlite3_column_bytes16() or + ** sqlite3_column_text16() is called. The content must be converted + ** to UTF-16.
  • + **
  • The initial content is UTF-16 text and sqlite3_column_bytes() or + ** sqlite3_column_text() is called. The content must be converted + ** to UTF-8.
  • + **
+ ** + ** ^Conversions between UTF-16be and UTF-16le are always done in place and do + ** not invalidate a prior pointer, though of course the content of the buffer + ** that the prior pointer references will have been modified. Other kinds + ** of conversion are done in place when it is possible, but sometimes they + ** are not possible and in those cases prior pointers are invalidated. + ** + ** The safest and easiest to remember policy is to invoke these routines + ** in one of the following ways: + ** + **
    + **
  • sqlite3_column_text() followed by sqlite3_column_bytes()
  • + **
  • sqlite3_column_blob() followed by sqlite3_column_bytes()
  • + **
  • sqlite3_column_text16() followed by sqlite3_column_bytes16()
  • + **
+ ** + ** In other words, you should call sqlite3_column_text(), + ** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result + ** into the desired format, then invoke sqlite3_column_bytes() or + ** sqlite3_column_bytes16() to find the size of the result. Do not mix calls + ** to sqlite3_column_text() or sqlite3_column_blob() with calls to + ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16() + ** with calls to sqlite3_column_bytes(). + ** + ** ^The pointers returned are valid until a type conversion occurs as + ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or + ** [sqlite3_finalize()] is called. ^The memory space used to hold strings + ** and BLOBs is freed automatically. Do not pass the pointers returned + ** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into + ** [sqlite3_free()]. + ** + ** ^(If a memory allocation error occurs during the evaluation of any + ** of these routines, a default value is returned. The default value + ** is either the integer 0, the floating point number 0.0, or a NULL + ** pointer. Subsequent calls to [sqlite3_errcode()] will return + ** [SQLITE_NOMEM].)^ + */ + //SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); + //SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol); + //SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol); + //SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol); + //SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol); + //SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol); + //SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol); + //SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol); + //SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol); + //SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol); + + /* + ** CAPI3REF: Destroy A Prepared Statement Object + ** + ** ^The sqlite3_finalize() function is called to delete a [prepared statement]. + ** ^If the most recent evaluation of the statement encountered no errors + ** or if the statement is never been evaluated, then sqlite3_finalize() returns + ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then + ** sqlite3_finalize(S) returns the appropriate [error code] or + ** [extended error code]. + ** + ** ^The sqlite3_finalize(S) routine can be called at any point during + ** the life cycle of [prepared statement] S: + ** before statement S is ever evaluated, after + ** one or more calls to [sqlite3_reset()], or after any call + ** to [sqlite3_step()] regardless of whether or not the statement has + ** completed execution. + ** + ** ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op. + ** + ** The application must finalize every [prepared statement] in order to avoid + ** resource leaks. It is a grievous error for the application to try to use + ** a prepared statement after it has been finalized. Any use of a prepared + ** statement after it has been finalized can result in undefined and + ** undesirable behavior such as segfaults and heap corruption. + */ + //SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt); + + /* + ** CAPI3REF: Reset A Prepared Statement Object + ** + ** The sqlite3_reset() function is called to reset a [prepared statement] + ** object back to its initial state, ready to be re-executed. + ** ^Any SQL statement variables that had values bound to them using + ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values. + ** Use [sqlite3_clear_bindings()] to reset the bindings. + ** + ** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S + ** back to the beginning of its program. + ** + ** ^If the most recent call to [sqlite3_step(S)] for the + ** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE], + ** or if [sqlite3_step(S)] has never before been called on S, + ** then [sqlite3_reset(S)] returns [SQLITE_OK]. + ** + ** ^If the most recent call to [sqlite3_step(S)] for the + ** [prepared statement] S indicated an error, then + ** [sqlite3_reset(S)] returns an appropriate [error code]. + ** + ** ^The [sqlite3_reset(S)] interface does not change the values + ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. + */ + //SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); + + /* + ** CAPI3REF: Create Or Redefine SQL Functions + ** KEYWORDS: {function creation routines} + ** KEYWORDS: {application-defined SQL function} + ** KEYWORDS: {application-defined SQL functions} + ** + ** ^These functions (collectively known as "function creation routines") + ** are used to add SQL functions or aggregates or to redefine the behavior + ** of existing SQL functions or aggregates. The only differences between + ** these routines are the text encoding expected for + ** the second parameter (the name of the function being created) + ** and the presence or absence of a destructor callback for + ** the application data pointer. + ** + ** ^The first parameter is the [database connection] to which the SQL + ** function is to be added. ^If an application uses more than one database + ** connection then application-defined SQL functions must be added + ** to each database connection separately. + ** + ** ^The second parameter is the name of the SQL function to be created or + ** redefined. ^The length of the name is limited to 255 bytes in a UTF-8 + ** representation, exclusive of the zero-terminator. ^Note that the name + ** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes. + ** ^Any attempt to create a function with a longer name + ** will result in [SQLITE_MISUSE] being returned. + ** + ** ^The third parameter (nArg) + ** is the number of arguments that the SQL function or + ** aggregate takes. ^If this parameter is -1, then the SQL function or + ** aggregate may take any number of arguments between 0 and the limit + ** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]). If the third + ** parameter is less than -1 or greater than 127 then the behavior is + ** undefined. + ** + ** ^The fourth parameter, eTextRep, specifies what + ** [SQLITE_UTF8 | text encoding] this SQL function prefers for + ** its parameters. Every SQL function implementation must be able to work + ** with UTF-8, UTF-16le, or UTF-16be. But some implementations may be + ** more efficient with one encoding than another. ^An application may + ** invoke sqlite3_create_function() or sqlite3_create_function16() multiple + ** times with the same function but with different values of eTextRep. + ** ^When multiple implementations of the same function are available, SQLite + ** will pick the one that involves the least amount of data conversion. + ** If there is only a single implementation which does not care what text + ** encoding is used, then the fourth argument should be [SQLITE_ANY]. + ** + ** ^(The fifth parameter is an arbitrary pointer. The implementation of the + ** function can gain access to this pointer using [sqlite3_user_data()].)^ + ** + ** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are + ** pointers to C-language functions that implement the SQL function or + ** aggregate. ^A scalar SQL function requires an implementation of the xFunc + ** callback only; NULL pointers must be passed as the xStep and xFinal + ** parameters. ^An aggregate SQL function requires an implementation of xStep + ** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing + ** SQL function or aggregate, pass NULL pointers for all three function + ** callbacks. + ** + ** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL, + ** then it is destructor for the application data pointer. + ** The destructor is invoked when the function is deleted, either by being + ** overloaded or when the database connection closes.)^ + ** ^The destructor is also invoked if the call to + ** sqlite3_create_function_v2() fails. + ** ^When the destructor callback of the tenth parameter is invoked, it + ** is passed a single argument which is a copy of the application data + ** pointer which was the fifth parameter to sqlite3_create_function_v2(). + ** + ** ^It is permitted to register multiple implementations of the same + ** functions with the same name but with either differing numbers of + ** arguments or differing preferred text encodings. ^SQLite will use + ** the implementation that most closely matches the way in which the + ** SQL function is used. ^A function implementation with a non-negative + ** nArg parameter is a better match than a function implementation with + ** a negative nArg. ^A function where the preferred text encoding + ** matches the database encoding is a better + ** match than a function where the encoding is different. + ** ^A function where the encoding difference is between UTF16le and UTF16be + ** is a closer match than a function where the encoding difference is + ** between UTF8 and UTF16. + ** + ** ^Built-in functions may be overloaded by new application-defined functions. + ** + ** ^An application-defined function is permitted to call other + ** SQLite interfaces. However, such calls must not + ** close the database connection nor finalize or reset the prepared + ** statement in which the function is running. + */ + //SQLITE_API int sqlite3_create_function( + // sqlite3 db, + // string zFunctionName, + // int nArg, + // int eTextRep, + // void *pApp, + // void (*xFunc)(sqlite3_context*,int,sqlite3_value*), + // void (*xStep)(sqlite3_context*,int,sqlite3_value*), + // void (*xFinal)(sqlite3_context) + //); + //SQLITE_API int sqlite3_create_function16( + // sqlite3 db, + // string zFunctionName, + // int nArg, + // int eTextRep, + // void *pApp, + // void (*xFunc)(sqlite3_context*,int,sqlite3_value*), + // void (*xStep)(sqlite3_context*,int,sqlite3_value*), + // void (*xFinal)(sqlite3_context) + //); + //SQLITE_API int sqlite3_create_function_v2( + // sqlite3 db, + // string zFunctionName, + // int nArg, + // int eTextRep, + // void *pApp, + // void (*xFunc)(sqlite3_context*,int,sqlite3_value*), + // void (*xStep)(sqlite3_context*,int,sqlite3_value*), + // void (*xFinal)(sqlite3_context), + // void(*xDestroy)(void) + //); + + /* + ** CAPI3REF: Text Encodings + ** + ** These constant define integer codes that represent the various + ** text encodings supported by SQLite. + */ + //#define SQLITE_UTF8 1 + //#define SQLITE_UTF16LE 2 + //#define SQLITE_UTF16BE 3 + //#define SQLITE_UTF16 4 /* Use native byte order */ + //#define SQLITE_ANY 5 /* sqlite3_create_function only */ + //#define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */ + public const u8 SQLITE_UTF8 = 1; + public const u8 SQLITE_UTF16LE = 2; + public const u8 SQLITE_UTF16BE = 3; + public const u8 SQLITE_UTF16 = 4; + public const u8 SQLITE_ANY = 5; + public const u8 SQLITE_UTF16_ALIGNED = 8; + + + /* + ** CAPI3REF: Deprecated Functions + ** DEPRECATED + ** + ** These functions are [deprecated]. In order to maintain + ** backwards compatibility with older code, these functions continue + ** to be supported. However, new applications should avoid + ** the use of these functions. To help encourage people to avoid + ** using these functions, we are not going to tell you what they do. + */ + //#if !SQLITE_OMIT_DEPRECATED + //SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context); + //SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt); + //SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt); + //SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void); + //SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); + //SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void()(void*,sqlite3_int64,int),void*,sqlite3_int64); + //#endif + + /* + ** CAPI3REF: Obtaining SQL Function Parameter Values + ** + ** The C-language implementation of SQL functions and aggregates uses + ** this set of interface routines to access the parameter values on + ** the function or aggregate. + ** + ** The xFunc (for scalar functions) or xStep (for aggregates) parameters + ** to [sqlite3_create_function()] and [sqlite3_create_function16()] + ** define callbacks that implement the SQL functions and aggregates. + ** The 3rd parameter to these callbacks is an array of pointers to + ** [protected sqlite3_value] objects. There is one [sqlite3_value] object for + ** each parameter to the SQL function. These routines are used to + ** extract values from the [sqlite3_value] objects. + ** + ** These routines work only with [protected sqlite3_value] objects. + ** Any attempt to use these routines on an [unprotected sqlite3_value] + ** object results in undefined behavior. + ** + ** ^These routines work just like the corresponding [column access functions] + ** except that these routines take a single [protected sqlite3_value] object + ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number. + ** + ** ^The sqlite3_value_text16() interface extracts a UTF-16 string + ** in the native byte-order of the host machine. ^The + ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces + ** extract UTF-16 strings as big-endian and little-endian respectively. + ** + ** ^(The sqlite3_value_numeric_type() interface attempts to apply + ** numeric affinity to the value. This means that an attempt is + ** made to convert the value to an integer or floating point. If + ** such a conversion is possible without loss of information (in other + ** words, if the value is a string that looks like a number) + ** then the conversion is performed. Otherwise no conversion occurs. + ** The [SQLITE_INTEGER | datatype] after conversion is returned.)^ + ** + ** Please pay particular attention to the fact that the pointer returned + ** from [sqlite3_value_blob()], [sqlite3_value_text()], or + ** [sqlite3_value_text16()] can be invalidated by a subsequent call to + ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()], + ** or [sqlite3_value_text16()]. + ** + ** These routines must be called from the same thread as + ** the SQL function that supplied the [sqlite3_value*] parameters. + */ + //SQLITE_API const void *sqlite3_value_blob(sqlite3_value); + //SQLITE_API int sqlite3_value_bytes(sqlite3_value); + //SQLITE_API int sqlite3_value_bytes16(sqlite3_value); + //SQLITE_API double sqlite3_value_double(sqlite3_value); + //SQLITE_API int sqlite3_value_int(sqlite3_value); + //SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value); + //SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value); + //SQLITE_API const void *sqlite3_value_text16(sqlite3_value); + //SQLITE_API const void *sqlite3_value_text16le(sqlite3_value); + //SQLITE_API const void *sqlite3_value_text16be(sqlite3_value); + //SQLITE_API int sqlite3_value_type(sqlite3_value); + //SQLITE_API int sqlite3_value_numeric_type(sqlite3_value); + + /* + ** CAPI3REF: Obtain Aggregate Function Context + ** + ** Implementations of aggregate SQL functions use this + ** routine to allocate memory for storing their state. + ** + ** ^The first time the sqlite3_aggregate_context(C,N) routine is called + ** for a particular aggregate function, SQLite + ** allocates N of memory, zeroes out that memory, and returns a pointer + ** to the new memory. ^On second and subsequent calls to + ** sqlite3_aggregate_context() for the same aggregate function instance, + ** the same buffer is returned. Sqlite3_aggregate_context() is normally + ** called once for each invocation of the xStep callback and then one + ** last time when the xFinal callback is invoked. ^(When no rows match + ** an aggregate query, the xStep() callback of the aggregate function + ** implementation is never called and xFinal() is called exactly once. + ** In those cases, sqlite3_aggregate_context() might be called for the + ** first time from within xFinal().)^ + ** + ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is + ** less than or equal to zero or if a memory allocate error occurs. + ** + ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is + ** determined by the N parameter on first successful call. Changing the + ** value of N in subsequent call to sqlite3_aggregate_context() within + ** the same aggregate function instance will not resize the memory + ** allocation.)^ + ** + ** ^SQLite automatically frees the memory allocated by + ** sqlite3_aggregate_context() when the aggregate query concludes. + ** + ** The first parameter must be a copy of the + ** [sqlite3_context | SQL function context] that is the first parameter + ** to the xStep or xFinal callback routine that implements the aggregate + ** function. + ** + ** This routine must be called from the same thread in which + ** the aggregate SQL function is running. + */ + //SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes); + + /* + ** CAPI3REF: User Data For Functions + ** + ** ^The sqlite3_user_data() interface returns a copy of + ** the pointer that was the pUserData parameter (the 5th parameter) + ** of the [sqlite3_create_function()] + ** and [sqlite3_create_function16()] routines that originally + ** registered the application defined function. + ** + ** This routine must be called from the same thread in which + ** the application-defined function is running. + */ + //SQLITE_API void *sqlite3_user_data(sqlite3_context); + + /* + ** CAPI3REF: Database Connection For Functions + ** + ** ^The sqlite3_context_db_handle() interface returns a copy of + ** the pointer to the [database connection] (the 1st parameter) + ** of the [sqlite3_create_function()] + ** and [sqlite3_create_function16()] routines that originally + ** registered the application defined function. + */ + //SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context); + + /* + ** CAPI3REF: Function Auxiliary Data + ** + ** The following two functions may be used by scalar SQL functions to + ** associate metadata with argument values. If the same value is passed to + ** multiple invocations of the same SQL function during query execution, under + ** some circumstances the associated metadata may be preserved. This may + ** be used, for example, to add a regular-expression matching scalar + ** function. The compiled version of the regular expression is stored as + ** metadata associated with the SQL value passed as the regular expression + ** pattern. The compiled regular expression can be reused on multiple + ** invocations of the same function so that the original pattern string + ** does not need to be recompiled on each invocation. + ** + ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata + ** associated by the sqlite3_set_auxdata() function with the Nth argument + ** value to the application-defined function. ^If no metadata has been ever + ** been set for the Nth argument of the function, or if the corresponding + ** function parameter has changed since the meta-data was set, + ** then sqlite3_get_auxdata() returns a NULL pointer. + ** + ** ^The sqlite3_set_auxdata() interface saves the metadata + ** pointed to by its 3rd parameter as the metadata for the N-th + ** argument of the application-defined function. Subsequent + ** calls to sqlite3_get_auxdata() might return this data, if it has + ** not been destroyed. + ** ^If it is not NULL, SQLite will invoke the destructor + ** function given by the 4th parameter to sqlite3_set_auxdata() on + ** the metadata when the corresponding function parameter changes + ** or when the SQL statement completes, whichever comes first. + ** + ** SQLite is free to call the destructor and drop metadata on any + ** parameter of any function at any time. ^The only guarantee is that + ** the destructor will be called before the metadata is dropped. + ** + ** ^(In practice, metadata is preserved between function calls for + ** expressions that are constant at compile time. This includes literal + ** values and [parameters].)^ + ** + ** These routines must be called from the same thread in which + ** the SQL function is running. + */ + //SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); + //SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, object ()(void)); + + + /* + ** CAPI3REF: Constants Defining Special Destructor Behavior + ** + ** These are special values for the destructor that is passed in as the + ** final argument to routines like [sqlite3_result_blob()]. ^If the destructor + ** argument is SQLITE_STATIC, it means that the content pointer is constant + ** and will never change. It does not need to be destroyed. ^The + ** SQLITE_TRANSIENT value means that the content will likely change in + ** the near future and that SQLite should make its own private copy of + ** the content before returning. + ** + ** The typedef is necessary to work around problems in certain + ** C++ compilers. See ticket #2191. + */ + //typedef void (*sqlite3_destructor_type)(void); + //#define SQLITE_STATIC ((sqlite3_destructor_type)0) + //#define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1) + static public dxDel SQLITE_STATIC; + static public dxDel SQLITE_TRANSIENT; + /* + ** CAPI3REF: Setting The Result Of An SQL Function + ** + ** These routines are used by the xFunc or xFinal callbacks that + ** implement SQL functions and aggregates. See + ** [sqlite3_create_function()] and [sqlite3_create_function16()] + ** for additional information. + ** + ** These functions work very much like the [parameter binding] family of + ** functions used to bind values to host parameters in prepared statements. + ** Refer to the [SQL parameter] documentation for additional information. + ** + ** ^The sqlite3_result_blob() interface sets the result from + ** an application-defined function to be the BLOB whose content is pointed + ** to by the second parameter and which is N bytes long where N is the + ** third parameter. + ** + ** ^The sqlite3_result_zeroblob() interfaces set the result of + ** the application-defined function to be a BLOB containing all zero + ** bytes and N bytes in size, where N is the value of the 2nd parameter. + ** + ** ^The sqlite3_result_double() interface sets the result from + ** an application-defined function to be a floating point value specified + ** by its 2nd argument. + ** + ** ^The sqlite3_result_error() and sqlite3_result_error16() functions + ** cause the implemented SQL function to throw an exception. + ** ^SQLite uses the string pointed to by the + ** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16() + ** as the text of an error message. ^SQLite interprets the error + ** message string from sqlite3_result_error() as UTF-8. ^SQLite + ** interprets the string from sqlite3_result_error16() as UTF-16 in native + ** byte order. ^If the third parameter to sqlite3_result_error() + ** or sqlite3_result_error16() is negative then SQLite takes as the error + ** message all text up through the first zero character. + ** ^If the third parameter to sqlite3_result_error() or + ** sqlite3_result_error16() is non-negative then SQLite takes that many + ** bytes (not characters) from the 2nd parameter as the error message. + ** ^The sqlite3_result_error() and sqlite3_result_error16() + ** routines make a private copy of the error message text before + ** they return. Hence, the calling function can deallocate or + ** modify the text after they return without harm. + ** ^The sqlite3_result_error_code() function changes the error code + ** returned by SQLite as a result of an error in a function. ^By default, + ** the error code is SQLITE_ERROR. ^A subsequent call to sqlite3_result_error() + ** or sqlite3_result_error16() resets the error code to SQLITE_ERROR. + ** + ** ^The sqlite3_result_toobig() interface causes SQLite to throw an error + ** indicating that a string or BLOB is too long to represent. + ** + ** ^The sqlite3_result_nomem() interface causes SQLite to throw an error + ** indicating that a memory allocation failed. + ** + ** ^The sqlite3_result_int() interface sets the return value + ** of the application-defined function to be the 32-bit signed integer + ** value given in the 2nd argument. + ** ^The sqlite3_result_int64() interface sets the return value + ** of the application-defined function to be the 64-bit signed integer + ** value given in the 2nd argument. + ** + ** ^The sqlite3_result_null() interface sets the return value + ** of the application-defined function to be NULL. + ** + ** ^The sqlite3_result_text(), sqlite3_result_text16(), + ** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces + ** set the return value of the application-defined function to be + ** a text string which is represented as UTF-8, UTF-16 native byte order, + ** UTF-16 little endian, or UTF-16 big endian, respectively. + ** ^SQLite takes the text result from the application from + ** the 2nd parameter of the sqlite3_result_text* interfaces. + ** ^If the 3rd parameter to the sqlite3_result_text* interfaces + ** is negative, then SQLite takes result text from the 2nd parameter + ** through the first zero character. + ** ^If the 3rd parameter to the sqlite3_result_text* interfaces + ** is non-negative, then as many bytes (not characters) of the text + ** pointed to by the 2nd parameter are taken as the application-defined + ** function result. + ** ^If the 4th parameter to the sqlite3_result_text* interfaces + ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that + ** function as the destructor on the text or BLOB result when it has + ** finished using that result. + ** ^If the 4th parameter to the sqlite3_result_text* interfaces or to + ** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite + ** assumes that the text or BLOB result is in constant space and does not + ** copy the content of the parameter nor call a destructor on the content + ** when it has finished using that result. + ** ^If the 4th parameter to the sqlite3_result_text* interfaces + ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT + ** then SQLite makes a copy of the result into space obtained from + ** from [sqlite3_malloc()] before it returns. + ** + ** ^The sqlite3_result_value() interface sets the result of + ** the application-defined function to be a copy the + ** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The + ** sqlite3_result_value() interface makes a copy of the [sqlite3_value] + ** so that the [sqlite3_value] specified in the parameter may change or + ** be deallocated after sqlite3_result_value() returns without harm. + ** ^A [protected sqlite3_value] object may always be used where an + ** [unprotected sqlite3_value] object is required, so either + ** kind of [sqlite3_value] object can be used with this interface. + ** + ** If these routines are called from within the different thread + ** than the one containing the application-defined function that received + ** the [sqlite3_context] pointer, the results are undefined. + */ + //SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void()(void)); + //SQLITE_API void sqlite3_result_double(sqlite3_context*, double); + //SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int); + //SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int); + //SQLITE_API void sqlite3_result_error_toobig(sqlite3_context); + //SQLITE_API void sqlite3_result_error_nomem(sqlite3_context); + //SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int); + //SQLITE_API void sqlite3_result_int(sqlite3_context*, int); + //SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64); + //SQLITE_API void sqlite3_result_null(sqlite3_context); + //SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void()(void)); + //SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void()(void)); + //SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void()(void)); + //SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void()(void)); + //SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value); + //SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); + + /* + ** CAPI3REF: Define New Collating Sequences + ** + ** ^These functions add, remove, or modify a [collation] associated + ** with the [database connection] specified as the first argument. + ** + ** ^The name of the collation is a UTF-8 string + ** for sqlite3_create_collation() and sqlite3_create_collation_v2() + ** and a UTF-16 string in native byte order for sqlite3_create_collation16(). + ** ^Collation names that compare equal according to [sqlite3_strnicmp()] are + ** considered to be the same name. + ** + ** ^(The third argument (eTextRep) must be one of the constants: + **
    + **
  • [SQLITE_UTF8], + **
  • [SQLITE_UTF16LE], + **
  • [SQLITE_UTF16BE], + **
  • [SQLITE_UTF16], or + **
  • [SQLITE_UTF16_ALIGNED]. + **
)^ + ** ^The eTextRep argument determines the encoding of strings passed + ** to the collating function callback, xCallback. + ** ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep + ** force strings to be UTF16 with native byte order. + ** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin + ** on an even byte address. + ** + ** ^The fourth argument, pArg, is an application data pointer that is passed + ** through as the first argument to the collating function callback. + ** + ** ^The fifth argument, xCallback, is a pointer to the collating function. + ** ^Multiple collating functions can be registered using the same name but + ** with different eTextRep parameters and SQLite will use whichever + ** function requires the least amount of data transformation. + ** ^If the xCallback argument is NULL then the collating function is + ** deleted. ^When all collating functions having the same name are deleted, + ** that collation is no longer usable. + ** + ** ^The collating function callback is invoked with a copy of the pArg + ** application data pointer and with two strings in the encoding specified + ** by the eTextRep argument. The collating function must return an + ** integer that is negative, zero, or positive + ** if the first string is less than, equal to, or greater than the second, + ** respectively. A collating function must always return the same answer + ** given the same inputs. If two or more collating functions are registered + ** to the same collation name (using different eTextRep values) then all + ** must give an equivalent answer when invoked with equivalent strings. + ** The collating function must obey the following properties for all + ** strings A, B, and C: + ** + **
    + **
  1. If A==B then B==A. + **
  2. If A==B and B==C then A==C. + **
  3. If A<B THEN B>A. + **
  4. If A<B and B<C then A<C. + **
+ ** + ** If a collating function fails any of the above constraints and that + ** collating function is registered and used, then the behavior of SQLite + ** is undefined. + ** + ** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation() + ** with the addition that the xDestroy callback is invoked on pArg when + ** the collating function is deleted. + ** ^Collating functions are deleted when they are overridden by later + ** calls to the collation creation functions or when the + ** [database connection] is closed using [sqlite3_close()]. + ** + ** ^The xDestroy callback is not called if the + ** sqlite3_create_collation_v2() function fails. Applications that invoke + ** sqlite3_create_collation_v2() with a non-NULL xDestroy argument should + ** check the return code and dispose of the application data pointer + ** themselves rather than expecting SQLite to deal with it for them. + ** This is different from every other SQLite interface. The inconsistency + ** is unfortunate but cannot be changed without breaking backwards + ** compatibility. + ** + ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()]. + */ + //SQLITE_API int sqlite3_create_collation( + // sqlite3*, + // string zName, + // int eTextRep, + // void *pArg, + // int(*xCompare)(void*,int,const void*,int,const void) + //); + //SQLITE_API int sqlite3_create_collation_v2( + // sqlite3*, + // string zName, + // int eTextRep, + // void *pArg, + // int(*xCompare)(void*,int,const void*,int,const void), + // void(*xDestroy)(void) + //); + //SQLITE_API int sqlite3_create_collation16( + // sqlite3*, + // string zName, + // int eTextRep, + // void *pArg, + // int(*xCompare)(void*,int,const void*,int,const void) + //); + + /* + ** CAPI3REF: Collation Needed Callbacks + ** + ** ^To avoid having to register all collation sequences before a database + ** can be used, a single callback function may be registered with the + ** [database connection] to be invoked whenever an undefined collation + ** sequence is required. + ** + ** ^If the function is registered using the sqlite3_collation_needed() API, + ** then it is passed the names of undefined collation sequences as strings + ** encoded in UTF-8. ^If sqlite3_collation_needed16() is used, + ** the names are passed as UTF-16 in machine native byte order. + ** ^A call to either function replaces the existing collation-needed callback. + ** + ** ^(When the callback is invoked, the first argument passed is a copy + ** of the second argument to sqlite3_collation_needed() or + ** sqlite3_collation_needed16(). The second argument is the database + ** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE], + ** or [SQLITE_UTF16LE], indicating the most desirable form of the collation + ** sequence function required. The fourth parameter is the name of the + ** required collation sequence.)^ + ** + ** The callback function should register the desired collation using + ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or + ** [sqlite3_create_collation_v2()]. + */ + //SQLITE_API int sqlite3_collation_needed( + // sqlite3*, + // void*, + // void()(void*,sqlite3*,int eTextRep,const char) + //); + //SQLITE_API int sqlite3_collation_needed16( + // sqlite3*, + // void*, + // void()(void*,sqlite3*,int eTextRep,const void) + //); + + //#if SQLITE_HAS_CODEC + /* + ** Specify the key for an encrypted database. This routine should be + ** called right after sqlite3_open(). + ** + ** The code to implement this API is not available in the public release + ** of SQLite. + */ + //SQLITE_API int sqlite3_key( + // sqlite3 db, /* Database to be rekeyed */ + // const void *pKey, int nKey /* The key */ + //); + + /* + ** Change the key on an open database. If the current database is not + ** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the + ** database is decrypted. + ** + ** The code to implement this API is not available in the public release + ** of SQLite. + */ + //SQLITE_API int sqlite3_rekey( + // sqlite3 db, /* Database to be rekeyed */ + // const void *pKey, int nKey /* The new key */ + //); + + /* + ** Specify the activation key for a SEE database. Unless + ** activated, none of the SEE routines will work. + */ + //SQLITE_API void sqlite3_activate_see( + // string zPassPhrase /* Activation phrase */ + //); + //#endif + + //#if SQLITE_ENABLE_CEROD + /* + ** Specify the activation key for a CEROD database. Unless + ** activated, none of the CEROD routines will work. + */ + //SQLITE_API void sqlite3_activate_cerod( + // string zPassPhrase /* Activation phrase */ + //); + //#endif + + /* + ** CAPI3REF: Suspend Execution For A Short Time + ** + ** The sqlite3_sleep() function causes the current thread to suspend execution + ** for at least a number of milliseconds specified in its parameter. + ** + ** If the operating system does not support sleep requests with + ** millisecond time resolution, then the time will be rounded up to + ** the nearest second. The number of milliseconds of sleep actually + ** requested from the operating system is returned. + ** + ** ^SQLite implements this interface by calling the xSleep() + ** method of the default [sqlite3_vfs] object. If the xSleep() method + ** of the default VFS is not implemented correctly, or not implemented at + ** all, then the behavior of sqlite3_sleep() may deviate from the description + ** in the previous paragraphs. + */ + //SQLITE_API int sqlite3_sleep(int); + + /* + ** CAPI3REF: Name Of The Folder Holding Temporary Files + ** + ** ^(If this global variable is made to point to a string which is + ** the name of a folder (a.k.a. directory), then all temporary files + ** created by SQLite when using a built-in [sqlite3_vfs | VFS] + ** will be placed in that directory.)^ ^If this variable + ** is a NULL pointer, then SQLite performs a search for an appropriate + ** temporary file directory. + ** + ** It is not safe to read or modify this variable in more than one + ** thread at a time. It is not safe to read or modify this variable + ** if a [database connection] is being used at the same time in a separate + ** thread. + ** It is intended that this variable be set once + ** as part of process initialization and before any SQLite interface + ** routines have been called and that this variable remain unchanged + ** thereafter. + ** + ** ^The [temp_store_directory pragma] may modify this variable and cause + ** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, + ** the [temp_store_directory pragma] always assumes that any string + ** that this variable points to is held in memory obtained from + ** [sqlite3_malloc] and the pragma may attempt to free that memory + ** using [sqlite3_free]. + ** Hence, if this variable is modified directly, either it should be + ** made NULL or made to point to memory obtained from [sqlite3_malloc] + ** or else the use of the [temp_store_directory pragma] should be avoided. + */ + //SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory; + + /* + ** CAPI3REF: Test For Auto-Commit Mode + ** KEYWORDS: {autocommit mode} + ** + ** ^The sqlite3_get_autocommit() interface returns non-zero or + ** zero if the given database connection is or is not in autocommit mode, + ** respectively. ^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 certain kinds of errors occur on a statement within a multi-statement + ** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR], + ** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the + ** transaction might be rolled back automatically. The only way to + ** find out whether SQLite automatically rolled back the transaction after + ** an error is to use this function. + ** + ** If another thread changes the autocommit status of the database + ** connection while this routine is running, then the return value + ** is undefined. + */ + //SQLITE_API int sqlite3_get_autocommit(sqlite3); + + /* + ** CAPI3REF: Find The Database Handle Of A Prepared Statement + ** + ** ^The sqlite3_db_handle interface returns the [database connection] handle + ** to which a [prepared statement] belongs. ^The [database connection] + ** returned by sqlite3_db_handle is the same [database connection] + ** that was the first argument + ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to + ** create the statement in the first place. + */ + //SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt); + + /* + ** CAPI3REF: Find the next prepared statement + ** + ** ^This interface returns a pointer to the next [prepared statement] after + ** pStmt associated with the [database connection] pDb. ^If pStmt is NULL + ** then this interface returns a pointer to the first prepared statement + ** associated with the database connection pDb. ^If no prepared statement + ** satisfies the conditions of this routine, it returns NULL. + ** + ** The [database connection] pointer D in a call to + ** [sqlite3_next_stmt(D,S)] must refer to an open database + ** connection and in particular must not be a NULL pointer. + */ + //SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); + + /* + ** CAPI3REF: Commit And Rollback Notification Callbacks + ** + ** ^The sqlite3_commit_hook() interface registers a callback + ** function to be invoked whenever a transaction is [COMMIT | committed]. + ** ^Any callback set by a previous call to sqlite3_commit_hook() + ** for the same database connection is overridden. + ** ^The sqlite3_rollback_hook() interface registers a callback + ** function to be invoked whenever a transaction is [ROLLBACK | rolled back]. + ** ^Any callback set by a previous call to sqlite3_rollback_hook() + ** for the same database connection is overridden. + ** ^The pArg argument is passed through to the callback. + ** ^If the callback on a commit hook function returns non-zero, + ** then the commit is converted into a rollback. + ** + ** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions + ** return the P argument from the previous call of the same function + ** on the same [database connection] D, or NULL for + ** the first call for each function on D. + ** + ** The callback implementation must not do anything that will modify + ** the database connection that invoked the callback. Any actions + ** to modify the database connection must be deferred until after the + ** completion of the [sqlite3_step()] call that triggered the commit + ** or rollback hook in the first place. + ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their + ** database connections for the meaning of "modify" in this paragraph. + ** + ** ^Registering a NULL function disables the callback. + ** + ** ^When the commit hook callback routine returns zero, the [COMMIT] + ** operation is allowed to continue normally. ^If the commit hook + ** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK]. + ** ^The rollback hook is invoked on a rollback that results from a commit + ** hook returning non-zero, just as it would be with any other rollback. + ** + ** ^For the purposes of this API, a transaction is said to have been + ** rolled back if an explicit "ROLLBACK" statement is executed, or + ** an error or constraint causes an implicit rollback to occur. + ** ^The rollback callback is not invoked if a transaction is + ** automatically rolled back because the database connection is closed. + ** + ** See also the [sqlite3_update_hook()] interface. + */ + //SQLITE_API void *sqlite3_commit_hook(sqlite3*, int()(void), void); + //SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void()(void ), void); + + /* + ** CAPI3REF: Data Change Notification Callbacks + ** + ** ^The sqlite3_update_hook() interface registers a callback function + ** with the [database connection] identified by the first argument + ** to be invoked whenever a row is updated, inserted or deleted. + ** ^Any callback set by a previous call to this function + ** for the same database connection is overridden. + ** + ** ^The second argument is a pointer to the function to invoke when a + ** row is updated, inserted or deleted. + ** ^The first argument to the callback is a copy of the third argument + ** to sqlite3_update_hook(). + ** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE], + ** or [SQLITE_UPDATE], depending on the operation that caused the callback + ** to be invoked. + ** ^The third and fourth arguments to the callback contain pointers to the + ** database and table name containing the affected row. + ** ^The final callback parameter is the [rowid] of the row. + ** ^In the case of an update, this is the [rowid] after the update takes place. + ** + ** ^(The update hook is not invoked when internal system tables are + ** modified (i.e. sqlite_master and sqlite_sequence).)^ + ** + ** ^In the current implementation, the update hook + ** is not invoked when duplication rows are deleted because of an + ** [ON CONFLICT | ON CONFLICT REPLACE] clause. ^Nor is the update hook + ** invoked when rows are deleted using the [truncate optimization]. + ** The exceptions defined in this paragraph might change in a future + ** release of SQLite. + ** + ** The update hook implementation must not do anything that will modify + ** the database connection that invoked the update hook. Any actions + ** to modify the database connection must be deferred until after the + ** completion of the [sqlite3_step()] call that triggered the update hook. + ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their + ** database connections for the meaning of "modify" in this paragraph. + ** + ** ^The sqlite3_update_hook(D,C,P) function + ** returns the P argument from the previous call + ** on the same [database connection] D, or NULL for + ** the first call on D. + ** + ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()] + ** interfaces. + */ + //SQLITE_API void *sqlite3_update_hook( + // sqlite3*, + // void()(void *,int ,char const *,char const *,sqlite3_int64), + // void* + //); + + /* + ** CAPI3REF: Enable Or Disable Shared Pager Cache + ** KEYWORDS: {shared cache} + ** + ** ^(This routine enables or disables the sharing of the database cache + ** and schema data structures between [database connection | connections] + ** to the same database. Sharing is enabled if the argument is true + ** and disabled if the argument is false.)^ + ** + ** ^Cache sharing is enabled and disabled for an entire process. + ** This is a change as of SQLite version 3.5.0. In prior versions of SQLite, + ** sharing was enabled or disabled for each thread separately. + ** + ** ^(The cache sharing mode set by this interface effects all subsequent + ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()]. + ** Existing database connections continue use the sharing mode + ** that was in effect at the time they were opened.)^ + ** + ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled + ** successfully. An [error code] is returned otherwise.)^ + ** + ** ^Shared cache is disabled by default. But this might change in + ** future releases of SQLite. Applications that care about shared + ** cache setting should set it explicitly. + ** + ** See Also: [SQLite Shared-Cache Mode] + */ + //SQLITE_API int sqlite3_enable_shared_cache(int); + + /* + ** CAPI3REF: Attempt To Free Heap Memory + ** + ** ^The sqlite3_release_memory() interface attempts to free N bytes + ** of heap memory by deallocating non-essential memory allocations + ** held by the database library. Memory used to cache database + ** pages to improve performance is an example of non-essential memory. + ** ^sqlite3_release_memory() returns the number of bytes actually freed, + ** which might be more or less than the amount requested. + ** ^The sqlite3_release_memory() routine is a no-op returning zero + ** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT]. + */ + //SQLITE_API int sqlite3_release_memory(int); + + /* + ** CAPI3REF: Impose A Limit On Heap Size + ** + ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the + ** soft limit on the amount of heap memory that may be allocated by SQLite. + ** ^SQLite strives to keep heap memory utilization below the soft heap + ** limit by reducing the number of pages held in the page cache + ** as heap memory usages approaches the limit. + ** ^The soft heap limit is "soft" because even though SQLite strives to stay + ** below the limit, it will exceed the limit rather than generate + ** an [SQLITE_NOMEM] error. In other words, the soft heap limit + ** is advisory only. + ** + ** ^The return value from sqlite3_soft_heap_limit64() is the size of + ** the soft heap limit prior to the call. ^If the argument N is negative + ** then no change is made to the soft heap limit. Hence, the current + ** size of the soft heap limit can be determined by invoking + ** sqlite3_soft_heap_limit64() with a negative argument. + ** + ** ^If the argument N is zero then the soft heap limit is disabled. + ** + ** ^(The soft heap limit is not enforced in the current implementation + ** if one or more of following conditions are true: + ** + **
    + **
  • The soft heap limit is set to zero. + **
  • Memory accounting is disabled using a combination of the + ** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and + ** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option. + **
  • An alternative page cache implementation is specified using + ** [sqlite3_config]([SQLITE_CONFIG_PCACHE],...). + **
  • The page cache allocates from its own memory pool supplied + ** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than + ** from the heap. + **
)^ + ** + ** Beginning with SQLite version 3.7.3, the soft heap limit is enforced + ** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT] + ** compile-time option is invoked. With [SQLITE_ENABLE_MEMORY_MANAGEMENT], + ** the soft heap limit is enforced on every memory allocation. Without + ** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced + ** when memory is allocated by the page cache. Testing suggests that because + ** the page cache is the predominate memory user in SQLite, most + ** applications will achieve adequate soft heap limit enforcement without + ** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT]. + ** + ** The circumstances under which SQLite will enforce the soft heap limit may + ** changes in future releases of SQLite. + */ + //SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N); + + /* + ** CAPI3REF: Deprecated Soft Heap Limit Interface + ** DEPRECATED + ** + ** This is a deprecated version of the [sqlite3_soft_heap_limit64()] + ** interface. This routine is provided for historical compatibility + ** only. All new applications should use the + ** [sqlite3_soft_heap_limit64()] interface rather than this one. + */ + //SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N); + + + /* + ** CAPI3REF: Extract Metadata About A Column Of A Table + ** + ** ^This routine returns metadata about a specific column of a specific + ** database table accessible using the [database connection] handle + ** passed as the first function argument. + ** + ** ^The column is identified by the second, third and fourth parameters to + ** this function. ^The second parameter is either the name of the database + ** (i.e. "main", "temp", or an attached database) containing the specified + ** table or NULL. ^If it is NULL, then all attached databases are searched + ** for the table using the same algorithm used by the database engine to + ** resolve unqualified table references. + ** + ** ^The third and fourth parameters to this function are the table and column + ** name of the desired column, respectively. Neither of these parameters + ** may be NULL. + ** + ** ^Metadata is returned by writing to the memory locations passed as the 5th + ** and subsequent parameters to this function. ^Any of these arguments may be + ** NULL, in which case the corresponding element of metadata is omitted. + ** + ** ^(
+ ** + **
Parameter Output
Type
Description + ** + **
5th const char* Data type + **
6th const char* Name of default collation sequence + **
7th int True if column has a NOT NULL constraint + **
8th int True if column is part of the PRIMARY KEY + **
9th int True if column is [AUTOINCREMENT] + **
+ **
)^ + ** + ** ^The memory pointed to by the character pointers returned for the + ** declaration type and collation sequence is valid only until the next + ** call to any SQLite API function. + ** + ** ^If the specified table is actually a view, an [error code] is returned. + ** + ** ^If the specified column is "rowid", "oid" or "_rowid_" and an + ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output + ** parameters are set for the explicitly declared column. ^(If there is no + ** explicitly declared [INTEGER PRIMARY KEY] column, then the output + ** parameters are set as follows: + ** + **
+    **     data type: "INTEGER"
+    **     collation sequence: "BINARY"
+    **     not null: 0
+    **     primary key: 1
+    **     auto increment: 0
+    ** 
)^ + ** + ** ^(This function may load one or more schemas from database files. If an + ** error occurs during this process, or if the requested table or column + ** cannot be found, an [error code] is returned and an error message left + ** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^ + ** + ** ^This API is only available if the library was compiled with the + ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined. + */ + //SQLITE_API int sqlite3_table_column_metadata( + // sqlite3 db, /* Connection handle */ + // string zDbName, /* Database name or NULL */ + // string zTableName, /* Table name */ + // string zColumnName, /* Column name */ + // char const **pzDataType, /* OUTPUT: Declared data type */ + // char const **pzCollSeq, /* OUTPUT: Collation sequence name */ + // int *pNotNull, /* OUTPUT: True if NOT NULL constraint exists */ + // int *pPrimaryKey, /* OUTPUT: True if column part of PK */ + // int *pAutoinc /* OUTPUT: True if column is auto-increment */ + //); + + /* + ** CAPI3REF: Load An Extension + ** + ** ^This interface loads an SQLite extension library from the named file. + ** + ** ^The sqlite3_load_extension() interface attempts to load an + ** SQLite extension library contained in the file zFile. + ** + ** ^The entry point is zProc. + ** ^zProc may be 0, in which case the name of the entry point + ** defaults to "sqlite3_extension_init". + ** ^The sqlite3_load_extension() interface returns + ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong. + ** ^If an error occurs and pzErrMsg is not 0, then the + ** [sqlite3_load_extension()] interface shall attempt to + ** fill *pzErrMsg with error message text stored in memory + ** obtained from [sqlite3_malloc()]. The calling function + ** should free this memory by calling [sqlite3_free()]. + ** + ** ^Extension loading must be enabled using + ** [sqlite3_enable_load_extension()] prior to calling this API, + ** otherwise an error will be returned. + ** + ** See also the [load_extension() SQL function]. + */ + //SQLITE_API int sqlite3_load_extension( + // sqlite3 db, /* Load the extension into this database connection */ + // string zFile, /* Name of the shared library containing extension */ + // string zProc, /* Entry point. Derived from zFile if 0 */ + // char **pzErrMsg /* Put error message here if not 0 */ + //); + + /* + ** CAPI3REF: Enable Or Disable Extension Loading + ** + ** ^So as not to open security holes in older applications that are + ** unprepared to deal with extension loading, and as a means of disabling + ** extension loading while evaluating user-entered SQL, the following API + ** is provided to turn the [sqlite3_load_extension()] mechanism on and off. + ** + ** ^Extension loading is off by default. See ticket #1863. + ** ^Call the sqlite3_enable_load_extension() routine with onoff==1 + ** to turn extension loading on and call it with onoff==0 to turn + ** it back off again. + */ + //SQLITE_API int sqlite3_enable_load_extension(sqlite3 db, int onoff); + + /* + ** CAPI3REF: Automatically Load Statically Linked Extensions + ** + ** ^This interface causes the xEntryPoint() function to be invoked for + ** each new [database connection] that is created. The idea here is that + ** xEntryPoint() is the entry point for a statically linked SQLite extension + ** that is to be automatically loaded into all new database connections. + ** + ** ^(Even though the function prototype shows that xEntryPoint() takes + ** no arguments and returns void, SQLite invokes xEntryPoint() with three + ** arguments and expects and integer result as if the signature of the + ** entry point where as follows: + ** + **
+    **    int xEntryPoint(
+    **      sqlite3 db,
+    **      string *pzErrMsg,
+    **      const struct sqlite3_api_routines *pThunk
+    **    );
+    ** 
)^ + ** + ** If the xEntryPoint routine encounters an error, it should make *pzErrMsg + ** point to an appropriate error message (obtained from [sqlite3_mprintf()]) + ** and return an appropriate [error code]. ^SQLite ensures that *pzErrMsg + ** is NULL before calling the xEntryPoint(). ^SQLite will invoke + ** [sqlite3_free()] on *pzErrMsg after xEntryPoint() returns. ^If any + ** xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()], + ** or [sqlite3_open_v2()] call that provoked the xEntryPoint() will fail. + ** + ** ^Calling sqlite3_auto_extension(X) with an entry point X that is already + ** on the list of automatic extensions is a harmless no-op. ^No entry point + ** will be called more than once for each database connection that is opened. + ** + ** See also: [sqlite3_reset_auto_extension()]. + */ + //SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void)); + + /* + ** CAPI3REF: Reset Automatic Extension Loading + ** + ** ^This interface disables all automatic extensions previously + ** registered using [sqlite3_auto_extension()]. + */ + //SQLITE_API void sqlite3_reset_auto_extension(void); + + /* + ** The interface to the virtual-table mechanism is currently considered + ** to be experimental. The interface might change in incompatible ways. + ** If this is a problem for you, do not use the interface at this time. + ** + ** When the virtual-table mechanism stabilizes, we will declare the + ** interface fixed, support it indefinitely, and remove this comment. + */ + + /* + ** Structures used by the virtual table interface + */ + //typedef struct sqlite3_vtab sqlite3_vtab; + //typedef struct sqlite3_index_info sqlite3_index_info; + //typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor; + //typedef struct sqlite3_module sqlite3_module; + + /* + ** CAPI3REF: Virtual Table Object + ** KEYWORDS: sqlite3_module {virtual table module} + ** + ** This structure, sometimes called a "virtual table module", + ** defines the implementation of a [virtual tables]. + ** This structure consists mostly of methods for the module. + ** + ** ^A virtual table module is created by filling in a persistent + ** instance of this structure and passing a pointer to that instance + ** to [sqlite3_create_module()] or [sqlite3_create_module_v2()]. + ** ^The registration remains valid until it is replaced by a different + ** module or until the [database connection] closes. The content + ** of this structure must not change while it is registered with + ** any database connection. + */ + //struct sqlite3_module { + // int iVersion; + // int (*xCreate)(sqlite3*, object *pAux, + // int argc, string[] argv, + // sqlite3_vtab **ppVTab, char*); + // int (*xConnect)(sqlite3*, object *pAux, + // int argc, string[] argv, + // sqlite3_vtab **ppVTab, char*); + // int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info); + // int (*xDisconnect)(sqlite3_vtab *pVTab); + // int (*xDestroy)(sqlite3_vtab *pVTab); + // int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor); + // int (*xClose)(sqlite3_vtab_cursor); + // int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, string idxStr, + // int argc, sqlite3_value **argv); + // int (*xNext)(sqlite3_vtab_cursor); + // int (*xEof)(sqlite3_vtab_cursor); + // int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int); + // int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid); + // int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 ); + // int (*xBegin)(sqlite3_vtab *pVTab); + // int (*xSync)(sqlite3_vtab *pVTab); + // int (*xCommit)(sqlite3_vtab *pVTab); + // int (*xRollback)(sqlite3_vtab *pVTab); + // int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, string zName, + // void (**pxFunc)(sqlite3_context*,int,sqlite3_value*), + // void **ppArg); + // int (*xRename)(sqlite3_vtab *pVtab, string zNew); + ///* The methods above are in version 1 of the sqlite_module object. Those + //** below are for version 2 and greater. */ + //int (*xSavepoint)(sqlite3_vtab *pVTab, int); + //int (*xRelease)(sqlite3_vtab *pVTab, int); + //int (*xRollbackTo)(sqlite3_vtab *pVTab, int); + //}; + // MINIMAL STRUCTURE + public class sqlite3_module + { + public int iVersion; + public smdxCreateConnect xCreate; + public smdxCreateConnect xConnect; + public smdxBestIndex xBestIndex; + public smdxDisconnect xDisconnect; + public smdxDestroy xDestroy; + public smdxOpen xOpen; + public smdxClose xClose; + public smdxFilter xFilter; + public smdxNext xNext; + public smdxEof xEof; + public smdxColumn xColumn; + public smdxRowid xRowid; + public smdxUpdate xUpdate; + public smdxFunction xBegin; + public smdxFunction xSync; + public smdxFunction xCommit; + public smdxFunction xRollback; + public smdxFindFunction xFindFunction; + public smdxRename xRename; + /* The methods above are in version 1 of the sqlite_module object. Those + ** below are for version 2 and greater. */ + public smdxFunctionArg xSavepoint; + public smdxFunctionArg xRelease; + public smdxFunctionArg xRollbackTo; + + //Version 1 + public sqlite3_module( + int iVersion, + smdxCreateConnect xCreate, + smdxCreateConnect xConnect, + smdxBestIndex xBestIndex, + smdxDisconnect xDisconnect, + smdxDestroy xDestroy, + smdxOpen xOpen, + smdxClose xClose, + smdxFilter xFilter, + smdxNext xNext, + smdxEof xEof, + smdxColumn xColumn, + smdxRowid xRowid, + smdxUpdate xUpdate, + smdxFunction xBegin, + smdxFunction xSync, + smdxFunction xCommit, + smdxFunction xRollback, + smdxFindFunction xFindFunction, + smdxRename xRename ) + { + this.iVersion = iVersion; + this.xCreate = xCreate; + this.xConnect = xConnect; + this.xBestIndex = xBestIndex; + this.xDisconnect = xDisconnect; + this.xDestroy = xDestroy; + this.xOpen = xOpen; + this.xClose = xClose; + this.xFilter = xFilter; + this.xNext = xNext; + this.xEof = xEof; + this.xColumn = xColumn; + this.xRowid = xRowid; + this.xUpdate = xUpdate; + this.xBegin = xBegin; + this.xSync = xSync; + this.xCommit = xCommit; + this.xRollback = xRollback; + this.xFindFunction = xFindFunction; + this.xRename = xRename; + } + + //Version 2 + public sqlite3_module( + int iVersion, + smdxCreateConnect xCreate, + smdxCreateConnect xConnect, + smdxBestIndex xBestIndex, + smdxDisconnect xDisconnect, + smdxDestroy xDestroy, + smdxOpen xOpen, + smdxClose xClose, + smdxFilter xFilter, + smdxNext xNext, + smdxEof xEof, + smdxColumn xColumn, + smdxRowid xRowid, + smdxUpdate xUpdate, + smdxFunction xBegin, + smdxFunction xSync, + smdxFunction xCommit, + smdxFunction xRollback, + smdxFindFunction xFindFunction, + smdxRename xRename, + /* The methods above are in version 1 of the sqlite_module object. Those + ** below are for version 2 and greater. */ + smdxFunctionArg xSavepoint, + smdxFunctionArg xRelease, + smdxFunctionArg xRollbackTo + ) + { + this.iVersion = iVersion; + this.xCreate = xCreate; + this.xConnect = xConnect; + this.xBestIndex = xBestIndex; + this.xDisconnect = xDisconnect; + this.xDestroy = xDestroy; + this.xOpen = xOpen; + this.xClose = xClose; + this.xFilter = xFilter; + this.xNext = xNext; + this.xEof = xEof; + this.xColumn = xColumn; + this.xRowid = xRowid; + this.xUpdate = xUpdate; + this.xBegin = xBegin; + this.xSync = xSync; + this.xCommit = xCommit; + this.xRollback = xRollback; + this.xFindFunction = xFindFunction; + this.xRename = xRename; + this.xSavepoint = xSavepoint; + this.xRelease = xRelease; + this.xRollbackTo = xRollbackTo; + } + } - /* - ** CAPI3REF: Memory Allocation Routines - ** - ** An instance of this object defines the interface between SQLite - ** and low-level memory allocation routines. - ** - ** This object is used in only one place in the SQLite interface. - ** A pointer to an instance of this object is the argument to - ** [sqlite3_config()] when the configuration option is - ** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC]. - ** By creating an instance of this object - ** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC]) - ** during configuration, an application can specify an alternative - ** memory allocation subsystem for SQLite to use for all of its - ** dynamic memory needs. - ** - ** Note that SQLite comes with several [built-in memory allocators] - ** that are perfectly adequate for the overwhelming majority of applications - ** and that this object is only useful to a tiny minority of applications - ** with specialized memory allocation requirements. This object is - ** also used during testing of SQLite in order to specify an alternative - ** memory allocator that simulates memory out-of-memory conditions in - ** order to verify that SQLite recovers gracefully from such - ** conditions. - ** - ** The xMalloc and xFree methods must work like the - ** malloc() and free() functions from the standard C library. - ** The xRealloc method must work like realloc() from the standard C library - ** with the exception that if the second argument to xRealloc is zero, - ** xRealloc must be a no-op - it must not perform any allocation or - ** deallocation. ^SQLite guarantees that the second argument to - ** xRealloc is always a value returned by a prior call to xRoundup. - ** And so in cases where xRoundup always returns a positive number, - ** xRealloc can perform exactly as the standard library realloc() and - ** still be in compliance with this specification. - ** - ** xSize should return the allocated size of a memory allocation - ** previously obtained from xMalloc or xRealloc. The allocated size - ** is always at least as big as the requested size but may be larger. - ** - ** The xRoundup method returns what would be the allocated size of - ** a memory allocation given a particular requested size. Most memory - ** allocators round up memory allocations at least to the next multiple - ** of 8. Some allocators round up to a larger multiple or to a power of 2. - ** Every memory allocation request coming in through [sqlite3_malloc()] - ** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0, - ** that causes the corresponding memory allocation to fail. - ** - ** The xInit method initializes the memory allocator. (For example, - ** it might allocate any require mutexes or initialize internal data - ** structures. The xShutdown method is invoked (indirectly) by - ** [sqlite3_shutdown()] and should deallocate any resources acquired - ** by xInit. The pAppData pointer is used as the only parameter to - ** xInit and xShutdown. - ** - ** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes - ** the xInit method, so the xInit method need not be threadsafe. The - ** xShutdown method is only called from [sqlite3_shutdown()] so it does - ** not need to be threadsafe either. For all other methods, SQLite - ** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the - ** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which - ** it is by default) and so the methods are automatically serialized. - ** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other - ** methods must be threadsafe or else make their own arrangements for - ** serialization. - ** - ** SQLite will never invoke xInit() more than once without an intervening - ** call to xShutdown(). - */ - //typedef struct sqlite3_mem_methods sqlite3_mem_methods; - //struct sqlite3_mem_methods { - // void *(*xMalloc)(int); /* Memory allocation function */ - // void (*xFree)(void); /* Free a prior allocation */ - // void *(*xRealloc)(void*,int); /* Resize an allocation */ - // int (*xSize)(void); /* Return the size of an allocation */ - // int (*xRoundup)(int); /* Round up request size to allocation size */ - // int (*xInit)(void); /* Initialize the memory allocator */ - // void (*xShutdown)(void); /* Deinitialize the memory allocator */ - // void *pAppData; /* Argument to xInit() and xShutdown() */ - //}; - public class sqlite3_mem_methods { - public dxMalloc xMalloc; //void *(*xMalloc)(int); /* Memory allocation function */ - public dxMallocInt xMallocInt; //void *(*xMalloc)(int); /* Memory allocation function */ - public dxMallocMem xMallocMem; //void *(*xMalloc)(int); /* Memory allocation function */ - public dxFree xFree; //void (*xFree)(void); /* Free a prior allocation */ - public dxFreeInt xFreeInt; //void (*xFree)(void); /* Free a prior allocation */ - public dxFreeMem xFreeMem; //void (*xFree)(void); /* Free a prior allocation */ - public dxRealloc xRealloc; //void *(*xRealloc)(void*,int); /* Resize an allocation */ - public dxSize xSize; //int (*xSize)(void); /* Return the size of an allocation */ - public dxRoundup xRoundup; //int (*xRoundup)(int); /* Round up request size to allocation size */ - public dxMemInit xInit; //int (*xInit)(void); /* Initialize the memory allocator */ - public dxMemShutdown xShutdown; //void (*xShutdown)(void); /* Deinitialize the memory allocator */ - public object pAppData; /* Argument to xInit() and xShutdown() */ - - public sqlite3_mem_methods() { - } - - public sqlite3_mem_methods( - dxMalloc xMalloc, - dxMallocInt xMallocInt, - dxMallocMem xMallocMem, - dxFree xFree, - dxFreeInt xFreeInt, - dxFreeMem xFreeMem, - dxRealloc xRealloc, - dxSize xSize, - dxRoundup xRoundup, - dxMemInit xInit, - dxMemShutdown xShutdown, - object pAppData - ) { - this.xMalloc = xMalloc; - this.xMallocInt = xMallocInt; - this.xMallocMem = xMallocMem; - this.xFree = xFree; - this.xFreeInt = xFreeInt; - this.xFreeMem = xFreeMem; - this.xRealloc = xRealloc; - this.xSize = xSize; - this.xRoundup = xRoundup; - this.xInit = xInit; - this.xShutdown = xShutdown; - this.pAppData = pAppData; - } - } + /* + ** CAPI3REF: Virtual Table Indexing Information + ** KEYWORDS: sqlite3_index_info + ** + ** The sqlite3_index_info structure and its substructures is used as part + ** of the [virtual table] interface to + ** pass information into and receive the reply from the [xBestIndex] + ** method of a [virtual table module]. The fields under **Inputs** are the + ** inputs to xBestIndex and are read-only. xBestIndex inserts its + ** results into the **Outputs** fields. + ** + ** ^(The aConstraint[] array records WHERE clause constraints of the form: + ** + **
column OP expr
+ ** + ** where OP is =, <, <=, >, or >=.)^ ^(The particular operator is + ** stored in aConstraint[].op using one of the + ** [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^ + ** ^(The index of the column is stored in + ** aConstraint[].iColumn.)^ ^(aConstraint[].usable is TRUE if the + ** expr on the right-hand side can be evaluated (and thus the constraint + ** is usable) and false if it cannot.)^ + ** + ** ^The optimizer automatically inverts terms of the form "expr OP column" + ** and makes other simplifications to the WHERE clause in an attempt to + ** get as many WHERE clause terms into the form shown above as possible. + ** ^The aConstraint[] array only reports WHERE clause terms that are + ** relevant to the particular virtual table being queried. + ** + ** ^Information about the ORDER BY clause is stored in aOrderBy[]. + ** ^Each term of aOrderBy records a column of the ORDER BY clause. + ** + ** The [xBestIndex] method must fill aConstraintUsage[] with information + ** about what parameters to pass to xFilter. ^If argvIndex>0 then + ** the right-hand side of the corresponding aConstraint[] is evaluated + ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit + ** is true, then the constraint is assumed to be fully handled by the + ** virtual table and is not checked again by SQLite.)^ + ** + ** ^The idxNum and idxPtr values are recorded and passed into the + ** [xFilter] method. + ** ^[sqlite3_free()] is used to free idxPtr if and only if + ** needToFreeIdxPtr is true. + ** + ** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in + ** the correct order to satisfy the ORDER BY clause so that no separate + ** sorting step is required. + ** + ** ^The estimatedCost value is an estimate of the cost of doing the + ** particular lookup. A full scan of a table with N entries should have + ** a cost of N. A binary search of a table of N entries should have a + ** cost of approximately log(N). + */ + //struct sqlite3_index_info { + // /* Inputs */ + // int nConstraint; /* Number of entries in aConstraint */ + // struct sqlite3_index_constraint { + // int iColumn; /* Column on left-hand side of constraint */ + // unsigned char op; /* Constraint operator */ + // unsigned char usable; /* True if this constraint is usable */ + // int iTermOffset; /* Used internally - xBestIndex should ignore */ + // } *aConstraint; /* Table of WHERE clause constraints */ + // int nOrderBy; /* Number of terms in the ORDER BY clause */ + // struct sqlite3_index_orderby { + // int iColumn; /* Column number */ + // unsigned char desc; /* True for DESC. False for ASC. */ + // } *aOrderBy; /* The ORDER BY clause */ + // /* Outputs */ + // struct sqlite3_index_constraint_usage { + // int argvIndex; /* if >0, constraint is part of argv to xFilter */ + // unsigned char omit; /* Do not code a test for this constraint */ + // } *aConstraintUsage; + // int idxNum; /* Number used to identify the index */ + // char *idxStr; /* String, possibly obtained from sqlite3_malloc */ + // int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */ + // int orderByConsumed; /* True if output is already ordered */ + // double estimatedCost; /* Estimated cost of using this index */ + //}; + public class sqlite3_index_constraint + { + public int iColumn; /* Column on left-hand side of constraint */ + public int op; /* Constraint operator */ + public bool usable; /* True if this constraint is usable */ + public int iTermOffset; /* Used internally - xBestIndex should ignore */ + } + public class sqlite3_index_orderby + { + public int iColumn; /* Column number */ + public bool desc; /* True for DESC. False for ASC. */ + } + public class sqlite3_index_constraint_usage + { + public int argvIndex; /* if >0, constraint is part of argv to xFilter */ + public bool omit; /* Do not code a test for this constraint */ + } - /* - ** CAPI3REF: Configuration Options - ** KEYWORDS: {configuration option} - ** - ** These constants are the available integer configuration options that - ** can be passed as the first argument to the [sqlite3_config()] interface. - ** - ** New configuration options may be added in future releases of SQLite. - ** Existing configuration options might be discontinued. Applications - ** should check the return code from [sqlite3_config()] to make sure that - ** the call worked. The [sqlite3_config()] interface will return a - ** non-zero [error code] if a discontinued or unsupported configuration option - ** is invoked. - ** - **
- ** [[SQLITE_CONFIG_SINGLETHREAD]]
SQLITE_CONFIG_SINGLETHREAD
- **
There are no arguments to this option. ^This option sets the - ** [threading mode] to Single-thread. In other words, it disables - ** all mutexing and puts SQLite into a mode where it can only be used - ** by a single thread. ^If SQLite is compiled with - ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then - ** it is not possible to change the [threading mode] from its default - ** value of Single-thread and so [sqlite3_config()] will return - ** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD - ** configuration option.
- ** - ** [[SQLITE_CONFIG_MULTITHREAD]]
SQLITE_CONFIG_MULTITHREAD
- **
There are no arguments to this option. ^This option sets the - ** [threading mode] to Multi-thread. In other words, it disables - ** mutexing on [database connection] and [prepared statement] objects. - ** The application is responsible for serializing access to - ** [database connections] and [prepared statements]. But other mutexes - ** are enabled so that SQLite will be safe to use in a multi-threaded - ** environment as long as no two threads attempt to use the same - ** [database connection] at the same time. ^If SQLite is compiled with - ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then - ** it is not possible to set the Multi-thread [threading mode] and - ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the - ** SQLITE_CONFIG_MULTITHREAD configuration option.
- ** - ** [[SQLITE_CONFIG_SERIALIZED]]
SQLITE_CONFIG_SERIALIZED
- **
There are no arguments to this option. ^This option sets the - ** [threading mode] to Serialized. In other words, this option enables - ** all mutexes including the recursive - ** mutexes on [database connection] and [prepared statement] objects. - ** In this mode (which is the default when SQLite is compiled with - ** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access - ** to [database connections] and [prepared statements] so that the - ** application is free to use the same [database connection] or the - ** same [prepared statement] in different threads at the same time. - ** ^If SQLite is compiled with - ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then - ** it is not possible to set the Serialized [threading mode] and - ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the - ** SQLITE_CONFIG_SERIALIZED configuration option.
- ** - ** [[SQLITE_CONFIG_MALLOC]]
SQLITE_CONFIG_MALLOC
- **
^(This option takes a single argument which is a pointer to an - ** instance of the [sqlite3_mem_methods] structure. The argument specifies - ** alternative low-level memory allocation routines to be used in place of - ** the memory allocation routines built into SQLite.)^ ^SQLite makes - ** its own private copy of the content of the [sqlite3_mem_methods] structure - ** before the [sqlite3_config()] call returns.
- ** - ** [[SQLITE_CONFIG_GETMALLOC]]
SQLITE_CONFIG_GETMALLOC
- **
^(This option takes a single argument which is a pointer to an - ** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods] - ** structure is filled with the currently defined memory allocation routines.)^ - ** This option can be used to overload the default memory allocation - ** routines with a wrapper that simulations memory allocation failure or - ** tracks memory usage, for example.
- ** - ** [[SQLITE_CONFIG_MEMSTATUS]]
SQLITE_CONFIG_MEMSTATUS
- **
^This option takes single argument of type int, interpreted as a - ** boolean, which enables or disables the collection of memory allocation - ** statistics. ^(When memory allocation statistics are disabled, the - ** following SQLite interfaces become non-operational: - **
    - **
  • [sqlite3_memory_used()] - **
  • [sqlite3_memory_highwater()] - **
  • [sqlite3_soft_heap_limit64()] - **
  • [sqlite3_status()] - **
)^ - ** ^Memory allocation statistics are enabled by default unless SQLite is - ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory - ** allocation statistics are disabled by default. - **
- ** - ** [[SQLITE_CONFIG_SCRATCH]]
SQLITE_CONFIG_SCRATCH
- **
^This option specifies a static memory buffer that SQLite can use for - ** scratch memory. There are three arguments: A pointer an 8-byte - ** aligned memory buffer from which the scratch allocations will be - ** drawn, the size of each scratch allocation (sz), - ** and the maximum number of scratch allocations (N). The sz - ** argument must be a multiple of 16. - ** The first argument must be a pointer to an 8-byte aligned buffer - ** of at least sz*N bytes of memory. - ** ^SQLite will use no more than two scratch buffers per thread. So - ** N should be set to twice the expected maximum number of threads. - ** ^SQLite will never require a scratch buffer that is more than 6 - ** times the database page size. ^If SQLite needs needs additional - ** scratch memory beyond what is provided by this configuration option, then - ** [sqlite3_malloc()] will be used to obtain the memory needed.
- ** - ** [[SQLITE_CONFIG_PAGECACHE]]
SQLITE_CONFIG_PAGECACHE
- **
^This option specifies a static memory buffer that SQLite can use for - ** the database page cache with the default page cache implementation. - ** This configuration should not be used if an application-define page - ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option. - ** There are three arguments to this option: A pointer to 8-byte aligned - ** memory, the size of each page buffer (sz), and the number of pages (N). - ** The sz argument should be the size of the largest database page - ** (a power of two between 512 and 32768) plus a little extra for each - ** page header. ^The page header size is 20 to 40 bytes depending on - ** the host architecture. ^It is harmless, apart from the wasted memory, - ** to make sz a little too large. The first - ** argument should point to an allocation of at least sz*N bytes of memory. - ** ^SQLite will use the memory provided by the first argument to satisfy its - ** memory needs for the first N pages that it adds to cache. ^If additional - ** page cache memory is needed beyond what is provided by this option, then - ** SQLite goes to [sqlite3_malloc()] for the additional storage space. - ** The pointer in the first argument must - ** be aligned to an 8-byte boundary or subsequent behavior of SQLite - ** will be undefined.
- ** - ** [[SQLITE_CONFIG_HEAP]]
SQLITE_CONFIG_HEAP
- **
^This option specifies a static memory buffer that SQLite will use - ** for all of its dynamic memory allocation needs beyond those provided - ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE]. - ** There are three arguments: An 8-byte aligned pointer to the memory, - ** the number of bytes in the memory buffer, and the minimum allocation size. - ** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts - ** to using its default memory allocator (the system malloc() implementation), - ** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. ^If the - ** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or - ** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory - ** allocator is engaged to handle all of SQLites memory allocation needs. - ** The first pointer (the memory pointer) must be aligned to an 8-byte - ** boundary or subsequent behavior of SQLite will be undefined. - ** The minimum allocation size is capped at 2^12. Reasonable values - ** for the minimum allocation size are 2^5 through 2^8.
- ** - ** [[SQLITE_CONFIG_MUTEX]]
SQLITE_CONFIG_MUTEX
- **
^(This option takes a single argument which is a pointer to an - ** instance of the [sqlite3_mutex_methods] structure. The argument specifies - ** alternative low-level mutex routines to be used in place - ** the mutex routines built into SQLite.)^ ^SQLite makes a copy of the - ** content of the [sqlite3_mutex_methods] structure before the call to - ** [sqlite3_config()] returns. ^If SQLite is compiled with - ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then - ** the entire mutexing subsystem is omitted from the build and hence calls to - ** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will - ** return [SQLITE_ERROR].
- ** - ** [[SQLITE_CONFIG_GETMUTEX]]
SQLITE_CONFIG_GETMUTEX
- **
^(This option takes a single argument which is a pointer to an - ** instance of the [sqlite3_mutex_methods] structure. The - ** [sqlite3_mutex_methods] - ** structure is filled with the currently defined mutex routines.)^ - ** This option can be used to overload the default mutex allocation - ** routines with a wrapper used to track mutex usage for performance - ** profiling or testing, for example. ^If SQLite is compiled with - ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then - ** the entire mutexing subsystem is omitted from the build and hence calls to - ** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will - ** return [SQLITE_ERROR].
- ** - ** [[SQLITE_CONFIG_LOOKASIDE]]
SQLITE_CONFIG_LOOKASIDE
- **
^(This option takes two arguments that determine the default - ** memory allocation for the lookaside memory allocator on each - ** [database connection]. The first argument is the - ** size of each lookaside buffer slot and the second is the number of - ** slots allocated to each database connection.)^ ^(This option sets the - ** default lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE] - ** verb to [sqlite3_db_config()] can be used to change the lookaside - ** configuration on individual connections.)^
- ** - ** [[SQLITE_CONFIG_PCACHE]]
SQLITE_CONFIG_PCACHE
- **
^(This option takes a single argument which is a pointer to - ** an [sqlite3_pcache_methods] object. This object specifies the interface - ** to a custom page cache implementation.)^ ^SQLite makes a copy of the - ** object and uses it for page cache memory allocations.
- ** - ** [[SQLITE_CONFIG_GETPCACHE]]
SQLITE_CONFIG_GETPCACHE
- **
^(This option takes a single argument which is a pointer to an - ** [sqlite3_pcache_methods] object. SQLite copies of the current - ** page cache implementation into that object.)^
- ** - ** [[SQLITE_CONFIG_LOG]]
SQLITE_CONFIG_LOG
- **
^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a - ** function with a call signature of void()(void*,int,const char), - ** and a pointer to void. ^If the function pointer is not NULL, it is - ** invoked by [sqlite3_log()] to process each logging event. ^If the - ** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op. - ** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is - ** passed through as the first parameter to the application-defined logger - ** function whenever that function is invoked. ^The second parameter to - ** the logger function is a copy of the first parameter to the corresponding - ** [sqlite3_log()] call and is intended to be a [result code] or an - ** [extended result code]. ^The third parameter passed to the logger is - ** log message after formatting via [sqlite3_snprintf()]. - ** The SQLite logging interface is not reentrant; the logger function - ** 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 - ** URI handling is globally enabled. If the parameter is zero, then URI handling - ** 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 - ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the - ** 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. - **
- */ - //#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ - //#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ - //#define SQLITE_CONFIG_SERIALIZED 3 /* nil */ - //#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ - //#define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ - //#define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */ - //#define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */ - //#define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */ - //#define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */ - //#define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */ - //#define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */ - ///* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ - //#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ - //#define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */ - //#define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */ - //#define SQLITE_CONFIG_LOG 16 /* xFunc, void* */ - //#define SQLITE_CONFIG_URI 17 /* int */ - public const int SQLITE_CONFIG_SINGLETHREAD = 1; - public const int SQLITE_CONFIG_MULTITHREAD = 2; - public const int SQLITE_CONFIG_SERIALIZED = 3; - public const int SQLITE_CONFIG_MALLOC = 4; - public const int SQLITE_CONFIG_GETMALLOC = 5; - public const int SQLITE_CONFIG_SCRATCH = 6; - public const int SQLITE_CONFIG_PAGECACHE = 7; - public const int SQLITE_CONFIG_HEAP = 8; - public const int SQLITE_CONFIG_MEMSTATUS = 9; - public const int SQLITE_CONFIG_MUTEX = 10; - public const int SQLITE_CONFIG_GETMUTEX = 11; - public const int SQLITE_CONFIG_LOOKASIDE = 13; - public const int SQLITE_CONFIG_PCACHE = 14; - public const int SQLITE_CONFIG_GETPCACHE = 15; - public const int SQLITE_CONFIG_LOG = 16; - public const int SQLITE_CONFIG_URI = 17; - - /* - ** CAPI3REF: Database Connection Configuration Options - ** - ** These constants are the available integer configuration options that - ** can be passed as the second argument to the [sqlite3_db_config()] interface. - ** - ** New configuration options may be added in future releases of SQLite. - ** Existing configuration options might be discontinued. Applications - ** should check the return code from [sqlite3_db_config()] to make sure that - ** the call worked. ^The [sqlite3_db_config()] interface will return a - ** non-zero [error code] if a discontinued or unsupported configuration option - ** is invoked. - ** - **
- **
SQLITE_DBCONFIG_LOOKASIDE
- **
^This option takes three additional arguments that determine the - ** [lookaside memory allocator] configuration for the [database connection]. - ** ^The first argument (the third parameter to [sqlite3_db_config()] is a - ** pointer to a memory buffer to use for lookaside memory. - ** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb - ** may be NULL in which case SQLite will allocate the - ** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the - ** size of each lookaside buffer slot. ^The third argument is the number of - ** slots. The size of the buffer in the first argument must be greater than - ** or equal to the product of the second and third arguments. The buffer - ** must be aligned to an 8-byte boundary. ^If the second argument to - ** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally - ** rounded down to the next smaller multiple of 8. ^(The lookaside memory - ** configuration for a database connection can only be changed when that - ** connection is not currently using lookaside memory, or in other words - ** when the "current value" returned by - ** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero. - ** Any attempt to change the lookaside memory configuration when lookaside - ** memory is in use leaves the configuration unchanged and returns - ** [SQLITE_BUSY].)^
- ** - **
SQLITE_DBCONFIG_ENABLE_FKEY
- **
^This option is used to enable or disable the enforcement of - ** [foreign key constraints]. There should be two additional arguments. - ** The first argument is an integer which is 0 to disable FK enforcement, - ** positive to enable FK enforcement or negative to leave FK enforcement - ** unchanged. The second parameter is a pointer to an integer into which - ** is written 0 or 1 to indicate whether FK enforcement is off or on - ** following this call. The second parameter may be a NULL pointer, in - ** which case the FK enforcement setting is not reported back.
- ** - **
SQLITE_DBCONFIG_ENABLE_TRIGGER
- **
^This option is used to enable or disable [CREATE TRIGGER | triggers]. - ** There should be two additional arguments. - ** The first argument is an integer which is 0 to disable triggers, - ** positive to enable triggers or negative to leave the setting unchanged. - ** The second parameter is a pointer to an integer into which - ** is written 0 or 1 to indicate whether triggers are disabled or enabled - ** following this call. The second parameter may be a NULL pointer, in - ** which case the trigger setting is not reported back.
- ** - **
- */ - //#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ - //#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */ - //#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */ - const int SQLITE_DBCONFIG_LOOKASIDE = 1001; - const int SQLITE_DBCONFIG_ENABLE_FKEY = 1002; - const int SQLITE_DBCONFIG_ENABLE_TRIGGER = 1003; - - /* - ** CAPI3REF: Enable Or Disable Extended Result Codes - ** - ** ^The sqlite3_extended_result_codes() routine enables or disables the - ** [extended result codes] feature of SQLite. ^The extended result - ** codes are disabled by default for historical compatibility. - */ - //SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff); - - /* - ** CAPI3REF: Last Insert Rowid - ** - ** ^Each entry in an SQLite table has a unique 64-bit signed - ** integer key called the [ROWID | "rowid"]. ^The rowid is always available - ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those - ** names are not also used by explicitly declared columns. ^If - ** the table has a column of type [INTEGER PRIMARY KEY] then that column - ** is another alias for the rowid. - ** - ** ^This routine returns the [rowid] of the most recent - ** successful [INSERT] into the database from the [database connection] - ** in the first argument. ^As of SQLite version 3.7.7, this routines - ** records the last insert rowid of both ordinary tables and [virtual tables]. - ** ^If no successful [INSERT]s - ** have ever occurred on that database connection, zero is returned. - ** - ** ^(If an [INSERT] occurs within a trigger or within a [virtual table] - ** method, then this routine will return the [rowid] of the inserted - ** row as long as the trigger or virtual table method is running. - ** But once the trigger or virtual table method ends, the value returned - ** by this routine reverts to what it was before the trigger or virtual - ** table method began.)^ - ** - ** ^An [INSERT] that fails due to a constraint violation is not a - ** successful [INSERT] and does not change the value returned by this - ** routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK, - ** and INSERT OR ABORT make no changes to the return value of this - ** routine when their insertion fails. ^(When INSERT OR REPLACE - ** encounters a constraint violation, it does not fail. The - ** INSERT continues to completion after deleting rows that caused - ** the constraint problem so INSERT OR REPLACE will always change - ** the return value of this interface.)^ - ** - ** ^For the purposes of this routine, an [INSERT] is considered to - ** be successful even if it is subsequently rolled back. - ** - ** This function is accessible to SQL statements via the - ** [last_insert_rowid() SQL function]. - ** - ** If a separate thread performs a new [INSERT] on the same - ** database connection while the [sqlite3_last_insert_rowid()] - ** function is running and thus changes the last insert [rowid], - ** then the value returned by [sqlite3_last_insert_rowid()] is - ** unpredictable and might not equal either the old or the new - ** last insert [rowid]. - */ - //SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3); - - /* - ** CAPI3REF: Count The Number Of Rows Modified - ** - ** ^This function returns the number of database rows that were changed - ** or inserted or deleted by the most recently completed SQL statement - ** on the [database connection] specified by the first parameter. - ** ^(Only changes that are directly specified by the [INSERT], [UPDATE], - ** or [DELETE] statement are counted. Auxiliary changes caused by - ** triggers or [foreign key actions] are not counted.)^ Use the - ** [sqlite3_total_changes()] function to find the total number of changes - ** including changes caused by triggers and foreign key actions. - ** - ** ^Changes to a view that are simulated by an [INSTEAD OF trigger] - ** are not counted. Only real table changes are counted. - ** - ** ^(A "row change" is a change to a single row of a single table - ** caused by an INSERT, DELETE, or UPDATE statement. Rows that - ** are changed as side effects of [REPLACE] constraint resolution, - ** rollback, ABORT processing, [DROP TABLE], or by any other - ** mechanisms do not count as direct row changes.)^ - ** - ** A "trigger context" is a scope of execution that begins and - ** ends with the script of a [CREATE TRIGGER | trigger]. - ** Most SQL statements are - ** evaluated outside of any trigger. This is the "top level" - ** trigger context. If a trigger fires from the top level, a - ** new trigger context is entered for the duration of that one - ** trigger. Subtriggers create subcontexts for their duration. - ** - ** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does - ** not create a new trigger context. - ** - ** ^This function returns the number of direct row changes in the - ** most recent INSERT, UPDATE, or DELETE statement within the same - ** trigger context. - ** - ** ^Thus, when called from the top level, this function returns the - ** number of changes in the most recent INSERT, UPDATE, or DELETE - ** that also occurred at the top level. ^(Within the body of a trigger, - ** the sqlite3_changes() interface can be called to find the number of - ** changes in the most recently completed INSERT, UPDATE, or DELETE - ** statement within the body of the same trigger. - ** However, the number returned does not include changes - ** caused by subtriggers since those have their own context.)^ - ** - ** See also the [sqlite3_total_changes()] interface, the - ** [count_changes pragma], and the [changes() SQL function]. - ** - ** If a separate thread makes changes on the same database connection - ** while [sqlite3_changes()] is running then the value returned - ** is unpredictable and not meaningful. - */ - //SQLITE_API int sqlite3_changes(sqlite3); - - /* - ** CAPI3REF: Total Number Of Rows Modified - ** - ** ^This function returns the number of row changes caused by [INSERT], - ** [UPDATE] or [DELETE] statements since the [database connection] was opened. - ** ^(The count returned by sqlite3_total_changes() includes all changes - ** from all [CREATE TRIGGER | trigger] contexts and changes made by - ** [foreign key actions]. However, - ** the count does not include changes used to implement [REPLACE] constraints, - ** do rollbacks or ABORT processing, or [DROP TABLE] processing. The - ** count does not include rows of views that fire an [INSTEAD OF trigger], - ** though if the INSTEAD OF trigger makes changes of its own, those changes - ** are counted.)^ - ** ^The sqlite3_total_changes() function counts the changes as soon as - ** the statement that makes them is completed (when the statement handle - ** is passed to [sqlite3_reset()] or [sqlite3_finalize()]). - ** - ** See also the [sqlite3_changes()] interface, the - ** [count_changes pragma], and the [total_changes() SQL function]. - ** - ** If a separate thread makes changes on the same database connection - ** while [sqlite3_total_changes()] is running then the value - ** returned is unpredictable and not meaningful. - */ - //SQLITE_API int sqlite3_total_changes(sqlite3); - - /* - ** CAPI3REF: Interrupt A Long-Running Query - ** - ** ^This function causes any pending database operation to abort and - ** return at its earliest opportunity. This routine is typically - ** called in response to a user action such as pressing "Cancel" - ** or Ctrl-C where the user wants a long query operation to halt - ** immediately. - ** - ** ^It is safe to call this routine from a thread different from the - ** thread that is currently running the database operation. But it - ** is not safe to call this routine with a [database connection] that - ** is closed or might close before sqlite3_interrupt() returns. - ** - ** ^If an SQL operation is very nearly finished at the time when - ** sqlite3_interrupt() is called, then it might not have an opportunity - ** to be interrupted and might continue to completion. - ** - ** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT]. - ** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE - ** that is inside an explicit transaction, then the entire transaction - ** will be rolled back automatically. - ** - ** ^The sqlite3_interrupt(D) call is in effect until all currently running - ** SQL statements on [database connection] D complete. ^Any new SQL statements - ** that are started after the sqlite3_interrupt() call and before the - ** running statements reaches zero are interrupted as if they had been - ** running prior to the sqlite3_interrupt() call. ^New SQL statements - ** that are started after the running statement count reaches zero are - ** not effected by the sqlite3_interrupt(). - ** ^A call to sqlite3_interrupt(D) that occurs when there are no running - ** SQL statements is a no-op and has no effect on SQL statements - ** that are started after the sqlite3_interrupt() call returns. - ** - ** If the database connection closes while [sqlite3_interrupt()] - ** is running then bad things will likely happen. - */ - //SQLITE_API void sqlite3_interrupt(sqlite3); - - /* - ** CAPI3REF: Determine If An SQL Statement Is Complete - ** - ** These routines are useful during command-line input to determine if the - ** currently entered text seems to form a complete SQL statement or - ** if additional input is needed before sending the text into - ** SQLite for parsing. ^These routines return 1 if the input string - ** appears to be a complete SQL statement. ^A statement is judged to be - ** complete if it ends with a semicolon token and is not a prefix of a - ** well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within - ** string literals or quoted identifier names or comments are not - ** independent tokens (they are part of the token in which they are - ** embedded) and thus do not count as a statement terminator. ^Whitespace - ** and comments that follow the final semicolon are ignored. - ** - ** ^These routines return 0 if the statement is incomplete. ^If a - ** memory allocation fails, then SQLITE_NOMEM is returned. - ** - ** ^These routines do not parse the SQL statements thus - ** will not detect syntactically incorrect SQL. - ** - ** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior - ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked - ** automatically by sqlite3_complete16(). If that initialization fails, - ** then the return value from sqlite3_complete16() will be non-zero - ** regardless of whether or not the input SQL is complete.)^ - ** - ** The input to [sqlite3_complete()] must be a zero-terminated - ** UTF-8 string. - ** - ** The input to [sqlite3_complete16()] must be a zero-terminated - ** UTF-16 string in native byte order. - */ - //SQLITE_API int sqlite3_complete(string sql); - //SQLITE_API int sqlite3_complete16(const void *sql); - - /* - ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors - ** - ** ^This routine sets a callback function that might be invoked whenever - ** an attempt is made to open a database table that another thread - ** or process has locked. - ** - ** ^If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] - ** is returned immediately upon encountering the lock. ^If the busy callback - ** is not NULL, then the callback might be invoked with two arguments. - ** - ** ^The first argument to the busy handler is a copy of the void* pointer which - ** is the third argument to sqlite3_busy_handler(). ^The second argument to - ** the busy handler callback is the number of times that the busy handler has - ** been invoked for this locking event. ^If the - ** busy callback returns 0, then no additional attempts are made to - ** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned. - ** ^If the callback returns non-zero, then another attempt - ** is made to open the database for reading and the cycle repeats. - ** - ** The presence of a busy handler does not guarantee that it will be invoked - ** when there is lock contention. ^If SQLite determines that invoking the busy - ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY] - ** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler. - ** Consider a scenario where one process is holding a read lock that - ** it is trying to promote to a reserved lock and - ** a second process is holding a reserved lock that it is trying - ** to promote to an exclusive lock. The first process cannot proceed - ** because it is blocked by the second and the second process cannot - ** proceed because it is blocked by the first. If both processes - ** invoke the busy handlers, neither will make any progress. Therefore, - ** SQLite returns [SQLITE_BUSY] for the first process, hoping that this - ** will induce the first process to release its read lock and allow - ** the second process to proceed. - ** - ** ^The default busy callback is NULL. - ** - ** ^The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED] - ** when SQLite is in the middle of a large transaction where all the - ** changes will not fit into the in-memory cache. SQLite will - ** already hold a RESERVED lock on the database file, but it needs - ** to promote this lock to EXCLUSIVE so that it can spill cache - ** pages into the database file without harm to concurrent - ** readers. ^If it is unable to promote the lock, then the in-memory - ** cache will be left in an inconsistent state and so the error - ** code is promoted from the relatively benign [SQLITE_BUSY] to - ** the more severe [SQLITE_IOERR_BLOCKED]. ^This error code promotion - ** forces an automatic rollback of the changes. See the - ** - ** CorruptionFollowingBusyError wiki page for a discussion of why - ** this is important. - ** - ** ^(There can only be a single busy handler defined for each - ** [database connection]. Setting a new busy handler clears any - ** previously set handler.)^ ^Note that calling [sqlite3_busy_timeout()] - ** will also set or clear the busy handler. - ** - ** The busy callback should not take any actions which modify the - ** database connection that invoked the busy handler. Any such actions - ** result in undefined behavior. - ** - ** A busy handler must not close the database connection - ** or [prepared statement] that invoked the busy handler. - */ - //SQLITE_API int sqlite3_busy_handler(sqlite3*, int()(void*,int), void); - - /* - ** CAPI3REF: Set A Busy Timeout - ** - ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps - ** for a specified amount of time when a table is locked. ^The handler - ** will sleep multiple times until at least "ms" milliseconds of sleeping - ** have accumulated. ^After at least "ms" milliseconds of sleeping, - ** the handler returns 0 which causes [sqlite3_step()] to return - ** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]. - ** - ** ^Calling this routine with an argument less than or equal to zero - ** turns off all busy handlers. - ** - ** ^(There can only be a single busy handler for a particular - ** [database connection] any any given moment. If another busy handler - ** was defined (using [sqlite3_busy_handler()]) prior to calling - ** this routine, that other busy handler is cleared.)^ - */ - //SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms); - - /* - ** CAPI3REF: Convenience Routines For Running Queries - ** - ** This is a legacy interface that is preserved for backwards compatibility. - ** Use of this interface is not recommended. - ** - ** Definition: A result table is memory data structure created by the - ** [sqlite3_get_table()] interface. A result table records the - ** complete query results from one or more queries. - ** - ** The table conceptually has a number of rows and columns. But - ** these numbers are not part of the result table itself. These - ** numbers are obtained separately. Let N be the number of rows - ** and M be the number of columns. - ** - ** A result table is an array of pointers to zero-terminated UTF-8 strings. - ** There are (N+1)*M elements in the array. The first M pointers point - ** to zero-terminated strings that contain the names of the columns. - ** The remaining entries all point to query results. NULL values result - ** in NULL pointers. All other values are in their UTF-8 zero-terminated - ** string representation as returned by [sqlite3_column_text()]. - ** - ** A result table might consist of one or more memory allocations. - ** It is not safe to pass a result table directly to [sqlite3_free()]. - ** A result table should be deallocated using [sqlite3_free_table()]. - ** - ** ^(As an example of the result table format, suppose a query result - ** is as follows: - ** - **
-        **        Name        | Age
-        **        -----------------------
-        **        Alice       | 43
-        **        Bob         | 28
-        **        Cindy       | 21
-        ** 
- ** - ** There are two column (M==2) and three rows (N==3). Thus the - ** result table has 8 entries. Suppose the result table is stored - ** in an array names azResult. Then azResult holds this content: - ** - **
-        **        azResult[0] = "Name";
-        **        azResult[1] = "Age";
-        **        azResult[2] = "Alice";
-        **        azResult[3] = "43";
-        **        azResult[4] = "Bob";
-        **        azResult[5] = "28";
-        **        azResult[6] = "Cindy";
-        **        azResult[7] = "21";
-        ** 
)^ - ** - ** ^The sqlite3_get_table() function evaluates one or more - ** semicolon-separated SQL statements in the zero-terminated UTF-8 - ** string of its 2nd parameter and returns a result table to the - ** pointer given in its 3rd parameter. - ** - ** After the application has finished with the result from sqlite3_get_table(), - ** it must pass the result table pointer to sqlite3_free_table() in order to - ** release the memory that was malloced. Because of the way the - ** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling - ** function must not try to call [sqlite3_free()] directly. Only - ** [sqlite3_free_table()] is able to release the memory properly and safely. - ** - ** The sqlite3_get_table() interface is implemented as a wrapper around - ** [sqlite3_exec()]. The sqlite3_get_table() routine does not have access - ** to any internal data structures of SQLite. It uses only the public - ** interface defined here. As a consequence, errors that occur in the - ** wrapper layer outside of the internal [sqlite3_exec()] call are not - ** reflected in subsequent calls to [sqlite3_errcode()] or - ** [sqlite3_errmsg()]. - */ - //SQLITE_API int sqlite3_get_table( - // sqlite3 db, /* An open database */ - // string zSql, /* SQL to be evaluated */ - // char ***pazResult, /* Results of the query */ - // int *pnRow, /* Number of result rows written here */ - // int *pnColumn, /* Number of result columns written here */ - // char **pzErrmsg /* Error msg written here */ - //); - //SQLITE_API void sqlite3_free_table(char **result); - - /* - ** CAPI3REF: Formatted String Printing Functions - ** - ** These routines are work-alikes of the "printf()" family of functions - ** from the standard C library. - ** - ** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their - ** results into memory obtained from [sqlite3_malloc()]. - ** The strings returned by these two routines should be - ** released by [sqlite3_free()]. ^Both routines return a - ** NULL pointer if [sqlite3_malloc()] is unable to allocate enough - ** memory to hold the resulting string. - ** - ** ^(The sqlite3_snprintf() routine is similar to "snprintf()" from - ** the standard C library. The result is written into the - ** buffer supplied as the second parameter whose size is given by - ** the first parameter. Note that the order of the - ** first two parameters is reversed from snprintf().)^ This is an - ** historical accident that cannot be fixed without breaking - ** backwards compatibility. ^(Note also that sqlite3_snprintf() - ** returns a pointer to its buffer instead of the number of - ** characters actually written into the buffer.)^ We admit that - ** the number of characters written would be a more useful return - ** value but we cannot change the implementation of sqlite3_snprintf() - ** now without breaking compatibility. - ** - ** ^As long as the buffer size is greater than zero, sqlite3_snprintf() - ** guarantees that the buffer is always zero-terminated. ^The first - ** parameter "n" is the total size of the buffer, including space for - ** the zero terminator. So the longest string that can be completely - ** written will be n-1 characters. - ** - ** ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf(). - ** - ** These routines all implement some additional formatting - ** options that are useful for constructing SQL statements. - ** All of the usual printf() formatting options apply. In addition, there - ** is are "%q", "%Q", and "%z" options. - ** - ** ^(The %q option works like %s in that it substitutes a null-terminated - ** string from the argument list. But %q also doubles every '\'' character. - ** %q is designed for use inside a string literal.)^ By doubling each '\'' - ** character it escapes that character and allows it to be inserted into - ** the string. - ** - ** For example, assume the string variable zText contains text as follows: - ** - **
-        **  string zText = "It's a happy day!";
-        ** 
- ** - ** One can use this text in an SQL statement as follows: - ** - **
-        **  string zSQL = sqlite3_mprintf("INSERT INTO table VALUES('%q')", zText);
-        **  sqlite3_exec(db, zSQL, 0, 0, 0);
-        **  sqlite3_free(zSQL);
-        ** 
- ** - ** Because the %q format string is used, the '\'' character in zText - ** is escaped and the SQL generated is as follows: - ** - **
-        **  INSERT INTO table1 VALUES('It''s a happy day!')
-        ** 
- ** - ** This is correct. Had we used %s instead of %q, the generated SQL - ** would have looked like this: - ** - **
-        **  INSERT INTO table1 VALUES('It's a happy day!');
-        ** 
- ** - ** This second example is an SQL syntax error. As a general rule you should - ** always use %q instead of %s when inserting text into a string literal. - ** - ** ^(The %Q option works like %q except it also adds single quotes around - ** the outside of the total string. Additionally, if the parameter in the - ** argument list is a NULL pointer, %Q substitutes the text "NULL" (without - ** single quotes).)^ So, for example, one could say: - ** - **
-        **  string zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
-        **  sqlite3_exec(db, zSQL, 0, 0, 0);
-        **  sqlite3_free(zSQL);
-        ** 
- ** - ** The code above will render a correct SQL statement in the zSQL - ** variable even if the zText variable is a NULL pointer. - ** - ** ^(The "%z" formatting option works like "%s" but with the - ** addition that after the string has been read and copied into - ** the result, [sqlite3_free()] is called on the input string.)^ - */ - //SQLITE_API char *sqlite3_mprintf(const char*,...); - //SQLITE_API char *sqlite3_vmprintf(const char*, va_list); - //SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...); - //SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list); - - - /* - ** CAPI3REF: Memory Allocation Subsystem - ** - ** The SQLite core uses these three routines for all of its own - ** internal memory allocation needs. "Core" in the previous sentence - ** does not include operating-system specific VFS implementation. The - ** Windows VFS uses native malloc() and free() for some operations. - ** - ** ^The sqlite3_malloc() routine returns a pointer to a block - ** of memory at least N bytes in length, where N is the parameter. - ** ^If sqlite3_malloc() is unable to obtain sufficient free - ** memory, it returns a NULL pointer. ^If the parameter N to - ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns - ** a NULL pointer. - ** - ** ^Calling sqlite3_free() with a pointer previously returned - ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so - ** that it might be reused. ^The sqlite3_free() routine is - ** a no-op if is called with a NULL pointer. Passing a NULL pointer - ** to sqlite3_free() is harmless. After being freed, memory - ** should neither be read nor written. Even reading previously freed - ** memory might result in a segmentation fault or other severe error. - ** Memory corruption, a segmentation fault, or other severe error - ** might result if sqlite3_free() is called with a non-NULL pointer that - ** was not obtained from sqlite3_malloc() or sqlite3_realloc(). - ** - ** ^(The sqlite3_realloc() interface attempts to resize a - ** prior memory allocation to be at least N bytes, where N is the - ** second parameter. The memory allocation to be resized is the first - ** parameter.)^ ^ If the first parameter to sqlite3_realloc() - ** is a NULL pointer then its behavior is identical to calling - ** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc(). - ** ^If the second parameter to sqlite3_realloc() is zero or - ** negative then the behavior is exactly the same as calling - ** sqlite3_free(P) where P is the first parameter to sqlite3_realloc(). - ** ^sqlite3_realloc() returns a pointer to a memory allocation - ** of at least N bytes in size or NULL if sufficient memory is unavailable. - ** ^If M is the size of the prior allocation, then min(N,M) bytes - ** of the prior allocation are copied into the beginning of buffer returned - ** by sqlite3_realloc() and the prior allocation is freed. - ** ^If sqlite3_realloc() returns NULL, then the prior allocation - ** is not freed. - ** - ** ^The memory returned by sqlite3_malloc() and sqlite3_realloc() - ** is always aligned to at least an 8 byte boundary, or to a - ** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time - ** option is used. - ** - ** In SQLite version 3.5.0 and 3.5.1, it was possible to define - ** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in - ** implementation of these routines to be omitted. That capability - ** is no longer provided. Only built-in memory allocators can be used. - ** - ** The Windows OS interface layer calls - ** the system malloc() and free() directly when converting - ** filenames between the UTF-8 encoding used by SQLite - ** and whatever filename encoding is used by the particular Windows - ** installation. Memory allocation errors are detected, but - ** they are reported back as [SQLITE_CANTOPEN] or - ** [SQLITE_IOERR] rather than [SQLITE_NOMEM]. - ** - ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()] - ** must be either NULL or else pointers obtained from a prior - ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have - ** not yet been released. - ** - ** The application must not read or write any part of - ** a block of memory after it has been released using - ** [sqlite3_free()] or [sqlite3_realloc()]. - */ - //SQLITE_API void *sqlite3_malloc(int); - //SQLITE_API void *sqlite3_realloc(void*, int); - //SQLITE_API void sqlite3_free(void); - - /* - ** CAPI3REF: Memory Allocator Statistics - ** - ** SQLite provides these two interfaces for reporting on the status - ** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()] - ** routines, which form the built-in memory allocation subsystem. - ** - ** ^The [sqlite3_memory_used()] routine returns the number of bytes - ** of memory currently outstanding (malloced but not freed). - ** ^The [sqlite3_memory_highwater()] routine returns the maximum - ** value of [sqlite3_memory_used()] since the high-water mark - ** was last reset. ^The values returned by [sqlite3_memory_used()] and - ** [sqlite3_memory_highwater()] include any overhead - ** added by SQLite in its implementation of [sqlite3_malloc()], - ** but not overhead added by the any underlying system library - ** routines that [sqlite3_malloc()] may call. - ** - ** ^The memory high-water mark is reset to the current value of - ** [sqlite3_memory_used()] if and only if the parameter to - ** [sqlite3_memory_highwater()] is true. ^The value returned - ** by [sqlite3_memory_highwater(1)] is the high-water mark - ** prior to the reset. - */ - //SQLITE_API sqlite3_int64 sqlite3_memory_used(void); - //SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag); - - /* - ** CAPI3REF: Pseudo-Random Number Generator - ** - ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to - ** select random [ROWID | ROWIDs] when inserting new records into a table that - ** already uses the largest possible [ROWID]. The PRNG is also used for - ** the build-in random() and randomblob() SQL functions. This interface allows - ** applications to access the same PRNG for other purposes. - ** - ** ^A call to this routine stores N bytes of randomness into buffer P. - ** - ** ^The first time this routine is invoked (either internally or by - ** the application) the PRNG is seeded using randomness obtained - ** from the xRandomness method of the default [sqlite3_vfs] object. - ** ^On all subsequent invocations, the pseudo-randomness is generated - ** internally and without recourse to the [sqlite3_vfs] xRandomness - ** method. - */ - //SQLITE_API void sqlite3_randomness(int N, object *P); - - /* - ** CAPI3REF: Compile-Time Authorization Callbacks - ** - ** ^This routine registers an authorizer callback with a particular - ** [database connection], supplied in the first argument. - ** ^The authorizer callback is invoked as SQL statements are being compiled - ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()], - ** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various - ** points during the compilation process, as logic is being created - ** to perform various actions, the authorizer callback is invoked to - ** see if those actions are allowed. ^The authorizer callback should - ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the - ** specific action but allow the SQL statement to continue to be - ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be - ** rejected with an error. ^If the authorizer callback returns - ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY] - ** then the [sqlite3_prepare_v2()] or equivalent call that triggered - ** the authorizer will fail with an error message. - ** - ** When the callback returns [SQLITE_OK], that means the operation - ** requested is ok. ^When the callback returns [SQLITE_DENY], the - ** [sqlite3_prepare_v2()] or equivalent call that triggered the - ** authorizer will fail with an error message explaining that - ** access is denied. - ** - ** ^The first parameter to the authorizer callback is a copy of the third - ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter - ** to the callback is an integer [SQLITE_COPY | action code] that specifies - ** the particular action to be authorized. ^The third through sixth parameters - ** to the callback are zero-terminated strings that contain additional - ** details about the action to be authorized. - ** - ** ^If the action code is [SQLITE_READ] - ** and the callback returns [SQLITE_IGNORE] then the - ** [prepared statement] statement is constructed to substitute - ** a NULL value in place of the table column that would have - ** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE] - ** return can be used to deny an untrusted user access to individual - ** columns of a table. - ** ^If the action code is [SQLITE_DELETE] and the callback returns - ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the - ** [truncate optimization] is disabled and all rows are deleted individually. - ** - ** An authorizer is used when [sqlite3_prepare | preparing] - ** SQL statements from an untrusted source, to ensure that the SQL statements - ** do not try to access data they are not allowed to see, or that they do not - ** try to execute malicious statements that damage the database. For - ** example, an application may allow a user to enter arbitrary - ** SQL queries for evaluation by a database. But the application does - ** not want the user to be able to make arbitrary changes to the - ** database. An authorizer could then be put in place while the - ** user-entered SQL is being [sqlite3_prepare | prepared] that - ** disallows everything except [SELECT] statements. - ** - ** Applications that need to process SQL from untrusted sources - ** might also consider lowering resource limits using [sqlite3_limit()] - ** and limiting database size using the [max_page_count] [PRAGMA] - ** in addition to using an authorizer. - ** - ** ^(Only a single authorizer can be in place on a database connection - ** at a time. Each call to sqlite3_set_authorizer overrides the - ** previous call.)^ ^Disable the authorizer by installing a NULL callback. - ** The authorizer is disabled by default. - ** - ** The authorizer callback must not do anything that will modify - ** the database connection that invoked the authorizer callback. - ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their - ** database connections for the meaning of "modify" in this paragraph. - ** - ** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the - ** statement might be re-prepared during [sqlite3_step()] due to a - ** schema change. Hence, the application should ensure that the - ** correct authorizer callback remains in place during the [sqlite3_step()]. - ** - ** ^Note that the authorizer callback is invoked only during - ** [sqlite3_prepare()] or its variants. Authorization is not - ** performed during statement evaluation in [sqlite3_step()], unless - ** as stated in the previous paragraph, sqlite3_step() invokes - ** sqlite3_prepare_v2() to reprepare a statement after a schema change. - */ - //SQLITE_API int sqlite3_set_authorizer( - // sqlite3*, - // int (*xAuth)(void*,int,const char*,const char*,const char*,const char), - // void *pUserData - //); - - /* - ** CAPI3REF: Authorizer Return Codes - ** - ** The [sqlite3_set_authorizer | authorizer callback function] must - ** return either [SQLITE_OK] or one of these two constants in order - ** to signal SQLite whether or not the action is permitted. See the - ** [sqlite3_set_authorizer | authorizer documentation] for additional - ** information. - ** - ** Note that SQLITE_IGNORE is also used as a [SQLITE_ROLLBACK | return code] - ** from the [sqlite3_vtab_on_conflict()] interface. - */ - //#define SQLITE_DENY 1 /* Abort the SQL statement with an error */ - //#define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */ - const int SQLITE_DENY = 1; - const int SQLITE_IGNORE = 2; - - /* - ** CAPI3REF: Authorizer Action Codes - ** - ** The [sqlite3_set_authorizer()] interface registers a callback function - ** that is invoked to authorize certain SQL statement actions. The - ** second parameter to the callback is an integer code that specifies - ** what action is being authorized. These are the integer action codes that - ** the authorizer callback may be passed. - ** - ** These action code values signify what kind of operation is to be - ** authorized. The 3rd and 4th parameters to the authorization - ** callback function will be parameters or NULL depending on which of these - ** codes is used as the second parameter. ^(The 5th parameter to the - ** authorizer callback is the name of the database ("main", "temp", - ** etc.) if applicable.)^ ^The 6th parameter to the authorizer callback - ** is the name of the inner-most trigger or view that is responsible for - ** the access attempt or NULL if this access attempt is directly from - ** top-level SQL code. - */ - /******************************************* 3rd ************ 4th ***********/ - //#define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */ - //#define SQLITE_CREATE_TABLE 2 /* Table Name NULL */ - //#define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */ - //#define SQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */ - //#define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */ - //#define SQLITE_CREATE_TEMP_VIEW 6 /* View Name NULL */ - //#define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */ - //#define SQLITE_CREATE_VIEW 8 /* View Name NULL */ - //#define SQLITE_DELETE 9 /* Table Name NULL */ - //#define SQLITE_DROP_INDEX 10 /* Index Name Table Name */ - //#define SQLITE_DROP_TABLE 11 /* Table Name NULL */ - //#define SQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */ - //#define SQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */ - //#define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */ - //#define SQLITE_DROP_TEMP_VIEW 15 /* View Name NULL */ - //#define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */ - //#define SQLITE_DROP_VIEW 17 /* View Name NULL */ - //#define SQLITE_INSERT 18 /* Table Name NULL */ - //#define SQLITE_PRAGMA 19 /* Pragma Name 1st arg or NULL */ - //#define SQLITE_READ 20 /* Table Name Column Name */ - //#define SQLITE_SELECT 21 /* NULL NULL */ - //#define SQLITE_TRANSACTION 22 /* Operation NULL */ - //#define SQLITE_UPDATE 23 /* Table Name Column Name */ - //#define SQLITE_ATTACH 24 /* Filename NULL */ - //#define SQLITE_DETACH 25 /* Database Name NULL */ - //#define SQLITE_ALTER_TABLE 26 /* Database Name Table Name */ - //#define SQLITE_REINDEX 27 /* Index Name NULL */ - //#define SQLITE_ANALYZE 28 /* Table Name NULL */ - //#define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */ - //#define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */ - //#define SQLITE_FUNCTION 31 /* NULL Function Name */ - //#define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */ - //#define SQLITE_COPY 0 /* No longer used */ - const int SQLITE_CREATE_INDEX = 1; - const int SQLITE_CREATE_TABLE = 2; - const int SQLITE_CREATE_TEMP_INDEX = 3; - const int SQLITE_CREATE_TEMP_TABLE = 4; - const int SQLITE_CREATE_TEMP_TRIGGER = 5; - const int SQLITE_CREATE_TEMP_VIEW = 6; - const int SQLITE_CREATE_TRIGGER = 7; - const int SQLITE_CREATE_VIEW = 8; - const int SQLITE_DELETE = 9; - const int SQLITE_DROP_INDEX = 10; - const int SQLITE_DROP_TABLE = 11; - const int SQLITE_DROP_TEMP_INDEX = 12; - const int SQLITE_DROP_TEMP_TABLE = 13; - const int SQLITE_DROP_TEMP_TRIGGER = 14; - const int SQLITE_DROP_TEMP_VIEW = 15; - const int SQLITE_DROP_TRIGGER = 16; - const int SQLITE_DROP_VIEW = 17; - const int SQLITE_INSERT = 18; - const int SQLITE_PRAGMA = 19; - const int SQLITE_READ = 20; - const int SQLITE_SELECT = 21; - const int SQLITE_TRANSACTION = 22; - const int SQLITE_UPDATE = 23; - const int SQLITE_ATTACH = 24; - const int SQLITE_DETACH = 25; - const int SQLITE_ALTER_TABLE = 26; - const int SQLITE_REINDEX = 27; - const int SQLITE_ANALYZE = 28; - const int SQLITE_CREATE_VTABLE = 29; - const int SQLITE_DROP_VTABLE = 30; - const int SQLITE_FUNCTION = 31; - const int SQLITE_SAVEPOINT = 32; - const int SQLITE_COPY = 0; - - /* - ** CAPI3REF: Tracing And Profiling Functions - ** - ** These routines register callback functions that can be used for - ** tracing and profiling the execution of SQL statements. - ** - ** ^The callback function registered by sqlite3_trace() is invoked at - ** various times when an SQL statement is being run by [sqlite3_step()]. - ** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the - ** SQL statement text as the statement first begins executing. - ** ^(Additional sqlite3_trace() callbacks might occur - ** as each triggered subprogram is entered. The callbacks for triggers - ** contain a UTF-8 SQL comment that identifies the trigger.)^ - ** - ** ^The callback function registered by sqlite3_profile() is invoked - ** as each SQL statement finishes. ^The profile callback contains - ** the original statement text and an estimate of wall-clock time - ** of how long that statement took to run. ^The profile callback - ** time is in units of nanoseconds, however the current implementation - ** is only capable of millisecond resolution so the six least significant - ** digits in the time are meaningless. Future versions of SQLite - ** might provide greater resolution on the profiler callback. The - ** sqlite3_profile() function is considered experimental and is - ** subject to change in future versions of SQLite. - */ - //SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char), void); - //SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*, - // void(*xProfile)(void*,const char*,sqlite3_uint64), void); - - /* - ** CAPI3REF: Query Progress Callbacks - ** - ** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback - ** function X to be invoked periodically during long running calls to - ** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for - ** database connection D. An example use for this - ** interface is to keep a GUI updated during a large query. - ** - ** ^The parameter P is passed through as the only parameter to the - ** callback function X. ^The parameter N is the number of - ** [virtual machine instructions] that are evaluated between successive - ** invocations of the callback X. - ** - ** ^Only a single progress handler may be defined at one time per - ** [database connection]; setting a new progress handler cancels the - ** old one. ^Setting parameter X to NULL disables the progress handler. - ** ^The progress handler is also disabled by setting N to a value less - ** than 1. - ** - ** ^If the progress callback returns non-zero, the operation is - ** interrupted. This feature can be used to implement a - ** "Cancel" button on a GUI progress dialog box. - ** - ** The progress handler callback must not do anything that will modify - ** the database connection that invoked the progress handler. - ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their - ** database connections for the meaning of "modify" in this paragraph. - ** - */ - //SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int()(void), void); - - /* - ** CAPI3REF: Opening A New Database Connection - ** - ** ^These routines open an SQLite database file as specified by the - ** filename argument. ^The filename argument is interpreted as UTF-8 for - ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte - ** order for sqlite3_open16(). ^(A [database connection] handle is usually - ** returned in *ppDb, even if an error occurs. The only exception is that - ** if SQLite is unable to allocate memory to hold the [sqlite3] object, - ** a NULL will be written into *ppDb instead of a pointer to the [sqlite3] - ** object.)^ ^(If the database is opened (and/or created) successfully, then - ** [SQLITE_OK] is returned. Otherwise an [error code] is returned.)^ ^The - ** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain - ** an English language description of the error following a failure of any - ** of the sqlite3_open() routines. - ** - ** ^The default encoding for the database will be UTF-8 if - ** sqlite3_open() or sqlite3_open_v2() is called and - ** UTF-16 in the native byte order if sqlite3_open16() is used. - ** - ** Whether or not an error occurs when it is opened, resources - ** associated with the [database connection] handle should be released by - ** passing it to [sqlite3_close()] when it is no longer required. - ** - ** The sqlite3_open_v2() interface works like sqlite3_open() - ** except that it accepts two additional parameters for additional control - ** over the new database connection. ^(The flags parameter to - ** sqlite3_open_v2() can take one of - ** the following three values, optionally combined with the - ** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE], - ** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^ - ** - **
- ** ^(
[SQLITE_OPEN_READONLY]
- **
The database is opened in read-only mode. If the database does not - ** already exist, an error is returned.
)^ - ** - ** ^(
[SQLITE_OPEN_READWRITE]
- **
The database is opened for reading and writing if possible, or reading - ** only if the file is write protected by the operating system. In either - ** case the database must already exist, otherwise an error is returned.
)^ - ** - ** ^(
[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]
- **
The database is opened for reading and writing, and is created if - ** it does not already exist. This is the behavior that is always used for - ** sqlite3_open() and sqlite3_open16().
)^ - **
- ** - ** If the 3rd parameter to sqlite3_open_v2() is not one of the - ** combinations shown above optionally combined with other - ** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits] - ** then the behavior is undefined. - ** - ** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection - ** opens in the multi-thread [threading mode] as long as the single-thread - ** mode has not been set at compile-time or start-time. ^If the - ** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens - ** in the serialized [threading mode] unless single-thread was - ** previously selected at compile-time or start-time. - ** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be - ** eligible to use [shared cache mode], regardless of whether or not shared - ** cache is enabled using [sqlite3_enable_shared_cache()]. ^The - ** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not - ** participate in [shared cache mode] even if it is enabled. - ** - ** ^The fourth parameter to sqlite3_open_v2() is the name of the - ** [sqlite3_vfs] object that defines the operating system interface that - ** the new database connection should use. ^If the fourth parameter is - ** a NULL pointer then the default [sqlite3_vfs] object is used. - ** - ** ^If the filename is ":memory:", then a private, temporary in-memory database - ** is created for the connection. ^This in-memory database will vanish when - ** the database connection is closed. Future versions of SQLite might - ** make use of additional special filenames that begin with the ":" character. - ** It is recommended that when a database filename actually does begin with - ** a ":" character you should prefix the filename with a pathname such as - ** "./" to avoid ambiguity. - ** - ** ^If the filename is an empty string, then a private, temporary - ** on-disk database will be created. ^This private database will be - ** automatically deleted as soon as the database connection is closed. - ** - ** [[URI filenames in sqlite3_open()]]

URI Filenames

- ** - ** ^If [URI filename] interpretation is enabled, and the filename argument - ** begins with "file:", then the filename is interpreted as a URI. ^URI - ** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is - ** set in the fourth argument to sqlite3_open_v2(), or if it has - ** been enabled globally using the [SQLITE_CONFIG_URI] option with the - ** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option. - ** As of SQLite version 3.7.7, URI filename interpretation is turned off - ** by default, but future releases of SQLite might enable URI filename - ** interpretation by default. See "[URI filenames]" for additional - ** information. - ** - ** URI filenames are parsed according to RFC 3986. ^If the URI contains an - ** authority, then it must be either an empty string or the string - ** "localhost". ^If the authority is not an empty string or "localhost", an - ** error is returned to the caller. ^The fragment component of a URI, if - ** present, is ignored. - ** - ** ^SQLite uses the path component of the URI as the name of the disk file - ** which contains the database. ^If the path begins with a '/' character, - ** then it is interpreted as an absolute path. ^If the path does not begin - ** with a '/' (meaning that the authority section is omitted from the URI) - ** then the path is interpreted as a relative path. - ** ^On windows, the first component of an absolute path - ** is a drive specification (e.g. "C:"). - ** - ** [[core URI query parameters]] - ** The query component of a URI may contain parameters that are interpreted - ** either by SQLite itself, or by a [VFS | custom VFS implementation]. - ** SQLite interprets the following three query parameters: - ** - **
    - **
  • vfs: ^The "vfs" parameter may be used to specify the name of - ** a VFS object that provides the operating system interface that should - ** be used to access the database file on disk. ^If this option is set to - ** an empty string the default VFS object is used. ^Specifying an unknown - ** VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is - ** present, then the VFS specified by the option takes precedence over - ** the value passed as the fourth parameter to sqlite3_open_v2(). - ** - **
  • mode: ^(The mode parameter may be set to either "ro", "rw" or - ** "rwc". Attempting to set it to any other value is an error)^. - ** ^If "ro" is specified, then the database is opened for read-only - ** access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the - ** third argument to sqlite3_prepare_v2(). ^If the mode option is set to - ** "rw", then the database is opened for read-write (but not create) - ** access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had - ** been set. ^Value "rwc" is equivalent to setting both - ** SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE. ^If sqlite3_open_v2() is - ** used, it is an error to specify a value for the mode parameter that is - ** less restrictive than that specified by the flags passed as the third - ** parameter. - ** - **
  • cache: ^The cache parameter may be set to either "shared" or - ** "private". ^Setting it to "shared" is equivalent to setting the - ** SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to - ** sqlite3_open_v2(). ^Setting the cache parameter to "private" is - ** equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit. - ** ^If sqlite3_open_v2() is used and the "cache" parameter is present in - ** a URI filename, its value overrides any behaviour requested by setting - ** SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag. - **
- ** - ** ^Specifying an unknown parameter in the query component of a URI is not an - ** error. Future versions of SQLite might understand additional query - ** parameters. See "[query parameters with special meaning to SQLite]" for - ** additional information. - ** - ** [[URI filename examples]]

URI filename examples

- ** - ** - **
URI filenames Results - **
file:data.db - ** Open the file "data.db" in the current directory. - **
file:/home/fred/data.db
- ** file:///home/fred/data.db
- ** file://localhost/home/fred/data.db
- ** Open the database file "/home/fred/data.db". - **
file://darkstar/home/fred/data.db - ** An error. "darkstar" is not a recognized authority. - **
- ** file:///C:/Documents%20and%20Settings/fred/Desktop/data.db - ** Windows only: Open the file "data.db" on fred's desktop on drive - ** C:. Note that the %20 escaping in this example is not strictly - ** necessary - space characters can be used literally - ** in URI filenames. - **
file:data.db?mode=ro&cache=private - ** Open file "data.db" in the current directory for read-only access. - ** Regardless of whether or not shared-cache mode is enabled by - ** default, use a private cache. - **
file:/home/fred/data.db?vfs=unix-nolock - ** Open file "/home/fred/data.db". Use the special VFS "unix-nolock". - **
file:data.db?mode=readonly - ** An error. "readonly" is not a valid option for the "mode" parameter. - **
- ** - ** ^URI hexadecimal escape sequences (%HH) are supported within the path and - ** query components of a URI. A hexadecimal escape sequence consists of a - ** percent sign - "%" - followed by exactly two hexadecimal digits - ** specifying an octet value. ^Before the path or query components of a - ** URI filename are interpreted, they are encoded using UTF-8 and all - ** hexadecimal escape sequences replaced by a single byte containing the - ** corresponding octet. If this process generates an invalid UTF-8 encoding, - ** the results are undefined. - ** - ** Note to Windows users: The encoding used for the filename argument - ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever - ** codepage is currently defined. Filenames containing international - ** characters must be converted to UTF-8 prior to passing them into - ** sqlite3_open() or sqlite3_open_v2(). - */ - //SQLITE_API int sqlite3_open( - // string filename, /* Database filename (UTF-8) */ - // sqlite3 **ppDb /* OUT: SQLite db handle */ - //); - //SQLITE_API int sqlite3_open16( - // const void *filename, /* Database filename (UTF-16) */ - // sqlite3 **ppDb /* OUT: SQLite db handle */ - //); - //SQLITE_API int sqlite3_open_v2( - // string filename, /* Database filename (UTF-8) */ - // sqlite3 **ppDb, /* OUT: SQLite db handle */ - // int flags, /* Flags */ - // string zVfs /* Name of VFS module to use */ - //); - - /* - ** CAPI3REF: Obtain Values For URI Parameters - ** - ** This is a utility routine, useful to VFS implementations, that checks - ** to see if a database file was a URI that contained a specific query - ** parameter, and if so obtains the value of the query parameter. - ** - ** The zFilename argument is the filename pointer passed into the xOpen() - ** method of a VFS implementation. The zParam argument is the name of the - ** query parameter we seek. This routine returns the value of the zParam - ** parameter if it exists. If the parameter does not exist, this routine - ** returns a NULL pointer. - ** - ** If the zFilename argument to this function is not a pointer that SQLite - ** passed into the xOpen VFS method, then the behavior of this routine - ** is undefined and probably undesirable. - */ - //SQLITE_API string sqlite3_uri_parameter(string zFilename, string zParam); - - - /* - ** CAPI3REF: Error Codes And Messages - ** - ** ^The sqlite3_errcode() interface returns the numeric [result code] or - ** [extended result code] for the most recent failed sqlite3_* API call - ** associated with a [database connection]. If a prior API call failed - ** but the most recent API call succeeded, the return value from - ** sqlite3_errcode() is undefined. ^The sqlite3_extended_errcode() - ** interface is the same except that it always returns the - ** [extended result code] even when extended result codes are - ** disabled. - ** - ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language - ** text that describes the error, as either UTF-8 or UTF-16 respectively. - ** ^(Memory to hold the error message string is managed internally. - ** The application does not need to worry about freeing the result. - ** However, the error string might be overwritten or deallocated by - ** subsequent calls to other SQLite interface functions.)^ - ** - ** When the serialized [threading mode] is in use, it might be the - ** case that a second error occurs on a separate thread in between - ** the time of the first error and the call to these interfaces. - ** When that happens, the second error will be reported since these - ** interfaces always report the most recent result. To avoid - ** this, each thread can obtain exclusive use of the [database connection] D - ** by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning - ** to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after - ** all calls to the interfaces listed here are completed. - ** - ** If an interface fails with SQLITE_MISUSE, that means the interface - ** was invoked incorrectly by the application. In that case, the - ** error code and message may or may not be set. - */ - //SQLITE_API int sqlite3_errcode(sqlite3 db); - //SQLITE_API int sqlite3_extended_errcode(sqlite3 db); - //SQLITE_API string sqlite3_errmsg(sqlite3); - //SQLITE_API const void *sqlite3_errmsg16(sqlite3); - - /* - ** CAPI3REF: SQL Statement Object - ** KEYWORDS: {prepared statement} {prepared statements} - ** - ** An instance of this object represents a single SQL statement. - ** This object is variously known as a "prepared statement" or a - ** "compiled SQL statement" or simply as a "statement". - ** - ** The life of a statement object goes something like this: - ** - **
    - **
  1. Create the object using [sqlite3_prepare_v2()] or a related - ** function. - **
  2. Bind values to [host parameters] using the sqlite3_bind_*() - ** interfaces. - **
  3. Run the SQL by calling [sqlite3_step()] one or more times. - **
  4. Reset the statement using [sqlite3_reset()] then go back - ** to step 2. Do this zero or more times. - **
  5. Destroy the object using [sqlite3_finalize()]. - **
- ** - ** Refer to documentation on individual methods above for additional - ** information. - */ - //typedef struct sqlite3_stmt sqlite3_stmt; - - /* - ** CAPI3REF: Run-time Limits - ** - ** ^(This interface allows the size of various constructs to be limited - ** on a connection by connection basis. The first parameter is the - ** [database connection] whose limit is to be set or queried. The - ** second parameter is one of the [limit categories] that define a - ** class of constructs to be size limited. The third parameter is the - ** new limit for that construct.)^ - ** - ** ^If the new limit is a negative number, the limit is unchanged. - ** ^(For each limit category SQLITE_LIMIT_NAME there is a - ** [limits | hard upper bound] - ** set at compile-time by a C preprocessor macro called - ** [limits | SQLITE_MAX_NAME]. - ** (The "_LIMIT_" in the name is changed to "_MAX_".))^ - ** ^Attempts to increase a limit above its hard upper bound are - ** silently truncated to the hard upper bound. - ** - ** ^Regardless of whether or not the limit was changed, the - ** [sqlite3_limit()] interface returns the prior value of the limit. - ** ^Hence, to find the current value of a limit without changing it, - ** simply invoke this interface with the third parameter set to -1. - ** - ** Run-time limits are intended for use in applications that manage - ** both their own internal database and also databases that are controlled - ** by untrusted external sources. An example application might be a - ** web browser that has its own databases for storing history and - ** separate databases controlled by JavaScript applications downloaded - ** off the Internet. The internal databases can be given the - ** large, default limits. Databases managed by external sources can - ** be given much smaller limits designed to prevent a denial of service - ** attack. Developers might also want to use the [sqlite3_set_authorizer()] - ** interface to further control untrusted SQL. The size of the database - ** created by an untrusted script can be contained using the - ** [max_page_count] [PRAGMA]. - ** - ** New run-time limit categories may be added in future releases. - */ - //SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); - - /* - ** CAPI3REF: Run-Time Limit Categories - ** KEYWORDS: {limit category} {*limit categories} - ** - ** These constants define various performance limits - ** that can be lowered at run-time using [sqlite3_limit()]. - ** The synopsis of the meanings of the various limits is shown below. - ** Additional information is available at [limits | Limits in SQLite]. - ** - **
- ** [[SQLITE_LIMIT_LENGTH]] ^(
SQLITE_LIMIT_LENGTH
- **
The maximum size of any string or BLOB or table row, in bytes.
)^ - ** - ** [[SQLITE_LIMIT_SQL_LENGTH]] ^(
SQLITE_LIMIT_SQL_LENGTH
- **
The maximum length of an SQL statement, in bytes.
)^ - ** - ** [[SQLITE_LIMIT_COLUMN]] ^(
SQLITE_LIMIT_COLUMN
- **
The maximum number of columns in a table definition or in the - ** result set of a [SELECT] or the maximum number of columns in an index - ** or in an ORDER BY or GROUP BY clause.
)^ - ** - ** [[SQLITE_LIMIT_EXPR_DEPTH]] ^(
SQLITE_LIMIT_EXPR_DEPTH
- **
The maximum depth of the parse tree on any expression.
)^ - ** - ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(
SQLITE_LIMIT_COMPOUND_SELECT
- **
The maximum number of terms in a compound SELECT statement.
)^ - ** - ** [[SQLITE_LIMIT_VDBE_OP]] ^(
SQLITE_LIMIT_VDBE_OP
- **
The maximum number of instructions in a virtual machine program - ** used to implement an SQL statement. This limit is not currently - ** enforced, though that might be added in some future release of - ** SQLite.
)^ - ** - ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(
SQLITE_LIMIT_FUNCTION_ARG
- **
The maximum number of arguments on a function.
)^ - ** - ** [[SQLITE_LIMIT_ATTACHED]] ^(
SQLITE_LIMIT_ATTACHED
- **
The maximum number of [ATTACH | attached databases].)^
- ** - ** [[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]] - ** ^(
SQLITE_LIMIT_LIKE_PATTERN_LENGTH
- **
The maximum length of the pattern argument to the [LIKE] or - ** [GLOB] operators.
)^ - ** - ** [[SQLITE_LIMIT_VARIABLE_NUMBER]] - ** ^(
SQLITE_LIMIT_VARIABLE_NUMBER
- **
The maximum index number of any [parameter] in an SQL statement.)^ - ** - ** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(
SQLITE_LIMIT_TRIGGER_DEPTH
- **
The maximum depth of recursion for triggers.
)^ - **
- */ - //#define SQLITE_LIMIT_LENGTH 0 - //#define SQLITE_LIMIT_SQL_LENGTH 1 - //#define SQLITE_LIMIT_COLUMN 2 - //#define SQLITE_LIMIT_EXPR_DEPTH 3 - //#define SQLITE_LIMIT_COMPOUND_SELECT 4 - //#define SQLITE_LIMIT_VDBE_OP 5 - //#define SQLITE_LIMIT_FUNCTION_ARG 6 - //#define SQLITE_LIMIT_ATTACHED 7 - //#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8 - //#define SQLITE_LIMIT_VARIABLE_NUMBER 9 - //#define SQLITE_LIMIT_TRIGGER_DEPTH 10 - const int SQLITE_LIMIT_LENGTH = 0; - const int SQLITE_LIMIT_SQL_LENGTH = 1; - const int SQLITE_LIMIT_COLUMN = 2; - const int SQLITE_LIMIT_EXPR_DEPTH = 3; - const int SQLITE_LIMIT_COMPOUND_SELECT = 4; - const int SQLITE_LIMIT_VDBE_OP = 5; - const int SQLITE_LIMIT_FUNCTION_ARG = 6; - const int SQLITE_LIMIT_ATTACHED = 7; - const int SQLITE_LIMIT_LIKE_PATTERN_LENGTH = 8; - const int SQLITE_LIMIT_VARIABLE_NUMBER = 9; - const int SQLITE_LIMIT_TRIGGER_DEPTH = 10; - - /* - ** CAPI3REF: Compiling An SQL Statement - ** KEYWORDS: {SQL statement compiler} - ** - ** To execute an SQL query, it must first be compiled into a byte-code - ** program using one of these routines. - ** - ** The first argument, "db", is a [database connection] obtained from a - ** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or - ** [sqlite3_open16()]. The database connection must not have been closed. - ** - ** The second argument, "zSql", is the statement to be compiled, encoded - ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() - ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2() - ** use UTF-16. - ** - ** ^If the nByte argument is less than zero, then zSql is read up to the - ** first zero terminator. ^If nByte is non-negative, then it is the maximum - ** number of bytes read from zSql. ^When nByte is non-negative, the - ** zSql string ends at either the first '\000' or '\u0000' character or - ** the nByte-th byte, whichever comes first. If the caller knows - ** that the supplied string is nul-terminated, then there is a small - ** performance advantage to be gained by passing an nByte parameter that - ** is equal to the number of bytes in the input string including - ** the nul-terminator bytes. - ** - ** ^If pzTail is not NULL then *pzTail is made to point to the first byte - ** past the end of the first SQL statement in zSql. These routines only - ** compile the first statement in zSql, so *pzTail is left pointing to - ** what remains uncompiled. - ** - ** ^*ppStmt is left pointing to a compiled [prepared statement] that can be - ** executed using [sqlite3_step()]. ^If there is an error, *ppStmt is set - ** to NULL. ^If the input text contains no SQL (if the input is an empty - ** string or a comment) then *ppStmt is set to NULL. - ** The calling procedure is responsible for deleting the compiled - ** SQL statement using [sqlite3_finalize()] after it has finished with it. - ** ppStmt may not be NULL. - ** - ** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK]; - ** otherwise an [error code] is returned. - ** - ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are - ** recommended for all new programs. The two older interfaces are retained - ** for backwards compatibility, but their use is discouraged. - ** ^In the "v2" interfaces, the prepared statement - ** that is returned (the [sqlite3_stmt] object) contains a copy of the - ** original SQL text. This causes the [sqlite3_step()] interface to - ** behave differently in three ways: - ** - **
    - **
  1. - ** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it - ** always used to do, [sqlite3_step()] will automatically recompile the SQL - ** statement and try to run it again. - **
  2. - ** - **
  3. - ** ^When an error occurs, [sqlite3_step()] will return one of the detailed - ** [error codes] or [extended error codes]. ^The legacy behavior was that - ** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code - ** and the application would have to make a second call to [sqlite3_reset()] - ** in order to find the underlying cause of the problem. With the "v2" prepare - ** interfaces, the underlying reason for the error is returned immediately. - **
  4. - ** - **
  5. - ** ^If the specific value bound to [parameter | host parameter] in the - ** WHERE clause might influence the choice of query plan for a statement, - ** then the statement will be automatically recompiled, as if there had been - ** a schema change, on the first [sqlite3_step()] call following any change - ** to the [sqlite3_bind_text | bindings] of that [parameter]. - ** ^The specific value of WHERE-clause [parameter] might influence the - ** choice of query plan if the parameter is the left-hand side of a [LIKE] - ** or [GLOB] operator or if the parameter is compared to an indexed column - ** and the [SQLITE_ENABLE_STAT2] compile-time option is enabled. - ** the - **
  6. - **
- */ - //SQLITE_API int sqlite3_prepare( - // sqlite3 db, /* Database handle */ - // string zSql, /* SQL statement, UTF-8 encoded */ - // int nByte, /* Maximum length of zSql in bytes. */ - // sqlite3_stmt **ppStmt, /* OUT: Statement handle */ - // string *pzTail /* OUT: Pointer to unused portion of zSql */ - //); - //SQLITE_API int sqlite3_prepare_v2( - // sqlite3 db, /* Database handle */ - // string zSql, /* SQL statement, UTF-8 encoded */ - // int nByte, /* Maximum length of zSql in bytes. */ - // sqlite3_stmt **ppStmt, /* OUT: Statement handle */ - // string *pzTail /* OUT: Pointer to unused portion of zSql */ - //); - //SQLITE_API int sqlite3_prepare16( - // sqlite3 db, /* Database handle */ - // string zSql, /* SQL statement, UTF-16 encoded */ - // int nByte, /* Maximum length of zSql in bytes. */ - // sqlite3_stmt **ppStmt, /* OUT: Statement handle */ - // const void **pzTail /* OUT: Pointer to unused portion of zSql */ - //); - //SQLITE_API int sqlite3_prepare16_v2( - // sqlite3 db, /* Database handle */ - // string zSql, /* SQL statement, UTF-16 encoded */ - // int nByte, /* Maximum length of zSql in bytes. */ - // sqlite3_stmt **ppStmt, /* OUT: Statement handle */ - // const void **pzTail /* OUT: Pointer to unused portion of zSql */ - //); - - /* - ** CAPI3REF: Retrieving Statement SQL - ** - ** ^This interface can be used to retrieve a saved copy of the original - ** SQL text used to create a [prepared statement] if that statement was - ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()]. - */ - //SQLITE_API string sqlite3_sql(sqlite3_stmt *pStmt); - - /* - ** CAPI3REF: Determine If An SQL Statement Writes The Database - ** - ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if - ** and only if the [prepared statement] X makes no direct changes to - ** the content of the database file. - ** - ** Note that [application-defined SQL functions] or - ** [virtual tables] might change the database indirectly as a side effect. - ** ^(For example, if an application defines a function "eval()" that - ** calls [sqlite3_exec()], then the following SQL statement would - ** change the database file through side-effects: - ** - **
-        **    SELECT eval('DELETE FROM t1') FROM t2;
-        ** 
- ** - ** But because the [SELECT] statement does not change the database file - ** directly, sqlite3_stmt_readonly() would still return true.)^ - ** - ** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK], - ** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true, - ** since the statements themselves do not actually modify the database but - ** rather they control the timing of when other statements modify the - ** database. ^The [ATTACH] and [DETACH] statements also cause - ** sqlite3_stmt_readonly() to return true since, while those statements - ** change the configuration of a database connection, they do not make - ** changes to the content of the database files on disk. - */ - //SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); - - /* - ** CAPI3REF: Dynamically Typed Value Object - ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value} - ** - ** SQLite uses the sqlite3_value object to represent all values - ** that can be stored in a database table. SQLite uses dynamic typing - ** for the values it stores. ^Values stored in sqlite3_value objects - ** can be integers, floating point values, strings, BLOBs, or NULL. - ** - ** An sqlite3_value object may be either "protected" or "unprotected". - ** Some interfaces require a protected sqlite3_value. Other interfaces - ** will accept either a protected or an unprotected sqlite3_value. - ** Every interface that accepts sqlite3_value arguments specifies - ** whether or not it requires a protected sqlite3_value. - ** - ** The terms "protected" and "unprotected" refer to whether or not - ** a mutex is held. An internal mutex is held for a protected - ** sqlite3_value object but no mutex is held for an unprotected - ** sqlite3_value object. If SQLite is compiled to be single-threaded - ** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0) - ** or if SQLite is run in one of reduced mutex modes - ** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD] - ** then there is no distinction between protected and unprotected - ** sqlite3_value objects and they can be used interchangeably. However, - ** for maximum code portability it is recommended that applications - ** still make the distinction between protected and unprotected - ** sqlite3_value objects even when not strictly required. - ** - ** ^The sqlite3_value objects that are passed as parameters into the - ** implementation of [application-defined SQL functions] are protected. - ** ^The sqlite3_value object returned by - ** [sqlite3_column_value()] is unprotected. - ** Unprotected sqlite3_value objects may only be used with - ** [sqlite3_result_value()] and [sqlite3_bind_value()]. - ** The [sqlite3_value_blob | sqlite3_value_type()] family of - ** interfaces require protected sqlite3_value objects. - */ - //typedef struct Mem sqlite3_value; - - /* - ** CAPI3REF: SQL Function Context Object - ** - ** The context in which an SQL function executes is stored in an - ** sqlite3_context object. ^A pointer to an sqlite3_context object - ** is always first parameter to [application-defined SQL functions]. - ** The application-defined SQL function implementation will pass this - ** pointer through into calls to [sqlite3_result_int | sqlite3_result()], - ** [sqlite3_aggregate_context()], [sqlite3_user_data()], - ** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()], - ** and/or [sqlite3_set_auxdata()]. - */ - //typedef struct sqlite3_context sqlite3_context; - - /* - ** CAPI3REF: Binding Values To Prepared Statements - ** KEYWORDS: {host parameter} {host parameters} {host parameter name} - ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding} - ** - ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants, - ** literals may be replaced by a [parameter] that matches one of following - ** templates: - ** - **
    - **
  • ? - **
  • ?NNN - **
  • :VVV - **
  • @VVV - **
  • $VVV - **
- ** - ** In the templates above, NNN represents an integer literal, - ** and VVV represents an alphanumeric identifier.)^ ^The values of these - ** parameters (also called "host parameter names" or "SQL parameters") - ** can be set using the sqlite3_bind_*() routines defined here. - ** - ** ^The first argument to the sqlite3_bind_*() routines is always - ** a pointer to the [sqlite3_stmt] object returned from - ** [sqlite3_prepare_v2()] or its variants. - ** - ** ^The second argument is the index of the SQL parameter to be set. - ** ^The leftmost SQL parameter has an index of 1. ^When the same named - ** SQL parameter is used more than once, second and subsequent - ** occurrences have the same index as the first occurrence. - ** ^The index for named parameters can be looked up using the - ** [sqlite3_bind_parameter_index()] API if desired. ^The index - ** for "?NNN" parameters is the value of NNN. - ** ^The NNN value must be between 1 and the [sqlite3_limit()] - ** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999). - ** - ** ^The third argument is the value to bind to the parameter. - ** - ** ^(In those routines that have a fourth argument, its value is the - ** number of bytes in the parameter. To be clear: the value is the - ** number of bytes in the value, not the number of characters.)^ - ** ^If the fourth parameter is negative, the length of the string is - ** the number of bytes up to the first zero terminator. - ** - ** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and - ** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or - ** string after SQLite has finished with it. ^The destructor is called - ** to dispose of the BLOB or string even if the call to sqlite3_bind_blob(), - ** sqlite3_bind_text(), or sqlite3_bind_text16() fails. - ** ^If the fifth argument is - ** the special value [SQLITE_STATIC], then SQLite assumes that the - ** information is in static, unmanaged space and does not need to be freed. - ** ^If the fifth argument has the value [SQLITE_TRANSIENT], then - ** SQLite makes its own private copy of the data immediately, before - ** the sqlite3_bind_*() routine returns. - ** - ** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that - ** is filled with zeroes. ^A zeroblob uses a fixed amount of memory - ** (just an integer to hold its size) while it is being processed. - ** Zeroblobs are intended to serve as placeholders for BLOBs whose - ** content is later written using - ** [sqlite3_blob_open | incremental BLOB I/O] routines. - ** ^A negative value for the zeroblob results in a zero-length BLOB. - ** - ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer - ** for the [prepared statement] or with a prepared statement for which - ** [sqlite3_step()] has been called more recently than [sqlite3_reset()], - ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() - ** routine is passed a [prepared statement] that has been finalized, the - ** result is undefined and probably harmful. - ** - ** ^Bindings are not cleared by the [sqlite3_reset()] routine. - ** ^Unbound parameters are interpreted as NULL. - ** - ** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an - ** [error code] if anything goes wrong. - ** ^[SQLITE_RANGE] is returned if the parameter - ** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails. - ** - ** See also: [sqlite3_bind_parameter_count()], - ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()]. - */ - //SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void()(void)); - //SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double); - //SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int); - //SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); - //SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int); - //SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void()(void)); - //SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void()(void)); - //SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value); - //SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); - - /* - ** CAPI3REF: Number Of SQL Parameters - ** - ** ^This routine can be used to find the number of [SQL parameters] - ** in a [prepared statement]. SQL parameters are tokens of the - ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as - ** placeholders for values that are [sqlite3_bind_blob | bound] - ** to the parameters at a later time. - ** - ** ^(This routine actually returns the index of the largest (rightmost) - ** parameter. For all forms except ?NNN, this will correspond to the - ** number of unique parameters. If parameters of the ?NNN form are used, - ** there may be gaps in the list.)^ - ** - ** See also: [sqlite3_bind_blob|sqlite3_bind()], - ** [sqlite3_bind_parameter_name()], and - ** [sqlite3_bind_parameter_index()]. - */ - //SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt); - - /* - ** CAPI3REF: Name Of A Host Parameter - ** - ** ^The sqlite3_bind_parameter_name(P,N) interface returns - ** the name of the N-th [SQL parameter] in the [prepared statement] P. - ** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA" - ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA" - ** respectively. - ** In other words, the initial ":" or "$" or "@" or "?" - ** is included as part of the name.)^ - ** ^Parameters of the form "?" without a following integer have no name - ** and are referred to as "nameless" or "anonymous parameters". - ** - ** ^The first host parameter has an index of 1, not 0. - ** - ** ^If the value N is out of range or if the N-th parameter is - ** nameless, then NULL is returned. ^The returned string is - ** always in UTF-8 encoding even if the named parameter was - ** originally specified as UTF-16 in [sqlite3_prepare16()] or - ** [sqlite3_prepare16_v2()]. - ** - ** See also: [sqlite3_bind_blob|sqlite3_bind()], - ** [sqlite3_bind_parameter_count()], and - ** [sqlite3_bind_parameter_index()]. - */ - //SQLITE_API string sqlite3_bind_parameter_name(sqlite3_stmt*, int); - - /* - ** CAPI3REF: Index Of A Parameter With A Given Name - ** - ** ^Return the index of an SQL parameter given its name. ^The - ** index value returned is suitable for use as the second - ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero - ** is returned if no matching parameter is found. ^The parameter - ** name must be given in UTF-8 even if the original statement - ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()]. - ** - ** See also: [sqlite3_bind_blob|sqlite3_bind()], - ** [sqlite3_bind_parameter_count()], and - ** [sqlite3_bind_parameter_index()]. - */ - //SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, string zName); - - /* - ** CAPI3REF: Reset All Bindings On A Prepared Statement - ** - ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset - ** the [sqlite3_bind_blob | bindings] on a [prepared statement]. - ** ^Use this routine to reset all host parameters to NULL. - */ - //SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt); - - /* - ** CAPI3REF: Number Of Columns In A Result Set - ** - ** ^Return the number of columns in the result set returned by the - ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL - ** statement that does not return data (for example an [UPDATE]). - ** - ** See also: [sqlite3_data_count()] - */ - //SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt); - - /* - ** CAPI3REF: Column Names In A Result Set - ** - ** ^These routines return the name assigned to a particular column - ** in the result set of a [SELECT] statement. ^The sqlite3_column_name() - ** interface returns a pointer to a zero-terminated UTF-8 string - ** and sqlite3_column_name16() returns a pointer to a zero-terminated - ** UTF-16 string. ^The first parameter is the [prepared statement] - ** that implements the [SELECT] statement. ^The second parameter is the - ** column number. ^The leftmost column is number 0. - ** - ** ^The returned string pointer is valid until either the [prepared statement] - ** is destroyed by [sqlite3_finalize()] or until the statement is automatically - ** reprepared by the first call to [sqlite3_step()] for a particular run - ** or until the next call to - ** sqlite3_column_name() or sqlite3_column_name16() on the same column. - ** - ** ^If sqlite3_malloc() fails during the processing of either routine - ** (for example during a conversion from UTF-8 to UTF-16) then a - ** NULL pointer is returned. - ** - ** ^The name of a result column is the value of the "AS" clause for - ** that column, if there is an AS clause. If there is no AS clause - ** then the name of the column is unspecified and may change from - ** one release of SQLite to the next. - */ - //SQLITE_API string sqlite3_column_name(sqlite3_stmt*, int N); - //SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N); - - /* - ** CAPI3REF: Source Of Data In A Query Result - ** - ** ^These routines provide a means to determine the database, table, and - ** table column that is the origin of a particular result column in - ** [SELECT] statement. - ** ^The name of the database or table or column can be returned as - ** either a UTF-8 or UTF-16 string. ^The _database_ routines return - ** the database name, the _table_ routines return the table name, and - ** the origin_ routines return the column name. - ** ^The returned string is valid until the [prepared statement] is destroyed - ** using [sqlite3_finalize()] or until the statement is automatically - ** reprepared by the first call to [sqlite3_step()] for a particular run - ** or until the same information is requested - ** again in a different encoding. - ** - ** ^The names returned are the original un-aliased names of the - ** database, table, and column. - ** - ** ^The first argument to these interfaces is a [prepared statement]. - ** ^These functions return information about the Nth result column returned by - ** the statement, where N is the second function argument. - ** ^The left-most column is column 0 for these routines. - ** - ** ^If the Nth column returned by the statement is an expression or - ** subquery and is not a column value, then all of these functions return - ** NULL. ^These routine might also return NULL if a memory allocation error - ** occurs. ^Otherwise, they return the name of the attached database, table, - ** or column that query result column was extracted from. - ** - ** ^As with all other SQLite APIs, those whose names end with "16" return - ** UTF-16 encoded strings and the other functions return UTF-8. - ** - ** ^These APIs are only available if the library was compiled with the - ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol. - ** - ** If two or more threads call one or more of these routines against the same - ** prepared statement and column at the same time then the results are - ** undefined. - ** - ** If two or more threads call one or more - ** [sqlite3_column_database_name | column metadata interfaces] - ** for the same [prepared statement] and result column - ** at the same time then the results are undefined. - */ - //SQLITE_API string sqlite3_column_database_name(sqlite3_stmt*,int); - //SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int); - //SQLITE_API string sqlite3_column_table_name(sqlite3_stmt*,int); - //SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int); - //SQLITE_API string sqlite3_column_origin_name(sqlite3_stmt*,int); - //SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int); - - /* - ** CAPI3REF: Declared Datatype Of A Query Result - ** - ** ^(The first parameter is a [prepared statement]. - ** If this statement is a [SELECT] statement and the Nth column of the - ** returned result set of that [SELECT] is a table column (not an - ** expression or subquery) then the declared type of the table - ** column is returned.)^ ^If the Nth column of the result set is an - ** expression or subquery, then a NULL pointer is returned. - ** ^The returned string is always UTF-8 encoded. - ** - ** ^(For example, given the database schema: - ** - ** CREATE TABLE t1(c1 VARIANT); - ** - ** and the following statement to be compiled: - ** - ** SELECT c1 + 1, c1 FROM t1; - ** - ** this routine would return the string "VARIANT" for the second result - ** column (i==1), and a NULL pointer for the first result column (i==0).)^ - ** - ** ^SQLite uses dynamic run-time typing. ^So just because a column - ** is declared to contain a particular type does not mean that the - ** data stored in that column is of the declared type. SQLite is - ** strongly typed, but the typing is dynamic not static. ^Type - ** is associated with individual values, not with the containers - ** used to hold those values. - */ - //SQLITE_API string sqlite3_column_decltype(sqlite3_stmt*,int); - //SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int); - - /* - ** CAPI3REF: Evaluate An SQL Statement - ** - ** After a [prepared statement] has been prepared using either - ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy - ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function - ** must be called one or more times to evaluate the statement. - ** - ** The details of the behavior of the sqlite3_step() interface depend - ** on whether the statement was prepared using the newer "v2" interface - ** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy - ** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the - ** new "v2" interface is recommended for new applications but the legacy - ** interface will continue to be supported. - ** - ** ^In the legacy interface, the return value will be either [SQLITE_BUSY], - ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE]. - ** ^With the "v2" interface, any of the other [result codes] or - ** [extended result codes] might be returned as well. - ** - ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the - ** database locks it needs to do its job. ^If the statement is a [COMMIT] - ** or occurs outside of an explicit transaction, then you can retry the - ** statement. If the statement is not a [COMMIT] and occurs within an - ** explicit transaction then you should rollback the transaction before - ** continuing. - ** - ** ^[SQLITE_DONE] means that the statement has finished executing - ** successfully. sqlite3_step() should not be called again on this virtual - ** machine without first calling [sqlite3_reset()] to reset the virtual - ** machine back to its initial state. - ** - ** ^If the SQL statement being executed returns any data, then [SQLITE_ROW] - ** is returned each time a new row of data is ready for processing by the - ** caller. The values may be accessed using the [column access functions]. - ** sqlite3_step() is called again to retrieve the next row of data. - ** - ** ^[SQLITE_ERROR] means that a run-time error (such as a constraint - ** violation) has occurred. sqlite3_step() should not be called again on - ** the VM. More information may be found by calling [sqlite3_errmsg()]. - ** ^With the legacy interface, a more specific error code (for example, - ** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth) - ** can be obtained by calling [sqlite3_reset()] on the - ** [prepared statement]. ^In the "v2" interface, - ** the more specific error code is returned directly by sqlite3_step(). - ** - ** [SQLITE_MISUSE] means that the this routine was called inappropriately. - ** Perhaps it was called on a [prepared statement] that has - ** already been [sqlite3_finalize | finalized] or on one that had - ** previously returned [SQLITE_ERROR] or [SQLITE_DONE]. Or it could - ** be the case that the same database connection is being used by two or - ** more threads at the same moment in time. - ** - ** For all versions of SQLite up to and including 3.6.23.1, a call to - ** [sqlite3_reset()] was required after sqlite3_step() returned anything - ** other than [SQLITE_ROW] before any subsequent invocation of - ** sqlite3_step(). Failure to reset the prepared statement using - ** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from - ** sqlite3_step(). But after version 3.6.23.1, sqlite3_step() began - ** calling [sqlite3_reset()] automatically in this circumstance rather - ** than returning [SQLITE_MISUSE]. This is not considered a compatibility - ** break because any application that ever receives an SQLITE_MISUSE error - ** is broken by definition. The [SQLITE_OMIT_AUTORESET] compile-time option - ** can be used to restore the legacy behavior. - ** - ** Goofy Interface Alert: In the legacy interface, the sqlite3_step() - ** API always returns a generic error code, [SQLITE_ERROR], following any - ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call - ** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the - ** specific [error codes] that better describes the error. - ** We admit that this is a goofy design. The problem has been fixed - ** with the "v2" interface. If you prepare all of your SQL statements - ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead - ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces, - ** then the more specific [error codes] are returned directly - ** by sqlite3_step(). The use of the "v2" interface is recommended. - */ - //SQLITE_API int sqlite3_step(sqlite3_stmt); - - /* - ** CAPI3REF: Number of columns in a result set - ** - ** ^The sqlite3_data_count(P) interface returns the number of columns in the - ** current row of the result set of [prepared statement] P. - ** ^If prepared statement P does not have results ready to return - ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of - ** interfaces) then sqlite3_data_count(P) returns 0. - ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer. - ** - ** See also: [sqlite3_column_count()] - */ - //SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); - - /* - ** CAPI3REF: Fundamental Datatypes - ** KEYWORDS: SQLITE_TEXT - ** - ** ^(Every value in SQLite has one of five fundamental datatypes: - ** - **
    - **
  • 64-bit signed integer - **
  • 64-bit IEEE floating point number - **
  • string - **
  • BLOB - **
  • NULL - **
)^ - ** - ** These constants are codes for each of those types. - ** - ** Note that the SQLITE_TEXT constant was also used in SQLite version 2 - ** for a completely different meaning. Software that links against both - ** SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, not - ** SQLITE_TEXT. - */ - //#define SQLITE_INTEGER 1 - //#define SQLITE_FLOAT 2 - //#define SQLITE_BLOB 4 - //#define SQLITE_NULL 5 - //#if SQLITE_TEXT - //# undef SQLITE_TEXT - //#else - //# define SQLITE_TEXT 3 - //#endif - //#define SQLITE3_TEXT 3 - public const u8 SQLITE_INTEGER = 1; - public const u8 SQLITE_FLOAT = 2; - public const u8 SQLITE_BLOB = 4; - public const u8 SQLITE_NULL = 5; - public const u8 SQLITE_TEXT = 3; - public const u8 SQLITE3_TEXT = 3; - - /* - ** CAPI3REF: Result Values From A Query - ** KEYWORDS: {column access functions} - ** - ** These routines form the "result set" interface. - ** - ** ^These routines return information about a single column of the current - ** result row of a query. ^In every case the first argument is a pointer - ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*] - ** that was returned from [sqlite3_prepare_v2()] or one of its variants) - ** and the second argument is the index of the column for which information - ** should be returned. ^The leftmost column of the result set has the index 0. - ** ^The number of columns in the result can be determined using - ** [sqlite3_column_count()]. - ** - ** If the SQL statement does not currently point to a valid row, or if the - ** column index is out of range, the result is undefined. - ** These routines may only be called when the most recent call to - ** [sqlite3_step()] has returned [SQLITE_ROW] and neither - ** [sqlite3_reset()] nor [sqlite3_finalize()] have been called subsequently. - ** If any of these routines are called after [sqlite3_reset()] or - ** [sqlite3_finalize()] or after [sqlite3_step()] has returned - ** something other than [SQLITE_ROW], the results are undefined. - ** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()] - ** are called from a different thread while any of these routines - ** are pending, then the results are undefined. - ** - ** ^The sqlite3_column_type() routine returns the - ** [SQLITE_INTEGER | datatype code] for the initial data type - ** of the result column. ^The returned value is one of [SQLITE_INTEGER], - ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value - ** returned by sqlite3_column_type() is only meaningful if no type - ** conversions have occurred as described below. After a type conversion, - ** the value returned by sqlite3_column_type() is undefined. Future - ** versions of SQLite may change the behavior of sqlite3_column_type() - ** following a type conversion. - ** - ** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes() - ** routine returns the number of bytes in that BLOB or string. - ** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts - ** the string to UTF-8 and then returns the number of bytes. - ** ^If the result is a numeric value then sqlite3_column_bytes() uses - ** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns - ** the number of bytes in that string. - ** ^If the result is NULL, then sqlite3_column_bytes() returns zero. - ** - ** ^If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16() - ** routine returns the number of bytes in that BLOB or string. - ** ^If the result is a UTF-8 string, then sqlite3_column_bytes16() converts - ** the string to UTF-16 and then returns the number of bytes. - ** ^If the result is a numeric value then sqlite3_column_bytes16() uses - ** [sqlite3_snprintf()] to convert that value to a UTF-16 string and returns - ** the number of bytes in that string. - ** ^If the result is NULL, then sqlite3_column_bytes16() returns zero. - ** - ** ^The values returned by [sqlite3_column_bytes()] and - ** [sqlite3_column_bytes16()] do not include the zero terminators at the end - ** of the string. ^For clarity: the values returned by - ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of - ** bytes in the string, not the number of characters. - ** - ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(), - ** even empty strings, are always zero terminated. ^The return - ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer. - ** - ** ^The object returned by [sqlite3_column_value()] is an - ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object - ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()]. - ** If the [unprotected sqlite3_value] object returned by - ** [sqlite3_column_value()] is used in any other way, including calls - ** to routines like [sqlite3_value_int()], [sqlite3_value_text()], - ** or [sqlite3_value_bytes()], then the behavior is undefined. - ** - ** These routines attempt to convert the value where appropriate. ^For - ** example, if the internal representation is FLOAT and a text result - ** is requested, [sqlite3_snprintf()] is used internally to perform the - ** conversion automatically. ^(The following table details the conversions - ** that are applied: - ** - **
- ** - **
Internal
Type
Requested
Type
Conversion - ** - **
NULL INTEGER Result is 0 - **
NULL FLOAT Result is 0.0 - **
NULL TEXT Result is NULL pointer - **
NULL BLOB Result is NULL pointer - **
INTEGER FLOAT Convert from integer to float - **
INTEGER TEXT ASCII rendering of the integer - **
INTEGER BLOB Same as INTEGER->TEXT - **
FLOAT INTEGER Convert from float to integer - **
FLOAT TEXT ASCII rendering of the float - **
FLOAT BLOB Same as FLOAT->TEXT - **
TEXT INTEGER Use atoi() - **
TEXT FLOAT Use atof() - **
TEXT BLOB No change - **
BLOB INTEGER Convert to TEXT then use atoi() - **
BLOB FLOAT Convert to TEXT then use atof() - **
BLOB TEXT Add a zero terminator if needed - **
- **
)^ - ** - ** The table above makes reference to standard C library functions atoi() - ** and atof(). SQLite does not really use these functions. It has its - ** own equivalent internal routines. The atoi() and atof() names are - ** used in the table for brevity and because they are familiar to most - ** C programmers. - ** - ** Note that when type conversions occur, pointers returned by prior - ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or - ** sqlite3_column_text16() may be invalidated. - ** Type conversions and pointer invalidations might occur - ** in the following cases: - ** - **
    - **
  • The initial content is a BLOB and sqlite3_column_text() or - ** sqlite3_column_text16() is called. A zero-terminator might - ** need to be added to the string.
  • - **
  • The initial content is UTF-8 text and sqlite3_column_bytes16() or - ** sqlite3_column_text16() is called. The content must be converted - ** to UTF-16.
  • - **
  • The initial content is UTF-16 text and sqlite3_column_bytes() or - ** sqlite3_column_text() is called. The content must be converted - ** to UTF-8.
  • - **
- ** - ** ^Conversions between UTF-16be and UTF-16le are always done in place and do - ** not invalidate a prior pointer, though of course the content of the buffer - ** that the prior pointer references will have been modified. Other kinds - ** of conversion are done in place when it is possible, but sometimes they - ** are not possible and in those cases prior pointers are invalidated. - ** - ** The safest and easiest to remember policy is to invoke these routines - ** in one of the following ways: - ** - **
    - **
  • sqlite3_column_text() followed by sqlite3_column_bytes()
  • - **
  • sqlite3_column_blob() followed by sqlite3_column_bytes()
  • - **
  • sqlite3_column_text16() followed by sqlite3_column_bytes16()
  • - **
- ** - ** In other words, you should call sqlite3_column_text(), - ** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result - ** into the desired format, then invoke sqlite3_column_bytes() or - ** sqlite3_column_bytes16() to find the size of the result. Do not mix calls - ** to sqlite3_column_text() or sqlite3_column_blob() with calls to - ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16() - ** with calls to sqlite3_column_bytes(). - ** - ** ^The pointers returned are valid until a type conversion occurs as - ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or - ** [sqlite3_finalize()] is called. ^The memory space used to hold strings - ** and BLOBs is freed automatically. Do not pass the pointers returned - ** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into - ** [sqlite3_free()]. - ** - ** ^(If a memory allocation error occurs during the evaluation of any - ** of these routines, a default value is returned. The default value - ** is either the integer 0, the floating point number 0.0, or a NULL - ** pointer. Subsequent calls to [sqlite3_errcode()] will return - ** [SQLITE_NOMEM].)^ - */ - //SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); - //SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol); - //SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol); - //SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol); - //SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol); - //SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol); - //SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol); - //SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol); - //SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol); - //SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol); - - /* - ** CAPI3REF: Destroy A Prepared Statement Object - ** - ** ^The sqlite3_finalize() function is called to delete a [prepared statement]. - ** ^If the most recent evaluation of the statement encountered no errors - ** or if the statement is never been evaluated, then sqlite3_finalize() returns - ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then - ** sqlite3_finalize(S) returns the appropriate [error code] or - ** [extended error code]. - ** - ** ^The sqlite3_finalize(S) routine can be called at any point during - ** the life cycle of [prepared statement] S: - ** before statement S is ever evaluated, after - ** one or more calls to [sqlite3_reset()], or after any call - ** to [sqlite3_step()] regardless of whether or not the statement has - ** completed execution. - ** - ** ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op. - ** - ** The application must finalize every [prepared statement] in order to avoid - ** resource leaks. It is a grievous error for the application to try to use - ** a prepared statement after it has been finalized. Any use of a prepared - ** statement after it has been finalized can result in undefined and - ** undesirable behavior such as segfaults and heap corruption. - */ - //SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt); - - /* - ** CAPI3REF: Reset A Prepared Statement Object - ** - ** The sqlite3_reset() function is called to reset a [prepared statement] - ** object back to its initial state, ready to be re-executed. - ** ^Any SQL statement variables that had values bound to them using - ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values. - ** Use [sqlite3_clear_bindings()] to reset the bindings. - ** - ** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S - ** back to the beginning of its program. - ** - ** ^If the most recent call to [sqlite3_step(S)] for the - ** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE], - ** or if [sqlite3_step(S)] has never before been called on S, - ** then [sqlite3_reset(S)] returns [SQLITE_OK]. - ** - ** ^If the most recent call to [sqlite3_step(S)] for the - ** [prepared statement] S indicated an error, then - ** [sqlite3_reset(S)] returns an appropriate [error code]. - ** - ** ^The [sqlite3_reset(S)] interface does not change the values - ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. - */ - //SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); - - /* - ** CAPI3REF: Create Or Redefine SQL Functions - ** KEYWORDS: {function creation routines} - ** KEYWORDS: {application-defined SQL function} - ** KEYWORDS: {application-defined SQL functions} - ** - ** ^These functions (collectively known as "function creation routines") - ** are used to add SQL functions or aggregates or to redefine the behavior - ** of existing SQL functions or aggregates. The only differences between - ** these routines are the text encoding expected for - ** the second parameter (the name of the function being created) - ** and the presence or absence of a destructor callback for - ** the application data pointer. - ** - ** ^The first parameter is the [database connection] to which the SQL - ** function is to be added. ^If an application uses more than one database - ** connection then application-defined SQL functions must be added - ** to each database connection separately. - ** - ** ^The second parameter is the name of the SQL function to be created or - ** redefined. ^The length of the name is limited to 255 bytes in a UTF-8 - ** representation, exclusive of the zero-terminator. ^Note that the name - ** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes. - ** ^Any attempt to create a function with a longer name - ** will result in [SQLITE_MISUSE] being returned. - ** - ** ^The third parameter (nArg) - ** is the number of arguments that the SQL function or - ** aggregate takes. ^If this parameter is -1, then the SQL function or - ** aggregate may take any number of arguments between 0 and the limit - ** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]). If the third - ** parameter is less than -1 or greater than 127 then the behavior is - ** undefined. - ** - ** ^The fourth parameter, eTextRep, specifies what - ** [SQLITE_UTF8 | text encoding] this SQL function prefers for - ** its parameters. Every SQL function implementation must be able to work - ** with UTF-8, UTF-16le, or UTF-16be. But some implementations may be - ** more efficient with one encoding than another. ^An application may - ** invoke sqlite3_create_function() or sqlite3_create_function16() multiple - ** times with the same function but with different values of eTextRep. - ** ^When multiple implementations of the same function are available, SQLite - ** will pick the one that involves the least amount of data conversion. - ** If there is only a single implementation which does not care what text - ** encoding is used, then the fourth argument should be [SQLITE_ANY]. - ** - ** ^(The fifth parameter is an arbitrary pointer. The implementation of the - ** function can gain access to this pointer using [sqlite3_user_data()].)^ - ** - ** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are - ** pointers to C-language functions that implement the SQL function or - ** aggregate. ^A scalar SQL function requires an implementation of the xFunc - ** callback only; NULL pointers must be passed as the xStep and xFinal - ** parameters. ^An aggregate SQL function requires an implementation of xStep - ** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing - ** SQL function or aggregate, pass NULL pointers for all three function - ** callbacks. - ** - ** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL, - ** then it is destructor for the application data pointer. - ** The destructor is invoked when the function is deleted, either by being - ** overloaded or when the database connection closes.)^ - ** ^The destructor is also invoked if the call to - ** sqlite3_create_function_v2() fails. - ** ^When the destructor callback of the tenth parameter is invoked, it - ** is passed a single argument which is a copy of the application data - ** pointer which was the fifth parameter to sqlite3_create_function_v2(). - ** - ** ^It is permitted to register multiple implementations of the same - ** functions with the same name but with either differing numbers of - ** arguments or differing preferred text encodings. ^SQLite will use - ** the implementation that most closely matches the way in which the - ** SQL function is used. ^A function implementation with a non-negative - ** nArg parameter is a better match than a function implementation with - ** a negative nArg. ^A function where the preferred text encoding - ** matches the database encoding is a better - ** match than a function where the encoding is different. - ** ^A function where the encoding difference is between UTF16le and UTF16be - ** is a closer match than a function where the encoding difference is - ** between UTF8 and UTF16. - ** - ** ^Built-in functions may be overloaded by new application-defined functions. - ** - ** ^An application-defined function is permitted to call other - ** SQLite interfaces. However, such calls must not - ** close the database connection nor finalize or reset the prepared - ** statement in which the function is running. - */ - //SQLITE_API int sqlite3_create_function( - // sqlite3 db, - // string zFunctionName, - // int nArg, - // int eTextRep, - // void *pApp, - // void (*xFunc)(sqlite3_context*,int,sqlite3_value*), - // void (*xStep)(sqlite3_context*,int,sqlite3_value*), - // void (*xFinal)(sqlite3_context) - //); - //SQLITE_API int sqlite3_create_function16( - // sqlite3 db, - // string zFunctionName, - // int nArg, - // int eTextRep, - // void *pApp, - // void (*xFunc)(sqlite3_context*,int,sqlite3_value*), - // void (*xStep)(sqlite3_context*,int,sqlite3_value*), - // void (*xFinal)(sqlite3_context) - //); - //SQLITE_API int sqlite3_create_function_v2( - // sqlite3 db, - // string zFunctionName, - // int nArg, - // int eTextRep, - // void *pApp, - // void (*xFunc)(sqlite3_context*,int,sqlite3_value*), - // void (*xStep)(sqlite3_context*,int,sqlite3_value*), - // void (*xFinal)(sqlite3_context), - // void(*xDestroy)(void) - //); - - /* - ** CAPI3REF: Text Encodings - ** - ** These constant define integer codes that represent the various - ** text encodings supported by SQLite. - */ - //#define SQLITE_UTF8 1 - //#define SQLITE_UTF16LE 2 - //#define SQLITE_UTF16BE 3 - //#define SQLITE_UTF16 4 /* Use native byte order */ - //#define SQLITE_ANY 5 /* sqlite3_create_function only */ - //#define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */ - public const u8 SQLITE_UTF8 = 1; - public const u8 SQLITE_UTF16LE = 2; - public const u8 SQLITE_UTF16BE = 3; - public const u8 SQLITE_UTF16 = 4; - public const u8 SQLITE_ANY = 5; - public const u8 SQLITE_UTF16_ALIGNED = 8; - - - /* - ** CAPI3REF: Deprecated Functions - ** DEPRECATED - ** - ** These functions are [deprecated]. In order to maintain - ** backwards compatibility with older code, these functions continue - ** to be supported. However, new applications should avoid - ** the use of these functions. To help encourage people to avoid - ** using these functions, we are not going to tell you what they do. - */ - //#if !SQLITE_OMIT_DEPRECATED - //SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context); - //SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt); - //SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt); - //SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void); - //SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); - //SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void()(void*,sqlite3_int64,int),void*,sqlite3_int64); - //#endif - - /* - ** CAPI3REF: Obtaining SQL Function Parameter Values - ** - ** The C-language implementation of SQL functions and aggregates uses - ** this set of interface routines to access the parameter values on - ** the function or aggregate. - ** - ** The xFunc (for scalar functions) or xStep (for aggregates) parameters - ** to [sqlite3_create_function()] and [sqlite3_create_function16()] - ** define callbacks that implement the SQL functions and aggregates. - ** The 3rd parameter to these callbacks is an array of pointers to - ** [protected sqlite3_value] objects. There is one [sqlite3_value] object for - ** each parameter to the SQL function. These routines are used to - ** extract values from the [sqlite3_value] objects. - ** - ** These routines work only with [protected sqlite3_value] objects. - ** Any attempt to use these routines on an [unprotected sqlite3_value] - ** object results in undefined behavior. - ** - ** ^These routines work just like the corresponding [column access functions] - ** except that these routines take a single [protected sqlite3_value] object - ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number. - ** - ** ^The sqlite3_value_text16() interface extracts a UTF-16 string - ** in the native byte-order of the host machine. ^The - ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces - ** extract UTF-16 strings as big-endian and little-endian respectively. - ** - ** ^(The sqlite3_value_numeric_type() interface attempts to apply - ** numeric affinity to the value. This means that an attempt is - ** made to convert the value to an integer or floating point. If - ** such a conversion is possible without loss of information (in other - ** words, if the value is a string that looks like a number) - ** then the conversion is performed. Otherwise no conversion occurs. - ** The [SQLITE_INTEGER | datatype] after conversion is returned.)^ - ** - ** Please pay particular attention to the fact that the pointer returned - ** from [sqlite3_value_blob()], [sqlite3_value_text()], or - ** [sqlite3_value_text16()] can be invalidated by a subsequent call to - ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()], - ** or [sqlite3_value_text16()]. - ** - ** These routines must be called from the same thread as - ** the SQL function that supplied the [sqlite3_value*] parameters. - */ - //SQLITE_API const void *sqlite3_value_blob(sqlite3_value); - //SQLITE_API int sqlite3_value_bytes(sqlite3_value); - //SQLITE_API int sqlite3_value_bytes16(sqlite3_value); - //SQLITE_API double sqlite3_value_double(sqlite3_value); - //SQLITE_API int sqlite3_value_int(sqlite3_value); - //SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value); - //SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value); - //SQLITE_API const void *sqlite3_value_text16(sqlite3_value); - //SQLITE_API const void *sqlite3_value_text16le(sqlite3_value); - //SQLITE_API const void *sqlite3_value_text16be(sqlite3_value); - //SQLITE_API int sqlite3_value_type(sqlite3_value); - //SQLITE_API int sqlite3_value_numeric_type(sqlite3_value); - - /* - ** CAPI3REF: Obtain Aggregate Function Context - ** - ** Implementations of aggregate SQL functions use this - ** routine to allocate memory for storing their state. - ** - ** ^The first time the sqlite3_aggregate_context(C,N) routine is called - ** for a particular aggregate function, SQLite - ** allocates N of memory, zeroes out that memory, and returns a pointer - ** to the new memory. ^On second and subsequent calls to - ** sqlite3_aggregate_context() for the same aggregate function instance, - ** the same buffer is returned. Sqlite3_aggregate_context() is normally - ** called once for each invocation of the xStep callback and then one - ** last time when the xFinal callback is invoked. ^(When no rows match - ** an aggregate query, the xStep() callback of the aggregate function - ** implementation is never called and xFinal() is called exactly once. - ** In those cases, sqlite3_aggregate_context() might be called for the - ** first time from within xFinal().)^ - ** - ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is - ** less than or equal to zero or if a memory allocate error occurs. - ** - ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is - ** determined by the N parameter on first successful call. Changing the - ** value of N in subsequent call to sqlite3_aggregate_context() within - ** the same aggregate function instance will not resize the memory - ** allocation.)^ - ** - ** ^SQLite automatically frees the memory allocated by - ** sqlite3_aggregate_context() when the aggregate query concludes. - ** - ** The first parameter must be a copy of the - ** [sqlite3_context | SQL function context] that is the first parameter - ** to the xStep or xFinal callback routine that implements the aggregate - ** function. - ** - ** This routine must be called from the same thread in which - ** the aggregate SQL function is running. - */ - //SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes); - - /* - ** CAPI3REF: User Data For Functions - ** - ** ^The sqlite3_user_data() interface returns a copy of - ** the pointer that was the pUserData parameter (the 5th parameter) - ** of the [sqlite3_create_function()] - ** and [sqlite3_create_function16()] routines that originally - ** registered the application defined function. - ** - ** This routine must be called from the same thread in which - ** the application-defined function is running. - */ - //SQLITE_API void *sqlite3_user_data(sqlite3_context); - - /* - ** CAPI3REF: Database Connection For Functions - ** - ** ^The sqlite3_context_db_handle() interface returns a copy of - ** the pointer to the [database connection] (the 1st parameter) - ** of the [sqlite3_create_function()] - ** and [sqlite3_create_function16()] routines that originally - ** registered the application defined function. - */ - //SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context); - - /* - ** CAPI3REF: Function Auxiliary Data - ** - ** The following two functions may be used by scalar SQL functions to - ** associate metadata with argument values. If the same value is passed to - ** multiple invocations of the same SQL function during query execution, under - ** some circumstances the associated metadata may be preserved. This may - ** be used, for example, to add a regular-expression matching scalar - ** function. The compiled version of the regular expression is stored as - ** metadata associated with the SQL value passed as the regular expression - ** pattern. The compiled regular expression can be reused on multiple - ** invocations of the same function so that the original pattern string - ** does not need to be recompiled on each invocation. - ** - ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata - ** associated by the sqlite3_set_auxdata() function with the Nth argument - ** value to the application-defined function. ^If no metadata has been ever - ** been set for the Nth argument of the function, or if the corresponding - ** function parameter has changed since the meta-data was set, - ** then sqlite3_get_auxdata() returns a NULL pointer. - ** - ** ^The sqlite3_set_auxdata() interface saves the metadata - ** pointed to by its 3rd parameter as the metadata for the N-th - ** argument of the application-defined function. Subsequent - ** calls to sqlite3_get_auxdata() might return this data, if it has - ** not been destroyed. - ** ^If it is not NULL, SQLite will invoke the destructor - ** function given by the 4th parameter to sqlite3_set_auxdata() on - ** the metadata when the corresponding function parameter changes - ** or when the SQL statement completes, whichever comes first. - ** - ** SQLite is free to call the destructor and drop metadata on any - ** parameter of any function at any time. ^The only guarantee is that - ** the destructor will be called before the metadata is dropped. - ** - ** ^(In practice, metadata is preserved between function calls for - ** expressions that are constant at compile time. This includes literal - ** values and [parameters].)^ - ** - ** These routines must be called from the same thread in which - ** the SQL function is running. - */ - //SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); - //SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, object ()(void)); - - - /* - ** CAPI3REF: Constants Defining Special Destructor Behavior - ** - ** These are special values for the destructor that is passed in as the - ** final argument to routines like [sqlite3_result_blob()]. ^If the destructor - ** argument is SQLITE_STATIC, it means that the content pointer is constant - ** and will never change. It does not need to be destroyed. ^The - ** SQLITE_TRANSIENT value means that the content will likely change in - ** the near future and that SQLite should make its own private copy of - ** the content before returning. - ** - ** The typedef is necessary to work around problems in certain - ** C++ compilers. See ticket #2191. - */ - //typedef void (*sqlite3_destructor_type)(void); - //#define SQLITE_STATIC ((sqlite3_destructor_type)0) - //#define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1) - static public dxDel SQLITE_STATIC; - static public dxDel SQLITE_TRANSIENT; - /* - ** CAPI3REF: Setting The Result Of An SQL Function - ** - ** These routines are used by the xFunc or xFinal callbacks that - ** implement SQL functions and aggregates. See - ** [sqlite3_create_function()] and [sqlite3_create_function16()] - ** for additional information. - ** - ** These functions work very much like the [parameter binding] family of - ** functions used to bind values to host parameters in prepared statements. - ** Refer to the [SQL parameter] documentation for additional information. - ** - ** ^The sqlite3_result_blob() interface sets the result from - ** an application-defined function to be the BLOB whose content is pointed - ** to by the second parameter and which is N bytes long where N is the - ** third parameter. - ** - ** ^The sqlite3_result_zeroblob() interfaces set the result of - ** the application-defined function to be a BLOB containing all zero - ** bytes and N bytes in size, where N is the value of the 2nd parameter. - ** - ** ^The sqlite3_result_double() interface sets the result from - ** an application-defined function to be a floating point value specified - ** by its 2nd argument. - ** - ** ^The sqlite3_result_error() and sqlite3_result_error16() functions - ** cause the implemented SQL function to throw an exception. - ** ^SQLite uses the string pointed to by the - ** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16() - ** as the text of an error message. ^SQLite interprets the error - ** message string from sqlite3_result_error() as UTF-8. ^SQLite - ** interprets the string from sqlite3_result_error16() as UTF-16 in native - ** byte order. ^If the third parameter to sqlite3_result_error() - ** or sqlite3_result_error16() is negative then SQLite takes as the error - ** message all text up through the first zero character. - ** ^If the third parameter to sqlite3_result_error() or - ** sqlite3_result_error16() is non-negative then SQLite takes that many - ** bytes (not characters) from the 2nd parameter as the error message. - ** ^The sqlite3_result_error() and sqlite3_result_error16() - ** routines make a private copy of the error message text before - ** they return. Hence, the calling function can deallocate or - ** modify the text after they return without harm. - ** ^The sqlite3_result_error_code() function changes the error code - ** returned by SQLite as a result of an error in a function. ^By default, - ** the error code is SQLITE_ERROR. ^A subsequent call to sqlite3_result_error() - ** or sqlite3_result_error16() resets the error code to SQLITE_ERROR. - ** - ** ^The sqlite3_result_toobig() interface causes SQLite to throw an error - ** indicating that a string or BLOB is too long to represent. - ** - ** ^The sqlite3_result_nomem() interface causes SQLite to throw an error - ** indicating that a memory allocation failed. - ** - ** ^The sqlite3_result_int() interface sets the return value - ** of the application-defined function to be the 32-bit signed integer - ** value given in the 2nd argument. - ** ^The sqlite3_result_int64() interface sets the return value - ** of the application-defined function to be the 64-bit signed integer - ** value given in the 2nd argument. - ** - ** ^The sqlite3_result_null() interface sets the return value - ** of the application-defined function to be NULL. - ** - ** ^The sqlite3_result_text(), sqlite3_result_text16(), - ** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces - ** set the return value of the application-defined function to be - ** a text string which is represented as UTF-8, UTF-16 native byte order, - ** UTF-16 little endian, or UTF-16 big endian, respectively. - ** ^SQLite takes the text result from the application from - ** the 2nd parameter of the sqlite3_result_text* interfaces. - ** ^If the 3rd parameter to the sqlite3_result_text* interfaces - ** is negative, then SQLite takes result text from the 2nd parameter - ** through the first zero character. - ** ^If the 3rd parameter to the sqlite3_result_text* interfaces - ** is non-negative, then as many bytes (not characters) of the text - ** pointed to by the 2nd parameter are taken as the application-defined - ** function result. - ** ^If the 4th parameter to the sqlite3_result_text* interfaces - ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that - ** function as the destructor on the text or BLOB result when it has - ** finished using that result. - ** ^If the 4th parameter to the sqlite3_result_text* interfaces or to - ** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite - ** assumes that the text or BLOB result is in constant space and does not - ** copy the content of the parameter nor call a destructor on the content - ** when it has finished using that result. - ** ^If the 4th parameter to the sqlite3_result_text* interfaces - ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT - ** then SQLite makes a copy of the result into space obtained from - ** from [sqlite3_malloc()] before it returns. - ** - ** ^The sqlite3_result_value() interface sets the result of - ** the application-defined function to be a copy the - ** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The - ** sqlite3_result_value() interface makes a copy of the [sqlite3_value] - ** so that the [sqlite3_value] specified in the parameter may change or - ** be deallocated after sqlite3_result_value() returns without harm. - ** ^A [protected sqlite3_value] object may always be used where an - ** [unprotected sqlite3_value] object is required, so either - ** kind of [sqlite3_value] object can be used with this interface. - ** - ** If these routines are called from within the different thread - ** than the one containing the application-defined function that received - ** the [sqlite3_context] pointer, the results are undefined. - */ - //SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void()(void)); - //SQLITE_API void sqlite3_result_double(sqlite3_context*, double); - //SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int); - //SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int); - //SQLITE_API void sqlite3_result_error_toobig(sqlite3_context); - //SQLITE_API void sqlite3_result_error_nomem(sqlite3_context); - //SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int); - //SQLITE_API void sqlite3_result_int(sqlite3_context*, int); - //SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64); - //SQLITE_API void sqlite3_result_null(sqlite3_context); - //SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void()(void)); - //SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void()(void)); - //SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void()(void)); - //SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void()(void)); - //SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value); - //SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); - - /* - ** CAPI3REF: Define New Collating Sequences - ** - ** ^These functions add, remove, or modify a [collation] associated - ** with the [database connection] specified as the first argument. - ** - ** ^The name of the collation is a UTF-8 string - ** for sqlite3_create_collation() and sqlite3_create_collation_v2() - ** and a UTF-16 string in native byte order for sqlite3_create_collation16(). - ** ^Collation names that compare equal according to [sqlite3_strnicmp()] are - ** considered to be the same name. - ** - ** ^(The third argument (eTextRep) must be one of the constants: - **
    - **
  • [SQLITE_UTF8], - **
  • [SQLITE_UTF16LE], - **
  • [SQLITE_UTF16BE], - **
  • [SQLITE_UTF16], or - **
  • [SQLITE_UTF16_ALIGNED]. - **
)^ - ** ^The eTextRep argument determines the encoding of strings passed - ** to the collating function callback, xCallback. - ** ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep - ** force strings to be UTF16 with native byte order. - ** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin - ** on an even byte address. - ** - ** ^The fourth argument, pArg, is an application data pointer that is passed - ** through as the first argument to the collating function callback. - ** - ** ^The fifth argument, xCallback, is a pointer to the collating function. - ** ^Multiple collating functions can be registered using the same name but - ** with different eTextRep parameters and SQLite will use whichever - ** function requires the least amount of data transformation. - ** ^If the xCallback argument is NULL then the collating function is - ** deleted. ^When all collating functions having the same name are deleted, - ** that collation is no longer usable. - ** - ** ^The collating function callback is invoked with a copy of the pArg - ** application data pointer and with two strings in the encoding specified - ** by the eTextRep argument. The collating function must return an - ** integer that is negative, zero, or positive - ** if the first string is less than, equal to, or greater than the second, - ** respectively. A collating function must always return the same answer - ** given the same inputs. If two or more collating functions are registered - ** to the same collation name (using different eTextRep values) then all - ** must give an equivalent answer when invoked with equivalent strings. - ** The collating function must obey the following properties for all - ** strings A, B, and C: - ** - **
    - **
  1. If A==B then B==A. - **
  2. If A==B and B==C then A==C. - **
  3. If A<B THEN B>A. - **
  4. If A<B and B<C then A<C. - **
- ** - ** If a collating function fails any of the above constraints and that - ** collating function is registered and used, then the behavior of SQLite - ** is undefined. - ** - ** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation() - ** with the addition that the xDestroy callback is invoked on pArg when - ** the collating function is deleted. - ** ^Collating functions are deleted when they are overridden by later - ** calls to the collation creation functions or when the - ** [database connection] is closed using [sqlite3_close()]. - ** - ** ^The xDestroy callback is not called if the - ** sqlite3_create_collation_v2() function fails. Applications that invoke - ** sqlite3_create_collation_v2() with a non-NULL xDestroy argument should - ** check the return code and dispose of the application data pointer - ** themselves rather than expecting SQLite to deal with it for them. - ** This is different from every other SQLite interface. The inconsistency - ** is unfortunate but cannot be changed without breaking backwards - ** compatibility. - ** - ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()]. - */ - //SQLITE_API int sqlite3_create_collation( - // sqlite3*, - // string zName, - // int eTextRep, - // void *pArg, - // int(*xCompare)(void*,int,const void*,int,const void) - //); - //SQLITE_API int sqlite3_create_collation_v2( - // sqlite3*, - // string zName, - // int eTextRep, - // void *pArg, - // int(*xCompare)(void*,int,const void*,int,const void), - // void(*xDestroy)(void) - //); - //SQLITE_API int sqlite3_create_collation16( - // sqlite3*, - // string zName, - // int eTextRep, - // void *pArg, - // int(*xCompare)(void*,int,const void*,int,const void) - //); - - /* - ** CAPI3REF: Collation Needed Callbacks - ** - ** ^To avoid having to register all collation sequences before a database - ** can be used, a single callback function may be registered with the - ** [database connection] to be invoked whenever an undefined collation - ** sequence is required. - ** - ** ^If the function is registered using the sqlite3_collation_needed() API, - ** then it is passed the names of undefined collation sequences as strings - ** encoded in UTF-8. ^If sqlite3_collation_needed16() is used, - ** the names are passed as UTF-16 in machine native byte order. - ** ^A call to either function replaces the existing collation-needed callback. - ** - ** ^(When the callback is invoked, the first argument passed is a copy - ** of the second argument to sqlite3_collation_needed() or - ** sqlite3_collation_needed16(). The second argument is the database - ** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE], - ** or [SQLITE_UTF16LE], indicating the most desirable form of the collation - ** sequence function required. The fourth parameter is the name of the - ** required collation sequence.)^ - ** - ** The callback function should register the desired collation using - ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or - ** [sqlite3_create_collation_v2()]. - */ - //SQLITE_API int sqlite3_collation_needed( - // sqlite3*, - // void*, - // void()(void*,sqlite3*,int eTextRep,const char) - //); - //SQLITE_API int sqlite3_collation_needed16( - // sqlite3*, - // void*, - // void()(void*,sqlite3*,int eTextRep,const void) - //); - - //#if SQLITE_HAS_CODEC - /* - ** Specify the key for an encrypted database. This routine should be - ** called right after sqlite3_open(). - ** - ** The code to implement this API is not available in the public release - ** of SQLite. - */ - //SQLITE_API int sqlite3_key( - // sqlite3 db, /* Database to be rekeyed */ - // const void *pKey, int nKey /* The key */ - //); - - /* - ** Change the key on an open database. If the current database is not - ** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the - ** database is decrypted. - ** - ** The code to implement this API is not available in the public release - ** of SQLite. - */ - //SQLITE_API int sqlite3_rekey( - // sqlite3 db, /* Database to be rekeyed */ - // const void *pKey, int nKey /* The new key */ - //); - - /* - ** Specify the activation key for a SEE database. Unless - ** activated, none of the SEE routines will work. - */ - //SQLITE_API void sqlite3_activate_see( - // string zPassPhrase /* Activation phrase */ - //); - //#endif - - //#if SQLITE_ENABLE_CEROD - /* - ** Specify the activation key for a CEROD database. Unless - ** activated, none of the CEROD routines will work. - */ - //SQLITE_API void sqlite3_activate_cerod( - // string zPassPhrase /* Activation phrase */ - //); - //#endif - - /* - ** CAPI3REF: Suspend Execution For A Short Time - ** - ** The sqlite3_sleep() function causes the current thread to suspend execution - ** for at least a number of milliseconds specified in its parameter. - ** - ** If the operating system does not support sleep requests with - ** millisecond time resolution, then the time will be rounded up to - ** the nearest second. The number of milliseconds of sleep actually - ** requested from the operating system is returned. - ** - ** ^SQLite implements this interface by calling the xSleep() - ** method of the default [sqlite3_vfs] object. If the xSleep() method - ** of the default VFS is not implemented correctly, or not implemented at - ** all, then the behavior of sqlite3_sleep() may deviate from the description - ** in the previous paragraphs. - */ - //SQLITE_API int sqlite3_sleep(int); - - /* - ** CAPI3REF: Name Of The Folder Holding Temporary Files - ** - ** ^(If this global variable is made to point to a string which is - ** the name of a folder (a.k.a. directory), then all temporary files - ** created by SQLite when using a built-in [sqlite3_vfs | VFS] - ** will be placed in that directory.)^ ^If this variable - ** is a NULL pointer, then SQLite performs a search for an appropriate - ** temporary file directory. - ** - ** It is not safe to read or modify this variable in more than one - ** thread at a time. It is not safe to read or modify this variable - ** if a [database connection] is being used at the same time in a separate - ** thread. - ** It is intended that this variable be set once - ** as part of process initialization and before any SQLite interface - ** routines have been called and that this variable remain unchanged - ** thereafter. - ** - ** ^The [temp_store_directory pragma] may modify this variable and cause - ** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, - ** the [temp_store_directory pragma] always assumes that any string - ** that this variable points to is held in memory obtained from - ** [sqlite3_malloc] and the pragma may attempt to free that memory - ** using [sqlite3_free]. - ** Hence, if this variable is modified directly, either it should be - ** made NULL or made to point to memory obtained from [sqlite3_malloc] - ** or else the use of the [temp_store_directory pragma] should be avoided. - */ - //SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory; - - /* - ** CAPI3REF: Test For Auto-Commit Mode - ** KEYWORDS: {autocommit mode} - ** - ** ^The sqlite3_get_autocommit() interface returns non-zero or - ** zero if the given database connection is or is not in autocommit mode, - ** respectively. ^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 certain kinds of errors occur on a statement within a multi-statement - ** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR], - ** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the - ** transaction might be rolled back automatically. The only way to - ** find out whether SQLite automatically rolled back the transaction after - ** an error is to use this function. - ** - ** If another thread changes the autocommit status of the database - ** connection while this routine is running, then the return value - ** is undefined. - */ - //SQLITE_API int sqlite3_get_autocommit(sqlite3); - - /* - ** CAPI3REF: Find The Database Handle Of A Prepared Statement - ** - ** ^The sqlite3_db_handle interface returns the [database connection] handle - ** to which a [prepared statement] belongs. ^The [database connection] - ** returned by sqlite3_db_handle is the same [database connection] - ** that was the first argument - ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to - ** create the statement in the first place. - */ - //SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt); - - /* - ** CAPI3REF: Find the next prepared statement - ** - ** ^This interface returns a pointer to the next [prepared statement] after - ** pStmt associated with the [database connection] pDb. ^If pStmt is NULL - ** then this interface returns a pointer to the first prepared statement - ** associated with the database connection pDb. ^If no prepared statement - ** satisfies the conditions of this routine, it returns NULL. - ** - ** The [database connection] pointer D in a call to - ** [sqlite3_next_stmt(D,S)] must refer to an open database - ** connection and in particular must not be a NULL pointer. - */ - //SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); - - /* - ** CAPI3REF: Commit And Rollback Notification Callbacks - ** - ** ^The sqlite3_commit_hook() interface registers a callback - ** function to be invoked whenever a transaction is [COMMIT | committed]. - ** ^Any callback set by a previous call to sqlite3_commit_hook() - ** for the same database connection is overridden. - ** ^The sqlite3_rollback_hook() interface registers a callback - ** function to be invoked whenever a transaction is [ROLLBACK | rolled back]. - ** ^Any callback set by a previous call to sqlite3_rollback_hook() - ** for the same database connection is overridden. - ** ^The pArg argument is passed through to the callback. - ** ^If the callback on a commit hook function returns non-zero, - ** then the commit is converted into a rollback. - ** - ** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions - ** return the P argument from the previous call of the same function - ** on the same [database connection] D, or NULL for - ** the first call for each function on D. - ** - ** The callback implementation must not do anything that will modify - ** the database connection that invoked the callback. Any actions - ** to modify the database connection must be deferred until after the - ** completion of the [sqlite3_step()] call that triggered the commit - ** or rollback hook in the first place. - ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their - ** database connections for the meaning of "modify" in this paragraph. - ** - ** ^Registering a NULL function disables the callback. - ** - ** ^When the commit hook callback routine returns zero, the [COMMIT] - ** operation is allowed to continue normally. ^If the commit hook - ** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK]. - ** ^The rollback hook is invoked on a rollback that results from a commit - ** hook returning non-zero, just as it would be with any other rollback. - ** - ** ^For the purposes of this API, a transaction is said to have been - ** rolled back if an explicit "ROLLBACK" statement is executed, or - ** an error or constraint causes an implicit rollback to occur. - ** ^The rollback callback is not invoked if a transaction is - ** automatically rolled back because the database connection is closed. - ** - ** See also the [sqlite3_update_hook()] interface. - */ - //SQLITE_API void *sqlite3_commit_hook(sqlite3*, int()(void), void); - //SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void()(void ), void); - - /* - ** CAPI3REF: Data Change Notification Callbacks - ** - ** ^The sqlite3_update_hook() interface registers a callback function - ** with the [database connection] identified by the first argument - ** to be invoked whenever a row is updated, inserted or deleted. - ** ^Any callback set by a previous call to this function - ** for the same database connection is overridden. - ** - ** ^The second argument is a pointer to the function to invoke when a - ** row is updated, inserted or deleted. - ** ^The first argument to the callback is a copy of the third argument - ** to sqlite3_update_hook(). - ** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE], - ** or [SQLITE_UPDATE], depending on the operation that caused the callback - ** to be invoked. - ** ^The third and fourth arguments to the callback contain pointers to the - ** database and table name containing the affected row. - ** ^The final callback parameter is the [rowid] of the row. - ** ^In the case of an update, this is the [rowid] after the update takes place. - ** - ** ^(The update hook is not invoked when internal system tables are - ** modified (i.e. sqlite_master and sqlite_sequence).)^ - ** - ** ^In the current implementation, the update hook - ** is not invoked when duplication rows are deleted because of an - ** [ON CONFLICT | ON CONFLICT REPLACE] clause. ^Nor is the update hook - ** invoked when rows are deleted using the [truncate optimization]. - ** The exceptions defined in this paragraph might change in a future - ** release of SQLite. - ** - ** The update hook implementation must not do anything that will modify - ** the database connection that invoked the update hook. Any actions - ** to modify the database connection must be deferred until after the - ** completion of the [sqlite3_step()] call that triggered the update hook. - ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their - ** database connections for the meaning of "modify" in this paragraph. - ** - ** ^The sqlite3_update_hook(D,C,P) function - ** returns the P argument from the previous call - ** on the same [database connection] D, or NULL for - ** the first call on D. - ** - ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()] - ** interfaces. - */ - //SQLITE_API void *sqlite3_update_hook( - // sqlite3*, - // void()(void *,int ,char const *,char const *,sqlite3_int64), - // void* - //); - - /* - ** CAPI3REF: Enable Or Disable Shared Pager Cache - ** KEYWORDS: {shared cache} - ** - ** ^(This routine enables or disables the sharing of the database cache - ** and schema data structures between [database connection | connections] - ** to the same database. Sharing is enabled if the argument is true - ** and disabled if the argument is false.)^ - ** - ** ^Cache sharing is enabled and disabled for an entire process. - ** This is a change as of SQLite version 3.5.0. In prior versions of SQLite, - ** sharing was enabled or disabled for each thread separately. - ** - ** ^(The cache sharing mode set by this interface effects all subsequent - ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()]. - ** Existing database connections continue use the sharing mode - ** that was in effect at the time they were opened.)^ - ** - ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled - ** successfully. An [error code] is returned otherwise.)^ - ** - ** ^Shared cache is disabled by default. But this might change in - ** future releases of SQLite. Applications that care about shared - ** cache setting should set it explicitly. - ** - ** See Also: [SQLite Shared-Cache Mode] - */ - //SQLITE_API int sqlite3_enable_shared_cache(int); - - /* - ** CAPI3REF: Attempt To Free Heap Memory - ** - ** ^The sqlite3_release_memory() interface attempts to free N bytes - ** of heap memory by deallocating non-essential memory allocations - ** held by the database library. Memory used to cache database - ** pages to improve performance is an example of non-essential memory. - ** ^sqlite3_release_memory() returns the number of bytes actually freed, - ** which might be more or less than the amount requested. - ** ^The sqlite3_release_memory() routine is a no-op returning zero - ** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT]. - */ - //SQLITE_API int sqlite3_release_memory(int); - - /* - ** CAPI3REF: Impose A Limit On Heap Size - ** - ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the - ** soft limit on the amount of heap memory that may be allocated by SQLite. - ** ^SQLite strives to keep heap memory utilization below the soft heap - ** limit by reducing the number of pages held in the page cache - ** as heap memory usages approaches the limit. - ** ^The soft heap limit is "soft" because even though SQLite strives to stay - ** below the limit, it will exceed the limit rather than generate - ** an [SQLITE_NOMEM] error. In other words, the soft heap limit - ** is advisory only. - ** - ** ^The return value from sqlite3_soft_heap_limit64() is the size of - ** the soft heap limit prior to the call. ^If the argument N is negative - ** then no change is made to the soft heap limit. Hence, the current - ** size of the soft heap limit can be determined by invoking - ** sqlite3_soft_heap_limit64() with a negative argument. - ** - ** ^If the argument N is zero then the soft heap limit is disabled. - ** - ** ^(The soft heap limit is not enforced in the current implementation - ** if one or more of following conditions are true: - ** - **
    - **
  • The soft heap limit is set to zero. - **
  • Memory accounting is disabled using a combination of the - ** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and - ** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option. - **
  • An alternative page cache implementation is specified using - ** [sqlite3_config]([SQLITE_CONFIG_PCACHE],...). - **
  • The page cache allocates from its own memory pool supplied - ** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than - ** from the heap. - **
)^ - ** - ** Beginning with SQLite version 3.7.3, the soft heap limit is enforced - ** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT] - ** compile-time option is invoked. With [SQLITE_ENABLE_MEMORY_MANAGEMENT], - ** the soft heap limit is enforced on every memory allocation. Without - ** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced - ** when memory is allocated by the page cache. Testing suggests that because - ** the page cache is the predominate memory user in SQLite, most - ** applications will achieve adequate soft heap limit enforcement without - ** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT]. - ** - ** The circumstances under which SQLite will enforce the soft heap limit may - ** changes in future releases of SQLite. - */ - //SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N); - - /* - ** CAPI3REF: Deprecated Soft Heap Limit Interface - ** DEPRECATED - ** - ** This is a deprecated version of the [sqlite3_soft_heap_limit64()] - ** interface. This routine is provided for historical compatibility - ** only. All new applications should use the - ** [sqlite3_soft_heap_limit64()] interface rather than this one. - */ - //SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N); - - - /* - ** CAPI3REF: Extract Metadata About A Column Of A Table - ** - ** ^This routine returns metadata about a specific column of a specific - ** database table accessible using the [database connection] handle - ** passed as the first function argument. - ** - ** ^The column is identified by the second, third and fourth parameters to - ** this function. ^The second parameter is either the name of the database - ** (i.e. "main", "temp", or an attached database) containing the specified - ** table or NULL. ^If it is NULL, then all attached databases are searched - ** for the table using the same algorithm used by the database engine to - ** resolve unqualified table references. - ** - ** ^The third and fourth parameters to this function are the table and column - ** name of the desired column, respectively. Neither of these parameters - ** may be NULL. - ** - ** ^Metadata is returned by writing to the memory locations passed as the 5th - ** and subsequent parameters to this function. ^Any of these arguments may be - ** NULL, in which case the corresponding element of metadata is omitted. - ** - ** ^(
- ** - **
Parameter Output
Type
Description - ** - **
5th const char* Data type - **
6th const char* Name of default collation sequence - **
7th int True if column has a NOT NULL constraint - **
8th int True if column is part of the PRIMARY KEY - **
9th int True if column is [AUTOINCREMENT] - **
- **
)^ - ** - ** ^The memory pointed to by the character pointers returned for the - ** declaration type and collation sequence is valid only until the next - ** call to any SQLite API function. - ** - ** ^If the specified table is actually a view, an [error code] is returned. - ** - ** ^If the specified column is "rowid", "oid" or "_rowid_" and an - ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output - ** parameters are set for the explicitly declared column. ^(If there is no - ** explicitly declared [INTEGER PRIMARY KEY] column, then the output - ** parameters are set as follows: - ** - **
-        **     data type: "INTEGER"
-        **     collation sequence: "BINARY"
-        **     not null: 0
-        **     primary key: 1
-        **     auto increment: 0
-        ** 
)^ - ** - ** ^(This function may load one or more schemas from database files. If an - ** error occurs during this process, or if the requested table or column - ** cannot be found, an [error code] is returned and an error message left - ** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^ - ** - ** ^This API is only available if the library was compiled with the - ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined. - */ - //SQLITE_API int sqlite3_table_column_metadata( - // sqlite3 db, /* Connection handle */ - // string zDbName, /* Database name or NULL */ - // string zTableName, /* Table name */ - // string zColumnName, /* Column name */ - // char const **pzDataType, /* OUTPUT: Declared data type */ - // char const **pzCollSeq, /* OUTPUT: Collation sequence name */ - // int *pNotNull, /* OUTPUT: True if NOT NULL constraint exists */ - // int *pPrimaryKey, /* OUTPUT: True if column part of PK */ - // int *pAutoinc /* OUTPUT: True if column is auto-increment */ - //); - - /* - ** CAPI3REF: Load An Extension - ** - ** ^This interface loads an SQLite extension library from the named file. - ** - ** ^The sqlite3_load_extension() interface attempts to load an - ** SQLite extension library contained in the file zFile. - ** - ** ^The entry point is zProc. - ** ^zProc may be 0, in which case the name of the entry point - ** defaults to "sqlite3_extension_init". - ** ^The sqlite3_load_extension() interface returns - ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong. - ** ^If an error occurs and pzErrMsg is not 0, then the - ** [sqlite3_load_extension()] interface shall attempt to - ** fill *pzErrMsg with error message text stored in memory - ** obtained from [sqlite3_malloc()]. The calling function - ** should free this memory by calling [sqlite3_free()]. - ** - ** ^Extension loading must be enabled using - ** [sqlite3_enable_load_extension()] prior to calling this API, - ** otherwise an error will be returned. - ** - ** See also the [load_extension() SQL function]. - */ - //SQLITE_API int sqlite3_load_extension( - // sqlite3 db, /* Load the extension into this database connection */ - // string zFile, /* Name of the shared library containing extension */ - // string zProc, /* Entry point. Derived from zFile if 0 */ - // char **pzErrMsg /* Put error message here if not 0 */ - //); - - /* - ** CAPI3REF: Enable Or Disable Extension Loading - ** - ** ^So as not to open security holes in older applications that are - ** unprepared to deal with extension loading, and as a means of disabling - ** extension loading while evaluating user-entered SQL, the following API - ** is provided to turn the [sqlite3_load_extension()] mechanism on and off. - ** - ** ^Extension loading is off by default. See ticket #1863. - ** ^Call the sqlite3_enable_load_extension() routine with onoff==1 - ** to turn extension loading on and call it with onoff==0 to turn - ** it back off again. - */ - //SQLITE_API int sqlite3_enable_load_extension(sqlite3 db, int onoff); - - /* - ** CAPI3REF: Automatically Load Statically Linked Extensions - ** - ** ^This interface causes the xEntryPoint() function to be invoked for - ** each new [database connection] that is created. The idea here is that - ** xEntryPoint() is the entry point for a statically linked SQLite extension - ** that is to be automatically loaded into all new database connections. - ** - ** ^(Even though the function prototype shows that xEntryPoint() takes - ** no arguments and returns void, SQLite invokes xEntryPoint() with three - ** arguments and expects and integer result as if the signature of the - ** entry point where as follows: - ** - **
-        **    int xEntryPoint(
-        **      sqlite3 db,
-        **      string *pzErrMsg,
-        **      const struct sqlite3_api_routines *pThunk
-        **    );
-        ** 
)^ - ** - ** If the xEntryPoint routine encounters an error, it should make *pzErrMsg - ** point to an appropriate error message (obtained from [sqlite3_mprintf()]) - ** and return an appropriate [error code]. ^SQLite ensures that *pzErrMsg - ** is NULL before calling the xEntryPoint(). ^SQLite will invoke - ** [sqlite3_free()] on *pzErrMsg after xEntryPoint() returns. ^If any - ** xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()], - ** or [sqlite3_open_v2()] call that provoked the xEntryPoint() will fail. - ** - ** ^Calling sqlite3_auto_extension(X) with an entry point X that is already - ** on the list of automatic extensions is a harmless no-op. ^No entry point - ** will be called more than once for each database connection that is opened. - ** - ** See also: [sqlite3_reset_auto_extension()]. - */ - //SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void)); - - /* - ** CAPI3REF: Reset Automatic Extension Loading - ** - ** ^This interface disables all automatic extensions previously - ** registered using [sqlite3_auto_extension()]. - */ - //SQLITE_API void sqlite3_reset_auto_extension(void); - - /* - ** The interface to the virtual-table mechanism is currently considered - ** to be experimental. The interface might change in incompatible ways. - ** If this is a problem for you, do not use the interface at this time. - ** - ** When the virtual-table mechanism stabilizes, we will declare the - ** interface fixed, support it indefinitely, and remove this comment. - */ - - /* - ** Structures used by the virtual table interface - */ - //typedef struct sqlite3_vtab sqlite3_vtab; - //typedef struct sqlite3_index_info sqlite3_index_info; - //typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor; - //typedef struct sqlite3_module sqlite3_module; - - /* - ** CAPI3REF: Virtual Table Object - ** KEYWORDS: sqlite3_module {virtual table module} - ** - ** This structure, sometimes called a "virtual table module", - ** defines the implementation of a [virtual tables]. - ** This structure consists mostly of methods for the module. - ** - ** ^A virtual table module is created by filling in a persistent - ** instance of this structure and passing a pointer to that instance - ** to [sqlite3_create_module()] or [sqlite3_create_module_v2()]. - ** ^The registration remains valid until it is replaced by a different - ** module or until the [database connection] closes. The content - ** of this structure must not change while it is registered with - ** any database connection. - */ - //struct sqlite3_module { - // int iVersion; - // int (*xCreate)(sqlite3*, object *pAux, - // int argc, string[] argv, - // sqlite3_vtab **ppVTab, char*); - // int (*xConnect)(sqlite3*, object *pAux, - // int argc, string[] argv, - // sqlite3_vtab **ppVTab, char*); - // int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info); - // int (*xDisconnect)(sqlite3_vtab *pVTab); - // int (*xDestroy)(sqlite3_vtab *pVTab); - // int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor); - // int (*xClose)(sqlite3_vtab_cursor); - // int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, string idxStr, - // int argc, sqlite3_value **argv); - // int (*xNext)(sqlite3_vtab_cursor); - // int (*xEof)(sqlite3_vtab_cursor); - // int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int); - // int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid); - // int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 ); - // int (*xBegin)(sqlite3_vtab *pVTab); - // int (*xSync)(sqlite3_vtab *pVTab); - // int (*xCommit)(sqlite3_vtab *pVTab); - // int (*xRollback)(sqlite3_vtab *pVTab); - // int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, string zName, - // void (**pxFunc)(sqlite3_context*,int,sqlite3_value*), - // void **ppArg); - // int (*xRename)(sqlite3_vtab *pVtab, string zNew); - ///* The methods above are in version 1 of the sqlite_module object. Those - //** below are for version 2 and greater. */ - //int (*xSavepoint)(sqlite3_vtab *pVTab, int); - //int (*xRelease)(sqlite3_vtab *pVTab, int); - //int (*xRollbackTo)(sqlite3_vtab *pVTab, int); - //}; - // MINIMAL STRUCTURE - public class sqlite3_module { - public int iVersion; - public smdxCreateConnect xCreate; - public smdxCreateConnect xConnect; - public smdxBestIndex xBestIndex; - public smdxDisconnect xDisconnect; - public smdxDestroy xDestroy; - public smdxOpen xOpen; - public smdxClose xClose; - public smdxFilter xFilter; - public smdxNext xNext; - public smdxEof xEof; - public smdxColumn xColumn; - public smdxRowid xRowid; - public smdxUpdate xUpdate; - public smdxFunction xBegin; - public smdxFunction xSync; - public smdxFunction xCommit; - public smdxFunction xRollback; - public smdxFindFunction xFindFunction; - public smdxRename xRename; - /* The methods above are in version 1 of the sqlite_module object. Those - ** below are for version 2 and greater. */ - public smdxFunctionArg xSavepoint; - public smdxFunctionArg xRelease; - public smdxFunctionArg xRollbackTo; - - //Version 1 - public sqlite3_module( - int iVersion, - smdxCreateConnect xCreate, - smdxCreateConnect xConnect, - smdxBestIndex xBestIndex, - smdxDisconnect xDisconnect, - smdxDestroy xDestroy, - smdxOpen xOpen, - smdxClose xClose, - smdxFilter xFilter, - smdxNext xNext, - smdxEof xEof, - smdxColumn xColumn, - smdxRowid xRowid, - smdxUpdate xUpdate, - smdxFunction xBegin, - smdxFunction xSync, - smdxFunction xCommit, - smdxFunction xRollback, - smdxFindFunction xFindFunction, - smdxRename xRename) { - this.iVersion = iVersion; - this.xCreate = xCreate; - this.xConnect = xConnect; - this.xBestIndex = xBestIndex; - this.xDisconnect = xDisconnect; - this.xDestroy = xDestroy; - this.xOpen = xOpen; - this.xClose = xClose; - this.xFilter = xFilter; - this.xNext = xNext; - this.xEof = xEof; - this.xColumn = xColumn; - this.xRowid = xRowid; - this.xUpdate = xUpdate; - this.xBegin = xBegin; - this.xSync = xSync; - this.xCommit = xCommit; - this.xRollback = xRollback; - this.xFindFunction = xFindFunction; - this.xRename = xRename; - } - - //Version 2 - public sqlite3_module( - int iVersion, - smdxCreateConnect xCreate, - smdxCreateConnect xConnect, - smdxBestIndex xBestIndex, - smdxDisconnect xDisconnect, - smdxDestroy xDestroy, - smdxOpen xOpen, - smdxClose xClose, - smdxFilter xFilter, - smdxNext xNext, - smdxEof xEof, - smdxColumn xColumn, - smdxRowid xRowid, - smdxUpdate xUpdate, - smdxFunction xBegin, - smdxFunction xSync, - smdxFunction xCommit, - smdxFunction xRollback, - smdxFindFunction xFindFunction, - smdxRename xRename, - /* The methods above are in version 1 of the sqlite_module object. Those - ** below are for version 2 and greater. */ - smdxFunctionArg xSavepoint, - smdxFunctionArg xRelease, - smdxFunctionArg xRollbackTo - ) { - this.iVersion = iVersion; - this.xCreate = xCreate; - this.xConnect = xConnect; - this.xBestIndex = xBestIndex; - this.xDisconnect = xDisconnect; - this.xDestroy = xDestroy; - this.xOpen = xOpen; - this.xClose = xClose; - this.xFilter = xFilter; - this.xNext = xNext; - this.xEof = xEof; - this.xColumn = xColumn; - this.xRowid = xRowid; - this.xUpdate = xUpdate; - this.xBegin = xBegin; - this.xSync = xSync; - this.xCommit = xCommit; - this.xRollback = xRollback; - this.xFindFunction = xFindFunction; - this.xRename = xRename; - this.xSavepoint = xSavepoint; - this.xRelease = xRelease; - this.xRollbackTo = xRollbackTo; - } - } - - - /* - ** CAPI3REF: Virtual Table Indexing Information - ** KEYWORDS: sqlite3_index_info - ** - ** The sqlite3_index_info structure and its substructures is used as part - ** of the [virtual table] interface to - ** pass information into and receive the reply from the [xBestIndex] - ** method of a [virtual table module]. The fields under **Inputs** are the - ** inputs to xBestIndex and are read-only. xBestIndex inserts its - ** results into the **Outputs** fields. - ** - ** ^(The aConstraint[] array records WHERE clause constraints of the form: - ** - **
column OP expr
- ** - ** where OP is =, <, <=, >, or >=.)^ ^(The particular operator is - ** stored in aConstraint[].op using one of the - ** [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^ - ** ^(The index of the column is stored in - ** aConstraint[].iColumn.)^ ^(aConstraint[].usable is TRUE if the - ** expr on the right-hand side can be evaluated (and thus the constraint - ** is usable) and false if it cannot.)^ - ** - ** ^The optimizer automatically inverts terms of the form "expr OP column" - ** and makes other simplifications to the WHERE clause in an attempt to - ** get as many WHERE clause terms into the form shown above as possible. - ** ^The aConstraint[] array only reports WHERE clause terms that are - ** relevant to the particular virtual table being queried. - ** - ** ^Information about the ORDER BY clause is stored in aOrderBy[]. - ** ^Each term of aOrderBy records a column of the ORDER BY clause. - ** - ** The [xBestIndex] method must fill aConstraintUsage[] with information - ** about what parameters to pass to xFilter. ^If argvIndex>0 then - ** the right-hand side of the corresponding aConstraint[] is evaluated - ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit - ** is true, then the constraint is assumed to be fully handled by the - ** virtual table and is not checked again by SQLite.)^ - ** - ** ^The idxNum and idxPtr values are recorded and passed into the - ** [xFilter] method. - ** ^[sqlite3_free()] is used to free idxPtr if and only if - ** needToFreeIdxPtr is true. - ** - ** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in - ** the correct order to satisfy the ORDER BY clause so that no separate - ** sorting step is required. - ** - ** ^The estimatedCost value is an estimate of the cost of doing the - ** particular lookup. A full scan of a table with N entries should have - ** a cost of N. A binary search of a table of N entries should have a - ** cost of approximately log(N). - */ - //struct sqlite3_index_info { - // /* Inputs */ - // int nConstraint; /* Number of entries in aConstraint */ - // struct sqlite3_index_constraint { - // int iColumn; /* Column on left-hand side of constraint */ - // unsigned char op; /* Constraint operator */ - // unsigned char usable; /* True if this constraint is usable */ - // int iTermOffset; /* Used internally - xBestIndex should ignore */ - // } *aConstraint; /* Table of WHERE clause constraints */ - // int nOrderBy; /* Number of terms in the ORDER BY clause */ - // struct sqlite3_index_orderby { - // int iColumn; /* Column number */ - // unsigned char desc; /* True for DESC. False for ASC. */ - // } *aOrderBy; /* The ORDER BY clause */ - // /* Outputs */ - // struct sqlite3_index_constraint_usage { - // int argvIndex; /* if >0, constraint is part of argv to xFilter */ - // unsigned char omit; /* Do not code a test for this constraint */ - // } *aConstraintUsage; - // int idxNum; /* Number used to identify the index */ - // char *idxStr; /* String, possibly obtained from sqlite3_malloc */ - // int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */ - // int orderByConsumed; /* True if output is already ordered */ - // double estimatedCost; /* Estimated cost of using this index */ - //}; - public class sqlite3_index_constraint { - public int iColumn; /* Column on left-hand side of constraint */ - public int op; /* Constraint operator */ - public bool usable; /* True if this constraint is usable */ - public int iTermOffset; /* Used internally - xBestIndex should ignore */ - } - public class sqlite3_index_orderby { - public int iColumn; /* Column number */ - public bool desc; /* True for DESC. False for ASC. */ - } - public class sqlite3_index_constraint_usage { - public int argvIndex; /* if >0, constraint is part of argv to xFilter */ - public bool omit; /* Do not code a test for this constraint */ - } - - public class sqlite3_index_info { - /* Inputs */ - public int nConstraint; /* Number of entries in aConstraint */ - public sqlite3_index_constraint[] aConstraint; /* Table of WHERE clause constraints */ - public int nOrderBy; /* Number of terms in the ORDER BY clause */ - public sqlite3_index_orderby[] aOrderBy;/* The ORDER BY clause */ - - /* Outputs */ - - public sqlite3_index_constraint_usage[] aConstraintUsage; - public int idxNum; /* Number used to identify the index */ - public string idxStr; /* String, possibly obtained from sqlite3Malloc */ - public int needToFreeIdxStr; /* Free idxStr using sqlite3DbFree(db,) if true */ - public bool orderByConsumed; /* True if output is already ordered */ - public double estimatedCost; /* Estimated cost of using this index */ - } - - /* - ** CAPI3REF: Virtual Table Constraint Operator Codes - ** - ** These macros defined the allowed values for the - ** [sqlite3_index_info].aConstraint[].op field. Each value represents - ** an operator that is part of a constraint term in the wHERE clause of - ** a query that uses a [virtual table]. - */ - //#define SQLITE_INDEX_CONSTRAINT_EQ 2 - //#define SQLITE_INDEX_CONSTRAINT_GT 4 - //#define SQLITE_INDEX_CONSTRAINT_LE 8 - //#define SQLITE_INDEX_CONSTRAINT_LT 16 - //#define SQLITE_INDEX_CONSTRAINT_GE 32 - //#define SQLITE_INDEX_CONSTRAINT_MATCH 64 - const int SQLITE_INDEX_CONSTRAINT_EQ = 2; - const int SQLITE_INDEX_CONSTRAINT_GT = 4; - const int SQLITE_INDEX_CONSTRAINT_LE = 8; - const int SQLITE_INDEX_CONSTRAINT_LT = 16; - const int SQLITE_INDEX_CONSTRAINT_GE = 32; - const int SQLITE_INDEX_CONSTRAINT_MATCH = 64; - - /* - ** CAPI3REF: Register A Virtual Table Implementation - ** - ** ^These routines are used to register a new [virtual table module] name. - ** ^Module names must be registered before - ** creating a new [virtual table] using the module and before using a - ** preexisting [virtual table] for the module. - ** - ** ^The module name is registered on the [database connection] specified - ** by the first parameter. ^The name of the module is given by the - ** second parameter. ^The third parameter is a pointer to - ** the implementation of the [virtual table module]. ^The fourth - ** parameter is an arbitrary client data pointer that is passed through - ** into the [xCreate] and [xConnect] methods of the virtual table module - ** when a new virtual table is be being created or reinitialized. - ** - ** ^The sqlite3_create_module_v2() interface has a fifth parameter which - ** is a pointer to a destructor for the pClientData. ^SQLite will - ** invoke the destructor function (if it is not NULL) when SQLite - ** no longer needs the pClientData pointer. ^The destructor will also - ** be invoked if the call to sqlite3_create_module_v2() fails. - ** ^The sqlite3_create_module() - ** interface is equivalent to sqlite3_create_module_v2() with a NULL - ** destructor. - */ - //SQLITE_API int sqlite3_create_module( - // sqlite3 db, /* SQLite connection to register module with */ - // string zName, /* Name of the module */ - // const sqlite3_module *p, /* Methods for the module */ - // void *pClientData /* Client data for xCreate/xConnect */ - //); - //SQLITE_API int sqlite3_create_module_v2( - // sqlite3 db, /* SQLite connection to register module with */ - // string zName, /* Name of the module */ - // const sqlite3_module *p, /* Methods for the module */ - // void *pClientData, /* Client data for xCreate/xConnect */ - // void(*xDestroy)(void) /* Module destructor function */ - //); - - /* - ** CAPI3REF: Virtual Table Instance Object - ** KEYWORDS: sqlite3_vtab - ** - ** Every [virtual table module] implementation uses a subclass - ** of this object to describe a particular instance - ** of the [virtual table]. Each subclass will - ** be tailored to the specific needs of the module implementation. - ** The purpose of this superclass is to define certain fields that are - ** common to all module implementations. - ** - ** ^Virtual tables methods can set an error message by assigning a - ** string obtained from [sqlite3_mprintf()] to zErrMsg. The method should - ** take care that any prior string is freed by a call to [sqlite3_free()] - ** prior to assigning a new string to zErrMsg. ^After the error message - ** is delivered up to the client application, the string will be automatically - ** freed by sqlite3_free() and the zErrMsg field will be zeroed. - */ - //struct sqlite3_vtab { - // const sqlite3_module *pModule; /* The module for this virtual table */ - // int nRef; /* NO LONGER USED */ - // string zErrMsg; /* Error message from sqlite3_mprintf() */ - // /* Virtual table implementations will typically add additional fields */ - //}; - public class sqlite3_vtab { - public sqlite3_module pModule; /* The module for this virtual table */ - public int nRef; /* Used internally */ - public string zErrMsg; /* Error message from sqlite3_mprintf() */ - /* Virtual table implementations will typically add additional fields */ - }; - - /* - ** CAPI3REF: Virtual Table Cursor Object - ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor} - ** - ** Every [virtual table module] implementation uses a subclass of the - ** following structure to describe cursors that point into the - ** [virtual table] and are used - ** to loop through the virtual table. Cursors are created using the - ** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed - ** by the [sqlite3_module.xClose | xClose] method. Cursors are used - ** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods - ** of the module. Each module implementation will define - ** the content of a cursor structure to suit its own needs. - ** - ** This superclass exists in order to define fields of the cursor that - ** are common to all implementations. - */ - //struct sqlite3_vtab_cursor { - // sqlite3_vtab *pVtab; /* Virtual table of this cursor */ - // /* Virtual table implementations will typically add additional fields */ - //}; - public class sqlite3_vtab_cursor { - public sqlite3_vtab pVtab; /* Virtual table of this cursor */ - /* Virtual table implementations will typically add additional fields */ - }; - - /* - ** CAPI3REF: Declare The Schema Of A Virtual Table - ** - ** ^The [xCreate] and [xConnect] methods of a - ** [virtual table module] call this interface - ** to declare the format (the names and datatypes of the columns) of - ** the virtual tables they implement. - */ - //SQLITE_API int sqlite3_declare_vtab(sqlite3*, string zSQL); - - /* - ** CAPI3REF: Overload A Function For A Virtual Table - ** - ** ^(Virtual tables can provide alternative implementations of functions - ** using the [xFindFunction] method of the [virtual table module]. - ** But global versions of those functions - ** must exist in order to be overloaded.)^ - ** - ** ^(This API makes sure a global version of a function with a particular - ** name and number of parameters exists. If no such function exists - ** before this API is called, a new function is created.)^ ^The implementation - ** of the new function always causes an exception to be thrown. So - ** the new function is not good for anything by itself. Its only - ** purpose is to be a placeholder function that can be overloaded - ** by a [virtual table]. - */ - //SQLITE_API int sqlite3_overload_function(sqlite3*, string zFuncName, int nArg); - - /* - ** The interface to the virtual-table mechanism defined above (back up - ** to a comment remarkably similar to this one) is currently considered - ** to be experimental. The interface might change in incompatible ways. - ** If this is a problem for you, do not use the interface at this time. - ** - ** When the virtual-table mechanism stabilizes, we will declare the - ** interface fixed, support it indefinitely, and remove this comment. - */ - - /* - ** CAPI3REF: A Handle To An Open BLOB - ** KEYWORDS: {BLOB handle} {BLOB handles} - ** - ** An instance of this object represents an open BLOB on which - ** [sqlite3_blob_open | incremental BLOB I/O] can be performed. - ** ^Objects of this type are created by [sqlite3_blob_open()] - ** and destroyed by [sqlite3_blob_close()]. - ** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces - ** can be used to read or write small subsections of the BLOB. - ** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes. - */ - //typedef struct sqlite3_blob sqlite3_blob; - - /* - ** CAPI3REF: Open A BLOB For Incremental I/O - ** - ** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located - ** in row iRow, column zColumn, table zTable in database zDb; - ** in other words, the same BLOB that would be selected by: - ** - **
-        **     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
-        ** 
)^ - ** - ** ^If the flags parameter is non-zero, then the BLOB is opened for read - ** and write access. ^If it is zero, the BLOB is opened for read access. - ** ^It is not possible to open a column that is part of an index or primary - ** key for writing. ^If [foreign key constraints] are enabled, it is - ** not possible to open a column that is part of a [child key] for writing. - ** - ** ^Note that the database name is not the filename that contains - ** the database but rather the symbolic name of the database that - ** appears after the AS keyword when the database is connected using [ATTACH]. - ** ^For the main database file, the database name is "main". - ** ^For TEMP tables, the database name is "temp". - ** - ** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written - ** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set - ** to be a null pointer.)^ - ** ^This function sets the [database connection] error code and message - ** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related - ** functions. ^Note that the *ppBlob variable is always initialized in a - ** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob - ** regardless of the success or failure of this routine. - ** - ** ^(If the row that a BLOB handle points to is modified by an - ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects - ** then the BLOB handle is marked as "expired". - ** This is true if any column of the row is changed, even a column - ** other than the one the BLOB handle is open on.)^ - ** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for - ** a expired BLOB handle fail with a return code of [SQLITE_ABORT]. - ** ^(Changes written into a BLOB prior to the BLOB expiring are not - ** rolled back by the expiration of the BLOB. Such changes will eventually - ** commit if the transaction continues to completion.)^ - ** - ** ^Use the [sqlite3_blob_bytes()] interface to determine the size of - ** the opened blob. ^The size of a blob may not be changed by this - ** interface. Use the [UPDATE] SQL command to change the size of a - ** blob. - ** - ** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces - ** and the built-in [zeroblob] SQL function can be used, if desired, - ** to create an empty, zero-filled blob in which to read or write using - ** this interface. - ** - ** To avoid a resource leak, every open [BLOB handle] should eventually - ** be released by a call to [sqlite3_blob_close()]. - */ - //SQLITE_API int sqlite3_blob_open( - // sqlite3*, - // string zDb, - // string zTable, - // string zColumn, - // sqlite3_int64 iRow, - // int flags, - // sqlite3_blob **ppBlob - //); - - /* - ** CAPI3REF: Move a BLOB Handle to a New Row - ** - ** ^This function is used to move an existing blob handle so that it points - ** to a different row of the same database table. ^The new row is identified - ** by the rowid value passed as the second argument. Only the row can be - ** changed. ^The database, table and column on which the blob handle is open - ** remain the same. Moving an existing blob handle to a new row can be - ** faster than closing the existing handle and opening a new one. - ** - ** ^(The new row must meet the same criteria as for [sqlite3_blob_open()] - - ** it must exist and there must be either a blob or text value stored in - ** the nominated column.)^ ^If the new row is not present in the table, or if - ** it does not contain a blob or text value, or if another error occurs, an - ** SQLite error code is returned and the blob handle is considered aborted. - ** ^All subsequent calls to [sqlite3_blob_read()], [sqlite3_blob_write()] or - ** [sqlite3_blob_reopen()] on an aborted blob handle immediately return - ** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle - ** always returns zero. - ** - ** ^This function sets the database handle error code and message. - */ - //SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64); - - /* - ** CAPI3REF: Close A BLOB Handle - ** - ** ^Closes an open [BLOB handle]. - ** - ** ^Closing a BLOB shall cause the current transaction to commit - ** if there are no other BLOBs, no pending prepared statements, and the - ** database connection is in [autocommit mode]. - ** ^If any writes were made to the BLOB, they might be held in cache - ** until the close operation if they will fit. - ** - ** ^(Closing the BLOB often forces the changes - ** out to disk and so if any I/O errors occur, they will likely occur - ** at the time when the BLOB is closed. Any errors that occur during - ** closing are reported as a non-zero return value.)^ - ** - ** ^(The BLOB is closed unconditionally. Even if this routine returns - ** an error code, the BLOB is still closed.)^ - ** - ** ^Calling this routine with a null pointer (such as would be returned - ** by a failed call to [sqlite3_blob_open()]) is a harmless no-op. - */ - //SQLITE_API int sqlite3_blob_close(sqlite3_blob ); - - /* - ** CAPI3REF: Return The Size Of An Open BLOB - ** - ** ^Returns the size in bytes of the BLOB accessible via the - ** successfully opened [BLOB handle] in its only argument. ^The - ** incremental blob I/O routines can only read or overwriting existing - ** blob content; they cannot change the size of a blob. - ** - ** This routine only works on a [BLOB handle] which has been created - ** by a prior successful call to [sqlite3_blob_open()] and which has not - ** been closed by [sqlite3_blob_close()]. Passing any other pointer in - ** to this routine results in undefined and probably undesirable behavior. - */ - //SQLITE_API int sqlite3_blob_bytes(sqlite3_blob ); - - /* - ** CAPI3REF: Read Data From A BLOB Incrementally - ** - ** ^(This function is used to read data from an open [BLOB handle] into a - ** caller-supplied buffer. N bytes of data are copied into buffer Z - ** from the open BLOB, starting at offset iOffset.)^ - ** - ** ^If offset iOffset is less than N bytes from the end of the BLOB, - ** [SQLITE_ERROR] is returned and no data is read. ^If N or iOffset is - ** less than zero, [SQLITE_ERROR] is returned and no data is read. - ** ^The size of the blob (and hence the maximum value of N+iOffset) - ** can be determined using the [sqlite3_blob_bytes()] interface. - ** - ** ^An attempt to read from an expired [BLOB handle] fails with an - ** error code of [SQLITE_ABORT]. - ** - ** ^(On success, sqlite3_blob_read() returns SQLITE_OK. - ** Otherwise, an [error code] or an [extended error code] is returned.)^ - ** - ** This routine only works on a [BLOB handle] which has been created - ** by a prior successful call to [sqlite3_blob_open()] and which has not - ** been closed by [sqlite3_blob_close()]. Passing any other pointer in - ** to this routine results in undefined and probably undesirable behavior. - ** - ** See also: [sqlite3_blob_write()]. - */ - //SQLITE_API int sqlite3_blob_read(sqlite3_blob *, object *Z, int N, int iOffset); - - /* - ** CAPI3REF: Write Data Into A BLOB Incrementally - ** - ** ^This function is used to write data into an open [BLOB handle] from a - ** caller-supplied buffer. ^N bytes of data are copied from the buffer Z - ** into the open BLOB, starting at offset iOffset. - ** - ** ^If the [BLOB handle] passed as the first argument was not opened for - ** writing (the flags parameter to [sqlite3_blob_open()] was zero), - ** this function returns [SQLITE_READONLY]. - ** - ** ^This function may only modify the contents of the BLOB; it is - ** not possible to increase the size of a BLOB using this API. - ** ^If offset iOffset is less than N bytes from the end of the BLOB, - ** [SQLITE_ERROR] is returned and no data is written. ^If N is - ** less than zero [SQLITE_ERROR] is returned and no data is written. - ** The size of the BLOB (and hence the maximum value of N+iOffset) - ** can be determined using the [sqlite3_blob_bytes()] interface. - ** - ** ^An attempt to write to an expired [BLOB handle] fails with an - ** error code of [SQLITE_ABORT]. ^Writes to the BLOB that occurred - ** before the [BLOB handle] expired are not rolled back by the - ** expiration of the handle, though of course those changes might - ** have been overwritten by the statement that expired the BLOB handle - ** or by other independent statements. - ** - ** ^(On success, sqlite3_blob_write() returns SQLITE_OK. - ** Otherwise, an [error code] or an [extended error code] is returned.)^ - ** - ** This routine only works on a [BLOB handle] which has been created - ** by a prior successful call to [sqlite3_blob_open()] and which has not - ** been closed by [sqlite3_blob_close()]. Passing any other pointer in - ** to this routine results in undefined and probably undesirable behavior. - ** - ** See also: [sqlite3_blob_read()]. - */ - //SQLITE_API int sqlite3_blob_write(sqlite3_blob *, string z, int n, int iOffset); - - /* - ** CAPI3REF: Virtual File System Objects - ** - ** A virtual filesystem (VFS) is an [sqlite3_vfs] object - ** that SQLite uses to interact - ** with the underlying operating system. Most SQLite builds come with a - ** single default VFS that is appropriate for the host computer. - ** New VFSes can be registered and existing VFSes can be unregistered. - ** The following interfaces are provided. - ** - ** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name. - ** ^Names are case sensitive. - ** ^Names are zero-terminated UTF-8 strings. - ** ^If there is no match, a NULL pointer is returned. - ** ^If zVfsName is NULL then the default VFS is returned. - ** - ** ^New VFSes are registered with sqlite3_vfs_register(). - ** ^Each new VFS becomes the default VFS if the makeDflt flag is set. - ** ^The same VFS can be registered multiple times without injury. - ** ^To make an existing VFS into the default VFS, register it again - ** with the makeDflt flag set. If two different VFSes with the - ** same name are registered, the behavior is undefined. If a - ** VFS is registered with a name that is NULL or an empty string, - ** then the behavior is undefined. - ** - ** ^Unregister a VFS with the sqlite3_vfs_unregister() interface. - ** ^(If the default VFS is unregistered, another VFS is chosen as - ** the default. The choice for the new VFS is arbitrary.)^ - */ - //SQLITE_API sqlite3_vfs *sqlite3_vfs_find(string zVfsName); - //SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt); - //SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs); - - /* - ** CAPI3REF: Mutexes - ** - ** The SQLite core uses these routines for thread - ** synchronization. Though they are intended for internal - ** use by SQLite, code that links against SQLite is - ** permitted to use any of these routines. - ** - ** The SQLite source code contains multiple implementations - ** of these mutex routines. An appropriate implementation - ** is selected automatically at compile-time. ^(The following - ** implementations are available in the SQLite core: - ** - **
    - **
  • SQLITE_MUTEX_OS2 - **
  • SQLITE_MUTEX_PTHREAD - **
  • SQLITE_MUTEX_W32 - **
  • SQLITE_MUTEX_NOOP - **
)^ - ** - ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines - ** that does no real locking and is appropriate for use in - ** a single-threaded application. ^The SQLITE_MUTEX_OS2, - ** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations - ** are appropriate for use on OS/2, Unix, and Windows. - ** - ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor - ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex - ** implementation is included with the library. In this case the - ** application must supply a custom mutex implementation using the - ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function - ** before calling sqlite3_initialize() or any other public sqlite3_ - ** function that calls sqlite3_initialize().)^ - ** - ** ^The sqlite3_mutex_alloc() routine allocates a new - ** mutex and returns a pointer to it. ^If it returns NULL - ** that means that a mutex could not be allocated. ^SQLite - ** will unwind its stack and return an error. ^(The argument - ** to sqlite3_mutex_alloc() is one of these integer constants: - ** - **
    - **
  • SQLITE_MUTEX_FAST - **
  • SQLITE_MUTEX_RECURSIVE - **
  • SQLITE_MUTEX_STATIC_MASTER - **
  • SQLITE_MUTEX_STATIC_MEM - **
  • SQLITE_MUTEX_STATIC_MEM2 - **
  • SQLITE_MUTEX_STATIC_PRNG - **
  • SQLITE_MUTEX_STATIC_LRU - **
  • SQLITE_MUTEX_STATIC_LRU2 - **
)^ - ** - ** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) - ** cause sqlite3_mutex_alloc() to create - ** a new mutex. ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE - ** is used but not necessarily so when SQLITE_MUTEX_FAST is used. - ** The mutex implementation does not need to make a distinction - ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does - ** not want to. ^SQLite will only request a recursive mutex in - ** cases where it really needs one. ^If a faster non-recursive mutex - ** implementation is available on the host platform, the mutex subsystem - ** might return such a mutex in response to SQLITE_MUTEX_FAST. - ** - ** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other - ** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return - ** a pointer to a static preexisting mutex. ^Six static mutexes are - ** used by the current version of SQLite. Future versions of SQLite - ** may add additional static mutexes. Static mutexes are for internal - ** use by SQLite only. Applications that use SQLite mutexes should - ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or - ** SQLITE_MUTEX_RECURSIVE. - ** - ** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST - ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() - ** returns a different mutex on every call. ^But for the static - ** mutex types, the same mutex is returned on every call that has - ** the same type number. - ** - ** ^The sqlite3_mutex_free() routine deallocates a previously - ** allocated dynamic mutex. ^SQLite is careful to deallocate every - ** dynamic mutex that it allocates. The dynamic mutexes must not be in - ** use when they are deallocated. Attempting to deallocate a static - ** mutex results in undefined behavior. ^SQLite never deallocates - ** a static mutex. - ** - ** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt - ** to enter a mutex. ^If another thread is already within the mutex, - ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return - ** SQLITE_BUSY. ^The sqlite3_mutex_try() interface returns [SQLITE_OK] - ** upon successful entry. ^(Mutexes created using - ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread. - ** In such cases the, - ** mutex must be exited an equal number of times before another thread - ** can enter.)^ ^(If the same thread tries to enter any other - ** kind of mutex more than once, the behavior is undefined. - ** SQLite will never exhibit - ** such behavior in its own use of mutexes.)^ - ** - ** ^(Some systems (for example, Windows 95) do not support the operation - ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() - ** will always return SQLITE_BUSY. The SQLite core only ever uses - ** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^ - ** - ** ^The sqlite3_mutex_leave() routine exits a mutex that was - ** previously entered by the same thread. ^(The behavior - ** is undefined if the mutex is not currently entered by the - ** calling thread or is not currently allocated. SQLite will - ** never do either.)^ - ** - ** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or - ** sqlite3_mutex_leave() is a NULL pointer, then all three routines - ** behave as no-ops. - ** - ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()]. - */ - //SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int); - //SQLITE_API void sqlite3_mutex_free(sqlite3_mutex); - //SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex); - //SQLITE_API int sqlite3_mutex_try(sqlite3_mutex); - //SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex); - - /* - ** CAPI3REF: Mutex Methods Object - ** - ** An instance of this structure defines the low-level routines - ** used to allocate and use mutexes. - ** - ** Usually, the default mutex implementations provided by SQLite are - ** sufficient, however the user has the option of substituting a custom - ** implementation for specialized deployments or systems for which SQLite - ** does not provide a suitable implementation. In this case, the user - ** creates and populates an instance of this structure to pass - ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option. - ** Additionally, an instance of this structure can be used as an - ** output variable when querying the system for the current mutex - ** implementation, using the [SQLITE_CONFIG_GETMUTEX] option. - ** - ** ^The xMutexInit method defined by this structure is invoked as - ** part of system initialization by the sqlite3_initialize() function. - ** ^The xMutexInit routine is called by SQLite exactly once for each - ** effective call to [sqlite3_initialize()]. - ** - ** ^The xMutexEnd method defined by this structure is invoked as - ** part of system shutdown by the sqlite3_shutdown() function. The - ** implementation of this method is expected to release all outstanding - ** resources obtained by the mutex methods implementation, especially - ** those obtained by the xMutexInit method. ^The xMutexEnd() - ** interface is invoked exactly once for each call to [sqlite3_shutdown()]. - ** - ** ^(The remaining seven methods defined by this structure (xMutexAlloc, - ** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and - ** xMutexNotheld) implement the following interfaces (respectively): - ** - **
    - **
  • [sqlite3_mutex_alloc()]
  • - **
  • [sqlite3_mutex_free()]
  • - **
  • [sqlite3_mutex_enter()]
  • - **
  • [sqlite3_mutex_try()]
  • - **
  • [sqlite3_mutex_leave()]
  • - **
  • [sqlite3_mutex_held()]
  • - **
  • [sqlite3_mutex_notheld()]
  • - **
)^ - ** - ** The only difference is that the public sqlite3_XXX functions enumerated - ** above silently ignore any invocations that pass a NULL pointer instead - ** of a valid mutex handle. The implementations of the methods defined - ** by this structure are not required to handle this case, the results - ** of passing a NULL pointer instead of a valid mutex handle are undefined - ** (i.e. it is acceptable to provide an implementation that segfaults if - ** it is passed a NULL pointer). - ** - ** The xMutexInit() method must be threadsafe. ^It must be harmless to - ** invoke xMutexInit() multiple times within the same process and without - ** intervening calls to xMutexEnd(). Second and subsequent calls to - ** xMutexInit() must be no-ops. - ** - ** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()] - ** and its associates). ^Similarly, xMutexAlloc() must not use SQLite memory - ** allocation for a static mutex. ^However xMutexAlloc() may use SQLite - ** memory allocation for a fast or recursive mutex. - ** - ** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is - ** called, but only if the prior call to xMutexInit returned SQLITE_OK. - ** If xMutexInit fails in any way, it is expected to clean up after itself - ** prior to returning. - */ - //typedef struct sqlite3_mutex_methods sqlite3_mutex_methods; - //struct sqlite3_mutex_methods { - // int (*xMutexInit)(void); - // int (*xMutexEnd)(void); - // sqlite3_mutex *(*xMutexAlloc)(int); - // void (*xMutexFree)(sqlite3_mutex ); - // void (*xMutexEnter)(sqlite3_mutex ); - // int (*xMutexTry)(sqlite3_mutex ); - // void (*xMutexLeave)(sqlite3_mutex ); - // int (*xMutexHeld)(sqlite3_mutex ); - // int (*xMutexNotheld)(sqlite3_mutex ); - //}; - public class sqlite3_mutex_methods { - public dxMutexInit xMutexInit; - public dxMutexEnd xMutexEnd; - public dxMutexAlloc xMutexAlloc; - public dxMutexFree xMutexFree; - public dxMutexEnter xMutexEnter; - public dxMutexTry xMutexTry; - public dxMutexLeave xMutexLeave; - public dxMutexHeld xMutexHeld; - public dxMutexNotheld xMutexNotheld; - - public sqlite3_mutex_methods() { - } - - public sqlite3_mutex_methods( - dxMutexInit xMutexInit, - dxMutexEnd xMutexEnd, - dxMutexAlloc xMutexAlloc, - dxMutexFree xMutexFree, - dxMutexEnter xMutexEnter, - dxMutexTry xMutexTry, - dxMutexLeave xMutexLeave, - dxMutexHeld xMutexHeld, - dxMutexNotheld xMutexNotheld - ) { - this.xMutexInit = xMutexInit; - this.xMutexEnd = xMutexEnd; - this.xMutexAlloc = xMutexAlloc; - this.xMutexFree = xMutexFree; - this.xMutexEnter = xMutexEnter; - this.xMutexTry = xMutexTry; - this.xMutexLeave = xMutexLeave; - this.xMutexHeld = xMutexHeld; - this.xMutexNotheld = xMutexNotheld; - } - - //Copy sqlite3_mutex_methods from existing - public void Copy(sqlite3_mutex_methods cp) { - Debug.Assert(cp != null); - this.xMutexInit = cp.xMutexInit; - this.xMutexEnd = cp.xMutexEnd; - this.xMutexAlloc = cp.xMutexAlloc; - this.xMutexFree = cp.xMutexFree; - this.xMutexEnter = cp.xMutexEnter; - this.xMutexTry = cp.xMutexTry; - this.xMutexLeave = cp.xMutexLeave; - this.xMutexHeld = cp.xMutexHeld; - this.xMutexNotheld = cp.xMutexNotheld; - } - } - /* - ** CAPI3REF: Mutex Verification Routines - ** - ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines - ** are intended for use inside Debug.Assert() statements. ^The SQLite core - ** never uses these routines except inside an Debug.Assert() and applications - ** are advised to follow the lead of the core. ^The SQLite core only - ** provides implementations for these routines when it is compiled - ** with the SQLITE_DEBUG flag. ^External mutex implementations - ** are only required to provide these routines if SQLITE_DEBUG is - ** defined and if NDEBUG is not defined. - ** - ** ^These routines should return true if the mutex in their argument - ** is held or not held, respectively, by the calling thread. - ** - ** ^The implementation is not required to provided versions of these - ** routines that actually work. If the implementation does not provide working - ** versions of these routines, it should at least provide stubs that always - ** return true so that one does not get spurious assertion failures. - ** - ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then - ** the routine should return 1. This seems counter-intuitive since - ** clearly the mutex cannot be held if it does not exist. But - ** the reason the mutex does not exist is because the build is not - ** using mutexes. And we do not want the Debug.Assert() containing the - ** call to sqlite3_mutex_held() to fail, so a non-zero return is - ** the appropriate thing to do. ^The sqlite3_mutex_notheld() - ** interface should also return 1 when given a NULL pointer. - */ - //#if !NDEBUG - //SQLITE_API int sqlite3_mutex_held(sqlite3_mutex); - //SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex); - //#endif - - /* - ** CAPI3REF: Mutex Types - ** - ** The [sqlite3_mutex_alloc()] interface takes a single argument - ** which is one of these integer constants. - ** - ** The set of static mutexes may change from one SQLite release to the - ** next. Applications that override the built-in mutex logic must be - ** prepared to accommodate additional static mutexes. - */ - //#define SQLITE_MUTEX_FAST 0 - //#define SQLITE_MUTEX_RECURSIVE 1 - //#define SQLITE_MUTEX_STATIC_MASTER 2 - //#define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite3_malloc() */ - //#define SQLITE_MUTEX_STATIC_MEM2 4 /* NOT USED */ - //#define SQLITE_MUTEX_STATIC_OPEN 4 /* sqlite3BtreeOpen() */ - //#define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */ - //#define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */ - //#define SQLITE_MUTEX_STATIC_LRU2 7 /* NOT USED */ - //#define SQLITE_MUTEX_STATIC_PMEM 7 /* sqlite3PageMalloc() */ - const int SQLITE_MUTEX_FAST = 0; - const int SQLITE_MUTEX_RECURSIVE = 1; - const int SQLITE_MUTEX_STATIC_MASTER = 2; - const int SQLITE_MUTEX_STATIC_MEM = 3; - const int SQLITE_MUTEX_STATIC_MEM2 = 4; - const int SQLITE_MUTEX_STATIC_OPEN = 4; - const int SQLITE_MUTEX_STATIC_PRNG = 5; - const int SQLITE_MUTEX_STATIC_LRU = 6; - const int SQLITE_MUTEX_STATIC_LRU2 = 7; - const int SQLITE_MUTEX_STATIC_PMEM = 7; - - /* - ** CAPI3REF: Retrieve the mutex for a database connection - ** - ** ^This interface returns a pointer the [sqlite3_mutex] object that - ** serializes access to the [database connection] given in the argument - ** when the [threading mode] is Serialized. - ** ^If the [threading mode] is Single-thread or Multi-thread then this - ** routine returns a NULL pointer. - */ - //SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3); - - /* - ** CAPI3REF: Low-Level Control Of Database Files - ** - ** ^The [sqlite3_file_control()] interface makes a direct call to the - ** xFileControl method for the [sqlite3_io_methods] object associated - ** with a particular database identified by the second argument. ^The - ** name of the database is "main" for the main database or "temp" for the - ** TEMP database, or the name that appears after the AS keyword for - ** databases that are added using the [ATTACH] SQL command. - ** ^A NULL pointer can be used in place of "main" to refer to the - ** main database file. - ** ^The third and fourth parameters to this routine - ** are passed directly through to the second and third parameters of - ** the xFileControl method. ^The return value of the xFileControl - ** method becomes the return value of this routine. - ** - ** ^The SQLITE_FCNTL_FILE_POINTER value for the op parameter causes - ** a pointer to the underlying [sqlite3_file] object to be written into - ** the space pointed to by the 4th parameter. ^The SQLITE_FCNTL_FILE_POINTER - ** case is a short-circuit path which does not actually invoke the - ** underlying sqlite3_io_methods.xFileControl method. - ** - ** ^If the second parameter (zDbName) does not match the name of any - ** open database file, then SQLITE_ERROR is returned. ^This error - ** code is not remembered and will not be recalled by [sqlite3_errcode()] - ** or [sqlite3_errmsg()]. The underlying xFileControl method might - ** also return SQLITE_ERROR. There is no way to distinguish between - ** an incorrect zDbName and an SQLITE_ERROR return from the underlying - ** xFileControl method. - ** - ** See also: [SQLITE_FCNTL_LOCKSTATE] - */ - //SQLITE_API int sqlite3_file_control(sqlite3*, string zDbName, int op, void); - - /* - ** CAPI3REF: Testing Interface - ** - ** ^The sqlite3_test_control() interface is used to read out internal - ** state of SQLite and to inject faults into SQLite for testing - ** purposes. ^The first parameter is an operation code that determines - ** the number, meaning, and operation of all subsequent parameters. - ** - ** This interface is not for use by applications. It exists solely - ** for verifying the correct operation of the SQLite library. Depending - ** on how the SQLite library is compiled, this interface might not exist. - ** - ** The details of the operation codes, their meanings, the parameters - ** they take, and what they do are all subject to change without notice. - ** Unlike most of the SQLite API, this function is not guaranteed to - ** operate consistently from one release to the next. - */ - //SQLITE_API int sqlite3_test_control(int op, ...); - - /* - ** CAPI3REF: Testing Interface Operation Codes - ** - ** These constants are the valid operation code parameters used - ** as the first argument to [sqlite3_test_control()]. - ** - ** These parameters and their meanings are subject to change - ** without notice. These values are for testing purposes only. - ** Applications should not use any of these parameters or the - ** [sqlite3_test_control()] interface. - */ - //#define SQLITE_TESTCTRL_FIRST 5 - //#define SQLITE_TESTCTRL_PRNG_SAVE 5 - //#define SQLITE_TESTCTRL_PRNG_RESTORE 6 - //#define SQLITE_TESTCTRL_PRNG_RESET 7 - //#define SQLITE_TESTCTRL_BITVEC_TEST 8 - //#define SQLITE_TESTCTRL_FAULT_INSTALL 9 - //#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 - //#define SQLITE_TESTCTRL_PENDING_BYTE 11 - //#define SQLITE_TESTCTRL_ASSERT 12 - //#define SQLITE_TESTCTRL_ALWAYS 13 - //#define SQLITE_TESTCTRL_RESERVE 14 - //#define SQLITE_TESTCTRL_OPTIMIZATIONS 15 - //#define SQLITE_TESTCTRL_ISKEYWORD 16 - //#define SQLITE_TESTCTRL_PGHDRSZ 17 - //#define SQLITE_TESTCTRL_SCRATCHMALLOC 18 - //#define SQLITE_TESTCTRL_LOCALTIME_FAULT 19 - //#define SQLITE_TESTCTRL_LAST 19 - public const int SQLITE_TESTCTRL_FIRST = 5; - public const int SQLITE_TESTCTRL_PRNG_SAVE = 5; - public const int SQLITE_TESTCTRL_PRNG_RESTORE = 6; - public const int SQLITE_TESTCTRL_PRNG_RESET = 7; - public const int SQLITE_TESTCTRL_BITVEC_TEST = 8; - public const int SQLITE_TESTCTRL_FAULT_INSTALL = 9; - public const int SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS = 10; - public const int SQLITE_TESTCTRL_PENDING_BYTE = 11; - public const int SQLITE_TESTCTRL_ASSERT = 12; - public const int SQLITE_TESTCTRL_ALWAYS = 13; - public const int SQLITE_TESTCTRL_RESERVE = 14; - public const int SQLITE_TESTCTRL_OPTIMIZATIONS = 15; - public const int SQLITE_TESTCTRL_ISKEYWORD = 16; - public const int SQLITE_TESTCTRL_PGHDRSZ = 17; - public const int SQLITE_TESTCTRL_SCRATCHMALLOC = 18; - public const int SQLITE_TESTCTRL_LOCALTIME_FAULT = 19; - public const int SQLITE_TESTCTRL_LAST = 19; - - /* - ** CAPI3REF: SQLite Runtime Status - ** - ** ^This interface is used to retrieve runtime status information - ** about the performance of SQLite, and optionally to reset various - ** highwater marks. ^The first argument is an integer code for - ** the specific parameter to measure. ^(Recognized integer codes - ** are of the form [status parameters | SQLITE_STATUS_...].)^ - ** ^The current value of the parameter is returned into *pCurrent. - ** ^The highest recorded value is returned in *pHighwater. ^If the - ** resetFlag is true, then the highest record value is reset after - ** *pHighwater is written. ^(Some parameters do not record the highest - ** value. For those parameters - ** nothing is written into *pHighwater and the resetFlag is ignored.)^ - ** ^(Other parameters record only the highwater mark and not the current - ** value. For these latter parameters nothing is written into *pCurrent.)^ - ** - ** ^The sqlite3_status() routine returns SQLITE_OK on success and a - ** non-zero [error code] on failure. - ** - ** This routine is threadsafe but is not atomic. This routine can be - ** called while other threads are running the same or different SQLite - ** interfaces. However the values returned in *pCurrent and - ** *pHighwater reflect the status of SQLite at different points in time - ** and it is possible that another thread might change the parameter - ** in between the times when *pCurrent and *pHighwater are written. - ** - ** See also: [sqlite3_db_status()] - */ - //SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); - - - /* - ** CAPI3REF: Status Parameters - ** KEYWORDS: {status parameters} - ** - ** These integer constants designate various run-time status parameters - ** that can be returned by [sqlite3_status()]. - ** - **
- ** [[SQLITE_STATUS_MEMORY_USED]] ^(
SQLITE_STATUS_MEMORY_USED
- **
This parameter is the current amount of memory checked out - ** using [sqlite3_malloc()], either directly or indirectly. The - ** figure includes calls made to [sqlite3_malloc()] by the application - ** and internal memory usage by the SQLite library. Scratch memory - ** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache - ** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in - ** this parameter. The amount returned is the sum of the allocation - ** sizes as reported by the xSize method in [sqlite3_mem_methods].
)^ - ** - ** [[SQLITE_STATUS_MALLOC_SIZE]] ^(
SQLITE_STATUS_MALLOC_SIZE
- **
This parameter records the largest memory allocation request - ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their - ** internal equivalents). Only the value returned in the - ** *pHighwater parameter to [sqlite3_status()] is of interest. - ** The value written into the *pCurrent parameter is undefined.
)^ - ** - ** [[SQLITE_STATUS_MALLOC_COUNT]] ^(
SQLITE_STATUS_MALLOC_COUNT
- **
This parameter records the number of separate memory allocations - ** currently checked out.
)^ - ** - ** [[SQLITE_STATUS_PAGECACHE_USED]] ^(
SQLITE_STATUS_PAGECACHE_USED
- **
This parameter returns the number of pages used out of the - ** [pagecache memory allocator] that was configured using - ** [SQLITE_CONFIG_PAGECACHE]. The - ** value returned is in pages, not in bytes.
)^ - ** - ** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]] - ** ^(
SQLITE_STATUS_PAGECACHE_OVERFLOW
- **
This parameter returns the number of bytes of page cache - ** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE] - ** buffer and where forced to overflow to [sqlite3_malloc()]. The - ** returned value includes allocations that overflowed because they - ** where too large (they were larger than the "sz" parameter to - ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because - ** no space was left in the page cache.
)^ - ** - ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(
SQLITE_STATUS_PAGECACHE_SIZE
- **
This parameter records the largest memory allocation request - ** handed to [pagecache memory allocator]. Only the value returned in the - ** *pHighwater parameter to [sqlite3_status()] is of interest. - ** The value written into the *pCurrent parameter is undefined.
)^ - ** - ** [[SQLITE_STATUS_SCRATCH_USED]] ^(
SQLITE_STATUS_SCRATCH_USED
- **
This parameter returns the number of allocations used out of the - ** [scratch memory allocator] configured using - ** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not - ** in bytes. Since a single thread may only have one scratch allocation - ** outstanding at time, this parameter also reports the number of threads - ** using scratch memory at the same time.
)^ - ** - ** [[SQLITE_STATUS_SCRATCH_OVERFLOW]] ^(
SQLITE_STATUS_SCRATCH_OVERFLOW
- **
This parameter returns the number of bytes of scratch memory - ** allocation which could not be satisfied by the [SQLITE_CONFIG_SCRATCH] - ** buffer and where forced to overflow to [sqlite3_malloc()]. The values - ** returned include overflows because the requested allocation was too - ** larger (that is, because the requested allocation was larger than the - ** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer - ** slots were available. - **
)^ - ** - ** [[SQLITE_STATUS_SCRATCH_SIZE]] ^(
SQLITE_STATUS_SCRATCH_SIZE
- **
This parameter records the largest memory allocation request - ** handed to [scratch memory allocator]. Only the value returned in the - ** *pHighwater parameter to [sqlite3_status()] is of interest. - ** The value written into the *pCurrent parameter is undefined.
)^ - ** - ** [[SQLITE_STATUS_PARSER_STACK]] ^(
SQLITE_STATUS_PARSER_STACK
- **
This parameter records the deepest parser stack. It is only - ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].
)^ - **
- ** - ** New status parameters may be added from time to time. - */ - //#define SQLITE_STATUS_MEMORY_USED 0 - //#define SQLITE_STATUS_PAGECACHE_USED 1 - //#define SQLITE_STATUS_PAGECACHE_OVERFLOW 2 - //#define SQLITE_STATUS_SCRATCH_USED 3 - //#define SQLITE_STATUS_SCRATCH_OVERFLOW 4 - //#define SQLITE_STATUS_MALLOC_SIZE 5 - //#define SQLITE_STATUS_PARSER_STACK 6 - //#define SQLITE_STATUS_PAGECACHE_SIZE 7 - //#define SQLITE_STATUS_SCRATCH_SIZE 8 - //#define SQLITE_STATUS_MALLOC_COUNT 9 - public const int SQLITE_STATUS_MEMORY_USED = 0; - public const int SQLITE_STATUS_PAGECACHE_USED = 1; - public const int SQLITE_STATUS_PAGECACHE_OVERFLOW = 2; - public const int SQLITE_STATUS_SCRATCH_USED = 3; - public const int SQLITE_STATUS_SCRATCH_OVERFLOW = 4; - public const int SQLITE_STATUS_MALLOC_SIZE = 5; - public const int SQLITE_STATUS_PARSER_STACK = 6; - public const int SQLITE_STATUS_PAGECACHE_SIZE = 7; - public const int SQLITE_STATUS_SCRATCH_SIZE = 8; - public const int SQLITE_STATUS_MALLOC_COUNT = 9; - - /* - ** CAPI3REF: Database Connection Status - ** - ** ^This interface is used to retrieve runtime status information - ** about a single [database connection]. ^The first argument is the - ** database connection object to be interrogated. ^The second argument - ** is an integer constant, taken from the set of - ** [SQLITE_DBSTATUS options], that - ** determines the parameter to interrogate. The set of - ** [SQLITE_DBSTATUS options] is likely - ** to grow in future releases of SQLite. - ** - ** ^The current value of the requested parameter is written into *pCur - ** and the highest instantaneous value is written into *pHiwtr. ^If - ** the resetFlg is true, then the highest instantaneous value is - ** reset back down to the current value. - ** - ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a - ** non-zero [error code] on failure. - ** - ** See also: [sqlite3_status()] and [sqlite3_stmt_status()]. - */ - //SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); - - /* - ** CAPI3REF: Status Parameters for database connections - ** KEYWORDS: {SQLITE_DBSTATUS options} - ** - ** These constants are the available integer "verbs" that can be passed as - ** the second argument to the [sqlite3_db_status()] interface. - ** - ** New verbs may be added in future releases of SQLite. Existing verbs - ** might be discontinued. Applications should check the return code from - ** [sqlite3_db_status()] to make sure that the call worked. - ** The [sqlite3_db_status()] interface will return a non-zero error code - ** if a discontinued or unsupported verb is invoked. - ** - **
- ** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(
SQLITE_DBSTATUS_LOOKASIDE_USED
- **
This parameter returns the number of lookaside memory slots currently - ** checked out.
)^ - ** - ** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(
SQLITE_DBSTATUS_LOOKASIDE_HIT
- **
This parameter returns the number malloc attempts that were - ** satisfied using lookaside memory. Only the high-water value is meaningful; - ** the current value is always zero.)^ - ** - ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]] - ** ^(
SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE
- **
This parameter returns the number malloc attempts that might have - ** been satisfied using lookaside memory but failed due to the amount of - ** memory requested being larger than the lookaside slot size. - ** Only the high-water value is meaningful; - ** the current value is always zero.)^ - ** - ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]] - ** ^(
SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL
- **
This parameter returns the number malloc attempts that might have - ** been satisfied using lookaside memory but failed due to all lookaside - ** memory already being in use. - ** Only the high-water value is meaningful; - ** the current value is always zero.)^ - ** - ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(
SQLITE_DBSTATUS_CACHE_USED
- **
This parameter returns the approximate number of of bytes of heap - ** memory used by all pager caches associated with the database connection.)^ - ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. - ** - ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(
SQLITE_DBSTATUS_SCHEMA_USED
- **
This parameter returns the approximate number of of bytes of heap - ** memory used to store the schema for all databases associated - ** with the connection - main, temp, and any [ATTACH]-ed databases.)^ - ** ^The full amount of memory used by the schemas is reported, even if the - ** schema memory is shared with other database connections due to - ** [shared cache mode] being enabled. - ** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0. - ** - ** [[SQLITE_DBSTATUS_STMT_USED]] ^(
SQLITE_DBSTATUS_STMT_USED
- **
This parameter returns the approximate number of of bytes of heap - ** and lookaside memory used by all prepared statements associated with - ** the database connection.)^ - ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. - **
- **
- */ - //#define SQLITE_DBSTATUS_LOOKASIDE_USED 0 - //#define SQLITE_DBSTATUS_CACHE_USED 1 - //#define SQLITE_DBSTATUS_SCHEMA_USED 2 - //#define SQLITE_DBSTATUS_STMT_USED 3 - //#define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 - //#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 - //#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 - //#define SQLITE_DBSTATUS_MAX 6 /* Largest defined DBSTATUS */ - public const int SQLITE_DBSTATUS_LOOKASIDE_USED = 0; - public const int SQLITE_DBSTATUS_CACHE_USED = 1; - public const int SQLITE_DBSTATUS_SCHEMA_USED = 2; - public const int SQLITE_DBSTATUS_STMT_USED = 3; - public const int SQLITE_DBSTATUS_LOOKASIDE_HIT = 4; - public const int SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE = 5; - public const int SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL = 6; - public const int SQLITE_DBSTATUS_MAX = 6; - - - /* - ** CAPI3REF: Prepared Statement Status - ** - ** ^(Each prepared statement maintains various - ** [SQLITE_STMTSTATUS counters] that measure the number - ** of times it has performed specific operations.)^ These counters can - ** be used to monitor the performance characteristics of the prepared - ** statements. For example, if the number of table steps greatly exceeds - ** the number of table searches or result rows, that would tend to indicate - ** that the prepared statement is using a full table scan rather than - ** an index. - ** - ** ^(This interface is used to retrieve and reset counter values from - ** a [prepared statement]. The first argument is the prepared statement - ** object to be interrogated. The second argument - ** is an integer code for a specific [SQLITE_STMTSTATUS counte - ** to be interrogated.)^ - ** ^The current value of the requested counter is returned. - ** ^If the resetFlg is true, then the counter is reset to zero after this - ** interface call returns. - ** - ** See also: [sqlite3_status()] and [sqlite3_db_status()]. - */ - //SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); - - /* - ** CAPI3REF: Status Parameters for prepared statements - ** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters} - ** - ** These preprocessor macros define integer codes that name counter - ** values associated with the [sqlite3_stmt_status()] interface. - ** The meanings of the various counters are as follows: - ** - **
- ** [[SQLITE_STMTSTATUS_FULLSCAN_STEP]]
SQLITE_STMTSTATUS_FULLSCAN_STEP
- **
^This is the number of times that SQLite has stepped forward in - ** a table as part of a full table scan. Large numbers for this counter - ** may indicate opportunities for performance improvement through - ** careful use of indices.
- ** - ** [[SQLITE_STMTSTATUS_SORT]]
SQLITE_STMTSTATUS_SORT
- **
^This is the number of sort operations that have occurred. - ** A non-zero value in this counter may indicate an opportunity to - ** improvement performance through careful use of indices.
- ** - ** [[SQLITE_STMTSTATUS_AUTOINDEX]]
SQLITE_STMTSTATUS_AUTOINDEX
- **
^This is the number of rows inserted into transient indices that - ** were created automatically in order to help joins run faster. - ** A non-zero value in this counter may indicate an opportunity to - ** improvement performance by adding permanent indices that do not - ** need to be reinitialized each time the statement is run.
- ** - **
- */ - //#define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 - //#define SQLITE_STMTSTATUS_SORT 2 - //#define SQLITE_STMTSTATUS_AUTOINDEX 3 - public const int SQLITE_STMTSTATUS_FULLSCAN_STEP = 1; - public const int SQLITE_STMTSTATUS_SORT = 2; - public const int SQLITE_STMTSTATUS_AUTOINDEX = 3; - - /* - ** CAPI3REF: Custom Page Cache Object - ** - ** The sqlite3_pcache type is opaque. It is implemented by - ** the pluggable module. The SQLite core has no knowledge of - ** its size or internal structure and never deals with the - ** sqlite3_pcache object except by holding and passing pointers - ** to the object. - ** - ** See [sqlite3_pcache_methods] for additional information. - */ - //typedef struct sqlite3_pcache sqlite3_pcache; - - /* - ** CAPI3REF: Application Defined Page Cache. - ** KEYWORDS: {page cache} - ** - ** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can - ** register an alternative page cache implementation by passing in an - ** instance of the sqlite3_pcache_methods structure.)^ - ** In many applications, most of the heap memory allocated by - ** SQLite is used for the page cache. - ** By implementing a - ** custom page cache using this API, an application can better control - ** the amount of memory consumed by SQLite, the way in which - ** that memory is allocated and released, and the policies used to - ** determine exactly which parts of a database file are cached and for - ** how long. - ** - ** The alternative page cache mechanism is an - ** extreme measure that is only needed by the most demanding applications. - ** The built-in page cache is recommended for most uses. - ** - ** ^(The contents of the sqlite3_pcache_methods structure are copied to an - ** internal buffer by SQLite within the call to [sqlite3_config]. Hence - ** the application may discard the parameter after the call to - ** [sqlite3_config()] returns.)^ - ** - ** [[the xInit() page cache method]] - ** ^(The xInit() method is called once for each effective - ** call to [sqlite3_initialize()])^ - ** (usually only once during the lifetime of the process). ^(The xInit() - ** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^ - ** The intent of the xInit() method is to set up global data structures - ** required by the custom page cache implementation. - ** ^(If the xInit() method is NULL, then the - ** built-in default page cache is used instead of the application defined - ** page cache.)^ - ** - ** [[the xShutdown() page cache method]] - ** ^The xShutdown() method is called by [sqlite3_shutdown()]. - ** It can be used to clean up - ** any outstanding resources before process shutdown, if required. - ** ^The xShutdown() method may be NULL. - ** - ** ^SQLite automatically serializes calls to the xInit method, - ** so the xInit method need not be threadsafe. ^The - ** xShutdown method is only called from [sqlite3_shutdown()] so it does - ** not need to be threadsafe either. All other methods must be threadsafe - ** in multithreaded applications. - ** - ** ^SQLite will never invoke xInit() more than once without an intervening - ** call to xShutdown(). - ** - ** [[the xCreate() page cache methods]] - ** ^SQLite invokes the xCreate() method to construct a new cache instance. - ** SQLite will typically create one cache instance for each open database file, - ** though this is not guaranteed. ^The - ** first parameter, szPage, is the size in bytes of the pages that must - ** be allocated by the cache. ^szPage will not be a power of two. ^szPage - ** will the page size of the database file that is to be cached plus an - ** increment (here called "R") of less than 250. SQLite will use the - ** extra R bytes on each page to store metadata about the underlying - ** database page on disk. The value of R depends - ** on the SQLite version, the target platform, and how SQLite was compiled. - ** ^(R is constant for a particular build of SQLite. Except, there are two - ** distinct values of R when SQLite is compiled with the proprietary - ** ZIPVFS extension.)^ ^The second argument to - ** xCreate(), bPurgeable, is true if the cache being created will - ** be used to cache database pages of a file stored on disk, or - ** false if it is used for an in-memory database. The cache implementation - ** does not have to do anything special based with the value of bPurgeable; - ** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will - ** never invoke xUnpin() except to deliberately delete a page. - ** ^In other words, calls to xUnpin() on a cache with bPurgeable set to - ** false will always have the "discard" flag set to true. - ** ^Hence, a cache created with bPurgeable false will - ** never contain any unpinned pages. - ** - ** [[the xCachesize() page cache method]] - ** ^(The xCachesize() method may be called at any time by SQLite to set the - ** suggested maximum cache-size (number of pages stored by) the cache - ** instance passed as the first argument. This is the value configured using - ** the SQLite "[PRAGMA cache_size]" command.)^ As with the bPurgeable - ** parameter, the implementation is not required to do anything with this - ** value; it is advisory only. - ** - ** [[the xPagecount() page cache methods]] - ** The xPagecount() method must return the number of pages currently - ** stored in the cache, both pinned and unpinned. - ** - ** [[the xFetch() page cache methods]] - ** The xFetch() method locates a page in the cache and returns a pointer to - ** the page, or a NULL pointer. - ** A "page", in this context, means a buffer of szPage bytes aligned at an - ** 8-byte boundary. The page to be fetched is determined by the key. ^The - ** minimum key value is 1. After it has been retrieved using xFetch, the page - ** is considered to be "pinned". - ** - ** If the requested page is already in the page cache, then the page cache - ** implementation must return a pointer to the page buffer with its content - ** intact. If the requested page is not already in the cache, then the - ** cache implementation should use the value of the createFlag - ** parameter to help it determined what action to take: - ** - ** - **
createFlag Behaviour when page is not already in cache - **
0 Do not allocate a new page. Return NULL. - **
1 Allocate a new page if it easy and convenient to do so. - ** Otherwise return NULL. - **
2 Make every effort to allocate a new page. Only return - ** NULL if allocating a new page is effectively impossible. - **
- ** - ** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite - ** will only use a createFlag of 2 after a prior call with a createFlag of 1 - ** failed.)^ In between the to xFetch() calls, SQLite may - ** attempt to unpin one or more cache pages by spilling the content of - ** pinned pages to disk and synching the operating system disk cache. - ** - ** [[the xUnpin() page cache method]] - ** ^xUnpin() is called by SQLite with a pointer to a currently pinned page - ** as its second argument. If the third parameter, discard, is non-zero, - ** then the page must be evicted from the cache. - ** ^If the discard parameter is - ** zero, then the page may be discarded or retained at the discretion of - ** page cache implementation. ^The page cache implementation - ** may choose to evict unpinned pages at any time. - ** - ** The cache must not perform any reference counting. A single - ** call to xUnpin() unpins the page regardless of the number of prior calls - ** to xFetch(). - ** - ** [[the xRekey() page cache methods]] - ** The xRekey() method is used to change the key value associated with the - ** page passed as the second argument. If the cache - ** previously contains an entry associated with newKey, it must be - ** discarded. ^Any prior cache entry associated with newKey is guaranteed not - ** to be pinned. - ** - ** When SQLite calls the xTruncate() method, the cache must discard all - ** existing cache entries with page numbers (keys) greater than or equal - ** to the value of the iLimit parameter passed to xTruncate(). If any - ** of these pages are pinned, they are implicitly unpinned, meaning that - ** they can be safely discarded. - ** - ** [[the xDestroy() page cache method]] - ** ^The xDestroy() method is used to delete a cache allocated by xCreate(). - ** All resources associated with the specified cache should be freed. ^After - ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] - ** handle invalid, and will not use it with any other sqlite3_pcache_methods - ** functions. - */ - //typedef struct sqlite3_pcache_methods sqlite3_pcache_methods; - //struct sqlite3_pcache_methods { - // void *pArg; - // int (*xInit)(void); - // void (*xShutdown)(void); - // sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable); - // void (*xCachesize)(sqlite3_pcache*, int nCachesize); - // int (*xPagecount)(sqlite3_pcache); - // void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); - // void (*xUnpin)(sqlite3_pcache*, void*, int discard); - // void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey); - // void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); - // void (*xDestroy)(sqlite3_pcache); - //}; - public class sqlite3_pcache_methods { - public object pArg; - public dxPC_Init xInit;//int (*xInit)(void); - public dxPC_Shutdown xShutdown;//public void (*xShutdown)(void); - public dxPC_Create xCreate;//public sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable); - public dxPC_Cachesize xCachesize;//public void (*xCachesize)(sqlite3_pcache*, int nCachesize); - public dxPC_Pagecount xPagecount;//public int (*xPagecount)(sqlite3_pcache); - public dxPC_Fetch xFetch;//public void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); - public dxPC_Unpin xUnpin;//public void (*xUnpin)(sqlite3_pcache*, void*, int discard); - public dxPC_Rekey xRekey;//public void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey); - public dxPC_Truncate xTruncate;//public void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); - public dxPC_Destroy xDestroy;//public void (*xDestroy)(sqlite3_pcache); - - public sqlite3_pcache_methods() { - } - - public sqlite3_pcache_methods(object pArg, dxPC_Init xInit, dxPC_Shutdown xShutdown, dxPC_Create xCreate, dxPC_Cachesize xCachesize, dxPC_Pagecount xPagecount, dxPC_Fetch xFetch, dxPC_Unpin xUnpin, dxPC_Rekey xRekey, dxPC_Truncate xTruncate, dxPC_Destroy xDestroy) { - this.pArg = pArg; - this.xInit = xInit; - this.xShutdown = xShutdown; - this.xCreate = xCreate; - this.xCachesize = xCachesize; - this.xPagecount = xPagecount; - this.xFetch = xFetch; - this.xUnpin = xUnpin; - this.xRekey = xRekey; - this.xTruncate = xTruncate; - this.xDestroy = xDestroy; - } - }; - - - /* - ** CAPI3REF: Online Backup Object - ** - ** The sqlite3_backup object records state information about an ongoing - ** online backup operation. ^The sqlite3_backup object is created by - ** a call to [sqlite3_backup_init()] and is destroyed by a call to - ** [sqlite3_backup_finish()]. - ** - ** See Also: [Using the SQLite Online Backup API] - */ - //typedef struct sqlite3_backup sqlite3_backup; - - /* - ** CAPI3REF: Online Backup API. - ** - ** The backup API copies the content of one database into another. - ** It is useful either for creating backups of databases or - ** for copying in-memory databases to or from persistent files. - ** - ** See Also: [Using the SQLite Online Backup API] - ** - ** ^SQLite holds a write transaction open on the destination database file - ** for the duration of the backup operation. - ** ^The source database is read-locked only while it is being read; - ** it is not locked continuously for the entire backup operation. - ** ^Thus, the backup may be performed on a live source database without - ** preventing other database connections from - ** reading or writing to the source database while the backup is underway. - ** - ** ^(To perform a backup operation: - **
    - **
  1. sqlite3_backup_init() is called once to initialize the - ** backup, - **
  2. sqlite3_backup_step() is called one or more times to transfer - ** the data between the two databases, and finally - **
  3. sqlite3_backup_finish() is called to release all resources - ** associated with the backup operation. - **
)^ - ** There should be exactly one call to sqlite3_backup_finish() for each - ** successful call to sqlite3_backup_init(). - ** - ** [[sqlite3_backup_init()]] sqlite3_backup_init() - ** - ** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the - ** [database connection] associated with the destination database - ** and the database name, respectively. - ** ^The database name is "main" for the main database, "temp" for the - ** temporary database, or the name specified after the AS keyword in - ** an [ATTACH] statement for an attached database. - ** ^The S and M arguments passed to - ** sqlite3_backup_init(D,N,S,M) identify the [database connection] - ** and database name of the source database, respectively. - ** ^The source and destination [database connections] (parameters S and D) - ** must be different or else sqlite3_backup_init(D,N,S,M) will fail with - ** an error. - ** - ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is - ** returned and an error code and error message are stored in the - ** destination [database connection] D. - ** ^The error code and message for the failed call to sqlite3_backup_init() - ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or - ** [sqlite3_errmsg16()] functions. - ** ^A successful call to sqlite3_backup_init() returns a pointer to an - ** [sqlite3_backup] object. - ** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and - ** sqlite3_backup_finish() functions to perform the specified backup - ** operation. - ** - ** [[sqlite3_backup_step()]] sqlite3_backup_step() - ** - ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between - ** the source and destination databases specified by [sqlite3_backup] object B. - ** ^If N is negative, all remaining source pages are copied. - ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there - ** are still more pages to be copied, then the function returns [SQLITE_OK]. - ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages - ** from source to destination, then it returns [SQLITE_DONE]. - ** ^If an error occurs while running sqlite3_backup_step(B,N), - ** then an [error code] is returned. ^As well as [SQLITE_OK] and - ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], - ** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an - ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code. - ** - ** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if - **
    - **
  1. the destination database was opened read-only, or - **
  2. the destination database is using write-ahead-log journaling - ** and the destination and source page sizes differ, or - **
  3. the destination database is an in-memory database and the - ** destination and source page sizes differ. - **
)^ - ** - ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then - ** the [sqlite3_busy_handler | busy-handler function] - ** is invoked (if one is specified). ^If the - ** busy-handler returns non-zero before the lock is available, then - ** [SQLITE_BUSY] is returned to the caller. ^In this case the call to - ** sqlite3_backup_step() can be retried later. ^If the source - ** [database connection] - ** is being used to write to the source database when sqlite3_backup_step() - ** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this - ** case the call to sqlite3_backup_step() can be retried later on. ^(If - ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or - ** [SQLITE_READONLY] is returned, then - ** there is no point in retrying the call to sqlite3_backup_step(). These - ** errors are considered fatal.)^ The application must accept - ** that the backup operation has failed and pass the backup operation handle - ** to the sqlite3_backup_finish() to release associated resources. - ** - ** ^The first call to sqlite3_backup_step() obtains an exclusive lock - ** on the destination file. ^The exclusive lock is not released until either - ** sqlite3_backup_finish() is called or the backup operation is complete - ** and sqlite3_backup_step() returns [SQLITE_DONE]. ^Every call to - ** sqlite3_backup_step() obtains a [shared lock] on the source database that - ** lasts for the duration of the sqlite3_backup_step() call. - ** ^Because the source database is not locked between calls to - ** sqlite3_backup_step(), the source database may be modified mid-way - ** through the backup process. ^If the source database is modified by an - ** external process or via a database connection other than the one being - ** used by the backup operation, then the backup will be automatically - ** restarted by the next call to sqlite3_backup_step(). ^If the source - ** database is modified by the using the same database connection as is used - ** by the backup operation, then the backup database is automatically - ** updated at the same time. - ** - ** [[sqlite3_backup_finish()]] sqlite3_backup_finish() - ** - ** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the - ** application wishes to abandon the backup operation, the application - ** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish(). - ** ^The sqlite3_backup_finish() interfaces releases all - ** resources associated with the [sqlite3_backup] object. - ** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any - ** active write-transaction on the destination database is rolled back. - ** The [sqlite3_backup] object is invalid - ** and may not be used following a call to sqlite3_backup_finish(). - ** - ** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no - ** sqlite3_backup_step() errors occurred, regardless or whether or not - ** sqlite3_backup_step() completed. - ** ^If an out-of-memory condition or IO error occurred during any prior - ** sqlite3_backup_step() call on the same [sqlite3_backup] object, then - ** sqlite3_backup_finish() returns the corresponding [error code]. - ** - ** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step() - ** is not a permanent error and does not affect the return value of - ** sqlite3_backup_finish(). - ** - ** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]] - ** sqlite3_backup_remaining() and sqlite3_backup_pagecount() - ** - ** ^Each call to sqlite3_backup_step() sets two values inside - ** the [sqlite3_backup] object: the number of pages still to be backed - ** up and the total number of pages in the source database file. - ** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces - ** retrieve these two values, respectively. - ** - ** ^The values returned by these functions are only updated by - ** sqlite3_backup_step(). ^If the source database is modified during a backup - ** operation, then the values are not updated to account for any extra - ** pages that need to be updated or the size of the source database file - ** changing. - ** - ** Concurrent Usage of Database Handles - ** - ** ^The source [database connection] may be used by the application for other - ** purposes while a backup operation is underway or being initialized. - ** ^If SQLite is compiled and configured to support threadsafe database - ** connections, then the source database connection may be used concurrently - ** from within other threads. - ** - ** However, the application must guarantee that the destination - ** [database connection] is not passed to any other API (by any thread) after - ** sqlite3_backup_init() is called and before the corresponding call to - ** sqlite3_backup_finish(). SQLite does not currently check to see - ** if the application incorrectly accesses the destination [database connection] - ** and so no error code is reported, but the operations may malfunction - ** nevertheless. Use of the destination database connection while a - ** backup is in progress might also also cause a mutex deadlock. - ** - ** If running in [shared cache mode], the application must - ** guarantee that the shared cache used by the destination database - ** is not accessed while the backup is running. In practice this means - ** that the application must guarantee that the disk file being - ** backed up to is not accessed by any connection within the process, - ** not just the specific connection that was passed to sqlite3_backup_init(). - ** - ** The [sqlite3_backup] object itself is partially threadsafe. Multiple - ** threads may safely make multiple concurrent calls to sqlite3_backup_step(). - ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount() - ** APIs are not strictly speaking threadsafe. If they are invoked at the - ** same time as another thread is invoking sqlite3_backup_step() it is - ** possible that they return invalid values. - */ - //SQLITE_API sqlite3_backup *sqlite3_backup_init( - // sqlite3 *pDest, /* Destination database handle */ - // string zDestName, /* Destination database name */ - // sqlite3 *pSource, /* Source database handle */ - // string zSourceName /* Source database name */ - //); - //SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage); - //SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p); - //SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p); - //SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p); - - /* - ** CAPI3REF: Unlock Notification - ** - ** ^When running in shared-cache mode, a database operation may fail with - ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or - ** individual tables within the shared-cache cannot be obtained. See - ** [SQLite Shared-Cache Mode] for a description of shared-cache locking. - ** ^This API may be used to register a callback that SQLite will invoke - ** when the connection currently holding the required lock relinquishes it. - ** ^This API is only available if the library was compiled with the - ** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined. - ** - ** See Also: [Using the SQLite Unlock Notification Feature]. - ** - ** ^Shared-cache locks are released when a database connection concludes - ** its current transaction, either by committing it or rolling it back. - ** - ** ^When a connection (known as the blocked connection) fails to obtain a - ** shared-cache lock and SQLITE_LOCKED is returned to the caller, the - ** identity of the database connection (the blocking connection) that - ** has locked the required resource is stored internally. ^After an - ** application receives an SQLITE_LOCKED error, it may call the - ** sqlite3_unlock_notify() method with the blocked connection handle as - ** the first argument to register for a callback that will be invoked - ** when the blocking connections current transaction is concluded. ^The - ** callback is invoked from within the [sqlite3_step] or [sqlite3_close] - ** call that concludes the blocking connections transaction. - ** - ** ^(If sqlite3_unlock_notify() is called in a multi-threaded application, - ** there is a chance that the blocking connection will have already - ** concluded its transaction by the time sqlite3_unlock_notify() is invoked. - ** If this happens, then the specified callback is invoked immediately, - ** from within the call to sqlite3_unlock_notify().)^ - ** - ** ^If the blocked connection is attempting to obtain a write-lock on a - ** shared-cache table, and more than one other connection currently holds - ** a read-lock on the same table, then SQLite arbitrarily selects one of - ** the other connections to use as the blocking connection. - ** - ** ^(There may be at most one unlock-notify callback registered by a - ** blocked connection. If sqlite3_unlock_notify() is called when the - ** blocked connection already has a registered unlock-notify callback, - ** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is - ** called with a NULL pointer as its second argument, then any existing - ** unlock-notify callback is canceled. ^The blocked connections - ** unlock-notify callback may also be canceled by closing the blocked - ** connection using [sqlite3_close()]. - ** - ** The unlock-notify callback is not reentrant. If an application invokes - ** any sqlite3_xxx API functions from within an unlock-notify callback, a - ** crash or deadlock may be the result. - ** - ** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always - ** returns SQLITE_OK. - ** - ** Callback Invocation Details - ** - ** When an unlock-notify callback is registered, the application provides a - ** single void* pointer that is passed to the callback when it is invoked. - ** However, the signature of the callback function allows SQLite to pass - ** it an array of void* context pointers. The first argument passed to - ** an unlock-notify callback is a pointer to an array of void* pointers, - ** and the second is the number of entries in the array. - ** - ** When a blocking connections transaction is concluded, there may be - ** more than one blocked connection that has registered for an unlock-notify - ** callback. ^If two or more such blocked connections have specified the - ** same callback function, then instead of invoking the callback function - ** multiple times, it is invoked once with the set of void* context pointers - ** specified by the blocked connections bundled together into an array. - ** This gives the application an opportunity to prioritize any actions - ** related to the set of unblocked database connections. - ** - ** Deadlock Detection - ** - ** Assuming that after registering for an unlock-notify callback a - ** database waits for the callback to be issued before taking any further - ** action (a reasonable assumption), then using this API may cause the - ** application to deadlock. For example, if connection X is waiting for - ** connection Y's transaction to be concluded, and similarly connection - ** Y is waiting on connection X's transaction, then neither connection - ** will proceed and the system may remain deadlocked indefinitely. - ** - ** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock - ** detection. ^If a given call to sqlite3_unlock_notify() would put the - ** system in a deadlocked state, then SQLITE_LOCKED is returned and no - ** unlock-notify callback is registered. The system is said to be in - ** a deadlocked state if connection A has registered for an unlock-notify - ** callback on the conclusion of connection B's transaction, and connection - ** B has itself registered for an unlock-notify callback when connection - ** A's transaction is concluded. ^Indirect deadlock is also detected, so - ** the system is also considered to be deadlocked if connection B has - ** registered for an unlock-notify callback on the conclusion of connection - ** C's transaction, where connection C is waiting on connection A. ^Any - ** number of levels of indirection are allowed. - ** - ** The "DROP TABLE" Exception - ** - ** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost - ** always appropriate to call sqlite3_unlock_notify(). There is however, - ** one exception. When executing a "DROP TABLE" or "DROP INDEX" statement, - ** SQLite checks if there are any currently executing SELECT statements - ** that belong to the same connection. If there are, SQLITE_LOCKED is - ** returned. In this case there is no "blocking connection", so invoking - ** sqlite3_unlock_notify() results in the unlock-notify callback being - ** invoked immediately. If the application then re-attempts the "DROP TABLE" - ** or "DROP INDEX" query, an infinite loop might be the result. - ** - ** One way around this problem is to check the extended error code returned - ** by an sqlite3_step() call. ^(If there is a blocking connection, then the - ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in - ** the special "DROP TABLE/INDEX" case, the extended error code is just - ** SQLITE_LOCKED.)^ - */ - //SQLITE_API int sqlite3_unlock_notify( - // sqlite3 *pBlocked, /* Waiting connection */ - // void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */ - // void *pNotifyArg /* Argument to pass to xNotify */ - //); - - - /* - ** CAPI3REF: String Comparison - ** - ** ^The [sqlite3_strnicmp()] API allows applications and extensions to - ** compare the contents of two buffers containing UTF-8 strings in a - ** case-independent fashion, using the same definition of case independence - ** that SQLite uses internally when comparing identifiers. - */ - //SQLITE_API int sqlite3_strnicmp(string , string , int); - - /* - ** CAPI3REF: Error Logging Interface - ** - ** ^The [sqlite3_log()] interface writes a message into the error log - ** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()]. - ** ^If logging is enabled, the zFormat string and subsequent arguments are - ** used with [sqlite3_snprintf()] to generate the final output string. - ** - ** The sqlite3_log() interface is intended for use by extensions such as - ** virtual tables, collating functions, and SQL functions. While there is - ** nothing to prevent an application from calling sqlite3_log(), doing so - ** is considered bad form. - ** - ** The zFormat string must not be NULL. - ** - ** To avoid deadlocks and other threading problems, the sqlite3_log() routine - ** will not use dynamically allocated memory. The log message is stored in - ** a fixed-length buffer on the stack. If the log message is longer than - ** a few hundred characters, it will be truncated to the length of the - ** buffer. - */ - //SQLITE_API void sqlite3_log(int iErrCode, string zFormat, ...); - - /* - ** CAPI3REF: Write-Ahead Log Commit Hook - ** - ** ^The [sqlite3_wal_hook()] function is used to register a callback that - ** will be invoked each time a database connection commits data to a - ** [write-ahead log] (i.e. whenever a transaction is committed in - ** [journal_mode | journal_mode=WAL mode]). - ** - ** ^The callback is invoked by SQLite after the commit has taken place and - ** the associated write-lock on the database released, so the implementation - ** may read, write or [checkpoint] the database as required. - ** - ** ^The first parameter passed to the callback function when it is invoked - ** is a copy of the third parameter passed to sqlite3_wal_hook() when - ** registering the callback. ^The second is a copy of the database handle. - ** ^The third parameter is the name of the database that was written to - - ** either "main" or the name of an [ATTACH]-ed database. ^The fourth parameter - ** is the number of pages currently in the write-ahead log file, - ** including those that were just committed. - ** - ** The callback function should normally return [SQLITE_OK]. ^If an error - ** code is returned, that error will propagate back up through the - ** SQLite code base to cause the statement that provoked the callback - ** to report an error, though the commit will have still occurred. If the - ** callback returns [SQLITE_ROW] or [SQLITE_DONE], or if it returns a value - ** that does not correspond to any valid SQLite error code, the results - ** are undefined. - ** - ** A single database handle may have at most a single write-ahead log callback - ** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any - ** previously registered write-ahead log callback. ^Note that the - ** [sqlite3_wal_autocheckpoint()] interface and the - ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will - ** those overwrite any prior [sqlite3_wal_hook()] settings. - */ - //SQLITE_API void *sqlite3_wal_hook( - // sqlite3*, - // int()(void *,sqlite3*,const char*,int), - // void* - //); - - /* - ** CAPI3REF: Configure an auto-checkpoint - ** - ** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around - ** [sqlite3_wal_hook()] that causes any database on [database connection] D - ** to automatically [checkpoint] - ** after committing a transaction if there are N or - ** more frames in the [write-ahead log] file. ^Passing zero or - ** a negative value as the nFrame parameter disables automatic - ** checkpoints entirely. - ** - ** ^The callback registered by this function replaces any existing callback - ** registered using [sqlite3_wal_hook()]. ^Likewise, registering a callback - ** using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism - ** configured by this function. - ** - ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface - ** from SQL. - ** - ** ^Every new [database connection] defaults to having the auto-checkpoint - ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] - ** pages. The use of this interface - ** for a particular application. - */ - //SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 db, int N); - - /* - ** CAPI3REF: Checkpoint a database - ** - ** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X - ** on [database connection] D to be [checkpointed]. ^If X is NULL or an - ** empty string, then a checkpoint is run on all databases of - ** connection D. ^If the database connection D is not in - ** [WAL | write-ahead log mode] then this interface is a harmless no-op. - ** - ** ^The [wal_checkpoint pragma] can be used to invoke this interface - ** from SQL. ^The [sqlite3_wal_autocheckpoint()] interface and the - ** [wal_autocheckpoint pragma] can be used to cause this interface to be - ** run whenever the WAL reaches a certain size threshold. - ** - ** See also: [sqlite3_wal_checkpoint_v2()] - */ - //SQLITE_API int sqlite3_wal_checkpoint(sqlite3 db, string zDb); - - /* - ** CAPI3REF: Checkpoint a database - ** - ** Run a checkpoint operation on WAL database zDb attached to database - ** handle db. The specific operation is determined by the value of the - ** eMode parameter: - ** - **
- **
SQLITE_CHECKPOINT_PASSIVE
- ** Checkpoint as many frames as possible without waiting for any database - ** readers or writers to finish. Sync the db file if all frames in the log - ** are checkpointed. This mode is the same as calling - ** sqlite3_wal_checkpoint(). The busy-handler callback is never invoked. - ** - **
SQLITE_CHECKPOINT_FULL
- ** This mode blocks (calls the busy-handler callback) until there is no - ** database writer and all readers are reading from the most recent database - ** snapshot. It then checkpoints all frames in the log file and syncs the - ** database file. This call blocks database writers while it is running, - ** but not database readers. - ** - **
SQLITE_CHECKPOINT_RESTART
- ** This mode works the same way as SQLITE_CHECKPOINT_FULL, except after - ** checkpointing the log file it blocks (calls the busy-handler callback) - ** until all readers are reading from the database file only. This ensures - ** that the next client to write to the database file restarts the log file - ** from the beginning. This call blocks database writers while it is running, - ** but not database readers. - **
- ** - ** If pnLog is not NULL, then *pnLog is set to the total number of frames in - ** the log file before returning. If pnCkpt is not NULL, then *pnCkpt is set to - ** the total number of checkpointed frames (including any that were already - ** checkpointed when this function is called). *pnLog and *pnCkpt may be - ** populated even if sqlite3_wal_checkpoint_v2() returns other than SQLITE_OK. - ** If no values are available because of an error, they are both set to -1 - ** before returning to communicate this to the caller. - ** - ** All calls obtain an exclusive "checkpoint" lock on the database file. If - ** any other process is running a checkpoint operation at the same time, the - ** lock cannot be obtained and SQLITE_BUSY is returned. Even if there is a - ** busy-handler configured, it will not be invoked in this case. - ** - ** The SQLITE_CHECKPOINT_FULL and RESTART modes also obtain the exclusive - ** "writer" lock on the database file. If the writer lock cannot be obtained - ** immediately, and a busy-handler is configured, it is invoked and the writer - ** lock retried until either the busy-handler returns 0 or the lock is - ** successfully obtained. The busy-handler is also invoked while waiting for - ** database readers as described above. If the busy-handler returns 0 before - ** the writer lock is obtained or while waiting for database readers, the - ** checkpoint operation proceeds from that point in the same way as - ** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible - ** without blocking any further. SQLITE_BUSY is returned in this case. - ** - ** If parameter zDb is NULL or points to a zero length string, then the - ** specified operation is attempted on all WAL databases. In this case the - ** values written to output parameters *pnLog and *pnCkpt are undefined. If - ** an SQLITE_BUSY error is encountered when processing one or more of the - ** attached WAL databases, the operation is still attempted on any remaining - ** attached databases and SQLITE_BUSY is returned to the caller. If any other - ** error occurs while processing an attached database, processing is abandoned - ** and the error code returned to the caller immediately. If no error - ** (SQLITE_BUSY or otherwise) is encountered while processing the attached - ** databases, SQLITE_OK is returned. - ** - ** If database zDb is the name of an attached database that is not in WAL - ** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. If - ** zDb is not NULL (or a zero length string) and is not the name of any - ** attached database, SQLITE_ERROR is returned to the caller. - */ - //SQLITE_API int sqlite3_wal_checkpoint_v2( - // sqlite3 db, /* Database handle */ - // string zDb, /* Name of attached database (or NULL) */ - // int eMode, /* SQLITE_CHECKPOINT_* value */ - // int *pnLog, /* OUT: Size of WAL log in frames */ - // int *pnCkpt /* OUT: Total number of frames checkpointed */ - //); - - /* - ** CAPI3REF: Checkpoint operation parameters - ** - ** These constants can be used as the 3rd parameter to - ** [sqlite3_wal_checkpoint_v2()]. See the [sqlite3_wal_checkpoint_v2()] - ** documentation for additional information about the meaning and use of - ** each of these values. - */ - //#define SQLITE_CHECKPOINT_PASSIVE 0 - //#define SQLITE_CHECKPOINT_FULL 1 - //#define SQLITE_CHECKPOINT_RESTART 2 - static public int SQLITE_CHECKPOINT_PASSIVE = 0; - static public int SQLITE_CHECKPOINT_FULL = 1; - static public int SQLITE_CHECKPOINT_RESTART = 2; - - - /* - ** CAPI3REF: Virtual Table Interface Configuration - ** - ** This function may be called by either the [xConnect] or [xCreate] method - ** of a [virtual table] implementation to configure - ** various facets of the virtual table interface. - ** - ** If this interface is invoked outside the context of an xConnect or - ** xCreate virtual table method then the behavior is undefined. - ** - ** At present, there is only one option that may be configured using - ** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options - ** may be added in the future. - */ - //SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...); - - /* - ** CAPI3REF: Virtual Table Configuration Options - ** - ** These macros define the various options to the - ** [sqlite3_vtab_config()] interface that [virtual table] implementations - ** can use to customize and optimize their behavior. - ** - **
- **
SQLITE_VTAB_CONSTRAINT_SUPPORT - **
Calls of the form - ** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported, - ** where X is an integer. If X is zero, then the [virtual table] whose - ** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not - ** support constraints. In this configuration (which is the default) if - ** a call to the [xUpdate] method returns [SQLITE_CONSTRAINT], then the entire - ** statement is rolled back as if [ON CONFLICT | OR ABORT] had been - ** specified as part of the users SQL statement, regardless of the actual - ** ON CONFLICT mode specified. - ** - ** If X is non-zero, then the virtual table implementation guarantees - ** that if [xUpdate] returns [SQLITE_CONSTRAINT], it will do so before - ** any modifications to internal or persistent data structures have been made. - ** If the [ON CONFLICT] mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite - ** is able to roll back a statement or database transaction, and abandon - ** or continue processing the current SQL statement as appropriate. - ** If the ON CONFLICT mode is REPLACE and the [xUpdate] method returns - ** [SQLITE_CONSTRAINT], SQLite handles this as if the ON CONFLICT mode - ** had been ABORT. - ** - ** Virtual table implementations that are required to handle OR REPLACE - ** must do so within the [xUpdate] method. If a call to the - ** [sqlite3_vtab_on_conflict()] function indicates that the current ON - ** CONFLICT policy is REPLACE, the virtual table implementation should - ** silently replace the appropriate rows within the xUpdate callback and - ** return SQLITE_OK. Or, if this is not possible, it may return - ** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT - ** constraint handling. - **
- */ - //#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1 - public const int SQLITE_VTAB_CONSTRAINT_SUPPORT = 1; - - /* - ** CAPI3REF: Determine The Virtual Table Conflict Policy - ** - ** This function may only be called from within a call to the [xUpdate] method - ** of a [virtual table] implementation for an INSERT or UPDATE operation. ^The - ** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL], - ** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode - ** of the SQL statement that triggered the call to the [xUpdate] method of the - ** [virtual table]. - */ - //SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 ); - - /* - ** CAPI3REF: Conflict resolution modes - ** - ** These constants are returned by [sqlite3_vtab_on_conflict()] to - ** inform a [virtual table] implementation what the [ON CONFLICT] mode - ** is for the SQL statement being evaluated. - ** - ** Note that the [SQLITE_IGNORE] constant is also used as a potential - ** return value from the [sqlite3_set_authorizer()] callback and that - ** [SQLITE_ABORT] is also a [result code]. - */ - //#define SQLITE_ROLLBACK 1 - public const int SQLITE_ROLLBACK = 1; - /* #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback */ - //#define SQLITE_FAIL 3 - public const int SQLITE_FAIL = 3; - /* #define SQLITE_ABORT 4 // Also an error code */ - //#define SQLITE_REPLACE 5 - public const int SQLITE_REPLACE = 5; - - - /* - ** Undo the hack that converts floating point types to integer for - ** builds on processors without floating point support. - */ - //#if SQLITE_OMIT_FLOATING_POINT - //# undef double - //#endif - - //#if __cplusplus - //} /* End of the 'extern "C"' block */ - //#endif - //#endif - - /* - ** 2010 August 30 - ** - ** 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. - ** - ************************************************************************* - */ - - //#if !_SQLITE3RTREE_H_ - //#define _SQLITE3RTREE_H_ - - - //#if __cplusplus - //extern "C" { - //#endif - - //typedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry; - - /* - ** Register a geometry callback named zGeom that can be used as part of an - ** R-Tree geometry query as follows: - ** - ** SELECT ... FROM WHERE MATCH $zGeom(... params ...) - */ - //SQLITE_API int sqlite3_rtree_geometry_callback( - // sqlite3 db, - // string zGeom, - // int (*xGeom)(sqlite3_rtree_geometry *, int nCoord, double *aCoord, int *pRes), - // void *pContext - //); - - - /* - ** A pointer to a structure of the following type is passed as the first - ** argument to callbacks registered using rtree_geometry_callback(). - */ - //struct sqlite3_rtree_geometry { - // void *pContext; /* Copy of pContext passed to s_r_g_c() */ - // int nParam; /* Size of array aParam[] */ - // double *aParam; /* Parameters passed to SQL geom function */ - // void *pUser; /* Callback implementation user data */ - // void (*xDelUser)(void ); /* Called by SQLite to clean up pUser */ - //}; - - - //#if __cplusplus - //} /* end of the 'extern "C"' block */ - //#endif - - //#endif /* ifndef _SQLITE3RTREE_H_ */ + public class sqlite3_index_info + { + /* Inputs */ + public int nConstraint; /* Number of entries in aConstraint */ + public sqlite3_index_constraint[] aConstraint; /* Table of WHERE clause constraints */ + public int nOrderBy; /* Number of terms in the ORDER BY clause */ + public sqlite3_index_orderby[] aOrderBy;/* The ORDER BY clause */ + + /* Outputs */ + + public sqlite3_index_constraint_usage[] aConstraintUsage; + public int idxNum; /* Number used to identify the index */ + public string idxStr; /* String, possibly obtained from sqlite3Malloc */ + public int needToFreeIdxStr; /* Free idxStr using sqlite3DbFree(db,) if true */ + public bool orderByConsumed; /* True if output is already ordered */ + public double estimatedCost; /* Estimated cost of using this index */ + } + /* + ** CAPI3REF: Virtual Table Constraint Operator Codes + ** + ** These macros defined the allowed values for the + ** [sqlite3_index_info].aConstraint[].op field. Each value represents + ** an operator that is part of a constraint term in the wHERE clause of + ** a query that uses a [virtual table]. + */ + //#define SQLITE_INDEX_CONSTRAINT_EQ 2 + //#define SQLITE_INDEX_CONSTRAINT_GT 4 + //#define SQLITE_INDEX_CONSTRAINT_LE 8 + //#define SQLITE_INDEX_CONSTRAINT_LT 16 + //#define SQLITE_INDEX_CONSTRAINT_GE 32 + //#define SQLITE_INDEX_CONSTRAINT_MATCH 64 + const int SQLITE_INDEX_CONSTRAINT_EQ = 2; + const int SQLITE_INDEX_CONSTRAINT_GT = 4; + const int SQLITE_INDEX_CONSTRAINT_LE = 8; + const int SQLITE_INDEX_CONSTRAINT_LT = 16; + const int SQLITE_INDEX_CONSTRAINT_GE = 32; + const int SQLITE_INDEX_CONSTRAINT_MATCH = 64; + + /* + ** CAPI3REF: Register A Virtual Table Implementation + ** + ** ^These routines are used to register a new [virtual table module] name. + ** ^Module names must be registered before + ** creating a new [virtual table] using the module and before using a + ** preexisting [virtual table] for the module. + ** + ** ^The module name is registered on the [database connection] specified + ** by the first parameter. ^The name of the module is given by the + ** second parameter. ^The third parameter is a pointer to + ** the implementation of the [virtual table module]. ^The fourth + ** parameter is an arbitrary client data pointer that is passed through + ** into the [xCreate] and [xConnect] methods of the virtual table module + ** when a new virtual table is be being created or reinitialized. + ** + ** ^The sqlite3_create_module_v2() interface has a fifth parameter which + ** is a pointer to a destructor for the pClientData. ^SQLite will + ** invoke the destructor function (if it is not NULL) when SQLite + ** no longer needs the pClientData pointer. ^The destructor will also + ** be invoked if the call to sqlite3_create_module_v2() fails. + ** ^The sqlite3_create_module() + ** interface is equivalent to sqlite3_create_module_v2() with a NULL + ** destructor. + */ + //SQLITE_API int sqlite3_create_module( + // sqlite3 db, /* SQLite connection to register module with */ + // string zName, /* Name of the module */ + // const sqlite3_module *p, /* Methods for the module */ + // void *pClientData /* Client data for xCreate/xConnect */ + //); + //SQLITE_API int sqlite3_create_module_v2( + // sqlite3 db, /* SQLite connection to register module with */ + // string zName, /* Name of the module */ + // const sqlite3_module *p, /* Methods for the module */ + // void *pClientData, /* Client data for xCreate/xConnect */ + // void(*xDestroy)(void) /* Module destructor function */ + //); + + /* + ** CAPI3REF: Virtual Table Instance Object + ** KEYWORDS: sqlite3_vtab + ** + ** Every [virtual table module] implementation uses a subclass + ** of this object to describe a particular instance + ** of the [virtual table]. Each subclass will + ** be tailored to the specific needs of the module implementation. + ** The purpose of this superclass is to define certain fields that are + ** common to all module implementations. + ** + ** ^Virtual tables methods can set an error message by assigning a + ** string obtained from [sqlite3_mprintf()] to zErrMsg. The method should + ** take care that any prior string is freed by a call to [sqlite3_free()] + ** prior to assigning a new string to zErrMsg. ^After the error message + ** is delivered up to the client application, the string will be automatically + ** freed by sqlite3_free() and the zErrMsg field will be zeroed. + */ + //struct sqlite3_vtab { + // const sqlite3_module *pModule; /* The module for this virtual table */ + // int nRef; /* NO LONGER USED */ + // string zErrMsg; /* Error message from sqlite3_mprintf() */ + // /* Virtual table implementations will typically add additional fields */ + //}; + public class sqlite3_vtab + { + public sqlite3_module pModule; /* The module for this virtual table */ + public int nRef; /* Used internally */ + public string zErrMsg; /* Error message from sqlite3_mprintf() */ + /* Virtual table implementations will typically add additional fields */ + }; + + /* + ** CAPI3REF: Virtual Table Cursor Object + ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor} + ** + ** Every [virtual table module] implementation uses a subclass of the + ** following structure to describe cursors that point into the + ** [virtual table] and are used + ** to loop through the virtual table. Cursors are created using the + ** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed + ** by the [sqlite3_module.xClose | xClose] method. Cursors are used + ** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods + ** of the module. Each module implementation will define + ** the content of a cursor structure to suit its own needs. + ** + ** This superclass exists in order to define fields of the cursor that + ** are common to all implementations. + */ + //struct sqlite3_vtab_cursor { + // sqlite3_vtab *pVtab; /* Virtual table of this cursor */ + // /* Virtual table implementations will typically add additional fields */ + //}; + public class sqlite3_vtab_cursor + { + public sqlite3_vtab pVtab; /* Virtual table of this cursor */ + /* Virtual table implementations will typically add additional fields */ + }; + + /* + ** CAPI3REF: Declare The Schema Of A Virtual Table + ** + ** ^The [xCreate] and [xConnect] methods of a + ** [virtual table module] call this interface + ** to declare the format (the names and datatypes of the columns) of + ** the virtual tables they implement. + */ + //SQLITE_API int sqlite3_declare_vtab(sqlite3*, string zSQL); + + /* + ** CAPI3REF: Overload A Function For A Virtual Table + ** + ** ^(Virtual tables can provide alternative implementations of functions + ** using the [xFindFunction] method of the [virtual table module]. + ** But global versions of those functions + ** must exist in order to be overloaded.)^ + ** + ** ^(This API makes sure a global version of a function with a particular + ** name and number of parameters exists. If no such function exists + ** before this API is called, a new function is created.)^ ^The implementation + ** of the new function always causes an exception to be thrown. So + ** the new function is not good for anything by itself. Its only + ** purpose is to be a placeholder function that can be overloaded + ** by a [virtual table]. + */ + //SQLITE_API int sqlite3_overload_function(sqlite3*, string zFuncName, int nArg); + + /* + ** The interface to the virtual-table mechanism defined above (back up + ** to a comment remarkably similar to this one) is currently considered + ** to be experimental. The interface might change in incompatible ways. + ** If this is a problem for you, do not use the interface at this time. + ** + ** When the virtual-table mechanism stabilizes, we will declare the + ** interface fixed, support it indefinitely, and remove this comment. + */ + + /* + ** CAPI3REF: A Handle To An Open BLOB + ** KEYWORDS: {BLOB handle} {BLOB handles} + ** + ** An instance of this object represents an open BLOB on which + ** [sqlite3_blob_open | incremental BLOB I/O] can be performed. + ** ^Objects of this type are created by [sqlite3_blob_open()] + ** and destroyed by [sqlite3_blob_close()]. + ** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces + ** can be used to read or write small subsections of the BLOB. + ** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes. + */ + //typedef struct sqlite3_blob sqlite3_blob; + + /* + ** CAPI3REF: Open A BLOB For Incremental I/O + ** + ** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located + ** in row iRow, column zColumn, table zTable in database zDb; + ** in other words, the same BLOB that would be selected by: + ** + **
+    **     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
+    ** 
)^ + ** + ** ^If the flags parameter is non-zero, then the BLOB is opened for read + ** and write access. ^If it is zero, the BLOB is opened for read access. + ** ^It is not possible to open a column that is part of an index or primary + ** key for writing. ^If [foreign key constraints] are enabled, it is + ** not possible to open a column that is part of a [child key] for writing. + ** + ** ^Note that the database name is not the filename that contains + ** the database but rather the symbolic name of the database that + ** appears after the AS keyword when the database is connected using [ATTACH]. + ** ^For the main database file, the database name is "main". + ** ^For TEMP tables, the database name is "temp". + ** + ** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written + ** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set + ** to be a null pointer.)^ + ** ^This function sets the [database connection] error code and message + ** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related + ** functions. ^Note that the *ppBlob variable is always initialized in a + ** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob + ** regardless of the success or failure of this routine. + ** + ** ^(If the row that a BLOB handle points to is modified by an + ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects + ** then the BLOB handle is marked as "expired". + ** This is true if any column of the row is changed, even a column + ** other than the one the BLOB handle is open on.)^ + ** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for + ** a expired BLOB handle fail with a return code of [SQLITE_ABORT]. + ** ^(Changes written into a BLOB prior to the BLOB expiring are not + ** rolled back by the expiration of the BLOB. Such changes will eventually + ** commit if the transaction continues to completion.)^ + ** + ** ^Use the [sqlite3_blob_bytes()] interface to determine the size of + ** the opened blob. ^The size of a blob may not be changed by this + ** interface. Use the [UPDATE] SQL command to change the size of a + ** blob. + ** + ** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces + ** and the built-in [zeroblob] SQL function can be used, if desired, + ** to create an empty, zero-filled blob in which to read or write using + ** this interface. + ** + ** To avoid a resource leak, every open [BLOB handle] should eventually + ** be released by a call to [sqlite3_blob_close()]. + */ + //SQLITE_API int sqlite3_blob_open( + // sqlite3*, + // string zDb, + // string zTable, + // string zColumn, + // sqlite3_int64 iRow, + // int flags, + // sqlite3_blob **ppBlob + //); + + /* + ** CAPI3REF: Move a BLOB Handle to a New Row + ** + ** ^This function is used to move an existing blob handle so that it points + ** to a different row of the same database table. ^The new row is identified + ** by the rowid value passed as the second argument. Only the row can be + ** changed. ^The database, table and column on which the blob handle is open + ** remain the same. Moving an existing blob handle to a new row can be + ** faster than closing the existing handle and opening a new one. + ** + ** ^(The new row must meet the same criteria as for [sqlite3_blob_open()] - + ** it must exist and there must be either a blob or text value stored in + ** the nominated column.)^ ^If the new row is not present in the table, or if + ** it does not contain a blob or text value, or if another error occurs, an + ** SQLite error code is returned and the blob handle is considered aborted. + ** ^All subsequent calls to [sqlite3_blob_read()], [sqlite3_blob_write()] or + ** [sqlite3_blob_reopen()] on an aborted blob handle immediately return + ** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle + ** always returns zero. + ** + ** ^This function sets the database handle error code and message. + */ + //SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64); + + /* + ** CAPI3REF: Close A BLOB Handle + ** + ** ^Closes an open [BLOB handle]. + ** + ** ^Closing a BLOB shall cause the current transaction to commit + ** if there are no other BLOBs, no pending prepared statements, and the + ** database connection is in [autocommit mode]. + ** ^If any writes were made to the BLOB, they might be held in cache + ** until the close operation if they will fit. + ** + ** ^(Closing the BLOB often forces the changes + ** out to disk and so if any I/O errors occur, they will likely occur + ** at the time when the BLOB is closed. Any errors that occur during + ** closing are reported as a non-zero return value.)^ + ** + ** ^(The BLOB is closed unconditionally. Even if this routine returns + ** an error code, the BLOB is still closed.)^ + ** + ** ^Calling this routine with a null pointer (such as would be returned + ** by a failed call to [sqlite3_blob_open()]) is a harmless no-op. + */ + //SQLITE_API int sqlite3_blob_close(sqlite3_blob ); + + /* + ** CAPI3REF: Return The Size Of An Open BLOB + ** + ** ^Returns the size in bytes of the BLOB accessible via the + ** successfully opened [BLOB handle] in its only argument. ^The + ** incremental blob I/O routines can only read or overwriting existing + ** blob content; they cannot change the size of a blob. + ** + ** This routine only works on a [BLOB handle] which has been created + ** by a prior successful call to [sqlite3_blob_open()] and which has not + ** been closed by [sqlite3_blob_close()]. Passing any other pointer in + ** to this routine results in undefined and probably undesirable behavior. + */ + //SQLITE_API int sqlite3_blob_bytes(sqlite3_blob ); + + /* + ** CAPI3REF: Read Data From A BLOB Incrementally + ** + ** ^(This function is used to read data from an open [BLOB handle] into a + ** caller-supplied buffer. N bytes of data are copied into buffer Z + ** from the open BLOB, starting at offset iOffset.)^ + ** + ** ^If offset iOffset is less than N bytes from the end of the BLOB, + ** [SQLITE_ERROR] is returned and no data is read. ^If N or iOffset is + ** less than zero, [SQLITE_ERROR] is returned and no data is read. + ** ^The size of the blob (and hence the maximum value of N+iOffset) + ** can be determined using the [sqlite3_blob_bytes()] interface. + ** + ** ^An attempt to read from an expired [BLOB handle] fails with an + ** error code of [SQLITE_ABORT]. + ** + ** ^(On success, sqlite3_blob_read() returns SQLITE_OK. + ** Otherwise, an [error code] or an [extended error code] is returned.)^ + ** + ** This routine only works on a [BLOB handle] which has been created + ** by a prior successful call to [sqlite3_blob_open()] and which has not + ** been closed by [sqlite3_blob_close()]. Passing any other pointer in + ** to this routine results in undefined and probably undesirable behavior. + ** + ** See also: [sqlite3_blob_write()]. + */ + //SQLITE_API int sqlite3_blob_read(sqlite3_blob *, object *Z, int N, int iOffset); + + /* + ** CAPI3REF: Write Data Into A BLOB Incrementally + ** + ** ^This function is used to write data into an open [BLOB handle] from a + ** caller-supplied buffer. ^N bytes of data are copied from the buffer Z + ** into the open BLOB, starting at offset iOffset. + ** + ** ^If the [BLOB handle] passed as the first argument was not opened for + ** writing (the flags parameter to [sqlite3_blob_open()] was zero), + ** this function returns [SQLITE_READONLY]. + ** + ** ^This function may only modify the contents of the BLOB; it is + ** not possible to increase the size of a BLOB using this API. + ** ^If offset iOffset is less than N bytes from the end of the BLOB, + ** [SQLITE_ERROR] is returned and no data is written. ^If N is + ** less than zero [SQLITE_ERROR] is returned and no data is written. + ** The size of the BLOB (and hence the maximum value of N+iOffset) + ** can be determined using the [sqlite3_blob_bytes()] interface. + ** + ** ^An attempt to write to an expired [BLOB handle] fails with an + ** error code of [SQLITE_ABORT]. ^Writes to the BLOB that occurred + ** before the [BLOB handle] expired are not rolled back by the + ** expiration of the handle, though of course those changes might + ** have been overwritten by the statement that expired the BLOB handle + ** or by other independent statements. + ** + ** ^(On success, sqlite3_blob_write() returns SQLITE_OK. + ** Otherwise, an [error code] or an [extended error code] is returned.)^ + ** + ** This routine only works on a [BLOB handle] which has been created + ** by a prior successful call to [sqlite3_blob_open()] and which has not + ** been closed by [sqlite3_blob_close()]. Passing any other pointer in + ** to this routine results in undefined and probably undesirable behavior. + ** + ** See also: [sqlite3_blob_read()]. + */ + //SQLITE_API int sqlite3_blob_write(sqlite3_blob *, string z, int n, int iOffset); + + /* + ** CAPI3REF: Virtual File System Objects + ** + ** A virtual filesystem (VFS) is an [sqlite3_vfs] object + ** that SQLite uses to interact + ** with the underlying operating system. Most SQLite builds come with a + ** single default VFS that is appropriate for the host computer. + ** New VFSes can be registered and existing VFSes can be unregistered. + ** The following interfaces are provided. + ** + ** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name. + ** ^Names are case sensitive. + ** ^Names are zero-terminated UTF-8 strings. + ** ^If there is no match, a NULL pointer is returned. + ** ^If zVfsName is NULL then the default VFS is returned. + ** + ** ^New VFSes are registered with sqlite3_vfs_register(). + ** ^Each new VFS becomes the default VFS if the makeDflt flag is set. + ** ^The same VFS can be registered multiple times without injury. + ** ^To make an existing VFS into the default VFS, register it again + ** with the makeDflt flag set. If two different VFSes with the + ** same name are registered, the behavior is undefined. If a + ** VFS is registered with a name that is NULL or an empty string, + ** then the behavior is undefined. + ** + ** ^Unregister a VFS with the sqlite3_vfs_unregister() interface. + ** ^(If the default VFS is unregistered, another VFS is chosen as + ** the default. The choice for the new VFS is arbitrary.)^ + */ + //SQLITE_API sqlite3_vfs *sqlite3_vfs_find(string zVfsName); + //SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt); + //SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs); + + /* + ** CAPI3REF: Mutexes + ** + ** The SQLite core uses these routines for thread + ** synchronization. Though they are intended for internal + ** use by SQLite, code that links against SQLite is + ** permitted to use any of these routines. + ** + ** The SQLite source code contains multiple implementations + ** of these mutex routines. An appropriate implementation + ** is selected automatically at compile-time. ^(The following + ** implementations are available in the SQLite core: + ** + **
    + **
  • SQLITE_MUTEX_OS2 + **
  • SQLITE_MUTEX_PTHREAD + **
  • SQLITE_MUTEX_W32 + **
  • SQLITE_MUTEX_NOOP + **
)^ + ** + ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines + ** that does no real locking and is appropriate for use in + ** a single-threaded application. ^The SQLITE_MUTEX_OS2, + ** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations + ** are appropriate for use on OS/2, Unix, and Windows. + ** + ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor + ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex + ** implementation is included with the library. In this case the + ** application must supply a custom mutex implementation using the + ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function + ** before calling sqlite3_initialize() or any other public sqlite3_ + ** function that calls sqlite3_initialize().)^ + ** + ** ^The sqlite3_mutex_alloc() routine allocates a new + ** mutex and returns a pointer to it. ^If it returns NULL + ** that means that a mutex could not be allocated. ^SQLite + ** will unwind its stack and return an error. ^(The argument + ** to sqlite3_mutex_alloc() is one of these integer constants: + ** + **
    + **
  • SQLITE_MUTEX_FAST + **
  • SQLITE_MUTEX_RECURSIVE + **
  • SQLITE_MUTEX_STATIC_MASTER + **
  • SQLITE_MUTEX_STATIC_MEM + **
  • SQLITE_MUTEX_STATIC_MEM2 + **
  • SQLITE_MUTEX_STATIC_PRNG + **
  • SQLITE_MUTEX_STATIC_LRU + **
  • SQLITE_MUTEX_STATIC_LRU2 + **
)^ + ** + ** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) + ** cause sqlite3_mutex_alloc() to create + ** a new mutex. ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE + ** is used but not necessarily so when SQLITE_MUTEX_FAST is used. + ** The mutex implementation does not need to make a distinction + ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does + ** not want to. ^SQLite will only request a recursive mutex in + ** cases where it really needs one. ^If a faster non-recursive mutex + ** implementation is available on the host platform, the mutex subsystem + ** might return such a mutex in response to SQLITE_MUTEX_FAST. + ** + ** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other + ** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return + ** a pointer to a static preexisting mutex. ^Six static mutexes are + ** used by the current version of SQLite. Future versions of SQLite + ** may add additional static mutexes. Static mutexes are for internal + ** use by SQLite only. Applications that use SQLite mutexes should + ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or + ** SQLITE_MUTEX_RECURSIVE. + ** + ** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST + ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() + ** returns a different mutex on every call. ^But for the static + ** mutex types, the same mutex is returned on every call that has + ** the same type number. + ** + ** ^The sqlite3_mutex_free() routine deallocates a previously + ** allocated dynamic mutex. ^SQLite is careful to deallocate every + ** dynamic mutex that it allocates. The dynamic mutexes must not be in + ** use when they are deallocated. Attempting to deallocate a static + ** mutex results in undefined behavior. ^SQLite never deallocates + ** a static mutex. + ** + ** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt + ** to enter a mutex. ^If another thread is already within the mutex, + ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return + ** SQLITE_BUSY. ^The sqlite3_mutex_try() interface returns [SQLITE_OK] + ** upon successful entry. ^(Mutexes created using + ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread. + ** In such cases the, + ** mutex must be exited an equal number of times before another thread + ** can enter.)^ ^(If the same thread tries to enter any other + ** kind of mutex more than once, the behavior is undefined. + ** SQLite will never exhibit + ** such behavior in its own use of mutexes.)^ + ** + ** ^(Some systems (for example, Windows 95) do not support the operation + ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() + ** will always return SQLITE_BUSY. The SQLite core only ever uses + ** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^ + ** + ** ^The sqlite3_mutex_leave() routine exits a mutex that was + ** previously entered by the same thread. ^(The behavior + ** is undefined if the mutex is not currently entered by the + ** calling thread or is not currently allocated. SQLite will + ** never do either.)^ + ** + ** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or + ** sqlite3_mutex_leave() is a NULL pointer, then all three routines + ** behave as no-ops. + ** + ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()]. + */ + //SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int); + //SQLITE_API void sqlite3_mutex_free(sqlite3_mutex); + //SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex); + //SQLITE_API int sqlite3_mutex_try(sqlite3_mutex); + //SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex); + + /* + ** CAPI3REF: Mutex Methods Object + ** + ** An instance of this structure defines the low-level routines + ** used to allocate and use mutexes. + ** + ** Usually, the default mutex implementations provided by SQLite are + ** sufficient, however the user has the option of substituting a custom + ** implementation for specialized deployments or systems for which SQLite + ** does not provide a suitable implementation. In this case, the user + ** creates and populates an instance of this structure to pass + ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option. + ** Additionally, an instance of this structure can be used as an + ** output variable when querying the system for the current mutex + ** implementation, using the [SQLITE_CONFIG_GETMUTEX] option. + ** + ** ^The xMutexInit method defined by this structure is invoked as + ** part of system initialization by the sqlite3_initialize() function. + ** ^The xMutexInit routine is called by SQLite exactly once for each + ** effective call to [sqlite3_initialize()]. + ** + ** ^The xMutexEnd method defined by this structure is invoked as + ** part of system shutdown by the sqlite3_shutdown() function. The + ** implementation of this method is expected to release all outstanding + ** resources obtained by the mutex methods implementation, especially + ** those obtained by the xMutexInit method. ^The xMutexEnd() + ** interface is invoked exactly once for each call to [sqlite3_shutdown()]. + ** + ** ^(The remaining seven methods defined by this structure (xMutexAlloc, + ** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and + ** xMutexNotheld) implement the following interfaces (respectively): + ** + **
    + **
  • [sqlite3_mutex_alloc()]
  • + **
  • [sqlite3_mutex_free()]
  • + **
  • [sqlite3_mutex_enter()]
  • + **
  • [sqlite3_mutex_try()]
  • + **
  • [sqlite3_mutex_leave()]
  • + **
  • [sqlite3_mutex_held()]
  • + **
  • [sqlite3_mutex_notheld()]
  • + **
)^ + ** + ** The only difference is that the public sqlite3_XXX functions enumerated + ** above silently ignore any invocations that pass a NULL pointer instead + ** of a valid mutex handle. The implementations of the methods defined + ** by this structure are not required to handle this case, the results + ** of passing a NULL pointer instead of a valid mutex handle are undefined + ** (i.e. it is acceptable to provide an implementation that segfaults if + ** it is passed a NULL pointer). + ** + ** The xMutexInit() method must be threadsafe. ^It must be harmless to + ** invoke xMutexInit() multiple times within the same process and without + ** intervening calls to xMutexEnd(). Second and subsequent calls to + ** xMutexInit() must be no-ops. + ** + ** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()] + ** and its associates). ^Similarly, xMutexAlloc() must not use SQLite memory + ** allocation for a static mutex. ^However xMutexAlloc() may use SQLite + ** memory allocation for a fast or recursive mutex. + ** + ** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is + ** called, but only if the prior call to xMutexInit returned SQLITE_OK. + ** If xMutexInit fails in any way, it is expected to clean up after itself + ** prior to returning. + */ + //typedef struct sqlite3_mutex_methods sqlite3_mutex_methods; + //struct sqlite3_mutex_methods { + // int (*xMutexInit)(void); + // int (*xMutexEnd)(void); + // sqlite3_mutex *(*xMutexAlloc)(int); + // void (*xMutexFree)(sqlite3_mutex ); + // void (*xMutexEnter)(sqlite3_mutex ); + // int (*xMutexTry)(sqlite3_mutex ); + // void (*xMutexLeave)(sqlite3_mutex ); + // int (*xMutexHeld)(sqlite3_mutex ); + // int (*xMutexNotheld)(sqlite3_mutex ); + //}; + public class sqlite3_mutex_methods + { + public dxMutexInit xMutexInit; + public dxMutexEnd xMutexEnd; + public dxMutexAlloc xMutexAlloc; + public dxMutexFree xMutexFree; + public dxMutexEnter xMutexEnter; + public dxMutexTry xMutexTry; + public dxMutexLeave xMutexLeave; + public dxMutexHeld xMutexHeld; + public dxMutexNotheld xMutexNotheld; + + public sqlite3_mutex_methods() + { + } + + public sqlite3_mutex_methods( + dxMutexInit xMutexInit, + dxMutexEnd xMutexEnd, + dxMutexAlloc xMutexAlloc, + dxMutexFree xMutexFree, + dxMutexEnter xMutexEnter, + dxMutexTry xMutexTry, + dxMutexLeave xMutexLeave, + dxMutexHeld xMutexHeld, + dxMutexNotheld xMutexNotheld + ) + { + this.xMutexInit = xMutexInit; + this.xMutexEnd = xMutexEnd; + this.xMutexAlloc = xMutexAlloc; + this.xMutexFree = xMutexFree; + this.xMutexEnter = xMutexEnter; + this.xMutexTry = xMutexTry; + this.xMutexLeave = xMutexLeave; + this.xMutexHeld = xMutexHeld; + this.xMutexNotheld = xMutexNotheld; + } + +//Copy sqlite3_mutex_methods from existing + public void Copy( sqlite3_mutex_methods cp ) + { + Debug.Assert( cp != null ); + this.xMutexInit = cp.xMutexInit; + this.xMutexEnd = cp.xMutexEnd; + this.xMutexAlloc = cp.xMutexAlloc; + this.xMutexFree = cp.xMutexFree; + this.xMutexEnter = cp.xMutexEnter; + this.xMutexTry = cp.xMutexTry; + this.xMutexLeave = cp.xMutexLeave; + this.xMutexHeld = cp.xMutexHeld; + this.xMutexNotheld = cp.xMutexNotheld; + } } + /* + ** CAPI3REF: Mutex Verification Routines + ** + ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines + ** are intended for use inside Debug.Assert() statements. ^The SQLite core + ** never uses these routines except inside an Debug.Assert() and applications + ** are advised to follow the lead of the core. ^The SQLite core only + ** provides implementations for these routines when it is compiled + ** with the SQLITE_DEBUG flag. ^External mutex implementations + ** are only required to provide these routines if SQLITE_DEBUG is + ** defined and if NDEBUG is not defined. + ** + ** ^These routines should return true if the mutex in their argument + ** is held or not held, respectively, by the calling thread. + ** + ** ^The implementation is not required to provided versions of these + ** routines that actually work. If the implementation does not provide working + ** versions of these routines, it should at least provide stubs that always + ** return true so that one does not get spurious assertion failures. + ** + ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then + ** the routine should return 1. This seems counter-intuitive since + ** clearly the mutex cannot be held if it does not exist. But + ** the reason the mutex does not exist is because the build is not + ** using mutexes. And we do not want the Debug.Assert() containing the + ** call to sqlite3_mutex_held() to fail, so a non-zero return is + ** the appropriate thing to do. ^The sqlite3_mutex_notheld() + ** interface should also return 1 when given a NULL pointer. + */ + //#if !NDEBUG + //SQLITE_API int sqlite3_mutex_held(sqlite3_mutex); + //SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex); + //#endif + + /* + ** CAPI3REF: Mutex Types + ** + ** The [sqlite3_mutex_alloc()] interface takes a single argument + ** which is one of these integer constants. + ** + ** The set of static mutexes may change from one SQLite release to the + ** next. Applications that override the built-in mutex logic must be + ** prepared to accommodate additional static mutexes. + */ + //#define SQLITE_MUTEX_FAST 0 + //#define SQLITE_MUTEX_RECURSIVE 1 + //#define SQLITE_MUTEX_STATIC_MASTER 2 + //#define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite3_malloc() */ + //#define SQLITE_MUTEX_STATIC_MEM2 4 /* NOT USED */ + //#define SQLITE_MUTEX_STATIC_OPEN 4 /* sqlite3BtreeOpen() */ + //#define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */ + //#define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */ + //#define SQLITE_MUTEX_STATIC_LRU2 7 /* NOT USED */ + //#define SQLITE_MUTEX_STATIC_PMEM 7 /* sqlite3PageMalloc() */ + const int SQLITE_MUTEX_FAST = 0; + const int SQLITE_MUTEX_RECURSIVE = 1; + const int SQLITE_MUTEX_STATIC_MASTER = 2; + const int SQLITE_MUTEX_STATIC_MEM = 3; + const int SQLITE_MUTEX_STATIC_MEM2 = 4; + const int SQLITE_MUTEX_STATIC_OPEN = 4; + const int SQLITE_MUTEX_STATIC_PRNG = 5; + const int SQLITE_MUTEX_STATIC_LRU = 6; + const int SQLITE_MUTEX_STATIC_LRU2 = 7; + const int SQLITE_MUTEX_STATIC_PMEM = 7; + + /* + ** CAPI3REF: Retrieve the mutex for a database connection + ** + ** ^This interface returns a pointer the [sqlite3_mutex] object that + ** serializes access to the [database connection] given in the argument + ** when the [threading mode] is Serialized. + ** ^If the [threading mode] is Single-thread or Multi-thread then this + ** routine returns a NULL pointer. + */ + //SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3); + + /* + ** CAPI3REF: Low-Level Control Of Database Files + ** + ** ^The [sqlite3_file_control()] interface makes a direct call to the + ** xFileControl method for the [sqlite3_io_methods] object associated + ** with a particular database identified by the second argument. ^The + ** name of the database is "main" for the main database or "temp" for the + ** TEMP database, or the name that appears after the AS keyword for + ** databases that are added using the [ATTACH] SQL command. + ** ^A NULL pointer can be used in place of "main" to refer to the + ** main database file. + ** ^The third and fourth parameters to this routine + ** are passed directly through to the second and third parameters of + ** the xFileControl method. ^The return value of the xFileControl + ** method becomes the return value of this routine. + ** + ** ^The SQLITE_FCNTL_FILE_POINTER value for the op parameter causes + ** a pointer to the underlying [sqlite3_file] object to be written into + ** the space pointed to by the 4th parameter. ^The SQLITE_FCNTL_FILE_POINTER + ** case is a short-circuit path which does not actually invoke the + ** underlying sqlite3_io_methods.xFileControl method. + ** + ** ^If the second parameter (zDbName) does not match the name of any + ** open database file, then SQLITE_ERROR is returned. ^This error + ** code is not remembered and will not be recalled by [sqlite3_errcode()] + ** or [sqlite3_errmsg()]. The underlying xFileControl method might + ** also return SQLITE_ERROR. There is no way to distinguish between + ** an incorrect zDbName and an SQLITE_ERROR return from the underlying + ** xFileControl method. + ** + ** See also: [SQLITE_FCNTL_LOCKSTATE] + */ + //SQLITE_API int sqlite3_file_control(sqlite3*, string zDbName, int op, void); + + /* + ** CAPI3REF: Testing Interface + ** + ** ^The sqlite3_test_control() interface is used to read out internal + ** state of SQLite and to inject faults into SQLite for testing + ** purposes. ^The first parameter is an operation code that determines + ** the number, meaning, and operation of all subsequent parameters. + ** + ** This interface is not for use by applications. It exists solely + ** for verifying the correct operation of the SQLite library. Depending + ** on how the SQLite library is compiled, this interface might not exist. + ** + ** The details of the operation codes, their meanings, the parameters + ** they take, and what they do are all subject to change without notice. + ** Unlike most of the SQLite API, this function is not guaranteed to + ** operate consistently from one release to the next. + */ + //SQLITE_API int sqlite3_test_control(int op, ...); + + /* + ** CAPI3REF: Testing Interface Operation Codes + ** + ** These constants are the valid operation code parameters used + ** as the first argument to [sqlite3_test_control()]. + ** + ** These parameters and their meanings are subject to change + ** without notice. These values are for testing purposes only. + ** Applications should not use any of these parameters or the + ** [sqlite3_test_control()] interface. + */ + //#define SQLITE_TESTCTRL_FIRST 5 + //#define SQLITE_TESTCTRL_PRNG_SAVE 5 + //#define SQLITE_TESTCTRL_PRNG_RESTORE 6 + //#define SQLITE_TESTCTRL_PRNG_RESET 7 + //#define SQLITE_TESTCTRL_BITVEC_TEST 8 + //#define SQLITE_TESTCTRL_FAULT_INSTALL 9 + //#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 + //#define SQLITE_TESTCTRL_PENDING_BYTE 11 + //#define SQLITE_TESTCTRL_ASSERT 12 + //#define SQLITE_TESTCTRL_ALWAYS 13 + //#define SQLITE_TESTCTRL_RESERVE 14 + //#define SQLITE_TESTCTRL_OPTIMIZATIONS 15 + //#define SQLITE_TESTCTRL_ISKEYWORD 16 + //#define SQLITE_TESTCTRL_PGHDRSZ 17 + //#define SQLITE_TESTCTRL_SCRATCHMALLOC 18 + //#define SQLITE_TESTCTRL_LOCALTIME_FAULT 19 + //#define SQLITE_TESTCTRL_LAST 19 + public const int SQLITE_TESTCTRL_FIRST = 5; + public const int SQLITE_TESTCTRL_PRNG_SAVE = 5; + public const int SQLITE_TESTCTRL_PRNG_RESTORE = 6; + public const int SQLITE_TESTCTRL_PRNG_RESET = 7; + public const int SQLITE_TESTCTRL_BITVEC_TEST = 8; + public const int SQLITE_TESTCTRL_FAULT_INSTALL = 9; + public const int SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS = 10; + public const int SQLITE_TESTCTRL_PENDING_BYTE = 11; + public const int SQLITE_TESTCTRL_ASSERT = 12; + public const int SQLITE_TESTCTRL_ALWAYS = 13; + public const int SQLITE_TESTCTRL_RESERVE = 14; + public const int SQLITE_TESTCTRL_OPTIMIZATIONS = 15; + public const int SQLITE_TESTCTRL_ISKEYWORD = 16; + public const int SQLITE_TESTCTRL_PGHDRSZ = 17; + public const int SQLITE_TESTCTRL_SCRATCHMALLOC = 18; + public const int SQLITE_TESTCTRL_LOCALTIME_FAULT = 19; + public const int SQLITE_TESTCTRL_LAST = 19; + + /* + ** CAPI3REF: SQLite Runtime Status + ** + ** ^This interface is used to retrieve runtime status information + ** about the performance of SQLite, and optionally to reset various + ** highwater marks. ^The first argument is an integer code for + ** the specific parameter to measure. ^(Recognized integer codes + ** are of the form [status parameters | SQLITE_STATUS_...].)^ + ** ^The current value of the parameter is returned into *pCurrent. + ** ^The highest recorded value is returned in *pHighwater. ^If the + ** resetFlag is true, then the highest record value is reset after + ** *pHighwater is written. ^(Some parameters do not record the highest + ** value. For those parameters + ** nothing is written into *pHighwater and the resetFlag is ignored.)^ + ** ^(Other parameters record only the highwater mark and not the current + ** value. For these latter parameters nothing is written into *pCurrent.)^ + ** + ** ^The sqlite3_status() routine returns SQLITE_OK on success and a + ** non-zero [error code] on failure. + ** + ** This routine is threadsafe but is not atomic. This routine can be + ** called while other threads are running the same or different SQLite + ** interfaces. However the values returned in *pCurrent and + ** *pHighwater reflect the status of SQLite at different points in time + ** and it is possible that another thread might change the parameter + ** in between the times when *pCurrent and *pHighwater are written. + ** + ** See also: [sqlite3_db_status()] + */ + //SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); + + + /* + ** CAPI3REF: Status Parameters + ** KEYWORDS: {status parameters} + ** + ** These integer constants designate various run-time status parameters + ** that can be returned by [sqlite3_status()]. + ** + **
+ ** [[SQLITE_STATUS_MEMORY_USED]] ^(
SQLITE_STATUS_MEMORY_USED
+ **
This parameter is the current amount of memory checked out + ** using [sqlite3_malloc()], either directly or indirectly. The + ** figure includes calls made to [sqlite3_malloc()] by the application + ** and internal memory usage by the SQLite library. Scratch memory + ** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache + ** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in + ** this parameter. The amount returned is the sum of the allocation + ** sizes as reported by the xSize method in [sqlite3_mem_methods].
)^ + ** + ** [[SQLITE_STATUS_MALLOC_SIZE]] ^(
SQLITE_STATUS_MALLOC_SIZE
+ **
This parameter records the largest memory allocation request + ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their + ** internal equivalents). Only the value returned in the + ** *pHighwater parameter to [sqlite3_status()] is of interest. + ** The value written into the *pCurrent parameter is undefined.
)^ + ** + ** [[SQLITE_STATUS_MALLOC_COUNT]] ^(
SQLITE_STATUS_MALLOC_COUNT
+ **
This parameter records the number of separate memory allocations + ** currently checked out.
)^ + ** + ** [[SQLITE_STATUS_PAGECACHE_USED]] ^(
SQLITE_STATUS_PAGECACHE_USED
+ **
This parameter returns the number of pages used out of the + ** [pagecache memory allocator] that was configured using + ** [SQLITE_CONFIG_PAGECACHE]. The + ** value returned is in pages, not in bytes.
)^ + ** + ** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]] + ** ^(
SQLITE_STATUS_PAGECACHE_OVERFLOW
+ **
This parameter returns the number of bytes of page cache + ** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE] + ** buffer and where forced to overflow to [sqlite3_malloc()]. The + ** returned value includes allocations that overflowed because they + ** where too large (they were larger than the "sz" parameter to + ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because + ** no space was left in the page cache.
)^ + ** + ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(
SQLITE_STATUS_PAGECACHE_SIZE
+ **
This parameter records the largest memory allocation request + ** handed to [pagecache memory allocator]. Only the value returned in the + ** *pHighwater parameter to [sqlite3_status()] is of interest. + ** The value written into the *pCurrent parameter is undefined.
)^ + ** + ** [[SQLITE_STATUS_SCRATCH_USED]] ^(
SQLITE_STATUS_SCRATCH_USED
+ **
This parameter returns the number of allocations used out of the + ** [scratch memory allocator] configured using + ** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not + ** in bytes. Since a single thread may only have one scratch allocation + ** outstanding at time, this parameter also reports the number of threads + ** using scratch memory at the same time.
)^ + ** + ** [[SQLITE_STATUS_SCRATCH_OVERFLOW]] ^(
SQLITE_STATUS_SCRATCH_OVERFLOW
+ **
This parameter returns the number of bytes of scratch memory + ** allocation which could not be satisfied by the [SQLITE_CONFIG_SCRATCH] + ** buffer and where forced to overflow to [sqlite3_malloc()]. The values + ** returned include overflows because the requested allocation was too + ** larger (that is, because the requested allocation was larger than the + ** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer + ** slots were available. + **
)^ + ** + ** [[SQLITE_STATUS_SCRATCH_SIZE]] ^(
SQLITE_STATUS_SCRATCH_SIZE
+ **
This parameter records the largest memory allocation request + ** handed to [scratch memory allocator]. Only the value returned in the + ** *pHighwater parameter to [sqlite3_status()] is of interest. + ** The value written into the *pCurrent parameter is undefined.
)^ + ** + ** [[SQLITE_STATUS_PARSER_STACK]] ^(
SQLITE_STATUS_PARSER_STACK
+ **
This parameter records the deepest parser stack. It is only + ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].
)^ + **
+ ** + ** New status parameters may be added from time to time. + */ + //#define SQLITE_STATUS_MEMORY_USED 0 + //#define SQLITE_STATUS_PAGECACHE_USED 1 + //#define SQLITE_STATUS_PAGECACHE_OVERFLOW 2 + //#define SQLITE_STATUS_SCRATCH_USED 3 + //#define SQLITE_STATUS_SCRATCH_OVERFLOW 4 + //#define SQLITE_STATUS_MALLOC_SIZE 5 + //#define SQLITE_STATUS_PARSER_STACK 6 + //#define SQLITE_STATUS_PAGECACHE_SIZE 7 + //#define SQLITE_STATUS_SCRATCH_SIZE 8 + //#define SQLITE_STATUS_MALLOC_COUNT 9 + public const int SQLITE_STATUS_MEMORY_USED = 0; + public const int SQLITE_STATUS_PAGECACHE_USED = 1; + public const int SQLITE_STATUS_PAGECACHE_OVERFLOW = 2; + public const int SQLITE_STATUS_SCRATCH_USED = 3; + public const int SQLITE_STATUS_SCRATCH_OVERFLOW = 4; + public const int SQLITE_STATUS_MALLOC_SIZE = 5; + public const int SQLITE_STATUS_PARSER_STACK = 6; + public const int SQLITE_STATUS_PAGECACHE_SIZE = 7; + public const int SQLITE_STATUS_SCRATCH_SIZE = 8; + public const int SQLITE_STATUS_MALLOC_COUNT = 9; + + /* + ** CAPI3REF: Database Connection Status + ** + ** ^This interface is used to retrieve runtime status information + ** about a single [database connection]. ^The first argument is the + ** database connection object to be interrogated. ^The second argument + ** is an integer constant, taken from the set of + ** [SQLITE_DBSTATUS options], that + ** determines the parameter to interrogate. The set of + ** [SQLITE_DBSTATUS options] is likely + ** to grow in future releases of SQLite. + ** + ** ^The current value of the requested parameter is written into *pCur + ** and the highest instantaneous value is written into *pHiwtr. ^If + ** the resetFlg is true, then the highest instantaneous value is + ** reset back down to the current value. + ** + ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a + ** non-zero [error code] on failure. + ** + ** See also: [sqlite3_status()] and [sqlite3_stmt_status()]. + */ + //SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); + + /* + ** CAPI3REF: Status Parameters for database connections + ** KEYWORDS: {SQLITE_DBSTATUS options} + ** + ** These constants are the available integer "verbs" that can be passed as + ** the second argument to the [sqlite3_db_status()] interface. + ** + ** New verbs may be added in future releases of SQLite. Existing verbs + ** might be discontinued. Applications should check the return code from + ** [sqlite3_db_status()] to make sure that the call worked. + ** The [sqlite3_db_status()] interface will return a non-zero error code + ** if a discontinued or unsupported verb is invoked. + ** + **
+ ** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(
SQLITE_DBSTATUS_LOOKASIDE_USED
+ **
This parameter returns the number of lookaside memory slots currently + ** checked out.
)^ + ** + ** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(
SQLITE_DBSTATUS_LOOKASIDE_HIT
+ **
This parameter returns the number malloc attempts that were + ** satisfied using lookaside memory. Only the high-water value is meaningful; + ** the current value is always zero.)^ + ** + ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]] + ** ^(
SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE
+ **
This parameter returns the number malloc attempts that might have + ** been satisfied using lookaside memory but failed due to the amount of + ** memory requested being larger than the lookaside slot size. + ** Only the high-water value is meaningful; + ** the current value is always zero.)^ + ** + ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]] + ** ^(
SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL
+ **
This parameter returns the number malloc attempts that might have + ** been satisfied using lookaside memory but failed due to all lookaside + ** memory already being in use. + ** Only the high-water value is meaningful; + ** the current value is always zero.)^ + ** + ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(
SQLITE_DBSTATUS_CACHE_USED
+ **
This parameter returns the approximate number of of bytes of heap + ** memory used by all pager caches associated with the database connection.)^ + ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. + ** + ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(
SQLITE_DBSTATUS_SCHEMA_USED
+ **
This parameter returns the approximate number of of bytes of heap + ** memory used to store the schema for all databases associated + ** with the connection - main, temp, and any [ATTACH]-ed databases.)^ + ** ^The full amount of memory used by the schemas is reported, even if the + ** schema memory is shared with other database connections due to + ** [shared cache mode] being enabled. + ** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0. + ** + ** [[SQLITE_DBSTATUS_STMT_USED]] ^(
SQLITE_DBSTATUS_STMT_USED
+ **
This parameter returns the approximate number of of bytes of heap + ** and lookaside memory used by all prepared statements associated with + ** the database connection.)^ + ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. + **
+ **
+ */ + //#define SQLITE_DBSTATUS_LOOKASIDE_USED 0 + //#define SQLITE_DBSTATUS_CACHE_USED 1 + //#define SQLITE_DBSTATUS_SCHEMA_USED 2 + //#define SQLITE_DBSTATUS_STMT_USED 3 + //#define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 + //#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 + //#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 + //#define SQLITE_DBSTATUS_MAX 6 /* Largest defined DBSTATUS */ + public const int SQLITE_DBSTATUS_LOOKASIDE_USED = 0; + public const int SQLITE_DBSTATUS_CACHE_USED = 1; + public const int SQLITE_DBSTATUS_SCHEMA_USED = 2; + public const int SQLITE_DBSTATUS_STMT_USED = 3; + public const int SQLITE_DBSTATUS_LOOKASIDE_HIT = 4; + public const int SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE = 5; + public const int SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL = 6; + public const int SQLITE_DBSTATUS_MAX = 6; + + + /* + ** CAPI3REF: Prepared Statement Status + ** + ** ^(Each prepared statement maintains various + ** [SQLITE_STMTSTATUS counters] that measure the number + ** of times it has performed specific operations.)^ These counters can + ** be used to monitor the performance characteristics of the prepared + ** statements. For example, if the number of table steps greatly exceeds + ** the number of table searches or result rows, that would tend to indicate + ** that the prepared statement is using a full table scan rather than + ** an index. + ** + ** ^(This interface is used to retrieve and reset counter values from + ** a [prepared statement]. The first argument is the prepared statement + ** object to be interrogated. The second argument + ** is an integer code for a specific [SQLITE_STMTSTATUS counte + ** to be interrogated.)^ + ** ^The current value of the requested counter is returned. + ** ^If the resetFlg is true, then the counter is reset to zero after this + ** interface call returns. + ** + ** See also: [sqlite3_status()] and [sqlite3_db_status()]. + */ + //SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); + + /* + ** CAPI3REF: Status Parameters for prepared statements + ** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters} + ** + ** These preprocessor macros define integer codes that name counter + ** values associated with the [sqlite3_stmt_status()] interface. + ** The meanings of the various counters are as follows: + ** + **
+ ** [[SQLITE_STMTSTATUS_FULLSCAN_STEP]]
SQLITE_STMTSTATUS_FULLSCAN_STEP
+ **
^This is the number of times that SQLite has stepped forward in + ** a table as part of a full table scan. Large numbers for this counter + ** may indicate opportunities for performance improvement through + ** careful use of indices.
+ ** + ** [[SQLITE_STMTSTATUS_SORT]]
SQLITE_STMTSTATUS_SORT
+ **
^This is the number of sort operations that have occurred. + ** A non-zero value in this counter may indicate an opportunity to + ** improvement performance through careful use of indices.
+ ** + ** [[SQLITE_STMTSTATUS_AUTOINDEX]]
SQLITE_STMTSTATUS_AUTOINDEX
+ **
^This is the number of rows inserted into transient indices that + ** were created automatically in order to help joins run faster. + ** A non-zero value in this counter may indicate an opportunity to + ** improvement performance by adding permanent indices that do not + ** need to be reinitialized each time the statement is run.
+ ** + **
+ */ + //#define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 + //#define SQLITE_STMTSTATUS_SORT 2 + //#define SQLITE_STMTSTATUS_AUTOINDEX 3 + public const int SQLITE_STMTSTATUS_FULLSCAN_STEP = 1; + public const int SQLITE_STMTSTATUS_SORT = 2; + public const int SQLITE_STMTSTATUS_AUTOINDEX = 3; + + /* + ** CAPI3REF: Custom Page Cache Object + ** + ** The sqlite3_pcache type is opaque. It is implemented by + ** the pluggable module. The SQLite core has no knowledge of + ** its size or internal structure and never deals with the + ** sqlite3_pcache object except by holding and passing pointers + ** to the object. + ** + ** See [sqlite3_pcache_methods] for additional information. + */ + //typedef struct sqlite3_pcache sqlite3_pcache; + + /* + ** CAPI3REF: Application Defined Page Cache. + ** KEYWORDS: {page cache} + ** + ** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can + ** register an alternative page cache implementation by passing in an + ** instance of the sqlite3_pcache_methods structure.)^ + ** In many applications, most of the heap memory allocated by + ** SQLite is used for the page cache. + ** By implementing a + ** custom page cache using this API, an application can better control + ** the amount of memory consumed by SQLite, the way in which + ** that memory is allocated and released, and the policies used to + ** determine exactly which parts of a database file are cached and for + ** how long. + ** + ** The alternative page cache mechanism is an + ** extreme measure that is only needed by the most demanding applications. + ** The built-in page cache is recommended for most uses. + ** + ** ^(The contents of the sqlite3_pcache_methods structure are copied to an + ** internal buffer by SQLite within the call to [sqlite3_config]. Hence + ** the application may discard the parameter after the call to + ** [sqlite3_config()] returns.)^ + ** + ** [[the xInit() page cache method]] + ** ^(The xInit() method is called once for each effective + ** call to [sqlite3_initialize()])^ + ** (usually only once during the lifetime of the process). ^(The xInit() + ** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^ + ** The intent of the xInit() method is to set up global data structures + ** required by the custom page cache implementation. + ** ^(If the xInit() method is NULL, then the + ** built-in default page cache is used instead of the application defined + ** page cache.)^ + ** + ** [[the xShutdown() page cache method]] + ** ^The xShutdown() method is called by [sqlite3_shutdown()]. + ** It can be used to clean up + ** any outstanding resources before process shutdown, if required. + ** ^The xShutdown() method may be NULL. + ** + ** ^SQLite automatically serializes calls to the xInit method, + ** so the xInit method need not be threadsafe. ^The + ** xShutdown method is only called from [sqlite3_shutdown()] so it does + ** not need to be threadsafe either. All other methods must be threadsafe + ** in multithreaded applications. + ** + ** ^SQLite will never invoke xInit() more than once without an intervening + ** call to xShutdown(). + ** + ** [[the xCreate() page cache methods]] + ** ^SQLite invokes the xCreate() method to construct a new cache instance. + ** SQLite will typically create one cache instance for each open database file, + ** though this is not guaranteed. ^The + ** first parameter, szPage, is the size in bytes of the pages that must + ** be allocated by the cache. ^szPage will not be a power of two. ^szPage + ** will the page size of the database file that is to be cached plus an + ** increment (here called "R") of less than 250. SQLite will use the + ** extra R bytes on each page to store metadata about the underlying + ** database page on disk. The value of R depends + ** on the SQLite version, the target platform, and how SQLite was compiled. + ** ^(R is constant for a particular build of SQLite. Except, there are two + ** distinct values of R when SQLite is compiled with the proprietary + ** ZIPVFS extension.)^ ^The second argument to + ** xCreate(), bPurgeable, is true if the cache being created will + ** be used to cache database pages of a file stored on disk, or + ** false if it is used for an in-memory database. The cache implementation + ** does not have to do anything special based with the value of bPurgeable; + ** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will + ** never invoke xUnpin() except to deliberately delete a page. + ** ^In other words, calls to xUnpin() on a cache with bPurgeable set to + ** false will always have the "discard" flag set to true. + ** ^Hence, a cache created with bPurgeable false will + ** never contain any unpinned pages. + ** + ** [[the xCachesize() page cache method]] + ** ^(The xCachesize() method may be called at any time by SQLite to set the + ** suggested maximum cache-size (number of pages stored by) the cache + ** instance passed as the first argument. This is the value configured using + ** the SQLite "[PRAGMA cache_size]" command.)^ As with the bPurgeable + ** parameter, the implementation is not required to do anything with this + ** value; it is advisory only. + ** + ** [[the xPagecount() page cache methods]] + ** The xPagecount() method must return the number of pages currently + ** stored in the cache, both pinned and unpinned. + ** + ** [[the xFetch() page cache methods]] + ** The xFetch() method locates a page in the cache and returns a pointer to + ** the page, or a NULL pointer. + ** A "page", in this context, means a buffer of szPage bytes aligned at an + ** 8-byte boundary. The page to be fetched is determined by the key. ^The + ** minimum key value is 1. After it has been retrieved using xFetch, the page + ** is considered to be "pinned". + ** + ** If the requested page is already in the page cache, then the page cache + ** implementation must return a pointer to the page buffer with its content + ** intact. If the requested page is not already in the cache, then the + ** cache implementation should use the value of the createFlag + ** parameter to help it determined what action to take: + ** + ** + **
createFlag Behaviour when page is not already in cache + **
0 Do not allocate a new page. Return NULL. + **
1 Allocate a new page if it easy and convenient to do so. + ** Otherwise return NULL. + **
2 Make every effort to allocate a new page. Only return + ** NULL if allocating a new page is effectively impossible. + **
+ ** + ** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite + ** will only use a createFlag of 2 after a prior call with a createFlag of 1 + ** failed.)^ In between the to xFetch() calls, SQLite may + ** attempt to unpin one or more cache pages by spilling the content of + ** pinned pages to disk and synching the operating system disk cache. + ** + ** [[the xUnpin() page cache method]] + ** ^xUnpin() is called by SQLite with a pointer to a currently pinned page + ** as its second argument. If the third parameter, discard, is non-zero, + ** then the page must be evicted from the cache. + ** ^If the discard parameter is + ** zero, then the page may be discarded or retained at the discretion of + ** page cache implementation. ^The page cache implementation + ** may choose to evict unpinned pages at any time. + ** + ** The cache must not perform any reference counting. A single + ** call to xUnpin() unpins the page regardless of the number of prior calls + ** to xFetch(). + ** + ** [[the xRekey() page cache methods]] + ** The xRekey() method is used to change the key value associated with the + ** page passed as the second argument. If the cache + ** previously contains an entry associated with newKey, it must be + ** discarded. ^Any prior cache entry associated with newKey is guaranteed not + ** to be pinned. + ** + ** When SQLite calls the xTruncate() method, the cache must discard all + ** existing cache entries with page numbers (keys) greater than or equal + ** to the value of the iLimit parameter passed to xTruncate(). If any + ** of these pages are pinned, they are implicitly unpinned, meaning that + ** they can be safely discarded. + ** + ** [[the xDestroy() page cache method]] + ** ^The xDestroy() method is used to delete a cache allocated by xCreate(). + ** All resources associated with the specified cache should be freed. ^After + ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] + ** handle invalid, and will not use it with any other sqlite3_pcache_methods + ** functions. + */ + //typedef struct sqlite3_pcache_methods sqlite3_pcache_methods; + //struct sqlite3_pcache_methods { + // void *pArg; + // int (*xInit)(void); + // void (*xShutdown)(void); + // sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable); + // void (*xCachesize)(sqlite3_pcache*, int nCachesize); + // int (*xPagecount)(sqlite3_pcache); + // void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); + // void (*xUnpin)(sqlite3_pcache*, void*, int discard); + // void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey); + // void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); + // void (*xDestroy)(sqlite3_pcache); + //}; + public class sqlite3_pcache_methods + { + public object pArg; + public dxPC_Init xInit;//int (*xInit)(void); + public dxPC_Shutdown xShutdown;//public void (*xShutdown)(void); + public dxPC_Create xCreate;//public sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable); + public dxPC_Cachesize xCachesize;//public void (*xCachesize)(sqlite3_pcache*, int nCachesize); + public dxPC_Pagecount xPagecount;//public int (*xPagecount)(sqlite3_pcache); + public dxPC_Fetch xFetch;//public void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); + public dxPC_Unpin xUnpin;//public void (*xUnpin)(sqlite3_pcache*, void*, int discard); + public dxPC_Rekey xRekey;//public void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey); + public dxPC_Truncate xTruncate;//public void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); + public dxPC_Destroy xDestroy;//public void (*xDestroy)(sqlite3_pcache); + + public sqlite3_pcache_methods() + { + } + + public sqlite3_pcache_methods( object pArg, dxPC_Init xInit, dxPC_Shutdown xShutdown, dxPC_Create xCreate, dxPC_Cachesize xCachesize, dxPC_Pagecount xPagecount, dxPC_Fetch xFetch, dxPC_Unpin xUnpin, dxPC_Rekey xRekey, dxPC_Truncate xTruncate, dxPC_Destroy xDestroy ) + { + this.pArg = pArg; + this.xInit = xInit; + this.xShutdown = xShutdown; + this.xCreate = xCreate; + this.xCachesize = xCachesize; + this.xPagecount = xPagecount; + this.xFetch = xFetch; + this.xUnpin = xUnpin; + this.xRekey = xRekey; + this.xTruncate = xTruncate; + this.xDestroy = xDestroy; + } + }; + + + /* + ** CAPI3REF: Online Backup Object + ** + ** The sqlite3_backup object records state information about an ongoing + ** online backup operation. ^The sqlite3_backup object is created by + ** a call to [sqlite3_backup_init()] and is destroyed by a call to + ** [sqlite3_backup_finish()]. + ** + ** See Also: [Using the SQLite Online Backup API] + */ + //typedef struct sqlite3_backup sqlite3_backup; + + /* + ** CAPI3REF: Online Backup API. + ** + ** The backup API copies the content of one database into another. + ** It is useful either for creating backups of databases or + ** for copying in-memory databases to or from persistent files. + ** + ** See Also: [Using the SQLite Online Backup API] + ** + ** ^SQLite holds a write transaction open on the destination database file + ** for the duration of the backup operation. + ** ^The source database is read-locked only while it is being read; + ** it is not locked continuously for the entire backup operation. + ** ^Thus, the backup may be performed on a live source database without + ** preventing other database connections from + ** reading or writing to the source database while the backup is underway. + ** + ** ^(To perform a backup operation: + **
    + **
  1. sqlite3_backup_init() is called once to initialize the + ** backup, + **
  2. sqlite3_backup_step() is called one or more times to transfer + ** the data between the two databases, and finally + **
  3. sqlite3_backup_finish() is called to release all resources + ** associated with the backup operation. + **
)^ + ** There should be exactly one call to sqlite3_backup_finish() for each + ** successful call to sqlite3_backup_init(). + ** + ** [[sqlite3_backup_init()]] sqlite3_backup_init() + ** + ** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the + ** [database connection] associated with the destination database + ** and the database name, respectively. + ** ^The database name is "main" for the main database, "temp" for the + ** temporary database, or the name specified after the AS keyword in + ** an [ATTACH] statement for an attached database. + ** ^The S and M arguments passed to + ** sqlite3_backup_init(D,N,S,M) identify the [database connection] + ** and database name of the source database, respectively. + ** ^The source and destination [database connections] (parameters S and D) + ** must be different or else sqlite3_backup_init(D,N,S,M) will fail with + ** an error. + ** + ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is + ** returned and an error code and error message are stored in the + ** destination [database connection] D. + ** ^The error code and message for the failed call to sqlite3_backup_init() + ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or + ** [sqlite3_errmsg16()] functions. + ** ^A successful call to sqlite3_backup_init() returns a pointer to an + ** [sqlite3_backup] object. + ** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and + ** sqlite3_backup_finish() functions to perform the specified backup + ** operation. + ** + ** [[sqlite3_backup_step()]] sqlite3_backup_step() + ** + ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between + ** the source and destination databases specified by [sqlite3_backup] object B. + ** ^If N is negative, all remaining source pages are copied. + ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there + ** are still more pages to be copied, then the function returns [SQLITE_OK]. + ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages + ** from source to destination, then it returns [SQLITE_DONE]. + ** ^If an error occurs while running sqlite3_backup_step(B,N), + ** then an [error code] is returned. ^As well as [SQLITE_OK] and + ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], + ** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an + ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code. + ** + ** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if + **
    + **
  1. the destination database was opened read-only, or + **
  2. the destination database is using write-ahead-log journaling + ** and the destination and source page sizes differ, or + **
  3. the destination database is an in-memory database and the + ** destination and source page sizes differ. + **
)^ + ** + ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then + ** the [sqlite3_busy_handler | busy-handler function] + ** is invoked (if one is specified). ^If the + ** busy-handler returns non-zero before the lock is available, then + ** [SQLITE_BUSY] is returned to the caller. ^In this case the call to + ** sqlite3_backup_step() can be retried later. ^If the source + ** [database connection] + ** is being used to write to the source database when sqlite3_backup_step() + ** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this + ** case the call to sqlite3_backup_step() can be retried later on. ^(If + ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or + ** [SQLITE_READONLY] is returned, then + ** there is no point in retrying the call to sqlite3_backup_step(). These + ** errors are considered fatal.)^ The application must accept + ** that the backup operation has failed and pass the backup operation handle + ** to the sqlite3_backup_finish() to release associated resources. + ** + ** ^The first call to sqlite3_backup_step() obtains an exclusive lock + ** on the destination file. ^The exclusive lock is not released until either + ** sqlite3_backup_finish() is called or the backup operation is complete + ** and sqlite3_backup_step() returns [SQLITE_DONE]. ^Every call to + ** sqlite3_backup_step() obtains a [shared lock] on the source database that + ** lasts for the duration of the sqlite3_backup_step() call. + ** ^Because the source database is not locked between calls to + ** sqlite3_backup_step(), the source database may be modified mid-way + ** through the backup process. ^If the source database is modified by an + ** external process or via a database connection other than the one being + ** used by the backup operation, then the backup will be automatically + ** restarted by the next call to sqlite3_backup_step(). ^If the source + ** database is modified by the using the same database connection as is used + ** by the backup operation, then the backup database is automatically + ** updated at the same time. + ** + ** [[sqlite3_backup_finish()]] sqlite3_backup_finish() + ** + ** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the + ** application wishes to abandon the backup operation, the application + ** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish(). + ** ^The sqlite3_backup_finish() interfaces releases all + ** resources associated with the [sqlite3_backup] object. + ** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any + ** active write-transaction on the destination database is rolled back. + ** The [sqlite3_backup] object is invalid + ** and may not be used following a call to sqlite3_backup_finish(). + ** + ** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no + ** sqlite3_backup_step() errors occurred, regardless or whether or not + ** sqlite3_backup_step() completed. + ** ^If an out-of-memory condition or IO error occurred during any prior + ** sqlite3_backup_step() call on the same [sqlite3_backup] object, then + ** sqlite3_backup_finish() returns the corresponding [error code]. + ** + ** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step() + ** is not a permanent error and does not affect the return value of + ** sqlite3_backup_finish(). + ** + ** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]] + ** sqlite3_backup_remaining() and sqlite3_backup_pagecount() + ** + ** ^Each call to sqlite3_backup_step() sets two values inside + ** the [sqlite3_backup] object: the number of pages still to be backed + ** up and the total number of pages in the source database file. + ** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces + ** retrieve these two values, respectively. + ** + ** ^The values returned by these functions are only updated by + ** sqlite3_backup_step(). ^If the source database is modified during a backup + ** operation, then the values are not updated to account for any extra + ** pages that need to be updated or the size of the source database file + ** changing. + ** + ** Concurrent Usage of Database Handles + ** + ** ^The source [database connection] may be used by the application for other + ** purposes while a backup operation is underway or being initialized. + ** ^If SQLite is compiled and configured to support threadsafe database + ** connections, then the source database connection may be used concurrently + ** from within other threads. + ** + ** However, the application must guarantee that the destination + ** [database connection] is not passed to any other API (by any thread) after + ** sqlite3_backup_init() is called and before the corresponding call to + ** sqlite3_backup_finish(). SQLite does not currently check to see + ** if the application incorrectly accesses the destination [database connection] + ** and so no error code is reported, but the operations may malfunction + ** nevertheless. Use of the destination database connection while a + ** backup is in progress might also also cause a mutex deadlock. + ** + ** If running in [shared cache mode], the application must + ** guarantee that the shared cache used by the destination database + ** is not accessed while the backup is running. In practice this means + ** that the application must guarantee that the disk file being + ** backed up to is not accessed by any connection within the process, + ** not just the specific connection that was passed to sqlite3_backup_init(). + ** + ** The [sqlite3_backup] object itself is partially threadsafe. Multiple + ** threads may safely make multiple concurrent calls to sqlite3_backup_step(). + ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount() + ** APIs are not strictly speaking threadsafe. If they are invoked at the + ** same time as another thread is invoking sqlite3_backup_step() it is + ** possible that they return invalid values. + */ + //SQLITE_API sqlite3_backup *sqlite3_backup_init( + // sqlite3 *pDest, /* Destination database handle */ + // string zDestName, /* Destination database name */ + // sqlite3 *pSource, /* Source database handle */ + // string zSourceName /* Source database name */ + //); + //SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage); + //SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p); + //SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p); + //SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p); + + /* + ** CAPI3REF: Unlock Notification + ** + ** ^When running in shared-cache mode, a database operation may fail with + ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or + ** individual tables within the shared-cache cannot be obtained. See + ** [SQLite Shared-Cache Mode] for a description of shared-cache locking. + ** ^This API may be used to register a callback that SQLite will invoke + ** when the connection currently holding the required lock relinquishes it. + ** ^This API is only available if the library was compiled with the + ** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined. + ** + ** See Also: [Using the SQLite Unlock Notification Feature]. + ** + ** ^Shared-cache locks are released when a database connection concludes + ** its current transaction, either by committing it or rolling it back. + ** + ** ^When a connection (known as the blocked connection) fails to obtain a + ** shared-cache lock and SQLITE_LOCKED is returned to the caller, the + ** identity of the database connection (the blocking connection) that + ** has locked the required resource is stored internally. ^After an + ** application receives an SQLITE_LOCKED error, it may call the + ** sqlite3_unlock_notify() method with the blocked connection handle as + ** the first argument to register for a callback that will be invoked + ** when the blocking connections current transaction is concluded. ^The + ** callback is invoked from within the [sqlite3_step] or [sqlite3_close] + ** call that concludes the blocking connections transaction. + ** + ** ^(If sqlite3_unlock_notify() is called in a multi-threaded application, + ** there is a chance that the blocking connection will have already + ** concluded its transaction by the time sqlite3_unlock_notify() is invoked. + ** If this happens, then the specified callback is invoked immediately, + ** from within the call to sqlite3_unlock_notify().)^ + ** + ** ^If the blocked connection is attempting to obtain a write-lock on a + ** shared-cache table, and more than one other connection currently holds + ** a read-lock on the same table, then SQLite arbitrarily selects one of + ** the other connections to use as the blocking connection. + ** + ** ^(There may be at most one unlock-notify callback registered by a + ** blocked connection. If sqlite3_unlock_notify() is called when the + ** blocked connection already has a registered unlock-notify callback, + ** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is + ** called with a NULL pointer as its second argument, then any existing + ** unlock-notify callback is canceled. ^The blocked connections + ** unlock-notify callback may also be canceled by closing the blocked + ** connection using [sqlite3_close()]. + ** + ** The unlock-notify callback is not reentrant. If an application invokes + ** any sqlite3_xxx API functions from within an unlock-notify callback, a + ** crash or deadlock may be the result. + ** + ** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always + ** returns SQLITE_OK. + ** + ** Callback Invocation Details + ** + ** When an unlock-notify callback is registered, the application provides a + ** single void* pointer that is passed to the callback when it is invoked. + ** However, the signature of the callback function allows SQLite to pass + ** it an array of void* context pointers. The first argument passed to + ** an unlock-notify callback is a pointer to an array of void* pointers, + ** and the second is the number of entries in the array. + ** + ** When a blocking connections transaction is concluded, there may be + ** more than one blocked connection that has registered for an unlock-notify + ** callback. ^If two or more such blocked connections have specified the + ** same callback function, then instead of invoking the callback function + ** multiple times, it is invoked once with the set of void* context pointers + ** specified by the blocked connections bundled together into an array. + ** This gives the application an opportunity to prioritize any actions + ** related to the set of unblocked database connections. + ** + ** Deadlock Detection + ** + ** Assuming that after registering for an unlock-notify callback a + ** database waits for the callback to be issued before taking any further + ** action (a reasonable assumption), then using this API may cause the + ** application to deadlock. For example, if connection X is waiting for + ** connection Y's transaction to be concluded, and similarly connection + ** Y is waiting on connection X's transaction, then neither connection + ** will proceed and the system may remain deadlocked indefinitely. + ** + ** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock + ** detection. ^If a given call to sqlite3_unlock_notify() would put the + ** system in a deadlocked state, then SQLITE_LOCKED is returned and no + ** unlock-notify callback is registered. The system is said to be in + ** a deadlocked state if connection A has registered for an unlock-notify + ** callback on the conclusion of connection B's transaction, and connection + ** B has itself registered for an unlock-notify callback when connection + ** A's transaction is concluded. ^Indirect deadlock is also detected, so + ** the system is also considered to be deadlocked if connection B has + ** registered for an unlock-notify callback on the conclusion of connection + ** C's transaction, where connection C is waiting on connection A. ^Any + ** number of levels of indirection are allowed. + ** + ** The "DROP TABLE" Exception + ** + ** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost + ** always appropriate to call sqlite3_unlock_notify(). There is however, + ** one exception. When executing a "DROP TABLE" or "DROP INDEX" statement, + ** SQLite checks if there are any currently executing SELECT statements + ** that belong to the same connection. If there are, SQLITE_LOCKED is + ** returned. In this case there is no "blocking connection", so invoking + ** sqlite3_unlock_notify() results in the unlock-notify callback being + ** invoked immediately. If the application then re-attempts the "DROP TABLE" + ** or "DROP INDEX" query, an infinite loop might be the result. + ** + ** One way around this problem is to check the extended error code returned + ** by an sqlite3_step() call. ^(If there is a blocking connection, then the + ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in + ** the special "DROP TABLE/INDEX" case, the extended error code is just + ** SQLITE_LOCKED.)^ + */ + //SQLITE_API int sqlite3_unlock_notify( + // sqlite3 *pBlocked, /* Waiting connection */ + // void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */ + // void *pNotifyArg /* Argument to pass to xNotify */ + //); + + + /* + ** CAPI3REF: String Comparison + ** + ** ^The [sqlite3_strnicmp()] API allows applications and extensions to + ** compare the contents of two buffers containing UTF-8 strings in a + ** case-independent fashion, using the same definition of case independence + ** that SQLite uses internally when comparing identifiers. + */ + //SQLITE_API int sqlite3_strnicmp(string , string , int); + + /* + ** CAPI3REF: Error Logging Interface + ** + ** ^The [sqlite3_log()] interface writes a message into the error log + ** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()]. + ** ^If logging is enabled, the zFormat string and subsequent arguments are + ** used with [sqlite3_snprintf()] to generate the final output string. + ** + ** The sqlite3_log() interface is intended for use by extensions such as + ** virtual tables, collating functions, and SQL functions. While there is + ** nothing to prevent an application from calling sqlite3_log(), doing so + ** is considered bad form. + ** + ** The zFormat string must not be NULL. + ** + ** To avoid deadlocks and other threading problems, the sqlite3_log() routine + ** will not use dynamically allocated memory. The log message is stored in + ** a fixed-length buffer on the stack. If the log message is longer than + ** a few hundred characters, it will be truncated to the length of the + ** buffer. + */ + //SQLITE_API void sqlite3_log(int iErrCode, string zFormat, ...); + + /* + ** CAPI3REF: Write-Ahead Log Commit Hook + ** + ** ^The [sqlite3_wal_hook()] function is used to register a callback that + ** will be invoked each time a database connection commits data to a + ** [write-ahead log] (i.e. whenever a transaction is committed in + ** [journal_mode | journal_mode=WAL mode]). + ** + ** ^The callback is invoked by SQLite after the commit has taken place and + ** the associated write-lock on the database released, so the implementation + ** may read, write or [checkpoint] the database as required. + ** + ** ^The first parameter passed to the callback function when it is invoked + ** is a copy of the third parameter passed to sqlite3_wal_hook() when + ** registering the callback. ^The second is a copy of the database handle. + ** ^The third parameter is the name of the database that was written to - + ** either "main" or the name of an [ATTACH]-ed database. ^The fourth parameter + ** is the number of pages currently in the write-ahead log file, + ** including those that were just committed. + ** + ** The callback function should normally return [SQLITE_OK]. ^If an error + ** code is returned, that error will propagate back up through the + ** SQLite code base to cause the statement that provoked the callback + ** to report an error, though the commit will have still occurred. If the + ** callback returns [SQLITE_ROW] or [SQLITE_DONE], or if it returns a value + ** that does not correspond to any valid SQLite error code, the results + ** are undefined. + ** + ** A single database handle may have at most a single write-ahead log callback + ** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any + ** previously registered write-ahead log callback. ^Note that the + ** [sqlite3_wal_autocheckpoint()] interface and the + ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will + ** those overwrite any prior [sqlite3_wal_hook()] settings. + */ + //SQLITE_API void *sqlite3_wal_hook( + // sqlite3*, + // int()(void *,sqlite3*,const char*,int), + // void* + //); + + /* + ** CAPI3REF: Configure an auto-checkpoint + ** + ** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around + ** [sqlite3_wal_hook()] that causes any database on [database connection] D + ** to automatically [checkpoint] + ** after committing a transaction if there are N or + ** more frames in the [write-ahead log] file. ^Passing zero or + ** a negative value as the nFrame parameter disables automatic + ** checkpoints entirely. + ** + ** ^The callback registered by this function replaces any existing callback + ** registered using [sqlite3_wal_hook()]. ^Likewise, registering a callback + ** using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism + ** configured by this function. + ** + ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface + ** from SQL. + ** + ** ^Every new [database connection] defaults to having the auto-checkpoint + ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] + ** pages. The use of this interface + ** for a particular application. + */ + //SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 db, int N); + + /* + ** CAPI3REF: Checkpoint a database + ** + ** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X + ** on [database connection] D to be [checkpointed]. ^If X is NULL or an + ** empty string, then a checkpoint is run on all databases of + ** connection D. ^If the database connection D is not in + ** [WAL | write-ahead log mode] then this interface is a harmless no-op. + ** + ** ^The [wal_checkpoint pragma] can be used to invoke this interface + ** from SQL. ^The [sqlite3_wal_autocheckpoint()] interface and the + ** [wal_autocheckpoint pragma] can be used to cause this interface to be + ** run whenever the WAL reaches a certain size threshold. + ** + ** See also: [sqlite3_wal_checkpoint_v2()] + */ + //SQLITE_API int sqlite3_wal_checkpoint(sqlite3 db, string zDb); + + /* + ** CAPI3REF: Checkpoint a database + ** + ** Run a checkpoint operation on WAL database zDb attached to database + ** handle db. The specific operation is determined by the value of the + ** eMode parameter: + ** + **
+ **
SQLITE_CHECKPOINT_PASSIVE
+ ** Checkpoint as many frames as possible without waiting for any database + ** readers or writers to finish. Sync the db file if all frames in the log + ** are checkpointed. This mode is the same as calling + ** sqlite3_wal_checkpoint(). The busy-handler callback is never invoked. + ** + **
SQLITE_CHECKPOINT_FULL
+ ** This mode blocks (calls the busy-handler callback) until there is no + ** database writer and all readers are reading from the most recent database + ** snapshot. It then checkpoints all frames in the log file and syncs the + ** database file. This call blocks database writers while it is running, + ** but not database readers. + ** + **
SQLITE_CHECKPOINT_RESTART
+ ** This mode works the same way as SQLITE_CHECKPOINT_FULL, except after + ** checkpointing the log file it blocks (calls the busy-handler callback) + ** until all readers are reading from the database file only. This ensures + ** that the next client to write to the database file restarts the log file + ** from the beginning. This call blocks database writers while it is running, + ** but not database readers. + **
+ ** + ** If pnLog is not NULL, then *pnLog is set to the total number of frames in + ** the log file before returning. If pnCkpt is not NULL, then *pnCkpt is set to + ** the total number of checkpointed frames (including any that were already + ** checkpointed when this function is called). *pnLog and *pnCkpt may be + ** populated even if sqlite3_wal_checkpoint_v2() returns other than SQLITE_OK. + ** If no values are available because of an error, they are both set to -1 + ** before returning to communicate this to the caller. + ** + ** All calls obtain an exclusive "checkpoint" lock on the database file. If + ** any other process is running a checkpoint operation at the same time, the + ** lock cannot be obtained and SQLITE_BUSY is returned. Even if there is a + ** busy-handler configured, it will not be invoked in this case. + ** + ** The SQLITE_CHECKPOINT_FULL and RESTART modes also obtain the exclusive + ** "writer" lock on the database file. If the writer lock cannot be obtained + ** immediately, and a busy-handler is configured, it is invoked and the writer + ** lock retried until either the busy-handler returns 0 or the lock is + ** successfully obtained. The busy-handler is also invoked while waiting for + ** database readers as described above. If the busy-handler returns 0 before + ** the writer lock is obtained or while waiting for database readers, the + ** checkpoint operation proceeds from that point in the same way as + ** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible + ** without blocking any further. SQLITE_BUSY is returned in this case. + ** + ** If parameter zDb is NULL or points to a zero length string, then the + ** specified operation is attempted on all WAL databases. In this case the + ** values written to output parameters *pnLog and *pnCkpt are undefined. If + ** an SQLITE_BUSY error is encountered when processing one or more of the + ** attached WAL databases, the operation is still attempted on any remaining + ** attached databases and SQLITE_BUSY is returned to the caller. If any other + ** error occurs while processing an attached database, processing is abandoned + ** and the error code returned to the caller immediately. If no error + ** (SQLITE_BUSY or otherwise) is encountered while processing the attached + ** databases, SQLITE_OK is returned. + ** + ** If database zDb is the name of an attached database that is not in WAL + ** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. If + ** zDb is not NULL (or a zero length string) and is not the name of any + ** attached database, SQLITE_ERROR is returned to the caller. + */ + //SQLITE_API int sqlite3_wal_checkpoint_v2( + // sqlite3 db, /* Database handle */ + // string zDb, /* Name of attached database (or NULL) */ + // int eMode, /* SQLITE_CHECKPOINT_* value */ + // int *pnLog, /* OUT: Size of WAL log in frames */ + // int *pnCkpt /* OUT: Total number of frames checkpointed */ + //); + + /* + ** CAPI3REF: Checkpoint operation parameters + ** + ** These constants can be used as the 3rd parameter to + ** [sqlite3_wal_checkpoint_v2()]. See the [sqlite3_wal_checkpoint_v2()] + ** documentation for additional information about the meaning and use of + ** each of these values. + */ + //#define SQLITE_CHECKPOINT_PASSIVE 0 + //#define SQLITE_CHECKPOINT_FULL 1 + //#define SQLITE_CHECKPOINT_RESTART 2 + static public int SQLITE_CHECKPOINT_PASSIVE = 0; + static public int SQLITE_CHECKPOINT_FULL = 1; + static public int SQLITE_CHECKPOINT_RESTART = 2; + + + /* + ** CAPI3REF: Virtual Table Interface Configuration + ** + ** This function may be called by either the [xConnect] or [xCreate] method + ** of a [virtual table] implementation to configure + ** various facets of the virtual table interface. + ** + ** If this interface is invoked outside the context of an xConnect or + ** xCreate virtual table method then the behavior is undefined. + ** + ** At present, there is only one option that may be configured using + ** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options + ** may be added in the future. + */ + //SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...); + + /* + ** CAPI3REF: Virtual Table Configuration Options + ** + ** These macros define the various options to the + ** [sqlite3_vtab_config()] interface that [virtual table] implementations + ** can use to customize and optimize their behavior. + ** + **
+ **
SQLITE_VTAB_CONSTRAINT_SUPPORT + **
Calls of the form + ** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported, + ** where X is an integer. If X is zero, then the [virtual table] whose + ** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not + ** support constraints. In this configuration (which is the default) if + ** a call to the [xUpdate] method returns [SQLITE_CONSTRAINT], then the entire + ** statement is rolled back as if [ON CONFLICT | OR ABORT] had been + ** specified as part of the users SQL statement, regardless of the actual + ** ON CONFLICT mode specified. + ** + ** If X is non-zero, then the virtual table implementation guarantees + ** that if [xUpdate] returns [SQLITE_CONSTRAINT], it will do so before + ** any modifications to internal or persistent data structures have been made. + ** If the [ON CONFLICT] mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite + ** is able to roll back a statement or database transaction, and abandon + ** or continue processing the current SQL statement as appropriate. + ** If the ON CONFLICT mode is REPLACE and the [xUpdate] method returns + ** [SQLITE_CONSTRAINT], SQLite handles this as if the ON CONFLICT mode + ** had been ABORT. + ** + ** Virtual table implementations that are required to handle OR REPLACE + ** must do so within the [xUpdate] method. If a call to the + ** [sqlite3_vtab_on_conflict()] function indicates that the current ON + ** CONFLICT policy is REPLACE, the virtual table implementation should + ** silently replace the appropriate rows within the xUpdate callback and + ** return SQLITE_OK. Or, if this is not possible, it may return + ** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT + ** constraint handling. + **
+ */ + //#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1 + public const int SQLITE_VTAB_CONSTRAINT_SUPPORT = 1; + + /* + ** CAPI3REF: Determine The Virtual Table Conflict Policy + ** + ** This function may only be called from within a call to the [xUpdate] method + ** of a [virtual table] implementation for an INSERT or UPDATE operation. ^The + ** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL], + ** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode + ** of the SQL statement that triggered the call to the [xUpdate] method of the + ** [virtual table]. + */ + //SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 ); + + /* + ** CAPI3REF: Conflict resolution modes + ** + ** These constants are returned by [sqlite3_vtab_on_conflict()] to + ** inform a [virtual table] implementation what the [ON CONFLICT] mode + ** is for the SQL statement being evaluated. + ** + ** Note that the [SQLITE_IGNORE] constant is also used as a potential + ** return value from the [sqlite3_set_authorizer()] callback and that + ** [SQLITE_ABORT] is also a [result code]. + */ + //#define SQLITE_ROLLBACK 1 + public const int SQLITE_ROLLBACK = 1; + /* #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback */ + //#define SQLITE_FAIL 3 + public const int SQLITE_FAIL = 3; + /* #define SQLITE_ABORT 4 // Also an error code */ + //#define SQLITE_REPLACE 5 + public const int SQLITE_REPLACE = 5; + + + /* + ** Undo the hack that converts floating point types to integer for + ** builds on processors without floating point support. + */ + //#if SQLITE_OMIT_FLOATING_POINT + //# undef double + //#endif + + //#if __cplusplus + //} /* End of the 'extern "C"' block */ + //#endif + //#endif + + /* + ** 2010 August 30 + ** + ** 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. + ** + ************************************************************************* + */ + + //#if !_SQLITE3RTREE_H_ + //#define _SQLITE3RTREE_H_ + + + //#if __cplusplus + //extern "C" { + //#endif + + //typedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry; + + /* + ** Register a geometry callback named zGeom that can be used as part of an + ** R-Tree geometry query as follows: + ** + ** SELECT ... FROM WHERE MATCH $zGeom(... params ...) + */ + //SQLITE_API int sqlite3_rtree_geometry_callback( + // sqlite3 db, + // string zGeom, + // int (*xGeom)(sqlite3_rtree_geometry *, int nCoord, double *aCoord, int *pRes), + // void *pContext + //); + + + /* + ** A pointer to a structure of the following type is passed as the first + ** argument to callbacks registered using rtree_geometry_callback(). + */ + //struct sqlite3_rtree_geometry { + // void *pContext; /* Copy of pContext passed to s_r_g_c() */ + // int nParam; /* Size of array aParam[] */ + // double *aParam; /* Parameters passed to SQL geom function */ + // void *pUser; /* Callback implementation user data */ + // void (*xDelUser)(void ); /* Called by SQLite to clean up pUser */ + //}; + + + //#if __cplusplus + //} /* end of the 'extern "C"' block */ + //#endif + + //#endif /* ifndef _SQLITE3RTREE_H_ */ + + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/sqliteInt_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/sqliteInt_h.cs index 728553bdd..a7f7ac6fe 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/sqliteInt_h.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/sqliteInt_h.cs @@ -2,6 +2,7 @@ using System; using System.Diagnostics; +using System.Runtime.InteropServices; using System.Text; using Bitmask = System.UInt64; @@ -13,6 +14,9 @@ using u16 = System.UInt16; using u32 = System.UInt32; using u64 = System.UInt64; +using unsigned = System.UInt64; + +using Pgno = System.UInt32; #if !SQLITE_MAX_VARIABLE_NUMBER using ynVar = System.Int16; @@ -31,86 +35,88 @@ using yDbMask = System.Int32; #endif -namespace Community.CsharpSqlite { - using sqlite3_value = Sqlite3.Mem; - - public partial class Sqlite3 { - /* - ** 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. - ** - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#if !_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. - */ - //#if !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 - */ +namespace Community.CsharpSqlite +{ + using sqlite3_value = Sqlite3.Mem; + + public partial class Sqlite3 + { + /* + ** 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. + ** + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#if !_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. + */ + //#if !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 + */ #if _HAVE_SQLITE_CONFIG_H //#include "config.h" #endif - //#include "sqliteLimit.h" - - /* Disable nuisance warnings on Borland compilers */ - //#if (__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... */ - //#if !_GNU_SOURCE - //#define _GNU_SOURCE - //#endif - /* - ** Include standard header files as necessary - */ + //#include "sqliteLimit.h" + + /* Disable nuisance warnings on Borland compilers */ + //#if (__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... */ + //#if !_GNU_SOURCE + //#define _GNU_SOURCE + //#endif + /* + ** Include standard header files as necessary + */ #if HAVE_STDINT_H //#include #endif @@ -118,246 +124,254 @@ public partial class Sqlite3 { //#include #endif - /* - ** The number of samples of an index that SQLite takes in order to - ** construct a histogram of the table content when running ANALYZE - ** and with SQLITE_ENABLE_STAT2 + /* +** The number of samples of an index that SQLite takes in order to +** construct a histogram of the table content when running ANALYZE +** and with SQLITE_ENABLE_STAT2 +*/ + //#define SQLITE_INDEX_SAMPLES 10 + public const int SQLITE_INDEX_SAMPLES = 10; + + /* + ** 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 (__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 libary 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. */ - //#define SQLITE_INDEX_SAMPLES 10 - public const int SQLITE_INDEX_SAMPLES = 10; - - /* - ** 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 (__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 libary 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 !SQLITE_THREADSAFE //# define SQLITE_THREADSAFE 2 const int SQLITE_THREADSAFE = 2; #else - const int SQLITE_THREADSAFE = 2; /* IMP: R-07272-22309 */ + const int SQLITE_THREADSAFE = 2; /* IMP: R-07272-22309 */ #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. - */ + /* +** 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 !(SQLITE_DEFAULT_MEMSTATUS) - //# define SQLITE_DEFAULT_MEMSTATUS 1 - const int SQLITE_DEFAULT_MEMSTATUS = 0; + //# define SQLITE_DEFAULT_MEMSTATUS 1 + const int SQLITE_DEFAULT_MEMSTATUS = 0; #else const int 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_MEMDEBUG // Debugging version of system malloc() - ** - ** (Historical note: There used to be several other options, but we've - ** pared it down to just these two.) - ** - ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as - ** the default. + /* +** 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_MEMDEBUG // Debugging version of system malloc() +** +** (Historical note: There used to be several other options, but we've +** pared it down to just these two.) +** +** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as +** the default. +*/ + //#if (SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)+\ + //# error "At most one of the following compile-time configuration options\ + // is allows: SQLITE_SYSTEM_MALLOC, SQLITE_MEMDEBUG" + //#endif + //#if (SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)+\ + //# 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 (SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)+\ - //# error "At most one of the following compile-time configuration options\ - // is allows: SQLITE_SYSTEM_MALLOC, SQLITE_MEMDEBUG" - //#endif - //#if (SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)+\ - //# 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 !(SQLITE_MALLOC_SOFT_LIMIT) - const int SQLITE_MALLOC_SOFT_LIMIT = 1024; + const int SQLITE_MALLOC_SOFT_LIMIT = 1024; #endif - /* - ** We need to define _XOPEN_SOURCE as follows in order to enable - ** recursive mutexes on most Unix systems. But Mac OS X is different. - ** The _XOPEN_SOURCE define causes problems for Mac OS X we are told, - ** so it is omitted there. See ticket #2673. - ** - ** Later we learn that _XOPEN_SOURCE is poorly or incorrectly - ** implemented on some systems. So we avoid defining it at all - ** if it is already defined or if it is unneeded because we are - ** not doing a threadsafe build. Ticket #2681. - ** - ** See also ticket #2741. - */ + /* +** We need to define _XOPEN_SOURCE as follows in order to enable +** recursive mutexes on most Unix systems. But Mac OS X is different. +** The _XOPEN_SOURCE define causes problems for Mac OS X we are told, +** so it is omitted there. See ticket #2673. +** +** Later we learn that _XOPEN_SOURCE is poorly or incorrectly +** implemented on some systems. So we avoid defining it at all +** if it is already defined or if it is unneeded because we are +** not doing a threadsafe build. Ticket #2681. +** +** See also ticket #2741. +*/ #if !_XOPEN_SOURCE && !__DARWIN__ && !__APPLE__ && SQLITE_THREADSAFE - const int _XOPEN_SOURCE = 500;//#define _XOPEN_SOURCE 500 /* Needed to enable pthread recursive mutexes */ + const int _XOPEN_SOURCE = 500;//#define _XOPEN_SOURCE 500 /* Needed to enable pthread recursive mutexes */ #endif - /* - ** The TCL headers are only needed when compiling the TCL bindings. - */ + /* +** The TCL headers are only needed when compiling the TCL bindings. +*/ #if SQLITE_TCL || TCLSH //# include #endif - /* - ** Many people are failing to set -DNDEBUG=1 when compiling SQLite. - ** Setting NDEBUG makes the code smaller and run faster. So the following - ** lines are added to automatically set NDEBUG unless the -DSQLITE_DEBUG=1 - ** option is set. Thus NDEBUG becomes an opt-in rather than an opt-out - ** feature. - */ + /* +** Many people are failing to set -DNDEBUG=1 when compiling SQLite. +** Setting NDEBUG makes the code smaller and run faster. So the following +** lines are added to automatically set NDEBUG unless the -DSQLITE_DEBUG=1 +** option is set. Thus NDEBUG becomes an opt-in rather than an opt-out +** feature. +*/ #if !NDEBUG && !SQLITE_DEBUG const int NDEBUG = 1;//# define NDEBUG 1 #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. - ** - */ + /* +** 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. +** +*/ #if SQLITE_COVERAGE_TEST void sqlite3Coverage(int); //# define testcase(X) if( X ){ sqlite3Coverage(__LINE__); } #else - //# define testcase(X) - static void testcase(T X) { - } + //# define testcase(X) + static void testcase( T 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 Debug.Assert() macros. - */ + /* +** The TESTONLY macro is used to enclose variable declarations or +** other bits of code that are needed to support the arguments +** within testcase() and Debug.Assert() macros. +*/ #if !NDEBUG || SQLITE_COVERAGE_TEST - //# define TESTONLY(X) X - // -- Need workaround for C#, since inline macros don't exist + //# define TESTONLY(X) X + // -- Need workaround for C#, since inline macros don't exist #else //# define TESTONLY(X) #endif - /* - ** Sometimes we need a small amount of code such as a variable initialization - ** to setup for a later Debug.Assert() statement. We do not want this code to - ** appear when Debug.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. - */ + /* +** Sometimes we need a small amount of code such as a variable initialization +** to setup for a later Debug.Assert() statement. We do not want this code to +** appear when Debug.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. +*/ #if !NDEBUG - //# define VVA_ONLY(X) X + //# 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 then specify will - ** not be counted as untested code. - */ + /* +** 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 then specify will +** not be counted as untested code. +*/ #if SQLITE_COVERAGE_TEST //# define ALWAYS(X) (1) //# define NEVER(X) (0) #elif !NDEBUG - //# define ALWAYS(X) ((X)?1:(Debug.Assert(0),0)) - static bool ALWAYS(bool X) { - if (X != true) - Debug.Assert(false); - return true; - } - static int ALWAYS(int X) { - if (X == 0) - Debug.Assert(false); - return 1; - } - static bool ALWAYS(T X) { - if (X == null) - Debug.Assert(false); - return true; - } + //# define ALWAYS(X) ((X)?1:(Debug.Assert(0),0)) + static bool ALWAYS( bool X ) + { + if ( X != true ) + Debug.Assert( false ); + return true; + } + static int ALWAYS( int X ) + { + if ( X == 0 ) + Debug.Assert( false ); + return 1; + } + static bool ALWAYS( T X ) + { + if ( X == null ) + Debug.Assert( false ); + return true; + } - //# define NEVER(X) ((X)?(Debug.Assert(0),1):0) - static bool NEVER(bool X) { - if (X == true) - Debug.Assert(false); - return false; - } - static byte NEVER(byte X) { - if (X != 0) - Debug.Assert(false); - return 0; - } - static int NEVER(int X) { - if (X != 0) - Debug.Assert(false); - return 0; - } - static bool NEVER(T X) { - if (X != null) - Debug.Assert(false); - return false; - } + //# define NEVER(X) ((X)?(Debug.Assert(0),1):0) + static bool NEVER( bool X ) + { + if ( X == true ) + Debug.Assert( false ); + return false; + } + static byte NEVER( byte X ) + { + if ( X != 0 ) + Debug.Assert( false ); + return 0; + } + static int NEVER( int X ) + { + if ( X != 0 ) + Debug.Assert( false ); + return 0; + } + static bool NEVER( T X ) + { + if ( X != null ) + Debug.Assert( false ); + return false; + } #else //# define ALWAYS(X) (X) static bool ALWAYS(bool X) { return X; } @@ -372,48 +386,51 @@ static bool NEVER(T X) { static bool NEVER(T X) { return false; } #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. + /* +** 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. +*/ + static bool IS_BIG_INT( i64 X ) + { + return ( ( ( X ) & ~(i64)0xffffffff ) != 0 ); + }//#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. GCC is able to + ** use these hints to generate better code, sometimes. */ - static bool IS_BIG_INT(i64 X) { - return (((X) & ~(i64)0xffffffff) != 0); - }//#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. GCC is able to - ** use these hints to generate better code, sometimes. - */ #if (__GNUC__) && FALSE //# define likely(X) __builtin_expect((X),1) //# define unlikely(X) __builtin_expect((X),0) #else - //# define likely(X) !!(X) - static bool likely(bool X) { - return !!X; - } - //# define unlikely(X) !!(X) - static bool unlikely(bool X) { - return !!X; - } + //# define likely(X) !!(X) + static bool likely( bool X ) + { + return !!X; + } + //# define unlikely(X) !!(X) + static bool unlikely( bool X ) + { + return !!X; + } #endif - //#include "sqlite3.h" - //#include "hash.h" - //#include "parse.h" - //#include - //#include - //#include - //#include - //#include - - /* - ** If compiling for a processor that lacks floating point support, - ** substitute integer for floating-point - */ + //#include "sqlite3.h" + //#include "hash.h" + //#include "parse.h" + //#include + //#include + //#include + //#include + //#include + + /* + ** If compiling for a processor that lacks floating point support, + ** substitute integer for floating-point + */ #if SQLITE_OMIT_FLOATING_POINT //# define double sqlite_int64 //# define float sqlite_int64 @@ -427,261 +444,265 @@ static bool unlikely(bool X) { //# undef SQLITE_HAVE_ISNAN #endif #if !SQLITE_BIG_DBL - const double SQLITE_BIG_DBL = (((sqlite3_int64)1) << 60);//# define SQLITE_BIG_DBL (1e99) + const double SQLITE_BIG_DBL = ( ( (sqlite3_int64)1 ) << 60 );//# define SQLITE_BIG_DBL (1e99) #endif - /* - ** OMIT_TEMPDB is set to 1 if SQLITE_OMIT_TEMPDB is defined, or 0 - ** afterward. Having this macro allows us to cause the C compiler - ** to omit code used by TEMP tables without messy #if !statements. - */ + /* +** OMIT_TEMPDB is set to 1 if SQLITE_OMIT_TEMPDB is defined, or 0 +** afterward. Having this macro allows us to cause the C compiler +** to omit code used by TEMP tables without messy #if !statements. +*/ #if SQLITE_OMIT_TEMPDB //#define OMIT_TEMPDB 1 #else - static int OMIT_TEMPDB = 0; + static int OMIT_TEMPDB = 0; #endif - /* - ** The "file format" number is an integer that is incremented whenever - ** the VDBE-level file format changes. The following macros define the - ** the default file format for new databases and the maximum file format - ** that the library can read. + /* +** The "file format" number is an integer that is incremented whenever +** the VDBE-level file format changes. The following macros define the +** the default file format for new databases and the maximum file format +** that the library can read. +*/ + static public int SQLITE_MAX_FILE_FORMAT = 4;//#define SQLITE_MAX_FILE_FORMAT 4 + //#if !SQLITE_DEFAULT_FILE_FORMAT + static int SQLITE_DEFAULT_FILE_FORMAT = 1;//# define SQLITE_DEFAULT_FILE_FORMAT 1 + //#endif + + /* + ** Determine whether triggers are recursive by default. This can be + ** changed at run-time using a pragma. */ - static public int SQLITE_MAX_FILE_FORMAT = 4;//#define SQLITE_MAX_FILE_FORMAT 4 - //#if !SQLITE_DEFAULT_FILE_FORMAT - static int SQLITE_DEFAULT_FILE_FORMAT = 1;//# define SQLITE_DEFAULT_FILE_FORMAT 1 - //#endif - - /* - ** Determine whether triggers are recursive by default. This can be - ** changed at run-time using a pragma. - */ #if !SQLITE_DEFAULT_RECURSIVE_TRIGGERS - //# define SQLITE_DEFAULT_RECURSIVE_TRIGGERS 0 - static public bool SQLITE_DEFAULT_RECURSIVE_TRIGGERS = false; + //# define SQLITE_DEFAULT_RECURSIVE_TRIGGERS 0 + static public bool SQLITE_DEFAULT_RECURSIVE_TRIGGERS = false; #else static public bool SQLITE_DEFAULT_RECURSIVE_TRIGGERS = true; #endif - /* - ** Provide a default value for SQLITE_TEMP_STORE in case it is not specified - ** on the command-line - */ - //#if !SQLITE_TEMP_STORE - static int SQLITE_TEMP_STORE = 1;//#define SQLITE_TEMP_STORE 1 - //#endif + /* +** Provide a default value for SQLITE_TEMP_STORE in case it is not specified +** on the command-line +*/ + //#if !SQLITE_TEMP_STORE + static int SQLITE_TEMP_STORE = 1;//#define SQLITE_TEMP_STORE 1 + //#endif - /* - ** GCC does not define the offsetof() macro so we'll have to do it - ** ourselves. - */ + /* +** GCC does not define the offsetof() macro so we'll have to do it +** ourselves. +*/ #if !offsetof - //#define offsetof(STRUCTURE,FIELD) ((int)((char)&((STRUCTURE)0)->FIELD)) + //#define offsetof(STRUCTURE,FIELD) ((int)((char)&((STRUCTURE)0)->FIELD)) #endif - /* - ** Check to see if this machine uses EBCDIC. (Yes, believe it or - ** not, there are still machines out there that use EBCDIC.) - */ + /* +** Check to see if this machine uses EBCDIC. (Yes, believe it or +** not, there are still machines out there that use EBCDIC.) +*/ #if FALSE //'A' == '\301' //# define SQLITE_EBCDIC 1 #else - const int SQLITE_ASCII = 1;//#define SQLITE_ASCII 1 + const int SQLITE_ASCII = 1;//#define SQLITE_ASCII 1 #endif - /* - ** Integers of known sizes. These typedefs might change for architectures - ** where the sizes very. Preprocessor macros are available so that the - ** types can be conveniently redefined at compile-type. Like this: - ** - ** cc '-Du32PTR_TYPE=long long int' ... + /* +** Integers of known sizes. These typedefs might change for architectures +** where the sizes very. Preprocessor macros are available so that the +** types can be conveniently redefined at compile-type. Like this: +** +** cc '-Du32PTR_TYPE=long long int' ... +*/ + //#if !u32_TYPE + //# ifdef HAVE_u32_T + //# define u32_TYPE u32_t + //# else + //# define u32_TYPE unsigned int + //# endif + //#endif + //#if !u3216_TYPE + //# ifdef HAVE_u3216_T + //# define u3216_TYPE u3216_t + //# else + //# define u3216_TYPE unsigned short int + //# endif + //#endif + //#if !INT16_TYPE + //# ifdef HAVE_INT16_T + //# define INT16_TYPE int16_t + //# else + //# define INT16_TYPE short int + //# endif + //#endif + //#if !u328_TYPE + //# ifdef HAVE_u328_T + //# define u328_TYPE u328_t + //# else + //# define u328_TYPE unsigned char + //# endif + //#endif + //#if !INT8_TYPE + //# ifdef HAVE_INT8_T + //# define INT8_TYPE int8_t + //# else + //# define INT8_TYPE signed char + //# endif + //#endif + //#if !LONGDOUBLE_TYPE + //# define LONGDOUBLE_TYPE long double + //#endif + //typedef sqlite_int64 i64; /* 8-byte signed integer */ + //typedef sqlite_u3264 u64; /* 8-byte unsigned integer */ + //typedef u32_TYPE u32; /* 4-byte unsigned integer */ + //typedef u3216_TYPE u16; /* 2-byte unsigned integer */ + //typedef INT16_TYPE i16; /* 2-byte signed integer */ + //typedef u328_TYPE u8; /* 1-byte unsigned integer */ + //typedef INT8_TYPE i8; /* 1-byte signed integer */ + + /* + ** SQLITE_MAX_U32 is a u64 constant that is the maximum u64 value + ** that can be stored in a u32 without loss of data. The value + ** is 0x00000000ffffffff. But because of quirks of some compilers, we + ** have to specify the value in the less intuitive manner shown: + */ + //#define SQLITE_MAX_U32 ((((u64)1)<<32)-1) + const u32 SQLITE_MAX_U32 = (u32)( ( ( (u64)1 ) << 32 ) - 1 ); + + + /* + ** Macros to determine whether the machine is big or little endian, + ** evaluated at runtime. */ - //#if !u32_TYPE - //# ifdef HAVE_u32_T - //# define u32_TYPE u32_t - //# else - //# define u32_TYPE unsigned int - //# endif - //#endif - //#if !u3216_TYPE - //# ifdef HAVE_u3216_T - //# define u3216_TYPE u3216_t - //# else - //# define u3216_TYPE unsigned short int - //# endif - //#endif - //#if !INT16_TYPE - //# ifdef HAVE_INT16_T - //# define INT16_TYPE int16_t - //# else - //# define INT16_TYPE short int - //# endif - //#endif - //#if !u328_TYPE - //# ifdef HAVE_u328_T - //# define u328_TYPE u328_t - //# else - //# define u328_TYPE unsigned char - //# endif - //#endif - //#if !INT8_TYPE - //# ifdef HAVE_INT8_T - //# define INT8_TYPE int8_t - //# else - //# define INT8_TYPE signed char - //# endif - //#endif - //#if !LONGDOUBLE_TYPE - //# define LONGDOUBLE_TYPE long double - //#endif - //typedef sqlite_int64 i64; /* 8-byte signed integer */ - //typedef sqlite_u3264 u64; /* 8-byte unsigned integer */ - //typedef u32_TYPE u32; /* 4-byte unsigned integer */ - //typedef u3216_TYPE u16; /* 2-byte unsigned integer */ - //typedef INT16_TYPE i16; /* 2-byte signed integer */ - //typedef u328_TYPE u8; /* 1-byte unsigned integer */ - //typedef INT8_TYPE i8; /* 1-byte signed integer */ - - /* - ** SQLITE_MAX_U32 is a u64 constant that is the maximum u64 value - ** that can be stored in a u32 without loss of data. The value - ** is 0x00000000ffffffff. But because of quirks of some compilers, we - ** have to specify the value in the less intuitive manner shown: - */ - //#define SQLITE_MAX_U32 ((((u64)1)<<32)-1) - const u32 SQLITE_MAX_U32 = (u32)((((u64)1) << 32) - 1); - - - /* - ** Macros to determine whether the machine is big or little endian, - ** evaluated at runtime. - */ #if SQLITE_AMALGAMATION //const int sqlite3one = 1; #else - const bool sqlite3one = true; + const bool sqlite3one = true; #endif #if i386 || __i386__ || _M_IX86 const int ;//#define SQLITE_BIGENDIAN 0 const int ;//#define SQLITE_LITTLEENDIAN 1 const int ;//#define SQLITE_UTF16NATIVE SQLITE_UTF16LE #else - static u8 SQLITE_BIGENDIAN = 0;//#define SQLITE_BIGENDIAN (*(char )(&sqlite3one)==0) - static u8 SQLITE_LITTLEENDIAN = 1;//#define SQLITE_LITTLEENDIAN (*(char )(&sqlite3one)==1) - static u8 SQLITE_UTF16NATIVE = (SQLITE_BIGENDIAN != 0 ? SQLITE_UTF16BE : SQLITE_UTF16LE);//#define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE) + static u8 SQLITE_BIGENDIAN = 0;//#define SQLITE_BIGENDIAN (*(char )(&sqlite3one)==0) + static u8 SQLITE_LITTLEENDIAN = 1;//#define SQLITE_LITTLEENDIAN (*(char )(&sqlite3one)==1) + static u8 SQLITE_UTF16NATIVE = ( SQLITE_BIGENDIAN != 0 ? SQLITE_UTF16BE : SQLITE_UTF16LE );//#define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE) #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. + /* +** 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. +*/ + //#define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32)) + //#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64) + const i64 LARGEST_INT64 = i64.MaxValue;//( 0xffffffff | ( ( (i64)0x7fffffff ) << 32 ) ); + const i64 SMALLEST_INT64 = i64.MinValue;//( ( ( i64 ) - 1 ) - LARGEST_INT64 ); + + /* + ** Round up a number to the next larger multiple of 8. This is used + ** to force 8-byte alignment on 64-bit architectures. */ - //#define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32)) - //#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64) - const i64 LARGEST_INT64 = i64.MaxValue;//( 0xffffffff | ( ( (i64)0x7fffffff ) << 32 ) ); - const i64 SMALLEST_INT64 = i64.MinValue;//( ( ( i64 ) - 1 ) - LARGEST_INT64 ); - - /* - ** Round up a number to the next larger multiple of 8. This is used - ** to force 8-byte alignment on 64-bit architectures. - */ - //#define ROUND8(x) (((x)+7)&~7) - static int ROUND8(int x) { - return (x + 7) & ~7; - } + //#define ROUND8(x) (((x)+7)&~7) + static int ROUND8( int x ) + { + return ( x + 7 ) & ~7; + } - /* - ** Round down to the nearest multiple of 8 - */ - //#define ROUNDDOWN8(x) ((x)&~7) - static int ROUNDDOWN8(int x) { - return x & ~7; - } + /* + ** Round down to the nearest multiple of 8 + */ + //#define ROUNDDOWN8(x) ((x)&~7) + static int ROUNDDOWN8( int x ) + { + return x & ~7; + } - /* - ** Assert that the pointer X is aligned to an 8-byte boundary. This - ** macro is used only within Debug.Assert() to verify that the code gets - ** all alignment restrictions correct. - ** - ** Except, if SQLITE_4_BYTE_ALIGNED_MALLOC is defined, then the - ** underlying malloc() implemention might return us 4-byte aligned - ** pointers. In that case, only verify 4-byte alignment. - */ - //#if SQLITE_4_BYTE_ALIGNED_MALLOC - //# define EIGHT_BYTE_ALIGNMENT(X) ((((char)(X) - (char)0)&3)==0) - //#else - //# define EIGHT_BYTE_ALIGNMENT(X) ((((char)(X) - (char)0)&7)==0) - //#endif - - /* - ** An instance of the following structure is used to store the busy-handler - ** callback for a given sqlite handle. - ** - ** The sqlite.busyHandler member of the sqlite struct contains the busy - ** callback for the database handle. Each pager opened via the sqlite - ** handle is passed a pointer to sqlite.busyHandler. The busy-handler - ** callback is currently invoked only from within pager.c. - */ - //typedef struct BusyHandler BusyHandler; - public class BusyHandler { - public dxBusy xFunc;//)(void *,int); /* The busy callback */ - public object pArg; /* First arg to busy callback */ - public int nBusy; /* Incremented with each busy call */ - }; - - /* - ** Name of the master database table. The master database table - ** is a special table that holds the names and attributes of all - ** user tables and indices. - */ - const string MASTER_NAME = "sqlite_master";//#define MASTER_NAME "sqlite_master" - const string TEMP_MASTER_NAME = "sqlite_temp_master";//#define TEMP_MASTER_NAME "sqlite_temp_master" - - /* - ** The root-page of the master database table. - */ - const int MASTER_ROOT = 1;//#define MASTER_ROOT 1 - - /* - ** The name of the schema table. - */ - static string SCHEMA_TABLE(int x) //#define SCHEMA_TABLE(x) ((!OMIT_TEMPDB)&&(x==1)?TEMP_MASTER_NAME:MASTER_NAME) - { - return ((OMIT_TEMPDB == 0) && (x == 1) ? TEMP_MASTER_NAME : MASTER_NAME); - } + /* + ** Assert that the pointer X is aligned to an 8-byte boundary. This + ** macro is used only within Debug.Assert() to verify that the code gets + ** all alignment restrictions correct. + ** + ** Except, if SQLITE_4_BYTE_ALIGNED_MALLOC is defined, then the + ** underlying malloc() implemention might return us 4-byte aligned + ** pointers. In that case, only verify 4-byte alignment. + */ + //#if SQLITE_4_BYTE_ALIGNED_MALLOC + //# define EIGHT_BYTE_ALIGNMENT(X) ((((char)(X) - (char)0)&3)==0) + //#else + //# define EIGHT_BYTE_ALIGNMENT(X) ((((char)(X) - (char)0)&7)==0) + //#endif + + /* + ** An instance of the following structure is used to store the busy-handler + ** callback for a given sqlite handle. + ** + ** The sqlite.busyHandler member of the sqlite struct contains the busy + ** callback for the database handle. Each pager opened via the sqlite + ** handle is passed a pointer to sqlite.busyHandler. The busy-handler + ** callback is currently invoked only from within pager.c. + */ + //typedef struct BusyHandler BusyHandler; + public class BusyHandler + { + public dxBusy xFunc;//)(void *,int); /* The busy callback */ + public object pArg; /* First arg to busy callback */ + public int nBusy; /* Incremented with each busy call */ + }; + + /* + ** Name of the master database table. The master database table + ** is a special table that holds the names and attributes of all + ** user tables and indices. + */ + const string MASTER_NAME = "sqlite_master";//#define MASTER_NAME "sqlite_master" + const string TEMP_MASTER_NAME = "sqlite_temp_master";//#define TEMP_MASTER_NAME "sqlite_temp_master" - /* - ** A convenience macro that returns the number of elements in - ** an array. - */ - //#define ArraySize(X) ((int)(sizeof(X)/sizeof(X[0]))) - static int ArraySize(T[] x) { - return x.Length; - } + /* + ** The root-page of the master database table. + */ + const int MASTER_ROOT = 1;//#define MASTER_ROOT 1 + + /* + ** The name of the schema table. + */ + static string SCHEMA_TABLE( int x ) //#define SCHEMA_TABLE(x) ((!OMIT_TEMPDB)&&(x==1)?TEMP_MASTER_NAME:MASTER_NAME) + { + return ( ( OMIT_TEMPDB == 0 ) && ( x == 1 ) ? TEMP_MASTER_NAME : MASTER_NAME ); + } + + /* + ** A convenience macro that returns the number of elements in + ** an array. + */ + //#define ArraySize(X) ((int)(sizeof(X)/sizeof(X[0]))) + static int ArraySize( T[] x ) + { + return x.Length; + } - /* - ** The following value as a destructor means to use sqlite3DbFree(). - ** This is an internal extension to SQLITE_STATIC and SQLITE_TRANSIENT. - */ - //#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3DbFree) - static dxDel SQLITE_DYNAMIC; - - /* - ** When SQLITE_OMIT_WSD is defined, it means that the target platform does - ** not support Writable Static Data (WSD) such as global and static variables. - ** All variables must either be on the stack or dynamically allocated from - ** the heap. When WSD is unsupported, the variable declarations scattered - ** throughout the SQLite code must become constants instead. The SQLITE_WSD - ** macro is used for this purpose. And instead of referencing the variable - ** directly, we use its constant as a key to lookup the run-time allocated - ** buffer that holds real variable. The constant is also the initializer - ** for the run-time allocated buffer. - ** - ** In the usual case where WSD is supported, the SQLITE_WSD and GLOBAL - ** macros become no-ops and have zero performance impact. - */ + /* + ** The following value as a destructor means to use sqlite3DbFree(). + ** This is an internal extension to SQLITE_STATIC and SQLITE_TRANSIENT. + */ + //#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3DbFree) + static dxDel SQLITE_DYNAMIC; + + /* + ** When SQLITE_OMIT_WSD is defined, it means that the target platform does + ** not support Writable Static Data (WSD) such as global and static variables. + ** All variables must either be on the stack or dynamically allocated from + ** the heap. When WSD is unsupported, the variable declarations scattered + ** throughout the SQLite code must become constants instead. The SQLITE_WSD + ** macro is used for this purpose. And instead of referencing the variable + ** directly, we use its constant as a key to lookup the run-time allocated + ** buffer that holds real variable. The constant is also the initializer + ** for the run-time allocated buffer. + ** + ** In the usual case where WSD is supported, the SQLITE_WSD and GLOBAL + ** macros become no-ops and have zero performance impact. + */ #if SQLITE_OMIT_WSD //#define SQLITE_WSD const //#define GLOBAL(t,v) (*(t)sqlite3_wsd_find((void)&(v), sizeof(v))) @@ -689,366 +710,383 @@ static int ArraySize(T[] x) { int sqlite3_wsd_init(int N, int J); void *sqlite3_wsd_find(void *K, int L); #else - //#define SQLITE_WSD - //#define GLOBAL(t,v) v - //#define sqlite3GlobalConfig sqlite3Config - static Sqlite3Config sqlite3GlobalConfig; + //#define SQLITE_WSD + //#define GLOBAL(t,v) v + //#define sqlite3GlobalConfig sqlite3Config + static Sqlite3Config sqlite3GlobalConfig; #endif - /* - ** The following macros are used to suppress compiler warnings and to - ** make it clear to human readers when a function parameter is deliberately - ** left unused within the body of a function. This usually happens when - ** a function is called via a function pointer. For example the - ** implementation of an SQL aggregate step callback may not use the - ** parameter indicating the number of arguments passed to the aggregate, - ** if it knows that this is enforced elsewhere. + /* +** The following macros are used to suppress compiler warnings and to +** make it clear to human readers when a function parameter is deliberately +** left unused within the body of a function. This usually happens when +** a function is called via a function pointer. For example the +** implementation of an SQL aggregate step callback may not use the +** parameter indicating the number of arguments passed to the aggregate, +** if it knows that this is enforced elsewhere. +** +** When a function parameter is not used at all within the body of a function, +** it is generally named "NotUsed" or "NotUsed2" to make things even clearer. +** However, these macros may also be used to suppress warnings related to +** parameters that may or may not be used depending on compilation options. +** For example those parameters only used in Debug.Assert() statements. In these +** cases the parameters are named as per the usual conventions. +*/ + //#define UNUSED_PARAMETER(x) (void)(x) + static void UNUSED_PARAMETER( T x ) + { + } + + //#define UNUSED_PARAMETER2(x,y) UNUSED_PARAMETER(x),UNUSED_PARAMETER(y) + static void UNUSED_PARAMETER2( T1 x, T2 y ) + { + UNUSED_PARAMETER( x ); + UNUSED_PARAMETER( y ); + } + + /* + ** Forward references to structures + */ + //typedef struct AggInfo AggInfo; + //typedef struct AuthContext AuthContext; + //typedef struct AutoincInfo AutoincInfo; + //typedef struct Bitvec Bitvec; + //typedef struct CollSeq CollSeq; + //typedef struct Column Column; + //typedef struct Db Db; + //typedef struct Schema Schema; + //typedef struct Expr Expr; + //typedef struct ExprList ExprList; + //typedef struct ExprSpan ExprSpan; + //typedef struct FKey FKey; + //typedef struct FuncDestructor FuncDestructor; + //typedef struct FuncDef FuncDef; + //typedef struct IdList IdList; + //typedef struct Index Index; + //typedef struct IndexSample IndexSample; + //typedef struct KeyClass KeyClass; + //typedef struct KeyInfo KeyInfo; + //typedef struct Lookaside Lookaside; + //typedef struct LookasideSlot LookasideSlot; + //typedef struct Module Module; + //typedef struct NameContext NameContext; + //typedef struct Parse Parse; + //typedef struct RowSet RowSet; + //typedef struct Savepoint Savepoint; + //typedef struct Select Select; + //typedef struct SrcList SrcList; + //typedef struct StrAccum StrAccum; + //typedef struct Table Table; + //typedef struct TableLock TableLock; + //typedef struct Token Token; + //typedef struct Trigger Trigger; + //typedef struct TriggerPrg TriggerPrg; + //typedef struct TriggerStep TriggerStep; + //typedef struct UnpackedRecord UnpackedRecord; + //typedef struct VTable VTable; + //typedef struct VtabCtx VtabCtx; + //typedef struct Walker Walker; + //typedef struct WherePlan WherePlan; + //typedef struct WhereInfo WhereInfo; + //typedef struct WhereLevel WhereLevel; + + /* + ** Defer sourcing vdbe.h and btree.h until after the "u8" and + ** "BusyHandler" typedefs. vdbe.h also requires a few of the opaque + ** pointer types (i.e. FuncDef) defined above. + */ + //#include "btree.h" + //#include "vdbe.h" + //#include "pager.h" + //#include "pcache_g.h" + + //#include "os.h" + //#include "mutex.h" + + /* + ** Each database file to be accessed by the system is an instance + ** of the following structure. There are normally two of these structures + ** in the sqlite.aDb[] array. aDb[0] is the main database file and + ** aDb[1] is the database file used to hold temporary tables. Additional + ** databases may be attached. + */ + public class Db + { + public string zName; /* Name of this database */ + public Btree pBt; /* The B Tree structure for this database file */ + public u8 inTrans; /* 0: not writable. 1: Transaction. 2: Checkpoint */ + public u8 safety_level; /* How aggressive at syncing data to disk */ + public Schema pSchema; /* Pointer to database schema (possibly shared) */ + }; + + /* + ** An instance of the following structure stores a database schema. ** - ** When a function parameter is not used at all within the body of a function, - ** it is generally named "NotUsed" or "NotUsed2" to make things even clearer. - ** However, these macros may also be used to suppress warnings related to - ** parameters that may or may not be used depending on compilation options. - ** For example those parameters only used in Debug.Assert() statements. In these - ** cases the parameters are named as per the usual conventions. + ** Most Schema objects are associated with a Btree. The exception is + ** the Schema for the TEMP databaes (sqlite3.aDb[1]) which is free-standing. + ** In shared cache mode, a single Schema object can be shared by multiple + ** Btrees that refer to the same underlying BtShared object. + ** + ** Schema objects are automatically deallocated when the last Btree that + ** references them is destroyed. The TEMP Schema is manually freed by + ** sqlite3_close(). + * + ** A thread must be holding a mutex on the corresponding Btree in order + ** to access Schema content. This implies that the thread must also be + ** holding a mutex on the sqlite3 connection pointer that owns the Btree. + ** For a TEMP Schema, only the connection mutex is required. */ - //#define UNUSED_PARAMETER(x) (void)(x) - static void UNUSED_PARAMETER(T x) { + public class Schema + { + public int schema_cookie; /* Database schema version number for this file */ + public u32 iGeneration; /* Generation counter. Incremented with each change */ + public Hash tblHash = new Hash(); /* All tables indexed by name */ + public Hash idxHash = new Hash(); /* All (named) indices indexed by name */ + public Hash trigHash = new Hash();/* All triggers indexed by name */ + public Hash fkeyHash = new Hash();/* All foreign keys by referenced table name */ + public Table pSeqTab; /* The sqlite_sequence table used by AUTOINCREMENT */ + public u8 file_format; /* Schema format version for this file */ + public u8 enc; /* Text encoding used by this database */ + public u16 flags; /* Flags associated with this schema */ + public int cache_size; /* Number of pages to use in the cache */ + public Schema Copy() + { + if ( this == null ) + return null; + else + { + Schema cp = (Schema)MemberwiseClone(); + return cp; } + } - //#define UNUSED_PARAMETER2(x,y) UNUSED_PARAMETER(x),UNUSED_PARAMETER(y) - static void UNUSED_PARAMETER2(T1 x, T2 y) { - UNUSED_PARAMETER(x); - UNUSED_PARAMETER(y); + public void Clear() + { + if ( this != null ) + { + schema_cookie = 0; + tblHash = new Hash(); + idxHash = new Hash(); + trigHash = new Hash(); + fkeyHash = new Hash(); + pSeqTab = null; } + } + }; - /* - ** Forward references to structures - */ - //typedef struct AggInfo AggInfo; - //typedef struct AuthContext AuthContext; - //typedef struct AutoincInfo AutoincInfo; - //typedef struct Bitvec Bitvec; - //typedef struct CollSeq CollSeq; - //typedef struct Column Column; - //typedef struct Db Db; - //typedef struct Schema Schema; - //typedef struct Expr Expr; - //typedef struct ExprList ExprList; - //typedef struct ExprSpan ExprSpan; - //typedef struct FKey FKey; - //typedef struct FuncDestructor FuncDestructor; - //typedef struct FuncDef FuncDef; - //typedef struct IdList IdList; - //typedef struct Index Index; - //typedef struct IndexSample IndexSample; - //typedef struct KeyClass KeyClass; - //typedef struct KeyInfo KeyInfo; - //typedef struct Lookaside Lookaside; - //typedef struct LookasideSlot LookasideSlot; - //typedef struct Module Module; - //typedef struct NameContext NameContext; - //typedef struct Parse Parse; - //typedef struct RowSet RowSet; - //typedef struct Savepoint Savepoint; - //typedef struct Select Select; - //typedef struct SrcList SrcList; - //typedef struct StrAccum StrAccum; - //typedef struct Table Table; - //typedef struct TableLock TableLock; - //typedef struct Token Token; - //typedef struct Trigger Trigger; - //typedef struct TriggerPrg TriggerPrg; - //typedef struct TriggerStep TriggerStep; - //typedef struct UnpackedRecord UnpackedRecord; - //typedef struct VTable VTable; - //typedef struct VtabCtx VtabCtx; - //typedef struct Walker Walker; - //typedef struct WherePlan WherePlan; - //typedef struct WhereInfo WhereInfo; - //typedef struct WhereLevel WhereLevel; - - /* - ** Defer sourcing vdbe.h and btree.h until after the "u8" and - ** "BusyHandler" typedefs. vdbe.h also requires a few of the opaque - ** pointer types (i.e. FuncDef) defined above. - */ - //#include "btree.h" - //#include "vdbe.h" - //#include "pager.h" - //#include "pcache_g.h" - - //#include "os.h" - //#include "mutex.h" - - /* - ** Each database file to be accessed by the system is an instance - ** of the following structure. There are normally two of these structures - ** in the sqlite.aDb[] array. aDb[0] is the main database file and - ** aDb[1] is the database file used to hold temporary tables. Additional - ** databases may be attached. - */ - public class Db { - public string zName; /* Name of this database */ - public Btree pBt; /* The B Tree structure for this database file */ - public u8 inTrans; /* 0: not writable. 1: Transaction. 2: Checkpoint */ - public u8 safety_level; /* How aggressive at syncing data to disk */ - public Schema pSchema; /* Pointer to database schema (possibly shared) */ - }; - - /* - ** An instance of the following structure stores a database schema. - ** - ** Most Schema objects are associated with a Btree. The exception is - ** the Schema for the TEMP databaes (sqlite3.aDb[1]) which is free-standing. - ** In shared cache mode, a single Schema object can be shared by multiple - ** Btrees that refer to the same underlying BtShared object. - ** - ** Schema objects are automatically deallocated when the last Btree that - ** references them is destroyed. The TEMP Schema is manually freed by - ** sqlite3_close(). - * - ** A thread must be holding a mutex on the corresponding Btree in order - ** to access Schema content. This implies that the thread must also be - ** holding a mutex on the sqlite3 connection pointer that owns the Btree. - ** For a TEMP Schema, only the connection mutex is required. - */ - public class Schema { - public int schema_cookie; /* Database schema version number for this file */ - public u32 iGeneration; /* Generation counter. Incremented with each change */ - public Hash tblHash = new Hash(); /* All tables indexed by name */ - public Hash idxHash = new Hash(); /* All (named) indices indexed by name */ - public Hash trigHash = new Hash();/* All triggers indexed by name */ - public Hash fkeyHash = new Hash();/* All foreign keys by referenced table name */ - public Table pSeqTab; /* The sqlite_sequence table used by AUTOINCREMENT */ - public u8 file_format; /* Schema format version for this file */ - public u8 enc; /* Text encoding used by this database */ - public u16 flags; /* Flags associated with this schema */ - public int cache_size; /* Number of pages to use in the cache */ - public Schema Copy() { - if (this == null) - return null; - else { - Schema cp = (Schema)MemberwiseClone(); - return cp; - } - } - - public void Clear() { - if (this != null) { - schema_cookie = 0; - tblHash = new Hash(); - idxHash = new Hash(); - trigHash = new Hash(); - fkeyHash = new Hash(); - pSeqTab = null; - } - } - }; - - /* - ** These macros can be used to test, set, or clear bits in the - ** Db.pSchema->flags field. - */ - //#define DbHasProperty(D,I,P) (((D)->aDb[I].pSchema->flags&(P))==(P)) - static bool DbHasProperty(sqlite3 D, int I, ushort P) { - return (D.aDb[I].pSchema.flags & P) == P; - } - //#define DbHasAnyProperty(D,I,P) (((D)->aDb[I].pSchema->flags&(P))!=0) - //#define DbSetProperty(D,I,P) (D)->aDb[I].pSchema->flags|=(P) - static void DbSetProperty(sqlite3 D, int I, ushort P) { - D.aDb[I].pSchema.flags = (u16)(D.aDb[I].pSchema.flags | P); - } - //#define DbClearProperty(D,I,P) (D)->aDb[I].pSchema->flags&=~(P) - static void DbClearProperty(sqlite3 D, int I, ushort P) { - D.aDb[I].pSchema.flags = (u16)(D.aDb[I].pSchema.flags & ~P); - } - /* - ** Allowed values for the DB.pSchema->flags field. - ** - ** The DB_SchemaLoaded flag is set after the database schema has been - ** read into internal hash tables. - ** - ** DB_UnresetViews means that one or more views have column names that - ** have been filled out. If the schema changes, these column names might - ** changes and so the view will need to be reset. - */ - //#define DB_SchemaLoaded 0x0001 /* The schema has been loaded */ - //#define DB_UnresetViews 0x0002 /* Some views have defined column names */ - //#define DB_Empty 0x0004 /* The file is empty (length 0 bytes) */ - const u16 DB_SchemaLoaded = 0x0001; - const u16 DB_UnresetViews = 0x0002; - const u16 DB_Empty = 0x0004; - - /* - ** The number of different kinds of things that can be limited - ** using the sqlite3_limit() interface. - */ - //#define SQLITE_N_LIMIT (SQLITE_LIMIT_TRIGGER_DEPTH+1) - const int SQLITE_N_LIMIT = SQLITE_LIMIT_TRIGGER_DEPTH + 1; - - /* - ** Lookaside malloc is a set of fixed-size buffers that can be used - ** to satisfy small transient memory allocation requests for objects - ** associated with a particular database connection. The use of - ** lookaside malloc provides a significant performance enhancement - ** (approx 10%) by avoiding numerous malloc/free requests while parsing - ** SQL statements. - ** - ** The Lookaside structure holds configuration information about the - ** lookaside malloc subsystem. Each available memory allocation in - ** the lookaside subsystem is stored on a linked list of LookasideSlot - ** objects. - ** - ** Lookaside allocations are only allowed for objects that are associated - ** with a particular database connection. Hence, schema information cannot - ** be stored in lookaside because in shared cache mode the schema information - ** is shared by multiple database connections. Therefore, while parsing - ** schema information, the Lookaside.bEnabled flag is cleared so that - ** lookaside allocations are not used to construct the schema objects. - */ - public class Lookaside { - public int sz; /* Size of each buffer in bytes */ - public u8 bEnabled; /* False to disable new lookaside allocations */ - public bool bMalloced; /* True if pStart obtained from sqlite3_malloc() */ - public int nOut; /* Number of buffers currently checked out */ - public int mxOut; /* Highwater mark for nOut */ - public int[] anStat = new int[3]; /* 0: hits. 1: size misses. 2: full misses */ - public LookasideSlot pFree; /* List of available buffers */ - public int pStart; /* First byte of available memory space */ - public int pEnd; /* First byte past end of available space */ - }; - public class LookasideSlot { - public LookasideSlot pNext; /* Next buffer in the list of free buffers */ - }; - - /* - ** A hash table for function definitions. - ** - ** Hash each FuncDef structure into one of the FuncDefHash.a[] slots. - ** Collisions are on the FuncDef.pHash chain. - */ - public class FuncDefHash { - public FuncDef[] a = new FuncDef[23]; /* Hash table for functions */ - }; - - /* - ** Each database connection is an instance of the following structure. - ** - ** The sqlite.lastRowid records the last insert rowid generated by an - ** insert statement. Inserts on views do not affect its value. Each - ** trigger has its own context, so that lastRowid can be updated inside - ** triggers as usual. The previous value will be restored once the trigger - ** exits. Upon entering a before or instead of trigger, lastRowid is no - ** longer (since after version 2.8.12) reset to -1. - ** - ** The sqlite.nChange does not count changes within triggers and keeps no - ** context. It is reset at start of sqlite3_exec. - ** The sqlite.lsChange represents the number of changes made by the last - ** insert, update, or delete statement. It remains constant throughout the - ** length of a statement and is then updated by OP_SetCounts. It keeps a - ** context stack just like lastRowid so that the count of changes - ** within a trigger is not seen outside the trigger. Changes to views do not - ** affect the value of lsChange. - ** The sqlite.csChange keeps track of the number of current changes (since - ** the last statement) and is used to update sqlite_lsChange. - ** - ** The member variables sqlite.errCode, sqlite.zErrMsg and sqlite.zErrMsg16 - ** store the most recent error code and, if applicable, string. The - ** internal function sqlite3Error() is used to set these variables - ** consistently. - */ - public class sqlite3 { - public sqlite3_vfs pVfs; /* OS Interface */ - public int nDb; /* Number of backends currently in use */ - public Db[] aDb = new Db[SQLITE_MAX_ATTACHED]; /* All backends */ - public int flags; /* Miscellaneous flags. See below */ - public int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */ - public int errCode; /* Most recent error code (SQLITE_) */ - public int errMask; /* & result codes with this before returning */ - public u8 autoCommit; /* The auto-commit flag. */ - public u8 temp_store; /* 1: file 2: memory 0: default */ - // Cannot happen under C# - // public u8 mallocFailed; /* True if we have seen a malloc failure */ - public u8 dfltLockMode; /* Default locking-mode for attached dbs */ - public int nextAutovac; /* Autovac setting after VACUUM if >=0 */ - public u8 suppressErr; /* Do not issue error messages if true */ - public u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */ - public int nextPagesize; /* Pagesize after VACUUM if >0 */ - public int nTable; /* Number of tables in the database */ - public CollSeq pDfltColl; /* The default collating sequence (BINARY) */ - public i64 lastRowid; /* ROWID of most recent insert (see above) */ - public u32 magic; /* Magic number for detect library misuse */ - public int nChange; /* Value returned by sqlite3_changes() */ - public int nTotalChange; /* Value returned by sqlite3_total_changes() */ - public sqlite3_mutex mutex; /* Connection mutex */ - public int[] aLimit = new int[SQLITE_N_LIMIT]; /* Limits */ - public class sqlite3InitInfo { /* Information used during initialization */ - public int iDb; /* When back is being initialized */ - public int newTnum; /* Rootpage of table being initialized */ - public u8 busy; /* TRUE if currently initializing */ - public u8 orphanTrigger; /* Last statement is orphaned TEMP trigger */ - }; - public sqlite3InitInfo init = new sqlite3InitInfo(); - public int nExtension; /* Number of loaded extensions */ - public object[] aExtension; /* Array of shared library handles */ - public Vdbe pVdbe; /* List of active virtual machines */ - public int activeVdbeCnt; /* Number of VDBEs currently executing */ - public int writeVdbeCnt; /* Number of active VDBEs that are writing */ - public int vdbeExecCnt; /* Number of nested calls to VdbeExec() */ - public dxTrace xTrace;//)(void*,const char); /* Trace function */ - public object pTraceArg; /* Argument to the trace function */ - public dxProfile xProfile;//)(void*,const char*,u64); /* Profiling function */ - public object pProfileArg; /* Argument to profile function */ - public object pCommitArg; /* Argument to xCommitCallback() */ - public dxCommitCallback xCommitCallback;//)(void); /* Invoked at every commit. */ - public object pRollbackArg; /* Argument to xRollbackCallback() */ - public dxRollbackCallback xRollbackCallback;//)(void); /* Invoked at every commit. */ - public object pUpdateArg; - public dxUpdateCallback xUpdateCallback;//)(void*,int, const char*,const char*,sqlite_int64); + /* + ** These macros can be used to test, set, or clear bits in the + ** Db.pSchema->flags field. + */ + //#define DbHasProperty(D,I,P) (((D)->aDb[I].pSchema->flags&(P))==(P)) + static bool DbHasProperty( sqlite3 D, int I, ushort P ) + { + return ( D.aDb[I].pSchema.flags & P ) == P; + } + //#define DbHasAnyProperty(D,I,P) (((D)->aDb[I].pSchema->flags&(P))!=0) + //#define DbSetProperty(D,I,P) (D)->aDb[I].pSchema->flags|=(P) + static void DbSetProperty( sqlite3 D, int I, ushort P ) + { + D.aDb[I].pSchema.flags = (u16)( D.aDb[I].pSchema.flags | P ); + } + //#define DbClearProperty(D,I,P) (D)->aDb[I].pSchema->flags&=~(P) + static void DbClearProperty( sqlite3 D, int I, ushort P ) + { + D.aDb[I].pSchema.flags = (u16)( D.aDb[I].pSchema.flags & ~P ); + } + /* + ** Allowed values for the DB.pSchema->flags field. + ** + ** The DB_SchemaLoaded flag is set after the database schema has been + ** read into internal hash tables. + ** + ** DB_UnresetViews means that one or more views have column names that + ** have been filled out. If the schema changes, these column names might + ** changes and so the view will need to be reset. + */ + //#define DB_SchemaLoaded 0x0001 /* The schema has been loaded */ + //#define DB_UnresetViews 0x0002 /* Some views have defined column names */ + //#define DB_Empty 0x0004 /* The file is empty (length 0 bytes) */ + const u16 DB_SchemaLoaded = 0x0001; + const u16 DB_UnresetViews = 0x0002; + const u16 DB_Empty = 0x0004; + + /* + ** The number of different kinds of things that can be limited + ** using the sqlite3_limit() interface. + */ + //#define SQLITE_N_LIMIT (SQLITE_LIMIT_TRIGGER_DEPTH+1) + const int SQLITE_N_LIMIT = SQLITE_LIMIT_TRIGGER_DEPTH + 1; + + /* + ** Lookaside malloc is a set of fixed-size buffers that can be used + ** to satisfy small transient memory allocation requests for objects + ** associated with a particular database connection. The use of + ** lookaside malloc provides a significant performance enhancement + ** (approx 10%) by avoiding numerous malloc/free requests while parsing + ** SQL statements. + ** + ** The Lookaside structure holds configuration information about the + ** lookaside malloc subsystem. Each available memory allocation in + ** the lookaside subsystem is stored on a linked list of LookasideSlot + ** objects. + ** + ** Lookaside allocations are only allowed for objects that are associated + ** with a particular database connection. Hence, schema information cannot + ** be stored in lookaside because in shared cache mode the schema information + ** is shared by multiple database connections. Therefore, while parsing + ** schema information, the Lookaside.bEnabled flag is cleared so that + ** lookaside allocations are not used to construct the schema objects. + */ + public class Lookaside + { + public int sz; /* Size of each buffer in bytes */ + public u8 bEnabled; /* False to disable new lookaside allocations */ + public bool bMalloced; /* True if pStart obtained from sqlite3_malloc() */ + public int nOut; /* Number of buffers currently checked out */ + public int mxOut; /* Highwater mark for nOut */ + public int[] anStat = new int[3]; /* 0: hits. 1: size misses. 2: full misses */ + public LookasideSlot pFree; /* List of available buffers */ + public int pStart; /* First byte of available memory space */ + public int pEnd; /* First byte past end of available space */ + }; + public class LookasideSlot + { + public LookasideSlot pNext; /* Next buffer in the list of free buffers */ + }; + + /* + ** A hash table for function definitions. + ** + ** Hash each FuncDef structure into one of the FuncDefHash.a[] slots. + ** Collisions are on the FuncDef.pHash chain. + */ + public class FuncDefHash + { + public FuncDef[] a = new FuncDef[23]; /* Hash table for functions */ + }; + + /* + ** Each database connection is an instance of the following structure. + ** + ** The sqlite.lastRowid records the last insert rowid generated by an + ** insert statement. Inserts on views do not affect its value. Each + ** trigger has its own context, so that lastRowid can be updated inside + ** triggers as usual. The previous value will be restored once the trigger + ** exits. Upon entering a before or instead of trigger, lastRowid is no + ** longer (since after version 2.8.12) reset to -1. + ** + ** The sqlite.nChange does not count changes within triggers and keeps no + ** context. It is reset at start of sqlite3_exec. + ** The sqlite.lsChange represents the number of changes made by the last + ** insert, update, or delete statement. It remains constant throughout the + ** length of a statement and is then updated by OP_SetCounts. It keeps a + ** context stack just like lastRowid so that the count of changes + ** within a trigger is not seen outside the trigger. Changes to views do not + ** affect the value of lsChange. + ** The sqlite.csChange keeps track of the number of current changes (since + ** the last statement) and is used to update sqlite_lsChange. + ** + ** The member variables sqlite.errCode, sqlite.zErrMsg and sqlite.zErrMsg16 + ** store the most recent error code and, if applicable, string. The + ** internal function sqlite3Error() is used to set these variables + ** consistently. + */ + public class sqlite3 + { + public sqlite3_vfs pVfs; /* OS Interface */ + public int nDb; /* Number of backends currently in use */ + public Db[] aDb = new Db[SQLITE_MAX_ATTACHED]; /* All backends */ + public int flags; /* Miscellaneous flags. See below */ + public int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */ + public int errCode; /* Most recent error code (SQLITE_) */ + public int errMask; /* & result codes with this before returning */ + public u8 autoCommit; /* The auto-commit flag. */ + public u8 temp_store; /* 1: file 2: memory 0: default */ + // Cannot happen under C# + // public u8 mallocFailed; /* True if we have seen a malloc failure */ + public u8 dfltLockMode; /* Default locking-mode for attached dbs */ + public int nextAutovac; /* Autovac setting after VACUUM if >=0 */ + public u8 suppressErr; /* Do not issue error messages if true */ + public u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */ + public int nextPagesize; /* Pagesize after VACUUM if >0 */ + public int nTable; /* Number of tables in the database */ + public CollSeq pDfltColl; /* The default collating sequence (BINARY) */ + public i64 lastRowid; /* ROWID of most recent insert (see above) */ + public u32 magic; /* Magic number for detect library misuse */ + public int nChange; /* Value returned by sqlite3_changes() */ + public int nTotalChange; /* Value returned by sqlite3_total_changes() */ + public sqlite3_mutex mutex; /* Connection mutex */ + public int[] aLimit = new int[SQLITE_N_LIMIT]; /* Limits */ + public class sqlite3InitInfo + { /* Information used during initialization */ + public int iDb; /* When back is being initialized */ + public int newTnum; /* Rootpage of table being initialized */ + public u8 busy; /* TRUE if currently initializing */ + public u8 orphanTrigger; /* Last statement is orphaned TEMP trigger */ + }; + public sqlite3InitInfo init = new sqlite3InitInfo(); + public int nExtension; /* Number of loaded extensions */ + public object[] aExtension; /* Array of shared library handles */ + public Vdbe pVdbe; /* List of active virtual machines */ + public int activeVdbeCnt; /* Number of VDBEs currently executing */ + public int writeVdbeCnt; /* Number of active VDBEs that are writing */ + public int vdbeExecCnt; /* Number of nested calls to VdbeExec() */ + public dxTrace xTrace;//)(void*,const char); /* Trace function */ + public object pTraceArg; /* Argument to the trace function */ + public dxProfile xProfile;//)(void*,const char*,u64); /* Profiling function */ + public object pProfileArg; /* Argument to profile function */ + public object pCommitArg; /* Argument to xCommitCallback() */ + public dxCommitCallback xCommitCallback;//)(void); /* Invoked at every commit. */ + public object pRollbackArg; /* Argument to xRollbackCallback() */ + public dxRollbackCallback xRollbackCallback;//)(void); /* Invoked at every commit. */ + public object pUpdateArg; + public dxUpdateCallback xUpdateCallback;//)(void*,int, const char*,const char*,sqlite_int64); #if !SQLITE_OMIT_WAL //int (*xWalCallback)(void *, sqlite3 *, string , int); //void *pWalArg; #endif - public dxCollNeeded xCollNeeded;//)(void*,sqlite3*,int eTextRep,const char); - public dxCollNeeded xCollNeeded16;//)(void*,sqlite3*,int eTextRep,const void); - public object pCollNeededArg; - public sqlite3_value pErr; /* Most recent error message */ - public string zErrMsg; /* Most recent error message (UTF-8 encoded) */ - public string zErrMsg16; /* Most recent error message (UTF-16 encoded) */ - public struct _u1 { - public bool isInterrupted; /* True if sqlite3_interrupt has been called */ - public double notUsed1; /* Spacer */ - } - public _u1 u1; - public Lookaside lookaside = new Lookaside(); /* Lookaside malloc configuration */ + public dxCollNeeded xCollNeeded;//)(void*,sqlite3*,int eTextRep,const char); + public dxCollNeeded xCollNeeded16;//)(void*,sqlite3*,int eTextRep,const void); + public object pCollNeededArg; + public sqlite3_value pErr; /* Most recent error message */ + public string zErrMsg; /* Most recent error message (UTF-8 encoded) */ + public string zErrMsg16; /* Most recent error message (UTF-16 encoded) */ + public struct _u1 + { + public bool isInterrupted; /* True if sqlite3_interrupt has been called */ + public double notUsed1; /* Spacer */ + } + public _u1 u1; + public Lookaside lookaside = new Lookaside(); /* Lookaside malloc configuration */ #if !SQLITE_OMIT_AUTHORIZATION public dxAuth xAuth;//)(void*,int,const char*,const char*,const char*,const char); /* Access authorization function */ public object pAuthArg; /* 1st argument to the access auth function */ #endif #if !SQLITE_OMIT_PROGRESS_CALLBACK - public dxProgress xProgress;//)(void ); /* The progress callback */ - public object pProgressArg; /* Argument to the progress callback */ - public int nProgressOps; /* Number of opcodes for progress callback */ + public dxProgress xProgress;//)(void ); /* The progress callback */ + public object pProgressArg; /* Argument to the progress callback */ + public int nProgressOps; /* Number of opcodes for progress callback */ #endif #if !SQLITE_OMIT_VIRTUALTABLE - public Hash aModule; /* populated by sqlite3_create_module() */ - public VtabCtx pVtabCtx; /* Context for active vtab connect/create */ - public VTable[] aVTrans; /* Virtual tables with open transactions */ - public int nVTrans; /* Allocated size of aVTrans */ - public VTable pDisconnect; /* Disconnect these in next sqlite3_prepare() */ + public Hash aModule; /* populated by sqlite3_create_module() */ + public VtabCtx pVtabCtx; /* Context for active vtab connect/create */ + public VTable[] aVTrans; /* Virtual tables with open transactions */ + public int nVTrans; /* Allocated size of aVTrans */ + public VTable pDisconnect; /* Disconnect these in next sqlite3_prepare() */ #endif - public FuncDefHash aFunc = new FuncDefHash(); /* Hash table of connection functions */ - public Hash aCollSeq = new Hash(); /* All collating sequences */ - public BusyHandler busyHandler = new BusyHandler(); /* Busy callback */ - public int busyTimeout; /* Busy handler timeout, in msec */ - public Db[] aDbStatic = new Db[] { new Db(), new Db() }; /* Static space for the 2 default backends */ - public Savepoint pSavepoint; /* List of active savepoints */ - public int nSavepoint; /* Number of non-transaction savepoints */ - public int nStatement; /* Number of nested statement-transactions */ - public u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */ - public i64 nDeferredCons; /* Net deferred constraints this transaction. */ - public int pnBytesFreed; /* If not NULL, increment this in DbFree() */ + public FuncDefHash aFunc = new FuncDefHash(); /* Hash table of connection functions */ + public Hash aCollSeq = new Hash(); /* All collating sequences */ + public BusyHandler busyHandler = new BusyHandler(); /* Busy callback */ + public int busyTimeout; /* Busy handler timeout, in msec */ + public Db[] aDbStatic = new Db[] { new Db(), new Db() }; /* Static space for the 2 default backends */ + public Savepoint pSavepoint; /* List of active savepoints */ + public int nSavepoint; /* Number of non-transaction savepoints */ + public int nStatement; /* Number of nested statement-transactions */ + public u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */ + public i64 nDeferredCons; /* Net deferred constraints this transaction. */ + public int pnBytesFreed; /* If not NULL, increment this in DbFree() */ #if SQLITE_ENABLE_UNLOCK_NOTIFY /* The following variables are all protected by the STATIC_MASTER ** mutex, not by sqlite3.mutex. They are used by code in notify.c. @@ -1066,608 +1104,633 @@ public struct _u1 { void (*xUnlockNotify)(void **, int); /* Unlock notify callback */ sqlite3 *pNextBlocked; /* Next in list of all blocked connections */ #endif - }; - - /* - ** A macro to discover the encoding of a database. - */ - //#define ENC(db) ((db)->aDb[0].pSchema->enc) - static u8 ENC(sqlite3 db) { - return db.aDb[0].pSchema.enc; - } + }; - /* - ** Possible values for the sqlite3.flags. - */ - //#define SQLITE_VdbeTrace 0x00000100 /* True to trace VDBE execution */ - //#define SQLITE_InternChanges 0x00000200 /* Uncommitted Hash table changes */ - //#define SQLITE_FullColNames 0x00000400 /* Show full column names on SELECT */ - //#define SQLITE_ShortColNames 0x00000800 /* Show short columns names */ - //#define SQLITE_CountRows 0x00001000 /* Count rows changed by INSERT, */ - // /* DELETE, or UPDATE and return */ - // /* the count using a callback. */ - //#define SQLITE_NullCallback 0x00002000 /* Invoke the callback once if the */ - // /* result set is empty */ - //#define SQLITE_SqlTrace 0x00004000 /* Debug print SQL as it executes */ - //#define SQLITE_VdbeListing 0x00008000 /* Debug listings of VDBE programs */ - //#define SQLITE_WriteSchema 0x00010000 /* OK to update SQLITE_MASTER */ - //#define SQLITE_NoReadlock 0x00020000 /* Readlocks are omitted when - // ** accessing read-only databases */ - //#define SQLITE_IgnoreChecks 0x00040000 /* Do not enforce check constraints */ - //#define SQLITE_ReadUncommitted 0x0080000 /* For shared-cache mode */ - //#define SQLITE_LegacyFileFmt 0x00100000 /* Create new databases in format 1 */ - //#define SQLITE_FullFSync 0x00200000 /* Use full fsync on the backend */ - //#define SQLITE_CkptFullFSync 0x00400000 /* Use full fsync for checkpoint */ - //#define SQLITE_RecoveryMode 0x00800000 /* Ignore schema errors */ - //#define SQLITE_ReverseOrder 0x01000000 /* Reverse unordered SELECTs */ - //#define SQLITE_RecTriggers 0x02000000 /* Enable recursive triggers */ - //#define SQLITE_ForeignKeys 0x04000000 /* Enforce foreign key constraints */ - //#define SQLITE_AutoIndex 0x08000000 /* Enable automatic indexes */ - //#define SQLITE_PreferBuiltin 0x10000000 /* Preference to built-in funcs */ - //#define SQLITE_LoadExtension 0x20000000 /* Enable load_extension */ - //define SQLITE_EnableTrigger 0x40000000 /* True to enable triggers */ - const int SQLITE_VdbeTrace = 0x00000100; - const int SQLITE_InternChanges = 0x00000200; - const int SQLITE_FullColNames = 0x00000400; - const int SQLITE_ShortColNames = 0x00000800; - const int SQLITE_CountRows = 0x00001000; - const int SQLITE_NullCallback = 0x00002000; - const int SQLITE_SqlTrace = 0x00004000; - const int SQLITE_VdbeListing = 0x00008000; - const int SQLITE_WriteSchema = 0x00010000; - const int SQLITE_NoReadlock = 0x00020000; - const int SQLITE_IgnoreChecks = 0x00040000; - const int SQLITE_ReadUncommitted = 0x0080000; - const int SQLITE_LegacyFileFmt = 0x00100000; - const int SQLITE_FullFSync = 0x00200000; - const int SQLITE_CkptFullFSync = 0x00400000; - const int SQLITE_RecoveryMode = 0x00800000; - const int SQLITE_ReverseOrder = 0x01000000; - const int SQLITE_RecTriggers = 0x02000000; - const int SQLITE_ForeignKeys = 0x04000000; - const int SQLITE_AutoIndex = 0x08000000; - const int SQLITE_PreferBuiltin = 0x10000000; - const int SQLITE_LoadExtension = 0x20000000; - const int SQLITE_EnableTrigger = 0x40000000; - - /* - ** Bits of the sqlite3.flags field that are used by the - ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface. - ** These must be the low-order bits of the flags field. - */ - //#define SQLITE_QueryFlattener 0x01 /* Disable query flattening */ - //#define SQLITE_ColumnCache 0x02 /* Disable the column cache */ - //#define SQLITE_IndexSort 0x04 /* Disable indexes for sorting */ - //#define SQLITE_IndexSearch 0x08 /* Disable indexes for searching */ - //#define SQLITE_IndexCover 0x10 /* Disable index covering table */ - //#define SQLITE_GroupByOrder 0x20 /* Disable GROUPBY cover of ORDERBY */ - //#define SQLITE_FactorOutConst 0x40 /* Disable factoring out constants */ - //#define SQLITE_IdxRealAsInt 0x80 /* Store REAL as INT in indices */ - //#define SQLITE_OptMask 0xff /* Mask of all disablable opts */ - const int SQLITE_QueryFlattener = 0x01; - const int SQLITE_ColumnCache = 0x02; - const int SQLITE_IndexSort = 0x04; - const int SQLITE_IndexSearch = 0x08; - const int SQLITE_IndexCover = 0x10; - const int SQLITE_GroupByOrder = 0x20; - const int SQLITE_FactorOutConst = 0x40; - const int SQLITE_IdxRealAsInt = 0x80; - const int SQLITE_OptMask = 0xff; - - /* - ** Possible values for the sqlite.magic field. - ** The numbers are obtained at random and have no special meaning, other - ** than being distinct from one another. - */ - const int SQLITE_MAGIC_OPEN = 0x1029a697; //#define SQLITE_MAGIC_OPEN 0xa029a697 /* Database is open */ - const int SQLITE_MAGIC_CLOSED = 0x2f3c2d33; //#define SQLITE_MAGIC_CLOSED 0x9f3c2d33 /* Database is closed */ - const int SQLITE_MAGIC_SICK = 0x3b771290; //#define SQLITE_MAGIC_SICK 0x4b771290 /* Error and awaiting close */ - const int SQLITE_MAGIC_BUSY = 0x403b7906; //#define SQLITE_MAGIC_BUSY 0xf03b7906 /* Database currently in use */ - const int SQLITE_MAGIC_ERROR = 0x55357930; //#define SQLITE_MAGIC_ERROR 0xb5357930 /* An SQLITE_MISUSE error occurred */ - - /* - ** Each SQL function is defined by an instance of the following - ** structure. A pointer to this structure is stored in the sqlite.aFunc - ** hash table. When multiple functions have the same name, the hash table - ** points to a linked list of these structures. - */ - public class FuncDef { - public i16 nArg; /* Number of arguments. -1 means unlimited */ - public u8 iPrefEnc; /* Preferred text encoding (SQLITE_UTF8, 16LE, 16BE) */ - public u8 flags; /* Some combination of SQLITE_FUNC_* */ - public object pUserData; /* User data parameter */ - public FuncDef pNext; /* Next function with same name */ - public dxFunc xFunc;//)(sqlite3_context*,int,sqlite3_value*); /* Regular function */ - public dxStep xStep;//)(sqlite3_context*,int,sqlite3_value*); /* Aggregate step */ - public dxFinal xFinalize;//)(sqlite3_context); /* Aggregate finalizer */ - public string zName; /* SQL name of the function. */ - public FuncDef pHash; /* Next with a different name but the same hash */ - public FuncDestructor pDestructor; /* Reference counted destructor function */ - - public FuncDef() { - } - - public FuncDef(i16 nArg, u8 iPrefEnc, u8 iflags, object pUserData, FuncDef pNext, dxFunc xFunc, dxStep xStep, dxFinal xFinalize, string zName, FuncDef pHash, FuncDestructor pDestructor) { - this.nArg = nArg; - this.iPrefEnc = iPrefEnc; - this.flags = iflags; - this.pUserData = pUserData; - this.pNext = pNext; - this.xFunc = xFunc; - this.xStep = xStep; - this.xFinalize = xFinalize; - this.zName = zName; - this.pHash = pHash; - this.pDestructor = pDestructor; - } - public FuncDef(string zName, u8 iPrefEnc, i16 nArg, int iArg, u8 iflags, dxFunc xFunc) { - this.nArg = nArg; - this.iPrefEnc = iPrefEnc; - this.flags = iflags; - this.pUserData = iArg; - this.pNext = null; - this.xFunc = xFunc; - this.xStep = null; - this.xFinalize = null; - this.zName = zName; - } - - public FuncDef(string zName, u8 iPrefEnc, i16 nArg, int iArg, u8 iflags, dxStep xStep, dxFinal xFinal) { - this.nArg = nArg; - this.iPrefEnc = iPrefEnc; - this.flags = iflags; - this.pUserData = iArg; - this.pNext = null; - this.xFunc = null; - this.xStep = xStep; - this.xFinalize = xFinal; - this.zName = zName; - } - - public FuncDef(string zName, u8 iPrefEnc, i16 nArg, object arg, dxFunc xFunc, u8 flags) { - this.nArg = nArg; - this.iPrefEnc = iPrefEnc; - this.flags = flags; - this.pUserData = arg; - this.pNext = null; - this.xFunc = xFunc; - this.xStep = null; - this.xFinalize = null; - this.zName = zName; - } - - public FuncDef Copy() { - FuncDef c = new FuncDef(); - c.nArg = nArg; - c.iPrefEnc = iPrefEnc; - c.flags = flags; - c.pUserData = pUserData; - c.pNext = pNext; - c.xFunc = xFunc; - c.xStep = xStep; - c.xFinalize = xFinalize; - c.zName = zName; - c.pHash = pHash; - c.pDestructor = pDestructor; - return c; - } - }; - - /* - ** This structure encapsulates a user-function destructor callback (as - ** configured using create_function_v2()) and a reference counter. When - ** create_function_v2() is called to create a function with a destructor, - ** a single object of this type is allocated. FuncDestructor.nRef is set to - ** the number of FuncDef objects created (either 1 or 3, depending on whether - ** or not the specified encoding is SQLITE_ANY). The FuncDef.pDestructor - ** member of each of the new FuncDef objects is set to point to the allocated - ** FuncDestructor. - ** - ** Thereafter, when one of the FuncDef objects is deleted, the reference - ** count on this object is decremented. When it reaches 0, the destructor - ** is invoked and the FuncDestructor structure freed. - */ - //struct FuncDestructor { - // int nRef; - // void (*xDestroy)(void ); - // void *pUserData; - //}; - public class FuncDestructor { - public int nRef; - public dxFDestroy xDestroy;// (*xDestroy)(void ); - public object pUserData; - }; - - - /* - ** Possible values for FuncDef.flags - */ - //#define SQLITE_FUNC_LIKE 0x01 /* Candidate for the LIKE optimization */ - //#define SQLITE_FUNC_CASE 0x02 /* Case-sensitive LIKE-type function */ - //#define SQLITE_FUNC_EPHEM 0x04 /* Ephemeral. Delete with VDBE */ - //#define SQLITE_FUNC_NEEDCOLL 0x08 /* sqlite3GetFuncCollSeq() might be called */ - //#define SQLITE_FUNC_PRIVATE 0x10 /* Allowed for internal use only */ - //#define SQLITE_FUNC_COUNT 0x20 /* Built-in count() aggregate */ - //#define SQLITE_FUNC_COALESCE 0x40 /* Built-in coalesce() or ifnull() function */ - const int SQLITE_FUNC_LIKE = 0x01; /* Candidate for the LIKE optimization */ - const int SQLITE_FUNC_CASE = 0x02; /* Case-sensitive LIKE-type function */ - const int SQLITE_FUNC_EPHEM = 0x04; /* Ephermeral. Delete with VDBE */ - const int SQLITE_FUNC_NEEDCOLL = 0x08;/* sqlite3GetFuncCollSeq() might be called */ - const int SQLITE_FUNC_PRIVATE = 0x10; /* Allowed for internal use only */ - const int SQLITE_FUNC_COUNT = 0x20; /* Built-in count() aggregate */ - const int SQLITE_FUNC_COALESCE = 0x40;/* Built-in coalesce() or ifnull() function */ - - - /* - ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are - ** used to create the initializers for the FuncDef structures. - ** - ** FUNCTION(zName, nArg, iArg, bNC, xFunc) - ** Used to create a scalar function definition of a function zName - ** implemented by C function xFunc that accepts nArg arguments. The - ** value passed as iArg is cast to a (void) and made available - ** as the user-data (sqlite3_user_data()) for the function. If - ** argument bNC is true, then the SQLITE_FUNC_NEEDCOLL flag is set. - ** - ** AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal) - ** Used to create an aggregate function definition implemented by - ** the C functions xStep and xFinal. The first four parameters - ** are interpreted in the same way as the first 4 parameters to - ** FUNCTION(). - ** - ** LIKEFUNC(zName, nArg, pArg, flags) - ** Used to create a scalar function definition of a function zName - ** that accepts nArg arguments and is implemented by a call to C - ** function likeFunc. Argument pArg is cast to a (void ) and made - ** available as the function user-data (sqlite3_user_data()). The - ** FuncDef.flags variable is set to the value passed as the flags - ** parameter. - */ - //#define FUNCTION(zName, nArg, iArg, bNC, xFunc) \ - // {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \ - //SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} - - static FuncDef FUNCTION(string zName, i16 nArg, int iArg, u8 bNC, dxFunc xFunc) { - return new FuncDef(zName, SQLITE_UTF8, nArg, iArg, (u8)(bNC * SQLITE_FUNC_NEEDCOLL), xFunc); - } + /* + ** A macro to discover the encoding of a database. + */ + //#define ENC(db) ((db)->aDb[0].pSchema->enc) + static u8 ENC( sqlite3 db ) + { + return db.aDb[0].pSchema.enc; + } + + /* + ** Possible values for the sqlite3.flags. + */ + //#define SQLITE_VdbeTrace 0x00000100 /* True to trace VDBE execution */ + //#define SQLITE_InternChanges 0x00000200 /* Uncommitted Hash table changes */ + //#define SQLITE_FullColNames 0x00000400 /* Show full column names on SELECT */ + //#define SQLITE_ShortColNames 0x00000800 /* Show short columns names */ + //#define SQLITE_CountRows 0x00001000 /* Count rows changed by INSERT, */ + // /* DELETE, or UPDATE and return */ + // /* the count using a callback. */ + //#define SQLITE_NullCallback 0x00002000 /* Invoke the callback once if the */ + // /* result set is empty */ + //#define SQLITE_SqlTrace 0x00004000 /* Debug print SQL as it executes */ + //#define SQLITE_VdbeListing 0x00008000 /* Debug listings of VDBE programs */ + //#define SQLITE_WriteSchema 0x00010000 /* OK to update SQLITE_MASTER */ + //#define SQLITE_NoReadlock 0x00020000 /* Readlocks are omitted when + // ** accessing read-only databases */ + //#define SQLITE_IgnoreChecks 0x00040000 /* Do not enforce check constraints */ + //#define SQLITE_ReadUncommitted 0x0080000 /* For shared-cache mode */ + //#define SQLITE_LegacyFileFmt 0x00100000 /* Create new databases in format 1 */ + //#define SQLITE_FullFSync 0x00200000 /* Use full fsync on the backend */ + //#define SQLITE_CkptFullFSync 0x00400000 /* Use full fsync for checkpoint */ + //#define SQLITE_RecoveryMode 0x00800000 /* Ignore schema errors */ + //#define SQLITE_ReverseOrder 0x01000000 /* Reverse unordered SELECTs */ + //#define SQLITE_RecTriggers 0x02000000 /* Enable recursive triggers */ + //#define SQLITE_ForeignKeys 0x04000000 /* Enforce foreign key constraints */ + //#define SQLITE_AutoIndex 0x08000000 /* Enable automatic indexes */ + //#define SQLITE_PreferBuiltin 0x10000000 /* Preference to built-in funcs */ + //#define SQLITE_LoadExtension 0x20000000 /* Enable load_extension */ + //define SQLITE_EnableTrigger 0x40000000 /* True to enable triggers */ + const int SQLITE_VdbeTrace = 0x00000100; + const int SQLITE_InternChanges = 0x00000200; + const int SQLITE_FullColNames = 0x00000400; + const int SQLITE_ShortColNames = 0x00000800; + const int SQLITE_CountRows = 0x00001000; + const int SQLITE_NullCallback = 0x00002000; + const int SQLITE_SqlTrace = 0x00004000; + const int SQLITE_VdbeListing = 0x00008000; + const int SQLITE_WriteSchema = 0x00010000; + const int SQLITE_NoReadlock = 0x00020000; + const int SQLITE_IgnoreChecks = 0x00040000; + const int SQLITE_ReadUncommitted = 0x0080000; + const int SQLITE_LegacyFileFmt = 0x00100000; + const int SQLITE_FullFSync = 0x00200000; + const int SQLITE_CkptFullFSync = 0x00400000; + const int SQLITE_RecoveryMode = 0x00800000; + const int SQLITE_ReverseOrder = 0x01000000; + const int SQLITE_RecTriggers = 0x02000000; + const int SQLITE_ForeignKeys = 0x04000000; + const int SQLITE_AutoIndex = 0x08000000; + const int SQLITE_PreferBuiltin = 0x10000000; + const int SQLITE_LoadExtension = 0x20000000; + const int SQLITE_EnableTrigger = 0x40000000; + + /* + ** Bits of the sqlite3.flags field that are used by the + ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface. + ** These must be the low-order bits of the flags field. + */ + //#define SQLITE_QueryFlattener 0x01 /* Disable query flattening */ + //#define SQLITE_ColumnCache 0x02 /* Disable the column cache */ + //#define SQLITE_IndexSort 0x04 /* Disable indexes for sorting */ + //#define SQLITE_IndexSearch 0x08 /* Disable indexes for searching */ + //#define SQLITE_IndexCover 0x10 /* Disable index covering table */ + //#define SQLITE_GroupByOrder 0x20 /* Disable GROUPBY cover of ORDERBY */ + //#define SQLITE_FactorOutConst 0x40 /* Disable factoring out constants */ + //#define SQLITE_IdxRealAsInt 0x80 /* Store REAL as INT in indices */ + //#define SQLITE_OptMask 0xff /* Mask of all disablable opts */ + const int SQLITE_QueryFlattener = 0x01; + const int SQLITE_ColumnCache = 0x02; + const int SQLITE_IndexSort = 0x04; + const int SQLITE_IndexSearch = 0x08; + const int SQLITE_IndexCover = 0x10; + const int SQLITE_GroupByOrder = 0x20; + const int SQLITE_FactorOutConst = 0x40; + const int SQLITE_IdxRealAsInt = 0x80; + const int SQLITE_OptMask = 0xff; + + /* + ** Possible values for the sqlite.magic field. + ** The numbers are obtained at random and have no special meaning, other + ** than being distinct from one another. + */ + const int SQLITE_MAGIC_OPEN = 0x1029a697; //#define SQLITE_MAGIC_OPEN 0xa029a697 /* Database is open */ + const int SQLITE_MAGIC_CLOSED = 0x2f3c2d33; //#define SQLITE_MAGIC_CLOSED 0x9f3c2d33 /* Database is closed */ + const int SQLITE_MAGIC_SICK = 0x3b771290; //#define SQLITE_MAGIC_SICK 0x4b771290 /* Error and awaiting close */ + const int SQLITE_MAGIC_BUSY = 0x403b7906; //#define SQLITE_MAGIC_BUSY 0xf03b7906 /* Database currently in use */ + const int SQLITE_MAGIC_ERROR = 0x55357930; //#define SQLITE_MAGIC_ERROR 0xb5357930 /* An SQLITE_MISUSE error occurred */ + + /* + ** Each SQL function is defined by an instance of the following + ** structure. A pointer to this structure is stored in the sqlite.aFunc + ** hash table. When multiple functions have the same name, the hash table + ** points to a linked list of these structures. + */ + public class FuncDef + { + public i16 nArg; /* Number of arguments. -1 means unlimited */ + public u8 iPrefEnc; /* Preferred text encoding (SQLITE_UTF8, 16LE, 16BE) */ + public u8 flags; /* Some combination of SQLITE_FUNC_* */ + public object pUserData; /* User data parameter */ + public FuncDef pNext; /* Next function with same name */ + public dxFunc xFunc;//)(sqlite3_context*,int,sqlite3_value*); /* Regular function */ + public dxStep xStep;//)(sqlite3_context*,int,sqlite3_value*); /* Aggregate step */ + public dxFinal xFinalize;//)(sqlite3_context); /* Aggregate finalizer */ + public string zName; /* SQL name of the function. */ + public FuncDef pHash; /* Next with a different name but the same hash */ + public FuncDestructor pDestructor; /* Reference counted destructor function */ + + public FuncDef() + { + } + + public FuncDef( i16 nArg, u8 iPrefEnc, u8 iflags, object pUserData, FuncDef pNext, dxFunc xFunc, dxStep xStep, dxFinal xFinalize, string zName, FuncDef pHash, FuncDestructor pDestructor ) + { + this.nArg = nArg; + this.iPrefEnc = iPrefEnc; + this.flags = iflags; + this.pUserData = pUserData; + this.pNext = pNext; + this.xFunc = xFunc; + this.xStep = xStep; + this.xFinalize = xFinalize; + this.zName = zName; + this.pHash = pHash; + this.pDestructor = pDestructor; + } + public FuncDef( string zName, u8 iPrefEnc, i16 nArg, int iArg, u8 iflags, dxFunc xFunc ) + { + this.nArg = nArg; + this.iPrefEnc = iPrefEnc; + this.flags = iflags; + this.pUserData = iArg; + this.pNext = null; + this.xFunc = xFunc; + this.xStep = null; + this.xFinalize = null; + this.zName = zName; + } + + public FuncDef( string zName, u8 iPrefEnc, i16 nArg, int iArg, u8 iflags, dxStep xStep, dxFinal xFinal ) + { + this.nArg = nArg; + this.iPrefEnc = iPrefEnc; + this.flags = iflags; + this.pUserData = iArg; + this.pNext = null; + this.xFunc = null; + this.xStep = xStep; + this.xFinalize = xFinal; + this.zName = zName; + } + + public FuncDef( string zName, u8 iPrefEnc, i16 nArg, object arg, dxFunc xFunc, u8 flags ) + { + this.nArg = nArg; + this.iPrefEnc = iPrefEnc; + this.flags = flags; + this.pUserData = arg; + this.pNext = null; + this.xFunc = xFunc; + this.xStep = null; + this.xFinalize = null; + this.zName = zName; + } + + public FuncDef Copy() + { + FuncDef c = new FuncDef(); + c.nArg = nArg; + c.iPrefEnc = iPrefEnc; + c.flags = flags; + c.pUserData = pUserData; + c.pNext = pNext; + c.xFunc = xFunc; + c.xStep = xStep; + c.xFinalize = xFinalize; + c.zName = zName; + c.pHash = pHash; + c.pDestructor = pDestructor; + return c; + } + }; + + /* + ** This structure encapsulates a user-function destructor callback (as + ** configured using create_function_v2()) and a reference counter. When + ** create_function_v2() is called to create a function with a destructor, + ** a single object of this type is allocated. FuncDestructor.nRef is set to + ** the number of FuncDef objects created (either 1 or 3, depending on whether + ** or not the specified encoding is SQLITE_ANY). The FuncDef.pDestructor + ** member of each of the new FuncDef objects is set to point to the allocated + ** FuncDestructor. + ** + ** Thereafter, when one of the FuncDef objects is deleted, the reference + ** count on this object is decremented. When it reaches 0, the destructor + ** is invoked and the FuncDestructor structure freed. + */ + //struct FuncDestructor { + // int nRef; + // void (*xDestroy)(void ); + // void *pUserData; + //}; + public class FuncDestructor + { + public int nRef; + public dxFDestroy xDestroy;// (*xDestroy)(void ); + public object pUserData; + }; - //#define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \ - // {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \ - //pArg, 0, xFunc, 0, 0, #zName, 0, 0} - //#define LIKEFUNC(zName, nArg, arg, flags) \ - // {nArg, SQLITE_UTF8, flags, (void )arg, 0, likeFunc, 0, 0, #zName, 0, 0} - static FuncDef LIKEFUNC(string zName, i16 nArg, object arg, u8 flags) { - return new FuncDef(zName, SQLITE_UTF8, nArg, arg, likeFunc, flags); - } + /* + ** Possible values for FuncDef.flags + */ + //#define SQLITE_FUNC_LIKE 0x01 /* Candidate for the LIKE optimization */ + //#define SQLITE_FUNC_CASE 0x02 /* Case-sensitive LIKE-type function */ + //#define SQLITE_FUNC_EPHEM 0x04 /* Ephemeral. Delete with VDBE */ + //#define SQLITE_FUNC_NEEDCOLL 0x08 /* sqlite3GetFuncCollSeq() might be called */ + //#define SQLITE_FUNC_PRIVATE 0x10 /* Allowed for internal use only */ + //#define SQLITE_FUNC_COUNT 0x20 /* Built-in count() aggregate */ + //#define SQLITE_FUNC_COALESCE 0x40 /* Built-in coalesce() or ifnull() function */ + const int SQLITE_FUNC_LIKE = 0x01; /* Candidate for the LIKE optimization */ + const int SQLITE_FUNC_CASE = 0x02; /* Case-sensitive LIKE-type function */ + const int SQLITE_FUNC_EPHEM = 0x04; /* Ephermeral. Delete with VDBE */ + const int SQLITE_FUNC_NEEDCOLL = 0x08;/* sqlite3GetFuncCollSeq() might be called */ + const int SQLITE_FUNC_PRIVATE = 0x10; /* Allowed for internal use only */ + const int SQLITE_FUNC_COUNT = 0x20; /* Built-in count() aggregate */ + const int SQLITE_FUNC_COALESCE = 0x40;/* Built-in coalesce() or ifnull() function */ + + + /* + ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are + ** used to create the initializers for the FuncDef structures. + ** + ** FUNCTION(zName, nArg, iArg, bNC, xFunc) + ** Used to create a scalar function definition of a function zName + ** implemented by C function xFunc that accepts nArg arguments. The + ** value passed as iArg is cast to a (void) and made available + ** as the user-data (sqlite3_user_data()) for the function. If + ** argument bNC is true, then the SQLITE_FUNC_NEEDCOLL flag is set. + ** + ** AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal) + ** Used to create an aggregate function definition implemented by + ** the C functions xStep and xFinal. The first four parameters + ** are interpreted in the same way as the first 4 parameters to + ** FUNCTION(). + ** + ** LIKEFUNC(zName, nArg, pArg, flags) + ** Used to create a scalar function definition of a function zName + ** that accepts nArg arguments and is implemented by a call to C + ** function likeFunc. Argument pArg is cast to a (void ) and made + ** available as the function user-data (sqlite3_user_data()). The + ** FuncDef.flags variable is set to the value passed as the flags + ** parameter. + */ + //#define FUNCTION(zName, nArg, iArg, bNC, xFunc) \ + // {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \ + //SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} - //#define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \ - // {nArg, SQLITE_UTF8, nc*SQLITE_FUNC_NEEDCOLL, \ - //SQLITE_INT_TO_PTR(arg), 0, 0, xStep,xFinal,#zName,0,0} + static FuncDef FUNCTION( string zName, i16 nArg, int iArg, u8 bNC, dxFunc xFunc ) + { + return new FuncDef( zName, SQLITE_UTF8, nArg, iArg, (u8)( bNC * SQLITE_FUNC_NEEDCOLL ), xFunc ); + } - static FuncDef AGGREGATE(string zName, i16 nArg, int arg, u8 nc, dxStep xStep, dxFinal xFinal) { - return new FuncDef(zName, SQLITE_UTF8, nArg, arg, (u8)(nc * SQLITE_FUNC_NEEDCOLL), xStep, xFinal); - } + //#define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \ + // {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \ + //pArg, 0, xFunc, 0, 0, #zName, 0, 0} - /* - ** All current savepoints are stored in a linked list starting at - ** sqlite3.pSavepoint. The first element in the list is the most recently - ** opened savepoint. Savepoints are added to the list by the vdbe - ** OP_Savepoint instruction. - */ - //struct Savepoint { - // string zName; /* Savepoint name (nul-terminated) */ - // i64 nDeferredCons; /* Number of deferred fk violations */ - // Savepoint *pNext; /* Parent savepoint (if any) */ - //}; - public class Savepoint { - public string zName; /* Savepoint name (nul-terminated) */ - public i64 nDeferredCons; /* Number of deferred fk violations */ - public Savepoint pNext; /* Parent savepoint (if any) */ - }; - /* - ** The following are used as the second parameter to sqlite3Savepoint(), - ** and as the P1 argument to the OP_Savepoint instruction. - */ - const int SAVEPOINT_BEGIN = 0; //#define SAVEPOINT_BEGIN 0 - const int SAVEPOINT_RELEASE = 1; //#define SAVEPOINT_RELEASE 1 - const int SAVEPOINT_ROLLBACK = 2; //#define SAVEPOINT_ROLLBACK 2 - - /* - ** Each SQLite module (virtual table definition) is defined by an - ** instance of the following structure, stored in the sqlite3.aModule - ** hash table. - */ - public class Module { - public sqlite3_module pModule; /* Callback pointers */ - public string zName; /* Name passed to create_module() */ - public object pAux; /* pAux passed to create_module() */ - public smdxDestroy xDestroy;//)(void );/* Module destructor function */ - }; - - /* - ** information about each column of an SQL table is held in an instance - ** of this structure. - */ - public class Column { - public string zName; /* Name of this column */ - public Expr pDflt; /* Default value of this column */ - public string zDflt; /* Original text of the default value */ - public string zType; /* Data type for this column */ - public string zColl; /* Collating sequence. If NULL, use the default */ - public u8 notNull; /* True if there is a NOT NULL constraint */ - public u8 isPrimKey; /* True if this column is part of the PRIMARY KEY */ - public char affinity; /* One of the SQLITE_AFF_... values */ + //#define LIKEFUNC(zName, nArg, arg, flags) \ + // {nArg, SQLITE_UTF8, flags, (void )arg, 0, likeFunc, 0, 0, #zName, 0, 0} + static FuncDef LIKEFUNC( string zName, i16 nArg, object arg, u8 flags ) + { + return new FuncDef( zName, SQLITE_UTF8, nArg, arg, likeFunc, flags ); + } + + //#define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \ + // {nArg, SQLITE_UTF8, nc*SQLITE_FUNC_NEEDCOLL, \ + //SQLITE_INT_TO_PTR(arg), 0, 0, xStep,xFinal,#zName,0,0} + + static FuncDef AGGREGATE( string zName, i16 nArg, int arg, u8 nc, dxStep xStep, dxFinal xFinal ) + { + return new FuncDef( zName, SQLITE_UTF8, nArg, arg, (u8)( nc * SQLITE_FUNC_NEEDCOLL ), xStep, xFinal ); + } + + /* + ** All current savepoints are stored in a linked list starting at + ** sqlite3.pSavepoint. The first element in the list is the most recently + ** opened savepoint. Savepoints are added to the list by the vdbe + ** OP_Savepoint instruction. + */ + //struct Savepoint { + // string zName; /* Savepoint name (nul-terminated) */ + // i64 nDeferredCons; /* Number of deferred fk violations */ + // Savepoint *pNext; /* Parent savepoint (if any) */ + //}; + public class Savepoint + { + public string zName; /* Savepoint name (nul-terminated) */ + public i64 nDeferredCons; /* Number of deferred fk violations */ + public Savepoint pNext; /* Parent savepoint (if any) */ + }; + /* + ** The following are used as the second parameter to sqlite3Savepoint(), + ** and as the P1 argument to the OP_Savepoint instruction. + */ + const int SAVEPOINT_BEGIN = 0; //#define SAVEPOINT_BEGIN 0 + const int SAVEPOINT_RELEASE = 1; //#define SAVEPOINT_RELEASE 1 + const int SAVEPOINT_ROLLBACK = 2; //#define SAVEPOINT_ROLLBACK 2 + + /* + ** Each SQLite module (virtual table definition) is defined by an + ** instance of the following structure, stored in the sqlite3.aModule + ** hash table. + */ + public class Module + { + public sqlite3_module pModule; /* Callback pointers */ + public string zName; /* Name passed to create_module() */ + public object pAux; /* pAux passed to create_module() */ + public smdxDestroy xDestroy;//)(void );/* Module destructor function */ + }; + + /* + ** information about each column of an SQL table is held in an instance + ** of this structure. + */ + public class Column + { + public string zName; /* Name of this column */ + public Expr pDflt; /* Default value of this column */ + public string zDflt; /* Original text of the default value */ + public string zType; /* Data type for this column */ + public string zColl; /* Collating sequence. If NULL, use the default */ + public u8 notNull; /* True if there is a NOT NULL constraint */ + public u8 isPrimKey; /* True if this column is part of the PRIMARY KEY */ + public char affinity; /* One of the SQLITE_AFF_... values */ #if !SQLITE_OMIT_VIRTUALTABLE - public u8 isHidden; /* True if this column is 'hidden' */ +public u8 isHidden; /* True if this column is 'hidden' */ #endif - public Column Copy() { - Column cp = (Column)MemberwiseClone(); - if (cp.pDflt != null) - cp.pDflt = pDflt.Copy(); - return cp; - } - }; - - /* - ** A "Collating Sequence" is defined by an instance of the following - ** structure. Conceptually, a collating sequence consists of a name and - ** a comparison routine that defines the order of that sequence. - ** - ** There may two separate implementations of the collation function, one - ** that processes text in UTF-8 encoding (CollSeq.xCmp) and another that - ** processes text encoded in UTF-16 (CollSeq.xCmp16), using the machine - ** native byte order. When a collation sequence is invoked, SQLite selects - ** the version that will require the least expensive encoding - ** translations, if any. - ** - ** The CollSeq.pUser member variable is an extra parameter that passed in - ** as the first argument to the UTF-8 comparison function, xCmp. - ** CollSeq.pUser16 is the equivalent for the UTF-16 comparison function, - ** xCmp16. - ** - ** If both CollSeq.xCmp and CollSeq.xCmp16 are NULL, it means that the - ** collating sequence is undefined. Indices built on an undefined - ** collating sequence may not be read or written. - */ - public class CollSeq { - public string zName; /* Name of the collating sequence, UTF-8 encoded */ - public u8 enc; /* Text encoding handled by xCmp() */ - public u8 type; /* One of the SQLITE_COLL_... values below */ - public object pUser; /* First argument to xCmp() */ - public dxCompare xCmp;//)(void*,int, const void*, int, const void); - public dxDelCollSeq xDel;//)(void); /* Destructor for pUser */ - - public CollSeq Copy() { - if (this == null) - return null; - else { - CollSeq cp = (CollSeq)MemberwiseClone(); - return cp; - } - } - }; - - /* - ** Allowed values of CollSeq.type: - */ - const int SQLITE_COLL_BINARY = 1;//#define SQLITE_COLL_BINARY 1 /* The default memcmp() collating sequence */ - const int SQLITE_COLL_NOCASE = 2;//#define SQLITE_COLL_NOCASE 2 /* The built-in NOCASE collating sequence */ - const int SQLITE_COLL_REVERSE = 3;//#define SQLITE_COLL_REVERSE 3 /* The built-in REVERSE collating sequence */ - const int SQLITE_COLL_USER = 0;//#define SQLITE_COLL_USER 0 /* Any other user-defined collating sequence */ - - /* - ** A sort order can be either ASC or DESC. - */ - const int SQLITE_SO_ASC = 0;//#define SQLITE_SO_ASC 0 /* Sort in ascending order */ - const int SQLITE_SO_DESC = 1;//#define SQLITE_SO_DESC 1 /* Sort in ascending order */ - - /* - ** Column affinity types. - ** - ** These used to have mnemonic name like 'i' for SQLITE_AFF_INTEGER and - ** 't' for SQLITE_AFF_TEXT. But we can save a little space and improve - ** the speed a little by numbering the values consecutively. - ** - ** But rather than start with 0 or 1, we begin with 'a'. That way, - ** when multiple affinity types are concatenated into a string and - ** used as the P4 operand, they will be more readable. - ** - ** Note also that the numeric types are grouped together so that testing - ** for a numeric type is a single comparison. - */ - const char SQLITE_AFF_TEXT = 'a';//#define SQLITE_AFF_TEXT 'a' - const char SQLITE_AFF_NONE = 'b';//#define SQLITE_AFF_NONE 'b' - const char SQLITE_AFF_NUMERIC = 'c';//#define SQLITE_AFF_NUMERIC 'c' - const char SQLITE_AFF_INTEGER = 'd';//#define SQLITE_AFF_INTEGER 'd' - const char SQLITE_AFF_REAL = 'e';//#define SQLITE_AFF_REAL 'e' - - //#define sqlite3IsNumericAffinity(X) ((X)>=SQLITE_AFF_NUMERIC) - - /* - ** The SQLITE_AFF_MASK values masks off the significant bits of an - ** affinity value. - */ - const int SQLITE_AFF_MASK = 0x67;//#define SQLITE_AFF_MASK 0x67 - - /* - ** Additional bit values that can be ORed with an affinity without - ** changing the affinity. - */ - const int SQLITE_JUMPIFNULL = 0x08; //#define SQLITE_JUMPIFNULL 0x08 /* jumps if either operand is NULL */ - const int SQLITE_STOREP2 = 0x10; //#define SQLITE_STOREP2 0x10 /* Store result in reg[P2] rather than jump */ - const int SQLITE_NULLEQ = 0x80; //#define SQLITE_NULLEQ 0x80 /* NULL=NULL */ - - /* - ** An object of this type is created for each virtual table present in - ** the database schema. - ** - ** If the database schema is shared, then there is one instance of this - ** structure for each database connection (sqlite3) that uses the shared - ** schema. This is because each database connection requires its own unique - ** instance of the sqlite3_vtab* handle used to access the virtual table - ** implementation. sqlite3_vtab* handles can not be shared between - ** database connections, even when the rest of the in-memory database - ** schema is shared, as the implementation often stores the database - ** connection handle passed to it via the xConnect() or xCreate() method - ** during initialization internally. This database connection handle may - ** then be used by the virtual table implementation to access real tables - ** within the database. So that they appear as part of the callers - ** transaction, these accesses need to be made via the same database - ** connection as that used to execute SQL operations on the virtual table. - ** - ** All VTable objects that correspond to a single table in a shared - ** database schema are initially stored in a linked-list pointed to by - ** the Table.pVTable member variable of the corresponding Table object. - ** When an sqlite3_prepare() operation is required to access the virtual - ** table, it searches the list for the VTable that corresponds to the - ** database connection doing the preparing so as to use the correct - ** sqlite3_vtab* handle in the compiled query. - ** - ** When an in-memory Table object is deleted (for example when the - ** schema is being reloaded for some reason), the VTable objects are not - ** deleted and the sqlite3_vtab* handles are not xDisconnect()ed - ** immediately. Instead, they are moved from the Table.pVTable list to - ** another linked list headed by the sqlite3.pDisconnect member of the - ** corresponding sqlite3 structure. They are then deleted/xDisconnected - ** next time a statement is prepared using said sqlite3*. This is done - ** to avoid deadlock issues involving multiple sqlite3.mutex mutexes. - ** Refer to comments above function sqlite3VtabUnlockList() for an - ** explanation as to why it is safe to add an entry to an sqlite3.pDisconnect - ** list without holding the corresponding sqlite3.mutex mutex. - ** - ** The memory for objects of this type is always allocated by - ** sqlite3DbMalloc(), using the connection handle stored in VTable.db as - ** the first argument. - */ - public class VTable { - public sqlite3 db; /* Database connection associated with this table */ - public Module pMod; /* Pointer to module implementation */ - public sqlite3_vtab pVtab; /* Pointer to vtab instance */ - public int nRef; /* Number of pointers to this structure */ - public u8 bConstraint; /* True if constraints are supported */ - public int iSavepoint; /* Depth of the SAVEPOINT stack */ - public VTable pNext; /* Next in linked list (see above) */ - }; - - /* - ** Each SQL table is represented in memory by an instance of the - ** following structure. - ** - ** Table.zName is the name of the table. The case of the original - ** CREATE TABLE statement is stored, but case is not significant for - ** comparisons. - ** - ** Table.nCol is the number of columns in this table. Table.aCol is a - ** pointer to an array of Column structures, one for each column. - ** - ** If the table has an INTEGER PRIMARY KEY, then Table.iPKey is the index of - ** the column that is that key. Otherwise Table.iPKey is negative. Note - ** that the datatype of the PRIMARY KEY must be INTEGER for this field to - ** be set. An INTEGER PRIMARY KEY is used as the rowid for each row of - ** the table. If a table has no INTEGER PRIMARY KEY, then a random rowid - ** is generated for each row of the table. TF_HasPrimaryKey is set if - ** the table has any PRIMARY KEY, INTEGER or otherwise. - ** - ** Table.tnum is the page number for the root BTree page of the table in the - ** database file. If Table.iDb is the index of the database table backend - ** in sqlite.aDb[]. 0 is for the main database and 1 is for the file that - ** holds temporary tables and indices. If TF_Ephemeral is set - ** then the table is stored in a file that is automatically deleted - ** when the VDBE cursor to the table is closed. In this case Table.tnum - ** refers VDBE cursor number that holds the table open, not to the root - ** page number. Transient tables are used to hold the results of a - ** sub-query that appears instead of a real table name in the FROM clause - ** of a SELECT statement. - */ - public class Table { - public string zName; /* Name of the table or view */ - public int iPKey; /* If not negative, use aCol[iPKey] as the primary key */ - public int nCol; /* Number of columns in this table */ - public Column[] aCol; /* Information about each column */ - public Index pIndex; /* List of SQL indexes on this table. */ - public int tnum; /* Root BTree node for this table (see note above) */ - public u32 nRowEst; /* Estimated rows in table - from sqlite_stat1 table */ - public Select pSelect; /* NULL for tables. Points to definition if a view. */ - public u16 nRef; /* Number of pointers to this Table */ - public u8 tabFlags; /* Mask of TF_* values */ - public u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */ - public FKey pFKey; /* Linked list of all foreign keys in this table */ - public string zColAff; /* String defining the affinity of each column */ + public Column Copy() + { + Column cp = (Column)MemberwiseClone(); + if ( cp.pDflt != null ) + cp.pDflt = pDflt.Copy(); + return cp; + } + }; + + /* + ** A "Collating Sequence" is defined by an instance of the following + ** structure. Conceptually, a collating sequence consists of a name and + ** a comparison routine that defines the order of that sequence. + ** + ** There may two separate implementations of the collation function, one + ** that processes text in UTF-8 encoding (CollSeq.xCmp) and another that + ** processes text encoded in UTF-16 (CollSeq.xCmp16), using the machine + ** native byte order. When a collation sequence is invoked, SQLite selects + ** the version that will require the least expensive encoding + ** translations, if any. + ** + ** The CollSeq.pUser member variable is an extra parameter that passed in + ** as the first argument to the UTF-8 comparison function, xCmp. + ** CollSeq.pUser16 is the equivalent for the UTF-16 comparison function, + ** xCmp16. + ** + ** If both CollSeq.xCmp and CollSeq.xCmp16 are NULL, it means that the + ** collating sequence is undefined. Indices built on an undefined + ** collating sequence may not be read or written. + */ + public class CollSeq + { + public string zName; /* Name of the collating sequence, UTF-8 encoded */ + public u8 enc; /* Text encoding handled by xCmp() */ + public u8 type; /* One of the SQLITE_COLL_... values below */ + public object pUser; /* First argument to xCmp() */ + public dxCompare xCmp;//)(void*,int, const void*, int, const void); + public dxDelCollSeq xDel;//)(void); /* Destructor for pUser */ + + public CollSeq Copy() + { + if ( this == null ) + return null; + else + { + CollSeq cp = (CollSeq)MemberwiseClone(); + return cp; + } + } + }; + + /* + ** Allowed values of CollSeq.type: + */ + const int SQLITE_COLL_BINARY = 1;//#define SQLITE_COLL_BINARY 1 /* The default memcmp() collating sequence */ + const int SQLITE_COLL_NOCASE = 2;//#define SQLITE_COLL_NOCASE 2 /* The built-in NOCASE collating sequence */ + const int SQLITE_COLL_REVERSE = 3;//#define SQLITE_COLL_REVERSE 3 /* The built-in REVERSE collating sequence */ + const int SQLITE_COLL_USER = 0;//#define SQLITE_COLL_USER 0 /* Any other user-defined collating sequence */ + + /* + ** A sort order can be either ASC or DESC. + */ + const int SQLITE_SO_ASC = 0;//#define SQLITE_SO_ASC 0 /* Sort in ascending order */ + const int SQLITE_SO_DESC = 1;//#define SQLITE_SO_DESC 1 /* Sort in ascending order */ + + /* + ** Column affinity types. + ** + ** These used to have mnemonic name like 'i' for SQLITE_AFF_INTEGER and + ** 't' for SQLITE_AFF_TEXT. But we can save a little space and improve + ** the speed a little by numbering the values consecutively. + ** + ** But rather than start with 0 or 1, we begin with 'a'. That way, + ** when multiple affinity types are concatenated into a string and + ** used as the P4 operand, they will be more readable. + ** + ** Note also that the numeric types are grouped together so that testing + ** for a numeric type is a single comparison. + */ + const char SQLITE_AFF_TEXT = 'a';//#define SQLITE_AFF_TEXT 'a' + const char SQLITE_AFF_NONE = 'b';//#define SQLITE_AFF_NONE 'b' + const char SQLITE_AFF_NUMERIC = 'c';//#define SQLITE_AFF_NUMERIC 'c' + const char SQLITE_AFF_INTEGER = 'd';//#define SQLITE_AFF_INTEGER 'd' + const char SQLITE_AFF_REAL = 'e';//#define SQLITE_AFF_REAL 'e' + + //#define sqlite3IsNumericAffinity(X) ((X)>=SQLITE_AFF_NUMERIC) + + /* + ** The SQLITE_AFF_MASK values masks off the significant bits of an + ** affinity value. + */ + const int SQLITE_AFF_MASK = 0x67;//#define SQLITE_AFF_MASK 0x67 + + /* + ** Additional bit values that can be ORed with an affinity without + ** changing the affinity. + */ + const int SQLITE_JUMPIFNULL = 0x08; //#define SQLITE_JUMPIFNULL 0x08 /* jumps if either operand is NULL */ + const int SQLITE_STOREP2 = 0x10; //#define SQLITE_STOREP2 0x10 /* Store result in reg[P2] rather than jump */ + const int SQLITE_NULLEQ = 0x80; //#define SQLITE_NULLEQ 0x80 /* NULL=NULL */ + + /* + ** An object of this type is created for each virtual table present in + ** the database schema. + ** + ** If the database schema is shared, then there is one instance of this + ** structure for each database connection (sqlite3) that uses the shared + ** schema. This is because each database connection requires its own unique + ** instance of the sqlite3_vtab* handle used to access the virtual table + ** implementation. sqlite3_vtab* handles can not be shared between + ** database connections, even when the rest of the in-memory database + ** schema is shared, as the implementation often stores the database + ** connection handle passed to it via the xConnect() or xCreate() method + ** during initialization internally. This database connection handle may + ** then be used by the virtual table implementation to access real tables + ** within the database. So that they appear as part of the callers + ** transaction, these accesses need to be made via the same database + ** connection as that used to execute SQL operations on the virtual table. + ** + ** All VTable objects that correspond to a single table in a shared + ** database schema are initially stored in a linked-list pointed to by + ** the Table.pVTable member variable of the corresponding Table object. + ** When an sqlite3_prepare() operation is required to access the virtual + ** table, it searches the list for the VTable that corresponds to the + ** database connection doing the preparing so as to use the correct + ** sqlite3_vtab* handle in the compiled query. + ** + ** When an in-memory Table object is deleted (for example when the + ** schema is being reloaded for some reason), the VTable objects are not + ** deleted and the sqlite3_vtab* handles are not xDisconnect()ed + ** immediately. Instead, they are moved from the Table.pVTable list to + ** another linked list headed by the sqlite3.pDisconnect member of the + ** corresponding sqlite3 structure. They are then deleted/xDisconnected + ** next time a statement is prepared using said sqlite3*. This is done + ** to avoid deadlock issues involving multiple sqlite3.mutex mutexes. + ** Refer to comments above function sqlite3VtabUnlockList() for an + ** explanation as to why it is safe to add an entry to an sqlite3.pDisconnect + ** list without holding the corresponding sqlite3.mutex mutex. + ** + ** The memory for objects of this type is always allocated by + ** sqlite3DbMalloc(), using the connection handle stored in VTable.db as + ** the first argument. + */ + public class VTable + { + public sqlite3 db; /* Database connection associated with this table */ + public Module pMod; /* Pointer to module implementation */ + public sqlite3_vtab pVtab; /* Pointer to vtab instance */ + public int nRef; /* Number of pointers to this structure */ + public u8 bConstraint; /* True if constraints are supported */ + public int iSavepoint; /* Depth of the SAVEPOINT stack */ + public VTable pNext; /* Next in linked list (see above) */ + }; + + /* + ** Each SQL table is represented in memory by an instance of the + ** following structure. + ** + ** Table.zName is the name of the table. The case of the original + ** CREATE TABLE statement is stored, but case is not significant for + ** comparisons. + ** + ** Table.nCol is the number of columns in this table. Table.aCol is a + ** pointer to an array of Column structures, one for each column. + ** + ** If the table has an INTEGER PRIMARY KEY, then Table.iPKey is the index of + ** the column that is that key. Otherwise Table.iPKey is negative. Note + ** that the datatype of the PRIMARY KEY must be INTEGER for this field to + ** be set. An INTEGER PRIMARY KEY is used as the rowid for each row of + ** the table. If a table has no INTEGER PRIMARY KEY, then a random rowid + ** is generated for each row of the table. TF_HasPrimaryKey is set if + ** the table has any PRIMARY KEY, INTEGER or otherwise. + ** + ** Table.tnum is the page number for the root BTree page of the table in the + ** database file. If Table.iDb is the index of the database table backend + ** in sqlite.aDb[]. 0 is for the main database and 1 is for the file that + ** holds temporary tables and indices. If TF_Ephemeral is set + ** then the table is stored in a file that is automatically deleted + ** when the VDBE cursor to the table is closed. In this case Table.tnum + ** refers VDBE cursor number that holds the table open, not to the root + ** page number. Transient tables are used to hold the results of a + ** sub-query that appears instead of a real table name in the FROM clause + ** of a SELECT statement. + */ + public class Table + { + public string zName; /* Name of the table or view */ + public int iPKey; /* If not negative, use aCol[iPKey] as the primary key */ + public int nCol; /* Number of columns in this table */ + public Column[] aCol; /* Information about each column */ + public Index pIndex; /* List of SQL indexes on this table. */ + public int tnum; /* Root BTree node for this table (see note above) */ + public u32 nRowEst; /* Estimated rows in table - from sqlite_stat1 table */ + public Select pSelect; /* NULL for tables. Points to definition if a view. */ + public u16 nRef; /* Number of pointers to this Table */ + public u8 tabFlags; /* Mask of TF_* values */ + public u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */ + public FKey pFKey; /* Linked list of all foreign keys in this table */ + public string zColAff; /* String defining the affinity of each column */ #if !SQLITE_OMIT_CHECK - public Expr pCheck; /* The AND of all CHECK constraints */ + public Expr pCheck; /* The AND of all CHECK constraints */ #endif #if !SQLITE_OMIT_ALTERTABLE - public int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */ + public int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */ #endif #if !SQLITE_OMIT_VIRTUALTABLE - public VTable pVTable; /* List of VTable objects. */ - public int nModuleArg; /* Number of arguments to the module */ - public string[] azModuleArg;/* Text of all module args. [0] is module name */ + public VTable pVTable; /* List of VTable objects. */ + public int nModuleArg; /* Number of arguments to the module */ + public string[] azModuleArg;/* Text of all module args. [0] is module name */ #endif - public Trigger pTrigger; /* List of SQL triggers on this table */ - public Schema pSchema; /* Schema that contains this table */ - public Table pNextZombie; /* Next on the Parse.pZombieTab list */ - - public Table Copy() { - if (this == null) - return null; - else { - Table cp = (Table)MemberwiseClone(); - if (pIndex != null) - cp.pIndex = pIndex.Copy(); - if (pSelect != null) - cp.pSelect = pSelect.Copy(); - if (pTrigger != null) - cp.pTrigger = pTrigger.Copy(); - if (pFKey != null) - cp.pFKey = pFKey.Copy(); + public Trigger pTrigger; /* List of SQL triggers on this table */ + public Schema pSchema; /* Schema that contains this table */ + public Table pNextZombie; /* Next on the Parse.pZombieTab list */ + + public Table Copy() + { + if ( this == null ) + return null; + else + { + Table cp = (Table)MemberwiseClone(); + if ( pIndex != null ) + cp.pIndex = pIndex.Copy(); + if ( pSelect != null ) + cp.pSelect = pSelect.Copy(); + if ( pTrigger != null ) + cp.pTrigger = pTrigger.Copy(); + if ( pFKey != null ) + cp.pFKey = pFKey.Copy(); #if !SQLITE_OMIT_CHECK - // Don't Clone Checks, only copy reference via Memberwise Clone above -- - //if ( pCheck != null ) cp.pCheck = pCheck.Copy(); + // Don't Clone Checks, only copy reference via Memberwise Clone above -- + //if ( pCheck != null ) cp.pCheck = pCheck.Copy(); #endif - // Don't Clone Schema, only copy reference via Memberwise Clone above -- - // if ( pSchema != null ) cp.pSchema=pSchema.Copy(); - // Don't Clone pNextZombie, only copy reference via Memberwise Clone above -- - // if ( pNextZombie != null ) cp.pNextZombie=pNextZombie.Copy(); - return cp; - } - } - }; - - /* - ** Allowed values for Tabe.tabFlags. - */ - //#define TF_Readonly 0x01 /* Read-only system table */ - //#define TF_Ephemeral 0x02 /* An ephemeral table */ - //#define TF_HasPrimaryKey 0x04 /* Table has a primary key */ - //#define TF_Autoincrement 0x08 /* Integer primary key is autoincrement */ - //#define TF_Virtual 0x10 /* Is a virtual table */ - //#define TF_NeedMetadata 0x20 /* aCol[].zType and aCol[].pColl missing */ - /* - ** Allowed values for Tabe.tabFlags. - */ - const int TF_Readonly = 0x01; /* Read-only system table */ - const int TF_Ephemeral = 0x02; /* An ephemeral table */ - const int TF_HasPrimaryKey = 0x04; /* Table has a primary key */ - const int TF_Autoincrement = 0x08; /* Integer primary key is autoincrement */ - const int TF_Virtual = 0x10; /* Is a virtual table */ - const int TF_NeedMetadata = 0x20; /* aCol[].zType and aCol[].pColl missing */ - - /* - ** Test to see whether or not a table is a virtual table. This is - ** done as a macro so that it will be optimized out when virtual - ** table support is omitted from the build. - */ -#if !SQLITE_OMIT_VIRTUALTABLE - //# define IsVirtual(X) (((X)->tabFlags & TF_Virtual)!=0) - static bool IsVirtual(Table X) { - return (X.tabFlags & TF_Virtual) != 0; - } - //# define IsHiddenColumn(X) ((X)->isHidden) - static bool IsHiddenColumn(Column X) { - return X.isHidden != 0; + // Don't Clone Schema, only copy reference via Memberwise Clone above -- + // if ( pSchema != null ) cp.pSchema=pSchema.Copy(); + // Don't Clone pNextZombie, only copy reference via Memberwise Clone above -- + // if ( pNextZombie != null ) cp.pNextZombie=pNextZombie.Copy(); + return cp; } + } + }; + + /* + ** Allowed values for Tabe.tabFlags. + */ + //#define TF_Readonly 0x01 /* Read-only system table */ + //#define TF_Ephemeral 0x02 /* An ephemeral table */ + //#define TF_HasPrimaryKey 0x04 /* Table has a primary key */ + //#define TF_Autoincrement 0x08 /* Integer primary key is autoincrement */ + //#define TF_Virtual 0x10 /* Is a virtual table */ + //#define TF_NeedMetadata 0x20 /* aCol[].zType and aCol[].pColl missing */ + /* + ** Allowed values for Tabe.tabFlags. + */ + const int TF_Readonly = 0x01; /* Read-only system table */ + const int TF_Ephemeral = 0x02; /* An ephemeral table */ + const int TF_HasPrimaryKey = 0x04; /* Table has a primary key */ + const int TF_Autoincrement = 0x08; /* Integer primary key is autoincrement */ + const int TF_Virtual = 0x10; /* Is a virtual table */ + const int TF_NeedMetadata = 0x20; /* aCol[].zType and aCol[].pColl missing */ + + /* + ** Test to see whether or not a table is a virtual table. This is + ** done as a macro so that it will be optimized out when virtual + ** table support is omitted from the build. + */ +#if !SQLITE_OMIT_VIRTUALTABLE +//# define IsVirtual(X) (((X)->tabFlags & TF_Virtual)!=0) + static bool IsVirtual( Table X ) + { + return ( X.tabFlags & TF_Virtual ) != 0; + } + //# define IsHiddenColumn(X) ((X)->isHidden) +static bool IsHiddenColumn( Column X ) +{ + return X.isHidden != 0; +} #else //# define IsVirtual(X) 0 static bool IsVirtual( Table T ) @@ -1681,224 +1744,237 @@ static bool IsHiddenColumn( Column C ) } #endif - /* - ** Each foreign key constraint is an instance of the following structure. + /* +** Each foreign key constraint is an instance of the following structure. +** +** A foreign key is associated with two tables. The "from" table is +** the table that contains the REFERENCES clause that creates the foreign +** key. The "to" table is the table that is named in the REFERENCES clause. +** Consider this example: +** +** CREATE TABLE ex1( +** a INTEGER PRIMARY KEY, +** b INTEGER CONSTRAINT fk1 REFERENCES ex2(x) +** ); +** +** For foreign key "fk1", the from-table is "ex1" and the to-table is "ex2". +** +** Each REFERENCES clause generates an instance of the following structure +** which is attached to the from-table. The to-table need not exist when +** the from-table is created. The existence of the to-table is not checked. +*/ + public class FKey + { + public Table pFrom; /* Table containing the REFERENCES clause (aka: Child) */ + public FKey pNextFrom; /* Next foreign key in pFrom */ + public string zTo; /* Name of table that the key points to (aka: Parent) */ + public FKey pNextTo; /* Next foreign key on table named zTo */ + public FKey pPrevTo; /* Previous foreign key on table named zTo */ + public int nCol; /* Number of columns in this key */ + /* EV: R-30323-21917 */ + public u8 isDeferred; /* True if constraint checking is deferred till COMMIT */ + public u8[] aAction = new u8[2]; /* ON DELETE and ON UPDATE actions, respectively */ + public Trigger[] apTrigger = new Trigger[2];/* Triggers for aAction[] actions */ + + public class sColMap + { /* Mapping of columns in pFrom to columns in zTo */ + public int iFrom; /* Index of column in pFrom */ + public string zCol; /* Name of column in zTo. If 0 use PRIMARY KEY */ + }; + public sColMap[] aCol; /* One entry for each of nCol column s */ + + public FKey Copy() + { + if ( this == null ) + return null; + else + { + FKey cp = (FKey)MemberwiseClone(); + return cp; + } + } + + }; + + /* + ** SQLite supports many different ways to resolve a constraint + ** error. ROLLBACK processing means that a constraint violation + ** causes the operation in process to fail and for the current transaction + ** to be rolled back. ABORT processing means the operation in process + ** fails and any prior changes from that one operation are backed out, + ** but the transaction is not rolled back. FAIL processing means that + ** the operation in progress stops and returns an error code. But prior + ** changes due to the same operation are not backed out and no rollback + ** occurs. IGNORE means that the particular row that caused the constraint + ** error is not inserted or updated. Processing continues and no error + ** is returned. REPLACE means that preexisting database rows that caused + ** a UNIQUE constraint violation are removed so that the new insert or + ** update can proceed. Processing continues and no error is reported. ** - ** A foreign key is associated with two tables. The "from" table is - ** the table that contains the REFERENCES clause that creates the foreign - ** key. The "to" table is the table that is named in the REFERENCES clause. - ** Consider this example: + ** RESTRICT, SETNULL, and CASCADE actions apply only to foreign keys. + ** RESTRICT is the same as ABORT for IMMEDIATE foreign keys and the + ** same as ROLLBACK for DEFERRED keys. SETNULL means that the foreign + ** key is set to NULL. CASCADE means that a DELETE or UPDATE of the + ** referenced table row is propagated into the row that holds the + ** foreign key. ** - ** CREATE TABLE ex1( - ** a INTEGER PRIMARY KEY, - ** b INTEGER CONSTRAINT fk1 REFERENCES ex2(x) - ** ); + ** The following symbolic values are used to record which type + ** of action to take. + */ + const int OE_None = 0;//#define OE_None 0 /* There is no constraint to check */ + const int OE_Rollback = 1;//#define OE_Rollback 1 /* Fail the operation and rollback the transaction */ + const int OE_Abort = 2;//#define OE_Abort 2 /* Back out changes but do no rollback transaction */ + const int OE_Fail = 3;//#define OE_Fail 3 /* Stop the operation but leave all prior changes */ + const int OE_Ignore = 4;//#define OE_Ignore 4 /* Ignore the error. Do not do the INSERT or UPDATE */ + const int OE_Replace = 5;//#define OE_Replace 5 /* Delete existing record, then do INSERT or UPDATE */ + + const int OE_Restrict = 6;//#define OE_Restrict 6 /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */ + const int OE_SetNull = 7;//#define OE_SetNull 7 /* Set the foreign key value to NULL */ + const int OE_SetDflt = 8;//#define OE_SetDflt 8 /* Set the foreign key value to its default */ + const int OE_Cascade = 9;//#define OE_Cascade 9 /* Cascade the changes */ + + const int OE_Default = 99;//#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 + ** comparison of the two index keys. + */ + public class KeyInfo + { + public sqlite3 db; /* The database connection */ + public u8 enc; /* Text encoding - one of the SQLITE_UTF* values */ + public u16 nField; /* Number of entries in aColl[] */ + public u8[] aSortOrder; /* Sort order for each column. May be NULL */ + public CollSeq[] aColl = new CollSeq[1]; /* Collating sequence for each term of the key */ + public KeyInfo Copy() + { + return (KeyInfo)MemberwiseClone(); + } + }; + + /* + ** An instance of the following structure holds information about a + ** single index record that has already been parsed out into individual + ** values. ** - ** For foreign key "fk1", the from-table is "ex1" and the to-table is "ex2". + ** A record is an object that contains one or more fields of data. + ** Records are used to store the content of a table row and to store + ** the key of an index. A blob encoding of a record is created by + ** the OP_MakeRecord opcode of the VDBE and is disassembled by the + ** OP_Column opcode. ** - ** Each REFERENCES clause generates an instance of the following structure - ** which is attached to the from-table. The to-table need not exist when - ** the from-table is created. The existence of the to-table is not checked. + ** This structure holds a record that has already been disassembled + ** into its constituent fields. + */ + public class UnpackedRecord + { + public KeyInfo pKeyInfo; /* Collation and sort-order information */ + public u16 nField; /* Number of entries in apMem[] */ + public u16 flags; /* Boolean settings. UNPACKED_... below */ + public i64 rowid; /* Used by UNPACKED_PREFIX_SEARCH */ + public Mem[] aMem; /* Values */ + }; + + /* + ** Allowed values of UnpackedRecord.flags */ - public class FKey { - public Table pFrom; /* Table containing the REFERENCES clause (aka: Child) */ - public FKey pNextFrom; /* Next foreign key in pFrom */ - public string zTo; /* Name of table that the key points to (aka: Parent) */ - public FKey pNextTo; /* Next foreign key on table named zTo */ - public FKey pPrevTo; /* Previous foreign key on table named zTo */ - public int nCol; /* Number of columns in this key */ - /* EV: R-30323-21917 */ - public u8 isDeferred; /* True if constraint checking is deferred till COMMIT */ - public u8[] aAction = new u8[2]; /* ON DELETE and ON UPDATE actions, respectively */ - public Trigger[] apTrigger = new Trigger[2];/* Triggers for aAction[] actions */ - - public class sColMap { /* Mapping of columns in pFrom to columns in zTo */ - public int iFrom; /* Index of column in pFrom */ - public string zCol; /* Name of column in zTo. If 0 use PRIMARY KEY */ - }; - public sColMap[] aCol; /* One entry for each of nCol column s */ - - public FKey Copy() { - if (this == null) - return null; - else { - FKey cp = (FKey)MemberwiseClone(); - return cp; - } - } - - }; - - /* - ** SQLite supports many different ways to resolve a constraint - ** error. ROLLBACK processing means that a constraint violation - ** causes the operation in process to fail and for the current transaction - ** to be rolled back. ABORT processing means the operation in process - ** fails and any prior changes from that one operation are backed out, - ** but the transaction is not rolled back. FAIL processing means that - ** the operation in progress stops and returns an error code. But prior - ** changes due to the same operation are not backed out and no rollback - ** occurs. IGNORE means that the particular row that caused the constraint - ** error is not inserted or updated. Processing continues and no error - ** is returned. REPLACE means that preexisting database rows that caused - ** a UNIQUE constraint violation are removed so that the new insert or - ** update can proceed. Processing continues and no error is reported. - ** - ** RESTRICT, SETNULL, and CASCADE actions apply only to foreign keys. - ** RESTRICT is the same as ABORT for IMMEDIATE foreign keys and the - ** same as ROLLBACK for DEFERRED keys. SETNULL means that the foreign - ** key is set to NULL. CASCADE means that a DELETE or UPDATE of the - ** referenced table row is propagated into the row that holds the - ** foreign key. - ** - ** The following symbolic values are used to record which type - ** of action to take. - */ - const int OE_None = 0;//#define OE_None 0 /* There is no constraint to check */ - const int OE_Rollback = 1;//#define OE_Rollback 1 /* Fail the operation and rollback the transaction */ - const int OE_Abort = 2;//#define OE_Abort 2 /* Back out changes but do no rollback transaction */ - const int OE_Fail = 3;//#define OE_Fail 3 /* Stop the operation but leave all prior changes */ - const int OE_Ignore = 4;//#define OE_Ignore 4 /* Ignore the error. Do not do the INSERT or UPDATE */ - const int OE_Replace = 5;//#define OE_Replace 5 /* Delete existing record, then do INSERT or UPDATE */ - - const int OE_Restrict = 6;//#define OE_Restrict 6 /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */ - const int OE_SetNull = 7;//#define OE_SetNull 7 /* Set the foreign key value to NULL */ - const int OE_SetDflt = 8;//#define OE_SetDflt 8 /* Set the foreign key value to its default */ - const int OE_Cascade = 9;//#define OE_Cascade 9 /* Cascade the changes */ - - const int OE_Default = 99;//#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 - ** comparison of the two index keys. - */ - public class KeyInfo { - public sqlite3 db; /* The database connection */ - public u8 enc; /* Text encoding - one of the SQLITE_UTF* values */ - public u16 nField; /* Number of entries in aColl[] */ - public u8[] aSortOrder; /* Sort order for each column. May be NULL */ - public CollSeq[] aColl = new CollSeq[1]; /* Collating sequence for each term of the key */ - public KeyInfo Copy() { - return (KeyInfo)MemberwiseClone(); - } - }; - - /* - ** An instance of the following structure holds information about a - ** single index record that has already been parsed out into individual - ** values. - ** - ** A record is an object that contains one or more fields of data. - ** Records are used to store the content of a table row and to store - ** the key of an index. A blob encoding of a record is created by - ** the OP_MakeRecord opcode of the VDBE and is disassembled by the - ** OP_Column opcode. - ** - ** This structure holds a record that has already been disassembled - ** into its constituent fields. - */ - public class UnpackedRecord { - public KeyInfo pKeyInfo; /* Collation and sort-order information */ - public u16 nField; /* Number of entries in apMem[] */ - public u16 flags; /* Boolean settings. UNPACKED_... below */ - public i64 rowid; /* Used by UNPACKED_PREFIX_SEARCH */ - public Mem[] aMem; /* Values */ - }; - - /* - ** Allowed values of UnpackedRecord.flags - */ - //#define UNPACKED_NEED_FREE 0x0001 /* Memory is from sqlite3Malloc() */ - //#define UNPACKED_NEED_DESTROY 0x0002 /* apMem[]s should all be destroyed */ - //#define UNPACKED_IGNORE_ROWID 0x0004 /* Ignore trailing rowid on key1 */ - //#define UNPACKED_INCRKEY 0x0008 /* Make this key an epsilon larger */ - //#define UNPACKED_PREFIX_MATCH 0x0010 /* A prefix match is considered OK */ - //#define UNPACKED_PREFIX_SEARCH 0x0020 /* A prefix match is considered OK */ - const int UNPACKED_NEED_FREE = 0x0001; /* Memory is from sqlite3Malloc() */ - const int UNPACKED_NEED_DESTROY = 0x0002; /* apMem[]s should all be destroyed */ - const int UNPACKED_IGNORE_ROWID = 0x0004; /* Ignore trailing rowid on key1 */ - const int UNPACKED_INCRKEY = 0x0008; /* Make this key an epsilon larger */ - const int UNPACKED_PREFIX_MATCH = 0x0010; /* A prefix match is considered OK */ - const int UNPACKED_PREFIX_SEARCH = 0x0020; /* A prefix match is considered OK */ - - /* - ** Each SQL index is represented in memory by an - ** instance of the following structure. - ** - ** The columns of the table that are to be indexed are described - ** by the aiColumn[] field of this structure. For example, suppose - ** we have the following table and index: - ** - ** CREATE TABLE Ex1(c1 int, c2 int, c3 text); - ** CREATE INDEX Ex2 ON Ex1(c3,c1); - ** - ** In the Table structure describing Ex1, nCol==3 because there are - ** three columns in the table. In the Index structure describing - ** Ex2, nColumn==2 since 2 of the 3 columns of Ex1 are indexed. - ** The value of aiColumn is {2, 0}. aiColumn[0]==2 because the - ** first column to be indexed (c3) has an index of 2 in Ex1.aCol[]. - ** The second column to be indexed (c1) has an index of 0 in - ** Ex1.aCol[], hence Ex2.aiColumn[1]==0. - ** - ** The Index.onError field determines whether or not the indexed columns - ** must be unique and what to do if they are not. When Index.onError=OE_None, - ** it means this is not a unique index. Otherwise it is a unique index - ** and the value of Index.onError indicate the which conflict resolution - ** algorithm to employ whenever an attempt is made to insert a non-unique - ** element. - */ - public class Index { - public string zName; /* Name of this index */ - public int nColumn; /* Number of columns in the table used by this index */ - public int[] aiColumn; /* Which columns are used by this index. 1st is 0 */ - public int[] aiRowEst; /* Result of ANALYZE: Est. rows selected by each column */ - public Table pTable; /* The SQL table being indexed */ - public int tnum; /* Page containing root of this index in database file */ - public u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ - public u8 autoIndex; /* True if is automatically created (ex: by UNIQUE) */ - public u8 bUnordered; /* Use this index for == or IN queries only */ - public string zColAff; /* String defining the affinity of each column */ - public Index pNext; /* The next index associated with the same table */ - public Schema pSchema; /* Schema containing this index */ - public u8[] aSortOrder; /* Array of size Index.nColumn. True==DESC, False==ASC */ - public string[] azColl; /* Array of collation sequence names for index */ - public IndexSample[] aSample; /* Array of SQLITE_INDEX_SAMPLES samples */ - - public Index Copy() { - if (this == null) - return null; - else { - Index cp = (Index)MemberwiseClone(); - return cp; - } - } - }; - /* - ** Each sample stored in the sqlite_stat2 table is represented in memory - ** using a structure of this type. - */ - public class IndexSample { - public struct _u { //union { - public string z; /* Value if eType is SQLITE_TEXT */ - public byte[] zBLOB; /* Value if eType is SQLITE_BLOB */ - public double r; /* Value if eType is SQLITE_FLOAT or SQLITE_INTEGER */ - } - public _u u; - public u8 eType; /* SQLITE_NULL, SQLITE_INTEGER ... etc. */ - public u8 nByte; /* Size in byte of text or blob. */ - }; - - /* - ** Each token coming out of the lexer is an instance of - ** this structure. Tokens are also used as part of an expression. - ** - ** Note if Token.z==0 then Token.dyn and Token.n are undefined and - ** may contain random values. Do not make any assumptions about Token.dyn - ** and Token.n when Token.z==0. - */ - public class Token { + //#define UNPACKED_NEED_FREE 0x0001 /* Memory is from sqlite3Malloc() */ + //#define UNPACKED_NEED_DESTROY 0x0002 /* apMem[]s should all be destroyed */ + //#define UNPACKED_IGNORE_ROWID 0x0004 /* Ignore trailing rowid on key1 */ + //#define UNPACKED_INCRKEY 0x0008 /* Make this key an epsilon larger */ + //#define UNPACKED_PREFIX_MATCH 0x0010 /* A prefix match is considered OK */ + //#define UNPACKED_PREFIX_SEARCH 0x0020 /* A prefix match is considered OK */ + const int UNPACKED_NEED_FREE = 0x0001; /* Memory is from sqlite3Malloc() */ + const int UNPACKED_NEED_DESTROY = 0x0002; /* apMem[]s should all be destroyed */ + const int UNPACKED_IGNORE_ROWID = 0x0004; /* Ignore trailing rowid on key1 */ + const int UNPACKED_INCRKEY = 0x0008; /* Make this key an epsilon larger */ + const int UNPACKED_PREFIX_MATCH = 0x0010; /* A prefix match is considered OK */ + const int UNPACKED_PREFIX_SEARCH = 0x0020; /* A prefix match is considered OK */ + + /* + ** Each SQL index is represented in memory by an + ** instance of the following structure. + ** + ** The columns of the table that are to be indexed are described + ** by the aiColumn[] field of this structure. For example, suppose + ** we have the following table and index: + ** + ** CREATE TABLE Ex1(c1 int, c2 int, c3 text); + ** CREATE INDEX Ex2 ON Ex1(c3,c1); + ** + ** In the Table structure describing Ex1, nCol==3 because there are + ** three columns in the table. In the Index structure describing + ** Ex2, nColumn==2 since 2 of the 3 columns of Ex1 are indexed. + ** The value of aiColumn is {2, 0}. aiColumn[0]==2 because the + ** first column to be indexed (c3) has an index of 2 in Ex1.aCol[]. + ** The second column to be indexed (c1) has an index of 0 in + ** Ex1.aCol[], hence Ex2.aiColumn[1]==0. + ** + ** The Index.onError field determines whether or not the indexed columns + ** must be unique and what to do if they are not. When Index.onError=OE_None, + ** it means this is not a unique index. Otherwise it is a unique index + ** and the value of Index.onError indicate the which conflict resolution + ** algorithm to employ whenever an attempt is made to insert a non-unique + ** element. + */ + public class Index + { + public string zName; /* Name of this index */ + public int nColumn; /* Number of columns in the table used by this index */ + public int[] aiColumn; /* Which columns are used by this index. 1st is 0 */ + public int[] aiRowEst; /* Result of ANALYZE: Est. rows selected by each column */ + public Table pTable; /* The SQL table being indexed */ + public int tnum; /* Page containing root of this index in database file */ + public u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ + public u8 autoIndex; /* True if is automatically created (ex: by UNIQUE) */ + public u8 bUnordered; /* Use this index for == or IN queries only */ + public string zColAff; /* String defining the affinity of each column */ + public Index pNext; /* The next index associated with the same table */ + public Schema pSchema; /* Schema containing this index */ + public u8[] aSortOrder; /* Array of size Index.nColumn. True==DESC, False==ASC */ + public string[] azColl; /* Array of collation sequence names for index */ + public IndexSample[] aSample; /* Array of SQLITE_INDEX_SAMPLES samples */ + + public Index Copy() + { + if ( this == null ) + return null; + else + { + Index cp = (Index)MemberwiseClone(); + return cp; + } + } + }; + /* + ** Each sample stored in the sqlite_stat2 table is represented in memory + ** using a structure of this type. + */ + public class IndexSample + { + public struct _u + { //union { + public string z; /* Value if eType is SQLITE_TEXT */ + public byte[] zBLOB; /* Value if eType is SQLITE_BLOB */ + public double r; /* Value if eType is SQLITE_FLOAT or SQLITE_INTEGER */ + } + public _u u; + public u8 eType; /* SQLITE_NULL, SQLITE_INTEGER ... etc. */ + public u8 nByte; /* Size in byte of text or blob. */ + }; + + /* + ** Each token coming out of the lexer is an instance of + ** this structure. Tokens are also used as part of an expression. + ** + ** Note if Token.z==0 then Token.dyn and Token.n are undefined and + ** may contain random values. Do not make any assumptions about Token.dyn + ** and Token.n when Token.z==0. + */ + public class Token + { #if DEBUG_CLASS_TOKEN || DEBUG_CLASS_ALL public string _z; /* Text of the token. Not NULL-terminated! */ public bool dyn;// : 1; /* True for malloced memory, false for static */ @@ -1916,169 +1992,179 @@ public Int32 n set { _n = value; } } #else - public string z; /* Text of the token. Not NULL-terminated! */ - public Int32 n; /* Number of characters in this token */ + public string z; /* Text of the token. Not NULL-terminated! */ + public Int32 n; /* Number of characters in this token */ #endif - public Token() { - this.z = null; - this.n = 0; - } - public Token(string z, Int32 n) { - this.z = z; - this.n = n; - } - public Token Copy() { - if (this == null) - return null; - else { - Token cp = (Token)MemberwiseClone(); - if (z == null || z.Length == 0) - cp.n = 0; - else - if (n > z.Length) - cp.n = z.Length; - return cp; - } - } + public Token() + { + this.z = null; + this.n = 0; + } + public Token( string z, Int32 n ) + { + this.z = z; + this.n = n; + } + public Token Copy() + { + if ( this == null ) + return null; + else + { + Token cp = (Token)MemberwiseClone(); + if ( z == null || z.Length == 0 ) + cp.n = 0; + else + if ( n > z.Length ) + cp.n = z.Length; + return cp; } + } + } - /* - ** An instance of this structure contains information needed to generate - ** code for a SELECT that contains aggregate functions. - ** - ** If Expr.op==TK_AGG_COLUMN or TK_AGG_FUNCTION then Expr.pAggInfo is a - ** pointer to this structure. The Expr.iColumn field is the index in - ** AggInfo.aCol[] or AggInfo.aFunc[] of information needed to generate - ** code for that node. - ** - ** AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the - ** original Select structure that describes the SELECT statement. These - ** fields do not need to be freed when deallocating the AggInfo structure. - */ - public class AggInfo_col { /* For each column used in source tables */ - public Table pTab; /* Source table */ - public int iTable; /* VdbeCursor number of the source table */ - public int iColumn; /* Column number within the source table */ - public int iSorterColumn; /* Column number in the sorting index */ - public int iMem; /* Memory location that acts as accumulator */ - public Expr pExpr; /* The original expression */ - }; - public class AggInfo_func { /* For each aggregate function */ - public Expr pExpr; /* Expression encoding the function */ - public FuncDef pFunc; /* The aggregate function implementation */ - public int iMem; /* Memory location that acts as accumulator */ - public int iDistinct; /* Ephemeral table used to enforce DISTINCT */ - } - public class AggInfo { - public u8 directMode; /* Direct rendering mode means take data directly + /* + ** An instance of this structure contains information needed to generate + ** code for a SELECT that contains aggregate functions. + ** + ** If Expr.op==TK_AGG_COLUMN or TK_AGG_FUNCTION then Expr.pAggInfo is a + ** pointer to this structure. The Expr.iColumn field is the index in + ** AggInfo.aCol[] or AggInfo.aFunc[] of information needed to generate + ** code for that node. + ** + ** AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the + ** original Select structure that describes the SELECT statement. These + ** fields do not need to be freed when deallocating the AggInfo structure. + */ + public class AggInfo_col + { /* For each column used in source tables */ + public Table pTab; /* Source table */ + public int iTable; /* VdbeCursor number of the source table */ + public int iColumn; /* Column number within the source table */ + public int iSorterColumn; /* Column number in the sorting index */ + public int iMem; /* Memory location that acts as accumulator */ + public Expr pExpr; /* The original expression */ + }; + public class AggInfo_func + { /* For each aggregate function */ + public Expr pExpr; /* Expression encoding the function */ + public FuncDef pFunc; /* The aggregate function implementation */ + public int iMem; /* Memory location that acts as accumulator */ + public int iDistinct; /* Ephemeral table used to enforce DISTINCT */ + } + public class AggInfo + { + public u8 directMode; /* Direct rendering mode means take data directly ** from source tables rather than from accumulators */ - public u8 useSortingIdx; /* In direct mode, reference the sorting index rather + public u8 useSortingIdx; /* In direct mode, reference the sorting index rather ** than the source table */ - public int sortingIdx; /* VdbeCursor number of the sorting index */ - public ExprList pGroupBy; /* The group by clause */ - public int nSortingColumn; /* Number of columns in the sorting index */ - public AggInfo_col[] aCol; - public int nColumn; /* Number of used entries in aCol[] */ - public int nColumnAlloc; /* Number of slots allocated for aCol[] */ - public int nAccumulator; /* Number of columns that show through to the output. + public int sortingIdx; /* VdbeCursor number of the sorting index */ + public ExprList pGroupBy; /* The group by clause */ + public int nSortingColumn; /* Number of columns in the sorting index */ + public AggInfo_col[] aCol; + public int nColumn; /* Number of used entries in aCol[] */ + public int nColumnAlloc; /* Number of slots allocated for aCol[] */ + public int nAccumulator; /* Number of columns that show through to the output. ** Additional columns are used only as parameters to ** aggregate functions */ - public AggInfo_func[] aFunc; - public int nFunc; /* Number of entries in aFunc[] */ - public int nFuncAlloc; /* Number of slots allocated for aFunc[] */ - - public AggInfo Copy() { - if (this == null) - return null; - else { - AggInfo cp = (AggInfo)MemberwiseClone(); - if (pGroupBy != null) - cp.pGroupBy = pGroupBy.Copy(); - return cp; - } - } - }; - - /* - ** The datatype ynVar is a signed integer, either 16-bit or 32-bit. - ** Usually it is 16-bits. But if SQLITE_MAX_VARIABLE_NUMBER is greater - ** than 32767 we have to make it 32-bit. 16-bit is preferred because - ** it uses less memory in the Expr object, which is a big memory user - ** in systems with lots of prepared statements. And few applications - ** need more than about 10 or 20 variables. But some extreme users want - ** to have prepared statements with over 32767 variables, and for them - ** the option is available (at compile-time). - */ - //#if SQLITE_MAX_VARIABLE_NUMBER<=32767 - //typedef i16 ynVar; - //#else - //typedef int ynVar; - //#endif - - /* - ** Each node of an expression in the parse tree is an instance - ** of this structure. - ** - ** Expr.op is the opcode. The integer parser token codes are reused - ** as opcodes here. For example, the parser defines TK_GE to be an integer - ** code representing the ">=" operator. This same integer code is reused - ** to represent the greater-than-or-equal-to operator in the expression - ** tree. - ** - ** If the expression is an SQL literal (TK_INTEGER, TK_FLOAT, TK_BLOB, - ** or TK_STRING), then Expr.token contains the text of the SQL literal. If - ** the expression is a variable (TK_VARIABLE), then Expr.token contains the - ** variable name. Finally, if the expression is an SQL function (TK_FUNCTION), - ** then Expr.token contains the name of the function. - ** - ** Expr.pRight and Expr.pLeft are the left and right subexpressions of a - ** binary operator. Either or both may be NULL. - ** - ** Expr.x.pList is a list of arguments if the expression is an SQL function, - ** a CASE expression or an IN expression of the form " IN (, ...)". - ** Expr.x.pSelect is used if the expression is a sub-select or an expression of - ** the form " IN (SELECT ...)". If the EP_xIsSelect bit is set in the - ** Expr.flags mask, then Expr.x.pSelect is valid. Otherwise, Expr.x.pList is - ** valid. - ** - ** An expression of the form ID or ID.ID refers to a column in a table. - ** For such expressions, Expr.op is set to TK_COLUMN and Expr.iTable is - ** the integer cursor number of a VDBE cursor pointing to that table and - ** Expr.iColumn is the column number for the specific column. If the - ** expression is used as a result in an aggregate SELECT, then the - ** value is also stored in the Expr.iAgg column in the aggregate so that - ** it can be accessed after all aggregates are computed. - ** - ** If the expression is an unbound variable marker (a question mark - ** character '?' in the original SQL) then the Expr.iTable holds the index - ** number for that variable. - ** - ** If the expression is a subquery then Expr.iColumn holds an integer - ** register number containing the result of the subquery. If the - ** subquery gives a constant result, then iTable is -1. If the subquery - ** gives a different answer at different times during statement processing - ** then iTable is the address of a subroutine that computes the subquery. - ** - ** If the Expr is of type OP_Column, and the table it is selecting from - ** is a disk table or the "old.*" pseudo-table, then pTab points to the - ** corresponding table definition. - ** - ** ALLOCATION NOTES: - ** - ** Expr objects can use a lot of memory space in database schema. To - ** help reduce memory requirements, sometimes an Expr object will be - ** truncated. And to reduce the number of memory allocations, sometimes - ** two or more Expr objects will be stored in a single memory allocation, - ** together with Expr.zToken strings. - ** - ** If the EP_Reduced and EP_TokenOnly flags are set when - ** an Expr object is truncated. When EP_Reduced is set, then all - ** the child Expr objects in the Expr.pLeft and Expr.pRight subtrees - ** are contained within the same memory allocation. Note, however, that - ** the subtrees in Expr.x.pList or Expr.x.pSelect are always separately - ** allocated, regardless of whether or not EP_Reduced is set. - */ - public class Expr { + public AggInfo_func[] aFunc; + public int nFunc; /* Number of entries in aFunc[] */ + public int nFuncAlloc; /* Number of slots allocated for aFunc[] */ + + public AggInfo Copy() + { + if ( this == null ) + return null; + else + { + AggInfo cp = (AggInfo)MemberwiseClone(); + if ( pGroupBy != null ) + cp.pGroupBy = pGroupBy.Copy(); + return cp; + } + } + }; + + /* + ** The datatype ynVar is a signed integer, either 16-bit or 32-bit. + ** Usually it is 16-bits. But if SQLITE_MAX_VARIABLE_NUMBER is greater + ** than 32767 we have to make it 32-bit. 16-bit is preferred because + ** it uses less memory in the Expr object, which is a big memory user + ** in systems with lots of prepared statements. And few applications + ** need more than about 10 or 20 variables. But some extreme users want + ** to have prepared statements with over 32767 variables, and for them + ** the option is available (at compile-time). + */ + //#if SQLITE_MAX_VARIABLE_NUMBER<=32767 + //typedef i16 ynVar; + //#else + //typedef int ynVar; + //#endif + + /* + ** Each node of an expression in the parse tree is an instance + ** of this structure. + ** + ** Expr.op is the opcode. The integer parser token codes are reused + ** as opcodes here. For example, the parser defines TK_GE to be an integer + ** code representing the ">=" operator. This same integer code is reused + ** to represent the greater-than-or-equal-to operator in the expression + ** tree. + ** + ** If the expression is an SQL literal (TK_INTEGER, TK_FLOAT, TK_BLOB, + ** or TK_STRING), then Expr.token contains the text of the SQL literal. If + ** the expression is a variable (TK_VARIABLE), then Expr.token contains the + ** variable name. Finally, if the expression is an SQL function (TK_FUNCTION), + ** then Expr.token contains the name of the function. + ** + ** Expr.pRight and Expr.pLeft are the left and right subexpressions of a + ** binary operator. Either or both may be NULL. + ** + ** Expr.x.pList is a list of arguments if the expression is an SQL function, + ** a CASE expression or an IN expression of the form " IN (, ...)". + ** Expr.x.pSelect is used if the expression is a sub-select or an expression of + ** the form " IN (SELECT ...)". If the EP_xIsSelect bit is set in the + ** Expr.flags mask, then Expr.x.pSelect is valid. Otherwise, Expr.x.pList is + ** valid. + ** + ** An expression of the form ID or ID.ID refers to a column in a table. + ** For such expressions, Expr.op is set to TK_COLUMN and Expr.iTable is + ** the integer cursor number of a VDBE cursor pointing to that table and + ** Expr.iColumn is the column number for the specific column. If the + ** expression is used as a result in an aggregate SELECT, then the + ** value is also stored in the Expr.iAgg column in the aggregate so that + ** it can be accessed after all aggregates are computed. + ** + ** If the expression is an unbound variable marker (a question mark + ** character '?' in the original SQL) then the Expr.iTable holds the index + ** number for that variable. + ** + ** If the expression is a subquery then Expr.iColumn holds an integer + ** register number containing the result of the subquery. If the + ** subquery gives a constant result, then iTable is -1. If the subquery + ** gives a different answer at different times during statement processing + ** then iTable is the address of a subroutine that computes the subquery. + ** + ** If the Expr is of type OP_Column, and the table it is selecting from + ** is a disk table or the "old.*" pseudo-table, then pTab points to the + ** corresponding table definition. + ** + ** ALLOCATION NOTES: + ** + ** Expr objects can use a lot of memory space in database schema. To + ** help reduce memory requirements, sometimes an Expr object will be + ** truncated. And to reduce the number of memory allocations, sometimes + ** two or more Expr objects will be stored in a single memory allocation, + ** together with Expr.zToken strings. + ** + ** If the EP_Reduced and EP_TokenOnly flags are set when + ** an Expr object is truncated. When EP_Reduced is set, then all + ** the child Expr objects in the Expr.pLeft and Expr.pRight subtrees + ** are contained within the same memory allocation. Note, however, that + ** the subtrees in Expr.x.pList or Expr.x.pSelect are always separately + ** allocated, regardless of whether or not EP_Reduced is set. + */ + public class Expr + { #if DEBUG_CLASS_EXPR || DEBUG_CLASS_ALL public u8 _op; /* Operation performed by this node */ public u8 op @@ -2087,9 +2173,9 @@ public u8 op set { _op = value; } } #else - public u8 op; /* Operation performed by this node */ + public u8 op; /* Operation performed by this node */ #endif - public char affinity; /* The affinity of the column or 0 if not a column */ + public char affinity; /* The affinity of the column or 0 if not a column */ #if DEBUG_CLASS_EXPR || DEBUG_CLASS_ALL public u16 _flags; /* Various flags. EP_* See below */ public u16 flags @@ -2109,47 +2195,49 @@ public string zToken } #else - public struct _u { - public string zToken; /* Token value. Zero terminated and dequoted */ - public int iValue; /* Non-negative integer value if EP_IntValue */ - } - public u16 flags; /* Various flags. EP_* See below */ + public struct _u + { + public string zToken; /* Token value. Zero terminated and dequoted */ + public int iValue; /* Non-negative integer value if EP_IntValue */ + } + public u16 flags; /* Various flags. EP_* See below */ #endif - public _u u; - - /* If the EP_TokenOnly 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. - *********************************************************************/ - - public Expr pLeft; /* Left subnode */ - public Expr pRight; /* Right subnode */ - public struct _x { - public ExprList pList; /* Function arguments or in " IN ( IN ()" */ + } + public _x x; + public CollSeq pColl; /* The collation type of the column or 0 */ + + /* 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. + *********************************************************************/ + + public int iTable; /* TK_COLUMN: cursor number of table holding column ** TK_REGISTER: register number ** TK_TRIGGER: 1 -> new, 0 -> old */ - public ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid. + public ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid. ** TK_VARIABLE: variable number (always >= 1). */ - public i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */ - public i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */ - public u8 flags2; /* Second set of flags. EP2_... */ - public u8 op2; /* If a TK_REGISTER, the original value of Expr.op */ - public AggInfo pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */ - public Table pTab; /* Table for TK_COLUMN expressions. */ + public i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */ + public i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */ + public u8 flags2; /* Second set of flags. EP2_... */ + public u8 op2; /* If a TK_REGISTER, the original value of Expr.op */ + public AggInfo pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */ + public Table pTab; /* Table for TK_COLUMN expressions. */ #if SQLITE_MAX_EXPR_DEPTH //>0 - public int nHeight; /* Height of the tree headed by this node */ - public Table pZombieTab; /* List of Table objects to delete after code gen */ + public int nHeight; /* Height of the tree headed by this node */ + public Table pZombieTab; /* List of Table objects to delete after code gen */ #endif #if DEBUG_CLASS @@ -2159,905 +2247,948 @@ public int op set { _op = value; } } #endif - public void CopyFrom(Expr cf) { - op = cf.op; - affinity = cf.affinity; - flags = cf.flags; - u = cf.u; - pColl = cf.pColl == null ? null : cf.pColl.Copy(); - iTable = cf.iTable; - iColumn = cf.iColumn; - pAggInfo = cf.pAggInfo == null ? null : cf.pAggInfo.Copy(); - iAgg = cf.iAgg; - iRightJoinTable = cf.iRightJoinTable; - flags2 = cf.flags2; - pTab = cf.pTab == null ? null : cf.pTab; + public void CopyFrom( Expr cf ) + { + op = cf.op; + affinity = cf.affinity; + flags = cf.flags; + u = cf.u; + pColl = cf.pColl == null ? null : cf.pColl.Copy(); + iTable = cf.iTable; + iColumn = cf.iColumn; + pAggInfo = cf.pAggInfo == null ? null : cf.pAggInfo.Copy(); + iAgg = cf.iAgg; + iRightJoinTable = cf.iRightJoinTable; + flags2 = cf.flags2; + pTab = cf.pTab == null ? null : cf.pTab; #if SQLITE_TEST || SQLITE_MAX_EXPR_DEPTH //SQLITE_MAX_EXPR_DEPTH>0 - nHeight = cf.nHeight; - pZombieTab = cf.pZombieTab; + nHeight = cf.nHeight; + pZombieTab = cf.pZombieTab; #endif - pLeft = cf.pLeft == null ? null : cf.pLeft.Copy(); - pRight = cf.pRight == null ? null : cf.pRight.Copy(); - x.pList = cf.x.pList == null ? null : cf.x.pList.Copy(); - x.pSelect = cf.x.pSelect == null ? null : cf.x.pSelect.Copy(); - } - - public Expr Copy() { - if (this == null) - return null; - else - return Copy(flags); - } - - public Expr Copy(int flag) { - Expr cp = new Expr(); - cp.op = op; - cp.affinity = affinity; - cp.flags = flags; - cp.u = u; - if ((flag & EP_TokenOnly) != 0) - return cp; - if (pLeft != null) - cp.pLeft = pLeft.Copy(); - if (pRight != null) - cp.pRight = pRight.Copy(); - cp.x = x; - cp.pColl = pColl; - if ((flag & EP_Reduced) != 0) - return cp; - cp.iTable = iTable; - cp.iColumn = iColumn; - cp.iAgg = iAgg; - cp.iRightJoinTable = iRightJoinTable; - cp.flags2 = flags2; - cp.op2 = op2; - cp.pAggInfo = pAggInfo; - cp.pTab = pTab; + pLeft = cf.pLeft == null ? null : cf.pLeft.Copy(); + pRight = cf.pRight == null ? null : cf.pRight.Copy(); + x.pList = cf.x.pList == null ? null : cf.x.pList.Copy(); + x.pSelect = cf.x.pSelect == null ? null : cf.x.pSelect.Copy(); + } + + public Expr Copy() + { + if ( this == null ) + return null; + else + return Copy( flags ); + } + + public Expr Copy( int flag ) + { + Expr cp = new Expr(); + cp.op = op; + cp.affinity = affinity; + cp.flags = flags; + cp.u = u; + if ( ( flag & EP_TokenOnly ) != 0 ) + return cp; + if ( pLeft != null ) + cp.pLeft = pLeft.Copy(); + if ( pRight != null ) + cp.pRight = pRight.Copy(); + cp.x = x; + cp.pColl = pColl; + if ( ( flag & EP_Reduced ) != 0 ) + return cp; + cp.iTable = iTable; + cp.iColumn = iColumn; + cp.iAgg = iAgg; + cp.iRightJoinTable = iRightJoinTable; + cp.flags2 = flags2; + cp.op2 = op2; + cp.pAggInfo = pAggInfo; + cp.pTab = pTab; #if SQLITE_MAX_EXPR_DEPTH //>0 - cp.nHeight = nHeight; - cp.pZombieTab = pZombieTab; + cp.nHeight = nHeight; + cp.pZombieTab = pZombieTab; #endif - return cp; - } - }; - - /* - ** The following are the meanings of bits in the Expr.flags field. - */ - //#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_ExpCollate 0x0100 /* Collating sequence specified explicitly */ - //#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_Reduced 0x1000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */ - //#define EP_TokenOnly 0x2000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */ - //#define EP_Static 0x4000 /* Held in memory not obtained from malloc() */ - - const ushort EP_FromJoin = 0x0001; - const ushort EP_Agg = 0x0002; - const ushort EP_Resolved = 0x0004; - const ushort EP_Error = 0x0008; - const ushort EP_Distinct = 0x0010; - const ushort EP_VarSelect = 0x0020; - const ushort EP_DblQuoted = 0x0040; - const ushort EP_InfixFunc = 0x0080; - const ushort EP_ExpCollate = 0x0100; - const ushort EP_FixedDest = 0x0200; - const ushort EP_IntValue = 0x0400; - const ushort EP_xIsSelect = 0x0800; - - const ushort EP_Reduced = 0x1000; - const ushort EP_TokenOnly = 0x2000; - const ushort EP_Static = 0x4000; - - /* - ** 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 */ - const u8 EP2_MallocedToken = 0x0001; - const u8 EP2_Irreducible = 0x0002; - - /* - ** 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. - */ + return cp; + } + }; + + /* + ** The following are the meanings of bits in the Expr.flags field. + */ + //#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_ExpCollate 0x0100 /* Collating sequence specified explicitly */ + //#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_Reduced 0x1000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */ + //#define EP_TokenOnly 0x2000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */ + //#define EP_Static 0x4000 /* Held in memory not obtained from malloc() */ + + const ushort EP_FromJoin = 0x0001; + const ushort EP_Agg = 0x0002; + const ushort EP_Resolved = 0x0004; + const ushort EP_Error = 0x0008; + const ushort EP_Distinct = 0x0010; + const ushort EP_VarSelect = 0x0020; + const ushort EP_DblQuoted = 0x0040; + const ushort EP_InfixFunc = 0x0080; + const ushort EP_ExpCollate = 0x0100; + const ushort EP_FixedDest = 0x0200; + const ushort EP_IntValue = 0x0400; + const ushort EP_xIsSelect = 0x0800; + + const ushort EP_Reduced = 0x1000; + const ushort EP_TokenOnly = 0x2000; + const ushort EP_Static = 0x4000; + + /* + ** 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 */ + const u8 EP2_MallocedToken = 0x0001; + const u8 EP2_Irreducible = 0x0002; + + /* + ** 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. + */ #if SQLITE_DEBUG - //# define ExprSetIrreducible(X) (X)->flags2 |= EP2_Irreducible - static void ExprSetIrreducible(Expr X) { - X.flags2 |= EP2_Irreducible; - } + //# define ExprSetIrreducible(X) (X)->flags2 |= EP2_Irreducible + static void ExprSetIrreducible( Expr X ) + { + X.flags2 |= EP2_Irreducible; + } #else //# define ExprSetIrreducible(X) static void ExprSetIrreducible( Expr X ) { } #endif - /* - ** These macros can be used to test, set, or clear bits in the - ** Expr.flags field. + /* +** These macros can be used to test, set, or clear bits in the +** Expr.flags field. +*/ + //#define ExprHasProperty(E,P) (((E)->flags&(P))==(P)) + static bool ExprHasProperty( Expr E, int P ) + { + return ( E.flags & P ) == P; + } + //#define ExprHasAnyProperty(E,P) (((E)->flags&(P))!=0) + static bool ExprHasAnyProperty( Expr E, int P ) + { + return ( E.flags & P ) != 0; + } + //#define ExprSetProperty(E,P) (E)->flags|=(P) + static void ExprSetProperty( Expr E, int P ) + { + E.flags = (ushort)( E.flags | P ); + } + //#define ExprClearProperty(E,P) (E)->flags&=~(P) + static void ExprClearProperty( Expr E, int P ) + { + E.flags = (ushort)( E.flags & ~P ); + } + + /* + ** 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. */ - //#define ExprHasProperty(E,P) (((E)->flags&(P))==(P)) - static bool ExprHasProperty(Expr E, int P) { - return (E.flags & P) == P; - } - //#define ExprHasAnyProperty(E,P) (((E)->flags&(P))!=0) - static bool ExprHasAnyProperty(Expr E, int P) { - return (E.flags & P) != 0; - } - //#define ExprSetProperty(E,P) (E)->flags|=(P) - static void ExprSetProperty(Expr E, int P) { - E.flags = (ushort)(E.flags | P); - } - //#define ExprClearProperty(E,P) (E)->flags&=~(P) - static void ExprClearProperty(Expr E, int P) { - E.flags = (ushort)(E.flags & ~P); + //#define EXPR_FULLSIZE sizeof(Expr) /* Full size */ + //#define EXPR_REDUCEDSIZE offsetof(Expr,iTable) /* Common features */ + //#define EXPR_TOKENONLYSIZE offsetof(Expr,pLeft) /* Fewer features */ + + // We don't use these in C#, but define them anyway, + const int EXPR_FULLSIZE = 48; + const int EXPR_REDUCEDSIZE = 24; + const int EXPR_TOKENONLYSIZE = 8; + + /* + ** Flags passed to the sqlite3ExprDup() function. See the header comment + ** above sqlite3ExprDup() for details. + */ + //#define EXPRDUP_REDUCE 0x0001 /* Used reduced-size Expr nodes */ + const int EXPRDUP_REDUCE = 0x0001; + + /* + ** A list of expressions. Each expression may optionally have a + ** name. An expr/name combination can be used in several ways, such + ** as the list of "expr AS ID" fields following a "SELECT" or in the + ** list of "ID = expr" items in an UPDATE. A list of expressions can + ** also be used as the argument to a function, in which case the a.zName + ** field is not used. + */ + public class ExprList_item + { + public Expr pExpr; /* The list of expressions */ + public string zName; /* Token associated with this expression */ + public string zSpan; /* Original text of the expression */ + public u8 sortOrder; /* 1 for DESC or 0 for ASC */ + public u8 done; /* A flag to indicate when processing is finished */ + public u16 iCol; /* For ORDER BY, column number in result set */ + public u16 iAlias; /* Index into Parse.aAlias[] for zName */ + } + public class ExprList + { + public int nExpr; /* Number of expressions on the list */ + public int nAlloc; /* Number of entries allocated below */ + public int iECursor; /* VDBE VdbeCursor associated with this ExprList */ + public ExprList_item[] a; /* One entry for each expression */ + + public ExprList Copy() + { + if ( this == null ) + return null; + else + { + ExprList cp = (ExprList)MemberwiseClone(); + a.CopyTo( cp.a, 0 ); + return cp; } + } - /* - ** 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. - */ - //#define EXPR_FULLSIZE sizeof(Expr) /* Full size */ - //#define EXPR_REDUCEDSIZE offsetof(Expr,iTable) /* Common features */ - //#define EXPR_TOKENONLYSIZE offsetof(Expr,pLeft) /* Fewer features */ - - // We don't use these in C#, but define them anyway, - const int EXPR_FULLSIZE = 48; - const int EXPR_REDUCEDSIZE = 24; - const int EXPR_TOKENONLYSIZE = 8; - - /* - ** Flags passed to the sqlite3ExprDup() function. See the header comment - ** above sqlite3ExprDup() for details. - */ - //#define EXPRDUP_REDUCE 0x0001 /* Used reduced-size Expr nodes */ - const int EXPRDUP_REDUCE = 0x0001; - - /* - ** A list of expressions. Each expression may optionally have a - ** name. An expr/name combination can be used in several ways, such - ** as the list of "expr AS ID" fields following a "SELECT" or in the - ** list of "ID = expr" items in an UPDATE. A list of expressions can - ** also be used as the argument to a function, in which case the a.zName - ** field is not used. - */ - public class ExprList_item { - public Expr pExpr; /* The list of expressions */ - public string zName; /* Token associated with this expression */ - public string zSpan; /* Original text of the expression */ - public u8 sortOrder; /* 1 for DESC or 0 for ASC */ - public u8 done; /* A flag to indicate when processing is finished */ - public u16 iCol; /* For ORDER BY, column number in result set */ - public u16 iAlias; /* Index into Parse.aAlias[] for zName */ - } - public class ExprList { - public int nExpr; /* Number of expressions on the list */ - public int nAlloc; /* Number of entries allocated below */ - public int iECursor; /* VDBE VdbeCursor associated with this ExprList */ - public ExprList_item[] a; /* One entry for each expression */ - - public ExprList Copy() { - if (this == null) - return null; - else { - ExprList cp = (ExprList)MemberwiseClone(); - a.CopyTo(cp.a, 0); - return cp; - } - } - - }; - - /* - ** An instance of this structure is used by the parser to record both - ** the parse tree for an expression and the span of input text for an - ** expression. - */ - public class ExprSpan { - public Expr pExpr; /* The expression parse tree */ - public string zStart; /* First character of input text */ - public string zEnd; /* One character past the end of input text */ - }; - - /* - ** An instance of this structure can hold a simple list of identifiers, - ** such as the list "a,b,c" in the following statements: - ** - ** INSERT INTO t(a,b,c) VALUES ...; - ** CREATE INDEX idx ON t(a,b,c); - ** CREATE TRIGGER trig BEFORE UPDATE ON t(a,b,c) ...; - ** - ** The IdList.a.idx field is used when the IdList represents the list of - ** column names after a table name in an INSERT statement. In the statement - ** - ** INSERT INTO t(a,b,c) ... - ** - ** If "a" is the k-th column of table "t", then IdList.a[0].idx==k. - */ - public class IdList_item { - public string zName; /* Name of the identifier */ - public int idx; /* Index in some Table.aCol[] of a column named zName */ + }; + + /* + ** An instance of this structure is used by the parser to record both + ** the parse tree for an expression and the span of input text for an + ** expression. + */ + public class ExprSpan + { + public Expr pExpr; /* The expression parse tree */ + public string zStart; /* First character of input text */ + public string zEnd; /* One character past the end of input text */ + }; + + /* + ** An instance of this structure can hold a simple list of identifiers, + ** such as the list "a,b,c" in the following statements: + ** + ** INSERT INTO t(a,b,c) VALUES ...; + ** CREATE INDEX idx ON t(a,b,c); + ** CREATE TRIGGER trig BEFORE UPDATE ON t(a,b,c) ...; + ** + ** The IdList.a.idx field is used when the IdList represents the list of + ** column names after a table name in an INSERT statement. In the statement + ** + ** INSERT INTO t(a,b,c) ... + ** + ** If "a" is the k-th column of table "t", then IdList.a[0].idx==k. + */ + public class IdList_item + { + public string zName; /* Name of the identifier */ + public int idx; /* Index in some Table.aCol[] of a column named zName */ + } + public class IdList + { + public IdList_item[] a; + public int nId; /* Number of identifiers on the list */ + public int nAlloc; /* Number of entries allocated for a[] below */ + + public IdList Copy() + { + if ( this == null ) + return null; + else + { + IdList cp = (IdList)MemberwiseClone(); + a.CopyTo( cp.a, 0 ); + return cp; } - public class IdList { - public IdList_item[] a; - public int nId; /* Number of identifiers on the list */ - public int nAlloc; /* Number of entries allocated for a[] below */ - - public IdList Copy() { - if (this == null) - return null; - else { - IdList cp = (IdList)MemberwiseClone(); - a.CopyTo(cp.a, 0); - return cp; - } - } - }; - - /* - ** The bitmask datatype defined below is used for various optimizations. - ** - ** Changing this from a 64-bit to a 32-bit type limits the number of - ** tables in a join to 32 instead of 64. But it also reduces the size - ** of the library by 738 bytes on ix86. - */ - //typedef u64 Bitmask; - - /* - ** The number of bits in a Bitmask. "BMS" means "BitMask Size". - */ - //#define BMS ((int)(sizeof(Bitmask)*8)) - const int BMS = ((int)(sizeof(Bitmask) * 8)); - - - /* - ** The following structure describes the FROM clause of a SELECT statement. - ** Each table or subquery in the FROM clause is a separate element of - ** the SrcList.a[] array. - ** - ** With the addition of multiple database support, the following structure - ** can also be used to describe a particular table such as the table that - ** is modified by an INSERT, DELETE, or UPDATE statement. In standard SQL, - ** such a table must be a simple name: ID. But in SQLite, the table can - ** now be identified by a database name, a dot, then the table name: ID.ID. - ** - ** The jointype starts out showing the join type between the current table - ** and the next table on the list. The parser builds the list this way. - ** But sqlite3SrcListShiftJoinType() later shifts the jointypes so that each - ** jointype expresses the join between the table and the previous table. - ** - ** In the colUsed field, the high-order bit (bit 63) is set if the table - ** contains more than 63 columns and the 64-th or later column is used. - */ - public class SrcList_item { - public string zDatabase; /* Name of database holding this table */ - public string zName; /* Name of the table */ - public string zAlias; /* The "B" part of a "A AS B" phrase. zName is the "A" */ - public Table pTab; /* An SQL table corresponding to zName */ - public Select pSelect; /* A SELECT statement used in place of a table name */ - public u8 isPopulated; /* Temporary table associated with SELECT is populated */ - public u8 jointype; /* Type of join between this able and the previous */ - public u8 notIndexed; /* True if there is a NOT INDEXED clause */ + } + }; + + /* + ** The bitmask datatype defined below is used for various optimizations. + ** + ** Changing this from a 64-bit to a 32-bit type limits the number of + ** tables in a join to 32 instead of 64. But it also reduces the size + ** of the library by 738 bytes on ix86. + */ + //typedef u64 Bitmask; + + /* + ** The number of bits in a Bitmask. "BMS" means "BitMask Size". + */ + //#define BMS ((int)(sizeof(Bitmask)*8)) + const int BMS = ( (int)( sizeof( Bitmask ) * 8 ) ); + + + /* + ** The following structure describes the FROM clause of a SELECT statement. + ** Each table or subquery in the FROM clause is a separate element of + ** the SrcList.a[] array. + ** + ** With the addition of multiple database support, the following structure + ** can also be used to describe a particular table such as the table that + ** is modified by an INSERT, DELETE, or UPDATE statement. In standard SQL, + ** such a table must be a simple name: ID. But in SQLite, the table can + ** now be identified by a database name, a dot, then the table name: ID.ID. + ** + ** The jointype starts out showing the join type between the current table + ** and the next table on the list. The parser builds the list this way. + ** But sqlite3SrcListShiftJoinType() later shifts the jointypes so that each + ** jointype expresses the join between the table and the previous table. + ** + ** In the colUsed field, the high-order bit (bit 63) is set if the table + ** contains more than 63 columns and the 64-th or later column is used. + */ + public class SrcList_item + { + public string zDatabase; /* Name of database holding this table */ + public string zName; /* Name of the table */ + public string zAlias; /* The "B" part of a "A AS B" phrase. zName is the "A" */ + public Table pTab; /* An SQL table corresponding to zName */ + public Select pSelect; /* A SELECT statement used in place of a table name */ + public u8 isPopulated; /* Temporary table associated with SELECT is populated */ + public u8 jointype; /* Type of join between this able and the previous */ + public u8 notIndexed; /* True if there is a NOT INDEXED clause */ #if !SQLITE_OMIT_EXPLAIN - public u8 iSelectId; /* If pSelect!=0, the id of the sub-select in EQP */ + public u8 iSelectId; /* If pSelect!=0, the id of the sub-select in EQP */ #endif - public int iCursor; /* The VDBE cursor number used to access this table */ - public Expr pOn; /* The ON clause of a join */ - public IdList pUsing; /* The USING clause of a join */ - public Bitmask colUsed; /* Bit N (1<" clause */ - public Index pIndex; /* Index structure corresponding to zIndex, if any */ + public int iCursor; /* The VDBE cursor number used to access this table */ + public Expr pOn; /* The ON clause of a join */ + public IdList pUsing; /* The USING clause of a join */ + public Bitmask colUsed; /* Bit N (1<" clause */ + public Index pIndex; /* Index structure corresponding to zIndex, if any */ + } + public class SrcList + { + public i16 nSrc; /* Number of tables or subqueries in the FROM clause */ + public i16 nAlloc; /* Number of entries allocated in a[] below */ + public SrcList_item[] a;/* One entry for each identifier on the list */ + public SrcList Copy() + { + if ( this == null ) + return null; + else + { + SrcList cp = (SrcList)MemberwiseClone(); + if ( a != null ) + a.CopyTo( cp.a, 0 ); + return cp; } - public class SrcList { - public i16 nSrc; /* Number of tables or subqueries in the FROM clause */ - public i16 nAlloc; /* Number of entries allocated in a[] below */ - public SrcList_item[] a;/* One entry for each identifier on the list */ - public SrcList Copy() { - if (this == null) - return null; - else { - SrcList cp = (SrcList)MemberwiseClone(); - if (a != null) - a.CopyTo(cp.a, 0); - return cp; - } - } - }; - - /* - ** Permitted values of the SrcList.a.jointype field - */ - const int JT_INNER = 0x0001; //#define JT_INNER 0x0001 /* Any kind of inner or cross join */ - const int JT_CROSS = 0x0002; //#define JT_CROSS 0x0002 /* Explicit use of the CROSS keyword */ - const int JT_NATURAL = 0x0004; //#define JT_NATURAL 0x0004 /* True for a "natural" join */ - const int JT_LEFT = 0x0008; //#define JT_LEFT 0x0008 /* Left outer join */ - const int JT_RIGHT = 0x0010; //#define JT_RIGHT 0x0010 /* Right outer join */ - const int JT_OUTER = 0x0020; //#define JT_OUTER 0x0020 /* The "OUTER" keyword is present */ - const int JT_ERROR = 0x0040; //#define JT_ERROR 0x0040 /* unknown or unsupported join type */ - - - /* - ** A WherePlan object holds information that describes a lookup - ** strategy. - ** - ** This object is intended to be opaque outside of the where.c module. - ** It is included here only so that that compiler will know how big it - ** is. None of the fields in this object should be used outside of - ** the where.c module. - ** - ** Within the union, pIdx is only used when wsFlags&WHERE_INDEXED is true. - ** pTerm is only used when wsFlags&WHERE_MULTI_OR is true. And pVtabIdx - ** is only used when wsFlags&WHERE_VIRTUALTABLE is true. It is never the - ** case that more than one of these conditions is true. - */ - public class WherePlan { - public u32 wsFlags; /* WHERE_* flags that describe the strategy */ - public u32 nEq; /* Number of == constraints */ - public double nRow; /* Estimated number of rows (for EQP) */ - public class _u { - public Index pIdx; /* Index when WHERE_INDEXED is true */ - public WhereTerm pTerm; /* WHERE clause term for OR-search */ - public sqlite3_index_info pVtabIdx; /* Virtual table index to use */ - } - public _u u = new _u(); - public void Clear() { - wsFlags = 0; - nEq = 0; - nRow = 0; - u.pIdx = null; - u.pTerm = null; - u.pVtabIdx = null; - } - }; - - /* - ** For each nested loop in a WHERE clause implementation, the WhereInfo - ** structure contains a single instance of this structure. This structure - ** is intended to be private the the where.c module and should not be - ** access or modified by other modules. - ** - ** The pIdxInfo field is used to help pick the best index on a - ** virtual table. The pIdxInfo pointer contains indexing - ** information for the i-th table in the FROM clause before reordering. - ** All the pIdxInfo pointers are freed by whereInfoFree() in where.c. - ** All other information in the i-th WhereLevel object for the i-th table - ** after FROM clause ordering. - */ - public class InLoop { - public int iCur; /* The VDBE cursor used by this IN operator */ - public int addrInTop; /* Top of the IN loop */ + } + }; + + /* + ** Permitted values of the SrcList.a.jointype field + */ + const int JT_INNER = 0x0001; //#define JT_INNER 0x0001 /* Any kind of inner or cross join */ + const int JT_CROSS = 0x0002; //#define JT_CROSS 0x0002 /* Explicit use of the CROSS keyword */ + const int JT_NATURAL = 0x0004; //#define JT_NATURAL 0x0004 /* True for a "natural" join */ + const int JT_LEFT = 0x0008; //#define JT_LEFT 0x0008 /* Left outer join */ + const int JT_RIGHT = 0x0010; //#define JT_RIGHT 0x0010 /* Right outer join */ + const int JT_OUTER = 0x0020; //#define JT_OUTER 0x0020 /* The "OUTER" keyword is present */ + const int JT_ERROR = 0x0040; //#define JT_ERROR 0x0040 /* unknown or unsupported join type */ + + + /* + ** A WherePlan object holds information that describes a lookup + ** strategy. + ** + ** This object is intended to be opaque outside of the where.c module. + ** It is included here only so that that compiler will know how big it + ** is. None of the fields in this object should be used outside of + ** the where.c module. + ** + ** Within the union, pIdx is only used when wsFlags&WHERE_INDEXED is true. + ** pTerm is only used when wsFlags&WHERE_MULTI_OR is true. And pVtabIdx + ** is only used when wsFlags&WHERE_VIRTUALTABLE is true. It is never the + ** case that more than one of these conditions is true. + */ + public class WherePlan + { + public u32 wsFlags; /* WHERE_* flags that describe the strategy */ + public u32 nEq; /* Number of == constraints */ + public double nRow; /* Estimated number of rows (for EQP) */ + public class _u + { + public Index pIdx; /* Index when WHERE_INDEXED is true */ + public WhereTerm pTerm; /* WHERE clause term for OR-search */ + public sqlite3_index_info pVtabIdx; /* Virtual table index to use */ + } + public _u u = new _u(); + public void Clear() + { + wsFlags = 0; + nEq = 0; + nRow = 0; + u.pIdx = null; + u.pTerm = null; + u.pVtabIdx = null; + } + }; + + /* + ** For each nested loop in a WHERE clause implementation, the WhereInfo + ** structure contains a single instance of this structure. This structure + ** is intended to be private the the where.c module and should not be + ** access or modified by other modules. + ** + ** The pIdxInfo field is used to help pick the best index on a + ** virtual table. The pIdxInfo pointer contains indexing + ** information for the i-th table in the FROM clause before reordering. + ** All the pIdxInfo pointers are freed by whereInfoFree() in where.c. + ** All other information in the i-th WhereLevel object for the i-th table + ** after FROM clause ordering. + */ + public class InLoop + { + public int iCur; /* The VDBE cursor used by this IN operator */ + public int addrInTop; /* Top of the IN loop */ + } + public class WhereLevel + { + public WherePlan plan = new WherePlan(); /* query plan for this element of the FROM clause */ + public int iLeftJoin; /* Memory cell used to implement LEFT OUTER JOIN */ + public int iTabCur; /* The VDBE cursor used to access the table */ + public int iIdxCur; /* The VDBE cursor used to access pIdx */ + public int addrBrk; /* Jump here to break out of the loop */ + public int addrNxt; /* Jump here to start the next IN combination */ + public int addrCont; /* Jump here to continue with the next loop cycle */ + public int addrFirst; /* First instruction of interior of the loop */ + public u8 iFrom; /* Which entry in the FROM clause */ + public u8 op, p5; /* Opcode and P5 of the opcode that ends the loop */ + public int p1, p2; /* Operands of the opcode used to ends the loop */ + public class _u + { + public class __in /* Information that depends on plan.wsFlags */ + { + public int nIn; /* Number of entries in aInLoop[] */ + public InLoop[] aInLoop; /* Information about each nested IN operator */ + } + public __in _in = new __in(); /* Used when plan.wsFlags&WHERE_IN_ABLE */ + } + public _u u = new _u(); + + + /* The following field is really not part of the current level. But + ** we need a place to cache virtual table index information for each + ** virtual table in the FROM clause and the WhereLevel structure is + ** a convenient place since there is one WhereLevel for each FROM clause + ** element. + */ + public sqlite3_index_info pIdxInfo; /* Index info for n-th source table */ + }; + + /* + ** Flags appropriate for the wctrlFlags parameter of sqlite3WhereBegin() + ** and the WhereInfo.wctrlFlags member. + */ + //#define WHERE_ORDERBY_NORMAL 0x0000 /* No-op */ + //#define WHERE_ORDERBY_MIN 0x0001 /* ORDER BY processing for min() func */ + //#define WHERE_ORDERBY_MAX 0x0002 /* ORDER BY processing for max() func */ + //#define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */ + //#define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */ + //#define WHERE_OMIT_OPEN 0x0010 /* Table cursors are already open */ + //#define WHERE_OMIT_CLOSE 0x0020 /* Omit close of table & index cursors */ + //#define WHERE_FORCE_TABLE 0x0040 /* Do not use an index-only search */ + //#define WHERE_ONETABLE_ONLY 0x0080 /* Only code the 1st table in pTabList */ + const int WHERE_ORDERBY_NORMAL = 0x0000; + const int WHERE_ORDERBY_MIN = 0x0001; + const int WHERE_ORDERBY_MAX = 0x0002; + const int WHERE_ONEPASS_DESIRED = 0x0004; + const int WHERE_DUPLICATES_OK = 0x0008; + const int WHERE_OMIT_OPEN = 0x0010; + const int WHERE_OMIT_CLOSE = 0x0020; + const int WHERE_FORCE_TABLE = 0x0040; + const int WHERE_ONETABLE_ONLY = 0x0080; + + /* + ** The WHERE clause processing routine has two halves. The + ** first part does the start of the WHERE loop and the second + ** half does the tail of the WHERE loop. An instance of + ** this structure is returned by the first half and passed + ** into the second half to give some continuity. + */ + public class WhereInfo + { + public Parse pParse; /* Parsing and code generating context */ + public u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */ + public u8 okOnePass; /* Ok to use one-pass algorithm for UPDATE or DELETE */ + public u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */ + public SrcList pTabList; /* List of tables in the join */ + public int iTop; /* The very beginning of the WHERE loop */ + public int iContinue; /* Jump here to continue with next record */ + public int iBreak; /* Jump here to break out of the loop */ + public int nLevel; /* Number of nested loop */ + public WhereClause pWC; /* Decomposition of the WHERE clause */ + public double savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */ + public double nRowOut; /* Estimated number of output rows */ + public WhereLevel[] a = new WhereLevel[] { new WhereLevel() }; /* Information about each nest loop in the WHERE */ + }; + + /* + ** A NameContext defines a context in which to resolve table and column + ** names. The context consists of a list of tables (the pSrcList) field and + ** a list of named expression (pEList). The named expression list may + ** be NULL. The pSrc corresponds to the FROM clause of a SELECT or + ** to the table being operated on by INSERT, UPDATE, or DELETE. The + ** pEList corresponds to the result set of a SELECT and is NULL for + ** other statements. + ** + ** NameContexts can be nested. When resolving names, the inner-most + ** context is searched first. If no match is found, the next outer + ** context is checked. If there is still no match, the next context + ** is checked. This process continues until either a match is found + ** or all contexts are check. When a match is found, the nRef member of + ** the context containing the match is incremented. + ** + ** Each subquery gets a new NameContext. The pNext field points to the + ** NameContext in the parent query. Thus the process of scanning the + ** NameContext list corresponds to searching through successively outer + ** subqueries looking for a match. + */ + public class NameContext + { + public Parse pParse; /* The parser */ + public SrcList pSrcList; /* One or more tables used to resolve names */ + public ExprList pEList; /* Optional list of named expressions */ + public int nRef; /* Number of names resolved by this context */ + public int nErr; /* Number of errors encountered while resolving names */ + public u8 allowAgg; /* Aggregate functions allowed here */ + public u8 hasAgg; /* True if aggregates are seen */ + public u8 isCheck; /* True if resolving names in a CHECK constraint */ + public int nDepth; /* Depth of subquery recursion. 1 for no recursion */ + public AggInfo pAggInfo; /* Information about aggregates at this level */ + public NameContext pNext; /* Next outer name context. NULL for outermost */ + }; + + /* + ** An instance of the following structure contains all information + ** needed to generate code for a single SELECT statement. + ** + ** nLimit is set to -1 if there is no LIMIT clause. nOffset is set to 0. + ** If there is a LIMIT clause, the parser sets nLimit to the value of the + ** limit and nOffset to the value of the offset (or 0 if there is not + ** offset). But later on, nLimit and nOffset become the memory locations + ** in the VDBE that record the limit and offset counters. + ** + ** addrOpenEphm[] entries contain the address of OP_OpenEphemeral opcodes. + ** These addresses must be stored so that we can go back and fill in + ** the P4_KEYINFO and P2 parameters later. Neither the KeyInfo nor + ** the number of columns in P2 can be computed at the same time + ** as the OP_OpenEphm instruction is coded because not + ** enough information about the compound query is known at that point. + ** The KeyInfo for addrOpenTran[0] and [1] contains collating sequences + ** for the result set. The KeyInfo for addrOpenTran[2] contains collating + ** sequences for the ORDER BY clause. + */ + public class Select + { + public ExprList pEList; /* The fields of the result */ + public u8 op; /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */ + public char affinity; /* MakeRecord with this affinity for SRT_Set */ + public u16 selFlags; /* Various SF_* values */ + public SrcList pSrc; /* The FROM clause */ + public Expr pWhere; /* The WHERE clause */ + public ExprList pGroupBy; /* The GROUP BY clause */ + public Expr pHaving; /* The HAVING clause */ + public ExprList pOrderBy; /* The ORDER BY clause */ + public Select pPrior; /* Prior select in a compound select statement */ + public Select pNext; /* Next select to the left in a compound */ + public Select pRightmost; /* Right-most select in a compound select statement */ + public Expr pLimit; /* LIMIT expression. NULL means not used. */ + public Expr pOffset; /* OFFSET expression. NULL means not used. */ + public int iLimit; + public int iOffset; /* Memory registers holding LIMIT & OFFSET counters */ + public int[] addrOpenEphm = new int[3]; /* OP_OpenEphem opcodes related to this select */ + public double nSelectRow; /* Estimated number of result rows */ + + public Select Copy() + { + if ( this == null ) + return null; + else + { + Select cp = (Select)MemberwiseClone(); + if ( pEList != null ) + cp.pEList = pEList.Copy(); + if ( pSrc != null ) + cp.pSrc = pSrc.Copy(); + if ( pWhere != null ) + cp.pWhere = pWhere.Copy(); + if ( pGroupBy != null ) + cp.pGroupBy = pGroupBy.Copy(); + if ( pHaving != null ) + cp.pHaving = pHaving.Copy(); + if ( pOrderBy != null ) + cp.pOrderBy = pOrderBy.Copy(); + if ( pPrior != null ) + cp.pPrior = pPrior.Copy(); + if ( pNext != null ) + cp.pNext = pNext.Copy(); + if ( pRightmost != null ) + cp.pRightmost = pRightmost.Copy(); + if ( pLimit != null ) + cp.pLimit = pLimit.Copy(); + if ( pOffset != null ) + cp.pOffset = pOffset.Copy(); + return cp; } - public class WhereLevel { - public WherePlan plan = new WherePlan(); /* query plan for this element of the FROM clause */ - public int iLeftJoin; /* Memory cell used to implement LEFT OUTER JOIN */ - public int iTabCur; /* The VDBE cursor used to access the table */ - public int iIdxCur; /* The VDBE cursor used to access pIdx */ - public int addrBrk; /* Jump here to break out of the loop */ - public int addrNxt; /* Jump here to start the next IN combination */ - public int addrCont; /* Jump here to continue with the next loop cycle */ - public int addrFirst; /* First instruction of interior of the loop */ - public u8 iFrom; /* Which entry in the FROM clause */ - public u8 op, p5; /* Opcode and P5 of the opcode that ends the loop */ - public int p1, p2; /* Operands of the opcode used to ends the loop */ - public class _u { - public class __in /* Information that depends on plan.wsFlags */ - { - public int nIn; /* Number of entries in aInLoop[] */ - public InLoop[] aInLoop; /* Information about each nested IN operator */ - } - public __in _in = new __in(); /* Used when plan.wsFlags&WHERE_IN_ABLE */ - } - public _u u = new _u(); - - - /* The following field is really not part of the current level. But - ** we need a place to cache virtual table index information for each - ** virtual table in the FROM clause and the WhereLevel structure is - ** a convenient place since there is one WhereLevel for each FROM clause - ** element. - */ - public sqlite3_index_info pIdxInfo; /* Index info for n-th source table */ - }; - - /* - ** Flags appropriate for the wctrlFlags parameter of sqlite3WhereBegin() - ** and the WhereInfo.wctrlFlags member. - */ - //#define WHERE_ORDERBY_NORMAL 0x0000 /* No-op */ - //#define WHERE_ORDERBY_MIN 0x0001 /* ORDER BY processing for min() func */ - //#define WHERE_ORDERBY_MAX 0x0002 /* ORDER BY processing for max() func */ - //#define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */ - //#define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */ - //#define WHERE_OMIT_OPEN 0x0010 /* Table cursors are already open */ - //#define WHERE_OMIT_CLOSE 0x0020 /* Omit close of table & index cursors */ - //#define WHERE_FORCE_TABLE 0x0040 /* Do not use an index-only search */ - //#define WHERE_ONETABLE_ONLY 0x0080 /* Only code the 1st table in pTabList */ - const int WHERE_ORDERBY_NORMAL = 0x0000; - const int WHERE_ORDERBY_MIN = 0x0001; - const int WHERE_ORDERBY_MAX = 0x0002; - const int WHERE_ONEPASS_DESIRED = 0x0004; - const int WHERE_DUPLICATES_OK = 0x0008; - const int WHERE_OMIT_OPEN = 0x0010; - const int WHERE_OMIT_CLOSE = 0x0020; - const int WHERE_FORCE_TABLE = 0x0040; - const int WHERE_ONETABLE_ONLY = 0x0080; - - /* - ** The WHERE clause processing routine has two halves. The - ** first part does the start of the WHERE loop and the second - ** half does the tail of the WHERE loop. An instance of - ** this structure is returned by the first half and passed - ** into the second half to give some continuity. - */ - public class WhereInfo { - public Parse pParse; /* Parsing and code generating context */ - public u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */ - public u8 okOnePass; /* Ok to use one-pass algorithm for UPDATE or DELETE */ - public u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */ - public SrcList pTabList; /* List of tables in the join */ - public int iTop; /* The very beginning of the WHERE loop */ - public int iContinue; /* Jump here to continue with next record */ - public int iBreak; /* Jump here to break out of the loop */ - public int nLevel; /* Number of nested loop */ - public WhereClause pWC; /* Decomposition of the WHERE clause */ - public double savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */ - public double nRowOut; /* Estimated number of output rows */ - public WhereLevel[] a = new WhereLevel[] { new WhereLevel() }; /* Information about each nest loop in the WHERE */ - }; - - /* - ** A NameContext defines a context in which to resolve table and column - ** names. The context consists of a list of tables (the pSrcList) field and - ** a list of named expression (pEList). The named expression list may - ** be NULL. The pSrc corresponds to the FROM clause of a SELECT or - ** to the table being operated on by INSERT, UPDATE, or DELETE. The - ** pEList corresponds to the result set of a SELECT and is NULL for - ** other statements. - ** - ** NameContexts can be nested. When resolving names, the inner-most - ** context is searched first. If no match is found, the next outer - ** context is checked. If there is still no match, the next context - ** is checked. This process continues until either a match is found - ** or all contexts are check. When a match is found, the nRef member of - ** the context containing the match is incremented. - ** - ** Each subquery gets a new NameContext. The pNext field points to the - ** NameContext in the parent query. Thus the process of scanning the - ** NameContext list corresponds to searching through successively outer - ** subqueries looking for a match. - */ - public class NameContext { - public Parse pParse; /* The parser */ - public SrcList pSrcList; /* One or more tables used to resolve names */ - public ExprList pEList; /* Optional list of named expressions */ - public int nRef; /* Number of names resolved by this context */ - public int nErr; /* Number of errors encountered while resolving names */ - public u8 allowAgg; /* Aggregate functions allowed here */ - public u8 hasAgg; /* True if aggregates are seen */ - public u8 isCheck; /* True if resolving names in a CHECK constraint */ - public int nDepth; /* Depth of subquery recursion. 1 for no recursion */ - public AggInfo pAggInfo; /* Information about aggregates at this level */ - public NameContext pNext; /* Next outer name context. NULL for outermost */ - }; - - /* - ** An instance of the following structure contains all information - ** needed to generate code for a single SELECT statement. - ** - ** nLimit is set to -1 if there is no LIMIT clause. nOffset is set to 0. - ** If there is a LIMIT clause, the parser sets nLimit to the value of the - ** limit and nOffset to the value of the offset (or 0 if there is not - ** offset). But later on, nLimit and nOffset become the memory locations - ** in the VDBE that record the limit and offset counters. - ** - ** addrOpenEphm[] entries contain the address of OP_OpenEphemeral opcodes. - ** These addresses must be stored so that we can go back and fill in - ** the P4_KEYINFO and P2 parameters later. Neither the KeyInfo nor - ** the number of columns in P2 can be computed at the same time - ** as the OP_OpenEphm instruction is coded because not - ** enough information about the compound query is known at that point. - ** The KeyInfo for addrOpenTran[0] and [1] contains collating sequences - ** for the result set. The KeyInfo for addrOpenTran[2] contains collating - ** sequences for the ORDER BY clause. - */ - public class Select { - public ExprList pEList; /* The fields of the result */ - public u8 op; /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */ - public char affinity; /* MakeRecord with this affinity for SRT_Set */ - public u16 selFlags; /* Various SF_* values */ - public SrcList pSrc; /* The FROM clause */ - public Expr pWhere; /* The WHERE clause */ - public ExprList pGroupBy; /* The GROUP BY clause */ - public Expr pHaving; /* The HAVING clause */ - public ExprList pOrderBy; /* The ORDER BY clause */ - public Select pPrior; /* Prior select in a compound select statement */ - public Select pNext; /* Next select to the left in a compound */ - public Select pRightmost; /* Right-most select in a compound select statement */ - public Expr pLimit; /* LIMIT expression. NULL means not used. */ - public Expr pOffset; /* OFFSET expression. NULL means not used. */ - public int iLimit; - public int iOffset; /* Memory registers holding LIMIT & OFFSET counters */ - public int[] addrOpenEphm = new int[3]; /* OP_OpenEphem opcodes related to this select */ - public double nSelectRow; /* Estimated number of result rows */ - - public Select Copy() { - if (this == null) - return null; - else { - Select cp = (Select)MemberwiseClone(); - if (pEList != null) - cp.pEList = pEList.Copy(); - if (pSrc != null) - cp.pSrc = pSrc.Copy(); - if (pWhere != null) - cp.pWhere = pWhere.Copy(); - if (pGroupBy != null) - cp.pGroupBy = pGroupBy.Copy(); - if (pHaving != null) - cp.pHaving = pHaving.Copy(); - if (pOrderBy != null) - cp.pOrderBy = pOrderBy.Copy(); - if (pPrior != null) - cp.pPrior = pPrior.Copy(); - if (pNext != null) - cp.pNext = pNext.Copy(); - if (pRightmost != null) - cp.pRightmost = pRightmost.Copy(); - if (pLimit != null) - cp.pLimit = pLimit.Copy(); - if (pOffset != null) - cp.pOffset = pOffset.Copy(); - return cp; - } - } - }; - - /* - ** Allowed values for Select.selFlags. The "SF" prefix stands for - ** "Select Flag". - */ - //#define SF_Distinct 0x0001 /* Output should be DISTINCT */ - //#define SF_Resolved 0x0002 /* Identifiers have been resolved */ - //#define SF_Aggregate 0x0004 /* Contains aggregate functions */ - //#define SF_UsesEphemeral 0x0008 /* Uses the OpenEphemeral opcode */ - //#define SF_Expanded 0x0010 /* sqlite3SelectExpand() called on this */ - //#define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */ - const int SF_Distinct = 0x0001; /* Output should be DISTINCT */ - const int SF_Resolved = 0x0002; /* Identifiers have been resolved */ - const int SF_Aggregate = 0x0004; /* Contains aggregate functions */ - const int SF_UsesEphemeral = 0x0008; /* Uses the OpenEphemeral opcode */ - const int SF_Expanded = 0x0010; /* sqlite3SelectExpand() called on this */ - const int SF_HasTypeInfo = 0x0020; /* FROM subqueries have Table metadata */ - - - /* - ** The results of a select can be distributed in several ways. The - ** "SRT" prefix means "SELECT Result Type". - */ - const int SRT_Union = 1;//#define SRT_Union 1 /* Store result as keys in an index */ - const int SRT_Except = 2;//#define SRT_Except 2 /* Remove result from a UNION index */ - const int SRT_Exists = 3;//#define SRT_Exists 3 /* Store 1 if the result is not empty */ - const int SRT_Discard = 4;//#define SRT_Discard 4 /* Do not save the results anywhere */ - - /* The ORDER BY clause is ignored for all of the above */ - //#define IgnorableOrderby(X) ((X->eDest)<=SRT_Discard) - - const int SRT_Output = 5;//#define SRT_Output 5 /* Output each row of result */ - const int SRT_Mem = 6;//#define SRT_Mem 6 /* Store result in a memory cell */ - const int SRT_Set = 7;//#define SRT_Set 7 /* Store results as keys in an index */ - const int SRT_Table = 8;//#define SRT_Table 8 /* Store result as data with an automatic rowid */ - const int SRT_EphemTab = 9;//#define SRT_EphemTab 9 /* Create transient tab and store like SRT_Table / - const int SRT_Coroutine = 10;//#define SRT_Coroutine 10 /* Generate a single row of result */ - - /* - ** A structure used to customize the behavior of sqlite3Select(). See - ** comments above sqlite3Select() for details. - */ - //typedef struct SelectDest SelectDest; - public class SelectDest { - public u8 eDest; /* How to dispose of the results */ - public char affinity; /* Affinity used when eDest==SRT_Set */ - public int iParm; /* A parameter used by the eDest disposal method */ - public int iMem; /* Base register where results are written */ - public int nMem; /* Number of registers allocated */ - public SelectDest() { - this.eDest = 0; - this.affinity = '\0'; - this.iParm = 0; - this.iMem = 0; - this.nMem = 0; - } - public SelectDest(u8 eDest, char affinity, int iParm) { - this.eDest = eDest; - this.affinity = affinity; - this.iParm = iParm; - this.iMem = 0; - this.nMem = 0; - } - public SelectDest(u8 eDest, char affinity, int iParm, int iMem, int nMem) { - this.eDest = eDest; - this.affinity = affinity; - this.iParm = iParm; - this.iMem = iMem; - this.nMem = nMem; - } - }; - - /* - ** During code generation of statements that do inserts into AUTOINCREMENT - ** tables, the following information is attached to the Table.u.autoInc.p - ** pointer of each autoincrement table to record some side information that - ** the code generator needs. We have to keep per-table autoincrement - ** information in case inserts are down within triggers. Triggers do not - ** normally coordinate their activities, but we do need to coordinate the - ** loading and saving of autoincrement information. - */ - public class AutoincInfo { - public AutoincInfo pNext; /* Next info block in a list of them all */ - public Table pTab; /* Table this info block refers to */ - public int iDb; /* Index in sqlite3.aDb[] of database holding pTab */ - public int regCtr; /* Memory register holding the rowid counter */ - }; - - /* - ** Size of the column cache - */ + } + }; + + /* + ** Allowed values for Select.selFlags. The "SF" prefix stands for + ** "Select Flag". + */ + //#define SF_Distinct 0x0001 /* Output should be DISTINCT */ + //#define SF_Resolved 0x0002 /* Identifiers have been resolved */ + //#define SF_Aggregate 0x0004 /* Contains aggregate functions */ + //#define SF_UsesEphemeral 0x0008 /* Uses the OpenEphemeral opcode */ + //#define SF_Expanded 0x0010 /* sqlite3SelectExpand() called on this */ + //#define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */ + const int SF_Distinct = 0x0001; /* Output should be DISTINCT */ + const int SF_Resolved = 0x0002; /* Identifiers have been resolved */ + const int SF_Aggregate = 0x0004; /* Contains aggregate functions */ + const int SF_UsesEphemeral = 0x0008; /* Uses the OpenEphemeral opcode */ + const int SF_Expanded = 0x0010; /* sqlite3SelectExpand() called on this */ + const int SF_HasTypeInfo = 0x0020; /* FROM subqueries have Table metadata */ + + + /* + ** The results of a select can be distributed in several ways. The + ** "SRT" prefix means "SELECT Result Type". + */ + const int SRT_Union = 1;//#define SRT_Union 1 /* Store result as keys in an index */ + const int SRT_Except = 2;//#define SRT_Except 2 /* Remove result from a UNION index */ + const int SRT_Exists = 3;//#define SRT_Exists 3 /* Store 1 if the result is not empty */ + const int SRT_Discard = 4;//#define SRT_Discard 4 /* Do not save the results anywhere */ + + /* The ORDER BY clause is ignored for all of the above */ + //#define IgnorableOrderby(X) ((X->eDest)<=SRT_Discard) + + const int SRT_Output = 5;//#define SRT_Output 5 /* Output each row of result */ + const int SRT_Mem = 6;//#define SRT_Mem 6 /* Store result in a memory cell */ + const int SRT_Set = 7;//#define SRT_Set 7 /* Store results as keys in an index */ + const int SRT_Table = 8;//#define SRT_Table 8 /* Store result as data with an automatic rowid */ + const int SRT_EphemTab = 9;//#define SRT_EphemTab 9 /* Create transient tab and store like SRT_Table / + const int SRT_Coroutine = 10;//#define SRT_Coroutine 10 /* Generate a single row of result */ + + /* + ** A structure used to customize the behavior of sqlite3Select(). See + ** comments above sqlite3Select() for details. + */ + //typedef struct SelectDest SelectDest; + public class SelectDest + { + public u8 eDest; /* How to dispose of the results */ + public char affinity; /* Affinity used when eDest==SRT_Set */ + public int iParm; /* A parameter used by the eDest disposal method */ + public int iMem; /* Base register where results are written */ + public int nMem; /* Number of registers allocated */ + public SelectDest() + { + this.eDest = 0; + this.affinity = '\0'; + this.iParm = 0; + this.iMem = 0; + this.nMem = 0; + } + public SelectDest( u8 eDest, char affinity, int iParm ) + { + this.eDest = eDest; + this.affinity = affinity; + this.iParm = iParm; + this.iMem = 0; + this.nMem = 0; + } + public SelectDest( u8 eDest, char affinity, int iParm, int iMem, int nMem ) + { + this.eDest = eDest; + this.affinity = affinity; + this.iParm = iParm; + this.iMem = iMem; + this.nMem = nMem; + } + }; + + /* + ** During code generation of statements that do inserts into AUTOINCREMENT + ** tables, the following information is attached to the Table.u.autoInc.p + ** pointer of each autoincrement table to record some side information that + ** the code generator needs. We have to keep per-table autoincrement + ** information in case inserts are down within triggers. Triggers do not + ** normally coordinate their activities, but we do need to coordinate the + ** loading and saving of autoincrement information. + */ + public class AutoincInfo + { + public AutoincInfo pNext; /* Next info block in a list of them all */ + public Table pTab; /* Table this info block refers to */ + public int iDb; /* Index in sqlite3.aDb[] of database holding pTab */ + public int regCtr; /* Memory register holding the rowid counter */ + }; + + /* + ** Size of the column cache + */ #if !SQLITE_N_COLCACHE - //# define SQLITE_N_COLCACHE 10 - const int SQLITE_N_COLCACHE = 10; + //# define SQLITE_N_COLCACHE 10 + const int SQLITE_N_COLCACHE = 10; #endif - /* - ** At least one instance of the following structure is created for each - ** trigger that may be fired while parsing an INSERT, UPDATE or DELETE - ** statement. All such objects are stored in the linked list headed at - ** Parse.pTriggerPrg and deleted once statement compilation has been - ** completed. + /* +** At least one instance of the following structure is created for each +** trigger that may be fired while parsing an INSERT, UPDATE or DELETE +** statement. All such objects are stored in the linked list headed at +** Parse.pTriggerPrg and deleted once statement compilation has been +** completed. +** +** A Vdbe sub-program that implements the body and WHEN clause of trigger +** TriggerPrg.pTrigger, assuming a default ON CONFLICT clause of +** TriggerPrg.orconf, is stored in the TriggerPrg.pProgram variable. +** The Parse.pTriggerPrg list never contains two entries with the same +** values for both pTrigger and orconf. +** +** The TriggerPrg.aColmask[0] variable is set to a mask of old.* columns +** accessed (or set to 0 for triggers fired as a result of INSERT +** statements). Similarly, the TriggerPrg.aColmask[1] variable is set to +** a mask of new.* columns used by the program. +*/ + public class TriggerPrg + { + public Trigger pTrigger; /* Trigger this program was coded from */ + public int orconf; /* Default ON CONFLICT policy */ + public SubProgram pProgram; /* Program implementing pTrigger/orconf */ + public u32[] aColmask = new u32[2]; /* Masks of old.*, new.* columns accessed */ + public TriggerPrg pNext; /* Next entry in Parse.pTriggerPrg list */ + }; + + /* + ** The yDbMask datatype for the bitmask of all attached databases. + */ + //#if SQLITE_MAX_ATTACHED>30 + // typedef sqlite3_uint64 yDbMask; + //#else + // typedef unsigned int yDbMask; + //#endif + + /* + ** An SQL parser context. A copy of this structure is passed through + ** the parser and down into all the parser action routine in order to + ** carry around information that is global to the entire parse. ** - ** A Vdbe sub-program that implements the body and WHEN clause of trigger - ** TriggerPrg.pTrigger, assuming a default ON CONFLICT clause of - ** TriggerPrg.orconf, is stored in the TriggerPrg.pProgram variable. - ** The Parse.pTriggerPrg list never contains two entries with the same - ** values for both pTrigger and orconf. + ** The structure is divided into two parts. When the parser and code + ** generate call themselves recursively, the first part of the structure + ** is constant but the second part is reset at the beginning and end of + ** each recursion. ** - ** The TriggerPrg.aColmask[0] variable is set to a mask of old.* columns - ** accessed (or set to 0 for triggers fired as a result of INSERT - ** statements). Similarly, the TriggerPrg.aColmask[1] variable is set to - ** a mask of new.* columns used by the program. + ** The nTableLock and aTableLock variables are only used if the shared-cache + ** feature is enabled (if sqlite3Tsd()->useSharedData is true). They are + ** used to store the set of table-locks required by the statement being + ** compiled. Function sqlite3TableLock() is used to add entries to the + ** list. */ - public class TriggerPrg { - public Trigger pTrigger; /* Trigger this program was coded from */ - public int orconf; /* Default ON CONFLICT policy */ - public SubProgram pProgram; /* Program implementing pTrigger/orconf */ - public u32[] aColmask = new u32[2]; /* Masks of old.*, new.* columns accessed */ - public TriggerPrg pNext; /* Next entry in Parse.pTriggerPrg list */ - }; - - /* - ** The yDbMask datatype for the bitmask of all attached databases. - */ - //#if SQLITE_MAX_ATTACHED>30 - // typedef sqlite3_uint64 yDbMask; - //#else - // typedef unsigned int yDbMask; - //#endif - - /* - ** An SQL parser context. A copy of this structure is passed through - ** the parser and down into all the parser action routine in order to - ** carry around information that is global to the entire parse. - ** - ** The structure is divided into two parts. When the parser and code - ** generate call themselves recursively, the first part of the structure - ** is constant but the second part is reset at the beginning and end of - ** each recursion. - ** - ** The nTableLock and aTableLock variables are only used if the shared-cache - ** feature is enabled (if sqlite3Tsd()->useSharedData is true). They are - ** used to store the set of table-locks required by the statement being - ** compiled. Function sqlite3TableLock() is used to add entries to the - ** list. - */ - public class yColCache { - public int iTable; /* Table cursor number */ - public int iColumn; /* Table column number */ - public u8 tempReg; /* iReg is a temp register that needs to be freed */ - public int iLevel; /* Nesting level */ - public int iReg; /* Reg with value of this column. 0 means none. */ - public int lru; /* Least recently used entry has the smallest value */ - } + public class yColCache + { + public int iTable; /* Table cursor number */ + public int iColumn; /* Table column number */ + public u8 tempReg; /* iReg is a temp register that needs to be freed */ + public int iLevel; /* Nesting level */ + public int iReg; /* Reg with value of this column. 0 means none. */ + public int lru; /* Least recently used entry has the smallest value */ + } - public class Parse { - public sqlite3 db; /* The main database structure */ - public int rc; /* Return code from execution */ - public string zErrMsg; /* An error message */ - public Vdbe pVdbe; /* An engine for executing database bytecode */ - public u8 colNamesSet; /* TRUE after OP_ColumnName has been issued to pVdbe */ - public u8 nameClash; /* A permanent table name clashes with temp table name */ - public u8 checkSchema; /* Causes schema cookie check after an error */ - public u8 nested; /* Number of nested calls to the parser/code generator */ - public u8 parseError; /* True after a parsing error. Ticket #1794 */ - public u8 nTempReg; /* Number of temporary registers in aTempReg[] */ - public u8 nTempInUse; /* Number of aTempReg[] currently checked out */ - public int[] aTempReg; /* Holding area for temporary registers */ - public int nRangeReg; /* Size of the temporary register block */ - public int iRangeReg; /* First register in temporary register block */ - public int nErr; /* Number of errors seen */ - public int nTab; /* Number of previously allocated VDBE cursors */ - public int nMem; /* Number of memory cells used so far */ - public int nSet; /* Number of sets used so far */ - public int ckBase; /* Base register of data during check constraints */ - public int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */ - public int iCacheCnt; /* Counter used to generate aColCache[].lru values */ - public u8 nColCache; /* Number of entries in the column cache */ - public u8 iColCache; /* Next entry of the cache to replace */ - public yColCache[] aColCache;/* One for each valid column cache entry */ - public yDbMask writeMask; /* Start a write transaction on these databases */ - public yDbMask cookieMask; /* Bitmask of schema verified databases */ - public u8 isMultiWrite; /* True if statement may affect/insert multiple rows */ - public u8 mayAbort; /* True if statement may throw an ABORT exception */ - public int cookieGoto; /* Address of OP_Goto to cookie verifier subroutine */ - public int[] cookieValue; /* Values of cookies to verify */ + public class Parse + { + public sqlite3 db; /* The main database structure */ + public int rc; /* Return code from execution */ + public string zErrMsg; /* An error message */ + public Vdbe pVdbe; /* An engine for executing database bytecode */ + public u8 colNamesSet; /* TRUE after OP_ColumnName has been issued to pVdbe */ + public u8 nameClash; /* A permanent table name clashes with temp table name */ + public u8 checkSchema; /* Causes schema cookie check after an error */ + public u8 nested; /* Number of nested calls to the parser/code generator */ + public u8 parseError; /* True after a parsing error. Ticket #1794 */ + public u8 nTempReg; /* Number of temporary registers in aTempReg[] */ + public u8 nTempInUse; /* Number of aTempReg[] currently checked out */ + public int[] aTempReg; /* Holding area for temporary registers */ + public int nRangeReg; /* Size of the temporary register block */ + public int iRangeReg; /* First register in temporary register block */ + public int nErr; /* Number of errors seen */ + public int nTab; /* Number of previously allocated VDBE cursors */ + public int nMem; /* Number of memory cells used so far */ + public int nSet; /* Number of sets used so far */ + public int ckBase; /* Base register of data during check constraints */ + public int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */ + public int iCacheCnt; /* Counter used to generate aColCache[].lru values */ + public u8 nColCache; /* Number of entries in the column cache */ + public u8 iColCache; /* Next entry of the cache to replace */ + public yColCache[] aColCache;/* One for each valid column cache entry */ + public yDbMask writeMask; /* Start a write transaction on these databases */ + public yDbMask cookieMask; /* Bitmask of schema verified databases */ + public u8 isMultiWrite; /* True if statement may affect/insert multiple rows */ + public u8 mayAbort; /* True if statement may throw an ABORT exception */ + public int cookieGoto; /* Address of OP_Goto to cookie verifier subroutine */ + public int[] cookieValue; /* Values of cookies to verify */ #if !SQLITE_OMIT_SHARED_CACHE public int nTableLock; /* Number of locks in aTableLock */ public TableLock[] aTableLock; /* Required table locks for shared-cache mode */ #endif - public int regRowid; /* Register holding rowid of CREATE TABLE entry */ - public int regRoot; /* Register holding root page number for new objects */ - public AutoincInfo pAinc; /* Information about AUTOINCREMENT counters */ - public int nMaxArg; /* Max args passed to user function by sub-program */ - - /* Information used while coding trigger programs. */ - public Parse pToplevel; /* Parse structure for main program (or NULL) */ - public Table pTriggerTab; /* Table triggers are being coded for */ - public u32 oldmask; /* Mask of old.* columns referenced */ - public u32 newmask; /* Mask of new.* columns referenced */ - public u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */ - public u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */ - public u8 disableTriggers; /* True to disable triggers */ - public double nQueryLoop; /* Estimated number of iterations of a query */ - - /* Above is constant between recursions. Below is reset before and after - ** each recursion */ - - public int nVar; /* Number of '?' variables seen in the SQL so far */ - public int nzVar; /* Number of available slots in azVar[] */ - public string[] azVar; /* Pointers to names of parameters */ - public Vdbe pReprepare; /* VM being reprepared (sqlite3Reprepare()) */ - public int nAlias; /* Number of aliased result set columns */ - public int nAliasAlloc; /* Number of allocated slots for aAlias[] */ - public int[] aAlias; /* Register used to hold aliased result */ - public u8 explain; /* True if the EXPLAIN flag is found on the query */ - public Token sNameToken; /* Token with unqualified schema object name */ - public Token sLastToken; /* The last token parsed */ - public StringBuilder zTail; /* All SQL text past the last semicolon parsed */ - public Table pNewTable; /* A table being constructed by CREATE TABLE */ - public Trigger pNewTrigger; /* Trigger under construct by a CREATE TRIGGER */ - public string zAuthContext; /* The 6th parameter to db.xAuth callbacks */ + public int regRowid; /* Register holding rowid of CREATE TABLE entry */ + public int regRoot; /* Register holding root page number for new objects */ + public AutoincInfo pAinc; /* Information about AUTOINCREMENT counters */ + public int nMaxArg; /* Max args passed to user function by sub-program */ + + /* Information used while coding trigger programs. */ + public Parse pToplevel; /* Parse structure for main program (or NULL) */ + public Table pTriggerTab; /* Table triggers are being coded for */ + public u32 oldmask; /* Mask of old.* columns referenced */ + public u32 newmask; /* Mask of new.* columns referenced */ + public u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */ + public u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */ + public u8 disableTriggers; /* True to disable triggers */ + public double nQueryLoop; /* Estimated number of iterations of a query */ + + /* Above is constant between recursions. Below is reset before and after + ** each recursion */ + + public int nVar; /* Number of '?' variables seen in the SQL so far */ + public int nzVar; /* Number of available slots in azVar[] */ + public string[] azVar; /* Pointers to names of parameters */ + public Vdbe pReprepare; /* VM being reprepared (sqlite3Reprepare()) */ + public int nAlias; /* Number of aliased result set columns */ + public int nAliasAlloc; /* Number of allocated slots for aAlias[] */ + public int[] aAlias; /* Register used to hold aliased result */ + public u8 explain; /* True if the EXPLAIN flag is found on the query */ + public Token sNameToken; /* Token with unqualified schema object name */ + public Token sLastToken; /* The last token parsed */ + public StringBuilder zTail; /* All SQL text past the last semicolon parsed */ + public Table pNewTable; /* A table being constructed by CREATE TABLE */ + public Trigger pNewTrigger; /* Trigger under construct by a CREATE TRIGGER */ + public string zAuthContext; /* The 6th parameter to db.xAuth callbacks */ #if !SQLITE_OMIT_VIRTUALTABLE - public Token sArg; /* Complete text of a module argument */ - public u8 declareVtab; /* True if inside sqlite3_declare_vtab() */ - public int nVtabLock; /* Number of virtual tables to lock */ - public Table[] apVtabLock; /* Pointer to virtual tables needing locking */ + public Token sArg; /* Complete text of a module argument */ + public u8 declareVtab; /* True if inside sqlite3_declare_vtab() */ + public int nVtabLock; /* Number of virtual tables to lock */ + public Table[] apVtabLock; /* Pointer to virtual tables needing locking */ #endif - public int nHeight; /* Expression tree height of current sub-select */ - public Table pZombieTab; /* List of Table objects to delete after code gen */ - public TriggerPrg pTriggerPrg; /* Linked list of coded triggers */ + public int nHeight; /* Expression tree height of current sub-select */ + public Table pZombieTab; /* List of Table objects to delete after code gen */ + public TriggerPrg pTriggerPrg; /* Linked list of coded triggers */ #if !SQLITE_OMIT_EXPLAIN - public int iSelectId; - public int iNextSelectId; + public int iSelectId; + public int iNextSelectId; #endif - // We need to create instances of the col cache - public Parse() { - aTempReg = new int[8]; /* Holding area for temporary registers */ + // We need to create instances of the col cache + public Parse() + { + aTempReg = new int[8]; /* Holding area for temporary registers */ - aColCache = new yColCache[SQLITE_N_COLCACHE]; /* One for each valid column cache entry */ - for (int i = 0; i < this.aColCache.Length; i++) { - this.aColCache[i] = new yColCache(); - } + aColCache = new yColCache[SQLITE_N_COLCACHE]; /* One for each valid column cache entry */ + for ( int i = 0; i < this.aColCache.Length; i++ ) + { + this.aColCache[i] = new yColCache(); + } - cookieValue = new int[SQLITE_MAX_ATTACHED + 2]; /* Values of cookies to verify */ + cookieValue = new int[SQLITE_MAX_ATTACHED + 2]; /* Values of cookies to verify */ - sLastToken = new Token(); /* The last token parsed */ + sLastToken = new Token(); /* The last token parsed */ #if !SQLITE_OMIT_VIRTUALTABLE - sArg = new Token(); + sArg = new Token(); #endif - } - - public void ResetMembers() // Need to clear all the following variables during each recursion - { - nVar = 0; - nzVar = 0; - azVar = null; - nAlias = 0; - nAliasAlloc = 0; - aAlias = null; - explain = 0; - sNameToken = new Token(); - sLastToken = new Token(); - zTail.Length = 0; - pNewTable = null; - pNewTrigger = null; - zAuthContext = null; + } + + public void ResetMembers() // Need to clear all the following variables during each recursion + { + nVar = 0; + nzVar = 0; + azVar = null; + nAlias = 0; + nAliasAlloc = 0; + aAlias = null; + explain = 0; + sNameToken = new Token(); + sLastToken = new Token(); + zTail.Length = 0; + pNewTable = null; + pNewTrigger = null; + zAuthContext = null; #if !SQLITE_OMIT_VIRTUALTABLE - sArg = new Token(); - declareVtab = 0; - nVtabLock = 0; - apVtabLock = null; + sArg = new Token(); + declareVtab = 0; + nVtabLock = 0; + apVtabLock = null; #endif - nHeight = 0; - pZombieTab = null; - pTriggerPrg = null; - } - Parse[] SaveBuf = new Parse[10]; //For Recursion Storage - public void RestoreMembers() // Need to clear all the following variables during each recursion - { - if (SaveBuf[nested] != null) { - nVar = SaveBuf[nested].nVar; - nzVar = SaveBuf[nested].nzVar; - azVar = SaveBuf[nested].azVar; - nAlias = SaveBuf[nested].nAlias; - nAliasAlloc = SaveBuf[nested].nAliasAlloc; - aAlias = SaveBuf[nested].aAlias; - explain = SaveBuf[nested].explain; - sNameToken = SaveBuf[nested].sNameToken; - sLastToken = SaveBuf[nested].sLastToken; - zTail = SaveBuf[nested].zTail; - pNewTable = SaveBuf[nested].pNewTable; - pNewTrigger = SaveBuf[nested].pNewTrigger; - zAuthContext = SaveBuf[nested].zAuthContext; + nHeight = 0; + pZombieTab = null; + pTriggerPrg = null; + } + Parse[] SaveBuf = new Parse[10]; //For Recursion Storage + public void RestoreMembers() // Need to clear all the following variables during each recursion + { + if ( SaveBuf[nested] != null ) + { + nVar = SaveBuf[nested].nVar; + nzVar = SaveBuf[nested].nzVar; + azVar = SaveBuf[nested].azVar; + nAlias = SaveBuf[nested].nAlias; + nAliasAlloc = SaveBuf[nested].nAliasAlloc; + aAlias = SaveBuf[nested].aAlias; + explain = SaveBuf[nested].explain; + sNameToken = SaveBuf[nested].sNameToken; + sLastToken = SaveBuf[nested].sLastToken; + zTail = SaveBuf[nested].zTail; + pNewTable = SaveBuf[nested].pNewTable; + pNewTrigger = SaveBuf[nested].pNewTrigger; + zAuthContext = SaveBuf[nested].zAuthContext; #if !SQLITE_OMIT_VIRTUALTABLE - sArg = SaveBuf[nested].sArg; - declareVtab = SaveBuf[nested].declareVtab; - nVtabLock = SaveBuf[nested].nVtabLock; - apVtabLock = SaveBuf[nested].apVtabLock; + sArg = SaveBuf[nested].sArg; + declareVtab = SaveBuf[nested].declareVtab; + nVtabLock = SaveBuf[nested].nVtabLock; + apVtabLock = SaveBuf[nested].apVtabLock; #endif - nHeight = SaveBuf[nested].nHeight; - pZombieTab = SaveBuf[nested].pZombieTab; - pTriggerPrg = SaveBuf[nested].pTriggerPrg; - SaveBuf[nested] = null; - } - } - public void SaveMembers() // Need to clear all the following variables during each recursion - { - SaveBuf[nested] = new Parse(); - SaveBuf[nested].nVar = nVar; - SaveBuf[nested].nzVar = nzVar; - SaveBuf[nested].azVar = azVar; - SaveBuf[nested].nAlias = nAlias; - SaveBuf[nested].nAliasAlloc = nAliasAlloc; - SaveBuf[nested].aAlias = aAlias; - SaveBuf[nested].explain = explain; - SaveBuf[nested].sNameToken = sNameToken; - SaveBuf[nested].sLastToken = sLastToken; - SaveBuf[nested].zTail = zTail; - SaveBuf[nested].pNewTable = pNewTable; - SaveBuf[nested].pNewTrigger = pNewTrigger; - SaveBuf[nested].zAuthContext = zAuthContext; + nHeight = SaveBuf[nested].nHeight; + pZombieTab = SaveBuf[nested].pZombieTab; + pTriggerPrg = SaveBuf[nested].pTriggerPrg; + SaveBuf[nested] = null; + } + } + public void SaveMembers() // Need to clear all the following variables during each recursion + { + SaveBuf[nested] = new Parse(); + SaveBuf[nested].nVar = nVar; + SaveBuf[nested].nzVar = nzVar; + SaveBuf[nested].azVar = azVar; + SaveBuf[nested].nAlias = nAlias; + SaveBuf[nested].nAliasAlloc = nAliasAlloc; + SaveBuf[nested].aAlias = aAlias; + SaveBuf[nested].explain = explain; + SaveBuf[nested].sNameToken = sNameToken; + SaveBuf[nested].sLastToken = sLastToken; + SaveBuf[nested].zTail = zTail; + SaveBuf[nested].pNewTable = pNewTable; + SaveBuf[nested].pNewTrigger = pNewTrigger; + SaveBuf[nested].zAuthContext = zAuthContext; #if !SQLITE_OMIT_VIRTUALTABLE - SaveBuf[nested].sArg = sArg; - SaveBuf[nested].declareVtab = declareVtab; - SaveBuf[nested].nVtabLock = nVtabLock; - SaveBuf[nested].apVtabLock = apVtabLock; + SaveBuf[nested].sArg = sArg; + SaveBuf[nested].declareVtab = declareVtab; + SaveBuf[nested].nVtabLock = nVtabLock; + SaveBuf[nested].apVtabLock = apVtabLock; #endif - SaveBuf[nested].nHeight = nHeight; - SaveBuf[nested].pZombieTab = pZombieTab; - SaveBuf[nested].pTriggerPrg = pTriggerPrg; - } - }; + SaveBuf[nested].nHeight = nHeight; + SaveBuf[nested].pZombieTab = pZombieTab; + SaveBuf[nested].pTriggerPrg = pTriggerPrg; + } + }; #if SQLITE_OMIT_VIRTUALTABLE //#define IN_DECLARE_VTAB 0 @@ -3066,490 +3197,528 @@ static bool IN_DECLARE_VTAB( Parse pParse ) return false; } #else - //#define IN_DECLARE_VTAB (pParse.declareVtab) - static bool IN_DECLARE_VTAB(Parse pParse) { - return pParse.declareVtab != 0; - } + //#define IN_DECLARE_VTAB (pParse.declareVtab) + static bool IN_DECLARE_VTAB( Parse pParse ) + { + return pParse.declareVtab != 0; + } #endif - /* - ** An instance of the following structure can be declared on a stack and used - ** to save the Parse.zAuthContext value so that it can be restored later. + /* +** An instance of the following structure can be declared on a stack and used +** to save the Parse.zAuthContext value so that it can be restored later. +*/ + public class AuthContext + { + public string zAuthContext; /* Put saved Parse.zAuthContext here */ + public Parse pParse; /* The Parse structure */ + }; + + /* + ** Bitfield flags for P5 value in OP_Insert and OP_Delete + */ + //#define OPFLAG_NCHANGE 0x01 /* Set to update db->nChange */ + //#define OPFLAG_LASTROWID 0x02 /* Set to update db->lastRowid */ + //#define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */ + //#define OPFLAG_APPEND 0x08 /* This is likely to be an append */ + //#define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */ + //#define OPFLAG_CLEARCACHE 0x20 /* Clear pseudo-table cache in OP_Column */ + const byte OPFLAG_NCHANGE = 0x01; + const byte OPFLAG_LASTROWID = 0x02; + const byte OPFLAG_ISUPDATE = 0x04; + const byte OPFLAG_APPEND = 0x08; + const byte OPFLAG_USESEEKRESULT = 0x10; + const byte OPFLAG_CLEARCACHE = 0x20; + + /* + * Each trigger present in the database schema is stored as an instance of + * struct Trigger. + * + * Pointers to instances of struct Trigger are stored in two ways. + * 1. In the "trigHash" hash table (part of the sqlite3* that represents the + * database). This allows Trigger structures to be retrieved by name. + * 2. All triggers associated with a single table form a linked list, using the + * pNext member of struct Trigger. A pointer to the first element of the + * linked list is stored as the "pTrigger" member of the associated + * struct Table. + * + * The "step_list" member points to the first element of a linked list + * containing the SQL statements specified as the trigger program. */ - public class AuthContext { - public string zAuthContext; /* Put saved Parse.zAuthContext here */ - public Parse pParse; /* The Parse structure */ - }; - - /* - ** Bitfield flags for P5 value in OP_Insert and OP_Delete - */ - //#define OPFLAG_NCHANGE 0x01 /* Set to update db->nChange */ - //#define OPFLAG_LASTROWID 0x02 /* Set to update db->lastRowid */ - //#define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */ - //#define OPFLAG_APPEND 0x08 /* This is likely to be an append */ - //#define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */ - //#define OPFLAG_CLEARCACHE 0x20 /* Clear pseudo-table cache in OP_Column */ - const byte OPFLAG_NCHANGE = 0x01; - const byte OPFLAG_LASTROWID = 0x02; - const byte OPFLAG_ISUPDATE = 0x04; - const byte OPFLAG_APPEND = 0x08; - const byte OPFLAG_USESEEKRESULT = 0x10; - const byte OPFLAG_CLEARCACHE = 0x20; - - /* - * Each trigger present in the database schema is stored as an instance of - * struct Trigger. - * - * Pointers to instances of struct Trigger are stored in two ways. - * 1. In the "trigHash" hash table (part of the sqlite3* that represents the - * database). This allows Trigger structures to be retrieved by name. - * 2. All triggers associated with a single table form a linked list, using the - * pNext member of struct Trigger. A pointer to the first element of the - * linked list is stored as the "pTrigger" member of the associated - * struct Table. - * - * The "step_list" member points to the first element of a linked list - * containing the SQL statements specified as the trigger program. - */ - public class Trigger { - public string zName; /* The name of the trigger */ - public string table; /* The table or view to which the trigger applies */ - public u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT */ - public u8 tr_tm; /* One of TRIGGER_BEFORE, TRIGGER_AFTER */ - public Expr pWhen; /* The WHEN clause of the expression (may be NULL) */ - public IdList pColumns; /* If this is an UPDATE OF trigger, + public class Trigger + { + public string zName; /* The name of the trigger */ + public string table; /* The table or view to which the trigger applies */ + public u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT */ + public u8 tr_tm; /* One of TRIGGER_BEFORE, TRIGGER_AFTER */ + public Expr pWhen; /* The WHEN clause of the expression (may be NULL) */ + public IdList pColumns; /* If this is an UPDATE OF trigger, the is stored here */ - public Schema pSchema; /* Schema containing the trigger */ - public Schema pTabSchema; /* Schema containing the table */ - public TriggerStep step_list; /* Link list of trigger program steps */ - public Trigger pNext; /* Next trigger associated with the table */ - - public Trigger Copy() { - if (this == null) - return null; - else { - Trigger cp = (Trigger)MemberwiseClone(); - if (pWhen != null) - cp.pWhen = pWhen.Copy(); - if (pColumns != null) - cp.pColumns = pColumns.Copy(); - if (pSchema != null) - cp.pSchema = pSchema.Copy(); - if (pTabSchema != null) - cp.pTabSchema = pTabSchema.Copy(); - if (step_list != null) - cp.step_list = step_list.Copy(); - if (pNext != null) - cp.pNext = pNext.Copy(); - return cp; - } - } - }; - - /* - ** A trigger is either a BEFORE or an AFTER trigger. The following constants - ** determine which. - ** - ** If there are multiple triggers, you might of some BEFORE and some AFTER. - ** In that cases, the constants below can be ORed together. - */ - const u8 TRIGGER_BEFORE = 1;//#define TRIGGER_BEFORE 1 - const u8 TRIGGER_AFTER = 2;//#define TRIGGER_AFTER 2 - - /* - * An instance of struct TriggerStep is used to store a single SQL statement - * that is a part of a trigger-program. - * - * Instances of struct TriggerStep are stored in a singly linked list (linked - * using the "pNext" member) referenced by the "step_list" member of the - * associated struct Trigger instance. The first element of the linked list is - * the first step of the trigger-program. - * - * The "op" member indicates whether this is a "DELETE", "INSERT", "UPDATE" or - * "SELECT" statement. The meanings of the other members is determined by the - * value of "op" as follows: - * - * (op == TK_INSERT) - * orconf -> stores the ON CONFLICT algorithm - * pSelect -> If this is an INSERT INTO ... SELECT ... statement, then - * this stores a pointer to the SELECT statement. Otherwise NULL. - * target -> A token holding the quoted name of the table to insert into. - * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then - * this stores values to be inserted. Otherwise NULL. - * pIdList -> If this is an INSERT INTO ... () VALUES ... - * statement, then this stores the column-names to be - * inserted into. - * - * (op == TK_DELETE) - * target -> A token holding the quoted name of the table to delete from. - * pWhere -> The WHERE clause of the DELETE statement if one is specified. - * Otherwise NULL. - * - * (op == TK_UPDATE) - * target -> A token holding the quoted name of the table to update rows of. - * pWhere -> The WHERE clause of the UPDATE statement if one is specified. - * Otherwise NULL. - * pExprList -> A list of the columns to update and the expressions to update - * them to. See sqlite3Update() documentation of "pChanges" - * argument. - * - */ - public class TriggerStep { - public u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */ - public u8 orconf; /* OE_Rollback etc. */ - public Trigger pTrig; /* The trigger that this step is a part of */ - public Select pSelect; /* SELECT statment or RHS of INSERT INTO .. SELECT ... */ - public Token target; /* Target table for DELETE, UPDATE, INSERT */ - public Expr pWhere; /* The WHERE clause for DELETE or UPDATE steps */ - public ExprList pExprList; /* SET clause for UPDATE. VALUES clause for INSERT */ - public IdList pIdList; /* Column names for INSERT */ - public TriggerStep pNext; /* Next in the link-list */ - public TriggerStep pLast; /* Last element in link-list. Valid for 1st elem only */ - - public TriggerStep() { - target = new Token(); - } - public TriggerStep Copy() { - if (this == null) - return null; - else { - TriggerStep cp = (TriggerStep)MemberwiseClone(); - return cp; - } - } - }; - - /* - ** The following structure contains information used by the sqliteFix... - ** routines as they walk the parse tree to make database references - ** explicit. - */ - //typedef struct DbFixer DbFixer; - public class DbFixer { - public Parse pParse; /* The parsing context. Error messages written here */ - public string zDb; /* Make sure all objects are contained in this database */ - public string zType; /* Type of the container - used for error messages */ - public Token pName; /* Name of the container - used for error messages */ - }; - - /* - ** An objected used to accumulate the text of a string where we - ** do not necessarily know how big the string will be in the end. - */ - public class StrAccum { - public sqlite3 db; /* Optional database for lookaside. Can be NULL */ - //public StringBuilder zBase; /* A base allocation. Not from malloc. */ - public StringBuilder zText; /* The string collected so far */ - //public int nChar; /* Length of the string so far */ - //public int nAlloc; /* Amount of space allocated in zText */ - public int mxAlloc; /* Maximum allowed string length */ - // Cannot happen under C# - //public u8 mallocFailed; /* Becomes true if any memory allocation fails */ - //public u8 useMalloc; /* 0: none, 1: sqlite3DbMalloc, 2: sqlite3_malloc */ - //public u8 tooBig; /* Becomes true if string size exceeds limits */ - public Mem Context; - - public StrAccum(int n) { - db = null; - //zBase = new StringBuilder( n ); - zText = new StringBuilder(n); - //nChar = 0; - //nAlloc = n; - mxAlloc = 0; - //useMalloc = 0; - //tooBig = 0; - Context = null; - } - - public i64 nChar { - get { - return zText.Length; - } - } - - public bool tooBig { - get { - return mxAlloc > 0 && zText.Length > mxAlloc; - } - } - }; - - /* - ** A pointer to this structure is used to communicate information - ** from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback. - */ - public class InitData { - public sqlite3 db; /* The database being initialized */ - public int iDb; /* 0 for main database. 1 for TEMP, 2.. for ATTACHed */ - public string pzErrMsg; /* Error message stored here */ - public int rc; /* Result code stored here */ + public Schema pSchema; /* Schema containing the trigger */ + public Schema pTabSchema; /* Schema containing the table */ + public TriggerStep step_list; /* Link list of trigger program steps */ + public Trigger pNext; /* Next trigger associated with the table */ + + public Trigger Copy() + { + if ( this == null ) + return null; + else + { + Trigger cp = (Trigger)MemberwiseClone(); + if ( pWhen != null ) + cp.pWhen = pWhen.Copy(); + if ( pColumns != null ) + cp.pColumns = pColumns.Copy(); + if ( pSchema != null ) + cp.pSchema = pSchema.Copy(); + if ( pTabSchema != null ) + cp.pTabSchema = pTabSchema.Copy(); + if ( step_list != null ) + cp.step_list = step_list.Copy(); + if ( pNext != null ) + cp.pNext = pNext.Copy(); + return cp; } + } + }; - /* - ** Structure containing global configuration data for the SQLite library. - ** - ** This structure also contains some state information. - */ - public class Sqlite3Config { - public bool bMemstat; /* True to enable memory status */ - public bool bCoreMutex; /* True to enable core mutexing */ - public bool bFullMutex; /* True to enable full mutexing */ - public bool bOpenUri; /* True to interpret filenames as URIs */ - public int mxStrlen; /* Maximum string length */ - public int szLookaside; /* Default lookaside buffer size */ - public int nLookaside; /* Default lookaside buffer count */ - public sqlite3_mem_methods m; /* Low-level memory allocation interface */ - public sqlite3_mutex_methods mutex; /* Low-level mutex interface */ - public sqlite3_pcache_methods pcache; /* Low-level page-cache interface */ - public byte[] pHeap; /* Heap storage space */ - public int nHeap; /* Size of pHeap[] */ - public int mnReq, mxReq; /* Min and max heap requests sizes */ - public byte[][] pScratch2; /* Scratch memory */ - public byte[][] pScratch; /* Scratch memory */ - public int szScratch; /* Size of each scratch buffer */ - public int nScratch; /* Number of scratch buffers */ - public MemPage pPage; /* Page cache memory */ - public int szPage; /* Size of each page in pPage[] */ - public int nPage; /* Number of pages in pPage[] */ - public int mxParserStack; /* maximum depth of the parser stack */ - public bool sharedCacheEnabled; /* true if shared-cache mode enabled */ - /* The above might be initialized to non-zero. The following need to always - ** initially be zero, however. */ - public int isInit; /* True after initialization has finished */ - public int inProgress; /* True while initialization in progress */ - public int isMutexInit; /* True after mutexes are initialized */ - public int isMallocInit; /* True after malloc is initialized */ - public int isPCacheInit; /* True after malloc is initialized */ - public sqlite3_mutex pInitMutex; /* Mutex used by sqlite3_initialize() */ - public int nRefInitMutex; /* Number of users of pInitMutex */ - public dxLog xLog; //void (*xLog)(void*,int,const char); /* Function for logging */ - public object pLogArg; /* First argument to xLog() */ - public bool bLocaltimeFault; /* True to fail localtime() calls */ - - public Sqlite3Config( - int bMemstat - , int bCoreMutex - , bool bFullMutex - , bool bOpenUri - , int mxStrlen - , int szLookaside - , int nLookaside - , sqlite3_mem_methods m - , sqlite3_mutex_methods mutex - , sqlite3_pcache_methods pcache - , byte[] pHeap - , int nHeap - , int mnReq - , int mxReq - , byte[][] pScratch - , int szScratch - , int nScratch - , MemPage pPage - , int szPage - , int nPage - , int mxParserStack - , bool sharedCacheEnabled - , int isInit - , int inProgress - , int isMutexInit - , int isMallocInit - , int isPCacheInit - , sqlite3_mutex pInitMutex - , int nRefInitMutex - , dxLog xLog - , object pLogArg - , bool bLocaltimeFault - ) { - this.bMemstat = bMemstat != 0; - this.bCoreMutex = bCoreMutex != 0; - this.bOpenUri = bOpenUri; - this.bFullMutex = bFullMutex; - this.mxStrlen = mxStrlen; - this.szLookaside = szLookaside; - this.nLookaside = nLookaside; - this.m = m; - this.mutex = mutex; - this.pcache = pcache; - this.pHeap = pHeap; - this.nHeap = nHeap; - this.mnReq = mnReq; - this.mxReq = mxReq; - this.pScratch = pScratch; - this.szScratch = szScratch; - this.nScratch = nScratch; - this.pPage = pPage; - this.szPage = szPage; - this.nPage = nPage; - this.mxParserStack = mxParserStack; - this.sharedCacheEnabled = sharedCacheEnabled; - this.isInit = isInit; - this.inProgress = inProgress; - this.isMutexInit = isMutexInit; - this.isMallocInit = isMallocInit; - this.isPCacheInit = isPCacheInit; - this.pInitMutex = pInitMutex; - this.nRefInitMutex = nRefInitMutex; - this.xLog = xLog; - this.pLogArg = pLogArg; - this.bLocaltimeFault = bLocaltimeFault; - } - }; - - /* - ** Context pointer passed down through the tree-walk. - */ - public class Walker { - public dxExprCallback xExprCallback; //)(Walker*, Expr); /* Callback for expressions */ - public dxSelectCallback xSelectCallback; //)(Walker*,Select); /* Callback for SELECTs */ - public Parse pParse; /* Parser context. */ - public struct uw { /* Extra data for callback */ - public NameContext pNC; /* Naming context */ - public int i; /* Integer value */ - } - public uw u; - }; - - /* Forward declarations */ - //int sqlite3WalkExpr(Walker*, Expr); - //int sqlite3WalkExprList(Walker*, ExprList); - //int sqlite3WalkSelect(Walker*, Select); - //int sqlite3WalkSelectExpr(Walker*, Select); - //int sqlite3WalkSelectFrom(Walker*, Select); - - /* - ** Return code from the parse-tree walking primitives and their - ** callbacks. - */ - //#define WRC_Continue 0 /* Continue down into children */ - //#define WRC_Prune 1 /* Omit children but continue walking siblings */ - //#define WRC_Abort 2 /* Abandon the tree walk */ - const int WRC_Continue = 0; - const int WRC_Prune = 1; - const int WRC_Abort = 2; - - - /* - ** Assuming zIn points to the first byte of a UTF-8 character, - ** advance zIn to point to the first byte of the next UTF-8 character. - */ - //#define SQLITE_SKIP_UTF8(zIn) { \ - // if( (*(zIn++))>=0xc0 ){ \ - // while( (*zIn & 0xc0)==0x80 ){ zIn++; } \ - // } \ - //} - static void SQLITE_SKIP_UTF8(string zIn, ref int iz) { - iz++; - if (iz < zIn.Length && zIn[iz - 1] >= 0xC0) { - while (iz < zIn.Length && (zIn[iz] & 0xC0) == 0x80) { - iz++; - } - } - } - static void SQLITE_SKIP_UTF8( - byte[] zIn, ref int iz) { - iz++; - if (iz < zIn.Length && zIn[iz - 1] >= 0xC0) { - while (iz < zIn.Length && (zIn[iz] & 0xC0) == 0x80) { - iz++; - } - } + /* + ** A trigger is either a BEFORE or an AFTER trigger. The following constants + ** determine which. + ** + ** If there are multiple triggers, you might of some BEFORE and some AFTER. + ** In that cases, the constants below can be ORed together. + */ + const u8 TRIGGER_BEFORE = 1;//#define TRIGGER_BEFORE 1 + const u8 TRIGGER_AFTER = 2;//#define TRIGGER_AFTER 2 + + /* + * An instance of struct TriggerStep is used to store a single SQL statement + * that is a part of a trigger-program. + * + * Instances of struct TriggerStep are stored in a singly linked list (linked + * using the "pNext" member) referenced by the "step_list" member of the + * associated struct Trigger instance. The first element of the linked list is + * the first step of the trigger-program. + * + * The "op" member indicates whether this is a "DELETE", "INSERT", "UPDATE" or + * "SELECT" statement. The meanings of the other members is determined by the + * value of "op" as follows: + * + * (op == TK_INSERT) + * orconf -> stores the ON CONFLICT algorithm + * pSelect -> If this is an INSERT INTO ... SELECT ... statement, then + * this stores a pointer to the SELECT statement. Otherwise NULL. + * target -> A token holding the quoted name of the table to insert into. + * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then + * this stores values to be inserted. Otherwise NULL. + * pIdList -> If this is an INSERT INTO ... () VALUES ... + * statement, then this stores the column-names to be + * inserted into. + * + * (op == TK_DELETE) + * target -> A token holding the quoted name of the table to delete from. + * pWhere -> The WHERE clause of the DELETE statement if one is specified. + * Otherwise NULL. + * + * (op == TK_UPDATE) + * target -> A token holding the quoted name of the table to update rows of. + * pWhere -> The WHERE clause of the UPDATE statement if one is specified. + * Otherwise NULL. + * pExprList -> A list of the columns to update and the expressions to update + * them to. See sqlite3Update() documentation of "pChanges" + * argument. + * + */ + public class TriggerStep + { + public u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */ + public u8 orconf; /* OE_Rollback etc. */ + public Trigger pTrig; /* The trigger that this step is a part of */ + public Select pSelect; /* SELECT statment or RHS of INSERT INTO .. SELECT ... */ + public Token target; /* Target table for DELETE, UPDATE, INSERT */ + public Expr pWhere; /* The WHERE clause for DELETE or UPDATE steps */ + public ExprList pExprList; /* SET clause for UPDATE. VALUES clause for INSERT */ + public IdList pIdList; /* Column names for INSERT */ + public TriggerStep pNext; /* Next in the link-list */ + public TriggerStep pLast; /* Last element in link-list. Valid for 1st elem only */ + + public TriggerStep() + { + target = new Token(); + } + public TriggerStep Copy() + { + if ( this == null ) + return null; + else + { + TriggerStep cp = (TriggerStep)MemberwiseClone(); + return cp; } + } + }; - /* - ** The SQLITE_*_BKPT macros are substitutes for the error codes with - ** the same name but without the _BKPT suffix. These macros invoke - ** routines that report the line-number on which the error originated - ** using sqlite3_log(). The routines also provide a convenient place - ** to set a debugger breakpoint. - */ - //int sqlite3CorruptError(int); - //int sqlite3MisuseError(int); - //int sqlite3CantopenError(int); -#if DEBUG - - //#define SQLITE_CORRUPT_BKPT sqlite3CorruptError(__LINE__) - static int SQLITE_CORRUPT_BKPT() { - return sqlite3CorruptError(0); + /* + ** The following structure contains information used by the sqliteFix... + ** routines as they walk the parse tree to make database references + ** explicit. + */ + //typedef struct DbFixer DbFixer; + public class DbFixer + { + public Parse pParse; /* The parsing context. Error messages written here */ + public string zDb; /* Make sure all objects are contained in this database */ + public string zType; /* Type of the container - used for error messages */ + public Token pName; /* Name of the container - used for error messages */ + }; + + /* + ** An objected used to accumulate the text of a string where we + ** do not necessarily know how big the string will be in the end. + */ + public class StrAccum + { + public sqlite3 db; /* Optional database for lookaside. Can be NULL */ + //public StringBuilder zBase; /* A base allocation. Not from malloc. */ + public StringBuilder zText; /* The string collected so far */ + //public int nChar; /* Length of the string so far */ + //public int nAlloc; /* Amount of space allocated in zText */ + public int mxAlloc; /* Maximum allowed string length */ + // Cannot happen under C# + //public u8 mallocFailed; /* Becomes true if any memory allocation fails */ + //public u8 useMalloc; /* 0: none, 1: sqlite3DbMalloc, 2: sqlite3_malloc */ + //public u8 tooBig; /* Becomes true if string size exceeds limits */ + public Mem Context; + + public StrAccum( int n ) + { + db = null; + //zBase = new StringBuilder( n ); + zText = new StringBuilder( n ); + //nChar = 0; + //nAlloc = n; + mxAlloc = 0; + //useMalloc = 0; + //tooBig = 0; + Context = null; + } + + public i64 nChar + { + get + { + return zText.Length; } + } - //#define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__) - static int SQLITE_MISUSE_BKPT() { - return sqlite3MisuseError(0); + public bool tooBig + { + get + { + return mxAlloc > 0 && zText.Length > mxAlloc; } + } + }; + + /* + ** A pointer to this structure is used to communicate information + ** from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback. + */ + public class InitData + { + public sqlite3 db; /* The database being initialized */ + public int iDb; /* 0 for main database. 1 for TEMP, 2.. for ATTACHed */ + public string pzErrMsg; /* Error message stored here */ + public int rc; /* Result code stored here */ + } + + /* + ** Structure containing global configuration data for the SQLite library. + ** + ** This structure also contains some state information. + */ + public class Sqlite3Config + { + public bool bMemstat; /* True to enable memory status */ + public bool bCoreMutex; /* True to enable core mutexing */ + public bool bFullMutex; /* True to enable full mutexing */ + public bool bOpenUri; /* True to interpret filenames as URIs */ + public int mxStrlen; /* Maximum string length */ + public int szLookaside; /* Default lookaside buffer size */ + public int nLookaside; /* Default lookaside buffer count */ + public sqlite3_mem_methods m; /* Low-level memory allocation interface */ + public sqlite3_mutex_methods mutex; /* Low-level mutex interface */ + public sqlite3_pcache_methods pcache; /* Low-level page-cache interface */ + public byte[] pHeap; /* Heap storage space */ + public int nHeap; /* Size of pHeap[] */ + public int mnReq, mxReq; /* Min and max heap requests sizes */ + public byte[][] pScratch2; /* Scratch memory */ + public byte[][] pScratch; /* Scratch memory */ + public int szScratch; /* Size of each scratch buffer */ + public int nScratch; /* Number of scratch buffers */ + public MemPage pPage; /* Page cache memory */ + public int szPage; /* Size of each page in pPage[] */ + public int nPage; /* Number of pages in pPage[] */ + public int mxParserStack; /* maximum depth of the parser stack */ + public bool sharedCacheEnabled; /* true if shared-cache mode enabled */ + /* The above might be initialized to non-zero. The following need to always + ** initially be zero, however. */ + public int isInit; /* True after initialization has finished */ + public int inProgress; /* True while initialization in progress */ + public int isMutexInit; /* True after mutexes are initialized */ + public int isMallocInit; /* True after malloc is initialized */ + public int isPCacheInit; /* True after malloc is initialized */ + public sqlite3_mutex pInitMutex; /* Mutex used by sqlite3_initialize() */ + public int nRefInitMutex; /* Number of users of pInitMutex */ + public dxLog xLog; //void (*xLog)(void*,int,const char); /* Function for logging */ + public object pLogArg; /* First argument to xLog() */ + public bool bLocaltimeFault; /* True to fail localtime() calls */ + + public Sqlite3Config( + int bMemstat + , int bCoreMutex + , bool bFullMutex + , bool bOpenUri + , int mxStrlen + , int szLookaside + , int nLookaside + , sqlite3_mem_methods m + , sqlite3_mutex_methods mutex + , sqlite3_pcache_methods pcache + , byte[] pHeap + , int nHeap + , int mnReq + , int mxReq + , byte[][] pScratch + , int szScratch + , int nScratch + , MemPage pPage + , int szPage + , int nPage + , int mxParserStack + , bool sharedCacheEnabled + , int isInit + , int inProgress + , int isMutexInit + , int isMallocInit + , int isPCacheInit + , sqlite3_mutex pInitMutex + , int nRefInitMutex + , dxLog xLog + , object pLogArg + , bool bLocaltimeFault + ) + { + this.bMemstat = bMemstat != 0; + this.bCoreMutex = bCoreMutex != 0; + this.bOpenUri = bOpenUri; + this.bFullMutex = bFullMutex; + this.mxStrlen = mxStrlen; + this.szLookaside = szLookaside; + this.nLookaside = nLookaside; + this.m = m; + this.mutex = mutex; + this.pcache = pcache; + this.pHeap = pHeap; + this.nHeap = nHeap; + this.mnReq = mnReq; + this.mxReq = mxReq; + this.pScratch = pScratch; + this.szScratch = szScratch; + this.nScratch = nScratch; + this.pPage = pPage; + this.szPage = szPage; + this.nPage = nPage; + this.mxParserStack = mxParserStack; + this.sharedCacheEnabled = sharedCacheEnabled; + this.isInit = isInit; + this.inProgress = inProgress; + this.isMutexInit = isMutexInit; + this.isMallocInit = isMallocInit; + this.isPCacheInit = isPCacheInit; + this.pInitMutex = pInitMutex; + this.nRefInitMutex = nRefInitMutex; + this.xLog = xLog; + this.pLogArg = pLogArg; + this.bLocaltimeFault = bLocaltimeFault; + } + }; + + /* + ** Context pointer passed down through the tree-walk. + */ + public class Walker + { + public dxExprCallback xExprCallback; //)(Walker*, Expr); /* Callback for expressions */ + public dxSelectCallback xSelectCallback; //)(Walker*,Select); /* Callback for SELECTs */ + public Parse pParse; /* Parser context. */ + public struct uw + { /* Extra data for callback */ + public NameContext pNC; /* Naming context */ + public int i; /* Integer value */ + } + public uw u; + }; + + /* Forward declarations */ + //int sqlite3WalkExpr(Walker*, Expr); + //int sqlite3WalkExprList(Walker*, ExprList); + //int sqlite3WalkSelect(Walker*, Select); + //int sqlite3WalkSelectExpr(Walker*, Select); + //int sqlite3WalkSelectFrom(Walker*, Select); + + /* + ** Return code from the parse-tree walking primitives and their + ** callbacks. + */ + //#define WRC_Continue 0 /* Continue down into children */ + //#define WRC_Prune 1 /* Omit children but continue walking siblings */ + //#define WRC_Abort 2 /* Abandon the tree walk */ + const int WRC_Continue = 0; + const int WRC_Prune = 1; + const int WRC_Abort = 2; + - //#define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__) - static int SQLITE_CANTOPEN_BKPT() { - return sqlite3CantopenError(0); + /* + ** Assuming zIn points to the first byte of a UTF-8 character, + ** advance zIn to point to the first byte of the next UTF-8 character. + */ + //#define SQLITE_SKIP_UTF8(zIn) { \ + // if( (*(zIn++))>=0xc0 ){ \ + // while( (*zIn & 0xc0)==0x80 ){ zIn++; } \ + // } \ + //} + static void SQLITE_SKIP_UTF8( string zIn, ref int iz ) + { + iz++; + if ( iz < zIn.Length && zIn[iz - 1] >= 0xC0 ) + { + while ( iz < zIn.Length && ( zIn[iz] & 0xC0 ) == 0x80 ) + { + iz++; + } + } + } + static void SQLITE_SKIP_UTF8( + byte[] zIn, ref int iz ) + { + iz++; + if ( iz < zIn.Length && zIn[iz - 1] >= 0xC0 ) + { + while ( iz < zIn.Length && ( zIn[iz] & 0xC0 ) == 0x80 ) + { + iz++; } + } + } + + /* + ** The SQLITE_*_BKPT macros are substitutes for the error codes with + ** the same name but without the _BKPT suffix. These macros invoke + ** routines that report the line-number on which the error originated + ** using sqlite3_log(). The routines also provide a convenient place + ** to set a debugger breakpoint. + */ + //int sqlite3CorruptError(int); + //int sqlite3MisuseError(int); + //int sqlite3CantopenError(int); +#if DEBUG + + //#define SQLITE_CORRUPT_BKPT sqlite3CorruptError(__LINE__) + static int SQLITE_CORRUPT_BKPT() + { + return sqlite3CorruptError( 0 ); + } + + //#define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__) + static int SQLITE_MISUSE_BKPT() + { + return sqlite3MisuseError( 0 ); + } + + //#define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__) + static int SQLITE_CANTOPEN_BKPT() + { + return sqlite3CantopenError( 0 ); + } #else static int SQLITE_CORRUPT_BKPT() {return SQLITE_CORRUPT;} static int SQLITE_MISUSE_BKPT() {return SQLITE_MISUSE;} static int SQLITE_CANTOPEN_BKPT() {return SQLITE_CANTOPEN;} #endif - /* - ** FTS4 is really an extension for FTS3. It is enabled using the - ** SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also all - ** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3. + /* +** FTS4 is really an extension for FTS3. It is enabled using the +** SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also all +** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3. +*/ + //#if (SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3) + //# define SQLITE_ENABLE_FTS3 + //#endif + + /* + ** The ctype.h header is needed for non-ASCII systems. It is also + ** needed by FTS3 when FTS3 is included in the amalgamation. + */ + //#if !defined(SQLITE_ASCII) || \ + // (defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_AMALGAMATION)) + //# include + //#endif + + + /* + ** The following macros mimic the standard library functions toupper(), + ** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The + ** sqlite versions only work for ASCII characters, regardless of locale. */ - //#if (SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3) - //# define SQLITE_ENABLE_FTS3 - //#endif - - /* - ** The ctype.h header is needed for non-ASCII systems. It is also - ** needed by FTS3 when FTS3 is included in the amalgamation. - */ - //#if !defined(SQLITE_ASCII) || \ - // (defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_AMALGAMATION)) - //# include - //#endif - - - /* - ** The following macros mimic the standard library functions toupper(), - ** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The - ** sqlite versions only work for ASCII characters, regardless of locale. - */ #if SQLITE_ASCII - //# define sqlite3Toupper(x) ((x)&~(sqlite3CtypeMap[(unsigned char)(x)]&0x20)) + //# define sqlite3Toupper(x) ((x)&~(sqlite3CtypeMap[(unsigned char)(x)]&0x20)) - //# define sqlite3Isspace(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x01) - static bool sqlite3Isspace(byte x) { - return (sqlite3CtypeMap[(byte)(x)] & 0x01) != 0; - } - static bool sqlite3Isspace(char x) { - return x < 256 && (sqlite3CtypeMap[(byte)(x)] & 0x01) != 0; - } + //# define sqlite3Isspace(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x01) + static bool sqlite3Isspace( byte x ) + { + return ( sqlite3CtypeMap[(byte)( x )] & 0x01 ) != 0; + } + static bool sqlite3Isspace( char x ) + { + return x < 256 && ( sqlite3CtypeMap[(byte)( x )] & 0x01 ) != 0; + } - //# define sqlite3Isalnum(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x06) - static bool sqlite3Isalnum(byte x) { - return (sqlite3CtypeMap[(byte)(x)] & 0x06) != 0; - } - static bool sqlite3Isalnum(char x) { - return x < 256 && (sqlite3CtypeMap[(byte)(x)] & 0x06) != 0; - } + //# define sqlite3Isalnum(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x06) + static bool sqlite3Isalnum( byte x ) + { + return ( sqlite3CtypeMap[(byte)( x )] & 0x06 ) != 0; + } + static bool sqlite3Isalnum( char x ) + { + return x < 256 && ( sqlite3CtypeMap[(byte)( x )] & 0x06 ) != 0; + } - //# define sqlite3Isalpha(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x02) + //# define sqlite3Isalpha(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x02) - //# define sqlite3Isdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x04) - static bool sqlite3Isdigit(byte x) { - return (sqlite3CtypeMap[((byte)x)] & 0x04) != 0; - } - static bool sqlite3Isdigit(char x) { - return x < 256 && (sqlite3CtypeMap[((byte)x)] & 0x04) != 0; - } + //# define sqlite3Isdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x04) + static bool sqlite3Isdigit( byte x ) + { + return ( sqlite3CtypeMap[( (byte)x )] & 0x04 ) != 0; + } + static bool sqlite3Isdigit( char x ) + { + return x < 256 && ( sqlite3CtypeMap[( (byte)x )] & 0x04 ) != 0; + } - //# define sqlite3Isxdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x08) - static bool sqlite3Isxdigit(byte x) { - return (sqlite3CtypeMap[((byte)x)] & 0x08) != 0; - } - static bool sqlite3Isxdigit(char x) { - return x < 256 && (sqlite3CtypeMap[((byte)x)] & 0x08) != 0; - } + //# define sqlite3Isxdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x08) + static bool sqlite3Isxdigit( byte x ) + { + return ( sqlite3CtypeMap[( (byte)x )] & 0x08 ) != 0; + } + static bool sqlite3Isxdigit( char x ) + { + return x < 256 && ( sqlite3CtypeMap[( (byte)x )] & 0x08 ) != 0; + } - //# define sqlite3Tolower(x) (sqlite3UpperToLower[(unsigned char)(x)]) + //# define sqlite3Tolower(x) (sqlite3UpperToLower[(unsigned char)(x)]) #else //# define sqlite3Toupper(x) toupper((unsigned char)(x)) //# define sqlite3Isspace(x) isspace((unsigned char)(x)) @@ -3560,43 +3729,43 @@ static bool sqlite3Isxdigit(char x) { //# define sqlite3Tolower(x) tolower((unsigned char)(x)) #endif - /* - ** Internal function prototypes + /* +** Internal function prototypes +*/ + //int sqlite3StrICmp(string , string ); + //int sqlite3Strlen30(const char); + //#define sqlite3StrNICmp sqlite3_strnicmp + + //int sqlite3MallocInit(void); + //void sqlite3MallocEnd(void); + //void *sqlite3Malloc(int); + //void *sqlite3MallocZero(int); + //void *sqlite3DbMallocZero(sqlite3*, int); + //void *sqlite3DbMallocRaw(sqlite3*, int); + //char *sqlite3DbStrDup(sqlite3*,const char); + //char *sqlite3DbStrNDup(sqlite3*,const char*, int); + //void *sqlite3Realloc(void*, int); + //void *sqlite3DbReallocOrFree(sqlite3 *, object *, int); + //void *sqlite3DbRealloc(sqlite3 *, object *, int); + //void sqlite3DbFree(sqlite3*, void); + //int sqlite3MallocSize(void); + //int sqlite3DbMallocSize(sqlite3*, void); + //void *sqlite3ScratchMalloc(int); + //void //sqlite3ScratchFree(void); + //void *sqlite3PageMalloc(int); + //void sqlite3PageFree(void); + //void sqlite3MemSetDefault(void); + //void sqlite3BenignMallocHooks(void ()(void), object ()(void)); + //int sqlite3HeapNearlyFull(void); + + /* + ** On systems with ample stack space and that support alloca(), make + ** use of alloca() to obtain space for large automatic objects. By default, + ** obtain space from malloc(). + ** + ** The alloca() routine never returns NULL. This will cause code paths + ** that deal with sqlite3StackAlloc() failures to be unreachable. */ - //int sqlite3StrICmp(string , string ); - //int sqlite3Strlen30(const char); - //#define sqlite3StrNICmp sqlite3_strnicmp - - //int sqlite3MallocInit(void); - //void sqlite3MallocEnd(void); - //void *sqlite3Malloc(int); - //void *sqlite3MallocZero(int); - //void *sqlite3DbMallocZero(sqlite3*, int); - //void *sqlite3DbMallocRaw(sqlite3*, int); - //char *sqlite3DbStrDup(sqlite3*,const char); - //char *sqlite3DbStrNDup(sqlite3*,const char*, int); - //void *sqlite3Realloc(void*, int); - //void *sqlite3DbReallocOrFree(sqlite3 *, object *, int); - //void *sqlite3DbRealloc(sqlite3 *, object *, int); - //void sqlite3DbFree(sqlite3*, void); - //int sqlite3MallocSize(void); - //int sqlite3DbMallocSize(sqlite3*, void); - //void *sqlite3ScratchMalloc(int); - //void //sqlite3ScratchFree(void); - //void *sqlite3PageMalloc(int); - //void sqlite3PageFree(void); - //void sqlite3MemSetDefault(void); - //void sqlite3BenignMallocHooks(void ()(void), object ()(void)); - //int sqlite3HeapNearlyFull(void); - - /* - ** On systems with ample stack space and that support alloca(), make - ** use of alloca() to obtain space for large automatic objects. By default, - ** obtain space from malloc(). - ** - ** The alloca() routine never returns NULL. This will cause code paths - ** that deal with sqlite3StackAlloc() failures to be unreachable. - */ #if SQLITE_USE_ALLOCA //# define sqlite3StackAllocRaw(D,N) alloca(N) //# define sqlite3StackAllocZero(D,N) memset(alloca(N), 0, N) @@ -3620,96 +3789,96 @@ static bool sqlite3Isxdigit(char x) { #endif #if !SQLITE_MUTEX_OMIT - // sqlite3_mutex_methods const *sqlite3DefaultMutex(void); - // sqlite3_mutex_methods const *sqlite3NoopMutex(void); - // sqlite3_mutex *sqlite3MutexAlloc(int); - // int sqlite3MutexInit(void); - // int sqlite3MutexEnd(void); + // sqlite3_mutex_methods const *sqlite3DefaultMutex(void); + // sqlite3_mutex_methods const *sqlite3NoopMutex(void); + // sqlite3_mutex *sqlite3MutexAlloc(int); + // int sqlite3MutexInit(void); + // int sqlite3MutexEnd(void); #endif - //int sqlite3StatusValue(int); - //void sqlite3StatusAdd(int, int); - //void sqlite3StatusSet(int, int); + //int sqlite3StatusValue(int); + //void sqlite3StatusAdd(int, int); + //void sqlite3StatusSet(int, int); - //#if !SQLITE_OMIT_FLOATING_POINT - // int sqlite3IsNaN(double); - //#else - //# define sqlite3IsNaN(X) 0 - //#endif + //#if !SQLITE_OMIT_FLOATING_POINT + // int sqlite3IsNaN(double); + //#else + //# define sqlite3IsNaN(X) 0 + //#endif - //void sqlite3VXPrintf(StrAccum*, int, const char*, va_list); -#if !SQLITE_OMIT_TRACE - //void sqlite3XPrintf(StrAccum*, const char*, ...); + //void sqlite3VXPrintf(StrAccum*, int, const char*, va_list); +#if!SQLITE_OMIT_TRACE + //void sqlite3XPrintf(StrAccum*, const char*, ...); #endif - //char *sqlite3MPrintf(sqlite3*,const char*, ...); - //char *sqlite3VMPrintf(sqlite3*,const char*, va_list); - //char *sqlite3MAppendf(sqlite3*,char*,const char*,...); + //char *sqlite3MPrintf(sqlite3*,const char*, ...); + //char *sqlite3VMPrintf(sqlite3*,const char*, va_list); + //char *sqlite3MAppendf(sqlite3*,char*,const char*,...); #if SQLITE_TEST || SQLITE_DEBUG - // void sqlite3DebugPrintf(const char*, ...); + // void sqlite3DebugPrintf(const char*, ...); #endif #if SQLITE_TEST // void *sqlite3TestTextToPtr(const char); #endif - //void sqlite3SetString(char **, sqlite3*, const char*, ...); - //void sqlite3ErrorMsg(Parse*, const char*, ...); - //int sqlite3Dequote(char); - //int sqlite3KeywordCode(const unsigned char*, int); - //int sqlite3RunParser(Parse*, const char*, char *); - //void sqlite3FinishCoding(Parse); - //int sqlite3GetTempReg(Parse); - //void sqlite3ReleaseTempReg(Parse*,int); - //int sqlite3GetTempRange(Parse*,int); - //void sqlite3ReleaseTempRange(Parse*,int,int); - //Expr *sqlite3ExprAlloc(sqlite3*,int,const Token*,int); - //Expr *sqlite3Expr(sqlite3*,int,const char); - //void sqlite3ExprAttachSubtrees(sqlite3*,Expr*,Expr*,Expr); - //Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*, const Token); - //Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr); - //Expr *sqlite3ExprFunction(Parse*,ExprList*, Token); - //void sqlite3ExprAssignVarNumber(Parse*, Expr); - //void sqlite3ExprDelete(sqlite3*, Expr); - //ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr); - //void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int); - //void sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan); - //void sqlite3ExprListDelete(sqlite3*, ExprList); - //int sqlite3Init(sqlite3*, char*); - //int sqlite3InitCallback(void*, int, char**, char*); - //void sqlite3Pragma(Parse*,Token*,Token*,Token*,int); - //void sqlite3ResetInternalSchema(sqlite3*, int); - //void sqlite3BeginParse(Parse*,int); - //void sqlite3CommitInternalChanges(sqlite3); - //Table *sqlite3ResultSetOfSelect(Parse*,Select); - //void sqlite3OpenMasterTable(Parse *, int); - //void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int); - //void sqlite3AddColumn(Parse*,Token); - //void sqlite3AddNotNull(Parse*, int); - //void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int); - //void sqlite3AddCheckConstraint(Parse*, Expr); - //void sqlite3AddColumnType(Parse*,Token); - //void sqlite3AddDefaultValue(Parse*,ExprSpan); - //void sqlite3AddCollateType(Parse*, Token); - //void sqlite3EndTable(Parse*,Token*,Token*,Select); - //int sqlite3ParseUri(const char*,const char*,unsigned int*, - // sqlite3_vfs**,char**,char *); - - //Bitvec *sqlite3BitvecCreate(u32); - //int sqlite3BitvecTest(Bitvec*, u32); - //int sqlite3BitvecSet(Bitvec*, u32); - //void sqlite3BitvecClear(Bitvec*, u32, void); - //void sqlite3BitvecDestroy(Bitvec); - //u32 sqlite3BitvecSize(Bitvec); - //int sqlite3BitvecBuiltinTest(int,int); - - //RowSet *sqlite3RowSetInit(sqlite3*, void*, unsigned int); - //void sqlite3RowSetClear(RowSet); - //void sqlite3RowSetInsert(RowSet*, i64); - //int sqlite3RowSetTest(RowSet*, u8 iBatch, i64); - //int sqlite3RowSetNext(RowSet*, i64); - - //void sqlite3CreateView(Parse*,Token*,Token*,Token*,Select*,int,int); + //void sqlite3SetString(char **, sqlite3*, const char*, ...); + //void sqlite3ErrorMsg(Parse*, const char*, ...); + //int sqlite3Dequote(char); + //int sqlite3KeywordCode(const unsigned char*, int); + //int sqlite3RunParser(Parse*, const char*, char *); + //void sqlite3FinishCoding(Parse); + //int sqlite3GetTempReg(Parse); + //void sqlite3ReleaseTempReg(Parse*,int); + //int sqlite3GetTempRange(Parse*,int); + //void sqlite3ReleaseTempRange(Parse*,int,int); + //Expr *sqlite3ExprAlloc(sqlite3*,int,const Token*,int); + //Expr *sqlite3Expr(sqlite3*,int,const char); + //void sqlite3ExprAttachSubtrees(sqlite3*,Expr*,Expr*,Expr); + //Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*, const Token); + //Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr); + //Expr *sqlite3ExprFunction(Parse*,ExprList*, Token); + //void sqlite3ExprAssignVarNumber(Parse*, Expr); + //void sqlite3ExprDelete(sqlite3*, Expr); + //ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr); + //void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int); + //void sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan); + //void sqlite3ExprListDelete(sqlite3*, ExprList); + //int sqlite3Init(sqlite3*, char*); + //int sqlite3InitCallback(void*, int, char**, char*); + //void sqlite3Pragma(Parse*,Token*,Token*,Token*,int); + //void sqlite3ResetInternalSchema(sqlite3*, int); + //void sqlite3BeginParse(Parse*,int); + //void sqlite3CommitInternalChanges(sqlite3); + //Table *sqlite3ResultSetOfSelect(Parse*,Select); + //void sqlite3OpenMasterTable(Parse *, int); + //void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int); + //void sqlite3AddColumn(Parse*,Token); + //void sqlite3AddNotNull(Parse*, int); + //void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int); + //void sqlite3AddCheckConstraint(Parse*, Expr); + //void sqlite3AddColumnType(Parse*,Token); + //void sqlite3AddDefaultValue(Parse*,ExprSpan); + //void sqlite3AddCollateType(Parse*, Token); + //void sqlite3EndTable(Parse*,Token*,Token*,Select); + //int sqlite3ParseUri(const char*,const char*,unsigned int*, + // sqlite3_vfs**,char**,char *); + + //Bitvec *sqlite3BitvecCreate(u32); + //int sqlite3BitvecTest(Bitvec*, u32); + //int sqlite3BitvecSet(Bitvec*, u32); + //void sqlite3BitvecClear(Bitvec*, u32, void); + //void sqlite3BitvecDestroy(Bitvec); + //u32 sqlite3BitvecSize(Bitvec); + //int sqlite3BitvecBuiltinTest(int,int); + + //RowSet *sqlite3RowSetInit(sqlite3*, void*, unsigned int); + //void sqlite3RowSetClear(RowSet); + //void sqlite3RowSetInsert(RowSet*, i64); + //int sqlite3RowSetTest(RowSet*, u8 iBatch, i64); + //int sqlite3RowSetNext(RowSet*, i64); + + //void sqlite3CreateView(Parse*,Token*,Token*,Token*,Select*,int,int); #if !SQLITE_OMIT_VIEW || !SQLITE_OMIT_VIRTUALTABLE - //int sqlite3ViewGetColumnNames(Parse*,Table); + //int sqlite3ViewGetColumnNames(Parse*,Table); #else //# define sqlite3ViewGetColumnNames(A,B) 0 static int sqlite3ViewGetColumnNames( Parse A, Table B ) @@ -3718,147 +3887,148 @@ static int sqlite3ViewGetColumnNames( Parse A, Table B ) } #endif - //void sqlite3DropTable(Parse*, SrcList*, int, int); - //void sqlite3DeleteTable(sqlite3*, Table); - //#if !SQLITE_OMIT_AUTOINCREMENT - // void sqlite3AutoincrementBegin(Parse *pParse); - // void sqlite3AutoincrementEnd(Parse *pParse); - //#else - //# define sqlite3AutoincrementBegin(X) - //# define sqlite3AutoincrementEnd(X) - //#endif - //void sqlite3Insert(Parse*, SrcList*, ExprList*, Select*, IdList*, int); - //void *sqlite3ArrayAllocate(sqlite3*,void*,int,int,int*,int*,int); - //IdList *sqlite3IdListAppend(sqlite3*, IdList*, Token); - //int sqlite3IdListIndex(IdList*,const char); - //SrcList *sqlite3SrcListEnlarge(sqlite3*, SrcList*, int, int); - //SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token); - //SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*, - // Token*, Select*, Expr*, IdList); - //void sqlite3SrcListIndexedBy(Parse *, SrcList *, Token ); - //int sqlite3IndexedByLookup(Parse *, struct SrcList_item ); - //void sqlite3SrcListShiftJoinType(SrcList); - //void sqlite3SrcListAssignCursors(Parse*, SrcList); - //void sqlite3IdListDelete(sqlite3*, IdList); - //void sqlite3SrcListDelete(sqlite3*, SrcList); - //Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*, - // Token*, int, int); - //void sqlite3DropIndex(Parse*, SrcList*, int); - //int sqlite3Select(Parse*, Select*, SelectDest); - //Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*, - // Expr*,ExprList*,int,Expr*,Expr); - //void sqlite3SelectDelete(sqlite3*, Select); - //Table *sqlite3SrcListLookup(Parse*, SrcList); - //int sqlite3IsReadOnly(Parse*, Table*, int); - //void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int); + //void sqlite3DropTable(Parse*, SrcList*, int, int); + //void sqlite3DeleteTable(sqlite3*, Table); + //#if !SQLITE_OMIT_AUTOINCREMENT + // void sqlite3AutoincrementBegin(Parse *pParse); + // void sqlite3AutoincrementEnd(Parse *pParse); + //#else + //# define sqlite3AutoincrementBegin(X) + //# define sqlite3AutoincrementEnd(X) + //#endif + //void sqlite3Insert(Parse*, SrcList*, ExprList*, Select*, IdList*, int); + //void *sqlite3ArrayAllocate(sqlite3*,void*,int,int,int*,int*,int); + //IdList *sqlite3IdListAppend(sqlite3*, IdList*, Token); + //int sqlite3IdListIndex(IdList*,const char); + //SrcList *sqlite3SrcListEnlarge(sqlite3*, SrcList*, int, int); + //SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token); + //SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*, + // Token*, Select*, Expr*, IdList); + //void sqlite3SrcListIndexedBy(Parse *, SrcList *, Token ); + //int sqlite3IndexedByLookup(Parse *, struct SrcList_item ); + //void sqlite3SrcListShiftJoinType(SrcList); + //void sqlite3SrcListAssignCursors(Parse*, SrcList); + //void sqlite3IdListDelete(sqlite3*, IdList); + //void sqlite3SrcListDelete(sqlite3*, SrcList); + //Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*, + // Token*, int, int); + //void sqlite3DropIndex(Parse*, SrcList*, int); + //int sqlite3Select(Parse*, Select*, SelectDest); + //Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*, + // Expr*,ExprList*,int,Expr*,Expr); + //void sqlite3SelectDelete(sqlite3*, Select); + //Table *sqlite3SrcListLookup(Parse*, SrcList); + //int sqlite3IsReadOnly(Parse*, Table*, int); + //void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int); #if (SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !(SQLITE_OMIT_SUBQUERY) //Expr *sqlite3LimitWhere(Parse *, SrcList *, Expr *, ExprList *, Expr *, Expr *, char ); #endif - //void sqlite3DeleteFrom(Parse*, SrcList*, Expr); - //void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int); - //WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**, u16); - //void sqlite3WhereEnd(WhereInfo); - //int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int); - //void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int); - //void sqlite3ExprCodeMove(Parse*, int, int, int); - //void sqlite3ExprCodeCopy(Parse*, int, int, int); - //void sqlite3ExprCacheStore(Parse*, int, int, int); - //void sqlite3ExprCachePush(Parse); - //void sqlite3ExprCachePop(Parse*, int); - //void sqlite3ExprCacheRemove(Parse*, int, int); - //void sqlite3ExprCacheClear(Parse); - //void sqlite3ExprCacheAffinityChange(Parse*, int, int); - //int sqlite3ExprCode(Parse*, Expr*, int); - //int sqlite3ExprCodeTemp(Parse*, Expr*, int); - //int sqlite3ExprCodeTarget(Parse*, Expr*, int); - //int sqlite3ExprCodeAndCache(Parse*, Expr*, int); - //void sqlite3ExprCodeConstants(Parse*, Expr); - //int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int); - //void sqlite3ExprIfTrue(Parse*, Expr*, int, int); - //void sqlite3ExprIfFalse(Parse*, Expr*, int, int); - //Table *sqlite3FindTable(sqlite3*,const char*, const char); - //Table *sqlite3LocateTable(Parse*,int isView,const char*, const char); - //Index *sqlite3FindIndex(sqlite3*,const char*, const char); - //void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char); - //void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char); - //void sqlite3Vacuum(Parse); - //int sqlite3RunVacuum(char**, sqlite3); - //char *sqlite3NameFromToken(sqlite3*, Token); - //int sqlite3ExprCompare(Expr*, Expr); - //int sqlite3ExprListCompare(ExprList*, ExprList); - //void sqlite3ExprAnalyzeAggregates(NameContext*, Expr); - //void sqlite3ExprAnalyzeAggList(NameContext*,ExprList); - //Vdbe *sqlite3GetVdbe(Parse); - //void sqlite3PrngSaveState(void); - //void sqlite3PrngRestoreState(void); - //void sqlite3PrngResetState(void); - //void sqlite3RollbackAll(sqlite3); - //void sqlite3CodeVerifySchema(Parse*, int); - //void sqlite3CodeVerifyNamedSchema(Parse*, string zDb); - //void sqlite3BeginTransaction(Parse*, int); - //void sqlite3CommitTransaction(Parse); - //void sqlite3RollbackTransaction(Parse); - //void sqlite3Savepoint(Parse*, int, Token); - //void sqlite3CloseSavepoints(sqlite3 ); - //int sqlite3ExprIsConstant(Expr); - //int sqlite3ExprIsConstantNotJoin(Expr); - //int sqlite3ExprIsConstantOrFunction(Expr); - //int sqlite3ExprIsInteger(Expr*, int); - //int sqlite3ExprCanBeNull(const Expr); - //void sqlite3ExprCodeIsNullJump(Vdbe*, const Expr*, int, int); - //int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); - //int sqlite3IsRowid(const char); - //void sqlite3GenerateRowDelete(Parse*, Table*, int, int, int, Trigger *, int); - //void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int); - //int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int); - //void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int, - // int*,int,int,int,int,int); - //void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int); - //int sqlite3OpenTableAndIndices(Parse*, Table*, int, int); - //void sqlite3BeginWriteOperation(Parse*, int, int); - //void sqlite3MultiWrite(Parse); - //void sqlite3MayAbort(Parse ); - //void sqlite3HaltConstraint(Parse*, int, char*, int); - //Expr *sqlite3ExprDup(sqlite3*,Expr*,int); - //ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int); - //SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int); - //IdList *sqlite3IdListDup(sqlite3*,IdList); - //Select *sqlite3SelectDup(sqlite3*,Select*,int); - //void sqlite3FuncDefInsert(FuncDefHash*, FuncDef); - //FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,int,u8,int); - //void sqlite3RegisterBuiltinFunctions(sqlite3); - //void sqlite3RegisterDateTimeFunctions(void); - //void sqlite3RegisterGlobalFunctions(void); - //int sqlite3SafetyCheckOk(sqlite3); - //int sqlite3SafetyCheckSickOrOk(sqlite3); - //void sqlite3ChangeCookie(Parse*, int); + //void sqlite3DeleteFrom(Parse*, SrcList*, Expr); + //void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int); + //WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**, u16); + //void sqlite3WhereEnd(WhereInfo); + //int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int); + //void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int); + //void sqlite3ExprCodeMove(Parse*, int, int, int); + //void sqlite3ExprCodeCopy(Parse*, int, int, int); + //void sqlite3ExprCacheStore(Parse*, int, int, int); + //void sqlite3ExprCachePush(Parse); + //void sqlite3ExprCachePop(Parse*, int); + //void sqlite3ExprCacheRemove(Parse*, int, int); + //void sqlite3ExprCacheClear(Parse); + //void sqlite3ExprCacheAffinityChange(Parse*, int, int); + //int sqlite3ExprCode(Parse*, Expr*, int); + //int sqlite3ExprCodeTemp(Parse*, Expr*, int); + //int sqlite3ExprCodeTarget(Parse*, Expr*, int); + //int sqlite3ExprCodeAndCache(Parse*, Expr*, int); + //void sqlite3ExprCodeConstants(Parse*, Expr); + //int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int); + //void sqlite3ExprIfTrue(Parse*, Expr*, int, int); + //void sqlite3ExprIfFalse(Parse*, Expr*, int, int); + //Table *sqlite3FindTable(sqlite3*,const char*, const char); + //Table *sqlite3LocateTable(Parse*,int isView,const char*, const char); + //Index *sqlite3FindIndex(sqlite3*,const char*, const char); + //void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char); + //void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char); + //void sqlite3Vacuum(Parse); + //int sqlite3RunVacuum(char**, sqlite3); + //char *sqlite3NameFromToken(sqlite3*, Token); + //int sqlite3ExprCompare(Expr*, Expr); + //int sqlite3ExprListCompare(ExprList*, ExprList); + //void sqlite3ExprAnalyzeAggregates(NameContext*, Expr); + //void sqlite3ExprAnalyzeAggList(NameContext*,ExprList); + //Vdbe *sqlite3GetVdbe(Parse); + //void sqlite3PrngSaveState(void); + //void sqlite3PrngRestoreState(void); + //void sqlite3PrngResetState(void); + //void sqlite3RollbackAll(sqlite3); + //void sqlite3CodeVerifySchema(Parse*, int); + //void sqlite3CodeVerifyNamedSchema(Parse*, string zDb); + //void sqlite3BeginTransaction(Parse*, int); + //void sqlite3CommitTransaction(Parse); + //void sqlite3RollbackTransaction(Parse); + //void sqlite3Savepoint(Parse*, int, Token); + //void sqlite3CloseSavepoints(sqlite3 ); + //int sqlite3ExprIsConstant(Expr); + //int sqlite3ExprIsConstantNotJoin(Expr); + //int sqlite3ExprIsConstantOrFunction(Expr); + //int sqlite3ExprIsInteger(Expr*, int); + //int sqlite3ExprCanBeNull(const Expr); + //void sqlite3ExprCodeIsNullJump(Vdbe*, const Expr*, int, int); + //int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); + //int sqlite3IsRowid(const char); + //void sqlite3GenerateRowDelete(Parse*, Table*, int, int, int, Trigger *, int); + //void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int); + //int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int); + //void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int, + // int*,int,int,int,int,int); + //void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int); + //int sqlite3OpenTableAndIndices(Parse*, Table*, int, int); + //void sqlite3BeginWriteOperation(Parse*, int, int); + //void sqlite3MultiWrite(Parse); + //void sqlite3MayAbort(Parse ); + //void sqlite3HaltConstraint(Parse*, int, char*, int); + //Expr *sqlite3ExprDup(sqlite3*,Expr*,int); + //ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int); + //SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int); + //IdList *sqlite3IdListDup(sqlite3*,IdList); + //Select *sqlite3SelectDup(sqlite3*,Select*,int); + //void sqlite3FuncDefInsert(FuncDefHash*, FuncDef); + //FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,int,u8,int); + //void sqlite3RegisterBuiltinFunctions(sqlite3); + //void sqlite3RegisterDateTimeFunctions(void); + //void sqlite3RegisterGlobalFunctions(void); + //int sqlite3SafetyCheckOk(sqlite3); + //int sqlite3SafetyCheckSickOrOk(sqlite3); + //void sqlite3ChangeCookie(Parse*, int); #if !(SQLITE_OMIT_VIEW) && !(SQLITE_OMIT_TRIGGER) - //void sqlite3MaterializeView(Parse*, Table*, Expr*, int); + //void sqlite3MaterializeView(Parse*, Table*, Expr*, int); #endif #if !SQLITE_OMIT_TRIGGER - //void sqlite3BeginTrigger(Parse*, Token*,Token*,int,int,IdList*,SrcList*, - // Expr*,int, int); - //void sqlite3FinishTrigger(Parse*, TriggerStep*, Token); - //void sqlite3DropTrigger(Parse*, SrcList*, int); - //Trigger *sqlite3TriggersExist(Parse *, Table*, int, ExprList*, int *pMask); - //Trigger *sqlite3TriggerList(Parse *, Table ); - // void sqlite3CodeRowTrigger(Parse*, Trigger *, int, ExprList*, int, Table *, - // int, int, int); - //void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList); - //void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep); - //TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select); - //TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*, - // ExprList*,Select*,u8); - //TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8); - //TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr); - //void sqlite3DeleteTrigger(sqlite3*, Trigger); - //void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char); - // u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int); - //# define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p)) - static Parse sqlite3ParseToplevel(Parse p) { - return p.pToplevel != null ? p.pToplevel : p; - } + //void sqlite3BeginTrigger(Parse*, Token*,Token*,int,int,IdList*,SrcList*, + // Expr*,int, int); + //void sqlite3FinishTrigger(Parse*, TriggerStep*, Token); + //void sqlite3DropTrigger(Parse*, SrcList*, int); + //Trigger *sqlite3TriggersExist(Parse *, Table*, int, ExprList*, int *pMask); + //Trigger *sqlite3TriggerList(Parse *, Table ); + // void sqlite3CodeRowTrigger(Parse*, Trigger *, int, ExprList*, int, Table *, + // int, int, int); + //void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList); + //void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep); + //TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select); + //TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*, + // ExprList*,Select*,u8); + //TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8); + //TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr); + //void sqlite3DeleteTrigger(sqlite3*, Trigger); + //void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char); + // u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int); + //# define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p)) + static Parse sqlite3ParseToplevel( Parse p ) + { + return p.pToplevel != null ? p.pToplevel : p; + } #else static void sqlite3BeginTrigger( Parse A, Token B, Token C, int D, int E, IdList F, SrcList G, Expr H, int I, int J ) { @@ -3946,9 +4116,9 @@ static u32 sqlite3TriggerOldmask( Parse A, Trigger B, int C, ExprList D, Table E } #endif - //int sqlite3JoinType(Parse*, Token*, Token*, Token); - //void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int); - //void sqlite3DeferForeignKey(Parse*, int); + //int sqlite3JoinType(Parse*, Token*, Token*, Token); + //void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int); + //void sqlite3DeferForeignKey(Parse*, int); #if !SQLITE_OMIT_AUTHORIZATION void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList); int sqlite3AuthCheck(Parse*,int, const char*, const char*, const char); @@ -3956,191 +4126,195 @@ static u32 sqlite3TriggerOldmask( Parse A, Trigger B, int C, ExprList D, Table E void sqlite3AuthContextPop(AuthContext); int sqlite3AuthReadCol(Parse*, string , string , int); #else - //# define sqlite3AuthRead(a,b,c,d) - static void sqlite3AuthRead(Parse a, Expr b, Schema c, SrcList d) { - } + //# define sqlite3AuthRead(a,b,c,d) + static void sqlite3AuthRead( Parse a, Expr b, Schema c, SrcList d ) + { + } - //# define sqlite3AuthCheck(a,b,c,d,e) SQLITE_OK - static int sqlite3AuthCheck(Parse a, int b, string c, byte[] d, byte[] e) { - return SQLITE_OK; - } + //# define sqlite3AuthCheck(a,b,c,d,e) SQLITE_OK + static int sqlite3AuthCheck( Parse a, int b, string c, byte[] d, byte[] e ) + { + return SQLITE_OK; + } - //# define sqlite3AuthContextPush(a,b,c) - static void sqlite3AuthContextPush(Parse a, AuthContext b, string c) { - } + //# define sqlite3AuthContextPush(a,b,c) + static void sqlite3AuthContextPush( Parse a, AuthContext b, string c ) + { + } - //# define sqlite3AuthContextPop(a) ((void)(a)) - static Parse sqlite3AuthContextPop(Parse a) { - return a; - } + //# define sqlite3AuthContextPop(a) ((void)(a)) + static Parse sqlite3AuthContextPop( Parse a ) + { + return a; + } #endif - //void sqlite3Attach(Parse*, Expr*, Expr*, Expr); - //void sqlite3Detach(Parse*, Expr); - //int sqlite3FixInit(DbFixer*, Parse*, int, const char*, const Token); - //int sqlite3FixSrcList(DbFixer*, SrcList); - //int sqlite3FixSelect(DbFixer*, Select); - //int sqlite3FixExpr(DbFixer*, Expr); - //int sqlite3FixExprList(DbFixer*, ExprList); - //int sqlite3FixTriggerStep(DbFixer*, TriggerStep); - //sqlite3AtoF(string z, double*, int, u8) - //int sqlite3GetInt32(string , int); - //int sqlite3Atoi(string ); - //int sqlite3Utf16ByteLen(const void pData, int nChar); - //int sqlite3Utf8CharLen(const char pData, int nByte); - //u32 sqlite3Utf8Read(const u8*, const u8*); - - /* - ** 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 - ** are coded to assume the single byte case is already handled (which - ** the MACRO form does). - */ - //int sqlite3PutVarint(unsigned char*, u64); - //int putVarint32(unsigned char*, u32); - //u8 sqlite3GetVarint(const unsigned char *, u64 ); - //u8 sqlite3GetVarint32(const unsigned char *, u32 ); - //int sqlite3VarintLen(u64 v); - - /* - ** The header of a record consists of a sequence variable-length integers. - ** These integers are almost always small and are encoded as a single byte. - ** The following macros take advantage this fact to provide a fast encode - ** and decode of the integers in a record header. It is faster for the common - ** case where the integer is a single byte. It is a little slower when the - ** integer is two or more bytes. But overall it is faster. - ** - ** The following expressions are equivalent: - ** - ** x = sqlite3GetVarint32( A, B ); - ** x = putVarint32( A, B ); - ** - ** x = getVarint32( A, B ); - ** x = putVarint32( A, B ); - ** - */ - //#define getVarint32(A,B) (u8)((*(A)<(u8)0x80) ? ((B) = (u32)*(A)),1 : sqlite3GetVarint32((A), (u32 )&(B))) - //#define putVarint32(A,B) (u8)(((u32)(B)<(u32)0x80) ? (*(A) = (unsigned char)(B)),1 : sqlite3PutVarint32((A), (B))) - //#define getVarint sqlite3GetVarint - //#define putVarint sqlite3PutVarint - - - //string sqlite3IndexAffinityStr(Vdbe *, Index ); - //void sqlite3TableAffinityStr(Vdbe *, Table ); - //char sqlite3CompareAffinity(Expr pExpr, char aff2); - //int sqlite3IndexAffinityOk(Expr pExpr, char idx_affinity); - //char sqlite3ExprAffinity(Expr pExpr); - //int sqlite3Atoi64(const char*, i64*, int, u8); - //void sqlite3Error(sqlite3*, int, const char*,...); - //void *sqlite3HexToBlob(sqlite3*, string z, int n); - //u8 sqlite3HexToInt(int h); - //int sqlite3TwoPartName(Parse *, Token *, Token *, Token *); - //string sqlite3ErrStr(int); - //int sqlite3ReadSchema(Parse pParse); - //CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int); - //CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName); - //CollSeq *sqlite3ExprCollSeq(Parse pParse, Expr pExpr); - //Expr *sqlite3ExprSetColl(Expr*, CollSeq); - //Expr *sqlite3ExprSetCollByToken(Parse *pParse, Expr*, Token); - //int sqlite3CheckCollSeq(Parse *, CollSeq ); - //int sqlite3CheckObjectName(Parse *, string ); - //void sqlite3VdbeSetChanges(sqlite3 *, int); - //int sqlite3AddInt64(i64*,i64); - //int sqlite3SubInt64(i64*,i64); - //int sqlite3MulInt64(i64*,i64); - //int sqlite3AbsInt32(int); -#if SQLITE_ENABLE_8_3_NAMES + //void sqlite3Attach(Parse*, Expr*, Expr*, Expr); + //void sqlite3Detach(Parse*, Expr); + //int sqlite3FixInit(DbFixer*, Parse*, int, const char*, const Token); + //int sqlite3FixSrcList(DbFixer*, SrcList); + //int sqlite3FixSelect(DbFixer*, Select); + //int sqlite3FixExpr(DbFixer*, Expr); + //int sqlite3FixExprList(DbFixer*, ExprList); + //int sqlite3FixTriggerStep(DbFixer*, TriggerStep); + //sqlite3AtoF(string z, double*, int, u8) + //int sqlite3GetInt32(string , int); + //int sqlite3Atoi(string ); + //int sqlite3Utf16ByteLen(const void pData, int nChar); + //int sqlite3Utf8CharLen(const char pData, int nByte); + //u32 sqlite3Utf8Read(const u8*, const u8*); + + /* + ** 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 + ** are coded to assume the single byte case is already handled (which + ** the MACRO form does). + */ + //int sqlite3PutVarint(unsigned char*, u64); + //int putVarint32(unsigned char*, u32); + //u8 sqlite3GetVarint(const unsigned char *, u64 ); + //u8 sqlite3GetVarint32(const unsigned char *, u32 ); + //int sqlite3VarintLen(u64 v); + + /* + ** The header of a record consists of a sequence variable-length integers. + ** These integers are almost always small and are encoded as a single byte. + ** The following macros take advantage this fact to provide a fast encode + ** and decode of the integers in a record header. It is faster for the common + ** case where the integer is a single byte. It is a little slower when the + ** integer is two or more bytes. But overall it is faster. + ** + ** The following expressions are equivalent: + ** + ** x = sqlite3GetVarint32( A, B ); + ** x = putVarint32( A, B ); + ** + ** x = getVarint32( A, B ); + ** x = putVarint32( A, B ); + ** + */ + //#define getVarint32(A,B) (u8)((*(A)<(u8)0x80) ? ((B) = (u32)*(A)),1 : sqlite3GetVarint32((A), (u32 )&(B))) + //#define putVarint32(A,B) (u8)(((u32)(B)<(u32)0x80) ? (*(A) = (unsigned char)(B)),1 : sqlite3PutVarint32((A), (B))) + //#define getVarint sqlite3GetVarint + //#define putVarint sqlite3PutVarint + + + //string sqlite3IndexAffinityStr(Vdbe *, Index ); + //void sqlite3TableAffinityStr(Vdbe *, Table ); + //char sqlite3CompareAffinity(Expr pExpr, char aff2); + //int sqlite3IndexAffinityOk(Expr pExpr, char idx_affinity); + //char sqlite3ExprAffinity(Expr pExpr); + //int sqlite3Atoi64(const char*, i64*, int, u8); + //void sqlite3Error(sqlite3*, int, const char*,...); + //void *sqlite3HexToBlob(sqlite3*, string z, int n); + //u8 sqlite3HexToInt(int h); + //int sqlite3TwoPartName(Parse *, Token *, Token *, Token *); + //string sqlite3ErrStr(int); + //int sqlite3ReadSchema(Parse pParse); + //CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int); + //CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName); + //CollSeq *sqlite3ExprCollSeq(Parse pParse, Expr pExpr); + //Expr *sqlite3ExprSetColl(Expr*, CollSeq); + //Expr *sqlite3ExprSetCollByToken(Parse *pParse, Expr*, Token); + //int sqlite3CheckCollSeq(Parse *, CollSeq ); + //int sqlite3CheckObjectName(Parse *, string ); + //void sqlite3VdbeSetChanges(sqlite3 *, int); + //int sqlite3AddInt64(i64*,i64); + //int sqlite3SubInt64(i64*,i64); + //int sqlite3MulInt64(i64*,i64); + //int sqlite3AbsInt32(int); + #if SQLITE_ENABLE_8_3_NAMES //void sqlite3FileSuffix3(const char*, char); -#else - //# define sqlite3FileSuffix3(X,Y) - static void sqlite3FileSuffix3(string X, string Y) { } -#endif - //u8 sqlite3GetBoolean(string z); - - //const void *sqlite3ValueText(sqlite3_value*, u8); - //int sqlite3ValueBytes(sqlite3_value*, u8); - //void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8, - // // void()(void)); - //void sqlite3ValueFree(sqlite3_value); - //sqlite3_value *sqlite3ValueNew(sqlite3 ); - //char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8); - //#if SQLITE_ENABLE_STAT2 - //char *sqlite3Utf8to16(sqlite3 *, u8, char *, int, int ); - //#endif - //int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value *); - //void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8); - //#if !SQLITE_AMALGAMATION - //extern const unsigned char sqlite3OpcodeProperty[]; - //extern const unsigned char sqlite3UpperToLower[]; - //extern const unsigned char sqlite3CtypeMap[]; - //extern const Token sqlite3IntTokens[]; - //extern SQLITE_WSD struct Sqlite3Config sqlite3Config; - //extern SQLITE_WSD FuncDefHash sqlite3GlobalFunctions; - //#if !SQLITE_OMIT_WSD - //extern int sqlite3PendingByte; - //#endif - //#endif - //void sqlite3RootPageMoved(sqlite3*, int, int, int); - //void sqlite3Reindex(Parse*, Token*, Token); - //void sqlite3AlterFunctions(void); - //void sqlite3AlterRenameTable(Parse*, SrcList*, Token); - //int sqlite3GetToken(const unsigned char *, int ); - //void sqlite3NestedParse(Parse*, const char*, ...); - //void sqlite3ExpirePreparedStatements(sqlite3); - //int sqlite3CodeSubselect(Parse *, Expr *, int, int); - //void sqlite3SelectPrep(Parse*, Select*, NameContext); - //int sqlite3ResolveExprNames(NameContext*, Expr); - //void sqlite3ResolveSelectNames(Parse*, Select*, NameContext); - //int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char); - //void sqlite3ColumnDefault(Vdbe *, Table *, int, int); - //void sqlite3AlterFinishAddColumn(Parse *, Token ); - //void sqlite3AlterBeginAddColumn(Parse *, SrcList ); - //CollSeq *sqlite3GetCollSeq(sqlite3*, u8, CollSeq *, const char); - //char sqlite3AffinityType(const char); - //void sqlite3Analyze(Parse*, Token*, Token); - //int sqlite3InvokeBusyHandler(BusyHandler); - //int sqlite3FindDb(sqlite3*, Token); - //int sqlite3FindDbName(sqlite3 *, string ); - //int sqlite3AnalysisLoad(sqlite3*,int iDB); - //void sqlite3DeleteIndexSamples(sqlite3*,Index); - //void sqlite3DefaultRowEst(Index); - //void sqlite3RegisterLikeFunctions(sqlite3*, int); - //int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char); - //void sqlite3MinimumFileFormat(Parse*, int, int); - //void sqlite3SchemaClear(void ); - //Schema *sqlite3SchemaGet(sqlite3 *, Btree ); - //int sqlite3SchemaToIndex(sqlite3 db, Schema ); - //KeyInfo *sqlite3IndexKeyinfo(Parse *, Index ); - //int sqlite3CreateFunc(sqlite3 *, string , int, int, object *, - // void ()(sqlite3_context*,int,sqlite3_value *), - // void ()(sqlite3_context*,int,sqlite3_value *), object ()(sqlite3_context), - // FuncDestructor *pDestructor - //); - //int sqlite3ApiExit(sqlite3 db, int); - //int sqlite3OpenTempDatabase(Parse ); - - //void sqlite3StrAccumAppend(StrAccum*,const char*,int); - //char *sqlite3StrAccumFinish(StrAccum); - //void sqlite3StrAccumReset(StrAccum); - //void sqlite3SelectDestInit(SelectDest*,int,int); - //Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int); - - //void sqlite3BackupRestart(sqlite3_backup ); - //void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 ); - - /* - ** The interface to the LEMON-generated parser - */ - //void *sqlite3ParserAlloc(void*()(size_t)); - //void sqlite3ParserFree(void*, void()(void)); - //void sqlite3Parser(void*, int, Token, Parse); + #else + //# define sqlite3FileSuffix3(X,Y) + static void sqlite3FileSuffix3(string X, string Y){} + #endif + //u8 sqlite3GetBoolean(string z); + + //const void *sqlite3ValueText(sqlite3_value*, u8); + //int sqlite3ValueBytes(sqlite3_value*, u8); + //void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8, + // // void()(void)); + //void sqlite3ValueFree(sqlite3_value); + //sqlite3_value *sqlite3ValueNew(sqlite3 ); + //char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8); + //#if SQLITE_ENABLE_STAT2 + //char *sqlite3Utf8to16(sqlite3 *, u8, char *, int, int ); + //#endif + //int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value *); + //void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8); + //#if !SQLITE_AMALGAMATION + //extern const unsigned char sqlite3OpcodeProperty[]; + //extern const unsigned char sqlite3UpperToLower[]; + //extern const unsigned char sqlite3CtypeMap[]; + //extern const Token sqlite3IntTokens[]; + //extern SQLITE_WSD struct Sqlite3Config sqlite3Config; + //extern SQLITE_WSD FuncDefHash sqlite3GlobalFunctions; + //#if !SQLITE_OMIT_WSD + //extern int sqlite3PendingByte; + //#endif + //#endif + //void sqlite3RootPageMoved(sqlite3*, int, int, int); + //void sqlite3Reindex(Parse*, Token*, Token); + //void sqlite3AlterFunctions(void); + //void sqlite3AlterRenameTable(Parse*, SrcList*, Token); + //int sqlite3GetToken(const unsigned char *, int ); + //void sqlite3NestedParse(Parse*, const char*, ...); + //void sqlite3ExpirePreparedStatements(sqlite3); + //int sqlite3CodeSubselect(Parse *, Expr *, int, int); + //void sqlite3SelectPrep(Parse*, Select*, NameContext); + //int sqlite3ResolveExprNames(NameContext*, Expr); + //void sqlite3ResolveSelectNames(Parse*, Select*, NameContext); + //int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char); + //void sqlite3ColumnDefault(Vdbe *, Table *, int, int); + //void sqlite3AlterFinishAddColumn(Parse *, Token ); + //void sqlite3AlterBeginAddColumn(Parse *, SrcList ); + //CollSeq *sqlite3GetCollSeq(sqlite3*, u8, CollSeq *, const char); + //char sqlite3AffinityType(const char); + //void sqlite3Analyze(Parse*, Token*, Token); + //int sqlite3InvokeBusyHandler(BusyHandler); + //int sqlite3FindDb(sqlite3*, Token); + //int sqlite3FindDbName(sqlite3 *, string ); + //int sqlite3AnalysisLoad(sqlite3*,int iDB); + //void sqlite3DeleteIndexSamples(sqlite3*,Index); + //void sqlite3DefaultRowEst(Index); + //void sqlite3RegisterLikeFunctions(sqlite3*, int); + //int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char); + //void sqlite3MinimumFileFormat(Parse*, int, int); + //void sqlite3SchemaClear(void ); + //Schema *sqlite3SchemaGet(sqlite3 *, Btree ); + //int sqlite3SchemaToIndex(sqlite3 db, Schema ); + //KeyInfo *sqlite3IndexKeyinfo(Parse *, Index ); + //int sqlite3CreateFunc(sqlite3 *, string , int, int, object *, + // void ()(sqlite3_context*,int,sqlite3_value *), + // void ()(sqlite3_context*,int,sqlite3_value *), object ()(sqlite3_context), + // FuncDestructor *pDestructor + //); + //int sqlite3ApiExit(sqlite3 db, int); + //int sqlite3OpenTempDatabase(Parse ); + + //void sqlite3StrAccumAppend(StrAccum*,const char*,int); + //char *sqlite3StrAccumFinish(StrAccum); + //void sqlite3StrAccumReset(StrAccum); + //void sqlite3SelectDestInit(SelectDest*,int,int); + //Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int); + + //void sqlite3BackupRestart(sqlite3_backup ); + //void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 ); + + /* + ** The interface to the LEMON-generated parser + */ + //void *sqlite3ParserAlloc(void*()(size_t)); + //void sqlite3ParserFree(void*, void()(void)); + //void sqlite3Parser(void*, int, Token, Parse); #if YYTRACKMAXSTACKDEPTH int sqlite3ParserStackPeak(void); #endif - //void sqlite3AutoLoadExtensions(sqlite3); + //void sqlite3AutoLoadExtensions(sqlite3); #if !SQLITE_OMIT_LOAD_EXTENSION - //void sqlite3CloseExtensions(sqlite3); + //void sqlite3CloseExtensions(sqlite3); #else //# define sqlite3CloseExtensions(X) #endif @@ -4148,11 +4322,13 @@ static void sqlite3FileSuffix3(string X, string Y) { } #if !SQLITE_OMIT_SHARED_CACHE //void sqlite3TableLock(Parse *, int, int, u8, string ); #else - //#define sqlite3TableLock(v,w,x,y,z) - static void sqlite3TableLock(Parse p, int p1, int p2, u8 p3, byte[] p4) { - } - static void sqlite3TableLock(Parse p, int p1, int p2, u8 p3, string p4) { - } + //#define sqlite3TableLock(v,w,x,y,z) + static void sqlite3TableLock( Parse p, int p1, int p2, u8 p3, byte[] p4 ) + { + } + static void sqlite3TableLock( Parse p, int p1, int p2, u8 p3, string p4 ) + { + } #endif #if SQLITE_TEST @@ -4231,55 +4407,56 @@ static VTable sqlite3GetVTable( sqlite3 db, Table T ) return null; } #else - //void sqlite3VtabClear(sqlite3 db, Table); - //int sqlite3VtabSync(sqlite3 db, int rc); - //int sqlite3VtabRollback(sqlite3 db); - //int sqlite3VtabCommit(sqlite3 db); - //void sqlite3VtabLock(VTable ); - //void sqlite3VtabUnlock(VTable ); - //void sqlite3VtabUnlockList(sqlite3); - //int sqlite3VtabSavepoint(sqlite3 *, int, int); - //# define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0) - static bool sqlite3VtabInSync(sqlite3 db) { - return (db.nVTrans > 0 && db.aVTrans == null); - } +//void sqlite3VtabClear(sqlite3 db, Table); +//int sqlite3VtabSync(sqlite3 db, int rc); +//int sqlite3VtabRollback(sqlite3 db); +//int sqlite3VtabCommit(sqlite3 db); +//void sqlite3VtabLock(VTable ); +//void sqlite3VtabUnlock(VTable ); +//void sqlite3VtabUnlockList(sqlite3); +//int sqlite3VtabSavepoint(sqlite3 *, int, int); +//# define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0) + static bool sqlite3VtabInSync( sqlite3 db ) + { + return ( db.nVTrans > 0 && db.aVTrans == null ); + } #endif - //void sqlite3VtabMakeWritable(Parse*,Table); - //void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token); - //void sqlite3VtabFinishParse(Parse*, Token); - //void sqlite3VtabArgInit(Parse); - //void sqlite3VtabArgExtend(Parse*, Token); - //int sqlite3VtabCallCreate(sqlite3*, int, string , char *); - //int sqlite3VtabCallConnect(Parse*, Table); - //int sqlite3VtabCallDestroy(sqlite3*, int, string ); - //int sqlite3VtabBegin(sqlite3 *, VTable ); - //FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr); - //void sqlite3InvalidFunction(sqlite3_context*,int,sqlite3_value*); - //int sqlite3VdbeParameterIndex(Vdbe*, const char*, int); - //int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt ); - //int sqlite3Reprepare(Vdbe); - //void sqlite3ExprListCheckLength(Parse*, ExprList*, const char); - //CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr ); - //int sqlite3TempInMemory(const sqlite3); - //VTable *sqlite3GetVTable(sqlite3*, Table); - //string sqlite3JournalModename(int); - //int sqlite3Checkpoint(sqlite3*, int, int, int*, int); - //int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int); - - /* Declarations for functions in fkey.c. All of these are replaced by - ** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign - ** key functionality is available. If OMIT_TRIGGER is defined but - ** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In - ** this case foreign keys are parsed, but no other functionality is - ** provided (enforcement of FK constraints requires the triggers sub-system). - */ + //void sqlite3VtabMakeWritable(Parse*,Table); + //void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token); + //void sqlite3VtabFinishParse(Parse*, Token); + //void sqlite3VtabArgInit(Parse); + //void sqlite3VtabArgExtend(Parse*, Token); + //int sqlite3VtabCallCreate(sqlite3*, int, string , char *); + //int sqlite3VtabCallConnect(Parse*, Table); + //int sqlite3VtabCallDestroy(sqlite3*, int, string ); + //int sqlite3VtabBegin(sqlite3 *, VTable ); + //FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr); + //void sqlite3InvalidFunction(sqlite3_context*,int,sqlite3_value*); + //int sqlite3VdbeParameterIndex(Vdbe*, const char*, int); + //int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt ); + //int sqlite3Reprepare(Vdbe); + //void sqlite3ExprListCheckLength(Parse*, ExprList*, const char); + //CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr ); + //int sqlite3TempInMemory(const sqlite3); + //VTable *sqlite3GetVTable(sqlite3*, Table); + //string sqlite3JournalModename(int); + //int sqlite3Checkpoint(sqlite3*, int, int, int*, int); + //int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int); + + /* Declarations for functions in fkey.c. All of these are replaced by + ** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign + ** key functionality is available. If OMIT_TRIGGER is defined but + ** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In + ** this case foreign keys are parsed, but no other functionality is + ** provided (enforcement of FK constraints requires the triggers sub-system). + */ #if !(SQLITE_OMIT_FOREIGN_KEY) && !(SQLITE_OMIT_TRIGGER) - //void sqlite3FkCheck(Parse*, Table*, int, int); - //void sqlite3FkDropTable(Parse*, SrcList *, Table); - //void sqlite3FkActions(Parse*, Table*, ExprList*, int); - //int sqlite3FkRequired(Parse*, Table*, int*, int); - //u32 sqlite3FkOldmask(Parse*, Table); - //FKey *sqlite3FkReferences(vtable ); + //void sqlite3FkCheck(Parse*, Table*, int, int); + //void sqlite3FkDropTable(Parse*, SrcList *, Table); + //void sqlite3FkActions(Parse*, Table*, ExprList*, int); + //int sqlite3FkRequired(Parse*, Table*, int*, int); + //u32 sqlite3FkOldmask(Parse*, Table); + //FKey *sqlite3FkReferences(vtable ); #else //#define sqlite3FkActions(a,b,c,d) static void sqlite3FkActions( Parse a, Table b, ExprList c, int d ) { } @@ -4297,86 +4474,90 @@ static void sqlite3FkDropTable( Parse a, SrcList b, Table c ) { } static int sqlite3FkRequired( Parse a, Table b, int[] c, int d ) { return 0; } #endif #if !SQLITE_OMIT_FOREIGN_KEY - //void sqlite3FkDelete(sqlite3 *, Table); + //void sqlite3FkDelete(sqlite3 *, Table); #else //#define sqlite3FkDelete(a, b) static void sqlite3FkDelete(sqlite3 a, Table b) {} #endif - /* - ** Available fault injectors. Should be numbered beginning with 0. + /* +** Available fault injectors. Should be numbered beginning with 0. +*/ + const int SQLITE_FAULTINJECTOR_MALLOC = 0;//#define SQLITE_FAULTINJECTOR_MALLOC 0 + const int SQLITE_FAULTINJECTOR_COUNT = 1;//#define SQLITE_FAULTINJECTOR_COUNT 1 + + /* + ** The interface to the code in fault.c used for identifying "benign" + ** malloc failures. This is only present if SQLITE_OMIT_BUILTIN_TEST + ** is not defined. */ - const int SQLITE_FAULTINJECTOR_MALLOC = 0;//#define SQLITE_FAULTINJECTOR_MALLOC 0 - const int SQLITE_FAULTINJECTOR_COUNT = 1;//#define SQLITE_FAULTINJECTOR_COUNT 1 - - /* - ** The interface to the code in fault.c used for identifying "benign" - ** malloc failures. This is only present if SQLITE_OMIT_BUILTIN_TEST - ** is not defined. - */ #if !SQLITE_OMIT_BUILTIN_TEST - //void sqlite3BeginBenignMalloc(void); - //void sqlite3EndBenignMalloc(void); + //void sqlite3BeginBenignMalloc(void); + //void sqlite3EndBenignMalloc(void); #else //#define sqlite3BeginBenignMalloc() //#define sqlite3EndBenignMalloc() #endif - const int IN_INDEX_ROWID = 1;//#define IN_INDEX_ROWID 1 - const int IN_INDEX_EPH = 2;//#define IN_INDEX_EPH 2 - const int IN_INDEX_INDEX = 3;//#define IN_INDEX_INDEX 3 - //int sqlite3FindInIndex(Parse *, Expr *, int); + const int IN_INDEX_ROWID = 1;//#define IN_INDEX_ROWID 1 + const int IN_INDEX_EPH = 2;//#define IN_INDEX_EPH 2 + const int IN_INDEX_INDEX = 3;//#define IN_INDEX_INDEX 3 + //int sqlite3FindInIndex(Parse *, Expr *, int); #if SQLITE_ENABLE_ATOMIC_WRITE // int sqlite3JournalOpen(sqlite3_vfs *, string , sqlite3_file *, int, int); // int sqlite3JournalSize(sqlite3_vfs ); // int sqlite3JournalCreate(sqlite3_file ); #else - //#define sqlite3JournalSize(pVfs) ((pVfs)->szOsFile) - static int sqlite3JournalSize(sqlite3_vfs pVfs) { - return pVfs.szOsFile; - } + //#define sqlite3JournalSize(pVfs) ((pVfs)->szOsFile) + static int sqlite3JournalSize( sqlite3_vfs pVfs ) + { + return pVfs.szOsFile; + } #endif - //void sqlite3MemJournalOpen(sqlite3_file ); - //int sqlite3MemJournalSize(void); - //int sqlite3IsMemJournal(sqlite3_file ); + //void sqlite3MemJournalOpen(sqlite3_file ); + //int sqlite3MemJournalSize(void); + //int sqlite3IsMemJournal(sqlite3_file ); #if SQLITE_MAX_EXPR_DEPTH//>0 - // void sqlite3ExprSetHeight(Parse pParse, Expr p); - // int sqlite3SelectExprHeight(Select ); - //int sqlite3ExprCheckHeight(Parse*, int); + // void sqlite3ExprSetHeight(Parse pParse, Expr p); + // int sqlite3SelectExprHeight(Select ); + //int sqlite3ExprCheckHeight(Parse*, int); #else //#define sqlite3ExprSetHeight(x,y) //#define sqlite3SelectExprHeight(x) 0 //#define sqlite3ExprCheckHeight(x,y) #endif - //u32 sqlite3Get4byte(const u8); - //void sqlite3sqlite3Put4byte(u8*, u32); + //u32 sqlite3Get4byte(const u8); + //void sqlite3sqlite3Put4byte(u8*, u32); #if SQLITE_ENABLE_UNLOCK_NOTIFY void sqlite3ConnectionBlocked(sqlite3 *, sqlite3 ); void sqlite3ConnectionUnlocked(sqlite3 db); void sqlite3ConnectionClosed(sqlite3 db); #else - static void sqlite3ConnectionBlocked(sqlite3 x, sqlite3 y) { - } //#define sqlite3ConnectionBlocked(x,y) - static void sqlite3ConnectionUnlocked(sqlite3 x) { - } //#define sqlite3ConnectionUnlocked(x) - static void sqlite3ConnectionClosed(sqlite3 x) { - } //#define sqlite3ConnectionClosed(x) + static void sqlite3ConnectionBlocked( sqlite3 x, sqlite3 y ) + { + } //#define sqlite3ConnectionBlocked(x,y) + static void sqlite3ConnectionUnlocked( sqlite3 x ) + { + } //#define sqlite3ConnectionUnlocked(x) + static void sqlite3ConnectionClosed( sqlite3 x ) + { + } //#define sqlite3ConnectionClosed(x) #endif #if SQLITE_DEBUG - // void sqlite3ParserTrace(FILE*, char ); + // void sqlite3ParserTrace(FILE*, char ); #endif - /* - ** If the SQLITE_ENABLE IOTRACE exists then the global variable - ** sqlite3IoTrace is a pointer to a printf-like routine used to - ** print I/O tracing messages. - */ + /* +** If the SQLITE_ENABLE IOTRACE exists then the global variable +** sqlite3IoTrace is a pointer to a printf-like routine used to +** print I/O tracing messages. +*/ #if SQLITE_ENABLE_IOTRACE static bool SQLite3IoTrace = false; //#define IOTRACE(A) if( sqlite3IoTrace ){ sqlite3IoTrace A; } @@ -4385,71 +4566,76 @@ static void sqlite3ConnectionClosed(sqlite3 x) { // void sqlite3VdbeIOTraceSql(Vdbe); //SQLITE_EXTERN void (*sqlite3IoTrace)(const char*,...); #else - //#define IOTRACE(A) - static void IOTRACE(string F, params object[] ap) { - } - //#define sqlite3VdbeIOTraceSql(X) - static void sqlite3VdbeIOTraceSql(Vdbe X) { - } + //#define IOTRACE(A) + static void IOTRACE( string F, params object[] ap ) + { + } + //#define sqlite3VdbeIOTraceSql(X) + static void sqlite3VdbeIOTraceSql( Vdbe X ) + { + } #endif - /* - ** These routines are available for the mem2.c debugging memory allocator - ** only. They are used to verify that different "types" of memory - ** allocations are properly tracked by the system. - ** - ** sqlite3MemdebugSetType() sets the "type" of an allocation to one of - ** the MEMTYPE_* macros defined below. The type must be a bitmask with - ** a single bit set. - ** - ** sqlite3MemdebugHasType() returns true if any of the bits in its second - ** argument match the type set by the previous sqlite3MemdebugSetType(). - ** sqlite3MemdebugHasType() is intended for use inside Debug.Assert() statements. - ** - ** sqlite3MemdebugNoType() returns true if none of the bits in its second - ** argument match the type set by the previous sqlite3MemdebugSetType(). - ** - ** Perhaps the most important point is the difference between MEMTYPE_HEAP - ** and MEMTYPE_LOOKASIDE. If an allocation is MEMTYPE_LOOKASIDE, that means - ** it might have been allocated by lookaside, except the allocation was - ** too large or lookaside was already full. It is important to verify - ** that allocations that might have been satisfied by lookaside are not - ** passed back to non-lookaside free() routines. Asserts such as the - ** example above are placed on the non-lookaside free() routines to verify - ** this constraint. - ** - ** All of this is no-op for a production build. It only comes into - ** play when the SQLITE_MEMDEBUG compile-time option is used. - */ + /* +** These routines are available for the mem2.c debugging memory allocator +** only. They are used to verify that different "types" of memory +** allocations are properly tracked by the system. +** +** sqlite3MemdebugSetType() sets the "type" of an allocation to one of +** the MEMTYPE_* macros defined below. The type must be a bitmask with +** a single bit set. +** +** sqlite3MemdebugHasType() returns true if any of the bits in its second +** argument match the type set by the previous sqlite3MemdebugSetType(). +** sqlite3MemdebugHasType() is intended for use inside Debug.Assert() statements. +** +** sqlite3MemdebugNoType() returns true if none of the bits in its second +** argument match the type set by the previous sqlite3MemdebugSetType(). +** +** Perhaps the most important point is the difference between MEMTYPE_HEAP +** and MEMTYPE_LOOKASIDE. If an allocation is MEMTYPE_LOOKASIDE, that means +** it might have been allocated by lookaside, except the allocation was +** too large or lookaside was already full. It is important to verify +** that allocations that might have been satisfied by lookaside are not +** passed back to non-lookaside free() routines. Asserts such as the +** example above are placed on the non-lookaside free() routines to verify +** this constraint. +** +** All of this is no-op for a production build. It only comes into +** play when the SQLITE_MEMDEBUG compile-time option is used. +*/ #if SQLITE_MEMDEBUG // void sqlite3MemdebugSetType(void*,u8); // int sqlite3MemdebugHasType(void*,u8); // int sqlite3MemdebugNoType(void*,u8); #else - //# define sqlite3MemdebugSetType(X,Y) /* no-op */ - static void sqlite3MemdebugSetType(T X, int Y) { - } - //# define sqlite3MemdebugHasType(X,Y) 1 - static bool sqlite3MemdebugHasType(T X, int Y) { - return true; - } - //# define sqlite3MemdebugNoType(X,Y) 1 - static bool sqlite3MemdebugNoType(T X, int Y) { - return true; - } -#endif - //#define MEMTYPE_HEAP 0x01 /* General heap allocations */ - //#define MEMTYPE_LOOKASIDE 0x02 /* Might have been lookaside memory */ - //#define MEMTYPE_SCRATCH 0x04 /* Scratch allocations */ - //#define MEMTYPE_PCACHE 0x08 /* Page cache allocations */ - //#define MEMTYPE_DB 0x10 /* Uses sqlite3DbMalloc, not sqlite_malloc */ - public const int MEMTYPE_HEAP = 0x01; - public const int MEMTYPE_LOOKASIDE = 0x02; - public const int MEMTYPE_SCRATCH = 0x04; - public const int MEMTYPE_PCACHE = 0x08; - public const int MEMTYPE_DB = 0x10; - - //#endif //* _SQLITEINT_H_ */ - + //# define sqlite3MemdebugSetType(X,Y) /* no-op */ + static void sqlite3MemdebugSetType( T X, int Y ) + { + } + //# define sqlite3MemdebugHasType(X,Y) 1 + static bool sqlite3MemdebugHasType( T X, int Y ) + { + return true; + } + //# define sqlite3MemdebugNoType(X,Y) 1 + static bool sqlite3MemdebugNoType( T X, int Y ) + { + return true; } +#endif + //#define MEMTYPE_HEAP 0x01 /* General heap allocations */ + //#define MEMTYPE_LOOKASIDE 0x02 /* Might have been lookaside memory */ + //#define MEMTYPE_SCRATCH 0x04 /* Scratch allocations */ + //#define MEMTYPE_PCACHE 0x08 /* Page cache allocations */ + //#define MEMTYPE_DB 0x10 /* Uses sqlite3DbMalloc, not sqlite_malloc */ + public const int MEMTYPE_HEAP = 0x01; + public const int MEMTYPE_LOOKASIDE = 0x02; + public const int MEMTYPE_SCRATCH = 0x04; + public const int MEMTYPE_PCACHE = 0x08; + public const int MEMTYPE_DB = 0x10; + + //#endif //* _SQLITEINT_H_ */ + + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/sqliteLimit_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/sqliteLimit_h.cs index fe9e26555..713eb3960 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/sqliteLimit_h.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/sqliteLimit_h.cs @@ -1,187 +1,189 @@ -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 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. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ - /* - ** 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. - */ -#if !SQLITE_MAX_LENGTH - const int SQLITE_MAX_LENGTH = 1000000000; -#endif - - /* - ** This is the maximum number of +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 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. ** - ** * 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. + ** This file defines various limits of what SQLite can process. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* */ -#if !SQLITE_MAX_COLUMN - const int SQLITE_MAX_COLUMN = 2000; -#endif - - /* - ** The maximum length of a single SQL statement in bytes. + /* + ** The maximum length of a TEXT or BLOB in bytes. This also + ** limits the size of a row in a table or index. ** - ** 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. + ** The hard limit is the ability of a 32-bit signed integer + ** to count the size: 2^31-1 or 2147483647. */ -#if !SQLITE_MAX_SQL_LENGTH - const int SQLITE_MAX_SQL_LENGTH = 1000000000; +#if !SQLITE_MAX_LENGTH + const int 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. +*/ +#if !SQLITE_MAX_COLUMN + const int SQLITE_MAX_COLUMN = 2000; #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. - */ + /* +** 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. +*/ +#if !SQLITE_MAX_SQL_LENGTH + const int 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. +*/ #if !SQLITE_MAX_EXPR_DEPTH - const int SQLITE_MAX_EXPR_DEPTH = 1000; + const int 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. - */ + /* +** 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. +*/ #if !SQLITE_MAX_COMPOUND_SELECT - const int SQLITE_MAX_COMPOUND_SELECT = 250; + const int SQLITE_MAX_COMPOUND_SELECT = 250; #endif - /* - ** The maximum number of opcodes in a VDBE program. - ** Not currently enforced. - */ + /* +** The maximum number of opcodes in a VDBE program. +** Not currently enforced. +*/ #if !SQLITE_MAX_VDBE_OP - const int SQLITE_MAX_VDBE_OP = 25000; + const int SQLITE_MAX_VDBE_OP = 25000; #endif - /* - ** The maximum number of arguments to an SQL function. - */ + /* +** The maximum number of arguments to an SQL function. +*/ #if !SQLITE_MAX_FUNCTION_ARG - const int SQLITE_MAX_FUNCTION_ARG = 127;//# define SQLITE_MAX_FUNCTION_ARG 127 + const int SQLITE_MAX_FUNCTION_ARG = 127;//# 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 - */ + /* +** The maximum number of in-memory pages to use for the main database +** table and for temporary tables. The SQLITE_DEFAULT_CACHE_SIZE +*/ #if !SQLITE_DEFAULT_CACHE_SIZE - const int SQLITE_DEFAULT_CACHE_SIZE = 2000; + const int SQLITE_DEFAULT_CACHE_SIZE = 2000; #endif #if !SQLITE_DEFAULT_TEMP_CACHE_SIZE - const int SQLITE_DEFAULT_TEMP_CACHE_SIZE = 500; + const int 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. - */ + /* +** The default number of frames to accumulate in the log file before +** checkpointing the database in WAL mode. +*/ #if !SQLITE_DEFAULT_WAL_AUTOCHECKPOINT - const int SQLITE_DEFAULT_WAL_AUTOCHECKPOINT = 1000; - //# define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT 1000 + const int SQLITE_DEFAULT_WAL_AUTOCHECKPOINT = 1000; + //# 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. - */ +/* +** 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. +*/ #if !SQLITE_MAX_ATTACHED - const int SQLITE_MAX_ATTACHED = 10; + const int SQLITE_MAX_ATTACHED = 10; #endif - /* - ** The maximum value of a ?nnn wildcard that the parser will accept. - */ + /* +** The maximum value of a ?nnn wildcard that the parser will accept. +*/ #if !SQLITE_MAX_VARIABLE_NUMBER - const int 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. - */ - //#if SQLITE_MAX_PAGE_SIZE - //# undef SQLITE_MAX_PAGE_SIZE - //#endif - //#define SQLITE_MAX_PAGE_SIZE 65536 - const int SQLITE_MAX_PAGE_SIZE = 65535; - - - /* - ** The default size of a database page. - */ + const int 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. +*/ + //#if SQLITE_MAX_PAGE_SIZE + //# undef SQLITE_MAX_PAGE_SIZE + //#endif + //#define SQLITE_MAX_PAGE_SIZE 65536 + const int SQLITE_MAX_PAGE_SIZE = 65535; + + + /* +** The default size of a database page. +*/ #if !SQLITE_DEFAULT_PAGE_SIZE - const int SQLITE_DEFAULT_PAGE_SIZE = 1024; + const int SQLITE_DEFAULT_PAGE_SIZE = 1024; #endif #if SQLITE_DEFAULT_PAGE_SIZE //SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE //# undef SQLITE_DEFAULT_PAGE_SIZE const int 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. - */ + /* +** 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. +*/ #if !SQLITE_MAX_DEFAULT_PAGE_SIZE - const int SQLITE_MAX_DEFAULT_PAGE_SIZE = 8192; + const int SQLITE_MAX_DEFAULT_PAGE_SIZE = 8192; #endif #if SQLITE_MAX_DEFAULT_PAGE_SIZE //SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE //# undef SQLITE_MAX_DEFAULT_PAGE_SIZE @@ -189,36 +191,36 @@ const int 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. - */ + /* +** 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. +*/ #if !SQLITE_MAX_PAGE_COUNT - const int SQLITE_MAX_PAGE_COUNT = 1073741823; + const int SQLITE_MAX_PAGE_COUNT = 1073741823; #endif - /* - ** Maximum length (in bytes) of the pattern in a LIKE or GLOB - ** operator. + /* +** Maximum length (in bytes) of the pattern in a LIKE or GLOB +** operator. +*/ + //#if !SQLITE_MAX_LIKE_PATTERN_LENGTH + const int 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. */ - //#if !SQLITE_MAX_LIKE_PATTERN_LENGTH - const int 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. - */ #if !SQLITE_MAX_TRIGGER_DEPTH - const int SQLITE_MAX_TRIGGER_DEPTH = 101; // # define SQLITE_MAX_TRIGGER_DEPTH 1000 + const int SQLITE_MAX_TRIGGER_DEPTH = 101; // # define SQLITE_MAX_TRIGGER_DEPTH 1000 #else const int SQLITE_MAX_TRIGGER_DEPTH=1; #endif - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/status_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/status_c.cs index 98dd93aaa..0e4b53f47 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/status_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/status_c.cs @@ -1,244 +1,277 @@ +using System; using System.Diagnostics; +using System.Text; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2008 June 18 - ** - ** 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 module implements the sqlite3_status() interface and related - ** functionality. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include "vdbeInt.h" +namespace Community.CsharpSqlite +{ + using sqlite3_value = Sqlite3.Mem; - /* - ** Variables in which to record status information. - */ - //typedef struct sqlite3StatType sqlite3StatType; - public class sqlite3StatType { - public int[] nowValue = new int[10]; /* Current value */ - public int[] mxValue = new int[10]; /* Maximum value */ - } - public static sqlite3StatType sqlite3Stat = new sqlite3StatType(); - - /* The "wsdStat" macro will resolve to the status information - ** state vector. If writable static data is unsupported on the target, - ** we have to locate the state vector at run-time. In the more common - ** case where writable static data is supported, wsdStat can refer directly - ** to the "sqlite3Stat" state vector declared above. - */ + public partial class Sqlite3 + { + /* + ** 2008 June 18 + ** + ** 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 module implements the sqlite3_status() interface and related + ** functionality. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include "vdbeInt.h" + + /* + ** Variables in which to record status information. + */ + //typedef struct sqlite3StatType sqlite3StatType; + public class sqlite3StatType + { + public int[] nowValue = new int[10]; /* Current value */ + public int[] mxValue = new int[10]; /* Maximum value */ + } + public static sqlite3StatType sqlite3Stat = new sqlite3StatType(); + + /* The "wsdStat" macro will resolve to the status information + ** state vector. If writable static data is unsupported on the target, + ** we have to locate the state vector at run-time. In the more common + ** case where writable static data is supported, wsdStat can refer directly + ** to the "sqlite3Stat" state vector declared above. + */ #if SQLITE_OMIT_WSD //# define wsdStatInit sqlite3StatType *x = &GLOBAL(sqlite3StatType,sqlite3Stat) //# define wsdStat x[0] #else - //# define wsdStatInit - static void wsdStatInit() { - } - //# define wsdStat sqlite3Stat - static sqlite3StatType wsdStat = sqlite3Stat; + //# define wsdStatInit + static void wsdStatInit() + { + } + //# define wsdStat sqlite3Stat + static sqlite3StatType wsdStat = sqlite3Stat; #endif - /* - ** Return the current value of a status parameter. + /* +** Return the current value of a status parameter. +*/ + static int sqlite3StatusValue( int op ) + { + wsdStatInit(); + Debug.Assert( op >= 0 && op < ArraySize( wsdStat.nowValue ) ); + return wsdStat.nowValue[op]; + } + + /* + ** Add N to the value of a status record. It is assumed that the + ** caller holds appropriate locks. */ - static int sqlite3StatusValue(int op) { - wsdStatInit(); - Debug.Assert(op >= 0 && op < ArraySize(wsdStat.nowValue)); - return wsdStat.nowValue[op]; - } + static void sqlite3StatusAdd( int op, int N ) + { + wsdStatInit(); + Debug.Assert( op >= 0 && op < ArraySize( wsdStat.nowValue ) ); + wsdStat.nowValue[op] += N; + if ( wsdStat.nowValue[op] > wsdStat.mxValue[op] ) + { + wsdStat.mxValue[op] = wsdStat.nowValue[op]; + } + } - /* - ** Add N to the value of a status record. It is assumed that the - ** caller holds appropriate locks. - */ - static void sqlite3StatusAdd(int op, int N) { - wsdStatInit(); - Debug.Assert(op >= 0 && op < ArraySize(wsdStat.nowValue)); - wsdStat.nowValue[op] += N; - if (wsdStat.nowValue[op] > wsdStat.mxValue[op]) { - wsdStat.mxValue[op] = wsdStat.nowValue[op]; + /* + ** Set the value of a status to X. + */ + static void sqlite3StatusSet( int op, int X ) + { + wsdStatInit(); + Debug.Assert( op >= 0 && op < ArraySize( wsdStat.nowValue ) ); + wsdStat.nowValue[op] = X; + if ( wsdStat.nowValue[op] > wsdStat.mxValue[op] ) + { + wsdStat.mxValue[op] = wsdStat.nowValue[op]; + } + } + + /* + ** Query status information. + ** + ** This implementation assumes that reading or writing an aligned + ** 32-bit integer is an atomic operation. If that assumption is not true, + ** then this routine is not threadsafe. + */ + static public int sqlite3_status( int op, ref int pCurrent, ref int pHighwater, int resetFlag ) + { + wsdStatInit(); + if ( op < 0 || op >= ArraySize( wsdStat.nowValue ) ) + { + return SQLITE_MISUSE_BKPT(); + } + pCurrent = wsdStat.nowValue[op]; + pHighwater = wsdStat.mxValue[op]; + if ( resetFlag != 0 ) + { + wsdStat.mxValue[op] = wsdStat.nowValue[op]; + } + return SQLITE_OK; + } + /* + ** Query status information for a single database connection + */ + static public int sqlite3_db_status( + sqlite3 db, /* The database connection whose status is desired */ + int op, /* Status verb */ + ref int pCurrent, /* Write current value here */ + ref int pHighwater, /* Write high-water mark here */ + int resetFlag /* Reset high-water mark if true */ + ) + { + int rc = SQLITE_OK; /* Return code */ + sqlite3_mutex_enter( db.mutex ); + switch ( op ) + { + case SQLITE_DBSTATUS_LOOKASIDE_USED: + { + pCurrent = db.lookaside.nOut; + pHighwater = db.lookaside.mxOut; + if ( resetFlag != 0 ) + { + db.lookaside.mxOut = db.lookaside.nOut; + } + break; + } + case SQLITE_DBSTATUS_LOOKASIDE_HIT: + case SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE: + case SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL: + { + testcase( op == SQLITE_DBSTATUS_LOOKASIDE_HIT ); + testcase( op == SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE ); + testcase( op == SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL ); + Debug.Assert( ( op - SQLITE_DBSTATUS_LOOKASIDE_HIT ) >= 0 ); + Debug.Assert( ( op - SQLITE_DBSTATUS_LOOKASIDE_HIT ) < 3 ); + pCurrent = 0; + pHighwater = db.lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT]; + if ( resetFlag != 0 ) + { + db.lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT] = 0; } - } + break; + } - /* - ** Set the value of a status to X. + /* + ** Return an approximation for the amount of memory currently used + ** by all pagers associated with the given database connection. The + ** highwater mark is meaningless and is returned as zero. */ - static void sqlite3StatusSet(int op, int X) { - wsdStatInit(); - Debug.Assert(op >= 0 && op < ArraySize(wsdStat.nowValue)); - wsdStat.nowValue[op] = X; - if (wsdStat.nowValue[op] > wsdStat.mxValue[op]) { - wsdStat.mxValue[op] = wsdStat.nowValue[op]; + case SQLITE_DBSTATUS_CACHE_USED: + { + int totalUsed = 0; + int i; + sqlite3BtreeEnterAll( db ); + for ( i = 0; i < db.nDb; i++ ) + { + Btree pBt = db.aDb[i].pBt; + if ( pBt != null ) + { + Pager pPager = sqlite3BtreePager( pBt ); + totalUsed += sqlite3PagerMemUsed( pPager ); + } } - } + sqlite3BtreeLeaveAll( db ); + pCurrent = totalUsed; + pHighwater = 0; + break; + } /* - ** Query status information. - ** - ** This implementation assumes that reading or writing an aligned - ** 32-bit integer is an atomic operation. If that assumption is not true, - ** then this routine is not threadsafe. + ** *pCurrent gets an accurate estimate of the amount of memory used + ** to store the schema for all databases (main, temp, and any ATTACHed + ** databases. *pHighwater is set to zero. */ - static public int sqlite3_status(int op, ref int pCurrent, ref int pHighwater, int resetFlag) { - wsdStatInit(); - if (op < 0 || op >= ArraySize(wsdStat.nowValue)) { - return SQLITE_MISUSE_BKPT(); - } - pCurrent = wsdStat.nowValue[op]; - pHighwater = wsdStat.mxValue[op]; - if (resetFlag != 0) { - wsdStat.mxValue[op] = wsdStat.nowValue[op]; + case SQLITE_DBSTATUS_SCHEMA_USED: + { + int i; /* Used to iterate through schemas */ + int nByte = 0; /* Used to accumulate return value */ + + sqlite3BtreeEnterAll( db ); + //db.pnBytesFreed = nByte; + for ( i = 0; i < db.nDb; i++ ) + { + Schema pSchema = db.aDb[i].pSchema; + if ( ALWAYS( pSchema != null ) ) + { + HashElem p; + + //nByte += (int)(sqlite3GlobalConfig.m.xRoundup(sizeof(HashElem)) * ( + // pSchema.tblHash.count + // + pSchema.trigHash.count + // + pSchema.idxHash.count + // + pSchema.fkeyHash.count + //)); + //nByte += (int)sqlite3MallocSize( pSchema.tblHash.ht ); + //nByte += (int)sqlite3MallocSize( pSchema.trigHash.ht ); + //nByte += (int)sqlite3MallocSize( pSchema.idxHash.ht ); + //nByte += (int)sqlite3MallocSize( pSchema.fkeyHash.ht ); + + for ( p = sqliteHashFirst( pSchema.trigHash ); p != null; p = sqliteHashNext( p ) ) + { + Trigger t = (Trigger)sqliteHashData( p ); + sqlite3DeleteTrigger( db, ref t ); + } + for ( p = sqliteHashFirst( pSchema.tblHash ); p != null; p = sqliteHashNext( p ) ) + { + Table t = (Table)sqliteHashData( p ); + sqlite3DeleteTable( db, ref t ); + } + } } - return SQLITE_OK; - } + db.pnBytesFreed = 0; + sqlite3BtreeLeaveAll( db ); + + pHighwater = 0; + pCurrent = nByte; + break; + } + /* - ** Query status information for a single database connection + ** *pCurrent gets an accurate estimate of the amount of memory used + ** to store all prepared statements. + ** *pHighwater is set to zero. */ - static public int sqlite3_db_status( - sqlite3 db, /* The database connection whose status is desired */ - int op, /* Status verb */ - ref int pCurrent, /* Write current value here */ - ref int pHighwater, /* Write high-water mark here */ - int resetFlag /* Reset high-water mark if true */ - ) { - int rc = SQLITE_OK; /* Return code */ - sqlite3_mutex_enter(db.mutex); - switch (op) { - case SQLITE_DBSTATUS_LOOKASIDE_USED: { - pCurrent = db.lookaside.nOut; - pHighwater = db.lookaside.mxOut; - if (resetFlag != 0) { - db.lookaside.mxOut = db.lookaside.nOut; - } - break; - } - case SQLITE_DBSTATUS_LOOKASIDE_HIT: - case SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE: - case SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL: { - testcase(op == SQLITE_DBSTATUS_LOOKASIDE_HIT); - testcase(op == SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE); - testcase(op == SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL); - Debug.Assert((op - SQLITE_DBSTATUS_LOOKASIDE_HIT) >= 0); - Debug.Assert((op - SQLITE_DBSTATUS_LOOKASIDE_HIT) < 3); - pCurrent = 0; - pHighwater = db.lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT]; - if (resetFlag != 0) { - db.lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT] = 0; - } - break; - } - - /* - ** Return an approximation for the amount of memory currently used - ** by all pagers associated with the given database connection. The - ** highwater mark is meaningless and is returned as zero. - */ - case SQLITE_DBSTATUS_CACHE_USED: { - int totalUsed = 0; - int i; - sqlite3BtreeEnterAll(db); - for (i = 0; i < db.nDb; i++) { - Btree pBt = db.aDb[i].pBt; - if (pBt != null) { - Pager pPager = sqlite3BtreePager(pBt); - totalUsed += sqlite3PagerMemUsed(pPager); - } - } - sqlite3BtreeLeaveAll(db); - pCurrent = totalUsed; - pHighwater = 0; - break; - } - - /* - ** *pCurrent gets an accurate estimate of the amount of memory used - ** to store the schema for all databases (main, temp, and any ATTACHed - ** databases. *pHighwater is set to zero. - */ - case SQLITE_DBSTATUS_SCHEMA_USED: { - int i; /* Used to iterate through schemas */ - int nByte = 0; /* Used to accumulate return value */ - - sqlite3BtreeEnterAll(db); - //db.pnBytesFreed = nByte; - for (i = 0; i < db.nDb; i++) { - Schema pSchema = db.aDb[i].pSchema; - if (ALWAYS(pSchema != null)) { - HashElem p; - - //nByte += (int)(sqlite3GlobalConfig.m.xRoundup(sizeof(HashElem)) * ( - // pSchema.tblHash.count - // + pSchema.trigHash.count - // + pSchema.idxHash.count - // + pSchema.fkeyHash.count - //)); - //nByte += (int)sqlite3MallocSize( pSchema.tblHash.ht ); - //nByte += (int)sqlite3MallocSize( pSchema.trigHash.ht ); - //nByte += (int)sqlite3MallocSize( pSchema.idxHash.ht ); - //nByte += (int)sqlite3MallocSize( pSchema.fkeyHash.ht ); - - for (p = sqliteHashFirst(pSchema.trigHash); p != null; p = sqliteHashNext(p)) { - Trigger t = (Trigger)sqliteHashData(p); - sqlite3DeleteTrigger(db, ref t); - } - for (p = sqliteHashFirst(pSchema.tblHash); p != null; p = sqliteHashNext(p)) { - Table t = (Table)sqliteHashData(p); - sqlite3DeleteTable(db, ref t); - } - } - } - db.pnBytesFreed = 0; - sqlite3BtreeLeaveAll(db); - - pHighwater = 0; - pCurrent = nByte; - break; - } - - /* - ** *pCurrent gets an accurate estimate of the amount of memory used - ** to store all prepared statements. - ** *pHighwater is set to zero. - */ - case SQLITE_DBSTATUS_STMT_USED: { - Vdbe pVdbe; /* Used to iterate through VMs */ - int nByte = 0; /* Used to accumulate return value */ - - //db.pnBytesFreed = nByte; - for (pVdbe = db.pVdbe; pVdbe != null; pVdbe = pVdbe.pNext) { - sqlite3VdbeDeleteObject(db, ref pVdbe); - } - db.pnBytesFreed = 0; - - pHighwater = 0; - pCurrent = nByte; - - break; - } - - default: { - rc = SQLITE_ERROR; - break; - } + case SQLITE_DBSTATUS_STMT_USED: + { + Vdbe pVdbe; /* Used to iterate through VMs */ + int nByte = 0; /* Used to accumulate return value */ + + //db.pnBytesFreed = nByte; + for ( pVdbe = db.pVdbe; pVdbe != null; pVdbe = pVdbe.pNext ) + { + sqlite3VdbeDeleteObject( db, ref pVdbe ); } - sqlite3_mutex_leave(db.mutex); - return rc; - } + db.pnBytesFreed = 0; + + pHighwater = 0; + pCurrent = nByte; + + break; + } + + default: + { + rc = SQLITE_ERROR; + break; + } + } + sqlite3_mutex_leave( db.mutex ); + return rc; } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/table_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/table_c.cs index af6994916..c129d0da2 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/table_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/table_c.cs @@ -1,33 +1,40 @@ -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 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. - ** - ************************************************************************* - ** This file contains the sqlite3_get_table() and //sqlite3_free_table() - ** interface routines. These are just wrappers around the main - ** interface routine of sqlite3_exec(). - ** - ** These routines are in a separate files so that they will not be linked - ** if they are not used. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include - //#include +using System; +using System.Diagnostics; + +using i64 = System.Int64; + +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 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. + ** + ************************************************************************* + ** This file contains the sqlite3_get_table() and //sqlite3_free_table() + ** interface routines. These are just wrappers around the main + ** interface routine of sqlite3_exec(). + ** + ** These routines are in a separate files so that they will not be linked + ** if they are not used. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include + //#include #if !SQLITE_OMIT_GET_TABLE @@ -210,5 +217,5 @@ ref string pzErrMsg /* Write error messages here */ } #endif //* SQLITE_OMIT_GET_TABLE */ - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/tokenize_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/tokenize_c.cs index 542fcfb87..71b7f5aa4 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/tokenize_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/tokenize_c.cs @@ -1,560 +1,669 @@ +using System; using System.Diagnostics; using System.Text; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 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. - ** - ************************************************************************* - ** An tokenizer for SQL - ** - ** This file contains C code that splits an SQL input string up into - ** individual tokens and sends those tokens one-by-one over to the - ** parser for analysis. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 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. + ** + ************************************************************************* + ** An tokenizer for SQL + ** + ** This file contains C code that splits an SQL input string up into + ** individual tokens and sends those tokens one-by-one over to the + ** parser for analysis. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include - /* - ** The charMap() macro maps alphabetic characters into their - ** lower-case ASCII equivalent. On ASCII machines, this is just - ** an upper-to-lower case map. On EBCDIC machines we also need - ** to adjust the encoding. Only alphabetic characters and underscores - ** need to be translated. - */ + /* + ** The charMap() macro maps alphabetic characters into their + ** lower-case ASCII equivalent. On ASCII machines, this is just + ** an upper-to-lower case map. On EBCDIC machines we also need + ** to adjust the encoding. Only alphabetic characters and underscores + ** need to be translated. + */ #if SQLITE_ASCII - //# define charMap(X) sqlite3UpperToLower[(unsigned char)X] + //# define charMap(X) sqlite3UpperToLower[(unsigned char)X] #endif - //#if SQLITE_EBCDIC - //# define charMap(X) ebcdicToAscii[(unsigned char)X] - //const unsigned char ebcdicToAscii[] = { - ///* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ - // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x */ - // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 1x */ - // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 2x */ - // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 3x */ - // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 4x */ - // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 5x */ - // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 0, 0, /* 6x */ - // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 7x */ - // 0, 97, 98, 99,100,101,102,103,104,105, 0, 0, 0, 0, 0, 0, /* 8x */ - // 0,106,107,108,109,110,111,112,113,114, 0, 0, 0, 0, 0, 0, /* 9x */ - // 0, 0,115,116,117,118,119,120,121,122, 0, 0, 0, 0, 0, 0, /* Ax */ - // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Bx */ - // 0, 97, 98, 99,100,101,102,103,104,105, 0, 0, 0, 0, 0, 0, /* Cx */ - // 0,106,107,108,109,110,111,112,113,114, 0, 0, 0, 0, 0, 0, /* Dx */ - // 0, 0,115,116,117,118,119,120,121,122, 0, 0, 0, 0, 0, 0, /* Ex */ - // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Fx */ - //}; - //#endif +//#if SQLITE_EBCDIC +//# define charMap(X) ebcdicToAscii[(unsigned char)X] +//const unsigned char ebcdicToAscii[] = { +///* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x */ +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 1x */ +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 2x */ +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 3x */ +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 4x */ +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 5x */ +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 0, 0, /* 6x */ +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 7x */ +// 0, 97, 98, 99,100,101,102,103,104,105, 0, 0, 0, 0, 0, 0, /* 8x */ +// 0,106,107,108,109,110,111,112,113,114, 0, 0, 0, 0, 0, 0, /* 9x */ +// 0, 0,115,116,117,118,119,120,121,122, 0, 0, 0, 0, 0, 0, /* Ax */ +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Bx */ +// 0, 97, 98, 99,100,101,102,103,104,105, 0, 0, 0, 0, 0, 0, /* Cx */ +// 0,106,107,108,109,110,111,112,113,114, 0, 0, 0, 0, 0, 0, /* Dx */ +// 0, 0,115,116,117,118,119,120,121,122, 0, 0, 0, 0, 0, 0, /* Ex */ +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Fx */ +//}; +//#endif - /* - ** The sqlite3KeywordCode function looks up an identifier to determine if - ** it is a keyword. If it is a keyword, the token code of that keyword is - ** returned. If the input is not a keyword, TK_ID is returned. - ** - ** The implementation of this routine was generated by a program, - ** mkkeywordhash.h, located in the tool subdirectory of the distribution. - ** The output of the mkkeywordhash.c program is written into a file - ** named keywordhash.h and then included into this source file by - ** the #include below. - */ - //#include "keywordhash.h" + /* +** The sqlite3KeywordCode function looks up an identifier to determine if +** it is a keyword. If it is a keyword, the token code of that keyword is +** returned. If the input is not a keyword, TK_ID is returned. +** +** The implementation of this routine was generated by a program, +** mkkeywordhash.h, located in the tool subdirectory of the distribution. +** The output of the mkkeywordhash.c program is written into a file +** named keywordhash.h and then included into this source file by +** the #include below. +*/ + //#include "keywordhash.h" - /* - ** If X is a character that can be used in an identifier then - ** IdChar(X) will be true. Otherwise it is false. - ** - ** For ASCII, any character with the high-order bit set is - ** allowed in an identifier. For 7-bit characters, - ** sqlite3IsIdChar[X] must be 1. - ** - ** For EBCDIC, the rules are more complex but have the same - ** end result. - ** - ** Ticket #1066. the SQL standard does not allow '$' in the - ** middle of identfiers. But many SQL implementations do. - ** SQLite will allow '$' in identifiers for compatibility. - ** But the feature is undocumented. - */ + /* + ** If X is a character that can be used in an identifier then + ** IdChar(X) will be true. Otherwise it is false. + ** + ** For ASCII, any character with the high-order bit set is + ** allowed in an identifier. For 7-bit characters, + ** sqlite3IsIdChar[X] must be 1. + ** + ** For EBCDIC, the rules are more complex but have the same + ** end result. + ** + ** Ticket #1066. the SQL standard does not allow '$' in the + ** middle of identfiers. But many SQL implementations do. + ** SQLite will allow '$' in identifiers for compatibility. + ** But the feature is undocumented. + */ #if SQLITE_ASCII - //#define IdChar(C) ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0) + //#define IdChar(C) ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0) #endif - //#if SQLITE_EBCDIC - //const char sqlite3IsEbcdicIdChar[] = { - ///* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */ - // 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 4x */ - // 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, /* 5x */ - // 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, /* 6x */ - // 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, /* 7x */ - // 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, /* 8x */ - // 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, /* 9x */ - // 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, /* Ax */ - // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Bx */ - // 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Cx */ - // 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Dx */ - // 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Ex */ - // 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, /* Fx */ - //}; - //#define IdChar(C) (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40])) - //#endif +//#if SQLITE_EBCDIC +//const char sqlite3IsEbcdicIdChar[] = { +///* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */ +// 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 4x */ +// 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, /* 5x */ +// 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, /* 6x */ +// 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, /* 7x */ +// 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, /* 8x */ +// 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, /* 9x */ +// 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, /* Ax */ +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Bx */ +// 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Cx */ +// 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Dx */ +// 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Ex */ +// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, /* Fx */ +//}; +//#define IdChar(C) (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40])) +//#endif - /* - ** Return the length of the token that begins at z[iOffset + 0]. - ** Store the token type in *tokenType before returning. - */ - static int sqlite3GetToken(string z, int iOffset, ref int tokenType) { - int i; - byte c = 0; - switch (z[iOffset + 0]) { - case ' ': - case '\t': - case '\n': - case '\f': - case '\r': { - testcase(z[iOffset + 0] == ' '); - testcase(z[iOffset + 0] == '\t'); - testcase(z[iOffset + 0] == '\n'); - testcase(z[iOffset + 0] == '\f'); - testcase(z[iOffset + 0] == '\r'); - for (i = 1; z.Length > iOffset + i && sqlite3Isspace(z[iOffset + i]); i++) { - } - tokenType = TK_SPACE; - return i; - } - case '-': { - if (z.Length > iOffset + 1 && z[iOffset + 1] == '-') { - /* IMP: R-15891-05542 -- syntax diagram for comments */ - for (i = 2; z.Length > iOffset + i && (c = (byte)z[iOffset + i]) != 0 && c != '\n'; i++) { - } - tokenType = TK_SPACE; /* IMP: R-22934-25134 */ - return i; - } - tokenType = TK_MINUS; - return 1; - } - case '(': { - tokenType = TK_LP; - return 1; - } - case ')': { - tokenType = TK_RP; - return 1; - } - case ';': { - tokenType = TK_SEMI; - return 1; - } - case '+': { - tokenType = TK_PLUS; - return 1; - } - case '*': { - tokenType = TK_STAR; - return 1; - } - case '/': { - if (iOffset + 2 >= z.Length || z[iOffset + 1] != '*') { - tokenType = TK_SLASH; - return 1; - } - /* IMP: R-15891-05542 -- syntax diagram for comments */ - for (i = 3, c = (byte)z[iOffset + 2]; iOffset + i < z.Length && (c != '*' || (z[iOffset + i] != '/') && (c != 0)); i++) { - c = (byte)z[iOffset + i]; - } - if (iOffset + i == z.Length) - c = 0; - if (c != 0) - i++; - tokenType = TK_SPACE; /* IMP: R-22934-25134 */ - return i; - } - case '%': { - tokenType = TK_REM; - return 1; - } - case '=': { - tokenType = TK_EQ; - return 1 + (z[iOffset + 1] == '=' ? 1 : 0); - } - case '<': { - if ((c = (byte)z[iOffset + 1]) == '=') { - tokenType = TK_LE; - return 2; - } else if (c == '>') { - tokenType = TK_NE; - return 2; - } else if (c == '<') { - tokenType = TK_LSHIFT; - return 2; - } else { - tokenType = TK_LT; - return 1; - } - } - case '>': { - if (z.Length > iOffset + 1 && (c = (byte)z[iOffset + 1]) == '=') { - tokenType = TK_GE; - return 2; - } else if (c == '>') { - tokenType = TK_RSHIFT; - return 2; - } else { - tokenType = TK_GT; - return 1; - } - } - case '!': { - if (z[iOffset + 1] != '=') { - tokenType = TK_ILLEGAL; - return 2; - } else { - tokenType = TK_NE; - return 2; - } - } - case '|': { - if (z[iOffset + 1] != '|') { - tokenType = TK_BITOR; - return 1; - } else { - tokenType = TK_CONCAT; - return 2; - } - } - case ',': { - tokenType = TK_COMMA; - return 1; - } - case '&': { - tokenType = TK_BITAND; - return 1; - } - case '~': { - tokenType = TK_BITNOT; - return 1; - } - case '`': - case '\'': - case '"': { - int delim = z[iOffset + 0]; - testcase(delim == '`'); - testcase(delim == '\''); - testcase(delim == '"'); - for (i = 1; (iOffset + i) < z.Length && (c = (byte)z[iOffset + i]) != 0; i++) { - if (c == delim) { - if (z.Length > iOffset + i + 1 && z[iOffset + i + 1] == delim) { - i++; - } else { - break; - } - } - } - if ((iOffset + i == z.Length && c != delim) || z[iOffset + i] != delim) { - tokenType = TK_ILLEGAL; - return i + 1; - } - if (c == '\'') { - tokenType = TK_STRING; - return i + 1; - } else if (c != 0) { - tokenType = TK_ID; - return i + 1; - } else { - tokenType = TK_ILLEGAL; - return i; - } - } - case '.': { + /* +** Return the length of the token that begins at z[iOffset + 0]. +** Store the token type in *tokenType before returning. +*/ + static int sqlite3GetToken( string z, int iOffset, ref int tokenType ) + { + int i; + byte c = 0; + switch ( z[iOffset + 0] ) + { + case ' ': + case '\t': + case '\n': + case '\f': + case '\r': + { + testcase( z[iOffset + 0] == ' ' ); + testcase( z[iOffset + 0] == '\t' ); + testcase( z[iOffset + 0] == '\n' ); + testcase( z[iOffset + 0] == '\f' ); + testcase( z[iOffset + 0] == '\r' ); + for ( i = 1; z.Length > iOffset + i && sqlite3Isspace( z[iOffset + i] ); i++ ) + { + } + tokenType = TK_SPACE; + return i; + } + case '-': + { + if ( z.Length > iOffset + 1 && z[iOffset + 1] == '-' ) + { + /* IMP: R-15891-05542 -- syntax diagram for comments */ + for ( i = 2; z.Length > iOffset + i && ( c = (byte)z[iOffset + i] ) != 0 && c != '\n'; i++ ) + { + } + tokenType = TK_SPACE; /* IMP: R-22934-25134 */ + return i; + } + tokenType = TK_MINUS; + return 1; + } + case '(': + { + tokenType = TK_LP; + return 1; + } + case ')': + { + tokenType = TK_RP; + return 1; + } + case ';': + { + tokenType = TK_SEMI; + return 1; + } + case '+': + { + tokenType = TK_PLUS; + return 1; + } + case '*': + { + tokenType = TK_STAR; + return 1; + } + case '/': + { + if ( iOffset + 2 >= z.Length || z[iOffset + 1] != '*' ) + { + tokenType = TK_SLASH; + return 1; + } + /* IMP: R-15891-05542 -- syntax diagram for comments */ + for ( i = 3, c = (byte)z[iOffset + 2]; iOffset + i < z.Length && ( c != '*' || ( z[iOffset + i] != '/' ) && ( c != 0 ) ); i++ ) + { + c = (byte)z[iOffset + i]; + } + if ( iOffset + i == z.Length ) + c = 0; + if ( c != 0 ) + i++; + tokenType = TK_SPACE; /* IMP: R-22934-25134 */ + return i; + } + case '%': + { + tokenType = TK_REM; + return 1; + } + case '=': + { + tokenType = TK_EQ; + return 1 + ( z[iOffset + 1] == '=' ? 1 : 0 ); + } + case '<': + { + if ( ( c = (byte)z[iOffset + 1] ) == '=' ) + { + tokenType = TK_LE; + return 2; + } + else if ( c == '>' ) + { + tokenType = TK_NE; + return 2; + } + else if ( c == '<' ) + { + tokenType = TK_LSHIFT; + return 2; + } + else + { + tokenType = TK_LT; + return 1; + } + } + case '>': + { + if ( z.Length > iOffset + 1 && ( c = (byte)z[iOffset + 1] ) == '=' ) + { + tokenType = TK_GE; + return 2; + } + else if ( c == '>' ) + { + tokenType = TK_RSHIFT; + return 2; + } + else + { + tokenType = TK_GT; + return 1; + } + } + case '!': + { + if ( z[iOffset + 1] != '=' ) + { + tokenType = TK_ILLEGAL; + return 2; + } + else + { + tokenType = TK_NE; + return 2; + } + } + case '|': + { + if ( z[iOffset + 1] != '|' ) + { + tokenType = TK_BITOR; + return 1; + } + else + { + tokenType = TK_CONCAT; + return 2; + } + } + case ',': + { + tokenType = TK_COMMA; + return 1; + } + case '&': + { + tokenType = TK_BITAND; + return 1; + } + case '~': + { + tokenType = TK_BITNOT; + return 1; + } + case '`': + case '\'': + case '"': + { + int delim = z[iOffset + 0]; + testcase( delim == '`' ); + testcase( delim == '\'' ); + testcase( delim == '"' ); + for ( i = 1; ( iOffset + i ) < z.Length && ( c = (byte)z[iOffset + i] ) != 0; i++ ) + { + if ( c == delim ) + { + if ( z.Length > iOffset + i + 1 && z[iOffset + i + 1] == delim ) + { + i++; + } + else + { + break; + } + } + } + if ( ( iOffset + i == z.Length && c != delim ) || z[iOffset + i] != delim ) + { + tokenType = TK_ILLEGAL; + return i + 1; + } + if ( c == '\'' ) + { + tokenType = TK_STRING; + return i + 1; + } + else if ( c != 0 ) + { + tokenType = TK_ID; + return i + 1; + } + else + { + tokenType = TK_ILLEGAL; + return i; + } + } + case '.': + { #if !SQLITE_OMIT_FLOATING_POINT - if (!sqlite3Isdigit(z[iOffset + 1])) + if ( !sqlite3Isdigit( z[iOffset + 1] ) ) #endif - { - tokenType = TK_DOT; - return 1; - } - /* If the next character is a digit, this is a floating point - ** number that begins with ".". Fall thru into the next case */ - goto case '0'; - } - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': { - testcase(z[iOffset] == '0'); - testcase(z[iOffset] == '1'); - testcase(z[iOffset] == '2'); - testcase(z[iOffset] == '3'); - testcase(z[iOffset] == '4'); - testcase(z[iOffset] == '5'); - testcase(z[iOffset] == '6'); - testcase(z[iOffset] == '7'); - testcase(z[iOffset] == '8'); - testcase(z[iOffset] == '9'); - tokenType = TK_INTEGER; - for (i = 0; z.Length > iOffset + i && sqlite3Isdigit(z[iOffset + i]); i++) { - } + { + tokenType = TK_DOT; + return 1; + } + /* If the next character is a digit, this is a floating point + ** number that begins with ".". Fall thru into the next case */ + goto case '0'; + } + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + testcase( z[iOffset] == '0' ); + testcase( z[iOffset] == '1' ); + testcase( z[iOffset] == '2' ); + testcase( z[iOffset] == '3' ); + testcase( z[iOffset] == '4' ); + testcase( z[iOffset] == '5' ); + testcase( z[iOffset] == '6' ); + testcase( z[iOffset] == '7' ); + testcase( z[iOffset] == '8' ); + testcase( z[iOffset] == '9' ); + tokenType = TK_INTEGER; + for ( i = 0; z.Length > iOffset + i && sqlite3Isdigit( z[iOffset + i] ); i++ ) + { + } #if !SQLITE_OMIT_FLOATING_POINT - if (z.Length > iOffset + i && z[iOffset + i] == '.') { - i++; - while (z.Length > iOffset + i && sqlite3Isdigit(z[iOffset + i])) { - i++; - } - tokenType = TK_FLOAT; - } - if (z.Length > iOffset + i + 1 && (z[iOffset + i] == 'e' || z[iOffset + i] == 'E') && - (sqlite3Isdigit(z[iOffset + i + 1]) - || z.Length > iOffset + i + 2 && ((z[iOffset + i + 1] == '+' || z[iOffset + i + 1] == '-') && sqlite3Isdigit(z[iOffset + i + 2])) - ) - ) { - i += 2; - while (z.Length > iOffset + i && sqlite3Isdigit(z[iOffset + i])) { - i++; - } - tokenType = TK_FLOAT; - } + if ( z.Length > iOffset + i && z[iOffset + i] == '.' ) + { + i++; + while ( z.Length > iOffset + i && sqlite3Isdigit( z[iOffset + i] ) ) + { + i++; + } + tokenType = TK_FLOAT; + } + if ( z.Length > iOffset + i + 1 && ( z[iOffset + i] == 'e' || z[iOffset + i] == 'E' ) && + ( sqlite3Isdigit( z[iOffset + i + 1] ) + || z.Length > iOffset + i + 2 && ( ( z[iOffset + i + 1] == '+' || z[iOffset + i + 1] == '-' ) && sqlite3Isdigit( z[iOffset + i + 2] ) ) + ) + ) + { + i += 2; + while ( z.Length > iOffset + i && sqlite3Isdigit( z[iOffset + i] ) ) + { + i++; + } + tokenType = TK_FLOAT; + } #endif - while (iOffset + i < z.Length && IdChar((byte)z[iOffset + i])) { - tokenType = TK_ILLEGAL; - i++; - } - return i; - } + while ( iOffset + i < z.Length && IdChar( (byte)z[iOffset + i] ) ) + { + tokenType = TK_ILLEGAL; + i++; + } + return i; + } - case '[': { - for (i = 1, c = (byte)z[iOffset + 0]; c != ']' && (iOffset + i) < z.Length && (c = (byte)z[iOffset + i]) != 0; i++) { - } - tokenType = c == ']' ? TK_ID : TK_ILLEGAL; - return i; - } - case '?': { - tokenType = TK_VARIABLE; - for (i = 1; z.Length > iOffset + i && sqlite3Isdigit(z[iOffset + i]); i++) { - } - return i; - } - case '#': { - for (i = 1; z.Length > iOffset + i && sqlite3Isdigit(z[iOffset + i]); i++) { - } - if (i > 1) { - /* Parameters of the form #NNN (where NNN is a number) are used - ** internally by sqlite3NestedParse. */ - tokenType = TK_REGISTER; - return i; - } - /* Fall through into the next case if the '#' is not followed by - ** a digit. Try to match #AAAA where AAAA is a parameter name. */ - goto case ':'; - } + case '[': + { + for ( i = 1, c = (byte)z[iOffset + 0]; c != ']' && ( iOffset + i ) < z.Length && ( c = (byte)z[iOffset + i] ) != 0; i++ ) + { + } + tokenType = c == ']' ? TK_ID : TK_ILLEGAL; + return i; + } + case '?': + { + tokenType = TK_VARIABLE; + for ( i = 1; z.Length > iOffset + i && sqlite3Isdigit( z[iOffset + i] ); i++ ) + { + } + return i; + } + case '#': + { + for ( i = 1; z.Length > iOffset + i && sqlite3Isdigit( z[iOffset + i] ); i++ ) + { + } + if ( i > 1 ) + { + /* Parameters of the form #NNN (where NNN is a number) are used + ** internally by sqlite3NestedParse. */ + tokenType = TK_REGISTER; + return i; + } + /* Fall through into the next case if the '#' is not followed by + ** a digit. Try to match #AAAA where AAAA is a parameter name. */ + goto case ':'; + } #if !SQLITE_OMIT_TCL_VARIABLE - case '$': + case '$': #endif - case '@': /* For compatibility with MS SQL Server */ - case ':': { - int n = 0; - testcase(z[iOffset + 0] == '$'); - testcase(z[iOffset + 0] == '@'); - testcase(z[iOffset + 0] == ':'); - tokenType = TK_VARIABLE; - for (i = 1; z.Length > iOffset + i && (c = (byte)z[iOffset + i]) != 0; i++) { - if (IdChar(c)) { - n++; + case '@': /* For compatibility with MS SQL Server */ + case ':': + { + int n = 0; + testcase( z[iOffset + 0] == '$' ); + testcase( z[iOffset + 0] == '@' ); + testcase( z[iOffset + 0] == ':' ); + tokenType = TK_VARIABLE; + for ( i = 1; z.Length > iOffset + i && ( c = (byte)z[iOffset + i] ) != 0; i++ ) + { + if ( IdChar( c ) ) + { + n++; #if !SQLITE_OMIT_TCL_VARIABLE - } else if (c == '(' && n > 0) { - do { - i++; - } while ((iOffset + i) < z.Length && (c = (byte)z[iOffset + i]) != 0 && !sqlite3Isspace(c) && c != ')'); - if (c == ')') { - i++; - } else { - tokenType = TK_ILLEGAL; - } - break; - } else if (c == ':' && z[iOffset + i + 1] == ':') { - i++; + } + else if ( c == '(' && n > 0 ) + { + do + { + i++; + } while ( ( iOffset + i ) < z.Length && ( c = (byte)z[iOffset + i] ) != 0 && !sqlite3Isspace( c ) && c != ')' ); + if ( c == ')' ) + { + i++; + } + else + { + tokenType = TK_ILLEGAL; + } + break; + } + else if ( c == ':' && z[iOffset + i + 1] == ':' ) + { + i++; #endif - } else { - break; - } - } - if (n == 0) - tokenType = TK_ILLEGAL; - return i; - } + } + else + { + break; + } + } + if ( n == 0 ) + tokenType = TK_ILLEGAL; + return i; + } #if !SQLITE_OMIT_BLOB_LITERAL - case 'x': - case 'X': { - testcase(z[iOffset + 0] == 'x'); - testcase(z[iOffset + 0] == 'X'); - if (z.Length > iOffset + 1 && z[iOffset + 1] == '\'') { - tokenType = TK_BLOB; - for (i = 2; z.Length > iOffset + i && sqlite3Isxdigit(z[iOffset + i]); i++) { - } - if (iOffset + i == z.Length || z[iOffset + i] != '\'' || i % 2 != 0) { - tokenType = TK_ILLEGAL; - while (z.Length > iOffset + i && z[iOffset + i] != '\'') { - i++; - } - } - if (z.Length > iOffset + i) - i++; - return i; - } - goto default; - /* Otherwise fall through to the next case */ - } + case 'x': + case 'X': + { + testcase( z[iOffset + 0] == 'x' ); + testcase( z[iOffset + 0] == 'X' ); + if ( z.Length > iOffset + 1 && z[iOffset + 1] == '\'' ) + { + tokenType = TK_BLOB; + for ( i = 2; z.Length > iOffset + i && sqlite3Isxdigit( z[iOffset + i] ); i++ ) + { + } + if ( iOffset + i == z.Length || z[iOffset + i] != '\'' || i % 2 != 0 ) + { + tokenType = TK_ILLEGAL; + while ( z.Length > iOffset + i && z[iOffset + i] != '\'' ) + { + i++; + } + } + if ( z.Length > iOffset + i ) + i++; + return i; + } + goto default; + /* Otherwise fall through to the next case */ + } #endif - default: { - if (!IdChar((byte)z[iOffset])) { - break; - } - for (i = 1; i < z.Length - iOffset && IdChar((byte)z[iOffset + i]); i++) { - } - tokenType = keywordCode(z, iOffset, i); - return i; - } - } - tokenType = TK_ILLEGAL; - return 1; - } + default: + { + if ( !IdChar( (byte)z[iOffset] ) ) + { + break; + } + for ( i = 1; i < z.Length - iOffset && IdChar( (byte)z[iOffset + i] ); i++ ) + { + } + tokenType = keywordCode( z, iOffset, i ); + return i; + } + } + tokenType = TK_ILLEGAL; + return 1; + } - /* - ** Run the parser on the given SQL string. The parser structure is - ** passed in. An SQLITE_ status code is returned. If an error occurs - ** then an and attempt is made to write an error message into - ** memory obtained from sqlite3_malloc() and to make pzErrMsg point to that - ** error message. - */ - static int sqlite3RunParser(Parse pParse, string zSql, ref string pzErrMsg) { - int nErr = 0; /* Number of errors encountered */ - int i; /* Loop counter */ - yyParser pEngine; /* The LEMON-generated LALR(1) parser */ - int tokenType = 0; /* type of the next token */ - int lastTokenParsed = -1; /* type of the previous token */ - byte enableLookaside; /* Saved value of db->lookaside.bEnabled */ - sqlite3 db = pParse.db; /* The database connection */ - int mxSqlLen; /* Max length of an SQL string */ + /* + ** Run the parser on the given SQL string. The parser structure is + ** passed in. An SQLITE_ status code is returned. If an error occurs + ** then an and attempt is made to write an error message into + ** memory obtained from sqlite3_malloc() and to make pzErrMsg point to that + ** error message. + */ + static int sqlite3RunParser( Parse pParse, string zSql, ref string pzErrMsg ) + { + int nErr = 0; /* Number of errors encountered */ + int i; /* Loop counter */ + yyParser pEngine; /* The LEMON-generated LALR(1) parser */ + int tokenType = 0; /* type of the next token */ + int lastTokenParsed = -1; /* type of the previous token */ + byte enableLookaside; /* Saved value of db->lookaside.bEnabled */ + sqlite3 db = pParse.db; /* The database connection */ + int mxSqlLen; /* Max length of an SQL string */ - mxSqlLen = db.aLimit[SQLITE_LIMIT_SQL_LENGTH]; - if (db.activeVdbeCnt == 0) { - db.u1.isInterrupted = false; - } - pParse.rc = SQLITE_OK; - pParse.zTail = new StringBuilder(zSql); - i = 0; - Debug.Assert(pzErrMsg != null); - pEngine = sqlite3ParserAlloc();//sqlite3ParserAlloc((void*(*)(size_t))sqlite3Malloc); - //if ( pEngine == null ) - //{ - // db.mallocFailed = 1; - // return SQLITE_NOMEM; - //} - Debug.Assert(pParse.pNewTable == null); - Debug.Assert(pParse.pNewTrigger == null); - Debug.Assert(pParse.nVar == 0); - Debug.Assert(pParse.nzVar == 0); - Debug.Assert(pParse.azVar == null); - enableLookaside = db.lookaside.bEnabled; - if (db.lookaside.pStart != 0) - db.lookaside.bEnabled = 1; - while ( /* 0 == db.mallocFailed && */ i < zSql.Length) { - Debug.Assert(i >= 0); - //pParse->sLastToken.z = &zSql[i]; - pParse.sLastToken.n = sqlite3GetToken(zSql, i, ref tokenType); - pParse.sLastToken.z = zSql.Substring(i); - i += pParse.sLastToken.n; - if (i > mxSqlLen) { - pParse.rc = SQLITE_TOOBIG; - break; - } - switch (tokenType) { - case TK_SPACE: { - if (db.u1.isInterrupted) { - sqlite3ErrorMsg(pParse, "interrupt"); - pParse.rc = SQLITE_INTERRUPT; - goto abort_parse; - } - break; - } - case TK_ILLEGAL: { - sqlite3DbFree(db, ref pzErrMsg); - pzErrMsg = sqlite3MPrintf(db, "unrecognized token: \"%T\"", - (object)pParse.sLastToken); - nErr++; - goto abort_parse; - } - case TK_SEMI: { - //pParse.zTail = new StringBuilder(zSql.Substring( i,zSql.Length-i )); - /* Fall thru into the default case */ - goto default; - } - default: { - sqlite3Parser(pEngine, tokenType, pParse.sLastToken, pParse); - lastTokenParsed = tokenType; - if (pParse.rc != SQLITE_OK) { - goto abort_parse; - } - break; - } - } + mxSqlLen = db.aLimit[SQLITE_LIMIT_SQL_LENGTH]; + if ( db.activeVdbeCnt == 0 ) + { + db.u1.isInterrupted = false; + } + pParse.rc = SQLITE_OK; + pParse.zTail = new StringBuilder( zSql ); + i = 0; + Debug.Assert( pzErrMsg != null ); + pEngine = sqlite3ParserAlloc();//sqlite3ParserAlloc((void*(*)(size_t))sqlite3Malloc); + //if ( pEngine == null ) + //{ + // db.mallocFailed = 1; + // return SQLITE_NOMEM; + //} + Debug.Assert( pParse.pNewTable == null ); + Debug.Assert( pParse.pNewTrigger == null ); + Debug.Assert( pParse.nVar == 0 ); + Debug.Assert( pParse.nzVar == 0 ); + Debug.Assert( pParse.azVar == null ); + enableLookaside = db.lookaside.bEnabled; + if ( db.lookaside.pStart != 0 ) + db.lookaside.bEnabled = 1; + while ( /* 0 == db.mallocFailed && */ i < zSql.Length ) + { + Debug.Assert( i >= 0 ); + //pParse->sLastToken.z = &zSql[i]; + pParse.sLastToken.n = sqlite3GetToken( zSql, i, ref tokenType ); + pParse.sLastToken.z = zSql.Substring( i ); + i += pParse.sLastToken.n; + if ( i > mxSqlLen ) + { + pParse.rc = SQLITE_TOOBIG; + break; + } + switch ( tokenType ) + { + case TK_SPACE: + { + if ( db.u1.isInterrupted ) + { + sqlite3ErrorMsg( pParse, "interrupt" ); + pParse.rc = SQLITE_INTERRUPT; + goto abort_parse; + } + break; } - abort_parse: - pParse.zTail = new StringBuilder(zSql.Length <= i ? "" : zSql.Substring(i)); - if (zSql.Length >= i && nErr == 0 && pParse.rc == SQLITE_OK) { - if (lastTokenParsed != TK_SEMI) { - sqlite3Parser(pEngine, TK_SEMI, pParse.sLastToken, pParse); - } - sqlite3Parser(pEngine, 0, pParse.sLastToken, pParse); + case TK_ILLEGAL: + { + sqlite3DbFree( db, ref pzErrMsg ); + pzErrMsg = sqlite3MPrintf( db, "unrecognized token: \"%T\"", + (object)pParse.sLastToken ); + nErr++; + goto abort_parse; + } + case TK_SEMI: + { + //pParse.zTail = new StringBuilder(zSql.Substring( i,zSql.Length-i )); + /* Fall thru into the default case */ + goto default; } + default: + { + sqlite3Parser( pEngine, tokenType, pParse.sLastToken, pParse ); + lastTokenParsed = tokenType; + if ( pParse.rc != SQLITE_OK ) + { + goto abort_parse; + } + break; + } + } + } +abort_parse: + pParse.zTail = new StringBuilder( zSql.Length <= i ? "" : zSql.Substring( i ) ); + if ( zSql.Length >= i && nErr == 0 && pParse.rc == SQLITE_OK ) + { + if ( lastTokenParsed != TK_SEMI ) + { + sqlite3Parser( pEngine, TK_SEMI, pParse.sLastToken, pParse ); + } + sqlite3Parser( pEngine, 0, pParse.sLastToken, pParse ); + } #if YYTRACKMAXSTACKDEPTH sqlite3StatusSet(SQLITE_STATUS_PARSER_STACK, sqlite3ParserStackPeak(pEngine) ); #endif //* YYDEBUG */ - sqlite3ParserFree(pEngine, null);//sqlite3_free ); - db.lookaside.bEnabled = enableLookaside; - //if ( db.mallocFailed != 0 ) - //{ - // pParse.rc = SQLITE_NOMEM; - //} - if (pParse.rc != SQLITE_OK && pParse.rc != SQLITE_DONE && pParse.zErrMsg == "") { - sqlite3SetString(ref pParse.zErrMsg, db, sqlite3ErrStr(pParse.rc)); - } - //assert( pzErrMsg!=0 ); - if (pParse.zErrMsg != null) { - pzErrMsg = pParse.zErrMsg; - sqlite3_log(pParse.rc, "%s", pzErrMsg); - pParse.zErrMsg = ""; - nErr++; - } - if (pParse.pVdbe != null && pParse.nErr > 0 && pParse.nested == 0) { - sqlite3VdbeDelete(ref pParse.pVdbe); - pParse.pVdbe = null; - } + sqlite3ParserFree( pEngine, null );//sqlite3_free ); + db.lookaside.bEnabled = enableLookaside; + //if ( db.mallocFailed != 0 ) + //{ + // pParse.rc = SQLITE_NOMEM; + //} + if ( pParse.rc != SQLITE_OK && pParse.rc != SQLITE_DONE && pParse.zErrMsg == "" ) + { + sqlite3SetString( ref pParse.zErrMsg, db, sqlite3ErrStr( pParse.rc ) ); + } + //assert( pzErrMsg!=0 ); + if ( pParse.zErrMsg != null ) + { + pzErrMsg = pParse.zErrMsg; + sqlite3_log( pParse.rc, "%s", pzErrMsg ); + pParse.zErrMsg = ""; + nErr++; + } + if ( pParse.pVdbe != null && pParse.nErr > 0 && pParse.nested == 0 ) + { + sqlite3VdbeDelete( ref pParse.pVdbe ); + pParse.pVdbe = null; + } #if !SQLITE_OMIT_SHARED_CACHE if ( pParse.nested == 0 ) { @@ -564,37 +673,41 @@ static int sqlite3RunParser(Parse pParse, string zSql, ref string pzErrMsg) { } #endif #if !SQLITE_OMIT_VIRTUALTABLE - pParse.apVtabLock = null;//sqlite3_free( pParse.apVtabLock ); + pParse.apVtabLock = null;//sqlite3_free( pParse.apVtabLock ); #endif - if (!IN_DECLARE_VTAB(pParse)) { - /* If the pParse.declareVtab flag is set, do not delete any table - ** structure built up in pParse.pNewTable. The calling code (see vtab.c) - ** will take responsibility for freeing the Table structure. - */ - sqlite3DeleteTable(db, ref pParse.pNewTable); - } + if ( !IN_DECLARE_VTAB(pParse) ) + { + /* If the pParse.declareVtab flag is set, do not delete any table + ** structure built up in pParse.pNewTable. The calling code (see vtab.c) + ** will take responsibility for freeing the Table structure. + */ + sqlite3DeleteTable( db, ref pParse.pNewTable ); + } #if !SQLITE_OMIT_TRIGGER - sqlite3DeleteTrigger(db, ref pParse.pNewTrigger); + sqlite3DeleteTrigger( db, ref pParse.pNewTrigger ); #endif - //for ( i = pParse.nzVar - 1; i >= 0; i-- ) - // sqlite3DbFree( db, pParse.azVar[i] ); - sqlite3DbFree(db, ref pParse.azVar); - sqlite3DbFree(db, ref pParse.aAlias); - while (pParse.pAinc != null) { - AutoincInfo p = pParse.pAinc; - pParse.pAinc = p.pNext; - sqlite3DbFree(db, ref p); - } - while (pParse.pZombieTab != null) { - Table p = pParse.pZombieTab; - pParse.pZombieTab = p.pNextZombie; - sqlite3DeleteTable(db, ref p); - } - if (nErr > 0 && pParse.rc == SQLITE_OK) { - pParse.rc = SQLITE_ERROR; - } - return nErr; - } + //for ( i = pParse.nzVar - 1; i >= 0; i-- ) + // sqlite3DbFree( db, pParse.azVar[i] ); + sqlite3DbFree( db, ref pParse.azVar ); + sqlite3DbFree( db, ref pParse.aAlias ); + while ( pParse.pAinc != null ) + { + AutoincInfo p = pParse.pAinc; + pParse.pAinc = p.pNext; + sqlite3DbFree( db, ref p ); + } + while ( pParse.pZombieTab != null ) + { + Table p = pParse.pZombieTab; + pParse.pZombieTab = p.pNextZombie; + sqlite3DeleteTable( db, ref p ); + } + if ( nErr > 0 && pParse.rc == SQLITE_OK ) + { + pParse.rc = SQLITE_ERROR; + } + return nErr; } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/trigger_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/trigger_c.cs index b27f77339..6a29a4232 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/trigger_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/trigger_c.cs @@ -1,235 +1,266 @@ using System; using System.Diagnostics; +using System.Text; -using u32 = System.UInt32; using u8 = System.Byte; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** - ** 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 contains the implementation for TRIGGERs - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +using u32 = System.UInt32; +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** + ** 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 contains the implementation for TRIGGERs + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" #if !SQLITE_OMIT_TRIGGER - /* - ** Delete a linked list of TriggerStep structures. + /* +** Delete a linked list of TriggerStep structures. +*/ + static void sqlite3DeleteTriggerStep( sqlite3 db, ref TriggerStep pTriggerStep ) + { + while ( pTriggerStep != null ) + { + TriggerStep pTmp = pTriggerStep; + pTriggerStep = pTriggerStep.pNext; + + sqlite3ExprDelete( db, ref pTmp.pWhere ); + sqlite3ExprListDelete( db, ref pTmp.pExprList ); + sqlite3SelectDelete( db, ref pTmp.pSelect ); + sqlite3IdListDelete( db, ref pTmp.pIdList ); + + pTriggerStep = null; + sqlite3DbFree( db, ref pTmp ); + } + } + + /* + ** Given table pTab, return a list of all the triggers attached to + ** the table. The list is connected by Trigger.pNext pointers. + ** + ** All of the triggers on pTab that are in the same database as pTab + ** are already attached to pTab.pTrigger. But there might be additional + ** triggers on pTab in the TEMP schema. This routine prepends all + ** TEMP triggers on pTab to the beginning of the pTab.pTrigger list + ** and returns the combined list. + ** + ** To state it another way: This routine returns a list of all triggers + ** that fire off of pTab. The list will include any TEMP triggers on + ** pTab as well as the triggers lised in pTab.pTrigger. */ - static void sqlite3DeleteTriggerStep(sqlite3 db, ref TriggerStep pTriggerStep) { - while (pTriggerStep != null) { - TriggerStep pTmp = pTriggerStep; - pTriggerStep = pTriggerStep.pNext; - - sqlite3ExprDelete(db, ref pTmp.pWhere); - sqlite3ExprListDelete(db, ref pTmp.pExprList); - sqlite3SelectDelete(db, ref pTmp.pSelect); - sqlite3IdListDelete(db, ref pTmp.pIdList); - - pTriggerStep = null; - sqlite3DbFree(db, ref pTmp); - } + static Trigger sqlite3TriggerList( Parse pParse, Table pTab ) + { + Schema pTmpSchema = pParse.db.aDb[1].pSchema; + Trigger pList = null; /* List of triggers to return */ + + if ( pParse.disableTriggers != 0 ) + { + return null; + } + + if ( pTmpSchema != pTab.pSchema ) + { + HashElem p; + Debug.Assert( sqlite3SchemaMutexHeld( pParse.db, 0, pTmpSchema ) ); + for ( p = sqliteHashFirst( pTmpSchema.trigHash ); p != null; p = sqliteHashNext( p ) ) + { + Trigger pTrig = (Trigger)sqliteHashData( p ); + if ( pTrig.pTabSchema == pTab.pSchema + && pTrig.table.Equals( pTab.zName, StringComparison.OrdinalIgnoreCase ) ) + { + pTrig.pNext = ( pList != null ? pList : pTab.pTrigger ); + pList = pTrig; + } } + } - /* - ** Given table pTab, return a list of all the triggers attached to - ** the table. The list is connected by Trigger.pNext pointers. - ** - ** All of the triggers on pTab that are in the same database as pTab - ** are already attached to pTab.pTrigger. But there might be additional - ** triggers on pTab in the TEMP schema. This routine prepends all - ** TEMP triggers on pTab to the beginning of the pTab.pTrigger list - ** and returns the combined list. - ** - ** To state it another way: This routine returns a list of all triggers - ** that fire off of pTab. The list will include any TEMP triggers on - ** pTab as well as the triggers lised in pTab.pTrigger. - */ - static Trigger sqlite3TriggerList(Parse pParse, Table pTab) { - Schema pTmpSchema = pParse.db.aDb[1].pSchema; - Trigger pList = null; /* List of triggers to return */ - - if (pParse.disableTriggers != 0) { - return null; - } - - if (pTmpSchema != pTab.pSchema) { - HashElem p; - Debug.Assert(sqlite3SchemaMutexHeld(pParse.db, 0, pTmpSchema)); - for (p = sqliteHashFirst(pTmpSchema.trigHash); p != null; p = sqliteHashNext(p)) { - Trigger pTrig = (Trigger)sqliteHashData(p); - if (pTrig.pTabSchema == pTab.pSchema - && pTrig.table.Equals(pTab.zName, StringComparison.OrdinalIgnoreCase)) { - pTrig.pNext = (pList != null ? pList : pTab.pTrigger); - pList = pTrig; - } - } - } + return ( pList != null ? pList : pTab.pTrigger ); + } - return (pList != null ? pList : pTab.pTrigger); + /* + ** This is called by the parser when it sees a CREATE TRIGGER statement + ** up to the point of the BEGIN before the trigger actions. A Trigger + ** structure is generated based on the information available and stored + ** in pParse.pNewTrigger. After the trigger actions have been parsed, the + ** sqlite3FinishTrigger() function is called to complete the trigger + ** construction process. + */ + static void sqlite3BeginTrigger( + Parse pParse, /* The parse context of the CREATE TRIGGER statement */ + Token pName1, /* The name of the trigger */ + Token pName2, /* The name of the trigger */ + int tr_tm, /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */ + int op, /* One of TK_INSERT, TK_UPDATE, TK_DELETE */ + IdList pColumns, /* column list if this is an UPDATE OF trigger */ + SrcList pTableName,/* The name of the table/view the trigger applies to */ + Expr pWhen, /* WHEN clause */ + int isTemp, /* True if the TEMPORARY keyword is present */ + int noErr /* Suppress errors if the trigger already exists */ + ) + { + Trigger pTrigger = null; /* The new trigger */ + Table pTab; /* Table that the trigger fires off of */ + string zName = null; /* Name of the trigger */ + sqlite3 db = pParse.db; /* The database connection */ + int iDb; /* The database to store the trigger in */ + Token pName = null; /* The unqualified db name */ + DbFixer sFix = new DbFixer(); /* State vector for the DB fixer */ + int iTabDb; /* Index of the database holding pTab */ + + Debug.Assert( pName1 != null ); /* pName1.z might be NULL, but not pName1 itself */ + Debug.Assert( pName2 != null ); + Debug.Assert( op == TK_INSERT || op == TK_UPDATE || op == TK_DELETE ); + Debug.Assert( op > 0 && op < 0xff ); + if ( isTemp != 0 ) + { + /* If TEMP was specified, then the trigger name may not be qualified. */ + if ( pName2.n > 0 ) + { + sqlite3ErrorMsg( pParse, "temporary trigger may not have qualified name" ); + goto trigger_cleanup; } - - /* - ** This is called by the parser when it sees a CREATE TRIGGER statement - ** up to the point of the BEGIN before the trigger actions. A Trigger - ** structure is generated based on the information available and stored - ** in pParse.pNewTrigger. After the trigger actions have been parsed, the - ** sqlite3FinishTrigger() function is called to complete the trigger - ** construction process. - */ - static void sqlite3BeginTrigger( - Parse pParse, /* The parse context of the CREATE TRIGGER statement */ - Token pName1, /* The name of the trigger */ - Token pName2, /* The name of the trigger */ - int tr_tm, /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */ - int op, /* One of TK_INSERT, TK_UPDATE, TK_DELETE */ - IdList pColumns, /* column list if this is an UPDATE OF trigger */ - SrcList pTableName,/* The name of the table/view the trigger applies to */ - Expr pWhen, /* WHEN clause */ - int isTemp, /* True if the TEMPORARY keyword is present */ - int noErr /* Suppress errors if the trigger already exists */ - ) { - Trigger pTrigger = null; /* The new trigger */ - Table pTab; /* Table that the trigger fires off of */ - string zName = null; /* Name of the trigger */ - sqlite3 db = pParse.db; /* The database connection */ - int iDb; /* The database to store the trigger in */ - Token pName = null; /* The unqualified db name */ - DbFixer sFix = new DbFixer(); /* State vector for the DB fixer */ - int iTabDb; /* Index of the database holding pTab */ - - Debug.Assert(pName1 != null); /* pName1.z might be NULL, but not pName1 itself */ - Debug.Assert(pName2 != null); - Debug.Assert(op == TK_INSERT || op == TK_UPDATE || op == TK_DELETE); - Debug.Assert(op > 0 && op < 0xff); - if (isTemp != 0) { - /* If TEMP was specified, then the trigger name may not be qualified. */ - if (pName2.n > 0) { - sqlite3ErrorMsg(pParse, "temporary trigger may not have qualified name"); - goto trigger_cleanup; - } - iDb = 1; - pName = pName1; - } else { - /* Figure out the db that the the trigger will be created in */ - iDb = sqlite3TwoPartName(pParse, pName1, pName2, ref pName); - if (iDb < 0) { - goto trigger_cleanup; - } - } - if (null == pTableName) //|| db.mallocFailed - { - goto trigger_cleanup; - } - - /* A long-standing parser bug is that this syntax was allowed: - ** - ** CREATE TRIGGER attached.demo AFTER INSERT ON attached.tab .... - ** ^^^^^^^^ - ** - ** To maintain backwards compatibility, ignore the database - ** name on pTableName if we are reparsing our of SQLITE_MASTER. - */ - if (db.init.busy != 0 && iDb != 1) { - //sqlite3DbFree( db, pTableName.a[0].zDatabase ); - pTableName.a[0].zDatabase = null; - } - - /* If the trigger name was unqualified, and the table is a temp table, - ** then set iDb to 1 to create the trigger in the temporary database. - ** If sqlite3SrcListLookup() returns 0, indicating the table does not - ** exist, the error is caught by the block below. - */ - if (pTableName == null /*|| db.mallocFailed != 0 */ ) { - goto trigger_cleanup; - } - pTab = sqlite3SrcListLookup(pParse, pTableName); - if (db.init.busy == 0 && pName2.n == 0 && pTab != null - && pTab.pSchema == db.aDb[1].pSchema) { - iDb = 1; - } - - /* Ensure the table name matches database name and that the table exists */ - // if ( db.mallocFailed != 0 ) goto trigger_cleanup; - Debug.Assert(pTableName.nSrc == 1); - if (sqlite3FixInit(sFix, pParse, iDb, "trigger", pName) != 0 && - sqlite3FixSrcList(sFix, pTableName) != 0) { - goto trigger_cleanup; - } - pTab = sqlite3SrcListLookup(pParse, pTableName); - if (pTab == null) { - /* The table does not exist. */ - if (db.init.iDb == 1) { - /* Ticket #3810. - ** Normally, whenever a table is dropped, all associated triggers are - ** dropped too. But if a TEMP trigger is created on a non-TEMP table - ** and the table is dropped by a different database connection, the - ** trigger is not visible to the database connection that does the - ** drop so the trigger cannot be dropped. This results in an - ** "orphaned trigger" - a trigger whose associated table is missing. - */ - db.init.orphanTrigger = 1; - } - goto trigger_cleanup; - } - if (IsVirtual(pTab)) { - sqlite3ErrorMsg(pParse, "cannot create triggers on virtual tables"); - goto trigger_cleanup; - } - - /* Check that the trigger name is not reserved and that no trigger of the - ** specified name exists */ - zName = sqlite3NameFromToken(db, pName); - if (zName == null || SQLITE_OK != sqlite3CheckObjectName(pParse, zName)) { - goto trigger_cleanup; - } - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); - if (sqlite3HashFind((db.aDb[iDb].pSchema.trigHash), - zName, sqlite3Strlen30(zName), (Trigger)null) != null) { - if (noErr == 0) { - sqlite3ErrorMsg(pParse, "trigger %T already exists", pName); - } else { - Debug.Assert(0 == db.init.busy); - sqlite3CodeVerifySchema(pParse, iDb); - } - goto trigger_cleanup; - } - - /* Do not create a trigger on a system table */ - if (pTab.zName.StartsWith("sqlite_", System.StringComparison.OrdinalIgnoreCase)) { - sqlite3ErrorMsg(pParse, "cannot create trigger on system table"); - pParse.nErr++; - goto trigger_cleanup; - } - - /* INSTEAD of triggers are only for views and views only support INSTEAD - ** of triggers. - */ - if (pTab.pSelect != null && tr_tm != TK_INSTEAD) { - sqlite3ErrorMsg(pParse, "cannot create %s trigger on view: %S", - (tr_tm == TK_BEFORE) ? "BEFORE" : "AFTER", pTableName, 0); - goto trigger_cleanup; - } - if (pTab.pSelect == null && tr_tm == TK_INSTEAD) { - sqlite3ErrorMsg(pParse, "cannot create INSTEAD OF" + - " trigger on table: %S", pTableName, 0); - goto trigger_cleanup; - } - iTabDb = sqlite3SchemaToIndex(db, pTab.pSchema); + iDb = 1; + pName = pName1; + } + else + { + /* Figure out the db that the the trigger will be created in */ + iDb = sqlite3TwoPartName( pParse, pName1, pName2, ref pName ); + if ( iDb < 0 ) + { + goto trigger_cleanup; + } + } + if ( null == pTableName ) //|| db.mallocFailed + { + goto trigger_cleanup; + } + + /* A long-standing parser bug is that this syntax was allowed: + ** + ** CREATE TRIGGER attached.demo AFTER INSERT ON attached.tab .... + ** ^^^^^^^^ + ** + ** To maintain backwards compatibility, ignore the database + ** name on pTableName if we are reparsing our of SQLITE_MASTER. + */ + if ( db.init.busy != 0 && iDb != 1 ) + { + //sqlite3DbFree( db, pTableName.a[0].zDatabase ); + pTableName.a[0].zDatabase = null; + } + + /* If the trigger name was unqualified, and the table is a temp table, + ** then set iDb to 1 to create the trigger in the temporary database. + ** If sqlite3SrcListLookup() returns 0, indicating the table does not + ** exist, the error is caught by the block below. + */ + if ( pTableName == null /*|| db.mallocFailed != 0 */ ) + { + goto trigger_cleanup; + } + pTab = sqlite3SrcListLookup( pParse, pTableName ); + if ( db.init.busy == 0 && pName2.n == 0 && pTab != null + && pTab.pSchema == db.aDb[1].pSchema ) + { + iDb = 1; + } + + /* Ensure the table name matches database name and that the table exists */ + // if ( db.mallocFailed != 0 ) goto trigger_cleanup; + Debug.Assert( pTableName.nSrc == 1 ); + if ( sqlite3FixInit( sFix, pParse, iDb, "trigger", pName ) != 0 && + sqlite3FixSrcList( sFix, pTableName ) != 0 ) + { + goto trigger_cleanup; + } + pTab = sqlite3SrcListLookup( pParse, pTableName ); + if ( pTab == null ) + { + /* The table does not exist. */ + if ( db.init.iDb == 1 ) + { + /* Ticket #3810. + ** Normally, whenever a table is dropped, all associated triggers are + ** dropped too. But if a TEMP trigger is created on a non-TEMP table + ** and the table is dropped by a different database connection, the + ** trigger is not visible to the database connection that does the + ** drop so the trigger cannot be dropped. This results in an + ** "orphaned trigger" - a trigger whose associated table is missing. + */ + db.init.orphanTrigger = 1; + } + goto trigger_cleanup; + } + if ( IsVirtual( pTab ) ) + { + sqlite3ErrorMsg( pParse, "cannot create triggers on virtual tables" ); + goto trigger_cleanup; + } + + /* Check that the trigger name is not reserved and that no trigger of the + ** specified name exists */ + zName = sqlite3NameFromToken( db, pName ); + if ( zName == null || SQLITE_OK != sqlite3CheckObjectName( pParse, zName ) ) + { + goto trigger_cleanup; + } + Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); + if ( sqlite3HashFind( ( db.aDb[iDb].pSchema.trigHash ), + zName, sqlite3Strlen30( zName ), (Trigger)null ) != null ) + { + if ( noErr == 0 ) + { + sqlite3ErrorMsg( pParse, "trigger %T already exists", pName ); + } + else + { + Debug.Assert( 0==db.init.busy ); + sqlite3CodeVerifySchema( pParse, iDb ); + } + goto trigger_cleanup; + } + + /* Do not create a trigger on a system table */ + if ( pTab.zName.StartsWith( "sqlite_", System.StringComparison.OrdinalIgnoreCase ) ) + { + sqlite3ErrorMsg( pParse, "cannot create trigger on system table" ); + pParse.nErr++; + goto trigger_cleanup; + } + + /* INSTEAD of triggers are only for views and views only support INSTEAD + ** of triggers. + */ + if ( pTab.pSelect != null && tr_tm != TK_INSTEAD ) + { + sqlite3ErrorMsg( pParse, "cannot create %s trigger on view: %S", + ( tr_tm == TK_BEFORE ) ? "BEFORE" : "AFTER", pTableName, 0 ); + goto trigger_cleanup; + } + if ( pTab.pSelect == null && tr_tm == TK_INSTEAD ) + { + sqlite3ErrorMsg( pParse, "cannot create INSTEAD OF" + + " trigger on table: %S", pTableName, 0 ); + goto trigger_cleanup; + } + iTabDb = sqlite3SchemaToIndex( db, pTab.pSchema ); #if !SQLITE_OMIT_AUTHORIZATION { @@ -246,354 +277,385 @@ static void sqlite3BeginTrigger( } #endif - /* INSTEAD OF triggers can only appear on views and BEFORE triggers - ** cannot appear on views. So we might as well translate every - ** INSTEAD OF trigger into a BEFORE trigger. It simplifies code - ** elsewhere. - */ - if (tr_tm == TK_INSTEAD) { - tr_tm = TK_BEFORE; - } + /* INSTEAD OF triggers can only appear on views and BEFORE triggers +** cannot appear on views. So we might as well translate every +** INSTEAD OF trigger into a BEFORE trigger. It simplifies code +** elsewhere. +*/ + if ( tr_tm == TK_INSTEAD ) + { + tr_tm = TK_BEFORE; + } + + /* Build the Trigger object */ + pTrigger = new Trigger();// (Trigger*)sqlite3DbMallocZero( db, sizeof(Trigger )) + if ( pTrigger == null ) + goto trigger_cleanup; + pTrigger.zName = zName; + pTrigger.table = pTableName.a[0].zName;// sqlite3DbStrDup( db, pTableName.a[0].zName ); + pTrigger.pSchema = db.aDb[iDb].pSchema; + pTrigger.pTabSchema = pTab.pSchema; + pTrigger.op = (u8)op; + pTrigger.tr_tm = tr_tm == TK_BEFORE ? TRIGGER_BEFORE : TRIGGER_AFTER; + pTrigger.pWhen = sqlite3ExprDup( db, pWhen, EXPRDUP_REDUCE ); + pTrigger.pColumns = sqlite3IdListDup( db, pColumns ); + Debug.Assert( pParse.pNewTrigger == null ); + pParse.pNewTrigger = pTrigger; + +trigger_cleanup: + sqlite3DbFree( db, ref zName ); + sqlite3SrcListDelete( db, ref pTableName ); + sqlite3IdListDelete( db, ref pColumns ); + sqlite3ExprDelete( db, ref pWhen ); + if ( pParse.pNewTrigger == null ) + { + sqlite3DeleteTrigger( db, ref pTrigger ); + } + else + { + Debug.Assert( pParse.pNewTrigger == pTrigger ); + } + } - /* Build the Trigger object */ - pTrigger = new Trigger();// (Trigger*)sqlite3DbMallocZero( db, sizeof(Trigger )) - if (pTrigger == null) - goto trigger_cleanup; - pTrigger.zName = zName; - pTrigger.table = pTableName.a[0].zName;// sqlite3DbStrDup( db, pTableName.a[0].zName ); - pTrigger.pSchema = db.aDb[iDb].pSchema; - pTrigger.pTabSchema = pTab.pSchema; - pTrigger.op = (u8)op; - pTrigger.tr_tm = tr_tm == TK_BEFORE ? TRIGGER_BEFORE : TRIGGER_AFTER; - pTrigger.pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE); - pTrigger.pColumns = sqlite3IdListDup(db, pColumns); - Debug.Assert(pParse.pNewTrigger == null); - pParse.pNewTrigger = pTrigger; - - trigger_cleanup: - sqlite3DbFree(db, ref zName); - sqlite3SrcListDelete(db, ref pTableName); - sqlite3IdListDelete(db, ref pColumns); - sqlite3ExprDelete(db, ref pWhen); - if (pParse.pNewTrigger == null) { - sqlite3DeleteTrigger(db, ref pTrigger); - } else { - Debug.Assert(pParse.pNewTrigger == pTrigger); - } + /* + ** This routine is called after all of the trigger actions have been parsed + ** in order to complete the process of building the trigger. + */ + static void sqlite3FinishTrigger( + Parse pParse, /* Parser context */ + TriggerStep pStepList, /* The triggered program */ + Token pAll /* Token that describes the complete CREATE TRIGGER */ + ) + { + Trigger pTrig = pParse.pNewTrigger; /* Trigger being finished */ + string zName; /* Name of trigger */ + + sqlite3 db = pParse.db; /* The database */ + DbFixer sFix = new DbFixer(); /* Fixer object */ + int iDb; /* Database containing the trigger */ + Token nameToken = new Token(); /* Trigger name for error reporting */ + + pParse.pNewTrigger = null; + if ( NEVER( pParse.nErr != 0 ) || pTrig == null ) + goto triggerfinish_cleanup; + zName = pTrig.zName; + iDb = sqlite3SchemaToIndex( pParse.db, pTrig.pSchema ); + pTrig.step_list = pStepList; + while ( pStepList != null ) + { + pStepList.pTrig = pTrig; + pStepList = pStepList.pNext; + } + nameToken.z = pTrig.zName; + nameToken.n = sqlite3Strlen30( nameToken.z ); + if ( sqlite3FixInit( sFix, pParse, iDb, "trigger", nameToken ) != 0 + && sqlite3FixTriggerStep( sFix, pTrig.step_list ) != 0 ) + { + goto triggerfinish_cleanup; + } + + /* if we are not initializing, + ** build the sqlite_master entry + */ + if ( 0 == db.init.busy ) + { + Vdbe v; + string z; + + /* Make an entry in the sqlite_master table */ + v = sqlite3GetVdbe( pParse ); + if ( v == null ) + goto triggerfinish_cleanup; + sqlite3BeginWriteOperation( pParse, 0, iDb ); + z = pAll.z.Substring( 0, pAll.n );//sqlite3DbStrNDup( db, (char*)pAll.z, pAll.n ); + sqlite3NestedParse( pParse, + "INSERT INTO %Q.%s VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')", + db.aDb[iDb].zName, SCHEMA_TABLE( iDb ), zName, + pTrig.table, z ); + sqlite3DbFree( db, ref z ); + sqlite3ChangeCookie( pParse, iDb ); + sqlite3VdbeAddParseSchemaOp( v, iDb, + sqlite3MPrintf( db, "type='trigger' AND name='%q'", zName ) ); + } + + if ( db.init.busy != 0 ) + { + Trigger pLink = pTrig; + Hash pHash = db.aDb[iDb].pSchema.trigHash; + Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); + pTrig = sqlite3HashInsert( ref pHash, zName, sqlite3Strlen30( zName ), pTrig ); + if ( pTrig != null ) + { + //db.mallocFailed = 1; } + else if ( pLink.pSchema == pLink.pTabSchema ) + { + Table pTab; + int n = sqlite3Strlen30( pLink.table ); + pTab = sqlite3HashFind( pLink.pTabSchema.tblHash, pLink.table, n, (Table)null ); + Debug.Assert( pTab != null ); + pLink.pNext = pTab.pTrigger; + pTab.pTrigger = pLink; + } + } - /* - ** This routine is called after all of the trigger actions have been parsed - ** in order to complete the process of building the trigger. - */ - static void sqlite3FinishTrigger( - Parse pParse, /* Parser context */ - TriggerStep pStepList, /* The triggered program */ - Token pAll /* Token that describes the complete CREATE TRIGGER */ - ) { - Trigger pTrig = pParse.pNewTrigger; /* Trigger being finished */ - string zName; /* Name of trigger */ - - sqlite3 db = pParse.db; /* The database */ - DbFixer sFix = new DbFixer(); /* Fixer object */ - int iDb; /* Database containing the trigger */ - Token nameToken = new Token(); /* Trigger name for error reporting */ - - pParse.pNewTrigger = null; - if (NEVER(pParse.nErr != 0) || pTrig == null) - goto triggerfinish_cleanup; - zName = pTrig.zName; - iDb = sqlite3SchemaToIndex(pParse.db, pTrig.pSchema); - pTrig.step_list = pStepList; - while (pStepList != null) { - pStepList.pTrig = pTrig; - pStepList = pStepList.pNext; - } - nameToken.z = pTrig.zName; - nameToken.n = sqlite3Strlen30(nameToken.z); - if (sqlite3FixInit(sFix, pParse, iDb, "trigger", nameToken) != 0 - && sqlite3FixTriggerStep(sFix, pTrig.step_list) != 0) { - goto triggerfinish_cleanup; - } +triggerfinish_cleanup: + sqlite3DeleteTrigger( db, ref pTrig ); + Debug.Assert( pParse.pNewTrigger == null ); + sqlite3DeleteTriggerStep( db, ref pStepList ); + } - /* if we are not initializing, - ** build the sqlite_master entry - */ - if (0 == db.init.busy) { - Vdbe v; - string z; - - /* Make an entry in the sqlite_master table */ - v = sqlite3GetVdbe(pParse); - if (v == null) - goto triggerfinish_cleanup; - sqlite3BeginWriteOperation(pParse, 0, iDb); - z = pAll.z.Substring(0, pAll.n);//sqlite3DbStrNDup( db, (char*)pAll.z, pAll.n ); - sqlite3NestedParse(pParse, - "INSERT INTO %Q.%s VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')", - db.aDb[iDb].zName, SCHEMA_TABLE(iDb), zName, - pTrig.table, z); - sqlite3DbFree(db, ref z); - sqlite3ChangeCookie(pParse, iDb); - sqlite3VdbeAddParseSchemaOp(v, iDb, - sqlite3MPrintf(db, "type='trigger' AND name='%q'", zName)); - } + /* + ** Turn a SELECT statement (that the pSelect parameter points to) into + ** a trigger step. Return a pointer to a TriggerStep structure. + ** + ** The parser calls this routine when it finds a SELECT statement in + ** body of a TRIGGER. + */ + static TriggerStep sqlite3TriggerSelectStep( sqlite3 db, Select pSelect ) + { + TriggerStep pTriggerStep = new TriggerStep();// sqlite3DbMallocZero( db, sizeof(TriggerStep )) + if ( pTriggerStep == null ) + { + sqlite3SelectDelete( db, ref pSelect ); + return null; + } + + pTriggerStep.op = TK_SELECT; + pTriggerStep.pSelect = pSelect; + pTriggerStep.orconf = OE_Default; + return pTriggerStep; + } - if (db.init.busy != 0) { - Trigger pLink = pTrig; - Hash pHash = db.aDb[iDb].pSchema.trigHash; - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); - pTrig = sqlite3HashInsert(ref pHash, zName, sqlite3Strlen30(zName), pTrig); - if (pTrig != null) { - //db.mallocFailed = 1; - } else if (pLink.pSchema == pLink.pTabSchema) { - Table pTab; - int n = sqlite3Strlen30(pLink.table); - pTab = sqlite3HashFind(pLink.pTabSchema.tblHash, pLink.table, n, (Table)null); - Debug.Assert(pTab != null); - pLink.pNext = pTab.pTrigger; - pTab.pTrigger = pLink; - } - } + /* + ** Allocate space to hold a new trigger step. The allocated space + ** holds both the TriggerStep object and the TriggerStep.target.z string. + ** + ** If an OOM error occurs, NULL is returned and db.mallocFailed is set. + */ + static TriggerStep triggerStepAllocate( + sqlite3 db, /* Database connection */ + u8 op, /* Trigger opcode */ + Token pName /* The target name */ + ) + { + TriggerStep pTriggerStep; + + pTriggerStep = new TriggerStep();// sqlite3DbMallocZero( db, sizeof( TriggerStep ) + pName.n ); + //if ( pTriggerStep != null ) + //{ + string z;// = (char*)&pTriggerStep[1]; + z = pName.z;// memcpy( z, pName.z, pName.n ); + pTriggerStep.target.z = z; + pTriggerStep.target.n = pName.n; + pTriggerStep.op = op; + //} + return pTriggerStep; + } - triggerfinish_cleanup: - sqlite3DeleteTrigger(db, ref pTrig); - Debug.Assert(pParse.pNewTrigger == null); - sqlite3DeleteTriggerStep(db, ref pStepList); - } + /* + ** Build a trigger step out of an INSERT statement. Return a pointer + ** to the new trigger step. + ** + ** The parser calls this routine when it sees an INSERT inside the + ** body of a trigger. + */ + // OVERLOADS, so I don't need to rewrite parse.c + static TriggerStep sqlite3TriggerInsertStep( sqlite3 db, Token pTableName, IdList pColumn, int null_4, int null_5, u8 orconf ) + { + return sqlite3TriggerInsertStep( db, pTableName, pColumn, null, null, orconf ); + } + static TriggerStep sqlite3TriggerInsertStep( sqlite3 db, Token pTableName, IdList pColumn, ExprList pEList, int null_5, u8 orconf ) + { + return sqlite3TriggerInsertStep( db, pTableName, pColumn, pEList, null, orconf ); + } + static TriggerStep sqlite3TriggerInsertStep( sqlite3 db, Token pTableName, IdList pColumn, int null_4, Select pSelect, u8 orconf ) + { + return sqlite3TriggerInsertStep( db, pTableName, pColumn, null, pSelect, orconf ); + } + static TriggerStep sqlite3TriggerInsertStep( + sqlite3 db, /* The database connection */ + Token pTableName, /* Name of the table into which we insert */ + IdList pColumn, /* List of columns in pTableName to insert into */ + ExprList pEList, /* The VALUE clause: a list of values to be inserted */ + Select pSelect, /* A SELECT statement that supplies values */ + u8 orconf /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */ + ) + { + TriggerStep pTriggerStep; + + Debug.Assert( pEList == null || pSelect == null ); + Debug.Assert( pEList != null || pSelect != null /*|| db.mallocFailed != 0 */ ); + + pTriggerStep = triggerStepAllocate( db, TK_INSERT, pTableName ); + //if ( pTriggerStep != null ) + //{ + pTriggerStep.pSelect = sqlite3SelectDup( db, pSelect, EXPRDUP_REDUCE ); + pTriggerStep.pIdList = pColumn; + pTriggerStep.pExprList = sqlite3ExprListDup( db, pEList, EXPRDUP_REDUCE ); + pTriggerStep.orconf = orconf; + //} + //else + //{ + // sqlite3IdListDelete( db, ref pColumn ); + //} + sqlite3ExprListDelete( db, ref pEList ); + sqlite3SelectDelete( db, ref pSelect ); + + return pTriggerStep; + } - /* - ** Turn a SELECT statement (that the pSelect parameter points to) into - ** a trigger step. Return a pointer to a TriggerStep structure. - ** - ** The parser calls this routine when it finds a SELECT statement in - ** body of a TRIGGER. - */ - static TriggerStep sqlite3TriggerSelectStep(sqlite3 db, Select pSelect) { - TriggerStep pTriggerStep = new TriggerStep();// sqlite3DbMallocZero( db, sizeof(TriggerStep )) - if (pTriggerStep == null) { - sqlite3SelectDelete(db, ref pSelect); - return null; - } + /* + ** Construct a trigger step that implements an UPDATE statement and return + ** a pointer to that trigger step. The parser calls this routine when it + ** sees an UPDATE statement inside the body of a CREATE TRIGGER. + */ + static TriggerStep sqlite3TriggerUpdateStep( + sqlite3 db, /* The database connection */ + Token pTableName, /* Name of the table to be updated */ + ExprList pEList, /* The SET clause: list of column and new values */ + Expr pWhere, /* The WHERE clause */ + u8 orconf /* The conflict algorithm. (OE_Abort, OE_Ignore, etc) */ + ) + { + TriggerStep pTriggerStep; + + pTriggerStep = triggerStepAllocate( db, TK_UPDATE, pTableName ); + //if ( pTriggerStep != null ) + //{ + pTriggerStep.pExprList = sqlite3ExprListDup( db, pEList, EXPRDUP_REDUCE ); + pTriggerStep.pWhere = sqlite3ExprDup( db, pWhere, EXPRDUP_REDUCE ); + pTriggerStep.orconf = orconf; + //} + sqlite3ExprListDelete( db, ref pEList ); + sqlite3ExprDelete( db, ref pWhere ); + return pTriggerStep; + } - pTriggerStep.op = TK_SELECT; - pTriggerStep.pSelect = pSelect; - pTriggerStep.orconf = OE_Default; - return pTriggerStep; - } + /* + ** Construct a trigger step that implements a DELETE statement and return + ** a pointer to that trigger step. The parser calls this routine when it + ** sees a DELETE statement inside the body of a CREATE TRIGGER. + */ + static TriggerStep sqlite3TriggerDeleteStep( + sqlite3 db, /* Database connection */ + Token pTableName, /* The table from which rows are deleted */ + Expr pWhere /* The WHERE clause */ + ) + { + TriggerStep pTriggerStep; + + pTriggerStep = triggerStepAllocate( db, TK_DELETE, pTableName ); + //if ( pTriggerStep != null ) + //{ + pTriggerStep.pWhere = sqlite3ExprDup( db, pWhere, EXPRDUP_REDUCE ); + pTriggerStep.orconf = OE_Default; + //} + sqlite3ExprDelete( db, ref pWhere ); + return pTriggerStep; + } - /* - ** Allocate space to hold a new trigger step. The allocated space - ** holds both the TriggerStep object and the TriggerStep.target.z string. - ** - ** If an OOM error occurs, NULL is returned and db.mallocFailed is set. - */ - static TriggerStep triggerStepAllocate( - sqlite3 db, /* Database connection */ - u8 op, /* Trigger opcode */ - Token pName /* The target name */ - ) { - TriggerStep pTriggerStep; - - pTriggerStep = new TriggerStep();// sqlite3DbMallocZero( db, sizeof( TriggerStep ) + pName.n ); - //if ( pTriggerStep != null ) - //{ - string z;// = (char*)&pTriggerStep[1]; - z = pName.z;// memcpy( z, pName.z, pName.n ); - pTriggerStep.target.z = z; - pTriggerStep.target.n = pName.n; - pTriggerStep.op = op; - //} - return pTriggerStep; - } - /* - ** Build a trigger step out of an INSERT statement. Return a pointer - ** to the new trigger step. - ** - ** The parser calls this routine when it sees an INSERT inside the - ** body of a trigger. - */ - // OVERLOADS, so I don't need to rewrite parse.c - static TriggerStep sqlite3TriggerInsertStep(sqlite3 db, Token pTableName, IdList pColumn, int null_4, int null_5, u8 orconf) { - return sqlite3TriggerInsertStep(db, pTableName, pColumn, null, null, orconf); - } - static TriggerStep sqlite3TriggerInsertStep(sqlite3 db, Token pTableName, IdList pColumn, ExprList pEList, int null_5, u8 orconf) { - return sqlite3TriggerInsertStep(db, pTableName, pColumn, pEList, null, orconf); - } - static TriggerStep sqlite3TriggerInsertStep(sqlite3 db, Token pTableName, IdList pColumn, int null_4, Select pSelect, u8 orconf) { - return sqlite3TriggerInsertStep(db, pTableName, pColumn, null, pSelect, orconf); - } - static TriggerStep sqlite3TriggerInsertStep( - sqlite3 db, /* The database connection */ - Token pTableName, /* Name of the table into which we insert */ - IdList pColumn, /* List of columns in pTableName to insert into */ - ExprList pEList, /* The VALUE clause: a list of values to be inserted */ - Select pSelect, /* A SELECT statement that supplies values */ - u8 orconf /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */ - ) { - TriggerStep pTriggerStep; - - Debug.Assert(pEList == null || pSelect == null); - Debug.Assert(pEList != null || pSelect != null /*|| db.mallocFailed != 0 */ ); - - pTriggerStep = triggerStepAllocate(db, TK_INSERT, pTableName); - //if ( pTriggerStep != null ) - //{ - pTriggerStep.pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE); - pTriggerStep.pIdList = pColumn; - pTriggerStep.pExprList = sqlite3ExprListDup(db, pEList, EXPRDUP_REDUCE); - pTriggerStep.orconf = orconf; - //} - //else - //{ - // sqlite3IdListDelete( db, ref pColumn ); - //} - sqlite3ExprListDelete(db, ref pEList); - sqlite3SelectDelete(db, ref pSelect); - - return pTriggerStep; - } - /* - ** Construct a trigger step that implements an UPDATE statement and return - ** a pointer to that trigger step. The parser calls this routine when it - ** sees an UPDATE statement inside the body of a CREATE TRIGGER. - */ - static TriggerStep sqlite3TriggerUpdateStep( - sqlite3 db, /* The database connection */ - Token pTableName, /* Name of the table to be updated */ - ExprList pEList, /* The SET clause: list of column and new values */ - Expr pWhere, /* The WHERE clause */ - u8 orconf /* The conflict algorithm. (OE_Abort, OE_Ignore, etc) */ - ) { - TriggerStep pTriggerStep; - - pTriggerStep = triggerStepAllocate(db, TK_UPDATE, pTableName); - //if ( pTriggerStep != null ) - //{ - pTriggerStep.pExprList = sqlite3ExprListDup(db, pEList, EXPRDUP_REDUCE); - pTriggerStep.pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE); - pTriggerStep.orconf = orconf; - //} - sqlite3ExprListDelete(db, ref pEList); - sqlite3ExprDelete(db, ref pWhere); - return pTriggerStep; - } + /* + ** Recursively delete a Trigger structure + */ + static void sqlite3DeleteTrigger( sqlite3 db, ref Trigger pTrigger ) + { + if ( pTrigger == null ) + return; + sqlite3DeleteTriggerStep( db, ref pTrigger.step_list ); + sqlite3DbFree( db, ref pTrigger.zName ); + sqlite3DbFree( db, ref pTrigger.table ); + sqlite3ExprDelete( db, ref pTrigger.pWhen ); + sqlite3IdListDelete( db, ref pTrigger.pColumns ); + pTrigger = null; + sqlite3DbFree( db, ref pTrigger ); + } - /* - ** Construct a trigger step that implements a DELETE statement and return - ** a pointer to that trigger step. The parser calls this routine when it - ** sees a DELETE statement inside the body of a CREATE TRIGGER. - */ - static TriggerStep sqlite3TriggerDeleteStep( - sqlite3 db, /* Database connection */ - Token pTableName, /* The table from which rows are deleted */ - Expr pWhere /* The WHERE clause */ - ) { - TriggerStep pTriggerStep; - - pTriggerStep = triggerStepAllocate(db, TK_DELETE, pTableName); - //if ( pTriggerStep != null ) - //{ - pTriggerStep.pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE); - pTriggerStep.orconf = OE_Default; - //} - sqlite3ExprDelete(db, ref pWhere); - return pTriggerStep; + /* + ** This function is called to drop a trigger from the database schema. + ** + ** This may be called directly from the parser and therefore identifies + ** the trigger by name. The sqlite3DropTriggerPtr() routine does the + ** same job as this routine except it takes a pointer to the trigger + ** instead of the trigger name. + **/ + static void sqlite3DropTrigger( Parse pParse, SrcList pName, int noErr ) + { + Trigger pTrigger = null; + int i; + string zDb; + string zName; + int nName; + sqlite3 db = pParse.db; + + // if ( db.mallocFailed != 0 ) goto drop_trigger_cleanup; + if ( SQLITE_OK != sqlite3ReadSchema( pParse ) ) + { + goto drop_trigger_cleanup; + } + + Debug.Assert( pName.nSrc == 1 ); + zDb = pName.a[0].zDatabase; + zName = pName.a[0].zName; + nName = sqlite3Strlen30( zName ); + Debug.Assert( zDb != null || sqlite3BtreeHoldsAllMutexes( db ) ); + for ( i = OMIT_TEMPDB; i < db.nDb; i++ ) + { + int j = ( i < 2 ) ? i ^ 1 : i; /* Search TEMP before MAIN */ + if ( zDb != null && !db.aDb[j].zName.Equals( zDb ,StringComparison.OrdinalIgnoreCase ) ) + continue; + Debug.Assert( sqlite3SchemaMutexHeld( db, j, null ) ); + pTrigger = sqlite3HashFind( ( db.aDb[j].pSchema.trigHash ), zName, nName, (Trigger)null ); + if ( pTrigger != null ) + break; + } + if ( pTrigger == null ) + { + if ( noErr == 0 ) + { + sqlite3ErrorMsg( pParse, "no such trigger: %S", pName, 0 ); } - - - - /* - ** Recursively delete a Trigger structure - */ - static void sqlite3DeleteTrigger(sqlite3 db, ref Trigger pTrigger) { - if (pTrigger == null) - return; - sqlite3DeleteTriggerStep(db, ref pTrigger.step_list); - sqlite3DbFree(db, ref pTrigger.zName); - sqlite3DbFree(db, ref pTrigger.table); - sqlite3ExprDelete(db, ref pTrigger.pWhen); - sqlite3IdListDelete(db, ref pTrigger.pColumns); - pTrigger = null; - sqlite3DbFree(db, ref pTrigger); + else + { + sqlite3CodeVerifyNamedSchema( pParse, zDb ); } + pParse.checkSchema = 1; + goto drop_trigger_cleanup; + } + sqlite3DropTriggerPtr( pParse, pTrigger ); - /* - ** This function is called to drop a trigger from the database schema. - ** - ** This may be called directly from the parser and therefore identifies - ** the trigger by name. The sqlite3DropTriggerPtr() routine does the - ** same job as this routine except it takes a pointer to the trigger - ** instead of the trigger name. - **/ - static void sqlite3DropTrigger(Parse pParse, SrcList pName, int noErr) { - Trigger pTrigger = null; - int i; - string zDb; - string zName; - int nName; - sqlite3 db = pParse.db; - - // if ( db.mallocFailed != 0 ) goto drop_trigger_cleanup; - if (SQLITE_OK != sqlite3ReadSchema(pParse)) { - goto drop_trigger_cleanup; - } - - Debug.Assert(pName.nSrc == 1); - zDb = pName.a[0].zDatabase; - zName = pName.a[0].zName; - nName = sqlite3Strlen30(zName); - Debug.Assert(zDb != null || sqlite3BtreeHoldsAllMutexes(db)); - for (i = OMIT_TEMPDB; i < db.nDb; i++) { - int j = (i < 2) ? i ^ 1 : i; /* Search TEMP before MAIN */ - if (zDb != null && !db.aDb[j].zName.Equals(zDb, StringComparison.OrdinalIgnoreCase)) - continue; - Debug.Assert(sqlite3SchemaMutexHeld(db, j, null)); - pTrigger = sqlite3HashFind((db.aDb[j].pSchema.trigHash), zName, nName, (Trigger)null); - if (pTrigger != null) - break; - } - if (pTrigger == null) { - if (noErr == 0) { - sqlite3ErrorMsg(pParse, "no such trigger: %S", pName, 0); - } else { - sqlite3CodeVerifyNamedSchema(pParse, zDb); - } - pParse.checkSchema = 1; - goto drop_trigger_cleanup; - } - sqlite3DropTriggerPtr(pParse, pTrigger); - - drop_trigger_cleanup: - sqlite3SrcListDelete(db, ref pName); - } +drop_trigger_cleanup: + sqlite3SrcListDelete( db, ref pName ); + } - /* - ** Return a pointer to the Table structure for the table that a trigger - ** is set on. - */ - static Table tableOfTrigger(Trigger pTrigger) { - int n = sqlite3Strlen30(pTrigger.table); - return sqlite3HashFind(pTrigger.pTabSchema.tblHash, pTrigger.table, n, (Table)null); - } + /* + ** Return a pointer to the Table structure for the table that a trigger + ** is set on. + */ + static Table tableOfTrigger( Trigger pTrigger ) + { + int n = sqlite3Strlen30( pTrigger.table ); + return sqlite3HashFind( pTrigger.pTabSchema.tblHash, pTrigger.table, n, (Table)null ); + } - /* - ** Drop a trigger given a pointer to that trigger. - */ - static void sqlite3DropTriggerPtr(Parse pParse, Trigger pTrigger) { - Table pTable; - Vdbe v; - sqlite3 db = pParse.db; - int iDb; - - iDb = sqlite3SchemaToIndex(pParse.db, pTrigger.pSchema); - Debug.Assert(iDb >= 0 && iDb < db.nDb); - pTable = tableOfTrigger(pTrigger); - Debug.Assert(pTable != null); - Debug.Assert(pTable.pSchema == pTrigger.pSchema || iDb == 1); + /* + ** Drop a trigger given a pointer to that trigger. + */ + static void sqlite3DropTriggerPtr( Parse pParse, Trigger pTrigger ) + { + Table pTable; + Vdbe v; + sqlite3 db = pParse.db; + int iDb; + + iDb = sqlite3SchemaToIndex( pParse.db, pTrigger.pSchema ); + Debug.Assert( iDb >= 0 && iDb < db.nDb ); + pTable = tableOfTrigger( pTrigger ); + Debug.Assert( pTable != null ); + Debug.Assert( pTable.pSchema == pTrigger.pSchema || iDb == 1 ); #if !SQLITE_OMIT_AUTHORIZATION { int code = SQLITE_DROP_TRIGGER; @@ -607,12 +669,13 @@ static void sqlite3DropTriggerPtr(Parse pParse, Trigger pTrigger) { } #endif - /* Generate code to destroy the database record of the trigger. - */ - Debug.Assert(pTable != null); - if ((v = sqlite3GetVdbe(pParse)) != null) { - int _base; - VdbeOpList[] dropTrigger = new VdbeOpList[] { + /* Generate code to destroy the database record of the trigger. +*/ + Debug.Assert( pTable != null ); + if ( ( v = sqlite3GetVdbe( pParse ) ) != null ) + { + int _base; + VdbeOpList[] dropTrigger = new VdbeOpList[] { new VdbeOpList( OP_Rewind, 0, ADDR(9), 0), new VdbeOpList( OP_String8, 0, 1, 0), /* 1 */ new VdbeOpList( OP_Column, 0, 1, 2), @@ -624,577 +687,624 @@ static void sqlite3DropTriggerPtr(Parse pParse, Trigger pTrigger) { new VdbeOpList( OP_Next, 0, ADDR(1), 0), /* 8 */ }; - sqlite3BeginWriteOperation(pParse, 0, iDb); - sqlite3OpenMasterTable(pParse, iDb); - _base = sqlite3VdbeAddOpList(v, dropTrigger.Length, dropTrigger); - sqlite3VdbeChangeP4(v, _base + 1, pTrigger.zName, P4_TRANSIENT); - sqlite3VdbeChangeP4(v, _base + 4, "trigger", P4_STATIC); - sqlite3ChangeCookie(pParse, iDb); - sqlite3VdbeAddOp2(v, OP_Close, 0, 0); - sqlite3VdbeAddOp4(v, OP_DropTrigger, iDb, 0, 0, pTrigger.zName, 0); - if (pParse.nMem < 3) { - pParse.nMem = 3; - } - } + sqlite3BeginWriteOperation( pParse, 0, iDb ); + sqlite3OpenMasterTable( pParse, iDb ); + _base = sqlite3VdbeAddOpList( v, dropTrigger.Length, dropTrigger ); + sqlite3VdbeChangeP4( v, _base + 1, pTrigger.zName, P4_TRANSIENT ); + sqlite3VdbeChangeP4( v, _base + 4, "trigger", P4_STATIC ); + sqlite3ChangeCookie( pParse, iDb ); + sqlite3VdbeAddOp2( v, OP_Close, 0, 0 ); + sqlite3VdbeAddOp4( v, OP_DropTrigger, iDb, 0, 0, pTrigger.zName, 0 ); + if ( pParse.nMem < 3 ) + { + pParse.nMem = 3; } + } + } - /* - ** Remove a trigger from the hash tables of the sqlite* pointer. - */ - static void sqlite3UnlinkAndDeleteTrigger(sqlite3 db, int iDb, string zName) { - Trigger pTrigger; - Hash pHash; - - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); - pHash = (db.aDb[iDb].pSchema.trigHash); - pTrigger = sqlite3HashInsert(ref pHash, zName, sqlite3Strlen30(zName), (Trigger)null); - if (ALWAYS(pTrigger != null)) { - if (pTrigger.pSchema == pTrigger.pTabSchema) { - Table pTab = tableOfTrigger(pTrigger); - //Trigger** pp; - //for ( pp = &pTab.pTrigger ; *pp != pTrigger ; pp = &( (*pp).pNext ) ) ; - //*pp = (*pp).pNext; - if (pTab.pTrigger == pTrigger) { - pTab.pTrigger = pTrigger.pNext; - } else { - Trigger cc = pTab.pTrigger; - while (cc != null) { - if (cc.pNext == pTrigger) { - cc.pNext = cc.pNext.pNext; - break; - } - cc = cc.pNext; - } - Debug.Assert(cc != null); - } - } - sqlite3DeleteTrigger(db, ref pTrigger); - db.flags |= SQLITE_InternChanges; + /* + ** Remove a trigger from the hash tables of the sqlite* pointer. + */ + static void sqlite3UnlinkAndDeleteTrigger( sqlite3 db, int iDb, string zName ) + { + Trigger pTrigger; + Hash pHash; + + Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); + pHash = ( db.aDb[iDb].pSchema.trigHash ); + pTrigger = sqlite3HashInsert( ref pHash, zName, sqlite3Strlen30( zName ), (Trigger)null ); + if ( ALWAYS( pTrigger != null ) ) + { + if ( pTrigger.pSchema == pTrigger.pTabSchema ) + { + Table pTab = tableOfTrigger( pTrigger ); + //Trigger** pp; + //for ( pp = &pTab.pTrigger ; *pp != pTrigger ; pp = &( (*pp).pNext ) ) ; + //*pp = (*pp).pNext; + if ( pTab.pTrigger == pTrigger ) + { + pTab.pTrigger = pTrigger.pNext; + } + else + { + Trigger cc = pTab.pTrigger; + while ( cc != null ) + { + if ( cc.pNext == pTrigger ) + { + cc.pNext = cc.pNext.pNext; + break; + } + cc = cc.pNext; } + Debug.Assert( cc != null ); + } } + sqlite3DeleteTrigger( db, ref pTrigger ); + db.flags |= SQLITE_InternChanges; + } + } - /* - ** pEList is the SET clause of an UPDATE statement. Each entry - ** in pEList is of the format =. If any of the entries - ** in pEList have an which matches an identifier in pIdList, - ** then return TRUE. If pIdList==NULL, then it is considered a - ** wildcard that matches anything. Likewise if pEList==NULL then - ** it matches anything so always return true. Return false only - ** if there is no match. - */ - static int checkColumnOverlap(IdList pIdList, ExprList pEList) { - int e; - if (pIdList == null || NEVER(pEList == null)) - return 1; - for (e = 0; e < pEList.nExpr; e++) { - if (sqlite3IdListIndex(pIdList, pEList.a[e].zName) >= 0) - return 1; - } - return 0; + /* + ** pEList is the SET clause of an UPDATE statement. Each entry + ** in pEList is of the format =. If any of the entries + ** in pEList have an which matches an identifier in pIdList, + ** then return TRUE. If pIdList==NULL, then it is considered a + ** wildcard that matches anything. Likewise if pEList==NULL then + ** it matches anything so always return true. Return false only + ** if there is no match. + */ + static int checkColumnOverlap( IdList pIdList, ExprList pEList ) + { + int e; + if ( pIdList == null || NEVER( pEList == null ) ) + return 1; + for ( e = 0; e < pEList.nExpr; e++ ) + { + if ( sqlite3IdListIndex( pIdList, pEList.a[e].zName ) >= 0 ) + return 1; + } + return 0; + } + + /* + ** Return a list of all triggers on table pTab if there exists at least + ** one trigger that must be fired when an operation of type 'op' is + ** performed on the table, and, if that operation is an UPDATE, if at + ** least one of the columns in pChanges is being modified. + */ + static Trigger sqlite3TriggersExist( + Parse pParse, /* Parse context */ + Table pTab, /* The table the contains the triggers */ + int op, /* one of TK_DELETE, TK_INSERT, TK_UPDATE */ + ExprList pChanges, /* Columns that change in an UPDATE statement */ + out int pMask /* OUT: Mask of TRIGGER_BEFORE|TRIGGER_AFTER */ + ) + { + int mask = 0; + Trigger pList = null; + Trigger p; + + if ( ( pParse.db.flags & SQLITE_EnableTrigger ) != 0 ) + { + pList = sqlite3TriggerList( pParse, pTab ); + } + Debug.Assert( pList == null || IsVirtual( pTab ) == false ); + for ( p = pList; p != null; p = p.pNext ) + { + if ( p.op == op && checkColumnOverlap( p.pColumns, pChanges ) != 0 ) + { + mask |= p.tr_tm; } + } + //if ( pMask != 0 ) + { + pMask = mask; + } + return ( mask != 0 ? pList : null ); + } - /* - ** Return a list of all triggers on table pTab if there exists at least - ** one trigger that must be fired when an operation of type 'op' is - ** performed on the table, and, if that operation is an UPDATE, if at - ** least one of the columns in pChanges is being modified. + + /* + ** Convert the pStep.target token into a SrcList and return a pointer + ** to that SrcList. + ** + ** This routine adds a specific database name, if needed, to the target when + ** forming the SrcList. This prevents a trigger in one database from + ** referring to a target in another database. An exception is when the + ** trigger is in TEMP in which case it can refer to any other database it + ** wants. + */ + static SrcList targetSrcList( + Parse pParse, /* The parsing context */ + TriggerStep pStep /* The trigger containing the target token */ + ) + { + int iDb; /* Index of the database to use */ + SrcList pSrc; /* SrcList to be returned */ + + pSrc = sqlite3SrcListAppend( pParse.db, 0, pStep.target, 0 ); + //if ( pSrc != null ) + //{ + Debug.Assert( pSrc.nSrc > 0 ); + Debug.Assert( pSrc.a != null ); + iDb = sqlite3SchemaToIndex( pParse.db, pStep.pTrig.pSchema ); + if ( iDb == 0 || iDb >= 2 ) + { + sqlite3 db = pParse.db; + Debug.Assert( iDb < pParse.db.nDb ); + pSrc.a[pSrc.nSrc - 1].zDatabase = db.aDb[iDb].zName;// sqlite3DbStrDup( db, db.aDb[iDb].zName ); + } + //} + return pSrc; + } + + /* + ** Generate VDBE code for the statements inside the body of a single + ** trigger. + */ + static int codeTriggerProgram( + Parse pParse, /* The parser context */ + TriggerStep pStepList, /* List of statements inside the trigger body */ + int orconf /* Conflict algorithm. (OE_Abort, etc) */ + ) + { + TriggerStep pStep; + Vdbe v = pParse.pVdbe; + sqlite3 db = pParse.db; + + Debug.Assert( pParse.pTriggerTab != null && pParse.pToplevel != null ); + Debug.Assert( pStepList != null ); + Debug.Assert( v != null ); + for ( pStep = pStepList; pStep != null; pStep = pStep.pNext ) + { + /* Figure out the ON CONFLICT policy that will be used for this step + ** of the trigger program. If the statement that caused this trigger + ** to fire had an explicit ON CONFLICT, then use it. Otherwise, use + ** the ON CONFLICT policy that was specified as part of the trigger + ** step statement. Example: + ** + ** CREATE TRIGGER AFTER INSERT ON t1 BEGIN; + ** INSERT OR REPLACE INTO t2 VALUES(new.a, new.b); + ** END; + ** + ** INSERT INTO t1 ... ; -- insert into t2 uses REPLACE policy + ** INSERT OR IGNORE INTO t1 ... ; -- insert into t2 uses IGNORE policy */ - static Trigger sqlite3TriggersExist( - Parse pParse, /* Parse context */ - Table pTab, /* The table the contains the triggers */ - int op, /* one of TK_DELETE, TK_INSERT, TK_UPDATE */ - ExprList pChanges, /* Columns that change in an UPDATE statement */ - out int pMask /* OUT: Mask of TRIGGER_BEFORE|TRIGGER_AFTER */ - ) { - int mask = 0; - Trigger pList = null; - Trigger p; - - if ((pParse.db.flags & SQLITE_EnableTrigger) != 0) { - pList = sqlite3TriggerList(pParse, pTab); + pParse.eOrconf = ( orconf == OE_Default ) ? pStep.orconf : (u8)orconf; + + switch ( pStep.op ) + { + case TK_UPDATE: + { + sqlite3Update( pParse, + targetSrcList( pParse, pStep ), + sqlite3ExprListDup( db, pStep.pExprList, 0 ), + sqlite3ExprDup( db, pStep.pWhere, 0 ), + pParse.eOrconf + ); + break; } - Debug.Assert(pList == null || IsVirtual(pTab) == false); - for (p = pList; p != null; p = p.pNext) { - if (p.op == op && checkColumnOverlap(p.pColumns, pChanges) != 0) { - mask |= p.tr_tm; - } + case TK_INSERT: + { + sqlite3Insert( pParse, + targetSrcList( pParse, pStep ), + sqlite3ExprListDup( db, pStep.pExprList, 0 ), + sqlite3SelectDup( db, pStep.pSelect, 0 ), + sqlite3IdListDup( db, pStep.pIdList ), + pParse.eOrconf + ); + break; } - //if ( pMask != 0 ) + case TK_DELETE: { - pMask = mask; + sqlite3DeleteFrom( pParse, + targetSrcList( pParse, pStep ), + sqlite3ExprDup( db, pStep.pWhere, 0 ) + ); + break; } - return (mask != 0 ? pList : null); - } - - - /* - ** Convert the pStep.target token into a SrcList and return a pointer - ** to that SrcList. - ** - ** This routine adds a specific database name, if needed, to the target when - ** forming the SrcList. This prevents a trigger in one database from - ** referring to a target in another database. An exception is when the - ** trigger is in TEMP in which case it can refer to any other database it - ** wants. - */ - static SrcList targetSrcList( - Parse pParse, /* The parsing context */ - TriggerStep pStep /* The trigger containing the target token */ - ) { - int iDb; /* Index of the database to use */ - SrcList pSrc; /* SrcList to be returned */ - - pSrc = sqlite3SrcListAppend(pParse.db, 0, pStep.target, 0); - //if ( pSrc != null ) - //{ - Debug.Assert(pSrc.nSrc > 0); - Debug.Assert(pSrc.a != null); - iDb = sqlite3SchemaToIndex(pParse.db, pStep.pTrig.pSchema); - if (iDb == 0 || iDb >= 2) { - sqlite3 db = pParse.db; - Debug.Assert(iDb < pParse.db.nDb); - pSrc.a[pSrc.nSrc - 1].zDatabase = db.aDb[iDb].zName;// sqlite3DbStrDup( db, db.aDb[iDb].zName ); + default: + Debug.Assert( pStep.op == TK_SELECT ); + { + SelectDest sDest = new SelectDest(); + Select pSelect = sqlite3SelectDup( db, pStep.pSelect, 0 ); + sqlite3SelectDestInit( sDest, SRT_Discard, 0 ); + sqlite3Select( pParse, pSelect, ref sDest ); + sqlite3SelectDelete( db, ref pSelect ); + break; } - //} - return pSrc; } - - /* - ** Generate VDBE code for the statements inside the body of a single - ** trigger. - */ - static int codeTriggerProgram( - Parse pParse, /* The parser context */ - TriggerStep pStepList, /* List of statements inside the trigger body */ - int orconf /* Conflict algorithm. (OE_Abort, etc) */ - ) { - TriggerStep pStep; - Vdbe v = pParse.pVdbe; - sqlite3 db = pParse.db; - - Debug.Assert(pParse.pTriggerTab != null && pParse.pToplevel != null); - Debug.Assert(pStepList != null); - Debug.Assert(v != null); - for (pStep = pStepList; pStep != null; pStep = pStep.pNext) { - /* Figure out the ON CONFLICT policy that will be used for this step - ** of the trigger program. If the statement that caused this trigger - ** to fire had an explicit ON CONFLICT, then use it. Otherwise, use - ** the ON CONFLICT policy that was specified as part of the trigger - ** step statement. Example: - ** - ** CREATE TRIGGER AFTER INSERT ON t1 BEGIN; - ** INSERT OR REPLACE INTO t2 VALUES(new.a, new.b); - ** END; - ** - ** INSERT INTO t1 ... ; -- insert into t2 uses REPLACE policy - ** INSERT OR IGNORE INTO t1 ... ; -- insert into t2 uses IGNORE policy - */ - pParse.eOrconf = (orconf == OE_Default) ? pStep.orconf : (u8)orconf; - - switch (pStep.op) { - case TK_UPDATE: { - sqlite3Update(pParse, - targetSrcList(pParse, pStep), - sqlite3ExprListDup(db, pStep.pExprList, 0), - sqlite3ExprDup(db, pStep.pWhere, 0), - pParse.eOrconf - ); - break; - } - case TK_INSERT: { - sqlite3Insert(pParse, - targetSrcList(pParse, pStep), - sqlite3ExprListDup(db, pStep.pExprList, 0), - sqlite3SelectDup(db, pStep.pSelect, 0), - sqlite3IdListDup(db, pStep.pIdList), - pParse.eOrconf - ); - break; - } - case TK_DELETE: { - sqlite3DeleteFrom(pParse, - targetSrcList(pParse, pStep), - sqlite3ExprDup(db, pStep.pWhere, 0) - ); - break; - } - default: - Debug.Assert(pStep.op == TK_SELECT); { - SelectDest sDest = new SelectDest(); - Select pSelect = sqlite3SelectDup(db, pStep.pSelect, 0); - sqlite3SelectDestInit(sDest, SRT_Discard, 0); - sqlite3Select(pParse, pSelect, ref sDest); - sqlite3SelectDelete(db, ref pSelect); - break; - } - } - if (pStep.op != TK_SELECT) { - sqlite3VdbeAddOp0(v, OP_ResetCount); - } - } - - return 0; + if ( pStep.op != TK_SELECT ) + { + sqlite3VdbeAddOp0( v, OP_ResetCount ); } + } + + return 0; + } #if SQLITE_DEBUG - /* - ** This function is used to add VdbeComment() annotations to a VDBE - ** program. It is not used in production code, only for debugging. - */ - static string onErrorText(int onError) { - switch (onError) { - case OE_Abort: - return "abort"; - case OE_Rollback: - return "rollback"; - case OE_Fail: - return "fail"; - case OE_Replace: - return "replace"; - case OE_Ignore: - return "ignore"; - case OE_Default: - return "default"; - } - return "n/a"; - } + /* +** This function is used to add VdbeComment() annotations to a VDBE +** program. It is not used in production code, only for debugging. +*/ + static string onErrorText( int onError ) + { + switch ( onError ) + { + case OE_Abort: + return "abort"; + case OE_Rollback: + return "rollback"; + case OE_Fail: + return "fail"; + case OE_Replace: + return "replace"; + case OE_Ignore: + return "ignore"; + case OE_Default: + return "default"; + } + return "n/a"; + } #endif - /* - ** Parse context structure pFrom has just been used to create a sub-vdbe - ** (trigger program). If an error has occurred, transfer error information - ** from pFrom to pTo. - */ - static void transferParseError(Parse pTo, Parse pFrom) { - Debug.Assert(String.IsNullOrEmpty(pFrom.zErrMsg) || pFrom.nErr != 0); - Debug.Assert(String.IsNullOrEmpty(pTo.zErrMsg) || pTo.nErr != 0); - if (pTo.nErr == 0) { - pTo.zErrMsg = pFrom.zErrMsg; - pTo.nErr = pFrom.nErr; - } else { - sqlite3DbFree(pFrom.db, ref pFrom.zErrMsg); - } - } + /* +** Parse context structure pFrom has just been used to create a sub-vdbe +** (trigger program). If an error has occurred, transfer error information +** from pFrom to pTo. +*/ + static void transferParseError( Parse pTo, Parse pFrom ) + { + Debug.Assert( String.IsNullOrEmpty( pFrom.zErrMsg ) || pFrom.nErr != 0 ); + Debug.Assert( String.IsNullOrEmpty( pTo.zErrMsg ) || pTo.nErr != 0 ); + if ( pTo.nErr == 0 ) + { + pTo.zErrMsg = pFrom.zErrMsg; + pTo.nErr = pFrom.nErr; + } + else + { + sqlite3DbFree( pFrom.db, ref pFrom.zErrMsg ); + } + } - /* - ** Create and populate a new TriggerPrg object with a sub-program - ** implementing trigger pTrigger with ON CONFLICT policy orconf. - */ - static TriggerPrg codeRowTrigger( - Parse pParse, /* Current parse context */ - Trigger pTrigger, /* Trigger to code */ - Table pTab, /* The table pTrigger is attached to */ - int orconf /* ON CONFLICT policy to code trigger program with */ - ) { - Parse pTop = sqlite3ParseToplevel(pParse); - sqlite3 db = pParse.db; /* Database handle */ - TriggerPrg pPrg; /* Value to return */ - Expr pWhen = null; /* Duplicate of trigger WHEN expression */ - Vdbe v; /* Temporary VM */ - NameContext sNC; /* Name context for sub-vdbe */ - SubProgram pProgram = null; /* Sub-vdbe for trigger program */ - Parse pSubParse; /* Parse context for sub-vdbe */ - int iEndTrigger = 0; /* Label to jump to if WHEN is false */ - - Debug.Assert(pTrigger.zName == null || pTab == tableOfTrigger(pTrigger)); - Debug.Assert(pTop.pVdbe != null); - - /* Allocate the TriggerPrg and SubProgram objects. To ensure that they - ** are freed if an error occurs, link them into the Parse.pTriggerPrg - ** list of the top-level Parse object sooner rather than later. */ - pPrg = new TriggerPrg();// sqlite3DbMallocZero( db, sizeof( TriggerPrg ) ); - //if ( null == pPrg ) return 0; - pPrg.pNext = pTop.pTriggerPrg; - pTop.pTriggerPrg = pPrg; - pPrg.pProgram = pProgram = new SubProgram();// sqlite3DbMallocZero( db, sizeof( SubProgram ) ); - //if( null==pProgram ) return 0; - sqlite3VdbeLinkSubProgram(pTop.pVdbe, pProgram); - pPrg.pTrigger = pTrigger; - pPrg.orconf = orconf; - pPrg.aColmask[0] = 0xffffffff; - pPrg.aColmask[1] = 0xffffffff; - - - /* Allocate and populate a new Parse context to use for coding the - ** trigger sub-program. */ - pSubParse = new Parse();// sqlite3StackAllocZero( db, sizeof( Parse ) ); - //if ( null == pSubParse ) return null; - sNC = new NameContext();// memset( &sNC, 0, sizeof( sNC ) ); - sNC.pParse = pSubParse; - pSubParse.db = db; - pSubParse.pTriggerTab = pTab; - pSubParse.pToplevel = pTop; - pSubParse.zAuthContext = pTrigger.zName; - pSubParse.eTriggerOp = pTrigger.op; - pSubParse.nQueryLoop = pParse.nQueryLoop; - - v = sqlite3GetVdbe(pSubParse); - if (v != null) { + /* + ** Create and populate a new TriggerPrg object with a sub-program + ** implementing trigger pTrigger with ON CONFLICT policy orconf. + */ + static TriggerPrg codeRowTrigger( + Parse pParse, /* Current parse context */ + Trigger pTrigger, /* Trigger to code */ + Table pTab, /* The table pTrigger is attached to */ + int orconf /* ON CONFLICT policy to code trigger program with */ + ) + { + Parse pTop = sqlite3ParseToplevel( pParse ); + sqlite3 db = pParse.db; /* Database handle */ + TriggerPrg pPrg; /* Value to return */ + Expr pWhen = null; /* Duplicate of trigger WHEN expression */ + Vdbe v; /* Temporary VM */ + NameContext sNC; /* Name context for sub-vdbe */ + SubProgram pProgram = null; /* Sub-vdbe for trigger program */ + Parse pSubParse; /* Parse context for sub-vdbe */ + int iEndTrigger = 0; /* Label to jump to if WHEN is false */ + + Debug.Assert( pTrigger.zName == null || pTab == tableOfTrigger( pTrigger ) ); + Debug.Assert( pTop.pVdbe != null ); + + /* Allocate the TriggerPrg and SubProgram objects. To ensure that they + ** are freed if an error occurs, link them into the Parse.pTriggerPrg + ** list of the top-level Parse object sooner rather than later. */ + pPrg = new TriggerPrg();// sqlite3DbMallocZero( db, sizeof( TriggerPrg ) ); + //if ( null == pPrg ) return 0; + pPrg.pNext = pTop.pTriggerPrg; + pTop.pTriggerPrg = pPrg; + pPrg.pProgram = pProgram = new SubProgram();// sqlite3DbMallocZero( db, sizeof( SubProgram ) ); + //if( null==pProgram ) return 0; + sqlite3VdbeLinkSubProgram( pTop.pVdbe, pProgram ); + pPrg.pTrigger = pTrigger; + pPrg.orconf = orconf; + pPrg.aColmask[0] = 0xffffffff; + pPrg.aColmask[1] = 0xffffffff; + + + /* Allocate and populate a new Parse context to use for coding the + ** trigger sub-program. */ + pSubParse = new Parse();// sqlite3StackAllocZero( db, sizeof( Parse ) ); + //if ( null == pSubParse ) return null; + sNC = new NameContext();// memset( &sNC, 0, sizeof( sNC ) ); + sNC.pParse = pSubParse; + pSubParse.db = db; + pSubParse.pTriggerTab = pTab; + pSubParse.pToplevel = pTop; + pSubParse.zAuthContext = pTrigger.zName; + pSubParse.eTriggerOp = pTrigger.op; + pSubParse.nQueryLoop = pParse.nQueryLoop; + + v = sqlite3GetVdbe( pSubParse ); + if ( v != null ) + { #if SQLITE_DEBUG - VdbeComment(v, "Start: %s.%s (%s %s%s%s ON %s)", - pTrigger.zName != null ? pTrigger.zName : "", onErrorText(orconf), - (pTrigger.tr_tm == TRIGGER_BEFORE ? "BEFORE" : "AFTER"), - (pTrigger.op == TK_UPDATE ? "UPDATE" : ""), - (pTrigger.op == TK_INSERT ? "INSERT" : ""), - (pTrigger.op == TK_DELETE ? "DELETE" : ""), - pTab.zName - ); + VdbeComment( v, "Start: %s.%s (%s %s%s%s ON %s)", + pTrigger.zName != null ? pTrigger.zName : "", onErrorText( orconf ), + ( pTrigger.tr_tm == TRIGGER_BEFORE ? "BEFORE" : "AFTER" ), + ( pTrigger.op == TK_UPDATE ? "UPDATE" : "" ), + ( pTrigger.op == TK_INSERT ? "INSERT" : "" ), + ( pTrigger.op == TK_DELETE ? "DELETE" : "" ), + pTab.zName + ); #endif #if !SQLITE_OMIT_TRACE - sqlite3VdbeChangeP4(v, -1, - sqlite3MPrintf(db, "-- TRIGGER %s", pTrigger.zName), P4_DYNAMIC - ); + sqlite3VdbeChangeP4( v, -1, + sqlite3MPrintf( db, "-- TRIGGER %s", pTrigger.zName ), P4_DYNAMIC + ); #endif - /* If one was specified, code the WHEN clause. If it evaluates to false - ** (or NULL) the sub-vdbe is immediately halted by jumping to the - ** OP_Halt inserted at the end of the program. */ - if (pTrigger.pWhen != null) { - pWhen = sqlite3ExprDup(db, pTrigger.pWhen, 0); - if (SQLITE_OK == sqlite3ResolveExprNames(sNC, ref pWhen) - //&& db.mallocFailed==0 - ) { - iEndTrigger = sqlite3VdbeMakeLabel(v); - sqlite3ExprIfFalse(pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL); - } - sqlite3ExprDelete(db, ref pWhen); - } - - /* Code the trigger program into the sub-vdbe. */ - codeTriggerProgram(pSubParse, pTrigger.step_list, orconf); - - /* Insert an OP_Halt at the end of the sub-program. */ - if (iEndTrigger != 0) { - sqlite3VdbeResolveLabel(v, iEndTrigger); - } - sqlite3VdbeAddOp0(v, OP_Halt); -#if SQLITE_DEBUG - VdbeComment(v, "End: %s.%s", pTrigger.zName, onErrorText(orconf)); -#endif - transferParseError(pParse, pSubParse); - //if( db.mallocFailed==0 ){ - pProgram.aOp = sqlite3VdbeTakeOpArray(v, ref pProgram.nOp, ref pTop.nMaxArg); - //} - pProgram.nMem = pSubParse.nMem; - pProgram.nCsr = pSubParse.nTab; - pProgram.token = pTrigger.GetHashCode(); - pPrg.aColmask[0] = pSubParse.oldmask; - pPrg.aColmask[1] = pSubParse.newmask; - sqlite3VdbeDelete(ref v); - } - - Debug.Assert(null == pSubParse.pAinc && null == pSubParse.pZombieTab); - Debug.Assert(null == pSubParse.pTriggerPrg && 0 == pSubParse.nMaxArg); - //sqlite3StackFree(db, pSubParse); - - return pPrg; + /* If one was specified, code the WHEN clause. If it evaluates to false + ** (or NULL) the sub-vdbe is immediately halted by jumping to the + ** OP_Halt inserted at the end of the program. */ + if ( pTrigger.pWhen != null ) + { + pWhen = sqlite3ExprDup( db, pTrigger.pWhen, 0 ); + if ( SQLITE_OK == sqlite3ResolveExprNames( sNC, ref pWhen ) + //&& db.mallocFailed==0 + ) + { + iEndTrigger = sqlite3VdbeMakeLabel( v ); + sqlite3ExprIfFalse( pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL ); + } + sqlite3ExprDelete( db, ref pWhen ); } - /* - ** Return a pointer to a TriggerPrg object containing the sub-program for - ** trigger pTrigger with default ON CONFLICT algorithm orconf. If no such - ** TriggerPrg object exists, a new object is allocated and populated before - ** being returned. - */ - static TriggerPrg getRowTrigger( - Parse pParse, /* Current parse context */ - Trigger pTrigger, /* Trigger to code */ - Table pTab, /* The table trigger pTrigger is attached to */ - int orconf /* ON CONFLICT algorithm. */ - ) { - Parse pRoot = sqlite3ParseToplevel(pParse); - TriggerPrg pPrg; - - Debug.Assert(pTrigger.zName == null || pTab == tableOfTrigger(pTrigger)); - - /* It may be that this trigger has already been coded (or is in the - ** process of being coded). If this is the case, then an entry with - ** a matching TriggerPrg.pTrigger field will be present somewhere - ** in the Parse.pTriggerPrg list. Search for such an entry. */ - for (pPrg = pRoot.pTriggerPrg; - pPrg != null && (pPrg.pTrigger != pTrigger || pPrg.orconf != orconf); - pPrg = pPrg.pNext - ) - ; - - /* If an existing TriggerPrg could not be located, create a new one. */ - if (null == pPrg) { - pPrg = codeRowTrigger(pParse, pTrigger, pTab, orconf); - } + /* Code the trigger program into the sub-vdbe. */ + codeTriggerProgram( pSubParse, pTrigger.step_list, orconf ); - return pPrg; + /* Insert an OP_Halt at the end of the sub-program. */ + if ( iEndTrigger != 0 ) + { + sqlite3VdbeResolveLabel( v, iEndTrigger ); } + sqlite3VdbeAddOp0( v, OP_Halt ); +#if SQLITE_DEBUG + VdbeComment( v, "End: %s.%s", pTrigger.zName, onErrorText( orconf ) ); +#endif + transferParseError( pParse, pSubParse ); + //if( db.mallocFailed==0 ){ + pProgram.aOp = sqlite3VdbeTakeOpArray( v, ref pProgram.nOp, ref pTop.nMaxArg ); + //} + pProgram.nMem = pSubParse.nMem; + pProgram.nCsr = pSubParse.nTab; + pProgram.token = pTrigger.GetHashCode(); + pPrg.aColmask[0] = pSubParse.oldmask; + pPrg.aColmask[1] = pSubParse.newmask; + sqlite3VdbeDelete( ref v ); + } + + Debug.Assert( null == pSubParse.pAinc && null == pSubParse.pZombieTab ); + Debug.Assert( null == pSubParse.pTriggerPrg && 0 == pSubParse.nMaxArg ); + //sqlite3StackFree(db, pSubParse); + + return pPrg; + } - /* - ** Generate code for the trigger program associated with trigger p on - ** table pTab. The reg, orconf and ignoreJump parameters passed to this - ** function are the same as those described in the header function for - ** sqlite3CodeRowTrigger() - */ - static void sqlite3CodeRowTriggerDirect( - Parse pParse, /* Parse context */ - Trigger p, /* Trigger to code */ - Table pTab, /* The table to code triggers from */ - int reg, /* Reg array containing OLD.* and NEW.* values */ - int orconf, /* ON CONFLICT policy */ - int ignoreJump /* Instruction to jump to for RAISE(IGNORE) */ - ) { - Vdbe v = sqlite3GetVdbe(pParse); /* Main VM */ - TriggerPrg pPrg; - pPrg = getRowTrigger(pParse, p, pTab, orconf); - Debug.Assert(pPrg != null || pParse.nErr != 0);//|| pParse.db.mallocFailed ); - - /* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program - ** is a pointer to the sub-vdbe containing the trigger program. */ - if (pPrg != null) { - bool bRecursive = (!String.IsNullOrEmpty(p.zName) && 0 == (pParse.db.flags & SQLITE_RecTriggers)); - sqlite3VdbeAddOp3(v, OP_Program, reg, ignoreJump, ++pParse.nMem); - sqlite3VdbeChangeP4(v, -1, pPrg.pProgram, P4_SUBPROGRAM); + /* + ** Return a pointer to a TriggerPrg object containing the sub-program for + ** trigger pTrigger with default ON CONFLICT algorithm orconf. If no such + ** TriggerPrg object exists, a new object is allocated and populated before + ** being returned. + */ + static TriggerPrg getRowTrigger( + Parse pParse, /* Current parse context */ + Trigger pTrigger, /* Trigger to code */ + Table pTab, /* The table trigger pTrigger is attached to */ + int orconf /* ON CONFLICT algorithm. */ + ) + { + Parse pRoot = sqlite3ParseToplevel( pParse ); + TriggerPrg pPrg; + + Debug.Assert( pTrigger.zName == null || pTab == tableOfTrigger( pTrigger ) ); + + /* It may be that this trigger has already been coded (or is in the + ** process of being coded). If this is the case, then an entry with + ** a matching TriggerPrg.pTrigger field will be present somewhere + ** in the Parse.pTriggerPrg list. Search for such an entry. */ + for ( pPrg = pRoot.pTriggerPrg; + pPrg != null && ( pPrg.pTrigger != pTrigger || pPrg.orconf != orconf ); + pPrg = pPrg.pNext + ) + ; + + /* If an existing TriggerPrg could not be located, create a new one. */ + if ( null == pPrg ) + { + pPrg = codeRowTrigger( pParse, pTrigger, pTab, orconf ); + } + + return pPrg; + } + + /* + ** Generate code for the trigger program associated with trigger p on + ** table pTab. The reg, orconf and ignoreJump parameters passed to this + ** function are the same as those described in the header function for + ** sqlite3CodeRowTrigger() + */ + static void sqlite3CodeRowTriggerDirect( + Parse pParse, /* Parse context */ + Trigger p, /* Trigger to code */ + Table pTab, /* The table to code triggers from */ + int reg, /* Reg array containing OLD.* and NEW.* values */ + int orconf, /* ON CONFLICT policy */ + int ignoreJump /* Instruction to jump to for RAISE(IGNORE) */ + ) + { + Vdbe v = sqlite3GetVdbe( pParse ); /* Main VM */ + TriggerPrg pPrg; + pPrg = getRowTrigger( pParse, p, pTab, orconf ); + Debug.Assert( pPrg != null || pParse.nErr != 0 );//|| pParse.db.mallocFailed ); + + /* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program + ** is a pointer to the sub-vdbe containing the trigger program. */ + if ( pPrg != null ) + { + bool bRecursive = ( !String.IsNullOrEmpty( p.zName ) && 0 == ( pParse.db.flags & SQLITE_RecTriggers ) ); + sqlite3VdbeAddOp3( v, OP_Program, reg, ignoreJump, ++pParse.nMem ); + sqlite3VdbeChangeP4( v, -1, pPrg.pProgram, P4_SUBPROGRAM ); #if SQLITE_DEBUG - VdbeComment - (v, "Call: %s.%s", (!String.IsNullOrEmpty(p.zName) ? p.zName : "fkey"), onErrorText(orconf)); + VdbeComment + ( v, "Call: %s.%s", ( !String.IsNullOrEmpty( p.zName ) ? p.zName : "fkey" ), onErrorText( orconf ) ); #endif - /* Set the P5 operand of the OP_Program instruction to non-zero if - ** recursive invocation of this trigger program is disallowed. Recursive - ** invocation is disallowed if (a) the sub-program is really a trigger, - ** not a foreign key action, and (b) the flag to enable recursive triggers - ** is clear. */ - sqlite3VdbeChangeP5(v, (u8)(bRecursive ? 1 : 0)); - } - } + /* Set the P5 operand of the OP_Program instruction to non-zero if + ** recursive invocation of this trigger program is disallowed. Recursive + ** invocation is disallowed if (a) the sub-program is really a trigger, + ** not a foreign key action, and (b) the flag to enable recursive triggers + ** is clear. */ + sqlite3VdbeChangeP5( v, (u8)( bRecursive ? 1 : 0 ) ); + } + } - /* - ** This is called to code the required FOR EACH ROW triggers for an operation - ** on table pTab. The operation to code triggers for (INSERT, UPDATE or DELETE) - ** is given by the op paramater. The tr_tm parameter determines whether the - ** BEFORE or AFTER triggers are coded. If the operation is an UPDATE, then - ** parameter pChanges is passed the list of columns being modified. - ** - ** If there are no triggers that fire at the specified time for the specified - ** operation on pTab, this function is a no-op. - ** - ** The reg argument is the address of the first in an array of registers - ** that contain the values substituted for the new.* and old.* references - ** in the trigger program. If N is the number of columns in table pTab - ** (a copy of pTab.nCol), then registers are populated as follows: - ** - ** Register Contains - ** ------------------------------------------------------ - ** reg+0 OLD.rowid - ** reg+1 OLD.* value of left-most column of pTab - ** ... ... - ** reg+N OLD.* value of right-most column of pTab - ** reg+N+1 NEW.rowid - ** reg+N+2 OLD.* value of left-most column of pTab - ** ... ... - ** reg+N+N+1 NEW.* value of right-most column of pTab - ** - ** For ON DELETE triggers, the registers containing the NEW.* values will - ** never be accessed by the trigger program, so they are not allocated or - ** populated by the caller (there is no data to populate them with anyway). - ** Similarly, for ON INSERT triggers the values stored in the OLD.* registers - ** are never accessed, and so are not allocated by the caller. So, for an - ** ON INSERT trigger, the value passed to this function as parameter reg - ** is not a readable register, although registers (reg+N) through - ** (reg+N+N+1) are. - ** - ** Parameter orconf is the default conflict resolution algorithm for the - ** trigger program to use (REPLACE, IGNORE etc.). Parameter ignoreJump - ** is the instruction that control should jump to if a trigger program - ** raises an IGNORE exception. - */ - static void sqlite3CodeRowTrigger( - Parse pParse, /* Parse context */ - Trigger pTrigger, /* List of triggers on table pTab */ - int op, /* One of TK_UPDATE, TK_INSERT, TK_DELETE */ - ExprList pChanges, /* Changes list for any UPDATE OF triggers */ - int tr_tm, /* One of TRIGGER_BEFORE, TRIGGER_AFTER */ - Table pTab, /* The table to code triggers from */ - int reg, /* The first in an array of registers (see above) */ - int orconf, /* ON CONFLICT policy */ - int ignoreJump /* Instruction to jump to for RAISE(IGNORE) */ - ) { - Trigger p; /* Used to iterate through pTrigger list */ - - Debug.Assert(op == TK_UPDATE || op == TK_INSERT || op == TK_DELETE); - Debug.Assert(tr_tm == TRIGGER_BEFORE || tr_tm == TRIGGER_AFTER); - Debug.Assert((op == TK_UPDATE) == (pChanges != null)); - - for (p = pTrigger; p != null; p = p.pNext) { - - /* Sanity checking: The schema for the trigger and for the table are - ** always defined. The trigger must be in the same schema as the table - ** or else it must be a TEMP trigger. */ - Debug.Assert(p.pSchema != null); - Debug.Assert(p.pTabSchema != null); - Debug.Assert(p.pSchema == p.pTabSchema - || p.pSchema == pParse.db.aDb[1].pSchema); - - /* Determine whether we should code this trigger */ - if (p.op == op - && p.tr_tm == tr_tm - && checkColumnOverlap(p.pColumns, pChanges) != 0 - ) { - sqlite3CodeRowTriggerDirect(pParse, p, pTab, reg, orconf, ignoreJump); - } - } + /* + ** This is called to code the required FOR EACH ROW triggers for an operation + ** on table pTab. The operation to code triggers for (INSERT, UPDATE or DELETE) + ** is given by the op paramater. The tr_tm parameter determines whether the + ** BEFORE or AFTER triggers are coded. If the operation is an UPDATE, then + ** parameter pChanges is passed the list of columns being modified. + ** + ** If there are no triggers that fire at the specified time for the specified + ** operation on pTab, this function is a no-op. + ** + ** The reg argument is the address of the first in an array of registers + ** that contain the values substituted for the new.* and old.* references + ** in the trigger program. If N is the number of columns in table pTab + ** (a copy of pTab.nCol), then registers are populated as follows: + ** + ** Register Contains + ** ------------------------------------------------------ + ** reg+0 OLD.rowid + ** reg+1 OLD.* value of left-most column of pTab + ** ... ... + ** reg+N OLD.* value of right-most column of pTab + ** reg+N+1 NEW.rowid + ** reg+N+2 OLD.* value of left-most column of pTab + ** ... ... + ** reg+N+N+1 NEW.* value of right-most column of pTab + ** + ** For ON DELETE triggers, the registers containing the NEW.* values will + ** never be accessed by the trigger program, so they are not allocated or + ** populated by the caller (there is no data to populate them with anyway). + ** Similarly, for ON INSERT triggers the values stored in the OLD.* registers + ** are never accessed, and so are not allocated by the caller. So, for an + ** ON INSERT trigger, the value passed to this function as parameter reg + ** is not a readable register, although registers (reg+N) through + ** (reg+N+N+1) are. + ** + ** Parameter orconf is the default conflict resolution algorithm for the + ** trigger program to use (REPLACE, IGNORE etc.). Parameter ignoreJump + ** is the instruction that control should jump to if a trigger program + ** raises an IGNORE exception. + */ + static void sqlite3CodeRowTrigger( + Parse pParse, /* Parse context */ + Trigger pTrigger, /* List of triggers on table pTab */ + int op, /* One of TK_UPDATE, TK_INSERT, TK_DELETE */ + ExprList pChanges, /* Changes list for any UPDATE OF triggers */ + int tr_tm, /* One of TRIGGER_BEFORE, TRIGGER_AFTER */ + Table pTab, /* The table to code triggers from */ + int reg, /* The first in an array of registers (see above) */ + int orconf, /* ON CONFLICT policy */ + int ignoreJump /* Instruction to jump to for RAISE(IGNORE) */ + ) + { + Trigger p; /* Used to iterate through pTrigger list */ + + Debug.Assert( op == TK_UPDATE || op == TK_INSERT || op == TK_DELETE ); + Debug.Assert( tr_tm == TRIGGER_BEFORE || tr_tm == TRIGGER_AFTER ); + Debug.Assert( ( op == TK_UPDATE ) == ( pChanges != null ) ); + + for ( p = pTrigger; p != null; p = p.pNext ) + { + + /* Sanity checking: The schema for the trigger and for the table are + ** always defined. The trigger must be in the same schema as the table + ** or else it must be a TEMP trigger. */ + Debug.Assert( p.pSchema != null ); + Debug.Assert( p.pTabSchema != null ); + Debug.Assert( p.pSchema == p.pTabSchema + || p.pSchema == pParse.db.aDb[1].pSchema ); + + /* Determine whether we should code this trigger */ + if ( p.op == op + && p.tr_tm == tr_tm + && checkColumnOverlap( p.pColumns, pChanges ) != 0 + ) + { + sqlite3CodeRowTriggerDirect( pParse, p, pTab, reg, orconf, ignoreJump ); } + } + } - /* - ** Triggers may access values stored in the old.* or new.* pseudo-table. - ** This function returns a 32-bit bitmask indicating which columns of the - ** old.* or new.* tables actually are used by triggers. This information - ** may be used by the caller, for example, to avoid having to load the entire - ** old.* record into memory when executing an UPDATE or DELETE command. - ** - ** Bit 0 of the returned mask is set if the left-most column of the - ** table may be accessed using an [old|new]. reference. Bit 1 is set if - ** the second leftmost column value is required, and so on. If there - ** are more than 32 columns in the table, and at least one of the columns - ** with an index greater than 32 may be accessed, 0xffffffff is returned. - ** - ** It is not possible to determine if the old.rowid or new.rowid column is - ** accessed by triggers. The caller must always assume that it is. - ** - ** Parameter isNew must be either 1 or 0. If it is 0, then the mask returned - ** applies to the old.* table. If 1, the new.* table. - ** - ** Parameter tr_tm must be a mask with one or both of the TRIGGER_BEFORE - ** and TRIGGER_AFTER bits set. Values accessed by BEFORE triggers are only - ** included in the returned mask if the TRIGGER_BEFORE bit is set in the - ** tr_tm parameter. Similarly, values accessed by AFTER triggers are only - ** included in the returned mask if the TRIGGER_AFTER bit is set in tr_tm. - */ - static u32 sqlite3TriggerColmask( - Parse pParse, /* Parse context */ - Trigger pTrigger, /* List of triggers on table pTab */ - ExprList pChanges, /* Changes list for any UPDATE OF triggers */ - int isNew, /* 1 for new.* ref mask, 0 for old.* ref mask */ - int tr_tm, /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */ - Table pTab, /* The table to code triggers from */ - int orconf /* Default ON CONFLICT policy for trigger steps */ - ) { - int op = pChanges != null ? TK_UPDATE : TK_DELETE; - u32 mask = 0; - Trigger p; - - Debug.Assert(isNew == 1 || isNew == 0); - for (p = pTrigger; p != null; p = p.pNext) { - if (p.op == op && (tr_tm & p.tr_tm) != 0 - && checkColumnOverlap(p.pColumns, pChanges) != 0 - ) { - TriggerPrg pPrg; - pPrg = getRowTrigger(pParse, p, pTab, orconf); - if (pPrg != null) { - mask |= pPrg.aColmask[isNew]; - } - } - } - - return mask; + /* + ** Triggers may access values stored in the old.* or new.* pseudo-table. + ** This function returns a 32-bit bitmask indicating which columns of the + ** old.* or new.* tables actually are used by triggers. This information + ** may be used by the caller, for example, to avoid having to load the entire + ** old.* record into memory when executing an UPDATE or DELETE command. + ** + ** Bit 0 of the returned mask is set if the left-most column of the + ** table may be accessed using an [old|new]. reference. Bit 1 is set if + ** the second leftmost column value is required, and so on. If there + ** are more than 32 columns in the table, and at least one of the columns + ** with an index greater than 32 may be accessed, 0xffffffff is returned. + ** + ** It is not possible to determine if the old.rowid or new.rowid column is + ** accessed by triggers. The caller must always assume that it is. + ** + ** Parameter isNew must be either 1 or 0. If it is 0, then the mask returned + ** applies to the old.* table. If 1, the new.* table. + ** + ** Parameter tr_tm must be a mask with one or both of the TRIGGER_BEFORE + ** and TRIGGER_AFTER bits set. Values accessed by BEFORE triggers are only + ** included in the returned mask if the TRIGGER_BEFORE bit is set in the + ** tr_tm parameter. Similarly, values accessed by AFTER triggers are only + ** included in the returned mask if the TRIGGER_AFTER bit is set in tr_tm. + */ + static u32 sqlite3TriggerColmask( + Parse pParse, /* Parse context */ + Trigger pTrigger, /* List of triggers on table pTab */ + ExprList pChanges, /* Changes list for any UPDATE OF triggers */ + int isNew, /* 1 for new.* ref mask, 0 for old.* ref mask */ + int tr_tm, /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */ + Table pTab, /* The table to code triggers from */ + int orconf /* Default ON CONFLICT policy for trigger steps */ + ) + { + int op = pChanges != null ? TK_UPDATE : TK_DELETE; + u32 mask = 0; + Trigger p; + + Debug.Assert( isNew == 1 || isNew == 0 ); + for ( p = pTrigger; p != null; p = p.pNext ) + { + if ( p.op == op && ( tr_tm & p.tr_tm ) != 0 + && checkColumnOverlap( p.pColumns, pChanges ) != 0 + ) + { + TriggerPrg pPrg; + pPrg = getRowTrigger( pParse, p, pTab, orconf ); + if ( pPrg != null ) + { + mask |= pPrg.aColmask[isNew]; + } } -#endif // * !SQLITE_OMIT_TRIGGER) */ + } + return mask; } +#endif // * !SQLITE_OMIT_TRIGGER) */ + + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/update_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/update_c.cs index 7570bd390..bc6b81874 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/update_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/update_c.cs @@ -1,174 +1,183 @@ using System; using System.Diagnostics; +using u8 = System.Byte; using u32 = System.UInt32; -namespace Community.CsharpSqlite { - using sqlite3_value = Sqlite3.Mem; - - public partial class Sqlite3 { - /* - ** 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. - ** - ************************************************************************* - ** This file contains C code routines that are called by the parser - ** to handle UPDATE statements. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - -#if !SQLITE_OMIT_VIRTUALTABLE - /* Forward declaration */ - //static void updateVirtualTable( - //Parse pParse, /* The parsing context */ - //SrcList pSrc, /* The virtual table to be modified */ - //Table pTab, /* The virtual table */ - //ExprList pChanges, /* The columns to change in the UPDATE statement */ - //Expr pRowidExpr, /* Expression used to recompute the rowid */ - //int aXRef, /* Mapping from columns of pTab to entries in pChanges */ - //Expr *pWhere, /* WHERE clause of the UPDATE statement */ - //int onError /* ON CONFLICT strategy */ - //); -#endif // * SQLITE_OMIT_VIRTUALTABLE */ +namespace Community.CsharpSqlite +{ + using sqlite3_value = Sqlite3.Mem; - /* - ** The most recently coded instruction was an OP_Column to retrieve the - ** i-th column of table pTab. This routine sets the P4 parameter of the - ** OP_Column to the default value, if any. + public partial class Sqlite3 + { + /* + ** 2001 September 15 ** - ** The default value of a column is specified by a DEFAULT clause in the - ** column definition. This was either supplied by the user when the table - ** was created, or added later to the table definition by an ALTER TABLE - ** command. If the latter, then the row-records in the table btree on disk - ** may not contain a value for the column and the default value, taken - ** from the P4 parameter of the OP_Column instruction, is returned instead. - ** If the former, then all row-records are guaranteed to include a value - ** for the column and the P4 value is not required. + ** The author disclaims copyright to this source code. In place of + ** a legal notice, here is a blessing: ** - ** Column definitions created by an ALTER TABLE command may only have - ** literal default values specified: a number, null or a string. (If a more - ** complicated default expression value was provided, it is evaluated - ** when the ALTER TABLE is executed and one of the literal values written - ** into the sqlite_master table.) + ** 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. ** - ** Therefore, the P4 parameter is only required if the default value for - ** the column is a literal number, string or null. The sqlite3ValueFromExpr() - ** function is capable of transforming these types of expressions into - ** sqlite3_value objects. + ************************************************************************* + ** This file contains C code routines that are called by the parser + ** to handle UPDATE statements. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library ** - ** If parameter iReg is not negative, code an OP_RealAffinity instruction - ** on register iReg. This is used when an equivalent integer value is - ** stored in place of an 8-byte floating point value in order to save - ** space. + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* */ - static void sqlite3ColumnDefault(Vdbe v, Table pTab, int i, int iReg) { - Debug.Assert(pTab != null); - if (null == pTab.pSelect) { - sqlite3_value pValue = new sqlite3_value(); - int enc = ENC(sqlite3VdbeDb(v)); - Column pCol = pTab.aCol[i]; + //#include "sqliteInt.h" + +#if !SQLITE_OMIT_VIRTUALTABLE + /* Forward declaration */ + //static void updateVirtualTable( + //Parse pParse, /* The parsing context */ + //SrcList pSrc, /* The virtual table to be modified */ + //Table pTab, /* The virtual table */ + //ExprList pChanges, /* The columns to change in the UPDATE statement */ + //Expr pRowidExpr, /* Expression used to recompute the rowid */ + //int aXRef, /* Mapping from columns of pTab to entries in pChanges */ + //Expr *pWhere, /* WHERE clause of the UPDATE statement */ + //int onError /* ON CONFLICT strategy */ + //); +#endif // * SQLITE_OMIT_VIRTUALTABLE */ + + /* +** The most recently coded instruction was an OP_Column to retrieve the +** i-th column of table pTab. This routine sets the P4 parameter of the +** OP_Column to the default value, if any. +** +** The default value of a column is specified by a DEFAULT clause in the +** column definition. This was either supplied by the user when the table +** was created, or added later to the table definition by an ALTER TABLE +** command. If the latter, then the row-records in the table btree on disk +** may not contain a value for the column and the default value, taken +** from the P4 parameter of the OP_Column instruction, is returned instead. +** If the former, then all row-records are guaranteed to include a value +** for the column and the P4 value is not required. +** +** Column definitions created by an ALTER TABLE command may only have +** literal default values specified: a number, null or a string. (If a more +** complicated default expression value was provided, it is evaluated +** when the ALTER TABLE is executed and one of the literal values written +** into the sqlite_master table.) +** +** Therefore, the P4 parameter is only required if the default value for +** the column is a literal number, string or null. The sqlite3ValueFromExpr() +** function is capable of transforming these types of expressions into +** sqlite3_value objects. +** +** If parameter iReg is not negative, code an OP_RealAffinity instruction +** on register iReg. This is used when an equivalent integer value is +** stored in place of an 8-byte floating point value in order to save +** space. +*/ + static void sqlite3ColumnDefault( Vdbe v, Table pTab, int i, int iReg ) + { + Debug.Assert( pTab != null ); + if ( null == pTab.pSelect ) + { + sqlite3_value pValue = new sqlite3_value(); + int enc = ENC( sqlite3VdbeDb( v ) ); + Column pCol = pTab.aCol[i]; #if SQLITE_DEBUG - VdbeComment(v, "%s.%s", pTab.zName, pCol.zName); + VdbeComment( v, "%s.%s", pTab.zName, pCol.zName ); #endif - Debug.Assert(i < pTab.nCol); - sqlite3ValueFromExpr(sqlite3VdbeDb(v), pCol.pDflt, enc, - pCol.affinity, ref pValue); - if (pValue != null) { - sqlite3VdbeChangeP4(v, -1, pValue, P4_MEM); - } + Debug.Assert( i < pTab.nCol ); + sqlite3ValueFromExpr( sqlite3VdbeDb( v ), pCol.pDflt, enc, + pCol.affinity, ref pValue ); + if ( pValue != null ) + { + sqlite3VdbeChangeP4( v, -1, pValue, P4_MEM ); + } #if !SQLITE_OMIT_FLOATING_POINT - if (iReg >= 0 && pTab.aCol[i].affinity == SQLITE_AFF_REAL) { - sqlite3VdbeAddOp1(v, OP_RealAffinity, iReg); - } -#endif - } + if ( iReg >= 0 && pTab.aCol[i].affinity == SQLITE_AFF_REAL ) + { + sqlite3VdbeAddOp1( v, OP_RealAffinity, iReg ); } +#endif + } + } - /* - ** Process an UPDATE statement. - ** - ** UPDATE OR IGNORE table_wxyz SET a=b, c=d WHERE e<5 AND f NOT NULL; - ** \_______/ \________/ \______/ \________________/ - * onError pTabList pChanges pWhere - */ - static void sqlite3Update( - Parse pParse, /* The parser context */ - SrcList pTabList, /* The table in which we should change things */ - ExprList pChanges, /* Things to be changed */ - Expr pWhere, /* The WHERE clause. May be null */ - int onError /* How to handle constraint errors */ - ) { - int i, j; /* Loop counters */ - Table pTab; /* The table to be updated */ - int addr = 0; /* VDBE instruction address of the start of the loop */ - WhereInfo pWInfo; /* Information about the WHERE clause */ - Vdbe v; /* The virtual database engine */ - Index pIdx; /* For looping over indices */ - int nIdx; /* Number of indices that need updating */ - int iCur; /* VDBE Cursor number of pTab */ - sqlite3 db; /* The database structure */ - int[] aRegIdx = null; /* One register assigned to each index to be updated */ - int[] aXRef = null; /* aXRef[i] is the index in pChanges.a[] of the + /* + ** Process an UPDATE statement. + ** + ** UPDATE OR IGNORE table_wxyz SET a=b, c=d WHERE e<5 AND f NOT NULL; + ** \_______/ \________/ \______/ \________________/ + * onError pTabList pChanges pWhere + */ + static void sqlite3Update( + Parse pParse, /* The parser context */ + SrcList pTabList, /* The table in which we should change things */ + ExprList pChanges, /* Things to be changed */ + Expr pWhere, /* The WHERE clause. May be null */ + int onError /* How to handle constraint errors */ + ) + { + int i, j; /* Loop counters */ + Table pTab; /* The table to be updated */ + int addr = 0; /* VDBE instruction address of the start of the loop */ + WhereInfo pWInfo; /* Information about the WHERE clause */ + Vdbe v; /* The virtual database engine */ + Index pIdx; /* For looping over indices */ + int nIdx; /* Number of indices that need updating */ + int iCur; /* VDBE Cursor number of pTab */ + sqlite3 db; /* The database structure */ + int[] aRegIdx = null; /* One register assigned to each index to be updated */ + int[] aXRef = null; /* aXRef[i] is the index in pChanges.a[] of the ** an expression for the i-th column of the table. ** aXRef[i]==-1 if the i-th column is not changed. */ - bool chngRowid; /* True if the record number is being changed */ - Expr pRowidExpr = null; /* Expression defining the new record number */ - bool openAll = false; /* True if all indices need to be opened */ - AuthContext sContext; /* The authorization context */ - NameContext sNC; /* The name-context to resolve expressions in */ - int iDb; /* Database containing the table being updated */ - bool okOnePass; /* True for one-pass algorithm without the FIFO */ - bool hasFK; /* True if foreign key processing is required */ + bool chngRowid; /* True if the record number is being changed */ + Expr pRowidExpr = null; /* Expression defining the new record number */ + bool openAll = false; /* True if all indices need to be opened */ + AuthContext sContext; /* The authorization context */ + NameContext sNC; /* The name-context to resolve expressions in */ + int iDb; /* Database containing the table being updated */ + bool okOnePass; /* True for one-pass algorithm without the FIFO */ + bool hasFK; /* True if foreign key processing is required */ #if !SQLITE_OMIT_TRIGGER - bool isView; /* True when updating a view (INSTEAD OF trigger) */ - Trigger pTrigger; /* List of triggers on pTab, if required */ - int tmask = 0; /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */ + bool isView; /* True when updating a view (INSTEAD OF trigger) */ + Trigger pTrigger; /* List of triggers on pTab, if required */ + int tmask = 0; /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */ #endif - int newmask; /* Mask of NEW.* columns accessed by BEFORE triggers */ - - /* Register Allocations */ - int regRowCount = 0; /* A count of rows changed */ - int regOldRowid; /* The old rowid */ - int regNewRowid; /* The new rowid */ - int regNew; - int regOld = 0; - int regRowSet = 0; /* Rowset of rows to be updated */ - - sContext = new AuthContext(); //memset( &sContext, 0, sizeof( sContext ) ); - db = pParse.db; - if (pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) { - goto update_cleanup; - } - Debug.Assert(pTabList.nSrc == 1); - - /* Locate the table which we want to update. - */ - pTab = sqlite3SrcListLookup(pParse, pTabList); - if (pTab == null) - goto update_cleanup; - iDb = sqlite3SchemaToIndex(pParse.db, pTab.pSchema); + int newmask; /* Mask of NEW.* columns accessed by BEFORE triggers */ + + /* Register Allocations */ + int regRowCount = 0; /* A count of rows changed */ + int regOldRowid; /* The old rowid */ + int regNewRowid; /* The new rowid */ + int regNew; + int regOld = 0; + int regRowSet = 0; /* Rowset of rows to be updated */ + + sContext = new AuthContext(); //memset( &sContext, 0, sizeof( sContext ) ); + db = pParse.db; + if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) + { + goto update_cleanup; + } + Debug.Assert( pTabList.nSrc == 1 ); + + /* Locate the table which we want to update. + */ + pTab = sqlite3SrcListLookup( pParse, pTabList ); + if ( pTab == null ) + goto update_cleanup; + iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema ); - /* Figure out if we have any triggers and if the table being - ** updated is a view. - */ + /* Figure out if we have any triggers and if the table being + ** updated is a view. + */ #if !SQLITE_OMIT_TRIGGER - pTrigger = sqlite3TriggersExist(pParse, pTab, TK_UPDATE, pChanges, out tmask); - isView = pTab.pSelect != null; - Debug.Assert(pTrigger != null || tmask == 0); + pTrigger = sqlite3TriggersExist( pParse, pTab, TK_UPDATE, pChanges, out tmask ); + isView = pTab.pSelect != null; + Debug.Assert( pTrigger != null || tmask == 0 ); #else const Trigger pTrigger = null;//# define pTrigger 0 const int tmask = 0; //# define tmask 0 @@ -178,63 +187,75 @@ int onError /* How to handle constraint errors */ const bool isView = false; //# define isView 0 #endif - if (sqlite3ViewGetColumnNames(pParse, pTab) != 0) { - goto update_cleanup; - } - if (sqlite3IsReadOnly(pParse, pTab, tmask)) { - goto update_cleanup; - } - aXRef = new int[pTab.nCol];// sqlite3DbMallocRaw(db, sizeof(int) * pTab.nCol); - //if ( aXRef == null ) goto update_cleanup; - for (i = 0; i < pTab.nCol; i++) - aXRef[i] = -1; - - /* Allocate a cursors for the main database table and for all indices. - ** The index cursors might not be used, but if they are used they - ** need to occur right after the database cursor. So go ahead and - ** allocate enough space, just in case. - */ - pTabList.a[0].iCursor = iCur = pParse.nTab++; - for (pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext) { - pParse.nTab++; + if ( sqlite3ViewGetColumnNames( pParse, pTab ) != 0 ) + { + goto update_cleanup; + } + if ( sqlite3IsReadOnly( pParse, pTab, tmask ) ) + { + goto update_cleanup; + } + aXRef = new int[pTab.nCol];// sqlite3DbMallocRaw(db, sizeof(int) * pTab.nCol); + //if ( aXRef == null ) goto update_cleanup; + for ( i = 0; i < pTab.nCol; i++ ) + aXRef[i] = -1; + + /* Allocate a cursors for the main database table and for all indices. + ** The index cursors might not be used, but if they are used they + ** need to occur right after the database cursor. So go ahead and + ** allocate enough space, just in case. + */ + pTabList.a[0].iCursor = iCur = pParse.nTab++; + for ( pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext ) + { + pParse.nTab++; + } + + /* Initialize the name-context */ + sNC = new NameContext();// memset(&sNC, 0, sNC).Length; + sNC.pParse = pParse; + sNC.pSrcList = pTabList; + + /* Resolve the column names in all the expressions of the + ** of the UPDATE statement. Also find the column index + ** for each column to be updated in the pChanges array. For each + ** column to be updated, make sure we have authorization to change + ** that column. + */ + chngRowid = false; + for ( i = 0; i < pChanges.nExpr; i++ ) + { + if ( sqlite3ResolveExprNames( sNC, ref pChanges.a[i].pExpr ) != 0 ) + { + goto update_cleanup; + } + for ( j = 0; j < pTab.nCol; j++ ) + { + if ( pTab.aCol[j].zName.Equals( pChanges.a[i].zName, StringComparison.OrdinalIgnoreCase ) ) + { + if ( j == pTab.iPKey ) + { + chngRowid = true; + pRowidExpr = pChanges.a[i].pExpr; } - - /* Initialize the name-context */ - sNC = new NameContext();// memset(&sNC, 0, sNC).Length; - sNC.pParse = pParse; - sNC.pSrcList = pTabList; - - /* Resolve the column names in all the expressions of the - ** of the UPDATE statement. Also find the column index - ** for each column to be updated in the pChanges array. For each - ** column to be updated, make sure we have authorization to change - ** that column. - */ - chngRowid = false; - for (i = 0; i < pChanges.nExpr; i++) { - if (sqlite3ResolveExprNames(sNC, ref pChanges.a[i].pExpr) != 0) { - goto update_cleanup; - } - for (j = 0; j < pTab.nCol; j++) { - if (pTab.aCol[j].zName.Equals(pChanges.a[i].zName, StringComparison.OrdinalIgnoreCase)) { - if (j == pTab.iPKey) { - chngRowid = true; - pRowidExpr = pChanges.a[i].pExpr; - } - aXRef[j] = i; - break; - } - } - if (j >= pTab.nCol) { - if (sqlite3IsRowid(pChanges.a[i].zName)) { - chngRowid = true; - pRowidExpr = pChanges.a[i].pExpr; - } else { - sqlite3ErrorMsg(pParse, "no such column: %s", pChanges.a[i].zName); - pParse.checkSchema = 1; - goto update_cleanup; - } - } + aXRef[j] = i; + break; + } + } + if ( j >= pTab.nCol ) + { + if ( sqlite3IsRowid( pChanges.a[i].zName ) ) + { + chngRowid = true; + pRowidExpr = pChanges.a[i].pExpr; + } + else + { + sqlite3ErrorMsg( pParse, "no such column: %s", pChanges.a[i].zName ); + pParse.checkSchema = 1; + goto update_cleanup; + } + } #if !SQLITE_OMIT_AUTHORIZATION { int rc; @@ -247,453 +268,514 @@ int onError /* How to handle constraint errors */ } } #endif - } + } - hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngRowid ? 1 : 0) != 0; + hasFK = sqlite3FkRequired( pParse, pTab, aXRef, chngRowid ? 1 : 0 ) != 0; - /* Allocate memory for the array aRegIdx[]. There is one entry in the - ** array for each index associated with table being updated. Fill in - ** the value with a register number for indices that are to be used - ** and with zero for unused indices. - */ - for (nIdx = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, nIdx++) { - } - if (nIdx > 0) { - aRegIdx = new int[nIdx]; // sqlite3DbMallocRaw(db, Index*.Length * nIdx); - if (aRegIdx == null) - goto update_cleanup; - } - for (j = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, j++) { - int reg; - if (hasFK || chngRowid) { - reg = ++pParse.nMem; - } else { - reg = 0; - for (i = 0; i < pIdx.nColumn; i++) { - if (aXRef[pIdx.aiColumn[i]] >= 0) { - reg = ++pParse.nMem; - break; - } - } - } - aRegIdx[j] = reg; + /* Allocate memory for the array aRegIdx[]. There is one entry in the + ** array for each index associated with table being updated. Fill in + ** the value with a register number for indices that are to be used + ** and with zero for unused indices. + */ + for ( nIdx = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, nIdx++ ) + { + } + if ( nIdx > 0 ) + { + aRegIdx = new int[nIdx]; // sqlite3DbMallocRaw(db, Index*.Length * nIdx); + if ( aRegIdx == null ) + goto update_cleanup; + } + for ( j = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, j++ ) + { + int reg; + if ( hasFK || chngRowid ) + { + reg = ++pParse.nMem; + } + else + { + reg = 0; + for ( i = 0; i < pIdx.nColumn; i++ ) + { + if ( aXRef[pIdx.aiColumn[i]] >= 0 ) + { + reg = ++pParse.nMem; + break; } + } + } + aRegIdx[j] = reg; + } - /* Begin generating code. */ - v = sqlite3GetVdbe(pParse); - if (v == null) - goto update_cleanup; - if (pParse.nested == 0) - sqlite3VdbeCountChanges(v); - sqlite3BeginWriteOperation(pParse, 1, iDb); + /* Begin generating code. */ + v = sqlite3GetVdbe( pParse ); + if ( v == null ) + goto update_cleanup; + if ( pParse.nested == 0 ) + sqlite3VdbeCountChanges( v ); + sqlite3BeginWriteOperation( pParse, 1, iDb ); #if !SQLITE_OMIT_VIRTUALTABLE - /* Virtual tables must be handled separately */ - if (IsVirtual(pTab)) { - updateVirtualTable(pParse, pTabList, pTab, pChanges, pRowidExpr, aXRef, - pWhere, onError); - pWhere = null; - pTabList = null; - goto update_cleanup; - } + /* Virtual tables must be handled separately */ + if ( IsVirtual( pTab ) ) + { + updateVirtualTable( pParse, pTabList, pTab, pChanges, pRowidExpr, aXRef, + pWhere, onError ); + pWhere = null; + pTabList = null; + goto update_cleanup; + } #endif - /* Allocate required registers. */ - regOldRowid = regNewRowid = ++pParse.nMem; - if (pTrigger != null || hasFK) { - regOld = pParse.nMem + 1; - pParse.nMem += pTab.nCol; - } - if (chngRowid || pTrigger != null || hasFK) { - regNewRowid = ++pParse.nMem; - } - regNew = pParse.nMem + 1; - pParse.nMem += pTab.nCol; - - /* Start the view context. */ - if (isView) { - sqlite3AuthContextPush(pParse, sContext, pTab.zName); - } - - /* If we are trying to update a view, realize that view into - ** a ephemeral table. - */ + /* Allocate required registers. */ + regOldRowid = regNewRowid = ++pParse.nMem; + if ( pTrigger != null || hasFK ) + { + regOld = pParse.nMem + 1; + pParse.nMem += pTab.nCol; + } + if ( chngRowid || pTrigger != null || hasFK ) + { + regNewRowid = ++pParse.nMem; + } + regNew = pParse.nMem + 1; + pParse.nMem += pTab.nCol; + + /* Start the view context. */ + if ( isView ) + { + sqlite3AuthContextPush( pParse, sContext, pTab.zName ); + } + + /* If we are trying to update a view, realize that view into + ** a ephemeral table. + */ #if !(SQLITE_OMIT_VIEW) && !(SQLITE_OMIT_TRIGGER) - if (isView) { - sqlite3MaterializeView(pParse, pTab, pWhere, iCur); - } + if ( isView ) + { + sqlite3MaterializeView( pParse, pTab, pWhere, iCur ); + } #endif - /* Resolve the column names in all the expressions in the - ** WHERE clause. + /* Resolve the column names in all the expressions in the +** WHERE clause. +*/ + if ( sqlite3ResolveExprNames( sNC, ref pWhere ) != 0 ) + { + goto update_cleanup; + } + + /* Begin the database scan */ - if (sqlite3ResolveExprNames(sNC, ref pWhere) != 0) { - goto update_cleanup; - } + sqlite3VdbeAddOp2( v, OP_Null, 0, regOldRowid ); + ExprList NullOrderby = null; + pWInfo = sqlite3WhereBegin( pParse, pTabList, pWhere, ref NullOrderby, WHERE_ONEPASS_DESIRED ); + if ( pWInfo == null ) + goto update_cleanup; + okOnePass = pWInfo.okOnePass != 0; + + /* Remember the rowid of every item to be updated. + */ + sqlite3VdbeAddOp2( v, OP_Rowid, iCur, regOldRowid ); + if ( !okOnePass ) + { + regRowSet = ++pParse.nMem; + sqlite3VdbeAddOp2( v, OP_RowSetAdd, regRowSet, regOldRowid ); + } + + /* End the database scan loop. + */ + sqlite3WhereEnd( pWInfo ); - /* Begin the database scan - */ - sqlite3VdbeAddOp2(v, OP_Null, 0, regOldRowid); - ExprList NullOrderby = null; - pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, ref NullOrderby, WHERE_ONEPASS_DESIRED); - if (pWInfo == null) - goto update_cleanup; - okOnePass = pWInfo.okOnePass != 0; - - /* Remember the rowid of every item to be updated. - */ - sqlite3VdbeAddOp2(v, OP_Rowid, iCur, regOldRowid); - if (!okOnePass) { - regRowSet = ++pParse.nMem; - sqlite3VdbeAddOp2(v, OP_RowSetAdd, regRowSet, regOldRowid); + /* Initialize the count of updated rows + */ + if ( ( db.flags & SQLITE_CountRows ) != 0 && null == pParse.pTriggerTab ) + { + regRowCount = ++pParse.nMem; + sqlite3VdbeAddOp2( v, OP_Integer, 0, regRowCount ); + } + + if ( !isView ) + { + /* + ** Open every index that needs updating. Note that if any + ** index could potentially invoke a REPLACE conflict resolution + ** action, then we need to open all indices because we might need + ** to be deleting some records. + */ + if ( !okOnePass ) + sqlite3OpenTable( pParse, iCur, iDb, pTab, OP_OpenWrite ); + if ( onError == OE_Replace ) + { + openAll = true; + } + else + { + openAll = false; + for ( pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext ) + { + if ( pIdx.onError == OE_Replace ) + { + openAll = true; + break; } - - /* End the database scan loop. + } + } + for ( i = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, i++ ) + { + if ( openAll || aRegIdx[i] > 0 ) + { + KeyInfo pKey = sqlite3IndexKeyinfo( pParse, pIdx ); + sqlite3VdbeAddOp4( v, OP_OpenWrite, iCur + i + 1, pIdx.tnum, iDb, + pKey, P4_KEYINFO_HANDOFF ); + Debug.Assert( pParse.nTab > iCur + i + 1 ); + } + } + } + + /* Top of the update loop */ + if ( okOnePass ) + { + int a1 = sqlite3VdbeAddOp1( v, OP_NotNull, regOldRowid ); + addr = sqlite3VdbeAddOp0( v, OP_Goto ); + sqlite3VdbeJumpHere( v, a1 ); + } + else + { + addr = sqlite3VdbeAddOp3( v, OP_RowSetRead, regRowSet, 0, regOldRowid ); + } + + /* Make cursor iCur point to the record that is being updated. If + ** this record does not exist for some reason (deleted by a trigger, + ** for example, then jump to the next iteration of the RowSet loop. */ + sqlite3VdbeAddOp3( v, OP_NotExists, iCur, addr, regOldRowid ); + + /* If the record number will change, set register regNewRowid to + ** contain the new value. If the record number is not being modified, + ** then regNewRowid is the same register as regOldRowid, which is + ** already populated. */ + Debug.Assert( chngRowid || pTrigger != null || hasFK || regOldRowid == regNewRowid ); + if ( chngRowid ) + { + sqlite3ExprCode( pParse, pRowidExpr, regNewRowid ); + sqlite3VdbeAddOp1( v, OP_MustBeInt, regNewRowid ); + } + + /* If there are triggers on this table, populate an array of registers + ** with the required old.* column data. */ + if ( hasFK || pTrigger != null ) + { + u32 oldmask = ( hasFK ? sqlite3FkOldmask( pParse, pTab ) : 0 ); + oldmask |= sqlite3TriggerColmask( pParse, + pTrigger, pChanges, 0, TRIGGER_BEFORE | TRIGGER_AFTER, pTab, onError + ); + for ( i = 0; i < pTab.nCol; i++ ) + { + if ( aXRef[i] < 0 || oldmask == 0xffffffff || ( i < 32 && 0 != ( oldmask & ( 1 << i ) ) ) ) + { + sqlite3ExprCodeGetColumnOfTable( v, pTab, iCur, i, regOld + i ); + } + else + { + sqlite3VdbeAddOp2( v, OP_Null, 0, regOld + i ); + } + } + if ( chngRowid == false ) + { + sqlite3VdbeAddOp2( v, OP_Copy, regOldRowid, regNewRowid ); + } + } + + /* Populate the array of registers beginning at regNew with the new + ** row data. This array is used to check constaints, create the new + ** table and index records, and as the values for any new.* references + ** made by triggers. + ** + ** If there are one or more BEFORE triggers, then do not populate the + ** registers associated with columns that are (a) not modified by + ** this UPDATE statement and (b) not accessed by new.* references. The + ** values for registers not modified by the UPDATE must be reloaded from + ** the database after the BEFORE triggers are fired anyway (as the trigger + ** may have modified them). So not loading those that are not going to + ** be used eliminates some redundant opcodes. + */ + newmask = (int)sqlite3TriggerColmask( + pParse, pTrigger, pChanges, 1, TRIGGER_BEFORE, pTab, onError + ); + for ( i = 0; i < pTab.nCol; i++ ) + { + if ( i == pTab.iPKey ) + { + sqlite3VdbeAddOp2( v, OP_Null, 0, regNew + i ); + } + else + { + j = aXRef[i]; + if ( j >= 0 ) + { + sqlite3ExprCode( pParse, pChanges.a[j].pExpr, regNew + i ); + } + else if ( 0 == ( tmask & TRIGGER_BEFORE ) || i > 31 || ( newmask & ( 1 << i ) ) != 0 ) + { + /* This branch loads the value of a column that will not be changed + ** into a register. This is done if there are no BEFORE triggers, or + ** if there are one or more BEFORE triggers that use this value via + ** a new.* reference in a trigger program. */ - sqlite3WhereEnd(pWInfo); + testcase( i == 31 ); + testcase( i == 32 ); + sqlite3VdbeAddOp3( v, OP_Column, iCur, i, regNew + i ); + sqlite3ColumnDefault( v, pTab, i, regNew + i ); + } + } + } - /* Initialize the count of updated rows - */ - if ((db.flags & SQLITE_CountRows) != 0 && null == pParse.pTriggerTab) { - regRowCount = ++pParse.nMem; - sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount); - } + /* Fire any BEFORE UPDATE triggers. This happens before constraints are + ** verified. One could argue that this is wrong. + */ + if ( ( tmask & TRIGGER_BEFORE ) != 0 ) + { + sqlite3VdbeAddOp2( v, OP_Affinity, regNew, pTab.nCol ); + sqlite3TableAffinityStr( v, pTab ); + sqlite3CodeRowTrigger( pParse, pTrigger, TK_UPDATE, pChanges, + TRIGGER_BEFORE, pTab, regOldRowid, onError, addr ); + + /* The row-trigger may have deleted the row being updated. In this + ** case, jump to the next row. No updates or AFTER triggers are + ** required. This behaviour - what happens when the row being updated + ** is deleted or renamed by a BEFORE trigger - is left undefined in the + ** documentation. + */ + sqlite3VdbeAddOp3( v, OP_NotExists, iCur, addr, regOldRowid ); - if (!isView) { - /* - ** Open every index that needs updating. Note that if any - ** index could potentially invoke a REPLACE conflict resolution - ** action, then we need to open all indices because we might need - ** to be deleting some records. - */ - if (!okOnePass) - sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenWrite); - if (onError == OE_Replace) { - openAll = true; - } else { - openAll = false; - for (pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext) { - if (pIdx.onError == OE_Replace) { - openAll = true; - break; - } - } - } - for (i = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, i++) { - if (openAll || aRegIdx[i] > 0) { - KeyInfo pKey = sqlite3IndexKeyinfo(pParse, pIdx); - sqlite3VdbeAddOp4(v, OP_OpenWrite, iCur + i + 1, pIdx.tnum, iDb, - pKey, P4_KEYINFO_HANDOFF); - Debug.Assert(pParse.nTab > iCur + i + 1); - } - } - } + /* If it did not delete it, the row-trigger may still have modified + ** some of the columns of the row being updated. Load the values for + ** all columns not modified by the update statement into their + ** registers in case this has happened. + */ + for ( i = 0; i < pTab.nCol; i++ ) + { + if ( aXRef[i] < 0 && i != pTab.iPKey ) + { + sqlite3VdbeAddOp3( v, OP_Column, iCur, i, regNew + i ); + sqlite3ColumnDefault( v, pTab, i, regNew + i ); + } + } + } - /* Top of the update loop */ - if (okOnePass) { - int a1 = sqlite3VdbeAddOp1(v, OP_NotNull, regOldRowid); - addr = sqlite3VdbeAddOp0(v, OP_Goto); - sqlite3VdbeJumpHere(v, a1); - } else { - addr = sqlite3VdbeAddOp3(v, OP_RowSetRead, regRowSet, 0, regOldRowid); - } + if ( !isView ) + { + int j1; /* Address of jump instruction */ - /* Make cursor iCur point to the record that is being updated. If - ** this record does not exist for some reason (deleted by a trigger, - ** for example, then jump to the next iteration of the RowSet loop. */ - sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, regOldRowid); - - /* If the record number will change, set register regNewRowid to - ** contain the new value. If the record number is not being modified, - ** then regNewRowid is the same register as regOldRowid, which is - ** already populated. */ - Debug.Assert(chngRowid || pTrigger != null || hasFK || regOldRowid == regNewRowid); - if (chngRowid) { - sqlite3ExprCode(pParse, pRowidExpr, regNewRowid); - sqlite3VdbeAddOp1(v, OP_MustBeInt, regNewRowid); - } + /* Do constraint checks. */ + int iDummy; + sqlite3GenerateConstraintChecks( pParse, pTab, iCur, regNewRowid, + aRegIdx, ( chngRowid ? regOldRowid : 0 ), true, onError, addr, out iDummy ); - /* If there are triggers on this table, populate an array of registers - ** with the required old.* column data. */ - if (hasFK || pTrigger != null) { - u32 oldmask = (hasFK ? sqlite3FkOldmask(pParse, pTab) : 0); - oldmask |= sqlite3TriggerColmask(pParse, - pTrigger, pChanges, 0, TRIGGER_BEFORE | TRIGGER_AFTER, pTab, onError - ); - for (i = 0; i < pTab.nCol; i++) { - if (aXRef[i] < 0 || oldmask == 0xffffffff || (i < 32 && 0 != (oldmask & (1 << i)))) { - sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, i, regOld + i); - } else { - sqlite3VdbeAddOp2(v, OP_Null, 0, regOld + i); - } - } - if (chngRowid == false) { - sqlite3VdbeAddOp2(v, OP_Copy, regOldRowid, regNewRowid); - } - } + /* Do FK constraint checks. */ + if ( hasFK ) + { + sqlite3FkCheck( pParse, pTab, regOldRowid, 0 ); + } - /* Populate the array of registers beginning at regNew with the new - ** row data. This array is used to check constaints, create the new - ** table and index records, and as the values for any new.* references - ** made by triggers. - ** - ** If there are one or more BEFORE triggers, then do not populate the - ** registers associated with columns that are (a) not modified by - ** this UPDATE statement and (b) not accessed by new.* references. The - ** values for registers not modified by the UPDATE must be reloaded from - ** the database after the BEFORE triggers are fired anyway (as the trigger - ** may have modified them). So not loading those that are not going to - ** be used eliminates some redundant opcodes. - */ - newmask = (int)sqlite3TriggerColmask( - pParse, pTrigger, pChanges, 1, TRIGGER_BEFORE, pTab, onError - ); - for (i = 0; i < pTab.nCol; i++) { - if (i == pTab.iPKey) { - sqlite3VdbeAddOp2(v, OP_Null, 0, regNew + i); - } else { - j = aXRef[i]; - if (j >= 0) { - sqlite3ExprCode(pParse, pChanges.a[j].pExpr, regNew + i); - } else if (0 == (tmask & TRIGGER_BEFORE) || i > 31 || (newmask & (1 << i)) != 0) { - /* This branch loads the value of a column that will not be changed - ** into a register. This is done if there are no BEFORE triggers, or - ** if there are one or more BEFORE triggers that use this value via - ** a new.* reference in a trigger program. - */ - testcase(i == 31); - testcase(i == 32); - sqlite3VdbeAddOp3(v, OP_Column, iCur, i, regNew + i); - sqlite3ColumnDefault(v, pTab, i, regNew + i); - } - } - } + /* Delete the index entries associated with the current record. */ + j1 = sqlite3VdbeAddOp3( v, OP_NotExists, iCur, 0, regOldRowid ); + sqlite3GenerateRowIndexDelete( pParse, pTab, iCur, aRegIdx ); - /* Fire any BEFORE UPDATE triggers. This happens before constraints are - ** verified. One could argue that this is wrong. - */ - if ((tmask & TRIGGER_BEFORE) != 0) { - sqlite3VdbeAddOp2(v, OP_Affinity, regNew, pTab.nCol); - sqlite3TableAffinityStr(v, pTab); - sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, - TRIGGER_BEFORE, pTab, regOldRowid, onError, addr); - - /* The row-trigger may have deleted the row being updated. In this - ** case, jump to the next row. No updates or AFTER triggers are - ** required. This behaviour - what happens when the row being updated - ** is deleted or renamed by a BEFORE trigger - is left undefined in the - ** documentation. - */ - sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, regOldRowid); - - /* If it did not delete it, the row-trigger may still have modified - ** some of the columns of the row being updated. Load the values for - ** all columns not modified by the update statement into their - ** registers in case this has happened. - */ - for (i = 0; i < pTab.nCol; i++) { - if (aXRef[i] < 0 && i != pTab.iPKey) { - sqlite3VdbeAddOp3(v, OP_Column, iCur, i, regNew + i); - sqlite3ColumnDefault(v, pTab, i, regNew + i); - } - } - } + /* If changing the record number, delete the old record. */ + if ( hasFK || chngRowid ) + { + sqlite3VdbeAddOp2( v, OP_Delete, iCur, 0 ); + } + sqlite3VdbeJumpHere( v, j1 ); - if (!isView) { - int j1; /* Address of jump instruction */ - - /* Do constraint checks. */ - int iDummy; - sqlite3GenerateConstraintChecks(pParse, pTab, iCur, regNewRowid, - aRegIdx, (chngRowid ? regOldRowid : 0), true, onError, addr, out iDummy); - - /* Do FK constraint checks. */ - if (hasFK) { - sqlite3FkCheck(pParse, pTab, regOldRowid, 0); - } - - /* Delete the index entries associated with the current record. */ - j1 = sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regOldRowid); - sqlite3GenerateRowIndexDelete(pParse, pTab, iCur, aRegIdx); - - /* If changing the record number, delete the old record. */ - if (hasFK || chngRowid) { - sqlite3VdbeAddOp2(v, OP_Delete, iCur, 0); - } - sqlite3VdbeJumpHere(v, j1); - - if (hasFK) { - sqlite3FkCheck(pParse, pTab, 0, regNewRowid); - } - - /* Insert the new index entries and the new record. */ - sqlite3CompleteInsertion(pParse, pTab, iCur, regNewRowid, aRegIdx, true, false, false); - - /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to - ** handle rows (possibly in other tables) that refer via a foreign key - ** to the row just updated. */ - if (hasFK) { - sqlite3FkActions(pParse, pTab, pChanges, regOldRowid); - } - } + if ( hasFK ) + { + sqlite3FkCheck( pParse, pTab, 0, regNewRowid ); + } - /* Increment the row counter - */ - if ((db.flags & SQLITE_CountRows) != 0 && null == pParse.pTriggerTab) { - sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1); - } + /* Insert the new index entries and the new record. */ + sqlite3CompleteInsertion( pParse, pTab, iCur, regNewRowid, aRegIdx, true, false, false ); - sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, - TRIGGER_AFTER, pTab, regOldRowid, onError, addr); + /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to + ** handle rows (possibly in other tables) that refer via a foreign key + ** to the row just updated. */ + if ( hasFK ) + { + sqlite3FkActions( pParse, pTab, pChanges, regOldRowid ); + } + } - /* Repeat the above with the next record to be updated, until - ** all record selected by the WHERE clause have been updated. - */ - sqlite3VdbeAddOp2(v, OP_Goto, 0, addr); - sqlite3VdbeJumpHere(v, addr); - - /* Close all tables */ - for (i = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, i++) { - if (openAll || aRegIdx[i] > 0) { - sqlite3VdbeAddOp2(v, OP_Close, iCur + i + 1, 0); - } - } - sqlite3VdbeAddOp2(v, OP_Close, iCur, 0); + /* Increment the row counter + */ + if ( ( db.flags & SQLITE_CountRows ) != 0 && null == pParse.pTriggerTab ) + { + sqlite3VdbeAddOp2( v, OP_AddImm, regRowCount, 1 ); + } - /* Update the sqlite_sequence table by storing the content of the - ** maximum rowid counter values recorded while inserting into - ** autoincrement tables. - */ - if (pParse.nested == 0 && pParse.pTriggerTab == null) { - sqlite3AutoincrementEnd(pParse); - } + sqlite3CodeRowTrigger( pParse, pTrigger, TK_UPDATE, pChanges, + TRIGGER_AFTER, pTab, regOldRowid, onError, addr ); - /* - ** Return the number of rows that were changed. If this routine is - ** generating code because of a call to sqlite3NestedParse(), do not - ** invoke the callback function. - */ - if ((db.flags & SQLITE_CountRows) != 0 && null == pParse.pTriggerTab && 0 == pParse.nested) { - sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1); - sqlite3VdbeSetNumCols(v, 1); - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows updated", SQLITE_STATIC); - } + /* Repeat the above with the next record to be updated, until + ** all record selected by the WHERE clause have been updated. + */ + sqlite3VdbeAddOp2( v, OP_Goto, 0, addr ); + sqlite3VdbeJumpHere( v, addr ); + + /* Close all tables */ + for ( i = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, i++ ) + { + if ( openAll || aRegIdx[i] > 0 ) + { + sqlite3VdbeAddOp2( v, OP_Close, iCur + i + 1, 0 ); + } + } + sqlite3VdbeAddOp2( v, OP_Close, iCur, 0 ); - update_cleanup: + /* Update the sqlite_sequence table by storing the content of the + ** maximum rowid counter values recorded while inserting into + ** autoincrement tables. + */ + if ( pParse.nested == 0 && pParse.pTriggerTab == null ) + { + sqlite3AutoincrementEnd( pParse ); + } + + /* + ** Return the number of rows that were changed. If this routine is + ** generating code because of a call to sqlite3NestedParse(), do not + ** invoke the callback function. + */ + if ( ( db.flags & SQLITE_CountRows ) != 0 && null == pParse.pTriggerTab && 0 == pParse.nested ) + { + sqlite3VdbeAddOp2( v, OP_ResultRow, regRowCount, 1 ); + sqlite3VdbeSetNumCols( v, 1 ); + sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "rows updated", SQLITE_STATIC ); + } + +update_cleanup: #if !SQLITE_OMIT_AUTHORIZATION sqlite3AuthContextPop(sContext); #endif - sqlite3DbFree(db, ref aRegIdx); - sqlite3DbFree(db, ref aXRef); - sqlite3SrcListDelete(db, ref pTabList); - sqlite3ExprListDelete(db, ref pChanges); - sqlite3ExprDelete(db, ref pWhere); - return; - } - /* Make sure "isView" and other macros defined above are undefined. Otherwise - ** thely may interfere with compilation of other functions in this file - ** (or in another file, if this file becomes part of the amalgamation). */ - //#if isView - // #undef isView - //#endif - //#if pTrigger - // #undef pTrigger - //#endif + sqlite3DbFree( db, ref aRegIdx ); + sqlite3DbFree( db, ref aXRef ); + sqlite3SrcListDelete( db, ref pTabList ); + sqlite3ExprListDelete( db, ref pChanges ); + sqlite3ExprDelete( db, ref pWhere ); + return; + } + /* Make sure "isView" and other macros defined above are undefined. Otherwise + ** thely may interfere with compilation of other functions in this file + ** (or in another file, if this file becomes part of the amalgamation). */ + //#if isView + // #undef isView + //#endif + //#if pTrigger + // #undef pTrigger + //#endif #if !SQLITE_OMIT_VIRTUALTABLE - /* - ** Generate code for an UPDATE of a virtual table. - ** - ** The strategy is that we create an ephemerial table that contains - ** for each row to be changed: - ** - ** (A) The original rowid of that row. - ** (B) The revised rowid for the row. (note1) - ** (C) The content of every column in the row. - ** - ** Then we loop over this ephemeral table and for each row in - ** the ephermeral table call VUpdate. - ** - ** When finished, drop the ephemeral table. - ** - ** (note1) Actually, if we know in advance that (A) is always the same - ** as (B) we only store (A), then duplicate (A) when pulling - ** it out of the ephemeral table before calling VUpdate. - */ - static void updateVirtualTable( - Parse pParse, /* The parsing context */ - SrcList pSrc, /* The virtual table to be modified */ - Table pTab, /* The virtual table */ - ExprList pChanges, /* The columns to change in the UPDATE statement */ - Expr pRowid, /* Expression used to recompute the rowid */ - int[] aXRef, /* Mapping from columns of pTab to entries in pChanges */ - Expr pWhere, /* WHERE clause of the UPDATE statement */ - int onError /* ON CONFLICT strategy */ - ) { - Vdbe v = pParse.pVdbe; /* Virtual machine under construction */ - ExprList pEList = null; /* The result set of the SELECT statement */ - Select pSelect = null; /* The SELECT statement */ - Expr pExpr; /* Temporary expression */ - int ephemTab; /* Table holding the result of the SELECT */ - int i; /* Loop counter */ - int addr; /* Address of top of loop */ - int iReg; /* First register in set passed to OP_VUpdate */ - sqlite3 db = pParse.db; /* Database connection */ - VTable pVTab = sqlite3GetVTable(db, pTab); - SelectDest dest = new SelectDest(); - - /* Construct the SELECT statement that will find the new values for - ** all updated rows. - */ - pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, TK_ID, "_rowid_")); - if (pRowid != null) { - pEList = sqlite3ExprListAppend(pParse, pEList, - sqlite3ExprDup(db, pRowid, 0)); - } - Debug.Assert(pTab.iPKey < 0); - for (i = 0; i < pTab.nCol; i++) { - if (aXRef[i] >= 0) { - pExpr = sqlite3ExprDup(db, pChanges.a[aXRef[i]].pExpr, 0); - } else { - pExpr = sqlite3Expr(db, TK_ID, pTab.aCol[i].zName); - } - pEList = sqlite3ExprListAppend(pParse, pEList, pExpr); - } - pSelect = sqlite3SelectNew(pParse, pEList, pSrc, pWhere, null, null, null, 0, null, null); + /* +** Generate code for an UPDATE of a virtual table. +** +** The strategy is that we create an ephemerial table that contains +** for each row to be changed: +** +** (A) The original rowid of that row. +** (B) The revised rowid for the row. (note1) +** (C) The content of every column in the row. +** +** Then we loop over this ephemeral table and for each row in +** the ephermeral table call VUpdate. +** +** When finished, drop the ephemeral table. +** +** (note1) Actually, if we know in advance that (A) is always the same +** as (B) we only store (A), then duplicate (A) when pulling +** it out of the ephemeral table before calling VUpdate. +*/ + static void updateVirtualTable( + Parse pParse, /* The parsing context */ + SrcList pSrc, /* The virtual table to be modified */ + Table pTab, /* The virtual table */ + ExprList pChanges, /* The columns to change in the UPDATE statement */ + Expr pRowid, /* Expression used to recompute the rowid */ + int[] aXRef, /* Mapping from columns of pTab to entries in pChanges */ + Expr pWhere, /* WHERE clause of the UPDATE statement */ + int onError /* ON CONFLICT strategy */ + ) + { + Vdbe v = pParse.pVdbe; /* Virtual machine under construction */ + ExprList pEList = null; /* The result set of the SELECT statement */ + Select pSelect = null; /* The SELECT statement */ + Expr pExpr; /* Temporary expression */ + int ephemTab; /* Table holding the result of the SELECT */ + int i; /* Loop counter */ + int addr; /* Address of top of loop */ + int iReg; /* First register in set passed to OP_VUpdate */ + sqlite3 db = pParse.db; /* Database connection */ + VTable pVTab = sqlite3GetVTable( db, pTab ); + SelectDest dest = new SelectDest(); + + /* Construct the SELECT statement that will find the new values for + ** all updated rows. + */ + pEList = sqlite3ExprListAppend( pParse, 0, sqlite3Expr( db, TK_ID, "_rowid_" ) ); + if ( pRowid != null) + { + pEList = sqlite3ExprListAppend( pParse, pEList, + sqlite3ExprDup( db, pRowid, 0 ) ); + } + Debug.Assert( pTab.iPKey < 0 ); + for ( i = 0; i < pTab.nCol; i++ ) + { + if ( aXRef[i] >= 0 ) + { + pExpr = sqlite3ExprDup( db, pChanges.a[aXRef[i]].pExpr, 0 ); + } + else + { + pExpr = sqlite3Expr( db, TK_ID, pTab.aCol[i].zName ); + } + pEList = sqlite3ExprListAppend( pParse, pEList, pExpr ); + } + pSelect = sqlite3SelectNew( pParse, pEList, pSrc, pWhere, null, null, null, 0, null, null ); - /* Create the ephemeral table into which the update results will - ** be stored. - */ - Debug.Assert(v != null); - ephemTab = pParse.nTab++; - sqlite3VdbeAddOp2(v, OP_OpenEphemeral, ephemTab, pTab.nCol + 1 + ((pRowid != null) ? 1 : 0)); - sqlite3VdbeChangeP5(v, BTREE_UNORDERED); + /* Create the ephemeral table into which the update results will + ** be stored. + */ + Debug.Assert( v != null); + ephemTab = pParse.nTab++; + sqlite3VdbeAddOp2( v, OP_OpenEphemeral, ephemTab, pTab.nCol + 1 + ( ( pRowid != null ) ? 1 : 0 ) ); + sqlite3VdbeChangeP5( v, BTREE_UNORDERED ); - /* fill the ephemeral table - */ - sqlite3SelectDestInit(dest, SRT_Table, ephemTab); - sqlite3Select(pParse, pSelect, ref dest); - - /* Generate code to scan the ephemeral table and call VUpdate. */ - iReg = ++pParse.nMem; - pParse.nMem += pTab.nCol + 1; - addr = sqlite3VdbeAddOp2(v, OP_Rewind, ephemTab, 0); - sqlite3VdbeAddOp3(v, OP_Column, ephemTab, 0, iReg); - sqlite3VdbeAddOp3(v, OP_Column, ephemTab, (pRowid != null ? 1 : 0), iReg + 1); - for (i = 0; i < pTab.nCol; i++) { - sqlite3VdbeAddOp3(v, OP_Column, ephemTab, i + 1 + ((pRowid != null) ? 1 : 0), iReg + 2 + i); - } - sqlite3VtabMakeWritable(pParse, pTab); - sqlite3VdbeAddOp4(v, OP_VUpdate, 0, pTab.nCol + 2, iReg, pVTab, P4_VTAB); - sqlite3VdbeChangeP5(v, (byte)(onError == OE_Default ? OE_Abort : onError)); - sqlite3MayAbort(pParse); - sqlite3VdbeAddOp2(v, OP_Next, ephemTab, addr + 1); - sqlite3VdbeJumpHere(v, addr); - sqlite3VdbeAddOp2(v, OP_Close, ephemTab, 0); - - /* Cleanup */ - sqlite3SelectDelete(db, ref pSelect); - } -#endif // * SQLITE_OMIT_VIRTUALTABLE */ + /* fill the ephemeral table + */ + sqlite3SelectDestInit( dest, SRT_Table, ephemTab ); + sqlite3Select( pParse, pSelect, ref dest ); + + /* Generate code to scan the ephemeral table and call VUpdate. */ + iReg = ++pParse.nMem; + pParse.nMem += pTab.nCol + 1; + addr = sqlite3VdbeAddOp2( v, OP_Rewind, ephemTab, 0 ); + sqlite3VdbeAddOp3( v, OP_Column, ephemTab, 0, iReg ); + sqlite3VdbeAddOp3( v, OP_Column, ephemTab, ( pRowid != null ? 1 : 0 ), iReg + 1 ); + for ( i = 0; i < pTab.nCol; i++ ) + { + sqlite3VdbeAddOp3( v, OP_Column, ephemTab, i + 1 + ( ( pRowid != null ) ? 1 : 0 ), iReg + 2 + i ); + } + sqlite3VtabMakeWritable( pParse, pTab ); + sqlite3VdbeAddOp4( v, OP_VUpdate, 0, pTab.nCol + 2, iReg, pVTab, P4_VTAB ); + sqlite3VdbeChangeP5( v, (byte)( onError == OE_Default ? OE_Abort : onError ) ); + sqlite3MayAbort( pParse ); + sqlite3VdbeAddOp2( v, OP_Next, ephemTab, addr + 1 ); + sqlite3VdbeJumpHere( v, addr ); + sqlite3VdbeAddOp2( v, OP_Close, ephemTab, 0 ); + + /* Cleanup */ + sqlite3SelectDelete( db, ref pSelect ); } +#endif // * SQLITE_OMIT_VIRTUALTABLE */ + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/utf_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/utf_c.cs index 9d15afc5a..0d18555a4 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/utf_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/utf_c.cs @@ -1,68 +1,71 @@ using System; - +using System.Diagnostics; +using System.Text; using u32 = System.UInt32; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2004 April 13 - ** - ** 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 contains routines used to translate between UTF-8, - ** UTF-16, UTF-16BE, and UTF-16LE. - ** - ** Notes on UTF-8: - ** - ** Byte-0 Byte-1 Byte-2 Byte-3 Value - ** 0xxxxxxx 00000000 00000000 0xxxxxxx - ** 110yyyyy 10xxxxxx 00000000 00000yyy yyxxxxxx - ** 1110zzzz 10yyyyyy 10xxxxxx 00000000 zzzzyyyy yyxxxxxx - ** 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx 000uuuuu zzzzyyyy yyxxxxxx - ** - ** - ** Notes on UTF-16: (with wwww+1==uuuuu) - ** - ** Word-0 Word-1 Value - ** 110110ww wwzzzzyy 110111yy yyxxxxxx 000uuuuu zzzzyyyy yyxxxxxx - ** zzzzyyyy yyxxxxxx 00000000 zzzzyyyy yyxxxxxx - ** - ** - ** BOM or Byte Order Mark: - ** 0xff 0xfe little-endian utf-16 follows - ** 0xfe 0xff big-endian utf-16 follows - ** - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include - //#include "vdbeInt.h" +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 2004 April 13 + ** + ** 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 contains routines used to translate between UTF-8, + ** UTF-16, UTF-16BE, and UTF-16LE. + ** + ** Notes on UTF-8: + ** + ** Byte-0 Byte-1 Byte-2 Byte-3 Value + ** 0xxxxxxx 00000000 00000000 0xxxxxxx + ** 110yyyyy 10xxxxxx 00000000 00000yyy yyxxxxxx + ** 1110zzzz 10yyyyyy 10xxxxxx 00000000 zzzzyyyy yyxxxxxx + ** 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx 000uuuuu zzzzyyyy yyxxxxxx + ** + ** + ** Notes on UTF-16: (with wwww+1==uuuuu) + ** + ** Word-0 Word-1 Value + ** 110110ww wwzzzzyy 110111yy yyxxxxxx 000uuuuu zzzzyyyy yyxxxxxx + ** zzzzyyyy yyxxxxxx 00000000 zzzzyyyy yyxxxxxx + ** + ** + ** BOM or Byte Order Mark: + ** 0xff 0xfe little-endian utf-16 follows + ** 0xfe 0xff big-endian utf-16 follows + ** + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include + //#include "vdbeInt.h" #if !SQLITE_AMALGAMATION - /* - ** The following constant value is used by the SQLITE_BIGENDIAN and - ** SQLITE_LITTLEENDIAN macros. - */ - //const int sqlite3one = 1; + /* +** The following constant value is used by the SQLITE_BIGENDIAN and +** SQLITE_LITTLEENDIAN macros. +*/ + //const int sqlite3one = 1; #endif //* SQLITE_AMALGAMATION */ - /* - ** This lookup table is used to help decode the first byte of - ** a multi-byte UTF8 character. - */ - static byte[] sqlite3Utf8Trans1 = new byte[] { + /* +** This lookup table is used to help decode the first byte of +** a multi-byte UTF8 character. +*/ + static byte[] sqlite3Utf8Trans1 = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, @@ -74,159 +77,163 @@ public partial class Sqlite3 { }; - //#define WRITE_UTF8(zOut, c) { \ - // if( c<0x00080 ){ \ - // *zOut++ = (u8)(c&0xFF); \ - // } \ - // else if( c<0x00800 ){ \ - // *zOut++ = 0xC0 + (u8)((c>>6)&0x1F); \ - // *zOut++ = 0x80 + (u8)(c & 0x3F); \ - // } \ - // else if( c<0x10000 ){ \ - // *zOut++ = 0xE0 + (u8)((c>>12)&0x0F); \ - // *zOut++ = 0x80 + (u8)((c>>6) & 0x3F); \ - // *zOut++ = 0x80 + (u8)(c & 0x3F); \ - // }else{ \ - // *zOut++ = 0xF0 + (u8)((c>>18) & 0x07); \ - // *zOut++ = 0x80 + (u8)((c>>12) & 0x3F); \ - // *zOut++ = 0x80 + (u8)((c>>6) & 0x3F); \ - // *zOut++ = 0x80 + (u8)(c & 0x3F); \ - // } \ - //} - - //#define WRITE_UTF16LE(zOut, c) { \ - // if( c<=0xFFFF ){ \ - // *zOut++ = (u8)(c&0x00FF); \ - // *zOut++ = (u8)((c>>8)&0x00FF); \ - // }else{ \ - // *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0)); \ - // *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03)); \ - // *zOut++ = (u8)(c&0x00FF); \ - // *zOut++ = (u8)(0x00DC + ((c>>8)&0x03)); \ - // } \ - //} - - //#define WRITE_UTF16BE(zOut, c) { \ - // if( c<=0xFFFF ){ \ - // *zOut++ = (u8)((c>>8)&0x00FF); \ - // *zOut++ = (u8)(c&0x00FF); \ - // }else{ \ - // *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03)); \ - // *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0)); \ - // *zOut++ = (u8)(0x00DC + ((c>>8)&0x03)); \ - // *zOut++ = (u8)(c&0x00FF); \ - // } \ - //} - - //#define READ_UTF16LE(zIn, TERM, c){ \ - // c = (*zIn++); \ - // c += ((*zIn++)<<8); \ - // if( c>=0xD800 && c<0xE000 && TERM ){ \ - // int c2 = (*zIn++); \ - // c2 += ((*zIn++)<<8); \ - // c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \ - // } \ - //} - - //#define READ_UTF16BE(zIn, TERM, c){ \ - // c = ((*zIn++)<<8); \ - // c += (*zIn++); \ - // if( c>=0xD800 && c<0xE000 && TERM ){ \ - // int c2 = ((*zIn++)<<8); \ - // c2 += (*zIn++); \ - // c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \ - // } \ - //} - - /* - ** Translate a single UTF-8 character. Return the unicode value. - ** - ** During translation, assume that the byte that zTerm points - ** is a 0x00. - ** - ** Write a pointer to the next unread byte back into pzNext. - ** - ** Notes On Invalid UTF-8: - ** - ** * This routine never allows a 7-bit character (0x00 through 0x7f) to - ** be encoded as a multi-byte character. Any multi-byte character that - ** attempts to encode a value between 0x00 and 0x7f is rendered as 0xfffd. - ** - ** * This routine never allows a UTF16 surrogate value to be encoded. - ** If a multi-byte character attempts to encode a value between - ** 0xd800 and 0xe000 then it is rendered as 0xfffd. - ** - ** * Bytes in the range of 0x80 through 0xbf which occur as the first - ** byte of a character are interpreted as single-byte characters - ** and rendered as themselves even though they are technically - ** invalid characters. - ** - ** * This routine accepts an infinite number of different UTF8 encodings - ** for unicode values 0x80 and greater. It do not change over-length - ** encodings to 0xfffd as some systems recommend. - */ - //#define READ_UTF8(zIn, zTerm, c) \ - // c = *(zIn++); \ - // if( c>=0xc0 ){ \ - // c = sqlite3Utf8Trans1[c-0xc0]; \ - // while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){ \ - // c = (c<<6) + (0x3f & *(zIn++)); \ - // } \ - // if( c<0x80 \ - // || (c&0xFFFFF800)==0xD800 \ - // || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \ - // } - static u32 sqlite3Utf8Read( - string zIn, /* First byte of UTF-8 character */ - ref string pzNext /* Write first byte past UTF-8 char here */ - ) { - //unsigned int c; - /* Same as READ_UTF8() above but without the zTerm parameter. - ** For this routine, we assume the UTF8 string is always zero-terminated. - */ - if (String.IsNullOrEmpty(zIn)) - return 0; - //c = *( zIn++ ); - //if ( c >= 0xc0 ) - //{ - // c = sqlite3Utf8Trans1[c - 0xc0]; - // while ( ( *zIn & 0xc0 ) == 0x80 ) - // { - // c = ( c << 6 ) + ( 0x3f & *( zIn++ ) ); - // } - // if ( c < 0x80 - // || ( c & 0xFFFFF800 ) == 0xD800 - // || ( c & 0xFFFFFFFE ) == 0xFFFE ) { c = 0xFFFD; } - //} - //*pzNext = zIn; - int zIndex = 0; - u32 c = zIn[zIndex++]; - if (c >= 0xc0) { - //if ( c > 0xff ) c = 0; - //else - { - //c = sqlite3Utf8Trans1[c - 0xc0]; - while (zIndex != zIn.Length && (zIn[zIndex] & 0xc0) == 0x80) { - c = (u32)((c << 6) + (0x3f & zIn[zIndex++])); - } - if (c < 0x80 - || (c & 0xFFFFF800) == 0xD800 - || (c & 0xFFFFFFFE) == 0xFFFE) { - c = 0xFFFD; - } - } - } - pzNext = zIn.Substring(zIndex); - return c; + //#define WRITE_UTF8(zOut, c) { \ + // if( c<0x00080 ){ \ + // *zOut++ = (u8)(c&0xFF); \ + // } \ + // else if( c<0x00800 ){ \ + // *zOut++ = 0xC0 + (u8)((c>>6)&0x1F); \ + // *zOut++ = 0x80 + (u8)(c & 0x3F); \ + // } \ + // else if( c<0x10000 ){ \ + // *zOut++ = 0xE0 + (u8)((c>>12)&0x0F); \ + // *zOut++ = 0x80 + (u8)((c>>6) & 0x3F); \ + // *zOut++ = 0x80 + (u8)(c & 0x3F); \ + // }else{ \ + // *zOut++ = 0xF0 + (u8)((c>>18) & 0x07); \ + // *zOut++ = 0x80 + (u8)((c>>12) & 0x3F); \ + // *zOut++ = 0x80 + (u8)((c>>6) & 0x3F); \ + // *zOut++ = 0x80 + (u8)(c & 0x3F); \ + // } \ + //} + + //#define WRITE_UTF16LE(zOut, c) { \ + // if( c<=0xFFFF ){ \ + // *zOut++ = (u8)(c&0x00FF); \ + // *zOut++ = (u8)((c>>8)&0x00FF); \ + // }else{ \ + // *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0)); \ + // *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03)); \ + // *zOut++ = (u8)(c&0x00FF); \ + // *zOut++ = (u8)(0x00DC + ((c>>8)&0x03)); \ + // } \ + //} + + //#define WRITE_UTF16BE(zOut, c) { \ + // if( c<=0xFFFF ){ \ + // *zOut++ = (u8)((c>>8)&0x00FF); \ + // *zOut++ = (u8)(c&0x00FF); \ + // }else{ \ + // *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03)); \ + // *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0)); \ + // *zOut++ = (u8)(0x00DC + ((c>>8)&0x03)); \ + // *zOut++ = (u8)(c&0x00FF); \ + // } \ + //} + + //#define READ_UTF16LE(zIn, TERM, c){ \ + // c = (*zIn++); \ + // c += ((*zIn++)<<8); \ + // if( c>=0xD800 && c<0xE000 && TERM ){ \ + // int c2 = (*zIn++); \ + // c2 += ((*zIn++)<<8); \ + // c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \ + // } \ + //} + + //#define READ_UTF16BE(zIn, TERM, c){ \ + // c = ((*zIn++)<<8); \ + // c += (*zIn++); \ + // if( c>=0xD800 && c<0xE000 && TERM ){ \ + // int c2 = ((*zIn++)<<8); \ + // c2 += (*zIn++); \ + // c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \ + // } \ + //} + + /* + ** Translate a single UTF-8 character. Return the unicode value. + ** + ** During translation, assume that the byte that zTerm points + ** is a 0x00. + ** + ** Write a pointer to the next unread byte back into pzNext. + ** + ** Notes On Invalid UTF-8: + ** + ** * This routine never allows a 7-bit character (0x00 through 0x7f) to + ** be encoded as a multi-byte character. Any multi-byte character that + ** attempts to encode a value between 0x00 and 0x7f is rendered as 0xfffd. + ** + ** * This routine never allows a UTF16 surrogate value to be encoded. + ** If a multi-byte character attempts to encode a value between + ** 0xd800 and 0xe000 then it is rendered as 0xfffd. + ** + ** * Bytes in the range of 0x80 through 0xbf which occur as the first + ** byte of a character are interpreted as single-byte characters + ** and rendered as themselves even though they are technically + ** invalid characters. + ** + ** * This routine accepts an infinite number of different UTF8 encodings + ** for unicode values 0x80 and greater. It do not change over-length + ** encodings to 0xfffd as some systems recommend. + */ + //#define READ_UTF8(zIn, zTerm, c) \ + // c = *(zIn++); \ + // if( c>=0xc0 ){ \ + // c = sqlite3Utf8Trans1[c-0xc0]; \ + // while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){ \ + // c = (c<<6) + (0x3f & *(zIn++)); \ + // } \ + // if( c<0x80 \ + // || (c&0xFFFFF800)==0xD800 \ + // || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \ + // } + static u32 sqlite3Utf8Read( + string zIn, /* First byte of UTF-8 character */ + ref string pzNext /* Write first byte past UTF-8 char here */ + ) + { + //unsigned int c; + /* Same as READ_UTF8() above but without the zTerm parameter. + ** For this routine, we assume the UTF8 string is always zero-terminated. + */ + if ( String.IsNullOrEmpty( zIn ) ) + return 0; + //c = *( zIn++ ); + //if ( c >= 0xc0 ) + //{ + // c = sqlite3Utf8Trans1[c - 0xc0]; + // while ( ( *zIn & 0xc0 ) == 0x80 ) + // { + // c = ( c << 6 ) + ( 0x3f & *( zIn++ ) ); + // } + // if ( c < 0x80 + // || ( c & 0xFFFFF800 ) == 0xD800 + // || ( c & 0xFFFFFFFE ) == 0xFFFE ) { c = 0xFFFD; } + //} + //*pzNext = zIn; + int zIndex = 0; + u32 c = zIn[zIndex++]; + if ( c >= 0xc0 ) + { + //if ( c > 0xff ) c = 0; + //else + { + //c = sqlite3Utf8Trans1[c - 0xc0]; + while ( zIndex != zIn.Length && ( zIn[zIndex] & 0xc0 ) == 0x80 ) + { + c = (u32)( ( c << 6 ) + ( 0x3f & zIn[zIndex++] ) ); + } + if ( c < 0x80 + || ( c & 0xFFFFF800 ) == 0xD800 + || ( c & 0xFFFFFFFE ) == 0xFFFE ) + { + c = 0xFFFD; + } } + } + pzNext = zIn.Substring( zIndex ); + return c; + } - /* - ** If the TRANSLATE_TRACE macro is defined, the value of each Mem is - ** printed on stderr on the way into and out of sqlite3VdbeMemTranslate(). - */ - /* #define TRANSLATE_TRACE 1 */ + /* + ** If the TRANSLATE_TRACE macro is defined, the value of each Mem is + ** printed on stderr on the way into and out of sqlite3VdbeMemTranslate(). + */ + /* #define TRANSLATE_TRACE 1 */ #if !SQLITE_OMIT_UTF16 @@ -415,36 +422,37 @@ static int sqlite3VdbeMemHandleBom(Mem pMem){ } #endif // * SQLITE_OMIT_UTF16 */ - /* - ** pZ is a UTF-8 encoded unicode string. If nByte is less than zero, - ** return the number of unicode characters in pZ up to (but not including) - ** the first 0x00 byte. If nByte is not less than zero, return the - ** number of unicode characters in the first nByte of pZ (or up to - ** the first 0x00, whichever comes first). - */ - static int sqlite3Utf8CharLen(string zIn, int nByte) { - //int r = 0; - //string z = zIn; - if (zIn.Length == 0) - return 0; - int zInLength = zIn.Length; - int zTerm = (nByte >= 0 && nByte <= zInLength) ? nByte : zInLength; - //Debug.Assert( z<=zTerm ); - //for ( int i = 0 ; i < zTerm ; i++ ) //while( *z!=0 && z= 0 && nByte <= zInLength ) ? nByte : zInLength; + //Debug.Assert( z<=zTerm ); + //for ( int i = 0 ; i < zTerm ; i++ ) //while( *z!=0 && z + +namespace Community.CsharpSqlite +{ + using sqlite_int64 = System.Int64; + using System.Globalization; + + public partial class Sqlite3 + { + /* + ** 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. + ** + ************************************************************************* + ** Utility functions used throughout sqlite. + ** + ** This file contains functions for allocating memory, comparing + ** strings, and stuff like that. + ** + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include #if SQLITE_HAVE_ISNAN //# include #endif - /* - ** Routine needed to support the testcase() macro. - */ + /* +** Routine needed to support the testcase() macro. +*/ #if SQLITE_COVERAGE_TEST void sqlite3Coverage(int x){ static uint dummy = 0; @@ -54,1108 +60,1264 @@ void sqlite3Coverage(int x){ #endif #if !SQLITE_OMIT_FLOATING_POINT - /* - ** Return true if the floating point value is Not a Number (NaN). - ** - ** Use the math library isnan() function if compiled with SQLITE_HAVE_ISNAN. - ** Otherwise, we have our own implementation that works on most systems. - */ - static bool sqlite3IsNaN(double x) { - bool rc; /* The value return */ + /* +** Return true if the floating point value is Not a Number (NaN). +** +** Use the math library isnan() function if compiled with SQLITE_HAVE_ISNAN. +** Otherwise, we have our own implementation that works on most systems. +*/ + static bool sqlite3IsNaN( double x ) + { + bool rc; /* The value return */ #if !(SQLITE_HAVE_ISNAN) - /* - ** Systems that support the isnan() library function should probably - ** make use of it by compiling with -DSQLITE_HAVE_ISNAN. But we have - ** found that many systems do not have a working isnan() function so - ** this implementation is provided as an alternative. - ** - ** This NaN test sometimes fails if compiled on GCC with -ffast-math. - ** On the other hand, the use of -ffast-math comes with the following - ** warning: - ** - ** This option [-ffast-math] should never be turned on by any - ** -O option since it can result in incorrect output for programs - ** which depend on an exact implementation of IEEE or ISO - ** rules/specifications for math functions. - ** - ** Under MSVC, this NaN test may fail if compiled with a floating- - ** point precision mode other than /fp:precise. From the MSDN - ** documentation: - ** - ** The compiler [with /fp:precise] will properly handle comparisons - ** involving NaN. For example, x != x evaluates to true if x is NaN - ** ... - */ + /* +** Systems that support the isnan() library function should probably +** make use of it by compiling with -DSQLITE_HAVE_ISNAN. But we have +** found that many systems do not have a working isnan() function so +** this implementation is provided as an alternative. +** +** This NaN test sometimes fails if compiled on GCC with -ffast-math. +** On the other hand, the use of -ffast-math comes with the following +** warning: +** +** This option [-ffast-math] should never be turned on by any +** -O option since it can result in incorrect output for programs +** which depend on an exact implementation of IEEE or ISO +** rules/specifications for math functions. +** +** Under MSVC, this NaN test may fail if compiled with a floating- +** point precision mode other than /fp:precise. From the MSDN +** documentation: +** +** The compiler [with /fp:precise] will properly handle comparisons +** involving NaN. For example, x != x evaluates to true if x is NaN +** ... +*/ #if __FAST_MATH__ -#error SQLite will not work correctly with the -ffast-math option of GCC. +# error SQLite will not work correctly with the -ffast-math option of GCC. #endif - double y = x; - double z = y; - rc = (y != z); + double y = x; + double z = y; + rc = ( y != z ); #else //* if defined(SQLITE_HAVE_ISNAN) */ rc = isnan(x); #endif //* SQLITE_HAVE_ISNAN */ - testcase(rc); - return rc; - } + testcase( rc ); + return rc; + } #endif //* SQLITE_OMIT_FLOATING_POINT */ - /* - ** Compute a string length that is limited to what can be stored in - ** lower 30 bits of a 32-bit signed integer. - ** - ** The value returned will never be negative. Nor will it ever be greater - ** than the actual length of the string. For very long strings (greater - ** than 1GiB) the value returned might be less than the true string length. - */ - static int sqlite3Strlen30(int z) { - return 0x3fffffff & z; - } - static int sqlite3Strlen30(StringBuilder z) { - //string z2 = z; - if (z == null) - return 0; - //while( *z2 ){ z2++; } - //return 0x3fffffff & (int)(z2 - z); - int iLen = z.ToString().IndexOf('\0'); - return 0x3fffffff & (iLen == -1 ? z.Length : iLen); - } - static int sqlite3Strlen30(string z) { - //string z2 = z; - if (z == null) - return 0; - //while( *z2 ){ z2++; } - //return 0x3fffffff & (int)(z2 - z); - int iLen = z.IndexOf('\0'); - return 0x3fffffff & (iLen == -1 ? z.Length : iLen); - } + /* +** Compute a string length that is limited to what can be stored in +** lower 30 bits of a 32-bit signed integer. +** +** The value returned will never be negative. Nor will it ever be greater +** than the actual length of the string. For very long strings (greater +** than 1GiB) the value returned might be less than the true string length. +*/ + static int sqlite3Strlen30( int z ) + { + return 0x3fffffff & z; + } + static int sqlite3Strlen30( StringBuilder z ) + { + //string z2 = z; + if ( z == null ) + return 0; + //while( *z2 ){ z2++; } + //return 0x3fffffff & (int)(z2 - z); + int iLen = z.ToString().IndexOf( '\0' ); + return 0x3fffffff & ( iLen == -1 ? z.Length : iLen ); + } + static int sqlite3Strlen30( string z ) + { + //string z2 = z; + if ( z == null ) + return 0; + //while( *z2 ){ z2++; } + //return 0x3fffffff & (int)(z2 - z); + int iLen = z.IndexOf( '\0' ); + return 0x3fffffff & (iLen == -1 ? z.Length : iLen); + } - /* - ** Set the most recent error code and error string for the sqlite - ** handle "db". The error code is set to "err_code". - ** - ** If it is not NULL, string zFormat specifies the format of the - ** error string in the style of the printf functions: The following - ** format characters are allowed: - ** - ** %s Insert a string - ** %z A string that should be freed after use - ** %d Insert an integer - ** %T Insert a token - ** %S Insert the first element of a SrcList - ** - ** zFormat and any string tokens that follow it are assumed to be - ** encoded in UTF-8. - ** - ** To clear the most recent error for sqlite handle "db", sqlite3Error - ** should be called with err_code set to SQLITE_OK and zFormat set - ** to NULL. - */ - //Overloads - static void sqlite3Error(sqlite3 db, int err_code, int noString) { - sqlite3Error(db, err_code, err_code == 0 ? null : ""); - } + /* + ** Set the most recent error code and error string for the sqlite + ** handle "db". The error code is set to "err_code". + ** + ** If it is not NULL, string zFormat specifies the format of the + ** error string in the style of the printf functions: The following + ** format characters are allowed: + ** + ** %s Insert a string + ** %z A string that should be freed after use + ** %d Insert an integer + ** %T Insert a token + ** %S Insert the first element of a SrcList + ** + ** zFormat and any string tokens that follow it are assumed to be + ** encoded in UTF-8. + ** + ** To clear the most recent error for sqlite handle "db", sqlite3Error + ** should be called with err_code set to SQLITE_OK and zFormat set + ** to NULL. + */ + //Overloads + static void sqlite3Error( sqlite3 db, int err_code, int noString ) + { + sqlite3Error( db, err_code, err_code == 0 ? null : "" ); + } - static void sqlite3Error(sqlite3 db, int err_code, string zFormat, params object[] ap) { - if (db != null && (db.pErr != null || (db.pErr = sqlite3ValueNew(db)) != null)) { - db.errCode = err_code; - if (zFormat != null) { - lock (lock_va_list) { - string z; - va_start(ap, zFormat); - z = sqlite3VMPrintf(db, zFormat, ap); - va_end(ref ap); - sqlite3ValueSetStr(db.pErr, -1, z, SQLITE_UTF8, (dxDel)SQLITE_DYNAMIC); - } - } else { - sqlite3ValueSetStr(db.pErr, 0, null, SQLITE_UTF8, SQLITE_STATIC); - } - } + static void sqlite3Error( sqlite3 db, int err_code, string zFormat, params object[] ap ) + { + if ( db != null && ( db.pErr != null || ( db.pErr = sqlite3ValueNew( db ) ) != null ) ) + { + db.errCode = err_code; + if ( zFormat != null ) + { + lock ( lock_va_list ) + { + string z; + va_start( ap, zFormat ); + z = sqlite3VMPrintf( db, zFormat, ap ); + va_end( ref ap ); + sqlite3ValueSetStr( db.pErr, -1, z, SQLITE_UTF8, (dxDel)SQLITE_DYNAMIC ); + } } - - /* - ** Add an error message to pParse.zErrMsg and increment pParse.nErr. - ** The following formatting characters are allowed: - ** - ** %s Insert a string - ** %z A string that should be freed after use - ** %d Insert an integer - ** %T Insert a token - ** %S Insert the first element of a SrcList - ** - ** This function should be used to report any error that occurs whilst - ** compiling an SQL statement (i.e. within sqlite3_prepare()). The - ** last thing the sqlite3_prepare() function does is copy the error - ** stored by this function into the database handle using sqlite3Error(). - ** Function sqlite3Error() should be used during statement execution - ** (sqlite3_step() etc.). - */ - static void sqlite3ErrorMsg(Parse pParse, string zFormat, params object[] ap) { - string zMsg; - sqlite3 db = pParse.db; - //va_list ap; - lock (lock_va_list) { - va_start(ap, zFormat); - zMsg = sqlite3VMPrintf(db, zFormat, ap); - va_end(ref ap); - } - if (db.suppressErr != 0) { - sqlite3DbFree(db, ref zMsg); - } else { - pParse.nErr++; - sqlite3DbFree(db, ref pParse.zErrMsg); - pParse.zErrMsg = zMsg; - pParse.rc = SQLITE_ERROR; - } + else + { + sqlite3ValueSetStr( db.pErr, 0, null, SQLITE_UTF8, SQLITE_STATIC ); } + } + } - /* - ** Convert an SQL-style quoted string into a normal string by removing - ** the quote characters. The conversion is done in-place. If the - ** input does not begin with a quote character, then this routine - ** is a no-op. - ** - ** The input string must be zero-terminated. A new zero-terminator - ** is added to the dequoted string. - ** - ** The return value is -1 if no dequoting occurs or the length of the - ** dequoted string, exclusive of the zero terminator, if dequoting does - ** occur. - ** - ** 2002-Feb-14: This routine is extended to remove MS-Access style - ** brackets from around identifers. For example: "[a-b-c]" becomes - ** "a-b-c". - */ - static int sqlite3Dequote(ref string z) { - char quote; - int i; - if (z == null || z == "") - return -1; - quote = z[0]; - switch (quote) { - case '\'': - break; - case '"': - break; - case '`': - break; /* For MySQL compatibility */ - case '[': - quote = ']'; - break; /* For MS SqlServer compatibility */ - default: - return -1; - } - StringBuilder sbZ = new StringBuilder(z.Length); - for (i = 1; i < z.Length; i++) //z[i] != 0; i++) - { - if (z[i] == quote) { - if (i < z.Length - 1 && (z[i + 1] == quote)) { - sbZ.Append(quote); - i++; - } else { - break; - } - } else { - sbZ.Append(z[i]); - } - } - z = sbZ.ToString(); - return sbZ.Length; - } + /* + ** Add an error message to pParse.zErrMsg and increment pParse.nErr. + ** The following formatting characters are allowed: + ** + ** %s Insert a string + ** %z A string that should be freed after use + ** %d Insert an integer + ** %T Insert a token + ** %S Insert the first element of a SrcList + ** + ** This function should be used to report any error that occurs whilst + ** compiling an SQL statement (i.e. within sqlite3_prepare()). The + ** last thing the sqlite3_prepare() function does is copy the error + ** stored by this function into the database handle using sqlite3Error(). + ** Function sqlite3Error() should be used during statement execution + ** (sqlite3_step() etc.). + */ + static void sqlite3ErrorMsg( Parse pParse, string zFormat, params object[] ap ) + { + string zMsg; + sqlite3 db = pParse.db; + //va_list ap; + lock ( lock_va_list ) + { + va_start( ap, zFormat ); + zMsg = sqlite3VMPrintf( db, zFormat, ap ); + va_end( ref ap ); + } + if ( db.suppressErr != 0 ) + { + sqlite3DbFree( db, ref zMsg ); + } + else + { + pParse.nErr++; + sqlite3DbFree( db, ref pParse.zErrMsg ); + pParse.zErrMsg = zMsg; + pParse.rc = SQLITE_ERROR; + } + } - /* Convenient short-hand */ - //#define UpperToLower sqlite3UpperToLower - - /* - ** Some systems have stricmp(). Others have strcasecmp(). Because - ** there is no consistency, we will define our own. - ** - ** IMPLEMENTATION-OF: R-20522-24639 The sqlite3_strnicmp() API allows - ** applications and extensions to compare the contents of two buffers - ** containing UTF-8 strings in a case-independent fashion, using the same - ** definition of case independence that SQLite uses internally when - ** comparing identifiers. - */ - - static int sqlite3StrNICmp(string zLeft, int offsetLeft, string zRight, int N) { - //register unsigned char *a, *b; - //a = (unsigned char )zLeft; - //b = (unsigned char )zRight; - int a = 0, b = 0; - while (N-- > 0 && a < zLeft.Length - offsetLeft && b < zRight.Length && zLeft[a + offsetLeft] != 0 && UpperToLower[zLeft[a + offsetLeft]] == UpperToLower[zRight[b]]) { - a++; - b++; - } - return N < 0 ? 0 : ((a < zLeft.Length - offsetLeft) ? UpperToLower[zLeft[a + offsetLeft]] : 0) - UpperToLower[zRight[b]]; + /* + ** Convert an SQL-style quoted string into a normal string by removing + ** the quote characters. The conversion is done in-place. If the + ** input does not begin with a quote character, then this routine + ** is a no-op. + ** + ** The input string must be zero-terminated. A new zero-terminator + ** is added to the dequoted string. + ** + ** The return value is -1 if no dequoting occurs or the length of the + ** dequoted string, exclusive of the zero terminator, if dequoting does + ** occur. + ** + ** 2002-Feb-14: This routine is extended to remove MS-Access style + ** brackets from around identifers. For example: "[a-b-c]" becomes + ** "a-b-c". + */ + static int sqlite3Dequote( ref string z ) + { + char quote; + int i; + if ( z == null || z == "" ) + return -1; + quote = z[0]; + switch ( quote ) + { + case '\'': + break; + case '"': + break; + case '`': + break; /* For MySQL compatibility */ + case '[': + quote = ']'; + break; /* For MS SqlServer compatibility */ + default: + return -1; + } + StringBuilder sbZ = new StringBuilder( z.Length ); + for ( i = 1; i < z.Length; i++ ) //z[i] != 0; i++) + { + if ( z[i] == quote ) + { + if ( i < z.Length - 1 && ( z[i + 1] == quote ) ) + { + sbZ.Append( quote ); + i++; + } + else + { + break; + } } - - static int sqlite3StrNICmp(string zLeft, string zRight, int N) { - //register unsigned char *a, *b; - //a = (unsigned char )zLeft; - //b = (unsigned char )zRight; - int a = 0, b = 0; - while (N-- > 0 && a < zLeft.Length && b < zRight.Length && (zLeft[a] == zRight[b] || (zLeft[a] != 0 && zLeft[a] < 256 && zRight[b] < 256 && UpperToLower[zLeft[a]] == UpperToLower[zRight[b]]))) { - a++; - b++; - } - if (N < 0) - return 0; - if (a == zLeft.Length && b == zRight.Length) - return 0; - if (a == zLeft.Length) - return -UpperToLower[zRight[b]]; - if (b == zRight.Length) - return UpperToLower[zLeft[a]]; - return (zLeft[a] < 256 ? UpperToLower[zLeft[a]] : zLeft[a]) - (zRight[b] < 256 ? UpperToLower[zRight[b]] : zRight[b]); + else + { + sbZ.Append( z[i] ); } + } + z = sbZ.ToString(); + return sbZ.Length; + } + /* Convenient short-hand */ + //#define UpperToLower sqlite3UpperToLower - /* - ** The string z[] is an text representation of a real number. - ** Convert this string to a double and write it into *pResult. - ** - ** The string z[] is length bytes in length (bytes, not characters) and - ** uses the encoding enc. 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 bool sqlite3AtoF(string z, ref double pResult, int length, u8 enc) { -#if !SQLITE_OMIT_FLOATING_POINT - if (String.IsNullOrEmpty(z)) { - pResult = 0; - return false; - } - int incr = (enc == SQLITE_UTF8 ? 1 : 2); - //const char* zEnd = z + length; - - /* sign * significand * (10 ^ (esign * exponent)) */ - int sign = 1; /* sign of significand */ - i64 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 = 0; - int nDigits = 0; - - pResult = 0.0; /* Default return value, in case of an error */ - - int zDx = 0; - if (enc == SQLITE_UTF16BE) - zDx++; - - while (zDx < length && sqlite3Isspace(z[zDx])) - zDx++; - if (zDx >= length) - return false; - - /* get sign of significand */ - if (z[zDx] == '-') { - sign = -1; - zDx += incr; - } else if (z[zDx] == '+') { - zDx += incr; - } - /* skip leading zeroes */ - while (zDx < z.Length && z[zDx] == '0') { - zDx += incr; - nDigits++; - } - /* copy max significant digits to significand */ - while (zDx < length && sqlite3Isdigit(z[zDx]) && s < ((LARGEST_INT64 - 9) / 10)) { - s = s * 10 + (z[zDx] - '0'); - zDx += incr; - nDigits++; - } - /* skip non-significant significand digits - ** (increase exponent by d to shift decimal left) */ - while (zDx < length && sqlite3Isdigit(z[zDx])) { - zDx += incr; - nDigits++; - d++; - } - if (zDx >= length) - goto do_atof_calc; - - /* if decimal point is present */ - if (z[zDx] == '.') { - zDx += incr; - /* copy digits from after decimal to significand - ** (decrease exponent by d to shift decimal right) */ - while (zDx < length && sqlite3Isdigit(z[zDx]) && s < ((LARGEST_INT64 - 9) / 10)) { - s = s * 10 + (z[zDx] - '0'); - zDx += incr; - nDigits++; - d--; - } - - /* skip non-significant digits */ - while (zDx < length && sqlite3Isdigit(z[zDx])) { - zDx += incr; - nDigits++; - } - if (zDx >= length) - goto do_atof_calc; - } + /* + ** Some systems have stricmp(). Others have strcasecmp(). Because + ** there is no consistency, we will define our own. + ** + ** IMPLEMENTATION-OF: R-20522-24639 The sqlite3_strnicmp() API allows + ** applications and extensions to compare the contents of two buffers + ** containing UTF-8 strings in a case-independent fashion, using the same + ** definition of case independence that SQLite uses internally when + ** comparing identifiers. + */ - /* if exponent is present */ - if (z[zDx] == 'e' || z[zDx] == 'E') { - zDx += incr; - eValid = 0; - if (zDx >= length) - goto do_atof_calc; - - /* get sign of exponent */ - if (z[zDx] == '-') { - esign = -1; - zDx += incr; - } else if (z[zDx] == '+') { - zDx += incr; - } - - /* copy digits to exponent */ - while (zDx < length && sqlite3Isdigit(z[zDx])) { - e = e * 10 + (z[zDx] - '0'); - zDx += incr; - eValid = 1; - } - } + static int sqlite3StrNICmp( string zLeft, int offsetLeft, string zRight, int N ) + { + //register unsigned char *a, *b; + //a = (unsigned char )zLeft; + //b = (unsigned char )zRight; + int a = 0, b = 0; + while ( N-- > 0 && a < zLeft.Length - offsetLeft && b < zRight.Length && zLeft[a + offsetLeft] != 0 && UpperToLower[zLeft[a + offsetLeft]] == UpperToLower[zRight[b]] ) + { + a++; + b++; + } + return N < 0 ? 0 : ( ( a < zLeft.Length - offsetLeft ) ? UpperToLower[zLeft[a + offsetLeft]] : 0 ) - UpperToLower[zRight[b]]; + } - /* skip trailing spaces */ - if (nDigits > 0 && eValid > 0) { - while (zDx < length && sqlite3Isspace(z[zDx])) - zDx += incr; - } + static int sqlite3StrNICmp( string zLeft, string zRight, int N ) + { + //register unsigned char *a, *b; + //a = (unsigned char )zLeft; + //b = (unsigned char )zRight; + int a = 0, b = 0; + while ( N-- > 0 && a < zLeft.Length && b < zRight.Length && ( zLeft[a] == zRight[b] || ( zLeft[a] != 0 && zLeft[a] < 256 && zRight[b] < 256 && UpperToLower[zLeft[a]] == UpperToLower[zRight[b]] ) ) ) + { + a++; + b++; + } + if ( N < 0 ) + return 0; + if ( a == zLeft.Length && b == zRight.Length ) + return 0; + if ( a == zLeft.Length ) + return -UpperToLower[zRight[b]]; + if ( b == zRight.Length ) + return UpperToLower[zLeft[a]]; + return ( zLeft[a] < 256 ? UpperToLower[zLeft[a]] : zLeft[a] ) - ( zRight[b] < 256 ? UpperToLower[zRight[b]] : zRight[b] ); + } - do_atof_calc: - /* adjust exponent by d, and update sign */ - e = (e * esign) + d; - if (e < 0) { - esign = -1; - e *= -1; - } else { - esign = 1; - } + /* + ** The string z[] is an text representation of a real number. + ** Convert this string to a double and write it into *pResult. + ** + ** The string z[] is length bytes in length (bytes, not characters) and + ** uses the encoding enc. 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 bool sqlite3AtoF( string z, ref double pResult, int length, u8 enc ) + { +#if !SQLITE_OMIT_FLOATING_POINT + if ( String.IsNullOrEmpty( z ) ) + { + pResult = 0; + return false; + } + int incr = ( enc == SQLITE_UTF8 ? 1 : 2 ); + //const char* zEnd = z + length; + + /* sign * significand * (10 ^ (esign * exponent)) */ + int sign = 1; /* sign of significand */ + i64 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 = 0; + int nDigits = 0; + + pResult = 0.0; /* Default return value, in case of an error */ + + int zDx = 0; + if ( enc == SQLITE_UTF16BE ) + zDx++; + + while ( zDx < length && sqlite3Isspace( z[zDx] ) ) + zDx++; + if ( zDx >= length ) + return false; + + /* get sign of significand */ + if ( z[zDx] == '-' ) + { + sign = -1; + zDx += incr; + } + else if ( z[zDx] == '+' ) + { + zDx += incr; + } + /* skip leading zeroes */ + while ( zDx < z.Length && z[zDx] == '0' ) + { + zDx += incr; + nDigits++; + } + /* copy max significant digits to significand */ + while ( zDx < length && sqlite3Isdigit( z[zDx] ) && s < ( ( LARGEST_INT64 - 9 ) / 10 ) ) + { + s = s * 10 + ( z[zDx] - '0' ); + zDx += incr; + nDigits++; + } + /* skip non-significant significand digits + ** (increase exponent by d to shift decimal left) */ + while ( zDx < length && sqlite3Isdigit( z[zDx] ) ) + { + zDx += incr; + nDigits++; + d++; + } + if ( zDx >= length ) + goto do_atof_calc; + + /* if decimal point is present */ + if ( z[zDx] == '.' ) + { + zDx += incr; + /* copy digits from after decimal to significand + ** (decrease exponent by d to shift decimal right) */ + while ( zDx < length && sqlite3Isdigit( z[zDx] ) && s < ( ( LARGEST_INT64 - 9 ) / 10 ) ) + { + s = s * 10 + ( z[zDx] - '0' ); + zDx += incr; + nDigits++; + d--; + } - /* if 0 significand */ - if (0 == s) { - /* In the IEEE 754 standard, zero is signed. - ** Add the sign if we've seen at least one digit */ - result = (sign < 0 && nDigits != 0) ? -(double)0 : (double)0; - } else { - /* attempt to reduce exponent */ - if (esign > 0) { - while (s < (LARGEST_INT64 / 10) && e > 0) { - e--; - s *= 10; - } - } else { - while (0 == (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 != 0) { - double scale = 1.0; - /* attempt to handle extremely small/large numbers better */ - if (e > 307 && e < 342) { - while ((e % 308) != 0) { - 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 { - /* 1.0e+22 is the largest power of 10 than can be - ** represented exactly. */ - while ((e % 22) != 0) { - 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; + /* skip non-significant digits */ + while ( zDx < length && sqlite3Isdigit( z[zDx] ) ) + { + zDx += incr; + nDigits++; + } + if ( zDx >= length ) + goto do_atof_calc; + } + + /* if exponent is present */ + if ( z[zDx] == 'e' || z[zDx] == 'E' ) + { + zDx += incr; + eValid = 0; + if ( zDx >= length ) + goto do_atof_calc; + + /* get sign of exponent */ + if ( z[zDx] == '-' ) + { + esign = -1; + zDx += incr; + } + else if ( z[zDx] == '+' ) + { + zDx += incr; + } - /* return true if number and no extra non-whitespace chracters after */ - return zDx >= length && nDigits > 0 && eValid != 0; -#else -return !sqlite3Atoi64(z, pResult, length, enc); -#endif //* SQLITE_OMIT_FLOATING_POINT */ + /* copy digits to exponent */ + while ( zDx < length && sqlite3Isdigit( z[zDx] ) ) + { + e = e * 10 + ( z[zDx] - '0' ); + zDx += incr; + eValid = 1; + } + } + + /* skip trailing spaces */ + if ( nDigits > 0 && eValid > 0 ) + { + while ( zDx < length && sqlite3Isspace( z[zDx] ) ) + zDx += incr; + } + +do_atof_calc: + + /* adjust exponent by d, and update sign */ + e = ( e * esign ) + d; + if ( e < 0 ) + { + esign = -1; + e *= -1; + } + else + { + esign = 1; + } + + /* if 0 significand */ + if ( 0 == s ) + { + /* In the IEEE 754 standard, zero is signed. + ** Add the sign if we've seen at least one digit */ + result = ( sign < 0 && nDigits != 0 ) ? -(double)0 : (double)0; + } + else + { + /* attempt to reduce exponent */ + if ( esign > 0 ) + { + while ( s < ( LARGEST_INT64 / 10 ) && e > 0 ) + { + e--; + s *= 10; + } + } + else + { + while ( 0 == ( s % 10 ) && e > 0 ) + { + e--; + s /= 10; + } } - /* - ** 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, - ** - ** compare2pow63("9223372036854775800", 1) - ** - ** will return -8. - */ - static int compare2pow63(string zNum, int incr) { - int c = 0; - int i; - /* 012345678901234567 */ - string pow63 = "922337203685477580"; - for (i = 0; c == 0 && i < 18; i++) { - c = (zNum[i * incr] - pow63[i]) * 10; + /* adjust the sign of significand */ + s = sign < 0 ? -s : s; + + /* if exponent, scale significand as appropriate + ** and store in result. */ + if ( e != 0 ) + { + double scale = 1.0; + /* attempt to handle extremely small/large numbers better */ + if ( e > 307 && e < 342 ) + { + while ( ( e % 308 ) != 0 ) + { + scale *= 1.0e+1; + e -= 1; } - - if (c == 0) { - c = zNum[18 * incr] - '8'; - testcase(c == (-1)); - testcase(c == 0); - testcase(c == (+1)); + if ( esign < 0 ) + { + result = s / scale; + result /= 1.0e+308; } - 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 then return 1. - ** - ** length is the number of bytes in the string (bytes, not characters). - ** The string is not necessarily zero-terminated. The encoding is - ** given by enc. - */ - static int sqlite3Atoi64(string zNum, ref i64 pNum, int length, u8 enc) { - if (zNum == null) { - pNum = 0; - return 1; + else + { + result = s * scale; + result *= 1.0e+308; } - int incr = (enc == SQLITE_UTF8 ? 1 : 2); - u64 u = 0; - int neg = 0; /* assume positive */ - int i; - int c = 0; - int zDx = 0;// string zStart; - //string zEnd = zNum + length; - - if (enc == SQLITE_UTF16BE) - zDx++; - while (zDx < length && sqlite3Isspace(zNum[zDx])) - zDx += incr; - if (zDx < length) { - if (zNum[zDx] == '-') { - neg = 1; - zDx += incr; - } else if (zNum[zDx] == '+') { - zDx += incr; - } + } + else + { + /* 1.0e+22 is the largest power of 10 than can be + ** represented exactly. */ + while ( ( e % 22 ) != 0 ) + { + scale *= 1.0e+1; + e -= 1; } - //zStart = zNum; - if (length > zNum.Length) - length = zNum.Length; - while (zDx < length - 1 && zNum[zDx] == '0') { - zDx += incr; - } /* Skip leading zeros. */ - for (i = zDx; i < length && (c = zNum[i]) >= '0' && c <= '9'; i += incr) { - u = u * 10 + (u64)(c - '0'); + while ( e > 0 ) + { + scale *= 1.0e+22; + e -= 22; } - if (u > LARGEST_INT64) { - pNum = SMALLEST_INT64; - } else if (neg != 0) { - pNum = -(i64)u; - } else { - pNum = (i64)u; + if ( esign < 0 ) + { + result = s / scale; } - testcase(i - zDx == 18); - testcase(i - zDx == 19); - testcase(i - zDx == 20); - if ((c != 0 && i < length) || i == zDx || i - zDx > 19 * incr) { - /* 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 - zDx < 19 * incr) { - /* Less than 19 digits, so we know that it fits in 64 bits */ - Debug.Assert(u <= LARGEST_INT64); - return 0; - } else { - /* zNum is a 19-digit numbers. Compare it against 9223372036854775808. */ - c = compare2pow63(zNum.Substring(zDx), incr); - if (c < 0) { - /* zNum is less than 9223372036854775808 so it fits */ - Debug.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 */ - Debug.Assert(u - 1 == LARGEST_INT64); - Debug.Assert((pNum) == SMALLEST_INT64); - return neg != 0 ? 0 : 2; - } + else + { + result = s * scale; } + } } - - /* - ** If zNum represents an integer that will fit in 32-bits, then set - ** pValue to that integer and return true. Otherwise return false. - ** - ** Any non-numeric characters that following zNum are ignored. - ** This is different from sqlite3Atoi64() which requires the - ** input number to be zero-terminated. - */ - static bool sqlite3GetInt32(string zNum, ref int pValue) { - return sqlite3GetInt32(zNum, 0, ref pValue); + else + { + result = (double)s; } - static bool sqlite3GetInt32(string zNum, int iZnum, ref int pValue) { - sqlite_int64 v = 0; - int i, c; - int neg = 0; - if (zNum[iZnum] == '-') { - neg = 1; - iZnum++; - } else if (zNum[iZnum] == '+') { - iZnum++; - } - while (iZnum < zNum.Length && zNum[iZnum] == '0') - iZnum++; - for (i = 0; i < 11 && i + iZnum < zNum.Length && (c = zNum[iZnum + i] - '0') >= 0 && c <= 9; i++) { - v = v * 10 + c; - } + } + /* store the result */ + pResult = result; - /* The longest decimal representation of a 32 bit integer is 10 digits: - ** - ** 1234567890 - ** 2^31 . 2147483648 - */ - testcase(i == 10); - if (i > 10) { - return false; - } - testcase(v - neg == 2147483647); - if (v - neg > 2147483647) { - return false; - } - if (neg != 0) { - v = -v; - } - pValue = (int)v; - return true; - } + /* return true if number and no extra non-whitespace chracters after */ + return zDx >= length && nDigits > 0 && eValid != 0; +#else +return !sqlite3Atoi64(z, pResult, length, enc); +#endif //* SQLITE_OMIT_FLOATING_POINT */ + } - /* - ** Return a 32-bit integer value extracted from a string. If the - ** string is not an integer, just return 0. - */ - static int sqlite3Atoi(string z) { - int x = 0; - if (!String.IsNullOrEmpty(z)) - sqlite3GetInt32(z, ref x); - return x; - } + /* + ** 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, + ** + ** compare2pow63("9223372036854775800", 1) + ** + ** will return -8. + */ + static int compare2pow63( string zNum, int incr ) + { + int c = 0; + int i; + /* 012345678901234567 */ + string pow63 = "922337203685477580"; + for ( i = 0; c == 0 && i < 18; i++ ) + { + c = ( zNum[i * incr] - pow63[i] ) * 10; + } + + if ( c == 0 ) + { + c = zNum[18 * incr] - '8'; + testcase( c == ( -1 ) ); + testcase( c == 0 ); + testcase( c == ( +1 ) ); + } + return c; + } - /* - ** The variable-length integer encoding is as follows: - ** - ** KEY: - ** A = 0xxxxxxx 7 bits of data and one flag bit - ** B = 1xxxxxxx 7 bits of data and one flag bit - ** C = xxxxxxxx 8 bits of data - ** - ** 7 bits - A - ** 14 bits - BA - ** 21 bits - BBA - ** 28 bits - BBBA - ** 35 bits - BBBBA - ** 42 bits - BBBBBA - ** 49 bits - BBBBBBA - ** 56 bits - BBBBBBBA - ** 64 bits - BBBBBBBBC - */ - - /* - ** Write a 64-bit variable-length integer to memory starting at p[0]. - ** The length of data write will be between 1 and 9 bytes. The number - ** of bytes written is returned. - ** - ** A variable-length integer consists of the lower 7 bits of each byte - ** for all bytes that have the 8th bit set and one byte with the 8th - ** bit clear. Except, if we get to the 9th byte, it stores the full - ** 8 bits and is the last byte. - */ - static int getVarint(byte[] p, out u32 v) { - v = p[0]; - if (v <= 0x7F) - return 1; - u64 u64_v = 0; - int result = sqlite3GetVarint(p, 0, out u64_v); - v = (u32)u64_v; - return result; - } - static int getVarint(byte[] p, int offset, out u32 v) { - v = p[offset + 0]; - if (v <= 0x7F) - return 1; - u64 u64_v = 0; - int result = sqlite3GetVarint(p, offset, out u64_v); - v = (u32)u64_v; - return result; - } - static int getVarint(byte[] p, int offset, out int v) { - v = p[offset + 0]; - if (v <= 0x7F) - return 1; - u64 u64_v = 0; - int result = sqlite3GetVarint(p, offset, out u64_v); - v = (int)u64_v; - return result; - } - static int getVarint(byte[] p, int offset, out i64 v) { - v = offset >= p.Length ? 0 : (int)p[offset + 0]; - if (v <= 0x7F) - return 1; - if (offset + 1 >= p.Length) { - v = 65535; - return 2; - } else { - u64 u64_v = 0; - int result = sqlite3GetVarint(p, offset, out u64_v); - v = (i64)u64_v; - return result; - } - } - static int getVarint(byte[] p, int offset, out u64 v) { - v = p[offset + 0]; - if (v <= 0x7F) - return 1; - int result = sqlite3GetVarint(p, offset, out v); - return result; - } - static int getVarint32(byte[] p, out u32 v) { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) - v = p[0]; - if (v <= 0x7F) - return 1; - return sqlite3GetVarint32(p, 0, out v); - } - static byte[] pByte4 = new byte[4]; - static int getVarint32(string s, u32 offset, out int v) { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) - v = s[(int)offset]; - if (v <= 0x7F) - return 1; - pByte4[0] = (u8)s[(int)offset + 0]; - pByte4[1] = (u8)s[(int)offset + 1]; - pByte4[2] = (u8)s[(int)offset + 2]; - pByte4[3] = (u8)s[(int)offset + 3]; - u32 u32_v = 0; - int result = sqlite3GetVarint32(pByte4, 0, out u32_v); - v = (int)u32_v; - return sqlite3GetVarint32(pByte4, 0, out v); - } - static int getVarint32(string s, u32 offset, out u32 v) { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) - v = s[(int)offset]; - if (v <= 0x7F) - return 1; - pByte4[0] = (u8)s[(int)offset + 0]; - pByte4[1] = (u8)s[(int)offset + 1]; - pByte4[2] = (u8)s[(int)offset + 2]; - pByte4[3] = (u8)s[(int)offset + 3]; - return sqlite3GetVarint32(pByte4, 0, out v); - } - static int getVarint32(byte[] p, u32 offset, out u32 v) { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) - v = p[offset]; - if (v <= 0x7F) - return 1; - return sqlite3GetVarint32(p, (int)offset, out v); - } - static int getVarint32(byte[] p, int offset, out u32 v) { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) - v = offset >= p.Length ? 0 : (u32)p[offset]; - if (v <= 0x7F) - return 1; - return sqlite3GetVarint32(p, offset, out v); - } - static int getVarint32(byte[] p, int offset, out int v) { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) - v = p[offset + 0]; - if (v <= 0x7F) - return 1; - u32 u32_v = 0; - int result = sqlite3GetVarint32(p, offset, out u32_v); - v = (int)u32_v; - return result; - } - static int putVarint(byte[] p, int offset, int v) { - return putVarint(p, offset, (u64)v); - } - static int putVarint(byte[] p, int offset, u64 v) { - return sqlite3PutVarint(p, offset, v); + + /* + ** 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 then return 1. + ** + ** length is the number of bytes in the string (bytes, not characters). + ** The string is not necessarily zero-terminated. The encoding is + ** given by enc. + */ + static int sqlite3Atoi64( string zNum, ref i64 pNum, int length, u8 enc ) + { + if ( zNum == null ) + { + pNum = 0; + return 1; + } + int incr = ( enc == SQLITE_UTF8 ? 1 : 2 ); + u64 u = 0; + int neg = 0; /* assume positive */ + int i; + int c = 0; + int zDx = 0;// string zStart; + //string zEnd = zNum + length; + + if ( enc == SQLITE_UTF16BE ) + zDx++; + while ( zDx < length && sqlite3Isspace( zNum[zDx] ) ) + zDx += incr; + if ( zDx < length ) + { + if ( zNum[zDx] == '-' ) + { + neg = 1; + zDx += incr; } - static int sqlite3PutVarint(byte[] p, int offset, int v) { - return sqlite3PutVarint(p, offset, (u64)v); + else if ( zNum[zDx] == '+' ) + { + zDx += incr; } - static u8[] bufByte10 = new u8[10]; - static int sqlite3PutVarint(byte[] p, int offset, u64 v) { - int i, j, n; - if ((v & (((u64)0xff000000) << 32)) != 0) { - p[offset + 8] = (byte)v; - v >>= 8; - for (i = 7; i >= 0; i--) { - p[offset + i] = (byte)((v & 0x7f) | 0x80); - v >>= 7; - } - return 9; - } - n = 0; - do { - bufByte10[n++] = (byte)((v & 0x7f) | 0x80); - v >>= 7; - } while (v != 0); - bufByte10[0] &= 0x7f; - Debug.Assert(n <= 9); - for (i = 0, j = n - 1; j >= 0; j--, i++) { - p[offset + i] = bufByte10[j]; - } - return n; + } + //zStart = zNum; + if ( length > zNum.Length ) + length = zNum.Length; + while ( zDx < length - 1 && zNum[zDx] == '0' ) + { + zDx += incr; + } /* Skip leading zeros. */ + for ( i = zDx; i < length && ( c = zNum[i] ) >= '0' && c <= '9'; i += incr ) + { + u = u * 10 + (u64)(c - '0'); + } + if ( u > LARGEST_INT64 ) + { + pNum = SMALLEST_INT64; + } + else if ( neg != 0) + { + pNum = -(i64)u; + } + else + { + pNum = (i64)u; + } + testcase( i - zDx == 18 ); + testcase( i - zDx == 19 ); + testcase( i - zDx == 20 ); + if ( ( c != 0 && i < length ) || i == zDx || i - zDx > 19 * incr ) + { + /* 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 - zDx < 19 * incr ) + { + /* Less than 19 digits, so we know that it fits in 64 bits */ + Debug.Assert( u <= LARGEST_INT64 ); + return 0; + } + else + { + /* zNum is a 19-digit numbers. Compare it against 9223372036854775808. */ + c = compare2pow63( zNum.Substring(zDx), incr ); + if ( c < 0 ) + { + /* zNum is less than 9223372036854775808 so it fits */ + Debug.Assert( u <= LARGEST_INT64 ); + return 0; } - - /* - ** This routine is a faster version of sqlite3PutVarint() that only - ** works for 32-bit positive integers and which is optimized for - ** the common case of small integers. - */ - static int putVarint32(byte[] p, int offset, int v) { -#if !putVarint32 - if ((v & ~0x7f) == 0) { - p[offset] = (byte)v; - return 1; - } -#endif - if ((v & ~0x3fff) == 0) { - p[offset] = (byte)((v >> 7) | 0x80); - p[offset + 1] = (byte)(v & 0x7f); - return 2; - } - return sqlite3PutVarint(p, offset, v); + else if ( c > 0 ) + { + /* zNum is greater than 9223372036854775808 so it overflows */ + return 1; } - - static int putVarint32(byte[] p, int v) { - if ((v & ~0x7f) == 0) { - p[0] = (byte)v; - return 1; - } else if ((v & ~0x3fff) == 0) { - p[0] = (byte)((v >> 7) | 0x80); - p[1] = (byte)(v & 0x7f); - return 2; - } else { - return sqlite3PutVarint(p, 0, v); - } + else + { + /* zNum is exactly 9223372036854775808. Fits if negative. The + ** special case 2 overflow if positive */ + Debug.Assert( u - 1 == LARGEST_INT64 ); + Debug.Assert( ( pNum ) == SMALLEST_INT64 ); + return neg != 0 ? 0 : 2; } + } + } - /* - ** Bitmasks used by sqlite3GetVarint(). These precomputed constants - ** are defined here rather than simply putting the constant expressions - ** inline in order to work around bugs in the RVT compiler. - ** - ** SLOT_2_0 A mask for (0x7f<<14) | 0x7f - ** - ** SLOT_4_2_0 A mask for (0x7f<<28) | SLOT_2_0 - */ - const int SLOT_2_0 = 0x001fc07f; //#define SLOT_2_0 0x001fc07f - const u32 SLOT_4_2_0 = (u32)0xf01fc07f; //#define SLOT_4_2_0 0xf01fc07f - - /* - ** Read a 64-bit variable-length integer from memory starting at p[0]. - ** Return the number of bytes read. The value is stored in *v. - */ - static u8 sqlite3GetVarint(byte[] p, int offset, out u64 v) { - u32 a, b, s; - - a = p[offset + 0]; - /* a: p0 (unmasked) */ - if (0 == (a & 0x80)) { - v = a; - return 1; - } - - //p++; - b = p[offset + 1]; - /* b: p1 (unmasked) */ - if (0 == (b & 0x80)) { - a &= 0x7f; - a = a << 7; - a |= b; - v = a; - return 2; - } - - /* Verify that constants are precomputed correctly */ - Debug.Assert(SLOT_2_0 == ((0x7f << 14) | (0x7f))); - Debug.Assert(SLOT_4_2_0 == ((0xfU << 28) | (0x7f << 14) | (0x7f))); - //p++; - a = a << 14; - a |= p[offset + 2]; - /* a: p0<<14 | p2 (unmasked) */ - if (0 == (a & 0x80)) { - a &= SLOT_2_0; - b &= 0x7f; - b = b << 7; - a |= b; - v = a; - return 3; - } - - /* CSE1 from below */ - a &= SLOT_2_0; - //p++; - b = b << 14; - b |= p[offset + 3]; - /* b: p1<<14 | p3 (unmasked) */ - if (0 == (b & 0x80)) { - b &= SLOT_2_0; - /* moved CSE1 up */ - /* a &= (0x7f<<14)|(0x7f); */ - a = a << 7; - a |= b; - v = a; - return 4; - } - - /* a: p0<<14 | p2 (masked) */ - /* b: p1<<14 | p3 (unmasked) */ - /* 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */ - /* moved CSE1 up */ - /* a &= (0x7f<<14)|(0x7f); */ - b &= SLOT_2_0; - s = a; - /* s: p0<<14 | p2 (masked) */ - - //p++; - a = a << 14; - a |= p[offset + 4]; - /* a: p0<<28 | p2<<14 | p4 (unmasked) */ - if (0 == (a & 0x80)) { - /* we can skip these cause they were (effectively) done above in calc'ing s */ - /* a &= (0x1f<<28)|(0x7f<<14)|(0x7f); */ - /* b &= (0x7f<<14)|(0x7f); */ - b = b << 7; - a |= b; - s = s >> 18; - v = ((u64)s) << 32 | a; - return 5; - } - - /* 2:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */ - s = s << 7; - s |= b; - /* s: p0<<21 | p1<<14 | p2<<7 | p3 (masked) */ - - //p++; - b = b << 14; - b |= p[offset + 5]; - /* b: p1<<28 | p3<<14 | p5 (unmasked) */ - if (0 == (b & 0x80)) { - /* we can skip this cause it was (effectively) done above in calc'ing s */ - /* b &= (0x1f<<28)|(0x7f<<14)|(0x7f); */ - a &= SLOT_2_0; - a = a << 7; - a |= b; - s = s >> 18; - v = ((u64)s) << 32 | a; - return 6; - } + /* + ** If zNum represents an integer that will fit in 32-bits, then set + ** pValue to that integer and return true. Otherwise return false. + ** + ** Any non-numeric characters that following zNum are ignored. + ** This is different from sqlite3Atoi64() which requires the + ** input number to be zero-terminated. + */ + static bool sqlite3GetInt32( string zNum, ref int pValue ) + { + return sqlite3GetInt32( zNum, 0, ref pValue ); + } + static bool sqlite3GetInt32( string zNum, int iZnum, ref int pValue ) + { + sqlite_int64 v = 0; + int i, c; + int neg = 0; + if ( zNum[iZnum] == '-' ) + { + neg = 1; + iZnum++; + } + else if ( zNum[iZnum] == '+' ) + { + iZnum++; + } + while ( iZnum < zNum.Length && zNum[iZnum] == '0' ) + iZnum++; + for ( i = 0; i < 11 && i + iZnum < zNum.Length && ( c = zNum[iZnum + i] - '0' ) >= 0 && c <= 9; i++ ) + { + v = v * 10 + c; + } + + /* The longest decimal representation of a 32 bit integer is 10 digits: + ** + ** 1234567890 + ** 2^31 . 2147483648 + */ + testcase( i == 10 ); + if ( i > 10 ) + { + return false; + } + testcase( v - neg == 2147483647 ); + if ( v - neg > 2147483647 ) + { + return false; + } + if ( neg != 0 ) + { + v = -v; + } + pValue = (int)v; + return true; + } - //p++; - a = a << 14; - a |= p[offset + 6]; - /* a: p2<<28 | p4<<14 | p6 (unmasked) */ - if (0 == (a & 0x80)) { - a &= SLOT_4_2_0; - b &= SLOT_2_0; - b = b << 7; - a |= b; - s = s >> 11; - v = ((u64)s) << 32 | a; - return 7; - } + /* + ** Return a 32-bit integer value extracted from a string. If the + ** string is not an integer, just return 0. + */ + static int sqlite3Atoi( string z ) + { + int x = 0; + if ( !String.IsNullOrEmpty( z ) ) + sqlite3GetInt32( z, ref x ); + return x; + } - /* CSE2 from below */ - a &= SLOT_2_0; - //p++; - b = b << 14; - b |= p[offset + 7]; - /* b: p3<<28 | p5<<14 | p7 (unmasked) */ - if (0 == (b & 0x80)) { - b &= SLOT_4_2_0; - /* moved CSE2 up */ - /* a &= (0x7f<<14)|(0x7f); */ - a = a << 7; - a |= b; - s = s >> 4; - v = ((u64)s) << 32 | a; - return 8; - } + /* + ** The variable-length integer encoding is as follows: + ** + ** KEY: + ** A = 0xxxxxxx 7 bits of data and one flag bit + ** B = 1xxxxxxx 7 bits of data and one flag bit + ** C = xxxxxxxx 8 bits of data + ** + ** 7 bits - A + ** 14 bits - BA + ** 21 bits - BBA + ** 28 bits - BBBA + ** 35 bits - BBBBA + ** 42 bits - BBBBBA + ** 49 bits - BBBBBBA + ** 56 bits - BBBBBBBA + ** 64 bits - BBBBBBBBC + */ - //p++; - a = a << 15; - a |= p[offset + 8]; - /* a: p4<<29 | p6<<15 | p8 (unmasked) */ + /* + ** Write a 64-bit variable-length integer to memory starting at p[0]. + ** The length of data write will be between 1 and 9 bytes. The number + ** of bytes written is returned. + ** + ** A variable-length integer consists of the lower 7 bits of each byte + ** for all bytes that have the 8th bit set and one byte with the 8th + ** bit clear. Except, if we get to the 9th byte, it stores the full + ** 8 bits and is the last byte. + */ + static int getVarint( byte[] p, out u32 v ) + { + v = p[0]; + if ( v <= 0x7F ) + return 1; + u64 u64_v = 0; + int result = sqlite3GetVarint( p, 0, out u64_v ); + v = (u32)u64_v; + return result; + } + static int getVarint( byte[] p, int offset, out u32 v ) + { + v = p[offset + 0]; + if ( v <= 0x7F ) + return 1; + u64 u64_v = 0; + int result = sqlite3GetVarint( p, offset, out u64_v ); + v = (u32)u64_v; + return result; + } + static int getVarint( byte[] p, int offset, out int v ) + { + v = p[offset + 0]; + if ( v <= 0x7F ) + return 1; + u64 u64_v = 0; + int result = sqlite3GetVarint( p, offset, out u64_v ); + v = (int)u64_v; + return result; + } + static int getVarint( byte[] p, int offset, out i64 v ) + { + v = offset >= p.Length ? 0 : (int)p[offset + 0]; + if ( v <= 0x7F ) + return 1; + if ( offset + 1 >= p.Length ) + { + v = 65535; + return 2; + } + else + { + u64 u64_v = 0; + int result = sqlite3GetVarint( p, offset, out u64_v ); + v = (i64)u64_v; + return result; + } + } + static int getVarint( byte[] p, int offset, out u64 v ) + { + v = p[offset + 0]; + if ( v <= 0x7F ) + return 1; + int result = sqlite3GetVarint( p, offset, out v ); + return result; + } + static int getVarint32( byte[] p, out u32 v ) + { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) + v = p[0]; + if ( v <= 0x7F ) + return 1; + return sqlite3GetVarint32( p, 0, out v ); + } + static byte[] pByte4 = new byte[4]; + static int getVarint32( string s, u32 offset, out int v ) + { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) + v = s[(int)offset]; + if ( v <= 0x7F ) + return 1; + pByte4[0] = (u8)s[(int)offset + 0]; + pByte4[1] = (u8)s[(int)offset + 1]; + pByte4[2] = (u8)s[(int)offset + 2]; + pByte4[3] = (u8)s[(int)offset + 3]; + u32 u32_v = 0; + int result = sqlite3GetVarint32( pByte4, 0, out u32_v ); + v = (int)u32_v; + return sqlite3GetVarint32( pByte4, 0, out v ); + } + static int getVarint32( string s, u32 offset, out u32 v ) + { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) + v = s[(int)offset]; + if ( v <= 0x7F ) + return 1; + pByte4[0] = (u8)s[(int)offset + 0]; + pByte4[1] = (u8)s[(int)offset + 1]; + pByte4[2] = (u8)s[(int)offset + 2]; + pByte4[3] = (u8)s[(int)offset + 3]; + return sqlite3GetVarint32( pByte4, 0, out v ); + } + static int getVarint32( byte[] p, u32 offset, out u32 v ) + { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) + v = p[offset]; + if ( v <= 0x7F ) + return 1; + return sqlite3GetVarint32( p, (int)offset, out v ); + } + static int getVarint32( byte[] p, int offset, out u32 v ) + { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) + v = offset >= p.Length ? 0 : (u32)p[offset]; + if ( v <= 0x7F ) + return 1; + return sqlite3GetVarint32( p, offset, out v ); + } + static int getVarint32( byte[] p, int offset, out int v ) + { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) + v = p[offset + 0]; + if ( v <= 0x7F ) + return 1; + u32 u32_v = 0; + int result = sqlite3GetVarint32( p, offset, out u32_v ); + v = (int)u32_v; + return result; + } + static int putVarint( byte[] p, int offset, int v ) + { + return putVarint( p, offset, (u64)v ); + } + static int putVarint( byte[] p, int offset, u64 v ) + { + return sqlite3PutVarint( p, offset, v ); + } + static int sqlite3PutVarint( byte[] p, int offset, int v ) + { + return sqlite3PutVarint( p, offset, (u64)v ); + } + static u8[] bufByte10 = new u8[10]; + static int sqlite3PutVarint( byte[] p, int offset, u64 v ) + { + int i, j, n; + if ( ( v & ( ( (u64)0xff000000 ) << 32 ) ) != 0 ) + { + p[offset + 8] = (byte)v; + v >>= 8; + for ( i = 7; i >= 0; i-- ) + { + p[offset + i] = (byte)( ( v & 0x7f ) | 0x80 ); + v >>= 7; + } + return 9; + } + n = 0; + do + { + bufByte10[n++] = (byte)( ( v & 0x7f ) | 0x80 ); + v >>= 7; + } while ( v != 0 ); + bufByte10[0] &= 0x7f; + Debug.Assert( n <= 9 ); + for ( i = 0, j = n - 1; j >= 0; j--, i++ ) + { + p[offset + i] = bufByte10[j]; + } + return n; + } - /* moved CSE2 up */ - /* a &= (0x7f<<29)|(0x7f<<15)|(0xff); */ - b &= SLOT_2_0; - b = b << 8; - a |= b; + /* + ** This routine is a faster version of sqlite3PutVarint() that only + ** works for 32-bit positive integers and which is optimized for + ** the common case of small integers. + */ + static int putVarint32( byte[] p, int offset, int v ) + { +#if !putVarint32 + if ( ( v & ~0x7f ) == 0 ) + { + p[offset] = (byte)v; + return 1; + } +#endif + if ( ( v & ~0x3fff ) == 0 ) + { + p[offset] = (byte)( ( v >> 7 ) | 0x80 ); + p[offset + 1] = (byte)( v & 0x7f ); + return 2; + } + return sqlite3PutVarint( p, offset, v ); + } - s = s << 4; - b = p[offset + 4]; - b &= 0x7f; - b = b >> 3; - s |= b; + static int putVarint32( byte[] p, int v ) + { + if ( ( v & ~0x7f ) == 0 ) + { + p[0] = (byte)v; + return 1; + } + else if ( ( v & ~0x3fff ) == 0 ) + { + p[0] = (byte)( ( v >> 7 ) | 0x80 ); + p[1] = (byte)( v & 0x7f ); + return 2; + } + else + { + return sqlite3PutVarint( p, 0, v ); + } + } - v = ((u64)s) << 32 | a; + /* + ** Bitmasks used by sqlite3GetVarint(). These precomputed constants + ** are defined here rather than simply putting the constant expressions + ** inline in order to work around bugs in the RVT compiler. + ** + ** SLOT_2_0 A mask for (0x7f<<14) | 0x7f + ** + ** SLOT_4_2_0 A mask for (0x7f<<28) | SLOT_2_0 + */ + const int SLOT_2_0 = 0x001fc07f; //#define SLOT_2_0 0x001fc07f + const u32 SLOT_4_2_0 = (u32)0xf01fc07f; //#define SLOT_4_2_0 0xf01fc07f - return 9; - } + /* + ** Read a 64-bit variable-length integer from memory starting at p[0]. + ** Return the number of bytes read. The value is stored in *v. + */ + static u8 sqlite3GetVarint( byte[] p, int offset, out u64 v ) + { + u32 a, b, s; + + a = p[offset + 0]; + /* a: p0 (unmasked) */ + if ( 0 == ( a & 0x80 ) ) + { + v = a; + return 1; + } + + //p++; + b = p[offset + 1]; + /* b: p1 (unmasked) */ + if ( 0 == ( b & 0x80 ) ) + { + a &= 0x7f; + a = a << 7; + a |= b; + v = a; + return 2; + } + + /* Verify that constants are precomputed correctly */ + Debug.Assert( SLOT_2_0 == ( ( 0x7f << 14 ) | ( 0x7f ) ) ); + Debug.Assert( SLOT_4_2_0 == ( ( 0xfU << 28 ) | ( 0x7f << 14 ) | ( 0x7f ) ) ); + //p++; + a = a << 14; + a |= p[offset + 2]; + /* a: p0<<14 | p2 (unmasked) */ + if ( 0 == ( a & 0x80 ) ) + { + a &= SLOT_2_0; + b &= 0x7f; + b = b << 7; + a |= b; + v = a; + return 3; + } + + /* CSE1 from below */ + a &= SLOT_2_0; + //p++; + b = b << 14; + b |= p[offset + 3]; + /* b: p1<<14 | p3 (unmasked) */ + if ( 0 == ( b & 0x80 ) ) + { + b &= SLOT_2_0; + /* moved CSE1 up */ + /* a &= (0x7f<<14)|(0x7f); */ + a = a << 7; + a |= b; + v = a; + return 4; + } + + /* a: p0<<14 | p2 (masked) */ + /* b: p1<<14 | p3 (unmasked) */ + /* 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */ + /* moved CSE1 up */ + /* a &= (0x7f<<14)|(0x7f); */ + b &= SLOT_2_0; + s = a; + /* s: p0<<14 | p2 (masked) */ + + //p++; + a = a << 14; + a |= p[offset + 4]; + /* a: p0<<28 | p2<<14 | p4 (unmasked) */ + if ( 0 == ( a & 0x80 ) ) + { + /* we can skip these cause they were (effectively) done above in calc'ing s */ + /* a &= (0x1f<<28)|(0x7f<<14)|(0x7f); */ + /* b &= (0x7f<<14)|(0x7f); */ + b = b << 7; + a |= b; + s = s >> 18; + v = ( (u64)s ) << 32 | a; + return 5; + } + + /* 2:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */ + s = s << 7; + s |= b; + /* s: p0<<21 | p1<<14 | p2<<7 | p3 (masked) */ + + //p++; + b = b << 14; + b |= p[offset + 5]; + /* b: p1<<28 | p3<<14 | p5 (unmasked) */ + if ( 0 == ( b & 0x80 ) ) + { + /* we can skip this cause it was (effectively) done above in calc'ing s */ + /* b &= (0x1f<<28)|(0x7f<<14)|(0x7f); */ + a &= SLOT_2_0; + a = a << 7; + a |= b; + s = s >> 18; + v = ( (u64)s ) << 32 | a; + return 6; + } + + //p++; + a = a << 14; + a |= p[offset + 6]; + /* a: p2<<28 | p4<<14 | p6 (unmasked) */ + if ( 0 == ( a & 0x80 ) ) + { + a &= SLOT_4_2_0; + b &= SLOT_2_0; + b = b << 7; + a |= b; + s = s >> 11; + v = ( (u64)s ) << 32 | a; + return 7; + } + + /* CSE2 from below */ + a &= SLOT_2_0; + //p++; + b = b << 14; + b |= p[offset + 7]; + /* b: p3<<28 | p5<<14 | p7 (unmasked) */ + if ( 0 == ( b & 0x80 ) ) + { + b &= SLOT_4_2_0; + /* moved CSE2 up */ + /* a &= (0x7f<<14)|(0x7f); */ + a = a << 7; + a |= b; + s = s >> 4; + v = ( (u64)s ) << 32 | a; + return 8; + } + + //p++; + a = a << 15; + a |= p[offset + 8]; + /* a: p4<<29 | p6<<15 | p8 (unmasked) */ + + /* moved CSE2 up */ + /* a &= (0x7f<<29)|(0x7f<<15)|(0xff); */ + b &= SLOT_2_0; + b = b << 8; + a |= b; + + s = s << 4; + b = p[offset + 4]; + b &= 0x7f; + b = b >> 3; + s |= b; + + v = ( (u64)s ) << 32 | a; + + return 9; + } - /* - ** Read a 32-bit variable-length integer from memory starting at p[0]. - ** Return the number of bytes read. The value is stored in *v. - ** - ** If the varint stored in p[0] is larger than can fit in a 32-bit unsigned - ** integer, then set *v to 0xffffffff. - ** - ** A MACRO version, getVarint32, is provided which inlines the - ** single-byte case. All code should use the MACRO version as - ** this function assumes the single-byte case has already been handled. - */ - static u8 sqlite3GetVarint32(byte[] p, out int v) { - u32 u32_v = 0; - u8 result = sqlite3GetVarint32(p, 0, out u32_v); - v = (int)u32_v; - return result; - } - static u8 sqlite3GetVarint32(byte[] p, int offset, out int v) { - u32 u32_v = 0; - u8 result = sqlite3GetVarint32(p, offset, out u32_v); - v = (int)u32_v; - return result; + /* + ** Read a 32-bit variable-length integer from memory starting at p[0]. + ** Return the number of bytes read. The value is stored in *v. + ** + ** If the varint stored in p[0] is larger than can fit in a 32-bit unsigned + ** integer, then set *v to 0xffffffff. + ** + ** A MACRO version, getVarint32, is provided which inlines the + ** single-byte case. All code should use the MACRO version as + ** this function assumes the single-byte case has already been handled. + */ + static u8 sqlite3GetVarint32( byte[] p, out int v ) + { + u32 u32_v = 0; + u8 result = sqlite3GetVarint32( p, 0, out u32_v ); + v = (int)u32_v; + return result; + } + static u8 sqlite3GetVarint32( byte[] p, int offset, out int v ) + { + u32 u32_v = 0; + u8 result = sqlite3GetVarint32( p, offset, out u32_v ); + v = (int)u32_v; + return result; + } + static u8 sqlite3GetVarint32( byte[] p, out u32 v ) + { + return sqlite3GetVarint32( p, 0, out v ); + } + static u8 sqlite3GetVarint32( byte[] p, int offset, out u32 v ) + { + u32 a, b; + + /* The 1-byte case. Overwhelmingly the most common. Handled inline + ** by the getVarin32() macro */ + a = p[offset + 0]; + /* a: p0 (unmasked) */ + //#if getVarint32 + // if ( 0==( a&0x80)) + // { + /* Values between 0 and 127 */ + // v = a; + // return 1; + // } + //#endif + + /* The 2-byte case */ + //p++; + b = ( offset + 1 ) < p.Length ? p[offset + 1] : (u32)0; + /* b: p1 (unmasked) */ + if ( 0 == ( b & 0x80 ) ) + { + /* Values between 128 and 16383 */ + a &= 0x7f; + a = a << 7; + v = a | b; + return 2; + } + + /* The 3-byte case */ + //p++; + a = a << 14; + a |= ( offset + 2 ) < p.Length ? p[offset + 2] : (u32)0; + /* a: p0<<14 | p2 (unmasked) */ + if ( 0 == ( a & 0x80 ) ) + { + /* Values between 16384 and 2097151 */ + a &= ( 0x7f << 14 ) | ( 0x7f ); + b &= 0x7f; + b = b << 7; + v = a | b; + return 3; + } + + /* A 32-bit varint is used to store size information in btrees. + ** Objects are rarely larger than 2MiB limit of a 3-byte varint. + ** A 3-byte varint is sufficient, for example, to record the size + ** of a 1048569-byte BLOB or string. + ** + ** We only unroll the first 1-, 2-, and 3- byte cases. The very + ** rare larger cases can be handled by the slower 64-bit varint + ** routine. + */ +#if TRUE + { + u64 v64 = 0; + u8 n; + + //p -= 2; + n = sqlite3GetVarint( p, offset, out v64 ); + Debug.Assert( n > 3 && n <= 9 ); + if ( ( v64 & SQLITE_MAX_U32 ) != v64 ) + { + v = 0xffffffff; } - static u8 sqlite3GetVarint32(byte[] p, out u32 v) { - return sqlite3GetVarint32(p, 0, out v); + else + { + v = (u32)v64; } - static u8 sqlite3GetVarint32(byte[] p, int offset, out u32 v) { - u32 a, b; - - /* The 1-byte case. Overwhelmingly the most common. Handled inline - ** by the getVarin32() macro */ - a = p[offset + 0]; - /* a: p0 (unmasked) */ - //#if getVarint32 - // if ( 0==( a&0x80)) - // { - /* Values between 0 and 127 */ - // v = a; - // return 1; - // } - //#endif - - /* The 2-byte case */ - //p++; - b = (offset + 1) < p.Length ? p[offset + 1] : (u32)0; - /* b: p1 (unmasked) */ - if (0 == (b & 0x80)) { - /* Values between 128 and 16383 */ - a &= 0x7f; - a = a << 7; - v = a | b; - return 2; - } - - /* The 3-byte case */ - //p++; - a = a << 14; - a |= (offset + 2) < p.Length ? p[offset + 2] : (u32)0; - /* a: p0<<14 | p2 (unmasked) */ - if (0 == (a & 0x80)) { - /* Values between 16384 and 2097151 */ - a &= (0x7f << 14) | (0x7f); - b &= 0x7f; - b = b << 7; - v = a | b; - return 3; - } - - /* A 32-bit varint is used to store size information in btrees. - ** Objects are rarely larger than 2MiB limit of a 3-byte varint. - ** A 3-byte varint is sufficient, for example, to record the size - ** of a 1048569-byte BLOB or string. - ** - ** We only unroll the first 1-, 2-, and 3- byte cases. The very - ** rare larger cases can be handled by the slower 64-bit varint - ** routine. - */ -#if TRUE - { - u64 v64 = 0; - u8 n; - - //p -= 2; - n = sqlite3GetVarint(p, offset, out v64); - Debug.Assert(n > 3 && n <= 9); - if ((v64 & SQLITE_MAX_U32) != v64) { - v = 0xffffffff; - } else { - v = (u32)v64; - } - return n; - } + return n; + } #else /* For following code (kept for historical record only) shows an ** unrolling for the 3- and 4-byte varint cases. This code is @@ -1204,250 +1366,286 @@ static u8 sqlite3GetVarint32(byte[] p, int offset, out u32 v) { return n; } #endif - } + } - /* - ** Return the number of bytes that will be needed to store the given - ** 64-bit integer. - */ - static int sqlite3VarintLen(u64 v) { - int i = 0; - do { - i++; - v >>= 7; - } while (v != 0 && ALWAYS(i < 9)); - return i; - } + /* + ** Return the number of bytes that will be needed to store the given + ** 64-bit integer. + */ + static int sqlite3VarintLen( u64 v ) + { + int i = 0; + do + { + i++; + v >>= 7; + } while ( v != 0 && ALWAYS( i < 9 ) ); + return i; + } - /* - ** Read or write a four-byte big-endian integer value. - */ - static u32 sqlite3Get4byte(u8[] p, int p_offset, int offset) { - offset += p_offset; - return (offset + 3 > p.Length) ? 0 : (u32)((p[0 + offset] << 24) | (p[1 + offset] << 16) | (p[2 + offset] << 8) | p[3 + offset]); - } - static u32 sqlite3Get4byte(u8[] p, int offset) { - return (offset + 3 > p.Length) ? 0 : (u32)((p[0 + offset] << 24) | (p[1 + offset] << 16) | (p[2 + offset] << 8) | p[3 + offset]); - } - static u32 sqlite3Get4byte(u8[] p, u32 offset) { - return (offset + 3 > p.Length) ? 0 : (u32)((p[0 + offset] << 24) | (p[1 + offset] << 16) | (p[2 + offset] << 8) | p[3 + offset]); - } - static u32 sqlite3Get4byte(u8[] p) { - return (u32)((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]); - } - static void sqlite3Put4byte(byte[] p, int v) { - p[0] = (byte)(v >> 24 & 0xFF); - p[1] = (byte)(v >> 16 & 0xFF); - p[2] = (byte)(v >> 8 & 0xFF); - p[3] = (byte)(v & 0xFF); - } - static void sqlite3Put4byte(byte[] p, int offset, int v) { - p[0 + offset] = (byte)(v >> 24 & 0xFF); - p[1 + offset] = (byte)(v >> 16 & 0xFF); - p[2 + offset] = (byte)(v >> 8 & 0xFF); - p[3 + offset] = (byte)(v & 0xFF); - } - static void sqlite3Put4byte(byte[] p, u32 offset, u32 v) { - p[0 + offset] = (byte)(v >> 24 & 0xFF); - p[1 + offset] = (byte)(v >> 16 & 0xFF); - p[2 + offset] = (byte)(v >> 8 & 0xFF); - p[3 + offset] = (byte)(v & 0xFF); - } - static void sqlite3Put4byte(byte[] p, int offset, u64 v) { - p[0 + offset] = (byte)(v >> 24 & 0xFF); - p[1 + offset] = (byte)(v >> 16 & 0xFF); - p[2 + offset] = (byte)(v >> 8 & 0xFF); - p[3 + offset] = (byte)(v & 0xFF); - } - static void sqlite3Put4byte(byte[] p, u64 v) { - p[0] = (byte)(v >> 24 & 0xFF); - p[1] = (byte)(v >> 16 & 0xFF); - p[2] = (byte)(v >> 8 & 0xFF); - p[3] = (byte)(v & 0xFF); - } + /* + ** Read or write a four-byte big-endian integer value. + */ + static u32 sqlite3Get4byte( u8[] p, int p_offset, int offset ) + { + offset += p_offset; + return ( offset + 3 > p.Length ) ? 0 : (u32)( ( p[0 + offset] << 24 ) | ( p[1 + offset] << 16 ) | ( p[2 + offset] << 8 ) | p[3 + offset] ); + } + static u32 sqlite3Get4byte( u8[] p, int offset ) + { + return ( offset + 3 > p.Length ) ? 0 : (u32)( ( p[0 + offset] << 24 ) | ( p[1 + offset] << 16 ) | ( p[2 + offset] << 8 ) | p[3 + offset] ); + } + static u32 sqlite3Get4byte( u8[] p, u32 offset ) + { + return ( offset + 3 > p.Length ) ? 0 : (u32)( ( p[0 + offset] << 24 ) | ( p[1 + offset] << 16 ) | ( p[2 + offset] << 8 ) | p[3 + offset] ); + } + static u32 sqlite3Get4byte( u8[] p ) + { + return (u32)( ( p[0] << 24 ) | ( p[1] << 16 ) | ( p[2] << 8 ) | p[3] ); + } + static void sqlite3Put4byte( byte[] p, int v ) + { + p[0] = (byte)( v >> 24 & 0xFF ); + p[1] = (byte)( v >> 16 & 0xFF ); + p[2] = (byte)( v >> 8 & 0xFF ); + p[3] = (byte)( v & 0xFF ); + } + static void sqlite3Put4byte( byte[] p, int offset, int v ) + { + p[0 + offset] = (byte)( v >> 24 & 0xFF ); + p[1 + offset] = (byte)( v >> 16 & 0xFF ); + p[2 + offset] = (byte)( v >> 8 & 0xFF ); + p[3 + offset] = (byte)( v & 0xFF ); + } + static void sqlite3Put4byte( byte[] p, u32 offset, u32 v ) + { + p[0 + offset] = (byte)( v >> 24 & 0xFF ); + p[1 + offset] = (byte)( v >> 16 & 0xFF ); + p[2 + offset] = (byte)( v >> 8 & 0xFF ); + p[3 + offset] = (byte)( v & 0xFF ); + } + static void sqlite3Put4byte( byte[] p, int offset, u64 v ) + { + p[0 + offset] = (byte)( v >> 24 & 0xFF ); + p[1 + offset] = (byte)( v >> 16 & 0xFF ); + p[2 + offset] = (byte)( v >> 8 & 0xFF ); + p[3 + offset] = (byte)( v & 0xFF ); + } + static void sqlite3Put4byte( byte[] p, u64 v ) + { + p[0] = (byte)( v >> 24 & 0xFF ); + p[1] = (byte)( v >> 16 & 0xFF ); + p[2] = (byte)( v >> 8 & 0xFF ); + p[3] = (byte)( v & 0xFF ); + } - /* - ** Translate a single byte of Hex into an integer. - ** This routine only works if h really is a valid hexadecimal - ** character: 0..9a..fA..F - */ - static int sqlite3HexToInt(int h) { - Debug.Assert((h >= '0' && h <= '9') || (h >= 'a' && h <= 'f') || (h >= 'A' && h <= 'F')); +/* +** Translate a single byte of Hex into an integer. +** This routine only works if h really is a valid hexadecimal +** character: 0..9a..fA..F +*/ + static int sqlite3HexToInt( int h ) + { + Debug.Assert( ( h >= '0' && h <= '9' ) || ( h >= 'a' && h <= 'f' ) || ( h >= 'A' && h <= 'F' ) ); #if SQLITE_ASCII - h += 9 * (1 & (h >> 6)); + h += 9 * ( 1 & ( h >> 6 ) ); #endif - //#if SQLITE_EBCDIC - //h += 9*(1&~(h>>4)); - //#endif - return h & 0xf; - } +//#if SQLITE_EBCDIC +//h += 9*(1&~(h>>4)); +//#endif + return h & 0xf; + } #if !SQLITE_OMIT_BLOB_LITERAL || SQLITE_HAS_CODEC - /* - ** Convert a BLOB literal of the form "x'hhhhhh'" into its binary - ** value. Return a pointer to its binary value. Space to hold the - ** binary value has been obtained from malloc and must be freed by - ** the calling routine. - */ - static byte[] sqlite3HexToBlob(sqlite3 db, string z, int n) { - StringBuilder zBlob; - int i; - - zBlob = new StringBuilder(n / 2 + 1);// (char)sqlite3DbMallocRaw(db, n / 2 + 1); - n--; - if (zBlob != null) { - for (i = 0; i < n; i += 2) { - zBlob.Append(Convert.ToChar((sqlite3HexToInt(z[i]) << 4) | sqlite3HexToInt(z[i + 1]))); - } - //zBlob[i / 2] = '\0'; ; - } - return Encoding.UTF8.GetBytes(zBlob.ToString()); + /* +** Convert a BLOB literal of the form "x'hhhhhh'" into its binary +** value. Return a pointer to its binary value. Space to hold the +** binary value has been obtained from malloc and must be freed by +** the calling routine. +*/ + static byte[] sqlite3HexToBlob( sqlite3 db, string z, int n ) + { + StringBuilder zBlob; + int i; + + zBlob = new StringBuilder( n / 2 + 1 );// (char)sqlite3DbMallocRaw(db, n / 2 + 1); + n--; + if ( zBlob != null ) + { + for ( i = 0; i < n; i += 2 ) + { + zBlob.Append( Convert.ToChar( ( sqlite3HexToInt( z[i] ) << 4 ) | sqlite3HexToInt( z[i + 1] ) ) ); } + //zBlob[i / 2] = '\0'; ; + } + return Encoding.UTF8.GetBytes( zBlob.ToString() ); + } #endif // * !SQLITE_OMIT_BLOB_LITERAL || SQLITE_HAS_CODEC */ - /* - ** Log an error that is an API call on a connection pointer that should - ** not have been used. The "type" of connection pointer is given as the - ** argument. The zType is a word like "NULL" or "closed" or "invalid". - */ - static void logBadConnection(string zType) { - sqlite3_log(SQLITE_MISUSE, - "API call with %s database connection pointer", - zType - ); - } + /* +** Log an error that is an API call on a connection pointer that should +** not have been used. The "type" of connection pointer is given as the +** argument. The zType is a word like "NULL" or "closed" or "invalid". +*/ + static void logBadConnection( string zType ) + { + sqlite3_log( SQLITE_MISUSE, + "API call with %s database connection pointer", + zType + ); + } - /* - ** Check to make sure we have a valid db pointer. This test is not - ** foolproof but it does provide some measure of protection against - ** misuse of the interface such as passing in db pointers that are - ** NULL or which have been previously closed. If this routine returns - ** 1 it means that the db pointer is valid and 0 if it should not be - ** dereferenced for any reason. The calling function should invoke - ** SQLITE_MISUSE immediately. - ** - ** sqlite3SafetyCheckOk() requires that the db pointer be valid for - ** use. sqlite3SafetyCheckSickOrOk() allows a db pointer that failed to - ** open properly and is not fit for general use but which can be - ** used as an argument to sqlite3_errmsg() or sqlite3_close(). - */ - static bool sqlite3SafetyCheckOk(sqlite3 db) { - u32 magic; - if (db == null) { - logBadConnection("NULL"); - return false; - } - magic = db.magic; - if (magic != SQLITE_MAGIC_OPEN) { - if (sqlite3SafetyCheckSickOrOk(db)) { - testcase(sqlite3GlobalConfig.xLog != null); - logBadConnection("unopened"); - } - return false; - } else { - return true; - } - } - static bool sqlite3SafetyCheckSickOrOk(sqlite3 db) { - u32 magic; - magic = db.magic; - if (magic != SQLITE_MAGIC_SICK && - magic != SQLITE_MAGIC_OPEN && - magic != SQLITE_MAGIC_BUSY) { - testcase(sqlite3GlobalConfig.xLog != null); - logBadConnection("invalid"); - return false; - } else { - return true; - } + /* + ** Check to make sure we have a valid db pointer. This test is not + ** foolproof but it does provide some measure of protection against + ** misuse of the interface such as passing in db pointers that are + ** NULL or which have been previously closed. If this routine returns + ** 1 it means that the db pointer is valid and 0 if it should not be + ** dereferenced for any reason. The calling function should invoke + ** SQLITE_MISUSE immediately. + ** + ** sqlite3SafetyCheckOk() requires that the db pointer be valid for + ** use. sqlite3SafetyCheckSickOrOk() allows a db pointer that failed to + ** open properly and is not fit for general use but which can be + ** used as an argument to sqlite3_errmsg() or sqlite3_close(). + */ + static bool sqlite3SafetyCheckOk( sqlite3 db ) + { + u32 magic; + if ( db == null ) + { + logBadConnection( "NULL" ); + return false; + } + magic = db.magic; + if ( magic != SQLITE_MAGIC_OPEN ) + { + if ( sqlite3SafetyCheckSickOrOk( db ) ) + { + testcase( sqlite3GlobalConfig.xLog != null ); + logBadConnection( "unopened" ); } + return false; + } + else + { + return true; + } + } + static bool sqlite3SafetyCheckSickOrOk( sqlite3 db ) + { + u32 magic; + magic = db.magic; + if ( magic != SQLITE_MAGIC_SICK && + magic != SQLITE_MAGIC_OPEN && + magic != SQLITE_MAGIC_BUSY ) + { + testcase( sqlite3GlobalConfig.xLog != null ); + logBadConnection( "invalid" ); + return false; + } + else + { + return true; + } + } - /* - ** Attempt to add, substract, or multiply the 64-bit signed value iB against - ** the other 64-bit signed integer at *pA and store the result in *pA. - ** Return 0 on success. Or if the operation would have resulted in an - ** overflow, leave *pA unchanged and return 1. - */ - static int sqlite3AddInt64(ref i64 pA, i64 iB) { - i64 iA = pA; - testcase(iA == 0); - testcase(iA == 1); - testcase(iB == -1); - testcase(iB == 0); - if (iB >= 0) { - testcase(iA > 0 && LARGEST_INT64 - iA == iB); - testcase(iA > 0 && LARGEST_INT64 - iA == iB - 1); - if (iA > 0 && LARGEST_INT64 - iA < iB) - return 1; - pA += iB; - } else { - testcase(iA < 0 && -(iA + LARGEST_INT64) == iB + 1); - testcase(iA < 0 && -(iA + LARGEST_INT64) == iB + 2); - if (iA < 0 && -(iA + LARGEST_INT64) > iB + 1) - return 1; - pA += iB; - } - return 0; - } - static int sqlite3SubInt64(ref i64 pA, i64 iB) { - testcase(iB == SMALLEST_INT64 + 1); - if (iB == SMALLEST_INT64) { - testcase((pA) == (-1)); - testcase((pA) == 0); - if ((pA) >= 0) - return 1; - pA -= iB; - return 0; - } else { - return sqlite3AddInt64(ref pA, -iB); - } - } - //#define TWOPOWER32 (((i64)1)<<32) - const i64 TWOPOWER32 = (((i64)1) << 32); - //#define TWOPOWER31 (((i64)1)<<31) - const i64 TWOPOWER31 = (((i64)1) << 31); - - static int sqlite3MulInt64(ref i64 pA, i64 iB) { - i64 iA = pA; - i64 iA1, iA0, iB1, iB0, r; - - iA1 = iA / TWOPOWER32; - iA0 = iA % TWOPOWER32; - iB1 = iB / TWOPOWER32; - iB0 = iB % TWOPOWER32; - if (iA1 * iB1 != 0) - return 1; - Debug.Assert(iA1 * iB0 == 0 || iA0 * iB1 == 0); - r = iA1 * iB0 + iA0 * iB1; - testcase(r == (-TWOPOWER31) - 1); - testcase(r == (-TWOPOWER31)); - testcase(r == TWOPOWER31); - testcase(r == TWOPOWER31 - 1); - if (r < (-TWOPOWER31) || r >= TWOPOWER31) - return 1; - r *= TWOPOWER32; - if (sqlite3AddInt64(ref r, iA0 * iB0) != 0) - return 1; - pA = r; - return 0; - } + /* + ** Attempt to add, substract, or multiply the 64-bit signed value iB against + ** the other 64-bit signed integer at *pA and store the result in *pA. + ** Return 0 on success. Or if the operation would have resulted in an + ** overflow, leave *pA unchanged and return 1. + */ + static int sqlite3AddInt64( ref i64 pA, i64 iB ) + { + i64 iA = pA; + testcase( iA == 0 ); + testcase( iA == 1 ); + testcase( iB == -1 ); + testcase( iB == 0 ); + if ( iB >= 0 ) + { + testcase( iA > 0 && LARGEST_INT64 - iA == iB ); + testcase( iA > 0 && LARGEST_INT64 - iA == iB - 1 ); + if ( iA > 0 && LARGEST_INT64 - iA < iB ) + return 1; + pA += iB; + } + else + { + testcase( iA < 0 && -( iA + LARGEST_INT64 ) == iB + 1 ); + testcase( iA < 0 && -( iA + LARGEST_INT64 ) == iB + 2 ); + if ( iA < 0 && -( iA + LARGEST_INT64 ) > iB + 1 ) + return 1; + pA += iB; + } + return 0; + } + static int sqlite3SubInt64( ref i64 pA, i64 iB ) + { + testcase( iB == SMALLEST_INT64 + 1 ); + if ( iB == SMALLEST_INT64 ) + { + testcase( ( pA ) == ( -1 ) ); + testcase( ( pA ) == 0 ); + if ( ( pA ) >= 0 ) + return 1; + pA -= iB; + return 0; + } + else + { + return sqlite3AddInt64( ref pA, -iB ); + } + } + //#define TWOPOWER32 (((i64)1)<<32) + const i64 TWOPOWER32 = ( ( (i64)1 ) << 32 ); + //#define TWOPOWER31 (((i64)1)<<31) + const i64 TWOPOWER31 = ( ( (i64)1 ) << 31 ); + + static int sqlite3MulInt64( ref i64 pA, i64 iB ) + { + i64 iA = pA; + i64 iA1, iA0, iB1, iB0, r; + + iA1 = iA / TWOPOWER32; + iA0 = iA % TWOPOWER32; + iB1 = iB / TWOPOWER32; + iB0 = iB % TWOPOWER32; + if ( iA1 * iB1 != 0 ) + return 1; + Debug.Assert( iA1 * iB0 == 0 || iA0 * iB1 == 0 ); + r = iA1 * iB0 + iA0 * iB1; + testcase( r == ( -TWOPOWER31 ) - 1 ); + testcase( r == ( -TWOPOWER31 ) ); + testcase( r == TWOPOWER31 ); + testcase( r == TWOPOWER31 - 1 ); + if ( r < ( -TWOPOWER31 ) || r >= TWOPOWER31 ) + return 1; + r *= TWOPOWER32; + if ( sqlite3AddInt64( ref r, iA0 * iB0 ) != 0) + return 1; + pA = r; + return 0; + } - /* - ** Compute the absolute value of a 32-bit signed integer, if possible. Or - ** if the integer has a value of -2147483648, return +2147483647 - */ - static int sqlite3AbsInt32(int x) { - if (x >= 0) - return x; - if (x == -2147483648) // 0x80000000 - return 0x7fffffff; - return -x; - } + /* + ** Compute the absolute value of a 32-bit signed integer, if possible. Or + ** if the integer has a value of -2147483648, return +2147483647 + */ + static int sqlite3AbsInt32( int x ) + { + if ( x >= 0 ) + return x; + if ( x == -2147483648) // 0x80000000 + return 0x7fffffff; + return -x; + } #if SQLITE_ENABLE_8_3_NAMES /* @@ -1475,5 +1673,5 @@ static void sqlite3FileSuffix3(string zBaseFilename, string z){ } #endif - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/vacuum_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/vacuum_c.cs index 40aa1c8e2..5d0df238b 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/vacuum_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/vacuum_c.cs @@ -1,199 +1,222 @@ +using System; using System.Diagnostics; +using System.Text; + +using Pgno = System.UInt32; using u32 = System.UInt32; -namespace Community.CsharpSqlite { - using sqlite3_stmt = Sqlite3.Vdbe; - - public partial class Sqlite3 { - /* - ** 2003 April 6 - ** - ** 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 contains code used to implement the VACUUM command. - ** - ** Most of the code in this file may be omitted by defining the - ** SQLITE_OMIT_VACUUM macro. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include "vdbeInt.h" +namespace Community.CsharpSqlite +{ + using sqlite3_stmt = Sqlite3.Vdbe; + + public partial class Sqlite3 + { + /* + ** 2003 April 6 + ** + ** 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 contains code used to implement the VACUUM command. + ** + ** Most of the code in this file may be omitted by defining the + ** SQLITE_OMIT_VACUUM macro. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include "vdbeInt.h" #if !SQLITE_OMIT_VACUUM && !SQLITE_OMIT_ATTACH - /* - ** Finalize a prepared statement. If there was an error, store the - ** text of the error message in *pzErrMsg. Return the result code. - */ - static int vacuumFinalize(sqlite3 db, sqlite3_stmt pStmt, string pzErrMsg) { - int rc; - rc = sqlite3VdbeFinalize(ref pStmt); - if (rc != 0) { - sqlite3SetString(ref pzErrMsg, db, sqlite3_errmsg(db)); - } - return rc; - } + /* +** Finalize a prepared statement. If there was an error, store the +** text of the error message in *pzErrMsg. Return the result code. +*/ + static int vacuumFinalize( sqlite3 db, sqlite3_stmt pStmt, string pzErrMsg ) + { + int rc; + rc = sqlite3VdbeFinalize( ref pStmt ); + if ( rc != 0 ) + { + sqlite3SetString( ref pzErrMsg, db, sqlite3_errmsg( db ) ); + } + return rc; + } - /* - ** Execute zSql on database db. Return an error code. - */ - static int execSql(sqlite3 db, string pzErrMsg, string zSql) { - sqlite3_stmt pStmt = null; + /* +** Execute zSql on database db. Return an error code. +*/ + static int execSql( sqlite3 db, string pzErrMsg, string zSql ) + { + sqlite3_stmt pStmt = null; #if !NDEBUG - int rc; - //VVA_ONLY( int rc; ) + int rc; + //VVA_ONLY( int rc; ) #endif - if (zSql == null) { - return SQLITE_NOMEM; - } - if (SQLITE_OK != sqlite3_prepare(db, zSql, -1, ref pStmt, 0)) { - sqlite3SetString(ref pzErrMsg, db, sqlite3_errmsg(db)); - return sqlite3_errcode(db); - } + if ( zSql == null ) + { + return SQLITE_NOMEM; + } + if ( SQLITE_OK != sqlite3_prepare( db, zSql, -1, ref pStmt, 0 ) ) + { + sqlite3SetString( ref pzErrMsg, db, sqlite3_errmsg( db ) ); + return sqlite3_errcode( db ); + } #if !NDEBUG - rc = sqlite3_step(pStmt); - //VVA_ONLY( rc = ) sqlite3_step(pStmt); - Debug.Assert(rc != SQLITE_ROW); + rc = sqlite3_step( pStmt ); + //VVA_ONLY( rc = ) sqlite3_step(pStmt); + Debug.Assert( rc != SQLITE_ROW ); #else sqlite3_step(pStmt); #endif - return vacuumFinalize(db, pStmt, pzErrMsg); - } + return vacuumFinalize( db, pStmt, pzErrMsg ); + } - /* - ** Execute zSql on database db. The statement returns exactly - ** one column. Execute this as SQL on the same database. - */ - static int execExecSql(sqlite3 db, string pzErrMsg, string zSql) { - sqlite3_stmt pStmt = null; - int rc; - - rc = sqlite3_prepare(db, zSql, -1, ref pStmt, 0); - if (rc != SQLITE_OK) - return rc; - - while (SQLITE_ROW == sqlite3_step(pStmt)) { - rc = execSql(db, pzErrMsg, sqlite3_column_text(pStmt, 0)); - if (rc != SQLITE_OK) { - vacuumFinalize(db, pStmt, pzErrMsg); - return rc; - } - } - - return vacuumFinalize(db, pStmt, pzErrMsg); - } + /* + ** Execute zSql on database db. The statement returns exactly + ** one column. Execute this as SQL on the same database. + */ + static int execExecSql( sqlite3 db, string pzErrMsg, string zSql ) + { + sqlite3_stmt pStmt = null; + int rc; - /* - ** 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. - ** - ** 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. - */ - static void sqlite3Vacuum(Parse pParse) { - Vdbe v = sqlite3GetVdbe(pParse); - if (v != null) { - sqlite3VdbeAddOp2(v, OP_Vacuum, 0, 0); - } - return; + rc = sqlite3_prepare( db, zSql, -1, ref pStmt, 0 ); + if ( rc != SQLITE_OK ) + return rc; + + while ( SQLITE_ROW == sqlite3_step( pStmt ) ) + { + rc = execSql( db, pzErrMsg, sqlite3_column_text( pStmt, 0 ) ); + if ( rc != SQLITE_OK ) + { + vacuumFinalize( db, pStmt, pzErrMsg ); + return rc; } + } - /* - ** This routine implements the OP_Vacuum opcode of the VDBE. - */ - static int sqlite3RunVacuum(ref string pzErrMsg, sqlite3 db) { - int rc = SQLITE_OK; /* Return code from service routines */ - Btree pMain; /* The database being vacuumed */ - Btree pTemp; /* The temporary database we vacuum into */ - string zSql = ""; /* SQL statements */ - int saved_flags; /* Saved value of the db.flags */ - int saved_nChange; /* Saved value of db.nChange */ - int saved_nTotalChange; /* Saved value of db.nTotalChange */ - dxTrace saved_xTrace; //void (*saved_xTrace)(void*,const char*); /* Saved db->xTrace */ - Db pDb = null; /* Database to detach at end of vacuum */ - bool isMemDb; /* True if vacuuming a :memory: database */ - int nRes; /* Bytes of reserved space at the end of each page */ - int nDb; /* Number of attached databases */ - - if (0 == db.autoCommit) { - sqlite3SetString(ref pzErrMsg, db, "cannot VACUUM from within a transaction"); - return SQLITE_ERROR; - } - if (db.activeVdbeCnt > 1) { - sqlite3SetString(ref pzErrMsg, db, "cannot VACUUM - SQL statements in progress"); - return SQLITE_ERROR; - } - - /* Save the current value of the database flags so that it can be - ** restored before returning. Then set the writable-schema flag, and - ** disable CHECK and foreign key constraints. */ - saved_flags = db.flags; - saved_nChange = db.nChange; - saved_nTotalChange = db.nTotalChange; - saved_xTrace = db.xTrace; - db.flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks | SQLITE_PreferBuiltin; - db.flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder); - - db.xTrace = null; - - pMain = db.aDb[0].pBt; - isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain)); - - /* Attach the temporary database as 'vacuum_db'. The synchronous pragma - ** can be set to 'off' for this file, as it is not recovered if a crash - ** occurs anyway. The integrity of the database is maintained by a - ** (possibly synchronous) transaction opened on the main database before - ** sqlite3BtreeCopyFile() is called. - ** - ** An optimisation would be to use a non-journaled pager. - ** (Later:) I tried setting "PRAGMA vacuum_db.journal_mode=OFF" but - ** that actually made the VACUUM run slower. Very little journalling - ** actually occurs when doing a vacuum since the vacuum_db is initially - ** empty. Only the journal header is written. Apparently it takes more - ** time to parse and run the PRAGMA to turn journalling off than it does - ** to write the journal header file. - */ - nDb = db.nDb; - if (sqlite3TempInMemory(db)) { - zSql = "ATTACH ':memory:' AS vacuum_db;"; - } else { - zSql = "ATTACH '' AS vacuum_db;"; - } - rc = execSql(db, pzErrMsg, zSql); - if (db.nDb > nDb) { - pDb = db.aDb[db.nDb - 1]; - Debug.Assert(pDb.zName == "vacuum_db"); - } - if (rc != SQLITE_OK) - goto end_of_vacuum; - pDb = db.aDb[db.nDb - 1]; - Debug.Assert(db.aDb[db.nDb - 1].zName == "vacuum_db"); - pTemp = db.aDb[db.nDb - 1].pBt; - - /* The call to execSql() to attach the temp database has left the file - ** locked (as there was more than one active statement when the transaction - ** to read the schema was concluded. Unlock it here so that this doesn't - ** cause problems for the call to BtreeSetPageSize() below. */ - sqlite3BtreeCommit(pTemp); - - nRes = sqlite3BtreeGetReserve(pMain); - - /* A VACUUM cannot change the pagesize of an encrypted database. */ + return vacuumFinalize( db, pStmt, pzErrMsg ); + } + + /* + ** 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. + ** + ** 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. + */ + static void sqlite3Vacuum( Parse pParse ) + { + Vdbe v = sqlite3GetVdbe( pParse ); + if ( v != null ) + { + sqlite3VdbeAddOp2( v, OP_Vacuum, 0, 0 ); + } + return; + } + + /* + ** This routine implements the OP_Vacuum opcode of the VDBE. + */ + static int sqlite3RunVacuum( ref string pzErrMsg, sqlite3 db ) + { + int rc = SQLITE_OK; /* Return code from service routines */ + Btree pMain; /* The database being vacuumed */ + Btree pTemp; /* The temporary database we vacuum into */ + string zSql = ""; /* SQL statements */ + int saved_flags; /* Saved value of the db.flags */ + int saved_nChange; /* Saved value of db.nChange */ + int saved_nTotalChange; /* Saved value of db.nTotalChange */ + dxTrace saved_xTrace; //void (*saved_xTrace)(void*,const char*); /* Saved db->xTrace */ + Db pDb = null; /* Database to detach at end of vacuum */ + bool isMemDb; /* True if vacuuming a :memory: database */ + int nRes; /* Bytes of reserved space at the end of each page */ + int nDb; /* Number of attached databases */ + + if ( 0 == db.autoCommit ) + { + sqlite3SetString( ref pzErrMsg, db, "cannot VACUUM from within a transaction" ); + return SQLITE_ERROR; + } + if ( db.activeVdbeCnt > 1 ) + { + sqlite3SetString( ref pzErrMsg, db, "cannot VACUUM - SQL statements in progress" ); + return SQLITE_ERROR; + } + + /* Save the current value of the database flags so that it can be + ** restored before returning. Then set the writable-schema flag, and + ** disable CHECK and foreign key constraints. */ + saved_flags = db.flags; + saved_nChange = db.nChange; + saved_nTotalChange = db.nTotalChange; + saved_xTrace = db.xTrace; + db.flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks | SQLITE_PreferBuiltin; + db.flags &= ~( SQLITE_ForeignKeys | SQLITE_ReverseOrder ); + + db.xTrace = null; + + pMain = db.aDb[0].pBt; + isMemDb = sqlite3PagerIsMemdb( sqlite3BtreePager( pMain ) ); + + /* Attach the temporary database as 'vacuum_db'. The synchronous pragma + ** can be set to 'off' for this file, as it is not recovered if a crash + ** occurs anyway. The integrity of the database is maintained by a + ** (possibly synchronous) transaction opened on the main database before + ** sqlite3BtreeCopyFile() is called. + ** + ** An optimisation would be to use a non-journaled pager. + ** (Later:) I tried setting "PRAGMA vacuum_db.journal_mode=OFF" but + ** that actually made the VACUUM run slower. Very little journalling + ** actually occurs when doing a vacuum since the vacuum_db is initially + ** empty. Only the journal header is written. Apparently it takes more + ** time to parse and run the PRAGMA to turn journalling off than it does + ** to write the journal header file. + */ + nDb = db.nDb; + if ( sqlite3TempInMemory( db ) ) + { + zSql = "ATTACH ':memory:' AS vacuum_db;"; + } + else + { + zSql = "ATTACH '' AS vacuum_db;"; + } + rc = execSql( db, pzErrMsg, zSql ); + if ( db.nDb > nDb ) + { + pDb = db.aDb[db.nDb - 1]; + Debug.Assert( pDb.zName == "vacuum_db" ); + } + if ( rc != SQLITE_OK ) + goto end_of_vacuum; + pDb = db.aDb[db.nDb - 1]; + Debug.Assert( db.aDb[db.nDb - 1].zName == "vacuum_db" ); + pTemp = db.aDb[db.nDb - 1].pBt; + + /* The call to execSql() to attach the temp database has left the file + ** locked (as there was more than one active statement when the transaction + ** to read the schema was concluded. Unlock it here so that this doesn't + ** cause problems for the call to BtreeSetPageSize() below. */ + sqlite3BtreeCommit( pTemp ); + + nRes = sqlite3BtreeGetReserve( pMain ); + + /* A VACUUM cannot change the pagesize of an encrypted database. */ #if SQLITE_HAS_CODEC if ( db.nextPagesize != 0 ) { @@ -206,182 +229,187 @@ static int sqlite3RunVacuum(ref string pzErrMsg, sqlite3 db) { } #endif - /* Do not attempt to change the page size for a WAL database */ - if (sqlite3PagerGetJournalMode(sqlite3BtreePager(pMain)) - == PAGER_JOURNALMODE_WAL) { - db.nextPagesize = 0; - } - - if (sqlite3BtreeSetPageSize(pTemp, sqlite3BtreeGetPageSize(pMain), nRes, 0) != 0 - || (!isMemDb && sqlite3BtreeSetPageSize(pTemp, db.nextPagesize, nRes, 0) != 0) - //|| NEVER( db.mallocFailed != 0 ) - ) { - rc = SQLITE_NOMEM; - goto end_of_vacuum; - } - rc = execSql(db, pzErrMsg, "PRAGMA vacuum_db.synchronous=OFF"); - if (rc != SQLITE_OK) { - goto end_of_vacuum; - } + /* Do not attempt to change the page size for a WAL database */ + if ( sqlite3PagerGetJournalMode( sqlite3BtreePager( pMain ) ) + == PAGER_JOURNALMODE_WAL ) + { + db.nextPagesize = 0; + } + + if ( sqlite3BtreeSetPageSize( pTemp, sqlite3BtreeGetPageSize( pMain ), nRes, 0 ) != 0 + || ( !isMemDb && sqlite3BtreeSetPageSize( pTemp, db.nextPagesize, nRes, 0 ) != 0 ) + //|| NEVER( db.mallocFailed != 0 ) + ) + { + rc = SQLITE_NOMEM; + goto end_of_vacuum; + } + rc = execSql( db, pzErrMsg, "PRAGMA vacuum_db.synchronous=OFF" ); + if ( rc != SQLITE_OK ) + { + goto end_of_vacuum; + } #if !SQLITE_OMIT_AUTOVACUUM - sqlite3BtreeSetAutoVacuum(pTemp, db.nextAutovac >= 0 ? db.nextAutovac : - sqlite3BtreeGetAutoVacuum(pMain)); + sqlite3BtreeSetAutoVacuum( pTemp, db.nextAutovac >= 0 ? db.nextAutovac : + sqlite3BtreeGetAutoVacuum( pMain ) ); #endif - /* Begin a transaction */ - rc = execSql(db, pzErrMsg, "BEGIN EXCLUSIVE;"); - if (rc != SQLITE_OK) - goto end_of_vacuum; - - /* Query the schema of the main database. Create a mirror schema - ** in the temporary database. - */ - rc = execExecSql(db, pzErrMsg, - "SELECT 'CREATE TABLE vacuum_db.' || substr(sql,14) " + - " FROM sqlite_master WHERE type='table' AND name!='sqlite_sequence'" + - " AND rootpage>0" - ); - if (rc != SQLITE_OK) - goto end_of_vacuum; - rc = execExecSql(db, pzErrMsg, - "SELECT 'CREATE INDEX vacuum_db.' || substr(sql,14)" + - " FROM sqlite_master WHERE sql LIKE 'CREATE INDEX %' "); - if (rc != SQLITE_OK) - goto end_of_vacuum; - rc = execExecSql(db, pzErrMsg, - "SELECT 'CREATE UNIQUE INDEX vacuum_db.' || substr(sql,21) " + - " FROM sqlite_master WHERE sql LIKE 'CREATE UNIQUE INDEX %'"); - if (rc != SQLITE_OK) - goto end_of_vacuum; - - /* Loop through the tables in the main database. For each, do - ** an "INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;" to copy - ** the contents to the temporary database. - */ - rc = execExecSql(db, pzErrMsg, - "SELECT 'INSERT INTO vacuum_db.' || quote(name) " + - "|| ' SELECT * FROM main.' || quote(name) || ';'" + - "FROM main.sqlite_master " + - "WHERE type = 'table' AND name!='sqlite_sequence' " + - " AND rootpage>0" - - ); - if (rc != SQLITE_OK) - goto end_of_vacuum; - - /* Copy over the sequence table - */ - rc = execExecSql(db, pzErrMsg, - "SELECT 'DELETE FROM vacuum_db.' || quote(name) || ';' " + - "FROM vacuum_db.sqlite_master WHERE name='sqlite_sequence' " - ); - if (rc != SQLITE_OK) - goto end_of_vacuum; - rc = execExecSql(db, pzErrMsg, - "SELECT 'INSERT INTO vacuum_db.' || quote(name) " + - "|| ' SELECT * FROM main.' || quote(name) || ';' " + - "FROM vacuum_db.sqlite_master WHERE name=='sqlite_sequence';" - ); - if (rc != SQLITE_OK) - goto end_of_vacuum; - - - /* Copy the triggers, views, and virtual tables from the main database - ** over to the temporary database. None of these objects has any - ** associated storage, so all we have to do is copy their entries - ** from the SQLITE_MASTER table. - */ - rc = execSql(db, pzErrMsg, - "INSERT INTO vacuum_db.sqlite_master " + - " SELECT type, name, tbl_name, rootpage, sql" + - " FROM main.sqlite_master" + - " WHERE type='view' OR type='trigger'" + - " OR (type='table' AND rootpage=0)" - ); - if (rc != 0) - goto end_of_vacuum; - - /* At this point, unless the main db was completely empty, there is now a - ** transaction open on the vacuum database, but not on the main database. - ** Open a btree level transaction on the main database. This allows a - ** call to sqlite3BtreeCopyFile(). The main database btree level - ** transaction is then committed, so the SQL level never knows it was - ** opened for writing. This way, the SQL transaction used to create the - ** temporary database never needs to be committed. - */ - { - u32 meta = 0; - int i; - - /* This array determines which meta meta values are preserved in the - ** vacuum. Even entries are the meta value number and odd entries - ** are an increment to apply to the meta value after the vacuum. - ** The increment is used to increase the schema cookie so that other - ** connections to the same database will know to reread the schema. - */ - byte[] aCopy = new byte[] { + /* Begin a transaction */ + rc = execSql( db, pzErrMsg, "BEGIN EXCLUSIVE;" ); + if ( rc != SQLITE_OK ) + goto end_of_vacuum; + + /* Query the schema of the main database. Create a mirror schema + ** in the temporary database. + */ + rc = execExecSql( db, pzErrMsg, + "SELECT 'CREATE TABLE vacuum_db.' || substr(sql,14) " + + " FROM sqlite_master WHERE type='table' AND name!='sqlite_sequence'" + + " AND rootpage>0" + ); + if ( rc != SQLITE_OK ) + goto end_of_vacuum; + rc = execExecSql( db, pzErrMsg, + "SELECT 'CREATE INDEX vacuum_db.' || substr(sql,14)" + + " FROM sqlite_master WHERE sql LIKE 'CREATE INDEX %' " ); + if ( rc != SQLITE_OK ) + goto end_of_vacuum; + rc = execExecSql( db, pzErrMsg, + "SELECT 'CREATE UNIQUE INDEX vacuum_db.' || substr(sql,21) " + + " FROM sqlite_master WHERE sql LIKE 'CREATE UNIQUE INDEX %'" ); + if ( rc != SQLITE_OK ) + goto end_of_vacuum; + + /* Loop through the tables in the main database. For each, do + ** an "INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;" to copy + ** the contents to the temporary database. + */ + rc = execExecSql( db, pzErrMsg, + "SELECT 'INSERT INTO vacuum_db.' || quote(name) " + + "|| ' SELECT * FROM main.' || quote(name) || ';'" + + "FROM main.sqlite_master " + + "WHERE type = 'table' AND name!='sqlite_sequence' " + + " AND rootpage>0" + + ); + if ( rc != SQLITE_OK ) + goto end_of_vacuum; + + /* Copy over the sequence table + */ + rc = execExecSql( db, pzErrMsg, + "SELECT 'DELETE FROM vacuum_db.' || quote(name) || ';' " + + "FROM vacuum_db.sqlite_master WHERE name='sqlite_sequence' " + ); + if ( rc != SQLITE_OK ) + goto end_of_vacuum; + rc = execExecSql( db, pzErrMsg, + "SELECT 'INSERT INTO vacuum_db.' || quote(name) " + + "|| ' SELECT * FROM main.' || quote(name) || ';' " + + "FROM vacuum_db.sqlite_master WHERE name=='sqlite_sequence';" + ); + if ( rc != SQLITE_OK ) + goto end_of_vacuum; + + + /* Copy the triggers, views, and virtual tables from the main database + ** over to the temporary database. None of these objects has any + ** associated storage, so all we have to do is copy their entries + ** from the SQLITE_MASTER table. + */ + rc = execSql( db, pzErrMsg, + "INSERT INTO vacuum_db.sqlite_master " + + " SELECT type, name, tbl_name, rootpage, sql" + + " FROM main.sqlite_master" + + " WHERE type='view' OR type='trigger'" + + " OR (type='table' AND rootpage=0)" + ); + if ( rc != 0 ) + goto end_of_vacuum; + + /* At this point, unless the main db was completely empty, there is now a + ** transaction open on the vacuum database, but not on the main database. + ** Open a btree level transaction on the main database. This allows a + ** call to sqlite3BtreeCopyFile(). The main database btree level + ** transaction is then committed, so the SQL level never knows it was + ** opened for writing. This way, the SQL transaction used to create the + ** temporary database never needs to be committed. + */ + { + u32 meta = 0; + int i; + + /* This array determines which meta meta values are preserved in the + ** vacuum. Even entries are the meta value number and odd entries + ** are an increment to apply to the meta value after the vacuum. + ** The increment is used to increase the schema cookie so that other + ** connections to the same database will know to reread the schema. + */ + byte[] aCopy = new byte[] { BTREE_SCHEMA_VERSION, 1, /* Add one to the old schema cookie */ BTREE_DEFAULT_CACHE_SIZE, 0, /* Preserve the default page cache size */ BTREE_TEXT_ENCODING, 0, /* Preserve the text encoding */ BTREE_USER_VERSION, 0, /* Preserve the user version */ }; - Debug.Assert(sqlite3BtreeIsInTrans(pTemp)); - Debug.Assert(sqlite3BtreeIsInTrans(pMain)); - - /* Copy Btree meta values */ - for (i = 0; i < ArraySize(aCopy); i += 2) { - /* GetMeta() and UpdateMeta() cannot fail in this context because - ** we already have page 1 loaded into cache and marked dirty. */ - sqlite3BtreeGetMeta(pMain, aCopy[i], ref meta); - rc = sqlite3BtreeUpdateMeta(pTemp, aCopy[i], (u32)(meta + aCopy[i + 1])); - if (NEVER(rc != SQLITE_OK)) - goto end_of_vacuum; - } - - rc = sqlite3BtreeCopyFile(pMain, pTemp); - if (rc != SQLITE_OK) - goto end_of_vacuum; - rc = sqlite3BtreeCommit(pTemp); - if (rc != SQLITE_OK) - goto end_of_vacuum; + Debug.Assert( sqlite3BtreeIsInTrans( pTemp ) ); + Debug.Assert( sqlite3BtreeIsInTrans( pMain ) ); + + /* Copy Btree meta values */ + for ( i = 0; i < ArraySize( aCopy ); i += 2 ) + { + /* GetMeta() and UpdateMeta() cannot fail in this context because + ** we already have page 1 loaded into cache and marked dirty. */ + sqlite3BtreeGetMeta( pMain, aCopy[i], ref meta ); + rc = sqlite3BtreeUpdateMeta( pTemp, aCopy[i], (u32)( meta + aCopy[i + 1] ) ); + if ( NEVER( rc != SQLITE_OK ) ) + goto end_of_vacuum; + } + + rc = sqlite3BtreeCopyFile( pMain, pTemp ); + if ( rc != SQLITE_OK ) + goto end_of_vacuum; + rc = sqlite3BtreeCommit( pTemp ); + if ( rc != SQLITE_OK ) + goto end_of_vacuum; #if !SQLITE_OMIT_AUTOVACUUM - sqlite3BtreeSetAutoVacuum(pMain, sqlite3BtreeGetAutoVacuum(pTemp)); + sqlite3BtreeSetAutoVacuum( pMain, sqlite3BtreeGetAutoVacuum( pTemp ) ); #endif - } - Debug.Assert(rc == SQLITE_OK); - rc = sqlite3BtreeSetPageSize(pMain, sqlite3BtreeGetPageSize(pTemp), nRes, 1); - - end_of_vacuum: - /* Restore the original value of db.flags */ - db.flags = saved_flags; - db.nChange = saved_nChange; - db.nTotalChange = saved_nTotalChange; - db.xTrace = saved_xTrace; - sqlite3BtreeSetPageSize(pMain, -1, -1, 1); - - /* Currently there is an SQL level transaction open on the vacuum - ** database. No locks are held on any other files (since the main file - ** was committed at the btree level). So it safe to end the transaction - ** by manually setting the autoCommit flag to true and detaching the - ** vacuum database. The vacuum_db journal file is deleted when the pager - ** is closed by the DETACH. - */ - db.autoCommit = 1; - - if (pDb != null) { - sqlite3BtreeClose(ref pDb.pBt); - pDb.pBt = null; - pDb.pSchema = null; - } - - /* This both clears the schemas and reduces the size of the db->aDb[] - ** array. */ - sqlite3ResetInternalSchema(db, -1); - - return rc; - } -#endif // * SQLITE_OMIT_VACUUM && SQLITE_OMIT_ATTACH */ + } + Debug.Assert( rc == SQLITE_OK ); + rc = sqlite3BtreeSetPageSize( pMain, sqlite3BtreeGetPageSize( pTemp ), nRes, 1 ); + +end_of_vacuum: + /* Restore the original value of db.flags */ + db.flags = saved_flags; + db.nChange = saved_nChange; + db.nTotalChange = saved_nTotalChange; + db.xTrace = saved_xTrace; + sqlite3BtreeSetPageSize( pMain, -1, -1, 1 ); + + /* Currently there is an SQL level transaction open on the vacuum + ** database. No locks are held on any other files (since the main file + ** was committed at the btree level). So it safe to end the transaction + ** by manually setting the autoCommit flag to true and detaching the + ** vacuum database. The vacuum_db journal file is deleted when the pager + ** is closed by the DETACH. + */ + db.autoCommit = 1; + + if ( pDb != null ) + { + sqlite3BtreeClose( ref pDb.pBt ); + pDb.pBt = null; + pDb.pSchema = null; + } + + /* This both clears the schemas and reduces the size of the db->aDb[] + ** array. */ + sqlite3ResetInternalSchema( db, -1 ); + + return rc; } +#endif // * SQLITE_OMIT_VACUUM && SQLITE_OMIT_ATTACH */ + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/vdbe_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/vdbe_c.cs index 39de09c6d..adba5fe7a 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/vdbe_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/vdbe_c.cs @@ -1,7 +1,10 @@ using System.Diagnostics; +using System.IO; using System.Text; using FILE = System.IO.TextWriter; + +using i32 = System.Int32; using i64 = System.Int64; using sqlite_int64 = System.Int64; @@ -9,6 +12,10 @@ using u16 = System.UInt16; using u32 = System.UInt32; using u64 = System.UInt64; + +using sqlite3_int64 = System.Int64; + +using Pgno = System.UInt32; /* ** The yDbMask datatype for the bitmask of all attached databases. */ @@ -20,91 +27,93 @@ using yDbMask = System.Int32; #endif -namespace Community.CsharpSqlite { - using System; - - using Op = Sqlite3.VdbeOp; - using sqlite3_value = Sqlite3.Mem; - - public partial class Sqlite3 { - /* - ** 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. - ** - ************************************************************************* - ** The code in this file implements execution method of the - ** Virtual Database Engine (VDBE). A separate file ("vdbeaux.c") - ** handles housekeeping details such as creating and deleting - ** VDBE instances. This file is solely interested in executing - ** the VDBE program. - ** - ** In the external interface, an "sqlite3_stmt*" is an opaque pointer - ** to a VDBE. - ** - ** The SQL parser generates a program which is then executed by - ** the VDBE to do the work of the SQL statement. VDBE programs are - ** similar in form to assembly language. The program consists of - ** a linear sequence of operations. Each operation has an opcode - ** and 5 operands. Operands P1, P2, and P3 are integers. Operand P4 - ** is a null-terminated string. Operand P5 is an unsigned character. - ** Few opcodes use all 5 operands. - ** - ** Computation results are stored on a set of registers numbered beginning - ** with 1 and going up to Vdbe.nMem. Each register can store - ** either an integer, a null-terminated string, a floating point - ** number, or the SQL "NULL" value. An implicit conversion from one - ** type to the other occurs as necessary. - ** - ** Most of the code in this file is taken up by the sqlite3VdbeExec() - ** function which does the work of interpreting a VDBE program. - ** But other routines are also provided to help in building up - ** a program instruction by instruction. - ** - ** Various scripts scan this source file in order to generate HTML - ** documentation, headers files, or other derived files. The formatting - ** of the code in this file is, therefore, important. See other comments - ** in this file for details. If in doubt, do not deviate from existing - ** commenting and indentation practices when changing or adding code. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include "vdbeInt.h" +namespace Community.CsharpSqlite +{ + using sqlite3_value = Sqlite3.Mem; + using Op = Sqlite3.VdbeOp; + using System; - /* - ** Invoke this macro on memory cells just prior to changing the - ** value of the cell. This macro verifies that shallow copies are - ** not misused. - */ + public partial class Sqlite3 + { + /* + ** 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. + ** + ************************************************************************* + ** The code in this file implements execution method of the + ** Virtual Database Engine (VDBE). A separate file ("vdbeaux.c") + ** handles housekeeping details such as creating and deleting + ** VDBE instances. This file is solely interested in executing + ** the VDBE program. + ** + ** In the external interface, an "sqlite3_stmt*" is an opaque pointer + ** to a VDBE. + ** + ** The SQL parser generates a program which is then executed by + ** the VDBE to do the work of the SQL statement. VDBE programs are + ** similar in form to assembly language. The program consists of + ** a linear sequence of operations. Each operation has an opcode + ** and 5 operands. Operands P1, P2, and P3 are integers. Operand P4 + ** is a null-terminated string. Operand P5 is an unsigned character. + ** Few opcodes use all 5 operands. + ** + ** Computation results are stored on a set of registers numbered beginning + ** with 1 and going up to Vdbe.nMem. Each register can store + ** either an integer, a null-terminated string, a floating point + ** number, or the SQL "NULL" value. An implicit conversion from one + ** type to the other occurs as necessary. + ** + ** Most of the code in this file is taken up by the sqlite3VdbeExec() + ** function which does the work of interpreting a VDBE program. + ** But other routines are also provided to help in building up + ** a program instruction by instruction. + ** + ** Various scripts scan this source file in order to generate HTML + ** documentation, headers files, or other derived files. The formatting + ** of the code in this file is, therefore, important. See other comments + ** in this file for details. If in doubt, do not deviate from existing + ** commenting and indentation practices when changing or adding code. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include "vdbeInt.h" + + /* + ** Invoke this macro on memory cells just prior to changing the + ** value of the cell. This macro verifies that shallow copies are + ** not misused. + */ #if SQLITE_DEBUG - //# define memAboutToChange(P,M) sqlite3VdbeMemPrepareToChange(P,M) - static void memAboutToChange(Vdbe P, Mem M) { - sqlite3VdbeMemPrepareToChange(P, M); - } + //# define memAboutToChange(P,M) sqlite3VdbeMemPrepareToChange(P,M) + static void memAboutToChange( Vdbe P, Mem M ) + { + sqlite3VdbeMemPrepareToChange( P, M ); + } #else //# define memAboutToChange(P,M) static void memAboutToChange(Vdbe P, Mem M) {} #endif - /* - ** The following global variable is incremented every time a cursor - ** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes. The test - ** procedures use this information to make sure that indices are - ** working correctly. This variable has no function other than to - ** help verify the correct operation of the library. - */ -#if SQLITE_TEST + /* +** The following global variable is incremented every time a cursor +** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes. The test +** procedures use this information to make sure that indices are +** working correctly. This variable has no function other than to +** help verify the correct operation of the library. +*/ +#if SQLITE_TEST #if !TCLSH static int sqlite3_search_count = 0; #else @@ -112,14 +121,14 @@ static void memAboutToChange(Vdbe P, Mem M) {} #endif #endif - /* - ** When this global variable is positive, it gets decremented once before - ** each instruction in the VDBE. When reaches zero, the u1.isInterrupted - ** field of the sqlite3 structure is set in order to simulate and interrupt. - ** - ** This facility is used for testing purposes only. It does not function - ** in an ordinary build. - */ + /* +** When this global variable is positive, it gets decremented once before +** each instruction in the VDBE. When reaches zero, the u1.isInterrupted +** field of the sqlite3 structure is set in order to simulate and interrupt. +** +** This facility is used for testing purposes only. It does not function +** in an ordinary build. +*/ #if SQLITE_TEST #if !TCLSH static int sqlite3_interrupt_count = 0; @@ -128,13 +137,13 @@ static void memAboutToChange(Vdbe P, Mem M) {} #endif #endif - /* - ** The next global variable is incremented each type the OP_Sort opcode - ** is executed. The test procedures use this information to make sure that - ** sorting is occurring or not occurring at appropriate times. This variable - ** has no function other than to help verify the correct operation of the - ** library. - */ + /* +** The next global variable is incremented each type the OP_Sort opcode +** is executed. The test procedures use this information to make sure that +** sorting is occurring or not occurring at appropriate times. This variable +** has no function other than to help verify the correct operation of the +** library. +*/ #if SQLITE_TEST #if !TCLSH static int sqlite3_sort_count = 0; @@ -143,13 +152,13 @@ static void memAboutToChange(Vdbe P, Mem M) {} #endif #endif - /* - ** The next global variable records the size of the largest MEM_Blob - ** or MEM_Str that has been used by a VDBE opcode. The test procedures - ** use this information to make sure that the zero-blob functionality - ** is working correctly. This variable has no function other than to - ** help verify the correct operation of the library. - */ + /* +** The next global variable records the size of the largest MEM_Blob +** or MEM_Str that has been used by a VDBE opcode. The test procedures +** use this information to make sure that the zero-blob functionality +** is working correctly. This variable has no function other than to +** help verify the correct operation of the library. +*/ #if SQLITE_TEST #if !TCLSH static int sqlite3_max_blobsize = 0; @@ -173,13 +182,13 @@ static void updateMaxBlobsize( Mem p ) } #endif - /* - ** The next global variable is incremented each type the OP_Found opcode - ** is executed. This is used to test whether or not the foreign key - ** operation implemented using OP_FkIsZero is working. This variable - ** has no function other than to help verify the correct operation of the - ** library. - */ + /* +** The next global variable is incremented each type the OP_Found opcode +** is executed. This is used to test whether or not the foreign key +** operation implemented using OP_FkIsZero is working. This variable +** has no function other than to help verify the correct operation of the +** library. +*/ #if SQLITE_TEST #if !TCLSH static int sqlite3_found_count = 0; @@ -188,365 +197,435 @@ static void updateMaxBlobsize( Mem p ) #endif #endif - /* /* - ** Test a register to see if it exceeds the current maximum blob size. - ** If it does, record the new maximum blob size. - */ +/* +** Test a register to see if it exceeds the current maximum blob size. +** If it does, record the new maximum blob size. +*/ #if SQLITE_TEST && !SQLITE_OMIT_BUILTIN_TEST static void UPDATE_MAX_BLOBSIZE( Mem P ) { updateMaxBlobsize( P ); } #else - //# define UPDATE_MAX_BLOBSIZE(P) - static void UPDATE_MAX_BLOBSIZE(Mem P) { } +//# define UPDATE_MAX_BLOBSIZE(P) +static void UPDATE_MAX_BLOBSIZE( Mem P ) { } #endif - /* - ** Convert the given register into a string if it isn't one - ** already. Return non-zero if a malloc() fails. + /* +** Convert the given register into a string if it isn't one +** already. Return non-zero if a malloc() fails. +*/ + //#define Stringify(P, enc) \ + // if(((P).flags&(MEM_Str|MEM_Blob))==0 && sqlite3VdbeMemStringify(P,enc)) \ + // { goto no_mem; } + + /* + ** An ephemeral string value (signified by the MEM_Ephem flag) contains + ** a pointer to a dynamically allocated string where some other entity + ** is responsible for deallocating that string. Because the register + ** does not control the string, it might be deleted without the register + ** knowing it. + ** + ** This routine converts an ephemeral string into a dynamically allocated + ** string that the register itself controls. In other words, it + ** converts an MEM_Ephem string into an MEM_Dyn string. */ - //#define Stringify(P, enc) \ - // if(((P).flags&(MEM_Str|MEM_Blob))==0 && sqlite3VdbeMemStringify(P,enc)) \ - // { goto no_mem; } - - /* - ** An ephemeral string value (signified by the MEM_Ephem flag) contains - ** a pointer to a dynamically allocated string where some other entity - ** is responsible for deallocating that string. Because the register - ** does not control the string, it might be deleted without the register - ** knowing it. - ** - ** This routine converts an ephemeral string into a dynamically allocated - ** string that the register itself controls. In other words, it - ** converts an MEM_Ephem string into an MEM_Dyn string. - */ - //#define Deephemeralize(P) \ - // if( ((P).flags&MEM_Ephem)!=0 \ - // && sqlite3VdbeMemMakeWriteable(P) ){ goto no_mem;} - static void Deephemeralize(Mem P) { - } + //#define Deephemeralize(P) \ + // if( ((P).flags&MEM_Ephem)!=0 \ + // && sqlite3VdbeMemMakeWriteable(P) ){ goto no_mem;} + static void Deephemeralize( Mem P ) + { + } - /* - ** Call sqlite3VdbeMemExpandBlob() on the supplied value (type Mem) - ** P if required. - */ - //#define ExpandBlob(P) (((P).flags&MEM_Zero)?sqlite3VdbeMemExpandBlob(P):0) - static int ExpandBlob(Mem P) { - return (P.flags & MEM_Zero) != 0 ? sqlite3VdbeMemExpandBlob(P) : 0; - } + /* + ** Call sqlite3VdbeMemExpandBlob() on the supplied value (type Mem) + ** P if required. + */ + //#define ExpandBlob(P) (((P).flags&MEM_Zero)?sqlite3VdbeMemExpandBlob(P):0) + static int ExpandBlob( Mem P ) + { + return ( P.flags & MEM_Zero ) != 0 ? sqlite3VdbeMemExpandBlob( P ) : 0; + } - /* - ** Argument pMem points at a register that will be passed to a - ** user-defined function or returned to the user as the result of a query. - ** This routine sets the pMem.type variable used by the sqlite3_value_*() - ** routines. - */ - static void sqlite3VdbeMemStoreType(Mem pMem) { - int flags = pMem.flags; - if ((flags & MEM_Null) != 0) { - pMem.type = SQLITE_NULL; - pMem.z = null; - pMem.zBLOB = null; - } else if ((flags & MEM_Int) != 0) { - pMem.type = SQLITE_INTEGER; - } else if ((flags & MEM_Real) != 0) { - pMem.type = SQLITE_FLOAT; - } else if ((flags & MEM_Str) != 0) { - pMem.type = SQLITE_TEXT; - } else { - pMem.type = SQLITE_BLOB; - } - } + /* + ** Argument pMem points at a register that will be passed to a + ** user-defined function or returned to the user as the result of a query. + ** This routine sets the pMem.type variable used by the sqlite3_value_*() + ** routines. + */ + static void sqlite3VdbeMemStoreType( Mem pMem ) + { + int flags = pMem.flags; + if ( ( flags & MEM_Null ) != 0 ) + { + pMem.type = SQLITE_NULL; + pMem.z = null; + pMem.zBLOB = null; + } + else if ( ( flags & MEM_Int ) != 0 ) + { + pMem.type = SQLITE_INTEGER; + } + else if ( ( flags & MEM_Real ) != 0 ) + { + pMem.type = SQLITE_FLOAT; + } + else if ( ( flags & MEM_Str ) != 0 ) + { + pMem.type = SQLITE_TEXT; + } + else + { + pMem.type = SQLITE_BLOB; + } + } - /* - ** Allocate VdbeCursor number iCur. Return a pointer to it. Return NULL - ** if we run out of memory. - */ - static VdbeCursor allocateCursor( - Vdbe p, /* The virtual machine */ - int iCur, /* Index of the new VdbeCursor */ - int nField, /* Number of fields in the table or index */ - int iDb, /* When database the cursor belongs to, or -1 */ - int isBtreeCursor /* True for B-Tree. False for pseudo-table or vtab */ - ) { - /* Find the memory cell that will be used to store the blob of memory - ** required for this VdbeCursor structure. It is convenient to use a - ** vdbe memory cell to manage the memory allocation required for a - ** VdbeCursor structure for the following reasons: - ** - ** * Sometimes cursor numbers are used for a couple of different - ** purposes in a vdbe program. The different uses might require - ** different sized allocations. Memory cells provide growable - ** allocations. - ** - ** * When using ENABLE_MEMORY_MANAGEMENT, memory cell buffers can - ** be freed lazily via the sqlite3_release_memory() API. This - ** minimizes the number of malloc calls made by the system. - ** - ** Memory cells for cursors are allocated at the top of the address - ** space. Memory cell (p.nMem) corresponds to cursor 0. Space for - ** cursor 1 is managed by memory cell (p.nMem-1), etc. - */ - //Mem pMem = p.aMem[p.nMem - iCur]; - - //int nByte; - VdbeCursor pCx = null; - //ROUND8(sizeof(VdbeCursor)) + - //( isBtreeCursor ? sqlite3BtreeCursorSize() : 0 ) + - //2 * nField * sizeof( u32 ); - - Debug.Assert(iCur < p.nCursor); - if (p.apCsr[iCur] != null) { - sqlite3VdbeFreeCursor(p, p.apCsr[iCur]); - p.apCsr[iCur] = null; - } - //if ( SQLITE_OK == sqlite3VdbeMemGrow( pMem, nByte, 0 ) ) - { - p.apCsr[iCur] = pCx = new VdbeCursor();// (VdbeCursor)pMem.z; - //memset(pCx, 0, sizeof(VdbeCursor)); - pCx.iDb = iDb; - pCx.nField = nField; - if (nField != 0) { - pCx.aType = new u32[nField];// (u32)&pMem.z[ROUND8(sizeof( VdbeCursor ))]; - } - if (isBtreeCursor != 0) { - pCx.pCursor = sqlite3MemMallocBtCursor(pCx.pCursor);// (BtCursor)&pMem.z[ROUND8(sizeof( VdbeCursor )) + 2 * nField * sizeof( u32 )]; - sqlite3BtreeCursorZero(pCx.pCursor); - } - } - return pCx; + /* + ** Allocate VdbeCursor number iCur. Return a pointer to it. Return NULL + ** if we run out of memory. + */ + static VdbeCursor allocateCursor( + Vdbe p, /* The virtual machine */ + int iCur, /* Index of the new VdbeCursor */ + int nField, /* Number of fields in the table or index */ + int iDb, /* When database the cursor belongs to, or -1 */ + int isBtreeCursor /* True for B-Tree. False for pseudo-table or vtab */ + ) + { + /* Find the memory cell that will be used to store the blob of memory + ** required for this VdbeCursor structure. It is convenient to use a + ** vdbe memory cell to manage the memory allocation required for a + ** VdbeCursor structure for the following reasons: + ** + ** * Sometimes cursor numbers are used for a couple of different + ** purposes in a vdbe program. The different uses might require + ** different sized allocations. Memory cells provide growable + ** allocations. + ** + ** * When using ENABLE_MEMORY_MANAGEMENT, memory cell buffers can + ** be freed lazily via the sqlite3_release_memory() API. This + ** minimizes the number of malloc calls made by the system. + ** + ** Memory cells for cursors are allocated at the top of the address + ** space. Memory cell (p.nMem) corresponds to cursor 0. Space for + ** cursor 1 is managed by memory cell (p.nMem-1), etc. + */ + //Mem pMem = p.aMem[p.nMem - iCur]; + + //int nByte; + VdbeCursor pCx = null; + //ROUND8(sizeof(VdbeCursor)) + + //( isBtreeCursor ? sqlite3BtreeCursorSize() : 0 ) + + //2 * nField * sizeof( u32 ); + + Debug.Assert( iCur < p.nCursor ); + if ( p.apCsr[iCur] != null ) + { + sqlite3VdbeFreeCursor( p, p.apCsr[iCur] ); + p.apCsr[iCur] = null; + } + //if ( SQLITE_OK == sqlite3VdbeMemGrow( pMem, nByte, 0 ) ) + { + p.apCsr[iCur] = pCx = new VdbeCursor();// (VdbeCursor)pMem.z; + //memset(pCx, 0, sizeof(VdbeCursor)); + pCx.iDb = iDb; + pCx.nField = nField; + if ( nField != 0 ) + { + pCx.aType = new u32[nField];// (u32)&pMem.z[ROUND8(sizeof( VdbeCursor ))]; } - - /* - ** Try to convert a value into a numeric representation if we can - ** do so without loss of information. In other words, if the string - ** looks like a number, convert it into a number. If it does not - ** look like a number, leave it alone. - */ - static void applyNumericAffinity(Mem pRec) { - if ((pRec.flags & (MEM_Real | MEM_Int)) == 0) { - double rValue = 0.0; - i64 iValue = 0; - u8 enc = pRec.enc; - if ((pRec.flags & MEM_Str) == 0) - return; - if (sqlite3AtoF(pRec.z, ref rValue, pRec.n, enc) == false) - return; - if (0 == sqlite3Atoi64(pRec.z, ref iValue, pRec.n, enc)) { - pRec.u.i = iValue; - pRec.flags |= MEM_Int; - } else { - pRec.r = rValue; - pRec.flags |= MEM_Real; - } - } + if ( isBtreeCursor != 0 ) + { + pCx.pCursor = sqlite3MemMallocBtCursor( pCx.pCursor );// (BtCursor)&pMem.z[ROUND8(sizeof( VdbeCursor )) + 2 * nField * sizeof( u32 )]; + sqlite3BtreeCursorZero( pCx.pCursor ); } + } + return pCx; + } - /* - ** Processing is determine by the affinity parameter: - ** - ** SQLITE_AFF_INTEGER: - ** SQLITE_AFF_REAL: - ** SQLITE_AFF_NUMERIC: - ** Try to convert pRec to an integer representation or a - ** floating-point representation if an integer representation - ** is not possible. Note that the integer representation is - ** always preferred, even if the affinity is REAL, because - ** an integer representation is more space efficient on disk. - ** - ** SQLITE_AFF_TEXT: - ** Convert pRec to a text representation. - ** - ** SQLITE_AFF_NONE: - ** No-op. pRec is unchanged. - */ - static void applyAffinity( - Mem pRec, /* The value to apply affinity to */ - char affinity, /* The affinity to be applied */ - int enc /* Use this text encoding */ - ) { - if (affinity == SQLITE_AFF_TEXT) { - /* Only attempt the conversion to TEXT if there is an integer or real - ** representation (blob and NULL do not get converted) but no string - ** representation. - */ - if (0 == (pRec.flags & MEM_Str) && (pRec.flags & (MEM_Real | MEM_Int)) != 0) { - sqlite3VdbeMemStringify(pRec, enc); - } - if ((pRec.flags & (MEM_Blob | MEM_Str)) == (MEM_Blob | MEM_Str)) { - StringBuilder sb = new StringBuilder(pRec.zBLOB.Length); - for (int i = 0; i < pRec.zBLOB.Length; i++) - sb.Append((char)pRec.zBLOB[i]); - pRec.z = sb.ToString(); - sqlite3_free(ref pRec.zBLOB); - pRec.flags = (u16)(pRec.flags & ~MEM_Blob); - } - pRec.flags = (u16)(pRec.flags & ~(MEM_Real | MEM_Int)); - } else if (affinity != SQLITE_AFF_NONE) { - Debug.Assert(affinity == SQLITE_AFF_INTEGER || affinity == SQLITE_AFF_REAL - || affinity == SQLITE_AFF_NUMERIC); - applyNumericAffinity(pRec); - if ((pRec.flags & MEM_Real) != 0) { - sqlite3VdbeIntegerAffinity(pRec); - } - } + /* + ** Try to convert a value into a numeric representation if we can + ** do so without loss of information. In other words, if the string + ** looks like a number, convert it into a number. If it does not + ** look like a number, leave it alone. + */ + static void applyNumericAffinity( Mem pRec ) + { + if ( ( pRec.flags & ( MEM_Real | MEM_Int ) ) == 0 ) + { + double rValue = 0.0; + i64 iValue = 0; + u8 enc = pRec.enc; + if ( ( pRec.flags & MEM_Str ) == 0 ) + return; + if ( sqlite3AtoF( pRec.z, ref rValue, pRec.n, enc ) == false ) + return; + if ( 0 == sqlite3Atoi64( pRec.z, ref iValue, pRec.n, enc ) ) + { + pRec.u.i = iValue; + pRec.flags |= MEM_Int; } - - /* - ** Try to convert the type of a function argument or a result column - ** into a numeric representation. Use either INTEGER or REAL whichever - ** is appropriate. But only do the conversion if it is possible without - ** loss of information and return the revised type of the argument. - */ - static int sqlite3_value_numeric_type(sqlite3_value pVal) { - Mem pMem = (Mem)pVal; - if (pMem.type == SQLITE_TEXT) { - applyNumericAffinity(pMem); - sqlite3VdbeMemStoreType(pMem); - } - return pMem.type; + else + { + pRec.r = rValue; + pRec.flags |= MEM_Real; } + } + } - /* - ** Exported version of applyAffinity(). This one works on sqlite3_value*, - ** not the internal Mem type. + /* + ** Processing is determine by the affinity parameter: + ** + ** SQLITE_AFF_INTEGER: + ** SQLITE_AFF_REAL: + ** SQLITE_AFF_NUMERIC: + ** Try to convert pRec to an integer representation or a + ** floating-point representation if an integer representation + ** is not possible. Note that the integer representation is + ** always preferred, even if the affinity is REAL, because + ** an integer representation is more space efficient on disk. + ** + ** SQLITE_AFF_TEXT: + ** Convert pRec to a text representation. + ** + ** SQLITE_AFF_NONE: + ** No-op. pRec is unchanged. + */ + static void applyAffinity( + Mem pRec, /* The value to apply affinity to */ + char affinity, /* The affinity to be applied */ + int enc /* Use this text encoding */ + ) + { + if ( affinity == SQLITE_AFF_TEXT ) + { + /* Only attempt the conversion to TEXT if there is an integer or real + ** representation (blob and NULL do not get converted) but no string + ** representation. */ - static void sqlite3ValueApplyAffinity( - sqlite3_value pVal, - char affinity, - int enc - ) { - applyAffinity((Mem)pVal, affinity, enc); + if ( 0 == ( pRec.flags & MEM_Str ) && ( pRec.flags & ( MEM_Real | MEM_Int ) ) != 0 ) + { + sqlite3VdbeMemStringify( pRec, enc ); + } + if ( ( pRec.flags & ( MEM_Blob | MEM_Str ) ) == ( MEM_Blob | MEM_Str ) ) + { + StringBuilder sb = new StringBuilder( pRec.zBLOB.Length ); + for ( int i = 0; i < pRec.zBLOB.Length; i++ ) + sb.Append( (char)pRec.zBLOB[i] ); + pRec.z = sb.ToString(); + sqlite3_free( ref pRec.zBLOB ); + pRec.flags = (u16)( pRec.flags & ~MEM_Blob ); + } + pRec.flags = (u16)( pRec.flags & ~( MEM_Real | MEM_Int ) ); + } + else if ( affinity != SQLITE_AFF_NONE ) + { + Debug.Assert( affinity == SQLITE_AFF_INTEGER || affinity == SQLITE_AFF_REAL + || affinity == SQLITE_AFF_NUMERIC ); + applyNumericAffinity( pRec ); + if ( ( pRec.flags & MEM_Real ) != 0 ) + { + sqlite3VdbeIntegerAffinity( pRec ); } + } + } -#if SQLITE_DEBUG - /* - ** Write a nice string representation of the contents of cell pMem - ** into buffer zBuf, length nBuf. + /* + ** Try to convert the type of a function argument or a result column + ** into a numeric representation. Use either INTEGER or REAL whichever + ** is appropriate. But only do the conversion if it is possible without + ** loss of information and return the revised type of the argument. */ - static StringBuilder zCsr = new StringBuilder(100); - static void sqlite3VdbeMemPrettyPrint(Mem pMem, StringBuilder zBuf) { - zBuf.Length = 0; - zCsr.Length = 0; - int f = pMem.flags; - - string[] encnames = new string[] { "(X)", "(8)", "(16LE)", "(16BE)" }; - - if ((f & MEM_Blob) != 0) { - int i; - char c; - if ((f & MEM_Dyn) != 0) { - c = 'z'; - Debug.Assert((f & (MEM_Static | MEM_Ephem)) == 0); - } else if ((f & MEM_Static) != 0) { - c = 't'; - Debug.Assert((f & (MEM_Dyn | MEM_Ephem)) == 0); - } else if ((f & MEM_Ephem) != 0) { - c = 'e'; - Debug.Assert((f & (MEM_Static | MEM_Dyn)) == 0); - } else { - c = 's'; - } + static int sqlite3_value_numeric_type( sqlite3_value pVal ) + { + Mem pMem = (Mem)pVal; + if ( pMem.type == SQLITE_TEXT ) + { + applyNumericAffinity( pMem ); + sqlite3VdbeMemStoreType( pMem ); + } + return pMem.type; + } - sqlite3_snprintf(100, zCsr, "%c", c); - zBuf.Append(zCsr);//zCsr += sqlite3Strlen30(zCsr); - sqlite3_snprintf(100, zCsr, "%d[", pMem.n); - zBuf.Append(zCsr);//zCsr += sqlite3Strlen30(zCsr); - for (i = 0; i < 16 && i < pMem.n; i++) { - sqlite3_snprintf(100, zCsr, "%02X", ((int)pMem.zBLOB[i] & 0xFF)); - zBuf.Append(zCsr);//zCsr += sqlite3Strlen30(zCsr); - } - for (i = 0; i < 16 && i < pMem.n; i++) { - char z = (char)pMem.zBLOB[i]; - if (z < 32 || z > 126) - zBuf.Append('.');//*zCsr++ = '.'; - else - zBuf.Append(z);//*zCsr++ = z; - } + /* + ** Exported version of applyAffinity(). This one works on sqlite3_value*, + ** not the internal Mem type. + */ + static void sqlite3ValueApplyAffinity( + sqlite3_value pVal, + char affinity, + int enc + ) + { + applyAffinity( (Mem)pVal, affinity, enc ); + } - sqlite3_snprintf(100, zCsr, "]%s", encnames[pMem.enc]); - zBuf.Append(zCsr);//zCsr += sqlite3Strlen30(zCsr); - if ((f & MEM_Zero) != 0) { - sqlite3_snprintf(100, zCsr, "+%dz", pMem.u.nZero); - zBuf.Append(zCsr);//zCsr += sqlite3Strlen30(zCsr); - } - //*zCsr = '\0'; - } else if ((f & MEM_Str) != 0) { - int j;//, k; - zBuf.Append(' '); - if ((f & MEM_Dyn) != 0) { - zBuf.Append('z'); - Debug.Assert((f & (MEM_Static | MEM_Ephem)) == 0); - } else if ((f & MEM_Static) != 0) { - zBuf.Append('t'); - Debug.Assert((f & (MEM_Dyn | MEM_Ephem)) == 0); - } else if ((f & MEM_Ephem) != 0) { - zBuf.Append('s'); //zBuf.Append( 'e' ); - Debug.Assert((f & (MEM_Static | MEM_Dyn)) == 0); - } else { - zBuf.Append('s'); - } - //k = 2; - sqlite3_snprintf(100, zCsr, "%d", pMem.n);//zBuf[k], "%d", pMem.n ); - zBuf.Append(zCsr); - //k += sqlite3Strlen30( &zBuf[k] ); - zBuf.Append('[');// zBuf[k++] = '['; - for (j = 0; j < 15 && j < pMem.n; j++) { - u8 c = pMem.z != null ? (u8)pMem.z[j] : pMem.zBLOB[j]; - if (c >= 0x20 && c < 0x7f) { - zBuf.Append((char)c);//zBuf[k++] = c; - } else { - zBuf.Append('.');//zBuf[k++] = '.'; - } - } - zBuf.Append(']');//zBuf[k++] = ']'; - sqlite3_snprintf(100, zCsr, encnames[pMem.enc]);//& zBuf[k], encnames[pMem.enc] ); - zBuf.Append(zCsr); - //k += sqlite3Strlen30( &zBuf[k] ); - //zBuf[k++] = 0; - } +#if SQLITE_DEBUG + /* +** Write a nice string representation of the contents of cell pMem +** into buffer zBuf, length nBuf. +*/ + static StringBuilder zCsr = new StringBuilder( 100 ); + static void sqlite3VdbeMemPrettyPrint( Mem pMem, StringBuilder zBuf ) + { + zBuf.Length = 0; + zCsr.Length = 0; + int f = pMem.flags; + + string[] encnames = new string[] { "(X)", "(8)", "(16LE)", "(16BE)" }; + + if ( ( f & MEM_Blob ) != 0 ) + { + int i; + char c; + if ( ( f & MEM_Dyn ) != 0 ) + { + c = 'z'; + Debug.Assert( ( f & ( MEM_Static | MEM_Ephem ) ) == 0 ); + } + else if ( ( f & MEM_Static ) != 0 ) + { + c = 't'; + Debug.Assert( ( f & ( MEM_Dyn | MEM_Ephem ) ) == 0 ); + } + else if ( ( f & MEM_Ephem ) != 0 ) + { + c = 'e'; + Debug.Assert( ( f & ( MEM_Static | MEM_Dyn ) ) == 0 ); + } + else + { + c = 's'; + } + + sqlite3_snprintf( 100, zCsr, "%c", c ); + zBuf.Append( zCsr );//zCsr += sqlite3Strlen30(zCsr); + sqlite3_snprintf( 100, zCsr, "%d[", pMem.n ); + zBuf.Append( zCsr );//zCsr += sqlite3Strlen30(zCsr); + for ( i = 0; i < 16 && i < pMem.n; i++ ) + { + sqlite3_snprintf( 100, zCsr, "%02X", ( (int)pMem.zBLOB[i] & 0xFF ) ); + zBuf.Append( zCsr );//zCsr += sqlite3Strlen30(zCsr); + } + for ( i = 0; i < 16 && i < pMem.n; i++ ) + { + char z = (char)pMem.zBLOB[i]; + if ( z < 32 || z > 126 ) + zBuf.Append( '.' );//*zCsr++ = '.'; + else + zBuf.Append( z );//*zCsr++ = z; + } + + sqlite3_snprintf( 100, zCsr, "]%s", encnames[pMem.enc] ); + zBuf.Append( zCsr );//zCsr += sqlite3Strlen30(zCsr); + if ( ( f & MEM_Zero ) != 0 ) + { + sqlite3_snprintf( 100, zCsr, "+%dz", pMem.u.nZero ); + zBuf.Append( zCsr );//zCsr += sqlite3Strlen30(zCsr); + } + //*zCsr = '\0'; + } + else if ( ( f & MEM_Str ) != 0 ) + { + int j;//, k; + zBuf.Append( ' ' ); + if ( ( f & MEM_Dyn ) != 0 ) + { + zBuf.Append( 'z' ); + Debug.Assert( ( f & ( MEM_Static | MEM_Ephem ) ) == 0 ); + } + else if ( ( f & MEM_Static ) != 0 ) + { + zBuf.Append( 't' ); + Debug.Assert( ( f & ( MEM_Dyn | MEM_Ephem ) ) == 0 ); + } + else if ( ( f & MEM_Ephem ) != 0 ) + { + zBuf.Append( 's' ); //zBuf.Append( 'e' ); + Debug.Assert( ( f & ( MEM_Static | MEM_Dyn ) ) == 0 ); + } + else + { + zBuf.Append( 's' ); + } + //k = 2; + sqlite3_snprintf( 100, zCsr, "%d", pMem.n );//zBuf[k], "%d", pMem.n ); + zBuf.Append( zCsr ); + //k += sqlite3Strlen30( &zBuf[k] ); + zBuf.Append( '[' );// zBuf[k++] = '['; + for ( j = 0; j < 15 && j < pMem.n; j++ ) + { + u8 c = pMem.z != null ? (u8)pMem.z[j] : pMem.zBLOB[j]; + if ( c >= 0x20 && c < 0x7f ) + { + zBuf.Append( (char)c );//zBuf[k++] = c; + } + else + { + zBuf.Append( '.' );//zBuf[k++] = '.'; + } } + zBuf.Append( ']' );//zBuf[k++] = ']'; + sqlite3_snprintf( 100, zCsr, encnames[pMem.enc] );//& zBuf[k], encnames[pMem.enc] ); + zBuf.Append( zCsr ); + //k += sqlite3Strlen30( &zBuf[k] ); + //zBuf[k++] = 0; + } + } #endif #if SQLITE_DEBUG - /* - ** Print the value of a register for tracing purposes: - */ - static void memTracePrint(FILE _out, Mem p) { - if ((p.flags & MEM_Null) != 0) { - fprintf(_out, " NULL"); - } else if ((p.flags & (MEM_Int | MEM_Str)) == (MEM_Int | MEM_Str)) { - fprintf(_out, " si:%lld", p.u.i); + /* +** Print the value of a register for tracing purposes: +*/ + static void memTracePrint( FILE _out, Mem p ) + { + if ( ( p.flags & MEM_Null ) != 0 ) + { + fprintf( _out, " NULL" ); + } + else if ( ( p.flags & ( MEM_Int | MEM_Str ) ) == ( MEM_Int | MEM_Str ) ) + { + fprintf( _out, " si:%lld", p.u.i ); #if !SQLITE_OMIT_FLOATING_POINT - } else if ((p.flags & MEM_Int) != 0) { - fprintf(_out, " i:%lld", p.u.i); + } + else if ( ( p.flags & MEM_Int ) != 0 ) + { + fprintf( _out, " i:%lld", p.u.i ); #endif - } else if ((p.flags & MEM_Real) != 0) { - fprintf(_out, " r:%g", p.r); - } else if ((p.flags & MEM_RowSet) != 0) { - fprintf(_out, " (rowset)"); - } else { - StringBuilder zBuf = new StringBuilder(200); - sqlite3VdbeMemPrettyPrint(p, zBuf); - fprintf(_out, " "); - fprintf(_out, "%s", zBuf); - } - } - static void registerTrace(FILE _out, int iReg, Mem p) { - fprintf(_out, "reg[%d] = ", iReg); - memTracePrint(_out, p); - fprintf(_out, "\n"); - } + } + else if ( ( p.flags & MEM_Real ) != 0 ) + { + fprintf( _out, " r:%g", p.r ); + } + else if ( ( p.flags & MEM_RowSet ) != 0 ) + { + fprintf( _out, " (rowset)" ); + } + else + { + StringBuilder zBuf = new StringBuilder( 200 ); + sqlite3VdbeMemPrettyPrint( p, zBuf ); + fprintf( _out, " " ); + fprintf( _out, "%s", zBuf ); + } + } + static void registerTrace( FILE _out, int iReg, Mem p ) + { + fprintf( _out, "reg[%d] = ", iReg ); + memTracePrint( _out, p ); + fprintf( _out, "\n" ); + } #endif #if SQLITE_DEBUG - //# define REGISTER_TRACE(R,M) if(p.trace)registerTrace(p.trace,R,M) - static void REGISTER_TRACE(Vdbe p, int R, Mem M) { - if (p.trace != null) - registerTrace(p.trace, R, M); - } + //# define REGISTER_TRACE(R,M) if(p.trace)registerTrace(p.trace,R,M) + static void REGISTER_TRACE( Vdbe p, int R, Mem M ) + { + if ( p.trace != null ) + registerTrace( p.trace, R, M ); + } #else //# define REGISTER_TRACE(R,M) static void REGISTER_TRACE( Vdbe p, int R, Mem M ) { } @@ -563,172 +642,181 @@ static void REGISTER_TRACE( Vdbe p, int R, Mem M ) { } #endif - /* - ** The CHECK_FOR_INTERRUPT macro defined here looks to see if the - ** sqlite3_interrupt() routine has been called. If it has been, then - ** processing of the VDBE program is interrupted. - ** - ** This macro added to every instruction that does a jump in order to - ** implement a loop. This test used to be on every single instruction, - ** but that meant we more testing that we needed. By only testing the - ** flag on jump instructions, we get a (small) speed improvement. - */ - //#define CHECK_FOR_INTERRUPT \ - // if( db.u1.isInterrupted ) goto abort_due_to_interrupt; + /* +** The CHECK_FOR_INTERRUPT macro defined here looks to see if the +** sqlite3_interrupt() routine has been called. If it has been, then +** processing of the VDBE program is interrupted. +** +** This macro added to every instruction that does a jump in order to +** implement a loop. This test used to be on every single instruction, +** but that meant we more testing that we needed. By only testing the +** flag on jump instructions, we get a (small) speed improvement. +*/ + //#define CHECK_FOR_INTERRUPT \ + // if( db.u1.isInterrupted ) goto abort_due_to_interrupt; #if !NDEBUG - /* - ** This function is only called from within an Debug.Assert() expression. It - ** checks that the sqlite3.nTransaction variable is correctly set to - ** the number of non-transaction savepoints currently in the - ** linked list starting at sqlite3.pSavepoint. - ** - ** Usage: - ** - ** Debug.Assert( checkSavepointCount(db) ); - */ - static int checkSavepointCount(sqlite3 db) { - int n = 0; - Savepoint p; - for (p = db.pSavepoint; p != null; p = p.pNext) - n++; - Debug.Assert(n == (db.nSavepoint + db.isTransactionSavepoint)); - return 1; - } + /* +** This function is only called from within an Debug.Assert() expression. It +** checks that the sqlite3.nTransaction variable is correctly set to +** the number of non-transaction savepoints currently in the +** linked list starting at sqlite3.pSavepoint. +** +** Usage: +** +** Debug.Assert( checkSavepointCount(db) ); +*/ + static int checkSavepointCount( sqlite3 db ) + { + int n = 0; + Savepoint p; + for ( p = db.pSavepoint; p != null; p = p.pNext ) + n++; + Debug.Assert( n == ( db.nSavepoint + db.isTransactionSavepoint ) ); + return 1; + } #else static int checkSavepointCount( sqlite3 db ) { return 1; } #endif - /* - ** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored - ** in memory obtained from sqlite3_malloc) into a Vdbe.zErrMsg (text stored - ** in memory obtained from sqlite3DbMalloc). - */ - static void importVtabErrMsg(Vdbe p, sqlite3_vtab pVtab) { - sqlite3 db = p.db; - sqlite3DbFree(db, ref p.zErrMsg); - p.zErrMsg = pVtab.zErrMsg; // sqlite3DbStrDup( db, pVtab.zErrMsg ); - //sqlite3_free( pVtab.zErrMsg ); - pVtab.zErrMsg = null; - } + /* +** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored +** in memory obtained from sqlite3_malloc) into a Vdbe.zErrMsg (text stored +** in memory obtained from sqlite3DbMalloc). +*/ + static void importVtabErrMsg( Vdbe p, sqlite3_vtab pVtab ) + { + sqlite3 db = p.db; + sqlite3DbFree( db, ref p.zErrMsg ); + p.zErrMsg = pVtab.zErrMsg; // sqlite3DbStrDup( db, pVtab.zErrMsg ); + //sqlite3_free( pVtab.zErrMsg ); + pVtab.zErrMsg = null; + } - /* - ** Execute as much of a VDBE program as we can then return. - ** - ** sqlite3VdbeMakeReady() must be called before this routine in order to - ** close the program with a final OP_Halt and to set up the callbacks - ** and the error message pointer. - ** - ** Whenever a row or result data is available, this routine will either - ** invoke the result callback (if there is one) or return with - ** SQLITE_ROW. - ** - ** If an attempt is made to open a locked database, then this routine - ** will either invoke the busy callback (if there is one) or it will - ** return SQLITE_BUSY. - ** - ** If an error occurs, an error message is written to memory obtained - ** from sqlite3Malloc() and p.zErrMsg is made to point to that memory. - ** The error code is stored in p.rc and this routine returns SQLITE_ERROR. - ** - ** If the callback ever returns non-zero, then the program exits - ** immediately. There will be no error message but the p.rc field is - ** set to SQLITE_ABORT and this routine will return SQLITE_ERROR. - ** - ** A memory allocation error causes p.rc to be set to SQLITE_NOMEM and this - ** routine to return SQLITE_ERROR. - ** - ** Other fatal errors return SQLITE_ERROR. - ** - ** After this routine has finished, sqlite3VdbeFinalize() should be - ** used to clean up the mess that was left behind. - */ - static int sqlite3VdbeExec( - Vdbe p /* The VDBE */ - ) { - int pc = 0; /* The program counter */ - Op[] aOp = p.aOp; /* Copy of p.aOp */ - Op pOp; /* Current operation */ - int rc = SQLITE_OK; /* Value to return */ - sqlite3 db = p.db; /* The database */ - u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */ - u8 encoding = ENC(db); /* The database encoding */ + /* + ** Execute as much of a VDBE program as we can then return. + ** + ** sqlite3VdbeMakeReady() must be called before this routine in order to + ** close the program with a final OP_Halt and to set up the callbacks + ** and the error message pointer. + ** + ** Whenever a row or result data is available, this routine will either + ** invoke the result callback (if there is one) or return with + ** SQLITE_ROW. + ** + ** If an attempt is made to open a locked database, then this routine + ** will either invoke the busy callback (if there is one) or it will + ** return SQLITE_BUSY. + ** + ** If an error occurs, an error message is written to memory obtained + ** from sqlite3Malloc() and p.zErrMsg is made to point to that memory. + ** The error code is stored in p.rc and this routine returns SQLITE_ERROR. + ** + ** If the callback ever returns non-zero, then the program exits + ** immediately. There will be no error message but the p.rc field is + ** set to SQLITE_ABORT and this routine will return SQLITE_ERROR. + ** + ** A memory allocation error causes p.rc to be set to SQLITE_NOMEM and this + ** routine to return SQLITE_ERROR. + ** + ** Other fatal errors return SQLITE_ERROR. + ** + ** After this routine has finished, sqlite3VdbeFinalize() should be + ** used to clean up the mess that was left behind. + */ + static int sqlite3VdbeExec( + Vdbe p /* The VDBE */ + ) + { + int pc = 0; /* The program counter */ + Op[] aOp = p.aOp; /* Copy of p.aOp */ + Op pOp; /* Current operation */ + int rc = SQLITE_OK; /* Value to return */ + sqlite3 db = p.db; /* The database */ + u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */ + u8 encoding = ENC( db ); /* The database encoding */ #if !SQLITE_OMIT_PROGRESS_CALLBACK - bool checkProgress; /* True if progress callbacks are enabled */ - int nProgressOps = 0; /* Opcodes executed since progress callback. */ + bool checkProgress; /* True if progress callbacks are enabled */ + int nProgressOps = 0; /* Opcodes executed since progress callback. */ #endif - Mem[] aMem = p.aMem; /* Copy of p.aMem */ - Mem pIn1 = null; /* 1st input operand */ - Mem pIn2 = null; /* 2nd input operand */ - Mem pIn3 = null; /* 3rd input operand */ - Mem pOut = null; /* Output operand */ - int iCompare = 0; /* Result of last OP_Compare operation */ - int[] aPermute = null; /* Permutation of columns for OP_Compare */ - i64 lastRowid = db.lastRowid; /* Saved value of the last insert ROWID */ + Mem[] aMem = p.aMem; /* Copy of p.aMem */ + Mem pIn1 = null; /* 1st input operand */ + Mem pIn2 = null; /* 2nd input operand */ + Mem pIn3 = null; /* 3rd input operand */ + Mem pOut = null; /* Output operand */ + int iCompare = 0; /* Result of last OP_Compare operation */ + int[] aPermute = null; /* Permutation of columns for OP_Compare */ + i64 lastRowid = db.lastRowid; /* Saved value of the last insert ROWID */ #if VDBE_PROFILE u64 start; /* CPU clock count at start of opcode */ int origPc; /* Program counter at start of opcode */ #endif - /*** INSERT STACK UNION HERE ***/ + /*** INSERT STACK UNION HERE ***/ - Debug.Assert(p.magic == VDBE_MAGIC_RUN); /* sqlite3_step() verifies this */ - sqlite3VdbeEnter(p); - if (p.rc == SQLITE_NOMEM) { - /* This happens if a malloc() inside a call to sqlite3_column_text() or - ** sqlite3_column_text16() failed. */ - goto no_mem; - } - Debug.Assert(p.rc == SQLITE_OK || p.rc == SQLITE_BUSY); - p.rc = SQLITE_OK; - Debug.Assert(p.explain == 0); - p.pResultSet = null; - db.busyHandler.nBusy = 0; - if (db.u1.isInterrupted) - goto abort_due_to_interrupt; //CHECK_FOR_INTERRUPT; + Debug.Assert( p.magic == VDBE_MAGIC_RUN ); /* sqlite3_step() verifies this */ + sqlite3VdbeEnter( p ); + if ( p.rc == SQLITE_NOMEM ) + { + /* This happens if a malloc() inside a call to sqlite3_column_text() or + ** sqlite3_column_text16() failed. */ + goto no_mem; + } + Debug.Assert( p.rc == SQLITE_OK || p.rc == SQLITE_BUSY ); + p.rc = SQLITE_OK; + Debug.Assert( p.explain == 0 ); + p.pResultSet = null; + db.busyHandler.nBusy = 0; + if ( db.u1.isInterrupted ) + goto abort_due_to_interrupt; //CHECK_FOR_INTERRUPT; #if TRACE - sqlite3VdbeIOTraceSql(p); +sqlite3VdbeIOTraceSql( p ); #endif #if !SQLITE_OMIT_PROGRESS_CALLBACK - checkProgress = db.xProgress != null; + checkProgress = db.xProgress != null; #endif #if SQLITE_DEBUG - sqlite3BeginBenignMalloc(); - if (p.pc == 0 - && (p.db.flags & SQLITE_VdbeListing) != 0) { - int i; - Console.Write("VDBE Program Listing:\n"); - sqlite3VdbePrintSql(p); - for (i = 0; i < p.nOp; i++) { - sqlite3VdbePrintOp(Console.Out, i, aOp[i]); - } - } - sqlite3EndBenignMalloc(); -#endif - for (pc = p.pc; rc == SQLITE_OK; pc++) { - Debug.Assert(pc >= 0 && pc < p.nOp); - // if ( db.mallocFailed != 0 ) goto no_mem; -#if VDBE_PROFILE + sqlite3BeginBenignMalloc(); + if ( p.pc == 0 + && ( p.db.flags & SQLITE_VdbeListing ) != 0 ) + { + int i; + Console.Write( "VDBE Program Listing:\n" ); + sqlite3VdbePrintSql( p ); + for ( i = 0; i < p.nOp; i++ ) + { + sqlite3VdbePrintOp( Console.Out, i, aOp[i] ); + } + } + sqlite3EndBenignMalloc(); +#endif + for ( pc = p.pc; rc == SQLITE_OK; pc++ ) + { + Debug.Assert( pc >= 0 && pc < p.nOp ); + // if ( db.mallocFailed != 0 ) goto no_mem; +#if VDBE_PROFILE origPc = pc; start = sqlite3Hwtime(); #endif - pOp = aOp[pc]; + pOp = aOp[pc]; - /* Only allow tracing if SQLITE_DEBUG is defined. - */ + /* Only allow tracing if SQLITE_DEBUG is defined. + */ #if SQLITE_DEBUG - if (p.trace != null) { - if (pc == 0) { - printf("VDBE Execution Trace:\n"); - sqlite3VdbePrintSql(p); - } - sqlite3VdbePrintOp(p.trace, pc, pOp); - } + if ( p.trace != null ) + { + if ( pc == 0 ) + { + printf( "VDBE Execution Trace:\n" ); + sqlite3VdbePrintSql( p ); + } + sqlite3VdbePrintOp( p.trace, pc, pOp ); + } #endif - /* Check to see if we need to simulate an interrupt. This only happens - ** if we have a special test build. - */ + /* Check to see if we need to simulate an interrupt. This only happens +** if we have a special test build. +*/ #if SQLITE_TEST #if !TCLSH if ( sqlite3_interrupt_count > 0 ) @@ -748,290 +836,318 @@ Vdbe p /* The VDBE */ #endif #if !SQLITE_OMIT_PROGRESS_CALLBACK - /* Call the progress callback if it is configured and the required number - ** of VDBE ops have been executed (either since this invocation of - ** sqlite3VdbeExec() or since last time the progress callback was called). - ** If the progress callback returns non-zero, exit the virtual machine with - ** a return code SQLITE_ABORT. - */ - if (checkProgress) { - if (db.nProgressOps == nProgressOps) { - int prc; - prc = db.xProgress(db.pProgressArg); - if (prc != 0) { - rc = SQLITE_INTERRUPT; - goto vdbe_error_halt; - } - nProgressOps = 0; - } - nProgressOps++; - } + /* Call the progress callback if it is configured and the required number +** of VDBE ops have been executed (either since this invocation of +** sqlite3VdbeExec() or since last time the progress callback was called). +** If the progress callback returns non-zero, exit the virtual machine with +** a return code SQLITE_ABORT. +*/ + if ( checkProgress ) + { + if ( db.nProgressOps == nProgressOps ) + { + int prc; + prc = db.xProgress( db.pProgressArg ); + if ( prc != 0 ) + { + rc = SQLITE_INTERRUPT; + goto vdbe_error_halt; + } + nProgressOps = 0; + } + nProgressOps++; + } #endif - /* On any opcode with the "out2-prerelase" tag, free any - ** external allocations out of mem[p2] and set mem[p2] to be - ** an undefined integer. Opcodes will either fill in the integer - ** value or convert mem[p2] to a different type. - */ - Debug.Assert(pOp.opflags == sqlite3OpcodeProperty[pOp.opcode]); - if ((pOp.opflags & OPFLG_OUT2_PRERELEASE) != 0) { - Debug.Assert(pOp.p2 > 0); - Debug.Assert(pOp.p2 <= p.nMem); - pOut = aMem[pOp.p2]; - memAboutToChange(p, pOut); - sqlite3VdbeMemReleaseExternal(pOut); - pOut.flags = MEM_Int; - } + /* On any opcode with the "out2-prerelase" tag, free any +** external allocations out of mem[p2] and set mem[p2] to be +** an undefined integer. Opcodes will either fill in the integer +** value or convert mem[p2] to a different type. +*/ + Debug.Assert( pOp.opflags == sqlite3OpcodeProperty[pOp.opcode] ); + if ( ( pOp.opflags & OPFLG_OUT2_PRERELEASE ) != 0 ) + { + Debug.Assert( pOp.p2 > 0 ); + Debug.Assert( pOp.p2 <= p.nMem ); + pOut = aMem[pOp.p2]; + memAboutToChange( p, pOut ); + sqlite3VdbeMemReleaseExternal( pOut ); + pOut.flags = MEM_Int; + } - /* Sanity checking on other operands */ - /* Sanity checking on other operands */ + /* Sanity checking on other operands */ + /* Sanity checking on other operands */ #if SQLITE_DEBUG - if ((pOp.opflags & OPFLG_IN1) != 0) { - Debug.Assert(pOp.p1 > 0); - Debug.Assert(pOp.p1 <= p.nMem); - Debug.Assert(memIsValid(aMem[pOp.p1])); - REGISTER_TRACE(p, pOp.p1, aMem[pOp.p1]); - } - if ((pOp.opflags & OPFLG_IN2) != 0) { - Debug.Assert(pOp.p2 > 0); - Debug.Assert(pOp.p2 <= p.nMem); - Debug.Assert(memIsValid(aMem[pOp.p2])); - REGISTER_TRACE(p, pOp.p2, aMem[pOp.p2]); - } - if ((pOp.opflags & OPFLG_IN3) != 0) { - Debug.Assert(pOp.p3 > 0); - Debug.Assert(pOp.p3 <= p.nMem); - Debug.Assert(memIsValid(aMem[pOp.p3])); - REGISTER_TRACE(p, pOp.p3, aMem[pOp.p3]); - } - if ((pOp.opflags & OPFLG_OUT2) != 0) { - Debug.Assert(pOp.p2 > 0); - Debug.Assert(pOp.p2 <= p.nMem); - memAboutToChange(p, aMem[pOp.p2]); - } - if ((pOp.opflags & OPFLG_OUT3) != 0) { - Debug.Assert(pOp.p3 > 0); - Debug.Assert(pOp.p3 <= p.nMem); - memAboutToChange(p, aMem[pOp.p3]); - } + if ( ( pOp.opflags & OPFLG_IN1 ) != 0 ) + { + Debug.Assert( pOp.p1 > 0 ); + Debug.Assert( pOp.p1 <= p.nMem ); + Debug.Assert( memIsValid( aMem[pOp.p1] ) ); + REGISTER_TRACE( p, pOp.p1, aMem[pOp.p1] ); + } + if ( ( pOp.opflags & OPFLG_IN2 ) != 0 ) + { + Debug.Assert( pOp.p2 > 0 ); + Debug.Assert( pOp.p2 <= p.nMem ); + Debug.Assert( memIsValid( aMem[pOp.p2] ) ); + REGISTER_TRACE( p, pOp.p2, aMem[pOp.p2] ); + } + if ( ( pOp.opflags & OPFLG_IN3 ) != 0 ) + { + Debug.Assert( pOp.p3 > 0 ); + Debug.Assert( pOp.p3 <= p.nMem ); + Debug.Assert( memIsValid( aMem[pOp.p3] ) ); + REGISTER_TRACE( p, pOp.p3, aMem[pOp.p3] ); + } + if ( ( pOp.opflags & OPFLG_OUT2 ) != 0 ) + { + Debug.Assert( pOp.p2 > 0 ); + Debug.Assert( pOp.p2 <= p.nMem ); + memAboutToChange( p, aMem[pOp.p2] ); + } + if ( ( pOp.opflags & OPFLG_OUT3 ) != 0 ) + { + Debug.Assert( pOp.p3 > 0 ); + Debug.Assert( pOp.p3 <= p.nMem ); + memAboutToChange( p, aMem[pOp.p3] ); + } #endif - switch (pOp.opcode) { - - /***************************************************************************** - ** What follows is a massive switch statement where each case implements a - ** separate instruction in the virtual machine. If we follow the usual - ** indentation conventions, each case should be indented by 6 spaces. But - ** that is a lot of wasted space on the left margin. So the code within - ** the switch statement will break with convention and be flush-left. Another - ** big comment (similar to this one) will mark the point in the code where - ** we transition back to normal indentation. - ** - ** The formatting of each case is important. The makefile for SQLite - ** generates two C files "opcodes.h" and "opcodes.c" by scanning this - ** file looking for lines that begin with "case OP_". The opcodes.h files - ** will be filled with #defines that give unique integer values to each - ** opcode and the opcodes.c file is filled with an array of strings where - ** each string is the symbolic name for the corresponding opcode. If the - ** case statement is followed by a comment of the form "/# same as ... #/" - ** that comment is used to determine the particular value of the opcode. - ** - ** Other keywords in the comment that follows each case are used to - ** construct the OPFLG_INITIALIZER value that initializes opcodeProperty[]. - ** Keywords include: in1, in2, in3, ref2_prerelease, ref2, ref3. See - ** the mkopcodeh.awk script for additional information. - ** - ** Documentation about VDBE opcodes is generated by scanning this file - ** for lines of that contain "Opcode:". That line and all subsequent - ** comment lines are used in the generation of the opcode.html documentation - ** file. - ** - ** SUMMARY: - ** - ** Formatting is important to scripts that scan this file. - ** Do not deviate from the formatting style currently in use. - ** - *****************************************************************************/ - - /* Opcode: Goto * P2 * * * - ** - ** An unconditional jump to address P2. - ** The next instruction executed will be - ** the one at index P2 from the beginning of - ** the program. - */ - case OP_Goto: { /* jump */ - if (db.u1.isInterrupted) - goto abort_due_to_interrupt; //CHECK_FOR_INTERRUPT; - pc = pOp.p2 - 1; - break; - } + switch ( pOp.opcode ) + { - /* Opcode: Gosub P1 P2 * * * - ** - ** Write the current address onto register P1 - ** and then jump to address P2. - */ - case OP_Gosub: { /* jump, in1 */ - pIn1 = aMem[pOp.p1]; - Debug.Assert((pIn1.flags & MEM_Dyn) == 0); - memAboutToChange(p, pIn1); - pIn1.flags = MEM_Int; - pIn1.u.i = pc; - REGISTER_TRACE(p, pOp.p1, pIn1); - pc = pOp.p2 - 1; - break; - } + /***************************************************************************** + ** What follows is a massive switch statement where each case implements a + ** separate instruction in the virtual machine. If we follow the usual + ** indentation conventions, each case should be indented by 6 spaces. But + ** that is a lot of wasted space on the left margin. So the code within + ** the switch statement will break with convention and be flush-left. Another + ** big comment (similar to this one) will mark the point in the code where + ** we transition back to normal indentation. + ** + ** The formatting of each case is important. The makefile for SQLite + ** generates two C files "opcodes.h" and "opcodes.c" by scanning this + ** file looking for lines that begin with "case OP_". The opcodes.h files + ** will be filled with #defines that give unique integer values to each + ** opcode and the opcodes.c file is filled with an array of strings where + ** each string is the symbolic name for the corresponding opcode. If the + ** case statement is followed by a comment of the form "/# same as ... #/" + ** that comment is used to determine the particular value of the opcode. + ** + ** Other keywords in the comment that follows each case are used to + ** construct the OPFLG_INITIALIZER value that initializes opcodeProperty[]. + ** Keywords include: in1, in2, in3, ref2_prerelease, ref2, ref3. See + ** the mkopcodeh.awk script for additional information. + ** + ** Documentation about VDBE opcodes is generated by scanning this file + ** for lines of that contain "Opcode:". That line and all subsequent + ** comment lines are used in the generation of the opcode.html documentation + ** file. + ** + ** SUMMARY: + ** + ** Formatting is important to scripts that scan this file. + ** Do not deviate from the formatting style currently in use. + ** + *****************************************************************************/ - /* Opcode: Return P1 * * * * - ** - ** Jump to the next instruction after the address in register P1. - */ - case OP_Return: { /* in1 */ - pIn1 = aMem[pOp.p1]; - Debug.Assert((pIn1.flags & MEM_Int) != 0); - pc = (int)pIn1.u.i; - break; - } + /* Opcode: Goto * P2 * * * + ** + ** An unconditional jump to address P2. + ** The next instruction executed will be + ** the one at index P2 from the beginning of + ** the program. + */ + case OP_Goto: + { /* jump */ + if ( db.u1.isInterrupted ) + goto abort_due_to_interrupt; //CHECK_FOR_INTERRUPT; + pc = pOp.p2 - 1; + break; + } - /* Opcode: Yield P1 * * * * - ** - ** Swap the program counter with the value in register P1. - */ - case OP_Yield: { /* in1 */ - int pcDest; - pIn1 = aMem[pOp.p1]; - Debug.Assert((pIn1.flags & MEM_Dyn) == 0); - pIn1.flags = MEM_Int; - pcDest = (int)pIn1.u.i; - pIn1.u.i = pc; - REGISTER_TRACE(p, pOp.p1, pIn1); - pc = pcDest; - break; - } + /* Opcode: Gosub P1 P2 * * * + ** + ** Write the current address onto register P1 + ** and then jump to address P2. + */ + case OP_Gosub: + { /* jump, in1 */ + pIn1 = aMem[pOp.p1]; + Debug.Assert( ( pIn1.flags & MEM_Dyn ) == 0 ); + memAboutToChange( p, pIn1 ); + pIn1.flags = MEM_Int; + pIn1.u.i = pc; + REGISTER_TRACE( p, pOp.p1, pIn1 ); + pc = pOp.p2 - 1; + break; + } - /* Opcode: HaltIfNull P1 P2 P3 P4 * - ** - ** Check the value in register P3. If it is NULL then Halt using - ** parameter P1, P2, and P4 as if this were a Halt instruction. If the - ** value in register P3 is not NULL, then this routine is a no-op. - */ - case OP_HaltIfNull: { /* in3 */ - pIn3 = aMem[pOp.p3]; - if ((pIn3.flags & MEM_Null) == 0) - break; - /* Fall through into OP_Halt */ - goto case OP_Halt; - } + /* Opcode: Return P1 * * * * + ** + ** Jump to the next instruction after the address in register P1. + */ + case OP_Return: + { /* in1 */ + pIn1 = aMem[pOp.p1]; + Debug.Assert( ( pIn1.flags & MEM_Int ) != 0 ); + pc = (int)pIn1.u.i; + break; + } - /* Opcode: Halt P1 P2 * P4 * - ** - ** Exit immediately. All open cursors, etc are closed - ** automatically. - ** - ** P1 is the result code returned by sqlite3_exec(), sqlite3_reset(), - ** or sqlite3_finalize(). For a normal halt, this should be SQLITE_OK (0). - ** For errors, it can be some other value. If P1!=0 then P2 will determine - ** whether or not to rollback the current transaction. Do not rollback - ** if P2==OE_Fail. Do the rollback if P2==OE_Rollback. If P2==OE_Abort, - ** then back out all changes that have occurred during this execution of the - ** VDBE, but do not rollback the transaction. - ** - ** If P4 is not null then it is an error message string. - ** - ** There is an implied "Halt 0 0 0" instruction inserted at the very end of - ** every program. So a jump past the last instruction of the program - ** is the same as executing Halt. - */ - case OP_Halt: { - pIn3 = aMem[pOp.p3]; - if (pOp.p1 == SQLITE_OK && p.pFrame != null) { - /* Halt the sub-program. Return control to the parent frame. */ - VdbeFrame pFrame = p.pFrame; - p.pFrame = pFrame.pParent; - p.nFrame--; - sqlite3VdbeSetChanges(db, p.nChange); - pc = sqlite3VdbeFrameRestore(pFrame); - lastRowid = db.lastRowid; - if (pOp.p2 == OE_Ignore) { - /* Instruction pc is the OP_Program that invoked the sub-program - ** currently being halted. If the p2 instruction of this OP_Halt - ** instruction is set to OE_Ignore, then the sub-program is throwing - ** an IGNORE exception. In this case jump to the address specified - ** as the p2 of the calling OP_Program. */ - pc = p.aOp[pc].p2 - 1; - } - aOp = p.aOp; - aMem = p.aMem; - break; - } - p.rc = pOp.p1; - p.errorAction = (u8)pOp.p2; - p.pc = pc; - if (pOp.p4.z != null) { - Debug.Assert(p.rc != SQLITE_OK); - sqlite3SetString(ref p.zErrMsg, db, "%s", pOp.p4.z); - testcase(sqlite3GlobalConfig.xLog != null); - sqlite3_log(pOp.p1, "abort at %d in [%s]: %s", pc, p.zSql, pOp.p4.z); - } else if (p.rc != 0) { - testcase(sqlite3GlobalConfig.xLog != null); - sqlite3_log(pOp.p1, "constraint failed at %d in [%s]", pc, p.zSql); - } - rc = sqlite3VdbeHalt(p); - Debug.Assert(rc == SQLITE_BUSY || rc == SQLITE_OK || rc == SQLITE_ERROR); - if (rc == SQLITE_BUSY) { - p.rc = rc = SQLITE_BUSY; - } else { - Debug.Assert(rc == SQLITE_OK || p.rc == SQLITE_CONSTRAINT); - Debug.Assert(rc == SQLITE_OK || db.nDeferredCons > 0); - rc = p.rc != 0 ? SQLITE_ERROR : SQLITE_DONE; - } - goto vdbe_return; - } + /* Opcode: Yield P1 * * * * + ** + ** Swap the program counter with the value in register P1. + */ + case OP_Yield: + { /* in1 */ + int pcDest; + pIn1 = aMem[pOp.p1]; + Debug.Assert( ( pIn1.flags & MEM_Dyn ) == 0 ); + pIn1.flags = MEM_Int; + pcDest = (int)pIn1.u.i; + pIn1.u.i = pc; + REGISTER_TRACE( p, pOp.p1, pIn1 ); + pc = pcDest; + break; + } - /* Opcode: Integer P1 P2 * * * - ** - ** The 32-bit integer value P1 is written into register P2. - */ - case OP_Integer: { /* out2-prerelease */ - pOut.u.i = pOp.p1; - break; - } + /* Opcode: HaltIfNull P1 P2 P3 P4 * + ** + ** Check the value in register P3. If it is NULL then Halt using + ** parameter P1, P2, and P4 as if this were a Halt instruction. If the + ** value in register P3 is not NULL, then this routine is a no-op. + */ + case OP_HaltIfNull: + { /* in3 */ + pIn3 = aMem[pOp.p3]; + if ( ( pIn3.flags & MEM_Null ) == 0 ) + break; + /* Fall through into OP_Halt */ + goto case OP_Halt; + } - /* Opcode: Int64 * P2 * P4 * - ** - ** P4 is a pointer to a 64-bit integer value. - ** Write that value into register P2. - */ - case OP_Int64: { /* out2-prerelease */ - // Integer pointer always exists Debug.Assert( pOp.p4.pI64 != 0 ); - pOut.u.i = pOp.p4.pI64; - break; - } + /* Opcode: Halt P1 P2 * P4 * + ** + ** Exit immediately. All open cursors, etc are closed + ** automatically. + ** + ** P1 is the result code returned by sqlite3_exec(), sqlite3_reset(), + ** or sqlite3_finalize(). For a normal halt, this should be SQLITE_OK (0). + ** For errors, it can be some other value. If P1!=0 then P2 will determine + ** whether or not to rollback the current transaction. Do not rollback + ** if P2==OE_Fail. Do the rollback if P2==OE_Rollback. If P2==OE_Abort, + ** then back out all changes that have occurred during this execution of the + ** VDBE, but do not rollback the transaction. + ** + ** If P4 is not null then it is an error message string. + ** + ** There is an implied "Halt 0 0 0" instruction inserted at the very end of + ** every program. So a jump past the last instruction of the program + ** is the same as executing Halt. + */ + case OP_Halt: + { + pIn3 = aMem[pOp.p3]; + if ( pOp.p1 == SQLITE_OK && p.pFrame != null ) + { + /* Halt the sub-program. Return control to the parent frame. */ + VdbeFrame pFrame = p.pFrame; + p.pFrame = pFrame.pParent; + p.nFrame--; + sqlite3VdbeSetChanges( db, p.nChange ); + pc = sqlite3VdbeFrameRestore( pFrame ); + lastRowid = db.lastRowid; + if ( pOp.p2 == OE_Ignore ) + { + /* Instruction pc is the OP_Program that invoked the sub-program + ** currently being halted. If the p2 instruction of this OP_Halt + ** instruction is set to OE_Ignore, then the sub-program is throwing + ** an IGNORE exception. In this case jump to the address specified + ** as the p2 of the calling OP_Program. */ + pc = p.aOp[pc].p2 - 1; + } + aOp = p.aOp; + aMem = p.aMem; + break; + } + p.rc = pOp.p1; + p.errorAction = (u8)pOp.p2; + p.pc = pc; + if ( pOp.p4.z != null ) + { + Debug.Assert( p.rc != SQLITE_OK ); + sqlite3SetString( ref p.zErrMsg, db, "%s", pOp.p4.z ); + testcase( sqlite3GlobalConfig.xLog != null ); + sqlite3_log( pOp.p1, "abort at %d in [%s]: %s", pc, p.zSql, pOp.p4.z ); + } + else if ( p.rc != 0 ) + { + testcase( sqlite3GlobalConfig.xLog != null ); + sqlite3_log( pOp.p1, "constraint failed at %d in [%s]", pc, p.zSql ); + } + rc = sqlite3VdbeHalt( p ); + Debug.Assert( rc == SQLITE_BUSY || rc == SQLITE_OK || rc == SQLITE_ERROR ); + if ( rc == SQLITE_BUSY ) + { + p.rc = rc = SQLITE_BUSY; + } + else + { + Debug.Assert( rc == SQLITE_OK || p.rc == SQLITE_CONSTRAINT ); + Debug.Assert( rc == SQLITE_OK || db.nDeferredCons > 0 ); + rc = p.rc != 0 ? SQLITE_ERROR : SQLITE_DONE; + } + goto vdbe_return; + } -#if !SQLITE_OMIT_FLOATING_POINT - /* Opcode: Real * P2 * P4 * + /* Opcode: Integer P1 P2 * * * ** - ** P4 is a pointer to a 64-bit floating point value. - ** Write that value into register P2. + ** The 32-bit integer value P1 is written into register P2. */ - case OP_Real: { /* same as TK_FLOAT, ref2-prerelease */ - pOut.flags = MEM_Real; - Debug.Assert(!sqlite3IsNaN(pOp.p4.pReal)); - pOut.r = pOp.p4.pReal; - break; - } -#endif + case OP_Integer: + { /* out2-prerelease */ + pOut.u.i = pOp.p1; + break; + } - /* Opcode: String8 * P2 * P4 * + /* Opcode: Int64 * P2 * P4 * ** - ** P4 points to a nul terminated UTF-8 string. This opcode is transformed - ** into an OP_String before it is executed for the first time. + ** P4 is a pointer to a 64-bit integer value. + ** Write that value into register P2. */ - case OP_String8: { /* same as TK_STRING, ref2-prerelease */ - Debug.Assert(pOp.p4.z != null); - pOp.opcode = OP_String; - pOp.p1 = sqlite3Strlen30(pOp.p4.z); + case OP_Int64: + { /* out2-prerelease */ + // Integer pointer always exists Debug.Assert( pOp.p4.pI64 != 0 ); + pOut.u.i = pOp.p4.pI64; + break; + } + +#if !SQLITE_OMIT_FLOATING_POINT + /* Opcode: Real * P2 * P4 * +** +** P4 is a pointer to a 64-bit floating point value. +** Write that value into register P2. +*/ + case OP_Real: + { /* same as TK_FLOAT, ref2-prerelease */ + pOut.flags = MEM_Real; + Debug.Assert( !sqlite3IsNaN( pOp.p4.pReal ) ); + pOut.r = pOp.p4.pReal; + break; + } +#endif + + /* Opcode: String8 * P2 * P4 * +** +** P4 points to a nul terminated UTF-8 string. This opcode is transformed +** into an OP_String before it is executed for the first time. +*/ + case OP_String8: + { /* same as TK_STRING, ref2-prerelease */ + Debug.Assert( pOp.p4.z != null ); + pOp.opcode = OP_String; + pOp.p1 = sqlite3Strlen30( pOp.p4.z ); #if !SQLITE_OMIT_UTF16 if( encoding!=SQLITE_UTF8 ){ @@ -1051,586 +1167,635 @@ Vdbe p /* The VDBE */ pOp.p1 = pOut.n; } #endif - if (pOp.p1 > db.aLimit[SQLITE_LIMIT_LENGTH]) { - goto too_big; - } - /* Fall through to the next case, OP_String */ - goto case OP_String; - } + if ( pOp.p1 > db.aLimit[SQLITE_LIMIT_LENGTH] ) + { + goto too_big; + } + /* Fall through to the next case, OP_String */ + goto case OP_String; + } - /* Opcode: String P1 P2 * P4 * - ** - ** The string value P4 of length P1 (bytes) is stored in register P2. - */ - case OP_String: { /* out2-prerelease */ - Debug.Assert(pOp.p4.z != null); - pOut.flags = MEM_Str | MEM_Static | MEM_Term; - sqlite3_free(ref pOut.zBLOB); - pOut.z = pOp.p4.z; - pOut.n = pOp.p1; + /* Opcode: String P1 P2 * P4 * + ** + ** The string value P4 of length P1 (bytes) is stored in register P2. + */ + case OP_String: + { /* out2-prerelease */ + Debug.Assert( pOp.p4.z != null ); + pOut.flags = MEM_Str | MEM_Static | MEM_Term; + sqlite3_free( ref pOut.zBLOB ); + pOut.z = pOp.p4.z; + pOut.n = pOp.p1; #if SQLITE_OMIT_UTF16 - pOut.enc = SQLITE_UTF8; -#else + pOut.enc = SQLITE_UTF8; +#else pOut.enc = encoding; #endif #if SQLITE_TEST UPDATE_MAX_BLOBSIZE( pOut ); #endif - break; - } + break; + } - /* Opcode: Null * P2 * * * - ** - ** Write a NULL into register P2. - */ - case OP_Null: { /* out2-prerelease */ - pOut.flags = MEM_Null; - break; - } + /* Opcode: Null * P2 * * * + ** + ** Write a NULL into register P2. + */ + case OP_Null: + { /* out2-prerelease */ + pOut.flags = MEM_Null; + break; + } - /* Opcode: Blob P1 P2 * P4 - ** - ** P4 points to a blob of data P1 bytes long. Store this - ** blob in register P2. - */ - case OP_Blob: { /* out2-prerelease */ - Debug.Assert(pOp.p1 <= db.aLimit[SQLITE_LIMIT_LENGTH]); - sqlite3VdbeMemSetStr(pOut, pOp.p4.z, pOp.p1, 0, null); - pOut.enc = encoding; + /* Opcode: Blob P1 P2 * P4 + ** + ** P4 points to a blob of data P1 bytes long. Store this + ** blob in register P2. + */ + case OP_Blob: + { /* out2-prerelease */ + Debug.Assert( pOp.p1 <= db.aLimit[SQLITE_LIMIT_LENGTH] ); + sqlite3VdbeMemSetStr( pOut, pOp.p4.z, pOp.p1, 0, null ); + pOut.enc = encoding; #if SQLITE_TEST UPDATE_MAX_BLOBSIZE( pOut ); #endif - break; - } - - /* Opcode: Variable P1 P2 * P4 * - ** - ** Transfer the values of bound parameter P1 into register P2 - ** - ** If the parameter is named, then its name appears in P4 and P3==1. - ** The P4 value is used by sqlite3_bind_parameter_name(). - */ - case OP_Variable: { /* out2-prerelease */ - Mem pVar; /* Value being transferred */ - - Debug.Assert(pOp.p1 >= 0 && pOp.p1 <= p.nVar); - Debug.Assert(pOp.p4.z == null || pOp.p4.z == p.azVar[pOp.p1 - 1]); - pVar = p.aVar[pOp.p1 - 1]; + break; + } - if (sqlite3VdbeMemTooBig(pVar)) { - goto too_big; - } - sqlite3VdbeMemShallowCopy(pOut, pVar, MEM_Static); + /* Opcode: Variable P1 P2 * P4 * + ** + ** Transfer the values of bound parameter P1 into register P2 + ** + ** If the parameter is named, then its name appears in P4 and P3==1. + ** The P4 value is used by sqlite3_bind_parameter_name(). + */ + case OP_Variable: + { /* out2-prerelease */ + Mem pVar; /* Value being transferred */ + + Debug.Assert( pOp.p1 >= 0 && pOp.p1 <= p.nVar ); + Debug.Assert( pOp.p4.z == null || pOp.p4.z == p.azVar[pOp.p1 - 1] ); + pVar = p.aVar[pOp.p1 - 1]; + + if ( sqlite3VdbeMemTooBig( pVar ) ) + { + goto too_big; + } + sqlite3VdbeMemShallowCopy( pOut, pVar, MEM_Static ); #if SQLITE_TEST UPDATE_MAX_BLOBSIZE( pOut ); #endif - break; - } - /* Opcode: Move P1 P2 P3 * * - ** - ** Move the values in register P1..P1+P3-1 over into - ** registers P2..P2+P3-1. Registers P1..P1+P1-1 are - ** left holding a NULL. It is an error for register ranges - ** P1..P1+P3-1 and P2..P2+P3-1 to overlap. - */ - case OP_Move: { - //char* zMalloc; /* Holding variable for allocated memory */ - int n; /* Number of registers left to copy */ - int p1; /* Register to copy from */ - int p2; /* Register to copy to */ - - n = pOp.p3; - p1 = pOp.p1; - p2 = pOp.p2; - Debug.Assert(n > 0 && p1 > 0 && p2 > 0); - Debug.Assert(p1 + n <= p2 || p2 + n <= p1); - //pIn1 = aMem[p1]; - //pOut = aMem[p2]; - while (n-- != 0) { - pIn1 = aMem[p1 + pOp.p3 - n - 1]; - pOut = aMem[p2]; - //Debug.Assert( pOut<=&aMem[p.nMem] ); - //Debug.Assert( pIn1<=&aMem[p.nMem] ); - Debug.Assert(memIsValid(pIn1)); - memAboutToChange(p, pOut); - //zMalloc = pOut.zMalloc; - //pOut.zMalloc = null; - sqlite3VdbeMemMove(pOut, pIn1); - //pIn1.zMalloc = zMalloc; - REGISTER_TRACE(p, p2++, pOut); - //pIn1++; - //pOut++; - } - break; - } + break; + } + /* Opcode: Move P1 P2 P3 * * + ** + ** Move the values in register P1..P1+P3-1 over into + ** registers P2..P2+P3-1. Registers P1..P1+P1-1 are + ** left holding a NULL. It is an error for register ranges + ** P1..P1+P3-1 and P2..P2+P3-1 to overlap. + */ + case OP_Move: + { + //char* zMalloc; /* Holding variable for allocated memory */ + int n; /* Number of registers left to copy */ + int p1; /* Register to copy from */ + int p2; /* Register to copy to */ + + n = pOp.p3; + p1 = pOp.p1; + p2 = pOp.p2; + Debug.Assert( n > 0 && p1 > 0 && p2 > 0 ); + Debug.Assert( p1 + n <= p2 || p2 + n <= p1 ); + //pIn1 = aMem[p1]; + //pOut = aMem[p2]; + while ( n-- != 0 ) + { + pIn1 = aMem[p1 + pOp.p3 - n - 1]; + pOut = aMem[p2]; + //Debug.Assert( pOut<=&aMem[p.nMem] ); + //Debug.Assert( pIn1<=&aMem[p.nMem] ); + Debug.Assert( memIsValid( pIn1 ) ); + memAboutToChange( p, pOut ); + //zMalloc = pOut.zMalloc; + //pOut.zMalloc = null; + sqlite3VdbeMemMove( pOut, pIn1 ); + //pIn1.zMalloc = zMalloc; + REGISTER_TRACE( p, p2++, pOut ); + //pIn1++; + //pOut++; + } + break; + } - /* Opcode: Copy P1 P2 * * * - ** - ** Make a copy of register P1 into register P2. - ** - ** This instruction makes a deep copy of the value. A duplicate - ** is made of any string or blob constant. See also OP_SCopy. - */ - case OP_Copy: { /* in1, ref2 */ - pIn1 = aMem[pOp.p1]; - pOut = aMem[pOp.p2]; - - Debug.Assert(pOut != pIn1); - sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem); - if ((pOut.flags & MEM_Ephem) != 0 && sqlite3VdbeMemMakeWriteable(pOut) != 0) { - goto no_mem; - }//Deephemeralize( pOut ); - REGISTER_TRACE(p, pOp.p2, pOut); - break; - } + /* Opcode: Copy P1 P2 * * * + ** + ** Make a copy of register P1 into register P2. + ** + ** This instruction makes a deep copy of the value. A duplicate + ** is made of any string or blob constant. See also OP_SCopy. + */ + case OP_Copy: + { /* in1, ref2 */ + pIn1 = aMem[pOp.p1]; + pOut = aMem[pOp.p2]; + + Debug.Assert( pOut != pIn1 ); + sqlite3VdbeMemShallowCopy( pOut, pIn1, MEM_Ephem ); + if ( ( pOut.flags & MEM_Ephem ) != 0 && sqlite3VdbeMemMakeWriteable( pOut ) != 0 ) + { + goto no_mem; + }//Deephemeralize( pOut ); + REGISTER_TRACE( p, pOp.p2, pOut ); + break; + } - /* Opcode: SCopy P1 P2 * * * - ** - ** Make a shallow copy of register P1 into register P2. - ** - ** This instruction makes a shallow copy of the value. If the value - ** is a string or blob, then the copy is only a pointer to the - ** original and hence if the original changes so will the copy. - ** Worse, if the original is deallocated, the copy becomes invalid. - ** Thus the program must guarantee that the original will not change - ** during the lifetime of the copy. Use OP_Copy to make a complete - ** copy. - */ - case OP_SCopy: { /* in1, ref2 */ - pIn1 = aMem[pOp.p1]; - pOut = aMem[pOp.p2]; - Debug.Assert(pOut != pIn1); - sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem); + /* Opcode: SCopy P1 P2 * * * + ** + ** Make a shallow copy of register P1 into register P2. + ** + ** This instruction makes a shallow copy of the value. If the value + ** is a string or blob, then the copy is only a pointer to the + ** original and hence if the original changes so will the copy. + ** Worse, if the original is deallocated, the copy becomes invalid. + ** Thus the program must guarantee that the original will not change + ** during the lifetime of the copy. Use OP_Copy to make a complete + ** copy. + */ + case OP_SCopy: + { /* in1, ref2 */ + pIn1 = aMem[pOp.p1]; + pOut = aMem[pOp.p2]; + Debug.Assert( pOut != pIn1 ); + sqlite3VdbeMemShallowCopy( pOut, pIn1, MEM_Ephem ); #if SQLITE_DEBUG - if (pOut.pScopyFrom == null) - pOut.pScopyFrom = pIn1; + if ( pOut.pScopyFrom == null ) + pOut.pScopyFrom = pIn1; #endif - REGISTER_TRACE(p, pOp.p2, pOut); - break; - } + REGISTER_TRACE( p, pOp.p2, pOut ); + break; + } - /* Opcode: ResultRow P1 P2 * * * - ** - ** The registers P1 through P1+P2-1 contain a single row of - ** results. This opcode causes the sqlite3_step() call to terminate - ** with an SQLITE_ROW return code and it sets up the sqlite3_stmt - ** structure to provide access to the top P1 values as the result - ** row. - */ - case OP_ResultRow: { - //Mem[] pMem; - int i; - Debug.Assert(p.nResColumn == pOp.p2); - Debug.Assert(pOp.p1 > 0); - Debug.Assert(pOp.p1 + pOp.p2 <= p.nMem + 1); - - /* If this statement has violated immediate foreign key constraints, do - ** not return the number of rows modified. And do not RELEASE the statement - ** transaction. It needs to be rolled back. */ - if (SQLITE_OK != (rc = sqlite3VdbeCheckFk(p, 0))) { - Debug.Assert((db.flags & SQLITE_CountRows) != 0); - Debug.Assert(p.usesStmtJournal); - break; - } - - /* If the SQLITE_CountRows flag is set in sqlite3.flags mask, then - ** DML statements invoke this opcode to return the number of rows - ** modified to the user. This is the only way that a VM that - ** opens a statement transaction may invoke this opcode. - ** - ** In case this is such a statement, close any statement transaction - ** opened by this VM before returning control to the user. This is to - ** ensure that statement-transactions are always nested, not overlapping. - ** If the open statement-transaction is not closed here, then the user - ** may step another VM that opens its own statement transaction. This - ** may lead to overlapping statement transactions. - ** - ** The statement transaction is never a top-level transaction. Hence - ** the RELEASE call below can never fail. - */ - Debug.Assert(p.iStatement == 0 || (db.flags & SQLITE_CountRows) != 0); - rc = sqlite3VdbeCloseStatement(p, SAVEPOINT_RELEASE); - if (NEVER(rc != SQLITE_OK)) { - break; - } - - /* Invalidate all ephemeral cursor row caches */ - p.cacheCtr = (p.cacheCtr + 2) | 1; - - /* Make sure the results of the current row are \000 terminated - ** and have an assigned type. The results are de-ephemeralized as - ** as side effect. - */ - //pMem = p.pResultSet = aMem[pOp.p1]; - p.pResultSet = new Mem[pOp.p2]; - for (i = 0; i < pOp.p2; i++) { - p.pResultSet[i] = aMem[pOp.p1 + i]; - Debug.Assert(memIsValid(p.pResultSet[i])); - //Deephemeralize( p.pResultSet[i] ); - //Debug.Assert( ( p.pResultSet[i].flags & MEM_Ephem ) == 0 - // || ( p.pResultSet[i].flags & ( MEM_Str | MEM_Blob ) ) == 0 ); - sqlite3VdbeMemNulTerminate(p.pResultSet[i]); //sqlite3VdbeMemNulTerminate(pMem[i]); - sqlite3VdbeMemStoreType(p.pResultSet[i]); - REGISTER_TRACE(p, pOp.p1 + i, p.pResultSet[i]); - } - // if ( db.mallocFailed != 0 ) goto no_mem; - - /* Return SQLITE_ROW - */ - p.pc = pc + 1; - rc = SQLITE_ROW; - goto vdbe_return; - } + /* Opcode: ResultRow P1 P2 * * * + ** + ** The registers P1 through P1+P2-1 contain a single row of + ** results. This opcode causes the sqlite3_step() call to terminate + ** with an SQLITE_ROW return code and it sets up the sqlite3_stmt + ** structure to provide access to the top P1 values as the result + ** row. + */ + case OP_ResultRow: + { + //Mem[] pMem; + int i; + Debug.Assert( p.nResColumn == pOp.p2 ); + Debug.Assert( pOp.p1 > 0 ); + Debug.Assert( pOp.p1 + pOp.p2 <= p.nMem + 1 ); + + /* If this statement has violated immediate foreign key constraints, do + ** not return the number of rows modified. And do not RELEASE the statement + ** transaction. It needs to be rolled back. */ + if ( SQLITE_OK != ( rc = sqlite3VdbeCheckFk( p, 0 ) ) ) + { + Debug.Assert( ( db.flags & SQLITE_CountRows ) != 0 ); + Debug.Assert( p.usesStmtJournal ); + break; + } + + /* If the SQLITE_CountRows flag is set in sqlite3.flags mask, then + ** DML statements invoke this opcode to return the number of rows + ** modified to the user. This is the only way that a VM that + ** opens a statement transaction may invoke this opcode. + ** + ** In case this is such a statement, close any statement transaction + ** opened by this VM before returning control to the user. This is to + ** ensure that statement-transactions are always nested, not overlapping. + ** If the open statement-transaction is not closed here, then the user + ** may step another VM that opens its own statement transaction. This + ** may lead to overlapping statement transactions. + ** + ** The statement transaction is never a top-level transaction. Hence + ** the RELEASE call below can never fail. + */ + Debug.Assert( p.iStatement == 0 || ( db.flags & SQLITE_CountRows ) != 0 ); + rc = sqlite3VdbeCloseStatement( p, SAVEPOINT_RELEASE ); + if ( NEVER( rc != SQLITE_OK ) ) + { + break; + } + + /* Invalidate all ephemeral cursor row caches */ + p.cacheCtr = ( p.cacheCtr + 2 ) | 1; + + /* Make sure the results of the current row are \000 terminated + ** and have an assigned type. The results are de-ephemeralized as + ** as side effect. + */ + //pMem = p.pResultSet = aMem[pOp.p1]; + p.pResultSet = new Mem[pOp.p2]; + for ( i = 0; i < pOp.p2; i++ ) + { + p.pResultSet[i] = aMem[pOp.p1 + i]; + Debug.Assert( memIsValid( p.pResultSet[i] ) ); + //Deephemeralize( p.pResultSet[i] ); + //Debug.Assert( ( p.pResultSet[i].flags & MEM_Ephem ) == 0 + // || ( p.pResultSet[i].flags & ( MEM_Str | MEM_Blob ) ) == 0 ); + sqlite3VdbeMemNulTerminate( p.pResultSet[i] ); //sqlite3VdbeMemNulTerminate(pMem[i]); + sqlite3VdbeMemStoreType( p.pResultSet[i] ); + REGISTER_TRACE( p, pOp.p1 + i, p.pResultSet[i] ); + } + // if ( db.mallocFailed != 0 ) goto no_mem; + + /* Return SQLITE_ROW + */ + p.pc = pc + 1; + rc = SQLITE_ROW; + goto vdbe_return; + } - /* Opcode: Concat P1 P2 P3 * * - ** - ** Add the text in register P1 onto the end of the text in - ** register P2 and store the result in register P3. - ** If either the P1 or P2 text are NULL then store NULL in P3. - ** - ** P3 = P2 || P1 - ** - ** It is illegal for P1 and P3 to be the same register. Sometimes, - ** if P3 is the same register as P2, the implementation is able - ** to avoid a memcpy(). - */ - case OP_Concat: { /* same as TK_CONCAT, in1, in2, ref3 */ - i64 nByte; - - pIn1 = aMem[pOp.p1]; - pIn2 = aMem[pOp.p2]; - pOut = aMem[pOp.p3]; - Debug.Assert(pIn1 != pOut); - if (((pIn1.flags | pIn2.flags) & MEM_Null) != 0) { - sqlite3VdbeMemSetNull(pOut); - break; - } - if (ExpandBlob(pIn1) != 0 || ExpandBlob(pIn2) != 0) - goto no_mem; - if (((pIn1.flags & (MEM_Str | MEM_Blob)) == 0) && sqlite3VdbeMemStringify(pIn1, encoding) != 0) { - goto no_mem; - }// Stringify(pIn1, encoding); - if (((pIn2.flags & (MEM_Str | MEM_Blob)) == 0) && sqlite3VdbeMemStringify(pIn2, encoding) != 0) { - goto no_mem; - }// Stringify(pIn2, encoding); - nByte = pIn1.n + pIn2.n; - if (nByte > db.aLimit[SQLITE_LIMIT_LENGTH]) { - goto too_big; - } - MemSetTypeFlag(pOut, MEM_Str); - //if ( sqlite3VdbeMemGrow( pOut, (int)nByte + 2, ( pOut == pIn2 ) ? 1 : 0 ) != 0 ) - //{ - // goto no_mem; - //} - //if ( pOut != pIn2 ) - //{ - // memcpy( pOut.z, pIn2.z, pIn2.n ); - //} - //memcpy( &pOut.z[pIn2.n], pIn1.z, pIn1.n ); - if (pIn2.z != null && pIn2.z.Length >= pIn2.n) - if (pIn1.z != null) - pOut.z = pIn2.z.Substring(0, pIn2.n) + (pIn1.n < pIn1.z.Length ? pIn1.z.Substring(0, pIn1.n) : pIn1.z); - else { - if ((pIn1.flags & MEM_Blob) == 0) //String as Blob - { - StringBuilder sb = new StringBuilder(pIn1.n); - for (int i = 0; i < pIn1.n; i++) - sb.Append((byte)pIn1.zBLOB[i]); - pOut.z = pIn2.z.Substring(0, pIn2.n) + sb.ToString(); - } else // UTF-8 Blob - pOut.z = pIn2.z.Substring(0, pIn2.n) + Encoding.UTF8.GetString(pIn1.zBLOB, 0, pIn1.zBLOB.Length); - } - else { - pOut.zBLOB = sqlite3Malloc(pIn1.n + pIn2.n); - Buffer.BlockCopy(pIn2.zBLOB, 0, pOut.zBLOB, 0, pIn2.n); - if (pIn1.zBLOB != null) - Buffer.BlockCopy(pIn1.zBLOB, 0, pOut.zBLOB, pIn2.n, pIn1.n); - else - for (int i = 0; i < pIn1.n; i++) - pOut.zBLOB[pIn2.n + i] = (byte)pIn1.z[i]; - } //pOut.z[nByte] = 0; - //pOut.z[nByte + 1] = 0; - pOut.flags |= MEM_Term; - pOut.n = (int)nByte; - pOut.enc = encoding; + /* Opcode: Concat P1 P2 P3 * * + ** + ** Add the text in register P1 onto the end of the text in + ** register P2 and store the result in register P3. + ** If either the P1 or P2 text are NULL then store NULL in P3. + ** + ** P3 = P2 || P1 + ** + ** It is illegal for P1 and P3 to be the same register. Sometimes, + ** if P3 is the same register as P2, the implementation is able + ** to avoid a memcpy(). + */ + case OP_Concat: + { /* same as TK_CONCAT, in1, in2, ref3 */ + i64 nByte; + + pIn1 = aMem[pOp.p1]; + pIn2 = aMem[pOp.p2]; + pOut = aMem[pOp.p3]; + Debug.Assert( pIn1 != pOut ); + if ( ( ( pIn1.flags | pIn2.flags ) & MEM_Null ) != 0 ) + { + sqlite3VdbeMemSetNull( pOut ); + break; + } + if ( ExpandBlob( pIn1 ) != 0 || ExpandBlob( pIn2 ) != 0 ) + goto no_mem; + if ( ( ( pIn1.flags & ( MEM_Str | MEM_Blob ) ) == 0 ) && sqlite3VdbeMemStringify( pIn1, encoding ) != 0 ) + { + goto no_mem; + }// Stringify(pIn1, encoding); + if ( ( ( pIn2.flags & ( MEM_Str | MEM_Blob ) ) == 0 ) && sqlite3VdbeMemStringify( pIn2, encoding ) != 0 ) + { + goto no_mem; + }// Stringify(pIn2, encoding); + nByte = pIn1.n + pIn2.n; + if ( nByte > db.aLimit[SQLITE_LIMIT_LENGTH] ) + { + goto too_big; + } + MemSetTypeFlag( pOut, MEM_Str ); + //if ( sqlite3VdbeMemGrow( pOut, (int)nByte + 2, ( pOut == pIn2 ) ? 1 : 0 ) != 0 ) + //{ + // goto no_mem; + //} + //if ( pOut != pIn2 ) + //{ + // memcpy( pOut.z, pIn2.z, pIn2.n ); + //} + //memcpy( &pOut.z[pIn2.n], pIn1.z, pIn1.n ); + if ( pIn2.z != null && pIn2.z.Length >= pIn2.n ) + if ( pIn1.z != null ) + pOut.z = pIn2.z.Substring( 0, pIn2.n ) + ( pIn1.n < pIn1.z.Length ? pIn1.z.Substring( 0, pIn1.n ) : pIn1.z ); + else + { + if ( ( pIn1.flags & MEM_Blob ) == 0 ) //String as Blob + { + StringBuilder sb = new StringBuilder( pIn1.n ); + for ( int i = 0; i < pIn1.n; i++ ) + sb.Append( (byte)pIn1.zBLOB[i] ); + pOut.z = pIn2.z.Substring( 0, pIn2.n ) + sb.ToString(); + } + else // UTF-8 Blob + pOut.z = pIn2.z.Substring( 0, pIn2.n ) + Encoding.UTF8.GetString( pIn1.zBLOB, 0, pIn1.zBLOB.Length ); + } + else + { + pOut.zBLOB = sqlite3Malloc( pIn1.n + pIn2.n ); + Buffer.BlockCopy( pIn2.zBLOB, 0, pOut.zBLOB, 0, pIn2.n ); + if ( pIn1.zBLOB != null ) + Buffer.BlockCopy( pIn1.zBLOB, 0, pOut.zBLOB, pIn2.n, pIn1.n ); + else + for ( int i = 0; i < pIn1.n; i++ ) + pOut.zBLOB[pIn2.n + i] = (byte)pIn1.z[i]; + } //pOut.z[nByte] = 0; + //pOut.z[nByte + 1] = 0; + pOut.flags |= MEM_Term; + pOut.n = (int)nByte; + pOut.enc = encoding; #if SQLITE_TEST UPDATE_MAX_BLOBSIZE( pOut ); #endif - break; - } + break; + } - /* Opcode: Add P1 P2 P3 * * - ** - ** Add the value in register P1 to the value in register P2 - ** and store the result in register P3. - ** If either input is NULL, the result is NULL. - */ - /* Opcode: Multiply P1 P2 P3 * * - ** - ** - ** Multiply the value in register P1 by the value in register P2 - ** and store the result in register P3. - ** If either input is NULL, the result is NULL. - */ - /* Opcode: Subtract P1 P2 P3 * * - ** - ** Subtract the value in register P1 from the value in register P2 - ** and store the result in register P3. - ** If either input is NULL, the result is NULL. - */ - /* Opcode: Divide P1 P2 P3 * * - ** - ** Divide the value in register P1 by the value in register P2 - ** and store the result in register P3 (P3=P2/P1). If the value in - ** register P1 is zero, then the result is NULL. If either input is - ** NULL, the result is NULL. - */ - /* Opcode: Remainder P1 P2 P3 * * - ** - ** Compute the remainder after integer division of the value in - ** register P1 by the value in register P2 and store the result in P3. - ** If the value in register P2 is zero the result is NULL. - ** If either operand is NULL, the result is NULL. - */ - case OP_Add: /* same as TK_PLUS, in1, in2, ref3 */ - case OP_Subtract: /* same as TK_MINUS, in1, in2, ref3 */ - case OP_Multiply: /* same as TK_STAR, in1, in2, ref3 */ - case OP_Divide: /* same as TK_SLASH, in1, in2, ref3 */ - case OP_Remainder: { /* same as TK_REM, in1, in2, ref3 */ - int flags; /* Combined MEM_* flags from both inputs */ - i64 iA; /* Integer value of left operand */ - i64 iB = 0; /* Integer value of right operand */ - double rA; /* Real value of left operand */ - double rB; /* Real value of right operand */ - - pIn1 = aMem[pOp.p1]; - applyNumericAffinity(pIn1); - pIn2 = aMem[pOp.p2]; - applyNumericAffinity(pIn2); - pOut = aMem[pOp.p3]; - flags = pIn1.flags | pIn2.flags; - if ((flags & MEM_Null) != 0) - goto arithmetic_result_is_null; - bool fp_math; - if (!(fp_math = !((pIn1.flags & pIn2.flags & MEM_Int) == MEM_Int))) { - iA = pIn1.u.i; - iB = pIn2.u.i; - switch (pOp.opcode) { - case OP_Add: { - if (sqlite3AddInt64(ref iB, iA) != 0) - fp_math = true; // goto fp_math - break; - } - case OP_Subtract: { - if (sqlite3SubInt64(ref iB, iA) != 0) - fp_math = true; // goto fp_math - break; - } - case OP_Multiply: { - if (sqlite3MulInt64(ref iB, iA) != 0) - fp_math = true; // goto fp_math - break; - } - case OP_Divide: { - if (iA == 0) - goto arithmetic_result_is_null; - if (iA == -1 && iB == SMALLEST_INT64) { - fp_math = true; // goto fp_math - break; - } - iB /= iA; - break; - } - default: { - if (iA == 0) - goto arithmetic_result_is_null; - if (iA == -1) - iA = 1; - iB %= iA; - break; - } - } - } - if (!fp_math) { - pOut.u.i = iB; - MemSetTypeFlag(pOut, MEM_Int); - } else { - //fp_math: - rA = sqlite3VdbeRealValue(pIn1); - rB = sqlite3VdbeRealValue(pIn2); - switch (pOp.opcode) { - case OP_Add: - rB += rA; - break; - case OP_Subtract: - rB -= rA; - break; - case OP_Multiply: - rB *= rA; - break; - case OP_Divide: { - /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ - if (rA == (double)0) - goto arithmetic_result_is_null; - rB /= rA; - break; - } - default: { - iA = (i64)rA; - iB = (i64)rB; - if (iA == 0) - goto arithmetic_result_is_null; - if (iA == -1) - iA = 1; - rB = (double)(iB % iA); - break; - } - } + /* Opcode: Add P1 P2 P3 * * + ** + ** Add the value in register P1 to the value in register P2 + ** and store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + /* Opcode: Multiply P1 P2 P3 * * + ** + ** + ** Multiply the value in register P1 by the value in register P2 + ** and store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + /* Opcode: Subtract P1 P2 P3 * * + ** + ** Subtract the value in register P1 from the value in register P2 + ** and store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + /* Opcode: Divide P1 P2 P3 * * + ** + ** Divide the value in register P1 by the value in register P2 + ** and store the result in register P3 (P3=P2/P1). If the value in + ** register P1 is zero, then the result is NULL. If either input is + ** NULL, the result is NULL. + */ + /* Opcode: Remainder P1 P2 P3 * * + ** + ** Compute the remainder after integer division of the value in + ** register P1 by the value in register P2 and store the result in P3. + ** If the value in register P2 is zero the result is NULL. + ** If either operand is NULL, the result is NULL. + */ + case OP_Add: /* same as TK_PLUS, in1, in2, ref3 */ + case OP_Subtract: /* same as TK_MINUS, in1, in2, ref3 */ + case OP_Multiply: /* same as TK_STAR, in1, in2, ref3 */ + case OP_Divide: /* same as TK_SLASH, in1, in2, ref3 */ + case OP_Remainder: + { /* same as TK_REM, in1, in2, ref3 */ + int flags; /* Combined MEM_* flags from both inputs */ + i64 iA; /* Integer value of left operand */ + i64 iB = 0; /* Integer value of right operand */ + double rA; /* Real value of left operand */ + double rB; /* Real value of right operand */ + + pIn1 = aMem[pOp.p1]; + applyNumericAffinity( pIn1 ); + pIn2 = aMem[pOp.p2]; + applyNumericAffinity( pIn2 ); + pOut = aMem[pOp.p3]; + flags = pIn1.flags | pIn2.flags; + if ( ( flags & MEM_Null ) != 0 ) + goto arithmetic_result_is_null; + bool fp_math; + if ( !( fp_math = !( ( pIn1.flags & pIn2.flags & MEM_Int ) == MEM_Int ) ) ) + { + iA = pIn1.u.i; + iB = pIn2.u.i; + switch ( pOp.opcode ) + { + case OP_Add: + { + if ( sqlite3AddInt64( ref iB, iA ) != 0 ) + fp_math = true; // goto fp_math + break; + } + case OP_Subtract: + { + if ( sqlite3SubInt64( ref iB, iA ) != 0 ) + fp_math = true; // goto fp_math + break; + } + case OP_Multiply: + { + if ( sqlite3MulInt64( ref iB, iA ) != 0 ) + fp_math = true; // goto fp_math + break; + } + case OP_Divide: + { + if ( iA == 0 ) + goto arithmetic_result_is_null; + if ( iA == -1 && iB == SMALLEST_INT64 ) + { + fp_math = true; // goto fp_math + break; + } + iB /= iA; + break; + } + default: + { + if ( iA == 0 ) + goto arithmetic_result_is_null; + if ( iA == -1 ) + iA = 1; + iB %= iA; + break; + } + } + } + if ( !fp_math ) + { + pOut.u.i = iB; + MemSetTypeFlag( pOut, MEM_Int ); + } + else + { + //fp_math: + rA = sqlite3VdbeRealValue( pIn1 ); + rB = sqlite3VdbeRealValue( pIn2 ); + switch ( pOp.opcode ) + { + case OP_Add: + rB += rA; + break; + case OP_Subtract: + rB -= rA; + break; + case OP_Multiply: + rB *= rA; + break; + case OP_Divide: + { + /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ + if ( rA == (double)0 ) + goto arithmetic_result_is_null; + rB /= rA; + break; + } + default: + { + iA = (i64)rA; + iB = (i64)rB; + if ( iA == 0 ) + goto arithmetic_result_is_null; + if ( iA == -1 ) + iA = 1; + rB = (double)( iB % iA ); + break; + } + } #if SQLITE_OMIT_FLOATING_POINT pOut->u.i = rB; MemSetTypeFlag(pOut, MEM_Int); #else - if (sqlite3IsNaN(rB)) { - goto arithmetic_result_is_null; - } - pOut.r = rB; - MemSetTypeFlag(pOut, MEM_Real); - if ((flags & MEM_Real) == 0) { - sqlite3VdbeIntegerAffinity(pOut); - } + if ( sqlite3IsNaN( rB ) ) + { + goto arithmetic_result_is_null; + } + pOut.r = rB; + MemSetTypeFlag( pOut, MEM_Real ); + if ( ( flags & MEM_Real ) == 0 ) + { + sqlite3VdbeIntegerAffinity( pOut ); + } #endif - } - break; + } + break; - arithmetic_result_is_null: - sqlite3VdbeMemSetNull(pOut); - break; - } +arithmetic_result_is_null: + sqlite3VdbeMemSetNull( pOut ); + break; + } - /* Opcode: CollSeq * * P4 - ** - ** P4 is a pointer to a CollSeq struct. If the next call to a user function - ** or aggregate calls sqlite3GetFuncCollSeq(), this collation sequence will - ** be returned. This is used by the built-in min(), max() and nullif() - ** functions. - ** - ** The interface used by the implementation of the aforementioned functions - ** to retrieve the collation sequence set by this opcode is not available - ** publicly, only to user functions defined in func.c. - */ - case OP_CollSeq: { - Debug.Assert(pOp.p4type == P4_COLLSEQ); - break; - } + /* Opcode: CollSeq * * P4 + ** + ** P4 is a pointer to a CollSeq struct. If the next call to a user function + ** or aggregate calls sqlite3GetFuncCollSeq(), this collation sequence will + ** be returned. This is used by the built-in min(), max() and nullif() + ** functions. + ** + ** The interface used by the implementation of the aforementioned functions + ** to retrieve the collation sequence set by this opcode is not available + ** publicly, only to user functions defined in func.c. + */ + case OP_CollSeq: + { + Debug.Assert( pOp.p4type == P4_COLLSEQ ); + break; + } - /* Opcode: Function P1 P2 P3 P4 P5 - ** - ** Invoke a user function (P4 is a pointer to a Function structure that - ** defines the function) with P5 arguments taken from register P2 and - ** successors. The result of the function is stored in register P3. - ** Register P3 must not be one of the function inputs. - ** - ** P1 is a 32-bit bitmask indicating whether or not each argument to the - ** function was determined to be constant at compile time. If the first - ** argument was constant then bit 0 of P1 is set. This is used to determine - ** whether meta data associated with a user function argument using the - ** sqlite3_set_auxdata() API may be safely retained until the next - ** invocation of this opcode. - ** - ** See also: AggStep and AggFinal - */ - case OP_Function: { - int i; - Mem pArg; - sqlite3_context ctx = new sqlite3_context(); - sqlite3_value[] apVal; - int n; - - n = pOp.p5; - apVal = p.apArg; - Debug.Assert(apVal != null || n == 0); - Debug.Assert(pOp.p3 > 0 && pOp.p3 <= p.nMem); - pOut = aMem[pOp.p3]; - memAboutToChange(p, pOut); - - Debug.Assert(n == 0 || (pOp.p2 > 0 && pOp.p2 + n <= p.nMem + 1)); - Debug.Assert(pOp.p3 < pOp.p2 || pOp.p3 >= pOp.p2 + n); - //pArg = aMem[pOp.p2]; - for (i = 0; i < n; i++)//, pArg++) - { - pArg = aMem[pOp.p2 + i]; - Debug.Assert(memIsValid(pArg)); - apVal[i] = pArg; - Deephemeralize(pArg); - sqlite3VdbeMemStoreType(pArg); - REGISTER_TRACE(p, pOp.p2 + i, pArg); - } - - Debug.Assert(pOp.p4type == P4_FUNCDEF || pOp.p4type == P4_VDBEFUNC); - if (pOp.p4type == P4_FUNCDEF) { - ctx.pFunc = pOp.p4.pFunc; - ctx.pVdbeFunc = null; - } else { - ctx.pVdbeFunc = (VdbeFunc)pOp.p4.pVdbeFunc; - ctx.pFunc = ctx.pVdbeFunc.pFunc; - } - - ctx.s.flags = MEM_Null; - ctx.s.db = db; - ctx.s.xDel = null; - //ctx.s.zMalloc = null; - - /* The output cell may already have a buffer allocated. Move - ** the pointer to ctx.s so in case the user-function can use - ** the already allocated buffer instead of allocating a new one. - */ - sqlite3VdbeMemMove(ctx.s, pOut); - MemSetTypeFlag(ctx.s, MEM_Null); - - ctx.isError = 0; - if ((ctx.pFunc.flags & SQLITE_FUNC_NEEDCOLL) != 0) { - Debug.Assert(pc > 1);//Debug.Assert(pOp > aOp); - Debug.Assert(p.aOp[pc - 1].p4type == P4_COLLSEQ);//Debug.Assert(pOp[-1].p4type == P4_COLLSEQ); - Debug.Assert(p.aOp[pc - 1].opcode == OP_CollSeq);//Debug.Assert(pOp[-1].opcode == OP_CollSeq); - ctx.pColl = p.aOp[pc - 1].p4.pColl;//ctx.pColl = pOp[-1].p4.pColl; - } - db.lastRowid = lastRowid; - ctx.pFunc.xFunc(ctx, n, apVal);///* IMP: R-24505-23230 */ - lastRowid = db.lastRowid; - - /* If any auxillary data functions have been called by this user function, - ** immediately call the destructor for any non-static values. - */ - if (ctx.pVdbeFunc != null) { - sqlite3VdbeDeleteAuxData(ctx.pVdbeFunc, pOp.p1); - pOp.p4.pVdbeFunc = ctx.pVdbeFunc; - pOp.p4type = P4_VDBEFUNC; - } - - //if ( db->mallocFailed ) - //{ - // /* Even though a malloc() has failed, the implementation of the - // ** user function may have called an sqlite3_result_XXX() function - // ** to return a value. The following call releases any resources - // ** associated with such a value. - // */ - // sqlite3VdbeMemRelease( &u.ag.ctx.s ); - // goto no_mem; - //} - - /* If the function returned an error, throw an exception */ - if (ctx.isError != 0) { - sqlite3SetString(ref p.zErrMsg, db, sqlite3_value_text(ctx.s)); - rc = ctx.isError; - } - - /* Copy the result of the function into register P3 */ - sqlite3VdbeChangeEncoding(ctx.s, encoding); - sqlite3VdbeMemMove(pOut, ctx.s); - if (sqlite3VdbeMemTooBig(pOut)) { - goto too_big; - } + /* Opcode: Function P1 P2 P3 P4 P5 + ** + ** Invoke a user function (P4 is a pointer to a Function structure that + ** defines the function) with P5 arguments taken from register P2 and + ** successors. The result of the function is stored in register P3. + ** Register P3 must not be one of the function inputs. + ** + ** P1 is a 32-bit bitmask indicating whether or not each argument to the + ** function was determined to be constant at compile time. If the first + ** argument was constant then bit 0 of P1 is set. This is used to determine + ** whether meta data associated with a user function argument using the + ** sqlite3_set_auxdata() API may be safely retained until the next + ** invocation of this opcode. + ** + ** See also: AggStep and AggFinal + */ + case OP_Function: + { + int i; + Mem pArg; + sqlite3_context ctx = new sqlite3_context(); + sqlite3_value[] apVal; + int n; + + n = pOp.p5; + apVal = p.apArg; + Debug.Assert( apVal != null || n == 0 ); + Debug.Assert( pOp.p3 > 0 && pOp.p3 <= p.nMem ); + pOut = aMem[pOp.p3]; + memAboutToChange( p, pOut ); + + Debug.Assert( n == 0 || ( pOp.p2 > 0 && pOp.p2 + n <= p.nMem + 1 ) ); + Debug.Assert( pOp.p3 < pOp.p2 || pOp.p3 >= pOp.p2 + n ); + //pArg = aMem[pOp.p2]; + for ( i = 0; i < n; i++ )//, pArg++) + { + pArg = aMem[pOp.p2 + i]; + Debug.Assert( memIsValid( pArg ) ); + apVal[i] = pArg; + Deephemeralize( pArg ); + sqlite3VdbeMemStoreType( pArg ); + REGISTER_TRACE( p, pOp.p2 + i, pArg ); + } + + Debug.Assert( pOp.p4type == P4_FUNCDEF || pOp.p4type == P4_VDBEFUNC ); + if ( pOp.p4type == P4_FUNCDEF ) + { + ctx.pFunc = pOp.p4.pFunc; + ctx.pVdbeFunc = null; + } + else + { + ctx.pVdbeFunc = (VdbeFunc)pOp.p4.pVdbeFunc; + ctx.pFunc = ctx.pVdbeFunc.pFunc; + } + + ctx.s.flags = MEM_Null; + ctx.s.db = db; + ctx.s.xDel = null; + //ctx.s.zMalloc = null; + + /* The output cell may already have a buffer allocated. Move + ** the pointer to ctx.s so in case the user-function can use + ** the already allocated buffer instead of allocating a new one. + */ + sqlite3VdbeMemMove( ctx.s, pOut ); + MemSetTypeFlag( ctx.s, MEM_Null ); + + ctx.isError = 0; + if ( ( ctx.pFunc.flags & SQLITE_FUNC_NEEDCOLL ) != 0 ) + { + Debug.Assert( pc > 1 );//Debug.Assert(pOp > aOp); + Debug.Assert( p.aOp[pc - 1].p4type == P4_COLLSEQ );//Debug.Assert(pOp[-1].p4type == P4_COLLSEQ); + Debug.Assert( p.aOp[pc - 1].opcode == OP_CollSeq );//Debug.Assert(pOp[-1].opcode == OP_CollSeq); + ctx.pColl = p.aOp[pc - 1].p4.pColl;//ctx.pColl = pOp[-1].p4.pColl; + } + db.lastRowid = lastRowid; + ctx.pFunc.xFunc( ctx, n, apVal );///* IMP: R-24505-23230 */ + lastRowid = db.lastRowid; + + /* If any auxillary data functions have been called by this user function, + ** immediately call the destructor for any non-static values. + */ + if ( ctx.pVdbeFunc != null ) + { + sqlite3VdbeDeleteAuxData( ctx.pVdbeFunc, pOp.p1 ); + pOp.p4.pVdbeFunc = ctx.pVdbeFunc; + pOp.p4type = P4_VDBEFUNC; + } + + //if ( db->mallocFailed ) + //{ + // /* Even though a malloc() has failed, the implementation of the + // ** user function may have called an sqlite3_result_XXX() function + // ** to return a value. The following call releases any resources + // ** associated with such a value. + // */ + // sqlite3VdbeMemRelease( &u.ag.ctx.s ); + // goto no_mem; + //} + + /* If the function returned an error, throw an exception */ + if ( ctx.isError != 0 ) + { + sqlite3SetString( ref p.zErrMsg, db, sqlite3_value_text( ctx.s ) ); + rc = ctx.isError; + } + + /* Copy the result of the function into register P3 */ + sqlite3VdbeChangeEncoding( ctx.s, encoding ); + sqlite3VdbeMemMove( pOut, ctx.s ); + if ( sqlite3VdbeMemTooBig( pOut ) ) + { + goto too_big; + } #if FALSE /* The app-defined function has done something that as caused this ** statement to expire. (Perhaps the function called sqlite3_exec() @@ -1639,2035 +1804,2297 @@ Vdbe p /* The VDBE */ if( p.expired ) rc = SQLITE_ABORT; #endif - REGISTER_TRACE(p, pOp.p3, pOut); + REGISTER_TRACE( p, pOp.p3, pOut ); #if SQLITE_TEST UPDATE_MAX_BLOBSIZE( pOut ); #endif - break; - } - - /* Opcode: BitAnd P1 P2 P3 * * - ** - ** Take the bit-wise AND of the values in register P1 and P2 and - ** store the result in register P3. - ** If either input is NULL, the result is NULL. - */ - /* Opcode: BitOr P1 P2 P3 * * - ** - ** Take the bit-wise OR of the values in register P1 and P2 and - ** store the result in register P3. - ** If either input is NULL, the result is NULL. - */ - /* Opcode: ShiftLeft P1 P2 P3 * * - ** - ** Shift the integer value in register P2 to the left by the - ** number of bits specified by the integer in register P1. - ** Store the result in register P3. - ** If either input is NULL, the result is NULL. - */ - /* Opcode: ShiftRight P1 P2 P3 * * - ** - ** Shift the integer value in register P2 to the right by the - ** number of bits specified by the integer in register P1. - ** Store the result in register P3. - ** If either input is NULL, the result is NULL. - */ - case OP_BitAnd: /* same as TK_BITAND, in1, in2, ref3 */ - case OP_BitOr: /* same as TK_BITOR, in1, in2, ref3 */ - case OP_ShiftLeft: /* same as TK_LSHIFT, in1, in2, ref3 */ - case OP_ShiftRight: { /* same as TK_RSHIFT, in1, in2, ref3 */ - i64 iA; - u64 uA; - i64 iB; - u8 op; - - pIn1 = aMem[pOp.p1]; - pIn2 = aMem[pOp.p2]; - pOut = aMem[pOp.p3]; - if (((pIn1.flags | pIn2.flags) & MEM_Null) != 0) { - sqlite3VdbeMemSetNull(pOut); - break; - } - iA = sqlite3VdbeIntValue(pIn2); - iB = sqlite3VdbeIntValue(pIn1); - op = pOp.opcode; - if (op == OP_BitAnd) { - iA &= iB; - } else if (op == OP_BitOr) { - iA |= iB; - } else if (iB != 0) { - Debug.Assert(op == OP_ShiftRight || op == OP_ShiftLeft); - - /* If shifting by a negative amount, shift in the other direction */ - if (iB < 0) { - Debug.Assert(OP_ShiftRight == OP_ShiftLeft + 1); - op = (u8)(2 * OP_ShiftLeft + 1 - op); - iB = iB > (-64) ? -iB : 64; - } - - if (iB >= 64) { - iA = (iA >= 0 || op == OP_ShiftLeft) ? 0 : -1; - } else { - //uA = (ulong)(iA << 0); // memcpy( &uA, &iA, sizeof( uA ) ); - if (op == OP_ShiftLeft) { - iA = iA << (int)iB; - } else { - iA = iA >> (int)iB; - /* Sign-extend on a right shift of a negative number */ - //if ( iA < 0 ) - // uA |= ( ( (0xffffffff ) << (u8)32 ) | 0xffffffff ) << (u8)( 64 - iB ); - } - //iA = (long)( uA << 0 ); //memcpy( &iA, &uA, sizeof( iA ) ); - } - } - pOut.u.i = iA; - MemSetTypeFlag(pOut, MEM_Int); - break; - } + break; + } - /* Opcode: AddImm P1 P2 * * * - ** - ** Add the constant P2 to the value in register P1. - ** The result is always an integer. - ** - ** To force any register to be an integer, just add 0. - */ - case OP_AddImm: { /* in1 */ - pIn1 = aMem[pOp.p1]; - memAboutToChange(p, pIn1); - sqlite3VdbeMemIntegerify(pIn1); - pIn1.u.i += pOp.p2; - break; - } + /* Opcode: BitAnd P1 P2 P3 * * + ** + ** Take the bit-wise AND of the values in register P1 and P2 and + ** store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + /* Opcode: BitOr P1 P2 P3 * * + ** + ** Take the bit-wise OR of the values in register P1 and P2 and + ** store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + /* Opcode: ShiftLeft P1 P2 P3 * * + ** + ** Shift the integer value in register P2 to the left by the + ** number of bits specified by the integer in register P1. + ** Store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + /* Opcode: ShiftRight P1 P2 P3 * * + ** + ** Shift the integer value in register P2 to the right by the + ** number of bits specified by the integer in register P1. + ** Store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + case OP_BitAnd: /* same as TK_BITAND, in1, in2, ref3 */ + case OP_BitOr: /* same as TK_BITOR, in1, in2, ref3 */ + case OP_ShiftLeft: /* same as TK_LSHIFT, in1, in2, ref3 */ + case OP_ShiftRight: + { /* same as TK_RSHIFT, in1, in2, ref3 */ + i64 iA; + u64 uA; + i64 iB; + u8 op; + + pIn1 = aMem[pOp.p1]; + pIn2 = aMem[pOp.p2]; + pOut = aMem[pOp.p3]; + if ( ( ( pIn1.flags | pIn2.flags ) & MEM_Null ) != 0 ) + { + sqlite3VdbeMemSetNull( pOut ); + break; + } + iA = sqlite3VdbeIntValue( pIn2 ); + iB = sqlite3VdbeIntValue( pIn1 ); + op = pOp.opcode; + if ( op == OP_BitAnd ) + { + iA &= iB; + } + else if ( op == OP_BitOr ) + { + iA |= iB; + } + else if ( iB != 0 ) + { + Debug.Assert( op == OP_ShiftRight || op == OP_ShiftLeft ); + + /* If shifting by a negative amount, shift in the other direction */ + if ( iB < 0 ) + { + Debug.Assert( OP_ShiftRight == OP_ShiftLeft + 1 ); + op = (u8)( 2 * OP_ShiftLeft + 1 - op ); + iB = iB > ( -64 ) ? -iB : 64; + } - /* Opcode: MustBeInt P1 P2 * * * - ** - ** Force the value in register P1 to be an integer. If the value - ** in P1 is not an integer and cannot be converted into an integer - ** without data loss, then jump immediately to P2, or if P2==0 - ** raise an SQLITE_MISMATCH exception. - */ - case OP_MustBeInt: { /* jump, in1 */ - pIn1 = aMem[pOp.p1]; - applyAffinity(pIn1, SQLITE_AFF_NUMERIC, encoding); - if ((pIn1.flags & MEM_Int) == 0) { - if (pOp.p2 == 0) { - rc = SQLITE_MISMATCH; - goto abort_due_to_error; - } else { - pc = pOp.p2 - 1; - } - } else { - MemSetTypeFlag(pIn1, MEM_Int); - } - break; - } + if ( iB >= 64 ) + { + iA = ( iA >= 0 || op == OP_ShiftLeft ) ? 0 : -1; + } + else + { + //uA = (ulong)(iA << 0); // memcpy( &uA, &iA, sizeof( uA ) ); + if ( op == OP_ShiftLeft ) + { + iA = iA << (int)iB; + } + else + { + iA = iA >> (int)iB; + /* Sign-extend on a right shift of a negative number */ + //if ( iA < 0 ) + // uA |= ( ( (0xffffffff ) << (u8)32 ) | 0xffffffff ) << (u8)( 64 - iB ); + } + //iA = (long)( uA << 0 ); //memcpy( &iA, &uA, sizeof( iA ) ); + } + } + pOut.u.i = iA; + MemSetTypeFlag( pOut, MEM_Int ); + break; + } -#if !SQLITE_OMIT_FLOATING_POINT - /* Opcode: RealAffinity P1 * * * * + /* Opcode: AddImm P1 P2 * * * ** - ** If register P1 holds an integer convert it to a real value. + ** Add the constant P2 to the value in register P1. + ** The result is always an integer. ** - ** This opcode is used when extracting information from a column that - ** has REAL affinity. Such column values may still be stored as - ** integers, for space efficiency, but after extraction we want them - ** to have only a real value. + ** To force any register to be an integer, just add 0. */ - case OP_RealAffinity: { /* in1 */ - pIn1 = aMem[pOp.p1]; - if ((pIn1.flags & MEM_Int) != 0) { - sqlite3VdbeMemRealify(pIn1); - } - break; - } -#endif + case OP_AddImm: + { /* in1 */ + pIn1 = aMem[pOp.p1]; + memAboutToChange( p, pIn1 ); + sqlite3VdbeMemIntegerify( pIn1 ); + pIn1.u.i += pOp.p2; + break; + } -#if !SQLITE_OMIT_CAST - /* Opcode: ToText P1 * * * * - ** - ** Force the value in register P1 to be text. - ** If the value is numeric, convert it to a string using the - ** equivalent of printf(). Blob values are unchanged and - ** are afterwards simply interpreted as text. + /* Opcode: MustBeInt P1 P2 * * * ** - ** A NULL value is not changed by this routine. It remains NULL. + ** Force the value in register P1 to be an integer. If the value + ** in P1 is not an integer and cannot be converted into an integer + ** without data loss, then jump immediately to P2, or if P2==0 + ** raise an SQLITE_MISMATCH exception. */ - case OP_ToText: { /* same as TK_TO_TEXT, in1 */ - pIn1 = aMem[pOp.p1]; - memAboutToChange(p, pIn1); - if ((pIn1.flags & MEM_Null) != 0) - break; - Debug.Assert(MEM_Str == (MEM_Blob >> 3)); - pIn1.flags |= (u16)((pIn1.flags & MEM_Blob) >> 3); - applyAffinity(pIn1, SQLITE_AFF_TEXT, encoding); - rc = ExpandBlob(pIn1); - Debug.Assert((pIn1.flags & MEM_Str) != 0 /*|| db.mallocFailed != 0 */ ); - pIn1.flags = (u16)(pIn1.flags & ~(MEM_Int | MEM_Real | MEM_Blob | MEM_Zero)); -#if SQLITE_TEST - UPDATE_MAX_BLOBSIZE( pIn1 ); -#endif - break; - } + case OP_MustBeInt: + { /* jump, in1 */ + pIn1 = aMem[pOp.p1]; + applyAffinity( pIn1, SQLITE_AFF_NUMERIC, encoding ); + if ( ( pIn1.flags & MEM_Int ) == 0 ) + { + if ( pOp.p2 == 0 ) + { + rc = SQLITE_MISMATCH; + goto abort_due_to_error; + } + else + { + pc = pOp.p2 - 1; + } + } + else + { + MemSetTypeFlag( pIn1, MEM_Int ); + } + break; + } - /* Opcode: ToBlob P1 * * * * - ** - ** Force the value in register P1 to be a BLOB. - ** If the value is numeric, convert it to a string first. - ** Strings are simply reinterpreted as blobs with no change - ** to the underlying data. - ** - ** A NULL value is not changed by this routine. It remains NULL. - */ - case OP_ToBlob: { /* same as TK_TO_BLOB, in1 */ - pIn1 = aMem[pOp.p1]; - if ((pIn1.flags & MEM_Null) != 0) - break; - if ((pIn1.flags & MEM_Blob) == 0) { - applyAffinity(pIn1, SQLITE_AFF_TEXT, encoding); - Debug.Assert((pIn1.flags & MEM_Str) != 0 /*|| db.mallocFailed != 0 */ ); - MemSetTypeFlag(pIn1, MEM_Blob); - } else { - pIn1.flags = (ushort)(pIn1.flags & ~(MEM_TypeMask & ~MEM_Blob)); - } +#if !SQLITE_OMIT_FLOATING_POINT + /* Opcode: RealAffinity P1 * * * * +** +** If register P1 holds an integer convert it to a real value. +** +** This opcode is used when extracting information from a column that +** has REAL affinity. Such column values may still be stored as +** integers, for space efficiency, but after extraction we want them +** to have only a real value. +*/ + case OP_RealAffinity: + { /* in1 */ + pIn1 = aMem[pOp.p1]; + if ( ( pIn1.flags & MEM_Int ) != 0 ) + { + sqlite3VdbeMemRealify( pIn1 ); + } + break; + } +#endif + +#if !SQLITE_OMIT_CAST + /* Opcode: ToText P1 * * * * +** +** Force the value in register P1 to be text. +** If the value is numeric, convert it to a string using the +** equivalent of printf(). Blob values are unchanged and +** are afterwards simply interpreted as text. +** +** A NULL value is not changed by this routine. It remains NULL. +*/ + case OP_ToText: + { /* same as TK_TO_TEXT, in1 */ + pIn1 = aMem[pOp.p1]; + memAboutToChange( p, pIn1 ); + if ( ( pIn1.flags & MEM_Null ) != 0 ) + break; + Debug.Assert( MEM_Str == ( MEM_Blob >> 3 ) ); + pIn1.flags |= (u16)( ( pIn1.flags & MEM_Blob ) >> 3 ); + applyAffinity( pIn1, SQLITE_AFF_TEXT, encoding ); + rc = ExpandBlob( pIn1 ); + Debug.Assert( ( pIn1.flags & MEM_Str ) != 0 /*|| db.mallocFailed != 0 */ ); + pIn1.flags = (u16)( pIn1.flags & ~( MEM_Int | MEM_Real | MEM_Blob | MEM_Zero ) ); #if SQLITE_TEST UPDATE_MAX_BLOBSIZE( pIn1 ); #endif - break; - } - - /* Opcode: ToNumeric P1 * * * * - ** - ** Force the value in register P1 to be numeric (either an - ** integer or a floating-point number.) - ** If the value is text or blob, try to convert it to an using the - ** equivalent of atoi() or atof() and store 0 if no such conversion - ** is possible. - ** - ** A NULL value is not changed by this routine. It remains NULL. - */ - case OP_ToNumeric: { /* same as TK_TO_NUMERIC, in1 */ - pIn1 = aMem[pOp.p1]; - sqlite3VdbeMemNumerify(pIn1); - break; - } -#endif // * SQLITE_OMIT_CAST */ + break; + } - /* Opcode: ToInt P1 * * * * + /* Opcode: ToBlob P1 * * * * ** - ** Force the value in register P1 to be an integer. If - ** The value is currently a real number, drop its fractional part. - ** If the value is text or blob, try to convert it to an integer using the - ** equivalent of atoi() and store 0 if no such conversion is possible. + ** Force the value in register P1 to be a BLOB. + ** If the value is numeric, convert it to a string first. + ** Strings are simply reinterpreted as blobs with no change + ** to the underlying data. ** ** A NULL value is not changed by this routine. It remains NULL. */ - case OP_ToInt: { /* same as TK_TO_INT, in1 */ - pIn1 = aMem[pOp.p1]; - if ((pIn1.flags & MEM_Null) == 0) { - sqlite3VdbeMemIntegerify(pIn1); - } - break; - } + case OP_ToBlob: + { /* same as TK_TO_BLOB, in1 */ + pIn1 = aMem[pOp.p1]; + if ( ( pIn1.flags & MEM_Null ) != 0 ) + break; + if ( ( pIn1.flags & MEM_Blob ) == 0 ) + { + applyAffinity( pIn1, SQLITE_AFF_TEXT, encoding ); + Debug.Assert( ( pIn1.flags & MEM_Str ) != 0 /*|| db.mallocFailed != 0 */ ); + MemSetTypeFlag( pIn1, MEM_Blob ); + } + else + { + pIn1.flags = (ushort)( pIn1.flags & ~( MEM_TypeMask & ~MEM_Blob ) ); + } +#if SQLITE_TEST + UPDATE_MAX_BLOBSIZE( pIn1 ); +#endif + break; + } -#if !(SQLITE_OMIT_CAST) && !(SQLITE_OMIT_FLOATING_POINT) - /* Opcode: ToReal P1 * * * * + /* Opcode: ToNumeric P1 * * * * ** - ** Force the value in register P1 to be a floating point number. - ** If The value is currently an integer, convert it. - ** If the value is text or blob, try to convert it to an integer using the - ** equivalent of atoi() and store 0.0 if no such conversion is possible. + ** Force the value in register P1 to be numeric (either an + ** integer or a floating-point number.) + ** If the value is text or blob, try to convert it to an using the + ** equivalent of atoi() or atof() and store 0 if no such conversion + ** is possible. ** ** A NULL value is not changed by this routine. It remains NULL. */ - case OP_ToReal: { /* same as TK_TO_REAL, in1 */ - pIn1 = aMem[pOp.p1]; - memAboutToChange(p, pIn1); - if ((pIn1.flags & MEM_Null) == 0) { - sqlite3VdbeMemRealify(pIn1); - } - break; - } + case OP_ToNumeric: + { /* same as TK_TO_NUMERIC, in1 */ + pIn1 = aMem[pOp.p1]; + sqlite3VdbeMemNumerify( pIn1 ); + break; + } +#endif // * SQLITE_OMIT_CAST */ + + /* Opcode: ToInt P1 * * * * +** +** Force the value in register P1 to be an integer. If +** The value is currently a real number, drop its fractional part. +** If the value is text or blob, try to convert it to an integer using the +** equivalent of atoi() and store 0 if no such conversion is possible. +** +** A NULL value is not changed by this routine. It remains NULL. +*/ + case OP_ToInt: + { /* same as TK_TO_INT, in1 */ + pIn1 = aMem[pOp.p1]; + if ( ( pIn1.flags & MEM_Null ) == 0 ) + { + sqlite3VdbeMemIntegerify( pIn1 ); + } + break; + } + +#if !(SQLITE_OMIT_CAST) && !(SQLITE_OMIT_FLOATING_POINT) + /* Opcode: ToReal P1 * * * * +** +** Force the value in register P1 to be a floating point number. +** If The value is currently an integer, convert it. +** If the value is text or blob, try to convert it to an integer using the +** equivalent of atoi() and store 0.0 if no such conversion is possible. +** +** A NULL value is not changed by this routine. It remains NULL. +*/ + case OP_ToReal: + { /* same as TK_TO_REAL, in1 */ + pIn1 = aMem[pOp.p1]; + memAboutToChange( p, pIn1 ); + if ( ( pIn1.flags & MEM_Null ) == 0 ) + { + sqlite3VdbeMemRealify( pIn1 ); + } + break; + } #endif //* !defined(SQLITE_OMIT_CAST) && !defined(SQLITE_OMIT_FLOATING_POINT) */ - /* Opcode: Lt P1 P2 P3 P4 P5 - ** - ** Compare the values in register P1 and P3. If reg(P3)flags */ - u16 flags3; /* Copy of initial value of pIn3->flags */ - pIn1 = aMem[pOp.p1]; - pIn3 = aMem[pOp.p3]; - flags1 = pIn1.flags; - flags3 = pIn3.flags; - if (((pIn1.flags | pIn3.flags) & MEM_Null) != 0) { - /* One or both operands are NULL */ - if ((pOp.p5 & SQLITE_NULLEQ) != 0) { - /* If SQLITE_NULLEQ is set (which will only happen if the operator is - ** OP_Eq or OP_Ne) then take the jump or not depending on whether - ** or not both operands are null. - */ - Debug.Assert(pOp.opcode == OP_Eq || pOp.opcode == OP_Ne); - res = (pIn1.flags & pIn3.flags & MEM_Null) == 0 ? 1 : 0; - } else { - /* SQLITE_NULLEQ is clear and at least one operand is NULL, - ** then the result is always NULL. - ** The jump is taken if the SQLITE_JUMPIFNULL bit is set. - */ - if ((pOp.p5 & SQLITE_STOREP2) != 0) { - pOut = aMem[pOp.p2]; - MemSetTypeFlag(pOut, MEM_Null); - REGISTER_TRACE(p, pOp.p2, pOut); - } else if ((pOp.p5 & SQLITE_JUMPIFNULL) != 0) { - pc = pOp.p2 - 1; - } - break; - } - - } else { - /* Neither operand is NULL. Do a comparison. */ - affinity = (char)(pOp.p5 & SQLITE_AFF_MASK); - if (affinity != '\0') { - applyAffinity(pIn1, affinity, encoding); - applyAffinity(pIn3, affinity, encoding); - // if ( db.mallocFailed != 0 ) goto no_mem; - } - - Debug.Assert(pOp.p4type == P4_COLLSEQ || pOp.p4.pColl == null); - ExpandBlob(pIn1); - ExpandBlob(pIn3); - res = sqlite3MemCompare(pIn3, pIn1, pOp.p4.pColl); - } - switch (pOp.opcode) { - case OP_Eq: - res = (res == 0) ? 1 : 0; - break; - case OP_Ne: - res = (res != 0) ? 1 : 0; - break; - case OP_Lt: - res = (res < 0) ? 1 : 0; - break; - case OP_Le: - res = (res <= 0) ? 1 : 0; - break; - case OP_Gt: - res = (res > 0) ? 1 : 0; - break; - default: - res = (res >= 0) ? 1 : 0; - break; - } - - if ((pOp.p5 & SQLITE_STOREP2) != 0) { - pOut = aMem[pOp.p2]; - memAboutToChange(p, pOut); - MemSetTypeFlag(pOut, MEM_Int); - pOut.u.i = res; - REGISTER_TRACE(p, pOp.p2, pOut); - } else if (res != 0) { - pc = pOp.p2 - 1; - } - - /* Undo any changes made by applyAffinity() to the input registers. */ - pIn1.flags = (u16)((pIn1.flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask)); - pIn3.flags = (u16)((pIn3.flags & ~MEM_TypeMask) | (flags3 & MEM_TypeMask)); - break; - } + /* Opcode: Eq P1 P2 P3 P4 P5 + ** + ** This works just like the Lt opcode except that the jump is taken if + ** the operands in registers P1 and P3 are equal. + ** See the Lt opcode for additional information. + ** + ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either + ** true or false and is never NULL. If both operands are NULL then the result + ** of comparison is true. If either operand is NULL then the result is false. + ** If neither operand is NULL the result is the same as it would be if + ** the SQLITE_NULLEQ flag were omitted from P5. + */ + /* Opcode: Le P1 P2 P3 P4 P5 + ** + ** This works just like the Lt opcode except that the jump is taken if + ** the content of register P3 is less than or equal to the content of + ** register P1. See the Lt opcode for additional information. + */ + /* Opcode: Gt P1 P2 P3 P4 P5 + ** + ** This works just like the Lt opcode except that the jump is taken if + ** the content of register P3 is greater than the content of + ** register P1. See the Lt opcode for additional information. + */ + /* Opcode: Ge P1 P2 P3 P4 P5 + ** + ** This works just like the Lt opcode except that the jump is taken if + ** the content of register P3 is greater than or equal to the content of + ** register P1. See the Lt opcode for additional information. + */ + case OP_Eq: /* same as TK_EQ, jump, in1, in3 */ + case OP_Ne: /* same as TK_NE, jump, in1, in3 */ + case OP_Lt: /* same as TK_LT, jump, in1, in3 */ + case OP_Le: /* same as TK_LE, jump, in1, in3 */ + case OP_Gt: /* same as TK_GT, jump, in1, in3 */ + case OP_Ge: + { /* same as TK_GE, jump, in1, in3 */ + int res = 0; /* Result of the comparison of pIn1 against pIn3 */ + char affinity; /* Affinity to use for comparison */ + u16 flags1; /* Copy of initial value of pIn1->flags */ + u16 flags3; /* Copy of initial value of pIn3->flags */ + pIn1 = aMem[pOp.p1]; + pIn3 = aMem[pOp.p3]; + flags1 = pIn1.flags; + flags3 = pIn3.flags; + if ( ( ( pIn1.flags | pIn3.flags ) & MEM_Null ) != 0 ) + { + /* One or both operands are NULL */ + if ( ( pOp.p5 & SQLITE_NULLEQ ) != 0 ) + { + /* If SQLITE_NULLEQ is set (which will only happen if the operator is + ** OP_Eq or OP_Ne) then take the jump or not depending on whether + ** or not both operands are null. + */ + Debug.Assert( pOp.opcode == OP_Eq || pOp.opcode == OP_Ne ); + res = ( pIn1.flags & pIn3.flags & MEM_Null ) == 0 ? 1 : 0; + } + else + { + /* SQLITE_NULLEQ is clear and at least one operand is NULL, + ** then the result is always NULL. + ** The jump is taken if the SQLITE_JUMPIFNULL bit is set. + */ + if ( ( pOp.p5 & SQLITE_STOREP2 ) != 0 ) + { + pOut = aMem[pOp.p2]; + MemSetTypeFlag( pOut, MEM_Null ); + REGISTER_TRACE( p, pOp.p2, pOut ); + } + else if ( ( pOp.p5 & SQLITE_JUMPIFNULL ) != 0 ) + { + pc = pOp.p2 - 1; + } + break; + } - /* Opcode: Permutation * * * P4 * - ** - ** Set the permutation used by the OP_Compare operator to be the array - ** of integers in P4. - ** - ** The permutation is only valid until the next OP_Permutation, OP_Compare, - ** OP_Halt, or OP_ResultRow. Typically the OP_Permutation should occur - ** immediately prior to the OP_Compare. - */ - case OP_Permutation: { - Debug.Assert(pOp.p4type == P4_INTARRAY); - Debug.Assert(pOp.p4.ai != null); - aPermute = pOp.p4.ai; - break; - } + } + else + { + /* Neither operand is NULL. Do a comparison. */ + affinity = (char)( pOp.p5 & SQLITE_AFF_MASK ); + if ( affinity != '\0' ) + { + applyAffinity( pIn1, affinity, encoding ); + applyAffinity( pIn3, affinity, encoding ); + // if ( db.mallocFailed != 0 ) goto no_mem; + } - /* Opcode: Compare P1 P2 P3 P4 * - ** - ** Compare two vectors of registers in reg(P1)..reg(P1+P3-1) (call this - ** vector "A") and in reg(P2)..reg(P2+P3-1) ("B"). Save the result of - ** the comparison for use by the next OP_Jump instruct. - ** - ** P4 is a KeyInfo structure that defines collating sequences and sort - ** orders for the comparison. The permutation applies to registers - ** only. The KeyInfo elements are used sequentially. - ** - ** The comparison is a sort comparison, so NULLs compare equal, - ** NULLs are less than numbers, numbers are less than strings, - ** and strings are less than blobs. - */ - case OP_Compare: { - int n; - int i; - int p1; - int p2; - KeyInfo pKeyInfo; - int idx; - CollSeq pColl; /* Collating sequence to use on this term */ - int bRev; /* True for DESCENDING sort order */ - - n = pOp.p3; - pKeyInfo = pOp.p4.pKeyInfo; - Debug.Assert(n > 0); - Debug.Assert(pKeyInfo != null); - p1 = pOp.p1; - p2 = pOp.p2; + Debug.Assert( pOp.p4type == P4_COLLSEQ || pOp.p4.pColl == null ); + ExpandBlob( pIn1 ); + ExpandBlob( pIn3 ); + res = sqlite3MemCompare( pIn3, pIn1, pOp.p4.pColl ); + } + switch ( pOp.opcode ) + { + case OP_Eq: + res = ( res == 0 ) ? 1 : 0; + break; + case OP_Ne: + res = ( res != 0 ) ? 1 : 0; + break; + case OP_Lt: + res = ( res < 0 ) ? 1 : 0; + break; + case OP_Le: + res = ( res <= 0 ) ? 1 : 0; + break; + case OP_Gt: + res = ( res > 0 ) ? 1 : 0; + break; + default: + res = ( res >= 0 ) ? 1 : 0; + break; + } + + if ( ( pOp.p5 & SQLITE_STOREP2 ) != 0 ) + { + pOut = aMem[pOp.p2]; + memAboutToChange( p, pOut ); + MemSetTypeFlag( pOut, MEM_Int ); + pOut.u.i = res; + REGISTER_TRACE( p, pOp.p2, pOut ); + } + else if ( res != 0 ) + { + pc = pOp.p2 - 1; + } + + /* Undo any changes made by applyAffinity() to the input registers. */ + pIn1.flags = (u16)( ( pIn1.flags & ~MEM_TypeMask ) | ( flags1 & MEM_TypeMask ) ); + pIn3.flags = (u16)( ( pIn3.flags & ~MEM_TypeMask ) | ( flags3 & MEM_TypeMask ) ); + break; + } + + /* Opcode: Permutation * * * P4 * + ** + ** Set the permutation used by the OP_Compare operator to be the array + ** of integers in P4. + ** + ** The permutation is only valid until the next OP_Permutation, OP_Compare, + ** OP_Halt, or OP_ResultRow. Typically the OP_Permutation should occur + ** immediately prior to the OP_Compare. + */ + case OP_Permutation: + { + Debug.Assert( pOp.p4type == P4_INTARRAY ); + Debug.Assert( pOp.p4.ai != null ); + aPermute = pOp.p4.ai; + break; + } + + /* Opcode: Compare P1 P2 P3 P4 * + ** + ** Compare two vectors of registers in reg(P1)..reg(P1+P3-1) (call this + ** vector "A") and in reg(P2)..reg(P2+P3-1) ("B"). Save the result of + ** the comparison for use by the next OP_Jump instruct. + ** + ** P4 is a KeyInfo structure that defines collating sequences and sort + ** orders for the comparison. The permutation applies to registers + ** only. The KeyInfo elements are used sequentially. + ** + ** The comparison is a sort comparison, so NULLs compare equal, + ** NULLs are less than numbers, numbers are less than strings, + ** and strings are less than blobs. + */ + case OP_Compare: + { + int n; + int i; + int p1; + int p2; + KeyInfo pKeyInfo; + int idx; + CollSeq pColl; /* Collating sequence to use on this term */ + int bRev; /* True for DESCENDING sort order */ + + n = pOp.p3; + pKeyInfo = pOp.p4.pKeyInfo; + Debug.Assert( n > 0 ); + Debug.Assert( pKeyInfo != null ); + p1 = pOp.p1; + p2 = pOp.p2; #if SQLITE_DEBUG - if (aPermute != null) { - int k, mx = 0; - for (k = 0; k < n; k++) - if (aPermute[k] > mx) - mx = aPermute[k]; - Debug.Assert(p1 > 0 && p1 + mx <= p.nMem + 1); - Debug.Assert(p2 > 0 && p2 + mx <= p.nMem + 1); - } else { - Debug.Assert(p1 > 0 && p1 + n <= p.nMem + 1); - Debug.Assert(p2 > 0 && p2 + n <= p.nMem + 1); - } + if ( aPermute != null ) + { + int k, mx = 0; + for ( k = 0; k < n; k++ ) + if ( aPermute[k] > mx ) + mx = aPermute[k]; + Debug.Assert( p1 > 0 && p1 + mx <= p.nMem + 1 ); + Debug.Assert( p2 > 0 && p2 + mx <= p.nMem + 1 ); + } + else + { + Debug.Assert( p1 > 0 && p1 + n <= p.nMem + 1 ); + Debug.Assert( p2 > 0 && p2 + n <= p.nMem + 1 ); + } #endif //* SQLITE_DEBUG */ - for (i = 0; i < n; i++) { - idx = aPermute != null ? aPermute[i] : i; - Debug.Assert(memIsValid(aMem[p1 + idx])); - Debug.Assert(memIsValid(aMem[p2 + idx])); - REGISTER_TRACE(p, p1 + idx, aMem[p1 + idx]); - REGISTER_TRACE(p, p2 + idx, aMem[p2 + idx]); - Debug.Assert(i < pKeyInfo.nField); - pColl = pKeyInfo.aColl[i]; - bRev = pKeyInfo.aSortOrder[i]; - iCompare = sqlite3MemCompare(aMem[p1 + idx], aMem[p2 + idx], pColl); - if (iCompare != 0) { - if (bRev != 0) - iCompare = -iCompare; - break; - } - } - aPermute = null; - break; - } + for ( i = 0; i < n; i++ ) + { + idx = aPermute != null ? aPermute[i] : i; + Debug.Assert( memIsValid( aMem[p1 + idx] ) ); + Debug.Assert( memIsValid( aMem[p2 + idx] ) ); + REGISTER_TRACE( p, p1 + idx, aMem[p1 + idx] ); + REGISTER_TRACE( p, p2 + idx, aMem[p2 + idx] ); + Debug.Assert( i < pKeyInfo.nField ); + pColl = pKeyInfo.aColl[i]; + bRev = pKeyInfo.aSortOrder[i]; + iCompare = sqlite3MemCompare( aMem[p1 + idx], aMem[p2 + idx], pColl ); + if ( iCompare != 0 ) + { + if ( bRev != 0 ) + iCompare = -iCompare; + break; + } + } + aPermute = null; + break; + } - /* Opcode: Jump P1 P2 P3 * * - ** - ** Jump to the instruction at address P1, P2, or P3 depending on whether - ** in the most recent OP_Compare instruction the P1 vector was less than - ** equal to, or greater than the P2 vector, respectively. - */ - case OP_Jump: { /* jump */ - if (iCompare < 0) { - pc = pOp.p1 - 1; - } else if (iCompare == 0) { - pc = pOp.p2 - 1; - } else { - pc = pOp.p3 - 1; - } - break; - } - /* Opcode: And P1 P2 P3 * * - ** - ** Take the logical AND of the values in registers P1 and P2 and - ** write the result into register P3. - ** - ** If either P1 or P2 is 0 (false) then the result is 0 even if - ** the other input is NULL. A NULL and true or two NULLs give - ** a NULL output. - */ - /* Opcode: Or P1 P2 P3 * * - ** - ** Take the logical OR of the values in register P1 and P2 and - ** store the answer in register P3. - ** - ** If either P1 or P2 is nonzero (true) then the result is 1 (true) - ** even if the other input is NULL. A NULL and false or two NULLs - ** give a NULL output. - */ - case OP_And: /* same as TK_AND, in1, in2, ref3 */ - case OP_Or: { /* same as TK_OR, in1, in2, ref3 */ - int v1; /* Left operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */ - int v2; /* Right operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */ - - pIn1 = aMem[pOp.p1]; - if ((pIn1.flags & MEM_Null) != 0) { - v1 = 2; - } else { - v1 = (sqlite3VdbeIntValue(pIn1) != 0) ? 1 : 0; - } - pIn2 = aMem[pOp.p2]; - if ((pIn2.flags & MEM_Null) != 0) { - v2 = 2; - } else { - v2 = (sqlite3VdbeIntValue(pIn2) != 0) ? 1 : 0; - } - if (pOp.opcode == OP_And) { - byte[] and_logic = new byte[] { 0, 0, 0, 0, 1, 2, 0, 2, 2 }; - v1 = and_logic[v1 * 3 + v2]; - } else { - byte[] or_logic = new byte[] { 0, 1, 2, 1, 1, 1, 2, 1, 2 }; - v1 = or_logic[v1 * 3 + v2]; - } - pOut = aMem[pOp.p3]; - if (v1 == 2) { - MemSetTypeFlag(pOut, MEM_Null); - } else { - pOut.u.i = v1; - MemSetTypeFlag(pOut, MEM_Int); - } - break; - } + /* Opcode: Jump P1 P2 P3 * * + ** + ** Jump to the instruction at address P1, P2, or P3 depending on whether + ** in the most recent OP_Compare instruction the P1 vector was less than + ** equal to, or greater than the P2 vector, respectively. + */ + case OP_Jump: + { /* jump */ + if ( iCompare < 0 ) + { + pc = pOp.p1 - 1; + } + else if ( iCompare == 0 ) + { + pc = pOp.p2 - 1; + } + else + { + pc = pOp.p3 - 1; + } + break; + } + /* Opcode: And P1 P2 P3 * * + ** + ** Take the logical AND of the values in registers P1 and P2 and + ** write the result into register P3. + ** + ** If either P1 or P2 is 0 (false) then the result is 0 even if + ** the other input is NULL. A NULL and true or two NULLs give + ** a NULL output. + */ + /* Opcode: Or P1 P2 P3 * * + ** + ** Take the logical OR of the values in register P1 and P2 and + ** store the answer in register P3. + ** + ** If either P1 or P2 is nonzero (true) then the result is 1 (true) + ** even if the other input is NULL. A NULL and false or two NULLs + ** give a NULL output. + */ + case OP_And: /* same as TK_AND, in1, in2, ref3 */ + case OP_Or: + { /* same as TK_OR, in1, in2, ref3 */ + int v1; /* Left operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */ + int v2; /* Right operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */ + + pIn1 = aMem[pOp.p1]; + if ( ( pIn1.flags & MEM_Null ) != 0 ) + { + v1 = 2; + } + else + { + v1 = ( sqlite3VdbeIntValue( pIn1 ) != 0 ) ? 1 : 0; + } + pIn2 = aMem[pOp.p2]; + if ( ( pIn2.flags & MEM_Null ) != 0 ) + { + v2 = 2; + } + else + { + v2 = ( sqlite3VdbeIntValue( pIn2 ) != 0 ) ? 1 : 0; + } + if ( pOp.opcode == OP_And ) + { + byte[] and_logic = new byte[] { 0, 0, 0, 0, 1, 2, 0, 2, 2 }; + v1 = and_logic[v1 * 3 + v2]; + } + else + { + byte[] or_logic = new byte[] { 0, 1, 2, 1, 1, 1, 2, 1, 2 }; + v1 = or_logic[v1 * 3 + v2]; + } + pOut = aMem[pOp.p3]; + if ( v1 == 2 ) + { + MemSetTypeFlag( pOut, MEM_Null ); + } + else + { + pOut.u.i = v1; + MemSetTypeFlag( pOut, MEM_Int ); + } + break; + } - /* Opcode: Not P1 P2 * * * - ** - ** Interpret the value in register P1 as a boolean value. Store the - ** boolean complement in register P2. If the value in register P1 is - ** NULL, then a NULL is stored in P2. - */ - case OP_Not: { /* same as TK_NOT, in1 */ - pIn1 = aMem[pOp.p1]; - pOut = aMem[pOp.p2]; - if ((pIn1.flags & MEM_Null) != 0) { - sqlite3VdbeMemSetNull(pOut); - } else { - sqlite3VdbeMemSetInt64(pOut, sqlite3VdbeIntValue(pIn1) == 0 ? 1 : 0); - } - break; - } + /* Opcode: Not P1 P2 * * * + ** + ** Interpret the value in register P1 as a boolean value. Store the + ** boolean complement in register P2. If the value in register P1 is + ** NULL, then a NULL is stored in P2. + */ + case OP_Not: + { /* same as TK_NOT, in1 */ + pIn1 = aMem[pOp.p1]; + pOut = aMem[pOp.p2]; + if ( ( pIn1.flags & MEM_Null ) != 0 ) + { + sqlite3VdbeMemSetNull( pOut ); + } + else + { + sqlite3VdbeMemSetInt64( pOut, sqlite3VdbeIntValue( pIn1 ) == 0 ? 1 : 0 ); + } + break; + } - /* Opcode: BitNot P1 P2 * * * - ** - ** Interpret the content of register P1 as an integer. Store the - ** ones-complement of the P1 value into register P2. If P1 holds - ** a NULL then store a NULL in P2. - */ - case OP_BitNot: { /* same as TK_BITNOT, in1 */ - pIn1 = aMem[pOp.p1]; - pOut = aMem[pOp.p2]; - if ((pIn1.flags & MEM_Null) != 0) { - sqlite3VdbeMemSetNull(pOut); - } else { - sqlite3VdbeMemSetInt64(pOut, ~sqlite3VdbeIntValue(pIn1)); - } - break; - } + /* Opcode: BitNot P1 P2 * * * + ** + ** Interpret the content of register P1 as an integer. Store the + ** ones-complement of the P1 value into register P2. If P1 holds + ** a NULL then store a NULL in P2. + */ + case OP_BitNot: + { /* same as TK_BITNOT, in1 */ + pIn1 = aMem[pOp.p1]; + pOut = aMem[pOp.p2]; + if ( ( pIn1.flags & MEM_Null ) != 0 ) + { + sqlite3VdbeMemSetNull( pOut ); + } + else + { + sqlite3VdbeMemSetInt64( pOut, ~sqlite3VdbeIntValue( pIn1 ) ); + } + break; + } - /* Opcode: If P1 P2 P3 * * - ** - ** Jump to P2 if the value in register P1 is true. The value - ** is considered true if it is numeric and non-zero. If the value - ** in P1 is NULL then take the jump if P3 is true. - */ - /* Opcode: IfNot P1 P2 P3 * * - ** - ** Jump to P2 if the value in register P1 is False. The value - ** is considered true if it has a numeric value of zero. If the value - ** in P1 is NULL then take the jump if P3 is true. - */ - case OP_If: /* jump, in1 */ - case OP_IfNot: { /* jump, in1 */ - int c; - pIn1 = aMem[pOp.p1]; - if ((pIn1.flags & MEM_Null) != 0) { - c = pOp.p3; - } else { + /* Opcode: If P1 P2 P3 * * + ** + ** Jump to P2 if the value in register P1 is true. The value + ** is considered true if it is numeric and non-zero. If the value + ** in P1 is NULL then take the jump if P3 is true. + */ + /* Opcode: IfNot P1 P2 P3 * * + ** + ** Jump to P2 if the value in register P1 is False. The value + ** is considered true if it has a numeric value of zero. If the value + ** in P1 is NULL then take the jump if P3 is true. + */ + case OP_If: /* jump, in1 */ + case OP_IfNot: + { /* jump, in1 */ + int c; + pIn1 = aMem[pOp.p1]; + if ( ( pIn1.flags & MEM_Null ) != 0 ) + { + c = pOp.p3; + } + else + { #if SQLITE_OMIT_FLOATING_POINT c = sqlite3VdbeIntValue(pIn1)!=0; #else - c = (sqlite3VdbeRealValue(pIn1) != 0.0) ? 1 : 0; + c = ( sqlite3VdbeRealValue( pIn1 ) != 0.0 ) ? 1 : 0; #endif - if (pOp.opcode == OP_IfNot) - c = (c == 0) ? 1 : 0; - } - if (c != 0) { - pc = pOp.p2 - 1; - } - break; - } + if ( pOp.opcode == OP_IfNot ) + c = ( c == 0 ) ? 1 : 0; + } + if ( c != 0 ) + { + pc = pOp.p2 - 1; + } + break; + } - /* Opcode: IsNull P1 P2 * * * - ** - ** Jump to P2 if the value in register P1 is NULL. - */ - case OP_IsNull: { /* same as TK_ISNULL, jump, in1 */ - pIn1 = aMem[pOp.p1]; - if ((pIn1.flags & MEM_Null) != 0) { - pc = pOp.p2 - 1; - } - break; - } + /* Opcode: IsNull P1 P2 * * * + ** + ** Jump to P2 if the value in register P1 is NULL. + */ + case OP_IsNull: + { /* same as TK_ISNULL, jump, in1 */ + pIn1 = aMem[pOp.p1]; + if ( ( pIn1.flags & MEM_Null ) != 0 ) + { + pc = pOp.p2 - 1; + } + break; + } - /* Opcode: NotNull P1 P2 * * * - ** - ** Jump to P2 if the value in register P1 is not NULL. - */ - case OP_NotNull: { /* same as TK_NOTNULL, jump, in1 */ - pIn1 = aMem[pOp.p1]; - if ((pIn1.flags & MEM_Null) == 0) { - pc = pOp.p2 - 1; - } - break; - } + /* Opcode: NotNull P1 P2 * * * + ** + ** Jump to P2 if the value in register P1 is not NULL. + */ + case OP_NotNull: + { /* same as TK_NOTNULL, jump, in1 */ + pIn1 = aMem[pOp.p1]; + if ( ( pIn1.flags & MEM_Null ) == 0 ) + { + pc = pOp.p2 - 1; + } + break; + } - /* Opcode: Column P1 P2 P3 P4 * - ** - ** Interpret the data that cursor P1 points to as a structure built using - ** the MakeRecord instruction. (See the MakeRecord opcode for additional - ** information about the format of the data.) Extract the P2-th column - ** from this record. If there are less that (P2+1) - ** values in the record, extract a NULL. - ** - ** The value extracted is stored in register P3. - ** - ** If the column contains fewer than P2 fields, then extract a NULL. Or, - ** if the P4 argument is a P4_MEM use the value of the P4 argument as - ** the result. - ** - ** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor, - ** then the cache of the cursor is reset prior to extracting the column. - ** The first OP_Column against a pseudo-table after the value of the content - ** register has changed should have this bit set. - */ - case OP_Column: { - u32 payloadSize; /* Number of bytes in the record */ - i64 payloadSize64; /* Number of bytes in the record */ - int p1; /* P1 value of the opcode */ - int p2; /* column number to retrieve */ - VdbeCursor pC; /* The VDBE cursor */ - byte[] zRec; /* Pointer to complete record-data */ - BtCursor pCrsr; /* The BTree cursor */ - u32[] aType; /* aType[i] holds the numeric type of the i-th column */ - u32[] aOffset; /* aOffset[i] is offset to start of data for i-th column */ - int nField; /* number of fields in the record */ - int len; /* The length of the serialized data for the column */ - int i; /* Loop counter */ - byte[] zData = null;/* Part of the record being decoded */ - Mem pDest; /* Where to write the extracted value */ - Mem sMem = null; /* For storing the record being decoded */ - int zIdx; /* Index into header */ - int zEndHdr; /* Pointer to first byte after the header */ - u32 offset; /* Offset into the data */ - u32 szField = 0; /* Number of bytes in the content of a field */ - int szHdr; /* Size of the header size field at start of record */ - int avail; /* Number of bytes of available data */ - Mem pReg; /* PseudoTable input register */ - - p1 = pOp.p1; - p2 = pOp.p2; - pC = null; - - payloadSize = 0; - payloadSize64 = 0; - offset = 0; - - sMem = sqlite3Malloc(sMem); - // memset(&sMem, 0, sizeof(sMem)); - Debug.Assert(p1 < p.nCursor); - Debug.Assert(pOp.p3 > 0 && pOp.p3 <= p.nMem); - pDest = aMem[pOp.p3]; - memAboutToChange(p, pDest); - MemSetTypeFlag(pDest, MEM_Null); - zRec = null; - - /* This block sets the variable payloadSize to be the total number of - ** bytes in the record. - ** - ** zRec is set to be the complete text of the record if it is available. - ** The complete record text is always available for pseudo-tables - ** If the record is stored in a cursor, the complete record text - ** might be available in the pC.aRow cache. Or it might not be. - ** If the data is unavailable, zRec is set to NULL. - ** - ** We also compute the number of columns in the record. For cursors, - ** the number of columns is stored in the VdbeCursor.nField element. - */ - pC = p.apCsr[p1]; - Debug.Assert(pC != null); + /* Opcode: Column P1 P2 P3 P4 * + ** + ** Interpret the data that cursor P1 points to as a structure built using + ** the MakeRecord instruction. (See the MakeRecord opcode for additional + ** information about the format of the data.) Extract the P2-th column + ** from this record. If there are less that (P2+1) + ** values in the record, extract a NULL. + ** + ** The value extracted is stored in register P3. + ** + ** If the column contains fewer than P2 fields, then extract a NULL. Or, + ** if the P4 argument is a P4_MEM use the value of the P4 argument as + ** the result. + ** + ** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor, + ** then the cache of the cursor is reset prior to extracting the column. + ** The first OP_Column against a pseudo-table after the value of the content + ** register has changed should have this bit set. + */ + case OP_Column: + { + u32 payloadSize; /* Number of bytes in the record */ + i64 payloadSize64; /* Number of bytes in the record */ + int p1; /* P1 value of the opcode */ + int p2; /* column number to retrieve */ + VdbeCursor pC; /* The VDBE cursor */ + byte[] zRec; /* Pointer to complete record-data */ + BtCursor pCrsr; /* The BTree cursor */ + u32[] aType; /* aType[i] holds the numeric type of the i-th column */ + u32[] aOffset; /* aOffset[i] is offset to start of data for i-th column */ + int nField; /* number of fields in the record */ + int len; /* The length of the serialized data for the column */ + int i; /* Loop counter */ + byte[] zData = null;/* Part of the record being decoded */ + Mem pDest; /* Where to write the extracted value */ + Mem sMem = null; /* For storing the record being decoded */ + int zIdx; /* Index into header */ + int zEndHdr; /* Pointer to first byte after the header */ + u32 offset; /* Offset into the data */ + u32 szField = 0; /* Number of bytes in the content of a field */ + int szHdr; /* Size of the header size field at start of record */ + int avail; /* Number of bytes of available data */ + Mem pReg; /* PseudoTable input register */ + + p1 = pOp.p1; + p2 = pOp.p2; + pC = null; + + payloadSize = 0; + payloadSize64 = 0; + offset = 0; + + sMem = sqlite3Malloc( sMem ); + // memset(&sMem, 0, sizeof(sMem)); + Debug.Assert( p1 < p.nCursor ); + Debug.Assert( pOp.p3 > 0 && pOp.p3 <= p.nMem ); + pDest = aMem[pOp.p3]; + memAboutToChange( p, pDest ); + MemSetTypeFlag( pDest, MEM_Null ); + zRec = null; + + /* This block sets the variable payloadSize to be the total number of + ** bytes in the record. + ** + ** zRec is set to be the complete text of the record if it is available. + ** The complete record text is always available for pseudo-tables + ** If the record is stored in a cursor, the complete record text + ** might be available in the pC.aRow cache. Or it might not be. + ** If the data is unavailable, zRec is set to NULL. + ** + ** We also compute the number of columns in the record. For cursors, + ** the number of columns is stored in the VdbeCursor.nField element. + */ + pC = p.apCsr[p1]; + Debug.Assert( pC != null ); #if !SQLITE_OMIT_VIRTUALTABLE - Debug.Assert(pC.pVtabCursor == null); + Debug.Assert( pC.pVtabCursor == null ); #endif - pCrsr = pC.pCursor; - if (pCrsr != null) { - /* The record is stored in a B-Tree */ - rc = sqlite3VdbeCursorMoveto(pC); - if (rc != 0) - goto abort_due_to_error; - if (pC.nullRow) { - payloadSize = 0; - } else if ((pC.cacheStatus == p.cacheCtr) && (pC.aRow != -1)) { - payloadSize = pC.payloadSize; - zRec = sqlite3Malloc((int)payloadSize); - Buffer.BlockCopy(pCrsr.info.pCell, pC.aRow, zRec, 0, (int)payloadSize); - } else if (pC.isIndex) { - Debug.Assert(sqlite3BtreeCursorIsValid(pCrsr)); - rc = sqlite3BtreeKeySize(pCrsr, ref payloadSize64); - Debug.Assert(rc == SQLITE_OK); /* True because of CursorMoveto() call above */ - /* sqlite3BtreeParseCellPtr() uses getVarint32() to extract the - ** payload size, so it is impossible for payloadSize64 to be - ** larger than 32 bits. */ - Debug.Assert(((u64)payloadSize64 & SQLITE_MAX_U32) == (u64)payloadSize64); - payloadSize = (u32)payloadSize64; - } else { - Debug.Assert(sqlite3BtreeCursorIsValid(pCrsr)); - rc = sqlite3BtreeDataSize(pCrsr, ref payloadSize); - Debug.Assert(rc == SQLITE_OK); /* DataSize() cannot fail */ - } - } else if (pC.pseudoTableReg > 0) { - /* The record is the sole entry of a pseudo-table */ - pReg = aMem[pC.pseudoTableReg]; - Debug.Assert((pReg.flags & MEM_Blob) != 0); - Debug.Assert(memIsValid(pReg)); - payloadSize = (u32)pReg.n; - zRec = pReg.zBLOB; - pC.cacheStatus = (pOp.p5 & OPFLAG_CLEARCACHE) != 0 ? CACHE_STALE : p.cacheCtr; - Debug.Assert(payloadSize == 0 || zRec != null); - } else { - /* Consider the row to be NULL */ - payloadSize = 0; - } - - /* If payloadSize is 0, then just store a NULL */ - if (payloadSize == 0) { - Debug.Assert((pDest.flags & MEM_Null) != 0); - goto op_column_out; - } - Debug.Assert(db.aLimit[SQLITE_LIMIT_LENGTH] >= 0); - if (payloadSize > (u32)db.aLimit[SQLITE_LIMIT_LENGTH]) { - goto too_big; - } - - nField = pC.nField; - Debug.Assert(p2 < nField); - - /* Read and parse the table header. Store the results of the parse - ** into the record header cache fields of the cursor. - */ - aType = pC.aType; - if (pC.cacheStatus == p.cacheCtr) { - aOffset = pC.aOffset; - } else { - Debug.Assert(aType != null); - avail = 0; - //pC.aOffset = aOffset = aType[nField]; - aOffset = new u32[nField]; - pC.aOffset = aOffset; - pC.payloadSize = payloadSize; - pC.cacheStatus = p.cacheCtr; - - /* Figure out how many bytes are in the header */ - if (zRec != null) { - zData = zRec; - } else { - if (pC.isIndex) { - zData = sqlite3BtreeKeyFetch(pCrsr, ref avail, ref pC.aRow); - } else { - zData = sqlite3BtreeDataFetch(pCrsr, ref avail, ref pC.aRow); - } - /* If KeyFetch()/DataFetch() managed to get the entire payload, - ** save the payload in the pC.aRow cache. That will save us from - ** having to make additional calls to fetch the content portion of - ** the record. - */ - Debug.Assert(avail >= 0); - if (payloadSize <= (u32)avail) { - zRec = zData; - //pC.aRow = zData; - } else { - pC.aRow = -1; //pC.aRow = null; - } - } - /* The following Debug.Assert is true in all cases accept when - ** the database file has been corrupted externally. - ** Debug.Assert( zRec!=0 || avail>=payloadSize || avail>=9 ); */ - szHdr = getVarint32(zData, out offset); - - /* Make sure a corrupt database has not given us an oversize header. - ** Do this now to avoid an oversize memory allocation. - ** - ** Type entries can be between 1 and 5 bytes each. But 4 and 5 byte - ** types use so much data space that there can only be 4096 and 32 of - ** them, respectively. So the maximum header length results from a - ** 3-byte type for each of the maximum of 32768 columns plus three - ** extra bytes for the header length itself. 32768*3 + 3 = 98307. - */ - if (offset > 98307) { - rc = SQLITE_CORRUPT_BKPT(); - goto op_column_out; - } - - /* Compute in len the number of bytes of data we need to read in order - ** to get nField type values. offset is an upper bound on this. But - ** nField might be significantly less than the true number of columns - ** in the table, and in that case, 5*nField+3 might be smaller than offset. - ** We want to minimize len in order to limit the size of the memory - ** allocation, especially if a corrupt database file has caused offset - ** to be oversized. Offset is limited to 98307 above. But 98307 might - ** still exceed Robson memory allocation limits on some configurations. - ** On systems that cannot tolerate large memory allocations, nField*5+3 - ** will likely be much smaller since nField will likely be less than - ** 20 or so. This insures that Robson memory allocation limits are - ** not exceeded even for corrupt database files. - */ - len = nField * 5 + 3; - if (len > (int)offset) - len = (int)offset; - - /* The KeyFetch() or DataFetch() above are fast and will get the entire - ** record header in most cases. But they will fail to get the complete - ** record header if the record header does not fit on a single page - ** in the B-Tree. When that happens, use sqlite3VdbeMemFromBtree() to - ** acquire the complete header text. - */ - if (zRec == null && avail < len) { - sMem.db = null; - sMem.flags = 0; - rc = sqlite3VdbeMemFromBtree(pCrsr, 0, len, pC.isIndex, sMem); - if (rc != SQLITE_OK) { - goto op_column_out; - } - zData = sMem.zBLOB; - } - zEndHdr = len;// zData[len]; - zIdx = szHdr;// zData[szHdr]; - - /* Scan the header and use it to fill in the aType[] and aOffset[] - ** arrays. aType[i] will contain the type integer for the i-th - ** column and aOffset[i] will contain the offset from the beginning - ** of the record to the start of the data for the i-th column - */ - for (i = 0; i < nField; i++) { - if (zIdx < zEndHdr) { - aOffset[i] = offset; - zIdx += getVarint32(zData, zIdx, out aType[i]);//getVarint32(zIdx, aType[i]); - szField = sqlite3VdbeSerialTypeLen(aType[i]); - offset += szField; - if (offset < szField) { /* True if offset overflows */ - zIdx = int.MaxValue; /* Forces SQLITE_CORRUPT return below */ - break; - } - } else { - /* If i is less that nField, then there are less fields in this - ** record than SetNumColumns indicated there are columns in the - ** table. Set the offset for any extra columns not present in - ** the record to 0. This tells code below to store a NULL - ** instead of deserializing a value from the record. - */ - aOffset[i] = 0; - } - } - sqlite3VdbeMemRelease(sMem); - sMem.flags = MEM_Null; - - /* If we have read more header data than was contained in the header, - ** or if the end of the last field appears to be past the end of the - ** record, or if the end of the last field appears to be before the end - ** of the record (when all fields present), then we must be dealing - ** with a corrupt database. - */ - if ((zIdx > zEndHdr) || (offset > payloadSize) - || (zIdx == zEndHdr && offset != payloadSize)) { - rc = SQLITE_CORRUPT_BKPT(); - goto op_column_out; - } - } - - /* Get the column information. If aOffset[p2] is non-zero, then - ** deserialize the value from the record. If aOffset[p2] is zero, - ** then there are not enough fields in the record to satisfy the - ** request. In this case, set the value NULL or to P4 if P4 is - ** a pointer to a Mem object. - */ - if (aOffset[p2] != 0) { - Debug.Assert(rc == SQLITE_OK); - if (zRec != null) { - sqlite3VdbeMemReleaseExternal(pDest); - sqlite3VdbeSerialGet(zRec, (int)aOffset[p2], aType[p2], pDest); - } else { - len = (int)sqlite3VdbeSerialTypeLen(aType[p2]); - sqlite3VdbeMemMove(sMem, pDest); - rc = sqlite3VdbeMemFromBtree(pCrsr, (int)aOffset[p2], len, pC.isIndex, sMem); - if (rc != SQLITE_OK) { - goto op_column_out; - } - zData = sMem.zBLOB; - sMem.zBLOB = null; - sqlite3VdbeSerialGet(zData, aType[p2], pDest); - } - pDest.enc = encoding; - } else { - if (pOp.p4type == P4_MEM) { - sqlite3VdbeMemShallowCopy(pDest, pOp.p4.pMem, MEM_Static); - } else { - Debug.Assert((pDest.flags & MEM_Null) != 0); - } - } - - /* If we dynamically allocated space to hold the data (in the - ** sqlite3VdbeMemFromBtree() call above) then transfer control of that - ** dynamically allocated space over to the pDest structure. - ** This prevents a memory copy. - */ - //if ( sMem.zMalloc != null ) - //{ - // Debug.Assert( sMem.z == sMem.zMalloc); - // Debug.Assert( sMem.xDel == null ); - // Debug.Assert( ( pDest.flags & MEM_Dyn ) == 0 ); - // Debug.Assert( ( pDest.flags & ( MEM_Blob | MEM_Str ) ) == 0 || pDest.z == sMem.z ); - // pDest.flags &= ~( MEM_Ephem | MEM_Static ); - // pDest.flags |= MEM_Term; - // pDest.z = sMem.z; - // pDest.zMalloc = sMem.zMalloc; - //} - - rc = sqlite3VdbeMemMakeWriteable(pDest); - - op_column_out: + pCrsr = pC.pCursor; + if ( pCrsr != null ) + { + /* The record is stored in a B-Tree */ + rc = sqlite3VdbeCursorMoveto( pC ); + if ( rc != 0 ) + goto abort_due_to_error; + if ( pC.nullRow ) + { + payloadSize = 0; + } + else if ( ( pC.cacheStatus == p.cacheCtr ) && ( pC.aRow != -1 ) ) + { + payloadSize = pC.payloadSize; + zRec = sqlite3Malloc( (int)payloadSize ); + Buffer.BlockCopy( pCrsr.info.pCell, pC.aRow, zRec, 0, (int)payloadSize ); + } + else if ( pC.isIndex ) + { + Debug.Assert( sqlite3BtreeCursorIsValid( pCrsr ) ); + rc = sqlite3BtreeKeySize( pCrsr, ref payloadSize64 ); + Debug.Assert( rc == SQLITE_OK ); /* True because of CursorMoveto() call above */ + /* sqlite3BtreeParseCellPtr() uses getVarint32() to extract the + ** payload size, so it is impossible for payloadSize64 to be + ** larger than 32 bits. */ + Debug.Assert( ( (u64)payloadSize64 & SQLITE_MAX_U32 ) == (u64)payloadSize64 ); + payloadSize = (u32)payloadSize64; + } + else + { + Debug.Assert( sqlite3BtreeCursorIsValid( pCrsr ) ); + rc = sqlite3BtreeDataSize( pCrsr, ref payloadSize ); + Debug.Assert( rc == SQLITE_OK ); /* DataSize() cannot fail */ + } + } + else if ( pC.pseudoTableReg > 0 ) + { + /* The record is the sole entry of a pseudo-table */ + pReg = aMem[pC.pseudoTableReg]; + Debug.Assert( ( pReg.flags & MEM_Blob ) != 0 ); + Debug.Assert( memIsValid( pReg ) ); + payloadSize = (u32)pReg.n; + zRec = pReg.zBLOB; + pC.cacheStatus = ( pOp.p5 & OPFLAG_CLEARCACHE ) != 0 ? CACHE_STALE : p.cacheCtr; + Debug.Assert( payloadSize == 0 || zRec != null ); + } + else + { + /* Consider the row to be NULL */ + payloadSize = 0; + } + + /* If payloadSize is 0, then just store a NULL */ + if ( payloadSize == 0 ) + { + Debug.Assert( ( pDest.flags & MEM_Null ) != 0 ); + goto op_column_out; + } + Debug.Assert( db.aLimit[SQLITE_LIMIT_LENGTH] >= 0 ); + if ( payloadSize > (u32)db.aLimit[SQLITE_LIMIT_LENGTH] ) + { + goto too_big; + } + + nField = pC.nField; + Debug.Assert( p2 < nField ); + + /* Read and parse the table header. Store the results of the parse + ** into the record header cache fields of the cursor. + */ + aType = pC.aType; + if ( pC.cacheStatus == p.cacheCtr ) + { + aOffset = pC.aOffset; + } + else + { + Debug.Assert( aType != null ); + avail = 0; + //pC.aOffset = aOffset = aType[nField]; + aOffset = new u32[nField]; + pC.aOffset = aOffset; + pC.payloadSize = payloadSize; + pC.cacheStatus = p.cacheCtr; + + /* Figure out how many bytes are in the header */ + if ( zRec != null ) + { + zData = zRec; + } + else + { + if ( pC.isIndex ) + { + zData = sqlite3BtreeKeyFetch( pCrsr, ref avail, ref pC.aRow ); + } + else + { + zData = sqlite3BtreeDataFetch( pCrsr, ref avail, ref pC.aRow ); + } + /* If KeyFetch()/DataFetch() managed to get the entire payload, + ** save the payload in the pC.aRow cache. That will save us from + ** having to make additional calls to fetch the content portion of + ** the record. + */ + Debug.Assert( avail >= 0 ); + if ( payloadSize <= (u32)avail ) + { + zRec = zData; + //pC.aRow = zData; + } + else + { + pC.aRow = -1; //pC.aRow = null; + } + } + /* The following Debug.Assert is true in all cases accept when + ** the database file has been corrupted externally. + ** Debug.Assert( zRec!=0 || avail>=payloadSize || avail>=9 ); */ + szHdr = getVarint32( zData, out offset ); + + /* Make sure a corrupt database has not given us an oversize header. + ** Do this now to avoid an oversize memory allocation. + ** + ** Type entries can be between 1 and 5 bytes each. But 4 and 5 byte + ** types use so much data space that there can only be 4096 and 32 of + ** them, respectively. So the maximum header length results from a + ** 3-byte type for each of the maximum of 32768 columns plus three + ** extra bytes for the header length itself. 32768*3 + 3 = 98307. + */ + if ( offset > 98307 ) + { + rc = SQLITE_CORRUPT_BKPT(); + goto op_column_out; + } + + /* Compute in len the number of bytes of data we need to read in order + ** to get nField type values. offset is an upper bound on this. But + ** nField might be significantly less than the true number of columns + ** in the table, and in that case, 5*nField+3 might be smaller than offset. + ** We want to minimize len in order to limit the size of the memory + ** allocation, especially if a corrupt database file has caused offset + ** to be oversized. Offset is limited to 98307 above. But 98307 might + ** still exceed Robson memory allocation limits on some configurations. + ** On systems that cannot tolerate large memory allocations, nField*5+3 + ** will likely be much smaller since nField will likely be less than + ** 20 or so. This insures that Robson memory allocation limits are + ** not exceeded even for corrupt database files. + */ + len = nField * 5 + 3; + if ( len > (int)offset ) + len = (int)offset; + + /* The KeyFetch() or DataFetch() above are fast and will get the entire + ** record header in most cases. But they will fail to get the complete + ** record header if the record header does not fit on a single page + ** in the B-Tree. When that happens, use sqlite3VdbeMemFromBtree() to + ** acquire the complete header text. + */ + if ( zRec == null && avail < len ) + { + sMem.db = null; + sMem.flags = 0; + rc = sqlite3VdbeMemFromBtree( pCrsr, 0, len, pC.isIndex, sMem ); + if ( rc != SQLITE_OK ) + { + goto op_column_out; + } + zData = sMem.zBLOB; + } + zEndHdr = len;// zData[len]; + zIdx = szHdr;// zData[szHdr]; + + /* Scan the header and use it to fill in the aType[] and aOffset[] + ** arrays. aType[i] will contain the type integer for the i-th + ** column and aOffset[i] will contain the offset from the beginning + ** of the record to the start of the data for the i-th column + */ + for ( i = 0; i < nField; i++ ) + { + if ( zIdx < zEndHdr ) + { + aOffset[i] = offset; + zIdx += getVarint32( zData, zIdx, out aType[i] );//getVarint32(zIdx, aType[i]); + szField = sqlite3VdbeSerialTypeLen( aType[i] ); + offset += szField; + if ( offset < szField ) + { /* True if offset overflows */ + zIdx = int.MaxValue; /* Forces SQLITE_CORRUPT return below */ + break; + } + } + else + { + /* If i is less that nField, then there are less fields in this + ** record than SetNumColumns indicated there are columns in the + ** table. Set the offset for any extra columns not present in + ** the record to 0. This tells code below to store a NULL + ** instead of deserializing a value from the record. + */ + aOffset[i] = 0; + } + } + sqlite3VdbeMemRelease( sMem ); + sMem.flags = MEM_Null; + + /* If we have read more header data than was contained in the header, + ** or if the end of the last field appears to be past the end of the + ** record, or if the end of the last field appears to be before the end + ** of the record (when all fields present), then we must be dealing + ** with a corrupt database. + */ + if ( ( zIdx > zEndHdr ) || ( offset > payloadSize ) + || ( zIdx == zEndHdr && offset != payloadSize ) ) + { + rc = SQLITE_CORRUPT_BKPT(); + goto op_column_out; + } + } + + /* Get the column information. If aOffset[p2] is non-zero, then + ** deserialize the value from the record. If aOffset[p2] is zero, + ** then there are not enough fields in the record to satisfy the + ** request. In this case, set the value NULL or to P4 if P4 is + ** a pointer to a Mem object. + */ + if ( aOffset[p2] != 0 ) + { + Debug.Assert( rc == SQLITE_OK ); + if ( zRec != null ) + { + sqlite3VdbeMemReleaseExternal( pDest ); + sqlite3VdbeSerialGet( zRec, (int)aOffset[p2], aType[p2], pDest ); + } + else + { + len = (int)sqlite3VdbeSerialTypeLen( aType[p2] ); + sqlite3VdbeMemMove( sMem, pDest ); + rc = sqlite3VdbeMemFromBtree( pCrsr, (int)aOffset[p2], len, pC.isIndex, sMem ); + if ( rc != SQLITE_OK ) + { + goto op_column_out; + } + zData = sMem.zBLOB; + sMem.zBLOB = null; + sqlite3VdbeSerialGet( zData, aType[p2], pDest ); + } + pDest.enc = encoding; + } + else + { + if ( pOp.p4type == P4_MEM ) + { + sqlite3VdbeMemShallowCopy( pDest, pOp.p4.pMem, MEM_Static ); + } + else + { + Debug.Assert( ( pDest.flags & MEM_Null ) != 0 ); + } + } + + /* If we dynamically allocated space to hold the data (in the + ** sqlite3VdbeMemFromBtree() call above) then transfer control of that + ** dynamically allocated space over to the pDest structure. + ** This prevents a memory copy. + */ + //if ( sMem.zMalloc != null ) + //{ + // Debug.Assert( sMem.z == sMem.zMalloc); + // Debug.Assert( sMem.xDel == null ); + // Debug.Assert( ( pDest.flags & MEM_Dyn ) == 0 ); + // Debug.Assert( ( pDest.flags & ( MEM_Blob | MEM_Str ) ) == 0 || pDest.z == sMem.z ); + // pDest.flags &= ~( MEM_Ephem | MEM_Static ); + // pDest.flags |= MEM_Term; + // pDest.z = sMem.z; + // pDest.zMalloc = sMem.zMalloc; + //} + + rc = sqlite3VdbeMemMakeWriteable( pDest ); + +op_column_out: #if SQLITE_TEST UPDATE_MAX_BLOBSIZE( pDest ); #endif - REGISTER_TRACE(p, pOp.p3, pDest); - if (zData != null && zData != zRec) - sqlite3_free(ref zData); - //sqlite3_free( ref zRec ); - sqlite3_free(ref sMem); - break; - } + REGISTER_TRACE( p, pOp.p3, pDest ); + if ( zData != null && zData != zRec ) + sqlite3_free( ref zData ); + //sqlite3_free( ref zRec ); + sqlite3_free( ref sMem ); + break; + } - /* Opcode: Affinity P1 P2 * P4 * - ** - ** Apply affinities to a range of P2 registers starting with P1. - ** - ** P4 is a string that is P2 characters long. The nth character of the - ** string indicates the column affinity that should be used for the nth - ** memory cell in the range. - */ - case OP_Affinity: { - string zAffinity; /* The affinity to be applied */ - char cAff; /* A single character of affinity */ - - zAffinity = pOp.p4.z; - Debug.Assert(!String.IsNullOrEmpty(zAffinity)); - Debug.Assert(zAffinity.Length <= pOp.p2);//zAffinity[pOp.p2] == 0 - //pIn1 = aMem[pOp.p1]; - for (int zI = 0; zI < zAffinity.Length; zI++)// while( (cAff = *(zAffinity++))!=0 ){ - { - cAff = zAffinity[zI]; - pIn1 = aMem[pOp.p1 + zI]; - //Debug.Assert( pIn1 <= p->aMem[p->nMem] ); - Debug.Assert(memIsValid(pIn1)); - ExpandBlob(pIn1); - applyAffinity(pIn1, cAff, encoding); - //pIn1++; - } - break; - } + /* Opcode: Affinity P1 P2 * P4 * + ** + ** Apply affinities to a range of P2 registers starting with P1. + ** + ** P4 is a string that is P2 characters long. The nth character of the + ** string indicates the column affinity that should be used for the nth + ** memory cell in the range. + */ + case OP_Affinity: + { + string zAffinity; /* The affinity to be applied */ + char cAff; /* A single character of affinity */ + + zAffinity = pOp.p4.z; + Debug.Assert( !String.IsNullOrEmpty( zAffinity ) ); + Debug.Assert( zAffinity.Length <= pOp.p2 );//zAffinity[pOp.p2] == 0 + //pIn1 = aMem[pOp.p1]; + for ( int zI = 0; zI < zAffinity.Length; zI++ )// while( (cAff = *(zAffinity++))!=0 ){ + { + cAff = zAffinity[zI]; + pIn1 = aMem[pOp.p1 + zI]; + //Debug.Assert( pIn1 <= p->aMem[p->nMem] ); + Debug.Assert( memIsValid( pIn1 ) ); + ExpandBlob( pIn1 ); + applyAffinity( pIn1, cAff, encoding ); + //pIn1++; + } + break; + } - /* Opcode: MakeRecord P1 P2 P3 P4 * - ** - ** Convert P2 registers beginning with P1 into the [record format] - ** use as a data record in a database table or as a key - ** in an index. The OP_Column opcode can decode the record later. - ** - ** P4 may be a string that is P2 characters long. The nth character of the - ** string indicates the column affinity that should be used for the nth - ** field of the index key. - ** - ** The mapping from character to affinity is given by the SQLITE_AFF_ - ** macros defined in sqliteInt.h. - ** - ** If P4 is NULL then all index fields have the affinity NONE. - */ - case OP_MakeRecord: { - byte[] zNewRecord; /* A buffer to hold the data for the new record */ - Mem pRec; /* The new record */ - u64 nData; /* Number of bytes of data space */ - int nHdr; /* Number of bytes of header space */ - i64 nByte; /* Data space required for this record */ - int nZero; /* Number of zero bytes at the end of the record */ - int nVarint; /* Number of bytes in a varint */ - u32 serial_type; /* Type field */ - //Mem pData0; /* First field to be combined into the record */ - //Mem pLast; /* Last field of the record */ - int nField; /* Number of fields in the record */ - string zAffinity; /* The affinity string for the record */ - int file_format; /* File format to use for encoding */ - int i; /* Space used in zNewRecord[] */ - int len; /* Length of a field */ - /* Assuming the record contains N fields, the record format looks - ** like this: - ** - ** ------------------------------------------------------------------------ - ** | hdr-size | type 0 | type 1 | ... | type N-1 | data0 | ... | data N-1 | - ** ------------------------------------------------------------------------ - ** - ** Data(0) is taken from register P1. Data(1) comes from register P1+1 - ** and so froth. - ** - ** Each type field is a varint representing the serial type of the - ** corresponding data element (see sqlite3VdbeSerialType()). The - ** hdr-size field is also a varint which is the offset from the beginning - ** of the record to data0. - */ - - nData = 0; /* Number of bytes of data space */ - nHdr = 0; /* Number of bytes of header space */ - nZero = 0; /* Number of zero bytes at the end of the record */ - nField = pOp.p1; - zAffinity = (pOp.p4.z == null || pOp.p4.z.Length == 0) ? "" : pOp.p4.z; - Debug.Assert(nField > 0 && pOp.p2 > 0 && pOp.p2 + nField <= p.nMem + 1); - //pData0 = aMem[nField]; - nField = pOp.p2; - //pLast = pData0[nField - 1]; - file_format = p.minWriteFileFormat; - - /* Identify the output register */ - Debug.Assert(pOp.p3 < pOp.p1 || pOp.p3 >= pOp.p1 + pOp.p2); - pOut = aMem[pOp.p3]; - memAboutToChange(p, pOut); - - /* Loop through the elements that will make up the record to figure - ** out how much space is required for the new record. - */ - //for (pRec = pData0; pRec <= pLast; pRec++) - for (int pD0 = 0; pD0 < nField; pD0++) { - pRec = p.aMem[pOp.p1 + pD0]; - Debug.Assert(memIsValid(pRec)); - if (pD0 < zAffinity.Length && zAffinity[pD0] != '\0') { - applyAffinity(pRec, (char)zAffinity[pD0], encoding); - } - if ((pRec.flags & MEM_Zero) != 0 && pRec.n > 0) { - sqlite3VdbeMemExpandBlob(pRec); - } - serial_type = sqlite3VdbeSerialType(pRec, file_format); - len = (int)sqlite3VdbeSerialTypeLen(serial_type); - nData += (u64)len; - nHdr += sqlite3VarintLen(serial_type); - if ((pRec.flags & MEM_Zero) != 0) { - /* Only pure zero-filled BLOBs can be input to this Opcode. - ** We do not allow blobs with a prefix and a zero-filled tail. */ - nZero += pRec.u.nZero; - } else if (len != 0) { - nZero = 0; - } - } - - /* Add the initial header varint and total the size */ - nHdr += nVarint = sqlite3VarintLen((u64)nHdr); - if (nVarint < sqlite3VarintLen((u64)nHdr)) { - nHdr++; - } - nByte = (i64)((u64)nHdr + nData - (u64)nZero); - if (nByte > db.aLimit[SQLITE_LIMIT_LENGTH]) { - goto too_big; - } - - /* Make sure the output register has a buffer large enough to store - ** the new record. The output register (pOp.p3) is not allowed to - ** be one of the input registers (because the following call to - ** sqlite3VdbeMemGrow() could clobber the value before it is used). - */ - //if ( sqlite3VdbeMemGrow( pOut, (int)nByte, 0 ) != 0 ) - //{ - // goto no_mem; - //} - zNewRecord = sqlite3Malloc((int)nByte);// (u8 )pOut.z; - - /* Write the record */ - i = putVarint32(zNewRecord, nHdr); - for (int pD0 = 0; pD0 < nField; pD0++)//for (pRec = pData0; pRec <= pLast; pRec++) - { - pRec = p.aMem[pOp.p1 + pD0]; - serial_type = sqlite3VdbeSerialType(pRec, file_format); - i += putVarint32(zNewRecord, i, (int)serial_type); /* serial type */ - } - for (int pD0 = 0; pD0 < nField; pD0++)//for (pRec = pData0; pRec <= pLast; pRec++) - { /* serial data */ - pRec = p.aMem[pOp.p1 + pD0]; - i += (int)sqlite3VdbeSerialPut(zNewRecord, i, (int)nByte - i, pRec, file_format); - } - //TODO -- Remove this for testing Debug.Assert( i == nByte ); - - Debug.Assert(pOp.p3 > 0 && pOp.p3 <= p.nMem); - pOut.zBLOB = zNewRecord; - pOut.z = null; - pOut.n = (int)nByte; - pOut.flags = MEM_Blob | MEM_Dyn; - pOut.xDel = null; - if (nZero != 0) { - pOut.u.nZero = nZero; - pOut.flags |= MEM_Zero; - } - pOut.enc = SQLITE_UTF8; /* In case the blob is ever converted to text */ - REGISTER_TRACE(p, pOp.p3, pOut); + /* Opcode: MakeRecord P1 P2 P3 P4 * + ** + ** Convert P2 registers beginning with P1 into the [record format] + ** use as a data record in a database table or as a key + ** in an index. The OP_Column opcode can decode the record later. + ** + ** P4 may be a string that is P2 characters long. The nth character of the + ** string indicates the column affinity that should be used for the nth + ** field of the index key. + ** + ** The mapping from character to affinity is given by the SQLITE_AFF_ + ** macros defined in sqliteInt.h. + ** + ** If P4 is NULL then all index fields have the affinity NONE. + */ + case OP_MakeRecord: + { + byte[] zNewRecord; /* A buffer to hold the data for the new record */ + Mem pRec; /* The new record */ + u64 nData; /* Number of bytes of data space */ + int nHdr; /* Number of bytes of header space */ + i64 nByte; /* Data space required for this record */ + int nZero; /* Number of zero bytes at the end of the record */ + int nVarint; /* Number of bytes in a varint */ + u32 serial_type; /* Type field */ + //Mem pData0; /* First field to be combined into the record */ + //Mem pLast; /* Last field of the record */ + int nField; /* Number of fields in the record */ + string zAffinity; /* The affinity string for the record */ + int file_format; /* File format to use for encoding */ + int i; /* Space used in zNewRecord[] */ + int len; /* Length of a field */ + /* Assuming the record contains N fields, the record format looks + ** like this: + ** + ** ------------------------------------------------------------------------ + ** | hdr-size | type 0 | type 1 | ... | type N-1 | data0 | ... | data N-1 | + ** ------------------------------------------------------------------------ + ** + ** Data(0) is taken from register P1. Data(1) comes from register P1+1 + ** and so froth. + ** + ** Each type field is a varint representing the serial type of the + ** corresponding data element (see sqlite3VdbeSerialType()). The + ** hdr-size field is also a varint which is the offset from the beginning + ** of the record to data0. + */ + + nData = 0; /* Number of bytes of data space */ + nHdr = 0; /* Number of bytes of header space */ + nZero = 0; /* Number of zero bytes at the end of the record */ + nField = pOp.p1; + zAffinity = ( pOp.p4.z == null || pOp.p4.z.Length == 0 ) ? "" : pOp.p4.z; + Debug.Assert( nField > 0 && pOp.p2 > 0 && pOp.p2 + nField <= p.nMem + 1 ); + //pData0 = aMem[nField]; + nField = pOp.p2; + //pLast = pData0[nField - 1]; + file_format = p.minWriteFileFormat; + + /* Identify the output register */ + Debug.Assert( pOp.p3 < pOp.p1 || pOp.p3 >= pOp.p1 + pOp.p2 ); + pOut = aMem[pOp.p3]; + memAboutToChange( p, pOut ); + + /* Loop through the elements that will make up the record to figure + ** out how much space is required for the new record. + */ + //for (pRec = pData0; pRec <= pLast; pRec++) + for ( int pD0 = 0; pD0 < nField; pD0++ ) + { + pRec = p.aMem[pOp.p1 + pD0]; + Debug.Assert( memIsValid( pRec ) ); + if ( pD0 < zAffinity.Length && zAffinity[pD0] != '\0' ) + { + applyAffinity( pRec, (char)zAffinity[pD0], encoding ); + } + if ( ( pRec.flags & MEM_Zero ) != 0 && pRec.n > 0 ) + { + sqlite3VdbeMemExpandBlob( pRec ); + } + serial_type = sqlite3VdbeSerialType( pRec, file_format ); + len = (int)sqlite3VdbeSerialTypeLen( serial_type ); + nData += (u64)len; + nHdr += sqlite3VarintLen( serial_type ); + if ( ( pRec.flags & MEM_Zero ) != 0 ) + { + /* Only pure zero-filled BLOBs can be input to this Opcode. + ** We do not allow blobs with a prefix and a zero-filled tail. */ + nZero += pRec.u.nZero; + } + else if ( len != 0 ) + { + nZero = 0; + } + } + + /* Add the initial header varint and total the size */ + nHdr += nVarint = sqlite3VarintLen( (u64)nHdr ); + if ( nVarint < sqlite3VarintLen( (u64)nHdr ) ) + { + nHdr++; + } + nByte = (i64)( (u64)nHdr + nData - (u64)nZero ); + if ( nByte > db.aLimit[SQLITE_LIMIT_LENGTH] ) + { + goto too_big; + } + + /* Make sure the output register has a buffer large enough to store + ** the new record. The output register (pOp.p3) is not allowed to + ** be one of the input registers (because the following call to + ** sqlite3VdbeMemGrow() could clobber the value before it is used). + */ + //if ( sqlite3VdbeMemGrow( pOut, (int)nByte, 0 ) != 0 ) + //{ + // goto no_mem; + //} + zNewRecord = sqlite3Malloc( (int)nByte );// (u8 )pOut.z; + + /* Write the record */ + i = putVarint32( zNewRecord, nHdr ); + for ( int pD0 = 0; pD0 < nField; pD0++ )//for (pRec = pData0; pRec <= pLast; pRec++) + { + pRec = p.aMem[pOp.p1 + pD0]; + serial_type = sqlite3VdbeSerialType( pRec, file_format ); + i += putVarint32( zNewRecord, i, (int)serial_type ); /* serial type */ + } + for ( int pD0 = 0; pD0 < nField; pD0++ )//for (pRec = pData0; pRec <= pLast; pRec++) + { /* serial data */ + pRec = p.aMem[pOp.p1 + pD0]; + i += (int)sqlite3VdbeSerialPut( zNewRecord, i, (int)nByte - i, pRec, file_format ); + } + //TODO -- Remove this for testing Debug.Assert( i == nByte ); + + Debug.Assert( pOp.p3 > 0 && pOp.p3 <= p.nMem ); + pOut.zBLOB = zNewRecord; + pOut.z = null; + pOut.n = (int)nByte; + pOut.flags = MEM_Blob | MEM_Dyn; + pOut.xDel = null; + if ( nZero != 0 ) + { + pOut.u.nZero = nZero; + pOut.flags |= MEM_Zero; + } + pOut.enc = SQLITE_UTF8; /* In case the blob is ever converted to text */ + REGISTER_TRACE( p, pOp.p3, pOut ); #if SQLITE_TEST UPDATE_MAX_BLOBSIZE( pOut ); #endif - break; - } + break; + } - /* Opcode: Count P1 P2 * * * - ** - ** Store the number of entries (an integer value) in the table or index - ** opened by cursor P1 in register P2 - */ + /* Opcode: Count P1 P2 * * * + ** + ** Store the number of entries (an integer value) in the table or index + ** opened by cursor P1 in register P2 + */ #if !SQLITE_OMIT_BTREECOUNT - case OP_Count: { /* out2-prerelease */ - i64 nEntry = 0; - BtCursor pCrsr; - pCrsr = p.apCsr[pOp.p1].pCursor; - if (pCrsr != null) { - rc = sqlite3BtreeCount(pCrsr, ref nEntry); - } else { - nEntry = 0; - } - pOut.u.i = nEntry; - break; - } + case OP_Count: + { /* out2-prerelease */ + i64 nEntry = 0; + BtCursor pCrsr; + pCrsr = p.apCsr[pOp.p1].pCursor; + if ( pCrsr != null ) + { + rc = sqlite3BtreeCount( pCrsr, ref nEntry ); + } + else + { + nEntry = 0; + } + pOut.u.i = nEntry; + break; + } #endif - /* Opcode: Savepoint P1 * * P4 * - ** - ** Open, release or rollback the savepoint named by parameter P4, depending - ** on the value of P1. To open a new savepoint, P1==0. To release (commit) an - ** existing savepoint, P1==1, or to rollback an existing savepoint P1==2. - */ - case OP_Savepoint: { - int p1; /* Value of P1 operand */ - string zName; /* Name of savepoint */ - Savepoint pNew; - Savepoint pSavepoint; - Savepoint pTmp; - int iSavepoint; - int ii; - - p1 = pOp.p1; - zName = pOp.p4.z; - - /* Assert that the p1 parameter is valid. Also that if there is no open - ** transaction, then there cannot be any savepoints. - */ - Debug.Assert(db.pSavepoint == null || db.autoCommit == 0); - Debug.Assert(p1 == SAVEPOINT_BEGIN || p1 == SAVEPOINT_RELEASE || p1 == SAVEPOINT_ROLLBACK); - Debug.Assert(db.pSavepoint != null || db.isTransactionSavepoint == 0); - Debug.Assert(checkSavepointCount(db) != 0); - - if (p1 == SAVEPOINT_BEGIN) { - if (db.writeVdbeCnt > 0) { - /* A new savepoint cannot be created if there are active write - ** statements (i.e. open read/write incremental blob handles). - */ - sqlite3SetString(ref p.zErrMsg, db, "cannot open savepoint - ", - "SQL statements in progress"); - rc = SQLITE_BUSY; - } else { - ////nName = sqlite3Strlen30( zName ); + /* Opcode: Savepoint P1 * * P4 * +** +** Open, release or rollback the savepoint named by parameter P4, depending +** on the value of P1. To open a new savepoint, P1==0. To release (commit) an +** existing savepoint, P1==1, or to rollback an existing savepoint P1==2. +*/ + case OP_Savepoint: + { + int p1; /* Value of P1 operand */ + string zName; /* Name of savepoint */ + Savepoint pNew; + Savepoint pSavepoint; + Savepoint pTmp; + int iSavepoint; + int ii; + + p1 = pOp.p1; + zName = pOp.p4.z; + + /* Assert that the p1 parameter is valid. Also that if there is no open + ** transaction, then there cannot be any savepoints. + */ + Debug.Assert( db.pSavepoint == null || db.autoCommit == 0 ); + Debug.Assert( p1 == SAVEPOINT_BEGIN || p1 == SAVEPOINT_RELEASE || p1 == SAVEPOINT_ROLLBACK ); + Debug.Assert( db.pSavepoint != null || db.isTransactionSavepoint == 0 ); + Debug.Assert( checkSavepointCount( db ) != 0 ); + + if ( p1 == SAVEPOINT_BEGIN ) + { + if ( db.writeVdbeCnt > 0 ) + { + /* A new savepoint cannot be created if there are active write + ** statements (i.e. open read/write incremental blob handles). + */ + sqlite3SetString( ref p.zErrMsg, db, "cannot open savepoint - ", + "SQL statements in progress" ); + rc = SQLITE_BUSY; + } + else + { + ////nName = sqlite3Strlen30( zName ); #if !SQLITE_OMIT_VIRTUALTABLE - /* This call is Ok even if this savepoint is actually a transaction - ** savepoint (and therefore should not prompt xSavepoint()) callbacks. - ** If this is a transaction savepoint being opened, it is guaranteed - ** that the db->aVTrans[] array is empty. */ - Debug.Assert(db.autoCommit == 0 || db.nVTrans == 0); - rc = sqlite3VtabSavepoint(db, SAVEPOINT_BEGIN, - db.nStatement + db.nSavepoint); - if (rc != SQLITE_OK) - goto abort_due_to_error; + /* This call is Ok even if this savepoint is actually a transaction + ** savepoint (and therefore should not prompt xSavepoint()) callbacks. + ** If this is a transaction savepoint being opened, it is guaranteed + ** that the db->aVTrans[] array is empty. */ + Debug.Assert( db.autoCommit == 0 || db.nVTrans == 0 ); + rc = sqlite3VtabSavepoint( db, SAVEPOINT_BEGIN, + db.nStatement + db.nSavepoint ); + if ( rc != SQLITE_OK ) + goto abort_due_to_error; #endif - /* Create a new savepoint structure. */ - pNew = new Savepoint();// sqlite3DbMallocRaw( db, sizeof( Savepoint ) + nName + 1 ); - if (pNew != null) { - //pNew.zName = (char )&pNew[1]; - //memcpy(pNew.zName, zName, nName+1); - pNew.zName = zName; - - /* If there is no open transaction, then mark this as a special - ** "transaction savepoint". */ - if (db.autoCommit != 0) { - db.autoCommit = 0; - db.isTransactionSavepoint = 1; - } else { - db.nSavepoint++; - } - - /* Link the new savepoint into the database handle's list. */ - pNew.pNext = db.pSavepoint; - db.pSavepoint = pNew; - pNew.nDeferredCons = db.nDeferredCons; - } - } - } else { - iSavepoint = 0; - - /* Find the named savepoint. If there is no such savepoint, then an - ** an error is returned to the user. */ - for ( - pSavepoint = db.pSavepoint; - pSavepoint != null && !pSavepoint.zName.Equals(zName, StringComparison.OrdinalIgnoreCase); - pSavepoint = pSavepoint.pNext - ) { - iSavepoint++; - } - if (null == pSavepoint) { - sqlite3SetString(ref p.zErrMsg, db, "no such savepoint: %s", zName); - rc = SQLITE_ERROR; - } else if ( - db.writeVdbeCnt > 0 || (p1 == SAVEPOINT_ROLLBACK && db.activeVdbeCnt > 1) - ) { - /* It is not possible to release (commit) a savepoint if there are - ** active write statements. It is not possible to rollback a savepoint - ** if there are any active statements at all. - */ - sqlite3SetString(ref p.zErrMsg, db, - "cannot %s savepoint - SQL statements in progress", - (p1 == SAVEPOINT_ROLLBACK ? "rollback" : "release") - ); - rc = SQLITE_BUSY; - } else { - - /* Determine whether or not this is a transaction savepoint. If so, - ** and this is a RELEASE command, then the current transaction - ** is committed. - */ - int isTransaction = (pSavepoint.pNext == null && db.isTransactionSavepoint != 0) ? 1 : 0; - if (isTransaction != 0 && p1 == SAVEPOINT_RELEASE) { - if ((rc = sqlite3VdbeCheckFk(p, 1)) != SQLITE_OK) { - goto vdbe_return; - } - db.autoCommit = 1; - if (sqlite3VdbeHalt(p) == SQLITE_BUSY) { - p.pc = pc; - db.autoCommit = 0; - p.rc = rc = SQLITE_BUSY; - goto vdbe_return; - } - db.isTransactionSavepoint = 0; - rc = p.rc; - } else { - iSavepoint = db.nSavepoint - iSavepoint - 1; - for (ii = 0; ii < db.nDb; ii++) { - rc = sqlite3BtreeSavepoint(db.aDb[ii].pBt, p1, iSavepoint); - if (rc != SQLITE_OK) { - goto abort_due_to_error; - } - } - if (p1 == SAVEPOINT_ROLLBACK && (db.flags & SQLITE_InternChanges) != 0) { - sqlite3ExpirePreparedStatements(db); - sqlite3ResetInternalSchema(db, -1); - db.flags = (db.flags | SQLITE_InternChanges); - } - } - - /* Regardless of whether this is a RELEASE or ROLLBACK, destroy all - ** savepoints nested inside of the savepoint being operated on. */ - while (db.pSavepoint != pSavepoint) { - pTmp = db.pSavepoint; - db.pSavepoint = pTmp.pNext; - sqlite3DbFree(db, ref pTmp); - db.nSavepoint--; - } - - /* If it is a RELEASE, then destroy the savepoint being operated on - ** too. If it is a ROLLBACK TO, then set the number of deferred - ** constraint violations present in the database to the value stored - ** when the savepoint was created. */ - if (p1 == SAVEPOINT_RELEASE) { - Debug.Assert(pSavepoint == db.pSavepoint); - db.pSavepoint = pSavepoint.pNext; - sqlite3DbFree(db, ref pSavepoint); - if (0 == isTransaction) { - db.nSavepoint--; - } - } else { - db.nDeferredCons = pSavepoint.nDeferredCons; - } - - if (0 == isTransaction) { - rc = sqlite3VtabSavepoint(db, p1, iSavepoint); - if (rc != SQLITE_OK) - goto abort_due_to_error; - } - - } - } - - break; - } + /* Create a new savepoint structure. */ + pNew = new Savepoint();// sqlite3DbMallocRaw( db, sizeof( Savepoint ) + nName + 1 ); + if ( pNew != null ) + { + //pNew.zName = (char )&pNew[1]; + //memcpy(pNew.zName, zName, nName+1); + pNew.zName = zName; + + /* If there is no open transaction, then mark this as a special + ** "transaction savepoint". */ + if ( db.autoCommit != 0 ) + { + db.autoCommit = 0; + db.isTransactionSavepoint = 1; + } + else + { + db.nSavepoint++; + } - /* Opcode: AutoCommit P1 P2 * * * - ** - ** Set the database auto-commit flag to P1 (1 or 0). If P2 is true, roll - ** back any currently active btree transactions. If there are any active - ** VMs (apart from this one), then the COMMIT or ROLLBACK statement fails. - ** - ** This instruction causes the VM to halt. - */ - case OP_AutoCommit: { - int desiredAutoCommit; - int iRollback; - int turnOnAC; - - desiredAutoCommit = (u8)pOp.p1; - iRollback = pOp.p2; - turnOnAC = (desiredAutoCommit != 0 && 0 == db.autoCommit) ? 1 : 0; - - Debug.Assert(desiredAutoCommit != 0 || 0 == desiredAutoCommit); - Debug.Assert(desiredAutoCommit != 0 || 0 == iRollback); - - Debug.Assert(db.activeVdbeCnt > 0); /* At least this one VM is active */ - - if (turnOnAC != 0 && iRollback != 0 && db.activeVdbeCnt > 1) { - /* If this instruction implements a ROLLBACK and other VMs are - ** still running, and a transaction is active, return an error indicating - ** that the other VMs must complete first. - */ - sqlite3SetString(ref p.zErrMsg, db, "cannot rollback transaction - " + - "SQL statements in progress"); - rc = SQLITE_BUSY; - } else if (turnOnAC != 0 && 0 == iRollback && db.writeVdbeCnt > 0) { - /* If this instruction implements a COMMIT and other VMs are writing - ** return an error indicating that the other VMs must complete first. - */ - sqlite3SetString(ref p.zErrMsg, db, "cannot commit transaction - " + - "SQL statements in progress"); - rc = SQLITE_BUSY; - } else if (desiredAutoCommit != db.autoCommit) { - if (iRollback != 0) { - Debug.Assert(desiredAutoCommit != 0); - sqlite3RollbackAll(db); - db.autoCommit = 1; - } else if ((rc = sqlite3VdbeCheckFk(p, 1)) != SQLITE_OK) { - goto vdbe_return; - } else { - db.autoCommit = (u8)desiredAutoCommit; - if (sqlite3VdbeHalt(p) == SQLITE_BUSY) { - p.pc = pc; - db.autoCommit = (u8)(desiredAutoCommit == 0 ? 1 : 0); - p.rc = rc = SQLITE_BUSY; - goto vdbe_return; - } - } - Debug.Assert(db.nStatement == 0); - sqlite3CloseSavepoints(db); - if (p.rc == SQLITE_OK) { - rc = SQLITE_DONE; - } else { - rc = SQLITE_ERROR; - } - goto vdbe_return; - } else { - sqlite3SetString(ref p.zErrMsg, db, - (0 == desiredAutoCommit) ? "cannot start a transaction within a transaction" : ( - (iRollback != 0) ? "cannot rollback - no transaction is active" : - "cannot commit - no transaction is active")); - rc = SQLITE_ERROR; - } - break; - } + /* Link the new savepoint into the database handle's list. */ + pNew.pNext = db.pSavepoint; + db.pSavepoint = pNew; + pNew.nDeferredCons = db.nDeferredCons; + } + } + } + else + { + iSavepoint = 0; + + /* Find the named savepoint. If there is no such savepoint, then an + ** an error is returned to the user. */ + for ( + pSavepoint = db.pSavepoint; + pSavepoint != null && !pSavepoint.zName.Equals( zName, StringComparison.OrdinalIgnoreCase ); + pSavepoint = pSavepoint.pNext + ) + { + iSavepoint++; + } + if ( null == pSavepoint ) + { + sqlite3SetString( ref p.zErrMsg, db, "no such savepoint: %s", zName ); + rc = SQLITE_ERROR; + } + else if ( + db.writeVdbeCnt > 0 || ( p1 == SAVEPOINT_ROLLBACK && db.activeVdbeCnt > 1 ) + ) + { + /* It is not possible to release (commit) a savepoint if there are + ** active write statements. It is not possible to rollback a savepoint + ** if there are any active statements at all. + */ + sqlite3SetString( ref p.zErrMsg, db, + "cannot %s savepoint - SQL statements in progress", + ( p1 == SAVEPOINT_ROLLBACK ? "rollback" : "release" ) + ); + rc = SQLITE_BUSY; + } + else + { + + /* Determine whether or not this is a transaction savepoint. If so, + ** and this is a RELEASE command, then the current transaction + ** is committed. + */ + int isTransaction = ( pSavepoint.pNext == null && db.isTransactionSavepoint != 0 ) ? 1 : 0; + if ( isTransaction != 0 && p1 == SAVEPOINT_RELEASE ) + { + if ( ( rc = sqlite3VdbeCheckFk( p, 1 ) ) != SQLITE_OK ) + { + goto vdbe_return; + } + db.autoCommit = 1; + if ( sqlite3VdbeHalt( p ) == SQLITE_BUSY ) + { + p.pc = pc; + db.autoCommit = 0; + p.rc = rc = SQLITE_BUSY; + goto vdbe_return; + } + db.isTransactionSavepoint = 0; + rc = p.rc; + } + else + { + iSavepoint = db.nSavepoint - iSavepoint - 1; + for ( ii = 0; ii < db.nDb; ii++ ) + { + rc = sqlite3BtreeSavepoint( db.aDb[ii].pBt, p1, iSavepoint ); + if ( rc != SQLITE_OK ) + { + goto abort_due_to_error; + } + } + if ( p1 == SAVEPOINT_ROLLBACK && ( db.flags & SQLITE_InternChanges ) != 0 ) + { + sqlite3ExpirePreparedStatements( db ); + sqlite3ResetInternalSchema( db, -1 ); + db.flags = ( db.flags | SQLITE_InternChanges ); + } + } + + /* Regardless of whether this is a RELEASE or ROLLBACK, destroy all + ** savepoints nested inside of the savepoint being operated on. */ + while ( db.pSavepoint != pSavepoint ) + { + pTmp = db.pSavepoint; + db.pSavepoint = pTmp.pNext; + sqlite3DbFree( db, ref pTmp ); + db.nSavepoint--; + } + + /* If it is a RELEASE, then destroy the savepoint being operated on + ** too. If it is a ROLLBACK TO, then set the number of deferred + ** constraint violations present in the database to the value stored + ** when the savepoint was created. */ + if ( p1 == SAVEPOINT_RELEASE ) + { + Debug.Assert( pSavepoint == db.pSavepoint ); + db.pSavepoint = pSavepoint.pNext; + sqlite3DbFree( db, ref pSavepoint ); + if ( 0 == isTransaction ) + { + db.nSavepoint--; + } + } + else + { + db.nDeferredCons = pSavepoint.nDeferredCons; + } + + if ( 0 == isTransaction ) + { + rc = sqlite3VtabSavepoint( db, p1, iSavepoint ); + if ( rc != SQLITE_OK ) + goto abort_due_to_error; + } - /* Opcode: Transaction P1 P2 * * * - ** - ** Begin a transaction. The transaction ends when a Commit or Rollback - ** opcode is encountered. Depending on the ON CONFLICT setting, the - ** transaction might also be rolled back if an error is encountered. - ** - ** P1 is the index of the database file on which the transaction is - ** started. Index 0 is the main database file and index 1 is the - ** file used for temporary tables. Indices of 2 or more are used for - ** attached databases. - ** - ** If P2 is non-zero, then a write-transaction is started. A RESERVED lock is - ** obtained on the database file when a write-transaction is started. No - ** other process can start another write transaction while this transaction is - ** underway. Starting a write transaction also creates a rollback journal. A - ** write transaction must be started before any changes can be made to the - ** database. If P2 is 2 or greater then an EXCLUSIVE lock is also obtained - ** on the file. - ** - ** If a write-transaction is started and the Vdbe.usesStmtJournal flag is - ** true (this flag is set if the Vdbe may modify more than one row and may - ** throw an ABORT exception), a statement transaction may also be opened. - ** More specifically, a statement transaction is opened iff the database - ** connection is currently not in autocommit mode, or if there are other - ** active statements. A statement transaction allows the affects of this - ** VDBE to be rolled back after an error without having to roll back the - ** entire transaction. If no error is encountered, the statement transaction - ** will automatically commit when the VDBE halts. - ** - ** If P2 is zero, then a read-lock is obtained on the database file. - */ - case OP_Transaction: { - Btree pBt; - - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < db.nDb); - Debug.Assert((p.btreeMask & (((yDbMask)1) << pOp.p1)) != 0); - pBt = db.aDb[pOp.p1].pBt; - - if (pBt != null) { - rc = sqlite3BtreeBeginTrans(pBt, pOp.p2); - if (rc == SQLITE_BUSY) { - p.pc = pc; - p.rc = rc = SQLITE_BUSY; - goto vdbe_return; - } - if (rc != SQLITE_OK) { - goto abort_due_to_error; - } - if (pOp.p2 != 0 && p.usesStmtJournal - && (db.autoCommit == 0 || db.activeVdbeCnt > 1) - ) { - Debug.Assert(sqlite3BtreeIsInTrans(pBt)); - if (p.iStatement == 0) { - Debug.Assert(db.nStatement >= 0 && db.nSavepoint >= 0); - db.nStatement++; - p.iStatement = db.nSavepoint + db.nStatement; - } - rc = sqlite3VtabSavepoint(db, SAVEPOINT_BEGIN, p.iStatement - 1); - if (rc == SQLITE_OK) { - rc = sqlite3BtreeBeginStmt(pBt, p.iStatement); - } - /* Store the current value of the database handles deferred constraint - ** counter. If the statement transaction needs to be rolled back, - ** the value of this counter needs to be restored too. */ - p.nStmtDefCons = db.nDeferredCons; - } - } - break; - } + } + } - /* Opcode: ReadCookie P1 P2 P3 * * - ** - ** Read cookie number P3 from database P1 and write it into register P2. - ** P3==1 is the schema version. P3==2 is the database format. - ** P3==3 is the recommended pager cache size, and so forth. P1==0 is - ** the main database file and P1==1 is the database file used to store - ** temporary tables. - ** - ** There must be a read-lock on the database (either a transaction - ** must be started or there must be an open cursor) before - ** executing this instruction. - */ - case OP_ReadCookie: { /* out2-prerelease */ - u32 iMeta; - int iDb; - int iCookie; - - iMeta = 0; - iDb = pOp.p1; - iCookie = pOp.p3; - - Debug.Assert(pOp.p3 < SQLITE_N_BTREE_META); - Debug.Assert(iDb >= 0 && iDb < db.nDb); - Debug.Assert(db.aDb[iDb].pBt != null); - Debug.Assert((p.btreeMask & (((yDbMask)1) << iDb)) != 0); - sqlite3BtreeGetMeta(db.aDb[iDb].pBt, iCookie, ref iMeta); - pOut.u.i = (int)iMeta; - break; - } + break; + } - /* Opcode: SetCookie P1 P2 P3 * * - ** - ** Write the content of register P3 (interpreted as an integer) - ** into cookie number P2 of database P1. P2==1 is the schema version. - ** P2==2 is the database format. P2==3 is the recommended pager cache - ** size, and so forth. P1==0 is the main database file and P1==1 is the - ** database file used to store temporary tables. - ** - ** A transaction must be started before executing this opcode. - */ - case OP_SetCookie: { /* in3 */ - Db pDb; - Debug.Assert(pOp.p2 < SQLITE_N_BTREE_META); - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < db.nDb); - Debug.Assert((p.btreeMask & (((yDbMask)1) << pOp.p1)) != 0); - pDb = db.aDb[pOp.p1]; - Debug.Assert(pDb.pBt != null); - Debug.Assert(sqlite3SchemaMutexHeld(db, pOp.p1, null)); - pIn3 = aMem[pOp.p3]; - sqlite3VdbeMemIntegerify(pIn3); - /* See note about index shifting on OP_ReadCookie */ - rc = sqlite3BtreeUpdateMeta(pDb.pBt, pOp.p2, (u32)pIn3.u.i); - if (pOp.p2 == BTREE_SCHEMA_VERSION) { - /* When the schema cookie changes, record the new cookie internally */ - pDb.pSchema.schema_cookie = (int)pIn3.u.i; - db.flags |= SQLITE_InternChanges; - } else if (pOp.p2 == BTREE_FILE_FORMAT) { - /* Record changes in the file format */ - pDb.pSchema.file_format = (u8)pIn3.u.i; - } - if (pOp.p1 == 1) { - /* Invalidate all prepared statements whenever the TEMP database - ** schema is changed. Ticket #1644 */ - sqlite3ExpirePreparedStatements(db); - p.expired = false; - } - break; - } + /* Opcode: AutoCommit P1 P2 * * * + ** + ** Set the database auto-commit flag to P1 (1 or 0). If P2 is true, roll + ** back any currently active btree transactions. If there are any active + ** VMs (apart from this one), then the COMMIT or ROLLBACK statement fails. + ** + ** This instruction causes the VM to halt. + */ + case OP_AutoCommit: + { + int desiredAutoCommit; + int iRollback; + int turnOnAC; - /* Opcode: VerifyCookie P1 P2 P3 * * - ** - ** Check the value of global database parameter number 0 (the - ** schema version) and make sure it is equal to P2 and that the - ** generation counter on the local schema parse equals P3. - ** - ** P1 is the database number which is 0 for the main database file - ** and 1 for the file holding temporary tables and some higher number - ** for auxiliary databases. - ** - ** The cookie changes its value whenever the database schema changes. - ** This operation is used to detect when that the cookie has changed - ** and that the current process needs to reread the schema. - ** - ** Either a transaction needs to have been started or an OP_Open needs - ** to be executed (to establish a read lock) before this opcode is - ** invoked. - */ - case OP_VerifyCookie: { - u32 iMeta = 0; - u32 iGen; - Btree pBt; - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < db.nDb); - Debug.Assert((p.btreeMask & ((yDbMask)1 << pOp.p1)) != 0); - Debug.Assert(sqlite3SchemaMutexHeld(db, pOp.p1, null)); - pBt = db.aDb[pOp.p1].pBt; - if (pBt != null) { - sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, ref iMeta); - iGen = db.aDb[pOp.p1].pSchema.iGeneration; - } else { - iGen = iMeta = 0; - } - if (iMeta != pOp.p2 || iGen != pOp.p3) { - sqlite3DbFree(db, ref p.zErrMsg); - p.zErrMsg = "database schema has changed";// sqlite3DbStrDup(db, "database schema has changed"); - /* If the schema-cookie from the database file matches the cookie - ** stored with the in-memory representation of the schema, do - ** not reload the schema from the database file. - ** - ** If virtual-tables are in use, this is not just an optimization. - ** Often, v-tables store their data in other SQLite tables, which - ** are queried from within xNext() and other v-table methods using - ** prepared queries. If such a query is out-of-date, we do not want to - ** discard the database schema, as the user code implementing the - ** v-table would have to be ready for the sqlite3_vtab structure itself - ** to be invalidated whenever sqlite3_step() is called from within - ** a v-table method. - */ - if (db.aDb[pOp.p1].pSchema.schema_cookie != iMeta) { - sqlite3ResetInternalSchema(db, pOp.p1); - } - - p.expired = true; - rc = SQLITE_SCHEMA; - } - break; - } + desiredAutoCommit = (u8)pOp.p1; + iRollback = pOp.p2; + turnOnAC = ( desiredAutoCommit != 0 && 0 == db.autoCommit ) ? 1 : 0; - /* Opcode: OpenRead P1 P2 P3 P4 P5 - ** - ** Open a read-only cursor for the database table whose root page is - ** P2 in a database file. The database file is determined by P3. - ** P3==0 means the main database, P3==1 means the database used for - ** temporary tables, and P3>1 means used the corresponding attached - ** database. Give the new cursor an identifier of P1. The P1 - ** values need not be contiguous but all P1 values should be small integers. - ** It is an error for P1 to be negative. - ** - ** If P5!=0 then use the content of register P2 as the root page, not - ** the value of P2 itself. - ** - ** There will be a read lock on the database whenever there is an - ** open cursor. If the database was unlocked prior to this instruction - ** then a read lock is acquired as part of this instruction. A read - ** lock allows other processes to read the database but prohibits - ** any other process from modifying the database. The read lock is - ** released when all cursors are closed. If this instruction attempts - ** to get a read lock but fails, the script terminates with an - ** SQLITE_BUSY error code. - ** - ** The P4 value may be either an integer (P4_INT32) or a pointer to - ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo - ** structure, then said structure defines the content and collating - ** sequence of the index being opened. Otherwise, if P4 is an integer - ** value, it is set to the number of columns in the table. - ** - ** See also OpenWrite. - */ - /* Opcode: OpenWrite P1 P2 P3 P4 P5 - ** - ** Open a read/write cursor named P1 on the table or index whose root - ** page is P2. Or if P5!=0 use the content of register P2 to find the - ** root page. - ** - ** The P4 value may be either an integer (P4_INT32) or a pointer to - ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo - ** structure, then said structure defines the content and collating - ** sequence of the index being opened. Otherwise, if P4 is an integer - ** value, it is set to the number of columns in the table, or to the - ** largest index of any column of the table that is actually used. - ** - ** This instruction works just like OpenRead except that it opens the cursor - ** in read/write mode. For a given table, there can be one or more read-only - ** cursors or a single read/write cursor but not both. - ** - ** See also OpenRead. - */ - case OP_OpenRead: - case OP_OpenWrite: { - int nField; - KeyInfo pKeyInfo; - int p2; - int iDb; - int wrFlag; - Btree pX; - VdbeCursor pCur; - Db pDb; - - if (p.expired) { - rc = SQLITE_ABORT; - break; - } - - nField = 0; - pKeyInfo = null; - p2 = pOp.p2; - iDb = pOp.p3; - Debug.Assert(iDb >= 0 && iDb < db.nDb); - Debug.Assert((p.btreeMask & (((yDbMask)1) << iDb)) != 0); - pDb = db.aDb[iDb]; - pX = pDb.pBt; - Debug.Assert(pX != null); - if (pOp.opcode == OP_OpenWrite) { - wrFlag = 1; - Debug.Assert(sqlite3SchemaMutexHeld(db, iDb, null)); - if (pDb.pSchema.file_format < p.minWriteFileFormat) { - p.minWriteFileFormat = pDb.pSchema.file_format; - } - } else { - wrFlag = 0; - } - if (pOp.p5 != 0) { - Debug.Assert(p2 > 0); - Debug.Assert(p2 <= p.nMem); - pIn2 = aMem[p2]; - Debug.Assert(memIsValid(pIn2)); - Debug.Assert((pIn2.flags & MEM_Int) != 0); - sqlite3VdbeMemIntegerify(pIn2); - p2 = (int)pIn2.u.i; - /* The p2 value always comes from a prior OP_CreateTable opcode and - ** that opcode will always set the p2 value to 2 or more or else fail. - ** If there were a failure, the prepared statement would have halted - ** before reaching this instruction. */ - if (NEVER(p2 < 2)) { - rc = SQLITE_CORRUPT_BKPT(); - goto abort_due_to_error; - } - } - if (pOp.p4type == P4_KEYINFO) { - pKeyInfo = pOp.p4.pKeyInfo; - pKeyInfo.enc = ENC(p.db); - nField = pKeyInfo.nField + 1; - } else if (pOp.p4type == P4_INT32) { - nField = pOp.p4.i; - } - Debug.Assert(pOp.p1 >= 0); - pCur = allocateCursor(p, pOp.p1, nField, iDb, 1); - if (pCur == null) - goto no_mem; - pCur.nullRow = true; - pCur.isOrdered = true; - rc = sqlite3BtreeCursor(pX, p2, wrFlag, pKeyInfo, pCur.pCursor); - pCur.pKeyInfo = pKeyInfo; - /* Since it performs no memory allocation or IO, the only values that - ** sqlite3BtreeCursor() may return are SQLITE_EMPTY and SQLITE_OK. - ** SQLITE_EMPTY is only returned when attempting to open the table - ** rooted at page 1 of a zero-byte database. */ - Debug.Assert(rc == SQLITE_EMPTY || rc == SQLITE_OK); - if (rc == SQLITE_EMPTY) { - sqlite3MemFreeBtCursor(ref pCur.pCursor); - rc = SQLITE_OK; - } - /* Set the VdbeCursor.isTable and isIndex variables. Previous versions of - ** SQLite used to check if the root-page flags were sane at this point - ** and report database corruption if they were not, but this check has - ** since moved into the btree layer. */ - pCur.isTable = pOp.p4type != P4_KEYINFO; - pCur.isIndex = !pCur.isTable; - break; - } + Debug.Assert( desiredAutoCommit != 0 || 0 == desiredAutoCommit ); + Debug.Assert( desiredAutoCommit != 0 || 0 == iRollback ); - /* Opcode: OpenEphemeral P1 P2 * P4 * - ** - ** Open a new cursor P1 to a transient table. - ** The cursor is always opened read/write even if - ** the main database is read-only. The ephemeral - ** table is deleted automatically when the cursor is closed. - ** - ** P2 is the number of columns in the ephemeral table. - ** The cursor points to a BTree table if P4==0 and to a BTree index - ** if P4 is not 0. If P4 is not NULL, it points to a KeyInfo structure - ** that defines the format of keys in the index. - ** - ** This opcode was once called OpenTemp. But that created - ** confusion because the term "temp table", might refer either - ** to a TEMP table at the SQL level, or to a table opened by - ** this opcode. Then this opcode was call OpenVirtual. But - ** that created confusion with the whole virtual-table idea. - */ - /* Opcode: OpenAutoindex P1 P2 * P4 * - ** - ** This opcode works the same as OP_OpenEphemeral. It has a - ** different name to distinguish its use. Tables created using - ** by this opcode will be used for automatically created transient - ** indices in joins. - */ - case OP_OpenAutoindex: - case OP_OpenEphemeral: { - VdbeCursor pCx; - const int vfsFlags = - SQLITE_OPEN_READWRITE | - SQLITE_OPEN_CREATE | - SQLITE_OPEN_EXCLUSIVE | - SQLITE_OPEN_DELETEONCLOSE | - SQLITE_OPEN_TRANSIENT_DB; - - Debug.Assert(pOp.p1 >= 0); - pCx = allocateCursor(p, pOp.p1, pOp.p2, -1, 1); - if (pCx == null) - goto no_mem; - pCx.nullRow = true; - rc = sqlite3BtreeOpen(db.pVfs, null, db, ref pCx.pBt, - BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp.p5, vfsFlags); - if (rc == SQLITE_OK) { - rc = sqlite3BtreeBeginTrans(pCx.pBt, 1); - } - if (rc == SQLITE_OK) { - /* If a transient index is required, create it by calling - ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before - ** opening it. If a transient table is required, just use the - ** automatically created table with root-page 1 (an BLOB_INTKEY table). - */ - if (pOp.p4.pKeyInfo != null) { - int pgno = 0; - Debug.Assert(pOp.p4type == P4_KEYINFO); - rc = sqlite3BtreeCreateTable(pCx.pBt, ref pgno, BTREE_BLOBKEY); - if (rc == SQLITE_OK) { - Debug.Assert(pgno == MASTER_ROOT + 1); - rc = sqlite3BtreeCursor(pCx.pBt, pgno, 1, - pOp.p4.pKeyInfo, pCx.pCursor); - pCx.pKeyInfo = pOp.p4.pKeyInfo; - pCx.pKeyInfo.enc = ENC(p.db); - } - pCx.isTable = false; - } else { - rc = sqlite3BtreeCursor(pCx.pBt, MASTER_ROOT, 1, null, pCx.pCursor); - pCx.isTable = true; - } - } - pCx.isOrdered = (pOp.p5 != BTREE_UNORDERED); - pCx.isIndex = !pCx.isTable; - break; - } + Debug.Assert( db.activeVdbeCnt > 0 ); /* At least this one VM is active */ - /* Opcode: OpenPseudo P1 P2 P3 * * - ** - ** Open a new cursor that points to a fake table that contains a single - ** row of data. The content of that one row in the content of memory - ** register P2. In other words, cursor P1 becomes an alias for the - ** MEM_Blob content contained in register P2. - ** - ** A pseudo-table created by this opcode is used to hold a single - ** row output from the sorter so that the row can be decomposed into - ** individual columns using the OP_Column opcode. The OP_Column opcode - ** is the only cursor opcode that works with a pseudo-table. - ** - ** P3 is the number of fields in the records that will be stored by - ** the pseudo-table. - */ - case OP_OpenPseudo: { - VdbeCursor pCx; - Debug.Assert(pOp.p1 >= 0); - pCx = allocateCursor(p, pOp.p1, pOp.p3, -1, 0); - if (pCx == null) - goto no_mem; - pCx.nullRow = true; - pCx.pseudoTableReg = pOp.p2; - pCx.isTable = true; - pCx.isIndex = false; - break; - } + if ( turnOnAC != 0 && iRollback != 0 && db.activeVdbeCnt > 1 ) + { + /* If this instruction implements a ROLLBACK and other VMs are + ** still running, and a transaction is active, return an error indicating + ** that the other VMs must complete first. + */ + sqlite3SetString( ref p.zErrMsg, db, "cannot rollback transaction - " + + "SQL statements in progress" ); + rc = SQLITE_BUSY; + } + else if ( turnOnAC != 0 && 0 == iRollback && db.writeVdbeCnt > 0 ) + { + /* If this instruction implements a COMMIT and other VMs are writing + ** return an error indicating that the other VMs must complete first. + */ + sqlite3SetString( ref p.zErrMsg, db, "cannot commit transaction - " + + "SQL statements in progress" ); + rc = SQLITE_BUSY; + } + else if ( desiredAutoCommit != db.autoCommit ) + { + if ( iRollback != 0 ) + { + Debug.Assert( desiredAutoCommit != 0 ); + sqlite3RollbackAll( db ); + db.autoCommit = 1; + } + else if ( ( rc = sqlite3VdbeCheckFk( p, 1 ) ) != SQLITE_OK ) + { + goto vdbe_return; + } + else + { + db.autoCommit = (u8)desiredAutoCommit; + if ( sqlite3VdbeHalt( p ) == SQLITE_BUSY ) + { + p.pc = pc; + db.autoCommit = (u8)( desiredAutoCommit == 0 ? 1 : 0 ); + p.rc = rc = SQLITE_BUSY; + goto vdbe_return; + } + } + Debug.Assert( db.nStatement == 0 ); + sqlite3CloseSavepoints( db ); + if ( p.rc == SQLITE_OK ) + { + rc = SQLITE_DONE; + } + else + { + rc = SQLITE_ERROR; + } + goto vdbe_return; + } + else + { + sqlite3SetString( ref p.zErrMsg, db, + ( 0 == desiredAutoCommit ) ? "cannot start a transaction within a transaction" : ( + ( iRollback != 0 ) ? "cannot rollback - no transaction is active" : + "cannot commit - no transaction is active" ) ); + rc = SQLITE_ERROR; + } + break; + } - /* Opcode: Close P1 * * * * - ** - ** Close a cursor previously opened as P1. If P1 is not - ** currently open, this instruction is a no-op. - */ - case OP_Close: { - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); - sqlite3VdbeFreeCursor(p, p.apCsr[pOp.p1]); - p.apCsr[pOp.p1] = null; - break; - } + /* Opcode: Transaction P1 P2 * * * + ** + ** Begin a transaction. The transaction ends when a Commit or Rollback + ** opcode is encountered. Depending on the ON CONFLICT setting, the + ** transaction might also be rolled back if an error is encountered. + ** + ** P1 is the index of the database file on which the transaction is + ** started. Index 0 is the main database file and index 1 is the + ** file used for temporary tables. Indices of 2 or more are used for + ** attached databases. + ** + ** If P2 is non-zero, then a write-transaction is started. A RESERVED lock is + ** obtained on the database file when a write-transaction is started. No + ** other process can start another write transaction while this transaction is + ** underway. Starting a write transaction also creates a rollback journal. A + ** write transaction must be started before any changes can be made to the + ** database. If P2 is 2 or greater then an EXCLUSIVE lock is also obtained + ** on the file. + ** + ** If a write-transaction is started and the Vdbe.usesStmtJournal flag is + ** true (this flag is set if the Vdbe may modify more than one row and may + ** throw an ABORT exception), a statement transaction may also be opened. + ** More specifically, a statement transaction is opened iff the database + ** connection is currently not in autocommit mode, or if there are other + ** active statements. A statement transaction allows the affects of this + ** VDBE to be rolled back after an error without having to roll back the + ** entire transaction. If no error is encountered, the statement transaction + ** will automatically commit when the VDBE halts. + ** + ** If P2 is zero, then a read-lock is obtained on the database file. + */ + case OP_Transaction: + { + Btree pBt; + + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < db.nDb ); + Debug.Assert( ( p.btreeMask & ( ( (yDbMask)1 ) << pOp.p1 ) ) != 0 ); + pBt = db.aDb[pOp.p1].pBt; + + if ( pBt != null ) + { + rc = sqlite3BtreeBeginTrans( pBt, pOp.p2 ); + if ( rc == SQLITE_BUSY ) + { + p.pc = pc; + p.rc = rc = SQLITE_BUSY; + goto vdbe_return; + } + if ( rc != SQLITE_OK ) + { + goto abort_due_to_error; + } + if ( pOp.p2 != 0 && p.usesStmtJournal + && ( db.autoCommit == 0 || db.activeVdbeCnt > 1 ) + ) + { + Debug.Assert( sqlite3BtreeIsInTrans( pBt ) ); + if ( p.iStatement == 0 ) + { + Debug.Assert( db.nStatement >= 0 && db.nSavepoint >= 0 ); + db.nStatement++; + p.iStatement = db.nSavepoint + db.nStatement; + } + rc = sqlite3VtabSavepoint( db, SAVEPOINT_BEGIN, p.iStatement - 1 ); + if ( rc == SQLITE_OK ) + { + rc = sqlite3BtreeBeginStmt( pBt, p.iStatement ); + } + /* Store the current value of the database handles deferred constraint + ** counter. If the statement transaction needs to be rolled back, + ** the value of this counter needs to be restored too. */ + p.nStmtDefCons = db.nDeferredCons; + } + } + break; + } - /* Opcode: SeekGe P1 P2 P3 P4 * - ** - ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), - ** use the value in register P3 as the key. If cursor P1 refers - ** to an SQL index, then P3 is the first in an array of P4 registers - ** that are used as an unpacked index key. - ** - ** Reposition cursor P1 so that it points to the smallest entry that - ** is greater than or equal to the key value. If there are no records - ** greater than or equal to the key and P2 is not zero, then jump to P2. - ** - ** See also: Found, NotFound, Distinct, SeekLt, SeekGt, SeekLe - */ - /* Opcode: SeekGt P1 P2 P3 P4 * - ** - ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), - ** use the value in register P3 as a key. If cursor P1 refers - ** to an SQL index, then P3 is the first in an array of P4 registers - ** that are used as an unpacked index key. - ** - ** Reposition cursor P1 so that it points to the smallest entry that - ** is greater than the key value. If there are no records greater than - ** the key and P2 is not zero, then jump to P2. - ** - ** See also: Found, NotFound, Distinct, SeekLt, SeekGe, SeekLe - */ - /* Opcode: SeekLt P1 P2 P3 P4 * - ** - ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), - ** use the value in register P3 as a key. If cursor P1 refers - ** to an SQL index, then P3 is the first in an array of P4 registers - ** that are used as an unpacked index key. - ** - ** Reposition cursor P1 so that it points to the largest entry that - ** is less than the key value. If there are no records less than - ** the key and P2 is not zero, then jump to P2. - ** - ** See also: Found, NotFound, Distinct, SeekGt, SeekGe, SeekLe - */ - /* Opcode: SeekLe P1 P2 P3 P4 * - ** - ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), - ** use the value in register P3 as a key. If cursor P1 refers - ** to an SQL index, then P3 is the first in an array of P4 registers - ** that are used as an unpacked index key. - ** - ** Reposition cursor P1 so that it points to the largest entry that - ** is less than or equal to the key value. If there are no records - ** less than or equal to the key and P2 is not zero, then jump to P2. - ** - ** See also: Found, NotFound, Distinct, SeekGt, SeekGe, SeekLt - */ - case OP_SeekLt: /* jump, in3 */ - case OP_SeekLe: /* jump, in3 */ - case OP_SeekGe: /* jump, in3 */ - case OP_SeekGt: { /* jump, in3 */ - int res; - int oc; - VdbeCursor pC; - UnpackedRecord r; - int nField; - i64 iKey; /* The rowid we are to seek to */ - - res = 0; - r = new UnpackedRecord(); - - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); - Debug.Assert(pOp.p2 != 0); - pC = p.apCsr[pOp.p1]; - Debug.Assert(pC != null); - Debug.Assert(pC.pseudoTableReg == 0); - Debug.Assert(OP_SeekLe == OP_SeekLt + 1); - Debug.Assert(OP_SeekGe == OP_SeekLt + 2); - Debug.Assert(OP_SeekGt == OP_SeekLt + 3); - Debug.Assert(pC.isOrdered); - if (pC.pCursor != null) { - oc = pOp.opcode; - pC.nullRow = false; - if (pC.isTable) { - /* The input value in P3 might be of any type: integer, real, string, - ** blob, or NULL. But it needs to be an integer before we can do - ** the seek, so convert it. */ - pIn3 = aMem[pOp.p3]; - applyNumericAffinity(pIn3); - iKey = sqlite3VdbeIntValue(pIn3); - pC.rowidIsValid = false; - - /* If the P3 value could not be converted into an integer without - ** loss of information, then special processing is required... */ - if ((pIn3.flags & MEM_Int) == 0) { - if ((pIn3.flags & MEM_Real) == 0) { - /* If the P3 value cannot be converted into any kind of a number, - ** then the seek is not possible, so jump to P2 */ - pc = pOp.p2 - 1; - break; - } - /* If we reach this point, then the P3 value must be a floating - ** point number. */ - Debug.Assert((pIn3.flags & MEM_Real) != 0); - - if (iKey == SMALLEST_INT64 && (pIn3.r < (double)iKey || pIn3.r > 0)) { - /* The P3 value is too large in magnitude to be expressed as an - ** integer. */ - res = 1; - if (pIn3.r < 0) { - if (oc >= OP_SeekGe) { - Debug.Assert(oc == OP_SeekGe || oc == OP_SeekGt); - rc = sqlite3BtreeFirst(pC.pCursor, ref res); - if (rc != SQLITE_OK) - goto abort_due_to_error; - } - } else { - if (oc <= OP_SeekLe) { - Debug.Assert(oc == OP_SeekLt || oc == OP_SeekLe); - rc = sqlite3BtreeLast(pC.pCursor, ref res); - if (rc != SQLITE_OK) - goto abort_due_to_error; - } - } - if (res != 0) { - pc = pOp.p2 - 1; - } - break; - } else if (oc == OP_SeekLt || oc == OP_SeekGe) { - /* Use the ceiling() function to convert real.int */ - if (pIn3.r > (double)iKey) - iKey++; - } else { - /* Use the floor() function to convert real.int */ - Debug.Assert(oc == OP_SeekLe || oc == OP_SeekGt); - if (pIn3.r < (double)iKey) - iKey--; - } - } - rc = sqlite3BtreeMovetoUnpacked(pC.pCursor, null, iKey, 0, ref res); - if (rc != SQLITE_OK) { - goto abort_due_to_error; - } - if (res == 0) { - pC.rowidIsValid = true; - pC.lastRowid = iKey; - } - } else { - nField = pOp.p4.i; - Debug.Assert(pOp.p4type == P4_INT32); - Debug.Assert(nField > 0); - r.pKeyInfo = pC.pKeyInfo; - r.nField = (u16)nField; - - /* The next line of code computes as follows, only faster: - ** if( oc==OP_SeekGt || oc==OP_SeekLe ){ - ** r.flags = UNPACKED_INCRKEY; - ** }else{ - ** r.flags = 0; - ** } - */ - r.flags = (u16)(UNPACKED_INCRKEY * (1 & (oc - OP_SeekLt))); - Debug.Assert(oc != OP_SeekGt || r.flags == UNPACKED_INCRKEY); - Debug.Assert(oc != OP_SeekLe || r.flags == UNPACKED_INCRKEY); - Debug.Assert(oc != OP_SeekGe || r.flags == 0); - Debug.Assert(oc != OP_SeekLt || r.flags == 0); - - r.aMem = new Mem[r.nField]; - for (int rI = 0; rI < r.nField; rI++) - r.aMem[rI] = aMem[pOp.p3 + rI];// r.aMem = aMem[pOp.p3]; + /* Opcode: ReadCookie P1 P2 P3 * * + ** + ** Read cookie number P3 from database P1 and write it into register P2. + ** P3==1 is the schema version. P3==2 is the database format. + ** P3==3 is the recommended pager cache size, and so forth. P1==0 is + ** the main database file and P1==1 is the database file used to store + ** temporary tables. + ** + ** There must be a read-lock on the database (either a transaction + ** must be started or there must be an open cursor) before + ** executing this instruction. + */ + case OP_ReadCookie: + { /* out2-prerelease */ + u32 iMeta; + int iDb; + int iCookie; + + iMeta = 0; + iDb = pOp.p1; + iCookie = pOp.p3; + + Debug.Assert( pOp.p3 < SQLITE_N_BTREE_META ); + Debug.Assert( iDb >= 0 && iDb < db.nDb ); + Debug.Assert( db.aDb[iDb].pBt != null ); + Debug.Assert( ( p.btreeMask & ( ( (yDbMask)1 ) << iDb ) ) != 0 ); + sqlite3BtreeGetMeta( db.aDb[iDb].pBt, iCookie, ref iMeta ); + pOut.u.i = (int)iMeta; + break; + } + + /* Opcode: SetCookie P1 P2 P3 * * + ** + ** Write the content of register P3 (interpreted as an integer) + ** into cookie number P2 of database P1. P2==1 is the schema version. + ** P2==2 is the database format. P2==3 is the recommended pager cache + ** size, and so forth. P1==0 is the main database file and P1==1 is the + ** database file used to store temporary tables. + ** + ** A transaction must be started before executing this opcode. + */ + case OP_SetCookie: + { /* in3 */ + Db pDb; + Debug.Assert( pOp.p2 < SQLITE_N_BTREE_META ); + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < db.nDb ); + Debug.Assert( ( p.btreeMask & ( ( (yDbMask)1 ) << pOp.p1 ) ) != 0 ); + pDb = db.aDb[pOp.p1]; + Debug.Assert( pDb.pBt != null ); + Debug.Assert( sqlite3SchemaMutexHeld( db, pOp.p1, null ) ); + pIn3 = aMem[pOp.p3]; + sqlite3VdbeMemIntegerify( pIn3 ); + /* See note about index shifting on OP_ReadCookie */ + rc = sqlite3BtreeUpdateMeta( pDb.pBt, pOp.p2, (u32)pIn3.u.i ); + if ( pOp.p2 == BTREE_SCHEMA_VERSION ) + { + /* When the schema cookie changes, record the new cookie internally */ + pDb.pSchema.schema_cookie = (int)pIn3.u.i; + db.flags |= SQLITE_InternChanges; + } + else if ( pOp.p2 == BTREE_FILE_FORMAT ) + { + /* Record changes in the file format */ + pDb.pSchema.file_format = (u8)pIn3.u.i; + } + if ( pOp.p1 == 1 ) + { + /* Invalidate all prepared statements whenever the TEMP database + ** schema is changed. Ticket #1644 */ + sqlite3ExpirePreparedStatements( db ); + p.expired = false; + } + break; + } + + /* Opcode: VerifyCookie P1 P2 P3 * * + ** + ** Check the value of global database parameter number 0 (the + ** schema version) and make sure it is equal to P2 and that the + ** generation counter on the local schema parse equals P3. + ** + ** P1 is the database number which is 0 for the main database file + ** and 1 for the file holding temporary tables and some higher number + ** for auxiliary databases. + ** + ** The cookie changes its value whenever the database schema changes. + ** This operation is used to detect when that the cookie has changed + ** and that the current process needs to reread the schema. + ** + ** Either a transaction needs to have been started or an OP_Open needs + ** to be executed (to establish a read lock) before this opcode is + ** invoked. + */ + case OP_VerifyCookie: + { + u32 iMeta = 0; + u32 iGen; + Btree pBt; + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < db.nDb ); + Debug.Assert( ( p.btreeMask & ( (yDbMask)1 << pOp.p1 ) ) != 0 ); + Debug.Assert( sqlite3SchemaMutexHeld( db, pOp.p1, null ) ); + pBt = db.aDb[pOp.p1].pBt; + if ( pBt != null ) + { + sqlite3BtreeGetMeta( pBt, BTREE_SCHEMA_VERSION, ref iMeta ); + iGen = db.aDb[pOp.p1].pSchema.iGeneration; + } + else + { + iGen = iMeta = 0; + } + if ( iMeta != pOp.p2 || iGen != pOp.p3 ) + { + sqlite3DbFree( db, ref p.zErrMsg ); + p.zErrMsg = "database schema has changed";// sqlite3DbStrDup(db, "database schema has changed"); + /* If the schema-cookie from the database file matches the cookie + ** stored with the in-memory representation of the schema, do + ** not reload the schema from the database file. + ** + ** If virtual-tables are in use, this is not just an optimization. + ** Often, v-tables store their data in other SQLite tables, which + ** are queried from within xNext() and other v-table methods using + ** prepared queries. If such a query is out-of-date, we do not want to + ** discard the database schema, as the user code implementing the + ** v-table would have to be ready for the sqlite3_vtab structure itself + ** to be invalidated whenever sqlite3_step() is called from within + ** a v-table method. + */ + if ( db.aDb[pOp.p1].pSchema.schema_cookie != iMeta ) + { + sqlite3ResetInternalSchema( db, pOp.p1 ); + } + + p.expired = true; + rc = SQLITE_SCHEMA; + } + break; + } + + /* Opcode: OpenRead P1 P2 P3 P4 P5 + ** + ** Open a read-only cursor for the database table whose root page is + ** P2 in a database file. The database file is determined by P3. + ** P3==0 means the main database, P3==1 means the database used for + ** temporary tables, and P3>1 means used the corresponding attached + ** database. Give the new cursor an identifier of P1. The P1 + ** values need not be contiguous but all P1 values should be small integers. + ** It is an error for P1 to be negative. + ** + ** If P5!=0 then use the content of register P2 as the root page, not + ** the value of P2 itself. + ** + ** There will be a read lock on the database whenever there is an + ** open cursor. If the database was unlocked prior to this instruction + ** then a read lock is acquired as part of this instruction. A read + ** lock allows other processes to read the database but prohibits + ** any other process from modifying the database. The read lock is + ** released when all cursors are closed. If this instruction attempts + ** to get a read lock but fails, the script terminates with an + ** SQLITE_BUSY error code. + ** + ** The P4 value may be either an integer (P4_INT32) or a pointer to + ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo + ** structure, then said structure defines the content and collating + ** sequence of the index being opened. Otherwise, if P4 is an integer + ** value, it is set to the number of columns in the table. + ** + ** See also OpenWrite. + */ + /* Opcode: OpenWrite P1 P2 P3 P4 P5 + ** + ** Open a read/write cursor named P1 on the table or index whose root + ** page is P2. Or if P5!=0 use the content of register P2 to find the + ** root page. + ** + ** The P4 value may be either an integer (P4_INT32) or a pointer to + ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo + ** structure, then said structure defines the content and collating + ** sequence of the index being opened. Otherwise, if P4 is an integer + ** value, it is set to the number of columns in the table, or to the + ** largest index of any column of the table that is actually used. + ** + ** This instruction works just like OpenRead except that it opens the cursor + ** in read/write mode. For a given table, there can be one or more read-only + ** cursors or a single read/write cursor but not both. + ** + ** See also OpenRead. + */ + case OP_OpenRead: + case OP_OpenWrite: + { + int nField; + KeyInfo pKeyInfo; + int p2; + int iDb; + int wrFlag; + Btree pX; + VdbeCursor pCur; + Db pDb; + + if ( p.expired ) + { + rc = SQLITE_ABORT; + break; + } + + nField = 0; + pKeyInfo = null; + p2 = pOp.p2; + iDb = pOp.p3; + Debug.Assert( iDb >= 0 && iDb < db.nDb ); + Debug.Assert( ( p.btreeMask & ( ( (yDbMask)1 ) << iDb ) ) != 0 ); + pDb = db.aDb[iDb]; + pX = pDb.pBt; + Debug.Assert( pX != null ); + if ( pOp.opcode == OP_OpenWrite ) + { + wrFlag = 1; + Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) ); + if ( pDb.pSchema.file_format < p.minWriteFileFormat ) + { + p.minWriteFileFormat = pDb.pSchema.file_format; + } + } + else + { + wrFlag = 0; + } + if ( pOp.p5 != 0 ) + { + Debug.Assert( p2 > 0 ); + Debug.Assert( p2 <= p.nMem ); + pIn2 = aMem[p2]; + Debug.Assert( memIsValid( pIn2 ) ); + Debug.Assert( ( pIn2.flags & MEM_Int ) != 0 ); + sqlite3VdbeMemIntegerify( pIn2 ); + p2 = (int)pIn2.u.i; + /* The p2 value always comes from a prior OP_CreateTable opcode and + ** that opcode will always set the p2 value to 2 or more or else fail. + ** If there were a failure, the prepared statement would have halted + ** before reaching this instruction. */ + if ( NEVER( p2 < 2 ) ) + { + rc = SQLITE_CORRUPT_BKPT(); + goto abort_due_to_error; + } + } + if ( pOp.p4type == P4_KEYINFO ) + { + pKeyInfo = pOp.p4.pKeyInfo; + pKeyInfo.enc = ENC( p.db ); + nField = pKeyInfo.nField + 1; + } + else if ( pOp.p4type == P4_INT32 ) + { + nField = pOp.p4.i; + } + Debug.Assert( pOp.p1 >= 0 ); + pCur = allocateCursor( p, pOp.p1, nField, iDb, 1 ); + if ( pCur == null ) + goto no_mem; + pCur.nullRow = true; + pCur.isOrdered = true; + rc = sqlite3BtreeCursor( pX, p2, wrFlag, pKeyInfo, pCur.pCursor ); + pCur.pKeyInfo = pKeyInfo; + /* Since it performs no memory allocation or IO, the only values that + ** sqlite3BtreeCursor() may return are SQLITE_EMPTY and SQLITE_OK. + ** SQLITE_EMPTY is only returned when attempting to open the table + ** rooted at page 1 of a zero-byte database. */ + Debug.Assert( rc == SQLITE_EMPTY || rc == SQLITE_OK ); + if ( rc == SQLITE_EMPTY ) + { + sqlite3MemFreeBtCursor( ref pCur.pCursor ); + rc = SQLITE_OK; + } + /* Set the VdbeCursor.isTable and isIndex variables. Previous versions of + ** SQLite used to check if the root-page flags were sane at this point + ** and report database corruption if they were not, but this check has + ** since moved into the btree layer. */ + pCur.isTable = pOp.p4type != P4_KEYINFO; + pCur.isIndex = !pCur.isTable; + break; + } + + /* Opcode: OpenEphemeral P1 P2 * P4 * + ** + ** Open a new cursor P1 to a transient table. + ** The cursor is always opened read/write even if + ** the main database is read-only. The ephemeral + ** table is deleted automatically when the cursor is closed. + ** + ** P2 is the number of columns in the ephemeral table. + ** The cursor points to a BTree table if P4==0 and to a BTree index + ** if P4 is not 0. If P4 is not NULL, it points to a KeyInfo structure + ** that defines the format of keys in the index. + ** + ** This opcode was once called OpenTemp. But that created + ** confusion because the term "temp table", might refer either + ** to a TEMP table at the SQL level, or to a table opened by + ** this opcode. Then this opcode was call OpenVirtual. But + ** that created confusion with the whole virtual-table idea. + */ + /* Opcode: OpenAutoindex P1 P2 * P4 * + ** + ** This opcode works the same as OP_OpenEphemeral. It has a + ** different name to distinguish its use. Tables created using + ** by this opcode will be used for automatically created transient + ** indices in joins. + */ + case OP_OpenAutoindex: + case OP_OpenEphemeral: + { + VdbeCursor pCx; + const int vfsFlags = + SQLITE_OPEN_READWRITE | + SQLITE_OPEN_CREATE | + SQLITE_OPEN_EXCLUSIVE | + SQLITE_OPEN_DELETEONCLOSE | + SQLITE_OPEN_TRANSIENT_DB; + + Debug.Assert( pOp.p1 >= 0 ); + pCx = allocateCursor( p, pOp.p1, pOp.p2, -1, 1 ); + if ( pCx == null ) + goto no_mem; + pCx.nullRow = true; + rc = sqlite3BtreeOpen( db.pVfs, null, db, ref pCx.pBt, + BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp.p5, vfsFlags ); + if ( rc == SQLITE_OK ) + { + rc = sqlite3BtreeBeginTrans( pCx.pBt, 1 ); + } + if ( rc == SQLITE_OK ) + { + /* If a transient index is required, create it by calling + ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before + ** opening it. If a transient table is required, just use the + ** automatically created table with root-page 1 (an BLOB_INTKEY table). + */ + if ( pOp.p4.pKeyInfo != null ) + { + int pgno = 0; + Debug.Assert( pOp.p4type == P4_KEYINFO ); + rc = sqlite3BtreeCreateTable( pCx.pBt, ref pgno, BTREE_BLOBKEY ); + if ( rc == SQLITE_OK ) + { + Debug.Assert( pgno == MASTER_ROOT + 1 ); + rc = sqlite3BtreeCursor( pCx.pBt, pgno, 1, + pOp.p4.pKeyInfo, pCx.pCursor ); + pCx.pKeyInfo = pOp.p4.pKeyInfo; + pCx.pKeyInfo.enc = ENC( p.db ); + } + pCx.isTable = false; + } + else + { + rc = sqlite3BtreeCursor( pCx.pBt, MASTER_ROOT, 1, null, pCx.pCursor ); + pCx.isTable = true; + } + } + pCx.isOrdered = ( pOp.p5 != BTREE_UNORDERED ); + pCx.isIndex = !pCx.isTable; + break; + } + + /* Opcode: OpenPseudo P1 P2 P3 * * + ** + ** Open a new cursor that points to a fake table that contains a single + ** row of data. The content of that one row in the content of memory + ** register P2. In other words, cursor P1 becomes an alias for the + ** MEM_Blob content contained in register P2. + ** + ** A pseudo-table created by this opcode is used to hold a single + ** row output from the sorter so that the row can be decomposed into + ** individual columns using the OP_Column opcode. The OP_Column opcode + ** is the only cursor opcode that works with a pseudo-table. + ** + ** P3 is the number of fields in the records that will be stored by + ** the pseudo-table. + */ + case OP_OpenPseudo: + { + VdbeCursor pCx; + Debug.Assert( pOp.p1 >= 0 ); + pCx = allocateCursor( p, pOp.p1, pOp.p3, -1, 0 ); + if ( pCx == null ) + goto no_mem; + pCx.nullRow = true; + pCx.pseudoTableReg = pOp.p2; + pCx.isTable = true; + pCx.isIndex = false; + break; + } + + /* Opcode: Close P1 * * * * + ** + ** Close a cursor previously opened as P1. If P1 is not + ** currently open, this instruction is a no-op. + */ + case OP_Close: + { + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); + sqlite3VdbeFreeCursor( p, p.apCsr[pOp.p1] ); + p.apCsr[pOp.p1] = null; + break; + } + + /* Opcode: SeekGe P1 P2 P3 P4 * + ** + ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), + ** use the value in register P3 as the key. If cursor P1 refers + ** to an SQL index, then P3 is the first in an array of P4 registers + ** that are used as an unpacked index key. + ** + ** Reposition cursor P1 so that it points to the smallest entry that + ** is greater than or equal to the key value. If there are no records + ** greater than or equal to the key and P2 is not zero, then jump to P2. + ** + ** See also: Found, NotFound, Distinct, SeekLt, SeekGt, SeekLe + */ + /* Opcode: SeekGt P1 P2 P3 P4 * + ** + ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), + ** use the value in register P3 as a key. If cursor P1 refers + ** to an SQL index, then P3 is the first in an array of P4 registers + ** that are used as an unpacked index key. + ** + ** Reposition cursor P1 so that it points to the smallest entry that + ** is greater than the key value. If there are no records greater than + ** the key and P2 is not zero, then jump to P2. + ** + ** See also: Found, NotFound, Distinct, SeekLt, SeekGe, SeekLe + */ + /* Opcode: SeekLt P1 P2 P3 P4 * + ** + ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), + ** use the value in register P3 as a key. If cursor P1 refers + ** to an SQL index, then P3 is the first in an array of P4 registers + ** that are used as an unpacked index key. + ** + ** Reposition cursor P1 so that it points to the largest entry that + ** is less than the key value. If there are no records less than + ** the key and P2 is not zero, then jump to P2. + ** + ** See also: Found, NotFound, Distinct, SeekGt, SeekGe, SeekLe + */ + /* Opcode: SeekLe P1 P2 P3 P4 * + ** + ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), + ** use the value in register P3 as a key. If cursor P1 refers + ** to an SQL index, then P3 is the first in an array of P4 registers + ** that are used as an unpacked index key. + ** + ** Reposition cursor P1 so that it points to the largest entry that + ** is less than or equal to the key value. If there are no records + ** less than or equal to the key and P2 is not zero, then jump to P2. + ** + ** See also: Found, NotFound, Distinct, SeekGt, SeekGe, SeekLt + */ + case OP_SeekLt: /* jump, in3 */ + case OP_SeekLe: /* jump, in3 */ + case OP_SeekGe: /* jump, in3 */ + case OP_SeekGt: + { /* jump, in3 */ + int res; + int oc; + VdbeCursor pC; + UnpackedRecord r; + int nField; + i64 iKey; /* The rowid we are to seek to */ + + res = 0; + r = new UnpackedRecord(); + + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); + Debug.Assert( pOp.p2 != 0 ); + pC = p.apCsr[pOp.p1]; + Debug.Assert( pC != null ); + Debug.Assert( pC.pseudoTableReg == 0 ); + Debug.Assert( OP_SeekLe == OP_SeekLt + 1 ); + Debug.Assert( OP_SeekGe == OP_SeekLt + 2 ); + Debug.Assert( OP_SeekGt == OP_SeekLt + 3 ); + Debug.Assert( pC.isOrdered ); + if ( pC.pCursor != null ) + { + oc = pOp.opcode; + pC.nullRow = false; + if ( pC.isTable ) + { + /* The input value in P3 might be of any type: integer, real, string, + ** blob, or NULL. But it needs to be an integer before we can do + ** the seek, so convert it. */ + pIn3 = aMem[pOp.p3]; + applyNumericAffinity( pIn3 ); + iKey = sqlite3VdbeIntValue( pIn3 ); + pC.rowidIsValid = false; + + /* If the P3 value could not be converted into an integer without + ** loss of information, then special processing is required... */ + if ( ( pIn3.flags & MEM_Int ) == 0 ) + { + if ( ( pIn3.flags & MEM_Real ) == 0 ) + { + /* If the P3 value cannot be converted into any kind of a number, + ** then the seek is not possible, so jump to P2 */ + pc = pOp.p2 - 1; + break; + } + /* If we reach this point, then the P3 value must be a floating + ** point number. */ + Debug.Assert( ( pIn3.flags & MEM_Real ) != 0 ); + + if ( iKey == SMALLEST_INT64 && ( pIn3.r < (double)iKey || pIn3.r > 0 ) ) + { + /* The P3 value is too large in magnitude to be expressed as an + ** integer. */ + res = 1; + if ( pIn3.r < 0 ) + { + if ( oc >= OP_SeekGe ) + { + Debug.Assert( oc == OP_SeekGe || oc == OP_SeekGt ); + rc = sqlite3BtreeFirst( pC.pCursor, ref res ); + if ( rc != SQLITE_OK ) + goto abort_due_to_error; + } + } + else + { + if ( oc <= OP_SeekLe ) + { + Debug.Assert( oc == OP_SeekLt || oc == OP_SeekLe ); + rc = sqlite3BtreeLast( pC.pCursor, ref res ); + if ( rc != SQLITE_OK ) + goto abort_due_to_error; + } + } + if ( res != 0 ) + { + pc = pOp.p2 - 1; + } + break; + } + else if ( oc == OP_SeekLt || oc == OP_SeekGe ) + { + /* Use the ceiling() function to convert real.int */ + if ( pIn3.r > (double)iKey ) + iKey++; + } + else + { + /* Use the floor() function to convert real.int */ + Debug.Assert( oc == OP_SeekLe || oc == OP_SeekGt ); + if ( pIn3.r < (double)iKey ) + iKey--; + } + } + rc = sqlite3BtreeMovetoUnpacked( pC.pCursor, null, iKey, 0, ref res ); + if ( rc != SQLITE_OK ) + { + goto abort_due_to_error; + } + if ( res == 0 ) + { + pC.rowidIsValid = true; + pC.lastRowid = iKey; + } + } + else + { + nField = pOp.p4.i; + Debug.Assert( pOp.p4type == P4_INT32 ); + Debug.Assert( nField > 0 ); + r.pKeyInfo = pC.pKeyInfo; + r.nField = (u16)nField; + + /* The next line of code computes as follows, only faster: + ** if( oc==OP_SeekGt || oc==OP_SeekLe ){ + ** r.flags = UNPACKED_INCRKEY; + ** }else{ + ** r.flags = 0; + ** } + */ + r.flags = (u16)( UNPACKED_INCRKEY * ( 1 & ( oc - OP_SeekLt ) ) ); + Debug.Assert( oc != OP_SeekGt || r.flags == UNPACKED_INCRKEY ); + Debug.Assert( oc != OP_SeekLe || r.flags == UNPACKED_INCRKEY ); + Debug.Assert( oc != OP_SeekGe || r.flags == 0 ); + Debug.Assert( oc != OP_SeekLt || r.flags == 0 ); + + r.aMem = new Mem[r.nField]; + for ( int rI = 0; rI < r.nField; rI++ ) + r.aMem[rI] = aMem[pOp.p3 + rI];// r.aMem = aMem[pOp.p3]; #if SQLITE_DEBUG - { - int i; - for (i = 0; i < r.nField; i++) - Debug.Assert(memIsValid(r.aMem[i])); - } + { + int i; + for ( i = 0; i < r.nField; i++ ) + Debug.Assert( memIsValid( r.aMem[i] ) ); + } #endif - ExpandBlob(r.aMem[0]); - rc = sqlite3BtreeMovetoUnpacked(pC.pCursor, r, 0, 0, ref res); - if (rc != SQLITE_OK) { - goto abort_due_to_error; - } - pC.rowidIsValid = false; - } - pC.deferredMoveto = false; - pC.cacheStatus = CACHE_STALE; + ExpandBlob( r.aMem[0] ); + rc = sqlite3BtreeMovetoUnpacked( pC.pCursor, r, 0, 0, ref res ); + if ( rc != SQLITE_OK ) + { + goto abort_due_to_error; + } + pC.rowidIsValid = false; + } + pC.deferredMoveto = false; + pC.cacheStatus = CACHE_STALE; #if SQLITE_TEST #if !TCLSH sqlite3_search_count++; @@ -3675,102 +4102,117 @@ Vdbe p /* The VDBE */ sqlite3_search_count.iValue++; #endif #endif - if (oc >= OP_SeekGe) { - Debug.Assert(oc == OP_SeekGe || oc == OP_SeekGt); - if (res < 0 || (res == 0 && oc == OP_SeekGt)) { - rc = sqlite3BtreeNext(pC.pCursor, ref res); - if (rc != SQLITE_OK) - goto abort_due_to_error; - pC.rowidIsValid = false; - } else { - res = 0; - } - } else { - Debug.Assert(oc == OP_SeekLt || oc == OP_SeekLe); - if (res > 0 || (res == 0 && oc == OP_SeekLt)) { - rc = sqlite3BtreePrevious(pC.pCursor, ref res); - if (rc != SQLITE_OK) - goto abort_due_to_error; - pC.rowidIsValid = false; - } else { - /* res might be negative because the table is empty. Check to - ** see if this is the case. - */ - res = sqlite3BtreeEof(pC.pCursor) ? 1 : 0; - } - } - Debug.Assert(pOp.p2 > 0); - if (res != 0) { - pc = pOp.p2 - 1; - } - } else { - /* This happens when attempting to open the sqlite3_master table - ** for read access returns SQLITE_EMPTY. In this case always - ** take the jump (since there are no records in the table). - */ - pc = pOp.p2 - 1; - } - break; - } - - /* Opcode: Seek P1 P2 * * * - ** - ** P1 is an open table cursor and P2 is a rowid integer. Arrange - ** for P1 to move so that it points to the rowid given by P2. - ** - ** This is actually a deferred seek. Nothing actually happens until - ** the cursor is used to read a record. That way, if no reads - ** occur, no unnecessary I/O happens. + if ( oc >= OP_SeekGe ) + { + Debug.Assert( oc == OP_SeekGe || oc == OP_SeekGt ); + if ( res < 0 || ( res == 0 && oc == OP_SeekGt ) ) + { + rc = sqlite3BtreeNext( pC.pCursor, ref res ); + if ( rc != SQLITE_OK ) + goto abort_due_to_error; + pC.rowidIsValid = false; + } + else + { + res = 0; + } + } + else + { + Debug.Assert( oc == OP_SeekLt || oc == OP_SeekLe ); + if ( res > 0 || ( res == 0 && oc == OP_SeekLt ) ) + { + rc = sqlite3BtreePrevious( pC.pCursor, ref res ); + if ( rc != SQLITE_OK ) + goto abort_due_to_error; + pC.rowidIsValid = false; + } + else + { + /* res might be negative because the table is empty. Check to + ** see if this is the case. */ - case OP_Seek: { /* in2 */ - VdbeCursor pC; - - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); - pC = p.apCsr[pOp.p1]; - Debug.Assert(ALWAYS(pC != null)); - if (pC.pCursor != null) { - Debug.Assert(pC.isTable); - pC.nullRow = false; - pIn2 = aMem[pOp.p2]; - pC.movetoTarget = sqlite3VdbeIntValue(pIn2); - pC.rowidIsValid = false; - pC.deferredMoveto = true; - } - break; - } + res = sqlite3BtreeEof( pC.pCursor ) ? 1 : 0; + } + } + Debug.Assert( pOp.p2 > 0 ); + if ( res != 0 ) + { + pc = pOp.p2 - 1; + } + } + else + { + /* This happens when attempting to open the sqlite3_master table + ** for read access returns SQLITE_EMPTY. In this case always + ** take the jump (since there are no records in the table). + */ + pc = pOp.p2 - 1; + } + break; + } - /* Opcode: Found P1 P2 P3 P4 * - ** - ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If - ** P4>0 then register P3 is the first of P4 registers that form an unpacked - ** record. - ** - ** Cursor P1 is on an index btree. If the record identified by P3 and P4 - ** is a prefix of any entry in P1 then a jump is made to P2 and - ** P1 is left pointing at the matching entry. - */ - /* Opcode: NotFound P1 P2 P3 P4 * - ** - ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If - ** P4>0 then register P3 is the first of P4 registers that form an unpacked - ** record. - ** - ** Cursor P1 is on an index btree. If the record identified by P3 and P4 - ** is not the prefix of any entry in P1 then a jump is made to P2. If P1 - ** does contain an entry whose prefix matches the P3/P4 record then control - ** falls through to the next instruction and P1 is left pointing at the - ** matching entry. - ** - ** See also: Found, NotExists, IsUnique - */ - case OP_NotFound: /* jump, in3 */ - case OP_Found: { /* jump, in3 */ - int alreadyExists; - VdbeCursor pC; - int res = 0; - UnpackedRecord pIdxKey; - UnpackedRecord r = new UnpackedRecord(); - UnpackedRecord aTempRec = new UnpackedRecord();//char aTempRec[ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*3 + 7]; + /* Opcode: Seek P1 P2 * * * + ** + ** P1 is an open table cursor and P2 is a rowid integer. Arrange + ** for P1 to move so that it points to the rowid given by P2. + ** + ** This is actually a deferred seek. Nothing actually happens until + ** the cursor is used to read a record. That way, if no reads + ** occur, no unnecessary I/O happens. + */ + case OP_Seek: + { /* in2 */ + VdbeCursor pC; + + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); + pC = p.apCsr[pOp.p1]; + Debug.Assert( ALWAYS( pC != null ) ); + if ( pC.pCursor != null ) + { + Debug.Assert( pC.isTable ); + pC.nullRow = false; + pIn2 = aMem[pOp.p2]; + pC.movetoTarget = sqlite3VdbeIntValue( pIn2 ); + pC.rowidIsValid = false; + pC.deferredMoveto = true; + } + break; + } + + /* Opcode: Found P1 P2 P3 P4 * + ** + ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If + ** P4>0 then register P3 is the first of P4 registers that form an unpacked + ** record. + ** + ** Cursor P1 is on an index btree. If the record identified by P3 and P4 + ** is a prefix of any entry in P1 then a jump is made to P2 and + ** P1 is left pointing at the matching entry. + */ + /* Opcode: NotFound P1 P2 P3 P4 * + ** + ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If + ** P4>0 then register P3 is the first of P4 registers that form an unpacked + ** record. + ** + ** Cursor P1 is on an index btree. If the record identified by P3 and P4 + ** is not the prefix of any entry in P1 then a jump is made to P2. If P1 + ** does contain an entry whose prefix matches the P3/P4 record then control + ** falls through to the next instruction and P1 is left pointing at the + ** matching entry. + ** + ** See also: Found, NotExists, IsUnique + */ + case OP_NotFound: /* jump, in3 */ + case OP_Found: + { /* jump, in3 */ + int alreadyExists; + VdbeCursor pC; + int res = 0; + UnpackedRecord pIdxKey; + UnpackedRecord r = new UnpackedRecord(); + UnpackedRecord aTempRec = new UnpackedRecord();//char aTempRec[ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*3 + 7]; #if SQLITE_TEST #if !TCLSH @@ -3779,772 +4221,865 @@ Vdbe p /* The VDBE */ sqlite3_found_count.iValue++; #endif #endif - alreadyExists = 0; - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); - Debug.Assert(pOp.p4type == P4_INT32); - pC = p.apCsr[pOp.p1]; - Debug.Assert(pC != null); - pIn3 = aMem[pOp.p3]; - if (ALWAYS(pC.pCursor != null)) { - - Debug.Assert(!pC.isTable); - if (pOp.p4.i > 0) { - r.pKeyInfo = pC.pKeyInfo; - r.nField = (u16)pOp.p4.i; - r.aMem = new Mem[r.nField]; - for (int i = 0; i < r.aMem.Length; i++) { - r.aMem[i] = aMem[pOp.p3 + i]; + alreadyExists = 0; + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); + Debug.Assert( pOp.p4type == P4_INT32 ); + pC = p.apCsr[pOp.p1]; + Debug.Assert( pC != null ); + pIn3 = aMem[pOp.p3]; + if ( ALWAYS( pC.pCursor != null ) ) + { + + Debug.Assert( !pC.isTable ); + if ( pOp.p4.i > 0 ) + { + r.pKeyInfo = pC.pKeyInfo; + r.nField = (u16)pOp.p4.i; + r.aMem = new Mem[r.nField]; + for ( int i = 0; i < r.aMem.Length; i++ ) + { + r.aMem[i] = aMem[pOp.p3 + i]; #if SQLITE_DEBUG - Debug.Assert(memIsValid(r.aMem[i])); + Debug.Assert( memIsValid( r.aMem[i] ) ); #endif - } - r.flags = UNPACKED_PREFIX_MATCH; - pIdxKey = r; - } else { - Debug.Assert((pIn3.flags & MEM_Blob) != 0); - Debug.Assert((pIn3.flags & MEM_Zero) == 0); /* zeroblobs already expanded */ - pIdxKey = sqlite3VdbeRecordUnpack(pC.pKeyInfo, pIn3.n, pIn3.zBLOB, - aTempRec, 0);//sizeof( aTempRec ) ); - if (pIdxKey == null) { - goto no_mem; - } - pIdxKey.flags |= UNPACKED_PREFIX_MATCH; - } - rc = sqlite3BtreeMovetoUnpacked(pC.pCursor, pIdxKey, 0, 0, ref res); - if (pOp.p4.i == 0) { - sqlite3VdbeDeleteUnpackedRecord(pIdxKey); - } - if (rc != SQLITE_OK) { - break; - } - alreadyExists = (res == 0) ? 1 : 0; - pC.deferredMoveto = false; - pC.cacheStatus = CACHE_STALE; - } - if (pOp.opcode == OP_Found) { - if (alreadyExists != 0) - pc = pOp.p2 - 1; - } else { - if (0 == alreadyExists) - pc = pOp.p2 - 1; - } - break; - } + } + r.flags = UNPACKED_PREFIX_MATCH; + pIdxKey = r; + } + else + { + Debug.Assert( ( pIn3.flags & MEM_Blob ) != 0 ); + Debug.Assert( ( pIn3.flags & MEM_Zero ) == 0 ); /* zeroblobs already expanded */ + pIdxKey = sqlite3VdbeRecordUnpack( pC.pKeyInfo, pIn3.n, pIn3.zBLOB, + aTempRec, 0 );//sizeof( aTempRec ) ); + if ( pIdxKey == null ) + { + goto no_mem; + } + pIdxKey.flags |= UNPACKED_PREFIX_MATCH; + } + rc = sqlite3BtreeMovetoUnpacked( pC.pCursor, pIdxKey, 0, 0, ref res ); + if ( pOp.p4.i == 0 ) + { + sqlite3VdbeDeleteUnpackedRecord( pIdxKey ); + } + if ( rc != SQLITE_OK ) + { + break; + } + alreadyExists = ( res == 0 ) ? 1 : 0; + pC.deferredMoveto = false; + pC.cacheStatus = CACHE_STALE; + } + if ( pOp.opcode == OP_Found ) + { + if ( alreadyExists != 0 ) + pc = pOp.p2 - 1; + } + else + { + if ( 0 == alreadyExists ) + pc = pOp.p2 - 1; + } + break; + } - /* Opcode: IsUnique P1 P2 P3 P4 * - ** - ** Cursor P1 is open on an index b-tree - that is to say, a btree which - ** no data and where the key are records generated by OP_MakeRecord with - ** the list field being the integer ROWID of the entry that the index - ** entry refers to. - ** - ** The P3 register contains an integer record number. Call this record - ** number R. Register P4 is the first in a set of N contiguous registers - ** that make up an unpacked index key that can be used with cursor P1. - ** The value of N can be inferred from the cursor. N includes the rowid - ** value appended to the end of the index record. This rowid value may - ** or may not be the same as R. - ** - ** If any of the N registers beginning with register P4 contains a NULL - ** value, jump immediately to P2. - ** - ** Otherwise, this instruction checks if cursor P1 contains an entry - ** where the first (N-1) fields match but the rowid value at the end - ** of the index entry is not R. If there is no such entry, control jumps - ** to instruction P2. Otherwise, the rowid of the conflicting index - ** entry is copied to register P3 and control falls through to the next - ** instruction. - ** - ** See also: NotFound, NotExists, Found - */ - case OP_IsUnique: { /* jump, in3 */ - u16 ii; - VdbeCursor pCx = new VdbeCursor(); - BtCursor pCrsr; - u16 nField; - Mem[] aMx; - UnpackedRecord r; /* B-Tree index search key */ - i64 R; /* Rowid stored in register P3 */ - - r = new UnpackedRecord(); - - pIn3 = aMem[pOp.p3]; - //aMx = aMem[pOp->p4.i]; - /* Assert that the values of parameters P1 and P4 are in range. */ - Debug.Assert(pOp.p4type == P4_INT32); - Debug.Assert(pOp.p4.i > 0 && pOp.p4.i <= p.nMem); - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); - - /* Find the index cursor. */ - pCx = p.apCsr[pOp.p1]; - Debug.Assert(!pCx.deferredMoveto); - pCx.seekResult = 0; - pCx.cacheStatus = CACHE_STALE; - pCrsr = pCx.pCursor; - - /* If any of the values are NULL, take the jump. */ - nField = pCx.pKeyInfo.nField; - aMx = new Mem[nField + 1]; - for (ii = 0; ii < nField; ii++) { - aMx[ii] = aMem[pOp.p4.i + ii]; - if ((aMx[ii].flags & MEM_Null) != 0) { - pc = pOp.p2 - 1; - pCrsr = null; - break; - } - } - aMx[nField] = new Mem(); - //Debug.Assert( ( aMx[nField].flags & MEM_Null ) == 0 ); - - if (pCrsr != null) { - /* Populate the index search key. */ - r.pKeyInfo = pCx.pKeyInfo; - r.nField = (ushort)(nField + 1); - r.flags = UNPACKED_PREFIX_SEARCH; - r.aMem = aMx; + /* Opcode: IsUnique P1 P2 P3 P4 * + ** + ** Cursor P1 is open on an index b-tree - that is to say, a btree which + ** no data and where the key are records generated by OP_MakeRecord with + ** the list field being the integer ROWID of the entry that the index + ** entry refers to. + ** + ** The P3 register contains an integer record number. Call this record + ** number R. Register P4 is the first in a set of N contiguous registers + ** that make up an unpacked index key that can be used with cursor P1. + ** The value of N can be inferred from the cursor. N includes the rowid + ** value appended to the end of the index record. This rowid value may + ** or may not be the same as R. + ** + ** If any of the N registers beginning with register P4 contains a NULL + ** value, jump immediately to P2. + ** + ** Otherwise, this instruction checks if cursor P1 contains an entry + ** where the first (N-1) fields match but the rowid value at the end + ** of the index entry is not R. If there is no such entry, control jumps + ** to instruction P2. Otherwise, the rowid of the conflicting index + ** entry is copied to register P3 and control falls through to the next + ** instruction. + ** + ** See also: NotFound, NotExists, Found + */ + case OP_IsUnique: + { /* jump, in3 */ + u16 ii; + VdbeCursor pCx = new VdbeCursor(); + BtCursor pCrsr; + u16 nField; + Mem[] aMx; + UnpackedRecord r; /* B-Tree index search key */ + i64 R; /* Rowid stored in register P3 */ + + r = new UnpackedRecord(); + + pIn3 = aMem[pOp.p3]; + //aMx = aMem[pOp->p4.i]; + /* Assert that the values of parameters P1 and P4 are in range. */ + Debug.Assert( pOp.p4type == P4_INT32 ); + Debug.Assert( pOp.p4.i > 0 && pOp.p4.i <= p.nMem ); + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); + + /* Find the index cursor. */ + pCx = p.apCsr[pOp.p1]; + Debug.Assert( !pCx.deferredMoveto ); + pCx.seekResult = 0; + pCx.cacheStatus = CACHE_STALE; + pCrsr = pCx.pCursor; + + /* If any of the values are NULL, take the jump. */ + nField = pCx.pKeyInfo.nField; + aMx = new Mem[nField + 1]; + for ( ii = 0; ii < nField; ii++ ) + { + aMx[ii] = aMem[pOp.p4.i + ii]; + if ( ( aMx[ii].flags & MEM_Null ) != 0 ) + { + pc = pOp.p2 - 1; + pCrsr = null; + break; + } + } + aMx[nField] = new Mem(); + //Debug.Assert( ( aMx[nField].flags & MEM_Null ) == 0 ); + + if ( pCrsr != null ) + { + /* Populate the index search key. */ + r.pKeyInfo = pCx.pKeyInfo; + r.nField = (ushort)( nField + 1 ); + r.flags = UNPACKED_PREFIX_SEARCH; + r.aMem = aMx; #if SQLITE_DEBUG - { - int i; - for (i = 0; i < r.nField; i++) - Debug.Assert(memIsValid(r.aMem[i])); - } + { + int i; + for ( i = 0; i < r.nField; i++ ) + Debug.Assert( memIsValid( r.aMem[i] ) ); + } #endif - /* Extract the value of R from register P3. */ - sqlite3VdbeMemIntegerify(pIn3); - R = pIn3.u.i; - - /* Search the B-Tree index. If no conflicting record is found, jump - ** to P2. Otherwise, copy the rowid of the conflicting record to - ** register P3 and fall through to the next instruction. */ - rc = sqlite3BtreeMovetoUnpacked(pCrsr, r, 0, 0, ref pCx.seekResult); - if ((r.flags & UNPACKED_PREFIX_SEARCH) != 0 || r.rowid == R) { - pc = pOp.p2 - 1; - } else { - pIn3.u.i = r.rowid; - } - } - break; - } + /* Extract the value of R from register P3. */ + sqlite3VdbeMemIntegerify( pIn3 ); + R = pIn3.u.i; + + /* Search the B-Tree index. If no conflicting record is found, jump + ** to P2. Otherwise, copy the rowid of the conflicting record to + ** register P3 and fall through to the next instruction. */ + rc = sqlite3BtreeMovetoUnpacked( pCrsr, r, 0, 0, ref pCx.seekResult ); + if ( ( r.flags & UNPACKED_PREFIX_SEARCH ) != 0 || r.rowid == R ) + { + pc = pOp.p2 - 1; + } + else + { + pIn3.u.i = r.rowid; + } + } + break; + } - /* Opcode: NotExists P1 P2 P3 * * - ** - ** Use the content of register P3 as an integer key. If a record - ** with that key does not exist in table of P1, then jump to P2. - ** If the record does exist, then fall through. The cursor is left - ** pointing to the record if it exists. - ** - ** The difference between this operation and NotFound is that this - ** operation assumes the key is an integer and that P1 is a table whereas - ** NotFound assumes key is a blob constructed from MakeRecord and - ** P1 is an index. - ** - ** See also: Found, NotFound, IsUnique - */ - case OP_NotExists: { /* jump, in3 */ - VdbeCursor pC; - BtCursor pCrsr; - int res; - i64 iKey; - - pIn3 = aMem[pOp.p3]; - Debug.Assert((pIn3.flags & MEM_Int) != 0); - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); - pC = p.apCsr[pOp.p1]; - Debug.Assert(pC != null); - Debug.Assert(pC.isTable); - Debug.Assert(pC.pseudoTableReg == 0); - pCrsr = pC.pCursor; - if (pCrsr != null) { - res = 0; - iKey = pIn3.u.i; - rc = sqlite3BtreeMovetoUnpacked(pCrsr, null, (long)iKey, 0, ref res); - pC.lastRowid = pIn3.u.i; - pC.rowidIsValid = res == 0 ? true : false; - pC.nullRow = false; - pC.cacheStatus = CACHE_STALE; - pC.deferredMoveto = false; - if (res != 0) { - pc = pOp.p2 - 1; - Debug.Assert(!pC.rowidIsValid); - } - pC.seekResult = res; - } else { - /* This happens when an attempt to open a read cursor on the - ** sqlite_master table returns SQLITE_EMPTY. - */ - pc = pOp.p2 - 1; - Debug.Assert(!pC.rowidIsValid); - pC.seekResult = 0; - } - break; - } + /* Opcode: NotExists P1 P2 P3 * * + ** + ** Use the content of register P3 as an integer key. If a record + ** with that key does not exist in table of P1, then jump to P2. + ** If the record does exist, then fall through. The cursor is left + ** pointing to the record if it exists. + ** + ** The difference between this operation and NotFound is that this + ** operation assumes the key is an integer and that P1 is a table whereas + ** NotFound assumes key is a blob constructed from MakeRecord and + ** P1 is an index. + ** + ** See also: Found, NotFound, IsUnique + */ + case OP_NotExists: + { /* jump, in3 */ + VdbeCursor pC; + BtCursor pCrsr; + int res; + i64 iKey; + + pIn3 = aMem[pOp.p3]; + Debug.Assert( ( pIn3.flags & MEM_Int ) != 0 ); + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); + pC = p.apCsr[pOp.p1]; + Debug.Assert( pC != null ); + Debug.Assert( pC.isTable ); + Debug.Assert( pC.pseudoTableReg == 0 ); + pCrsr = pC.pCursor; + if ( pCrsr != null ) + { + res = 0; + iKey = pIn3.u.i; + rc = sqlite3BtreeMovetoUnpacked( pCrsr, null, (long)iKey, 0, ref res ); + pC.lastRowid = pIn3.u.i; + pC.rowidIsValid = res == 0 ? true : false; + pC.nullRow = false; + pC.cacheStatus = CACHE_STALE; + pC.deferredMoveto = false; + if ( res != 0 ) + { + pc = pOp.p2 - 1; + Debug.Assert( !pC.rowidIsValid ); + } + pC.seekResult = res; + } + else + { + /* This happens when an attempt to open a read cursor on the + ** sqlite_master table returns SQLITE_EMPTY. + */ + pc = pOp.p2 - 1; + Debug.Assert( !pC.rowidIsValid ); + pC.seekResult = 0; + } + break; + } - /* Opcode: Sequence P1 P2 * * * - ** - ** Find the next available sequence number for cursor P1. - ** Write the sequence number into register P2. - ** The sequence number on the cursor is incremented after this - ** instruction. - */ - case OP_Sequence: { /* out2-prerelease */ - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); - Debug.Assert(p.apCsr[pOp.p1] != null); - pOut.u.i = (long)p.apCsr[pOp.p1].seqCount++; - break; - } + /* Opcode: Sequence P1 P2 * * * + ** + ** Find the next available sequence number for cursor P1. + ** Write the sequence number into register P2. + ** The sequence number on the cursor is incremented after this + ** instruction. + */ + case OP_Sequence: + { /* out2-prerelease */ + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); + Debug.Assert( p.apCsr[pOp.p1] != null ); + pOut.u.i = (long)p.apCsr[pOp.p1].seqCount++; + break; + } - /* Opcode: NewRowid P1 P2 P3 * * - ** - ** Get a new integer record number (a.k.a "rowid") used as the key to a table. - ** The record number is not previously used as a key in the database - ** table that cursor P1 points to. The new record number is written - ** written to register P2. - ** - ** If P3>0 then P3 is a register in the root frame of this VDBE that holds - ** the largest previously generated record number. No new record numbers are - ** allowed to be less than this value. When this value reaches its maximum, - ** an SQLITE_FULL error is generated. The P3 register is updated with the ' - ** generated record number. This P3 mechanism is used to help implement the - ** AUTOINCREMENT feature. - */ - case OP_NewRowid: { /* out2-prerelease */ - i64 v; /* The new rowid */ - VdbeCursor pC; /* Cursor of table to get the new rowid */ - int res; /* Result of an sqlite3BtreeLast() */ - int cnt; /* Counter to limit the number of searches */ - Mem pMem; /* Register holding largest rowid for AUTOINCREMENT */ - VdbeFrame pFrame; /* Root frame of VDBE */ - - v = 0; - res = 0; - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); - pC = p.apCsr[pOp.p1]; - Debug.Assert(pC != null); - if (NEVER(pC.pCursor == null)) { - /* The zero initialization above is all that is needed */ - } else { - /* The next rowid or record number (different terms for the same - ** thing) is obtained in a two-step algorithm. - ** - ** First we attempt to find the largest existing rowid and add one - ** to that. But if the largest existing rowid is already the maximum - ** positive integer, we have to fall through to the second - ** probabilistic algorithm - ** - ** The second algorithm is to select a rowid at random and see if - ** it already exists in the table. If it does not exist, we have - ** succeeded. If the random rowid does exist, we select a new one - ** and try again, up to 100 times. - */ - Debug.Assert(pC.isTable); + /* Opcode: NewRowid P1 P2 P3 * * + ** + ** Get a new integer record number (a.k.a "rowid") used as the key to a table. + ** The record number is not previously used as a key in the database + ** table that cursor P1 points to. The new record number is written + ** written to register P2. + ** + ** If P3>0 then P3 is a register in the root frame of this VDBE that holds + ** the largest previously generated record number. No new record numbers are + ** allowed to be less than this value. When this value reaches its maximum, + ** an SQLITE_FULL error is generated. The P3 register is updated with the ' + ** generated record number. This P3 mechanism is used to help implement the + ** AUTOINCREMENT feature. + */ + case OP_NewRowid: + { /* out2-prerelease */ + i64 v; /* The new rowid */ + VdbeCursor pC; /* Cursor of table to get the new rowid */ + int res; /* Result of an sqlite3BtreeLast() */ + int cnt; /* Counter to limit the number of searches */ + Mem pMem; /* Register holding largest rowid for AUTOINCREMENT */ + VdbeFrame pFrame; /* Root frame of VDBE */ + + v = 0; + res = 0; + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); + pC = p.apCsr[pOp.p1]; + Debug.Assert( pC != null ); + if ( NEVER( pC.pCursor == null ) ) + { + /* The zero initialization above is all that is needed */ + } + else + { + /* The next rowid or record number (different terms for the same + ** thing) is obtained in a two-step algorithm. + ** + ** First we attempt to find the largest existing rowid and add one + ** to that. But if the largest existing rowid is already the maximum + ** positive integer, we have to fall through to the second + ** probabilistic algorithm + ** + ** The second algorithm is to select a rowid at random and see if + ** it already exists in the table. If it does not exist, we have + ** succeeded. If the random rowid does exist, we select a new one + ** and try again, up to 100 times. + */ + Debug.Assert( pC.isTable ); #if SQLITE_32BIT_ROWID const int MAX_ROWID = i32.MaxValue;//# define MAX_ROWID 0x7fffffff #else - /* Some compilers complain about constants of the form 0x7fffffffffffffff. - ** Others complain about 0x7ffffffffffffffffLL. The following macro seems - ** to provide the constant while making all compilers happy. - */ - const long MAX_ROWID = i64.MaxValue;// (i64)( (((u64)0x7fffffff)<<32) | (u64)0xffffffff ) + /* Some compilers complain about constants of the form 0x7fffffffffffffff. +** Others complain about 0x7ffffffffffffffffLL. The following macro seems +** to provide the constant while making all compilers happy. +*/ + const long MAX_ROWID = i64.MaxValue;// (i64)( (((u64)0x7fffffff)<<32) | (u64)0xffffffff ) #endif - if (!pC.useRandomRowid) { - v = sqlite3BtreeGetCachedRowid(pC.pCursor); - if (v == 0) { - rc = sqlite3BtreeLast(pC.pCursor, ref res); - if (rc != SQLITE_OK) { - goto abort_due_to_error; - } - if (res != 0) { - v = 1;/* IMP: R-61914-48074 */ - } else { - Debug.Assert(sqlite3BtreeCursorIsValid(pC.pCursor)); - rc = sqlite3BtreeKeySize(pC.pCursor, ref v); - Debug.Assert(rc == SQLITE_OK); /* Cannot fail following BtreeLast() */ - if (v == MAX_ROWID) { - pC.useRandomRowid = true; - } else { - v++; /* IMP: R-29538-34987 */ - } - } - } + if ( !pC.useRandomRowid ) + { + v = sqlite3BtreeGetCachedRowid( pC.pCursor ); + if ( v == 0 ) + { + rc = sqlite3BtreeLast( pC.pCursor, ref res ); + if ( rc != SQLITE_OK ) + { + goto abort_due_to_error; + } + if ( res != 0 ) + { + v = 1;/* IMP: R-61914-48074 */ + } + else + { + Debug.Assert( sqlite3BtreeCursorIsValid( pC.pCursor ) ); + rc = sqlite3BtreeKeySize( pC.pCursor, ref v ); + Debug.Assert( rc == SQLITE_OK ); /* Cannot fail following BtreeLast() */ + if ( v == MAX_ROWID ) + { + pC.useRandomRowid = true; + } + else + { + v++; /* IMP: R-29538-34987 */ + } + } + } #if !SQLITE_OMIT_AUTOINCREMENT - if (pOp.p3 != 0) { - /* Assert that P3 is a valid memory cell. */ - Debug.Assert(pOp.p3 > 0); - if (p.pFrame != null) { - for (pFrame = p.pFrame; pFrame.pParent != null; pFrame = pFrame.pParent) - ; - /* Assert that P3 is a valid memory cell. */ - Debug.Assert(pOp.p3 <= pFrame.nMem); - pMem = pFrame.aMem[pOp.p3]; - } else { - /* Assert that P3 is a valid memory cell. */ - Debug.Assert(pOp.p3 <= p.nMem); - pMem = aMem[pOp.p3]; - memAboutToChange(p, pMem); - } - Debug.Assert(memIsValid(pMem)); - - REGISTER_TRACE(p, pOp.p3, pMem); - sqlite3VdbeMemIntegerify(pMem); - Debug.Assert((pMem.flags & MEM_Int) != 0); /* mem(P3) holds an integer */ - if (pMem.u.i == MAX_ROWID || pC.useRandomRowid) { - rc = SQLITE_FULL; /* IMP: R-12275-61338 */ - goto abort_due_to_error; - } - if (v < (pMem.u.i + 1)) { - v = (int)(pMem.u.i + 1); - } - pMem.u.i = (long)v; - } + if ( pOp.p3 != 0 ) + { + /* Assert that P3 is a valid memory cell. */ + Debug.Assert( pOp.p3 > 0 ); + if ( p.pFrame != null ) + { + for ( pFrame = p.pFrame; pFrame.pParent != null; pFrame = pFrame.pParent ) + ; + /* Assert that P3 is a valid memory cell. */ + Debug.Assert( pOp.p3 <= pFrame.nMem ); + pMem = pFrame.aMem[pOp.p3]; + } + else + { + /* Assert that P3 is a valid memory cell. */ + Debug.Assert( pOp.p3 <= p.nMem ); + pMem = aMem[pOp.p3]; + memAboutToChange( p, pMem ); + } + Debug.Assert( memIsValid( pMem ) ); + + REGISTER_TRACE( p, pOp.p3, pMem ); + sqlite3VdbeMemIntegerify( pMem ); + Debug.Assert( ( pMem.flags & MEM_Int ) != 0 ); /* mem(P3) holds an integer */ + if ( pMem.u.i == MAX_ROWID || pC.useRandomRowid ) + { + rc = SQLITE_FULL; /* IMP: R-12275-61338 */ + goto abort_due_to_error; + } + if ( v < ( pMem.u.i + 1 ) ) + { + v = (int)( pMem.u.i + 1 ); + } + pMem.u.i = (long)v; + } #endif - sqlite3BtreeSetCachedRowid(pC.pCursor, v < MAX_ROWID ? v + 1 : 0); - } - if (pC.useRandomRowid) { - /* IMPLEMENTATION-OF: R-07677-41881 If the largest ROWID is equal to the - ** largest possible integer (9223372036854775807) then the database - ** engine starts picking positive candidate ROWIDs at random until - ** it finds one that is not previously used. */ - Debug.Assert(pOp.p3 == 0); /* We cannot be in random rowid mode if this is + sqlite3BtreeSetCachedRowid( pC.pCursor, v < MAX_ROWID ? v + 1 : 0 ); + } + if ( pC.useRandomRowid ) + { + /* IMPLEMENTATION-OF: R-07677-41881 If the largest ROWID is equal to the + ** largest possible integer (9223372036854775807) then the database + ** engine starts picking positive candidate ROWIDs at random until + ** it finds one that is not previously used. */ + Debug.Assert( pOp.p3 == 0 ); /* We cannot be in random rowid mode if this is ** an AUTOINCREMENT table. */ - /* on the first attempt, simply do one more than previous */ - v = lastRowid; - v &= (MAX_ROWID >> 1); /* ensure doesn't go negative */ - v++; /* ensure non-zero */ - cnt = 0; - while (((rc = sqlite3BtreeMovetoUnpacked(pC.pCursor, null, v, - 0, ref res)) == SQLITE_OK) - && (res == 0) - && (++cnt < 100)) { - /* collision - try another random rowid */ - sqlite3_randomness(sizeof(i64), ref v); - if (cnt < 5) { - /* try "small" random rowids for the initial attempts */ - v &= 0xffffff; - } else { - v &= (MAX_ROWID >> 1); /* ensure doesn't go negative */ - } - v++; /* ensure non-zero */ - } - if (rc == SQLITE_OK && res == 0) { - rc = SQLITE_FULL;/* IMP: R-38219-53002 */ - goto abort_due_to_error; - } - Debug.Assert(v > 0); /* EV: R-40812-03570 */ - } - pC.rowidIsValid = false; - pC.deferredMoveto = false; - pC.cacheStatus = CACHE_STALE; - } - pOut.u.i = (long)v; - break; - } + /* on the first attempt, simply do one more than previous */ + v = lastRowid; + v &= ( MAX_ROWID >> 1 ); /* ensure doesn't go negative */ + v++; /* ensure non-zero */ + cnt = 0; + while ( ( ( rc = sqlite3BtreeMovetoUnpacked( pC.pCursor, null, v, + 0, ref res ) ) == SQLITE_OK ) + && ( res == 0 ) + && ( ++cnt < 100 ) ) + { + /* collision - try another random rowid */ + sqlite3_randomness( sizeof( i64 ), ref v ); + if ( cnt < 5 ) + { + /* try "small" random rowids for the initial attempts */ + v &= 0xffffff; + } + else + { + v &= ( MAX_ROWID >> 1 ); /* ensure doesn't go negative */ + } + v++; /* ensure non-zero */ + } + if ( rc == SQLITE_OK && res == 0 ) + { + rc = SQLITE_FULL;/* IMP: R-38219-53002 */ + goto abort_due_to_error; + } + Debug.Assert( v > 0 ); /* EV: R-40812-03570 */ + } + pC.rowidIsValid = false; + pC.deferredMoveto = false; + pC.cacheStatus = CACHE_STALE; + } + pOut.u.i = (long)v; + break; + } - /* Opcode: Insert P1 P2 P3 P4 P5 - ** - ** Write an entry into the table of cursor P1. A new entry is - ** created if it doesn't already exist or the data for an existing - ** entry is overwritten. The data is the value MEM_Blob stored in register - ** number P2. The key is stored in register P3. The key must - ** be a MEM_Int. - ** - ** If the OPFLAG_NCHANGE flag of P5 is set, then the row change count is - ** incremented (otherwise not). If the OPFLAG_LASTROWID flag of P5 is set, - ** then rowid is stored for subsequent return by the - ** sqlite3_last_insert_rowid() function (otherwise it is unmodified). - ** - ** If the OPFLAG_USESEEKRESULT flag of P5 is set and if the result of - ** the last seek operation (OP_NotExists) was a success, then this - ** operation will not attempt to find the appropriate row before doing - ** the insert but will instead overwrite the row that the cursor is - ** currently pointing to. Presumably, the prior OP_NotExists opcode - ** has already positioned the cursor correctly. This is an optimization - ** that boosts performance by avoiding redundant seeks. - ** - ** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an - ** UPDATE operation. Otherwise (if the flag is clear) then this opcode - ** is part of an INSERT operation. The difference is only important to - ** the update hook. - ** - ** Parameter P4 may point to a string containing the table-name, or - ** may be NULL. If it is not NULL, then the update-hook - ** (sqlite3.xUpdateCallback) is invoked following a successful insert. - ** - ** (WARNING/TODO: If P1 is a pseudo-cursor and P2 is dynamically - ** allocated, then ownership of P2 is transferred to the pseudo-cursor - ** and register P2 becomes ephemeral. If the cursor is changed, the - ** value of register P2 will then change. Make sure this does not - ** cause any problems.) - ** - ** This instruction only works on tables. The equivalent instruction - ** for indices is OP_IdxInsert. - */ - /* Opcode: InsertInt P1 P2 P3 P4 P5 - ** - ** This works exactly like OP_Insert except that the key is the - ** integer value P3, not the value of the integer stored in register P3. - */ - case OP_Insert: - case OP_InsertInt: { - Mem pData; /* MEM cell holding data for the record to be inserted */ - Mem pKey; /* MEM cell holding key for the record */ - i64 iKey; /* The integer ROWID or key for the record to be inserted */ - VdbeCursor pC; /* Cursor to table into which insert is written */ - int nZero; /* Number of zero-bytes to append */ - int seekResult; /* Result of prior seek or 0 if no USESEEKRESULT flag */ - string zDb; /* database name - used by the update hook */ - string zTbl; /* Table name - used by the opdate hook */ - int op; /* Opcode for update hook: SQLITE_UPDATE or SQLITE_INSERT */ - - pData = aMem[pOp.p2]; - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); - Debug.Assert(memIsValid(pData)); - pC = p.apCsr[pOp.p1]; - Debug.Assert(pC != null); - Debug.Assert(pC.pCursor != null); - Debug.Assert(pC.pseudoTableReg == 0); - Debug.Assert(pC.isTable); - REGISTER_TRACE(p, pOp.p2, pData); - - if (pOp.opcode == OP_Insert) { - pKey = aMem[pOp.p3]; - Debug.Assert((pKey.flags & MEM_Int) != 0); - Debug.Assert(memIsValid(pKey)); - REGISTER_TRACE(p, pOp.p3, pKey); - iKey = pKey.u.i; - } else { - Debug.Assert(pOp.opcode == OP_InsertInt); - iKey = pOp.p3; - } - - if ((pOp.p5 & OPFLAG_NCHANGE) != 0) - p.nChange++; - if ((pOp.p5 & OPFLAG_LASTROWID) != 0) - db.lastRowid = lastRowid = iKey; - if ((pData.flags & MEM_Null) != 0) { - sqlite3_free(ref pData.zBLOB); - pData.z = null; - pData.n = 0; - } else { - Debug.Assert((pData.flags & (MEM_Blob | MEM_Str)) != 0); - } - seekResult = ((pOp.p5 & OPFLAG_USESEEKRESULT) != 0 ? pC.seekResult : 0); - if ((pData.flags & MEM_Zero) != 0) { - nZero = pData.u.nZero; - } else { - nZero = 0; - } - rc = sqlite3BtreeInsert(pC.pCursor, null, iKey, - pData.zBLOB - , pData.n, nZero, - (pOp.p5 & OPFLAG_APPEND) != 0 ? 1 : 0, seekResult - ); - - pC.rowidIsValid = false; - pC.deferredMoveto = false; - pC.cacheStatus = CACHE_STALE; - - /* Invoke the update-hook if required. */ - if (rc == SQLITE_OK && db.xUpdateCallback != null && pOp.p4.z != null) { - zDb = db.aDb[pC.iDb].zName; - zTbl = pOp.p4.z; - op = ((pOp.p5 & OPFLAG_ISUPDATE) != 0 ? SQLITE_UPDATE : SQLITE_INSERT); - Debug.Assert(pC.isTable); - db.xUpdateCallback(db.pUpdateArg, op, zDb, zTbl, iKey); - Debug.Assert(pC.iDb >= 0); - } - break; - } + /* Opcode: Insert P1 P2 P3 P4 P5 + ** + ** Write an entry into the table of cursor P1. A new entry is + ** created if it doesn't already exist or the data for an existing + ** entry is overwritten. The data is the value MEM_Blob stored in register + ** number P2. The key is stored in register P3. The key must + ** be a MEM_Int. + ** + ** If the OPFLAG_NCHANGE flag of P5 is set, then the row change count is + ** incremented (otherwise not). If the OPFLAG_LASTROWID flag of P5 is set, + ** then rowid is stored for subsequent return by the + ** sqlite3_last_insert_rowid() function (otherwise it is unmodified). + ** + ** If the OPFLAG_USESEEKRESULT flag of P5 is set and if the result of + ** the last seek operation (OP_NotExists) was a success, then this + ** operation will not attempt to find the appropriate row before doing + ** the insert but will instead overwrite the row that the cursor is + ** currently pointing to. Presumably, the prior OP_NotExists opcode + ** has already positioned the cursor correctly. This is an optimization + ** that boosts performance by avoiding redundant seeks. + ** + ** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an + ** UPDATE operation. Otherwise (if the flag is clear) then this opcode + ** is part of an INSERT operation. The difference is only important to + ** the update hook. + ** + ** Parameter P4 may point to a string containing the table-name, or + ** may be NULL. If it is not NULL, then the update-hook + ** (sqlite3.xUpdateCallback) is invoked following a successful insert. + ** + ** (WARNING/TODO: If P1 is a pseudo-cursor and P2 is dynamically + ** allocated, then ownership of P2 is transferred to the pseudo-cursor + ** and register P2 becomes ephemeral. If the cursor is changed, the + ** value of register P2 will then change. Make sure this does not + ** cause any problems.) + ** + ** This instruction only works on tables. The equivalent instruction + ** for indices is OP_IdxInsert. + */ + /* Opcode: InsertInt P1 P2 P3 P4 P5 + ** + ** This works exactly like OP_Insert except that the key is the + ** integer value P3, not the value of the integer stored in register P3. + */ + case OP_Insert: + case OP_InsertInt: + { + Mem pData; /* MEM cell holding data for the record to be inserted */ + Mem pKey; /* MEM cell holding key for the record */ + i64 iKey; /* The integer ROWID or key for the record to be inserted */ + VdbeCursor pC; /* Cursor to table into which insert is written */ + int nZero; /* Number of zero-bytes to append */ + int seekResult; /* Result of prior seek or 0 if no USESEEKRESULT flag */ + string zDb; /* database name - used by the update hook */ + string zTbl; /* Table name - used by the opdate hook */ + int op; /* Opcode for update hook: SQLITE_UPDATE or SQLITE_INSERT */ + + pData = aMem[pOp.p2]; + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); + Debug.Assert( memIsValid( pData ) ); + pC = p.apCsr[pOp.p1]; + Debug.Assert( pC != null ); + Debug.Assert( pC.pCursor != null ); + Debug.Assert( pC.pseudoTableReg == 0 ); + Debug.Assert( pC.isTable ); + REGISTER_TRACE( p, pOp.p2, pData ); + + if ( pOp.opcode == OP_Insert ) + { + pKey = aMem[pOp.p3]; + Debug.Assert( ( pKey.flags & MEM_Int ) != 0 ); + Debug.Assert( memIsValid( pKey ) ); + REGISTER_TRACE( p, pOp.p3, pKey ); + iKey = pKey.u.i; + } + else + { + Debug.Assert( pOp.opcode == OP_InsertInt ); + iKey = pOp.p3; + } + + if ( ( pOp.p5 & OPFLAG_NCHANGE ) != 0 ) + p.nChange++; + if ( ( pOp.p5 & OPFLAG_LASTROWID ) != 0 ) + db.lastRowid = lastRowid = iKey; + if ( ( pData.flags & MEM_Null ) != 0 ) + { + sqlite3_free( ref pData.zBLOB ); + pData.z = null; + pData.n = 0; + } + else + { + Debug.Assert( ( pData.flags & ( MEM_Blob | MEM_Str ) ) != 0 ); + } + seekResult = ( ( pOp.p5 & OPFLAG_USESEEKRESULT ) != 0 ? pC.seekResult : 0 ); + if ( ( pData.flags & MEM_Zero ) != 0 ) + { + nZero = pData.u.nZero; + } + else + { + nZero = 0; + } + rc = sqlite3BtreeInsert( pC.pCursor, null, iKey, + pData.zBLOB + , pData.n, nZero, + ( pOp.p5 & OPFLAG_APPEND ) != 0 ? 1 : 0, seekResult + ); + + pC.rowidIsValid = false; + pC.deferredMoveto = false; + pC.cacheStatus = CACHE_STALE; + + /* Invoke the update-hook if required. */ + if ( rc == SQLITE_OK && db.xUpdateCallback != null && pOp.p4.z != null ) + { + zDb = db.aDb[pC.iDb].zName; + zTbl = pOp.p4.z; + op = ( ( pOp.p5 & OPFLAG_ISUPDATE ) != 0 ? SQLITE_UPDATE : SQLITE_INSERT ); + Debug.Assert( pC.isTable ); + db.xUpdateCallback( db.pUpdateArg, op, zDb, zTbl, iKey ); + Debug.Assert( pC.iDb >= 0 ); + } + break; + } - /* Opcode: Delete P1 P2 * P4 * - ** - ** Delete the record at which the P1 cursor is currently pointing. - ** - ** The cursor will be left pointing at either the next or the previous - ** record in the table. If it is left pointing at the next record, then - ** the next Next instruction will be a no-op. Hence it is OK to delete - ** a record from within an Next loop. - ** - ** If the OPFLAG_NCHANGE flag of P2 is set, then the row change count is - ** incremented (otherwise not). - ** - ** P1 must not be pseudo-table. It has to be a real table with - ** multiple rows. - ** - ** If P4 is not NULL, then it is the name of the table that P1 is - ** pointing to. The update hook will be invoked, if it exists. - ** If P4 is not NULL then the P1 cursor must have been positioned - ** using OP_NotFound prior to invoking this opcode. - */ - case OP_Delete: { - i64 iKey; - VdbeCursor pC; - - iKey = 0; - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); - pC = p.apCsr[pOp.p1]; - Debug.Assert(pC != null); - Debug.Assert(pC.pCursor != null); /* Only valid for real tables, no pseudotables */ - - /* If the update-hook will be invoked, set iKey to the rowid of the - ** row being deleted. - */ - if (db.xUpdateCallback != null && pOp.p4.z != null) { - Debug.Assert(pC.isTable); - Debug.Assert(pC.rowidIsValid); /* lastRowid set by previous OP_NotFound */ - iKey = pC.lastRowid; - } - - /* The OP_Delete opcode always follows an OP_NotExists or OP_Last or - ** OP_Column on the same table without any intervening operations that - ** might move or invalidate the cursor. Hence cursor pC is always pointing - ** to the row to be deleted and the sqlite3VdbeCursorMoveto() operation - ** below is always a no-op and cannot fail. We will run it anyhow, though, - ** to guard against future changes to the code generator. - **/ - Debug.Assert(pC.deferredMoveto == false); - rc = sqlite3VdbeCursorMoveto(pC); - if (NEVER(rc != SQLITE_OK)) - goto abort_due_to_error; - sqlite3BtreeSetCachedRowid(pC.pCursor, 0); - rc = sqlite3BtreeDelete(pC.pCursor); - pC.cacheStatus = CACHE_STALE; - - /* Invoke the update-hook if required. */ - if (rc == SQLITE_OK && db.xUpdateCallback != null && pOp.p4.z != null) { - string zDb = db.aDb[pC.iDb].zName; - string zTbl = pOp.p4.z; - db.xUpdateCallback(db.pUpdateArg, SQLITE_DELETE, zDb, zTbl, iKey); - Debug.Assert(pC.iDb >= 0); - } - if ((pOp.p2 & OPFLAG_NCHANGE) != 0) - p.nChange++; - break; - } + /* Opcode: Delete P1 P2 * P4 * + ** + ** Delete the record at which the P1 cursor is currently pointing. + ** + ** The cursor will be left pointing at either the next or the previous + ** record in the table. If it is left pointing at the next record, then + ** the next Next instruction will be a no-op. Hence it is OK to delete + ** a record from within an Next loop. + ** + ** If the OPFLAG_NCHANGE flag of P2 is set, then the row change count is + ** incremented (otherwise not). + ** + ** P1 must not be pseudo-table. It has to be a real table with + ** multiple rows. + ** + ** If P4 is not NULL, then it is the name of the table that P1 is + ** pointing to. The update hook will be invoked, if it exists. + ** If P4 is not NULL then the P1 cursor must have been positioned + ** using OP_NotFound prior to invoking this opcode. + */ + case OP_Delete: + { + i64 iKey; + VdbeCursor pC; + + iKey = 0; + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); + pC = p.apCsr[pOp.p1]; + Debug.Assert( pC != null ); + Debug.Assert( pC.pCursor != null ); /* Only valid for real tables, no pseudotables */ + + /* If the update-hook will be invoked, set iKey to the rowid of the + ** row being deleted. + */ + if ( db.xUpdateCallback != null && pOp.p4.z != null ) + { + Debug.Assert( pC.isTable ); + Debug.Assert( pC.rowidIsValid ); /* lastRowid set by previous OP_NotFound */ + iKey = pC.lastRowid; + } + + /* The OP_Delete opcode always follows an OP_NotExists or OP_Last or + ** OP_Column on the same table without any intervening operations that + ** might move or invalidate the cursor. Hence cursor pC is always pointing + ** to the row to be deleted and the sqlite3VdbeCursorMoveto() operation + ** below is always a no-op and cannot fail. We will run it anyhow, though, + ** to guard against future changes to the code generator. + **/ + Debug.Assert( pC.deferredMoveto == false ); + rc = sqlite3VdbeCursorMoveto( pC ); + if ( NEVER( rc != SQLITE_OK ) ) + goto abort_due_to_error; + sqlite3BtreeSetCachedRowid( pC.pCursor, 0 ); + rc = sqlite3BtreeDelete( pC.pCursor ); + pC.cacheStatus = CACHE_STALE; + + /* Invoke the update-hook if required. */ + if ( rc == SQLITE_OK && db.xUpdateCallback != null && pOp.p4.z != null ) + { + string zDb = db.aDb[pC.iDb].zName; + string zTbl = pOp.p4.z; + db.xUpdateCallback( db.pUpdateArg, SQLITE_DELETE, zDb, zTbl, iKey ); + Debug.Assert( pC.iDb >= 0 ); + } + if ( ( pOp.p2 & OPFLAG_NCHANGE ) != 0 ) + p.nChange++; + break; + } - /* Opcode: ResetCount P1 * * - ** - ** The value of the change counter is copied to the database handle - ** change counter (returned by subsequent calls to sqlite3_changes()). - ** Then the VMs internal change counter resets to 0. - ** This is used by trigger programs. - */ - case OP_ResetCount: { - sqlite3VdbeSetChanges(db, p.nChange); - p.nChange = 0; - break; - } + /* Opcode: ResetCount P1 * * + ** + ** The value of the change counter is copied to the database handle + ** change counter (returned by subsequent calls to sqlite3_changes()). + ** Then the VMs internal change counter resets to 0. + ** This is used by trigger programs. + */ + case OP_ResetCount: + { + sqlite3VdbeSetChanges( db, p.nChange ); + p.nChange = 0; + break; + } - /* Opcode: RowData P1 P2 * * * - ** - ** Write into register P2 the complete row data for cursor P1. - ** There is no interpretation of the data. - ** It is just copied onto the P2 register exactly as - ** it is found in the database file. - ** - ** If the P1 cursor must be pointing to a valid row (not a NULL row) - ** of a real table, not a pseudo-table. - */ - /* Opcode: RowKey P1 P2 * * * - ** - ** Write into register P2 the complete row key for cursor P1. - ** There is no interpretation of the data. - ** The key is copied onto the P3 register exactly as - ** it is found in the database file. - ** - ** If the P1 cursor must be pointing to a valid row (not a NULL row) - ** of a real table, not a pseudo-table. - */ - case OP_RowKey: - case OP_RowData: { - VdbeCursor pC; - BtCursor pCrsr; - u32 n; - i64 n64; - - n = 0; - n64 = 0; - - pOut = aMem[pOp.p2]; - memAboutToChange(p, pOut); - - /* Note that RowKey and RowData are really exactly the same instruction */ - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); - pC = p.apCsr[pOp.p1]; - Debug.Assert(pC.isTable || pOp.opcode == OP_RowKey); - Debug.Assert(pC.isIndex || pOp.opcode == OP_RowData); - Debug.Assert(pC != null); - Debug.Assert(pC.nullRow == false); - Debug.Assert(pC.pseudoTableReg == 0); - Debug.Assert(pC.pCursor != null); - pCrsr = pC.pCursor; - Debug.Assert(sqlite3BtreeCursorIsValid(pCrsr)); - - /* The OP_RowKey and OP_RowData opcodes always follow OP_NotExists or - ** OP_Rewind/Op_Next with no intervening instructions that might invalidate - ** the cursor. Hence the following sqlite3VdbeCursorMoveto() call is always - ** a no-op and can never fail. But we leave it in place as a safety. - */ - Debug.Assert(pC.deferredMoveto == false); - rc = sqlite3VdbeCursorMoveto(pC); - if (NEVER(rc != SQLITE_OK)) - goto abort_due_to_error; - if (pC.isIndex) { - Debug.Assert(!pC.isTable); - rc = sqlite3BtreeKeySize(pCrsr, ref n64); - Debug.Assert(rc == SQLITE_OK); /* True because of CursorMoveto() call above */ - if (n64 > db.aLimit[SQLITE_LIMIT_LENGTH]) { - goto too_big; - } - n = (u32)n64; - } else { - rc = sqlite3BtreeDataSize(pCrsr, ref n); - Debug.Assert(rc == SQLITE_OK); /* DataSize() cannot fail */ - if (n > (u32)db.aLimit[SQLITE_LIMIT_LENGTH]) { - goto too_big; - } - if (sqlite3VdbeMemGrow(pOut, (int)n, 0) != 0) { - goto no_mem; - } - } - pOut.n = (int)n; - if (pC.isIndex) { - pOut.zBLOB = sqlite3Malloc((int)n); - rc = sqlite3BtreeKey(pCrsr, 0, n, pOut.zBLOB); - } else { - pOut.zBLOB = sqlite3Malloc((int)pCrsr.info.nData); - rc = sqlite3BtreeData(pCrsr, 0, (u32)n, pOut.zBLOB); - } - MemSetTypeFlag(pOut, MEM_Blob); - pOut.enc = SQLITE_UTF8; /* In case the blob is ever cast to text */ + /* Opcode: RowData P1 P2 * * * + ** + ** Write into register P2 the complete row data for cursor P1. + ** There is no interpretation of the data. + ** It is just copied onto the P2 register exactly as + ** it is found in the database file. + ** + ** If the P1 cursor must be pointing to a valid row (not a NULL row) + ** of a real table, not a pseudo-table. + */ + /* Opcode: RowKey P1 P2 * * * + ** + ** Write into register P2 the complete row key for cursor P1. + ** There is no interpretation of the data. + ** The key is copied onto the P3 register exactly as + ** it is found in the database file. + ** + ** If the P1 cursor must be pointing to a valid row (not a NULL row) + ** of a real table, not a pseudo-table. + */ + case OP_RowKey: + case OP_RowData: + { + VdbeCursor pC; + BtCursor pCrsr; + u32 n; + i64 n64; + + n = 0; + n64 = 0; + + pOut = aMem[pOp.p2]; + memAboutToChange( p, pOut ); + + /* Note that RowKey and RowData are really exactly the same instruction */ + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); + pC = p.apCsr[pOp.p1]; + Debug.Assert( pC.isTable || pOp.opcode == OP_RowKey ); + Debug.Assert( pC.isIndex || pOp.opcode == OP_RowData ); + Debug.Assert( pC != null ); + Debug.Assert( pC.nullRow == false ); + Debug.Assert( pC.pseudoTableReg == 0 ); + Debug.Assert( pC.pCursor != null ); + pCrsr = pC.pCursor; + Debug.Assert( sqlite3BtreeCursorIsValid( pCrsr ) ); + + /* The OP_RowKey and OP_RowData opcodes always follow OP_NotExists or + ** OP_Rewind/Op_Next with no intervening instructions that might invalidate + ** the cursor. Hence the following sqlite3VdbeCursorMoveto() call is always + ** a no-op and can never fail. But we leave it in place as a safety. + */ + Debug.Assert( pC.deferredMoveto == false ); + rc = sqlite3VdbeCursorMoveto( pC ); + if ( NEVER( rc != SQLITE_OK ) ) + goto abort_due_to_error; + if ( pC.isIndex ) + { + Debug.Assert( !pC.isTable ); + rc = sqlite3BtreeKeySize( pCrsr, ref n64 ); + Debug.Assert( rc == SQLITE_OK ); /* True because of CursorMoveto() call above */ + if ( n64 > db.aLimit[SQLITE_LIMIT_LENGTH] ) + { + goto too_big; + } + n = (u32)n64; + } + else + { + rc = sqlite3BtreeDataSize( pCrsr, ref n ); + Debug.Assert( rc == SQLITE_OK ); /* DataSize() cannot fail */ + if ( n > (u32)db.aLimit[SQLITE_LIMIT_LENGTH] ) + { + goto too_big; + } + if ( sqlite3VdbeMemGrow( pOut, (int)n, 0 ) != 0 ) + { + goto no_mem; + } + } + pOut.n = (int)n; + if ( pC.isIndex ) + { + pOut.zBLOB = sqlite3Malloc( (int)n ); + rc = sqlite3BtreeKey( pCrsr, 0, n, pOut.zBLOB ); + } + else + { + pOut.zBLOB = sqlite3Malloc( (int)pCrsr.info.nData ); + rc = sqlite3BtreeData( pCrsr, 0, (u32)n, pOut.zBLOB ); + } + MemSetTypeFlag( pOut, MEM_Blob ); + pOut.enc = SQLITE_UTF8; /* In case the blob is ever cast to text */ #if SQLITE_TEST UPDATE_MAX_BLOBSIZE( pOut ); #endif - break; - } + break; + } - /* Opcode: Rowid P1 P2 * * * - ** - ** Store in register P2 an integer which is the key of the table entry that - ** P1 is currently point to. - ** - ** P1 can be either an ordinary table or a virtual table. There used to - ** be a separate OP_VRowid opcode for use with virtual tables, but this - ** one opcode now works for both table types. - */ - case OP_Rowid: { /* out2-prerelease */ - VdbeCursor pC; - i64 v; - sqlite3_vtab pVtab; - sqlite3_module pModule; - - v = 0; - - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); - pC = p.apCsr[pOp.p1]; - Debug.Assert(pC != null); - Debug.Assert(pC.pseudoTableReg == 0); - if (pC.nullRow) { - pOut.flags = MEM_Null; - break; - } else if (pC.deferredMoveto) { - v = pC.movetoTarget; + /* Opcode: Rowid P1 P2 * * * + ** + ** Store in register P2 an integer which is the key of the table entry that + ** P1 is currently point to. + ** + ** P1 can be either an ordinary table or a virtual table. There used to + ** be a separate OP_VRowid opcode for use with virtual tables, but this + ** one opcode now works for both table types. + */ + case OP_Rowid: + { /* out2-prerelease */ + VdbeCursor pC; + i64 v; + sqlite3_vtab pVtab; + sqlite3_module pModule; + + v = 0; + + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); + pC = p.apCsr[pOp.p1]; + Debug.Assert( pC != null ); + Debug.Assert( pC.pseudoTableReg == 0 ); + if ( pC.nullRow ) + { + pOut.flags = MEM_Null; + break; + } + else if ( pC.deferredMoveto ) + { + v = pC.movetoTarget; #if !SQLITE_OMIT_VIRTUALTABLE - } else if (pC.pVtabCursor != null) { - pVtab = pC.pVtabCursor.pVtab; - pModule = pVtab.pModule; - Debug.Assert(pModule.xRowid != null); - rc = pModule.xRowid(pC.pVtabCursor, out v); - importVtabErrMsg(p, pVtab); + } + else if ( pC.pVtabCursor!=null ) + { + pVtab = pC.pVtabCursor.pVtab; + pModule = pVtab.pModule; + Debug.Assert( pModule.xRowid != null ); + rc = pModule.xRowid( pC.pVtabCursor, out v ); + importVtabErrMsg( p, pVtab ); #endif //* SQLITE_OMIT_VIRTUALTABLE */ - } else { - Debug.Assert(pC.pCursor != null); - rc = sqlite3VdbeCursorMoveto(pC); - if (rc != 0) - goto abort_due_to_error; - if (pC.rowidIsValid) { - v = pC.lastRowid; - } else { - rc = sqlite3BtreeKeySize(pC.pCursor, ref v); - Debug.Assert(rc == SQLITE_OK); /* Always so because of CursorMoveto() above */ - } - } - pOut.u.i = (long)v; - break; - } + } + else + { + Debug.Assert( pC.pCursor != null ); + rc = sqlite3VdbeCursorMoveto( pC ); + if ( rc != 0 ) + goto abort_due_to_error; + if ( pC.rowidIsValid ) + { + v = pC.lastRowid; + } + else + { + rc = sqlite3BtreeKeySize( pC.pCursor, ref v ); + Debug.Assert( rc == SQLITE_OK ); /* Always so because of CursorMoveto() above */ + } + } + pOut.u.i = (long)v; + break; + } - /* Opcode: NullRow P1 * * * * - ** - ** Move the cursor P1 to a null row. Any OP_Column operations - ** that occur while the cursor is on the null row will always - ** write a NULL. - */ - case OP_NullRow: { - VdbeCursor pC; - - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); - pC = p.apCsr[pOp.p1]; - Debug.Assert(pC != null); - pC.nullRow = true; - pC.rowidIsValid = false; - if (pC.pCursor != null) { - sqlite3BtreeClearCursor(pC.pCursor); - } - break; - } + /* Opcode: NullRow P1 * * * * + ** + ** Move the cursor P1 to a null row. Any OP_Column operations + ** that occur while the cursor is on the null row will always + ** write a NULL. + */ + case OP_NullRow: + { + VdbeCursor pC; + + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); + pC = p.apCsr[pOp.p1]; + Debug.Assert( pC != null ); + pC.nullRow = true; + pC.rowidIsValid = false; + if ( pC.pCursor != null ) + { + sqlite3BtreeClearCursor( pC.pCursor ); + } + break; + } - /* Opcode: Last P1 P2 * * * - ** - ** The next use of the Rowid or Column or Next instruction for P1 - ** will refer to the last entry in the database table or index. - ** If the table or index is empty and P2>0, then jump immediately to P2. - ** If P2 is 0 or if the table or index is not empty, fall through - ** to the following instruction. - */ - case OP_Last: { /* jump */ - VdbeCursor pC; - BtCursor pCrsr; - int res = 0; - - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); - pC = p.apCsr[pOp.p1]; - Debug.Assert(pC != null); - pCrsr = pC.pCursor; - if (pCrsr == null) { - res = 1; - } else { - rc = sqlite3BtreeLast(pCrsr, ref res); - } - pC.nullRow = res == 1 ? true : false; - pC.deferredMoveto = false; - pC.rowidIsValid = false; - pC.cacheStatus = CACHE_STALE; - if (pOp.p2 > 0 && res != 0) { - pc = pOp.p2 - 1; - } - break; - } + /* Opcode: Last P1 P2 * * * + ** + ** The next use of the Rowid or Column or Next instruction for P1 + ** will refer to the last entry in the database table or index. + ** If the table or index is empty and P2>0, then jump immediately to P2. + ** If P2 is 0 or if the table or index is not empty, fall through + ** to the following instruction. + */ + case OP_Last: + { /* jump */ + VdbeCursor pC; + BtCursor pCrsr; + int res = 0; + + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); + pC = p.apCsr[pOp.p1]; + Debug.Assert( pC != null ); + pCrsr = pC.pCursor; + if ( pCrsr == null ) + { + res = 1; + } + else + { + rc = sqlite3BtreeLast( pCrsr, ref res ); + } + pC.nullRow = res == 1 ? true : false; + pC.deferredMoveto = false; + pC.rowidIsValid = false; + pC.cacheStatus = CACHE_STALE; + if ( pOp.p2 > 0 && res != 0 ) + { + pc = pOp.p2 - 1; + } + break; + } - /* Opcode: Sort P1 P2 * * * - ** - ** This opcode does exactly the same thing as OP_Rewind except that - ** it increments an undocumented global variable used for testing. - ** - ** Sorting is accomplished by writing records into a sorting index, - ** then rewinding that index and playing it back from beginning to - ** end. We use the OP_Sort opcode instead of OP_Rewind to do the - ** rewinding so that the global variable will be incremented and - ** regression tests can determine whether or not the optimizer is - ** correctly optimizing out sorts. - */ - case OP_Sort: { /* jump */ + /* Opcode: Sort P1 P2 * * * + ** + ** This opcode does exactly the same thing as OP_Rewind except that + ** it increments an undocumented global variable used for testing. + ** + ** Sorting is accomplished by writing records into a sorting index, + ** then rewinding that index and playing it back from beginning to + ** end. We use the OP_Sort opcode instead of OP_Rewind to do the + ** rewinding so that the global variable will be incremented and + ** regression tests can determine whether or not the optimizer is + ** correctly optimizing out sorts. + */ + case OP_Sort: + { /* jump */ #if SQLITE_TEST #if !TCLSH sqlite3_sort_count++; @@ -4554,95 +5089,102 @@ Vdbe p /* The VDBE */ sqlite3_search_count.iValue--; #endif #endif - p.aCounter[SQLITE_STMTSTATUS_SORT - 1]++; - /* Fall through into OP_Rewind */ - goto case OP_Rewind; - } - /* Opcode: Rewind P1 P2 * * * - ** - ** The next use of the Rowid or Column or Next instruction for P1 - ** will refer to the first entry in the database table or index. - ** If the table or index is empty and P2>0, then jump immediately to P2. - ** If P2 is 0 or if the table or index is not empty, fall through - ** to the following instruction. - */ - case OP_Rewind: { /* jump */ - VdbeCursor pC; - BtCursor pCrsr; - int res = 0; - - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); - pC = p.apCsr[pOp.p1]; - Debug.Assert(pC != null); - res = 1; - if ((pCrsr = pC.pCursor) != null) { - rc = sqlite3BtreeFirst(pCrsr, ref res); - pC.atFirst = res == 0 ? true : false; - pC.deferredMoveto = false; - pC.cacheStatus = CACHE_STALE; - pC.rowidIsValid = false; - } - pC.nullRow = res == 1 ? true : false; - Debug.Assert(pOp.p2 > 0 && pOp.p2 < p.nOp); - if (res != 0) { - pc = pOp.p2 - 1; - } - break; - } + p.aCounter[SQLITE_STMTSTATUS_SORT - 1]++; + /* Fall through into OP_Rewind */ + goto case OP_Rewind; + } + /* Opcode: Rewind P1 P2 * * * + ** + ** The next use of the Rowid or Column or Next instruction for P1 + ** will refer to the first entry in the database table or index. + ** If the table or index is empty and P2>0, then jump immediately to P2. + ** If P2 is 0 or if the table or index is not empty, fall through + ** to the following instruction. + */ + case OP_Rewind: + { /* jump */ + VdbeCursor pC; + BtCursor pCrsr; + int res = 0; + + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); + pC = p.apCsr[pOp.p1]; + Debug.Assert( pC != null ); + res = 1; + if ( ( pCrsr = pC.pCursor ) != null ) + { + rc = sqlite3BtreeFirst( pCrsr, ref res ); + pC.atFirst = res == 0 ? true : false; + pC.deferredMoveto = false; + pC.cacheStatus = CACHE_STALE; + pC.rowidIsValid = false; + } + pC.nullRow = res == 1 ? true : false; + Debug.Assert( pOp.p2 > 0 && pOp.p2 < p.nOp ); + if ( res != 0 ) + { + pc = pOp.p2 - 1; + } + break; + } - /* Opcode: Next P1 P2 * * P5 - ** - ** Advance cursor P1 so that it points to the next key/data pair in its - ** table or index. If there are no more key/value pairs then fall through - ** to the following instruction. But if the cursor advance was successful, - ** jump immediately to P2. - ** - ** The P1 cursor must be for a real table, not a pseudo-table. - ** - ** See also: Prev - */ - /* Opcode: Prev P1 P2 * * * - ** - ** Back up cursor P1 so that it points to the previous key/data pair in its - ** table or index. If there is no previous key/value pairs then fall through - ** to the following instruction. But if the cursor backup was successful, - ** jump immediately to P2. - ** - ** The P1 cursor must be for a real table, not a pseudo-table. - ** - ** If P5 is positive and the jump is taken, then event counter - ** number P5-1 in the prepared statement is incremented. - ** - */ - case OP_Prev: /* jump */ - case OP_Next: { /* jump */ - VdbeCursor pC; - BtCursor pCrsr; - int res; - - if (db.u1.isInterrupted) - goto abort_due_to_interrupt; //CHECK_FOR_INTERRUPT; - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); - Debug.Assert(pOp.p5 <= ArraySize(p.aCounter)); - pC = p.apCsr[pOp.p1]; - if (pC == null) { - break; /* See ticket #2273 */ - } - pCrsr = pC.pCursor; - if (pCrsr == null) { - pC.nullRow = true; - break; - } - res = 1; - Debug.Assert(!pC.deferredMoveto); - rc = pOp.opcode == OP_Next ? sqlite3BtreeNext(pCrsr, ref res) : - sqlite3BtreePrevious(pCrsr, ref res); - pC.nullRow = res == 1 ? true : false; - pC.cacheStatus = CACHE_STALE; - if (res == 0) { - pc = pOp.p2 - 1; - if (pOp.p5 != 0) - p.aCounter[pOp.p5 - 1]++; + /* Opcode: Next P1 P2 * * P5 + ** + ** Advance cursor P1 so that it points to the next key/data pair in its + ** table or index. If there are no more key/value pairs then fall through + ** to the following instruction. But if the cursor advance was successful, + ** jump immediately to P2. + ** + ** The P1 cursor must be for a real table, not a pseudo-table. + ** + ** See also: Prev + */ + /* Opcode: Prev P1 P2 * * * + ** + ** Back up cursor P1 so that it points to the previous key/data pair in its + ** table or index. If there is no previous key/value pairs then fall through + ** to the following instruction. But if the cursor backup was successful, + ** jump immediately to P2. + ** + ** The P1 cursor must be for a real table, not a pseudo-table. + ** + ** If P5 is positive and the jump is taken, then event counter + ** number P5-1 in the prepared statement is incremented. + ** + */ + case OP_Prev: /* jump */ + case OP_Next: + { /* jump */ + VdbeCursor pC; + BtCursor pCrsr; + int res; + + if ( db.u1.isInterrupted ) + goto abort_due_to_interrupt; //CHECK_FOR_INTERRUPT; + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); + Debug.Assert( pOp.p5 <= ArraySize( p.aCounter ) ); + pC = p.apCsr[pOp.p1]; + if ( pC == null ) + { + break; /* See ticket #2273 */ + } + pCrsr = pC.pCursor; + if ( pCrsr == null ) + { + pC.nullRow = true; + break; + } + res = 1; + Debug.Assert( !pC.deferredMoveto ); + rc = pOp.opcode == OP_Next ? sqlite3BtreeNext( pCrsr, ref res ) : + sqlite3BtreePrevious( pCrsr, ref res ); + pC.nullRow = res == 1 ? true : false; + pC.cacheStatus = CACHE_STALE; + if ( res == 0 ) + { + pc = pOp.p2 - 1; + if ( pOp.p5 != 0 ) + p.aCounter[pOp.p5 - 1]++; #if SQLITE_TEST #if !TCLSH sqlite3_search_count++; @@ -4650,979 +5192,1074 @@ Vdbe p /* The VDBE */ sqlite3_search_count.iValue++; #endif #endif - } - pC.rowidIsValid = false; - break; - } + } + pC.rowidIsValid = false; + break; + } - /* Opcode: IdxInsert P1 P2 P3 * P5 - ** - ** Register P2 holds an SQL index key made using the - ** MakeRecord instructions. This opcode writes that key - ** into the index P1. Data for the entry is nil. - ** - ** P3 is a flag that provides a hint to the b-tree layer that this - ** insert is likely to be an append. - ** - ** This instruction only works for indices. The equivalent instruction - ** for tables is OP_Insert. - */ - case OP_IdxInsert: { /* in2 */ - VdbeCursor pC; - BtCursor pCrsr; - int nKey; - byte[] zKey; - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); - pC = p.apCsr[pOp.p1]; - Debug.Assert(pC != null); - pIn2 = aMem[pOp.p2]; - Debug.Assert((pIn2.flags & MEM_Blob) != 0); - pCrsr = pC.pCursor; - if (ALWAYS(pCrsr != null)) { - Debug.Assert(!pC.isTable); - ExpandBlob(pIn2); - if (rc == SQLITE_OK) { - nKey = pIn2.n; - zKey = (pIn2.flags & MEM_Blob) != 0 ? pIn2.zBLOB : Encoding.UTF8.GetBytes(pIn2.z); - rc = sqlite3BtreeInsert(pCrsr, zKey, nKey, null, 0, 0, (pOp.p3 != 0) ? 1 : 0, - ((pOp.p5 & OPFLAG_USESEEKRESULT) != 0 ? pC.seekResult : 0) - ); - Debug.Assert(!pC.deferredMoveto); - pC.cacheStatus = CACHE_STALE; - } - } - break; - } + /* Opcode: IdxInsert P1 P2 P3 * P5 + ** + ** Register P2 holds an SQL index key made using the + ** MakeRecord instructions. This opcode writes that key + ** into the index P1. Data for the entry is nil. + ** + ** P3 is a flag that provides a hint to the b-tree layer that this + ** insert is likely to be an append. + ** + ** This instruction only works for indices. The equivalent instruction + ** for tables is OP_Insert. + */ + case OP_IdxInsert: + { /* in2 */ + VdbeCursor pC; + BtCursor pCrsr; + int nKey; + byte[] zKey; + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); + pC = p.apCsr[pOp.p1]; + Debug.Assert( pC != null ); + pIn2 = aMem[pOp.p2]; + Debug.Assert( ( pIn2.flags & MEM_Blob ) != 0 ); + pCrsr = pC.pCursor; + if ( ALWAYS( pCrsr != null ) ) + { + Debug.Assert( !pC.isTable ); + ExpandBlob( pIn2 ); + if ( rc == SQLITE_OK ) + { + nKey = pIn2.n; + zKey = ( pIn2.flags & MEM_Blob ) != 0 ? pIn2.zBLOB : Encoding.UTF8.GetBytes( pIn2.z ); + rc = sqlite3BtreeInsert( pCrsr, zKey, nKey, null, 0, 0, ( pOp.p3 != 0 ) ? 1 : 0, + ( ( pOp.p5 & OPFLAG_USESEEKRESULT ) != 0 ? pC.seekResult : 0 ) + ); + Debug.Assert( !pC.deferredMoveto ); + pC.cacheStatus = CACHE_STALE; + } + } + break; + } - /* Opcode: IdxDelete P1 P2 P3 * * - ** - ** The content of P3 registers starting at register P2 form - ** an unpacked index key. This opcode removes that entry from the - ** index opened by cursor P1. - */ - case OP_IdxDelete: { - VdbeCursor pC; - BtCursor pCrsr; - int res; - UnpackedRecord r; - - res = 0; - r = new UnpackedRecord(); - - Debug.Assert(pOp.p3 > 0); - Debug.Assert(pOp.p2 > 0 && pOp.p2 + pOp.p3 <= p.nMem + 1); - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); - pC = p.apCsr[pOp.p1]; - Debug.Assert(pC != null); - pCrsr = pC.pCursor; - if (ALWAYS(pCrsr != null)) { - r.pKeyInfo = pC.pKeyInfo; - r.nField = (u16)pOp.p3; - r.flags = 0; - r.aMem = new Mem[r.nField]; - for (int ra = 0; ra < r.nField; ra++) { - r.aMem[ra] = aMem[pOp.p2 + ra]; + /* Opcode: IdxDelete P1 P2 P3 * * + ** + ** The content of P3 registers starting at register P2 form + ** an unpacked index key. This opcode removes that entry from the + ** index opened by cursor P1. + */ + case OP_IdxDelete: + { + VdbeCursor pC; + BtCursor pCrsr; + int res; + UnpackedRecord r; + + res = 0; + r = new UnpackedRecord(); + + Debug.Assert( pOp.p3 > 0 ); + Debug.Assert( pOp.p2 > 0 && pOp.p2 + pOp.p3 <= p.nMem + 1 ); + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); + pC = p.apCsr[pOp.p1]; + Debug.Assert( pC != null ); + pCrsr = pC.pCursor; + if ( ALWAYS( pCrsr != null ) ) + { + r.pKeyInfo = pC.pKeyInfo; + r.nField = (u16)pOp.p3; + r.flags = 0; + r.aMem = new Mem[r.nField]; + for ( int ra = 0; ra < r.nField; ra++ ) + { + r.aMem[ra] = aMem[pOp.p2 + ra]; #if SQLITE_DEBUG - Debug.Assert(memIsValid(r.aMem[ra])); + Debug.Assert( memIsValid( r.aMem[ra] ) ); #endif - } - rc = sqlite3BtreeMovetoUnpacked(pCrsr, r, 0, 0, ref res); - if (rc == SQLITE_OK && res == 0) { - rc = sqlite3BtreeDelete(pCrsr); - } - Debug.Assert(!pC.deferredMoveto); - pC.cacheStatus = CACHE_STALE; - } - break; - } + } + rc = sqlite3BtreeMovetoUnpacked( pCrsr, r, 0, 0, ref res ); + if ( rc == SQLITE_OK && res == 0 ) + { + rc = sqlite3BtreeDelete( pCrsr ); + } + Debug.Assert( !pC.deferredMoveto ); + pC.cacheStatus = CACHE_STALE; + } + break; + } - /* Opcode: IdxRowid P1 P2 * * * - ** - ** Write into register P2 an integer which is the last entry in the record at - ** the end of the index key pointed to by cursor P1. This integer should be - ** the rowid of the table entry to which this index entry points. - ** - ** See also: Rowid, MakeRecord. - */ - case OP_IdxRowid: { /* out2-prerelease */ - BtCursor pCrsr; - VdbeCursor pC; - i64 rowid; - - rowid = 0; - - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); - pC = p.apCsr[pOp.p1]; - Debug.Assert(pC != null); - pCrsr = pC.pCursor; - pOut.flags = MEM_Null; - if (ALWAYS(pCrsr != null)) { - rc = sqlite3VdbeCursorMoveto(pC); - if (NEVER(rc != 0)) - goto abort_due_to_error; - Debug.Assert(!pC.deferredMoveto); - Debug.Assert(!pC.isTable); - if (!pC.nullRow) { - rc = sqlite3VdbeIdxRowid(db, pCrsr, ref rowid); - if (rc != SQLITE_OK) { - goto abort_due_to_error; - } - pOut.u.i = rowid; - pOut.flags = MEM_Int; - } - } - break; - } + /* Opcode: IdxRowid P1 P2 * * * + ** + ** Write into register P2 an integer which is the last entry in the record at + ** the end of the index key pointed to by cursor P1. This integer should be + ** the rowid of the table entry to which this index entry points. + ** + ** See also: Rowid, MakeRecord. + */ + case OP_IdxRowid: + { /* out2-prerelease */ + BtCursor pCrsr; + VdbeCursor pC; + i64 rowid; + + rowid = 0; + + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); + pC = p.apCsr[pOp.p1]; + Debug.Assert( pC != null ); + pCrsr = pC.pCursor; + pOut.flags = MEM_Null; + if ( ALWAYS( pCrsr != null ) ) + { + rc = sqlite3VdbeCursorMoveto( pC ); + if ( NEVER( rc != 0 ) ) + goto abort_due_to_error; + Debug.Assert( !pC.deferredMoveto ); + Debug.Assert( !pC.isTable ); + if ( !pC.nullRow ) + { + rc = sqlite3VdbeIdxRowid( db, pCrsr, ref rowid ); + if ( rc != SQLITE_OK ) + { + goto abort_due_to_error; + } + pOut.u.i = rowid; + pOut.flags = MEM_Int; + } + } + break; + } - /* Opcode: IdxGE P1 P2 P3 P4 P5 - ** - ** The P4 register values beginning with P3 form an unpacked index - ** key that omits the ROWID. Compare this key value against the index - ** that P1 is currently pointing to, ignoring the ROWID on the P1 index. - ** - ** If the P1 index entry is greater than or equal to the key value - ** then jump to P2. Otherwise fall through to the next instruction. - ** - ** If P5 is non-zero then the key value is increased by an epsilon - ** prior to the comparison. This make the opcode work like IdxGT except - ** that if the key from register P3 is a prefix of the key in the cursor, - ** the result is false whereas it would be true with IdxGT. - */ - /* Opcode: IdxLT P1 P2 P3 P4 P5 - ** - ** The P4 register values beginning with P3 form an unpacked index - ** key that omits the ROWID. Compare this key value against the index - ** that P1 is currently pointing to, ignoring the ROWID on the P1 index. - ** - ** If the P1 index entry is less than the key value then jump to P2. - ** Otherwise fall through to the next instruction. - ** - ** If P5 is non-zero then the key value is increased by an epsilon prior - ** to the comparison. This makes the opcode work like IdxLE. - */ - case OP_IdxLT: /* jump */ - case OP_IdxGE: { /* jump */ - VdbeCursor pC; - int res; - UnpackedRecord r; - - res = 0; - r = new UnpackedRecord(); - - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < p.nCursor); - pC = p.apCsr[pOp.p1]; - Debug.Assert(pC != null); - Debug.Assert(pC.isOrdered); - if (ALWAYS(pC.pCursor != null)) { - Debug.Assert(pC.deferredMoveto == false); - Debug.Assert(pOp.p5 == 0 || pOp.p5 == 1); - Debug.Assert(pOp.p4type == P4_INT32); - r.pKeyInfo = pC.pKeyInfo; - r.nField = (u16)pOp.p4.i; - if (pOp.p5 != 0) { - r.flags = UNPACKED_INCRKEY | UNPACKED_IGNORE_ROWID; - } else { - r.flags = UNPACKED_IGNORE_ROWID; - } - r.aMem = new Mem[r.nField]; - for (int rI = 0; rI < r.nField; rI++) { - r.aMem[rI] = aMem[pOp.p3 + rI];// r.aMem = aMem[pOp.p3]; + /* Opcode: IdxGE P1 P2 P3 P4 P5 + ** + ** The P4 register values beginning with P3 form an unpacked index + ** key that omits the ROWID. Compare this key value against the index + ** that P1 is currently pointing to, ignoring the ROWID on the P1 index. + ** + ** If the P1 index entry is greater than or equal to the key value + ** then jump to P2. Otherwise fall through to the next instruction. + ** + ** If P5 is non-zero then the key value is increased by an epsilon + ** prior to the comparison. This make the opcode work like IdxGT except + ** that if the key from register P3 is a prefix of the key in the cursor, + ** the result is false whereas it would be true with IdxGT. + */ + /* Opcode: IdxLT P1 P2 P3 P4 P5 + ** + ** The P4 register values beginning with P3 form an unpacked index + ** key that omits the ROWID. Compare this key value against the index + ** that P1 is currently pointing to, ignoring the ROWID on the P1 index. + ** + ** If the P1 index entry is less than the key value then jump to P2. + ** Otherwise fall through to the next instruction. + ** + ** If P5 is non-zero then the key value is increased by an epsilon prior + ** to the comparison. This makes the opcode work like IdxLE. + */ + case OP_IdxLT: /* jump */ + case OP_IdxGE: + { /* jump */ + VdbeCursor pC; + int res; + UnpackedRecord r; + + res = 0; + r = new UnpackedRecord(); + + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < p.nCursor ); + pC = p.apCsr[pOp.p1]; + Debug.Assert( pC != null ); + Debug.Assert( pC.isOrdered ); + if ( ALWAYS( pC.pCursor != null ) ) + { + Debug.Assert( pC.deferredMoveto == false ); + Debug.Assert( pOp.p5 == 0 || pOp.p5 == 1 ); + Debug.Assert( pOp.p4type == P4_INT32 ); + r.pKeyInfo = pC.pKeyInfo; + r.nField = (u16)pOp.p4.i; + if ( pOp.p5 != 0 ) + { + r.flags = UNPACKED_INCRKEY | UNPACKED_IGNORE_ROWID; + } + else + { + r.flags = UNPACKED_IGNORE_ROWID; + } + r.aMem = new Mem[r.nField]; + for ( int rI = 0; rI < r.nField; rI++ ) + { + r.aMem[rI] = aMem[pOp.p3 + rI];// r.aMem = aMem[pOp.p3]; #if SQLITE_DEBUG - Debug.Assert(memIsValid(r.aMem[rI])); + Debug.Assert( memIsValid( r.aMem[rI] ) ); #endif - } - rc = sqlite3VdbeIdxKeyCompare(pC, r, ref res); - if (pOp.opcode == OP_IdxLT) { - res = -res; - } else { - Debug.Assert(pOp.opcode == OP_IdxGE); - res++; - } - if (res > 0) { - pc = pOp.p2 - 1; - } - } - break; - } + } + rc = sqlite3VdbeIdxKeyCompare( pC, r, ref res ); + if ( pOp.opcode == OP_IdxLT ) + { + res = -res; + } + else + { + Debug.Assert( pOp.opcode == OP_IdxGE ); + res++; + } + if ( res > 0 ) + { + pc = pOp.p2 - 1; + } + } + break; + } - /* Opcode: Destroy P1 P2 P3 * * - ** - ** Delete an entire database table or index whose root page in the database - ** file is given by P1. - ** - ** The table being destroyed is in the main database file if P3==0. If - ** P3==1 then the table to be clear is in the auxiliary database file - ** that is used to store tables create using CREATE TEMPORARY TABLE. - ** - ** If AUTOVACUUM is enabled then it is possible that another root page - ** might be moved into the newly deleted root page in order to keep all - ** root pages contiguous at the beginning of the database. The former - ** value of the root page that moved - its value before the move occurred - - ** is stored in register P2. If no page - ** movement was required (because the table being dropped was already - ** the last one in the database) then a zero is stored in register P2. - ** If AUTOVACUUM is disabled then a zero is stored in register P2. - ** - ** See also: Clear - */ - case OP_Destroy: { /* out2-prerelease */ - int iMoved = 0; - int iCnt; - Vdbe pVdbe; - int iDb; + /* Opcode: Destroy P1 P2 P3 * * + ** + ** Delete an entire database table or index whose root page in the database + ** file is given by P1. + ** + ** The table being destroyed is in the main database file if P3==0. If + ** P3==1 then the table to be clear is in the auxiliary database file + ** that is used to store tables create using CREATE TEMPORARY TABLE. + ** + ** If AUTOVACUUM is enabled then it is possible that another root page + ** might be moved into the newly deleted root page in order to keep all + ** root pages contiguous at the beginning of the database. The former + ** value of the root page that moved - its value before the move occurred - + ** is stored in register P2. If no page + ** movement was required (because the table being dropped was already + ** the last one in the database) then a zero is stored in register P2. + ** If AUTOVACUUM is disabled then a zero is stored in register P2. + ** + ** See also: Clear + */ + case OP_Destroy: + { /* out2-prerelease */ + int iMoved = 0; + int iCnt; + Vdbe pVdbe; + int iDb; #if !SQLITE_OMIT_VIRTUALTABLE - iCnt = 0; - for (pVdbe = db.pVdbe; pVdbe != null; pVdbe = pVdbe.pNext) { - if (pVdbe.magic == VDBE_MAGIC_RUN && pVdbe.inVtabMethod < 2 && pVdbe.pc >= 0) { - iCnt++; - } - } + iCnt = 0; + for ( pVdbe = db.pVdbe; pVdbe != null; pVdbe = pVdbe.pNext ) + { + if ( pVdbe.magic == VDBE_MAGIC_RUN && pVdbe.inVtabMethod < 2 && pVdbe.pc >= 0 ) + { + iCnt++; + } + } #else iCnt = db.activeVdbeCnt; #endif - pOut.flags = MEM_Null; - if (iCnt > 1) { - rc = SQLITE_LOCKED; - p.errorAction = OE_Abort; - } else { - iDb = pOp.p3; - Debug.Assert(iCnt == 1); - Debug.Assert((p.btreeMask & (((yDbMask)1) << iDb)) != 0); - rc = sqlite3BtreeDropTable(db.aDb[iDb].pBt, pOp.p1, ref iMoved); - pOut.flags = MEM_Int; - pOut.u.i = iMoved; + pOut.flags = MEM_Null; + if ( iCnt > 1 ) + { + rc = SQLITE_LOCKED; + p.errorAction = OE_Abort; + } + else + { + iDb = pOp.p3; + Debug.Assert( iCnt == 1 ); + Debug.Assert( ( p.btreeMask & ( ( (yDbMask)1 ) << iDb ) ) != 0 ); + rc = sqlite3BtreeDropTable( db.aDb[iDb].pBt, pOp.p1, ref iMoved ); + pOut.flags = MEM_Int; + pOut.u.i = iMoved; #if !SQLITE_OMIT_AUTOVACUUM - if (rc == SQLITE_OK && iMoved != 0) { - sqlite3RootPageMoved(db, iDb, iMoved, pOp.p1); - /* All OP_Destroy operations occur on the same btree */ - Debug.Assert(resetSchemaOnFault == 0 || resetSchemaOnFault == iDb + 1); - resetSchemaOnFault = (u8)(iDb + 1); - } + if ( rc == SQLITE_OK && iMoved != 0 ) + { + sqlite3RootPageMoved( db, iDb, iMoved, pOp.p1 ); + /* All OP_Destroy operations occur on the same btree */ + Debug.Assert( resetSchemaOnFault == 0 || resetSchemaOnFault == iDb + 1 ); + resetSchemaOnFault = (u8)( iDb + 1 ); + } #endif - } - break; - } + } + break; + } - /* Opcode: Clear P1 P2 P3 - ** - ** Delete all contents of the database table or index whose root page - ** in the database file is given by P1. But, unlike Destroy, do not - ** remove the table or index from the database file. - ** - ** The table being clear is in the main database file if P2==0. If - ** P2==1 then the table to be clear is in the auxiliary database file - ** that is used to store tables create using CREATE TEMPORARY TABLE. - ** - ** If the P3 value is non-zero, then the table referred to must be an - ** intkey table (an SQL table, not an index). In this case the row change - ** count is incremented by the number of rows in the table being cleared. - ** If P3 is greater than zero, then the value stored in register P3 is - ** also incremented by the number of rows in the table being cleared. - ** - ** See also: Destroy - */ - case OP_Clear: { - int nChange; - - nChange = 0; - Debug.Assert((p.btreeMask & (((yDbMask)1) << pOp.p2)) != 0); - int iDummy0 = 0; - if (pOp.p3 != 0) - rc = sqlite3BtreeClearTable(db.aDb[pOp.p2].pBt, pOp.p1, ref nChange); - else - rc = sqlite3BtreeClearTable(db.aDb[pOp.p2].pBt, pOp.p1, ref iDummy0); - if (pOp.p3 != 0) { - p.nChange += nChange; - if (pOp.p3 > 0) { - Debug.Assert(memIsValid(aMem[pOp.p3])); - memAboutToChange(p, aMem[pOp.p3]); - aMem[pOp.p3].u.i += nChange; - } - } - break; - } + /* Opcode: Clear P1 P2 P3 + ** + ** Delete all contents of the database table or index whose root page + ** in the database file is given by P1. But, unlike Destroy, do not + ** remove the table or index from the database file. + ** + ** The table being clear is in the main database file if P2==0. If + ** P2==1 then the table to be clear is in the auxiliary database file + ** that is used to store tables create using CREATE TEMPORARY TABLE. + ** + ** If the P3 value is non-zero, then the table referred to must be an + ** intkey table (an SQL table, not an index). In this case the row change + ** count is incremented by the number of rows in the table being cleared. + ** If P3 is greater than zero, then the value stored in register P3 is + ** also incremented by the number of rows in the table being cleared. + ** + ** See also: Destroy + */ + case OP_Clear: + { + int nChange; + + nChange = 0; + Debug.Assert( ( p.btreeMask & ( ( (yDbMask)1 ) << pOp.p2 ) ) != 0 ); + int iDummy0 = 0; + if ( pOp.p3 != 0 ) + rc = sqlite3BtreeClearTable( db.aDb[pOp.p2].pBt, pOp.p1, ref nChange ); + else + rc = sqlite3BtreeClearTable( db.aDb[pOp.p2].pBt, pOp.p1, ref iDummy0 ); + if ( pOp.p3 != 0 ) + { + p.nChange += nChange; + if ( pOp.p3 > 0 ) + { + Debug.Assert( memIsValid( aMem[pOp.p3] ) ); + memAboutToChange( p, aMem[pOp.p3] ); + aMem[pOp.p3].u.i += nChange; + } + } + break; + } - /* Opcode: CreateTable P1 P2 * * * - ** - ** Allocate a new table in the main database file if P1==0 or in the - ** auxiliary database file if P1==1 or in an attached database if - ** P1>1. Write the root page number of the new table into - ** register P2 - ** - ** The difference between a table and an index is this: A table must - ** have a 4-byte integer key and can have arbitrary data. An index - ** has an arbitrary key but no data. - ** - ** See also: CreateIndex - */ - /* Opcode: CreateIndex P1 P2 * * * - ** - ** Allocate a new index in the main database file if P1==0 or in the - ** auxiliary database file if P1==1 or in an attached database if - ** P1>1. Write the root page number of the new table into - ** register P2. - ** - ** See documentation on OP_CreateTable for additional information. - */ - case OP_CreateIndex: /* out2-prerelease */ - case OP_CreateTable: { /* out2-prerelease */ - int pgno; - int flags; - Db pDb; - - pgno = 0; - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < db.nDb); - Debug.Assert((p.btreeMask & (((yDbMask)1) << pOp.p1)) != 0); - pDb = db.aDb[pOp.p1]; - Debug.Assert(pDb.pBt != null); - if (pOp.opcode == OP_CreateTable) { - /* flags = BTREE_INTKEY; */ - flags = BTREE_INTKEY; - } else { - flags = BTREE_BLOBKEY; - } - rc = sqlite3BtreeCreateTable(pDb.pBt, ref pgno, flags); - pOut.u.i = pgno; - break; - } + /* Opcode: CreateTable P1 P2 * * * + ** + ** Allocate a new table in the main database file if P1==0 or in the + ** auxiliary database file if P1==1 or in an attached database if + ** P1>1. Write the root page number of the new table into + ** register P2 + ** + ** The difference between a table and an index is this: A table must + ** have a 4-byte integer key and can have arbitrary data. An index + ** has an arbitrary key but no data. + ** + ** See also: CreateIndex + */ + /* Opcode: CreateIndex P1 P2 * * * + ** + ** Allocate a new index in the main database file if P1==0 or in the + ** auxiliary database file if P1==1 or in an attached database if + ** P1>1. Write the root page number of the new table into + ** register P2. + ** + ** See documentation on OP_CreateTable for additional information. + */ + case OP_CreateIndex: /* out2-prerelease */ + case OP_CreateTable: + { /* out2-prerelease */ + int pgno; + int flags; + Db pDb; + + pgno = 0; + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < db.nDb ); + Debug.Assert( ( p.btreeMask & ( ( (yDbMask)1 ) << pOp.p1 ) ) != 0 ); + pDb = db.aDb[pOp.p1]; + Debug.Assert( pDb.pBt != null ); + if ( pOp.opcode == OP_CreateTable ) + { + /* flags = BTREE_INTKEY; */ + flags = BTREE_INTKEY; + } + else + { + flags = BTREE_BLOBKEY; + } + rc = sqlite3BtreeCreateTable( pDb.pBt, ref pgno, flags ); + pOut.u.i = pgno; + break; + } - /* Opcode: ParseSchema P1 * * P4 * - ** - ** Read and parse all entries from the SQLITE_MASTER table of database P1 - ** that match the WHERE clause P4. - ** - ** This opcode invokes the parser to create a new virtual machine, - ** then runs the new virtual machine. It is thus a re-entrant opcode. - */ - case OP_ParseSchema: { - int iDb; - string zMaster; - string zSql; - InitData initData; - - /* Any prepared statement that invokes this opcode will hold mutexes - ** on every btree. This is a prerequisite for invoking - ** sqlite3InitCallback(). - */ + /* Opcode: ParseSchema P1 * * P4 * + ** + ** Read and parse all entries from the SQLITE_MASTER table of database P1 + ** that match the WHERE clause P4. + ** + ** This opcode invokes the parser to create a new virtual machine, + ** then runs the new virtual machine. It is thus a re-entrant opcode. + */ + case OP_ParseSchema: + { + int iDb; + string zMaster; + string zSql; + InitData initData; + + /* Any prepared statement that invokes this opcode will hold mutexes + ** on every btree. This is a prerequisite for invoking + ** sqlite3InitCallback(). + */ #if SQLITE_DEBUG - for (iDb = 0; iDb < db.nDb; iDb++) { - Debug.Assert(iDb == 1 || sqlite3BtreeHoldsMutex(db.aDb[iDb].pBt)); - } + for ( iDb = 0; iDb < db.nDb; iDb++ ) + { + Debug.Assert( iDb == 1 || sqlite3BtreeHoldsMutex( db.aDb[iDb].pBt ) ); + } #endif - iDb = pOp.p1; - Debug.Assert(iDb >= 0 && iDb < db.nDb); - Debug.Assert(DbHasProperty(db, iDb, DB_SchemaLoaded)); - /* Used to be a conditional */ - { - zMaster = SCHEMA_TABLE(iDb); - initData = new InitData(); - initData.db = db; - initData.iDb = pOp.p1; - initData.pzErrMsg = p.zErrMsg; - zSql = sqlite3MPrintf(db, - "SELECT name, rootpage, sql FROM '%q'.%s WHERE %s ORDER BY rowid", - db.aDb[iDb].zName, zMaster, pOp.p4.z); - if (String.IsNullOrEmpty(zSql)) { - rc = SQLITE_NOMEM; - } else { - Debug.Assert(0 == db.init.busy); - db.init.busy = 1; - initData.rc = SQLITE_OK; - //Debug.Assert( 0 == db.mallocFailed ); - rc = sqlite3_exec(db, zSql, (dxCallback)sqlite3InitCallback, (object)initData, 0); - if (rc == SQLITE_OK) - rc = initData.rc; - sqlite3DbFree(db, ref zSql); - db.init.busy = 0; - } - } - if (rc == SQLITE_NOMEM) { - goto no_mem; - } - break; - } + iDb = pOp.p1; + Debug.Assert( iDb >= 0 && iDb < db.nDb ); + Debug.Assert( DbHasProperty( db, iDb, DB_SchemaLoaded ) ); + /* Used to be a conditional */ + { + zMaster = SCHEMA_TABLE( iDb ); + initData = new InitData(); + initData.db = db; + initData.iDb = pOp.p1; + initData.pzErrMsg = p.zErrMsg; + zSql = sqlite3MPrintf( db, + "SELECT name, rootpage, sql FROM '%q'.%s WHERE %s ORDER BY rowid", + db.aDb[iDb].zName, zMaster, pOp.p4.z ); + if ( String.IsNullOrEmpty( zSql ) ) + { + rc = SQLITE_NOMEM; + } + else + { + Debug.Assert( 0 == db.init.busy ); + db.init.busy = 1; + initData.rc = SQLITE_OK; + //Debug.Assert( 0 == db.mallocFailed ); + rc = sqlite3_exec( db, zSql, (dxCallback)sqlite3InitCallback, (object)initData, 0 ); + if ( rc == SQLITE_OK ) + rc = initData.rc; + sqlite3DbFree( db, ref zSql ); + db.init.busy = 0; + } + } + if ( rc == SQLITE_NOMEM ) + { + goto no_mem; + } + break; + } -#if !SQLITE_OMIT_ANALYZE - /* Opcode: LoadAnalysis P1 * * * * - ** - ** Read the sqlite_stat1 table for database P1 and load the content - ** of that table into the internal index hash table. This will cause - ** the analysis to be used when preparing all subsequent queries. - */ - case OP_LoadAnalysis: { - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < db.nDb); - rc = sqlite3AnalysisLoad(db, pOp.p1); - break; - } +#if !SQLITE_OMIT_ANALYZE + /* Opcode: LoadAnalysis P1 * * * * +** +** Read the sqlite_stat1 table for database P1 and load the content +** of that table into the internal index hash table. This will cause +** the analysis to be used when preparing all subsequent queries. +*/ + case OP_LoadAnalysis: + { + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < db.nDb ); + rc = sqlite3AnalysisLoad( db, pOp.p1 ); + break; + } #endif // * !SQLITE_OMIT_ANALYZE) */ - /* Opcode: DropTable P1 * * P4 * + /* Opcode: DropTable P1 * * P4 * +** +** Remove the internal (in-memory) data structures that describe +** the table named P4 in database P1. This is called after a table +** is dropped in order to keep the internal representation of the +** schema consistent with what is on disk. +*/ + case OP_DropTable: + { + sqlite3UnlinkAndDeleteTable( db, pOp.p1, pOp.p4.z ); + break; + } + + /* Opcode: DropIndex P1 * * P4 * ** ** Remove the internal (in-memory) data structures that describe - ** the table named P4 in database P1. This is called after a table + ** the index named P4 in database P1. This is called after an index ** is dropped in order to keep the internal representation of the ** schema consistent with what is on disk. */ - case OP_DropTable: { - sqlite3UnlinkAndDeleteTable(db, pOp.p1, pOp.p4.z); - break; - } - - /* Opcode: DropIndex P1 * * P4 * - ** - ** Remove the internal (in-memory) data structures that describe - ** the index named P4 in database P1. This is called after an index - ** is dropped in order to keep the internal representation of the - ** schema consistent with what is on disk. - */ - case OP_DropIndex: { - sqlite3UnlinkAndDeleteIndex(db, pOp.p1, pOp.p4.z); - break; - } + case OP_DropIndex: + { + sqlite3UnlinkAndDeleteIndex( db, pOp.p1, pOp.p4.z ); + break; + } - /* Opcode: DropTrigger P1 * * P4 * - ** - ** Remove the internal (in-memory) data structures that describe - ** the trigger named P4 in database P1. This is called after a trigger - ** is dropped in order to keep the internal representation of the - ** schema consistent with what is on disk. - */ - case OP_DropTrigger: { - sqlite3UnlinkAndDeleteTrigger(db, pOp.p1, pOp.p4.z); - break; - } + /* Opcode: DropTrigger P1 * * P4 * + ** + ** Remove the internal (in-memory) data structures that describe + ** the trigger named P4 in database P1. This is called after a trigger + ** is dropped in order to keep the internal representation of the + ** schema consistent with what is on disk. + */ + case OP_DropTrigger: + { + sqlite3UnlinkAndDeleteTrigger( db, pOp.p1, pOp.p4.z ); + break; + } #if !SQLITE_OMIT_INTEGRITY_CHECK - /* Opcode: IntegrityCk P1 P2 P3 * P5 - ** - ** Do an analysis of the currently open database. Store in - ** register P1 the text of an error message describing any problems. - ** If no problems are found, store a NULL in register P1. - ** - ** The register P3 contains the maximum number of allowed errors. - ** At most reg(P3) errors will be reported. - ** In other words, the analysis stops as soon as reg(P1) errors are - ** seen. Reg(P1) is updated with the number of errors remaining. - ** - ** The root page numbers of all tables in the database are integer - ** stored in reg(P1), reg(P1+1), reg(P1+2), .... There are P2 tables - ** total. - ** - ** If P5 is not zero, the check is done on the auxiliary database - ** file, not the main database file. - ** - ** This opcode is used to implement the integrity_check pragma. - */ - case OP_IntegrityCk: { - int nRoot; /* Number of tables to check. (Number of root pages.) */ - int[] aRoot = null; /* Array of rootpage numbers for tables to be checked */ - int j; /* Loop counter */ - int nErr = 0; /* Number of errors reported */ - string z; /* Text of the error report */ - Mem pnErr; /* Register keeping track of errors remaining */ - - nRoot = pOp.p2; - Debug.Assert(nRoot > 0); - aRoot = sqlite3Malloc(aRoot, (nRoot + 1));// sqlite3DbMallocRaw(db, sizeof(int) * (nRoot + 1)); - if (aRoot == null) - goto no_mem; - Debug.Assert(pOp.p3 > 0 && pOp.p3 <= p.nMem); - pnErr = aMem[pOp.p3]; - Debug.Assert((pnErr.flags & MEM_Int) != 0); - Debug.Assert((pnErr.flags & (MEM_Str | MEM_Blob)) == 0); - pIn1 = aMem[pOp.p1]; - for (j = 0; j < nRoot; j++) { - aRoot[j] = (int)sqlite3VdbeIntValue(p.aMem[pOp.p1 + j]); // pIn1[j]); - } - aRoot[j] = 0; - Debug.Assert(pOp.p5 < db.nDb); - Debug.Assert((p.btreeMask & (((yDbMask)1) << pOp.p5)) != 0); - z = sqlite3BtreeIntegrityCheck(db.aDb[pOp.p5].pBt, aRoot, nRoot, - (int)pnErr.u.i, ref nErr); - sqlite3DbFree(db, ref aRoot); - pnErr.u.i -= nErr; - sqlite3VdbeMemSetNull(pIn1); - if (nErr == 0) { - Debug.Assert(z == ""); - } else if (String.IsNullOrEmpty(z)) { - goto no_mem; - } else { - sqlite3VdbeMemSetStr(pIn1, z, -1, SQLITE_UTF8, null); //sqlite3_free ); - } + /* Opcode: IntegrityCk P1 P2 P3 * P5 +** +** Do an analysis of the currently open database. Store in +** register P1 the text of an error message describing any problems. +** If no problems are found, store a NULL in register P1. +** +** The register P3 contains the maximum number of allowed errors. +** At most reg(P3) errors will be reported. +** In other words, the analysis stops as soon as reg(P1) errors are +** seen. Reg(P1) is updated with the number of errors remaining. +** +** The root page numbers of all tables in the database are integer +** stored in reg(P1), reg(P1+1), reg(P1+2), .... There are P2 tables +** total. +** +** If P5 is not zero, the check is done on the auxiliary database +** file, not the main database file. +** +** This opcode is used to implement the integrity_check pragma. +*/ + case OP_IntegrityCk: + { + int nRoot; /* Number of tables to check. (Number of root pages.) */ + int[] aRoot = null; /* Array of rootpage numbers for tables to be checked */ + int j; /* Loop counter */ + int nErr = 0; /* Number of errors reported */ + string z; /* Text of the error report */ + Mem pnErr; /* Register keeping track of errors remaining */ + + nRoot = pOp.p2; + Debug.Assert( nRoot > 0 ); + aRoot = sqlite3Malloc( aRoot, ( nRoot + 1 ) );// sqlite3DbMallocRaw(db, sizeof(int) * (nRoot + 1)); + if ( aRoot == null ) + goto no_mem; + Debug.Assert( pOp.p3 > 0 && pOp.p3 <= p.nMem ); + pnErr = aMem[pOp.p3]; + Debug.Assert( ( pnErr.flags & MEM_Int ) != 0 ); + Debug.Assert( ( pnErr.flags & ( MEM_Str | MEM_Blob ) ) == 0 ); + pIn1 = aMem[pOp.p1]; + for ( j = 0; j < nRoot; j++ ) + { + aRoot[j] = (int)sqlite3VdbeIntValue( p.aMem[pOp.p1 + j] ); // pIn1[j]); + } + aRoot[j] = 0; + Debug.Assert( pOp.p5 < db.nDb ); + Debug.Assert( ( p.btreeMask & ( ( (yDbMask)1 ) << pOp.p5 ) ) != 0 ); + z = sqlite3BtreeIntegrityCheck( db.aDb[pOp.p5].pBt, aRoot, nRoot, + (int)pnErr.u.i, ref nErr ); + sqlite3DbFree( db, ref aRoot ); + pnErr.u.i -= nErr; + sqlite3VdbeMemSetNull( pIn1 ); + if ( nErr == 0 ) + { + Debug.Assert( z == "" ); + } + else if ( String.IsNullOrEmpty( z ) ) + { + goto no_mem; + } + else + { + sqlite3VdbeMemSetStr( pIn1, z, -1, SQLITE_UTF8, null ); //sqlite3_free ); + } #if SQLITE_TEST UPDATE_MAX_BLOBSIZE( pIn1 ); #endif - sqlite3VdbeChangeEncoding(pIn1, encoding); - break; - } + sqlite3VdbeChangeEncoding( pIn1, encoding ); + break; + } #endif // * SQLITE_OMIT_INTEGRITY_CHECK */ - /* Opcode: RowSetAdd P1 P2 * * * - ** - ** Insert the integer value held by register P2 into a boolean index - ** held in register P1. + /* Opcode: RowSetAdd P1 P2 * * * +** +** Insert the integer value held by register P2 into a boolean index +** held in register P1. +** +** An assertion fails if P2 is not an integer. +*/ + case OP_RowSetAdd: + { /* in1, in2 */ + pIn1 = aMem[pOp.p1]; + pIn2 = aMem[pOp.p2]; + Debug.Assert( ( pIn2.flags & MEM_Int ) != 0 ); + if ( ( pIn1.flags & MEM_RowSet ) == 0 ) + { + sqlite3VdbeMemSetRowSet( pIn1 ); + if ( ( pIn1.flags & MEM_RowSet ) == 0 ) + goto no_mem; + } + sqlite3RowSetInsert( pIn1.u.pRowSet, pIn2.u.i ); + break; + } + /* Opcode: RowSetRead P1 P2 P3 * * ** - ** An assertion fails if P2 is not an integer. + ** Extract the smallest value from boolean index P1 and put that value into + ** register P3. Or, if boolean index P1 is initially empty, leave P3 + ** unchanged and jump to instruction P2. */ - case OP_RowSetAdd: { /* in1, in2 */ - pIn1 = aMem[pOp.p1]; - pIn2 = aMem[pOp.p2]; - Debug.Assert((pIn2.flags & MEM_Int) != 0); - if ((pIn1.flags & MEM_RowSet) == 0) { - sqlite3VdbeMemSetRowSet(pIn1); - if ((pIn1.flags & MEM_RowSet) == 0) - goto no_mem; - } - sqlite3RowSetInsert(pIn1.u.pRowSet, pIn2.u.i); - break; - } - /* Opcode: RowSetRead P1 P2 P3 * * - ** - ** Extract the smallest value from boolean index P1 and put that value into - ** register P3. Or, if boolean index P1 is initially empty, leave P3 - ** unchanged and jump to instruction P2. - */ - case OP_RowSetRead: { /* jump, in1, ref3 */ - i64 val = 0; - if (db.u1.isInterrupted) - goto abort_due_to_interrupt; //CHECK_FOR_INTERRUPT; - pIn1 = aMem[pOp.p1]; - if ((pIn1.flags & MEM_RowSet) == 0 - || sqlite3RowSetNext(pIn1.u.pRowSet, ref val) == 0 - ) { - /* The boolean index is empty */ - sqlite3VdbeMemSetNull(pIn1); - pc = pOp.p2 - 1; - } else { - /* A value was pulled from the index */ - sqlite3VdbeMemSetInt64(aMem[pOp.p3], val); - } - break; - } + case OP_RowSetRead: + { /* jump, in1, ref3 */ + i64 val = 0; + if ( db.u1.isInterrupted ) + goto abort_due_to_interrupt; //CHECK_FOR_INTERRUPT; + pIn1 = aMem[pOp.p1]; + if ( ( pIn1.flags & MEM_RowSet ) == 0 + || sqlite3RowSetNext( pIn1.u.pRowSet, ref val ) == 0 + ) + { + /* The boolean index is empty */ + sqlite3VdbeMemSetNull( pIn1 ); + pc = pOp.p2 - 1; + } + else + { + /* A value was pulled from the index */ + sqlite3VdbeMemSetInt64( aMem[pOp.p3], val ); + } + break; + } - /* Opcode: RowSetTest P1 P2 P3 P4 - ** - ** Register P3 is assumed to hold a 64-bit integer value. If register P1 - ** contains a RowSet object and that RowSet object contains - ** the value held in P3, jump to register P2. Otherwise, insert the - ** integer in P3 into the RowSet and continue on to the - ** next opcode. - ** - ** The RowSet object is optimized for the case where successive sets - ** of integers, where each set contains no duplicates. Each set - ** of values is identified by a unique P4 value. The first set - ** must have P4==0, the final set P4=-1. P4 must be either -1 or - ** non-negative. For non-negative values of P4 only the lower 4 - ** bits are significant. - ** - ** This allows optimizations: (a) when P4==0 there is no need to test - ** the rowset object for P3, as it is guaranteed not to contain it, - ** (b) when P4==-1 there is no need to insert the value, as it will - ** never be tested for, and (c) when a value that is part of set X is - ** inserted, there is no need to search to see if the same value was - ** previously inserted as part of set X (only if it was previously - ** inserted as part of some other set). - */ - case OP_RowSetTest: { /* jump, in1, in3 */ - int iSet; - int exists; - - pIn1 = aMem[pOp.p1]; - pIn3 = aMem[pOp.p3]; - iSet = pOp.p4.i; - Debug.Assert((pIn3.flags & MEM_Int) != 0); - - /* If there is anything other than a rowset object in memory cell P1, - ** delete it now and initialize P1 with an empty rowset - */ - if ((pIn1.flags & MEM_RowSet) == 0) { - sqlite3VdbeMemSetRowSet(pIn1); - if ((pIn1.flags & MEM_RowSet) == 0) - goto no_mem; - } - - Debug.Assert(pOp.p4type == P4_INT32); - Debug.Assert(iSet == -1 || iSet >= 0); - if (iSet != 0) { - exists = sqlite3RowSetTest(pIn1.u.pRowSet, - (u8)(iSet >= 0 ? iSet & 0xf : 0xff), - pIn3.u.i); - if (exists != 0) { - pc = pOp.p2 - 1; - break; - } - } - if (iSet >= 0) { - sqlite3RowSetInsert(pIn1.u.pRowSet, pIn3.u.i); - } - break; - } + /* Opcode: RowSetTest P1 P2 P3 P4 + ** + ** Register P3 is assumed to hold a 64-bit integer value. If register P1 + ** contains a RowSet object and that RowSet object contains + ** the value held in P3, jump to register P2. Otherwise, insert the + ** integer in P3 into the RowSet and continue on to the + ** next opcode. + ** + ** The RowSet object is optimized for the case where successive sets + ** of integers, where each set contains no duplicates. Each set + ** of values is identified by a unique P4 value. The first set + ** must have P4==0, the final set P4=-1. P4 must be either -1 or + ** non-negative. For non-negative values of P4 only the lower 4 + ** bits are significant. + ** + ** This allows optimizations: (a) when P4==0 there is no need to test + ** the rowset object for P3, as it is guaranteed not to contain it, + ** (b) when P4==-1 there is no need to insert the value, as it will + ** never be tested for, and (c) when a value that is part of set X is + ** inserted, there is no need to search to see if the same value was + ** previously inserted as part of set X (only if it was previously + ** inserted as part of some other set). + */ + case OP_RowSetTest: + { /* jump, in1, in3 */ + int iSet; + int exists; + + pIn1 = aMem[pOp.p1]; + pIn3 = aMem[pOp.p3]; + iSet = pOp.p4.i; + Debug.Assert( ( pIn3.flags & MEM_Int ) != 0 ); + + /* If there is anything other than a rowset object in memory cell P1, + ** delete it now and initialize P1 with an empty rowset + */ + if ( ( pIn1.flags & MEM_RowSet ) == 0 ) + { + sqlite3VdbeMemSetRowSet( pIn1 ); + if ( ( pIn1.flags & MEM_RowSet ) == 0 ) + goto no_mem; + } + + Debug.Assert( pOp.p4type == P4_INT32 ); + Debug.Assert( iSet == -1 || iSet >= 0 ); + if ( iSet != 0 ) + { + exists = sqlite3RowSetTest( pIn1.u.pRowSet, + (u8)( iSet >= 0 ? iSet & 0xf : 0xff ), + pIn3.u.i ); + if ( exists != 0 ) + { + pc = pOp.p2 - 1; + break; + } + } + if ( iSet >= 0 ) + { + sqlite3RowSetInsert( pIn1.u.pRowSet, pIn3.u.i ); + } + break; + } #if !SQLITE_OMIT_TRIGGER - /* Opcode: Program P1 P2 P3 P4 * - ** - ** Execute the trigger program passed as P4 (type P4_SUBPROGRAM). + /* Opcode: Program P1 P2 P3 P4 * +** +** Execute the trigger program passed as P4 (type P4_SUBPROGRAM). +** +** P1 contains the address of the memory cell that contains the first memory +** cell in an array of values used as arguments to the sub-program. P2 +** contains the address to jump to if the sub-program throws an IGNORE +** exception using the RAISE() function. Register P3 contains the address +** of a memory cell in this (the parent) VM that is used to allocate the +** memory required by the sub-vdbe at runtime. +** +** P4 is a pointer to the VM containing the trigger program. +*/ + case OP_Program: + { /* jump */ + int nMem; /* Number of memory registers for sub-program */ + int nByte; /* Bytes of runtime space required for sub-program */ + Mem pRt; /* Register to allocate runtime space */ + Mem pMem = null; /* Used to iterate through memory cells */ + //Mem pEnd; /* Last memory cell in new array */ + VdbeFrame pFrame; /* New vdbe frame to execute in */ + SubProgram pProgram; /* Sub-program to execute */ + int t; /* Token identifying trigger */ + + pProgram = pOp.p4.pProgram; + pRt = aMem[pOp.p3]; + Debug.Assert( memIsValid( pRt ) ); + Debug.Assert( pProgram.nOp > 0 ); + + /* If the p5 flag is clear, then recursive invocation of triggers is + ** disabled for backwards compatibility (p5 is set if this sub-program + ** is really a trigger, not a foreign key action, and the flag set + ** and cleared by the "PRAGMA recursive_triggers" command is clear). + ** + ** It is recursive invocation of triggers, at the SQL level, that is + ** disabled. In some cases a single trigger may generate more than one + ** SubProgram (if the trigger may be executed with more than one different + ** ON CONFLICT algorithm). SubProgram structures associated with a + ** single trigger all have the same value for the SubProgram.token + ** variable. */ + if ( pOp.p5 != 0 ) + { + t = pProgram.token; + for ( pFrame = p.pFrame; pFrame != null && pFrame.token != t; pFrame = pFrame.pParent ) + ; + if ( pFrame != null ) + break; + } + + if ( p.nFrame >= db.aLimit[SQLITE_LIMIT_TRIGGER_DEPTH] ) + { + rc = SQLITE_ERROR; + sqlite3SetString( ref p.zErrMsg, db, "too many levels of trigger recursion" ); + break; + } + + /* Register pRt is used to store the memory required to save the state + ** of the current program, and the memory required at runtime to execute + ** the trigger program. If this trigger has been fired before, then pRt + ** is already allocated. Otherwise, it must be initialized. */ + if ( ( pRt.flags & MEM_Frame ) == 0 ) + { + /* SubProgram.nMem is set to the number of memory cells used by the + ** program stored in SubProgram.aOp. As well as these, one memory + ** cell is required for each cursor used by the program. Set local + ** variable nMem (and later, VdbeFrame.nChildMem) to this value. + */ + nMem = pProgram.nMem + pProgram.nCsr; + //nByte = ROUND8( sizeof( VdbeFrame ) ) + //+ nMem * sizeof( Mem ) + //+ pProgram.nCsr * sizeof( VdbeCursor* ); + pFrame = new VdbeFrame();// sqlite3DbMallocZero( db, nByte ); + //if ( !pFrame ) + //{ + // goto no_mem; + //} + sqlite3VdbeMemRelease( pRt ); + pRt.flags = MEM_Frame; + pRt.u.pFrame = pFrame; + + pFrame.v = p; + pFrame.nChildMem = nMem; + pFrame.nChildCsr = pProgram.nCsr; + pFrame.pc = pc; + pFrame.aMem = p.aMem; + pFrame.nMem = p.nMem; + pFrame.apCsr = p.apCsr; + pFrame.nCursor = p.nCursor; + pFrame.aOp = p.aOp; + pFrame.nOp = p.nOp; + pFrame.token = pProgram.token; + + // &VdbeFrameMem( pFrame )[pFrame.nChildMem]; + // aMem is 1 based, so allocate 1 extra cell under C# + pFrame.aChildMem = new Mem[pFrame.nChildMem + 1]; + for ( int i = 0; i < pFrame.aChildMem.Length; i++ )//pMem = VdbeFrameMem( pFrame ) ; pMem != pEnd ; pMem++ ) + { + //pFrame.aMem[i] = pFrame.aMem[pFrame.nMem+i]; + pMem = sqlite3Malloc( pMem ); + pMem.flags = MEM_Null; + pMem.db = db; + pFrame.aChildMem[i] = pMem; + } + pFrame.aChildCsr = new VdbeCursor[pFrame.nChildCsr]; + for ( int i = 0; i < pFrame.nChildCsr; i++ ) + pFrame.aChildCsr[i] = new VdbeCursor(); + } + else + { + pFrame = pRt.u.pFrame; + Debug.Assert( pProgram.nMem + pProgram.nCsr == pFrame.nChildMem ); + Debug.Assert( pProgram.nCsr == pFrame.nChildCsr ); + Debug.Assert( pc == pFrame.pc ); + } + + p.nFrame++; + pFrame.pParent = p.pFrame; + pFrame.lastRowid = lastRowid; + pFrame.nChange = p.nChange; + p.nChange = 0; + p.pFrame = pFrame; + p.aMem = aMem = pFrame.aChildMem; // &VdbeFrameMem( pFrame )[-1]; + p.nMem = pFrame.nChildMem; + p.nCursor = (u16)pFrame.nChildCsr; + p.apCsr = pFrame.aChildCsr;// (VdbeCursor *)&aMem[p->nMem+1]; + p.aOp = aOp = pProgram.aOp; + p.nOp = pProgram.nOp; + pc = -1; + + break; + } + + /* Opcode: Param P1 P2 * * * ** - ** P1 contains the address of the memory cell that contains the first memory - ** cell in an array of values used as arguments to the sub-program. P2 - ** contains the address to jump to if the sub-program throws an IGNORE - ** exception using the RAISE() function. Register P3 contains the address - ** of a memory cell in this (the parent) VM that is used to allocate the - ** memory required by the sub-vdbe at runtime. + ** This opcode is only ever present in sub-programs called via the + ** OP_Program instruction. Copy a value currently stored in a memory + ** cell of the calling (parent) frame to cell P2 in the current frames + ** address space. This is used by trigger programs to access the new.* + ** and old.* values. ** - ** P4 is a pointer to the VM containing the trigger program. + ** The address of the cell in the parent frame is determined by adding + ** the value of the P1 argument to the value of the P1 argument to the + ** calling OP_Program instruction. */ - case OP_Program: { /* jump */ - int nMem; /* Number of memory registers for sub-program */ - int nByte; /* Bytes of runtime space required for sub-program */ - Mem pRt; /* Register to allocate runtime space */ - Mem pMem = null; /* Used to iterate through memory cells */ - //Mem pEnd; /* Last memory cell in new array */ - VdbeFrame pFrame; /* New vdbe frame to execute in */ - SubProgram pProgram; /* Sub-program to execute */ - int t; /* Token identifying trigger */ - - pProgram = pOp.p4.pProgram; - pRt = aMem[pOp.p3]; - Debug.Assert(memIsValid(pRt)); - Debug.Assert(pProgram.nOp > 0); - - /* If the p5 flag is clear, then recursive invocation of triggers is - ** disabled for backwards compatibility (p5 is set if this sub-program - ** is really a trigger, not a foreign key action, and the flag set - ** and cleared by the "PRAGMA recursive_triggers" command is clear). - ** - ** It is recursive invocation of triggers, at the SQL level, that is - ** disabled. In some cases a single trigger may generate more than one - ** SubProgram (if the trigger may be executed with more than one different - ** ON CONFLICT algorithm). SubProgram structures associated with a - ** single trigger all have the same value for the SubProgram.token - ** variable. */ - if (pOp.p5 != 0) { - t = pProgram.token; - for (pFrame = p.pFrame; pFrame != null && pFrame.token != t; pFrame = pFrame.pParent) - ; - if (pFrame != null) - break; - } - - if (p.nFrame >= db.aLimit[SQLITE_LIMIT_TRIGGER_DEPTH]) { - rc = SQLITE_ERROR; - sqlite3SetString(ref p.zErrMsg, db, "too many levels of trigger recursion"); - break; - } - - /* Register pRt is used to store the memory required to save the state - ** of the current program, and the memory required at runtime to execute - ** the trigger program. If this trigger has been fired before, then pRt - ** is already allocated. Otherwise, it must be initialized. */ - if ((pRt.flags & MEM_Frame) == 0) { - /* SubProgram.nMem is set to the number of memory cells used by the - ** program stored in SubProgram.aOp. As well as these, one memory - ** cell is required for each cursor used by the program. Set local - ** variable nMem (and later, VdbeFrame.nChildMem) to this value. - */ - nMem = pProgram.nMem + pProgram.nCsr; - //nByte = ROUND8( sizeof( VdbeFrame ) ) - //+ nMem * sizeof( Mem ) - //+ pProgram.nCsr * sizeof( VdbeCursor* ); - pFrame = new VdbeFrame();// sqlite3DbMallocZero( db, nByte ); - //if ( !pFrame ) - //{ - // goto no_mem; - //} - sqlite3VdbeMemRelease(pRt); - pRt.flags = MEM_Frame; - pRt.u.pFrame = pFrame; - - pFrame.v = p; - pFrame.nChildMem = nMem; - pFrame.nChildCsr = pProgram.nCsr; - pFrame.pc = pc; - pFrame.aMem = p.aMem; - pFrame.nMem = p.nMem; - pFrame.apCsr = p.apCsr; - pFrame.nCursor = p.nCursor; - pFrame.aOp = p.aOp; - pFrame.nOp = p.nOp; - pFrame.token = pProgram.token; - - // &VdbeFrameMem( pFrame )[pFrame.nChildMem]; - // aMem is 1 based, so allocate 1 extra cell under C# - pFrame.aChildMem = new Mem[pFrame.nChildMem + 1]; - for (int i = 0; i < pFrame.aChildMem.Length; i++)//pMem = VdbeFrameMem( pFrame ) ; pMem != pEnd ; pMem++ ) - { - //pFrame.aMem[i] = pFrame.aMem[pFrame.nMem+i]; - pMem = sqlite3Malloc(pMem); - pMem.flags = MEM_Null; - pMem.db = db; - pFrame.aChildMem[i] = pMem; - } - pFrame.aChildCsr = new VdbeCursor[pFrame.nChildCsr]; - for (int i = 0; i < pFrame.nChildCsr; i++) - pFrame.aChildCsr[i] = new VdbeCursor(); - } else { - pFrame = pRt.u.pFrame; - Debug.Assert(pProgram.nMem + pProgram.nCsr == pFrame.nChildMem); - Debug.Assert(pProgram.nCsr == pFrame.nChildCsr); - Debug.Assert(pc == pFrame.pc); - } - - p.nFrame++; - pFrame.pParent = p.pFrame; - pFrame.lastRowid = lastRowid; - pFrame.nChange = p.nChange; - p.nChange = 0; - p.pFrame = pFrame; - p.aMem = aMem = pFrame.aChildMem; // &VdbeFrameMem( pFrame )[-1]; - p.nMem = pFrame.nChildMem; - p.nCursor = (u16)pFrame.nChildCsr; - p.apCsr = pFrame.aChildCsr;// (VdbeCursor *)&aMem[p->nMem+1]; - p.aOp = aOp = pProgram.aOp; - p.nOp = pProgram.nOp; - pc = -1; - - break; - } - - /* Opcode: Param P1 P2 * * * - ** - ** This opcode is only ever present in sub-programs called via the - ** OP_Program instruction. Copy a value currently stored in a memory - ** cell of the calling (parent) frame to cell P2 in the current frames - ** address space. This is used by trigger programs to access the new.* - ** and old.* values. - ** - ** The address of the cell in the parent frame is determined by adding - ** the value of the P1 argument to the value of the P1 argument to the - ** calling OP_Program instruction. - */ - case OP_Param: { /* out2-prerelease */ - VdbeFrame pFrame; - Mem pIn; - pFrame = p.pFrame; - pIn = pFrame.aMem[pOp.p1 + pFrame.aOp[pFrame.pc].p1]; - sqlite3VdbeMemShallowCopy(pOut, pIn, MEM_Ephem); - break; - } + case OP_Param: + { /* out2-prerelease */ + VdbeFrame pFrame; + Mem pIn; + pFrame = p.pFrame; + pIn = pFrame.aMem[pOp.p1 + pFrame.aOp[pFrame.pc].p1]; + sqlite3VdbeMemShallowCopy( pOut, pIn, MEM_Ephem ); + break; + } #endif // * #if !SQLITE_OMIT_TRIGGER */ #if !SQLITE_OMIT_FOREIGN_KEY - /* Opcode: FkCounter P1 P2 * * * + /* Opcode: FkCounter P1 P2 * * * +** +** Increment a "constraint counter" by P2 (P2 may be negative or positive). +** If P1 is non-zero, the database constraint counter is incremented +** (deferred foreign key constraints). Otherwise, if P1 is zero, the +** statement counter is incremented (immediate foreign key constraints). +*/ + case OP_FkCounter: + { + if ( pOp.p1 != 0 ) + { + db.nDeferredCons += pOp.p2; + } + else + { + p.nFkConstraint += pOp.p2; + } + break; + } + + /* Opcode: FkIfZero P1 P2 * * * ** - ** Increment a "constraint counter" by P2 (P2 may be negative or positive). - ** If P1 is non-zero, the database constraint counter is incremented - ** (deferred foreign key constraints). Otherwise, if P1 is zero, the - ** statement counter is incremented (immediate foreign key constraints). + ** This opcode tests if a foreign key constraint-counter is currently zero. + ** If so, jump to instruction P2. Otherwise, fall through to the next + ** instruction. + ** + ** If P1 is non-zero, then the jump is taken if the database constraint-counter + ** is zero (the one that counts deferred constraint violations). If P1 is + ** zero, the jump is taken if the statement constraint-counter is zero + ** (immediate foreign key constraint violations). */ - case OP_FkCounter: { - if (pOp.p1 != 0) { - db.nDeferredCons += pOp.p2; - } else { - p.nFkConstraint += pOp.p2; - } - break; - } - - /* Opcode: FkIfZero P1 P2 * * * - ** - ** This opcode tests if a foreign key constraint-counter is currently zero. - ** If so, jump to instruction P2. Otherwise, fall through to the next - ** instruction. - ** - ** If P1 is non-zero, then the jump is taken if the database constraint-counter - ** is zero (the one that counts deferred constraint violations). If P1 is - ** zero, the jump is taken if the statement constraint-counter is zero - ** (immediate foreign key constraint violations). - */ - case OP_FkIfZero: { /* jump */ - if (pOp.p1 != 0) { - if (db.nDeferredCons == 0) - pc = pOp.p2 - 1; - } else { - if (p.nFkConstraint == 0) - pc = pOp.p2 - 1; - } - break; - } + case OP_FkIfZero: + { /* jump */ + if ( pOp.p1 != 0 ) + { + if ( db.nDeferredCons == 0 ) + pc = pOp.p2 - 1; + } + else + { + if ( p.nFkConstraint == 0 ) + pc = pOp.p2 - 1; + } + break; + } #endif //* #if !SQLITE_OMIT_FOREIGN_KEY */ #if !SQLITE_OMIT_AUTOINCREMENT - /* Opcode: MemMax P1 P2 * * * - ** - ** P1 is a register in the root frame of this VM (the root frame is - ** different from the current frame if this instruction is being executed - ** within a sub-program). Set the value of register P1 to the maximum of - ** its current value and the value in register P2. - ** - ** This instruction throws an error if the memory cell is not initially - ** an integer. - */ - case OP_MemMax: { /* in2 */ - Mem _pIn1; - VdbeFrame pFrame; - if (p.pFrame != null) { - for (pFrame = p.pFrame; pFrame.pParent != null; pFrame = pFrame.pParent) - ; - _pIn1 = pFrame.aMem[pOp.p1]; - } else { - _pIn1 = aMem[pOp.p1]; - } - Debug.Assert(memIsValid(_pIn1)); - sqlite3VdbeMemIntegerify(_pIn1); - pIn2 = aMem[pOp.p2]; - sqlite3VdbeMemIntegerify(pIn2); - if (_pIn1.u.i < pIn2.u.i) { - _pIn1.u.i = pIn2.u.i; - } - break; - } + /* Opcode: MemMax P1 P2 * * * +** +** P1 is a register in the root frame of this VM (the root frame is +** different from the current frame if this instruction is being executed +** within a sub-program). Set the value of register P1 to the maximum of +** its current value and the value in register P2. +** +** This instruction throws an error if the memory cell is not initially +** an integer. +*/ + case OP_MemMax: + { /* in2 */ + Mem _pIn1; + VdbeFrame pFrame; + if ( p.pFrame != null ) + { + for ( pFrame = p.pFrame; pFrame.pParent != null; pFrame = pFrame.pParent ) + ; + _pIn1 = pFrame.aMem[pOp.p1]; + } + else + { + _pIn1 = aMem[pOp.p1]; + } + Debug.Assert( memIsValid( _pIn1 ) ); + sqlite3VdbeMemIntegerify( _pIn1 ); + pIn2 = aMem[pOp.p2]; + sqlite3VdbeMemIntegerify( pIn2 ); + if ( _pIn1.u.i < pIn2.u.i ) + { + _pIn1.u.i = pIn2.u.i; + } + break; + } #endif // * SQLITE_OMIT_AUTOINCREMENT */ - /* Opcode: IfPos P1 P2 * * * + /* Opcode: IfPos P1 P2 * * * +** +** If the value of register P1 is 1 or greater, jump to P2. +** +** It is illegal to use this instruction on a register that does +** not contain an integer. An Debug.Assertion fault will result if you try. +*/ + case OP_IfPos: + { /* jump, in1 */ + pIn1 = aMem[pOp.p1]; + Debug.Assert( ( pIn1.flags & MEM_Int ) != 0 ); + if ( pIn1.u.i > 0 ) + { + pc = pOp.p2 - 1; + } + break; + } + + /* Opcode: IfNeg P1 P2 * * * ** - ** If the value of register P1 is 1 or greater, jump to P2. + ** If the value of register P1 is less than zero, jump to P2. ** ** It is illegal to use this instruction on a register that does ** not contain an integer. An Debug.Assertion fault will result if you try. */ - case OP_IfPos: { /* jump, in1 */ - pIn1 = aMem[pOp.p1]; - Debug.Assert((pIn1.flags & MEM_Int) != 0); - if (pIn1.u.i > 0) { - pc = pOp.p2 - 1; - } - break; - } - - /* Opcode: IfNeg P1 P2 * * * - ** - ** If the value of register P1 is less than zero, jump to P2. - ** - ** It is illegal to use this instruction on a register that does - ** not contain an integer. An Debug.Assertion fault will result if you try. - */ - case OP_IfNeg: { /* jump, in1 */ - pIn1 = aMem[pOp.p1]; - Debug.Assert((pIn1.flags & MEM_Int) != 0); - if (pIn1.u.i < 0) { - pc = pOp.p2 - 1; - } - break; - } + case OP_IfNeg: + { /* jump, in1 */ + pIn1 = aMem[pOp.p1]; + Debug.Assert( ( pIn1.flags & MEM_Int ) != 0 ); + if ( pIn1.u.i < 0 ) + { + pc = pOp.p2 - 1; + } + break; + } - /* Opcode: IfZero P1 P2 P3 * * - ** - ** The register P1 must contain an integer. Add literal P3 to the - ** value in register P1. If the result is exactly 0, jump to P2. - ** - ** It is illegal to use this instruction on a register that does - ** not contain an integer. An assertion fault will result if you try. - */ - case OP_IfZero: { /* jump, in1 */ - pIn1 = aMem[pOp.p1]; - Debug.Assert((pIn1.flags & MEM_Int) != 0); - pIn1.u.i += pOp.p3; - if (pIn1.u.i == 0) { - pc = pOp.p2 - 1; - } - break; - } + /* Opcode: IfZero P1 P2 P3 * * + ** + ** The register P1 must contain an integer. Add literal P3 to the + ** value in register P1. If the result is exactly 0, jump to P2. + ** + ** It is illegal to use this instruction on a register that does + ** not contain an integer. An assertion fault will result if you try. + */ + case OP_IfZero: + { /* jump, in1 */ + pIn1 = aMem[pOp.p1]; + Debug.Assert( ( pIn1.flags & MEM_Int ) != 0 ); + pIn1.u.i += pOp.p3; + if ( pIn1.u.i == 0 ) + { + pc = pOp.p2 - 1; + } + break; + } - /* Opcode: AggStep * P2 P3 P4 P5 - ** - ** Execute the step function for an aggregate. The - ** function has P5 arguments. P4 is a pointer to the FuncDef - ** structure that specifies the function. Use register - ** P3 as the accumulator. - ** - ** The P5 arguments are taken from register P2 and its - ** successors. - */ - case OP_AggStep: { - int n; - int i; - Mem pMem; - Mem pRec; - sqlite3_context ctx = new sqlite3_context(); - sqlite3_value[] apVal; - - n = pOp.p5; - Debug.Assert(n >= 0); - //pRec = aMem[pOp.p2]; - apVal = p.apArg; - Debug.Assert(apVal != null || n == 0); - for (i = 0; i < n; i++)//, pRec++) - { - pRec = aMem[pOp.p2 + i]; - Debug.Assert(memIsValid(pRec)); - apVal[i] = pRec; - memAboutToChange(p, pRec); - sqlite3VdbeMemStoreType(pRec); - } - ctx.pFunc = pOp.p4.pFunc; - Debug.Assert(pOp.p3 > 0 && pOp.p3 <= p.nMem); - ctx.pMem = pMem = aMem[pOp.p3]; - pMem.n++; - ctx.s.flags = MEM_Null; - ctx.s.z = null; - //ctx.s.zMalloc = null; - ctx.s.xDel = null; - ctx.s.db = db; - ctx.isError = 0; - ctx.pColl = null; - if ((ctx.pFunc.flags & SQLITE_FUNC_NEEDCOLL) != 0) { - Debug.Assert(pc > 0);//pOp > p.aOp ); - Debug.Assert(p.aOp[pc - 1].p4type == P4_COLLSEQ); //pOp[-1].p4type == P4_COLLSEQ ); - Debug.Assert(p.aOp[pc - 1].opcode == OP_CollSeq); // pOp[-1].opcode == OP_CollSeq ); - ctx.pColl = p.aOp[pc - 1].p4.pColl; - ;// pOp[-1].p4.pColl; - } - ctx.pFunc.xStep(ctx, n, apVal); /* IMP: R-24505-23230 */ - if (ctx.isError != 0) { - sqlite3SetString(ref p.zErrMsg, db, sqlite3_value_text(ctx.s)); - rc = ctx.isError; - } - sqlite3VdbeMemRelease(ctx.s); - break; - } + /* Opcode: AggStep * P2 P3 P4 P5 + ** + ** Execute the step function for an aggregate. The + ** function has P5 arguments. P4 is a pointer to the FuncDef + ** structure that specifies the function. Use register + ** P3 as the accumulator. + ** + ** The P5 arguments are taken from register P2 and its + ** successors. + */ + case OP_AggStep: + { + int n; + int i; + Mem pMem; + Mem pRec; + sqlite3_context ctx = new sqlite3_context(); + sqlite3_value[] apVal; + + n = pOp.p5; + Debug.Assert( n >= 0 ); + //pRec = aMem[pOp.p2]; + apVal = p.apArg; + Debug.Assert( apVal != null || n == 0 ); + for ( i = 0; i < n; i++ )//, pRec++) + { + pRec = aMem[pOp.p2 + i]; + Debug.Assert( memIsValid( pRec ) ); + apVal[i] = pRec; + memAboutToChange( p, pRec ); + sqlite3VdbeMemStoreType( pRec ); + } + ctx.pFunc = pOp.p4.pFunc; + Debug.Assert( pOp.p3 > 0 && pOp.p3 <= p.nMem ); + ctx.pMem = pMem = aMem[pOp.p3]; + pMem.n++; + ctx.s.flags = MEM_Null; + ctx.s.z = null; + //ctx.s.zMalloc = null; + ctx.s.xDel = null; + ctx.s.db = db; + ctx.isError = 0; + ctx.pColl = null; + if ( ( ctx.pFunc.flags & SQLITE_FUNC_NEEDCOLL ) != 0 ) + { + Debug.Assert( pc > 0 );//pOp > p.aOp ); + Debug.Assert( p.aOp[pc - 1].p4type == P4_COLLSEQ ); //pOp[-1].p4type == P4_COLLSEQ ); + Debug.Assert( p.aOp[pc - 1].opcode == OP_CollSeq ); // pOp[-1].opcode == OP_CollSeq ); + ctx.pColl = p.aOp[pc - 1].p4.pColl; + ;// pOp[-1].p4.pColl; + } + ctx.pFunc.xStep( ctx, n, apVal ); /* IMP: R-24505-23230 */ + if ( ctx.isError != 0 ) + { + sqlite3SetString( ref p.zErrMsg, db, sqlite3_value_text( ctx.s ) ); + rc = ctx.isError; + } + sqlite3VdbeMemRelease( ctx.s ); + break; + } - /* Opcode: AggFinal P1 P2 * P4 * - ** - ** Execute the finalizer function for an aggregate. P1 is - ** the memory location that is the accumulator for the aggregate. - ** - ** P2 is the number of arguments that the step function takes and - ** P4 is a pointer to the FuncDef for this function. The P2 - ** argument is not used by this opcode. It is only there to disambiguate - ** functions that can take varying numbers of arguments. The - ** P4 argument is only needed for the degenerate case where - ** the step function was not previously called. - */ - case OP_AggFinal: { - Mem pMem; - Debug.Assert(pOp.p1 > 0 && pOp.p1 <= p.nMem); - pMem = aMem[pOp.p1]; - Debug.Assert((pMem.flags & ~(MEM_Null | MEM_Agg)) == 0); - rc = sqlite3VdbeMemFinalize(pMem, pOp.p4.pFunc); - p.aMem[pOp.p1] = pMem; - if (rc != 0) { - sqlite3SetString(ref p.zErrMsg, db, sqlite3_value_text(pMem)); - } - sqlite3VdbeChangeEncoding(pMem, encoding); + /* Opcode: AggFinal P1 P2 * P4 * + ** + ** Execute the finalizer function for an aggregate. P1 is + ** the memory location that is the accumulator for the aggregate. + ** + ** P2 is the number of arguments that the step function takes and + ** P4 is a pointer to the FuncDef for this function. The P2 + ** argument is not used by this opcode. It is only there to disambiguate + ** functions that can take varying numbers of arguments. The + ** P4 argument is only needed for the degenerate case where + ** the step function was not previously called. + */ + case OP_AggFinal: + { + Mem pMem; + Debug.Assert( pOp.p1 > 0 && pOp.p1 <= p.nMem ); + pMem = aMem[pOp.p1]; + Debug.Assert( ( pMem.flags & ~( MEM_Null | MEM_Agg ) ) == 0 ); + rc = sqlite3VdbeMemFinalize( pMem, pOp.p4.pFunc ); + p.aMem[pOp.p1] = pMem; + if ( rc != 0 ) + { + sqlite3SetString( ref p.zErrMsg, db, sqlite3_value_text( pMem ) ); + } + sqlite3VdbeChangeEncoding( pMem, encoding ); #if SQLITE_TEST UPDATE_MAX_BLOBSIZE( pMem ); #endif - if (sqlite3VdbeMemTooBig(pMem)) { - goto too_big; - } - break; - } + if ( sqlite3VdbeMemTooBig( pMem ) ) + { + goto too_big; + } + break; + } #if !SQLITE_OMIT_WAL @@ -5657,42 +6294,43 @@ Vdbe p /* The VDBE */ #endif #if !SQLITE_OMIT_PRAGMA - /* Opcode: JournalMode P1 P2 P3 * P5 - ** - ** Change the journal mode of database P1 to P3. P3 must be one of the - ** PAGER_JOURNALMODE_XXX values. If changing between the various rollback - ** modes (delete, truncate, persist, off and memory), this is a simple - ** operation. No IO is required. - ** - ** If changing into or out of WAL mode the procedure is more complicated. - ** - ** Write a string containing the final journal-mode to register P2. - */ - case OP_JournalMode: { /* out2-prerelease */ - Btree pBt; /* Btree to change journal mode of */ - Pager pPager; /* Pager associated with pBt */ - int eNew; /* New journal mode */ - int eOld; /* The old journal mode */ - string zFilename; /* Name of database file for pPager */ - - eNew = pOp.p3; - Debug.Assert(eNew == PAGER_JOURNALMODE_DELETE - || eNew == PAGER_JOURNALMODE_TRUNCATE - || eNew == PAGER_JOURNALMODE_PERSIST - || eNew == PAGER_JOURNALMODE_OFF - || eNew == PAGER_JOURNALMODE_MEMORY - || eNew == PAGER_JOURNALMODE_WAL - || eNew == PAGER_JOURNALMODE_QUERY - ); - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < db.nDb); - - pBt = db.aDb[pOp.p1].pBt; - pPager = sqlite3BtreePager(pBt); - eOld = sqlite3PagerGetJournalMode(pPager); - if (eNew == PAGER_JOURNALMODE_QUERY) - eNew = eOld; - if (0 == sqlite3PagerOkToChangeJournalMode(pPager)) - eNew = eOld; + /* Opcode: JournalMode P1 P2 P3 * P5 +** +** Change the journal mode of database P1 to P3. P3 must be one of the +** PAGER_JOURNALMODE_XXX values. If changing between the various rollback +** modes (delete, truncate, persist, off and memory), this is a simple +** operation. No IO is required. +** +** If changing into or out of WAL mode the procedure is more complicated. +** +** Write a string containing the final journal-mode to register P2. +*/ + case OP_JournalMode: + { /* out2-prerelease */ + Btree pBt; /* Btree to change journal mode of */ + Pager pPager; /* Pager associated with pBt */ + int eNew; /* New journal mode */ + int eOld; /* The old journal mode */ + string zFilename; /* Name of database file for pPager */ + + eNew = pOp.p3; + Debug.Assert( eNew == PAGER_JOURNALMODE_DELETE + || eNew == PAGER_JOURNALMODE_TRUNCATE + || eNew == PAGER_JOURNALMODE_PERSIST + || eNew == PAGER_JOURNALMODE_OFF + || eNew == PAGER_JOURNALMODE_MEMORY + || eNew == PAGER_JOURNALMODE_WAL + || eNew == PAGER_JOURNALMODE_QUERY + ); + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < db.nDb ); + + pBt = db.aDb[pOp.p1].pBt; + pPager = sqlite3BtreePager( pBt ); + eOld = sqlite3PagerGetJournalMode( pPager ); + if ( eNew == PAGER_JOURNALMODE_QUERY ) + eNew = eOld; + if ( 0 == sqlite3PagerOkToChangeJournalMode( pPager ) ) + eNew = eOld; #if !SQLITE_OMIT_WAL zFilename = sqlite3PagerFilename(pPager); @@ -5746,73 +6384,81 @@ Vdbe p /* The VDBE */ } #endif //* ifndef SQLITE_OMIT_WAL */ - if (rc != 0) { - eNew = eOld; - } - eNew = sqlite3PagerSetJournalMode(pPager, eNew); - - pOut = aMem[pOp.p2]; - pOut.flags = MEM_Str | MEM_Static | MEM_Term; - pOut.z = sqlite3JournalModename(eNew); - pOut.n = sqlite3Strlen30(pOut.z); - pOut.enc = SQLITE_UTF8; - sqlite3VdbeChangeEncoding(pOut, encoding); - break; - }; + if ( rc != 0 ) + { + eNew = eOld; + } + eNew = sqlite3PagerSetJournalMode( pPager, eNew ); + + pOut = aMem[pOp.p2]; + pOut.flags = MEM_Str | MEM_Static | MEM_Term; + pOut.z = sqlite3JournalModename( eNew ); + pOut.n = sqlite3Strlen30( pOut.z ); + pOut.enc = SQLITE_UTF8; + sqlite3VdbeChangeEncoding( pOut, encoding ); + break; + }; #endif //* SQLITE_OMIT_PRAGMA */ -#if !SQLITE_OMIT_VACUUM && !SQLITE_OMIT_ATTACH - /* Opcode: Vacuum * * * * * - ** - ** Vacuum the entire database. This opcode will cause other virtual - ** machines to be created and run. It may not be called from within - ** a transaction. - */ - case OP_Vacuum: { - rc = sqlite3RunVacuum(ref p.zErrMsg, db); - break; - } +#if !SQLITE_OMIT_VACUUM && !SQLITE_OMIT_ATTACH + /* Opcode: Vacuum * * * * * +** +** Vacuum the entire database. This opcode will cause other virtual +** machines to be created and run. It may not be called from within +** a transaction. +*/ + case OP_Vacuum: + { + rc = sqlite3RunVacuum( ref p.zErrMsg, db ); + break; + } #endif -#if !SQLITE_OMIT_AUTOVACUUM - /* Opcode: IncrVacuum P1 P2 * * * - ** - ** Perform a single step of the incremental vacuum procedure on - ** the P1 database. If the vacuum has finished, jump to instruction - ** P2. Otherwise, fall through to the next instruction. - */ - case OP_IncrVacuum: { /* jump */ - Btree pBt; - - Debug.Assert(pOp.p1 >= 0 && pOp.p1 < db.nDb); - Debug.Assert((p.btreeMask & (((yDbMask)1) << pOp.p1)) != 0); - pBt = db.aDb[pOp.p1].pBt; - rc = sqlite3BtreeIncrVacuum(pBt); - if (rc == SQLITE_DONE) { - pc = pOp.p2 - 1; - rc = SQLITE_OK; - } - break; - } +#if !SQLITE_OMIT_AUTOVACUUM + /* Opcode: IncrVacuum P1 P2 * * * +** +** Perform a single step of the incremental vacuum procedure on +** the P1 database. If the vacuum has finished, jump to instruction +** P2. Otherwise, fall through to the next instruction. +*/ + case OP_IncrVacuum: + { /* jump */ + Btree pBt; + + Debug.Assert( pOp.p1 >= 0 && pOp.p1 < db.nDb ); + Debug.Assert( ( p.btreeMask & ( ( (yDbMask)1 ) << pOp.p1 ) ) != 0 ); + pBt = db.aDb[pOp.p1].pBt; + rc = sqlite3BtreeIncrVacuum( pBt ); + if ( rc == SQLITE_DONE ) + { + pc = pOp.p2 - 1; + rc = SQLITE_OK; + } + break; + } #endif - /* Opcode: Expire P1 * * * * - ** - ** Cause precompiled statements to become expired. An expired statement - ** fails with an error code of SQLITE_SCHEMA if it is ever executed - ** (via sqlite3_step()). - ** - ** If P1 is 0, then all SQL statements become expired. If P1 is non-zero, - ** then only the currently executing statement is affected. - */ - case OP_Expire: { - if (pOp.p1 == 0) { - sqlite3ExpirePreparedStatements(db); - } else { - p.expired = true; - } - break; - } + /* Opcode: Expire P1 * * * * +** +** Cause precompiled statements to become expired. An expired statement +** fails with an error code of SQLITE_SCHEMA if it is ever executed +** (via sqlite3_step()). +** +** If P1 is 0, then all SQL statements become expired. If P1 is non-zero, +** then only the currently executing statement is affected. +*/ + case OP_Expire: + { + if ( pOp.p1 == 0 ) + { + sqlite3ExpirePreparedStatements( db ); + } + else + { + p.expired = true; + } + break; + } #if !SQLITE_OMIT_SHARED_CACHE /* Opcode: TableLock P1 P2 P3 P4 * @@ -5849,543 +6495,586 @@ Vdbe p /* The VDBE */ #endif // * SQLITE_OMIT_SHARED_CACHE */ #if !SQLITE_OMIT_VIRTUALTABLE - /* Opcode: VBegin * * * P4 * - ** - ** P4 may be a pointer to an sqlite3_vtab structure. If so, call the - ** xBegin method for that table. - ** - ** Also, whether or not P4 is set, check that this is not being called from - ** within a callback to a virtual table xSync() method. If it is, the error - ** code will be set to SQLITE_LOCKED. - */ - case OP_VBegin: { - VTable pVTab; - pVTab = pOp.p4.pVtab; - rc = sqlite3VtabBegin(db, pVTab); - if (pVTab != null) - importVtabErrMsg(p, pVTab.pVtab); - break; - } + /* Opcode: VBegin * * * P4 * +** +** P4 may be a pointer to an sqlite3_vtab structure. If so, call the +** xBegin method for that table. +** +** Also, whether or not P4 is set, check that this is not being called from +** within a callback to a virtual table xSync() method. If it is, the error +** code will be set to SQLITE_LOCKED. +*/ + case OP_VBegin: + { + VTable pVTab; + pVTab = pOp.p4.pVtab; + rc = sqlite3VtabBegin( db, pVTab ); + if ( pVTab != null ) + importVtabErrMsg( p, pVTab.pVtab ); + break; + } #endif //* SQLITE_OMIT_VIRTUALTABLE */ #if !SQLITE_OMIT_VIRTUALTABLE - /* Opcode: VCreate P1 * * P4 * - ** - ** P4 is the name of a virtual table in database P1. Call the xCreate method - ** for that table. - */ - case OP_VCreate: { - rc = sqlite3VtabCallCreate(db, pOp.p1, pOp.p4.z, ref p.zErrMsg); - break; - } + /* Opcode: VCreate P1 * * P4 * +** +** P4 is the name of a virtual table in database P1. Call the xCreate method +** for that table. +*/ + case OP_VCreate: + { + rc = sqlite3VtabCallCreate( db, pOp.p1, pOp.p4.z, ref p.zErrMsg ); + break; + } #endif //* SQLITE_OMIT_VIRTUALTABLE */ #if !SQLITE_OMIT_VIRTUALTABLE - /* Opcode: VDestroy P1 * * P4 * - ** - ** P4 is the name of a virtual table in database P1. Call the xDestroy method - ** of that table. - */ - case OP_VDestroy: { - p.inVtabMethod = 2; - rc = sqlite3VtabCallDestroy(db, pOp.p1, pOp.p4.z); - p.inVtabMethod = 0; - break; - } + /* Opcode: VDestroy P1 * * P4 * +** +** P4 is the name of a virtual table in database P1. Call the xDestroy method +** of that table. +*/ + case OP_VDestroy: + { + p.inVtabMethod = 2; + rc = sqlite3VtabCallDestroy( db, pOp.p1, pOp.p4.z ); + p.inVtabMethod = 0; + break; + } #endif //* SQLITE_OMIT_VIRTUALTABLE */ #if !SQLITE_OMIT_VIRTUALTABLE - /* Opcode: VOpen P1 * * P4 * - ** - ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. - ** P1 is a cursor number. This opcode opens a cursor to the virtual - ** table and stores that cursor in P1. - */ - case OP_VOpen: { - VdbeCursor pCur; - sqlite3_vtab_cursor pVtabCursor; - sqlite3_vtab pVtab; - sqlite3_module pModule; - - pCur = null; - pVtab = pOp.p4.pVtab.pVtab; - pModule = (sqlite3_module)pVtab.pModule; - Debug.Assert(pVtab != null && pModule != null); - rc = pModule.xOpen(pVtab, out pVtabCursor); - importVtabErrMsg(p, pVtab); - if (SQLITE_OK == rc) { - /* Initialize sqlite3_vtab_cursor base class */ - pVtabCursor.pVtab = pVtab; - - /* Initialise vdbe cursor object */ - pCur = allocateCursor(p, pOp.p1, 0, -1, 0); - if (pCur != null) { - pCur.pVtabCursor = pVtabCursor; - pCur.pModule = pVtabCursor.pVtab.pModule; - } else { - //db.mallocFailed = 1; - pModule.xClose(ref pVtabCursor); - } - } - break; - } + /* Opcode: VOpen P1 * * P4 * +** +** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. +** P1 is a cursor number. This opcode opens a cursor to the virtual +** table and stores that cursor in P1. +*/ + case OP_VOpen: + { + VdbeCursor pCur; + sqlite3_vtab_cursor pVtabCursor; + sqlite3_vtab pVtab; + sqlite3_module pModule; + + pCur = null; + pVtab = pOp.p4.pVtab.pVtab; + pModule = (sqlite3_module)pVtab.pModule; + Debug.Assert( pVtab != null && pModule != null ); + rc = pModule.xOpen( pVtab, out pVtabCursor ); + importVtabErrMsg( p, pVtab ); + if ( SQLITE_OK == rc ) + { + /* Initialize sqlite3_vtab_cursor base class */ + pVtabCursor.pVtab = pVtab; + + /* Initialise vdbe cursor object */ + pCur = allocateCursor( p, pOp.p1, 0, -1, 0 ); + if ( pCur != null ) + { + pCur.pVtabCursor = pVtabCursor; + pCur.pModule = pVtabCursor.pVtab.pModule; + } + else + { + //db.mallocFailed = 1; + pModule.xClose( ref pVtabCursor ); + } + } + break; + } #endif //* SQLITE_OMIT_VIRTUALTABLE */ #if !SQLITE_OMIT_VIRTUALTABLE - /* Opcode: VFilter P1 P2 P3 P4 * - ** - ** P1 is a cursor opened using VOpen. P2 is an address to jump to if - ** the filtered result set is empty. - ** - ** P4 is either NULL or a string that was generated by the xBestIndex - ** method of the module. The interpretation of the P4 string is left - ** to the module implementation. - ** - ** This opcode invokes the xFilter method on the virtual table specified - ** by P1. The integer query plan parameter to xFilter is stored in register - ** P3. Register P3+1 stores the argc parameter to be passed to the - ** xFilter method. Registers P3+2..P3+1+argc are the argc - ** additional parameters which are passed to - ** xFilter as argv. Register P3+2 becomes argv[0] when passed to xFilter. - ** - ** A jump is made to P2 if the result set after filtering would be empty. - */ - case OP_VFilter: { /* jump */ - int nArg; - int iQuery; - sqlite3_module pModule; - Mem pQuery; - Mem pArgc = null; - sqlite3_vtab_cursor pVtabCursor; - sqlite3_vtab pVtab; - VdbeCursor pCur; - int res; - int i; - Mem[] apArg; - - pQuery = aMem[pOp.p3]; - pArgc = aMem[pOp.p3 + 1];// pQuery[1]; - pCur = p.apCsr[pOp.p1]; - Debug.Assert(memIsValid(pQuery)); - REGISTER_TRACE(p, pOp.p3, pQuery); - Debug.Assert(pCur.pVtabCursor != null); - pVtabCursor = pCur.pVtabCursor; - pVtab = pVtabCursor.pVtab; - pModule = pVtab.pModule; - - /* Grab the index number and argc parameters */ - Debug.Assert((pQuery.flags & MEM_Int) != 0 && pArgc.flags == MEM_Int); - nArg = (int)pArgc.u.i; - iQuery = (int)pQuery.u.i; - - /* Invoke the xFilter method */ - { - res = 0; - apArg = p.apArg; - for (i = 0; i < nArg; i++) { - apArg[i] = aMem[(pOp.p3 + 1) + i + 1];//apArg[i] = pArgc[i + 1]; - sqlite3VdbeMemStoreType(apArg[i]); - } - - p.inVtabMethod = 1; - rc = pModule.xFilter(pVtabCursor, iQuery, pOp.p4.z, nArg, apArg); - p.inVtabMethod = 0; - importVtabErrMsg(p, pVtab); - if (rc == SQLITE_OK) { - res = pModule.xEof(pVtabCursor); - } - - if (res != 0) { - pc = pOp.p2 - 1; - } - } - pCur.nullRow = false; - break; - } + /* Opcode: VFilter P1 P2 P3 P4 * +** +** P1 is a cursor opened using VOpen. P2 is an address to jump to if +** the filtered result set is empty. +** +** P4 is either NULL or a string that was generated by the xBestIndex +** method of the module. The interpretation of the P4 string is left +** to the module implementation. +** +** This opcode invokes the xFilter method on the virtual table specified +** by P1. The integer query plan parameter to xFilter is stored in register +** P3. Register P3+1 stores the argc parameter to be passed to the +** xFilter method. Registers P3+2..P3+1+argc are the argc +** additional parameters which are passed to +** xFilter as argv. Register P3+2 becomes argv[0] when passed to xFilter. +** +** A jump is made to P2 if the result set after filtering would be empty. +*/ + case OP_VFilter: + { /* jump */ + int nArg; + int iQuery; + sqlite3_module pModule; + Mem pQuery; + Mem pArgc = null; + sqlite3_vtab_cursor pVtabCursor; + sqlite3_vtab pVtab; + VdbeCursor pCur; + int res; + int i; + Mem[] apArg; + + pQuery = aMem[pOp.p3]; + pArgc = aMem[pOp.p3 + 1];// pQuery[1]; + pCur = p.apCsr[pOp.p1]; + Debug.Assert( memIsValid( pQuery ) ); + REGISTER_TRACE( p, pOp.p3, pQuery ); + Debug.Assert( pCur.pVtabCursor != null ); + pVtabCursor = pCur.pVtabCursor; + pVtab = pVtabCursor.pVtab; + pModule = pVtab.pModule; + + /* Grab the index number and argc parameters */ + Debug.Assert( ( pQuery.flags & MEM_Int ) != 0 && pArgc.flags == MEM_Int ); + nArg = (int)pArgc.u.i; + iQuery = (int)pQuery.u.i; + + /* Invoke the xFilter method */ + { + res = 0; + apArg = p.apArg; + for ( i = 0; i < nArg; i++ ) + { + apArg[i] = aMem[(pOp.p3 + 1) + i + 1];//apArg[i] = pArgc[i + 1]; + sqlite3VdbeMemStoreType( apArg[i] ); + } + + p.inVtabMethod = 1; + rc = pModule.xFilter( pVtabCursor, iQuery, pOp.p4.z, nArg, apArg ); + p.inVtabMethod = 0; + importVtabErrMsg( p, pVtab ); + if ( rc == SQLITE_OK ) + { + res = pModule.xEof( pVtabCursor ); + } + + if ( res != 0 ) + { + pc = pOp.p2 - 1; + } + } + pCur.nullRow = false; + break; + } #endif //* SQLITE_OMIT_VIRTUALTABLE */ #if !SQLITE_OMIT_VIRTUALTABLE - /* Opcode: VColumn P1 P2 P3 * * - ** - ** Store the value of the P2-th column of - ** the row of the virtual-table that the - ** P1 cursor is pointing to into register P3. - */ - case OP_VColumn: { - sqlite3_vtab pVtab; - sqlite3_module pModule; - Mem pDest; - sqlite3_context sContext; - - VdbeCursor pCur = p.apCsr[pOp.p1]; - Debug.Assert(pCur.pVtabCursor != null); - Debug.Assert(pOp.p3 > 0 && pOp.p3 <= p.nMem); - pDest = aMem[pOp.p3]; - memAboutToChange(p, pDest); - if (pCur.nullRow) { - sqlite3VdbeMemSetNull(pDest); - break; - } - pVtab = pCur.pVtabCursor.pVtab; - pModule = pVtab.pModule; - Debug.Assert(pModule.xColumn != null); - sContext = new sqlite3_context();//memset( &sContext, 0, sizeof( sContext ) ); - - /* The output cell may already have a buffer allocated. Move - ** the current contents to sContext.s so in case the user-function - ** can use the already allocated buffer instead of allocating a - ** new one. - */ - sqlite3VdbeMemMove(sContext.s, pDest); - MemSetTypeFlag(sContext.s, MEM_Null); - - rc = pModule.xColumn(pCur.pVtabCursor, sContext, pOp.p2); - importVtabErrMsg(p, pVtab); - - if (sContext.isError != 0) { - rc = sContext.isError; - } - - /* Copy the result of the function to the P3 register. We - ** do this regardless of whether or not an error occurred to ensure any - ** dynamic allocation in sContext.s (a Mem struct) is released. - */ - sqlite3VdbeChangeEncoding(sContext.s, encoding); - sqlite3VdbeMemMove(pDest, sContext.s); - REGISTER_TRACE(p, pOp.p3, pDest); - UPDATE_MAX_BLOBSIZE(pDest); - if (sqlite3VdbeMemTooBig(pDest)) { - goto too_big; - } - break; - } + /* Opcode: VColumn P1 P2 P3 * * +** +** Store the value of the P2-th column of +** the row of the virtual-table that the +** P1 cursor is pointing to into register P3. +*/ + case OP_VColumn: + { + sqlite3_vtab pVtab; + sqlite3_module pModule; + Mem pDest; + sqlite3_context sContext; + + VdbeCursor pCur = p.apCsr[pOp.p1]; + Debug.Assert( pCur.pVtabCursor != null ); + Debug.Assert( pOp.p3 > 0 && pOp.p3 <= p.nMem ); + pDest = aMem[pOp.p3]; + memAboutToChange( p, pDest ); + if ( pCur.nullRow ) + { + sqlite3VdbeMemSetNull( pDest ); + break; + } + pVtab = pCur.pVtabCursor.pVtab; + pModule = pVtab.pModule; + Debug.Assert( pModule.xColumn != null ); + sContext = new sqlite3_context();//memset( &sContext, 0, sizeof( sContext ) ); + + /* The output cell may already have a buffer allocated. Move + ** the current contents to sContext.s so in case the user-function + ** can use the already allocated buffer instead of allocating a + ** new one. + */ + sqlite3VdbeMemMove( sContext.s, pDest ); + MemSetTypeFlag( sContext.s, MEM_Null ); + + rc = pModule.xColumn( pCur.pVtabCursor, sContext, pOp.p2 ); + importVtabErrMsg( p, pVtab ); + + if ( sContext.isError != 0 ) + { + rc = sContext.isError; + } + + /* Copy the result of the function to the P3 register. We + ** do this regardless of whether or not an error occurred to ensure any + ** dynamic allocation in sContext.s (a Mem struct) is released. + */ + sqlite3VdbeChangeEncoding( sContext.s, encoding ); + sqlite3VdbeMemMove( pDest, sContext.s ); + REGISTER_TRACE( p, pOp.p3, pDest ); + UPDATE_MAX_BLOBSIZE( pDest ); + if ( sqlite3VdbeMemTooBig( pDest ) ) + { + goto too_big; + } + break; + } #endif //* SQLITE_OMIT_VIRTUALTABLE */ #if !SQLITE_OMIT_VIRTUALTABLE - /* Opcode: VNext P1 P2 * * * - ** - ** Advance virtual table P1 to the next row in its result set and - ** jump to instruction P2. Or, if the virtual table has reached - ** the end of its result set, then fall through to the next instruction. - */ - case OP_VNext: { /* jump */ - sqlite3_vtab pVtab; - sqlite3_module pModule; - int res; - VdbeCursor pCur; - - res = 0; - pCur = p.apCsr[pOp.p1]; - Debug.Assert(pCur.pVtabCursor != null); - if (pCur.nullRow) { - break; - } - pVtab = pCur.pVtabCursor.pVtab; - pModule = pVtab.pModule; - Debug.Assert(pModule.xNext != null); - - /* Invoke the xNext() method of the module. There is no way for the - ** underlying implementation to return an error if one occurs during - ** xNext(). Instead, if an error occurs, true is returned (indicating that - ** data is available) and the error code returned when xColumn or - ** some other method is next invoked on the save virtual table cursor. - */ - p.inVtabMethod = 1; - rc = pModule.xNext(pCur.pVtabCursor); - p.inVtabMethod = 0; - importVtabErrMsg(p, pVtab); - if (rc == SQLITE_OK) { - res = pModule.xEof(pCur.pVtabCursor); - } - - if (0 == res) { - /* If there is data, jump to P2 */ - pc = pOp.p2 - 1; - } - break; - } + /* Opcode: VNext P1 P2 * * * +** +** Advance virtual table P1 to the next row in its result set and +** jump to instruction P2. Or, if the virtual table has reached +** the end of its result set, then fall through to the next instruction. +*/ + case OP_VNext: + { /* jump */ + sqlite3_vtab pVtab; + sqlite3_module pModule; + int res; + VdbeCursor pCur; + + res = 0; + pCur = p.apCsr[pOp.p1]; + Debug.Assert( pCur.pVtabCursor != null ); + if ( pCur.nullRow ) + { + break; + } + pVtab = pCur.pVtabCursor.pVtab; + pModule = pVtab.pModule; + Debug.Assert( pModule.xNext != null ); + + /* Invoke the xNext() method of the module. There is no way for the + ** underlying implementation to return an error if one occurs during + ** xNext(). Instead, if an error occurs, true is returned (indicating that + ** data is available) and the error code returned when xColumn or + ** some other method is next invoked on the save virtual table cursor. + */ + p.inVtabMethod = 1; + rc = pModule.xNext( pCur.pVtabCursor ); + p.inVtabMethod = 0; + importVtabErrMsg( p, pVtab ); + if ( rc == SQLITE_OK ) + { + res = pModule.xEof( pCur.pVtabCursor ); + } + + if ( 0 == res ) + { + /* If there is data, jump to P2 */ + pc = pOp.p2 - 1; + } + break; + } #endif //* SQLITE_OMIT_VIRTUALTABLE */ #if !SQLITE_OMIT_VIRTUALTABLE - /* Opcode: VRename P1 * * P4 * - ** - ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. - ** This opcode invokes the corresponding xRename method. The value - ** in register P1 is passed as the zName argument to the xRename method. - */ - case OP_VRename: { - sqlite3_vtab pVtab; - Mem pName; - - pVtab = pOp.p4.pVtab.pVtab; - pName = aMem[pOp.p1]; - Debug.Assert(pVtab.pModule.xRename != null); - Debug.Assert(memIsValid(pName)); - REGISTER_TRACE(p, pOp.p1, pName); - Debug.Assert((pName.flags & MEM_Str) != 0); - rc = pVtab.pModule.xRename(pVtab, pName.z); - importVtabErrMsg(p, pVtab); - p.expired = false; - break; - } + /* Opcode: VRename P1 * * P4 * +** +** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. +** This opcode invokes the corresponding xRename method. The value +** in register P1 is passed as the zName argument to the xRename method. +*/ + case OP_VRename: + { + sqlite3_vtab pVtab; + Mem pName; + + pVtab = pOp.p4.pVtab.pVtab; + pName = aMem[pOp.p1]; + Debug.Assert( pVtab.pModule.xRename != null ); + Debug.Assert( memIsValid( pName ) ); + REGISTER_TRACE( p, pOp.p1, pName ); + Debug.Assert( ( pName.flags & MEM_Str ) != 0 ); + rc = pVtab.pModule.xRename( pVtab, pName.z ); + importVtabErrMsg( p, pVtab ); + p.expired = false; + break; + } #endif #if !SQLITE_OMIT_VIRTUALTABLE - /* Opcode: VUpdate P1 P2 P3 P4 * - ** - ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. - ** This opcode invokes the corresponding xUpdate method. P2 values - ** are contiguous memory cells starting at P3 to pass to the xUpdate - ** invocation. The value in register (P3+P2-1) corresponds to the - ** p2th element of the argv array passed to xUpdate. - ** - ** The xUpdate method will do a DELETE or an INSERT or both. - ** The argv[0] element (which corresponds to memory cell P3) - ** is the rowid of a row to delete. If argv[0] is NULL then no - ** deletion occurs. The argv[1] element is the rowid of the new - ** row. This can be NULL to have the virtual table select the new - ** rowid for itself. The subsequent elements in the array are - ** the values of columns in the new row. - ** - ** If P2==1 then no insert is performed. argv[0] is the rowid of - ** a row to delete. - ** - ** P1 is a boolean flag. If it is set to true and the xUpdate call - ** is successful, then the value returned by sqlite3_last_insert_rowid() - ** is set to the value of the rowid for the row just inserted. - */ - case OP_VUpdate: { - sqlite3_vtab pVtab; - sqlite3_module pModule; - int nArg; - int i; - sqlite_int64 rowid = 0; - Mem[] apArg; - Mem pX; - - Debug.Assert(pOp.p2 == 1 || pOp.p5 == OE_Fail || pOp.p5 == OE_Rollback - || pOp.p5 == OE_Abort || pOp.p5 == OE_Ignore || pOp.p5 == OE_Replace - ); - pVtab = pOp.p4.pVtab.pVtab; - pModule = (sqlite3_module)pVtab.pModule; - nArg = pOp.p2; - Debug.Assert(pOp.p4type == P4_VTAB); - if (ALWAYS(pModule.xUpdate)) { - u8 vtabOnConflict = db.vtabOnConflict; - apArg = p.apArg; - //pX = aMem[pOp.p3]; - for (i = 0; i < nArg; i++) { - pX = aMem[pOp.p3 + i]; - Debug.Assert(memIsValid(pX)); - memAboutToChange(p, pX); - sqlite3VdbeMemStoreType(pX); - apArg[i] = pX; - //pX++; - } - db.vtabOnConflict = pOp.p5; - rc = pModule.xUpdate(pVtab, nArg, apArg, out rowid); - db.vtabOnConflict = vtabOnConflict; - importVtabErrMsg(p, pVtab); - if (rc == SQLITE_OK && pOp.p1 != 0) { - Debug.Assert(nArg > 1 && apArg[0] != null && (apArg[0].flags & MEM_Null) != 0); - db.lastRowid = lastRowid = rowid; - } - if (rc == SQLITE_CONSTRAINT && pOp.p4.pVtab.bConstraint != 0) { - if (pOp.p5 == OE_Ignore) { - rc = SQLITE_OK; - } else { - p.errorAction = pOp.p5 == (u8)OE_Replace ? (u8)OE_Abort : pOp.p5; - } - } else { - p.nChange++; - } - } - break; - } + /* Opcode: VUpdate P1 P2 P3 P4 * +** +** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. +** This opcode invokes the corresponding xUpdate method. P2 values +** are contiguous memory cells starting at P3 to pass to the xUpdate +** invocation. The value in register (P3+P2-1) corresponds to the +** p2th element of the argv array passed to xUpdate. +** +** The xUpdate method will do a DELETE or an INSERT or both. +** The argv[0] element (which corresponds to memory cell P3) +** is the rowid of a row to delete. If argv[0] is NULL then no +** deletion occurs. The argv[1] element is the rowid of the new +** row. This can be NULL to have the virtual table select the new +** rowid for itself. The subsequent elements in the array are +** the values of columns in the new row. +** +** If P2==1 then no insert is performed. argv[0] is the rowid of +** a row to delete. +** +** P1 is a boolean flag. If it is set to true and the xUpdate call +** is successful, then the value returned by sqlite3_last_insert_rowid() +** is set to the value of the rowid for the row just inserted. +*/ + case OP_VUpdate: + { + sqlite3_vtab pVtab; + sqlite3_module pModule; + int nArg; + int i; + sqlite_int64 rowid = 0; + Mem[] apArg; + Mem pX; + + Debug.Assert( pOp.p2 == 1 || pOp.p5 == OE_Fail || pOp.p5 == OE_Rollback + || pOp.p5 == OE_Abort || pOp.p5 == OE_Ignore || pOp.p5 == OE_Replace + ); + pVtab = pOp.p4.pVtab.pVtab; + pModule = (sqlite3_module)pVtab.pModule; + nArg = pOp.p2; + Debug.Assert( pOp.p4type == P4_VTAB ); + if ( ALWAYS( pModule.xUpdate ) ) + { + u8 vtabOnConflict = db.vtabOnConflict; + apArg = p.apArg; + //pX = aMem[pOp.p3]; + for ( i = 0; i < nArg; i++ ) + { + pX = aMem[pOp.p3 + i]; + Debug.Assert( memIsValid( pX ) ); + memAboutToChange( p, pX ); + sqlite3VdbeMemStoreType( pX ); + apArg[i] = pX; + //pX++; + } + db.vtabOnConflict = pOp.p5; + rc = pModule.xUpdate( pVtab, nArg, apArg, out rowid ); + db.vtabOnConflict = vtabOnConflict; + importVtabErrMsg( p, pVtab ); + if ( rc == SQLITE_OK && pOp.p1 != 0 ) + { + Debug.Assert( nArg > 1 && apArg[0] != null && ( apArg[0].flags & MEM_Null ) != 0 ); + db.lastRowid = lastRowid = rowid; + } + if ( rc == SQLITE_CONSTRAINT && pOp.p4.pVtab.bConstraint != 0 ) + { + if ( pOp.p5 == OE_Ignore ) + { + rc = SQLITE_OK; + } + else + { + p.errorAction = pOp.p5 == (u8)OE_Replace ? (u8)OE_Abort : pOp.p5; + } + } + else + { + p.nChange++; + } + } + break; + } #endif //* SQLITE_OMIT_VIRTUALTABLE */ #if !SQLITE_OMIT_PAGER_PRAGMAS - /* Opcode: Pagecount P1 P2 * * * - ** - ** Write the current number of pages in database P1 to memory cell P2. - */ - case OP_Pagecount: { /* out2-prerelease */ - pOut.u.i = sqlite3BtreeLastPage(db.aDb[pOp.p1].pBt); - break; - } + /* Opcode: Pagecount P1 P2 * * * +** +** Write the current number of pages in database P1 to memory cell P2. +*/ + case OP_Pagecount: + { /* out2-prerelease */ + pOut.u.i = sqlite3BtreeLastPage( db.aDb[pOp.p1].pBt ); + break; + } #endif #if !SQLITE_OMIT_PAGER_PRAGMAS - /* Opcode: MaxPgcnt P1 P2 P3 * * - ** - ** Try to set the maximum page count for database P1 to the value in P3. - ** Do not let the maximum page count fall below the current page count and - ** do not change the maximum page count value if P3==0. - ** - ** Store the maximum page count after the change in register P2. - */ - case OP_MaxPgcnt: { /* out2-prerelease */ - i64 newMax; - Btree pBt; - - pBt = db.aDb[pOp.p1].pBt; - newMax = 0; - if (pOp.p3 != 0) { - newMax = sqlite3BtreeLastPage(pBt); - if (newMax < pOp.p3) - newMax = pOp.p3; - } - pOut.u.i = (i64)sqlite3BtreeMaxPageCount(pBt, (int)newMax); - break; - } + /* Opcode: MaxPgcnt P1 P2 P3 * * +** +** Try to set the maximum page count for database P1 to the value in P3. +** Do not let the maximum page count fall below the current page count and +** do not change the maximum page count value if P3==0. +** +** Store the maximum page count after the change in register P2. +*/ + case OP_MaxPgcnt: + { /* out2-prerelease */ + i64 newMax; + Btree pBt; + + pBt = db.aDb[pOp.p1].pBt; + newMax = 0; + if ( pOp.p3 != 0 ) + { + newMax = sqlite3BtreeLastPage( pBt ); + if ( newMax < pOp.p3 ) + newMax = pOp.p3; + } + pOut.u.i = (i64)sqlite3BtreeMaxPageCount( pBt, (int)newMax ); + break; + } #endif #if !SQLITE_OMIT_TRACE - /* Opcode: Trace * * * P4 * - ** - ** If tracing is enabled (by the sqlite3_trace()) interface, then - ** the UTF-8 string contained in P4 is emitted on the trace callback. - */ - case OP_Trace: { - string zTrace; - string z; - - if (db.xTrace != null && !String.IsNullOrEmpty(zTrace = (pOp.p4.z != null ? pOp.p4.z : p.zSql))) { - z = sqlite3VdbeExpandSql(p, zTrace); - db.xTrace(db.pTraceArg, z); - //sqlite3DbFree( db, ref z ); - } + /* Opcode: Trace * * * P4 * +** +** If tracing is enabled (by the sqlite3_trace()) interface, then +** the UTF-8 string contained in P4 is emitted on the trace callback. +*/ + case OP_Trace: + { + string zTrace; + string z; + + if ( db.xTrace != null && !String.IsNullOrEmpty( zTrace = ( pOp.p4.z != null ? pOp.p4.z : p.zSql ) ) ) + { + z = sqlite3VdbeExpandSql( p, zTrace ); + db.xTrace( db.pTraceArg, z ); + //sqlite3DbFree( db, ref z ); + } #if SQLITE_DEBUG - if ((db.flags & SQLITE_SqlTrace) != 0 - && (zTrace = (pOp.p4.z != null ? pOp.p4.z : p.zSql)) != "") { - sqlite3DebugPrintf("SQL-trace: %s\n", zTrace); - } + if ( ( db.flags & SQLITE_SqlTrace ) != 0 + && ( zTrace = ( pOp.p4.z != null ? pOp.p4.z : p.zSql ) ) != "" ) + { + sqlite3DebugPrintf( "SQL-trace: %s\n", zTrace ); + } #endif // * SQLITE_DEBUG */ - break; - } + break; + } #endif - /* Opcode: Noop * * * * * - ** - ** Do nothing. This instruction is often useful as a jump - ** destination. + /* Opcode: Noop * * * * * +** +** Do nothing. This instruction is often useful as a jump +** destination. +*/ + /* + ** The magic Explain opcode are only inserted when explain==2 (which + ** is to say when the EXPLAIN QUERY PLAN syntax is used.) + ** This opcode records information from the optimizer. It is the + ** the same as a no-op. This opcodesnever appears in a real VM program. */ - /* - ** The magic Explain opcode are only inserted when explain==2 (which - ** is to say when the EXPLAIN QUERY PLAN syntax is used.) - ** This opcode records information from the optimizer. It is the - ** the same as a no-op. This opcodesnever appears in a real VM program. - */ - default: { /* This is really OP_Noop and OP_Explain */ - Debug.Assert(pOp.opcode == OP_Noop || pOp.opcode == OP_Explain); - break; - } + default: + { /* This is really OP_Noop and OP_Explain */ + Debug.Assert( pOp.opcode == OP_Noop || pOp.opcode == OP_Explain ); + break; + } - /***************************************************************************** - ** The cases of the switch statement above this line should all be indented - ** by 6 spaces. But the left-most 6 spaces have been removed to improve the - ** readability. From this point on down, the normal indentation rules are - ** restored. - *****************************************************************************/ - } + /***************************************************************************** + ** The cases of the switch statement above this line should all be indented + ** by 6 spaces. But the left-most 6 spaces have been removed to improve the + ** readability. From this point on down, the normal indentation rules are + ** restored. + *****************************************************************************/ + } #if VDBE_PROFILE { u64 elapsed = sqlite3Hwtime() - start; pOp.cycles += elapsed; pOp.cnt++; -#if FALSE +#if FALSE fprintf(stdout, "%10llu ", elapsed); sqlite3VdbePrintOp(stdout, origPc, aOp[origPc]); #endif } #endif - /* The following code adds nothing to the actual functionality - ** of the program. It is only here for testing and debugging. - ** On the other hand, it does burn CPU cycles every time through - ** the evaluator loop. So we can leave it out when NDEBUG is defined. - */ + /* The following code adds nothing to the actual functionality +** of the program. It is only here for testing and debugging. +** On the other hand, it does burn CPU cycles every time through +** the evaluator loop. So we can leave it out when NDEBUG is defined. +*/ #if !NDEBUG - Debug.Assert(pc >= -1 && pc < p.nOp); + Debug.Assert( pc >= -1 && pc < p.nOp ); #if SQLITE_DEBUG - if (p.trace != null) { - if (rc != 0) - fprintf(p.trace, "rc=%d\n", rc); - if ((pOp.opflags & (OPFLG_OUT2_PRERELEASE | OPFLG_OUT2)) != 0) { - registerTrace(p.trace, pOp.p2, aMem[pOp.p2]); - } - if ((pOp.opflags & OPFLG_OUT3) != 0) { - registerTrace(p.trace, pOp.p3, aMem[pOp.p3]); - } - } + if ( p.trace != null ) + { + if ( rc != 0 ) + fprintf( p.trace, "rc=%d\n", rc ); + if ( ( pOp.opflags & ( OPFLG_OUT2_PRERELEASE | OPFLG_OUT2 ) ) != 0 ) + { + registerTrace( p.trace, pOp.p2, aMem[pOp.p2] ); + } + if ( ( pOp.opflags & OPFLG_OUT3 ) != 0 ) + { + registerTrace( p.trace, pOp.p3, aMem[pOp.p3] ); + } + } #endif // * SQLITE_DEBUG */ #endif // * NDEBUG */ - } /* The end of the for(;;) loop the loops through opcodes */ + } /* The end of the for(;;) loop the loops through opcodes */ - /* If we reach this point, it means that execution is finished with - ** an error of some kind. - */ - vdbe_error_halt: - Debug.Assert(rc != 0); - p.rc = rc; - testcase(sqlite3GlobalConfig.xLog != null); - sqlite3_log(rc, "statement aborts at %d: [%s] %s", - pc, p.zSql, p.zErrMsg); - sqlite3VdbeHalt(p); - //if ( rc == SQLITE_IOERR_NOMEM ) db.mallocFailed = 1; - rc = SQLITE_ERROR; - if (resetSchemaOnFault > 0) { - sqlite3ResetInternalSchema(db, resetSchemaOnFault - 1); - } - /* This is the only way out of this procedure. We have to - ** release the mutexes on btrees that were acquired at the - ** top. */ - vdbe_return: - db.lastRowid = lastRowid; - sqlite3VdbeLeave(p); - return rc; + /* If we reach this point, it means that execution is finished with + ** an error of some kind. + */ +vdbe_error_halt: + Debug.Assert( rc != 0 ); + p.rc = rc; + testcase( sqlite3GlobalConfig.xLog != null ); + sqlite3_log( rc, "statement aborts at %d: [%s] %s", + pc, p.zSql, p.zErrMsg ); + sqlite3VdbeHalt( p ); + //if ( rc == SQLITE_IOERR_NOMEM ) db.mallocFailed = 1; + rc = SQLITE_ERROR; + if ( resetSchemaOnFault > 0 ) + { + sqlite3ResetInternalSchema( db, resetSchemaOnFault - 1 ); + } +/* This is the only way out of this procedure. We have to +** release the mutexes on btrees that were acquired at the +** top. */ +vdbe_return: + db.lastRowid = lastRowid; + sqlite3VdbeLeave( p ); + return rc; /* Jump to here if a string or blob larger than db.aLimit[SQLITE_LIMIT_LENGTH] ** is encountered. */ - too_big: - sqlite3SetString(ref p.zErrMsg, db, "string or blob too big"); - rc = SQLITE_TOOBIG; - goto vdbe_error_halt; +too_big: + sqlite3SetString( ref p.zErrMsg, db, "string or blob too big" ); + rc = SQLITE_TOOBIG; + goto vdbe_error_halt; /* Jump to here if a malloc() fails. */ - no_mem: - //db.mallocFailed = 1; - sqlite3SetString(ref p.zErrMsg, db, "out of memory"); - rc = SQLITE_NOMEM; - goto vdbe_error_halt; +no_mem: + //db.mallocFailed = 1; + sqlite3SetString( ref p.zErrMsg, db, "out of memory" ); + rc = SQLITE_NOMEM; + goto vdbe_error_halt; /* Jump to here for any other kind of fatal error. The "rc" variable ** should hold the error number. */ - abort_due_to_error: - //Debug.Assert( p.zErrMsg); /// Not needed in C# - //if ( db.mallocFailed != 0 ) rc = SQLITE_NOMEM; - if (rc != SQLITE_IOERR_NOMEM) { - sqlite3SetString(ref p.zErrMsg, db, "%s", sqlite3ErrStr(rc)); - } - goto vdbe_error_halt; +abort_due_to_error: + //Debug.Assert( p.zErrMsg); /// Not needed in C# + //if ( db.mallocFailed != 0 ) rc = SQLITE_NOMEM; + if ( rc != SQLITE_IOERR_NOMEM ) + { + sqlite3SetString( ref p.zErrMsg, db, "%s", sqlite3ErrStr( rc ) ); + } + goto vdbe_error_halt; /* Jump to here if the sqlite3_interrupt() API sets the interrupt ** flag. */ - abort_due_to_interrupt: - Debug.Assert(db.u1.isInterrupted); - rc = SQLITE_INTERRUPT; - p.rc = rc; - sqlite3SetString(ref p.zErrMsg, db, sqlite3ErrStr(rc)); - goto vdbe_error_halt; - } +abort_due_to_interrupt: + Debug.Assert( db.u1.isInterrupted ); + rc = SQLITE_INTERRUPT; + p.rc = rc; + sqlite3SetString( ref p.zErrMsg, db, sqlite3ErrStr( rc ) ); + goto vdbe_error_halt; } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/vdbeapi_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/vdbeapi_c.cs index f8d7607f5..eb1a225ba 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/vdbeapi_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/vdbeapi_c.cs @@ -1,43 +1,46 @@ using System; using System.Diagnostics; using System.Text; - using i64 = System.Int64; -using sqlite3_int64 = System.Int64; using u16 = System.UInt16; using u32 = System.UInt32; +using u64 = System.UInt64; using u8 = System.Byte; +using sqlite3_int64 = System.Int64; -namespace Community.CsharpSqlite { - using sqlite_int64 = System.Int64; - using sqlite3_stmt = Sqlite3.Vdbe; - using sqlite3_value = Sqlite3.Mem; - - public partial class Sqlite3 { - /* - ** 2004 May 26 - ** - ** 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 contains code use to implement APIs that are part of the - ** VDBE. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include "vdbeInt.h" +namespace Community.CsharpSqlite +{ + using Op = Sqlite3.VdbeOp; + using sqlite_int64 = System.Int64; + using sqlite3_stmt = Sqlite3.Vdbe; + using sqlite3_value = Sqlite3.Mem; + + public partial class Sqlite3 + { + /* + ** 2004 May 26 + ** + ** 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 contains code use to implement APIs that are part of the + ** VDBE. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include "vdbeInt.h" #if !SQLITE_OMIT_DEPRECATED /* @@ -55,161 +58,192 @@ static int sqlite3_expired( sqlite3_stmt pStmt ) } #endif - /* - ** Check on a Vdbe to make sure it has not been finalized. Log - ** an error and return true if it has been finalized (or is otherwise - ** invalid). Return false if it is ok. - */ - static bool vdbeSafety(Vdbe p) { - if (p.db == null) { - sqlite3_log(SQLITE_MISUSE, "API called with finalized prepared statement"); - return true; - } else { - return false; - } - } - static bool vdbeSafetyNotNull(Vdbe p) { - if (p == null) { - sqlite3_log(SQLITE_MISUSE, "API called with NULL prepared statement"); - return true; - } else { - return vdbeSafety(p); - } - } + /* +** Check on a Vdbe to make sure it has not been finalized. Log +** an error and return true if it has been finalized (or is otherwise +** invalid). Return false if it is ok. +*/ + static bool vdbeSafety( Vdbe p ) + { + if ( p.db == null ) + { + sqlite3_log( SQLITE_MISUSE, "API called with finalized prepared statement" ); + return true; + } + else + { + return false; + } + } + static bool vdbeSafetyNotNull( Vdbe p ) + { + if ( p == null ) + { + sqlite3_log( SQLITE_MISUSE, "API called with NULL prepared statement" ); + return true; + } + else + { + return vdbeSafety( p ); + } + } - /* - ** The following routine destroys a virtual machine that is created by - ** the sqlite3_compile() routine. The integer returned is an SQLITE_ - ** success/failure code that describes the result of executing the virtual - ** machine. - ** - ** This routine sets the error code and string returned by - ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16(). - */ - public static int sqlite3_finalize(sqlite3_stmt pStmt) { - int rc; - if (pStmt == null) { - /* IMPLEMENTATION-OF: R-57228-12904 Invoking sqlite3_finalize() on a NULL - ** pointer is a harmless no-op. */ - rc = SQLITE_OK; - } else { - Vdbe v = pStmt; - sqlite3 db = v.db; -#if SQLITE_THREADSAFE - sqlite3_mutex mutex; + /* + ** The following routine destroys a virtual machine that is created by + ** the sqlite3_compile() routine. The integer returned is an SQLITE_ + ** success/failure code that describes the result of executing the virtual + ** machine. + ** + ** This routine sets the error code and string returned by + ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16(). + */ + public static int sqlite3_finalize( sqlite3_stmt pStmt ) + { + int rc; + if ( pStmt == null ) + { + /* IMPLEMENTATION-OF: R-57228-12904 Invoking sqlite3_finalize() on a NULL + ** pointer is a harmless no-op. */ + rc = SQLITE_OK; + } + else + { + Vdbe v = pStmt; + sqlite3 db = v.db; +#if SQLITE_THREADSAFE + sqlite3_mutex mutex; #endif - if (vdbeSafety(v)) - return SQLITE_MISUSE_BKPT(); + if ( vdbeSafety( v ) ) + return SQLITE_MISUSE_BKPT(); #if SQLITE_THREADSAFE - mutex = v.db.mutex; + mutex = v.db.mutex; #endif - sqlite3_mutex_enter(mutex); - rc = sqlite3VdbeFinalize(ref v); - rc = sqlite3ApiExit(db, rc); - sqlite3_mutex_leave(mutex); - } - return rc; - } + sqlite3_mutex_enter( mutex ); + rc = sqlite3VdbeFinalize( ref v ); + rc = sqlite3ApiExit( db, rc ); + sqlite3_mutex_leave( mutex ); + } + return rc; + } - /* - ** Terminate the current execution of an SQL statement and reset it - ** back to its starting state so that it can be reused. A success code from - ** the prior execution is returned. - ** - ** This routine sets the error code and string returned by - ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16(). - */ - public static int sqlite3_reset(sqlite3_stmt pStmt) { - int rc; - if (pStmt == null) { - rc = SQLITE_OK; - } else { - Vdbe v = (Vdbe)pStmt; - sqlite3_mutex_enter(v.db.mutex); - rc = sqlite3VdbeReset(v); - sqlite3VdbeRewind(v); - Debug.Assert((rc & (v.db.errMask)) == rc); - rc = sqlite3ApiExit(v.db, rc); - sqlite3_mutex_leave(v.db.mutex); - } - return rc; - } + /* + ** Terminate the current execution of an SQL statement and reset it + ** back to its starting state so that it can be reused. A success code from + ** the prior execution is returned. + ** + ** This routine sets the error code and string returned by + ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16(). + */ + public static int sqlite3_reset( sqlite3_stmt pStmt ) + { + int rc; + if ( pStmt == null ) + { + rc = SQLITE_OK; + } + else + { + Vdbe v = (Vdbe)pStmt; + sqlite3_mutex_enter( v.db.mutex ); + rc = sqlite3VdbeReset( v ); + sqlite3VdbeRewind( v ); + Debug.Assert( ( rc & ( v.db.errMask ) ) == rc ); + rc = sqlite3ApiExit( v.db, rc ); + sqlite3_mutex_leave( v.db.mutex ); + } + return rc; + } - /* - ** Set all the parameters in the compiled SQL statement to NULL. - */ - public static int sqlite3_clear_bindings(sqlite3_stmt pStmt) { - int i; - int rc = SQLITE_OK; - Vdbe p = (Vdbe)pStmt; -#if SQLITE_THREADSAFE - sqlite3_mutex mutex = ((Vdbe)pStmt).db.mutex; + /* + ** Set all the parameters in the compiled SQL statement to NULL. + */ + public static int sqlite3_clear_bindings( sqlite3_stmt pStmt ) + { + int i; + int rc = SQLITE_OK; + Vdbe p = (Vdbe)pStmt; +#if SQLITE_THREADSAFE + sqlite3_mutex mutex = ( (Vdbe)pStmt ).db.mutex; #endif - sqlite3_mutex_enter(mutex); - for (i = 0; i < p.nVar; i++) { - sqlite3VdbeMemRelease(p.aVar[i]); - p.aVar[i].flags = MEM_Null; - } - if (p.isPrepareV2 && p.expmask != 0) { - p.expired = true; - } - sqlite3_mutex_leave(mutex); - return rc; - } + sqlite3_mutex_enter( mutex ); + for ( i = 0; i < p.nVar; i++ ) + { + sqlite3VdbeMemRelease( p.aVar[i] ); + p.aVar[i].flags = MEM_Null; + } + if ( p.isPrepareV2 && p.expmask != 0 ) + { + p.expired = true; + } + sqlite3_mutex_leave( mutex ); + return rc; + } - /**************************** sqlite3_value_ ******************************* - ** The following routines extract information from a Mem or sqlite3_value - ** structure. - */ - public static byte[] sqlite3_value_blob(sqlite3_value pVal) { - Mem p = pVal; - if ((p.flags & (MEM_Blob | MEM_Str)) != 0) { - sqlite3VdbeMemExpandBlob(p); - if (p.zBLOB == null && p.z != null) { - if (p.z.Length == 0) - p.zBLOB = sqlite3Malloc(1); - else { - p.zBLOB = sqlite3Malloc(p.z.Length); - Debug.Assert(p.zBLOB.Length == p.z.Length); - for (int i = 0; i < p.zBLOB.Length; i++) - p.zBLOB[i] = (u8)p.z[i]; - } - p.z = null; - } - p.flags = (u16)(p.flags & ~MEM_Str); - p.flags |= MEM_Blob; - return p.n > 0 ? p.zBLOB : null; - } else { - return sqlite3_value_text(pVal) == null ? null : Encoding.UTF8.GetBytes(sqlite3_value_text(pVal)); - } - } + /**************************** sqlite3_value_ ******************************* + ** The following routines extract information from a Mem or sqlite3_value + ** structure. + */ + public static byte[] sqlite3_value_blob( sqlite3_value pVal ) + { + Mem p = pVal; + if ( ( p.flags & ( MEM_Blob | MEM_Str ) ) != 0 ) + { + sqlite3VdbeMemExpandBlob( p ); + if ( p.zBLOB == null && p.z != null ) + { + if ( p.z.Length == 0 ) + p.zBLOB = sqlite3Malloc( 1 ); + else + { + p.zBLOB = sqlite3Malloc( p.z.Length ); + Debug.Assert( p.zBLOB.Length == p.z.Length ); + for ( int i = 0; i < p.zBLOB.Length; i++ ) + p.zBLOB[i] = (u8)p.z[i]; + } + p.z = null; + } + p.flags = (u16)( p.flags & ~MEM_Str ); + p.flags |= MEM_Blob; + return p.n > 0 ? p.zBLOB : null; + } + else + { + return sqlite3_value_text( pVal ) == null ? null : Encoding.UTF8.GetBytes( sqlite3_value_text( pVal ) ); + } + } - public static int sqlite3_value_bytes(sqlite3_value pVal) { - return sqlite3ValueBytes(pVal, SQLITE_UTF8); - } + public static int sqlite3_value_bytes( sqlite3_value pVal ) + { + return sqlite3ValueBytes( pVal, SQLITE_UTF8 ); + } - public static int sqlite3_value_bytes16(sqlite3_value pVal) { - return sqlite3ValueBytes(pVal, SQLITE_UTF16NATIVE); - } + public static int sqlite3_value_bytes16( sqlite3_value pVal ) + { + return sqlite3ValueBytes( pVal, SQLITE_UTF16NATIVE ); + } - public static double sqlite3_value_double(sqlite3_value pVal) { - return sqlite3VdbeRealValue(pVal); - } + public static double sqlite3_value_double( sqlite3_value pVal ) + { + return sqlite3VdbeRealValue( pVal ); + } - public static int sqlite3_value_int(sqlite3_value pVal) { - return (int)sqlite3VdbeIntValue(pVal); - } + public static int sqlite3_value_int( sqlite3_value pVal ) + { + return (int)sqlite3VdbeIntValue( pVal ); + } - public static sqlite_int64 sqlite3_value_int64(sqlite3_value pVal) { - return sqlite3VdbeIntValue(pVal); - } + public static sqlite_int64 sqlite3_value_int64( sqlite3_value pVal ) + { + return sqlite3VdbeIntValue( pVal ); + } - public static string sqlite3_value_text(sqlite3_value pVal) { - return sqlite3ValueText(pVal, SQLITE_UTF8); - } + public static string sqlite3_value_text( sqlite3_value pVal ) + { + return sqlite3ValueText( pVal, SQLITE_UTF8 ); + } -#if !SQLITE_OMIT_UTF16 +#if !SQLITE_OMIT_UTF16 public static string sqlite3_value_text16(sqlite3_value pVal){ return sqlite3ValueText(pVal, SQLITE_UTF16NATIVE); } @@ -221,65 +255,73 @@ public static string sqlite3_value_text16le(sqlite3_value pVal){ } #endif // * SQLITE_OMIT_UTF16 */ - public static int sqlite3_value_type(sqlite3_value pval) { - return pval.type; - } + public static int sqlite3_value_type( sqlite3_value pval ) + { + return pval.type; + } - /**************************** sqlite3_result_ ******************************* - ** The following routines are used by user-defined functions to specify - ** the function result. - ** - ** The setStrOrError() funtion calls sqlite3VdbeMemSetStr() to store the - ** result as a string or blob but if the string or blob is too large, it - ** then sets the error code to SQLITE_TOOBIG - */ - static void setResultStrOrError( - sqlite3_context pCtx, /* Function context */ - string z, /* String pointer */ - int o, /* offset into string */ - int n, /* Bytes in string, or negative */ - u8 enc, /* Encoding of z. 0 for BLOBs */ - dxDel xDel //void (*xDel)(void) /* Destructor function */ - ) { - if (sqlite3VdbeMemSetStr(pCtx.s, z, o, n, enc, xDel) == SQLITE_TOOBIG) { - sqlite3_result_error_toobig(pCtx); - } - } - static void setResultStrOrError( - sqlite3_context pCtx, /* Function context */ - string z, /* String pointer */ - int n, /* Bytes in string, or negative */ - u8 enc, /* Encoding of z. 0 for BLOBs */ - dxDel xDel //void (*xDel)(void) /* Destructor function */ - ) { - if (sqlite3VdbeMemSetStr(pCtx.s, z, n, enc, xDel) == SQLITE_TOOBIG) { - sqlite3_result_error_toobig(pCtx); - } - } + /**************************** sqlite3_result_ ******************************* + ** The following routines are used by user-defined functions to specify + ** the function result. + ** + ** The setStrOrError() funtion calls sqlite3VdbeMemSetStr() to store the + ** result as a string or blob but if the string or blob is too large, it + ** then sets the error code to SQLITE_TOOBIG + */ + static void setResultStrOrError( + sqlite3_context pCtx, /* Function context */ + string z, /* String pointer */ + int o, /* offset into string */ + int n, /* Bytes in string, or negative */ + u8 enc, /* Encoding of z. 0 for BLOBs */ + dxDel xDel //void (*xDel)(void) /* Destructor function */ + ) + { + if ( sqlite3VdbeMemSetStr( pCtx.s, z, o, n, enc, xDel ) == SQLITE_TOOBIG ) + { + sqlite3_result_error_toobig( pCtx ); + } + } + static void setResultStrOrError( + sqlite3_context pCtx, /* Function context */ + string z, /* String pointer */ + int n, /* Bytes in string, or negative */ + u8 enc, /* Encoding of z. 0 for BLOBs */ + dxDel xDel //void (*xDel)(void) /* Destructor function */ + ) + { + if ( sqlite3VdbeMemSetStr( pCtx.s, z, n, enc, xDel ) == SQLITE_TOOBIG ) + { + sqlite3_result_error_toobig( pCtx ); + } + } - public static void sqlite3_result_blob( - sqlite3_context pCtx, - string z, - int n, - dxDel xDel - ) { - Debug.Assert(n >= 0); - Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); - setResultStrOrError(pCtx, z, n, 0, xDel); - } + public static void sqlite3_result_blob( + sqlite3_context pCtx, + string z, + int n, + dxDel xDel + ) + { + Debug.Assert( n >= 0 ); + Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); + setResultStrOrError( pCtx, z, n, 0, xDel ); + } - public static void sqlite3_result_double(sqlite3_context pCtx, double rVal) { - Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); - sqlite3VdbeMemSetDouble(pCtx.s, rVal); - } + public static void sqlite3_result_double( sqlite3_context pCtx, double rVal ) + { + Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); + sqlite3VdbeMemSetDouble( pCtx.s, rVal ); + } - public static void sqlite3_result_error(sqlite3_context pCtx, string z, int n) { - Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); - setResultStrOrError(pCtx, z, n, SQLITE_UTF8, SQLITE_TRANSIENT); - pCtx.isError = SQLITE_ERROR; - } + public static void sqlite3_result_error( sqlite3_context pCtx, string z, int n ) + { + Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); + setResultStrOrError( pCtx, z, n, SQLITE_UTF8, SQLITE_TRANSIENT ); + pCtx.isError = SQLITE_ERROR; + } -#if !SQLITE_OMIT_UTF16 +#if !SQLITE_OMIT_UTF16 //void sqlite3_result_error16(sqlite3_context pCtx, string z, int n){ // Debug.Assert( sqlite3_mutex_held(pCtx.s.db.mutex) ); // pCtx.isError = SQLITE_ERROR; @@ -287,53 +329,59 @@ public static void sqlite3_result_error(sqlite3_context pCtx, string z, int n) { //} #endif - public static void sqlite3_result_int(sqlite3_context pCtx, int iVal) { - Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); - sqlite3VdbeMemSetInt64(pCtx.s, (i64)iVal); - } + public static void sqlite3_result_int( sqlite3_context pCtx, int iVal ) + { + Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); + sqlite3VdbeMemSetInt64( pCtx.s, (i64)iVal ); + } - public static void sqlite3_result_int64(sqlite3_context pCtx, i64 iVal) { - Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); - sqlite3VdbeMemSetInt64(pCtx.s, iVal); - } + public static void sqlite3_result_int64( sqlite3_context pCtx, i64 iVal ) + { + Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); + sqlite3VdbeMemSetInt64( pCtx.s, iVal ); + } - public static void sqlite3_result_null(sqlite3_context pCtx) { - Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); - sqlite3VdbeMemSetNull(pCtx.s); - } + public static void sqlite3_result_null( sqlite3_context pCtx ) + { + Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); + sqlite3VdbeMemSetNull( pCtx.s ); + } - public static void sqlite3_result_text( - sqlite3_context pCtx, - string z, - int o, //Offset - int n, - dxDel xDel - ) { - Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); - setResultStrOrError(pCtx, z, o, n, SQLITE_UTF8, xDel); - } + public static void sqlite3_result_text( + sqlite3_context pCtx, + string z, + int o, //Offset + int n, + dxDel xDel + ) + { + Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); + setResultStrOrError( pCtx, z, o, n, SQLITE_UTF8, xDel ); + } - public static void sqlite3_result_text( - sqlite3_context pCtx, - StringBuilder z, - int n, - dxDel xDel - ) { - Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); - setResultStrOrError(pCtx, z.ToString(), n, SQLITE_UTF8, xDel); - } + public static void sqlite3_result_text( + sqlite3_context pCtx, + StringBuilder z, + int n, + dxDel xDel + ) + { + Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); + setResultStrOrError( pCtx, z.ToString(), n, SQLITE_UTF8, xDel ); + } - public static void sqlite3_result_text( - sqlite3_context pCtx, - string z, - int n, - dxDel xDel - ) { - Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); - setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel); - } -#if !SQLITE_OMIT_UTF16 + public static void sqlite3_result_text( + sqlite3_context pCtx, + string z, + int n, + dxDel xDel + ) + { + Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); + setResultStrOrError( pCtx, z, n, SQLITE_UTF8, xDel ); + } +#if !SQLITE_OMIT_UTF16 void sqlite3_result_text16( sqlite3_context pCtx, string z, @@ -363,47 +411,54 @@ dxDel xDel } #endif // * SQLITE_OMIT_UTF16 */ - public static void sqlite3_result_value(sqlite3_context pCtx, sqlite3_value pValue) { - Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); - sqlite3VdbeMemCopy(pCtx.s, pValue); - } + public static void sqlite3_result_value( sqlite3_context pCtx, sqlite3_value pValue ) + { + Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); + sqlite3VdbeMemCopy( pCtx.s, pValue ); + } - public static void sqlite3_result_zeroblob(sqlite3_context pCtx, int n) { - Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); - sqlite3VdbeMemSetZeroBlob(pCtx.s, n); - } + public static void sqlite3_result_zeroblob( sqlite3_context pCtx, int n ) + { + Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); + sqlite3VdbeMemSetZeroBlob( pCtx.s, n ); + } - public static void sqlite3_result_error_code(sqlite3_context pCtx, int errCode) { - pCtx.isError = errCode; - if ((pCtx.s.flags & MEM_Null) != 0) { - setResultStrOrError(pCtx, sqlite3ErrStr(errCode), -1, - SQLITE_UTF8, SQLITE_STATIC); - } - } + public static void sqlite3_result_error_code( sqlite3_context pCtx, int errCode ) + { + pCtx.isError = errCode; + if ( ( pCtx.s.flags & MEM_Null ) != 0 ) + { + setResultStrOrError( pCtx, sqlite3ErrStr( errCode ), -1, + SQLITE_UTF8, SQLITE_STATIC ); + } + } - /* Force an SQLITE_TOOBIG error. */ + /* Force an SQLITE_TOOBIG error. */ - public static void sqlite3_result_error_toobig(sqlite3_context pCtx) { - Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); - pCtx.isError = SQLITE_ERROR; - setResultStrOrError(pCtx, "string or blob too big", -1, - SQLITE_UTF8, SQLITE_STATIC); - } + public static void sqlite3_result_error_toobig( sqlite3_context pCtx ) + { + Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); + pCtx.isError = SQLITE_ERROR; + setResultStrOrError( pCtx, "string or blob too big", -1, + SQLITE_UTF8, SQLITE_STATIC ); + } - /* An SQLITE_NOMEM error. */ - public static void sqlite3_result_error_nomem(sqlite3_context pCtx) { - Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); - sqlite3VdbeMemSetNull(pCtx.s); - pCtx.isError = SQLITE_NOMEM; - //pCtx.s.db.mallocFailed = 1; - } + /* An SQLITE_NOMEM error. */ + public static void sqlite3_result_error_nomem( sqlite3_context pCtx ) + { + Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); + sqlite3VdbeMemSetNull( pCtx.s ); + pCtx.isError = SQLITE_NOMEM; + //pCtx.s.db.mallocFailed = 1; + } - /* - ** This function is called after a transaction has been committed. It - ** invokes callbacks registered with sqlite3_wal_hook() as required. - */ - static int doWalCallbacks(sqlite3 db) { - int rc = SQLITE_OK; + /* + ** This function is called after a transaction has been committed. It + ** invokes callbacks registered with sqlite3_wal_hook() as required. + */ + static int doWalCallbacks( sqlite3 db ) + { + int rc = SQLITE_OK; #if !SQLITE_OMIT_WAL int i; for(i=0; inDb; i++){ @@ -416,39 +471,41 @@ static int doWalCallbacks(sqlite3 db) { } } #endif - return rc; - } - /* - ** Execute the statement pStmt, either until a row of data is ready, the - ** statement is completely executed or an error occurs. + return rc; + } + /* + ** Execute the statement pStmt, either until a row of data is ready, the + ** statement is completely executed or an error occurs. + ** + ** This routine implements the bulk of the logic behind the sqlite_step() + ** API. The only thing omitted is the automatic recompile if a + ** schema change has occurred. That detail is handled by the + ** outer sqlite3_step() wrapper procedure. + */ + static int sqlite3Step( Vdbe p ) + { + sqlite3 db; + int rc; + + Debug.Assert( p != null ); + if ( p.magic != VDBE_MAGIC_RUN ) + { + /* We used to require that sqlite3_reset() be called before retrying + ** sqlite3_step() after any error or after SQLITE_DONE. But beginning + ** with version 3.7.0, we changed this so that sqlite3_reset() would + ** be called automatically instead of throwing the SQLITE_MISUSE error. + ** This "automatic-reset" change is not technically an incompatibility, + ** since any application that receives an SQLITE_MISUSE is broken by + ** definition. ** - ** This routine implements the bulk of the logic behind the sqlite_step() - ** API. The only thing omitted is the automatic recompile if a - ** schema change has occurred. That detail is handled by the - ** outer sqlite3_step() wrapper procedure. + ** Nevertheless, some published applications that were originally written + ** for version 3.6.23 or earlier do in fact depend on SQLITE_MISUSE + ** returns, and the so were broken by the automatic-reset change. As a + ** a work-around, the SQLITE_OMIT_AUTORESET compile-time restores the + ** legacy behavior of returning SQLITE_MISUSE for cases where the + ** previous sqlite3_step() returned something other than a SQLITE_LOCKED + ** or SQLITE_BUSY error. */ - static int sqlite3Step(Vdbe p) { - sqlite3 db; - int rc; - - Debug.Assert(p != null); - if (p.magic != VDBE_MAGIC_RUN) { - /* We used to require that sqlite3_reset() be called before retrying - ** sqlite3_step() after any error or after SQLITE_DONE. But beginning - ** with version 3.7.0, we changed this so that sqlite3_reset() would - ** be called automatically instead of throwing the SQLITE_MISUSE error. - ** This "automatic-reset" change is not technically an incompatibility, - ** since any application that receives an SQLITE_MISUSE is broken by - ** definition. - ** - ** Nevertheless, some published applications that were originally written - ** for version 3.6.23 or earlier do in fact depend on SQLITE_MISUSE - ** returns, and the so were broken by the automatic-reset change. As a - ** a work-around, the SQLITE_OMIT_AUTORESET compile-time restores the - ** legacy behavior of returning SQLITE_MISUSE for cases where the - ** previous sqlite3_step() returned something other than a SQLITE_LOCKED - ** or SQLITE_BUSY error. - */ #if SQLITE_OMIT_AUTORESET if( p.rc==SQLITE_BUSY || p.rc==SQLITE_LOCKED ){ sqlite3_reset((sqlite3_stmt)p); @@ -456,298 +513,330 @@ static int sqlite3Step(Vdbe p) { return SQLITE_MISUSE_BKPT(); } #else - sqlite3_reset((sqlite3_stmt)p); + sqlite3_reset( (sqlite3_stmt)p ); #endif - } + } + + /* Check that malloc() has not failed. If it has, return early. */ + db = p.db; + //if ( db.mallocFailed != 0 ) + //{ + //p->rc = SQLITE_NOMEM; + // return SQLITE_NOMEM; + //} + + if ( p.pc <= 0 && p.expired ) + { + p.rc = SQLITE_SCHEMA; + rc = SQLITE_ERROR; + goto end_of_step; + } + if ( p.pc < 0 ) + { + /* If there are no other statements currently running, then + ** reset the interrupt flag. This prevents a call to sqlite3_interrupt + ** from interrupting a statement that has not yet started. + */ + if ( db.activeVdbeCnt == 0 ) + { + db.u1.isInterrupted = false; + } - /* Check that malloc() has not failed. If it has, return early. */ - db = p.db; - //if ( db.mallocFailed != 0 ) - //{ - //p->rc = SQLITE_NOMEM; - // return SQLITE_NOMEM; - //} - - if (p.pc <= 0 && p.expired) { - p.rc = SQLITE_SCHEMA; - rc = SQLITE_ERROR; - goto end_of_step; - } - if (p.pc < 0) { - /* If there are no other statements currently running, then - ** reset the interrupt flag. This prevents a call to sqlite3_interrupt - ** from interrupting a statement that has not yet started. - */ - if (db.activeVdbeCnt == 0) { - db.u1.isInterrupted = false; - } - - Debug.Assert(db.writeVdbeCnt > 0 || db.autoCommit == 0 || db.nDeferredCons == 0); -#if !SQLITE_OMIT_TRACE - if (db.xProfile != null && 0 == db.init.busy) { - sqlite3OsCurrentTimeInt64(db.pVfs, ref p.startTime); - } + Debug.Assert( db.writeVdbeCnt > 0 || db.autoCommit == 0 || db.nDeferredCons == 0 ); +#if !SQLITE_OMIT_TRACE + if ( db.xProfile != null && 0 == db.init.busy ) + { + sqlite3OsCurrentTimeInt64( db.pVfs, ref p.startTime ); + } #endif - db.activeVdbeCnt++; - if (p.readOnly == false) - db.writeVdbeCnt++; - p.pc = 0; - } -#if !SQLITE_OMIT_EXPLAIN - if (p.explain != 0) { - rc = sqlite3VdbeList(p); - } else + db.activeVdbeCnt++; + if ( p.readOnly == false ) + db.writeVdbeCnt++; + p.pc = 0; + } +#if !SQLITE_OMIT_EXPLAIN + if ( p.explain != 0 ) + { + rc = sqlite3VdbeList( p ); + } + else #endif // * SQLITE_OMIT_EXPLAIN */ - { + { - db.vdbeExecCnt++; - rc = sqlite3VdbeExec(p); - db.vdbeExecCnt--; - } + db.vdbeExecCnt++; + rc = sqlite3VdbeExec( p ); + db.vdbeExecCnt--; + } -#if !SQLITE_OMIT_TRACE - /* Invoke the profile callback if there is one - */ - if (rc != SQLITE_ROW && db.xProfile != null && 0 == db.init.busy && p.zSql != null) { - sqlite3_int64 iNow = 0; - sqlite3OsCurrentTimeInt64(db.pVfs, ref iNow); - db.xProfile(db.pProfileArg, p.zSql, (iNow - p.startTime) * 1000000); - } +#if !SQLITE_OMIT_TRACE + /* Invoke the profile callback if there is one +*/ + if ( rc != SQLITE_ROW && db.xProfile != null && 0 == db.init.busy && p.zSql != null ) + { + sqlite3_int64 iNow = 0; + sqlite3OsCurrentTimeInt64( db.pVfs, ref iNow ); + db.xProfile( db.pProfileArg, p.zSql, ( iNow - p.startTime ) * 1000000 ); + } #endif - if (rc == SQLITE_DONE) { - Debug.Assert(p.rc == SQLITE_OK); - p.rc = doWalCallbacks(db); - if (p.rc != SQLITE_OK) { - rc = SQLITE_ERROR; - } - } - - db.errCode = rc; - if (SQLITE_NOMEM == sqlite3ApiExit(p.db, p.rc)) { - p.rc = SQLITE_NOMEM; - } - end_of_step: - /* At this point local variable rc holds the value that should be - ** returned if this statement was compiled using the legacy - ** sqlite3_prepare() interface. According to the docs, this can only - ** be one of the values in the first Debug.Assert() below. Variable p.rc - ** contains the value that would be returned if sqlite3_finalize() - ** were called on statement p. - */ - Debug.Assert(rc == SQLITE_ROW || rc == SQLITE_DONE || rc == SQLITE_ERROR - || rc == SQLITE_BUSY || rc == SQLITE_MISUSE - ); - Debug.Assert(p.rc != SQLITE_ROW && p.rc != SQLITE_DONE); - if (p.isPrepareV2 && rc != SQLITE_ROW && rc != SQLITE_DONE) { - /* If this statement was prepared using sqlite3_prepare_v2(), and an - ** error has occured, then return the error code in p.rc to the - ** caller. Set the error code in the database handle to the same value. - */ - rc = db.errCode = p.rc; - } - return (rc & db.errMask); - } - - /* - ** The maximum number of times that a statement will try to reparse - ** itself before giving up and returning SQLITE_SCHEMA. + if ( rc == SQLITE_DONE ) + { + Debug.Assert( p.rc == SQLITE_OK ); + p.rc = doWalCallbacks( db ); + if ( p.rc != SQLITE_OK ) + { + rc = SQLITE_ERROR; + } + } + + db.errCode = rc; + if ( SQLITE_NOMEM == sqlite3ApiExit( p.db, p.rc ) ) + { + p.rc = SQLITE_NOMEM; + } +end_of_step: + /* At this point local variable rc holds the value that should be + ** returned if this statement was compiled using the legacy + ** sqlite3_prepare() interface. According to the docs, this can only + ** be one of the values in the first Debug.Assert() below. Variable p.rc + ** contains the value that would be returned if sqlite3_finalize() + ** were called on statement p. + */ + Debug.Assert( rc == SQLITE_ROW || rc == SQLITE_DONE || rc == SQLITE_ERROR + || rc == SQLITE_BUSY || rc == SQLITE_MISUSE + ); + Debug.Assert( p.rc != SQLITE_ROW && p.rc != SQLITE_DONE ); + if ( p.isPrepareV2 && rc != SQLITE_ROW && rc != SQLITE_DONE ) + { + /* If this statement was prepared using sqlite3_prepare_v2(), and an + ** error has occured, then return the error code in p.rc to the + ** caller. Set the error code in the database handle to the same value. */ + rc = db.errCode = p.rc; + } + return ( rc & db.errMask ); + } + +/* +** The maximum number of times that a statement will try to reparse +** itself before giving up and returning SQLITE_SCHEMA. +*/ #if !SQLITE_MAX_SCHEMA_RETRY - //# define SQLITE_MAX_SCHEMA_RETRY 5 - public const int SQLITE_MAX_SCHEMA_RETRY = 5; +//# define SQLITE_MAX_SCHEMA_RETRY 5 + public const int SQLITE_MAX_SCHEMA_RETRY = 5; #endif - /* - ** This is the top-level implementation of sqlite3_step(). Call - ** sqlite3Step() to do most of the work. If a schema error occurs, - ** call sqlite3Reprepare() and try again. - */ - public static int sqlite3_step(sqlite3_stmt pStmt) { - int rc = SQLITE_OK; /* Result from sqlite3Step() */ - int rc2 = SQLITE_OK; /* Result from sqlite3Reprepare() */ - Vdbe v = (Vdbe)pStmt; /* the prepared statement */ - int cnt = 0; /* Counter to prevent infinite loop of reprepares */ - sqlite3 db; /* The database connection */ - - if (vdbeSafetyNotNull(v)) { - return SQLITE_MISUSE_BKPT(); - } - db = v.db; - sqlite3_mutex_enter(db.mutex); - while ((rc = sqlite3Step(v)) == SQLITE_SCHEMA - && cnt++ < SQLITE_MAX_SCHEMA_RETRY - && (rc2 = rc = sqlite3Reprepare(v)) == SQLITE_OK) { - sqlite3_reset(pStmt); - v.expired = false; - } - if (rc2 != SQLITE_OK && ALWAYS(v.isPrepareV2) && ALWAYS(db.pErr != null)) { - /* This case occurs after failing to recompile an sql statement. - ** The error message from the SQL compiler has already been loaded - ** into the database handle. This block copies the error message - ** from the database handle into the statement and sets the statement - ** program counter to 0 to ensure that when the statement is - ** finalized or reset the parser error message is available via - ** sqlite3_errmsg() and sqlite3_errcode(). - */ - string zErr = sqlite3_value_text(db.pErr); - sqlite3DbFree(db, ref v.zErrMsg); - //if ( 0 == db.mallocFailed ) - { - v.zErrMsg = zErr;// sqlite3DbStrDup(db, zErr); - v.rc = rc2; - } - //else - //{ - // v.zErrMsg = ""; - // v->rc = rc = SQLITE_NOMEM; - //} - } - 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. - ** - ** IMPLEMENTATION-OF: R-46798-50301 The sqlite3_context_db_handle() interface - ** returns a copy of the pointer to the database connection (the 1st - ** parameter) of the sqlite3_create_function() and - ** sqlite3_create_function16() routines that originally registered the - ** application defined function. - */ - public static object sqlite3_user_data(sqlite3_context p) { - Debug.Assert(p != null && p.pFunc != null); - return p.pFunc.pUserData; - } - - /* - ** Extract the user data from a sqlite3_context structure and return a - ** pointer to it. - */ - public static sqlite3 sqlite3_context_db_handle(sqlite3_context p) { - Debug.Assert(p != null && p.pFunc != null); - return p.s.db; - } - - /* - ** 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 - ** for name resolution but are actually overloaded by the xFindFunction - ** method of virtual tables. + /* + ** This is the top-level implementation of sqlite3_step(). Call + ** sqlite3Step() to do most of the work. If a schema error occurs, + ** call sqlite3Reprepare() and try again. + */ + public static int sqlite3_step( sqlite3_stmt pStmt ) + { + int rc = SQLITE_OK; /* Result from sqlite3Step() */ + int rc2 = SQLITE_OK; /* Result from sqlite3Reprepare() */ + Vdbe v = (Vdbe)pStmt; /* the prepared statement */ + int cnt = 0; /* Counter to prevent infinite loop of reprepares */ + sqlite3 db; /* The database connection */ + + if ( vdbeSafetyNotNull( v ) ) + { + return SQLITE_MISUSE_BKPT(); + } + db = v.db; + sqlite3_mutex_enter( db.mutex ); + while ( ( rc = sqlite3Step( v ) ) == SQLITE_SCHEMA + && cnt++ < SQLITE_MAX_SCHEMA_RETRY + && ( rc2 = rc = sqlite3Reprepare( v ) ) == SQLITE_OK ) + { + sqlite3_reset( pStmt ); + v.expired = false; + } + if ( rc2 != SQLITE_OK && ALWAYS( v.isPrepareV2 ) && ALWAYS( db.pErr != null ) ) + { + /* This case occurs after failing to recompile an sql statement. + ** The error message from the SQL compiler has already been loaded + ** into the database handle. This block copies the error message + ** from the database handle into the statement and sets the statement + ** program counter to 0 to ensure that when the statement is + ** finalized or reset the parser error message is available via + ** sqlite3_errmsg() and sqlite3_errcode(). */ - public static void sqlite3InvalidFunction( - sqlite3_context context, /* The function calling context */ - int NotUsed, /* Number of arguments to the function */ - sqlite3_value[] NotUsed2 /* Value of each argument */ - ) { - string zName = context.pFunc.zName; - string zErr; - UNUSED_PARAMETER2(NotUsed, NotUsed2); - zErr = sqlite3_mprintf( - "unable to use function %s in the requested context", zName); - sqlite3_result_error(context, zErr, -1); - //sqlite3_free( ref zErr ); - } + string zErr = sqlite3_value_text( db.pErr ); + sqlite3DbFree( db, ref v.zErrMsg ); + //if ( 0 == db.mallocFailed ) + { + v.zErrMsg = zErr;// sqlite3DbStrDup(db, zErr); + v.rc = rc2; + } + //else + //{ + // v.zErrMsg = ""; + // v->rc = rc = SQLITE_NOMEM; + //} + } + rc = sqlite3ApiExit( db, rc ); + sqlite3_mutex_leave( db.mutex ); + return rc; + } - /* - ** Allocate or return the aggregate context for a user function. A new - ** context is allocated on the first call. Subsequent calls return the - ** same context that was returned on prior calls. - */ - public static Mem sqlite3_aggregate_context(sqlite3_context p, int nByte) { - Mem pMem; - Debug.Assert(p != null && p.pFunc != null && p.pFunc.xStep != null); - Debug.Assert(sqlite3_mutex_held(p.s.db.mutex)); - pMem = p.pMem; - testcase(nByte < 0); - if ((pMem.flags & MEM_Agg) == 0) { - if (nByte <= 0) { - sqlite3VdbeMemReleaseExternal(pMem); - pMem.flags = 0; - pMem.z = null; - } else { - sqlite3VdbeMemGrow(pMem, nByte, 0); - pMem.flags = MEM_Agg; - pMem.u.pDef = p.pFunc; - if (pMem.z != null) { - pMem.z = null; - } - pMem._Mem = sqlite3Malloc(pMem._Mem); - pMem._Mem.flags = 0; - pMem._Mem.z = null; - } - } - return pMem._Mem; - } + /* + ** Extract the user data from a sqlite3_context structure and return a + ** pointer to it. + ** + ** IMPLEMENTATION-OF: R-46798-50301 The sqlite3_context_db_handle() interface + ** returns a copy of the pointer to the database connection (the 1st + ** parameter) of the sqlite3_create_function() and + ** sqlite3_create_function16() routines that originally registered the + ** application defined function. + */ + public static object sqlite3_user_data( sqlite3_context p ) + { + Debug.Assert( p != null && p.pFunc != null ); + return p.pFunc.pUserData; + } - /* - ** Return the auxillary data pointer, if any, for the iArg'th argument to - ** the user-function defined by pCtx. - */ - public static object sqlite3_get_auxdata(sqlite3_context pCtx, int iArg) { - VdbeFunc pVdbeFunc; + /* + ** Extract the user data from a sqlite3_context structure and return a + ** pointer to it. + */ + public static sqlite3 sqlite3_context_db_handle( sqlite3_context p ) + { + Debug.Assert( p != null && p.pFunc != null ); + return p.s.db; + } - Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); - pVdbeFunc = pCtx.pVdbeFunc; - if (null == pVdbeFunc || iArg >= pVdbeFunc.nAux || iArg < 0) { - return null; - } - return pVdbeFunc.apAux[iArg].pAux; - } + /* + ** 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 + ** for name resolution but are actually overloaded by the xFindFunction + ** method of virtual tables. + */ + public static void sqlite3InvalidFunction( + sqlite3_context context, /* The function calling context */ + int NotUsed, /* Number of arguments to the function */ + sqlite3_value[] NotUsed2 /* Value of each argument */ + ) + { + string zName = context.pFunc.zName; + string zErr; + UNUSED_PARAMETER2( NotUsed, NotUsed2 ); + zErr = sqlite3_mprintf( + "unable to use function %s in the requested context", zName ); + sqlite3_result_error( context, zErr, -1 ); + //sqlite3_free( ref zErr ); + } - /* - ** Set the auxillary data pointer and delete function, for the iArg'th - ** argument to the user-function defined by pCtx. Any previous value is - ** deleted by calling the delete function specified when it was set. - */ - public static void sqlite3_set_auxdata( - sqlite3_context pCtx, - int iArg, - object pAux - //void (*xDelete)(void) - ) { - AuxData pAuxData; - VdbeFunc pVdbeFunc; - if (iArg < 0) - goto failed; - - Debug.Assert(sqlite3_mutex_held(pCtx.s.db.mutex)); - pVdbeFunc = pCtx.pVdbeFunc; - if (null == pVdbeFunc || pVdbeFunc.nAux <= iArg) { - int nAux = (pVdbeFunc != null ? pVdbeFunc.nAux : 0); - ////int nMalloc = iArg; - ////VdbeFunc+ sizeof(struct AuxData)*iArg; - if (pVdbeFunc == null) { - //pVdbeFunc = (VdbeFunc)sqlite3DbRealloc( pCtx.s.db, pVdbeFunc, nMalloc ); - pVdbeFunc = new VdbeFunc(); - if (null == pVdbeFunc) { - goto failed; - } - pCtx.pVdbeFunc = pVdbeFunc; - } - pVdbeFunc.apAux[nAux] = new AuxData();//memset(pVdbeFunc.apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux)); - pVdbeFunc.nAux = iArg + 1; - pVdbeFunc.pFunc = pCtx.pFunc; - } + /* + ** Allocate or return the aggregate context for a user function. A new + ** context is allocated on the first call. Subsequent calls return the + ** same context that was returned on prior calls. + */ + public static Mem sqlite3_aggregate_context( sqlite3_context p, int nByte ) + { + Mem pMem; + Debug.Assert( p != null && p.pFunc != null && p.pFunc.xStep != null ); + Debug.Assert( sqlite3_mutex_held( p.s.db.mutex ) ); + pMem = p.pMem; + testcase( nByte < 0 ); + if ( ( pMem.flags & MEM_Agg ) == 0 ) + { + if ( nByte <= 0 ) + { + sqlite3VdbeMemReleaseExternal( pMem ); + pMem.flags = 0; + pMem.z = null; + } + else + { + sqlite3VdbeMemGrow( pMem, nByte, 0 ); + pMem.flags = MEM_Agg; + pMem.u.pDef = p.pFunc; + if ( pMem.z != null ) + { + pMem.z = null; + } + pMem._Mem = sqlite3Malloc( pMem._Mem ); + pMem._Mem.flags = 0; + pMem._Mem.z = null; + } + } + return pMem._Mem; + } - pAuxData = pVdbeFunc.apAux[iArg]; - if (pAuxData.pAux != null && pAuxData.pAux is IDisposable) { - (pAuxData.pAux as IDisposable).Dispose(); - } - pAuxData.pAux = pAux; - return; + /* + ** Return the auxillary data pointer, if any, for the iArg'th argument to + ** the user-function defined by pCtx. + */ + public static object sqlite3_get_auxdata( sqlite3_context pCtx, int iArg ) + { + VdbeFunc pVdbeFunc; + + Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); + pVdbeFunc = pCtx.pVdbeFunc; + if ( null == pVdbeFunc || iArg >= pVdbeFunc.nAux || iArg < 0 ) + { + return null; + } + return pVdbeFunc.apAux[iArg].pAux; + } - failed: - if (pAux != null && pAux is IDisposable) { - (pAux as IDisposable).Dispose(); - } - } + /* + ** Set the auxillary data pointer and delete function, for the iArg'th + ** argument to the user-function defined by pCtx. Any previous value is + ** deleted by calling the delete function specified when it was set. + */ + public static void sqlite3_set_auxdata( + sqlite3_context pCtx, + int iArg, + object pAux + //void (*xDelete)(void) + ) + { + AuxData pAuxData; + VdbeFunc pVdbeFunc; + if ( iArg < 0 ) + goto failed; + + Debug.Assert( sqlite3_mutex_held( pCtx.s.db.mutex ) ); + pVdbeFunc = pCtx.pVdbeFunc; + if ( null == pVdbeFunc || pVdbeFunc.nAux <= iArg ) + { + int nAux = ( pVdbeFunc != null ? pVdbeFunc.nAux : 0 ); + ////int nMalloc = iArg; + ////VdbeFunc+ sizeof(struct AuxData)*iArg; + if ( pVdbeFunc == null ) + { + //pVdbeFunc = (VdbeFunc)sqlite3DbRealloc( pCtx.s.db, pVdbeFunc, nMalloc ); + pVdbeFunc = new VdbeFunc(); + if ( null == pVdbeFunc ) + { + goto failed; + } + pCtx.pVdbeFunc = pVdbeFunc; + } + pVdbeFunc.apAux[nAux] = new AuxData();//memset(pVdbeFunc.apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux)); + pVdbeFunc.nAux = iArg + 1; + pVdbeFunc.pFunc = pCtx.pFunc; + } + + pAuxData = pVdbeFunc.apAux[iArg]; + if ( pAuxData.pAux != null && pAuxData.pAux is IDisposable ) + { + (pAuxData.pAux as IDisposable).Dispose(); + } + pAuxData.pAux = pAux; + return; + +failed: + if ( pAux != null && pAux is IDisposable) + { + (pAux as IDisposable).Dispose(); + } + } #if !SQLITE_OMIT_DEPRECATED /* @@ -766,169 +855,187 @@ static int sqlite3_aggregate_count( sqlite3_context p ) } #endif - /* - ** Return the number of columns in the result set for the statement pStmt. - */ - public static int sqlite3_column_count(sqlite3_stmt pStmt) { - Vdbe pVm = pStmt; - return pVm != null ? (int)pVm.nResColumn : 0; - } + /* +** Return the number of columns in the result set for the statement pStmt. +*/ + public static int sqlite3_column_count( sqlite3_stmt pStmt ) + { + Vdbe pVm = pStmt; + return pVm != null ? (int)pVm.nResColumn : 0; + } - /* - ** Return the number of values available from the current row of the - ** currently executing statement pStmt. - */ - public static int sqlite3_data_count(sqlite3_stmt pStmt) { - Vdbe pVm = pStmt; - if (pVm == null || pVm.pResultSet == null) - return 0; - return pVm.nResColumn; - } + /* + ** Return the number of values available from the current row of the + ** currently executing statement pStmt. + */ + public static int sqlite3_data_count( sqlite3_stmt pStmt ) + { + Vdbe pVm = pStmt; + if ( pVm == null || pVm.pResultSet == null ) + return 0; + return pVm.nResColumn; + } - /* - ** Check to see if column iCol of the given statement is valid. If - ** it is, return a pointer to the Mem for the value of that column. - ** If iCol is not valid, return a pointer to a Mem which has a value - ** of NULL. - */ - static Mem columnMem(sqlite3_stmt pStmt, int i) { - Vdbe pVm; - Mem pOut; - - pVm = (Vdbe)pStmt; - if (pVm != null && pVm.pResultSet != null && i < pVm.nResColumn && i >= 0) { - sqlite3_mutex_enter(pVm.db.mutex); - pOut = pVm.pResultSet[i]; - } else { - /* If the value passed as the second argument is out of range, return - ** a pointer to the following public static Mem object which contains the - ** value SQL NULL. Even though the Mem structure contains an element - ** of type i64, on certain architecture (x86) with certain compiler - ** switches (-Os), gcc may align this Mem object on a 4-byte boundary - ** instead of an 8-byte one. This all works fine, except that when - ** running with SQLITE_DEBUG defined the SQLite code sometimes Debug.Assert()s - ** that a Mem structure is located on an 8-byte boundary. To prevent - ** this Debug.Assert() from failing, when building with SQLITE_DEBUG defined - ** using gcc, force nullMem to be 8-byte aligned using the magical - ** __attribute__((aligned(8))) macro. */ - // static const Mem nullMem - //#if defined(SQLITE_DEBUG) && defined(__GNUC__) - // __attribute__((aligned(8))) - //#endif - // = {0, "", (double)0, {0}, 0, MEM_Null, SQLITE_NULL, 0, - //#if SQLITE_DEBUG - // 0, 0, /* pScopyFrom, pFiller */ - //#endif - // 0, 0 }; - Mem nullMem = new Mem(null, "", (double)0, 0, 0, MEM_Null, SQLITE_NULL, 0 + /* + ** Check to see if column iCol of the given statement is valid. If + ** it is, return a pointer to the Mem for the value of that column. + ** If iCol is not valid, return a pointer to a Mem which has a value + ** of NULL. + */ + static Mem columnMem( sqlite3_stmt pStmt, int i ) + { + Vdbe pVm; + Mem pOut; + + pVm = (Vdbe)pStmt; + if ( pVm != null && pVm.pResultSet != null && i < pVm.nResColumn && i >= 0 ) + { + sqlite3_mutex_enter( pVm.db.mutex ); + pOut = pVm.pResultSet[i]; + } + else + { + /* If the value passed as the second argument is out of range, return + ** a pointer to the following public static Mem object which contains the + ** value SQL NULL. Even though the Mem structure contains an element + ** of type i64, on certain architecture (x86) with certain compiler + ** switches (-Os), gcc may align this Mem object on a 4-byte boundary + ** instead of an 8-byte one. This all works fine, except that when + ** running with SQLITE_DEBUG defined the SQLite code sometimes Debug.Assert()s + ** that a Mem structure is located on an 8-byte boundary. To prevent + ** this Debug.Assert() from failing, when building with SQLITE_DEBUG defined + ** using gcc, force nullMem to be 8-byte aligned using the magical + ** __attribute__((aligned(8))) macro. */ + // static const Mem nullMem + //#if defined(SQLITE_DEBUG) && defined(__GNUC__) + // __attribute__((aligned(8))) + //#endif + // = {0, "", (double)0, {0}, 0, MEM_Null, SQLITE_NULL, 0, + //#if SQLITE_DEBUG + // 0, 0, /* pScopyFrom, pFiller */ + //#endif + // 0, 0 }; + Mem nullMem = new Mem( null, "", (double)0, 0, 0, MEM_Null, SQLITE_NULL, 0 #if SQLITE_DEBUG - , null, null /* pScopyFrom, pFiller */ + , null, null /* pScopyFrom, pFiller */ #endif - ); + ); - if (pVm != null && ALWAYS(pVm.db != null)) { - sqlite3_mutex_enter(pVm.db.mutex); - sqlite3Error(pVm.db, SQLITE_RANGE, 0); - } - pOut = nullMem; - } - return pOut; + if ( pVm != null && ALWAYS( pVm.db != null ) ) + { + sqlite3_mutex_enter( pVm.db.mutex ); + sqlite3Error( pVm.db, SQLITE_RANGE, 0 ); } + pOut = nullMem; + } + return pOut; + } - /* - ** This function is called after invoking an sqlite3_value_XXX function on a - ** column value (i.e. a value returned by evaluating an SQL expression in the - ** select list of a SELECT statement) that may cause a malloc() failure. If - ** malloc() has failed, the threads mallocFailed flag is cleared and the result - ** code of statement pStmt set to SQLITE_NOMEM. - ** - ** Specifically, this is called from within: - ** - ** sqlite3_column_int() - ** sqlite3_column_int64() - ** sqlite3_column_text() - ** sqlite3_column_text16() - ** sqlite3_column_real() - ** sqlite3_column_bytes() - ** sqlite3_column_bytes16() - ** sqlite3_column_blob() - */ - static void columnMallocFailure(sqlite3_stmt pStmt) { - /* If malloc() failed during an encoding conversion within an - ** sqlite3_column_XXX API, then set the return code of the statement to - ** SQLITE_NOMEM. The next call to _step() (if any) will return SQLITE_ERROR - ** and _finalize() will return NOMEM. - */ - Vdbe p = pStmt; - if (p != null) { - p.rc = sqlite3ApiExit(p.db, p.rc); - sqlite3_mutex_leave(p.db.mutex); - } - } + /* + ** This function is called after invoking an sqlite3_value_XXX function on a + ** column value (i.e. a value returned by evaluating an SQL expression in the + ** select list of a SELECT statement) that may cause a malloc() failure. If + ** malloc() has failed, the threads mallocFailed flag is cleared and the result + ** code of statement pStmt set to SQLITE_NOMEM. + ** + ** Specifically, this is called from within: + ** + ** sqlite3_column_int() + ** sqlite3_column_int64() + ** sqlite3_column_text() + ** sqlite3_column_text16() + ** sqlite3_column_real() + ** sqlite3_column_bytes() + ** sqlite3_column_bytes16() + ** sqlite3_column_blob() + */ + static void columnMallocFailure( sqlite3_stmt pStmt ) + { + /* If malloc() failed during an encoding conversion within an + ** sqlite3_column_XXX API, then set the return code of the statement to + ** SQLITE_NOMEM. The next call to _step() (if any) will return SQLITE_ERROR + ** and _finalize() will return NOMEM. + */ + Vdbe p = pStmt; + if ( p != null ) + { + p.rc = sqlite3ApiExit( p.db, p.rc ); + sqlite3_mutex_leave( p.db.mutex ); + } + } - /**************************** sqlite3_column_ ******************************* - ** The following routines are used to access elements of the current row - ** in the result set. - */ - public static byte[] sqlite3_column_blob(sqlite3_stmt pStmt, int i) { - byte[] val; - val = sqlite3_value_blob(columnMem(pStmt, i)); - /* Even though there is no encoding conversion, value_blob() might - ** need to call malloc() to expand the result of a zeroblob() - ** expression. - */ - columnMallocFailure(pStmt); - return val; - } + /**************************** sqlite3_column_ ******************************* + ** The following routines are used to access elements of the current row + ** in the result set. + */ + public static byte[] sqlite3_column_blob( sqlite3_stmt pStmt, int i ) + { + byte[] val; + val = sqlite3_value_blob( columnMem( pStmt, i ) ); + /* Even though there is no encoding conversion, value_blob() might + ** need to call malloc() to expand the result of a zeroblob() + ** expression. + */ + columnMallocFailure( pStmt ); + return val; + } - public static int sqlite3_column_bytes(sqlite3_stmt pStmt, int i) { - int val = sqlite3_value_bytes(columnMem(pStmt, i)); - columnMallocFailure(pStmt); - return val; - } + public static int sqlite3_column_bytes( sqlite3_stmt pStmt, int i ) + { + int val = sqlite3_value_bytes( columnMem( pStmt, i ) ); + columnMallocFailure( pStmt ); + return val; + } - public static int sqlite3_column_bytes16(sqlite3_stmt pStmt, int i) { - int val = sqlite3_value_bytes16(columnMem(pStmt, i)); - columnMallocFailure(pStmt); - return val; - } + public static int sqlite3_column_bytes16( sqlite3_stmt pStmt, int i ) + { + int val = sqlite3_value_bytes16( columnMem( pStmt, i ) ); + columnMallocFailure( pStmt ); + return val; + } - public static double sqlite3_column_double(sqlite3_stmt pStmt, int i) { - double val = sqlite3_value_double(columnMem(pStmt, i)); - columnMallocFailure(pStmt); - return val; - } + public static double sqlite3_column_double( sqlite3_stmt pStmt, int i ) + { + double val = sqlite3_value_double( columnMem( pStmt, i ) ); + columnMallocFailure( pStmt ); + return val; + } - public static int sqlite3_column_int(sqlite3_stmt pStmt, int i) { - int val = sqlite3_value_int(columnMem(pStmt, i)); - columnMallocFailure(pStmt); - return val; - } + public static int sqlite3_column_int( sqlite3_stmt pStmt, int i ) + { + int val = sqlite3_value_int( columnMem( pStmt, i ) ); + columnMallocFailure( pStmt ); + return val; + } - public static sqlite_int64 sqlite3_column_int64(sqlite3_stmt pStmt, int i) { - sqlite_int64 val = sqlite3_value_int64(columnMem(pStmt, i)); - columnMallocFailure(pStmt); - return val; - } + public static sqlite_int64 sqlite3_column_int64( sqlite3_stmt pStmt, int i ) + { + sqlite_int64 val = sqlite3_value_int64( columnMem( pStmt, i ) ); + columnMallocFailure( pStmt ); + return val; + } - public static string sqlite3_column_text(sqlite3_stmt pStmt, int i) { - string val = sqlite3_value_text(columnMem(pStmt, i)); - columnMallocFailure(pStmt); - return val; - } + public static string sqlite3_column_text( sqlite3_stmt pStmt, int i ) + { + string val = sqlite3_value_text( columnMem( pStmt, i ) ); + columnMallocFailure( pStmt ); + return val; + } - public static sqlite3_value sqlite3_column_value(sqlite3_stmt pStmt, int i) { - Mem pOut = columnMem(pStmt, i); - if ((pOut.flags & MEM_Static) != 0) { - pOut.flags = (u16)(pOut.flags & ~MEM_Static); - pOut.flags |= MEM_Ephem; - } - columnMallocFailure(pStmt); - return (sqlite3_value)pOut; - } -#if !SQLITE_OMIT_UTF16 + public static sqlite3_value sqlite3_column_value( sqlite3_stmt pStmt, int i ) + { + Mem pOut = columnMem( pStmt, i ); + if ( ( pOut.flags & MEM_Static ) != 0 ) + { + pOut.flags = (u16)( pOut.flags & ~MEM_Static ); + pOut.flags |= MEM_Ephem; + } + columnMallocFailure( pStmt ); + return (sqlite3_value)pOut; + } +#if !SQLITE_OMIT_UTF16 //const void *sqlite3_column_text16(sqlite3_stmt pStmt, int i){ // const void *val = sqlite3_value_text16( columnMem(pStmt,i) ); // columnMallocFailure(pStmt); @@ -936,101 +1043,106 @@ public static sqlite3_value sqlite3_column_value(sqlite3_stmt pStmt, int i) { //} #endif // * SQLITE_OMIT_UTF16 */ - public static int sqlite3_column_type(sqlite3_stmt pStmt, int i) { - int iType = sqlite3_value_type(columnMem(pStmt, i)); - columnMallocFailure(pStmt); - return iType; - } + public static int sqlite3_column_type( sqlite3_stmt pStmt, int i ) + { + int iType = sqlite3_value_type( columnMem( pStmt, i ) ); + columnMallocFailure( pStmt ); + return iType; + } - /* The following function is experimental and subject to change or - ** removal */ - /*int sqlite3_column_numeric_type(sqlite3_stmt pStmt, int i){ - ** return sqlite3_value_numeric_type( columnMem(pStmt,i) ); - **} - */ + /* The following function is experimental and subject to change or + ** removal */ + /*int sqlite3_column_numeric_type(sqlite3_stmt pStmt, int i){ + ** return sqlite3_value_numeric_type( columnMem(pStmt,i) ); + **} + */ - /* - ** Convert the N-th element of pStmt.pColName[] into a string using - ** xFunc() then return that string. If N is out of range, return 0. - ** - ** There are up to 5 names for each column. useType determines which - ** name is returned. Here are the names: - ** - ** 0 The column name as it should be displayed for output - ** 1 The datatype name for the column - ** 2 The name of the database that the column derives from - ** 3 The name of the table that the column derives from - ** 4 The name of the table column that the result column derives from - ** - ** If the result is not a simple column reference (if it is an expression - ** or a constant) then useTypes 2, 3, and 4 return NULL. + /* + ** Convert the N-th element of pStmt.pColName[] into a string using + ** xFunc() then return that string. If N is out of range, return 0. + ** + ** There are up to 5 names for each column. useType determines which + ** name is returned. Here are the names: + ** + ** 0 The column name as it should be displayed for output + ** 1 The datatype name for the column + ** 2 The name of the database that the column derives from + ** 3 The name of the table that the column derives from + ** 4 The name of the table column that the result column derives from + ** + ** If the result is not a simple column reference (if it is an expression + ** or a constant) then useTypes 2, 3, and 4 return NULL. + */ + public static string columnName( + sqlite3_stmt pStmt, + int N, + dxColname xFunc, + int useType + ) + { + string ret = null; + Vdbe p = pStmt; + int n; + sqlite3 db = p.db; + + Debug.Assert( db != null ); + + n = sqlite3_column_count( pStmt ); + if ( N < n && N >= 0 ) + { + N += useType * n; + sqlite3_mutex_enter( db.mutex ); + //Debug.Assert( db.mallocFailed == 0 ); + ret = xFunc( p.aColName[N] ); + + /* A malloc may have failed inside of the xFunc() call. If this + ** is the case, clear the mallocFailed flag and return NULL. */ - public static string columnName( - sqlite3_stmt pStmt, - int N, - dxColname xFunc, - int useType - ) { - string ret = null; - Vdbe p = pStmt; - int n; - sqlite3 db = p.db; - - Debug.Assert(db != null); - - n = sqlite3_column_count(pStmt); - if (N < n && N >= 0) { - N += useType * n; - sqlite3_mutex_enter(db.mutex); - //Debug.Assert( db.mallocFailed == 0 ); - ret = xFunc(p.aColName[N]); - - /* A malloc may have failed inside of the xFunc() call. If this - ** is the case, clear the mallocFailed flag and return NULL. - */ - //if ( db.mallocFailed != 0 ) - //{ - // //db.mallocFailed = 0; - // ret = null; - //} - sqlite3_mutex_leave(db.mutex); - } - return ret; - } + //if ( db.mallocFailed != 0 ) + //{ + // //db.mallocFailed = 0; + // ret = null; + //} + sqlite3_mutex_leave( db.mutex ); + } + return ret; + } - /* - ** Return the name of the Nth column of the result set returned by SQL - ** statement pStmt. - */ - public static string sqlite3_column_name(sqlite3_stmt pStmt, int N) { - return columnName( - pStmt, N, sqlite3_value_text, COLNAME_NAME); - } -#if !SQLITE_OMIT_UTF16 + /* + ** Return the name of the Nth column of the result set returned by SQL + ** statement pStmt. + */ + public static string sqlite3_column_name( sqlite3_stmt pStmt, int N ) + { + return columnName( + pStmt, N, sqlite3_value_text, COLNAME_NAME ); + } +#if !SQLITE_OMIT_UTF16 public static string sqlite3_column_name16(sqlite3_stmt pStmt, int N){ return columnName( pStmt, N, sqlite3_value_text16, COLNAME_NAME); } #endif - /* - ** Constraint: If you have ENABLE_COLUMN_METADATA then you must - ** not define OMIT_DECLTYPE. - */ + /* +** Constraint: If you have ENABLE_COLUMN_METADATA then you must +** not define OMIT_DECLTYPE. +*/ #if SQLITE_OMIT_DECLTYPE && SQLITE_ENABLE_COLUMN_METADATA -#error "Must not define both SQLITE_OMIT_DECLTYPE and SQLITE_ENABLE_COLUMN_METADATA" +# error "Must not define both SQLITE_OMIT_DECLTYPE and SQLITE_ENABLE_COLUMN_METADATA" #endif #if !SQLITE_OMIT_DECLTYPE - /* - ** Return the column declaration type (if applicable) of the 'i'th column - ** of the result set of SQL statement pStmt. - */ - public static string sqlite3_column_decltype(sqlite3_stmt pStmt, int N) { - return columnName( - pStmt, N, sqlite3_value_text, COLNAME_DECLTYPE); - } -#if !SQLITE_OMIT_UTF16 + /* +** Return the column declaration type (if applicable) of the 'i'th column +** of the result set of SQL statement pStmt. +*/ + public static string sqlite3_column_decltype( sqlite3_stmt pStmt, int N ) + { + return columnName( + pStmt, N, sqlite3_value_text, COLNAME_DECLTYPE ); + } +#if !SQLITE_OMIT_UTF16 //const void *sqlite3_column_decltype16(sqlite3_stmt pStmt, int N){ // return columnName( // pStmt, N, (const void*()(Mem))sqlite3_value_text16, COLNAME_DECLTYPE); @@ -1038,17 +1150,18 @@ public static string sqlite3_column_decltype(sqlite3_stmt pStmt, int N) { #endif // * SQLITE_OMIT_UTF16 */ #endif // * SQLITE_OMIT_DECLTYPE */ -#if SQLITE_ENABLE_COLUMN_METADATA +#if SQLITE_ENABLE_COLUMN_METADATA - /* - ** Return the name of the database from which a result column derives. - ** NULL is returned if the result column is an expression or constant or - ** anything else which is not an unabiguous reference to a database column. - */ - public static string sqlite3_column_database_name(sqlite3_stmt pStmt, int N) { - return columnName( - pStmt, N, sqlite3_value_text, COLNAME_DATABASE); - } +/* +** Return the name of the database from which a result column derives. +** NULL is returned if the result column is an expression or constant or +** anything else which is not an unabiguous reference to a database column. +*/ + public static string sqlite3_column_database_name( sqlite3_stmt pStmt, int N ) + { + return columnName( + pStmt, N, sqlite3_value_text, COLNAME_DATABASE ); + } #if !SQLITE_OMIT_UTF16 const void *sqlite3_column_database_name16(sqlite3_stmt pStmt, int N){ return columnName( @@ -1056,15 +1169,16 @@ public static string sqlite3_column_database_name(sqlite3_stmt pStmt, int N) { } #endif //* SQLITE_OMIT_UTF16 */ - /* - ** Return the name of the table from which a result column derives. - ** NULL is returned if the result column is an expression or constant or - ** anything else which is not an unabiguous reference to a database column. - */ - public static string sqlite3_column_table_name(sqlite3_stmt pStmt, int N) { - return columnName( - pStmt, N, sqlite3_value_text, COLNAME_TABLE); - } +/* +** Return the name of the table from which a result column derives. +** NULL is returned if the result column is an expression or constant or +** anything else which is not an unabiguous reference to a database column. +*/ + public static string sqlite3_column_table_name( sqlite3_stmt pStmt, int N ) + { + return columnName( + pStmt, N, sqlite3_value_text, COLNAME_TABLE ); + } #if !SQLITE_OMIT_UTF16 const void *sqlite3_column_table_name16(sqlite3_stmt pStmt, int N){ return columnName( @@ -1072,15 +1186,16 @@ public static string sqlite3_column_table_name(sqlite3_stmt pStmt, int N) { } #endif //* SQLITE_OMIT_UTF16 */ - /* - ** Return the name of the table column from which a result column derives. - ** NULL is returned if the result column is an expression or constant or - ** anything else which is not an unabiguous reference to a database column. - */ - public static string sqlite3_column_origin_name(sqlite3_stmt pStmt, int N) { - return columnName( - pStmt, N, sqlite3_value_text, COLNAME_COLUMN); - } +/* +** Return the name of the table column from which a result column derives. +** NULL is returned if the result column is an expression or constant or +** anything else which is not an unabiguous reference to a database column. +*/ + public static string sqlite3_column_origin_name( sqlite3_stmt pStmt, int N ) + { + return columnName( + pStmt, N, sqlite3_value_text, COLNAME_COLUMN ); + } #if !SQLITE_OMIT_UTF16 const void *sqlite3_column_origin_name16(sqlite3_stmt pStmt, int N){ return columnName( @@ -1090,184 +1205,208 @@ public static string sqlite3_column_origin_name(sqlite3_stmt pStmt, int N) { #endif // * SQLITE_ENABLE_COLUMN_METADATA */ - /******************************* sqlite3_bind_ *************************** + /******************************* sqlite3_bind_ *************************** +** +** Routines used to attach values to wildcards in a compiled SQL statement. +*/ + /* + ** Unbind the value bound to variable i in virtual machine p. This is the + ** the same as binding a NULL value to the column. If the "i" parameter is + ** out of range, then SQLITE_RANGE is returned. Othewise SQLITE_OK. + ** + ** A successful evaluation of this routine acquires the mutex on p. + ** the mutex is released if any kind of error occurs. ** - ** Routines used to attach values to wildcards in a compiled SQL statement. + ** The error code stored in database p.db is overwritten with the return + ** value in any case. */ - /* - ** Unbind the value bound to variable i in virtual machine p. This is the - ** the same as binding a NULL value to the column. If the "i" parameter is - ** out of range, then SQLITE_RANGE is returned. Othewise SQLITE_OK. - ** - ** A successful evaluation of this routine acquires the mutex on p. - ** the mutex is released if any kind of error occurs. - ** - ** The error code stored in database p.db is overwritten with the return - ** value in any case. - */ - public static int vdbeUnbind(Vdbe p, int i) { - Mem pVar; - if (vdbeSafetyNotNull(p)) { - return SQLITE_MISUSE_BKPT(); - } - sqlite3_mutex_enter(p.db.mutex); - if (p.magic != VDBE_MAGIC_RUN || p.pc >= 0) { - sqlite3Error(p.db, SQLITE_MISUSE, 0); - sqlite3_mutex_leave(p.db.mutex); - sqlite3_log(SQLITE_MISUSE, - "bind on a busy prepared statement: [%s]", p.zSql); - return SQLITE_MISUSE_BKPT(); - } - if (i < 1 || i > p.nVar) { - sqlite3Error(p.db, SQLITE_RANGE, 0); - sqlite3_mutex_leave(p.db.mutex); - return SQLITE_RANGE; - } - i--; - pVar = p.aVar[i]; - sqlite3VdbeMemRelease(pVar); - pVar.flags = MEM_Null; - sqlite3Error(p.db, SQLITE_OK, 0); - - /* If the bit corresponding to this variable in Vdbe.expmask is set, then - ** binding a new value to this variable invalidates the current query plan. - ** - ** IMPLEMENTATION-OF: R-48440-37595 If the specific value bound to host - ** parameter in the WHERE clause might influence the choice of query plan - ** for a statement, then the statement will be automatically recompiled, - ** as if there had been a schema change, on the first sqlite3_step() call - ** following any change to the bindings of that parameter. - */ - if (p.isPrepareV2 && - ((i < 32 && p.expmask != 0 & ((u32)1 << i) != 0) || p.expmask == 0xffffffff) - ) { - p.expired = true; - } - - return SQLITE_OK; - } + public static int vdbeUnbind( Vdbe p, int i ) + { + Mem pVar; + if ( vdbeSafetyNotNull( p ) ) + { + return SQLITE_MISUSE_BKPT(); + } + sqlite3_mutex_enter( p.db.mutex ); + if ( p.magic != VDBE_MAGIC_RUN || p.pc >= 0 ) + { + sqlite3Error( p.db, SQLITE_MISUSE, 0 ); + sqlite3_mutex_leave( p.db.mutex ); + sqlite3_log( SQLITE_MISUSE, + "bind on a busy prepared statement: [%s]", p.zSql ); + return SQLITE_MISUSE_BKPT(); + } + if ( i < 1 || i > p.nVar ) + { + sqlite3Error( p.db, SQLITE_RANGE, 0 ); + sqlite3_mutex_leave( p.db.mutex ); + return SQLITE_RANGE; + } + i--; + pVar = p.aVar[i]; + sqlite3VdbeMemRelease( pVar ); + pVar.flags = MEM_Null; + sqlite3Error( p.db, SQLITE_OK, 0 ); + + /* If the bit corresponding to this variable in Vdbe.expmask is set, then + ** binding a new value to this variable invalidates the current query plan. + ** + ** IMPLEMENTATION-OF: R-48440-37595 If the specific value bound to host + ** parameter in the WHERE clause might influence the choice of query plan + ** for a statement, then the statement will be automatically recompiled, + ** as if there had been a schema change, on the first sqlite3_step() call + ** following any change to the bindings of that parameter. + */ + if ( p.isPrepareV2 && + ( ( i < 32 && p.expmask != 0 & ( (u32)1 << i ) != 0 ) || p.expmask == 0xffffffff ) + ) + { + p.expired = true; + } + + return SQLITE_OK; + } - /* - ** Bind a text or BLOB value. - */ - static int bindBlob( - sqlite3_stmt pStmt, /* The statement to bind against */ - int i, /* Index of the parameter to bind */ - byte[] zData, /* Pointer to the data to be bound */ - int nData, /* Number of bytes of data to be bound */ - dxDel xDel, /* Destructor for the data */ - u8 encoding /* Encoding for the data */ - ) { - Vdbe p = pStmt; - Mem pVar; - int rc; - - rc = vdbeUnbind(p, i); - if (rc == SQLITE_OK) { - if (zData != null) { - pVar = p.aVar[i - 1]; - rc = sqlite3VdbeMemSetBlob(pVar, zData, nData, encoding, xDel); - if (rc == SQLITE_OK && encoding != 0) { - rc = sqlite3VdbeChangeEncoding(pVar, ENC(p.db)); - } - sqlite3Error(p.db, rc, 0); - rc = sqlite3ApiExit(p.db, rc); - } - sqlite3_mutex_leave(p.db.mutex); - } - return rc; - } + /* + ** Bind a text or BLOB value. + */ + static int bindBlob( + sqlite3_stmt pStmt, /* The statement to bind against */ + int i, /* Index of the parameter to bind */ + byte[] zData, /* Pointer to the data to be bound */ + int nData, /* Number of bytes of data to be bound */ + dxDel xDel, /* Destructor for the data */ + u8 encoding /* Encoding for the data */ + ) + { + Vdbe p = pStmt; + Mem pVar; + int rc; + + rc = vdbeUnbind( p, i ); + if ( rc == SQLITE_OK ) + { + if ( zData != null ) + { + pVar = p.aVar[i - 1]; + rc = sqlite3VdbeMemSetBlob( pVar, zData, nData, encoding, xDel ); + if ( rc == SQLITE_OK && encoding != 0 ) + { + rc = sqlite3VdbeChangeEncoding( pVar, ENC( p.db ) ); + } + sqlite3Error( p.db, rc, 0 ); + rc = sqlite3ApiExit( p.db, rc ); + } + sqlite3_mutex_leave( p.db.mutex ); + } + return rc; + } - /* - ** Bind a text value. - */ - public static int bindText( - sqlite3_stmt pStmt, /* The statement to bind against */ - int i, /* Index of the parameter to bind */ - string zData, /* Pointer to the data to be bound */ - int nData, /* Number of bytes of data to be bound */ - dxDel xDel, /* Destructor for the data */ - u8 encoding /* Encoding for the data */ - ) { - Vdbe p = pStmt; - Mem pVar; - int rc; - - rc = vdbeUnbind(p, i); - if (rc == SQLITE_OK) { - if (zData != null) { - pVar = p.aVar[i - 1]; - rc = sqlite3VdbeMemSetStr(pVar, zData, nData, encoding, xDel); - if (rc == SQLITE_OK && encoding != 0) { - rc = sqlite3VdbeChangeEncoding(pVar, ENC(p.db)); - } - sqlite3Error(p.db, rc, 0); - rc = sqlite3ApiExit(p.db, rc); - } - sqlite3_mutex_leave(p.db.mutex); - } else if (xDel != SQLITE_STATIC && xDel != SQLITE_TRANSIENT) { - xDel(ref zData); - } - return rc; - } + /* + ** Bind a text value. + */ + public static int bindText( + sqlite3_stmt pStmt, /* The statement to bind against */ + int i, /* Index of the parameter to bind */ + string zData, /* Pointer to the data to be bound */ + int nData, /* Number of bytes of data to be bound */ + dxDel xDel, /* Destructor for the data */ + u8 encoding /* Encoding for the data */ + ) + { + Vdbe p = pStmt; + Mem pVar; + int rc; + + rc = vdbeUnbind( p, i ); + if ( rc == SQLITE_OK ) + { + if ( zData != null ) + { + pVar = p.aVar[i - 1]; + rc = sqlite3VdbeMemSetStr( pVar, zData, nData, encoding, xDel ); + if ( rc == SQLITE_OK && encoding != 0 ) + { + rc = sqlite3VdbeChangeEncoding( pVar, ENC( p.db ) ); + } + sqlite3Error( p.db, rc, 0 ); + rc = sqlite3ApiExit( p.db, rc ); + } + sqlite3_mutex_leave( p.db.mutex ); + } + else if ( xDel != SQLITE_STATIC && xDel != SQLITE_TRANSIENT ) + { + xDel( ref zData ); + } + return rc; + } - public static int sqlite3_bind_double(sqlite3_stmt pStmt, int i, double rValue) { - int rc; - Vdbe p = pStmt; - rc = vdbeUnbind(p, i); - if (rc == SQLITE_OK) { - sqlite3VdbeMemSetDouble(p.aVar[i - 1], rValue); - sqlite3_mutex_leave(p.db.mutex); - } - return rc; - } + public static int sqlite3_bind_double( sqlite3_stmt pStmt, int i, double rValue ) + { + int rc; + Vdbe p = pStmt; + rc = vdbeUnbind( p, i ); + if ( rc == SQLITE_OK ) + { + sqlite3VdbeMemSetDouble( p.aVar[i - 1], rValue ); + sqlite3_mutex_leave( p.db.mutex ); + } + return rc; + } - public static int sqlite3_bind_int(sqlite3_stmt p, int i, int iValue) { - return sqlite3_bind_int64(p, i, (i64)iValue); - } + public static int sqlite3_bind_int( sqlite3_stmt p, int i, int iValue ) + { + return sqlite3_bind_int64( p, i, (i64)iValue ); + } - public static int sqlite3_bind_int64(sqlite3_stmt pStmt, int i, sqlite_int64 iValue) { - int rc; - Vdbe p = pStmt; - rc = vdbeUnbind(p, i); - if (rc == SQLITE_OK) { - sqlite3VdbeMemSetInt64(p.aVar[i - 1], iValue); - sqlite3_mutex_leave(p.db.mutex); - } - return rc; - } + public static int sqlite3_bind_int64( sqlite3_stmt pStmt, int i, sqlite_int64 iValue ) + { + int rc; + Vdbe p = pStmt; + rc = vdbeUnbind( p, i ); + if ( rc == SQLITE_OK ) + { + sqlite3VdbeMemSetInt64( p.aVar[i - 1], iValue ); + sqlite3_mutex_leave( p.db.mutex ); + } + return rc; + } - public static int sqlite3_bind_null(sqlite3_stmt pStmt, int i) { - int rc; - Vdbe p = (Vdbe)pStmt; - rc = vdbeUnbind(p, i); - if (rc == SQLITE_OK) { - sqlite3_mutex_leave(p.db.mutex); - } - return rc; - } + public static int sqlite3_bind_null( sqlite3_stmt pStmt, int i ) + { + int rc; + Vdbe p = (Vdbe)pStmt; + rc = vdbeUnbind( p, i ); + if ( rc == SQLITE_OK ) + { + sqlite3_mutex_leave( p.db.mutex ); + } + return rc; + } - public static int sqlite3_bind_text( - sqlite3_stmt pStmt, - int i, - string zData, - int nData, - dxDel xDel - ) { - return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF8); - } + public static int sqlite3_bind_text( + sqlite3_stmt pStmt, + int i, + string zData, + int nData, + dxDel xDel + ) + { + return bindText( pStmt, i, zData, nData, xDel, SQLITE_UTF8 ); + } - public static int sqlite3_bind_blob( - sqlite3_stmt pStmt, - int i, - byte[] zData, - int nData, - dxDel xDel - ) { - return bindBlob(pStmt, i, zData, nData >= 0 ? nData : zData.Length, xDel, 0); - } + public static int sqlite3_bind_blob( + sqlite3_stmt pStmt, + int i, + byte[] zData, + int nData, + dxDel xDel + ) + { + return bindBlob( pStmt, i, zData, nData >= 0 ? nData : zData.Length, xDel, 0 ); + } -#if !SQLITE_OMIT_UTF16 +#if !SQLITE_OMIT_UTF16 static int sqlite3_bind_text16( sqlite3_stmt pStmt, int i, @@ -1279,114 +1418,136 @@ dxDel xDel } #endif // * SQLITE_OMIT_UTF16 */ - public static int sqlite3_bind_value(sqlite3_stmt pStmt, int i, sqlite3_value pValue) { - int rc; - switch (pValue.type) { - case SQLITE_INTEGER: { - rc = sqlite3_bind_int64(pStmt, i, pValue.u.i); - break; - } - case SQLITE_FLOAT: { - rc = sqlite3_bind_double(pStmt, i, pValue.r); - break; - } - case SQLITE_BLOB: { - if ((pValue.flags & MEM_Zero) != 0) { - rc = sqlite3_bind_zeroblob(pStmt, i, pValue.u.nZero); - } else { - rc = sqlite3_bind_blob(pStmt, i, pValue.zBLOB, pValue.n, SQLITE_TRANSIENT); - } - break; - } - case SQLITE_TEXT: { - rc = bindText(pStmt, i, pValue.z, pValue.n, SQLITE_TRANSIENT, - pValue.enc); - break; - } - default: { - rc = sqlite3_bind_null(pStmt, i); - break; - } + public static int sqlite3_bind_value( sqlite3_stmt pStmt, int i, sqlite3_value pValue ) + { + int rc; + switch ( pValue.type ) + { + case SQLITE_INTEGER: + { + rc = sqlite3_bind_int64( pStmt, i, pValue.u.i ); + break; + } + case SQLITE_FLOAT: + { + rc = sqlite3_bind_double( pStmt, i, pValue.r ); + break; + } + case SQLITE_BLOB: + { + if ( ( pValue.flags & MEM_Zero ) != 0 ) + { + rc = sqlite3_bind_zeroblob( pStmt, i, pValue.u.nZero ); } - return rc; - } - - public static int sqlite3_bind_zeroblob(sqlite3_stmt pStmt, int i, int n) { - int rc; - Vdbe p = pStmt; - rc = vdbeUnbind(p, i); - if (rc == SQLITE_OK) { - sqlite3VdbeMemSetZeroBlob(p.aVar[i - 1], n); - sqlite3_mutex_leave(p.db.mutex); + else + { + rc = sqlite3_bind_blob( pStmt, i, pValue.zBLOB, pValue.n, SQLITE_TRANSIENT ); } - return rc; - } + break; + } + case SQLITE_TEXT: + { + rc = bindText( pStmt, i, pValue.z, pValue.n, SQLITE_TRANSIENT, + pValue.enc ); + break; + } + default: + { + rc = sqlite3_bind_null( pStmt, i ); + break; + } + } + return rc; + } - /* - ** Return the number of wildcards that can be potentially bound to. - ** This routine is added to support DBD::SQLite. - */ - public static int sqlite3_bind_parameter_count(sqlite3_stmt pStmt) { - Vdbe p = (Vdbe)pStmt; - return (p != null) ? (int)p.nVar : 0; - } + public static int sqlite3_bind_zeroblob( sqlite3_stmt pStmt, int i, int n ) + { + int rc; + Vdbe p = pStmt; + rc = vdbeUnbind( p, i ); + if ( rc == SQLITE_OK ) + { + sqlite3VdbeMemSetZeroBlob( p.aVar[i - 1], n ); + sqlite3_mutex_leave( p.db.mutex ); + } + return rc; + } - /* - ** Return the name of a wildcard parameter. Return NULL if the index - ** is out of range or if the wildcard is unnamed. - ** - ** The result is always UTF-8. - */ - public static string sqlite3_bind_parameter_name(sqlite3_stmt pStmt, int i) { - Vdbe p = (Vdbe)pStmt; - if (p == null || i < 1 || i > p.nzVar) { - return ""; - } - return p.azVar[i - 1]; - } + /* + ** Return the number of wildcards that can be potentially bound to. + ** This routine is added to support DBD::SQLite. + */ + public static int sqlite3_bind_parameter_count( sqlite3_stmt pStmt ) + { + Vdbe p = (Vdbe)pStmt; + return ( p != null ) ? (int)p.nVar : 0; + } - /* - ** Given a wildcard parameter name, return the index of the variable - ** with that name. If there is no variable with the given name, - ** return 0. - */ - public static int sqlite3VdbeParameterIndex(Vdbe p, string zName, int nName) { - int i; - if (p == null) { - return 0; - } - if (zName != null && zName != "") { - for (i = 0; i < p.nzVar; i++) { - string z = p.azVar[i]; - if (z != null && z == zName)//&& memcmp(z,zName,nName)==0 && z[nName]==0) - { - return i + 1; - } - } - } - return 0; - } + /* + ** Return the name of a wildcard parameter. Return NULL if the index + ** is out of range or if the wildcard is unnamed. + ** + ** The result is always UTF-8. + */ + public static string sqlite3_bind_parameter_name( sqlite3_stmt pStmt, int i ) + { + Vdbe p = (Vdbe)pStmt; + if ( p == null || i < 1 || i > p.nzVar ) + { + return ""; + } + return p.azVar[i - 1]; + } - public static int sqlite3_bind_parameter_index(sqlite3_stmt pStmt, string zName) { - return sqlite3VdbeParameterIndex((Vdbe)pStmt, zName, sqlite3Strlen30(zName)); - } + /* + ** Given a wildcard parameter name, return the index of the variable + ** with that name. If there is no variable with the given name, + ** return 0. + */ + public static int sqlite3VdbeParameterIndex( Vdbe p, string zName, int nName ) + { + int i; + if ( p == null ) + { + return 0; + } + if ( zName != null && zName != "" ) + { + for ( i = 0; i < p.nzVar; i++ ) + { + string z = p.azVar[i]; + if ( z != null && z == zName )//&& memcmp(z,zName,nName)==0 && z[nName]==0) + { + return i + 1; + } + } + } + return 0; + } - /* - ** Transfer all bindings from the first statement over to the second. - */ - public static int sqlite3TransferBindings(sqlite3_stmt pFromStmt, sqlite3_stmt pToStmt) { - Vdbe pFrom = (Vdbe)pFromStmt; - Vdbe pTo = (Vdbe)pToStmt; - int i; - Debug.Assert(pTo.db == pFrom.db); - Debug.Assert(pTo.nVar == pFrom.nVar); - sqlite3_mutex_enter(pTo.db.mutex); - for (i = 0; i < pFrom.nVar; i++) { - sqlite3VdbeMemMove(pTo.aVar[i], pFrom.aVar[i]); - } - sqlite3_mutex_leave(pTo.db.mutex); - return SQLITE_OK; - } + public static int sqlite3_bind_parameter_index( sqlite3_stmt pStmt, string zName ) + { + return sqlite3VdbeParameterIndex( (Vdbe)pStmt, zName, sqlite3Strlen30( zName ) ); + } + + /* + ** Transfer all bindings from the first statement over to the second. + */ + public static int sqlite3TransferBindings( sqlite3_stmt pFromStmt, sqlite3_stmt pToStmt ) + { + Vdbe pFrom = (Vdbe)pFromStmt; + Vdbe pTo = (Vdbe)pToStmt; + int i; + Debug.Assert( pTo.db == pFrom.db ); + Debug.Assert( pTo.nVar == pFrom.nVar ); + sqlite3_mutex_enter( pTo.db.mutex ); + for ( i = 0; i < pFrom.nVar; i++ ) + { + sqlite3VdbeMemMove( pTo.aVar[i], pFrom.aVar[i] ); + } + sqlite3_mutex_leave( pTo.db.mutex ); + return SQLITE_OK; + } #if !SQLITE_OMIT_DEPRECATED /* @@ -1419,52 +1580,59 @@ static int sqlite3_transfer_bindings( sqlite3_stmt pFromStmt, sqlite3_stmt pToSt } #endif - /* - ** Return the sqlite3* database handle to which the prepared statement given - ** in the argument belongs. This is the same database handle that was - ** the first argument to the sqlite3_prepare() that was used to create - ** the statement in the first place. - */ - public static sqlite3 sqlite3_db_handle(sqlite3_stmt pStmt) { - return pStmt != null ? ((Vdbe)pStmt).db : null; - } + /* +** Return the sqlite3* database handle to which the prepared statement given +** in the argument belongs. This is the same database handle that was +** the first argument to the sqlite3_prepare() that was used to create +** the statement in the first place. +*/ + public static sqlite3 sqlite3_db_handle( sqlite3_stmt pStmt ) + { + return pStmt != null ? ( (Vdbe)pStmt ).db : null; + } - /* - ** Return true if the prepared statement is guaranteed to not modify the - ** database. - */ - static bool sqlite3_stmt_readonly(sqlite3_stmt pStmt) { - return pStmt != null ? ((Vdbe)pStmt).readOnly : true; - } + /* + ** Return true if the prepared statement is guaranteed to not modify the + ** database. + */ + static bool sqlite3_stmt_readonly( sqlite3_stmt pStmt ) + { + return pStmt != null ? ( (Vdbe)pStmt ).readOnly : true; + } - /* - ** Return a pointer to the next prepared statement after pStmt associated - ** with database connection pDb. If pStmt is NULL, return the first - ** prepared statement for the database connection. Return NULL if there - ** are no more. - */ + /* + ** Return a pointer to the next prepared statement after pStmt associated + ** with database connection pDb. If pStmt is NULL, return the first + ** prepared statement for the database connection. Return NULL if there + ** are no more. + */ - public static sqlite3_stmt sqlite3_next_stmt(sqlite3 pDb, sqlite3_stmt pStmt) { - sqlite3_stmt pNext; - sqlite3_mutex_enter(pDb.mutex); - if (pStmt == null) { - pNext = (sqlite3_stmt)pDb.pVdbe; - } else { - pNext = (sqlite3_stmt)((Vdbe)pStmt).pNext; - } - sqlite3_mutex_leave(pDb.mutex); - return pNext; - } - /* - ** Return the value of a status counter for a prepared statement - */ - public static int sqlite3_stmt_status(sqlite3_stmt pStmt, int op, int resetFlag) { - Vdbe pVdbe = (Vdbe)pStmt; - int v = pVdbe.aCounter[op - 1]; - if (resetFlag != 0) - pVdbe.aCounter[op - 1] = 0; - return v; - } + public static sqlite3_stmt sqlite3_next_stmt( sqlite3 pDb, sqlite3_stmt pStmt ) + { + sqlite3_stmt pNext; + sqlite3_mutex_enter( pDb.mutex ); + if ( pStmt == null ) + { + pNext = (sqlite3_stmt)pDb.pVdbe; + } + else + { + pNext = (sqlite3_stmt)( (Vdbe)pStmt ).pNext; + } + sqlite3_mutex_leave( pDb.mutex ); + return pNext; + } + /* + ** Return the value of a status counter for a prepared statement + */ + public static int sqlite3_stmt_status( sqlite3_stmt pStmt, int op, int resetFlag ) + { + Vdbe pVdbe = (Vdbe)pStmt; + int v = pVdbe.aCounter[op - 1]; + if ( resetFlag != 0 ) + pVdbe.aCounter[op - 1] = 0; + return v; } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/vdbeaux_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/vdbeaux_c.cs index a7ae335db..c996b9af9 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/vdbeaux_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/vdbeaux_c.cs @@ -1,4 +1,5 @@ using System.Diagnostics; +using System.IO; using System.Text; using FILE = System.IO.TextWriter; @@ -10,6 +11,8 @@ using u32 = System.UInt32; using u64 = System.UInt64; +using Pgno = System.UInt32; + #if !SQLITE_MAX_VARIABLE_NUMBER using ynVar = System.Int16; #else @@ -27,1248 +30,1425 @@ using yDbMask = System.Int32; #endif -namespace Community.CsharpSqlite { - using System; - - using Op = Sqlite3.VdbeOp; - using sqlite3_stmt = Sqlite3.Vdbe; - using sqlite3_value = Sqlite3.Mem; - - public partial class Sqlite3 { - /* - ** 2003 September 6 - ** - ** 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 contains code used for creating, destroying, and populating - ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.) Prior - ** to version 2.8.7, all this code was combined into the vdbe.c source file. - ** But that file was getting too big so this subroutines were split out. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include "vdbeInt.h" +namespace Community.CsharpSqlite +{ + using Op = Sqlite3.VdbeOp; + using sqlite3_stmt = Sqlite3.Vdbe; + using sqlite3_value = Sqlite3.Mem; + using System; + + public partial class Sqlite3 + { + /* + ** 2003 September 6 + ** + ** 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 contains code used for creating, destroying, and populating + ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.) Prior + ** to version 2.8.7, all this code was combined into the vdbe.c source file. + ** But that file was getting too big so this subroutines were split out. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include "vdbeInt.h" - /* - ** When debugging the code generator in a symbolic debugger, one can - ** set the sqlite3VdbeAddopTrace to 1 and all opcodes will be printed - ** as they are added to the instruction stream. - */ -#if SQLITE_DEBUG - static bool sqlite3VdbeAddopTrace = false; + /* + ** When debugging the code generator in a symbolic debugger, one can + ** set the sqlite3VdbeAddopTrace to 1 and all opcodes will be printed + ** as they are added to the instruction stream. + */ +#if SQLITE_DEBUG + static bool sqlite3VdbeAddopTrace = false; #endif - /* - ** Create a new virtual database engine. - */ - static Vdbe sqlite3VdbeCreate(sqlite3 db) { - Vdbe p; - p = new Vdbe();// sqlite3DbMallocZero(db, Vdbe).Length; - if (p == null) - return null; - p.db = db; - if (db.pVdbe != null) { - db.pVdbe.pPrev = p; - } - p.pNext = db.pVdbe; - p.pPrev = null; - db.pVdbe = p; - p.magic = VDBE_MAGIC_INIT; - return p; - } + /* +** Create a new virtual database engine. +*/ + static Vdbe sqlite3VdbeCreate( sqlite3 db ) + { + Vdbe p; + p = new Vdbe();// sqlite3DbMallocZero(db, Vdbe).Length; + if ( p == null ) + return null; + p.db = db; + if ( db.pVdbe != null ) + { + db.pVdbe.pPrev = p; + } + p.pNext = db.pVdbe; + p.pPrev = null; + db.pVdbe = p; + p.magic = VDBE_MAGIC_INIT; + return p; + } - /* - ** Remember the SQL string for a prepared statement. - */ - static void sqlite3VdbeSetSql(Vdbe p, string z, int n, int isPrepareV2) { - Debug.Assert(isPrepareV2 == 1 || isPrepareV2 == 0); - if (p == null) - return; + /* + ** Remember the SQL string for a prepared statement. + */ + static void sqlite3VdbeSetSql( Vdbe p, string z, int n, int isPrepareV2 ) + { + Debug.Assert( isPrepareV2 == 1 || isPrepareV2 == 0 ); + if ( p == null ) + return; #if SQLITE_OMIT_TRACE if( 0==isPrepareV2 ) return; #endif - Debug.Assert(p.zSql == ""); - p.zSql = z.Substring(0, n);// sqlite3DbStrNDup(p.db, z, n); - p.isPrepareV2 = isPrepareV2 != 0; - } - - /* - ** Return the SQL associated with a prepared statement - */ - static public string sqlite3_sql(sqlite3_stmt pStmt) { - Vdbe p = (Vdbe)pStmt; - return (p != null && p.isPrepareV2 ? p.zSql : ""); - } + Debug.Assert( p.zSql == "" ); + p.zSql = z.Substring( 0, n );// sqlite3DbStrNDup(p.db, z, n); + p.isPrepareV2 = isPrepareV2 != 0; + } - /* - ** Swap all content between two VDBE structures. - */ - static void sqlite3VdbeSwap(Vdbe pA, Vdbe pB) { - Vdbe tmp = new Vdbe(); - Vdbe pTmp = new Vdbe(); - string zTmp; - pA.CopyTo(tmp); - pB.CopyTo(pA); - tmp.CopyTo(pB); - pTmp = pA.pNext; - pA.pNext = pB.pNext; - pB.pNext = pTmp; - pTmp = pA.pPrev; - pA.pPrev = pB.pPrev; - pB.pPrev = pTmp; - zTmp = pA.zSql; - pA.zSql = pB.zSql; - pB.zSql = zTmp; - pB.isPrepareV2 = pA.isPrepareV2; - } + /* + ** Return the SQL associated with a prepared statement + */ + static public string sqlite3_sql( sqlite3_stmt pStmt ) + { + Vdbe p = (Vdbe)pStmt; + return ( p != null && p.isPrepareV2 ? p.zSql : "" ); + } -#if SQLITE_DEBUG - /* - ** Turn tracing on or off + /* + ** Swap all content between two VDBE structures. */ - static void sqlite3VdbeTrace(Vdbe p, FILE trace) { - p.trace = trace; - } + static void sqlite3VdbeSwap( Vdbe pA, Vdbe pB ) + { + Vdbe tmp = new Vdbe(); + Vdbe pTmp = new Vdbe(); + string zTmp; + pA.CopyTo( tmp ); + pB.CopyTo( pA ); + tmp.CopyTo( pB ); + pTmp = pA.pNext; + pA.pNext = pB.pNext; + pB.pNext = pTmp; + pTmp = pA.pPrev; + pA.pPrev = pB.pPrev; + pB.pPrev = pTmp; + zTmp = pA.zSql; + pA.zSql = pB.zSql; + pB.zSql = zTmp; + pB.isPrepareV2 = pA.isPrepareV2; + } + +#if SQLITE_DEBUG + /* +** Turn tracing on or off +*/ + static void sqlite3VdbeTrace( Vdbe p, FILE trace ) + { + p.trace = trace; + } #endif - /* - ** Resize the Vdbe.aOp array so that it is at least one op larger than - ** it was. + /* +** Resize the Vdbe.aOp array so that it is at least one op larger than +** it was. +** +** If an out-of-memory error occurs while resizing the array, return +** SQLITE_NOMEM. In this case Vdbe.aOp and Vdbe.nOpAlloc remain +** unchanged (this is so that any opcodes already allocated can be +** correctly deallocated along with the rest of the Vdbe). +*/ + static int growOpArray( Vdbe p ) + { + //VdbeOp pNew; + int nNew = ( p.nOpAlloc != 0 ? p.nOpAlloc * 2 : 1024 / 4 );//(int)(1024/sizeof(Op))); + // pNew = sqlite3DbRealloc( p.db, p.aOp, nNew * sizeof( Op ) ); + //if (pNew != null) + //{ + // p.nOpAlloc = sqlite3DbMallocSize(p.db, pNew)/sizeof(Op); + // p.aOp = pNew; + //} + p.nOpAlloc = nNew; + if ( p.aOp == null ) + p.aOp = new VdbeOp[nNew]; + else + Array.Resize( ref p.aOp, nNew ); + return ( p.aOp != null ? SQLITE_OK : SQLITE_NOMEM ); // return (pNew ? SQLITE_OK : SQLITE_NOMEM); + } + + /* + ** Add a new instruction to the list of instructions current in the + ** VDBE. Return the address of the new instruction. ** - ** If an out-of-memory error occurs while resizing the array, return - ** SQLITE_NOMEM. In this case Vdbe.aOp and Vdbe.nOpAlloc remain - ** unchanged (this is so that any opcodes already allocated can be - ** correctly deallocated along with the rest of the Vdbe). - */ - static int growOpArray(Vdbe p) { - //VdbeOp pNew; - int nNew = (p.nOpAlloc != 0 ? p.nOpAlloc * 2 : 1024 / 4);//(int)(1024/sizeof(Op))); - // pNew = sqlite3DbRealloc( p.db, p.aOp, nNew * sizeof( Op ) ); - //if (pNew != null) - //{ - // p.nOpAlloc = sqlite3DbMallocSize(p.db, pNew)/sizeof(Op); - // p.aOp = pNew; - //} - p.nOpAlloc = nNew; - if (p.aOp == null) - p.aOp = new VdbeOp[nNew]; - else - Array.Resize(ref p.aOp, nNew); - return (p.aOp != null ? SQLITE_OK : SQLITE_NOMEM); // return (pNew ? SQLITE_OK : SQLITE_NOMEM); + ** Parameters: + ** + ** p Pointer to the VDBE + ** + ** op The opcode for this instruction + ** + ** p1, p2, p3 Operands + ** + ** Use the sqlite3VdbeResolveLabel() function to fix an address and + ** the sqlite3VdbeChangeP4() function to change the value of the P4 + ** operand. + */ + static int sqlite3VdbeAddOp3( Vdbe p, int op, int p1, int p2, int p3 ) + { + int i; + VdbeOp pOp; + + i = p.nOp; + Debug.Assert( p.magic == VDBE_MAGIC_INIT ); + Debug.Assert( op > 0 && op < 0xff ); + if ( p.nOpAlloc <= i ) + { + if ( growOpArray( p ) != 0 ) + { + return 1; } - - /* - ** Add a new instruction to the list of instructions current in the - ** VDBE. Return the address of the new instruction. - ** - ** Parameters: - ** - ** p Pointer to the VDBE - ** - ** op The opcode for this instruction - ** - ** p1, p2, p3 Operands - ** - ** Use the sqlite3VdbeResolveLabel() function to fix an address and - ** the sqlite3VdbeChangeP4() function to change the value of the P4 - ** operand. - */ - static int sqlite3VdbeAddOp3(Vdbe p, int op, int p1, int p2, int p3) { - int i; - VdbeOp pOp; - - i = p.nOp; - Debug.Assert(p.magic == VDBE_MAGIC_INIT); - Debug.Assert(op > 0 && op < 0xff); - if (p.nOpAlloc <= i) { - if (growOpArray(p) != 0) { - return 1; - } - } - p.nOp++; - if (p.aOp[i] == null) - p.aOp[i] = new VdbeOp(); - pOp = p.aOp[i]; - pOp.opcode = (u8)op; - pOp.p5 = 0; - pOp.p1 = p1; - pOp.p2 = p2; - pOp.p3 = p3; - pOp.p4.p = null; - pOp.p4type = P4_NOTUSED; -#if SQLITE_DEBUG - pOp.zComment = null; - if (sqlite3VdbeAddopTrace) - sqlite3VdbePrintOp(null, i, p.aOp[i]); + } + p.nOp++; + if ( p.aOp[i] == null ) + p.aOp[i] = new VdbeOp(); + pOp = p.aOp[i]; + pOp.opcode = (u8)op; + pOp.p5 = 0; + pOp.p1 = p1; + pOp.p2 = p2; + pOp.p3 = p3; + pOp.p4.p = null; + pOp.p4type = P4_NOTUSED; +#if SQLITE_DEBUG + pOp.zComment = null; + if ( sqlite3VdbeAddopTrace ) + sqlite3VdbePrintOp( null, i, p.aOp[i] ); #endif #if VDBE_PROFILE pOp.cycles = 0; pOp.cnt = 0; #endif - return i; - } - static int sqlite3VdbeAddOp0(Vdbe p, int op) { - return sqlite3VdbeAddOp3(p, op, 0, 0, 0); - } - static int sqlite3VdbeAddOp1(Vdbe p, int op, int p1) { - return sqlite3VdbeAddOp3(p, op, p1, 0, 0); - } - static int sqlite3VdbeAddOp2(Vdbe p, int op, int p1, bool b2) { - return sqlite3VdbeAddOp2(p, op, p1, (int)(b2 ? 1 : 0)); - } + return i; + } + static int sqlite3VdbeAddOp0( Vdbe p, int op ) + { + return sqlite3VdbeAddOp3( p, op, 0, 0, 0 ); + } + static int sqlite3VdbeAddOp1( Vdbe p, int op, int p1 ) + { + return sqlite3VdbeAddOp3( p, op, p1, 0, 0 ); + } + static int sqlite3VdbeAddOp2( Vdbe p, int op, int p1, bool b2 ) + { + return sqlite3VdbeAddOp2( p, op, p1, (int)( b2 ? 1 : 0 ) ); + } - static int sqlite3VdbeAddOp2(Vdbe p, int op, int p1, int p2) { - return sqlite3VdbeAddOp3(p, op, p1, p2, 0); - } + static int sqlite3VdbeAddOp2( Vdbe p, int op, int p1, int p2 ) + { + return sqlite3VdbeAddOp3( p, op, p1, p2, 0 ); + } - /* - ** Add an opcode that includes the p4 value as a pointer. - */ - //P4_INT32 - static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, i32 pP4, int p4type) { - union_p4 _p4 = new union_p4(); - _p4.i = pP4; - int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); - sqlite3VdbeChangeP4(p, addr, _p4, p4type); - return addr; - } - - //char - static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, char pP4, int p4type) { - union_p4 _p4 = new union_p4(); - _p4.z = pP4.ToString(); - int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); - sqlite3VdbeChangeP4(p, addr, _p4, p4type); - return addr; - } - - //StringBuilder - static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, StringBuilder pP4, int p4type) { - // Debug.Assert( pP4 != null ); - union_p4 _p4 = new union_p4(); - _p4.z = pP4.ToString(); - int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); - sqlite3VdbeChangeP4(p, addr, _p4, p4type); - return addr; - } - - //String - static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, string pP4, int p4type) { - // Debug.Assert( pP4 != null ); - union_p4 _p4 = new union_p4(); - _p4.z = pP4; - int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); - sqlite3VdbeChangeP4(p, addr, _p4, p4type); - return addr; - } - - static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, byte[] pP4, int p4type) { - Debug.Assert(op == OP_Null || pP4 != null); - union_p4 _p4 = new union_p4(); - _p4.z = Encoding.UTF8.GetString(pP4, 0, pP4.Length); - int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); - sqlite3VdbeChangeP4(p, addr, _p4, p4type); - return addr; - } - - //P4_INTARRAY - static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, int[] pP4, int p4type) { - Debug.Assert(pP4 != null); - union_p4 _p4 = new union_p4(); - _p4.ai = pP4; - int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); - sqlite3VdbeChangeP4(p, addr, _p4, p4type); - return addr; - } - //P4_INT64 - static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, i64 pP4, int p4type) { - union_p4 _p4 = new union_p4(); - _p4.pI64 = pP4; - int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); - sqlite3VdbeChangeP4(p, addr, _p4, p4type); - return addr; - } - - //DOUBLE (REAL) - static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, double pP4, int p4type) { - union_p4 _p4 = new union_p4(); - _p4.pReal = pP4; - int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); - sqlite3VdbeChangeP4(p, addr, _p4, p4type); - return addr; - } - - //FUNCDEF - static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, FuncDef pP4, int p4type) { - union_p4 _p4 = new union_p4(); - _p4.pFunc = pP4; - int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); - sqlite3VdbeChangeP4(p, addr, _p4, p4type); - return addr; - } - - //CollSeq - static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, CollSeq pP4, int p4type) { - union_p4 _p4 = new union_p4(); - _p4.pColl = pP4; - int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); - sqlite3VdbeChangeP4(p, addr, _p4, p4type); - return addr; - } - - //KeyInfo - static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, KeyInfo pP4, int p4type) { - union_p4 _p4 = new union_p4(); - _p4.pKeyInfo = pP4; - int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); - sqlite3VdbeChangeP4(p, addr, _p4, p4type); - return addr; - } + /* + ** Add an opcode that includes the p4 value as a pointer. + */ + //P4_INT32 + static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, i32 pP4, int p4type ) + { + union_p4 _p4 = new union_p4(); + _p4.i = pP4; + int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); + sqlite3VdbeChangeP4( p, addr, _p4, p4type ); + return addr; + } -#if !SQLITE_OMIT_VIRTUALTABLE - //VTable - static int sqlite3VdbeAddOp4(Vdbe p, int op, int p1, int p2, int p3, VTable pP4, int p4type) { - Debug.Assert(pP4 != null); - union_p4 _p4 = new union_p4(); - _p4.pVtab = pP4; - int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); - sqlite3VdbeChangeP4(p, addr, _p4, p4type); - return addr; - } -#endif + //char + static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, char pP4, int p4type ) + { + union_p4 _p4 = new union_p4(); + _p4.z = pP4.ToString(); + int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); + sqlite3VdbeChangeP4( p, addr, _p4, p4type ); + return addr; + } - // static int sqlite3VdbeAddOp4( - // Vdbe p, /* Add the opcode to this VM */ - // int op, /* The new opcode */ - // int p1, /* The P1 operand */ - // int p2, /* The P2 operand */ - // int p3, /* The P3 operand */ - // union_p4 _p4, /* The P4 operand */ - // int p4type /* P4 operand type */ - //) - // { - // int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); - // sqlite3VdbeChangeP4(p, addr, _p4, p4type); - // return addr; - // } + //StringBuilder + static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, StringBuilder pP4, int p4type ) + { + // Debug.Assert( pP4 != null ); + union_p4 _p4 = new union_p4(); + _p4.z = pP4.ToString(); + int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); + sqlite3VdbeChangeP4( p, addr, _p4, p4type ); + return addr; + } - /* - ** Add an OP_ParseSchema opcode. This routine is broken out from - ** sqlite3VdbeAddOp4() since it needs to also local all btrees. - ** - ** The zWhere string must have been obtained from sqlite3_malloc(). - ** This routine will take ownership of the allocated memory. - */ - static void sqlite3VdbeAddParseSchemaOp(Vdbe p, int iDb, string zWhere) { - int j; - int addr = sqlite3VdbeAddOp3(p, OP_ParseSchema, iDb, 0, 0); - sqlite3VdbeChangeP4(p, addr, zWhere, P4_DYNAMIC); - for (j = 0; j < p.db.nDb; j++) - sqlite3VdbeUsesBtree(p, j); - } + //String + static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, string pP4, int p4type ) + { + // Debug.Assert( pP4 != null ); + union_p4 _p4 = new union_p4(); + _p4.z = pP4; + int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); + sqlite3VdbeChangeP4( p, addr, _p4, p4type ); + return addr; + } - /* - ** Add an opcode that includes the p4 value as an integer. - */ - static int sqlite3VdbeAddOp4Int( - Vdbe p, /* Add the opcode to this VM */ - int op, /* The new opcode */ - int p1, /* The P1 operand */ - int p2, /* The P2 operand */ - int p3, /* The P3 operand */ - int p4 /* The P4 operand as an integer */ - ) { - union_p4 _p4 = new union_p4(); - _p4.i = p4; - int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); - sqlite3VdbeChangeP4(p, addr, _p4, P4_INT32); - return addr; - } - /* - ** Create a new symbolic label for an instruction that has yet to be - ** coded. The symbolic label is really just a negative number. The - ** label can be used as the P2 value of an operation. Later, when - ** the label is resolved to a specific address, the VDBE will scan - ** through its operation list and change all values of P2 which match - ** the label into the resolved address. - ** - ** The VDBE knows that a P2 value is a label because labels are - ** always negative and P2 values are suppose to be non-negative. - ** Hence, a negative P2 value is a label that has yet to be resolved. - ** - ** Zero is returned if a malloc() fails. - */ - static int sqlite3VdbeMakeLabel(Vdbe p) { - int i; - i = p.nLabel++; - Debug.Assert(p.magic == VDBE_MAGIC_INIT); - if (i >= p.nLabelAlloc) { - int n = p.nLabelAlloc == 0 ? 15 : p.nLabelAlloc * 2 + 5; - if (p.aLabel == null) - p.aLabel = sqlite3Malloc(p.aLabel, n); - else - Array.Resize(ref p.aLabel, n); - //p.aLabel = sqlite3DbReallocOrFree(p.db, p.aLabel, - // n*sizeof(p.aLabel[0])); - p.nLabelAlloc = p.aLabel.Length;//sqlite3DbMallocSize(p.db, p.aLabel)/sizeof(p.aLabel[0]); - } - if (p.aLabel != null) { - p.aLabel[i] = -1; - } - return -1 - i; - } + static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, byte[] pP4, int p4type ) + { + Debug.Assert( op == OP_Null || pP4 != null ); + union_p4 _p4 = new union_p4(); + _p4.z = Encoding.UTF8.GetString( pP4, 0, pP4.Length ); + int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); + sqlite3VdbeChangeP4( p, addr, _p4, p4type ); + return addr; + } - /* - ** Resolve label "x" to be the address of the next instruction to - ** be inserted. The parameter "x" must have been obtained from - ** a prior call to sqlite3VdbeMakeLabel(). - */ - static void sqlite3VdbeResolveLabel(Vdbe p, int x) { - int j = -1 - x; - Debug.Assert(p.magic == VDBE_MAGIC_INIT); - Debug.Assert(j >= 0 && j < p.nLabel); - if (p.aLabel != null) { - p.aLabel[j] = p.nOp; - } - } + //P4_INTARRAY + static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, int[] pP4, int p4type ) + { + Debug.Assert( pP4 != null ); + union_p4 _p4 = new union_p4(); + _p4.ai = pP4; + int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); + sqlite3VdbeChangeP4( p, addr, _p4, p4type ); + return addr; + } + //P4_INT64 + static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, i64 pP4, int p4type ) + { + union_p4 _p4 = new union_p4(); + _p4.pI64 = pP4; + int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); + sqlite3VdbeChangeP4( p, addr, _p4, p4type ); + return addr; + } - /* - ** Mark the VDBE as one that can only be run one time. - */ - static void sqlite3VdbeRunOnlyOnce(Vdbe p) { - p.runOnlyOnce = 1; - } + //DOUBLE (REAL) + static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, double pP4, int p4type ) + { + union_p4 _p4 = new union_p4(); + _p4.pReal = pP4; + int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); + sqlite3VdbeChangeP4( p, addr, _p4, p4type ); + return addr; + } -#if SQLITE_DEBUG //* sqlite3AssertMayAbort() logic */ + //FUNCDEF + static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, FuncDef pP4, int p4type ) + { + union_p4 _p4 = new union_p4(); + _p4.pFunc = pP4; + int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); + sqlite3VdbeChangeP4( p, addr, _p4, p4type ); + return addr; + } + + //CollSeq + static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, CollSeq pP4, int p4type ) + { + union_p4 _p4 = new union_p4(); + _p4.pColl = pP4; + int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); + sqlite3VdbeChangeP4( p, addr, _p4, p4type ); + return addr; + } + + //KeyInfo + static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, KeyInfo pP4, int p4type ) + { + union_p4 _p4 = new union_p4(); + _p4.pKeyInfo = pP4; + int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); + sqlite3VdbeChangeP4( p, addr, _p4, p4type ); + return addr; + } + +#if !SQLITE_OMIT_VIRTUALTABLE + //VTable + static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, VTable pP4, int p4type ) + { + Debug.Assert( pP4 != null ); + union_p4 _p4 = new union_p4(); + _p4.pVtab = pP4; + int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); + sqlite3VdbeChangeP4( p, addr, _p4, p4type ); + return addr; + } +#endif + + // static int sqlite3VdbeAddOp4( + // Vdbe p, /* Add the opcode to this VM */ + // int op, /* The new opcode */ + // int p1, /* The P1 operand */ + // int p2, /* The P2 operand */ + // int p3, /* The P3 operand */ + // union_p4 _p4, /* The P4 operand */ + // int p4type /* P4 operand type */ + //) + // { + // int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); + // sqlite3VdbeChangeP4(p, addr, _p4, p4type); + // return addr; + // } + + /* + ** Add an OP_ParseSchema opcode. This routine is broken out from + ** sqlite3VdbeAddOp4() since it needs to also local all btrees. + ** + ** The zWhere string must have been obtained from sqlite3_malloc(). + ** This routine will take ownership of the allocated memory. + */ + static void sqlite3VdbeAddParseSchemaOp( Vdbe p, int iDb, string zWhere ) + { + int j; + int addr = sqlite3VdbeAddOp3( p, OP_ParseSchema, iDb, 0, 0 ); + sqlite3VdbeChangeP4( p, addr, zWhere, P4_DYNAMIC ); + for ( j = 0; j < p.db.nDb; j++ ) + sqlite3VdbeUsesBtree( p, j ); + } - /* - ** The following type and function are used to iterate through all opcodes - ** in a Vdbe main program and each of the sub-programs (triggers) it may - ** invoke directly or indirectly. It should be used as follows: + /* + ** Add an opcode that includes the p4 value as an integer. + */ + static int sqlite3VdbeAddOp4Int( + Vdbe p, /* Add the opcode to this VM */ + int op, /* The new opcode */ + int p1, /* The P1 operand */ + int p2, /* The P2 operand */ + int p3, /* The P3 operand */ + int p4 /* The P4 operand as an integer */ + ) + { + union_p4 _p4 = new union_p4(); + _p4.i = p4; + int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 ); + sqlite3VdbeChangeP4( p, addr, _p4, P4_INT32 ); + return addr; + } + /* + ** Create a new symbolic label for an instruction that has yet to be + ** coded. The symbolic label is really just a negative number. The + ** label can be used as the P2 value of an operation. Later, when + ** the label is resolved to a specific address, the VDBE will scan + ** through its operation list and change all values of P2 which match + ** the label into the resolved address. ** - ** Op *pOp; - ** VdbeOpIter sIter; + ** The VDBE knows that a P2 value is a label because labels are + ** always negative and P2 values are suppose to be non-negative. + ** Hence, a negative P2 value is a label that has yet to be resolved. ** - ** memset(&sIter, 0, sizeof(sIter)); - ** sIter.v = v; // v is of type Vdbe* - ** while( (pOp = opIterNext(&sIter)) ){ - ** // Do something with pOp - ** } - ** sqlite3DbFree(v->db, sIter.apSub); - ** - */ - //typedef struct VdbeOpIter VdbeOpIter; - public class VdbeOpIter { - public Vdbe v; /* Vdbe to iterate through the opcodes of */ - public SubProgram[] apSub; /* Array of subprograms */ - public int nSub; /* Number of entries in apSub */ - public int iAddr; /* Address of next instruction to return */ - public int iSub; /* 0 = main program, 1 = first sub-program etc. */ - }; - - static Op opIterNext(VdbeOpIter p) { - Vdbe v = p.v; - Op pRet = null; - Op[] aOp; - int nOp; - - if (p.iSub <= p.nSub) { - - if (p.iSub == 0) { - aOp = v.aOp; - nOp = v.nOp; - } else { - aOp = p.apSub[p.iSub - 1].aOp; - nOp = p.apSub[p.iSub - 1].nOp; - } - Debug.Assert(p.iAddr < nOp); + ** Zero is returned if a malloc() fails. + */ + static int sqlite3VdbeMakeLabel( Vdbe p ) + { + int i; + i = p.nLabel++; + Debug.Assert( p.magic == VDBE_MAGIC_INIT ); + if ( i >= p.nLabelAlloc ) + { + int n = p.nLabelAlloc == 0 ? 15 : p.nLabelAlloc * 2 + 5; + if ( p.aLabel == null ) + p.aLabel = sqlite3Malloc( p.aLabel, n ); + else + Array.Resize( ref p.aLabel, n ); + //p.aLabel = sqlite3DbReallocOrFree(p.db, p.aLabel, + // n*sizeof(p.aLabel[0])); + p.nLabelAlloc = p.aLabel.Length;//sqlite3DbMallocSize(p.db, p.aLabel)/sizeof(p.aLabel[0]); + } + if ( p.aLabel != null ) + { + p.aLabel[i] = -1; + } + return -1 - i; + } - pRet = aOp[p.iAddr]; - p.iAddr++; - if (p.iAddr == nOp) { - p.iSub++; - p.iAddr = 0; - } + /* + ** Resolve label "x" to be the address of the next instruction to + ** be inserted. The parameter "x" must have been obtained from + ** a prior call to sqlite3VdbeMakeLabel(). + */ + static void sqlite3VdbeResolveLabel( Vdbe p, int x ) + { + int j = -1 - x; + Debug.Assert( p.magic == VDBE_MAGIC_INIT ); + Debug.Assert( j >= 0 && j < p.nLabel ); + if ( p.aLabel != null ) + { + p.aLabel[j] = p.nOp; + } + } - if (pRet.p4type == P4_SUBPROGRAM) { - //int nByte = p.nSub + 1 ) * sizeof( SubProgram* ); - int j; - for (j = 0; j < p.nSub; j++) { - if (p.apSub[j] == pRet.p4.pProgram) - break; - } - if (j == p.nSub) { - Array.Resize(ref p.apSub, p.nSub + 1);/// sqlite3DbReallocOrFree( v.db, p.apSub, nByte ); - //if( null==p.apSub ){ - // pRet = null; - //}else{ - p.apSub[p.nSub++] = pRet.p4.pProgram; - //} - } - } - } + /* + ** Mark the VDBE as one that can only be run one time. + */ + static void sqlite3VdbeRunOnlyOnce( Vdbe p ) + { + p.runOnlyOnce = 1; + } - return pRet; - } +#if SQLITE_DEBUG //* sqlite3AssertMayAbort() logic */ - /* - ** Check if the program stored in the VM associated with pParse may - ** throw an ABORT exception (causing the statement, but not entire transaction - ** to be rolled back). This condition is true if the main program or any - ** sub-programs contains any of the following: - ** - ** * OP_Halt with P1=SQLITE_CONSTRAINT and P2=OE_Abort. - ** * OP_HaltIfNull with P1=SQLITE_CONSTRAINT and P2=OE_Abort. - ** * OP_Destroy - ** * OP_VUpdate - ** * OP_VRename - ** * OP_FkCounter with P2==0 (immediate foreign key constraint) - ** - ** Then check that the value of Parse.mayAbort is true if an - ** ABORT may be thrown, or false otherwise. Return true if it does - ** match, or false otherwise. This function is intended to be used as - ** part of an assert statement in the compiler. Similar to: - ** - ** Debug.Assert( sqlite3VdbeAssertMayAbort(pParse->pVdbe, pParse->mayAbort) ); - */ - static int sqlite3VdbeAssertMayAbort(Vdbe v, int mayAbort) { - int hasAbort = 0; - Op pOp; - VdbeOpIter sIter; - sIter = new VdbeOpIter();// memset( &sIter, 0, sizeof( sIter ) ); - sIter.v = v; - - while ((pOp = opIterNext(sIter)) != null) { - int opcode = pOp.opcode; - if (opcode == OP_Destroy || opcode == OP_VUpdate || opcode == OP_VRename -#if !SQLITE_OMIT_FOREIGN_KEY - || (opcode == OP_FkCounter && pOp.p1 == 0 && pOp.p2 == 1) -#endif - || ((opcode == OP_Halt || opcode == OP_HaltIfNull) - && (pOp.p1 == SQLITE_CONSTRAINT && pOp.p2 == OE_Abort)) - ) { - hasAbort = 1; - break; - } - } - sIter.apSub = null;// sqlite3DbFree( v.db, sIter.apSub ); + /* +** The following type and function are used to iterate through all opcodes +** in a Vdbe main program and each of the sub-programs (triggers) it may +** invoke directly or indirectly. It should be used as follows: +** +** Op *pOp; +** VdbeOpIter sIter; +** +** memset(&sIter, 0, sizeof(sIter)); +** sIter.v = v; // v is of type Vdbe* +** while( (pOp = opIterNext(&sIter)) ){ +** // Do something with pOp +** } +** sqlite3DbFree(v->db, sIter.apSub); +** +*/ + //typedef struct VdbeOpIter VdbeOpIter; + public class VdbeOpIter + { + public Vdbe v; /* Vdbe to iterate through the opcodes of */ + public SubProgram[] apSub; /* Array of subprograms */ + public int nSub; /* Number of entries in apSub */ + public int iAddr; /* Address of next instruction to return */ + public int iSub; /* 0 = main program, 1 = first sub-program etc. */ + }; + + static Op opIterNext( VdbeOpIter p ) + { + Vdbe v = p.v; + Op pRet = null; + Op[] aOp; + int nOp; + + if ( p.iSub <= p.nSub ) + { + + if ( p.iSub == 0 ) + { + aOp = v.aOp; + nOp = v.nOp; + } + else + { + aOp = p.apSub[p.iSub - 1].aOp; + nOp = p.apSub[p.iSub - 1].nOp; + } + Debug.Assert( p.iAddr < nOp ); + + pRet = aOp[p.iAddr]; + p.iAddr++; + if ( p.iAddr == nOp ) + { + p.iSub++; + p.iAddr = 0; + } - /* Return true if hasAbort==mayAbort. Or if a malloc failure occured. - ** If malloc failed, then the while() loop above may not have iterated - ** through all opcodes and hasAbort may be set incorrectly. Return - ** true for this case to prevent the Debug.Assert() in the callers frame - ** from failing. */ - return (hasAbort == mayAbort) ? 1 : 0;//v.db.mallocFailed !=0|| hasAbort==mayAbort ); + if ( pRet.p4type == P4_SUBPROGRAM ) + { + //int nByte = p.nSub + 1 ) * sizeof( SubProgram* ); + int j; + for ( j = 0; j < p.nSub; j++ ) + { + if ( p.apSub[j] == pRet.p4.pProgram ) + break; + } + if ( j == p.nSub ) + { + Array.Resize( ref p.apSub, p.nSub + 1 );/// sqlite3DbReallocOrFree( v.db, p.apSub, nByte ); + //if( null==p.apSub ){ + // pRet = null; + //}else{ + p.apSub[p.nSub++] = pRet.p4.pProgram; + //} + } } -#endif //* SQLITE_DEBUG - the sqlite3AssertMayAbort() function */ + } - /* - ** Loop through the program looking for P2 values that are negative - ** on jump instructions. Each such value is a label. Resolve the - ** label by setting the P2 value to its correct non-zero value. + return pRet; + } + + /* + ** Check if the program stored in the VM associated with pParse may + ** throw an ABORT exception (causing the statement, but not entire transaction + ** to be rolled back). This condition is true if the main program or any + ** sub-programs contains any of the following: ** - ** This routine is called once after all opcodes have been inserted. + ** * OP_Halt with P1=SQLITE_CONSTRAINT and P2=OE_Abort. + ** * OP_HaltIfNull with P1=SQLITE_CONSTRAINT and P2=OE_Abort. + ** * OP_Destroy + ** * OP_VUpdate + ** * OP_VRename + ** * OP_FkCounter with P2==0 (immediate foreign key constraint) ** - ** Variable *pMaxFuncArgs is set to the maximum value of any P2 argument - ** to an OP_Function, OP_AggStep or OP_VFilter opcode. This is used by - ** sqlite3VdbeMakeReady() to size the Vdbe.apArg[] array. + ** Then check that the value of Parse.mayAbort is true if an + ** ABORT may be thrown, or false otherwise. Return true if it does + ** match, or false otherwise. This function is intended to be used as + ** part of an assert statement in the compiler. Similar to: ** - ** The Op.opflags field is set on all opcodes. - */ - static void resolveP2Values(Vdbe p, ref int pMaxFuncArgs) { - int i; - int nMaxArgs = pMaxFuncArgs; - Op pOp; - int[] aLabel = p.aLabel; - p.readOnly = true; - for (i = 0; i < p.nOp; i++)// for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++) - { - pOp = p.aOp[i]; - u8 opcode = pOp.opcode; - - pOp.opflags = (u8)sqlite3OpcodeProperty[opcode]; - if (opcode == OP_Function || opcode == OP_AggStep) { - if (pOp.p5 > nMaxArgs) - nMaxArgs = pOp.p5; - } else if ((opcode == OP_Transaction && pOp.p2 != 0) || opcode == OP_Vacuum) { - p.readOnly = false; -#if !SQLITE_OMIT_VIRTUALTABLE - } else if (opcode == OP_VUpdate) { - if (pOp.p2 > nMaxArgs) - nMaxArgs = pOp.p2; - } else if (opcode == OP_VFilter) { - int n; - Debug.Assert(p.nOp - i >= 3); - Debug.Assert(p.aOp[i - 1].opcode == OP_Integer);//pOp[-1].opcode==OP_Integer ); - n = p.aOp[i - 1].p1;//pOp[-1].p1; - if (n > nMaxArgs) - nMaxArgs = n; + ** Debug.Assert( sqlite3VdbeAssertMayAbort(pParse->pVdbe, pParse->mayAbort) ); + */ + static int sqlite3VdbeAssertMayAbort( Vdbe v, int mayAbort ) + { + int hasAbort = 0; + Op pOp; + VdbeOpIter sIter; + sIter = new VdbeOpIter();// memset( &sIter, 0, sizeof( sIter ) ); + sIter.v = v; + + while ( ( pOp = opIterNext( sIter ) ) != null ) + { + int opcode = pOp.opcode; + if ( opcode == OP_Destroy || opcode == OP_VUpdate || opcode == OP_VRename +#if !SQLITE_OMIT_FOREIGN_KEY + || ( opcode == OP_FkCounter && pOp.p1 == 0 && pOp.p2 == 1 ) #endif - } - - if ((pOp.opflags & OPFLG_JUMP) != 0 && pOp.p2 < 0) { - Debug.Assert(-1 - pOp.p2 < p.nLabel); - pOp.p2 = aLabel[-1 - pOp.p2]; - } - } - sqlite3DbFree(p.db, ref p.aLabel); + || ( ( opcode == OP_Halt || opcode == OP_HaltIfNull ) + && ( pOp.p1 == SQLITE_CONSTRAINT && pOp.p2 == OE_Abort ) ) + ) + { + hasAbort = 1; + break; + } + } + sIter.apSub = null;// sqlite3DbFree( v.db, sIter.apSub ); + + /* Return true if hasAbort==mayAbort. Or if a malloc failure occured. + ** If malloc failed, then the while() loop above may not have iterated + ** through all opcodes and hasAbort may be set incorrectly. Return + ** true for this case to prevent the Debug.Assert() in the callers frame + ** from failing. */ + return ( hasAbort == mayAbort ) ? 1 : 0;//v.db.mallocFailed !=0|| hasAbort==mayAbort ); + } +#endif //* SQLITE_DEBUG - the sqlite3AssertMayAbort() function */ - pMaxFuncArgs = nMaxArgs; + /* +** Loop through the program looking for P2 values that are negative +** on jump instructions. Each such value is a label. Resolve the +** label by setting the P2 value to its correct non-zero value. +** +** This routine is called once after all opcodes have been inserted. +** +** Variable *pMaxFuncArgs is set to the maximum value of any P2 argument +** to an OP_Function, OP_AggStep or OP_VFilter opcode. This is used by +** sqlite3VdbeMakeReady() to size the Vdbe.apArg[] array. +** +** The Op.opflags field is set on all opcodes. +*/ + static void resolveP2Values( Vdbe p, ref int pMaxFuncArgs ) + { + int i; + int nMaxArgs = pMaxFuncArgs; + Op pOp; + int[] aLabel = p.aLabel; + p.readOnly = true; + for ( i = 0; i < p.nOp; i++ )// for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++) + { + pOp = p.aOp[i]; + u8 opcode = pOp.opcode; + + pOp.opflags = (u8)sqlite3OpcodeProperty[opcode]; + if ( opcode == OP_Function || opcode == OP_AggStep ) + { + if ( pOp.p5 > nMaxArgs ) + nMaxArgs = pOp.p5; + } + else if ( ( opcode == OP_Transaction && pOp.p2 != 0 ) || opcode == OP_Vacuum ) + { + p.readOnly = false; +#if !SQLITE_OMIT_VIRTUALTABLE + } + else if ( opcode == OP_VUpdate ) + { + if ( pOp.p2 > nMaxArgs ) + nMaxArgs = pOp.p2; + } + else if ( opcode == OP_VFilter ) + { + int n; + Debug.Assert( p.nOp - i >= 3 ); + Debug.Assert( p.aOp[i - 1].opcode == OP_Integer );//pOp[-1].opcode==OP_Integer ); + n = p.aOp[i - 1].p1;//pOp[-1].p1; + if ( n > nMaxArgs ) + nMaxArgs = n; +#endif } - /* - ** Return the address of the next instruction to be inserted. - */ - static int sqlite3VdbeCurrentAddr(Vdbe p) { - Debug.Assert(p.magic == VDBE_MAGIC_INIT); - return p.nOp; + if ( ( pOp.opflags & OPFLG_JUMP ) != 0 && pOp.p2 < 0 ) + { + Debug.Assert( -1 - pOp.p2 < p.nLabel ); + pOp.p2 = aLabel[-1 - pOp.p2]; } + } + sqlite3DbFree( p.db, ref p.aLabel ); - /* - ** This function returns a pointer to the array of opcodes associated with - ** the Vdbe passed as the first argument. It is the callers responsibility - ** to arrange for the returned array to be eventually freed using the - ** vdbeFreeOpArray() function. - ** - ** Before returning, *pnOp is set to the number of entries in the returned - ** array. Also, *pnMaxArg is set to the larger of its current value and - ** the number of entries in the Vdbe.apArg[] array required to execute the - ** returned program. - */ - static VdbeOp[] sqlite3VdbeTakeOpArray(Vdbe p, ref int pnOp, ref int pnMaxArg) { - VdbeOp[] aOp = p.aOp; - Debug.Assert(aOp != null);// && 0==p.db.mallocFailed ); + pMaxFuncArgs = nMaxArgs; + } - /* Check that sqlite3VdbeUsesBtree() was not called on this VM */ - Debug.Assert(p.btreeMask == 0); + /* + ** Return the address of the next instruction to be inserted. + */ + static int sqlite3VdbeCurrentAddr( Vdbe p ) + { + Debug.Assert( p.magic == VDBE_MAGIC_INIT ); + return p.nOp; + } - resolveP2Values(p, ref pnMaxArg); - pnOp = p.nOp; - p.aOp = null; - return aOp; - } + /* + ** This function returns a pointer to the array of opcodes associated with + ** the Vdbe passed as the first argument. It is the callers responsibility + ** to arrange for the returned array to be eventually freed using the + ** vdbeFreeOpArray() function. + ** + ** Before returning, *pnOp is set to the number of entries in the returned + ** array. Also, *pnMaxArg is set to the larger of its current value and + ** the number of entries in the Vdbe.apArg[] array required to execute the + ** returned program. + */ + static VdbeOp[] sqlite3VdbeTakeOpArray( Vdbe p, ref int pnOp, ref int pnMaxArg ) + { + VdbeOp[] aOp = p.aOp; + Debug.Assert( aOp != null );// && 0==p.db.mallocFailed ); + + /* Check that sqlite3VdbeUsesBtree() was not called on this VM */ + Debug.Assert( p.btreeMask == 0 ); + + resolveP2Values( p, ref pnMaxArg ); + pnOp = p.nOp; + p.aOp = null; + return aOp; + } - /* - ** Add a whole list of operations to the operation stack. Return the - ** address of the first operation added. - */ - static int sqlite3VdbeAddOpList(Vdbe p, int nOp, VdbeOpList[] aOp) { - int addr; - Debug.Assert(p.magic == VDBE_MAGIC_INIT); - if (p.nOp + nOp > p.nOpAlloc && growOpArray(p) != 0) { - return 0; - } - addr = p.nOp; - if (ALWAYS(nOp > 0)) { - int i; - VdbeOpList pIn; - for (i = 0; i < nOp; i++) { - pIn = aOp[i]; - int p2 = pIn.p2; - if (p.aOp[i + addr] == null) - p.aOp[i + addr] = new VdbeOp(); - VdbeOp pOut = p.aOp[i + addr]; - pOut.opcode = pIn.opcode; - pOut.p1 = pIn.p1; - if (p2 < 0 && (sqlite3OpcodeProperty[pOut.opcode] & OPFLG_JUMP) != 0) { - pOut.p2 = addr + (-1 - p2);// ADDR(p2); - } else { - pOut.p2 = p2; - } - pOut.p3 = pIn.p3; - pOut.p4type = P4_NOTUSED; - pOut.p4.p = null; - pOut.p5 = 0; -#if SQLITE_DEBUG - pOut.zComment = null; - if (sqlite3VdbeAddopTrace) { - sqlite3VdbePrintOp(null, i + addr, p.aOp[i + addr]); - } + /* + ** Add a whole list of operations to the operation stack. Return the + ** address of the first operation added. + */ + static int sqlite3VdbeAddOpList( Vdbe p, int nOp, VdbeOpList[] aOp ) + { + int addr; + Debug.Assert( p.magic == VDBE_MAGIC_INIT ); + if ( p.nOp + nOp > p.nOpAlloc && growOpArray( p ) != 0 ) + { + return 0; + } + addr = p.nOp; + if ( ALWAYS( nOp > 0 ) ) + { + int i; + VdbeOpList pIn; + for ( i = 0; i < nOp; i++ ) + { + pIn = aOp[i]; + int p2 = pIn.p2; + if ( p.aOp[i + addr] == null ) + p.aOp[i + addr] = new VdbeOp(); + VdbeOp pOut = p.aOp[i + addr]; + pOut.opcode = pIn.opcode; + pOut.p1 = pIn.p1; + if ( p2 < 0 && ( sqlite3OpcodeProperty[pOut.opcode] & OPFLG_JUMP ) != 0 ) + { + pOut.p2 = addr + ( -1 - p2 );// ADDR(p2); + } + else + { + pOut.p2 = p2; + } + pOut.p3 = pIn.p3; + pOut.p4type = P4_NOTUSED; + pOut.p4.p = null; + pOut.p5 = 0; +#if SQLITE_DEBUG + pOut.zComment = null; + if ( sqlite3VdbeAddopTrace ) + { + sqlite3VdbePrintOp( null, i + addr, p.aOp[i + addr] ); + } #endif - } - p.nOp += nOp; - } - return addr; } + p.nOp += nOp; + } + return addr; + } - /* - ** Change the value of the P1 operand for a specific instruction. - ** This routine is useful when a large program is loaded from a - ** static array using sqlite3VdbeAddOpList but we want to make a - ** few minor changes to the program. - */ - static void sqlite3VdbeChangeP1(Vdbe p, int addr, int val) { - Debug.Assert(p != null); - Debug.Assert(addr >= 0); - if (p.nOp > addr) { - p.aOp[addr].p1 = val; - } - } + /* + ** Change the value of the P1 operand for a specific instruction. + ** This routine is useful when a large program is loaded from a + ** static array using sqlite3VdbeAddOpList but we want to make a + ** few minor changes to the program. + */ + static void sqlite3VdbeChangeP1( Vdbe p, int addr, int val ) + { + Debug.Assert( p != null ); + Debug.Assert( addr >= 0 ); + if ( p.nOp > addr ) + { + p.aOp[addr].p1 = val; + } + } - /* - ** Change the value of the P2 operand for a specific instruction. - ** This routine is useful for setting a jump destination. - */ - static void sqlite3VdbeChangeP2(Vdbe p, int addr, int val) { - Debug.Assert(p != null); - Debug.Assert(addr >= 0); - if (p.nOp > addr) { - p.aOp[addr].p2 = val; - } - } + /* + ** Change the value of the P2 operand for a specific instruction. + ** This routine is useful for setting a jump destination. + */ + static void sqlite3VdbeChangeP2( Vdbe p, int addr, int val ) + { + Debug.Assert( p != null ); + Debug.Assert( addr >= 0 ); + if ( p.nOp > addr ) + { + p.aOp[addr].p2 = val; + } + } - /* - ** Change the value of the P3 operand for a specific instruction. - */ - static void sqlite3VdbeChangeP3(Vdbe p, int addr, int val) { - Debug.Assert(p != null); - Debug.Assert(addr >= 0); - if (p.nOp > addr) { - p.aOp[addr].p3 = val; - } - } + /* + ** Change the value of the P3 operand for a specific instruction. + */ + static void sqlite3VdbeChangeP3( Vdbe p, int addr, int val ) + { + Debug.Assert( p != null ); + Debug.Assert( addr >= 0 ); + if ( p.nOp > addr ) + { + p.aOp[addr].p3 = val; + } + } - /* - ** Change the value of the P5 operand for the most recently - ** added operation. - */ - static void sqlite3VdbeChangeP5(Vdbe p, u8 val) { - Debug.Assert(p != null); - if (p.aOp != null) { - Debug.Assert(p.nOp > 0); - p.aOp[p.nOp - 1].p5 = val; - } - } + /* + ** Change the value of the P5 operand for the most recently + ** added operation. + */ + static void sqlite3VdbeChangeP5( Vdbe p, u8 val ) + { + Debug.Assert( p != null ); + if ( p.aOp != null ) + { + Debug.Assert( p.nOp > 0 ); + p.aOp[p.nOp - 1].p5 = val; + } + } - /* - ** Change the P2 operand of instruction addr so that it points to - ** the address of the next instruction to be coded. - */ - static void sqlite3VdbeJumpHere(Vdbe p, int addr) { - Debug.Assert(addr >= 0); - sqlite3VdbeChangeP2(p, addr, p.nOp); - } + /* + ** Change the P2 operand of instruction addr so that it points to + ** the address of the next instruction to be coded. + */ + static void sqlite3VdbeJumpHere( Vdbe p, int addr ) + { + Debug.Assert( addr >= 0 ); + sqlite3VdbeChangeP2( p, addr, p.nOp ); + } - /* - ** If the input FuncDef structure is ephemeral, then free it. If - ** the FuncDef is not ephermal, then do nothing. - */ - static void freeEphemeralFunction(sqlite3 db, FuncDef pDef) { - if (ALWAYS(pDef) && (pDef.flags & SQLITE_FUNC_EPHEM) != 0) { - pDef = null; - sqlite3DbFree(db, ref pDef); - } - } + /* + ** If the input FuncDef structure is ephemeral, then free it. If + ** the FuncDef is not ephermal, then do nothing. + */ + static void freeEphemeralFunction( sqlite3 db, FuncDef pDef ) + { + if ( ALWAYS( pDef ) && ( pDef.flags & SQLITE_FUNC_EPHEM ) != 0 ) + { + pDef = null; + sqlite3DbFree( db, ref pDef ); + } + } - //static void vdbeFreeOpArray(sqlite3 *, Op *, int); + //static void vdbeFreeOpArray(sqlite3 *, Op *, int); - /* - ** Delete a P4 value if necessary. - */ - static void freeP4(sqlite3 db, int p4type, object p4) { - if (p4 != null) { - switch (p4type) { - case P4_REAL: - case P4_INT64: - case P4_DYNAMIC: - case P4_KEYINFO: - case P4_INTARRAY: - case P4_KEYINFO_HANDOFF: { - sqlite3DbFree(db, ref p4); - break; - } - case P4_MPRINTF: { - if (db.pnBytesFreed == 0) - p4 = null;// sqlite3_free( ref p4 ); - break; - } - case P4_VDBEFUNC: { - VdbeFunc pVdbeFunc = (VdbeFunc)p4; - freeEphemeralFunction(db, pVdbeFunc.pFunc); - if (db.pnBytesFreed == 0) - sqlite3VdbeDeleteAuxData(pVdbeFunc, 0); - sqlite3DbFree(db, ref pVdbeFunc); - break; - } - case P4_FUNCDEF: { - freeEphemeralFunction(db, (FuncDef)p4); - break; - } - case P4_MEM: { - if (db.pnBytesFreed == 0) { - p4 = null;// sqlite3ValueFree(ref (sqlite3_value)p4); - } else { - Mem p = (Mem)p4; - //sqlite3DbFree( db, ref p.zMalloc ); - sqlite3DbFree(db, ref p); - } - break; - } - case P4_VTAB: { - if (db.pnBytesFreed == 0) - sqlite3VtabUnlock((VTable)p4); - break; - } - } + /* + ** Delete a P4 value if necessary. + */ + static void freeP4( sqlite3 db, int p4type, object p4 ) + { + if ( p4 != null ) + { + switch ( p4type ) + { + case P4_REAL: + case P4_INT64: + case P4_DYNAMIC: + case P4_KEYINFO: + case P4_INTARRAY: + case P4_KEYINFO_HANDOFF: + { + sqlite3DbFree( db, ref p4 ); + break; } - } - - /* - ** Free the space allocated for aOp and any p4 values allocated for the - ** opcodes contained within. If aOp is not NULL it is assumed to contain - ** nOp entries. - */ - static void vdbeFreeOpArray(sqlite3 db, ref Op[] aOp, int nOp) { - if (aOp != null) { - //Op pOp; - // for(pOp=aOp; pOp<&aOp[nOp]; pOp++){ - // freeP4(db, pOp.p4type, pOp.p4.p); - //#if SQLITE_DEBUG - // sqlite3DbFree(db, ref pOp.zComment); - //#endif - // } - // } - // sqlite3DbFree(db, aOp); - aOp = null; + case P4_MPRINTF: + { + if ( db.pnBytesFreed == 0 ) + p4 = null;// sqlite3_free( ref p4 ); + break; } - } - - /* - ** Link the SubProgram object passed as the second argument into the linked - ** list at Vdbe.pSubProgram. This list is used to delete all sub-program - ** objects when the VM is no longer required. - */ - static void sqlite3VdbeLinkSubProgram(Vdbe pVdbe, SubProgram p) { - p.pNext = pVdbe.pProgram; - pVdbe.pProgram = p; - } - - /* - ** Change N opcodes starting at addr to No-ops. - */ - static void sqlite3VdbeChangeToNoop(Vdbe p, int addr, int N) { - if (p.aOp != null) { - sqlite3 db = p.db; - while (N-- > 0) { - VdbeOp pOp = p.aOp[addr + N]; - freeP4(db, pOp.p4type, pOp.p4.p); - pOp = p.aOp[addr + N] = new VdbeOp();//memset(pOp, 0, sizeof(pOp[0])); - pOp.opcode = OP_Noop; - //pOp++; - } + case P4_VDBEFUNC: + { + VdbeFunc pVdbeFunc = (VdbeFunc)p4; + freeEphemeralFunction( db, pVdbeFunc.pFunc ); + if ( db.pnBytesFreed == 0 ) + sqlite3VdbeDeleteAuxData( pVdbeFunc, 0 ); + sqlite3DbFree( db, ref pVdbeFunc ); + break; + } + case P4_FUNCDEF: + { + freeEphemeralFunction( db, (FuncDef)p4 ); + break; + } + case P4_MEM: + { + if ( db.pnBytesFreed == 0 ) + { + p4 = null;// sqlite3ValueFree(ref (sqlite3_value)p4); + } + else + { + Mem p = (Mem)p4; + //sqlite3DbFree( db, ref p.zMalloc ); + sqlite3DbFree( db, ref p ); + } + break; + } + case P4_VTAB: + { + if ( db.pnBytesFreed == 0 ) + sqlite3VtabUnlock( (VTable)p4 ); + break; } } + } + } - /* - ** Change the value of the P4 operand for a specific instruction. - ** This routine is useful when a large program is loaded from a - ** static array using sqlite3VdbeAddOpList but we want to make a - ** few minor changes to the program. - ** - ** If n>=0 then the P4 operand is dynamic, meaning that a copy of - ** the string is made into memory obtained from sqlite3Malloc(). - ** A value of n==0 means copy bytes of zP4 up to and including the - ** first null byte. If n>0 then copy n+1 bytes of zP4. - ** - ** If n==P4_KEYINFO it means that zP4 is a pointer to a KeyInfo structure. - ** A copy is made of the KeyInfo structure into memory obtained from - ** sqlite3Malloc, to be freed when the Vdbe is finalized. - ** n==P4_KEYINFO_HANDOFF indicates that zP4 points to a KeyInfo structure - ** stored in memory that the caller has obtained from sqlite3Malloc. The - ** caller should not free the allocation, it will be freed when the Vdbe is - ** finalized. - ** - ** Other values of n (P4_STATIC, P4_COLLSEQ etc.) indicate that zP4 points - ** to a string or structure that is guaranteed to exist for the lifetime of - ** the Vdbe. In these cases we can just copy the pointer. - ** - ** If addr<0 then change P4 on the most recently inserted instruction. - */ + /* + ** Free the space allocated for aOp and any p4 values allocated for the + ** opcodes contained within. If aOp is not NULL it is assumed to contain + ** nOp entries. + */ + static void vdbeFreeOpArray( sqlite3 db, ref Op[] aOp, int nOp ) + { + if ( aOp != null ) + { + //Op pOp; + // for(pOp=aOp; pOp<&aOp[nOp]; pOp++){ + // freeP4(db, pOp.p4type, pOp.p4.p); + //#if SQLITE_DEBUG + // sqlite3DbFree(db, ref pOp.zComment); + //#endif + // } + // } + // sqlite3DbFree(db, aOp); + aOp = null; + } + } - //P4_COLLSEQ - static void sqlite3VdbeChangeP4(Vdbe p, int addr, CollSeq pColl, int n) { - union_p4 _p4 = new union_p4(); - _p4.pColl = pColl; - sqlite3VdbeChangeP4(p, addr, _p4, n); - } - //P4_FUNCDEF - static void sqlite3VdbeChangeP4(Vdbe p, int addr, FuncDef pFunc, int n) { - union_p4 _p4 = new union_p4(); - _p4.pFunc = pFunc; - sqlite3VdbeChangeP4(p, addr, _p4, n); - } - //P4_INT32 - static void sqlite3VdbeChangeP4(Vdbe p, int addr, int i32n, int n) { - union_p4 _p4 = new union_p4(); - _p4.i = i32n; - sqlite3VdbeChangeP4(p, addr, _p4, n); - } + /* + ** Link the SubProgram object passed as the second argument into the linked + ** list at Vdbe.pSubProgram. This list is used to delete all sub-program + ** objects when the VM is no longer required. + */ + static void sqlite3VdbeLinkSubProgram( Vdbe pVdbe, SubProgram p ) + { + p.pNext = pVdbe.pProgram; + pVdbe.pProgram = p; + } - //P4_KEYINFO - static void sqlite3VdbeChangeP4(Vdbe p, int addr, KeyInfo pKeyInfo, int n) { - union_p4 _p4 = new union_p4(); - _p4.pKeyInfo = pKeyInfo; - sqlite3VdbeChangeP4(p, addr, _p4, n); - } - //CHAR - static void sqlite3VdbeChangeP4(Vdbe p, int addr, char c, int n) { - union_p4 _p4 = new union_p4(); - _p4.z = c.ToString(); - sqlite3VdbeChangeP4(p, addr, _p4, n); + /* + ** Change N opcodes starting at addr to No-ops. + */ + static void sqlite3VdbeChangeToNoop( Vdbe p, int addr, int N ) + { + if ( p.aOp != null ) + { + sqlite3 db = p.db; + while ( N-- > 0 ) + { + VdbeOp pOp = p.aOp[addr + N]; + freeP4( db, pOp.p4type, pOp.p4.p ); + pOp = p.aOp[addr + N] = new VdbeOp();//memset(pOp, 0, sizeof(pOp[0])); + pOp.opcode = OP_Noop; + //pOp++; } + } + } - //MEM - static void sqlite3VdbeChangeP4(Vdbe p, int addr, Mem m, int n) { - union_p4 _p4 = new union_p4(); - _p4.pMem = m; - sqlite3VdbeChangeP4(p, addr, _p4, n); - } + /* + ** Change the value of the P4 operand for a specific instruction. + ** This routine is useful when a large program is loaded from a + ** static array using sqlite3VdbeAddOpList but we want to make a + ** few minor changes to the program. + ** + ** If n>=0 then the P4 operand is dynamic, meaning that a copy of + ** the string is made into memory obtained from sqlite3Malloc(). + ** A value of n==0 means copy bytes of zP4 up to and including the + ** first null byte. If n>0 then copy n+1 bytes of zP4. + ** + ** If n==P4_KEYINFO it means that zP4 is a pointer to a KeyInfo structure. + ** A copy is made of the KeyInfo structure into memory obtained from + ** sqlite3Malloc, to be freed when the Vdbe is finalized. + ** n==P4_KEYINFO_HANDOFF indicates that zP4 points to a KeyInfo structure + ** stored in memory that the caller has obtained from sqlite3Malloc. The + ** caller should not free the allocation, it will be freed when the Vdbe is + ** finalized. + ** + ** Other values of n (P4_STATIC, P4_COLLSEQ etc.) indicate that zP4 points + ** to a string or structure that is guaranteed to exist for the lifetime of + ** the Vdbe. In these cases we can just copy the pointer. + ** + ** If addr<0 then change P4 on the most recently inserted instruction. + */ - //STRING + //P4_COLLSEQ + static void sqlite3VdbeChangeP4( Vdbe p, int addr, CollSeq pColl, int n ) + { + union_p4 _p4 = new union_p4(); + _p4.pColl = pColl; + sqlite3VdbeChangeP4( p, addr, _p4, n ); + } + //P4_FUNCDEF + static void sqlite3VdbeChangeP4( Vdbe p, int addr, FuncDef pFunc, int n ) + { + union_p4 _p4 = new union_p4(); + _p4.pFunc = pFunc; + sqlite3VdbeChangeP4( p, addr, _p4, n ); + } + //P4_INT32 + static void sqlite3VdbeChangeP4( Vdbe p, int addr, int i32n, int n ) + { + union_p4 _p4 = new union_p4(); + _p4.i = i32n; + sqlite3VdbeChangeP4( p, addr, _p4, n ); + } - //STRING + Type - static void sqlite3VdbeChangeP4(Vdbe p, int addr, string z, dxDel P4_Type) { - union_p4 _p4 = new union_p4(); - _p4.z = z; - sqlite3VdbeChangeP4(p, addr, _p4, P4_DYNAMIC); - } + //P4_KEYINFO + static void sqlite3VdbeChangeP4( Vdbe p, int addr, KeyInfo pKeyInfo, int n ) + { + union_p4 _p4 = new union_p4(); + _p4.pKeyInfo = pKeyInfo; + sqlite3VdbeChangeP4( p, addr, _p4, n ); + } + //CHAR + static void sqlite3VdbeChangeP4( Vdbe p, int addr, char c, int n ) + { + union_p4 _p4 = new union_p4(); + _p4.z = c.ToString(); + sqlite3VdbeChangeP4( p, addr, _p4, n ); + } - //SUBPROGRAM - static void sqlite3VdbeChangeP4(Vdbe p, int addr, SubProgram pProgram, int n) { - union_p4 _p4 = new union_p4(); - _p4.pProgram = pProgram; - sqlite3VdbeChangeP4(p, addr, _p4, n); - } + //MEM + static void sqlite3VdbeChangeP4( Vdbe p, int addr, Mem m, int n ) + { + union_p4 _p4 = new union_p4(); + _p4.pMem = m; + sqlite3VdbeChangeP4( p, addr, _p4, n ); + } - static void sqlite3VdbeChangeP4(Vdbe p, int addr, string z, int n) { - union_p4 _p4 = new union_p4(); - if (n > 0 && n <= z.Length) - _p4.z = z.Substring(0, n); - else - _p4.z = z; - sqlite3VdbeChangeP4(p, addr, _p4, n); - } - - static void sqlite3VdbeChangeP4(Vdbe p, int addr, union_p4 _p4, int n) { - Op pOp; - sqlite3 db; - Debug.Assert(p != null); - db = p.db; - Debug.Assert(p.magic == VDBE_MAGIC_INIT); - if (p.aOp == null /*|| db.mallocFailed != 0 */) { - if (n != P4_KEYINFO && n != P4_VTAB) { - freeP4(db, n, _p4); - } - return; - } - Debug.Assert(p.nOp > 0); - Debug.Assert(addr < p.nOp); - if (addr < 0) { - addr = p.nOp - 1; - } - pOp = p.aOp[addr]; - freeP4(db, pOp.p4type, pOp.p4.p); - pOp.p4.p = null; - if (n == P4_INT32) { - /* Note: this cast is safe, because the origin data point was an int - ** that was cast to a (string ). */ - pOp.p4.i = _p4.i; // SQLITE_PTR_TO_INT(zP4); - pOp.p4type = P4_INT32; - } else if (n == P4_INT64) { - pOp.p4.pI64 = _p4.pI64; - pOp.p4type = n; - } else if (n == P4_REAL) { - pOp.p4.pReal = _p4.pReal; - pOp.p4type = n; - } else if (_p4 == null) { - pOp.p4.p = null; - pOp.p4type = P4_NOTUSED; - } else if (n == P4_KEYINFO) { - KeyInfo pKeyInfo; - int nByte; - - //int nField = _p4.pKeyInfo.nField; - //nByte = sizeof(*pKeyInfo) + (nField-1)*sizeof(pKeyInfo.aColl[0]) + nField; - pKeyInfo = new KeyInfo();//sqlite3DbMallocRaw(0, nByte); - pOp.p4.pKeyInfo = pKeyInfo; - if (pKeyInfo != null) { - //u8 *aSortOrder; - // memcpy((char)pKeyInfo, zP4, nByte - nField); - //aSortOrder = pKeyInfo.aSortOrder; - //if( aSortOrder ){ - // pKeyInfo.aSortOrder = (unsigned char)&pKeyInfo.aColl[nField]; - // memcpy(pKeyInfo.aSortOrder, aSortOrder, nField); - //} - pKeyInfo = _p4.pKeyInfo.Copy(); - pOp.p4type = P4_KEYINFO; - } else { - //p.db.mallocFailed = 1; - pOp.p4type = P4_NOTUSED; - } - pOp.p4.pKeyInfo = _p4.pKeyInfo; - pOp.p4type = P4_KEYINFO; - } else if (n == P4_KEYINFO_HANDOFF || n == P4_KEYINFO_STATIC) { - pOp.p4.pKeyInfo = _p4.pKeyInfo; - pOp.p4type = P4_KEYINFO; - } else if (n == P4_FUNCDEF) { - pOp.p4.pFunc = _p4.pFunc; - pOp.p4type = P4_FUNCDEF; - } else if (n == P4_COLLSEQ) { - pOp.p4.pColl = _p4.pColl; - pOp.p4type = P4_COLLSEQ; - } else if (n == P4_DYNAMIC || n == P4_STATIC || n == P4_MPRINTF) { - pOp.p4.z = _p4.z; - pOp.p4type = P4_DYNAMIC; - } else if (n == P4_MEM) { - pOp.p4.pMem = _p4.pMem; - pOp.p4type = P4_MEM; - } else if (n == P4_INTARRAY) { - pOp.p4.ai = _p4.ai; - pOp.p4type = P4_INTARRAY; - } else if (n == P4_SUBPROGRAM) { - pOp.p4.pProgram = _p4.pProgram; - pOp.p4type = P4_SUBPROGRAM; - } else if (n == P4_VTAB) { - pOp.p4.pVtab = _p4.pVtab; - pOp.p4type = P4_VTAB; - sqlite3VtabLock(_p4.pVtab); - Debug.Assert((_p4.pVtab).db == p.db); - } else if (n < 0) { - pOp.p4.p = _p4.p; - pOp.p4type = n; - } else { - //if (n == 0) n = n = sqlite3Strlen30(zP4); - pOp.p4.z = _p4.z;// sqlite3DbStrNDup(p.db, zP4, n); - pOp.p4type = P4_DYNAMIC; - } + //STRING + + //STRING + Type + static void sqlite3VdbeChangeP4( Vdbe p, int addr, string z, dxDel P4_Type ) + { + union_p4 _p4 = new union_p4(); + _p4.z = z; + sqlite3VdbeChangeP4( p, addr, _p4, P4_DYNAMIC ); + } + + //SUBPROGRAM + static void sqlite3VdbeChangeP4( Vdbe p, int addr, SubProgram pProgram, int n ) + { + union_p4 _p4 = new union_p4(); + _p4.pProgram = pProgram; + sqlite3VdbeChangeP4( p, addr, _p4, n ); + } + + static void sqlite3VdbeChangeP4( Vdbe p, int addr, string z, int n ) + { + union_p4 _p4 = new union_p4(); + if ( n > 0 && n <= z.Length ) + _p4.z = z.Substring( 0, n ); + else + _p4.z = z; + sqlite3VdbeChangeP4( p, addr, _p4, n ); + } + + static void sqlite3VdbeChangeP4( Vdbe p, int addr, union_p4 _p4, int n ) + { + Op pOp; + sqlite3 db; + Debug.Assert( p != null ); + db = p.db; + Debug.Assert( p.magic == VDBE_MAGIC_INIT ); + if ( p.aOp == null /*|| db.mallocFailed != 0 */) + { + if ( n != P4_KEYINFO && n != P4_VTAB ) + { + freeP4( db, n, _p4 ); } + return; + } + Debug.Assert( p.nOp > 0 ); + Debug.Assert( addr < p.nOp ); + if ( addr < 0 ) + { + addr = p.nOp - 1; + } + pOp = p.aOp[addr]; + freeP4( db, pOp.p4type, pOp.p4.p ); + pOp.p4.p = null; + if ( n == P4_INT32 ) + { + /* Note: this cast is safe, because the origin data point was an int + ** that was cast to a (string ). */ + pOp.p4.i = _p4.i; // SQLITE_PTR_TO_INT(zP4); + pOp.p4type = P4_INT32; + } + else if ( n == P4_INT64 ) + { + pOp.p4.pI64 = _p4.pI64; + pOp.p4type = n; + } + else if ( n == P4_REAL ) + { + pOp.p4.pReal = _p4.pReal; + pOp.p4type = n; + } + else if ( _p4 == null ) + { + pOp.p4.p = null; + pOp.p4type = P4_NOTUSED; + } + else if ( n == P4_KEYINFO ) + { + KeyInfo pKeyInfo; + int nByte; + + //int nField = _p4.pKeyInfo.nField; + //nByte = sizeof(*pKeyInfo) + (nField-1)*sizeof(pKeyInfo.aColl[0]) + nField; + pKeyInfo = new KeyInfo();//sqlite3DbMallocRaw(0, nByte); + pOp.p4.pKeyInfo = pKeyInfo; + if ( pKeyInfo != null ) + { + //u8 *aSortOrder; + // memcpy((char)pKeyInfo, zP4, nByte - nField); + //aSortOrder = pKeyInfo.aSortOrder; + //if( aSortOrder ){ + // pKeyInfo.aSortOrder = (unsigned char)&pKeyInfo.aColl[nField]; + // memcpy(pKeyInfo.aSortOrder, aSortOrder, nField); + //} + pKeyInfo = _p4.pKeyInfo.Copy(); + pOp.p4type = P4_KEYINFO; + } + else + { + //p.db.mallocFailed = 1; + pOp.p4type = P4_NOTUSED; + } + pOp.p4.pKeyInfo = _p4.pKeyInfo; + pOp.p4type = P4_KEYINFO; + } + else if ( n == P4_KEYINFO_HANDOFF || n == P4_KEYINFO_STATIC ) + { + pOp.p4.pKeyInfo = _p4.pKeyInfo; + pOp.p4type = P4_KEYINFO; + } + else if ( n == P4_FUNCDEF ) + { + pOp.p4.pFunc = _p4.pFunc; + pOp.p4type = P4_FUNCDEF; + } + else if ( n == P4_COLLSEQ ) + { + pOp.p4.pColl = _p4.pColl; + pOp.p4type = P4_COLLSEQ; + } + else if ( n == P4_DYNAMIC || n == P4_STATIC || n == P4_MPRINTF ) + { + pOp.p4.z = _p4.z; + pOp.p4type = P4_DYNAMIC; + } + else if ( n == P4_MEM ) + { + pOp.p4.pMem = _p4.pMem; + pOp.p4type = P4_MEM; + } + else if ( n == P4_INTARRAY ) + { + pOp.p4.ai = _p4.ai; + pOp.p4type = P4_INTARRAY; + } + else if ( n == P4_SUBPROGRAM ) + { + pOp.p4.pProgram = _p4.pProgram; + pOp.p4type = P4_SUBPROGRAM; + } + else if ( n == P4_VTAB ) + { + pOp.p4.pVtab = _p4.pVtab; + pOp.p4type = P4_VTAB; + sqlite3VtabLock( _p4.pVtab ); + Debug.Assert( ( _p4.pVtab ).db == p.db ); + } + else if ( n < 0 ) + { + pOp.p4.p = _p4.p; + pOp.p4type = n; + } + else + { + //if (n == 0) n = n = sqlite3Strlen30(zP4); + pOp.p4.z = _p4.z;// sqlite3DbStrNDup(p.db, zP4, n); + pOp.p4type = P4_DYNAMIC; + } + } #if !NDEBUG - /* - ** Change the comment on the the most recently coded instruction. Or - ** insert a No-op and add the comment to that new instruction. This - ** makes the code easier to read during debugging. None of this happens - ** in a production build. - */ - static void sqlite3VdbeComment(Vdbe p, string zFormat, params object[] ap) { - if (null == p) - return; - // va_list ap; - lock (lock_va_list) { - Debug.Assert(p.nOp > 0 || p.aOp == null); - Debug.Assert(p.aOp == null || p.aOp[p.nOp - 1].zComment == null /* || p.db.mallocFailed != 0 */); - if (p.nOp != 0) { - string pz;// = p.aOp[p.nOp-1].zComment; - va_start(ap, zFormat); - //sqlite3DbFree(db, ref pz); - pz = sqlite3VMPrintf(p.db, zFormat, ap); - p.aOp[p.nOp - 1].zComment = pz; - va_end(ref ap); - } - } + /* +** Change the comment on the the most recently coded instruction. Or +** insert a No-op and add the comment to that new instruction. This +** makes the code easier to read during debugging. None of this happens +** in a production build. +*/ + static void sqlite3VdbeComment( Vdbe p, string zFormat, params object[] ap ) + { + if ( null == p ) + return; + // va_list ap; + lock ( lock_va_list ) + { + Debug.Assert( p.nOp > 0 || p.aOp == null ); + Debug.Assert( p.aOp == null || p.aOp[p.nOp - 1].zComment == null /* || p.db.mallocFailed != 0 */); + if ( p.nOp != 0 ) + { + string pz;// = p.aOp[p.nOp-1].zComment; + va_start( ap, zFormat ); + //sqlite3DbFree(db, ref pz); + pz = sqlite3VMPrintf( p.db, zFormat, ap ); + p.aOp[p.nOp - 1].zComment = pz; + va_end( ref ap ); } - static void sqlite3VdbeNoopComment(Vdbe p, string zFormat, params object[] ap) { - if (null == p) - return; - //va_list ap; - lock (lock_va_list) { - sqlite3VdbeAddOp0(p, OP_Noop); - Debug.Assert(p.nOp > 0 || p.aOp == null); - Debug.Assert(p.aOp == null || p.aOp[p.nOp - 1].zComment == null /* || p.db.mallocFailed != 0 */); - if (p.nOp != 0) { - string pz; // = p.aOp[p.nOp - 1].zComment; - va_start(ap, zFormat); - //sqlite3DbFree(db,ref pz); - pz = sqlite3VMPrintf(p.db, zFormat, ap); - p.aOp[p.nOp - 1].zComment = pz; - va_end(ref ap); - } - } + } + } + static void sqlite3VdbeNoopComment( Vdbe p, string zFormat, params object[] ap ) + { + if ( null == p ) + return; + //va_list ap; + lock ( lock_va_list ) + { + sqlite3VdbeAddOp0( p, OP_Noop ); + Debug.Assert( p.nOp > 0 || p.aOp == null ); + Debug.Assert( p.aOp == null || p.aOp[p.nOp - 1].zComment == null /* || p.db.mallocFailed != 0 */); + if ( p.nOp != 0 ) + { + string pz; // = p.aOp[p.nOp - 1].zComment; + va_start( ap, zFormat ); + //sqlite3DbFree(db,ref pz); + pz = sqlite3VMPrintf( p.db, zFormat, ap ); + p.aOp[p.nOp - 1].zComment = pz; + va_end( ref ap ); } + } + } #else #endif //* NDEBUG */ - /* - ** Return the opcode for a given address. If the address is -1, then - ** return the most recently inserted opcode. - ** - ** If a memory allocation error has occurred prior to the calling of this - ** routine, then a pointer to a dummy VdbeOp will be returned. That opcode - ** is readable but not writable, though it is cast to a writable value. - ** The return of a dummy opcode allows the call to continue functioning - ** after a OOM fault without having to check to see if the return from - ** this routine is a valid pointer. But because the dummy.opcode is 0, - ** dummy will never be written to. This is verified by code inspection and - ** by running with Valgrind. - ** - ** About the #if SQLITE_OMIT_TRACE: Normally, this routine is never called - ** unless p->nOp>0. This is because in the absense of SQLITE_OMIT_TRACE, - ** an OP_Trace instruction is always inserted by sqlite3VdbeGet() as soon as - ** a new VDBE is created. So we are free to set addr to p->nOp-1 without - ** having to double-check to make sure that the result is non-negative. But - ** if SQLITE_OMIT_TRACE is defined, the OP_Trace is omitted and we do need to - ** check the value of p->nOp-1 before continuing. - */ - const VdbeOp dummy = null; /* Ignore the MSVC warning about no initializer */ - static VdbeOp sqlite3VdbeGetOp(Vdbe p, int addr) { - /* C89 specifies that the constant "dummy" will be initialized to all - ** zeros, which is correct. MSVC generates a warning, nevertheless. */ - Debug.Assert(p.magic == VDBE_MAGIC_INIT); - if (addr < 0) { + /* +** Return the opcode for a given address. If the address is -1, then +** return the most recently inserted opcode. +** +** If a memory allocation error has occurred prior to the calling of this +** routine, then a pointer to a dummy VdbeOp will be returned. That opcode +** is readable but not writable, though it is cast to a writable value. +** The return of a dummy opcode allows the call to continue functioning +** after a OOM fault without having to check to see if the return from +** this routine is a valid pointer. But because the dummy.opcode is 0, +** dummy will never be written to. This is verified by code inspection and +** by running with Valgrind. +** +** About the #if SQLITE_OMIT_TRACE: Normally, this routine is never called +** unless p->nOp>0. This is because in the absense of SQLITE_OMIT_TRACE, +** an OP_Trace instruction is always inserted by sqlite3VdbeGet() as soon as +** a new VDBE is created. So we are free to set addr to p->nOp-1 without +** having to double-check to make sure that the result is non-negative. But +** if SQLITE_OMIT_TRACE is defined, the OP_Trace is omitted and we do need to +** check the value of p->nOp-1 before continuing. +*/ + const VdbeOp dummy = null; /* Ignore the MSVC warning about no initializer */ + static VdbeOp sqlite3VdbeGetOp( Vdbe p, int addr ) + { + /* C89 specifies that the constant "dummy" will be initialized to all + ** zeros, which is correct. MSVC generates a warning, nevertheless. */ + Debug.Assert( p.magic == VDBE_MAGIC_INIT ); + if ( addr < 0 ) + { #if SQLITE_OMIT_TRACE if( p.nOp==0 ) return dummy; #endif - addr = p.nOp - 1; + addr = p.nOp - 1; + } + Debug.Assert( ( addr >= 0 && addr < p.nOp ) /* || p.db.mallocFailed != 0 */); + //if ( p.db.mallocFailed != 0 ) + //{ + // return dummy; + //} + //else + { + return p.aOp[addr]; + } + } + +#if !SQLITE_OMIT_EXPLAIN || !NDEBUG || VDBE_PROFILE || SQLITE_DEBUG + /* +** Compute a string that describes the P4 parameter for an opcode. +** Use zTemp for any required temporary buffer space. +*/ + static StringBuilder zTemp = new StringBuilder( 100 ); + static string displayP4( Op pOp, string zBuffer, int nTemp ) + { + zTemp.Length = 0; + Debug.Assert( nTemp >= 20 ); + switch ( pOp.p4type ) + { + case P4_KEYINFO_STATIC: + case P4_KEYINFO: + { + int i, j; + KeyInfo pKeyInfo = pOp.p4.pKeyInfo; + sqlite3_snprintf( nTemp, zTemp, "keyinfo(%d", pKeyInfo.nField ); + i = sqlite3Strlen30( zTemp ); + for ( j = 0; j < pKeyInfo.nField; j++ ) + { + CollSeq pColl = pKeyInfo.aColl[j]; + if ( pColl != null ) + { + int n = sqlite3Strlen30( pColl.zName ); + if ( i + n > nTemp ) + { + zTemp.Append( ",..." ); // memcpy( &zTemp[i], ",...", 4 ); + break; + } + zTemp.Append( "," );// zTemp[i++] = ','; + if ( pKeyInfo.aSortOrder != null && pKeyInfo.aSortOrder[j] != 0 ) + { + zTemp.Append( "-" );// zTemp[i++] = '-'; + } + zTemp.Append( pColl.zName );// memcpy( &zTemp[i], pColl.zName, n + 1 ); + i += n; + } + else if ( i + 4 < nTemp ) + { + zTemp.Append( ",nil" );// memcpy( &zTemp[i], ",nil", 4 ); + i += 4; + } } - Debug.Assert((addr >= 0 && addr < p.nOp) /* || p.db.mallocFailed != 0 */); - //if ( p.db.mallocFailed != 0 ) - //{ - // return dummy; - //} - //else + zTemp.Append( ")" );// zTemp[i++] = ')'; + //zTemp[i] = 0; + Debug.Assert( i < nTemp ); + break; + } + case P4_COLLSEQ: + { + CollSeq pColl = pOp.p4.pColl; + sqlite3_snprintf( nTemp, zTemp, "collseq(%.20s)", ( pColl != null ? pColl.zName : "null" ) ); + break; + } + case P4_FUNCDEF: + { + FuncDef pDef = pOp.p4.pFunc; + sqlite3_snprintf( nTemp, zTemp, "%s(%d)", pDef.zName, pDef.nArg ); + break; + } + case P4_INT64: + { + sqlite3_snprintf( nTemp, zTemp, "%lld", pOp.p4.pI64 ); + break; + } + case P4_INT32: + { + sqlite3_snprintf( nTemp, zTemp, "%d", pOp.p4.i ); + break; + } + case P4_REAL: + { + sqlite3_snprintf( nTemp, zTemp, "%.16g", pOp.p4.pReal ); + break; + } + case P4_MEM: + { + Mem pMem = pOp.p4.pMem; + Debug.Assert( ( pMem.flags & MEM_Null ) == 0 ); + if ( ( pMem.flags & MEM_Str ) != 0 ) { - return p.aOp[addr]; + zTemp.Append( pMem.z ); } - } - -#if !SQLITE_OMIT_EXPLAIN || !NDEBUG || VDBE_PROFILE || SQLITE_DEBUG - /* - ** Compute a string that describes the P4 parameter for an opcode. - ** Use zTemp for any required temporary buffer space. - */ - static StringBuilder zTemp = new StringBuilder(100); - static string displayP4(Op pOp, string zBuffer, int nTemp) { - zTemp.Length = 0; - Debug.Assert(nTemp >= 20); - switch (pOp.p4type) { - case P4_KEYINFO_STATIC: - case P4_KEYINFO: { - int i, j; - KeyInfo pKeyInfo = pOp.p4.pKeyInfo; - sqlite3_snprintf(nTemp, zTemp, "keyinfo(%d", pKeyInfo.nField); - i = sqlite3Strlen30(zTemp); - for (j = 0; j < pKeyInfo.nField; j++) { - CollSeq pColl = pKeyInfo.aColl[j]; - if (pColl != null) { - int n = sqlite3Strlen30(pColl.zName); - if (i + n > nTemp) { - zTemp.Append(",..."); // memcpy( &zTemp[i], ",...", 4 ); - break; - } - zTemp.Append(",");// zTemp[i++] = ','; - if (pKeyInfo.aSortOrder != null && pKeyInfo.aSortOrder[j] != 0) { - zTemp.Append("-");// zTemp[i++] = '-'; - } - zTemp.Append(pColl.zName);// memcpy( &zTemp[i], pColl.zName, n + 1 ); - i += n; - } else if (i + 4 < nTemp) { - zTemp.Append(",nil");// memcpy( &zTemp[i], ",nil", 4 ); - i += 4; - } - } - zTemp.Append(")");// zTemp[i++] = ')'; - //zTemp[i] = 0; - Debug.Assert(i < nTemp); - break; - } - case P4_COLLSEQ: { - CollSeq pColl = pOp.p4.pColl; - sqlite3_snprintf(nTemp, zTemp, "collseq(%.20s)", (pColl != null ? pColl.zName : "null")); - break; - } - case P4_FUNCDEF: { - FuncDef pDef = pOp.p4.pFunc; - sqlite3_snprintf(nTemp, zTemp, "%s(%d)", pDef.zName, pDef.nArg); - break; - } - case P4_INT64: { - sqlite3_snprintf(nTemp, zTemp, "%lld", pOp.p4.pI64); - break; - } - case P4_INT32: { - sqlite3_snprintf(nTemp, zTemp, "%d", pOp.p4.i); - break; - } - case P4_REAL: { - sqlite3_snprintf(nTemp, zTemp, "%.16g", pOp.p4.pReal); - break; - } - case P4_MEM: { - Mem pMem = pOp.p4.pMem; - Debug.Assert((pMem.flags & MEM_Null) == 0); - if ((pMem.flags & MEM_Str) != 0) { - zTemp.Append(pMem.z); - } else if ((pMem.flags & MEM_Int) != 0) { - sqlite3_snprintf(nTemp, zTemp, "%lld", pMem.u.i); - } else if ((pMem.flags & MEM_Real) != 0) { - sqlite3_snprintf(nTemp, zTemp, "%.16g", pMem.r); - } else { - Debug.Assert((pMem.flags & MEM_Blob) != 0); - zTemp = new StringBuilder("(blob)"); - } - break; - } + else if ( ( pMem.flags & MEM_Int ) != 0 ) + { + sqlite3_snprintf( nTemp, zTemp, "%lld", pMem.u.i ); + } + else if ( ( pMem.flags & MEM_Real ) != 0 ) + { + sqlite3_snprintf( nTemp, zTemp, "%.16g", pMem.r ); + } + else + { + Debug.Assert( ( pMem.flags & MEM_Blob ) != 0 ); + zTemp = new StringBuilder( "(blob)" ); + } + break; + } #if !SQLITE_OMIT_VIRTUALTABLE - case P4_VTAB: { - sqlite3_vtab pVtab = pOp.p4.pVtab.pVtab; - sqlite3_snprintf(nTemp, zTemp, "vtab:%p:%p", pVtab, pVtab.pModule); - break; - } + case P4_VTAB: + { + sqlite3_vtab pVtab = pOp.p4.pVtab.pVtab; + sqlite3_snprintf( nTemp, zTemp, "vtab:%p:%p", pVtab, pVtab.pModule ); + break; + } #endif - case P4_INTARRAY: { - sqlite3_snprintf(nTemp, zTemp, "intarray"); - break; - } - case P4_SUBPROGRAM: { - sqlite3_snprintf(nTemp, zTemp, "program"); - break; - } - default: { - if (pOp.p4.z != null) - zTemp.Append(pOp.p4.z); - //if ( zTemp == null ) - //{ - // zTemp = ""; - //} - break; - } - } - Debug.Assert(zTemp != null); - return zTemp.ToString(); - } + case P4_INTARRAY: + { + sqlite3_snprintf( nTemp, zTemp, "intarray" ); + break; + } + case P4_SUBPROGRAM: + { + sqlite3_snprintf( nTemp, zTemp, "program" ); + break; + } + default: + { + if ( pOp.p4.z != null ) + zTemp.Append( pOp.p4.z ); + //if ( zTemp == null ) + //{ + // zTemp = ""; + //} + break; + } + } + Debug.Assert( zTemp != null ); + return zTemp.ToString(); + } #endif - /* - ** Declare to the Vdbe that the BTree object at db->aDb[i] is used. - ** - ** The prepared statements need to know in advance the complete set of - ** attached databases that they will be using. A mask of these databases - ** is maintained in p->btreeMask and is used for locking and other purposes. - */ - static void sqlite3VdbeUsesBtree(Vdbe p, int i) { - Debug.Assert(i >= 0 && i < p.db.nDb && i < (int)sizeof(yDbMask) * 8); - Debug.Assert(i < (int)sizeof(yDbMask) * 8); - p.btreeMask |= ((yDbMask)1) << i; - if (i != 1 && sqlite3BtreeSharable(p.db.aDb[i].pBt)) { - p.lockMask |= ((yDbMask)1) << i; - } - } + /* + ** Declare to the Vdbe that the BTree object at db->aDb[i] is used. + ** + ** The prepared statements need to know in advance the complete set of + ** attached databases that they will be using. A mask of these databases + ** is maintained in p->btreeMask and is used for locking and other purposes. + */ + static void sqlite3VdbeUsesBtree( Vdbe p, int i ) + { + Debug.Assert( i >= 0 && i < p.db.nDb && i < (int)sizeof( yDbMask ) * 8 ); + Debug.Assert( i < (int)sizeof( yDbMask ) * 8 ); + p.btreeMask |= ( (yDbMask)1 ) << i; + if ( i != 1 && sqlite3BtreeSharable( p.db.aDb[i].pBt ) ) + { + p.lockMask |= ( (yDbMask)1 ) << i; + } + } #if !(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE//>0 /* @@ -1334,350 +1514,391 @@ void sqlite3VdbeLeave(Vdbe *p){ #if VDBE_PROFILE || SQLITE_DEBUG - /* - ** Print a single opcode. This routine is used for debugging only. - */ - static void sqlite3VdbePrintOp(FILE pOut, int pc, Op pOp) { - string zP4; - string zPtr = null; - string zFormat1 = "%4d %-13s %4d %4d %4d %-4s %.2X %s\n"; - if (pOut == null) - pOut = System.Console.Out; - zP4 = displayP4(pOp, zPtr, 50); - StringBuilder zOut = new StringBuilder(10); - sqlite3_snprintf(999, zOut, zFormat1, pc, - sqlite3OpcodeName(pOp.opcode), pOp.p1, pOp.p2, pOp.p3, zP4, pOp.p5, -#if SQLITE_DEBUG - pOp.zComment != null ? pOp.zComment : "" + /* +** Print a single opcode. This routine is used for debugging only. +*/ + static void sqlite3VdbePrintOp( FILE pOut, int pc, Op pOp ) + { + string zP4; + string zPtr = null; + string zFormat1 = "%4d %-13s %4d %4d %4d %-4s %.2X %s\n"; + if ( pOut == null ) + pOut = System.Console.Out; + zP4 = displayP4( pOp, zPtr, 50 ); + StringBuilder zOut = new StringBuilder( 10 ); + sqlite3_snprintf( 999, zOut, zFormat1, pc, + sqlite3OpcodeName( pOp.opcode ), pOp.p1, pOp.p2, pOp.p3, zP4, pOp.p5, +#if SQLITE_DEBUG + pOp.zComment != null ? pOp.zComment : "" #else "" #endif - ); - pOut.Write(zOut); - //fflush(pOut); - } + ); + pOut.Write( zOut ); + //fflush(pOut); + } #endif - /* - ** Release an array of N Mem elements - */ - static void releaseMemArray(Mem[] p, int N) { - releaseMemArray(p, 0, N); - } - static void releaseMemArray(Mem[] p, int starting, int N) { - if (p != null && p.Length > starting && p[starting] != null && N != 0) { - Mem pEnd; - //sqlite3 db = p[starting].db; - //u8 malloc_failed = db.mallocFailed; - //if ( db != null ) //&& db.pnBytesFreed != 0 ) - //{ - // for ( int i = starting; i < N; i++ )//pEnd = p[N] ; p < pEnd ; p++ ) - // { - // sqlite3DbFree( db, ref p[i].zMalloc ); - // } - // return; - //} - for (int i = starting; i < N; i++)//pEnd = p[N] ; p < pEnd ; p++ ) - { - pEnd = p[i]; - Debug.Assert( //( p[1] ) == pEnd || - N == 1 || i == p.Length - 1 || p[starting].db == p[starting + 1].db); - - /* This block is really an inlined version of sqlite3VdbeMemRelease() - ** that takes advantage of the fact that the memory cell value is - ** being set to NULL after releasing any dynamic resources. - ** - ** The justification for duplicating code is that according to - ** callgrind, this causes a certain test case to hit the CPU 4.7 - ** percent less (x86 linux, gcc version 4.1.2, -O6) than if - ** sqlite3MemRelease() were called from here. With -O2, this jumps - ** to 6.6 percent. The test case is inserting 1000 rows into a table - ** with no indexes using a single prepared INSERT statement, bind() - ** and reset(). Inserts are grouped into a transaction. - */ - if (pEnd != null) { - if ((pEnd.flags & (MEM_Agg | MEM_Dyn | MEM_Frame | MEM_RowSet)) != 0) { - sqlite3VdbeMemRelease(pEnd); - } - //else if ( pEnd.zMalloc != null ) - //{ - // sqlite3DbFree( db, ref pEnd.zMalloc ); - // pEnd.zMalloc = 0; - //} - pEnd.z = null; - pEnd.n = 0; - pEnd.flags = MEM_Null; - sqlite3_free(ref pEnd._Mem); - sqlite3_free(ref pEnd.zBLOB); - } - } - // db.mallocFailed = malloc_failed; + /* +** Release an array of N Mem elements +*/ + static void releaseMemArray( Mem[] p, int N ) + { + releaseMemArray( p, 0, N ); + } + static void releaseMemArray( Mem[] p, int starting, int N ) + { + if ( p != null && p.Length > starting && p[starting] != null && N != 0 ) + { + Mem pEnd; + //sqlite3 db = p[starting].db; + //u8 malloc_failed = db.mallocFailed; + //if ( db != null ) //&& db.pnBytesFreed != 0 ) + //{ + // for ( int i = starting; i < N; i++ )//pEnd = p[N] ; p < pEnd ; p++ ) + // { + // sqlite3DbFree( db, ref p[i].zMalloc ); + // } + // return; + //} + for ( int i = starting; i < N; i++ )//pEnd = p[N] ; p < pEnd ; p++ ) + { + pEnd = p[i]; + Debug.Assert( //( p[1] ) == pEnd || + N == 1 || i == p.Length - 1 || p[starting].db == p[starting + 1].db ); + + /* This block is really an inlined version of sqlite3VdbeMemRelease() + ** that takes advantage of the fact that the memory cell value is + ** being set to NULL after releasing any dynamic resources. + ** + ** The justification for duplicating code is that according to + ** callgrind, this causes a certain test case to hit the CPU 4.7 + ** percent less (x86 linux, gcc version 4.1.2, -O6) than if + ** sqlite3MemRelease() were called from here. With -O2, this jumps + ** to 6.6 percent. The test case is inserting 1000 rows into a table + ** with no indexes using a single prepared INSERT statement, bind() + ** and reset(). Inserts are grouped into a transaction. + */ + if ( pEnd != null ) + { + if ( ( pEnd.flags & ( MEM_Agg | MEM_Dyn | MEM_Frame | MEM_RowSet ) ) != 0 ) + { + sqlite3VdbeMemRelease( pEnd ); } + //else if ( pEnd.zMalloc != null ) + //{ + // sqlite3DbFree( db, ref pEnd.zMalloc ); + // pEnd.zMalloc = 0; + //} + pEnd.z = null; + pEnd.n = 0; + pEnd.flags = MEM_Null; + sqlite3_free( ref pEnd._Mem ); + sqlite3_free( ref pEnd.zBLOB ); + } } + // db.mallocFailed = malloc_failed; + } + } - /* - ** Delete a VdbeFrame object and its contents. VdbeFrame objects are - ** allocated by the OP_Program opcode in sqlite3VdbeExec(). - */ - static void sqlite3VdbeFrameDelete(VdbeFrame p) { - int i; - //Mem[] aMem = VdbeFrameMem(p); - VdbeCursor[] apCsr = p.aChildCsr;// (VdbeCursor)aMem[p.nChildMem]; - for (i = 0; i < p.nChildCsr; i++) { - sqlite3VdbeFreeCursor(p.v, apCsr[i]); - } - releaseMemArray(p.aChildMem, p.nChildMem); - p = null;// sqlite3DbFree( p.v.db, p ); - } + /* + ** Delete a VdbeFrame object and its contents. VdbeFrame objects are + ** allocated by the OP_Program opcode in sqlite3VdbeExec(). + */ + static void sqlite3VdbeFrameDelete( VdbeFrame p ) + { + int i; + //Mem[] aMem = VdbeFrameMem(p); + VdbeCursor[] apCsr = p.aChildCsr;// (VdbeCursor)aMem[p.nChildMem]; + for ( i = 0; i < p.nChildCsr; i++ ) + { + sqlite3VdbeFreeCursor( p.v, apCsr[i] ); + } + releaseMemArray( p.aChildMem, p.nChildMem ); + p = null;// sqlite3DbFree( p.v.db, p ); + } #if !SQLITE_OMIT_EXPLAIN - /* - ** Give a listing of the program in the virtual machine. - ** - ** The interface is the same as sqlite3VdbeExec(). But instead of - ** running the code, it invokes the callback once for each instruction. - ** This feature is used to implement "EXPLAIN". - ** - ** When p.explain==1, each instruction is listed. When - ** p.explain==2, only OP_Explain instructions are listed and these - ** are shown in a different format. p.explain==2 is used to implement - ** EXPLAIN QUERY PLAN. - ** - ** When p->explain==1, first the main program is listed, then each of - ** the trigger subprograms are listed one by one. - */ - static int sqlite3VdbeList( - Vdbe p /* The VDBE */ - ) { - int nRow; /* Stop when row count reaches this */ - int nSub = 0; /* Number of sub-vdbes seen so far */ - SubProgram[] apSub = null; /* Array of sub-vdbes */ - Mem pSub = null; /* Memory cell hold array of subprogs */ - sqlite3 db = p.db; /* The database connection */ - int i; /* Loop counter */ - int rc = SQLITE_OK; /* Return code */ - if (p.pResultSet == null) - p.pResultSet = Array.Empty();//Mem* pMem = p.pResultSet = p.aMem[1]; /* First Mem of result set */ - Mem pMem; - Debug.Assert(p.explain != 0); - Debug.Assert(p.magic == VDBE_MAGIC_RUN); - Debug.Assert(p.rc == SQLITE_OK || p.rc == SQLITE_BUSY || p.rc == SQLITE_NOMEM); - /* Even though this opcode does not use dynamic strings for - ** the result, result columns may become dynamic if the user calls - ** sqlite3_column_text16(), causing a translation to UTF-16 encoding. - */ - releaseMemArray(p.pResultSet, 8); - - //if ( p.rc == SQLITE_NOMEM ) - //{ - // /* This happens if a malloc() inside a call to sqlite3_column_text() or - // ** sqlite3_column_text16() failed. */ - // db.mallocFailed = 1; - // return SQLITE_ERROR; - //} - - /* When the number of output rows reaches nRow, that means the - ** listing has finished and sqlite3_step() should return SQLITE_DONE. - ** nRow is the sum of the number of rows in the main program, plus - ** the sum of the number of rows in all trigger subprograms encountered - ** so far. The nRow value will increase as new trigger subprograms are - ** encountered, but p->pc will eventually catch up to nRow. - */ - nRow = p.nOp; - int i_pMem; - if (p.explain == 1) { - /* The first 8 memory cells are used for the result set. So we will - ** commandeer the 9th cell to use as storage for an array of pointers - ** to trigger subprograms. The VDBE is guaranteed to have at least 9 - ** cells. */ - Debug.Assert(p.nMem > 9); - pSub = p.aMem[9]; - if ((pSub.flags & MEM_Blob) != 0) { - /* On the first call to sqlite3_step(), pSub will hold a NULL. It is - ** initialized to a BLOB by the P4_SUBPROGRAM processing logic below */ - apSub = p.aMem[9]._SubProgram; // apSub = (SubProgram*)pSub->z; - nSub = apSub.Length;// pSub->n / sizeof( Vdbe* ); - } - for (i = 0; i < nSub; i++) { - nRow += apSub[i].nOp; - } - } + /* +** Give a listing of the program in the virtual machine. +** +** The interface is the same as sqlite3VdbeExec(). But instead of +** running the code, it invokes the callback once for each instruction. +** This feature is used to implement "EXPLAIN". +** +** When p.explain==1, each instruction is listed. When +** p.explain==2, only OP_Explain instructions are listed and these +** are shown in a different format. p.explain==2 is used to implement +** EXPLAIN QUERY PLAN. +** +** When p->explain==1, first the main program is listed, then each of +** the trigger subprograms are listed one by one. +*/ + static int sqlite3VdbeList( + Vdbe p /* The VDBE */ + ) + { + int nRow; /* Stop when row count reaches this */ + int nSub = 0; /* Number of sub-vdbes seen so far */ + SubProgram[] apSub = null; /* Array of sub-vdbes */ + Mem pSub = null; /* Memory cell hold array of subprogs */ + sqlite3 db = p.db; /* The database connection */ + int i; /* Loop counter */ + int rc = SQLITE_OK; /* Return code */ + if ( p.pResultSet == null ) + p.pResultSet = Array.Empty();//Mem* pMem = p.pResultSet = p.aMem[1]; /* First Mem of result set */ + Mem pMem; + Debug.Assert( p.explain != 0 ); + Debug.Assert( p.magic == VDBE_MAGIC_RUN ); + Debug.Assert( p.rc == SQLITE_OK || p.rc == SQLITE_BUSY || p.rc == SQLITE_NOMEM ); + /* Even though this opcode does not use dynamic strings for + ** the result, result columns may become dynamic if the user calls + ** sqlite3_column_text16(), causing a translation to UTF-16 encoding. + */ + releaseMemArray( p.pResultSet, 8 ); + + //if ( p.rc == SQLITE_NOMEM ) + //{ + // /* This happens if a malloc() inside a call to sqlite3_column_text() or + // ** sqlite3_column_text16() failed. */ + // db.mallocFailed = 1; + // return SQLITE_ERROR; + //} + + /* When the number of output rows reaches nRow, that means the + ** listing has finished and sqlite3_step() should return SQLITE_DONE. + ** nRow is the sum of the number of rows in the main program, plus + ** the sum of the number of rows in all trigger subprograms encountered + ** so far. The nRow value will increase as new trigger subprograms are + ** encountered, but p->pc will eventually catch up to nRow. + */ + nRow = p.nOp; + int i_pMem; + if ( p.explain == 1 ) + { + /* The first 8 memory cells are used for the result set. So we will + ** commandeer the 9th cell to use as storage for an array of pointers + ** to trigger subprograms. The VDBE is guaranteed to have at least 9 + ** cells. */ + Debug.Assert( p.nMem > 9 ); + pSub = p.aMem[9]; + if ( ( pSub.flags & MEM_Blob ) != 0 ) + { + /* On the first call to sqlite3_step(), pSub will hold a NULL. It is + ** initialized to a BLOB by the P4_SUBPROGRAM processing logic below */ + apSub = p.aMem[9]._SubProgram; // apSub = (SubProgram*)pSub->z; + nSub = apSub.Length;// pSub->n / sizeof( Vdbe* ); + } + for ( i = 0; i < nSub; i++ ) + { + nRow += apSub[i].nOp; + } + } - i_pMem = 0; - if (i_pMem >= p.pResultSet.Length) - Array.Resize(ref p.pResultSet, 8 + p.pResultSet.Length); + i_pMem = 0; + if ( i_pMem >= p.pResultSet.Length ) + Array.Resize( ref p.pResultSet, 8 + p.pResultSet.Length ); + { + p.pResultSet[i_pMem] = sqlite3Malloc( p.pResultSet[i_pMem] ); + } + pMem = p.pResultSet[i_pMem++]; + do + { + i = p.pc++; + } while ( i < nRow && p.explain == 2 && p.aOp[i].opcode != OP_Explain ); + if ( i >= nRow ) + { + p.rc = SQLITE_OK; + rc = SQLITE_DONE; + } + else if ( db.u1.isInterrupted ) + { + p.rc = SQLITE_INTERRUPT; + rc = SQLITE_ERROR; + sqlite3SetString( ref p.zErrMsg, db, sqlite3ErrStr( p.rc ) ); + } + else + { + string z; + Op pOp; + if ( i < p.nOp ) + { + /* The output line number is small enough that we are still in the + ** main program. */ + pOp = p.aOp[i]; + } + else + { + /* We are currently listing subprograms. Figure out which one and + ** pick up the appropriate opcode. */ + int j; + i -= p.nOp; + for ( j = 0; i >= apSub[j].nOp; j++ ) + { + i -= apSub[j].nOp; + } + pOp = apSub[j].aOp[i]; + } + if ( p.explain == 1 ) + { + pMem.flags = MEM_Int; + pMem.type = SQLITE_INTEGER; + pMem.u.i = i; /* Program counter */ + if ( p.pResultSet[i_pMem] == null ) + { + p.pResultSet[i_pMem] = sqlite3Malloc( p.pResultSet[i_pMem] ); + } + pMem = p.pResultSet[i_pMem++]; //pMem++; + + /* When an OP_Program opcode is encounter (the only opcode that has + ** a P4_SUBPROGRAM argument), expand the size of the array of subprograms + ** kept in p->aMem[9].z to hold the new program - assuming this subprogram + ** has not already been seen. + */ + pMem.flags = MEM_Static | MEM_Str | MEM_Term; + pMem.z = sqlite3OpcodeName( pOp.opcode ); /* Opcode */ + Debug.Assert( pMem.z != null ); + pMem.n = sqlite3Strlen30( pMem.z ); + pMem.type = SQLITE_TEXT; + pMem.enc = SQLITE_UTF8; + if ( p.pResultSet[i_pMem] == null ) + { + p.pResultSet[i_pMem] = sqlite3Malloc( p.pResultSet[i_pMem] ); + } + pMem = p.pResultSet[i_pMem++]; //pMem++; + if ( pOp.p4type == P4_SUBPROGRAM ) + { + //Debugger.Break(); // TODO + //int nByte = 0;//(nSub+1)*sizeof(SubProgram); + int j; + for ( j = 0; j < nSub; j++ ) { - p.pResultSet[i_pMem] = sqlite3Malloc(p.pResultSet[i_pMem]); + if ( apSub[j] == pOp.p4.pProgram ) + break; } - pMem = p.pResultSet[i_pMem++]; - do { - i = p.pc++; - } while (i < nRow && p.explain == 2 && p.aOp[i].opcode != OP_Explain); - if (i >= nRow) { - p.rc = SQLITE_OK; - rc = SQLITE_DONE; - } else if (db.u1.isInterrupted) { - p.rc = SQLITE_INTERRUPT; - rc = SQLITE_ERROR; - sqlite3SetString(ref p.zErrMsg, db, sqlite3ErrStr(p.rc)); - } else { - string z; - Op pOp; - if (i < p.nOp) { - /* The output line number is small enough that we are still in the - ** main program. */ - pOp = p.aOp[i]; - } else { - /* We are currently listing subprograms. Figure out which one and - ** pick up the appropriate opcode. */ - int j; - i -= p.nOp; - for (j = 0; i >= apSub[j].nOp; j++) { - i -= apSub[j].nOp; - } - pOp = apSub[j].aOp[i]; - } - if (p.explain == 1) { - pMem.flags = MEM_Int; - pMem.type = SQLITE_INTEGER; - pMem.u.i = i; /* Program counter */ - if (p.pResultSet[i_pMem] == null) { - p.pResultSet[i_pMem] = sqlite3Malloc(p.pResultSet[i_pMem]); - } - pMem = p.pResultSet[i_pMem++]; //pMem++; - - /* When an OP_Program opcode is encounter (the only opcode that has - ** a P4_SUBPROGRAM argument), expand the size of the array of subprograms - ** kept in p->aMem[9].z to hold the new program - assuming this subprogram - ** has not already been seen. - */ - pMem.flags = MEM_Static | MEM_Str | MEM_Term; - pMem.z = sqlite3OpcodeName(pOp.opcode); /* Opcode */ - Debug.Assert(pMem.z != null); - pMem.n = sqlite3Strlen30(pMem.z); - pMem.type = SQLITE_TEXT; - pMem.enc = SQLITE_UTF8; - if (p.pResultSet[i_pMem] == null) { - p.pResultSet[i_pMem] = sqlite3Malloc(p.pResultSet[i_pMem]); - } - pMem = p.pResultSet[i_pMem++]; //pMem++; - if (pOp.p4type == P4_SUBPROGRAM) { - //Debugger.Break(); // TODO - //int nByte = 0;//(nSub+1)*sizeof(SubProgram); - int j; - for (j = 0; j < nSub; j++) { - if (apSub[j] == pOp.p4.pProgram) - break; - } - if (j == nSub) {// && SQLITE_OK==sqlite3VdbeMemGrow(pSub, nByte, 1) ){ - Array.Resize(ref apSub, nSub + 1); - pSub._SubProgram = apSub;// (SubProgram)pSub.z; - apSub[nSub++] = pOp.p4.pProgram; - pSub.flags |= MEM_Blob; - pSub.n = 0;//nSub*sizeof(SubProgram); - } - } - } - - pMem.flags = MEM_Int; - pMem.u.i = pOp.p1; /* P1 */ - pMem.type = SQLITE_INTEGER; - if (p.pResultSet[i_pMem] == null) { - p.pResultSet[i_pMem] = sqlite3Malloc(p.pResultSet[i_pMem]); - } - pMem = p.pResultSet[i_pMem++]; //pMem++; + if ( j == nSub ) + {// && SQLITE_OK==sqlite3VdbeMemGrow(pSub, nByte, 1) ){ + Array.Resize( ref apSub, nSub + 1 ); + pSub._SubProgram = apSub;// (SubProgram)pSub.z; + apSub[nSub++] = pOp.p4.pProgram; + pSub.flags |= MEM_Blob; + pSub.n = 0;//nSub*sizeof(SubProgram); + } + } + } - pMem.flags = MEM_Int; - pMem.u.i = pOp.p2; /* P2 */ - pMem.type = SQLITE_INTEGER; - if (p.pResultSet[i_pMem] == null) { - p.pResultSet[i_pMem] = sqlite3Malloc(p.pResultSet[i_pMem]); - } - pMem = p.pResultSet[i_pMem++]; //pMem++; + pMem.flags = MEM_Int; + pMem.u.i = pOp.p1; /* P1 */ + pMem.type = SQLITE_INTEGER; + if ( p.pResultSet[i_pMem] == null ) + { + p.pResultSet[i_pMem] = sqlite3Malloc( p.pResultSet[i_pMem] ); + } + pMem = p.pResultSet[i_pMem++]; //pMem++; + + pMem.flags = MEM_Int; + pMem.u.i = pOp.p2; /* P2 */ + pMem.type = SQLITE_INTEGER; + if ( p.pResultSet[i_pMem] == null ) + { + p.pResultSet[i_pMem] = sqlite3Malloc( p.pResultSet[i_pMem] ); + } + pMem = p.pResultSet[i_pMem++]; //pMem++; + + pMem.flags = MEM_Int; + pMem.u.i = pOp.p3; /* P3 */ + pMem.type = SQLITE_INTEGER; + if ( p.pResultSet[i_pMem] == null ) + { + p.pResultSet[i_pMem] = sqlite3Malloc( p.pResultSet[i_pMem] ); + } + pMem = p.pResultSet[i_pMem++]; //pMem++; - pMem.flags = MEM_Int; - pMem.u.i = pOp.p3; /* P3 */ - pMem.type = SQLITE_INTEGER; - if (p.pResultSet[i_pMem] == null) { - p.pResultSet[i_pMem] = sqlite3Malloc(p.pResultSet[i_pMem]); - } - pMem = p.pResultSet[i_pMem++]; //pMem++; - - //if ( sqlite3VdbeMemGrow( pMem, 32, 0 ) != 0 ) - //{ /* P4 */ - // Debug.Assert( p.db.mallocFailed != 0 ); - // return SQLITE_ERROR; - //} - pMem.flags = MEM_Dyn | MEM_Str | MEM_Term; - z = displayP4(pOp, pMem.z, 32); - if (z != pMem.z) { - sqlite3VdbeMemSetStr(pMem, z, -1, SQLITE_UTF8, null); - } else { - Debug.Assert(pMem.z != null); - pMem.n = sqlite3Strlen30(pMem.z); - pMem.enc = SQLITE_UTF8; - } - pMem.type = SQLITE_TEXT; - if (p.pResultSet[i_pMem] == null) { - p.pResultSet[i_pMem] = sqlite3Malloc(p.pResultSet[i_pMem]); - } - pMem = p.pResultSet[i_pMem++]; //pMem++; - - if (p.explain == 1) { - //if ( sqlite3VdbeMemGrow( pMem, 4, 0 ) != 0 ) - //{ - // Debug.Assert( p.db.mallocFailed != 0 ); - // return SQLITE_ERROR; - //} - pMem.flags = MEM_Dyn | MEM_Str | MEM_Term; - pMem.n = 2; - pMem.z = pOp.p5.ToString("x2"); //sqlite3_snprintf( 3, pMem.z, "%.2x", pOp.p5 ); /* P5 */ - pMem.type = SQLITE_TEXT; - pMem.enc = SQLITE_UTF8; - if (p.pResultSet[i_pMem] == null) { - p.pResultSet[i_pMem] = sqlite3Malloc(p.pResultSet[i_pMem]); - } - pMem = p.pResultSet[i_pMem++]; // pMem++; + //if ( sqlite3VdbeMemGrow( pMem, 32, 0 ) != 0 ) + //{ /* P4 */ + // Debug.Assert( p.db.mallocFailed != 0 ); + // return SQLITE_ERROR; + //} + pMem.flags = MEM_Dyn | MEM_Str | MEM_Term; + z = displayP4( pOp, pMem.z, 32 ); + if ( z != pMem.z ) + { + sqlite3VdbeMemSetStr( pMem, z, -1, SQLITE_UTF8, null ); + } + else + { + Debug.Assert( pMem.z != null ); + pMem.n = sqlite3Strlen30( pMem.z ); + pMem.enc = SQLITE_UTF8; + } + pMem.type = SQLITE_TEXT; + if ( p.pResultSet[i_pMem] == null ) + { + p.pResultSet[i_pMem] = sqlite3Malloc( p.pResultSet[i_pMem] ); + } + pMem = p.pResultSet[i_pMem++]; //pMem++; + + if ( p.explain == 1 ) + { + //if ( sqlite3VdbeMemGrow( pMem, 4, 0 ) != 0 ) + //{ + // Debug.Assert( p.db.mallocFailed != 0 ); + // return SQLITE_ERROR; + //} + pMem.flags = MEM_Dyn | MEM_Str | MEM_Term; + pMem.n = 2; + pMem.z = pOp.p5.ToString( "x2" ); //sqlite3_snprintf( 3, pMem.z, "%.2x", pOp.p5 ); /* P5 */ + pMem.type = SQLITE_TEXT; + pMem.enc = SQLITE_UTF8; + if ( p.pResultSet[i_pMem] == null ) + { + p.pResultSet[i_pMem] = sqlite3Malloc( p.pResultSet[i_pMem] ); + } + pMem = p.pResultSet[i_pMem++]; // pMem++; #if SQLITE_DEBUG - if (pOp.zComment != null) { - pMem.flags = MEM_Str | MEM_Term; - pMem.z = pOp.zComment; - pMem.n = pMem.z == null ? 0 : sqlite3Strlen30(pMem.z); - pMem.enc = SQLITE_UTF8; - pMem.type = SQLITE_TEXT; - } else + if ( pOp.zComment != null ) + { + pMem.flags = MEM_Str | MEM_Term; + pMem.z = pOp.zComment; + pMem.n = pMem.z == null ? 0 : sqlite3Strlen30( pMem.z ); + pMem.enc = SQLITE_UTF8; + pMem.type = SQLITE_TEXT; + } + else #endif - { - pMem.flags = MEM_Null; /* Comment */ - pMem.type = SQLITE_NULL; - } - } - - p.nResColumn = (u16)(8 - 4 * (p.explain - 1)); - p.rc = SQLITE_OK; - rc = SQLITE_ROW; - } - return rc; + { + pMem.flags = MEM_Null; /* Comment */ + pMem.type = SQLITE_NULL; + } } + + p.nResColumn = (u16)( 8 - 4 * ( p.explain - 1 ) ); + p.rc = SQLITE_OK; + rc = SQLITE_ROW; + } + return rc; + } #endif // * SQLITE_OMIT_EXPLAIN */ -#if SQLITE_DEBUG - /* - ** Print the SQL that was used to generate a VDBE program. - */ - static void sqlite3VdbePrintSql(Vdbe p) { - int nOp = p.nOp; - VdbeOp pOp; - if (nOp < 1) - return; - pOp = p.aOp[0]; - if (pOp.opcode == OP_Trace && pOp.p4.z != null) { - string z = pOp.p4.z; - z = z.Trim();// while ( sqlite3Isspace( *(u8)z ) ) z++; - Console.Write("SQL: [{0}]\n", z); - } - } +#if SQLITE_DEBUG + /* +** Print the SQL that was used to generate a VDBE program. +*/ + static void sqlite3VdbePrintSql( Vdbe p ) + { + int nOp = p.nOp; + VdbeOp pOp; + if ( nOp < 1 ) + return; + pOp = p.aOp[0]; + if ( pOp.opcode == OP_Trace && pOp.p4.z != null ) + { + string z = pOp.p4.z; + z = z.Trim();// while ( sqlite3Isspace( *(u8)z ) ) z++; + Console.Write( "SQL: [{0}]\n", z ); + } + } #endif #if !SQLITE_OMIT_TRACE && SQLITE_ENABLE_IOTRACE @@ -1713,429 +1934,456 @@ static void sqlite3VdbeIOTraceSql( Vdbe p ) } #endif // * !SQLITE_OMIT_TRACE && SQLITE_ENABLE_IOTRACE */ - /* - ** Allocate space from a fixed size buffer and return a pointer to - ** that space. If insufficient space is available, return NULL. - ** - ** The pBuf parameter is the initial value of a pointer which will - ** receive the new memory. pBuf is normally NULL. If pBuf is not - ** NULL, it means that memory space has already been allocated and that - ** this routine should not allocate any new memory. When pBuf is not - ** NULL simply return pBuf. Only allocate new memory space when pBuf - ** is NULL. - ** - ** nByte is the number of bytes of space needed. - ** - ** *ppFrom points to available space and pEnd points to the end of the - ** available space. When space is allocated, *ppFrom is advanced past - ** the end of the allocated space. - ** - ** *pnByte is a counter of the number of bytes of space that have failed - ** to allocate. If there is insufficient space in *ppFrom to satisfy the - ** request, then increment *pnByte by the amount of the request. - */ - //static void* allocSpace( - // void* pBuf, /* Where return pointer will be stored */ - // int nByte, /* Number of bytes to allocate */ - // u8** ppFrom, /* IN/OUT: Allocate from *ppFrom */ - // u8* pEnd, /* Pointer to 1 byte past the end of *ppFrom buffer */ - // int* pnByte /* If allocation cannot be made, increment *pnByte */ - //) - //{ - // Debug.Assert(EIGHT_BYTE_ALIGNMENT(*ppFrom)); - // if (pBuf) return pBuf; - // nByte = ROUND8(nByte); - // if (&(*ppFrom)[nByte] <= pEnd) - // { - // pBuf = (void)*ppFrom; - // *ppFrom += nByte; - // } - // else - // { - // *pnByte += nByte; - // } - // return pBuf; - //} - - /* - ** Rewind the VDBE back to the beginning in preparation for - ** running it. - */ - static void sqlite3VdbeRewind(Vdbe p) { -#if (SQLITE_DEBUG) || (VDBE_PROFILE) - int i; -#endif - Debug.Assert(p != null); - Debug.Assert(p.magic == VDBE_MAGIC_INIT); - - /* There should be at least one opcode. - */ - Debug.Assert(p.nOp > 0); + /* +** Allocate space from a fixed size buffer and return a pointer to +** that space. If insufficient space is available, return NULL. +** +** The pBuf parameter is the initial value of a pointer which will +** receive the new memory. pBuf is normally NULL. If pBuf is not +** NULL, it means that memory space has already been allocated and that +** this routine should not allocate any new memory. When pBuf is not +** NULL simply return pBuf. Only allocate new memory space when pBuf +** is NULL. +** +** nByte is the number of bytes of space needed. +** +** *ppFrom points to available space and pEnd points to the end of the +** available space. When space is allocated, *ppFrom is advanced past +** the end of the allocated space. +** +** *pnByte is a counter of the number of bytes of space that have failed +** to allocate. If there is insufficient space in *ppFrom to satisfy the +** request, then increment *pnByte by the amount of the request. +*/ + //static void* allocSpace( + // void* pBuf, /* Where return pointer will be stored */ + // int nByte, /* Number of bytes to allocate */ + // u8** ppFrom, /* IN/OUT: Allocate from *ppFrom */ + // u8* pEnd, /* Pointer to 1 byte past the end of *ppFrom buffer */ + // int* pnByte /* If allocation cannot be made, increment *pnByte */ + //) + //{ + // Debug.Assert(EIGHT_BYTE_ALIGNMENT(*ppFrom)); + // if (pBuf) return pBuf; + // nByte = ROUND8(nByte); + // if (&(*ppFrom)[nByte] <= pEnd) + // { + // pBuf = (void)*ppFrom; + // *ppFrom += nByte; + // } + // else + // { + // *pnByte += nByte; + // } + // return pBuf; + //} + + /* + ** Rewind the VDBE back to the beginning in preparation for + ** running it. + */ + static void sqlite3VdbeRewind(Vdbe p){ + #if (SQLITE_DEBUG) || (VDBE_PROFILE) + int i; + #endif + Debug.Assert( p!=null ); + Debug.Assert( p.magic==VDBE_MAGIC_INIT ); + + /* There should be at least one opcode. + */ + Debug.Assert( p.nOp>0 ); - /* Set the magic to VDBE_MAGIC_RUN sooner rather than later. */ - p.magic = VDBE_MAGIC_RUN; + /* Set the magic to VDBE_MAGIC_RUN sooner rather than later. */ + p.magic = VDBE_MAGIC_RUN; -#if SQLITE_DEBUG - for (i = 1; i < p.nMem; i++) { - Debug.Assert(p.aMem[i].db == p.db); - } -#endif - p.pc = -1; - p.rc = SQLITE_OK; - p.errorAction = OE_Abort; - p.magic = VDBE_MAGIC_RUN; - p.nChange = 0; - p.cacheCtr = 1; - p.minWriteFileFormat = 255; - p.iStatement = 0; - p.nFkConstraint = 0; -#if VDBE_PROFILE + #if SQLITE_DEBUG + for(i=1; iaOp[p->nOp]; /* Memory avaliable for allocation */ + //zEnd = (u8)&p->aOp[p->nOpAlloc]; /* First byte past end of zCsr[] */ + resolveP2Values( p, ref nArg ); + p.usesStmtJournal = (pParse.isMultiWrite !=0 && pParse.mayAbort !=0 ); + if( pParse.explain !=0 && nMem<10 ){ + nMem = 10; } - /* - ** Prepare a virtual machine for execution for the first time after - ** creating the virtual machine. This involves things such - ** as allocating stack space and initializing the program counter. - ** After the VDBE has be prepped, it can be executed by one or more - ** calls to sqlite3VdbeExec(). + //memset(zCsr, 0, zEnd-zCsr); + //zCsr += ( zCsr - (u8)0 ) & 7; + //Debug.Assert( EIGHT_BYTE_ALIGNMENT( zCsr ) ); + p.expired = false; + + // + // C# -- Replace allocation with individual Dims + // + /* Memory for registers, parameters, cursor, etc, is allocated in two + ** passes. On the first pass, we try to reuse unused space at the + ** end of the opcode array. If we are unable to satisfy all memory + ** requirements by reusing the opcode array tail, then the second + ** pass will fill in the rest using a fresh allocation. ** - ** This function may be called exact once on a each virtual machine. - ** After this routine is called the VM has been "packaged" and is ready - ** to run. After this routine is called, futher calls to - ** sqlite3VdbeAddOp() functions are prohibited. This routine disconnects - ** the Vdbe from the Parse object that helped generate it so that the - ** the Vdbe becomes an independent entity and the Parse object can be - ** destroyed. - ** - ** Use the sqlite3VdbeRewind() procedure to restore a virtual machine back - ** to its initial state after it has been run. + ** This two-pass approach that reuses as much memory as possible from + ** the leftover space at the end of the opcode array can significantly + ** reduce the amount of memory held by a prepared statement. */ - static void sqlite3VdbeMakeReady( - Vdbe p, /* The VDBE */ - Parse pParse /* Parsing context */ - ) { - sqlite3 db; /* The database connection */ - int nVar; /* Number of parameters */ - int nMem; /* Number of VM memory registers */ - int nCursor; /* Number of cursors required */ - int nArg; /* Number of arguments in subprograms */ - int n; /* Loop counter */ - //u8 zCsr; /* Memory available for allocation */ - //u8 zEnd; /* First byte past allocated memory */ - int nByte; /* How much extra memory is needed */ - - Debug.Assert(p != null); - Debug.Assert(pParse != null); - Debug.Assert(p.magic == VDBE_MAGIC_INIT); - db = p.db; - //Debug.Assert( db.mallocFailed == 0 ); - nVar = pParse.nVar; - nMem = pParse.nMem; - nCursor = pParse.nTab; - nArg = pParse.nMaxArg; - - /* For each cursor required, also allocate a memory cell. Memory - ** cells (nMem+1-nCursor)..nMem, inclusive, will never be used by - ** the vdbe program. Instead they are used to allocate space for - ** VdbeCursor/BtCursor structures. The blob of memory associated with - ** cursor 0 is stored in memory cell nMem. Memory cell (nMem-1) - ** stores the blob of memory associated with cursor 1, etc. - ** - ** See also: allocateCursor(). - */ - nMem += nCursor; - - /* Allocate space for memory registers, SQL variables, VDBE cursors and - ** an array to marshal SQL function arguments in. - */ - //zCsr = (u8)&p->aOp[p->nOp]; /* Memory avaliable for allocation */ - //zEnd = (u8)&p->aOp[p->nOpAlloc]; /* First byte past end of zCsr[] */ - resolveP2Values(p, ref nArg); - p.usesStmtJournal = (pParse.isMultiWrite != 0 && pParse.mayAbort != 0); - if (pParse.explain != 0 && nMem < 10) { - nMem = 10; - } - - //memset(zCsr, 0, zEnd-zCsr); - //zCsr += ( zCsr - (u8)0 ) & 7; - //Debug.Assert( EIGHT_BYTE_ALIGNMENT( zCsr ) ); - p.expired = false; - - // - // C# -- Replace allocation with individual Dims - // - /* Memory for registers, parameters, cursor, etc, is allocated in two - ** passes. On the first pass, we try to reuse unused space at the - ** end of the opcode array. If we are unable to satisfy all memory - ** requirements by reusing the opcode array tail, then the second - ** pass will fill in the rest using a fresh allocation. - ** - ** This two-pass approach that reuses as much memory as possible from - ** the leftover space at the end of the opcode array can significantly - ** reduce the amount of memory held by a prepared statement. - */ - //do - //{ - // nByte = 0; - // p->aMem = allocSpace( p->aMem, nMem * sizeof( Mem ), &zCsr, zEnd, &nByte ); - // p->aVar = allocSpace( p->aVar, nVar * sizeof( Mem ), &zCsr, zEnd, &nByte ); - // p->apArg = allocSpace( p->apArg, nArg * sizeof( Mem* ), &zCsr, zEnd, &nByte ); - // p->azVar = allocSpace( p->azVar, nVar * sizeof( char* ), &zCsr, zEnd, &nByte ); - // p->apCsr = allocSpace( p->apCsr, nCursor * sizeof( VdbeCursor* ), - // &zCsr, zEnd, &nByte ); - // if ( nByte ) - // { - // p->pFree = sqlite3DbMallocZero( db, nByte ); - // } - // zCsr = p->pFree; - // zEnd = zCsr[nByte]; - //} while ( nByte && !db->mallocFailed ); - - //p->nCursor = (u16)nCursor; - //if( p->aVar ){ - // p->nVar = (ynVar)nVar; - // for(n=0; naVar[n].flags = MEM_Null; - // p->aVar[n].db = db; - // } - //} - //if( p->azVar ){ - // p->nzVar = pParse->nzVar; - // memcpy(p->azVar, pParse->azVar, p->nzVar*sizeof(p->azVar[0])); - // memset(pParse->azVar, 0, pParse->nzVar*sizeof(pParse->azVar[0])); - //} - p.nzVar = (i16)pParse.nzVar; - p.azVar = new string[(int)p.nzVar == 0 ? 1 : (int)p.nzVar]; //p.azVar = (char*)p.apArg[nArg]; - for (n = 0; n < p.nzVar; n++) { - p.azVar[n] = pParse.azVar[n]; - } - // - - // C# -- Replace allocation with individual Dims - // aMem is 1 based, so allocate 1 extra cell under C# - p.aMem = new Mem[nMem + 1]; - for (n = 0; n <= nMem; n++) { - p.aMem[n] = sqlite3Malloc(p.aMem[n]); - p.aMem[n].db = db; - } - //p.aMem--; /* aMem[] goes from 1..nMem */ - p.nMem = nMem; /* not from 0..nMem-1 */ - // - p.aVar = new Mem[nVar == 0 ? 1 : nVar]; - for (n = 0; n < nVar; n++) { - p.aVar[n] = sqlite3Malloc(p.aVar[n]); - } - p.nVar = (ynVar)nVar; - // - p.apArg = new Mem[nArg == 0 ? 1 : nArg];//p.apArg = (Mem*)p.aVar[nVar]; - // - - p.apCsr = new VdbeCursor[nCursor == 0 ? 1 : nCursor];//p.apCsr = (VdbeCursor*)p.azVar[nVar]; - p.apCsr[0] = new VdbeCursor(); - p.nCursor = (u16)nCursor; - if (p.aVar != null) { - p.nVar = (ynVar)nVar; - // - for (n = 0; n < nVar; n++) { - p.aVar[n].flags = MEM_Null; - p.aVar[n].db = db; - } - } - if (p.aMem != null) { - //p.aMem--; /* aMem[] goes from 1..nMem */ - p.nMem = nMem; /* not from 0..nMem-1 */ - for (n = 0; n <= nMem; n++) { - p.aMem[n].flags = MEM_Null; - p.aMem[n].n = 0; - p.aMem[n].z = null; - p.aMem[n].zBLOB = null; - p.aMem[n].db = db; - } - } - p.explain = pParse.explain; - sqlite3VdbeRewind(p); + //do + //{ + // nByte = 0; + // p->aMem = allocSpace( p->aMem, nMem * sizeof( Mem ), &zCsr, zEnd, &nByte ); + // p->aVar = allocSpace( p->aVar, nVar * sizeof( Mem ), &zCsr, zEnd, &nByte ); + // p->apArg = allocSpace( p->apArg, nArg * sizeof( Mem* ), &zCsr, zEnd, &nByte ); + // p->azVar = allocSpace( p->azVar, nVar * sizeof( char* ), &zCsr, zEnd, &nByte ); + // p->apCsr = allocSpace( p->apCsr, nCursor * sizeof( VdbeCursor* ), + // &zCsr, zEnd, &nByte ); + // if ( nByte ) + // { + // p->pFree = sqlite3DbMallocZero( db, nByte ); + // } + // zCsr = p->pFree; + // zEnd = zCsr[nByte]; + //} while ( nByte && !db->mallocFailed ); + + //p->nCursor = (u16)nCursor; + //if( p->aVar ){ + // p->nVar = (ynVar)nVar; + // for(n=0; naVar[n].flags = MEM_Null; + // p->aVar[n].db = db; + // } + //} + //if( p->azVar ){ + // p->nzVar = pParse->nzVar; + // memcpy(p->azVar, pParse->azVar, p->nzVar*sizeof(p->azVar[0])); + // memset(pParse->azVar, 0, pParse->nzVar*sizeof(pParse->azVar[0])); + //} + p.nzVar = (i16)pParse.nzVar; + p.azVar = new string[(int)p.nzVar == 0 ? 1 : (int)p.nzVar]; //p.azVar = (char*)p.apArg[nArg]; + for ( n = 0; n < p.nzVar; n++ ) + { + p.azVar[n] = pParse.azVar[n]; + } + // + + // C# -- Replace allocation with individual Dims + // aMem is 1 based, so allocate 1 extra cell under C# + p.aMem = new Mem[nMem + 1]; + for ( n = 0; n <= nMem; n++ ) + { + p.aMem[n] = sqlite3Malloc( p.aMem[n] ); + p.aMem[n].db = db; + } + //p.aMem--; /* aMem[] goes from 1..nMem */ + p.nMem = nMem; /* not from 0..nMem-1 */ + // + p.aVar = new Mem[nVar == 0 ? 1 : nVar]; + for ( n = 0; n < nVar; n++ ) + { + p.aVar[n] = sqlite3Malloc( p.aVar[n] ); + } + p.nVar = (ynVar)nVar; + // + p.apArg = new Mem[nArg == 0 ? 1 : nArg];//p.apArg = (Mem*)p.aVar[nVar]; + // + + p.apCsr = new VdbeCursor[nCursor == 0 ? 1 : nCursor];//p.apCsr = (VdbeCursor*)p.azVar[nVar]; + p.apCsr[0] = new VdbeCursor(); + p.nCursor = (u16)nCursor; + if ( p.aVar != null ) + { + p.nVar = (ynVar)nVar; + // + for ( n = 0; n < nVar; n++ ) + { + p.aVar[n].flags = MEM_Null; + p.aVar[n].db = db; + } } + if ( p.aMem != null ) + { + //p.aMem--; /* aMem[] goes from 1..nMem */ + p.nMem = nMem; /* not from 0..nMem-1 */ + for ( n = 0; n <= nMem; n++ ) + { + p.aMem[n].flags = MEM_Null; + p.aMem[n].n = 0; + p.aMem[n].z = null; + p.aMem[n].zBLOB = null; + p.aMem[n].db = db; + } + } + p.explain = pParse.explain; + sqlite3VdbeRewind( p ); + } - /* - ** Close a VDBE cursor and release all the resources that cursor - ** happens to hold. - */ - static void sqlite3VdbeFreeCursor(Vdbe p, VdbeCursor pCx) { - if (pCx == null) { - return; - } + /* + ** Close a VDBE cursor and release all the resources that cursor + ** happens to hold. + */ + static void sqlite3VdbeFreeCursor( Vdbe p, VdbeCursor pCx ) + { + if ( pCx == null ) + { + return; + } - if (pCx.pBt != null) { - sqlite3BtreeClose(ref pCx.pBt); - /* The pCx.pCursor will be close automatically, if it exists, by - ** the call above. */ - } else if (pCx.pCursor != null) { - sqlite3BtreeCloseCursor(pCx.pCursor); - } + if ( pCx.pBt != null ) + { + sqlite3BtreeClose( ref pCx.pBt ); + /* The pCx.pCursor will be close automatically, if it exists, by + ** the call above. */ + } + else if ( pCx.pCursor != null ) + { + sqlite3BtreeCloseCursor( pCx.pCursor ); + } #if !SQLITE_OMIT_VIRTUALTABLE - if (pCx.pVtabCursor != null) { - sqlite3_vtab_cursor pVtabCursor = pCx.pVtabCursor; - sqlite3_module pModule = pCx.pModule; - p.inVtabMethod = 1; - pModule.xClose(ref pVtabCursor); - p.inVtabMethod = 0; - } + if ( pCx.pVtabCursor != null ) + { + sqlite3_vtab_cursor pVtabCursor = pCx.pVtabCursor; + sqlite3_module pModule = pCx.pModule; + p.inVtabMethod = 1; + pModule.xClose( ref pVtabCursor ); + p.inVtabMethod = 0; + } #endif - } - /* - ** Copy the values stored in the VdbeFrame structure to its Vdbe. This - ** is used, for example, when a trigger sub-program is halted to restore - ** control to the main program. - */ - static int sqlite3VdbeFrameRestore(VdbeFrame pFrame) { - Vdbe v = pFrame.v; - v.aOp = pFrame.aOp; - v.nOp = pFrame.nOp; - v.aMem = pFrame.aMem; - v.nMem = pFrame.nMem; - v.apCsr = pFrame.apCsr; - v.nCursor = pFrame.nCursor; - v.db.lastRowid = pFrame.lastRowid; - v.nChange = pFrame.nChange; - return pFrame.pc; - } - - /* - ** Close all cursors. - ** - ** Also release any dynamic memory held by the VM in the Vdbe.aMem memory - ** cell array. This is necessary as the memory cell array may contain - ** pointers to VdbeFrame objects, which may in turn contain pointers to - ** open cursors. - */ - static void closeAllCursors(Vdbe p) { - if (p.pFrame != null) { - VdbeFrame pFrame; - for (pFrame = p.pFrame; pFrame.pParent != null; pFrame = pFrame.pParent) - ; - sqlite3VdbeFrameRestore(pFrame); - } - p.pFrame = null; - p.nFrame = 0; - - if (p.apCsr != null) { - int i; - for (i = 0; i < p.nCursor; i++) { - VdbeCursor pC = p.apCsr[i]; - if (pC != null) { - sqlite3VdbeFreeCursor(p, pC); - p.apCsr[i] = null; - } - } - } - if (p.aMem != null) { - releaseMemArray(p.aMem, 1, p.nMem); - } - while (p.pDelFrame != null) { - VdbeFrame pDel = p.pDelFrame; - p.pDelFrame = pDel.pParent; - sqlite3VdbeFrameDelete(pDel); - } + } + /* + ** Copy the values stored in the VdbeFrame structure to its Vdbe. This + ** is used, for example, when a trigger sub-program is halted to restore + ** control to the main program. + */ + static int sqlite3VdbeFrameRestore( VdbeFrame pFrame ) + { + Vdbe v = pFrame.v; + v.aOp = pFrame.aOp; + v.nOp = pFrame.nOp; + v.aMem = pFrame.aMem; + v.nMem = pFrame.nMem; + v.apCsr = pFrame.apCsr; + v.nCursor = pFrame.nCursor; + v.db.lastRowid = pFrame.lastRowid; + v.nChange = pFrame.nChange; + return pFrame.pc; + } + /* + ** Close all cursors. + ** + ** Also release any dynamic memory held by the VM in the Vdbe.aMem memory + ** cell array. This is necessary as the memory cell array may contain + ** pointers to VdbeFrame objects, which may in turn contain pointers to + ** open cursors. + */ + static void closeAllCursors( Vdbe p ) + { + if ( p.pFrame != null ) + { + VdbeFrame pFrame; + for ( pFrame = p.pFrame; pFrame.pParent != null; pFrame = pFrame.pParent ) + ; + sqlite3VdbeFrameRestore( pFrame ); + } + p.pFrame = null; + p.nFrame = 0; + + if ( p.apCsr != null ) + { + int i; + for ( i = 0; i < p.nCursor; i++ ) + { + VdbeCursor pC = p.apCsr[i]; + if ( pC != null ) + { + sqlite3VdbeFreeCursor( p, pC ); + p.apCsr[i] = null; + } } - /* - ** Clean up the VM after execution. - ** - ** This routine will automatically close any cursors, lists, and/or - ** sorters that were left open. It also deletes the values of - ** variables in the aVar[] array. - */ - static void Cleanup(Vdbe p) { - sqlite3 db = p.db; + } + if ( p.aMem != null ) + { + releaseMemArray( p.aMem, 1, p.nMem ); + } + while ( p.pDelFrame != null ) + { + VdbeFrame pDel = p.pDelFrame; + p.pDelFrame = pDel.pParent; + sqlite3VdbeFrameDelete( pDel ); + } + + } + /* + ** Clean up the VM after execution. + ** + ** This routine will automatically close any cursors, lists, and/or + ** sorters that were left open. It also deletes the values of + ** variables in the aVar[] array. + */ + static void Cleanup( Vdbe p ) + { + sqlite3 db = p.db; #if SQLITE_DEBUG - /* Execute Debug.Assert() statements to ensure that the Vdbe.apCsr[] and - ** Vdbe.aMem[] arrays have already been cleaned up. */ - int i; - //TODO for(i=0; i 0) { - p.aColName[n] = sqlite3Malloc(p.aColName[n]); - pColName = p.aColName[n]; - pColName.flags = MEM_Null; - pColName.db = p.db; - } - } + /* + ** Set the number of result columns that will be returned by this SQL + ** statement. This is now set at compile time, rather than during + ** execution of the vdbe program so that sqlite3_column_count() can + ** be called on an SQL statement before sqlite3_step(). + */ + static void sqlite3VdbeSetNumCols( Vdbe p, int nResColumn ) + { + Mem pColName; + int n; + sqlite3 db = p.db; + + releaseMemArray( p.aColName, p.nResColumn * COLNAME_N ); + sqlite3DbFree( db, ref p.aColName ); + n = nResColumn * COLNAME_N; + p.nResColumn = (u16)nResColumn; + p.aColName = new Mem[n];// (Mem)sqlite3DbMallocZero(db, Mem.Length * n); + //if (p.aColName == 0) return; + while ( n-- > 0 ) + { + p.aColName[n] = sqlite3Malloc( p.aColName[n] ); + pColName = p.aColName[n]; + pColName.flags = MEM_Null; + pColName.db = p.db; + } + } - /* - ** Set the name of the idx'th column to be returned by the SQL statement. - ** zName must be a pointer to a nul terminated string. - ** - ** This call must be made after a call to sqlite3VdbeSetNumCols(). - ** - ** The final parameter, xDel, must be one of SQLITE_DYNAMIC, SQLITE_STATIC - ** or SQLITE_TRANSIENT. If it is SQLITE_DYNAMIC, then the buffer pointed - ** to by zName will be freed by sqlite3DbFree() when the vdbe is destroyed. - */ + /* + ** Set the name of the idx'th column to be returned by the SQL statement. + ** zName must be a pointer to a nul terminated string. + ** + ** This call must be made after a call to sqlite3VdbeSetNumCols(). + ** + ** The final parameter, xDel, must be one of SQLITE_DYNAMIC, SQLITE_STATIC + ** or SQLITE_TRANSIENT. If it is SQLITE_DYNAMIC, then the buffer pointed + ** to by zName will be freed by sqlite3DbFree() when the vdbe is destroyed. + */ - static int sqlite3VdbeSetColName( - Vdbe p, /* Vdbe being configured */ - int idx, /* Index of column zName applies to */ - int var, /* One of the COLNAME_* constants */ - string zName, /* Pointer to buffer containing name */ - dxDel xDel /* Memory management strategy for zName */ - ) { - int rc; - Mem pColName; - Debug.Assert(idx < p.nResColumn); - Debug.Assert(var < COLNAME_N); - //if ( p.db.mallocFailed != 0 ) - //{ - // Debug.Assert( null == zName || xDel != SQLITE_DYNAMIC ); - // return SQLITE_NOMEM; - //} - Debug.Assert(p.aColName != null); - pColName = p.aColName[idx + var * p.nResColumn]; - rc = sqlite3VdbeMemSetStr(pColName, zName, -1, SQLITE_UTF8, xDel); - Debug.Assert(rc != 0 || null == zName || (pColName.flags & MEM_Term) != 0); - return rc; - } - - /* - ** A read or write transaction may or may not be active on database handle - ** db. If a transaction is active, commit it. If there is a - ** write-transaction spanning more than one database file, this routine - ** takes care of the master journal trickery. - */ - static int vdbeCommit(sqlite3 db, Vdbe p) { - int i; - int nTrans = 0; /* Number of databases with an active write-transaction */ - int rc = SQLITE_OK; - bool needXcommit = false; + static int sqlite3VdbeSetColName( + Vdbe p, /* Vdbe being configured */ + int idx, /* Index of column zName applies to */ + int var, /* One of the COLNAME_* constants */ + string zName, /* Pointer to buffer containing name */ + dxDel xDel /* Memory management strategy for zName */ + ) + { + int rc; + Mem pColName; + Debug.Assert( idx < p.nResColumn ); + Debug.Assert( var < COLNAME_N ); + //if ( p.db.mallocFailed != 0 ) + //{ + // Debug.Assert( null == zName || xDel != SQLITE_DYNAMIC ); + // return SQLITE_NOMEM; + //} + Debug.Assert( p.aColName != null ); + pColName = p.aColName[idx + var * p.nResColumn]; + rc = sqlite3VdbeMemSetStr( pColName, zName, -1, SQLITE_UTF8, xDel ); + Debug.Assert( rc != 0 || null == zName || ( pColName.flags & MEM_Term ) != 0 ); + return rc; + } + + /* + ** A read or write transaction may or may not be active on database handle + ** db. If a transaction is active, commit it. If there is a + ** write-transaction spanning more than one database file, this routine + ** takes care of the master journal trickery. + */ + static int vdbeCommit( sqlite3 db, Vdbe p ) + { + int i; + int nTrans = 0; /* Number of databases with an active write-transaction */ + int rc = SQLITE_OK; + bool needXcommit = false; #if SQLITE_OMIT_VIRTUALTABLE /* With this option, sqlite3VtabSync() is defined to be simply @@ -2143,642 +2391,733 @@ static int vdbeCommit(sqlite3 db, Vdbe p) { */ UNUSED_PARAMETER( p ); #endif - /* Before doing anything else, call the xSync() callback for any - ** virtual module tables written in this transaction. This has to - ** be done before determining whether a master journal file is - ** required, as an xSync() callback may add an attached database - ** to the transaction. + /* Before doing anything else, call the xSync() callback for any +** virtual module tables written in this transaction. This has to +** be done before determining whether a master journal file is +** required, as an xSync() callback may add an attached database +** to the transaction. +*/ + rc = sqlite3VtabSync( db, ref p.zErrMsg ); + + /* This loop determines (a) if the commit hook should be invoked and + ** (b) how many database files have open write transactions, not + ** including the temp database. (b) is important because if more than + ** one database file has an open write transaction, a master journal + ** file is required for an atomic commit. */ - rc = sqlite3VtabSync(db, ref p.zErrMsg); - - /* This loop determines (a) if the commit hook should be invoked and - ** (b) how many database files have open write transactions, not - ** including the temp database. (b) is important because if more than - ** one database file has an open write transaction, a master journal - ** file is required for an atomic commit. - */ - for (i = 0; rc == SQLITE_OK && i < db.nDb; i++) { - Btree pBt = db.aDb[i].pBt; - if (sqlite3BtreeIsInTrans(pBt)) { - needXcommit = true; - if (i != 1) - nTrans++; - rc = sqlite3PagerExclusiveLock(sqlite3BtreePager(pBt)); - } - } - if (rc != SQLITE_OK) { - return rc; - } + for ( i = 0; rc == SQLITE_OK && i < db.nDb; i++ ) + { + Btree pBt = db.aDb[i].pBt; + if ( sqlite3BtreeIsInTrans( pBt ) ) + { + needXcommit = true; + if ( i != 1 ) + nTrans++; + rc = sqlite3PagerExclusiveLock( sqlite3BtreePager( pBt ) ); + } + } + if ( rc != SQLITE_OK ) + { + return rc; + } - /* If there are any write-transactions at all, invoke the commit hook */ - if (needXcommit && db.xCommitCallback != null) { - rc = db.xCommitCallback(db.pCommitArg); - if (rc != 0) { - return SQLITE_CONSTRAINT; - } - } + /* If there are any write-transactions at all, invoke the commit hook */ + if ( needXcommit && db.xCommitCallback != null ) + { + rc = db.xCommitCallback( db.pCommitArg ); + if ( rc != 0 ) + { + return SQLITE_CONSTRAINT; + } + } - /* The simple case - no more than one database file (not counting the - ** TEMP database) has a transaction active. There is no need for the - ** master-journal. - ** - ** If the return value of sqlite3BtreeGetFilename() is a zero length - ** string, it means the main database is :memory: or a temp file. In - ** that case we do not support atomic multi-file commits, so use the - ** simple case then too. - */ - if (0 == sqlite3Strlen30(sqlite3BtreeGetFilename(db.aDb[0].pBt)) - || nTrans <= 1) { - for (i = 0; rc == SQLITE_OK && i < db.nDb; i++) { - Btree pBt = db.aDb[i].pBt; - if (pBt != null) { - rc = sqlite3BtreeCommitPhaseOne(pBt, null); - } - } + /* The simple case - no more than one database file (not counting the + ** TEMP database) has a transaction active. There is no need for the + ** master-journal. + ** + ** If the return value of sqlite3BtreeGetFilename() is a zero length + ** string, it means the main database is :memory: or a temp file. In + ** that case we do not support atomic multi-file commits, so use the + ** simple case then too. + */ + if ( 0 == sqlite3Strlen30( sqlite3BtreeGetFilename( db.aDb[0].pBt ) ) + || nTrans <= 1 ) + { + for ( i = 0; rc == SQLITE_OK && i < db.nDb; i++ ) + { + Btree pBt = db.aDb[i].pBt; + if ( pBt != null ) + { + rc = sqlite3BtreeCommitPhaseOne( pBt, null ); + } + } - /* Do the commit only if all databases successfully complete phase 1. - ** If one of the BtreeCommitPhaseOne() calls fails, this indicates an - ** IO error while deleting or truncating a journal file. It is unlikely, - ** but could happen. In this case abandon processing and return the error. - */ - for (i = 0; rc == SQLITE_OK && i < db.nDb; i++) { - Btree pBt = db.aDb[i].pBt; - if (pBt != null) { - rc = sqlite3BtreeCommitPhaseTwo(pBt, 0); - } - } - if (rc == SQLITE_OK) { - sqlite3VtabCommit(db); - } - } + /* Do the commit only if all databases successfully complete phase 1. + ** If one of the BtreeCommitPhaseOne() calls fails, this indicates an + ** IO error while deleting or truncating a journal file. It is unlikely, + ** but could happen. In this case abandon processing and return the error. + */ + for ( i = 0; rc == SQLITE_OK && i < db.nDb; i++ ) + { + Btree pBt = db.aDb[i].pBt; + if ( pBt != null ) + { + rc = sqlite3BtreeCommitPhaseTwo( pBt, 0 ); + } + } + if ( rc == SQLITE_OK ) + { + sqlite3VtabCommit( db ); + } + } - /* The complex case - There is a multi-file write-transaction active. - ** This requires a master journal file to ensure the transaction is - ** committed atomicly. - */ + /* The complex case - There is a multi-file write-transaction active. + ** This requires a master journal file to ensure the transaction is + ** committed atomicly. + */ #if !SQLITE_OMIT_DISKIO - else { - sqlite3_vfs pVfs = db.pVfs; - bool needSync = false; - string zMaster = ""; /* File-name for the master journal */ - string zMainFile = sqlite3BtreeGetFilename(db.aDb[0].pBt); - sqlite3_file pMaster = null; - i64 offset = 0; - int res = 0; - - /* Select a master journal file name */ - do { - i64 iRandom = 0; - sqlite3DbFree(db, ref zMaster); - sqlite3_randomness(sizeof(u32), ref iRandom);//random.Length - zMaster = sqlite3MPrintf(db, "%s-mj%08X", zMainFile, iRandom & 0x7fffffff); - //if (!zMaster) - //{ - // return SQLITE_NOMEM; - //} - sqlite3FileSuffix3(zMainFile, zMaster); - rc = sqlite3OsAccess(pVfs, zMaster, SQLITE_ACCESS_EXISTS, ref res); - } while (rc == SQLITE_OK && res == 1); - if (rc == SQLITE_OK) { - /* Open the master journal. */ - rc = sqlite3OsOpenMalloc(ref pVfs, zMaster, ref pMaster, - SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | - SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_MASTER_JOURNAL, ref rc - ); - } - if (rc != SQLITE_OK) { - sqlite3DbFree(db, ref zMaster); - return rc; - } + else + { + sqlite3_vfs pVfs = db.pVfs; + bool needSync = false; + string zMaster = ""; /* File-name for the master journal */ + string zMainFile = sqlite3BtreeGetFilename( db.aDb[0].pBt ); + sqlite3_file pMaster = null; + i64 offset = 0; + int res = 0; + + /* Select a master journal file name */ + do + { + i64 iRandom = 0; + sqlite3DbFree( db, ref zMaster ); + sqlite3_randomness( sizeof( u32 ), ref iRandom );//random.Length + zMaster = sqlite3MPrintf( db, "%s-mj%08X", zMainFile, iRandom & 0x7fffffff ); + //if (!zMaster) + //{ + // return SQLITE_NOMEM; + //} + sqlite3FileSuffix3( zMainFile, zMaster ); + rc = sqlite3OsAccess( pVfs, zMaster, SQLITE_ACCESS_EXISTS, ref res ); + } while ( rc == SQLITE_OK && res == 1 ); + if ( rc == SQLITE_OK ) + { + /* Open the master journal. */ + rc = sqlite3OsOpenMalloc( ref pVfs, zMaster, ref pMaster, + SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | + SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_MASTER_JOURNAL, ref rc + ); + } + if ( rc != SQLITE_OK ) + { + sqlite3DbFree( db, ref zMaster ); + return rc; + } - /* Write the name of each database file in the transaction into the new - ** master journal file. If an error occurs at this point close - ** and delete the master journal file. All the individual journal files - ** still have 'null' as the master journal pointer, so they will roll - ** back independently if a failure occurs. - */ - for (i = 0; i < db.nDb; i++) { - Btree pBt = db.aDb[i].pBt; - if (sqlite3BtreeIsInTrans(pBt)) { - string zFile = sqlite3BtreeGetJournalname(pBt); - if (zFile == null) { - continue; /* Ignore TEMP and :memory: databases */ - } - Debug.Assert(zFile != ""); - if (!needSync && 0 == sqlite3BtreeSyncDisabled(pBt)) { - needSync = true; - } - rc = sqlite3OsWrite(pMaster, Encoding.UTF8.GetBytes(zFile), sqlite3Strlen30(zFile), offset); - offset += sqlite3Strlen30(zFile); - if (rc != SQLITE_OK) { - sqlite3OsCloseFree(pMaster); - sqlite3OsDelete(pVfs, zMaster, 0); - sqlite3DbFree(db, ref zMaster); - return rc; - } - } - } + /* Write the name of each database file in the transaction into the new + ** master journal file. If an error occurs at this point close + ** and delete the master journal file. All the individual journal files + ** still have 'null' as the master journal pointer, so they will roll + ** back independently if a failure occurs. + */ + for ( i = 0; i < db.nDb; i++ ) + { + Btree pBt = db.aDb[i].pBt; + if ( sqlite3BtreeIsInTrans( pBt ) ) + { + string zFile = sqlite3BtreeGetJournalname( pBt ); + if ( zFile == null ) + { + continue; /* Ignore TEMP and :memory: databases */ + } + Debug.Assert( zFile != "" ); + if ( !needSync && 0 == sqlite3BtreeSyncDisabled( pBt ) ) + { + needSync = true; + } + rc = sqlite3OsWrite( pMaster, Encoding.UTF8.GetBytes( zFile ), sqlite3Strlen30( zFile ), offset ); + offset += sqlite3Strlen30( zFile ); + if ( rc != SQLITE_OK ) + { + sqlite3OsCloseFree( pMaster ); + sqlite3OsDelete( pVfs, zMaster, 0 ); + sqlite3DbFree( db, ref zMaster ); + return rc; + } + } + } - /* Sync the master journal file. If the IOCAP_SEQUENTIAL device - ** flag is set this is not required. - */ - if (needSync - && 0 == (sqlite3OsDeviceCharacteristics(pMaster) & SQLITE_IOCAP_SEQUENTIAL) - && SQLITE_OK != (rc = sqlite3OsSync(pMaster, SQLITE_SYNC_NORMAL)) - ) { - sqlite3OsCloseFree(pMaster); - sqlite3OsDelete(pVfs, zMaster, 0); - sqlite3DbFree(db, ref zMaster); - return rc; - } + /* Sync the master journal file. If the IOCAP_SEQUENTIAL device + ** flag is set this is not required. + */ + if ( needSync + && 0 == ( sqlite3OsDeviceCharacteristics( pMaster ) & SQLITE_IOCAP_SEQUENTIAL ) + && SQLITE_OK != ( rc = sqlite3OsSync( pMaster, SQLITE_SYNC_NORMAL ) ) + ) + { + sqlite3OsCloseFree( pMaster ); + sqlite3OsDelete( pVfs, zMaster, 0 ); + sqlite3DbFree( db, ref zMaster ); + return rc; + } - /* Sync all the db files involved in the transaction. The same call - ** sets the master journal pointer in each individual journal. If - ** an error occurs here, do not delete the master journal file. - ** - ** If the error occurs during the first call to - ** sqlite3BtreeCommitPhaseOne(), then there is a chance that the - ** master journal file will be orphaned. But we cannot delete it, - ** in case the master journal file name was written into the journal - ** file before the failure occurred. - */ - for (i = 0; rc == SQLITE_OK && i < db.nDb; i++) { - Btree pBt = db.aDb[i].pBt; - if (pBt != null) { - rc = sqlite3BtreeCommitPhaseOne(pBt, zMaster); - } - } - sqlite3OsCloseFree(pMaster); - Debug.Assert(rc != SQLITE_BUSY); - if (rc != SQLITE_OK) { - sqlite3DbFree(db, ref zMaster); - return rc; - } + /* Sync all the db files involved in the transaction. The same call + ** sets the master journal pointer in each individual journal. If + ** an error occurs here, do not delete the master journal file. + ** + ** If the error occurs during the first call to + ** sqlite3BtreeCommitPhaseOne(), then there is a chance that the + ** master journal file will be orphaned. But we cannot delete it, + ** in case the master journal file name was written into the journal + ** file before the failure occurred. + */ + for ( i = 0; rc == SQLITE_OK && i < db.nDb; i++ ) + { + Btree pBt = db.aDb[i].pBt; + if ( pBt != null ) + { + rc = sqlite3BtreeCommitPhaseOne( pBt, zMaster ); + } + } + sqlite3OsCloseFree( pMaster ); + Debug.Assert( rc != SQLITE_BUSY ); + if ( rc != SQLITE_OK ) + { + sqlite3DbFree( db, ref zMaster ); + return rc; + } - /* Delete the master journal file. This commits the transaction. After - ** doing this the directory is synced again before any individual - ** transaction files are deleted. - */ - rc = sqlite3OsDelete(pVfs, zMaster, 1); - sqlite3DbFree(db, ref zMaster); - if (rc != 0) { - return rc; - } + /* Delete the master journal file. This commits the transaction. After + ** doing this the directory is synced again before any individual + ** transaction files are deleted. + */ + rc = sqlite3OsDelete( pVfs, zMaster, 1 ); + sqlite3DbFree( db, ref zMaster ); + if ( rc != 0 ) + { + return rc; + } - /* All files and directories have already been synced, so the following - ** calls to sqlite3BtreeCommitPhaseTwo() are only closing files and - ** deleting or truncating journals. If something goes wrong while - ** this is happening we don't really care. The integrity of the - ** transaction is already guaranteed, but some stray 'cold' journals - ** may be lying around. Returning an error code won't help matters. - */ + /* All files and directories have already been synced, so the following + ** calls to sqlite3BtreeCommitPhaseTwo() are only closing files and + ** deleting or truncating journals. If something goes wrong while + ** this is happening we don't really care. The integrity of the + ** transaction is already guaranteed, but some stray 'cold' journals + ** may be lying around. Returning an error code won't help matters. + */ #if SQLITE_TEST disable_simulated_io_errors(); #endif - sqlite3BeginBenignMalloc(); - for (i = 0; i < db.nDb; i++) { - Btree pBt = db.aDb[i].pBt; - if (pBt != null) { - sqlite3BtreeCommitPhaseTwo(pBt, 0); - } - } - sqlite3EndBenignMalloc(); + sqlite3BeginBenignMalloc(); + for ( i = 0; i < db.nDb; i++ ) + { + Btree pBt = db.aDb[i].pBt; + if ( pBt != null ) + { + sqlite3BtreeCommitPhaseTwo( pBt, 0 ); + } + } + sqlite3EndBenignMalloc(); #if SQLITE_TEST enable_simulated_io_errors(); #endif - sqlite3VtabCommit(db); - } + sqlite3VtabCommit( db ); + } #endif - return rc; - } + return rc; + } - /* - ** This routine checks that the sqlite3.activeVdbeCnt count variable - ** matches the number of vdbe's in the list sqlite3.pVdbe that are - ** currently active. An Debug.Assertion fails if the two counts do not match. - ** This is an internal self-check only - it is not an essential processing - ** step. - ** - ** This is a no-op if NDEBUG is defined. - */ + /* + ** This routine checks that the sqlite3.activeVdbeCnt count variable + ** matches the number of vdbe's in the list sqlite3.pVdbe that are + ** currently active. An Debug.Assertion fails if the two counts do not match. + ** This is an internal self-check only - it is not an essential processing + ** step. + ** + ** This is a no-op if NDEBUG is defined. + */ #if !NDEBUG - static void checkActiveVdbeCnt(sqlite3 db) { - Vdbe p; - int cnt = 0; - int nWrite = 0; - p = db.pVdbe; - while (p != null) { - if (p.magic == VDBE_MAGIC_RUN && p.pc >= 0) { - cnt++; - if (p.readOnly == false) - nWrite++; - } - p = p.pNext; - } - Debug.Assert(cnt == db.activeVdbeCnt); - Debug.Assert(nWrite == db.writeVdbeCnt); + static void checkActiveVdbeCnt( sqlite3 db ) + { + Vdbe p; + int cnt = 0; + int nWrite = 0; + p = db.pVdbe; + while ( p != null ) + { + if ( p.magic == VDBE_MAGIC_RUN && p.pc >= 0 ) + { + cnt++; + if ( p.readOnly == false ) + nWrite++; } + p = p.pNext; + } + Debug.Assert( cnt == db.activeVdbeCnt ); + Debug.Assert( nWrite == db.writeVdbeCnt ); + } #else //#define checkActiveVdbeCnt(x) static void checkActiveVdbeCnt( sqlite3 db ){} #endif - /* - ** For every Btree that in database connection db which - ** has been modified, "trip" or invalidate each cursor in - ** that Btree might have been modified so that the cursor - ** can never be used again. This happens when a rollback - *** occurs. We have to trip all the other cursors, even - ** cursor from other VMs in different database connections, - ** so that none of them try to use the data at which they - ** were pointing and which now may have been changed due - ** to the rollback. + /* +** For every Btree that in database connection db which +** has been modified, "trip" or invalidate each cursor in +** that Btree might have been modified so that the cursor +** can never be used again. This happens when a rollback +*** occurs. We have to trip all the other cursors, even +** cursor from other VMs in different database connections, +** so that none of them try to use the data at which they +** were pointing and which now may have been changed due +** to the rollback. +** +** Remember that a rollback can delete tables complete and +** reorder rootpages. So it is not sufficient just to save +** the state of the cursor. We have to invalidate the cursor +** so that it is never used again. +*/ + static void invalidateCursorsOnModifiedBtrees( sqlite3 db ) + { + int i; + for ( i = 0; i < db.nDb; i++ ) + { + Btree p = db.aDb[i].pBt; + if ( p != null && sqlite3BtreeIsInTrans( p ) ) + { + sqlite3BtreeTripAllCursors( p, SQLITE_ABORT ); + } + } + } + + /* + ** If the Vdbe passed as the first argument opened a statement-transaction, + ** close it now. Argument eOp must be either SAVEPOINT_ROLLBACK or + ** SAVEPOINT_RELEASE. If it is SAVEPOINT_ROLLBACK, then the statement + ** transaction is rolled back. If eOp is SAVEPOINT_RELEASE, then the + ** statement transaction is commtted. ** - ** Remember that a rollback can delete tables complete and - ** reorder rootpages. So it is not sufficient just to save - ** the state of the cursor. We have to invalidate the cursor - ** so that it is never used again. - */ - static void invalidateCursorsOnModifiedBtrees(sqlite3 db) { - int i; - for (i = 0; i < db.nDb; i++) { - Btree p = db.aDb[i].pBt; - if (p != null && sqlite3BtreeIsInTrans(p)) { - sqlite3BtreeTripAllCursors(p, SQLITE_ABORT); - } + ** If an IO error occurs, an SQLITE_IOERR_XXX error code is returned. + ** Otherwise SQLITE_OK. + */ + static int sqlite3VdbeCloseStatement( Vdbe p, int eOp ) + { + sqlite3 db = p.db; + int rc = SQLITE_OK; + /* If p->iStatement is greater than zero, then this Vdbe opened a + ** statement transaction that should be closed here. The only exception + ** is that an IO error may have occured, causing an emergency rollback. + ** In this case (db->nStatement==0), and there is nothing to do. + */ + if ( db.nStatement != 0 && p.iStatement != 0 ) + { + int i; + int iSavepoint = p.iStatement - 1; + + Debug.Assert( eOp == SAVEPOINT_ROLLBACK || eOp == SAVEPOINT_RELEASE ); + Debug.Assert( db.nStatement > 0 ); + Debug.Assert( p.iStatement == ( db.nStatement + db.nSavepoint ) ); + + for ( i = 0; i < db.nDb; i++ ) + { + int rc2 = SQLITE_OK; + Btree pBt = db.aDb[i].pBt; + if ( pBt != null ) + { + if ( eOp == SAVEPOINT_ROLLBACK ) + { + rc2 = sqlite3BtreeSavepoint( pBt, SAVEPOINT_ROLLBACK, iSavepoint ); + } + if ( rc2 == SQLITE_OK ) + { + rc2 = sqlite3BtreeSavepoint( pBt, SAVEPOINT_RELEASE, iSavepoint ); } + if ( rc == SQLITE_OK ) + { + rc = rc2; + } + } + } + db.nStatement--; + p.iStatement = 0; + + if ( rc == SQLITE_OK ) + { + if ( eOp == SAVEPOINT_ROLLBACK ) + { + rc = sqlite3VtabSavepoint( db, SAVEPOINT_ROLLBACK, iSavepoint ); + } + if ( rc == SQLITE_OK ) + { + rc = sqlite3VtabSavepoint( db, SAVEPOINT_RELEASE, iSavepoint ); + } } - /* - ** If the Vdbe passed as the first argument opened a statement-transaction, - ** close it now. Argument eOp must be either SAVEPOINT_ROLLBACK or - ** SAVEPOINT_RELEASE. If it is SAVEPOINT_ROLLBACK, then the statement - ** transaction is rolled back. If eOp is SAVEPOINT_RELEASE, then the - ** statement transaction is commtted. - ** - ** If an IO error occurs, an SQLITE_IOERR_XXX error code is returned. - ** Otherwise SQLITE_OK. - */ - static int sqlite3VdbeCloseStatement(Vdbe p, int eOp) { - sqlite3 db = p.db; - int rc = SQLITE_OK; - /* If p->iStatement is greater than zero, then this Vdbe opened a - ** statement transaction that should be closed here. The only exception - ** is that an IO error may have occured, causing an emergency rollback. - ** In this case (db->nStatement==0), and there is nothing to do. - */ - if (db.nStatement != 0 && p.iStatement != 0) { - int i; - int iSavepoint = p.iStatement - 1; - - Debug.Assert(eOp == SAVEPOINT_ROLLBACK || eOp == SAVEPOINT_RELEASE); - Debug.Assert(db.nStatement > 0); - Debug.Assert(p.iStatement == (db.nStatement + db.nSavepoint)); - - for (i = 0; i < db.nDb; i++) { - int rc2 = SQLITE_OK; - Btree pBt = db.aDb[i].pBt; - if (pBt != null) { - if (eOp == SAVEPOINT_ROLLBACK) { - rc2 = sqlite3BtreeSavepoint(pBt, SAVEPOINT_ROLLBACK, iSavepoint); - } - if (rc2 == SQLITE_OK) { - rc2 = sqlite3BtreeSavepoint(pBt, SAVEPOINT_RELEASE, iSavepoint); - } - if (rc == SQLITE_OK) { - rc = rc2; - } - } - } - db.nStatement--; - p.iStatement = 0; - - if (rc == SQLITE_OK) { - if (eOp == SAVEPOINT_ROLLBACK) { - rc = sqlite3VtabSavepoint(db, SAVEPOINT_ROLLBACK, iSavepoint); - } - if (rc == SQLITE_OK) { - rc = sqlite3VtabSavepoint(db, SAVEPOINT_RELEASE, iSavepoint); - } - } + /* If the statement transaction is being rolled back, also restore the + ** database handles deferred constraint counter to the value it had when + ** the statement transaction was opened. */ + if ( eOp == SAVEPOINT_ROLLBACK ) + { + db.nDeferredCons = p.nStmtDefCons; + } + } + return rc; + } - /* If the statement transaction is being rolled back, also restore the - ** database handles deferred constraint counter to the value it had when - ** the statement transaction was opened. */ - if (eOp == SAVEPOINT_ROLLBACK) { - db.nDeferredCons = p.nStmtDefCons; - } + /* + ** This function is called when a transaction opened by the database + ** handle associated with the VM passed as an argument is about to be + ** committed. If there are outstanding deferred foreign key constraint + ** violations, return SQLITE_ERROR. Otherwise, SQLITE_OK. + ** + ** If there are outstanding FK violations and this function returns + ** SQLITE_ERROR, set the result of the VM to SQLITE_CONSTRAINT and write + ** an error message to it. Then return SQLITE_ERROR. + */ +#if !SQLITE_OMIT_FOREIGN_KEY + static int sqlite3VdbeCheckFk( Vdbe p, int deferred ) + { + sqlite3 db = p.db; + if ( ( deferred != 0 && db.nDeferredCons > 0 ) || ( 0 == deferred && p.nFkConstraint > 0 ) ) + { + p.rc = SQLITE_CONSTRAINT; + p.errorAction = OE_Abort; + sqlite3SetString( ref p.zErrMsg, db, "foreign key constraint failed" ); + return SQLITE_ERROR; + } + return SQLITE_OK; + } +#endif + + /* +** This routine is called the when a VDBE tries to halt. If the VDBE +** has made changes and is in autocommit mode, then commit those +** changes. If a rollback is needed, then do the rollback. +** +** This routine is the only way to move the state of a VM from +** SQLITE_MAGIC_RUN to SQLITE_MAGIC_HALT. It is harmless to +** call this on a VM that is in the SQLITE_MAGIC_HALT state. +** +** Return an error code. If the commit could not complete because of +** lock contention, return SQLITE_BUSY. If SQLITE_BUSY is returned, it +** means the close did not happen and needs to be repeated. +*/ + static int sqlite3VdbeHalt( Vdbe p ) + { + int rc; /* Used to store transient return codes */ + sqlite3 db = p.db; + + /* This function contains the logic that determines if a statement or + ** transaction will be committed or rolled back as a result of the + ** execution of this virtual machine. + ** + ** If any of the following errors occur: + ** + ** SQLITE_NOMEM + ** SQLITE_IOERR + ** SQLITE_FULL + ** SQLITE_INTERRUPT + ** + ** Then the internal cache might have been left in an inconsistent + ** state. We need to rollback the statement transaction, if there is + ** one, or the complete transaction if there is no statement transaction. + */ + + //if ( p.db.mallocFailed != 0 ) + //{ + // p.rc = SQLITE_NOMEM; + //} + closeAllCursors( p ); + if ( p.magic != VDBE_MAGIC_RUN ) + { + return SQLITE_OK; + } + checkActiveVdbeCnt( db ); + + /* No commit or rollback needed if the program never started */ + if ( p.pc >= 0 ) + { + int mrc; /* Primary error code from p.rc */ + int eStatementOp = 0; + bool isSpecialError = false; /* Set to true if a 'special' error */ + + /* Lock all btrees used by the statement */ + sqlite3VdbeEnter( p ); + /* Check for one of the special errors */ + mrc = p.rc & 0xff; + Debug.Assert( p.rc != SQLITE_IOERR_BLOCKED ); /* This error no longer exists */ + isSpecialError = mrc == SQLITE_NOMEM || mrc == SQLITE_IOERR + || mrc == SQLITE_INTERRUPT || mrc == SQLITE_FULL; + if ( isSpecialError ) + { + /* If the query was read-only and the error code is SQLITE_INTERRUPT, + ** no rollback is necessary. Otherwise, at least a savepoint + ** transaction must be rolled back to restore the database to a + ** consistent state. + ** + ** Even if the statement is read-only, it is important to perform + ** a statement or transaction rollback operation. If the error + ** occured while writing to the journal, sub-journal or database + ** file as part of an effort to free up cache space (see function + ** pagerStress() in pager.c), the rollback is required to restore + ** the pager to a consistent state. + */ + if ( !p.readOnly || mrc != SQLITE_INTERRUPT ) + { + if ( ( mrc == SQLITE_NOMEM || mrc == SQLITE_FULL ) && p.usesStmtJournal ) + { + eStatementOp = SAVEPOINT_ROLLBACK; } - return rc; + else + { + /* We are forced to roll back the active transaction. Before doing + ** so, abort any other statements this handle currently has active. + */ + invalidateCursorsOnModifiedBtrees( db ); + sqlite3RollbackAll( db ); + sqlite3CloseSavepoints( db ); + db.autoCommit = 1; + } + } } - /* - ** This function is called when a transaction opened by the database - ** handle associated with the VM passed as an argument is about to be - ** committed. If there are outstanding deferred foreign key constraint - ** violations, return SQLITE_ERROR. Otherwise, SQLITE_OK. + /* Check for immediate foreign key violations. */ + if ( p.rc == SQLITE_OK ) + { + sqlite3VdbeCheckFk( p, 0 ); + } + + /* If the auto-commit flag is set and this is the only active writer + ** VM, then we do either a commit or rollback of the current transaction. ** - ** If there are outstanding FK violations and this function returns - ** SQLITE_ERROR, set the result of the VM to SQLITE_CONSTRAINT and write - ** an error message to it. Then return SQLITE_ERROR. + ** Note: This block also runs if one of the special errors handled + ** above has occurred. */ -#if !SQLITE_OMIT_FOREIGN_KEY - static int sqlite3VdbeCheckFk(Vdbe p, int deferred) { - sqlite3 db = p.db; - if ((deferred != 0 && db.nDeferredCons > 0) || (0 == deferred && p.nFkConstraint > 0)) { - p.rc = SQLITE_CONSTRAINT; - p.errorAction = OE_Abort; - sqlite3SetString(ref p.zErrMsg, db, "foreign key constraint failed"); + if ( !sqlite3VtabInSync( db ) + && db.autoCommit != 0 + && db.writeVdbeCnt == ( ( p.readOnly == false ) ? 1 : 0 ) + ) + { + if ( p.rc == SQLITE_OK || ( p.errorAction == OE_Fail && !isSpecialError ) ) + { + rc = sqlite3VdbeCheckFk( p, 1 ); + if ( rc != SQLITE_OK ) + { + if ( NEVER( p.readOnly ) ) + { + sqlite3VdbeLeave( p ); return SQLITE_ERROR; + } + rc = SQLITE_CONSTRAINT; + } + else + { + /* The auto-commit flag is true, the vdbe program was successful + ** or hit an 'OR FAIL' constraint and there are no deferred foreign + ** key constraints to hold up the transaction. This means a commit + ** is required. */ + rc = vdbeCommit( db, p ); + } + if ( rc == SQLITE_BUSY && p.readOnly ) + { + sqlite3VdbeLeave( p ); + return SQLITE_BUSY; } - return SQLITE_OK; + else if ( rc != SQLITE_OK ) + { + p.rc = rc; + sqlite3RollbackAll( db ); + } + else + { + db.nDeferredCons = 0; + sqlite3CommitInternalChanges( db ); + } + } + else + { + sqlite3RollbackAll( db ); + } + db.nStatement = 0; + } + else if ( eStatementOp == 0 ) + { + if ( p.rc == SQLITE_OK || p.errorAction == OE_Fail ) + { + eStatementOp = SAVEPOINT_RELEASE; + } + else if ( p.errorAction == OE_Abort ) + { + eStatementOp = SAVEPOINT_ROLLBACK; + } + else + { + invalidateCursorsOnModifiedBtrees( db ); + sqlite3RollbackAll( db ); + sqlite3CloseSavepoints( db ); + db.autoCommit = 1; + } } -#endif - /* - ** This routine is called the when a VDBE tries to halt. If the VDBE - ** has made changes and is in autocommit mode, then commit those - ** changes. If a rollback is needed, then do the rollback. - ** - ** This routine is the only way to move the state of a VM from - ** SQLITE_MAGIC_RUN to SQLITE_MAGIC_HALT. It is harmless to - ** call this on a VM that is in the SQLITE_MAGIC_HALT state. - ** - ** Return an error code. If the commit could not complete because of - ** lock contention, return SQLITE_BUSY. If SQLITE_BUSY is returned, it - ** means the close did not happen and needs to be repeated. - */ - static int sqlite3VdbeHalt(Vdbe p) { - int rc; /* Used to store transient return codes */ - sqlite3 db = p.db; - - /* This function contains the logic that determines if a statement or - ** transaction will be committed or rolled back as a result of the - ** execution of this virtual machine. - ** - ** If any of the following errors occur: - ** - ** SQLITE_NOMEM - ** SQLITE_IOERR - ** SQLITE_FULL - ** SQLITE_INTERRUPT - ** - ** Then the internal cache might have been left in an inconsistent - ** state. We need to rollback the statement transaction, if there is - ** one, or the complete transaction if there is no statement transaction. - */ - - //if ( p.db.mallocFailed != 0 ) - //{ - // p.rc = SQLITE_NOMEM; - //} - closeAllCursors(p); - if (p.magic != VDBE_MAGIC_RUN) { - return SQLITE_OK; + /* If eStatementOp is non-zero, then a statement transaction needs to + ** be committed or rolled back. Call sqlite3VdbeCloseStatement() to + ** do so. If this operation returns an error, and the current statement + ** error code is SQLITE_OK or SQLITE_CONSTRAINT, then promote the + ** current statement error code. + */ + if ( eStatementOp != 0 ) + { + rc = sqlite3VdbeCloseStatement( p, eStatementOp ); + if ( rc != 0 ) + { + if ( p.rc == SQLITE_OK || p.rc == SQLITE_CONSTRAINT ) + { + p.rc = rc; + sqlite3DbFree( db, ref p.zErrMsg ); + p.zErrMsg = null; } - checkActiveVdbeCnt(db); - - /* No commit or rollback needed if the program never started */ - if (p.pc >= 0) { - int mrc; /* Primary error code from p.rc */ - int eStatementOp = 0; - bool isSpecialError = false; /* Set to true if a 'special' error */ - - /* Lock all btrees used by the statement */ - sqlite3VdbeEnter(p); - /* Check for one of the special errors */ - mrc = p.rc & 0xff; - Debug.Assert(p.rc != SQLITE_IOERR_BLOCKED); /* This error no longer exists */ - isSpecialError = mrc == SQLITE_NOMEM || mrc == SQLITE_IOERR - || mrc == SQLITE_INTERRUPT || mrc == SQLITE_FULL; - if (isSpecialError) { - /* If the query was read-only and the error code is SQLITE_INTERRUPT, - ** no rollback is necessary. Otherwise, at least a savepoint - ** transaction must be rolled back to restore the database to a - ** consistent state. - ** - ** Even if the statement is read-only, it is important to perform - ** a statement or transaction rollback operation. If the error - ** occured while writing to the journal, sub-journal or database - ** file as part of an effort to free up cache space (see function - ** pagerStress() in pager.c), the rollback is required to restore - ** the pager to a consistent state. - */ - if (!p.readOnly || mrc != SQLITE_INTERRUPT) { - if ((mrc == SQLITE_NOMEM || mrc == SQLITE_FULL) && p.usesStmtJournal) { - eStatementOp = SAVEPOINT_ROLLBACK; - } else { - /* We are forced to roll back the active transaction. Before doing - ** so, abort any other statements this handle currently has active. - */ - invalidateCursorsOnModifiedBtrees(db); - sqlite3RollbackAll(db); - sqlite3CloseSavepoints(db); - db.autoCommit = 1; - } - } - } - - /* Check for immediate foreign key violations. */ - if (p.rc == SQLITE_OK) { - sqlite3VdbeCheckFk(p, 0); - } + invalidateCursorsOnModifiedBtrees( db ); + sqlite3RollbackAll( db ); + sqlite3CloseSavepoints( db ); + db.autoCommit = 1; + } + } - /* If the auto-commit flag is set and this is the only active writer - ** VM, then we do either a commit or rollback of the current transaction. - ** - ** Note: This block also runs if one of the special errors handled - ** above has occurred. - */ - if (!sqlite3VtabInSync(db) - && db.autoCommit != 0 - && db.writeVdbeCnt == ((p.readOnly == false) ? 1 : 0) - ) { - if (p.rc == SQLITE_OK || (p.errorAction == OE_Fail && !isSpecialError)) { - rc = sqlite3VdbeCheckFk(p, 1); - if (rc != SQLITE_OK) { - if (NEVER(p.readOnly)) { - sqlite3VdbeLeave(p); - return SQLITE_ERROR; - } - rc = SQLITE_CONSTRAINT; - } else { - /* The auto-commit flag is true, the vdbe program was successful - ** or hit an 'OR FAIL' constraint and there are no deferred foreign - ** key constraints to hold up the transaction. This means a commit - ** is required. */ - rc = vdbeCommit(db, p); - } - if (rc == SQLITE_BUSY && p.readOnly) { - sqlite3VdbeLeave(p); - return SQLITE_BUSY; - } else if (rc != SQLITE_OK) { - p.rc = rc; - sqlite3RollbackAll(db); - } else { - db.nDeferredCons = 0; - sqlite3CommitInternalChanges(db); - } - } else { - sqlite3RollbackAll(db); - } - db.nStatement = 0; - } else if (eStatementOp == 0) { - if (p.rc == SQLITE_OK || p.errorAction == OE_Fail) { - eStatementOp = SAVEPOINT_RELEASE; - } else if (p.errorAction == OE_Abort) { - eStatementOp = SAVEPOINT_ROLLBACK; - } else { - invalidateCursorsOnModifiedBtrees(db); - sqlite3RollbackAll(db); - sqlite3CloseSavepoints(db); - db.autoCommit = 1; - } - } + /* If this was an INSERT, UPDATE or DELETE and no statement transaction + ** has been rolled back, update the database connection change-counter. + */ + if ( p.changeCntOn ) + { + if ( eStatementOp != SAVEPOINT_ROLLBACK ) + { + sqlite3VdbeSetChanges( db, p.nChange ); + } + else + { + sqlite3VdbeSetChanges( db, 0 ); + } + p.nChange = 0; + } - /* If eStatementOp is non-zero, then a statement transaction needs to - ** be committed or rolled back. Call sqlite3VdbeCloseStatement() to - ** do so. If this operation returns an error, and the current statement - ** error code is SQLITE_OK or SQLITE_CONSTRAINT, then promote the - ** current statement error code. - */ - if (eStatementOp != 0) { - rc = sqlite3VdbeCloseStatement(p, eStatementOp); - if (rc != 0) { - if (p.rc == SQLITE_OK || p.rc == SQLITE_CONSTRAINT) { - p.rc = rc; - sqlite3DbFree(db, ref p.zErrMsg); - p.zErrMsg = null; - } - invalidateCursorsOnModifiedBtrees(db); - sqlite3RollbackAll(db); - sqlite3CloseSavepoints(db); - db.autoCommit = 1; - } - } + /* Rollback or commit any schema changes that occurred. */ + if ( p.rc != SQLITE_OK && ( db.flags & SQLITE_InternChanges ) != 0 ) + { + sqlite3ResetInternalSchema( db, -1 ); + db.flags = ( db.flags | SQLITE_InternChanges ); + } - /* If this was an INSERT, UPDATE or DELETE and no statement transaction - ** has been rolled back, update the database connection change-counter. - */ - if (p.changeCntOn) { - if (eStatementOp != SAVEPOINT_ROLLBACK) { - sqlite3VdbeSetChanges(db, p.nChange); - } else { - sqlite3VdbeSetChanges(db, 0); - } - p.nChange = 0; - } + /* Release the locks */ + sqlite3VdbeLeave( p ); + } - /* Rollback or commit any schema changes that occurred. */ - if (p.rc != SQLITE_OK && (db.flags & SQLITE_InternChanges) != 0) { - sqlite3ResetInternalSchema(db, -1); - db.flags = (db.flags | SQLITE_InternChanges); - } + /* We have successfully halted and closed the VM. Record this fact. */ + if ( p.pc >= 0 ) + { + db.activeVdbeCnt--; + if ( !p.readOnly ) + { + db.writeVdbeCnt--; + } + Debug.Assert( db.activeVdbeCnt >= db.writeVdbeCnt ); + } + p.magic = VDBE_MAGIC_HALT; + checkActiveVdbeCnt( db ); + //if ( p.db.mallocFailed != 0 ) + //{ + // p.rc = SQLITE_NOMEM; + //} + /* If the auto-commit flag is set to true, then any locks that were held + ** by connection db have now been released. Call sqlite3ConnectionUnlocked() + ** to invoke any required unlock-notify callbacks. + */ + if ( db.autoCommit != 0 ) + { + sqlite3ConnectionUnlocked( db ); + } - /* Release the locks */ - sqlite3VdbeLeave(p); - } + Debug.Assert( db.activeVdbeCnt > 0 || db.autoCommit == 0 || db.nStatement == 0 ); + return ( p.rc == SQLITE_BUSY ? SQLITE_BUSY : SQLITE_OK ); + } - /* We have successfully halted and closed the VM. Record this fact. */ - if (p.pc >= 0) { - db.activeVdbeCnt--; - if (!p.readOnly) { - db.writeVdbeCnt--; - } - Debug.Assert(db.activeVdbeCnt >= db.writeVdbeCnt); - } - p.magic = VDBE_MAGIC_HALT; - checkActiveVdbeCnt(db); - //if ( p.db.mallocFailed != 0 ) - //{ - // p.rc = SQLITE_NOMEM; - //} - /* If the auto-commit flag is set to true, then any locks that were held - ** by connection db have now been released. Call sqlite3ConnectionUnlocked() - ** to invoke any required unlock-notify callbacks. - */ - if (db.autoCommit != 0) { - sqlite3ConnectionUnlocked(db); - } - Debug.Assert(db.activeVdbeCnt > 0 || db.autoCommit == 0 || db.nStatement == 0); - return (p.rc == SQLITE_BUSY ? SQLITE_BUSY : SQLITE_OK); - } + /* + ** Each VDBE holds the result of the most recent sqlite3_step() call + ** in p.rc. This routine sets that result back to SQLITE_OK. + */ + static void sqlite3VdbeResetStepResult( Vdbe p ) + { + p.rc = SQLITE_OK; + } + /* + ** Clean up a VDBE after execution but do not delete the VDBE just yet. + ** Write any error messages into pzErrMsg. Return the result code. + ** + ** After this routine is run, the VDBE should be ready to be executed + ** again. + ** + ** To look at it another way, this routine resets the state of the + ** virtual machine from VDBE_MAGIC_RUN or VDBE_MAGIC_HALT back to + ** VDBE_MAGIC_INIT. + */ + static int sqlite3VdbeReset( Vdbe p ) + { + sqlite3 db; + db = p.db; + + /* If the VM did not run to completion or if it encountered an + ** error, then it might not have been halted properly. So halt + ** it now. + */ + sqlite3VdbeHalt( p ); - /* - ** Each VDBE holds the result of the most recent sqlite3_step() call - ** in p.rc. This routine sets that result back to SQLITE_OK. - */ - static void sqlite3VdbeResetStepResult(Vdbe p) { - p.rc = SQLITE_OK; + /* If the VDBE has be run even partially, then transfer the error code + ** and error message from the VDBE into the main database structure. But + ** if the VDBE has just been set to run but has not actually executed any + ** instructions yet, leave the main database error information unchanged. + */ + if ( p.pc >= 0 ) + { + //if ( p.zErrMsg != 0 ) // Always exists under C# + { + sqlite3BeginBenignMalloc(); + sqlite3ValueSetStr( db.pErr, -1, p.zErrMsg == null ? "" : p.zErrMsg, SQLITE_UTF8, SQLITE_TRANSIENT ); + sqlite3EndBenignMalloc(); + db.errCode = p.rc; + sqlite3DbFree( db, ref p.zErrMsg ); + p.zErrMsg = ""; } - - /* - ** Clean up a VDBE after execution but do not delete the VDBE just yet. - ** Write any error messages into pzErrMsg. Return the result code. - ** - ** After this routine is run, the VDBE should be ready to be executed - ** again. - ** - ** To look at it another way, this routine resets the state of the - ** virtual machine from VDBE_MAGIC_RUN or VDBE_MAGIC_HALT back to - ** VDBE_MAGIC_INIT. + //else if ( p.rc != 0 ) + //{ + // sqlite3Error( db, p.rc, 0 ); + //} + //else + //{ + // sqlite3Error( db, SQLITE_OK, 0 ); + //} + if ( p.runOnlyOnce != 0 ) + p.expired = true; + } + else if ( p.rc != 0 && p.expired ) + { + /* The expired flag was set on the VDBE before the first call + ** to sqlite3_step(). For consistency (since sqlite3_step() was + ** called), set the database error in this case as well. */ - static int sqlite3VdbeReset(Vdbe p) { - sqlite3 db; - db = p.db; - - /* If the VM did not run to completion or if it encountered an - ** error, then it might not have been halted properly. So halt - ** it now. - */ - sqlite3VdbeHalt(p); - - /* If the VDBE has be run even partially, then transfer the error code - ** and error message from the VDBE into the main database structure. But - ** if the VDBE has just been set to run but has not actually executed any - ** instructions yet, leave the main database error information unchanged. - */ - if (p.pc >= 0) { - //if ( p.zErrMsg != 0 ) // Always exists under C# - { - sqlite3BeginBenignMalloc(); - sqlite3ValueSetStr(db.pErr, -1, p.zErrMsg == null ? "" : p.zErrMsg, SQLITE_UTF8, SQLITE_TRANSIENT); - sqlite3EndBenignMalloc(); - db.errCode = p.rc; - sqlite3DbFree(db, ref p.zErrMsg); - p.zErrMsg = ""; - } - //else if ( p.rc != 0 ) - //{ - // sqlite3Error( db, p.rc, 0 ); - //} - //else - //{ - // sqlite3Error( db, SQLITE_OK, 0 ); - //} - if (p.runOnlyOnce != 0) - p.expired = true; - } else if (p.rc != 0 && p.expired) { - /* The expired flag was set on the VDBE before the first call - ** to sqlite3_step(). For consistency (since sqlite3_step() was - ** called), set the database error in this case as well. - */ - sqlite3Error(db, p.rc, 0); - sqlite3ValueSetStr(db.pErr, -1, p.zErrMsg, SQLITE_UTF8, SQLITE_TRANSIENT); - sqlite3DbFree(db, ref p.zErrMsg); - p.zErrMsg = ""; - } + sqlite3Error( db, p.rc, 0 ); + sqlite3ValueSetStr( db.pErr, -1, p.zErrMsg, SQLITE_UTF8, SQLITE_TRANSIENT ); + sqlite3DbFree( db, ref p.zErrMsg ); + p.zErrMsg = ""; + } - /* Reclaim all memory used by the VDBE - */ - Cleanup(p); + /* Reclaim all memory used by the VDBE + */ + Cleanup( p ); - /* Save profiling information from this VDBE run. - */ -#if VDBE_PROFILE && TODO + /* Save profiling information from this VDBE run. + */ +#if VDBE_PROFILE && TODO { FILE *out = fopen("vdbe_profile.out", "a"); if( out ){ @@ -2800,292 +3139,327 @@ static int sqlite3VdbeReset(Vdbe p) { } } #endif - p.magic = VDBE_MAGIC_INIT; - return p.rc & db.errMask; - } + p.magic = VDBE_MAGIC_INIT; + return p.rc & db.errMask; + } - /* - ** Clean up and delete a VDBE after execution. Return an integer which is - ** the result code. Write any error message text into pzErrMsg. - */ - static int sqlite3VdbeFinalize(ref Vdbe p) { - int rc = SQLITE_OK; - if (p.magic == VDBE_MAGIC_RUN || p.magic == VDBE_MAGIC_HALT) { - rc = sqlite3VdbeReset(p); - Debug.Assert((rc & p.db.errMask) == rc); - } - sqlite3VdbeDelete(ref p); - return rc; - } + /* + ** Clean up and delete a VDBE after execution. Return an integer which is + ** the result code. Write any error message text into pzErrMsg. + */ + static int sqlite3VdbeFinalize( ref Vdbe p ) + { + int rc = SQLITE_OK; + if ( p.magic == VDBE_MAGIC_RUN || p.magic == VDBE_MAGIC_HALT ) + { + rc = sqlite3VdbeReset( p ); + Debug.Assert( ( rc & p.db.errMask ) == rc ); + } + sqlite3VdbeDelete( ref p ); + return rc; + } - /* - ** Call the destructor for each auxdata entry in pVdbeFunc for which - ** the corresponding bit in mask is clear. Auxdata entries beyond 31 - ** are always destroyed. To destroy all auxdata entries, call this - ** routine with mask==0. - */ - static void sqlite3VdbeDeleteAuxData(VdbeFunc pVdbeFunc, int mask) { - int i; - for (i = 0; i < pVdbeFunc.nAux; i++) { - AuxData pAux = pVdbeFunc.apAux[i]; - if ((i > 31 || (mask & (((u32)1) << i)) == 0 && pAux.pAux != null)) { - if (pAux.pAux != null && pAux.pAux is IDisposable) { - (pAux.pAux as IDisposable).Dispose(); - } - pAux.pAux = null; - } - } + /* + ** Call the destructor for each auxdata entry in pVdbeFunc for which + ** the corresponding bit in mask is clear. Auxdata entries beyond 31 + ** are always destroyed. To destroy all auxdata entries, call this + ** routine with mask==0. + */ + static void sqlite3VdbeDeleteAuxData( VdbeFunc pVdbeFunc, int mask ) + { + int i; + for ( i = 0; i < pVdbeFunc.nAux; i++ ) + { + AuxData pAux = pVdbeFunc.apAux[i]; + if ( ( i > 31 || ( mask & ( ( (u32)1 ) << i ) ) == 0 && pAux.pAux != null ) ) + { + if ( pAux.pAux != null && pAux.pAux is IDisposable ) + { + (pAux.pAux as IDisposable).Dispose(); + } + pAux.pAux = null; } + } + } - /* - ** Free all memory associated with the Vdbe passed as the second argument. - ** The difference between this function and sqlite3VdbeDelete() is that - ** VdbeDelete() also unlinks the Vdbe from the list of VMs associated with - ** the database connection. - */ - static void sqlite3VdbeDeleteObject(sqlite3 db, ref Vdbe p) { - SubProgram pSub, pNext; - int i; - Debug.Assert(p.db == null || p.db == db); - releaseMemArray(p.aVar, p.nVar); - releaseMemArray(p.aColName, p.nResColumn, COLNAME_N); - for (pSub = p.pProgram; pSub != null; pSub = pNext) { - pNext = pSub.pNext; - vdbeFreeOpArray(db, ref pSub.aOp, pSub.nOp); - sqlite3DbFree(db, ref pSub); - } - //for ( i = p->nzVar - 1; i >= 0; i-- ) - // sqlite3DbFree( db, p.azVar[i] ); - vdbeFreeOpArray(db, ref p.aOp, p.nOp); - sqlite3DbFree(db, ref p.aLabel); - sqlite3DbFree(db, ref p.aColName); - sqlite3DbFree(db, ref p.zSql); - sqlite3DbFree(db, ref p.pFree); - // Free memory allocated from db within p - //sqlite3DbFree( db, p ); - } - - /* - ** Delete an entire VDBE. - */ - static void sqlite3VdbeDelete(ref Vdbe p) { - sqlite3 db; - if (NEVER(p == null)) - return; - Cleanup(p); - db = p.db; - if (p.pPrev != null) { - p.pPrev.pNext = p.pNext; - } else { - Debug.Assert(db.pVdbe == p); - db.pVdbe = p.pNext; - } - if (p.pNext != null) { - p.pNext.pPrev = p.pPrev; - } - p.magic = VDBE_MAGIC_DEAD; - p.db = null; - sqlite3VdbeDeleteObject(db, ref p); - } + /* + ** Free all memory associated with the Vdbe passed as the second argument. + ** The difference between this function and sqlite3VdbeDelete() is that + ** VdbeDelete() also unlinks the Vdbe from the list of VMs associated with + ** the database connection. + */ + static void sqlite3VdbeDeleteObject( sqlite3 db, ref Vdbe p ) + { + SubProgram pSub, pNext; + int i; + Debug.Assert( p.db == null || p.db == db ); + releaseMemArray( p.aVar, p.nVar ); + releaseMemArray( p.aColName, p.nResColumn, COLNAME_N ); + for ( pSub = p.pProgram; pSub != null; pSub = pNext ) + { + pNext = pSub.pNext; + vdbeFreeOpArray( db, ref pSub.aOp, pSub.nOp ); + sqlite3DbFree( db, ref pSub ); + } + //for ( i = p->nzVar - 1; i >= 0; i-- ) + // sqlite3DbFree( db, p.azVar[i] ); + vdbeFreeOpArray( db, ref p.aOp, p.nOp ); + sqlite3DbFree( db, ref p.aLabel ); + sqlite3DbFree( db, ref p.aColName ); + sqlite3DbFree( db, ref p.zSql ); + sqlite3DbFree( db, ref p.pFree ); + // Free memory allocated from db within p + //sqlite3DbFree( db, p ); + } - /* - ** Make sure the cursor p is ready to read or write the row to which it - ** was last positioned. Return an error code if an OOM fault or I/O error - ** prevents us from positioning the cursor to its correct position. - ** - ** If a MoveTo operation is pending on the given cursor, then do that - ** MoveTo now. If no move is pending, check to see if the row has been - ** deleted out from under the cursor and if it has, mark the row as - ** a NULL row. - ** - ** If the cursor is already pointing to the correct row and that row has - ** not been deleted out from under the cursor, then this routine is a no-op. - */ - static int sqlite3VdbeCursorMoveto(VdbeCursor p) { - if (p.deferredMoveto) { - int res = 0; - int rc; -#if SQLITE_TEST + /* + ** Delete an entire VDBE. + */ + static void sqlite3VdbeDelete( ref Vdbe p ) + { + sqlite3 db; + if ( NEVER( p == null ) ) + return; + Cleanup( p ); + db = p.db; + if ( p.pPrev != null ) + { + p.pPrev.pNext = p.pNext; + } + else + { + Debug.Assert( db.pVdbe == p ); + db.pVdbe = p.pNext; + } + if ( p.pNext != null ) + { + p.pNext.pPrev = p.pPrev; + } + p.magic = VDBE_MAGIC_DEAD; + p.db = null; + sqlite3VdbeDeleteObject( db, ref p ); + } + + /* + ** Make sure the cursor p is ready to read or write the row to which it + ** was last positioned. Return an error code if an OOM fault or I/O error + ** prevents us from positioning the cursor to its correct position. + ** + ** If a MoveTo operation is pending on the given cursor, then do that + ** MoveTo now. If no move is pending, check to see if the row has been + ** deleted out from under the cursor and if it has, mark the row as + ** a NULL row. + ** + ** If the cursor is already pointing to the correct row and that row has + ** not been deleted out from under the cursor, then this routine is a no-op. + */ + static int sqlite3VdbeCursorMoveto( VdbeCursor p ) + { + if ( p.deferredMoveto ) + { + int res = 0; + int rc; +#if SQLITE_TEST //extern int sqlite3_search_count; #endif - Debug.Assert(p.isTable); - rc = sqlite3BtreeMovetoUnpacked(p.pCursor, null, p.movetoTarget, 0, ref res); - if (rc != 0) - return rc; - p.lastRowid = p.movetoTarget; - if (res != 0) - return SQLITE_CORRUPT_BKPT(); - p.rowidIsValid = true; -#if SQLITE_TEST + Debug.Assert( p.isTable ); + rc = sqlite3BtreeMovetoUnpacked( p.pCursor, null, p.movetoTarget, 0, ref res ); + if ( rc != 0 ) + return rc; + p.lastRowid = p.movetoTarget; + if ( res != 0 ) + return SQLITE_CORRUPT_BKPT(); + p.rowidIsValid = true; +#if SQLITE_TEST #if !TCLSH sqlite3_search_count++; #else sqlite3_search_count.iValue++; #endif #endif - p.deferredMoveto = false; - p.cacheStatus = CACHE_STALE; - } else if (ALWAYS(p.pCursor != null)) { - int hasMoved = 0; - int rc = sqlite3BtreeCursorHasMoved(p.pCursor, ref hasMoved); - if (rc != 0) - return rc; - if (hasMoved != 0) { - p.cacheStatus = CACHE_STALE; - p.nullRow = true; - } - } - return SQLITE_OK; + p.deferredMoveto = false; + p.cacheStatus = CACHE_STALE; + } + else if ( ALWAYS( p.pCursor != null ) ) + { + int hasMoved = 0; + int rc = sqlite3BtreeCursorHasMoved( p.pCursor, ref hasMoved ); + if ( rc != 0 ) + return rc; + if ( hasMoved != 0 ) + { + p.cacheStatus = CACHE_STALE; + p.nullRow = true; } + } + return SQLITE_OK; + } - /* - ** The following functions: - ** - ** sqlite3VdbeSerialType() - ** sqlite3VdbeSerialTypeLen() - ** sqlite3VdbeSerialLen() - ** sqlite3VdbeSerialPut() - ** sqlite3VdbeSerialGet() - ** - ** encapsulate the code that serializes values for storage in SQLite - ** data and index records. Each serialized value consists of a - ** 'serial-type' and a blob of data. The serial type is an 8-byte unsigned - ** integer, stored as a varint. - ** - ** In an SQLite index record, the serial type is stored directly before - ** the blob of data that it corresponds to. In a table record, all serial - ** types are stored at the start of the record, and the blobs of data at - ** the end. Hence these functions allow the caller to handle the - ** serial-type and data blob seperately. - ** - ** The following table describes the various storage classes for data: - ** - ** serial type bytes of data type - ** -------------- --------------- --------------- - ** 0 0 NULL - ** 1 1 signed integer - ** 2 2 signed integer - ** 3 3 signed integer - ** 4 4 signed integer - ** 5 6 signed integer - ** 6 8 signed integer - ** 7 8 IEEE float - ** 8 0 Integer constant 0 - ** 9 0 Integer constant 1 - ** 10,11 reserved for expansion - ** N>=12 and even (N-12)/2 BLOB - ** N>=13 and odd (N-13)/2 text - ** - ** The 8 and 9 types were added in 3.3.0, file format 4. Prior versions - ** of SQLite will not understand those serial types. - */ - - /* - ** Return the serial-type for the value stored in pMem. - */ - static u32 sqlite3VdbeSerialType(Mem pMem, int file_format) { - int flags = pMem.flags; - int n; - - if ((flags & MEM_Null) != 0) { - return 0; - } - if ((flags & MEM_Int) != 0) { - /* Figure out whether to use 1, 2, 4, 6 or 8 bytes. */ - const i64 MAX_6BYTE = ((((i64)0x00008000) << 32) - 1); - i64 i = pMem.u.i; - u64 u; - if (file_format >= 4 && (i & 1) == i) { - return 8 + (u32)i; - } - if (i < 0) { - if (i < (-MAX_6BYTE)) - return 6; - /* Previous test prevents: u = -(-9223372036854775808) */ - u = (u64)(-i); - } else { - u = (u64)i; - } - if (u <= 127) - return 1; - if (u <= 32767) - return 2; - if (u <= 8388607) - return 3; - if (u <= 2147483647) - return 4; - if (u <= MAX_6BYTE) - return 5; - return 6; - } - if ((flags & MEM_Real) != 0) { - return 7; - } - Debug.Assert( /* pMem.db.mallocFailed != 0 || */ (flags & (MEM_Str | MEM_Blob)) != 0); - n = pMem.n; - if ((flags & MEM_Zero) != 0) { - n += pMem.u.nZero; - } else if ((flags & MEM_Blob) != 0) { - n = pMem.zBLOB != null ? pMem.zBLOB.Length : pMem.z != null ? pMem.z.Length : 0; - } else { - if (pMem.z != null) - n = Encoding.UTF8.GetByteCount(pMem.n < pMem.z.Length ? pMem.z.Substring(0, pMem.n) : pMem.z); - else - n = pMem.zBLOB.Length; - pMem.n = n; - } + /* + ** The following functions: + ** + ** sqlite3VdbeSerialType() + ** sqlite3VdbeSerialTypeLen() + ** sqlite3VdbeSerialLen() + ** sqlite3VdbeSerialPut() + ** sqlite3VdbeSerialGet() + ** + ** encapsulate the code that serializes values for storage in SQLite + ** data and index records. Each serialized value consists of a + ** 'serial-type' and a blob of data. The serial type is an 8-byte unsigned + ** integer, stored as a varint. + ** + ** In an SQLite index record, the serial type is stored directly before + ** the blob of data that it corresponds to. In a table record, all serial + ** types are stored at the start of the record, and the blobs of data at + ** the end. Hence these functions allow the caller to handle the + ** serial-type and data blob seperately. + ** + ** The following table describes the various storage classes for data: + ** + ** serial type bytes of data type + ** -------------- --------------- --------------- + ** 0 0 NULL + ** 1 1 signed integer + ** 2 2 signed integer + ** 3 3 signed integer + ** 4 4 signed integer + ** 5 6 signed integer + ** 6 8 signed integer + ** 7 8 IEEE float + ** 8 0 Integer constant 0 + ** 9 0 Integer constant 1 + ** 10,11 reserved for expansion + ** N>=12 and even (N-12)/2 BLOB + ** N>=13 and odd (N-13)/2 text + ** + ** The 8 and 9 types were added in 3.3.0, file format 4. Prior versions + ** of SQLite will not understand those serial types. + */ - Debug.Assert(n >= 0); - return (u32)((n * 2) + 12 + (((flags & MEM_Str) != 0) ? 1 : 0)); + /* + ** Return the serial-type for the value stored in pMem. + */ + static u32 sqlite3VdbeSerialType( Mem pMem, int file_format ) + { + int flags = pMem.flags; + int n; + + if ( ( flags & MEM_Null ) != 0 ) + { + return 0; + } + if ( ( flags & MEM_Int ) != 0 ) + { + /* Figure out whether to use 1, 2, 4, 6 or 8 bytes. */ + const i64 MAX_6BYTE = ( ( ( (i64)0x00008000 ) << 32 ) - 1 ); + i64 i = pMem.u.i; + u64 u; + if ( file_format >= 4 && ( i & 1 ) == i ) + { + return 8 + (u32)i; } - - /* - ** Return the length of the data corresponding to the supplied serial-type. - */ - static u32[] aSize = new u32[] { 0, 1, 2, 3, 4, 6, 8, 8, 0, 0, 0, 0 }; - static u32 sqlite3VdbeSerialTypeLen(u32 serial_type) { - if (serial_type >= 12) { - return (u32)((serial_type - 12) / 2); - } else { - return aSize[serial_type]; - } + if ( i < 0 ) + { + if ( i < ( -MAX_6BYTE ) ) + return 6; + /* Previous test prevents: u = -(-9223372036854775808) */ + u = (u64)( -i ); } + else + { + u = (u64)i; + } + if ( u <= 127 ) + return 1; + if ( u <= 32767 ) + return 2; + if ( u <= 8388607 ) + return 3; + if ( u <= 2147483647 ) + return 4; + if ( u <= MAX_6BYTE ) + return 5; + return 6; + } + if ( ( flags & MEM_Real ) != 0 ) + { + return 7; + } + Debug.Assert( /* pMem.db.mallocFailed != 0 || */ ( flags & ( MEM_Str | MEM_Blob ) ) != 0 ); + n = pMem.n; + if ( ( flags & MEM_Zero ) != 0 ) + { + n += pMem.u.nZero; + } + else if ( ( flags & MEM_Blob ) != 0 ) + { + n = pMem.zBLOB != null ? pMem.zBLOB.Length : pMem.z != null ? pMem.z.Length : 0; + } + else + { + if ( pMem.z != null ) + n = Encoding.UTF8.GetByteCount( pMem.n < pMem.z.Length ? pMem.z.Substring( 0, pMem.n ) : pMem.z ); + else + n = pMem.zBLOB.Length; + pMem.n = n; + } - /* - ** If we are on an architecture with mixed-endian floating - ** points (ex: ARM7) then swap the lower 4 bytes with the - ** upper 4 bytes. Return the result. - ** - ** For most architectures, this is a no-op. - ** - ** (later): It is reported to me that the mixed-endian problem - ** on ARM7 is an issue with GCC, not with the ARM7 chip. It seems - ** that early versions of GCC stored the two words of a 64-bit - ** float in the wrong order. And that error has been propagated - ** ever since. The blame is not necessarily with GCC, though. - ** GCC might have just copying the problem from a prior compiler. - ** I am also told that newer versions of GCC that follow a different - ** ABI get the byte order right. - ** - ** Developers using SQLite on an ARM7 should compile and run their - ** application using -DSQLITE_DEBUG=1 at least once. With DEBUG - ** enabled, some Debug.Asserts below will ensure that the byte order of - ** floating point values is correct. - ** - ** (2007-08-30) Frank van Vugt has studied this problem closely - ** and has send his findings to the SQLite developers. Frank - ** writes that some Linux kernels offer floating point hardware - ** emulation that uses only 32-bit mantissas instead of a full - ** 48-bits as required by the IEEE standard. (This is the - ** CONFIG_FPE_FASTFPE option.) On such systems, floating point - ** byte swapping becomes very complicated. To avoid problems, - ** the necessary byte swapping is carried out using a 64-bit integer - ** rather than a 64-bit float. Frank assures us that the code here - ** works for him. We, the developers, have no way to independently - ** verify this, but Frank seems to know what he is talking about - ** so we trust him. - */ -#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT + Debug.Assert( n >= 0 ); + return (u32)( ( n * 2 ) + 12 + ( ( ( flags & MEM_Str ) != 0 ) ? 1 : 0 ) ); + } + + /* + ** Return the length of the data corresponding to the supplied serial-type. + */ + static u32[] aSize = new u32[] { 0, 1, 2, 3, 4, 6, 8, 8, 0, 0, 0, 0 }; + static u32 sqlite3VdbeSerialTypeLen( u32 serial_type ) + { + if ( serial_type >= 12 ) + { + return (u32)( ( serial_type - 12 ) / 2 ); + } + else + { + return aSize[serial_type]; + } + } + + /* + ** If we are on an architecture with mixed-endian floating + ** points (ex: ARM7) then swap the lower 4 bytes with the + ** upper 4 bytes. Return the result. + ** + ** For most architectures, this is a no-op. + ** + ** (later): It is reported to me that the mixed-endian problem + ** on ARM7 is an issue with GCC, not with the ARM7 chip. It seems + ** that early versions of GCC stored the two words of a 64-bit + ** float in the wrong order. And that error has been propagated + ** ever since. The blame is not necessarily with GCC, though. + ** GCC might have just copying the problem from a prior compiler. + ** I am also told that newer versions of GCC that follow a different + ** ABI get the byte order right. + ** + ** Developers using SQLite on an ARM7 should compile and run their + ** application using -DSQLITE_DEBUG=1 at least once. With DEBUG + ** enabled, some Debug.Asserts below will ensure that the byte order of + ** floating point values is correct. + ** + ** (2007-08-30) Frank van Vugt has studied this problem closely + ** and has send his findings to the SQLite developers. Frank + ** writes that some Linux kernels offer floating point hardware + ** emulation that uses only 32-bit mantissas instead of a full + ** 48-bits as required by the IEEE standard. (This is the + ** CONFIG_FPE_FASTFPE option.) On such systems, floating point + ** byte swapping becomes very complicated. To avoid problems, + ** the necessary byte swapping is carried out using a 64-bit integer + ** rather than a 64-bit float. Frank assures us that the code here + ** works for him. We, the developers, have no way to independently + ** verify this, but Frank seems to know what he is talking about + ** so we trust him. + */ +#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT //static u64 floatSwap(u64 in){ // union { // u64 r; @@ -3101,751 +3475,839 @@ static u32 sqlite3VdbeSerialTypeLen(u32 serial_type) { //} //# define swapMixedEndianFloat(X) X = floatSwap(X) #else - //# define swapMixedEndianFloat(X) + //# define swapMixedEndianFloat(X) #endif - /* - ** Write the serialized data blob for the value stored in pMem into - ** buf. It is assumed that the caller has allocated sufficient space. - ** Return the number of bytes written. - ** - ** nBuf is the amount of space left in buf[]. nBuf must always be - ** large enough to hold the entire field. Except, if the field is - ** a blob with a zero-filled tail, then buf[] might be just the right - ** size to hold everything except for the zero-filled tail. If buf[] - ** is only big enough to hold the non-zero prefix, then only write that - ** prefix into buf[]. But if buf[] is large enough to hold both the - ** prefix and the tail then write the prefix and set the tail to all - ** zeros. - ** - ** Return the number of bytes actually written into buf[]. The number - ** of bytes in the zero-filled tail is included in the return value only - ** if those bytes were zeroed in buf[]. - */ - static u32 sqlite3VdbeSerialPut(byte[] buf, int offset, int nBuf, Mem pMem, int file_format) { - u32 serial_type = sqlite3VdbeSerialType(pMem, file_format); - u32 len; - - /* Integer and Real */ - if (serial_type <= 7 && serial_type > 0) { - u64 v; - u32 i; - if (serial_type == 7) { - //Debug.Assert( sizeof( v) == sizeof(pMem.r)); + /* +** Write the serialized data blob for the value stored in pMem into +** buf. It is assumed that the caller has allocated sufficient space. +** Return the number of bytes written. +** +** nBuf is the amount of space left in buf[]. nBuf must always be +** large enough to hold the entire field. Except, if the field is +** a blob with a zero-filled tail, then buf[] might be just the right +** size to hold everything except for the zero-filled tail. If buf[] +** is only big enough to hold the non-zero prefix, then only write that +** prefix into buf[]. But if buf[] is large enough to hold both the +** prefix and the tail then write the prefix and set the tail to all +** zeros. +** +** Return the number of bytes actually written into buf[]. The number +** of bytes in the zero-filled tail is included in the return value only +** if those bytes were zeroed in buf[]. +*/ + static u32 sqlite3VdbeSerialPut( byte[] buf, int offset, int nBuf, Mem pMem, int file_format ) + { + u32 serial_type = sqlite3VdbeSerialType( pMem, file_format ); + u32 len; + + /* Integer and Real */ + if ( serial_type <= 7 && serial_type > 0 ) + { + u64 v; + u32 i; + if ( serial_type == 7 ) + { + //Debug.Assert( sizeof( v) == sizeof(pMem.r)); #if WINDOWS_PHONE || WINDOWS_MOBILE v = (ulong)BitConverter.ToInt64(BitConverter.GetBytes(pMem.r),0); #else - v = (ulong)BitConverter.DoubleToInt64Bits(pMem.r);// memcpy( &v, pMem.r, v ).Length; + v = (ulong)BitConverter.DoubleToInt64Bits( pMem.r );// memcpy( &v, pMem.r, v ).Length; #endif -#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT +#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT swapMixedEndianFloat( v ); #endif - } else { - v = (ulong)pMem.u.i; - } - len = i = sqlite3VdbeSerialTypeLen(serial_type); - Debug.Assert(len <= (u32)nBuf); - while (i-- != 0) { - buf[offset + i] = (u8)(v & 0xFF); - v >>= 8; - } - return len; - } - - /* String or blob */ - if (serial_type >= 12) { - // TO DO -- PASS TESTS WITH THIS ON Debug.Assert( pMem.n + ( ( pMem.flags & MEM_Zero ) != 0 ? pMem.u.nZero : 0 ) == (int)sqlite3VdbeSerialTypeLen( serial_type ) ); - Debug.Assert(pMem.n <= nBuf); - if ((len = (u32)pMem.n) != 0) - if (pMem.zBLOB == null && String.IsNullOrEmpty(pMem.z)) { - } else if (pMem.zBLOB != null && ((pMem.flags & MEM_Blob) != 0 || pMem.z == null)) - Buffer.BlockCopy(pMem.zBLOB, 0, buf, offset, (int)len);//memcpy( buf, pMem.z, len ); - else - Buffer.BlockCopy(Encoding.UTF8.GetBytes(pMem.z), 0, buf, offset, (int)len);//memcpy( buf, pMem.z, len ); - if ((pMem.flags & MEM_Zero) != 0) { - len += (u32)pMem.u.nZero; - Debug.Assert(nBuf >= 0); - if (len > (u32)nBuf) { - len = (u32)nBuf; - } - Array.Clear(buf, offset + pMem.n, (int)(len - pMem.n));// memset( &buf[pMem.n], 0, len - pMem.n ); - } - return len; - } + } + else + { + v = (ulong)pMem.u.i; + } + len = i = sqlite3VdbeSerialTypeLen( serial_type ); + Debug.Assert( len <= (u32)nBuf ); + while ( i-- != 0 ) + { + buf[offset + i] = (u8)( v & 0xFF ); + v >>= 8; + } + return len; + } - /* NULL or constants 0 or 1 */ - return 0; + /* String or blob */ + if ( serial_type >= 12 ) + { + // TO DO -- PASS TESTS WITH THIS ON Debug.Assert( pMem.n + ( ( pMem.flags & MEM_Zero ) != 0 ? pMem.u.nZero : 0 ) == (int)sqlite3VdbeSerialTypeLen( serial_type ) ); + Debug.Assert( pMem.n <= nBuf ); + if ( ( len = (u32)pMem.n ) != 0 ) + if ( pMem.zBLOB == null && String.IsNullOrEmpty( pMem.z ) ) + { + } + else if ( pMem.zBLOB != null && (( pMem.flags & MEM_Blob ) != 0 || pMem.z == null )) + Buffer.BlockCopy( pMem.zBLOB, 0, buf, offset, (int)len );//memcpy( buf, pMem.z, len ); + else + Buffer.BlockCopy( Encoding.UTF8.GetBytes( pMem.z ), 0, buf, offset, (int)len );//memcpy( buf, pMem.z, len ); + if ( ( pMem.flags & MEM_Zero ) != 0 ) + { + len += (u32)pMem.u.nZero; + Debug.Assert( nBuf >= 0 ); + if ( len > (u32)nBuf ) + { + len = (u32)nBuf; + } + Array.Clear( buf, offset + pMem.n, (int)( len - pMem.n ) );// memset( &buf[pMem.n], 0, len - pMem.n ); } + return len; + } - /* - ** Deserialize the data blob pointed to by buf as serial type serial_type - ** and store the result in pMem. Return the number of bytes read. - */ - static u32 sqlite3VdbeSerialGet( - byte[] buf, /* Buffer to deserialize from */ - int offset, /* Offset into Buffer */ - u32 serial_type, /* Serial type to deserialize */ - Mem pMem /* Memory cell to write value into */ - ) { - switch (serial_type) { - case 10: /* Reserved for future use */ - case 11: /* Reserved for future use */ - case 0: { /* NULL */ - pMem.flags = MEM_Null; - pMem.n = 0; - pMem.z = null; - pMem.zBLOB = null; - break; - } - case 1: { /* 1-byte signed integer */ - pMem.u.i = (sbyte)buf[offset + 0]; - pMem.flags = MEM_Int; - return 1; - } - case 2: { /* 2-byte signed integer */ - pMem.u.i = (int)((((sbyte)buf[offset + 0]) << 8) | buf[offset + 1]); - pMem.flags = MEM_Int; - return 2; - } - case 3: { /* 3-byte signed integer */ - pMem.u.i = (int)((((sbyte)buf[offset + 0]) << 16) | (buf[offset + 1] << 8) | buf[offset + 2]); - pMem.flags = MEM_Int; - return 3; - } - case 4: { /* 4-byte signed integer */ - pMem.u.i = (int)(((sbyte)buf[offset + 0] << 24) | (buf[offset + 1] << 16) | (buf[offset + 2] << 8) | buf[offset + 3]); - pMem.flags = MEM_Int; - return 4; - } - case 5: { /* 6-byte signed integer */ - u64 x = (ulong)((((sbyte)buf[offset + 0]) << 8) | buf[offset + 1]); - u32 y = (u32)((buf[offset + 2] << 24) | (buf[offset + 3] << 16) | (buf[offset + 4] << 8) | buf[offset + 5]); - x = (x << 32) | y; - pMem.u.i = (i64)x; - pMem.flags = MEM_Int; - return 6; - } - case 6: /* 8-byte signed integer */ - case 7: { /* IEEE floating point */ - u64 x; - u32 y; + /* NULL or constants 0 or 1 */ + return 0; + } + + /* + ** Deserialize the data blob pointed to by buf as serial type serial_type + ** and store the result in pMem. Return the number of bytes read. + */ + static u32 sqlite3VdbeSerialGet( + byte[] buf, /* Buffer to deserialize from */ + int offset, /* Offset into Buffer */ + u32 serial_type, /* Serial type to deserialize */ + Mem pMem /* Memory cell to write value into */ + ) + { + switch ( serial_type ) + { + case 10: /* Reserved for future use */ + case 11: /* Reserved for future use */ + case 0: + { /* NULL */ + pMem.flags = MEM_Null; + pMem.n = 0; + pMem.z = null; + pMem.zBLOB = null; + break; + } + case 1: + { /* 1-byte signed integer */ + pMem.u.i = (sbyte)buf[offset + 0]; + pMem.flags = MEM_Int; + return 1; + } + case 2: + { /* 2-byte signed integer */ + pMem.u.i = (int)( ( ( (sbyte)buf[offset + 0] ) << 8 ) | buf[offset + 1] ); + pMem.flags = MEM_Int; + return 2; + } + case 3: + { /* 3-byte signed integer */ + pMem.u.i = (int)( ( ( (sbyte)buf[offset + 0] ) << 16 ) | ( buf[offset + 1] << 8 ) | buf[offset + 2] ); + pMem.flags = MEM_Int; + return 3; + } + case 4: + { /* 4-byte signed integer */ + pMem.u.i = (int)( ( (sbyte)buf[offset + 0] << 24 ) | ( buf[offset + 1] << 16 ) | ( buf[offset + 2] << 8 ) | buf[offset + 3] ); + pMem.flags = MEM_Int; + return 4; + } + case 5: + { /* 6-byte signed integer */ + u64 x = (ulong)( ( ( (sbyte)buf[offset + 0] ) << 8 ) | buf[offset + 1] ); + u32 y = (u32)( ( buf[offset + 2] << 24 ) | ( buf[offset + 3] << 16 ) | ( buf[offset + 4] << 8 ) | buf[offset + 5] ); + x = ( x << 32 ) | y; + pMem.u.i = (i64)x; + pMem.flags = MEM_Int; + return 6; + } + case 6: /* 8-byte signed integer */ + case 7: + { /* IEEE floating point */ + u64 x; + u32 y; #if !NDEBUG && !SQLITE_OMIT_FLOATING_POINT - /* Verify that integers and floating point values use the same - ** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is - ** defined that 64-bit floating point values really are mixed - ** endian. - */ - const u64 t1 = ((u64)0x3ff00000) << 32; - const double r1 = 1.0; - u64 t2 = t1; -#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT + /* Verify that integers and floating point values use the same +** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is +** defined that 64-bit floating point values really are mixed +** endian. +*/ + const u64 t1 = ( (u64)0x3ff00000 ) << 32; + const double r1 = 1.0; + u64 t2 = t1; +#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT swapMixedEndianFloat(t2); #endif - Debug.Assert(sizeof(double) == sizeof(u64) && memcmp(BitConverter.GetBytes(r1), BitConverter.GetBytes(t2), sizeof(double)) == 0);//Debug.Assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, t2, sizeof(r1))==0 ); + Debug.Assert( sizeof( double ) == sizeof( u64 ) && memcmp( BitConverter.GetBytes( r1 ), BitConverter.GetBytes( t2 ), sizeof( double ) ) == 0 );//Debug.Assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, t2, sizeof(r1))==0 ); #endif - x = (u64)((buf[offset + 0] << 24) | (buf[offset + 1] << 16) | (buf[offset + 2] << 8) | buf[offset + 3]); - y = (u32)((buf[offset + 4] << 24) | (buf[offset + 5] << 16) | (buf[offset + 6] << 8) | buf[offset + 7]); - x = (x << 32) | y; - if (serial_type == 6) { - pMem.u.i = (i64)x; - pMem.flags = MEM_Int; - } else { - Debug.Assert(sizeof(i64) == 8 && sizeof(double) == 8); -#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT + x = (u64)( ( buf[offset + 0] << 24 ) | ( buf[offset + 1] << 16 ) | ( buf[offset + 2] << 8 ) | buf[offset + 3] ); + y = (u32)( ( buf[offset + 4] << 24 ) | ( buf[offset + 5] << 16 ) | ( buf[offset + 6] << 8 ) | buf[offset + 7] ); + x = ( x << 32 ) | y; + if ( serial_type == 6 ) + { + pMem.u.i = (i64)x; + pMem.flags = MEM_Int; + } + else + { + Debug.Assert( sizeof( i64 ) == 8 && sizeof( double ) == 8 ); +#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT swapMixedEndianFloat(x); #endif #if WINDOWS_PHONE || WINDOWS_MOBILE pMem.r = BitConverter.ToDouble(BitConverter.GetBytes((long)x), 0); #else - pMem.r = BitConverter.Int64BitsToDouble((long)x);// memcpy(pMem.r, x, sizeof(x)) + pMem.r = BitConverter.Int64BitsToDouble( (long)x );// memcpy(pMem.r, x, sizeof(x)) #endif - pMem.flags = (u16)(sqlite3IsNaN(pMem.r) ? MEM_Null : MEM_Real); - } - return 8; - } - case 8: /* Integer 0 */ - case 9: { /* Integer 1 */ - pMem.u.i = serial_type - 8; - pMem.flags = MEM_Int; - return 0; - } - default: { - u32 len = (serial_type - 12) / 2; - pMem.n = (int)len; - pMem.xDel = null; - if ((serial_type & 0x01) != 0) { - pMem.flags = MEM_Str | MEM_Ephem; - if (len <= buf.Length - offset) { - pMem.z = Encoding.UTF8.GetString(buf, offset, (int)len);//memcpy( buf, pMem.z, len ); - pMem.n = pMem.z.Length; - } else { - pMem.z = ""; // Corrupted Data - pMem.n = 0; - } - pMem.zBLOB = null; - } else { - pMem.z = null; - pMem.zBLOB = sqlite3Malloc((int)len); - pMem.flags = MEM_Blob | MEM_Ephem; - if (len <= buf.Length - offset) { - Buffer.BlockCopy(buf, offset, pMem.zBLOB, 0, (int)len);//memcpy( buf, pMem.z, len ); - } else { - Buffer.BlockCopy(buf, offset, pMem.zBLOB, 0, buf.Length - offset - 1); - } - } - return len; - } + pMem.flags = (u16)( sqlite3IsNaN( pMem.r ) ? MEM_Null : MEM_Real ); } + return 8; + } + case 8: /* Integer 0 */ + case 9: + { /* Integer 1 */ + pMem.u.i = serial_type - 8; + pMem.flags = MEM_Int; return 0; - } + } + default: + { + u32 len = ( serial_type - 12 ) / 2; + pMem.n = (int)len; + pMem.xDel = null; + if ( ( serial_type & 0x01 ) != 0 ) + { + pMem.flags = MEM_Str | MEM_Ephem; + if ( len <= buf.Length - offset ) + { + pMem.z = Encoding.UTF8.GetString( buf, offset, (int)len );//memcpy( buf, pMem.z, len ); + pMem.n = pMem.z.Length; + } + else + { + pMem.z = ""; // Corrupted Data + pMem.n = 0; + } + pMem.zBLOB = null; + } + else + { + pMem.z = null; + pMem.zBLOB = sqlite3Malloc( (int)len ); + pMem.flags = MEM_Blob | MEM_Ephem; + if ( len <= buf.Length - offset ) + { + Buffer.BlockCopy( buf, offset, pMem.zBLOB, 0, (int)len );//memcpy( buf, pMem.z, len ); + } + else + { + Buffer.BlockCopy( buf, offset, pMem.zBLOB, 0, buf.Length - offset - 1 ); + } + } + return len; + } + } + return 0; + } - static int sqlite3VdbeSerialGet( - byte[] buf, /* Buffer to deserialize from */ - u32 serial_type, /* Serial type to deserialize */ - Mem pMem /* Memory cell to write value into */ - ) { - switch (serial_type) { - case 10: /* Reserved for future use */ - case 11: /* Reserved for future use */ - case 0: { /* NULL */ - pMem.flags = MEM_Null; - break; - } - case 1: { /* 1-byte signed integer */ - pMem.u.i = (sbyte)buf[0]; - pMem.flags = MEM_Int; - return 1; - } - case 2: { /* 2-byte signed integer */ - pMem.u.i = (int)(((buf[0]) << 8) | buf[1]); - pMem.flags = MEM_Int; - return 2; - } - case 3: { /* 3-byte signed integer */ - pMem.u.i = (int)(((buf[0]) << 16) | (buf[1] << 8) | buf[2]); - pMem.flags = MEM_Int; - return 3; - } - case 4: { /* 4-byte signed integer */ - pMem.u.i = (int)((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]); - pMem.flags = MEM_Int; - return 4; - } - case 5: { /* 6-byte signed integer */ - u64 x = (ulong)(((buf[0]) << 8) | buf[1]); - u32 y = (u32)((buf[2] << 24) | (buf[3] << 16) | (buf[4] << 8) | buf[5]); - x = (x << 32) | y; - pMem.u.i = (i64)x; - pMem.flags = MEM_Int; - return 6; - } - case 6: /* 8-byte signed integer */ - case 7: { /* IEEE floating point */ - u64 x; - u32 y; + static int sqlite3VdbeSerialGet( + byte[] buf, /* Buffer to deserialize from */ + u32 serial_type, /* Serial type to deserialize */ + Mem pMem /* Memory cell to write value into */ + ) + { + switch ( serial_type ) + { + case 10: /* Reserved for future use */ + case 11: /* Reserved for future use */ + case 0: + { /* NULL */ + pMem.flags = MEM_Null; + break; + } + case 1: + { /* 1-byte signed integer */ + pMem.u.i = (sbyte)buf[0]; + pMem.flags = MEM_Int; + return 1; + } + case 2: + { /* 2-byte signed integer */ + pMem.u.i = (int)( ( ( buf[0] ) << 8 ) | buf[1] ); + pMem.flags = MEM_Int; + return 2; + } + case 3: + { /* 3-byte signed integer */ + pMem.u.i = (int)( ( ( buf[0] ) << 16 ) | ( buf[1] << 8 ) | buf[2] ); + pMem.flags = MEM_Int; + return 3; + } + case 4: + { /* 4-byte signed integer */ + pMem.u.i = (int)( ( buf[0] << 24 ) | ( buf[1] << 16 ) | ( buf[2] << 8 ) | buf[3] ); + pMem.flags = MEM_Int; + return 4; + } + case 5: + { /* 6-byte signed integer */ + u64 x = (ulong)( ( ( buf[0] ) << 8 ) | buf[1] ); + u32 y = (u32)( ( buf[2] << 24 ) | ( buf[3] << 16 ) | ( buf[4] << 8 ) | buf[5] ); + x = ( x << 32 ) | y; + pMem.u.i = (i64)x; + pMem.flags = MEM_Int; + return 6; + } + case 6: /* 8-byte signed integer */ + case 7: + { /* IEEE floating point */ + u64 x; + u32 y; #if !NDEBUG && !SQLITE_OMIT_FLOATING_POINT - /* Verify that integers and floating point values use the same - ** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is - ** defined that 64-bit floating point values really are mixed - ** endian. - */ - const u64 t1 = ((u64)0x3ff00000) << 32; - const double r1 = 1.0; - u64 t2 = t1; -#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT + /* Verify that integers and floating point values use the same +** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is +** defined that 64-bit floating point values really are mixed +** endian. +*/ + const u64 t1 = ( (u64)0x3ff00000 ) << 32; + const double r1 = 1.0; + u64 t2 = t1; +#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT swapMixedEndianFloat(t2); #endif - Debug.Assert(sizeof(double) == sizeof(u64) && memcmp(BitConverter.GetBytes(r1), BitConverter.GetBytes(t2), sizeof(double)) == 0);//Debug.Assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, t2, sizeof(r1))==0 ); + Debug.Assert( sizeof( double ) == sizeof( u64 ) && memcmp( BitConverter.GetBytes( r1 ), BitConverter.GetBytes( t2 ), sizeof( double ) ) == 0 );//Debug.Assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, t2, sizeof(r1))==0 ); #endif - x = (u64)((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]); - y = (u32)((buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7]); - x = (x << 32) | y; - if (serial_type == 6) { - pMem.u.i = (i64)x; - pMem.flags = MEM_Int; - } else { - Debug.Assert(sizeof(i64) == 8 && sizeof(double) == 8); -#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT + x = (u64)( ( buf[0] << 24 ) | ( buf[1] << 16 ) | ( buf[2] << 8 ) | buf[3] ); + y = (u32)( ( buf[4] << 24 ) | ( buf[5] << 16 ) | ( buf[6] << 8 ) | buf[7] ); + x = ( x << 32 ) | y; + if ( serial_type == 6 ) + { + pMem.u.i = (i64)x; + pMem.flags = MEM_Int; + } + else + { + Debug.Assert( sizeof( i64 ) == 8 && sizeof( double ) == 8 ); +#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT swapMixedEndianFloat(x); #endif #if WINDOWS_PHONE || WINDOWS_MOBILE pMem.r = BitConverter.ToDouble(BitConverter.GetBytes((long)x), 0); #else - pMem.r = BitConverter.Int64BitsToDouble((long)x);// memcpy(pMem.r, x, sizeof(x)) + pMem.r = BitConverter.Int64BitsToDouble( (long)x );// memcpy(pMem.r, x, sizeof(x)) #endif - pMem.flags = MEM_Real; - } - return 8; - } - case 8: /* Integer 0 */ - case 9: { /* Integer 1 */ - pMem.u.i = serial_type - 8; - pMem.flags = MEM_Int; - return 0; - } - default: { - int len = (int)((serial_type - 12) / 2); - pMem.xDel = null; - if ((serial_type & 0x01) != 0) { - pMem.flags = MEM_Str | MEM_Ephem; - pMem.z = Encoding.UTF8.GetString(buf, 0, len);//memcpy( buf, pMem.z, len ); - pMem.n = pMem.z.Length;// len; - pMem.zBLOB = null; - } else { - pMem.flags = MEM_Blob | MEM_Ephem; - pMem.zBLOB = sqlite3Malloc(len); - buf.CopyTo(pMem.zBLOB, 0); - pMem.n = len;// len; - pMem.z = null; - } - return len; - } + pMem.flags = MEM_Real; } + return 8; + } + case 8: /* Integer 0 */ + case 9: + { /* Integer 1 */ + pMem.u.i = serial_type - 8; + pMem.flags = MEM_Int; return 0; - } - - /* - ** Given the nKey-byte encoding of a record in pKey[], parse the - ** record into a UnpackedRecord structure. Return a pointer to - ** that structure. - ** - ** The calling function might provide szSpace bytes of memory - ** space at pSpace. This space can be used to hold the returned - ** VDbeParsedRecord structure if it is large enough. If it is - ** not big enough, space is obtained from sqlite3Malloc(). - ** - ** The returned structure should be closed by a call to - ** sqlite3VdbeDeleteUnpackedRecord(). - */ - static UnpackedRecord sqlite3VdbeRecordUnpack( - KeyInfo pKeyInfo, /* Information about the record format */ - int nKey, /* Size of the binary record */ - byte[] pKey, /* The binary record */ - UnpackedRecord pSpace, // char *pSpace, /* Unaligned space available to hold the object */ - int szSpace /* Size of pSpace[] in bytes */ - ) { - byte[] aKey = pKey; - UnpackedRecord p; /* The unpacked record that we will return */ - int nByte; /* Memory space needed to hold p, in bytes */ - int d; - u32 idx; - int u; /* Unsigned loop counter */ - int szHdr = 0; - Mem pMem; - int nOff; /* Increase pSpace by this much to 8-byte align it */ - - /* - ** We want to shift the pointer pSpace up such that it is 8-byte aligned. - ** Thus, we need to calculate a value, nOff, between 0 and 7, to shift - ** it by. If pSpace is already 8-byte aligned, nOff should be zero. - */ - //nOff = ( 8 - ( SQLITE_PTR_TO_INT( pSpace ) & 7 ) ) & 7; - //pSpace += nOff; - //szSpace -= nOff; - //nByte = ROUND8( sizeof( UnpackedRecord ) ) + sizeof( Mem ) * ( pKeyInfo->nField + 1 ); - //if ( nByte > szSpace) - //{ - //var p = new UnpackedRecord();//sqlite3DbMallocRaw(pKeyInfo.db, nByte); - // if ( p == null ) return null; - // p.flags = UNPACKED_NEED_FREE | UNPACKED_NEED_DESTROY; - //} - //else + } + default: + { + int len = (int)( ( serial_type - 12 ) / 2 ); + pMem.xDel = null; + if ( ( serial_type & 0x01 ) != 0 ) { - p = pSpace;//(UnpackedRecord)pSpace; - p.flags = UNPACKED_NEED_DESTROY; + pMem.flags = MEM_Str | MEM_Ephem; + pMem.z = Encoding.UTF8.GetString( buf, 0, len );//memcpy( buf, pMem.z, len ); + pMem.n = pMem.z.Length;// len; + pMem.zBLOB = null; } - p.pKeyInfo = pKeyInfo; - p.nField = (u16)(pKeyInfo.nField + 1); - //p->aMem = pMem = (Mem)&( (char)p )[ROUND8( sizeof( UnpackedRecord ) )]; - //Debug.Assert( EIGHT_BYTE_ALIGNMENT( pMem ) ); - p.aMem = new Mem[p.nField + 1]; - idx = (u32)getVarint32(aKey, 0, out szHdr);// GetVarint( aKey, szHdr ); - d = (int)szHdr; - u = 0; - while (idx < (int)szHdr && u < p.nField && d <= nKey) { - p.aMem[u] = sqlite3Malloc(p.aMem[u]); - pMem = p.aMem[u]; - u32 serial_type = 0; - - idx += (u32)getVarint32(aKey, idx, out serial_type);// GetVarint( aKey + idx, serial_type ); - pMem.enc = pKeyInfo.enc; - pMem.db = pKeyInfo.db; - /* pMem->flags = 0; // sqlite3VdbeSerialGet() will set this for us */ - //pMem.zMalloc = null; - d += (int)sqlite3VdbeSerialGet(aKey, d, serial_type, pMem); - //pMem++; - u++; + else + { + pMem.flags = MEM_Blob | MEM_Ephem; + pMem.zBLOB = sqlite3Malloc( len ); + buf.CopyTo( pMem.zBLOB, 0 ); + pMem.n = len;// len; + pMem.z = null; } - Debug.Assert(u <= pKeyInfo.nField + 1); - p.nField = (u16)u; - return p;// (void)p; - } + return len; + } + } + return 0; + } - /* - ** This routine destroys a UnpackedRecord object. - */ - static void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord p) { + /* + ** Given the nKey-byte encoding of a record in pKey[], parse the + ** record into a UnpackedRecord structure. Return a pointer to + ** that structure. + ** + ** The calling function might provide szSpace bytes of memory + ** space at pSpace. This space can be used to hold the returned + ** VDbeParsedRecord structure if it is large enough. If it is + ** not big enough, space is obtained from sqlite3Malloc(). + ** + ** The returned structure should be closed by a call to + ** sqlite3VdbeDeleteUnpackedRecord(). + */ + static UnpackedRecord sqlite3VdbeRecordUnpack( + KeyInfo pKeyInfo, /* Information about the record format */ + int nKey, /* Size of the binary record */ + byte[] pKey, /* The binary record */ + UnpackedRecord pSpace, // char *pSpace, /* Unaligned space available to hold the object */ + int szSpace /* Size of pSpace[] in bytes */ + ) + { + byte[] aKey = pKey; + UnpackedRecord p; /* The unpacked record that we will return */ + int nByte; /* Memory space needed to hold p, in bytes */ + int d; + u32 idx; + int u; /* Unsigned loop counter */ + int szHdr = 0; + Mem pMem; + int nOff; /* Increase pSpace by this much to 8-byte align it */ + + /* + ** We want to shift the pointer pSpace up such that it is 8-byte aligned. + ** Thus, we need to calculate a value, nOff, between 0 and 7, to shift + ** it by. If pSpace is already 8-byte aligned, nOff should be zero. + */ + //nOff = ( 8 - ( SQLITE_PTR_TO_INT( pSpace ) & 7 ) ) & 7; + //pSpace += nOff; + //szSpace -= nOff; + //nByte = ROUND8( sizeof( UnpackedRecord ) ) + sizeof( Mem ) * ( pKeyInfo->nField + 1 ); + //if ( nByte > szSpace) + //{ + //var p = new UnpackedRecord();//sqlite3DbMallocRaw(pKeyInfo.db, nByte); + // if ( p == null ) return null; + // p.flags = UNPACKED_NEED_FREE | UNPACKED_NEED_DESTROY; + //} + //else + { + p = pSpace;//(UnpackedRecord)pSpace; + p.flags = UNPACKED_NEED_DESTROY; + } + p.pKeyInfo = pKeyInfo; + p.nField = (u16)( pKeyInfo.nField + 1 ); + //p->aMem = pMem = (Mem)&( (char)p )[ROUND8( sizeof( UnpackedRecord ) )]; + //Debug.Assert( EIGHT_BYTE_ALIGNMENT( pMem ) ); + p.aMem = new Mem[p.nField + 1]; + idx = (u32)getVarint32( aKey, 0, out szHdr );// GetVarint( aKey, szHdr ); + d = (int)szHdr; + u = 0; + while ( idx < (int)szHdr && u < p.nField && d <= nKey ) + { + p.aMem[u] = sqlite3Malloc( p.aMem[u] ); + pMem = p.aMem[u]; + u32 serial_type = 0; + + idx += (u32)getVarint32( aKey, idx, out serial_type );// GetVarint( aKey + idx, serial_type ); + pMem.enc = pKeyInfo.enc; + pMem.db = pKeyInfo.db; + /* pMem->flags = 0; // sqlite3VdbeSerialGet() will set this for us */ + //pMem.zMalloc = null; + d += (int)sqlite3VdbeSerialGet( aKey, d, serial_type, pMem ); + //pMem++; + u++; + } + Debug.Assert( u <= pKeyInfo.nField + 1 ); + p.nField = (u16)u; + return p;// (void)p; + } + + /* + ** This routine destroys a UnpackedRecord object. + */ + static void sqlite3VdbeDeleteUnpackedRecord( UnpackedRecord p ) + { #if SQLITE_DEBUG - int i; - Mem pMem; - Debug.Assert(p != null); - Debug.Assert((p.flags & UNPACKED_NEED_DESTROY) != 0); - //for ( i = 0, pMem = p->aMem ; i < p->nField ; i++, pMem++ ) - //{ - // /* The unpacked record is always constructed by the - // ** sqlite3VdbeUnpackRecord() function above, which makes all - // ** strings and blobs static. And none of the elements are - // ** ever transformed, so there is never anything to delete. - // */ - // if ( NEVER( pMem->zMalloc ) ) sqlite3VdbeMemRelease( pMem ); - //} + int i; + Mem pMem; + Debug.Assert( p != null ); + Debug.Assert( ( p.flags & UNPACKED_NEED_DESTROY ) != 0 ); + //for ( i = 0, pMem = p->aMem ; i < p->nField ; i++, pMem++ ) + //{ + // /* The unpacked record is always constructed by the + // ** sqlite3VdbeUnpackRecord() function above, which makes all + // ** strings and blobs static. And none of the elements are + // ** ever transformed, so there is never anything to delete. + // */ + // if ( NEVER( pMem->zMalloc ) ) sqlite3VdbeMemRelease( pMem ); + //} #endif - if ((p.flags & UNPACKED_NEED_FREE) != 0) { - sqlite3DbFree(p.pKeyInfo.db, ref p.aMem); - p = null; - } - } - - /* - ** This function compares the two table rows or index records - ** specified by {nKey1, pKey1} and pPKey2. It returns a negative, zero - ** or positive integer if key1 is less than, equal to or - ** greater than key2. The {nKey1, pKey1} key must be a blob - ** created by th OP_MakeRecord opcode of the VDBE. The pPKey2 - ** key must be a parsed key such as obtained from - ** sqlite3VdbeParseRecord. - ** - ** Key1 and Key2 do not have to contain the same number of fields. - ** The key with fewer fields is usually compares less than the - ** longer key. However if the UNPACKED_INCRKEY flags in pPKey2 is set - ** and the common prefixes are equal, then key1 is less than key2. - ** Or if the UNPACKED_MATCH_PREFIX flag is set and the prefixes are - ** equal, then the keys are considered to be equal and - ** the parts beyond the common prefix are ignored. - ** - ** If the UNPACKED_IGNORE_ROWID flag is set, then the last byte of - ** the header of pKey1 is ignored. It is assumed that pKey1 is - ** an index key, and thus ends with a rowid value. The last byte - ** of the header will therefore be the serial type of the rowid: - ** one of 1, 2, 3, 4, 5, 6, 8, or 9 - the integer serial types. - ** The serial type of the final rowid will always be a single byte. - ** By ignoring this last byte of the header, we force the comparison - ** to ignore the rowid at the end of key1. - */ + if ( ( p.flags & UNPACKED_NEED_FREE ) != 0 ) + { + sqlite3DbFree( p.pKeyInfo.db, ref p.aMem ); + p = null; + } + } - static Mem mem1 = new Mem(); - // ALTERNATE FORM for C# - static int sqlite3VdbeRecordCompare( - int nKey1, byte[] pKey1, /* Left key */ - UnpackedRecord pPKey2 /* Right key */ - ) { - return sqlite3VdbeRecordCompare(nKey1, pKey1, 0, pPKey2); - } - - static int sqlite3VdbeRecordCompare( - int nKey1, byte[] pKey1, /* Left key */ - int offset, - UnpackedRecord pPKey2 /* Right key */ - ) { - int d1; /* Offset into aKey[] of next data element */ - u32 idx1; /* Offset into aKey[] of next header element */ - u32 szHdr1; /* Number of bytes in header */ - int i = 0; - int nField; - int rc = 0; - - //byte[] aKey1 = new byte[pKey1.Length - offset]; - //Buffer.BlockCopy( pKey1, offset, aKey1, 0, aKey1.Length ); - KeyInfo pKeyInfo; - - pKeyInfo = pPKey2.pKeyInfo; - mem1.enc = pKeyInfo.enc; - mem1.db = pKeyInfo.db; - /* mem1.flags = 0; // Will be initialized by sqlite3VdbeSerialGet() */ - // VVA_ONLY( mem1.zMalloc = 0; ) /* Only needed by Debug.Assert() statements */ - - /* Compilers may complain that mem1.u.i is potentially uninitialized. - ** We could initialize it, as shown here, to silence those complaints. - ** But in fact, mem1.u.i will never actually be used uninitialized, and doing - ** the unnecessary initialization has a measurable negative performance - ** impact, since this routine is a very high runner. And so, we choose - ** to ignore the compiler warnings and leave this variable uninitialized. - */ - /* mem1.u.i = 0; // not needed, here to silence compiler warning */ - - idx1 = (u32)((szHdr1 = pKey1[offset]) <= 0x7f ? 1 : getVarint32(pKey1, offset, out szHdr1));// GetVarint( aKey1, szHdr1 ); - d1 = (int)szHdr1; - if ((pPKey2.flags & UNPACKED_IGNORE_ROWID) != 0) { - szHdr1--; - } - nField = pKeyInfo.nField; - while (idx1 < szHdr1 && i < pPKey2.nField) { - u32 serial_type1; - - /* Read the serial types for the next element in each key. */ - idx1 += (u32)((serial_type1 = pKey1[offset + idx1]) <= 0x7f ? 1 : getVarint32(pKey1, (uint)(offset + idx1), out serial_type1)); //GetVarint( aKey1 + idx1, serial_type1 ); - if (d1 <= 0 || d1 >= nKey1 && sqlite3VdbeSerialTypeLen(serial_type1) > 0) - break; - - /* Extract the values to be compared. - */ - d1 += (int)sqlite3VdbeSerialGet(pKey1, offset + d1, serial_type1, mem1);//sqlite3VdbeSerialGet( aKey1, d1, serial_type1, mem1 ); - - /* Do the comparison - */ - rc = sqlite3MemCompare(mem1, pPKey2.aMem[i], i < nField ? pKeyInfo.aColl[i] : null); - if (rc != 0) { - //Debug.Assert( mem1.zMalloc==null ); /* See comment below */ - - /* Invert the result if we are using DESC sort order. */ - if (pKeyInfo.aSortOrder != null && i < nField && pKeyInfo.aSortOrder[i] != 0) { - rc = -rc; - } - - /* If the PREFIX_SEARCH flag is set and all fields except the final - ** rowid field were equal, then clear the PREFIX_SEARCH flag and set - ** pPKey2->rowid to the value of the rowid field in (pKey1, nKey1). - ** This is used by the OP_IsUnique opcode. - */ - if ((pPKey2.flags & UNPACKED_PREFIX_SEARCH) != 0 && i == (pPKey2.nField - 1)) { - Debug.Assert(idx1 == szHdr1 && rc != 0); - Debug.Assert((mem1.flags & MEM_Int) != 0); - pPKey2.flags = (ushort)(pPKey2.flags & ~UNPACKED_PREFIX_SEARCH); - pPKey2.rowid = mem1.u.i; - } - - return rc; - } - i++; - } + /* + ** This function compares the two table rows or index records + ** specified by {nKey1, pKey1} and pPKey2. It returns a negative, zero + ** or positive integer if key1 is less than, equal to or + ** greater than key2. The {nKey1, pKey1} key must be a blob + ** created by th OP_MakeRecord opcode of the VDBE. The pPKey2 + ** key must be a parsed key such as obtained from + ** sqlite3VdbeParseRecord. + ** + ** Key1 and Key2 do not have to contain the same number of fields. + ** The key with fewer fields is usually compares less than the + ** longer key. However if the UNPACKED_INCRKEY flags in pPKey2 is set + ** and the common prefixes are equal, then key1 is less than key2. + ** Or if the UNPACKED_MATCH_PREFIX flag is set and the prefixes are + ** equal, then the keys are considered to be equal and + ** the parts beyond the common prefix are ignored. + ** + ** If the UNPACKED_IGNORE_ROWID flag is set, then the last byte of + ** the header of pKey1 is ignored. It is assumed that pKey1 is + ** an index key, and thus ends with a rowid value. The last byte + ** of the header will therefore be the serial type of the rowid: + ** one of 1, 2, 3, 4, 5, 6, 8, or 9 - the integer serial types. + ** The serial type of the final rowid will always be a single byte. + ** By ignoring this last byte of the header, we force the comparison + ** to ignore the rowid at the end of key1. + */ - /* No memory allocation is ever used on mem1. Prove this using - ** the following Debug.Assert(). If the Debug.Assert() fails, it indicates a - ** memory leak and a need to call sqlite3VdbeMemRelease(&mem1). - */ - //Debug.Assert( mem1.zMalloc==null ); - - /* rc==0 here means that one of the keys ran out of fields and - ** all the fields up to that point were equal. If the UNPACKED_INCRKEY - ** flag is set, then break the tie by treating key2 as larger. - ** If the UPACKED_PREFIX_MATCH flag is set, then keys with common prefixes - ** are considered to be equal. Otherwise, the longer key is the - ** larger. As it happens, the pPKey2 will always be the longer - ** if there is a difference. - */ - Debug.Assert(rc == 0); - if ((pPKey2.flags & UNPACKED_INCRKEY) != 0) { - rc = -1; - } else if ((pPKey2.flags & UNPACKED_PREFIX_MATCH) != 0) { - /* Leave rc==0 */ - } else if (idx1 < szHdr1) { - rc = 1; - } - return rc; - } + static Mem mem1 = new Mem(); + // ALTERNATE FORM for C# + static int sqlite3VdbeRecordCompare( + int nKey1, byte[] pKey1, /* Left key */ + UnpackedRecord pPKey2 /* Right key */ + ) + { + return sqlite3VdbeRecordCompare( nKey1, pKey1, 0, pPKey2 ); + } - /* - ** pCur points at an index entry created using the OP_MakeRecord opcode. - ** Read the rowid (the last field in the record) and store it in *rowid. - ** Return SQLITE_OK if everything works, or an error code otherwise. - ** - ** pCur might be pointing to text obtained from a corrupt database file. - ** So the content cannot be trusted. Do appropriate checks on the content. - */ - static int sqlite3VdbeIdxRowid(sqlite3 db, BtCursor pCur, ref i64 rowid) { - i64 nCellKey = 0; - int rc; - u32 szHdr = 0; /* Size of the header */ - u32 typeRowid = 0; /* Serial type of the rowid */ - u32 lenRowid; /* Size of the rowid */ - Mem m = null; - Mem v = null; - v = sqlite3Malloc(v); - UNUSED_PARAMETER(db); - - /* Get the size of the index entry. Only indices entries of less - ** than 2GiB are support - anything large must be database corruption. - ** Any corruption is detected in sqlite3BtreeParseCellPtr(), though, so - ** this code can safely assume that nCellKey is 32-bits - */ - Debug.Assert(sqlite3BtreeCursorIsValid(pCur)); - rc = sqlite3BtreeKeySize(pCur, ref nCellKey); - Debug.Assert(rc == SQLITE_OK); /* pCur is always valid so KeySize cannot fail */ - Debug.Assert(((u32)nCellKey & SQLITE_MAX_U32) == (u64)nCellKey); - - /* Read in the complete content of the index entry */ - m = sqlite3Malloc(m); - // memset(&m, 0, sizeof(m)); - rc = sqlite3VdbeMemFromBtree(pCur, 0, (int)nCellKey, true, m); - if (rc != 0) { - return rc; - } + static int sqlite3VdbeRecordCompare( + int nKey1, byte[] pKey1, /* Left key */ + int offset, + UnpackedRecord pPKey2 /* Right key */ + ) + { + int d1; /* Offset into aKey[] of next data element */ + u32 idx1; /* Offset into aKey[] of next header element */ + u32 szHdr1; /* Number of bytes in header */ + int i = 0; + int nField; + int rc = 0; + + //byte[] aKey1 = new byte[pKey1.Length - offset]; + //Buffer.BlockCopy( pKey1, offset, aKey1, 0, aKey1.Length ); + KeyInfo pKeyInfo; + + pKeyInfo = pPKey2.pKeyInfo; + mem1.enc = pKeyInfo.enc; + mem1.db = pKeyInfo.db; + /* mem1.flags = 0; // Will be initialized by sqlite3VdbeSerialGet() */ + // VVA_ONLY( mem1.zMalloc = 0; ) /* Only needed by Debug.Assert() statements */ + + /* Compilers may complain that mem1.u.i is potentially uninitialized. + ** We could initialize it, as shown here, to silence those complaints. + ** But in fact, mem1.u.i will never actually be used uninitialized, and doing + ** the unnecessary initialization has a measurable negative performance + ** impact, since this routine is a very high runner. And so, we choose + ** to ignore the compiler warnings and leave this variable uninitialized. + */ + /* mem1.u.i = 0; // not needed, here to silence compiler warning */ - /* The index entry must begin with a header size */ - getVarint32(m.zBLOB, 0, out szHdr); - testcase(szHdr == 3); - testcase(szHdr == m.n); - if (unlikely(szHdr < 3 || (int)szHdr > m.n)) { - goto idx_rowid_corruption; - } + idx1 = (u32)( ( szHdr1 = pKey1[offset] ) <= 0x7f ? 1 : getVarint32( pKey1, offset, out szHdr1 ) );// GetVarint( aKey1, szHdr1 ); + d1 = (int)szHdr1; + if ( ( pPKey2.flags & UNPACKED_IGNORE_ROWID ) != 0 ) + { + szHdr1--; + } + nField = pKeyInfo.nField; + while ( idx1 < szHdr1 && i < pPKey2.nField ) + { + u32 serial_type1; - /* The last field of the index should be an integer - the ROWID. - ** Verify that the last entry really is an integer. */ - getVarint32(m.zBLOB, szHdr - 1, out typeRowid); - testcase(typeRowid == 1); - testcase(typeRowid == 2); - testcase(typeRowid == 3); - testcase(typeRowid == 4); - testcase(typeRowid == 5); - testcase(typeRowid == 6); - testcase(typeRowid == 8); - testcase(typeRowid == 9); - if (unlikely(typeRowid < 1 || typeRowid > 9 || typeRowid == 7)) { - goto idx_rowid_corruption; - } - lenRowid = (u32)sqlite3VdbeSerialTypeLen(typeRowid); - testcase((u32)m.n == szHdr + lenRowid); - if (unlikely((u32)m.n < szHdr + lenRowid)) { - goto idx_rowid_corruption; - } + /* Read the serial types for the next element in each key. */ + idx1 += (u32)( ( serial_type1 = pKey1[offset + idx1] ) <= 0x7f ? 1 : getVarint32( pKey1, (uint)( offset + idx1 ), out serial_type1 ) ); //GetVarint( aKey1 + idx1, serial_type1 ); + if ( d1 <= 0 || d1 >= nKey1 && sqlite3VdbeSerialTypeLen( serial_type1 ) > 0 ) + break; - /* Fetch the integer off the end of the index record */ - sqlite3VdbeSerialGet(m.zBLOB, (int)(m.n - lenRowid), typeRowid, v); - rowid = v.u.i; - sqlite3VdbeMemRelease(m); - return SQLITE_OK; - - /* Jump here if database corruption is detected after m has been - ** allocated. Free the m object and return SQLITE_CORRUPT. */ - idx_rowid_corruption: - //testcase( m.zMalloc != 0 ); - sqlite3VdbeMemRelease(m); - return SQLITE_CORRUPT_BKPT(); - } - - /* - ** Compare the key of the index entry that cursor pC is pointing to against - ** the key string in pUnpacked. Write into *pRes a number - ** that is negative, zero, or positive if pC is less than, equal to, - ** or greater than pUnpacked. Return SQLITE_OK on success. - ** - ** pUnpacked is either created without a rowid or is truncated so that it - ** omits the rowid at the end. The rowid at the end of the index entry - ** is ignored as well. Hence, this routine only compares the prefixes - ** of the keys prior to the final rowid, not the entire key. + /* Extract the values to be compared. */ - static int sqlite3VdbeIdxKeyCompare( - VdbeCursor pC, /* The cursor to compare against */ - UnpackedRecord pUnpacked, /* Unpacked version of key to compare against */ - ref int res /* Write the comparison result here */ - ) { - i64 nCellKey = 0; - int rc; - BtCursor pCur = pC.pCursor; - Mem m = null; - - Debug.Assert(sqlite3BtreeCursorIsValid(pCur)); - rc = sqlite3BtreeKeySize(pCur, ref nCellKey); - Debug.Assert(rc == SQLITE_OK); /* pCur is always valid so KeySize cannot fail */ - /* nCellKey will always be between 0 and 0xffffffff because of the say - ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */ - if (nCellKey <= 0 || nCellKey > 0x7fffffff) { - res = 0; - return SQLITE_CORRUPT_BKPT(); - } - - m = sqlite3Malloc(m); - // memset(&m, 0, sizeof(m)); - rc = sqlite3VdbeMemFromBtree(pC.pCursor, 0, (int)nCellKey, true, m); - if (rc != 0) { - return rc; - } - Debug.Assert((pUnpacked.flags & UNPACKED_IGNORE_ROWID) != 0); - res = sqlite3VdbeRecordCompare(m.n, m.zBLOB, pUnpacked); - sqlite3VdbeMemRelease(m); - return SQLITE_OK; - } + d1 += (int)sqlite3VdbeSerialGet( pKey1, offset + d1, serial_type1, mem1 );//sqlite3VdbeSerialGet( aKey1, d1, serial_type1, mem1 ); - /* - ** This routine sets the value to be returned by subsequent calls to - ** sqlite3_changes() on the database handle 'db'. + /* Do the comparison */ - static void sqlite3VdbeSetChanges(sqlite3 db, int nChange) { - Debug.Assert(sqlite3_mutex_held(db.mutex)); - db.nChange = nChange; - db.nTotalChange += nChange; + rc = sqlite3MemCompare( mem1, pPKey2.aMem[i], i < nField ? pKeyInfo.aColl[i] : null ); + if ( rc != 0 ) + { + //Debug.Assert( mem1.zMalloc==null ); /* See comment below */ + + /* Invert the result if we are using DESC sort order. */ + if ( pKeyInfo.aSortOrder != null && i < nField && pKeyInfo.aSortOrder[i] != 0 ) + { + rc = -rc; + } + + /* If the PREFIX_SEARCH flag is set and all fields except the final + ** rowid field were equal, then clear the PREFIX_SEARCH flag and set + ** pPKey2->rowid to the value of the rowid field in (pKey1, nKey1). + ** This is used by the OP_IsUnique opcode. + */ + if ( ( pPKey2.flags & UNPACKED_PREFIX_SEARCH ) != 0 && i == ( pPKey2.nField - 1 ) ) + { + Debug.Assert( idx1 == szHdr1 && rc != 0 ); + Debug.Assert( ( mem1.flags & MEM_Int ) != 0 ); + pPKey2.flags = (ushort)( pPKey2.flags & ~UNPACKED_PREFIX_SEARCH ); + pPKey2.rowid = mem1.u.i; + } + + return rc; } + i++; + } - /* - ** Set a flag in the vdbe to update the change counter when it is finalised - ** or reset. - */ - static void sqlite3VdbeCountChanges(Vdbe v) { - v.changeCntOn = true; - } + /* No memory allocation is ever used on mem1. Prove this using + ** the following Debug.Assert(). If the Debug.Assert() fails, it indicates a + ** memory leak and a need to call sqlite3VdbeMemRelease(&mem1). + */ + //Debug.Assert( mem1.zMalloc==null ); + + /* rc==0 here means that one of the keys ran out of fields and + ** all the fields up to that point were equal. If the UNPACKED_INCRKEY + ** flag is set, then break the tie by treating key2 as larger. + ** If the UPACKED_PREFIX_MATCH flag is set, then keys with common prefixes + ** are considered to be equal. Otherwise, the longer key is the + ** larger. As it happens, the pPKey2 will always be the longer + ** if there is a difference. + */ + Debug.Assert( rc == 0 ); + if ( ( pPKey2.flags & UNPACKED_INCRKEY ) != 0 ) + { + rc = -1; + } + else if ( ( pPKey2.flags & UNPACKED_PREFIX_MATCH ) != 0 ) + { + /* Leave rc==0 */ + } + else if ( idx1 < szHdr1 ) + { + rc = 1; + } + return rc; + } - /* - ** Mark every prepared statement associated with a database connection - ** as expired. - ** - ** An expired statement means that recompilation of the statement is - ** recommend. Statements expire when things happen that make their - ** programs obsolete. Removing user-defined functions or collating - ** sequences, or changing an authorization function are the types of - ** things that make prepared statements obsolete. - */ - static void sqlite3ExpirePreparedStatements(sqlite3 db) { - Vdbe p; - for (p = db.pVdbe; p != null; p = p.pNext) { - p.expired = true; - } - } + /* + ** pCur points at an index entry created using the OP_MakeRecord opcode. + ** Read the rowid (the last field in the record) and store it in *rowid. + ** Return SQLITE_OK if everything works, or an error code otherwise. + ** + ** pCur might be pointing to text obtained from a corrupt database file. + ** So the content cannot be trusted. Do appropriate checks on the content. + */ + static int sqlite3VdbeIdxRowid( sqlite3 db, BtCursor pCur, ref i64 rowid ) + { + i64 nCellKey = 0; + int rc; + u32 szHdr = 0; /* Size of the header */ + u32 typeRowid = 0; /* Serial type of the rowid */ + u32 lenRowid; /* Size of the rowid */ + Mem m = null; + Mem v = null; + v = sqlite3Malloc( v ); + UNUSED_PARAMETER( db ); + + /* Get the size of the index entry. Only indices entries of less + ** than 2GiB are support - anything large must be database corruption. + ** Any corruption is detected in sqlite3BtreeParseCellPtr(), though, so + ** this code can safely assume that nCellKey is 32-bits + */ + Debug.Assert( sqlite3BtreeCursorIsValid( pCur ) ); + rc = sqlite3BtreeKeySize( pCur, ref nCellKey ); + Debug.Assert( rc == SQLITE_OK ); /* pCur is always valid so KeySize cannot fail */ + Debug.Assert( ( (u32)nCellKey & SQLITE_MAX_U32 ) == (u64)nCellKey ); + + /* Read in the complete content of the index entry */ + m = sqlite3Malloc( m ); + // memset(&m, 0, sizeof(m)); + rc = sqlite3VdbeMemFromBtree( pCur, 0, (int)nCellKey, true, m ); + if ( rc != 0 ) + { + return rc; + } - /* - ** Return the database associated with the Vdbe. - */ - static sqlite3 sqlite3VdbeDb(Vdbe v) { - return v.db; - } - /* - ** Return a pointer to an sqlite3_value structure containing the value bound - ** parameter iVar of VM v. Except, if the value is an SQL NULL, return - ** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_* - ** constants) to the value before returning it. - ** - ** The returned value must be freed by the caller using sqlite3ValueFree(). - */ - static sqlite3_value sqlite3VdbeGetValue(Vdbe v, int iVar, u8 aff) { - Debug.Assert(iVar > 0); - if (v != null) { - Mem pMem = v.aVar[iVar - 1]; - if (0 == (pMem.flags & MEM_Null)) { - sqlite3_value pRet = sqlite3ValueNew(v.db); - if (pRet != null) { - sqlite3VdbeMemCopy((Mem)pRet, pMem); - sqlite3ValueApplyAffinity(pRet, (char)aff, SQLITE_UTF8); - sqlite3VdbeMemStoreType((Mem)pRet); - } - return pRet; - } - } - return null; - } + /* The index entry must begin with a header size */ + getVarint32( m.zBLOB, 0, out szHdr ); + testcase( szHdr == 3 ); + testcase( szHdr == m.n ); + if ( unlikely( szHdr < 3 || (int)szHdr > m.n ) ) + { + goto idx_rowid_corruption; + } - /* - ** Configure SQL variable iVar so that binding a new value to it signals - ** to sqlite3_reoptimize() that re-preparing the statement may result - ** in a better query plan. - */ - static void sqlite3VdbeSetVarmask(Vdbe v, int iVar) { - Debug.Assert(iVar > 0); - if (iVar > 32) { - v.expmask = 0xffffffff; - } else { - v.expmask |= ((u32)1 << (iVar - 1)); - } + /* The last field of the index should be an integer - the ROWID. + ** Verify that the last entry really is an integer. */ + getVarint32( m.zBLOB, szHdr - 1, out typeRowid ); + testcase( typeRowid == 1 ); + testcase( typeRowid == 2 ); + testcase( typeRowid == 3 ); + testcase( typeRowid == 4 ); + testcase( typeRowid == 5 ); + testcase( typeRowid == 6 ); + testcase( typeRowid == 8 ); + testcase( typeRowid == 9 ); + if ( unlikely( typeRowid < 1 || typeRowid > 9 || typeRowid == 7 ) ) + { + goto idx_rowid_corruption; + } + lenRowid = (u32)sqlite3VdbeSerialTypeLen( typeRowid ); + testcase( (u32)m.n == szHdr + lenRowid ); + if ( unlikely( (u32)m.n < szHdr + lenRowid ) ) + { + goto idx_rowid_corruption; + } + + /* Fetch the integer off the end of the index record */ + sqlite3VdbeSerialGet( m.zBLOB, (int)( m.n - lenRowid ), typeRowid, v ); + rowid = v.u.i; + sqlite3VdbeMemRelease( m ); + return SQLITE_OK; + + /* Jump here if database corruption is detected after m has been + ** allocated. Free the m object and return SQLITE_CORRUPT. */ +idx_rowid_corruption: + //testcase( m.zMalloc != 0 ); + sqlite3VdbeMemRelease( m ); + return SQLITE_CORRUPT_BKPT(); + } + + /* + ** Compare the key of the index entry that cursor pC is pointing to against + ** the key string in pUnpacked. Write into *pRes a number + ** that is negative, zero, or positive if pC is less than, equal to, + ** or greater than pUnpacked. Return SQLITE_OK on success. + ** + ** pUnpacked is either created without a rowid or is truncated so that it + ** omits the rowid at the end. The rowid at the end of the index entry + ** is ignored as well. Hence, this routine only compares the prefixes + ** of the keys prior to the final rowid, not the entire key. + */ + static int sqlite3VdbeIdxKeyCompare( + VdbeCursor pC, /* The cursor to compare against */ + UnpackedRecord pUnpacked, /* Unpacked version of key to compare against */ + ref int res /* Write the comparison result here */ + ) + { + i64 nCellKey = 0; + int rc; + BtCursor pCur = pC.pCursor; + Mem m = null; + + Debug.Assert( sqlite3BtreeCursorIsValid( pCur ) ); + rc = sqlite3BtreeKeySize( pCur, ref nCellKey ); + Debug.Assert( rc == SQLITE_OK ); /* pCur is always valid so KeySize cannot fail */ + /* nCellKey will always be between 0 and 0xffffffff because of the say + ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */ + if ( nCellKey <= 0 || nCellKey > 0x7fffffff ) + { + res = 0; + return SQLITE_CORRUPT_BKPT(); + } + + m = sqlite3Malloc( m ); + // memset(&m, 0, sizeof(m)); + rc = sqlite3VdbeMemFromBtree( pC.pCursor, 0, (int)nCellKey, true, m ); + if ( rc != 0 ) + { + return rc; + } + Debug.Assert( ( pUnpacked.flags & UNPACKED_IGNORE_ROWID ) != 0 ); + res = sqlite3VdbeRecordCompare( m.n, m.zBLOB, pUnpacked ); + sqlite3VdbeMemRelease( m ); + return SQLITE_OK; + } + + /* + ** This routine sets the value to be returned by subsequent calls to + ** sqlite3_changes() on the database handle 'db'. + */ + static void sqlite3VdbeSetChanges( sqlite3 db, int nChange ) + { + Debug.Assert( sqlite3_mutex_held( db.mutex ) ); + db.nChange = nChange; + db.nTotalChange += nChange; + } + + /* + ** Set a flag in the vdbe to update the change counter when it is finalised + ** or reset. + */ + static void sqlite3VdbeCountChanges( Vdbe v ) + { + v.changeCntOn = true; + } + + /* + ** Mark every prepared statement associated with a database connection + ** as expired. + ** + ** An expired statement means that recompilation of the statement is + ** recommend. Statements expire when things happen that make their + ** programs obsolete. Removing user-defined functions or collating + ** sequences, or changing an authorization function are the types of + ** things that make prepared statements obsolete. + */ + static void sqlite3ExpirePreparedStatements( sqlite3 db ) + { + Vdbe p; + for ( p = db.pVdbe; p != null; p = p.pNext ) + { + p.expired = true; + } + } + + /* + ** Return the database associated with the Vdbe. + */ + static sqlite3 sqlite3VdbeDb( Vdbe v ) + { + return v.db; + } + /* + ** Return a pointer to an sqlite3_value structure containing the value bound + ** parameter iVar of VM v. Except, if the value is an SQL NULL, return + ** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_* + ** constants) to the value before returning it. + ** + ** The returned value must be freed by the caller using sqlite3ValueFree(). + */ + static sqlite3_value sqlite3VdbeGetValue( Vdbe v, int iVar, u8 aff ) + { + Debug.Assert( iVar > 0 ); + if ( v != null ) + { + Mem pMem = v.aVar[iVar - 1]; + if ( 0 == ( pMem.flags & MEM_Null ) ) + { + sqlite3_value pRet = sqlite3ValueNew( v.db ); + if ( pRet != null ) + { + sqlite3VdbeMemCopy( (Mem)pRet, pMem ); + sqlite3ValueApplyAffinity( pRet, (char)aff, SQLITE_UTF8 ); + sqlite3VdbeMemStoreType( (Mem)pRet ); + } + return pRet; } + } + return null; + } + + /* + ** Configure SQL variable iVar so that binding a new value to it signals + ** to sqlite3_reoptimize() that re-preparing the statement may result + ** in a better query plan. + */ + static void sqlite3VdbeSetVarmask( Vdbe v, int iVar ) + { + Debug.Assert( iVar > 0 ); + if ( iVar > 32 ) + { + v.expmask = 0xffffffff; + } + else + { + v.expmask |= ( (u32)1 << ( iVar - 1 ) ); + } } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/vdbeblob_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/vdbeblob_c.cs index 33abe5c6a..0e6f7abb6 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/vdbeblob_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/vdbeblob_c.cs @@ -1,28 +1,34 @@ -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2007 May 1 - ** - ** 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 contains code used to implement incremental BLOB I/O. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include "vdbeInt.h" +using System.Diagnostics; + +namespace Community.CsharpSqlite +{ + using sqlite3_stmt = Sqlite3.Vdbe; + + public partial class Sqlite3 + { + /* + ** 2007 May 1 + ** + ** 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 contains code used to implement incremental BLOB I/O. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include "vdbeInt.h" #if !SQLITE_OMIT_INCRBLOB /* @@ -393,5 +399,5 @@ int sqlite3_blob_bytes(sqlite3_blob *pBlob){ } #endif // * #if !SQLITE_OMIT_INCRBLOB */ - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/vdbemem_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/vdbemem_c.cs index 280460dce..e95b8cfd3 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/vdbemem_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/vdbemem_c.cs @@ -3,79 +3,83 @@ using System.Text; using i64 = System.Int64; +using u8 = System.Byte; using u16 = System.UInt16; using u32 = System.UInt32; -using u8 = System.Byte; -namespace Community.CsharpSqlite { - using System.Globalization; - - using sqlite3_value = Sqlite3.Mem; - - public partial class Sqlite3 { - /* - ** 2004 May 26 - ** - ** 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 contains code use to manipulate "Mem" structure. A "Mem" - ** stores a single value in the VDBE. Mem is an opaque structure visible - ** only within the VDBE. Interface routines refer to a Mem using the - ** name sqlite_value - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include "vdbeInt.h" +namespace Community.CsharpSqlite +{ + using sqlite3_value = Sqlite3.Mem; + using System.Globalization; - /* - ** Call sqlite3VdbeMemExpandBlob() on the supplied value (type Mem*) - ** P if required. - */ - //#define expandBlob(P) (((P)->flags&MEM_Zero)?sqlite3VdbeMemExpandBlob(P):0) - static void expandBlob(Mem P) { - if ((P.flags & MEM_Zero) != 0) - sqlite3VdbeMemExpandBlob(P); - } // TODO -- Convert to inline for speed - - /* - ** If pMem is an object with a valid string representation, this routine - ** ensures the internal encoding for the string representation is - ** 'desiredEnc', one of SQLITE_UTF8, SQLITE_UTF16LE or SQLITE_UTF16BE. - ** - ** If pMem is not a string object, or the encoding of the string - ** representation is already stored using the requested encoding, then this - ** routine is a no-op. - ** - ** SQLITE_OK is returned if the conversion is successful (or not required). - ** SQLITE_NOMEM may be returned if a malloc() fails during conversion - ** between formats. - */ - static int sqlite3VdbeChangeEncoding(Mem pMem, int desiredEnc) { - int rc; - Debug.Assert((pMem.flags & MEM_RowSet) == 0); - Debug.Assert(desiredEnc == SQLITE_UTF8 || desiredEnc == SQLITE_UTF16LE - || desiredEnc == SQLITE_UTF16BE); - if ((pMem.flags & MEM_Str) == 0 || pMem.enc == desiredEnc) { - if (String.IsNullOrEmpty(pMem.z) && pMem.zBLOB != null) - pMem.z = Encoding.UTF8.GetString(pMem.zBLOB, 0, pMem.zBLOB.Length); - return SQLITE_OK; - } - Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); -#if SQLITE_OMIT_UTF16 - return SQLITE_ERROR; + public partial class Sqlite3 + { + /* + ** 2004 May 26 + ** + ** 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 contains code use to manipulate "Mem" structure. A "Mem" + ** stores a single value in the VDBE. Mem is an opaque structure visible + ** only within the VDBE. Interface routines refer to a Mem using the + ** name sqlite_value + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include "vdbeInt.h" + + /* + ** Call sqlite3VdbeMemExpandBlob() on the supplied value (type Mem*) + ** P if required. + */ + //#define expandBlob(P) (((P)->flags&MEM_Zero)?sqlite3VdbeMemExpandBlob(P):0) + static void expandBlob( Mem P ) + { + if ( ( P.flags & MEM_Zero ) != 0 ) + sqlite3VdbeMemExpandBlob( P ); + } // TODO -- Convert to inline for speed + + /* + ** If pMem is an object with a valid string representation, this routine + ** ensures the internal encoding for the string representation is + ** 'desiredEnc', one of SQLITE_UTF8, SQLITE_UTF16LE or SQLITE_UTF16BE. + ** + ** If pMem is not a string object, or the encoding of the string + ** representation is already stored using the requested encoding, then this + ** routine is a no-op. + ** + ** SQLITE_OK is returned if the conversion is successful (or not required). + ** SQLITE_NOMEM may be returned if a malloc() fails during conversion + ** between formats. + */ + static int sqlite3VdbeChangeEncoding( Mem pMem, int desiredEnc ) + { + int rc; + Debug.Assert( ( pMem.flags & MEM_RowSet ) == 0 ); + Debug.Assert( desiredEnc == SQLITE_UTF8 || desiredEnc == SQLITE_UTF16LE + || desiredEnc == SQLITE_UTF16BE ); + if ( ( pMem.flags & MEM_Str ) == 0 || pMem.enc == desiredEnc ) + { + if ( String.IsNullOrEmpty( pMem.z ) && pMem.zBLOB != null ) + pMem.z = Encoding.UTF8.GetString( pMem.zBLOB, 0, pMem.zBLOB.Length ); + return SQLITE_OK; + } + Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); +#if SQLITE_OMIT_UTF16 + return SQLITE_ERROR; #else /* MemTranslate() may return SQLITE_OK or SQLITE_NOMEM. If NOMEM is returned, @@ -87,97 +91,106 @@ static int sqlite3VdbeChangeEncoding(Mem pMem, int desiredEnc) { Debug.Assert(rc==SQLITE_NOMEM || pMem.enc==desiredEnc); return rc; #endif - } + } - /* - ** Make sure pMem.z points to a writable allocation of at least - ** n bytes. - ** - ** If the memory cell currently contains string or blob data - ** and the third argument passed to this function is true, the - ** current content of the cell is preserved. Otherwise, it may - ** be discarded. - ** - ** This function sets the MEM_Dyn flag and clears any xDel callback. - ** It also clears MEM_Ephem and MEM_Static. If the preserve flag is - ** not set, Mem.n is zeroed. - */ - static int sqlite3VdbeMemGrow(Mem pMem, int n, int preserve) { - // TODO -- What do we want to do about this routine? - //Debug.Assert( 1 >= - // ((pMem.zMalloc !=null )? 1 : 0) + //&& pMem.zMalloc==pMem.z) ? 1 : 0) + - // (((pMem.flags & MEM_Dyn)!=0 && pMem.xDel!=null) ? 1 : 0) + - // ((pMem.flags & MEM_Ephem)!=0 ? 1 : 0) + - // ((pMem.flags & MEM_Static)!=0 ? 1 : 0) - //); - //assert( (pMem->flags&MEM_RowSet)==0 ); - - //if( n<32 ) n = 32; - //if( sqlite3DbMallocSize(pMem->db, pMem.zMalloc)db,ref pMem.zMalloc); - pMem.z = "";// sqlite3DbMallocRaw( pMem.db, n ); - } - //} - - // if( pMem->z && preserve && pMem->zMalloc && pMem->z!=pMem->zMalloc ){ - // memcpy(pMem.zMalloc, pMem.z, pMem.n); - //} - if ((pMem.flags & MEM_Dyn) != 0 && pMem.xDel != null) { - pMem.xDel(ref pMem.z); - } - - // TODO --pMem.z = pMem.zMalloc; - if (pMem.z == null) { - pMem.flags = MEM_Null; - } else { - pMem.flags = (u16)(pMem.flags & ~(MEM_Ephem | MEM_Static)); - } - pMem.xDel = null; - return pMem.z != null ? SQLITE_OK : SQLITE_NOMEM; - } + /* + ** Make sure pMem.z points to a writable allocation of at least + ** n bytes. + ** + ** If the memory cell currently contains string or blob data + ** and the third argument passed to this function is true, the + ** current content of the cell is preserved. Otherwise, it may + ** be discarded. + ** + ** This function sets the MEM_Dyn flag and clears any xDel callback. + ** It also clears MEM_Ephem and MEM_Static. If the preserve flag is + ** not set, Mem.n is zeroed. + */ + static int sqlite3VdbeMemGrow( Mem pMem, int n, int preserve ) + { + // TODO -- What do we want to do about this routine? + //Debug.Assert( 1 >= + // ((pMem.zMalloc !=null )? 1 : 0) + //&& pMem.zMalloc==pMem.z) ? 1 : 0) + + // (((pMem.flags & MEM_Dyn)!=0 && pMem.xDel!=null) ? 1 : 0) + + // ((pMem.flags & MEM_Ephem)!=0 ? 1 : 0) + + // ((pMem.flags & MEM_Static)!=0 ? 1 : 0) + //); + //assert( (pMem->flags&MEM_RowSet)==0 ); + + //if( n<32 ) n = 32; + //if( sqlite3DbMallocSize(pMem->db, pMem.zMalloc)db,ref pMem.zMalloc); + pMem.z = "";// sqlite3DbMallocRaw( pMem.db, n ); + } + //} + + // if( pMem->z && preserve && pMem->zMalloc && pMem->z!=pMem->zMalloc ){ + // memcpy(pMem.zMalloc, pMem.z, pMem.n); + //} + if ( ( pMem.flags & MEM_Dyn ) != 0 && pMem.xDel != null ) + { + pMem.xDel( ref pMem.z ); + } + + // TODO --pMem.z = pMem.zMalloc; + if ( pMem.z == null ) + { + pMem.flags = MEM_Null; + } + else + { + pMem.flags = (u16)( pMem.flags & ~( MEM_Ephem | MEM_Static ) ); + } + pMem.xDel = null; + return pMem.z != null ? SQLITE_OK : SQLITE_NOMEM; + } - /* - ** Make the given Mem object MEM_Dyn. In other words, make it so - ** that any TEXT or BLOB content is stored in memory obtained from - ** malloc(). In this way, we know that the memory is safe to be - ** overwritten or altered. - ** - ** Return SQLITE_OK on success or SQLITE_NOMEM if malloc fails. - */ - static int sqlite3VdbeMemMakeWriteable(Mem pMem) { - int f; - Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); - Debug.Assert((pMem.flags & MEM_RowSet) == 0); - expandBlob(pMem); - f = pMem.flags; - if ((f & (MEM_Str | MEM_Blob)) != 0) // TODO -- && pMem.z != pMem.zMalloc ) - { - if (sqlite3VdbeMemGrow(pMem, pMem.n + 2, 1) != 0) - //{ - // return SQLITE_NOMEM; - //} - //pMem.z[pMem->n] = 0; - //pMem.z[pMem->n + 1] = 0; - pMem.flags |= MEM_Term; + /* + ** Make the given Mem object MEM_Dyn. In other words, make it so + ** that any TEXT or BLOB content is stored in memory obtained from + ** malloc(). In this way, we know that the memory is safe to be + ** overwritten or altered. + ** + ** Return SQLITE_OK on success or SQLITE_NOMEM if malloc fails. + */ + static int sqlite3VdbeMemMakeWriteable( Mem pMem ) + { + int f; + Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); + Debug.Assert( ( pMem.flags & MEM_RowSet ) == 0 ); + expandBlob( pMem ); + f = pMem.flags; + if ( ( f & ( MEM_Str | MEM_Blob ) ) != 0 ) // TODO -- && pMem.z != pMem.zMalloc ) + { + if ( sqlite3VdbeMemGrow( pMem, pMem.n + 2, 1 ) != 0 ) + //{ + // return SQLITE_NOMEM; + //} + //pMem.z[pMem->n] = 0; + //pMem.z[pMem->n + 1] = 0; + pMem.flags |= MEM_Term; #if SQLITE_DEBUG - pMem.pScopyFrom = null; + pMem.pScopyFrom = null; #endif - } + } - return SQLITE_OK; - } - /* - ** If the given Mem* has a zero-filled tail, turn it into an ordinary - ** blob stored in dynamically allocated space. - */ + return SQLITE_OK; + } + /* + ** If the given Mem* has a zero-filled tail, turn it into an ordinary + ** blob stored in dynamically allocated space. + */ #if !SQLITE_OMIT_INCRBLOB static int sqlite3VdbeMemExpandBlob( Mem pMem ) { @@ -219,740 +232,861 @@ static int sqlite3VdbeMemExpandBlob( Mem pMem ) #endif - /* - ** Make sure the given Mem is \u0000 terminated. + /* +** Make sure the given Mem is \u0000 terminated. +*/ + static int sqlite3VdbeMemNulTerminate( Mem pMem ) + { + Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); + if ( ( pMem.flags & MEM_Term ) != 0 || ( pMem.flags & MEM_Str ) == 0 ) + { + return SQLITE_OK; /* Nothing to do */ + } + //if ( pMem.n != 0 && sqlite3VdbeMemGrow( pMem, pMem.n + 2, 1 ) != 0 ) + //{ + // return SQLITE_NOMEM; + //} + // pMem.z[pMem->n] = 0; + // pMem.z[pMem->n+1] = 0; + if ( pMem.z != null && pMem.n < pMem.z.Length ) + pMem.z = pMem.z.Substring( 0, pMem.n ); + pMem.flags |= MEM_Term; + return SQLITE_OK; + } + + /* + ** Add MEM_Str to the set of representations for the given Mem. Numbers + ** are converted using sqlite3_snprintf(). Converting a BLOB to a string + ** is a no-op. + ** + ** Existing representations MEM_Int and MEM_Real are *not* invalidated. + ** + ** A MEM_Null value will never be passed to this function. This function is + ** used for converting values to text for returning to the user (i.e. via + ** sqlite3_value_text()), or for ensuring that values to be used as btree + ** keys are strings. In the former case a NULL pointer is returned the + ** user and the later is an internal programming error. */ - static int sqlite3VdbeMemNulTerminate(Mem pMem) { - Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); - if ((pMem.flags & MEM_Term) != 0 || (pMem.flags & MEM_Str) == 0) { - return SQLITE_OK; /* Nothing to do */ - } - //if ( pMem.n != 0 && sqlite3VdbeMemGrow( pMem, pMem.n + 2, 1 ) != 0 ) - //{ - // return SQLITE_NOMEM; - //} - // pMem.z[pMem->n] = 0; - // pMem.z[pMem->n+1] = 0; - if (pMem.z != null && pMem.n < pMem.z.Length) - pMem.z = pMem.z.Substring(0, pMem.n); - pMem.flags |= MEM_Term; - return SQLITE_OK; - } + static int sqlite3VdbeMemStringify( Mem pMem, int enc ) + { + int rc = SQLITE_OK; + int fg = pMem.flags; + const int nByte = 32; + + Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); + Debug.Assert( ( fg & MEM_Zero ) == 0 ); + Debug.Assert( ( fg & ( MEM_Str | MEM_Blob ) ) == 0 ); + Debug.Assert( ( fg & ( MEM_Int | MEM_Real ) ) != 0 ); + Debug.Assert( ( pMem.flags & MEM_RowSet ) == 0 ); + //assert( EIGHT_BYTE_ALIGNMENT(pMem) ); + + if ( sqlite3VdbeMemGrow( pMem, nByte, 0 ) != 0 ) + { + return SQLITE_NOMEM; + } + + /* For a Real or Integer, use sqlite3_snprintf() to produce the UTF-8 + ** string representation of the value. Then, if the required encoding + ** is UTF-16le or UTF-16be do a translation. + ** + ** FIX ME: It would be better if sqlite3_snprintf() could do UTF-16. + */ + if ( ( fg & MEM_Int ) != 0 ) + { + pMem.z = pMem.u.i.ToString(); //sqlite3_snprintf(nByte, pMem.z, "%lld", pMem->u.i); + } + else + { + Debug.Assert( ( fg & MEM_Real ) != 0 ); + if ( Double.IsNegativeInfinity( pMem.r ) ) + pMem.z = "-Inf"; + else if ( Double.IsInfinity( pMem.r ) ) + pMem.z = "Inf"; + else if ( Double.IsPositiveInfinity( pMem.r ) ) + pMem.z = "+Inf"; + else if ( pMem.r.ToString( CultureInfo.InvariantCulture ).Contains( "." ) ) + pMem.z = pMem.r.ToString( CultureInfo.InvariantCulture ).ToLowerInvariant();//sqlite3_snprintf(nByte, pMem.z, "%!.15g", pMem->r); + else + pMem.z = pMem.r.ToString( CultureInfo.InvariantCulture) + ".0"; + } + pMem.n = sqlite3Strlen30( pMem.z ); + pMem.enc = SQLITE_UTF8; + pMem.flags |= MEM_Str | MEM_Term; + sqlite3VdbeChangeEncoding( pMem, enc ); + return rc; + } - /* - ** Add MEM_Str to the set of representations for the given Mem. Numbers - ** are converted using sqlite3_snprintf(). Converting a BLOB to a string - ** is a no-op. - ** - ** Existing representations MEM_Int and MEM_Real are *not* invalidated. - ** - ** A MEM_Null value will never be passed to this function. This function is - ** used for converting values to text for returning to the user (i.e. via - ** sqlite3_value_text()), or for ensuring that values to be used as btree - ** keys are strings. In the former case a NULL pointer is returned the - ** user and the later is an internal programming error. - */ - static int sqlite3VdbeMemStringify(Mem pMem, int enc) { - int rc = SQLITE_OK; - int fg = pMem.flags; - const int nByte = 32; - - Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); - Debug.Assert((fg & MEM_Zero) == 0); - Debug.Assert((fg & (MEM_Str | MEM_Blob)) == 0); - Debug.Assert((fg & (MEM_Int | MEM_Real)) != 0); - Debug.Assert((pMem.flags & MEM_RowSet) == 0); - //assert( EIGHT_BYTE_ALIGNMENT(pMem) ); - - if (sqlite3VdbeMemGrow(pMem, nByte, 0) != 0) { - return SQLITE_NOMEM; - } - - /* For a Real or Integer, use sqlite3_snprintf() to produce the UTF-8 - ** string representation of the value. Then, if the required encoding - ** is UTF-16le or UTF-16be do a translation. - ** - ** FIX ME: It would be better if sqlite3_snprintf() could do UTF-16. - */ - if ((fg & MEM_Int) != 0) { - pMem.z = pMem.u.i.ToString(); //sqlite3_snprintf(nByte, pMem.z, "%lld", pMem->u.i); - } else { - Debug.Assert((fg & MEM_Real) != 0); - if (Double.IsNegativeInfinity(pMem.r)) - pMem.z = "-Inf"; - else if (Double.IsInfinity(pMem.r)) - pMem.z = "Inf"; - else if (Double.IsPositiveInfinity(pMem.r)) - pMem.z = "+Inf"; - else if (pMem.r.ToString(CultureInfo.InvariantCulture).Contains(".")) - pMem.z = pMem.r.ToString(CultureInfo.InvariantCulture).ToLowerInvariant();//sqlite3_snprintf(nByte, pMem.z, "%!.15g", pMem->r); - else - pMem.z = pMem.r.ToString(CultureInfo.InvariantCulture) + ".0"; - } - pMem.n = sqlite3Strlen30(pMem.z); - pMem.enc = SQLITE_UTF8; - pMem.flags |= MEM_Str | MEM_Term; - sqlite3VdbeChangeEncoding(pMem, enc); - return rc; - } + /* + ** Memory cell pMem contains the context of an aggregate function. + ** This routine calls the finalize method for that function. The + ** result of the aggregate is stored back into pMem. + ** + ** Return SQLITE_ERROR if the finalizer reports an error. SQLITE_OK + ** otherwise. + */ + static int sqlite3VdbeMemFinalize( Mem pMem, FuncDef pFunc ) + { + int rc = SQLITE_OK; + if ( ALWAYS( pFunc != null && pFunc.xFinalize != null ) ) + { + sqlite3_context ctx = new sqlite3_context(); + Debug.Assert( ( pMem.flags & MEM_Null ) != 0 || pFunc == pMem.u.pDef ); + Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); + //memset(&ctx, 0, sizeof(ctx)); + ctx.s.flags = MEM_Null; + ctx.s.db = pMem.db; + ctx.pMem = pMem; + ctx.pFunc = pFunc; + pFunc.xFinalize( ctx ); /* IMP: R-24505-23230 */ + Debug.Assert( 0 == ( pMem.flags & MEM_Dyn ) && pMem.xDel == null ); + sqlite3DbFree( pMem.db, ref pMem.zBLOB );//zMalloc ); + ctx.s.CopyTo( ref pMem );//memcpy(pMem, &ctx.s, sizeof(ctx.s)); + rc = ctx.isError; + } + return rc; + } - /* - ** Memory cell pMem contains the context of an aggregate function. - ** This routine calls the finalize method for that function. The - ** result of the aggregate is stored back into pMem. - ** - ** Return SQLITE_ERROR if the finalizer reports an error. SQLITE_OK - ** otherwise. - */ - static int sqlite3VdbeMemFinalize(Mem pMem, FuncDef pFunc) { - int rc = SQLITE_OK; - if (ALWAYS(pFunc != null && pFunc.xFinalize != null)) { - sqlite3_context ctx = new sqlite3_context(); - Debug.Assert((pMem.flags & MEM_Null) != 0 || pFunc == pMem.u.pDef); - Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); - //memset(&ctx, 0, sizeof(ctx)); - ctx.s.flags = MEM_Null; - ctx.s.db = pMem.db; - ctx.pMem = pMem; - ctx.pFunc = pFunc; - pFunc.xFinalize(ctx); /* IMP: R-24505-23230 */ - Debug.Assert(0 == (pMem.flags & MEM_Dyn) && pMem.xDel == null); - sqlite3DbFree(pMem.db, ref pMem.zBLOB);//zMalloc ); - ctx.s.CopyTo(ref pMem);//memcpy(pMem, &ctx.s, sizeof(ctx.s)); - rc = ctx.isError; - } - return rc; + /* + ** If the memory cell contains a string value that must be freed by + ** invoking an external callback, free it now. Calling this function + ** does not free any Mem.zMalloc buffer. + */ + static void sqlite3VdbeMemReleaseExternal( Mem p ) + { + Debug.Assert( p.db == null || sqlite3_mutex_held( p.db.mutex ) ); + testcase( p.flags & MEM_Agg ); + testcase( p.flags & MEM_Dyn ); + testcase( p.flags & MEM_RowSet ); + testcase( p.flags & MEM_Frame ); + if ( ( p.flags & ( MEM_Agg | MEM_Dyn | MEM_RowSet | MEM_Frame ) ) != 0 ) + { + if ( ( p.flags & MEM_Agg ) != 0 ) + { + sqlite3VdbeMemFinalize( p, p.u.pDef ); + Debug.Assert( ( p.flags & MEM_Agg ) == 0 ); + sqlite3VdbeMemRelease( p ); } - - /* - ** If the memory cell contains a string value that must be freed by - ** invoking an external callback, free it now. Calling this function - ** does not free any Mem.zMalloc buffer. - */ - static void sqlite3VdbeMemReleaseExternal(Mem p) { - Debug.Assert(p.db == null || sqlite3_mutex_held(p.db.mutex)); - testcase(p.flags & MEM_Agg); - testcase(p.flags & MEM_Dyn); - testcase(p.flags & MEM_RowSet); - testcase(p.flags & MEM_Frame); - if ((p.flags & (MEM_Agg | MEM_Dyn | MEM_RowSet | MEM_Frame)) != 0) { - if ((p.flags & MEM_Agg) != 0) { - sqlite3VdbeMemFinalize(p, p.u.pDef); - Debug.Assert((p.flags & MEM_Agg) == 0); - sqlite3VdbeMemRelease(p); - } else if ((p.flags & MEM_Dyn) != 0 && p.xDel != null) { - Debug.Assert((p.flags & MEM_RowSet) == 0); - p.xDel(ref p.z); - p.xDel = null; - } else if ((p.flags & MEM_RowSet) != 0) { - sqlite3RowSetClear(p.u.pRowSet); - } else if ((p.flags & MEM_Frame) != 0) { - sqlite3VdbeMemSetNull(p); - } - } - p.n = 0; - p.z = null; - p.zBLOB = null; + else if ( ( p.flags & MEM_Dyn ) != 0 && p.xDel != null ) + { + Debug.Assert( ( p.flags & MEM_RowSet ) == 0 ); + p.xDel( ref p.z ); + p.xDel = null; } - - /* - ** Release any memory held by the Mem. This may leave the Mem in an - ** inconsistent state, for example with (Mem.z==0) and - ** (Mem.type==SQLITE_TEXT). - */ - static void sqlite3VdbeMemRelease(Mem p) { - sqlite3VdbeMemReleaseExternal(p); - sqlite3DbFree(p.db, ref p.zBLOB);//zMalloc ); - p.z = null; - //p.zMalloc = 0; - p.xDel = null; + else if ( ( p.flags & MEM_RowSet ) != 0 ) + { + sqlite3RowSetClear( p.u.pRowSet ); + } + else if ( ( p.flags & MEM_Frame ) != 0 ) + { + sqlite3VdbeMemSetNull( p ); } + } + p.n = 0; + p.z = null; + p.zBLOB = null; + } - /* - ** Convert a 64-bit IEEE double into a 64-bit signed integer. - ** If the double is too large, return 0x8000000000000000. - ** - ** Most systems appear to do this simply by assigning - ** variables and without the extra range tests. But - ** there are reports that windows throws an expection - ** if the floating point value is out of range. (See ticket #2880.) - ** Because we do not completely understand the problem, we will - ** take the conservative approach and always do range tests - ** before attempting the conversion. - */ - static i64 doubleToInt64(double r) { + /* + ** Release any memory held by the Mem. This may leave the Mem in an + ** inconsistent state, for example with (Mem.z==0) and + ** (Mem.type==SQLITE_TEXT). + */ + static void sqlite3VdbeMemRelease( Mem p ) + { + sqlite3VdbeMemReleaseExternal( p ); + sqlite3DbFree( p.db, ref p.zBLOB );//zMalloc ); + p.z = null; + //p.zMalloc = 0; + p.xDel = null; + } + + /* + ** Convert a 64-bit IEEE double into a 64-bit signed integer. + ** If the double is too large, return 0x8000000000000000. + ** + ** Most systems appear to do this simply by assigning + ** variables and without the extra range tests. But + ** there are reports that windows throws an expection + ** if the floating point value is out of range. (See ticket #2880.) + ** Because we do not completely understand the problem, we will + ** take the conservative approach and always do range tests + ** before attempting the conversion. + */ + static i64 doubleToInt64( double r ) + { #if SQLITE_OMIT_FLOATING_POINT /* When floating-point is omitted, double and int64 are the same thing */ return r; #else - /* - ** Many compilers we encounter do not define constants for the - ** minimum and maximum 64-bit integers, or they define them - ** inconsistently. And many do not understand the "LL" notation. - ** So we define our own static constants here using nothing - ** larger than a 32-bit integer constant. - */ - const i64 maxInt = LARGEST_INT64; - const i64 minInt = SMALLEST_INT64; - - if (r < (double)minInt) { - return minInt; - } else if (r > (double)maxInt) { - /* minInt is correct here - not maxInt. It turns out that assigning - ** a very large positive number to an integer results in a very large - ** negative integer. This makes no sense, but it is what x86 hardware - ** does so for compatibility we will do the same in software. */ - return minInt; - } else { - return (i64)r; - } + /* +** Many compilers we encounter do not define constants for the +** minimum and maximum 64-bit integers, or they define them +** inconsistently. And many do not understand the "LL" notation. +** So we define our own static constants here using nothing +** larger than a 32-bit integer constant. +*/ + const i64 maxInt = LARGEST_INT64; + const i64 minInt = SMALLEST_INT64; + + if ( r < (double)minInt ) + { + return minInt; + } + else if ( r > (double)maxInt ) + { + /* minInt is correct here - not maxInt. It turns out that assigning + ** a very large positive number to an integer results in a very large + ** negative integer. This makes no sense, but it is what x86 hardware + ** does so for compatibility we will do the same in software. */ + return minInt; + } + else + { + return (i64)r; + } #endif - } + } - /* - ** Return some kind of integer value which is the best we can do - ** at representing the value that *pMem describes as an integer. - ** If pMem is an integer, then the value is exact. If pMem is - ** a floating-point then the value returned is the integer part. - ** If pMem is a string or blob, then we make an attempt to convert - ** it into a integer and return that. If pMem represents an - ** an SQL-NULL value, return 0. - ** - ** If pMem represents a string value, its encoding might be changed. - */ - static i64 sqlite3VdbeIntValue(Mem pMem) { - int flags; - Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); - // assert( EIGHT_BYTE_ALIGNMENT(pMem) ); - flags = pMem.flags; - if ((flags & MEM_Int) != 0) { - return pMem.u.i; - } else if ((flags & MEM_Real) != 0) { - return doubleToInt64(pMem.r); - } else if ((flags & (MEM_Str)) != 0) { - i64 value = 0; - Debug.Assert(pMem.z != null || pMem.n == 0); - testcase(pMem.z == null); - sqlite3Atoi64(pMem.z, ref value, pMem.n, pMem.enc); - return value; - } else if ((flags & (MEM_Blob)) != 0) { - i64 value = 0; - Debug.Assert(pMem.zBLOB != null || pMem.n == 0); - testcase(pMem.zBLOB == null); - sqlite3Atoi64(Encoding.UTF8.GetString(pMem.zBLOB, 0, pMem.n), ref value, pMem.n, pMem.enc); - return value; - } else { - return 0; - } - } + /* + ** Return some kind of integer value which is the best we can do + ** at representing the value that *pMem describes as an integer. + ** If pMem is an integer, then the value is exact. If pMem is + ** a floating-point then the value returned is the integer part. + ** If pMem is a string or blob, then we make an attempt to convert + ** it into a integer and return that. If pMem represents an + ** an SQL-NULL value, return 0. + ** + ** If pMem represents a string value, its encoding might be changed. + */ + static i64 sqlite3VdbeIntValue( Mem pMem ) + { + int flags; + Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); + // assert( EIGHT_BYTE_ALIGNMENT(pMem) ); + flags = pMem.flags; + if ( ( flags & MEM_Int ) != 0 ) + { + return pMem.u.i; + } + else if ( ( flags & MEM_Real ) != 0 ) + { + return doubleToInt64( pMem.r ); + } + else if ( ( flags & ( MEM_Str ) ) != 0 ) + { + i64 value = 0; + Debug.Assert( pMem.z != null || pMem.n == 0 ); + testcase( pMem.z == null ); + sqlite3Atoi64( pMem.z, ref value, pMem.n, pMem.enc ); + return value; + } + else if ( ( flags & ( MEM_Blob ) ) != 0 ) + { + i64 value = 0; + Debug.Assert( pMem.zBLOB != null || pMem.n == 0 ); + testcase( pMem.zBLOB == null ); + sqlite3Atoi64( Encoding.UTF8.GetString( pMem.zBLOB, 0, pMem.n ), ref value, pMem.n, pMem.enc ); + return value; + } + else + { + return 0; + } + } - /* - ** Return the best representation of pMem that we can get into a - ** double. If pMem is already a double or an integer, return its - ** value. If it is a string or blob, try to convert it to a double. - ** If it is a NULL, return 0.0. - */ - static double sqlite3VdbeRealValue(Mem pMem) { - Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); - //assert( EIGHT_BYTE_ALIGNMENT(pMem) ); - if ((pMem.flags & MEM_Real) != 0) { - return pMem.r; - } else if ((pMem.flags & MEM_Int) != 0) { - return (double)pMem.u.i; - } else if ((pMem.flags & (MEM_Str)) != 0) { - /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ - double val = (double)0; - sqlite3AtoF(pMem.z, ref val, pMem.n, pMem.enc); - return val; - } else if ((pMem.flags & (MEM_Blob)) != 0) { - /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ - double val = (double)0; - Debug.Assert(pMem.zBLOB != null || pMem.n == 0); - sqlite3AtoF(Encoding.UTF8.GetString(pMem.zBLOB, 0, pMem.n), ref val, pMem.n, pMem.enc); - return val; - } else { - /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ - return (double)0; - } - } + /* + ** Return the best representation of pMem that we can get into a + ** double. If pMem is already a double or an integer, return its + ** value. If it is a string or blob, try to convert it to a double. + ** If it is a NULL, return 0.0. + */ + static double sqlite3VdbeRealValue( Mem pMem ) + { + Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); + //assert( EIGHT_BYTE_ALIGNMENT(pMem) ); + if ( ( pMem.flags & MEM_Real ) != 0 ) + { + return pMem.r; + } + else if ( ( pMem.flags & MEM_Int ) != 0 ) + { + return (double)pMem.u.i; + } + else if ( ( pMem.flags & ( MEM_Str ) ) != 0 ) + { + /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ + double val = (double)0; + sqlite3AtoF( pMem.z, ref val, pMem.n, pMem.enc ); + return val; + } + else if ( ( pMem.flags & ( MEM_Blob ) ) != 0 ) + { + /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ + double val = (double)0; + Debug.Assert( pMem.zBLOB != null || pMem.n == 0 ); + sqlite3AtoF( Encoding.UTF8.GetString( pMem.zBLOB, 0, pMem.n ), ref val, pMem.n, pMem.enc ); + return val; + } + else + { + /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ + return (double)0; + } + } - /* - ** The MEM structure is already a MEM_Real. Try to also make it a - ** MEM_Int if we can. - */ - static void sqlite3VdbeIntegerAffinity(Mem pMem) { - Debug.Assert((pMem.flags & MEM_Real) != 0); - Debug.Assert((pMem.flags & MEM_RowSet) == 0); - Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); - //assert( EIGHT_BYTE_ALIGNMENT(pMem) ); - - pMem.u.i = doubleToInt64(pMem.r); - - /* Only mark the value as an integer if - ** - ** (1) the round-trip conversion real->int->real is a no-op, and - ** (2) The integer is neither the largest nor the smallest - ** possible integer (ticket #3922) - ** - ** The second and third terms in the following conditional enforces - ** the second condition under the assumption that addition overflow causes - ** values to wrap around. On x86 hardware, the third term is always - ** true and could be omitted. But we leave it in because other - ** architectures might behave differently. - */ - if (pMem.r == (double)pMem.u.i && pMem.u.i > SMALLEST_INT64 - && ALWAYS(pMem.u.i < LARGEST_INT64)) { - pMem.flags |= MEM_Int; - } - } + /* + ** The MEM structure is already a MEM_Real. Try to also make it a + ** MEM_Int if we can. + */ + static void sqlite3VdbeIntegerAffinity( Mem pMem ) + { + Debug.Assert( ( pMem.flags & MEM_Real ) != 0 ); + Debug.Assert( ( pMem.flags & MEM_RowSet ) == 0 ); + Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); + //assert( EIGHT_BYTE_ALIGNMENT(pMem) ); + + pMem.u.i = doubleToInt64( pMem.r ); + + /* Only mark the value as an integer if + ** + ** (1) the round-trip conversion real->int->real is a no-op, and + ** (2) The integer is neither the largest nor the smallest + ** possible integer (ticket #3922) + ** + ** The second and third terms in the following conditional enforces + ** the second condition under the assumption that addition overflow causes + ** values to wrap around. On x86 hardware, the third term is always + ** true and could be omitted. But we leave it in because other + ** architectures might behave differently. + */ + if ( pMem.r == (double)pMem.u.i && pMem.u.i > SMALLEST_INT64 + && ALWAYS( pMem.u.i < LARGEST_INT64 ) ) + { + pMem.flags |= MEM_Int; + } + } - /* - ** Convert pMem to type integer. Invalidate any prior representations. - */ - static int sqlite3VdbeMemIntegerify(Mem pMem) { - Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); - Debug.Assert((pMem.flags & MEM_RowSet) == 0); - //assert( EIGHT_BYTE_ALIGNMENT(pMem) ); - - pMem.u.i = sqlite3VdbeIntValue(pMem); - MemSetTypeFlag(pMem, MEM_Int); - return SQLITE_OK; - } + /* + ** Convert pMem to type integer. Invalidate any prior representations. + */ + static int sqlite3VdbeMemIntegerify( Mem pMem ) + { + Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); + Debug.Assert( ( pMem.flags & MEM_RowSet ) == 0 ); + //assert( EIGHT_BYTE_ALIGNMENT(pMem) ); + + pMem.u.i = sqlite3VdbeIntValue( pMem ); + MemSetTypeFlag( pMem, MEM_Int ); + return SQLITE_OK; + } - /* - ** Convert pMem so that it is of type MEM_Real. - ** Invalidate any prior representations. - */ - static int sqlite3VdbeMemRealify(Mem pMem) { - Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); - //assert( EIGHT_BYTE_ALIGNMENT(pMem) ); + /* + ** Convert pMem so that it is of type MEM_Real. + ** Invalidate any prior representations. + */ + static int sqlite3VdbeMemRealify( Mem pMem ) + { + Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); + //assert( EIGHT_BYTE_ALIGNMENT(pMem) ); + + pMem.r = sqlite3VdbeRealValue( pMem ); + MemSetTypeFlag( pMem, MEM_Real ); + return SQLITE_OK; + } - pMem.r = sqlite3VdbeRealValue(pMem); - MemSetTypeFlag(pMem, MEM_Real); - return SQLITE_OK; + /* + ** Convert pMem so that it has types MEM_Real or MEM_Int or both. + ** Invalidate any prior representations. + ** + ** Every effort is made to force the conversion, even if the input + ** is a string that does not look completely like a number. Convert + ** as much of the string as we can and ignore the rest. + */ + static int sqlite3VdbeMemNumerify( Mem pMem ) + { + if ( ( pMem.flags & ( MEM_Int | MEM_Real | MEM_Null ) ) == 0 ) + { + Debug.Assert( ( pMem.flags & ( MEM_Blob | MEM_Str ) ) != 0 ); + Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); + if ( ( pMem.flags & MEM_Blob ) != 0 && pMem.z == null ) + { + if ( 0 == sqlite3Atoi64( Encoding.UTF8.GetString( pMem.zBLOB, 0, pMem.zBLOB.Length ), ref pMem.u.i, pMem.n, pMem.enc ) ) + MemSetTypeFlag( pMem, MEM_Int ); + else + { + pMem.r = sqlite3VdbeRealValue( pMem ); + MemSetTypeFlag( pMem, MEM_Real ); + sqlite3VdbeIntegerAffinity( pMem ); + } } - - /* - ** Convert pMem so that it has types MEM_Real or MEM_Int or both. - ** Invalidate any prior representations. - ** - ** Every effort is made to force the conversion, even if the input - ** is a string that does not look completely like a number. Convert - ** as much of the string as we can and ignore the rest. - */ - static int sqlite3VdbeMemNumerify(Mem pMem) { - if ((pMem.flags & (MEM_Int | MEM_Real | MEM_Null)) == 0) { - Debug.Assert((pMem.flags & (MEM_Blob | MEM_Str)) != 0); - Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); - if ((pMem.flags & MEM_Blob) != 0 && pMem.z == null) { - if (0 == sqlite3Atoi64(Encoding.UTF8.GetString(pMem.zBLOB, 0, pMem.zBLOB.Length), ref pMem.u.i, pMem.n, pMem.enc)) - MemSetTypeFlag(pMem, MEM_Int); - else { - pMem.r = sqlite3VdbeRealValue(pMem); - MemSetTypeFlag(pMem, MEM_Real); - sqlite3VdbeIntegerAffinity(pMem); - } - } else if (0 == sqlite3Atoi64(pMem.z, ref pMem.u.i, pMem.n, pMem.enc)) { - MemSetTypeFlag(pMem, MEM_Int); - } else { - pMem.r = sqlite3VdbeRealValue(pMem); - MemSetTypeFlag(pMem, MEM_Real); - sqlite3VdbeIntegerAffinity(pMem); - } - } - Debug.Assert((pMem.flags & (MEM_Int | MEM_Real | MEM_Null)) != 0); - pMem.flags = (ushort)(pMem.flags & ~(MEM_Str | MEM_Blob)); - return SQLITE_OK; + else if ( 0 == sqlite3Atoi64( pMem.z, ref pMem.u.i, pMem.n, pMem.enc ) ) + { + MemSetTypeFlag( pMem, MEM_Int ); + } + else + { + pMem.r = sqlite3VdbeRealValue( pMem ); + MemSetTypeFlag( pMem, MEM_Real ); + sqlite3VdbeIntegerAffinity( pMem ); } + } + Debug.Assert( ( pMem.flags & ( MEM_Int | MEM_Real | MEM_Null ) ) != 0 ); + pMem.flags = (ushort)( pMem.flags & ~( MEM_Str | MEM_Blob ) ); + return SQLITE_OK; + } #if !SQLITE_OMIT_FLOATING_POINT - /* - ** Delete any previous value and set the value stored in pMem to NULL. - */ - static void sqlite3VdbeMemSetNull(Mem pMem) { - if ((pMem.flags & MEM_Frame) != 0) { - VdbeFrame pFrame = pMem.u.pFrame; - pFrame.pParent = pFrame.v.pDelFrame; - pFrame.v.pDelFrame = pFrame; - } - if ((pMem.flags & MEM_RowSet) != 0) { - sqlite3RowSetClear(pMem.u.pRowSet); - } - MemSetTypeFlag(pMem, MEM_Null); - sqlite3_free(ref pMem.zBLOB); - pMem.z = null; - pMem.type = SQLITE_NULL; - } + /* +** Delete any previous value and set the value stored in pMem to NULL. +*/ + static void sqlite3VdbeMemSetNull( Mem pMem ) + { + if ( ( pMem.flags & MEM_Frame ) != 0 ) + { + VdbeFrame pFrame = pMem.u.pFrame; + pFrame.pParent = pFrame.v.pDelFrame; + pFrame.v.pDelFrame = pFrame; + } + if ( ( pMem.flags & MEM_RowSet ) != 0 ) + { + sqlite3RowSetClear( pMem.u.pRowSet ); + } + MemSetTypeFlag( pMem, MEM_Null ); + sqlite3_free( ref pMem.zBLOB ); + pMem.z = null; + pMem.type = SQLITE_NULL; + } #endif - /* - ** Delete any previous value and set the value to be a BLOB of length - ** n containing all zeros. - */ - static void sqlite3VdbeMemSetZeroBlob(Mem pMem, int n) { - sqlite3VdbeMemRelease(pMem); - pMem.flags = MEM_Blob | MEM_Zero; - pMem.type = SQLITE_BLOB; - pMem.n = 0; - if (n < 0) - n = 0; - pMem.u.nZero = n; - pMem.enc = SQLITE_UTF8; + /* +** Delete any previous value and set the value to be a BLOB of length +** n containing all zeros. +*/ + static void sqlite3VdbeMemSetZeroBlob( Mem pMem, int n ) + { + sqlite3VdbeMemRelease( pMem ); + pMem.flags = MEM_Blob | MEM_Zero; + pMem.type = SQLITE_BLOB; + pMem.n = 0; + if ( n < 0 ) + n = 0; + pMem.u.nZero = n; + pMem.enc = SQLITE_UTF8; #if SQLITE_OMIT_INCRBLOB - sqlite3VdbeMemGrow(pMem, n, 0); - //if( pMem.z!= null ){ - pMem.n = n; - pMem.z = null;//memset(pMem.z, 0, n); - pMem.zBLOB = sqlite3Malloc(n); - //} + sqlite3VdbeMemGrow( pMem, n, 0 ); + //if( pMem.z!= null ){ + pMem.n = n; + pMem.z = null;//memset(pMem.z, 0, n); + pMem.zBLOB = sqlite3Malloc( n ); + //} #endif - } + } - /* - ** Delete any previous value and set the value stored in pMem to val, - ** manifest type INTEGER. - */ - static void sqlite3VdbeMemSetInt64(Mem pMem, i64 val) { - sqlite3VdbeMemRelease(pMem); - pMem.u.i = val; - pMem.flags = MEM_Int; - pMem.type = SQLITE_INTEGER; - } + /* + ** Delete any previous value and set the value stored in pMem to val, + ** manifest type INTEGER. + */ + static void sqlite3VdbeMemSetInt64( Mem pMem, i64 val ) + { + sqlite3VdbeMemRelease( pMem ); + pMem.u.i = val; + pMem.flags = MEM_Int; + pMem.type = SQLITE_INTEGER; + } - /* - ** Delete any previous value and set the value stored in pMem to val, - ** manifest type REAL. - */ - static void sqlite3VdbeMemSetDouble(Mem pMem, double val) { - if (sqlite3IsNaN(val)) { - sqlite3VdbeMemSetNull(pMem); - } else { - sqlite3VdbeMemRelease(pMem); - pMem.r = val; - pMem.flags = MEM_Real; - pMem.type = SQLITE_FLOAT; - } - } + /* + ** Delete any previous value and set the value stored in pMem to val, + ** manifest type REAL. + */ + static void sqlite3VdbeMemSetDouble( Mem pMem, double val ) + { + if ( sqlite3IsNaN( val ) ) + { + sqlite3VdbeMemSetNull( pMem ); + } + else + { + sqlite3VdbeMemRelease( pMem ); + pMem.r = val; + pMem.flags = MEM_Real; + pMem.type = SQLITE_FLOAT; + } + } - /* - ** Delete any previous value and set the value of pMem to be an - ** empty boolean index. - */ - static void sqlite3VdbeMemSetRowSet(Mem pMem) { - sqlite3 db = pMem.db; - Debug.Assert(db != null); - Debug.Assert((pMem.flags & MEM_RowSet) == 0); - sqlite3VdbeMemRelease(pMem); - //pMem.zMalloc = sqlite3DbMallocRaw( db, 64 ); - //if ( db.mallocFailed != 0 ) - //{ - // pMem.flags = MEM_Null; - //} - //else - { - //Debug.Assert( pMem.zMalloc ); - pMem.u.pRowSet = new RowSet(db, 5);// sqlite3RowSetInit( db, pMem.zMalloc, - // sqlite3DbMallocSize( db, pMem.zMalloc ) ); - Debug.Assert(pMem.u.pRowSet != null); - pMem.flags = MEM_RowSet; - } - } + /* + ** Delete any previous value and set the value of pMem to be an + ** empty boolean index. + */ + static void sqlite3VdbeMemSetRowSet( Mem pMem ) + { + sqlite3 db = pMem.db; + Debug.Assert( db != null ); + Debug.Assert( ( pMem.flags & MEM_RowSet ) == 0 ); + sqlite3VdbeMemRelease( pMem ); + //pMem.zMalloc = sqlite3DbMallocRaw( db, 64 ); + //if ( db.mallocFailed != 0 ) + //{ + // pMem.flags = MEM_Null; + //} + //else + { + //Debug.Assert( pMem.zMalloc ); + pMem.u.pRowSet = new RowSet( db, 5 );// sqlite3RowSetInit( db, pMem.zMalloc, + // sqlite3DbMallocSize( db, pMem.zMalloc ) ); + Debug.Assert( pMem.u.pRowSet != null ); + pMem.flags = MEM_RowSet; + } + } - /* - ** Return true if the Mem object contains a TEXT or BLOB that is - ** too large - whose size exceeds p.db.aLimit[SQLITE_LIMIT_LENGTH]. - */ - static bool sqlite3VdbeMemTooBig(Mem p) { - //Debug.Assert( p.db != null ); - if ((p.flags & (MEM_Str | MEM_Blob)) != 0) { - int n = p.n; - if ((p.flags & MEM_Zero) != 0) { - n += p.u.nZero; - } - return n > p.db.aLimit[SQLITE_LIMIT_LENGTH]; - } - return false; + /* + ** Return true if the Mem object contains a TEXT or BLOB that is + ** too large - whose size exceeds p.db.aLimit[SQLITE_LIMIT_LENGTH]. + */ + static bool sqlite3VdbeMemTooBig( Mem p ) + { + //Debug.Assert( p.db != null ); + if ( ( p.flags & ( MEM_Str | MEM_Blob ) ) != 0 ) + { + int n = p.n; + if ( ( p.flags & MEM_Zero ) != 0 ) + { + n += p.u.nZero; } + return n > p.db.aLimit[SQLITE_LIMIT_LENGTH]; + } + return false; + } #if SQLITE_DEBUG - /* - ** This routine prepares a memory cell for modication by breaking - ** its link to a shallow copy and by marking any current shallow - ** copies of this cell as invalid. - ** - ** This is used for testing and debugging only - to make sure shallow - ** copies are not misused. - */ - static void sqlite3VdbeMemPrepareToChange(Vdbe pVdbe, Mem pMem) { - int i; - Mem pX; - for (i = 1; i <= pVdbe.nMem; i++) { - pX = pVdbe.aMem[i]; - if (pX.pScopyFrom == pMem) { - pX.flags |= MEM_Invalid; - pX.pScopyFrom = null; - } - } - pMem.pScopyFrom = null; + /* +** This routine prepares a memory cell for modication by breaking +** its link to a shallow copy and by marking any current shallow +** copies of this cell as invalid. +** +** This is used for testing and debugging only - to make sure shallow +** copies are not misused. +*/ + static void sqlite3VdbeMemPrepareToChange( Vdbe pVdbe, Mem pMem ) + { + int i; + Mem pX; + for ( i = 1; i <= pVdbe.nMem; i++ ) + { + pX = pVdbe.aMem[i]; + if ( pX.pScopyFrom == pMem ) + { + pX.flags |= MEM_Invalid; + pX.pScopyFrom = null; } + } + pMem.pScopyFrom = null; + } #endif //* SQLITE_DEBUG */ - /* - ** Size of struct Mem not including the Mem.zMalloc member. + /* +** Size of struct Mem not including the Mem.zMalloc member. +*/ + //#define MEMCELLSIZE (size_t)(&(((Mem *)0).zMalloc)) + + /* + ** Make an shallow copy of pFrom into pTo. Prior contents of + ** pTo are freed. The pFrom.z field is not duplicated. If + ** pFrom.z is used, then pTo.z points to the same thing as pFrom.z + ** and flags gets srcType (either MEM_Ephem or MEM_Static). */ - //#define MEMCELLSIZE (size_t)(&(((Mem *)0).zMalloc)) + static void sqlite3VdbeMemShallowCopy( Mem pTo, Mem pFrom, int srcType ) + { + Debug.Assert( ( pFrom.flags & MEM_RowSet ) == 0 ); + sqlite3VdbeMemReleaseExternal( pTo ); + pFrom.CopyTo( ref pTo );// memcpy(pTo, pFrom, MEMCELLSIZE); + pTo.xDel = null; + if ( ( pFrom.flags & MEM_Static ) != 0 ) + { + pTo.flags = (u16)( pFrom.flags & ~( MEM_Dyn | MEM_Static | MEM_Ephem ) ); + Debug.Assert( srcType == MEM_Ephem || srcType == MEM_Static ); + pTo.flags |= (u16)srcType; + } + } - /* - ** Make an shallow copy of pFrom into pTo. Prior contents of - ** pTo are freed. The pFrom.z field is not duplicated. If - ** pFrom.z is used, then pTo.z points to the same thing as pFrom.z - ** and flags gets srcType (either MEM_Ephem or MEM_Static). - */ - static void sqlite3VdbeMemShallowCopy(Mem pTo, Mem pFrom, int srcType) { - Debug.Assert((pFrom.flags & MEM_RowSet) == 0); - sqlite3VdbeMemReleaseExternal(pTo); - pFrom.CopyTo(ref pTo);// memcpy(pTo, pFrom, MEMCELLSIZE); - pTo.xDel = null; - if ((pFrom.flags & MEM_Static) != 0) { - pTo.flags = (u16)(pFrom.flags & ~(MEM_Dyn | MEM_Static | MEM_Ephem)); - Debug.Assert(srcType == MEM_Ephem || srcType == MEM_Static); - pTo.flags |= (u16)srcType; - } + /* + ** Make a full copy of pFrom into pTo. Prior contents of pTo are + ** freed before the copy is made. + */ + static int sqlite3VdbeMemCopy( Mem pTo, Mem pFrom ) + { + int rc = SQLITE_OK; + + Debug.Assert( ( pFrom.flags & MEM_RowSet ) == 0 ); + sqlite3VdbeMemReleaseExternal( pTo ); + pFrom.CopyTo( ref pTo );// memcpy(pTo, pFrom, MEMCELLSIZE); + pTo.flags = (u16)( pTo.flags & ~MEM_Dyn ); + + if ( ( pTo.flags & ( MEM_Str | MEM_Blob ) ) != 0 ) + { + if ( 0 == ( pFrom.flags & MEM_Static ) ) + { + pTo.flags |= MEM_Ephem; + rc = sqlite3VdbeMemMakeWriteable( pTo ); } + } - /* - ** Make a full copy of pFrom into pTo. Prior contents of pTo are - ** freed before the copy is made. - */ - static int sqlite3VdbeMemCopy(Mem pTo, Mem pFrom) { - int rc = SQLITE_OK; + return rc; + } - Debug.Assert((pFrom.flags & MEM_RowSet) == 0); - sqlite3VdbeMemReleaseExternal(pTo); - pFrom.CopyTo(ref pTo);// memcpy(pTo, pFrom, MEMCELLSIZE); - pTo.flags = (u16)(pTo.flags & ~MEM_Dyn); - if ((pTo.flags & (MEM_Str | MEM_Blob)) != 0) { - if (0 == (pFrom.flags & MEM_Static)) { - pTo.flags |= MEM_Ephem; - rc = sqlite3VdbeMemMakeWriteable(pTo); - } - } - return rc; - } + /* + ** Transfer the contents of pFrom to pTo. Any existing value in pTo is + ** freed. If pFrom contains ephemeral data, a copy is made. + ** + ** pFrom contains an SQL NULL when this routine returns. + */ + static void sqlite3VdbeMemMove( Mem pTo, Mem pFrom ) + { + Debug.Assert( pFrom.db == null || sqlite3_mutex_held( pFrom.db.mutex ) ); + Debug.Assert( pTo.db == null || sqlite3_mutex_held( pTo.db.mutex ) ); + Debug.Assert( pFrom.db == null || pTo.db == null || pFrom.db == pTo.db ); + sqlite3VdbeMemRelease( pTo ); + pFrom.CopyTo( ref pTo );// memcpy(pTo, pFrom, Mem).Length; + pFrom.flags = MEM_Null; + pFrom.xDel = null; + pFrom.z = null; + sqlite3_free( ref pFrom.zBLOB ); //pFrom.zMalloc=0; + } + /* + ** Change the value of a Mem to be a string or a BLOB. + ** + ** The memory management strategy depends on the value of the xDel + ** parameter. If the value passed is SQLITE_TRANSIENT, then the + ** string is copied into a (possibly existing) buffer managed by the + ** Mem structure. Otherwise, any existing buffer is freed and the + ** pointer copied. + ** + ** If the string is too large (if it exceeds the SQLITE_LIMIT_LENGTH + ** size limit) then no memory allocation occurs. If the string can be + ** stored without allocating memory, then it is. If a memory allocation + ** is required to store the string, then value of pMem is unchanged. In + ** either case, SQLITE_TOOBIG is returned. + */ + static int sqlite3VdbeMemSetBlob( + Mem pMem, /* Memory cell to set to string value */ + byte[] zBlob, /* Blob pointer */ + int n, /* Bytes in Blob */ + u8 enc, /* 0 for BLOBs */ + dxDel xDel /* Destructor function */ + ) + { + return sqlite3VdbeMemSetBlob( pMem, zBlob, 0, n >= 0 ? n : zBlob.Length, enc, xDel ); + } // Call w/o offset + + static int sqlite3VdbeMemSetBlob( + Mem pMem, /* Memory cell to set to string value */ + byte[] zBlob, /* Blob pointer */ + int offset, /* offset into string */ + int n, /* Bytes in string, or negative */ + u8 enc, /* Encoding of z. 0 for BLOBs */ + dxDel xDel//)(void*)/* Destructor function */ + ) + { + int nByte = n; /* New value for pMem->n */ + int iLimit; /* Maximum allowed string or blob size */ + + Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); + Debug.Assert( ( pMem.flags & MEM_RowSet ) == 0 ); + + /* If zBlob is a NULL pointer, set pMem to contain an SQL NULL. */ + if ( zBlob == null || zBlob.Length < offset ) + { + sqlite3VdbeMemSetNull( pMem ); + return SQLITE_OK; + } + + if ( pMem.db != null ) + { + iLimit = pMem.db.aLimit[SQLITE_LIMIT_LENGTH]; + } + else + { + iLimit = SQLITE_MAX_LENGTH; + } + if ( nByte < 0 ) + { + Debug.Assert( enc != 0 ); + if ( enc == SQLITE_UTF8 ) + { + for ( nByte = 0; nByte <= iLimit && nByte < zBlob.Length - offset && zBlob[offset + nByte] != 0; nByte++ ) + { + } + } + else + { + for ( nByte = 0; nByte <= iLimit && zBlob[nByte + offset] != 0 || zBlob[offset + nByte + 1] != 0; nByte += 2 ) + { + } + } + } + /* The following block sets the new values of Mem.z and Mem.xDel. It + ** also sets a flag in local variable "flags" to indicate the memory + ** management (one of MEM_Dyn or MEM_Static). + */ + Debug.Assert( enc == 0 ); + { + pMem.z = null; + pMem.zBLOB = sqlite3Malloc( n ); + Buffer.BlockCopy( zBlob, offset, pMem.zBLOB, 0, n ); + } + pMem.n = nByte; + pMem.flags = MEM_Blob | MEM_Term; + pMem.enc = ( enc == 0 ? SQLITE_UTF8 : enc ); + pMem.type = ( enc == 0 ? SQLITE_BLOB : SQLITE_TEXT ); + + if ( nByte > iLimit ) + { + return SQLITE_TOOBIG; + } + + return SQLITE_OK; + } - /* - ** Transfer the contents of pFrom to pTo. Any existing value in pTo is - ** freed. If pFrom contains ephemeral data, a copy is made. - ** - ** pFrom contains an SQL NULL when this routine returns. - */ - static void sqlite3VdbeMemMove(Mem pTo, Mem pFrom) { - Debug.Assert(pFrom.db == null || sqlite3_mutex_held(pFrom.db.mutex)); - Debug.Assert(pTo.db == null || sqlite3_mutex_held(pTo.db.mutex)); - Debug.Assert(pFrom.db == null || pTo.db == null || pFrom.db == pTo.db); - sqlite3VdbeMemRelease(pTo); - pFrom.CopyTo(ref pTo);// memcpy(pTo, pFrom, Mem).Length; - pFrom.flags = MEM_Null; - pFrom.xDel = null; - pFrom.z = null; - sqlite3_free(ref pFrom.zBLOB); //pFrom.zMalloc=0; + static int sqlite3VdbeMemSetStr( + Mem pMem, /* Memory cell to set to string value */ + string z, /* String pointer */ + int n, /* Bytes in string, or negative */ + u8 enc, /* Encoding of z. 0 for BLOBs */ + dxDel xDel /* Destructor function */ + ) + { + return sqlite3VdbeMemSetStr( pMem, z, 0, n, enc, xDel ); + } // Call w/o offset + + static int sqlite3VdbeMemSetStr( + Mem pMem, /* Memory cell to set to string value */ + string z, /* String pointer */ + int offset, /* offset into string */ + int n, /* Bytes in string, or negative */ + u8 enc, /* Encoding of z. 0 for BLOBs */ + dxDel xDel//)(void*)/* Destructor function */ + ) + { + int nByte = n; /* New value for pMem->n */ + int iLimit; /* Maximum allowed string or blob size */ + u16 flags = 0; /* New value for pMem->flags */ + + Debug.Assert( pMem.db == null || sqlite3_mutex_held( pMem.db.mutex ) ); + Debug.Assert( ( pMem.flags & MEM_RowSet ) == 0 ); + + /* If z is a NULL pointer, set pMem to contain an SQL NULL. */ + if ( z == null || z.Length < offset ) + { + sqlite3VdbeMemSetNull( pMem ); + return SQLITE_OK; + } + + if ( pMem.db != null ) + { + iLimit = pMem.db.aLimit[SQLITE_LIMIT_LENGTH]; + } + else + { + iLimit = SQLITE_MAX_LENGTH; + } + flags = (u16)( enc == 0 ? MEM_Blob : MEM_Str ); + if ( nByte < 0 ) + { + Debug.Assert( enc != 0 ); + if ( enc == SQLITE_UTF8 ) + { + for ( nByte = 0; nByte <= iLimit && nByte < z.Length - offset && z[offset + nByte] != 0; nByte++ ) + { + } } - - /* - ** Change the value of a Mem to be a string or a BLOB. - ** - ** The memory management strategy depends on the value of the xDel - ** parameter. If the value passed is SQLITE_TRANSIENT, then the - ** string is copied into a (possibly existing) buffer managed by the - ** Mem structure. Otherwise, any existing buffer is freed and the - ** pointer copied. - ** - ** If the string is too large (if it exceeds the SQLITE_LIMIT_LENGTH - ** size limit) then no memory allocation occurs. If the string can be - ** stored without allocating memory, then it is. If a memory allocation - ** is required to store the string, then value of pMem is unchanged. In - ** either case, SQLITE_TOOBIG is returned. - */ - static int sqlite3VdbeMemSetBlob( - Mem pMem, /* Memory cell to set to string value */ - byte[] zBlob, /* Blob pointer */ - int n, /* Bytes in Blob */ - u8 enc, /* 0 for BLOBs */ - dxDel xDel /* Destructor function */ - ) { - return sqlite3VdbeMemSetBlob(pMem, zBlob, 0, n >= 0 ? n : zBlob.Length, enc, xDel); - } // Call w/o offset - - static int sqlite3VdbeMemSetBlob( - Mem pMem, /* Memory cell to set to string value */ - byte[] zBlob, /* Blob pointer */ - int offset, /* offset into string */ - int n, /* Bytes in string, or negative */ - u8 enc, /* Encoding of z. 0 for BLOBs */ - dxDel xDel//)(void*)/* Destructor function */ - ) { - int nByte = n; /* New value for pMem->n */ - int iLimit; /* Maximum allowed string or blob size */ - - Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); - Debug.Assert((pMem.flags & MEM_RowSet) == 0); - - /* If zBlob is a NULL pointer, set pMem to contain an SQL NULL. */ - if (zBlob == null || zBlob.Length < offset) { - sqlite3VdbeMemSetNull(pMem); - return SQLITE_OK; - } - - if (pMem.db != null) { - iLimit = pMem.db.aLimit[SQLITE_LIMIT_LENGTH]; - } else { - iLimit = SQLITE_MAX_LENGTH; - } - if (nByte < 0) { - Debug.Assert(enc != 0); - if (enc == SQLITE_UTF8) { - for (nByte = 0; nByte <= iLimit && nByte < zBlob.Length - offset && zBlob[offset + nByte] != 0; nByte++) { - } - } else { - for (nByte = 0; nByte <= iLimit && zBlob[nByte + offset] != 0 || zBlob[offset + nByte + 1] != 0; nByte += 2) { - } - } - } - - /* The following block sets the new values of Mem.z and Mem.xDel. It - ** also sets a flag in local variable "flags" to indicate the memory - ** management (one of MEM_Dyn or MEM_Static). - */ - Debug.Assert(enc == 0); - { - pMem.z = null; - pMem.zBLOB = sqlite3Malloc(n); - Buffer.BlockCopy(zBlob, offset, pMem.zBLOB, 0, n); - } - pMem.n = nByte; - pMem.flags = MEM_Blob | MEM_Term; - pMem.enc = (enc == 0 ? SQLITE_UTF8 : enc); - pMem.type = (enc == 0 ? SQLITE_BLOB : SQLITE_TEXT); - - if (nByte > iLimit) { - return SQLITE_TOOBIG; - } - - return SQLITE_OK; + else + { + for ( nByte = 0; nByte <= iLimit && z[nByte + offset] != 0 || z[offset + nByte + 1] != 0; nByte += 2 ) + { + } } + flags |= MEM_Term; + } - static int sqlite3VdbeMemSetStr( - Mem pMem, /* Memory cell to set to string value */ - string z, /* String pointer */ - int n, /* Bytes in string, or negative */ - u8 enc, /* Encoding of z. 0 for BLOBs */ - dxDel xDel /* Destructor function */ - ) { - return sqlite3VdbeMemSetStr(pMem, z, 0, n, enc, xDel); - } // Call w/o offset - - static int sqlite3VdbeMemSetStr( - Mem pMem, /* Memory cell to set to string value */ - string z, /* String pointer */ - int offset, /* offset into string */ - int n, /* Bytes in string, or negative */ - u8 enc, /* Encoding of z. 0 for BLOBs */ - dxDel xDel//)(void*)/* Destructor function */ - ) { - int nByte = n; /* New value for pMem->n */ - int iLimit; /* Maximum allowed string or blob size */ - u16 flags = 0; /* New value for pMem->flags */ - - Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex)); - Debug.Assert((pMem.flags & MEM_RowSet) == 0); - - /* If z is a NULL pointer, set pMem to contain an SQL NULL. */ - if (z == null || z.Length < offset) { - sqlite3VdbeMemSetNull(pMem); - return SQLITE_OK; - } - - if (pMem.db != null) { - iLimit = pMem.db.aLimit[SQLITE_LIMIT_LENGTH]; - } else { - iLimit = SQLITE_MAX_LENGTH; - } - flags = (u16)(enc == 0 ? MEM_Blob : MEM_Str); - if (nByte < 0) { - Debug.Assert(enc != 0); - if (enc == SQLITE_UTF8) { - for (nByte = 0; nByte <= iLimit && nByte < z.Length - offset && z[offset + nByte] != 0; nByte++) { - } - } else { - for (nByte = 0; nByte <= iLimit && z[nByte + offset] != 0 || z[offset + nByte + 1] != 0; nByte += 2) { - } - } - flags |= MEM_Term; - } - - /* The following block sets the new values of Mem.z and Mem.xDel. It - ** also sets a flag in local variable "flags" to indicate the memory - ** management (one of MEM_Dyn or MEM_Static). - */ - if (xDel == SQLITE_TRANSIENT) { - u32 nAlloc = (u32)nByte; - if ((flags & MEM_Term) != 0) { - nAlloc += (u32)(enc == SQLITE_UTF8 ? 1 : 2); - } - if (nByte > iLimit) { - return SQLITE_TOOBIG; - } - if (sqlite3VdbeMemGrow(pMem, (int)nAlloc, 0) != 0) { - return SQLITE_NOMEM; - } - //if ( nAlloc < z.Length ) - //pMem.z = new byte[nAlloc]; Buffer.BlockCopy( z, 0, pMem.z, 0, (int)nAlloc ); } - //else - if (enc == 0) { - pMem.z = null; - pMem.zBLOB = sqlite3Malloc(n); - for (int i = 0; i < n && i < z.Length - offset; i++) - pMem.zBLOB[i] = (byte)z[offset + i]; - } else { - pMem.z = n > 0 && z.Length - offset > n ? z.Substring(offset, n) : z.Substring(offset);//memcpy(pMem.z, z, nAlloc); - sqlite3_free(ref pMem.zBLOB); - } - } else if (xDel == SQLITE_DYNAMIC) { - sqlite3VdbeMemRelease(pMem); - //pMem.zMalloc = pMem.z = (char*)z; - if (enc == 0) { - pMem.z = null; - if (pMem.zBLOB != null) - sqlite3_free(ref pMem.zBLOB); - pMem.zBLOB = Encoding.UTF8.GetBytes(offset == 0 ? z : z.Length + offset < n ? z.Substring(offset, n) : z.Substring(offset)); - } else { - pMem.z = n > 0 && z.Length - offset > n ? z.Substring(offset, n) : z.Substring(offset);//memcpy(pMem.z, z, nAlloc); - sqlite3_free(ref pMem.zBLOB); - } - pMem.xDel = null; - } else { - sqlite3VdbeMemRelease(pMem); - if (enc == 0) { - pMem.z = null; - if (pMem.zBLOB != null) - sqlite3_free(ref pMem.zBLOB); - pMem.zBLOB = Encoding.UTF8.GetBytes(offset == 0 ? z : z.Length + offset < n ? z.Substring(offset, n) : z.Substring(offset)); - } else { - pMem.z = n > 0 && z.Length - offset > n ? z.Substring(offset, n) : z.Substring(offset);//memcpy(pMem.z, z, nAlloc); - sqlite3_free(ref pMem.zBLOB); - } - pMem.xDel = xDel; - flags |= (u16)((xDel == SQLITE_STATIC) ? MEM_Static : MEM_Dyn); - } - pMem.n = nByte; - pMem.flags = flags; - pMem.enc = (enc == 0 ? SQLITE_UTF8 : enc); - pMem.type = (enc == 0 ? SQLITE_BLOB : SQLITE_TEXT); + /* The following block sets the new values of Mem.z and Mem.xDel. It + ** also sets a flag in local variable "flags" to indicate the memory + ** management (one of MEM_Dyn or MEM_Static). + */ + if ( xDel == SQLITE_TRANSIENT ) + { + u32 nAlloc = (u32)nByte; + if ( ( flags & MEM_Term ) != 0 ) + { + nAlloc += (u32)( enc == SQLITE_UTF8 ? 1 : 2 ); + } + if ( nByte > iLimit ) + { + return SQLITE_TOOBIG; + } + if ( sqlite3VdbeMemGrow( pMem, (int)nAlloc, 0 ) != 0 ) + { + return SQLITE_NOMEM; + } + //if ( nAlloc < z.Length ) + //pMem.z = new byte[nAlloc]; Buffer.BlockCopy( z, 0, pMem.z, 0, (int)nAlloc ); } + //else + if ( enc == 0 ) + { + pMem.z = null; + pMem.zBLOB = sqlite3Malloc( n ); + for ( int i = 0; i < n && i < z.Length - offset; i++ ) + pMem.zBLOB[i] = (byte)z[offset + i]; + } + else + { + pMem.z = n > 0 && z.Length - offset > n ? z.Substring( offset, n ) : z.Substring( offset );//memcpy(pMem.z, z, nAlloc); + sqlite3_free( ref pMem.zBLOB ); + } + } + else if ( xDel == SQLITE_DYNAMIC ) + { + sqlite3VdbeMemRelease( pMem ); + //pMem.zMalloc = pMem.z = (char*)z; + if ( enc == 0 ) + { + pMem.z = null; + if ( pMem.zBLOB != null ) + sqlite3_free( ref pMem.zBLOB ); + pMem.zBLOB = Encoding.UTF8.GetBytes( offset == 0 ? z : z.Length + offset < n ? z.Substring( offset, n ) : z.Substring( offset ) ); + } + else + { + pMem.z = n > 0 && z.Length - offset > n ? z.Substring( offset, n ) : z.Substring( offset );//memcpy(pMem.z, z, nAlloc); + sqlite3_free( ref pMem.zBLOB ); + } + pMem.xDel = null; + } + else + { + sqlite3VdbeMemRelease( pMem ); + if ( enc == 0 ) + { + pMem.z = null; + if ( pMem.zBLOB != null ) + sqlite3_free( ref pMem.zBLOB ); + pMem.zBLOB = Encoding.UTF8.GetBytes( offset == 0 ? z : z.Length + offset < n ? z.Substring( offset, n ) : z.Substring( offset ) ); + } + else + { + pMem.z = n > 0 && z.Length - offset > n ? z.Substring( offset, n ) : z.Substring( offset );//memcpy(pMem.z, z, nAlloc); + sqlite3_free( ref pMem.zBLOB ); + } + pMem.xDel = xDel; + flags |= (u16)( ( xDel == SQLITE_STATIC ) ? MEM_Static : MEM_Dyn ); + } + pMem.n = nByte; + pMem.flags = flags; + pMem.enc = ( enc == 0 ? SQLITE_UTF8 : enc ); + pMem.type = ( enc == 0 ? SQLITE_BLOB : SQLITE_TEXT ); #if !SQLITE_OMIT_UTF16 if( pMem.enc!=SQLITE_UTF8 && sqlite3VdbeMemHandleBom(pMem)!=0 ){ @@ -960,440 +1094,514 @@ static int sqlite3VdbeMemSetStr( } #endif - if (nByte > iLimit) { - return SQLITE_TOOBIG; - } + if ( nByte > iLimit ) + { + return SQLITE_TOOBIG; + } + + return SQLITE_OK; + } - return SQLITE_OK; + /* + ** Compare the values contained by the two memory cells, returning + ** negative, zero or positive if pMem1 is less than, equal to, or greater + ** than pMem2. Sorting order is NULL's first, followed by numbers (integers + ** and reals) sorted numerically, followed by text ordered by the collating + ** sequence pColl and finally blob's ordered by memcmp(). + ** + ** Two NULL values are considered equal by this function. + */ + static int sqlite3MemCompare( Mem pMem1, Mem pMem2, CollSeq pColl ) + { + int rc; + int f1, f2; + int combined_flags; + + f1 = pMem1.flags; + f2 = pMem2.flags; + combined_flags = f1 | f2; + Debug.Assert( ( combined_flags & MEM_RowSet ) == 0 ); + + /* If one value is NULL, it is less than the other. If both values + ** are NULL, return 0. + */ + if ( ( combined_flags & MEM_Null ) != 0 ) + { + return ( f2 & MEM_Null ) - ( f1 & MEM_Null ); + } + + /* If one value is a number and the other is not, the number is less. + ** If both are numbers, compare as reals if one is a real, or as integers + ** if both values are integers. + */ + if ( ( combined_flags & ( MEM_Int | MEM_Real ) ) != 0 ) + { + if ( ( f1 & ( MEM_Int | MEM_Real ) ) == 0 ) + { + return 1; + } + if ( ( f2 & ( MEM_Int | MEM_Real ) ) == 0 ) + { + return -1; + } + if ( ( f1 & f2 & MEM_Int ) == 0 ) + { + double r1, r2; + if ( ( f1 & MEM_Real ) == 0 ) + { + r1 = (double)pMem1.u.i; + } + else + { + r1 = pMem1.r; + } + if ( ( f2 & MEM_Real ) == 0 ) + { + r2 = (double)pMem2.u.i; + } + else + { + r2 = pMem2.r; + } + if ( r1 < r2 ) + return -1; + if ( r1 > r2 ) + return 1; + return 0; + } + else + { + Debug.Assert( ( f1 & MEM_Int ) != 0 ); + Debug.Assert( ( f2 & MEM_Int ) != 0 ); + if ( pMem1.u.i < pMem2.u.i ) + return -1; + if ( pMem1.u.i > pMem2.u.i ) + return 1; + return 0; } + } - /* - ** Compare the values contained by the two memory cells, returning - ** negative, zero or positive if pMem1 is less than, equal to, or greater - ** than pMem2. Sorting order is NULL's first, followed by numbers (integers - ** and reals) sorted numerically, followed by text ordered by the collating - ** sequence pColl and finally blob's ordered by memcmp(). - ** - ** Two NULL values are considered equal by this function. - */ - static int sqlite3MemCompare(Mem pMem1, Mem pMem2, CollSeq pColl) { - int rc; - int f1, f2; - int combined_flags; - - f1 = pMem1.flags; - f2 = pMem2.flags; - combined_flags = f1 | f2; - Debug.Assert((combined_flags & MEM_RowSet) == 0); - - /* If one value is NULL, it is less than the other. If both values - ** are NULL, return 0. - */ - if ((combined_flags & MEM_Null) != 0) { - return (f2 & MEM_Null) - (f1 & MEM_Null); - } - - /* If one value is a number and the other is not, the number is less. - ** If both are numbers, compare as reals if one is a real, or as integers - ** if both values are integers. - */ - if ((combined_flags & (MEM_Int | MEM_Real)) != 0) { - if ((f1 & (MEM_Int | MEM_Real)) == 0) { - return 1; - } - if ((f2 & (MEM_Int | MEM_Real)) == 0) { - return -1; - } - if ((f1 & f2 & MEM_Int) == 0) { - double r1, r2; - if ((f1 & MEM_Real) == 0) { - r1 = (double)pMem1.u.i; - } else { - r1 = pMem1.r; - } - if ((f2 & MEM_Real) == 0) { - r2 = (double)pMem2.u.i; - } else { - r2 = pMem2.r; - } - if (r1 < r2) - return -1; - if (r1 > r2) - return 1; - return 0; - } else { - Debug.Assert((f1 & MEM_Int) != 0); - Debug.Assert((f2 & MEM_Int) != 0); - if (pMem1.u.i < pMem2.u.i) - return -1; - if (pMem1.u.i > pMem2.u.i) - return 1; - return 0; - } - } - - /* If one value is a string and the other is a blob, the string is less. - ** If both are strings, compare using the collating functions. - */ - if ((combined_flags & MEM_Str) != 0) { - if ((f1 & MEM_Str) == 0) { - return 1; - } - if ((f2 & MEM_Str) == 0) { - return -1; - } - - Debug.Assert(pMem1.enc == pMem2.enc); - Debug.Assert(pMem1.enc == SQLITE_UTF8 || - pMem1.enc == SQLITE_UTF16LE || pMem1.enc == SQLITE_UTF16BE); - - /* The collation sequence must be defined at this point, even if - ** the user deletes the collation sequence after the vdbe program is - ** compiled (this was not always the case). - */ - Debug.Assert(pColl == null || pColl.xCmp != null); - - if (pColl != null) { - if (pMem1.enc == pColl.enc) { - /* The strings are already in the correct encoding. Call the - ** comparison function directly */ - return pColl.xCmp(pColl.pUser, pMem1.n, pMem1.z, pMem2.n, pMem2.z); - } else { - string v1, v2; - int n1, n2; - Mem c1 = null; - Mem c2 = null; - - c1 = sqlite3Malloc(c1);// memset( &c1, 0, sizeof( c1 ) ); - c2 = sqlite3Malloc(c2);// memset( &c2, 0, sizeof( c2 ) ); - - sqlite3VdbeMemShallowCopy(c1, pMem1, MEM_Ephem); - sqlite3VdbeMemShallowCopy(c2, pMem2, MEM_Ephem); - v1 = sqlite3ValueText((sqlite3_value)c1, pColl.enc); - n1 = v1 == null ? 0 : c1.n; - v2 = sqlite3ValueText((sqlite3_value)c2, pColl.enc); - n2 = v2 == null ? 0 : c2.n; - rc = pColl.xCmp(pColl.pUser, n1, v1, n2, v2); - sqlite3VdbeMemRelease(c1); - sqlite3VdbeMemRelease(c2); - return rc; - } - } - /* If a NULL pointer was passed as the collate function, fall through - ** to the blob case and use memcmp(). */ - } - - /* Both values must be blobs. Compare using memcmp(). */ - if ((pMem1.flags & MEM_Blob) != 0) - if (pMem1.zBLOB != null) - rc = memcmp(pMem1.zBLOB, pMem2.zBLOB, (pMem1.n > pMem2.n) ? pMem2.n : pMem1.n); - else - rc = memcmp(pMem1.z, pMem2.zBLOB, (pMem1.n > pMem2.n) ? pMem2.n : pMem1.n); - else - rc = memcmp(pMem1.z, pMem2.z, (pMem1.n > pMem2.n) ? pMem2.n : pMem1.n); - if (rc == 0) { - rc = pMem1.n - pMem2.n; - } - return rc; + /* If one value is a string and the other is a blob, the string is less. + ** If both are strings, compare using the collating functions. + */ + if ( ( combined_flags & MEM_Str ) != 0 ) + { + if ( ( f1 & MEM_Str ) == 0 ) + { + return 1; + } + if ( ( f2 & MEM_Str ) == 0 ) + { + return -1; } - /* - ** Move data out of a btree key or data field and into a Mem structure. - ** The data or key is taken from the entry that pCur is currently pointing - ** to. offset and amt determine what portion of the data or key to retrieve. - ** key is true to get the key or false to get data. The result is written - ** into the pMem element. - ** - ** The pMem structure is assumed to be uninitialized. Any prior content - ** is overwritten without being freed. - ** - ** If this routine fails for any reason (malloc returns NULL or unable - ** to read from the disk) then the pMem is left in an inconsistent state. - */ - static int sqlite3VdbeMemFromBtree( - BtCursor pCur, /* Cursor pointing at record to retrieve. */ - int offset, /* Offset from the start of data to return bytes from. */ - int amt, /* Number of bytes to return. */ - bool key, /* If true, retrieve from the btree key, not data. */ - Mem pMem /* OUT: Return data in this Mem structure. */ - ) { - byte[] zData; /* Data from the btree layer */ - int available = 0; /* Number of bytes available on the local btree page */ - int rc = SQLITE_OK; /* Return code */ - - Debug.Assert(sqlite3BtreeCursorIsValid(pCur)); - - /* Note: the calls to BtreeKeyFetch() and DataFetch() below assert() - ** that both the BtShared and database handle mutexes are held. */ - Debug.Assert((pMem.flags & MEM_RowSet) == 0); - int outOffset = -1; - if (key) { - zData = sqlite3BtreeKeyFetch(pCur, ref available, ref outOffset); - } else { - zData = sqlite3BtreeDataFetch(pCur, ref available, ref outOffset); - } - Debug.Assert(zData != null); - - if (offset + amt <= available && (pMem.flags & MEM_Dyn) == 0) { - sqlite3VdbeMemRelease(pMem); - pMem.zBLOB = sqlite3Malloc(amt); - Buffer.BlockCopy(zData, offset, pMem.zBLOB, 0, amt);//pMem.z = &zData[offset]; - pMem.flags = MEM_Blob | MEM_Ephem; - } else if (SQLITE_OK == (rc = sqlite3VdbeMemGrow(pMem, amt + 2, 0))) { - pMem.enc = 0; - pMem.type = SQLITE_BLOB; - pMem.z = null; - pMem.zBLOB = sqlite3Malloc(amt); - pMem.flags = MEM_Blob | MEM_Dyn | MEM_Term; - if (key) { - rc = sqlite3BtreeKey(pCur, (u32)offset, (u32)amt, pMem.zBLOB); - } else { - rc = sqlite3BtreeData(pCur, (u32)offset, (u32)amt, pMem.zBLOB);//pMem.z = pMem_z ; - } - //pMem.z[amt] = 0; - //pMem.z[amt+1] = 0; - if (rc != SQLITE_OK) { - sqlite3VdbeMemRelease(pMem); - } - } - pMem.n = amt; - sqlite3_free(ref zData); + Debug.Assert( pMem1.enc == pMem2.enc ); + Debug.Assert( pMem1.enc == SQLITE_UTF8 || + pMem1.enc == SQLITE_UTF16LE || pMem1.enc == SQLITE_UTF16BE ); + /* The collation sequence must be defined at this point, even if + ** the user deletes the collation sequence after the vdbe program is + ** compiled (this was not always the case). + */ + Debug.Assert( pColl == null || pColl.xCmp != null ); + + if ( pColl != null ) + { + if ( pMem1.enc == pColl.enc ) + { + /* The strings are already in the correct encoding. Call the + ** comparison function directly */ + return pColl.xCmp( pColl.pUser, pMem1.n, pMem1.z, pMem2.n, pMem2.z ); + } + else + { + string v1, v2; + int n1, n2; + Mem c1 = null; + Mem c2 = null; + + c1 = sqlite3Malloc( c1 );// memset( &c1, 0, sizeof( c1 ) ); + c2 = sqlite3Malloc( c2 );// memset( &c2, 0, sizeof( c2 ) ); + + sqlite3VdbeMemShallowCopy( c1, pMem1, MEM_Ephem ); + sqlite3VdbeMemShallowCopy( c2, pMem2, MEM_Ephem ); + v1 = sqlite3ValueText( (sqlite3_value)c1, pColl.enc ); + n1 = v1 == null ? 0 : c1.n; + v2 = sqlite3ValueText( (sqlite3_value)c2, pColl.enc ); + n2 = v2 == null ? 0 : c2.n; + rc = pColl.xCmp( pColl.pUser, n1, v1, n2, v2 ); + sqlite3VdbeMemRelease( c1 ); + sqlite3VdbeMemRelease( c2 ); return rc; + } } + /* If a NULL pointer was passed as the collate function, fall through + ** to the blob case and use memcmp(). */ + } + + /* Both values must be blobs. Compare using memcmp(). */ + if ( ( pMem1.flags & MEM_Blob ) != 0 ) + if ( pMem1.zBLOB != null ) + rc = memcmp( pMem1.zBLOB, pMem2.zBLOB, ( pMem1.n > pMem2.n ) ? pMem2.n : pMem1.n ); + else + rc = memcmp( pMem1.z, pMem2.zBLOB, ( pMem1.n > pMem2.n ) ? pMem2.n : pMem1.n ); + else + rc = memcmp( pMem1.z, pMem2.z, ( pMem1.n > pMem2.n ) ? pMem2.n : pMem1.n ); + if ( rc == 0 ) + { + rc = pMem1.n - pMem2.n; + } + return rc; + } - /* This function is only available internally, it is not part of the - ** external API. It works in a similar way to sqlite3_value_text(), - ** except the data returned is in the encoding specified by the second - ** parameter, which must be one of SQLITE_UTF16BE, SQLITE_UTF16LE or - ** SQLITE_UTF8. - ** - ** (2006-02-16:) The enc value can be or-ed with SQLITE_UTF16_ALIGNED. - ** If that is the case, then the result must be aligned on an even byte - ** boundary. - */ - static string sqlite3ValueText(sqlite3_value pVal, int enc) { - if (pVal == null) - return null; - - Debug.Assert(pVal.db == null || sqlite3_mutex_held(pVal.db.mutex)); - Debug.Assert((enc & 3) == (enc & ~SQLITE_UTF16_ALIGNED)); - Debug.Assert((pVal.flags & MEM_RowSet) == 0); - - if ((pVal.flags & MEM_Null) != 0) { - return null; - } - Debug.Assert((MEM_Blob >> 3) == MEM_Str); - pVal.flags |= (u16)((pVal.flags & MEM_Blob) >> 3); - if ((pVal.flags & MEM_Zero) != 0) - sqlite3VdbeMemExpandBlob(pVal); // expandBlob(pVal); - if ((pVal.flags & MEM_Str) != 0) { - if (sqlite3VdbeChangeEncoding(pVal, enc & ~SQLITE_UTF16_ALIGNED) != SQLITE_OK) { - return null; // Encoding Error - } - if ((enc & SQLITE_UTF16_ALIGNED) != 0 && 1 == (1 & (pVal.z[0]))) //1==(1&SQLITE_PTR_TO_INT(pVal.z)) - { - Debug.Assert((pVal.flags & (MEM_Ephem | MEM_Static)) != 0); - if (sqlite3VdbeMemMakeWriteable(pVal) != SQLITE_OK) { - return null; - } - } - sqlite3VdbeMemNulTerminate(pVal); /* IMP: R-59893-45467 */ - } else { - Debug.Assert((pVal.flags & MEM_Blob) == 0); - sqlite3VdbeMemStringify(pVal, enc); - // assert( 0==(1&SQLITE_PTR_TO_INT(pVal->z)) ); - } - Debug.Assert(pVal.enc == (enc & ~SQLITE_UTF16_ALIGNED) || pVal.db == null - //|| pVal.db.mallocFailed != 0 - ); - if (pVal.enc == (enc & ~SQLITE_UTF16_ALIGNED)) { - return pVal.z; - } else { - return null; - } + /* + ** Move data out of a btree key or data field and into a Mem structure. + ** The data or key is taken from the entry that pCur is currently pointing + ** to. offset and amt determine what portion of the data or key to retrieve. + ** key is true to get the key or false to get data. The result is written + ** into the pMem element. + ** + ** The pMem structure is assumed to be uninitialized. Any prior content + ** is overwritten without being freed. + ** + ** If this routine fails for any reason (malloc returns NULL or unable + ** to read from the disk) then the pMem is left in an inconsistent state. + */ + static int sqlite3VdbeMemFromBtree( + BtCursor pCur, /* Cursor pointing at record to retrieve. */ + int offset, /* Offset from the start of data to return bytes from. */ + int amt, /* Number of bytes to return. */ + bool key, /* If true, retrieve from the btree key, not data. */ + Mem pMem /* OUT: Return data in this Mem structure. */ + ) + { + byte[] zData; /* Data from the btree layer */ + int available = 0; /* Number of bytes available on the local btree page */ + int rc = SQLITE_OK; /* Return code */ + + Debug.Assert( sqlite3BtreeCursorIsValid( pCur ) ); + + /* Note: the calls to BtreeKeyFetch() and DataFetch() below assert() + ** that both the BtShared and database handle mutexes are held. */ + Debug.Assert( ( pMem.flags & MEM_RowSet ) == 0 ); + int outOffset = -1; + if ( key ) + { + zData = sqlite3BtreeKeyFetch( pCur, ref available, ref outOffset ); + } + else + { + zData = sqlite3BtreeDataFetch( pCur, ref available, ref outOffset ); + } + Debug.Assert( zData != null ); + + if ( offset + amt <= available && ( pMem.flags & MEM_Dyn ) == 0 ) + { + sqlite3VdbeMemRelease( pMem ); + pMem.zBLOB = sqlite3Malloc( amt ); + Buffer.BlockCopy( zData, offset, pMem.zBLOB, 0, amt );//pMem.z = &zData[offset]; + pMem.flags = MEM_Blob | MEM_Ephem; + } + else if ( SQLITE_OK == ( rc = sqlite3VdbeMemGrow( pMem, amt + 2, 0 ) ) ) + { + pMem.enc = 0; + pMem.type = SQLITE_BLOB; + pMem.z = null; + pMem.zBLOB = sqlite3Malloc( amt ); + pMem.flags = MEM_Blob | MEM_Dyn | MEM_Term; + if ( key ) + { + rc = sqlite3BtreeKey( pCur, (u32)offset, (u32)amt, pMem.zBLOB ); + } + else + { + rc = sqlite3BtreeData( pCur, (u32)offset, (u32)amt, pMem.zBLOB );//pMem.z = pMem_z ; + } + //pMem.z[amt] = 0; + //pMem.z[amt+1] = 0; + if ( rc != SQLITE_OK ) + { + sqlite3VdbeMemRelease( pMem ); } + } + pMem.n = amt; + sqlite3_free( ref zData ); - /* - ** Create a new sqlite3_value object. - */ - static sqlite3_value sqlite3ValueNew(sqlite3 db) { - Mem p = null; - p = sqlite3DbMallocZero(db, p); - //if ( p != null ) - //{ - p.flags = MEM_Null; - p.type = SQLITE_NULL; - p.db = db; - //} - return p; + return rc; + } + + /* This function is only available internally, it is not part of the + ** external API. It works in a similar way to sqlite3_value_text(), + ** except the data returned is in the encoding specified by the second + ** parameter, which must be one of SQLITE_UTF16BE, SQLITE_UTF16LE or + ** SQLITE_UTF8. + ** + ** (2006-02-16:) The enc value can be or-ed with SQLITE_UTF16_ALIGNED. + ** If that is the case, then the result must be aligned on an even byte + ** boundary. + */ + static string sqlite3ValueText( sqlite3_value pVal, int enc ) + { + if ( pVal == null ) + return null; + + Debug.Assert( pVal.db == null || sqlite3_mutex_held( pVal.db.mutex ) ); + Debug.Assert( ( enc & 3 ) == ( enc & ~SQLITE_UTF16_ALIGNED ) ); + Debug.Assert( ( pVal.flags & MEM_RowSet ) == 0 ); + + if ( ( pVal.flags & MEM_Null ) != 0 ) + { + return null; + } + Debug.Assert( ( MEM_Blob >> 3 ) == MEM_Str ); + pVal.flags |= (u16)( ( pVal.flags & MEM_Blob ) >> 3 ); + if ( ( pVal.flags & MEM_Zero ) != 0 ) + sqlite3VdbeMemExpandBlob( pVal ); // expandBlob(pVal); + if ( ( pVal.flags & MEM_Str ) != 0 ) + { + if ( sqlite3VdbeChangeEncoding( pVal, enc & ~SQLITE_UTF16_ALIGNED ) != SQLITE_OK ) + { + return null; // Encoding Error + } + if ( ( enc & SQLITE_UTF16_ALIGNED ) != 0 && 1 == ( 1 & ( pVal.z[0] ) ) ) //1==(1&SQLITE_PTR_TO_INT(pVal.z)) + { + Debug.Assert( ( pVal.flags & ( MEM_Ephem | MEM_Static ) ) != 0 ); + if ( sqlite3VdbeMemMakeWriteable( pVal ) != SQLITE_OK ) + { + return null; + } } + sqlite3VdbeMemNulTerminate( pVal ); /* IMP: R-59893-45467 */ + } + else + { + Debug.Assert( ( pVal.flags & MEM_Blob ) == 0 ); + sqlite3VdbeMemStringify( pVal, enc ); + // assert( 0==(1&SQLITE_PTR_TO_INT(pVal->z)) ); + } + Debug.Assert( pVal.enc == ( enc & ~SQLITE_UTF16_ALIGNED ) || pVal.db == null + //|| pVal.db.mallocFailed != 0 + ); + if ( pVal.enc == ( enc & ~SQLITE_UTF16_ALIGNED ) ) + { + return pVal.z; + } + else + { + return null; + } + } - /* - ** Create a new sqlite3_value object, containing the value of pExpr. - ** - ** This only works for very simple expressions that consist of one constant - ** token (i.e. "5", "5.1", "'a string'"). If the expression can - ** be converted directly into a value, then the value is allocated and - ** a pointer written to ppVal. The caller is responsible for deallocating - ** the value by passing it to sqlite3ValueFree() later on. If the expression - ** cannot be converted to a value, then ppVal is set to NULL. - */ - static int sqlite3ValueFromExpr( - sqlite3 db, /* The database connection */ - Expr pExpr, /* The expression to evaluate */ - int enc, /* Encoding to use */ - char affinity, /* Affinity to use */ - ref sqlite3_value ppVal /* Write the new value here */ - ) { - int op; - string zVal = ""; - sqlite3_value pVal = null; - int negInt = 1; - string zNeg = ""; - - if (pExpr == null) { - ppVal = null; - return SQLITE_OK; - } - op = pExpr.op; - - /* op can only be TK_REGISTER if we have compiled with SQLITE_ENABLE_STAT2. - ** The ifdef here is to enable us to achieve 100% branch test coverage even - ** when SQLITE_ENABLE_STAT2 is omitted. - */ + /* + ** Create a new sqlite3_value object. + */ + static sqlite3_value sqlite3ValueNew( sqlite3 db ) + { + Mem p = null; + p = sqlite3DbMallocZero( db, p ); + //if ( p != null ) + //{ + p.flags = MEM_Null; + p.type = SQLITE_NULL; + p.db = db; + //} + return p; + } + + /* + ** Create a new sqlite3_value object, containing the value of pExpr. + ** + ** This only works for very simple expressions that consist of one constant + ** token (i.e. "5", "5.1", "'a string'"). If the expression can + ** be converted directly into a value, then the value is allocated and + ** a pointer written to ppVal. The caller is responsible for deallocating + ** the value by passing it to sqlite3ValueFree() later on. If the expression + ** cannot be converted to a value, then ppVal is set to NULL. + */ + static int sqlite3ValueFromExpr( + sqlite3 db, /* The database connection */ + Expr pExpr, /* The expression to evaluate */ + int enc, /* Encoding to use */ + char affinity, /* Affinity to use */ + ref sqlite3_value ppVal /* Write the new value here */ + ) + { + int op; + string zVal = ""; + sqlite3_value pVal = null; + int negInt = 1; + string zNeg = ""; + + if ( pExpr == null ) + { + ppVal = null; + return SQLITE_OK; + } + op = pExpr.op; + + /* op can only be TK_REGISTER if we have compiled with SQLITE_ENABLE_STAT2. + ** The ifdef here is to enable us to achieve 100% branch test coverage even + ** when SQLITE_ENABLE_STAT2 is omitted. + */ #if SQLITE_ENABLE_STAT2 if ( op == TK_REGISTER ) op = pExpr.op2; #else - if (NEVER(op == TK_REGISTER)) op = pExpr.op2; +if( NEVER(op==TK_REGISTER) ) op = pExpr.op2; #endif - /* Handle negative integers in a single step. This is needed in the - ** case when the value is -9223372036854775808. - */ - if (op == TK_UMINUS - && (pExpr.pLeft.op == TK_INTEGER || pExpr.pLeft.op == TK_FLOAT)) { - pExpr = pExpr.pLeft; - op = pExpr.op; - negInt = -1; - zNeg = "-"; - } - - if (op == TK_STRING || op == TK_FLOAT || op == TK_INTEGER) { - pVal = sqlite3ValueNew(db); - if (pVal == null) - goto no_mem; - if (ExprHasProperty(pExpr, EP_IntValue)) { - sqlite3VdbeMemSetInt64(pVal, (i64)pExpr.u.iValue * negInt); - } else { - zVal = sqlite3MPrintf(db, "%s%s", zNeg, pExpr.u.zToken); - //if ( zVal == null ) goto no_mem; - sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC); - if (op == TK_FLOAT) - pVal.type = SQLITE_FLOAT; - } - if ((op == TK_INTEGER || op == TK_FLOAT) && affinity == SQLITE_AFF_NONE) { - sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8); - } else { - sqlite3ValueApplyAffinity(pVal, affinity, SQLITE_UTF8); - } - if ((pVal.flags & (MEM_Int | MEM_Real)) != 0) - pVal.flags = (ushort)(pVal.flags & ~MEM_Str); - if (enc != SQLITE_UTF8) { - sqlite3VdbeChangeEncoding(pVal, enc); - } - } - if (enc != SQLITE_UTF8) { - sqlite3VdbeChangeEncoding(pVal, enc); - } else if (op == TK_UMINUS) { - /* This branch happens for multiple negative signs. Ex: -(-5) */ - if (SQLITE_OK == sqlite3ValueFromExpr(db, pExpr.pLeft, enc, affinity, ref pVal)) { - sqlite3VdbeMemNumerify(pVal); - if (pVal.u.i == SMALLEST_INT64) { - pVal.flags &= MEM_Int; - pVal.flags |= MEM_Real; - pVal.r = (double)LARGEST_INT64; - } else { - pVal.u.i = -pVal.u.i; - } - pVal.r = -pVal.r; - sqlite3ValueApplyAffinity(pVal, affinity, enc); - } - } else if (op == TK_NULL) { - pVal = sqlite3ValueNew(db); - if (pVal == null) - goto no_mem; - } + /* Handle negative integers in a single step. This is needed in the +** case when the value is -9223372036854775808. +*/ + if ( op == TK_UMINUS + && ( pExpr.pLeft.op == TK_INTEGER || pExpr.pLeft.op == TK_FLOAT ) ) + { + pExpr = pExpr.pLeft; + op = pExpr.op; + negInt = -1; + zNeg = "-"; + } + + if ( op == TK_STRING || op == TK_FLOAT || op == TK_INTEGER ) + { + pVal = sqlite3ValueNew( db ); + if ( pVal == null ) + goto no_mem; + if ( ExprHasProperty( pExpr, EP_IntValue ) ) + { + sqlite3VdbeMemSetInt64( pVal, (i64)pExpr.u.iValue * negInt ); + } + else + { + zVal = sqlite3MPrintf( db, "%s%s", zNeg, pExpr.u.zToken ); + //if ( zVal == null ) goto no_mem; + sqlite3ValueSetStr( pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC ); + if ( op == TK_FLOAT ) + pVal.type = SQLITE_FLOAT; + } + if ( ( op == TK_INTEGER || op == TK_FLOAT ) && affinity == SQLITE_AFF_NONE ) + { + sqlite3ValueApplyAffinity( pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8 ); + } + else + { + sqlite3ValueApplyAffinity( pVal, affinity, SQLITE_UTF8 ); + } + if ( ( pVal.flags & ( MEM_Int | MEM_Real ) ) != 0 ) + pVal.flags = (ushort)( pVal.flags & ~MEM_Str ); + if ( enc != SQLITE_UTF8 ) + { + sqlite3VdbeChangeEncoding( pVal, enc ); + } + } + if ( enc != SQLITE_UTF8 ) + { + sqlite3VdbeChangeEncoding( pVal, enc ); + } + else if ( op == TK_UMINUS ) + { + /* This branch happens for multiple negative signs. Ex: -(-5) */ + if ( SQLITE_OK == sqlite3ValueFromExpr( db, pExpr.pLeft, enc, affinity, ref pVal ) ) + { + sqlite3VdbeMemNumerify( pVal ); + if ( pVal.u.i == SMALLEST_INT64 ) + { + pVal.flags &= MEM_Int; + pVal.flags |= MEM_Real; + pVal.r = (double)LARGEST_INT64; + } + else + { + pVal.u.i = -pVal.u.i; + } + pVal.r = -pVal.r; + sqlite3ValueApplyAffinity( pVal, affinity, enc ); + } + } + else if ( op == TK_NULL ) + { + pVal = sqlite3ValueNew( db ); + if ( pVal == null) + goto no_mem; + } #if !SQLITE_OMIT_BLOB_LITERAL - else if (op == TK_BLOB) { - int nVal; - Debug.Assert(pExpr.u.zToken[0] == 'x' || pExpr.u.zToken[0] == 'X'); - Debug.Assert(pExpr.u.zToken[1] == '\''); - pVal = sqlite3ValueNew(db); - if (null == pVal) - goto no_mem; - zVal = pExpr.u.zToken.Substring(2); - nVal = sqlite3Strlen30(zVal) - 1; - Debug.Assert(zVal[nVal] == '\''); - byte[] blob = sqlite3HexToBlob(db, zVal, nVal); - sqlite3VdbeMemSetStr(pVal, Encoding.UTF8.GetString(blob, 0, blob.Length), nVal / 2, 0, SQLITE_DYNAMIC); - } + else if ( op == TK_BLOB ) + { + int nVal; + Debug.Assert( pExpr.u.zToken[0] == 'x' || pExpr.u.zToken[0] == 'X' ); + Debug.Assert( pExpr.u.zToken[1] == '\'' ); + pVal = sqlite3ValueNew( db ); + if ( null == pVal ) + goto no_mem; + zVal = pExpr.u.zToken.Substring( 2 ); + nVal = sqlite3Strlen30( zVal ) - 1; + Debug.Assert( zVal[nVal] == '\'' ); + byte[] blob = sqlite3HexToBlob( db, zVal, nVal ); + sqlite3VdbeMemSetStr( pVal, Encoding.UTF8.GetString( blob, 0, blob.Length ), nVal / 2, 0, SQLITE_DYNAMIC ); + } #endif - if (pVal != null) { - sqlite3VdbeMemStoreType(pVal); - } + if ( pVal != null ) + { + sqlite3VdbeMemStoreType( pVal ); + } - ppVal = pVal; - return SQLITE_OK; + ppVal = pVal; + return SQLITE_OK; - no_mem: - //db.mallocFailed = 1; - sqlite3DbFree(db, ref zVal); - pVal = null;// sqlite3ValueFree(pVal); - ppVal = null; - return SQLITE_NOMEM; - } +no_mem: + //db.mallocFailed = 1; + sqlite3DbFree( db, ref zVal ); + pVal = null;// sqlite3ValueFree(pVal); + ppVal = null; + return SQLITE_NOMEM; + } - /* - ** Change the string value of an sqlite3_value object - */ - static void sqlite3ValueSetStr( - sqlite3_value v, /* Value to be set */ - int n, /* Length of string z */ - string z, /* Text of the new string */ - u8 enc, /* Encoding to use */ - dxDel xDel//)(void*) /* Destructor for the string */ - ) { - if (v != null) - sqlite3VdbeMemSetStr(v, z, n, enc, xDel); - } + /* + ** Change the string value of an sqlite3_value object + */ + static void sqlite3ValueSetStr( + sqlite3_value v, /* Value to be set */ + int n, /* Length of string z */ + string z, /* Text of the new string */ + u8 enc, /* Encoding to use */ + dxDel xDel//)(void*) /* Destructor for the string */ + ) + { + if ( v != null ) + sqlite3VdbeMemSetStr( v, z, n, enc, xDel ); + } - /* - ** Free an sqlite3_value object - */ - static void sqlite3ValueFree(ref sqlite3_value v) { - if (v == null) - return; - sqlite3VdbeMemRelease(v); - sqlite3DbFree(v.db, ref v); - } + /* + ** Free an sqlite3_value object + */ + static void sqlite3ValueFree( ref sqlite3_value v ) + { + if ( v == null ) + return; + sqlite3VdbeMemRelease( v ); + sqlite3DbFree( v.db, ref v ); + } - /* - ** Return the number of bytes in the sqlite3_value object assuming - ** that it uses the encoding "enc" - */ - static int sqlite3ValueBytes(sqlite3_value pVal, int enc) { - Mem p = (Mem)pVal; - if ((p.flags & MEM_Blob) != 0 || sqlite3ValueText(pVal, enc) != null) { - if ((p.flags & MEM_Zero) != 0) { - return p.n + p.u.nZero; - } else { - return p.z == null ? p.zBLOB.Length : p.n; - } - } - return 0; + /* + ** Return the number of bytes in the sqlite3_value object assuming + ** that it uses the encoding "enc" + */ + static int sqlite3ValueBytes( sqlite3_value pVal, int enc ) + { + Mem p = (Mem)pVal; + if ( ( p.flags & MEM_Blob ) != 0 || sqlite3ValueText( pVal, enc ) != null ) + { + if ( ( p.flags & MEM_Zero ) != 0 ) + { + return p.n + p.u.nZero; + } + else + { + return p.z == null ? p.zBLOB.Length : p.n; } + } + return 0; } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/vdbetrace_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/vdbetrace_c.cs index 523ef9d14..0431f52ba 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/vdbetrace_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/vdbetrace_c.cs @@ -1,139 +1,170 @@ +using System; using System.Diagnostics; +using System.Text; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2009 November 25 - ** - ** 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 contains code used to insert the values of host parameters - ** (aka "wildcards") into the SQL text output by sqlite3_trace(). - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include "vdbeInt.h" +using Bitmask = System.UInt64; +using u8 = System.Byte; +using u16 = System.UInt16; +using u32 = System.UInt32; + +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 2009 November 25 + ** + ** 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 contains code used to insert the values of host parameters + ** (aka "wildcards") into the SQL text output by sqlite3_trace(). + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include "vdbeInt.h" #if !SQLITE_OMIT_TRACE - /* - ** zSql is a zero-terminated string of UTF-8 SQL text. Return the number of - ** bytes in this text up to but excluding the first character in - ** a host parameter. If the text contains no host parameters, return - ** the total number of bytes in the text. - */ - static int findNextHostParameter(string zSql, int iOffset, ref int pnToken) { - int tokenType = 0; - int nTotal = 0; - int n; + /* +** zSql is a zero-terminated string of UTF-8 SQL text. Return the number of +** bytes in this text up to but excluding the first character in +** a host parameter. If the text contains no host parameters, return +** the total number of bytes in the text. +*/ + static int findNextHostParameter( string zSql, int iOffset, ref int pnToken ) + { + int tokenType = 0; + int nTotal = 0; + int n; - pnToken = 0; - while (iOffset < zSql.Length) { - n = sqlite3GetToken(zSql, iOffset, ref tokenType); - Debug.Assert(n > 0 && tokenType != TK_ILLEGAL); - if (tokenType == TK_VARIABLE) { - pnToken = n; - break; - } - nTotal += n; - iOffset += n;// zSql += n; - } - return nTotal; + pnToken = 0; + while ( iOffset < zSql.Length ) + { + n = sqlite3GetToken( zSql, iOffset, ref tokenType ); + Debug.Assert( n > 0 && tokenType != TK_ILLEGAL ); + if ( tokenType == TK_VARIABLE ) + { + pnToken = n; + break; } + nTotal += n; + iOffset += n;// zSql += n; + } + return nTotal; + } - /* - ** This function returns a pointer to a nul-terminated string in memory - ** obtained from sqlite3DbMalloc(). If sqlite3.vdbeExecCnt is 1, then the - ** string contains a copy of zRawSql but with host parameters expanded to - ** their current bindings. Or, if sqlite3.vdbeExecCnt is greater than 1, - ** then the returned string holds a copy of zRawSql with "-- " prepended - ** to each line of text. - ** - ** The calling function is responsible for making sure the memory returned - ** is eventually freed. - ** - ** ALGORITHM: Scan the input string looking for host parameters in any of - ** these forms: ?, ?N, $A, @A, :A. Take care to avoid text within - ** string literals, quoted identifier names, and comments. For text forms, - ** the host parameter index is found by scanning the perpared - ** statement for the corresponding OP_Variable opcode. Once the host - ** parameter index is known, locate the value in p->aVar[]. Then render - ** the value as a literal in place of the host parameter name. - */ - static string sqlite3VdbeExpandSql( - Vdbe p, /* The prepared statement being evaluated */ - string zRawSql /* Raw text of the SQL statement */ - ) { - sqlite3 db; /* The database connection */ - int idx = 0; /* Index of a host parameter */ - int nextIndex = 1; /* Index of next ? host parameter */ - int n; /* Length of a token prefix */ - int nToken = 0; /* Length of the parameter token */ - int i; /* Loop counter */ - Mem pVar; /* Value of a host parameter */ - StrAccum _out = new StrAccum(1000); /* Accumulate the _output here */ - int izRawSql = 0; + /* + ** This function returns a pointer to a nul-terminated string in memory + ** obtained from sqlite3DbMalloc(). If sqlite3.vdbeExecCnt is 1, then the + ** string contains a copy of zRawSql but with host parameters expanded to + ** their current bindings. Or, if sqlite3.vdbeExecCnt is greater than 1, + ** then the returned string holds a copy of zRawSql with "-- " prepended + ** to each line of text. + ** + ** The calling function is responsible for making sure the memory returned + ** is eventually freed. + ** + ** ALGORITHM: Scan the input string looking for host parameters in any of + ** these forms: ?, ?N, $A, @A, :A. Take care to avoid text within + ** string literals, quoted identifier names, and comments. For text forms, + ** the host parameter index is found by scanning the perpared + ** statement for the corresponding OP_Variable opcode. Once the host + ** parameter index is known, locate the value in p->aVar[]. Then render + ** the value as a literal in place of the host parameter name. + */ + static string sqlite3VdbeExpandSql( + Vdbe p, /* The prepared statement being evaluated */ + string zRawSql /* Raw text of the SQL statement */ + ) + { + sqlite3 db; /* The database connection */ + int idx = 0; /* Index of a host parameter */ + int nextIndex = 1; /* Index of next ? host parameter */ + int n; /* Length of a token prefix */ + int nToken = 0; /* Length of the parameter token */ + int i; /* Loop counter */ + Mem pVar; /* Value of a host parameter */ + StrAccum _out = new StrAccum( 1000 ); /* Accumulate the _output here */ + int izRawSql = 0; - db = p.db; - sqlite3StrAccumInit(_out, null, 100, - db.aLimit[SQLITE_LIMIT_LENGTH]); - _out.db = db; - if (db.vdbeExecCnt > 1) { - while (izRawSql < zRawSql.Length) { - //string zStart = zRawSql; - while (zRawSql[izRawSql++] != '\n' && izRawSql < zRawSql.Length) - ; - sqlite3StrAccumAppend(_out, "-- ", 3); - sqlite3StrAccumAppend(_out, zRawSql, (int)izRawSql);//zRawSql - zStart ); - } - } else { - while (izRawSql < zRawSql.Length) { - n = findNextHostParameter(zRawSql, izRawSql, ref nToken); - Debug.Assert(n > 0); - sqlite3StrAccumAppend(_out, zRawSql.Substring(izRawSql, n), n); - izRawSql += n; - Debug.Assert(izRawSql < zRawSql.Length || nToken == 0); - if (nToken == 0) - break; - if (zRawSql[izRawSql] == '?') { - if (nToken > 1) { - Debug.Assert(sqlite3Isdigit(zRawSql[izRawSql + 1])); - sqlite3GetInt32(zRawSql, izRawSql + 1, ref idx); - } else { - idx = nextIndex; - } - } else { - Debug.Assert(zRawSql[izRawSql] == ':' || zRawSql[izRawSql] == '$' || zRawSql[izRawSql] == '@'); - testcase(zRawSql[izRawSql] == ':'); - testcase(zRawSql[izRawSql] == '$'); - testcase(zRawSql[izRawSql] == '@'); - idx = sqlite3VdbeParameterIndex(p, zRawSql.Substring(izRawSql, nToken), nToken); - Debug.Assert(idx > 0); - } - izRawSql += nToken; - nextIndex = idx + 1; - Debug.Assert(idx > 0 && idx <= p.nVar); - pVar = p.aVar[idx - 1]; - if ((pVar.flags & MEM_Null) != 0) { - sqlite3StrAccumAppend(_out, "NULL", 4); - } else if ((pVar.flags & MEM_Int) != 0) { - sqlite3XPrintf(_out, "%lld", pVar.u.i); - } else if ((pVar.flags & MEM_Real) != 0) { - sqlite3XPrintf(_out, "%!.15g", pVar.r); - } else if ((pVar.flags & MEM_Str) != 0) { + db = p.db; + sqlite3StrAccumInit( _out, null, 100, + db.aLimit[SQLITE_LIMIT_LENGTH] ); + _out.db = db; + if ( db.vdbeExecCnt > 1 ) + { + while ( izRawSql < zRawSql.Length ) + { + //string zStart = zRawSql; + while ( zRawSql[izRawSql++] != '\n' && izRawSql < zRawSql.Length ) + ; + sqlite3StrAccumAppend( _out, "-- ", 3 ); + sqlite3StrAccumAppend( _out, zRawSql, (int)izRawSql );//zRawSql - zStart ); + } + } + else + { + while ( izRawSql < zRawSql.Length ) + { + n = findNextHostParameter( zRawSql, izRawSql, ref nToken ); + Debug.Assert( n > 0 ); + sqlite3StrAccumAppend( _out, zRawSql.Substring( izRawSql, n ), n ); + izRawSql += n; + Debug.Assert( izRawSql < zRawSql.Length || nToken == 0 ); + if ( nToken == 0 ) + break; + if ( zRawSql[izRawSql] == '?' ) + { + if ( nToken > 1 ) + { + Debug.Assert( sqlite3Isdigit( zRawSql[izRawSql + 1] ) ); + sqlite3GetInt32( zRawSql, izRawSql + 1, ref idx ); + } + else + { + idx = nextIndex; + } + } + else + { + Debug.Assert( zRawSql[izRawSql] == ':' || zRawSql[izRawSql] == '$' || zRawSql[izRawSql] == '@' ); + testcase( zRawSql[izRawSql] == ':' ); + testcase( zRawSql[izRawSql] == '$' ); + testcase( zRawSql[izRawSql] == '@' ); + idx = sqlite3VdbeParameterIndex( p, zRawSql.Substring( izRawSql, nToken ), nToken ); + Debug.Assert( idx > 0 ); + } + izRawSql += nToken; + nextIndex = idx + 1; + Debug.Assert( idx > 0 && idx <= p.nVar ); + pVar = p.aVar[idx - 1]; + if ( ( pVar.flags & MEM_Null ) != 0 ) + { + sqlite3StrAccumAppend( _out, "NULL", 4 ); + } + else if ( ( pVar.flags & MEM_Int ) != 0 ) + { + sqlite3XPrintf( _out, "%lld", pVar.u.i ); + } + else if ( ( pVar.flags & MEM_Real ) != 0 ) + { + sqlite3XPrintf( _out, "%!.15g", pVar.r ); + } + else if ( ( pVar.flags & MEM_Str ) != 0 ) + { #if !SQLITE_OMIT_UTF16 u8 enc = ENC(db); if( enc!=SQLITE_UTF8 ){ @@ -146,24 +177,29 @@ string zRawSql /* Raw text of the SQL statement */ sqlite3VdbeMemRelease(&utf8); }else #endif - { - sqlite3XPrintf(_out, "'%.*q'", pVar.n, pVar.z); - } - } else if ((pVar.flags & MEM_Zero) != 0) { - sqlite3XPrintf(_out, "zeroblob(%d)", pVar.u.nZero); - } else { - Debug.Assert((pVar.flags & MEM_Blob) != 0); - sqlite3StrAccumAppend(_out, "x'", 2); - for (i = 0; i < pVar.n; i++) { - sqlite3XPrintf(_out, "%02x", pVar.zBLOB[i] & 0xff); - } - sqlite3StrAccumAppend(_out, "'", 1); - } - } + { + sqlite3XPrintf( _out, "'%.*q'", pVar.n, pVar.z ); } - return sqlite3StrAccumFinish(_out); + } + else if ( ( pVar.flags & MEM_Zero ) != 0 ) + { + sqlite3XPrintf( _out, "zeroblob(%d)", pVar.u.nZero ); + } + else + { + Debug.Assert( ( pVar.flags & MEM_Blob ) != 0 ); + sqlite3StrAccumAppend( _out, "x'", 2 ); + for ( i = 0; i < pVar.n; i++ ) + { + sqlite3XPrintf( _out, "%02x", pVar.zBLOB[i] & 0xff ); + } + sqlite3StrAccumAppend( _out, "'", 1 ); + } } + } + return sqlite3StrAccumFinish( _out ); + } #endif //* #if !SQLITE_OMIT_TRACE */ - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/vtab_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/vtab_c.cs index 73e22118e..940cebf0a 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/vtab_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/vtab_c.cs @@ -2,326 +2,356 @@ using System.Diagnostics; using System.Text; -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2006 June 10 - ** - ** 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 contains code used to help implement virtual tables. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ +using u8 = System.Byte; + +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 2006 June 10 + ** + ** 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 contains code used to help implement virtual tables. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ #if !SQLITE_OMIT_VIRTUALTABLE - //#include "sqliteInt.h" - - /* - ** Before a virtual table xCreate() or xConnect() method is invoked, the - ** sqlite3.pVtabCtx member variable is set to point to an instance of - ** this struct allocated on the stack. It is used by the implementation of - ** the sqlite3_declare_vtab() and sqlite3_vtab_config() APIs, both of which - ** are invoked only from within xCreate and xConnect methods. - */ - public class VtabCtx { - public Table pTab; - public VTable pVTable; - }; - - /* - ** The actual function that does the work of creating a new module. - ** This function implements the sqlite3_create_module() and - ** sqlite3_create_module_v2() interfaces. - */ - static int createModule( - sqlite3 db, /* Database in which module is registered */ - string zName, /* Name assigned to this module */ - sqlite3_module pModule, /* The definition of the module */ - object pAux, /* Context pointer for xCreate/xConnect */ - smdxDestroy xDestroy /* Module destructor function */ - ) { - int rc, nName; - Module pMod; - - sqlite3_mutex_enter(db.mutex); - nName = sqlite3Strlen30(zName); - pMod = new Module();// (Module)sqlite3DbMallocRaw( db, sizeof( Module ) + nName + 1 ); - if (pMod != null) { - Module pDel; - string zCopy;// = (char )(&pMod[1]); - zCopy = zName;//memcpy(zCopy, zName, nName+1); - pMod.zName = zCopy; - pMod.pModule = pModule; - pMod.pAux = pAux; - pMod.xDestroy = xDestroy; - pDel = (Module)sqlite3HashInsert(ref db.aModule, zCopy, nName, pMod); - if (pDel != null && pDel.xDestroy != null) { - sqlite3ResetInternalSchema(db, -1); - pDel.xDestroy(ref pDel.pAux); - } - sqlite3DbFree(db, ref pDel); - //if( pDel==pMod ){ - // db.mallocFailed = 1; - //} - } else if (xDestroy != null) { - xDestroy(ref pAux); - } - rc = sqlite3ApiExit(db, SQLITE_OK); - sqlite3_mutex_leave(db.mutex); - return rc; + //#include "sqliteInt.h" + + /* + ** Before a virtual table xCreate() or xConnect() method is invoked, the + ** sqlite3.pVtabCtx member variable is set to point to an instance of + ** this struct allocated on the stack. It is used by the implementation of + ** the sqlite3_declare_vtab() and sqlite3_vtab_config() APIs, both of which + ** are invoked only from within xCreate and xConnect methods. + */ + public class VtabCtx + { + public Table pTab; + public VTable pVTable; + }; + + /* + ** The actual function that does the work of creating a new module. + ** This function implements the sqlite3_create_module() and + ** sqlite3_create_module_v2() interfaces. + */ + static int createModule( + sqlite3 db, /* Database in which module is registered */ + string zName, /* Name assigned to this module */ + sqlite3_module pModule, /* The definition of the module */ + object pAux, /* Context pointer for xCreate/xConnect */ + smdxDestroy xDestroy /* Module destructor function */ + ) + { + int rc, nName; + Module pMod; + + sqlite3_mutex_enter( db.mutex ); + nName = sqlite3Strlen30( zName ); + pMod = new Module();// (Module)sqlite3DbMallocRaw( db, sizeof( Module ) + nName + 1 ); + if ( pMod != null ) + { + Module pDel; + string zCopy;// = (char )(&pMod[1]); + zCopy = zName;//memcpy(zCopy, zName, nName+1); + pMod.zName = zCopy; + pMod.pModule = pModule; + pMod.pAux = pAux; + pMod.xDestroy = xDestroy; + pDel = (Module)sqlite3HashInsert( ref db.aModule, zCopy, nName, pMod ); + if ( pDel != null && pDel.xDestroy != null ) + { + sqlite3ResetInternalSchema( db, -1 ); + pDel.xDestroy( ref pDel.pAux ); } + sqlite3DbFree( db, ref pDel ); + //if( pDel==pMod ){ + // db.mallocFailed = 1; + //} + } + else if ( xDestroy != null ) + { + xDestroy( ref pAux ); + } + rc = sqlite3ApiExit( db, SQLITE_OK ); + sqlite3_mutex_leave( db.mutex ); + return rc; + } - /* - ** External API function used to create a new virtual-table module. - */ - static int sqlite3_create_module( - sqlite3 db, /* Database in which module is registered */ - string zName, /* Name assigned to this module */ - sqlite3_module pModule, /* The definition of the module */ - object pAux /* Context pointer for xCreate/xConnect */ - ) { - return createModule(db, zName, pModule, pAux, null); - } + /* + ** External API function used to create a new virtual-table module. + */ + static int sqlite3_create_module( + sqlite3 db, /* Database in which module is registered */ + string zName, /* Name assigned to this module */ + sqlite3_module pModule, /* The definition of the module */ + object pAux /* Context pointer for xCreate/xConnect */ + ) + { + return createModule( db, zName, pModule, pAux, null ); + } - /* - ** External API function used to create a new virtual-table module. - */ - static int sqlite3_create_module_v2( - sqlite3 db, /* Database in which module is registered */ - string zName, /* Name assigned to this module */ - sqlite3_module pModule, /* The definition of the module */ - sqlite3_vtab pAux, /* Context pointer for xCreate/xConnect */ - smdxDestroy xDestroy /* Module destructor function */ - ) { - return createModule(db, zName, pModule, pAux, xDestroy); - } + /* + ** External API function used to create a new virtual-table module. + */ + static int sqlite3_create_module_v2( + sqlite3 db, /* Database in which module is registered */ + string zName, /* Name assigned to this module */ + sqlite3_module pModule, /* The definition of the module */ + sqlite3_vtab pAux, /* Context pointer for xCreate/xConnect */ + smdxDestroy xDestroy /* Module destructor function */ + ) + { + return createModule( db, zName, pModule, pAux, xDestroy ); + } - /* - ** Lock the virtual table so that it cannot be disconnected. - ** Locks nest. Every lock should have a corresponding unlock. - ** If an unlock is omitted, resources leaks will occur. - ** - ** If a disconnect is attempted while a virtual table is locked, - ** the disconnect is deferred until all locks have been removed. - */ - static void sqlite3VtabLock(VTable pVTab) { - pVTab.nRef++; - } + /* + ** Lock the virtual table so that it cannot be disconnected. + ** Locks nest. Every lock should have a corresponding unlock. + ** If an unlock is omitted, resources leaks will occur. + ** + ** If a disconnect is attempted while a virtual table is locked, + ** the disconnect is deferred until all locks have been removed. + */ + static void sqlite3VtabLock( VTable pVTab ) + { + pVTab.nRef++; + } - /* - ** pTab is a pointer to a Table structure representing a virtual-table. - ** Return a pointer to the VTable object used by connection db to access - ** this virtual-table, if one has been created, or NULL otherwise. - */ - static VTable sqlite3GetVTable(sqlite3 db, Table pTab) { - VTable pVtab; - Debug.Assert(IsVirtual(pTab)); - for (pVtab = pTab.pVTable; pVtab != null && pVtab.db != db; pVtab = pVtab.pNext) - ; - return pVtab; - } + /* + ** pTab is a pointer to a Table structure representing a virtual-table. + ** Return a pointer to the VTable object used by connection db to access + ** this virtual-table, if one has been created, or NULL otherwise. + */ + static VTable sqlite3GetVTable( sqlite3 db, Table pTab ) + { + VTable pVtab; + Debug.Assert( IsVirtual( pTab ) ); + for ( pVtab = pTab.pVTable; pVtab != null && pVtab.db != db; pVtab = pVtab.pNext ) + ; + return pVtab; + } - /* - ** Decrement the ref-count on a virtual table object. When the ref-count - ** reaches zero, call the xDisconnect() method to delete the object. - */ - static void sqlite3VtabUnlock(VTable pVTab) { - sqlite3 db = pVTab.db; - - Debug.Assert(db != null); - Debug.Assert(pVTab.nRef > 0); - Debug.Assert(sqlite3SafetyCheckOk(db)); - - pVTab.nRef--; - if (pVTab.nRef == 0) { - object p = pVTab.pVtab; - if (p != null) { - ((sqlite3_vtab)p).pModule.xDisconnect(ref p); - } - sqlite3DbFree(db, ref pVTab); - } + /* + ** Decrement the ref-count on a virtual table object. When the ref-count + ** reaches zero, call the xDisconnect() method to delete the object. + */ + static void sqlite3VtabUnlock( VTable pVTab ) + { + sqlite3 db = pVTab.db; + + Debug.Assert( db != null); + Debug.Assert( pVTab.nRef > 0 ); + Debug.Assert( sqlite3SafetyCheckOk( db ) ); + + pVTab.nRef--; + if ( pVTab.nRef == 0 ) + { + object p = pVTab.pVtab; + if ( p != null ) + { + ((sqlite3_vtab)p).pModule.xDisconnect( ref p ); } + sqlite3DbFree( db, ref pVTab ); + } + } - /* - ** Table p is a virtual table. This function moves all elements in the - ** p.pVTable list to the sqlite3.pDisconnect lists of their associated - ** database connections to be disconnected at the next opportunity. - ** Except, if argument db is not NULL, then the entry associated with - ** connection db is left in the p.pVTable list. - */ - static VTable vtabDisconnectAll(sqlite3 db, Table p) { - VTable pRet = null; - VTable pVTable = p.pVTable; - p.pVTable = null; - - /* Assert that the mutex (if any) associated with the BtShared database - ** that contains table p is held by the caller. See header comments - ** above function sqlite3VtabUnlockList() for an explanation of why - ** this makes it safe to access the sqlite3.pDisconnect list of any - ** database connection that may have an entry in the p.pVTable list. - */ - Debug.Assert(db == null || sqlite3SchemaMutexHeld(db, 0, p.pSchema)); - - while (pVTable != null) { - sqlite3 db2 = pVTable.db; - VTable pNext = pVTable.pNext; - Debug.Assert(db2 != null); - if (db2 == db) { - pRet = pVTable; - p.pVTable = pRet; - pRet.pNext = null; - } else { - pVTable.pNext = db2.pDisconnect; - db2.pDisconnect = pVTable; - } - pVTable = pNext; - } - - Debug.Assert(null == db || pRet != null); - return pRet; + /* + ** Table p is a virtual table. This function moves all elements in the + ** p.pVTable list to the sqlite3.pDisconnect lists of their associated + ** database connections to be disconnected at the next opportunity. + ** Except, if argument db is not NULL, then the entry associated with + ** connection db is left in the p.pVTable list. + */ + static VTable vtabDisconnectAll( sqlite3 db, Table p ) + { + VTable pRet = null; + VTable pVTable = p.pVTable; + p.pVTable = null; + + /* Assert that the mutex (if any) associated with the BtShared database + ** that contains table p is held by the caller. See header comments + ** above function sqlite3VtabUnlockList() for an explanation of why + ** this makes it safe to access the sqlite3.pDisconnect list of any + ** database connection that may have an entry in the p.pVTable list. + */ + Debug.Assert( db == null || sqlite3SchemaMutexHeld( db, 0, p.pSchema ) ); + + while ( pVTable != null ) + { + sqlite3 db2 = pVTable.db; + VTable pNext = pVTable.pNext; + Debug.Assert( db2 != null ); + if ( db2 == db ) + { + pRet = pVTable; + p.pVTable = pRet; + pRet.pNext = null; } + else + { + pVTable.pNext = db2.pDisconnect; + db2.pDisconnect = pVTable; + } + pVTable = pNext; + } + Debug.Assert( null == db || pRet != null ); + return pRet; + } - /* - ** Disconnect all the virtual table objects in the sqlite3.pDisconnect list. - ** - ** This function may only be called when the mutexes associated with all - ** shared b-tree databases opened using connection db are held by the - ** caller. This is done to protect the sqlite3.pDisconnect list. The - ** sqlite3.pDisconnect list is accessed only as follows: - ** - ** 1) By this function. In this case, all BtShared mutexes and the mutex - ** associated with the database handle itself must be held. - ** - ** 2) By function vtabDisconnectAll(), when it adds a VTable entry to - ** the sqlite3.pDisconnect list. In this case either the BtShared mutex - ** associated with the database the virtual table is stored in is held - ** or, if the virtual table is stored in a non-sharable database, then - ** the database handle mutex is held. - ** - ** As a result, a sqlite3.pDisconnect cannot be accessed simultaneously - ** by multiple threads. It is thread-safe. - */ - static void sqlite3VtabUnlockList(sqlite3 db) { - VTable p = db.pDisconnect; - db.pDisconnect = null; - - Debug.Assert(sqlite3BtreeHoldsAllMutexes(db)); - Debug.Assert(sqlite3_mutex_held(db.mutex)); - - if (p != null) { - sqlite3ExpirePreparedStatements(db); - do { - VTable pNext = p.pNext; - sqlite3VtabUnlock(p); - p = pNext; - } while (p != null); - } - } - /* - ** Clear any and all virtual-table information from the Table record. - ** This routine is called, for example, just before deleting the Table - ** record. - ** - ** Since it is a virtual-table, the Table structure contains a pointer - ** to the head of a linked list of VTable structures. Each VTable - ** structure is associated with a single sqlite3* user of the schema. - ** The reference count of the VTable structure associated with database - ** connection db is decremented immediately (which may lead to the - ** structure being xDisconnected and free). Any other VTable structures - ** in the list are moved to the sqlite3.pDisconnect list of the associated - ** database connection. - */ - static void sqlite3VtabClear(sqlite3 db, Table p) { - if (null == db || db.pnBytesFreed == 0) - vtabDisconnectAll(null, p); - if (p.azModuleArg != null) { - int i; - for (i = 0; i < p.nModuleArg; i++) { - sqlite3DbFree(db, ref p.azModuleArg[i]); - } - sqlite3DbFree(db, ref p.azModuleArg); - } - } + /* + ** Disconnect all the virtual table objects in the sqlite3.pDisconnect list. + ** + ** This function may only be called when the mutexes associated with all + ** shared b-tree databases opened using connection db are held by the + ** caller. This is done to protect the sqlite3.pDisconnect list. The + ** sqlite3.pDisconnect list is accessed only as follows: + ** + ** 1) By this function. In this case, all BtShared mutexes and the mutex + ** associated with the database handle itself must be held. + ** + ** 2) By function vtabDisconnectAll(), when it adds a VTable entry to + ** the sqlite3.pDisconnect list. In this case either the BtShared mutex + ** associated with the database the virtual table is stored in is held + ** or, if the virtual table is stored in a non-sharable database, then + ** the database handle mutex is held. + ** + ** As a result, a sqlite3.pDisconnect cannot be accessed simultaneously + ** by multiple threads. It is thread-safe. + */ + static void sqlite3VtabUnlockList( sqlite3 db ) + { + VTable p = db.pDisconnect; + db.pDisconnect = null; + + Debug.Assert( sqlite3BtreeHoldsAllMutexes( db ) ); + Debug.Assert( sqlite3_mutex_held( db.mutex ) ); + + if ( p != null ) + { + sqlite3ExpirePreparedStatements( db ); + do + { + VTable pNext = p.pNext; + sqlite3VtabUnlock( p ); + p = pNext; + } while ( p != null ); + } + } - /* - ** Add a new module argument to pTable.azModuleArg[]. - ** The string is not copied - the pointer is stored. The - ** string will be freed automatically when the table is - ** deleted. - */ - static void addModuleArgument(sqlite3 db, Table pTable, string zArg) { - int i = pTable.nModuleArg++; - //int nBytes = sizeof(char )*(1+pTable.nModuleArg); - //string[] azModuleArg; - //sqlite3DbRealloc( db, pTable.azModuleArg, nBytes ); - if (pTable.azModuleArg == null || pTable.azModuleArg.Length < pTable.nModuleArg) - Array.Resize(ref pTable.azModuleArg, 3 + pTable.nModuleArg); - //if ( azModuleArg == null ) - //{ - // int j; - // for ( j = 0; j < i; j++ ) - // { - // sqlite3DbFree( db, ref pTable.azModuleArg[j] ); - // } - // sqlite3DbFree( db, ref zArg ); - // sqlite3DbFree( db, ref pTable.azModuleArg ); - // pTable.nModuleArg = 0; - //} - //else - { - pTable.azModuleArg[i] = zArg; - //pTable.azModuleArg[i + 1] = null; - //azModuleArg[i+1] = 0; - } - //pTable.azModuleArg = azModuleArg; + /* + ** Clear any and all virtual-table information from the Table record. + ** This routine is called, for example, just before deleting the Table + ** record. + ** + ** Since it is a virtual-table, the Table structure contains a pointer + ** to the head of a linked list of VTable structures. Each VTable + ** structure is associated with a single sqlite3* user of the schema. + ** The reference count of the VTable structure associated with database + ** connection db is decremented immediately (which may lead to the + ** structure being xDisconnected and free). Any other VTable structures + ** in the list are moved to the sqlite3.pDisconnect list of the associated + ** database connection. + */ + static void sqlite3VtabClear( sqlite3 db, Table p ) + { + if ( null == db || db.pnBytesFreed == 0 ) + vtabDisconnectAll( null, p ); + if ( p.azModuleArg != null ) + { + int i; + for ( i = 0; i < p.nModuleArg; i++ ) + { + sqlite3DbFree( db, ref p.azModuleArg[i] ); } + sqlite3DbFree( db, ref p.azModuleArg ); + } + } - /* - ** The parser calls this routine when it first sees a CREATE VIRTUAL TABLE - ** statement. The module name has been parsed, but the optional list - ** of parameters that follow the module name are still pending. - */ - static void sqlite3VtabBeginParse( - Parse pParse, /* Parsing context */ - Token pName1, /* Name of new table, or database name */ - Token pName2, /* Name of new table or NULL */ - Token pModuleName /* Name of the module for the virtual table */ - ) { - int iDb; /* The database the table is being created in */ - Table pTable; /* The new virtual table */ - sqlite3 db; /* Database connection */ - - sqlite3StartTable(pParse, pName1, pName2, 0, 0, 1, 0); - pTable = pParse.pNewTable; - if (pTable == null) - return; - Debug.Assert(null == pTable.pIndex); - - db = pParse.db; - iDb = sqlite3SchemaToIndex(db, pTable.pSchema); - Debug.Assert(iDb >= 0); - - pTable.tabFlags |= TF_Virtual; - pTable.nModuleArg = 0; - addModuleArgument(db, pTable, sqlite3NameFromToken(db, pModuleName)); - addModuleArgument(db, pTable, db.aDb[iDb].zName);//sqlite3DbStrDup( db, db.aDb[iDb].zName ) ); - addModuleArgument(db, pTable, pTable.zName);//sqlite3DbStrDup( db, pTable.zName ) ); - pParse.sNameToken.n = pParse.sNameToken.z.Length;// (int)[pModuleName.n] - pName1.z ); + /* + ** Add a new module argument to pTable.azModuleArg[]. + ** The string is not copied - the pointer is stored. The + ** string will be freed automatically when the table is + ** deleted. + */ + static void addModuleArgument( sqlite3 db, Table pTable, string zArg ) + { + int i = pTable.nModuleArg++; + //int nBytes = sizeof(char )*(1+pTable.nModuleArg); + //string[] azModuleArg; + //sqlite3DbRealloc( db, pTable.azModuleArg, nBytes ); + if ( pTable.azModuleArg == null || pTable.azModuleArg.Length < pTable.nModuleArg ) + Array.Resize( ref pTable.azModuleArg, 3 + pTable.nModuleArg ); + //if ( azModuleArg == null ) + //{ + // int j; + // for ( j = 0; j < i; j++ ) + // { + // sqlite3DbFree( db, ref pTable.azModuleArg[j] ); + // } + // sqlite3DbFree( db, ref zArg ); + // sqlite3DbFree( db, ref pTable.azModuleArg ); + // pTable.nModuleArg = 0; + //} + //else + { + pTable.azModuleArg[i] = zArg; + //pTable.azModuleArg[i + 1] = null; + //azModuleArg[i+1] = 0; + } + //pTable.azModuleArg = azModuleArg; + } + + /* + ** The parser calls this routine when it first sees a CREATE VIRTUAL TABLE + ** statement. The module name has been parsed, but the optional list + ** of parameters that follow the module name are still pending. + */ + static void sqlite3VtabBeginParse( + Parse pParse, /* Parsing context */ + Token pName1, /* Name of new table, or database name */ + Token pName2, /* Name of new table or NULL */ + Token pModuleName /* Name of the module for the virtual table */ + ) + { + int iDb; /* The database the table is being created in */ + Table pTable; /* The new virtual table */ + sqlite3 db; /* Database connection */ + + sqlite3StartTable( pParse, pName1, pName2, 0, 0, 1, 0 ); + pTable = pParse.pNewTable; + if ( pTable == null ) + return; + Debug.Assert( null == pTable.pIndex ); + + db = pParse.db; + iDb = sqlite3SchemaToIndex( db, pTable.pSchema ); + Debug.Assert( iDb >= 0 ); + + pTable.tabFlags |= TF_Virtual; + pTable.nModuleArg = 0; + addModuleArgument( db, pTable, sqlite3NameFromToken( db, pModuleName ) ); + addModuleArgument( db, pTable, db.aDb[iDb].zName);//sqlite3DbStrDup( db, db.aDb[iDb].zName ) ); + addModuleArgument( db, pTable, pTable.zName );//sqlite3DbStrDup( db, pTable.zName ) ); + pParse.sNameToken.n = pParse.sNameToken.z.Length;// (int)[pModuleName.n] - pName1.z ); #if !SQLITE_OMIT_AUTHORIZATION /* Creating a virtual table invokes the authorization callback twice. @@ -334,793 +364,878 @@ static void sqlite3VtabBeginParse( pTable->azModuleArg[0], pParse->db->aDb[iDb].zName); } #endif - } - - /* - ** This routine takes the module argument that has been accumulating - ** in pParse.zArg[] and appends it to the list of arguments on the - ** virtual table currently under construction in pParse.pTable. - */ - static void addArgumentToVtab(Parse pParse) { - if (pParse.sArg.z != null && ALWAYS(pParse.pNewTable)) { - string z = pParse.sArg.z.Substring(0, pParse.sArg.n); - ////int n = pParse.sArg.n; - sqlite3 db = pParse.db; - addModuleArgument(db, pParse.pNewTable, z);////sqlite3DbStrNDup( db, z, n ) ); - } - } + } - /* - ** The parser calls this routine after the CREATE VIRTUAL TABLE statement - ** has been completely parsed. - */ - static void sqlite3VtabFinishParse(Parse pParse, Token pEnd) { - Table pTab = pParse.pNewTable; /* The table being constructed */ - sqlite3 db = pParse.db; /* The database connection */ - - if (pTab == null) - return; - addArgumentToVtab(pParse); - pParse.sArg.z = ""; - if (pTab.nModuleArg < 1) - return; - - /* If the CREATE VIRTUAL TABLE statement is being entered for the - ** first time (in other words if the virtual table is actually being - ** created now instead of just being read out of sqlite_master) then - ** do additional initialization work and store the statement text - ** in the sqlite_master table. - */ - if (0 == db.init.busy) { - string zStmt; - string zWhere; - int iDb; - Vdbe v; - - /* Compute the complete text of the CREATE VIRTUAL TABLE statement */ - if (pEnd != null) { - pParse.sNameToken.n = pParse.sNameToken.z.Length;//(int)( pEnd.z - pParse.sNameToken.z ) + pEnd.n; - } - zStmt = sqlite3MPrintf(db, "CREATE VIRTUAL TABLE %T", pParse.sNameToken.z.Substring(0, pParse.sNameToken.n)); - - /* A slot for the record has already been allocated in the - ** SQLITE_MASTER table. We just need to update that slot with all - ** the information we've collected. - ** - ** The VM register number pParse.regRowid holds the rowid of an - ** entry in the sqlite_master table tht was created for this vtab - ** by sqlite3StartTable(). - */ - iDb = sqlite3SchemaToIndex(db, pTab.pSchema); - sqlite3NestedParse(pParse, - "UPDATE %Q.%s " + - "SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q " + - "WHERE rowid=#%d", - db.aDb[iDb].zName, SCHEMA_TABLE(iDb), - pTab.zName, - pTab.zName, - zStmt, - pParse.regRowid - ); - sqlite3DbFree(db, ref zStmt); - v = sqlite3GetVdbe(pParse); - sqlite3ChangeCookie(pParse, iDb); - - sqlite3VdbeAddOp2(v, OP_Expire, 0, 0); - zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab.zName); - sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere); - sqlite3VdbeAddOp4(v, OP_VCreate, iDb, 0, 0, - pTab.zName, sqlite3Strlen30(pTab.zName) + 1); - } + /* + ** This routine takes the module argument that has been accumulating + ** in pParse.zArg[] and appends it to the list of arguments on the + ** virtual table currently under construction in pParse.pTable. + */ + static void addArgumentToVtab( Parse pParse ) + { + if ( pParse.sArg.z != null && ALWAYS( pParse.pNewTable ) ) + { + string z = pParse.sArg.z.Substring( 0, pParse.sArg.n ); + ////int n = pParse.sArg.n; + sqlite3 db = pParse.db; + addModuleArgument( db, pParse.pNewTable, z );////sqlite3DbStrNDup( db, z, n ) ); + } + } - /* If we are rereading the sqlite_master table create the in-memory - ** record of the table. The xConnect() method is not called until - ** the first time the virtual table is used in an SQL statement. This - ** allows a schema that contains virtual tables to be loaded before - ** the required virtual table implementations are registered. */ - else { - Table pOld; - Schema pSchema = pTab.pSchema; - string zName = pTab.zName; - int nName = sqlite3Strlen30(zName); - Debug.Assert(sqlite3SchemaMutexHeld(db, 0, pSchema)); - pOld = sqlite3HashInsert(ref pSchema.tblHash, zName, nName, pTab); - if (pOld != null) { - //db.mallocFailed = 1; - Debug.Assert(pTab == pOld); /* Malloc must have failed inside HashInsert() */ - return; - } - pParse.pNewTable = null; - } + /* + ** The parser calls this routine after the CREATE VIRTUAL TABLE statement + ** has been completely parsed. + */ + static void sqlite3VtabFinishParse( Parse pParse, Token pEnd ) + { + Table pTab = pParse.pNewTable; /* The table being constructed */ + sqlite3 db = pParse.db; /* The database connection */ + + if ( pTab == null ) + return; + addArgumentToVtab( pParse ); + pParse.sArg.z = ""; + if ( pTab.nModuleArg < 1 ) + return; + + /* If the CREATE VIRTUAL TABLE statement is being entered for the + ** first time (in other words if the virtual table is actually being + ** created now instead of just being read out of sqlite_master) then + ** do additional initialization work and store the statement text + ** in the sqlite_master table. + */ + if ( 0 == db.init.busy ) + { + string zStmt; + string zWhere; + int iDb; + Vdbe v; + + /* Compute the complete text of the CREATE VIRTUAL TABLE statement */ + if ( pEnd != null ) + { + pParse.sNameToken.n = pParse.sNameToken.z.Length;//(int)( pEnd.z - pParse.sNameToken.z ) + pEnd.n; } + zStmt = sqlite3MPrintf( db, "CREATE VIRTUAL TABLE %T", pParse.sNameToken.z.Substring(0,pParse.sNameToken.n) ); - /* - ** The parser calls this routine when it sees the first token - ** of an argument to the module name in a CREATE VIRTUAL TABLE statement. + /* A slot for the record has already been allocated in the + ** SQLITE_MASTER table. We just need to update that slot with all + ** the information we've collected. + ** + ** The VM register number pParse.regRowid holds the rowid of an + ** entry in the sqlite_master table tht was created for this vtab + ** by sqlite3StartTable(). */ - static void sqlite3VtabArgInit(Parse pParse) { - addArgumentToVtab(pParse); - pParse.sArg.z = null; - pParse.sArg.n = 0; + iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); + sqlite3NestedParse( pParse, + "UPDATE %Q.%s " + + "SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q " + + "WHERE rowid=#%d", + db.aDb[iDb].zName, SCHEMA_TABLE( iDb ), + pTab.zName, + pTab.zName, + zStmt, + pParse.regRowid + ); + sqlite3DbFree( db, ref zStmt ); + v = sqlite3GetVdbe( pParse ); + sqlite3ChangeCookie( pParse, iDb ); + + sqlite3VdbeAddOp2( v, OP_Expire, 0, 0 ); + zWhere = sqlite3MPrintf( db, "name='%q' AND type='table'", pTab.zName ); + sqlite3VdbeAddParseSchemaOp( v, iDb, zWhere ); + sqlite3VdbeAddOp4( v, OP_VCreate, iDb, 0, 0, + pTab.zName, sqlite3Strlen30( pTab.zName ) + 1 ); + } + + /* If we are rereading the sqlite_master table create the in-memory + ** record of the table. The xConnect() method is not called until + ** the first time the virtual table is used in an SQL statement. This + ** allows a schema that contains virtual tables to be loaded before + ** the required virtual table implementations are registered. */ + else + { + Table pOld; + Schema pSchema = pTab.pSchema; + string zName = pTab.zName; + int nName = sqlite3Strlen30( zName ); + Debug.Assert( sqlite3SchemaMutexHeld( db, 0, pSchema ) ); + pOld = sqlite3HashInsert( ref pSchema.tblHash, zName, nName, pTab ); + if ( pOld != null ) + { + //db.mallocFailed = 1; + Debug.Assert( pTab == pOld ); /* Malloc must have failed inside HashInsert() */ + return; } + pParse.pNewTable = null; + } + } - /* - ** The parser calls this routine for each token after the first token - ** in an argument to the module name in a CREATE VIRTUAL TABLE statement. - */ - static void sqlite3VtabArgExtend(Parse pParse, Token p) { - Token pArg = pParse.sArg; - if (pArg.z == null) { - pArg.z = p.z; - pArg.n = p.n; - } else { - //Debug.Assert( pArg.z< p.z ); - pArg.n += p.n + 1;//(int)( p.z[p.n] - pArg.z ); - } - } + /* + ** The parser calls this routine when it sees the first token + ** of an argument to the module name in a CREATE VIRTUAL TABLE statement. + */ + static void sqlite3VtabArgInit( Parse pParse ) + { + addArgumentToVtab( pParse ); + pParse.sArg.z = null; + pParse.sArg.n = 0; + } - /* - ** Invoke a virtual table constructor (either xCreate or xConnect). The - ** pointer to the function to invoke is passed as the fourth parameter - ** to this procedure. - */ - static int vtabCallConstructor( - sqlite3 db, - Table pTab, - Module pMod, - smdxCreateConnect xConstruct, - ref string pzErr - ) { - VtabCtx sCtx = new VtabCtx(); - VTable pVTable; - int rc; - string[] azArg = pTab.azModuleArg; - int nArg = pTab.nModuleArg; - string zErr = null; - string zModuleName = sqlite3MPrintf(db, "%s", pTab.zName); - - //if ( String.IsNullOrEmpty( zModuleName ) ) - //{ - // return SQLITE_NOMEM; - //} - - pVTable = new VTable();//sqlite3DbMallocZero( db, sizeof( VTable ) ); - //if ( null == pVTable ) - //{ - // sqlite3DbFree( db, ref zModuleName ); - // return SQLITE_NOMEM; - //} - pVTable.db = db; - pVTable.pMod = pMod; - - /* Invoke the virtual table constructor */ - //assert( &db->pVtabCtx ); - Debug.Assert(xConstruct != null); - sCtx.pTab = pTab; - sCtx.pVTable = pVTable; - db.pVtabCtx = sCtx; - rc = xConstruct(db, pMod.pAux, nArg, azArg, out pVTable.pVtab, out zErr); - db.pVtabCtx = null; - //if ( rc == SQLITE_NOMEM ) - // db.mallocFailed = 1; - - if (SQLITE_OK != rc) { - if (zErr == "") { - pzErr = sqlite3MPrintf(db, "vtable constructor failed: %s", zModuleName); - } else { - pzErr = sqlite3MPrintf(db, "%s", zErr); - zErr = null;//sqlite3_free( zErr ); - } - sqlite3DbFree(db, ref pVTable); - } else if (ALWAYS(pVTable.pVtab)) { - /* Justification of ALWAYS(): A correct vtab constructor must allocate - ** the sqlite3_vtab object if successful. */ - pVTable.pVtab.pModule = pMod.pModule; - pVTable.nRef = 1; - if (sCtx.pTab != null) { - string zFormat = "vtable constructor did not declare schema: %s"; - pzErr = sqlite3MPrintf(db, zFormat, pTab.zName); - sqlite3VtabUnlock(pVTable); - rc = SQLITE_ERROR; - } else { - int iCol; - /* If everything went according to plan, link the new VTable structure - ** into the linked list headed by pTab->pVTable. Then loop through the - ** columns of the table to see if any of them contain the token "hidden". - ** If so, set the Column.isHidden flag and remove the token from - ** the type string. */ - pVTable.pNext = pTab.pVTable; - pTab.pVTable = pVTable; - - for (iCol = 0; iCol < pTab.nCol; iCol++) { - if (String.IsNullOrEmpty(pTab.aCol[iCol].zType)) - continue; - StringBuilder zType = new StringBuilder(pTab.aCol[iCol].zType); - int nType; - int i = 0; - //if ( zType ) - // continue; - nType = sqlite3Strlen30(zType); - if (sqlite3StrNICmp("hidden", 0, zType.ToString(), 6) != 0 || (zType.Length > 6 && zType[6] != ' ')) { - for (i = 0; i < nType; i++) { - if ((0 == sqlite3StrNICmp(" hidden", zType.ToString().Substring(i), 7)) - && (i + 7 == zType.Length || (zType[i + 7] == '\0' || zType[i + 7] == ' ')) - ) { - i++; - break; - } - } - } - if (i < nType) { - int j; - int nDel = 6 + (zType.Length > i + 6 ? 1 : 0); - for (j = i; (j + nDel) < nType; j++) { - zType[j] = zType[j + nDel]; - } - if (zType[i] == '\0' && i > 0) { - Debug.Assert(zType[i - 1] == ' '); - zType.Length = i;//[i - 1] = '\0'; - } - pTab.aCol[iCol].isHidden = 1; - pTab.aCol[iCol].zType = zType.ToString().Substring(0, j); - } - } - } - } + /* + ** The parser calls this routine for each token after the first token + ** in an argument to the module name in a CREATE VIRTUAL TABLE statement. + */ + static void sqlite3VtabArgExtend( Parse pParse, Token p ) + { + Token pArg = pParse.sArg; + if ( pArg.z == null ) + { + pArg.z = p.z; + pArg.n = p.n; + } + else + { + //Debug.Assert( pArg.z< p.z ); + pArg.n += p.n+1;//(int)( p.z[p.n] - pArg.z ); + } + } - sqlite3DbFree(db, ref zModuleName); - return rc; + /* + ** Invoke a virtual table constructor (either xCreate or xConnect). The + ** pointer to the function to invoke is passed as the fourth parameter + ** to this procedure. + */ + static int vtabCallConstructor( + sqlite3 db, + Table pTab, + Module pMod, + smdxCreateConnect xConstruct, + ref string pzErr + ) + { + VtabCtx sCtx = new VtabCtx(); + VTable pVTable; + int rc; + string[] azArg = pTab.azModuleArg; + int nArg = pTab.nModuleArg; + string zErr = null; + string zModuleName = sqlite3MPrintf( db, "%s", pTab.zName ); + + //if ( String.IsNullOrEmpty( zModuleName ) ) + //{ + // return SQLITE_NOMEM; + //} + + pVTable = new VTable();//sqlite3DbMallocZero( db, sizeof( VTable ) ); + //if ( null == pVTable ) + //{ + // sqlite3DbFree( db, ref zModuleName ); + // return SQLITE_NOMEM; + //} + pVTable.db = db; + pVTable.pMod = pMod; + + /* Invoke the virtual table constructor */ + //assert( &db->pVtabCtx ); + Debug.Assert( xConstruct != null ); + sCtx.pTab = pTab; + sCtx.pVTable = pVTable; + db.pVtabCtx = sCtx; + rc = xConstruct( db, pMod.pAux, nArg, azArg, out pVTable.pVtab, out zErr ); + db.pVtabCtx = null; + //if ( rc == SQLITE_NOMEM ) + // db.mallocFailed = 1; + + if ( SQLITE_OK != rc ) + { + if ( zErr == "" ) + { + pzErr = sqlite3MPrintf( db, "vtable constructor failed: %s", zModuleName ); } - - /* - ** This function is invoked by the parser to call the xConnect() method - ** of the virtual table pTab. If an error occurs, an error code is returned - ** and an error left in pParse. - ** - ** This call is a no-op if table pTab is not a virtual table. - */ - static int sqlite3VtabCallConnect(Parse pParse, Table pTab) { - sqlite3 db = pParse.db; - string zMod; - Module pMod; - int rc; - - Debug.Assert(pTab != null); - if ((pTab.tabFlags & TF_Virtual) == 0 || sqlite3GetVTable(db, pTab) != null) { - return SQLITE_OK; - } - - /* Locate the required virtual table module */ - zMod = pTab.azModuleArg[0]; - pMod = (Module)sqlite3HashFind(db.aModule, zMod, sqlite3Strlen30(zMod), (Module)null); - - if (null == pMod) { - string zModule = pTab.azModuleArg[0]; - sqlite3ErrorMsg(pParse, "no such module: %s", zModule); - rc = SQLITE_ERROR; - } else { - string zErr = null; - rc = vtabCallConstructor(db, pTab, pMod, pMod.pModule.xConnect, ref zErr); - if (rc != SQLITE_OK) { - sqlite3ErrorMsg(pParse, "%s", zErr); + else + { + pzErr = sqlite3MPrintf( db, "%s", zErr ); + zErr = null;//sqlite3_free( zErr ); + } + sqlite3DbFree( db, ref pVTable ); + } + else if ( ALWAYS( pVTable.pVtab ) ) + { + /* Justification of ALWAYS(): A correct vtab constructor must allocate + ** the sqlite3_vtab object if successful. */ + pVTable.pVtab.pModule = pMod.pModule; + pVTable.nRef = 1; + if ( sCtx.pTab != null ) + { + string zFormat = "vtable constructor did not declare schema: %s"; + pzErr = sqlite3MPrintf( db, zFormat, pTab.zName ); + sqlite3VtabUnlock( pVTable ); + rc = SQLITE_ERROR; + } + else + { + int iCol; + /* If everything went according to plan, link the new VTable structure + ** into the linked list headed by pTab->pVTable. Then loop through the + ** columns of the table to see if any of them contain the token "hidden". + ** If so, set the Column.isHidden flag and remove the token from + ** the type string. */ + pVTable.pNext = pTab.pVTable; + pTab.pVTable = pVTable; + + for ( iCol = 0; iCol < pTab.nCol; iCol++ ) + { + if ( String.IsNullOrEmpty( pTab.aCol[iCol].zType ) ) + continue; + StringBuilder zType = new StringBuilder( pTab.aCol[iCol].zType); + int nType; + int i = 0; + //if ( zType ) + // continue; + nType = sqlite3Strlen30( zType ); + if ( sqlite3StrNICmp( "hidden", 0, zType.ToString(), 6 ) != 0 || ( zType.Length > 6 && zType[6] != ' ' ) ) + { + for ( i = 0; i < nType; i++ ) + { + if ( ( 0 == sqlite3StrNICmp( " hidden", zType.ToString().Substring( i ), 7 ) ) + && ( i+7 == zType.Length || (zType[i + 7] == '\0' || zType[i + 7] == ' ' )) + ) + { + i++; + break; } - zErr = null;//sqlite3DbFree( db, zErr ); + } } - - return rc; - } - /* - ** Grow the db.aVTrans[] array so that there is room for at least one - ** more v-table. Return SQLITE_NOMEM if a malloc fails, or SQLITE_OK otherwise. - */ - static int growVTrans(sqlite3 db) { - const int ARRAY_INCR = 5; - - /* Grow the sqlite3.aVTrans array if required */ - if ((db.nVTrans % ARRAY_INCR) == 0) { - //VTable** aVTrans; - //int nBytes = sizeof( sqlite3_vtab* ) * ( db.nVTrans + ARRAY_INCR ); - //aVTrans = sqlite3DbRealloc( db, (void)db.aVTrans, nBytes ); - //if ( !aVTrans ) - //{ - // return SQLITE_NOMEM; - //} - //memset( &aVTrans[db.nVTrans], 0, sizeof( sqlite3_vtab* ) * ARRAY_INCR ); - Array.Resize(ref db.aVTrans, db.nVTrans + ARRAY_INCR); + if ( i < nType ) + { + int j; + int nDel = 6 + ( zType.Length > i + 6 ? 1 : 0 ); + for ( j = i; ( j + nDel ) < nType; j++ ) + { + zType[j] = zType[j + nDel]; + } + if ( zType[i] == '\0' && i > 0 ) + { + Debug.Assert( zType[i - 1] == ' ' ); + zType.Length = i;//[i - 1] = '\0'; + } + pTab.aCol[iCol].isHidden = 1; + pTab.aCol[iCol].zType = zType.ToString().Substring(0,j); } - - return SQLITE_OK; - } - - /* - ** Add the virtual table pVTab to the array sqlite3.aVTrans[]. Space should - ** have already been reserved using growVTrans(). - */ - static void addToVTrans(sqlite3 db, VTable pVTab) { - /* Add pVtab to the end of sqlite3.aVTrans */ - db.aVTrans[db.nVTrans++] = pVTab; - sqlite3VtabLock(pVTab); + } } + } - /* - ** This function is invoked by the vdbe to call the xCreate method - ** of the virtual table named zTab in database iDb. - ** - ** If an error occurs, *pzErr is set to point an an English language - ** description of the error and an SQLITE_XXX error code is returned. - ** In this case the caller must call sqlite3DbFree(db, ) on *pzErr. - */ - static int sqlite3VtabCallCreate(sqlite3 db, int iDb, string zTab, ref string pzErr) { - int rc = SQLITE_OK; - Table pTab; - Module pMod; - string zMod; - - pTab = sqlite3FindTable(db, zTab, db.aDb[iDb].zName); - Debug.Assert(pTab != null && (pTab.tabFlags & TF_Virtual) != 0 && null == pTab.pVTable); - - /* Locate the required virtual table module */ - zMod = pTab.azModuleArg[0]; - pMod = (Module)sqlite3HashFind(db.aModule, zMod, sqlite3Strlen30(zMod), (Module)null); - - /* If the module has been registered and includes a Create method, - ** invoke it now. If the module has not been registered, return an - ** error. Otherwise, do nothing. - */ - if (null == pMod) { - pzErr = sqlite3MPrintf(db, "no such module: %s", zMod); - rc = SQLITE_ERROR; - } else { - rc = vtabCallConstructor(db, pTab, pMod, pMod.pModule.xCreate, ref pzErr); - } - - /* Justification of ALWAYS(): The xConstructor method is required to - ** create a valid sqlite3_vtab if it returns SQLITE_OK. */ - if (rc == SQLITE_OK && ALWAYS(sqlite3GetVTable(db, pTab))) { - rc = growVTrans(db); - if (rc == SQLITE_OK) { - addToVTrans(db, sqlite3GetVTable(db, pTab)); - } - } + sqlite3DbFree( db, ref zModuleName ); + return rc; + } - return rc; + /* + ** This function is invoked by the parser to call the xConnect() method + ** of the virtual table pTab. If an error occurs, an error code is returned + ** and an error left in pParse. + ** + ** This call is a no-op if table pTab is not a virtual table. + */ + static int sqlite3VtabCallConnect( Parse pParse, Table pTab ) + { + sqlite3 db = pParse.db; + string zMod; + Module pMod; + int rc; + + Debug.Assert( pTab != null); + if ( ( pTab.tabFlags & TF_Virtual ) == 0 || sqlite3GetVTable( db, pTab )!= null ) + { + return SQLITE_OK; + } + + /* Locate the required virtual table module */ + zMod = pTab.azModuleArg[0]; + pMod = (Module)sqlite3HashFind( db.aModule, zMod, sqlite3Strlen30( zMod ), (Module)null ); + + if ( null == pMod ) + { + string zModule = pTab.azModuleArg[0]; + sqlite3ErrorMsg( pParse, "no such module: %s", zModule ); + rc = SQLITE_ERROR; + } + else + { + string zErr = null; + rc = vtabCallConstructor( db, pTab, pMod, pMod.pModule.xConnect, ref zErr ); + if ( rc != SQLITE_OK ) + { + sqlite3ErrorMsg( pParse, "%s", zErr ); } + zErr = null;//sqlite3DbFree( db, zErr ); + } - /* - ** This function is used to set the schema of a virtual table. It is only - ** valid to call this function from within the xCreate() or xConnect() of a - ** virtual table module. - */ - static int sqlite3_declare_vtab(sqlite3 db, string zCreateTable) { - Parse pParse; - - int rc = SQLITE_OK; - Table pTab; - string zErr = ""; - - sqlite3_mutex_enter(db.mutex); - if (null == db.pVtabCtx || null == (pTab = db.pVtabCtx.pTab)) { - sqlite3Error(db, SQLITE_MISUSE, 0); - sqlite3_mutex_leave(db.mutex); - return SQLITE_MISUSE_BKPT(); - } - Debug.Assert((pTab.tabFlags & TF_Virtual) != 0); - - pParse = new Parse();//sqlite3StackAllocZero(db, sizeof(*pParse)); - //if ( pParse == null ) - //{ - // rc = SQLITE_NOMEM; - //} - //else - { - pParse.declareVtab = 1; - pParse.db = db; - pParse.nQueryLoop = 1; - - if (SQLITE_OK == sqlite3RunParser(pParse, zCreateTable, ref zErr) - && pParse.pNewTable != null - //&& !db.mallocFailed - && null == pParse.pNewTable.pSelect - && (pParse.pNewTable.tabFlags & TF_Virtual) == 0 - ) { - if (null == pTab.aCol) { - pTab.aCol = pParse.pNewTable.aCol; - pTab.nCol = pParse.pNewTable.nCol; - pParse.pNewTable.nCol = 0; - pParse.pNewTable.aCol = null; - } - db.pVtabCtx.pTab = null; - } else { - sqlite3Error(db, SQLITE_ERROR, (zErr != null ? "%s" : null), zErr); - zErr = null;//sqlite3DbFree( db, zErr ); - rc = SQLITE_ERROR; - } - pParse.declareVtab = 0; + return rc; + } + /* + ** Grow the db.aVTrans[] array so that there is room for at least one + ** more v-table. Return SQLITE_NOMEM if a malloc fails, or SQLITE_OK otherwise. + */ + static int growVTrans( sqlite3 db ) + { + const int ARRAY_INCR = 5; + + /* Grow the sqlite3.aVTrans array if required */ + if ( ( db.nVTrans % ARRAY_INCR ) == 0 ) + { + //VTable** aVTrans; + //int nBytes = sizeof( sqlite3_vtab* ) * ( db.nVTrans + ARRAY_INCR ); + //aVTrans = sqlite3DbRealloc( db, (void)db.aVTrans, nBytes ); + //if ( !aVTrans ) + //{ + // return SQLITE_NOMEM; + //} + //memset( &aVTrans[db.nVTrans], 0, sizeof( sqlite3_vtab* ) * ARRAY_INCR ); + Array.Resize( ref db.aVTrans, db.nVTrans + ARRAY_INCR ); + } + + return SQLITE_OK; + } - if (pParse.pVdbe != null) { - sqlite3VdbeFinalize(ref pParse.pVdbe); - } - sqlite3DeleteTable(db, ref pParse.pNewTable); - //sqlite3StackFree( db, pParse ); - } + /* + ** Add the virtual table pVTab to the array sqlite3.aVTrans[]. Space should + ** have already been reserved using growVTrans(). + */ + static void addToVTrans( sqlite3 db, VTable pVTab ) + { + /* Add pVtab to the end of sqlite3.aVTrans */ + db.aVTrans[db.nVTrans++] = pVTab; + sqlite3VtabLock( pVTab ); + } - Debug.Assert((rc & 0xff) == rc); - rc = sqlite3ApiExit(db, rc); - sqlite3_mutex_leave(db.mutex); - return rc; + /* + ** This function is invoked by the vdbe to call the xCreate method + ** of the virtual table named zTab in database iDb. + ** + ** If an error occurs, *pzErr is set to point an an English language + ** description of the error and an SQLITE_XXX error code is returned. + ** In this case the caller must call sqlite3DbFree(db, ) on *pzErr. + */ + static int sqlite3VtabCallCreate( sqlite3 db, int iDb, string zTab, ref string pzErr ) + { + int rc = SQLITE_OK; + Table pTab; + Module pMod; + string zMod; + + pTab = sqlite3FindTable( db, zTab, db.aDb[iDb].zName ); + Debug.Assert( pTab != null && ( pTab.tabFlags & TF_Virtual ) != 0 && null == pTab.pVTable ); + + /* Locate the required virtual table module */ + zMod = pTab.azModuleArg[0]; + pMod = (Module)sqlite3HashFind( db.aModule, zMod, sqlite3Strlen30( zMod ), (Module)null ); + + /* If the module has been registered and includes a Create method, + ** invoke it now. If the module has not been registered, return an + ** error. Otherwise, do nothing. + */ + if ( null == pMod ) + { + pzErr = sqlite3MPrintf( db, "no such module: %s", zMod ); + rc = SQLITE_ERROR; + } + else + { + rc = vtabCallConstructor( db, pTab, pMod, pMod.pModule.xCreate, ref pzErr ); + } + + /* Justification of ALWAYS(): The xConstructor method is required to + ** create a valid sqlite3_vtab if it returns SQLITE_OK. */ + if ( rc == SQLITE_OK && ALWAYS( sqlite3GetVTable( db, pTab ) ) ) + { + rc = growVTrans( db ); + if ( rc == SQLITE_OK ) + { + addToVTrans( db, sqlite3GetVTable( db, pTab ) ); } + } - /* - ** This function is invoked by the vdbe to call the xDestroy method - ** of the virtual table named zTab in database iDb. This occurs - ** when a DROP TABLE is mentioned. - ** - ** This call is a no-op if zTab is not a virtual table. - */ - static int sqlite3VtabCallDestroy(sqlite3 db, int iDb, string zTab) { - int rc = SQLITE_OK; - Table pTab; - - pTab = sqlite3FindTable(db, zTab, db.aDb[iDb].zName); - if (ALWAYS(pTab != null && pTab.pVTable != null)) { - VTable p = vtabDisconnectAll(db, pTab); - - Debug.Assert(rc == SQLITE_OK); - object obj = p.pVtab; - rc = p.pMod.pModule.xDestroy(ref obj); - p.pVtab = null; - - /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */ - if (rc == SQLITE_OK) { - Debug.Assert(pTab.pVTable == p && p.pNext == null); - p.pVtab = null; - pTab.pVTable = null; - sqlite3VtabUnlock(p); - } - } + return rc; + } - return rc; + /* + ** This function is used to set the schema of a virtual table. It is only + ** valid to call this function from within the xCreate() or xConnect() of a + ** virtual table module. + */ + static int sqlite3_declare_vtab( sqlite3 db, string zCreateTable ) + { + Parse pParse; + + int rc = SQLITE_OK; + Table pTab; + string zErr = ""; + + sqlite3_mutex_enter( db.mutex ); + if ( null == db.pVtabCtx || null == ( pTab = db.pVtabCtx.pTab ) ) + { + sqlite3Error( db, SQLITE_MISUSE, 0 ); + sqlite3_mutex_leave( db.mutex ); + return SQLITE_MISUSE_BKPT(); + } + Debug.Assert( ( pTab.tabFlags & TF_Virtual ) != 0 ); + + pParse = new Parse();//sqlite3StackAllocZero(db, sizeof(*pParse)); + //if ( pParse == null ) + //{ + // rc = SQLITE_NOMEM; + //} + //else + { + pParse.declareVtab = 1; + pParse.db = db; + pParse.nQueryLoop = 1; + + if ( SQLITE_OK == sqlite3RunParser( pParse, zCreateTable, ref zErr ) + && pParse.pNewTable != null + //&& !db.mallocFailed + && null==pParse.pNewTable.pSelect + && ( pParse.pNewTable.tabFlags & TF_Virtual ) == 0 + ) + { + if ( null==pTab.aCol ) + { + pTab.aCol = pParse.pNewTable.aCol; + pTab.nCol = pParse.pNewTable.nCol; + pParse.pNewTable.nCol = 0; + pParse.pNewTable.aCol = null; + } + db.pVtabCtx.pTab = null; } - - /* - ** This function invokes either the xRollback or xCommit method - ** of each of the virtual tables in the sqlite3.aVTrans array. The method - ** called is identified by the second argument, "offset", which is - ** the offset of the method to call in the sqlite3_module structure. - ** - ** The array is cleared after invoking the callbacks. - */ - static void callFinaliser(sqlite3 db, int offset) { - int i; - if (db.aVTrans != null) { - for (i = 0; i < db.nVTrans; i++) { - VTable pVTab = db.aVTrans[i]; - sqlite3_vtab p = pVTab.pVtab; - if (p != null) { - //int (*x)(sqlite3_vtab ); - //x = *(int (*)(sqlite3_vtab ))((char )p.pModule + offset); - //if( x ) x(p); - if (offset == 0) { - if (p.pModule.xCommit != null) - p.pModule.xCommit(p); - } else { - if (p.pModule.xRollback != null) - p.pModule.xRollback(p); - } - } - pVTab.iSavepoint = 0; - sqlite3VtabUnlock(pVTab); - } - sqlite3DbFree(db, ref db.aVTrans); - db.nVTrans = 0; - db.aVTrans = null; - } + else + { + sqlite3Error( db, SQLITE_ERROR, ( zErr != null ? "%s" : null ), zErr ); + zErr = null;//sqlite3DbFree( db, zErr ); + rc = SQLITE_ERROR; } + pParse.declareVtab = 0; - /* - ** Invoke the xSync method of all virtual tables in the sqlite3.aVTrans - ** array. Return the error code for the first error that occurs, or - ** SQLITE_OK if all xSync operations are successful. - ** - ** Set *pzErrmsg to point to a buffer that should be released using - ** sqlite3DbFree() containing an error message, if one is available. - */ - static int sqlite3VtabSync(sqlite3 db, ref string pzErrmsg) { - int i; - int rc = SQLITE_OK; - VTable[] aVTrans = db.aVTrans; - - db.aVTrans = null; - for (i = 0; rc == SQLITE_OK && i < db.nVTrans; i++) { - smdxFunction x;//int (*x)(sqlite3_vtab ); - sqlite3_vtab pVtab = aVTrans[i].pVtab; - if (pVtab != null && (x = pVtab.pModule.xSync) != null) { - rc = x(pVtab); - //sqlite3DbFree(db, ref pzErrmsg); - pzErrmsg = pVtab.zErrMsg;// sqlite3DbStrDup( db, pVtab.zErrMsg ); - pVtab.zErrMsg = null;//sqlite3_free( ref pVtab.zErrMsg ); - } - } - db.aVTrans = aVTrans; - return rc; + if ( pParse.pVdbe !=null) + { + sqlite3VdbeFinalize( ref pParse.pVdbe ); } + sqlite3DeleteTable( db, ref pParse.pNewTable ); + //sqlite3StackFree( db, pParse ); + } + + Debug.Assert( ( rc & 0xff ) == rc ); + rc = sqlite3ApiExit( db, rc ); + sqlite3_mutex_leave( db.mutex ); + return rc; + } - /* - ** Invoke the xRollback method of all virtual tables in the - ** sqlite3.aVTrans array. Then clear the array itself. - */ - static int sqlite3VtabRollback(sqlite3 db) { - callFinaliser(db, 1);//offsetof( sqlite3_module, xRollback ) ); - return SQLITE_OK; + /* + ** This function is invoked by the vdbe to call the xDestroy method + ** of the virtual table named zTab in database iDb. This occurs + ** when a DROP TABLE is mentioned. + ** + ** This call is a no-op if zTab is not a virtual table. + */ + static int sqlite3VtabCallDestroy( sqlite3 db, int iDb, string zTab ) + { + int rc = SQLITE_OK; + Table pTab; + + pTab = sqlite3FindTable( db, zTab, db.aDb[iDb].zName ); + if ( ALWAYS( pTab != null && pTab.pVTable != null ) ) + { + VTable p = vtabDisconnectAll( db, pTab ); + + Debug.Assert( rc == SQLITE_OK ); + object obj = p.pVtab; + rc = p.pMod.pModule.xDestroy( ref obj ); + p.pVtab = null; + + /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */ + if ( rc == SQLITE_OK ) + { + Debug.Assert( pTab.pVTable == p && p.pNext == null ); + p.pVtab = null; + pTab.pVTable = null; + sqlite3VtabUnlock( p ); } + } - /* - ** Invoke the xCommit method of all virtual tables in the - ** sqlite3.aVTrans array. Then clear the array itself. - */ - static int sqlite3VtabCommit(sqlite3 db) { - callFinaliser(db, 0);//offsetof( sqlite3_module, xCommit ) ); - return SQLITE_OK; - } + return rc; + } - /* - ** If the virtual table pVtab supports the transaction interface - ** (xBegin/xRollback/xCommit and optionally xSync) and a transaction is - ** not currently open, invoke the xBegin method now. - ** - ** If the xBegin call is successful, place the sqlite3_vtab pointer - ** in the sqlite3.aVTrans array. - */ - static int sqlite3VtabBegin(sqlite3 db, VTable pVTab) { - int rc = SQLITE_OK; - sqlite3_module pModule; - - /* Special case: If db.aVTrans is NULL and db.nVTrans is greater - ** than zero, then this function is being called from within a - ** virtual module xSync() callback. It is illegal to write to - ** virtual module tables in this case, so return SQLITE_LOCKED. - */ - if (sqlite3VtabInSync(db)) { - return SQLITE_LOCKED; + /* + ** This function invokes either the xRollback or xCommit method + ** of each of the virtual tables in the sqlite3.aVTrans array. The method + ** called is identified by the second argument, "offset", which is + ** the offset of the method to call in the sqlite3_module structure. + ** + ** The array is cleared after invoking the callbacks. + */ + static void callFinaliser( sqlite3 db, int offset ) + { + int i; + if ( db.aVTrans != null ) + { + for ( i = 0; i < db.nVTrans; i++ ) + { + VTable pVTab = db.aVTrans[i]; + sqlite3_vtab p = pVTab.pVtab; + if ( p != null ) + { + //int (*x)(sqlite3_vtab ); + //x = *(int (*)(sqlite3_vtab ))((char )p.pModule + offset); + //if( x ) x(p); + if ( offset == 0 ) + { + if ( p.pModule.xCommit != null ) + p.pModule.xCommit( p ); } - if (null == pVTab) { - return SQLITE_OK; + else + { + if ( p.pModule.xRollback != null ) + p.pModule.xRollback( p ); } - pModule = pVTab.pVtab.pModule; + } + pVTab.iSavepoint = 0; + sqlite3VtabUnlock( pVTab ); + } + sqlite3DbFree( db, ref db.aVTrans ); + db.nVTrans = 0; + db.aVTrans = null; + } + } - if (pModule.xBegin != null) { - int i; + /* + ** Invoke the xSync method of all virtual tables in the sqlite3.aVTrans + ** array. Return the error code for the first error that occurs, or + ** SQLITE_OK if all xSync operations are successful. + ** + ** Set *pzErrmsg to point to a buffer that should be released using + ** sqlite3DbFree() containing an error message, if one is available. + */ + static int sqlite3VtabSync( sqlite3 db, ref string pzErrmsg ) + { + int i; + int rc = SQLITE_OK; + VTable[] aVTrans = db.aVTrans; + + db.aVTrans = null; + for ( i = 0; rc == SQLITE_OK && i < db.nVTrans; i++ ) + { + smdxFunction x;//int (*x)(sqlite3_vtab ); + sqlite3_vtab pVtab = aVTrans[i].pVtab; + if ( pVtab != null && ( x = pVtab.pModule.xSync ) != null ) + { + rc = x( pVtab ); + //sqlite3DbFree(db, ref pzErrmsg); + pzErrmsg = pVtab.zErrMsg;// sqlite3DbStrDup( db, pVtab.zErrMsg ); + pVtab.zErrMsg = null;//sqlite3_free( ref pVtab.zErrMsg ); + } + } + db.aVTrans = aVTrans; + return rc; + } - /* If pVtab is already in the aVTrans array, return early */ - for (i = 0; i < db.nVTrans; i++) { - if (db.aVTrans[i] == pVTab) { - return SQLITE_OK; - } - } + /* + ** Invoke the xRollback method of all virtual tables in the + ** sqlite3.aVTrans array. Then clear the array itself. + */ + static int sqlite3VtabRollback( sqlite3 db ) + { + callFinaliser( db, 1 );//offsetof( sqlite3_module, xRollback ) ); + return SQLITE_OK; + } - /* Invoke the xBegin method. If successful, add the vtab to the - ** sqlite3.aVTrans[] array. */ - rc = growVTrans(db); - if (rc == SQLITE_OK) { - rc = pModule.xBegin(pVTab.pVtab); - if (rc == SQLITE_OK) { - addToVTrans(db, pVTab); - } - } - } - return rc; - } + /* + ** Invoke the xCommit method of all virtual tables in the + ** sqlite3.aVTrans array. Then clear the array itself. + */ + static int sqlite3VtabCommit( sqlite3 db ) + { + callFinaliser( db, 0 );//offsetof( sqlite3_module, xCommit ) ); + return SQLITE_OK; + } - /* - ** Invoke either the xSavepoint, xRollbackTo or xRelease method of all - ** virtual tables that currently have an open transaction. Pass iSavepoint - ** as the second argument to the virtual table method invoked. - ** - ** If op is SAVEPOINT_BEGIN, the xSavepoint method is invoked. If it is - ** SAVEPOINT_ROLLBACK, the xRollbackTo method. Otherwise, if op is - ** SAVEPOINT_RELEASE, then the xRelease method of each virtual table with - ** an open transaction is invoked. - ** - ** If any virtual table method returns an error code other than SQLITE_OK, - ** processing is abandoned and the error returned to the caller of this - ** function immediately. If all calls to virtual table methods are successful, - ** SQLITE_OK is returned. - */ - static int sqlite3VtabSavepoint(sqlite3 db, int op, int iSavepoint) { - int rc = SQLITE_OK; - - Debug.Assert(op == SAVEPOINT_RELEASE || op == SAVEPOINT_ROLLBACK || op == SAVEPOINT_BEGIN); - Debug.Assert(iSavepoint >= 0); - if (db.aVTrans != null) { - int i; - for (i = 0; rc == SQLITE_OK && i < db.nVTrans; i++) { - VTable pVTab = db.aVTrans[i]; - sqlite3_module pMod = pVTab.pMod.pModule; - if (pMod.iVersion >= 2) { - smdxFunctionArg xMethod = null; //int (*xMethod)(sqlite3_vtab *, int); - switch (op) { - case SAVEPOINT_BEGIN: - xMethod = pMod.xSavepoint; - pVTab.iSavepoint = iSavepoint + 1; - break; - case SAVEPOINT_ROLLBACK: - xMethod = pMod.xRollbackTo; - break; - default: - xMethod = pMod.xRelease; - break; - } - if (xMethod != null && pVTab.iSavepoint > iSavepoint) { - rc = xMethod(db.aVTrans[i].pVtab, iSavepoint); - } - } - } - } - return rc; + /* + ** If the virtual table pVtab supports the transaction interface + ** (xBegin/xRollback/xCommit and optionally xSync) and a transaction is + ** not currently open, invoke the xBegin method now. + ** + ** If the xBegin call is successful, place the sqlite3_vtab pointer + ** in the sqlite3.aVTrans array. + */ + static int sqlite3VtabBegin( sqlite3 db, VTable pVTab ) + { + int rc = SQLITE_OK; + sqlite3_module pModule; + + /* Special case: If db.aVTrans is NULL and db.nVTrans is greater + ** than zero, then this function is being called from within a + ** virtual module xSync() callback. It is illegal to write to + ** virtual module tables in this case, so return SQLITE_LOCKED. + */ + if ( sqlite3VtabInSync( db ) ) + { + return SQLITE_LOCKED; + } + if ( null == pVTab ) + { + return SQLITE_OK; + } + pModule = pVTab.pVtab.pModule; + + if ( pModule.xBegin != null ) + { + int i; + + /* If pVtab is already in the aVTrans array, return early */ + for ( i = 0; i < db.nVTrans; i++ ) + { + if ( db.aVTrans[i] == pVTab ) + { + return SQLITE_OK; + } } - /* - ** The first parameter (pDef) is a function implementation. The - ** second parameter (pExpr) is the first argument to this function. - ** If pExpr is a column in a virtual table, then let the virtual - ** table implementation have an opportunity to overload the function. - ** - ** This routine is used to allow virtual table implementations to - ** overload MATCH, LIKE, GLOB, and REGEXP operators. - ** - ** Return either the pDef argument (indicating no change) or a - ** new FuncDef structure that is marked as ephemeral using the - ** SQLITE_FUNC_EPHEM flag. - */ - static FuncDef sqlite3VtabOverloadFunction( - sqlite3 db, /* Database connection for reporting malloc problems */ - FuncDef pDef, /* Function to possibly overload */ - int nArg, /* Number of arguments to the function */ - Expr pExpr /* First argument to the function */ - ) { - Table pTab; - sqlite3_vtab pVtab; - sqlite3_module pMod; - dxFunc xFunc = null;//void (*xFunc)(sqlite3_context*,int,sqlite3_value*) = 0; - object pArg = null; - FuncDef pNew; - int rc = 0; - string zLowerName; - string z; - - /* Check to see the left operand is a column in a virtual table */ - if (NEVER(pExpr == null)) - return pDef; - if (pExpr.op != TK_COLUMN) - return pDef; - pTab = pExpr.pTab; - if (NEVER(pTab == null)) - return pDef; - if ((pTab.tabFlags & TF_Virtual) == 0) - return pDef; - pVtab = sqlite3GetVTable(db, pTab).pVtab; - Debug.Assert(pVtab != null); - Debug.Assert(pVtab.pModule != null); - pMod = (sqlite3_module)pVtab.pModule; - if (pMod.xFindFunction == null) - return pDef; - - /* Call the xFindFunction method on the virtual table implementation - ** to see if the implementation wants to overload this function - */ - zLowerName = pDef.zName;//sqlite3DbStrDup(db, pDef.zName); - if (zLowerName != null) { - //for(z=(unsigned char)zLowerName; *z; z++){ - // *z = sqlite3UpperToLower[*z]; - //} - rc = pMod.xFindFunction(pVtab, nArg, zLowerName.ToLowerInvariant(), ref xFunc, ref pArg); - sqlite3DbFree(db, ref zLowerName); - } - if (rc == 0) { - return pDef; - } - - /* Create a new ephemeral function definition for the overloaded - ** function */ - //sqlite3DbMallocZero(db, sizeof(*pNew) - // + sqlite3Strlen30(pDef.zName) + 1); - //if ( pNew == null ) - //{ - // return pDef; - //} - pNew = pDef.Copy(); - pNew.zName = pDef.zName; - //pNew.zName = (char )&pNew[1]; - //memcpy(pNew.zName, pDef.zName, sqlite3Strlen30(pDef.zName)+1); - pNew.xFunc = xFunc; - pNew.pUserData = pArg; - pNew.flags |= SQLITE_FUNC_EPHEM; - return pNew; + /* Invoke the xBegin method. If successful, add the vtab to the + ** sqlite3.aVTrans[] array. */ + rc = growVTrans( db ); + if ( rc == SQLITE_OK ) + { + rc = pModule.xBegin( pVTab.pVtab ); + if ( rc == SQLITE_OK ) + { + addToVTrans( db, pVTab ); + } } + } + return rc; + } - /* - ** Make sure virtual table pTab is contained in the pParse.apVirtualLock[] - ** array so that an OP_VBegin will get generated for it. Add pTab to the - ** array if it is missing. If pTab is already in the array, this routine - ** is a no-op. - */ - static void sqlite3VtabMakeWritable(Parse pParse, Table pTab) { - Parse pToplevel = sqlite3ParseToplevel(pParse); - int i, n; - //Table[] apVtabLock = null; - - Debug.Assert(IsVirtual(pTab)); - for (i = 0; i < pToplevel.nVtabLock; i++) { - if (pTab == pToplevel.apVtabLock[i]) - return; + /* + ** Invoke either the xSavepoint, xRollbackTo or xRelease method of all + ** virtual tables that currently have an open transaction. Pass iSavepoint + ** as the second argument to the virtual table method invoked. + ** + ** If op is SAVEPOINT_BEGIN, the xSavepoint method is invoked. If it is + ** SAVEPOINT_ROLLBACK, the xRollbackTo method. Otherwise, if op is + ** SAVEPOINT_RELEASE, then the xRelease method of each virtual table with + ** an open transaction is invoked. + ** + ** If any virtual table method returns an error code other than SQLITE_OK, + ** processing is abandoned and the error returned to the caller of this + ** function immediately. If all calls to virtual table methods are successful, + ** SQLITE_OK is returned. + */ + static int sqlite3VtabSavepoint( sqlite3 db, int op, int iSavepoint ) + { + int rc = SQLITE_OK; + + Debug.Assert( op == SAVEPOINT_RELEASE || op == SAVEPOINT_ROLLBACK || op == SAVEPOINT_BEGIN ); + Debug.Assert( iSavepoint >= 0 ); + if ( db.aVTrans != null ) + { + int i; + for ( i = 0; rc == SQLITE_OK && i < db.nVTrans; i++ ) + { + VTable pVTab = db.aVTrans[i]; + sqlite3_module pMod = pVTab.pMod.pModule; + if ( pMod.iVersion >= 2 ) + { + smdxFunctionArg xMethod = null; //int (*xMethod)(sqlite3_vtab *, int); + switch ( op ) + { + case SAVEPOINT_BEGIN: + xMethod = pMod.xSavepoint; + pVTab.iSavepoint = iSavepoint + 1; + break; + case SAVEPOINT_ROLLBACK: + xMethod = pMod.xRollbackTo; + break; + default: + xMethod = pMod.xRelease; + break; } - n = pToplevel.apVtabLock == null ? 1 : pToplevel.apVtabLock.Length + 1;//(pToplevel.nVtabLock+1)*sizeof(pToplevel.apVtabLock[0]); - //sqlite3_realloc( pToplevel.apVtabLock, n ); - //if ( apVtabLock != null ) + if ( xMethod != null && pVTab.iSavepoint > iSavepoint ) { - Array.Resize(ref pToplevel.apVtabLock, n);// pToplevel.apVtabLock= apVtabLock; - pToplevel.apVtabLock[pToplevel.nVtabLock++] = pTab; + rc = xMethod( db.aVTrans[i].pVtab, iSavepoint ); } - //else - //{ - // pToplevel.db.mallocFailed = 1; - //} + } } + } + return rc; + } - static int[] aMap = new int[] { - SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE + /* + ** The first parameter (pDef) is a function implementation. The + ** second parameter (pExpr) is the first argument to this function. + ** If pExpr is a column in a virtual table, then let the virtual + ** table implementation have an opportunity to overload the function. + ** + ** This routine is used to allow virtual table implementations to + ** overload MATCH, LIKE, GLOB, and REGEXP operators. + ** + ** Return either the pDef argument (indicating no change) or a + ** new FuncDef structure that is marked as ephemeral using the + ** SQLITE_FUNC_EPHEM flag. + */ + static FuncDef sqlite3VtabOverloadFunction( + sqlite3 db, /* Database connection for reporting malloc problems */ + FuncDef pDef, /* Function to possibly overload */ + int nArg, /* Number of arguments to the function */ + Expr pExpr /* First argument to the function */ + ) + { + Table pTab; + sqlite3_vtab pVtab; + sqlite3_module pMod; + dxFunc xFunc = null;//void (*xFunc)(sqlite3_context*,int,sqlite3_value*) = 0; + object pArg = null; + FuncDef pNew; + int rc = 0; + string zLowerName; + string z; + + /* Check to see the left operand is a column in a virtual table */ + if ( NEVER( pExpr == null ) ) + return pDef; + if ( pExpr.op != TK_COLUMN ) + return pDef; + pTab = pExpr.pTab; + if ( NEVER( pTab == null ) ) + return pDef; + if ( ( pTab.tabFlags & TF_Virtual ) == 0 ) + return pDef; + pVtab = sqlite3GetVTable( db, pTab ).pVtab; + Debug.Assert( pVtab != null ); + Debug.Assert( pVtab.pModule != null ); + pMod = (sqlite3_module)pVtab.pModule; + if ( pMod.xFindFunction == null ) + return pDef; + + /* Call the xFindFunction method on the virtual table implementation + ** to see if the implementation wants to overload this function + */ + zLowerName = pDef.zName;//sqlite3DbStrDup(db, pDef.zName); + if ( zLowerName != null ) + { + //for(z=(unsigned char)zLowerName; *z; z++){ + // *z = sqlite3UpperToLower[*z]; + //} + rc = pMod.xFindFunction( pVtab, nArg, zLowerName.ToLowerInvariant(), ref xFunc, ref pArg ); + sqlite3DbFree( db, ref zLowerName ); + } + if ( rc == 0 ) + { + return pDef; + } + + /* Create a new ephemeral function definition for the overloaded + ** function */ + //sqlite3DbMallocZero(db, sizeof(*pNew) + // + sqlite3Strlen30(pDef.zName) + 1); + //if ( pNew == null ) + //{ + // return pDef; + //} + pNew = pDef.Copy(); + pNew.zName = pDef.zName; + //pNew.zName = (char )&pNew[1]; + //memcpy(pNew.zName, pDef.zName, sqlite3Strlen30(pDef.zName)+1); + pNew.xFunc = xFunc; + pNew.pUserData = pArg; + pNew.flags |= SQLITE_FUNC_EPHEM; + return pNew; + } + + /* + ** Make sure virtual table pTab is contained in the pParse.apVirtualLock[] + ** array so that an OP_VBegin will get generated for it. Add pTab to the + ** array if it is missing. If pTab is already in the array, this routine + ** is a no-op. + */ + static void sqlite3VtabMakeWritable( Parse pParse, Table pTab ) + { + Parse pToplevel = sqlite3ParseToplevel( pParse ); + int i, n; + //Table[] apVtabLock = null; + + Debug.Assert( IsVirtual( pTab ) ); + for ( i = 0; i < pToplevel.nVtabLock; i++ ) + { + if ( pTab == pToplevel.apVtabLock[i] ) + return; + } + n = pToplevel.apVtabLock == null ? 1 : pToplevel.apVtabLock.Length + 1;//(pToplevel.nVtabLock+1)*sizeof(pToplevel.apVtabLock[0]); + //sqlite3_realloc( pToplevel.apVtabLock, n ); + //if ( apVtabLock != null ) + { + Array.Resize( ref pToplevel.apVtabLock, n );// pToplevel.apVtabLock= apVtabLock; + pToplevel.apVtabLock[pToplevel.nVtabLock++] = pTab; + } + //else + //{ + // pToplevel.db.mallocFailed = 1; + //} + } + + static int[] aMap = new int[] { + SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE }; - /* - ** Return the ON CONFLICT resolution mode in effect for the virtual - ** table update operation currently in progress. - ** - ** The results of this routine are undefined unless it is called from - ** within an xUpdate method. - */ - static int sqlite3_vtab_on_conflict(sqlite3 db) { - //static const unsigned char aMap[] = { - // SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE - //}; - Debug.Assert(OE_Rollback == 1 && OE_Abort == 2 && OE_Fail == 3); - Debug.Assert(OE_Ignore == 4 && OE_Replace == 5); - Debug.Assert(db.vtabOnConflict >= 1 && db.vtabOnConflict <= 5); - return (int)aMap[db.vtabOnConflict - 1]; - } + /* + ** Return the ON CONFLICT resolution mode in effect for the virtual + ** table update operation currently in progress. + ** + ** The results of this routine are undefined unless it is called from + ** within an xUpdate method. + */ + static int sqlite3_vtab_on_conflict( sqlite3 db ){ + //static const unsigned char aMap[] = { + // SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE + //}; + Debug.Assert( OE_Rollback==1 && OE_Abort==2 && OE_Fail==3 ); + Debug.Assert( OE_Ignore==4 && OE_Replace==5 ); + Debug.Assert( db.vtabOnConflict>=1 && db.vtabOnConflict<=5 ); + return (int)aMap[db.vtabOnConflict-1]; +} - /* - ** Call from within the xCreate() or xConnect() methods to provide - ** the SQLite core with additional information about the behavior - ** of the virtual table being implemented. - */ - static int sqlite3_vtab_config(sqlite3 db, int op, params object[] ap) { // TODO ...){ - //va_list ap; - int rc = SQLITE_OK; - - sqlite3_mutex_enter(db.mutex); - - va_start(ap, "op"); - switch (op) { - case SQLITE_VTAB_CONSTRAINT_SUPPORT: { - VtabCtx p = db.pVtabCtx; - if (null == p) { - rc = SQLITE_MISUSE_BKPT(); - } else { - Debug.Assert(p.pTab == null || (p.pTab.tabFlags & TF_Virtual) != 0); - p.pVTable.bConstraint = (Byte)va_arg(ap, (Int32)0); - } - break; - } - default: - rc = SQLITE_MISUSE_BKPT(); - break; - } - va_end(ref ap); + /* + ** Call from within the xCreate() or xConnect() methods to provide + ** the SQLite core with additional information about the behavior + ** of the virtual table being implemented. + */ + static int sqlite3_vtab_config( sqlite3 db, int op, params object[] ap ){ // TODO ...){ + //va_list ap; + int rc = SQLITE_OK; + + sqlite3_mutex_enter(db.mutex); + + va_start(ap, "op"); + switch( op ){ + case SQLITE_VTAB_CONSTRAINT_SUPPORT: { + VtabCtx p = db.pVtabCtx; + if( null == p ){ + rc = SQLITE_MISUSE_BKPT(); + }else{ + Debug.Assert( p.pTab == null || ( p.pTab.tabFlags & TF_Virtual ) != 0 ); + p.pVTable.bConstraint = (Byte)va_arg(ap, (Int32)0); + } + break; + } + default: + rc = SQLITE_MISUSE_BKPT(); + break; + } + va_end(ref ap); - if (rc != SQLITE_OK) sqlite3Error(db, rc, 0); - sqlite3_mutex_leave(db.mutex); - return rc; - } + if( rc!=SQLITE_OK ) sqlite3Error(db, rc, 0); + sqlite3_mutex_leave(db.mutex); + return rc; +} #endif //* SQLITE_OMIT_VIRTUALTABLE */ - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/wal_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/wal_c.cs index abea4175f..00db88b42 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/wal_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/wal_c.cs @@ -1,253 +1,262 @@ -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2010 February 1 - ** - ** 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 contains the implementation of a write-ahead log (WAL) used in - ** "journal_mode=WAL" mode. - ** - ** WRITE-AHEAD LOG (WAL) FILE FORMAT - ** - ** A WAL file consists of a header followed by zero or more "frames". - ** Each frame records the revised content of a single page from the - ** database file. All changes to the database are recorded by writing - ** frames into the WAL. Transactions commit when a frame is written that - ** contains a commit marker. A single WAL can and usually does record - ** multiple transactions. Periodically, the content of the WAL is - ** transferred back into the database file in an operation called a - ** "checkpoint". - ** - ** A single WAL file can be used multiple times. In other words, the - ** WAL can fill up with frames and then be checkpointed and then new - ** frames can overwrite the old ones. A WAL always grows from beginning - ** toward the end. Checksums and counters attached to each frame are - ** used to determine which frames within the WAL are valid and which - ** are leftovers from prior checkpoints. - ** - ** The WAL header is 32 bytes in size and consists of the following eight - ** big-endian 32-bit unsigned integer values: - ** - ** 0: Magic number. 0x377f0682 or 0x377f0683 - ** 4: File format version. Currently 3007000 - ** 8: Database page size. Example: 1024 - ** 12: Checkpoint sequence number - ** 16: Salt-1, random integer incremented with each checkpoint - ** 20: Salt-2, a different random integer changing with each ckpt - ** 24: Checksum-1 (first part of checksum for first 24 bytes of header). - ** 28: Checksum-2 (second part of checksum for first 24 bytes of header). - ** - ** Immediately following the wal-header are zero or more frames. Each - ** frame consists of a 24-byte frame-header followed by a bytes - ** of page data. The frame-header is six big-endian 32-bit unsigned - ** integer values, as follows: - ** - ** 0: Page number. - ** 4: For commit records, the size of the database image in pages - ** after the commit. For all other records, zero. - ** 8: Salt-1 (copied from the header) - ** 12: Salt-2 (copied from the header) - ** 16: Checksum-1. - ** 20: Checksum-2. - ** - ** A frame is considered valid if and only if the following conditions are - ** true: - ** - ** (1) The salt-1 and salt-2 values in the frame-header match - ** salt values in the wal-header - ** - ** (2) The checksum values in the final 8 bytes of the frame-header - ** exactly match the checksum computed consecutively on the - ** WAL header and the first 8 bytes and the content of all frames - ** up to and including the current frame. - ** - ** The checksum is computed using 32-bit big-endian integers if the - ** magic number in the first 4 bytes of the WAL is 0x377f0683 and it - ** is computed using little-endian if the magic number is 0x377f0682. - ** The checksum values are always stored in the frame header in a - ** big-endian format regardless of which byte order is used to compute - ** the checksum. The checksum is computed by interpreting the input as - ** an even number of unsigned 32-bit integers: x[0] through x[N]. The - ** algorithm used for the checksum is as follows: - ** - ** for i from 0 to n-1 step 2: - ** s0 += x[i] + s1; - ** s1 += x[i+1] + s0; - ** endfor - ** - ** Note that s0 and s1 are both weighted checksums using fibonacci weights - ** in reverse order (the largest fibonacci weight occurs on the first element - ** of the sequence being summed.) The s1 value spans all 32-bit - ** terms of the sequence whereas s0 omits the final term. - ** - ** On a checkpoint, the WAL is first VFS.xSync-ed, then valid content of the - ** WAL is transferred into the database, then the database is VFS.xSync-ed. - ** The VFS.xSync operations serve as write barriers - all writes launched - ** before the xSync must complete before any write that launches after the - ** xSync begins. - ** - ** After each checkpoint, the salt-1 value is incremented and the salt-2 - ** value is randomized. This prevents old and new frames in the WAL from - ** being considered valid at the same time and being checkpointing together - ** following a crash. - ** - ** READER ALGORITHM - ** - ** To read a page from the database (call it page number P), a reader - ** first checks the WAL to see if it contains page P. If so, then the - ** last valid instance of page P that is a followed by a commit frame - ** or is a commit frame itself becomes the value read. If the WAL - ** contains no copies of page P that are valid and which are a commit - ** frame or are followed by a commit frame, then page P is read from - ** the database file. - ** - ** To start a read transaction, the reader records the index of the last - ** valid frame in the WAL. The reader uses this recorded "mxFrame" value - ** for all subsequent read operations. New transactions can be appended - ** to the WAL, but as long as the reader uses its original mxFrame value - ** and ignores the newly appended content, it will see a consistent snapshot - ** of the database from a single point in time. This technique allows - ** multiple concurrent readers to view different versions of the database - ** content simultaneously. - ** - ** The reader algorithm in the previous paragraphs works correctly, but - ** because frames for page P can appear anywhere within the WAL, the - ** reader has to scan the entire WAL looking for page P frames. If the - ** WAL is large (multiple megabytes is typical) that scan can be slow, - ** and read performance suffers. To overcome this problem, a separate - ** data structure called the wal-index is maintained to expedite the - ** search for frames of a particular page. - ** - ** WAL-INDEX FORMAT - ** - ** Conceptually, the wal-index is shared memory, though VFS implementations - ** might choose to implement the wal-index using a mmapped file. Because - ** the wal-index is shared memory, SQLite does not support journal_mode=WAL - ** on a network filesystem. All users of the database must be able to - ** share memory. - ** - ** The wal-index is transient. After a crash, the wal-index can (and should - ** be) reconstructed from the original WAL file. In fact, the VFS is required - ** to either truncate or zero the header of the wal-index when the last - ** connection to it closes. Because the wal-index is transient, it can - ** use an architecture-specific format; it does not have to be cross-platform. - ** Hence, unlike the database and WAL file formats which store all values - ** as big endian, the wal-index can store multi-byte values in the native - ** byte order of the host computer. - ** - ** The purpose of the wal-index is to answer this question quickly: Given - ** a page number P, return the index of the last frame for page P in the WAL, - ** or return NULL if there are no frames for page P in the WAL. - ** - ** The wal-index consists of a header region, followed by an one or - ** more index blocks. - ** - ** The wal-index header contains the total number of frames within the WAL - ** in the the mxFrame field. - ** - ** Each index block except for the first contains information on - ** HASHTABLE_NPAGE frames. The first index block contains information on - ** HASHTABLE_NPAGE_ONE frames. The values of HASHTABLE_NPAGE_ONE and - ** HASHTABLE_NPAGE are selected so that together the wal-index header and - ** first index block are the same size as all other index blocks in the - ** wal-index. - ** - ** Each index block contains two sections, a page-mapping that contains the - ** database page number associated with each wal frame, and a hash-table - ** that allows readers to query an index block for a specific page number. - ** The page-mapping is an array of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE - ** for the first index block) 32-bit page numbers. The first entry in the - ** first index-block contains the database page number corresponding to the - ** first frame in the WAL file. The first entry in the second index block - ** in the WAL file corresponds to the (HASHTABLE_NPAGE_ONE+1)th frame in - ** the log, and so on. - ** - ** The last index block in a wal-index usually contains less than the full - ** complement of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE) page-numbers, - ** depending on the contents of the WAL file. This does not change the - ** allocated size of the page-mapping array - the page-mapping array merely - ** contains unused entries. - ** - ** Even without using the hash table, the last frame for page P - ** can be found by scanning the page-mapping sections of each index block - ** starting with the last index block and moving toward the first, and - ** within each index block, starting at the end and moving toward the - ** beginning. The first entry that equals P corresponds to the frame - ** holding the content for that page. - ** - ** The hash table consists of HASHTABLE_NSLOT 16-bit unsigned integers. - ** HASHTABLE_NSLOT = 2*HASHTABLE_NPAGE, and there is one entry in the - ** hash table for each page number in the mapping section, so the hash - ** table is never more than half full. The expected number of collisions - ** prior to finding a match is 1. Each entry of the hash table is an - ** 1-based index of an entry in the mapping section of the same - ** index block. Let K be the 1-based index of the largest entry in - ** the mapping section. (For index blocks other than the last, K will - ** always be exactly HASHTABLE_NPAGE (4096) and for the last index block - ** K will be (mxFrame%HASHTABLE_NPAGE).) Unused slots of the hash table - ** contain a value of 0. - ** - ** To look for page P in the hash table, first compute a hash iKey on - ** P as follows: - ** - ** iKey = (P * 383) % HASHTABLE_NSLOT - ** - ** Then start scanning entries of the hash table, starting with iKey - ** (wrapping around to the beginning when the end of the hash table is - ** reached) until an unused hash slot is found. Let the first unused slot - ** be at index iUnused. (iUnused might be less than iKey if there was - ** wrap-around.) Because the hash table is never more than half full, - ** the search is guaranteed to eventually hit an unused entry. Let - ** iMax be the value between iKey and iUnused, closest to iUnused, - ** where aHash[iMax]==P. If there is no iMax entry (if there exists - ** no hash slot such that aHash[i]==p) then page P is not in the - ** current index block. Otherwise the iMax-th mapping entry of the - ** current index block corresponds to the last entry that references - ** page P. - ** - ** A hash search begins with the last index block and moves toward the - ** first index block, looking for entries corresponding to page P. On - ** average, only two or three slots in each index block need to be - ** examined in order to either find the last entry for page P, or to - ** establish that no such entry exists in the block. Each index block - ** holds over 4000 entries. So two or three index blocks are sufficient - ** to cover a typical 10 megabyte WAL file, assuming 1K pages. 8 or 10 - ** comparisons (on average) suffice to either locate a frame in the - ** WAL or to establish that the frame does not exist in the WAL. This - ** is much faster than scanning the entire 10MB WAL. - ** - ** Note that entries are added in order of increasing K. Hence, one - ** reader might be using some value K0 and a second reader that started - ** at a later time (after additional transactions were added to the WAL - ** and to the wal-index) might be using a different value K1, where K1>K0. - ** Both readers can use the same hash table and mapping section to get - ** the correct result. There may be entries in the hash table with - ** K>K0 but to the first reader, those entries will appear to be unused - ** slots in the hash table and so the first reader will get an answer as - ** if no values greater than K0 had ever been inserted into the hash table - ** in the first place - which is what reader one wants. Meanwhile, the - ** second reader using K1 will see additional values that were inserted - ** later, which is exactly what reader two wants. - ** - ** When a rollback occurs, the value of K is decreased. Hash table entries - ** that correspond to frames greater than the new K value are removed - ** from the hash table at this point. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ +using System; +using System.Diagnostics; +using System.Text; + +using Bitmask = System.UInt64; +using u32 = System.UInt32; + +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 2010 February 1 + ** + ** 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 contains the implementation of a write-ahead log (WAL) used in + ** "journal_mode=WAL" mode. + ** + ** WRITE-AHEAD LOG (WAL) FILE FORMAT + ** + ** A WAL file consists of a header followed by zero or more "frames". + ** Each frame records the revised content of a single page from the + ** database file. All changes to the database are recorded by writing + ** frames into the WAL. Transactions commit when a frame is written that + ** contains a commit marker. A single WAL can and usually does record + ** multiple transactions. Periodically, the content of the WAL is + ** transferred back into the database file in an operation called a + ** "checkpoint". + ** + ** A single WAL file can be used multiple times. In other words, the + ** WAL can fill up with frames and then be checkpointed and then new + ** frames can overwrite the old ones. A WAL always grows from beginning + ** toward the end. Checksums and counters attached to each frame are + ** used to determine which frames within the WAL are valid and which + ** are leftovers from prior checkpoints. + ** + ** The WAL header is 32 bytes in size and consists of the following eight + ** big-endian 32-bit unsigned integer values: + ** + ** 0: Magic number. 0x377f0682 or 0x377f0683 + ** 4: File format version. Currently 3007000 + ** 8: Database page size. Example: 1024 + ** 12: Checkpoint sequence number + ** 16: Salt-1, random integer incremented with each checkpoint + ** 20: Salt-2, a different random integer changing with each ckpt + ** 24: Checksum-1 (first part of checksum for first 24 bytes of header). + ** 28: Checksum-2 (second part of checksum for first 24 bytes of header). + ** + ** Immediately following the wal-header are zero or more frames. Each + ** frame consists of a 24-byte frame-header followed by a bytes + ** of page data. The frame-header is six big-endian 32-bit unsigned + ** integer values, as follows: + ** + ** 0: Page number. + ** 4: For commit records, the size of the database image in pages + ** after the commit. For all other records, zero. + ** 8: Salt-1 (copied from the header) + ** 12: Salt-2 (copied from the header) + ** 16: Checksum-1. + ** 20: Checksum-2. + ** + ** A frame is considered valid if and only if the following conditions are + ** true: + ** + ** (1) The salt-1 and salt-2 values in the frame-header match + ** salt values in the wal-header + ** + ** (2) The checksum values in the final 8 bytes of the frame-header + ** exactly match the checksum computed consecutively on the + ** WAL header and the first 8 bytes and the content of all frames + ** up to and including the current frame. + ** + ** The checksum is computed using 32-bit big-endian integers if the + ** magic number in the first 4 bytes of the WAL is 0x377f0683 and it + ** is computed using little-endian if the magic number is 0x377f0682. + ** The checksum values are always stored in the frame header in a + ** big-endian format regardless of which byte order is used to compute + ** the checksum. The checksum is computed by interpreting the input as + ** an even number of unsigned 32-bit integers: x[0] through x[N]. The + ** algorithm used for the checksum is as follows: + ** + ** for i from 0 to n-1 step 2: + ** s0 += x[i] + s1; + ** s1 += x[i+1] + s0; + ** endfor + ** + ** Note that s0 and s1 are both weighted checksums using fibonacci weights + ** in reverse order (the largest fibonacci weight occurs on the first element + ** of the sequence being summed.) The s1 value spans all 32-bit + ** terms of the sequence whereas s0 omits the final term. + ** + ** On a checkpoint, the WAL is first VFS.xSync-ed, then valid content of the + ** WAL is transferred into the database, then the database is VFS.xSync-ed. + ** The VFS.xSync operations serve as write barriers - all writes launched + ** before the xSync must complete before any write that launches after the + ** xSync begins. + ** + ** After each checkpoint, the salt-1 value is incremented and the salt-2 + ** value is randomized. This prevents old and new frames in the WAL from + ** being considered valid at the same time and being checkpointing together + ** following a crash. + ** + ** READER ALGORITHM + ** + ** To read a page from the database (call it page number P), a reader + ** first checks the WAL to see if it contains page P. If so, then the + ** last valid instance of page P that is a followed by a commit frame + ** or is a commit frame itself becomes the value read. If the WAL + ** contains no copies of page P that are valid and which are a commit + ** frame or are followed by a commit frame, then page P is read from + ** the database file. + ** + ** To start a read transaction, the reader records the index of the last + ** valid frame in the WAL. The reader uses this recorded "mxFrame" value + ** for all subsequent read operations. New transactions can be appended + ** to the WAL, but as long as the reader uses its original mxFrame value + ** and ignores the newly appended content, it will see a consistent snapshot + ** of the database from a single point in time. This technique allows + ** multiple concurrent readers to view different versions of the database + ** content simultaneously. + ** + ** The reader algorithm in the previous paragraphs works correctly, but + ** because frames for page P can appear anywhere within the WAL, the + ** reader has to scan the entire WAL looking for page P frames. If the + ** WAL is large (multiple megabytes is typical) that scan can be slow, + ** and read performance suffers. To overcome this problem, a separate + ** data structure called the wal-index is maintained to expedite the + ** search for frames of a particular page. + ** + ** WAL-INDEX FORMAT + ** + ** Conceptually, the wal-index is shared memory, though VFS implementations + ** might choose to implement the wal-index using a mmapped file. Because + ** the wal-index is shared memory, SQLite does not support journal_mode=WAL + ** on a network filesystem. All users of the database must be able to + ** share memory. + ** + ** The wal-index is transient. After a crash, the wal-index can (and should + ** be) reconstructed from the original WAL file. In fact, the VFS is required + ** to either truncate or zero the header of the wal-index when the last + ** connection to it closes. Because the wal-index is transient, it can + ** use an architecture-specific format; it does not have to be cross-platform. + ** Hence, unlike the database and WAL file formats which store all values + ** as big endian, the wal-index can store multi-byte values in the native + ** byte order of the host computer. + ** + ** The purpose of the wal-index is to answer this question quickly: Given + ** a page number P, return the index of the last frame for page P in the WAL, + ** or return NULL if there are no frames for page P in the WAL. + ** + ** The wal-index consists of a header region, followed by an one or + ** more index blocks. + ** + ** The wal-index header contains the total number of frames within the WAL + ** in the the mxFrame field. + ** + ** Each index block except for the first contains information on + ** HASHTABLE_NPAGE frames. The first index block contains information on + ** HASHTABLE_NPAGE_ONE frames. The values of HASHTABLE_NPAGE_ONE and + ** HASHTABLE_NPAGE are selected so that together the wal-index header and + ** first index block are the same size as all other index blocks in the + ** wal-index. + ** + ** Each index block contains two sections, a page-mapping that contains the + ** database page number associated with each wal frame, and a hash-table + ** that allows readers to query an index block for a specific page number. + ** The page-mapping is an array of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE + ** for the first index block) 32-bit page numbers. The first entry in the + ** first index-block contains the database page number corresponding to the + ** first frame in the WAL file. The first entry in the second index block + ** in the WAL file corresponds to the (HASHTABLE_NPAGE_ONE+1)th frame in + ** the log, and so on. + ** + ** The last index block in a wal-index usually contains less than the full + ** complement of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE) page-numbers, + ** depending on the contents of the WAL file. This does not change the + ** allocated size of the page-mapping array - the page-mapping array merely + ** contains unused entries. + ** + ** Even without using the hash table, the last frame for page P + ** can be found by scanning the page-mapping sections of each index block + ** starting with the last index block and moving toward the first, and + ** within each index block, starting at the end and moving toward the + ** beginning. The first entry that equals P corresponds to the frame + ** holding the content for that page. + ** + ** The hash table consists of HASHTABLE_NSLOT 16-bit unsigned integers. + ** HASHTABLE_NSLOT = 2*HASHTABLE_NPAGE, and there is one entry in the + ** hash table for each page number in the mapping section, so the hash + ** table is never more than half full. The expected number of collisions + ** prior to finding a match is 1. Each entry of the hash table is an + ** 1-based index of an entry in the mapping section of the same + ** index block. Let K be the 1-based index of the largest entry in + ** the mapping section. (For index blocks other than the last, K will + ** always be exactly HASHTABLE_NPAGE (4096) and for the last index block + ** K will be (mxFrame%HASHTABLE_NPAGE).) Unused slots of the hash table + ** contain a value of 0. + ** + ** To look for page P in the hash table, first compute a hash iKey on + ** P as follows: + ** + ** iKey = (P * 383) % HASHTABLE_NSLOT + ** + ** Then start scanning entries of the hash table, starting with iKey + ** (wrapping around to the beginning when the end of the hash table is + ** reached) until an unused hash slot is found. Let the first unused slot + ** be at index iUnused. (iUnused might be less than iKey if there was + ** wrap-around.) Because the hash table is never more than half full, + ** the search is guaranteed to eventually hit an unused entry. Let + ** iMax be the value between iKey and iUnused, closest to iUnused, + ** where aHash[iMax]==P. If there is no iMax entry (if there exists + ** no hash slot such that aHash[i]==p) then page P is not in the + ** current index block. Otherwise the iMax-th mapping entry of the + ** current index block corresponds to the last entry that references + ** page P. + ** + ** A hash search begins with the last index block and moves toward the + ** first index block, looking for entries corresponding to page P. On + ** average, only two or three slots in each index block need to be + ** examined in order to either find the last entry for page P, or to + ** establish that no such entry exists in the block. Each index block + ** holds over 4000 entries. So two or three index blocks are sufficient + ** to cover a typical 10 megabyte WAL file, assuming 1K pages. 8 or 10 + ** comparisons (on average) suffice to either locate a frame in the + ** WAL or to establish that the frame does not exist in the WAL. This + ** is much faster than scanning the entire 10MB WAL. + ** + ** Note that entries are added in order of increasing K. Hence, one + ** reader might be using some value K0 and a second reader that started + ** at a later time (after additional transactions were added to the WAL + ** and to the wal-index) might be using a different value K1, where K1>K0. + ** Both readers can use the same hash table and mapping section to get + ** the correct result. There may be entries in the hash table with + ** K>K0 but to the first reader, those entries will appear to be unused + ** slots in the hash table and so the first reader will get an answer as + ** if no values greater than K0 had ever been inserted into the hash table + ** in the first place - which is what reader one wants. Meanwhile, the + ** second reader using K1 will see additional values that were inserted + ** later, which is exactly what reader two wants. + ** + ** When a rollback occurs, the value of K is decreased. Hash table entries + ** that correspond to frames greater than the new K value are removed + ** from the hash table at this point. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ #if !SQLITE_OMIT_WAL //#include "wal.h" @@ -2957,5 +2966,5 @@ int sqlite3WalHeapMemory(Wal *pWal){ } #endif //* #if !SQLITE_OMIT_WAL */ - } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/wal_h.cs b/src/extensions/IronPython.SQLite/c#sqlite/wal_h.cs index 2eae2199b..c80dd778c 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/wal_h.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/wal_h.cs @@ -5,123 +5,141 @@ using Wal = System.Object; #endif -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2010 February 1 - ** - ** 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 header file defines the interface to the write-ahead logging - ** system. Refer to the comments below and the header comment attached to - ** the implementation of each function in log.c for further details. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 - ** - ************************************************************************* - */ - - //#if !_WAL_H_ - //#define _WAL_H_ - - //#include "sqliteInt.h" +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 2010 February 1 + ** + ** 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 header file defines the interface to the write-ahead logging + ** system. Refer to the comments below and the header comment attached to + ** the implementation of each function in log.c for further details. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 + ** + ************************************************************************* + */ + + //#if !_WAL_H_ + //#define _WAL_H_ + + //#include "sqliteInt.h" #if SQLITE_OMIT_WAL - //# define sqlite3WalOpen(x,y,z) 0 - static int sqlite3WalOpen(sqlite3_vfs x, sqlite3_file y, string z) { - return 0; - } - - //# define sqlite3WalLimit(x,y) - static void sqlite3WalLimit(sqlite3_vfs x, long y) { - } - - //# define sqlite3WalClose(w,x,y,z) 0 - static int sqlite3WalClose(Wal w, int x, int y, u8 z) { - return 0; - } - - //# define sqlite3WalBeginReadTransaction(y,z) 0 - static int sqlite3WalBeginReadTransaction(Wal y, int z) { - return 0; - } - - //# define sqlite3WalEndReadTransaction(z) - static void sqlite3WalEndReadTransaction(Wal z) { - } - - //# define sqlite3WalRead(v,w,x,y,z) 0 - static int sqlite3WalRead(Wal v, Pgno w, ref int x, int y, u8[] z) { - return 0; - } - - //# define sqlite3WalDbsize(y) 0 - static Pgno sqlite3WalDbsize(Wal y) { - return 0; - } - - //# define sqlite3WalBeginWriteTransaction(y) 0 - static int sqlite3WalBeginWriteTransaction(Wal y) { - return 0; - } - - //# define sqlite3WalEndWriteTransaction(x) 0 - static int sqlite3WalEndWriteTransaction(Wal x) { - return 0; - } - - //# define sqlite3WalUndo(x,y,z) 0 - static int sqlite3WalUndo(Wal x, int y, object z) { - return 0; - } - - - //# define sqlite3WalSavepoint(y,z) - static void sqlite3WalSavepoint(Wal y, object z) { - } - - //# define sqlite3WalSavepointUndo(y,z) 0 - static int sqlite3WalSavepointUndo(Wal y, object z) { - return 0; - } - - //# define sqlite3WalFrames(u,v,w,x,y,z) 0 - static int sqlite3WalFrames(Wal u, int v, PgHdr w, Pgno x, int y, int z) { - return 0; - } - - //# define sqlite3WalCheckpoint(r,s,t,u,v,w,x,y,z) 0 - static int sqlite3WalCheckpoint(Wal r, int s, int t, u8[] u, int v, int w, u8[] x, ref int y, ref int z)//r,s,t,u,v,w,x,y,z - { - y = 0; - z = 0; - return 0; - } - - //# define sqlite3WalCallback(z) 0 - static int sqlite3WalCallback(Wal z) { - return 0; - } - - //# define sqlite3WalExclusiveMode(y,z) 0 - static bool sqlite3WalExclusiveMode(Wal y, int z) { - return false; - } - - //# define sqlite3WalHeapMemory(z) 0 - static bool sqlite3WalHeapMemory(Wal z) { - return false; - } + //# define sqlite3WalOpen(x,y,z) 0 + static int sqlite3WalOpen( sqlite3_vfs x, sqlite3_file y, string z ) + { + return 0; + } + + //# define sqlite3WalLimit(x,y) + static void sqlite3WalLimit( sqlite3_vfs x, long y ) + { + } + + //# define sqlite3WalClose(w,x,y,z) 0 + static int sqlite3WalClose( Wal w, int x, int y, u8 z ) + { + return 0; + } + + //# define sqlite3WalBeginReadTransaction(y,z) 0 + static int sqlite3WalBeginReadTransaction( Wal y, int z ) + { + return 0; + } + + //# define sqlite3WalEndReadTransaction(z) + static void sqlite3WalEndReadTransaction( Wal z ) + { + } + + //# define sqlite3WalRead(v,w,x,y,z) 0 + static int sqlite3WalRead( Wal v, Pgno w, ref int x, int y, u8[] z ) + { + return 0; + } + + //# define sqlite3WalDbsize(y) 0 + static Pgno sqlite3WalDbsize( Wal y ) + { + return 0; + } + + //# define sqlite3WalBeginWriteTransaction(y) 0 + static int sqlite3WalBeginWriteTransaction( Wal y ) + { + return 0; + } + + //# define sqlite3WalEndWriteTransaction(x) 0 + static int sqlite3WalEndWriteTransaction( Wal x ) + { + return 0; + } + + //# define sqlite3WalUndo(x,y,z) 0 + static int sqlite3WalUndo( Wal x, int y, object z ) + { + return 0; + } + + + //# define sqlite3WalSavepoint(y,z) + static void sqlite3WalSavepoint( Wal y, object z ) + { + } + + //# define sqlite3WalSavepointUndo(y,z) 0 + static int sqlite3WalSavepointUndo( Wal y, object z ) + { + return 0; + } + + //# define sqlite3WalFrames(u,v,w,x,y,z) 0 + static int sqlite3WalFrames( Wal u, int v, PgHdr w, Pgno x, int y, int z ) + { + return 0; + } + + //# define sqlite3WalCheckpoint(r,s,t,u,v,w,x,y,z) 0 + static int sqlite3WalCheckpoint( Wal r, int s, int t, u8[] u, int v, int w, u8[]x, ref int y, ref int z )//r,s,t,u,v,w,x,y,z + { + y = 0; + z = 0; + return 0; + } + + //# define sqlite3WalCallback(z) 0 + static int sqlite3WalCallback( Wal z ) + { + return 0; + } + + //# define sqlite3WalExclusiveMode(y,z) 0 + static bool sqlite3WalExclusiveMode( Wal y, int z ) + { + return false; + } + + //# define sqlite3WalHeapMemory(z) 0 + static bool sqlite3WalHeapMemory( Wal z ) + { + return false; + } #else @@ -206,6 +224,6 @@ int sqlite3WalCheckpoint( int sqlite3WalHeapMemory(Wal *pWal); #endif //* ifndef SQLITE_OMIT_WAL */ - //#endif //* _WAL_H_ */ - } + //#endif //* _WAL_H_ */ + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/walker_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/walker_c.cs index bbd53fabe..b0cd879d1 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/walker_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/walker_c.cs @@ -1,167 +1,190 @@ -namespace Community.CsharpSqlite { - public partial class Sqlite3 { - /* - ** 2008 August 16 - ** - ** 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 contains routines used for walking the parser tree for - ** an SQL statement. - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" - //#include - //#include +using System; +using System.Diagnostics; +using System.Text; +using Bitmask = System.UInt64; +using u32 = System.UInt32; + +namespace Community.CsharpSqlite +{ + public partial class Sqlite3 + { + /* + ** 2008 August 16 + ** + ** 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 contains routines used for walking the parser tree for + ** an SQL statement. + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" + //#include + //#include - /* - ** Walk an expression tree. Invoke the callback once for each node - ** of the expression, while decending. (In other words, the callback - ** is invoked before visiting children.) - ** - ** The return value from the callback should be one of the WRC_* - ** constants to specify how to proceed with the walk. - ** - ** WRC_Continue Continue descending down the tree. - ** - ** WRC_Prune Do not descend into child nodes. But allow - ** the walk to continue with sibling nodes. - ** - ** WRC_Abort Do no more callbacks. Unwind the stack and - ** return the top-level walk call. - ** - ** The return value from this routine is WRC_Abort to abandon the tree walk - ** and WRC_Continue to continue. - */ - static int sqlite3WalkExpr(Walker pWalker, ref Expr pExpr) { - int rc; - if (pExpr == null) - return WRC_Continue; - testcase(ExprHasProperty(pExpr, EP_TokenOnly)); - testcase(ExprHasProperty(pExpr, EP_Reduced)); - rc = pWalker.xExprCallback(pWalker, ref pExpr); - if (rc == WRC_Continue - && !ExprHasAnyProperty(pExpr, EP_TokenOnly)) { - if (sqlite3WalkExpr(pWalker, ref pExpr.pLeft) != 0) - return WRC_Abort; - if (sqlite3WalkExpr(pWalker, ref pExpr.pRight) != 0) - return WRC_Abort; - if (ExprHasProperty(pExpr, EP_xIsSelect)) { - if (sqlite3WalkSelect(pWalker, pExpr.x.pSelect) != 0) - return WRC_Abort; - } else { - if (sqlite3WalkExprList(pWalker, pExpr.x.pList) != 0) - return WRC_Abort; - } - } - return rc & WRC_Abort; - } - /* - ** Call sqlite3WalkExpr() for every expression in list p or until - ** an abort request is seen. - */ - static int sqlite3WalkExprList(Walker pWalker, ExprList p) { - int i; - ExprList_item pItem; - if (p != null) { - for (i = p.nExpr; i > 0; i--) {//, pItem++){ - pItem = p.a[p.nExpr - i]; - if (sqlite3WalkExpr(pWalker, ref pItem.pExpr) != 0) - return WRC_Abort; - } - } - return WRC_Continue; + /* + ** Walk an expression tree. Invoke the callback once for each node + ** of the expression, while decending. (In other words, the callback + ** is invoked before visiting children.) + ** + ** The return value from the callback should be one of the WRC_* + ** constants to specify how to proceed with the walk. + ** + ** WRC_Continue Continue descending down the tree. + ** + ** WRC_Prune Do not descend into child nodes. But allow + ** the walk to continue with sibling nodes. + ** + ** WRC_Abort Do no more callbacks. Unwind the stack and + ** return the top-level walk call. + ** + ** The return value from this routine is WRC_Abort to abandon the tree walk + ** and WRC_Continue to continue. + */ + static int sqlite3WalkExpr( Walker pWalker, ref Expr pExpr ) + { + int rc; + if ( pExpr == null ) + return WRC_Continue; + testcase( ExprHasProperty( pExpr, EP_TokenOnly ) ); + testcase( ExprHasProperty( pExpr, EP_Reduced ) ); + rc = pWalker.xExprCallback( pWalker, ref pExpr ); + if ( rc == WRC_Continue + && !ExprHasAnyProperty( pExpr, EP_TokenOnly ) ) + { + if ( sqlite3WalkExpr( pWalker, ref pExpr.pLeft ) != 0 ) + return WRC_Abort; + if ( sqlite3WalkExpr( pWalker, ref pExpr.pRight ) != 0 ) + return WRC_Abort; + if ( ExprHasProperty( pExpr, EP_xIsSelect ) ) + { + if ( sqlite3WalkSelect( pWalker, pExpr.x.pSelect ) != 0 ) + return WRC_Abort; + } + else + { + if ( sqlite3WalkExprList( pWalker, pExpr.x.pList ) != 0 ) + return WRC_Abort; } + } + return rc & WRC_Abort; + } - /* - ** Walk all expressions associated with SELECT statement p. Do - ** not invoke the SELECT callback on p, but do (of course) invoke - ** any expr callbacks and SELECT callbacks that come from subqueries. - ** Return WRC_Abort or WRC_Continue. - */ - static int sqlite3WalkSelectExpr(Walker pWalker, Select p) { - if (sqlite3WalkExprList(pWalker, p.pEList) != 0) - return WRC_Abort; - if (sqlite3WalkExpr(pWalker, ref p.pWhere) != 0) - return WRC_Abort; - if (sqlite3WalkExprList(pWalker, p.pGroupBy) != 0) - return WRC_Abort; - if (sqlite3WalkExpr(pWalker, ref p.pHaving) != 0) - return WRC_Abort; - if (sqlite3WalkExprList(pWalker, p.pOrderBy) != 0) - return WRC_Abort; - if (sqlite3WalkExpr(pWalker, ref p.pLimit) != 0) - return WRC_Abort; - if (sqlite3WalkExpr(pWalker, ref p.pOffset) != 0) - return WRC_Abort; - return WRC_Continue; + /* + ** Call sqlite3WalkExpr() for every expression in list p or until + ** an abort request is seen. + */ + static int sqlite3WalkExprList( Walker pWalker, ExprList p ) + { + int i; + ExprList_item pItem; + if ( p != null ) + { + for ( i = p.nExpr; i > 0; i-- ) + {//, pItem++){ + pItem = p.a[p.nExpr - i]; + if ( sqlite3WalkExpr( pWalker, ref pItem.pExpr ) != 0 ) + return WRC_Abort; } + } + return WRC_Continue; + } - /* - ** Walk the parse trees associated with all subqueries in the - ** FROM clause of SELECT statement p. Do not invoke the select - ** callback on p, but do invoke it on each FROM clause subquery - ** and on any subqueries further down in the tree. Return - ** WRC_Abort or WRC_Continue; - */ - static int sqlite3WalkSelectFrom(Walker pWalker, Select p) { - SrcList pSrc; - int i; - SrcList_item pItem; + /* + ** Walk all expressions associated with SELECT statement p. Do + ** not invoke the SELECT callback on p, but do (of course) invoke + ** any expr callbacks and SELECT callbacks that come from subqueries. + ** Return WRC_Abort or WRC_Continue. + */ + static int sqlite3WalkSelectExpr( Walker pWalker, Select p ) + { + if ( sqlite3WalkExprList( pWalker, p.pEList ) != 0 ) + return WRC_Abort; + if ( sqlite3WalkExpr( pWalker, ref p.pWhere ) != 0 ) + return WRC_Abort; + if ( sqlite3WalkExprList( pWalker, p.pGroupBy ) != 0 ) + return WRC_Abort; + if ( sqlite3WalkExpr( pWalker, ref p.pHaving ) != 0 ) + return WRC_Abort; + if ( sqlite3WalkExprList( pWalker, p.pOrderBy ) != 0 ) + return WRC_Abort; + if ( sqlite3WalkExpr( pWalker, ref p.pLimit ) != 0 ) + return WRC_Abort; + if ( sqlite3WalkExpr( pWalker, ref p.pOffset ) != 0 ) + return WRC_Abort; + return WRC_Continue; + } - pSrc = p.pSrc; - if (ALWAYS(pSrc)) { - for (i = pSrc.nSrc; i > 0; i--)// pItem++ ) - { - pItem = pSrc.a[pSrc.nSrc - i]; - if (sqlite3WalkSelect(pWalker, pItem.pSelect) != 0) { - return WRC_Abort; - } - } - } - return WRC_Continue; - } + /* + ** Walk the parse trees associated with all subqueries in the + ** FROM clause of SELECT statement p. Do not invoke the select + ** callback on p, but do invoke it on each FROM clause subquery + ** and on any subqueries further down in the tree. Return + ** WRC_Abort or WRC_Continue; + */ + static int sqlite3WalkSelectFrom( Walker pWalker, Select p ) + { + SrcList pSrc; + int i; + SrcList_item pItem; - /* - ** Call sqlite3WalkExpr() for every expression in Select statement p. - ** Invoke sqlite3WalkSelect() for subqueries in the FROM clause and - ** on the compound select chain, p.pPrior. - ** - ** Return WRC_Continue under normal conditions. Return WRC_Abort if - ** there is an abort request. - ** - ** If the Walker does not have an xSelectCallback() then this routine - ** is a no-op returning WRC_Continue. - */ - static int sqlite3WalkSelect(Walker pWalker, Select p) { - int rc; - if (p == null || pWalker.xSelectCallback == null) - return WRC_Continue; - rc = WRC_Continue; - while (p != null) { - rc = pWalker.xSelectCallback(pWalker, p); - if (rc != 0) - break; - if (sqlite3WalkSelectExpr(pWalker, p) != 0) - return WRC_Abort; - if (sqlite3WalkSelectFrom(pWalker, p) != 0) - return WRC_Abort; - p = p.pPrior; - } - return rc & WRC_Abort; + pSrc = p.pSrc; + if ( ALWAYS( pSrc ) ) + { + for ( i = pSrc.nSrc; i > 0; i-- )// pItem++ ) + { + pItem = pSrc.a[pSrc.nSrc - i]; + if ( sqlite3WalkSelect( pWalker, pItem.pSelect ) != 0 ) + { + return WRC_Abort; + } } + } + return WRC_Continue; + } + + /* + ** Call sqlite3WalkExpr() for every expression in Select statement p. + ** Invoke sqlite3WalkSelect() for subqueries in the FROM clause and + ** on the compound select chain, p.pPrior. + ** + ** Return WRC_Continue under normal conditions. Return WRC_Abort if + ** there is an abort request. + ** + ** If the Walker does not have an xSelectCallback() then this routine + ** is a no-op returning WRC_Continue. + */ + static int sqlite3WalkSelect( Walker pWalker, Select p ) + { + int rc; + if ( p == null || pWalker.xSelectCallback == null ) + return WRC_Continue; + rc = WRC_Continue; + while ( p != null ) + { + rc = pWalker.xSelectCallback( pWalker, p ); + if ( rc != 0 ) + break; + if ( sqlite3WalkSelectExpr( pWalker, p ) != 0 ) + return WRC_Abort; + if ( sqlite3WalkSelectFrom( pWalker, p ) != 0 ) + return WRC_Abort; + p = p.pPrior; + } + return rc & WRC_Abort; } + } } diff --git a/src/extensions/IronPython.SQLite/c#sqlite/where_c.cs b/src/extensions/IronPython.SQLite/c#sqlite/where_c.cs index 045317ca1..fc26723c3 100644 --- a/src/extensions/IronPython.SQLite/c#sqlite/where_c.cs +++ b/src/extensions/IronPython.SQLite/c#sqlite/where_c.cs @@ -3,1452 +3,1580 @@ using System.Text; using Bitmask = System.UInt64; + using i16 = System.Int16; -using sqlite3_int64 = System.Int64; +using u8 = System.Byte; using u16 = System.UInt16; using u32 = System.UInt32; -using u8 = System.Byte; -namespace Community.CsharpSqlite { - using sqlite3_value = Sqlite3.Mem; - public partial class Sqlite3 { - /* - ** 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. - ** - ************************************************************************* - ** This module contains C code that generates VDBE code used to process - ** the WHERE clause of SQL statements. This module is responsible for - ** generating the code that loops through a table looking for applicable - ** rows. Indices are selected and used to speed the search when doing - ** so is applicable. Because this module is responsible for selecting - ** indices, you might also think of this module as the "query optimizer". - ************************************************************************* - ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart - ** C#-SQLite is an independent reimplementation of the SQLite software library - ** - ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908ecd7 - ** - ************************************************************************* - */ - //#include "sqliteInt.h" +using sqlite3_int64 = System.Int64; +namespace Community.CsharpSqlite +{ + using sqlite3_value = Sqlite3.Mem; + public partial class Sqlite3 + { + /* + ** 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. + ** + ************************************************************************* + ** This module contains C code that generates VDBE code used to process + ** the WHERE clause of SQL statements. This module is responsible for + ** generating the code that loops through a table looking for applicable + ** rows. Indices are selected and used to speed the search when doing + ** so is applicable. Because this module is responsible for selecting + ** indices, you might also think of this module as the "query optimizer". + ************************************************************************* + ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart + ** C#-SQLite is an independent reimplementation of the SQLite software library + ** + ** SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908ecd7 + ** + ************************************************************************* + */ + //#include "sqliteInt.h" - /* - ** Trace output macros - */ -#if (SQLITE_TEST) || (SQLITE_DEBUG) - static bool sqlite3WhereTrace = false; + + /* + ** Trace output macros + */ +#if (SQLITE_TEST) || (SQLITE_DEBUG) + static bool sqlite3WhereTrace = false; #endif -#if (SQLITE_TEST) && (SQLITE_DEBUG) && TRACE +#if (SQLITE_TEST) && (SQLITE_DEBUG) && TRACE //# define WHERETRACE(X) if(sqlite3WhereTrace) sqlite3DebugPrintf X static void WHERETRACE( string X, params object[] ap ) { if ( sqlite3WhereTrace ) sqlite3DebugPrintf( X, ap ); } #else - //# define WHERETRACE(X) - static void WHERETRACE(string X, params object[] ap) { - } + //# define WHERETRACE(X) + static void WHERETRACE( string X, params object[] ap ) + { + } #endif - /* Forward reference - */ - //typedef struct WhereClause WhereClause; - //typedef struct WhereMaskSet WhereMaskSet; - //typedef struct WhereOrInfo WhereOrInfo; - //typedef struct WhereAndInfo WhereAndInfo; - //typedef struct WhereCost WhereCost; + /* Forward reference +*/ + //typedef struct WhereClause WhereClause; + //typedef struct WhereMaskSet WhereMaskSet; + //typedef struct WhereOrInfo WhereOrInfo; + //typedef struct WhereAndInfo WhereAndInfo; + //typedef struct WhereCost WhereCost; - /* - ** The query generator uses an array of instances of this structure to - ** help it analyze the subexpressions of the WHERE clause. Each WHERE - ** clause subexpression is separated from the others by AND operators, - ** usually, or sometimes subexpressions separated by OR. - ** - ** All WhereTerms are collected into a single WhereClause structure. - ** The following identity holds: - ** - ** WhereTerm.pWC.a[WhereTerm.idx] == WhereTerm - ** - ** When a term is of the form: - ** - ** X - ** - ** where X is a column name and is one of certain operators, - ** then WhereTerm.leftCursor and WhereTerm.u.leftColumn record the - ** cursor number and column number for X. WhereTerm.eOperator records - ** the using a bitmask encoding defined by WO_xxx below. The - ** use of a bitmask encoding for the operator allows us to search - ** quickly for terms that match any of several different operators. - ** - ** A WhereTerm might also be two or more subterms connected by OR: - ** - ** (t1.X ) OR (t1.Y ) OR .... - ** - ** In this second case, wtFlag as the TERM_ORINFO set and eOperator==WO_OR - ** and the WhereTerm.u.pOrInfo field points to auxiliary information that - ** is collected about the - ** - ** If a term in the WHERE clause does not match either of the two previous - ** categories, then eOperator==0. The WhereTerm.pExpr field is still set - ** to the original subexpression content and wtFlags is set up appropriately - ** but no other fields in the WhereTerm object are meaningful. - ** - ** When eOperator!=0, prereqRight and prereqAll record sets of cursor numbers, - ** but they do so indirectly. A single WhereMaskSet structure translates - ** cursor number into bits and the translated bit is stored in the prereq - ** fields. The translation is used in order to maximize the number of - ** bits that will fit in a Bitmask. The VDBE cursor numbers might be - ** spread out over the non-negative integers. For example, the cursor - ** numbers might be 3, 8, 9, 10, 20, 23, 41, and 45. The WhereMaskSet - ** translates these sparse cursor numbers into consecutive integers - ** beginning with 0 in order to make the best possible use of the available - ** bits in the Bitmask. So, in the example above, the cursor numbers - ** would be mapped into integers 0 through 7. - ** - ** The number of terms in a join is limited by the number of bits - ** in prereqRight and prereqAll. The default is 64 bits, hence SQLite - ** is only able to process joins with 64 or fewer tables. - */ - //typedef struct WhereTerm WhereTerm; - public class WhereTerm { - public Expr pExpr; /* Pointer to the subexpression that is this term */ - public int iParent; /* Disable pWC.a[iParent] when this term disabled */ - public int leftCursor; /* Cursor number of X in "X " */ - public class _u { - public int leftColumn; /* Column number of X in "X " */ - public WhereOrInfo pOrInfo; /* Extra information if eOperator==WO_OR */ - public WhereAndInfo pAndInfo; /* Extra information if eOperator==WO_AND */ - } - public _u u = new _u(); - public u16 eOperator; /* A WO_xx value describing */ - public u8 wtFlags; /* TERM_xxx bit flags. See below */ - public u8 nChild; /* Number of children that must disable us */ - public WhereClause pWC; /* The clause this term is part of */ - public Bitmask prereqRight; /* Bitmask of tables used by pExpr.pRight */ - public Bitmask prereqAll; /* Bitmask of tables referenced by pExpr */ - }; + /* + ** The query generator uses an array of instances of this structure to + ** help it analyze the subexpressions of the WHERE clause. Each WHERE + ** clause subexpression is separated from the others by AND operators, + ** usually, or sometimes subexpressions separated by OR. + ** + ** All WhereTerms are collected into a single WhereClause structure. + ** The following identity holds: + ** + ** WhereTerm.pWC.a[WhereTerm.idx] == WhereTerm + ** + ** When a term is of the form: + ** + ** X + ** + ** where X is a column name and is one of certain operators, + ** then WhereTerm.leftCursor and WhereTerm.u.leftColumn record the + ** cursor number and column number for X. WhereTerm.eOperator records + ** the using a bitmask encoding defined by WO_xxx below. The + ** use of a bitmask encoding for the operator allows us to search + ** quickly for terms that match any of several different operators. + ** + ** A WhereTerm might also be two or more subterms connected by OR: + ** + ** (t1.X ) OR (t1.Y ) OR .... + ** + ** In this second case, wtFlag as the TERM_ORINFO set and eOperator==WO_OR + ** and the WhereTerm.u.pOrInfo field points to auxiliary information that + ** is collected about the + ** + ** If a term in the WHERE clause does not match either of the two previous + ** categories, then eOperator==0. The WhereTerm.pExpr field is still set + ** to the original subexpression content and wtFlags is set up appropriately + ** but no other fields in the WhereTerm object are meaningful. + ** + ** When eOperator!=0, prereqRight and prereqAll record sets of cursor numbers, + ** but they do so indirectly. A single WhereMaskSet structure translates + ** cursor number into bits and the translated bit is stored in the prereq + ** fields. The translation is used in order to maximize the number of + ** bits that will fit in a Bitmask. The VDBE cursor numbers might be + ** spread out over the non-negative integers. For example, the cursor + ** numbers might be 3, 8, 9, 10, 20, 23, 41, and 45. The WhereMaskSet + ** translates these sparse cursor numbers into consecutive integers + ** beginning with 0 in order to make the best possible use of the available + ** bits in the Bitmask. So, in the example above, the cursor numbers + ** would be mapped into integers 0 through 7. + ** + ** The number of terms in a join is limited by the number of bits + ** in prereqRight and prereqAll. The default is 64 bits, hence SQLite + ** is only able to process joins with 64 or fewer tables. + */ + //typedef struct WhereTerm WhereTerm; + public class WhereTerm + { + public Expr pExpr; /* Pointer to the subexpression that is this term */ + public int iParent; /* Disable pWC.a[iParent] when this term disabled */ + public int leftCursor; /* Cursor number of X in "X " */ + public class _u + { + public int leftColumn; /* Column number of X in "X " */ + public WhereOrInfo pOrInfo; /* Extra information if eOperator==WO_OR */ + public WhereAndInfo pAndInfo; /* Extra information if eOperator==WO_AND */ + } + public _u u = new _u(); + public u16 eOperator; /* A WO_xx value describing */ + public u8 wtFlags; /* TERM_xxx bit flags. See below */ + public u8 nChild; /* Number of children that must disable us */ + public WhereClause pWC; /* The clause this term is part of */ + public Bitmask prereqRight; /* Bitmask of tables used by pExpr.pRight */ + public Bitmask prereqAll; /* Bitmask of tables referenced by pExpr */ + }; - /* - ** Allowed values of WhereTerm.wtFlags - */ - //#define TERM_DYNAMIC 0x01 /* Need to call sqlite3ExprDelete(db, ref pExpr) */ - //#define TERM_VIRTUAL 0x02 /* Added by the optimizer. Do not code */ - //#define TERM_CODED 0x04 /* This term is already coded */ - //#define TERM_COPIED 0x08 /* Has a child */ - //#define TERM_ORINFO 0x10 /* Need to free the WhereTerm.u.pOrInfo object */ - //#define TERM_ANDINFO 0x20 /* Need to free the WhereTerm.u.pAndInfo obj */ - //#define TERM_OR_OK 0x40 /* Used during OR-clause processing */ + /* + ** Allowed values of WhereTerm.wtFlags + */ + //#define TERM_DYNAMIC 0x01 /* Need to call sqlite3ExprDelete(db, ref pExpr) */ + //#define TERM_VIRTUAL 0x02 /* Added by the optimizer. Do not code */ + //#define TERM_CODED 0x04 /* This term is already coded */ + //#define TERM_COPIED 0x08 /* Has a child */ + //#define TERM_ORINFO 0x10 /* Need to free the WhereTerm.u.pOrInfo object */ + //#define TERM_ANDINFO 0x20 /* Need to free the WhereTerm.u.pAndInfo obj */ + //#define TERM_OR_OK 0x40 /* Used during OR-clause processing */ #if SQLITE_ENABLE_STAT2 //# define TERM_VNULL 0x80 /* Manufactured x>NULL or x<=NULL term */ #else - //# define TERM_VNULL 0x00 /* Disabled if not using stat2 */ +//# define TERM_VNULL 0x00 /* Disabled if not using stat2 */ #endif - const int TERM_DYNAMIC = 0x01; /* Need to call sqlite3ExprDelete(db, ref pExpr) */ - const int TERM_VIRTUAL = 0x02; /* Added by the optimizer. Do not code */ - const int TERM_CODED = 0x04; /* This term is already coded */ - const int TERM_COPIED = 0x08; /* Has a child */ - const int TERM_ORINFO = 0x10; /* Need to free the WhereTerm.u.pOrInfo object */ - const int TERM_ANDINFO = 0x20; /* Need to free the WhereTerm.u.pAndInfo obj */ - const int TERM_OR_OK = 0x40; /* Used during OR-clause processing */ + const int TERM_DYNAMIC = 0x01; /* Need to call sqlite3ExprDelete(db, ref pExpr) */ + const int TERM_VIRTUAL = 0x02; /* Added by the optimizer. Do not code */ + const int TERM_CODED = 0x04; /* This term is already coded */ + const int TERM_COPIED = 0x08; /* Has a child */ + const int TERM_ORINFO = 0x10; /* Need to free the WhereTerm.u.pOrInfo object */ + const int TERM_ANDINFO = 0x20; /* Need to free the WhereTerm.u.pAndInfo obj */ + const int TERM_OR_OK = 0x40; /* Used during OR-clause processing */ #if SQLITE_ENABLE_STAT2 const int TERM_VNULL = 0x80; /* Manufactured x>NULL or x<=NULL term */ #else - const int TERM_VNULL = 0x00; /* Disabled if not using stat2 */ + const int TERM_VNULL = 0x00; /* Disabled if not using stat2 */ #endif - /* - ** An instance of the following structure holds all information about a - ** WHERE clause. Mostly this is a container for one or more WhereTerms. - */ - public class WhereClause { - public Parse pParse; /* The parser context */ - public WhereMaskSet pMaskSet; /* Mapping of table cursor numbers to bitmasks */ - public Bitmask vmask; /* Bitmask identifying virtual table cursors */ - public u8 op; /* Split operator. TK_AND or TK_OR */ - public int nTerm; /* Number of terms */ - public int nSlot; /* Number of entries in a[] */ - public WhereTerm[] a; /* Each a[] describes a term of the WHERE cluase */ + /* + ** An instance of the following structure holds all information about a + ** WHERE clause. Mostly this is a container for one or more WhereTerms. + */ + public class WhereClause + { + public Parse pParse; /* The parser context */ + public WhereMaskSet pMaskSet; /* Mapping of table cursor numbers to bitmasks */ + public Bitmask vmask; /* Bitmask identifying virtual table cursors */ + public u8 op; /* Split operator. TK_AND or TK_OR */ + public int nTerm; /* Number of terms */ + public int nSlot; /* Number of entries in a[] */ + public WhereTerm[] a; /* Each a[] describes a term of the WHERE cluase */ #if (SQLITE_SMALL_STACK) public WhereTerm[] aStatic = new WhereTerm[1]; /* Initial static space for a[] */ #else - public WhereTerm[] aStatic = new WhereTerm[8]; /* Initial static space for a[] */ + public WhereTerm[] aStatic = new WhereTerm[8]; /* Initial static space for a[] */ #endif - public void CopyTo(WhereClause wc) { - wc.pParse = this.pParse; - wc.pMaskSet = new WhereMaskSet(); - this.pMaskSet.CopyTo(wc.pMaskSet); - wc.op = this.op; - wc.nTerm = this.nTerm; - wc.nSlot = this.nSlot; - wc.a = (WhereTerm[])this.a.Clone(); - wc.aStatic = (WhereTerm[])this.aStatic.Clone(); - } - }; + public void CopyTo( WhereClause wc ) + { + wc.pParse = this.pParse; + wc.pMaskSet = new WhereMaskSet(); + this.pMaskSet.CopyTo( wc.pMaskSet ); + wc.op = this.op; + wc.nTerm = this.nTerm; + wc.nSlot = this.nSlot; + wc.a = (WhereTerm[])this.a.Clone(); + wc.aStatic = (WhereTerm[])this.aStatic.Clone(); + } + }; - /* - ** A WhereTerm with eOperator==WO_OR has its u.pOrInfo pointer set to - ** a dynamically allocated instance of the following structure. - */ - public class WhereOrInfo { - public WhereClause wc = new WhereClause();/* Decomposition into subterms */ - public Bitmask indexable; /* Bitmask of all indexable tables in the clause */ - }; + /* + ** A WhereTerm with eOperator==WO_OR has its u.pOrInfo pointer set to + ** a dynamically allocated instance of the following structure. + */ + public class WhereOrInfo + { + public WhereClause wc = new WhereClause();/* Decomposition into subterms */ + public Bitmask indexable; /* Bitmask of all indexable tables in the clause */ + }; - /* - ** A WhereTerm with eOperator==WO_AND has its u.pAndInfo pointer set to - ** a dynamically allocated instance of the following structure. - */ - public class WhereAndInfo { - public WhereClause wc = new WhereClause(); /* The subexpression broken out */ - }; + /* + ** A WhereTerm with eOperator==WO_AND has its u.pAndInfo pointer set to + ** a dynamically allocated instance of the following structure. + */ + public class WhereAndInfo + { + public WhereClause wc = new WhereClause(); /* The subexpression broken out */ + }; - /* - ** An instance of the following structure keeps track of a mapping - ** between VDBE cursor numbers and bits of the bitmasks in WhereTerm. - ** - ** The VDBE cursor numbers are small integers contained in - ** SrcList_item.iCursor and Expr.iTable fields. For any given WHERE - ** clause, the cursor numbers might not begin with 0 and they might - ** contain gaps in the numbering sequence. But we want to make maximum - ** use of the bits in our bitmasks. This structure provides a mapping - ** from the sparse cursor numbers into consecutive integers beginning - ** with 0. - ** - ** If WhereMaskSet.ix[A]==B it means that The A-th bit of a Bitmask - ** corresponds VDBE cursor number B. The A-th bit of a bitmask is 1<EXPR */ - //#define WHERE_COLUMN_EQ 0x00010000 /* x=EXPR or x IN (...) or x IS NULL */ - //#define WHERE_COLUMN_RANGE 0x00020000 /* xEXPR */ - //#define WHERE_COLUMN_IN 0x00040000 /* x IN (...) */ - //#define WHERE_COLUMN_NULL 0x00080000 /* x IS NULL */ - //#define WHERE_INDEXED 0x000f0000 /* Anything that uses an index */ - //#define WHERE_IN_ABLE 0x000f1000 /* Able to support an IN operator */ - //#define WHERE_NOT_FULLSCAN 0x100f3000 /* Does not do a full table scan */ - //#define WHERE_TOP_LIMIT 0x00100000 /* xEXPR or x>=EXPR constraint */ - //#define WHERE_BOTH_LIMIT 0x00300000 /* Both x>EXPR and xEXPR */ + //#define WHERE_COLUMN_EQ 0x00010000 /* x=EXPR or x IN (...) or x IS NULL */ + //#define WHERE_COLUMN_RANGE 0x00020000 /* xEXPR */ + //#define WHERE_COLUMN_IN 0x00040000 /* x IN (...) */ + //#define WHERE_COLUMN_NULL 0x00080000 /* x IS NULL */ + //#define WHERE_INDEXED 0x000f0000 /* Anything that uses an index */ + //#define WHERE_IN_ABLE 0x000f1000 /* Able to support an IN operator */ + //#define WHERE_NOT_FULLSCAN 0x100f3000 /* Does not do a full table scan */ + //#define WHERE_TOP_LIMIT 0x00100000 /* xEXPR or x>=EXPR constraint */ + //#define WHERE_BOTH_LIMIT 0x00300000 /* Both x>EXPR and x= 0; i-- )//, a++) + { + a = pWC.a[i]; + if ( ( a.wtFlags & TERM_DYNAMIC ) != 0 ) + { + sqlite3ExprDelete( db, ref a.pExpr ); + } + if ( ( a.wtFlags & TERM_ORINFO ) != 0 ) + { + whereOrInfoDelete( db, a.u.pOrInfo ); + } + else if ( ( a.wtFlags & TERM_ANDINFO ) != 0 ) + { + whereAndInfoDelete( db, a.u.pAndInfo ); } + } + if ( pWC.a != pWC.aStatic ) + { + sqlite3DbFree( db, ref pWC.a ); + } + } - /* Forward reference */ - //static void whereClauseClear(WhereClause); + /* + ** Add a single new WhereTerm entry to the WhereClause object pWC. + ** The new WhereTerm object is constructed from Expr p and with wtFlags. + ** The index in pWC.a[] of the new WhereTerm is returned on success. + ** 0 is returned if the new WhereTerm could not be added due to a memory + ** allocation error. The memory allocation failure will be recorded in + ** the db.mallocFailed flag so that higher-level functions can detect it. + ** + ** This routine will increase the size of the pWC.a[] array as necessary. + ** + ** If the wtFlags argument includes TERM_DYNAMIC, then responsibility + ** for freeing the expression p is Debug.Assumed by the WhereClause object pWC. + ** This is true even if this routine fails to allocate a new WhereTerm. + ** + ** WARNING: This routine might reallocate the space used to store + ** WhereTerms. All pointers to WhereTerms should be invalidated after + ** calling this routine. Such pointers may be reinitialized by referencing + ** the pWC.a[] array. + */ + static int whereClauseInsert( WhereClause pWC, Expr p, u8 wtFlags ) + { + WhereTerm pTerm; + int idx; + testcase( wtFlags & TERM_VIRTUAL ); /* EV: R-00211-15100 */ + if ( pWC.nTerm >= pWC.nSlot ) + { + //WhereTerm pOld = pWC.a; + //sqlite3 db = pWC.pParse.db; + Array.Resize( ref pWC.a, pWC.nSlot * 2 ); + //pWC.a = sqlite3DbMallocRaw(db, sizeof(pWC.a[0])*pWC.nSlot*2 ); + //if( pWC.a==null ){ + // if( wtFlags & TERM_DYNAMIC ){ + // sqlite3ExprDelete(db, ref p); + // } + // pWC.a = pOld; + // return 0; + //} + //memcpy(pWC.a, pOld, sizeof(pWC.a[0])*pWC.nTerm); + //if( pOld!=pWC.aStatic ){ + // sqlite3DbFree(db, ref pOld); + //} + //pWC.nSlot = sqlite3DbMallocSize(db, pWC.a)/sizeof(pWC.a[0]); + pWC.nSlot = pWC.a.Length - 1; + } + pWC.a[idx = pWC.nTerm++] = new WhereTerm(); + pTerm = pWC.a[idx]; + pTerm.pExpr = p; + pTerm.wtFlags = wtFlags; + pTerm.pWC = pWC; + pTerm.iParent = -1; + return idx; + } - /* - ** Deallocate all memory Debug.Associated with a WhereOrInfo object. - */ - static void whereOrInfoDelete(sqlite3 db, WhereOrInfo p) { - whereClauseClear(p.wc); - sqlite3DbFree(db, ref p); + /* + ** This routine identifies subexpressions in the WHERE clause where + ** each subexpression is separated by the AND operator or some other + ** operator specified in the op parameter. The WhereClause structure + ** is filled with pointers to subexpressions. For example: + ** + ** WHERE a=='hello' AND coalesce(b,11)<10 AND (c+12!=d OR c==22) + ** \________/ \_______________/ \________________/ + ** slot[0] slot[1] slot[2] + ** + ** The original WHERE clause in pExpr is unaltered. All this routine + ** does is make slot[] entries point to substructure within pExpr. + ** + ** In the previous sentence and in the diagram, "slot[]" refers to + ** the WhereClause.a[] array. The slot[] array grows as needed to contain + ** all terms of the WHERE clause. + */ + static void whereSplit( WhereClause pWC, Expr pExpr, int op ) + { + pWC.op = (u8)op; + if ( pExpr == null ) + return; + if ( pExpr.op != op ) + { + whereClauseInsert( pWC, pExpr, 0 ); + } + else + { + whereSplit( pWC, pExpr.pLeft, op ); + whereSplit( pWC, pExpr.pRight, op ); + } + } + + /* + ** Initialize an expression mask set (a WhereMaskSet object) + */ + //#define initMaskSet(P) memset(P, 0, sizeof(*P)) + + /* + ** Return the bitmask for the given cursor number. Return 0 if + ** iCursor is not in the set. + */ + static Bitmask getMask( WhereMaskSet pMaskSet, int iCursor ) + { + int i; + Debug.Assert( pMaskSet.n <= (int)sizeof( Bitmask ) * 8 ); + for ( i = 0; i < pMaskSet.n; i++ ) + { + if ( pMaskSet.ix[i] == iCursor ) + { + return ( (Bitmask)1 ) << i; } + } + return 0; + } - /* - ** Deallocate all memory Debug.Associated with a WhereAndInfo object. - */ - static void whereAndInfoDelete(sqlite3 db, WhereAndInfo p) { - whereClauseClear(p.wc); - sqlite3DbFree(db, ref p); + /* + ** Create a new mask for cursor iCursor. + ** + ** There is one cursor per table in the FROM clause. The number of + ** tables in the FROM clause is limited by a test early in the + ** sqlite3WhereBegin() routine. So we know that the pMaskSet.ix[] + ** array will never overflow. + */ + static void createMask( WhereMaskSet pMaskSet, int iCursor ) + { + Debug.Assert( pMaskSet.n < ArraySize( pMaskSet.ix ) ); + pMaskSet.ix[pMaskSet.n++] = iCursor; + } + + /* + ** This routine walks (recursively) an expression tree and generates + ** a bitmask indicating which tables are used in that expression + ** tree. + ** + ** In order for this routine to work, the calling function must have + ** previously invoked sqlite3ResolveExprNames() on the expression. See + ** the header comment on that routine for additional information. + ** The sqlite3ResolveExprNames() routines looks for column names and + ** sets their opcodes to TK_COLUMN and their Expr.iTable fields to + ** the VDBE cursor number of the table. This routine just has to + ** translate the cursor numbers into bitmask values and OR all + ** the bitmasks together. + */ + //static Bitmask exprListTableUsage(WhereMaskSet*, ExprList); + //static Bitmask exprSelectTableUsage(WhereMaskSet*, Select); + static Bitmask exprTableUsage( WhereMaskSet pMaskSet, Expr p ) + { + Bitmask mask = 0; + if ( p == null ) + return 0; + if ( p.op == TK_COLUMN ) + { + mask = getMask( pMaskSet, p.iTable ); + return mask; + } + mask = exprTableUsage( pMaskSet, p.pRight ); + mask |= exprTableUsage( pMaskSet, p.pLeft ); + if ( ExprHasProperty( p, EP_xIsSelect ) ) + { + mask |= exprSelectTableUsage( pMaskSet, p.x.pSelect ); + } + else + { + mask |= exprListTableUsage( pMaskSet, p.x.pList ); + } + return mask; + } + static Bitmask exprListTableUsage( WhereMaskSet pMaskSet, ExprList pList ) + { + int i; + Bitmask mask = 0; + if ( pList != null ) + { + for ( i = 0; i < pList.nExpr; i++ ) + { + mask |= exprTableUsage( pMaskSet, pList.a[i].pExpr ); } + } + return mask; + } + static Bitmask exprSelectTableUsage( WhereMaskSet pMaskSet, Select pS ) + { + Bitmask mask = 0; + while ( pS != null ) + { + mask |= exprListTableUsage( pMaskSet, pS.pEList ); + mask |= exprListTableUsage( pMaskSet, pS.pGroupBy ); + mask |= exprListTableUsage( pMaskSet, pS.pOrderBy ); + mask |= exprTableUsage( pMaskSet, pS.pWhere ); + mask |= exprTableUsage( pMaskSet, pS.pHaving ); + pS = pS.pPrior; + } + return mask; + } - /* - ** Deallocate a WhereClause structure. The WhereClause structure - ** itself is not freed. This routine is the inverse of whereClauseInit(). - */ - static void whereClauseClear(WhereClause pWC) { - int i; - WhereTerm a; - sqlite3 db = pWC.pParse.db; - for (i = pWC.nTerm - 1; i >= 0; i--)//, a++) + /* + ** Return TRUE if the given operator is one of the operators that is + ** allowed for an indexable WHERE clause term. The allowed operators are + ** "=", "<", ">", "<=", ">=", and "IN". + ** + ** IMPLEMENTATION-OF: R-59926-26393 To be usable by an index a term must be + ** of one of the following forms: column = expression column > expression + ** column >= expression column < expression column <= expression + ** expression = column expression > column expression >= column + ** expression < column expression <= column column IN + ** (expression-list) column IN (subquery) column IS NULL + */ + static bool allowedOp( int op ) + { + Debug.Assert( TK_GT > TK_EQ && TK_GT < TK_GE ); + Debug.Assert( TK_LT > TK_EQ && TK_LT < TK_GE ); + Debug.Assert( TK_LE > TK_EQ && TK_LE < TK_GE ); + Debug.Assert( TK_GE == TK_EQ + 4 ); + return op == TK_IN || ( op >= TK_EQ && op <= TK_GE ) || op == TK_ISNULL; + } + + /* + ** Swap two objects of type TYPE. + */ + //#define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;} + + /* + ** Commute a comparison operator. Expressions of the form "X op Y" + ** are converted into "Y op X". + ** + ** If a collation sequence is Debug.Associated with either the left or right + ** side of the comparison, it remains Debug.Associated with the same side after + ** the commutation. So "Y collate NOCASE op X" becomes + ** "X collate NOCASE op Y". This is because any collation sequence on + ** the left hand side of a comparison overrides any collation sequence + ** attached to the right. For the same reason the EP_ExpCollate flag + ** is not commuted. + */ + static void exprCommute( Parse pParse, Expr pExpr ) + { + u16 expRight = (u16)( pExpr.pRight.flags & EP_ExpCollate ); + u16 expLeft = (u16)( pExpr.pLeft.flags & EP_ExpCollate ); + Debug.Assert( allowedOp( pExpr.op ) && pExpr.op != TK_IN ); + pExpr.pRight.pColl = sqlite3ExprCollSeq( pParse, pExpr.pRight ); + pExpr.pLeft.pColl = sqlite3ExprCollSeq( pParse, pExpr.pLeft ); + SWAP( ref pExpr.pRight.pColl, ref pExpr.pLeft.pColl ); + pExpr.pRight.flags = (u16)( ( pExpr.pRight.flags & ~EP_ExpCollate ) | expLeft ); + pExpr.pLeft.flags = (u16)( ( pExpr.pLeft.flags & ~EP_ExpCollate ) | expRight ); + SWAP( ref pExpr.pRight, ref pExpr.pLeft ); + if ( pExpr.op >= TK_GT ) + { + Debug.Assert( TK_LT == TK_GT + 2 ); + Debug.Assert( TK_GE == TK_LE + 2 ); + Debug.Assert( TK_GT > TK_EQ ); + Debug.Assert( TK_GT < TK_LE ); + Debug.Assert( pExpr.op >= TK_GT && pExpr.op <= TK_GE ); + pExpr.op = (u8)( ( ( pExpr.op - TK_GT ) ^ 2 ) + TK_GT ); + } + } + + /* + ** Translate from TK_xx operator to WO_xx bitmask. + */ + static u16 operatorMask( int op ) + { + u16 c; + Debug.Assert( allowedOp( op ) ); + if ( op == TK_IN ) + { + c = WO_IN; + } + else if ( op == TK_ISNULL ) + { + c = WO_ISNULL; + } + else + { + Debug.Assert( ( WO_EQ << ( op - TK_EQ ) ) < 0x7fff ); + c = (u16)( WO_EQ << ( op - TK_EQ ) ); + } + Debug.Assert( op != TK_ISNULL || c == WO_ISNULL ); + Debug.Assert( op != TK_IN || c == WO_IN ); + Debug.Assert( op != TK_EQ || c == WO_EQ ); + Debug.Assert( op != TK_LT || c == WO_LT ); + Debug.Assert( op != TK_LE || c == WO_LE ); + Debug.Assert( op != TK_GT || c == WO_GT ); + Debug.Assert( op != TK_GE || c == WO_GE ); + return c; + } + + /* + ** Search for a term in the WHERE clause that is of the form "X " + ** where X is a reference to the iColumn of table iCur and is one of + ** the WO_xx operator codes specified by the op parameter. + ** Return a pointer to the term. Return 0 if not found. + */ + static WhereTerm findTerm( + WhereClause pWC, /* The WHERE clause to be searched */ + int iCur, /* Cursor number of LHS */ + int iColumn, /* Column number of LHS */ + Bitmask notReady, /* RHS must not overlap with this mask */ + u32 op, /* Mask of WO_xx values describing operator */ + Index pIdx /* Must be compatible with this index, if not NULL */ + ) + { + WhereTerm pTerm; + int k; + Debug.Assert( iCur >= 0 ); + op &= WO_ALL; + for ( k = pWC.nTerm; k != 0; k-- )//, pTerm++) + { + pTerm = pWC.a[pWC.nTerm - k]; + if ( pTerm.leftCursor == iCur + && ( pTerm.prereqRight & notReady ) == 0 + && pTerm.u.leftColumn == iColumn + && ( pTerm.eOperator & op ) != 0 + ) + { + if ( pIdx != null && pTerm.eOperator != WO_ISNULL ) + { + Expr pX = pTerm.pExpr; + CollSeq pColl; + char idxaff; + int j; + Parse pParse = pWC.pParse; + + idxaff = pIdx.pTable.aCol[iColumn].affinity; + if ( !sqlite3IndexAffinityOk( pX, idxaff ) ) + continue; + + /* Figure out the collation sequence required from an index for + ** it to be useful for optimising expression pX. Store this + ** value in variable pColl. + */ + Debug.Assert( pX.pLeft != null ); + pColl = sqlite3BinaryCompareCollSeq( pParse, pX.pLeft, pX.pRight ); + Debug.Assert( pColl != null || pParse.nErr != 0 ); + + for ( j = 0; pIdx.aiColumn[j] != iColumn; j++ ) { - a = pWC.a[i]; - if ((a.wtFlags & TERM_DYNAMIC) != 0) { - sqlite3ExprDelete(db, ref a.pExpr); - } - if ((a.wtFlags & TERM_ORINFO) != 0) { - whereOrInfoDelete(db, a.u.pOrInfo); - } else if ((a.wtFlags & TERM_ANDINFO) != 0) { - whereAndInfoDelete(db, a.u.pAndInfo); - } - } - if (pWC.a != pWC.aStatic) { - sqlite3DbFree(db, ref pWC.a); + if ( NEVER( j >= pIdx.nColumn ) ) + return null; } + if ( pColl != null && !pColl.zName.Equals( pIdx.azColl[j], StringComparison.OrdinalIgnoreCase ) ) + continue; + } + return pTerm; } + } + return null; + } - /* - ** Add a single new WhereTerm entry to the WhereClause object pWC. - ** The new WhereTerm object is constructed from Expr p and with wtFlags. - ** The index in pWC.a[] of the new WhereTerm is returned on success. - ** 0 is returned if the new WhereTerm could not be added due to a memory - ** allocation error. The memory allocation failure will be recorded in - ** the db.mallocFailed flag so that higher-level functions can detect it. - ** - ** This routine will increase the size of the pWC.a[] array as necessary. - ** - ** If the wtFlags argument includes TERM_DYNAMIC, then responsibility - ** for freeing the expression p is Debug.Assumed by the WhereClause object pWC. - ** This is true even if this routine fails to allocate a new WhereTerm. - ** - ** WARNING: This routine might reallocate the space used to store - ** WhereTerms. All pointers to WhereTerms should be invalidated after - ** calling this routine. Such pointers may be reinitialized by referencing - ** the pWC.a[] array. - */ - static int whereClauseInsert(WhereClause pWC, Expr p, u8 wtFlags) { - WhereTerm pTerm; - int idx; - testcase(wtFlags & TERM_VIRTUAL); /* EV: R-00211-15100 */ - if (pWC.nTerm >= pWC.nSlot) { - //WhereTerm pOld = pWC.a; - //sqlite3 db = pWC.pParse.db; - Array.Resize(ref pWC.a, pWC.nSlot * 2); - //pWC.a = sqlite3DbMallocRaw(db, sizeof(pWC.a[0])*pWC.nSlot*2 ); - //if( pWC.a==null ){ - // if( wtFlags & TERM_DYNAMIC ){ - // sqlite3ExprDelete(db, ref p); - // } - // pWC.a = pOld; - // return 0; - //} - //memcpy(pWC.a, pOld, sizeof(pWC.a[0])*pWC.nTerm); - //if( pOld!=pWC.aStatic ){ - // sqlite3DbFree(db, ref pOld); - //} - //pWC.nSlot = sqlite3DbMallocSize(db, pWC.a)/sizeof(pWC.a[0]); - pWC.nSlot = pWC.a.Length - 1; - } - pWC.a[idx = pWC.nTerm++] = new WhereTerm(); - pTerm = pWC.a[idx]; - pTerm.pExpr = p; - pTerm.wtFlags = wtFlags; - pTerm.pWC = pWC; - pTerm.iParent = -1; - return idx; - } + /* Forward reference */ + //static void exprAnalyze(SrcList*, WhereClause*, int); - /* - ** This routine identifies subexpressions in the WHERE clause where - ** each subexpression is separated by the AND operator or some other - ** operator specified in the op parameter. The WhereClause structure - ** is filled with pointers to subexpressions. For example: - ** - ** WHERE a=='hello' AND coalesce(b,11)<10 AND (c+12!=d OR c==22) - ** \________/ \_______________/ \________________/ - ** slot[0] slot[1] slot[2] - ** - ** The original WHERE clause in pExpr is unaltered. All this routine - ** does is make slot[] entries point to substructure within pExpr. - ** - ** In the previous sentence and in the diagram, "slot[]" refers to - ** the WhereClause.a[] array. The slot[] array grows as needed to contain - ** all terms of the WHERE clause. - */ - static void whereSplit(WhereClause pWC, Expr pExpr, int op) { - pWC.op = (u8)op; - if (pExpr == null) - return; - if (pExpr.op != op) { - whereClauseInsert(pWC, pExpr, 0); - } else { - whereSplit(pWC, pExpr.pLeft, op); - whereSplit(pWC, pExpr.pRight, op); - } - } + /* + ** Call exprAnalyze on all terms in a WHERE clause. + ** + ** + */ + static void exprAnalyzeAll( + SrcList pTabList, /* the FROM clause */ + WhereClause pWC /* the WHERE clause to be analyzed */ + ) + { + int i; + for ( i = pWC.nTerm - 1; i >= 0; i-- ) + { + exprAnalyze( pTabList, pWC, i ); + } + } - /* - ** Initialize an expression mask set (a WhereMaskSet object) - */ - //#define initMaskSet(P) memset(P, 0, sizeof(*P)) +#if !SQLITE_OMIT_LIKE_OPTIMIZATION + /* +** Check to see if the given expression is a LIKE or GLOB operator that +** can be optimized using inequality constraints. Return TRUE if it is +** so and false if not. +** +** In order for the operator to be optimizible, the RHS must be a string +** literal that does not begin with a wildcard. +*/ + static int isLikeOrGlob( + Parse pParse, /* Parsing and code generating context */ + Expr pExpr, /* Test this expression */ + ref Expr ppPrefix, /* Pointer to TK_STRING expression with pattern prefix */ + ref bool pisComplete, /* True if the only wildcard is % in the last character */ + ref bool pnoCase /* True if uppercase is equivalent to lowercase */ + ) + { + string z = null; /* String on RHS of LIKE operator */ + Expr pRight, pLeft; /* Right and left size of LIKE operator */ + ExprList pList; /* List of operands to the LIKE operator */ + int c = 0; /* One character in z[] */ + int cnt; /* Number of non-wildcard prefix characters */ + char[] wc = new char[3]; /* Wildcard characters */ + sqlite3 db = pParse.db; /* Data_base connection */ + sqlite3_value pVal = null; + int op; /* Opcode of pRight */ + + if ( !sqlite3IsLikeFunction( db, pExpr, ref pnoCase, wc ) ) + { + return 0; + } + //#if SQLITE_EBCDIC + //if( pnoCase ) return 0; + //#endif + pList = pExpr.x.pList; + pLeft = pList.a[1].pExpr; + if ( pLeft.op != TK_COLUMN || sqlite3ExprAffinity( pLeft ) != SQLITE_AFF_TEXT ) + { + /* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must + ** be the name of an indexed column with TEXT affinity. */ + return 0; + } + Debug.Assert( pLeft.iColumn != ( -1 ) ); /* Because IPK never has AFF_TEXT */ - /* - ** Return the bitmask for the given cursor number. Return 0 if - ** iCursor is not in the set. - */ - static Bitmask getMask(WhereMaskSet pMaskSet, int iCursor) { - int i; - Debug.Assert(pMaskSet.n <= (int)sizeof(Bitmask) * 8); - for (i = 0; i < pMaskSet.n; i++) { - if (pMaskSet.ix[i] == iCursor) { - return ((Bitmask)1) << i; - } - } - return 0; + pRight = pList.a[0].pExpr; + op = pRight.op; + if ( op == TK_REGISTER ) + { + op = pRight.op2; + } + if ( op == TK_VARIABLE ) + { + Vdbe pReprepare = pParse.pReprepare; + int iCol = pRight.iColumn; + pVal = sqlite3VdbeGetValue( pReprepare, iCol, (byte)SQLITE_AFF_NONE ); + if ( pVal != null && sqlite3_value_type( pVal ) == SQLITE_TEXT ) + { + z = sqlite3_value_text( pVal ); } - - /* - ** Create a new mask for cursor iCursor. - ** - ** There is one cursor per table in the FROM clause. The number of - ** tables in the FROM clause is limited by a test early in the - ** sqlite3WhereBegin() routine. So we know that the pMaskSet.ix[] - ** array will never overflow. - */ - static void createMask(WhereMaskSet pMaskSet, int iCursor) { - Debug.Assert(pMaskSet.n < ArraySize(pMaskSet.ix)); - pMaskSet.ix[pMaskSet.n++] = iCursor; + sqlite3VdbeSetVarmask( pParse.pVdbe, iCol ); /* IMP: R-23257-02778 */ + Debug.Assert( pRight.op == TK_VARIABLE || pRight.op == TK_REGISTER ); + } + else if ( op == TK_STRING ) + { + z = pRight.u.zToken; + } + if ( !String.IsNullOrEmpty( z ) ) + { + cnt = 0; + while ( cnt < z.Length && ( c = z[cnt] ) != 0 && c != wc[0] && c != wc[1] && c != wc[2] ) + { + cnt++; } - - /* - ** This routine walks (recursively) an expression tree and generates - ** a bitmask indicating which tables are used in that expression - ** tree. - ** - ** In order for this routine to work, the calling function must have - ** previously invoked sqlite3ResolveExprNames() on the expression. See - ** the header comment on that routine for additional information. - ** The sqlite3ResolveExprNames() routines looks for column names and - ** sets their opcodes to TK_COLUMN and their Expr.iTable fields to - ** the VDBE cursor number of the table. This routine just has to - ** translate the cursor numbers into bitmask values and OR all - ** the bitmasks together. - */ - //static Bitmask exprListTableUsage(WhereMaskSet*, ExprList); - //static Bitmask exprSelectTableUsage(WhereMaskSet*, Select); - static Bitmask exprTableUsage(WhereMaskSet pMaskSet, Expr p) { - Bitmask mask = 0; - if (p == null) - return 0; - if (p.op == TK_COLUMN) { - mask = getMask(pMaskSet, p.iTable); - return mask; - } - mask = exprTableUsage(pMaskSet, p.pRight); - mask |= exprTableUsage(pMaskSet, p.pLeft); - if (ExprHasProperty(p, EP_xIsSelect)) { - mask |= exprSelectTableUsage(pMaskSet, p.x.pSelect); - } else { - mask |= exprListTableUsage(pMaskSet, p.x.pList); + if ( cnt != 0 && 255 != (u8)z[cnt - 1] ) + { + Expr pPrefix; + pisComplete = c == wc[0] && cnt == z.Length - 1; + pPrefix = sqlite3Expr( db, TK_STRING, z ); + if ( pPrefix != null ) + pPrefix.u.zToken = pPrefix.u.zToken.Substring( 0, cnt ); + ppPrefix = pPrefix; + if ( op == TK_VARIABLE ) + { + Vdbe v = pParse.pVdbe; + sqlite3VdbeSetVarmask( v, pRight.iColumn ); /* IMP: R-23257-02778 */ + if ( pisComplete && pRight.u.zToken.Length > 1 ) + { + /* If the rhs of the LIKE expression is a variable, and the current + ** value of the variable means there is no need to invoke the LIKE + ** function, then no OP_Variable will be added to the program. + ** This causes problems for the sqlite3_bind_parameter_name() + ** API. To workaround them, add a dummy OP_Variable here. + */ + int r1 = sqlite3GetTempReg( pParse ); + sqlite3ExprCodeTarget( pParse, pRight, r1 ); + sqlite3VdbeChangeP3( v, sqlite3VdbeCurrentAddr( v ) - 1, 0 ); + sqlite3ReleaseTempReg( pParse, r1 ); } - return mask; + } } - static Bitmask exprListTableUsage(WhereMaskSet pMaskSet, ExprList pList) { - int i; - Bitmask mask = 0; - if (pList != null) { - for (i = 0; i < pList.nExpr; i++) { - mask |= exprTableUsage(pMaskSet, pList.a[i].pExpr); - } - } - return mask; + else + { + z = null; } - static Bitmask exprSelectTableUsage(WhereMaskSet pMaskSet, Select pS) { - Bitmask mask = 0; - while (pS != null) { - mask |= exprListTableUsage(pMaskSet, pS.pEList); - mask |= exprListTableUsage(pMaskSet, pS.pGroupBy); - mask |= exprListTableUsage(pMaskSet, pS.pOrderBy); - mask |= exprTableUsage(pMaskSet, pS.pWhere); - mask |= exprTableUsage(pMaskSet, pS.pHaving); - pS = pS.pPrior; + } + + sqlite3ValueFree( ref pVal ); + return ( z != null ) ? 1 : 0; + } +#endif //* SQLITE_OMIT_LIKE_OPTIMIZATION */ + + +#if !SQLITE_OMIT_VIRTUALTABLE +/* +** Check to see if the given expression is of the form +** +** column MATCH expr +** +** If it is then return TRUE. If not, return FALSE. +*/ +static int isMatchOfColumn( +Expr pExpr /* Test this expression */ +){ +ExprList pList; + +if( pExpr.op!=TK_FUNCTION ){ +return 0; +} +if( !pExpr.u.zToken.Equals("match", StringComparison.OrdinalIgnoreCase ) ){ +return 0; +} +pList = pExpr.x.pList; +if( pList.nExpr!=2 ){ + return 0; +} +if( pList.a[1].pExpr.op != TK_COLUMN ){ +return 0; +} +return 1; +} +#endif //* SQLITE_OMIT_VIRTUALTABLE */ + + /* +** If the pBase expression originated in the ON or USING clause of +** a join, then transfer the appropriate markings over to derived. +*/ + static void transferJoinMarkings( Expr pDerived, Expr pBase ) + { + pDerived.flags = (u16)( pDerived.flags | pBase.flags & EP_FromJoin ); + pDerived.iRightJoinTable = pBase.iRightJoinTable; + } + +#if !(SQLITE_OMIT_OR_OPTIMIZATION) && !(SQLITE_OMIT_SUBQUERY) + /* +** Analyze a term that consists of two or more OR-connected +** subterms. So in: +** +** ... WHERE (a=5) AND (b=7 OR c=9 OR d=13) AND (d=13) +** ^^^^^^^^^^^^^^^^^^^^ +** +** This routine analyzes terms such as the middle term in the above example. +** A WhereOrTerm object is computed and attached to the term under +** analysis, regardless of the outcome of the analysis. Hence: +** +** WhereTerm.wtFlags |= TERM_ORINFO +** WhereTerm.u.pOrInfo = a dynamically allocated WhereOrTerm object +** +** The term being analyzed must have two or more of OR-connected subterms. +** A single subterm might be a set of AND-connected sub-subterms. +** Examples of terms under analysis: +** +** (A) t1.x=t2.y OR t1.x=t2.z OR t1.y=15 OR t1.z=t3.a+5 +** (B) x=expr1 OR expr2=x OR x=expr3 +** (C) t1.x=t2.y OR (t1.x=t2.z AND t1.y=15) +** (D) x=expr1 OR (y>11 AND y<22 AND z LIKE '*hello*') +** (E) (p.a=1 AND q.b=2 AND r.c=3) OR (p.x=4 AND q.y=5 AND r.z=6) +** +** CASE 1: +** +** If all subterms are of the form T.C=expr for some single column of C +** a single table T (as shown in example B above) then create a new virtual +** term that is an equivalent IN expression. In other words, if the term +** being analyzed is: +** +** x = expr1 OR expr2 = x OR x = expr3 +** +** then create a new virtual term like this: +** +** x IN (expr1,expr2,expr3) +** +** CASE 2: +** +** If all subterms are indexable by a single table T, then set +** +** WhereTerm.eOperator = WO_OR +** WhereTerm.u.pOrInfo.indexable |= the cursor number for table T +** +** A subterm is "indexable" if it is of the form +** "T.C " where C is any column of table T and +** is one of "=", "<", "<=", ">", ">=", "IS NULL", or "IN". +** A subterm is also indexable if it is an AND of two or more +** subsubterms at least one of which is indexable. Indexable AND +** subterms have their eOperator set to WO_AND and they have +** u.pAndInfo set to a dynamically allocated WhereAndTerm object. +** +** From another point of view, "indexable" means that the subterm could +** potentially be used with an index if an appropriate index exists. +** This analysis does not consider whether or not the index exists; that +** is something the bestIndex() routine will determine. This analysis +** only looks at whether subterms appropriate for indexing exist. +** +** All examples A through E above all satisfy case 2. But if a term +** also statisfies case 1 (such as B) we know that the optimizer will +** always prefer case 1, so in that case we pretend that case 2 is not +** satisfied. +** +** It might be the case that multiple tables are indexable. For example, +** (E) above is indexable on tables P, Q, and R. +** +** Terms that satisfy case 2 are candidates for lookup by using +** separate indices to find rowids for each subterm and composing +** the union of all rowids using a RowSet object. This is similar +** to "bitmap indices" in other data_base engines. +** +** OTHERWISE: +** +** If neither case 1 nor case 2 apply, then leave the eOperator set to +** zero. This term is not useful for search. +*/ + static void exprAnalyzeOrTerm( + SrcList pSrc, /* the FROM clause */ + WhereClause pWC, /* the complete WHERE clause */ + int idxTerm /* Index of the OR-term to be analyzed */ + ) + { + Parse pParse = pWC.pParse; /* Parser context */ + sqlite3 db = pParse.db; /* Data_base connection */ + WhereTerm pTerm = pWC.a[idxTerm]; /* The term to be analyzed */ + Expr pExpr = pTerm.pExpr; /* The expression of the term */ + WhereMaskSet pMaskSet = pWC.pMaskSet; /* Table use masks */ + int i; /* Loop counters */ + WhereClause pOrWc; /* Breakup of pTerm into subterms */ + WhereTerm pOrTerm; /* A Sub-term within the pOrWc */ + WhereOrInfo pOrInfo; /* Additional information Debug.Associated with pTerm */ + Bitmask chngToIN; /* Tables that might satisfy case 1 */ + Bitmask indexable; /* Tables that are indexable, satisfying case 2 */ + + /* + ** Break the OR clause into its separate subterms. The subterms are + ** stored in a WhereClause structure containing within the WhereOrInfo + ** object that is attached to the original OR clause term. + */ + Debug.Assert( ( pTerm.wtFlags & ( TERM_DYNAMIC | TERM_ORINFO | TERM_ANDINFO ) ) == 0 ); + Debug.Assert( pExpr.op == TK_OR ); + pTerm.u.pOrInfo = pOrInfo = new WhereOrInfo();//sqlite3DbMallocZero(db, sizeof(*pOrInfo)); + if ( pOrInfo == null ) + return; + pTerm.wtFlags |= TERM_ORINFO; + pOrWc = pOrInfo.wc; + whereClauseInit( pOrWc, pWC.pParse, pMaskSet ); + whereSplit( pOrWc, pExpr, TK_OR ); + exprAnalyzeAll( pSrc, pOrWc ); + // if ( db.mallocFailed != 0 ) return; + Debug.Assert( pOrWc.nTerm >= 2 ); + + /* + ** Compute the set of tables that might satisfy cases 1 or 2. + */ + indexable = ~(Bitmask)0; + chngToIN = ~( pWC.vmask ); + for ( i = pOrWc.nTerm - 1; i >= 0 && indexable != 0; i-- )//, pOrTerm++ ) + { + pOrTerm = pOrWc.a[i]; + if ( ( pOrTerm.eOperator & WO_SINGLE ) == 0 ) + { + WhereAndInfo pAndInfo; + Debug.Assert( pOrTerm.eOperator == 0 ); + Debug.Assert( ( pOrTerm.wtFlags & ( TERM_ANDINFO | TERM_ORINFO ) ) == 0 ); + chngToIN = 0; + pAndInfo = new WhereAndInfo();//sqlite3DbMallocRaw(db, sizeof(*pAndInfo)); + if ( pAndInfo != null ) + { + WhereClause pAndWC; + WhereTerm pAndTerm; + int j; + Bitmask b = 0; + pOrTerm.u.pAndInfo = pAndInfo; + pOrTerm.wtFlags |= TERM_ANDINFO; + pOrTerm.eOperator = WO_AND; + pAndWC = pAndInfo.wc; + whereClauseInit( pAndWC, pWC.pParse, pMaskSet ); + whereSplit( pAndWC, pOrTerm.pExpr, TK_AND ); + exprAnalyzeAll( pSrc, pAndWC ); + //testcase( db.mallocFailed ); + ////if ( 0 == db.mallocFailed ) + { + for ( j = 0; j < pAndWC.nTerm; j++ )//, pAndTerm++ ) + { + pAndTerm = pAndWC.a[j]; + Debug.Assert( pAndTerm.pExpr != null ); + if ( allowedOp( pAndTerm.pExpr.op ) ) + { + b |= getMask( pMaskSet, pAndTerm.leftCursor ); + } + } } - return mask; + indexable &= b; + } } - - /* - ** Return TRUE if the given operator is one of the operators that is - ** allowed for an indexable WHERE clause term. The allowed operators are - ** "=", "<", ">", "<=", ">=", and "IN". - ** - ** IMPLEMENTATION-OF: R-59926-26393 To be usable by an index a term must be - ** of one of the following forms: column = expression column > expression - ** column >= expression column < expression column <= expression - ** expression = column expression > column expression >= column - ** expression < column expression <= column column IN - ** (expression-list) column IN (subquery) column IS NULL - */ - static bool allowedOp(int op) { - Debug.Assert(TK_GT > TK_EQ && TK_GT < TK_GE); - Debug.Assert(TK_LT > TK_EQ && TK_LT < TK_GE); - Debug.Assert(TK_LE > TK_EQ && TK_LE < TK_GE); - Debug.Assert(TK_GE == TK_EQ + 4); - return op == TK_IN || (op >= TK_EQ && op <= TK_GE) || op == TK_ISNULL; + else if ( ( pOrTerm.wtFlags & TERM_COPIED ) != 0 ) + { + /* Skip this term for now. We revisit it when we process the + ** corresponding TERM_VIRTUAL term */ } - - /* - ** Swap two objects of type TYPE. - */ - //#define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;} - - /* - ** Commute a comparison operator. Expressions of the form "X op Y" - ** are converted into "Y op X". - ** - ** If a collation sequence is Debug.Associated with either the left or right - ** side of the comparison, it remains Debug.Associated with the same side after - ** the commutation. So "Y collate NOCASE op X" becomes - ** "X collate NOCASE op Y". This is because any collation sequence on - ** the left hand side of a comparison overrides any collation sequence - ** attached to the right. For the same reason the EP_ExpCollate flag - ** is not commuted. - */ - static void exprCommute(Parse pParse, Expr pExpr) { - u16 expRight = (u16)(pExpr.pRight.flags & EP_ExpCollate); - u16 expLeft = (u16)(pExpr.pLeft.flags & EP_ExpCollate); - Debug.Assert(allowedOp(pExpr.op) && pExpr.op != TK_IN); - pExpr.pRight.pColl = sqlite3ExprCollSeq(pParse, pExpr.pRight); - pExpr.pLeft.pColl = sqlite3ExprCollSeq(pParse, pExpr.pLeft); - SWAP(ref pExpr.pRight.pColl, ref pExpr.pLeft.pColl); - pExpr.pRight.flags = (u16)((pExpr.pRight.flags & ~EP_ExpCollate) | expLeft); - pExpr.pLeft.flags = (u16)((pExpr.pLeft.flags & ~EP_ExpCollate) | expRight); - SWAP(ref pExpr.pRight, ref pExpr.pLeft); - if (pExpr.op >= TK_GT) { - Debug.Assert(TK_LT == TK_GT + 2); - Debug.Assert(TK_GE == TK_LE + 2); - Debug.Assert(TK_GT > TK_EQ); - Debug.Assert(TK_GT < TK_LE); - Debug.Assert(pExpr.op >= TK_GT && pExpr.op <= TK_GE); - pExpr.op = (u8)(((pExpr.op - TK_GT) ^ 2) + TK_GT); - } + else + { + Bitmask b; + b = getMask( pMaskSet, pOrTerm.leftCursor ); + if ( ( pOrTerm.wtFlags & TERM_VIRTUAL ) != 0 ) + { + WhereTerm pOther = pOrWc.a[pOrTerm.iParent]; + b |= getMask( pMaskSet, pOther.leftCursor ); + } + indexable &= b; + if ( pOrTerm.eOperator != WO_EQ ) + { + chngToIN = 0; + } + else + { + chngToIN &= b; + } } + } - /* - ** Translate from TK_xx operator to WO_xx bitmask. - */ - static u16 operatorMask(int op) { - u16 c; - Debug.Assert(allowedOp(op)); - if (op == TK_IN) { - c = WO_IN; - } else if (op == TK_ISNULL) { - c = WO_ISNULL; - } else { - Debug.Assert((WO_EQ << (op - TK_EQ)) < 0x7fff); - c = (u16)(WO_EQ << (op - TK_EQ)); - } - Debug.Assert(op != TK_ISNULL || c == WO_ISNULL); - Debug.Assert(op != TK_IN || c == WO_IN); - Debug.Assert(op != TK_EQ || c == WO_EQ); - Debug.Assert(op != TK_LT || c == WO_LT); - Debug.Assert(op != TK_LE || c == WO_LE); - Debug.Assert(op != TK_GT || c == WO_GT); - Debug.Assert(op != TK_GE || c == WO_GE); - return c; - } + /* + ** Record the set of tables that satisfy case 2. The set might be + ** empty. + */ + pOrInfo.indexable = indexable; + pTerm.eOperator = (u16)( indexable == 0 ? 0 : WO_OR ); - /* - ** Search for a term in the WHERE clause that is of the form "X " - ** where X is a reference to the iColumn of table iCur and is one of - ** the WO_xx operator codes specified by the op parameter. - ** Return a pointer to the term. Return 0 if not found. + /* + ** chngToIN holds a set of tables that *might* satisfy case 1. But + ** we have to do some additional checking to see if case 1 really + ** is satisfied. + ** + ** chngToIN will hold either 0, 1, or 2 bits. The 0-bit case means + ** that there is no possibility of transforming the OR clause into an + ** IN operator because one or more terms in the OR clause contain + ** something other than == on a column in the single table. The 1-bit + ** case means that every term of the OR clause is of the form + ** "table.column=expr" for some single table. The one bit that is set + ** will correspond to the common table. We still need to check to make + ** sure the same column is used on all terms. The 2-bit case is when + ** the all terms are of the form "table1.column=table2.column". It + ** might be possible to form an IN operator with either table1.column + ** or table2.column as the LHS if either is common to every term of + ** the OR clause. + ** + ** Note that terms of the form "table.column1=table.column2" (the + ** same table on both sizes of the ==) cannot be optimized. + */ + if ( chngToIN != 0 ) + { + int okToChngToIN = 0; /* True if the conversion to IN is valid */ + int iColumn = -1; /* Column index on lhs of IN operator */ + int iCursor = -1; /* Table cursor common to all terms */ + int j = 0; /* Loop counter */ + + /* Search for a table and column that appears on one side or the + ** other of the == operator in every subterm. That table and column + ** will be recorded in iCursor and iColumn. There might not be any + ** such table and column. Set okToChngToIN if an appropriate table + ** and column is found but leave okToChngToIN false if not found. */ - static WhereTerm findTerm( - WhereClause pWC, /* The WHERE clause to be searched */ - int iCur, /* Cursor number of LHS */ - int iColumn, /* Column number of LHS */ - Bitmask notReady, /* RHS must not overlap with this mask */ - u32 op, /* Mask of WO_xx values describing operator */ - Index pIdx /* Must be compatible with this index, if not NULL */ - ) { - WhereTerm pTerm; - int k; - Debug.Assert(iCur >= 0); - op &= WO_ALL; - for (k = pWC.nTerm; k != 0; k--)//, pTerm++) + for ( j = 0; j < 2 && 0 == okToChngToIN; j++ ) + { + //pOrTerm = pOrWc.a; + for ( i = pOrWc.nTerm - 1; i >= 0; i-- )//, pOrTerm++) + { + pOrTerm = pOrWc.a[pOrWc.nTerm - 1 - i]; + Debug.Assert( pOrTerm.eOperator == WO_EQ ); + pOrTerm.wtFlags = (u8)( pOrTerm.wtFlags & ~TERM_OR_OK ); + if ( pOrTerm.leftCursor == iCursor ) { - pTerm = pWC.a[pWC.nTerm - k]; - if (pTerm.leftCursor == iCur - && (pTerm.prereqRight & notReady) == 0 - && pTerm.u.leftColumn == iColumn - && (pTerm.eOperator & op) != 0 - ) { - if (pIdx != null && pTerm.eOperator != WO_ISNULL) { - Expr pX = pTerm.pExpr; - CollSeq pColl; - char idxaff; - int j; - Parse pParse = pWC.pParse; - - idxaff = pIdx.pTable.aCol[iColumn].affinity; - if (!sqlite3IndexAffinityOk(pX, idxaff)) - continue; - - /* Figure out the collation sequence required from an index for - ** it to be useful for optimising expression pX. Store this - ** value in variable pColl. - */ - Debug.Assert(pX.pLeft != null); - pColl = sqlite3BinaryCompareCollSeq(pParse, pX.pLeft, pX.pRight); - Debug.Assert(pColl != null || pParse.nErr != 0); - - for (j = 0; pIdx.aiColumn[j] != iColumn; j++) { - if (NEVER(j >= pIdx.nColumn)) - return null; - } - if (pColl != null && !pColl.zName.Equals(pIdx.azColl[j], StringComparison.OrdinalIgnoreCase)) - continue; - } - return pTerm; - } - } - return null; - } - - /* Forward reference */ - //static void exprAnalyze(SrcList*, WhereClause*, int); - - /* - ** Call exprAnalyze on all terms in a WHERE clause. - ** - ** - */ - static void exprAnalyzeAll( - SrcList pTabList, /* the FROM clause */ - WhereClause pWC /* the WHERE clause to be analyzed */ - ) { - int i; - for (i = pWC.nTerm - 1; i >= 0; i--) { - exprAnalyze(pTabList, pWC, i); - } - } - -#if !SQLITE_OMIT_LIKE_OPTIMIZATION - /* - ** Check to see if the given expression is a LIKE or GLOB operator that - ** can be optimized using inequality constraints. Return TRUE if it is - ** so and false if not. - ** - ** In order for the operator to be optimizible, the RHS must be a string - ** literal that does not begin with a wildcard. - */ - static int isLikeOrGlob( - Parse pParse, /* Parsing and code generating context */ - Expr pExpr, /* Test this expression */ - ref Expr ppPrefix, /* Pointer to TK_STRING expression with pattern prefix */ - ref bool pisComplete, /* True if the only wildcard is % in the last character */ - ref bool pnoCase /* True if uppercase is equivalent to lowercase */ - ) { - string z = null; /* String on RHS of LIKE operator */ - Expr pRight, pLeft; /* Right and left size of LIKE operator */ - ExprList pList; /* List of operands to the LIKE operator */ - int c = 0; /* One character in z[] */ - int cnt; /* Number of non-wildcard prefix characters */ - char[] wc = new char[3]; /* Wildcard characters */ - sqlite3 db = pParse.db; /* Data_base connection */ - sqlite3_value pVal = null; - int op; /* Opcode of pRight */ - - if (!sqlite3IsLikeFunction(db, pExpr, ref pnoCase, wc)) { - return 0; + /* This is the 2-bit case and we are on the second iteration and + ** current term is from the first iteration. So skip this term. */ + Debug.Assert( j == 1 ); + continue; } - //#if SQLITE_EBCDIC - //if( pnoCase ) return 0; - //#endif - pList = pExpr.x.pList; - pLeft = pList.a[1].pExpr; - if (pLeft.op != TK_COLUMN || sqlite3ExprAffinity(pLeft) != SQLITE_AFF_TEXT) { - /* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must - ** be the name of an indexed column with TEXT affinity. */ - return 0; + if ( ( chngToIN & getMask( pMaskSet, pOrTerm.leftCursor ) ) == 0 ) + { + /* This term must be of the form t1.a==t2.b where t2 is in the + ** chngToIN set but t1 is not. This term will be either preceeded + ** or follwed by an inverted copy (t2.b==t1.a). Skip this term + ** and use its inversion. */ + testcase( pOrTerm.wtFlags & TERM_COPIED ); + testcase( pOrTerm.wtFlags & TERM_VIRTUAL ); + Debug.Assert( ( pOrTerm.wtFlags & ( TERM_COPIED | TERM_VIRTUAL ) ) != 0 ); + continue; } - Debug.Assert(pLeft.iColumn != (-1)); /* Because IPK never has AFF_TEXT */ + iColumn = pOrTerm.u.leftColumn; + iCursor = pOrTerm.leftCursor; + break; + } + if ( i < 0 ) + { + /* No candidate table+column was found. This can only occur + ** on the second iteration */ + Debug.Assert( j == 1 ); + Debug.Assert( ( chngToIN & ( chngToIN - 1 ) ) == 0 ); + Debug.Assert( chngToIN == getMask( pMaskSet, iCursor ) ); + break; + } + testcase( j == 1 ); - pRight = pList.a[0].pExpr; - op = pRight.op; - if (op == TK_REGISTER) { - op = pRight.op2; + /* We have found a candidate table and column. Check to see if that + ** table and column is common to every term in the OR clause */ + okToChngToIN = 1; + for ( ; i >= 0 && okToChngToIN != 0; i-- )//, pOrTerm++) + { + pOrTerm = pOrWc.a[pOrWc.nTerm - 1 - i]; + Debug.Assert( pOrTerm.eOperator == WO_EQ ); + if ( pOrTerm.leftCursor != iCursor ) + { + pOrTerm.wtFlags = (u8)( pOrTerm.wtFlags & ~TERM_OR_OK ); } - if (op == TK_VARIABLE) { - Vdbe pReprepare = pParse.pReprepare; - int iCol = pRight.iColumn; - pVal = sqlite3VdbeGetValue(pReprepare, iCol, (byte)SQLITE_AFF_NONE); - if (pVal != null && sqlite3_value_type(pVal) == SQLITE_TEXT) { - z = sqlite3_value_text(pVal); - } - sqlite3VdbeSetVarmask(pParse.pVdbe, iCol); /* IMP: R-23257-02778 */ - Debug.Assert(pRight.op == TK_VARIABLE || pRight.op == TK_REGISTER); - } else if (op == TK_STRING) { - z = pRight.u.zToken; + else if ( pOrTerm.u.leftColumn != iColumn ) + { + okToChngToIN = 0; } - if (!String.IsNullOrEmpty(z)) { - cnt = 0; - while (cnt < z.Length && (c = z[cnt]) != 0 && c != wc[0] && c != wc[1] && c != wc[2]) { - cnt++; - } - if (cnt != 0 && 255 != (u8)z[cnt - 1]) { - Expr pPrefix; - pisComplete = c == wc[0] && cnt == z.Length - 1; - pPrefix = sqlite3Expr(db, TK_STRING, z); - if (pPrefix != null) - pPrefix.u.zToken = pPrefix.u.zToken.Substring(0, cnt); - ppPrefix = pPrefix; - if (op == TK_VARIABLE) { - Vdbe v = pParse.pVdbe; - sqlite3VdbeSetVarmask(v, pRight.iColumn); /* IMP: R-23257-02778 */ - if (pisComplete && pRight.u.zToken.Length > 1) { - /* If the rhs of the LIKE expression is a variable, and the current - ** value of the variable means there is no need to invoke the LIKE - ** function, then no OP_Variable will be added to the program. - ** This causes problems for the sqlite3_bind_parameter_name() - ** API. To workaround them, add a dummy OP_Variable here. - */ - int r1 = sqlite3GetTempReg(pParse); - sqlite3ExprCodeTarget(pParse, pRight, r1); - sqlite3VdbeChangeP3(v, sqlite3VdbeCurrentAddr(v) - 1, 0); - sqlite3ReleaseTempReg(pParse, r1); - } - } - } else { - z = null; - } + else + { + int affLeft, affRight; + /* If the right-hand side is also a column, then the affinities + ** of both right and left sides must be such that no type + ** conversions are required on the right. (Ticket #2249) + */ + affRight = sqlite3ExprAffinity( pOrTerm.pExpr.pRight ); + affLeft = sqlite3ExprAffinity( pOrTerm.pExpr.pLeft ); + if ( affRight != 0 && affRight != affLeft ) + { + okToChngToIN = 0; + } + else + { + pOrTerm.wtFlags |= TERM_OR_OK; + } } - - sqlite3ValueFree(ref pVal); - return (z != null) ? 1 : 0; + } } -#endif //* SQLITE_OMIT_LIKE_OPTIMIZATION */ - -#if !SQLITE_OMIT_VIRTUALTABLE - /* - ** Check to see if the given expression is of the form - ** - ** column MATCH expr + /* At this point, okToChngToIN is true if original pTerm satisfies + ** case 1. In that case, construct a new virtual term that is + ** pTerm converted into an IN operator. ** - ** If it is then return TRUE. If not, return FALSE. + ** EV: R-00211-15100 */ - static int isMatchOfColumn( - Expr pExpr /* Test this expression */ - ) { - ExprList pList; - - if (pExpr.op != TK_FUNCTION) { - return 0; - } - if (!pExpr.u.zToken.Equals("match", StringComparison.OrdinalIgnoreCase)) { - return 0; - } - pList = pExpr.x.pList; - if (pList.nExpr != 2) { - return 0; - } - if (pList.a[1].pExpr.op != TK_COLUMN) { - return 0; - } - return 1; - } -#endif //* SQLITE_OMIT_VIRTUALTABLE */ - - /* - ** If the pBase expression originated in the ON or USING clause of - ** a join, then transfer the appropriate markings over to derived. - */ - static void transferJoinMarkings(Expr pDerived, Expr pBase) { - pDerived.flags = (u16)(pDerived.flags | pBase.flags & EP_FromJoin); - pDerived.iRightJoinTable = pBase.iRightJoinTable; - } - -#if !(SQLITE_OMIT_OR_OPTIMIZATION) && !(SQLITE_OMIT_SUBQUERY) - /* - ** Analyze a term that consists of two or more OR-connected - ** subterms. So in: - ** - ** ... WHERE (a=5) AND (b=7 OR c=9 OR d=13) AND (d=13) - ** ^^^^^^^^^^^^^^^^^^^^ - ** - ** This routine analyzes terms such as the middle term in the above example. - ** A WhereOrTerm object is computed and attached to the term under - ** analysis, regardless of the outcome of the analysis. Hence: - ** - ** WhereTerm.wtFlags |= TERM_ORINFO - ** WhereTerm.u.pOrInfo = a dynamically allocated WhereOrTerm object - ** - ** The term being analyzed must have two or more of OR-connected subterms. - ** A single subterm might be a set of AND-connected sub-subterms. - ** Examples of terms under analysis: - ** - ** (A) t1.x=t2.y OR t1.x=t2.z OR t1.y=15 OR t1.z=t3.a+5 - ** (B) x=expr1 OR expr2=x OR x=expr3 - ** (C) t1.x=t2.y OR (t1.x=t2.z AND t1.y=15) - ** (D) x=expr1 OR (y>11 AND y<22 AND z LIKE '*hello*') - ** (E) (p.a=1 AND q.b=2 AND r.c=3) OR (p.x=4 AND q.y=5 AND r.z=6) - ** - ** CASE 1: - ** - ** If all subterms are of the form T.C=expr for some single column of C - ** a single table T (as shown in example B above) then create a new virtual - ** term that is an equivalent IN expression. In other words, if the term - ** being analyzed is: - ** - ** x = expr1 OR expr2 = x OR x = expr3 - ** - ** then create a new virtual term like this: - ** - ** x IN (expr1,expr2,expr3) - ** - ** CASE 2: - ** - ** If all subterms are indexable by a single table T, then set - ** - ** WhereTerm.eOperator = WO_OR - ** WhereTerm.u.pOrInfo.indexable |= the cursor number for table T - ** - ** A subterm is "indexable" if it is of the form - ** "T.C " where C is any column of table T and - ** is one of "=", "<", "<=", ">", ">=", "IS NULL", or "IN". - ** A subterm is also indexable if it is an AND of two or more - ** subsubterms at least one of which is indexable. Indexable AND - ** subterms have their eOperator set to WO_AND and they have - ** u.pAndInfo set to a dynamically allocated WhereAndTerm object. - ** - ** From another point of view, "indexable" means that the subterm could - ** potentially be used with an index if an appropriate index exists. - ** This analysis does not consider whether or not the index exists; that - ** is something the bestIndex() routine will determine. This analysis - ** only looks at whether subterms appropriate for indexing exist. - ** - ** All examples A through E above all satisfy case 2. But if a term - ** also statisfies case 1 (such as B) we know that the optimizer will - ** always prefer case 1, so in that case we pretend that case 2 is not - ** satisfied. - ** - ** It might be the case that multiple tables are indexable. For example, - ** (E) above is indexable on tables P, Q, and R. - ** - ** Terms that satisfy case 2 are candidates for lookup by using - ** separate indices to find rowids for each subterm and composing - ** the union of all rowids using a RowSet object. This is similar - ** to "bitmap indices" in other data_base engines. - ** - ** OTHERWISE: - ** - ** If neither case 1 nor case 2 apply, then leave the eOperator set to - ** zero. This term is not useful for search. - */ - static void exprAnalyzeOrTerm( - SrcList pSrc, /* the FROM clause */ - WhereClause pWC, /* the complete WHERE clause */ - int idxTerm /* Index of the OR-term to be analyzed */ - ) { - Parse pParse = pWC.pParse; /* Parser context */ - sqlite3 db = pParse.db; /* Data_base connection */ - WhereTerm pTerm = pWC.a[idxTerm]; /* The term to be analyzed */ - Expr pExpr = pTerm.pExpr; /* The expression of the term */ - WhereMaskSet pMaskSet = pWC.pMaskSet; /* Table use masks */ - int i; /* Loop counters */ - WhereClause pOrWc; /* Breakup of pTerm into subterms */ - WhereTerm pOrTerm; /* A Sub-term within the pOrWc */ - WhereOrInfo pOrInfo; /* Additional information Debug.Associated with pTerm */ - Bitmask chngToIN; /* Tables that might satisfy case 1 */ - Bitmask indexable; /* Tables that are indexable, satisfying case 2 */ - - /* - ** Break the OR clause into its separate subterms. The subterms are - ** stored in a WhereClause structure containing within the WhereOrInfo - ** object that is attached to the original OR clause term. - */ - Debug.Assert((pTerm.wtFlags & (TERM_DYNAMIC | TERM_ORINFO | TERM_ANDINFO)) == 0); - Debug.Assert(pExpr.op == TK_OR); - pTerm.u.pOrInfo = pOrInfo = new WhereOrInfo();//sqlite3DbMallocZero(db, sizeof(*pOrInfo)); - if (pOrInfo == null) - return; - pTerm.wtFlags |= TERM_ORINFO; - pOrWc = pOrInfo.wc; - whereClauseInit(pOrWc, pWC.pParse, pMaskSet); - whereSplit(pOrWc, pExpr, TK_OR); - exprAnalyzeAll(pSrc, pOrWc); - // if ( db.mallocFailed != 0 ) return; - Debug.Assert(pOrWc.nTerm >= 2); - - /* - ** Compute the set of tables that might satisfy cases 1 or 2. - */ - indexable = ~(Bitmask)0; - chngToIN = ~(pWC.vmask); - for (i = pOrWc.nTerm - 1; i >= 0 && indexable != 0; i--)//, pOrTerm++ ) - { - pOrTerm = pOrWc.a[i]; - if ((pOrTerm.eOperator & WO_SINGLE) == 0) { - WhereAndInfo pAndInfo; - Debug.Assert(pOrTerm.eOperator == 0); - Debug.Assert((pOrTerm.wtFlags & (TERM_ANDINFO | TERM_ORINFO)) == 0); - chngToIN = 0; - pAndInfo = new WhereAndInfo();//sqlite3DbMallocRaw(db, sizeof(*pAndInfo)); - if (pAndInfo != null) { - WhereClause pAndWC; - WhereTerm pAndTerm; - int j; - Bitmask b = 0; - pOrTerm.u.pAndInfo = pAndInfo; - pOrTerm.wtFlags |= TERM_ANDINFO; - pOrTerm.eOperator = WO_AND; - pAndWC = pAndInfo.wc; - whereClauseInit(pAndWC, pWC.pParse, pMaskSet); - whereSplit(pAndWC, pOrTerm.pExpr, TK_AND); - exprAnalyzeAll(pSrc, pAndWC); - //testcase( db.mallocFailed ); - ////if ( 0 == db.mallocFailed ) - { - for (j = 0; j < pAndWC.nTerm; j++)//, pAndTerm++ ) - { - pAndTerm = pAndWC.a[j]; - Debug.Assert(pAndTerm.pExpr != null); - if (allowedOp(pAndTerm.pExpr.op)) { - b |= getMask(pMaskSet, pAndTerm.leftCursor); - } - } - } - indexable &= b; - } - } else if ((pOrTerm.wtFlags & TERM_COPIED) != 0) { - /* Skip this term for now. We revisit it when we process the - ** corresponding TERM_VIRTUAL term */ - } else { - Bitmask b; - b = getMask(pMaskSet, pOrTerm.leftCursor); - if ((pOrTerm.wtFlags & TERM_VIRTUAL) != 0) { - WhereTerm pOther = pOrWc.a[pOrTerm.iParent]; - b |= getMask(pMaskSet, pOther.leftCursor); - } - indexable &= b; - if (pOrTerm.eOperator != WO_EQ) { - chngToIN = 0; - } else { - chngToIN &= b; - } - } - } - - /* - ** Record the set of tables that satisfy case 2. The set might be - ** empty. - */ - pOrInfo.indexable = indexable; - pTerm.eOperator = (u16)(indexable == 0 ? 0 : WO_OR); - - /* - ** chngToIN holds a set of tables that *might* satisfy case 1. But - ** we have to do some additional checking to see if case 1 really - ** is satisfied. - ** - ** chngToIN will hold either 0, 1, or 2 bits. The 0-bit case means - ** that there is no possibility of transforming the OR clause into an - ** IN operator because one or more terms in the OR clause contain - ** something other than == on a column in the single table. The 1-bit - ** case means that every term of the OR clause is of the form - ** "table.column=expr" for some single table. The one bit that is set - ** will correspond to the common table. We still need to check to make - ** sure the same column is used on all terms. The 2-bit case is when - ** the all terms are of the form "table1.column=table2.column". It - ** might be possible to form an IN operator with either table1.column - ** or table2.column as the LHS if either is common to every term of - ** the OR clause. - ** - ** Note that terms of the form "table.column1=table.column2" (the - ** same table on both sizes of the ==) cannot be optimized. - */ - if (chngToIN != 0) { - int okToChngToIN = 0; /* True if the conversion to IN is valid */ - int iColumn = -1; /* Column index on lhs of IN operator */ - int iCursor = -1; /* Table cursor common to all terms */ - int j = 0; /* Loop counter */ - - /* Search for a table and column that appears on one side or the - ** other of the == operator in every subterm. That table and column - ** will be recorded in iCursor and iColumn. There might not be any - ** such table and column. Set okToChngToIN if an appropriate table - ** and column is found but leave okToChngToIN false if not found. - */ - for (j = 0; j < 2 && 0 == okToChngToIN; j++) { - //pOrTerm = pOrWc.a; - for (i = pOrWc.nTerm - 1; i >= 0; i--)//, pOrTerm++) - { - pOrTerm = pOrWc.a[pOrWc.nTerm - 1 - i]; - Debug.Assert(pOrTerm.eOperator == WO_EQ); - pOrTerm.wtFlags = (u8)(pOrTerm.wtFlags & ~TERM_OR_OK); - if (pOrTerm.leftCursor == iCursor) { - /* This is the 2-bit case and we are on the second iteration and - ** current term is from the first iteration. So skip this term. */ - Debug.Assert(j == 1); - continue; - } - if ((chngToIN & getMask(pMaskSet, pOrTerm.leftCursor)) == 0) { - /* This term must be of the form t1.a==t2.b where t2 is in the - ** chngToIN set but t1 is not. This term will be either preceeded - ** or follwed by an inverted copy (t2.b==t1.a). Skip this term - ** and use its inversion. */ - testcase(pOrTerm.wtFlags & TERM_COPIED); - testcase(pOrTerm.wtFlags & TERM_VIRTUAL); - Debug.Assert((pOrTerm.wtFlags & (TERM_COPIED | TERM_VIRTUAL)) != 0); - continue; - } - iColumn = pOrTerm.u.leftColumn; - iCursor = pOrTerm.leftCursor; - break; - } - if (i < 0) { - /* No candidate table+column was found. This can only occur - ** on the second iteration */ - Debug.Assert(j == 1); - Debug.Assert((chngToIN & (chngToIN - 1)) == 0); - Debug.Assert(chngToIN == getMask(pMaskSet, iCursor)); - break; - } - testcase(j == 1); - - /* We have found a candidate table and column. Check to see if that - ** table and column is common to every term in the OR clause */ - okToChngToIN = 1; - for (; i >= 0 && okToChngToIN != 0; i--)//, pOrTerm++) - { - pOrTerm = pOrWc.a[pOrWc.nTerm - 1 - i]; - Debug.Assert(pOrTerm.eOperator == WO_EQ); - if (pOrTerm.leftCursor != iCursor) { - pOrTerm.wtFlags = (u8)(pOrTerm.wtFlags & ~TERM_OR_OK); - } else if (pOrTerm.u.leftColumn != iColumn) { - okToChngToIN = 0; - } else { - int affLeft, affRight; - /* If the right-hand side is also a column, then the affinities - ** of both right and left sides must be such that no type - ** conversions are required on the right. (Ticket #2249) - */ - affRight = sqlite3ExprAffinity(pOrTerm.pExpr.pRight); - affLeft = sqlite3ExprAffinity(pOrTerm.pExpr.pLeft); - if (affRight != 0 && affRight != affLeft) { - okToChngToIN = 0; - } else { - pOrTerm.wtFlags |= TERM_OR_OK; - } - } - } - } + if ( okToChngToIN != 0 ) + { + Expr pDup; /* A transient duplicate expression */ + ExprList pList = null; /* The RHS of the IN operator */ + Expr pLeft = null; /* The LHS of the IN operator */ + Expr pNew; /* The complete IN operator */ - /* At this point, okToChngToIN is true if original pTerm satisfies - ** case 1. In that case, construct a new virtual term that is - ** pTerm converted into an IN operator. - ** - ** EV: R-00211-15100 - */ - if (okToChngToIN != 0) { - Expr pDup; /* A transient duplicate expression */ - ExprList pList = null; /* The RHS of the IN operator */ - Expr pLeft = null; /* The LHS of the IN operator */ - Expr pNew; /* The complete IN operator */ - - for (i = pOrWc.nTerm - 1; i >= 0; i--)//, pOrTerm++) - { - pOrTerm = pOrWc.a[pOrWc.nTerm - 1 - i]; - if ((pOrTerm.wtFlags & TERM_OR_OK) == 0) - continue; - Debug.Assert(pOrTerm.eOperator == WO_EQ); - Debug.Assert(pOrTerm.leftCursor == iCursor); - Debug.Assert(pOrTerm.u.leftColumn == iColumn); - pDup = sqlite3ExprDup(db, pOrTerm.pExpr.pRight, 0); - pList = sqlite3ExprListAppend(pWC.pParse, pList, pDup); - pLeft = pOrTerm.pExpr.pLeft; - } - Debug.Assert(pLeft != null); - pDup = sqlite3ExprDup(db, pLeft, 0); - pNew = sqlite3PExpr(pParse, TK_IN, pDup, null, null); - if (pNew != null) { - int idxNew; - transferJoinMarkings(pNew, pExpr); - Debug.Assert(!ExprHasProperty(pNew, EP_xIsSelect)); - pNew.x.pList = pList; - idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL | TERM_DYNAMIC); - testcase(idxNew == 0); - exprAnalyze(pSrc, pWC, idxNew); - pTerm = pWC.a[idxTerm]; - pWC.a[idxNew].iParent = idxTerm; - pTerm.nChild = 1; - } else { - sqlite3ExprListDelete(db, ref pList); - } - pTerm.eOperator = WO_NOOP; /* case 1 trumps case 2 */ - } - } + for ( i = pOrWc.nTerm - 1; i >= 0; i-- )//, pOrTerm++) + { + pOrTerm = pOrWc.a[pOrWc.nTerm - 1 - i]; + if ( ( pOrTerm.wtFlags & TERM_OR_OK ) == 0 ) + continue; + Debug.Assert( pOrTerm.eOperator == WO_EQ ); + Debug.Assert( pOrTerm.leftCursor == iCursor ); + Debug.Assert( pOrTerm.u.leftColumn == iColumn ); + pDup = sqlite3ExprDup( db, pOrTerm.pExpr.pRight, 0 ); + pList = sqlite3ExprListAppend( pWC.pParse, pList, pDup ); + pLeft = pOrTerm.pExpr.pLeft; + } + Debug.Assert( pLeft != null ); + pDup = sqlite3ExprDup( db, pLeft, 0 ); + pNew = sqlite3PExpr( pParse, TK_IN, pDup, null, null ); + if ( pNew != null ) + { + int idxNew; + transferJoinMarkings( pNew, pExpr ); + Debug.Assert( !ExprHasProperty( pNew, EP_xIsSelect ) ); + pNew.x.pList = pList; + idxNew = whereClauseInsert( pWC, pNew, TERM_VIRTUAL | TERM_DYNAMIC ); + testcase( idxNew == 0 ); + exprAnalyze( pSrc, pWC, idxNew ); + pTerm = pWC.a[idxTerm]; + pWC.a[idxNew].iParent = idxTerm; + pTerm.nChild = 1; + } + else + { + sqlite3ExprListDelete( db, ref pList ); + } + pTerm.eOperator = WO_NOOP; /* case 1 trumps case 2 */ } + } + } #endif //* !SQLITE_OMIT_OR_OPTIMIZATION && !SQLITE_OMIT_SUBQUERY */ - /* - ** The input to this routine is an WhereTerm structure with only the - ** "pExpr" field filled in. The job of this routine is to analyze the - ** subexpression and populate all the other fields of the WhereTerm - ** structure. - ** - ** If the expression is of the form " X" it gets commuted - ** to the standard form of "X ". - ** - ** If the expression is of the form "X Y" where both X and Y are - ** columns, then the original expression is unchanged and a new virtual - ** term of the form "Y X" is added to the WHERE clause and - ** analyzed separately. The original term is marked with TERM_COPIED - ** and the new term is marked with TERM_DYNAMIC (because it's pExpr - ** needs to be freed with the WhereClause) and TERM_VIRTUAL (because it - ** is a commuted copy of a prior term.) The original term has nChild=1 - ** and the copy has idxParent set to the index of the original term. - */ - static void exprAnalyze( - SrcList pSrc, /* the FROM clause */ - WhereClause pWC, /* the WHERE clause */ - int idxTerm /* Index of the term to be analyzed */ - ) { - WhereTerm pTerm; /* The term to be analyzed */ - WhereMaskSet pMaskSet; /* Set of table index masks */ - Expr pExpr; /* The expression to be analyzed */ - Bitmask prereqLeft; /* Prerequesites of the pExpr.pLeft */ - Bitmask prereqAll; /* Prerequesites of pExpr */ - Bitmask extraRight = 0; /* Extra dependencies on LEFT JOIN */ - Expr pStr1 = null; /* RHS of LIKE/GLOB operator */ - bool isComplete = false; /* RHS of LIKE/GLOB ends with wildcard */ - bool noCase = false; /* LIKE/GLOB distinguishes case */ - int op; /* Top-level operator. pExpr.op */ - Parse pParse = pWC.pParse; /* Parsing context */ - sqlite3 db = pParse.db; /* Data_base connection */ - + /* +** The input to this routine is an WhereTerm structure with only the +** "pExpr" field filled in. The job of this routine is to analyze the +** subexpression and populate all the other fields of the WhereTerm +** structure. +** +** If the expression is of the form " X" it gets commuted +** to the standard form of "X ". +** +** If the expression is of the form "X Y" where both X and Y are +** columns, then the original expression is unchanged and a new virtual +** term of the form "Y X" is added to the WHERE clause and +** analyzed separately. The original term is marked with TERM_COPIED +** and the new term is marked with TERM_DYNAMIC (because it's pExpr +** needs to be freed with the WhereClause) and TERM_VIRTUAL (because it +** is a commuted copy of a prior term.) The original term has nChild=1 +** and the copy has idxParent set to the index of the original term. +*/ + static void exprAnalyze( + SrcList pSrc, /* the FROM clause */ + WhereClause pWC, /* the WHERE clause */ + int idxTerm /* Index of the term to be analyzed */ + ) + { + WhereTerm pTerm; /* The term to be analyzed */ + WhereMaskSet pMaskSet; /* Set of table index masks */ + Expr pExpr; /* The expression to be analyzed */ + Bitmask prereqLeft; /* Prerequesites of the pExpr.pLeft */ + Bitmask prereqAll; /* Prerequesites of pExpr */ + Bitmask extraRight = 0; /* Extra dependencies on LEFT JOIN */ + Expr pStr1 = null; /* RHS of LIKE/GLOB operator */ + bool isComplete = false; /* RHS of LIKE/GLOB ends with wildcard */ + bool noCase = false; /* LIKE/GLOB distinguishes case */ + int op; /* Top-level operator. pExpr.op */ + Parse pParse = pWC.pParse; /* Parsing context */ + sqlite3 db = pParse.db; /* Data_base connection */ + + //if ( db.mallocFailed != 0 ) + //{ + // return; + //} + pTerm = pWC.a[idxTerm]; + pMaskSet = pWC.pMaskSet; + pExpr = pTerm.pExpr; + prereqLeft = exprTableUsage( pMaskSet, pExpr.pLeft ); + op = pExpr.op; + if ( op == TK_IN ) + { + Debug.Assert( pExpr.pRight == null ); + if ( ExprHasProperty( pExpr, EP_xIsSelect ) ) + { + pTerm.prereqRight = exprSelectTableUsage( pMaskSet, pExpr.x.pSelect ); + } + else + { + pTerm.prereqRight = exprListTableUsage( pMaskSet, pExpr.x.pList ); + } + } + else if ( op == TK_ISNULL ) + { + pTerm.prereqRight = 0; + } + else + { + pTerm.prereqRight = exprTableUsage( pMaskSet, pExpr.pRight ); + } + prereqAll = exprTableUsage( pMaskSet, pExpr ); + if ( ExprHasProperty( pExpr, EP_FromJoin ) ) + { + Bitmask x = getMask( pMaskSet, pExpr.iRightJoinTable ); + prereqAll |= x; + extraRight = x - 1; /* ON clause terms may not be used with an index +** on left table of a LEFT JOIN. Ticket #3015 */ + } + pTerm.prereqAll = prereqAll; + pTerm.leftCursor = -1; + pTerm.iParent = -1; + pTerm.eOperator = 0; + if ( allowedOp( op ) && ( pTerm.prereqRight & prereqLeft ) == 0 ) + { + Expr pLeft = pExpr.pLeft; + Expr pRight = pExpr.pRight; + if ( pLeft.op == TK_COLUMN ) + { + pTerm.leftCursor = pLeft.iTable; + pTerm.u.leftColumn = pLeft.iColumn; + pTerm.eOperator = operatorMask( op ); + } + if ( pRight != null && pRight.op == TK_COLUMN ) + { + WhereTerm pNew; + Expr pDup; + if ( pTerm.leftCursor >= 0 ) + { + int idxNew; + pDup = sqlite3ExprDup( db, pExpr, 0 ); //if ( db.mallocFailed != 0 ) //{ + // sqlite3ExprDelete( db, ref pDup ); // return; //} + idxNew = whereClauseInsert( pWC, pDup, TERM_VIRTUAL | TERM_DYNAMIC ); + if ( idxNew == 0 ) + return; + pNew = pWC.a[idxNew]; + pNew.iParent = idxTerm; pTerm = pWC.a[idxTerm]; - pMaskSet = pWC.pMaskSet; - pExpr = pTerm.pExpr; - prereqLeft = exprTableUsage(pMaskSet, pExpr.pLeft); - op = pExpr.op; - if (op == TK_IN) { - Debug.Assert(pExpr.pRight == null); - if (ExprHasProperty(pExpr, EP_xIsSelect)) { - pTerm.prereqRight = exprSelectTableUsage(pMaskSet, pExpr.x.pSelect); - } else { - pTerm.prereqRight = exprListTableUsage(pMaskSet, pExpr.x.pList); - } - } else if (op == TK_ISNULL) { - pTerm.prereqRight = 0; - } else { - pTerm.prereqRight = exprTableUsage(pMaskSet, pExpr.pRight); - } - prereqAll = exprTableUsage(pMaskSet, pExpr); - if (ExprHasProperty(pExpr, EP_FromJoin)) { - Bitmask x = getMask(pMaskSet, pExpr.iRightJoinTable); - prereqAll |= x; - extraRight = x - 1; /* ON clause terms may not be used with an index -** on left table of a LEFT JOIN. Ticket #3015 */ - } - pTerm.prereqAll = prereqAll; - pTerm.leftCursor = -1; - pTerm.iParent = -1; - pTerm.eOperator = 0; - if (allowedOp(op) && (pTerm.prereqRight & prereqLeft) == 0) { - Expr pLeft = pExpr.pLeft; - Expr pRight = pExpr.pRight; - if (pLeft.op == TK_COLUMN) { - pTerm.leftCursor = pLeft.iTable; - pTerm.u.leftColumn = pLeft.iColumn; - pTerm.eOperator = operatorMask(op); - } - if (pRight != null && pRight.op == TK_COLUMN) { - WhereTerm pNew; - Expr pDup; - if (pTerm.leftCursor >= 0) { - int idxNew; - pDup = sqlite3ExprDup(db, pExpr, 0); - //if ( db.mallocFailed != 0 ) - //{ - // sqlite3ExprDelete( db, ref pDup ); - // return; - //} - idxNew = whereClauseInsert(pWC, pDup, TERM_VIRTUAL | TERM_DYNAMIC); - if (idxNew == 0) - return; - pNew = pWC.a[idxNew]; - pNew.iParent = idxTerm; - pTerm = pWC.a[idxTerm]; - pTerm.nChild = 1; - pTerm.wtFlags |= TERM_COPIED; - } else { - pDup = pExpr; - pNew = pTerm; - } - exprCommute(pParse, pDup); - pLeft = pDup.pLeft; - pNew.leftCursor = pLeft.iTable; - pNew.u.leftColumn = pLeft.iColumn; - testcase((prereqLeft | extraRight) != prereqLeft); - pNew.prereqRight = prereqLeft | extraRight; - pNew.prereqAll = prereqAll; - pNew.eOperator = operatorMask(pDup.op); - } - } + pTerm.nChild = 1; + pTerm.wtFlags |= TERM_COPIED; + } + else + { + pDup = pExpr; + pNew = pTerm; + } + exprCommute( pParse, pDup ); + pLeft = pDup.pLeft; + pNew.leftCursor = pLeft.iTable; + pNew.u.leftColumn = pLeft.iColumn; + testcase( ( prereqLeft | extraRight ) != prereqLeft ); + pNew.prereqRight = prereqLeft | extraRight; + pNew.prereqAll = prereqAll; + pNew.eOperator = operatorMask( pDup.op ); + } + } -#if !SQLITE_OMIT_BETWEEN_OPTIMIZATION - /* If a term is the BETWEEN operator, create two new virtual terms - ** that define the range that the BETWEEN implements. For example: - ** - ** a BETWEEN b AND c - ** - ** is converted into: - ** - ** (a BETWEEN b AND c) AND (a>=b) AND (a<=c) - ** - ** The two new terms are added onto the end of the WhereClause object. - ** The new terms are "dynamic" and are children of the original BETWEEN - ** term. That means that if the BETWEEN term is coded, the children are - ** skipped. Or, if the children are satisfied by an index, the original - ** BETWEEN term is skipped. - */ - else if (pExpr.op == TK_BETWEEN && pWC.op == TK_AND) { - ExprList pList = pExpr.x.pList; - int i; - u8[] ops = new u8[] { TK_GE, TK_LE }; - Debug.Assert(pList != null); - Debug.Assert(pList.nExpr == 2); - for (i = 0; i < 2; i++) { - Expr pNewExpr; - int idxNew; - pNewExpr = sqlite3PExpr(pParse, ops[i], - sqlite3ExprDup(db, pExpr.pLeft, 0), - sqlite3ExprDup(db, pList.a[i].pExpr, 0), null); - idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL | TERM_DYNAMIC); - testcase(idxNew == 0); - exprAnalyze(pSrc, pWC, idxNew); - pTerm = pWC.a[idxTerm]; - pWC.a[idxNew].iParent = idxTerm; - } - pTerm.nChild = 2; - } +#if !SQLITE_OMIT_BETWEEN_OPTIMIZATION + /* If a term is the BETWEEN operator, create two new virtual terms +** that define the range that the BETWEEN implements. For example: +** +** a BETWEEN b AND c +** +** is converted into: +** +** (a BETWEEN b AND c) AND (a>=b) AND (a<=c) +** +** The two new terms are added onto the end of the WhereClause object. +** The new terms are "dynamic" and are children of the original BETWEEN +** term. That means that if the BETWEEN term is coded, the children are +** skipped. Or, if the children are satisfied by an index, the original +** BETWEEN term is skipped. +*/ + else if ( pExpr.op == TK_BETWEEN && pWC.op == TK_AND ) + { + ExprList pList = pExpr.x.pList; + int i; + u8[] ops = new u8[] { TK_GE, TK_LE }; + Debug.Assert( pList != null ); + Debug.Assert( pList.nExpr == 2 ); + for ( i = 0; i < 2; i++ ) + { + Expr pNewExpr; + int idxNew; + pNewExpr = sqlite3PExpr( pParse, ops[i], + sqlite3ExprDup( db, pExpr.pLeft, 0 ), + sqlite3ExprDup( db, pList.a[i].pExpr, 0 ), null ); + idxNew = whereClauseInsert( pWC, pNewExpr, TERM_VIRTUAL | TERM_DYNAMIC ); + testcase( idxNew == 0 ); + exprAnalyze( pSrc, pWC, idxNew ); + pTerm = pWC.a[idxTerm]; + pWC.a[idxNew].iParent = idxTerm; + } + pTerm.nChild = 2; + } #endif //* SQLITE_OMIT_BETWEEN_OPTIMIZATION */ -#if !(SQLITE_OMIT_OR_OPTIMIZATION) && !(SQLITE_OMIT_SUBQUERY) - /* Analyze a term that is composed of two or more subterms connected by - ** an OR operator. - */ - else if (pExpr.op == TK_OR) { - Debug.Assert(pWC.op == TK_AND); - exprAnalyzeOrTerm(pSrc, pWC, idxTerm); - pTerm = pWC.a[idxTerm]; - } +#if !(SQLITE_OMIT_OR_OPTIMIZATION) && !(SQLITE_OMIT_SUBQUERY) + /* Analyze a term that is composed of two or more subterms connected by +** an OR operator. +*/ + else if ( pExpr.op == TK_OR ) + { + Debug.Assert( pWC.op == TK_AND ); + exprAnalyzeOrTerm( pSrc, pWC, idxTerm ); + pTerm = pWC.a[idxTerm]; + } #endif //* SQLITE_OMIT_OR_OPTIMIZATION */ -#if !SQLITE_OMIT_LIKE_OPTIMIZATION - /* Add constraints to reduce the search space on a LIKE or GLOB - ** operator. - ** - ** A like pattern of the form "x LIKE 'abc%'" is changed into constraints - ** - ** x>='abc' AND x<'abd' AND x LIKE 'abc%' - ** - ** The last character of the prefix "abc" is incremented to form the - ** termination condition "abd". - */ - if (pWC.op == TK_AND - && isLikeOrGlob(pParse, pExpr, ref pStr1, ref isComplete, ref noCase) != 0 - ) { - Expr pLeft; /* LHS of LIKE/GLOB operator */ - Expr pStr2; /* Copy of pStr1 - RHS of LIKE/GLOB operator */ - Expr pNewExpr1; - Expr pNewExpr2; - int idxNew1; - int idxNew2; - CollSeq pColl; /* Collating sequence to use */ - - pLeft = pExpr.x.pList.a[1].pExpr; - pStr2 = sqlite3ExprDup(db, pStr1, 0); - ////if ( 0 == db.mallocFailed ) - { - int c, pC; /* Last character before the first wildcard */ - pC = pStr2.u.zToken[sqlite3Strlen30(pStr2.u.zToken) - 1]; - c = pC; - if (noCase) { - /* The point is to increment the last character before the first - ** wildcard. But if we increment '@', that will push it into the - ** alphabetic range where case conversions will mess up the - ** inequality. To avoid this, make sure to also run the full - ** LIKE on all candidate expressions by clearing the isComplete flag - */ - if (c == 'A' - 1) - isComplete = false; /* EV: R-64339-08207 */ - c = sqlite3UpperToLower[c]; - } - pStr2.u.zToken = pStr2.u.zToken.Substring(0, sqlite3Strlen30(pStr2.u.zToken) - 1) + (char)(c + 1);// pC = c + 1; - } - pColl = sqlite3FindCollSeq(db, SQLITE_UTF8, noCase ? "NOCASE" : "BINARY", 0); - pNewExpr1 = sqlite3PExpr(pParse, TK_GE, - sqlite3ExprSetColl(sqlite3ExprDup(db, pLeft, 0), pColl), - pStr1, 0); - idxNew1 = whereClauseInsert(pWC, pNewExpr1, TERM_VIRTUAL | TERM_DYNAMIC); - testcase(idxNew1 == 0); - exprAnalyze(pSrc, pWC, idxNew1); - pNewExpr2 = sqlite3PExpr(pParse, TK_LT, - sqlite3ExprSetColl(sqlite3ExprDup(db, pLeft, 0), pColl), - pStr2, null); - idxNew2 = whereClauseInsert(pWC, pNewExpr2, TERM_VIRTUAL | TERM_DYNAMIC); - testcase(idxNew2 == 0); - exprAnalyze(pSrc, pWC, idxNew2); - pTerm = pWC.a[idxTerm]; - if (isComplete) { - pWC.a[idxNew1].iParent = idxTerm; - pWC.a[idxNew2].iParent = idxTerm; - pTerm.nChild = 2; - } - } +#if !SQLITE_OMIT_LIKE_OPTIMIZATION + /* Add constraints to reduce the search space on a LIKE or GLOB +** operator. +** +** A like pattern of the form "x LIKE 'abc%'" is changed into constraints +** +** x>='abc' AND x<'abd' AND x LIKE 'abc%' +** +** The last character of the prefix "abc" is incremented to form the +** termination condition "abd". +*/ + if ( pWC.op == TK_AND + && isLikeOrGlob( pParse, pExpr, ref pStr1, ref isComplete, ref noCase ) != 0 + ) + { + Expr pLeft; /* LHS of LIKE/GLOB operator */ + Expr pStr2; /* Copy of pStr1 - RHS of LIKE/GLOB operator */ + Expr pNewExpr1; + Expr pNewExpr2; + int idxNew1; + int idxNew2; + CollSeq pColl; /* Collating sequence to use */ + + pLeft = pExpr.x.pList.a[1].pExpr; + pStr2 = sqlite3ExprDup( db, pStr1, 0 ); + ////if ( 0 == db.mallocFailed ) + { + int c, pC; /* Last character before the first wildcard */ + pC = pStr2.u.zToken[sqlite3Strlen30( pStr2.u.zToken ) - 1]; + c = pC; + if ( noCase ) + { + /* The point is to increment the last character before the first + ** wildcard. But if we increment '@', that will push it into the + ** alphabetic range where case conversions will mess up the + ** inequality. To avoid this, make sure to also run the full + ** LIKE on all candidate expressions by clearing the isComplete flag + */ + if ( c == 'A' - 1 ) + isComplete = false; /* EV: R-64339-08207 */ + c = sqlite3UpperToLower[c]; + } + pStr2.u.zToken = pStr2.u.zToken.Substring( 0, sqlite3Strlen30( pStr2.u.zToken ) - 1 ) + (char)( c + 1 );// pC = c + 1; + } + pColl = sqlite3FindCollSeq( db, SQLITE_UTF8, noCase ? "NOCASE" : "BINARY", 0 ); + pNewExpr1 = sqlite3PExpr( pParse, TK_GE, + sqlite3ExprSetColl( sqlite3ExprDup( db, pLeft, 0 ), pColl ), + pStr1, 0 ); + idxNew1 = whereClauseInsert( pWC, pNewExpr1, TERM_VIRTUAL | TERM_DYNAMIC ); + testcase( idxNew1 == 0 ); + exprAnalyze( pSrc, pWC, idxNew1 ); + pNewExpr2 = sqlite3PExpr( pParse, TK_LT, + sqlite3ExprSetColl( sqlite3ExprDup( db, pLeft, 0 ), pColl ), + pStr2, null ); + idxNew2 = whereClauseInsert( pWC, pNewExpr2, TERM_VIRTUAL | TERM_DYNAMIC ); + testcase( idxNew2 == 0 ); + exprAnalyze( pSrc, pWC, idxNew2 ); + pTerm = pWC.a[idxTerm]; + if ( isComplete ) + { + pWC.a[idxNew1].iParent = idxTerm; + pWC.a[idxNew2].iParent = idxTerm; + pTerm.nChild = 2; + } + } #endif //* SQLITE_OMIT_LIKE_OPTIMIZATION */ -#if !SQLITE_OMIT_VIRTUALTABLE - /* Add a WO_MATCH auxiliary term to the constraint set if the - ** current expression is of the form: column MATCH expr. - ** This information is used by the xBestIndex methods of - ** virtual tables. The native query optimizer does not attempt - ** to do anything with MATCH functions. - */ - if (isMatchOfColumn(pExpr) != 0) { - int idxNew; - Expr pRight, pLeft; - WhereTerm pNewTerm; - Bitmask prereqColumn, prereqExpr; - - pRight = pExpr.x.pList.a[0].pExpr; - pLeft = pExpr.x.pList.a[1].pExpr; - prereqExpr = exprTableUsage(pMaskSet, pRight); - prereqColumn = exprTableUsage(pMaskSet, pLeft); - if ((prereqExpr & prereqColumn) == 0) { - Expr pNewExpr; - pNewExpr = sqlite3PExpr(pParse, TK_MATCH, - null, sqlite3ExprDup(db, pRight, 0), null); - idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL | TERM_DYNAMIC); - testcase(idxNew == 0); - pNewTerm = pWC.a[idxNew]; - pNewTerm.prereqRight = prereqExpr; - pNewTerm.leftCursor = pLeft.iTable; - pNewTerm.u.leftColumn = pLeft.iColumn; - pNewTerm.eOperator = WO_MATCH; - pNewTerm.iParent = idxTerm; - pTerm = pWC.a[idxTerm]; - pTerm.nChild = 1; - pTerm.wtFlags |= TERM_COPIED; - pNewTerm.prereqAll = pTerm.prereqAll; - } - } +#if !SQLITE_OMIT_VIRTUALTABLE +/* Add a WO_MATCH auxiliary term to the constraint set if the +** current expression is of the form: column MATCH expr. +** This information is used by the xBestIndex methods of +** virtual tables. The native query optimizer does not attempt +** to do anything with MATCH functions. +*/ + if ( isMatchOfColumn( pExpr ) != 0 ) + { + int idxNew; + Expr pRight, pLeft; + WhereTerm pNewTerm; + Bitmask prereqColumn, prereqExpr; + + pRight = pExpr.x.pList.a[0].pExpr; + pLeft = pExpr.x.pList.a[1].pExpr; + prereqExpr = exprTableUsage( pMaskSet, pRight ); + prereqColumn = exprTableUsage( pMaskSet, pLeft ); + if ( ( prereqExpr & prereqColumn ) == 0 ) + { + Expr pNewExpr; + pNewExpr = sqlite3PExpr( pParse, TK_MATCH, + null, sqlite3ExprDup( db, pRight, 0 ), null ); + idxNew = whereClauseInsert( pWC, pNewExpr, TERM_VIRTUAL | TERM_DYNAMIC ); + testcase( idxNew == 0 ); + pNewTerm = pWC.a[idxNew]; + pNewTerm.prereqRight = prereqExpr; + pNewTerm.leftCursor = pLeft.iTable; + pNewTerm.u.leftColumn = pLeft.iColumn; + pNewTerm.eOperator = WO_MATCH; + pNewTerm.iParent = idxTerm; + pTerm = pWC.a[idxTerm]; + pTerm.nChild = 1; + pTerm.wtFlags |= TERM_COPIED; + pNewTerm.prereqAll = pTerm.prereqAll; + } +} #endif //* SQLITE_OMIT_VIRTUALTABLE */ #if SQLITE_ENABLE_STAT2 @@ -1492,236 +1620,267 @@ int idxTerm /* Index of the term to be analyzed */ pNewTerm.prereqAll = pTerm.prereqAll; } } -#endif //* SQLITE_ENABLE_STAT2 */ +#endif //* SQLITE_ENABLE_STAT2 */ + + /* Prevent ON clause terms of a LEFT JOIN from being used to drive +** an index for tables to the left of the join. +*/ + pTerm.prereqRight |= extraRight; + } + + /* + ** Return TRUE if any of the expressions in pList.a[iFirst...] contain + ** a reference to any table other than the iBase table. + */ + static bool referencesOtherTables( + ExprList pList, /* Search expressions in ths list */ + WhereMaskSet pMaskSet, /* Mapping from tables to bitmaps */ + int iFirst, /* Be searching with the iFirst-th expression */ + int iBase /* Ignore references to this table */ + ) + { + Bitmask allowed = ~getMask( pMaskSet, iBase ); + while ( iFirst < pList.nExpr ) + { + if ( ( exprTableUsage( pMaskSet, pList.a[iFirst++].pExpr ) & allowed ) != 0 ) + { + return true; + } + } + return false; + } + - /* Prevent ON clause terms of a LEFT JOIN from being used to drive - ** an index for tables to the left of the join. + /* + ** This routine decides if pIdx can be used to satisfy the ORDER BY + ** clause. If it can, it returns 1. If pIdx cannot satisfy the + ** ORDER BY clause, this routine returns 0. + ** + ** pOrderBy is an ORDER BY clause from a SELECT statement. pTab is the + ** left-most table in the FROM clause of that same SELECT statement and + ** the table has a cursor number of "_base". pIdx is an index on pTab. + ** + ** nEqCol is the number of columns of pIdx that are used as equality + ** constraints. Any of these columns may be missing from the ORDER BY + ** clause and the match can still be a success. + ** + ** All terms of the ORDER BY that match against the index must be either + ** ASC or DESC. (Terms of the ORDER BY clause past the end of a UNIQUE + ** index do not need to satisfy this constraint.) The pbRev value is + ** set to 1 if the ORDER BY clause is all DESC and it is set to 0 if + ** the ORDER BY clause is all ASC. + */ + static bool isSortingIndex( + Parse pParse, /* Parsing context */ + WhereMaskSet pMaskSet, /* Mapping from table cursor numbers to bitmaps */ + Index pIdx, /* The index we are testing */ + int _base, /* Cursor number for the table to be sorted */ + ExprList pOrderBy, /* The ORDER BY clause */ + int nEqCol, /* Number of index columns with == constraints */ + int wsFlags, /* Index usages flags */ + ref int pbRev /* Set to 1 if ORDER BY is DESC */ + ) + { + int i, j; /* Loop counters */ + int sortOrder = 0; /* XOR of index and ORDER BY sort direction */ + int nTerm; /* Number of ORDER BY terms */ + ExprList_item pTerm; /* A term of the ORDER BY clause */ + sqlite3 db = pParse.db; + + Debug.Assert( pOrderBy != null ); + nTerm = pOrderBy.nExpr; + Debug.Assert( nTerm > 0 ); + + /* Argument pIdx must either point to a 'real' named index structure, + ** or an index structure allocated on the stack by bestBtreeIndex() to + ** represent the rowid index that is part of every table. */ + Debug.Assert( !String.IsNullOrEmpty( pIdx.zName ) || ( pIdx.nColumn == 1 && pIdx.aiColumn[0] == -1 ) ); + + /* Match terms of the ORDER BY clause against columns of + ** the index. + ** + ** Note that indices have pIdx.nColumn regular columns plus + ** one additional column containing the rowid. The rowid column + ** of the index is also allowed to match against the ORDER BY + ** clause. */ - pTerm.prereqRight |= extraRight; + for ( i = j = 0; j < nTerm && i <= pIdx.nColumn; i++ ) + { + pTerm = pOrderBy.a[j]; + Expr pExpr; /* The expression of the ORDER BY pTerm */ + CollSeq pColl; /* The collating sequence of pExpr */ + int termSortOrder; /* Sort order for this term */ + int iColumn; /* The i-th column of the index. -1 for rowid */ + int iSortOrder; /* 1 for DESC, 0 for ASC on the i-th index term */ + string zColl; /* Name of the collating sequence for i-th index term */ + + pExpr = pTerm.pExpr; + if ( pExpr.op != TK_COLUMN || pExpr.iTable != _base ) + { + /* Can not use an index sort on anything that is not a column in the + ** left-most table of the FROM clause */ + break; } - - /* - ** Return TRUE if any of the expressions in pList.a[iFirst...] contain - ** a reference to any table other than the iBase table. - */ - static bool referencesOtherTables( - ExprList pList, /* Search expressions in ths list */ - WhereMaskSet pMaskSet, /* Mapping from tables to bitmaps */ - int iFirst, /* Be searching with the iFirst-th expression */ - int iBase /* Ignore references to this table */ - ) { - Bitmask allowed = ~getMask(pMaskSet, iBase); - while (iFirst < pList.nExpr) { - if ((exprTableUsage(pMaskSet, pList.a[iFirst++].pExpr) & allowed) != 0) { - return true; - } - } - return false; + pColl = sqlite3ExprCollSeq( pParse, pExpr ); + if ( null == pColl ) + { + pColl = db.pDfltColl; } - - - /* - ** This routine decides if pIdx can be used to satisfy the ORDER BY - ** clause. If it can, it returns 1. If pIdx cannot satisfy the - ** ORDER BY clause, this routine returns 0. - ** - ** pOrderBy is an ORDER BY clause from a SELECT statement. pTab is the - ** left-most table in the FROM clause of that same SELECT statement and - ** the table has a cursor number of "_base". pIdx is an index on pTab. - ** - ** nEqCol is the number of columns of pIdx that are used as equality - ** constraints. Any of these columns may be missing from the ORDER BY - ** clause and the match can still be a success. - ** - ** All terms of the ORDER BY that match against the index must be either - ** ASC or DESC. (Terms of the ORDER BY clause past the end of a UNIQUE - ** index do not need to satisfy this constraint.) The pbRev value is - ** set to 1 if the ORDER BY clause is all DESC and it is set to 0 if - ** the ORDER BY clause is all ASC. - */ - static bool isSortingIndex( - Parse pParse, /* Parsing context */ - WhereMaskSet pMaskSet, /* Mapping from table cursor numbers to bitmaps */ - Index pIdx, /* The index we are testing */ - int _base, /* Cursor number for the table to be sorted */ - ExprList pOrderBy, /* The ORDER BY clause */ - int nEqCol, /* Number of index columns with == constraints */ - int wsFlags, /* Index usages flags */ - ref int pbRev /* Set to 1 if ORDER BY is DESC */ - ) { - int i, j; /* Loop counters */ - int sortOrder = 0; /* XOR of index and ORDER BY sort direction */ - int nTerm; /* Number of ORDER BY terms */ - ExprList_item pTerm; /* A term of the ORDER BY clause */ - sqlite3 db = pParse.db; - - Debug.Assert(pOrderBy != null); - nTerm = pOrderBy.nExpr; - Debug.Assert(nTerm > 0); - - /* Argument pIdx must either point to a 'real' named index structure, - ** or an index structure allocated on the stack by bestBtreeIndex() to - ** represent the rowid index that is part of every table. */ - Debug.Assert(!String.IsNullOrEmpty(pIdx.zName) || (pIdx.nColumn == 1 && pIdx.aiColumn[0] == -1)); - - /* Match terms of the ORDER BY clause against columns of - ** the index. - ** - ** Note that indices have pIdx.nColumn regular columns plus - ** one additional column containing the rowid. The rowid column - ** of the index is also allowed to match against the ORDER BY - ** clause. + if ( !String.IsNullOrEmpty( pIdx.zName ) && i < pIdx.nColumn ) + { + iColumn = pIdx.aiColumn[i]; + if ( iColumn == pIdx.pTable.iPKey ) + { + iColumn = -1; + } + iSortOrder = pIdx.aSortOrder[i]; + zColl = pIdx.azColl[i]; + } + else + { + iColumn = -1; + iSortOrder = 0; + zColl = pColl.zName; + } + if ( pExpr.iColumn != iColumn || !pColl.zName.Equals( zColl, StringComparison.OrdinalIgnoreCase ) ) + { + /* Term j of the ORDER BY clause does not match column i of the index */ + if ( i < nEqCol ) + { + /* If an index column that is constrained by == fails to match an + ** ORDER BY term, that is OK. Just ignore that column of the index + */ + continue; + } + else if ( i == pIdx.nColumn ) + { + /* Index column i is the rowid. All other terms match. */ + break; + } + else + { + /* If an index column fails to match and is not constrained by == + ** then the index cannot satisfy the ORDER BY constraint. */ - for (i = j = 0; j < nTerm && i <= pIdx.nColumn; i++) { - pTerm = pOrderBy.a[j]; - Expr pExpr; /* The expression of the ORDER BY pTerm */ - CollSeq pColl; /* The collating sequence of pExpr */ - int termSortOrder; /* Sort order for this term */ - int iColumn; /* The i-th column of the index. -1 for rowid */ - int iSortOrder; /* 1 for DESC, 0 for ASC on the i-th index term */ - string zColl; /* Name of the collating sequence for i-th index term */ - - pExpr = pTerm.pExpr; - if (pExpr.op != TK_COLUMN || pExpr.iTable != _base) { - /* Can not use an index sort on anything that is not a column in the - ** left-most table of the FROM clause */ - break; - } - pColl = sqlite3ExprCollSeq(pParse, pExpr); - if (null == pColl) { - pColl = db.pDfltColl; - } - if (!String.IsNullOrEmpty(pIdx.zName) && i < pIdx.nColumn) { - iColumn = pIdx.aiColumn[i]; - if (iColumn == pIdx.pTable.iPKey) { - iColumn = -1; - } - iSortOrder = pIdx.aSortOrder[i]; - zColl = pIdx.azColl[i]; - } else { - iColumn = -1; - iSortOrder = 0; - zColl = pColl.zName; - } - if (pExpr.iColumn != iColumn || !pColl.zName.Equals(zColl, StringComparison.OrdinalIgnoreCase)) { - /* Term j of the ORDER BY clause does not match column i of the index */ - if (i < nEqCol) { - /* If an index column that is constrained by == fails to match an - ** ORDER BY term, that is OK. Just ignore that column of the index - */ - continue; - } else if (i == pIdx.nColumn) { - /* Index column i is the rowid. All other terms match. */ - break; - } else { - /* If an index column fails to match and is not constrained by == - ** then the index cannot satisfy the ORDER BY constraint. - */ - return false; - } - } - Debug.Assert(pIdx.aSortOrder != null || iColumn == -1); - Debug.Assert(pTerm.sortOrder == 0 || pTerm.sortOrder == 1); - Debug.Assert(iSortOrder == 0 || iSortOrder == 1); - termSortOrder = iSortOrder ^ pTerm.sortOrder; - if (i > nEqCol) { - if (termSortOrder != sortOrder) { - /* Indices can only be used if all ORDER BY terms past the - ** equality constraints are all either DESC or ASC. */ - return false; - } - } else { - sortOrder = termSortOrder; - } - j++; - //pTerm++; - if (iColumn < 0 && !referencesOtherTables(pOrderBy, pMaskSet, j, _base)) { - /* If the indexed column is the primary key and everything matches - ** so far and none of the ORDER BY terms to the right reference other - ** tables in the join, then we are Debug.Assured that the index can be used - ** to sort because the primary key is unique and so none of the other - ** columns will make any difference - */ - j = nTerm; - } - } - - pbRev = sortOrder != 0 ? 1 : 0; - if (j >= nTerm) { - /* All terms of the ORDER BY clause are covered by this index so - ** this index can be used for sorting. */ - return true; - } - if (pIdx.onError != OE_None && i == pIdx.nColumn - && (wsFlags & WHERE_COLUMN_NULL) == 0 - && !referencesOtherTables(pOrderBy, pMaskSet, j, _base)) { - /* All terms of this index match some prefix of the ORDER BY clause - ** and the index is UNIQUE and no terms on the tail of the ORDER BY - ** clause reference other tables in a join. If this is all true then - ** the order by clause is superfluous. Not that if the matching - ** condition is IS NULL then the result is not necessarily unique - ** even on a UNIQUE index, so disallow those cases. */ - return true; - } return false; + } } - - /* - ** Prepare a crude estimate of the logarithm of the input value. - ** The results need not be exact. This is only used for estimating - ** the total cost of performing operations with O(logN) or O(NlogN) - ** complexity. Because N is just a guess, it is no great tragedy if - ** logN is a little off. - */ - static double estLog(double N) { - double logN = 1; - double x = 10; - while (N > x) { - logN += 1; - x *= 10; - } - return logN; + Debug.Assert( pIdx.aSortOrder != null || iColumn == -1 ); + Debug.Assert( pTerm.sortOrder == 0 || pTerm.sortOrder == 1 ); + Debug.Assert( iSortOrder == 0 || iSortOrder == 1 ); + termSortOrder = iSortOrder ^ pTerm.sortOrder; + if ( i > nEqCol ) + { + if ( termSortOrder != sortOrder ) + { + /* Indices can only be used if all ORDER BY terms past the + ** equality constraints are all either DESC or ASC. */ + return false; + } } - - /* - ** Two routines for printing the content of an sqlite3_index_info - ** structure. Used for testing and debugging only. If neither - ** SQLITE_TEST or SQLITE_DEBUG are defined, then these routines - ** are no-ops. - */ -#if !(SQLITE_OMIT_VIRTUALTABLE) && (SQLITE_DEBUG) - static void TRACE_IDX_INPUTS(sqlite3_index_info p) { - int i; - if (!sqlite3WhereTrace) return; - for (i = 0; i < p.nConstraint; i++) { - sqlite3DebugPrintf(" constraint[%d]: col=%d termid=%d op=%d usabled=%d\n", - i, - p.aConstraint[i].iColumn, - p.aConstraint[i].iTermOffset, - p.aConstraint[i].op, - p.aConstraint[i].usable); - } - for (i = 0; i < p.nOrderBy; i++) { - sqlite3DebugPrintf(" orderby[%d]: col=%d desc=%d\n", - i, - p.aOrderBy[i].iColumn, - p.aOrderBy[i].desc); - } + else + { + sortOrder = termSortOrder; } - static void TRACE_IDX_OUTPUTS(sqlite3_index_info p) { - int i; - if (!sqlite3WhereTrace) return; - for (i = 0; i < p.nConstraint; i++) { - sqlite3DebugPrintf(" usage[%d]: argvIdx=%d omit=%d\n", - i, - p.aConstraintUsage[i].argvIndex, - p.aConstraintUsage[i].omit); - } - sqlite3DebugPrintf(" idxNum=%d\n", p.idxNum); - sqlite3DebugPrintf(" idxStr=%s\n", p.idxStr); - sqlite3DebugPrintf(" orderByConsumed=%d\n", p.orderByConsumed); - sqlite3DebugPrintf(" estimatedCost=%g\n", p.estimatedCost); + j++; + //pTerm++; + if ( iColumn < 0 && !referencesOtherTables( pOrderBy, pMaskSet, j, _base ) ) + { + /* If the indexed column is the primary key and everything matches + ** so far and none of the ORDER BY terms to the right reference other + ** tables in the join, then we are Debug.Assured that the index can be used + ** to sort because the primary key is unique and so none of the other + ** columns will make any difference + */ + j = nTerm; } + } + + pbRev = sortOrder != 0 ? 1 : 0; + if ( j >= nTerm ) + { + /* All terms of the ORDER BY clause are covered by this index so + ** this index can be used for sorting. */ + return true; + } + if ( pIdx.onError != OE_None && i == pIdx.nColumn + && ( wsFlags & WHERE_COLUMN_NULL ) == 0 + && !referencesOtherTables( pOrderBy, pMaskSet, j, _base ) ) + { + /* All terms of this index match some prefix of the ORDER BY clause + ** and the index is UNIQUE and no terms on the tail of the ORDER BY + ** clause reference other tables in a join. If this is all true then + ** the order by clause is superfluous. Not that if the matching + ** condition is IS NULL then the result is not necessarily unique + ** even on a UNIQUE index, so disallow those cases. */ + return true; + } + return false; + } + + /* + ** Prepare a crude estimate of the logarithm of the input value. + ** The results need not be exact. This is only used for estimating + ** the total cost of performing operations with O(logN) or O(NlogN) + ** complexity. Because N is just a guess, it is no great tragedy if + ** logN is a little off. + */ + static double estLog( double N ) + { + double logN = 1; + double x = 10; + while ( N > x ) + { + logN += 1; + x *= 10; + } + return logN; + } + + /* + ** Two routines for printing the content of an sqlite3_index_info + ** structure. Used for testing and debugging only. If neither + ** SQLITE_TEST or SQLITE_DEBUG are defined, then these routines + ** are no-ops. + */ +#if !(SQLITE_OMIT_VIRTUALTABLE) && (SQLITE_DEBUG) +static void TRACE_IDX_INPUTS( sqlite3_index_info p ) +{ +int i; +if ( !sqlite3WhereTrace ) return; +for ( i = 0 ; i < p.nConstraint ; i++ ) +{ +sqlite3DebugPrintf( " constraint[%d]: col=%d termid=%d op=%d usabled=%d\n", +i, +p.aConstraint[i].iColumn, +p.aConstraint[i].iTermOffset, +p.aConstraint[i].op, +p.aConstraint[i].usable ); +} +for ( i = 0 ; i < p.nOrderBy ; i++ ) +{ +sqlite3DebugPrintf( " orderby[%d]: col=%d desc=%d\n", +i, +p.aOrderBy[i].iColumn, +p.aOrderBy[i].desc ); +} +} +static void TRACE_IDX_OUTPUTS( sqlite3_index_info p ) +{ +int i; +if ( !sqlite3WhereTrace ) return; +for ( i = 0 ; i < p.nConstraint ; i++ ) +{ +sqlite3DebugPrintf( " usage[%d]: argvIdx=%d omit=%d\n", +i, +p.aConstraintUsage[i].argvIndex, +p.aConstraintUsage[i].omit ); +} +sqlite3DebugPrintf( " idxNum=%d\n", p.idxNum ); +sqlite3DebugPrintf( " idxStr=%s\n", p.idxStr ); +sqlite3DebugPrintf( " orderByConsumed=%d\n", p.orderByConsumed ); +sqlite3DebugPrintf( " estimatedCost=%g\n", p.estimatedCost ); +} #else //#define TRACE_IDX_INPUTS(A) static void TRACE_IDX_INPUTS( sqlite3_index_info p ) { } @@ -1729,210 +1888,228 @@ static void TRACE_IDX_INPUTS( sqlite3_index_info p ) { } static void TRACE_IDX_OUTPUTS( sqlite3_index_info p ) { } #endif - /* - ** Required because bestIndex() is called by bestOrClauseIndex() - */ - //static void bestIndex( - //Parse*, WhereClause*, struct SrcList_item*, - //Bitmask, ExprList*, WhereCost); + /* +** Required because bestIndex() is called by bestOrClauseIndex() +*/ + //static void bestIndex( + //Parse*, WhereClause*, struct SrcList_item*, + //Bitmask, ExprList*, WhereCost); - /* - ** This routine attempts to find an scanning strategy that can be used - ** to optimize an 'OR' expression that is part of a WHERE clause. - ** - ** The table associated with FROM clause term pSrc may be either a - ** regular B-Tree table or a virtual table. - */ - static void bestOrClauseIndex( - Parse pParse, /* The parsing context */ - WhereClause pWC, /* The WHERE clause */ - SrcList_item pSrc, /* The FROM clause term to search */ - Bitmask notReady, /* Mask of cursors not available for indexing */ - Bitmask notValid, /* Cursors not available for any purpose */ - ExprList pOrderBy, /* The ORDER BY clause */ - WhereCost pCost /* Lowest cost query plan */ - ) { + /* + ** This routine attempts to find an scanning strategy that can be used + ** to optimize an 'OR' expression that is part of a WHERE clause. + ** + ** The table associated with FROM clause term pSrc may be either a + ** regular B-Tree table or a virtual table. + */ + static void bestOrClauseIndex( + Parse pParse, /* The parsing context */ + WhereClause pWC, /* The WHERE clause */ + SrcList_item pSrc, /* The FROM clause term to search */ + Bitmask notReady, /* Mask of cursors not available for indexing */ + Bitmask notValid, /* Cursors not available for any purpose */ + ExprList pOrderBy, /* The ORDER BY clause */ + WhereCost pCost /* Lowest cost query plan */ + ) + { #if !SQLITE_OMIT_OR_OPTIMIZATION - int iCur = pSrc.iCursor; /* The cursor of the table to be accessed */ - Bitmask maskSrc = getMask(pWC.pMaskSet, iCur); /* Bitmask for pSrc */ - WhereTerm pWCEnd = pWC.a[pWC.nTerm]; /* End of pWC.a[] */ - WhereTerm pTerm; /* A single term of the WHERE clause */ - - /* No OR-clause optimization allowed if the INDEXED BY or NOT INDEXED clauses - ** are used */ - if (pSrc.notIndexed != 0 || pSrc.pIndex != null) { - return; - } + int iCur = pSrc.iCursor; /* The cursor of the table to be accessed */ + Bitmask maskSrc = getMask( pWC.pMaskSet, iCur ); /* Bitmask for pSrc */ + WhereTerm pWCEnd = pWC.a[pWC.nTerm]; /* End of pWC.a[] */ + WhereTerm pTerm; /* A single term of the WHERE clause */ + + /* No OR-clause optimization allowed if the INDEXED BY or NOT INDEXED clauses + ** are used */ + if ( pSrc.notIndexed != 0 || pSrc.pIndex != null ) + { + return; + } - /* Search the WHERE clause terms for a usable WO_OR term. */ - for (int _pt = 0; _pt < pWC.nTerm; _pt++)//= pCost.rCost) - break; - } - - /* If there is an ORDER BY clause, increase the scan cost to account - ** for the cost of the sort. */ - if (pOrderBy != null) { -#if (SQLITE_TEST) && (SQLITE_DEBUG) + if ( pOrTerm.eOperator == WO_AND ) + { + WhereClause pAndWC = pOrTerm.u.pAndInfo.wc; + bestIndex( pParse, pAndWC, pSrc, notReady, notValid, null, ref sTermCost ); + } + else if ( pOrTerm.leftCursor == iCur ) + { + WhereClause tempWC = new WhereClause(); + tempWC.pParse = pWC.pParse; + tempWC.pMaskSet = pWC.pMaskSet; + tempWC.op = TK_AND; + tempWC.a = new WhereTerm[2]; + tempWC.a[0] = pOrTerm; + tempWC.nTerm = 1; + bestIndex( pParse, tempWC, pSrc, notReady, notValid, null, ref sTermCost ); + } + else + { + continue; + } + rTotal += sTermCost.rCost; + nRow += sTermCost.plan.nRow; + used |= sTermCost.used; + if ( rTotal >= pCost.rCost ) + break; + } + + /* If there is an ORDER BY clause, increase the scan cost to account + ** for the cost of the sort. */ + if ( pOrderBy != null ) + { +#if (SQLITE_TEST) && (SQLITE_DEBUG) WHERETRACE( "... sorting increases OR cost %.9g to %.9g\n", rTotal, rTotal + nRow * estLog( nRow ) ); #endif - rTotal += nRow * estLog(nRow); - } + rTotal += nRow * estLog( nRow ); + } - /* If the cost of scanning using this OR term for optimization is - ** less than the current cost stored in pCost, replace the contents - ** of pCost. */ -#if (SQLITE_TEST) && (SQLITE_DEBUG) + /* If the cost of scanning using this OR term for optimization is + ** less than the current cost stored in pCost, replace the contents + ** of pCost. */ +#if (SQLITE_TEST) && (SQLITE_DEBUG) WHERETRACE( "... multi-index OR cost=%.9g nrow=%.9g\n", rTotal, nRow ); #endif - if (rTotal < pCost.rCost) { - pCost.rCost = rTotal; - pCost.used = used; - pCost.plan.nRow = nRow; - pCost.plan.wsFlags = (uint)flags; - pCost.plan.u.pTerm = pTerm; - } - } - } -#endif //* SQLITE_OMIT_OR_OPTIMIZATION */ + if ( rTotal < pCost.rCost ) + { + pCost.rCost = rTotal; + pCost.used = used; + pCost.plan.nRow = nRow; + pCost.plan.wsFlags = (uint)flags; + pCost.plan.u.pTerm = pTerm; + } } + } +#endif //* SQLITE_OMIT_OR_OPTIMIZATION */ + } #if !SQLITE_OMIT_AUTOMATIC_INDEX - /* - ** Return TRUE if the WHERE clause term pTerm is of a form where it - ** could be used with an index to access pSrc, assuming an appropriate - ** index existed. - */ - static int termCanDriveIndex( - WhereTerm pTerm, /* WHERE clause term to check */ - SrcList_item pSrc, /* Table we are trying to access */ - Bitmask notReady /* Tables in outer loops of the join */ - ) { - char aff; - if (pTerm.leftCursor != pSrc.iCursor) - return 0; - if (pTerm.eOperator != WO_EQ) - return 0; - if ((pTerm.prereqRight & notReady) != 0) - return 0; - aff = pSrc.pTab.aCol[pTerm.u.leftColumn].affinity; - if (!sqlite3IndexAffinityOk(pTerm.pExpr, aff)) - return 0; - return 1; - } + /* +** Return TRUE if the WHERE clause term pTerm is of a form where it +** could be used with an index to access pSrc, assuming an appropriate +** index existed. +*/ + static int termCanDriveIndex( + WhereTerm pTerm, /* WHERE clause term to check */ + SrcList_item pSrc, /* Table we are trying to access */ + Bitmask notReady /* Tables in outer loops of the join */ + ) + { + char aff; + if ( pTerm.leftCursor != pSrc.iCursor ) + return 0; + if ( pTerm.eOperator != WO_EQ ) + return 0; + if ( ( pTerm.prereqRight & notReady ) != 0 ) + return 0; + aff = pSrc.pTab.aCol[pTerm.u.leftColumn].affinity; + if ( !sqlite3IndexAffinityOk( pTerm.pExpr, aff ) ) + return 0; + return 1; + } #endif #if !SQLITE_OMIT_AUTOMATIC_INDEX - /* - ** If the query plan for pSrc specified in pCost is a full table scan - ** and indexing is allows (if there is no NOT INDEXED clause) and it - ** possible to construct a transient index that would perform better - ** than a full table scan even when the cost of constructing the index - ** is taken into account, then alter the query plan to use the - ** transient index. - */ - static void bestAutomaticIndex( - Parse pParse, /* The parsing context */ - WhereClause pWC, /* The WHERE clause */ - SrcList_item pSrc, /* The FROM clause term to search */ - Bitmask notReady, /* Mask of cursors that are not available */ - WhereCost pCost /* Lowest cost query plan */ - ) { - double nTableRow; /* Rows in the input table */ - double logN; /* log(nTableRow) */ - double costTempIdx; /* per-query cost of the transient index */ - WhereTerm pTerm; /* A single term of the WHERE clause */ - WhereTerm pWCEnd; /* End of pWC.a[] */ - Table pTable; /* Table that might be indexed */ - - if (pParse.nQueryLoop <= (double)1) { - /* There is no point in building an automatic index for a single scan */ - return; - } - if ((pParse.db.flags & SQLITE_AutoIndex) == 0) { - /* Automatic indices are disabled at run-time */ - return; - } - if ((pCost.plan.wsFlags & WHERE_NOT_FULLSCAN) != 0) { - /* We already have some kind of index in use for this query. */ - return; - } - if (pSrc.notIndexed != 0) { - /* The NOT INDEXED clause appears in the SQL. */ - return; - } + /* +** If the query plan for pSrc specified in pCost is a full table scan +** and indexing is allows (if there is no NOT INDEXED clause) and it +** possible to construct a transient index that would perform better +** than a full table scan even when the cost of constructing the index +** is taken into account, then alter the query plan to use the +** transient index. +*/ + static void bestAutomaticIndex( + Parse pParse, /* The parsing context */ + WhereClause pWC, /* The WHERE clause */ + SrcList_item pSrc, /* The FROM clause term to search */ + Bitmask notReady, /* Mask of cursors that are not available */ + WhereCost pCost /* Lowest cost query plan */ + ) + { + double nTableRow; /* Rows in the input table */ + double logN; /* log(nTableRow) */ + double costTempIdx; /* per-query cost of the transient index */ + WhereTerm pTerm; /* A single term of the WHERE clause */ + WhereTerm pWCEnd; /* End of pWC.a[] */ + Table pTable; /* Table that might be indexed */ + + if ( pParse.nQueryLoop <= (double)1 ) + { + /* There is no point in building an automatic index for a single scan */ + return; + } + if ( ( pParse.db.flags & SQLITE_AutoIndex ) == 0 ) + { + /* Automatic indices are disabled at run-time */ + return; + } + if ( ( pCost.plan.wsFlags & WHERE_NOT_FULLSCAN ) != 0 ) + { + /* We already have some kind of index in use for this query. */ + return; + } + if ( pSrc.notIndexed != 0 ) + { + /* The NOT INDEXED clause appears in the SQL. */ + return; + } - Debug.Assert(pParse.nQueryLoop >= (double)1); - pTable = pSrc.pTab; - nTableRow = pTable.nRowEst; - logN = estLog(nTableRow); - costTempIdx = 2 * logN * (nTableRow / pParse.nQueryLoop + 1); - if (costTempIdx >= pCost.rCost) { - /* The cost of creating the transient table would be greater than - ** doing the full table scan */ - return; - } + Debug.Assert( pParse.nQueryLoop >= (double)1 ); + pTable = pSrc.pTab; + nTableRow = pTable.nRowEst; + logN = estLog( nTableRow ); + costTempIdx = 2 * logN * ( nTableRow / pParse.nQueryLoop + 1 ); + if ( costTempIdx >= pCost.rCost ) + { + /* The cost of creating the transient table would be greater than + ** doing the full table scan */ + return; + } - /* Search for any equality comparison term */ - //pWCEnd = pWC.a[pWC.nTerm]; - for (int ipTerm = 0; ipTerm < pWC.nTerm; ipTerm++)//; pTerm= BMS ? ((Bitmask)1) << (BMS - 1) : ((Bitmask)1) << iCol; - testcase(iCol == BMS); - testcase(iCol == BMS - 1); - if ((idxCols & cMask) == 0) { - nColumn++; - idxCols |= cMask; - } - } - } - Debug.Assert(nColumn > 0); - pLevel.plan.nEq = (u32)nColumn; - - /* Count the number of additional columns needed to create a - ** covering index. A "covering index" is an index that contains all - ** columns that are needed by the query. With a covering index, the - ** original table never needs to be accessed. Automatic indices must - ** be a covering index because the index will not be updated if the - ** original table changes and the index and table cannot both be used - ** if they go out of sync. - */ - extraCols = pSrc.colUsed & (~idxCols | (((Bitmask)1) << (BMS - 1))); - mxBitCol = (pTable.nCol >= BMS - 1) ? BMS - 1 : pTable.nCol; - testcase(pTable.nCol == BMS - 1); - testcase(pTable.nCol == BMS - 2); - for (i = 0; i < mxBitCol; i++) { - if ((extraCols & (((Bitmask)1) << i)) != 0) - nColumn++; - } - if ((pSrc.colUsed & (((Bitmask)1) << (BMS - 1))) != 0) { - nColumn += pTable.nCol - BMS + 1; - } - pLevel.plan.wsFlags |= WHERE_COLUMN_EQ | WHERE_IDX_ONLY | WO_EQ; - - /* Construct the Index object to describe this index */ - //nByte = sizeof(Index); - //nByte += nColumn*sizeof(int); /* Index.aiColumn */ - //nByte += nColumn*sizeof(char); /* Index.azColl */ - //nByte += nColumn; /* Index.aSortOrder */ - //pIdx = sqlite3DbMallocZero(pParse.db, nByte); - //if( pIdx==null) return; - pIdx = new Index(); - pLevel.plan.u.pIdx = pIdx; - pIdx.azColl = new string[nColumn + 1];// pIdx[1]; - pIdx.aiColumn = new int[nColumn + 1];// pIdx.azColl[nColumn]; - pIdx.aSortOrder = new u8[nColumn + 1];// pIdx.aiColumn[nColumn]; - pIdx.zName = "auto-index"; - pIdx.nColumn = nColumn; - pIdx.pTable = pTable; - n = 0; - idxCols = 0; - //for(pTerm=pWC.a; pTerm= BMS ? ((Bitmask)1) << (BMS - 1) : ((Bitmask)1) << iCol; - if ((idxCols & cMask) == 0) { - Expr pX = pTerm.pExpr; - idxCols |= cMask; - pIdx.aiColumn[n] = pTerm.u.leftColumn; - pColl = sqlite3BinaryCompareCollSeq(pParse, pX.pLeft, pX.pRight); - pIdx.azColl[n] = ALWAYS(pColl != null) ? pColl.zName : "BINARY"; - n++; - } - } - } - Debug.Assert((u32)n == pLevel.plan.nEq); - - /* Add additional columns needed to make the automatic index into - ** a covering index */ - for (i = 0; i < mxBitCol; i++) { - if ((extraCols & (((Bitmask)1) << i)) != 0) { - pIdx.aiColumn[n] = i; - pIdx.azColl[n] = "BINARY"; - n++; - } - } - if ((pSrc.colUsed & (((Bitmask)1) << (BMS - 1))) != 0) { - for (i = BMS - 1; i < pTable.nCol; i++) { - pIdx.aiColumn[n] = i; - pIdx.azColl[n] = "BINARY"; - n++; - } - } - Debug.Assert(n == nColumn); - - /* Create the automatic index */ - pKeyinfo = sqlite3IndexKeyinfo(pParse, pIdx); - Debug.Assert(pLevel.iIdxCur >= 0); - sqlite3VdbeAddOp4(v, OP_OpenAutoindex, pLevel.iIdxCur, nColumn + 1, 0, - pKeyinfo, P4_KEYINFO_HANDOFF); - VdbeComment(v, "for %s", pTable.zName); - - /* Fill the automatic index with content */ - addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel.iTabCur); - regRecord = sqlite3GetTempReg(pParse); - sqlite3GenerateIndexKey(pParse, pIdx, pLevel.iTabCur, regRecord, true); - sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel.iIdxCur, regRecord); - sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); - sqlite3VdbeAddOp2(v, OP_Next, pLevel.iTabCur, addrTop + 1); - sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX); - sqlite3VdbeJumpHere(v, addrTop); - sqlite3ReleaseTempReg(pParse, regRecord); - - /* Jump here when skipping the initialization */ - sqlite3VdbeJumpHere(v, addrInit); + /* +** Generate code to construct the Index object for an automatic index +** and to set up the WhereLevel object pLevel so that the code generator +** makes use of the automatic index. +*/ + static void constructAutomaticIndex( + Parse pParse, /* The parsing context */ + WhereClause pWC, /* The WHERE clause */ + SrcList_item pSrc, /* The FROM clause term to get the next index */ + Bitmask notReady, /* Mask of cursors that are not available */ + WhereLevel pLevel /* Write new index here */ + ) + { + int nColumn; /* Number of columns in the constructed index */ + WhereTerm pTerm; /* A single term of the WHERE clause */ + WhereTerm pWCEnd; /* End of pWC.a[] */ + int nByte; /* Byte of memory needed for pIdx */ + Index pIdx; /* Object describing the transient index */ + Vdbe v; /* Prepared statement under construction */ + int regIsInit; /* Register set by initialization */ + int addrInit; /* Address of the initialization bypass jump */ + Table pTable; /* The table being indexed */ + KeyInfo pKeyinfo; /* Key information for the index */ + int addrTop; /* Top of the index fill loop */ + int regRecord; /* Register holding an index record */ + int n; /* Column counter */ + int i; /* Loop counter */ + int mxBitCol; /* Maximum column in pSrc.colUsed */ + CollSeq pColl; /* Collating sequence to on a column */ + Bitmask idxCols; /* Bitmap of columns used for indexing */ + Bitmask extraCols; /* Bitmap of additional columns */ + + /* Generate code to skip over the creation and initialization of the + ** transient index on 2nd and subsequent iterations of the loop. */ + v = pParse.pVdbe; + Debug.Assert( v != null ); + regIsInit = ++pParse.nMem; + addrInit = sqlite3VdbeAddOp1( v, OP_If, regIsInit ); + sqlite3VdbeAddOp2( v, OP_Integer, 1, regIsInit ); + + /* Count the number of columns that will be added to the index + ** and used to match WHERE clause constraints */ + nColumn = 0; + pTable = pSrc.pTab; + //pWCEnd = pWC.a[pWC.nTerm]; + idxCols = 0; + for ( int ipTerm = 0; ipTerm < pWC.nTerm; ipTerm++ )//; pTerm= BMS ? ( (Bitmask)1 ) << ( BMS - 1 ) : ( (Bitmask)1 ) << iCol; + testcase( iCol == BMS ); + testcase( iCol == BMS - 1 ); + if ( ( idxCols & cMask ) == 0 ) + { + nColumn++; + idxCols |= cMask; + } + } + } + Debug.Assert( nColumn > 0 ); + pLevel.plan.nEq = (u32)nColumn; + + /* Count the number of additional columns needed to create a + ** covering index. A "covering index" is an index that contains all + ** columns that are needed by the query. With a covering index, the + ** original table never needs to be accessed. Automatic indices must + ** be a covering index because the index will not be updated if the + ** original table changes and the index and table cannot both be used + ** if they go out of sync. + */ + extraCols = pSrc.colUsed & ( ~idxCols | ( ( (Bitmask)1 ) << ( BMS - 1 ) ) ); + mxBitCol = ( pTable.nCol >= BMS - 1 ) ? BMS - 1 : pTable.nCol; + testcase( pTable.nCol == BMS - 1 ); + testcase( pTable.nCol == BMS - 2 ); + for ( i = 0; i < mxBitCol; i++ ) + { + if ( ( extraCols & ( ( (Bitmask)1 ) << i ) ) != 0 ) + nColumn++; + } + if ( ( pSrc.colUsed & ( ( (Bitmask)1 ) << ( BMS - 1 ) ) ) != 0 ) + { + nColumn += pTable.nCol - BMS + 1; + } + pLevel.plan.wsFlags |= WHERE_COLUMN_EQ | WHERE_IDX_ONLY | WO_EQ; + + /* Construct the Index object to describe this index */ + //nByte = sizeof(Index); + //nByte += nColumn*sizeof(int); /* Index.aiColumn */ + //nByte += nColumn*sizeof(char); /* Index.azColl */ + //nByte += nColumn; /* Index.aSortOrder */ + //pIdx = sqlite3DbMallocZero(pParse.db, nByte); + //if( pIdx==null) return; + pIdx = new Index(); + pLevel.plan.u.pIdx = pIdx; + pIdx.azColl = new string[nColumn + 1];// pIdx[1]; + pIdx.aiColumn = new int[nColumn + 1];// pIdx.azColl[nColumn]; + pIdx.aSortOrder = new u8[nColumn + 1];// pIdx.aiColumn[nColumn]; + pIdx.zName = "auto-index"; + pIdx.nColumn = nColumn; + pIdx.pTable = pTable; + n = 0; + idxCols = 0; + //for(pTerm=pWC.a; pTerm= BMS ? ( (Bitmask)1 ) << ( BMS - 1 ) : ( (Bitmask)1 ) << iCol; + if ( ( idxCols & cMask ) == 0 ) + { + Expr pX = pTerm.pExpr; + idxCols |= cMask; + pIdx.aiColumn[n] = pTerm.u.leftColumn; + pColl = sqlite3BinaryCompareCollSeq( pParse, pX.pLeft, pX.pRight ); + pIdx.azColl[n] = ALWAYS( pColl != null ) ? pColl.zName : "BINARY"; + n++; + } + } + } + Debug.Assert( (u32)n == pLevel.plan.nEq ); + + /* Add additional columns needed to make the automatic index into + ** a covering index */ + for ( i = 0; i < mxBitCol; i++ ) + { + if ( ( extraCols & ( ( (Bitmask)1 ) << i ) ) != 0 ) + { + pIdx.aiColumn[n] = i; + pIdx.azColl[n] = "BINARY"; + n++; + } + } + if ( ( pSrc.colUsed & ( ( (Bitmask)1 ) << ( BMS - 1 ) ) ) != 0 ) + { + for ( i = BMS - 1; i < pTable.nCol; i++ ) + { + pIdx.aiColumn[n] = i; + pIdx.azColl[n] = "BINARY"; + n++; } + } + Debug.Assert( n == nColumn ); + + /* Create the automatic index */ + pKeyinfo = sqlite3IndexKeyinfo( pParse, pIdx ); + Debug.Assert( pLevel.iIdxCur >= 0 ); + sqlite3VdbeAddOp4( v, OP_OpenAutoindex, pLevel.iIdxCur, nColumn + 1, 0, + pKeyinfo, P4_KEYINFO_HANDOFF ); + VdbeComment( v, "for %s", pTable.zName ); + + /* Fill the automatic index with content */ + addrTop = sqlite3VdbeAddOp1( v, OP_Rewind, pLevel.iTabCur ); + regRecord = sqlite3GetTempReg( pParse ); + sqlite3GenerateIndexKey( pParse, pIdx, pLevel.iTabCur, regRecord, true ); + sqlite3VdbeAddOp2( v, OP_IdxInsert, pLevel.iIdxCur, regRecord ); + sqlite3VdbeChangeP5( v, OPFLAG_USESEEKRESULT ); + sqlite3VdbeAddOp2( v, OP_Next, pLevel.iTabCur, addrTop + 1 ); + sqlite3VdbeChangeP5( v, SQLITE_STMTSTATUS_AUTOINDEX ); + sqlite3VdbeJumpHere( v, addrTop ); + sqlite3ReleaseTempReg( pParse, regRecord ); + + /* Jump here when skipping the initialization */ + sqlite3VdbeJumpHere( v, addrInit ); + } #endif //* SQLITE_OMIT_AUTOMATIC_INDEX */ #if !SQLITE_OMIT_VIRTUALTABLE - /* - ** Allocate and populate an sqlite3_index_info structure. It is the - ** responsibility of the caller to eventually release the structure - ** by passing the pointer returned by this function to //sqlite3_free(). - */ - static sqlite3_index_info allocateIndexInfo( - Parse pParse, - WhereClause pWC, - SrcList_item pSrc, - ExprList pOrderBy - ) { - int i, j; - int nTerm; - sqlite3_index_constraint[] pIdxCons; - sqlite3_index_orderby[] pIdxOrderBy; - sqlite3_index_constraint_usage[] pUsage; - WhereTerm pTerm; - int nOrderBy; - sqlite3_index_info pIdxInfo; - -#if (SQLITE_TEST) && (SQLITE_DEBUG) + /* +** Allocate and populate an sqlite3_index_info structure. It is the +** responsibility of the caller to eventually release the structure +** by passing the pointer returned by this function to //sqlite3_free(). +*/ + static sqlite3_index_info allocateIndexInfo( + Parse pParse, + WhereClause pWC, + SrcList_item pSrc, + ExprList pOrderBy + ) + { + int i, j; + int nTerm; + sqlite3_index_constraint[] pIdxCons; + sqlite3_index_orderby[] pIdxOrderBy; + sqlite3_index_constraint_usage[] pUsage; + WhereTerm pTerm; + int nOrderBy; + sqlite3_index_info pIdxInfo; + +#if (SQLITE_TEST) && (SQLITE_DEBUG) WHERETRACE( "Recomputing index info for %s...\n", pSrc.pTab.zName ); #endif - /* Count the number of possible WHERE clause constraints referring - ** to this virtual table */ - for (i = nTerm = 0; i < pWC.nTerm; i++)//, pTerm++ ) - { - pTerm = pWC.a[i]; - if (pTerm.leftCursor != pSrc.iCursor) - continue; - Debug.Assert((pTerm.eOperator & (pTerm.eOperator - 1)) == 0); - testcase(pTerm.eOperator == WO_IN); - testcase(pTerm.eOperator == WO_ISNULL); - if ((pTerm.eOperator & (WO_IN | WO_ISNULL)) != 0) - continue; - nTerm++; - } + /* Count the number of possible WHERE clause constraints referring +** to this virtual table */ + for ( i = nTerm = 0; i < pWC.nTerm; i++)//, pTerm++ ) + { + pTerm = pWC.a[i]; + if ( pTerm.leftCursor != pSrc.iCursor ) + continue; + Debug.Assert( ( pTerm.eOperator & ( pTerm.eOperator - 1 ) ) == 0 ); + testcase( pTerm.eOperator == WO_IN ); + testcase( pTerm.eOperator == WO_ISNULL ); + if ( ( pTerm.eOperator & ( WO_IN | WO_ISNULL ) ) != 0 ) + continue; + nTerm++; + } - /* If the ORDER BY clause contains only columns in the current - ** virtual table then allocate space for the aOrderBy part of - ** the sqlite3_index_info structure. - */ - nOrderBy = 0; - if (pOrderBy != null) { - for (i = 0; i < pOrderBy.nExpr; i++) { - Expr pExpr = pOrderBy.a[i].pExpr; - if (pExpr.op != TK_COLUMN || pExpr.iTable != pSrc.iCursor) - break; - } - if (i == pOrderBy.nExpr) { - nOrderBy = pOrderBy.nExpr; - } - } + /* If the ORDER BY clause contains only columns in the current + ** virtual table then allocate space for the aOrderBy part of + ** the sqlite3_index_info structure. + */ + nOrderBy = 0; + if ( pOrderBy != null ) + { + for ( i = 0; i < pOrderBy.nExpr; i++ ) + { + Expr pExpr = pOrderBy.a[i].pExpr; + if ( pExpr.op != TK_COLUMN || pExpr.iTable != pSrc.iCursor ) + break; + } + if ( i == pOrderBy.nExpr ) + { + nOrderBy = pOrderBy.nExpr; + } + } - /* Allocate the sqlite3_index_info structure - */ - pIdxInfo = new sqlite3_index_info(); - //sqlite3DbMallocZero(pParse.db, sizeof(*pIdxInfo) - //+ (sizeof(*pIdxCons) + sizeof(*pUsage))*nTerm - //+ sizeof(*pIdxOrderBy)*nOrderBy ); - //if ( pIdxInfo == null ) - //{ - // sqlite3ErrorMsg( pParse, "out of memory" ); - // /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ - // return null; - //} + /* Allocate the sqlite3_index_info structure + */ + pIdxInfo = new sqlite3_index_info(); + //sqlite3DbMallocZero(pParse.db, sizeof(*pIdxInfo) + //+ (sizeof(*pIdxCons) + sizeof(*pUsage))*nTerm + //+ sizeof(*pIdxOrderBy)*nOrderBy ); + //if ( pIdxInfo == null ) + //{ + // sqlite3ErrorMsg( pParse, "out of memory" ); + // /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ + // return null; + //} - /* Initialize the structure. The sqlite3_index_info structure contains - ** many fields that are declared "const" to prevent xBestIndex from - ** changing them. We have to do some funky casting in order to - ** initialize those fields. - */ - pIdxCons = new sqlite3_index_constraint[nTerm];//(sqlite3_index_constraint)pIdxInfo[1]; - pIdxOrderBy = new sqlite3_index_orderby[nOrderBy];//(sqlite3_index_orderby)pIdxCons[nTerm]; - pUsage = new sqlite3_index_constraint_usage[nTerm];//(sqlite3_index_constraint_usage)pIdxOrderBy[nOrderBy]; - pIdxInfo.nConstraint = nTerm; - pIdxInfo.nOrderBy = nOrderBy; - pIdxInfo.aConstraint = pIdxCons; - pIdxInfo.aOrderBy = pIdxOrderBy; - pIdxInfo.aConstraintUsage = - pUsage; - - for (i = j = 0; i < pWC.nTerm; i++)//, pTerm++ ) - { - pTerm = pWC.a[i]; - if (pTerm.leftCursor != pSrc.iCursor) - continue; - Debug.Assert((pTerm.eOperator & (pTerm.eOperator - 1)) == 0); - testcase(pTerm.eOperator == WO_IN); - testcase(pTerm.eOperator == WO_ISNULL); - if ((pTerm.eOperator & (WO_IN | WO_ISNULL)) != 0) - continue; - if (pIdxCons[j] == null) - pIdxCons[j] = new sqlite3_index_constraint(); - pIdxCons[j].iColumn = pTerm.u.leftColumn; - pIdxCons[j].iTermOffset = i; - pIdxCons[j].op = (u8)pTerm.eOperator; - /* The direct Debug.Assignment in the previous line is possible only because - ** the WO_ and SQLITE_INDEX_CONSTRAINT_ codes are identical. The - ** following Debug.Asserts verify this fact. */ - Debug.Assert(WO_EQ == SQLITE_INDEX_CONSTRAINT_EQ); - Debug.Assert(WO_LT == SQLITE_INDEX_CONSTRAINT_LT); - Debug.Assert(WO_LE == SQLITE_INDEX_CONSTRAINT_LE); - Debug.Assert(WO_GT == SQLITE_INDEX_CONSTRAINT_GT); - Debug.Assert(WO_GE == SQLITE_INDEX_CONSTRAINT_GE); - Debug.Assert(WO_MATCH == SQLITE_INDEX_CONSTRAINT_MATCH); - Debug.Assert((pTerm.eOperator & (WO_EQ | WO_LT | WO_LE | WO_GT | WO_GE | WO_MATCH)) != 0); - j++; - } - for (i = 0; i < nOrderBy; i++) { - Expr pExpr = pOrderBy.a[i].pExpr; - if (pIdxOrderBy[i] == null) - pIdxOrderBy[i] = new sqlite3_index_orderby(); - pIdxOrderBy[i].iColumn = pExpr.iColumn; - pIdxOrderBy[i].desc = pOrderBy.a[i].sortOrder != 0; - } + /* Initialize the structure. The sqlite3_index_info structure contains + ** many fields that are declared "const" to prevent xBestIndex from + ** changing them. We have to do some funky casting in order to + ** initialize those fields. + */ + pIdxCons = new sqlite3_index_constraint[nTerm];//(sqlite3_index_constraint)pIdxInfo[1]; + pIdxOrderBy = new sqlite3_index_orderby[nOrderBy];//(sqlite3_index_orderby)pIdxCons[nTerm]; + pUsage = new sqlite3_index_constraint_usage[nTerm];//(sqlite3_index_constraint_usage)pIdxOrderBy[nOrderBy]; + pIdxInfo.nConstraint = nTerm; + pIdxInfo.nOrderBy = nOrderBy; + pIdxInfo.aConstraint = pIdxCons; + pIdxInfo.aOrderBy = pIdxOrderBy; + pIdxInfo.aConstraintUsage = + pUsage; + + for ( i = j = 0; i < pWC.nTerm; i++)//, pTerm++ ) + { + pTerm = pWC.a[i]; + if ( pTerm.leftCursor != pSrc.iCursor ) + continue; + Debug.Assert( ( pTerm.eOperator & ( pTerm.eOperator - 1 ) ) == 0 ); + testcase( pTerm.eOperator == WO_IN ); + testcase( pTerm.eOperator == WO_ISNULL ); + if ( ( pTerm.eOperator & ( WO_IN | WO_ISNULL ) ) != 0 ) + continue; + if ( pIdxCons[j] == null ) + pIdxCons[j] = new sqlite3_index_constraint(); + pIdxCons[j].iColumn = pTerm.u.leftColumn; + pIdxCons[j].iTermOffset = i; + pIdxCons[j].op = (u8)pTerm.eOperator; + /* The direct Debug.Assignment in the previous line is possible only because + ** the WO_ and SQLITE_INDEX_CONSTRAINT_ codes are identical. The + ** following Debug.Asserts verify this fact. */ + Debug.Assert( WO_EQ == SQLITE_INDEX_CONSTRAINT_EQ ); + Debug.Assert( WO_LT == SQLITE_INDEX_CONSTRAINT_LT ); + Debug.Assert( WO_LE == SQLITE_INDEX_CONSTRAINT_LE ); + Debug.Assert( WO_GT == SQLITE_INDEX_CONSTRAINT_GT ); + Debug.Assert( WO_GE == SQLITE_INDEX_CONSTRAINT_GE ); + Debug.Assert( WO_MATCH == SQLITE_INDEX_CONSTRAINT_MATCH ); + Debug.Assert( ( pTerm.eOperator & ( WO_EQ | WO_LT | WO_LE | WO_GT | WO_GE | WO_MATCH ) ) != 0 ); + j++; + } + for ( i = 0; i < nOrderBy; i++ ) + { + Expr pExpr = pOrderBy.a[i].pExpr; + if ( pIdxOrderBy[i] == null ) + pIdxOrderBy[i] = new sqlite3_index_orderby(); + pIdxOrderBy[i].iColumn = pExpr.iColumn; + pIdxOrderBy[i].desc = pOrderBy.a[i].sortOrder != 0; + } - return pIdxInfo; - } + return pIdxInfo; + } - /* - ** The table object reference passed as the second argument to this function - ** must represent a virtual table. This function invokes the xBestIndex() - ** method of the virtual table with the sqlite3_index_info pointer passed - ** as the argument. - ** - ** If an error occurs, pParse is populated with an error message and a - ** non-zero value is returned. Otherwise, 0 is returned and the output - ** part of the sqlite3_index_info structure is left populated. - ** - ** Whether or not an error is returned, it is the responsibility of the - ** caller to eventually free p.idxStr if p.needToFreeIdxStr indicates - ** that this is required. - */ - static int vtabBestIndex(Parse pParse, Table pTab, sqlite3_index_info p) { - sqlite3_vtab pVtab = sqlite3GetVTable(pParse.db, pTab).pVtab; - int i; - int rc; + /* + ** The table object reference passed as the second argument to this function + ** must represent a virtual table. This function invokes the xBestIndex() + ** method of the virtual table with the sqlite3_index_info pointer passed + ** as the argument. + ** + ** If an error occurs, pParse is populated with an error message and a + ** non-zero value is returned. Otherwise, 0 is returned and the output + ** part of the sqlite3_index_info structure is left populated. + ** + ** Whether or not an error is returned, it is the responsibility of the + ** caller to eventually free p.idxStr if p.needToFreeIdxStr indicates + ** that this is required. + */ + static int vtabBestIndex( Parse pParse, Table pTab, sqlite3_index_info p ) + { + sqlite3_vtab pVtab = sqlite3GetVTable( pParse.db, pTab ).pVtab; + int i; + int rc; -#if (SQLITE_TEST) && (SQLITE_DEBUG) +#if (SQLITE_TEST) && (SQLITE_DEBUG) WHERETRACE( "xBestIndex for %s\n", pTab.zName ); #endif - TRACE_IDX_INPUTS(p); - rc = pVtab.pModule.xBestIndex(pVtab, ref p); - TRACE_IDX_OUTPUTS(p); - - if (rc != SQLITE_OK) { - //if ( rc == SQLITE_NOMEM ) - //{ - // pParse.db.mallocFailed = 1; - //} - // else - if (String.IsNullOrEmpty(pVtab.zErrMsg)) { - sqlite3ErrorMsg(pParse, "%s", sqlite3ErrStr(rc)); - } else { - sqlite3ErrorMsg(pParse, "%s", pVtab.zErrMsg); - } - } - //sqlite3_free( pVtab.zErrMsg ); - pVtab.zErrMsg = null; + TRACE_IDX_INPUTS( p ); + rc = pVtab.pModule.xBestIndex( pVtab, ref p ); + TRACE_IDX_OUTPUTS( p ); - for (i = 0; i < p.nConstraint; i++) { - if (!p.aConstraint[i].usable && p.aConstraintUsage[i].argvIndex > 0) { - sqlite3ErrorMsg(pParse, - "table %s: xBestIndex returned an invalid plan", pTab.zName); - } - } + if ( rc != SQLITE_OK ) + { + //if ( rc == SQLITE_NOMEM ) + //{ + // pParse.db.mallocFailed = 1; + //} + // else + if ( String.IsNullOrEmpty( pVtab.zErrMsg ) ) + { + sqlite3ErrorMsg( pParse, "%s", sqlite3ErrStr( rc ) ); + } + else + { + sqlite3ErrorMsg( pParse, "%s", pVtab.zErrMsg ); + } + } + //sqlite3_free( pVtab.zErrMsg ); + pVtab.zErrMsg = null; - return pParse.nErr; + for ( i = 0; i < p.nConstraint; i++ ) + { + if ( !p.aConstraint[i].usable && p.aConstraintUsage[i].argvIndex > 0 ) + { + sqlite3ErrorMsg( pParse, + "table %s: xBestIndex returned an invalid plan", pTab.zName ); } + } + return pParse.nErr; + } - /* - ** Compute the best index for a virtual table. - ** - ** The best index is computed by the xBestIndex method of the virtual - ** table module. This routine is really just a wrapper that sets up - ** the sqlite3_index_info structure that is used to communicate with - ** xBestIndex. - ** - ** In a join, this routine might be called multiple times for the - ** same virtual table. The sqlite3_index_info structure is created - ** and initialized on the first invocation and reused on all subsequent - ** invocations. The sqlite3_index_info structure is also used when - ** code is generated to access the virtual table. The whereInfoDelete() - ** routine takes care of freeing the sqlite3_index_info structure after - ** everybody has finished with it. - */ - static void bestVirtualIndex( - Parse pParse, /* The parsing context */ - WhereClause pWC, /* The WHERE clause */ - SrcList_item pSrc, /* The FROM clause term to search */ - Bitmask notReady, /* Mask of cursors not available for index */ - Bitmask notValid, /* Cursors not valid for any purpose */ - ExprList pOrderBy, /* The order by clause */ - ref WhereCost pCost, /* Lowest cost query plan */ - ref sqlite3_index_info ppIdxInfo /* Index information passed to xBestIndex */ - ) { - Table pTab = pSrc.pTab; - sqlite3_index_info pIdxInfo; - sqlite3_index_constraint pIdxCons; - sqlite3_index_constraint_usage[] pUsage = null; - WhereTerm pTerm; - int i, j; - int nOrderBy; - double rCost; - - - /* Make sure wsFlags is initialized to some sane value. Otherwise, if the - ** malloc in allocateIndexInfo() fails and this function returns leaving - ** wsFlags in an uninitialized state, the caller may behave unpredictably. - */ - pCost = new WhereCost();//memset(pCost, 0, sizeof(*pCost)); - pCost.plan.wsFlags = WHERE_VIRTUALTABLE; - /* If the sqlite3_index_info structure has not been previously - ** allocated and initialized, then allocate and initialize it now. - */ - pIdxInfo = ppIdxInfo; - if (pIdxInfo == null) { - ppIdxInfo = pIdxInfo = allocateIndexInfo(pParse, pWC, pSrc, pOrderBy); - } - if (pIdxInfo == null) { - return; - } + /* + ** Compute the best index for a virtual table. + ** + ** The best index is computed by the xBestIndex method of the virtual + ** table module. This routine is really just a wrapper that sets up + ** the sqlite3_index_info structure that is used to communicate with + ** xBestIndex. + ** + ** In a join, this routine might be called multiple times for the + ** same virtual table. The sqlite3_index_info structure is created + ** and initialized on the first invocation and reused on all subsequent + ** invocations. The sqlite3_index_info structure is also used when + ** code is generated to access the virtual table. The whereInfoDelete() + ** routine takes care of freeing the sqlite3_index_info structure after + ** everybody has finished with it. + */ + static void bestVirtualIndex( + Parse pParse, /* The parsing context */ + WhereClause pWC, /* The WHERE clause */ + SrcList_item pSrc, /* The FROM clause term to search */ + Bitmask notReady, /* Mask of cursors not available for index */ + Bitmask notValid, /* Cursors not valid for any purpose */ + ExprList pOrderBy, /* The order by clause */ + ref WhereCost pCost, /* Lowest cost query plan */ + ref sqlite3_index_info ppIdxInfo /* Index information passed to xBestIndex */ + ) + { + Table pTab = pSrc.pTab; + sqlite3_index_info pIdxInfo; + sqlite3_index_constraint pIdxCons; + sqlite3_index_constraint_usage[] pUsage = null; + WhereTerm pTerm; + int i, j; + int nOrderBy; + double rCost; + + + /* Make sure wsFlags is initialized to some sane value. Otherwise, if the + ** malloc in allocateIndexInfo() fails and this function returns leaving + ** wsFlags in an uninitialized state, the caller may behave unpredictably. + */ + pCost = new WhereCost();//memset(pCost, 0, sizeof(*pCost)); + pCost.plan.wsFlags = WHERE_VIRTUALTABLE; - /* At this point, the sqlite3_index_info structure that pIdxInfo points - ** to will have been initialized, either during the current invocation or - ** during some prior invocation. Now we just have to customize the - ** details of pIdxInfo for the current invocation and pDebug.Ass it to - ** xBestIndex. - */ + /* If the sqlite3_index_info structure has not been previously + ** allocated and initialized, then allocate and initialize it now. + */ + pIdxInfo = ppIdxInfo; + if ( pIdxInfo == null ) + { + ppIdxInfo = pIdxInfo = allocateIndexInfo( pParse, pWC, pSrc, pOrderBy ); + } + if ( pIdxInfo == null ) + { + return; + } - /* The module name must be defined. Also, by this point there must - ** be a pointer to an sqlite3_vtab structure. Otherwise - ** sqlite3ViewGetColumnNames() would have picked up the error. - */ - Debug.Assert(pTab.azModuleArg != null && pTab.azModuleArg[0] != null); - Debug.Assert(sqlite3GetVTable(pParse.db, pTab) != null); + /* At this point, the sqlite3_index_info structure that pIdxInfo points + ** to will have been initialized, either during the current invocation or + ** during some prior invocation. Now we just have to customize the + ** details of pIdxInfo for the current invocation and pDebug.Ass it to + ** xBestIndex. + */ - /* Set the aConstraint[].usable fields and initialize all - ** output variables to zero. - ** - ** aConstraint[].usable is true for constraints where the right-hand - ** side contains only references to tables to the left of the current - ** table. In other words, if the constraint is of the form: - ** - ** column = expr - ** - ** and we are evaluating a join, then the constraint on column is - ** only valid if all tables referenced in expr occur to the left - ** of the table containing column. - ** - ** The aConstraints[] array contains entries for all constraints - ** on the current table. That way we only have to compute it once - ** even though we might try to pick the best index multiple times. - ** For each attempt at picking an index, the order of tables in the - ** join might be different so we have to recompute the usable flag - ** each time. - */ - //pIdxCons = *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint; - //pUsage = pIdxInfo->aConstraintUsage; - for (i = 0; i < pIdxInfo.nConstraint; i++) { - pIdxCons = pIdxInfo.aConstraint[i]; - pUsage = pIdxInfo.aConstraintUsage; - j = pIdxCons.iTermOffset; - pTerm = pWC.a[j]; - pIdxCons.usable = (pTerm.prereqRight & notReady) == 0; - pUsage[i] = new sqlite3_index_constraint_usage(); - } - // memset(pUsage, 0, sizeof(pUsage[0])*pIdxInfo.nConstraint); - if (pIdxInfo.needToFreeIdxStr != 0) { - //sqlite3_free(ref pIdxInfo.idxStr); - } - pIdxInfo.idxStr = null; - pIdxInfo.idxNum = 0; - pIdxInfo.needToFreeIdxStr = 0; - pIdxInfo.orderByConsumed = false; - /* ((double)2) In case of SQLITE_OMIT_FLOATING_POINT... */ - pIdxInfo.estimatedCost = SQLITE_BIG_DBL / ((double)2); - nOrderBy = pIdxInfo.nOrderBy; - if (null == pOrderBy) { - pIdxInfo.nOrderBy = 0; - } + /* The module name must be defined. Also, by this point there must + ** be a pointer to an sqlite3_vtab structure. Otherwise + ** sqlite3ViewGetColumnNames() would have picked up the error. + */ + Debug.Assert( pTab.azModuleArg != null && pTab.azModuleArg[0] != null ); + Debug.Assert( sqlite3GetVTable( pParse.db, pTab ) != null ); - if (vtabBestIndex(pParse, pTab, pIdxInfo) != 0) { - return; - } + /* Set the aConstraint[].usable fields and initialize all + ** output variables to zero. + ** + ** aConstraint[].usable is true for constraints where the right-hand + ** side contains only references to tables to the left of the current + ** table. In other words, if the constraint is of the form: + ** + ** column = expr + ** + ** and we are evaluating a join, then the constraint on column is + ** only valid if all tables referenced in expr occur to the left + ** of the table containing column. + ** + ** The aConstraints[] array contains entries for all constraints + ** on the current table. That way we only have to compute it once + ** even though we might try to pick the best index multiple times. + ** For each attempt at picking an index, the order of tables in the + ** join might be different so we have to recompute the usable flag + ** each time. + */ + //pIdxCons = *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint; + //pUsage = pIdxInfo->aConstraintUsage; + for ( i = 0; i < pIdxInfo.nConstraint; i++) + { + pIdxCons = pIdxInfo.aConstraint[i]; + pUsage = pIdxInfo.aConstraintUsage; + j = pIdxCons.iTermOffset; + pTerm = pWC.a[j]; + pIdxCons.usable = ( pTerm.prereqRight & notReady ) == 0; + pUsage[i] = new sqlite3_index_constraint_usage(); + } + // memset(pUsage, 0, sizeof(pUsage[0])*pIdxInfo.nConstraint); + if ( pIdxInfo.needToFreeIdxStr!=0 ) + { + //sqlite3_free(ref pIdxInfo.idxStr); + } + pIdxInfo.idxStr = null; + pIdxInfo.idxNum = 0; + pIdxInfo.needToFreeIdxStr = 0; + pIdxInfo.orderByConsumed = false; + /* ((double)2) In case of SQLITE_OMIT_FLOATING_POINT... */ + pIdxInfo.estimatedCost = SQLITE_BIG_DBL / ( (double)2 ); + nOrderBy = pIdxInfo.nOrderBy; + if ( null == pOrderBy ) + { + pIdxInfo.nOrderBy = 0; + } - //pIdxCons = (sqlite3_index_constraint)pIdxInfo.aConstraint; - for (i = 0; i < pIdxInfo.nConstraint; i++) { - if (pUsage[i].argvIndex > 0) { - //pCost.used |= pWC.a[pIdxCons[i].iTermOffset].prereqRight; - pCost.used |= pWC.a[pIdxInfo.aConstraint[i].iTermOffset].prereqRight; - } - } + if ( vtabBestIndex( pParse, pTab, pIdxInfo ) != 0 ) + { + return; + } - /* If there is an ORDER BY clause, and the selected virtual table index - ** does not satisfy it, increase the cost of the scan accordingly. This - ** matches the processing for non-virtual tables in bestBtreeIndex(). - */ - rCost = pIdxInfo.estimatedCost; - if (pOrderBy != null && !pIdxInfo.orderByConsumed) { - rCost += estLog(rCost) * rCost; - } + //pIdxCons = (sqlite3_index_constraint)pIdxInfo.aConstraint; + for ( i = 0; i < pIdxInfo.nConstraint; i++ ) + { + if ( pUsage[i].argvIndex > 0 ) + { + //pCost.used |= pWC.a[pIdxCons[i].iTermOffset].prereqRight; + pCost.used |= pWC.a[pIdxInfo.aConstraint[i].iTermOffset].prereqRight; + } + } - /* The cost is not allowed to be larger than SQLITE_BIG_DBL (the - ** inital value of lowestCost in this loop. If it is, then the - ** (cost ? AND a < ? ... - ** |_____| |_____| - ** | | - ** pLower pUpper - ** - ** If either of the upper or lower bound is not present, then NULL is passed in - ** place of the corresponding WhereTerm. - ** - ** The nEq parameter is passed the index of the index column subject to the - ** range constraint. Or, equivalently, the number of equality constraints - ** optimized by the proposed index scan. For example, assuming index p is - ** on t1(a, b), and the SQL query is: - ** - ** ... FROM t1 WHERE a = ? AND b > ? AND b < ? ... - ** - ** then nEq should be passed the value 1 (as the range restricted column, - ** b, is the second left-most column of the index). Or, if the query is: - ** - ** ... FROM t1 WHERE a > ? AND a < ? ... - ** - ** then nEq should be passed 0. - ** - ** The returned value is an integer between 1 and 100, inclusive. A return - ** value of 1 indicates that the proposed range scan is expected to visit - ** approximately 1/100th (1%) of the rows selected by the nEq equality - ** constraints (if any). A return value of 100 indicates that it is expected - ** that the range scan will visit every row (100%) selected by the equality - ** constraints. - ** - ** In the absence of sqlite_stat2 ANALYZE data, each range inequality - ** reduces the search space by 3/4ths. Hence a single constraint (x>?) - ** results in a return of 25 and a range constraint (x>? AND x123" Might be NULL */ - WhereTerm pUpper, /* Upper bound on the range. ex: "x<455" Might be NULL */ - out int piEst /* OUT: Return value */ - ) { - int rc = SQLITE_OK; + /* +** This function is used to estimate the number of rows that will be visited +** by scanning an index for a range of values. The range may have an upper +** bound, a lower bound, or both. The WHERE clause terms that set the upper +** and lower bounds are represented by pLower and pUpper respectively. For +** example, assuming that index p is on t1(a): +** +** ... FROM t1 WHERE a > ? AND a < ? ... +** |_____| |_____| +** | | +** pLower pUpper +** +** If either of the upper or lower bound is not present, then NULL is passed in +** place of the corresponding WhereTerm. +** +** The nEq parameter is passed the index of the index column subject to the +** range constraint. Or, equivalently, the number of equality constraints +** optimized by the proposed index scan. For example, assuming index p is +** on t1(a, b), and the SQL query is: +** +** ... FROM t1 WHERE a = ? AND b > ? AND b < ? ... +** +** then nEq should be passed the value 1 (as the range restricted column, +** b, is the second left-most column of the index). Or, if the query is: +** +** ... FROM t1 WHERE a > ? AND a < ? ... +** +** then nEq should be passed 0. +** +** The returned value is an integer between 1 and 100, inclusive. A return +** value of 1 indicates that the proposed range scan is expected to visit +** approximately 1/100th (1%) of the rows selected by the nEq equality +** constraints (if any). A return value of 100 indicates that it is expected +** that the range scan will visit every row (100%) selected by the equality +** constraints. +** +** In the absence of sqlite_stat2 ANALYZE data, each range inequality +** reduces the search space by 3/4ths. Hence a single constraint (x>?) +** results in a return of 25 and a range constraint (x>? AND x123" Might be NULL */ + WhereTerm pUpper, /* Upper bound on the range. ex: "x<455" Might be NULL */ + out int piEst /* OUT: Return value */ + ) + { + int rc = SQLITE_OK; #if SQLITE_ENABLE_STAT2 @@ -2744,18 +2960,18 @@ static int whereRangeScanEst( } range_est_fallback: #else - UNUSED_PARAMETER(pParse); - UNUSED_PARAMETER(p); - UNUSED_PARAMETER(nEq); +UNUSED_PARAMETER(pParse); +UNUSED_PARAMETER(p); +UNUSED_PARAMETER(nEq); #endif - Debug.Assert(pLower != null || pUpper != null); - piEst = 100; - if (pLower != null && (pLower.wtFlags & TERM_VNULL) == 0) - piEst /= 4; - if (pUpper != null) - piEst /= 4; - return rc; - } + Debug.Assert( pLower != null || pUpper != null ); + piEst = 100; + if ( pLower != null && ( pLower.wtFlags & TERM_VNULL ) == 0 ) + piEst /= 4; + if ( pUpper != null ) + piEst /= 4; + return rc; + } #if SQLITE_ENABLE_STAT2 /* @@ -2924,297 +3140,331 @@ ref double pnRow /* Write the revised row estimate here */ #endif //* defined(SQLITE_ENABLE_STAT2) */ - /* - ** Find the best query plan for accessing a particular table. Write the - ** best query plan and its cost into the WhereCost object supplied as the - ** last parameter. - ** - ** The lowest cost plan wins. The cost is an estimate of the amount of - ** CPU and disk I/O needed to process the requested result. - ** Factors that influence cost include: - ** - ** * The estimated number of rows that will be retrieved. (The - ** fewer the better.) - ** - ** * Whether or not sorting must occur. - ** - ** * Whether or not there must be separate lookups in the - ** index and in the main table. - ** - ** If there was an INDEXED BY clause (pSrc->pIndex) attached to the table in - ** the SQL statement, then this function only considers plans using the - ** named index. If no such plan is found, then the returned cost is - ** SQLITE_BIG_DBL. If a plan is found that uses the named index, - ** then the cost is calculated in the usual way. - ** - ** If a NOT INDEXED clause (pSrc->notIndexed!=0) was attached to the table - ** in the SELECT statement, then no indexes are considered. However, the - ** selected plan may still take advantage of the built-in rowid primary key - ** index. - */ - static void bestBtreeIndex( - Parse pParse, /* The parsing context */ - WhereClause pWC, /* The WHERE clause */ - SrcList_item pSrc, /* The FROM clause term to search */ - Bitmask notReady, /* Mask of cursors not available for indexing */ - Bitmask notValid, /* Cursors not available for any purpose */ - ExprList pOrderBy, /* The ORDER BY clause */ - ref WhereCost pCost /* Lowest cost query plan */ - ) { - int iCur = pSrc.iCursor; /* The cursor of the table to be accessed */ - Index pProbe; /* An index we are evaluating */ - Index pIdx; /* Copy of pProbe, or zero for IPK index */ - u32 eqTermMask; /* Current mask of valid equality operators */ - u32 idxEqTermMask; /* Index mask of valid equality operators */ - Index sPk; /* A fake index object for the primary key */ - int[] aiRowEstPk = new int[2]; /* The aiRowEst[] value for the sPk index */ - int aiColumnPk = -1; /* The aColumn[] value for the sPk index */ - int wsFlagMask; /* Allowed flags in pCost.plan.wsFlag */ - - /* Initialize the cost to a worst-case value */ - if (pCost == null) - pCost = new WhereCost(); - else - pCost.Clear(); //memset(pCost, 0, sizeof(*pCost)); - pCost.rCost = SQLITE_BIG_DBL; + /* +** Find the best query plan for accessing a particular table. Write the +** best query plan and its cost into the WhereCost object supplied as the +** last parameter. +** +** The lowest cost plan wins. The cost is an estimate of the amount of +** CPU and disk I/O needed to process the requested result. +** Factors that influence cost include: +** +** * The estimated number of rows that will be retrieved. (The +** fewer the better.) +** +** * Whether or not sorting must occur. +** +** * Whether or not there must be separate lookups in the +** index and in the main table. +** +** If there was an INDEXED BY clause (pSrc->pIndex) attached to the table in +** the SQL statement, then this function only considers plans using the +** named index. If no such plan is found, then the returned cost is +** SQLITE_BIG_DBL. If a plan is found that uses the named index, +** then the cost is calculated in the usual way. +** +** If a NOT INDEXED clause (pSrc->notIndexed!=0) was attached to the table +** in the SELECT statement, then no indexes are considered. However, the +** selected plan may still take advantage of the built-in rowid primary key +** index. +*/ + static void bestBtreeIndex( + Parse pParse, /* The parsing context */ + WhereClause pWC, /* The WHERE clause */ + SrcList_item pSrc, /* The FROM clause term to search */ + Bitmask notReady, /* Mask of cursors not available for indexing */ + Bitmask notValid, /* Cursors not available for any purpose */ + ExprList pOrderBy, /* The ORDER BY clause */ + ref WhereCost pCost /* Lowest cost query plan */ + ) + { + int iCur = pSrc.iCursor; /* The cursor of the table to be accessed */ + Index pProbe; /* An index we are evaluating */ + Index pIdx; /* Copy of pProbe, or zero for IPK index */ + u32 eqTermMask; /* Current mask of valid equality operators */ + u32 idxEqTermMask; /* Index mask of valid equality operators */ + Index sPk; /* A fake index object for the primary key */ + int[] aiRowEstPk = new int[2]; /* The aiRowEst[] value for the sPk index */ + int aiColumnPk = -1; /* The aColumn[] value for the sPk index */ + int wsFlagMask; /* Allowed flags in pCost.plan.wsFlag */ + + /* Initialize the cost to a worst-case value */ + if ( pCost == null ) + pCost = new WhereCost(); + else + pCost.Clear(); //memset(pCost, 0, sizeof(*pCost)); + pCost.rCost = SQLITE_BIG_DBL; - /* If the pSrc table is the right table of a LEFT JOIN then we may not - ** use an index to satisfy IS NULL constraints on that table. This is - ** because columns might end up being NULL if the table does not match - - ** a circumstance which the index cannot help us discover. Ticket #2177. - */ - if ((pSrc.jointype & JT_LEFT) != 0) { - idxEqTermMask = WO_EQ | WO_IN; - } else { - idxEqTermMask = WO_EQ | WO_IN | WO_ISNULL; - } + /* If the pSrc table is the right table of a LEFT JOIN then we may not + ** use an index to satisfy IS NULL constraints on that table. This is + ** because columns might end up being NULL if the table does not match - + ** a circumstance which the index cannot help us discover. Ticket #2177. + */ + if ( ( pSrc.jointype & JT_LEFT ) != 0 ) + { + idxEqTermMask = WO_EQ | WO_IN; + } + else + { + idxEqTermMask = WO_EQ | WO_IN | WO_ISNULL; + } - if (pSrc.pIndex != null) { - /* An INDEXED BY clause specifies a particular index to use */ - pIdx = pProbe = pSrc.pIndex; - wsFlagMask = ~(WHERE_ROWID_EQ | WHERE_ROWID_RANGE); - eqTermMask = idxEqTermMask; - } else { - /* There is no INDEXED BY clause. Create a fake Index object in local - ** variable sPk to represent the rowid primary key index. Make this - ** fake index the first in a chain of Index objects with all of the real - ** indices to follow */ - Index pFirst; /* First of real indices on the table */ - sPk = new Index(); // memset( &sPk, 0, sizeof( Index ) ); - sPk.aSortOrder = new byte[1]; - sPk.azColl = new string[1]; - sPk.azColl[0] = ""; - sPk.nColumn = 1; - sPk.aiColumn = new int[1]; - sPk.aiColumn[0] = aiColumnPk; - sPk.aiRowEst = aiRowEstPk; - sPk.onError = OE_Replace; - sPk.pTable = pSrc.pTab; - aiRowEstPk[0] = (int)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; - wsFlagMask = ~( - WHERE_COLUMN_IN | WHERE_COLUMN_EQ | WHERE_COLUMN_NULL | WHERE_COLUMN_RANGE - ); - eqTermMask = WO_EQ | WO_IN; - pIdx = null; - } + if ( pSrc.pIndex != null ) + { + /* An INDEXED BY clause specifies a particular index to use */ + pIdx = pProbe = pSrc.pIndex; + wsFlagMask = ~( WHERE_ROWID_EQ | WHERE_ROWID_RANGE ); + eqTermMask = idxEqTermMask; + } + else + { + /* There is no INDEXED BY clause. Create a fake Index object in local + ** variable sPk to represent the rowid primary key index. Make this + ** fake index the first in a chain of Index objects with all of the real + ** indices to follow */ + Index pFirst; /* First of real indices on the table */ + sPk = new Index(); // memset( &sPk, 0, sizeof( Index ) ); + sPk.aSortOrder = new byte[1]; + sPk.azColl = new string[1]; + sPk.azColl[0] = ""; + sPk.nColumn = 1; + sPk.aiColumn = new int[1]; + sPk.aiColumn[0] = aiColumnPk; + sPk.aiRowEst = aiRowEstPk; + sPk.onError = OE_Replace; + sPk.pTable = pSrc.pTab; + aiRowEstPk[0] = (int)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; + wsFlagMask = ~( + WHERE_COLUMN_IN | WHERE_COLUMN_EQ | WHERE_COLUMN_NULL | WHERE_COLUMN_RANGE + ); + eqTermMask = WO_EQ | WO_IN; + pIdx = null; + } - /* Loop over all indices looking for the best one to use - */ - for (; pProbe != null; pIdx = pProbe = pProbe.pNext) { - int[] aiRowEst = pProbe.aiRowEst; - double cost; /* Cost of using pProbe */ - double nRow; /* Estimated number of rows in result set */ - double log10N = 0; /* base-10 logarithm of nRow (inexact) */ - int rev = 0; /* True to scan in reverse order */ - int wsFlags = 0; - Bitmask used = 0; - - /* The following variables are populated based on the properties of - ** index being evaluated. They are then used to determine the expected - ** cost and number of rows returned. - ** - ** nEq: - ** Number of equality terms that can be implemented using the index. - ** In other words, the number of initial fields in the index that - ** are used in == or IN or NOT NULL constraints of the WHERE clause. - ** - ** nInMul: - ** The "in-multiplier". This is an estimate of how many seek operations - ** SQLite must perform on the index in question. For example, if the - ** WHERE clause is: - ** - ** WHERE a IN (1, 2, 3) AND b IN (4, 5, 6) - ** - ** SQLite must perform 9 lookups on an index on (a, b), so nInMul is - ** set to 9. Given the same schema and either of the following WHERE - ** clauses: - ** - ** WHERE a = 1 - ** WHERE a >= 2 - ** - ** nInMul is set to 1. - ** - ** If there exists a WHERE term of the form "x IN (SELECT ...)", then - ** the sub-select is assumed to return 25 rows for the purposes of - ** determining nInMul. - ** - ** bInEst: - ** Set to true if there was at least one "x IN (SELECT ...)" term used - ** in determining the value of nInMul. Note that the RHS of the - ** IN operator must be a SELECT, not a value list, for this variable - ** to be true. - ** - ** estBound: - ** An estimate on the amount of the table that must be searched. A - ** value of 100 means the entire table is searched. Range constraints - ** might reduce this to a value less than 100 to indicate that only - ** a fraction of the table needs searching. In the absence of - ** sqlite_stat2 ANALYZE data, a single inequality reduces the search - ** space to 1/4rd its original size. So an x>? constraint reduces - ** estBound to 25. Two constraints (x>? AND x= 2 + ** + ** nInMul is set to 1. + ** + ** If there exists a WHERE term of the form "x IN (SELECT ...)", then + ** the sub-select is assumed to return 25 rows for the purposes of + ** determining nInMul. + ** + ** bInEst: + ** Set to true if there was at least one "x IN (SELECT ...)" term used + ** in determining the value of nInMul. Note that the RHS of the + ** IN operator must be a SELECT, not a value list, for this variable + ** to be true. + ** + ** estBound: + ** An estimate on the amount of the table that must be searched. A + ** value of 100 means the entire table is searched. Range constraints + ** might reduce this to a value less than 100 to indicate that only + ** a fraction of the table needs searching. In the absence of + ** sqlite_stat2 ANALYZE data, a single inequality reduces the search + ** space to 1/4rd its original size. So an x>? constraint reduces + ** estBound to 25. Two constraints (x>? AND x aiRowEst[0]) { - nRow = aiRowEst[0] / 2; - nInMul = (int)(nRow / aiRowEst[nEq]); - } + /* + ** Estimate the number of rows of output. For an "x IN (SELECT...)" + ** constraint, do not let the estimate exceed half the rows in the table. + */ + nRow = (double)( aiRowEst[nEq] * nInMul ); + if ( bInEst != 0 && nRow * 2 > aiRowEst[0] ) + { + nRow = aiRowEst[0] / 2; + nInMul = (int)( nRow / aiRowEst[nEq] ); + } #if SQLITE_ENABLE_STAT2 /* If the constraint is of the form x=VALUE and histogram @@ -3237,140 +3487,162 @@ ref WhereCost pCost /* Lowest cost query plan */ } #endif //* SQLITE_ENABLE_STAT2 */ - /* Adjust the number of output rows and downward to reflect rows - ** that are excluded by range constraints. + /* Adjust the number of output rows and downward to reflect rows + ** that are excluded by range constraints. + */ + nRow = ( nRow * (double)estBound ) / (double)100; + if ( nRow < 1 ) + nRow = 1; + + /* Experiments run on real SQLite databases show that the time needed + ** to do a binary search to locate a row in a table or index is roughly + ** log10(N) times the time to move from one row to the next row within + ** a table or index. The actual times can vary, with the size of + ** records being an important factor. Both moves and searches are + ** slower with larger records, presumably because fewer records fit + ** on one page and hence more pages have to be fetched. + ** + ** The ANALYZE command and the sqlite_stat1 and sqlite_stat2 tables do + ** not give us data on the relative sizes of table and index records. + ** So this computation assumes table records are about twice as big + ** as index records + */ + if ( ( wsFlags & WHERE_NOT_FULLSCAN ) == 0 ) + { + /* The cost of a full table scan is a number of move operations equal + ** to the number of rows in the table. + ** + ** We add an additional 4x penalty to full table scans. This causes + ** the cost function to err on the side of choosing an index over + ** choosing a full scan. This 4x full-scan penalty is an arguable + ** decision and one which we expect to revisit in the future. But + ** it seems to be working well enough at the moment. + */ + cost = aiRowEst[0] * 4; + } + else + { + log10N = estLog( aiRowEst[0] ); + cost = nRow; + if ( pIdx != null ) + { + if ( bLookup != 0 ) + { + /* For an index lookup followed by a table lookup: + ** nInMul index searches to find the start of each index range + ** + nRow steps through the index + ** + nRow table searches to lookup the table entry using the rowid + */ + cost += ( nInMul + nRow ) * log10N; + } + else + { + /* For a covering index: + ** nInMul index searches to find the initial entry + ** + nRow steps through the index + */ + cost += nInMul * log10N; + } + } + else + { + /* For a rowid primary key lookup: + ** nInMult table searches to find the initial entry for each range + ** + nRow steps through the table */ - nRow = (nRow * (double)estBound) / (double)100; - if (nRow < 1) - nRow = 1; - - /* Experiments run on real SQLite databases show that the time needed - ** to do a binary search to locate a row in a table or index is roughly - ** log10(N) times the time to move from one row to the next row within - ** a table or index. The actual times can vary, with the size of - ** records being an important factor. Both moves and searches are - ** slower with larger records, presumably because fewer records fit - ** on one page and hence more pages have to be fetched. - ** - ** The ANALYZE command and the sqlite_stat1 and sqlite_stat2 tables do - ** not give us data on the relative sizes of table and index records. - ** So this computation assumes table records are about twice as big - ** as index records - */ - if ((wsFlags & WHERE_NOT_FULLSCAN) == 0) { - /* The cost of a full table scan is a number of move operations equal - ** to the number of rows in the table. - ** - ** We add an additional 4x penalty to full table scans. This causes - ** the cost function to err on the side of choosing an index over - ** choosing a full scan. This 4x full-scan penalty is an arguable - ** decision and one which we expect to revisit in the future. But - ** it seems to be working well enough at the moment. - */ - cost = aiRowEst[0] * 4; - } else { - log10N = estLog(aiRowEst[0]); - cost = nRow; - if (pIdx != null) { - if (bLookup != 0) { - /* For an index lookup followed by a table lookup: - ** nInMul index searches to find the start of each index range - ** + nRow steps through the index - ** + nRow table searches to lookup the table entry using the rowid - */ - cost += (nInMul + nRow) * log10N; - } else { - /* For a covering index: - ** nInMul index searches to find the initial entry - ** + nRow steps through the index - */ - cost += nInMul * log10N; - } - } else { - /* For a rowid primary key lookup: - ** nInMult table searches to find the initial entry for each range - ** + nRow steps through the table - */ - cost += nInMul * log10N; - } - } + cost += nInMul * log10N; + } + } - /* Add in the estimated cost of sorting the result. Actual experimental - ** measurements of sorting performance in SQLite show that sorting time - ** adds C*N*log10(N) to the cost, where N is the number of rows to be - ** sorted and C is a factor between 1.95 and 4.3. We will split the - ** difference and select C of 3.0. - */ - if (bSort != 0) { - cost += nRow * estLog(nRow) * 3; - } + /* Add in the estimated cost of sorting the result. Actual experimental + ** measurements of sorting performance in SQLite show that sorting time + ** adds C*N*log10(N) to the cost, where N is the number of rows to be + ** sorted and C is a factor between 1.95 and 4.3. We will split the + ** difference and select C of 3.0. + */ + if ( bSort != 0 ) + { + cost += nRow * estLog( nRow ) * 3; + } - /**** Cost of using this index has now been computed ****/ - - /* If there are additional constraints on this table that cannot - ** be used with the current index, but which might lower the number - ** of output rows, adjust the nRow value accordingly. This only - ** matters if the current index is the least costly, so do not bother - ** with this step if we already know this index will not be chosen. - ** Also, never reduce the output row count below 2 using this step. - ** - ** It is critical that the notValid mask be used here instead of - ** the notReady mask. When computing an "optimal" index, the notReady - ** mask will only have one bit set - the bit for the current table. - ** The notValid mask, on the other hand, always has all bits set for - ** tables that are not in outer loops. If notReady is used here instead - ** of notValid, then a optimal index that depends on inner joins loops - ** might be selected even when there exists an optimal index that has - ** no such dependency. - */ - if (nRow > 2 && cost <= pCost.rCost) { - //int k; /* Loop counter */ - int nSkipEq = nEq; /* Number of == constraints to skip */ - int nSkipRange = nBound; /* Number of < constraints to skip */ - Bitmask thisTab; /* Bitmap for pSrc */ - - thisTab = getMask(pWC.pMaskSet, iCur); - for (int ipTerm = 0, k = pWC.nTerm; nRow > 2 && k != 0; k--, ipTerm++)//pTerm++) - { - pTerm = pWC.a[ipTerm]; - if ((pTerm.wtFlags & TERM_VIRTUAL) != 0) - continue; - if ((pTerm.prereqAll & notValid) != thisTab) - continue; - if ((pTerm.eOperator & (WO_EQ | WO_IN | WO_ISNULL)) != 0) { - if (nSkipEq != 0) { - /* Ignore the first nEq equality matches since the index - ** has already accounted for these */ - nSkipEq--; - } else { - /* Assume each additional equality match reduces the result - ** set size by a factor of 10 */ - nRow /= 10; - } - } else if ((pTerm.eOperator & (WO_LT | WO_LE | WO_GT | WO_GE)) != 0) { - if (nSkipRange != 0) { - /* Ignore the first nSkipRange range constraints since the index - ** has already accounted for these */ - nSkipRange--; - } else { - /* Assume each additional range constraint reduces the result - ** set size by a factor of 3. Indexed range constraints reduce - ** the search space by a larger factor: 4. We make indexed range - ** more selective intentionally because of the subjective - ** observation that indexed range constraints really are more - ** selective in practice, on average. */ - nRow /= 3; - } - } else if (pTerm.eOperator != WO_NOOP) { - /* Any other expression lowers the output row count by half */ - nRow /= 2; - } - } - if (nRow < 2) - nRow = 2; - } + /**** Cost of using this index has now been computed ****/ -#if (SQLITE_TEST) && (SQLITE_DEBUG) + /* If there are additional constraints on this table that cannot + ** be used with the current index, but which might lower the number + ** of output rows, adjust the nRow value accordingly. This only + ** matters if the current index is the least costly, so do not bother + ** with this step if we already know this index will not be chosen. + ** Also, never reduce the output row count below 2 using this step. + ** + ** It is critical that the notValid mask be used here instead of + ** the notReady mask. When computing an "optimal" index, the notReady + ** mask will only have one bit set - the bit for the current table. + ** The notValid mask, on the other hand, always has all bits set for + ** tables that are not in outer loops. If notReady is used here instead + ** of notValid, then a optimal index that depends on inner joins loops + ** might be selected even when there exists an optimal index that has + ** no such dependency. + */ + if ( nRow > 2 && cost <= pCost.rCost ) + { + //int k; /* Loop counter */ + int nSkipEq = nEq; /* Number of == constraints to skip */ + int nSkipRange = nBound; /* Number of < constraints to skip */ + Bitmask thisTab; /* Bitmap for pSrc */ + + thisTab = getMask( pWC.pMaskSet, iCur ); + for ( int ipTerm = 0, k = pWC.nTerm; nRow > 2 && k != 0; k--, ipTerm++ )//pTerm++) + { + pTerm = pWC.a[ipTerm]; + if ( ( pTerm.wtFlags & TERM_VIRTUAL ) != 0 ) + continue; + if ( ( pTerm.prereqAll & notValid ) != thisTab ) + continue; + if ( ( pTerm.eOperator & ( WO_EQ | WO_IN | WO_ISNULL ) ) != 0 ) + { + if ( nSkipEq != 0 ) + { + /* Ignore the first nEq equality matches since the index + ** has already accounted for these */ + nSkipEq--; + } + else + { + /* Assume each additional equality match reduces the result + ** set size by a factor of 10 */ + nRow /= 10; + } + } + else if ( ( pTerm.eOperator & ( WO_LT | WO_LE | WO_GT | WO_GE ) ) != 0 ) + { + if ( nSkipRange != 0 ) + { + /* Ignore the first nSkipRange range constraints since the index + ** has already accounted for these */ + nSkipRange--; + } + else + { + /* Assume each additional range constraint reduces the result + ** set size by a factor of 3. Indexed range constraints reduce + ** the search space by a larger factor: 4. We make indexed range + ** more selective intentionally because of the subjective + ** observation that indexed range constraints really are more + ** selective in practice, on average. */ + nRow /= 3; + } + } + else if ( pTerm.eOperator != WO_NOOP ) + { + /* Any other expression lowers the output row count by half */ + nRow /= 2; + } + } + if ( nRow < 2 ) + nRow = 2; + } + +#if (SQLITE_TEST) && (SQLITE_DEBUG) WHERETRACE( "%s(%s): nEq=%d nInMul=%d estBound=%d bSort=%d bLookup=%d wsFlags=0x%x\n" + " notReady=0x%llx log10N=%.1f nRow=%.1f cost=%.1f used=0x%llx\n", @@ -3379,749 +3651,836 @@ ref WhereCost pCost /* Lowest cost query plan */ notReady, log10N, cost, used ); #endif - /* If this index is the best we have seen so far, then record this - ** index and its cost in the pCost structure. - */ - if ((null == pIdx || wsFlags != 0) - && (cost < pCost.rCost || (cost <= pCost.rCost && nRow < pCost.plan.nRow)) - ) { - pCost.rCost = cost; - pCost.used = used; - pCost.plan.nRow = nRow; - pCost.plan.wsFlags = (uint)(wsFlags & wsFlagMask); - pCost.plan.nEq = (uint)nEq; - pCost.plan.u.pIdx = pIdx; - } + /* If this index is the best we have seen so far, then record this +** index and its cost in the pCost structure. +*/ + if ( ( null == pIdx || wsFlags != 0 ) + && ( cost < pCost.rCost || ( cost <= pCost.rCost && nRow < pCost.plan.nRow ) ) + ) + { + pCost.rCost = cost; + pCost.used = used; + pCost.plan.nRow = nRow; + pCost.plan.wsFlags = (uint)( wsFlags & wsFlagMask ); + pCost.plan.nEq = (uint)nEq; + pCost.plan.u.pIdx = pIdx; + } - /* If there was an INDEXED BY clause, then only that one index is - ** considered. */ - if (pSrc.pIndex != null) - break; + /* If there was an INDEXED BY clause, then only that one index is + ** considered. */ + if ( pSrc.pIndex != null ) + break; - /* Reset masks for the next index in the loop */ - wsFlagMask = ~(WHERE_ROWID_EQ | WHERE_ROWID_RANGE); - eqTermMask = idxEqTermMask; - } + /* Reset masks for the next index in the loop */ + wsFlagMask = ~( WHERE_ROWID_EQ | WHERE_ROWID_RANGE ); + eqTermMask = idxEqTermMask; + } - /* If there is no ORDER BY clause and the SQLITE_ReverseOrder flag - ** is set, then reverse the order that the index will be scanned - ** in. This is used for application testing, to help find cases - ** where application behaviour depends on the (undefined) order that - ** SQLite outputs rows in in the absence of an ORDER BY clause. */ - if (null == pOrderBy && (pParse.db.flags & SQLITE_ReverseOrder) != 0) { - pCost.plan.wsFlags |= WHERE_REVERSE; - } + /* If there is no ORDER BY clause and the SQLITE_ReverseOrder flag + ** is set, then reverse the order that the index will be scanned + ** in. This is used for application testing, to help find cases + ** where application behaviour depends on the (undefined) order that + ** SQLite outputs rows in in the absence of an ORDER BY clause. */ + if ( null == pOrderBy && ( pParse.db.flags & SQLITE_ReverseOrder ) != 0 ) + { + pCost.plan.wsFlags |= WHERE_REVERSE; + } - Debug.Assert(pOrderBy != null || (pCost.plan.wsFlags & WHERE_ORDERBY) == 0); - Debug.Assert(pCost.plan.u.pIdx == null || (pCost.plan.wsFlags & WHERE_ROWID_EQ) == 0); - Debug.Assert(pSrc.pIndex == null - || pCost.plan.u.pIdx == null - || pCost.plan.u.pIdx == pSrc.pIndex - ); + Debug.Assert( pOrderBy != null || ( pCost.plan.wsFlags & WHERE_ORDERBY ) == 0 ); + Debug.Assert( pCost.plan.u.pIdx == null || ( pCost.plan.wsFlags & WHERE_ROWID_EQ ) == 0 ); + Debug.Assert( pSrc.pIndex == null + || pCost.plan.u.pIdx == null + || pCost.plan.u.pIdx == pSrc.pIndex + ); -#if (SQLITE_TEST) && (SQLITE_DEBUG) +#if (SQLITE_TEST) && (SQLITE_DEBUG) WHERETRACE( "best index is: %s\n", ( ( pCost.plan.wsFlags & WHERE_NOT_FULLSCAN ) == 0 ? "none" : pCost.plan.u.pIdx != null ? pCost.plan.u.pIdx.zName : "ipk" ) ); #endif - bestOrClauseIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, pCost); - bestAutomaticIndex(pParse, pWC, pSrc, notReady, pCost); - pCost.plan.wsFlags |= (u32)eqTermMask; - } + bestOrClauseIndex( pParse, pWC, pSrc, notReady, notValid, pOrderBy, pCost ); + bestAutomaticIndex( pParse, pWC, pSrc, notReady, pCost ); + pCost.plan.wsFlags |= (u32)eqTermMask; + } - /* - ** Find the query plan for accessing table pSrc.pTab. Write the - ** best query plan and its cost into the WhereCost object supplied - ** as the last parameter. This function may calculate the cost of - ** both real and virtual table scans. - */ - static void bestIndex( - Parse pParse, /* The parsing context */ - WhereClause pWC, /* The WHERE clause */ - SrcList_item pSrc, /* The FROM clause term to search */ - Bitmask notReady, /* Mask of cursors not available for indexing */ - Bitmask notValid, /* Cursors not available for any purpose */ - ExprList pOrderBy, /* The ORDER BY clause */ - ref WhereCost pCost /* Lowest cost query plan */ - ) { + /* + ** Find the query plan for accessing table pSrc.pTab. Write the + ** best query plan and its cost into the WhereCost object supplied + ** as the last parameter. This function may calculate the cost of + ** both real and virtual table scans. + */ + static void bestIndex( + Parse pParse, /* The parsing context */ + WhereClause pWC, /* The WHERE clause */ + SrcList_item pSrc, /* The FROM clause term to search */ + Bitmask notReady, /* Mask of cursors not available for indexing */ + Bitmask notValid, /* Cursors not available for any purpose */ + ExprList pOrderBy, /* The ORDER BY clause */ + ref WhereCost pCost /* Lowest cost query plan */ + ) + { #if !SQLITE_OMIT_VIRTUALTABLE - if (IsVirtual(pSrc.pTab)) { - sqlite3_index_info p = null; - bestVirtualIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, ref pCost, ref p); - if (p.needToFreeIdxStr != 0) { - //sqlite3_free(ref p.idxStr); - } - sqlite3DbFree(pParse.db, ref p); - } else -#endif - { - bestBtreeIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, ref pCost); - } + if ( IsVirtual( pSrc.pTab ) ) + { + sqlite3_index_info p = null; + bestVirtualIndex( pParse, pWC, pSrc, notReady, notValid, pOrderBy, ref pCost, ref p ); + if ( p.needToFreeIdxStr != 0 ) + { + //sqlite3_free(ref p.idxStr); } + sqlite3DbFree( pParse.db, ref p ); + } + else +#endif + { + bestBtreeIndex( pParse, pWC, pSrc, notReady, notValid, pOrderBy, ref pCost ); + } + } - /* - ** Disable a term in the WHERE clause. Except, do not disable the term - ** if it controls a LEFT OUTER JOIN and it did not originate in the ON - ** or USING clause of that join. - ** - ** Consider the term t2.z='ok' in the following queries: - ** - ** (1) SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x WHERE t2.z='ok' - ** (2) SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x AND t2.z='ok' - ** (3) SELECT * FROM t1, t2 WHERE t1.a=t2.x AND t2.z='ok' - ** - ** The t2.z='ok' is disabled in the in (2) because it originates - ** in the ON clause. The term is disabled in (3) because it is not part - ** of a LEFT OUTER JOIN. In (1), the term is not disabled. - ** - ** IMPLEMENTATION-OF: R-24597-58655 No tests are done for terms that are - ** completely satisfied by indices. - ** - ** Disabling a term causes that term to not be tested in the inner loop - ** of the join. Disabling is an optimization. When terms are satisfied - ** by indices, we disable them to prevent redundant tests in the inner - ** loop. We would get the correct results if nothing were ever disabled, - ** but joins might run a little slower. The trick is to disable as much - ** as we can without disabling too much. If we disabled in (1), we'd get - ** the wrong answer. See ticket #813. - */ - static void disableTerm(WhereLevel pLevel, WhereTerm pTerm) { - if (pTerm != null - && (pTerm.wtFlags & TERM_CODED) == 0 - && (pLevel.iLeftJoin == 0 || ExprHasProperty(pTerm.pExpr, EP_FromJoin))) { - pTerm.wtFlags |= TERM_CODED; - if (pTerm.iParent >= 0) { - WhereTerm pOther = pTerm.pWC.a[pTerm.iParent]; - if ((--pOther.nChild) == 0) { - disableTerm(pLevel, pOther); - } - } - } + /* + ** Disable a term in the WHERE clause. Except, do not disable the term + ** if it controls a LEFT OUTER JOIN and it did not originate in the ON + ** or USING clause of that join. + ** + ** Consider the term t2.z='ok' in the following queries: + ** + ** (1) SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x WHERE t2.z='ok' + ** (2) SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x AND t2.z='ok' + ** (3) SELECT * FROM t1, t2 WHERE t1.a=t2.x AND t2.z='ok' + ** + ** The t2.z='ok' is disabled in the in (2) because it originates + ** in the ON clause. The term is disabled in (3) because it is not part + ** of a LEFT OUTER JOIN. In (1), the term is not disabled. + ** + ** IMPLEMENTATION-OF: R-24597-58655 No tests are done for terms that are + ** completely satisfied by indices. + ** + ** Disabling a term causes that term to not be tested in the inner loop + ** of the join. Disabling is an optimization. When terms are satisfied + ** by indices, we disable them to prevent redundant tests in the inner + ** loop. We would get the correct results if nothing were ever disabled, + ** but joins might run a little slower. The trick is to disable as much + ** as we can without disabling too much. If we disabled in (1), we'd get + ** the wrong answer. See ticket #813. + */ + static void disableTerm( WhereLevel pLevel, WhereTerm pTerm ) + { + if ( pTerm != null + && ( pTerm.wtFlags & TERM_CODED ) == 0 + && ( pLevel.iLeftJoin == 0 || ExprHasProperty( pTerm.pExpr, EP_FromJoin ) ) ) + { + pTerm.wtFlags |= TERM_CODED; + if ( pTerm.iParent >= 0 ) + { + WhereTerm pOther = pTerm.pWC.a[pTerm.iParent]; + if ( ( --pOther.nChild ) == 0 ) + { + disableTerm( pLevel, pOther ); + } } + } + } - /* - ** Code an OP_Affinity opcode to apply the column affinity string zAff - ** to the n registers starting at base. - ** - ** As an optimization, SQLITE_AFF_NONE entries (which are no-ops) at the - ** beginning and end of zAff are ignored. If all entries in zAff are - ** SQLITE_AFF_NONE, then no code gets generated. - ** - ** This routine makes its own copy of zAff so that the caller is free - ** to modify zAff after this routine returns. - */ - static void codeApplyAffinity(Parse pParse, int _base, int n, string zAff) { - Vdbe v = pParse.pVdbe; - //if (zAff == 0) - //{ - // Debug.Assert(pParse.db.mallocFailed); - // return; - //} - Debug.Assert(v != null); - /* Adjust base and n to skip over SQLITE_AFF_NONE entries at the beginning - ** and end of the affinity string. - */ - while (n > 0 && zAff[0] == SQLITE_AFF_NONE) { - n--; - _base++; - zAff = zAff.Substring(1);// zAff++; - } - while (n > 1 && zAff[n - 1] == SQLITE_AFF_NONE) { - n--; - } + /* + ** Code an OP_Affinity opcode to apply the column affinity string zAff + ** to the n registers starting at base. + ** + ** As an optimization, SQLITE_AFF_NONE entries (which are no-ops) at the + ** beginning and end of zAff are ignored. If all entries in zAff are + ** SQLITE_AFF_NONE, then no code gets generated. + ** + ** This routine makes its own copy of zAff so that the caller is free + ** to modify zAff after this routine returns. + */ + static void codeApplyAffinity( Parse pParse, int _base, int n, string zAff ) + { + Vdbe v = pParse.pVdbe; + //if (zAff == 0) + //{ + // Debug.Assert(pParse.db.mallocFailed); + // return; + //} + Debug.Assert( v != null ); + /* Adjust base and n to skip over SQLITE_AFF_NONE entries at the beginning + ** and end of the affinity string. + */ + while ( n > 0 && zAff[0] == SQLITE_AFF_NONE ) + { + n--; + _base++; + zAff = zAff.Substring( 1 );// zAff++; + } + while ( n > 1 && zAff[n - 1] == SQLITE_AFF_NONE ) + { + n--; + } - /* Code the OP_Affinity opcode if there is anything left to do. */ - if (n > 0) { - sqlite3VdbeAddOp2(v, OP_Affinity, _base, n); - sqlite3VdbeChangeP4(v, -1, zAff, n); - sqlite3ExprCacheAffinityChange(pParse, _base, n); - } - } + /* Code the OP_Affinity opcode if there is anything left to do. */ + if ( n > 0 ) + { + sqlite3VdbeAddOp2( v, OP_Affinity, _base, n ); + sqlite3VdbeChangeP4( v, -1, zAff, n ); + sqlite3ExprCacheAffinityChange( pParse, _base, n ); + } + } - /* - ** Generate code for a single equality term of the WHERE clause. An equality - ** term can be either X=expr or X IN (...). pTerm is the term to be - ** coded. - ** - ** The current value for the constraint is left in register iReg. - ** - ** For a constraint of the form X=expr, the expression is evaluated and its - ** result is left on the stack. For constraints of the form X IN (...) - ** this routine sets up a loop that will iterate over all values of X. - */ - static int codeEqualityTerm( - Parse pParse, /* The parsing context */ - WhereTerm pTerm, /* The term of the WHERE clause to be coded */ - WhereLevel pLevel, /* When level of the FROM clause we are working on */ - int iTarget /* Attempt to leave results in this register */ - ) { - Expr pX = pTerm.pExpr; - Vdbe v = pParse.pVdbe; - int iReg; /* Register holding results */ - - Debug.Assert(iTarget > 0); - if (pX.op == TK_EQ) { - iReg = sqlite3ExprCodeTarget(pParse, pX.pRight, iTarget); - } else if (pX.op == TK_ISNULL) { - iReg = iTarget; - sqlite3VdbeAddOp2(v, OP_Null, 0, iReg); -#if !SQLITE_OMIT_SUBQUERY - } else { - int eType; - int iTab; - InLoop pIn; - - Debug.Assert(pX.op == TK_IN); - iReg = iTarget; - int iDummy = -1; - eType = sqlite3FindInIndex(pParse, pX, ref iDummy); - iTab = pX.iTable; - sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0); - Debug.Assert((pLevel.plan.wsFlags & WHERE_IN_ABLE) != 0); - if (pLevel.u._in.nIn == 0) { - pLevel.addrNxt = sqlite3VdbeMakeLabel(v); - } - pLevel.u._in.nIn++; - if (pLevel.u._in.aInLoop == null) - pLevel.u._in.aInLoop = new InLoop[pLevel.u._in.nIn]; - else - Array.Resize(ref pLevel.u._in.aInLoop, pLevel.u._in.nIn); - //sqlite3DbReallocOrFree(pParse.db, pLevel.u._in.aInLoop, - // sizeof(pLevel.u._in.aInLoop[0])*pLevel.u._in.nIn); - //pIn = pLevel.u._in.aInLoop; - if (pLevel.u._in.aInLoop != null)//(pIn ) - { - pLevel.u._in.aInLoop[pLevel.u._in.nIn - 1] = new InLoop(); - pIn = pLevel.u._in.aInLoop[pLevel.u._in.nIn - 1];//pIn++ - pIn.iCur = iTab; - if (eType == IN_INDEX_ROWID) { - pIn.addrInTop = sqlite3VdbeAddOp2(v, OP_Rowid, iTab, iReg); - } else { - pIn.addrInTop = sqlite3VdbeAddOp3(v, OP_Column, iTab, 0, iReg); - } - sqlite3VdbeAddOp1(v, OP_IsNull, iReg); - } else { - pLevel.u._in.nIn = 0; - } -#endif - } - disableTerm(pLevel, pTerm); - return iReg; + /* + ** Generate code for a single equality term of the WHERE clause. An equality + ** term can be either X=expr or X IN (...). pTerm is the term to be + ** coded. + ** + ** The current value for the constraint is left in register iReg. + ** + ** For a constraint of the form X=expr, the expression is evaluated and its + ** result is left on the stack. For constraints of the form X IN (...) + ** this routine sets up a loop that will iterate over all values of X. + */ + static int codeEqualityTerm( + Parse pParse, /* The parsing context */ + WhereTerm pTerm, /* The term of the WHERE clause to be coded */ + WhereLevel pLevel, /* When level of the FROM clause we are working on */ + int iTarget /* Attempt to leave results in this register */ + ) + { + Expr pX = pTerm.pExpr; + Vdbe v = pParse.pVdbe; + int iReg; /* Register holding results */ + + Debug.Assert( iTarget > 0 ); + if ( pX.op == TK_EQ ) + { + iReg = sqlite3ExprCodeTarget( pParse, pX.pRight, iTarget ); + } + else if ( pX.op == TK_ISNULL ) + { + iReg = iTarget; + sqlite3VdbeAddOp2( v, OP_Null, 0, iReg ); +#if !SQLITE_OMIT_SUBQUERY + } + else + { + int eType; + int iTab; + InLoop pIn; + + Debug.Assert( pX.op == TK_IN ); + iReg = iTarget; + int iDummy = -1; + eType = sqlite3FindInIndex( pParse, pX, ref iDummy ); + iTab = pX.iTable; + sqlite3VdbeAddOp2( v, OP_Rewind, iTab, 0 ); + Debug.Assert( ( pLevel.plan.wsFlags & WHERE_IN_ABLE ) != 0 ); + if ( pLevel.u._in.nIn == 0 ) + { + pLevel.addrNxt = sqlite3VdbeMakeLabel( v ); + } + pLevel.u._in.nIn++; + if ( pLevel.u._in.aInLoop == null ) + pLevel.u._in.aInLoop = new InLoop[pLevel.u._in.nIn]; + else + Array.Resize( ref pLevel.u._in.aInLoop, pLevel.u._in.nIn ); + //sqlite3DbReallocOrFree(pParse.db, pLevel.u._in.aInLoop, + // sizeof(pLevel.u._in.aInLoop[0])*pLevel.u._in.nIn); + //pIn = pLevel.u._in.aInLoop; + if ( pLevel.u._in.aInLoop != null )//(pIn ) + { + pLevel.u._in.aInLoop[pLevel.u._in.nIn - 1] = new InLoop(); + pIn = pLevel.u._in.aInLoop[pLevel.u._in.nIn - 1];//pIn++ + pIn.iCur = iTab; + if ( eType == IN_INDEX_ROWID ) + { + pIn.addrInTop = sqlite3VdbeAddOp2( v, OP_Rowid, iTab, iReg ); + } + else + { + pIn.addrInTop = sqlite3VdbeAddOp3( v, OP_Column, iTab, 0, iReg ); + } + sqlite3VdbeAddOp1( v, OP_IsNull, iReg ); + } + else + { + pLevel.u._in.nIn = 0; } +#endif + } + disableTerm( pLevel, pTerm ); + return iReg; + } - /* - ** Generate code for a single equality term of the WHERE clause. An equality - ** term can be either X=expr or X IN (...). pTerm is the term to be - ** coded. - ** - ** For example, consider table t1(a,b,c,d,e,f) with index i1(a,b,c). - ** Suppose the WHERE clause is this: a==5 AND b IN (1,2,3) AND c>5 AND c<10 - ** The index has as many as three equality constraints, but in this - ** example, the third "c" value is an inequality. So only two - ** constraints are coded. This routine will generate code to evaluate - ** a==5 and b IN (1,2,3). The current values for a and b will be stored - ** in consecutive registers and the index of the first register is returned. - ** - ** In the example above nEq==2. But this subroutine works for any value - ** of nEq including 0. If nEq==null, this routine is nearly a no-op. - ** The only thing it does is allocate the pLevel.iMem memory cell and - ** compute the affinity string. - ** - ** This routine always allocates at least one memory cell and returns - ** the index of that memory cell. The code that - ** calls this routine will use that memory cell to store the termination - ** key value of the loop. If one or more IN operators appear, then - ** this routine allocates an additional nEq memory cells for internal - ** use. - ** - ** Before returning, *pzAff is set to point to a buffer containing a - ** copy of the column affinity string of the index allocated using - ** sqlite3DbMalloc(). Except, entries in the copy of the string associated - ** with equality constraints that use NONE affinity are set to - ** SQLITE_AFF_NONE. This is to deal with SQL such as the following: - ** - ** CREATE TABLE t1(a TEXT PRIMARY KEY, b); - ** SELECT ... FROM t1 AS t2, t1 WHERE t1.a = t2.b; - ** - ** In the example above, the index on t1(a) has TEXT affinity. But since - ** the right hand side of the equality constraint (t2.b) has NONE affinity, - ** no conversion should be attempted before using a t2.b value as part of - ** a key to search the index. Hence the first byte in the returned affinity - ** string in this example would be set to SQLITE_AFF_NONE. - */ - static int codeAllEqualityTerms( - Parse pParse, /* Parsing context */ - WhereLevel pLevel, /* Which nested loop of the FROM we are coding */ - WhereClause pWC, /* The WHERE clause */ - Bitmask notReady, /* Which parts of FROM have not yet been coded */ - int nExtraReg, /* Number of extra registers to allocate */ - out StringBuilder pzAff /* OUT: Set to point to affinity string */ - ) { - int nEq = (int)pLevel.plan.nEq; /* The number of == or IN constraints to code */ - Vdbe v = pParse.pVdbe; /* The vm under construction */ - Index pIdx; /* The index being used for this loop */ - int iCur = pLevel.iTabCur; /* The cursor of the table */ - WhereTerm pTerm; /* A single constraint term */ - int j; /* Loop counter */ - int regBase; /* Base register */ - int nReg; /* Number of registers to allocate */ - StringBuilder zAff; /* Affinity string to return */ - - /* This module is only called on query plans that use an index. */ - Debug.Assert((pLevel.plan.wsFlags & WHERE_INDEXED) != 0); - pIdx = pLevel.plan.u.pIdx; - - /* Figure out how many memory cells we will need then allocate them. - */ - regBase = pParse.nMem + 1; - nReg = (int)(pLevel.plan.nEq + nExtraReg); - pParse.nMem += nReg; + /* + ** Generate code for a single equality term of the WHERE clause. An equality + ** term can be either X=expr or X IN (...). pTerm is the term to be + ** coded. + ** + ** For example, consider table t1(a,b,c,d,e,f) with index i1(a,b,c). + ** Suppose the WHERE clause is this: a==5 AND b IN (1,2,3) AND c>5 AND c<10 + ** The index has as many as three equality constraints, but in this + ** example, the third "c" value is an inequality. So only two + ** constraints are coded. This routine will generate code to evaluate + ** a==5 and b IN (1,2,3). The current values for a and b will be stored + ** in consecutive registers and the index of the first register is returned. + ** + ** In the example above nEq==2. But this subroutine works for any value + ** of nEq including 0. If nEq==null, this routine is nearly a no-op. + ** The only thing it does is allocate the pLevel.iMem memory cell and + ** compute the affinity string. + ** + ** This routine always allocates at least one memory cell and returns + ** the index of that memory cell. The code that + ** calls this routine will use that memory cell to store the termination + ** key value of the loop. If one or more IN operators appear, then + ** this routine allocates an additional nEq memory cells for internal + ** use. + ** + ** Before returning, *pzAff is set to point to a buffer containing a + ** copy of the column affinity string of the index allocated using + ** sqlite3DbMalloc(). Except, entries in the copy of the string associated + ** with equality constraints that use NONE affinity are set to + ** SQLITE_AFF_NONE. This is to deal with SQL such as the following: + ** + ** CREATE TABLE t1(a TEXT PRIMARY KEY, b); + ** SELECT ... FROM t1 AS t2, t1 WHERE t1.a = t2.b; + ** + ** In the example above, the index on t1(a) has TEXT affinity. But since + ** the right hand side of the equality constraint (t2.b) has NONE affinity, + ** no conversion should be attempted before using a t2.b value as part of + ** a key to search the index. Hence the first byte in the returned affinity + ** string in this example would be set to SQLITE_AFF_NONE. + */ + static int codeAllEqualityTerms( + Parse pParse, /* Parsing context */ + WhereLevel pLevel, /* Which nested loop of the FROM we are coding */ + WhereClause pWC, /* The WHERE clause */ + Bitmask notReady, /* Which parts of FROM have not yet been coded */ + int nExtraReg, /* Number of extra registers to allocate */ + out StringBuilder pzAff /* OUT: Set to point to affinity string */ + ) + { + int nEq = (int)pLevel.plan.nEq; /* The number of == or IN constraints to code */ + Vdbe v = pParse.pVdbe; /* The vm under construction */ + Index pIdx; /* The index being used for this loop */ + int iCur = pLevel.iTabCur; /* The cursor of the table */ + WhereTerm pTerm; /* A single constraint term */ + int j; /* Loop counter */ + int regBase; /* Base register */ + int nReg; /* Number of registers to allocate */ + StringBuilder zAff; /* Affinity string to return */ + + /* This module is only called on query plans that use an index. */ + Debug.Assert( ( pLevel.plan.wsFlags & WHERE_INDEXED ) != 0 ); + pIdx = pLevel.plan.u.pIdx; + + /* Figure out how many memory cells we will need then allocate them. + */ + regBase = pParse.nMem + 1; + nReg = (int)( pLevel.plan.nEq + nExtraReg ); + pParse.nMem += nReg; - zAff = new StringBuilder(sqlite3IndexAffinityStr(v, pIdx));//sqlite3DbStrDup(pParse.db, sqlite3IndexAffinityStr(v, pIdx)); - //if( null==zAff ){ - // pParse.db.mallocFailed = 1; - //} + zAff = new StringBuilder( sqlite3IndexAffinityStr( v, pIdx ) );//sqlite3DbStrDup(pParse.db, sqlite3IndexAffinityStr(v, pIdx)); + //if( null==zAff ){ + // pParse.db.mallocFailed = 1; + //} - /* Evaluate the equality constraints - */ - Debug.Assert(pIdx.nColumn >= nEq); - for (j = 0; j < nEq; j++) { - int r1; - int k = pIdx.aiColumn[j]; - pTerm = findTerm(pWC, iCur, k, notReady, pLevel.plan.wsFlags, pIdx); - if (NEVER(pTerm == null)) - break; - /* The following true for indices with redundant columns. - ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */ - testcase((pTerm.wtFlags & TERM_CODED) != 0); - testcase(pTerm.wtFlags & TERM_VIRTUAL); /* EV: R-30575-11662 */ - r1 = codeEqualityTerm(pParse, pTerm, pLevel, regBase + j); - if (r1 != regBase + j) { - if (nReg == 1) { - sqlite3ReleaseTempReg(pParse, regBase); - regBase = r1; - } else { - sqlite3VdbeAddOp2(v, OP_SCopy, r1, regBase + j); - } - } - testcase(pTerm.eOperator & WO_ISNULL); - testcase(pTerm.eOperator & WO_IN); - if ((pTerm.eOperator & (WO_ISNULL | WO_IN)) == 0) { - Expr pRight = pTerm.pExpr.pRight; - sqlite3ExprCodeIsNullJump(v, pRight, regBase + j, pLevel.addrBrk); - if (zAff.Length > 0) { - if (sqlite3CompareAffinity(pRight, zAff[j]) == SQLITE_AFF_NONE) { - zAff[j] = SQLITE_AFF_NONE; - } - if ((sqlite3ExprNeedsNoAffinityChange(pRight, zAff[j])) != 0) { - zAff[j] = SQLITE_AFF_NONE; - } - } - } + /* Evaluate the equality constraints + */ + Debug.Assert( pIdx.nColumn >= nEq ); + for ( j = 0; j < nEq; j++ ) + { + int r1; + int k = pIdx.aiColumn[j]; + pTerm = findTerm( pWC, iCur, k, notReady, pLevel.plan.wsFlags, pIdx ); + if ( NEVER( pTerm == null ) ) + break; + /* The following true for indices with redundant columns. + ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */ + testcase( ( pTerm.wtFlags & TERM_CODED ) != 0 ); + testcase( pTerm.wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ + r1 = codeEqualityTerm( pParse, pTerm, pLevel, regBase + j ); + if ( r1 != regBase + j ) + { + if ( nReg == 1 ) + { + sqlite3ReleaseTempReg( pParse, regBase ); + regBase = r1; + } + else + { + sqlite3VdbeAddOp2( v, OP_SCopy, r1, regBase + j ); + } + } + testcase( pTerm.eOperator & WO_ISNULL ); + testcase( pTerm.eOperator & WO_IN ); + if ( ( pTerm.eOperator & ( WO_ISNULL | WO_IN ) ) == 0 ) + { + Expr pRight = pTerm.pExpr.pRight; + sqlite3ExprCodeIsNullJump( v, pRight, regBase + j, pLevel.addrBrk ); + if ( zAff.Length > 0 ) + { + if ( sqlite3CompareAffinity( pRight, zAff[j] ) == SQLITE_AFF_NONE ) + { + zAff[j] = SQLITE_AFF_NONE; + } + if ( ( sqlite3ExprNeedsNoAffinityChange( pRight, zAff[j] ) ) != 0 ) + { + zAff[j] = SQLITE_AFF_NONE; } - pzAff = zAff; - return regBase; + } } + } + pzAff = zAff; + return regBase; + } #if !SQLITE_OMIT_EXPLAIN - /* - ** This routine is a helper for explainIndexRange() below + /* +** This routine is a helper for explainIndexRange() below +** +** pStr holds the text of an expression that we are building up one term +** at a time. This routine adds a new term to the end of the expression. +** Terms are separated by AND so add the "AND" text for second and subsequent +** terms only. +*/ + static void explainAppendTerm( + StrAccum pStr, /* The text expression being built */ + int iTerm, /* Index of this term. First is zero */ + string zColumn, /* Name of the column */ + string zOp /* Name of the operator */ + ) + { + if ( iTerm != 0 ) + sqlite3StrAccumAppend( pStr, " AND ", 5 ); + sqlite3StrAccumAppend( pStr, zColumn, -1 ); + sqlite3StrAccumAppend( pStr, zOp, 1 ); + sqlite3StrAccumAppend( pStr, "?", 1 ); + } + + /* + ** Argument pLevel describes a strategy for scanning table pTab. This + ** function returns a pointer to a string buffer containing a description + ** of the subset of table rows scanned by the strategy in the form of an + ** SQL expression. Or, if all rows are scanned, NULL is returned. + ** + ** For example, if the query: + ** + ** SELECT * FROM t1 WHERE a=1 AND b>2; + ** + ** is run and there is an index on (a, b), then this function returns a + ** string similar to: + ** + ** "a=? AND b>?" ** - ** pStr holds the text of an expression that we are building up one term - ** at a time. This routine adds a new term to the end of the expression. - ** Terms are separated by AND so add the "AND" text for second and subsequent - ** terms only. + ** The returned pointer points to memory obtained from sqlite3DbMalloc(). + ** It is the responsibility of the caller to free the buffer when it is + ** no longer required. */ - static void explainAppendTerm( - StrAccum pStr, /* The text expression being built */ - int iTerm, /* Index of this term. First is zero */ - string zColumn, /* Name of the column */ - string zOp /* Name of the operator */ - ) { - if (iTerm != 0) - sqlite3StrAccumAppend(pStr, " AND ", 5); - sqlite3StrAccumAppend(pStr, zColumn, -1); - sqlite3StrAccumAppend(pStr, zOp, 1); - sqlite3StrAccumAppend(pStr, "?", 1); - } + static string explainIndexRange( sqlite3 db, WhereLevel pLevel, Table pTab ) + { + WherePlan pPlan = pLevel.plan; + Index pIndex = pPlan.u.pIdx; + uint nEq = pPlan.nEq; + int i, j; + Column[] aCol = pTab.aCol; + int[] aiColumn = pIndex.aiColumn; + StrAccum txt = new StrAccum( 100 ); + + if ( nEq == 0 && ( pPlan.wsFlags & ( WHERE_BTM_LIMIT | WHERE_TOP_LIMIT ) ) == 0 ) + { + return null; + } + sqlite3StrAccumInit( txt, null, 0, SQLITE_MAX_LENGTH ); + txt.db = db; + sqlite3StrAccumAppend( txt, " (", 2 ); + for ( i = 0; i < nEq; i++ ) + { + explainAppendTerm( txt, i, aCol[aiColumn[i]].zName, "=" ); + } - /* - ** Argument pLevel describes a strategy for scanning table pTab. This - ** function returns a pointer to a string buffer containing a description - ** of the subset of table rows scanned by the strategy in the form of an - ** SQL expression. Or, if all rows are scanned, NULL is returned. - ** - ** For example, if the query: - ** - ** SELECT * FROM t1 WHERE a=1 AND b>2; - ** - ** is run and there is an index on (a, b), then this function returns a - ** string similar to: - ** - ** "a=? AND b>?" - ** - ** The returned pointer points to memory obtained from sqlite3DbMalloc(). - ** It is the responsibility of the caller to free the buffer when it is - ** no longer required. - */ - static string explainIndexRange(sqlite3 db, WhereLevel pLevel, Table pTab) { - WherePlan pPlan = pLevel.plan; - Index pIndex = pPlan.u.pIdx; - uint nEq = pPlan.nEq; - int i, j; - Column[] aCol = pTab.aCol; - int[] aiColumn = pIndex.aiColumn; - StrAccum txt = new StrAccum(100); - - if (nEq == 0 && (pPlan.wsFlags & (WHERE_BTM_LIMIT | WHERE_TOP_LIMIT)) == 0) { - return null; - } - sqlite3StrAccumInit(txt, null, 0, SQLITE_MAX_LENGTH); - txt.db = db; - sqlite3StrAccumAppend(txt, " (", 2); - for (i = 0; i < nEq; i++) { - explainAppendTerm(txt, i, aCol[aiColumn[i]].zName, "="); - } + j = i; + if ( ( pPlan.wsFlags & WHERE_BTM_LIMIT ) != 0 ) + { + explainAppendTerm( txt, i++, aCol[aiColumn[j]].zName, ">" ); + } + if ( ( pPlan.wsFlags & WHERE_TOP_LIMIT ) != 0 ) + { + explainAppendTerm( txt, i, aCol[aiColumn[j]].zName, "<" ); + } + sqlite3StrAccumAppend( txt, ")", 1 ); + return sqlite3StrAccumFinish( txt ); + } - j = i; - if ((pPlan.wsFlags & WHERE_BTM_LIMIT) != 0) { - explainAppendTerm(txt, i++, aCol[aiColumn[j]].zName, ">"); - } - if ((pPlan.wsFlags & WHERE_TOP_LIMIT) != 0) { - explainAppendTerm(txt, i, aCol[aiColumn[j]].zName, "<"); - } - sqlite3StrAccumAppend(txt, ")", 1); - return sqlite3StrAccumFinish(txt); + /* + ** This function is a no-op unless currently processing an EXPLAIN QUERY PLAN + ** command. If the query being compiled is an EXPLAIN QUERY PLAN, a single + ** record is added to the output to describe the table scan strategy in + ** pLevel. + */ + static void explainOneScan( + Parse pParse, /* Parse context */ + SrcList pTabList, /* Table list this loop refers to */ + WhereLevel pLevel, /* Scan to write OP_Explain opcode for */ + int iLevel, /* Value for "level" column of output */ + int iFrom, /* Value for "from" column of output */ + u16 wctrlFlags /* Flags passed to sqlite3WhereBegin() */ + ) + { + if ( pParse.explain == 2 ) + { + u32 flags = pLevel.plan.wsFlags; + SrcList_item pItem = pTabList.a[pLevel.iFrom]; + Vdbe v = pParse.pVdbe; /* VM being constructed */ + sqlite3 db = pParse.db; /* Database handle */ + StringBuilder zMsg = new StringBuilder( 1000 ); /* Text to add to EQP output */ + sqlite3_int64 nRow; /* Expected number of rows visited by scan */ + int iId = pParse.iSelectId; /* Select id (left-most output column) */ + bool isSearch; /* True for a SEARCH. False for SCAN. */ + + if ( ( flags & WHERE_MULTI_OR ) != 0 || ( wctrlFlags & WHERE_ONETABLE_ONLY ) != 0 ) + return; + + isSearch = ( pLevel.plan.nEq > 0 ) + || ( flags & ( WHERE_BTM_LIMIT | WHERE_TOP_LIMIT ) ) != 0 + || ( wctrlFlags & ( WHERE_ORDERBY_MIN | WHERE_ORDERBY_MAX ) ) != 0; + + zMsg.Append( sqlite3MPrintf( db, "%s", isSearch ? "SEARCH" : "SCAN" ) ); + if ( pItem.pSelect != null ) + { + zMsg.Append( sqlite3MAppendf( db, null, " SUBQUERY %d", pItem.iSelectId ) ); + } + else + { + zMsg.Append( sqlite3MAppendf( db, null, " TABLE %s", pItem.zName ) ); } - /* - ** This function is a no-op unless currently processing an EXPLAIN QUERY PLAN - ** command. If the query being compiled is an EXPLAIN QUERY PLAN, a single - ** record is added to the output to describe the table scan strategy in - ** pLevel. - */ - static void explainOneScan( - Parse pParse, /* Parse context */ - SrcList pTabList, /* Table list this loop refers to */ - WhereLevel pLevel, /* Scan to write OP_Explain opcode for */ - int iLevel, /* Value for "level" column of output */ - int iFrom, /* Value for "from" column of output */ - u16 wctrlFlags /* Flags passed to sqlite3WhereBegin() */ - ) { - if (pParse.explain == 2) { - u32 flags = pLevel.plan.wsFlags; - SrcList_item pItem = pTabList.a[pLevel.iFrom]; - Vdbe v = pParse.pVdbe; /* VM being constructed */ - sqlite3 db = pParse.db; /* Database handle */ - StringBuilder zMsg = new StringBuilder(1000); /* Text to add to EQP output */ - sqlite3_int64 nRow; /* Expected number of rows visited by scan */ - int iId = pParse.iSelectId; /* Select id (left-most output column) */ - bool isSearch; /* True for a SEARCH. False for SCAN. */ - - if ((flags & WHERE_MULTI_OR) != 0 || (wctrlFlags & WHERE_ONETABLE_ONLY) != 0) - return; - - isSearch = (pLevel.plan.nEq > 0) - || (flags & (WHERE_BTM_LIMIT | WHERE_TOP_LIMIT)) != 0 - || (wctrlFlags & (WHERE_ORDERBY_MIN | WHERE_ORDERBY_MAX)) != 0; - - zMsg.Append(sqlite3MPrintf(db, "%s", isSearch ? "SEARCH" : "SCAN")); - if (pItem.pSelect != null) { - zMsg.Append(sqlite3MAppendf(db, null, " SUBQUERY %d", pItem.iSelectId)); - } else { - zMsg.Append(sqlite3MAppendf(db, null, " TABLE %s", pItem.zName)); - } + if ( pItem.zAlias != null ) + { + zMsg.Append( sqlite3MAppendf( db, null, " AS %s", pItem.zAlias ) ); + } + if ( ( flags & WHERE_INDEXED ) != 0 ) + { + string zWhere = explainIndexRange( db, pLevel, pItem.pTab ); + zMsg.Append( sqlite3MAppendf( db, null, " USING %s%sINDEX%s%s%s", + ( ( flags & WHERE_TEMP_INDEX ) != 0 ? "AUTOMATIC " : "" ), + ( ( flags & WHERE_IDX_ONLY ) != 0 ? "COVERING " : "" ), + ( ( flags & WHERE_TEMP_INDEX ) != 0 ? "" : " " ), + ( ( flags & WHERE_TEMP_INDEX ) != 0 ? "" : pLevel.plan.u.pIdx.zName ), + zWhere != null ? zWhere : "" + ) ); + sqlite3DbFree( db, ref zWhere ); + } + else if ( ( flags & ( WHERE_ROWID_EQ | WHERE_ROWID_RANGE ) ) != 0 ) + { + zMsg.Append( " USING INTEGER PRIMARY KEY" ); - if (pItem.zAlias != null) { - zMsg.Append(sqlite3MAppendf(db, null, " AS %s", pItem.zAlias)); - } - if ((flags & WHERE_INDEXED) != 0) { - string zWhere = explainIndexRange(db, pLevel, pItem.pTab); - zMsg.Append(sqlite3MAppendf(db, null, " USING %s%sINDEX%s%s%s", - ((flags & WHERE_TEMP_INDEX) != 0 ? "AUTOMATIC " : ""), - ((flags & WHERE_IDX_ONLY) != 0 ? "COVERING " : ""), - ((flags & WHERE_TEMP_INDEX) != 0 ? "" : " "), - ((flags & WHERE_TEMP_INDEX) != 0 ? "" : pLevel.plan.u.pIdx.zName), - zWhere != null ? zWhere : "" - )); - sqlite3DbFree(db, ref zWhere); - } else if ((flags & (WHERE_ROWID_EQ | WHERE_ROWID_RANGE)) != 0) { - zMsg.Append(" USING INTEGER PRIMARY KEY"); - - if ((flags & WHERE_ROWID_EQ) != 0) { - zMsg.Append(" (rowid=?)"); - } else if ((flags & WHERE_BOTH_LIMIT) == WHERE_BOTH_LIMIT) { - zMsg.Append(" (rowid>? AND rowid?)"); - } else if ((flags & WHERE_TOP_LIMIT) != 0) { - zMsg.Append(" (rowid? AND rowid?)" ); + } + else if ( ( flags & WHERE_TOP_LIMIT ) != 0 ) + { + zMsg.Append( " (rowid 0 && (pTabItem.jointype & JT_LEFT) != 0)// Check value of pTabItem[0].jointype - { - pLevel.iLeftJoin = ++pParse.nMem; - sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel.iLeftJoin); + /* If this is the right table of a LEFT OUTER JOIN, allocate and + ** initialize a memory cell that records if this table matches any + ** row of the left table of the join. + */ + if ( pLevel.iFrom > 0 && ( pTabItem.jointype & JT_LEFT ) != 0 )// Check value of pTabItem[0].jointype + { + pLevel.iLeftJoin = ++pParse.nMem; + sqlite3VdbeAddOp2( v, OP_Integer, 0, pLevel.iLeftJoin ); #if SQLITE_DEBUG - VdbeComment(v, "init LEFT JOIN no-match flag"); + VdbeComment( v, "init LEFT JOIN no-match flag" ); #endif - } + } -#if !SQLITE_OMIT_VIRTUALTABLE - if ((pLevel.plan.wsFlags & WHERE_VIRTUALTABLE) != 0) { - /* Case 0: The table is a virtual-table. Use the VFilter and VNext - ** to access the data. - */ - int iReg; /* P3 Value for OP_VFilter */ - sqlite3_index_info pVtabIdx = pLevel.plan.u.pVtabIdx; - int nConstraint = pVtabIdx.nConstraint; - sqlite3_index_constraint_usage[] aUsage = pVtabIdx.aConstraintUsage; - sqlite3_index_constraint[] aConstraint = pVtabIdx.aConstraint; - - sqlite3ExprCachePush(pParse); - iReg = sqlite3GetTempRange(pParse, nConstraint + 2); - for (j = 1; j <= nConstraint; j++) { - for (k = 0; k < nConstraint; k++) { - if (aUsage[k].argvIndex == j) { - int iTerm = aConstraint[k].iTermOffset; - sqlite3ExprCode(pParse, pWC.a[iTerm].pExpr.pRight, iReg + j + 1); - break; - } - } - if (k == nConstraint) - break; - } - sqlite3VdbeAddOp2(v, OP_Integer, pVtabIdx.idxNum, iReg); - sqlite3VdbeAddOp2(v, OP_Integer, j - 1, iReg + 1); - sqlite3VdbeAddOp4(v, OP_VFilter, iCur, addrBrk, iReg, pVtabIdx.idxStr, - pVtabIdx.needToFreeIdxStr != 0 ? P4_MPRINTF : P4_STATIC); - pVtabIdx.needToFreeIdxStr = 0; - for (j = 0; j < nConstraint; j++) { - if (aUsage[j].omit != false) { - int iTerm = aConstraint[j].iTermOffset; - disableTerm(pLevel, pWC.a[iTerm]); - } - } - pLevel.op = OP_VNext; - pLevel.p1 = iCur; - pLevel.p2 = sqlite3VdbeCurrentAddr(v); - sqlite3ReleaseTempRange(pParse, iReg, nConstraint + 2); - sqlite3ExprCachePop(pParse, 1); - } else +#if !SQLITE_OMIT_VIRTUALTABLE + if ( ( pLevel.plan.wsFlags & WHERE_VIRTUALTABLE ) != 0 ) + { + /* Case 0: The table is a virtual-table. Use the VFilter and VNext + ** to access the data. + */ + int iReg; /* P3 Value for OP_VFilter */ + sqlite3_index_info pVtabIdx = pLevel.plan.u.pVtabIdx; + int nConstraint = pVtabIdx.nConstraint; + sqlite3_index_constraint_usage[] aUsage = pVtabIdx.aConstraintUsage; + sqlite3_index_constraint[] aConstraint = pVtabIdx.aConstraint; + + sqlite3ExprCachePush( pParse ); + iReg = sqlite3GetTempRange( pParse, nConstraint + 2 ); + for ( j = 1; j <= nConstraint; j++ ) + { + for ( k = 0; k < nConstraint; k++ ) + { + if ( aUsage[k].argvIndex == j ) + { + int iTerm = aConstraint[k].iTermOffset; + sqlite3ExprCode( pParse, pWC.a[iTerm].pExpr.pRight, iReg + j + 1 ); + break; + } + } + if ( k == nConstraint ) + break; + } + sqlite3VdbeAddOp2( v, OP_Integer, pVtabIdx.idxNum, iReg ); + sqlite3VdbeAddOp2( v, OP_Integer, j - 1, iReg + 1 ); + sqlite3VdbeAddOp4( v, OP_VFilter, iCur, addrBrk, iReg, pVtabIdx.idxStr, + pVtabIdx.needToFreeIdxStr != 0 ? P4_MPRINTF : P4_STATIC ); + pVtabIdx.needToFreeIdxStr = 0; + for ( j = 0; j < nConstraint; j++ ) + { + if ( aUsage[j].omit != false ) + { + int iTerm = aConstraint[j].iTermOffset; + disableTerm( pLevel, pWC.a[iTerm] ); + } + } + pLevel.op = OP_VNext; + pLevel.p1 = iCur; + pLevel.p2 = sqlite3VdbeCurrentAddr( v ); + sqlite3ReleaseTempRange( pParse, iReg, nConstraint + 2 ); + sqlite3ExprCachePop( pParse, 1 ); + } + else #endif //* SQLITE_OMIT_VIRTUALTABLE */ - if ((pLevel.plan.wsFlags & WHERE_ROWID_EQ) != 0) { - /* Case 1: We can directly reference a single row using an - ** equality comparison against the ROWID field. Or - ** we reference multiple rows using a "rowid IN (...)" - ** construct. - */ - iReleaseReg = sqlite3GetTempReg(pParse); - pTerm = findTerm(pWC, iCur, -1, notReady, WO_EQ | WO_IN, null); - Debug.Assert(pTerm != null); - Debug.Assert(pTerm.pExpr != null); - Debug.Assert(pTerm.leftCursor == iCur); - Debug.Assert(omitTable == 0); - testcase(pTerm.wtFlags & TERM_VIRTUAL); /* EV: R-30575-11662 */ - iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, iReleaseReg); - addrNxt = pLevel.addrNxt; - sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt); - sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg); - sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg); + if ( ( pLevel.plan.wsFlags & WHERE_ROWID_EQ ) != 0 ) + { + /* Case 1: We can directly reference a single row using an + ** equality comparison against the ROWID field. Or + ** we reference multiple rows using a "rowid IN (...)" + ** construct. + */ + iReleaseReg = sqlite3GetTempReg( pParse ); + pTerm = findTerm( pWC, iCur, -1, notReady, WO_EQ | WO_IN, null ); + Debug.Assert( pTerm != null ); + Debug.Assert( pTerm.pExpr != null ); + Debug.Assert( pTerm.leftCursor == iCur ); + Debug.Assert( omitTable == 0 ); + testcase( pTerm.wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ + iRowidReg = codeEqualityTerm( pParse, pTerm, pLevel, iReleaseReg ); + addrNxt = pLevel.addrNxt; + sqlite3VdbeAddOp2( v, OP_MustBeInt, iRowidReg, addrNxt ); + sqlite3VdbeAddOp3( v, OP_NotExists, iCur, addrNxt, iRowidReg ); + sqlite3ExprCacheStore( pParse, iCur, -1, iRowidReg ); #if SQLITE_DEBUG - VdbeComment(v, "pk"); + VdbeComment( v, "pk" ); #endif - pLevel.op = OP_Noop; - } else if ((pLevel.plan.wsFlags & WHERE_ROWID_RANGE) != 0) { - /* Case 2: We have an inequality comparison against the ROWID field. - */ - int testOp = OP_Noop; - int start; - int memEndValue = 0; - WhereTerm pStart, pEnd; - - Debug.Assert(omitTable == 0); - pStart = findTerm(pWC, iCur, -1, notReady, WO_GT | WO_GE, null); - pEnd = findTerm(pWC, iCur, -1, notReady, WO_LT | WO_LE, null); - if (bRev != 0) { - pTerm = pStart; - pStart = pEnd; - pEnd = pTerm; - } - if (pStart != null) { - Expr pX; /* The expression that defines the start bound */ - int r1, rTemp = 0; /* Registers for holding the start boundary */ - - /* The following constant maps TK_xx codes into corresponding - ** seek opcodes. It depends on a particular ordering of TK_xx - */ - u8[] aMoveOp = new u8[]{ + pLevel.op = OP_Noop; + } + else if ( ( pLevel.plan.wsFlags & WHERE_ROWID_RANGE ) != 0 ) + { + /* Case 2: We have an inequality comparison against the ROWID field. + */ + int testOp = OP_Noop; + int start; + int memEndValue = 0; + WhereTerm pStart, pEnd; + + Debug.Assert( omitTable == 0 ); + pStart = findTerm( pWC, iCur, -1, notReady, WO_GT | WO_GE, null ); + pEnd = findTerm( pWC, iCur, -1, notReady, WO_LT | WO_LE, null ); + if ( bRev != 0 ) + { + pTerm = pStart; + pStart = pEnd; + pEnd = pTerm; + } + if ( pStart != null ) + { + Expr pX; /* The expression that defines the start bound */ + int r1, rTemp = 0; /* Registers for holding the start boundary */ + + /* The following constant maps TK_xx codes into corresponding + ** seek opcodes. It depends on a particular ordering of TK_xx + */ + u8[] aMoveOp = new u8[]{ /* TK_GT */ OP_SeekGt, /* TK_LE */ OP_SeekLe, /* TK_LT */ OP_SeekLt, /* TK_GE */ OP_SeekGe }; - Debug.Assert(TK_LE == TK_GT + 1); /* Make sure the ordering.. */ - Debug.Assert(TK_LT == TK_GT + 2); /* ... of the TK_xx values... */ - Debug.Assert(TK_GE == TK_GT + 3); /* ... is correcct. */ - - testcase(pStart.wtFlags & TERM_VIRTUAL); /* EV: R-30575-11662 */ - pX = pStart.pExpr; - Debug.Assert(pX != null); - Debug.Assert(pStart.leftCursor == iCur); - r1 = sqlite3ExprCodeTemp(pParse, pX.pRight, ref rTemp); - sqlite3VdbeAddOp3(v, aMoveOp[pX.op - TK_GT], iCur, addrBrk, r1); + Debug.Assert( TK_LE == TK_GT + 1 ); /* Make sure the ordering.. */ + Debug.Assert( TK_LT == TK_GT + 2 ); /* ... of the TK_xx values... */ + Debug.Assert( TK_GE == TK_GT + 3 ); /* ... is correcct. */ + + testcase( pStart.wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ + pX = pStart.pExpr; + Debug.Assert( pX != null ); + Debug.Assert( pStart.leftCursor == iCur ); + r1 = sqlite3ExprCodeTemp( pParse, pX.pRight, ref rTemp ); + sqlite3VdbeAddOp3( v, aMoveOp[pX.op - TK_GT], iCur, addrBrk, r1 ); #if SQLITE_DEBUG - VdbeComment(v, "pk"); + VdbeComment( v, "pk" ); #endif - sqlite3ExprCacheAffinityChange(pParse, r1, 1); - sqlite3ReleaseTempReg(pParse, rTemp); - disableTerm(pLevel, pStart); - } else { - sqlite3VdbeAddOp2(v, bRev != 0 ? OP_Last : OP_Rewind, iCur, addrBrk); - } - if (pEnd != null) { - Expr pX; - pX = pEnd.pExpr; - Debug.Assert(pX != null); - Debug.Assert(pEnd.leftCursor == iCur); - testcase(pEnd.wtFlags & TERM_VIRTUAL); /* EV: R-30575-11662 */ - memEndValue = ++pParse.nMem; - sqlite3ExprCode(pParse, pX.pRight, memEndValue); - if (pX.op == TK_LT || pX.op == TK_GT) { - testOp = bRev != 0 ? OP_Le : OP_Ge; - } else { - testOp = bRev != 0 ? OP_Lt : OP_Gt; - } - disableTerm(pLevel, pEnd); - } - start = sqlite3VdbeCurrentAddr(v); - pLevel.op = (u8)(bRev != 0 ? OP_Prev : OP_Next); - pLevel.p1 = iCur; - pLevel.p2 = start; - if (pStart == null && pEnd == null) { - pLevel.p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP; - } else { - Debug.Assert(pLevel.p5 == 0); - } - if (testOp != OP_Noop) { - iRowidReg = iReleaseReg = sqlite3GetTempReg(pParse); - sqlite3VdbeAddOp2(v, OP_Rowid, iCur, iRowidReg); - sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg); - sqlite3VdbeAddOp3(v, testOp, memEndValue, addrBrk, iRowidReg); - sqlite3VdbeChangeP5(v, SQLITE_AFF_NUMERIC | SQLITE_JUMPIFNULL); - } - } else if ((pLevel.plan.wsFlags & (WHERE_COLUMN_RANGE | WHERE_COLUMN_EQ)) != 0) { - /* Case 3: A scan using an index. - ** - ** The WHERE clause may contain zero or more equality - ** terms ("==" or "IN" operators) that refer to the N - ** left-most columns of the index. It may also contain - ** inequality constraints (>, <, >= or <=) on the indexed - ** column that immediately follows the N equalities. Only - ** the right-most column can be an inequality - the rest must - ** use the "==" and "IN" operators. For example, if the - ** index is on (x,y,z), then the following clauses are all - ** optimized: - ** - ** x=5 - ** x=5 AND y=10 - ** x=5 AND y<10 - ** x=5 AND y>5 AND y<10 - ** x=5 AND y=5 AND z<=10 - ** - ** The z<10 term of the following cannot be used, only - ** the x=5 term: - ** - ** x=5 AND z<10 - ** - ** N may be zero if there are inequality constraints. - ** If there are no inequality constraints, then N is at - ** least one. - ** - ** This case is also used when there are no WHERE clause - ** constraints but an index is selected anyway, in order - ** to force the output order to conform to an ORDER BY. - */ - u8[] aStartOp = new u8[] { + sqlite3ExprCacheAffinityChange( pParse, r1, 1 ); + sqlite3ReleaseTempReg( pParse, rTemp ); + disableTerm( pLevel, pStart ); + } + else + { + sqlite3VdbeAddOp2( v, bRev != 0 ? OP_Last : OP_Rewind, iCur, addrBrk ); + } + if ( pEnd != null ) + { + Expr pX; + pX = pEnd.pExpr; + Debug.Assert( pX != null ); + Debug.Assert( pEnd.leftCursor == iCur ); + testcase( pEnd.wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ + memEndValue = ++pParse.nMem; + sqlite3ExprCode( pParse, pX.pRight, memEndValue ); + if ( pX.op == TK_LT || pX.op == TK_GT ) + { + testOp = bRev != 0 ? OP_Le : OP_Ge; + } + else + { + testOp = bRev != 0 ? OP_Lt : OP_Gt; + } + disableTerm( pLevel, pEnd ); + } + start = sqlite3VdbeCurrentAddr( v ); + pLevel.op = (u8)( bRev != 0 ? OP_Prev : OP_Next ); + pLevel.p1 = iCur; + pLevel.p2 = start; + if ( pStart == null && pEnd == null ) + { + pLevel.p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP; + } + else + { + Debug.Assert( pLevel.p5 == 0 ); + } + if ( testOp != OP_Noop ) + { + iRowidReg = iReleaseReg = sqlite3GetTempReg( pParse ); + sqlite3VdbeAddOp2( v, OP_Rowid, iCur, iRowidReg ); + sqlite3ExprCacheStore( pParse, iCur, -1, iRowidReg ); + sqlite3VdbeAddOp3( v, testOp, memEndValue, addrBrk, iRowidReg ); + sqlite3VdbeChangeP5( v, SQLITE_AFF_NUMERIC | SQLITE_JUMPIFNULL ); + } + } + else if ( ( pLevel.plan.wsFlags & ( WHERE_COLUMN_RANGE | WHERE_COLUMN_EQ ) ) != 0 ) + { + /* Case 3: A scan using an index. + ** + ** The WHERE clause may contain zero or more equality + ** terms ("==" or "IN" operators) that refer to the N + ** left-most columns of the index. It may also contain + ** inequality constraints (>, <, >= or <=) on the indexed + ** column that immediately follows the N equalities. Only + ** the right-most column can be an inequality - the rest must + ** use the "==" and "IN" operators. For example, if the + ** index is on (x,y,z), then the following clauses are all + ** optimized: + ** + ** x=5 + ** x=5 AND y=10 + ** x=5 AND y<10 + ** x=5 AND y>5 AND y<10 + ** x=5 AND y=5 AND z<=10 + ** + ** The z<10 term of the following cannot be used, only + ** the x=5 term: + ** + ** x=5 AND z<10 + ** + ** N may be zero if there are inequality constraints. + ** If there are no inequality constraints, then N is at + ** least one. + ** + ** This case is also used when there are no WHERE clause + ** constraints but an index is selected anyway, in order + ** to force the output order to conform to an ORDER BY. + */ + u8[] aStartOp = new u8[] { 0, 0, OP_Rewind, /* 2: (!start_constraints && startEq && !bRev) */ @@ -4131,432 +4490,471 @@ Bitmask notReady /* Which tables are currently available */ OP_SeekGe, /* 6: (start_constraints && startEq && !bRev) */ OP_SeekLe /* 7: (start_constraints && startEq && bRev) */ }; - u8[] aEndOp = new u8[] { + u8[] aEndOp = new u8[] { OP_Noop, /* 0: (!end_constraints) */ OP_IdxGE, /* 1: (end_constraints && !bRev) */ OP_IdxLT /* 2: (end_constraints && bRev) */ }; - int nEq = (int)pLevel.plan.nEq; /* Number of == or IN terms */ - int isMinQuery = 0; /* If this is an optimized SELECT min(x).. */ - int regBase; /* Base register holding constraint values */ - int r1; /* Temp register */ - WhereTerm pRangeStart = null; /* Inequality constraint at range start */ - WhereTerm pRangeEnd = null; /* Inequality constraint at range end */ - int startEq; /* True if range start uses ==, >= or <= */ - int endEq; /* True if range end uses ==, >= or <= */ - int start_constraints; /* Start of range is constrained */ - int nConstraint; /* Number of constraint terms */ - Index pIdx; /* The index we will be using */ - int iIdxCur; /* The VDBE cursor for the index */ - int nExtraReg = 0; /* Number of extra registers needed */ - int op; /* Instruction opcode */ - StringBuilder zStartAff = new StringBuilder(""); - ;/* Affinity for start of range constraint */ - StringBuilder zEndAff; /* Affinity for end of range constraint */ - - pIdx = pLevel.plan.u.pIdx; - iIdxCur = pLevel.iIdxCur; - k = pIdx.aiColumn[nEq]; /* Column for inequality constraints */ - - /* If this loop satisfies a sort order (pOrderBy) request that - ** was pDebug.Assed to this function to implement a "SELECT min(x) ..." - ** query, then the caller will only allow the loop to run for - ** a single iteration. This means that the first row returned - ** should not have a NULL value stored in 'x'. If column 'x' is - ** the first one after the nEq equality constraints in the index, - ** this requires some special handling. - */ - if ((wctrlFlags & WHERE_ORDERBY_MIN) != 0 - && ((pLevel.plan.wsFlags & WHERE_ORDERBY) != 0) - && (pIdx.nColumn > nEq) - ) { - /* Debug.Assert( pOrderBy.nExpr==1 ); */ - /* Debug.Assert( pOrderBy.a[0].pExpr.iColumn==pIdx.aiColumn[nEq] ); */ - isMinQuery = 1; - nExtraReg = 1; - } - - /* Find any inequality constraint terms for the start and end - ** of the range. - */ - if ((pLevel.plan.wsFlags & WHERE_TOP_LIMIT) != 0) { - pRangeEnd = findTerm(pWC, iCur, k, notReady, (WO_LT | WO_LE), pIdx); - nExtraReg = 1; - } - if ((pLevel.plan.wsFlags & WHERE_BTM_LIMIT) != 0) { - pRangeStart = findTerm(pWC, iCur, k, notReady, (WO_GT | WO_GE), pIdx); - nExtraReg = 1; - } + int nEq = (int)pLevel.plan.nEq; /* Number of == or IN terms */ + int isMinQuery = 0; /* If this is an optimized SELECT min(x).. */ + int regBase; /* Base register holding constraint values */ + int r1; /* Temp register */ + WhereTerm pRangeStart = null; /* Inequality constraint at range start */ + WhereTerm pRangeEnd = null; /* Inequality constraint at range end */ + int startEq; /* True if range start uses ==, >= or <= */ + int endEq; /* True if range end uses ==, >= or <= */ + int start_constraints; /* Start of range is constrained */ + int nConstraint; /* Number of constraint terms */ + Index pIdx; /* The index we will be using */ + int iIdxCur; /* The VDBE cursor for the index */ + int nExtraReg = 0; /* Number of extra registers needed */ + int op; /* Instruction opcode */ + StringBuilder zStartAff = new StringBuilder( "" ); + ;/* Affinity for start of range constraint */ + StringBuilder zEndAff; /* Affinity for end of range constraint */ + + pIdx = pLevel.plan.u.pIdx; + iIdxCur = pLevel.iIdxCur; + k = pIdx.aiColumn[nEq]; /* Column for inequality constraints */ + + /* If this loop satisfies a sort order (pOrderBy) request that + ** was pDebug.Assed to this function to implement a "SELECT min(x) ..." + ** query, then the caller will only allow the loop to run for + ** a single iteration. This means that the first row returned + ** should not have a NULL value stored in 'x'. If column 'x' is + ** the first one after the nEq equality constraints in the index, + ** this requires some special handling. + */ + if ( ( wctrlFlags & WHERE_ORDERBY_MIN ) != 0 + && ( ( pLevel.plan.wsFlags & WHERE_ORDERBY ) != 0 ) + && ( pIdx.nColumn > nEq ) + ) + { + /* Debug.Assert( pOrderBy.nExpr==1 ); */ + /* Debug.Assert( pOrderBy.a[0].pExpr.iColumn==pIdx.aiColumn[nEq] ); */ + isMinQuery = 1; + nExtraReg = 1; + } - /* Generate code to evaluate all constraint terms using == or IN - ** and store the values of those terms in an array of registers - ** starting at regBase. - */ - regBase = codeAllEqualityTerms( - pParse, pLevel, pWC, notReady, nExtraReg, out zStartAff - ); - zEndAff = new StringBuilder(zStartAff.ToString());//sqlite3DbStrDup(pParse.db, zStartAff); - addrNxt = pLevel.addrNxt; - - /* If we are doing a reverse order scan on an ascending index, or - ** a forward order scan on a descending index, interchange the - ** start and end terms (pRangeStart and pRangeEnd). - */ - if (nEq < pIdx.nColumn && bRev == (pIdx.aSortOrder[nEq] == SQLITE_SO_ASC ? 1 : 0)) { - SWAP(ref pRangeEnd, ref pRangeStart); - } + /* Find any inequality constraint terms for the start and end + ** of the range. + */ + if ( ( pLevel.plan.wsFlags & WHERE_TOP_LIMIT ) != 0 ) + { + pRangeEnd = findTerm( pWC, iCur, k, notReady, ( WO_LT | WO_LE ), pIdx ); + nExtraReg = 1; + } + if ( ( pLevel.plan.wsFlags & WHERE_BTM_LIMIT ) != 0 ) + { + pRangeStart = findTerm( pWC, iCur, k, notReady, ( WO_GT | WO_GE ), pIdx ); + nExtraReg = 1; + } - testcase(pRangeStart != null && (pRangeStart.eOperator & WO_LE) != 0); - testcase(pRangeStart != null && (pRangeStart.eOperator & WO_GE) != 0); - testcase(pRangeEnd != null && (pRangeEnd.eOperator & WO_LE) != 0); - testcase(pRangeEnd != null && (pRangeEnd.eOperator & WO_GE) != 0); - startEq = (null == pRangeStart || (pRangeStart.eOperator & (WO_LE | WO_GE)) != 0) ? 1 : 0; - endEq = (null == pRangeEnd || (pRangeEnd.eOperator & (WO_LE | WO_GE)) != 0) ? 1 : 0; - start_constraints = (pRangeStart != null || nEq > 0) ? 1 : 0; - - /* Seek the index cursor to the start of the range. */ - nConstraint = nEq; - if (pRangeStart != null) { - Expr pRight = pRangeStart.pExpr.pRight; - sqlite3ExprCode(pParse, pRight, regBase + nEq); - if ((pRangeStart.wtFlags & TERM_VNULL) == 0) { - sqlite3ExprCodeIsNullJump(v, pRight, regBase + nEq, addrNxt); - } - if (zStartAff.Length != 0) { - if (sqlite3CompareAffinity(pRight, zStartAff[nEq]) == SQLITE_AFF_NONE) { - /* Since the comparison is to be performed with no conversions - ** applied to the operands, set the affinity to apply to pRight to - ** SQLITE_AFF_NONE. */ - zStartAff[nEq] = SQLITE_AFF_NONE; - } - if ((sqlite3ExprNeedsNoAffinityChange(pRight, zStartAff[nEq])) != 0) { - zStartAff[nEq] = SQLITE_AFF_NONE; - } - } - nConstraint++; - testcase(pRangeStart.wtFlags & TERM_VIRTUAL); /* EV: R-30575-11662 */ - } else if (isMinQuery != 0) { - sqlite3VdbeAddOp2(v, OP_Null, 0, regBase + nEq); - nConstraint++; - startEq = 0; - start_constraints = 1; - } - codeApplyAffinity(pParse, regBase, nConstraint, zStartAff.ToString()); - op = aStartOp[(start_constraints << 2) + (startEq << 1) + bRev]; - Debug.Assert(op != 0); - testcase(op == OP_Rewind); - testcase(op == OP_Last); - testcase(op == OP_SeekGt); - testcase(op == OP_SeekGe); - testcase(op == OP_SeekLe); - testcase(op == OP_SeekLt); - sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint); - - /* Load the value for the inequality constraint at the end of the - ** range (if any). - */ - nConstraint = nEq; - if (pRangeEnd != null) { - Expr pRight = pRangeEnd.pExpr.pRight; - sqlite3ExprCacheRemove(pParse, regBase + nEq, 1); - sqlite3ExprCode(pParse, pRight, regBase + nEq); - if ((pRangeEnd.wtFlags & TERM_VNULL) == 0) { - sqlite3ExprCodeIsNullJump(v, pRight, regBase + nEq, addrNxt); - } - if (zEndAff.Length > 0) { - if (sqlite3CompareAffinity(pRight, zEndAff[nEq]) == SQLITE_AFF_NONE) { - /* Since the comparison is to be performed with no conversions - ** applied to the operands, set the affinity to apply to pRight to - ** SQLITE_AFF_NONE. */ - zEndAff[nEq] = SQLITE_AFF_NONE; - } - if ((sqlite3ExprNeedsNoAffinityChange(pRight, zEndAff[nEq])) != 0) { - zEndAff[nEq] = SQLITE_AFF_NONE; - } - } - codeApplyAffinity(pParse, regBase, nEq + 1, zEndAff.ToString()); - nConstraint++; - testcase(pRangeEnd.wtFlags & TERM_VIRTUAL); /* EV: R-30575-11662 */ - } - sqlite3DbFree(pParse.db, ref zStartAff); - sqlite3DbFree(pParse.db, ref zEndAff); - - /* Top of the loop body */ - pLevel.p2 = sqlite3VdbeCurrentAddr(v); - - /* Check if the index cursor is past the end of the range. */ - op = aEndOp[((pRangeEnd != null || nEq != 0) ? 1 : 0) * (1 + bRev)]; - testcase(op == OP_Noop); - testcase(op == OP_IdxGE); - testcase(op == OP_IdxLT); - if (op != OP_Noop) { - sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint); - sqlite3VdbeChangeP5(v, (u8)(endEq != bRev ? 1 : 0)); - } + /* Generate code to evaluate all constraint terms using == or IN + ** and store the values of those terms in an array of registers + ** starting at regBase. + */ + regBase = codeAllEqualityTerms( + pParse, pLevel, pWC, notReady, nExtraReg, out zStartAff + ); + zEndAff = new StringBuilder( zStartAff.ToString() );//sqlite3DbStrDup(pParse.db, zStartAff); + addrNxt = pLevel.addrNxt; + + /* If we are doing a reverse order scan on an ascending index, or + ** a forward order scan on a descending index, interchange the + ** start and end terms (pRangeStart and pRangeEnd). + */ + if ( nEq < pIdx.nColumn && bRev == ( pIdx.aSortOrder[nEq] == SQLITE_SO_ASC ? 1 : 0 ) ) + { + SWAP( ref pRangeEnd, ref pRangeStart ); + } - /* If there are inequality constraints, check that the value - ** of the table column that the inequality contrains is not NULL. - ** If it is, jump to the next iteration of the loop. - */ - r1 = sqlite3GetTempReg(pParse); - testcase(pLevel.plan.wsFlags & WHERE_BTM_LIMIT); - testcase(pLevel.plan.wsFlags & WHERE_TOP_LIMIT); - if ((pLevel.plan.wsFlags & (WHERE_BTM_LIMIT | WHERE_TOP_LIMIT)) != 0) { - sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, nEq, r1); - sqlite3VdbeAddOp2(v, OP_IsNull, r1, addrCont); - } - sqlite3ReleaseTempReg(pParse, r1); - - /* Seek the table cursor, if required */ - disableTerm(pLevel, pRangeStart); - disableTerm(pLevel, pRangeEnd); - if (0 == omitTable) { - iRowidReg = iReleaseReg = sqlite3GetTempReg(pParse); - sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, iRowidReg); - sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg); - sqlite3VdbeAddOp2(v, OP_Seek, iCur, iRowidReg); /* Deferred seek */ - } + testcase( pRangeStart != null && ( pRangeStart.eOperator & WO_LE ) != 0 ); + testcase( pRangeStart != null && ( pRangeStart.eOperator & WO_GE ) != 0 ); + testcase( pRangeEnd != null && ( pRangeEnd.eOperator & WO_LE ) != 0 ); + testcase( pRangeEnd != null && ( pRangeEnd.eOperator & WO_GE ) != 0 ); + startEq = ( null == pRangeStart || ( pRangeStart.eOperator & ( WO_LE | WO_GE ) ) != 0 ) ? 1 : 0; + endEq = ( null == pRangeEnd || ( pRangeEnd.eOperator & ( WO_LE | WO_GE ) ) != 0 ) ? 1 : 0; + start_constraints = ( pRangeStart != null || nEq > 0 ) ? 1 : 0; + + /* Seek the index cursor to the start of the range. */ + nConstraint = nEq; + if ( pRangeStart != null ) + { + Expr pRight = pRangeStart.pExpr.pRight; + sqlite3ExprCode( pParse, pRight, regBase + nEq ); + if ( ( pRangeStart.wtFlags & TERM_VNULL ) == 0 ) + { + sqlite3ExprCodeIsNullJump( v, pRight, regBase + nEq, addrNxt ); + } + if ( zStartAff.Length != 0 ) + { + if ( sqlite3CompareAffinity( pRight, zStartAff[nEq] ) == SQLITE_AFF_NONE ) + { + /* Since the comparison is to be performed with no conversions + ** applied to the operands, set the affinity to apply to pRight to + ** SQLITE_AFF_NONE. */ + zStartAff[nEq] = SQLITE_AFF_NONE; + } + if ( ( sqlite3ExprNeedsNoAffinityChange( pRight, zStartAff[nEq] ) ) != 0 ) + { + zStartAff[nEq] = SQLITE_AFF_NONE; + } + } + nConstraint++; + testcase( pRangeStart.wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ + } + else if ( isMinQuery != 0 ) + { + sqlite3VdbeAddOp2( v, OP_Null, 0, regBase + nEq ); + nConstraint++; + startEq = 0; + start_constraints = 1; + } + codeApplyAffinity( pParse, regBase, nConstraint, zStartAff.ToString() ); + op = aStartOp[( start_constraints << 2 ) + ( startEq << 1 ) + bRev]; + Debug.Assert( op != 0 ); + testcase( op == OP_Rewind ); + testcase( op == OP_Last ); + testcase( op == OP_SeekGt ); + testcase( op == OP_SeekGe ); + testcase( op == OP_SeekLe ); + testcase( op == OP_SeekLt ); + sqlite3VdbeAddOp4Int( v, op, iIdxCur, addrNxt, regBase, nConstraint ); + + /* Load the value for the inequality constraint at the end of the + ** range (if any). + */ + nConstraint = nEq; + if ( pRangeEnd != null ) + { + Expr pRight = pRangeEnd.pExpr.pRight; + sqlite3ExprCacheRemove( pParse, regBase + nEq, 1 ); + sqlite3ExprCode( pParse, pRight, regBase + nEq ); + if ( ( pRangeEnd.wtFlags & TERM_VNULL ) == 0 ) + { + sqlite3ExprCodeIsNullJump( v, pRight, regBase + nEq, addrNxt ); + } + if ( zEndAff.Length > 0 ) + { + if ( sqlite3CompareAffinity( pRight, zEndAff[nEq] ) == SQLITE_AFF_NONE ) + { + /* Since the comparison is to be performed with no conversions + ** applied to the operands, set the affinity to apply to pRight to + ** SQLITE_AFF_NONE. */ + zEndAff[nEq] = SQLITE_AFF_NONE; + } + if ( ( sqlite3ExprNeedsNoAffinityChange( pRight, zEndAff[nEq] ) ) != 0 ) + { + zEndAff[nEq] = SQLITE_AFF_NONE; + } + } + codeApplyAffinity( pParse, regBase, nEq + 1, zEndAff.ToString() ); + nConstraint++; + testcase( pRangeEnd.wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ + } + sqlite3DbFree( pParse.db, ref zStartAff ); + sqlite3DbFree( pParse.db, ref zEndAff ); + + /* Top of the loop body */ + pLevel.p2 = sqlite3VdbeCurrentAddr( v ); + + /* Check if the index cursor is past the end of the range. */ + op = aEndOp[( ( pRangeEnd != null || nEq != 0 ) ? 1 : 0 ) * ( 1 + bRev )]; + testcase( op == OP_Noop ); + testcase( op == OP_IdxGE ); + testcase( op == OP_IdxLT ); + if ( op != OP_Noop ) + { + sqlite3VdbeAddOp4Int( v, op, iIdxCur, addrNxt, regBase, nConstraint ); + sqlite3VdbeChangeP5( v, (u8)( endEq != bRev ? 1 : 0 ) ); + } - /* Record the instruction used to terminate the loop. Disable - ** WHERE clause terms made redundant by the index range scan. - */ - if ((pLevel.plan.wsFlags & WHERE_UNIQUE) != 0) { - pLevel.op = OP_Noop; - } else if (bRev != 0) { - pLevel.op = OP_Prev; - } else { - pLevel.op = OP_Next; - } - pLevel.p1 = iIdxCur; - } else + /* If there are inequality constraints, check that the value + ** of the table column that the inequality contrains is not NULL. + ** If it is, jump to the next iteration of the loop. + */ + r1 = sqlite3GetTempReg( pParse ); + testcase( pLevel.plan.wsFlags & WHERE_BTM_LIMIT ); + testcase( pLevel.plan.wsFlags & WHERE_TOP_LIMIT ); + if ( ( pLevel.plan.wsFlags & ( WHERE_BTM_LIMIT | WHERE_TOP_LIMIT ) ) != 0 ) + { + sqlite3VdbeAddOp3( v, OP_Column, iIdxCur, nEq, r1 ); + sqlite3VdbeAddOp2( v, OP_IsNull, r1, addrCont ); + } + sqlite3ReleaseTempReg( pParse, r1 ); -#if !SQLITE_OMIT_OR_OPTIMIZATION - if ((pLevel.plan.wsFlags & WHERE_MULTI_OR) != 0) { - /* Case 4: Two or more separately indexed terms connected by OR - ** - ** Example: - ** - ** CREATE TABLE t1(a,b,c,d); - ** CREATE INDEX i1 ON t1(a); - ** CREATE INDEX i2 ON t1(b); - ** CREATE INDEX i3 ON t1(c); - ** - ** SELECT * FROM t1 WHERE a=5 OR b=7 OR (c=11 AND d=13) - ** - ** In the example, there are three indexed terms connected by OR. - ** The top of the loop looks like this: - ** - ** Null 1 # Zero the rowset in reg 1 - ** - ** Then, for each indexed term, the following. The arguments to - ** RowSetTest are such that the rowid of the current row is inserted - ** into the RowSet. If it is already present, control skips the - ** Gosub opcode and jumps straight to the code generated by WhereEnd(). - ** - ** sqlite3WhereBegin() - ** RowSetTest # Insert rowid into rowset - ** Gosub 2 A - ** sqlite3WhereEnd() - ** - ** Following the above, code to terminate the loop. Label A, the target - ** of the Gosub above, jumps to the instruction right after the Goto. - ** - ** Null 1 # Zero the rowset in reg 1 - ** Goto B # The loop is finished. - ** - ** A: # Return data, whatever. - ** - ** Return 2 # Jump back to the Gosub - ** - ** B: - ** - */ - WhereClause pOrWc; /* The OR-clause broken out into subterms */ - SrcList pOrTab; /* Shortened table list or OR-clause generation */ - - int regReturn = ++pParse.nMem; /* Register used with OP_Gosub */ - int regRowset = 0; /* Register for RowSet object */ - int regRowid = 0; /* Register holding rowid */ - int iLoopBody = sqlite3VdbeMakeLabel(v);/* Start of loop body */ - int iRetInit; /* Address of regReturn init */ - int untestedTerms = 0; /* Some terms not completely tested */ - int ii; - pTerm = pLevel.plan.u.pTerm; - Debug.Assert(pTerm != null); - Debug.Assert(pTerm.eOperator == WO_OR); - Debug.Assert((pTerm.wtFlags & TERM_ORINFO) != 0); - pOrWc = pTerm.u.pOrInfo.wc; - pLevel.op = OP_Return; - pLevel.p1 = regReturn; - - /* Set up a new SrcList in pOrTab containing the table being scanned - ** by this loop in the a[0] slot and all notReady tables in a[1..] slots. - ** This becomes the SrcList in the recursive call to sqlite3WhereBegin(). - */ - if (pWInfo.nLevel > 1) { - int nNotReady; /* The number of notReady tables */ - SrcList_item[] origSrc; /* Original list of tables */ - nNotReady = pWInfo.nLevel - iLevel - 1; - //sqlite3StackAllocRaw(pParse.db, - //sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab.a[0])); - pOrTab = new SrcList(); - pOrTab.a = new SrcList_item[nNotReady + 1]; - //if( pOrTab==0 ) return notReady; - pOrTab.nAlloc = (i16)(nNotReady + 1); - pOrTab.nSrc = pOrTab.nAlloc; - pOrTab.a[0] = pTabItem;//memcpy(pOrTab.a, pTabItem, sizeof(*pTabItem)); - origSrc = pWInfo.pTabList.a; - for (k = 1; k <= nNotReady; k++) { - pOrTab.a[k] = origSrc[pWInfo.a[iLevel + k].iFrom];// memcpy(&pOrTab.a[k], &origSrc[pLevel[k].iFrom], sizeof(pOrTab.a[k])); - } - } else { - pOrTab = pWInfo.pTabList; - } + /* Seek the table cursor, if required */ + disableTerm( pLevel, pRangeStart ); + disableTerm( pLevel, pRangeEnd ); + if ( 0 == omitTable ) + { + iRowidReg = iReleaseReg = sqlite3GetTempReg( pParse ); + sqlite3VdbeAddOp2( v, OP_IdxRowid, iIdxCur, iRowidReg ); + sqlite3ExprCacheStore( pParse, iCur, -1, iRowidReg ); + sqlite3VdbeAddOp2( v, OP_Seek, iCur, iRowidReg ); /* Deferred seek */ + } - /* Initialize the rowset register to contain NULL. An SQL NULL is - ** equivalent to an empty rowset. - ** - ** Also initialize regReturn to contain the address of the instruction - ** immediately following the OP_Return at the bottom of the loop. This - ** is required in a few obscure LEFT JOIN cases where control jumps - ** over the top of the loop into the body of it. In this case the - ** correct response for the end-of-loop code (the OP_Return) is to - ** fall through to the next instruction, just as an OP_Next does if - ** called on an uninitialized cursor. - */ - if ((wctrlFlags & WHERE_DUPLICATES_OK) == 0) { - regRowset = ++pParse.nMem; - regRowid = ++pParse.nMem; - sqlite3VdbeAddOp2(v, OP_Null, 0, regRowset); - } - iRetInit = sqlite3VdbeAddOp2(v, OP_Integer, 0, regReturn); - - for (ii = 0; ii < pOrWc.nTerm; ii++) { - WhereTerm pOrTerm = pOrWc.a[ii]; - if (pOrTerm.leftCursor == iCur || pOrTerm.eOperator == WO_AND) { - WhereInfo pSubWInfo; /* Info for single OR-term scan */ - - /* Loop through table entries that match term pOrTerm. */ - ExprList elDummy = null; - pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrTerm.pExpr, ref elDummy, - WHERE_OMIT_OPEN | WHERE_OMIT_CLOSE | - WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY); - if (pSubWInfo != null) { - explainOneScan( - pParse, pOrTab, pSubWInfo.a[0], iLevel, pLevel.iFrom, 0 - ); - if ((wctrlFlags & WHERE_DUPLICATES_OK) == 0) { - int iSet = ((ii == pOrWc.nTerm - 1) ? -1 : ii); - int r; - r = sqlite3ExprCodeGetColumn(pParse, pTabItem.pTab, -1, iCur, - regRowid); - sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset, - sqlite3VdbeCurrentAddr(v) + 2, r, iSet); - } - sqlite3VdbeAddOp2(v, OP_Gosub, regReturn, iLoopBody); - - /* The pSubWInfo.untestedTerms flag means that this OR term - ** contained one or more AND term from a notReady table. The - ** terms from the notReady table could not be tested and will - ** need to be tested later. - */ - if (pSubWInfo.untestedTerms != 0) - untestedTerms = 1; - - /* Finish the loop through table entries that match term pOrTerm. */ - sqlite3WhereEnd(pSubWInfo); - } - } - } - sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v)); - sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel.addrBrk); - sqlite3VdbeResolveLabel(v, iLoopBody); - - if (pWInfo.nLevel > 1) - sqlite3DbFree(pParse.db, ref pOrTab);//sqlite3DbFree(pParse.db, pOrTab) - if (0 == untestedTerms) - disableTerm(pLevel, pTerm); - } else -#endif //* SQLITE_OMIT_OR_OPTIMIZATION */ + /* Record the instruction used to terminate the loop. Disable + ** WHERE clause terms made redundant by the index range scan. + */ + if ( ( pLevel.plan.wsFlags & WHERE_UNIQUE ) != 0 ) + { + pLevel.op = OP_Noop; + } + else if ( bRev != 0 ) + { + pLevel.op = OP_Prev; + } + else + { + pLevel.op = OP_Next; + } + pLevel.p1 = iIdxCur; + } + else +#if !SQLITE_OMIT_OR_OPTIMIZATION + if ( ( pLevel.plan.wsFlags & WHERE_MULTI_OR ) != 0 ) + { + /* Case 4: Two or more separately indexed terms connected by OR + ** + ** Example: + ** + ** CREATE TABLE t1(a,b,c,d); + ** CREATE INDEX i1 ON t1(a); + ** CREATE INDEX i2 ON t1(b); + ** CREATE INDEX i3 ON t1(c); + ** + ** SELECT * FROM t1 WHERE a=5 OR b=7 OR (c=11 AND d=13) + ** + ** In the example, there are three indexed terms connected by OR. + ** The top of the loop looks like this: + ** + ** Null 1 # Zero the rowset in reg 1 + ** + ** Then, for each indexed term, the following. The arguments to + ** RowSetTest are such that the rowid of the current row is inserted + ** into the RowSet. If it is already present, control skips the + ** Gosub opcode and jumps straight to the code generated by WhereEnd(). + ** + ** sqlite3WhereBegin() + ** RowSetTest # Insert rowid into rowset + ** Gosub 2 A + ** sqlite3WhereEnd() + ** + ** Following the above, code to terminate the loop. Label A, the target + ** of the Gosub above, jumps to the instruction right after the Goto. + ** + ** Null 1 # Zero the rowset in reg 1 + ** Goto B # The loop is finished. + ** + ** A: # Return data, whatever. + ** + ** Return 2 # Jump back to the Gosub + ** + ** B: + ** + */ + WhereClause pOrWc; /* The OR-clause broken out into subterms */ + SrcList pOrTab; /* Shortened table list or OR-clause generation */ + + int regReturn = ++pParse.nMem; /* Register used with OP_Gosub */ + int regRowset = 0; /* Register for RowSet object */ + int regRowid = 0; /* Register holding rowid */ + int iLoopBody = sqlite3VdbeMakeLabel( v );/* Start of loop body */ + int iRetInit; /* Address of regReturn init */ + int untestedTerms = 0; /* Some terms not completely tested */ + int ii; + pTerm = pLevel.plan.u.pTerm; + Debug.Assert( pTerm != null ); + Debug.Assert( pTerm.eOperator == WO_OR ); + Debug.Assert( ( pTerm.wtFlags & TERM_ORINFO ) != 0 ); + pOrWc = pTerm.u.pOrInfo.wc; + pLevel.op = OP_Return; + pLevel.p1 = regReturn; + + /* Set up a new SrcList in pOrTab containing the table being scanned + ** by this loop in the a[0] slot and all notReady tables in a[1..] slots. + ** This becomes the SrcList in the recursive call to sqlite3WhereBegin(). + */ + if ( pWInfo.nLevel > 1 ) + { + int nNotReady; /* The number of notReady tables */ + SrcList_item[] origSrc; /* Original list of tables */ + nNotReady = pWInfo.nLevel - iLevel - 1; + //sqlite3StackAllocRaw(pParse.db, + //sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab.a[0])); + pOrTab = new SrcList(); + pOrTab.a = new SrcList_item[nNotReady + 1]; + //if( pOrTab==0 ) return notReady; + pOrTab.nAlloc = (i16)( nNotReady + 1 ); + pOrTab.nSrc = pOrTab.nAlloc; + pOrTab.a[0] = pTabItem;//memcpy(pOrTab.a, pTabItem, sizeof(*pTabItem)); + origSrc = pWInfo.pTabList.a; + for ( k = 1; k <= nNotReady; k++ ) { - /* Case 5: There is no usable index. We must do a complete - ** scan of the entire table. - */ - u8[] aStep = new u8[] { OP_Next, OP_Prev }; - u8[] aStart = new u8[] { OP_Rewind, OP_Last }; - Debug.Assert(bRev == 0 || bRev == 1); - Debug.Assert(omitTable == 0); - pLevel.op = aStep[bRev]; - pLevel.p1 = iCur; - pLevel.p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrBrk); - pLevel.p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP; + pOrTab.a[k] = origSrc[pWInfo.a[iLevel + k].iFrom];// memcpy(&pOrTab.a[k], &origSrc[pLevel[k].iFrom], sizeof(pOrTab.a[k])); + } + } + else + { + pOrTab = pWInfo.pTabList; } - notReady &= ~getMask(pWC.pMaskSet, iCur); - /* Insert code to test every subexpression that can be completely - ** computed using the current set of tables. + /* Initialize the rowset register to contain NULL. An SQL NULL is + ** equivalent to an empty rowset. ** - ** IMPLEMENTATION-OF: R-49525-50935 Terms that cannot be satisfied through - ** the use of indices become tests that are evaluated against each row of - ** the relevant input tables. + ** Also initialize regReturn to contain the address of the instruction + ** immediately following the OP_Return at the bottom of the loop. This + ** is required in a few obscure LEFT JOIN cases where control jumps + ** over the top of the loop into the body of it. In this case the + ** correct response for the end-of-loop code (the OP_Return) is to + ** fall through to the next instruction, just as an OP_Next does if + ** called on an uninitialized cursor. */ - for (j = pWC.nTerm; j > 0; j--)//, pTerm++) + if ( ( wctrlFlags & WHERE_DUPLICATES_OK ) == 0 ) { - pTerm = pWC.a[pWC.nTerm - j]; - Expr pE; - testcase(pTerm.wtFlags & TERM_VIRTUAL); /* IMP: R-30575-11662 */ - testcase(pTerm.wtFlags & TERM_CODED); - if ((pTerm.wtFlags & (TERM_VIRTUAL | TERM_CODED)) != 0) - continue; - if ((pTerm.prereqAll & notReady) != 0) { - testcase(pWInfo.untestedTerms == 0 - && (pWInfo.wctrlFlags & WHERE_ONETABLE_ONLY) != 0); - pWInfo.untestedTerms = 1; - continue; - } - pE = pTerm.pExpr; - Debug.Assert(pE != null); - if (pLevel.iLeftJoin != 0 && !((pE.flags & EP_FromJoin) == EP_FromJoin))// !ExprHasProperty(pE, EP_FromJoin) ){ + regRowset = ++pParse.nMem; + regRowid = ++pParse.nMem; + sqlite3VdbeAddOp2( v, OP_Null, 0, regRowset ); + } + iRetInit = sqlite3VdbeAddOp2( v, OP_Integer, 0, regReturn ); + + for ( ii = 0; ii < pOrWc.nTerm; ii++ ) + { + WhereTerm pOrTerm = pOrWc.a[ii]; + if ( pOrTerm.leftCursor == iCur || pOrTerm.eOperator == WO_AND ) + { + WhereInfo pSubWInfo; /* Info for single OR-term scan */ + + /* Loop through table entries that match term pOrTerm. */ + ExprList elDummy = null; + pSubWInfo = sqlite3WhereBegin( pParse, pOrTab, pOrTerm.pExpr, ref elDummy, + WHERE_OMIT_OPEN | WHERE_OMIT_CLOSE | + WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY ); + if ( pSubWInfo != null ) { - continue; + explainOneScan( + pParse, pOrTab, pSubWInfo.a[0], iLevel, pLevel.iFrom, 0 + ); + if ( ( wctrlFlags & WHERE_DUPLICATES_OK ) == 0 ) + { + int iSet = ( ( ii == pOrWc.nTerm - 1 ) ? -1 : ii ); + int r; + r = sqlite3ExprCodeGetColumn( pParse, pTabItem.pTab, -1, iCur, + regRowid ); + sqlite3VdbeAddOp4Int( v, OP_RowSetTest, regRowset, + sqlite3VdbeCurrentAddr( v ) + 2, r, iSet ); + } + sqlite3VdbeAddOp2( v, OP_Gosub, regReturn, iLoopBody ); + + /* The pSubWInfo.untestedTerms flag means that this OR term + ** contained one or more AND term from a notReady table. The + ** terms from the notReady table could not be tested and will + ** need to be tested later. + */ + if ( pSubWInfo.untestedTerms != 0 ) + untestedTerms = 1; + + /* Finish the loop through table entries that match term pOrTerm. */ + sqlite3WhereEnd( pSubWInfo ); } - sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL); - pTerm.wtFlags |= TERM_CODED; + } } + sqlite3VdbeChangeP1( v, iRetInit, sqlite3VdbeCurrentAddr( v ) ); + sqlite3VdbeAddOp2( v, OP_Goto, 0, pLevel.addrBrk ); + sqlite3VdbeResolveLabel( v, iLoopBody ); + + if ( pWInfo.nLevel > 1 ) + sqlite3DbFree( pParse.db, ref pOrTab );//sqlite3DbFree(pParse.db, pOrTab) + if ( 0 == untestedTerms ) + disableTerm( pLevel, pTerm ); + } + else +#endif //* SQLITE_OMIT_OR_OPTIMIZATION */ - /* For a LEFT OUTER JOIN, generate code that will record the fact that - ** at least one row of the right table has matched the left table. + { + /* Case 5: There is no usable index. We must do a complete + ** scan of the entire table. */ - if (pLevel.iLeftJoin != 0) { - pLevel.addrFirst = sqlite3VdbeCurrentAddr(v); - sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel.iLeftJoin); + u8[] aStep = new u8[] { OP_Next, OP_Prev }; + u8[] aStart = new u8[] { OP_Rewind, OP_Last }; + Debug.Assert( bRev == 0 || bRev == 1 ); + Debug.Assert( omitTable == 0 ); + pLevel.op = aStep[bRev]; + pLevel.p1 = iCur; + pLevel.p2 = 1 + sqlite3VdbeAddOp2( v, aStart[bRev], iCur, addrBrk ); + pLevel.p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP; + } + notReady &= ~getMask( pWC.pMaskSet, iCur ); + + /* Insert code to test every subexpression that can be completely + ** computed using the current set of tables. + ** + ** IMPLEMENTATION-OF: R-49525-50935 Terms that cannot be satisfied through + ** the use of indices become tests that are evaluated against each row of + ** the relevant input tables. + */ + for ( j = pWC.nTerm; j > 0; j-- )//, pTerm++) + { + pTerm = pWC.a[pWC.nTerm - j]; + Expr pE; + testcase( pTerm.wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */ + testcase( pTerm.wtFlags & TERM_CODED ); + if ( ( pTerm.wtFlags & ( TERM_VIRTUAL | TERM_CODED ) ) != 0 ) + continue; + if ( ( pTerm.prereqAll & notReady ) != 0 ) + { + testcase( pWInfo.untestedTerms == 0 + && ( pWInfo.wctrlFlags & WHERE_ONETABLE_ONLY ) != 0 ); + pWInfo.untestedTerms = 1; + continue; + } + pE = pTerm.pExpr; + Debug.Assert( pE != null ); + if ( pLevel.iLeftJoin != 0 && !( ( pE.flags & EP_FromJoin ) == EP_FromJoin ) )// !ExprHasProperty(pE, EP_FromJoin) ){ + { + continue; + } + sqlite3ExprIfFalse( pParse, pE, addrCont, SQLITE_JUMPIFNULL ); + pTerm.wtFlags |= TERM_CODED; + } + + /* For a LEFT OUTER JOIN, generate code that will record the fact that + ** at least one row of the right table has matched the left table. + */ + if ( pLevel.iLeftJoin != 0 ) + { + pLevel.addrFirst = sqlite3VdbeCurrentAddr( v ); + sqlite3VdbeAddOp2( v, OP_Integer, 1, pLevel.iLeftJoin ); #if SQLITE_DEBUG - VdbeComment(v, "record LEFT JOIN hit"); + VdbeComment( v, "record LEFT JOIN hit" ); #endif - sqlite3ExprCacheClear(pParse); - for (j = 0; j < pWC.nTerm; j++)//, pTerm++) - { - pTerm = pWC.a[j]; - testcase(pTerm.wtFlags & TERM_VIRTUAL); /* IMP: R-30575-11662 */ - testcase(pTerm.wtFlags & TERM_CODED); - if ((pTerm.wtFlags & (TERM_VIRTUAL | TERM_CODED)) != 0) - continue; - if ((pTerm.prereqAll & notReady) != 0) { - Debug.Assert(pWInfo.untestedTerms != 0); - continue; - } - Debug.Assert(pTerm.pExpr != null); - sqlite3ExprIfFalse(pParse, pTerm.pExpr, addrCont, SQLITE_JUMPIFNULL); - pTerm.wtFlags |= TERM_CODED; - } - } - - sqlite3ReleaseTempReg(pParse, iReleaseReg); - return notReady; + sqlite3ExprCacheClear( pParse ); + for ( j = 0; j < pWC.nTerm; j++ )//, pTerm++) + { + pTerm = pWC.a[j]; + testcase( pTerm.wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */ + testcase( pTerm.wtFlags & TERM_CODED ); + if ( ( pTerm.wtFlags & ( TERM_VIRTUAL | TERM_CODED ) ) != 0 ) + continue; + if ( ( pTerm.prereqAll & notReady ) != 0 ) + { + Debug.Assert( pWInfo.untestedTerms != 0 ); + continue; + } + Debug.Assert( pTerm.pExpr != null ); + sqlite3ExprIfFalse( pParse, pTerm.pExpr, addrCont, SQLITE_JUMPIFNULL ); + pTerm.wtFlags |= TERM_CODED; } + } + + sqlite3ReleaseTempReg( pParse, iReleaseReg ); + return notReady; + } -#if (SQLITE_TEST) +#if (SQLITE_TEST) /* ** The following variable holds a text description of query plan generated ** by the most recent call to sqlite3WhereBegin(). Each call to WhereBegin @@ -4574,587 +4972,632 @@ Bitmask notReady /* Which tables are currently available */ #endif //* SQLITE_TEST */ - /* - ** Free a WhereInfo structure - */ - static void whereInfoFree(sqlite3 db, WhereInfo pWInfo) { - if (ALWAYS(pWInfo != null)) { - int i; - for (i = 0; i < pWInfo.nLevel; i++) { - sqlite3_index_info pInfo = pWInfo.a[i] != null ? pWInfo.a[i].pIdxInfo : null; - if (pInfo != null) { - /* Debug.Assert( pInfo.needToFreeIdxStr==0 || db.mallocFailed ); */ - if (pInfo.needToFreeIdxStr != 0) { - //sqlite3_free( ref pInfo.idxStr ); - } - sqlite3DbFree(db, ref pInfo); - } - if (pWInfo.a[i] != null && (pWInfo.a[i].plan.wsFlags & WHERE_TEMP_INDEX) != 0) { - Index pIdx = pWInfo.a[i].plan.u.pIdx; - if (pIdx != null) { - sqlite3DbFree(db, ref pIdx.zColAff); - sqlite3DbFree(db, ref pIdx); - } - } - } - whereClauseClear(pWInfo.pWC); - sqlite3DbFree(db, ref pWInfo); + /* +** Free a WhereInfo structure +*/ + static void whereInfoFree( sqlite3 db, WhereInfo pWInfo ) + { + if ( ALWAYS( pWInfo != null ) ) + { + int i; + for ( i = 0; i < pWInfo.nLevel; i++ ) + { + sqlite3_index_info pInfo = pWInfo.a[i] != null ? pWInfo.a[i].pIdxInfo : null; + if ( pInfo != null ) + { + /* Debug.Assert( pInfo.needToFreeIdxStr==0 || db.mallocFailed ); */ + if ( pInfo.needToFreeIdxStr != 0 ) + { + //sqlite3_free( ref pInfo.idxStr ); + } + sqlite3DbFree( db, ref pInfo ); + } + if ( pWInfo.a[i] != null && ( pWInfo.a[i].plan.wsFlags & WHERE_TEMP_INDEX ) != 0 ) + { + Index pIdx = pWInfo.a[i].plan.u.pIdx; + if ( pIdx != null ) + { + sqlite3DbFree( db, ref pIdx.zColAff ); + sqlite3DbFree( db, ref pIdx ); } + } } + whereClauseClear( pWInfo.pWC ); + sqlite3DbFree( db, ref pWInfo ); + } + } - /* - ** Generate the beginning of the loop used for WHERE clause processing. - ** The return value is a pointer to an opaque structure that contains - ** information needed to terminate the loop. Later, the calling routine - ** should invoke sqlite3WhereEnd() with the return value of this function - ** in order to complete the WHERE clause processing. - ** - ** If an error occurs, this routine returns NULL. - ** - ** The basic idea is to do a nested loop, one loop for each table in - ** the FROM clause of a select. (INSERT and UPDATE statements are the - ** same as a SELECT with only a single table in the FROM clause.) For - ** example, if the SQL is this: - ** - ** SELECT * FROM t1, t2, t3 WHERE ...; - ** - ** Then the code generated is conceptually like the following: - ** - ** foreach row1 in t1 do \ Code generated - ** foreach row2 in t2 do |-- by sqlite3WhereBegin() - ** foreach row3 in t3 do / - ** ... - ** end \ Code generated - ** end |-- by sqlite3WhereEnd() - ** end / - ** - ** Note that the loops might not be nested in the order in which they - ** appear in the FROM clause if a different order is better able to make - ** use of indices. Note also that when the IN operator appears in - ** the WHERE clause, it might result in additional nested loops for - ** scanning through all values on the right-hand side of the IN. - ** - ** There are Btree cursors Debug.Associated with each table. t1 uses cursor - ** number pTabList.a[0].iCursor. t2 uses the cursor pTabList.a[1].iCursor. - ** And so forth. This routine generates code to open those VDBE cursors - ** and sqlite3WhereEnd() generates the code to close them. - ** - ** The code that sqlite3WhereBegin() generates leaves the cursors named - ** in pTabList pointing at their appropriate entries. The [...] code - ** can use OP_Column and OP_Rowid opcodes on these cursors to extract - ** data from the various tables of the loop. - ** - ** If the WHERE clause is empty, the foreach loops must each scan their - ** entire tables. Thus a three-way join is an O(N^3) operation. But if - ** the tables have indices and there are terms in the WHERE clause that - ** refer to those indices, a complete table scan can be avoided and the - ** code will run much faster. Most of the work of this routine is checking - ** to see if there are indices that can be used to speed up the loop. - ** - ** Terms of the WHERE clause are also used to limit which rows actually - ** make it to the "..." in the middle of the loop. After each "foreach", - ** terms of the WHERE clause that use only terms in that loop and outer - ** loops are evaluated and if false a jump is made around all subsequent - ** inner loops (or around the "..." if the test occurs within the inner- - ** most loop) - ** - ** OUTER JOINS - ** - ** An outer join of tables t1 and t2 is conceptally coded as follows: - ** - ** foreach row1 in t1 do - ** flag = 0 - ** foreach row2 in t2 do - ** start: - ** ... - ** flag = 1 - ** end - ** if flag==null then - ** move the row2 cursor to a null row - ** goto start - ** fi - ** end - ** - ** ORDER BY CLAUSE PROCESSING - ** - ** ppOrderBy is a pointer to the ORDER BY clause of a SELECT statement, - ** if there is one. If there is no ORDER BY clause or if this routine - ** is called from an UPDATE or DELETE statement, then ppOrderBy is NULL. - ** - ** If an index can be used so that the natural output order of the table - ** scan is correct for the ORDER BY clause, then that index is used and - ** ppOrderBy is set to NULL. This is an optimization that prevents an - ** unnecessary sort of the result set if an index appropriate for the - ** ORDER BY clause already exists. - ** - ** If the where clause loops cannot be arranged to provide the correct - ** output order, then the ppOrderBy is unchanged. - */ - static WhereInfo sqlite3WhereBegin( - Parse pParse, /* The parser context */ - SrcList pTabList, /* A list of all tables to be scanned */ - Expr pWhere, /* The WHERE clause */ - ref ExprList ppOrderBy, /* An ORDER BY clause, or NULL */ - u16 wctrlFlags /* One of the WHERE_* flags defined in sqliteInt.h */ - ) { - int i; /* Loop counter */ - int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */ - int nTabList; /* Number of elements in pTabList */ - WhereInfo pWInfo; /* Will become the return value of this function */ - Vdbe v = pParse.pVdbe; /* The virtual data_base engine */ - Bitmask notReady; /* Cursors that are not yet positioned */ - WhereMaskSet pMaskSet; /* The expression mask set */ - WhereClause pWC = new WhereClause(); /* Decomposition of the WHERE clause */ - SrcList_item pTabItem; /* A single entry from pTabList */ - WhereLevel pLevel; /* A single level in the pWInfo list */ - int iFrom; /* First unused FROM clause element */ - int andFlags; /* AND-ed combination of all pWC.a[].wtFlags */ - sqlite3 db; /* Data_base connection */ - - /* The number of tables in the FROM clause is limited by the number of - ** bits in a Bitmask - */ - testcase(pTabList.nSrc == BMS); - if (pTabList.nSrc > BMS) { - sqlite3ErrorMsg(pParse, "at most %d tables in a join", BMS); - return null; - } + /* + ** Generate the beginning of the loop used for WHERE clause processing. + ** The return value is a pointer to an opaque structure that contains + ** information needed to terminate the loop. Later, the calling routine + ** should invoke sqlite3WhereEnd() with the return value of this function + ** in order to complete the WHERE clause processing. + ** + ** If an error occurs, this routine returns NULL. + ** + ** The basic idea is to do a nested loop, one loop for each table in + ** the FROM clause of a select. (INSERT and UPDATE statements are the + ** same as a SELECT with only a single table in the FROM clause.) For + ** example, if the SQL is this: + ** + ** SELECT * FROM t1, t2, t3 WHERE ...; + ** + ** Then the code generated is conceptually like the following: + ** + ** foreach row1 in t1 do \ Code generated + ** foreach row2 in t2 do |-- by sqlite3WhereBegin() + ** foreach row3 in t3 do / + ** ... + ** end \ Code generated + ** end |-- by sqlite3WhereEnd() + ** end / + ** + ** Note that the loops might not be nested in the order in which they + ** appear in the FROM clause if a different order is better able to make + ** use of indices. Note also that when the IN operator appears in + ** the WHERE clause, it might result in additional nested loops for + ** scanning through all values on the right-hand side of the IN. + ** + ** There are Btree cursors Debug.Associated with each table. t1 uses cursor + ** number pTabList.a[0].iCursor. t2 uses the cursor pTabList.a[1].iCursor. + ** And so forth. This routine generates code to open those VDBE cursors + ** and sqlite3WhereEnd() generates the code to close them. + ** + ** The code that sqlite3WhereBegin() generates leaves the cursors named + ** in pTabList pointing at their appropriate entries. The [...] code + ** can use OP_Column and OP_Rowid opcodes on these cursors to extract + ** data from the various tables of the loop. + ** + ** If the WHERE clause is empty, the foreach loops must each scan their + ** entire tables. Thus a three-way join is an O(N^3) operation. But if + ** the tables have indices and there are terms in the WHERE clause that + ** refer to those indices, a complete table scan can be avoided and the + ** code will run much faster. Most of the work of this routine is checking + ** to see if there are indices that can be used to speed up the loop. + ** + ** Terms of the WHERE clause are also used to limit which rows actually + ** make it to the "..." in the middle of the loop. After each "foreach", + ** terms of the WHERE clause that use only terms in that loop and outer + ** loops are evaluated and if false a jump is made around all subsequent + ** inner loops (or around the "..." if the test occurs within the inner- + ** most loop) + ** + ** OUTER JOINS + ** + ** An outer join of tables t1 and t2 is conceptally coded as follows: + ** + ** foreach row1 in t1 do + ** flag = 0 + ** foreach row2 in t2 do + ** start: + ** ... + ** flag = 1 + ** end + ** if flag==null then + ** move the row2 cursor to a null row + ** goto start + ** fi + ** end + ** + ** ORDER BY CLAUSE PROCESSING + ** + ** ppOrderBy is a pointer to the ORDER BY clause of a SELECT statement, + ** if there is one. If there is no ORDER BY clause or if this routine + ** is called from an UPDATE or DELETE statement, then ppOrderBy is NULL. + ** + ** If an index can be used so that the natural output order of the table + ** scan is correct for the ORDER BY clause, then that index is used and + ** ppOrderBy is set to NULL. This is an optimization that prevents an + ** unnecessary sort of the result set if an index appropriate for the + ** ORDER BY clause already exists. + ** + ** If the where clause loops cannot be arranged to provide the correct + ** output order, then the ppOrderBy is unchanged. + */ + static WhereInfo sqlite3WhereBegin( + Parse pParse, /* The parser context */ + SrcList pTabList, /* A list of all tables to be scanned */ + Expr pWhere, /* The WHERE clause */ + ref ExprList ppOrderBy, /* An ORDER BY clause, or NULL */ + u16 wctrlFlags /* One of the WHERE_* flags defined in sqliteInt.h */ + ) + { + int i; /* Loop counter */ + int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */ + int nTabList; /* Number of elements in pTabList */ + WhereInfo pWInfo; /* Will become the return value of this function */ + Vdbe v = pParse.pVdbe; /* The virtual data_base engine */ + Bitmask notReady; /* Cursors that are not yet positioned */ + WhereMaskSet pMaskSet; /* The expression mask set */ + WhereClause pWC = new WhereClause(); /* Decomposition of the WHERE clause */ + SrcList_item pTabItem; /* A single entry from pTabList */ + WhereLevel pLevel; /* A single level in the pWInfo list */ + int iFrom; /* First unused FROM clause element */ + int andFlags; /* AND-ed combination of all pWC.a[].wtFlags */ + sqlite3 db; /* Data_base connection */ + + /* The number of tables in the FROM clause is limited by the number of + ** bits in a Bitmask + */ + testcase( pTabList.nSrc == BMS ); + if ( pTabList.nSrc > BMS ) + { + sqlite3ErrorMsg( pParse, "at most %d tables in a join", BMS ); + return null; + } - /* This function normally generates a nested loop for all tables in - ** pTabList. But if the WHERE_ONETABLE_ONLY flag is set, then we should - ** only generate code for the first table in pTabList and assume that - ** any cursors associated with subsequent tables are uninitialized. - */ - nTabList = ((wctrlFlags & WHERE_ONETABLE_ONLY) != 0) ? 1 : (int)pTabList.nSrc; - - /* Allocate and initialize the WhereInfo structure that will become the - ** return value. A single allocation is used to store the WhereInfo - ** struct, the contents of WhereInfo.a[], the WhereClause structure - ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte - ** field (type Bitmask) it must be aligned on an 8-byte boundary on - ** some architectures. Hence the ROUND8() below. - */ - db = pParse.db; - pWInfo = new WhereInfo(); - //nByteWInfo = ROUND8(sizeof(WhereInfo)+(nTabList-1)*sizeof(WhereLevel)); - //pWInfo = sqlite3DbMallocZero( db, - // nByteWInfo + - // sizeof( WhereClause ) + - // sizeof( WhereMaskSet ) - //); - pWInfo.a = new WhereLevel[pTabList.nSrc]; - for (int ai = 0; ai < pWInfo.a.Length; ai++) { - pWInfo.a[ai] = new WhereLevel(); - } - //if ( db.mallocFailed != 0 ) - //{ - //sqlite3DbFree(db, pWInfo); - //pWInfo = 0; - // goto whereBeginError; - //} - pWInfo.nLevel = nTabList; - pWInfo.pParse = pParse; - pWInfo.pTabList = pTabList; - pWInfo.iBreak = sqlite3VdbeMakeLabel(v); - pWInfo.pWC = pWC = new WhereClause();// (WhereClause )((u8 )pWInfo)[nByteWInfo]; - pWInfo.wctrlFlags = wctrlFlags; - pWInfo.savedNQueryLoop = pParse.nQueryLoop; - //pMaskSet = (WhereMaskSet)pWC[1]; - - /* Split the WHERE clause into separate subexpressions where each - ** subexpression is separated by an AND operator. - */ - pMaskSet = new WhereMaskSet();//initMaskSet(pMaskSet); - whereClauseInit(pWC, pParse, pMaskSet); - sqlite3ExprCodeConstants(pParse, pWhere); - whereSplit(pWC, pWhere, TK_AND); /* IMP: R-15842-53296 */ + /* This function normally generates a nested loop for all tables in + ** pTabList. But if the WHERE_ONETABLE_ONLY flag is set, then we should + ** only generate code for the first table in pTabList and assume that + ** any cursors associated with subsequent tables are uninitialized. + */ + nTabList = ( ( wctrlFlags & WHERE_ONETABLE_ONLY ) != 0 ) ? 1 : (int)pTabList.nSrc; + + /* Allocate and initialize the WhereInfo structure that will become the + ** return value. A single allocation is used to store the WhereInfo + ** struct, the contents of WhereInfo.a[], the WhereClause structure + ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte + ** field (type Bitmask) it must be aligned on an 8-byte boundary on + ** some architectures. Hence the ROUND8() below. + */ + db = pParse.db; + pWInfo = new WhereInfo(); + //nByteWInfo = ROUND8(sizeof(WhereInfo)+(nTabList-1)*sizeof(WhereLevel)); + //pWInfo = sqlite3DbMallocZero( db, + // nByteWInfo + + // sizeof( WhereClause ) + + // sizeof( WhereMaskSet ) + //); + pWInfo.a = new WhereLevel[pTabList.nSrc]; + for ( int ai = 0; ai < pWInfo.a.Length; ai++ ) + { + pWInfo.a[ai] = new WhereLevel(); + } + //if ( db.mallocFailed != 0 ) + //{ + //sqlite3DbFree(db, pWInfo); + //pWInfo = 0; + // goto whereBeginError; + //} + pWInfo.nLevel = nTabList; + pWInfo.pParse = pParse; + pWInfo.pTabList = pTabList; + pWInfo.iBreak = sqlite3VdbeMakeLabel( v ); + pWInfo.pWC = pWC = new WhereClause();// (WhereClause )((u8 )pWInfo)[nByteWInfo]; + pWInfo.wctrlFlags = wctrlFlags; + pWInfo.savedNQueryLoop = pParse.nQueryLoop; + //pMaskSet = (WhereMaskSet)pWC[1]; + + /* Split the WHERE clause into separate subexpressions where each + ** subexpression is separated by an AND operator. + */ + pMaskSet = new WhereMaskSet();//initMaskSet(pMaskSet); + whereClauseInit( pWC, pParse, pMaskSet ); + sqlite3ExprCodeConstants( pParse, pWhere ); + whereSplit( pWC, pWhere, TK_AND ); /* IMP: R-15842-53296 */ - /* Special case: a WHERE clause that is constant. Evaluate the - ** expression and either jump over all of the code or fall thru. - */ - if (pWhere != null && (nTabList == 0 || sqlite3ExprIsConstantNotJoin(pWhere) != 0)) { - sqlite3ExprIfFalse(pParse, pWhere, pWInfo.iBreak, SQLITE_JUMPIFNULL); - pWhere = null; - } + /* Special case: a WHERE clause that is constant. Evaluate the + ** expression and either jump over all of the code or fall thru. + */ + if ( pWhere != null && ( nTabList == 0 || sqlite3ExprIsConstantNotJoin( pWhere ) != 0 ) ) + { + sqlite3ExprIfFalse( pParse, pWhere, pWInfo.iBreak, SQLITE_JUMPIFNULL ); + pWhere = null; + } - /* Assign a bit from the bitmask to every term in the FROM clause. - ** - ** When assigning bitmask values to FROM clause cursors, it must be - ** the case that if X is the bitmask for the N-th FROM clause term then - ** the bitmask for all FROM clause terms to the left of the N-th term - ** is (X-1). An expression from the ON clause of a LEFT JOIN can use - ** its Expr.iRightJoinTable value to find the bitmask of the right table - ** of the join. Subtracting one from the right table bitmask gives a - ** bitmask for all tables to the left of the join. Knowing the bitmask - ** for all tables to the left of a left join is important. Ticket #3015. - ** - ** Configure the WhereClause.vmask variable so that bits that correspond - ** to virtual table cursors are set. This is used to selectively disable - ** the OR-to-IN transformation in exprAnalyzeOrTerm(). It is not helpful - ** with virtual tables. - ** - ** Note that bitmasks are created for all pTabList.nSrc tables in - ** pTabList, not just the first nTabList tables. nTabList is normally - ** equal to pTabList.nSrc but might be shortened to 1 if the - ** WHERE_ONETABLE_ONLY flag is set. - */ - Debug.Assert(pWC.vmask == 0 && pMaskSet.n == 0); - for (i = 0; i < pTabList.nSrc; i++) { - createMask(pMaskSet, pTabList.a[i].iCursor); + /* Assign a bit from the bitmask to every term in the FROM clause. + ** + ** When assigning bitmask values to FROM clause cursors, it must be + ** the case that if X is the bitmask for the N-th FROM clause term then + ** the bitmask for all FROM clause terms to the left of the N-th term + ** is (X-1). An expression from the ON clause of a LEFT JOIN can use + ** its Expr.iRightJoinTable value to find the bitmask of the right table + ** of the join. Subtracting one from the right table bitmask gives a + ** bitmask for all tables to the left of the join. Knowing the bitmask + ** for all tables to the left of a left join is important. Ticket #3015. + ** + ** Configure the WhereClause.vmask variable so that bits that correspond + ** to virtual table cursors are set. This is used to selectively disable + ** the OR-to-IN transformation in exprAnalyzeOrTerm(). It is not helpful + ** with virtual tables. + ** + ** Note that bitmasks are created for all pTabList.nSrc tables in + ** pTabList, not just the first nTabList tables. nTabList is normally + ** equal to pTabList.nSrc but might be shortened to 1 if the + ** WHERE_ONETABLE_ONLY flag is set. + */ + Debug.Assert( pWC.vmask == 0 && pMaskSet.n == 0 ); + for ( i = 0; i < pTabList.nSrc; i++ ) + { + createMask( pMaskSet, pTabList.a[i].iCursor ); #if !SQLITE_OMIT_VIRTUALTABLE - if (ALWAYS(pTabList.a[i].pTab) && IsVirtual(pTabList.a[i].pTab)) { - pWC.vmask |= ((Bitmask)1 << i); - } + if ( ALWAYS( pTabList.a[i].pTab ) && IsVirtual( pTabList.a[i].pTab ) ) + { + pWC.vmask |= ( (Bitmask)1 << i ); + } #endif - } -#if !NDEBUG - { - Bitmask toTheLeft = 0; - for (i = 0; i < pTabList.nSrc; i++) { - Bitmask m = getMask(pMaskSet, pTabList.a[i].iCursor); - Debug.Assert((m - 1) == toTheLeft); - toTheLeft |= m; - } - } + } +#if !NDEBUG + { + Bitmask toTheLeft = 0; + for ( i = 0; i < pTabList.nSrc; i++ ) + { + Bitmask m = getMask( pMaskSet, pTabList.a[i].iCursor ); + Debug.Assert( ( m - 1 ) == toTheLeft ); + toTheLeft |= m; + } + } #endif - /* Analyze all of the subexpressions. Note that exprAnalyze() might - ** add new virtual terms onto the end of the WHERE clause. We do not - ** want to analyze these virtual terms, so start analyzing at the end - ** and work forward so that the added virtual terms are never processed. - */ - exprAnalyzeAll(pTabList, pWC); - //if ( db.mallocFailed != 0 ) - //{ - // goto whereBeginError; - //} + /* Analyze all of the subexpressions. Note that exprAnalyze() might +** add new virtual terms onto the end of the WHERE clause. We do not +** want to analyze these virtual terms, so start analyzing at the end +** and work forward so that the added virtual terms are never processed. +*/ + exprAnalyzeAll( pTabList, pWC ); + //if ( db.mallocFailed != 0 ) + //{ + // goto whereBeginError; + //} - /* Chose the best index to use for each table in the FROM clause. - ** - ** This loop fills in the following fields: - ** - ** pWInfo.a[].pIdx The index to use for this level of the loop. - ** pWInfo.a[].wsFlags WHERE_xxx flags Debug.Associated with pIdx - ** pWInfo.a[].nEq The number of == and IN constraints - ** pWInfo.a[].iFrom Which term of the FROM clause is being coded - ** pWInfo.a[].iTabCur The VDBE cursor for the data_base table - ** pWInfo.a[].iIdxCur The VDBE cursor for the index - ** pWInfo.a[].pTerm When wsFlags==WO_OR, the OR-clause term - ** - ** This loop also figures out the nesting order of tables in the FROM - ** clause. - */ - notReady = ~(Bitmask)0; - andFlags = ~0; + /* Chose the best index to use for each table in the FROM clause. + ** + ** This loop fills in the following fields: + ** + ** pWInfo.a[].pIdx The index to use for this level of the loop. + ** pWInfo.a[].wsFlags WHERE_xxx flags Debug.Associated with pIdx + ** pWInfo.a[].nEq The number of == and IN constraints + ** pWInfo.a[].iFrom Which term of the FROM clause is being coded + ** pWInfo.a[].iTabCur The VDBE cursor for the data_base table + ** pWInfo.a[].iIdxCur The VDBE cursor for the index + ** pWInfo.a[].pTerm When wsFlags==WO_OR, the OR-clause term + ** + ** This loop also figures out the nesting order of tables in the FROM + ** clause. + */ + notReady = ~(Bitmask)0; + andFlags = ~0; #if (SQLITE_TEST) && (SQLITE_DEBUG) WHERETRACE( "*** Optimizer Start ***\n" ); #endif - for (i = iFrom = 0; i < nTabList; i++)//, pLevel++ ) - { - pLevel = pWInfo.a[i]; - WhereCost bestPlan; /* Most efficient plan seen so far */ - Index pIdx; /* Index for FROM table at pTabItem */ - int j; /* For looping over FROM tables */ - int bestJ = -1; /* The value of j */ - Bitmask m; /* Bitmask value for j or bestJ */ - int isOptimal; /* Iterator for optimal/non-optimal search */ - int nUnconstrained; /* Number tables without INDEXED BY */ - Bitmask notIndexed; /* Mask of tables that cannot use an index */ - - bestPlan = new WhereCost();// memset( &bestPlan, 0, sizeof( bestPlan ) ); - bestPlan.rCost = SQLITE_BIG_DBL; -#if (SQLITE_TEST) && (SQLITE_DEBUG) + for ( i = iFrom = 0; i < nTabList; i++ )//, pLevel++ ) + { + pLevel = pWInfo.a[i]; + WhereCost bestPlan; /* Most efficient plan seen so far */ + Index pIdx; /* Index for FROM table at pTabItem */ + int j; /* For looping over FROM tables */ + int bestJ = -1; /* The value of j */ + Bitmask m; /* Bitmask value for j or bestJ */ + int isOptimal; /* Iterator for optimal/non-optimal search */ + int nUnconstrained; /* Number tables without INDEXED BY */ + Bitmask notIndexed; /* Mask of tables that cannot use an index */ + + bestPlan = new WhereCost();// memset( &bestPlan, 0, sizeof( bestPlan ) ); + bestPlan.rCost = SQLITE_BIG_DBL; +#if (SQLITE_TEST) && (SQLITE_DEBUG) WHERETRACE( "*** Begin search for loop %d ***\n", i ); #endif - /* Loop through the remaining entries in the FROM clause to find the - ** next nested loop. The loop tests all FROM clause entries - ** either once or twice. - ** - ** The first test is always performed if there are two or more entries - ** remaining and never performed if there is only one FROM clause entry - ** to choose from. The first test looks for an "optimal" scan. In - ** this context an optimal scan is one that uses the same strategy - ** for the given FROM clause entry as would be selected if the entry - ** were used as the innermost nested loop. In other words, a table - ** is chosen such that the cost of running that table cannot be reduced - ** by waiting for other tables to run first. This "optimal" test works - ** by first assuming that the FROM clause is on the inner loop and finding - ** its query plan, then checking to see if that query plan uses any - ** other FROM clause terms that are notReady. If no notReady terms are - ** used then the "optimal" query plan works. - ** - ** Note that the WhereCost.nRow parameter for an optimal scan might - ** not be as small as it would be if the table really were the innermost - ** join. The nRow value can be reduced by WHERE clause constraints - ** that do not use indices. But this nRow reduction only happens if the - ** table really is the innermost join. - ** - ** The second loop iteration is only performed if no optimal scan - ** strategies were found by the first iteration. This second iteration - ** is used to search for the lowest cost scan overall. - ** - ** Previous versions of SQLite performed only the second iteration - - ** the next outermost loop was always that with the lowest overall - ** cost. However, this meant that SQLite could select the wrong plan - ** for scripts such as the following: - ** - ** CREATE TABLE t1(a, b); - ** CREATE TABLE t2(c, d); - ** SELECT * FROM t2, t1 WHERE t2.rowid = t1.a; - ** - ** The best strategy is to iterate through table t1 first. However it - ** is not possible to determine this with a simple greedy algorithm. - ** Since the cost of a linear scan through table t2 is the same - ** as the cost of a linear scan through table t1, a simple greedy - ** algorithm may choose to use t2 for the outer loop, which is a much - ** costlier approach. - */ - nUnconstrained = 0; - notIndexed = 0; - for (isOptimal = (iFrom < nTabList - 1) ? 1 : 0; isOptimal >= 0 && bestJ < 0; isOptimal--) { - Bitmask mask; /* Mask of tables not yet ready */ - for (j = iFrom; j < nTabList; j++)//, pTabItem++) - { - pTabItem = pTabList.a[j]; - int doNotReorder; /* True if this table should not be reordered */ - WhereCost sCost = new WhereCost(); /* Cost information from best[Virtual]Index() */ - ExprList pOrderBy; /* ORDER BY clause for index to optimize */ - - doNotReorder = (pTabItem.jointype & (JT_LEFT | JT_CROSS)) != 0 ? 1 : 0; - if ((j != iFrom && doNotReorder != 0)) - break; - m = getMask(pMaskSet, pTabItem.iCursor); - if ((m & notReady) == 0) { - if (j == iFrom) - iFrom++; - continue; - } - mask = (isOptimal != 0 ? m : notReady); - pOrderBy = ((i == 0 && ppOrderBy != null) ? ppOrderBy : null); - if (pTabItem.pIndex == null) - nUnconstrained++; + /* Loop through the remaining entries in the FROM clause to find the +** next nested loop. The loop tests all FROM clause entries +** either once or twice. +** +** The first test is always performed if there are two or more entries +** remaining and never performed if there is only one FROM clause entry +** to choose from. The first test looks for an "optimal" scan. In +** this context an optimal scan is one that uses the same strategy +** for the given FROM clause entry as would be selected if the entry +** were used as the innermost nested loop. In other words, a table +** is chosen such that the cost of running that table cannot be reduced +** by waiting for other tables to run first. This "optimal" test works +** by first assuming that the FROM clause is on the inner loop and finding +** its query plan, then checking to see if that query plan uses any +** other FROM clause terms that are notReady. If no notReady terms are +** used then the "optimal" query plan works. +** +** Note that the WhereCost.nRow parameter for an optimal scan might +** not be as small as it would be if the table really were the innermost +** join. The nRow value can be reduced by WHERE clause constraints +** that do not use indices. But this nRow reduction only happens if the +** table really is the innermost join. +** +** The second loop iteration is only performed if no optimal scan +** strategies were found by the first iteration. This second iteration +** is used to search for the lowest cost scan overall. +** +** Previous versions of SQLite performed only the second iteration - +** the next outermost loop was always that with the lowest overall +** cost. However, this meant that SQLite could select the wrong plan +** for scripts such as the following: +** +** CREATE TABLE t1(a, b); +** CREATE TABLE t2(c, d); +** SELECT * FROM t2, t1 WHERE t2.rowid = t1.a; +** +** The best strategy is to iterate through table t1 first. However it +** is not possible to determine this with a simple greedy algorithm. +** Since the cost of a linear scan through table t2 is the same +** as the cost of a linear scan through table t1, a simple greedy +** algorithm may choose to use t2 for the outer loop, which is a much +** costlier approach. +*/ + nUnconstrained = 0; + notIndexed = 0; + for ( isOptimal = ( iFrom < nTabList - 1 ) ? 1 : 0; isOptimal >= 0 && bestJ < 0; isOptimal-- ) + { + Bitmask mask; /* Mask of tables not yet ready */ + for ( j = iFrom; j < nTabList; j++ )//, pTabItem++) + { + pTabItem = pTabList.a[j]; + int doNotReorder; /* True if this table should not be reordered */ + WhereCost sCost = new WhereCost(); /* Cost information from best[Virtual]Index() */ + ExprList pOrderBy; /* ORDER BY clause for index to optimize */ -#if (SQLITE_TEST) && (SQLITE_DEBUG) + doNotReorder = ( pTabItem.jointype & ( JT_LEFT | JT_CROSS ) ) != 0 ? 1 : 0; + if ( ( j != iFrom && doNotReorder != 0 ) ) + break; + m = getMask( pMaskSet, pTabItem.iCursor ); + if ( ( m & notReady ) == 0 ) + { + if ( j == iFrom ) + iFrom++; + continue; + } + mask = ( isOptimal != 0 ? m : notReady ); + pOrderBy = ( ( i == 0 && ppOrderBy != null ) ? ppOrderBy : null ); + if ( pTabItem.pIndex == null ) + nUnconstrained++; + +#if (SQLITE_TEST) && (SQLITE_DEBUG) WHERETRACE( "=== trying table %d with isOptimal=%d ===\n", j, isOptimal ); #endif - Debug.Assert(pTabItem.pTab != null); -#if !SQLITE_OMIT_VIRTUALTABLE - if (IsVirtual(pTabItem.pTab)) { - sqlite3_index_info pp = pWInfo.a[j].pIdxInfo; - bestVirtualIndex(pParse, pWC, pTabItem, mask, notReady, pOrderBy, - ref sCost, ref pp); - } else + Debug.Assert( pTabItem.pTab != null ); +#if !SQLITE_OMIT_VIRTUALTABLE + if ( IsVirtual( pTabItem.pTab ) ) + { + sqlite3_index_info pp = pWInfo.a[j].pIdxInfo; + bestVirtualIndex( pParse, pWC, pTabItem, mask, notReady, pOrderBy, + ref sCost, ref pp ); + } + else #endif - { - bestBtreeIndex(pParse, pWC, pTabItem, mask, notReady, pOrderBy, - ref sCost); - } - Debug.Assert(isOptimal != 0 || (sCost.used & notReady) == 0); - - /* If an INDEXED BY clause is present, then the plan must use that - ** index if it uses any index at all */ - Debug.Assert(pTabItem.pIndex == null - || (sCost.plan.wsFlags & WHERE_NOT_FULLSCAN) == 0 - || sCost.plan.u.pIdx == pTabItem.pIndex); - - if (isOptimal != 0 && (sCost.plan.wsFlags & WHERE_NOT_FULLSCAN) == 0) { - notIndexed |= m; - } - - /* Conditions under which this table becomes the best so far: - ** - ** (1) The table must not depend on other tables that have not - ** yet run. - ** - ** (2) A full-table-scan plan cannot supercede indexed plan unless - ** the full-table-scan is an "optimal" plan as defined above. - ** - ** (3) All tables have an INDEXED BY clause or this table lacks an - ** INDEXED BY clause or this table uses the specific - ** index specified by its INDEXED BY clause. This rule ensures - ** that a best-so-far is always selected even if an impossible - ** combination of INDEXED BY clauses are given. The error - ** will be detected and relayed back to the application later. - ** The NEVER() comes about because rule (2) above prevents - ** An indexable full-table-scan from reaching rule (3). - ** - ** (4) The plan cost must be lower than prior plans or else the - ** cost must be the same and the number of rows must be lower. - */ - if ((sCost.used & notReady) == 0 /* (1) */ - && (bestJ < 0 || (notIndexed & m) != 0 /* (2) */ - || (bestPlan.plan.wsFlags & WHERE_NOT_FULLSCAN) == 0 - || (sCost.plan.wsFlags & WHERE_NOT_FULLSCAN) != 0) - && (nUnconstrained == 0 || pTabItem.pIndex == null /* (3) */ - || NEVER((sCost.plan.wsFlags & WHERE_NOT_FULLSCAN) != 0)) - && (bestJ < 0 || sCost.rCost < bestPlan.rCost /* (4) */ - || (sCost.rCost <= bestPlan.rCost - && sCost.plan.nRow < bestPlan.plan.nRow)) - ) { -#if (SQLITE_TEST) && (SQLITE_DEBUG) + { + bestBtreeIndex( pParse, pWC, pTabItem, mask, notReady, pOrderBy, + ref sCost ); + } + Debug.Assert( isOptimal != 0 || ( sCost.used & notReady ) == 0 ); + + /* If an INDEXED BY clause is present, then the plan must use that + ** index if it uses any index at all */ + Debug.Assert( pTabItem.pIndex == null + || ( sCost.plan.wsFlags & WHERE_NOT_FULLSCAN ) == 0 + || sCost.plan.u.pIdx == pTabItem.pIndex ); + + if ( isOptimal != 0 && ( sCost.plan.wsFlags & WHERE_NOT_FULLSCAN ) == 0 ) + { + notIndexed |= m; + } + + /* Conditions under which this table becomes the best so far: + ** + ** (1) The table must not depend on other tables that have not + ** yet run. + ** + ** (2) A full-table-scan plan cannot supercede indexed plan unless + ** the full-table-scan is an "optimal" plan as defined above. + ** + ** (3) All tables have an INDEXED BY clause or this table lacks an + ** INDEXED BY clause or this table uses the specific + ** index specified by its INDEXED BY clause. This rule ensures + ** that a best-so-far is always selected even if an impossible + ** combination of INDEXED BY clauses are given. The error + ** will be detected and relayed back to the application later. + ** The NEVER() comes about because rule (2) above prevents + ** An indexable full-table-scan from reaching rule (3). + ** + ** (4) The plan cost must be lower than prior plans or else the + ** cost must be the same and the number of rows must be lower. + */ + if ( ( sCost.used & notReady ) == 0 /* (1) */ + && ( bestJ < 0 || ( notIndexed & m ) != 0 /* (2) */ + || ( bestPlan.plan.wsFlags & WHERE_NOT_FULLSCAN ) == 0 + || ( sCost.plan.wsFlags & WHERE_NOT_FULLSCAN ) != 0 ) + && ( nUnconstrained == 0 || pTabItem.pIndex == null /* (3) */ + || NEVER( ( sCost.plan.wsFlags & WHERE_NOT_FULLSCAN ) != 0 ) ) + && ( bestJ < 0 || sCost.rCost < bestPlan.rCost /* (4) */ + || ( sCost.rCost <= bestPlan.rCost + && sCost.plan.nRow < bestPlan.plan.nRow ) ) + ) + { +#if (SQLITE_TEST) && (SQLITE_DEBUG) WHERETRACE( "=== table %d is best so far" + " with cost=%g and nRow=%g\n", j, sCost.rCost, sCost.plan.nRow ); #endif - bestPlan = sCost; - bestJ = j; - } - if (doNotReorder != 0) - break; - } - } - Debug.Assert(bestJ >= 0); - Debug.Assert((notReady & getMask(pMaskSet, pTabList.a[bestJ].iCursor)) != 0); + bestPlan = sCost; + bestJ = j; + } + if ( doNotReorder != 0 ) + break; + } + } + Debug.Assert( bestJ >= 0 ); + Debug.Assert( ( notReady & getMask( pMaskSet, pTabList.a[bestJ].iCursor ) ) != 0 ); #if (SQLITE_TEST) && (SQLITE_DEBUG) WHERETRACE( "*** Optimizer selects table %d for loop %d" + " with cost=%g and nRow=%g\n", bestJ, i,//pLevel-pWInfo.a, bestPlan.rCost, bestPlan.plan.nRow ); #endif - if ((bestPlan.plan.wsFlags & WHERE_ORDERBY) != 0) { - ppOrderBy = null; - } - andFlags = (int)(andFlags & bestPlan.plan.wsFlags); - pLevel.plan = bestPlan.plan; - testcase(bestPlan.plan.wsFlags & WHERE_INDEXED); - testcase(bestPlan.plan.wsFlags & WHERE_TEMP_INDEX); - if ((bestPlan.plan.wsFlags & (WHERE_INDEXED | WHERE_TEMP_INDEX)) != 0) { - pLevel.iIdxCur = pParse.nTab++; - } else { - pLevel.iIdxCur = -1; - } - notReady &= ~getMask(pMaskSet, pTabList.a[bestJ].iCursor); - pLevel.iFrom = (u8)bestJ; - if (bestPlan.plan.nRow >= (double)1) { - pParse.nQueryLoop *= bestPlan.plan.nRow; - } + if ( ( bestPlan.plan.wsFlags & WHERE_ORDERBY ) != 0 ) + { + ppOrderBy = null; + } + andFlags = (int)( andFlags & bestPlan.plan.wsFlags ); + pLevel.plan = bestPlan.plan; + testcase( bestPlan.plan.wsFlags & WHERE_INDEXED ); + testcase( bestPlan.plan.wsFlags & WHERE_TEMP_INDEX ); + if ( ( bestPlan.plan.wsFlags & ( WHERE_INDEXED | WHERE_TEMP_INDEX ) ) != 0 ) + { + pLevel.iIdxCur = pParse.nTab++; + } + else + { + pLevel.iIdxCur = -1; + } + notReady &= ~getMask( pMaskSet, pTabList.a[bestJ].iCursor ); + pLevel.iFrom = (u8)bestJ; + if ( bestPlan.plan.nRow >= (double)1 ) + { + pParse.nQueryLoop *= bestPlan.plan.nRow; + } - /* Check that if the table scanned by this loop iteration had an - ** INDEXED BY clause attached to it, that the named index is being - ** used for the scan. If not, then query compilation has failed. - ** Return an error. - */ - pIdx = pTabList.a[bestJ].pIndex; - if (pIdx != null) { - if ((bestPlan.plan.wsFlags & WHERE_INDEXED) == 0) { - sqlite3ErrorMsg(pParse, "cannot use index: %s", pIdx.zName); - goto whereBeginError; - } else { - /* If an INDEXED BY clause is used, the bestIndex() function is - ** guaranteed to find the index specified in the INDEXED BY clause - ** if it find an index at all. */ - Debug.Assert(bestPlan.plan.u.pIdx == pIdx); - } - } - } + /* Check that if the table scanned by this loop iteration had an + ** INDEXED BY clause attached to it, that the named index is being + ** used for the scan. If not, then query compilation has failed. + ** Return an error. + */ + pIdx = pTabList.a[bestJ].pIndex; + if ( pIdx != null ) + { + if ( ( bestPlan.plan.wsFlags & WHERE_INDEXED ) == 0 ) + { + sqlite3ErrorMsg( pParse, "cannot use index: %s", pIdx.zName ); + goto whereBeginError; + } + else + { + /* If an INDEXED BY clause is used, the bestIndex() function is + ** guaranteed to find the index specified in the INDEXED BY clause + ** if it find an index at all. */ + Debug.Assert( bestPlan.plan.u.pIdx == pIdx ); + } + } + } #if (SQLITE_TEST) && (SQLITE_DEBUG) WHERETRACE( "*** Optimizer Finished ***\n" ); #endif - if (pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) { - goto whereBeginError; - } + if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) + { + goto whereBeginError; + } - /* If the total query only selects a single row, then the ORDER BY - ** clause is irrelevant. - */ - if ((andFlags & WHERE_UNIQUE) != 0 && ppOrderBy != null) { - ppOrderBy = null; - } + /* If the total query only selects a single row, then the ORDER BY + ** clause is irrelevant. + */ + if ( ( andFlags & WHERE_UNIQUE ) != 0 && ppOrderBy != null ) + { + ppOrderBy = null; + } - /* If the caller is an UPDATE or DELETE statement that is requesting - ** to use a one-pDebug.Ass algorithm, determine if this is appropriate. - ** The one-pass algorithm only works if the WHERE clause constraints - ** the statement to update a single row. - */ - Debug.Assert((wctrlFlags & WHERE_ONEPASS_DESIRED) == 0 || pWInfo.nLevel == 1); - if ((wctrlFlags & WHERE_ONEPASS_DESIRED) != 0 && (andFlags & WHERE_UNIQUE) != 0) { - pWInfo.okOnePass = 1; - pWInfo.a[0].plan.wsFlags = (u32)(pWInfo.a[0].plan.wsFlags & ~WHERE_IDX_ONLY); - } + /* If the caller is an UPDATE or DELETE statement that is requesting + ** to use a one-pDebug.Ass algorithm, determine if this is appropriate. + ** The one-pass algorithm only works if the WHERE clause constraints + ** the statement to update a single row. + */ + Debug.Assert( ( wctrlFlags & WHERE_ONEPASS_DESIRED ) == 0 || pWInfo.nLevel == 1 ); + if ( ( wctrlFlags & WHERE_ONEPASS_DESIRED ) != 0 && ( andFlags & WHERE_UNIQUE ) != 0 ) + { + pWInfo.okOnePass = 1; + pWInfo.a[0].plan.wsFlags = (u32)( pWInfo.a[0].plan.wsFlags & ~WHERE_IDX_ONLY ); + } - /* Open all tables in the pTabList and any indices selected for - ** searching those tables. - */ - sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */ - notReady = ~(Bitmask)0; - pWInfo.nRowOut = (double)1; - for (i = 0; i < nTabList; i++)//, pLevel++ ) - { - pLevel = pWInfo.a[i]; - Table pTab; /* Table to open */ - int iDb; /* Index of data_base containing table/index */ - - pTabItem = pTabList.a[pLevel.iFrom]; - pTab = pTabItem.pTab; - pLevel.iTabCur = pTabItem.iCursor; - pWInfo.nRowOut *= pLevel.plan.nRow; - iDb = sqlite3SchemaToIndex(db, pTab.pSchema); - if ((pTab.tabFlags & TF_Ephemeral) != 0 || pTab.pSelect != null) { - /* Do nothing */ - } else -#if !SQLITE_OMIT_VIRTUALTABLE - if ((pLevel.plan.wsFlags & WHERE_VIRTUALTABLE) != 0) { - VTable pVTab = sqlite3GetVTable(db, pTab); - int iCur = pTabItem.iCursor; - sqlite3VdbeAddOp4(v, OP_VOpen, iCur, 0, 0, - pVTab, P4_VTAB); - } else + /* Open all tables in the pTabList and any indices selected for + ** searching those tables. + */ + sqlite3CodeVerifySchema( pParse, -1 ); /* Insert the cookie verifier Goto */ + notReady = ~(Bitmask)0; + pWInfo.nRowOut = (double)1; + for ( i = 0; i < nTabList; i++ )//, pLevel++ ) + { + pLevel = pWInfo.a[i]; + Table pTab; /* Table to open */ + int iDb; /* Index of data_base containing table/index */ + + pTabItem = pTabList.a[pLevel.iFrom]; + pTab = pTabItem.pTab; + pLevel.iTabCur = pTabItem.iCursor; + pWInfo.nRowOut *= pLevel.plan.nRow; + iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); + if ( ( pTab.tabFlags & TF_Ephemeral ) != 0 || pTab.pSelect != null ) + { + /* Do nothing */ + } + else +#if !SQLITE_OMIT_VIRTUALTABLE + if ( ( pLevel.plan.wsFlags & WHERE_VIRTUALTABLE ) != 0 ) + { + VTable pVTab = sqlite3GetVTable( db, pTab ); + int iCur = pTabItem.iCursor; + sqlite3VdbeAddOp4( v, OP_VOpen, iCur, 0, 0, + pVTab, P4_VTAB ); + } + else #endif - if ((pLevel.plan.wsFlags & WHERE_IDX_ONLY) == 0 - && (wctrlFlags & WHERE_OMIT_OPEN) == 0) { - int op = pWInfo.okOnePass != 0 ? OP_OpenWrite : OP_OpenRead; - sqlite3OpenTable(pParse, pTabItem.iCursor, iDb, pTab, op); - testcase(pTab.nCol == BMS - 1); - testcase(pTab.nCol == BMS); - if (0 == pWInfo.okOnePass && pTab.nCol < BMS) { - Bitmask b = pTabItem.colUsed; - int n = 0; - for (; b != 0; b = b >> 1, n++) { - } - sqlite3VdbeChangeP4(v, sqlite3VdbeCurrentAddr(v) - 1, - n, P4_INT32);//SQLITE_INT_TO_PTR(n) - Debug.Assert(n <= pTab.nCol); - } - } else { - sqlite3TableLock(pParse, iDb, pTab.tnum, 0, pTab.zName); + if ( ( pLevel.plan.wsFlags & WHERE_IDX_ONLY ) == 0 + && ( wctrlFlags & WHERE_OMIT_OPEN ) == 0 ) + { + int op = pWInfo.okOnePass != 0 ? OP_OpenWrite : OP_OpenRead; + sqlite3OpenTable( pParse, pTabItem.iCursor, iDb, pTab, op ); + testcase( pTab.nCol == BMS - 1 ); + testcase( pTab.nCol == BMS ); + if ( 0 == pWInfo.okOnePass && pTab.nCol < BMS ) + { + Bitmask b = pTabItem.colUsed; + int n = 0; + for ( ; b != 0; b = b >> 1, n++ ) + { } + sqlite3VdbeChangeP4( v, sqlite3VdbeCurrentAddr( v ) - 1, + n, P4_INT32 );//SQLITE_INT_TO_PTR(n) + Debug.Assert( n <= pTab.nCol ); + } + } + else + { + sqlite3TableLock( pParse, iDb, pTab.tnum, 0, pTab.zName ); + } #if !SQLITE_OMIT_AUTOMATIC_INDEX - if ((pLevel.plan.wsFlags & WHERE_TEMP_INDEX) != 0) { - constructAutomaticIndex(pParse, pWC, pTabItem, notReady, pLevel); - } else + if ( ( pLevel.plan.wsFlags & WHERE_TEMP_INDEX ) != 0 ) + { + constructAutomaticIndex( pParse, pWC, pTabItem, notReady, pLevel ); + } + else #endif - if ((pLevel.plan.wsFlags & WHERE_INDEXED) != 0) { - Index pIx = pLevel.plan.u.pIdx; - KeyInfo pKey = sqlite3IndexKeyinfo(pParse, pIx); - int iIdxCur = pLevel.iIdxCur; - Debug.Assert(pIx.pSchema == pTab.pSchema); - Debug.Assert(iIdxCur >= 0); - sqlite3VdbeAddOp4(v, OP_OpenRead, iIdxCur, pIx.tnum, iDb, - pKey, P4_KEYINFO_HANDOFF); + if ( ( pLevel.plan.wsFlags & WHERE_INDEXED ) != 0 ) + { + Index pIx = pLevel.plan.u.pIdx; + KeyInfo pKey = sqlite3IndexKeyinfo( pParse, pIx ); + int iIdxCur = pLevel.iIdxCur; + Debug.Assert( pIx.pSchema == pTab.pSchema ); + Debug.Assert( iIdxCur >= 0 ); + sqlite3VdbeAddOp4( v, OP_OpenRead, iIdxCur, pIx.tnum, iDb, + pKey, P4_KEYINFO_HANDOFF ); #if SQLITE_DEBUG - VdbeComment(v, "%s", pIx.zName); + VdbeComment( v, "%s", pIx.zName ); #endif - } - sqlite3CodeVerifySchema(pParse, iDb); - notReady &= ~getMask(pWC.pMaskSet, pTabItem.iCursor); - } - pWInfo.iTop = sqlite3VdbeCurrentAddr(v); - //if( db.mallocFailed ) goto whereBeginError; + } + sqlite3CodeVerifySchema( pParse, iDb ); + notReady &= ~getMask( pWC.pMaskSet, pTabItem.iCursor ); + } + pWInfo.iTop = sqlite3VdbeCurrentAddr( v ); + //if( db.mallocFailed ) goto whereBeginError; - /* Generate the code to do the search. Each iteration of the for - ** loop below generates code for a single nested loop of the VM - ** program. - */ - notReady = ~(Bitmask)0; - for (i = 0; i < nTabList; i++) { - pLevel = pWInfo.a[i]; - explainOneScan(pParse, pTabList, pLevel, i, pLevel.iFrom, wctrlFlags); - notReady = codeOneLoopStart(pWInfo, i, wctrlFlags, notReady); - pWInfo.iContinue = pLevel.addrCont; - } + /* Generate the code to do the search. Each iteration of the for + ** loop below generates code for a single nested loop of the VM + ** program. + */ + notReady = ~(Bitmask)0; + for ( i = 0; i < nTabList; i++ ) + { + pLevel = pWInfo.a[i]; + explainOneScan( pParse, pTabList, pLevel, i, pLevel.iFrom, wctrlFlags ); + notReady = codeOneLoopStart( pWInfo, i, wctrlFlags, notReady ); + pWInfo.iContinue = pLevel.addrCont; + } #if SQLITE_TEST //* For testing and debugging use only */ /* Record in the query plan information about the current table @@ -5228,154 +5671,173 @@ u16 wctrlFlags /* One of the WHERE_* flags defined in sqliteInt.h */ nQPlan = 0; #endif //* SQLITE_TEST // Testing and debugging use only */ - /* Record the continuation address in the WhereInfo structure. Then - ** clean up and return. - */ - return pWInfo; + /* Record the continuation address in the WhereInfo structure. Then +** clean up and return. +*/ + return pWInfo; - /* Jump here if malloc fails */ - whereBeginError: - if (pWInfo != null) { - pParse.nQueryLoop = pWInfo.savedNQueryLoop; - whereInfoFree(db, pWInfo); - } - return null; - } + /* Jump here if malloc fails */ +whereBeginError: + if ( pWInfo != null ) + { + pParse.nQueryLoop = pWInfo.savedNQueryLoop; + whereInfoFree( db, pWInfo ); + } + return null; + } - /* - ** Generate the end of the WHERE loop. See comments on - ** sqlite3WhereBegin() for additional information. - */ - static void sqlite3WhereEnd(WhereInfo pWInfo) { - Parse pParse = pWInfo.pParse; - Vdbe v = pParse.pVdbe; - int i; - WhereLevel pLevel; - SrcList pTabList = pWInfo.pTabList; - sqlite3 db = pParse.db; + /* + ** Generate the end of the WHERE loop. See comments on + ** sqlite3WhereBegin() for additional information. + */ + static void sqlite3WhereEnd( WhereInfo pWInfo ) + { + Parse pParse = pWInfo.pParse; + Vdbe v = pParse.pVdbe; + int i; + WhereLevel pLevel; + SrcList pTabList = pWInfo.pTabList; + sqlite3 db = pParse.db; + + /* Generate loop termination code. + */ + sqlite3ExprCacheClear( pParse ); + for ( i = pWInfo.nLevel - 1; i >= 0; i-- ) + { + pLevel = pWInfo.a[i]; + sqlite3VdbeResolveLabel( v, pLevel.addrCont ); + if ( pLevel.op != OP_Noop ) + { + sqlite3VdbeAddOp2( v, pLevel.op, pLevel.p1, pLevel.p2 ); + sqlite3VdbeChangeP5( v, pLevel.p5 ); + } + if ( ( pLevel.plan.wsFlags & WHERE_IN_ABLE ) != 0 && pLevel.u._in.nIn > 0 ) + { + InLoop pIn; + int j; + sqlite3VdbeResolveLabel( v, pLevel.addrNxt ); + for ( j = pLevel.u._in.nIn; j > 0; j-- )//, pIn--) + { + pIn = pLevel.u._in.aInLoop[j - 1]; + sqlite3VdbeJumpHere( v, pIn.addrInTop + 1 ); + sqlite3VdbeAddOp2( v, OP_Next, pIn.iCur, pIn.addrInTop ); + sqlite3VdbeJumpHere( v, pIn.addrInTop - 1 ); + } + sqlite3DbFree( db, ref pLevel.u._in.aInLoop ); + } + sqlite3VdbeResolveLabel( v, pLevel.addrBrk ); + if ( pLevel.iLeftJoin != 0 ) + { + int addr; + addr = sqlite3VdbeAddOp1( v, OP_IfPos, pLevel.iLeftJoin ); + Debug.Assert( ( pLevel.plan.wsFlags & WHERE_IDX_ONLY ) == 0 + || ( pLevel.plan.wsFlags & WHERE_INDEXED ) != 0 ); + if ( ( pLevel.plan.wsFlags & WHERE_IDX_ONLY ) == 0 ) + { + sqlite3VdbeAddOp1( v, OP_NullRow, pTabList.a[i].iCursor ); + } + if ( pLevel.iIdxCur >= 0 ) + { + sqlite3VdbeAddOp1( v, OP_NullRow, pLevel.iIdxCur ); + } + if ( pLevel.op == OP_Return ) + { + sqlite3VdbeAddOp2( v, OP_Gosub, pLevel.p1, pLevel.addrFirst ); + } + else + { + sqlite3VdbeAddOp2( v, OP_Goto, 0, pLevel.addrFirst ); + } + sqlite3VdbeJumpHere( v, addr ); + } + } - /* Generate loop termination code. - */ - sqlite3ExprCacheClear(pParse); - for (i = pWInfo.nLevel - 1; i >= 0; i--) { - pLevel = pWInfo.a[i]; - sqlite3VdbeResolveLabel(v, pLevel.addrCont); - if (pLevel.op != OP_Noop) { - sqlite3VdbeAddOp2(v, pLevel.op, pLevel.p1, pLevel.p2); - sqlite3VdbeChangeP5(v, pLevel.p5); - } - if ((pLevel.plan.wsFlags & WHERE_IN_ABLE) != 0 && pLevel.u._in.nIn > 0) { - InLoop pIn; - int j; - sqlite3VdbeResolveLabel(v, pLevel.addrNxt); - for (j = pLevel.u._in.nIn; j > 0; j--)//, pIn--) - { - pIn = pLevel.u._in.aInLoop[j - 1]; - sqlite3VdbeJumpHere(v, pIn.addrInTop + 1); - sqlite3VdbeAddOp2(v, OP_Next, pIn.iCur, pIn.addrInTop); - sqlite3VdbeJumpHere(v, pIn.addrInTop - 1); - } - sqlite3DbFree(db, ref pLevel.u._in.aInLoop); - } - sqlite3VdbeResolveLabel(v, pLevel.addrBrk); - if (pLevel.iLeftJoin != 0) { - int addr; - addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel.iLeftJoin); - Debug.Assert((pLevel.plan.wsFlags & WHERE_IDX_ONLY) == 0 - || (pLevel.plan.wsFlags & WHERE_INDEXED) != 0); - if ((pLevel.plan.wsFlags & WHERE_IDX_ONLY) == 0) { - sqlite3VdbeAddOp1(v, OP_NullRow, pTabList.a[i].iCursor); - } - if (pLevel.iIdxCur >= 0) { - sqlite3VdbeAddOp1(v, OP_NullRow, pLevel.iIdxCur); - } - if (pLevel.op == OP_Return) { - sqlite3VdbeAddOp2(v, OP_Gosub, pLevel.p1, pLevel.addrFirst); - } else { - sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel.addrFirst); - } - sqlite3VdbeJumpHere(v, addr); - } - } + /* The "break" point is here, just past the end of the outer loop. + ** Set it. + */ + sqlite3VdbeResolveLabel( v, pWInfo.iBreak ); - /* The "break" point is here, just past the end of the outer loop. - ** Set it. - */ - sqlite3VdbeResolveLabel(v, pWInfo.iBreak); + /* Close all of the cursors that were opened by sqlite3WhereBegin. + */ + Debug.Assert( pWInfo.nLevel == 1 || pWInfo.nLevel == pTabList.nSrc ); + for ( i = 0; i < pWInfo.nLevel; i++ )// for(i=0, pLevel=pWInfo.a; i Yielder(IEnumerator iter) { if (MoveNextHelper(iter)) { while (!_fFinished) { while (PythonContext.Equal(GetKey(iter.Current), curKey)) { - if (!MoveNextHelper(iter)) { - _fFinished = true; - yield break; + if (!MoveNextHelper(iter)) { + _fFinished = true; + yield break; } } curKey = GetKey(iter.Current); @@ -531,9 +531,9 @@ private IEnumerator Yielder(IEnumerator iter) { private IEnumerator Grouper(IEnumerator iter, object curKey) { while (PythonContext.Equal(GetKey(iter.Current), curKey)) { yield return iter.Current; - if (!MoveNextHelper(iter)) { - _fFinished = true; - yield break; + if (!MoveNextHelper(iter)) { + _fFinished = true; + yield break; } } } @@ -658,7 +658,7 @@ public zip_longest(params object[] iterables) { } } - public zip_longest([ParamDictionary] IDictionary paramDict, params object[] iterables) { + public zip_longest([ParamDictionary]IDictionary paramDict, params object[] iterables) { object fill; if (paramDict.TryGetValue("fillvalue", out fill)) { @@ -747,7 +747,7 @@ public product(CodeContext context, params object[] iterables) { InnerEnumerator = Yielder(ArrayUtils.ConvertAll(iterables, x => new PythonList(context, PythonOps.GetEnumerator(x)))); } - public product(CodeContext context, [ParamDictionary] IDictionary paramDict, params object[] iterables) { + public product(CodeContext context, [ParamDictionary]IDictionary paramDict, params object[] iterables) { object repeat; int iRepeat = 1; if (paramDict.TryGetValue("repeat", out repeat)) { @@ -970,7 +970,7 @@ public permutations(CodeContext context, object iterable) { public permutations(CodeContext context, object iterable, object r) { _data = new PythonList(context, iterable); - + InnerEnumerator = Yielder(GetR(r, _data)); } @@ -1133,9 +1133,9 @@ IEnumerator IEnumerable.GetEnumerator() { #endregion } - + [PythonType] - public class starmap : IterBase { + public class starmap : IterBase { public starmap(CodeContext context, object function, object iterable) { InnerEnumerator = Yielder(context, function, PythonOps.GetEnumerator(iterable)); } @@ -1194,7 +1194,7 @@ public void __setstate__(object state) { private IEnumerator Yielder(object predicate, IEnumerator iter) { while (MoveNextHelper(iter)) { - if (!Converter.ConvertToBoolean( + if(!Converter.ConvertToBoolean( _context.LanguageContext.CallSplat(predicate, iter.Current) )) { break; diff --git a/src/ipy/IronPython.Modules/ModuleOps.cs b/src/ipy/IronPython.Modules/ModuleOps.cs index aab4c099f..c7441cb3b 100644 --- a/src/ipy/IronPython.Modules/ModuleOps.cs +++ b/src/ipy/IronPython.Modules/ModuleOps.cs @@ -10,13 +10,14 @@ using System.Numerics; using System.Runtime.InteropServices; +using Microsoft.Scripting; +using Microsoft.Scripting.Utils; + using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting.Utils; - namespace IronPython.Modules { /// /// Provides helper functions which need to be called from generated code to implement various @@ -91,7 +92,7 @@ public static CTypes.CData CheckSimpleCDataType(object o, object type) { bool valid = true; // if we have an array, we can also send a pointer as long as the element types // for the pointer and array are the same - if (res != null && res.NativeType is CTypes.ArrayType at) { + if(res != null && res.NativeType is CTypes.ArrayType at) { valid = ((type is CTypes.ArrayType t) && (t.ElementType == at.ElementType)) || ((type is CTypes.PointerType p) && (p._type == at.ElementType)); } @@ -108,7 +109,7 @@ public static CTypes.CData CheckSimpleCDataType(object o, object type) { if (res == null && PythonOps.TryGetBoundAttr(o, "_as_parameter_", out object asParam)) { res = asParam as CTypes._CFuncPtr; } - + if (res == null || res.NativeType != type) { throw ArgumentError(type, ((PythonType)type).Name, o); } @@ -296,14 +297,14 @@ public static IntPtr GetPointer(object value) { } if (value is int iVal) { - if (iVal > int.MaxValue) { + if(iVal > int.MaxValue) { iVal = -1; } return new IntPtr(iVal); } if (value is BigInteger bigVal) { - if (bigVal > long.MaxValue) { + if(bigVal > long.MaxValue) { bigVal = -1; } return new IntPtr((long)bigVal); diff --git a/src/ipy/IronPython.Modules/NtSignalState.cs b/src/ipy/IronPython.Modules/NtSignalState.cs index 9b87ecd5b..2bc1ec812 100644 --- a/src/ipy/IronPython.Modules/NtSignalState.cs +++ b/src/ipy/IronPython.Modules/NtSignalState.cs @@ -102,7 +102,7 @@ internal static class NativeSignal { [DllImport("Kernel32")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool SetConsoleCtrlHandler(WinSignalsHandler Handler, [MarshalAs(UnmanagedType.Bool)] bool Add); + internal static extern bool SetConsoleCtrlHandler(WinSignalsHandler Handler, [MarshalAs(UnmanagedType.Bool)]bool Add); [DllImport("Kernel32")] [return: MarshalAs(UnmanagedType.Bool)] diff --git a/src/ipy/IronPython.Modules/Properties/AssemblyInfo.cs b/src/ipy/IronPython.Modules/Properties/AssemblyInfo.cs index 994510a64..2f5435278 100644 --- a/src/ipy/IronPython.Modules/Properties/AssemblyInfo.cs +++ b/src/ipy/IronPython.Modules/Properties/AssemblyInfo.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; diff --git a/src/ipy/IronPython.Modules/ResourceMetaPathImporter.cs b/src/ipy/IronPython.Modules/ResourceMetaPathImporter.cs index 55ed53f31..a3c444e2d 100644 --- a/src/ipy/IronPython.Modules/ResourceMetaPathImporter.cs +++ b/src/ipy/IronPython.Modules/ResourceMetaPathImporter.cs @@ -3,11 +3,9 @@ using System.IO; using System.Linq; using System.Reflection; - using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Zlib; - using Microsoft.Scripting; using Microsoft.Scripting.Runtime; @@ -133,7 +131,8 @@ public object load_module(CodeContext /*!*/ context, string fullname) { modules.Add(fullname, mod); try { script.Run(mod.Scope); - } catch (Exception) { + } + catch (Exception) { modules.Remove(fullname); throw; } @@ -176,7 +175,8 @@ private byte[] GetCodeFromData(CodeContext /*!*/ context, bool isbytecode, Packe if (data != null) { if (isbytecode) { // would put in code to unmarshal the bytecode here... - } else { + } + else { code = data; } } @@ -221,8 +221,8 @@ public static PackedResourceInfo Create(string fullName, int compress, #if DEBUG public override string ToString() { var sizeDesc = String.Format("{0} bytes", _fileSize); - if (Convert.ToDouble(_fileSize) / 1024.0 > 1.0) - sizeDesc = String.Format("{0} KB", Math.Round(Convert.ToDouble(_fileSize) / 1024.0, 1)); + if (Convert.ToDouble(_fileSize)/1024.0 > 1.0) + sizeDesc = String.Format("{0} KB", Math.Round(Convert.ToDouble(_fileSize)/1024.0, 1)); return String.Format("{0} ({1})", FullName, sizeDesc); } #endif @@ -259,25 +259,26 @@ where isPyFile let path = lineage.Take(lineage.Length - 1).ToArray() orderby fileName select new { - name = fileName, - path, - dottedPath = String.Join(".", path), - entry - }; + name = fileName, + path, + dottedPath = String.Join(".", path), + entry + }; var moduleContents = from source in parsedSources orderby source.dottedPath group source by source.dottedPath into moduleGroup select new { - moduleGroup.Key, - Items = moduleGroup.Select(item => item.entry).ToArray() - }; + moduleGroup.Key, + Items = moduleGroup.Select(item => item.entry).ToArray() + }; modules = moduleContents.ToDictionary( moduleGroup => moduleGroup.Key, moduleGroup => moduleGroup.Items); return true; - } catch (Exception exception) { + } + catch (Exception exception) { files = null; modules = null; unpackingError = String.Format("{0}: {1}", exception.GetType().Name, exception.Message); @@ -309,7 +310,7 @@ private bool ReadZipDirectory(out IDictionary result var endofCentralDir = new byte[22]; reader.BaseStream.Seek(-22, SeekOrigin.End); - var headerPosition = (int)reader.BaseStream.Position; + var headerPosition = (int) reader.BaseStream.Position; if (reader.Read(endofCentralDir, 0, 22) != 22) { unpackingError = "Can't read ZIP resource: Invalid ZIP Directory."; return false; @@ -331,7 +332,8 @@ private bool ReadZipDirectory(out IDictionary result .ToDictionary(entry => entry.FullName); return true; } - } catch (Exception exception) { + } + catch (Exception exception) { unpackingError = String.Format("{0}: {1}", exception.GetType().Name, exception.Message); return false; } @@ -408,19 +410,21 @@ public bool GetData(PackedResourceInfo tocEntry, out byte[] result, out string u byte[] rawData; try { rawData = reader.ReadBytes(compress == 0 ? dataSize : dataSize + 1); - } catch { + } + catch { unpackingError = "Can't read data"; return false; } if (compress != 0) { - rawData[dataSize] = (byte)'Z'; + rawData[dataSize] = (byte) 'Z'; } result = compress == 0 ? rawData : ZlibModule.Decompress(rawData, -15); return true; } - } catch (Exception exception) { + } + catch (Exception exception) { unpackingError = String.Format("{0}: {1}", exception.GetType().Name, exception.Message); return false; } diff --git a/src/ipy/IronPython.Modules/SimpleSignalState.cs b/src/ipy/IronPython.Modules/SimpleSignalState.cs index 784c5fbf2..c746290b3 100644 --- a/src/ipy/IronPython.Modules/SimpleSignalState.cs +++ b/src/ipy/IronPython.Modules/SimpleSignalState.cs @@ -1,5 +1,7 @@ using System; - +using System.Collections.Generic; +using System.Linq; +using System.Text; using IronPython.Runtime; #if FEATURE_PROCESS @@ -14,7 +16,7 @@ public SimpleSignalState(PythonContext pc) private void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e) { int pySignal; - switch (e.SpecialKey) { + switch(e.SpecialKey) { case ConsoleSpecialKey.ControlC: pySignal = SIGINT; break; @@ -26,7 +28,7 @@ private void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e) { default: throw new InvalidOperationException("unreachable"); } - + lock (PySignalToPyHandler) { if (PySignalToPyHandler[pySignal].GetType() == typeof(int)) { int tempId = (int)PySignalToPyHandler[pySignal]; diff --git a/src/ipy/IronPython.Modules/_bisect.cs b/src/ipy/IronPython.Modules/_bisect.cs index b90a79ea1..1468699d9 100644 --- a/src/ipy/IronPython.Modules/_bisect.cs +++ b/src/ipy/IronPython.Modules/_bisect.cs @@ -6,14 +6,14 @@ using System.Collections; using System.Reflection; -using IronPython.Runtime; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + [assembly: PythonModule("_bisect", typeof(IronPython.Modules.PythonBisectModule))] namespace IronPython.Modules { @@ -201,7 +201,7 @@ public static object bisect_left(CodeContext/*!*/ context, object a, object x, i Optional args lo (default 0) and hi (default len(a)) bound the slice of a to be searched. ")] - public static void InsortRight(CodeContext/*!*/ context, object a, object x, int lo = 0, int hi = -1) { + public static void InsortRight(CodeContext/*!*/ context, object a, object x, int lo=0, int hi=-1) { if (a is PythonList l && l.GetType() == typeof(PythonList)) { l.Insert(InternalBisectRight(context, l, x, lo, hi), x); return; @@ -227,7 +227,7 @@ public static void InsortRight(CodeContext/*!*/ context, object a, object x, int Optional args lo (default 0) and hi (default len(a)) bound the slice of a to be searched. ")] - public static void insort_left(CodeContext/*!*/ context, object a, object x, int lo = 0, int hi = -1) { + public static void insort_left(CodeContext/*!*/ context, object a, object x, int lo=0, int hi=-1) { if (a is PythonList l && l.GetType() == typeof(PythonList)) { l.Insert(InternalBisectLeft(context, l, x, lo, hi), x); return; diff --git a/src/ipy/IronPython.Modules/_codecs.cs b/src/ipy/IronPython.Modules/_codecs.cs index 991362b82..277b74160 100644 --- a/src/ipy/IronPython.Modules/_codecs.cs +++ b/src/ipy/IronPython.Modules/_codecs.cs @@ -161,7 +161,8 @@ public static PythonTuple escape_decode([NotNone] IBufferProtocol data, string? Func?>? eh = null; return delegate (in ReadOnlySpan data, int start, int end, string message) { - eh ??= errors switch { + eh ??= errors switch + { "strict" => idx => throw PythonOps.ValueError(@"invalid \x escape at position {0}", idx), "replace" => idx => _replacementMarker ??= new[] { (byte)'?' }, "ignore" => idx => null, diff --git a/src/ipy/IronPython.Modules/_codecs_cn.cs b/src/ipy/IronPython.Modules/_codecs_cn.cs index 76d712608..9836d2887 100644 --- a/src/ipy/IronPython.Modules/_codecs_cn.cs +++ b/src/ipy/IronPython.Modules/_codecs_cn.cs @@ -2,6 +2,13 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; +using System.Collections.Generic; +using System.Text; +using System.Runtime.InteropServices; +using IronPython.Runtime; +using IronPython.Runtime.Operations; + #if FALSE [assembly: PythonModule("_codecs_cn", typeof(IronPython.Modules._codecs_cn))] namespace IronPython.Modules { diff --git a/src/ipy/IronPython.Modules/_collections.cs b/src/ipy/IronPython.Modules/_collections.cs index ada192949..f0f838ba4 100644 --- a/src/ipy/IronPython.Modules/_collections.cs +++ b/src/ipy/IronPython.Modules/_collections.cs @@ -10,16 +10,17 @@ using System.Runtime.CompilerServices; using System.Text; -using IronPython.Runtime; -using IronPython.Runtime.Binding; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime; +using IronPython.Runtime.Binding; +using IronPython.Runtime.Exceptions; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + [assembly: PythonModule("_collections", typeof(IronPython.Modules.PythonCollections))] namespace IronPython.Modules { public class PythonCollections { @@ -41,7 +42,7 @@ private deque(int maxlen) { _data = _maxLen < 0 ? new object[8] : new object[Math.Min(_maxLen, 8)]; } - public static object __new__(CodeContext/*!*/ context, PythonType cls, [ParamDictionary] IDictionary dict, params object[] args) { + public static object __new__(CodeContext/*!*/ context, PythonType cls, [ParamDictionary]IDictionary dict, params object[] args) { if (cls == DynamicHelpers.GetPythonTypeFromType(typeof(deque))) return new deque(); return cls.CreateInstance(context); } @@ -51,7 +52,7 @@ public void __init__() { clear(); } - public void __init__([ParamDictionary] IDictionary dict) { + public void __init__([ParamDictionary]IDictionary dict) { _maxLen = VerifyMaxLen(dict); clear(); } @@ -64,12 +65,12 @@ public void __init__(object iterable) { public void __init__(object iterable, object maxlen) { _maxLen = VerifyMaxLenValue(maxlen); - + clear(); extend(iterable); } - public void __init__(object iterable, [ParamDictionary] IDictionary dict) { + public void __init__(object iterable, [ParamDictionary]IDictionary dict) { if (VerifyMaxLen(dict) < 0) { __init__(iterable); } else { @@ -81,7 +82,7 @@ private static int VerifyMaxLen(IDictionary dict) { if (dict.Count != 1) { throw PythonOps.TypeError("deque() takes at most 1 keyword argument ({0} given)", dict.Count); } - + object value; if (!dict.TryGetValue("maxlen", out value)) { IEnumerator e = dict.Keys.GetEnumerator(); @@ -104,7 +105,7 @@ private static int VerifyMaxLenValue(object value) { Extensible ebi => (int)ebi.Value, _ => throw PythonOps.TypeError("an integer is required") }; - + if (res < 0) throw PythonOps.ValueError("maxlen must be non-negative"); return res; @@ -424,7 +425,7 @@ public void rotate(CodeContext/*!*/ context, object n) { // too bad, we got gaps, looks like we'll be doing some real work. object[] newData = new object[_itemCnt]; // we re-size to itemCnt so that future rotates don't require work int curWriteIndex = rot; - WalkDeque(delegate (int curIndex) { + WalkDeque(delegate(int curIndex) { newData[curWriteIndex] = _data[curIndex]; curWriteIndex = (curWriteIndex + 1) % _itemCnt; return true; @@ -533,7 +534,7 @@ public void __delitem__(CodeContext/*!*/ context, object index) { // we'll just recreate our data by walking the data once. object[] newData = new object[_data.Length]; int writeIndex = 0; - WalkDeque(delegate (int curIndex) { + WalkDeque(delegate(int curIndex) { if (curIndex != realIndex) { newData[writeIndex++] = _data[curIndex]; } @@ -554,7 +555,7 @@ public PythonTuple __reduce__() { lock (_lockObj) { object[] items = new object[_itemCnt]; int curItem = 0; - WalkDeque(delegate (int curIndex) { + WalkDeque(delegate(int curIndex) { items[curItem++] = _data[curIndex]; return true; }); @@ -931,7 +932,7 @@ private bool WalkDeque(DequeWalker walker) { string comma = ""; lock (_lockObj) { - WalkDeque(delegate (int index) { + WalkDeque(delegate(int index) { sb.Append(comma); sb.Append(PythonOps.Repr(context, _data[index])); comma = ", "; @@ -1166,7 +1167,7 @@ public void __init__(CodeContext/*!*/ context, object default_factory, [NotNone] public void __init__(CodeContext/*!*/ context, object default_factory, [ParamDictionary, NotNone] IDictionary dict, [NotNone] params object[] args) { __init__(context, default_factory, args); - foreach (KeyValuePair kvp in dict) { + foreach (KeyValuePair kvp in dict) { this[kvp.Key] = kvp.Value; } } diff --git a/src/ipy/IronPython.Modules/_csv.cs b/src/ipy/IronPython.Modules/_csv.cs index eda531097..9623552b7 100644 --- a/src/ipy/IronPython.Modules/_csv.cs +++ b/src/ipy/IronPython.Modules/_csv.cs @@ -319,7 +319,7 @@ public static Dialect Create(CodeContext/*!*/ context, public void DeleteMember(CodeContext/*!*/ context, string name) { if (string.Equals(name, "delimiter") || string.Equals(name, "skipinitialspace") || - string.Equals(name, "doublequote") || + string.Equals(name, "doublequote")|| string.Equals(name, "strict") || string.Equals(name, "escapechar") || string.Equals(name, "lineterminator") || diff --git a/src/ipy/IronPython.Modules/_ctypes/Array.cs b/src/ipy/IronPython.Modules/_ctypes/Array.cs index 8d8cd2348..cec1619b3 100644 --- a/src/ipy/IronPython.Modules/_ctypes/Array.cs +++ b/src/ipy/IronPython.Modules/_ctypes/Array.cs @@ -7,6 +7,7 @@ using System.Collections; using System.Collections.Generic; using System.Diagnostics; +using System.Numerics; using System.Text; using IronPython.Runtime; diff --git a/src/ipy/IronPython.Modules/_ctypes/ArrayType.cs b/src/ipy/IronPython.Modules/_ctypes/ArrayType.cs index c36cd44fd..72dc3838a 100644 --- a/src/ipy/IronPython.Modules/_ctypes/ArrayType.cs +++ b/src/ipy/IronPython.Modules/_ctypes/ArrayType.cs @@ -9,6 +9,7 @@ using System.Diagnostics; using System.Numerics; using System.Reflection.Emit; +using System.Runtime.InteropServices; using IronPython.Runtime; using IronPython.Runtime.Operations; diff --git a/src/ipy/IronPython.Modules/_ctypes/CData.cs b/src/ipy/IronPython.Modules/_ctypes/CData.cs index 6eff67f5e..147061c25 100644 --- a/src/ipy/IronPython.Modules/_ctypes/CData.cs +++ b/src/ipy/IronPython.Modules/_ctypes/CData.cs @@ -13,6 +13,7 @@ using System.Threading; using IronPython.Runtime; +using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; @@ -72,7 +73,7 @@ internal void SetAddress(IntPtr address) { internal void InitializeFromBuffer(object? data, int offset, int size) { var bp = data as IBufferProtocol ?? throw PythonOps.TypeErrorForBadInstance("{0} object does not have the buffer interface", data); - // Python 3.5: PythonOps.TypeErrorForBytesLikeTypeMismatch(data); + // Python 3.5: PythonOps.TypeErrorForBytesLikeTypeMismatch(data); IPythonBuffer buffer = bp.GetBuffer(BufferFlags.FullRO); if (buffer.IsReadOnly) { @@ -97,7 +98,7 @@ internal void InitializeFromBuffer(object? data, int offset, int size) { internal void InitializeFromBufferCopy(object? data, int offset, int size) { var bp = data as IBufferProtocol ?? throw PythonOps.TypeErrorForBadInstance("{0} object does not have the buffer interface", data); - // Python 3.5: PythonOps.TypeErrorForBytesLikeTypeMismatch(data); + // Python 3.5: PythonOps.TypeErrorForBytesLikeTypeMismatch(data); using IPythonBuffer buffer = bp.GetBuffer(); var span = buffer.AsReadOnlySpan(); diff --git a/src/ipy/IronPython.Modules/_ctypes/CFuncPtrType.cs b/src/ipy/IronPython.Modules/_ctypes/CFuncPtrType.cs index fa1f4dfb3..4e0d81143 100644 --- a/src/ipy/IronPython.Modules/_ctypes/CFuncPtrType.cs +++ b/src/ipy/IronPython.Modules/_ctypes/CFuncPtrType.cs @@ -12,14 +12,15 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using IronPython.Runtime; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - +using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Utils; +using IronPython.Runtime; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + namespace IronPython.Modules { /// /// Provides support for interop with native code from Python code. @@ -186,7 +187,7 @@ internal Delegate MakeReverseDelegate(CodeContext/*!*/ context, object target) { return _reverseDelegate.CreateDelegate(_reverseDelegateType, constantPool); } - + private void MakeReverseDelegateWorker(CodeContext context) { Type[] sigTypes; Type[] callSiteType; @@ -222,7 +223,7 @@ private void MakeReverseDelegateWorker(CodeContext context) { // load code context int contextIndex = constantPool.Count; Debug.Assert(pc.SharedContext != null); - constantPool.Add(pc.SharedContext); + constantPool.Add(pc.SharedContext); ilGen.Emit(OpCodes.Ldarg_0); ilGen.Emit(OpCodes.Ldc_I4, contextIndex); ilGen.Emit(OpCodes.Ldelem_Ref); diff --git a/src/ipy/IronPython.Modules/_ctypes/Field.cs b/src/ipy/IronPython.Modules/_ctypes/Field.cs index d4f2a0e5e..9b38b43e5 100644 --- a/src/ipy/IronPython.Modules/_ctypes/Field.cs +++ b/src/ipy/IronPython.Modules/_ctypes/Field.cs @@ -8,12 +8,12 @@ using System.Diagnostics; using System.Numerics; +using Microsoft.Scripting.Runtime; + using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting.Runtime; - namespace IronPython.Modules { /// /// Provides support for interop with native code from Python code. diff --git a/src/ipy/IronPython.Modules/_ctypes/MarshalCleanup.cs b/src/ipy/IronPython.Modules/_ctypes/MarshalCleanup.cs index f2256dec2..6db8a3eb7 100644 --- a/src/ipy/IronPython.Modules/_ctypes/MarshalCleanup.cs +++ b/src/ipy/IronPython.Modules/_ctypes/MarshalCleanup.cs @@ -4,6 +4,8 @@ #if FEATURE_LCG +using System; +using System.Reflection; using System.Reflection.Emit; using System.Runtime.InteropServices; diff --git a/src/ipy/IronPython.Modules/_ctypes/MemoryHolder.cs b/src/ipy/IronPython.Modules/_ctypes/MemoryHolder.cs index aeee5fe79..ff0872b26 100644 --- a/src/ipy/IronPython.Modules/_ctypes/MemoryHolder.cs +++ b/src/ipy/IronPython.Modules/_ctypes/MemoryHolder.cs @@ -165,24 +165,24 @@ public byte ReadByte(int offset) { return res; } - public short ReadInt16(int offset, bool swap = false) { + public short ReadInt16(int offset, bool swap=false) { short res = Marshal.ReadInt16(_data, offset); GC.KeepAlive(this); - if (swap) res = Swap(res); + if(swap) res = Swap(res); return res; } - public int ReadInt32(int offset, bool swap = false) { + public int ReadInt32(int offset, bool swap=false) { int res = Marshal.ReadInt32(_data, offset); GC.KeepAlive(this); - if (swap) res = Swap(res); + if(swap) res = Swap(res); return res; } - public long ReadInt64(int offset, bool swap = false) { + public long ReadInt64(int offset, bool swap=false) { long res = Marshal.ReadInt64(_data, offset); GC.KeepAlive(this); - if (swap) res = Swap(res); + if(swap) res = Swap(res); return res; } @@ -240,7 +240,7 @@ internal static Bytes ReadBytes(IntPtr addr, int offset, int length) { // ptrToStringAnsi gives special treatment to values >= 128. MemoryStream res = new MemoryStream(); byte b; - while ((b = Marshal.ReadByte(addr, offset++)) != 0) { + while((b = Marshal.ReadByte(addr, offset++)) != 0) { res.WriteByte(b); } return Bytes.Make(res.ToArray()); @@ -259,17 +259,17 @@ public void WriteByte(int offset, byte value) { GC.KeepAlive(this); } - public void WriteInt16(int offset, short value, bool swap = false) { + public void WriteInt16(int offset, short value, bool swap=false) { Marshal.WriteInt16(_data, offset, swap ? Swap(value) : value); GC.KeepAlive(this); } - public void WriteInt32(int offset, int value, bool swap = false) { + public void WriteInt32(int offset, int value, bool swap=false) { Marshal.WriteInt32(_data, offset, swap ? Swap(value) : value); GC.KeepAlive(this); } - public void WriteInt64(int offset, long value, bool swap = false) { + public void WriteInt64(int offset, long value, bool swap=false) { Marshal.WriteInt64(_data, offset, swap ? Swap(value) : value); GC.KeepAlive(this); } diff --git a/src/ipy/IronPython.Modules/_ctypes/NativeArgument.cs b/src/ipy/IronPython.Modules/_ctypes/NativeArgument.cs index ca58cdff0..880d097d2 100644 --- a/src/ipy/IronPython.Modules/_ctypes/NativeArgument.cs +++ b/src/ipy/IronPython.Modules/_ctypes/NativeArgument.cs @@ -6,16 +6,16 @@ using System; +using Microsoft.Scripting.Runtime; + using IronPython.Runtime; using IronPython.Runtime.Types; -using Microsoft.Scripting.Runtime; - namespace IronPython.Modules { /// /// Provides support for interop with native code from Python code. /// - public static partial class CTypes { + public static partial class CTypes { // returned from from_param, byref, seemingly called "cparam", but type() says CArgObject in CPython [PythonType, PythonHidden] public sealed class NativeArgument : ICodeFormattable { diff --git a/src/ipy/IronPython.Modules/_ctypes/Pointer.cs b/src/ipy/IronPython.Modules/_ctypes/Pointer.cs index aa9c27afc..cb36feecf 100644 --- a/src/ipy/IronPython.Modules/_ctypes/Pointer.cs +++ b/src/ipy/IronPython.Modules/_ctypes/Pointer.cs @@ -44,7 +44,7 @@ public object contents { CData res = (CData)elementType.CreateInstance(elementType.Context.SharedContext); res.MemHolder = MemHolder.ReadMemoryHolder(0); - if (res.MemHolder.UnsafeAddress == IntPtr.Zero) { + if(res.MemHolder.UnsafeAddress == IntPtr.Zero) { throw PythonOps.ValueError("NULL value access"); } return res; diff --git a/src/ipy/IronPython.Modules/_ctypes/PointerType.cs b/src/ipy/IronPython.Modules/_ctypes/PointerType.cs index 26fa69abc..197863398 100644 --- a/src/ipy/IronPython.Modules/_ctypes/PointerType.cs +++ b/src/ipy/IronPython.Modules/_ctypes/PointerType.cs @@ -9,12 +9,13 @@ using System.Numerics; using System.Reflection.Emit; +using Microsoft.Scripting; +using Microsoft.Scripting.Runtime; + using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting.Runtime; - namespace IronPython.Modules { /// /// Provides support for interop with native code from Python code. @@ -123,7 +124,7 @@ object INativeType.SetValue(MemoryHolder address, int offset, object value) { _Array array; if (value == null) { address.WriteIntPtr(offset, IntPtr.Zero); - } else if (value is int) { + } else if (value is int) { address.WriteIntPtr(offset, new IntPtr((int)value)); } else if (value is BigInteger) { address.WriteIntPtr(offset, new IntPtr((long)(BigInteger)value)); @@ -160,7 +161,7 @@ MarshalCleanup INativeType.EmitMarshalling(ILGenerator/*!*/ method, LocalOrArg a method.MarkLabel(nextTry); nextTry = method.DefineLabel(); - + argIndex.Emit(method); if (argumentType.IsValueType) { method.Emit(OpCodes.Box, argumentType); @@ -171,7 +172,7 @@ MarshalCleanup INativeType.EmitMarshalling(ILGenerator/*!*/ method, LocalOrArg a MarshalCleanup res = null; if (st != null && !argIndex.Type.IsValueType) { if (st._type == SimpleTypeKind.Char || st._type == SimpleTypeKind.WChar) { - + if (st._type == SimpleTypeKind.Char) { SimpleType.TryToCharPtrConversion(method, argIndex, argumentType, done); } else { diff --git a/src/ipy/IronPython.Modules/_ctypes/SimpleCData.cs b/src/ipy/IronPython.Modules/_ctypes/SimpleCData.cs index 6839c8fc6..9bb1cb126 100644 --- a/src/ipy/IronPython.Modules/_ctypes/SimpleCData.cs +++ b/src/ipy/IronPython.Modules/_ctypes/SimpleCData.cs @@ -9,12 +9,12 @@ using System.Numerics; using System.Runtime.CompilerServices; +using Microsoft.Scripting.Runtime; + using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting.Runtime; - namespace IronPython.Modules { /// /// Provides support for interop with native code from Python code. @@ -36,8 +36,9 @@ public void __init__() { } public void __init__(CodeContext/*!*/ context, object value) { - switch (((SimpleType)NativeType)._type) { - case SimpleTypeKind.Char: { + switch(((SimpleType)NativeType)._type) { + case SimpleTypeKind.Char: + { if (value is IList t && t.Count == 1) { value = Bytes.FromByte(t[0]); } else if (value is int i) { diff --git a/src/ipy/IronPython.Modules/_ctypes/SimpleType.cs b/src/ipy/IronPython.Modules/_ctypes/SimpleType.cs index 22cba6f1c..a071c2118 100644 --- a/src/ipy/IronPython.Modules/_ctypes/SimpleType.cs +++ b/src/ipy/IronPython.Modules/_ctypes/SimpleType.cs @@ -13,6 +13,7 @@ using System.Runtime.InteropServices; using IronPython.Runtime; +using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; @@ -253,7 +254,7 @@ object INativeType.SetValue(MemoryHolder/*!*/ owner, int offset, object value) { case SimpleTypeKind.SignedByte: owner.WriteByte(offset, ModuleOps.GetSignedByte(value, this)); break; case SimpleTypeKind.UnsignedByte: owner.WriteByte(offset, ModuleOps.GetUnsignedByte(value, this)); break; case SimpleTypeKind.WChar: owner.WriteInt16(offset, (short)ModuleOps.GetWChar(value, this)); break; - case SimpleTypeKind.SignedShort: owner.WriteInt16(offset, ModuleOps.GetSignedShort(value, this), _swap); break; + case SimpleTypeKind.SignedShort: owner.WriteInt16(offset, ModuleOps.GetSignedShort(value, this), _swap); break; case SimpleTypeKind.UnsignedShort: owner.WriteInt16(offset, ModuleOps.GetUnsignedShort(value, this), _swap); break; case SimpleTypeKind.VariantBool: owner.WriteInt16(offset, (short)ModuleOps.GetVariantBool(value, this), _swap); break; case SimpleTypeKind.SignedInt: owner.WriteInt32(offset, ModuleOps.GetSignedInt(value, this), _swap); break; @@ -523,7 +524,8 @@ internal static void MarshalWCharPointer(ILGenerator method, LocalOrArg argIndex method.Emit(OpCodes.Ldc_I4, RuntimeHelpers.OffsetToStringData); #pragma warning restore CS0618 // Type or member is obsolete method.Emit(OpCodes.Add); - } else { + } + else { method.Emit(OpCodes.Call, StringGetPinnableReference); } method.Emit(OpCodes.Br, done); diff --git a/src/ipy/IronPython.Modules/_ctypes/SimpleTypeKind.cs b/src/ipy/IronPython.Modules/_ctypes/SimpleTypeKind.cs index 291a04658..995a248b3 100644 --- a/src/ipy/IronPython.Modules/_ctypes/SimpleTypeKind.cs +++ b/src/ipy/IronPython.Modules/_ctypes/SimpleTypeKind.cs @@ -4,6 +4,8 @@ #if FEATURE_CTYPES +using System; + namespace IronPython.Modules { /// /// Provides support for interop with native code from Python code. diff --git a/src/ipy/IronPython.Modules/_ctypes/StructType.cs b/src/ipy/IronPython.Modules/_ctypes/StructType.cs index 77f3f2e4b..e4ffdafee 100644 --- a/src/ipy/IronPython.Modules/_ctypes/StructType.cs +++ b/src/ipy/IronPython.Modules/_ctypes/StructType.cs @@ -5,18 +5,20 @@ #if FEATURE_CTYPES using System; +using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Numerics; using System.Reflection.Emit; +using System.Runtime.InteropServices; using System.Text; +using Microsoft.Scripting; + using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting; - namespace IronPython.Modules { /// /// Provides support for interop with native code from Python code. diff --git a/src/ipy/IronPython.Modules/_ctypes/Structure.cs b/src/ipy/IronPython.Modules/_ctypes/Structure.cs index 4f7c23312..e3711c2d6 100644 --- a/src/ipy/IronPython.Modules/_ctypes/Structure.cs +++ b/src/ipy/IronPython.Modules/_ctypes/Structure.cs @@ -6,12 +6,12 @@ using System.Collections.Generic; +using Microsoft.Scripting; + using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting; - namespace IronPython.Modules { /// /// Provides support for interop with native code from Python code. @@ -53,7 +53,7 @@ public void __init__([NotNone] params object[] args) { st.SetValueInternal(MemHolder, 0, args); } - public void __init__(CodeContext/*!*/ context, [ParamDictionary] IDictionary kwargs) { + public void __init__(CodeContext/*!*/ context, [ParamDictionary]IDictionary kwargs) { CheckAbstract(); foreach (var x in kwargs) { diff --git a/src/ipy/IronPython.Modules/_ctypes/Union.cs b/src/ipy/IronPython.Modules/_ctypes/Union.cs index c5ef9c1f2..987dfdc8e 100644 --- a/src/ipy/IronPython.Modules/_ctypes/Union.cs +++ b/src/ipy/IronPython.Modules/_ctypes/Union.cs @@ -11,7 +11,7 @@ namespace IronPython.Modules { /// /// Provides support for interop with native code from Python code. /// - public static partial class CTypes { + public static partial class CTypes { [PythonType("Union")] public abstract class _Union : CData { public void __init__(CodeContext/*!*/ context) { diff --git a/src/ipy/IronPython.Modules/_ctypes/UnionType.cs b/src/ipy/IronPython.Modules/_ctypes/UnionType.cs index ac0b1202c..ce2e0c0b6 100644 --- a/src/ipy/IronPython.Modules/_ctypes/UnionType.cs +++ b/src/ipy/IronPython.Modules/_ctypes/UnionType.cs @@ -5,9 +5,12 @@ #if FEATURE_CTYPES using System; +using System.Collections; using System.Collections.Generic; using System.Reflection.Emit; +using Microsoft.Scripting; + using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; diff --git a/src/ipy/IronPython.Modules/_datetime.cs b/src/ipy/IronPython.Modules/_datetime.cs index 6066e8a4e..b3acc4d42 100644 --- a/src/ipy/IronPython.Modules/_datetime.cs +++ b/src/ipy/IronPython.Modules/_datetime.cs @@ -1037,7 +1037,8 @@ public override string strftime(CodeContext/*!*/ context, [NotNone] string dateF public double timestamp() { if (tzinfo is null) { return PythonTime.TicksToTimestamp(_dateTime.ToUniversalTime().Ticks); - } else { + } + else { return (this - new datetime(new DateTime(1970, 1, 1), timezone.utc)).total_seconds(); } } diff --git a/src/ipy/IronPython.Modules/_functools.cs b/src/ipy/IronPython.Modules/_functools.cs index ac573fd43..6bd2d9dd9 100644 --- a/src/ipy/IronPython.Modules/_functools.cs +++ b/src/ipy/IronPython.Modules/_functools.cs @@ -148,7 +148,7 @@ public PythonDictionary __dict__ { get { return EnsureDict(); } - [param: NotNone] + [param: NotNone] set { _dict = value; } diff --git a/src/ipy/IronPython.Modules/_heapq.cs b/src/ipy/IronPython.Modules/_heapq.cs index 7bae82b5a..a9c1f3b68 100644 --- a/src/ipy/IronPython.Modules/_heapq.cs +++ b/src/ipy/IronPython.Modules/_heapq.cs @@ -4,13 +4,14 @@ using System; using System.Collections; - +using System.Collections.Generic; +using System.Text; +using Microsoft.Scripting.Runtime; using IronPython.Runtime; +using IronPython.Runtime.Binding; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting.Runtime; - [assembly: PythonModule("_heapq", typeof(IronPython.Modules.PythonHeapq))] namespace IronPython.Modules { public static class PythonHeapq { diff --git a/src/ipy/IronPython.Modules/_multibytecodec.cs b/src/ipy/IronPython.Modules/_multibytecodec.cs index 242b36096..0c75d3880 100644 --- a/src/ipy/IronPython.Modules/_multibytecodec.cs +++ b/src/ipy/IronPython.Modules/_multibytecodec.cs @@ -2,6 +2,14 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; +using System.Collections.Generic; +using System.Text; +using System.Runtime.InteropServices; +using IronPython.Runtime; +using IronPython.Runtime.Operations; +using Microsoft.Scripting; + #if FALSE [assembly: PythonModule("_multibytecodec", typeof(IronPython.Modules._multibytecodec))] namespace IronPython.Modules { diff --git a/src/ipy/IronPython.Modules/_multiprocessing.cs b/src/ipy/IronPython.Modules/_multiprocessing.cs index fa624450b..63fcba0d5 100644 --- a/src/ipy/IronPython.Modules/_multiprocessing.cs +++ b/src/ipy/IronPython.Modules/_multiprocessing.cs @@ -7,6 +7,8 @@ using System.Runtime.InteropServices; using System.Runtime.Versioning; +using Microsoft.Win32.SafeHandles; + using IronPython.Runtime; [assembly: PythonModule("_multiprocessing", typeof(IronPython.Modules.MultiProcessing))] diff --git a/src/ipy/IronPython.Modules/_opcode.cs b/src/ipy/IronPython.Modules/_opcode.cs index cbddd04f2..03c654010 100644 --- a/src/ipy/IronPython.Modules/_opcode.cs +++ b/src/ipy/IronPython.Modules/_opcode.cs @@ -2,8 +2,19 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Numerics; +using System.Text; + +using Microsoft.Scripting.Utils; + using IronPython.Runtime; +using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; [assembly: PythonModule("_opcode", typeof(IronPython.Modules.PythonOpcode))] namespace IronPython.Modules { @@ -145,7 +156,7 @@ public static class PythonOpcode { private const int FVS_MASK = 0x4; private const int FVS_HAVE_SPEC = 0x4; - public static int stack_effect(CodeContext context, int opcode, object oparg = null) { + public static int stack_effect(CodeContext context, int opcode, object oparg=null) { int ioparg = 0; if (opcode >= HAVE_ARGUMENT) { diff --git a/src/ipy/IronPython.Modules/_random.cs b/src/ipy/IronPython.Modules/_random.cs index d2a0045c1..a77b7fdac 100644 --- a/src/ipy/IronPython.Modules/_random.cs +++ b/src/ipy/IronPython.Modules/_random.cs @@ -4,10 +4,10 @@ using System; using System.Linq; +using System.Numerics; using IronPython.Runtime; using IronPython.Runtime.Operations; - using Microsoft.Scripting.Utils; [assembly: PythonModule("_random", typeof(IronPython.Modules.PythonRandom))] diff --git a/src/ipy/IronPython.Modules/_socket.cs b/src/ipy/IronPython.Modules/_socket.cs index ff3f486df..9587d6864 100644 --- a/src/ipy/IronPython.Modules/_socket.cs +++ b/src/ipy/IronPython.Modules/_socket.cs @@ -1588,40 +1588,40 @@ public static void setdefaulttimeout(CodeContext/*!*/ context, object? timeout) // Darwin: man 3 gai_strerror // The specified network host does not have any network addresses in the requested address family. [PythonHidden(PlatformsAttribute.PlatformFamily.Windows)] - public static int EAI_ADDRFAMILY => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 1 : -9; + public static int EAI_ADDRFAMILY => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 1 : -9; // The name server returned a temporary failure indication. Try again later. - public static int EAI_AGAIN => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 2 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -3 : (int)SocketError.TryAgain; + public static int EAI_AGAIN => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 2 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -3 : (int)SocketError.TryAgain; // hints.ai_flags contains invalid flags. - public static int EAI_BADFLAGS => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 3 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -1 : (int)SocketError.InvalidArgument; + public static int EAI_BADFLAGS => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 3 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -1 : (int)SocketError.InvalidArgument; // The name server returned a permanent failure indication. - public static int EAI_FAIL => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 4 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -4 : (int)SocketError.NoRecovery; + public static int EAI_FAIL => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 4 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -4 : (int)SocketError.NoRecovery; // The requested address family is not supported. - public static int EAI_FAMILY => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 5 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -6 : (int)SocketError.AddressFamilyNotSupported; + public static int EAI_FAMILY => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 5 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -6 : (int)SocketError.AddressFamilyNotSupported; // Out of memory. - public static int EAI_MEMORY => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 6 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -10 : (int)SocketError.NoBufferSpaceAvailable; + public static int EAI_MEMORY => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 6 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -10 : (int)SocketError.NoBufferSpaceAvailable; // The specified network host exists, but does not have any network addresses defined. - public static int EAI_NODATA => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 7 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -5 : (int)SocketError.HostNotFound; // not SocketError.NoData, like you would think + public static int EAI_NODATA => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 7 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -5 : (int)SocketError.HostNotFound; // not SocketError.NoData, like you would think // The node or service is not known. - public static int EAI_NONAME => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 8 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -2 : (int)SocketError.HostNotFound; + public static int EAI_NONAME => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 8 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -2 : (int)SocketError.HostNotFound; // The requested service is not available for the requested socket type. - public static int EAI_SERVICE => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 9 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -8 : (int)SocketError.TypeNotFound; + public static int EAI_SERVICE => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 9 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -8 : (int)SocketError.TypeNotFound; // The requested socket type is not supported. - public static int EAI_SOCKTYPE => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 10 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -7 : (int)SocketError.SocketNotSupported; + public static int EAI_SOCKTYPE => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 10 : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? -7 : (int)SocketError.SocketNotSupported; // Other system error, check errno for details. [PythonHidden(PlatformsAttribute.PlatformFamily.Windows)] - public static int EAI_SYSTEM => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 11 : -11; + public static int EAI_SYSTEM => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 11 : -11; // Invalid value for hints. [PythonHidden(PlatformsAttribute.PlatformFamily.Windows, PlatformID.Unix)] - public static int EAI_BADHINTS => 12; + public static int EAI_BADHINTS => 12; // Resolved protocol is unknown. [PythonHidden(PlatformsAttribute.PlatformFamily.Windows, PlatformID.Unix)] - public static int EAI_PROTOCOL => 13; + public static int EAI_PROTOCOL => 13; // Argument buffer overflow. [PythonHidden(PlatformsAttribute.PlatformFamily.Windows)] - public static int EAI_OVERFLOW => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 14 : -12; + public static int EAI_OVERFLOW => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 14 : -12; // Maximum value of EAI_* erors plus one. [PythonHidden(PlatformsAttribute.PlatformFamily.Windows, PlatformID.Unix)] - public static int EAI_MAX => 15; + public static int EAI_MAX => 15; public const int INADDR_ALLHOSTS_GROUP = unchecked((int)0xe0000001); public const int INADDR_ANY = (int)0x00000000; @@ -1739,9 +1739,9 @@ public static void setdefaulttimeout(CodeContext/*!*/ context, object? timeout) #region Private implementation private static int HERROR_HOST_NOT_FOUND = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? (int)SocketError.HostNotFound : 1; - private static int HERROR_TRY_AGAIN = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? (int)SocketError.TryAgain : 2; - private static int HERROR_NO_RECOVERY = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? (int)SocketError.NoRecovery : 3; - private static int HERROR_NO_DATA = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? (int)SocketError.NoData : 4; + private static int HERROR_TRY_AGAIN = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? (int)SocketError.TryAgain : 2; + private static int HERROR_NO_RECOVERY = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? (int)SocketError.NoRecovery : 3; + private static int HERROR_NO_DATA = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? (int)SocketError.NoData : 4; /// /// Return a socket exception (socket.error, socket.timeout, socket.herror) based on the information in the existing exception. @@ -1842,7 +1842,7 @@ private static Exception MakeGaiException(CodeContext context, int eaiCode) { return PythonExceptions.CreateThrowable(gaierror(context), EAI_BADHINTS, "Bad hints"); } return MakeGaiException(context, EAI_SERVICE); - // TODO: Handle other defined codes (currently unused). Remap codes that are not available on a specific system. + // TODO: Handle other defined codes (currently unused). Remap codes that are not available on a specific system. } else { // fallback to generic error if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { @@ -2033,7 +2033,7 @@ private static IPAddress[] HostToAddresses(CodeContext/*!*/ context, string host if (addrs.Count > 0) return addrs.ToArray(); } throw MakeGaiException(context, EAI_NODATA); - } catch (SocketException ex) { + } catch (SocketException ex) { throw MakeGaiException(context, ex); } } diff --git a/src/ipy/IronPython.Modules/_ssl.cs b/src/ipy/IronPython.Modules/_ssl.cs index 431506fb3..499dc3789 100644 --- a/src/ipy/IronPython.Modules/_ssl.cs +++ b/src/ipy/IronPython.Modules/_ssl.cs @@ -640,10 +640,12 @@ public int read(CodeContext/*!*/ context, int size, [NotNone] IBufferProtocol bu var numRead = _sslStream.Read(buf, 0, size); buf.AsSpan(0, numRead).CopyTo(pythonBuffer.AsSpan()); return numRead; - } finally { + } + finally { ArrayPool.Return(buf); } - } else { + } + else { return _sslStream.Read(buf, 0, size); } #endif diff --git a/src/ipy/IronPython.Modules/_struct.cs b/src/ipy/IronPython.Modules/_struct.cs index 98bd84267..de4c8989b 100644 --- a/src/ipy/IronPython.Modules/_struct.cs +++ b/src/ipy/IronPython.Modules/_struct.cs @@ -9,15 +9,15 @@ using System.Runtime.CompilerServices; using System.Threading; +using Microsoft.Scripting; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - [assembly: PythonModule("_struct", typeof(IronPython.Modules.PythonStruct))] namespace IronPython.Modules { public static class PythonStruct { @@ -60,7 +60,7 @@ public Struct(params object[] args) { } [Documentation("creates a new uninitialized struct object - all arguments are ignored")] - public Struct([ParamDictionary] IDictionary kwArgs, params object[] args) { + public Struct([ParamDictionary]IDictionary kwArgs, params object[] args) { } [Documentation("initializes or re-initializes the compiled struct object with a new format")] diff --git a/src/ipy/IronPython.Modules/_warnings.cs b/src/ipy/IronPython.Modules/_warnings.cs index b1d712257..ae37101c8 100644 --- a/src/ipy/IronPython.Modules/_warnings.cs +++ b/src/ipy/IronPython.Modules/_warnings.cs @@ -3,18 +3,20 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.IO; using System.Numerics; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; using System.Text; - +using System.Text.RegularExpressions; using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; - using Microsoft.Scripting; using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; [assembly: PythonModule("_warnings", typeof(IronPython.Modules.PythonWarnings))] namespace IronPython.Modules { @@ -52,7 +54,7 @@ public static void PerformModuleReload(PythonContext/*!*/ context, PythonDiction public static void _filters_mutated() { } // TODO: do something with this - public static void warn(CodeContext context, object message, PythonType category = null, int stacklevel = 1) { + public static void warn(CodeContext context, object message, PythonType category=null, int stacklevel=1) { PythonContext pContext = context.LanguageContext; PythonList argv = pContext.GetSystemStateValue("argv") as PythonList; @@ -109,7 +111,7 @@ public static void warn(CodeContext context, object message, PythonType category warn_explicit(context, message, category, filename, lineno, module, registry, globals); } - public static void warn_explicit(CodeContext context, object message, PythonType category, string filename, int lineno, string module = null, PythonDictionary registry = null, object module_globals = null) { + public static void warn_explicit(CodeContext context, object message, PythonType category, string filename, int lineno, string module=null, PythonDictionary registry=null, object module_globals=null) { PythonContext pContext = context.LanguageContext; PythonDictionary fields = (PythonDictionary)pContext.GetModuleState(_keyFields); object warnings = pContext.GetWarningsModule(); @@ -146,7 +148,7 @@ public static void warn_explicit(CodeContext context, object message, PythonType PythonList filters = (PythonList)fields[_keyFilters]; if (warnings != null) { filters = PythonOps.GetBoundAttr(context, warnings, "filters") as PythonList; - if (filters == null) { + if(filters == null) { throw PythonOps.ValueError("_warnings.filters must be a list"); } } @@ -210,7 +212,7 @@ public static void warn_explicit(CodeContext context, object message, PythonType if (warnings != null) { object show_fxn = PythonOps.GetBoundAttr(context, warnings, "showwarning"); - if (show_fxn != null) { + if(show_fxn != null) { PythonCalls.Call( context, show_fxn, @@ -223,7 +225,7 @@ public static void warn_explicit(CodeContext context, object message, PythonType } } - internal static string formatwarning(object message, PythonType category, string filename, int lineno, string line = null) { + internal static string formatwarning(object message, PythonType category, string filename, int lineno, string line=null) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("{0}:{1}: {2}: {3}\n", filename, lineno, category.Name, message); if (line == null && lineno > 0 && File.Exists(filename)) { @@ -239,7 +241,7 @@ internal static string formatwarning(object message, PythonType category, string return sb.ToString(); } - internal static void showwarning(CodeContext context, object message, PythonType category, string filename, int lineno, object file = null, string line = null) { + internal static void showwarning(CodeContext context, object message, PythonType category, string filename, int lineno, object file=null, string line=null) { string text = formatwarning(message, category, filename, lineno, line); try { diff --git a/src/ipy/IronPython.Modules/_weakref.cs b/src/ipy/IronPython.Modules/_weakref.cs index 787b8884b..838fe71ae 100644 --- a/src/ipy/IronPython.Modules/_weakref.cs +++ b/src/ipy/IronPython.Modules/_weakref.cs @@ -8,10 +8,12 @@ using System.Runtime.CompilerServices; using IronPython.Runtime; +using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; using Microsoft.Scripting; +using Microsoft.Scripting.Actions; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; @@ -74,7 +76,8 @@ public static void _remove_dead_weakref(CodeContext context, PythonDictionary di public static readonly PythonType ReferenceType = DynamicHelpers.GetPythonTypeFromType(typeof(@ref)); [PythonType("weakref")] - public class @ref : IStructuralEquatable { + public class @ref : IStructuralEquatable + { private readonly CodeContext _context; internal readonly WeakHandle _target; private int _hashVal; @@ -280,7 +283,8 @@ private static bool RefEquals(object x, object y, IEqualityComparer comparer) { } [PythonType, DynamicBaseType, PythonHidden] - public sealed partial class weakproxy : IPythonObject, ICodeFormattable, IProxyObject, IPythonMembersList, IStructuralEquatable { + public sealed partial class weakproxy : IPythonObject, ICodeFormattable, IProxyObject, IPythonMembersList, IStructuralEquatable + { internal readonly WeakHandle _target; private readonly CodeContext/*!*/ _context; @@ -378,7 +382,7 @@ PythonType IPythonObject.PythonType { object[] IPythonObject.GetSlots() { return null; } object[] IPythonObject.GetSlotsCreate() { return null; } - + #endregion #region object overloads @@ -480,7 +484,7 @@ bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer) { return comparer.Equals(obj, other); } - + #endregion public object __bool__() { @@ -495,7 +499,7 @@ public static explicit operator bool(weakproxy self) { [PythonType, DynamicBaseTypeAttribute, PythonHidden] public sealed partial class weakcallableproxy : IPythonObject, - ICodeFormattable, + ICodeFormattable, IProxyObject, IStructuralEquatable, IPythonMembersList { @@ -541,7 +545,8 @@ private weakcallableproxy(CodeContext context, object target, object callback) { ~weakcallableproxy() { // remove our self from the chain... IWeakReferenceable iwr; - if (_context.LanguageContext.TryConvertToWeakReferenceable(_target.Target, out iwr)) { + if (_context.LanguageContext.TryConvertToWeakReferenceable(_target.Target, out iwr)) + { WeakRefTracker wrt = iwr.GetWeakRef(); wrt.RemoveHandler(this); } @@ -605,7 +610,7 @@ PythonType IPythonObject.PythonType { object[] IPythonObject.GetSlots() { return null; } object[] IPythonObject.GetSlotsCreate() { return null; } - + #endregion #region object overloads @@ -633,9 +638,9 @@ public override string ToString() { public object Call(CodeContext/*!*/ context, params object[] args) { return context.LanguageContext.CallSplat(GetObject(), args); } - + [SpecialName] - public object Call(CodeContext/*!*/ context, [ParamDictionary] IDictionary dict, params object[] args) { + public object Call(CodeContext/*!*/ context, [ParamDictionary]IDictionary dict, params object[] args) { return PythonCalls.CallWithKeywordArgs(context, GetObject(), args, dict); } @@ -731,7 +736,7 @@ public static WeakRefTracker InitializeWeakRef(PythonContext context, object sel WeakRefTracker wrt = iwr.GetWeakRef(); if (wrt == null) { - if (!iwr.SetWeakRef(wrt = new WeakRefTracker(iwr))) + if (!iwr.SetWeakRef(wrt = new WeakRefTracker(iwr))) throw PythonOps.TypeError("cannot create weak reference to '{0}' object", PythonOps.GetPythonTypeName(target)); } @@ -805,7 +810,7 @@ public object Call(CodeContext context, params object[] args) { [SpecialName] - public object Call(CodeContext context, [ParamDictionary] IDictionary dict, params object[] args) { + public object Call(CodeContext context, [ParamDictionary]IDictionary dict, params object[] args) { object targetMethod; if (!DynamicHelpers.GetPythonType(target.Target).TryGetBoundMember(context, target.Target, name, out targetMethod)) throw PythonOps.AttributeError("type {0} has no attribute {1}", diff --git a/src/ipy/IronPython.Modules/_winapi.cs b/src/ipy/IronPython.Modules/_winapi.cs index 3d11b0594..dcfacd5d4 100644 --- a/src/ipy/IronPython.Modules/_winapi.cs +++ b/src/ipy/IronPython.Modules/_winapi.cs @@ -24,7 +24,8 @@ public static class PythonWinApi { if (overlapped) { throw new NotImplementedException(); - } else { + } + else { var result = ConnectNamedPipe(checked((IntPtr)(long)handle), IntPtr.Zero); if (!result) throw PythonNT.GetLastWin32Error(); @@ -168,7 +169,7 @@ public static BigInteger DuplicateHandle( int desired_access, bool inherit_handle, object? DUPLICATE_SAME_ACCESS) { - + IntPtr currentProcessIntPtr = new IntPtr((long)source_process_handle); IntPtr handleIntPtr = new IntPtr((long)source_handle); IntPtr currentProcess2IntPtr = new IntPtr((long)target_process_handle); @@ -302,7 +303,7 @@ private static extern IntPtr CreateFile( [DllImport("kernel32.dll", EntryPoint = "CreateProcess", SetLastError = true)] private static extern bool CreateProcessPI(string? lpApplicationName, string? lpCommandLine, ref SECURITY_ATTRIBUTES lpProcessAttributes, - ref SECURITY_ATTRIBUTES lpThreadAttributes, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandles, + ref SECURITY_ATTRIBUTES lpThreadAttributes, [MarshalAs(UnmanagedType.Bool)]bool bInheritHandles, uint dwCreationFlags, string? lpEnvironment, string? lpCurrentDirectory, [In] ref STARTUPINFO lpStartupInfo, out PROCESS_INFORMATION lpProcessInformation); diff --git a/src/ipy/IronPython.Modules/array.cs b/src/ipy/IronPython.Modules/array.cs index 2c1242251..578ec8d2f 100644 --- a/src/ipy/IronPython.Modules/array.cs +++ b/src/ipy/IronPython.Modules/array.cs @@ -13,18 +13,19 @@ using System.Linq; using System.Numerics; using System.Reflection; +using System.Runtime.InteropServices; using System.Text; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - -using NotNull = System.Diagnostics.CodeAnalysis.NotNullAttribute; using SpecialName = System.Runtime.CompilerServices.SpecialNameAttribute; +using NotNull = System.Diagnostics.CodeAnalysis.NotNullAttribute; [assembly: PythonModule("array", typeof(IronPython.Modules.ArrayModule))] namespace IronPython.Modules { @@ -68,14 +69,16 @@ private static array ArrayReconstructor(CodeContext context, [NotNone] PythonTyp static string MachineFormatToTypeCode(int machineFormat, out bool isBigEndian, out string? encoding) { isBigEndian = machineFormat % 2 == 1; - encoding = machineFormat switch { + encoding = machineFormat switch + { 18 => "UTF-16-LE", 19 => "UTF-16-BE", 20 => "UTF-32-LE", 21 => "UTF-32-BE", _ => null, }; - return machineFormat switch { + return machineFormat switch + { 0 => "B", 1 => "b", 2 => "H", @@ -154,7 +157,8 @@ private array(char typeCode, ArrayData data) { } private static ArrayData CreateData(char typecode) { - return (typecode) switch { + return (typecode) switch + { 'b' => new ArrayData(), 'B' => new ArrayData(), 'u' => new ArrayData(), @@ -577,7 +581,8 @@ public PythonTuple __reduce_ex__(CodeContext context, int version) { dict); static int TypeCodeToMachineFormat(char typeCode) { - return typeCode switch { + return typeCode switch + { 'b' => 1, 'B' => 0, 'u' => 18, diff --git a/src/ipy/IronPython.Modules/atexit.cs b/src/ipy/IronPython.Modules/atexit.cs index 8943951e9..c2a35aeb0 100644 --- a/src/ipy/IronPython.Modules/atexit.cs +++ b/src/ipy/IronPython.Modules/atexit.cs @@ -2,13 +2,14 @@ using System.Collections.Generic; using System.Runtime.CompilerServices; -using IronPython.Runtime; -using IronPython.Runtime.Exceptions; -using IronPython.Runtime.Operations; - using Microsoft.Scripting; + +using IronPython.Runtime; using Microsoft.Scripting.Runtime; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Exceptions; + [assembly: PythonModule("atexit", typeof(IronPython.Modules.PythonAtExit))] namespace IronPython.Modules { public static class PythonAtExit { @@ -27,15 +28,15 @@ public FunctionDescriptor(object func, IDictionary kwargs, objec } public object Func { - get; + get; } public IDictionary KeywordArgs { - get; + get; } public object[] Args { - get; + get; } } @@ -56,7 +57,7 @@ Register a function to be executed upon normal program termination\n\ kwargs - optional keyword arguments to pass to func func is returned to facilitate usage as a decorator.")] - public static object register(CodeContext context, object func, [ParamDictionary] IDictionary kwargs, params object[] args) { + public static object register(CodeContext context, object func, [ParamDictionary]IDictionary kwargs, params object[] args) { if (!PythonOps.IsCallable(context, func)) { throw PythonOps.TypeError("the first argument must be callable"); } diff --git a/src/ipy/IronPython.Modules/bz2/BZ2Compressor.cs b/src/ipy/IronPython.Modules/bz2/BZ2Compressor.cs index 7ef908efc..9453e1ff5 100644 --- a/src/ipy/IronPython.Modules/bz2/BZ2Compressor.cs +++ b/src/ipy/IronPython.Modules/bz2/BZ2Compressor.cs @@ -6,13 +6,12 @@ // using System; +using System.Collections.Generic; using System.IO; using System.Linq; - +using System.Runtime.InteropServices; using Ionic.BZip2; - using IronPython.Runtime; - using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; @@ -20,7 +19,7 @@ namespace IronPython.Modules.Bz2 { public static partial class Bz2Module { [PythonType] public class BZ2Compressor { - public const string __doc__ = + public const string __doc__ = @"BZ2Compressor([compresslevel=9]) -> compressor object Create a new compressor object. This object may be used to compress diff --git a/src/ipy/IronPython.Modules/bz2/BZ2Decompressor.cs b/src/ipy/IronPython.Modules/bz2/BZ2Decompressor.cs index 13d98582a..fcc9a54e0 100644 --- a/src/ipy/IronPython.Modules/bz2/BZ2Decompressor.cs +++ b/src/ipy/IronPython.Modules/bz2/BZ2Decompressor.cs @@ -9,12 +9,9 @@ using System.Collections.Generic; using System.IO; using System.Linq; - using Ionic.BZip2; - using IronPython.Runtime; using IronPython.Runtime.Operations; - using Microsoft.Scripting.Runtime; namespace IronPython.Modules.Bz2 { diff --git a/src/ipy/IronPython.Modules/bz2/BZ2Module.cs b/src/ipy/IronPython.Modules/bz2/BZ2Module.cs index b83f37626..6ad5cbcb5 100644 --- a/src/ipy/IronPython.Modules/bz2/BZ2Module.cs +++ b/src/ipy/IronPython.Modules/bz2/BZ2Module.cs @@ -5,6 +5,9 @@ // Copyright 2012 Jeff Hardy // +using System.Collections.Generic; +using System.Linq; + using IronPython.Runtime; [assembly: PythonModule("_bz2", typeof(IronPython.Modules.Bz2.Bz2Module))] diff --git a/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs b/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs index a0ee547e0..e628857bb 100644 --- a/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs +++ b/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs @@ -85,11 +85,14 @@ // using System; +using System.IO; // flymake: csc.exe /t:module BZip2InputStream.cs BZip2OutputStream.cs Rand.cs BCRC32.cs @@FILE@@ -namespace Ionic.BZip2 { - internal class BZip2Compressor { +namespace Ionic.BZip2 +{ + internal class BZip2Compressor + { private int blockSize100k; // 0...9 private int currentByte = -1; private int runLength = 0; @@ -138,10 +141,12 @@ internal class BZip2Compressor { /// is necessary because BZip2 does byte shredding. /// public BZip2Compressor(BitWriter writer) - : this(writer, BZip2.MaxBlockSize) { + : this(writer, BZip2.MaxBlockSize) + { } - public BZip2Compressor(BitWriter writer, int blockSize) { + public BZip2Compressor(BitWriter writer, int blockSize) + { this.blockSize100k = blockSize; this.bw = writer; @@ -155,7 +160,8 @@ public BZip2Compressor(BitWriter writer, int blockSize) { Reset(); } - private void Reset() { + private void Reset() + { // initBlock(); this.crc.Reset(); this.currentByte = -1; @@ -167,15 +173,18 @@ private void Reset() { } - public int BlockSize { + public int BlockSize + { get { return this.blockSize100k; } } - public uint Crc32 { + public uint Crc32 + { get; private set; } - public int AvailableBytesOut { + public int AvailableBytesOut + { get; private set; } @@ -193,7 +202,8 @@ public int AvailableBytesOut { /// then writes no more. In that case the stream may want to check. /// /// - public int UncompressedBytes { + public int UncompressedBytes + { get { return this.last + 1; } } @@ -207,7 +217,8 @@ public int UncompressedBytes { /// stores the encoded data into the rle block. /// /// - public int Fill(byte[] buffer, int offset, int count) { + public int Fill(byte[] buffer, int offset, int count) + { if (this.last >= this.outBlockFillThreshold) return 0; // We're full, I tell you! @@ -216,7 +227,8 @@ public int Fill(byte[] buffer, int offset, int count) { int rc; // do run-length-encoding until block is full - do { + do + { rc = write0(buffer[offset++]); if (rc > 0) bytesWritten++; } while (offset < limit && rc == 1); @@ -247,18 +259,22 @@ public int Fill(byte[] buffer, int offset, int count) { /// /// /// 0 if the byte was not written, non-zero if written. - private int write0(byte b) { + private int write0(byte b) + { bool rc; // there is no current run in progress - if (this.currentByte == -1) { + if (this.currentByte == -1) + { this.currentByte = b; this.runLength++; return 1; } // this byte is the same as the current run in progress - if (this.currentByte == b) { - if (++this.runLength > 254) { + if (this.currentByte == b) + { + if (++this.runLength > 254) + { rc = AddRunToOutputBlock(false); this.currentByte = -1; this.runLength = 0; @@ -272,7 +288,8 @@ private int write0(byte b) { // and try to start a new run. rc = AddRunToOutputBlock(false); - if (rc) { + if (rc) + { this.currentByte = -1; this.runLength = 0; // returning 0 implies the block is full, and the byte was not written. @@ -299,7 +316,8 @@ private int write0(byte b) { /// /// /// true if the block is now full; otherwise false. - private bool AddRunToOutputBlock(bool final) { + private bool AddRunToOutputBlock(bool final) + { runs++; /* add_pair_to_block ( EState* s ) */ int previousLast = this.last; @@ -307,7 +325,8 @@ private bool AddRunToOutputBlock(bool final) { // sanity check only - because of the check done at the // bottom of this method, and the logic in write0(), this // should never ever happen. - if (previousLast >= this.outBlockFillThreshold && !final) { + if (previousLast >= this.outBlockFillThreshold && !final) + { var msg = String.Format("block overrun(final={2}): {0} >= threshold ({1})", previousLast, this.outBlockFillThreshold, final); throw new Exception(msg); @@ -322,13 +341,14 @@ private bool AddRunToOutputBlock(bool final) { // rle block. For those two reasons, the base offset from last is // always +2. - byte b = (byte)this.currentByte; + byte b = (byte) this.currentByte; byte[] block = this.cstate.block; this.cstate.inUse[b] = true; int rl = this.runLength; this.crc.UpdateCRC(b, rl); - switch (rl) { + switch (rl) + { case 1: block[previousLast + 2] = b; this.last = previousLast + 1; @@ -354,7 +374,7 @@ private bool AddRunToOutputBlock(bool final) { block[previousLast + 3] = b; block[previousLast + 4] = b; block[previousLast + 5] = b; - block[previousLast + 6] = (byte)rl; + block[previousLast + 6] = (byte) rl; this.last = previousLast + 5; break; } @@ -409,11 +429,11 @@ public void CompressAndWrite() // endBlock this.bw.WriteByte(0x53); this.bw.WriteByte(0x59); - this.Crc32 = (uint)this.crc.Crc32Result; + this.Crc32 = (uint) this.crc.Crc32Result; this.bw.WriteInt(this.Crc32); /* Now a single bit indicating randomisation. */ - this.bw.WriteBits(1, (this.blockRandomised) ? 1U : 0U); + this.bw.WriteBits(1, (this.blockRandomised)?1U:0U); /* Finally, block's contents proper. */ moveToFrontCodeAndSend(); @@ -422,7 +442,8 @@ public void CompressAndWrite() // endBlock } - private void randomiseBlock() { + private void randomiseBlock() + { bool[] inUse = this.cstate.inUse; byte[] block = this.cstate.block; int lastShadow = this.last; @@ -432,16 +453,19 @@ private void randomiseBlock() { int rNToGo = 0; int rTPos = 0; - for (int i = 0, j = 1; i <= lastShadow; i = j, j++) { - if (rNToGo == 0) { - rNToGo = (char)Rand.Rnums(rTPos); - if (++rTPos == 512) { + for (int i = 0, j = 1; i <= lastShadow; i = j, j++) + { + if (rNToGo == 0) + { + rNToGo = (char) Rand.Rnums(rTPos); + if (++rTPos == 512) + { rTPos = 0; } } rNToGo--; - block[j] ^= (byte)((rNToGo == 1) ? 1 : 0); + block[j] ^= (byte) ((rNToGo == 1) ? 1 : 0); // handle 16 bit signed numbers inUse[block[j] & 0xff] = true; @@ -450,7 +474,8 @@ private void randomiseBlock() { this.blockRandomised = true; } - private void mainSort() { + private void mainSort() + { CompressionState dataShadow = this.cstate; int[] runningOrder = dataShadow.mainSort_runningOrder; int[] copy = dataShadow.mainSort_copy; @@ -464,7 +489,8 @@ private void mainSort() { bool firstAttemptShadow = this.firstAttempt; // Set up the 2-byte frequency table - for (int i = 65537; --i >= 0;) { + for (int i = 65537; --i >= 0;) + { ftab[i] = 0; } @@ -473,10 +499,12 @@ private void mainSort() { * last+NUM_OVERSHOOT_BYTES inclusive. First, set up the overshoot area * for block. */ - for (int i = 0; i < BZip2.NUM_OVERSHOOT_BYTES; i++) { + for (int i = 0; i < BZip2.NUM_OVERSHOOT_BYTES; i++) + { block[lastShadow + i + 2] = block[(i % (lastShadow + 1)) + 1]; } - for (int i = lastShadow + BZip2.NUM_OVERSHOOT_BYTES + 1; --i >= 0;) { + for (int i = lastShadow + BZip2.NUM_OVERSHOOT_BYTES +1; --i >= 0;) + { quadrant[i] = '\0'; } block[0] = block[lastShadow + 1]; @@ -484,7 +512,8 @@ private void mainSort() { // Complete the initial radix sort: int c1 = block[0] & 0xff; - for (int i = 0; i <= lastShadow; i++) { + for (int i = 0; i <= lastShadow; i++) + { int c2 = block[i + 1] & 0xff; ftab[(c1 << 8) + c2]++; c1 = c2; @@ -494,7 +523,8 @@ private void mainSort() { ftab[i] += ftab[i - 1]; c1 = block[1] & 0xff; - for (int i = 0; i < lastShadow; i++) { + for (int i = 0; i < lastShadow; i++) + { int c2 = block[i + 2] & 0xff; fmap[--ftab[(c1 << 8) + c2]] = i; c1 = c2; @@ -506,23 +536,28 @@ private void mainSort() { * Now ftab contains the first loc of every small bucket. Calculate the * running order, from smallest to largest big bucket. */ - for (int i = 256; --i >= 0;) { + for (int i = 256; --i >= 0;) + { bigDone[i] = false; runningOrder[i] = i; } - for (int h = 364; h != 1;) { + for (int h = 364; h != 1;) + { h /= 3; - for (int i = h; i <= 255; i++) { + for (int i = h; i <= 255; i++) + { int vv = runningOrder[i]; int a = ftab[(vv + 1) << 8] - ftab[vv << 8]; int b = h - 1; int j = i; for (int ro = runningOrder[j - h]; (ftab[(ro + 1) << 8] - ftab[ro << 8]) > a; ro = runningOrder[j - - h]) { + - h]) + { runningOrder[j] = ro; j -= h; - if (j <= b) { + if (j <= b) + { break; } } @@ -533,7 +568,8 @@ private void mainSort() { /* * The main sorting loop. */ - for (int i = 0; i <= 255; i++) { + for (int i = 0; i <= 255; i++) + { /* * Process big buckets, starting with the least full. */ @@ -546,16 +582,20 @@ private void mainSort() { * already completed many of the small buckets [ss, j], so we don't * have to sort them at all. */ - for (int j = 0; j <= 255; j++) { + for (int j = 0; j <= 255; j++) + { int sb = (ss << 8) + j; int ftab_sb = ftab[sb]; - if ((ftab_sb & SETMASK) != SETMASK) { + if ((ftab_sb & SETMASK) != SETMASK) + { int lo = ftab_sb & CLEARMASK; int hi = (ftab[sb + 1] & CLEARMASK) - 1; - if (hi > lo) { + if (hi > lo) + { mainQSort3(dataShadow, lo, hi, 2); if (firstAttemptShadow - && (this.workDone > workLimitShadow)) { + && (this.workDone > workLimitShadow)) + { return; } } @@ -567,14 +607,17 @@ private void mainSort() { // Now scan this big bucket so as to synthesise the // sorted order for small buckets [t, ss] for all t != ss. - for (int j = 0; j <= 255; j++) { + for (int j = 0; j <= 255; j++) + { copy[j] = ftab[(j << 8) + ss] & CLEARMASK; } - for (int j = ftab[ss << 8] & CLEARMASK, hj = (ftab[(ss + 1) << 8] & CLEARMASK); j < hj; j++) { + for (int j = ftab[ss << 8] & CLEARMASK, hj = (ftab[(ss + 1) << 8] & CLEARMASK); j < hj; j++) + { int fmap_j = fmap[j]; c1 = block[fmap_j] & 0xff; - if (!bigDone[c1]) { + if (!bigDone[c1]) + { fmap[copy[c1]] = (fmap_j == 0) ? lastShadow : (fmap_j - 1); copy[c1]++; } @@ -593,20 +636,24 @@ private void mainSort() { */ bigDone[ss] = true; - if (i < 255) { + if (i < 255) + { int bbStart = ftab[ss << 8] & CLEARMASK; int bbSize = (ftab[(ss + 1) << 8] & CLEARMASK) - bbStart; int shifts = 0; - while ((bbSize >> shifts) > 65534) { + while ((bbSize >> shifts) > 65534) + { shifts++; } - for (int j = 0; j < bbSize; j++) { + for (int j = 0; j < bbSize; j++) + { int a2update = fmap[bbStart + j]; - char qVal = (char)(j >> shifts); + char qVal = (char) (j >> shifts); quadrant[a2update] = qVal; - if (a2update < BZip2.NUM_OVERSHOOT_BYTES) { + if (a2update < BZip2.NUM_OVERSHOOT_BYTES) + { quadrant[a2update + lastShadow + 1] = qVal; } } @@ -616,14 +663,16 @@ private void mainSort() { } - private void blockSort() { + private void blockSort() + { this.workLimit = WORK_FACTOR * this.last; this.workDone = 0; this.blockRandomised = false; this.firstAttempt = true; mainSort(); - if (this.firstAttempt && (this.workDone > this.workLimit)) { + if (this.firstAttempt && (this.workDone > this.workLimit)) + { randomiseBlock(); this.workLimit = this.workDone = 0; this.firstAttempt = false; @@ -632,8 +681,10 @@ private void blockSort() { int[] fmap = this.cstate.fmap; this.origPtr = -1; - for (int i = 0, lastShadow = this.last; i <= lastShadow; i++) { - if (fmap[i] == 0) { + for (int i = 0, lastShadow = this.last; i <= lastShadow; i++) + { + if (fmap[i] == 0) + { this.origPtr = i; break; } @@ -651,9 +702,11 @@ private void blockSort() { *

*/ private bool mainSimpleSort(CompressionState dataShadow, int lo, - int hi, int d) { + int hi, int d) + { int bigN = hi - lo + 1; - if (bigN < 2) { + if (bigN < 2) + { return this.firstAttempt && (this.workDone > this.workLimit); } @@ -674,13 +727,16 @@ private bool mainSimpleSort(CompressionState dataShadow, int lo, // coding it in additional loops. // HP: - while (--hp >= 0) { + while (--hp >= 0) + { int h = increments[hp]; int mj = lo + h - 1; - for (int i = lo + h; i <= hi;) { + for (int i = lo + h; i <= hi;) + { // copy - for (int k = 3; (i <= hi) && (--k >= 0); i++) { + for (int k = 3; (i <= hi) && (--k >= 0); i++) + { int v = fmap[i]; int vd = v + d; int j = i; @@ -698,13 +754,17 @@ private bool mainSimpleSort(CompressionState dataShadow, int lo, bool onceRunned = false; int a = 0; - HAMMER: while (true) { - if (onceRunned) { + HAMMER: while (true) + { + if (onceRunned) + { fmap[j] = a; - if ((j -= h) <= mj) { + if ((j -= h) <= mj) + { goto END_HAMMER; } - } else { + } + else { onceRunned = true; } @@ -714,70 +774,111 @@ private bool mainSimpleSort(CompressionState dataShadow, int lo, // following could be done in a loop, but // unrolled it for performance: - if (block[i1 + 1] == block[i2 + 1]) { - if (block[i1 + 2] == block[i2 + 2]) { - if (block[i1 + 3] == block[i2 + 3]) { - if (block[i1 + 4] == block[i2 + 4]) { - if (block[i1 + 5] == block[i2 + 5]) { - if (block[(i1 += 6)] == block[(i2 += 6)]) { + if (block[i1 + 1] == block[i2 + 1]) + { + if (block[i1 + 2] == block[i2 + 2]) + { + if (block[i1 + 3] == block[i2 + 3]) + { + if (block[i1 + 4] == block[i2 + 4]) + { + if (block[i1 + 5] == block[i2 + 5]) + { + if (block[(i1 += 6)] == block[(i2 += 6)]) + { int x = lastShadow; - X: while (x > 0) { + X: while (x > 0) + { x -= 4; - if (block[i1 + 1] == block[i2 + 1]) { - if (quadrant[i1] == quadrant[i2]) { - if (block[i1 + 2] == block[i2 + 2]) { - if (quadrant[i1 + 1] == quadrant[i2 + 1]) { - if (block[i1 + 3] == block[i2 + 3]) { - if (quadrant[i1 + 2] == quadrant[i2 + 2]) { - if (block[i1 + 4] == block[i2 + 4]) { - if (quadrant[i1 + 3] == quadrant[i2 + 3]) { - if ((i1 += 4) >= lastPlus1) { + if (block[i1 + 1] == block[i2 + 1]) + { + if (quadrant[i1] == quadrant[i2]) + { + if (block[i1 + 2] == block[i2 + 2]) + { + if (quadrant[i1 + 1] == quadrant[i2 + 1]) + { + if (block[i1 + 3] == block[i2 + 3]) + { + if (quadrant[i1 + 2] == quadrant[i2 + 2]) + { + if (block[i1 + 4] == block[i2 + 4]) + { + if (quadrant[i1 + 3] == quadrant[i2 + 3]) + { + if ((i1 += 4) >= lastPlus1) + { i1 -= lastPlus1; } - if ((i2 += 4) >= lastPlus1) { + if ((i2 += 4) >= lastPlus1) + { i2 -= lastPlus1; } workDoneShadow++; goto X; - } else if ((quadrant[i1 + 3] > quadrant[i2 + 3])) { + } + else if ((quadrant[i1 + 3] > quadrant[i2 + 3])) + { goto HAMMER; - } else { + } + else { goto END_HAMMER; } - } else if ((block[i1 + 4] & 0xff) > (block[i2 + 4] & 0xff)) { + } + else if ((block[i1 + 4] & 0xff) > (block[i2 + 4] & 0xff)) + { goto HAMMER; - } else { + } + else { goto END_HAMMER; } - } else if ((quadrant[i1 + 2] > quadrant[i2 + 2])) { + } + else if ((quadrant[i1 + 2] > quadrant[i2 + 2])) + { goto HAMMER; - } else { + } + else { goto END_HAMMER; } - } else if ((block[i1 + 3] & 0xff) > (block[i2 + 3] & 0xff)) { + } + else if ((block[i1 + 3] & 0xff) > (block[i2 + 3] & 0xff)) + { goto HAMMER; - } else { + } + else { goto END_HAMMER; } - } else if ((quadrant[i1 + 1] > quadrant[i2 + 1])) { + } + else if ((quadrant[i1 + 1] > quadrant[i2 + 1])) + { goto HAMMER; - } else { + } + else { goto END_HAMMER; } - } else if ((block[i1 + 2] & 0xff) > (block[i2 + 2] & 0xff)) { + } + else if ((block[i1 + 2] & 0xff) > (block[i2 + 2] & 0xff)) + { goto HAMMER; - } else { + } + else { goto END_HAMMER; } - } else if ((quadrant[i1] > quadrant[i2])) { + } + else if ((quadrant[i1] > quadrant[i2])) + { goto HAMMER; - } else { + } + else { goto END_HAMMER; } - } else if ((block[i1 + 1] & 0xff) > (block[i2 + 1] & 0xff)) { + } + else if ((block[i1 + 1] & 0xff) > (block[i2 + 1] & 0xff)) + { goto HAMMER; - } else { + } + else { goto END_HAMMER; } @@ -785,53 +886,71 @@ private bool mainSimpleSort(CompressionState dataShadow, int lo, goto END_HAMMER; } // while x > 0 else { - if ((block[i1] & 0xff) > (block[i2] & 0xff)) { + if ((block[i1] & 0xff) > (block[i2] & 0xff)) + { goto HAMMER; - } else { + } + else { goto END_HAMMER; } } - } else if ((block[i1 + 5] & 0xff) > (block[i2 + 5] & 0xff)) { + } + else if ((block[i1 + 5] & 0xff) > (block[i2 + 5] & 0xff)) + { goto HAMMER; - } else { + } + else { goto END_HAMMER; } - } else if ((block[i1 + 4] & 0xff) > (block[i2 + 4] & 0xff)) { + } + else if ((block[i1 + 4] & 0xff) > (block[i2 + 4] & 0xff)) + { goto HAMMER; - } else { + } + else { goto END_HAMMER; } - } else if ((block[i1 + 3] & 0xff) > (block[i2 + 3] & 0xff)) { + } + else if ((block[i1 + 3] & 0xff) > (block[i2 + 3] & 0xff)) + { goto HAMMER; - } else { + } + else { goto END_HAMMER; } - } else if ((block[i1 + 2] & 0xff) > (block[i2 + 2] & 0xff)) { + } + else if ((block[i1 + 2] & 0xff) > (block[i2 + 2] & 0xff)) + { goto HAMMER; - } else { + } + else { goto END_HAMMER; } - } else if ((block[i1 + 1] & 0xff) > (block[i2 + 1] & 0xff)) { + } + else if ((block[i1 + 1] & 0xff) > (block[i2 + 1] & 0xff)) + { goto HAMMER; - } else { + } + else { goto END_HAMMER; } } // HAMMER - END_HAMMER: + END_HAMMER: // end inline mainGTU fmap[j] = v; } if (firstAttemptShadow && (i <= hi) - && (workDoneShadow > workLimitShadow)) { + && (workDoneShadow > workLimitShadow)) + { goto END_HP; } } } - END_HP: + END_HP: this.workDone = workDoneShadow; return firstAttemptShadow && (workDoneShadow > workLimitShadow); @@ -839,16 +958,19 @@ private bool mainSimpleSort(CompressionState dataShadow, int lo, - private static void vswap(int[] fmap, int p1, int p2, int n) { + private static void vswap(int[] fmap, int p1, int p2, int n) + { n += p1; - while (p1 < n) { + while (p1 < n) + { int t = fmap[p1]; fmap[p1++] = fmap[p2]; fmap[p2++] = t; } } - private static byte med3(byte a, byte b, byte c) { + private static byte med3(byte a, byte b, byte c) + { return (a < b) ? (b < c ? b : a < c ? c : a) : (b > c ? b : a > c ? c : a); } @@ -858,7 +980,8 @@ private static byte med3(byte a, byte b, byte c) { * Method "mainQSort3", file "blocksort.c", BZip2 1.0.2 */ private void mainQSort3(CompressionState dataShadow, int loSt, - int hiSt, int dSt) { + int hiSt, int dSt) + { int[] stack_ll = dataShadow.stack_ll; int[] stack_hh = dataShadow.stack_hh; int[] stack_dd = dataShadow.stack_dd; @@ -869,16 +992,20 @@ private void mainQSort3(CompressionState dataShadow, int loSt, stack_hh[0] = hiSt; stack_dd[0] = dSt; - for (int sp = 1; --sp >= 0;) { + for (int sp = 1; --sp >= 0;) + { int lo = stack_ll[sp]; int hi = stack_hh[sp]; int d = stack_dd[sp]; - if ((hi - lo < SMALL_THRESH) || (d > DEPTH_THRESH)) { - if (mainSimpleSort(dataShadow, lo, hi, d)) { + if ((hi - lo < SMALL_THRESH) || (d > DEPTH_THRESH)) + { + if (mainSimpleSort(dataShadow, lo, hi, d)) + { return; } - } else { + } + else { int d1 = d + 1; int med = med3(block[fmap[lo] + d1], block[fmap[hi] + d1], block[fmap[(lo + hi) >> 1] + d1]) & 0xff; @@ -888,50 +1015,65 @@ private void mainQSort3(CompressionState dataShadow, int loSt, int ltLo = lo; int gtHi = hi; - while (true) { - while (unLo <= unHi) { + while (true) + { + while (unLo <= unHi) + { int n = (block[fmap[unLo] + d1] & 0xff) - med; - if (n == 0) { + if (n == 0) + { int temp = fmap[unLo]; fmap[unLo++] = fmap[ltLo]; fmap[ltLo++] = temp; - } else if (n < 0) { + } + else if (n < 0) + { unLo++; - } else { + } + else { break; } } - while (unLo <= unHi) { + while (unLo <= unHi) + { int n = (block[fmap[unHi] + d1] & 0xff) - med; - if (n == 0) { + if (n == 0) + { int temp = fmap[unHi]; fmap[unHi--] = fmap[gtHi]; fmap[gtHi--] = temp; - } else if (n > 0) { + } + else if (n > 0) + { unHi--; - } else { + } + else { break; } } - if (unLo <= unHi) { + if (unLo <= unHi) + { int temp = fmap[unLo]; fmap[unLo++] = fmap[unHi]; fmap[unHi--] = temp; - } else { + } + else { break; } } - if (gtHi < ltLo) { + if (gtHi < ltLo) + { stack_ll[sp] = lo; stack_hh[sp] = hi; stack_dd[sp] = d1; sp++; - } else { + } + else { int n = ((ltLo - lo) < (unLo - ltLo)) ? (ltLo - lo) : (unLo - ltLo); vswap(fmap, lo, unLo - n, n); @@ -963,7 +1105,8 @@ private void mainQSort3(CompressionState dataShadow, int loSt, - private void generateMTFValues() { + private void generateMTFValues() + { int lastShadow = this.last; CompressionState dataShadow = this.cstate; bool[] inUse = dataShadow.inUse; @@ -976,9 +1119,11 @@ private void generateMTFValues() { // make maps int nInUseShadow = 0; - for (int i = 0; i < 256; i++) { - if (inUse[i]) { - unseqToSeq[i] = (byte)nInUseShadow; + for (int i = 0; i < 256; i++) + { + if (inUse[i]) + { + unseqToSeq[i] = (byte) nInUseShadow; nInUseShadow++; } } @@ -986,23 +1131,27 @@ private void generateMTFValues() { int eob = nInUseShadow + 1; - for (int i = eob; i >= 0; i--) { + for (int i = eob; i >= 0; i--) + { mtfFreq[i] = 0; } - for (int i = nInUseShadow; --i >= 0;) { - yy[i] = (byte)i; + for (int i = nInUseShadow; --i >= 0;) + { + yy[i] = (byte) i; } int wr = 0; int zPend = 0; - for (int i = 0; i <= lastShadow; i++) { + for (int i = 0; i <= lastShadow; i++) + { byte ll_i = unseqToSeq[block[fmap[i]] & 0xff]; byte tmp = yy[0]; int j = 0; - while (ll_i != tmp) { + while (ll_i != tmp) + { j++; byte tmp2 = tmp; tmp = yy[j]; @@ -1010,70 +1159,93 @@ private void generateMTFValues() { } yy[0] = tmp; - if (j == 0) { + if (j == 0) + { zPend++; - } else { - if (zPend > 0) { + } + else + { + if (zPend > 0) + { zPend--; - while (true) { - if ((zPend & 1) == 0) { + while (true) + { + if ((zPend & 1) == 0) + { sfmap[wr] = BZip2.RUNA; wr++; mtfFreq[BZip2.RUNA]++; - } else { + } + else + { sfmap[wr] = BZip2.RUNB; wr++; mtfFreq[BZip2.RUNB]++; } - if (zPend >= 2) { + if (zPend >= 2) + { zPend = (zPend - 2) >> 1; - } else { + } + else + { break; } } zPend = 0; } - sfmap[wr] = (char)(j + 1); + sfmap[wr] = (char) (j + 1); wr++; mtfFreq[j + 1]++; } } - if (zPend > 0) { + if (zPend > 0) + { zPend--; - while (true) { - if ((zPend & 1) == 0) { + while (true) + { + if ((zPend & 1) == 0) + { sfmap[wr] = BZip2.RUNA; wr++; mtfFreq[BZip2.RUNA]++; - } else { + } + else + { sfmap[wr] = BZip2.RUNB; wr++; mtfFreq[BZip2.RUNB]++; } - if (zPend >= 2) { + if (zPend >= 2) + { zPend = (zPend - 2) >> 1; - } else { + } + else + { break; } } } - sfmap[wr] = (char)eob; + sfmap[wr] = (char) eob; mtfFreq[eob]++; this.nMTF = wr + 1; } - private static void hbAssignCodes(int[] code, byte[] length, + private static void hbAssignCodes(int[] code, byte[] length, int minLen, int maxLen, - int alphaSize) { + int alphaSize) + { int vec = 0; - for (int n = minLen; n <= maxLen; n++) { - for (int i = 0; i < alphaSize; i++) { - if ((length[i] & 0xff) == n) { + for (int n = minLen; n <= maxLen; n++) + { + for (int i = 0; i < alphaSize; i++) + { + if ((length[i] & 0xff) == n) + { code[i] = vec; vec++; } @@ -1085,13 +1257,16 @@ private static void hbAssignCodes(int[] code, byte[] length, - private void sendMTFValues() { + private void sendMTFValues() + { byte[][] len = this.cstate.sendMTFValues_len; int alphaSize = this.nInUse + 2; - for (int t = BZip2.NGroups; --t >= 0;) { + for (int t = BZip2.NGroups; --t >= 0;) + { byte[] len_t = len[t]; - for (int v = alphaSize; --v >= 0;) { + for (int v = alphaSize; --v >= 0;) + { len_t[v] = GREATER_ICOST; } } @@ -1128,32 +1303,39 @@ private void sendMTFValues() { sendMTFValues7(nSelectors); } - private void sendMTFValues0(int nGroups, int alphaSize) { + private void sendMTFValues0(int nGroups, int alphaSize) + { byte[][] len = this.cstate.sendMTFValues_len; int[] mtfFreq = this.cstate.mtfFreq; int remF = this.nMTF; int gs = 0; - for (int nPart = nGroups; nPart > 0; nPart--) { + for (int nPart = nGroups; nPart > 0; nPart--) + { int tFreq = remF / nPart; int ge = gs - 1; int aFreq = 0; - for (int a = alphaSize - 1; (aFreq < tFreq) && (ge < a);) { + for (int a = alphaSize - 1; (aFreq < tFreq) && (ge < a);) + { aFreq += mtfFreq[++ge]; } if ((ge > gs) && (nPart != nGroups) && (nPart != 1) - && (((nGroups - nPart) & 1) != 0)) { + && (((nGroups - nPart) & 1) != 0)) + { aFreq -= mtfFreq[ge--]; } byte[] len_np = len[nPart - 1]; - for (int v = alphaSize; --v >= 0;) { - if ((v >= gs) && (v <= ge)) { + for (int v = alphaSize; --v >= 0;) + { + if ((v >= gs) && (v <= ge)) + { len_np[v] = LESSER_ICOST; - } else { + } + else { len_np[v] = GREATER_ICOST; } } @@ -1164,9 +1346,10 @@ private void sendMTFValues0(int nGroups, int alphaSize) { } - private static void hbMakeCodeLengths(byte[] len, int[] freq, + private static void hbMakeCodeLengths(byte[] len, int[] freq, CompressionState state1, int alphaSize, - int maxLen) { + int maxLen) + { /* * Nodes and heap entries run from 1. Entry 0 for both the heap and * nodes is a sentinel. @@ -1175,11 +1358,13 @@ private static void hbMakeCodeLengths(byte[] len, int[] freq, int[] weight = state1.weight; int[] parent = state1.parent; - for (int i = alphaSize; --i >= 0;) { + for (int i = alphaSize; --i >= 0;) + { weight[i + 1] = (freq[i] == 0 ? 1 : freq[i]) << 8; } - for (bool tooLong = true; tooLong;) { + for (bool tooLong = true; tooLong;) + { tooLong = false; int nNodes = alphaSize; @@ -1188,21 +1373,24 @@ private static void hbMakeCodeLengths(byte[] len, int[] freq, weight[0] = 0; parent[0] = -2; - for (int i = 1; i <= alphaSize; i++) { + for (int i = 1; i <= alphaSize; i++) + { parent[i] = -1; nHeap++; heap[nHeap] = i; int zz = nHeap; int tmp = heap[zz]; - while (weight[tmp] < weight[heap[zz >> 1]]) { + while (weight[tmp] < weight[heap[zz >> 1]]) + { heap[zz] = heap[zz >> 1]; zz >>= 1; } heap[zz] = tmp; } - while (nHeap > 1) { + while (nHeap > 1) + { int n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; @@ -1211,19 +1399,23 @@ private static void hbMakeCodeLengths(byte[] len, int[] freq, int zz = 1; int tmp = heap[1]; - while (true) { + while (true) + { yy = zz << 1; - if (yy > nHeap) { + if (yy > nHeap) + { break; } if ((yy < nHeap) - && (weight[heap[yy + 1]] < weight[heap[yy]])) { + && (weight[heap[yy + 1]] < weight[heap[yy]])) + { yy++; } - if (weight[tmp] < weight[heap[yy]]) { + if (weight[tmp] < weight[heap[yy]]) + { break; } @@ -1241,19 +1433,23 @@ private static void hbMakeCodeLengths(byte[] len, int[] freq, zz = 1; tmp = heap[1]; - while (true) { + while (true) + { yy = zz << 1; - if (yy > nHeap) { + if (yy > nHeap) + { break; } if ((yy < nHeap) - && (weight[heap[yy + 1]] < weight[heap[yy]])) { + && (weight[heap[yy + 1]] < weight[heap[yy]])) + { yy++; } - if (weight[tmp] < weight[heap[yy]]) { + if (weight[tmp] < weight[heap[yy]]) + { break; } @@ -1267,7 +1463,7 @@ private static void hbMakeCodeLengths(byte[] len, int[] freq, int weight_n1 = weight[n1]; int weight_n2 = weight[n2]; - weight[nNodes] = (int)(((uint)weight_n1 & 0xffffff00U) + weight[nNodes] = (int) (((uint)weight_n1 & 0xffffff00U) + ((uint)weight_n2 & 0xffffff00U)) | (1 + (((weight_n1 & 0x000000ff) > (weight_n2 & 0x000000ff)) @@ -1282,7 +1478,8 @@ private static void hbMakeCodeLengths(byte[] len, int[] freq, zz = nHeap; tmp = heap[zz]; int weight_tmp = weight[tmp]; - while (weight_tmp < weight[heap[zz >> 1]]) { + while (weight_tmp < weight[heap[zz >> 1]]) + { heap[zz] = heap[zz >> 1]; zz >>= 1; } @@ -1290,23 +1487,28 @@ private static void hbMakeCodeLengths(byte[] len, int[] freq, } - for (int i = 1; i <= alphaSize; i++) { + for (int i = 1; i <= alphaSize; i++) + { int j = 0; int k = i; - for (int parent_k; (parent_k = parent[k]) >= 0;) { + for (int parent_k; (parent_k = parent[k]) >= 0;) + { k = parent_k; j++; } - len[i - 1] = (byte)j; - if (j > maxLen) { + len[i - 1] = (byte) j; + if (j > maxLen) + { tooLong = true; } } - if (tooLong) { - for (int i = 1; i < alphaSize; i++) { + if (tooLong) + { + for (int i = 1; i < alphaSize; i++) + { int j = weight[i] >> 8; j = 1 + (j >> 1); weight[i] = j << 8; @@ -1316,7 +1518,8 @@ private static void hbMakeCodeLengths(byte[] len, int[] freq, } - private int sendMTFValues1(int nGroups, int alphaSize) { + private int sendMTFValues1(int nGroups, int alphaSize) + { CompressionState dataShadow = this.cstate; int[][] rfreq = dataShadow.sendMTFValues_rfreq; int[] fave = dataShadow.sendMTFValues_fave; @@ -1334,18 +1537,22 @@ private int sendMTFValues1(int nGroups, int alphaSize) { int nSelectors = 0; - for (int iter = 0; iter < BZip2.N_ITERS; iter++) { - for (int t = nGroups; --t >= 0;) { + for (int iter = 0; iter < BZip2.N_ITERS; iter++) + { + for (int t = nGroups; --t >= 0;) + { fave[t] = 0; int[] rfreqt = rfreq[t]; - for (int i = alphaSize; --i >= 0;) { + for (int i = alphaSize; --i >= 0;) + { rfreqt[i] = 0; } } nSelectors = 0; - for (int gs = 0; gs < this.nMTF;) { + for (int gs = 0; gs < this.nMTF;) + { /* Set group start & end marks. */ /* @@ -1355,12 +1562,14 @@ private int sendMTFValues1(int nGroups, int alphaSize) { int ge = Math.Min(gs + BZip2.G_SIZE - 1, nMTFShadow - 1); - if (nGroups == BZip2.NGroups) { + if (nGroups == BZip2.NGroups) + { // unrolled version of the else-block int[] c = new int[6]; - for (int i = gs; i <= ge; i++) { + for (int i = gs; i <= ge; i++) + { int icv = sfmap[i]; c[0] += len_0[icv] & 0xff; c[1] += len_1[icv] & 0xff; @@ -1370,21 +1579,26 @@ private int sendMTFValues1(int nGroups, int alphaSize) { c[5] += len_5[icv] & 0xff; } - cost[0] = (short)c[0]; - cost[1] = (short)c[1]; - cost[2] = (short)c[2]; - cost[3] = (short)c[3]; - cost[4] = (short)c[4]; - cost[5] = (short)c[5]; - } else { - for (int t = nGroups; --t >= 0;) { + cost[0] = (short) c[0]; + cost[1] = (short) c[1]; + cost[2] = (short) c[2]; + cost[3] = (short) c[3]; + cost[4] = (short) c[4]; + cost[5] = (short) c[5]; + } + else + { + for (int t = nGroups; --t >= 0;) + { cost[t] = 0; } - for (int i = gs; i <= ge; i++) { + for (int i = gs; i <= ge; i++) + { int icv = sfmap[i]; - for (int t = nGroups; --t >= 0;) { - cost[t] += (short)(len[t][icv] & 0xff); + for (int t = nGroups; --t >= 0;) + { + cost[t] += (short) (len[t][icv] & 0xff); } } } @@ -1394,23 +1608,26 @@ private int sendMTFValues1(int nGroups, int alphaSize) { * record its identity in the selector table. */ int bt = -1; - for (int t = nGroups, bc = 999999999; --t >= 0;) { + for (int t = nGroups, bc = 999999999; --t >= 0;) + { int cost_t = cost[t]; - if (cost_t < bc) { + if (cost_t < bc) + { bc = cost_t; bt = t; } } fave[bt]++; - selector[nSelectors] = (byte)bt; + selector[nSelectors] = (byte) bt; nSelectors++; /* * Increment the symbol frequencies for the selected table. */ int[] rfreq_bt = rfreq[bt]; - for (int i = gs; i <= ge; i++) { + for (int i = gs; i <= ge; i++) + { rfreq_bt[sfmap[i]]++; } @@ -1420,7 +1637,8 @@ private int sendMTFValues1(int nGroups, int alphaSize) { /* * Recompute the tables based on the accumulated frequencies. */ - for (int t = 0; t < nGroups; t++) { + for (int t = 0; t < nGroups; t++) + { hbMakeCodeLengths(len[t], rfreq[t], this.cstate, alphaSize, 20); } } @@ -1428,22 +1646,26 @@ private int sendMTFValues1(int nGroups, int alphaSize) { return nSelectors; } - private void sendMTFValues2(int nGroups, int nSelectors) { + private void sendMTFValues2(int nGroups, int nSelectors) + { // assert (nGroups < 8) : nGroups; CompressionState dataShadow = this.cstate; byte[] pos = dataShadow.sendMTFValues2_pos; - for (int i = nGroups; --i >= 0;) { - pos[i] = (byte)i; + for (int i = nGroups; --i >= 0;) + { + pos[i] = (byte) i; } - for (int i = 0; i < nSelectors; i++) { + for (int i = 0; i < nSelectors; i++) + { byte ll_i = dataShadow.selector[i]; byte tmp = pos[0]; int j = 0; - while (ll_i != tmp) { + while (ll_i != tmp) + { j++; byte tmp2 = tmp; tmp = pos[j]; @@ -1451,24 +1673,29 @@ private void sendMTFValues2(int nGroups, int nSelectors) { } pos[0] = tmp; - dataShadow.selectorMtf[i] = (byte)j; + dataShadow.selectorMtf[i] = (byte) j; } } - private void sendMTFValues3(int nGroups, int alphaSize) { + private void sendMTFValues3(int nGroups, int alphaSize) + { int[][] code = this.cstate.sendMTFValues_code; byte[][] len = this.cstate.sendMTFValues_len; - for (int t = 0; t < nGroups; t++) { + for (int t = 0; t < nGroups; t++) + { int minLen = 32; int maxLen = 0; byte[] len_t = len[t]; - for (int i = alphaSize; --i >= 0;) { + for (int i = alphaSize; --i >= 0;) + { int l = len_t[i] & 0xff; - if (l > maxLen) { + if (l > maxLen) + { maxLen = l; } - if (l < minLen) { + if (l < minLen) + { minLen = l; } } @@ -1480,34 +1707,43 @@ private void sendMTFValues3(int nGroups, int alphaSize) { } } - private void sendMTFValues4() { + private void sendMTFValues4() + { bool[] inUse = this.cstate.inUse; bool[] inUse16 = this.cstate.sentMTFValues4_inUse16; - for (int i = 16; --i >= 0;) { + for (int i = 16; --i >= 0;) + { inUse16[i] = false; int i16 = i * 16; - for (int j = 16; --j >= 0;) { - if (inUse[i16 + j]) { + for (int j = 16; --j >= 0;) + { + if (inUse[i16 + j]) + { inUse16[i] = true; } } } uint u = 0; - for (int i = 0; i < 16; i++) { + for (int i = 0; i < 16; i++) + { if (inUse16[i]) u |= 1U << (16 - i - 1); } this.bw.WriteBits(16, u); - for (int i = 0; i < 16; i++) { - if (inUse16[i]) { + for (int i = 0; i < 16; i++) + { + if (inUse16[i]) + { int i16 = i * 16; u = 0; - for (int j = 0; j < 16; j++) { - if (inUse[i16 + j]) { + for (int j = 0; j < 16; j++) + { + if (inUse[i16 + j]) + { u |= 1U << (16 - j - 1); } } @@ -1517,14 +1753,17 @@ private void sendMTFValues4() { } - private void sendMTFValues5(int nGroups, int nSelectors) { - this.bw.WriteBits(3, (uint)nGroups); - this.bw.WriteBits(15, (uint)nSelectors); + private void sendMTFValues5(int nGroups, int nSelectors) + { + this.bw.WriteBits(3, (uint) nGroups); + this.bw.WriteBits(15, (uint) nSelectors); byte[] selectorMtf = this.cstate.selectorMtf; - for (int i = 0; i < nSelectors; i++) { - for (int j = 0, hj = selectorMtf[i] & 0xff; j < hj; j++) { + for (int i = 0; i < nSelectors; i++) + { + for (int j = 0, hj = selectorMtf[i] & 0xff; j < hj; j++) + { this.bw.WriteBits(1, 1); } @@ -1532,22 +1771,27 @@ private void sendMTFValues5(int nGroups, int nSelectors) { } } - private void sendMTFValues6(int nGroups, int alphaSize) { + private void sendMTFValues6(int nGroups, int alphaSize) + { byte[][] len = this.cstate.sendMTFValues_len; - for (int t = 0; t < nGroups; t++) { + for (int t = 0; t < nGroups; t++) + { byte[] len_t = len[t]; - uint curr = (uint)(len_t[0] & 0xff); + uint curr = (uint) (len_t[0] & 0xff); this.bw.WriteBits(5, curr); - for (int i = 0; i < alphaSize; i++) { + for (int i = 0; i < alphaSize; i++) + { int lti = len_t[i] & 0xff; - while (curr < lti) { + while (curr < lti) + { this.bw.WriteBits(2, 2U); curr++; /* 10 */ } - while (curr > lti) { + while (curr > lti) + { this.bw.WriteBits(2, 3U); curr--; /* 11 */ } @@ -1558,25 +1802,28 @@ private void sendMTFValues6(int nGroups, int alphaSize) { } - private void sendMTFValues7(int nSelectors) { - byte[][] len = this.cstate.sendMTFValues_len; - int[][] code = this.cstate.sendMTFValues_code; + private void sendMTFValues7(int nSelectors) + { + byte[][] len = this.cstate.sendMTFValues_len; + int[][] code = this.cstate.sendMTFValues_code; byte[] selector = this.cstate.selector; - char[] sfmap = this.cstate.sfmap; - int nMTFShadow = this.nMTF; + char[] sfmap = this.cstate.sfmap; + int nMTFShadow = this.nMTF; int selCtr = 0; - for (int gs = 0; gs < nMTFShadow;) { + for (int gs = 0; gs < nMTFShadow;) + { int ge = Math.Min(gs + BZip2.G_SIZE - 1, nMTFShadow - 1); int ix = selector[selCtr] & 0xff; int[] code_selCtr = code[ix]; byte[] len_selCtr = len[ix]; - while (gs <= ge) { + while (gs <= ge) + { int sfmap_i = sfmap[gs]; int n = len_selCtr[sfmap_i] & 0xFF; - this.bw.WriteBits(n, (uint)code_selCtr[sfmap_i]); + this.bw.WriteBits(n, (uint) code_selCtr[sfmap_i]); gs++; } @@ -1585,8 +1832,9 @@ private void sendMTFValues7(int nSelectors) { } } - private void moveToFrontCodeAndSend() { - this.bw.WriteBits(24, (uint)this.origPtr); + private void moveToFrontCodeAndSend() + { + this.bw.WriteBits(24, (uint) this.origPtr); generateMTFValues(); sendMTFValues(); } @@ -1596,7 +1844,8 @@ private void moveToFrontCodeAndSend() { - private class CompressionState { + private class CompressionState + { // with blockSize 900k public readonly bool[] inUse = new bool[256]; // 256 byte public readonly byte[] unseqToSeq = new byte[256]; // 256 byte @@ -1650,15 +1899,16 @@ private class CompressionState { */ public char[] quadrant; - public CompressionState(int blockSize100k) { + public CompressionState(int blockSize100k) + { int n = blockSize100k * BZip2.BlockSizeMultiple; this.block = new byte[(n + 1 + BZip2.NUM_OVERSHOOT_BYTES)]; this.fmap = new int[n]; this.sfmap = new char[2 * n]; this.quadrant = this.sfmap; - this.sendMTFValues_len = BZip2.InitRectangularArray(BZip2.NGroups, BZip2.MaxAlphaSize); - this.sendMTFValues_rfreq = BZip2.InitRectangularArray(BZip2.NGroups, BZip2.MaxAlphaSize); - this.sendMTFValues_code = BZip2.InitRectangularArray(BZip2.NGroups, BZip2.MaxAlphaSize); + this.sendMTFValues_len = BZip2.InitRectangularArray(BZip2.NGroups,BZip2.MaxAlphaSize); + this.sendMTFValues_rfreq = BZip2.InitRectangularArray(BZip2.NGroups,BZip2.MaxAlphaSize); + this.sendMTFValues_code = BZip2.InitRectangularArray(BZip2.NGroups,BZip2.MaxAlphaSize); } } diff --git a/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs b/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs index 19f075e91..113d139aa 100644 --- a/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs +++ b/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs @@ -57,12 +57,14 @@ using System; using System.IO; -namespace Ionic.BZip2 { +namespace Ionic.BZip2 +{ /// /// A read-only decorator stream that performs BZip2 decompression on Read. /// - public class BZip2InputStream : System.IO.Stream { + public class BZip2InputStream : System.IO.Stream + { private bool _disposed; private bool _leaveOpen; private Int64 totalBytesRead; @@ -87,7 +89,8 @@ public class BZip2InputStream : System.IO.Stream { /// /// Compressor State /// - private enum CState { + private enum CState + { EOF = 0, START_BLOCK = 1, RAND_PART_A = 2, @@ -126,7 +129,8 @@ private enum CState { /// /// The stream from which to read compressed data public BZip2InputStream(Stream input) - : this(input, false) { } + : this(input, false) + {} /// @@ -165,7 +169,8 @@ public BZip2InputStream(Stream input) /// /// public BZip2InputStream(Stream input, bool leaveOpen) - : base() { + : base() + { this.input = input; this._leaveOpen = leaveOpen; @@ -193,7 +198,8 @@ public BZip2InputStream(Stream input, bool leaveOpen) /// the offset within that data array to put the first byte read. /// the number of bytes to read. /// the number of bytes actually read - public override int Read(byte[] buffer, int offset, int count) { + public override int Read(byte[] buffer, int offset, int count) + { if (offset < 0) throw new IndexOutOfRangeException(String.Format("offset ({0}) must be > 0", offset)); @@ -210,22 +216,25 @@ public override int Read(byte[] buffer, int offset, int count) { int hi = offset + count; int destOffset = offset; - for (int b; (destOffset < hi) && ((b = ReadByte()) >= 0);) { - buffer[destOffset++] = (byte)b; + for (int b; (destOffset < hi) && ((b = ReadByte()) >= 0);) + { + buffer[destOffset++] = (byte) b; } return destOffset - offset; } - private void MakeMaps() { + private void MakeMaps() + { bool[] inUse = this.data.inUse; byte[] seqToUnseq = this.data.seqToUnseq; int n = 0; - for (int i = 0; i < 256; i++) { + for (int i = 0; i < 256; i++) + { if (inUse[i]) - seqToUnseq[n++] = (byte)i; + seqToUnseq[n++] = (byte) i; } this.nInUse = n; @@ -235,10 +244,12 @@ private void MakeMaps() { /// Read a single byte from the stream. /// /// the byte read from the stream, or -1 if EOF - public override int ReadByte() { + public override int ReadByte() + { int retChar = this.currentChar; totalBytesRead++; - switch (this.currentState) { + switch (this.currentState) + { case CState.EOF: return -1; @@ -283,8 +294,10 @@ public override int ReadByte() { /// /// The return value depends on whether the captive stream supports reading. /// - public override bool CanRead { - get { + public override bool CanRead + { + get + { if (_disposed) throw new ObjectDisposedException("BZip2Stream"); return this.input.CanRead; } @@ -297,7 +310,8 @@ public override bool CanRead { /// /// Always returns false. /// - public override bool CanSeek { + public override bool CanSeek + { get { return false; } } @@ -308,8 +322,10 @@ public override bool CanSeek { /// /// The return value depends on whether the captive stream supports writing. /// - public override bool CanWrite { - get { + public override bool CanWrite + { + get + { if (_disposed) throw new ObjectDisposedException("BZip2Stream"); return input.CanWrite; } @@ -318,7 +334,8 @@ public override bool CanWrite { /// /// Flush the stream. /// - public override void Flush() { + public override void Flush() + { if (_disposed) throw new ObjectDisposedException("BZip2Stream"); input.Flush(); } @@ -326,7 +343,8 @@ public override void Flush() { /// /// Reading this property always throws a . /// - public override long Length { + public override long Length + { get { throw new NotImplementedException(); } } @@ -339,8 +357,10 @@ public override long Length { /// cref="NotImplementedException"/>. Reading will return the /// total number of uncompressed bytes read in. /// - public override long Position { - get { + public override long Position + { + get + { return this.totalBytesRead; } set { throw new NotImplementedException(); } @@ -352,7 +372,8 @@ public override long Position { /// this is irrelevant, since it will always throw! /// this is irrelevant, since it will always throw! /// irrelevant! - public override long Seek(long offset, System.IO.SeekOrigin origin) { + public override long Seek(long offset, System.IO.SeekOrigin origin) + { throw new NotImplementedException(); } @@ -360,7 +381,8 @@ public override long Seek(long offset, System.IO.SeekOrigin origin) { /// Calling this method always throws a . ///
/// this is irrelevant, since it will always throw! - public override void SetLength(long value) { + public override void SetLength(long value) + { throw new NotImplementedException(); } @@ -370,7 +392,8 @@ public override void SetLength(long value) { /// this parameter is never used /// this parameter is never used /// this parameter is never used - public override void Write(byte[] buffer, int offset, int count) { + public override void Write(byte[] buffer, int offset, int count) + { throw new NotImplementedException(); } @@ -381,19 +404,25 @@ public override void Write(byte[] buffer, int offset, int count) { /// /// indicates whether the Dispose method was invoked by user code. /// - protected override void Dispose(bool disposing) { - try { - if (!_disposed) { + protected override void Dispose(bool disposing) + { + try + { + if (!_disposed) + { if (disposing) input?.Close(); _disposed = true; } - } finally { + } + finally + { base.Dispose(disposing); } } - private void init() { + private void init() + { if (null == this.input) throw new IOException("No input Stream"); @@ -408,7 +437,7 @@ private void init() { if ((blockSize < '1') || (blockSize > '9')) throw new IOException("Stream is not BZip2 formatted: illegal " - + "blocksize " + (char)blockSize); + + "blocksize " + (char) blockSize); this.blockSize100k = blockSize - '0'; @@ -416,16 +445,19 @@ private void init() { SetupBlock(); } - private void CheckMagicChar(char expected, int position) { + private void CheckMagicChar(char expected, int position) + { int magic = this.input.ReadByte(); - if (magic != (int)expected) { + if (magic != (int)expected) + { var msg = String.Format("Not a valid BZip2 stream. byte {0}, expected '{1}', got '{2}'", position, (int)expected, magic); throw new IOException(msg); } } - private void InitBlock() { + private void InitBlock() + { char magic0 = bsGetUByte(); char magic1 = bsGetUByte(); char magic2 = bsGetUByte(); @@ -434,19 +466,24 @@ private void InitBlock() { char magic5 = bsGetUByte(); if (magic0 == 0x17 && magic1 == 0x72 && magic2 == 0x45 - && magic3 == 0x38 && magic4 == 0x50 && magic5 == 0x90) { + && magic3 == 0x38 && magic4 == 0x50 && magic5 == 0x90) + { complete(); // end of file - } else if (magic0 != 0x31 || - magic1 != 0x41 || - magic2 != 0x59 || - magic3 != 0x26 || - magic4 != 0x53 || - magic5 != 0x59) { + } + else if (magic0 != 0x31 || + magic1 != 0x41 || + magic2 != 0x59 || + magic3 != 0x26 || + magic4 != 0x53 || + magic5 != 0x59) + { this.currentState = CState.EOF; var msg = String.Format("bad block header at offset 0x{0:X}", this.input.Position); throw new IOException(msg); - } else { + } + else + { this.storedBlockCRC = bsGetInt(); // Console.WriteLine(" stored block CRC : {0:X8}", this.storedBlockCRC); @@ -465,11 +502,13 @@ private void InitBlock() { } - private void EndBlock() { + private void EndBlock() + { this.computedBlockCRC = (uint)this.crc.Crc32Result; // A bad CRC is considered a fatal error. - if (this.storedBlockCRC != this.computedBlockCRC) { + if (this.storedBlockCRC != this.computedBlockCRC) + { // make next blocks readable without error // (repair feature, not yet documented, not tested) // this.computedCombinedCRC = (this.storedCombinedCRC << 1) @@ -491,12 +530,14 @@ private void EndBlock() { } - private void complete() { + private void complete() + { this.storedCombinedCRC = bsGetInt(); this.currentState = CState.EOF; this.data = null; - if (this.storedCombinedCRC != this.computedCombinedCRC) { + if (this.storedCombinedCRC != this.computedCombinedCRC) + { var msg = String.Format("BZip2 CRC error (expected {0:X8}, computed {1:X8})", this.storedCombinedCRC, this.computedCombinedCRC); @@ -507,13 +548,18 @@ private void complete() { /// /// Close the stream. /// - public override void Close() { + public override void Close() + { Stream inShadow = this.input; - if (inShadow != null) { - try { + if (inShadow != null) + { + try + { if (!this._leaveOpen) inShadow.Close(); - } finally { + } + finally + { this.data = null; this.input = null; } @@ -533,12 +579,15 @@ public override void Close() { /// /// The number of bits to read, always between 1 and 32. /// - private int GetBits(int n) { + private int GetBits(int n) + { int bsLiveShadow = this.bsLive; int bsBuffShadow = this.bsBuff; - if (bsLiveShadow < n) { - do { + if (bsLiveShadow < n) + { + do + { int thech = this.input.ReadByte(); if (thech < 0) @@ -581,16 +630,19 @@ private int GetBits(int n) { // return ((bsBuffShadow >> (bsLiveShadow - 1)) & 1) != 0; // } - private bool bsGetBit() { + private bool bsGetBit() + { int bit = GetBits(1); return bit != 0; } - private char bsGetUByte() { - return (char)GetBits(8); + private char bsGetUByte() + { + return (char) GetBits(8); } - private uint bsGetInt() { + private uint bsGetInt() + { return (uint)((((((GetBits(8) << 8) | GetBits(8)) << 8) | GetBits(8)) << 8) | GetBits(8)); } @@ -599,31 +651,39 @@ private uint bsGetInt() { * Called by createHuffmanDecodingTables() exclusively. */ private static void hbCreateDecodeTables(int[] limit, - int[] bbase, int[] perm, char[] length, - int minLen, int maxLen, int alphaSize) { - for (int i = minLen, pp = 0; i <= maxLen; i++) { - for (int j = 0; j < alphaSize; j++) { - if (length[j] == i) { + int[] bbase, int[] perm, char[] length, + int minLen, int maxLen, int alphaSize) + { + for (int i = minLen, pp = 0; i <= maxLen; i++) + { + for (int j = 0; j < alphaSize; j++) + { + if (length[j] == i) + { perm[pp++] = j; } } } - for (int i = BZip2.MaxCodeLength; --i > 0;) { + for (int i = BZip2.MaxCodeLength; --i > 0;) + { bbase[i] = 0; limit[i] = 0; } - for (int i = 0; i < alphaSize; i++) { + for (int i = 0; i < alphaSize; i++) + { bbase[length[i] + 1]++; } - for (int i = 1, b = bbase[0]; i < BZip2.MaxCodeLength; i++) { + for (int i = 1, b = bbase[0]; i < BZip2.MaxCodeLength; i++) + { b += bbase[i]; bbase[i] = b; } - for (int i = minLen, vec = 0, b = bbase[i]; i <= maxLen; i++) { + for (int i = minLen, vec = 0, b = bbase[i]; i <= maxLen; i++) + { int nb = bbase[i + 1]; vec += nb - b; b = nb; @@ -631,14 +691,16 @@ private static void hbCreateDecodeTables(int[] limit, vec <<= 1; } - for (int i = minLen + 1; i <= maxLen; i++) { + for (int i = minLen + 1; i <= maxLen; i++) + { bbase[i] = ((limit[i - 1] + 1) << 1) - bbase[i]; } } - private void recvDecodingTables() { + private void recvDecodingTables() + { var s = this.data; bool[] inUse = s.inUse; byte[] pos = s.recvDecodingTables_pos; @@ -647,21 +709,28 @@ private void recvDecodingTables() { int inUse16 = 0; /* Receive the mapping table */ - for (int i = 0; i < 16; i++) { - if (bsGetBit()) { + for (int i = 0; i < 16; i++) + { + if (bsGetBit()) + { inUse16 |= 1 << i; } } - for (int i = 256; --i >= 0;) { + for (int i = 256; --i >= 0;) + { inUse[i] = false; } - for (int i = 0; i < 16; i++) { - if ((inUse16 & (1 << i)) != 0) { + for (int i = 0; i < 16; i++) + { + if ((inUse16 & (1 << i)) != 0) + { int i16 = i << 4; - for (int j = 0; j < 16; j++) { - if (bsGetBit()) { + for (int j = 0; j < 16; j++) + { + if (bsGetBit()) + { inUse[i16 + j] = true; } } @@ -675,23 +744,28 @@ private void recvDecodingTables() { int nGroups = GetBits(3); int nSelectors = GetBits(15); - for (int i = 0; i < nSelectors; i++) { + for (int i = 0; i < nSelectors; i++) + { int j = 0; - while (bsGetBit()) { + while (bsGetBit()) + { j++; } - s.selectorMtf[i] = (byte)j; + s.selectorMtf[i] = (byte) j; } /* Undo the MTF values for the selectors. */ - for (int v = nGroups; --v >= 0;) { - pos[v] = (byte)v; + for (int v = nGroups; --v >= 0;) + { + pos[v] = (byte) v; } - for (int i = 0; i < nSelectors; i++) { + for (int i = 0; i < nSelectors; i++) + { int v = s.selectorMtf[i]; byte tmp = pos[v]; - while (v > 0) { + while (v > 0) + { // nearly all times v is zero, 4 in most other cases pos[v] = pos[v - 1]; v--; @@ -703,14 +777,17 @@ private void recvDecodingTables() { char[][] len = s.temp_charArray2d; /* Now the coding tables */ - for (int t = 0; t < nGroups; t++) { + for (int t = 0; t < nGroups; t++) + { int curr = GetBits(5); char[] len_t = len[t]; - for (int i = 0; i < alphaSize; i++) { - while (bsGetBit()) { + for (int i = 0; i < alphaSize; i++) + { + while (bsGetBit()) + { curr += bsGetBit() ? -1 : 1; } - len_t[i] = (char)curr; + len_t[i] = (char) curr; } } @@ -723,15 +800,18 @@ private void recvDecodingTables() { * Called by recvDecodingTables() exclusively. */ private void createHuffmanDecodingTables(int alphaSize, - int nGroups) { + int nGroups) + { var s = this.data; char[][] len = s.temp_charArray2d; - for (int t = 0; t < nGroups; t++) { + for (int t = 0; t < nGroups; t++) + { int minLen = 32; int maxLen = 0; char[] len_t = len[t]; - for (int i = alphaSize; --i >= 0;) { + for (int i = alphaSize; --i >= 0;) + { char lent = len_t[i]; if (lent > maxLen) maxLen = lent; @@ -747,7 +827,8 @@ private void createHuffmanDecodingTables(int alphaSize, - private void getAndMoveToFrontDecode() { + private void getAndMoveToFrontDecode() + { var s = this.data; this.origPtr = GetBits(24); @@ -766,8 +847,9 @@ private void getAndMoveToFrontDecode() { * does save having to do it later in a separate pass, and so saves a * block's worth of cache misses. */ - for (int i = 256; --i >= 0;) { - yy[i] = (byte)i; + for (int i = 256; --i >= 0;) + { + yy[i] = (byte) i; s.unzftab[i] = 0; } @@ -784,27 +866,38 @@ private void getAndMoveToFrontDecode() { int[] perm_zt = s.gPerm[zt]; int minLens_zt = s.gMinlen[zt]; - while (nextSym != eob) { - if ((nextSym == BZip2.RUNA) || (nextSym == BZip2.RUNB)) { + while (nextSym != eob) + { + if ((nextSym == BZip2.RUNA) || (nextSym == BZip2.RUNB)) + { int es = -1; - for (int n = 1; true; n <<= 1) { - if (nextSym == BZip2.RUNA) { + for (int n = 1; true; n <<= 1) + { + if (nextSym == BZip2.RUNA) + { es += n; - } else if (nextSym == BZip2.RUNB) { + } + else if (nextSym == BZip2.RUNB) + { es += n << 1; - } else { + } + else + { break; } - if (groupPos == 0) { + if (groupPos == 0) + { groupPos = BZip2.G_SIZE - 1; zt = s.selector[++groupNo] & 0xff; base_zt = s.gBase[zt]; limit_zt = s.gLimit[zt]; perm_zt = s.gPerm[zt]; minLens_zt = s.gMinlen[zt]; - } else { + } + else + { groupPos--; } @@ -812,13 +905,17 @@ private void getAndMoveToFrontDecode() { // Inlined: // int zvec = GetBits(zn); - while (bsLiveShadow < zn) { + while (bsLiveShadow < zn) + { int thech = this.input.ReadByte(); - if (thech >= 0) { + if (thech >= 0) + { bsBuffShadow = (bsBuffShadow << 8) | thech; bsLiveShadow += 8; continue; - } else { + } + else + { throw new IOException("unexpected end of stream"); } } @@ -826,15 +923,20 @@ private void getAndMoveToFrontDecode() { & ((1 << zn) - 1); bsLiveShadow -= zn; - while (zvec > limit_zt[zn]) { + while (zvec > limit_zt[zn]) + { zn++; - while (bsLiveShadow < 1) { + while (bsLiveShadow < 1) + { int thech = this.input.ReadByte(); - if (thech >= 0) { + if (thech >= 0) + { bsBuffShadow = (bsBuffShadow << 8) | thech; bsLiveShadow += 8; continue; - } else { + } + else + { throw new IOException("unexpected end of stream"); } } @@ -848,13 +950,16 @@ private void getAndMoveToFrontDecode() { byte ch = s.seqToUnseq[yy[0]]; s.unzftab[ch & 0xff] += es + 1; - while (es-- >= 0) { + while (es-- >= 0) + { s.ll8[++lastShadow] = ch; } if (lastShadow >= limitLast) throw new IOException("block overrun"); - } else { + } + else + { if (++lastShadow >= limitLast) throw new IOException("block overrun"); @@ -867,24 +972,31 @@ private void getAndMoveToFrontDecode() { * native method call overhead of System.Buffer.BlockCopy for very * small ranges to copy. */ - if (nextSym <= 16) { - for (int j = nextSym - 1; j > 0;) { + if (nextSym <= 16) + { + for (int j = nextSym - 1; j > 0;) + { yy[j] = yy[--j]; } - } else { + } + else + { System.Buffer.BlockCopy(yy, 0, yy, 1, nextSym - 1); } yy[0] = tmp; - if (groupPos == 0) { + if (groupPos == 0) + { groupPos = BZip2.G_SIZE - 1; zt = s.selector[++groupNo] & 0xff; base_zt = s.gBase[zt]; limit_zt = s.gLimit[zt]; perm_zt = s.gPerm[zt]; minLens_zt = s.gMinlen[zt]; - } else { + } + else + { groupPos--; } @@ -892,13 +1004,17 @@ private void getAndMoveToFrontDecode() { // Inlined: // int zvec = GetBits(zn); - while (bsLiveShadow < zn) { + while (bsLiveShadow < zn) + { int thech = this.input.ReadByte(); - if (thech >= 0) { + if (thech >= 0) + { bsBuffShadow = (bsBuffShadow << 8) | thech; bsLiveShadow += 8; continue; - } else { + } + else + { throw new IOException("unexpected end of stream"); } } @@ -906,15 +1022,20 @@ private void getAndMoveToFrontDecode() { & ((1 << zn) - 1); bsLiveShadow -= zn; - while (zvec > limit_zt[zn]) { + while (zvec > limit_zt[zn]) + { zn++; - while (bsLiveShadow < 1) { + while (bsLiveShadow < 1) + { int thech = this.input.ReadByte(); - if (thech >= 0) { + if (thech >= 0) + { bsBuffShadow = (bsBuffShadow << 8) | thech; bsLiveShadow += 8; continue; - } else { + } + else + { throw new IOException("unexpected end of stream"); } } @@ -931,7 +1052,8 @@ private void getAndMoveToFrontDecode() { } - private int getAndMoveToFrontDecode0(int groupNo) { + private int getAndMoveToFrontDecode0(int groupNo) + { var s = this.data; int zt = s.selector[groupNo] & 0xff; int[] limit_zt = s.gLimit[zt]; @@ -940,16 +1062,21 @@ private int getAndMoveToFrontDecode0(int groupNo) { int bsLiveShadow = this.bsLive; int bsBuffShadow = this.bsBuff; - while (zvec > limit_zt[zn]) { + while (zvec > limit_zt[zn]) + { zn++; - while (bsLiveShadow < 1) { + while (bsLiveShadow < 1) + { int thech = this.input.ReadByte(); - if (thech >= 0) { + if (thech >= 0) + { bsBuffShadow = (bsBuffShadow << 8) | thech; bsLiveShadow += 8; continue; - } else { + } + else + { throw new IOException("unexpected end of stream"); } } @@ -964,7 +1091,8 @@ private int getAndMoveToFrontDecode0(int groupNo) { } - private void SetupBlock() { + private void SetupBlock() + { if (this.data == null) return; @@ -975,31 +1103,36 @@ private void SetupBlock() { // xxxx /* Check: unzftab entries in range. */ - for (i = 0; i <= 255; i++) { + for (i = 0; i <= 255; i++) + { if (s.unzftab[i] < 0 || s.unzftab[i] > this.last) throw new Exception("BZ_DATA_ERROR"); } /* Actually generate cftab. */ s.cftab[0] = 0; - for (i = 1; i <= 256; i++) s.cftab[i] = s.unzftab[i - 1]; - for (i = 1; i <= 256; i++) s.cftab[i] += s.cftab[i - 1]; + for (i = 1; i <= 256; i++) s.cftab[i] = s.unzftab[i-1]; + for (i = 1; i <= 256; i++) s.cftab[i] += s.cftab[i-1]; /* Check: cftab entries in range. */ - for (i = 0; i <= 256; i++) { - if (s.cftab[i] < 0 || s.cftab[i] > this.last + 1) { + for (i = 0; i <= 256; i++) + { + if (s.cftab[i] < 0 || s.cftab[i] > this.last+1) + { var msg = String.Format("BZ_DATA_ERROR: cftab[{0}]={1} last={2}", i, s.cftab[i], this.last); throw new Exception(msg); } } /* Check: cftab entries non-descending. */ - for (i = 1; i <= 256; i++) { - if (s.cftab[i - 1] > s.cftab[i]) + for (i = 1; i <= 256; i++) + { + if (s.cftab[i-1] > s.cftab[i]) throw new Exception("BZ_DATA_ERROR"); } int lastShadow; - for (i = 0, lastShadow = this.last; i <= lastShadow; i++) { + for (i = 0, lastShadow = this.last; i <= lastShadow; i++) + { tt[s.cftab[s.ll8[i] & 0xff]++] = i; } @@ -1011,28 +1144,37 @@ private void SetupBlock() { this.su_i2 = 0; this.su_ch2 = 256; /* not a valid 8-bit byte value?, and not EOF */ - if (this.blockRandomised) { + if (this.blockRandomised) + { this.su_rNToGo = 0; this.su_rTPos = 0; SetupRandPartA(); - } else { + } + else + { SetupNoRandPartA(); } } - private void SetupRandPartA() { - if (this.su_i2 <= this.last) { + private void SetupRandPartA() + { + if (this.su_i2 <= this.last) + { this.su_chPrev = this.su_ch2; int su_ch2Shadow = this.data.ll8[this.su_tPos] & 0xff; this.su_tPos = this.data.tt[this.su_tPos]; - if (this.su_rNToGo == 0) { + if (this.su_rNToGo == 0) + { this.su_rNToGo = Rand.Rnums(this.su_rTPos) - 1; - if (++this.su_rTPos == 512) { + if (++this.su_rTPos == 512) + { this.su_rTPos = 0; } - } else { + } + else + { this.su_rNToGo--; } this.su_ch2 = su_ch2Shadow ^= (this.su_rNToGo == 1) ? 1 : 0; @@ -1040,15 +1182,19 @@ private void SetupRandPartA() { this.currentChar = su_ch2Shadow; this.currentState = CState.RAND_PART_B; this.crc.UpdateCRC((byte)su_ch2Shadow); - } else { + } + else + { EndBlock(); InitBlock(); SetupBlock(); } } - private void SetupNoRandPartA() { - if (this.su_i2 <= this.last) { + private void SetupNoRandPartA() + { + if (this.su_i2 <= this.last) + { this.su_chPrev = this.su_ch2; int su_ch2Shadow = this.data.ll8[this.su_tPos] & 0xff; this.su_ch2 = su_ch2Shadow; @@ -1057,7 +1203,9 @@ private void SetupNoRandPartA() { this.currentChar = su_ch2Shadow; this.currentState = CState.NO_RAND_PART_B; this.crc.UpdateCRC((byte)su_ch2Shadow); - } else { + } + else + { this.currentState = CState.NO_RAND_PART_A; EndBlock(); InitBlock(); @@ -1065,40 +1213,55 @@ private void SetupNoRandPartA() { } } - private void SetupRandPartB() { - if (this.su_ch2 != this.su_chPrev) { + private void SetupRandPartB() + { + if (this.su_ch2 != this.su_chPrev) + { this.currentState = CState.RAND_PART_A; this.su_count = 1; SetupRandPartA(); - } else if (++this.su_count >= 4) { - this.su_z = (char)(this.data.ll8[this.su_tPos] & 0xff); + } + else if (++this.su_count >= 4) + { + this.su_z = (char) (this.data.ll8[this.su_tPos] & 0xff); this.su_tPos = this.data.tt[this.su_tPos]; - if (this.su_rNToGo == 0) { + if (this.su_rNToGo == 0) + { this.su_rNToGo = Rand.Rnums(this.su_rTPos) - 1; - if (++this.su_rTPos == 512) { + if (++this.su_rTPos == 512) + { this.su_rTPos = 0; } - } else { + } + else + { this.su_rNToGo--; } this.su_j2 = 0; this.currentState = CState.RAND_PART_C; - if (this.su_rNToGo == 1) { + if (this.su_rNToGo == 1) + { this.su_z ^= (char)1; } SetupRandPartC(); - } else { + } + else + { this.currentState = CState.RAND_PART_A; SetupRandPartA(); } } - private void SetupRandPartC() { - if (this.su_j2 < this.su_z) { + private void SetupRandPartC() + { + if (this.su_j2 < this.su_z) + { this.currentChar = this.su_ch2; this.crc.UpdateCRC((byte)this.su_ch2); this.su_j2++; - } else { + } + else + { this.currentState = CState.RAND_PART_A; this.su_i2++; this.su_count = 0; @@ -1106,35 +1269,46 @@ private void SetupRandPartC() { } } - private void SetupNoRandPartB() { - if (this.su_ch2 != this.su_chPrev) { + private void SetupNoRandPartB() + { + if (this.su_ch2 != this.su_chPrev) + { this.su_count = 1; SetupNoRandPartA(); - } else if (++this.su_count >= 4) { - this.su_z = (char)(this.data.ll8[this.su_tPos] & 0xff); + } + else if (++this.su_count >= 4) + { + this.su_z = (char) (this.data.ll8[this.su_tPos] & 0xff); this.su_tPos = this.data.tt[this.su_tPos]; this.su_j2 = 0; SetupNoRandPartC(); - } else { + } + else + { SetupNoRandPartA(); } } - private void SetupNoRandPartC() { - if (this.su_j2 < this.su_z) { + private void SetupNoRandPartC() + { + if (this.su_j2 < this.su_z) + { int su_ch2Shadow = this.su_ch2; this.currentChar = su_ch2Shadow; this.crc.UpdateCRC((byte)su_ch2Shadow); this.su_j2++; this.currentState = CState.NO_RAND_PART_C; - } else { + } + else + { this.su_i2++; this.su_count = 0; SetupNoRandPartA(); } } - private sealed class DecompressionState { + private sealed class DecompressionState + { // (with blockSize 900k) public readonly bool[] inUse = new bool[256]; public readonly byte[] seqToUnseq = new byte[256]; // 256 byte @@ -1165,17 +1339,18 @@ private sealed class DecompressionState { // 4560782 byte // =============== - public DecompressionState(int blockSize100k) { + public DecompressionState(int blockSize100k) + { this.unzftab = new int[256]; // 1024 byte - this.gLimit = BZip2.InitRectangularArray(BZip2.NGroups, BZip2.MaxAlphaSize); - this.gBase = BZip2.InitRectangularArray(BZip2.NGroups, BZip2.MaxAlphaSize); - this.gPerm = BZip2.InitRectangularArray(BZip2.NGroups, BZip2.MaxAlphaSize); + this.gLimit = BZip2.InitRectangularArray(BZip2.NGroups,BZip2.MaxAlphaSize); + this.gBase = BZip2.InitRectangularArray(BZip2.NGroups,BZip2.MaxAlphaSize); + this.gPerm = BZip2.InitRectangularArray(BZip2.NGroups,BZip2.MaxAlphaSize); this.gMinlen = new int[BZip2.NGroups]; // 24 byte this.cftab = new int[257]; // 1028 byte this.getAndMoveToFrontDecode_yy = new byte[256]; // 512 byte - this.temp_charArray2d = BZip2.InitRectangularArray(BZip2.NGroups, BZip2.MaxAlphaSize); + this.temp_charArray2d = BZip2.InitRectangularArray(BZip2.NGroups,BZip2.MaxAlphaSize); this.recvDecodingTables_pos = new byte[BZip2.NGroups]; // 6 byte this.ll8 = new byte[blockSize100k * BZip2.BlockSizeMultiple]; @@ -1188,14 +1363,16 @@ public DecompressionState(int blockSize100k) { * I don't initialize it at construction time to avoid unneccessary * memory allocation when compressing small files. */ - public int[] initTT(int length) { + public int[] initTT(int length) + { int[] ttShadow = this.tt; // tt.length should always be >= length, but theoretically // it can happen, if the compressor mixed small and large // blocks. Normally only the last block will be smaller // than others. - if ((ttShadow == null) || (ttShadow.Length < length)) { + if ((ttShadow == null) || (ttShadow.Length < length)) + { this.tt = ttShadow = new int[length]; } @@ -1338,33 +1515,36 @@ private struct StateDump { // } - internal static class BZip2 { - internal static T[][] InitRectangularArray(int d1, int d2) { - var x = new T[d1][]; - for (int i = 0; i < d1; i++) { - x[i] = new T[d2]; + internal static class BZip2 + { + internal static T[][] InitRectangularArray(int d1, int d2) + { + var x = new T[d1][]; + for (int i=0; i < d1; i++) + { + x[i] = new T[d2]; + } + return x; } - return x; - } - public static readonly int BlockSizeMultiple = 100000; - public static readonly int MinBlockSize = 1; - public static readonly int MaxBlockSize = 9; - public static readonly int MaxAlphaSize = 258; - public static readonly int MaxCodeLength = 23; - public static readonly char RUNA = (char)0; - public static readonly char RUNB = (char)1; - public static readonly int NGroups = 6; - public static readonly int G_SIZE = 50; - public static readonly int N_ITERS = 4; - public static readonly int MaxSelectors = (2 + (900000 / G_SIZE)); + public static readonly int BlockSizeMultiple = 100000; + public static readonly int MinBlockSize = 1; + public static readonly int MaxBlockSize = 9; + public static readonly int MaxAlphaSize = 258; + public static readonly int MaxCodeLength = 23; + public static readonly char RUNA = (char) 0; + public static readonly char RUNB = (char) 1; + public static readonly int NGroups = 6; + public static readonly int G_SIZE = 50; + public static readonly int N_ITERS = 4; + public static readonly int MaxSelectors = (2 + (900000 / G_SIZE)); public static readonly int NUM_OVERSHOOT_BYTES = 20; - /* - *

If you are ever unlucky/improbable enough to get a stack - * overflow whilst sorting, increase the following constant and - * try again. In practice I have never seen the stack go above 27 - * elems, so the following limit seems very generous.

- */ + /* + *

If you are ever unlucky/improbable enough to get a stack + * overflow whilst sorting, increase the following constant and + * try again. In practice I have never seen the stack go above 27 + * elems, so the following limit seems very generous.

+ */ internal static readonly int QSORT_STACK_SIZE = 1000; diff --git a/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs b/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs index 95b5d3a80..41863ffb0 100644 --- a/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs +++ b/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs @@ -83,12 +83,14 @@ using System.IO; -namespace Ionic.BZip2 { +namespace Ionic.BZip2 +{ /// /// A write-only decorator stream that compresses data as it is /// written using the BZip2 algorithm. /// - public class BZip2OutputStream : System.IO.Stream { + public class BZip2OutputStream : System.IO.Stream + { private int totalBytesWrittenIn; private bool leaveOpen; private BZip2Compressor compressor; @@ -134,7 +136,8 @@ public class BZip2OutputStream : System.IO.Stream { /// /// public BZip2OutputStream(Stream output) - : this(output, BZip2.MaxBlockSize, false) { + : this(output, BZip2.MaxBlockSize, false) + { } @@ -147,7 +150,8 @@ public BZip2OutputStream(Stream output) /// The valid range is 1..9. /// public BZip2OutputStream(Stream output, int blockSize) - : this(output, blockSize, false) { + : this(output, blockSize, false) + { } @@ -159,7 +163,8 @@ public BZip2OutputStream(Stream output, int blockSize) /// whether to leave the captive stream open upon closing this stream. /// public BZip2OutputStream(Stream output, bool leaveOpen) - : this(output, BZip2.MaxBlockSize, leaveOpen) { + : this(output, BZip2.MaxBlockSize, leaveOpen) + { } @@ -176,9 +181,11 @@ public BZip2OutputStream(Stream output, bool leaveOpen) /// /// whether to leave the captive stream open upon closing this stream. /// - public BZip2OutputStream(Stream output, int blockSize, bool leaveOpen) { + public BZip2OutputStream(Stream output, int blockSize, bool leaveOpen) + { if (blockSize < BZip2.MinBlockSize || - blockSize > BZip2.MaxBlockSize) { + blockSize > BZip2.MaxBlockSize) + { var msg = String.Format("blockSize={0} is out of range; must be between {1} and {2}", blockSize, BZip2.MinBlockSize, BZip2.MaxBlockSize); @@ -209,8 +216,10 @@ public BZip2OutputStream(Stream output, int blockSize, bool leaveOpen) { /// constructors that accept a bool value. /// /// - public override void Close() { - if (output != null) { + public override void Close() + { + if (output != null) + { Stream o = this.output; Finish(); if (!leaveOpen) @@ -222,14 +231,17 @@ public override void Close() { /// /// Flush the stream. /// - public override void Flush() { - if (this.output != null) { + public override void Flush() + { + if (this.output != null) + { this.bw.Flush(); this.output.Flush(); } } - private void EmitHeader() { + private void EmitHeader() + { var magic = new byte[] { (byte) 'B', (byte) 'Z', @@ -241,7 +253,8 @@ private void EmitHeader() { this.output.Write(magic, 0, magic.Length); } - private void EmitTrailer() { + private void EmitTrailer() + { // A magic 48-bit number, 0x177245385090, to indicate the end // of the last block. (sqrt(pi), if you want to know) @@ -264,26 +277,30 @@ private void EmitTrailer() { this.bw.TotalBytesWrittenOut); } - private void Finish() { + private void Finish() + { // Console.WriteLine("BZip2:Finish"); - try { + try + { var totalBefore = this.bw.TotalBytesWrittenOut; this.compressor.CompressAndWrite(); - TraceOutput(TraceBits.Write, "out block length (bytes): {0} (0x{0:X})", + TraceOutput(TraceBits.Write,"out block length (bytes): {0} (0x{0:X})", this.bw.TotalBytesWrittenOut - totalBefore); TraceOutput(TraceBits.Crc, " combined CRC (before): {0:X8}", this.combinedCRC); this.combinedCRC = (this.combinedCRC << 1) | (this.combinedCRC >> 31); - this.combinedCRC ^= (uint)compressor.Crc32; + this.combinedCRC ^= (uint) compressor.Crc32; TraceOutput(TraceBits.Crc, " block CRC : {0:X8}", this.compressor.Crc32); TraceOutput(TraceBits.Crc, " combined CRC (final) : {0:X8}", this.combinedCRC); EmitTrailer(); - } finally { + } + finally + { this.output = null; this.compressor = null; this.bw = null; @@ -294,7 +311,8 @@ private void Finish() { /// /// The blocksize parameter specified at construction time. /// - public int BlockSize { + public int BlockSize + { get { return this.blockSize100k; } } @@ -321,7 +339,8 @@ public int BlockSize { /// The buffer holding data to write to the stream. /// the offset within that data array to find the first byte to write. /// the number of bytes to write. - public override void Write(byte[] buffer, int offset, int count) { + public override void Write(byte[] buffer, int offset, int count) + { if (offset < 0) throw new IndexOutOfRangeException(String.Format("offset ({0}) must be > 0", offset)); if (count < 0) @@ -337,28 +356,30 @@ public override void Write(byte[] buffer, int offset, int count) { int bytesWritten = 0; int bytesRemaining = count; - do { + do + { int n = compressor.Fill(buffer, offset, bytesRemaining); - if (n != bytesRemaining) { + if (n != bytesRemaining) + { // The compressor data block is full. Compress and // write out the compressed data, then reset the // compressor and continue. var totalBefore = this.bw.TotalBytesWrittenOut; this.compressor.CompressAndWrite(); - TraceOutput(TraceBits.Write, "out block length (bytes): {0} (0x{0:X})", + TraceOutput(TraceBits.Write,"out block length (bytes): {0} (0x{0:X})", this.bw.TotalBytesWrittenOut - totalBefore); - // and now any remaining bits - TraceOutput(TraceBits.Write, - " remaining: {0} 0x{1:X}", - this.bw.NumRemainingBits, - this.bw.RemainingBits); + // and now any remaining bits + TraceOutput(TraceBits.Write, + " remaining: {0} 0x{1:X}", + this.bw.NumRemainingBits, + this.bw.RemainingBits); TraceOutput(TraceBits.Crc, " combined CRC (before): {0:X8}", this.combinedCRC); this.combinedCRC = (this.combinedCRC << 1) | (this.combinedCRC >> 31); - this.combinedCRC ^= (uint)compressor.Crc32; + this.combinedCRC ^= (uint) compressor.Crc32; TraceOutput(TraceBits.Crc, " block CRC : {0:X8}", compressor.Crc32); TraceOutput(TraceBits.Crc, " combined CRC (after) : {0:X8}", @@ -381,7 +402,8 @@ public override void Write(byte[] buffer, int offset, int count) { /// /// The return value is always false. /// - public override bool CanRead { + public override bool CanRead + { get { return false; } } @@ -391,7 +413,8 @@ public override bool CanRead { /// /// Always returns false. /// - public override bool CanSeek { + public override bool CanSeek + { get { return false; } } @@ -402,8 +425,10 @@ public override bool CanSeek { /// The return value should always be true, unless and until the /// object is disposed and closed. /// - public override bool CanWrite { - get { + public override bool CanWrite + { + get + { if (this.output == null) throw new ObjectDisposedException("BZip2Stream"); return this.output.CanWrite; } @@ -412,7 +437,8 @@ public override bool CanWrite { /// /// Reading this property always throws a . /// - public override long Length { + public override long Length + { get { throw new NotImplementedException(); } } @@ -425,8 +451,10 @@ public override long Length { /// cref="NotImplementedException"/>. Reading will return the /// total number of uncompressed bytes written through. /// - public override long Position { - get { + public override long Position + { + get + { return this.totalBytesWrittenIn; } set { throw new NotImplementedException(); } @@ -438,7 +466,8 @@ public override long Position { /// this is irrelevant, since it will always throw! /// this is irrelevant, since it will always throw! /// irrelevant! - public override long Seek(long offset, System.IO.SeekOrigin origin) { + public override long Seek(long offset, System.IO.SeekOrigin origin) + { throw new NotImplementedException(); } @@ -446,7 +475,8 @@ public override long Seek(long offset, System.IO.SeekOrigin origin) { /// Calling this method always throws a . ///
/// this is irrelevant, since it will always throw! - public override void SetLength(long value) { + public override void SetLength(long value) + { throw new NotImplementedException(); } @@ -457,28 +487,32 @@ public override void SetLength(long value) { /// this parameter is never used /// this parameter is never used /// never returns anything; always throws - public override int Read(byte[] buffer, int offset, int count) { + public override int Read(byte[] buffer, int offset, int count) + { throw new NotImplementedException(); } // used only when Trace is defined [Flags] - private enum TraceBits : uint { - None = 0, - Crc = 1, - Write = 2, - All = 0xffffffff, + private enum TraceBits : uint + { + None = 0, + Crc = 1, + Write = 2, + All = 0xffffffff, } [System.Diagnostics.ConditionalAttribute("Trace")] - private void TraceOutput(TraceBits bits, string format, params object[] varParams) { - if ((bits & this.desiredTrace) != 0) { + private void TraceOutput(TraceBits bits, string format, params object[] varParams) + { + if ((bits & this.desiredTrace) != 0) + { //lock(outputLock) { int tid = System.Threading.Thread.CurrentThread.GetHashCode(); - Console.ForegroundColor = (ConsoleColor)(tid % 8 + 10); + Console.ForegroundColor = (ConsoleColor) (tid % 8 + 10); Console.Write("{0:000} PBOS ", tid); Console.WriteLine(format, varParams); Console.ResetColor(); diff --git a/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BitWriter.cs b/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BitWriter.cs index ab991203f..02ab1bb9a 100644 --- a/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BitWriter.cs +++ b/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BitWriter.cs @@ -80,17 +80,21 @@ // +using System; using System.IO; -namespace Ionic.BZip2 { +namespace Ionic.BZip2 +{ - internal class BitWriter { + internal class BitWriter + { private uint accumulator; private int nAccumulatedBits; private Stream output; private int totalBytesWrittenOut; - public BitWriter(Stream s) { + public BitWriter(Stream s) + { this.output = s; } @@ -103,20 +107,26 @@ public BitWriter(Stream s) { /// in other words it is valid only after a call to Flush(). /// /// - public byte RemainingBits { - get { - return (byte)(this.accumulator >> (32 - this.nAccumulatedBits) & 0xff); + public byte RemainingBits + { + get + { + return (byte) (this.accumulator >> (32 - this.nAccumulatedBits) & 0xff); } } - public int NumRemainingBits { - get { + public int NumRemainingBits + { + get + { return this.nAccumulatedBits; } } - public int TotalBytesWrittenOut { - get { + public int TotalBytesWrittenOut + { + get + { return this.totalBytesWrittenOut; } } @@ -131,7 +141,8 @@ public int TotalBytesWrittenOut { /// distinct data blocks. /// /// - public void Reset() { + public void Reset() + { this.accumulator = 0; this.nAccumulatedBits = 0; this.totalBytesWrittenOut = 0; @@ -148,12 +159,14 @@ public void Reset() { /// reasons, this method does not check! /// /// - public void WriteBits(int nbits, uint value) { + public void WriteBits(int nbits, uint value) + { int nAccumulated = this.nAccumulatedBits; uint u = this.accumulator; - while (nAccumulated >= 8) { - this.output.WriteByte((byte)(u >> 24 & 0xff)); + while (nAccumulated >= 8) + { + this.output.WriteByte ((byte)(u >> 24 & 0xff)); this.totalBytesWrittenOut++; u <<= 8; nAccumulated -= 8; @@ -174,14 +187,16 @@ public void WriteBits(int nbits, uint value) { /// /// Write a full 8-bit byte into the output. /// - public void WriteByte(byte b) { + public void WriteByte(byte b) + { WriteBits(8, b); } /// /// Write four 8-bit bytes into the output. /// - public void WriteInt(uint u) { + public void WriteInt(uint u) + { WriteBits(8, (u >> 24) & 0xff); WriteBits(8, (u >> 16) & 0xff); WriteBits(8, (u >> 8) & 0xff); @@ -205,8 +220,9 @@ public void WriteInt(uint u) { /// parent BZip2OutputStream. /// /// - public void Flush() { - WriteBits(0, 0); + public void Flush() + { + WriteBits(0,0); } @@ -215,10 +231,12 @@ public void Flush() { /// necessary. This must be the last method invoked on an instance of /// BitWriter. ///
- public void FinishAndPad() { + public void FinishAndPad() + { Flush(); - if (this.NumRemainingBits > 0) { + if (this.NumRemainingBits > 0) + { byte b = (byte)((this.accumulator >> 24) & 0xff); this.output.WriteByte(b); this.totalBytesWrittenOut++; diff --git a/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/CRC32.cs b/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/CRC32.cs index ffc0397cb..46f3ad2e4 100644 --- a/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/CRC32.cs +++ b/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/CRC32.cs @@ -27,8 +27,10 @@ using System; +using Interop = System.Runtime.InteropServices; -namespace Ionic.Crc { +namespace Ionic.Crc +{ /// /// Computes a CRC-32. The CRC-32 algorithm is parameterized - you /// can set the polynomial and enable or disable bit @@ -40,12 +42,15 @@ namespace Ionic.Crc { /// archive files. /// - public class CRC32 { + public class CRC32 + { /// /// Indicates the total number of bytes applied to the CRC. /// - public Int64 TotalBytesRead { - get { + public Int64 TotalBytesRead + { + get + { return _TotalBytesRead; } } @@ -53,8 +58,10 @@ public Int64 TotalBytesRead { /// /// Indicates the current CRC for all blocks slurped in. /// - public Int32 Crc32Result { - get { + public Int32 Crc32Result + { + get + { return unchecked((Int32)(~_register)); } } @@ -64,7 +71,8 @@ public Int32 Crc32Result { /// /// The stream over which to calculate the CRC32 /// the CRC32 calculation - public Int32 GetCrc32(System.IO.Stream input) { + public Int32 GetCrc32(System.IO.Stream input) + { return GetCrc32AndCopy(input, null); } @@ -75,11 +83,13 @@ public Int32 GetCrc32(System.IO.Stream input) { /// The stream over which to calculate the CRC32 /// The stream into which to deflate the input /// the CRC32 calculation - public Int32 GetCrc32AndCopy(System.IO.Stream input, System.IO.Stream output) { + public Int32 GetCrc32AndCopy(System.IO.Stream input, System.IO.Stream output) + { if (input == null) throw new Exception("The input stream must not be null."); - unchecked { + unchecked + { byte[] buffer = new byte[BUFFER_SIZE]; int readSize = BUFFER_SIZE; @@ -87,7 +97,8 @@ public Int32 GetCrc32AndCopy(System.IO.Stream input, System.IO.Stream output) { int count = input.Read(buffer, 0, readSize); output?.Write(buffer, 0, count); _TotalBytesRead += count; - while (count > 0) { + while (count > 0) + { SlurpBlock(buffer, 0, count); count = input.Read(buffer, 0, readSize); if (output != null) output.Write(buffer, 0, count); @@ -106,11 +117,13 @@ public Int32 GetCrc32AndCopy(System.IO.Stream input, System.IO.Stream output) { /// The word to start with. /// The byte to combine it with. /// The CRC-ized result. - public Int32 ComputeCrc32(Int32 W, byte B) { + public Int32 ComputeCrc32(Int32 W, byte B) + { return _InternalComputeCrc32((UInt32)W, B); } - internal Int32 _InternalComputeCrc32(UInt32 W, byte B) { + internal Int32 _InternalComputeCrc32(UInt32 W, byte B) + { return (Int32)(crc32Table[(W ^ B) & 0xFF] ^ (W >> 8)); } @@ -122,18 +135,23 @@ internal Int32 _InternalComputeCrc32(UInt32 W, byte B) { /// block of bytes to slurp /// starting point in the block /// how many bytes within the block to slurp - public void SlurpBlock(byte[] block, int offset, int count) { + public void SlurpBlock(byte[] block, int offset, int count) + { if (block == null) throw new Exception("The data buffer must not be null."); // bzip algorithm - for (int i = 0; i < count; i++) { + for (int i = 0; i < count; i++) + { int x = offset + i; byte b = block[x]; - if (this.reverseBits) { + if (this.reverseBits) + { UInt32 temp = (_register >> 24) ^ b; _register = (_register << 8) ^ crc32Table[temp]; - } else { + } + else + { UInt32 temp = (_register & 0x000000FF) ^ b; _register = (_register >> 8) ^ crc32Table[temp]; } @@ -146,11 +164,15 @@ public void SlurpBlock(byte[] block, int offset, int count) { /// Process one byte in the CRC. ///
/// the byte to include into the CRC . - public void UpdateCRC(byte b) { - if (this.reverseBits) { + public void UpdateCRC(byte b) + { + if (this.reverseBits) + { UInt32 temp = (_register >> 24) ^ b; _register = (_register << 8) ^ crc32Table[temp]; - } else { + } + else + { UInt32 temp = (_register & 0x000000FF) ^ b; _register = (_register >> 8) ^ crc32Table[temp]; } @@ -170,14 +192,19 @@ public void UpdateCRC(byte b) { /// /// the byte to include into the CRC. /// the number of times that byte should be repeated. - public void UpdateCRC(byte b, int n) { - while (n-- > 0) { - if (this.reverseBits) { + public void UpdateCRC(byte b, int n) + { + while (n-- > 0) + { + if (this.reverseBits) + { uint temp = (_register >> 24) ^ b; _register = (_register << 8) ^ crc32Table[(temp >= 0) ? temp : (temp + 256)]; - } else { + } + else + { UInt32 temp = (_register & 0x000000FF) ^ b; _register = (_register >> 8) ^ crc32Table[(temp >= 0) ? temp @@ -189,8 +216,10 @@ public void UpdateCRC(byte b, int n) { - private static uint ReverseBits(uint data) { - unchecked { + private static uint ReverseBits(uint data) + { + unchecked + { uint ret = data; ret = (ret & 0x55555555) << 1 | (ret >> 1) & 0x55555555; ret = (ret & 0x33333333) << 2 | (ret >> 2) & 0x33333333; @@ -200,8 +229,10 @@ private static uint ReverseBits(uint data) { } } - private static byte ReverseBits(byte data) { - unchecked { + private static byte ReverseBits(byte data) + { + unchecked + { uint u = (uint)data * 0x00020202; uint m = 0x01044010; uint s = u & m; @@ -212,27 +243,37 @@ private static byte ReverseBits(byte data) { - private void GenerateLookupTable() { + private void GenerateLookupTable() + { crc32Table = new UInt32[256]; - unchecked { + unchecked + { UInt32 dwCrc; byte i = 0; - do { + do + { dwCrc = i; - for (byte j = 8; j > 0; j--) { - if ((dwCrc & 1) == 1) { + for (byte j = 8; j > 0; j--) + { + if ((dwCrc & 1) == 1) + { dwCrc = (dwCrc >> 1) ^ dwPolynomial; - } else { + } + else + { dwCrc >>= 1; } } - if (reverseBits) { + if (reverseBits) + { crc32Table[ReverseBits(i)] = ReverseBits(dwCrc); - } else { + } + else + { crc32Table[i] = dwCrc; } i++; - } while (i != 0); + } while (i!=0); } #if VERBOSE @@ -253,11 +294,13 @@ private void GenerateLookupTable() { } - private uint gf2_matrix_times(uint[] matrix, uint vec) { + private uint gf2_matrix_times(uint[] matrix, uint vec) + { uint sum = 0; - int i = 0; - while (vec != 0) { - if ((vec & 0x01) == 0x01) + int i=0; + while (vec != 0) + { + if ((vec & 0x01)== 0x01) sum ^= matrix[i]; vec >>= 1; i++; @@ -265,7 +308,8 @@ private uint gf2_matrix_times(uint[] matrix, uint vec) { return sum; } - private void gf2_matrix_square(uint[] square, uint[] mat) { + private void gf2_matrix_square(uint[] square, uint[] mat) + { for (int i = 0; i < 32; i++) square[i] = gf2_matrix_times(mat, mat[i]); } @@ -283,20 +327,22 @@ private void gf2_matrix_square(uint[] square, uint[] mat) { /// /// the crc value to be combined with this one /// the length of data the CRC value was calculated on - public void Combine(int crc, int length) { + public void Combine(int crc, int length) + { uint[] even = new uint[32]; // even-power-of-two zeros operator uint[] odd = new uint[32]; // odd-power-of-two zeros operator if (length == 0) return; - uint crc1 = ~_register; - uint crc2 = (uint)crc; + uint crc1= ~_register; + uint crc2= (uint) crc; // put operator for one zero bit in odd odd[0] = this.dwPolynomial; // the CRC-32 polynomial uint row = 1; - for (int i = 1; i < 32; i++) { + for (int i = 1; i < 32; i++) + { odd[i] = row; row <<= 1; } @@ -307,7 +353,7 @@ public void Combine(int crc, int length) { // put operator for four zero bits in odd gf2_matrix_square(odd, even); - uint len2 = (uint)length; + uint len2 = (uint) length; // apply len2 zeros to crc1 (first square will put the operator for one // zero byte, eight zero bits, in even) @@ -315,7 +361,7 @@ public void Combine(int crc, int length) { // apply zeros operator for this bit of len2 gf2_matrix_square(even, odd); - if ((len2 & 1) == 1) + if ((len2 & 1)== 1) crc1 = gf2_matrix_times(even, crc1); len2 >>= 1; @@ -324,7 +370,7 @@ public void Combine(int crc, int length) { // another iteration of the loop with odd and even swapped gf2_matrix_square(odd, even); - if ((len2 & 1) == 1) + if ((len2 & 1)==1) crc1 = gf2_matrix_times(odd, crc1); len2 >>= 1; @@ -333,7 +379,7 @@ public void Combine(int crc, int length) { crc1 ^= crc2; - _register = ~crc1; + _register= ~crc1; //return (int) crc1; return; @@ -344,7 +390,8 @@ public void Combine(int crc, int length) { /// Create an instance of the CRC32 class using the default settings: no /// bit reversal, and a polynomial of 0xEDB88320. ///
- public CRC32() : this(false) { + public CRC32() : this(false) + { } /// @@ -364,7 +411,8 @@ public CRC32() : this(false) { /// /// public CRC32(bool reverseBits) : - this(unchecked((int)0xEDB88320), reverseBits) { + this( unchecked((int)0xEDB88320), reverseBits) + { } @@ -393,9 +441,10 @@ public CRC32(bool reverseBits) : /// reverseBits parameter. /// /// - public CRC32(int polynomial, bool reverseBits) { + public CRC32(int polynomial, bool reverseBits) + { this.reverseBits = reverseBits; - this.dwPolynomial = (uint)polynomial; + this.dwPolynomial = (uint) polynomial; this.GenerateLookupTable(); } @@ -408,7 +457,8 @@ public CRC32(int polynomial, bool reverseBits) { /// multiple, distinct CRCs on multiple, distinct data blocks. /// /// - public void Reset() { + public void Reset() + { _register = 0xFFFFFFFFU; } @@ -441,7 +491,8 @@ public void Reset() { /// DotNetZip library. /// /// - public class CrcCalculatorStream : System.IO.Stream, System.IDisposable { + public class CrcCalculatorStream : System.IO.Stream, System.IDisposable + { private static readonly Int64 UnsetLengthLimit = -99; internal System.IO.Stream _innerStream; @@ -461,7 +512,8 @@ public class CrcCalculatorStream : System.IO.Stream, System.IDisposable { /// /// The underlying stream public CrcCalculatorStream(System.IO.Stream stream) - : this(true, CrcCalculatorStream.UnsetLengthLimit, stream, null) { + : this(true, CrcCalculatorStream.UnsetLengthLimit, stream, null) + { } /// @@ -478,7 +530,8 @@ public CrcCalculatorStream(System.IO.Stream stream) /// true to leave the underlying stream /// open upon close of the CrcCalculatorStream; false otherwise. public CrcCalculatorStream(System.IO.Stream stream, bool leaveOpen) - : this(leaveOpen, CrcCalculatorStream.UnsetLengthLimit, stream, null) { + : this(leaveOpen, CrcCalculatorStream.UnsetLengthLimit, stream, null) + { } /// @@ -498,7 +551,8 @@ public CrcCalculatorStream(System.IO.Stream stream, bool leaveOpen) /// The underlying stream /// The length of the stream to slurp public CrcCalculatorStream(System.IO.Stream stream, Int64 length) - : this(true, length, stream, null) { + : this(true, length, stream, null) + { if (length < 0) throw new ArgumentException("length"); } @@ -519,7 +573,8 @@ public CrcCalculatorStream(System.IO.Stream stream, Int64 length) /// true to leave the underlying stream /// open upon close of the CrcCalculatorStream; false otherwise. public CrcCalculatorStream(System.IO.Stream stream, Int64 length, bool leaveOpen) - : this(leaveOpen, length, stream, null) { + : this(leaveOpen, length, stream, null) + { if (length < 0) throw new ArgumentException("length"); } @@ -542,7 +597,8 @@ public CrcCalculatorStream(System.IO.Stream stream, Int64 length, bool leaveOpen /// the CRC32 instance to use to calculate the CRC32 public CrcCalculatorStream(System.IO.Stream stream, Int64 length, bool leaveOpen, CRC32 crc32) - : this(leaveOpen, length, stream, crc32) { + : this(leaveOpen, length, stream, crc32) + { if (length < 0) throw new ArgumentException("length"); } @@ -555,7 +611,8 @@ public CrcCalculatorStream(System.IO.Stream stream, Int64 length, bool leaveOpen // value. private CrcCalculatorStream (bool leaveOpen, Int64 length, System.IO.Stream stream, CRC32 crc32) - : base() { + : base() + { _innerStream = stream; _Crc32 = crc32 ?? new CRC32(); _lengthLimit = length; @@ -571,7 +628,8 @@ private CrcCalculatorStream /// This is either the total number of bytes read, or the total number of /// bytes written, depending on the direction of this stream. /// - public Int64 TotalBytesSlurped { + public Int64 TotalBytesSlurped + { get { return _Crc32.TotalBytesRead; } } @@ -585,7 +643,8 @@ public Int64 TotalBytesSlurped { /// get an accurate CRC for the entire stream. /// /// - public Int32 Crc { + public Int32 Crc + { get { return _Crc32.Crc32Result; } } @@ -598,7 +657,8 @@ public Int32 Crc { /// Set this at any point before calling . /// /// - public bool LeaveOpen { + public bool LeaveOpen + { get { return _leaveOpen; } set { _leaveOpen = value; } } @@ -610,7 +670,8 @@ public bool LeaveOpen { /// the offset at which to start /// the number of bytes to read /// the number of bytes actually read - public override int Read(byte[] buffer, int offset, int count) { + public override int Read(byte[] buffer, int offset, int count) + { int bytesToRead = count; // Need to limit the # of bytes returned, if the stream is intended to have @@ -621,7 +682,8 @@ public override int Read(byte[] buffer, int offset, int count) { // calling ReadToEnd() on it, We can "over-read" the zip data and get a // corrupt string. The length limits that, prevents that problem. - if (_lengthLimit != CrcCalculatorStream.UnsetLengthLimit) { + if (_lengthLimit != CrcCalculatorStream.UnsetLengthLimit) + { if (_Crc32.TotalBytesRead >= _lengthLimit) return 0; // EOF Int64 bytesRemaining = _lengthLimit - _Crc32.TotalBytesRead; if (bytesRemaining < count) bytesToRead = (int)bytesRemaining; @@ -637,7 +699,8 @@ public override int Read(byte[] buffer, int offset, int count) { /// the buffer from which to write /// the offset at which to start writing /// the number of bytes to write - public override void Write(byte[] buffer, int offset, int count) { + public override void Write(byte[] buffer, int offset, int count) + { if (count > 0) _Crc32.SlurpBlock(buffer, offset, count); _innerStream.Write(buffer, offset, count); } @@ -645,7 +708,8 @@ public override void Write(byte[] buffer, int offset, int count) { /// /// Indicates whether the stream supports reading. /// - public override bool CanRead { + public override bool CanRead + { get { return _innerStream.CanRead; } } @@ -657,29 +721,34 @@ public override bool CanRead { /// Always returns false. /// /// - public override bool CanSeek { + public override bool CanSeek + { get { return false; } } /// /// Indicates whether the stream supports writing. /// - public override bool CanWrite { + public override bool CanWrite + { get { return _innerStream.CanWrite; } } /// /// Flush the stream. /// - public override void Flush() { + public override void Flush() + { _innerStream.Flush(); } /// /// Returns the length of the underlying stream. /// - public override long Length { - get { + public override long Length + { + get + { if (_lengthLimit == CrcCalculatorStream.UnsetLengthLimit) return _innerStream.Length; else return _lengthLimit; @@ -691,7 +760,8 @@ public override long Length { /// If you use the setter, it will throw /// . /// - public override long Position { + public override long Position + { get { return _Crc32.TotalBytesRead; } set { throw new NotSupportedException(); } } @@ -703,7 +773,8 @@ public override long Position { /// N/A /// N/A /// N/A - public override long Seek(long offset, System.IO.SeekOrigin origin) { + public override long Seek(long offset, System.IO.SeekOrigin origin) + { throw new NotSupportedException(); } @@ -712,19 +783,22 @@ public override long Seek(long offset, System.IO.SeekOrigin origin) { /// /// /// N/A - public override void SetLength(long value) { + public override void SetLength(long value) + { throw new NotSupportedException(); } - void IDisposable.Dispose() { + void IDisposable.Dispose() + { Close(); } /// /// Closes the stream. /// - public override void Close() { + public override void Close() + { base.Close(); if (!_leaveOpen) _innerStream.Close(); diff --git a/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs b/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs index 3231651f3..91193f5aa 100644 --- a/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs +++ b/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs @@ -129,19 +129,22 @@ // using System; -using System.Collections.Generic; using System.IO; +using System.Collections.Generic; using System.Threading; -namespace Ionic.BZip2 { - internal class WorkItem { +namespace Ionic.BZip2 +{ + internal class WorkItem + { public int index; public BZip2Compressor Compressor { get; private set; } public MemoryStream ms; public int ordinal; public BitWriter bw; - public WorkItem(int ix, int blockSize) { + public WorkItem(int ix, int blockSize) + { // compressed data gets written to a MemoryStream this.ms = new MemoryStream(); this.bw = new BitWriter(ms); @@ -181,7 +184,8 @@ public WorkItem(int ix, int blockSize) { /// /// /// - public class ParallelBZip2OutputStream : System.IO.Stream { + public class ParallelBZip2OutputStream : System.IO.Stream + { private static readonly int BufferPairsPerCore = 4; private int _maxWorkers; private bool firstWriteDone; @@ -192,8 +196,8 @@ public class ParallelBZip2OutputStream : System.IO.Stream { private volatile Exception pendingException; private bool handlingException; private bool emitting; - private System.Collections.Generic.Queue toWrite; - private System.Collections.Generic.Queue toFill; + private System.Collections.Generic.Queue toWrite; + private System.Collections.Generic.Queue toFill; private System.Collections.Generic.List pool; private object latestLock = new object(); private object eLock = new object(); // for exceptions @@ -244,7 +248,8 @@ public class ParallelBZip2OutputStream : System.IO.Stream { /// /// public ParallelBZip2OutputStream(Stream output) - : this(output, BZip2.MaxBlockSize, false) { + : this(output, BZip2.MaxBlockSize, false) + { } /// @@ -256,7 +261,8 @@ public ParallelBZip2OutputStream(Stream output) /// The valid range is 1..9. /// public ParallelBZip2OutputStream(Stream output, int blockSize) - : this(output, blockSize, false) { + : this(output, blockSize, false) + { } /// @@ -267,7 +273,8 @@ public ParallelBZip2OutputStream(Stream output, int blockSize) /// whether to leave the captive stream open upon closing this stream. /// public ParallelBZip2OutputStream(Stream output, bool leaveOpen) - : this(output, BZip2.MaxBlockSize, leaveOpen) { + : this(output, BZip2.MaxBlockSize, leaveOpen) + { } /// @@ -283,8 +290,10 @@ public ParallelBZip2OutputStream(Stream output, bool leaveOpen) /// /// whether to leave the captive stream open upon closing this stream. /// - public ParallelBZip2OutputStream(Stream output, int blockSize, bool leaveOpen) { - if (blockSize < BZip2.MinBlockSize || blockSize > BZip2.MaxBlockSize) { + public ParallelBZip2OutputStream(Stream output, int blockSize, bool leaveOpen) + { + if (blockSize < BZip2.MinBlockSize || blockSize > BZip2.MaxBlockSize) + { var msg = String.Format("blockSize={0} is out of range; must be between {1} and {2}", blockSize, BZip2.MinBlockSize, BZip2.MaxBlockSize); @@ -304,13 +313,15 @@ public ParallelBZip2OutputStream(Stream output, int blockSize, bool leaveOpen) { } - private void InitializePoolOfWorkItems() { + private void InitializePoolOfWorkItems() + { this.toWrite = new Queue(); this.toFill = new Queue(); this.pool = new System.Collections.Generic.List(); int nWorkers = BufferPairsPerCore * Environment.ProcessorCount; nWorkers = Math.Min(nWorkers, this.MaxWorkers); - for (int i = 0; i < nWorkers; i++) { + for(int i=0; i < nWorkers; i++) + { this.pool.Add(new WorkItem(i, this.blockSize100k)); this.toFill.Enqueue(i); } @@ -384,11 +395,14 @@ private void InitializePoolOfWorkItems() { /// allocated. /// /// - public int MaxWorkers { - get { + public int MaxWorkers + { + get + { return _maxWorkers; } - set { + set + { if (value < 4) throw new ArgumentException("MaxWorkers", "Value must be 4 or greater."); @@ -405,8 +419,10 @@ public int MaxWorkers { /// constructors that accept a bool value. /// /// - public override void Close() { - if (this.pendingException != null) { + public override void Close() + { + if (this.pendingException != null) + { this.handlingException = true; var pe = this.pendingException; this.pendingException = null; @@ -421,9 +437,12 @@ public override void Close() { Stream o = this.output; - try { + try + { FlushOutput(true); - } finally { + } + finally + { this.output = null; this.bw = null; } @@ -433,20 +452,25 @@ public override void Close() { } - private void FlushOutput(bool lastInput) { + private void FlushOutput(bool lastInput) + { if (this.emitting) return; // compress and write whatever is ready - if (this.currentlyFilling >= 0) { + if (this.currentlyFilling >= 0) + { WorkItem workitem = this.pool[this.currentlyFilling]; CompressOne(workitem); this.currentlyFilling = -1; // get a new buffer next Write() } - if (lastInput) { + if (lastInput) + { EmitPendingBuffers(true, false); EmitTrailer(); - } else { + } + else + { EmitPendingBuffers(false, false); } } @@ -456,15 +480,18 @@ private void FlushOutput(bool lastInput) { /// /// Flush the stream. /// - public override void Flush() { - if (this.output != null) { + public override void Flush() + { + if (this.output != null) + { FlushOutput(false); this.bw.Flush(); this.output.Flush(); } } - private void EmitHeader() { + private void EmitHeader() + { var magic = new byte[] { (byte) 'B', (byte) 'Z', @@ -476,7 +503,8 @@ private void EmitHeader() { this.output.Write(magic, 0, magic.Length); } - private void EmitTrailer() { + private void EmitTrailer() + { // A magic 48-bit number, 0x177245385090, to indicate the end // of the last block. (sqrt(pi), if you want to know) @@ -503,7 +531,8 @@ private void EmitTrailer() { /// /// The blocksize parameter specified at construction time. /// - public int BlockSize { + public int BlockSize + { get { return this.blockSize100k; } } @@ -532,7 +561,8 @@ public int BlockSize { /// The buffer holding data to write to the stream. /// the offset within that data array to find the first byte to write. /// the number of bytes to write. - public override void Write(byte[] buffer, int offset, int count) { + public override void Write(byte[] buffer, int offset, int count) + { bool mustWait = false; // This method does this: @@ -545,7 +575,8 @@ public override void Write(byte[] buffer, int offset, int count) { throw new IOException("the stream is not open"); // dispense any exceptions that occurred on the BG threads - if (this.pendingException != null) { + if (this.pendingException != null) + { this.handlingException = true; var pe = this.pendingException; this.pendingException = null; @@ -564,7 +595,8 @@ public override void Write(byte[] buffer, int offset, int count) { if (count == 0) return; // nothing to do - if (!this.firstWriteDone) { + if (!this.firstWriteDone) + { // Want to do this on first Write, first session, and not in the // constructor. Must allow the MaxWorkers to change after // construction, but before first Write(). @@ -575,7 +607,8 @@ public override void Write(byte[] buffer, int offset, int count) { int bytesWritten = 0; int bytesRemaining = count; - do { + do + { // may need to make buffers available EmitPendingBuffers(false, mustWait); @@ -583,10 +616,14 @@ public override void Write(byte[] buffer, int offset, int count) { // get a compressor to fill int ix = -1; - if (this.currentlyFilling >= 0) { + if (this.currentlyFilling >= 0) + { ix = this.currentlyFilling; - } else { - if (this.toFill.Count == 0) { + } + else + { + if (this.toFill.Count == 0) + { // No compressors available to fill, so... need to emit // compressed buffers. mustWait = true; @@ -601,13 +638,15 @@ public override void Write(byte[] buffer, int offset, int count) { workitem.ordinal = this.lastFilled; int n = workitem.Compressor.Fill(buffer, offset, bytesRemaining); - if (n != bytesRemaining) { - if (!ThreadPool.QueueUserWorkItem(CompressOne, workitem)) + if (n != bytesRemaining) + { + if (!ThreadPool.QueueUserWorkItem( CompressOne, workitem )) throw new Exception("Cannot enqueue workitem"); this.currentlyFilling = -1; // will get a new buffer next time offset += n; - } else + } + else this.currentlyFilling = ix; bytesRemaining -= n; @@ -621,7 +660,8 @@ public override void Write(byte[] buffer, int offset, int count) { - private void EmitPendingBuffers(bool doAll, bool mustWait) { + private void EmitPendingBuffers(bool doAll, bool mustWait) + { // When combining parallel compression with a ZipSegmentedStream, it's // possible for the ZSS to throw from within this method. In that // case, Close/Dispose will be called on this stream, if this stream @@ -636,36 +676,47 @@ private void EmitPendingBuffers(bool doAll, bool mustWait) { if (doAll || mustWait) this.newlyCompressedBlob.WaitOne(); - do { + do + { int firstSkip = -1; int millisecondsToWait = doAll ? 200 : (mustWait ? -1 : 0); int nextToWrite = -1; - do { - if (Monitor.TryEnter(this.toWrite, millisecondsToWait)) { + do + { + if (Monitor.TryEnter(this.toWrite, millisecondsToWait)) + { nextToWrite = -1; - try { + try + { if (this.toWrite.Count > 0) nextToWrite = this.toWrite.Dequeue(); - } finally { + } + finally + { Monitor.Exit(this.toWrite); } - if (nextToWrite >= 0) { + if (nextToWrite >= 0) + { WorkItem workitem = this.pool[nextToWrite]; - if (workitem.ordinal != this.lastWritten + 1) { + if (workitem.ordinal != this.lastWritten + 1) + { // out of order. requeue and try again. - lock (this.toWrite) { + lock(this.toWrite) + { this.toWrite.Enqueue(nextToWrite); } - if (firstSkip == nextToWrite) { + if (firstSkip == nextToWrite) + { // We went around the list once. // None of the items in the list is the one we want. // Now wait for a compressor to signal again. this.newlyCompressedBlob.WaitOne(); firstSkip = -1; - } else if (firstSkip == -1) + } + else if (firstSkip == -1) firstSkip = nextToWrite; continue; @@ -680,7 +731,7 @@ private void EmitPendingBuffers(bool doAll, bool mustWait) { var bw2 = workitem.bw; bw2.Flush(); // not bw2.FinishAndPad()! var ms = workitem.ms; - ms.Seek(0, SeekOrigin.Begin); + ms.Seek(0,SeekOrigin.Begin); // cannot dump bytes!! // ms.WriteTo(this.output); @@ -690,7 +741,8 @@ private void EmitPendingBuffers(bool doAll, bool mustWait) { int y = -1; long totOut = 0; var buffer = new byte[1024]; - while ((n = ms.Read(buffer, 0, buffer.Length)) > 0) { + while ((n = ms.Read(buffer,0,buffer.Length)) > 0) + { #if Trace if (y == -1) // diagnostics only { @@ -702,7 +754,8 @@ private void EmitPendingBuffers(bool doAll, bool mustWait) { } #endif y = n; - for (int k = 0; k < n; k++) { + for (int k=0; k < n; k++) + { this.bw.WriteByte(buffer[k]); } totOut += n; @@ -721,14 +774,15 @@ private void EmitPendingBuffers(bool doAll, bool mustWait) { " remaining bits: {0} 0x{1:X}", bw2.NumRemainingBits, bw2.RemainingBits); - if (bw2.NumRemainingBits > 0) { + if (bw2.NumRemainingBits > 0) + { this.bw.WriteBits(bw2.NumRemainingBits, bw2.RemainingBits); } - TraceOutput(TraceBits.Crc, " combined CRC (before): {0:X8}", + TraceOutput(TraceBits.Crc," combined CRC (before): {0:X8}", this.combinedCRC); this.combinedCRC = (this.combinedCRC << 1) | (this.combinedCRC >> 31); - this.combinedCRC ^= (uint)workitem.Compressor.Crc32; + this.combinedCRC ^= (uint) workitem.Compressor.Crc32; TraceOutput(TraceBits.Crc, " block CRC : {0:X8}", @@ -751,14 +805,16 @@ private void EmitPendingBuffers(bool doAll, bool mustWait) { // don't wait next time through if (millisecondsToWait == -1) millisecondsToWait = 0; } - } else + } + else nextToWrite = -1; } while (nextToWrite >= 0); } while (doAll && (this.lastWritten != this.latestCompressed)); - if (doAll) { + if (doAll) + { TraceOutput(TraceBits.Crc, " combined CRC (final) : {0:X8}", this.combinedCRC); } @@ -767,25 +823,32 @@ private void EmitPendingBuffers(bool doAll, bool mustWait) { } - private void CompressOne(Object wi) { + private void CompressOne(Object wi) + { // compress and one buffer - WorkItem workitem = (WorkItem)wi; - try { + WorkItem workitem = (WorkItem) wi; + try + { // compress and write to the compressor's MemoryStream workitem.Compressor.CompressAndWrite(); - lock (this.latestLock) { + lock(this.latestLock) + { if (workitem.ordinal > this.latestCompressed) this.latestCompressed = workitem.ordinal; } - lock (this.toWrite) { + lock (this.toWrite) + { this.toWrite.Enqueue(workitem.index); } this.newlyCompressedBlob.Set(); - } catch (System.Exception exc1) { - lock (this.eLock) { + } + catch (System.Exception exc1) + { + lock(this.eLock) + { // expose the exception to the main thread - if (this.pendingException != null) + if (this.pendingException!=null) this.pendingException = exc1; } } @@ -800,7 +863,8 @@ private void CompressOne(Object wi) { /// /// The return value is always false. /// - public override bool CanRead { + public override bool CanRead + { get { return false; } } @@ -810,7 +874,8 @@ public override bool CanRead { /// /// Always returns false. /// - public override bool CanSeek { + public override bool CanSeek + { get { return false; } } @@ -820,8 +885,10 @@ public override bool CanSeek { /// /// The return value depends on whether the captive stream supports writing. /// - public override bool CanWrite { - get { + public override bool CanWrite + { + get + { if (this.output == null) throw new ObjectDisposedException("BZip2Stream"); return this.output.CanWrite; } @@ -830,7 +897,8 @@ public override bool CanWrite { /// /// Reading this property always throws a . /// - public override long Length { + public override long Length + { get { throw new NotImplementedException(); } } @@ -843,8 +911,10 @@ public override long Length { /// cref="NotImplementedException"/>. Reading will return the /// total number of uncompressed bytes written through. /// - public override long Position { - get { + public override long Position + { + get + { return this.totalBytesWrittenIn; } set { throw new NotImplementedException(); } @@ -864,7 +934,8 @@ public override long Position { /// this is irrelevant, since it will always throw! /// this is irrelevant, since it will always throw! /// irrelevant! - public override long Seek(long offset, System.IO.SeekOrigin origin) { + public override long Seek(long offset, System.IO.SeekOrigin origin) + { throw new NotImplementedException(); } @@ -872,7 +943,8 @@ public override long Seek(long offset, System.IO.SeekOrigin origin) { /// Calling this method always throws a . /// /// this is irrelevant, since it will always throw! - public override void SetLength(long value) { + public override void SetLength(long value) + { throw new NotImplementedException(); } @@ -883,27 +955,32 @@ public override void SetLength(long value) { /// this parameter is never used /// this parameter is never used /// never returns anything; always throws - public override int Read(byte[] buffer, int offset, int count) { + public override int Read(byte[] buffer, int offset, int count) + { throw new NotImplementedException(); } // used only when Trace is defined [Flags] - private enum TraceBits : uint { - None = 0, - Crc = 1, - Write = 2, - All = 0xffffffff, + private enum TraceBits : uint + { + None = 0, + Crc = 1, + Write = 2, + All = 0xffffffff, } [System.Diagnostics.ConditionalAttribute("Trace")] - private void TraceOutput(TraceBits bits, string format, params object[] varParams) { - if ((bits & this.desiredTrace) != 0) { - lock (outputLock) { + private void TraceOutput(TraceBits bits, string format, params object[] varParams) + { + if ((bits & this.desiredTrace) != 0) + { + lock(outputLock) + { int tid = Thread.CurrentThread.GetHashCode(); - Console.ForegroundColor = (ConsoleColor)(tid % 8 + 10); + Console.ForegroundColor = (ConsoleColor) (tid % 8 + 10); Console.Write("{0:000} PBOS ", tid); Console.WriteLine(format, varParams); Console.ResetColor(); diff --git a/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/Rand.cs b/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/Rand.cs index 654ae49da..ac00decd2 100644 --- a/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/Rand.cs +++ b/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/Rand.cs @@ -24,8 +24,10 @@ // ------------------------------------------------------------------ -namespace Ionic.BZip2 { - internal static class Rand { +namespace Ionic.BZip2 +{ + internal static class Rand + { private static int[] RNUMS = { 619, 720, 127, 481, 931, 816, 813, 233, 566, 247, @@ -88,7 +90,8 @@ internal static class Rand { /// /// the index /// the random number - internal static int Rnums(int i) { + internal static int Rnums(int i) + { return RNUMS[i]; } } diff --git a/src/ipy/IronPython.Modules/gc.cs b/src/ipy/IronPython.Modules/gc.cs index a27605892..87bcacbaf 100644 --- a/src/ipy/IronPython.Modules/gc.cs +++ b/src/ipy/IronPython.Modules/gc.cs @@ -5,11 +5,13 @@ using System; using System.Linq; +using Microsoft.Scripting; +using Microsoft.Scripting.Runtime; + using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; - -using Microsoft.Scripting.Runtime; +using IronPython.Runtime.Types; using SpecialName = System.Runtime.CompilerServices.SpecialNameAttribute; @@ -27,7 +29,7 @@ public static class PythonGC { private static readonly object _threadholdKey = new object(); [SpecialName] - public static void PerformModuleReload(PythonContext/*!*/ context, PythonDictionary/*!*/ dict) { + public static void PerformModuleReload(PythonContext/*!*/ context, PythonDictionary/*!*/ dict) { context.SetModuleState(_threadholdKey, PythonTuple.MakeTuple(64 * 1024, 256 * 1024, 1024 * 1024)); } @@ -63,19 +65,19 @@ public static object[] get_objects() { } public static void set_threshold(CodeContext/*!*/ context, params object[] args) { - if (args.Length == 0) { + if(args.Length == 0) { throw PythonOps.TypeError("set_threshold() takes at least 1 argument (0 given)"); } - if (args.Length > 3) { + if(args.Length > 3) { throw PythonOps.TypeError("set_threshold() takes at most 3 arguments ({0} given)", args.Length); } - if (args.Any(x => x is double)) { + if(args.Any(x => x is double)) { throw PythonOps.TypeError("integer argument expected, got float"); } - if (!args.All(x => x is int)) { + if(!args.All(x => x is int)) { throw PythonOps.TypeError("an integer is required"); } diff --git a/src/ipy/IronPython.Modules/grp.cs b/src/ipy/IronPython.Modules/grp.cs index 16dfe8b26..d46de20f5 100644 --- a/src/ipy/IronPython.Modules/grp.cs +++ b/src/ipy/IronPython.Modules/grp.cs @@ -8,14 +8,16 @@ using System.Collections.Generic; using System.Runtime.InteropServices; +using Microsoft.Scripting.Runtime; + using IronPython.Runtime; using IronPython.Runtime.Operations; -using Microsoft.Scripting.Runtime; +using System.Numerics; [assembly: PythonModule("grp", typeof(IronPython.Modules.PythonGrp), PlatformsAttribute.PlatformFamily.Unix)] namespace IronPython.Modules { - + public static class PythonGrp { public const string __doc__ = @"Access to the Unix group database. @@ -77,10 +79,13 @@ private static struct_group Make(IntPtr pwd) { return new struct_group(g.gr_name, g.gr_passwd, g.gr_gid, PythonList.FromEnumerable(MarshalStringArray(g.gr_mem))); } - private static IEnumerable MarshalStringArray(IntPtr arrayPtr) { - if (arrayPtr != IntPtr.Zero) { + private static IEnumerable MarshalStringArray(IntPtr arrayPtr) + { + if (arrayPtr != IntPtr.Zero) + { IntPtr ptr = Marshal.ReadIntPtr(arrayPtr); - while (ptr != IntPtr.Zero) { + while (ptr != IntPtr.Zero) + { string key = Marshal.PtrToStringAnsi(ptr); yield return key; arrayPtr = new IntPtr(arrayPtr.ToInt64() + IntPtr.Size); @@ -91,7 +96,7 @@ private static IEnumerable MarshalStringArray(IntPtr arrayPtr) { public static struct_group getgrgid(int gid) { var grp = _getgrgid(gid); - if (grp == IntPtr.Zero) { + if(grp == IntPtr.Zero) { throw PythonOps.KeyError($"getgrgid(): gid not found: {gid}"); } @@ -100,7 +105,7 @@ public static struct_group getgrgid(int gid) { public static struct_group getgrnam(string name) { var grp = _getgrnam(name); - if (grp == IntPtr.Zero) { + if(grp == IntPtr.Zero) { throw PythonOps.KeyError($"getgrnam()): name not found: {name}"); } @@ -111,27 +116,27 @@ public static PythonList getgrall() { var res = new PythonList(); setgrent(); IntPtr val = getgrent(); - while (val != IntPtr.Zero) { + while(val != IntPtr.Zero) { res.Add(Make(val)); val = getgrent(); } - + return res; } #region P/Invoke Declarations - [DllImport("libc", EntryPoint = "getgrgid", CallingConvention = CallingConvention.Cdecl)] + [DllImport("libc", EntryPoint="getgrgid", CallingConvention=CallingConvention.Cdecl)] private static extern IntPtr _getgrgid(int uid); - [DllImport("libc", EntryPoint = "getgrnam", CallingConvention = CallingConvention.Cdecl)] + [DllImport("libc", EntryPoint="getgrnam", CallingConvention=CallingConvention.Cdecl)] private static extern IntPtr _getgrnam([MarshalAs(UnmanagedType.LPStr)] string name); - [DllImport("libc", CallingConvention = CallingConvention.Cdecl)] + [DllImport("libc", CallingConvention=CallingConvention.Cdecl)] private static extern void setgrent(); - [DllImport("libc", CallingConvention = CallingConvention.Cdecl)] + [DllImport("libc", CallingConvention=CallingConvention.Cdecl)] private static extern IntPtr getgrent(); #endregion diff --git a/src/ipy/IronPython.Modules/hashlib/SHA224Managed.cs b/src/ipy/IronPython.Modules/hashlib/SHA224Managed.cs index 4840afd76..6037a5df2 100644 --- a/src/ipy/IronPython.Modules/hashlib/SHA224Managed.cs +++ b/src/ipy/IronPython.Modules/hashlib/SHA224Managed.cs @@ -29,6 +29,8 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System.Security.Cryptography; + using IronPython.Runtime; namespace Mono.Security.Cryptography { diff --git a/src/ipy/IronPython.Modules/hashlib/SHA384Managed.cs b/src/ipy/IronPython.Modules/hashlib/SHA384Managed.cs index e47a86c94..6ea90617b 100644 --- a/src/ipy/IronPython.Modules/hashlib/SHA384Managed.cs +++ b/src/ipy/IronPython.Modules/hashlib/SHA384Managed.cs @@ -30,6 +30,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; using System.Runtime.InteropServices; using System.Security.Cryptography; diff --git a/src/ipy/IronPython.Modules/hashlib/_hashlib.cs b/src/ipy/IronPython.Modules/hashlib/_hashlib.cs index 2af22c374..f463224ca 100644 --- a/src/ipy/IronPython.Modules/hashlib/_hashlib.cs +++ b/src/ipy/IronPython.Modules/hashlib/_hashlib.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Security.Cryptography; diff --git a/src/ipy/IronPython.Modules/marshal.cs b/src/ipy/IronPython.Modules/marshal.cs index f431892e7..1841e9a93 100644 --- a/src/ipy/IronPython.Modules/marshal.cs +++ b/src/ipy/IronPython.Modules/marshal.cs @@ -30,7 +30,7 @@ public static Bytes dumps(object value, int version = PythonMarshal.version) { return Bytes.Make(MarshalOps.GetBytes(value, version)); } - public static object loads([BytesLike] IList bytes) { + public static object loads([BytesLike]IList bytes) { return MarshalOps.GetObject(bytes.GetEnumerator()); } diff --git a/src/ipy/IronPython.Modules/math.cs b/src/ipy/IronPython.Modules/math.cs index 6e6dfff2d..a7f3910a5 100644 --- a/src/ipy/IronPython.Modules/math.cs +++ b/src/ipy/IronPython.Modules/math.cs @@ -9,10 +9,12 @@ using System.Linq; using System.Numerics; +using Microsoft.Scripting; +using Microsoft.Scripting.Utils; + using IronPython.Runtime; using IronPython.Runtime.Operations; - -using Microsoft.Scripting.Utils; +using IronPython.Runtime.Types; [assembly: PythonModule("math", typeof(IronPython.Modules.PythonMath))] namespace IronPython.Modules { diff --git a/src/ipy/IronPython.Modules/msvcrt.cs b/src/ipy/IronPython.Modules/msvcrt.cs index 3ccc6e61a..e81c3d119 100644 --- a/src/ipy/IronPython.Modules/msvcrt.cs +++ b/src/ipy/IronPython.Modules/msvcrt.cs @@ -5,7 +5,6 @@ #if FEATURE_NATIVE using Microsoft.Win32.SafeHandles; - using System; using System.ComponentModel; using System.IO; @@ -196,34 +195,34 @@ public static void ungetwch(char @char) { private static int EOF = -1; private static ushort WEOF = 0xFFFF; - [DllImport("msvcr100", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] + [DllImport("msvcr100", SetLastError=true, CallingConvention=CallingConvention.Cdecl)] private static extern int _heapmin(); - [DllImport("msvcr100", CallingConvention = CallingConvention.Cdecl)] + [DllImport("msvcr100", CallingConvention=CallingConvention.Cdecl)] private static extern int _kbhit(); - [DllImport("msvcr100", CallingConvention = CallingConvention.Cdecl)] + [DllImport("msvcr100", CallingConvention=CallingConvention.Cdecl)] private static extern int _getch(); - [DllImport("msvcr100", CallingConvention = CallingConvention.Cdecl)] + [DllImport("msvcr100", CallingConvention=CallingConvention.Cdecl)] private static extern int _getche(); - [DllImport("msvcr100", CallingConvention = CallingConvention.Cdecl)] + [DllImport("msvcr100", CallingConvention=CallingConvention.Cdecl)] private static extern int _putch(int c); - [DllImport("msvcr100", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] + [DllImport("msvcr100", SetLastError=true, CallingConvention=CallingConvention.Cdecl)] private static extern int _ungetch(int c); - [DllImport("msvcr100", CallingConvention = CallingConvention.Cdecl)] + [DllImport("msvcr100", CallingConvention=CallingConvention.Cdecl)] private static extern ushort _getwch(); - [DllImport("msvcr100", CallingConvention = CallingConvention.Cdecl)] + [DllImport("msvcr100", CallingConvention=CallingConvention.Cdecl)] private static extern ushort _getwche(); - [DllImport("msvcr100", CallingConvention = CallingConvention.Cdecl)] + [DllImport("msvcr100", CallingConvention=CallingConvention.Cdecl)] private static extern ushort _putwch(char c); - [DllImport("msvcr100", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] + [DllImport("msvcr100", SetLastError=true, CallingConvention=CallingConvention.Cdecl)] private static extern ushort _ungetwch(ushort c); #endregion diff --git a/src/ipy/IronPython.Modules/nt.cs b/src/ipy/IronPython.Modules/nt.cs index e5fe37817..f6f920a3c 100644 --- a/src/ipy/IronPython.Modules/nt.cs +++ b/src/ipy/IronPython.Modules/nt.cs @@ -5,7 +5,6 @@ #nullable enable using Microsoft.Win32.SafeHandles; - using System; using System.Collections; using System.Collections.Generic; @@ -2307,10 +2306,10 @@ private static Bytes ToFsBytes(this IBufferProtocol bp, CodeContext context) { private static string ConvertToFsString(CodeContext context, [NotNull] object? o, string argname, [CallerMemberName] string? methodname = null) => o switch { - string s => s, + string s => s, ExtensibleString es => es.Value, - Bytes b => b.ToFsString(context), - IBufferProtocol bp => bp.ToFsBytes(context).ToFsString(context), + Bytes b => b.ToFsString(context), + IBufferProtocol bp => bp.ToFsBytes(context).ToFsString(context), // TODO: Python 3.6: os.PathLike _ => throw PythonOps.TypeError("{0}: {1} should be string or bytes, not '{2}'", methodname, argname, PythonOps.GetPythonTypeName(o)) }; diff --git a/src/ipy/IronPython.Modules/pwd.cs b/src/ipy/IronPython.Modules/pwd.cs index a848008f1..1eb3b015b 100644 --- a/src/ipy/IronPython.Modules/pwd.cs +++ b/src/ipy/IronPython.Modules/pwd.cs @@ -5,17 +5,19 @@ #if FEATURE_NATIVE using System; -using System.Numerics; using System.Runtime.InteropServices; +using Microsoft.Scripting.Runtime; + +using IronPython; using IronPython.Runtime; using IronPython.Runtime.Operations; -using Microsoft.Scripting.Runtime; +using System.Numerics; [assembly: PythonModule("pwd", typeof(IronPython.Modules.PythonPwd), PlatformsAttribute.PlatformFamily.Unix)] namespace IronPython.Modules { - + public static class PythonPwd { public const string __doc__ = @"This module provides access to the Unix password database. It is available on all Unix versions. @@ -128,11 +130,11 @@ public static struct_passwd getpwuid(object uid) { if (uid is int id) { var pwd = _getpwuid(id); - if (pwd == IntPtr.Zero) { + if(pwd == IntPtr.Zero) { throw PythonOps.KeyError($"getpwuid(): uid not found: {id}"); } - return Make(pwd); + return Make(pwd); } throw PythonOps.TypeError($"integer argument expected, got {PythonOps.GetPythonTypeName(uid)}"); @@ -141,7 +143,7 @@ public static struct_passwd getpwuid(object uid) { [Documentation("Return the password database entry for the given user name.")] public static struct_passwd getpwnam(string name) { var pwd = _getpwnam(name); - if (pwd == IntPtr.Zero) { + if(pwd == IntPtr.Zero) { throw PythonOps.KeyError($"getpwname(): name not found: {name}"); } @@ -153,27 +155,27 @@ public static PythonList getpwall() { var res = new PythonList(); setpwent(); IntPtr val = getpwent(); - while (val != IntPtr.Zero) { + while(val != IntPtr.Zero) { res.Add(Make(val)); val = getpwent(); } - + return res; } #region P/Invoke Declarations - [DllImport("libc", EntryPoint = "getpwuid", CallingConvention = CallingConvention.Cdecl)] + [DllImport("libc", EntryPoint="getpwuid", CallingConvention=CallingConvention.Cdecl)] private static extern IntPtr _getpwuid(int uid); - [DllImport("libc", EntryPoint = "getpwnam", CallingConvention = CallingConvention.Cdecl)] + [DllImport("libc", EntryPoint="getpwnam", CallingConvention=CallingConvention.Cdecl)] private static extern IntPtr _getpwnam([MarshalAs(UnmanagedType.LPStr)] string name); - [DllImport("libc", CallingConvention = CallingConvention.Cdecl)] + [DllImport("libc", CallingConvention=CallingConvention.Cdecl)] private static extern void setpwent(); - [DllImport("libc", CallingConvention = CallingConvention.Cdecl)] + [DllImport("libc", CallingConvention=CallingConvention.Cdecl)] private static extern IntPtr getpwent(); #endregion diff --git a/src/ipy/IronPython.Modules/pyexpat.cs b/src/ipy/IronPython.Modules/pyexpat.cs index a8ead845d..0e68c8a06 100644 --- a/src/ipy/IronPython.Modules/pyexpat.cs +++ b/src/ipy/IronPython.Modules/pyexpat.cs @@ -229,7 +229,7 @@ public static string ErrorString(int errno) { return null; } - public static object ParserCreate(CodeContext context, [ParamDictionary] IDictionary kwArgs\u00F8, params object[] args\u00F8) { + public static object ParserCreate(CodeContext context, [ParamDictionary]IDictionary kwArgs\u00F8, params object[] args\u00F8) { var numArgs = argsø.Length + kwArgsø.Count; if (numArgs > 3) throw PythonOps.TypeError($"ParserCreate() takes at most 3 arguments ({numArgs} given)"); diff --git a/src/ipy/IronPython.Modules/re.cs b/src/ipy/IronPython.Modules/re.cs index 0d065889e..c2a371819 100644 --- a/src/ipy/IronPython.Modules/re.cs +++ b/src/ipy/IronPython.Modules/re.cs @@ -74,14 +74,14 @@ internal enum ReFlags : int { public const int A = (int)ReFlags.ASCII; // long forms - public const int TEMPLATE = (int)ReFlags.TEMPLATE; + public const int TEMPLATE = (int)ReFlags.TEMPLATE; public const int IGNORECASE = (int)ReFlags.IGNORECASE; - public const int LOCALE = (int)ReFlags.LOCALE; - public const int MULTILINE = (int)ReFlags.MULTILINE; - public const int DOTALL = (int)ReFlags.DOTALL; - public const int UNICODE = (int)ReFlags.UNICODE; - public const int VERBOSE = (int)ReFlags.VERBOSE; - public const int ASCII = (int)ReFlags.ASCII; + public const int LOCALE = (int)ReFlags.LOCALE; + public const int MULTILINE = (int)ReFlags.MULTILINE; + public const int DOTALL = (int)ReFlags.DOTALL; + public const int UNICODE = (int)ReFlags.UNICODE; + public const int VERBOSE = (int)ReFlags.VERBOSE; + public const int ASCII = (int)ReFlags.ASCII; #endregion diff --git a/src/ipy/IronPython.Modules/resource.cs b/src/ipy/IronPython.Modules/resource.cs index ba6f0babb..f83898a1c 100644 --- a/src/ipy/IronPython.Modules/resource.cs +++ b/src/ipy/IronPython.Modules/resource.cs @@ -5,18 +5,18 @@ #nullable enable using System; -using System.Linq; using System.Numerics; +using System.Linq; using System.Runtime.InteropServices; using System.Runtime.Versioning; +using Microsoft.Scripting.Runtime; + using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting.Runtime; - [assembly: PythonModule("resource", typeof(IronPython.Modules.PythonResourceModule), PlatformsAttribute.PlatformFamily.Unix)] namespace IronPython.Modules; @@ -367,20 +367,20 @@ internal struct rusage { public timeval ru_utime; // user CPU time used public timeval ru_stime; // system CPU time used - public long ru_maxrss; // maximum resident set size - public long ru_ixrss; // integral shared memory size - public long ru_idrss; // integral unshared data size - public long ru_isrss; // integral unshared stack size - public long ru_minflt; // page reclaims (soft page faults) - public long ru_majflt; // page faults (hard page faults) - public long ru_nswap; // swaps - public long ru_inblock; // block input operations - public long ru_oublock; // block output operations - public long ru_msgsnd; // IPC messages sent - public long ru_msgrcv; // IPC messages received - public long ru_nsignals; // signals received - public long ru_nvcsw; // voluntary context switches - public long ru_nivcsw; // involuntary context switches + public long ru_maxrss; // maximum resident set size + public long ru_ixrss; // integral shared memory size + public long ru_idrss; // integral unshared data size + public long ru_isrss; // integral unshared stack size + public long ru_minflt; // page reclaims (soft page faults) + public long ru_majflt; // page faults (hard page faults) + public long ru_nswap; // swaps + public long ru_inblock; // block input operations + public long ru_oublock; // block output operations + public long ru_msgsnd; // IPC messages sent + public long ru_msgrcv; // IPC messages received + public long ru_nsignals; // signals received + public long ru_nvcsw; // voluntary context switches + public long ru_nivcsw; // involuntary context switches } #pragma warning restore CS0649 diff --git a/src/ipy/IronPython.Modules/select.cs b/src/ipy/IronPython.Modules/select.cs index 9d7e9a5a3..f5f8c2ed3 100644 --- a/src/ipy/IronPython.Modules/select.cs +++ b/src/ipy/IronPython.Modules/select.cs @@ -40,7 +40,7 @@ public static class PythonSelect { + "Note that select() on IronPython works only with sockets; it will not work with\n" + "files or other objects." )] - public static PythonTuple select(CodeContext/*!*/ context, object iwtd, object owtd, object ewtd, object timeout = null) { + public static PythonTuple select(CodeContext/*!*/ context, object iwtd, object owtd, object ewtd, object timeout=null) { PythonList readerList, writerList, errorList; Dictionary readerOriginals, writerOriginals, errorOriginals; ProcessSocketSequence(context, iwtd, out readerList, out readerOriginals); @@ -57,7 +57,7 @@ public static PythonTuple select(CodeContext/*!*/ context, object iwtd, object o if (!Converter.TryConvertToDouble(timeout, out timeoutSeconds)) { throw PythonOps.TypeErrorForTypeMismatch("float or None", timeout); } - timeoutMicroseconds = (int)(1000000 * timeoutSeconds); + timeoutMicroseconds = (int) (1000000 * timeoutSeconds); } try { diff --git a/src/ipy/IronPython.Modules/signal.cs b/src/ipy/IronPython.Modules/signal.cs index b42c63fdf..1ae2de2f8 100644 --- a/src/ipy/IronPython.Modules/signal.cs +++ b/src/ipy/IronPython.Modules/signal.cs @@ -160,7 +160,7 @@ public static object signal(CodeContext/*!*/ context, int sig, object action) { PythonFunction result = action as PythonFunction; if (result == null) { //It could still be something like a type that implements __call__ - if (!PythonOps.IsCallable(context, action)) { + if (! PythonOps.IsCallable(context, action)) { throw PythonOps.TypeError("signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object"); } } @@ -191,11 +191,11 @@ public static void set_wakeup_fd(CodeContext/*!*/ context, uint fd) { } private static readonly object _PythonSignalStateKey = new object(); - + private static PythonSignalState GetPythonSignalState(CodeContext/*!*/ context) { return (PythonSignalState)context.LanguageContext.GetModuleState(_PythonSignalStateKey); } - + private static void SetPythonSignalState(CodeContext/*!*/ context, PythonSignalState pss) { context.LanguageContext.SetModuleState(_PythonSignalStateKey, pss); } diff --git a/src/ipy/IronPython.Modules/spwd.cs b/src/ipy/IronPython.Modules/spwd.cs index a477f56d7..9445f7341 100644 --- a/src/ipy/IronPython.Modules/spwd.cs +++ b/src/ipy/IronPython.Modules/spwd.cs @@ -7,14 +7,16 @@ using System; using System.Runtime.InteropServices; +using Microsoft.Scripting.Runtime; + using IronPython.Runtime; using IronPython.Runtime.Operations; -using Microsoft.Scripting.Runtime; +using System.Numerics; [assembly: PythonModule("spwd", typeof(IronPython.Modules.PythonSpwd), PlatformsAttribute.PlatformFamily.Unix)] namespace IronPython.Modules { - + public static class PythonSpwd { public const string __doc__ = @"This module provides access to the Unix shadow password database. It is available on various Unix versions. @@ -39,7 +41,7 @@ private struct spwd { public int sp_inact; public int sp_expire; public int sp_flag; - }; + }; [PythonType("struct_spwd")] [Documentation(@"spwd.struct_spwd: Results from getsp*() routines. @@ -52,7 +54,7 @@ public class struct_spwd : PythonTuple { private const int LENGTH = 9; internal struct_spwd(string sp_nam, string sp_pwd, int sp_lstchg, int sp_min, int sp_max, int sp_warn, int sp_inact, int sp_expire, int sp_flag) : - base(new object[] { sp_nam, sp_pwd, sp_lstchg, sp_min, sp_max, sp_warn, sp_inact, sp_expire, sp_flag }) { + base(new object[] { sp_nam ,sp_pwd, sp_lstchg, sp_min, sp_max, sp_warn, sp_inact, sp_expire, sp_flag }) { } [Documentation("login name")] @@ -95,7 +97,7 @@ private static struct_spwd Make(IntPtr pwd) { [Documentation("Return the shadow password database entry for the given user name.")] public static struct_spwd getspnam(string name) { var pwd = _getspnam(name); - if (pwd == IntPtr.Zero) { + if(pwd == IntPtr.Zero) { throw PythonOps.KeyError($"getspnam(): name not found"); } @@ -107,24 +109,24 @@ public static PythonList getspall() { var res = new PythonList(); setspent(); IntPtr val = getspent(); - while (val != IntPtr.Zero) { + while(val != IntPtr.Zero) { res.Add(Make(val)); val = getspent(); } - + return res; } #region P/Invoke Declarations - [DllImport("libc", EntryPoint = "getspnam", CallingConvention = CallingConvention.Cdecl)] + [DllImport("libc", EntryPoint="getspnam", CallingConvention=CallingConvention.Cdecl)] private static extern IntPtr _getspnam([MarshalAs(UnmanagedType.LPStr)] string name); - [DllImport("libc", CallingConvention = CallingConvention.Cdecl)] + [DllImport("libc", CallingConvention=CallingConvention.Cdecl)] private static extern void setspent(); - [DllImport("libc", CallingConvention = CallingConvention.Cdecl)] + [DllImport("libc", CallingConvention=CallingConvention.Cdecl)] private static extern IntPtr getspent(); #endregion diff --git a/src/ipy/IronPython.Modules/winreg.cs b/src/ipy/IronPython.Modules/winreg.cs index 22270900b..5b80836d2 100644 --- a/src/ipy/IronPython.Modules/winreg.cs +++ b/src/ipy/IronPython.Modules/winreg.cs @@ -4,6 +4,8 @@ #if FEATURE_REGISTRY +using Microsoft.Win32; +using Microsoft.Win32.SafeHandles; using System; using System.Collections.Concurrent; using System.ComponentModel; @@ -20,9 +22,6 @@ using IronPython.Runtime.Exceptions; using IronPython.Runtime.Types; -using Microsoft.Win32; -using Microsoft.Win32.SafeHandles; - [assembly: PythonModule("winreg", typeof(IronPython.Modules.PythonWinReg), PlatformsAttribute.PlatformFamily.Windows)] namespace IronPython.Modules { [SupportedOSPlatform("windows")] diff --git a/src/ipy/IronPython.Modules/winsound.cs b/src/ipy/IronPython.Modules/winsound.cs index 327bf04d1..56cb0cfc8 100644 --- a/src/ipy/IronPython.Modules/winsound.cs +++ b/src/ipy/IronPython.Modules/winsound.cs @@ -7,6 +7,7 @@ #nullable enable using System; +using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Runtime.Versioning; @@ -131,7 +132,7 @@ public static void Beep(CodeContext/*!*/ context, int freq, int dur) { } [Documentation("MessageBeep(x) - call Windows MessageBeep(x). x defaults to MB_OK.")] - public static void MessageBeep(CodeContext/*!*/ context, int x = MB_OK) { + public static void MessageBeep(CodeContext/*!*/ context, int x=MB_OK) { MessageBeep(x); } diff --git a/src/ipy/IronPython.Modules/xxsubtype.cs b/src/ipy/IronPython.Modules/xxsubtype.cs index db2c251ec..8980fc8c1 100644 --- a/src/ipy/IronPython.Modules/xxsubtype.cs +++ b/src/ipy/IronPython.Modules/xxsubtype.cs @@ -2,16 +2,17 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; using System.Collections.Generic; +using Microsoft.Scripting; + using IronPython.Runtime; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting; - [assembly: PythonModule("xxsubtype", typeof(IronPython.Modules.xxsubtype))] -namespace IronPython.Modules { +namespace IronPython.Modules { /// /// Samples on how to subtype built-in types from C# /// @@ -49,12 +50,12 @@ public void setstate(int value) { state = value; } - public static object staticmeth([ParamDictionary] IDictionary dict, params object[] args) { + public static object staticmeth([ParamDictionary]IDictionary dict, params object[] args) { return PythonTuple.MakeTuple(null, PythonTuple.MakeTuple(args), dict); } [ClassMethod] - public static object classmeth(PythonType cls, [ParamDictionary] IDictionary dict, params object[] args) { + public static object classmeth(PythonType cls, [ParamDictionary]IDictionary dict, params object[] args) { return PythonTuple.MakeTuple(cls, PythonTuple.MakeTuple(args), dict); } } diff --git a/src/ipy/IronPython.Modules/zipimport.cs b/src/ipy/IronPython.Modules/zipimport.cs index 62bb9c8f7..f1d97b0d2 100644 --- a/src/ipy/IronPython.Modules/zipimport.cs +++ b/src/ipy/IronPython.Modules/zipimport.cs @@ -1,6 +1,6 @@ using System; -using System.Collections.Generic; using System.IO; +using System.Collections.Generic; using System.Runtime.CompilerServices; using IronPython.Runtime; @@ -10,6 +10,7 @@ using IronPython.Zlib; using Microsoft.Scripting; +using Microsoft.Scripting.Utils; using Microsoft.Scripting.Runtime; [assembly: PythonModule("zipimport", typeof(IronPython.Runtime.ZipImportModule))] diff --git a/src/ipy/IronPython.Modules/zlib/Compress.cs b/src/ipy/IronPython.Modules/zlib/Compress.cs index e9903d2a9..4f07b7fdf 100644 --- a/src/ipy/IronPython.Modules/zlib/Compress.cs +++ b/src/ipy/IronPython.Modules/zlib/Compress.cs @@ -6,30 +6,33 @@ // using System; +using System.Collections.Generic; using System.Linq; - +using System.Runtime.InteropServices; using ComponentAce.Compression.Libs.ZLib; - using IronPython.Runtime; using IronPython.Runtime.Operations; - using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -namespace IronPython.Zlib { +namespace IronPython.Zlib +{ [PythonType] - public class Compress { + public class Compress + { private const int Z_OK = ZlibModule.Z_OK; private const int Z_BUF_ERROR = ZlibModule.Z_BUF_ERROR; private const int Z_STREAM_END = ZlibModule.Z_STREAM_END; - + private const int Z_NO_FLUSH = ZlibModule.Z_NO_FLUSH; private const int Z_FINISH = ZlibModule.Z_FINISH; - internal Compress(int level, int method, int wbits, int memlevel, int strategy) { + internal Compress(int level, int method, int wbits, int memlevel, int strategy) + { zst = new ZStream(); int err = zst.DeflateInit(level, wbits); - switch (err) { + switch(err) + { case ZlibModule.Z_OK: break; @@ -46,7 +49,8 @@ internal Compress(int level, int method, int wbits, int memlevel, int strategy) After calling this function, some of the input data may still be stored in internal buffers for later processing. Call the flush() method to clear these buffers.")] - public Bytes compress([NotNone] IBufferProtocol data) { + public Bytes compress([NotNone] IBufferProtocol data) + { using var buffer = data.GetBuffer(); byte[] input = buffer.AsUnsafeArray() ?? buffer.ToArray(); byte[] output = new byte[ZlibModule.DEFAULTALLOC]; @@ -61,7 +65,8 @@ public Bytes compress([NotNone] IBufferProtocol data) { int err = zst.deflate(Z_NO_FLUSH); - while (err == Z_OK && zst.avail_out == 0) { + while(err == Z_OK && zst.avail_out == 0) + { int length = output.Length; Array.Resize(ref output, output.Length * 2); @@ -71,7 +76,8 @@ public Bytes compress([NotNone] IBufferProtocol data) { err = zst.deflate(Z_NO_FLUSH); } - if (err != Z_OK && err != Z_BUF_ERROR) { + if(err != Z_OK && err != Z_BUF_ERROR) + { throw ZlibModule.zlib_error(this.zst, err, "while compressing"); } @@ -84,10 +90,12 @@ public Bytes compress([NotNone] IBufferProtocol data) { default value used when mode is not specified is Z_FINISH. If mode == Z_FINISH, the compressor object can no longer be used after calling the flush() method. Otherwise, more data can still be compressed.")] - public Bytes flush(int mode = Z_FINISH) { + public Bytes flush(int mode=Z_FINISH) + { byte[] output = new byte[ZlibModule.DEFAULTALLOC]; - if (mode == Z_NO_FLUSH) { + if(mode == Z_NO_FLUSH) + { return Bytes.Empty; } @@ -98,7 +106,8 @@ public Bytes flush(int mode = Z_FINISH) { zst.avail_out = output.Length; int err = zst.deflate((FlushStrategy)mode); - while (err == Z_OK && zst.avail_out == 0) { + while(err == Z_OK && zst.avail_out == 0) + { int old_length = output.Length; Array.Resize(ref output, output.Length * 2); @@ -108,12 +117,16 @@ public Bytes flush(int mode = Z_FINISH) { err = zst.deflate((FlushStrategy)mode); } - if (err == Z_STREAM_END && mode == Z_FINISH) { + if(err == Z_STREAM_END && mode == Z_FINISH) + { err = zst.deflateEnd(); - if (err != Z_OK) { + if(err != Z_OK) + { throw ZlibModule.zlib_error(this.zst, err, "from deflateEnd()"); } - } else if (err != Z_OK && err != Z_BUF_ERROR) { + } + else if(err != Z_OK && err != Z_BUF_ERROR) + { throw ZlibModule.zlib_error(this.zst, err, "while flushing"); } @@ -128,7 +141,8 @@ public Bytes flush(int mode = Z_FINISH) { private ZStream zst; - private static Bytes GetBytes(byte[] bytes, int index, int count) { + private static Bytes GetBytes(byte[] bytes, int index, int count) + { var res = new byte[count]; Array.Copy(bytes, index, res, 0, count); return Bytes.Make(res); diff --git a/src/ipy/IronPython.Modules/zlib/Decompress.cs b/src/ipy/IronPython.Modules/zlib/Decompress.cs index 528e36cf2..c0965e6ad 100644 --- a/src/ipy/IronPython.Modules/zlib/Decompress.cs +++ b/src/ipy/IronPython.Modules/zlib/Decompress.cs @@ -6,19 +6,20 @@ // using System; +using System.Collections.Generic; using System.Linq; - +using System.Runtime.InteropServices; using ComponentAce.Compression.Libs.ZLib; - using IronPython.Runtime; using IronPython.Runtime.Operations; - using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -namespace IronPython.Zlib { +namespace IronPython.Zlib +{ [PythonType] - public class Decompress { + public class Decompress + { private const int Z_OK = ZlibModule.Z_OK; private const int Z_STREAM_END = ZlibModule.Z_STREAM_END; private const int Z_BUF_ERROR = ZlibModule.Z_BUF_ERROR; @@ -26,10 +27,12 @@ public class Decompress { private const int Z_SYNC_FLUSH = ZlibModule.Z_SYNC_FLUSH; private const int Z_FINISH = ZlibModule.Z_FINISH; - internal Decompress(int wbits) { + internal Decompress(int wbits) + { zst = new ZStream(); int err = zst.inflateInit(wbits); - switch (err) { + switch(err) + { case ZlibModule.Z_OK: break; @@ -56,8 +59,9 @@ Call the flush() method to clear these buffers. If the max_length parameter is specified then the return value will be no longer than max_length. Unconsumed input data will be stored in the unconsumed_tail attribute.")] - public Bytes decompress([NotNone] IBufferProtocol data, int max_length = 0) { - if (max_length < 0) throw new ArgumentException("max_length must be greater than zero"); + public Bytes decompress([NotNone] IBufferProtocol data, int max_length=0) + { + if(max_length < 0) throw new ArgumentException("max_length must be greater than zero"); using var buffer = data.GetBuffer(); byte[] input = buffer.AsUnsafeArray() ?? buffer.ToArray(); @@ -73,8 +77,9 @@ public Bytes decompress([NotNone] IBufferProtocol data, int max_length = 0) { int err = zst.inflate(FlushStrategy.Z_SYNC_FLUSH); - while (err == Z_OK && zst.avail_out == 0) { - if (max_length > 0 && output.Length >= max_length) + while(err == Z_OK && zst.avail_out == 0) + { + if(max_length > 0 && output.Length >= max_length) break; int old_length = output.Length; @@ -85,14 +90,18 @@ public Bytes decompress([NotNone] IBufferProtocol data, int max_length = 0) { err = zst.inflate(FlushStrategy.Z_SYNC_FLUSH); } - if (max_length > 0) { + if(max_length > 0) + { unconsumed_tail = GetBytes(zst.next_in, zst.next_in_index, zst.avail_in); } - if (err == Z_STREAM_END) { + if(err == Z_STREAM_END) + { unused_data += GetBytes(zst.next_in, zst.next_in_index, zst.avail_in); eof = true; - } else if (err != Z_OK && err != Z_BUF_ERROR) { + } + else if(err != Z_OK && err != Z_BUF_ERROR) + { throw ZlibModule.zlib_error(this.zst, err, "while decompressing"); } @@ -106,8 +115,9 @@ public Bytes decompress([NotNone] IBufferProtocol data, int max_length = 0) { output buffer. The decompressor object can no longer be used after this call.")] - public Bytes flush(int length = ZlibModule.DEFAULTALLOC) { - if (length < 1) + public Bytes flush(int length=ZlibModule.DEFAULTALLOC) + { + if(length < 1) throw PythonOps.ValueError("length must be greater than 0."); byte[] output = new byte[length]; @@ -119,7 +129,8 @@ public Bytes flush(int length = ZlibModule.DEFAULTALLOC) { int err = zst.inflate(FlushStrategy.Z_FINISH); - while ((err == Z_OK || err == Z_BUF_ERROR) && zst.avail_out == 0) { + while((err == Z_OK || err == Z_BUF_ERROR) &&zst.avail_out == 0) + { int old_length = output.Length; Array.Resize(ref output, output.Length * 2); zst.next_out = output; @@ -128,9 +139,11 @@ public Bytes flush(int length = ZlibModule.DEFAULTALLOC) { err = zst.inflate(FlushStrategy.Z_FINISH); } - if (err == Z_STREAM_END) { + if(err == Z_STREAM_END) + { err = zst.inflateEnd(); - if (err != Z_OK) { + if(err != Z_OK) + { throw ZlibModule.zlib_error(this.zst, err, "from inflateEnd()"); } } @@ -146,7 +159,8 @@ public Bytes flush(int length = ZlibModule.DEFAULTALLOC) { private ZStream zst; - private static Bytes GetBytes(byte[] bytes, int index, int count) { + private static Bytes GetBytes(byte[] bytes, int index, int count) + { var res = new byte[count]; Array.Copy(bytes, index, res, 0, count); return Bytes.Make(res); diff --git a/src/ipy/IronPython.Modules/zlib/ZlibModule.cs b/src/ipy/IronPython.Modules/zlib/ZlibModule.cs index 940739236..208c61417 100644 --- a/src/ipy/IronPython.Modules/zlib/ZlibModule.cs +++ b/src/ipy/IronPython.Modules/zlib/ZlibModule.cs @@ -6,23 +6,24 @@ // using System; +using System.Collections.Generic; using System.Linq; +using System.Numerics; using System.Runtime.CompilerServices; - using ComponentAce.Compression.Libs.ZLib; - using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; - using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; [assembly: PythonModule("zlib", typeof(IronPython.Zlib.ZlibModule))] -namespace IronPython.Zlib { - public static class ZlibModule { +namespace IronPython.Zlib +{ + public static class ZlibModule + { public const string __doc__ = @"The functions in this module allow compression and decompression using the zlib library, which is based on GNU zip. @@ -72,7 +73,8 @@ public static class ZlibModule { An optional starting value can be specified. The returned checksum is a signed integer.")] - public static int adler32([NotNone] IBufferProtocol data, long value = 1L) { + public static int adler32([NotNone] IBufferProtocol data, long value=1L) + { using var buffer = data.GetBuffer(); return (int)Adler32.GetAdler32Checksum(value, buffer.AsUnsafeArray() ?? buffer.ToArray(), 0, buffer.NumBytes()); } @@ -89,7 +91,8 @@ public static object crc32([NotNone] IBufferProtocol data, uint value = 0) Optional arg level is the compression level, in 1-9.")] public static Bytes compress([NotNone] IBufferProtocol data, - int level = Z_DEFAULT_COMPRESSION) { + int level=Z_DEFAULT_COMPRESSION) + { using var buffer = data.GetBuffer(); byte[] input = buffer.AsUnsafeArray() ?? buffer.ToArray(); byte[] output = new byte[input.Length + input.Length / 1000 + 12 + 1]; @@ -101,14 +104,15 @@ public static Bytes compress([NotNone] IBufferProtocol data, zst.avail_out = output.Length; int err = zst.DeflateInit(level); - switch (err) { + switch(err) + { case (Z_OK): break; - + case (Z_STREAM_ERROR): throw PythonOps.CreateThrowable(error, "Bad compression level"); - + default: zst.deflateEnd(); zlib_error(zst, err, "while compressing data"); @@ -117,14 +121,16 @@ public static Bytes compress([NotNone] IBufferProtocol data, err = zst.deflate(FlushStrategy.Z_FINISH); - if (err != Z_STREAM_END) { + if(err != Z_STREAM_END) + { zst.deflateEnd(); throw zlib_error(zst, err, "while compressing data"); } err = zst.deflateEnd(); - if (err == Z_OK) { + if(err == Z_OK) + { var res = new byte[(int)zst.total_out]; Array.Copy(output, res, res.Length); return Bytes.Make(res); @@ -137,11 +143,12 @@ public static Bytes compress([NotNone] IBufferProtocol data, Optional arg level is the compression level, in 1-9.")] public static Compress compressobj( - int level = Z_DEFAULT_COMPRESSION, - int method = DEFLATED, - int wbits = MAX_WBITS, - int memlevel = DEF_MEM_LEVEL, - int strategy = Z_DEFAULT_STRATEGY) { + int level=Z_DEFAULT_COMPRESSION, + int method=DEFLATED, + int wbits=MAX_WBITS, + int memlevel=DEF_MEM_LEVEL, + int strategy=Z_DEFAULT_STRATEGY) + { return new Compress(level, method, wbits, memlevel, strategy); } @@ -150,8 +157,9 @@ public static Compress compressobj( Optional arg wbits is the window buffer size. Optional arg bufsize is the initial output buffer size.")] public static Bytes decompress([NotNone] IBufferProtocol data, - int wbits = MAX_WBITS, - int bufsize = DEFAULTALLOC) { + int wbits=MAX_WBITS, + int bufsize=DEFAULTALLOC) + { using var buffer = data.GetBuffer(); var bytes = Decompress(buffer.AsUnsafeArray() ?? buffer.ToArray(), wbits, bufsize); return Bytes.Make(bytes); @@ -160,24 +168,30 @@ public static Bytes decompress([NotNone] IBufferProtocol data, [Documentation(@"decompressobj([wbits]) -- Return a decompressor object. Optional arg wbits is the window buffer size.")] - public static Decompress decompressobj(int wbits = MAX_WBITS) { + public static Decompress decompressobj(int wbits=MAX_WBITS) + { return new Decompress(wbits); } [SpecialName] - public static void PerformModuleReload(PythonContext context, PythonDictionary dict) { + public static void PerformModuleReload(PythonContext context, PythonDictionary dict) + { error = context.EnsureModuleException("zlib.error", PythonExceptions.Exception, dict, "error", "zlib"); } public static PythonType error; - internal static Exception MakeError(params object[] args) { + internal static Exception MakeError(params object[] args) + { return PythonOps.CreateThrowable(error, args); } - internal static Exception zlib_error(ZStream zst, int err, string msg) { + internal static Exception zlib_error(ZStream zst, int err, string msg) + { string zmsg = zst.msg; - if (zmsg == null) { - switch (err) { + if(zmsg == null) + { + switch(err) + { case Z_BUF_ERROR: zmsg = "incomplete or truncated stream"; break; @@ -190,14 +204,15 @@ internal static Exception zlib_error(ZStream zst, int err, string msg) { } } - if (zmsg == null) + if(zmsg == null) return MakeError(string.Format("Error {0} {1}", err, msg)); else return MakeError(string.Format("Error {0} {1}: {2}", err, msg, zmsg)); } [PythonHidden] - internal static byte[] Decompress(byte[] input, int wbits = MAX_WBITS, int bufsize = DEFAULTALLOC) { + internal static byte[] Decompress(byte[] input, int wbits=MAX_WBITS, int bufsize=DEFAULTALLOC) + { byte[] outputBuffer = new byte[bufsize]; byte[] output = new byte[bufsize]; int outputOffset = 0; @@ -209,20 +224,26 @@ internal static byte[] Decompress(byte[] input, int wbits = MAX_WBITS, int bufsi zst.avail_out = outputBuffer.Length; int err = zst.inflateInit(wbits); - if (err != Z_OK) { + if(err != Z_OK) + { zst.inflateEnd(); throw zlib_error(zst, err, "while preparing to decompress data"); } - do { + do + { err = zst.inflate(FlushStrategy.Z_FINISH); - if (err != Z_STREAM_END) { - if (err == Z_BUF_ERROR && zst.avail_out > 0) { + if(err != Z_STREAM_END) + { + if(err == Z_BUF_ERROR && zst.avail_out > 0) + { zst.inflateEnd(); throw zlib_error(zst, err, "while decompressing data"); - } else if (err == Z_OK || (err == Z_BUF_ERROR && zst.avail_out == 0)) { + } + else if(err == Z_OK || (err == Z_BUF_ERROR && zst.avail_out == 0)) + { // copy to the output and reset the buffer - if (outputOffset + outputBuffer.Length > output.Length) + if(outputOffset + outputBuffer.Length > output.Length) Array.Resize(ref output, output.Length * 2); Array.Copy(outputBuffer, 0, output, outputOffset, outputBuffer.Length); @@ -231,20 +252,23 @@ internal static byte[] Decompress(byte[] input, int wbits = MAX_WBITS, int bufsi zst.next_out = outputBuffer; zst.avail_out = outputBuffer.Length; zst.next_out_index = 0; - } else { + } + else + { zst.inflateEnd(); throw zlib_error(zst, err, "while decompressing data"); } } - } while (err != Z_STREAM_END); + } while(err != Z_STREAM_END); err = zst.inflateEnd(); - if (err != Z_OK) { + if(err != Z_OK) + { throw zlib_error(zst, err, "while finishing data decompression"); } - if (outputOffset + outputBuffer.Length - zst.avail_out > output.Length) + if(outputOffset + outputBuffer.Length - zst.avail_out > output.Length) Array.Resize(ref output, output.Length * 2); Array.Copy(outputBuffer, 0, output, outputOffset, outputBuffer.Length - zst.avail_out); diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/Adler32.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/Adler32.cs index 827b0f019..aa3f973b9 100644 --- a/src/ipy/IronPython.Modules/zlib/zlib.net/Adler32.cs +++ b/src/ipy/IronPython.Modules/zlib/zlib.net/Adler32.cs @@ -44,60 +44,70 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * and contributors of zlib. */ -namespace ComponentAce.Compression.Libs.ZLib { +using System; + +namespace ComponentAce.Compression.Libs.ZLib +{ /// /// This class represents adler32 checksum algorithm. /// - public static class Adler32 { - // largest prime smaller than 65536 - private const int BASE = 65521; - // NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 - private const int NMAX = 5552; - + public static class Adler32 + { + // largest prime smaller than 65536 + private const int BASE = 65521; + // NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 + private const int NMAX = 5552; + /// /// This static method returns adler32 checksum of the buffer data /// - public static long GetAdler32Checksum(long adler, byte[] buf, int index, int len) { - if (buf == null) { - return 1L; - } - - long s1 = adler & 0xffff; - long s2 = (adler >> 16) & 0xffff; - int k; - - while (len > 0) { - k = len < NMAX ? len : NMAX; - len -= k; - while (k >= 16) { - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - k -= 16; - } - if (k != 0) { - do { - s1 += (buf[index++] & 0xff); s2 += s1; - } - while (--k != 0); - } - s1 %= BASE; - s2 %= BASE; - } - return (s2 << 16) | s1; - } - } + public static long GetAdler32Checksum(long adler, byte[] buf, int index, int len) + { + if (buf == null) + { + return 1L; + } + + long s1 = adler & 0xffff; + long s2 = (adler >> 16) & 0xffff; + int k; + + while (len > 0) + { + k = len < NMAX?len:NMAX; + len -= k; + while (k >= 16) + { + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + s1 += (buf[index++] & 0xff); s2 += s1; + k -= 16; + } + if (k != 0) + { + do + { + s1 += (buf[index++] & 0xff); s2 += s1; + } + while (--k != 0); + } + s1 %= BASE; + s2 %= BASE; + } + return (s2 << 16) | s1; + } + } } \ No newline at end of file diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/Deflate.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/Deflate.cs index 02f124f20..59ab2d132 100644 --- a/src/ipy/IronPython.Modules/zlib/zlib.net/Deflate.cs +++ b/src/ipy/IronPython.Modules/zlib/zlib.net/Deflate.cs @@ -44,19 +44,22 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using System; -namespace ComponentAce.Compression.Libs.ZLib { +namespace ComponentAce.Compression.Libs.ZLib +{ /// /// Implementation of the Deflate compression algorithm. /// - public sealed class Deflate { + public sealed class Deflate + { #region Nested class /// /// Deflate algorithm configuration parameters class /// - internal class Config { + internal class Config + { /// /// reduce lazy search above this match length /// @@ -75,11 +78,12 @@ internal class Config { internal int max_chain; internal int func; - + /// /// Constructor which initializes class inner fields /// - internal Config(int good_length, int max_lazy, int nice_length, int max_chain, int func) { + internal Config(int good_length, int max_lazy, int nice_length, int max_chain, int func) + { this.good_length = good_length; this.max_lazy = max_lazy; this.nice_length = nice_length; @@ -101,7 +105,7 @@ internal Config(int good_length, int max_lazy, int nice_length, int max_chain, i /// Defalult compression method /// public const int Z_DEFAULT_COMPRESSION = -1; - + /// /// Default memory level /// @@ -111,7 +115,7 @@ internal Config(int good_length, int max_lazy, int nice_length, int max_chain, i private const int STORED = 0; private const int FAST = 1; private const int SLOW = 2; - + /// /// Deflate class congiration table /// @@ -253,7 +257,7 @@ internal Config(int good_length, int max_lazy, int nice_length, int max_chain, i /// /// LZ77 Window size (32K by default) /// - private int w_size; + private int w_size; /// /// log2(w_size) (8..16) @@ -383,7 +387,7 @@ internal Config(int good_length, int max_lazy, int nice_length, int max_chain, i /// favor or force Huffman coding /// private CompressionStrategy strategy; - + /// /// Use a faster search when the previous match is longer than this /// @@ -403,7 +407,7 @@ internal Config(int good_length, int max_lazy, int nice_length, int max_chain, i /// distance tree /// private short[] dyn_dtree; - + /// /// Huffman tree for bit lengths /// @@ -417,7 +421,7 @@ internal Config(int good_length, int max_lazy, int nice_length, int max_chain, i /// /// desc for distance tree /// - private Tree d_desc = new Tree(); + private Tree d_desc = new Tree(); /// /// desc for bit length tree @@ -531,7 +535,8 @@ internal Config(int good_length, int max_lazy, int nice_length, int max_chain, i /// /// Default constructor /// - internal Deflate() { + internal Deflate() + { dyn_ltree = new short[HEAP_SIZE * 2]; dyn_dtree = new short[(2 * D_CODES + 1) * 2]; // distance tree bl_tree = new short[(2 * BL_CODES + 1) * 2]; // Huffman tree for bit lengths @@ -540,7 +545,8 @@ internal Deflate() { /// /// Initialization /// - private void lm_init() { + private void lm_init() + { window_size = 2 * w_size; Array.Clear(head, 0, hash_size); @@ -562,7 +568,8 @@ private void lm_init() { /// /// Initialize the tree data structures for a new zlib stream. /// - private void tr_init() { + private void tr_init() + { l_desc.DynTree = dyn_ltree; l_desc.StatDesc = StaticTree.static_l_desc; @@ -584,7 +591,8 @@ private void tr_init() { /// /// Initializes block /// - private void init_block() { + private void init_block() + { // Initialize the trees. for (int i = 0; i < L_CODES; i++) dyn_ltree[i * 2] = 0; @@ -604,12 +612,15 @@ private void init_block() { /// when the heap property is re-established (each father smaller than its /// two sons). /// - internal void pqdownheap(short[] tree, int k) { + internal void pqdownheap(short[] tree, int k) + { int v = heap[k]; int j = k << 1; // left son of k - while (j <= heap_len) { + while (j <= heap_len) + { // Set j to the smallest of the two sons: - if (j < heap_len && smaller(tree, heap[j + 1], heap[j], depth)) { + if (j < heap_len && smaller(tree, heap[j + 1], heap[j], depth)) + { j++; } // Exit if v is smaller than both sons @@ -624,7 +635,8 @@ internal void pqdownheap(short[] tree, int k) { heap[k] = v; } - internal static bool smaller(short[] tree, int n, int m, byte[] depth) { + internal static bool smaller(short[] tree, int n, int m, byte[] depth) + { return (tree[n * 2] < tree[m * 2] || (tree[n * 2] == tree[m * 2] && depth[n] <= depth[m])); } @@ -632,7 +644,8 @@ internal static bool smaller(short[] tree, int n, int m, byte[] depth) { /// Scan a literal or distance tree to determine the frequencies of the codes /// in the bit length tree. ///
- private void scan_tree(short[] tree, int max_code) { + private void scan_tree(short[] tree, int max_code) + { int n; // iterates over all tree elements int prevlen = -1; // last emitted length int curlen; // length of current code @@ -641,34 +654,49 @@ private void scan_tree(short[] tree, int max_code) { int max_count = 7; // max repeat count int min_count = 4; // min repeat count - if (nextlen == 0) { + if (nextlen == 0) + { max_count = 138; min_count = 3; } tree[(max_code + 1) * 2 + 1] = (short)ZLibUtil.Identity(0xffff); // guard - for (n = 0; n <= max_code; n++) { + for (n = 0; n <= max_code; n++) + { curlen = nextlen; nextlen = tree[(n + 1) * 2 + 1]; - if (++count < max_count && curlen == nextlen) { + if (++count < max_count && curlen == nextlen) + { continue; } - if (count < min_count) { + if (count < min_count) + { bl_tree[curlen * 2] = (short)(bl_tree[curlen * 2] + count); - } else if (curlen != 0) { + } + else if (curlen != 0) + { if (curlen != prevlen) bl_tree[curlen * 2]++; bl_tree[REP_3_6 * 2]++; - } else if (count <= 10) { + } + else if (count <= 10) + { bl_tree[REPZ_3_10 * 2]++; - } else { + } + else + { bl_tree[REPZ_11_138 * 2]++; } count = 0; prevlen = curlen; - if (nextlen == 0) { + if (nextlen == 0) + { max_count = 138; min_count = 3; - } else if (curlen == nextlen) { + } + else if (curlen == nextlen) + { max_count = 6; min_count = 3; - } else { + } + else + { max_count = 7; min_count = 4; } } @@ -678,7 +706,8 @@ private void scan_tree(short[] tree, int max_code) { /// Construct the Huffman tree for the bit lengths and return the index in /// bl_order of the last bit length code to send. ///
- private int build_bl_tree() { + private int build_bl_tree() + { int max_blindex; // index of last bit length code of non zero freq // Determine the bit length frequencies for literal and distance trees @@ -693,7 +722,8 @@ private int build_bl_tree() { // Determine the number of bit length codes to send. The pkzip format // requires that at least 4 bit length codes be sent. (appnote.txt says // 3 but the actual value used is 4.) - for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) { + for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) + { if (bl_tree[ZLibUtil.bl_order[max_blindex] * 2 + 1] != 0) break; } @@ -708,13 +738,15 @@ private int build_bl_tree() { /// lengths of the bit length codes, the literal tree and the distance tree. /// IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. /// - private void send_all_trees(int lcodes, int dcodes, int blcodes) { + private void send_all_trees(int lcodes, int dcodes, int blcodes) + { int rank; // index in bl_order send_bits(lcodes - 257, 5); // not +255 as stated in appnote.txt send_bits(dcodes - 1, 5); send_bits(blcodes - 4, 4); // not -3 as stated in appnote.txt - for (rank = 0; rank < blcodes; rank++) { + for (rank = 0; rank < blcodes; rank++) + { send_bits(bl_tree[ZLibUtil.bl_order[rank] * 2 + 1], 3); } send_tree(dyn_ltree, lcodes - 1); // literal tree @@ -725,7 +757,8 @@ private void send_all_trees(int lcodes, int dcodes, int blcodes) { /// Send a literal or distance tree in compressed form, using the codes in /// bl_tree. /// - private void send_tree(short[] tree, int max_code) { + private void send_tree(short[] tree, int max_code) + { int n; // iterates over all tree elements int prevlen = -1; // last emitted length int curlen; // length of current code @@ -734,38 +767,56 @@ private void send_tree(short[] tree, int max_code) { int max_count = 7; // max repeat count int min_count = 4; // min repeat count - if (nextlen == 0) { + if (nextlen == 0) + { max_count = 138; min_count = 3; } - for (n = 0; n <= max_code; n++) { + for (n = 0; n <= max_code; n++) + { curlen = nextlen; nextlen = tree[(n + 1) * 2 + 1]; - if (++count < max_count && curlen == nextlen) { + if (++count < max_count && curlen == nextlen) + { continue; - } else if (count < min_count) { - do { + } + else if (count < min_count) + { + do + { send_code(curlen, bl_tree); } while (--count != 0); - } else if (curlen != 0) { - if (curlen != prevlen) { + } + else if (curlen != 0) + { + if (curlen != prevlen) + { send_code(curlen, bl_tree); count--; } send_code(REP_3_6, bl_tree); send_bits(count - 3, 2); - } else if (count <= 10) { + } + else if (count <= 10) + { send_code(REPZ_3_10, bl_tree); send_bits(count - 3, 3); - } else { + } + else + { send_code(REPZ_11_138, bl_tree); send_bits(count - 11, 7); } count = 0; prevlen = curlen; - if (nextlen == 0) { + if (nextlen == 0) + { max_count = 138; min_count = 3; - } else if (curlen == nextlen) { + } + else if (curlen == nextlen) + { max_count = 6; min_count = 3; - } else { + } + else + { max_count = 7; min_count = 4; } } @@ -775,7 +826,8 @@ private void send_tree(short[] tree, int max_code) { /// Output a byte on the stream. /// IN assertion: there is enough room in Pending_buf. /// - private void put_byte(byte[] p, int start, int len) { + private void put_byte(byte[] p, int start, int len) + { Array.Copy(p, start, Pending_buf, Pending, len); Pending += len; } @@ -783,34 +835,42 @@ private void put_byte(byte[] p, int start, int len) { /// /// Adds a byte to the buffer /// - private void put_byte(byte c) { + private void put_byte(byte c) + { Pending_buf[Pending++] = c; } - private void put_short(int w) { + private void put_short(int w) + { put_byte((byte)(w)); put_byte((byte)(ZLibUtil.URShift(w, 8))); } - private void putShortMSB(int b) { + private void putShortMSB(int b) + { put_byte((byte)(b >> 8)); put_byte((byte)(b)); } - private void send_code(int c, short[] tree) { + private void send_code(int c, short[] tree) + { send_bits((tree[c * 2] & 0xffff), (tree[c * 2 + 1] & 0xffff)); } - private void send_bits(int value_Renamed, int length) { + private void send_bits(int value_Renamed, int length) + { int len = length; - if (bi_valid > (int)Buf_size - len) { + if (bi_valid > (int)Buf_size - len) + { int val = value_Renamed; // bi_buf |= (val << bi_valid); bi_buf = (short)((ushort)bi_buf | (ushort)(((val << bi_valid) & 0xffff))); put_short(bi_buf); bi_buf = (short)(ZLibUtil.URShift(val, (Buf_size - bi_valid))); bi_valid += len - Buf_size; - } else { + } + else + { // bi_buf |= (value) << bi_valid; bi_buf = (short)((ushort)bi_buf | (ushort)((((value_Renamed) << bi_valid) & 0xffff))); bi_valid += len; @@ -828,7 +888,8 @@ private void send_bits(int value_Renamed, int length) { /// To simplify the code, we assume the worst case of last real code encoded /// on one bit only. /// - private void _tr_align() { + private void _tr_align() + { send_bits(STATIC_TREES << 1, 3); send_code(END_BLOCK, StaticTree.static_ltree); @@ -838,7 +899,8 @@ private void _tr_align() { // (10 - bi_valid) bits. The lookahead for the last real code (before // the EOB of the previous block) was thus at least one plus the length // of the EOB plus what we have just sent of the empty static block. - if (1 + last_eob_len + 10 - bi_valid < 9) { + if (1 + last_eob_len + 10 - bi_valid < 9) + { send_bits(STATIC_TREES << 1, 3); send_code(END_BLOCK, StaticTree.static_ltree); bi_flush(); @@ -850,17 +912,21 @@ private void _tr_align() { /// Save the match info and tally the frequency counts. Return true if /// the current block must be flushed. /// - private bool _tr_tally(int dist, int lc) { + private bool _tr_tally(int dist, int lc) + { Pending_buf[d_buf + last_lit * 2] = (byte)(ZLibUtil.URShift(dist, 8)); Pending_buf[d_buf + last_lit * 2 + 1] = (byte)dist; Pending_buf[l_buf + last_lit] = (byte)lc; last_lit++; - if (dist == 0) { + if (dist == 0) + { // lc is the unmatched char dyn_ltree[lc * 2]++; - } else { + } + else + { matches++; // Here, lc is the match length - MIN_MATCH dist--; // dist = match distance - 1 @@ -868,12 +934,14 @@ private bool _tr_tally(int dist, int lc) { dyn_dtree[Tree.d_code(dist) * 2]++; } - if ((last_lit & 0x1fff) == 0 && level > 2) { + if ((last_lit & 0x1fff) == 0 && level > 2) + { // Compute an upper bound for the compressed length int out_length = last_lit * 8; int in_length = strstart - block_start; int dcode; - for (dcode = 0; dcode < D_CODES; dcode++) { + for (dcode = 0; dcode < D_CODES; dcode++) + { out_length = (int)(out_length + (int)dyn_dtree[dcode * 2] * (5L + ZLibUtil.extra_dbits[dcode])); } out_length = ZLibUtil.URShift(out_length, 3); @@ -890,27 +958,34 @@ private bool _tr_tally(int dist, int lc) { /// /// Send the block data compressed using the given Huffman trees /// - private void compress_block(short[] ltree, short[] dtree) { + private void compress_block(short[] ltree, short[] dtree) + { int dist; // distance of matched string int lc; // match length or unmatched char (if dist == 0) int lx = 0; // running index in l_buf int code; // the code to send int extra; // number of extra bits to send - if (last_lit != 0) { - do { + if (last_lit != 0) + { + do + { dist = ((Pending_buf[d_buf + lx * 2] << 8) & 0xff00) | (Pending_buf[d_buf + lx * 2 + 1] & 0xff); lc = (Pending_buf[l_buf + lx]) & 0xff; lx++; - if (dist == 0) { + if (dist == 0) + { send_code(lc, ltree); // send a literal byte - } else { + } + else + { // Here, lc is the match length - MIN_MATCH code = ZLibUtil._length_code[lc]; send_code(code + LITERALS + 1, ltree); // send the length code extra = ZLibUtil.extra_lbits[code]; - if (extra != 0) { + if (extra != 0) + { lc -= ZLibUtil.base_length[code]; send_bits(lc, extra); // send the extra length bits } @@ -919,7 +994,8 @@ private void compress_block(short[] ltree, short[] dtree) { send_code(code, dtree); // send the distance code extra = ZLibUtil.extra_dbits[code]; - if (extra != 0) { + if (extra != 0) + { dist -= ZLibUtil.base_dist[code]; send_bits(dist, extra); // send the extra distance bits } @@ -940,17 +1016,21 @@ private void compress_block(short[] ltree, short[] dtree) { /// IN assertion: the fields freq of dyn_ltree are set and the total of all /// frequencies does not exceed 64K (to fit in an int on 16 bit machines). /// - private void set_data_type() { + private void set_data_type() + { int n = 0; int ascii_freq = 0; int bin_freq = 0; - while (n < 7) { + while (n < 7) + { bin_freq += dyn_ltree[n * 2]; n++; } - while (n < 128) { + while (n < 128) + { ascii_freq += dyn_ltree[n * 2]; n++; } - while (n < LITERALS) { + while (n < LITERALS) + { bin_freq += dyn_ltree[n * 2]; n++; } data_type = (bin_freq > (ZLibUtil.URShift(ascii_freq, 2)) ? BlockType.Z_BINARY : BlockType.Z_ASCII); @@ -959,12 +1039,16 @@ private void set_data_type() { /// /// Flush the bit buffer, keeping at most 7 bits in it. /// - private void bi_flush() { - if (bi_valid == 16) { + private void bi_flush() + { + if (bi_valid == 16) + { put_short(bi_buf); bi_buf = 0; bi_valid = 0; - } else if (bi_valid >= 8) { + } + else if (bi_valid >= 8) + { put_byte((byte)bi_buf); bi_buf = (short)(ZLibUtil.URShift(bi_buf, 8)); bi_valid -= 8; @@ -974,10 +1058,14 @@ private void bi_flush() { /// /// Flush the bit buffer and align the output on a byte boundary /// - private void bi_windup() { - if (bi_valid > 8) { + private void bi_windup() + { + if (bi_valid > 8) + { put_short(bi_buf); - } else if (bi_valid > 0) { + } + else if (bi_valid > 0) + { put_byte((byte)bi_buf); } bi_buf = 0; @@ -988,12 +1076,14 @@ private void bi_windup() { /// Copy a stored block, storing first the length and its /// one's complement if requested. /// - private void copy_block(int buf, int len, bool header) { + private void copy_block(int buf, int len, bool header) + { bi_windup(); // align on byte boundary last_eob_len = 8; // enough lookahead for inflate - if (header) { + if (header) + { put_short((short)len); put_short((short)~len); } @@ -1004,7 +1094,8 @@ private void copy_block(int buf, int len, bool header) { /// /// Flushes block /// - private void flush_block_only(bool eof) { + private void flush_block_only(bool eof) + { _tr_flush_block(block_start >= 0 ? block_start : -1, strstart - block_start, eof); block_start = strstart; strm.FlushPending(); @@ -1019,21 +1110,25 @@ private void flush_block_only(bool eof) { /// NOTE: this function should be optimized to avoid extra copying from /// Window to Pending_buf. /// - private int deflate_stored(int flush) { + private int deflate_stored(int flush) + { // Stored blocks are limited to 0xffff bytes, Pending_buf is limited // to pending_buf_size, and each stored block has a 5 byte header: int max_block_size = 0xffff; int max_start; - if (max_block_size > pending_buf_size - 5) { + if (max_block_size > pending_buf_size - 5) + { max_block_size = pending_buf_size - 5; } // Copy as much as possible from input to output: - while (true) { + while (true) + { // Fill the Window as much as possible: - if (lookahead <= 1) { + if (lookahead <= 1) + { fill_window(); if (lookahead == 0 && flush == (int)FlushStrategy.Z_NO_FLUSH) return NeedMore; @@ -1046,7 +1141,8 @@ private int deflate_stored(int flush) { // Emit a stored block if Pending_buf will be full: max_start = block_start + max_block_size; - if (strstart == 0 || strstart >= max_start) { + if (strstart == 0 || strstart >= max_start) + { // strstart == 0 is possible when wraparound on 16-bit machine lookahead = (int)(strstart - max_start); strstart = (int)max_start; @@ -1058,7 +1154,8 @@ private int deflate_stored(int flush) { // Flush if we may have to slide, otherwise block_start may become // negative and the data will be gone: - if (strstart - block_start >= w_size - MIN_LOOKAHEAD) { + if (strstart - block_start >= w_size - MIN_LOOKAHEAD) + { flush_block_only(false); if (strm.avail_out == 0) return NeedMore; @@ -1075,7 +1172,8 @@ private int deflate_stored(int flush) { /// /// Send a stored block /// - private void _tr_stored_block(int buf, int stored_len, bool eof) { + private void _tr_stored_block(int buf, int stored_len, bool eof) + { send_bits((STORED_BLOCK << 1) + (eof ? 1 : 0), 3); // send block type copy_block(buf, stored_len, true); // with header } @@ -1084,12 +1182,14 @@ private void _tr_stored_block(int buf, int stored_len, bool eof) { /// Determine the best encoding for the current block: dynamic trees, static /// trees or store, and output the encoded block to the zip file. /// - private void _tr_flush_block(int buf, int stored_len, bool eof) { + private void _tr_flush_block(int buf, int stored_len, bool eof) + { int opt_lenb, static_lenb; // opt_len and static_len in bytes int max_blindex = 0; // index of last bit length code of non zero freq // Build the Huffman trees unless a stored block is forced - if (level > 0) { + if (level > 0) + { // Check if the file is ascii or binary if (data_type == BlockType.Z_UNKNOWN) set_data_type(); @@ -1112,11 +1212,14 @@ private void _tr_flush_block(int buf, int stored_len, bool eof) { if (static_lenb <= opt_lenb) opt_lenb = static_lenb; - } else { + } + else + { opt_lenb = static_lenb = stored_len + 5; // force a stored block } - if (stored_len + 4 <= opt_lenb && buf != -1) { + if (stored_len + 4 <= opt_lenb && buf != -1) + { // 4: two words for the lengths // The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. // Otherwise we can't have processed more than WSIZE input bytes since @@ -1124,10 +1227,14 @@ private void _tr_flush_block(int buf, int stored_len, bool eof) { // successful. If LIT_BUFSIZE <= WSIZE, it is never too late to // transform a block into a stored block. _tr_stored_block(buf, stored_len, eof); - } else if (static_lenb == opt_lenb) { + } + else if (static_lenb == opt_lenb) + { send_bits((STATIC_TREES << 1) + (eof ? 1 : 0), 3); compress_block(StaticTree.static_ltree, StaticTree.static_dtree); - } else { + } + else + { send_bits((DYN_TREES << 1) + (eof ? 1 : 0), 3); send_all_trees(l_desc.MaxCode + 1, d_desc.MaxCode + 1, max_blindex + 1); compress_block(dyn_ltree, dyn_dtree); @@ -1138,7 +1245,8 @@ private void _tr_flush_block(int buf, int stored_len, bool eof) { init_block(); - if (eof) { + if (eof) + { bi_windup(); } } @@ -1153,25 +1261,32 @@ private void _tr_flush_block(int buf, int stored_len, bool eof) { /// performed for at least two bytes (required for the zip translate_eol /// option -- not supported here). /// - private void fill_window() { + private void fill_window() + { int n, m; int p; int more; // Amount of free space at the End of the Window. - do { + do + { more = (window_size - lookahead - strstart); // Deal with !@#$% 64K limit: - if (more == 0 && strstart == 0 && lookahead == 0) { + if (more == 0 && strstart == 0 && lookahead == 0) + { more = w_size; - } else if (more == -1) { + } + else if (more == -1) + { // Very unlikely, but possible on 16 bit machine if strstart == 0 // and lookahead == 1 (input done one byte at time) more--; // If the Window is almost full and there is insufficient lookahead, // move the upper half to the lower one to make room in the upper half. - } else if (strstart >= w_size + w_size - MIN_LOOKAHEAD) { + } + else if (strstart >= w_size + w_size - MIN_LOOKAHEAD) + { Array.Copy(window, w_size, window, 0, w_size); match_start -= w_size; strstart -= w_size; // we now have strstart >= MAX_DIST @@ -1185,7 +1300,8 @@ private void fill_window() { n = hash_size; p = n; - do { + do + { m = (head[--p] & 0xffff); head[p] = (short)(m >= w_size ? (m - w_size) : 0); //head[p] = (m >= w_size?(short) (m - w_size):0); @@ -1194,7 +1310,8 @@ private void fill_window() { n = w_size; p = n; - do { + do + { m = (prev[--p] & 0xffff); prev[p] = (short)(m >= w_size ? (m - w_size) : 0); //prev[p] = (m >= w_size?(short) (m - w_size):0); @@ -1223,7 +1340,8 @@ private void fill_window() { lookahead += n; // Initialize the hash value now that we have some input: - if (lookahead >= MIN_MATCH) { + if (lookahead >= MIN_MATCH) + { ins_h = window[strstart] & 0xff; ins_h = (((ins_h) << hash_shift) ^ (window[strstart + 1] & 0xff)) & hash_mask; } @@ -1240,19 +1358,23 @@ private void fill_window() { /// new strings in the dictionary only for unmatched strings or for short /// matches. It is used only for the fast compression options. /// - private int deflate_fast(int flush) { + private int deflate_fast(int flush) + { // short hash_head = 0; // head of the hash chain int hash_head = 0; // head of the hash chain bool bflush; // set if current block must be flushed - while (true) { + while (true) + { // Make sure that we always have enough lookahead, except // at the End of the input file. We need MAX_MATCH bytes // for the next match, plus MIN_MATCH bytes to insert the // string following the next match. - if (lookahead < MIN_LOOKAHEAD) { + if (lookahead < MIN_LOOKAHEAD) + { fill_window(); - if (lookahead < MIN_LOOKAHEAD && flush == (int)FlushStrategy.Z_NO_FLUSH) { + if (lookahead < MIN_LOOKAHEAD && flush == (int)FlushStrategy.Z_NO_FLUSH) + { return NeedMore; } if (lookahead == 0) @@ -1261,7 +1383,8 @@ private int deflate_fast(int flush) { // Insert the string Window[strstart .. strstart+2] in the // dictionary, and set hash_head to the head of the hash chain: - if (lookahead >= MIN_MATCH) { + if (lookahead >= MIN_MATCH) + { ins_h = (((ins_h) << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; // prev[strstart&w_mask]=hash_head=head[ins_h]; @@ -1273,16 +1396,19 @@ private int deflate_fast(int flush) { // Find the longest match, discarding those <= prev_length. // At this point we have always match_length < MIN_MATCH - if (hash_head != 0L && ((strstart - hash_head) & 0xffff) <= w_size - MIN_LOOKAHEAD) { + if (hash_head != 0L && ((strstart - hash_head) & 0xffff) <= w_size - MIN_LOOKAHEAD) + { // To simplify the code, we prevent matches with the string // of Window index 0 (in particular we have to avoid a match // of the string with itself at the start of the input file). - if (strategy != CompressionStrategy.Z_HUFFMAN_ONLY) { + if (strategy != CompressionStrategy.Z_HUFFMAN_ONLY) + { match_length = longest_match(hash_head); } // longest_match() sets match_start } - if (match_length >= MIN_MATCH) { + if (match_length >= MIN_MATCH) + { // check_match(strstart, match_start, match_length); bflush = _tr_tally(strstart - match_start, match_length - MIN_MATCH); @@ -1291,9 +1417,11 @@ private int deflate_fast(int flush) { // Insert new strings in the hash table only if the match length // is not too large. This saves time but degrades compression. - if (match_length <= max_lazy_match && lookahead >= MIN_MATCH) { + if (match_length <= max_lazy_match && lookahead >= MIN_MATCH) + { match_length--; // string at strstart already in hash table - do { + do + { strstart++; ins_h = ((ins_h << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; @@ -1307,7 +1435,9 @@ private int deflate_fast(int flush) { } while (--match_length != 0); strstart++; - } else { + } + else + { strstart += match_length; match_length = 0; ins_h = window[strstart] & 0xff; @@ -1316,14 +1446,17 @@ private int deflate_fast(int flush) { // If lookahead < MIN_MATCH, ins_h is garbage, but it does not // matter since it will be recomputed at next deflate call. } - } else { + } + else + { // No match, output a literal byte bflush = _tr_tally(0, window[strstart] & 0xff); lookahead--; strstart++; } - if (bflush) { + if (bflush) + { flush_block_only(false); if (strm.avail_out == 0) @@ -1332,7 +1465,8 @@ private int deflate_fast(int flush) { } flush_block_only(flush == (int)FlushStrategy.Z_FINISH); - if (strm.avail_out == 0) { + if (strm.avail_out == 0) + { if (flush == (int)FlushStrategy.Z_FINISH) return FinishStarted; else @@ -1346,21 +1480,25 @@ private int deflate_fast(int flush) { /// evaluation for matches: a match is finally adopted only if there is /// no better match at the next Window position. /// - private int deflate_slow(int flush) { + private int deflate_slow(int flush) + { // short hash_head = 0; // head of hash chain int hash_head = 0; // head of hash chain bool bflush; // set if current block must be flushed // Process the input block. - while (true) { + while (true) + { // Make sure that we always have enough lookahead, except // at the End of the input file. We need MAX_MATCH bytes // for the next match, plus MIN_MATCH bytes to insert the // string following the next match. - if (lookahead < MIN_LOOKAHEAD) { + if (lookahead < MIN_LOOKAHEAD) + { fill_window(); - if (lookahead < MIN_LOOKAHEAD && flush == (int)FlushStrategy.Z_NO_FLUSH) { + if (lookahead < MIN_LOOKAHEAD && flush == (int)FlushStrategy.Z_NO_FLUSH) + { return NeedMore; } if (lookahead == 0) @@ -1370,7 +1508,8 @@ private int deflate_slow(int flush) { // Insert the string Window[strstart .. strstart+2] in the // dictionary, and set hash_head to the head of the hash chain: - if (lookahead >= MIN_MATCH) { + if (lookahead >= MIN_MATCH) + { ins_h = (((ins_h) << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; // prev[strstart&w_mask]=hash_head=head[ins_h]; hash_head = (head[ins_h] & 0xffff); @@ -1382,17 +1521,20 @@ private int deflate_slow(int flush) { prev_length = match_length; prev_match = match_start; match_length = MIN_MATCH - 1; - if (hash_head != 0 && prev_length < max_lazy_match && ((strstart - hash_head) & 0xffff) <= w_size - MIN_LOOKAHEAD) { + if (hash_head != 0 && prev_length < max_lazy_match && ((strstart - hash_head) & 0xffff) <= w_size - MIN_LOOKAHEAD) + { // To simplify the code, we prevent matches with the string // of Window index 0 (in particular we have to avoid a match // of the string with itself at the start of the input file). - if (strategy != CompressionStrategy.Z_HUFFMAN_ONLY) { + if (strategy != CompressionStrategy.Z_HUFFMAN_ONLY) + { match_length = longest_match(hash_head); } // longest_match() sets match_start - if (match_length <= 5 && (strategy == CompressionStrategy.Z_FILTERED || (match_length == MIN_MATCH && strstart - match_start > 4096))) { + if (match_length <= 5 && (strategy == CompressionStrategy.Z_FILTERED || (match_length == MIN_MATCH && strstart - match_start > 4096))) + { // If prev_match is also MIN_MATCH, match_start is garbage // but we will ignore the current match anyway. @@ -1402,7 +1544,8 @@ private int deflate_slow(int flush) { // If there was a match at the previous step and the current // match is not better, output the previous match: - if (prev_length >= MIN_MATCH && match_length <= prev_length) { + if (prev_length >= MIN_MATCH && match_length <= prev_length) + { int max_insert = strstart + lookahead - MIN_MATCH; // Do not insert strings in hash table beyond this. @@ -1416,8 +1559,10 @@ private int deflate_slow(int flush) { // the hash table. lookahead -= (prev_length - 1); prev_length -= 2; - do { - if (++strstart <= max_insert) { + do + { + if (++strstart <= max_insert) + { ins_h = (((ins_h) << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; //prev[strstart&w_mask]=hash_head=head[ins_h]; hash_head = (head[ins_h] & 0xffff); @@ -1430,12 +1575,15 @@ private int deflate_slow(int flush) { match_length = MIN_MATCH - 1; strstart++; - if (bflush) { + if (bflush) + { flush_block_only(false); if (strm.avail_out == 0) return NeedMore; } - } else if (match_available != 0) { + } + else if (match_available != 0) + { // If there was no match at the previous position, output a // single literal. If there was a match but the current match @@ -1443,14 +1591,17 @@ private int deflate_slow(int flush) { bflush = _tr_tally(0, window[strstart - 1] & 0xff); - if (bflush) { + if (bflush) + { flush_block_only(false); } strstart++; lookahead--; if (strm.avail_out == 0) return NeedMore; - } else { + } + else + { // There is no previous match to compare with, wait for // the next step to decide. @@ -1460,13 +1611,15 @@ private int deflate_slow(int flush) { } } - if (match_available != 0) { + if (match_available != 0) + { bflush = _tr_tally(0, window[strstart - 1] & 0xff); match_available = 0; } flush_block_only(flush == (int)FlushStrategy.Z_FINISH); - if (strm.avail_out == 0) { + if (strm.avail_out == 0) + { if (flush == (int)FlushStrategy.Z_FINISH) return FinishStarted; @@ -1479,7 +1632,8 @@ private int deflate_slow(int flush) { /// /// Finds the longest matching data part /// - private int longest_match(int cur_match) { + private int longest_match(int cur_match) + { int chain_length = max_chain_length; // max hash chain length int scan = strstart; // current string int match; // matched string @@ -1501,7 +1655,8 @@ private int longest_match(int cur_match) { // It is easy to get rid of this optimization if necessary. // Do not waste too much time if we already have a good match: - if (prev_length >= good_match) { + if (prev_length >= good_match) + { chain_length >>= 2; } @@ -1510,7 +1665,8 @@ private int longest_match(int cur_match) { if (nice_match > lookahead) nice_match = lookahead; - do { + do + { match = cur_match; // Skip to next match if the match length cannot increase @@ -1527,14 +1683,16 @@ private int longest_match(int cur_match) { // We check for insufficient lookahead only every 8th comparison; // the 256th check will be made at strstart+258. - do { + do + { } while (window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && scan < strend); len = MAX_MATCH - (int)(strend - scan); scan = strend - MAX_MATCH; - if (len > best_len) { + if (len > best_len) + { match_start = cur_match; best_len = len; if (len >= nice_match) @@ -1557,7 +1715,8 @@ private int longest_match(int cur_match) { /// Compression level /// Window bits /// A result code - internal int DeflateInit(ZStream strm, int level, int bits) { + internal int DeflateInit(ZStream strm, int level, int bits) + { return DeflateInit2(strm, level, bits, DEF_MEM_LEVEL, CompressionStrategy.Z_DEFAULT_STRATEGY); } @@ -1567,7 +1726,8 @@ internal int DeflateInit(ZStream strm, int level, int bits) { /// ZStream object /// Compression level /// Operation result result code - internal int DeflateInit(ZStream strm, int level) { + internal int DeflateInit(ZStream strm, int level) + { return DeflateInit(strm, level, ZLibUtil.MAX_WBITS); } @@ -1580,7 +1740,8 @@ internal int DeflateInit(ZStream strm, int level) { /// Memory level /// Compression strategy /// Operation result code - internal int DeflateInit2(ZStream strm, int level, int windowBits, int memLevel, CompressionStrategy strategy) { + internal int DeflateInit2(ZStream strm, int level, int windowBits, int memLevel, CompressionStrategy strategy) + { int noheader = 0; strm.msg = null; @@ -1588,13 +1749,15 @@ internal int DeflateInit2(ZStream strm, int level, int windowBits, int memLevel, if (level == Z_DEFAULT_COMPRESSION) level = 6; - if (windowBits < 0) { + if (windowBits < 0) + { // undocumented feature: suppress zlib header noheader = 1; windowBits = -windowBits; } - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || windowBits < 9 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > CompressionStrategy.Z_HUFFMAN_ONLY) { + if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || windowBits < 9 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > CompressionStrategy.Z_HUFFMAN_ONLY) + { return (int)ZLibResultCode.Z_STREAM_ERROR; } @@ -1635,7 +1798,8 @@ internal int DeflateInit2(ZStream strm, int level, int windowBits, int memLevel, /// /// Resets the current state of deflate object /// - internal int deflateReset(ZStream strm) { + internal int deflateReset(ZStream strm) + { strm.total_in = strm.total_out = 0; strm.msg = null; // strm.Data_type = BlockType.Z_UNKNOWN; @@ -1643,7 +1807,8 @@ internal int deflateReset(ZStream strm) { Pending = 0; Pending_out = 0; - if (NoHeader < 0) { + if (NoHeader < 0) + { NoHeader = 0; // was set to -1 by deflate(..., Z_FINISH); } status = (NoHeader != 0) ? DeflateState.BUSY_STATE : DeflateState.INIT_STATE; @@ -1660,8 +1825,10 @@ internal int deflateReset(ZStream strm) { /// /// Finish compression with deflate algorithm /// - internal int deflateEnd() { - if (status != DeflateState.INIT_STATE && status != DeflateState.BUSY_STATE && status != DeflateState.FINISH_STATE) { + internal int deflateEnd() + { + if (status != DeflateState.INIT_STATE && status != DeflateState.BUSY_STATE && status != DeflateState.FINISH_STATE) + { return (int)ZLibResultCode.Z_STREAM_ERROR; } // Deallocate in reverse order of allocations: @@ -1676,22 +1843,27 @@ internal int deflateEnd() { /// /// Sets deflate algorithm parameters /// - internal int deflateParams(ZStream strm, int level, CompressionStrategy strategy) { + internal int deflateParams(ZStream strm, int level, CompressionStrategy strategy) + { int err = (int)ZLibResultCode.Z_OK; - if (level == Z_DEFAULT_COMPRESSION) { + if (level == Z_DEFAULT_COMPRESSION) + { level = 6; } - if (level < 0 || level > 9 || strategy < 0 || strategy > CompressionStrategy.Z_HUFFMAN_ONLY) { + if (level < 0 || level > 9 || strategy < 0 || strategy > CompressionStrategy.Z_HUFFMAN_ONLY) + { return (int)ZLibResultCode.Z_STREAM_ERROR; } - if (config_table[this.level].func != config_table[level].func && strm.total_in != 0) { + if (config_table[this.level].func != config_table[level].func && strm.total_in != 0) + { // Flush the last buffer: err = strm.deflate(FlushStrategy.Z_PARTIAL_FLUSH); } - if (this.level != level) { + if (this.level != level) + { this.level = level; max_lazy_match = config_table[this.level].max_lazy; good_match = config_table[this.level].good_length; @@ -1705,7 +1877,8 @@ internal int deflateParams(ZStream strm, int level, CompressionStrategy strategy /// /// Sets deflate dictionary /// - internal int deflateSetDictionary(ZStream strm, byte[] dictionary, int dictLength) { + internal int deflateSetDictionary(ZStream strm, byte[] dictionary, int dictLength) + { int length = dictLength; int index = 0; @@ -1716,7 +1889,8 @@ internal int deflateSetDictionary(ZStream strm, byte[] dictionary, int dictLengt if (length < MIN_MATCH) return (int)ZLibResultCode.Z_OK; - if (length > w_size - MIN_LOOKAHEAD) { + if (length > w_size - MIN_LOOKAHEAD) + { length = w_size - MIN_LOOKAHEAD; index = dictLength - length; // use the tail of the dictionary } @@ -1731,7 +1905,8 @@ internal int deflateSetDictionary(ZStream strm, byte[] dictionary, int dictLengt ins_h = window[0] & 0xff; ins_h = (((ins_h) << hash_shift) ^ (window[1] & 0xff)) & hash_mask; - for (int n = 0; n <= length - MIN_MATCH; n++) { + for (int n = 0; n <= length - MIN_MATCH; n++) + { ins_h = (((ins_h) << hash_shift) ^ (window[(n) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; prev[n & w_mask] = head[ins_h]; head[ins_h] = (short)n; @@ -1742,18 +1917,22 @@ internal int deflateSetDictionary(ZStream strm, byte[] dictionary, int dictLengt /// /// Performs data compression with the deflate algorithm /// - internal int deflate(ZStream strm, FlushStrategy f) { + internal int deflate(ZStream strm, FlushStrategy f) + { int internalFlush = (int)f; - if (internalFlush > (int)FlushStrategy.Z_FINISH || internalFlush < 0) { + if (internalFlush > (int)FlushStrategy.Z_FINISH || internalFlush < 0) + { return (int)ZLibResultCode.Z_STREAM_ERROR; } - if (strm.next_out == null || (strm.next_in == null && strm.avail_in != 0) || (status == DeflateState.FINISH_STATE && internalFlush != (int)FlushStrategy.Z_FINISH)) { + if (strm.next_out == null || (strm.next_in == null && strm.avail_in != 0) || (status == DeflateState.FINISH_STATE && internalFlush != (int)FlushStrategy.Z_FINISH)) + { strm.msg = ZLibUtil.z_errmsg[(int)ZLibResultCode.Z_NEED_DICT - ((int)ZLibResultCode.Z_STREAM_ERROR)]; return (int)ZLibResultCode.Z_STREAM_ERROR; } - if (strm.avail_out == 0) { + if (strm.avail_out == 0) + { strm.msg = ZLibUtil.z_errmsg[(int)ZLibResultCode.Z_NEED_DICT - ((int)ZLibResultCode.Z_BUF_ERROR)]; return (int)ZLibResultCode.Z_BUF_ERROR; } @@ -1763,7 +1942,8 @@ internal int deflate(ZStream strm, FlushStrategy f) { last_flush = internalFlush; // Write the zlib header - if (status == DeflateState.INIT_STATE) { + if (status == DeflateState.INIT_STATE) + { int header = (Z_DEFLATED + ((w_bits - 8) << 4)) << 8; int level_flags = (level > 0) ? ((level - 1) & 0xff) >> 1 : 0; @@ -1779,7 +1959,8 @@ internal int deflate(ZStream strm, FlushStrategy f) { // Save the adler32 of the preset dictionary: - if (strstart != 0) { + if (strstart != 0) + { putShortMSB((int)(ZLibUtil.URShift(strm.adler, 16))); putShortMSB((int)(strm.adler & 0xffff)); } @@ -1787,9 +1968,11 @@ internal int deflate(ZStream strm, FlushStrategy f) { } // Flush as much pending output as possible - if (Pending != 0) { + if (Pending != 0) + { strm.FlushPending(); - if (strm.avail_out == 0) { + if (strm.avail_out == 0) + { //System.out.println(" _avail_out==0"); // Since _avail_out is 0, deflate will be called again with // more output space, but possibly with both pending and @@ -1803,76 +1986,90 @@ internal int deflate(ZStream strm, FlushStrategy f) { // Make sure there is something to do and avoid duplicate consecutive // flushes. For repeated and useless calls with Z_FINISH, we keep // returning (int)ZLibResultCode.Z_STREAM_END instead of Z_BUFF_ERROR. - } else if (strm.avail_in == 0 && internalFlush <= old_flush && internalFlush != (int)FlushStrategy.Z_FINISH) { + } + else if (strm.avail_in == 0 && internalFlush <= old_flush && internalFlush != (int)FlushStrategy.Z_FINISH) + { strm.msg = ZLibUtil.z_errmsg[(int)ZLibResultCode.Z_NEED_DICT - ((int)ZLibResultCode.Z_BUF_ERROR)]; return (int)ZLibResultCode.Z_BUF_ERROR; } // User must not provide more input after the first FINISH: - if (status == DeflateState.FINISH_STATE && strm.avail_in != 0) { + if (status == DeflateState.FINISH_STATE && strm.avail_in != 0) + { strm.msg = ZLibUtil.z_errmsg[(int)ZLibResultCode.Z_NEED_DICT - ((int)ZLibResultCode.Z_BUF_ERROR)]; - return (int)ZLibResultCode.Z_BUF_ERROR; - } - - // Start a new block or continue the current one. - if (strm.avail_in != 0 || lookahead != 0 || (internalFlush != (int)FlushStrategy.Z_NO_FLUSH && status != DeflateState.FINISH_STATE)) { - int bstate = -1; - switch (config_table[level].func) { - - case STORED: - bstate = deflate_stored(internalFlush); - break; - - case FAST: - bstate = deflate_fast(internalFlush); - break; - - case SLOW: - bstate = deflate_slow(internalFlush); - break; - - default: - break; - - } - - if (bstate == FinishStarted || bstate == FinishDone) { - status = DeflateState.FINISH_STATE; - } - if (bstate == NeedMore || bstate == FinishStarted) { - if (strm.avail_out == 0) { - last_flush = -1; // avoid BUF_ERROR next call, see above - } - return (int)ZLibResultCode.Z_OK; - // If internalFlush != Z_NO_FLUSH && _avail_out == 0, the next call - // of deflate should use the same internalFlush parameter to make sure - // that the internalFlush is complete. So we don't have to output an - // empty block here, this will be done at next call. This also - // ensures that for a very small output buffer, we emit at most - // one empty block. - } - - if (bstate == BlockDone) { - if (internalFlush == (int)FlushStrategy.Z_PARTIAL_FLUSH) { - _tr_align(); - } else { - // FULL_FLUSH or SYNC_FLUSH - _tr_stored_block(0, 0, false); - // For a full internalFlush, this empty block will be recognized - // as a special marker by inflate_sync(). - if (internalFlush == (int)FlushStrategy.Z_FULL_FLUSH) { - for (int i = 0; i < hash_size; i++) - // forget history - head[i] = 0; - } - } - strm.FlushPending(); - if (strm.avail_out == 0) { - last_flush = -1; // avoid BUF_ERROR at next call, see above - return (int)ZLibResultCode.Z_OK; - } - } - } + return (int)ZLibResultCode.Z_BUF_ERROR; + } + + // Start a new block or continue the current one. + if (strm.avail_in != 0 || lookahead != 0 || (internalFlush != (int)FlushStrategy.Z_NO_FLUSH && status != DeflateState.FINISH_STATE)) + { + int bstate = - 1; + switch (config_table[level].func) + { + + case STORED: + bstate = deflate_stored(internalFlush); + break; + + case FAST: + bstate = deflate_fast(internalFlush); + break; + + case SLOW: + bstate = deflate_slow(internalFlush); + break; + + default: + break; + + } + + if (bstate == FinishStarted || bstate == FinishDone) + { + status = DeflateState.FINISH_STATE; + } + if (bstate == NeedMore || bstate == FinishStarted) + { + if (strm.avail_out == 0) + { + last_flush = -1; // avoid BUF_ERROR next call, see above + } + return (int)ZLibResultCode.Z_OK; + // If internalFlush != Z_NO_FLUSH && _avail_out == 0, the next call + // of deflate should use the same internalFlush parameter to make sure + // that the internalFlush is complete. So we don't have to output an + // empty block here, this will be done at next call. This also + // ensures that for a very small output buffer, we emit at most + // one empty block. + } + + if (bstate == BlockDone) + { + if (internalFlush == (int)FlushStrategy.Z_PARTIAL_FLUSH) + { + _tr_align(); + } + else + { + // FULL_FLUSH or SYNC_FLUSH + _tr_stored_block(0, 0, false); + // For a full internalFlush, this empty block will be recognized + // as a special marker by inflate_sync(). + if (internalFlush == (int)FlushStrategy.Z_FULL_FLUSH) + { + for (int i = 0; i < hash_size; i++) + // forget history + head[i] = 0; + } + } + strm.FlushPending(); + if (strm.avail_out == 0) + { + last_flush = -1; // avoid BUF_ERROR at next call, see above + return (int)ZLibResultCode.Z_OK; + } + } + } if (internalFlush != (int)FlushStrategy.Z_FINISH) return (int)ZLibResultCode.Z_OK; @@ -1880,13 +2077,13 @@ internal int deflate(ZStream strm, FlushStrategy f) { return (int)ZLibResultCode.Z_STREAM_END; // Write the zlib trailer (adler32) - putShortMSB((int)(ZLibUtil.URShift(strm.adler, 16))); - putShortMSB((int)(strm.adler & 0xffff)); + putShortMSB((int) (ZLibUtil.URShift(strm.adler, 16))); + putShortMSB((int) (strm.adler & 0xffff)); strm.FlushPending(); // If _avail_out is zero, the application will call deflate again // to internalFlush the rest. - NoHeader = -1; // WritePos the trailer only once! + NoHeader = - 1; // WritePos the trailer only once! return Pending != 0 ? (int)ZLibResultCode.Z_OK : (int)ZLibResultCode.Z_STREAM_END; } @@ -1895,7 +2092,8 @@ internal int deflate(ZStream strm, FlushStrategy f) { /// /// Static constructor initializes config_table /// - static Deflate() { + static Deflate() + { { config_table = new Config[10]; // good lazy nice chain @@ -1912,5 +2110,5 @@ static Deflate() { config_table[9] = new Config(32, 258, 258, 4096, SLOW); } } - } + } } diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/InfBlocks.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/InfBlocks.cs index 64f9fc02b..3283c3e38 100644 --- a/src/ipy/IronPython.Modules/zlib/zlib.net/InfBlocks.cs +++ b/src/ipy/IronPython.Modules/zlib/zlib.net/InfBlocks.cs @@ -43,9 +43,11 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ using System; -namespace ComponentAce.Compression.Libs.ZLib { +namespace ComponentAce.Compression.Libs.ZLib +{ - internal enum InflateBlockMode { + internal enum InflateBlockMode + { TYPE = 0, // get type bits (3, including End bit) LENS = 1, // get lengths for stored STORED = 2, // processing stored block @@ -58,7 +60,8 @@ internal enum InflateBlockMode { BAD = 9 // a data error--stuck here } - internal sealed class InfBlocks { + internal sealed class InfBlocks + { #region Fields private const int MANY = 1440; @@ -163,7 +166,8 @@ internal sealed class InfBlocks { #region Methods - internal InfBlocks(ZStream z, bool needCheck, int w) { + internal InfBlocks(ZStream z, bool needCheck, int w) + { hufts = new int[MANY * 3]; Window = new byte[w]; End = w; @@ -175,13 +179,16 @@ internal InfBlocks(ZStream z, bool needCheck, int w) { /// /// Resets this InfBlocks class instance /// - internal void reset(ZStream z, long[] c) { + internal void reset(ZStream z, long[] c) + { if (c != null) c[0] = check; - if (mode == InflateBlockMode.BTREE || mode == InflateBlockMode.DTREE) { + if (mode == InflateBlockMode.BTREE || mode == InflateBlockMode.DTREE) + { blens = null; } - if (mode == InflateBlockMode.CODES) { + if (mode == InflateBlockMode.CODES) + { codes.free(z); } mode = InflateBlockMode.TYPE; @@ -196,7 +203,8 @@ internal void reset(ZStream z, long[] c) { /// /// Block processing functions /// - internal int proc(ZStream z, int r) { + internal int proc(ZStream z, int r) + { int t; // temporary storage int b; // bit buffer int k; // bits in bit buffer @@ -214,15 +222,21 @@ internal int proc(ZStream z, int r) { } // process input based on current state - while (true) { - switch (mode) { + while (true) + { + switch (mode) + { case InflateBlockMode.TYPE: - while (k < (3)) { - if (n != 0) { + while (k < (3)) + { + if (n != 0) + { r = (int)ZLibResultCode.Z_OK; - } else { + } + else + { BitB = b; BitK = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; @@ -237,7 +251,8 @@ internal int proc(ZStream z, int r) { t = (int)(b & 7); last = t & 1; - switch (ZLibUtil.URShift(t, 1)) { + switch (ZLibUtil.URShift(t, 1)) + { case 0: // stored { @@ -259,7 +274,8 @@ internal int proc(ZStream z, int r) { InfTree.inflate_trees_fixed(bl, bd, tl, td, z); codes = new InfCodes(bl[0], bd[0], tl[0], td[0], z); - } { + } + { b = ZLibUtil.URShift(b, (3)); k -= (3); } @@ -291,10 +307,14 @@ internal int proc(ZStream z, int r) { case InflateBlockMode.LENS: - while (k < (32)) { - if (n != 0) { + while (k < (32)) + { + if (n != 0) + { r = (int)ZLibResultCode.Z_OK; - } else { + } + else + { BitB = b; BitK = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; @@ -307,7 +327,8 @@ internal int proc(ZStream z, int r) { k += 8; } - if (((ZLibUtil.URShift((~b), 16)) & 0xffff) != (b & 0xffff)) { + if (((ZLibUtil.URShift((~b), 16)) & 0xffff) != (b & 0xffff)) + { mode = InflateBlockMode.BAD; z.msg = "invalid stored block lengths"; r = (int)ZLibResultCode.Z_DATA_ERROR; @@ -323,25 +344,31 @@ internal int proc(ZStream z, int r) { break; case InflateBlockMode.STORED: - if (n == 0) { + if (n == 0) + { BitB = b; BitK = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; WritePos = q; return inflate_flush(z, r); } - if (m == 0) { - if (q == End && ReadPos != 0) { + if (m == 0) + { + if (q == End && ReadPos != 0) + { q = 0; m = (int)(q < ReadPos ? ReadPos - q - 1 : End - q); } - if (m == 0) { + if (m == 0) + { WritePos = q; r = inflate_flush(z, r); q = WritePos; m = (int)(q < ReadPos ? ReadPos - q - 1 : End - q); - if (q == End && ReadPos != 0) { + if (q == End && ReadPos != 0) + { q = 0; m = (int)(q < ReadPos ? ReadPos - q - 1 : End - q); } - if (m == 0) { + if (m == 0) + { BitB = b; BitK = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; WritePos = q; @@ -366,10 +393,14 @@ internal int proc(ZStream z, int r) { case InflateBlockMode.TABLE: - while (k < (14)) { - if (n != 0) { + while (k < (14)) + { + if (n != 0) + { r = (int)ZLibResultCode.Z_OK; - } else { + } + else + { BitB = b; BitK = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; @@ -383,7 +414,8 @@ internal int proc(ZStream z, int r) { } table = t = (b & 0x3fff); - if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) { + if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) + { mode = InflateBlockMode.BAD; z.msg = "too many length or distance symbols"; r = (int)ZLibResultCode.Z_DATA_ERROR; @@ -394,7 +426,8 @@ internal int proc(ZStream z, int r) { return inflate_flush(z, r); } t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); - blens = new int[t]; { + blens = new int[t]; + { b = ZLibUtil.URShift(b, (14)); k -= (14); } @@ -403,11 +436,16 @@ internal int proc(ZStream z, int r) { goto case InflateBlockMode.BTREE; case InflateBlockMode.BTREE: - while (index < 4 + (ZLibUtil.URShift(table, 10))) { - while (k < (3)) { - if (n != 0) { + while (index < 4 + (ZLibUtil.URShift(table, 10))) + { + while (k < (3)) + { + if (n != 0) + { r = (int)ZLibResultCode.Z_OK; - } else { + } + else + { BitB = b; BitK = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; @@ -427,15 +465,18 @@ internal int proc(ZStream z, int r) { } } - while (index < 19) { + while (index < 19) + { blens[ZLibUtil.border[index++]] = 0; } bb[0] = 7; t = InfTree.inflate_trees_bits(blens, bb, tb, hufts, z); - if (t != (int)ZLibResultCode.Z_OK) { + if (t != (int)ZLibResultCode.Z_OK) + { r = t; - if (r == (int)ZLibResultCode.Z_DATA_ERROR) { + if (r == (int)ZLibResultCode.Z_DATA_ERROR) + { blens = null; mode = InflateBlockMode.BAD; } @@ -451,9 +492,11 @@ internal int proc(ZStream z, int r) { goto case InflateBlockMode.DTREE; case InflateBlockMode.DTREE: - while (true) { + while (true) + { t = table; - if (!(index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))) { + if (!(index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))) + { break; } @@ -462,10 +505,14 @@ internal int proc(ZStream z, int r) { t = bb[0]; - while (k < (t)) { - if (n != 0) { + while (k < (t)) + { + if (n != 0) + { r = (int)ZLibResultCode.Z_OK; - } else { + } + else + { BitB = b; BitK = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; @@ -481,18 +528,25 @@ internal int proc(ZStream z, int r) { t = hufts[(tb[0] + (b & ZLibUtil.inflate_mask[t])) * 3 + 1]; c = hufts[(tb[0] + (b & ZLibUtil.inflate_mask[t])) * 3 + 2]; - if (c < 16) { + if (c < 16) + { b = ZLibUtil.URShift(b, (t)); k -= (t); blens[index++] = c; - } else { + } + else + { // c == 16..18 i = c == 18 ? 7 : c - 14; j = c == 18 ? 11 : 3; - while (k < (t + i)) { - if (n != 0) { + while (k < (t + i)) + { + if (n != 0) + { r = (int)ZLibResultCode.Z_OK; - } else { + } + else + { BitB = b; BitK = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; @@ -513,7 +567,8 @@ internal int proc(ZStream z, int r) { i = index; t = table; - if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || (c == 16 && i < 1)) { + if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || (c == 16 && i < 1)) + { blens = null; mode = InflateBlockMode.BAD; z.msg = "invalid bit length repeat"; @@ -526,7 +581,8 @@ internal int proc(ZStream z, int r) { } c = c == 16 ? blens[i - 1] : 0; - do { + do + { blens[i++] = c; } while (--j != 0); @@ -534,7 +590,8 @@ internal int proc(ZStream z, int r) { } } - tb[0] = -1; { + tb[0] = -1; + { int[] bl = new int[1]; int[] bd = new int[1]; int[] tl = new int[1]; @@ -545,8 +602,10 @@ internal int proc(ZStream z, int r) { bd[0] = 6; // must be <= 9 for lookahead assumptions t = table; t = InfTree.inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), blens, bl, bd, tl, td, hufts, z); - if (t != (int)ZLibResultCode.Z_OK) { - if (t == (int)ZLibResultCode.Z_DATA_ERROR) { + if (t != (int)ZLibResultCode.Z_OK) + { + if (t == (int)ZLibResultCode.Z_DATA_ERROR) + { blens = null; mode = InflateBlockMode.BAD; } @@ -569,7 +628,8 @@ internal int proc(ZStream z, int r) { z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; WritePos = q; - if ((r = codes.proc(this, z, r)) != (int)ZLibResultCode.Z_STREAM_END) { + if ((r = codes.proc(this, z, r)) != (int)ZLibResultCode.Z_STREAM_END) + { return inflate_flush(z, r); } r = (int)ZLibResultCode.Z_OK; @@ -578,7 +638,8 @@ internal int proc(ZStream z, int r) { p = z.next_in_index; n = z.avail_in; b = BitB; k = BitK; q = WritePos; m = (int)(q < ReadPos ? ReadPos - q - 1 : End - q); - if (last == 0) { + if (last == 0) + { mode = InflateBlockMode.TYPE; break; } @@ -589,7 +650,8 @@ internal int proc(ZStream z, int r) { WritePos = q; r = inflate_flush(z, r); q = WritePos; m = (int)(q < ReadPos ? ReadPos - q - 1 : End - q); - if (ReadPos != WritePos) { + if (ReadPos != WritePos) + { BitB = b; BitK = k; z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; WritePos = q; @@ -630,7 +692,8 @@ internal int proc(ZStream z, int r) { /// /// Frees inner buffers /// - internal void free(ZStream z) { + internal void free(ZStream z) + { reset(z, null); Window = null; hufts = null; @@ -641,7 +704,8 @@ internal void free(ZStream z) { /// Sets dictionary /// - internal void set_dictionary(byte[] d, int start, int n) { + internal void set_dictionary(byte[] d, int start, int n) + { Array.Copy(d, start, Window, 0, n); ReadPos = WritePos = n; } @@ -650,72 +714,75 @@ internal void set_dictionary(byte[] d, int start, int n) { /// Returns true if inflate is currently at the End of a block generated /// by Z_SYNC_FLUSH or Z_FULL_FLUSH. /// - internal int sync_point() { + internal int sync_point() + { return mode == InflateBlockMode.LENS ? 1 : 0; } /// /// copy as much as possible from the sliding Window to the output area /// - internal int inflate_flush(ZStream z, int r) { - // local copies of source and destination pointers - int p = z.next_out_index; - int q = ReadPos; - - // compute number of bytes to copy as far as End of Window - int n = (int)((q <= WritePos ? WritePos : End) - q); - if (n > z.avail_out) - n = z.avail_out; - if (n != 0 && r == (int)ZLibResultCode.Z_BUF_ERROR) - r = (int)ZLibResultCode.Z_OK; - - // update counters - z.avail_out -= n; - z.total_out += n; - - // update check information - if (needCheck) - z.adler = check = Adler32.GetAdler32Checksum(check, Window, q, n); - - // copy as far as End of Window - Array.Copy(Window, q, z.next_out, p, n); - p += n; - q += n; - - // see if more to copy at beginning of Window - if (q == End) { - // wrap pointers - q = 0; - if (WritePos == End) - WritePos = 0; - - // compute bytes to copy - n = WritePos - q; - if (n > z.avail_out) - n = z.avail_out; - if (n != 0 && r == (int)ZLibResultCode.Z_BUF_ERROR) - r = (int)ZLibResultCode.Z_OK; - - // update counters - z.avail_out -= n; - z.total_out += n; - - // update check information - if (needCheck) - z.adler = check = Adler32.GetAdler32Checksum(check, Window, q, n); - - // copy - Array.Copy(Window, q, z.next_out, p, n); - p += n; - q += n; - } - - // update pointers - z.next_out_index = p; - ReadPos = q; - - // done - return r; + internal int inflate_flush(ZStream z, int r) + { + // local copies of source and destination pointers + int p = z.next_out_index; + int q = ReadPos; + + // compute number of bytes to copy as far as End of Window + int n = (int) ((q <= WritePos?WritePos:End) - q); + if (n > z.avail_out) + n = z.avail_out; + if (n != 0 && r == (int)ZLibResultCode.Z_BUF_ERROR) + r = (int)ZLibResultCode.Z_OK; + + // update counters + z.avail_out -= n; + z.total_out += n; + + // update check information + if (needCheck) + z.adler = check = Adler32.GetAdler32Checksum(check, Window, q, n); + + // copy as far as End of Window + Array.Copy(Window, q, z.next_out, p, n); + p += n; + q += n; + + // see if more to copy at beginning of Window + if (q == End) + { + // wrap pointers + q = 0; + if (WritePos == End) + WritePos = 0; + + // compute bytes to copy + n = WritePos - q; + if (n > z.avail_out) + n = z.avail_out; + if (n != 0 && r == (int)ZLibResultCode.Z_BUF_ERROR) + r = (int)ZLibResultCode.Z_OK; + + // update counters + z.avail_out -= n; + z.total_out += n; + + // update check information + if (needCheck) + z.adler = check = Adler32.GetAdler32Checksum(check, Window, q, n); + + // copy + Array.Copy(Window, q, z.next_out, p, n); + p += n; + q += n; + } + + // update pointers + z.next_out_index = p; + ReadPos = q; + + // done + return r; } #endregion diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/InfCodes.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/InfCodes.cs index 79b7a371c..78700fcf8 100644 --- a/src/ipy/IronPython.Modules/zlib/zlib.net/InfCodes.cs +++ b/src/ipy/IronPython.Modules/zlib/zlib.net/InfCodes.cs @@ -43,29 +43,32 @@ EVEN IF ADVISED OF THE POSSIBI InflateCodesMode.LITY OF SUCH DAMAGE. */ using System; -namespace ComponentAce.Compression.Libs.ZLib { +namespace ComponentAce.Compression.Libs.ZLib +{ /// /// Inflate codes mode /// - internal enum InflateCodesMode { - START = 0, // x: set up for InflateCodesMode.LEN - LEN = 1, // i: get length/literal/eob next - LENEXT = 2, // i: getting length extra (have base) - DIST = 3, // i: get distance next - DISTEXT = 4, // i: getting distance extra - COPY = 5, // o: copying bytes in Window, waiting for space - LIT = 6, // o: got literal, waiting for output space - WASH = 7, // o: got eob, possibly still output waiting - END = 8, // x: got eob and all data flushed - BADCODE = 9 // x: got error + internal enum InflateCodesMode + { + START = 0, // x: set up for InflateCodesMode.LEN + LEN = 1, // i: get length/literal/eob next + LENEXT = 2, // i: getting length extra (have base) + DIST = 3, // i: get distance next + DISTEXT = 4, // i: getting distance extra + COPY = 5, // o: copying bytes in Window, waiting for space + LIT = 6, // o: got literal, waiting for output space + WASH = 7, // o: got eob, possibly still output waiting + END = 8, // x: got eob and all data flushed + BADCODE = 9 // x: got error } /// /// This class is used by the InfBlocks class /// - internal sealed class InfCodes { - + internal sealed class InfCodes + { + #region Fields /// @@ -139,563 +142,635 @@ internal sealed class InfCodes { /// /// Constructor which takes literal, distance trees, corresponding bites decoded for branches, corresponding indexes and a ZStream object /// - internal InfCodes(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, ZStream z) { - mode = InflateCodesMode.START; - lbits = (byte)bl; - dbits = (byte)bd; - ltree = tl; - ltree_index = tl_index; - dtree = td; - dtree_index = td_index; - } + internal InfCodes(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, ZStream z) + { + mode = InflateCodesMode.START; + lbits = (byte) bl; + dbits = (byte) bd; + ltree = tl; + ltree_index = tl_index; + dtree = td; + dtree_index = td_index; + } /// /// Constructor which takes literal, distance trees, corresponding bites decoded for branches and a ZStream object /// - internal InfCodes(int bl, int bd, int[] tl, int[] td, ZStream z) { - mode = InflateCodesMode.START; - lbits = (byte)bl; - dbits = (byte)bd; - ltree = tl; - ltree_index = 0; - dtree = td; - dtree_index = 0; - } - + internal InfCodes(int bl, int bd, int[] tl, int[] td, ZStream z) + { + mode = InflateCodesMode.START; + lbits = (byte) bl; + dbits = (byte) bd; + ltree = tl; + ltree_index = 0; + dtree = td; + dtree_index = 0; + } + /// /// Block processing method /// /// An instance of the InfBlocks class /// A ZStream object /// A result code - internal int proc(InfBlocks s, ZStream z, int r) { - int j; // temporary storage - //int[] t; // temporary pointer - int tindex; // temporary pointer - int e; // extra bits or operation - int b = 0; // bit buffer - int k = 0; // bits in bit buffer - int p = 0; // input data pointer - int n; // bytes available there - int q; // output Window WritePos pointer - int m; // bytes to End of Window or ReadPos pointer - int f; // pointer to copy strings from - - // copy input/output information to locals (UPDATE macro restores) - p = z.next_in_index; n = z.avail_in; b = s.BitB; k = s.BitK; - q = s.WritePos; m = q < s.ReadPos ? s.ReadPos - q - 1 : s.End - q; - - // process input and output based on current state - while (true) { - switch (mode) { - - // waiting for "i:"=input, "o:"=output, "x:"=nothing - case InflateCodesMode.START: // x: set up for InflateCodesMode.LEN - if (m >= 258 && n >= 10) { - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - r = inflate_fast(lbits, dbits, ltree, ltree_index, dtree, dtree_index, s, z); - - p = z.next_in_index; n = z.avail_in; b = s.BitB; k = s.BitK; - q = s.WritePos; m = q < s.ReadPos ? s.ReadPos - q - 1 : s.End - q; - - if (r != (int)ZLibResultCode.Z_OK) { - mode = r == (int)ZLibResultCode.Z_STREAM_END ? InflateCodesMode.WASH : InflateCodesMode.BADCODE; - break; - } - } - need = lbits; - tree = ltree; - tree_index = ltree_index; - - mode = InflateCodesMode.LEN; - goto case InflateCodesMode.LEN; - - case InflateCodesMode.LEN: // i: get length/literal/eob next - j = need; - - while (k < (j)) { - if (n != 0) - r = (int)ZLibResultCode.Z_OK; - else { - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - } - n--; - b |= (z.next_in[p++] & 0xff) << k; - k += 8; - } - - tindex = (tree_index + (b & ZLibUtil.inflate_mask[j])) * 3; - - b = ZLibUtil.URShift(b, (tree[tindex + 1])); - k -= (tree[tindex + 1]); - - e = tree[tindex]; - - if (e == 0) { - // literal - lit = tree[tindex + 2]; - mode = InflateCodesMode.LIT; - break; - } - if ((e & 16) != 0) { - // length - get_Renamed = e & 15; - count = tree[tindex + 2]; - mode = InflateCodesMode.LENEXT; - break; - } - if ((e & 64) == 0) { - // next table - need = e; - tree_index = tindex / 3 + tree[tindex + 2]; - break; - } - if ((e & 32) != 0) { - // End of block - mode = InflateCodesMode.WASH; - break; - } - mode = InflateCodesMode.BADCODE; // invalid code - z.msg = "invalid literal/length code"; - r = (int)ZLibResultCode.Z_DATA_ERROR; - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - - - case InflateCodesMode.LENEXT: // i: getting length extra (have base) - j = get_Renamed; - - while (k < (j)) { - if (n != 0) - r = (int)ZLibResultCode.Z_OK; - else { - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - } - n--; b |= (z.next_in[p++] & 0xff) << k; - k += 8; - } - - count += (b & ZLibUtil.inflate_mask[j]); - - b >>= j; - k -= j; - - need = dbits; - tree = dtree; - tree_index = dtree_index; - mode = InflateCodesMode.DIST; - goto case InflateCodesMode.DIST; - - case InflateCodesMode.DIST: // i: get distance next - j = need; - - while (k < (j)) { - if (n != 0) - r = (int)ZLibResultCode.Z_OK; - else { - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - } - n--; b |= (z.next_in[p++] & 0xff) << k; - k += 8; - } - - tindex = (tree_index + (b & ZLibUtil.inflate_mask[j])) * 3; - - b >>= tree[tindex + 1]; - k -= tree[tindex + 1]; - - e = (tree[tindex]); - if ((e & 16) != 0) { - // distance - get_Renamed = e & 15; - dist = tree[tindex + 2]; - mode = InflateCodesMode.DISTEXT; - break; - } - if ((e & 64) == 0) { - // next table - need = e; - tree_index = tindex / 3 + tree[tindex + 2]; - break; - } - mode = InflateCodesMode.BADCODE; // invalid code - z.msg = "invalid distance code"; - r = (int)ZLibResultCode.Z_DATA_ERROR; - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - - - case InflateCodesMode.DISTEXT: // i: getting distance extra - j = get_Renamed; - - while (k < (j)) { - if (n != 0) - r = (int)ZLibResultCode.Z_OK; - else { - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - } - n--; b |= (z.next_in[p++] & 0xff) << k; - k += 8; - } - - dist += (b & ZLibUtil.inflate_mask[j]); - - b >>= j; - k -= j; - - mode = InflateCodesMode.COPY; - goto case InflateCodesMode.COPY; - - case InflateCodesMode.COPY: // o: copying bytes in Window, waiting for space - f = q - dist; - while (f < 0) { - // modulo Window size-"while" instead - f += s.End; // of "if" handles invalid distances - } - while (count != 0) { - - if (m == 0) { - if (q == s.End && s.ReadPos != 0) { - q = 0; m = q < s.ReadPos ? s.ReadPos - q - 1 : s.End - q; - } - if (m == 0) { - s.WritePos = q; r = s.inflate_flush(z, r); - q = s.WritePos; m = q < s.ReadPos ? s.ReadPos - q - 1 : s.End - q; - - if (q == s.End && s.ReadPos != 0) { - q = 0; m = q < s.ReadPos ? s.ReadPos - q - 1 : s.End - q; - } - - if (m == 0) { - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - } - } - } - - s.Window[q++] = s.Window[f++]; m--; - - if (f == s.End) - f = 0; - count--; - } - mode = InflateCodesMode.START; - break; - - case InflateCodesMode.LIT: // o: got literal, waiting for output space - if (m == 0) { - if (q == s.End && s.ReadPos != 0) { - q = 0; m = q < s.ReadPos ? s.ReadPos - q - 1 : s.End - q; - } - if (m == 0) { - s.WritePos = q; r = s.inflate_flush(z, r); - q = s.WritePos; m = q < s.ReadPos ? s.ReadPos - q - 1 : s.End - q; - - if (q == s.End && s.ReadPos != 0) { - q = 0; m = q < s.ReadPos ? s.ReadPos - q - 1 : s.End - q; - } - if (m == 0) { - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - } - } - } - r = (int)ZLibResultCode.Z_OK; - - s.Window[q++] = (byte)lit; m--; - - mode = InflateCodesMode.START; - break; - - case InflateCodesMode.WASH: // o: got eob, possibly more output - if (k > 7) { - // return unused byte, if any - k -= 8; - n++; - p--; // can always return one - } - - s.WritePos = q; r = s.inflate_flush(z, r); - q = s.WritePos; m = q < s.ReadPos ? s.ReadPos - q - 1 : s.End - q; - - if (s.ReadPos != s.WritePos) { - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - } - mode = InflateCodesMode.END; - goto case InflateCodesMode.END; - - case InflateCodesMode.END: - r = (int)ZLibResultCode.Z_STREAM_END; - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - - - case InflateCodesMode.BADCODE: // x: got error - - r = (int)ZLibResultCode.Z_DATA_ERROR; - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - - - default: - r = (int)ZLibResultCode.Z_STREAM_ERROR; - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - return s.inflate_flush(z, r); - - } - } - } - + internal int proc(InfBlocks s, ZStream z, int r) + { + int j; // temporary storage + //int[] t; // temporary pointer + int tindex; // temporary pointer + int e; // extra bits or operation + int b = 0; // bit buffer + int k = 0; // bits in bit buffer + int p = 0; // input data pointer + int n; // bytes available there + int q; // output Window WritePos pointer + int m; // bytes to End of Window or ReadPos pointer + int f; // pointer to copy strings from + + // copy input/output information to locals (UPDATE macro restores) + p = z.next_in_index; n = z.avail_in; b = s.BitB; k = s.BitK; + q = s.WritePos; m = q < s.ReadPos?s.ReadPos - q - 1:s.End - q; + + // process input and output based on current state + while (true) + { + switch (mode) + { + + // waiting for "i:"=input, "o:"=output, "x:"=nothing + case InflateCodesMode.START: // x: set up for InflateCodesMode.LEN + if (m >= 258 && n >= 10) + { + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + r = inflate_fast(lbits, dbits, ltree, ltree_index, dtree, dtree_index, s, z); + + p = z.next_in_index; n = z.avail_in; b = s.BitB; k = s.BitK; + q = s.WritePos; m = q < s.ReadPos?s.ReadPos - q - 1:s.End - q; + + if (r != (int)ZLibResultCode.Z_OK) + { + mode = r == (int)ZLibResultCode.Z_STREAM_END? InflateCodesMode.WASH: InflateCodesMode.BADCODE; + break; + } + } + need = lbits; + tree = ltree; + tree_index = ltree_index; + + mode = InflateCodesMode.LEN; + goto case InflateCodesMode.LEN; + + case InflateCodesMode.LEN: // i: get length/literal/eob next + j = need; + + while (k < (j)) + { + if (n != 0) + r = (int)ZLibResultCode.Z_OK; + else + { + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + } + n--; + b |= (z.next_in[p++] & 0xff) << k; + k += 8; + } + + tindex = (tree_index + (b & ZLibUtil.inflate_mask[j])) * 3; + + b = ZLibUtil.URShift(b, (tree[tindex + 1])); + k -= (tree[tindex + 1]); + + e = tree[tindex]; + + if (e == 0) + { + // literal + lit = tree[tindex + 2]; + mode = InflateCodesMode.LIT; + break; + } + if ((e & 16) != 0) + { + // length + get_Renamed = e & 15; + count = tree[tindex + 2]; + mode = InflateCodesMode.LENEXT; + break; + } + if ((e & 64) == 0) + { + // next table + need = e; + tree_index = tindex / 3 + tree[tindex + 2]; + break; + } + if ((e & 32) != 0) + { + // End of block + mode = InflateCodesMode.WASH; + break; + } + mode = InflateCodesMode.BADCODE; // invalid code + z.msg = "invalid literal/length code"; + r = (int)ZLibResultCode.Z_DATA_ERROR; + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + + + case InflateCodesMode.LENEXT: // i: getting length extra (have base) + j = get_Renamed; + + while (k < (j)) + { + if (n != 0) + r = (int)ZLibResultCode.Z_OK; + else + { + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + } + n--; b |= (z.next_in[p++] & 0xff) << k; + k += 8; + } + + count += (b & ZLibUtil.inflate_mask[j]); + + b >>= j; + k -= j; + + need = dbits; + tree = dtree; + tree_index = dtree_index; + mode = InflateCodesMode.DIST; + goto case InflateCodesMode.DIST; + + case InflateCodesMode.DIST: // i: get distance next + j = need; + + while (k < (j)) + { + if (n != 0) + r = (int)ZLibResultCode.Z_OK; + else + { + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + } + n--; b |= (z.next_in[p++] & 0xff) << k; + k += 8; + } + + tindex = (tree_index + (b & ZLibUtil.inflate_mask[j])) * 3; + + b >>= tree[tindex + 1]; + k -= tree[tindex + 1]; + + e = (tree[tindex]); + if ((e & 16) != 0) + { + // distance + get_Renamed = e & 15; + dist = tree[tindex + 2]; + mode = InflateCodesMode.DISTEXT; + break; + } + if ((e & 64) == 0) + { + // next table + need = e; + tree_index = tindex / 3 + tree[tindex + 2]; + break; + } + mode = InflateCodesMode.BADCODE; // invalid code + z.msg = "invalid distance code"; + r = (int)ZLibResultCode.Z_DATA_ERROR; + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + + + case InflateCodesMode.DISTEXT: // i: getting distance extra + j = get_Renamed; + + while (k < (j)) + { + if (n != 0) + r = (int)ZLibResultCode.Z_OK; + else + { + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + } + n--; b |= (z.next_in[p++] & 0xff) << k; + k += 8; + } + + dist += (b & ZLibUtil.inflate_mask[j]); + + b >>= j; + k -= j; + + mode = InflateCodesMode.COPY; + goto case InflateCodesMode.COPY; + + case InflateCodesMode.COPY: // o: copying bytes in Window, waiting for space + f = q - dist; + while (f < 0) + { + // modulo Window size-"while" instead + f += s.End; // of "if" handles invalid distances + } + while (count != 0) + { + + if (m == 0) + { + if (q == s.End && s.ReadPos != 0) + { + q = 0; m = q < s.ReadPos?s.ReadPos - q - 1:s.End - q; + } + if (m == 0) + { + s.WritePos = q; r = s.inflate_flush(z, r); + q = s.WritePos; m = q < s.ReadPos?s.ReadPos - q - 1:s.End - q; + + if (q == s.End && s.ReadPos != 0) + { + q = 0; m = q < s.ReadPos?s.ReadPos - q - 1:s.End - q; + } + + if (m == 0) + { + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + } + } + } + + s.Window[q++] = s.Window[f++]; m--; + + if (f == s.End) + f = 0; + count--; + } + mode = InflateCodesMode.START; + break; + + case InflateCodesMode.LIT: // o: got literal, waiting for output space + if (m == 0) + { + if (q == s.End && s.ReadPos != 0) + { + q = 0; m = q < s.ReadPos?s.ReadPos - q - 1:s.End - q; + } + if (m == 0) + { + s.WritePos = q; r = s.inflate_flush(z, r); + q = s.WritePos; m = q < s.ReadPos?s.ReadPos - q - 1:s.End - q; + + if (q == s.End && s.ReadPos != 0) + { + q = 0; m = q < s.ReadPos?s.ReadPos - q - 1:s.End - q; + } + if (m == 0) + { + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + } + } + } + r = (int)ZLibResultCode.Z_OK; + + s.Window[q++] = (byte) lit; m--; + + mode = InflateCodesMode.START; + break; + + case InflateCodesMode.WASH: // o: got eob, possibly more output + if (k > 7) + { + // return unused byte, if any + k -= 8; + n++; + p--; // can always return one + } + + s.WritePos = q; r = s.inflate_flush(z, r); + q = s.WritePos; m = q < s.ReadPos?s.ReadPos - q - 1:s.End - q; + + if (s.ReadPos != s.WritePos) + { + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + } + mode = InflateCodesMode.END; + goto case InflateCodesMode.END; + + case InflateCodesMode.END: + r = (int)ZLibResultCode.Z_STREAM_END; + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + + + case InflateCodesMode.BADCODE: // x: got error + + r = (int)ZLibResultCode.Z_DATA_ERROR; + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + + + default: + r = (int)ZLibResultCode.Z_STREAM_ERROR; + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + return s.inflate_flush(z, r); + + } + } + } + /// /// Frees allocated resources /// - internal void free(ZStream z) { - } + internal void free(ZStream z) + { + } + - - /// + /// /// Fast inflate procedure. Called with number of bytes left to WritePos in Window at least 258 /// (the maximum string length) and number of input bytes available /// at least ten. The ten bytes are six bytes for the longest length/ /// distance pair plus four bytes for overloading the bit buffer. - /// - internal int inflate_fast(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, InfBlocks s, ZStream z) { - int t; // temporary pointer - int[] tp; // temporary pointer - int tp_index; // temporary pointer - int e; // extra bits or operation - int b; // bit buffer - int k; // bits in bit buffer - int p; // input data pointer - int n; // bytes available there - int q; // output Window WritePos pointer - int m; // bytes to End of Window or ReadPos pointer - int ml; // mask for literal/length tree - int md; // mask for distance tree - int c; // bytes to copy - int d; // distance back to copy from - int r; // copy source pointer - - // load input, output, bit values - p = z.next_in_index; n = z.avail_in; b = s.BitB; k = s.BitK; - q = s.WritePos; m = q < s.ReadPos ? s.ReadPos - q - 1 : s.End - q; - - // initialize masks - ml = ZLibUtil.inflate_mask[bl]; - md = ZLibUtil.inflate_mask[bd]; - - // do until not enough input or output space for fast loop - do { - // assume called with m >= 258 && n >= 10 - // get literal/length code - while (k < (20)) { - // max bits for literal/length code - n--; - b |= (z.next_in[p++] & 0xff) << k; k += 8; - } - - t = b & ml; - tp = tl; - tp_index = tl_index; - if ((e = tp[(tp_index + t) * 3]) == 0) { - b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]); - - s.Window[q++] = (byte)tp[(tp_index + t) * 3 + 2]; - m--; - continue; - } - do { - - b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]); - - if ((e & 16) != 0) { - e &= 15; - c = tp[(tp_index + t) * 3 + 2] + ((int)b & ZLibUtil.inflate_mask[e]); - - b >>= e; k -= e; - - // decode distance base of block to copy - while (k < (15)) { - // max bits for distance code - n--; - b |= (z.next_in[p++] & 0xff) << k; k += 8; - } - - t = b & md; - tp = td; - tp_index = td_index; - e = tp[(tp_index + t) * 3]; - - do { - - b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]); - - if ((e & 16) != 0) { - // get extra bits to add to distance base - e &= 15; - while (k < (e)) { - // get extra bits (up to 13) - n--; - b |= (z.next_in[p++] & 0xff) << k; k += 8; - } - - d = tp[(tp_index + t) * 3 + 2] + (b & ZLibUtil.inflate_mask[e]); - - b >>= (e); k -= (e); - - // do the copy - m -= c; - if (q >= d) { - // offset before dest - // just copy - r = q - d; - if (q - r > 0 && 2 > (q - r)) { - s.Window[q++] = s.Window[r++]; c--; // minimum count is three, - s.Window[q++] = s.Window[r++]; c--; // so unroll loop a little - } else { - Array.Copy(s.Window, r, s.Window, q, 2); - q += 2; r += 2; c -= 2; - } - } else { - // else offset after destination - r = q - d; - do { - r += s.End; // force pointer in Window - } - while (r < 0); // covers invalid distances - e = s.End - r; - if (c > e) { - // if source crosses, - c -= e; // wrapped copy - if (q - r > 0 && e > (q - r)) { - do { - s.Window[q++] = s.Window[r++]; - } - while (--e != 0); - } else { - Array.Copy(s.Window, r, s.Window, q, e); - q += e; r += e; e = 0; - } - r = 0; // copy rest from start of Window - } - } - - // copy all or what's left - if (q - r > 0 && c > (q - r)) { - do { - s.Window[q++] = s.Window[r++]; - } - while (--c != 0); - } else { - Array.Copy(s.Window, r, s.Window, q, c); - q += c; r += c; c = 0; - } - break; - } else if ((e & 64) == 0) { - t += tp[(tp_index + t) * 3 + 2]; - t += (b & ZLibUtil.inflate_mask[e]); - e = tp[(tp_index + t) * 3]; - } else { - z.msg = "invalid distance code"; - - c = z.avail_in - n; c = (k >> 3) < c ? k >> 3 : c; n += c; p -= c; k -= (c << 3); - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - - return (int)ZLibResultCode.Z_DATA_ERROR; - } - } - while (true); - break; - } - - if ((e & 64) == 0) { - t += tp[(tp_index + t) * 3 + 2]; - t += (b & ZLibUtil.inflate_mask[e]); - if ((e = tp[(tp_index + t) * 3]) == 0) { - - b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]); - - s.Window[q++] = (byte)tp[(tp_index + t) * 3 + 2]; - m--; - break; - } - } else if ((e & 32) != 0) { - - c = z.avail_in - n; c = (k >> 3) < c ? k >> 3 : c; n += c; p -= c; k -= (c << 3); - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - - return (int)ZLibResultCode.Z_STREAM_END; - } else { - z.msg = "invalid literal/length code"; - - c = z.avail_in - n; c = (k >> 3) < c ? k >> 3 : c; n += c; p -= c; k -= (c << 3); - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - - return (int)ZLibResultCode.Z_DATA_ERROR; - } - } - while (true); - } - while (m >= 258 && n >= 10); - - // not enough input or output--restore pointers and return - c = z.avail_in - n; c = (k >> 3) < c ? k >> 3 : c; n += c; p -= c; k -= (c << 3); - - s.BitB = b; s.BitK = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.WritePos = q; - - return (int)ZLibResultCode.Z_OK; - } + /// + internal int inflate_fast(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, InfBlocks s, ZStream z) + { + int t; // temporary pointer + int[] tp; // temporary pointer + int tp_index; // temporary pointer + int e; // extra bits or operation + int b; // bit buffer + int k; // bits in bit buffer + int p; // input data pointer + int n; // bytes available there + int q; // output Window WritePos pointer + int m; // bytes to End of Window or ReadPos pointer + int ml; // mask for literal/length tree + int md; // mask for distance tree + int c; // bytes to copy + int d; // distance back to copy from + int r; // copy source pointer + + // load input, output, bit values + p = z.next_in_index; n = z.avail_in; b = s.BitB; k = s.BitK; + q = s.WritePos; m = q < s.ReadPos?s.ReadPos - q - 1:s.End - q; + + // initialize masks + ml = ZLibUtil.inflate_mask[bl]; + md = ZLibUtil.inflate_mask[bd]; + + // do until not enough input or output space for fast loop + do + { + // assume called with m >= 258 && n >= 10 + // get literal/length code + while (k < (20)) + { + // max bits for literal/length code + n--; + b |= (z.next_in[p++] & 0xff) << k; k += 8; + } + + t = b & ml; + tp = tl; + tp_index = tl_index; + if ((e = tp[(tp_index + t) * 3]) == 0) + { + b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]); + + s.Window[q++] = (byte) tp[(tp_index + t) * 3 + 2]; + m--; + continue; + } + do + { + + b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]); + + if ((e & 16) != 0) + { + e &= 15; + c = tp[(tp_index + t) * 3 + 2] + ((int) b & ZLibUtil.inflate_mask[e]); + + b >>= e; k -= e; + + // decode distance base of block to copy + while (k < (15)) + { + // max bits for distance code + n--; + b |= (z.next_in[p++] & 0xff) << k; k += 8; + } + + t = b & md; + tp = td; + tp_index = td_index; + e = tp[(tp_index + t) * 3]; + + do + { + + b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]); + + if ((e & 16) != 0) + { + // get extra bits to add to distance base + e &= 15; + while (k < (e)) + { + // get extra bits (up to 13) + n--; + b |= (z.next_in[p++] & 0xff) << k; k += 8; + } + + d = tp[(tp_index + t) * 3 + 2] + (b & ZLibUtil.inflate_mask[e]); + + b >>= (e); k -= (e); + + // do the copy + m -= c; + if (q >= d) + { + // offset before dest + // just copy + r = q - d; + if (q - r > 0 && 2 > (q - r)) + { + s.Window[q++] = s.Window[r++]; c--; // minimum count is three, + s.Window[q++] = s.Window[r++]; c--; // so unroll loop a little + } + else + { + Array.Copy(s.Window, r, s.Window, q, 2); + q += 2; r += 2; c -= 2; + } + } + else + { + // else offset after destination + r = q - d; + do + { + r += s.End; // force pointer in Window + } + while (r < 0); // covers invalid distances + e = s.End - r; + if (c > e) + { + // if source crosses, + c -= e; // wrapped copy + if (q - r > 0 && e > (q - r)) + { + do + { + s.Window[q++] = s.Window[r++]; + } + while (--e != 0); + } + else + { + Array.Copy(s.Window, r, s.Window, q, e); + q += e; r += e; e = 0; + } + r = 0; // copy rest from start of Window + } + } + + // copy all or what's left + if (q - r > 0 && c > (q - r)) + { + do + { + s.Window[q++] = s.Window[r++]; + } + while (--c != 0); + } + else + { + Array.Copy(s.Window, r, s.Window, q, c); + q += c; r += c; c = 0; + } + break; + } + else if ((e & 64) == 0) + { + t += tp[(tp_index + t) * 3 + 2]; + t += (b & ZLibUtil.inflate_mask[e]); + e = tp[(tp_index + t) * 3]; + } + else + { + z.msg = "invalid distance code"; + + c = z.avail_in - n; c = (k >> 3) < c?k >> 3:c; n += c; p -= c; k -= (c << 3); + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + + return (int)ZLibResultCode.Z_DATA_ERROR; + } + } + while (true); + break; + } + + if ((e & 64) == 0) + { + t += tp[(tp_index + t) * 3 + 2]; + t += (b & ZLibUtil.inflate_mask[e]); + if ((e = tp[(tp_index + t) * 3]) == 0) + { + + b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]); + + s.Window[q++] = (byte) tp[(tp_index + t) * 3 + 2]; + m--; + break; + } + } + else if ((e & 32) != 0) + { + + c = z.avail_in - n; c = (k >> 3) < c?k >> 3:c; n += c; p -= c; k -= (c << 3); + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + + return (int)ZLibResultCode.Z_STREAM_END; + } + else + { + z.msg = "invalid literal/length code"; + + c = z.avail_in - n; c = (k >> 3) < c?k >> 3:c; n += c; p -= c; k -= (c << 3); + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + + return (int)ZLibResultCode.Z_DATA_ERROR; + } + } + while (true); + } + while (m >= 258 && n >= 10); + + // not enough input or output--restore pointers and return + c = z.avail_in - n; c = (k >> 3) < c?k >> 3:c; n += c; p -= c; k -= (c << 3); + + s.BitB = b; s.BitK = k; + z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; + s.WritePos = q; + + return (int)ZLibResultCode.Z_OK; + } #endregion } diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/InfTree.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/InfTree.cs index e3f5d4c45..3a0be26d6 100644 --- a/src/ipy/IronPython.Modules/zlib/zlib.net/InfTree.cs +++ b/src/ipy/IronPython.Modules/zlib/zlib.net/InfTree.cs @@ -43,20 +43,22 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ using System; -namespace ComponentAce.Compression.Libs.ZLib { - /// - /// Contains utility information for the InfTree class - /// - internal class InfTreeUtil { +namespace ComponentAce.Compression.Libs.ZLib +{ + /// + /// Contains utility information for the InfTree class + /// + internal class InfTreeUtil + { internal const int MANY = 1440; internal const int fixed_bl = 9; internal const int fixed_bd = 5; - internal static readonly int[] fixed_tl = new int[]{96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 192, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 160, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 224, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 144, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 208, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 176, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 240, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 200, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 168, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 232, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 152, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 216, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 184, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 248, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 196, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 164, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 228, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 148, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 212, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 180, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 244, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 204, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 172, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 236, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 156, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 220, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 188, 0, 8, 14, 0, 8, 142, 0, 8, 78, 0, 9, 252, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 194, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 162, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 226, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 146, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 210, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 178, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 242, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 202, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 170, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 234, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 154, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 218, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 186, - 0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 250, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 198, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 166, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 230, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 150, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 214, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 182, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 246, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 206, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 174, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 238, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 158, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 222, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 190, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 254, 96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 193, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 161, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 225, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 145, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 209, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 177, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 241, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 201, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 169, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 233, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 153, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 217, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 185, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 249, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 197, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 165, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 229, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 149, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 213, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 181, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 245, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 205, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 173, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 237, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 157, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 221, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 189, 0, 8, - 14, 0, 8, 142, 0, 8, 78, 0, 9, 253, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 195, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 163, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 227, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 147, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 211, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 179, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 243, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 203, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 171, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 235, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 155, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 219, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 187, 0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 251, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 199, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 167, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 231, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 151, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 215, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 183, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 247, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 207, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 175, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 239, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 159, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 223, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 191, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 255}; + internal static readonly int[] fixed_tl = new int[]{96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 192, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 160, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 224, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 144, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 208, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 176, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 240, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 200, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 168, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 232, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 152, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 216, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 184, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 248, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 196, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 164, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 228, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 148, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 212, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 180, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 244, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 204, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 172, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 236, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 156, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 220, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 188, 0, 8, 14, 0, 8, 142, 0, 8, 78, 0, 9, 252, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 194, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 162, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 226, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 146, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 210, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 178, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 242, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 202, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 170, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 234, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 154, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 218, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 186, + 0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 250, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 198, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 166, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 230, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 150, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 214, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 182, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 246, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 206, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 174, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 238, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 158, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 222, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 190, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 254, 96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 193, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 161, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 225, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 145, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 209, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 177, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 241, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 201, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 169, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 233, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 153, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 217, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 185, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 249, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 197, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 165, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 229, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 149, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 213, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 181, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 245, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 205, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 173, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 237, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 157, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 221, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 189, 0, 8, + 14, 0, 8, 142, 0, 8, 78, 0, 9, 253, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 195, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 163, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 227, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 147, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 211, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 179, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 243, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 203, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 171, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 235, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 155, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 219, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 187, 0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 251, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 199, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 167, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 231, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 151, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 215, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 183, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 247, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 207, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 175, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 239, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 159, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 223, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 191, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 255}; internal static readonly int[] fixed_td = new int[] { 80, 5, 1, 87, 5, 257, 83, 5, 17, 91, 5, 4097, 81, 5, 5, 89, 5, 1025, 85, 5, 65, 93, 5, 16385, 80, 5, 3, 88, 5, 513, 84, 5, 33, 92, 5, 8193, 82, 5, 9, 90, 5, 2049, 86, 5, 129, 192, 5, 24577, 80, 5, 2, 87, 5, 385, 83, 5, 25, 91, 5, 6145, 81, 5, 7, 89, 5, 1537, 85, 5, 97, 93, 5, 24577, 80, 5, 4, 88, 5, 769, 84, 5, 49, 92, 5, 12289, 82, 5, 13, 90, 5, 3073, 86, 5, 193, 192, 5, 24577 }; @@ -73,8 +75,9 @@ internal class InfTreeUtil { internal const int BMAX = 15; // maximum bit length of any code } - internal sealed class InfTree { - + internal sealed class InfTree + { + #region Methods /// @@ -83,255 +86,300 @@ internal sealed class InfTree { /// /// Return (int)ZLibResultCode.Z_OK on success, (int)ZLibResultCode.Z_DATA_ERROR if the given code set is incomplete (the tables are still built in this case), (int)ZLibResultCode.Z_DATA_ERROR if the input is invalid (an over-subscribed set of lengths), or (int)ZLibResultCode.Z_DATA_ERROR if not enough memory. /// - private static int huft_build(int[] b, int bindex, int n, int s, int[] d, int[] e, int[] t, int[] m, int[] hp, int[] hn, int[] v) { - - int a; // counter for codes of length k - int[] c = new int[InfTreeUtil.BMAX + 1]; // bit length count table - int f; // i repeats in table every internalFlush entries - int g; // maximum code length - int h; // table level - int i; // counter, current code - int j; // counter - int k; // number of bits in current code - int l; // bits per table (returned in m) - int mask; // (1 << windowBits) - 1, to avoid cc -O bug on HP - int p; // pointer into c[], buffer[], or v[] - int q; // points to current table - int[] r = new int[3]; // table entry for structure assignment + private static int huft_build(int[] b, int bindex, int n, int s, int[] d, int[] e, int[] t, int[] m, int[] hp, int[] hn, int[] v) + { + + int a; // counter for codes of length k + int[] c = new int[InfTreeUtil.BMAX + 1]; // bit length count table + int f; // i repeats in table every internalFlush entries + int g; // maximum code length + int h; // table level + int i; // counter, current code + int j; // counter + int k; // number of bits in current code + int l; // bits per table (returned in m) + int mask; // (1 << windowBits) - 1, to avoid cc -O bug on HP + int p; // pointer into c[], buffer[], or v[] + int q; // points to current table + int[] r = new int[3]; // table entry for structure assignment int[] u = new int[InfTreeUtil.BMAX]; // table stack - int w; // bits before this table == (l * h) + int w; // bits before this table == (l * h) int[] x = new int[InfTreeUtil.BMAX + 1]; // bit offsets, then code stack - int xp; // pointer into x - int y; // number of dummy codes added - int z; // number of entries in current table - - // Generate counts for each bit length - - p = 0; i = n; - do { - c[b[bindex + p]]++; p++; i--; // assume all entries <= BMAX - } - while (i != 0); - - if (c[0] == n) { - // null input--all zero length codes - t[0] = -1; - m[0] = 0; - return (int)ZLibResultCode.Z_OK; - } - - // Find minimum and maximum length, bound *m by those - l = m[0]; + int xp; // pointer into x + int y; // number of dummy codes added + int z; // number of entries in current table + + // Generate counts for each bit length + + p = 0; i = n; + do + { + c[b[bindex + p]]++; p++; i--; // assume all entries <= BMAX + } + while (i != 0); + + if (c[0] == n) + { + // null input--all zero length codes + t[0] = - 1; + m[0] = 0; + return (int)ZLibResultCode.Z_OK; + } + + // Find minimum and maximum length, bound *m by those + l = m[0]; for (j = 1; j <= InfTreeUtil.BMAX; j++) - if (c[j] != 0) - break; - k = j; // minimum code length - if (l < j) { - l = j; - } - for (i = InfTreeUtil.BMAX; i != 0; i--) { - if (c[i] != 0) - break; - } - g = i; // maximum code length - if (l > i) { - l = i; - } - m[0] = l; - - // Adjust last length count to fill out codes, if needed - for (y = 1 << j; j < i; j++, y <<= 1) { - if ((y -= c[j]) < 0) { - return (int)ZLibResultCode.Z_DATA_ERROR; - } - } - if ((y -= c[i]) < 0) { - return (int)ZLibResultCode.Z_DATA_ERROR; - } - c[i] += y; - - // Generate starting offsets into the value table for each length - x[1] = j = 0; - p = 1; xp = 2; - while (--i != 0) { - // note that i == g from above - x[xp] = (j += c[p]); - xp++; - p++; - } - - // Make a table of values in order of bit lengths - i = 0; p = 0; - do { - if ((j = b[bindex + p]) != 0) { - v[x[j]++] = i; - } - p++; - } - while (++i < n); - n = x[g]; // set n to length of v - - // Generate the Huffman codes and for each, make the table entries - x[0] = i = 0; // first Huffman code is zero - p = 0; // grab values in bit order - h = -1; // no tables yet--level -1 - w = -l; // bits decoded == (l * h) - u[0] = 0; // just to keep compilers happy - q = 0; // ditto - z = 0; // ditto - - // go through the bit lengths (k already is bits in shortest code) - for (; k <= g; k++) { - a = c[k]; - while (a-- != 0) { - // here i is the Huffman code of length k bits for value *p - // make tables up to required level - while (k > w + l) { - h++; - w += l; // previous table always l bits - // compute minimum size table less than or equal to l bits - z = g - w; - z = (z > l) ? l : z; // table size upper limit - if ((f = 1 << (j = k - w)) > a + 1) { - // try a k-windowBits bit table - // too few codes for k-windowBits bit table - f -= (a + 1); // deduct codes from patterns left - xp = k; - if (j < z) { - while (++j < z) { - // try smaller tables up to z bits - if ((f <<= 1) <= c[++xp]) - break; // enough codes to use up j bits - f -= c[xp]; // else deduct codes from patterns - } - } - } - z = 1 << j; // table entries for j-bit table - - // allocate new table + if (c[j] != 0) + break; + k = j; // minimum code length + if (l < j) + { + l = j; + } + for (i = InfTreeUtil.BMAX; i != 0; i--) + { + if (c[i] != 0) + break; + } + g = i; // maximum code length + if (l > i) + { + l = i; + } + m[0] = l; + + // Adjust last length count to fill out codes, if needed + for (y = 1 << j; j < i; j++, y <<= 1) + { + if ((y -= c[j]) < 0) + { + return (int)ZLibResultCode.Z_DATA_ERROR; + } + } + if ((y -= c[i]) < 0) + { + return (int)ZLibResultCode.Z_DATA_ERROR; + } + c[i] += y; + + // Generate starting offsets into the value table for each length + x[1] = j = 0; + p = 1; xp = 2; + while (--i != 0) + { + // note that i == g from above + x[xp] = (j += c[p]); + xp++; + p++; + } + + // Make a table of values in order of bit lengths + i = 0; p = 0; + do + { + if ((j = b[bindex + p]) != 0) + { + v[x[j]++] = i; + } + p++; + } + while (++i < n); + n = x[g]; // set n to length of v + + // Generate the Huffman codes and for each, make the table entries + x[0] = i = 0; // first Huffman code is zero + p = 0; // grab values in bit order + h = - 1; // no tables yet--level -1 + w = - l; // bits decoded == (l * h) + u[0] = 0; // just to keep compilers happy + q = 0; // ditto + z = 0; // ditto + + // go through the bit lengths (k already is bits in shortest code) + for (; k <= g; k++) + { + a = c[k]; + while (a-- != 0) + { + // here i is the Huffman code of length k bits for value *p + // make tables up to required level + while (k > w + l) + { + h++; + w += l; // previous table always l bits + // compute minimum size table less than or equal to l bits + z = g - w; + z = (z > l)?l:z; // table size upper limit + if ((f = 1 << (j = k - w)) > a + 1) + { + // try a k-windowBits bit table + // too few codes for k-windowBits bit table + f -= (a + 1); // deduct codes from patterns left + xp = k; + if (j < z) + { + while (++j < z) + { + // try smaller tables up to z bits + if ((f <<= 1) <= c[++xp]) + break; // enough codes to use up j bits + f -= c[xp]; // else deduct codes from patterns + } + } + } + z = 1 << j; // table entries for j-bit table + + // allocate new table if (hn[0] + z > InfTreeUtil.MANY) - // (note: doesn't matter for fixed) - return (int)ZLibResultCode.Z_DATA_ERROR; // overflow of MANY - u[h] = q = hn[0]; // DEBUG - hn[0] += z; - - // connect to last table, if there is one - if (h != 0) { - x[h] = i; // save pattern for backing up - r[0] = (byte)j; // bits in this table - r[1] = (byte)l; // bits to dump before this table - j = ZLibUtil.URShift(i, (w - l)); - r[2] = (int)(q - u[h - 1] - j); // offset to this table - Array.Copy(r, 0, hp, (u[h - 1] + j) * 3, 3); // connect to last table - } else { - t[0] = q; // first table is returned result - } - } - - // set up table entry in r - r[1] = (byte)(k - w); - if (p >= n) { - r[0] = 128 + 64; // out of values--invalid code - } else if (v[p] < s) { - r[0] = (byte)(v[p] < 256 ? 0 : 32 + 64); // 256 is End-of-block - r[2] = v[p++]; // simple code is just the value - } else { - r[0] = (byte)(e[v[p] - s] + 16 + 64); // non-simple--look up in lists - r[2] = d[v[p++] - s]; - } - - // fill code-like entries with r - f = 1 << (k - w); - for (j = ZLibUtil.URShift(i, w); j < z; j += f) { - Array.Copy(r, 0, hp, (q + j) * 3, 3); - } - - // backwards increment the k-bit code i - for (j = 1 << (k - 1); (i & j) != 0; j = ZLibUtil.URShift(j, 1)) { - i ^= j; - } - i ^= j; - - // backup over finished tables - mask = (1 << w) - 1; // needed on HP, cc -O bug - while ((i & mask) != x[h]) { - h--; // don't need to update q - w -= l; - mask = (1 << w) - 1; - } - } - } - // Return (int)ZLibResultCode.Z_DATA_ERROR if we were given an incomplete table + // (note: doesn't matter for fixed) + return (int)ZLibResultCode.Z_DATA_ERROR; // overflow of MANY + u[h] = q = hn[0]; // DEBUG + hn[0] += z; + + // connect to last table, if there is one + if (h != 0) + { + x[h] = i; // save pattern for backing up + r[0] = (byte) j; // bits in this table + r[1] = (byte) l; // bits to dump before this table + j = ZLibUtil.URShift(i, (w - l)); + r[2] = (int) (q - u[h - 1] - j); // offset to this table + Array.Copy(r, 0, hp, (u[h - 1] + j) * 3, 3); // connect to last table + } + else + { + t[0] = q; // first table is returned result + } + } + + // set up table entry in r + r[1] = (byte) (k - w); + if (p >= n) + { + r[0] = 128 + 64; // out of values--invalid code + } + else if (v[p] < s) + { + r[0] = (byte) (v[p] < 256?0:32 + 64); // 256 is End-of-block + r[2] = v[p++]; // simple code is just the value + } + else + { + r[0] = (byte) (e[v[p] - s] + 16 + 64); // non-simple--look up in lists + r[2] = d[v[p++] - s]; + } + + // fill code-like entries with r + f = 1 << (k - w); + for (j = ZLibUtil.URShift(i, w); j < z; j += f) + { + Array.Copy(r, 0, hp, (q + j) * 3, 3); + } + + // backwards increment the k-bit code i + for (j = 1 << (k - 1); (i & j) != 0; j = ZLibUtil.URShift(j, 1)) + { + i ^= j; + } + i ^= j; + + // backup over finished tables + mask = (1 << w) - 1; // needed on HP, cc -O bug + while ((i & mask) != x[h]) + { + h--; // don't need to update q + w -= l; + mask = (1 << w) - 1; + } + } + } + // Return (int)ZLibResultCode.Z_DATA_ERROR if we were given an incomplete table return y != 0 && g != 1 ? (int)ZLibResultCode.Z_BUF_ERROR : (int)ZLibResultCode.Z_OK; - } - + } + /// /// Build trees /// - internal static int inflate_trees_bits(int[] c, int[] bb, int[] tb, int[] hp, ZStream z) { - int r; - int[] hn = new int[1]; // hufts used in space - int[] v = new int[19]; // work area for huft_build - - r = huft_build(c, 0, 19, 19, null, null, tb, bb, hp, hn, v); - - if (r == (int)ZLibResultCode.Z_DATA_ERROR) { - z.msg = "oversubscribed dynamic bit lengths tree"; - } else if (r == (int)ZLibResultCode.Z_DATA_ERROR || bb[0] == 0) { - z.msg = "incomplete dynamic bit lengths tree"; - r = (int)ZLibResultCode.Z_DATA_ERROR; - } - return r; - } - + internal static int inflate_trees_bits(int[] c, int[] bb, int[] tb, int[] hp, ZStream z) + { + int r; + int[] hn = new int[1]; // hufts used in space + int[] v = new int[19]; // work area for huft_build + + r = huft_build(c, 0, 19, 19, null, null, tb, bb, hp, hn, v); + + if (r == (int)ZLibResultCode.Z_DATA_ERROR) + { + z.msg = "oversubscribed dynamic bit lengths tree"; + } + else if (r == (int)ZLibResultCode.Z_DATA_ERROR || bb[0] == 0) + { + z.msg = "incomplete dynamic bit lengths tree"; + r = (int)ZLibResultCode.Z_DATA_ERROR; + } + return r; + } + /// /// Builds dynamic trees /// - internal static int inflate_trees_dynamic(int nl, int nd, int[] c, int[] bl, int[] bd, int[] tl, int[] td, int[] hp, ZStream z) { - int r; - int[] hn = new int[1]; // hufts used in space - int[] v = new int[288]; // work area for huft_build - - // build literal/length tree + internal static int inflate_trees_dynamic(int nl, int nd, int[] c, int[] bl, int[] bd, int[] tl, int[] td, int[] hp, ZStream z) + { + int r; + int[] hn = new int[1]; // hufts used in space + int[] v = new int[288]; // work area for huft_build + + // build literal/length tree r = huft_build(c, 0, nl, 257, InfTreeUtil.cplens, InfTreeUtil.cplext, tl, bl, hp, hn, v); - if (r != (int)ZLibResultCode.Z_OK || bl[0] == 0) { - if (r == (int)ZLibResultCode.Z_DATA_ERROR) { - z.msg = "oversubscribed literal/length tree"; - } else if (r != (int)ZLibResultCode.Z_DATA_ERROR) { - z.msg = "incomplete literal/length tree"; - r = (int)ZLibResultCode.Z_DATA_ERROR; - } - return r; - } - - // build distance tree + if (r != (int)ZLibResultCode.Z_OK || bl[0] == 0) + { + if (r == (int)ZLibResultCode.Z_DATA_ERROR) + { + z.msg = "oversubscribed literal/length tree"; + } + else if (r != (int)ZLibResultCode.Z_DATA_ERROR) + { + z.msg = "incomplete literal/length tree"; + r = (int)ZLibResultCode.Z_DATA_ERROR; + } + return r; + } + + // build distance tree r = huft_build(c, nl, nd, 0, InfTreeUtil.cpdist, InfTreeUtil.cpdext, td, bd, hp, hn, v); - - if (r != (int)ZLibResultCode.Z_OK || (bd[0] == 0 && nl > 257)) { - if (r == (int)ZLibResultCode.Z_DATA_ERROR) { - z.msg = "oversubscribed distance tree"; - } else if (r == (int)ZLibResultCode.Z_DATA_ERROR) { - z.msg = "incomplete distance tree"; - r = (int)ZLibResultCode.Z_DATA_ERROR; - } else if (r != (int)ZLibResultCode.Z_DATA_ERROR) { - z.msg = "empty distance tree with lengths"; - r = (int)ZLibResultCode.Z_DATA_ERROR; - } - return r; - } - - return (int)ZLibResultCode.Z_OK; - } - + + if (r != (int)ZLibResultCode.Z_OK || (bd[0] == 0 && nl > 257)) + { + if (r == (int)ZLibResultCode.Z_DATA_ERROR) + { + z.msg = "oversubscribed distance tree"; + } + else if (r == (int)ZLibResultCode.Z_DATA_ERROR) + { + z.msg = "incomplete distance tree"; + r = (int)ZLibResultCode.Z_DATA_ERROR; + } + else if (r != (int)ZLibResultCode.Z_DATA_ERROR) + { + z.msg = "empty distance tree with lengths"; + r = (int)ZLibResultCode.Z_DATA_ERROR; + } + return r; + } + + return (int)ZLibResultCode.Z_OK; + } + /// /// Build fixed trees /// - internal static int inflate_trees_fixed(int[] bl, int[] bd, int[][] tl, int[][] td, ZStream z) { + internal static int inflate_trees_fixed(int[] bl, int[] bd, int[][] tl, int[][] td, ZStream z) + { bl[0] = InfTreeUtil.fixed_bl; bd[0] = InfTreeUtil.fixed_bd; tl[0] = InfTreeUtil.fixed_tl; td[0] = InfTreeUtil.fixed_td; - return (int)ZLibResultCode.Z_OK; + return (int)ZLibResultCode.Z_OK; } #endregion diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/Inflate.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/Inflate.cs index f50f6375b..6cf3e0d5b 100644 --- a/src/ipy/IronPython.Modules/zlib/zlib.net/Inflate.cs +++ b/src/ipy/IronPython.Modules/zlib/zlib.net/Inflate.cs @@ -44,15 +44,17 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using System; using System.Collections.Generic; -namespace ComponentAce.Compression.Libs.ZLib { +namespace ComponentAce.Compression.Libs.ZLib +{ /// /// This enumeration contains modes of inflate processing /// - internal enum InflateMode { + internal enum InflateMode + { /// /// waiting for method byte /// - METHOD = 0, + METHOD = 0, /// /// waiting for flag byte /// @@ -108,14 +110,15 @@ internal enum InflateMode { } - internal sealed class Inflate { + internal sealed class Inflate + { #region Fields - /// + /// /// current inflate mode - /// - public InflateMode mode; + /// + public InflateMode mode; #region mode dependent information @@ -123,8 +126,8 @@ internal sealed class Inflate { /// if FLAGS, method byte /// private int method; - - // if CHECK, check values to compare + + // if CHECK, check values to compare /// /// computed check value @@ -135,10 +138,10 @@ internal sealed class Inflate { /// stream check value /// private long need; - - /// + + /// /// if BAD, inflateSync's marker bytes count - /// + /// private int marker; #endregion @@ -147,15 +150,15 @@ internal sealed class Inflate { /// /// flag for no wrapper /// - private int nowrap; + private int nowrap; /// /// log2(Window size) (8..15, defaults to 15) /// private int wbits; - private IEnumerator gzipHeaderRemover; + private IEnumerator gzipHeaderRemover; - private bool detectHeader; + private bool detectHeader; #endregion @@ -163,7 +166,7 @@ internal sealed class Inflate { /// current inflate_blocks state /// private InfBlocks blocks; - + #endregion #region Methods @@ -173,28 +176,30 @@ internal sealed class Inflate { /// /// A ZStream object /// A result code - internal int inflateReset(ZStream z) { + internal int inflateReset(ZStream z) + { if (z?.istate == null) return (int)ZLibResultCode.Z_STREAM_ERROR; - + z.total_in = z.total_out = 0; z.msg = null; - z.istate.mode = z.istate.nowrap != 0 ? InflateMode.BLOCKS : InflateMode.METHOD; + z.istate.mode = z.istate.nowrap != 0? InflateMode.BLOCKS: InflateMode.METHOD; z.istate.blocks.reset(z, null); return (int)ZLibResultCode.Z_OK; } - + /// /// Finishes the inflate algorithm processing /// /// A ZStream object /// Operation result code - internal int inflateEnd(ZStream z) { - blocks?.free(z); - blocks = null; - // ZFREE(z, z->state); - return (int)ZLibResultCode.Z_OK; - } + internal int inflateEnd(ZStream z) + { + blocks?.free(z); + blocks = null; + // ZFREE(z, z->state); + return (int)ZLibResultCode.Z_OK; + } /// /// Initializes the inflate algorithm @@ -202,39 +207,46 @@ internal int inflateEnd(ZStream z) { /// A ZStream object /// Window size /// Operation result code - internal int inflateInit(ZStream z, int windowBits) { - z.msg = null; - blocks = null; - - // handle undocumented nowrap option (no zlib header or check) - nowrap = 0; + internal int inflateInit(ZStream z, int windowBits) + { + z.msg = null; + blocks = null; + + // handle undocumented nowrap option (no zlib header or check) + nowrap = 0; detectHeader = false; - if (windowBits < 0) { + if (windowBits < 0) + { // deflate, no header - windowBits = -windowBits; - nowrap = 1; - } else if ((windowBits & 16) != 0) { + windowBits = - windowBits; + nowrap = 1; + } + else if ((windowBits & 16) != 0) + { gzipHeaderRemover = GzipHeader.CreateRemover(z); windowBits &= ~16; - } else if ((windowBits & 32) != 0) { + } + else if ((windowBits & 32) != 0) + { detectHeader = true; windowBits &= ~32; } - // set Window size - if (windowBits < 8 || windowBits > 15) { - inflateEnd(z); - return (int)ZLibResultCode.Z_STREAM_ERROR; - } - wbits = windowBits; - - z.istate.blocks = new InfBlocks(z, z.istate.nowrap == 0, 1 << windowBits); - - // reset state - inflateReset(z); - return (int)ZLibResultCode.Z_OK; - } + // set Window size + if (windowBits < 8 || windowBits > 15) + { + inflateEnd(z); + return (int)ZLibResultCode.Z_STREAM_ERROR; + } + wbits = windowBits; + + z.istate.blocks = new InfBlocks(z, z.istate.nowrap == 0, 1 << windowBits); + + // reset state + inflateReset(z); + return (int)ZLibResultCode.Z_OK; + } /// @@ -243,17 +255,19 @@ internal int inflateInit(ZStream z, int windowBits) { /// A ZStream object /// Flush strategy /// Operation result code - internal int inflate(ZStream z, FlushStrategy flush) { - int internalFlush = (int)flush; + internal int inflate(ZStream z, FlushStrategy flush) + { + int internalFlush = (int)flush; - if (z?.istate == null || z.next_in == null) + if (z?.istate == null || z.next_in == null) return (int)ZLibResultCode.Z_STREAM_ERROR; - int res_temp = internalFlush == (int)FlushStrategy.Z_FINISH - ? (int)ZLibResultCode.Z_BUF_ERROR - : (int)ZLibResultCode.Z_OK; - int r = (int)ZLibResultCode.Z_BUF_ERROR; + int res_temp = internalFlush == (int)FlushStrategy.Z_FINISH + ? (int)ZLibResultCode.Z_BUF_ERROR + : (int)ZLibResultCode.Z_OK; + int r = (int)ZLibResultCode.Z_BUF_ERROR; - if (detectHeader) { + if (detectHeader) + { if (z.avail_in == 0) return r; if (z.next_in[z.next_in_index] == 0x1F) @@ -261,7 +275,8 @@ internal int inflate(ZStream z, FlushStrategy flush) { detectHeader = false; } - if (gzipHeaderRemover != null) { + if (gzipHeaderRemover != null) + { if (z.avail_in == 0) return r; if (gzipHeaderRemover.MoveNext()) @@ -272,276 +287,300 @@ internal int inflate(ZStream z, FlushStrategy flush) { nowrap = 1; } - while (true) { + while (true) + { - switch (z.istate.mode) { - - case InflateMode.METHOD: - - if (z.avail_in == 0) + switch (z.istate.mode) + { + + case InflateMode.METHOD: + + if (z.avail_in == 0) return r; r = res_temp; - - z.avail_in--; z.total_in++; - if (((z.istate.method = z.next_in[z.next_in_index++]) & 0xf) != ZLibUtil.Z_DEFLATED) { - z.istate.mode = InflateMode.BAD; - z.msg = "unknown compression method"; - z.istate.marker = 5; // can't try inflateSync - break; - } - if ((z.istate.method >> 4) + 8 > z.istate.wbits) { - z.istate.mode = InflateMode.BAD; - z.msg = "invalid Window size"; - z.istate.marker = 5; // can't try inflateSync - break; - } - z.istate.mode = InflateMode.FLAG; - goto case InflateMode.FLAG; - - case InflateMode.FLAG: - - if (z.avail_in == 0) + + z.avail_in--; z.total_in++; + if (((z.istate.method = z.next_in[z.next_in_index++]) & 0xf) != ZLibUtil.Z_DEFLATED) + { + z.istate.mode = InflateMode.BAD; + z.msg = "unknown compression method"; + z.istate.marker = 5; // can't try inflateSync + break; + } + if ((z.istate.method >> 4) + 8 > z.istate.wbits) + { + z.istate.mode = InflateMode.BAD; + z.msg = "invalid Window size"; + z.istate.marker = 5; // can't try inflateSync + break; + } + z.istate.mode = InflateMode.FLAG; + goto case InflateMode.FLAG; + + case InflateMode.FLAG: + + if (z.avail_in == 0) return r; r = res_temp; - - z.avail_in--; z.total_in++; - int b = (z.next_in[z.next_in_index++]) & 0xff; - - if ((((z.istate.method << 8) + b) % 31) != 0) { - z.istate.mode = InflateMode.BAD; - z.msg = "incorrect header check"; - z.istate.marker = 5; // can't try inflateSync - break; - } - - if ((b & ZLibUtil.PRESET_DICT) == 0) { - z.istate.mode = InflateMode.BLOCKS; - break; - } - z.istate.mode = InflateMode.DICT4; - goto case InflateMode.DICT4; - - case InflateMode.DICT4: - - if (z.avail_in == 0) + + z.avail_in--; z.total_in++; + int b = (z.next_in[z.next_in_index++]) & 0xff; + + if ((((z.istate.method << 8) + b) % 31) != 0) + { + z.istate.mode = InflateMode.BAD; + z.msg = "incorrect header check"; + z.istate.marker = 5; // can't try inflateSync + break; + } + + if ((b & ZLibUtil.PRESET_DICT) == 0) + { + z.istate.mode = InflateMode.BLOCKS; + break; + } + z.istate.mode = InflateMode.DICT4; + goto case InflateMode.DICT4; + + case InflateMode.DICT4: + + if (z.avail_in == 0) return r; r = res_temp; - - z.avail_in--; z.total_in++; - z.istate.need = ((long)(z.next_in[z.next_in_index++] & 0xff) << 24) & unchecked((int)0xff000000L); - z.istate.mode = InflateMode.DICT3; - goto case InflateMode.DICT3; - - case InflateMode.DICT3: - - if (z.avail_in == 0) + + z.avail_in--; z.total_in++; + z.istate.need = ((long)(z.next_in[z.next_in_index++] & 0xff) << 24) & unchecked((int) 0xff000000L); + z.istate.mode = InflateMode.DICT3; + goto case InflateMode.DICT3; + + case InflateMode.DICT3: + + if (z.avail_in == 0) return r; r = res_temp; - - z.avail_in--; z.total_in++; - z.istate.need += (((long)(z.next_in[z.next_in_index++] & 0xff) << 16) & 0xff0000L); - z.istate.mode = InflateMode.DICT2; - goto case InflateMode.DICT2; - - case InflateMode.DICT2: - - if (z.avail_in == 0) + + z.avail_in--; z.total_in++; + z.istate.need += (((long)(z.next_in[z.next_in_index++] & 0xff) << 16) & 0xff0000L); + z.istate.mode = InflateMode.DICT2; + goto case InflateMode.DICT2; + + case InflateMode.DICT2: + + if (z.avail_in == 0) return r; r = res_temp; - - z.avail_in--; z.total_in++; - z.istate.need += (((long)(z.next_in[z.next_in_index++] & 0xff) << 8) & 0xff00L); - z.istate.mode = InflateMode.DICT1; - goto case InflateMode.DICT1; - - case InflateMode.DICT1: - - if (z.avail_in == 0) + + z.avail_in--; z.total_in++; + z.istate.need += (((long)(z.next_in[z.next_in_index++] & 0xff) << 8) & 0xff00L); + z.istate.mode = InflateMode.DICT1; + goto case InflateMode.DICT1; + + case InflateMode.DICT1: + + if (z.avail_in == 0) return r; r = res_temp; - - z.avail_in--; z.total_in++; - z.istate.need += (z.next_in[z.next_in_index++] & 0xffL); - z.adler = z.istate.need; - z.istate.mode = InflateMode.DICT0; - return (int)ZLibResultCode.Z_NEED_DICT; - - case InflateMode.DICT0: - z.istate.mode = InflateMode.BAD; - z.msg = "need dictionary"; - z.istate.marker = 0; // can try inflateSync - return (int)ZLibResultCode.Z_STREAM_ERROR; - - case InflateMode.BLOCKS: - r = z.istate.blocks.proc(z, r); - if (r == (int)ZLibResultCode.Z_DATA_ERROR) { - z.istate.mode = InflateMode.BAD; - z.istate.marker = 0; // can try inflateSync - break; - } - if (r == (int)ZLibResultCode.Z_OK) { + + z.avail_in--; z.total_in++; + z.istate.need += (z.next_in[z.next_in_index++] & 0xffL); + z.adler = z.istate.need; + z.istate.mode = InflateMode.DICT0; + return (int)ZLibResultCode.Z_NEED_DICT; + + case InflateMode.DICT0: + z.istate.mode = InflateMode.BAD; + z.msg = "need dictionary"; + z.istate.marker = 0; // can try inflateSync + return (int)ZLibResultCode.Z_STREAM_ERROR; + + case InflateMode.BLOCKS: + r = z.istate.blocks.proc(z, r); + if (r == (int)ZLibResultCode.Z_DATA_ERROR) + { + z.istate.mode = InflateMode.BAD; + z.istate.marker = 0; // can try inflateSync + break; + } + if (r == (int)ZLibResultCode.Z_OK) + { r = res_temp; - } - if (r != (int)ZLibResultCode.Z_STREAM_END) { - return r; - } + } + if (r != (int)ZLibResultCode.Z_STREAM_END) + { + return r; + } r = res_temp; - z.istate.blocks.reset(z, z.istate.was); - if (z.istate.nowrap != 0) { - z.istate.mode = InflateMode.DONE; - break; - } - z.istate.mode = InflateMode.CHECK4; - goto case InflateMode.CHECK4; - - case InflateMode.CHECK4: - - if (z.avail_in == 0) + z.istate.blocks.reset(z, z.istate.was); + if (z.istate.nowrap != 0) + { + z.istate.mode = InflateMode.DONE; + break; + } + z.istate.mode = InflateMode.CHECK4; + goto case InflateMode.CHECK4; + + case InflateMode.CHECK4: + + if (z.avail_in == 0) return r; r = res_temp; - - z.avail_in--; z.total_in++; - z.istate.need = ((z.next_in[z.next_in_index++] & 0xff) << 24) & unchecked((int)0xff000000L); - z.istate.mode = InflateMode.CHECK3; - goto case InflateMode.CHECK3; - - case InflateMode.CHECK3: - - if (z.avail_in == 0) + + z.avail_in--; z.total_in++; + z.istate.need = ((z.next_in[z.next_in_index++] & 0xff) << 24) & unchecked((int) 0xff000000L); + z.istate.mode = InflateMode.CHECK3; + goto case InflateMode.CHECK3; + + case InflateMode.CHECK3: + + if (z.avail_in == 0) return r; r = res_temp; - - z.avail_in--; z.total_in++; - z.istate.need += (((z.next_in[z.next_in_index++] & 0xff) << 16) & 0xff0000L); - z.istate.mode = InflateMode.CHECK2; - goto case InflateMode.CHECK2; - - case InflateMode.CHECK2: - - if (z.avail_in == 0) + + z.avail_in--; z.total_in++; + z.istate.need += (((z.next_in[z.next_in_index++] & 0xff) << 16) & 0xff0000L); + z.istate.mode = InflateMode.CHECK2; + goto case InflateMode.CHECK2; + + case InflateMode.CHECK2: + + if (z.avail_in == 0) return r; r = res_temp; - - z.avail_in--; z.total_in++; - z.istate.need += (((z.next_in[z.next_in_index++] & 0xff) << 8) & 0xff00L); - z.istate.mode = InflateMode.CHECK1; - goto case InflateMode.CHECK1; - - case InflateMode.CHECK1: - - if (z.avail_in == 0) + + z.avail_in--; z.total_in++; + z.istate.need += (((z.next_in[z.next_in_index++] & 0xff) << 8) & 0xff00L); + z.istate.mode = InflateMode.CHECK1; + goto case InflateMode.CHECK1; + + case InflateMode.CHECK1: + + if (z.avail_in == 0) return r; r = res_temp; - - z.avail_in--; z.total_in++; - z.istate.need += (z.next_in[z.next_in_index++] & 0xffL); - - if (unchecked(((int)(z.istate.was[0])) != ((int)(z.istate.need)))) { - z.istate.mode = InflateMode.BAD; - z.msg = "incorrect data check"; - z.istate.marker = 5; // can't try inflateSync - break; - } - - z.istate.mode = InflateMode.DONE; - goto case InflateMode.DONE; - - case InflateMode.DONE: - return (int)ZLibResultCode.Z_STREAM_END; - - case InflateMode.BAD: - return (int)ZLibResultCode.Z_DATA_ERROR; - - default: - return (int)ZLibResultCode.Z_STREAM_ERROR; - - } - } - } - - /// - /// Sets dictionary for the inflate operation - /// - /// A ZStream object - /// An array of byte - dictionary - /// Dictionary length - /// Operation result code - internal int inflateSetDictionary(ZStream z, byte[] dictionary, int dictLength) { - int index = 0; - int length = dictLength; - if (z?.istate?.mode != InflateMode.DICT0) - return (int)ZLibResultCode.Z_STREAM_ERROR; - - if (Adler32.GetAdler32Checksum(1L, dictionary, 0, dictLength) != z.adler) { - return (int)ZLibResultCode.Z_DATA_ERROR; - } - - z.adler = Adler32.GetAdler32Checksum(0, null, 0, 0); - - if (length >= (1 << z.istate.wbits)) { - length = (1 << z.istate.wbits) - 1; - index = dictLength - length; - } - z.istate.blocks.set_dictionary(dictionary, index, length); - z.istate.mode = InflateMode.BLOCKS; - return (int)ZLibResultCode.Z_OK; - } - - + + z.avail_in--; z.total_in++; + z.istate.need += (z.next_in[z.next_in_index++] & 0xffL); + + if (unchecked(((int) (z.istate.was[0])) != ((int) (z.istate.need)))) + { + z.istate.mode = InflateMode.BAD; + z.msg = "incorrect data check"; + z.istate.marker = 5; // can't try inflateSync + break; + } + + z.istate.mode = InflateMode.DONE; + goto case InflateMode.DONE; + + case InflateMode.DONE: + return (int)ZLibResultCode.Z_STREAM_END; + + case InflateMode.BAD: + return (int)ZLibResultCode.Z_DATA_ERROR; + + default: + return (int)ZLibResultCode.Z_STREAM_ERROR; + + } + } + } + + /// + /// Sets dictionary for the inflate operation + /// + /// A ZStream object + /// An array of byte - dictionary + /// Dictionary length + /// Operation result code + internal int inflateSetDictionary(ZStream z, byte[] dictionary, int dictLength) + { + int index = 0; + int length = dictLength; + if (z?.istate?.mode != InflateMode.DICT0) + return (int)ZLibResultCode.Z_STREAM_ERROR; + + if (Adler32.GetAdler32Checksum(1L, dictionary, 0, dictLength) != z.adler) + { + return (int)ZLibResultCode.Z_DATA_ERROR; + } + + z.adler = Adler32.GetAdler32Checksum(0, null, 0, 0); + + if (length >= (1 << z.istate.wbits)) + { + length = (1 << z.istate.wbits) - 1; + index = dictLength - length; + } + z.istate.blocks.set_dictionary(dictionary, index, length); + z.istate.mode = InflateMode.BLOCKS; + return (int)ZLibResultCode.Z_OK; + } + + /// /// Inflate synchronization /// /// A ZStream object /// Operation result code - internal int inflateSync(ZStream z) { - int n; // number of bytes to look at - int p; // pointer to bytes - int m; // number of marker bytes found in a row - long r, w; // temporaries to save _total_in and _total_out - - // set up - if (z?.istate == null) - return (int)ZLibResultCode.Z_STREAM_ERROR; - if (z.istate.mode != InflateMode.BAD) { - z.istate.mode = InflateMode.BAD; - z.istate.marker = 0; - } - if ((n = z.avail_in) == 0) - return (int)ZLibResultCode.Z_BUF_ERROR; - p = z.next_in_index; - m = z.istate.marker; - - // search - while (n != 0 && m < 4) { - if (z.next_in[p] == ZLibUtil.mark[m]) { - m++; - } else if (z.next_in[p] != 0) { - m = 0; - } else { - m = 4 - m; - } - p++; n--; - } - - // restore - z.total_in += p - z.next_in_index; - z.next_in_index = p; - z.avail_in = n; - z.istate.marker = m; - - // return no joy or set up to restart on a new block - if (m != 4) { - return (int)ZLibResultCode.Z_DATA_ERROR; - } - r = z.total_in; w = z.total_out; - inflateReset(z); - z.total_in = r; z.total_out = w; - z.istate.mode = InflateMode.BLOCKS; - return (int)ZLibResultCode.Z_OK; - } - + internal int inflateSync(ZStream z) + { + int n; // number of bytes to look at + int p; // pointer to bytes + int m; // number of marker bytes found in a row + long r, w; // temporaries to save _total_in and _total_out + + // set up + if (z?.istate == null) + return (int)ZLibResultCode.Z_STREAM_ERROR; + if (z.istate.mode != InflateMode.BAD) + { + z.istate.mode = InflateMode.BAD; + z.istate.marker = 0; + } + if ((n = z.avail_in) == 0) + return (int)ZLibResultCode.Z_BUF_ERROR; + p = z.next_in_index; + m = z.istate.marker; + + // search + while (n != 0 && m < 4) + { + if (z.next_in[p] == ZLibUtil.mark[m]) + { + m++; + } + else if (z.next_in[p] != 0) + { + m = 0; + } + else + { + m = 4 - m; + } + p++; n--; + } + + // restore + z.total_in += p - z.next_in_index; + z.next_in_index = p; + z.avail_in = n; + z.istate.marker = m; + + // return no joy or set up to restart on a new block + if (m != 4) + { + return (int)ZLibResultCode.Z_DATA_ERROR; + } + r = z.total_in; w = z.total_out; + inflateReset(z); + z.total_in = r; z.total_out = w; + z.istate.mode = InflateMode.BLOCKS; + return (int)ZLibResultCode.Z_OK; + } + /// - /// Returns true if inflate is currently at the End of a block generated - /// by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP - /// implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH - /// but removes the length bytes of the resulting empty stored block. When - /// decompressing, PPP checks that at the End of input packet, inflate is - /// waiting for these length bytes. + /// Returns true if inflate is currently at the End of a block generated + /// by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP + /// implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH + /// but removes the length bytes of the resulting empty stored block. When + /// decompressing, PPP checks that at the End of input packet, inflate is + /// waiting for these length bytes. /// - internal int inflateSyncPoint(ZStream z) { - if (z?.istate?.blocks == null) - return (int)ZLibResultCode.Z_STREAM_ERROR; - return z.istate.blocks.sync_point(); + internal int inflateSyncPoint(ZStream z) + { + if (z?.istate?.blocks == null) + return (int)ZLibResultCode.Z_STREAM_ERROR; + return z.istate.blocks.sync_point(); } #endregion diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/StaticTree.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/StaticTree.cs index 4349421b7..cf7f7ec0b 100644 --- a/src/ipy/IronPython.Modules/zlib/zlib.net/StaticTree.cs +++ b/src/ipy/IronPython.Modules/zlib/zlib.net/StaticTree.cs @@ -42,54 +42,58 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * and contributors of zlib. */ -namespace ComponentAce.Compression.Libs.ZLib { - - internal sealed class StaticTree { +namespace ComponentAce.Compression.Libs.ZLib +{ + + internal sealed class StaticTree + { #region Fields - - private const int BL_CODES = 19; - private const int D_CODES = 30; - private const int LITERALS = 256; - private const int LENGTH_CODES = 29; - private const int L_CODES = (LITERALS + 1 + LENGTH_CODES); - - /// + + private const int BL_CODES = 19; + private const int D_CODES = 30; + private const int LITERALS = 256; + private const int LENGTH_CODES = 29; + private const int L_CODES = (LITERALS + 1 + LENGTH_CODES); + + /// /// Bit length codes must not exceed MAX_BL_BITS bits - /// - internal const int MAX_BL_BITS = 7; - - internal static readonly short[] static_ltree = new short[]{12, 8, 140, 8, 76, 8, 204, 8, 44, 8, 172, 8, 108, 8, 236, 8, 28, 8, 156, 8, 92, 8, 220, 8, 60, 8, 188, 8, 124, 8, 252, 8, 2, 8, 130, 8, 66, 8, 194, 8, 34, 8, 162, 8, 98, 8, 226, 8, 18, 8, 146, 8, 82, 8, 210, 8, 50, 8, 178, 8, 114, 8, 242, 8, 10, 8, 138, 8, 74, 8, 202, 8, 42, 8, 170, 8, 106, 8, 234, 8, 26, 8, 154, 8, 90, 8, 218, 8, 58, 8, 186, 8, 122, 8, 250, 8, 6, 8, 134, 8, 70, 8, 198, 8, 38, 8, 166, 8, 102, 8, 230, 8, 22, 8, 150, 8, 86, 8, 214, 8, 54, 8, 182, 8, 118, 8, 246, 8, 14, 8, 142, 8, 78, 8, 206, 8, 46, 8, 174, 8, 110, 8, 238, 8, 30, 8, 158, 8, 94, 8, 222, 8, 62, 8, 190, 8, 126, 8, 254, 8, 1, 8, 129, 8, 65, 8, 193, 8, 33, 8, 161, 8, 97, 8, 225, 8, 17, 8, 145, 8, 81, 8, 209, 8, 49, 8, 177, 8, 113, 8, 241, 8, 9, 8, 137, 8, 73, 8, 201, 8, 41, 8, 169, 8, 105, 8, 233, 8, 25, 8, 153, 8, 89, 8, 217, 8, 57, 8, 185, 8, 121, 8, 249, 8, 5, 8, 133, 8, 69, 8, 197, 8, 37, 8, 165, 8, 101, 8, 229, 8, 21, 8, 149, 8, 85, 8, 213, 8, 53, 8, 181, 8, 117, 8, 245, 8, 13, 8, 141, 8, 77, 8, 205, 8, 45, 8, 173, 8, 109, 8, 237, 8, 29, 8, 157, 8, 93, 8, 221, 8, 61, 8, 189, 8, 125, 8, 253, 8, 19, 9, 275, 9, 147, 9, 403, 9, 83, 9, 339, 9, 211, 9, 467, 9, 51, 9, 307, 9, 179, 9, 435, 9, 115, 9, 371, 9, 243, 9, 499, 9, 11, 9, 267, 9, 139, 9, 395, 9, 75, 9, 331, 9, 203, 9, 459, 9, 43, 9, 299, 9, 171, 9, 427, 9, 107, 9, 363, 9, 235, 9, 491, 9, 27, 9, 283, 9, 155, 9, 411, 9, 91, 9, 347, 9, 219, 9, 475, 9, 59, 9, 315, 9, 187, 9, 443, 9, 123, 9, 379, 9, 251, 9, 507, 9, 7, 9, 263, 9, 135, 9, 391, 9, 71, 9, 327, 9, 199, 9, 455, 9, 39, 9, 295, 9, 167, 9, 423, 9, 103, 9, 359, 9, 231, 9, 487, 9, 23, 9, 279, 9, 151, 9, 407, 9, 87, 9, 343, 9, 215, 9, 471, 9, 55, 9, 311, 9, 183, 9, 439, 9, 119, 9, 375, 9, 247, 9, 503, 9, 15, 9, 271, 9, 143, 9, 399, 9, 79, 9, 335, 9, 207, 9, 463, 9, 47, 9, 303, 9, 175, 9, 431, 9, 111, 9, 367, 9, 239, 9, 495, 9, 31, 9, 287, 9, 159, 9, 415, 9, 95, 9, 351, 9, 223, 9, 479, 9, 63, 9, 319, 9, 191, 9, 447, 9, 127, 9, 383, 9, 255, 9, 511, 9, 0, 7, 64, 7 - , 32, 7, 96, 7, 16, 7, 80, 7, 48, 7, 112, 7, 8, 7, 72, 7, 40, 7, 104, 7, 24, 7, 88, 7, 56, 7, 120, 7, 4, 7, 68, 7, 36, 7, 100, 7, 20, 7, 84, 7, 52, 7, 116, 7, 3, 8, 131, 8, 67, 8, 195, 8, 35, 8, 163, 8, 99, 8, 227, 8}; + /// + internal const int MAX_BL_BITS = 7; + + internal static readonly short[] static_ltree = new short[]{12, 8, 140, 8, 76, 8, 204, 8, 44, 8, 172, 8, 108, 8, 236, 8, 28, 8, 156, 8, 92, 8, 220, 8, 60, 8, 188, 8, 124, 8, 252, 8, 2, 8, 130, 8, 66, 8, 194, 8, 34, 8, 162, 8, 98, 8, 226, 8, 18, 8, 146, 8, 82, 8, 210, 8, 50, 8, 178, 8, 114, 8, 242, 8, 10, 8, 138, 8, 74, 8, 202, 8, 42, 8, 170, 8, 106, 8, 234, 8, 26, 8, 154, 8, 90, 8, 218, 8, 58, 8, 186, 8, 122, 8, 250, 8, 6, 8, 134, 8, 70, 8, 198, 8, 38, 8, 166, 8, 102, 8, 230, 8, 22, 8, 150, 8, 86, 8, 214, 8, 54, 8, 182, 8, 118, 8, 246, 8, 14, 8, 142, 8, 78, 8, 206, 8, 46, 8, 174, 8, 110, 8, 238, 8, 30, 8, 158, 8, 94, 8, 222, 8, 62, 8, 190, 8, 126, 8, 254, 8, 1, 8, 129, 8, 65, 8, 193, 8, 33, 8, 161, 8, 97, 8, 225, 8, 17, 8, 145, 8, 81, 8, 209, 8, 49, 8, 177, 8, 113, 8, 241, 8, 9, 8, 137, 8, 73, 8, 201, 8, 41, 8, 169, 8, 105, 8, 233, 8, 25, 8, 153, 8, 89, 8, 217, 8, 57, 8, 185, 8, 121, 8, 249, 8, 5, 8, 133, 8, 69, 8, 197, 8, 37, 8, 165, 8, 101, 8, 229, 8, 21, 8, 149, 8, 85, 8, 213, 8, 53, 8, 181, 8, 117, 8, 245, 8, 13, 8, 141, 8, 77, 8, 205, 8, 45, 8, 173, 8, 109, 8, 237, 8, 29, 8, 157, 8, 93, 8, 221, 8, 61, 8, 189, 8, 125, 8, 253, 8, 19, 9, 275, 9, 147, 9, 403, 9, 83, 9, 339, 9, 211, 9, 467, 9, 51, 9, 307, 9, 179, 9, 435, 9, 115, 9, 371, 9, 243, 9, 499, 9, 11, 9, 267, 9, 139, 9, 395, 9, 75, 9, 331, 9, 203, 9, 459, 9, 43, 9, 299, 9, 171, 9, 427, 9, 107, 9, 363, 9, 235, 9, 491, 9, 27, 9, 283, 9, 155, 9, 411, 9, 91, 9, 347, 9, 219, 9, 475, 9, 59, 9, 315, 9, 187, 9, 443, 9, 123, 9, 379, 9, 251, 9, 507, 9, 7, 9, 263, 9, 135, 9, 391, 9, 71, 9, 327, 9, 199, 9, 455, 9, 39, 9, 295, 9, 167, 9, 423, 9, 103, 9, 359, 9, 231, 9, 487, 9, 23, 9, 279, 9, 151, 9, 407, 9, 87, 9, 343, 9, 215, 9, 471, 9, 55, 9, 311, 9, 183, 9, 439, 9, 119, 9, 375, 9, 247, 9, 503, 9, 15, 9, 271, 9, 143, 9, 399, 9, 79, 9, 335, 9, 207, 9, 463, 9, 47, 9, 303, 9, 175, 9, 431, 9, 111, 9, 367, 9, 239, 9, 495, 9, 31, 9, 287, 9, 159, 9, 415, 9, 95, 9, 351, 9, 223, 9, 479, 9, 63, 9, 319, 9, 191, 9, 447, 9, 127, 9, 383, 9, 255, 9, 511, 9, 0, 7, 64, 7 + , 32, 7, 96, 7, 16, 7, 80, 7, 48, 7, 112, 7, 8, 7, 72, 7, 40, 7, 104, 7, 24, 7, 88, 7, 56, 7, 120, 7, 4, 7, 68, 7, 36, 7, 100, 7, 20, 7, 84, 7, 52, 7, 116, 7, 3, 8, 131, 8, 67, 8, 195, 8, 35, 8, 163, 8, 99, 8, 227, 8}; internal static readonly short[] static_dtree = new short[] { 0, 5, 16, 5, 8, 5, 24, 5, 4, 5, 20, 5, 12, 5, 28, 5, 2, 5, 18, 5, 10, 5, 26, 5, 6, 5, 22, 5, 14, 5, 30, 5, 1, 5, 17, 5, 9, 5, 25, 5, 5, 5, 21, 5, 13, 5, 29, 5, 3, 5, 19, 5, 11, 5, 27, 5, 7, 5, 23, 5 }; - - internal static StaticTree static_l_desc; - - internal static StaticTree static_d_desc; - - internal static StaticTree static_bl_desc; - - internal short[] static_tree; // static tree or null - internal int[] extra_bits; // extra bits for each code or null - internal int extra_base; // base index for extra_bits - internal int elems; // max number of elements in the tree - internal int max_length; // max bit length for the codes + + internal static StaticTree static_l_desc; + + internal static StaticTree static_d_desc; + + internal static StaticTree static_bl_desc; + + internal short[] static_tree; // static tree or null + internal int[] extra_bits; // extra bits for each code or null + internal int extra_base; // base index for extra_bits + internal int elems; // max number of elements in the tree + internal int max_length; // max bit length for the codes #endregion #region Constructors - internal StaticTree(short[] static_tree, int[] extra_bits, int extra_base, int elems, int max_length) { - this.static_tree = static_tree; - this.extra_bits = extra_bits; - this.extra_base = extra_base; - this.elems = elems; - this.max_length = max_length; - } - static StaticTree() { - static_l_desc = new StaticTree(static_ltree, ZLibUtil.extra_lbits, LITERALS + 1, L_CODES, ZLibUtil.MAX_WBITS); + internal StaticTree(short[] static_tree, int[] extra_bits, int extra_base, int elems, int max_length) + { + this.static_tree = static_tree; + this.extra_bits = extra_bits; + this.extra_base = extra_base; + this.elems = elems; + this.max_length = max_length; + } + static StaticTree() + { + static_l_desc = new StaticTree(static_ltree, ZLibUtil.extra_lbits, LITERALS + 1, L_CODES, ZLibUtil.MAX_WBITS); static_d_desc = new StaticTree(static_dtree, ZLibUtil.extra_dbits, 0, D_CODES, ZLibUtil.MAX_WBITS); static_bl_desc = new StaticTree(null, ZLibUtil.extra_blbits, 0, BL_CODES, MAX_BL_BITS); } diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/Tree.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/Tree.cs index 8f5e26b30..576be2f1b 100644 --- a/src/ipy/IronPython.Modules/zlib/zlib.net/Tree.cs +++ b/src/ipy/IronPython.Modules/zlib/zlib.net/Tree.cs @@ -41,12 +41,16 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) * and contributors of zlib. */ -namespace ComponentAce.Compression.Libs.ZLib { +using System; +namespace ComponentAce.Compression.Libs.ZLib +{ + /// /// This class represents a tree and is used in the Deflate class /// - internal sealed class Tree { + internal sealed class Tree + { #region Fields @@ -72,7 +76,8 @@ internal sealed class Tree { /// /// The dynamic tree /// - public short[] DynTree { + public short[] DynTree + { get { return dyn_tree; } set { dyn_tree = value; } } @@ -80,14 +85,16 @@ public short[] DynTree { /// /// Largest code with non zero frequency /// - public int MaxCode { + public int MaxCode + { get { return max_code; } set { max_code = value; } } /// /// the corresponding static tree /// - internal StaticTree StatDesc { + internal StaticTree StatDesc + { get { return stat_desc; } set { stat_desc = value; } } @@ -101,93 +108,101 @@ internal StaticTree StatDesc { /// must not have side effects. _dist_code[256] and _dist_code[257] are never /// used. /// - internal static int d_code(int dist) { + internal static int d_code(int dist) + { return ((dist) < 256 ? ZLibUtil._dist_code[dist] : ZLibUtil._dist_code[256 + (ZLibUtil.URShift((dist), 7))]); - } - - /// - /// Compute the optimal bit lengths for a tree and update the total bit length - /// for the current block. - /// IN assertion: the fields freq and dad are set, heap[heap_max] and - /// above are the tree nodes sorted by increasing frequency. - /// OUT assertions: the field count is set to the optimal bit length, the - /// array bl_count contains the frequencies for each bit length. - /// The length opt_len is updated; static_len is also updated if stree is - /// not null. + } + + /// + /// Compute the optimal bit lengths for a tree and update the total bit length + /// for the current block. + /// IN assertion: the fields freq and dad are set, heap[heap_max] and + /// above are the tree nodes sorted by increasing frequency. + /// OUT assertions: the field count is set to the optimal bit length, the + /// array bl_count contains the frequencies for each bit length. + /// The length opt_len is updated; static_len is also updated if stree is + /// not null. /// - private void gen_bitlen(Deflate s) { - short[] tree = dyn_tree; - short[] stree = stat_desc.static_tree; - int[] extra = stat_desc.extra_bits; - int base_Renamed = stat_desc.extra_base; - int max_length = stat_desc.max_length; - int h; // heap index - int n, m; // iterate over the tree elements - int bits; // bit length - int xbits; // extra bits - short f; // frequency - int overflow = 0; // number of elements with bit length too large + private void gen_bitlen(Deflate s) + { + short[] tree = dyn_tree; + short[] stree = stat_desc.static_tree; + int[] extra = stat_desc.extra_bits; + int base_Renamed = stat_desc.extra_base; + int max_length = stat_desc.max_length; + int h; // heap index + int n, m; // iterate over the tree elements + int bits; // bit length + int xbits; // extra bits + short f; // frequency + int overflow = 0; // number of elements with bit length too large for (bits = 0; bits <= ZLibUtil.MAX_WBITS; bits++) - s.bl_count[bits] = 0; - - // In a first pass, compute the optimal bit lengths (which may - // overflow in the case of the bit length tree). - tree[s.heap[s.heap_max] * 2 + 1] = 0; // root of the heap - - for (h = s.heap_max + 1; h < ZLibUtil.HEAP_SIZE; h++) { - n = s.heap[h]; - bits = tree[tree[n * 2 + 1] * 2 + 1] + 1; - if (bits > max_length) { - bits = max_length; overflow++; - } - tree[n * 2 + 1] = (short)bits; - // We overwrite tree[n*2+1] which is no longer needed - - if (n > max_code) - continue; // not a leaf node - - s.bl_count[bits]++; - xbits = 0; - if (n >= base_Renamed) - xbits = extra[n - base_Renamed]; - f = tree[n * 2]; - s.opt_len += f * (bits + xbits); - if (stree != null) - s.static_len += f * (stree[n * 2 + 1] + xbits); - } - if (overflow == 0) - return; - - // This happens for example on obj2 and pic of the Calgary corpus - // Find the first bit length which could increase: - do { - bits = max_length - 1; - while (s.bl_count[bits] == 0) - bits--; - s.bl_count[bits]--; // move one leaf down the tree - s.bl_count[bits + 1] = (short)(s.bl_count[bits + 1] + 2); // move one overflow item as its brother - s.bl_count[max_length]--; - // The brother of the overflow item also moves one step up, - // but this does not affect bl_count[max_length] - overflow -= 2; - } - while (overflow > 0); - - for (bits = max_length; bits != 0; bits--) { - n = s.bl_count[bits]; - while (n != 0) { - m = s.heap[--h]; - if (m > max_code) - continue; - if (tree[m * 2 + 1] != bits) { - s.opt_len = (int)(s.opt_len + ((long)bits - (long)tree[m * 2 + 1]) * (long)tree[m * 2]); - tree[m * 2 + 1] = (short)bits; - } - n--; - } - } - } + s.bl_count[bits] = 0; + + // In a first pass, compute the optimal bit lengths (which may + // overflow in the case of the bit length tree). + tree[s.heap[s.heap_max] * 2 + 1] = 0; // root of the heap + + for (h = s.heap_max + 1; h < ZLibUtil.HEAP_SIZE; h++) + { + n = s.heap[h]; + bits = tree[tree[n * 2 + 1] * 2 + 1] + 1; + if (bits > max_length) + { + bits = max_length; overflow++; + } + tree[n * 2 + 1] = (short) bits; + // We overwrite tree[n*2+1] which is no longer needed + + if (n > max_code) + continue; // not a leaf node + + s.bl_count[bits]++; + xbits = 0; + if (n >= base_Renamed) + xbits = extra[n - base_Renamed]; + f = tree[n * 2]; + s.opt_len += f * (bits + xbits); + if (stree != null) + s.static_len += f * (stree[n * 2 + 1] + xbits); + } + if (overflow == 0) + return ; + + // This happens for example on obj2 and pic of the Calgary corpus + // Find the first bit length which could increase: + do + { + bits = max_length - 1; + while (s.bl_count[bits] == 0) + bits--; + s.bl_count[bits]--; // move one leaf down the tree + s.bl_count[bits + 1] = (short) (s.bl_count[bits + 1] + 2); // move one overflow item as its brother + s.bl_count[max_length]--; + // The brother of the overflow item also moves one step up, + // but this does not affect bl_count[max_length] + overflow -= 2; + } + while (overflow > 0); + + for (bits = max_length; bits != 0; bits--) + { + n = s.bl_count[bits]; + while (n != 0) + { + m = s.heap[--h]; + if (m > max_code) + continue; + if (tree[m * 2 + 1] != bits) + { + s.opt_len = (int) (s.opt_len + ((long) bits - (long) tree[m * 2 + 1]) * (long) tree[m * 2]); + tree[m * 2 + 1] = (short) bits; + } + n--; + } + } + } /// /// Construct one Huffman tree and assigns the code bit strings and lengths. @@ -197,85 +212,92 @@ private void gen_bitlen(Deflate s) { /// and corresponding code. The length opt_len is updated; static_len is /// also updated if stree is not null. The field max_code is set. /// - internal void build_tree(Deflate s) { - short[] tree = dyn_tree; - short[] stree = stat_desc.static_tree; - int elems = stat_desc.elems; - int n, m; // iterate over heap elements - int max_code = -1; // largest code with non zero frequency - int node; // new node being created - - // Construct the initial heap, with least frequent element in - // heap[1]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. - // heap[0] is not used. - s.heap_len = 0; - s.heap_max = ZLibUtil.HEAP_SIZE; - - for (n = 0; n < elems; n++) { - if (tree[n * 2] != 0) { - s.heap[++s.heap_len] = max_code = n; - s.depth[n] = 0; - } else { - tree[n * 2 + 1] = 0; - } - } - - // The pkzip format requires that at least one distance code exists, - // and that at least one bit should be sent even if there is only one - // possible code. So to avoid special checks later on we force at least - // two codes of non zero frequency. - while (s.heap_len < 2) { - node = s.heap[++s.heap_len] = (max_code < 2 ? ++max_code : 0); - tree[node * 2] = 1; - s.depth[node] = 0; - s.opt_len--; - if (stree != null) - s.static_len -= stree[node * 2 + 1]; - // node is 0 or 1 so it does not have extra bits - } - this.max_code = max_code; - - // The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, - // establish sub-heaps of increasing lengths: - - for (n = s.heap_len / 2; n >= 1; n--) - s.pqdownheap(tree, n); - - // Construct the Huffman tree by repeatedly combining the least two - // frequent nodes. - - node = elems; // next internal node of the tree - do { - // n = node of least frequency - n = s.heap[1]; - s.heap[1] = s.heap[s.heap_len--]; - s.pqdownheap(tree, 1); - m = s.heap[1]; // m = node of next least frequency - - s.heap[--s.heap_max] = n; // keep the nodes sorted by frequency - s.heap[--s.heap_max] = m; - - // Create a new node father of n and m - tree[node * 2] = (short)(tree[n * 2] + tree[m * 2]); - s.depth[node] = (byte)(System.Math.Max((byte)s.depth[n], (byte)s.depth[m]) + 1); - tree[n * 2 + 1] = tree[m * 2 + 1] = (short)node; - - // and insert the new node in the heap - s.heap[1] = node++; - s.pqdownheap(tree, 1); - } - while (s.heap_len >= 2); - - s.heap[--s.heap_max] = s.heap[1]; - - // At this point, the fields freq and dad are set. We can now - // generate the bit lengths. - - gen_bitlen(s); - - // The field count is now set, we can generate the bit codes - gen_codes(tree, max_code, s.bl_count); - } + internal void build_tree(Deflate s) + { + short[] tree = dyn_tree; + short[] stree = stat_desc.static_tree; + int elems = stat_desc.elems; + int n, m; // iterate over heap elements + int max_code = - 1; // largest code with non zero frequency + int node; // new node being created + + // Construct the initial heap, with least frequent element in + // heap[1]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. + // heap[0] is not used. + s.heap_len = 0; + s.heap_max = ZLibUtil.HEAP_SIZE; + + for (n = 0; n < elems; n++) + { + if (tree[n * 2] != 0) + { + s.heap[++s.heap_len] = max_code = n; + s.depth[n] = 0; + } + else + { + tree[n * 2 + 1] = 0; + } + } + + // The pkzip format requires that at least one distance code exists, + // and that at least one bit should be sent even if there is only one + // possible code. So to avoid special checks later on we force at least + // two codes of non zero frequency. + while (s.heap_len < 2) + { + node = s.heap[++s.heap_len] = (max_code < 2?++max_code:0); + tree[node * 2] = 1; + s.depth[node] = 0; + s.opt_len--; + if (stree != null) + s.static_len -= stree[node * 2 + 1]; + // node is 0 or 1 so it does not have extra bits + } + this.max_code = max_code; + + // The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, + // establish sub-heaps of increasing lengths: + + for (n = s.heap_len / 2; n >= 1; n--) + s.pqdownheap(tree, n); + + // Construct the Huffman tree by repeatedly combining the least two + // frequent nodes. + + node = elems; // next internal node of the tree + do + { + // n = node of least frequency + n = s.heap[1]; + s.heap[1] = s.heap[s.heap_len--]; + s.pqdownheap(tree, 1); + m = s.heap[1]; // m = node of next least frequency + + s.heap[--s.heap_max] = n; // keep the nodes sorted by frequency + s.heap[--s.heap_max] = m; + + // Create a new node father of n and m + tree[node * 2] = (short) (tree[n * 2] + tree[m * 2]); + s.depth[node] = (byte) (System.Math.Max((byte) s.depth[n], (byte) s.depth[m]) + 1); + tree[n * 2 + 1] = tree[m * 2 + 1] = (short) node; + + // and insert the new node in the heap + s.heap[1] = node++; + s.pqdownheap(tree, 1); + } + while (s.heap_len >= 2); + + s.heap[--s.heap_max] = s.heap[1]; + + // At this point, the fields freq and dad are set. We can now + // generate the bit lengths. + + gen_bitlen(s); + + // The field count is now set, we can generate the bit codes + gen_codes(tree, max_code, s.bl_count); + } /// /// Generate the codes for a given tree and bit counts (which need not be @@ -285,43 +307,48 @@ internal void build_tree(Deflate s) { /// OUT assertion: the field code is set for all tree elements of non /// zero code length. /// - private static void gen_codes(short[] tree, int max_code, short[] bl_count) { + private static void gen_codes(short[] tree, int max_code, short[] bl_count) + { short[] next_code = new short[ZLibUtil.MAX_WBITS + 1]; // next code value for each bit length - short code = 0; // running code value - int bits; // bit index - int n; // code index - - // The distribution counts are first used to generate the code values - // without bit reversal. - for (bits = 1; bits <= ZLibUtil.MAX_WBITS; bits++) { - next_code[bits] = code = (short)((code + bl_count[bits - 1]) << 1); - } - - // Check that the bit counts in bl_count are consistent. The last code - // must be all ones. - - for (n = 0; n <= max_code; n++) { - int len = tree[n * 2 + 1]; - if (len == 0) - continue; - // Now reverse the bits - tree[n * 2] = (short)(bi_reverse(next_code[len]++, len)); - } - } + short code = 0; // running code value + int bits; // bit index + int n; // code index + + // The distribution counts are first used to generate the code values + // without bit reversal. + for (bits = 1; bits <= ZLibUtil.MAX_WBITS; bits++) + { + next_code[bits] = code = (short) ((code + bl_count[bits - 1]) << 1); + } + + // Check that the bit counts in bl_count are consistent. The last code + // must be all ones. + + for (n = 0; n <= max_code; n++) + { + int len = tree[n * 2 + 1]; + if (len == 0) + continue; + // Now reverse the bits + tree[n * 2] = (short) (bi_reverse(next_code[len]++, len)); + } + } /// /// Reverse the first count bits of a code, using straightforward code (a faster /// method would use a table) /// - private static int bi_reverse(int code, int len) { - int res = 0; - do { - res |= code & 1; - code = ZLibUtil.URShift(code, 1); - res <<= 1; - } - while (--len > 0); - return ZLibUtil.URShift(res, 1); + private static int bi_reverse(int code, int len) + { + int res = 0; + do + { + res |= code & 1; + code = ZLibUtil.URShift(code, 1); + res <<= 1; + } + while (--len > 0); + return ZLibUtil.URShift(res, 1); } #endregion diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/ZStream.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/ZStream.cs index b264ac549..cb3fde016 100644 --- a/src/ipy/IronPython.Modules/zlib/zlib.net/ZStream.cs +++ b/src/ipy/IronPython.Modules/zlib/zlib.net/ZStream.cs @@ -45,20 +45,22 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma warning disable 419 // msc: Ambiguous reference in cref attribute -namespace ComponentAce.Compression.Libs.ZLib { +namespace ComponentAce.Compression.Libs.ZLib +{ /// /// ZStream is used to store user data to compress/decompress. /// - public sealed class ZStream { + public sealed class ZStream + { #region Constants - + private const int DEF_WBITS = ZLibUtil.MAX_WBITS; #endregion #region Fields - + /// /// Next input byte array /// @@ -73,7 +75,7 @@ public sealed class ZStream { /// Number of bytes available at _next_in /// private int _avail_in; - + /// /// total nb of input bytes ReadPos so far /// @@ -131,7 +133,8 @@ public sealed class ZStream { /// /// Gets/Sets the next input byte array. /// - public byte[] next_in { + public byte[] next_in + { get { return _next_in; } set { _next_in = value; } } @@ -139,7 +142,8 @@ public byte[] next_in { /// /// Index of the first byte in the input array. /// - public int next_in_index { + public int next_in_index + { get { return _next_in_index; } set { _next_in_index = value; } } @@ -147,7 +151,8 @@ public int next_in_index { /// /// Gets/Sets the number of bytes available in the input buffer. /// - public int avail_in { + public int avail_in + { get { return _avail_in; } set { _avail_in = value; } } @@ -155,7 +160,8 @@ public int avail_in { /// /// Gets/Sets the total number of bytes in the input buffer. /// - public long total_in { + public long total_in + { get { return _total_in; } set { _total_in = value; } } @@ -163,7 +169,8 @@ public long total_in { /// /// Gets/Sets the buffer for the next output data. /// - public byte[] next_out { + public byte[] next_out + { get { return _next_out; } set { _next_out = value; } } @@ -171,7 +178,8 @@ public byte[] next_out { /// /// Gets/Sets the index of the first byte in the byte array to write to. /// - public int next_out_index { + public int next_out_index + { get { return _next_out_index; } set { _next_out_index = value; } } @@ -179,7 +187,8 @@ public int next_out_index { /// /// Gets/Sets the remaining free space in the buffer. /// - public int avail_out { + public int avail_out + { get { return _avail_out; } set { _avail_out = value; } } @@ -187,7 +196,8 @@ public int avail_out { /// /// Gets/Sets the total number of bytes in the output array. /// - public long total_out { + public long total_out + { get { return _total_out; } set { _total_out = value; } } @@ -195,7 +205,8 @@ public long total_out { /// /// Gets sets the last error message occurred during class operations. /// - public string msg { + public string msg + { get { return _msg; } set { _msg = value; } } @@ -203,7 +214,8 @@ public string msg { /// /// A deflate object to perform data compression /// - internal Deflate dstate { + internal Deflate dstate + { get { return _dstate; } set { _dstate = value; } } @@ -211,7 +223,8 @@ internal Deflate dstate { /// /// Inflate object to perform data decompression /// - internal Inflate istate { + internal Inflate istate + { get { return _istate; } set { _istate = value; } } @@ -238,9 +251,10 @@ public bool IsInitialized { /// apart from reading the ZLib header if present: this will be done by . (So and /// may be modified, but and are unchanged.) /// - public int inflateInit() { - return inflateInit(DEF_WBITS); - } + public int inflateInit() + { + return inflateInit(DEF_WBITS); + } /// /// This is another version of with an extra parameter. The fields , must be @@ -260,11 +274,12 @@ public int inflateInit() { /// if present: this will be done by . (So and may be modified, /// but and are unchanged.) /// - public int inflateInit(int windowBits) { - _istate = new Inflate(); - return _istate.inflateInit(this, windowBits); - } - + public int inflateInit(int windowBits) + { + _istate = new Inflate(); + return _istate.inflateInit(this, windowBits); + } + /// /// This method decompresses as much data as possible, and stops when the input buffer () becomes empty or /// the output buffer () becomes full. It may some introduce some output latency (reading input without producing any output) @@ -317,11 +332,12 @@ public int inflateInit(int windowBits) { /// when is used. In the case, the application /// may then call to look for a good compression block. /// - public int inflate(FlushStrategy flush) { - if (_istate == null) - return (int)ZLibResultCode.Z_STREAM_ERROR; - return _istate.inflate(this, flush); - } + public int inflate(FlushStrategy flush) + { + if (_istate == null) + return (int)ZLibResultCode.Z_STREAM_ERROR; + return _istate.inflate(this, flush); + } /// /// All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any @@ -331,16 +347,17 @@ public int inflate(FlushStrategy flush) { /// inflateEnd returns if success, /// if the stream state was inconsistent. In the error case, msg may be set but then points to a static string (which must not be deallocated). /// - public int inflateEnd() { - next_in_index = 0; - next_out_index = 0; - - if (_istate == null) - return (int)ZLibResultCode.Z_STREAM_ERROR; - int ret = _istate.inflateEnd(this); - _istate = null; - return ret; - } + public int inflateEnd() + { + next_in_index = 0; + next_out_index = 0; + + if (_istate == null) + return (int)ZLibResultCode.Z_STREAM_ERROR; + int ret = _istate.inflateEnd(this); + _istate = null; + return ret; + } /// /// Skips invalid compressed data until a full flush point (see the description of deflate with Z_FULL_FLUSH) can be found, @@ -353,11 +370,12 @@ public int inflateEnd() { /// current value of which indicates where valid compressed data was found. In the error case, the application may repeatedly /// call , providing more input each time, until success or end of the input data. /// - public int inflateSync() { - if (_istate == null) - return (int)ZLibResultCode.Z_STREAM_ERROR; - return _istate.inflateSync(this); - } + public int inflateSync() + { + if (_istate == null) + return (int)ZLibResultCode.Z_STREAM_ERROR; + return _istate.inflateSync(this); + } /// /// Initializes the decompression dictionary from the given uncompressed byte sequence. This function must be called immediately after a call of if this call returned . The dictionary chosen by the compressor can be determined from the Adler32 value returned by this call of . The compressor and decompresser must use exactly the same dictionary. @@ -367,11 +385,12 @@ public int inflateSync() { /// /// inflateSetDictionary returns if success, if a parameter is invalid (such as null dictionary) or the stream state is inconsistent, if the given dictionary doesn't match the expected one (incorrect Adler32 value). inflateSetDictionary does not perform any decompression: this will be done by subsequent calls of . /// - public int inflateSetDictionary(byte[] dictionary, int dictLength) { - if (_istate == null) - return (int)ZLibResultCode.Z_STREAM_ERROR; - return _istate.inflateSetDictionary(this, dictionary, dictLength); - } + public int inflateSetDictionary(byte[] dictionary, int dictLength) + { + if (_istate == null) + return (int)ZLibResultCode.Z_STREAM_ERROR; + return _istate.inflateSetDictionary(this, dictionary, dictLength); + } /// /// Initializes the internal stream state for compression. @@ -382,9 +401,10 @@ public int inflateSetDictionary(byte[] dictionary, int dictLength) { /// if level is not a valid compression level. is set to null if there is /// no error message. does not perform any compression: this will be done by . /// - public int DeflateInit(int level) { - return DeflateInit(level, ZLibUtil.MAX_WBITS); - } + public int DeflateInit(int level) + { + return DeflateInit(level, ZLibUtil.MAX_WBITS); + } /// /// Initializes the internal stream state for compression. @@ -398,10 +418,11 @@ public int DeflateInit(int level) { /// if level is not a valid compression level. is set to null if there /// is no error message. does not perform any compression: this will be done by . /// - public int DeflateInit(int level, int bits) { - _dstate = new Deflate(); - return _dstate.DeflateInit(this, level, bits); - } + public int DeflateInit(int level, int bits) + { + _dstate = new Deflate(); + return _dstate.DeflateInit(this, level, bits); + } public int DeflateInit(int level, int windowBits, int memLevel, CompressionStrategy strategy) { _dstate = new Deflate(); @@ -410,7 +431,7 @@ public int DeflateInit(int level, int windowBits, int memLevel, CompressionStrat public int reset() { if (_dstate != null) { - return _dstate.deflateReset(this); + return _dstate.deflateReset(this); } if (_istate != null) { @@ -489,12 +510,14 @@ public int reset() { /// (for example or was zero). /// /// - public int deflate(FlushStrategy flush) { - if (_dstate == null) { - return (int)ZLibResultCode.Z_STREAM_ERROR; - } - return _dstate.deflate(this, flush); - } + public int deflate(FlushStrategy flush) + { + if (_dstate == null) + { + return (int)ZLibResultCode.Z_STREAM_ERROR; + } + return _dstate.deflate(this, flush); + } /// /// All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending @@ -505,16 +528,17 @@ public int deflate(FlushStrategy flush) { /// if the stream was freed prematurely (some input or output was discarded). In the error case, /// may be set but then points to a static string (which must not be deallocated). /// - public int deflateEnd() { - next_in_index = 0; - next_out_index = 0; - - if (_dstate == null) - return (int)ZLibResultCode.Z_STREAM_ERROR; - int ret = _dstate.deflateEnd(); - _dstate = null; - return ret; - } + public int deflateEnd() + { + next_in_index = 0; + next_out_index = 0; + + if (_dstate == null) + return (int)ZLibResultCode.Z_STREAM_ERROR; + int ret = _dstate.deflateEnd(); + _dstate = null; + return ret; + } /// /// Dynamically update the compression level and compression strategy. The interpretation of level is as in . @@ -532,11 +556,12 @@ public int deflateEnd() { /// deflateParams returns if success, if the source stream /// state was inconsistent or if a parameter was invalid, if was zero. /// - public int deflateParams(int level, CompressionStrategy strategy) { - if (_dstate == null) - return (int)ZLibResultCode.Z_STREAM_ERROR; - return _dstate.deflateParams(this, level, strategy); - } + public int deflateParams(int level, CompressionStrategy strategy) + { + if (_dstate == null) + return (int)ZLibResultCode.Z_STREAM_ERROR; + return _dstate.deflateParams(this, level, strategy); + } /// /// Initializes the compression dictionary from the given byte sequence without producing any compressed output. This function must be called @@ -564,65 +589,71 @@ public int deflateParams(int level, CompressionStrategy strategy) { /// called for this stream or if the compression method is bsort). does not perform any compression: /// this will be done by . /// - public int deflateSetDictionary(byte[] dictionary, int dictLength) { - if (_dstate == null) - return (int)ZLibResultCode.Z_STREAM_ERROR; - return _dstate.deflateSetDictionary(this, dictionary, dictLength); - } + public int deflateSetDictionary(byte[] dictionary, int dictLength) + { + if (_dstate == null) + return (int)ZLibResultCode.Z_STREAM_ERROR; + return _dstate.deflateSetDictionary(this, dictionary, dictLength); + } /// /// Flush as much pending output as possible. All output goes through this function so some applications may wish to /// modify it to avoid allocating a large buffer and copying into it. /// /// - public void FlushPending() { - int len = _dstate.Pending; - - if (len > _avail_out) - len = _avail_out; - if (len == 0) - return; - - Array.Copy(_dstate.Pending_buf, _dstate.Pending_out, _next_out, _next_out_index, len); - - _next_out_index += len; - _dstate.Pending_out += len; - _total_out += len; - _avail_out -= len; - _dstate.Pending -= len; - if (_dstate.Pending == 0) { - _dstate.Pending_out = 0; - } - } + public void FlushPending() + { + int len = _dstate.Pending; + + if (len > _avail_out) + len = _avail_out; + if (len == 0) + return ; + + Array.Copy(_dstate.Pending_buf, _dstate.Pending_out, _next_out, _next_out_index, len); + + _next_out_index += len; + _dstate.Pending_out += len; + _total_out += len; + _avail_out -= len; + _dstate.Pending -= len; + if (_dstate.Pending == 0) + { + _dstate.Pending_out = 0; + } + } /// /// Read a new buffer from the current input stream, update the adler32 and total number of bytes read. All input goes /// through this function so some applications may wish to modify it to avoid allocating a large buffer and copying from it. /// /// - public int ReadBuf(byte[] buf, int start, int size) { - int len = _avail_in; - - if (len > size) - len = size; - if (len == 0) - return 0; - - _avail_in -= len; - - if (_dstate.NoHeader == 0) { - adler = Adler32.GetAdler32Checksum(adler, _next_in, _next_in_index, len); - } - Array.Copy(_next_in, _next_in_index, buf, start, len); - _next_in_index += len; - _total_in += len; - return len; - } + public int ReadBuf(byte[] buf, int start, int size) + { + int len = _avail_in; + + if (len > size) + len = size; + if (len == 0) + return 0; + + _avail_in -= len; + + if (_dstate.NoHeader == 0) + { + adler = Adler32.GetAdler32Checksum(adler, _next_in, _next_in_index, len); + } + Array.Copy(_next_in, _next_in_index, buf, start, len); + _next_in_index += len; + _total_in += len; + return len; + } /// /// Frees all inner buffers. /// - public void free() { + public void free() + { _next_in = null; _next_out = null; _msg = null; diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/ZStreamException.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/ZStreamException.cs index 9a128c5e9..e0204d4b0 100644 --- a/src/ipy/IronPython.Modules/zlib/zlib.net/ZStreamException.cs +++ b/src/ipy/IronPython.Modules/zlib/zlib.net/ZStreamException.cs @@ -42,23 +42,27 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * and contributors of zlib. */ -namespace ComponentAce.Compression.Libs.ZLib { - /// - /// Exceptions that occur in ZStream - /// - public class ZStreamException : System.IO.IOException { +namespace ComponentAce.Compression.Libs.ZLib +{ + /// + /// Exceptions that occur in ZStream + /// + public class ZStreamException : System.IO.IOException + { /// /// Default constructor. /// public ZStreamException() - : base() { - } - + :base() + { + } + /// /// Constructor which takes one parameter - an error message /// - public ZStreamException(System.String s) - : base(s) { - } - } + public ZStreamException(System.String s) + :base(s) + { + } + } } \ No newline at end of file diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/Zlib.cs b/src/ipy/IronPython.Modules/zlib/zlib.net/Zlib.cs index ec1760997..129d5647c 100644 --- a/src/ipy/IronPython.Modules/zlib/zlib.net/Zlib.cs +++ b/src/ipy/IronPython.Modules/zlib/zlib.net/Zlib.cs @@ -44,11 +44,13 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using System; using System.Text; -namespace ComponentAce.Compression.Libs.ZLib { +namespace ComponentAce.Compression.Libs.ZLib +{ /// /// Some constants for specifying compression levels. Methods which takes a compression level as a parameter expects an integer value from 0 to 9. You can either specify an integer value or use constants for some most widely used compression levels. /// - public static class ZLibCompressionLevel { + public static class ZLibCompressionLevel + { /// /// No compression should be used at all. /// @@ -70,7 +72,8 @@ public static class ZLibCompressionLevel { /// /// Compression strategies. The strategy parameter is used to tune the compression algorithm. The strategy parameter only affects the compression ratio but not the correctness of the compressed output even if it is not set appropriately. /// - public enum CompressionStrategy { + public enum CompressionStrategy + { /// /// This strategy is designed for filtered data. Data which consists of mostly small values, with random distribution should use Z_FILTERED. With this strategy, less string matching is performed. /// @@ -88,7 +91,8 @@ public enum CompressionStrategy { /// /// Flush strategies /// - public enum FlushStrategy { + public enum FlushStrategy + { /// /// Do not internalFlush data, but just write data as normal to the output buffer. This is the normal way in which data is written to the output buffer. /// @@ -114,7 +118,8 @@ public enum FlushStrategy { /// /// Results of operations in ZLib library /// - public enum ZLibResultCode { + public enum ZLibResultCode + { /// /// No failure was encountered, the operation completed without problem. /// @@ -130,33 +135,34 @@ public enum ZLibResultCode { /// /// An internal error occurred /// - Z_ERRNO = -1, + Z_ERRNO = - 1, /// /// The stream structure was inconsistent /// - Z_STREAM_ERROR = -2, + Z_STREAM_ERROR = - 2, /// /// Input data has been corrupted (for decompression). /// - Z_DATA_ERROR = -3, + Z_DATA_ERROR = - 3, /// /// Memory allocation failed. /// - Z_MEM_ERROR = -4, + Z_MEM_ERROR = - 4, /// /// There was not enough space in the output buffer. /// - Z_BUF_ERROR = -5, + Z_BUF_ERROR = - 5, /// /// The version supplied does not match that supported by the ZLib module. /// - Z_VERSION_ERROR = -6 + Z_VERSION_ERROR = - 6 } /// /// States of deflate operation /// - internal enum DeflateState { + internal enum DeflateState + { INIT_STATE = 42, BUSY_STATE = 113, FINISH_STATE = 666 @@ -165,7 +171,8 @@ internal enum DeflateState { /// /// Data block types, i.e. binary or ascii text /// - public enum BlockType { + public enum BlockType + { Z_BINARY = 0, Z_ASCII = 1, Z_UNKNOWN = 2 @@ -174,10 +181,12 @@ public enum BlockType { /// /// Helper class /// - public static class ZLibUtil { + public static class ZLibUtil + { #region Copy large array to a small one in several steps - internal class CopyLargeArrayToSmall { + internal class CopyLargeArrayToSmall + { private static byte[] srcBuf; private static int srcOff; @@ -187,7 +196,8 @@ internal class CopyLargeArrayToSmall { private static int destLen; private static int nWritten; - public static void Initialize(byte[] srcBuf, int srcOff, int srcDataLen, byte[] destBuff, int destOff, int destLen) { + public static void Initialize(byte[] srcBuf, int srcOff, int srcDataLen, byte[] destBuff, int destOff, int destLen) + { ZLibUtil.CopyLargeArrayToSmall.srcBuf = srcBuf; ZLibUtil.CopyLargeArrayToSmall.srcOff = srcOff; ZLibUtil.CopyLargeArrayToSmall.srcDataLen = srcDataLen; @@ -196,21 +206,25 @@ public static void Initialize(byte[] srcBuf, int srcOff, int srcDataLen, byte[] ZLibUtil.CopyLargeArrayToSmall.destLen = destLen; ZLibUtil.CopyLargeArrayToSmall.nWritten = 0; } - + public static int GetRemainingDataSize() { return srcDataLen; } /// /// Copies large array which was passed as srcBuf to the Initialize method into the destination array which were passes as destBuff /// /// The number of bytes copied - public static int CopyData() { - if (srcDataLen > destLen) { + public static int CopyData() + { + if (srcDataLen > destLen) + { Array.Copy(srcBuf, srcOff, destBuff, destOff, destLen); srcDataLen -= destLen; srcOff += destLen; nWritten = destLen; return nWritten; - } else { + } + else + { Array.Copy(srcBuf, srcOff, destBuff, destOff, srcDataLen); nWritten = srcDataLen; srcDataLen = 0; @@ -254,146 +268,158 @@ public static int CopyData() { /// /// The literal to return /// The received value - internal static long Identity(long literal) { - return literal; - } - - /// - /// This method returns the literal value received - /// - /// The literal to return - /// The received value - internal static ulong Identity(ulong literal) { - return literal; - } - - /// - /// This method returns the literal value received - /// - /// The literal to return - /// The received value - internal static float Identity(float literal) { - return literal; - } - - /// - /// This method returns the literal value received - /// - /// The literal to return - /// The received value - internal static double Identity(double literal) { - return literal; - } - - /*******************************/ - /// - /// Performs an unsigned bitwise right shift with the specified number - /// - /// Number to operate on - /// Ammount of bits to shift - /// The resulting number from the shift operation - internal static int URShift(int number, int bits) { - if (number >= 0) - return number >> bits; - else - return (number >> bits) + (2 << ~bits); - } - - /// - /// Performs an unsigned bitwise right shift with the specified number - /// - /// Number to operate on - /// Ammount of bits to shift - /// The resulting number from the shift operation - internal static int URShift(int number, long bits) { - return URShift(number, (int)bits); - } - - /// - /// Performs an unsigned bitwise right shift with the specified number - /// - /// Number to operate on - /// Ammount of bits to shift - /// The resulting number from the shift operation - internal static long URShift(long number, int bits) { - if (number >= 0) - return number >> bits; - else - return (number >> bits) + (2L << ~bits); - } - - /// - /// Performs an unsigned bitwise right shift with the specified number - /// - /// Number to operate on - /// Ammount of bits to shift - /// The resulting number from the shift operation - internal static long URShift(long number, long bits) { - return URShift(number, (int)bits); - } + internal static long Identity(long literal) + { + return literal; + } - /*******************************/ - /// Reads a number of characters from the current source Stream and writes the data to the target array at the specified index. - /// The source Stream to ReadPos from. - /// Contains the array of characters ReadPos from the source Stream. - /// The starting index of the target array. - /// The maximum number of characters to ReadPos from the source Stream. - /// The number of characters ReadPos. The number will be less than or equal to count depending on the data available in the source Stream. Returns -1 if the End of the stream is reached. - internal static System.Int32 ReadInput(System.IO.Stream sourceStream, byte[] target, int start, int count) { - // Returns 0 bytes if not enough space in target - if (target.Length == 0) - return 0; - - byte[] receiver = new byte[target.Length]; - int bytesRead = sourceStream.Read(receiver, start, count); - - // Returns -1 if EOF - if (bytesRead == 0) - return -1; - - for (int i = start; i < start + bytesRead; i++) - target[i] = (byte)receiver[i]; - - return bytesRead; - } - - /// Reads a number of characters from the current source TextReader and writes the data to the target array at the specified index. - /// The source TextReader to ReadPos from - /// Contains the array of characteres ReadPos from the source TextReader. - /// The starting index of the target array. - /// The maximum number of characters to ReadPos from the source TextReader. - /// The number of characters ReadPos. The number will be less than or equal to count depending on the data available in the source TextReader. Returns -1 if the End of the stream is reached. - internal static System.Int32 ReadInput(System.IO.TextReader sourceTextReader, byte[] target, int start, int count) { - // Returns 0 bytes if not enough space in target - if (target.Length == 0) return 0; - - char[] charArray = new char[target.Length]; - int bytesRead = sourceTextReader.Read(charArray, start, count); - - // Returns -1 if EOF - if (bytesRead == 0) return -1; - - for (int index = start; index < start + bytesRead; index++) - target[index] = (byte)charArray[index]; - - return bytesRead; - } + /// + /// This method returns the literal value received + /// + /// The literal to return + /// The received value + internal static ulong Identity(ulong literal) + { + return literal; + } - /// - /// Converts a string to an array of bytes - /// - /// The string to be converted - /// The new array of bytes - internal static byte[] ToByteArray(string sourceString) { - return Encoding.UTF8.GetBytes(sourceString); - } + /// + /// This method returns the literal value received + /// + /// The literal to return + /// The received value + internal static float Identity(float literal) + { + return literal; + } - /// - /// Converts an array of bytes to an array of chars - /// - /// The array of bytes to convert - /// The new array of chars - internal static char[] ToCharArray(byte[] byteArray) { + /// + /// This method returns the literal value received + /// + /// The literal to return + /// The received value + internal static double Identity(double literal) + { + return literal; + } + + /*******************************/ + /// + /// Performs an unsigned bitwise right shift with the specified number + /// + /// Number to operate on + /// Ammount of bits to shift + /// The resulting number from the shift operation + internal static int URShift(int number, int bits) + { + if ( number >= 0) + return number >> bits; + else + return (number >> bits) + (2 << ~bits); + } + + /// + /// Performs an unsigned bitwise right shift with the specified number + /// + /// Number to operate on + /// Ammount of bits to shift + /// The resulting number from the shift operation + internal static int URShift(int number, long bits) + { + return URShift(number, (int)bits); + } + + /// + /// Performs an unsigned bitwise right shift with the specified number + /// + /// Number to operate on + /// Ammount of bits to shift + /// The resulting number from the shift operation + internal static long URShift(long number, int bits) + { + if ( number >= 0) + return number >> bits; + else + return (number >> bits) + (2L << ~bits); + } + + /// + /// Performs an unsigned bitwise right shift with the specified number + /// + /// Number to operate on + /// Ammount of bits to shift + /// The resulting number from the shift operation + internal static long URShift(long number, long bits) + { + return URShift(number, (int)bits); + } + + /*******************************/ + /// Reads a number of characters from the current source Stream and writes the data to the target array at the specified index. + /// The source Stream to ReadPos from. + /// Contains the array of characters ReadPos from the source Stream. + /// The starting index of the target array. + /// The maximum number of characters to ReadPos from the source Stream. + /// The number of characters ReadPos. The number will be less than or equal to count depending on the data available in the source Stream. Returns -1 if the End of the stream is reached. + internal static System.Int32 ReadInput(System.IO.Stream sourceStream, byte[] target, int start, int count) + { + // Returns 0 bytes if not enough space in target + if (target.Length == 0) + return 0; + + byte[] receiver = new byte[target.Length]; + int bytesRead = sourceStream.Read(receiver, start, count); + + // Returns -1 if EOF + if (bytesRead == 0) + return -1; + + for(int i = start; i < start + bytesRead; i++) + target[i] = (byte)receiver[i]; + + return bytesRead; + } + + /// Reads a number of characters from the current source TextReader and writes the data to the target array at the specified index. + /// The source TextReader to ReadPos from + /// Contains the array of characteres ReadPos from the source TextReader. + /// The starting index of the target array. + /// The maximum number of characters to ReadPos from the source TextReader. + /// The number of characters ReadPos. The number will be less than or equal to count depending on the data available in the source TextReader. Returns -1 if the End of the stream is reached. + internal static System.Int32 ReadInput(System.IO.TextReader sourceTextReader, byte[] target, int start, int count) + { + // Returns 0 bytes if not enough space in target + if (target.Length == 0) return 0; + + char[] charArray = new char[target.Length]; + int bytesRead = sourceTextReader.Read(charArray, start, count); + + // Returns -1 if EOF + if (bytesRead == 0) return -1; + + for(int index=start; index + /// Converts a string to an array of bytes + /// + /// The string to be converted + /// The new array of bytes + internal static byte[] ToByteArray(string sourceString) + { + return Encoding.UTF8.GetBytes(sourceString); + } + + /// + /// Converts an array of bytes to an array of chars + /// + /// The array of bytes to convert + /// The new array of chars + internal static char[] ToCharArray(byte[] byteArray) + { return Encoding.UTF8.GetChars(byteArray); } @@ -450,8 +476,8 @@ internal static char[] ToCharArray(byte[] byteArray) { /// internal const int DIST_CODE_LEN = 512; - internal static readonly byte[] _dist_code = new byte[]{0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29}; + internal static readonly byte[] _dist_code = new byte[]{0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29}; internal static readonly byte[] _length_code = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 }; diff --git a/src/ipy/IronPython/Compiler/Ast/AndExpression.cs b/src/ipy/IronPython/Compiler/Ast/AndExpression.cs index b13ca49ff..2c9326091 100644 --- a/src/ipy/IronPython/Compiler/Ast/AndExpression.cs +++ b/src/ipy/IronPython/Compiler/Ast/AndExpression.cs @@ -5,7 +5,6 @@ #nullable enable using System; - using Microsoft.Scripting.Actions; using Microsoft.Scripting.Utils; diff --git a/src/ipy/IronPython/Compiler/Ast/AssertStatement.cs b/src/ipy/IronPython/Compiler/Ast/AssertStatement.cs index 5e9800e31..7eb7226c5 100644 --- a/src/ipy/IronPython/Compiler/Ast/AssertStatement.cs +++ b/src/ipy/IronPython/Compiler/Ast/AssertStatement.cs @@ -2,14 +2,15 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using AstUtils = Microsoft.Scripting.Ast.Utils; using MSAst = System.Linq.Expressions; +using AstUtils = Microsoft.Scripting.Ast.Utils; + namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; public class AssertStatement : Statement { - + public AssertStatement(Expression test, Expression message) { Test = test; Message = message; diff --git a/src/ipy/IronPython/Compiler/Ast/AssignmentStatement.cs b/src/ipy/IronPython/Compiler/Ast/AssignmentStatement.cs index ac8f773d0..7f01bfdda 100644 --- a/src/ipy/IronPython/Compiler/Ast/AssignmentStatement.cs +++ b/src/ipy/IronPython/Compiler/Ast/AssignmentStatement.cs @@ -2,16 +2,19 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using Microsoft.Scripting; + using IronPython.Runtime.Binding; +using IronPython.Runtime.Operations; -using Microsoft.Scripting; +using MSAst = System.Linq.Expressions; using AstUtils = Microsoft.Scripting.Ast.Utils; -using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; @@ -91,7 +94,7 @@ private MSAst.Expression AssignOne() { if (!isStarred && seLeft != null && seRight != null && seLeft.Items.Count == seRight.Items.Count) { int cnt = seLeft.Items.Count; - + // a, b = 1, 2, or [a,b] = 1,2 - not something like a, b = range(2) // we can do a fast parallel assignment MSAst.ParameterExpression[] tmps = new MSAst.ParameterExpression[cnt]; @@ -118,7 +121,7 @@ private MSAst.Expression AssignOne() { for (int i = 0; i < cnt; i++) { body[i + cnt] = seLeft.Items[i].TransformSet(SourceSpan.None, tmps[i], PythonOperationKind.None); } - + // 4. Create and return the resulting suite body[cnt * 2] = AstUtils.Empty(); return GlobalParent.AddDebugInfoAndVoid(Ast.Block(tmps, body), Span); diff --git a/src/ipy/IronPython/Compiler/Ast/AstMethods.cs b/src/ipy/IronPython/Compiler/Ast/AstMethods.cs index 34c621912..da27a5ab0 100644 --- a/src/ipy/IronPython/Compiler/Ast/AstMethods.cs +++ b/src/ipy/IronPython/Compiler/Ast/AstMethods.cs @@ -7,10 +7,12 @@ using System.Collections.Generic; using System.Reflection; +using Microsoft.Scripting; +using Microsoft.Scripting.Utils; + using IronPython.Runtime; using IronPython.Runtime.Operations; - -using Microsoft.Scripting; +using IronPython.Runtime.Types; namespace IronPython.Compiler.Ast { internal static class AstMethods { diff --git a/src/ipy/IronPython/Compiler/Ast/AugmentedAssignStatement.cs b/src/ipy/IronPython/Compiler/Ast/AugmentedAssignStatement.cs index e09a73833..a5af34796 100644 --- a/src/ipy/IronPython/Compiler/Ast/AugmentedAssignStatement.cs +++ b/src/ipy/IronPython/Compiler/Ast/AugmentedAssignStatement.cs @@ -2,12 +2,11 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Diagnostics; +using MSAst = System.Linq.Expressions; +using System.Diagnostics; using IronPython.Runtime.Binding; -using MSAst = System.Linq.Expressions; - namespace IronPython.Compiler.Ast { public class AugmentedAssignStatement : Statement { public AugmentedAssignStatement(PythonOperator op, Expression left, Expression right) { diff --git a/src/ipy/IronPython/Compiler/Ast/BinaryExpression.cs b/src/ipy/IronPython/Compiler/Ast/BinaryExpression.cs index ea20a9a66..83cce7e94 100644 --- a/src/ipy/IronPython/Compiler/Ast/BinaryExpression.cs +++ b/src/ipy/IronPython/Compiler/Ast/BinaryExpression.cs @@ -2,23 +2,25 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using MSAst = System.Linq.Expressions; + +using System; using System.Diagnostics; using System.Reflection; -using IronPython.Runtime.Binding; -using IronPython.Runtime.Exceptions; -using IronPython.Runtime.Operations; - using Microsoft.Scripting; using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Exceptions; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Binding; + using AstUtils = Microsoft.Scripting.Ast.Utils; -using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; - + public partial class BinaryExpression : Expression, IInstructionProvider { public BinaryExpression(PythonOperator op, Expression left, Expression right) { ContractUtils.RequiresNotNull(left, nameof(left)); diff --git a/src/ipy/IronPython/Compiler/Ast/BreakStatement.cs b/src/ipy/IronPython/Compiler/Ast/BreakStatement.cs index f65cb6d85..68e3188e5 100644 --- a/src/ipy/IronPython/Compiler/Ast/BreakStatement.cs +++ b/src/ipy/IronPython/Compiler/Ast/BreakStatement.cs @@ -4,6 +4,8 @@ using MSAst = System.Linq.Expressions; +using AstUtils = Microsoft.Scripting.Ast.Utils; + namespace IronPython.Compiler.Ast { public class BreakStatement : Statement { diff --git a/src/ipy/IronPython/Compiler/Ast/ClassDefinition.cs b/src/ipy/IronPython/Compiler/Ast/ClassDefinition.cs index 5a6e72db3..1b126d4fe 100644 --- a/src/ipy/IronPython/Compiler/Ast/ClassDefinition.cs +++ b/src/ipy/IronPython/Compiler/Ast/ClassDefinition.cs @@ -15,6 +15,7 @@ using IronPython.Runtime; using Microsoft.Scripting; +using Microsoft.Scripting.Actions; using Microsoft.Scripting.Utils; using AstUtils = Microsoft.Scripting.Ast.Utils; diff --git a/src/ipy/IronPython/Compiler/Ast/Comprehension.cs b/src/ipy/IronPython/Compiler/Ast/Comprehension.cs index 26b04aebd..848ea2efd 100644 --- a/src/ipy/IronPython/Compiler/Ast/Comprehension.cs +++ b/src/ipy/IronPython/Compiler/Ast/Comprehension.cs @@ -8,13 +8,14 @@ using System.Reflection; using System.Runtime.CompilerServices; +using Microsoft.Scripting; + using IronPython.Runtime; using IronPython.Runtime.Operations; -using Microsoft.Scripting; +using MSAst = System.Linq.Expressions; using AstUtils = Microsoft.Scripting.Ast.Utils; -using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; @@ -344,7 +345,7 @@ internal Ast AddVariables(Ast expression) { body.Add(expression); return Expression.Block( - locals, + locals, body ); } diff --git a/src/ipy/IronPython/Compiler/Ast/ComprehensionFor.cs b/src/ipy/IronPython/Compiler/Ast/ComprehensionFor.cs index 5d98f4e16..5cd656b30 100644 --- a/src/ipy/IronPython/Compiler/Ast/ComprehensionFor.cs +++ b/src/ipy/IronPython/Compiler/Ast/ComprehensionFor.cs @@ -2,12 +2,12 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using MSAst = System.Linq.Expressions; + using System; using System.Collections; using System.Collections.Generic; -using MSAst = System.Linq.Expressions; - namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/src/ipy/IronPython/Compiler/Ast/ComprehensionIf.cs b/src/ipy/IronPython/Compiler/Ast/ComprehensionIf.cs index 3ffab849a..6ddf8ac69 100644 --- a/src/ipy/IronPython/Compiler/Ast/ComprehensionIf.cs +++ b/src/ipy/IronPython/Compiler/Ast/ComprehensionIf.cs @@ -2,12 +2,15 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using MSAst = System.Linq.Expressions; + using Microsoft.Scripting.Actions; using AstUtils = Microsoft.Scripting.Ast.Utils; -using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { + using Ast = MSAst.Expression; + public class ComprehensionIf : ComprehensionIterator { public ComprehensionIf(Expression test) { Test = test; diff --git a/src/ipy/IronPython/Compiler/Ast/ConditionalExpression.cs b/src/ipy/IronPython/Compiler/Ast/ConditionalExpression.cs index 03ec2ec23..59ece32e3 100644 --- a/src/ipy/IronPython/Compiler/Ast/ConditionalExpression.cs +++ b/src/ipy/IronPython/Compiler/Ast/ConditionalExpression.cs @@ -2,10 +2,10 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using Microsoft.Scripting.Actions; - using MSAst = System.Linq.Expressions; +using Microsoft.Scripting.Actions; + namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -31,7 +31,7 @@ public override MSAst.Expression Reduce() { return Ast.Condition( GlobalParent.Convert(typeof(bool), ConversionResultKind.ExplicitCast, Test), - ifTrue, + ifTrue, ifFalse ); } diff --git a/src/ipy/IronPython/Compiler/Ast/ConstantExpression.cs b/src/ipy/IronPython/Compiler/Ast/ConstantExpression.cs index 4807073ee..10ca0b1c9 100644 --- a/src/ipy/IronPython/Compiler/Ast/ConstantExpression.cs +++ b/src/ipy/IronPython/Compiler/Ast/ConstantExpression.cs @@ -4,13 +4,14 @@ using System; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Runtime; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + using MSAst = System.Linq.Expressions; +using AstUtils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/src/ipy/IronPython/Compiler/Ast/ContinueStatement.cs b/src/ipy/IronPython/Compiler/Ast/ContinueStatement.cs index 6aa81fcfd..d8e0da140 100644 --- a/src/ipy/IronPython/Compiler/Ast/ContinueStatement.cs +++ b/src/ipy/IronPython/Compiler/Ast/ContinueStatement.cs @@ -4,6 +4,8 @@ using MSAst = System.Linq.Expressions; +using AstUtils = Microsoft.Scripting.Ast.Utils; + namespace IronPython.Compiler.Ast { public class ContinueStatement : Statement { diff --git a/src/ipy/IronPython/Compiler/Ast/DelStatement.cs b/src/ipy/IronPython/Compiler/Ast/DelStatement.cs index f63e8a716..121430d46 100644 --- a/src/ipy/IronPython/Compiler/Ast/DelStatement.cs +++ b/src/ipy/IronPython/Compiler/Ast/DelStatement.cs @@ -2,11 +2,11 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using MSAst = System.Linq.Expressions; + using System.Collections.Generic; using System.Runtime.CompilerServices; - using AstUtils = Microsoft.Scripting.Ast.Utils; -using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { diff --git a/src/ipy/IronPython/Compiler/Ast/DottedName.cs b/src/ipy/IronPython/Compiler/Ast/DottedName.cs index 4a4b7d3d0..a8246688a 100644 --- a/src/ipy/IronPython/Compiler/Ast/DottedName.cs +++ b/src/ipy/IronPython/Compiler/Ast/DottedName.cs @@ -2,7 +2,9 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; using System.Collections.Generic; +using Microsoft.Scripting; using System.Text; namespace IronPython.Compiler.Ast { diff --git a/src/ipy/IronPython/Compiler/Ast/DynamicConvertExpression.cs b/src/ipy/IronPython/Compiler/Ast/DynamicConvertExpression.cs index 56836032c..34446a18d 100644 --- a/src/ipy/IronPython/Compiler/Ast/DynamicConvertExpression.cs +++ b/src/ipy/IronPython/Compiler/Ast/DynamicConvertExpression.cs @@ -4,13 +4,15 @@ using System; +using Microsoft.Scripting.Interpreter; + using IronPython.Runtime; using IronPython.Runtime.Binding; -using Microsoft.Scripting.Interpreter; - using MSAst = System.Linq.Expressions; +using AstUtils = Microsoft.Scripting.Ast.Utils; + namespace IronPython.Compiler.Ast { internal class DynamicConvertExpression : MSAst.Expression, IInstructionProvider { private readonly PythonConversionBinder _binder; diff --git a/src/ipy/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs b/src/ipy/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs index 68eb82d93..5bf0f00ec 100644 --- a/src/ipy/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs +++ b/src/ipy/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs @@ -3,15 +3,25 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Dynamic; +using System.IO; using System.Runtime.CompilerServices; -using IronPython.Runtime; -using IronPython.Runtime.Binding; - +using Microsoft.Scripting; +using Microsoft.Scripting.Actions; using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Utils; +using IronPython.Runtime; +using IronPython.Runtime.Binding; +using IronPython.Runtime.Operations; + using MSAst = System.Linq.Expressions; + +using AstUtils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Compiler.Ast { internal class DynamicGetMemberExpression : MSAst.Expression, IInstructionProvider { private readonly PythonGetMemberBinder/*!*/ _binder; diff --git a/src/ipy/IronPython/Compiler/Ast/EmptyStatement.cs b/src/ipy/IronPython/Compiler/Ast/EmptyStatement.cs index fb64b3bc6..d14114952 100644 --- a/src/ipy/IronPython/Compiler/Ast/EmptyStatement.cs +++ b/src/ipy/IronPython/Compiler/Ast/EmptyStatement.cs @@ -2,9 +2,10 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using AstUtils = Microsoft.Scripting.Ast.Utils; using MSAst = System.Linq.Expressions; +using AstUtils = Microsoft.Scripting.Ast.Utils; + namespace IronPython.Compiler.Ast { public class EmptyStatement : Statement { diff --git a/src/ipy/IronPython/Compiler/Ast/ErrorExpression.cs b/src/ipy/IronPython/Compiler/Ast/ErrorExpression.cs index 51bd1de83..8931133d0 100644 --- a/src/ipy/IronPython/Compiler/Ast/ErrorExpression.cs +++ b/src/ipy/IronPython/Compiler/Ast/ErrorExpression.cs @@ -2,6 +2,10 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using MSAst = System.Linq.Expressions; + +using System; + namespace IronPython.Compiler.Ast { public class ErrorExpression : Expression { public ErrorExpression() { diff --git a/src/ipy/IronPython/Compiler/Ast/Expression.cs b/src/ipy/IronPython/Compiler/Ast/Expression.cs index 3c497ac55..5e6ab3b92 100644 --- a/src/ipy/IronPython/Compiler/Ast/Expression.cs +++ b/src/ipy/IronPython/Compiler/Ast/Expression.cs @@ -5,6 +5,7 @@ #nullable enable using System; +using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; @@ -54,7 +55,7 @@ internal virtual MSAst.Expression TransformDelete() { internal virtual bool IsConstant => ConstantFold()?.IsConstant ?? false; - internal virtual object GetConstantValue() { + internal virtual object GetConstantValue() { var folded = ConstantFold(); if (folded != null && folded.IsConstant) { return folded.GetConstantValue(); diff --git a/src/ipy/IronPython/Compiler/Ast/ExpressionStatement.cs b/src/ipy/IronPython/Compiler/Ast/ExpressionStatement.cs index 8a7d7866f..28e851e39 100644 --- a/src/ipy/IronPython/Compiler/Ast/ExpressionStatement.cs +++ b/src/ipy/IronPython/Compiler/Ast/ExpressionStatement.cs @@ -4,6 +4,8 @@ using MSAst = System.Linq.Expressions; +using AstUtils = Microsoft.Scripting.Ast.Utils; + namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/src/ipy/IronPython/Compiler/Ast/FlowChecker.cs b/src/ipy/IronPython/Compiler/Ast/FlowChecker.cs index be702b199..8b3acf40f 100644 --- a/src/ipy/IronPython/Compiler/Ast/FlowChecker.cs +++ b/src/ipy/IronPython/Compiler/Ast/FlowChecker.cs @@ -5,6 +5,7 @@ using System.Collections; using System.Collections.Generic; using System.Diagnostics; +using Microsoft.Scripting; /* * The data flow. @@ -121,7 +122,7 @@ internal class FlowDeleter : PythonWalkerNonRecursive { public FlowDeleter(FlowChecker fc) { _fc = fc; } - + public override bool Walk(NameExpression node) { _fc.Delete(node.Name); return false; diff --git a/src/ipy/IronPython/Compiler/Ast/ForStatement.cs b/src/ipy/IronPython/Compiler/Ast/ForStatement.cs index 8f16e36c0..bb18f05c6 100644 --- a/src/ipy/IronPython/Compiler/Ast/ForStatement.cs +++ b/src/ipy/IronPython/Compiler/Ast/ForStatement.cs @@ -2,16 +2,18 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using MSAst = System.Linq.Expressions; + using System; using System.Collections; using System.Collections.Generic; -using IronPython.Runtime.Binding; - using Microsoft.Scripting; +using IronPython.Runtime.Binding; +using IronPython.Runtime.Operations; + using AstUtils = Microsoft.Scripting.Ast.Utils; -using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; @@ -66,8 +68,8 @@ internal static MSAst.Expression TransformFor(ScopeStatement parent, MSAst.Param Binders.UnaryOperationBinder( parent.GlobalParent.PyContext, PythonOperationKind.GetEnumeratorForIteration - ), - parent.GlobalParent.CompilationMode, + ), + parent.GlobalParent.CompilationMode, AstUtils.Convert(list, typeof(object)) ) ); diff --git a/src/ipy/IronPython/Compiler/Ast/FromImportStatement.cs b/src/ipy/IronPython/Compiler/Ast/FromImportStatement.cs index f183b460a..19e46d9d7 100644 --- a/src/ipy/IronPython/Compiler/Ast/FromImportStatement.cs +++ b/src/ipy/IronPython/Compiler/Ast/FromImportStatement.cs @@ -2,13 +2,13 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using MSAst = System.Linq.Expressions; + using System.Collections.Generic; using System.Runtime.CompilerServices; - using Microsoft.Scripting.Runtime; - +using Microsoft.Scripting; using AstUtils = Microsoft.Scripting.Ast.Utils; -using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/src/ipy/IronPython/Compiler/Ast/FunctionDefinition.cs b/src/ipy/IronPython/Compiler/Ast/FunctionDefinition.cs index 6c97816bd..edc452a27 100644 --- a/src/ipy/IronPython/Compiler/Ast/FunctionDefinition.cs +++ b/src/ipy/IronPython/Compiler/Ast/FunctionDefinition.cs @@ -5,21 +5,22 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Runtime.CompilerServices; using System.Text; using System.Threading; - -using IronPython.Runtime; -using IronPython.Runtime.Operations; +using System.Runtime.CompilerServices; using Microsoft.Scripting; using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Utils; -using AstUtils = Microsoft.Scripting.Ast.Utils; -using LightLambdaExpression = Microsoft.Scripting.Ast.LightLambdaExpression; +using IronPython.Runtime; +using IronPython.Runtime.Operations; + using MSAst = System.Linq.Expressions; +using LightLambdaExpression = Microsoft.Scripting.Ast.LightLambdaExpression; +using AstUtils = Microsoft.Scripting.Ast.Utils; + namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; @@ -84,7 +85,8 @@ internal override MSAst.Expression LocalContext { internal override int ArgCount { get { int argCount = 0; - for (argCount = 0; argCount < _parameters.Length; argCount++) { + for (argCount = 0; argCount < _parameters.Length; argCount++) + { Parameter p = _parameters[argCount]; if (p.IsDictionary || p.IsList || p.IsKeywordOnly) break; } @@ -254,7 +256,7 @@ internal override void Bind(PythonNameBinder binder) { NeedsLocalsDictionary = true; } } - + internal override void FinishBind(PythonNameBinder binder) { foreach (var param in _parameters) { _variableMapping[param.PythonVariable] = param.FinishBind(forceClosureCell: ExposesLocalVariable(param.PythonVariable)); @@ -284,7 +286,7 @@ public override MSAst.Expression Reduce() { new SourceSpan(GlobalParent.IndexToLocation(StartIndex), GlobalParent.IndexToLocation(HeaderIndex)) ); } - + /// /// Returns an expression which creates the function object. /// @@ -561,7 +563,7 @@ public override int ConsumedStack { get { return _defaultCount + (_kwdefaultCount * 2) + (_annotationCount * 2) + (_context == null ? 1 : 0) + - (_name == null ? 1 : 0); + (_name == null ? 1 : 0); } } @@ -777,7 +779,7 @@ internal override IList GetVarNames() { return res; } - + private void InitializeParameters(List init, bool needsWrapperMethod, MSAst.Expression[] parameters) { for (int i = 0; i < _parameters.Length; i++) { Parameter p = _parameters[i]; @@ -827,10 +829,10 @@ private static Type GetDelegateType(Parameter[] parameters, bool wrapper, out De internal override void RewriteBody(MSAst.ExpressionVisitor visitor) { _dlrBody = null; // clear the cached body if we've been reduced - + MSAst.Expression funcCode = GlobalParent.Constant(GetOrMakeFunctionCode()); FuncCodeExpr = funcCode; - + Body = new RewrittenBodyStatement(Body, visitor.Visit(Body)); } diff --git a/src/ipy/IronPython/Compiler/Ast/GeneratorExpression.cs b/src/ipy/IronPython/Compiler/Ast/GeneratorExpression.cs index 8486bed32..1916c55ec 100644 --- a/src/ipy/IronPython/Compiler/Ast/GeneratorExpression.cs +++ b/src/ipy/IronPython/Compiler/Ast/GeneratorExpression.cs @@ -4,6 +4,14 @@ using MSAst = System.Linq.Expressions; +using System; +using System.Diagnostics; + +using Microsoft.Scripting.Actions; + +using IronPython.Runtime; +using IronPython.Runtime.Binding; + namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/src/ipy/IronPython/Compiler/Ast/GetGlobalContextExpression.cs b/src/ipy/IronPython/Compiler/Ast/GetGlobalContextExpression.cs index 8ff512e7e..4d88e2668 100644 --- a/src/ipy/IronPython/Compiler/Ast/GetGlobalContextExpression.cs +++ b/src/ipy/IronPython/Compiler/Ast/GetGlobalContextExpression.cs @@ -3,11 +3,12 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; +using System.Text; using IronPython.Runtime; -using IronPython.Runtime.Operations; - using Microsoft.Scripting.Interpreter; +using IronPython.Runtime.Operations; using MSAst = System.Linq.Expressions; diff --git a/src/ipy/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs b/src/ipy/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs index 706f19d63..86882e7d8 100644 --- a/src/ipy/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs +++ b/src/ipy/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs @@ -4,11 +4,11 @@ using System; +using Microsoft.Scripting.Interpreter; + using IronPython.Runtime; using IronPython.Runtime.Operations; -using Microsoft.Scripting.Interpreter; - using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { diff --git a/src/ipy/IronPython/Compiler/Ast/IfStatement.cs b/src/ipy/IronPython/Compiler/Ast/IfStatement.cs index 58ed3fc9e..715081dbb 100644 --- a/src/ipy/IronPython/Compiler/Ast/IfStatement.cs +++ b/src/ipy/IronPython/Compiler/Ast/IfStatement.cs @@ -2,14 +2,19 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using MSAst = System.Linq.Expressions; + +using System; using System.Collections.Generic; +using System.Diagnostics; using Microsoft.Scripting; using Microsoft.Scripting.Ast; using Microsoft.Scripting.Interpreter; +using IronPython.Runtime; + using AstUtils = Microsoft.Scripting.Ast.Utils; -using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/src/ipy/IronPython/Compiler/Ast/ImportStatement.cs b/src/ipy/IronPython/Compiler/Ast/ImportStatement.cs index 79e415989..40c473815 100644 --- a/src/ipy/IronPython/Compiler/Ast/ImportStatement.cs +++ b/src/ipy/IronPython/Compiler/Ast/ImportStatement.cs @@ -2,13 +2,14 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using MSAst = System.Linq.Expressions; + using System.Collections.Generic; using System.Runtime.CompilerServices; +using Microsoft.Scripting; using Microsoft.Scripting.Runtime; - using AstUtils = Microsoft.Scripting.Ast.Utils; -using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/src/ipy/IronPython/Compiler/Ast/IndexExpression.cs b/src/ipy/IronPython/Compiler/Ast/IndexExpression.cs index cef6e199a..fdc830ea7 100644 --- a/src/ipy/IronPython/Compiler/Ast/IndexExpression.cs +++ b/src/ipy/IronPython/Compiler/Ast/IndexExpression.cs @@ -2,14 +2,14 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using MSAst = System.Linq.Expressions; + using IronPython.Runtime; using IronPython.Runtime.Binding; using Microsoft.Scripting; using Microsoft.Scripting.Utils; -using MSAst = System.Linq.Expressions; - namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/src/ipy/IronPython/Compiler/Ast/LambdaExpression.cs b/src/ipy/IronPython/Compiler/Ast/LambdaExpression.cs index 2f50c2453..b915e22f0 100644 --- a/src/ipy/IronPython/Compiler/Ast/LambdaExpression.cs +++ b/src/ipy/IronPython/Compiler/Ast/LambdaExpression.cs @@ -4,6 +4,8 @@ using MSAst = System.Linq.Expressions; +using System; + namespace IronPython.Compiler.Ast { public class LambdaExpression : Expression { public LambdaExpression(FunctionDefinition function) { diff --git a/src/ipy/IronPython/Compiler/Ast/MemberExpression.cs b/src/ipy/IronPython/Compiler/Ast/MemberExpression.cs index 67fb1c85c..2f34a8936 100644 --- a/src/ipy/IronPython/Compiler/Ast/MemberExpression.cs +++ b/src/ipy/IronPython/Compiler/Ast/MemberExpression.cs @@ -2,12 +2,13 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using IronPython.Runtime.Binding; +using MSAst = System.Linq.Expressions; +using System; +using System.Dynamic; +using IronPython.Runtime.Binding; using Microsoft.Scripting; - using AstUtils = Microsoft.Scripting.Ast.Utils; -using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/src/ipy/IronPython/Compiler/Ast/ModuleName.cs b/src/ipy/IronPython/Compiler/Ast/ModuleName.cs index 1e60c448f..db9990fb1 100644 --- a/src/ipy/IronPython/Compiler/Ast/ModuleName.cs +++ b/src/ipy/IronPython/Compiler/Ast/ModuleName.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using Microsoft.Scripting; + namespace IronPython.Compiler.Ast { public class ModuleName : DottedName { public ModuleName(string[] names) diff --git a/src/ipy/IronPython/Compiler/Ast/NameExpression.cs b/src/ipy/IronPython/Compiler/Ast/NameExpression.cs index f7c0a5a54..daa62ce51 100644 --- a/src/ipy/IronPython/Compiler/Ast/NameExpression.cs +++ b/src/ipy/IronPython/Compiler/Ast/NameExpression.cs @@ -2,12 +2,13 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using IronPython.Runtime.Binding; +using MSAst = System.Linq.Expressions; using Microsoft.Scripting; +using IronPython.Runtime.Binding; + using AstUtils = Microsoft.Scripting.Ast.Utils; -using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; @@ -77,7 +78,7 @@ internal override MSAst.Expression TransformSet(SourceSpan span, MSAst.Expressio assignment = Ast.Call( null, AstMethods.SetName, - Parent.LocalContext, + Parent.LocalContext, Ast.Constant(Name), AstUtils.Convert(right, typeof(object)) ); diff --git a/src/ipy/IronPython/Compiler/Ast/Node.cs b/src/ipy/IronPython/Compiler/Ast/Node.cs index 8021ab4dd..c15820c82 100644 --- a/src/ipy/IronPython/Compiler/Ast/Node.cs +++ b/src/ipy/IronPython/Compiler/Ast/Node.cs @@ -4,21 +4,24 @@ #nullable enable +using Microsoft.Scripting; + +using MSAst = System.Linq.Expressions; +using System.Linq.Expressions; + using System; using System.Collections.Generic; using System.Diagnostics; -using System.Linq.Expressions; - -using IronPython.Runtime.Binding; -using IronPython.Runtime.Operations; -using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Ast; +using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using MSAst = System.Linq.Expressions; +using IronPython.Runtime; +using IronPython.Runtime.Binding; +using IronPython.Runtime.Operations; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; @@ -86,7 +89,7 @@ public int StartIndex { IndexSpan = new IndexSpan(value, 0); } } - + internal SourceLocation IndexToLocation(int index) { if (index == -1) { return SourceLocation.Invalid; @@ -202,7 +205,7 @@ internal static MSAst.Expression TransformOrConstantNull(Expression? expression, internal MSAst.Expression TransformAndDynamicConvert(Expression expression, Type/*!*/ type) { Assert.NotNull(expression); - + MSAst.Expression res = expression; // Do we need conversion? @@ -213,7 +216,7 @@ internal MSAst.Expression TransformAndDynamicConvert(Expression expression, Type if (reduced is LightDynamicExpression) { reduced = reduced.Reduce(); } - + // Add conversion step to the AST MSAst.DynamicExpression? ae = reduced as MSAst.DynamicExpression; ReducableDynamicExpression? rde = reduced as ReducableDynamicExpression; @@ -237,7 +240,7 @@ internal MSAst.Expression TransformAndDynamicConvert(Expression expression, Type for (int i = 0; i < infos.Length; i++) { infos[i] = ParameterMappingInfo.Parameter(i); } - + res = Expression.Dynamic( GlobalParent.PyContext.BinaryOperationRetType( binder, @@ -440,7 +443,7 @@ internal static MSAst.ParameterExpression/*!*/ LineNumberUpdated { return _lineNumberUpdated; } } - + internal static MSAst.Expression UpdateLineNumber(int line) { return Ast.Assign(LineNumberExpression, AstUtils.Constant(line)); } diff --git a/src/ipy/IronPython/Compiler/Ast/OrExpression.cs b/src/ipy/IronPython/Compiler/Ast/OrExpression.cs index 8e907d89c..baf33bd20 100644 --- a/src/ipy/IronPython/Compiler/Ast/OrExpression.cs +++ b/src/ipy/IronPython/Compiler/Ast/OrExpression.cs @@ -5,7 +5,6 @@ #nullable enable using System; - using Microsoft.Scripting.Actions; using Microsoft.Scripting.Utils; diff --git a/src/ipy/IronPython/Compiler/Ast/Parameter.cs b/src/ipy/IronPython/Compiler/Ast/Parameter.cs index bfea948fa..03a123fd1 100644 --- a/src/ipy/IronPython/Compiler/Ast/Parameter.cs +++ b/src/ipy/IronPython/Compiler/Ast/Parameter.cs @@ -4,7 +4,10 @@ using System.Collections.Generic; +using Microsoft.Scripting; + using IronPython.Runtime; +using IronPython.Runtime.Binding; using MSAst = System.Linq.Expressions; diff --git a/src/ipy/IronPython/Compiler/Ast/ParenthesisExpression.cs b/src/ipy/IronPython/Compiler/Ast/ParenthesisExpression.cs index c1ceb8fb0..2aa62f4a2 100644 --- a/src/ipy/IronPython/Compiler/Ast/ParenthesisExpression.cs +++ b/src/ipy/IronPython/Compiler/Ast/ParenthesisExpression.cs @@ -4,10 +4,10 @@ using System; -using IronPython.Runtime.Binding; - using Microsoft.Scripting; +using IronPython.Runtime.Binding; + using MSAst = System.Linq.Expressions; diff --git a/src/ipy/IronPython/Compiler/Ast/PythonAst.cs b/src/ipy/IronPython/Compiler/Ast/PythonAst.cs index 8c5e6b2d5..383537c33 100644 --- a/src/ipy/IronPython/Compiler/Ast/PythonAst.cs +++ b/src/ipy/IronPython/Compiler/Ast/PythonAst.cs @@ -6,20 +6,24 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; +using System.Dynamic; using System.IO; using System.Runtime.CompilerServices; -using IronPython.Runtime; -using IronPython.Runtime.Binding; - using Microsoft.Scripting; using Microsoft.Scripting.Actions; +using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using AstUtils = Microsoft.Scripting.Ast.Utils; +using IronPython.Runtime; +using IronPython.Runtime.Binding; +using IronPython.Runtime.Operations; + using MSAst = System.Linq.Expressions; +using AstUtils = Microsoft.Scripting.Ast.Utils; + namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; @@ -64,7 +68,7 @@ public PythonAst(Statement body, bool isModule, ModuleOptions languageFeatures, ContractUtils.RequiresNotNull(body, nameof(body)); _body = body; - + _lineLocations = lineLocations; } @@ -94,7 +98,7 @@ public PythonAst(bool isModule, ModuleOptions languageFeatures, bool printExpres Debug.Assert(_name != null); PythonOptions po = ((PythonContext)context.SourceUnit.LanguageContext).PythonOptions; - if (po.EnableProfiler + if (po.EnableProfiler #if FEATURE_REFEMIT && _mode != CompilationMode.ToDisk #endif @@ -179,7 +183,7 @@ internal override void FinishBind(PythonNameBinder binder) { #if FEATURE_REFEMIT if (_mode == CompilationMode.ToDisk) { _arrayExpression = _globalArray; - } else + } else #endif { var newArray = new ConstantExpression(globalArray); @@ -393,7 +397,7 @@ internal MSAst.Expression ReduceWorker() { block.Add(_body); MSAst.Expression body = Ast.Block(block.ToReadOnlyCollection()); - + body = WrapScopeStatements(body, Body.CanThrow); // new ComboActionRewriter().VisitNode(Transform(ag)) body = AddModulePublishing(body); @@ -548,7 +552,7 @@ internal void PrepareScope(ReadOnlyCollectionBuilder internal new MSAst.Expression Constant(object value) { return new PythonConstantExpression(CompilationMode, value); } - + #endregion #region Binder Factories @@ -575,7 +579,7 @@ internal void PrepareScope(ReadOnlyCollectionBuilder ); } - + internal MSAst.Expression/*!*/ Operation(Type/*!*/ resultType, PythonOperationKind operation, MSAst.Expression arg0) { if (resultType == typeof(object)) { return new PythonDynamicExpression1( @@ -587,7 +591,7 @@ internal void PrepareScope(ReadOnlyCollectionBuilder arg0 ); } - + return CompilationMode.Dynamic( Binders.UnaryOperationBinder( PyContext, @@ -636,7 +640,7 @@ internal void PrepareScope(ReadOnlyCollectionBuilder return new DynamicGetMemberExpression(PyContext.GetMember(name), _mode, target, LocalContext); } - + internal MSAst.Expression/*!*/ Delete(Type/*!*/ resultType, string/*!*/ name, MSAst.Expression/*!*/ target) { return CompilationMode.Dynamic( PyContext.DeleteMember( @@ -673,7 +677,7 @@ internal void PrepareScope(ReadOnlyCollectionBuilder ), CompilationMode, expressions - ); + ); } internal MSAst.Expression/*!*/ SetSlice(MSAst.Expression/*!*/[]/*!*/ expressions) { @@ -681,10 +685,10 @@ internal void PrepareScope(ReadOnlyCollectionBuilder PyContext.SetSliceBinder, CompilationMode, expressions - ); + ); } - internal MSAst.Expression/*!*/ DeleteIndex(MSAst.Expression/*!*/[]/*!*/ expressions) { + internal MSAst.Expression/*!*/ DeleteIndex(MSAst.Expression/*!*/[]/*!*/ expressions) { return CompilationMode.Dynamic( PyContext.DeleteIndex( expressions.Length @@ -699,7 +703,7 @@ internal void PrepareScope(ReadOnlyCollectionBuilder PyContext.DeleteSlice, CompilationMode, expressions - ); + ); } #endregion diff --git a/src/ipy/IronPython/Compiler/Ast/PythonNameBinder.cs b/src/ipy/IronPython/Compiler/Ast/PythonNameBinder.cs index d5f070d6c..68e5eb2c4 100644 --- a/src/ipy/IronPython/Compiler/Ast/PythonNameBinder.cs +++ b/src/ipy/IronPython/Compiler/Ast/PythonNameBinder.cs @@ -2,16 +2,16 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using MSAst = System.Linq.Expressions; + using System.Collections.Generic; using System.Diagnostics; -using IronPython.Runtime; - using Microsoft.Scripting; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using MSAst = System.Linq.Expressions; +using IronPython.Runtime; /* * The name binding: @@ -589,14 +589,14 @@ public override bool Walk(WhileStatement node) { public override bool Walk(BreakStatement node) { node.Parent = _currentScope; node.LoopStatement = _loops[_loops.Count - 1]; - + return base.Walk(node); } public override bool Walk(ContinueStatement node) { node.Parent = _currentScope; node.LoopStatement = _loops[_loops.Count - 1]; - + return base.Walk(node); } diff --git a/src/ipy/IronPython/Compiler/Ast/PythonVariable.cs b/src/ipy/IronPython/Compiler/Ast/PythonVariable.cs index 7d8276a84..85c41bcaf 100644 --- a/src/ipy/IronPython/Compiler/Ast/PythonVariable.cs +++ b/src/ipy/IronPython/Compiler/Ast/PythonVariable.cs @@ -4,11 +4,20 @@ #nullable enable +using MSAst = System.Linq.Expressions; + +using System; using System.Diagnostics; +using Microsoft.Scripting; +using Microsoft.Scripting.Ast; using Microsoft.Scripting.Utils; +using IronPython.Runtime; + namespace IronPython.Compiler.Ast { + using Ast = MSAst.Expression; + [DebuggerDisplay("{Kind} {Name} from {Scope.Name}")] public class PythonVariable { diff --git a/src/ipy/IronPython/Compiler/Ast/RelativeModuleName.cs b/src/ipy/IronPython/Compiler/Ast/RelativeModuleName.cs index cdb588356..9d465cb71 100644 --- a/src/ipy/IronPython/Compiler/Ast/RelativeModuleName.cs +++ b/src/ipy/IronPython/Compiler/Ast/RelativeModuleName.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using Microsoft.Scripting; + namespace IronPython.Compiler.Ast { public class RelativeModuleName : ModuleName { public RelativeModuleName(string[] names, int dotCount) diff --git a/src/ipy/IronPython/Compiler/Ast/ScopeStatement.cs b/src/ipy/IronPython/Compiler/Ast/ScopeStatement.cs index 4a08f0aaa..28d571804 100644 --- a/src/ipy/IronPython/Compiler/Ast/ScopeStatement.cs +++ b/src/ipy/IronPython/Compiler/Ast/ScopeStatement.cs @@ -92,7 +92,7 @@ public abstract class ScopeStatement : Statement { /// /// It is used to ensure that the first argument is accessible through a closure cell. /// - internal bool ContainsSuperCall { get; set; } + internal bool ContainsSuperCall{ get; set; } public virtual string Name => ""; @@ -439,7 +439,7 @@ private PythonVariable CreateNonlocalVariable(string name) { } internal void EnsureNonlocalVariable(string name, NonlocalStatement node) { - _nonlocalVars ??= new(); + _nonlocalVars ??= new(); if (!_nonlocalVars.ContainsKey(name)) { CreateNonlocalVariable(name); _nonlocalVars[name] = node; @@ -611,7 +611,7 @@ internal MSAst.Expression? FuncCodeExpr { internal MSAst.MethodCallExpression CreateLocalContext(MSAst.Expression parentContext, bool newNamespace = true) { var closureVariables = _closureVariables ?? Array.Empty(); - + int numFreeVars = FreeVariables?.Count ?? 0; int firstArgIdx = -1; if ((NeedsLocalsDictionary || ContainsSuperCall) && ArgCount > 0) { diff --git a/src/ipy/IronPython/Compiler/Ast/SerializedScopeStatement.cs b/src/ipy/IronPython/Compiler/Ast/SerializedScopeStatement.cs index 9b1e59e25..35e3734a1 100644 --- a/src/ipy/IronPython/Compiler/Ast/SerializedScopeStatement.cs +++ b/src/ipy/IronPython/Compiler/Ast/SerializedScopeStatement.cs @@ -3,9 +3,15 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; +using System.Text; + +using Microsoft.Scripting; using IronPython.Runtime; +using MSAst = System.Linq.Expressions; + namespace IronPython.Compiler.Ast { /// /// Fake ScopeStatement for FunctionCode's to hold on to after we have deserialized pre-compiled code. diff --git a/src/ipy/IronPython/Compiler/Ast/SliceExpression.cs b/src/ipy/IronPython/Compiler/Ast/SliceExpression.cs index 484a1f5db..ce3a185fa 100644 --- a/src/ipy/IronPython/Compiler/Ast/SliceExpression.cs +++ b/src/ipy/IronPython/Compiler/Ast/SliceExpression.cs @@ -7,6 +7,8 @@ using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { + using Ast = MSAst.Expression; + public class SliceExpression : Expression { public SliceExpression(Expression? start, Expression? stop, Expression? step) { SliceStart = start; diff --git a/src/ipy/IronPython/Compiler/Ast/SuiteStatement.cs b/src/ipy/IronPython/Compiler/Ast/SuiteStatement.cs index 679b170f4..6d4299ea9 100644 --- a/src/ipy/IronPython/Compiler/Ast/SuiteStatement.cs +++ b/src/ipy/IronPython/Compiler/Ast/SuiteStatement.cs @@ -2,17 +2,21 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using MSAst = System.Linq.Expressions; + using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; using System.Runtime.CompilerServices; +using Microsoft.Scripting; using Microsoft.Scripting.Utils; using AstUtils = Microsoft.Scripting.Ast.Utils; -using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; - + public sealed class SuiteStatement : Statement { private readonly Statement[] _statements; @@ -23,7 +27,7 @@ public SuiteStatement(Statement[] statements) { public IList Statements { get { return _statements; } - } + } public override MSAst.Expression Reduce() { if (_statements.Length == 0) { @@ -48,7 +52,7 @@ public override MSAst.Expression Reduce() { } curStart = newline; } - + return Ast.Block(statements.ToReadOnlyCollection()); } @@ -96,7 +100,7 @@ public override void Walk(PythonWalker walker) { } public override string Documentation { - get { + get { if (_statements.Length > 0) { return _statements[0].Documentation; } diff --git a/src/ipy/IronPython/Compiler/Ast/TryStatement.cs b/src/ipy/IronPython/Compiler/Ast/TryStatement.cs index 1fa19a0ef..84d431190 100644 --- a/src/ipy/IronPython/Compiler/Ast/TryStatement.cs +++ b/src/ipy/IronPython/Compiler/Ast/TryStatement.cs @@ -9,15 +9,18 @@ using System.Diagnostics; using System.Runtime.CompilerServices; -using IronPython.Runtime.Binding; - using Microsoft.Scripting; +using Microsoft.Scripting.Ast; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using AstUtils = Microsoft.Scripting.Ast.Utils; +using IronPython.Runtime.Binding; +using IronPython.Runtime.Operations; + using MSAst = System.Linq.Expressions; +using AstUtils = Microsoft.Scripting.Ast.Utils; + namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/src/ipy/IronPython/Compiler/Ast/UnaryExpression.cs b/src/ipy/IronPython/Compiler/Ast/UnaryExpression.cs index 28e2be18a..dbdc75af7 100644 --- a/src/ipy/IronPython/Compiler/Ast/UnaryExpression.cs +++ b/src/ipy/IronPython/Compiler/Ast/UnaryExpression.cs @@ -2,13 +2,17 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using MSAst = System.Linq.Expressions; + +using System; using System.Diagnostics; using IronPython.Runtime.Binding; -using MSAst = System.Linq.Expressions; - namespace IronPython.Compiler.Ast { + using Ast = MSAst.Expression; + using AstUtils = Microsoft.Scripting.Ast.Utils; + public class UnaryExpression : Expression { public UnaryExpression(PythonOperator op, Expression expression) { Operator = op; diff --git a/src/ipy/IronPython/Compiler/Ast/WhileStatement.cs b/src/ipy/IronPython/Compiler/Ast/WhileStatement.cs index b4cfab035..9d8b24848 100644 --- a/src/ipy/IronPython/Compiler/Ast/WhileStatement.cs +++ b/src/ipy/IronPython/Compiler/Ast/WhileStatement.cs @@ -2,11 +2,12 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using MSAst = System.Linq.Expressions; + using Microsoft.Scripting; using Microsoft.Scripting.Interpreter; using AstUtils = Microsoft.Scripting.Ast.Utils; -using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { diff --git a/src/ipy/IronPython/Compiler/Ast/WithStatement.cs b/src/ipy/IronPython/Compiler/Ast/WithStatement.cs index 3f386f61d..6712de29b 100644 --- a/src/ipy/IronPython/Compiler/Ast/WithStatement.cs +++ b/src/ipy/IronPython/Compiler/Ast/WithStatement.cs @@ -3,16 +3,18 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Runtime.CompilerServices; -using IronPython.Runtime.Binding; - using Microsoft.Scripting; using Microsoft.Scripting.Actions; -using AstUtils = Microsoft.Scripting.Ast.Utils; +using IronPython.Runtime.Binding; + using MSAst = System.Linq.Expressions; +using AstUtils = Microsoft.Scripting.Ast.Utils; + namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; @@ -168,29 +170,29 @@ public override MSAst.Expression Reduce() { Ast.Assign(previousException, Ast.Call(AstMethods.SaveCurrentException)), _var != null ? (MSAst.Expression)Ast.Block( - // VAR = value + // VAR = value _var.TransformSet(SourceSpan.None, value, PythonOperationKind.None), - // BLOCK + // BLOCK _body, AstUtils.Empty() ) : - // BLOCK + // BLOCK (MSAst.Expression)_body // except:, // try statement location ).Catch(exception = Ast.Variable(typeof(Exception), "exception"), - // Python specific exception handling code + // Python specific exception handling code TryStatement.GetTracebackHeader( this, exception, GlobalParent.AddDebugInfoAndVoid( Ast.Block( Ast.Call(AstMethods.SetCurrentException, Parent.LocalContext, exception), - // exc = False + // exc = False MakeAssignment( exc, AstUtils.Constant(false) ), - // if not exit(*sys.exc_info()): - // raise + // if not exit(*sys.exc_info()): + // raise AstUtils.IfThen( GlobalParent.Convert( typeof(bool), @@ -219,8 +221,8 @@ public override MSAst.Expression Reduce() { // finally: ).Finally( Ast.Call(AstMethods.RestoreCurrentException, previousException), - // if exc: - // exit(None, None, None) + // if exc: + // exit(None, None, None) AstUtils.IfThen( exc, GlobalParent.AddDebugInfoAndVoid( diff --git a/src/ipy/IronPython/Compiler/Ast/YieldExpression.cs b/src/ipy/IronPython/Compiler/Ast/YieldExpression.cs index 332bc4b51..266a157aa 100644 --- a/src/ipy/IronPython/Compiler/Ast/YieldExpression.cs +++ b/src/ipy/IronPython/Compiler/Ast/YieldExpression.cs @@ -4,13 +4,13 @@ #nullable enable -using System.Diagnostics; +using MSAst = System.Linq.Expressions; +using System; +using System.Diagnostics; using Microsoft.Scripting; using Microsoft.Scripting.Runtime; - using AstUtils = Microsoft.Scripting.Ast.Utils; -using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/src/ipy/IronPython/Compiler/Ast/YieldFromExpression.cs b/src/ipy/IronPython/Compiler/Ast/YieldFromExpression.cs index aa2ca83ef..47ce30213 100644 --- a/src/ipy/IronPython/Compiler/Ast/YieldFromExpression.cs +++ b/src/ipy/IronPython/Compiler/Ast/YieldFromExpression.cs @@ -4,9 +4,13 @@ #nullable enable -using AstUtils = Microsoft.Scripting.Ast.Utils; using MSAst = System.Linq.Expressions; +using System; +using System.Diagnostics; +using Microsoft.Scripting; +using AstUtils = Microsoft.Scripting.Ast.Utils; + namespace IronPython.Compiler.Ast { using Ast = MSAst.Expression; diff --git a/src/ipy/IronPython/Compiler/ClosureExpression.cs b/src/ipy/IronPython/Compiler/ClosureExpression.cs index c112796f2..8520ea877 100644 --- a/src/ipy/IronPython/Compiler/ClosureExpression.cs +++ b/src/ipy/IronPython/Compiler/ClosureExpression.cs @@ -2,17 +2,18 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Linq.Expressions; -using System.Reflection; -using IronPython.Runtime; -using IronPython.Runtime.Operations; +using System; +using System.Reflection; using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime; +using IronPython.Runtime.Operations; + namespace IronPython.Compiler { /// /// Small reducable node which just fetches the value from a ClosureCell diff --git a/src/ipy/IronPython/Compiler/ClosureInfo.cs b/src/ipy/IronPython/Compiler/ClosureInfo.cs index 7d6e4fa4e..1408530f7 100644 --- a/src/ipy/IronPython/Compiler/ClosureInfo.cs +++ b/src/ipy/IronPython/Compiler/ClosureInfo.cs @@ -2,12 +2,16 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using IronPython.Compiler.Ast; +using System; -using Microsoft.Scripting.Utils; +using Microsoft.Scripting; + +using IronPython.Compiler.Ast; using MSAst = System.Linq.Expressions; +using Microsoft.Scripting.Utils; + namespace IronPython.Compiler { /// /// Tracking for variables lifted into closure objects. Used to store information in a function diff --git a/src/ipy/IronPython/Compiler/CollectableCompilationMode.cs b/src/ipy/IronPython/Compiler/CollectableCompilationMode.cs index 56e7edacc..efad65c5f 100644 --- a/src/ipy/IronPython/Compiler/CollectableCompilationMode.cs +++ b/src/ipy/IronPython/Compiler/CollectableCompilationMode.cs @@ -2,17 +2,20 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using MSAst = System.Linq.Expressions; + using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Runtime.CompilerServices; -using IronPython.Runtime; - +using Microsoft.Scripting; using Microsoft.Scripting.Ast; using Microsoft.Scripting.Utils; +using IronPython.Runtime; + using AstUtils = Microsoft.Scripting.Ast.Utils; -using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { diff --git a/src/ipy/IronPython/Compiler/CompilationMode.cs b/src/ipy/IronPython/Compiler/CompilationMode.cs index 9a6fbfb57..e5606ccb7 100644 --- a/src/ipy/IronPython/Compiler/CompilationMode.cs +++ b/src/ipy/IronPython/Compiler/CompilationMode.cs @@ -2,20 +2,22 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using MSAst = System.Linq.Expressions; + + using System; using System.Collections.Generic; using System.Dynamic; -using System.Reflection; using System.Runtime.CompilerServices; -using IronPython.Compiler.Ast; -using IronPython.Runtime; - using Microsoft.Scripting; using Microsoft.Scripting.Ast; using Microsoft.Scripting.Utils; -using MSAst = System.Linq.Expressions; +using IronPython.Compiler.Ast; +using IronPython.Runtime; +using System.Collections; +using System.Reflection; namespace IronPython.Compiler { public delegate object LookupCompilationDelegate(CodeContext context, FunctionCode code); @@ -30,20 +32,20 @@ internal abstract class CompilationMode { /// Compilation will proceed in a manner in which the resulting AST can be serialized to disk. /// public static readonly CompilationMode ToDisk = new ToDiskCompilationMode(); - + /// /// Compilation will use a type and declare static fields for globals. The resulting type /// is uncollectible and therefore extended use of this will cause memory leaks. /// public static readonly CompilationMode Uncollectable = new UncollectableCompilationMode(); #endif - + /// /// Compilation will use an array for globals. The resulting code will be fully collectible /// and once all references are released will be collected. /// public static readonly CompilationMode Collectable = new CollectableCompilationMode(); - + /// /// Compilation will force all global accesses to do a full lookup. This will also happen for /// any unbound local references. This is the slowest form of code generation and is only @@ -120,7 +122,7 @@ public virtual void PublishContext(CodeContext codeContext, ConstantInfo _contex public MSAst.Expression/*!*/ Dynamic(DynamicMetaObjectBinder/*!*/ binder, Type/*!*/ retType, MSAst.Expression/*!*/[]/*!*/ args) { Assert.NotNull(binder, retType, args); Assert.NotNullItems(args); - + switch (args.Length) { case 1: return Dynamic(binder, retType, args[0]); case 2: return Dynamic(binder, retType, args[0], args[1]); diff --git a/src/ipy/IronPython/Compiler/GeneratorRewriter.cs b/src/ipy/IronPython/Compiler/GeneratorRewriter.cs index 5fe5e3cb6..ee48035eb 100644 --- a/src/ipy/IronPython/Compiler/GeneratorRewriter.cs +++ b/src/ipy/IronPython/Compiler/GeneratorRewriter.cs @@ -2,21 +2,22 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; -using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; -using IronPython.Runtime; -using IronPython.Runtime.Operations; - using Microsoft.Scripting; using Microsoft.Scripting.Ast; using Microsoft.Scripting.Utils; +using IronPython.Runtime; +using IronPython.Runtime.Operations; + using AstUtils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Compiler { @@ -55,7 +56,7 @@ internal sealed class GeneratorRewriter : DynamicExpressionVisitor { internal const int NotStarted = -1; internal const int Finished = 0; internal static ParameterExpression _generatorParam = Expression.Parameter(typeof(PythonGenerator), "$generator"); - + internal GeneratorRewriter(string name, Expression body) { _body = body; _name = name; @@ -63,8 +64,8 @@ internal GeneratorRewriter(string name, Expression body) { _gotoRouter = Expression.Variable(typeof(int), "$gotoRouter"); } - internal Expression Reduce(bool shouldInterpret, bool emitDebugSymbols, int compilationThreshold, - IList parameters, Func>, + internal Expression Reduce(bool shouldInterpret, bool emitDebugSymbols, int compilationThreshold, + IList parameters, Func>, Expression>> bodyConverter) { _state = LiftVariable(Expression.Parameter(typeof(int), "state")); @@ -131,7 +132,7 @@ internal Expression Reduce(bool shouldInterpret, bool emitDebugSymbols, int comp _name, new ParameterExpression[] { tupleArg } ); - + // Generate a call to PythonOps.MakeGeneratorClosure(Tuple data, object generatorCode) return Expression.Block( new[] { tupleTmp, ret }, @@ -231,7 +232,7 @@ private class GotoRewriter : ExpressionVisitor { private readonly GotoRewriteInfo _gotoInfo; private readonly LabelTarget _target; private readonly GeneratorRewriter _rewriter; - + public GotoRewriter(GeneratorRewriter rewriter, GotoRewriteInfo gotoInfo, LabelTarget target) { _gotoInfo = gotoInfo; _target = target; @@ -261,12 +262,12 @@ private Expression MakeAssignBlock(Expression variable, Expression value) { if (blockRhs.NodeType == ExpressionType.Label) { var label = (LabelExpression)blockRhs; GotoRewriteInfo curVariable = new GotoRewriteInfo(variable, Expression.Label(label.Target.Name + "_voided")); - + var rewriter = new GotoRewriter(this, curVariable, label.Target); for (int i = 0; i < newBlock.Count - 1; i++) { newBlock[i] = rewriter.Visit(newBlock[i]); } - + newBlock[newBlock.Count - 1] = MakeAssignLabel(variable, curVariable, label.Target, rewriter.Visit(label.DefaultValue)); } else { newBlock[newBlock.Count - 1] = MakeAssign(variable, newBlock[newBlock.Count - 1]); @@ -371,7 +372,7 @@ protected override Expression VisitTry(TryExpression node) { // the catch block had one. It needs to be hoisted because // the catch might contain yields. var deferredVar = c.Variable ?? Expression.Variable(c.Test, null); - LiftVariable(deferredVar); + LiftVariable(deferredVar); // We need to ensure that filters can access the exception // variable @@ -394,7 +395,7 @@ protected override Expression VisitTry(TryExpression node) { // We need to rewrite rethrows into "throw deferredVar" var catchBody = new RethrowRewriter { Exception = deferredVar }.Visit(c.Body); - + // if (deferredVar != null) { // ... catch body ... // } @@ -546,7 +547,7 @@ protected override CatchBlock VisitCatchBlock(CatchBlock node) { // No one needs this yet, and it's not clear what it should even do throw new NotSupportedException("yield in filter is not allowed"); } - + Expression b = Visit(node.Body); if (v == node.Variable && b == node.Body && f == node.Filter) { return node; @@ -972,7 +973,7 @@ private sealed class YieldMarker { internal YieldMarker(int state) { State = state; } - } + } } /// @@ -1024,7 +1025,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) { internal sealed class DelayedTupleAssign : Expression { private readonly Expression _lhs, _rhs; - + public DelayedTupleAssign(Expression lhs, Expression rhs) { _lhs = lhs; _rhs = rhs; diff --git a/src/ipy/IronPython/Compiler/LookupCompilationMode.cs b/src/ipy/IronPython/Compiler/LookupCompilationMode.cs index db128388f..b0d84058b 100644 --- a/src/ipy/IronPython/Compiler/LookupCompilationMode.cs +++ b/src/ipy/IronPython/Compiler/LookupCompilationMode.cs @@ -2,13 +2,22 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using MSAst = System.Linq.Expressions; + +using System; +using System.Collections.Generic; + using Microsoft.Scripting; using Microsoft.Scripting.Ast; +using Microsoft.Scripting.Utils; + +using IronPython.Runtime; using AstUtils = Microsoft.Scripting.Ast.Utils; -using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { + using Ast = MSAst.Expression; + /// /// Provides globals for when we need to lookup into a dictionary for each global access. /// diff --git a/src/ipy/IronPython/Compiler/OnDiskScriptCode.cs b/src/ipy/IronPython/Compiler/OnDiskScriptCode.cs index a0fb06d1b..046574d30 100644 --- a/src/ipy/IronPython/Compiler/OnDiskScriptCode.cs +++ b/src/ipy/IronPython/Compiler/OnDiskScriptCode.cs @@ -4,11 +4,15 @@ using System; using System.Collections.Generic; - -using IronPython.Runtime; +using System.Text; +using System.Reflection; using Microsoft.Scripting; using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + +using IronPython.Runtime; +using IronPython.Runtime.Operations; namespace IronPython.Compiler { /// diff --git a/src/ipy/IronPython/Compiler/Parser.cs b/src/ipy/IronPython/Compiler/Parser.cs index 1e8270721..ddbf3b02e 100644 --- a/src/ipy/IronPython/Compiler/Parser.cs +++ b/src/ipy/IronPython/Compiler/Parser.cs @@ -10,16 +10,16 @@ using System.Numerics; using System.Text; +using Microsoft.Scripting; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + using IronPython.Compiler.Ast; using IronPython.Runtime; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - namespace IronPython.Compiler { // this file is your friend (check the python version that is being developed against) // https://raw.githubusercontent.com/python/cpython/v3.4.10/Grammar/Grammar diff --git a/src/ipy/IronPython/Compiler/PythonCallTargets.cs b/src/ipy/IronPython/Compiler/PythonCallTargets.cs index 3fa32c1bf..03231df95 100644 --- a/src/ipy/IronPython/Compiler/PythonCallTargets.cs +++ b/src/ipy/IronPython/Compiler/PythonCallTargets.cs @@ -3,7 +3,8 @@ // See the LICENSE file in the project root for more information. using System; - +using System.Collections; +using Microsoft.Scripting.Utils; using IronPython.Runtime; using IronPython.Runtime.Operations; @@ -105,7 +106,7 @@ public static object OriginalCallTarget15(PythonFunction function, object arg0, // *** END GENERATED CODE *** #endregion - + public const int MaxArgs = 15; internal static Type GetPythonTargetType(bool wrapper, int parameters, out Delegate originalTarget) { if (!wrapper) { @@ -115,58 +116,58 @@ internal static Type GetPythonTargetType(bool wrapper, int parameters, out Deleg // *** BEGIN GENERATED CODE *** // generated by function: gen_python_switch from: generate_calls.py - case 0: + case 0: originalTarget = (Func)OriginalCallTarget0; return typeof(Func); - case 1: + case 1: originalTarget = (Func)OriginalCallTarget1; return typeof(Func); - case 2: + case 2: originalTarget = (Func)OriginalCallTarget2; return typeof(Func); - case 3: + case 3: originalTarget = (Func)OriginalCallTarget3; return typeof(Func); - case 4: + case 4: originalTarget = (Func)OriginalCallTarget4; return typeof(Func); - case 5: + case 5: originalTarget = (Func)OriginalCallTarget5; return typeof(Func); - case 6: + case 6: originalTarget = (Func)OriginalCallTarget6; return typeof(Func); - case 7: + case 7: originalTarget = (Func)OriginalCallTarget7; return typeof(Func); - case 8: + case 8: originalTarget = (Func)OriginalCallTarget8; return typeof(Func); - case 9: + case 9: originalTarget = (Func)OriginalCallTarget9; return typeof(Func); - case 10: + case 10: originalTarget = (Func)OriginalCallTarget10; return typeof(Func); - case 11: + case 11: originalTarget = (Func)OriginalCallTarget11; return typeof(Func); - case 12: + case 12: originalTarget = (Func)OriginalCallTarget12; return typeof(Func); - case 13: + case 13: originalTarget = (Func)OriginalCallTarget13; return typeof(Func); - case 14: + case 14: originalTarget = (Func)OriginalCallTarget14; return typeof(Func); - case 15: + case 15: originalTarget = (Func)OriginalCallTarget15; return typeof(Func); - // *** END GENERATED CODE *** + // *** END GENERATED CODE *** - #endregion + #endregion } } diff --git a/src/ipy/IronPython/Compiler/PythonCompilerOptions.cs b/src/ipy/IronPython/Compiler/PythonCompilerOptions.cs index ce1aec8e1..645ee7491 100644 --- a/src/ipy/IronPython/Compiler/PythonCompilerOptions.cs +++ b/src/ipy/IronPython/Compiler/PythonCompilerOptions.cs @@ -4,10 +4,10 @@ using System; -using IronPython.Runtime; - using Microsoft.Scripting; +using IronPython.Runtime; + namespace IronPython.Compiler { [Serializable] public sealed class PythonCompilerOptions : CompilerOptions { diff --git a/src/ipy/IronPython/Compiler/PythonDynamicExpression.cs b/src/ipy/IronPython/Compiler/PythonDynamicExpression.cs index 631bdc43e..af518004f 100644 --- a/src/ipy/IronPython/Compiler/PythonDynamicExpression.cs +++ b/src/ipy/IronPython/Compiler/PythonDynamicExpression.cs @@ -2,23 +2,22 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; -using System.Collections.Generic; using System.Dynamic; -using System.Linq.Expressions; using System.Runtime.CompilerServices; - using IronPython.Runtime; - using Microsoft.Scripting.Ast; using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Utils; +using System.Collections.Generic; namespace IronPython.Compiler { internal sealed class PythonDynamicExpression1 : LightDynamicExpression1 { private readonly CompilationMode/*!*/ _mode; - public PythonDynamicExpression1(CallSiteBinder/*!*/ binder, CompilationMode/*!*/ mode, Expression/*!*/ arg0) + public PythonDynamicExpression1(CallSiteBinder/*!*/ binder, CompilationMode/*!*/ mode, Expression/*!*/ arg0) : base(binder, arg0) { _mode = mode; } @@ -214,7 +213,7 @@ public override void AddInstructions(LightCompiler compiler) { compiler.Compile(GetArgument(i)); } - switch (ArgumentCount) { + switch(ArgumentCount) { case 1: compiler.Instructions.EmitDynamic(Binder); break; case 2: compiler.Instructions.EmitDynamic(Binder); break; case 3: compiler.Instructions.EmitDynamic(Binder); break; @@ -229,7 +228,7 @@ public override void AddInstructions(LightCompiler compiler) { case 12: compiler.Instructions.EmitDynamic(Binder); break; case 13: compiler.Instructions.EmitDynamic(Binder); break; case 14: compiler.Instructions.EmitDynamic(Binder); break; - case 15: compiler.Instructions.EmitDynamic(Binder); break; + case 15: compiler.Instructions.EmitDynamic(Binder); break; } } else { base.AddInstructions(compiler); diff --git a/src/ipy/IronPython/Compiler/PythonGlobal.cs b/src/ipy/IronPython/Compiler/PythonGlobal.cs index d0bd28584..c67c1f43c 100644 --- a/src/ipy/IronPython/Compiler/PythonGlobal.cs +++ b/src/ipy/IronPython/Compiler/PythonGlobal.cs @@ -8,12 +8,14 @@ using System.Diagnostics; using System.Reflection; -using IronPython.Runtime; -using IronPython.Runtime.Operations; - +using Microsoft.Scripting; +using Microsoft.Scripting.Ast; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime; +using IronPython.Runtime.Operations; + namespace IronPython.Compiler { /// /// Provides cached global variable for modules to enable optimized access to diff --git a/src/ipy/IronPython/Compiler/PythonGlobalVariableExpression.cs b/src/ipy/IronPython/Compiler/PythonGlobalVariableExpression.cs index 5ce026ef1..e108d8997 100644 --- a/src/ipy/IronPython/Compiler/PythonGlobalVariableExpression.cs +++ b/src/ipy/IronPython/Compiler/PythonGlobalVariableExpression.cs @@ -2,20 +2,22 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Diagnostics; using System.Linq.Expressions; -using IronPython.Runtime; -using IronPython.Runtime.Operations; +using System; +using System.Diagnostics; +using Microsoft.Scripting; using Microsoft.Scripting.Ast; using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime; +using IronPython.Runtime.Operations; + namespace IronPython.Compiler { - internal interface IPythonVariableExpression { + internal interface IPythonVariableExpression { Expression/*!*/ Assign(Expression/*!*/ value); Expression/*!*/ Delete(); Expression/*!*/ Create(); @@ -91,7 +93,7 @@ public override bool CanReduce { public Expression/*!*/ RawValue() { return new PythonRawGlobalValueExpression(this); - } + } public Expression/*!*/ Assign(Expression/*!*/ value) { return new PythonSetGlobalVariableExpression(this, value); diff --git a/src/ipy/IronPython/Compiler/PythonSavableScriptCode.cs b/src/ipy/IronPython/Compiler/PythonSavableScriptCode.cs index 2fc82716f..78a70bcd6 100644 --- a/src/ipy/IronPython/Compiler/PythonSavableScriptCode.cs +++ b/src/ipy/IronPython/Compiler/PythonSavableScriptCode.cs @@ -3,15 +3,20 @@ // See the LICENSE file in the project root for more information. #if FEATURE_REFEMIT +using System.Linq.Expressions; + using System; using System.Collections.Generic; -using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using Microsoft.Scripting; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + +using IronPython.Runtime; +using IronPython.Runtime.Operations; namespace IronPython.Compiler { /// @@ -22,7 +27,7 @@ internal class PythonSavableScriptCode : SavableScriptCode, ICustomScriptCodeDat private readonly Expression _code; private readonly string[] _names; private readonly string _moduleName; - + public PythonSavableScriptCode(Expression code, SourceUnit sourceUnit, string[] names, string moduleName) : base(sourceUnit) { _code = code; diff --git a/src/ipy/IronPython/Compiler/PythonScriptCode.cs b/src/ipy/IronPython/Compiler/PythonScriptCode.cs index ef5d71f5a..fdda7b685 100644 --- a/src/ipy/IronPython/Compiler/PythonScriptCode.cs +++ b/src/ipy/IronPython/Compiler/PythonScriptCode.cs @@ -2,21 +2,23 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Diagnostics; using System.Linq.Expressions; +using Microsoft.Scripting.Ast; +using MSAst = System.Linq.Expressions; -using IronPython.Compiler.Ast; -using IronPython.Runtime; -using IronPython.Runtime.Operations; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; using Microsoft.Scripting; -using Microsoft.Scripting.Ast; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using MSAst = System.Linq.Expressions; +using IronPython.Compiler.Ast; +using IronPython.Runtime; +using IronPython.Runtime.Operations; namespace IronPython.Compiler { @@ -46,7 +48,7 @@ public override object Run() { public override object Run(Scope scope) { CodeContext ctx = GetContextForScope(scope, SourceUnit); - + if (SourceUnit.Kind == SourceCodeKind.Expression) { return EvalWrapper(ctx); } @@ -125,10 +127,10 @@ private bool ShouldInterpret(PythonContext pc) { } private static PythonConstantExpression ExtractConstant(LightExpression lambda) { - if (!(lambda.Body is BlockExpression body) || - body.Expressions.Count != 2 || - !(body.Expressions[0] is DebugInfoExpression) || - body.Expressions[1].NodeType != ExpressionType.Convert || + if (!(lambda.Body is BlockExpression body) || + body.Expressions.Count != 2 || + !(body.Expressions[0] is DebugInfoExpression) || + body.Expressions[1].NodeType != ExpressionType.Convert || !(((MSAst.UnaryExpression)body.Expressions[1]).Operand is PythonConstantExpression)) { return null; } diff --git a/src/ipy/IronPython/Compiler/ReducableDynamicExpression.cs b/src/ipy/IronPython/Compiler/ReducableDynamicExpression.cs index 2b5d16bf3..7d12f0734 100644 --- a/src/ipy/IronPython/Compiler/ReducableDynamicExpression.cs +++ b/src/ipy/IronPython/Compiler/ReducableDynamicExpression.cs @@ -2,13 +2,17 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; +using Microsoft.Scripting.Ast; + using System; using System.Collections.Generic; +using System.Diagnostics; +using System.Reflection; +using System.Reflection.Emit; +using System.Runtime.CompilerServices; using System.Dynamic; -using System.Linq.Expressions; - using Microsoft.Scripting.Actions; -using Microsoft.Scripting.Ast; namespace IronPython.Compiler { /// diff --git a/src/ipy/IronPython/Compiler/RunnableScriptCode.cs b/src/ipy/IronPython/Compiler/RunnableScriptCode.cs index 82dc2ee83..6865bfdc0 100644 --- a/src/ipy/IronPython/Compiler/RunnableScriptCode.cs +++ b/src/ipy/IronPython/Compiler/RunnableScriptCode.cs @@ -7,11 +7,12 @@ using System.Diagnostics; using System.Threading; -using IronPython.Runtime; -using IronPython.Runtime.Operations; - using Microsoft.Scripting; using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + +using IronPython.Runtime; +using IronPython.Runtime.Operations; namespace IronPython.Compiler { internal abstract class RunnableScriptCode : ScriptCode { @@ -82,7 +83,7 @@ public FunctionCode Code { } public abstract FunctionCode GetFunctionCode(bool register); - + protected void PushFrame(CodeContext context, FunctionCode code) { if (((PythonContext)SourceUnit.LanguageContext).PythonOptions.Frames) { PythonOps.PushFrame(context, code); diff --git a/src/ipy/IronPython/Compiler/RuntimeScriptCode.cs b/src/ipy/IronPython/Compiler/RuntimeScriptCode.cs index a5cdbb7fb..6e0069b72 100644 --- a/src/ipy/IronPython/Compiler/RuntimeScriptCode.cs +++ b/src/ipy/IronPython/Compiler/RuntimeScriptCode.cs @@ -2,19 +2,20 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using MSAst = System.Linq.Expressions; + using System; using System.Diagnostics; using System.Threading; -using IronPython.Compiler.Ast; -using IronPython.Runtime; -using IronPython.Runtime.Operations; - using Microsoft.Scripting; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; -using MSAst = System.Linq.Expressions; +using IronPython.Compiler.Ast; +using IronPython.Runtime; +using IronPython.Runtime.Operations; namespace IronPython.Compiler { /// @@ -83,7 +84,7 @@ private object InvokeTarget(Scope scope) { // exec/eval code. Therefore we don't need to do any of that here. return _unoptimizedCode.Run(scope); } - + private object OptimizedEvalWrapper(FunctionCode funcCode) { try { return _optimizedTarget(funcCode); @@ -106,7 +107,7 @@ private void EnsureCompiled() { private Func/*!*/ Compile() { var pco = (PythonCompilerOptions)Ast.CompilerContext.Options; var pc = (PythonContext)SourceUnit.LanguageContext; - + if (pc.ShouldInterpret(pco, SourceUnit)) { return ((Microsoft.Scripting.Ast.LightExpression>)Ast.GetLambda()).Compile(pc.Options.CompilationThreshold); } else { diff --git a/src/ipy/IronPython/Compiler/ToDiskCompilationMode.cs b/src/ipy/IronPython/Compiler/ToDiskCompilationMode.cs index 1bca21ce7..40c089791 100644 --- a/src/ipy/IronPython/Compiler/ToDiskCompilationMode.cs +++ b/src/ipy/IronPython/Compiler/ToDiskCompilationMode.cs @@ -4,15 +4,19 @@ #if FEATURE_REFEMIT -using System.Collections.Generic; +using MSAst = System.Linq.Expressions; -using IronPython.Runtime.Operations; +using System; +using System.Collections.Generic; using Microsoft.Scripting; using Microsoft.Scripting.Ast; +using Microsoft.Scripting.Utils; + +using IronPython.Runtime; +using IronPython.Runtime.Operations; using AstUtils = Microsoft.Scripting.Ast.Utils; -using MSAst = System.Linq.Expressions; namespace IronPython.Compiler.Ast { diff --git a/src/ipy/IronPython/Compiler/Token.cs b/src/ipy/IronPython/Compiler/Token.cs index 11c1dfb5c..88ed87b1f 100644 --- a/src/ipy/IronPython/Compiler/Token.cs +++ b/src/ipy/IronPython/Compiler/Token.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System; - +using System.Dynamic; using Microsoft.Scripting; namespace IronPython.Compiler { diff --git a/src/ipy/IronPython/Compiler/UncollectableCompilationMode.cs b/src/ipy/IronPython/Compiler/UncollectableCompilationMode.cs index 4901385e0..15ece0f17 100644 --- a/src/ipy/IronPython/Compiler/UncollectableCompilationMode.cs +++ b/src/ipy/IronPython/Compiler/UncollectableCompilationMode.cs @@ -11,15 +11,16 @@ using System.Reflection; using System.Runtime.CompilerServices; -using IronPython.Runtime; - +using Microsoft.Scripting; using Microsoft.Scripting.Ast; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Utils; -using AstUtils = Microsoft.Scripting.Ast.Utils; +using IronPython.Runtime; + using MSAst = System.Linq.Expressions; +using AstUtils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Compiler.Ast { @@ -48,7 +49,7 @@ public override LightLambdaExpression ReduceAst(PythonAst instance, string name) public override MSAst.Expression/*!*/ GetConstant(object value) { // if we can emit the value and we won't be continiously boxing/unboxing // then don't bother caching the value in a static field. - + // TODO: Sometimes we don't want to pre-box the values, such as if it's an int // going to a call site which can be strongly typed. We need to coordinate // more with whoever consumes the values. @@ -176,7 +177,7 @@ public void AddInstructions(LightCompiler compiler) { public static SiteInfo/*!*/ NextSite(DynamicMetaObjectBinder/*!*/ binder) where T : class { lock (StorageData.SiteLockObj) { int index = SiteStorage.SiteCount++; - + int arrIndex = index - StorageData.SiteTypes * StorageData.StaticFields; Type storageType = SiteStorage.SiteStorageType(index); @@ -238,7 +239,7 @@ public override void PublishContext(CodeContext/*!*/ context, ConstantInfo/*!*/ ((CodeContextExpression)codeContextInfo.Expression).Context = context; } - + private static void PublishConstant(object constant, ConstantInfo info) { StorageData.ConstantStorageType(info.Offset); @@ -308,7 +309,7 @@ public static DelegateCache FirstCacheNode(Type/*!*/ argType) { public DelegateCache NextCacheNode(Type/*!*/ argType) { Assert.NotNull(argType); - + DelegateCache nextCacheNode; if (TypeChain == null) { TypeChain = new Dictionary(); @@ -331,7 +332,7 @@ internal abstract class ReducibleExpression : MSAst.Expression { private readonly int _offset; private int _start = -1; private FieldInfo _fieldInfo; - + public ReducibleExpression(int offset) { _offset = offset; } @@ -340,7 +341,7 @@ public ReducibleExpression(int offset) { public abstract int FieldCount { get; } public abstract override Type/*!*/ Type { get; } protected abstract Type/*!*/ GetStorageType(int index); - + public FieldInfo FieldInfo { get { return _fieldInfo; @@ -431,7 +432,7 @@ public override Type/*!*/ Type { return returnType; } else { return typeof(object); - } + } } } diff --git a/src/ipy/IronPython/Hosting/Python.cs b/src/ipy/IronPython/Hosting/Python.cs index e5acde0ba..32e666307 100644 --- a/src/ipy/IronPython/Hosting/Python.cs +++ b/src/ipy/IronPython/Hosting/Python.cs @@ -5,14 +5,14 @@ using System; using System.Collections.Generic; +using Microsoft.Scripting.Utils; +using Microsoft.Scripting.Hosting; +using Microsoft.Scripting.Hosting.Providers; + using IronPython.Modules; using IronPython.Runtime; using IronPython.Runtime.Exceptions; -using Microsoft.Scripting.Hosting; -using Microsoft.Scripting.Hosting.Providers; -using Microsoft.Scripting.Utils; - namespace IronPython.Hosting { /// @@ -198,11 +198,11 @@ public static class Python { /// /// /// - public static void ImportModule(this ScriptScope/*!*/ scope, string/*!*/ moduleName) { - ContractUtils.RequiresNotNull(scope, nameof(scope)); - ContractUtils.RequiresNotNull(moduleName, nameof(moduleName)); + public static void ImportModule (this ScriptScope/*!*/ scope, string/*!*/ moduleName) { + ContractUtils.RequiresNotNull (scope, nameof(scope)); + ContractUtils.RequiresNotNull (moduleName, nameof(moduleName)); - scope.SetVariable(moduleName, scope.Engine.ImportModule(moduleName)); + scope.SetVariable (moduleName, scope.Engine.ImportModule (moduleName)); } /// diff --git a/src/ipy/IronPython/Hosting/PythonCodeDomCodeGen.cs b/src/ipy/IronPython/Hosting/PythonCodeDomCodeGen.cs index 75f150ca1..76c711b01 100644 --- a/src/ipy/IronPython/Hosting/PythonCodeDomCodeGen.cs +++ b/src/ipy/IronPython/Hosting/PythonCodeDomCodeGen.cs @@ -4,7 +4,6 @@ using System.CodeDom; using System.Collections.Generic; - using Microsoft.Scripting.Runtime; #if FEATURE_CODEDOM @@ -45,7 +44,8 @@ protected override void WriteSnippetStatement(CodeSnippetStatement s) { int indentLen = lastLine.Length; if (indentLen > _indents.Peek()) { _indents.Push(indentLen); - } else { + } + else { while (indentLen < _indents.Peek()) { _indents.Pop(); } diff --git a/src/ipy/IronPython/Hosting/PythonConsoleOptions.cs b/src/ipy/IronPython/Hosting/PythonConsoleOptions.cs index d79afa33f..b8b3dde7e 100644 --- a/src/ipy/IronPython/Hosting/PythonConsoleOptions.cs +++ b/src/ipy/IronPython/Hosting/PythonConsoleOptions.cs @@ -3,8 +3,7 @@ // See the LICENSE file in the project root for more information. using System; - -using Microsoft.Scripting.Hosting.Shell; +using Microsoft.Scripting.Hosting.Shell; namespace IronPython.Hosting { [CLSCompliant(true)] diff --git a/src/ipy/IronPython/Hosting/PythonService.cs b/src/ipy/IronPython/Hosting/PythonService.cs index 6948d16b1..c790b9b8e 100644 --- a/src/ipy/IronPython/Hosting/PythonService.cs +++ b/src/ipy/IronPython/Hosting/PythonService.cs @@ -11,10 +11,8 @@ using System; using System.Collections.Generic; using System.Threading; - using IronPython.Runtime; using IronPython.Runtime.Operations; - using Microsoft.Scripting.Hosting; using Microsoft.Scripting.Hosting.Providers; using Microsoft.Scripting.Utils; @@ -78,7 +76,7 @@ public PythonService(PythonContext/*!*/ context, ScriptEngine/*!*/ engine) { _context.PublishModule(name, module); module.__init__(name, docString); module.__dict__["__file__"] = filename; - + return HostingHelpers.CreateScriptScope(_engine, module.Scope); } @@ -116,7 +114,7 @@ public ObjectHandle GetSetCommandDispatcher(ObjectHandle dispatcher) { if (res != null) { return new ObjectHandle(res); } - + return null; } diff --git a/src/ipy/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs b/src/ipy/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs index bd64248c7..2f987168e 100644 --- a/src/ipy/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs +++ b/src/ipy/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; +using System.Buffers; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; diff --git a/src/ipy/IronPython/Modules/_ast.cs b/src/ipy/IronPython/Modules/_ast.cs index ce982b244..42d5deabc 100644 --- a/src/ipy/IronPython/Modules/_ast.cs +++ b/src/ipy/IronPython/Modules/_ast.cs @@ -10,6 +10,7 @@ using System.Collections; using System.Collections.Generic; using System.Diagnostics; +using System.Linq; using System.Numerics; using System.Runtime.InteropServices; diff --git a/src/ipy/IronPython/Modules/_fileio.cs b/src/ipy/IronPython/Modules/_fileio.cs index ac5d1a774..1069ea15b 100644 --- a/src/ipy/IronPython/Modules/_fileio.cs +++ b/src/ipy/IronPython/Modules/_fileio.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Diagnostics; using System.Dynamic; using System.IO; using System.Linq.Expressions; @@ -18,6 +19,7 @@ using Microsoft.Scripting; using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; // TODO: Documentation copied from CPython is inadequate in some places and wrong in others. @@ -125,7 +127,8 @@ public FileIO(CodeContext/*!*/ context, string name, string mode = "r", bool clo default: throw new InvalidOperationException(); } - } else { + } + else { object fdobj = PythonOps.CallWithContext(context, opener, name, flags); if (fdobj is int fd) { if (fd < 0) { diff --git a/src/ipy/IronPython/Modules/_imp.cs b/src/ipy/IronPython/Modules/_imp.cs index 11d81dee0..1e91700cf 100644 --- a/src/ipy/IronPython/Modules/_imp.cs +++ b/src/ipy/IronPython/Modules/_imp.cs @@ -10,6 +10,8 @@ using IronPython.Runtime.Operations; using IronPython.Runtime.Types; +using Microsoft.Scripting.Utils; + [assembly: PythonModule("_imp", typeof(IronPython.Modules.PythonImport))] namespace IronPython.Modules { public static class PythonImport { @@ -57,7 +59,7 @@ public static void release_lock(CodeContext/*!*/ context) { throw PythonOps.RuntimeError("not holding the import lock"); } SetLockCount(context, lockCount - 1); - } + } } public static object init_builtin(CodeContext/*!*/ context, [NotNone] string/*!*/ name) { @@ -105,7 +107,7 @@ public static int is_builtin(CodeContext/*!*/ context, string/*!*/ name) { return -1; } - + return 1; } return 0; diff --git a/src/ipy/IronPython/Modules/_io.cs b/src/ipy/IronPython/Modules/_io.cs index e347cfd85..c9e9818bc 100644 --- a/src/ipy/IronPython/Modules/_io.cs +++ b/src/ipy/IronPython/Modules/_io.cs @@ -14,15 +14,15 @@ using System.Runtime.InteropServices; using System.Text; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + using IronPython.Runtime; using IronPython.Runtime.Binding; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - [assembly: PythonModule("_io", typeof(IronPython.Modules.PythonIOModule))] namespace IronPython.Modules { public static partial class PythonIOModule { @@ -32,7 +32,7 @@ public static partial class PythonIOModule { private static readonly object _unsupportedOperationKey = new object(); // Values of the O_flags below has to be identical with flags defined in PythonNT - + #region Generated Common O_Flags // *** BEGIN GENERATED CODE *** @@ -165,18 +165,18 @@ public virtual bool isatty(CodeContext/*!*/ context) { } [PythonHidden] - public virtual Bytes peek(CodeContext/*!*/ context, int length = 0) { + public virtual Bytes peek(CodeContext/*!*/ context, int length=0) { _checkClosed(); throw AttributeError("peek"); } [PythonHidden] - public virtual object read(CodeContext/*!*/ context, object length = null) { + public virtual object read(CodeContext/*!*/ context, object length=null) { throw AttributeError("read"); } [PythonHidden] - public virtual Bytes read1(CodeContext/*!*/ context, int length = 0) { + public virtual Bytes read1(CodeContext/*!*/ context, int length=0) { throw AttributeError("read1"); } @@ -194,7 +194,7 @@ public virtual object readline(CodeContext/*!*/ context, int limit) { if (cur == null) { break; } - + Bytes curBytes = GetBytes(cur, "read()"); if (curBytes.Count == 0) { break; @@ -210,7 +210,7 @@ public virtual object readline(CodeContext/*!*/ context, int limit) { return Bytes.Concat(res, count); } - public object readline(CodeContext/*!*/ context, object limit = null) { + public object readline(CodeContext/*!*/ context, object limit=null) { return readline(context, GetInt(limit, -1)); } @@ -218,7 +218,7 @@ public virtual PythonList readlines() { return readlines(null); } - public virtual PythonList readlines(object hint = null) { + public virtual PythonList readlines(object hint=null) { int size = GetInt(hint, -1); PythonList res = new PythonList(); @@ -255,7 +255,7 @@ public virtual PythonList readlines(object hint = null) { return res; } - public virtual BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optional] object whence) { + public virtual BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optional]object whence) { throw UnsupportedOperation(context, "seek"); } @@ -267,7 +267,7 @@ public virtual BigInteger tell(CodeContext/*!*/ context) { return seek(context, 0, 1); } - public virtual BigInteger truncate(CodeContext/*!*/ context, object pos = null) { + public virtual BigInteger truncate(CodeContext/*!*/ context, object pos=null) { throw UnsupportedOperation(context, "truncate"); } @@ -406,7 +406,7 @@ private PythonDictionary EnsureCustomAttributes() { DynamicMetaObject IDynamicMetaObjectProvider.GetMetaObject(Expression parameter) { return new MetaExpandable<_IOBase>(parameter, this); } - + #endregion #region Private implementation details @@ -428,7 +428,7 @@ internal Exception AttributeError(string attrName) { internal Exception InvalidPosition(BigInteger pos) { return PythonOps.IOError("Raw stream returned invalid position {0}", pos); } - + #endregion } @@ -438,7 +438,7 @@ public _RawIOBase(CodeContext/*!*/ context) : base(context) { } #region Public API - public override object read(CodeContext/*!*/ context, object size = null) { + public override object read(CodeContext/*!*/ context, object size=null) { int sizeInt = GetInt(size, -1); if (sizeInt < 0) { return readall(context); @@ -484,7 +484,7 @@ public override BigInteger write(CodeContext/*!*/ context, object buf) { } #endregion - + #region IDynamicMetaObjectProvider Members DynamicMetaObject IDynamicMetaObjectProvider.GetMetaObject(Expression parameter) { @@ -504,7 +504,7 @@ public virtual object detach(CodeContext/*!*/ context) { throw UnsupportedOperation(context, "detach"); } - public override object read(CodeContext/*!*/ context, object length = null) { + public override object read(CodeContext/*!*/ context, object length=null) { throw UnsupportedOperation(context, "read"); } @@ -577,15 +577,15 @@ public virtual object newlines { get { return null; } } - public override object read(CodeContext/*!*/ context, [DefaultParameterValue(-1)] object length) { + public override object read(CodeContext/*!*/ context, [DefaultParameterValue(-1)]object length) { throw UnsupportedOperation(context, "read"); } - public override object readline(CodeContext/*!*/ context, int limit = -1) { + public override object readline(CodeContext/*!*/ context, int limit=-1) { throw UnsupportedOperation(context, "readline"); } - public override BigInteger truncate(CodeContext/*!*/ context, object pos = null) { + public override BigInteger truncate(CodeContext/*!*/ context, object pos=null) { throw UnsupportedOperation(context, "truncate"); } @@ -614,7 +614,7 @@ public class BufferedReader : _BufferedIOBase, IDynamicMetaObjectProvider { private int _readBufPos; private long _absPos = -1; - internal static BufferedReader Create(CodeContext/*!*/ context, object raw, int buffer_size = DEFAULT_BUFFER_SIZE) { + internal static BufferedReader Create(CodeContext/*!*/ context, object raw, int buffer_size=DEFAULT_BUFFER_SIZE) { var res = new BufferedReader(context, raw, buffer_size); res.__init__(context, raw, buffer_size); return res; @@ -629,7 +629,7 @@ params object[] args public void __init__( CodeContext/*!*/ context, object raw, - int buffer_size = DEFAULT_BUFFER_SIZE + int buffer_size=DEFAULT_BUFFER_SIZE ) { this.raw = raw; @@ -745,7 +745,7 @@ public override bool isatty(CodeContext/*!*/ context) { #endregion - public override object read(CodeContext/*!*/ context, object length = null) { + public override object read(CodeContext/*!*/ context, object length=null) { int len = GetInt(length, -1); if (len < -1) { @@ -791,7 +791,7 @@ public override object read(CodeContext/*!*/ context, object length = null) { } break; } - chunks.Add(chunk); + chunks.Add(chunk); count += chunk.Count; if (read1) break; } @@ -880,7 +880,7 @@ private Bytes PeekNoLock(CodeContext/*!*/ context, int length) { return _readBuf; } - public override Bytes read1(CodeContext/*!*/ context, int length = 0) { + public override Bytes read1(CodeContext/*!*/ context, int length=0) { if (length == 0) { return Bytes.Empty; } else if (length < 0) { @@ -975,13 +975,13 @@ public override BigInteger tell(CodeContext/*!*/ context) { return res - _readBuf.Count + _readBufPos; } - public BigInteger seek(double offset, [Optional] object whence) { + public BigInteger seek(double offset, [Optional]object whence) { _checkClosed(); throw PythonOps.TypeError("an integer is required"); } - public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optional] object whence) { + public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optional]object whence) { int whenceInt = GetInt(whence); if (whenceInt < 0 || whenceInt > 2) { throw PythonOps.ValueError("invalid whence ({0}, should be 0, 1, or 2)", whenceInt); @@ -1023,7 +1023,7 @@ public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optio ResetReadBuf(); if (pos < 0) { throw InvalidPosition(pos); - } + } GC.KeepAlive(this); return pos; @@ -1082,8 +1082,8 @@ public class BufferedWriter : _BufferedIOBase, IDynamicMetaObjectProvider { internal static BufferedWriter Create(CodeContext/*!*/ context, object raw, - int buffer_size = DEFAULT_BUFFER_SIZE, - object max_buffer_size = null) { + int buffer_size=DEFAULT_BUFFER_SIZE, + object max_buffer_size=null) { var res = new BufferedWriter(context, raw, buffer_size, max_buffer_size); res.__init__(context, raw, buffer_size, max_buffer_size); @@ -1093,8 +1093,8 @@ internal static BufferedWriter Create(CodeContext/*!*/ context, public BufferedWriter( CodeContext/*!*/ context, object raw, - int buffer_size = DEFAULT_BUFFER_SIZE, - object max_buffer_size = null + int buffer_size=DEFAULT_BUFFER_SIZE, + object max_buffer_size=null ) : base(context) { } @@ -1102,8 +1102,8 @@ public BufferedWriter( public void __init__( CodeContext/*!*/ context, object raw, - int buffer_size = DEFAULT_BUFFER_SIZE, - object max_buffer_size = null + int buffer_size=DEFAULT_BUFFER_SIZE, + object max_buffer_size=null ) { if (max_buffer_size != null) { PythonOps.Warn(context, PythonExceptions.DeprecationWarning, "max_buffer_size is deprecated"); @@ -1269,7 +1269,7 @@ public override BigInteger write(CodeContext/*!*/ context, object buf) { } } - public override BigInteger truncate(CodeContext/*!*/ context, object pos = null) { + public override BigInteger truncate(CodeContext/*!*/ context, object pos=null) { lock (this) { FlushNoLock(context); if (pos == null) { @@ -1351,13 +1351,13 @@ public override BigInteger tell(CodeContext/*!*/ context) { return res + _writeBuf.Count; } - public BigInteger seek(double offset, [Optional] object whence) { + public BigInteger seek(double offset, [Optional]object whence) { _checkClosed(); throw PythonOps.TypeError("an integer is required"); } - public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optional] object whence) { + public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optional]object whence) { int whenceInt = GetInt(whence); if (whenceInt < 0 || whenceInt > 2) { throw PythonOps.ValueError("invalid whence ({0}, should be 0, 1, or 2)", whenceInt); @@ -1401,7 +1401,7 @@ DynamicMetaObject IDynamicMetaObjectProvider.GetMetaObject(Expression parameter) [PythonType] public class BufferedRandom : _BufferedIOBase, IDynamicMetaObjectProvider { private _IOBase _inner; - + private int _bufSize; private Bytes _readBuf; private int _readBufPos; @@ -1409,8 +1409,8 @@ public class BufferedRandom : _BufferedIOBase, IDynamicMetaObjectProvider { internal static BufferedRandom Create(CodeContext/*!*/ context, _IOBase raw, - int buffer_size = DEFAULT_BUFFER_SIZE, - object max_buffer_size = null) { + int buffer_size=DEFAULT_BUFFER_SIZE, + object max_buffer_size=null) { var res = new BufferedRandom(context, raw, buffer_size, max_buffer_size); res.__init__(context, raw, buffer_size, max_buffer_size); return res; @@ -1419,16 +1419,16 @@ internal static BufferedRandom Create(CodeContext/*!*/ context, public BufferedRandom( CodeContext/*!*/ context, _IOBase raw, - int buffer_size = DEFAULT_BUFFER_SIZE, - object max_buffer_size = null + int buffer_size=DEFAULT_BUFFER_SIZE, + object max_buffer_size=null ) : base(context) { } public void __init__( CodeContext/*!*/ context, _IOBase raw, - int buffer_size = DEFAULT_BUFFER_SIZE, - object max_buffer_size = null + int buffer_size=DEFAULT_BUFFER_SIZE, + object max_buffer_size=null ) { if (max_buffer_size != null) { PythonOps.Warn(context, PythonExceptions.DeprecationWarning, "max_buffer_size is deprecated"); @@ -1530,7 +1530,7 @@ public override bool isatty(CodeContext/*!*/ context) { #region BufferedReader - public override object read(CodeContext/*!*/ context, object length = null) { + public override object read(CodeContext/*!*/ context, object length=null) { flush(context); int len = GetInt(length, -1); @@ -1611,7 +1611,7 @@ private Bytes ReadNoLock(CodeContext/*!*/ context, int length) { } } - public override Bytes peek(CodeContext/*!*/ context, int length = 0) { + public override Bytes peek(CodeContext/*!*/ context, int length=0) { _checkClosed(); flush(context); @@ -1639,7 +1639,7 @@ private Bytes PeekNoLock(CodeContext/*!*/ context, int length) { return _readBuf; } - public override Bytes read1(CodeContext/*!*/ context, int length = 0) { + public override Bytes read1(CodeContext/*!*/ context, int length=0) { flush(context); if (length == 0) { return Bytes.Empty; @@ -1756,13 +1756,13 @@ public override BigInteger readinto(CodeContext/*!*/ context, object buf) { return base.readinto(context, buf); } - public BigInteger seek(double offset, [Optional] object whence) { + public BigInteger seek(double offset, [Optional]object whence) { _checkClosed(); throw PythonOps.TypeError("an integer is required"); } - public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optional] object whence) { + public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optional]object whence) { int whenceInt = GetInt(whence); if (whenceInt < 0 || whenceInt > 2) { throw PythonOps.ValueError("invalid whence ({0}, should be 0, 1, or 2)", whenceInt); @@ -1786,7 +1786,7 @@ public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optio } } - public override BigInteger truncate(CodeContext/*!*/ context, object pos = null) { + public override BigInteger truncate(CodeContext/*!*/ context, object pos=null) { lock (this) { FlushNoLock(context); if (pos == null) { @@ -1831,8 +1831,8 @@ public BufferedRWPair( CodeContext/*!*/ context, object reader, object writer, - int buffer_size = DEFAULT_BUFFER_SIZE, - object max_buffer_size = null + int buffer_size=DEFAULT_BUFFER_SIZE, + object max_buffer_size=null ) : base(context) { } @@ -1840,8 +1840,8 @@ public void __init__( CodeContext/*!*/ context, object reader, object writer, - int buffer_size = DEFAULT_BUFFER_SIZE, - object max_buffer_size = null + int buffer_size=DEFAULT_BUFFER_SIZE, + object max_buffer_size=null ) { if (max_buffer_size != null) { PythonOps.Warn(context, PythonExceptions.DeprecationWarning, "max_buffer_size is deprecated"); @@ -1879,7 +1879,7 @@ public object writer { } } - public override object read(CodeContext/*!*/ context, object length = null) { + public override object read(CodeContext/*!*/ context, object length=null) { var res = _reader.read(context, length); GC.KeepAlive(this); return res; @@ -1897,7 +1897,7 @@ public override BigInteger write(CodeContext/*!*/ context, object buf) { return res; } - public override Bytes peek(CodeContext/*!*/ context, int length = 0) { + public override Bytes peek(CodeContext/*!*/ context, int length=0) { var res = _reader.peek(context, length); GC.KeepAlive(this); return res; @@ -2006,7 +2006,7 @@ public void __init__( bool line_buffering = false, bool write_through = false ) { - switch (newline) { + switch(newline) { case null: case "": case "\n": @@ -2208,7 +2208,7 @@ public override BigInteger tell(CodeContext/*!*/ context) { // skip backwards to snapshot point pos -= _nextInput.Count; - + // determine number of decoded chars used up after snapshot int skip = _decodedCharsUsed; if (skip == 0) { @@ -2288,7 +2288,7 @@ public override BigInteger tell(CodeContext/*!*/ context) { } } - public override BigInteger truncate(CodeContext/*!*/ context, object pos = null) { + public override BigInteger truncate(CodeContext/*!*/ context, object pos=null) { flush(context); if (pos == null) { pos = tell(context); @@ -2326,9 +2326,9 @@ public override object detach(CodeContext/*!*/ context) { return res; } - public BigInteger seek(double offset, [Optional] object whence) => throw PythonOps.TypeError("integer argument expected, got float"); + public BigInteger seek(double offset, [Optional]object whence) => throw PythonOps.TypeError("integer argument expected, got float"); - public override BigInteger seek(CodeContext/*!*/ context, BigInteger cookie, [Optional] object whence) { + public override BigInteger seek(CodeContext/*!*/ context, BigInteger cookie, [Optional]object whence) { int whenceInt = GetInt(whence); if (closed) { throw PythonOps.ValueError("tell on closed file"); @@ -2460,7 +2460,7 @@ public override BigInteger seek(CodeContext/*!*/ context, BigInteger cookie, [Op return cookie; } - public override object read(CodeContext/*!*/ context, object length = null) { + public override object read(CodeContext/*!*/ context, object length=null) { _checkClosed(); if (!readable(context)) { throw UnsupportedOperationWithMessage(context, "not readable"); @@ -2506,7 +2506,7 @@ public override object read(CodeContext/*!*/ context, object length = null) { } } - public override object readline(CodeContext/*!*/ context, int limit = -1) { + public override object readline(CodeContext/*!*/ context, int limit=-1) { _checkClosed("read from closed file"); if (!readable(context)) { throw UnsupportedOperationWithMessage(context, "not readable"); @@ -2586,7 +2586,7 @@ public override object readline(CodeContext/*!*/ context, int limit = -1) { } #endregion - + #region IEnumerator Members private object _current; @@ -2804,13 +2804,13 @@ private bool ReadChunk(CodeContext/*!*/ context) { public static _IOBase open( CodeContext/*!*/ context, object file, - string mode = "r", - int buffering = -1, - string encoding = null, - string errors = null, - string newline = null, - bool closefd = true, - object opener = null + string mode="r", + int buffering=-1, + string encoding=null, + string errors=null, + string newline=null, + bool closefd=true, + object opener=null ) { string fname = null; if (!Converter.TryConvertToIndex(file, out int fd, false, false)) { @@ -2907,13 +2907,15 @@ internal static TextIOWrapper CreateConsole(PythonContext context, SharedIO io, var fio = new FileIO(cc, sio) { name = name }; var buffer = BufferedReader.Create(cc, fio, DEFAULT_BUFFER_SIZE); return TextIOWrapper.Create(cc, buffer, encoding, null, null, true); - } else if (type == ConsoleStreamType.Output) { + } + else if (type == ConsoleStreamType.Output) { var encoding = StringOps.GetEncodingName(io.OutputEncoding); sio = new StreamBox(io.GetStreamProxy(type), type); var fio = new FileIO(cc, sio) { name = name }; var buffer = BufferedWriter.Create(cc, fio, DEFAULT_BUFFER_SIZE, null); return TextIOWrapper.Create(cc, buffer, encoding, null, null, true); - } else { + } + else { Debug.Assert(type == ConsoleStreamType.ErrorOutput); var encoding = StringOps.GetEncodingName(io.ErrorEncoding); sio = new StreamBox(io.GetStreamProxy(type), type); @@ -2943,13 +2945,13 @@ internal enum LineEnding { private string _errors; #pragma warning restore 414 - public IncrementalNewlineDecoder(object decoder, bool translate, string errors = "strict") { + public IncrementalNewlineDecoder(object decoder, bool translate, string errors="strict") { _decoder = decoder; _translate = translate; _errors = errors; } - public string decode(CodeContext/*!*/ context, [NotNone] IList input, bool final = false) { + public string decode(CodeContext/*!*/ context, [NotNone] IList input, bool final=false) { object output; if (_decoder == null) { output = input.MakeString(); @@ -2973,7 +2975,7 @@ public string decode(CodeContext/*!*/ context, [NotNone] IList input, bool return DecodeWorker(context, decoded, final); } - public string decode(CodeContext/*!*/ context, [NotNone] string input, bool final = false) { + public string decode(CodeContext/*!*/ context, [NotNone] string input, bool final=false) { if (_decoder == null) { return DecodeWorker(context, input, final); } diff --git a/src/ipy/IronPython/Runtime/ArrayData.cs b/src/ipy/IronPython/Runtime/ArrayData.cs index 6f33f48f9..c8f2b60ca 100644 --- a/src/ipy/IronPython/Runtime/ArrayData.cs +++ b/src/ipy/IronPython/Runtime/ArrayData.cs @@ -20,7 +20,7 @@ namespace IronPython.Runtime { internal interface ArrayData : IList { Type StorageType { get; } - bool CanStore([NotNullWhen(true)] object? item); + bool CanStore([NotNullWhen(true)]object? item); int CountItems(object? item); IntPtr GetAddress(); void AddRange(ArrayData value); @@ -131,7 +131,7 @@ public void AddRange(IEnumerable collection) { void ArrayData.AddRange(ArrayData value) => AddRange((ArrayData)value); - bool ArrayData.CanStore([NotNullWhen(true)] object? item) + bool ArrayData.CanStore([NotNullWhen(true)]object? item) => TryConvert(item, out _); public void Clear() { @@ -144,7 +144,7 @@ public void Clear() { public bool Contains(T item) => _size != 0 && IndexOf(item) != -1; - bool IList.Contains([NotNullWhen(true)] object? item) + bool IList.Contains([NotNullWhen(true)]object? item) => TryConvert(item, out T value) && Contains(value); public void CopyTo(T[] array, int arrayIndex) @@ -368,7 +368,7 @@ public void Reverse() public Span AsByteSpan() => MemoryMarshal.AsBytes(_items.AsSpan(0, _size)); - private static bool TryConvert([NotNullWhen(true)] object? value, out T result) { + private static bool TryConvert([NotNullWhen(true)]object? value, out T result) { if (value is null) { result = default; return false; @@ -433,7 +433,7 @@ public void Dispose() { public int Offset => 0; - public string? Format => _flags.HasFlag(BufferFlags.Format) ? _format : null; + public string? Format => _flags.HasFlag(BufferFlags.Format)? _format : null; public int ItemCount => _arrayData.Count; diff --git a/src/ipy/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs b/src/ipy/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs index cd732e55f..9be44b4a9 100644 --- a/src/ipy/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs +++ b/src/ipy/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs @@ -4,12 +4,14 @@ using System; using System.Dynamic; -using System.Linq.Expressions; +using System.Runtime.CompilerServices; -using IronPython.Runtime.Operations; +using System.Linq.Expressions; using Microsoft.Scripting.Actions; +using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; +using IronPython.Runtime.Operations; namespace IronPython.Runtime.Binding { internal partial class BinaryRetTypeBinder : ComboBinder, IExpressionSerializable { @@ -40,7 +42,7 @@ public override Type ReturnType { #region IExpressionSerializable Members public Expression CreateExpression() { - + return Expression.Call( typeof(PythonOps).GetMethod(nameof(PythonOps.MakeComboAction)), BindingHelpers.CreateBinderStateExpression(), diff --git a/src/ipy/IronPython/Runtime/Binding/Binders.cs b/src/ipy/IronPython/Runtime/Binding/Binders.cs index 38479d579..36f0d7f1e 100644 --- a/src/ipy/IronPython/Runtime/Binding/Binders.cs +++ b/src/ipy/IronPython/Runtime/Binding/Binders.cs @@ -2,13 +2,16 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; using System.Dynamic; -using System.Linq.Expressions; using Microsoft.Scripting.Actions; namespace IronPython.Runtime.Binding { + using Ast = Expression; + internal static class Binders { /// /// Backwards compatible Convert for the old sites that need to flow CodeContext @@ -45,7 +48,7 @@ internal static class Binders { public static DynamicMetaObjectBinder UnaryOperationBinder(PythonContext state, PythonOperationKind operatorName) { ExpressionType? et = GetExpressionTypeFromUnaryOperator(operatorName); - + if (et == null) { return state.Operation( operatorName diff --git a/src/ipy/IronPython/Runtime/Binding/BindingHelpers.cs b/src/ipy/IronPython/Runtime/Binding/BindingHelpers.cs index 6d8d41cea..2119d635d 100644 --- a/src/ipy/IronPython/Runtime/Binding/BindingHelpers.cs +++ b/src/ipy/IronPython/Runtime/Binding/BindingHelpers.cs @@ -2,21 +2,22 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; +using System.Numerics; + using System; using System.Diagnostics; using System.Dynamic; -using System.Linq.Expressions; -using System.Numerics; using System.Reflection; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using Microsoft.Scripting.Actions; using Microsoft.Scripting.Actions.Calls; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -94,7 +95,7 @@ internal static CallSignature GetCallSignature(DynamicMetaObjectBinder/*!*/ acti if (action is InvokeMemberBinder cla) { return CallInfoToSignature(cla.CallInfo); } - + // DLR Create action which we hand off to our call code, also // has an argument array. CreateInstanceBinder ca = action as CreateInstanceBinder; @@ -124,7 +125,7 @@ internal static CallSignature GetCallSignature(DynamicMetaObjectBinder/*!*/ acti return action.Defer(args); } - return AddDynamicTestAndDefer(action, + return AddDynamicTestAndDefer(action, action.FallbackInvoke( new DynamicMetaObject( Binders.Get( @@ -195,7 +196,7 @@ internal static bool IsSubclassOf(DynamicMetaObject/*!*/ xType, DynamicMetaObjec PythonType y = MetaPythonObject.GetPythonType(yType); return x.IsSubclassOf(y); } - + private static BuiltinFunction TryConvertToBuiltinFunction(object o) { if (o is BuiltinMethodDescriptor md) { return md.Template; @@ -221,7 +222,7 @@ private static BuiltinFunction TryConvertToBuiltinFunction(object o) { AstUtils.Convert(res.Expression, bestType), AstUtils.Convert(defer, bestType) ), - res.Restrictions + res.Restrictions ); } @@ -236,13 +237,13 @@ private static BuiltinFunction TryConvertToBuiltinFunction(object o) { return res; } - + internal static ValidationInfo/*!*/ GetValidationInfo(DynamicMetaObject/*!*/ tested, PythonType type) { return new ValidationInfo( Ast.AndAlso( Ast.TypeEqual(tested.Expression, type.UnderlyingSystemType), CheckTypeVersion( - AstUtils.Convert(tested.Expression, type.UnderlyingSystemType), + AstUtils.Convert(tested.Expression, type.UnderlyingSystemType), type.Version ) ) @@ -307,9 +308,9 @@ private static BuiltinFunction TryConvertToBuiltinFunction(object o) { internal static Expression AddRecursionCheck(PythonContext pyContext, Expression expr) { ParameterExpression tmp = Ast.Variable(expr.Type, "callres"); - expr = + expr = Ast.Block( - new[] { tmp }, + new [] { tmp }, AstUtils.Try( Ast.Call(typeof(PythonOps).GetMethod(nameof(PythonOps.FunctionPushFrame)), Ast.Constant(pyContext)), Ast.Assign(tmp, expr) diff --git a/src/ipy/IronPython/Runtime/Binding/BindingWarnings.cs b/src/ipy/IronPython/Runtime/Binding/BindingWarnings.cs index 1ba44d942..9776e3297 100644 --- a/src/ipy/IronPython/Runtime/Binding/BindingWarnings.cs +++ b/src/ipy/IronPython/Runtime/Binding/BindingWarnings.cs @@ -4,6 +4,7 @@ using System; using System.Linq.Expressions; +using System.Reflection; using System.Threading; using IronPython.Runtime.Exceptions; diff --git a/src/ipy/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs b/src/ipy/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs index e0ce789de..1760542dc 100644 --- a/src/ipy/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs +++ b/src/ipy/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs @@ -2,9 +2,19 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + +using System; +using System.Collections.Generic; +using System.Diagnostics; using System.Dynamic; +using Microsoft.Scripting; using Microsoft.Scripting.Actions; +using Microsoft.Scripting.Actions.Calls; +using Microsoft.Scripting.Utils; + +using IronPython.Runtime.Operations; using AstUtils = Microsoft.Scripting.Ast.Utils; diff --git a/src/ipy/IronPython/Runtime/Binding/ConditionalBuilder.cs b/src/ipy/IronPython/Runtime/Binding/ConditionalBuilder.cs index 3d05a2c4c..ec61a5a7e 100644 --- a/src/ipy/IronPython/Runtime/Binding/ConditionalBuilder.cs +++ b/src/ipy/IronPython/Runtime/Binding/ConditionalBuilder.cs @@ -2,10 +2,12 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; using System.Collections.Generic; +using System.Text; using System.Dynamic; -using System.Linq.Expressions; namespace IronPython.Runtime.Binding { using Ast = Expression; @@ -61,7 +63,7 @@ public void ExtendLastCondition(Expression condition) { condition); } } - + /// /// Adds the non-conditional terminating node. /// diff --git a/src/ipy/IronPython/Runtime/Binding/ContextArgBuilder.cs b/src/ipy/IronPython/Runtime/Binding/ContextArgBuilder.cs index a137d632a..33edf183f 100644 --- a/src/ipy/IronPython/Runtime/Binding/ContextArgBuilder.cs +++ b/src/ipy/IronPython/Runtime/Binding/ContextArgBuilder.cs @@ -3,9 +3,14 @@ // See the LICENSE file in the project root for more information. using System.Linq.Expressions; -using System.Reflection; +using System.Collections.Generic; +using System.Diagnostics; +using System.Reflection; +using System; +using System.Dynamic; using Microsoft.Scripting.Actions.Calls; +using Microsoft.Scripting.Utils; namespace IronPython.Runtime.Binding { @@ -13,8 +18,8 @@ namespace IronPython.Runtime.Binding { /// ArgBuilder which provides the CodeContext parameter to a method. /// public sealed class ContextArgBuilder : ArgBuilder { - public ContextArgBuilder(ParameterInfo info) - : base(info) { + public ContextArgBuilder(ParameterInfo info) + : base(info){ } public override int Priority { diff --git a/src/ipy/IronPython/Runtime/Binding/ConversionBinder.cs b/src/ipy/IronPython/Runtime/Binding/ConversionBinder.cs index 038974434..61349b7aa 100644 --- a/src/ipy/IronPython/Runtime/Binding/ConversionBinder.cs +++ b/src/ipy/IronPython/Runtime/Binding/ConversionBinder.cs @@ -2,25 +2,26 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Dynamic; -using System.Linq.Expressions; using System.Numerics; -using System.Reflection; using System.Runtime.CompilerServices; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; +using System.Reflection; + namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -545,7 +546,7 @@ public override bool Equals(object obj) { return false; } - return ob._context.Binder == _context.Binder && + return ob._context.Binder == _context.Binder && _kind == ob._kind && base.Equals(obj) && _retObject == ob._retObject; } diff --git a/src/ipy/IronPython/Runtime/Binding/CreateFallbackBinder.cs b/src/ipy/IronPython/Runtime/Binding/CreateFallbackBinder.cs index 07b739b28..2b6a9aaa0 100644 --- a/src/ipy/IronPython/Runtime/Binding/CreateFallbackBinder.cs +++ b/src/ipy/IronPython/Runtime/Binding/CreateFallbackBinder.cs @@ -2,7 +2,17 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + +using System; +using System.Collections.Generic; +using System.Diagnostics; using System.Dynamic; +using IronPython.Runtime.Operations; +using Microsoft.Scripting; +using Microsoft.Scripting.Actions; +using Microsoft.Scripting.Utils; +using AstUtils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Runtime.Binding { /// diff --git a/src/ipy/IronPython/Runtime/Binding/FastBindResult.cs b/src/ipy/IronPython/Runtime/Binding/FastBindResult.cs index 7f4a07761..e6866a55c 100644 --- a/src/ipy/IronPython/Runtime/Binding/FastBindResult.cs +++ b/src/ipy/IronPython/Runtime/Binding/FastBindResult.cs @@ -2,7 +2,17 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + +using System; +using System.Dynamic; +using System.Runtime.CompilerServices; + +using Microsoft.Scripting.Actions; + namespace IronPython.Runtime.Binding { + using Ast = Expression; + internal readonly struct FastBindResult where T : class { public readonly T Target; public readonly bool ShouldCache; diff --git a/src/ipy/IronPython/Runtime/Binding/FastGetBase.cs b/src/ipy/IronPython/Runtime/Binding/FastGetBase.cs index 9ab7f96d7..bb849308c 100644 --- a/src/ipy/IronPython/Runtime/Binding/FastGetBase.cs +++ b/src/ipy/IronPython/Runtime/Binding/FastGetBase.cs @@ -5,6 +5,8 @@ using System; using System.Runtime.CompilerServices; +using Microsoft.Scripting.Utils; + using IronPython.Runtime.Types; namespace IronPython.Runtime.Binding { diff --git a/src/ipy/IronPython/Runtime/Binding/FastSetBase.cs b/src/ipy/IronPython/Runtime/Binding/FastSetBase.cs index d553eadb2..4d0b3352b 100644 --- a/src/ipy/IronPython/Runtime/Binding/FastSetBase.cs +++ b/src/ipy/IronPython/Runtime/Binding/FastSetBase.cs @@ -4,6 +4,7 @@ using System; using System.Runtime.CompilerServices; +using Microsoft.Scripting.Utils; namespace IronPython.Runtime.Binding { internal class FastSetBase { diff --git a/src/ipy/IronPython/Runtime/Binding/IComConvertible.cs b/src/ipy/IronPython/Runtime/Binding/IComConvertible.cs index a588d408f..4fdb80c4a 100644 --- a/src/ipy/IronPython/Runtime/Binding/IComConvertible.cs +++ b/src/ipy/IronPython/Runtime/Binding/IComConvertible.cs @@ -2,7 +2,10 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; +using System.Collections.Generic; using System.Dynamic; +using System.Text; namespace IronPython.Runtime.Binding { /// diff --git a/src/ipy/IronPython/Runtime/Binding/IFastGettable.cs b/src/ipy/IronPython/Runtime/Binding/IFastGettable.cs index b1b457d8e..fc728450c 100644 --- a/src/ipy/IronPython/Runtime/Binding/IFastGettable.cs +++ b/src/ipy/IronPython/Runtime/Binding/IFastGettable.cs @@ -2,6 +2,13 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + +using System; +using System.Dynamic; + +using Microsoft.Scripting.Actions; + using System.Runtime.CompilerServices; namespace IronPython.Runtime.Binding { diff --git a/src/ipy/IronPython/Runtime/Binding/IFastInvokable.cs b/src/ipy/IronPython/Runtime/Binding/IFastInvokable.cs index d4aa4a78f..e0bf05d73 100644 --- a/src/ipy/IronPython/Runtime/Binding/IFastInvokable.cs +++ b/src/ipy/IronPython/Runtime/Binding/IFastInvokable.cs @@ -2,7 +2,12 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + +using System; +using System.Dynamic; using System.Runtime.CompilerServices; +using Microsoft.Scripting.Actions; namespace IronPython.Runtime.Binding { internal interface IFastInvokable { diff --git a/src/ipy/IronPython/Runtime/Binding/IFastSettable.cs b/src/ipy/IronPython/Runtime/Binding/IFastSettable.cs index 2b5abe432..dcfe19c99 100644 --- a/src/ipy/IronPython/Runtime/Binding/IFastSettable.cs +++ b/src/ipy/IronPython/Runtime/Binding/IFastSettable.cs @@ -2,6 +2,14 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + +using System; +using System.Dynamic; + +using Microsoft.Scripting.Actions; + +using Microsoft.Scripting.Runtime; using System.Runtime.CompilerServices; namespace IronPython.Runtime.Binding { diff --git a/src/ipy/IronPython/Runtime/Binding/IPythonConvertible.cs b/src/ipy/IronPython/Runtime/Binding/IPythonConvertible.cs index e4534eb16..ceb0e3edc 100644 --- a/src/ipy/IronPython/Runtime/Binding/IPythonConvertible.cs +++ b/src/ipy/IronPython/Runtime/Binding/IPythonConvertible.cs @@ -2,7 +2,11 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + +using System; using System.Dynamic; +using Microsoft.Scripting.Actions; namespace IronPython.Runtime.Binding { internal interface IPythonConvertible { diff --git a/src/ipy/IronPython/Runtime/Binding/IPythonGetable.cs b/src/ipy/IronPython/Runtime/Binding/IPythonGetable.cs index 02c6fbdc1..468dbc2fe 100644 --- a/src/ipy/IronPython/Runtime/Binding/IPythonGetable.cs +++ b/src/ipy/IronPython/Runtime/Binding/IPythonGetable.cs @@ -2,6 +2,9 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + +using System; using System.Dynamic; namespace IronPython.Runtime.Binding { diff --git a/src/ipy/IronPython/Runtime/Binding/IPythonInvokable.cs b/src/ipy/IronPython/Runtime/Binding/IPythonInvokable.cs index 58f0fa455..217e75fe9 100644 --- a/src/ipy/IronPython/Runtime/Binding/IPythonInvokable.cs +++ b/src/ipy/IronPython/Runtime/Binding/IPythonInvokable.cs @@ -2,9 +2,11 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Dynamic; using System.Linq.Expressions; +using System; +using System.Dynamic; + namespace IronPython.Runtime.Binding { /// /// Interface used to mark objects as being invokable from Python. These objects support diff --git a/src/ipy/IronPython/Runtime/Binding/IPythonOperable.cs b/src/ipy/IronPython/Runtime/Binding/IPythonOperable.cs index 2dfba352d..e17eebd91 100644 --- a/src/ipy/IronPython/Runtime/Binding/IPythonOperable.cs +++ b/src/ipy/IronPython/Runtime/Binding/IPythonOperable.cs @@ -2,6 +2,9 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; +using System.Collections.Generic; +using System.Text; using System.Dynamic; namespace IronPython.Runtime.Binding { diff --git a/src/ipy/IronPython/Runtime/Binding/IPythonSite.cs b/src/ipy/IronPython/Runtime/Binding/IPythonSite.cs index 72164159d..d1aa81cd0 100644 --- a/src/ipy/IronPython/Runtime/Binding/IPythonSite.cs +++ b/src/ipy/IronPython/Runtime/Binding/IPythonSite.cs @@ -1,4 +1,8 @@ -namespace IronPython.Runtime.Binding { +using System; +using System.Collections.Generic; +using System.Text; + +namespace IronPython.Runtime.Binding { internal interface IPythonSite { /// /// Gets the PythonContext which the CallSiteBinder is associated with. diff --git a/src/ipy/IronPython/Runtime/Binding/MetaBuiltinFunction.cs b/src/ipy/IronPython/Runtime/Binding/MetaBuiltinFunction.cs index 0b736e6af..fb0c4846d 100644 --- a/src/ipy/IronPython/Runtime/Binding/MetaBuiltinFunction.cs +++ b/src/ipy/IronPython/Runtime/Binding/MetaBuiltinFunction.cs @@ -2,13 +2,13 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Dynamic; using System.Linq.Expressions; -using System.Runtime.CompilerServices; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; +using System; +using System.Collections; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Dynamic; using Microsoft.Scripting; using Microsoft.Scripting.Actions; @@ -17,6 +17,9 @@ using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -121,9 +124,9 @@ DynamicMetaObject IPythonOperable.BindOperation(PythonOperationBinder action, Dy newArgs, BindingHelpers.GetCallSignature(call), codeContext - ), - Value.Targets, - selfRestrict, + ), + Value.Targets, + selfRestrict, Value.Name, PythonNarrowing.None, Value.IsBinaryOperator ? PythonNarrowing.BinaryOperator : NarrowingLevel.All, @@ -158,48 +161,48 @@ out target ); DynamicMetaObject self = GetInstance(instance, CompilerHelpers.GetType(Value.BindingSelf)); - return Value.MakeBuiltinFunctionCall( - call, - codeContext, - this, - ArrayUtils.Insert(self, args), - true, // has self - selfRestrict, - (newArgs) => { - CallSignature signature = BindingHelpers.GetCallSignature(call); - PythonContext state = PythonContext.GetPythonContext(call); - BindingTarget target; - PythonOverloadResolver resolver; - if (Value.IsReversedOperator) { - resolver = new PythonOverloadResolver( - state.Binder, - newArgs, - GetReversedSignature(signature), - codeContext - ); - } else { - resolver = new PythonOverloadResolver( - state.Binder, - self, - args, - signature, - codeContext + return Value.MakeBuiltinFunctionCall( + call, + codeContext, + this, + ArrayUtils.Insert(self, args), + true, // has self + selfRestrict, + (newArgs) => { + CallSignature signature = BindingHelpers.GetCallSignature(call); + PythonContext state = PythonContext.GetPythonContext(call); + BindingTarget target; + PythonOverloadResolver resolver; + if (Value.IsReversedOperator) { + resolver = new PythonOverloadResolver( + state.Binder, + newArgs, + GetReversedSignature(signature), + codeContext + ); + } else { + resolver = new PythonOverloadResolver( + state.Binder, + self, + args, + signature, + codeContext + ); + } + + DynamicMetaObject res = state.Binder.CallMethod( + resolver, + Value.Targets, + self.Restrictions, + Value.Name, + NarrowingLevel.None, + Value.IsBinaryOperator ? PythonNarrowing.BinaryOperator : NarrowingLevel.All, + out target ); - } - DynamicMetaObject res = state.Binder.CallMethod( - resolver, - Value.Targets, - self.Restrictions, - Value.Name, - NarrowingLevel.None, - Value.IsBinaryOperator ? PythonNarrowing.BinaryOperator : NarrowingLevel.All, - out target - ); - - return BindingHelpers.CheckLightThrow(call, res, target); - } - ); + return BindingHelpers.CheckLightThrow(call, res, target); + } + ); } private DynamicMetaObject/*!*/ GetInstance(Expression/*!*/ instance, Type/*!*/ testType) { diff --git a/src/ipy/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs b/src/ipy/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs index 528dfb0a2..10713fbae 100644 --- a/src/ipy/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs +++ b/src/ipy/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs @@ -2,17 +2,19 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Dynamic; using System.Linq.Expressions; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; +using System; +using System.Dynamic; using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Actions.Calls; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -91,7 +93,7 @@ out target ); return BindingHelpers.CheckLightThrow(call, res, target); - }); + }); } internal Expression MakeFunctionTest(Expression functionTarget) { diff --git a/src/ipy/IronPython/Runtime/Binding/MetaPythonFunction.cs b/src/ipy/IronPython/Runtime/Binding/MetaPythonFunction.cs index 93ba70899..cd492f595 100644 --- a/src/ipy/IronPython/Runtime/Binding/MetaPythonFunction.cs +++ b/src/ipy/IronPython/Runtime/Binding/MetaPythonFunction.cs @@ -2,15 +2,14 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; -using System.Dynamic; -using System.Linq.Expressions; using System.Reflection; - -using IronPython.Runtime.Operations; +using System.Dynamic; using Microsoft.Scripting; using Microsoft.Scripting.Actions; @@ -18,6 +17,9 @@ using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -216,7 +218,7 @@ public override DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder) { Expression.Convert(Expression, typeof(PythonFunction)) ), BindingRestrictions.GetTypeRestriction(Expression, typeof(PythonFunction)) - ); + ); } // first get the default binder value @@ -344,9 +346,9 @@ public FunctionBinderHelper(DynamicMetaObjectBinder/*!*/ call, MetaPythonFunctio } return BindingHelpers.AddDynamicTestAndDefer( - _call, - res, - deferArgs, + _call, + res, + deferArgs, new ValidationInfo(_deferTest), res.Expression.Type // force defer to our return type, our restrictions guarantee this to be true (only defaults can change, and we restrict to the delegate type) ); @@ -889,7 +891,7 @@ private static Expression VariableOrNull(ParameterExpression var, Type type) { Type target = _func.Value.__code__.Target.GetType(); if (target == typeof(Func)) { exprArgs = new Expression[] { - AstUtils.NewArrayHelper(typeof(object), exprArgs) + AstUtils.NewArrayHelper(typeof(object), exprArgs) }; } @@ -911,7 +913,7 @@ private static Expression VariableOrNull(ParameterExpression var, Type type) { Debug.Assert(_dict == null); userDict = userDict.Restrict(userDict.GetLimitType()); - _temps.Add(_dict = Ast.Variable(typeof(PythonDictionary), "$dict")); + _temps.Add(_dict = Ast.Variable(typeof(PythonDictionary), "$dict")); EnsureInit(); @@ -1035,7 +1037,7 @@ private Expression MakeDictionary(Dictionary namedArgs) // If calling generator, create the instance of PythonGenerator first // and add it into the list of arguments invokeArgs = ArrayUtils.Insert(GetFunctionParam(), invokeArgs); - + Expression invoke = AstUtils.SimpleCallHelper( Ast.Convert( Ast.Call( @@ -1083,7 +1085,7 @@ private void MakeUnexpectedKeywordError(Dictionary namedArgs ), typeof(PythonOps) ); - } + } private void EnsureInit() { if (_init == null) _init = new List(); diff --git a/src/ipy/IronPython/Runtime/Binding/MetaPythonObject.cs b/src/ipy/IronPython/Runtime/Binding/MetaPythonObject.cs index 04f3a40e1..3b0631a5c 100644 --- a/src/ipy/IronPython/Runtime/Binding/MetaPythonObject.cs +++ b/src/ipy/IronPython/Runtime/Binding/MetaPythonObject.cs @@ -2,16 +2,16 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; using System.Diagnostics; using System.Dynamic; -using System.Linq.Expressions; - -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - +using Microsoft.Scripting.Actions; using Microsoft.Scripting.Ast; using Microsoft.Scripting.Runtime; +using IronPython.Runtime.Types; +using IronPython.Runtime.Operations; namespace IronPython.Runtime.Binding { using Ast = Expression; @@ -37,7 +37,7 @@ public MetaPythonObject(Expression/*!*/ expression, BindingRestrictions/*!*/ res internal static MethodCallExpression MakeTryGetTypeMember(PythonContext/*!*/ PythonContext, PythonTypeSlot dts, Expression self, ParameterExpression tmp) { return MakeTryGetTypeMember( PythonContext, - dts, + dts, tmp, self, Ast.Property( @@ -100,7 +100,7 @@ public PythonType/*!*/ PythonType { PythonContext state = PythonContext.GetPythonContext(action); CodeContext context = state != null ? state.SharedContext : DefaultContext.Default; - + return new DynamicMetaObject( Ast.Convert( Ast.Call( diff --git a/src/ipy/IronPython/Runtime/Binding/MetaPythonType.Calls.cs b/src/ipy/IronPython/Runtime/Binding/MetaPythonType.Calls.cs index b69221da4..c61c530fa 100644 --- a/src/ipy/IronPython/Runtime/Binding/MetaPythonType.Calls.cs +++ b/src/ipy/IronPython/Runtime/Binding/MetaPythonType.Calls.cs @@ -2,22 +2,24 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; using System.Collections.Generic; using System.Diagnostics; using System.Dynamic; -using System.Linq.Expressions; using System.Reflection; -using IronPython.Runtime.Exceptions; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using Microsoft.Scripting; using Microsoft.Scripting.Actions; +using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Exceptions; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -40,7 +42,7 @@ internal partial class MetaPythonType : MetaPythonObject, IPythonInvokable { #region MetaObject Overrides public override DynamicMetaObject/*!*/ BindInvokeMember(InvokeMemberBinder/*!*/ action, DynamicMetaObject/*!*/[]/*!*/ args) { - + foreach (PythonType pt in Value.ResolutionOrder) { if (pt.IsSystemType) { return action.FallbackInvokeMember(this, args); @@ -108,7 +110,7 @@ internal partial class MetaPythonType : MetaPythonObject, IPythonInvokable { string msg; if (Value.UnderlyingSystemType.IsAbstract) { msg = String.Format("Cannot create instances of {0} because it is abstract", Value.Name); - } else { + }else{ msg = String.Format("Cannot create instances of {0} because it has no public constructors", Value.Name); } return new DynamicMetaObject( @@ -156,16 +158,16 @@ internal partial class MetaPythonType : MetaPythonObject, IPythonInvokable { GetAdapters(ai, call, codeContext, out newAdapter, out initAdapter); PythonContext state = PythonContext.GetPythonContext(call); - + // get the expression for calling __new__ DynamicMetaObject createExpr = newAdapter.GetExpression(state.Binder); if (createExpr.Expression.Type == typeof(void)) { return BindingHelpers.AddDynamicTestAndDefer( call, createExpr, - args, + args, valInfo - ); + ); } Expression res; @@ -250,7 +252,7 @@ internal partial class MetaPythonType : MetaPythonObject, IPythonInvokable { valInfo ); } - + #endregion #region Adapter support @@ -425,16 +427,16 @@ public ConstructorNewAdapter(ArgumentValues/*!*/ ai, PythonType/*!*/ creating, P if (_creating.IsSystemType || _creating.HasSystemCtor) { resolve = new PythonOverloadResolver( - binder, - Arguments.Arguments, - Arguments.Signature, + binder, + Arguments.Arguments, + Arguments.Signature, CodeContext ); } else { resolve = new PythonOverloadResolver( - binder, - ArrayUtils.Insert(Arguments.Self, Arguments.Arguments), - GetDynamicNewSignature(), + binder, + ArrayUtils.Insert(Arguments.Self, Arguments.Arguments), + GetDynamicNewSignature(), CodeContext ); } @@ -498,13 +500,13 @@ protected InitAdapter(ArgumentValues/*!*/ ai, PythonContext/*!*/ state, Expressi args.ToArray() ), Arguments.Self.Restrictions.Merge(createExpr.Restrictions) - ); + ); } } private class SlotInitAdapter : InitAdapter { private readonly PythonTypeSlot/*!*/ _slot; - + public SlotInitAdapter(PythonTypeSlot/*!*/ slot, ArgumentValues/*!*/ ai, PythonContext/*!*/ state, Expression/*!*/ codeContext) : base(ai, state, codeContext) { _slot = slot; @@ -590,8 +592,8 @@ public BuiltinInitAdapter(ArgumentValues/*!*/ ai, BuiltinFunction/*!*/ method, P ) ), GetErrorRestrictions(ai) - ), - ai.Arguments, + ), + ai.Arguments, valInfo ); } @@ -655,7 +657,7 @@ public BuiltinInitAdapter(ArgumentValues/*!*/ ai, BuiltinFunction/*!*/ method, P private static BindingRestrictions GetInstanceRestriction(ArgumentValues ai) { return BindingRestrictions.GetInstanceRestriction(ai.Self.Expression, ai.Self.Value); } - + private bool HasFinalizer(DynamicMetaObjectBinder/*!*/ action) { // only user types have finalizers... if (Value.IsSystemType) return false; @@ -690,7 +692,7 @@ private bool TooManyArgsForDefaultNew(DynamicMetaObjectBinder/*!*/ action, Dynam for (int i = 0; i < infos.Length; i++) { Argument curArg = infos[i]; - switch (curArg.Kind) { + switch(curArg.Kind) { case ArgumentType.List: // Deferral? if (((IList)args[i].Value).Count > 0) { @@ -705,7 +707,7 @@ private bool TooManyArgsForDefaultNew(DynamicMetaObjectBinder/*!*/ action, Dynam break; default: return true; - } + } } } return false; @@ -735,7 +737,7 @@ private bool IsStandardDotNetType(DynamicMetaObjectBinder/*!*/ action) { !Value.IsPythonType && !bState.Binder.HasExtensionTypes(Value.UnderlyingSystemType) && !typeof(Delegate).IsAssignableFrom(Value.UnderlyingSystemType) && - !Value.UnderlyingSystemType.IsArray; + !Value.UnderlyingSystemType.IsArray; } #endregion diff --git a/src/ipy/IronPython/Runtime/Binding/MetaPythonType.Members.cs b/src/ipy/IronPython/Runtime/Binding/MetaPythonType.Members.cs index e3d5e364f..c88ee5363 100644 --- a/src/ipy/IronPython/Runtime/Binding/MetaPythonType.Members.cs +++ b/src/ipy/IronPython/Runtime/Binding/MetaPythonType.Members.cs @@ -3,22 +3,24 @@ // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; using System.Collections.Generic; using System.Diagnostics; using System.Dynamic; -using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Threading; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; namespace IronPython.Runtime.Binding { using Ast = Expression; @@ -222,7 +224,7 @@ public TResult MakeTypeGetMember() { if (!isFinal) { // the member doesn't exist anywhere in the type hierarchy, see if // we define __getattr__ on our meta type. - if (metaType.TryResolveSlot(_context, "__getattr__", out pts) && + if (metaType.TryResolveSlot(_context, "__getattr__", out pts) && !pts.IsSetDescriptor(lookupContext, metaType)) { // we tried get/set descriptors initially AddMetaGetAttribute(metaType, pts); @@ -271,7 +273,7 @@ public MetaGetBinderHelper(MetaPythonType type, DynamicMetaObjectBinder member, _state = PythonContext.GetPythonContext(member); _valInfo = validationInfo; _metaValInfo = metaValidation; - } + } private void EnsureTmp() { if (_tmp == null) { diff --git a/src/ipy/IronPython/Runtime/Binding/MetaPythonType.cs b/src/ipy/IronPython/Runtime/Binding/MetaPythonType.cs index 90cd7e469..816704566 100644 --- a/src/ipy/IronPython/Runtime/Binding/MetaPythonType.cs +++ b/src/ipy/IronPython/Runtime/Binding/MetaPythonType.cs @@ -2,16 +2,20 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Dynamic; using System.Linq.Expressions; -using IronPython.Runtime.Types; +using System; +using System.Collections.Generic; +using System.Dynamic; +using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Types; + namespace IronPython.Runtime.Binding { + using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; internal partial class MetaPythonType : MetaPythonObject, IPythonConvertible { diff --git a/src/ipy/IronPython/Runtime/Binding/MetaUserObject.Members.cs b/src/ipy/IronPython/Runtime/Binding/MetaUserObject.Members.cs index 452a87ea3..d7a1a1f12 100644 --- a/src/ipy/IronPython/Runtime/Binding/MetaUserObject.Members.cs +++ b/src/ipy/IronPython/Runtime/Binding/MetaUserObject.Members.cs @@ -2,18 +2,13 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; -using System.Collections.Generic; using System.Diagnostics; using System.Dynamic; -using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; -using System.Threading; - -using IronPython.Runtime.Exceptions; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; using Microsoft.Scripting; using Microsoft.Scripting.Actions; @@ -21,6 +16,13 @@ using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Exceptions; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + +using System.Threading; +using System.Collections.Generic; + namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -30,7 +32,7 @@ internal partial class MetaUserObject : MetaPythonObject, IPythonGetable { public DynamicMetaObject GetMember(PythonGetMemberBinder/*!*/ member, DynamicMetaObject/*!*/ codeContext) { return GetMemberWorker(member, codeContext); - } + } #endregion @@ -131,7 +133,7 @@ public TResult Bind(CodeContext context, string name) { protected abstract TResult BindGetAttribute(PythonTypeSlot foundSlot); protected abstract TResult FinishRule(); protected abstract void MakeDictionaryAccess(); - + public IPythonObject Value { get { return _value; @@ -220,7 +222,7 @@ public MetaGetBinderHelper(MetaUserObject target, DynamicMetaObjectBinder binder info.Validation ); } - + protected abstract DynamicMetaObject FallbackError(); protected abstract DynamicMetaObject Fallback(); @@ -331,7 +333,7 @@ protected override void MakeSlotAccess(PythonTypeSlot foundSlot, bool systemType MakeSlotAccess(foundSlot); } } - + private void MakeSlotAccess(PythonTypeSlot dts) { if (dts is ReflectedSlotProperty rsp) { // we need to fall back to __getattr__ if the value is not defined, so call it and check the result. @@ -486,7 +488,7 @@ public Expression Expression { get { return _target.Expression; } - } + } } internal class FastGetBinderHelper : GetOrInvokeBinderHelper { @@ -524,12 +526,12 @@ protected override void MakeSlotAccess(PythonTypeSlot foundSlot, bool systemType } _slot = foundSlot; } - + public FastBindResult> GetBinding(CodeContext context, string name) { var cachedGets = GetCachedGets(); var key = CachedGetKey.Make(name, context.ModuleContext.ExtensionMethods); FastGetBase dlg; - lock (cachedGets) { + lock (cachedGets) { if (!cachedGets.TryGetValue(key, out dlg) || !dlg.IsValid(Value.PythonType)) { var binding = Bind(context, name); if (binding != null) { @@ -597,7 +599,7 @@ protected override FastGetBase FinishRule() { private Func FallbackError() { Type finalType = Value.PythonType.FinalSystemType; - if (typeof(IDynamicMetaObjectProvider).IsAssignableFrom(finalType)) { + if (typeof(IDynamicMetaObjectProvider).IsAssignableFrom(finalType)) { return ((IFastGettable)Value).MakeGetBinding(_site, _binder, _context, _binder.Name); } @@ -619,9 +621,9 @@ protected override FastGetBase BindGetAttribute(PythonTypeSlot foundSlot) { Debug.Assert(Value is IFastGettable); PythonTypeSlot baseSlot; - if (TryGetGetAttribute(_context, DynamicHelpers.GetPythonTypeFromType(finalType), out baseSlot) && + if (TryGetGetAttribute(_context, DynamicHelpers.GetPythonTypeFromType(finalType), out baseSlot) && baseSlot == foundSlot) { - + return new ChainedUserGet(_binder, _version, FallbackError()); } } @@ -703,7 +705,7 @@ private static bool TryGetGetAttribute(CodeContext/*!*/ context, PythonType/*!*/ } return false; } - + private static MethodCallExpression/*!*/ MakeGetAttrTestAndGet(GetBindingInfo/*!*/ info, Expression/*!*/ getattr) { return Ast.Call( PythonTypeInfo._PythonOps.SlotTryGetBoundValue, @@ -721,8 +723,8 @@ private static bool TryGetGetAttribute(CodeContext/*!*/ context, PythonType/*!*/ ), info.Result ); - } - + } + private static Expression/*!*/ GetWeakSlot(PythonTypeSlot slot) { return AstUtils.Convert(AstUtils.WeakConstant(slot), typeof(PythonTypeSlot)); } @@ -755,7 +757,7 @@ public SetBinderHelper(CodeContext/*!*/ context, IPythonObject/*!*/ instance, ob _context = context; } - public TResult Bind(string name) { + public TResult Bind(string name) { bool bound = false; // call __setattr__ if it exists @@ -807,7 +809,7 @@ public object Value { } protected abstract TResult Finish(); - + protected abstract void MakeSetAttrTarget(PythonTypeSlot dts); protected abstract void MakeSlotsSetTarget(ReflectedSlotProperty prop); protected abstract void MakeSlotSetOrFallback(PythonTypeSlot dts, bool systemTypeResolution); @@ -835,13 +837,13 @@ protected override SetMemberDelegates Finish() { return new SetMemberDelegates(_context, Instance.PythonType, OptimizedSetKind.SetAttr, _binder.Name, _version, _setattrSlot, null); } else if (_slotProp != null) { return new SetMemberDelegates(_context, Instance.PythonType, OptimizedSetKind.UserSlot, _binder.Name, _version, null, _slotProp.Setter); - } else if (_dictSet) { + } else if(_dictSet) { return new SetMemberDelegates(_context, Instance.PythonType, OptimizedSetKind.SetDict, _binder.Name, _version, null, null); } else { return new SetMemberDelegates(_context, Instance.PythonType, OptimizedSetKind.Error, _binder.Name, _version, null, null); - } + } } - + public FastBindResult> MakeSet() { var cachedSets = GetCachedSets(); @@ -953,14 +955,14 @@ protected override void MakeSetAttrTarget(PythonTypeSlot dts) { protected override DynamicMetaObject Finish() { PerfTrack.NoteEvent(PerfTrack.Categories.Binding, _resolution); PerfTrack.NoteEvent(PerfTrack.Categories.BindingTarget, "UserSet"); - + Debug.Assert(_result != null); _result = new DynamicMetaObject( _result.Expression, _target.Restrict(Instance.GetType()).Restrictions.Merge(_result.Restrictions) ); - + Debug.Assert(!_result.Expression.Type.IsValueType); return BindingHelpers.AddDynamicTestAndDefer( @@ -1045,7 +1047,7 @@ protected override void MakeSlotSetOrFallback(PythonTypeSlot dts, bool systemTyp _result = MakeSlotSet(_info, dts); } } - + protected override void MakeSlotsSetTarget(ReflectedSlotProperty prop) { _resolution += "Slot "; MakeSlotsSetTargetHelper(_info, prop, _value.Expression); @@ -1212,7 +1214,7 @@ private static DynamicMetaObject MakeSlotSet(SetBindingInfo/*!*/ info, PythonTyp if (dts is ReflectedSlotProperty rsp) { MakeSlotsDeleteTarget(info, rsp); } - + if (!info.Body.IsFinal && dts != null) { MakeSlotDelete(info, dts); } @@ -1266,7 +1268,7 @@ private static DynamicMetaObject MakeSlotDelete(DeleteBindingInfo/*!*/ info, Pyt Ast.NotEqual( tmpDeleter, AstUtils.Constant(null) - ), + ), Ast.Dynamic( PythonContext.GetPythonContext(info.Action).InvokeOne, typeof(object), diff --git a/src/ipy/IronPython/Runtime/Binding/MetaUserObject.cs b/src/ipy/IronPython/Runtime/Binding/MetaUserObject.cs index 542649d73..74b94eb48 100644 --- a/src/ipy/IronPython/Runtime/Binding/MetaUserObject.cs +++ b/src/ipy/IronPython/Runtime/Binding/MetaUserObject.cs @@ -2,20 +2,22 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Collections; -using System.Dynamic; using System.Linq.Expressions; using System.Numerics; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Dynamic; using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -82,7 +84,7 @@ public DynamicMetaObject ConvertWorker(DynamicMetaObjectBinder binder, Type type public override DynamicMetaObject/*!*/ BindDeleteIndex(DeleteIndexBinder/*!*/ binder, DynamicMetaObject/*!*/[]/*!*/ indexes) { return PythonProtocol.Index(binder, PythonIndexType.DeleteItem, ArrayUtils.Insert(this, indexes)); - } + } public override DynamicMetaObject/*!*/ BindInvoke(InvokeBinder/*!*/ action, DynamicMetaObject/*!*/[]/*!*/ args) { Expression context = Ast.Call( @@ -94,8 +96,8 @@ public DynamicMetaObject ConvertWorker(DynamicMetaObjectBinder binder, Type type ); return InvokeWorker( - action, - context, + action, + context, args ); } @@ -123,7 +125,7 @@ public override System.Collections.Generic.IEnumerable GetDynamicMemberN if (Value.PythonType.TryResolveSlot(context.SharedContext, "__call__", out callSlot) && TypeCache.PythonType.TryResolveSlot(context.SharedContext, "__call__", out typeCallSlot) && callSlot == typeCallSlot) { - + return InvokeFallback(action, codeContext, args); } } @@ -183,7 +185,7 @@ private DynamicMetaObject TryPythonConversion(DynamicMetaObjectBinder conversion } } else if (type == typeof(IEnumerable)) { return PythonConversionBinder.ConvertToIEnumerable(conversion, Restrict(Value.GetType())); - } else if (type == typeof(IEnumerator)) { + } else if (type == typeof(IEnumerator)){ return PythonConversionBinder.ConvertToIEnumerator(conversion, Restrict(Value.GetType())); } else if (type.IsSubclassOf(typeof(Delegate))) { return MakeDelegateTarget(conversion, type, Restrict(Value.GetType())); @@ -362,14 +364,14 @@ private static bool IsBuiltinConversion(CodeContext/*!*/ context, PythonTypeSlot db.MakeConversionError( convertToAction.Type, self.Expression - ), + ), typeof(object) ); default: throw new InvalidOperationException(convertToAction.ResultKind.ToString()); } } - + /// /// Helper for falling back - if we have a base object fallback to it first (which can /// then fallback to the calling site), otherwise fallback to the calling site. diff --git a/src/ipy/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs index c7fc38419..bae68d0f9 100644 --- a/src/ipy/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs +++ b/src/ipy/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs @@ -2,22 +2,25 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; +using Microsoft.Scripting.Ast; + using System; using System.Dynamic; -using System.Linq.Expressions; +using System.Reflection; using System.Runtime.CompilerServices; -using IronPython.Runtime.Operations; - using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -namespace IronPython.Runtime.Binding { - using Microsoft.Scripting.Actions; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; +namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; + using Microsoft.Scripting.Actions; internal class PythonBinaryOperationBinder : BinaryOperationBinder, IPythonSite, IExpressionSerializable, ILightExceptionBinder { private readonly PythonContext/*!*/ _context; @@ -27,7 +30,7 @@ public PythonBinaryOperationBinder(PythonContext/*!*/ context, ExpressionType op : base(operation) { _context = context; } - + public override DynamicMetaObject FallbackBinaryOperation(DynamicMetaObject target, DynamicMetaObject arg, DynamicMetaObject errorSuggestion) { return PythonProtocol.Operation(this, target, arg, errorSuggestion); } @@ -72,7 +75,7 @@ public override T BindDelegate(CallSite site, object[] args) { return BindModulo(site, args); } } else { - switch (Operation) { + switch(Operation) { case ExpressionType.Modulo: return BindModulo(site, args); case ExpressionType.Multiply: @@ -272,7 +275,7 @@ private T BindAdd(CallSite site, object[] args) where T : class { } else if (!t.IsEnum) { switch (t.GetTypeCode()) { case TypeCode.Double: - if (typeof(T) == typeof(Func)) { + if(typeof(T) == typeof(Func)) { return (T)(object)new Func(DoubleAdd); } break; @@ -392,7 +395,7 @@ private object StringModulo(CallSite site, object self, object other) { } private object DoubleAdd(CallSite site, object self, object other) { - if (self != null && self.GetType() == typeof(double) && + if (self != null && self.GetType() == typeof(double) && other != null && other.GetType() == typeof(double)) { return (double)self + (double)other; } @@ -401,7 +404,7 @@ private object DoubleAdd(CallSite site, object self, object other) { } private object IntAdd(CallSite site, object self, object other) { - if (self != null && self.GetType() == typeof(int) && + if (self != null && self.GetType() == typeof(int) && other != null && other.GetType() == typeof(int)) { return Int32Ops.Add((int)self, (int)other); } @@ -580,7 +583,7 @@ private object TupleAdd(CallSite site, object self, object other) { } private object StringAdd(CallSite site, object self, object other) { - if (self != null && self.GetType() == typeof(string) && + if (self != null && self.GetType() == typeof(string) && other != null && other.GetType() == typeof(string)) { return StringOps.Add((string)self, (string)other); } @@ -589,7 +592,7 @@ private object StringAdd(CallSite site, object self, object other) { } private object StringAdd(CallSite site, string self, object other) { - if (self != null && + if (self != null && other != null && other.GetType() == typeof(string)) { return StringOps.Add(self, (string)other); } @@ -605,7 +608,7 @@ private object StringAdd(CallSite site, object self, string other) { return ((CallSite>)site).Update(site, self, other); } - + private object DoubleSubtract(CallSite site, object self, object other) { if (self != null && self.GetType() == typeof(double) && other != null && other.GetType() == typeof(double)) { @@ -684,7 +687,7 @@ private object StringEqual(CallSite site, object self, string other) { return ((CallSite>)site).Update(site, self, other); } - + private object DoubleNotEqual(CallSite site, object self, object other) { if (self != null && self.GetType() == typeof(double) && other != null && other.GetType() == typeof(double)) { diff --git a/src/ipy/IronPython/Runtime/Binding/PythonBinder.Create.cs b/src/ipy/IronPython/Runtime/Binding/PythonBinder.Create.cs index 5b4974cd5..c94067050 100644 --- a/src/ipy/IronPython/Runtime/Binding/PythonBinder.Create.cs +++ b/src/ipy/IronPython/Runtime/Binding/PythonBinder.Create.cs @@ -2,15 +2,17 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; using System.Dynamic; -using System.Linq.Expressions; using System.Reflection; +using Microsoft.Scripting.Actions; +using Microsoft.Scripting.Generation; +using Microsoft.Scripting.Utils; using IronPython.Runtime.Operations; -using Microsoft.Scripting.Actions; - using AstUtils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Runtime.Binding { diff --git a/src/ipy/IronPython/Runtime/Binding/PythonBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonBinder.cs index 9db715591..50ae3404b 100644 --- a/src/ipy/IronPython/Runtime/Binding/PythonBinder.cs +++ b/src/ipy/IronPython/Runtime/Binding/PythonBinder.cs @@ -2,21 +2,18 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; +using System.Numerics; + using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Dynamic; using System.Linq; -using System.Linq.Expressions; -using System.Numerics; using System.Reflection; using System.Threading; -using IronPython.Runtime.Exceptions; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Actions.Calls; @@ -24,6 +21,10 @@ using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Exceptions; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -42,7 +43,7 @@ public PythonBinder(PythonContext/*!*/ pythonContext, CodeContext context) { ContractUtils.RequiresNotNull(pythonContext, nameof(pythonContext)); _dlrExtensionTypes = MakeExtensionTypes(); - _context = pythonContext; + _context = pythonContext; if (context != null) { context.LanguageContext.DomainManager.AssemblyLoaded += new EventHandler(DomainManager_AssemblyLoaded); @@ -81,7 +82,7 @@ public PythonBinder(PythonBinder binder) { } return expr; } - + Type visType = Context.Binder.PrivateBinding ? toType : CompilerHelpers.GetVisibleType(toType); if (exprType == typeof(PythonType) && visType == typeof(Type)) { @@ -184,17 +185,17 @@ public override ErrorInfo MakeSetValueTypeFieldError(FieldTracker field, Dynamic Expression.Assign( Expression.Field( AstUtils.Convert( - instance.Expression, + instance.Expression, field.DeclaringType - ), + ), field.Field ), ConvertExpression( - value.Expression, - field.FieldType, - ConversionResultKind.ExplicitCast, + value.Expression, + field.FieldType, + ConversionResultKind.ExplicitCast, new PythonOverloadResolverFactory( - this, + this, Expression.Constant(_context.SharedContext) ) ) @@ -236,7 +237,7 @@ public override ErrorInfo MakeConversionError(Type toType, Expression value) { return MakeMissingMemberError(accessingType, instance, info.Name); } - public override ErrorInfo/*!*/ MakeStaticPropertyInstanceAccessError(PropertyTracker/*!*/ tracker, bool isAssignment, IList/*!*/ parameters) { + public override ErrorInfo/*!*/ MakeStaticPropertyInstanceAccessError(PropertyTracker/*!*/ tracker, bool isAssignment, IList/*!*/ parameters) { ContractUtils.RequiresNotNull(tracker, nameof(tracker)); ContractUtils.RequiresNotNull(parameters, nameof(parameters)); @@ -280,7 +281,7 @@ public override string GetTypeName(Type t) { } - public override ErrorInfo/*!*/ MakeEventValidation(MemberGroup/*!*/ members, DynamicMetaObject eventObject, DynamicMetaObject/*!*/ value, OverloadResolverFactory/*!*/ factory) { + public override ErrorInfo/*!*/ MakeEventValidation(MemberGroup/*!*/ members, DynamicMetaObject eventObject, DynamicMetaObject/*!*/ value, OverloadResolverFactory/*!*/ factory) { EventTracker ev = (EventTracker)members[0]; return ErrorInfo.FromValueNoError( @@ -404,7 +405,7 @@ public override IList GetExtensionTypes(Type t) { return list; } - + private void AddExtensionTypes(Type t, List list) { ExtensionTypeInfo extType; if (_sysTypes.TryGetValue(t, out extType)) { @@ -460,16 +461,16 @@ private static DynamicMetaObject ReturnMemberTracker(Type type, MemberTracker me case TrackerTypes.Bound: return new DynamicMetaObject(ReturnBoundTracker((BoundMemberTracker)memberTracker, privateBinding), BindingRestrictions.Empty); case TrackerTypes.Property: - return new DynamicMetaObject(ReturnPropertyTracker((PropertyTracker)memberTracker, privateBinding), BindingRestrictions.Empty); ; + return new DynamicMetaObject(ReturnPropertyTracker((PropertyTracker)memberTracker, privateBinding), BindingRestrictions.Empty);; case TrackerTypes.Event: return new DynamicMetaObject(Ast.Call( typeof(PythonOps).GetMethod(nameof(PythonOps.MakeBoundEvent)), AstUtils.Constant(PythonTypeOps.GetReflectedEvent((EventTracker)memberTracker)), AstUtils.Constant(null), AstUtils.Constant(type) - ), BindingRestrictions.Empty); ; + ), BindingRestrictions.Empty);; case TrackerTypes.Field: - return new DynamicMetaObject(ReturnFieldTracker((FieldTracker)memberTracker), BindingRestrictions.Empty); ; + return new DynamicMetaObject(ReturnFieldTracker((FieldTracker)memberTracker), BindingRestrictions.Empty);; case TrackerTypes.MethodGroup: return new DynamicMetaObject(ReturnMethodGroup((MethodGroup)memberTracker), BindingRestrictions.Empty); ; case TrackerTypes.Constructor: @@ -588,7 +589,7 @@ public void LookupMembers(CodeContext/*!*/ context, PythonType/*!*/ type, Python if (!members.ContainsKey(rm.Name)) { members[rm.Name] = new KeyValuePair( - PythonTypeOps.GetSlot(rm.Member, rm.Name, PrivateBinding), + PythonTypeOps.GetSlot(rm.Member, rm.Name, PrivateBinding), rm.Member ); } @@ -624,7 +625,7 @@ public void ResolveMemberNames(CodeContext/*!*/ context, PythonType/*!*/ type, P if (!members.ContainsKey(rm.Name)) { members[rm.Name] = new KeyValuePair( - PythonTypeOps.GetSlot(rm.Member, rm.Name, PrivateBinding), + PythonTypeOps.GetSlot(rm.Member, rm.Name, PrivateBinding), rm.Member ); } @@ -1083,7 +1084,7 @@ private void EnsureInfo() { private class SlotCacheInfo { public SlotCacheInfo() { Members = new Dictionary>(StringComparer.Ordinal); - } + } public bool TryGetSlot(string/*!*/ name, out PythonTypeSlot slot) { Debug.Assert(name != null); diff --git a/src/ipy/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs index e747621f4..9b05ba4fe 100644 --- a/src/ipy/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs +++ b/src/ipy/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs @@ -2,16 +2,17 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Dynamic; using System.Linq.Expressions; -using IronPython.Runtime.Operations; +using System; +using System.Dynamic; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; - using AstUtils = Microsoft.Scripting.Ast.Utils; +using IronPython.Runtime.Operations; + namespace IronPython.Runtime.Binding { using Ast = Expression; @@ -24,7 +25,7 @@ public PythonDeleteIndexBinder(PythonContext/*!*/ context, int argCount) } public override DynamicMetaObject FallbackDeleteIndex(DynamicMetaObject target, DynamicMetaObject[] indexes, DynamicMetaObject errorSuggestion) { - return PythonProtocol.Index(this, PythonIndexType.DeleteItem, ArrayUtils.Insert(target, indexes), errorSuggestion); + return PythonProtocol.Index(this, PythonIndexType.DeleteItem, ArrayUtils.Insert(target, indexes),errorSuggestion); } public override int GetHashCode() { diff --git a/src/ipy/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs index 0087c4b19..5c3ee8175 100644 --- a/src/ipy/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs +++ b/src/ipy/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs @@ -2,13 +2,17 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Dynamic; using System.Linq.Expressions; -using IronPython.Runtime.Operations; - +using System; +using Microsoft.Scripting; +using System.Dynamic; using Microsoft.Scripting.Runtime; +using IronPython.Runtime.Binding; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; diff --git a/src/ipy/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs index e1a1c0f89..af5c43ba1 100644 --- a/src/ipy/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs +++ b/src/ipy/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs @@ -2,14 +2,16 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Dynamic; using System.Linq.Expressions; -using IronPython.Runtime.Operations; +using System; +using System.Dynamic; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Operations; + namespace IronPython.Runtime.Binding { using Ast = Expression; diff --git a/src/ipy/IronPython/Runtime/Binding/PythonExtensionBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonExtensionBinder.cs index b961bb0f3..276366231 100644 --- a/src/ipy/IronPython/Runtime/Binding/PythonExtensionBinder.cs +++ b/src/ipy/IronPython/Runtime/Binding/PythonExtensionBinder.cs @@ -5,10 +5,11 @@ using System; using System.Collections.Generic; using System.Linq; - +using System.Text; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Actions.Calls; using Microsoft.Scripting.Utils; +using System.Diagnostics; namespace IronPython.Runtime.Binding { internal class PythonExtensionBinder : PythonBinder { @@ -46,10 +47,10 @@ public override MemberGroup GetMember(MemberRequestKind actionKind, Type type, s } internal static bool IsApplicableExtensionMethod(Type instanceType, Type extensionMethodThisType) { - + if (extensionMethodThisType.ContainsGenericParameters) { Dictionary binding = new Dictionary(); - + if (extensionMethodThisType.IsArray) { if (instanceType.IsArray) { extensionMethodThisType = extensionMethodThisType.GetElementType(); diff --git a/src/ipy/IronPython/Runtime/Binding/PythonGetIndexBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonGetIndexBinder.cs index 811261fb8..db210247c 100644 --- a/src/ipy/IronPython/Runtime/Binding/PythonGetIndexBinder.cs +++ b/src/ipy/IronPython/Runtime/Binding/PythonGetIndexBinder.cs @@ -2,16 +2,18 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; using System.Dynamic; -using System.Linq.Expressions; +using System.Reflection; using System.Runtime.CompilerServices; -using IronPython.Runtime.Operations; - -using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using Microsoft.Scripting.Generation; + +using IronPython.Runtime.Operations; namespace IronPython.Runtime.Binding { using Ast = Expression; @@ -105,7 +107,7 @@ private object TupleIndex(CallSite site, object target, object index) { if (target is PythonTuple lst && index != null && index.GetType() == typeof(int)) { return lst[(int)index]; } - + return ((CallSite>)site).Update(site, target, index); } diff --git a/src/ipy/IronPython/Runtime/Binding/PythonGetMemberBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonGetMemberBinder.cs index 3d9387a30..d674d83bf 100644 --- a/src/ipy/IronPython/Runtime/Binding/PythonGetMemberBinder.cs +++ b/src/ipy/IronPython/Runtime/Binding/PythonGetMemberBinder.cs @@ -2,26 +2,27 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; +using Microsoft.Scripting.Ast; + using System; using System.Diagnostics; using System.Dynamic; -using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using System.Threading; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using Microsoft.Scripting; using Microsoft.Scripting.Actions; -using Microsoft.Scripting.Ast; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; diff --git a/src/ipy/IronPython/Runtime/Binding/PythonGetSliceBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonGetSliceBinder.cs index b6cffeee8..3cd18aaea 100644 --- a/src/ipy/IronPython/Runtime/Binding/PythonGetSliceBinder.cs +++ b/src/ipy/IronPython/Runtime/Binding/PythonGetSliceBinder.cs @@ -2,14 +2,16 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Dynamic; using System.Linq.Expressions; -using IronPython.Runtime.Operations; +using System; +using System.Dynamic; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Operations; + namespace IronPython.Runtime.Binding { using Ast = Expression; diff --git a/src/ipy/IronPython/Runtime/Binding/PythonIndexType.cs b/src/ipy/IronPython/Runtime/Binding/PythonIndexType.cs index 10580d390..bafaafefb 100644 --- a/src/ipy/IronPython/Runtime/Binding/PythonIndexType.cs +++ b/src/ipy/IronPython/Runtime/Binding/PythonIndexType.cs @@ -2,6 +2,10 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; +using System.Collections.Generic; +using System.Text; + namespace IronPython.Runtime.Binding { internal enum PythonIndexType { GetItem, diff --git a/src/ipy/IronPython/Runtime/Binding/PythonInvokeBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonInvokeBinder.cs index 9967b3dc8..72cd330c3 100644 --- a/src/ipy/IronPython/Runtime/Binding/PythonInvokeBinder.cs +++ b/src/ipy/IronPython/Runtime/Binding/PythonInvokeBinder.cs @@ -2,21 +2,23 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; +using Microsoft.Scripting.Ast; + using System; using System.Collections.Generic; using System.Diagnostics; using System.Dynamic; -using System.Linq.Expressions; using System.Runtime.CompilerServices; -using IronPython.Runtime.Operations; - using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Operations; + using AstUtils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Runtime.Binding { @@ -258,7 +260,7 @@ private void TranslateArguments(DynamicMetaObject target, DynamicMetaObject/*!*/ throw new InvalidOperationException(); } } - + callInfo = new CallInfo(metaArgs.Count - 1, namedArgNames.ToArray()); test = splatArgTest; @@ -295,7 +297,7 @@ public virtual bool SupportsLightThrow { get { return false; } } - public virtual CallSiteBinder GetLightExceptionBinder() { + public virtual CallSiteBinder GetLightExceptionBinder() { if (_lightThrowBinder == null) { _lightThrowBinder = new LightThrowBinder(_context, _signature); } diff --git a/src/ipy/IronPython/Runtime/Binding/PythonOperationBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonOperationBinder.cs index 13911421d..6f5b01b1e 100644 --- a/src/ipy/IronPython/Runtime/Binding/PythonOperationBinder.cs +++ b/src/ipy/IronPython/Runtime/Binding/PythonOperationBinder.cs @@ -2,20 +2,21 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; using System.Collections; using System.Collections.Generic; using System.Dynamic; -using System.Linq.Expressions; using System.Runtime.CompilerServices; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + using AstUtils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Runtime.Binding { @@ -42,7 +43,7 @@ public override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObje } public override T BindDelegate(CallSite site, object[] args) { - switch (_operation) { + switch(_operation) { case PythonOperationKind.Hash: if (CompilerHelpers.GetType(args[0]) == typeof(PythonType)) { if (typeof(T) == typeof(Func)) { @@ -99,7 +100,7 @@ public override T BindDelegate(CallSite site, object[] args) { Type tType = typeof(T); if (tType == typeof(Func)) { return (T)(object)new Func(StringContains); - } else if (tType == typeof(Func)) { + } else if(tType == typeof(Func)) { return (T)(object)new Func(StringContains); } else if (tType == typeof(Func)) { return (T)(object)new Func(StringContains); @@ -112,25 +113,25 @@ public override T BindDelegate(CallSite site, object[] args) { } } break; - + } return base.BindDelegate(site, args); } private KeyValuePair GetListEnumerator(CallSite site, PythonList value) { - return new KeyValuePair(new PythonListIterator(value), null); + return new KeyValuePair(new PythonListIterator(value), null); } private KeyValuePair GetListEnumerator(CallSite site, object value) { if (value != null && value.GetType() == typeof(PythonList)) { - return new KeyValuePair(new PythonListIterator((PythonList)value), null); + return new KeyValuePair(new PythonListIterator((PythonList)value), null); } return ((CallSite>>)site).Update(site, value); } private KeyValuePair GetTupleEnumerator(CallSite site, PythonTuple value) { - return new KeyValuePair(new PythonTupleEnumerator(value), null); + return new KeyValuePair(new PythonTupleEnumerator(value), null); } private KeyValuePair GetTupleEnumerator(CallSite site, object value) { @@ -232,7 +233,7 @@ public override Type ReturnType { case PythonOperationKind.CallSignatures: return typeof(IList); case PythonOperationKind.Documentation: return typeof(string); } - return typeof(object); + return typeof(object); } } diff --git a/src/ipy/IronPython/Runtime/Binding/PythonOperationKind.cs b/src/ipy/IronPython/Runtime/Binding/PythonOperationKind.cs index 7e0d0dce7..a2f0112a8 100644 --- a/src/ipy/IronPython/Runtime/Binding/PythonOperationKind.cs +++ b/src/ipy/IronPython/Runtime/Binding/PythonOperationKind.cs @@ -1,4 +1,8 @@ -namespace IronPython.Runtime.Binding { +using System; +using System.Collections.Generic; +using System.Text; + +namespace IronPython.Runtime.Binding { /// /// Custom dynamic site kinds for simple sites that just take a fixed set of parameters. /// @@ -197,8 +201,8 @@ internal enum PythonOperationKind { ///Operator for performing reverse divmod ReverseDivMod = DivMod | Reversed, - InPlace = 0x20000000, - Reversed = 0x10000000, - Comparison = 0x08000000, + InPlace = 0x20000000, + Reversed = 0x10000000, + Comparison = 0x08000000, } } diff --git a/src/ipy/IronPython/Runtime/Binding/PythonOverloadResolver.cs b/src/ipy/IronPython/Runtime/Binding/PythonOverloadResolver.cs index c93ada3f2..434d46f79 100644 --- a/src/ipy/IronPython/Runtime/Binding/PythonOverloadResolver.cs +++ b/src/ipy/IronPython/Runtime/Binding/PythonOverloadResolver.cs @@ -10,12 +10,12 @@ using System.Numerics; using System.Reflection; -using IronPython.Runtime.Operations; - using Microsoft.Scripting.Actions; using Microsoft.Scripting.Actions.Calls; -using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using Microsoft.Scripting.Generation; +using Microsoft.Scripting.Runtime; +using IronPython.Runtime.Operations; namespace IronPython.Runtime.Binding { internal sealed class PythonOverloadResolverFactory : OverloadResolverFactory { @@ -242,10 +242,10 @@ private static Candidate SelectWiderNumericType(Type candidateOneType, Type cand if (GetUnmanagedNumericTypeWidth(candidateTwoType) is not int candidateTwoWidth) return Candidate.Ambiguous; Candidate preferred = Comparer.Default.Compare(candidateOneWidth, candidateTwoWidth) switch { - 1 => Candidate.One, - 0 => Candidate.Equivalent, + 1 => Candidate.One, + 0 => Candidate.Equivalent, -1 => Candidate.Two, - _ => throw new InvalidOperationException() + _ => throw new InvalidOperationException() }; if (preferred == Candidate.One && Converter.IsUnsignedInt(candidateOneType) && !Converter.IsUnsignedInt(candidateTwoType)) { diff --git a/src/ipy/IronPython/Runtime/Binding/PythonProtocol.Operations.cs b/src/ipy/IronPython/Runtime/Binding/PythonProtocol.Operations.cs index bdd1120d9..61f916e14 100644 --- a/src/ipy/IronPython/Runtime/Binding/PythonProtocol.Operations.cs +++ b/src/ipy/IronPython/Runtime/Binding/PythonProtocol.Operations.cs @@ -2,19 +2,17 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; +using System.Numerics; + using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Dynamic; -using System.Linq.Expressions; -using System.Numerics; using System.Reflection; using System.Text; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Actions.Calls; @@ -23,6 +21,9 @@ using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + namespace IronPython.Runtime.Binding { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -265,7 +266,7 @@ private static DynamicMetaObject MakeBinaryOperation(DynamicMetaObjectBinder ope null, // test Ast.Assign(curIndex, Ast.Add(curIndex, AstUtils.Constant(1))), // increment Ast.Block( // body - // getItemRes = param0.__getitem__(curIndex) + // getItemRes = param0.__getitem__(curIndex) Utils.Try( Ast.Block( Ast.Assign( @@ -275,11 +276,11 @@ private static DynamicMetaObject MakeBinaryOperation(DynamicMetaObjectBinder ope Ast.Empty() ) ).Catch( - // end of indexes, return false + // end of indexes, return false typeof(IndexOutOfRangeException), Ast.Break(target) ), - // if(getItemRes == param1) return true + // if(getItemRes == param1) return true Utils.If( DynamicExpression.Dynamic( state.BinaryOperationRetType( @@ -553,7 +554,8 @@ private static NewExpression MakeEnumeratorResult(Expression tmp) { } else { notExpr = errorSuggestion.Expression; } - } else { + } + else { Debug.Assert(res.Expression.Type == typeof(bool)); notExpr = Ast.IsFalse(res.Expression); self = res; @@ -989,7 +991,7 @@ private static void MakeSlotCallWorker(PythonContext/*!*/ state, PythonTypeSlot/ SlotOrFunction.GetCombinedTargets(fop, rop, out fop, out rop); bool shouldWarn = false; - + // if the left operand is an instance of a built-in type or a new-style class, and the right operand is an instance of a proper subclass of that type or class // and overrides the base's __rop__() method, the right operand's __rop__() method is tried before the left operand's __op__() method. PythonType xPythonType = MetaPythonObject.GetPythonType(xType); @@ -1141,15 +1143,15 @@ private static DynamicMetaObject MakeUnindexableError(DynamicMetaObjectBinder op private static DynamicMetaObject/*!*/[]/*!*/ GetItemSliceArguments(PythonContext state, PythonIndexType op, DynamicMetaObject/*!*/[]/*!*/ types) { DynamicMetaObject[] args; if (op == PythonIndexType.SetSlice) { - args = new DynamicMetaObject[] { + args = new DynamicMetaObject[] { types[0].Restrict(types[0].GetLimitType()), - GetSetSlice(state, types), + GetSetSlice(state, types), types[types.Length- 1].Restrict(types[types.Length - 1].GetLimitType()) }; } else { Debug.Assert(op == PythonIndexType.GetSlice || op == PythonIndexType.DeleteSlice); - args = new DynamicMetaObject[] { + args = new DynamicMetaObject[] { types[0].Restrict(types[0].GetLimitType()), GetGetOrDeleteSlice(state, types) }; @@ -1415,7 +1417,7 @@ public ItemBuilder(DynamicMetaObject/*!*/[]/*!*/ types, Callable/*!*/ callable) public override DynamicMetaObject/*!*/ MakeRule(DynamicMetaObjectBinder/*!*/ metaBinder, PythonContext/*!*/ binder, DynamicMetaObject/*!*/[]/*!*/ args) { DynamicMetaObject[] tupleArgs = Callable.GetTupleArguments(args); - return Callable.CompleteRuleTarget(metaBinder, tupleArgs, delegate () { + return Callable.CompleteRuleTarget(metaBinder, tupleArgs, delegate() { if (args[1].GetLimitType() != typeof(Slice) && GetTypeAt(1).TryResolveSlot(binder.SharedContext, "__index__", out _)) { args[1] = new DynamicMetaObject( DynamicExpression.Dynamic( @@ -1740,7 +1742,7 @@ public static PythonOperationKind OperatorToReverseOperator(PythonOperationKind Expression error = action.Throw( Ast.Call( - typeof(PythonOps).GetMethod(nameof(PythonOps.SimpleTypeError)), + typeof(PythonOps).GetMethod(nameof(PythonOps.SimpleTypeError)), Ast.Constant(message) ), typeof(object) diff --git a/src/ipy/IronPython/Runtime/Binding/PythonSetIndexBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonSetIndexBinder.cs index 7b2b028c3..89ffc18f1 100644 --- a/src/ipy/IronPython/Runtime/Binding/PythonSetIndexBinder.cs +++ b/src/ipy/IronPython/Runtime/Binding/PythonSetIndexBinder.cs @@ -2,14 +2,16 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; using System.Dynamic; -using System.Linq.Expressions; using System.Runtime.CompilerServices; -using IronPython.Runtime.Operations; - using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + +using IronPython.Runtime.Operations; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -31,7 +33,7 @@ public override DynamicMetaObject FallbackSetIndex(DynamicMetaObject target, Dyn return com; } #endif - + DynamicMetaObject[] finalArgs = new DynamicMetaObject[indexes.Length + 2]; finalArgs[0] = target; for (int i = 0; i < indexes.Length; i++) { @@ -51,7 +53,7 @@ public override T BindDelegate(CallSite site, object[] args) { return base.BindDelegate(site, args); } - + private object DictAssign(CallSite site, object dict, object key, object value) { if (dict != null && dict.GetType() == typeof(PythonDictionary)) { ((PythonDictionary)dict)[key] = value; diff --git a/src/ipy/IronPython/Runtime/Binding/PythonSetMemberBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonSetMemberBinder.cs index 619b65c35..347e1c1bb 100644 --- a/src/ipy/IronPython/Runtime/Binding/PythonSetMemberBinder.cs +++ b/src/ipy/IronPython/Runtime/Binding/PythonSetMemberBinder.cs @@ -2,21 +2,21 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Dynamic; using System.Linq.Expressions; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - +using System; +using System.Dynamic; using Microsoft.Scripting; using Microsoft.Scripting.Runtime; - using AstUtils = Microsoft.Scripting.Ast.Utils; -namespace IronPython.Runtime.Binding { - using System.Runtime.CompilerServices; +using IronPython.Runtime.Binding; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; +namespace IronPython.Runtime.Binding { using Ast = Expression; + using System.Runtime.CompilerServices; internal class PythonSetMemberBinder : SetMemberBinder, IPythonSite, IExpressionSerializable { private readonly PythonContext/*!*/ _context; diff --git a/src/ipy/IronPython/Runtime/Binding/PythonSetSliceBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonSetSliceBinder.cs index 64e2f394c..db3f13b12 100644 --- a/src/ipy/IronPython/Runtime/Binding/PythonSetSliceBinder.cs +++ b/src/ipy/IronPython/Runtime/Binding/PythonSetSliceBinder.cs @@ -2,14 +2,16 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Dynamic; using System.Linq.Expressions; -using IronPython.Runtime.Operations; +using System; +using System.Dynamic; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Operations; + namespace IronPython.Runtime.Binding { using Ast = Expression; @@ -21,7 +23,7 @@ public PythonSetSliceBinder(PythonContext/*!*/ context) { _context = context; } - public override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args) { + public override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args) { return PythonProtocol.Index(this, PythonIndexType.SetSlice, ArrayUtils.Insert(target, args)); } diff --git a/src/ipy/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs b/src/ipy/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs index 7be52081a..abaf83227 100644 --- a/src/ipy/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs +++ b/src/ipy/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs @@ -2,15 +2,17 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; using System.Dynamic; -using System.Linq.Expressions; using System.Runtime.CompilerServices; -using IronPython.Runtime.Operations; - using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + +using IronPython.Runtime.Operations; namespace IronPython.Runtime.Binding { using Ast = Expression; diff --git a/src/ipy/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs b/src/ipy/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs index 38801afe2..949a9873d 100644 --- a/src/ipy/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs +++ b/src/ipy/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs @@ -2,17 +2,19 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Linq.Expressions; -using System.Reflection; - -using Microsoft.Scripting.Actions.Calls; +using System; +using System.Collections.Generic; +using System.Dynamic; +using System.Reflection; using AstUtils = Microsoft.Scripting.Ast.Utils; +using Microsoft.Scripting.Actions.Calls; +using Microsoft.Scripting.Utils; namespace IronPython.Runtime.Binding { public sealed class SiteLocalStorageBuilder : ArgBuilder { - public SiteLocalStorageBuilder(ParameterInfo info) + public SiteLocalStorageBuilder(ParameterInfo info) : base(info) { } diff --git a/src/ipy/IronPython/Runtime/Binding/SlotOrFunction.cs b/src/ipy/IronPython/Runtime/Binding/SlotOrFunction.cs index a48863992..5f54c0fb2 100644 --- a/src/ipy/IronPython/Runtime/Binding/SlotOrFunction.cs +++ b/src/ipy/IronPython/Runtime/Binding/SlotOrFunction.cs @@ -2,19 +2,20 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; using System.Collections.Generic; using System.Diagnostics; -using System.Dynamic; -using System.Linq.Expressions; using System.Reflection; - +using System.Dynamic; using IronPython.Runtime.Types; - +using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Actions.Calls; -using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Generation; using Microsoft.Scripting.Utils; +using Microsoft.Scripting.Runtime; namespace IronPython.Runtime.Binding { using Ast = Expression; @@ -239,9 +240,9 @@ internal static bool TryGetBinder(PythonContext/*!*/ state, DynamicMetaObject/*! } var mc = new PythonOverloadResolver( - state.Binder, + state.Binder, types, - new CallSignature(types.Length), + new CallSignature(types.Length), AstUtils.Constant(state.SharedContext) ); diff --git a/src/ipy/IronPython/Runtime/Binding/WarningInfo.cs b/src/ipy/IronPython/Runtime/Binding/WarningInfo.cs index d23c10469..616ecd3af 100644 --- a/src/ipy/IronPython/Runtime/Binding/WarningInfo.cs +++ b/src/ipy/IronPython/Runtime/Binding/WarningInfo.cs @@ -7,7 +7,6 @@ using IronPython.Runtime.Operations; using IronPython.Runtime.Types; - using Microsoft.Scripting.Utils; using AstUtils = Microsoft.Scripting.Ast.Utils; diff --git a/src/ipy/IronPython/Runtime/BufferProtocol.cs b/src/ipy/IronPython/Runtime/BufferProtocol.cs index 1b4b6321c..f537ae709 100644 --- a/src/ipy/IronPython/Runtime/BufferProtocol.cs +++ b/src/ipy/IronPython/Runtime/BufferProtocol.cs @@ -30,7 +30,7 @@ public enum BufferFlags { /// /// The buffer must be writable. The consumer cannot handle read-only buffers. /// - Writable = 0x0001, + Writable = 0x0001, /// /// The consumer expects the item format to be reported and is prepared to deal with items that are more complex than a byte. @@ -38,30 +38,30 @@ public enum BufferFlags { /// /// If format is requested, the consumer must also indicate preparedness to handle shape ( flag set). /// - Format = 0x0004, + Format = 0x0004, /// /// An N-dimensional array, 0 <= N <= 64. The dimensions are reported as shape. /// - ND = 0x0008, + ND = 0x0008, /// /// An N-dimensional array with strides, so data may not be memory contiguous. /// However, it will fit in a contiguous memory range. /// - Strides = 0x0010 | ND, + Strides = 0x0010 | ND, /// /// An N-dimensional array with strides, so it may not be memory contiguous. /// The last dimension is contiguous. /// - CContiguous = 0x0020 | Strides, + CContiguous = 0x0020 | Strides, /// /// An N-dimensional array with strides, so it may not be memory contiguous. /// The first dimension is contiguous. /// - FContiguous = 0x0040 | Strides, + FContiguous = 0x0040 | Strides, /// /// The client is prepared to deal with either or . @@ -72,29 +72,29 @@ public enum BufferFlags { /// An N-dimensional array that has a complex structure, where higher dimensions /// may contains pointers to memory blocks holding lower dimensions. /// - Indirect = 0x0100 | Strides, + Indirect = 0x0100 | Strides, #region Flag combinations for common requests /// /// Unformatted (i.e. byte-oriented) read-only blob with no structure. /// - Simple = 0, + Simple = 0, /// /// Contiguous writable buffer of any dimension. /// - Contig = ND | Writable, + Contig = ND | Writable, /// /// Contiguous buffer of any dimension. /// - ContigRO = ND, + ContigRO = ND, /// /// Writable byte buffer of any dimension, possibly non-contiguous, but with no embedded pointers. /// - Strided = Strides | Writable, + Strided = Strides | Writable, /// /// Byte buffer of any dimension, possibly non-contiguous, but with no embedded pointers. @@ -105,7 +105,7 @@ public enum BufferFlags { /// Writable buffer of any dimension, possibly non-contiguous, but with no embedded pointers. /// Elements can be any struct type. /// - Records = Strides | Writable | Format, + Records = Strides | Writable | Format, /// /// Buffer of any dimension, possibly non-contiguous, but with no embedded pointers. @@ -113,8 +113,8 @@ public enum BufferFlags { /// RecordsRO = Strides | Format, - Full = Indirect | Writable | Format, - FullRO = Indirect | Format, + Full = Indirect | Writable | Format, + FullRO = Indirect | Format, #endregion } diff --git a/src/ipy/IronPython/Runtime/BuiltinPythonModule.cs b/src/ipy/IronPython/Runtime/BuiltinPythonModule.cs index ee315159d..65e973fd6 100644 --- a/src/ipy/IronPython/Runtime/BuiltinPythonModule.cs +++ b/src/ipy/IronPython/Runtime/BuiltinPythonModule.cs @@ -2,10 +2,9 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; using System.Collections.Generic; - using IronPython.Compiler; - using Microsoft.Scripting.Utils; namespace IronPython.Runtime { diff --git a/src/ipy/IronPython/Runtime/BuiltinsDictionaryStorage.cs b/src/ipy/IronPython/Runtime/BuiltinsDictionaryStorage.cs index c5b4e5e5b..06e5ebafc 100644 --- a/src/ipy/IronPython/Runtime/BuiltinsDictionaryStorage.cs +++ b/src/ipy/IronPython/Runtime/BuiltinsDictionaryStorage.cs @@ -4,10 +4,11 @@ using System; -using IronPython.Modules; - +using Microsoft.Scripting; using Microsoft.Scripting.Runtime; +using IronPython.Modules; + namespace IronPython.Runtime { internal class BuiltinsDictionaryStorage : ModuleDictionaryStorage { private readonly EventHandler/*!*/ _change; @@ -27,7 +28,7 @@ public override void Add(ref DictionaryStorage storage, object key, object value } base.Add(ref storage, key, value); } - + protected override void LazyAdd(object name, object value) { base.Add(name, value); } diff --git a/src/ipy/IronPython/Runtime/ByteArray.cs b/src/ipy/IronPython/Runtime/ByteArray.cs index d3a21b3fc..ef3f6a2a0 100644 --- a/src/ipy/IronPython/Runtime/ByteArray.cs +++ b/src/ipy/IronPython/Runtime/ByteArray.cs @@ -9,15 +9,16 @@ using System.Collections.Generic; using System.Numerics; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; using System.Text; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - namespace IronPython.Runtime { /// /// bytearray(string, encoding[, errors]) -> bytearray @@ -294,7 +295,7 @@ public int count([BytesLike, NotNone] IList sub, object? start, object? en int istart = start != null ? Converter.ConvertToIndex(start) : 0; lock (this) { int iend = end != null ? Converter.ConvertToIndex(end) : _bytes.Count; - return _bytes.CountOf(sub, istart, iend); + return _bytes.CountOf(sub, istart, iend); } } @@ -659,7 +660,7 @@ public ByteArray lstrip() { } } - public ByteArray lstrip([BytesLike] IList? chars) { + public ByteArray lstrip([BytesLike]IList? chars) { if (chars == null) return lstrip(); lock (this) { var res = _bytes.LeftStrip(chars); @@ -843,7 +844,7 @@ public PythonTuple rpartition([BytesLike, NotNone] IList sep) { } [return: SequenceTypeInfo(typeof(ByteArray))] - public PythonList rsplit([BytesLike] IList? sep = null, int maxsplit = -1) { + public PythonList rsplit([BytesLike]IList? sep = null, int maxsplit = -1) { lock (this) { return _bytes.RightSplit(sep, maxsplit, x => new ByteArray(new List(x))); } @@ -856,7 +857,7 @@ public ByteArray rstrip() { } } - public ByteArray rstrip([BytesLike] IList? chars) { + public ByteArray rstrip([BytesLike]IList? chars) { if (chars == null) return rstrip(); lock (this) { var res = _bytes.RightStrip(chars); @@ -865,7 +866,7 @@ public ByteArray rstrip([BytesLike] IList? chars) { } [return: SequenceTypeInfo(typeof(ByteArray))] - public PythonList split([BytesLike] IList? sep = null, int maxsplit = -1) { + public PythonList split([BytesLike]IList? sep = null, int maxsplit = -1) { lock (this) { return _bytes.Split(sep, maxsplit, x => new ByteArray(x)); } @@ -961,7 +962,7 @@ public ByteArray strip() { } } - public ByteArray strip([BytesLike] IList? chars) { + public ByteArray strip([BytesLike]IList? chars) { if (chars == null) return strip(); lock (this) { var res = _bytes.Strip(chars); @@ -988,7 +989,7 @@ private void ValidateTable(IList? table) { } } - public ByteArray translate([BytesLike] IList? table) { + public ByteArray translate([BytesLike]IList? table) { ValidateTable(table); lock (this) { return new ByteArray(_bytes.Translate(table, null)); @@ -996,14 +997,14 @@ public ByteArray translate([BytesLike] IList? table) { } - public ByteArray translate([BytesLike] IList? table, [BytesLike, NotNone] IList delete) { + public ByteArray translate([BytesLike]IList? table, [BytesLike, NotNone] IList delete) { ValidateTable(table); lock (this) { return new ByteArray(_bytes.Translate(table, delete)); } } - public ByteArray translate([BytesLike] IList? table, object? delete) { + public ByteArray translate([BytesLike]IList? table, object? delete) { if (delete is IBufferProtocol bufferProtocol) { using var buffer = bufferProtocol.GetBuffer(); return translate(table, buffer.AsReadOnlySpan().ToArray()); diff --git a/src/ipy/IronPython/Runtime/Bytes.cs b/src/ipy/IronPython/Runtime/Bytes.cs index 8251d1d40..1f4c3d1d0 100644 --- a/src/ipy/IronPython/Runtime/Bytes.cs +++ b/src/ipy/IronPython/Runtime/Bytes.cs @@ -14,13 +14,12 @@ using System.Numerics; using System.Text; -using IronPython.Runtime.Exceptions; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Exceptions; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; using NotNullWhenAttribute = System.Diagnostics.CodeAnalysis.NotNullWhenAttribute; namespace IronPython.Runtime { @@ -532,7 +531,7 @@ public Bytes lstrip() { return res == null ? this.AsBytes() : new Bytes(res); } - public Bytes lstrip([BytesLike] IList? chars) { + public Bytes lstrip([BytesLike]IList? chars) { if (chars == null) return lstrip(); var res = _bytes.LeftStrip(chars); return res == null ? this.AsBytes() : new Bytes(res); @@ -701,7 +700,7 @@ public PythonTuple rpartition([BytesLike, NotNone] IList sep) { } [return: SequenceTypeInfo(typeof(Bytes))] - public PythonList rsplit([BytesLike] IList? sep = null, int maxsplit = -1) { + public PythonList rsplit([BytesLike]IList? sep = null, int maxsplit = -1) { return _bytes.RightSplit(sep, maxsplit, x => new Bytes(new List(x))); } @@ -710,14 +709,14 @@ public Bytes rstrip() { return res == null ? this.AsBytes() : new Bytes(res); } - public Bytes rstrip([BytesLike] IList? chars) { + public Bytes rstrip([BytesLike]IList? chars) { if (chars == null) return rstrip(); var res = _bytes.RightStrip(chars); return res == null ? this.AsBytes() : new Bytes(res); } [return: SequenceTypeInfo(typeof(Bytes))] - public PythonList split([BytesLike] IList? sep = null, int maxsplit = -1) { + public PythonList split([BytesLike]IList? sep = null, int maxsplit = -1) { return _bytes.Split(sep, maxsplit, x => new Bytes(x)); } @@ -791,7 +790,7 @@ public Bytes strip() { return res == null ? this.AsBytes() : new Bytes(res); } - public Bytes strip([BytesLike] IList? chars) { + public Bytes strip([BytesLike]IList? chars) { if (chars == null) return strip(); var res = _bytes.Strip(chars); return res == null ? this.AsBytes() : new Bytes(res); @@ -816,7 +815,7 @@ private void ValidateTable(IList? table) { } } - public Bytes translate([BytesLike] IList? table) { + public Bytes translate([BytesLike]IList? table) { ValidateTable(table); if (table is null) return AsBytes(); var res = _bytes.Translate(table, null, out bool changed); @@ -824,7 +823,7 @@ public Bytes translate([BytesLike] IList? table) { return AsBytes(); } - public Bytes translate([BytesLike] IList? table, [BytesLike, NotNone] IList delete) { + public Bytes translate([BytesLike]IList? table, [BytesLike, NotNone] IList delete) { ValidateTable(table); if (table is null && delete.Count == 0) return AsBytes(); var res = _bytes.Translate(table, delete, out bool changed); @@ -832,7 +831,7 @@ public Bytes translate([BytesLike] IList? table, [BytesLike, NotNone] ILis return AsBytes(); } - public Bytes translate([BytesLike] IList? table, object? delete) { + public Bytes translate([BytesLike]IList? table, object? delete) { if (delete is IBufferProtocol bufferProtocol) { using var buffer = bufferProtocol.GetBuffer(); return translate(table, buffer.AsReadOnlySpan().ToArray()); diff --git a/src/ipy/IronPython/Runtime/ClassMethodDescriptor.cs b/src/ipy/IronPython/Runtime/ClassMethodDescriptor.cs index 4cab7c741..c04c03289 100644 --- a/src/ipy/IronPython/Runtime/ClassMethodDescriptor.cs +++ b/src/ipy/IronPython/Runtime/ClassMethodDescriptor.cs @@ -3,10 +3,8 @@ // See the LICENSE file in the project root for more information. using System; - using IronPython.Runtime.Operations; using IronPython.Runtime.Types; - using Microsoft.Scripting.Runtime; namespace IronPython.Runtime { @@ -25,7 +23,7 @@ internal override bool TryGetValue(CodeContext context, object instance, PythonT } #region Descriptor Protocol - + private PythonType CheckGetArgs(CodeContext context, object instance, PythonType owner) { if (owner == null) { if (instance == null) throw PythonOps.TypeError("__get__(None, None) is invalid"); @@ -70,5 +68,5 @@ public override bool Equals(object obj) { public override int GetHashCode() { return ~_func.GetHashCode(); } - } + } } diff --git a/src/ipy/IronPython/Runtime/ClrModule.cs b/src/ipy/IronPython/Runtime/ClrModule.cs index 0ceddef7f..7e7b404bc 100644 --- a/src/ipy/IronPython/Runtime/ClrModule.cs +++ b/src/ipy/IronPython/Runtime/ClrModule.cs @@ -171,7 +171,7 @@ assembly on disk. After the load the assemblies namespaces and top-level types will be available via import Namespace.")] public static Assembly/*!*/ LoadAssemblyFromFileWithPath(CodeContext/*!*/ context, string/*!*/ file) { if (file == null) throw new TypeErrorException("LoadAssemblyFromFileWithPath: arg 1 must be a string."); - + Assembly res; if (!context.LanguageContext.TryLoadAssemblyFromFileWithPath(file, out res)) { if (!Path.IsPathRooted(file)) { @@ -253,7 +253,7 @@ public static string GetString(byte[] bytes) { [Documentation("Converts maxCount of an array of bytes to a string")] public static string GetString(byte[] bytes, int maxCount) { - int bytesToCopy = Math.Min(bytes.Length, maxCount); + int bytesToCopy = Math.Min(bytes.Length, maxCount); return Encoding.GetEncoding("iso-8859-1").GetString(bytes, 0, bytesToCopy); } @@ -699,7 +699,7 @@ internal override bool GetAlwaysSucceeds { #region IFancyCallable Members [SpecialName] - public object Call(CodeContext context, [ParamDictionary] IDictionary dict, params object[] args) { + public object Call(CodeContext context, [ParamDictionary]IDictionary dict, params object[] args) { ValidateArgs(args); if (_inst != null) { @@ -794,7 +794,7 @@ internal override bool GetAlwaysSucceeds { #region IFancyCallable Members [SpecialName] - public object Call(CodeContext context, [ParamDictionary] IDictionary dict, params object[] args) { + public object Call(CodeContext context, [ParamDictionary]IDictionary dict, params object[] args) { object ret; if (_inst != null) { ret = PythonCalls.CallWithKeywordArgs(context, _func, ArrayUtils.Insert(_inst, args), dict); @@ -870,7 +870,7 @@ public static object Convert(CodeContext/*!*/ context, object o, Type toType) { /// Provides a helper for compiling a group of modules into a single assembly. The assembly can later be /// reloaded using the clr.AddReference API. /// - public static void CompileModules(CodeContext/*!*/ context, string/*!*/ assemblyName, [ParamDictionary] IDictionary kwArgs, params string/*!*/[]/*!*/ filenames) { + public static void CompileModules(CodeContext/*!*/ context, string/*!*/ assemblyName, [ParamDictionary]IDictionary kwArgs, params string/*!*/[]/*!*/ filenames) { ContractUtils.RequiresNotNull(assemblyName, nameof(assemblyName)); ContractUtils.RequiresNotNullItems(filenames, nameof(filenames)); @@ -996,7 +996,7 @@ public static void CompileSubclassTypes(string/*!*/ assemblyName, params object[ /// public static PythonTuple GetSubclassedTypes() { List res = new List(); - + foreach (NewTypeInfo info in NewTypeMaker._newTypes.Keys) { Type clrBaseType = info.BaseType; Type tempType = clrBaseType; @@ -1129,7 +1129,7 @@ private static void SortModules(List modules) { /// /// All times are expressed in the same unit of measure as DateTime.Ticks /// - public static PythonTuple GetProfilerData(CodeContext/*!*/ context, bool includeUnused = false) { + public static PythonTuple GetProfilerData(CodeContext/*!*/ context, bool includeUnused=false) { return new PythonTuple(Profiler.GetProfiler(context.LanguageContext).GetProfile(includeUnused)); } diff --git a/src/ipy/IronPython/Runtime/CodeContext.cs b/src/ipy/IronPython/Runtime/CodeContext.cs index 0f8a8e82a..404f3c28a 100644 --- a/src/ipy/IronPython/Runtime/CodeContext.cs +++ b/src/ipy/IronPython/Runtime/CodeContext.cs @@ -4,13 +4,14 @@ #nullable enable +using System; using System.Diagnostics; -using IronPython.Compiler; - using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Compiler; + namespace IronPython.Runtime { /// diff --git a/src/ipy/IronPython/Runtime/CollectionDebugView.cs b/src/ipy/IronPython/Runtime/CollectionDebugView.cs index f224255ed..fc070aa21 100644 --- a/src/ipy/IronPython/Runtime/CollectionDebugView.cs +++ b/src/ipy/IronPython/Runtime/CollectionDebugView.cs @@ -2,9 +2,11 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Collections; +using System; using System.Collections.Generic; +using System.Text; using System.Diagnostics; +using System.Collections; namespace IronPython.Runtime { internal class CollectionDebugProxy { diff --git a/src/ipy/IronPython/Runtime/CommonDictionaryStorage.cs b/src/ipy/IronPython/Runtime/CommonDictionaryStorage.cs index 5d6d0657c..22a3c0de1 100644 --- a/src/ipy/IronPython/Runtime/CommonDictionaryStorage.cs +++ b/src/ipy/IronPython/Runtime/CommonDictionaryStorage.cs @@ -10,11 +10,13 @@ using System.Runtime.Serialization; using System.Threading; +using Microsoft.Scripting.Generation; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting.Runtime; - namespace IronPython.Runtime { /// /// General purpose storage used for most PythonDictionarys. diff --git a/src/ipy/IronPython/Runtime/CompiledLoader.cs b/src/ipy/IronPython/Runtime/CompiledLoader.cs index 26db14f37..06f29cb3e 100644 --- a/src/ipy/IronPython/Runtime/CompiledLoader.cs +++ b/src/ipy/IronPython/Runtime/CompiledLoader.cs @@ -6,10 +6,11 @@ using System.Collections.Generic; using System.IO; -using IronPython.Compiler; - using Microsoft.Scripting; +using IronPython.Compiler; +using IronPython.Runtime.Operations; + namespace IronPython.Runtime { public class CompiledLoader { private readonly Dictionary _codes = new Dictionary(); diff --git a/src/ipy/IronPython/Runtime/ConstantDictionaryStorage.cs b/src/ipy/IronPython/Runtime/ConstantDictionaryStorage.cs index 8e73eac5c..215cde859 100644 --- a/src/ipy/IronPython/Runtime/ConstantDictionaryStorage.cs +++ b/src/ipy/IronPython/Runtime/ConstantDictionaryStorage.cs @@ -2,14 +2,14 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using MSAst = System.Linq.Expressions; + using System; using System.Collections.Generic; - -using IronPython.Runtime.Operations; - +using System.Text; using Microsoft.Scripting.Runtime; - -using MSAst = System.Linq.Expressions; +using IronPython.Runtime.Operations; +using Microsoft.Scripting.Generation; using Utils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Runtime { @@ -34,7 +34,7 @@ public override void Add(ref DictionaryStorage storage, object key, object value return; } } - + // race, try again... storage.Add(ref storage, key, value); } @@ -54,7 +54,7 @@ public override bool Remove(ref DictionaryStorage storage, object key) { // race, try again return storage.Remove(ref storage, key); } - + return false; } diff --git a/src/ipy/IronPython/Runtime/Converter.cs b/src/ipy/IronPython/Runtime/Converter.cs index 464686131..8dc38890d 100644 --- a/src/ipy/IronPython/Runtime/Converter.cs +++ b/src/ipy/IronPython/Runtime/Converter.cs @@ -47,19 +47,19 @@ public static partial class Converter { private static readonly CallSite> _floatSite = MakeExplicitConvertSite(); private static readonly CallSite> - _tryByteSite = MakeExplicitTrySite(), - _trySByteSite = MakeExplicitTrySite(), - _tryInt16Site = MakeExplicitTrySite(), - _tryInt32Site = MakeExplicitTrySite(), - _tryInt64Site = MakeExplicitTrySite(), - _tryUInt16Site = MakeExplicitTrySite(), - _tryUInt32Site = MakeExplicitTrySite(), - _tryUInt64Site = MakeExplicitTrySite(), - _tryDoubleSite = MakeExplicitTrySite(), - _tryCharSite = MakeExplicitTrySite(), + _tryByteSite = MakeExplicitTrySite(), + _trySByteSite = MakeExplicitTrySite(), + _tryInt16Site = MakeExplicitTrySite(), + _tryInt32Site = MakeExplicitTrySite(), + _tryInt64Site = MakeExplicitTrySite(), + _tryUInt16Site = MakeExplicitTrySite(), + _tryUInt32Site = MakeExplicitTrySite(), + _tryUInt64Site = MakeExplicitTrySite(), + _tryDoubleSite = MakeExplicitTrySite(), + _tryCharSite = MakeExplicitTrySite(), _tryBigIntegerSite = MakeExplicitTrySite(), - _tryComplexSite = MakeExplicitTrySite(), - _tryStringSite = MakeExplicitTrySite(); + _tryComplexSite = MakeExplicitTrySite(), + _tryStringSite = MakeExplicitTrySite(); private static CallSite> MakeImplicitConvertSite() { return MakeConvertSite(ConversionResultKind.ImplicitCast); diff --git a/src/ipy/IronPython/Runtime/CustomDictionaryStorage.cs b/src/ipy/IronPython/Runtime/CustomDictionaryStorage.cs index 351309d00..072c156e8 100644 --- a/src/ipy/IronPython/Runtime/CustomDictionaryStorage.cs +++ b/src/ipy/IronPython/Runtime/CustomDictionaryStorage.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using System.Linq; +using Microsoft.Scripting; using Microsoft.Scripting.Runtime; namespace IronPython.Runtime { diff --git a/src/ipy/IronPython/Runtime/DebuggerDictionaryStorage.cs b/src/ipy/IronPython/Runtime/DebuggerDictionaryStorage.cs index 5b2e96194..ae28867e1 100644 --- a/src/ipy/IronPython/Runtime/DebuggerDictionaryStorage.cs +++ b/src/ipy/IronPython/Runtime/DebuggerDictionaryStorage.cs @@ -5,6 +5,8 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Threading; +using Microsoft.Scripting; namespace IronPython.Runtime { /// diff --git a/src/ipy/IronPython/Runtime/DefaultContext.cs b/src/ipy/IronPython/Runtime/DefaultContext.cs index ce385a3e7..663706507 100644 --- a/src/ipy/IronPython/Runtime/DefaultContext.cs +++ b/src/ipy/IronPython/Runtime/DefaultContext.cs @@ -4,7 +4,7 @@ using System.Diagnostics; using System.Threading; - +using IronPython.Runtime.Binding; using Microsoft.Scripting; using Microsoft.Scripting.Runtime; @@ -14,13 +14,13 @@ public static class DefaultContext { internal static CodeContext _default; [MultiRuntimeAware] internal static CodeContext _defaultCLS; - + public static ContextId Id { get { return Default.LanguageContext.ContextId; } } - + public static CodeContext Default { get { Debug.Assert(_default != null); diff --git a/src/ipy/IronPython/Runtime/Descriptors.cs b/src/ipy/IronPython/Runtime/Descriptors.cs index 7f6b7f0b8..d448ca334 100644 --- a/src/ipy/IronPython/Runtime/Descriptors.cs +++ b/src/ipy/IronPython/Runtime/Descriptors.cs @@ -2,14 +2,17 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; using System.Collections.Generic; using System.Runtime.CompilerServices; - -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; +using System.Runtime.InteropServices; using Microsoft.Scripting; using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; namespace IronPython.Runtime { [PythonType] @@ -22,7 +25,7 @@ public staticmethod(CodeContext/*!*/ context, object func) { public void __init__(CodeContext/*!*/ context, object func) { _func = func; - } + } internal override bool TryGetValue(CodeContext context, object instance, PythonType owner, out object value) { value = __get__(instance, owner); @@ -153,7 +156,7 @@ internal override bool TrySetValue(CodeContext context, object instance, PythonT internal override bool TryDeleteValue(CodeContext context, object instance, PythonType owner) { if (instance == null) { return false; - } + } __delete__(context, instance); return true; } @@ -163,9 +166,9 @@ public bool __isabstractmethod__ { object isabstract; if (PythonOps.TryGetBoundAttr(_fget, "__isabstractmethod__", out isabstract)) { return PythonOps.IsTrue(isabstract); - } else if (PythonOps.TryGetBoundAttr(_fset, "__isabstractmethod__", out isabstract)) { + } else if(PythonOps.TryGetBoundAttr(_fset, "__isabstractmethod__", out isabstract)) { return PythonOps.IsTrue(isabstract); - } else if (PythonOps.TryGetBoundAttr(_fdel, "__isabstractmethod__", out isabstract)) { + } else if(PythonOps.TryGetBoundAttr(_fdel, "__isabstractmethod__", out isabstract)) { return PythonOps.IsTrue(isabstract); } return false; @@ -204,7 +207,7 @@ public object fget { } } - public override object __get__(CodeContext/*!*/ context, object instance, object owner = null) { + public override object __get__(CodeContext/*!*/ context, object instance, object owner=null) { if (instance == null) { return this; } else if (fget != null) { diff --git a/src/ipy/IronPython/Runtime/DictionaryOps.cs b/src/ipy/IronPython/Runtime/DictionaryOps.cs index 0bbca1c32..cf5f3cd0d 100644 --- a/src/ipy/IronPython/Runtime/DictionaryOps.cs +++ b/src/ipy/IronPython/Runtime/DictionaryOps.cs @@ -2,16 +2,20 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; +using System.Runtime.CompilerServices; using System.Text; +using Microsoft.Scripting; +using Microsoft.Scripting.Runtime; + +using IronPython.Runtime.Binding; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting.Runtime; - namespace IronPython.Runtime { /// /// Provides both helpers for implementing Python dictionaries as well diff --git a/src/ipy/IronPython/Runtime/DictionaryStorage.cs b/src/ipy/IronPython/Runtime/DictionaryStorage.cs index 227a31fe3..c5751eb58 100644 --- a/src/ipy/IronPython/Runtime/DictionaryStorage.cs +++ b/src/ipy/IronPython/Runtime/DictionaryStorage.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. @@ -8,6 +8,7 @@ using System.Collections.Generic; using System.Diagnostics; +using Microsoft.Scripting; using Microsoft.Scripting.Runtime; namespace IronPython.Runtime { @@ -122,7 +123,7 @@ public virtual void EnsureCapacityNoLock(int size) { public virtual IEnumerator> GetEnumerator() { return GetItems().GetEnumerator(); } - + /// /// Provides fast access to the __path__ attribute if the dictionary storage supports caching it. /// diff --git a/src/ipy/IronPython/Runtime/DictionaryTypeInfoAttribute.cs b/src/ipy/IronPython/Runtime/DictionaryTypeInfoAttribute.cs index 36fa3cd59..583d8269c 100644 --- a/src/ipy/IronPython/Runtime/DictionaryTypeInfoAttribute.cs +++ b/src/ipy/IronPython/Runtime/DictionaryTypeInfoAttribute.cs @@ -12,7 +12,7 @@ namespace IronPython.Runtime { /// inspected to get type information about the types of the keys and values of the expected /// dictionary or the returned dictionary. /// - [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, AllowMultiple = false)] + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, AllowMultiple=false)] public sealed class DictionaryTypeInfoAttribute : Attribute { public DictionaryTypeInfoAttribute(Type keyType, Type valueType) { KeyType = keyType; diff --git a/src/ipy/IronPython/Runtime/EmptyDictionaryStorage.cs b/src/ipy/IronPython/Runtime/EmptyDictionaryStorage.cs index 0c27d814e..3e86ff4fa 100644 --- a/src/ipy/IronPython/Runtime/EmptyDictionaryStorage.cs +++ b/src/ipy/IronPython/Runtime/EmptyDictionaryStorage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Text; using IronPython.Runtime.Operations; @@ -23,7 +24,7 @@ public override void Add(ref DictionaryStorage storage, object key, object value return; } } - + // race, try again... storage.Add(ref storage, key, value); } diff --git a/src/ipy/IronPython/Runtime/Enumerate.cs b/src/ipy/IronPython/Runtime/Enumerate.cs index 22b785e32..c8fae3449 100644 --- a/src/ipy/IronPython/Runtime/Enumerate.cs +++ b/src/ipy/IronPython/Runtime/Enumerate.cs @@ -9,12 +9,12 @@ using System.Numerics; using System.Runtime.CompilerServices; +using Microsoft.Scripting.Runtime; + using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting.Runtime; - namespace IronPython.Runtime { /* * Enumerators exposed to Python code directly diff --git a/src/ipy/IronPython/Runtime/ErrorCodes.cs b/src/ipy/IronPython/Runtime/ErrorCodes.cs index d36d66a82..3718dcf28 100644 --- a/src/ipy/IronPython/Runtime/ErrorCodes.cs +++ b/src/ipy/IronPython/Runtime/ErrorCodes.cs @@ -25,12 +25,12 @@ public static class ErrorCodes { /// /// The error was a general syntax error /// - public const int SyntaxError = 0x0010; + public const int SyntaxError = 0x0010; /// /// The error was an indentation error. /// - public const int IndentationError = 0x0020; + public const int IndentationError = 0x0020; /// /// The error was a tab error. diff --git a/src/ipy/IronPython/Runtime/Exceptions/AttributeErrorException.cs b/src/ipy/IronPython/Runtime/Exceptions/AttributeErrorException.cs index effd22634..ec4a18038 100644 --- a/src/ipy/IronPython/Runtime/Exceptions/AttributeErrorException.cs +++ b/src/ipy/IronPython/Runtime/Exceptions/AttributeErrorException.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Runtime.Serialization; - using Microsoft.Scripting.Runtime; namespace IronPython.Runtime.Exceptions { diff --git a/src/ipy/IronPython/Runtime/Exceptions/IndentationException.cs b/src/ipy/IronPython/Runtime/Exceptions/IndentationException.cs index 5e19ceabd..508522cb0 100644 --- a/src/ipy/IronPython/Runtime/Exceptions/IndentationException.cs +++ b/src/ipy/IronPython/Runtime/Exceptions/IndentationException.cs @@ -5,7 +5,6 @@ using System; using System.Runtime.Serialization; using System.Security; - using Microsoft.Scripting; using Microsoft.Scripting.Utils; diff --git a/src/ipy/IronPython/Runtime/Exceptions/PythonException.cs b/src/ipy/IronPython/Runtime/Exceptions/PythonException.cs index d909d13ef..45e9e169e 100644 --- a/src/ipy/IronPython/Runtime/Exceptions/PythonException.cs +++ b/src/ipy/IronPython/Runtime/Exceptions/PythonException.cs @@ -7,7 +7,6 @@ using System; using System.Collections.Generic; using System.Runtime.Serialization; - using Microsoft.Scripting.Runtime; namespace IronPython.Runtime.Exceptions { diff --git a/src/ipy/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs b/src/ipy/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs index 20aef855a..6a7bc59e5 100644 --- a/src/ipy/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs +++ b/src/ipy/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs @@ -87,7 +87,8 @@ public static object __new__([NotNone] PythonType/*!*/ cls, [NotNone] params obj BaseException res; if (cls.UnderlyingSystemType == typeof(BaseException)) { res = new BaseException(cls); - } else { + } + else { res = (BaseException)Activator.CreateInstance(cls.UnderlyingSystemType, cls)!; } res._args = new PythonTuple(args\u00F8); @@ -179,7 +180,8 @@ internal set { } public override string/*!*/ ToString() { - return (_args.__len__()) switch { + return (_args.__len__()) switch + { 0 => string.Empty, 1 => PythonOps.ToString(_args[0]), _ => _args.ToString(), diff --git a/src/ipy/IronPython/Runtime/Exceptions/PythonExceptions.cs b/src/ipy/IronPython/Runtime/Exceptions/PythonExceptions.cs index 45253538d..be0a8567d 100644 --- a/src/ipy/IronPython/Runtime/Exceptions/PythonExceptions.cs +++ b/src/ipy/IronPython/Runtime/Exceptions/PythonExceptions.cs @@ -6,20 +6,23 @@ using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; +using System.Dynamic; using System.IO; +using System.Linq.Expressions; using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; using System.Threading; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using Microsoft.Scripting; using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + #if !FEATURE_REMOTING using MarshalByRefObject = System.Object; #endif @@ -119,7 +122,7 @@ public override string ToString() { } public partial class _OSError { - public static new object __new__(PythonType cls, [ParamDictionary] IDictionary kwArgs, params object[] args) { + public static new object __new__(PythonType cls, [ParamDictionary]IDictionary kwArgs, params object[] args) { if (cls == OSError && args.Length >= 1 && args[0] is int errno) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { if (args.Length >= 4 && args[3] is int winerror) { @@ -220,7 +223,8 @@ private static Error ErrnoToErrorEnum(int errno) { } private static PythonType ErrnoToPythonType(Error errno) { - var res = errno switch { + var res = errno switch + { Error.EPERM => PermissionError, Error.ENOENT => FileNotFoundError, Error.ESRCH => ProcessLookupError, @@ -235,7 +239,8 @@ private static PythonType ErrnoToPythonType(Error errno) { _ => null }; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { - res ??= errno switch { + res ??= errno switch + { // Windows or remapped OSX Error.WSAEWOULDBLOCK => BlockingIOError, Error.WSAEINPROGRESS => BlockingIOError, @@ -248,7 +253,8 @@ private static PythonType ErrnoToPythonType(Error errno) { _ => null }; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { - res ??= errno switch { + res ??= errno switch + { // Linux Error.ECONNABORTED => ConnectionAbortedError, Error.ECONNRESET => ConnectionResetError, @@ -523,7 +529,7 @@ internal static int WinErrorToErrno(int winerror) { } public partial class _ImportError { - public void __init__([ParamDictionary] IDictionary kwargs, params object[] args) { + public void __init__([ParamDictionary]IDictionary kwargs, params object[] args) { base.__init__(args); foreach (var pair in kwargs) { diff --git a/src/ipy/IronPython/Runtime/Exceptions/SystemExitException.cs b/src/ipy/IronPython/Runtime/Exceptions/SystemExitException.cs index 15f34df3d..6444bb4c6 100644 --- a/src/ipy/IronPython/Runtime/Exceptions/SystemExitException.cs +++ b/src/ipy/IronPython/Runtime/Exceptions/SystemExitException.cs @@ -4,7 +4,6 @@ using System; using System.Runtime.Serialization; - using IronPython.Modules; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; diff --git a/src/ipy/IronPython/Runtime/Exceptions/TabException.cs b/src/ipy/IronPython/Runtime/Exceptions/TabException.cs index e7f715a61..7d0815d86 100644 --- a/src/ipy/IronPython/Runtime/Exceptions/TabException.cs +++ b/src/ipy/IronPython/Runtime/Exceptions/TabException.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System; - +using System.Dynamic; using Microsoft.Scripting; namespace IronPython.Runtime.Exceptions { diff --git a/src/ipy/IronPython/Runtime/Exceptions/TraceBack.cs b/src/ipy/IronPython/Runtime/Exceptions/TraceBack.cs index 912331e93..49f1bb208 100644 --- a/src/ipy/IronPython/Runtime/Exceptions/TraceBack.cs +++ b/src/ipy/IronPython/Runtime/Exceptions/TraceBack.cs @@ -8,11 +8,11 @@ using System.Runtime.CompilerServices; using System.Text; -using IronPython.Runtime.Operations; - using Microsoft.Scripting; using Microsoft.Scripting.Runtime; +using IronPython.Runtime.Operations; + [module: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "IronPython.Runtime.Exceptions.TraceBackFrame..ctor(System.Object,System.Object,System.Object)", MessageId = "0#globals")] [module: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "IronPython.Runtime.Exceptions.TraceBackFrame.Globals", MessageId = "Globals")] @@ -118,11 +118,11 @@ internal TraceBackFrame(PythonTracebackListener traceAdapter, FunctionCode code, [SpecialName, PropertyMethod] public object Getf_trace() { - if (_traceAdapter != null) { - return _traceObject; - } else { - return null; - } + if (_traceAdapter != null) { + return _traceObject; + } else { + return null; + } } [SpecialName, PropertyMethod] @@ -230,7 +230,7 @@ private void SetLineNumber(int newLineNum) { Dictionary currentLoopIds = null; bool inForLoopOrFinally = loopAndFinallyLocations != null && loopAndFinallyLocations.TryGetValue(_lineNo, out currentLoopIds); - + int originalNewLine = newLineNum; if (newLineNum < funcCode.Span.Start.Line) { @@ -246,7 +246,7 @@ private void SetLineNumber(int newLineNum) { // Check if we're jumping onto a handler bool handlerIsFinally; if (handlerLocations != null && handlerLocations.TryGetValue(newLineNum, out handlerIsFinally)) { - throw PythonOps.ValueError("can't jump to 'except' line"); + throw PythonOps.ValueError("can't jump to 'except' line"); } // Check if we're jumping into a for-loop diff --git a/src/ipy/IronPython/Runtime/Exceptions/TypeErrorException.cs b/src/ipy/IronPython/Runtime/Exceptions/TypeErrorException.cs index 62ff49703..4e96b88a8 100644 --- a/src/ipy/IronPython/Runtime/Exceptions/TypeErrorException.cs +++ b/src/ipy/IronPython/Runtime/Exceptions/TypeErrorException.cs @@ -5,9 +5,8 @@ using System; using System.Collections.Generic; using System.Runtime.Serialization; - -using Microsoft.Scripting; using Microsoft.Scripting.Runtime; +using Microsoft.Scripting; namespace IronPython.Runtime.Exceptions { #region Generated TypeErrorException @@ -45,7 +44,7 @@ PythonExceptions.BaseException IPythonAwareException.PythonException { newEx.InitializeFromClr(this); _pyExceptionObject = newEx; } - return _pyExceptionObject; + return _pyExceptionObject; } set { _pyExceptionObject = value; } } diff --git a/src/ipy/IronPython/Runtime/Exceptions/ValueErrorException.cs b/src/ipy/IronPython/Runtime/Exceptions/ValueErrorException.cs index 65e91a4fc..9b86c8201 100644 --- a/src/ipy/IronPython/Runtime/Exceptions/ValueErrorException.cs +++ b/src/ipy/IronPython/Runtime/Exceptions/ValueErrorException.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Runtime.Serialization; - using Microsoft.Scripting.Runtime; namespace IronPython.Runtime.Exceptions { diff --git a/src/ipy/IronPython/Runtime/FunctionAttributes.cs b/src/ipy/IronPython/Runtime/FunctionAttributes.cs index 325c6831b..6ffc0c85b 100644 --- a/src/ipy/IronPython/Runtime/FunctionAttributes.cs +++ b/src/ipy/IronPython/Runtime/FunctionAttributes.cs @@ -7,11 +7,11 @@ namespace IronPython.Runtime { [Flags] public enum FunctionAttributes { - None = 0, + None = 0, /// /// Set if the function includes a *args argument list. /// - ArgumentList = 0x04, + ArgumentList = 0x04, /// /// Set if the function includes a **kwargs argument dictionary. /// diff --git a/src/ipy/IronPython/Runtime/FunctionCode.cs b/src/ipy/IronPython/Runtime/FunctionCode.cs index 406e7a072..bbaef9e05 100644 --- a/src/ipy/IronPython/Runtime/FunctionCode.cs +++ b/src/ipy/IronPython/Runtime/FunctionCode.cs @@ -2,26 +2,27 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; +using Microsoft.Scripting.Ast; + using System; using System.Collections.Generic; using System.Diagnostics; -using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Threading; -using IronPython.Compiler; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using Microsoft.Scripting; -using Microsoft.Scripting.Ast; using Microsoft.Scripting.Debugging.CompilerServices; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Interpreter; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Compiler; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + namespace IronPython.Runtime { /// /// Represents a piece of code. This can reference either a CompiledCode @@ -771,7 +772,7 @@ private LambdaExpression GetGeneratorOrNormalLambdaTracing(PythonContext context ); } - + /// /// Gets the correct final LambdaExpression for this piece of code. /// @@ -783,8 +784,8 @@ private LightLambdaExpression GetGeneratorOrNormalLambda() { finalCode = Code; } else { finalCode = Code.ToGenerator( - _lambda.ShouldInterpret, - _lambda.EmitDebugSymbols, + _lambda.ShouldInterpret, + _lambda.EmitDebugSymbols, _lambda.GlobalParent.PyContext.Options.CompilationThreshold ); } @@ -837,7 +838,7 @@ private Delegate CompileLambda(LambdaExpression code, EventHandler || + if (finalTarget is Func || finalTarget is Func || finalTarget is LookupCompilationDelegate) { // no recursion enforcement on classes or modules diff --git a/src/ipy/IronPython/Runtime/Generator.cs b/src/ipy/IronPython/Runtime/Generator.cs index e27a10a3a..b1210df4c 100644 --- a/src/ipy/IronPython/Runtime/Generator.cs +++ b/src/ipy/IronPython/Runtime/Generator.cs @@ -10,14 +10,14 @@ using System.Diagnostics; using System.Threading; +using Microsoft.Scripting; +using Microsoft.Scripting.Runtime; + using IronPython.Compiler; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting; -using Microsoft.Scripting.Runtime; - namespace IronPython.Runtime { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix"), PythonType("generator")] [DontMapIDisposableToContextManager, DontMapIEnumerableToContains] @@ -76,7 +76,7 @@ public object __next__() { if (Closed) { return LightExceptions.Throw(PythonOps.StopIteration()); } - + object res = NextWorker(); if (res == OperationFailed.Value) { if (FinalValue is null) @@ -365,7 +365,8 @@ private void SaveFunctionStack(bool done) { stack.RemoveAt(stack.Count - 1); Debug.Assert(functionStack.Context is not null); fnStack = new FunctionStack(functionStack.Context!, functionStack.Code); // don't keep the frame since f_back may be invalid - } else { + } + else { fnStack = null; } } diff --git a/src/ipy/IronPython/Runtime/GlobalDictionaryStorage.cs b/src/ipy/IronPython/Runtime/GlobalDictionaryStorage.cs index d17bfa980..6a31eaae6 100644 --- a/src/ipy/IronPython/Runtime/GlobalDictionaryStorage.cs +++ b/src/ipy/IronPython/Runtime/GlobalDictionaryStorage.cs @@ -4,13 +4,16 @@ #nullable enable +using System; using System.Collections.Generic; -using IronPython.Compiler; - +using Microsoft.Scripting; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime; +using IronPython.Compiler; + namespace IronPython.Runtime { internal class GlobalDictionaryStorage : CustomDictionaryStorage { private readonly Dictionary/*!*/ _globals; diff --git a/src/ipy/IronPython/Runtime/Implementation.cs b/src/ipy/IronPython/Runtime/Implementation.cs index 45f9f0732..cc244460f 100644 --- a/src/ipy/IronPython/Runtime/Implementation.cs +++ b/src/ipy/IronPython/Runtime/Implementation.cs @@ -3,8 +3,11 @@ // See the LICENSE file in the project root for more information. using System; +using System.Linq; using System.Reflection; +using IronPython.Runtime.Operations; + namespace IronPython.Runtime { [PythonType("sys.version_info")] public class VersionInfo : PythonTuple { diff --git a/src/ipy/IronPython/Runtime/Importer.cs b/src/ipy/IronPython/Runtime/Importer.cs index db81e4031..24b90ccd6 100644 --- a/src/ipy/IronPython/Runtime/Importer.cs +++ b/src/ipy/IronPython/Runtime/Importer.cs @@ -10,16 +10,16 @@ using System.Reflection; using System.Text; -using IronPython.Modules; -using IronPython.Runtime.Exceptions; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Modules; +using IronPython.Runtime.Exceptions; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + namespace IronPython.Runtime { /// @@ -576,7 +576,7 @@ private static object ImportTopAbsolute(CodeContext/*!*/ context, string/*!*/ na return ret; } - private static string[] SubArray(string[] t, int len) { + private static string [] SubArray(string[] t, int len) { var ret = new string[len]; Array.Copy(t, ret, len); return ret; @@ -914,7 +914,7 @@ internal static PythonModule LoadPackageFromSource(CodeContext/*!*/ context, str return null; } - if (context.LanguageContext.DomainManager.Platform.DirectoryExists(path) && !context.LanguageContext.DomainManager.Platform.FileExists(context.LanguageContext.DomainManager.Platform.CombinePaths(path, "__init__.py"))) { + if(context.LanguageContext.DomainManager.Platform.DirectoryExists(path) && !context.LanguageContext.DomainManager.Platform.FileExists(context.LanguageContext.DomainManager.Platform.CombinePaths(path, "__init__.py"))) { PythonOps.Warn(context, PythonExceptions.ImportWarning, "Not importing directory '{0}': missing __init__.py", path); } diff --git a/src/ipy/IronPython/Runtime/Index.cs b/src/ipy/IronPython/Runtime/Index.cs index 779854c43..34efd5270 100644 --- a/src/ipy/IronPython/Runtime/Index.cs +++ b/src/ipy/IronPython/Runtime/Index.cs @@ -1,4 +1,7 @@ -using Microsoft.Scripting.Utils; +using System; +using System.Collections.Generic; +using System.Text; +using Microsoft.Scripting.Utils; namespace IronPython.Runtime { /// diff --git a/src/ipy/IronPython/Runtime/InstancedModuleDictionaryStorage.cs b/src/ipy/IronPython/Runtime/InstancedModuleDictionaryStorage.cs index c48102122..d1682025c 100644 --- a/src/ipy/IronPython/Runtime/InstancedModuleDictionaryStorage.cs +++ b/src/ipy/IronPython/Runtime/InstancedModuleDictionaryStorage.cs @@ -2,8 +2,8 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; using System.Collections.Generic; - using IronPython.Compiler; namespace IronPython.Runtime { diff --git a/src/ipy/IronPython/Runtime/Interfaces.cs b/src/ipy/IronPython/Runtime/Interfaces.cs index 6593c587b..4f33ce05d 100644 --- a/src/ipy/IronPython/Runtime/Interfaces.cs +++ b/src/ipy/IronPython/Runtime/Interfaces.cs @@ -13,7 +13,7 @@ namespace IronPython.Runtime { public interface ICodeFormattable { string/*!*/ __repr__(CodeContext/*!*/ context); - } + } /// /// Defines the internal interface used for accessing weak references and adding finalizers diff --git a/src/ipy/IronPython/Runtime/MemoryStreamContentProvider.cs b/src/ipy/IronPython/Runtime/MemoryStreamContentProvider.cs index c72a95f65..4fd4e5704 100644 --- a/src/ipy/IronPython/Runtime/MemoryStreamContentProvider.cs +++ b/src/ipy/IronPython/Runtime/MemoryStreamContentProvider.cs @@ -4,7 +4,6 @@ using System; using System.IO; - using Microsoft.Scripting; using Microsoft.Scripting.Utils; diff --git a/src/ipy/IronPython/Runtime/MemoryView.cs b/src/ipy/IronPython/Runtime/MemoryView.cs index 958c398b7..ffd9bbaab 100644 --- a/src/ipy/IronPython/Runtime/MemoryView.cs +++ b/src/ipy/IronPython/Runtime/MemoryView.cs @@ -9,8 +9,8 @@ using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -using System.Linq; using System.Threading; +using System.Linq; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; @@ -57,7 +57,7 @@ public MemoryView([NotNone] IBufferProtocol @object) { ReadOnlySpan memblock = _buffer.AsReadOnlySpan(); - if ((_buffer.ItemCount != 0 && !VerifyStructure(memblock.Length, _buffer.ItemSize, _buffer.NumOfDims, _buffer.Shape, _buffer.Strides, _buffer.Offset)) + if ( (_buffer.ItemCount != 0 && !VerifyStructure(memblock.Length, _buffer.ItemSize, _buffer.NumOfDims, _buffer.Shape, _buffer.Strides, _buffer.Offset)) || (_buffer.Shape == null && (_buffer.Offset != 0 || _buffer.NumBytes() != memblock.Length)) ) { throw PythonOps.BufferError("memoryview: invalid buffer exported from object of type {0}", PythonOps.GetPythonTypeName(@object)); @@ -100,19 +100,19 @@ public MemoryView([NotNone] IBufferProtocol @object) { } public MemoryView([NotNone] MemoryView @object) { - _exporter = @object._exporter; - _flags = BufferFlags.RecordsRO; - _buffer = _exporter.GetBuffer(_flags); - _offset = @object._offset; - _isReadOnly = @object._isReadOnly; - _numDims = @object._numDims; - _format = @object._format; - _itemSize = @object._itemSize; - _shape = @object._shape; - _strides = @object._strides; - _isCContig = @object._isCContig; - _isFContig = @object._isFContig; - _numItems = @object._numItems; + _exporter = @object._exporter; + _flags = BufferFlags.RecordsRO; + _buffer = _exporter.GetBuffer(_flags); + _offset = @object._offset; + _isReadOnly = @object._isReadOnly; + _numDims = @object._numDims; + _format = @object._format; + _itemSize = @object._itemSize; + _shape = @object._shape; + _strides = @object._strides; + _isCContig = @object._isCContig; + _isFContig = @object._isFContig; + _numItems = @object._numItems; } internal MemoryView(IBufferProtocol @object, bool readOnly) : this(@object) { @@ -180,7 +180,7 @@ private MemoryView(MemoryView @object, BufferFlags flags) : this(@object) { if (_buffer != null) { _buffer.Dispose(); } - } catch { } + } catch {} } [MemberNotNull(nameof(_buffer))] @@ -385,7 +385,8 @@ public string hex() { if (_isCContig) { return Bytes.ToHex(_buffer.AsReadOnlySpan().Slice(_offset, _numItems * _itemSize)); - } else { + } + else { var builder = new System.Text.StringBuilder(_numItems * _itemSize * 2); foreach (byte b in this.EnumerateBytes()) { builder.Append(ToAscii(b >> 4)); @@ -446,7 +447,7 @@ public MemoryView cast([NotNone] string format) { return cast(format, null); } - public MemoryView cast([NotNone] string format, [NotNone, AllowNull] object shape) { + public MemoryView cast([NotNone] string format, [NotNone, AllowNull]object shape) { if (!_isCContig) { throw PythonOps.TypeError("memoryview: casts are restricted to C-contiguous views"); } @@ -474,7 +475,7 @@ public MemoryView cast([NotNone] string format, [NotNone, AllowNull] object shap } } - if (!TypecodeOps.TryDecomposeTypecode(format, out char byteorder, out char typecode) + if ( !TypecodeOps.TryDecomposeTypecode(format, out char byteorder, out char typecode) || !IsSupportedTypecode(typecode) || byteorder != '@' ) { diff --git a/src/ipy/IronPython/Runtime/Method.cs b/src/ipy/IronPython/Runtime/Method.cs index 390a0aa38..83e3dfaca 100644 --- a/src/ipy/IronPython/Runtime/Method.cs +++ b/src/ipy/IronPython/Runtime/Method.cs @@ -8,12 +8,12 @@ using System.Linq.Expressions; using System.Runtime.CompilerServices; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using Microsoft.Scripting; using Microsoft.Scripting.Runtime; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + namespace IronPython.Runtime { [PythonType("method"), DontMapGetMemberNamesToDir] public sealed partial class Method : PythonTypeSlot, IWeakReferenceable, IPythonMembersList, IDynamicMetaObjectProvider, ICodeFormattable, Binding.IFastInvokable { @@ -49,7 +49,7 @@ public object Call(CodeContext/*!*/ context, params object[] args) => context.LanguageContext.CallSplat(this, args); [SpecialName] - public object Call(CodeContext/*!*/ context, [ParamDictionary] IDictionary kwArgs, params object[] args) + public object Call(CodeContext/*!*/ context, [ParamDictionary]IDictionary kwArgs, params object[] args) => context.LanguageContext.CallWithKeywords(this, args, kwArgs); #region Object Overrides @@ -117,11 +117,11 @@ IList IPythonMembersList.GetMemberNames(CodeContext/*!*/ context) { if (__func__ is PythonFunction pf) { PythonDictionary dict = pf.__dict__; - + // Check the func foreach (KeyValuePair kvp in dict) { ret.AddNoLockNoDups(kvp.Key); - } + } } return ret; diff --git a/src/ipy/IronPython/Runtime/ModuleContext.cs b/src/ipy/IronPython/Runtime/ModuleContext.cs index 45d2db2be..db8c00430 100644 --- a/src/ipy/IronPython/Runtime/ModuleContext.cs +++ b/src/ipy/IronPython/Runtime/ModuleContext.cs @@ -2,8 +2,8 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; using System.Diagnostics; - using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; diff --git a/src/ipy/IronPython/Runtime/ModuleDictionaryStorage.cs b/src/ipy/IronPython/Runtime/ModuleDictionaryStorage.cs index ad22a86e8..e4a7887ee 100644 --- a/src/ipy/IronPython/Runtime/ModuleDictionaryStorage.cs +++ b/src/ipy/IronPython/Runtime/ModuleDictionaryStorage.cs @@ -6,10 +6,8 @@ using System.Collections.Generic; using System.Diagnostics; using System.Reflection; - using IronPython.Compiler; using IronPython.Runtime.Types; - using Microsoft.Scripting.Actions; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; @@ -219,7 +217,7 @@ public override bool TryGetValue(object key, out object value) { return value != Uninitialized.Instance; } - if (key is string strKey) { + if(key is string strKey) { return TryGetLazyValue(strKey, out value); } diff --git a/src/ipy/IronPython/Runtime/ModuleGlobalCache.cs b/src/ipy/IronPython/Runtime/ModuleGlobalCache.cs index aa2a406e4..f6c55203a 100644 --- a/src/ipy/IronPython/Runtime/ModuleGlobalCache.cs +++ b/src/ipy/IronPython/Runtime/ModuleGlobalCache.cs @@ -2,13 +2,14 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; using System.Diagnostics; -using IronPython.Runtime.Exceptions; - using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Exceptions; + namespace IronPython.Runtime { /// /// Cached global value. Created and maintained on a per-language basis. Default diff --git a/src/ipy/IronPython/Runtime/ModuleLoader.cs b/src/ipy/IronPython/Runtime/ModuleLoader.cs index 7a214e8db..3966d0157 100644 --- a/src/ipy/IronPython/Runtime/ModuleLoader.cs +++ b/src/ipy/IronPython/Runtime/ModuleLoader.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; +using Microsoft.Scripting; using IronPython.Compiler; namespace IronPython.Runtime { diff --git a/src/ipy/IronPython/Runtime/ModuleOptions.cs b/src/ipy/IronPython/Runtime/ModuleOptions.cs index 1ab443470..9d051028c 100644 --- a/src/ipy/IronPython/Runtime/ModuleOptions.cs +++ b/src/ipy/IronPython/Runtime/ModuleOptions.cs @@ -3,6 +3,8 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; +using System.Text; namespace IronPython.Runtime { [Flags] diff --git a/src/ipy/IronPython/Runtime/NewStringFormatter.cs b/src/ipy/IronPython/Runtime/NewStringFormatter.cs index 00117b00c..84ca824ab 100644 --- a/src/ipy/IronPython/Runtime/NewStringFormatter.cs +++ b/src/ipy/IronPython/Runtime/NewStringFormatter.cs @@ -6,12 +6,12 @@ using System.Collections.Generic; using System.Text; -using IronPython.Modules; -using IronPython.Runtime.Operations; - using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Modules; +using IronPython.Runtime.Operations; + namespace IronPython.Runtime { /// /// New string formatter for 'str'.format(...) calls and support for the Formatter diff --git a/src/ipy/IronPython/Runtime/ObjectAttributesAdapter.cs b/src/ipy/IronPython/Runtime/ObjectAttributesAdapter.cs index f01d56111..d5c267d75 100644 --- a/src/ipy/IronPython/Runtime/ObjectAttributesAdapter.cs +++ b/src/ipy/IronPython/Runtime/ObjectAttributesAdapter.cs @@ -6,11 +6,10 @@ using System.Collections; using System.Collections.Generic; - using IronPython.Runtime.Operations; namespace IronPython.Runtime { - internal class ObjectAttributesAdapter : DictionaryStorage { + internal class ObjectAttributesAdapter : DictionaryStorage { private readonly object _backing; private readonly CodeContext/*!*/ _context; @@ -56,7 +55,7 @@ public override bool TryGetValue(object? key, out object? value) { } public override int Count { - get { return PythonOps.Length(_backing); } + get { return PythonOps.Length(_backing); } } public override void Clear(ref DictionaryStorage storage) { diff --git a/src/ipy/IronPython/Runtime/ObjectDebugView.cs b/src/ipy/IronPython/Runtime/ObjectDebugView.cs index 0cc08640a..803cf391d 100644 --- a/src/ipy/IronPython/Runtime/ObjectDebugView.cs +++ b/src/ipy/IronPython/Runtime/ObjectDebugView.cs @@ -2,8 +2,10 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; +using System.Collections.Generic; +using System.Text; using System.Diagnostics; - using IronPython.Runtime.Operations; namespace IronPython.Runtime { diff --git a/src/ipy/IronPython/Runtime/Operations/ArrayOps.cs b/src/ipy/IronPython/Runtime/Operations/ArrayOps.cs index ecfa9b46b..f80cd9734 100644 --- a/src/ipy/IronPython/Runtime/Operations/ArrayOps.cs +++ b/src/ipy/IronPython/Runtime/Operations/ArrayOps.cs @@ -10,11 +10,11 @@ using System.Diagnostics; using System.Text; -using IronPython.Runtime.Types; - using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Types; + using SpecialNameAttribute = System.Runtime.CompilerServices.SpecialNameAttribute; namespace IronPython.Runtime.Operations { diff --git a/src/ipy/IronPython/Runtime/Operations/BigIntegerOps.cs b/src/ipy/IronPython/Runtime/Operations/BigIntegerOps.cs index 59099a442..6ed328bf2 100644 --- a/src/ipy/IronPython/Runtime/Operations/BigIntegerOps.cs +++ b/src/ipy/IronPython/Runtime/Operations/BigIntegerOps.cs @@ -5,6 +5,7 @@ #nullable enable using System; +using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; @@ -13,32 +14,12 @@ using System.Runtime.CompilerServices; using System.Text; - -/* Unmerged change from project 'IronPython (net6.0)' -Before: using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using IronPython.Runtime.Exceptions; -After: -using IronPython.Runtime.Exceptions; -*/ using IronPython.Runtime.Exceptions; using IronPython.Runtime.Types; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - - -/* Unmerged change from project 'IronPython (net6.0)' -Before: -namespace IronPython.Runtime.Operations { -After: -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - -namespace IronPython.Runtime.Operations { -*/ namespace IronPython.Runtime.Operations { public static partial class BigIntegerOps { @@ -776,7 +757,8 @@ public static BigInteger ToBigInteger(BigInteger self) { if (spec.Fill == '0' && spec.Width > 1) { digits = FormattingHelper.ToCultureString(val, culture.NumberFormat, spec, (spec.Sign != null && spec.Sign != '-' || self < 0) ? spec.Width - 1 : null); - } else { + } + else { digits = FormattingHelper.ToCultureString(val, culture.NumberFormat, spec); } break; @@ -843,7 +825,7 @@ public static BigInteger ToBigInteger(BigInteger self) { int iVal; if (!self.AsInt32(out iVal)) { throw PythonOps.OverflowError("Python int too large to convert to System.Int32"); - } else if (iVal < 0 || iVal > 0x10ffff) { + } else if(iVal < 0 || iVal > 0x10ffff) { throw PythonOps.OverflowError("%c arg not in range(0x110000)"); } @@ -871,7 +853,7 @@ public static Bytes to_bytes(BigInteger value, int length, [NotNone] string byte #if NETCOREAPP var bytes = new byte[length]; - int start = isLittle ? 0 : length - value.GetByteCount(isUnsigned: !signed); + int start = isLittle? 0 : length - value.GetByteCount(isUnsigned: !signed); if (start < 0) ThrowOverflow(); if (!value.TryWriteBytes(bytes.AsSpan(start), out int written, isUnsigned: !signed, isBigEndian: !isLittle)) { ThrowOverflow(); diff --git a/src/ipy/IronPython/Runtime/Operations/BoolOps.cs b/src/ipy/IronPython/Runtime/Operations/BoolOps.cs index 848d2772b..9654968e3 100644 --- a/src/ipy/IronPython/Runtime/Operations/BoolOps.cs +++ b/src/ipy/IronPython/Runtime/Operations/BoolOps.cs @@ -6,7 +6,6 @@ using System.Numerics; using Microsoft.Scripting.Runtime; - using SpecialNameAttribute = System.Runtime.CompilerServices.SpecialNameAttribute; namespace IronPython.Runtime.Operations { @@ -27,7 +26,7 @@ public static bool __new__(object cls, object o) { public static bool BitwiseAnd(bool x, bool y) { return x & y; } - + [SpecialName] public static bool BitwiseOr(bool x, bool y) { return x | y; diff --git a/src/ipy/IronPython/Runtime/Operations/ByteOps.cs b/src/ipy/IronPython/Runtime/Operations/ByteOps.cs index 05f7882d6..50418728b 100644 --- a/src/ipy/IronPython/Runtime/Operations/ByteOps.cs +++ b/src/ipy/IronPython/Runtime/Operations/ByteOps.cs @@ -7,8 +7,11 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using System.Numerics; +using Microsoft.Scripting.Utils; + namespace IronPython.Runtime.Operations { public static partial class ByteOps { internal static byte ToByteChecked(this int item) { diff --git a/src/ipy/IronPython/Runtime/Operations/CharOps.cs b/src/ipy/IronPython/Runtime/Operations/CharOps.cs index 700bbc4be..10e76d84d 100644 --- a/src/ipy/IronPython/Runtime/Operations/CharOps.cs +++ b/src/ipy/IronPython/Runtime/Operations/CharOps.cs @@ -6,9 +6,8 @@ using System.Runtime.CompilerServices; -using IronPython.Runtime.Types; - using Microsoft.Scripting.Runtime; +using IronPython.Runtime.Types; namespace IronPython.Runtime.Operations { diff --git a/src/ipy/IronPython/Runtime/Operations/DBNullOps.cs b/src/ipy/IronPython/Runtime/Operations/DBNullOps.cs index a46f9ca39..f2b1628b7 100644 --- a/src/ipy/IronPython/Runtime/Operations/DBNullOps.cs +++ b/src/ipy/IronPython/Runtime/Operations/DBNullOps.cs @@ -15,7 +15,7 @@ public static object __new__(object cls) { return DBNull.Value; } - public static bool __bool__(DBNull value) { + public static bool __bool__(DBNull value) { return false; } } diff --git a/src/ipy/IronPython/Runtime/Operations/DelegateOps.cs b/src/ipy/IronPython/Runtime/Operations/DelegateOps.cs index 30fe2b9cc..90376973e 100644 --- a/src/ipy/IronPython/Runtime/Operations/DelegateOps.cs +++ b/src/ipy/IronPython/Runtime/Operations/DelegateOps.cs @@ -7,12 +7,12 @@ using System; using System.Collections.Generic; -using IronPython.Runtime.Types; - using Microsoft.Scripting; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Types; + namespace IronPython.Runtime.Operations { public static class DelegateOps { @@ -48,7 +48,7 @@ public static object Call(CodeContext/*!*/ context, Delegate @delegate, params o return context.LanguageContext.CallSplat(@delegate, args); } - public static object Call(CodeContext/*!*/ context, Delegate @delegate, [ParamDictionary] IDictionary dict, params object[] args) { + public static object Call(CodeContext/*!*/ context, Delegate @delegate, [ParamDictionary]IDictionary dict, params object[] args) { return context.LanguageContext.CallWithKeywords(@delegate, args, dict); } diff --git a/src/ipy/IronPython/Runtime/Operations/EnumOps.cs b/src/ipy/IronPython/Runtime/Operations/EnumOps.cs index 5eab047ca..6c0085772 100644 --- a/src/ipy/IronPython/Runtime/Operations/EnumOps.cs +++ b/src/ipy/IronPython/Runtime/Operations/EnumOps.cs @@ -44,7 +44,7 @@ public static object ExclusiveOr(object self, object other) { } [SpecialName] - public static object OnesComplement(object self) { + public static object OnesComplement(object self) { object result = EnumUtils.OnesComplement(self); if (result != null) { return result; diff --git a/src/ipy/IronPython/Runtime/Operations/FloatOps.cs b/src/ipy/IronPython/Runtime/Operations/FloatOps.cs index 5e182dc6e..fa02bc04e 100644 --- a/src/ipy/IronPython/Runtime/Operations/FloatOps.cs +++ b/src/ipy/IronPython/Runtime/Operations/FloatOps.cs @@ -869,7 +869,7 @@ internal static string DoubleToFormatString(CodeContext/*!*/ context, double sel // only have as single digit avoid exponents. if (digitCnt > spec.Precision.Value && digitCnt != 1) { // first round off the decimal value - self = MathUtils.Round(self, 0, MidpointRounding.ToEven); + self = MathUtils.Round(self, 0 , MidpointRounding.ToEven); // then remove any insignificant digits double pow = Math.Pow(10, digitCnt - Math.Max(spec.Precision.Value, 1)); @@ -1043,7 +1043,7 @@ public static double __round__(double self, int ndigits) { } var result = MathUtils.Round(self, ndigits, MidpointRounding.ToEven); - + if (double.IsInfinity(result)) { throw PythonOps.OverflowError("rounded value too large to represent"); } @@ -1065,7 +1065,8 @@ public static double __round__(double self, BigInteger ndigits) { public static double __round__(double self, object ndigits) { var index = PythonOps.Index(ndigits); - switch (index) { + switch (index) + { case int i: return __round__(self, i); diff --git a/src/ipy/IronPython/Runtime/Operations/IListOfByteOps.cs b/src/ipy/IronPython/Runtime/Operations/IListOfByteOps.cs index 9499a4b3e..b43e26195 100644 --- a/src/ipy/IronPython/Runtime/Operations/IListOfByteOps.cs +++ b/src/ipy/IronPython/Runtime/Operations/IListOfByteOps.cs @@ -52,7 +52,7 @@ internal static bool EndsWith(this IList self, IList suffix) { internal static bool EndsWith(this IList self, IList suffix, int start, int end) { int len = self.Count; - if (!PythonOps.TryFixSubsequenceIndices(len, ref start, ref end)) { + if(!PythonOps.TryFixSubsequenceIndices(len, ref start, ref end)) { return false; } @@ -305,7 +305,7 @@ internal static bool StartsWith(this IList self, IList prefix) { internal static bool StartsWith(this IList self, IList prefix, int start, int end) { int len = self.Count; - if (!PythonOps.TryFixSubsequenceIndices(len, ref start, ref end)) { + if(!PythonOps.TryFixSubsequenceIndices(len, ref start, ref end)) { return false; } @@ -638,7 +638,8 @@ internal static List Translate(this IList bytes, IList? table, if (b != t) changed = true; res.Add(t); } - } else { + } + else { changed = true; } } diff --git a/src/ipy/IronPython/Runtime/Operations/InstanceOps.cs b/src/ipy/IronPython/Runtime/Operations/InstanceOps.cs index 31387f47e..2b6c6578f 100644 --- a/src/ipy/IronPython/Runtime/Operations/InstanceOps.cs +++ b/src/ipy/IronPython/Runtime/Operations/InstanceOps.cs @@ -2,21 +2,23 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Dynamic; -using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; -using IronPython.Runtime.Types; - using Microsoft.Scripting; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Exceptions; +using IronPython.Runtime.Types; + namespace IronPython.Runtime.Operations { /// /// InstanceOps contains methods that get added to CLS types depending on what @@ -105,7 +107,7 @@ public static object DefaultNew(CodeContext context, PythonType type\u00F8, para return type\u00F8.CreateInstance(context); } - public static object DefaultNewClsKW(CodeContext context, PythonType type\u00F8, [ParamDictionary] IDictionary kwargs\u00F8, params object[] args\u00F8) { + public static object DefaultNewClsKW(CodeContext context, PythonType type\u00F8, [ParamDictionary]IDictionary kwargs\u00F8, params object[] args\u00F8) { object res = DefaultNew(context, type\u00F8, args\u00F8); if (kwargs\u00F8.Count > 0) { @@ -125,13 +127,13 @@ public static object OverloadedNewBasic(CodeContext context, SiteLocalStorage kwargs\u00F8) { + public static object OverloadedNewKW(CodeContext context, BuiltinFunction overloads\u00F8, PythonType type\u00F8, [ParamDictionary]IDictionary kwargs\u00F8) { if (type\u00F8 == null) throw PythonOps.TypeError("__new__ expected type object, got {0}", PythonOps.Repr(context, DynamicHelpers.GetPythonType(type\u00F8))); return overloads\u00F8.Call(context, null, null, ArrayUtils.EmptyObjects, kwargs\u00F8); } - public static object OverloadedNewClsKW(CodeContext context, BuiltinFunction overloads\u00F8, PythonType type\u00F8, [ParamDictionary] IDictionary kwargs\u00F8, params object[] args\u00F8) { + public static object OverloadedNewClsKW(CodeContext context, BuiltinFunction overloads\u00F8, PythonType type\u00F8, [ParamDictionary]IDictionary kwargs\u00F8, params object[] args\u00F8) { if (type\u00F8 == null) throw PythonOps.TypeError("__new__ expected type object, got {0}", PythonOps.Repr(context, DynamicHelpers.GetPythonType(type\u00F8))); if (args\u00F8 == null) args\u00F8 = new object[1]; @@ -143,7 +145,7 @@ public static void DefaultInit(CodeContext context, object self, params object[] } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "self"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "kwargs\u00F8"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "context"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "args\u00F8")] - public static void DefaultInitKW(CodeContext context, object self, [ParamDictionary] IDictionary kwargs\u00F8, params object[] args\u00F8) { + public static void DefaultInitKW(CodeContext context, object self, [ParamDictionary]IDictionary kwargs\u00F8, params object[] args\u00F8) { } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "context")] @@ -156,18 +158,18 @@ public static object NonDefaultNew(CodeContext context, PythonType type\u00F8, p [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "context")] [StaticExtensionMethod] - public static object NonDefaultNewKW(CodeContext context, PythonType type\u00F8, [ParamDictionary] IDictionary kwargs\u00F8, params object[] args\u00F8) { + public static object NonDefaultNewKW(CodeContext context, PythonType type\u00F8, [ParamDictionary]IDictionary kwargs\u00F8, params object[] args\u00F8) { if (type\u00F8 == null) throw PythonOps.TypeError("__new__ expected type object, got {0}", PythonOps.Repr(context, DynamicHelpers.GetPythonType(type\u00F8))); if (args\u00F8 == null) args\u00F8 = new object[1]; - string[] names; + string []names; GetKeywordArgs(kwargs\u00F8, args\u00F8, out args\u00F8, out names); return type\u00F8.CreateInstance(context, args\u00F8, names); } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "context")] [StaticExtensionMethod] - public static object NonDefaultNewKWNoParams(CodeContext context, PythonType type\u00F8, [ParamDictionary] IDictionary kwargs\u00F8) { + public static object NonDefaultNewKWNoParams(CodeContext context, PythonType type\u00F8, [ParamDictionary]IDictionary kwargs\u00F8) { if (type\u00F8 == null) throw PythonOps.TypeError("__new__ expected type object, got {0}", PythonOps.Repr(context, DynamicHelpers.GetPythonType(type\u00F8))); string[] names; diff --git a/src/ipy/IronPython/Runtime/Operations/IntOps.cs b/src/ipy/IronPython/Runtime/Operations/IntOps.cs index 156680e64..075e0bd41 100644 --- a/src/ipy/IronPython/Runtime/Operations/IntOps.cs +++ b/src/ipy/IronPython/Runtime/Operations/IntOps.cs @@ -10,11 +10,11 @@ using System.Numerics; using System.Text; -using IronPython.Runtime.Types; - using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Types; + using SpecialNameAttribute = System.Runtime.CompilerServices.SpecialNameAttribute; namespace IronPython.Runtime.Operations { diff --git a/src/ipy/IronPython/Runtime/Operations/MarshalOps.cs b/src/ipy/IronPython/Runtime/Operations/MarshalOps.cs index 90f4853cf..5c043c803 100644 --- a/src/ipy/IronPython/Runtime/Operations/MarshalOps.cs +++ b/src/ipy/IronPython/Runtime/Operations/MarshalOps.cs @@ -10,15 +10,15 @@ namespace IronPython.Runtime.Operations { public class MarshalOps { - public static byte[] GetBytes(object o, int version) { - MarshalWriter mw = new MarshalWriter(version); - mw.WriteObject(o); - return mw.GetBytes(); + public static byte[] GetBytes (object o, int version) { + MarshalWriter mw = new MarshalWriter (version); + mw.WriteObject (o); + return mw.GetBytes (); } - public static object GetObject(IEnumerator bytes) { - MarshalReader mr = new MarshalReader(bytes); - return mr.ReadObject(); + public static object GetObject (IEnumerator bytes) { + MarshalReader mr = new MarshalReader (bytes); + return mr.ReadObject (); } @@ -56,75 +56,75 @@ private class MarshalWriter { private readonly int _version; private readonly Dictionary _strings; - public MarshalWriter(int version) { - _bytes = new List(); + public MarshalWriter (int version) { + _bytes = new List (); _version = version; if (_version > 0) { - _strings = new Dictionary(); + _strings = new Dictionary (); } } - public void WriteObject(object o) { - List infinite = PythonOps.GetReprInfinite(); + public void WriteObject (object o) { + List infinite = PythonOps.GetReprInfinite (); - if (infinite.Contains(o)) throw PythonOps.ValueError("Marshaled data contains infinite cycle"); + if (infinite.Contains (o)) throw PythonOps.ValueError ("Marshaled data contains infinite cycle"); int index = infinite.Count; - infinite.Add(o); + infinite.Add (o); try { - if (o == null) _bytes.Add((byte)'N'); - else if (o == ScriptingRuntimeHelpers.True || (o is bool && (bool)o)) _bytes.Add((byte)'T'); - else if (o == ScriptingRuntimeHelpers.False || (o is bool && (!(bool)o))) _bytes.Add((byte)'F'); + if (o == null) _bytes.Add ((byte)'N'); + else if (o == ScriptingRuntimeHelpers.True || (o is bool && (bool)o)) _bytes.Add ((byte)'T'); + else if (o == ScriptingRuntimeHelpers.False || (o is bool && (!(bool)o))) _bytes.Add ((byte)'F'); else if (o is IBufferProtocol) WriteBufferProtocol((IBufferProtocol)o); else if (o is string) WriteString(o as string); - else if (o is int) WriteInt((int)o); - else if (o is float) WriteFloat((float)o); - else if (o is double) WriteFloat((double)o); - else if (o is long) WriteLong((long)o); - else if (o.GetType() == typeof(PythonList)) WriteList(o); - else if (o.GetType() == typeof(PythonDictionary)) WriteDict(o); - else if (o.GetType() == typeof(PythonTuple)) WriteTuple(o); - else if (o.GetType() == typeof(SetCollection)) WriteSet(o); - else if (o.GetType() == typeof(FrozenSetCollection)) WriteFrozenSet(o); - else if (o is BigInteger) WriteInteger((BigInteger)o); - else if (o is Complex) WriteComplex((Complex)o); - else if (o == PythonExceptions.StopIteration) WriteStopIteration(); - else throw PythonOps.ValueError("unmarshallable object " + o.GetType().ToString()); + else if (o is int) WriteInt ((int)o); + else if (o is float) WriteFloat ((float)o); + else if (o is double) WriteFloat ((double)o); + else if (o is long) WriteLong ((long)o); + else if (o.GetType () == typeof (PythonList)) WriteList (o); + else if (o.GetType () == typeof (PythonDictionary)) WriteDict (o); + else if (o.GetType () == typeof (PythonTuple)) WriteTuple (o); + else if (o.GetType () == typeof (SetCollection)) WriteSet (o); + else if (o.GetType () == typeof (FrozenSetCollection)) WriteFrozenSet (o); + else if (o is BigInteger) WriteInteger ((BigInteger)o); + else if (o is Complex) WriteComplex ((Complex)o); + else if (o == PythonExceptions.StopIteration) WriteStopIteration (); + else throw PythonOps.ValueError ("unmarshallable object " + o.GetType().ToString()); } finally { - infinite.RemoveAt(index); + infinite.RemoveAt (index); } } - private void WriteFloat(float f) { + private void WriteFloat (float f) { if (_version > 1) { - _bytes.Add((byte)'g'); - _bytes.AddRange(BitConverter.GetBytes((double)f)); + _bytes.Add ((byte)'g'); + _bytes.AddRange (BitConverter.GetBytes ((double)f)); } else { - _bytes.Add((byte)'f'); - WriteDoubleString(f); + _bytes.Add ((byte)'f'); + WriteDoubleString (f); } } - private void WriteFloat(double f) { + private void WriteFloat (double f) { if (_version > 1) { - _bytes.Add((byte)'g'); - _bytes.AddRange(BitConverter.GetBytes(f)); + _bytes.Add ((byte)'g'); + _bytes.AddRange (BitConverter.GetBytes (f)); } else { - _bytes.Add((byte)'f'); - WriteDoubleString(f); + _bytes.Add ((byte)'f'); + WriteDoubleString (f); } } - private void WriteDoubleString(double d) { - string s = DoubleOps.__repr__(DefaultContext.Default, d); - _bytes.Add((byte)s.Length); + private void WriteDoubleString (double d) { + string s = DoubleOps.__repr__ (DefaultContext.Default, d); + _bytes.Add ((byte)s.Length); for (int i = 0; i < s.Length; i++) { - _bytes.Add((byte)s[i]); + _bytes.Add ((byte)s[i]); } } - private void WriteInteger(BigInteger val) { - _bytes.Add((byte)'l'); + private void WriteInteger (BigInteger val) { + _bytes.Add ((byte)'l'); int wordCount = 0, dir; if (val < BigInteger.Zero) { val *= -1; @@ -133,50 +133,50 @@ private void WriteInteger(BigInteger val) { dir = 1; } - List bytes = new List(); + List bytes = new List (); while (val != BigInteger.Zero) { int word = (int)(val & 0x7FFF); val = val >> 15; - bytes.Add((byte)(word & 0xFF)); - bytes.Add((byte)((word >> 8) & 0xFF)); + bytes.Add ((byte)(word & 0xFF)); + bytes.Add ((byte)((word >> 8) & 0xFF)); wordCount += dir; } - WriteInt32(wordCount); + WriteInt32 (wordCount); - _bytes.AddRange(bytes); + _bytes.AddRange (bytes); } - private void WriteLong(long l) { - _bytes.Add((byte)'I'); + private void WriteLong (long l) { + _bytes.Add ((byte)'I'); for (int i = 0; i < 8; i++) { - _bytes.Add((byte)(l & 0xff)); + _bytes.Add ((byte)(l & 0xff)); l = l >> 8; } } - private void WriteComplex(Complex val) { - _bytes.Add((byte)'x'); - WriteDoubleString(val.Real); - WriteDoubleString(val.Imaginary); + private void WriteComplex (Complex val) { + _bytes.Add ((byte)'x'); + WriteDoubleString (val.Real); + WriteDoubleString (val.Imaginary); } - private void WriteStopIteration() { - _bytes.Add((byte)'S'); + private void WriteStopIteration () { + _bytes.Add ((byte)'S'); } - private void WriteInt(int val) { - _bytes.Add((byte)'i'); - WriteInt32(val); + private void WriteInt (int val) { + _bytes.Add ((byte)'i'); + WriteInt32 (val); } - private void WriteInt32(int val) { - _bytes.Add((byte)(val & 0xff)); - _bytes.Add((byte)((val >> 8) & 0xff)); - _bytes.Add((byte)((val >> 16) & 0xff)); - _bytes.Add((byte)((val >> 24) & 0xff)); + private void WriteInt32 (int val) { + _bytes.Add ((byte)(val & 0xff)); + _bytes.Add ((byte)((val >> 8) & 0xff)); + _bytes.Add ((byte)((val >> 16) & 0xff)); + _bytes.Add ((byte)((val >> 24) & 0xff)); } private void WriteBufferProtocol(IBufferProtocol b) { @@ -195,55 +195,55 @@ private void WriteString(string s) { _bytes.AddRange(utfBytes); } - private void WriteList(object o) { + private void WriteList (object o) { PythonList l = o as PythonList; - _bytes.Add((byte)'['); - WriteInt32(l.__len__()); - for (int i = 0; i < l.__len__(); i++) { - WriteObject(l[i]); + _bytes.Add ((byte)'['); + WriteInt32 (l.__len__ ()); + for (int i = 0; i < l.__len__ (); i++) { + WriteObject (l[i]); } } - private void WriteDict(object o) { + private void WriteDict (object o) { PythonDictionary d = o as PythonDictionary; - _bytes.Add((byte)'{'); - IEnumerator> ie = ((IEnumerable>)d).GetEnumerator(); - while (ie.MoveNext()) { - WriteObject(ie.Current.Key); - WriteObject(ie.Current.Value); + _bytes.Add ((byte)'{'); + IEnumerator> ie = ((IEnumerable>)d).GetEnumerator (); + while (ie.MoveNext ()) { + WriteObject (ie.Current.Key); + WriteObject (ie.Current.Value); } - _bytes.Add((byte)'0'); + _bytes.Add ((byte)'0'); } - private void WriteTuple(object o) { + private void WriteTuple (object o) { PythonTuple t = o as PythonTuple; - _bytes.Add((byte)'('); - WriteInt32(t.__len__()); - for (int i = 0; i < t.__len__(); i++) { - WriteObject(t[i]); + _bytes.Add ((byte)'('); + WriteInt32 (t.__len__ ()); + for (int i = 0; i < t.__len__ (); i++) { + WriteObject (t[i]); } } - private void WriteSet(object set) { + private void WriteSet (object set) { SetCollection s = set as SetCollection; - _bytes.Add((byte)'<'); - WriteInt32(s.__len__()); + _bytes.Add ((byte)'<'); + WriteInt32 (s.__len__ ()); foreach (object o in s) { - WriteObject(o); + WriteObject (o); } } - private void WriteFrozenSet(object set) { + private void WriteFrozenSet (object set) { FrozenSetCollection s = set as FrozenSetCollection; - _bytes.Add((byte)'>'); - WriteInt32(s.__len__()); + _bytes.Add ((byte)'>'); + WriteInt32 (s.__len__ ()); foreach (object o in s) { - WriteObject(o); + WriteObject (o); } } - public byte[] GetBytes() { - return _bytes.ToArray(); + public byte[] GetBytes () { + return _bytes.ToArray (); } } @@ -253,37 +253,37 @@ private class MarshalReader { private readonly Dictionary _strings; private object _result; - public MarshalReader(IEnumerator bytes) { + public MarshalReader (IEnumerator bytes) { _myBytes = bytes; - _strings = new Dictionary(); + _strings = new Dictionary (); } - public object ReadObject() { - while (_myBytes.MoveNext()) { + public object ReadObject () { + while (_myBytes.MoveNext ()) { byte cur = _myBytes.Current; object res; switch ((char)cur) { - case '(': PushStack(StackType.Tuple); break; - case '[': PushStack(StackType.List); break; - case '{': PushStack(StackType.Dict); break; - case '<': PushStack(StackType.Set); break; - case '>': PushStack(StackType.FrozenSet); break; + case '(': PushStack (StackType.Tuple); break; + case '[': PushStack (StackType.List); break; + case '{': PushStack (StackType.Dict); break; + case '<': PushStack (StackType.Set); break; + case '>': PushStack (StackType.FrozenSet); break; case '0': // end of dictionary if (_stack == null || _stack.Count == 0) { - throw PythonOps.ValueError("bad marshal data"); + throw PythonOps.ValueError ("bad marshal data"); } - _stack.Peek().StackCount = 0; + _stack.Peek ().StackCount = 0; break; // case 'c': break; default: - res = YieldSimple(); + res = YieldSimple (); if (_stack == null) { return res; } do { - res = UpdateStack(res); + res = UpdateStack (res); } while (res != null && _stack.Count > 0); if (_stack.Count == 0) { @@ -294,8 +294,8 @@ public object ReadObject() { } // handle empty lists/tuples... - if (_stack != null && _stack.Count > 0 && _stack.Peek().StackCount == 0) { - ProcStack ps = _stack.Pop(); + if (_stack != null && _stack.Count > 0 && _stack.Peek ().StackCount == 0) { + ProcStack ps = _stack.Pop (); res = ps.StackObj; if (ps.StackType == StackType.Tuple) { @@ -307,7 +307,7 @@ public object ReadObject() { if (_stack.Count > 0) { // empty list/tuple do { - res = UpdateStack(res); + res = UpdateStack (res); } while (res != null && _stack.Count > 0); if (_stack.Count == 0) break; } else { @@ -320,40 +320,40 @@ public object ReadObject() { return _result; } - private void PushStack(StackType type) { - ProcStack newStack = new ProcStack(); + private void PushStack (StackType type) { + ProcStack newStack = new ProcStack (); newStack.StackType = type; switch (type) { case StackType.Dict: - newStack.StackObj = new PythonDictionary(); + newStack.StackObj = new PythonDictionary (); newStack.StackCount = -1; break; case StackType.List: - newStack.StackObj = new PythonList(); - newStack.StackCount = ReadInt32(); + newStack.StackObj = new PythonList (); + newStack.StackCount = ReadInt32 (); break; case StackType.Tuple: - newStack.StackCount = ReadInt32(); - newStack.StackObj = new List(newStack.StackCount); + newStack.StackCount = ReadInt32 (); + newStack.StackObj = new List (newStack.StackCount); break; case StackType.Set: - newStack.StackObj = new SetCollection(); - newStack.StackCount = ReadInt32(); + newStack.StackObj = new SetCollection (); + newStack.StackCount = ReadInt32 (); break; case StackType.FrozenSet: - newStack.StackCount = ReadInt32(); - newStack.StackObj = new List(newStack.StackCount); + newStack.StackCount = ReadInt32 (); + newStack.StackObj = new List (newStack.StackCount); break; } - if (_stack == null) _stack = new Stack(); + if (_stack == null) _stack = new Stack (); - _stack.Push(newStack); + _stack.Push (newStack); } - private object UpdateStack(object res) { - ProcStack curStack = _stack.Peek(); + private object UpdateStack (object res) { + ProcStack curStack = _stack.Peek (); switch (curStack.StackType) { case StackType.Dict: PythonDictionary od = curStack.StackObj as PythonDictionary; @@ -367,11 +367,11 @@ private object UpdateStack(object res) { break; case StackType.Tuple: List objs = curStack.StackObj as List; - objs.Add(res); + objs.Add (res); curStack.StackCount--; if (curStack.StackCount == 0) { - _stack.Pop(); - object tuple = PythonTuple.Make(objs); + _stack.Pop (); + object tuple = PythonTuple.Make (objs); if (_stack.Count == 0) { _result = tuple; } @@ -380,10 +380,10 @@ private object UpdateStack(object res) { break; case StackType.List: PythonList ol = curStack.StackObj as PythonList; - ol.AddNoLock(res); + ol.AddNoLock (res); curStack.StackCount--; if (curStack.StackCount == 0) { - _stack.Pop(); + _stack.Pop (); if (_stack.Count == 0) { _result = ol; } @@ -392,10 +392,10 @@ private object UpdateStack(object res) { break; case StackType.Set: SetCollection os = curStack.StackObj as SetCollection; - os.add(res); + os.add (res); curStack.StackCount--; if (curStack.StackCount == 0) { - _stack.Pop(); + _stack.Pop (); if (_stack.Count == 0) { _result = os; } @@ -404,10 +404,10 @@ private object UpdateStack(object res) { break; case StackType.FrozenSet: List ofs = curStack.StackObj as List; - ofs.Add(res); + ofs.Add (res); curStack.StackCount--; if (curStack.StackCount == 0) { - _stack.Pop(); + _stack.Pop (); object frozenSet = FrozenSetCollection.Make(ofs); if (_stack.Count == 0) { _result = frozenSet; @@ -435,34 +435,34 @@ private class ProcStack { public object Key; } - private object YieldSimple() { + private object YieldSimple () { object res; switch ((char)_myBytes.Current) { // simple ops to be read in - case 'i': res = ReadInt(); break; - case 'l': res = ReadBigInteger(); break; + case 'i': res = ReadInt (); break; + case 'l': res = ReadBigInteger (); break; case 'T': res = ScriptingRuntimeHelpers.True; break; case 'F': res = ScriptingRuntimeHelpers.False; break; - case 'f': res = ReadFloat(); break; - case 't': res = ReadAsciiString(); break; - case 'u': res = ReadUnicodeString(); break; + case 'f': res = ReadFloat (); break; + case 't': res = ReadAsciiString (); break; + case 'u': res = ReadUnicodeString (); break; case 'S': res = PythonExceptions.StopIteration; break; case 'N': res = null; break; - case 'x': res = ReadComplex(); break; - case 's': res = ReadBuffer(); break; - case 'I': res = ReadLong(); break; - case 'R': res = _strings[ReadInt32()]; break; - case 'g': res = ReadBinaryFloat(); break; - default: throw PythonOps.ValueError("bad marshal data"); + case 'x': res = ReadComplex (); break; + case 's': res = ReadBuffer (); break; + case 'I': res = ReadLong (); break; + case 'R': res = _strings[ReadInt32 ()]; break; + case 'g': res = ReadBinaryFloat (); break; + default: throw PythonOps.ValueError ("bad marshal data"); } return res; } - private byte[] ReadBytes(int len) { + private byte[] ReadBytes (int len) { byte[] bytes = new byte[len]; for (int i = 0; i < len; i++) { - if (!_myBytes.MoveNext()) { - throw PythonOps.ValueError("bad marshal data"); + if (!_myBytes.MoveNext ()) { + throw PythonOps.ValueError ("bad marshal data"); } bytes[i] = _myBytes.Current; } @@ -470,8 +470,8 @@ private byte[] ReadBytes(int len) { return bytes; } - private int ReadInt32() { - byte[] intBytes = ReadBytes(4); + private int ReadInt32 () { + byte[] intBytes = ReadBytes (4); int res = intBytes[0] | (intBytes[1] << 8) | @@ -481,10 +481,10 @@ private int ReadInt32() { return res; } - private double ReadFloatStr() { - MoveNext(); + private double ReadFloatStr () { + MoveNext (); - string str = DecodeString(Encoding.ASCII, ReadBytes(_myBytes.Current)); + string str = DecodeString (Encoding.ASCII, ReadBytes (_myBytes.Current)); if (double.TryParse(str, NumberStyles.Float, CultureInfo.InvariantCulture, out double res)) { return res; @@ -492,32 +492,32 @@ private double ReadFloatStr() { return 0; } - private void MoveNext() { - if (!_myBytes.MoveNext()) { - throw PythonOps.EofError("EOF read where object expected"); + private void MoveNext () { + if (!_myBytes.MoveNext ()) { + throw PythonOps.EofError ("EOF read where object expected"); } } - private string DecodeString(Encoding enc, byte[] bytes) { - return enc.GetString(bytes, 0, bytes.Length); + private string DecodeString (Encoding enc, byte[] bytes) { + return enc.GetString (bytes, 0, bytes.Length); } - private object ReadInt() { - + private object ReadInt () { + // bytes not present are treated as being -1 - byte b1 = ReadIntPart(); - byte b2 = ReadIntPart(); - byte b3 = ReadIntPart(); - byte b4 = ReadIntPart(); + byte b1 = ReadIntPart (); + byte b2 = ReadIntPart (); + byte b3 = ReadIntPart (); + byte b4 = ReadIntPart (); byte[] bytes = new byte[] { b1, b2, b3, b4 }; - return ScriptingRuntimeHelpers.Int32ToObject(BitConverter.ToInt32(bytes, 0)); + return ScriptingRuntimeHelpers.Int32ToObject (BitConverter.ToInt32 (bytes, 0)); //return Ops.int2object(b1 | (b2 << 8) | (b3 << 16) | (b4 << 24)); } - private byte ReadIntPart() { + private byte ReadIntPart () { byte b; - if (_myBytes.MoveNext()) { + if (_myBytes.MoveNext ()) { b = _myBytes.Current; } else { b = 255; @@ -525,38 +525,38 @@ private byte ReadIntPart() { return b; } - private object ReadFloat() { - return ReadFloatStr(); + private object ReadFloat () { + return ReadFloatStr (); } - private object ReadBinaryFloat() { - return BitConverter.ToDouble(ReadBytes(8), 0); + private object ReadBinaryFloat () { + return BitConverter.ToDouble (ReadBytes (8), 0); } - private object ReadAsciiString() { + private object ReadAsciiString () { // Legacy IronPython 2 behavior, accepts Latin-1 - string res = DecodeString(StringOps.Latin1Encoding, ReadBytes(ReadInt32())); + string res = DecodeString (StringOps.Latin1Encoding, ReadBytes (ReadInt32 ())); _strings[_strings.Count] = res; return res; } - private object ReadUnicodeString() { - return DecodeString(Encoding.UTF8, ReadBytes(ReadInt32())); + private object ReadUnicodeString () { + return DecodeString (Encoding.UTF8, ReadBytes (ReadInt32 ())); } - private object ReadComplex() { - double real = ReadFloatStr(); - double imag = ReadFloatStr(); + private object ReadComplex () { + double real = ReadFloatStr (); + double imag = ReadFloatStr (); - return new Complex(real, imag); + return new Complex (real, imag); } - private object ReadBuffer() { - return Bytes.Make(ReadBytes(ReadInt32())); + private object ReadBuffer () { + return Bytes.Make (ReadBytes (ReadInt32 ())); } - private object ReadLong() { - byte[] bytes = ReadBytes(8); + private object ReadLong () { + byte[] bytes = ReadBytes (8); long res = 0; for (int i = 0; i < 8; i++) { @@ -566,8 +566,8 @@ private object ReadLong() { return res; } - private object ReadBigInteger() { - int encodingSize = ReadInt32(); + private object ReadBigInteger () { + int encodingSize = ReadInt32 (); if (encodingSize == 0) { return BigInteger.Zero; } @@ -579,7 +579,7 @@ private object ReadBigInteger() { } int len = encodingSize * 2; - byte[] bytes = ReadBytes(len); + byte[] bytes = ReadBytes (len); // re-pack our 15-bit values into bytes byte[] data = new byte[bytes.Length]; @@ -613,7 +613,7 @@ private object ReadBigInteger() { } // and finally pass the data onto the big integer. - BigInteger res = new BigInteger(data); + BigInteger res = new BigInteger (data); return sign < 0 ? -res : res; } } diff --git a/src/ipy/IronPython/Runtime/Operations/NamespaceTrackerOps.cs b/src/ipy/IronPython/Runtime/Operations/NamespaceTrackerOps.cs index 97917f17a..2b1b335b9 100644 --- a/src/ipy/IronPython/Runtime/Operations/NamespaceTrackerOps.cs +++ b/src/ipy/IronPython/Runtime/Operations/NamespaceTrackerOps.cs @@ -4,14 +4,17 @@ #nullable enable +using System; +using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Text; -using IronPython.Runtime.Types; - +using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Runtime; +using IronPython.Runtime.Types; + namespace IronPython.Runtime.Operations { public static class NamespaceTrackerOps { [SpecialName, PropertyMethod] diff --git a/src/ipy/IronPython/Runtime/Operations/ObjectOps.cs b/src/ipy/IronPython/Runtime/Operations/ObjectOps.cs index a34032f87..058259ba5 100644 --- a/src/ipy/IronPython/Runtime/Operations/ObjectOps.cs +++ b/src/ipy/IronPython/Runtime/Operations/ObjectOps.cs @@ -6,13 +6,15 @@ using System; using System.Collections.Generic; +using System.Numerics; using System.Reflection; using System.Threading; -using IronPython.Runtime.Types; - using Microsoft.Scripting; using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + +using IronPython.Runtime.Types; namespace IronPython.Runtime.Operations { @@ -72,7 +74,7 @@ public static void __init__(CodeContext/*!*/ context, object self, [NotNone] par /// /// Initializes the object. The base class does nothing. /// - public static void __init__(CodeContext/*!*/ context, object self, [ParamDictionary] IDictionary kwargs, params object[] args\u00F8) { + public static void __init__(CodeContext/*!*/ context, object self, [ParamDictionary]IDictionary kwargs, params object[] args\u00F8) { InstanceOps.CheckInitArgs(context, kwargs, args\u00F8, self); } @@ -106,7 +108,7 @@ public static object __new__(CodeContext/*!*/ context, PythonType cls, [NotNone] /// Creates a new instance of the type /// [StaticExtensionMethod] - public static object __new__(CodeContext/*!*/ context, PythonType cls, [ParamDictionary] IDictionary kwargs\u00F8, [NotNone] params object[] args\u00F8) { + public static object __new__(CodeContext/*!*/ context, PythonType cls, [ParamDictionary]IDictionary kwargs\u00F8, [NotNone] params object[] args\u00F8) { if (cls == null) { throw PythonOps.TypeError("__new__ expected type object, got {0}", PythonOps.Repr(context, DynamicHelpers.GetPythonType(cls))); } diff --git a/src/ipy/IronPython/Runtime/Operations/PythonCalls.cs b/src/ipy/IronPython/Runtime/Operations/PythonCalls.cs index 6135391bf..5ef15414b 100644 --- a/src/ipy/IronPython/Runtime/Operations/PythonCalls.cs +++ b/src/ipy/IronPython/Runtime/Operations/PythonCalls.cs @@ -4,7 +4,9 @@ #nullable enable +using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace IronPython.Runtime.Operations { public static partial class PythonCalls { diff --git a/src/ipy/IronPython/Runtime/Operations/PythonOps.cs b/src/ipy/IronPython/Runtime/Operations/PythonOps.cs index aad57dd2b..380c5006f 100644 --- a/src/ipy/IronPython/Runtime/Operations/PythonOps.cs +++ b/src/ipy/IronPython/Runtime/Operations/PythonOps.cs @@ -23,13 +23,6 @@ using System.Text; using System.Threading; -using IronPython.Compiler; -using IronPython.Hosting; -using IronPython.Modules; -using IronPython.Runtime.Binding; -using IronPython.Runtime.Exceptions; -using IronPython.Runtime.Types; - using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Ast; @@ -39,6 +32,13 @@ using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Compiler; +using IronPython.Hosting; +using IronPython.Modules; +using IronPython.Runtime.Binding; +using IronPython.Runtime.Exceptions; +using IronPython.Runtime.Types; + using NotNullAttribute = System.Diagnostics.CodeAnalysis.NotNullAttribute; namespace IronPython.Runtime.Operations { @@ -107,7 +107,7 @@ public static PythonDictionary MakeHomogeneousDictFromItems(object[] data) { return new PythonDictionary(new CommonDictionaryStorage(data, true)); } - public static bool IsCallable(CodeContext/*!*/ context, [NotNullWhen(true)] object? o) { + public static bool IsCallable(CodeContext/*!*/ context, [NotNullWhen(true)]object? o) { // This tells if an object can be called, but does not make a claim about the parameter list. // In 1.x, we could check for certain interfaces like ICallable*, but those interfaces were deprecated // in favor of dynamic sites. @@ -391,7 +391,7 @@ internal static bool IsSubClass(PythonType/*!*/ c, PythonType/*!*/ typeinfo) { return typeinfo.__subclasscheck__(c); } - internal static bool IsSubClass(CodeContext/*!*/ context, PythonType c, [NotNull] object? typeinfo) { + internal static bool IsSubClass(CodeContext/*!*/ context, PythonType c, [NotNull]object? typeinfo) { if (c == null) throw PythonOps.TypeError("issubclass: arg 1 must be a class"); if (typeinfo == null) throw PythonOps.TypeError("issubclass: arg 2 must be a class"); @@ -476,7 +476,7 @@ internal static bool IsInstance(CodeContext/*!*/ context, object? o, PythonTuple } // used by Ironclad - public static bool IsInstance(CodeContext/*!*/ context, object? o, [NotNull] object? typeinfo) { + public static bool IsInstance(CodeContext/*!*/ context, object? o, [NotNull]object? typeinfo) { if (typeinfo == null) throw PythonOps.TypeError("isinstance: arg 2 must be a class, type, or tuple of classes and types"); if (typeinfo is PythonTuple tt) { @@ -505,7 +505,7 @@ private static bool IsInstanceDynamic(object? o, object typeinfo, PythonType odt return false; } - private static bool IsSubclassSlow([NotNullWhen(true)] object? cls, object typeinfo) { + private static bool IsSubclassSlow([NotNullWhen(true)]object? cls, object typeinfo) { if (cls == null) return false; // Same type @@ -2178,7 +2178,7 @@ public static object GetEnumeratorObject(CodeContext/*!*/ context, object? o) { throw TypeErrorForNotIterable(o); } - private static bool TryGetEnumeratorObject(CodeContext/*!*/ context, object? o, [NotNullWhen(true)] out object? enumerator) { + private static bool TryGetEnumeratorObject(CodeContext/*!*/ context, object? o, [NotNullWhen(true)]out object? enumerator) { // IronPython defines __getitem__ on PythonType (to support generics and .NET enums) // which would make it "iterable" even though it is not. if (o is PythonType pt && !pt.IsIterable(context)) { @@ -2212,7 +2212,7 @@ public static KeyValuePair ThrowTypeErrorForBadIterati throw PythonOps.TypeError("iteration over non-sequence of type {0}", PythonOps.GetPythonTypeName(enumerable)); } - internal static bool TryGetEnumerator(CodeContext/*!*/ context, [NotNullWhen(true)] object? enumerable, [NotNullWhen(true)] out IEnumerator? enumerator) { + internal static bool TryGetEnumerator(CodeContext/*!*/ context, [NotNullWhen(true)]object? enumerable, [NotNullWhen(true)]out IEnumerator? enumerator) { enumerator = null; // IronPython defines __getitem__ on PythonType (to support generics and .NET enums) @@ -2856,7 +2856,7 @@ public static object GetInitSlotMember(CodeContext/*!*/ context, PythonType type /// Helper to determine if the value is a simple numeric type (int or big int or bool) - used for OldInstance /// deprecated form of slicing. /// - public static bool IsNumericObject([NotNullWhen(true)] object? value) { + public static bool IsNumericObject([NotNullWhen(true)]object? value) { return value is int || value is BigInteger || value is Extensible || value is bool; } @@ -2920,7 +2920,8 @@ internal static MethodInfo GetConversionHelper(string name, ConversionResultKind } public static object ConvertToPythonPrimitive(object value) { - return value switch { + return value switch + { float f => (double)f, sbyte sb => (int)sb, byte b => (int)b, @@ -4077,7 +4078,7 @@ public static Exception TypeErrorForArgumentCountMismatch(string methodName, int methodName, expectedArgCount, expectedArgCount == 1 ? "" : "s", actualArgCount); } - public static Exception TypeErrorForOptionalArgumentCountMismatch(string methodName, int expectedArgCount, int actualArgCount, bool positional = false) { + public static Exception TypeErrorForOptionalArgumentCountMismatch(string methodName, int expectedArgCount, int actualArgCount, bool positional=false) { return TypeError("{0}() takes at most {1} {2}argument{3} ({4} given)", methodName, expectedArgCount, positional ? "positional " : "", expectedArgCount == 1 ? "" : "s", actualArgCount); } diff --git a/src/ipy/IronPython/Runtime/Operations/PythonTypeOps.cs b/src/ipy/IronPython/Runtime/Operations/PythonTypeOps.cs index d6b95d84f..9edf44394 100644 --- a/src/ipy/IronPython/Runtime/Operations/PythonTypeOps.cs +++ b/src/ipy/IronPython/Runtime/Operations/PythonTypeOps.cs @@ -5,13 +5,11 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Reflection; using System.Dynamic; using System.Linq; -using System.Reflection; - using IronPython.Runtime.Binding; using IronPython.Runtime.Types; - using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Generation; @@ -85,7 +83,7 @@ internal static object CallWorker(CodeContext/*!*/ context, PythonType dt, IDict argNames[i++ - args.Length] = kvp.Key; } - return CallWorker(context, dt, new KwCallInfo(allArgs, argNames)); + return CallWorker(context, dt, new KwCallInfo(allArgs, argNames)); } internal static object CallWorker(CodeContext/*!*/ context, PythonType dt, KwCallInfo args) { @@ -116,7 +114,7 @@ private static object GetInitMethod(CodeContext/*!*/ context, PythonType dt, obj PythonType cdt = dt.ResolutionOrder[i]; PythonTypeSlot dts; object value; - + if (cdt.TryLookupSlot(context, "__init__", out dts) && dts.TryGetValue(context, newObject, dt, out value)) { return value; @@ -172,7 +170,7 @@ private static bool ShouldInvokeInit(PythonType cls, PythonType newObjectType, i // or if this is the user doing type(x), or if it's a standard // .NET type which doesn't have an __init__ method (this is a perf optimization) return (!cls.IsSystemType || cls.IsPythonType) && - newObjectType.IsSubclassOf(cls) && + newObjectType.IsSubclassOf(cls) && (cls != TypeCache.PythonType || argCnt > 1); } @@ -232,7 +230,7 @@ internal static TrackerTypes GetMemberType(MemberGroup members) { group = FilterNewSlots(group); TrackerTypes tt = GetMemberType(group); - switch (tt) { + switch(tt) { case TrackerTypes.Method: bool checkStatic = false; List mems = new List(); @@ -243,37 +241,37 @@ internal static TrackerTypes GetMemberType(MemberGroup members) { } Type declType = group[0].DeclaringType; - MemberInfo[] memArray = mems.ToArray(); + MemberInfo[] memArray = mems.ToArray(); FunctionType ft = GetMethodFunctionType(declType, memArray, checkStatic); return GetFinalSlotForFunction(GetBuiltinFunction(declType, group[0].Name, name, ft, memArray)); - + case TrackerTypes.Field: return GetReflectedField(((FieldTracker)group[0]).Field); - + case TrackerTypes.Property: - return GetReflectedProperty((PropertyTracker)group[0], group, privateBinding); - + return GetReflectedProperty((PropertyTracker)group[0], group, privateBinding); + case TrackerTypes.Event: return GetReflectedEvent(((EventTracker)group[0])); - + case TrackerTypes.Type: TypeTracker type = (TypeTracker)group[0]; for (int i = 1; i < group.Count; i++) { type = TypeGroup.UpdateTypeEntity(type, (TypeTracker)group[i]); } - + if (type is TypeGroup) { return new PythonTypeUserDescriptorSlot(type, true); } return new PythonTypeUserDescriptorSlot(DynamicHelpers.GetPythonTypeFromType(type.Type), true); - + case TrackerTypes.Constructor: return GetConstructorFunction(group[0].DeclaringType, privateBinding); - + case TrackerTypes.Custom: return ((PythonCustomTracker)group[0]).GetSlot(); - + default: // if we have a new slot in the derived class filter out the // members from the base class. @@ -313,7 +311,7 @@ private static BuiltinFunction GetConstructorFunction(Type t, bool privateBindin return GetConstructor(t, ctorFunc, ctors); } - + internal static MethodBase[] GetConstructors(Type t, bool privateBinding, bool includeProtected = false) { MethodBase[] ctors = CompilerHelpers.GetConstructors(t, privateBinding, includeProtected); if (t.IsEnum) { @@ -322,7 +320,7 @@ internal static MethodBase[] GetConstructors(Type t, bool privateBinding, bool i } return ctors; } - // support for EnumType(number) + // support for EnumType(number) private static T CreateEnum(object value) { if (value == null) { throw PythonOps.ValueError( @@ -366,7 +364,7 @@ internal static BuiltinFunction GetConstructorFunction(Type type, string name) { methods.Add(ci); } } - + if (type.IsValueType && !hasDefaultConstructor && type != typeof(void)) { try { methods.Add(typeof(ScriptingRuntimeHelpers).GetMethod(nameof(ScriptingRuntimeHelpers.CreateInstance), ReflectionUtils.EmptyTypes).MakeGenericMethod(type)); @@ -482,7 +480,7 @@ public static MemberInfo[] GetNonBaseHelperMemberInfos(MemberInfo[] members) { BuiltinFunction res = null; if (mems.Length != 0) { - FunctionType ft = funcType ?? GetMethodFunctionType(type, mems); + FunctionType ft = funcType ?? GetMethodFunctionType(type, mems); type = GetBaseDeclaringType(type, mems); BuiltinFunctionKey cache = new BuiltinFunctionKey(type, new ReflectionCache.MethodBaseCache(cacheName, GetNonBaseHelperMethodInfos(mems)), ft); @@ -542,7 +540,7 @@ private static Type GetCommonBaseType(Type xType, Type yType) { private static Type GetBaseDeclaringType(Type type, MemberInfo/*!*/[] mems) { // get the base most declaring type, first sort the list so that // the most derived class is at the beginning. - Array.Sort(mems, delegate (MemberInfo x, MemberInfo y) { + Array.Sort(mems, delegate(MemberInfo x, MemberInfo y) { if (x.DeclaringType.IsSubclassOf(y.DeclaringType)) { return -1; } else if (y.DeclaringType.IsSubclassOf(x.DeclaringType)) { @@ -604,7 +602,7 @@ internal static FunctionType GetMethodFunctionType(Type/*!*/ type, MemberInfo/*! if (mi.IsStatic && mi.IsSpecialName) { ParameterInfo[] pis = mi.GetParameters(); - if ((pis.Length == 2 && pis[0].ParameterType != typeof(CodeContext)) || + if ((pis.Length == 2 && pis[0].ParameterType != typeof(CodeContext)) || (pis.Length == 3 && pis[0].ParameterType == typeof(CodeContext))) { ft |= FunctionType.BinaryOperator; @@ -659,8 +657,8 @@ private static bool IsMethodAlwaysVisible(Type/*!*/ type, MemberInfo/*!*/[]/*!*/ } } } else if (type.IsAssignableFrom(typeof(int))) { // GH #52 - // only show methods defined outside of int - foreach (MethodInfo mi in methods) { + // only show methods defined outside of int + foreach (MethodInfo mi in methods) { Debug.Assert(!mi.DeclaringType.IsInterface || typeof(int).GetInterfaces().Contains(mi.DeclaringType)); if (PythonBinder.IsPythonSupportingType(mi.DeclaringType) || mi.DeclaringType.IsInterface || @@ -677,7 +675,7 @@ private static bool IsMethodAlwaysVisible(Type/*!*/ type, MemberInfo/*!*/[]/*!*/ /// a function is static if it's a static .NET method and it's defined on the type or is an extension method /// with StaticExtensionMethod decoration. /// - private static bool IsStaticFunction(Type type, MethodInfo mi) { + private static bool IsStaticFunction(Type type, MethodInfo mi) { return mi.IsStatic && // method must be truly static !mi.IsDefined(typeof(WrapperDescriptorAttribute), false) && // wrapper descriptors are instance methods (mi.DeclaringType.IsAssignableFrom(type) || mi.IsDefined(typeof(StaticExtensionMethodAttribute), false)); // or it's not an extension method or it's a static extension method @@ -816,7 +814,7 @@ internal static ReflectedGetterSetter GetReflectedProperty(PropertyTracker pt, M _propertyCache[pt] = rp; return rp; - } + } } private static MethodInfo FilterProtectedGetterOrSetter(MethodInfo info, bool privateBinding) { @@ -886,7 +884,7 @@ internal static bool TryInvokeTernaryOperator(CodeContext context, object o, obj /// internal static PythonTuple EnsureBaseType(PythonTuple bases) { bool hasInterface = false; - foreach (object baseClass in bases) { + foreach (object baseClass in bases) { PythonType dt = baseClass as PythonType; if (!dt.UnderlyingSystemType.IsInterface) { diff --git a/src/ipy/IronPython/Runtime/Operations/StringOps.cs b/src/ipy/IronPython/Runtime/Operations/StringOps.cs index e07b94ea6..7f2ffb457 100644 --- a/src/ipy/IronPython/Runtime/Operations/StringOps.cs +++ b/src/ipy/IronPython/Runtime/Operations/StringOps.cs @@ -16,18 +16,18 @@ using System.Numerics; using System.Reflection; using System.Runtime.InteropServices; -using System.Text; using System.Threading; - -using IronPython.Runtime.Exceptions; -using IronPython.Runtime.Types; +using System.Text; using Microsoft.Scripting; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -using NotNullAttribute = System.Diagnostics.CodeAnalysis.NotNullAttribute; +using IronPython.Runtime.Exceptions; +using IronPython.Runtime.Types; + using SpecialNameAttribute = System.Runtime.CompilerServices.SpecialNameAttribute; +using NotNullAttribute = System.Diagnostics.CodeAnalysis.NotNullAttribute; namespace IronPython.Runtime.Operations { /// @@ -1318,7 +1318,7 @@ public static string zfill([NotNone] this string self, int width) { /// /// Conversion can be 'r' for repr or 's' for string. /// - public static string/*!*/ format(CodeContext/*!*/ context, [NotNone] string format_string\u00F8, [ParamDictionary] IDictionary kwargs\u00F8, params object[] args\u00F8) { + public static string/*!*/ format(CodeContext/*!*/ context, [NotNone] string format_string\u00F8, [ParamDictionary]IDictionary kwargs\u00F8, params object[] args\u00F8) { return NewStringFormatter.FormatString( context.LanguageContext, format_string\u00F8, @@ -1729,7 +1729,7 @@ private static string RawUnicodeEscapeEncode(string s, int start, int count, boo return b?.ToString() ?? s.Substring(start, count); } - private static void StringBuilderInit([NotNull] ref StringBuilder? sb, string s, int start, int end) { + private static void StringBuilderInit([NotNull]ref StringBuilder? sb, string s, int start, int end) { if (sb != null) return; sb = new StringBuilder(s.Length); @@ -1912,7 +1912,7 @@ internal static Bytes RawEncode(CodeContext/*!*/ context, string s, string encod internal static Bytes DoEncodeAscii(string s) => DoEncode(DefaultContext.Default, s, "strict", "ascii", Encoding.ASCII, includePreamble: false); - internal static bool TryEncodeAscii(string s, [NotNullWhen(true)] out Bytes? b) { + internal static bool TryEncodeAscii(string s, [NotNullWhen(true)]out Bytes? b) { try { b = DoEncodeAscii(s); return true; @@ -2012,17 +2012,17 @@ static CodecsInfo() { // set up well-known/often-used mappings d["iso_8859_1"] = d["iso8859_1"] = d["8859"] = d["iso8859"] = d["cp28591"] = d["28591"] = d["cp819"] = d["819"] - = d["latin_1"] = d["latin1"] = d["latin"] = d["l1"] = makeEncodingProxy(() => Latin1Encoding); + = d["latin_1"] = d["latin1"] = d["latin"] = d["l1"] = makeEncodingProxy(() => Latin1Encoding); d["cp20127"] = d["us_ascii"] = d["us"] = d["ascii"] = d["646"] = makeEncodingProxy(() => Encoding.ASCII); - d["cp65000"] = d["utf_7"] = d["u7"] = d["unicode_1_1_utf_7"] = makeEncodingProxy(() => new UTF7Encoding(allowOptionals: true)); - d["cp65001"] = d["utf_8"] = d["utf8"] = d["u8"] = makeEncodingProxy(() => new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); - d["utf_8_sig"] = makeEncodingProxy(() => new UTF8Encoding(encoderShouldEmitUTF8Identifier: true)); - d["utf_16le"] = d["utf_16_le"] = makeEncodingProxy(() => new UnicodeEncoding(bigEndian: false, byteOrderMark: false)); - d["cp1200"] = d["utf_16"] = d["utf16"] = d["u16"] = makeEncodingProxy(() => new UnicodeEncoding(bigEndian: !BitConverter.IsLittleEndian, byteOrderMark: true)); - d["cp1201"] = d["utf_16be"] = d["utf_16_be"] = makeEncodingProxy(() => new UnicodeEncoding(bigEndian: true, byteOrderMark: false)); - d["utf_32le"] = d["utf_32_le"] = makeEncodingProxy(() => new UTF32Encoding(bigEndian: false, byteOrderMark: false)); - d["cp12000"] = d["utf_32"] = d["utf32"] = d["u32"] = makeEncodingProxy(() => new UTF32Encoding(bigEndian: !BitConverter.IsLittleEndian, byteOrderMark: true)); - d["cp12001"] = d["utf_32be"] = d["utf_32_be"] = makeEncodingProxy(() => new UTF32Encoding(bigEndian: true, byteOrderMark: false)); + d["cp65000"] = d["utf_7"] = d["u7"] = d["unicode_1_1_utf_7"] = makeEncodingProxy(() => new UTF7Encoding(allowOptionals: true)); + d["cp65001"] = d["utf_8"] = d["utf8"] = d["u8"] = makeEncodingProxy(() => new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); + d["utf_8_sig"] = makeEncodingProxy(() => new UTF8Encoding(encoderShouldEmitUTF8Identifier: true)); + d["utf_16le"] = d["utf_16_le"] = makeEncodingProxy(() => new UnicodeEncoding(bigEndian: false, byteOrderMark: false)); + d["cp1200"] = d["utf_16"] = d["utf16"] = d["u16"] = makeEncodingProxy(() => new UnicodeEncoding(bigEndian: !BitConverter.IsLittleEndian, byteOrderMark: true)); + d["cp1201"] = d["utf_16be"] = d["utf_16_be"] = makeEncodingProxy(() => new UnicodeEncoding(bigEndian: true, byteOrderMark: false)); + d["utf_32le"] = d["utf_32_le"] = makeEncodingProxy(() => new UTF32Encoding(bigEndian: false, byteOrderMark: false)); + d["cp12000"] = d["utf_32"] = d["utf32"] = d["u32"] = makeEncodingProxy(() => new UTF32Encoding(bigEndian: !BitConverter.IsLittleEndian, byteOrderMark: true)); + d["cp12001"] = d["utf_32be"] = d["utf_32_be"] = makeEncodingProxy(() => new UTF32Encoding(bigEndian: true, byteOrderMark: false)); // set up internal codecs d["raw_unicode_escape"] = makeEncodingProxy(() => RawUnicodeEscapeEncoding); @@ -2079,9 +2079,9 @@ static CodecsInfo() { #if DEBUG foreach (KeyValuePair> kvp in d) { // all codecs should be stored in lowercase because we only look up from lowercase strings -#pragma warning disable CA1862 // disable warning about comparing with ToLower() + #pragma warning disable CA1862 // disable warning about comparing with ToLower() Debug.Assert(kvp.Key.ToLower(CultureInfo.InvariantCulture) == kvp.Key); -#pragma warning restore + #pragma warning restore // all codec names should use underscores instead of dashes to match lookup values Debug.Assert(kvp.Key.IndexOf('-') < 0); } @@ -2173,7 +2173,7 @@ private static PythonList SplitInternal(string self, string separator, int maxsp } } - private static void AssertStringOrTuple([NotNull] object? prefix) { + private static void AssertStringOrTuple([NotNull]object? prefix) { if (prefix == null) { throw PythonOps.TypeError("expected string or tuple, got NoneType"); } @@ -2731,7 +2731,7 @@ static string NameReplaceEncode(string s, int start, int count) { } private delegate string? DecodeErrorHandler(IList bytes, int start, ref int end); - private delegate Bytes? EncodeErrorHandler(string text, int start, ref int end); + private delegate Bytes? EncodeErrorHandler(string text, int start, ref int end); private static object SurrogateEscapeErrors(object unicodeError) { return SurrogateErrorsImpl(unicodeError, surrogateEscapeDecode, surrogateEscapeEncode); @@ -2890,7 +2890,7 @@ private static object SurrogateErrorsImpl(object unicodeError, DecodeErrorHandle int end = dfe.BytesUnknown.Length; string? res = decodeFallback(dfe.BytesUnknown, 0, ref end); if (res == null) throw dfe; - return PythonTuple.MakeTuple(res, dfe.Index + end); + return PythonTuple.MakeTuple(res, dfe.Index + end); } case EncoderFallbackException efe: { diff --git a/src/ipy/IronPython/Runtime/Operations/TypeGroupOps.cs b/src/ipy/IronPython/Runtime/Operations/TypeGroupOps.cs index af109c56e..19354664c 100644 --- a/src/ipy/IronPython/Runtime/Operations/TypeGroupOps.cs +++ b/src/ipy/IronPython/Runtime/Operations/TypeGroupOps.cs @@ -20,8 +20,8 @@ public static class TypeGroupOps { public static string __repr__(TypeGroup self) { StringBuilder sb = new StringBuilder(" MakeGetBinding(CodeContext codeCont } return (Binding.FastBindResult)(object)new Binding.MetaUserObject.FastGetBinderHelper( codeContext, - (CallSite>)(object)site, - self, + (CallSite>)(object)site, + self, getBinder).GetBinding(codeContext, getBinder.Name); } @@ -388,7 +390,7 @@ internal static FastBindResult MakeSetBinding(CodeContext codeContext, Cal /// public class UserTypeDebugView { private readonly IPythonObject _userObject; - + public UserTypeDebugView(IPythonObject userObject) { _userObject = userObject; } @@ -414,8 +416,8 @@ internal List Members { if (slots != null) { var mro = _userObject.PythonType.ResolutionOrder; List slotNames = new List(); - - for (int i = mro.Count - 1; i >= 0; i--) { + + for(int i = mro.Count - 1; i>= 0; i--) { slotNames.AddRange(mro[i].GetTypeSlots()); } diff --git a/src/ipy/IronPython/Runtime/OutputWriter.cs b/src/ipy/IronPython/Runtime/OutputWriter.cs index d56465dfb..6aca910a9 100644 --- a/src/ipy/IronPython/Runtime/OutputWriter.cs +++ b/src/ipy/IronPython/Runtime/OutputWriter.cs @@ -5,9 +5,8 @@ using System; using System.IO; using System.Text; - using IronPython.Runtime.Operations; - +using Microsoft.Scripting; using Microsoft.Scripting.Utils; namespace IronPython.Runtime { diff --git a/src/ipy/IronPython/Runtime/Profiler.cs b/src/ipy/IronPython/Runtime/Profiler.cs index 1e0dbe5cd..bc0d245e4 100644 --- a/src/ipy/IronPython/Runtime/Profiler.cs +++ b/src/ipy/IronPython/Runtime/Profiler.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using MSAst = System.Linq.Expressions; + using System; using System.Collections.Generic; using System.Diagnostics; @@ -10,11 +12,10 @@ using System.Text; using System.Threading; -using IronPython.Compiler; - using Microsoft.Scripting; +using Microsoft.Scripting.Actions.Calls; -using MSAst = System.Linq.Expressions; +using IronPython.Compiler; namespace IronPython.Runtime { using Ast = MSAst.Expression; @@ -225,7 +226,7 @@ internal MSAst.Expression AddOuterProfiling(MSAst.Expression/*!*/ body, MSAst.Pa AstUtils.Constant(profileIndex) ) ), - AstUtils.Try( + AstUtils.Try( body ).Finally( Ast.Call( diff --git a/src/ipy/IronPython/Runtime/PythonContext.cs b/src/ipy/IronPython/Runtime/PythonContext.cs index 697a6f524..d13d72a75 100644 --- a/src/ipy/IronPython/Runtime/PythonContext.cs +++ b/src/ipy/IronPython/Runtime/PythonContext.cs @@ -18,6 +18,13 @@ using System.Text; using System.Threading; +using Microsoft.Scripting; +using Microsoft.Scripting.Actions; +using Microsoft.Scripting.Debugging.CompilerServices; +using Microsoft.Scripting.Generation; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + using IronPython.Compiler; using IronPython.Hosting; using IronPython.Modules; @@ -26,13 +33,6 @@ using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting; -using Microsoft.Scripting.Actions; -using Microsoft.Scripting.Debugging.CompilerServices; -using Microsoft.Scripting.Generation; -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - using Debugging = Microsoft.Scripting.Debugging; using PyAst = IronPython.Compiler.Ast; diff --git a/src/ipy/IronPython/Runtime/PythonDictionary.cs b/src/ipy/IronPython/Runtime/PythonDictionary.cs index 65b36998d..8a6033482 100644 --- a/src/ipy/IronPython/Runtime/PythonDictionary.cs +++ b/src/ipy/IronPython/Runtime/PythonDictionary.cs @@ -10,12 +10,12 @@ using System.Security; using System.Text; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using Microsoft.Scripting; using Microsoft.Scripting.Runtime; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + namespace IronPython.Runtime { [PythonType("dict"), Serializable, DebuggerTypeProxy(typeof(DebugProxy)), DebuggerDisplay("Count = {Count}")] @@ -87,12 +87,12 @@ internal static PythonDictionary MakeSymbolDictionary(int count) { return new PythonDictionary(new StringDictionaryStorage(count)); } - public void __init__(CodeContext/*!*/ context, object o\u00F8, [ParamDictionary] IDictionary kwArgs) { + public void __init__(CodeContext/*!*/ context, object o\u00F8, [ParamDictionary]IDictionary kwArgs) { update(context, o\u00F8); update(context, kwArgs); } - public void __init__(CodeContext/*!*/ context, [ParamDictionary] IDictionary kwArgs) { + public void __init__(CodeContext/*!*/ context, [ParamDictionary]IDictionary kwArgs) { update(context, kwArgs); } @@ -356,7 +356,7 @@ public object setdefault(object key, object defaultValue) { public void update() { } - public void update(CodeContext/*!*/ context, [ParamDictionary] IDictionary other\u00F8) { + public void update(CodeContext/*!*/ context, [ParamDictionary]IDictionary other\u00F8) { DictionaryOps.update(context, this, other\u00F8); } @@ -364,7 +364,7 @@ public void update(CodeContext/*!*/ context, object other\u00F8) { DictionaryOps.update(context, this, other\u00F8); } - public void update(CodeContext/*!*/ context, object other\u00F8, [ParamDictionary] IDictionary otherArgs\u00F8) { + public void update(CodeContext/*!*/ context, object other\u00F8, [ParamDictionary]IDictionary otherArgs\u00F8) { DictionaryOps.update(context, this, other\u00F8); DictionaryOps.update(context, this, otherArgs\u00F8); } @@ -1491,7 +1491,7 @@ void ICollection.CopyTo(object[] array, int arrayIndex) { int ICollection.Count => _dict.Count; - bool ICollection.IsReadOnly => true; + bool ICollection.IsReadOnly => true; bool ICollection.Remove(object item) => throw new NotSupportedException("Collection is read-only"); diff --git a/src/ipy/IronPython/Runtime/PythonDocumentationProvider.cs b/src/ipy/IronPython/Runtime/PythonDocumentationProvider.cs index 572cb8bb2..adc89c53b 100644 --- a/src/ipy/IronPython/Runtime/PythonDocumentationProvider.cs +++ b/src/ipy/IronPython/Runtime/PythonDocumentationProvider.cs @@ -6,11 +6,13 @@ using System.Collections.Generic; using System.Reflection; -using IronPython.Runtime.Types; - +using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Hosting; using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + +using IronPython.Runtime.Types; namespace IronPython.Runtime { internal class PythonDocumentationProvider : DocumentationProvider { @@ -77,7 +79,7 @@ private static MemberDoc MakeMemberDoc(string name, object value, bool fromClass if (value is BuiltinFunction) { kind = MemberKind.Function; } else if (value is NamespaceTracker) { - kind = MemberKind.Namespace; + kind = MemberKind.Namespace; } else if (value is PythonFunction) { kind = fromClass ? MemberKind.Method : MemberKind.Function; } else if (value is BuiltinMethodDescriptor || value is Method) { @@ -121,7 +123,7 @@ public override ICollection GetOverloads(object value) { } if (value is PythonFunction pf) { - return new[] { + return new[] { new OverloadDoc( pf.__name__, pf.__doc__ as string, diff --git a/src/ipy/IronPython/Runtime/PythonDynamicStackFrame.cs b/src/ipy/IronPython/Runtime/PythonDynamicStackFrame.cs index 9dda5b494..e9ad9984a 100644 --- a/src/ipy/IronPython/Runtime/PythonDynamicStackFrame.cs +++ b/src/ipy/IronPython/Runtime/PythonDynamicStackFrame.cs @@ -17,7 +17,8 @@ namespace IronPython.Runtime { /// function code object which is needed to build frame objects from. /// [Serializable] - internal sealed class PythonDynamicStackFrame : DynamicStackFrame, ISerializable { + internal sealed class PythonDynamicStackFrame : DynamicStackFrame, ISerializable + { private readonly CodeContext _context; private readonly FunctionCode _code; diff --git a/src/ipy/IronPython/Runtime/PythonEncoding.cs b/src/ipy/IronPython/Runtime/PythonEncoding.cs index e32f4ca25..7aca2e6a7 100644 --- a/src/ipy/IronPython/Runtime/PythonEncoding.cs +++ b/src/ipy/IronPython/Runtime/PythonEncoding.cs @@ -4,6 +4,11 @@ #nullable enable +using IronPython.Runtime.Exceptions; +using IronPython.Runtime.Operations; + +using Microsoft.Scripting.Runtime; + using System; using System.Collections.Generic; using System.Diagnostics; @@ -12,11 +17,6 @@ using System.Runtime.InteropServices; using System.Text; -using IronPython.Runtime.Exceptions; -using IronPython.Runtime.Operations; - -using Microsoft.Scripting.Runtime; - namespace IronPython.Runtime { /// @@ -953,7 +953,7 @@ public override Tuple, ReadOnlyMemory> GetFallbackCha if ((runeUnknown & ~0xff) != LoneSurrogateBase) { // EncoderFallbackException(string, char, int) is not accessible here throw PythonOps.UnicodeEncodeError( - $"'surrogateescape' error handler: value not in range(0x{LoneSurrogateBase:x4}, 0x{LoneSurrogateBase + 0x100:x4})", + $"'surrogateescape' error handler: value not in range(0x{LoneSurrogateBase:x4}, 0x{LoneSurrogateBase+0x100:x4})", runeUnknown, index ); @@ -1262,7 +1262,7 @@ public override void Reset() { _buffer = null; } - protected void Throw(byte[] bytesUnknown, int index) + protected void Throw(byte[] bytesUnknown, int index) => throw new DecoderFallbackException($"'surrogatepass' error handler: not a surrogate character", bytesUnknown, index); } } @@ -1453,7 +1453,7 @@ public override void FinalizeIncrement(int endIndex, bool flush) { int retain = _previousData.Length - span.Length; if (retain <= 0) { _previousDataLen = 0; - } else if (retain < _previousDataLen) { + } else if (retain < _previousDataLen) { Array.Copy(_previousData, _previousDataLen - retain, _previousData, 0, retain); _previousDataLen = retain; } diff --git a/src/ipy/IronPython/Runtime/PythonFileManager.cs b/src/ipy/IronPython/Runtime/PythonFileManager.cs index 9e919ee36..5070b9ffa 100644 --- a/src/ipy/IronPython/Runtime/PythonFileManager.cs +++ b/src/ipy/IronPython/Runtime/PythonFileManager.cs @@ -8,15 +8,15 @@ using System.Buffers; using System.Collections.Concurrent; using System.Collections.Generic; -using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; -using IronPython.Runtime.Operations; - using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Operations; +using System.Diagnostics; + namespace IronPython.Runtime { /// @@ -96,7 +96,7 @@ bool isattyUnix() { } } - public long Truncate(long size) { + public long Truncate(long size) { long pos = _readStream.Position; _writeStream.SetLength(size); _readStream.Seek(pos, SeekOrigin.Begin); @@ -268,7 +268,7 @@ public bool TryGetStreams(int id, [NotNullWhen(true)] out StreamBox? streams) { public StreamBox GetStreams(int id) { if (TryGetStreams(id, out StreamBox? streams)) { - return streams; + return streams; } throw PythonOps.OSError(9, "Bad file descriptor"); } @@ -290,7 +290,7 @@ public void EnsureRefStreams(StreamBox streams) { public void AddRefStreams(StreamBox streams) { Debug.Assert(streams.Id >= 0); - _refs.AddOrUpdate(streams.ReadStream, 1, (_, v) => v + 1); + _refs.AddOrUpdate(streams.ReadStream, 1, (_, v) => v + 1); } public bool DerefStreamsAndCloseIfLast(StreamBox streams) { diff --git a/src/ipy/IronPython/Runtime/PythonFunction.cs b/src/ipy/IronPython/Runtime/PythonFunction.cs index 26976433f..104dd3bf2 100644 --- a/src/ipy/IronPython/Runtime/PythonFunction.cs +++ b/src/ipy/IronPython/Runtime/PythonFunction.cs @@ -99,7 +99,7 @@ internal PythonFunction(CodeContext/*!*/ context, FunctionCode funcInfo, object _annotations = annotations ?? new PythonDictionary(); Debug.Assert(_defaults.Length <= _code.co_argcount); - Debug.Assert((__kwdefaults__?.Count ?? 0) <= _code.co_kwonlyargcount); + Debug.Assert((__kwdefaults__ ?.Count ?? 0) <= _code.co_kwonlyargcount); if (modName != Uninitialized.Instance) { _module = modName; } @@ -211,7 +211,7 @@ public object __module__ { public FunctionCode __code__ { get { - return _code; + return _code; } set { if (value == null) { @@ -226,7 +226,7 @@ public object __call__(CodeContext/*!*/ context, params object[] args) { return PythonCalls.Call(context, this, args); } - public object __call__(CodeContext/*!*/ context, [ParamDictionary] IDictionary dict, params object[] args) { + public object __call__(CodeContext/*!*/ context, [ParamDictionary]IDictionary dict, params object[] args) { return PythonCalls.CallWithKeywordArgs(context, this, args, dict); } @@ -417,7 +417,7 @@ internal Exception BadKeywordArgumentError(int count) { } #endregion - + #region Custom member lookup operators IList IMembersList.GetMemberNames() { @@ -471,7 +471,7 @@ internal PythonDictionary EnsureDict() { } return _dict; } - + internal static int AddRecursionDepth(int change) { // ManagedThreadId starts at 1 and increases as we get more threads. // Therefore we keep track of a limited number of threads in an array @@ -523,7 +523,8 @@ internal override bool TryGetValue(CodeContext context, object instance, PythonT } [PythonType("cell")] - public sealed class ClosureCell : ICodeFormattable { + public sealed class ClosureCell : ICodeFormattable + { [PythonHidden] public object Value; diff --git a/src/ipy/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs b/src/ipy/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs index 391d7e488..30cd90a43 100644 --- a/src/ipy/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs +++ b/src/ipy/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs @@ -1,4 +1,7 @@ using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; namespace IronPython.Runtime { /// diff --git a/src/ipy/IronPython/Runtime/PythonList.cs b/src/ipy/IronPython/Runtime/PythonList.cs index 69459f751..6c491ba2f 100644 --- a/src/ipy/IronPython/Runtime/PythonList.cs +++ b/src/ipy/IronPython/Runtime/PythonList.cs @@ -12,14 +12,15 @@ using System.Text; using System.Threading; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using Microsoft.Scripting; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Exceptions; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + using SpecialNameAttribute = System.Runtime.CompilerServices.SpecialNameAttribute; namespace IronPython.Runtime { diff --git a/src/ipy/IronPython/Runtime/PythonModule.cs b/src/ipy/IronPython/Runtime/PythonModule.cs index 440b6f49a..377f856b3 100644 --- a/src/ipy/IronPython/Runtime/PythonModule.cs +++ b/src/ipy/IronPython/Runtime/PythonModule.cs @@ -10,14 +10,14 @@ using System.Runtime.CompilerServices; using System.Threading; -using IronPython.Runtime.Binding; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using Microsoft.Scripting; using Microsoft.Scripting.Ast; using Microsoft.Scripting.Runtime; +using IronPython.Runtime.Binding; +using IronPython.Runtime.Operations; +using IronPython.Runtime.Types; + namespace IronPython.Runtime { /// /// Python module. Stores classes, functions, and data. Usually a module @@ -69,7 +69,7 @@ internal PythonModule(PythonDictionary dict) { } [StaticExtensionMethod] - public static PythonModule/*!*/ __new__(CodeContext/*!*/ context, PythonType/*!*/ cls, [ParamDictionary] IDictionary kwDict0, params object[]/*!*/ args\u00F8) { + public static PythonModule/*!*/ __new__(CodeContext/*!*/ context, PythonType/*!*/ cls, [ParamDictionary]IDictionary kwDict0, params object[]/*!*/ args\u00F8) { return __new__(context, cls, args\u00F8); } @@ -255,7 +255,7 @@ public DynamicMetaObject GetMember(PythonGetMemberBinder member, DynamicMetaObje private DynamicMetaObject GetMemberWorker(DynamicMetaObjectBinder binder, DynamicMetaObject codeContext) { string name = GetGetMemberName(binder); - var tmp = Expression.Variable(typeof(object), "res"); + var tmp = Expression.Variable(typeof(object), "res"); return new DynamicMetaObject( Expression.Block( @@ -360,7 +360,7 @@ IList IMembersList.GetMemberNames() { } #endregion - + internal class DebugProxy { private readonly PythonModule _module; @@ -380,6 +380,6 @@ public List Members { } } - + } } diff --git a/src/ipy/IronPython/Runtime/PythonOptions.cs b/src/ipy/IronPython/Runtime/PythonOptions.cs index 3bde88d31..92125273f 100644 --- a/src/ipy/IronPython/Runtime/PythonOptions.cs +++ b/src/ipy/IronPython/Runtime/PythonOptions.cs @@ -134,7 +134,7 @@ public sealed class PythonOptions : LanguageOptions { internal bool NoImportLib { get; } // TODO: get rid of me when we no longer bootstrap importlib - public PythonOptions() + public PythonOptions() : this(null) { } @@ -172,8 +172,8 @@ private static IDictionary EnsureSearchPaths(IDictionary() { { "SearchPaths", new[] { "." } } }; } else if (!options.ContainsKey("SearchPaths")) { - options["SearchPaths"] = new[] { "." }; - } + options["SearchPaths"] = new [] { "." }; + } return options; } diff --git a/src/ipy/IronPython/Runtime/PythonScopeExtension.cs b/src/ipy/IronPython/Runtime/PythonScopeExtension.cs index bad00ed33..3adb330b5 100644 --- a/src/ipy/IronPython/Runtime/PythonScopeExtension.cs +++ b/src/ipy/IronPython/Runtime/PythonScopeExtension.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; using System.Collections.Generic; using System.Threading; diff --git a/src/ipy/IronPython/Runtime/PythonStrIterator.cs b/src/ipy/IronPython/Runtime/PythonStrIterator.cs index 02c04b350..29f390338 100644 --- a/src/ipy/IronPython/Runtime/PythonStrIterator.cs +++ b/src/ipy/IronPython/Runtime/PythonStrIterator.cs @@ -7,12 +7,12 @@ using System.Collections; using System.Collections.Generic; -using IronPython.Runtime.Operations; -using IronPython.Runtime.Types; - using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Types; +using IronPython.Runtime.Operations; + namespace IronPython.Runtime { // note: any changes in how this iterator works should also be applied in the // optimized overloads of Builtins.map() diff --git a/src/ipy/IronPython/Runtime/PythonTracebackListener.cs b/src/ipy/IronPython/Runtime/PythonTracebackListener.cs index cd1f81629..ab96e1027 100644 --- a/src/ipy/IronPython/Runtime/PythonTracebackListener.cs +++ b/src/ipy/IronPython/Runtime/PythonTracebackListener.cs @@ -5,13 +5,13 @@ using System; using System.Collections.Generic; +using Microsoft.Scripting; + using IronPython.Modules; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting; - using Debugging = Microsoft.Scripting.Debugging; namespace IronPython.Runtime { @@ -21,7 +21,7 @@ internal sealed class PythonTracebackListener : Debugging.ITraceCallback { private TracebackDelegate _traceDispatch; private bool _inTraceBack; private bool _exceptionThrown; - + #if PROFILE_SUPPORT private bool _profile; #endif @@ -72,7 +72,7 @@ internal void SetProfile(TracebackDelegate traceDispatch) { #region ITraceCallback Members - public void OnTraceEvent(Debugging.TraceEventKind kind, string name, string sourceFileName, SourceSpan sourceSpan, Func> scopeCallback, object payload, object customPayload) { + public void OnTraceEvent(Debugging.TraceEventKind kind, string name, string sourceFileName, SourceSpan sourceSpan, Func> scopeCallback, object payload, object customPayload) { if (kind == Debugging.TraceEventKind.ThreadExit || // We don't care about thread-exit events #if PROFILE_SUPPORT (_profile && kind == Debugging.TraceEventKind.TracePoint) || // Ignore code execute tracebacks when in profile mode @@ -111,7 +111,7 @@ public void OnTraceEvent(Debugging.TraceEventKind kind, string name, string sour if (traceDispatchObject == null) { return; } - + pyFrame.Setf_trace(traceDispatchObject); } else { if (thread.Count == 0) { @@ -141,12 +141,12 @@ public void OnTraceEvent(Debugging.TraceEventKind kind, string name, string sour thread.RemoveAt(thread.Count - 1); } } - } + } } #endregion - + private void DispatchTrace(List thread, Debugging.TraceEventKind kind, object payload, TracebackDelegate traceDispatch, object traceDispatchObject, TraceBackFrame pyFrame) { object args = null; diff --git a/src/ipy/IronPython/Runtime/PythonTuple.cs b/src/ipy/IronPython/Runtime/PythonTuple.cs index 896f58f32..ad5f35e63 100644 --- a/src/ipy/IronPython/Runtime/PythonTuple.cs +++ b/src/ipy/IronPython/Runtime/PythonTuple.cs @@ -13,6 +13,7 @@ using System.Numerics; using System.Text; +using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; @@ -28,7 +29,7 @@ public class PythonTuple : IList, IList, ICodeFormattable, IExpressionS internal static readonly PythonTuple EMPTY = new PythonTuple(); - public PythonTuple([AllowNull] object o) { + public PythonTuple([AllowNull]object o) { _data = MakeItems(o); } diff --git a/src/ipy/IronPython/Runtime/PythonTypeAttribute.cs b/src/ipy/IronPython/Runtime/PythonTypeAttribute.cs index c05b5d966..32bb9e576 100644 --- a/src/ipy/IronPython/Runtime/PythonTypeAttribute.cs +++ b/src/ipy/IronPython/Runtime/PythonTypeAttribute.cs @@ -3,6 +3,8 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; +using System.Text; namespace IronPython.Runtime { /// diff --git a/src/ipy/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs b/src/ipy/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs index 53418ded7..2b6f3e216 100644 --- a/src/ipy/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs +++ b/src/ipy/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs @@ -4,6 +4,7 @@ #nullable enable +using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/src/ipy/IronPython/Runtime/ScopeDictionaryStorage.cs b/src/ipy/IronPython/Runtime/ScopeDictionaryStorage.cs index 06cb991ad..f472db7a2 100644 --- a/src/ipy/IronPython/Runtime/ScopeDictionaryStorage.cs +++ b/src/ipy/IronPython/Runtime/ScopeDictionaryStorage.cs @@ -2,13 +2,15 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; using System.Collections.Generic; -using IronPython.Runtime.Operations; - +using Microsoft.Scripting; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Operations; + namespace IronPython.Runtime { /// /// Provides dictionary based storage which is backed by a Scope object. diff --git a/src/ipy/IronPython/Runtime/SequenceTypeInfoAttribute.cs b/src/ipy/IronPython/Runtime/SequenceTypeInfoAttribute.cs index 02bc634f7..87fdd716c 100644 --- a/src/ipy/IronPython/Runtime/SequenceTypeInfoAttribute.cs +++ b/src/ipy/IronPython/Runtime/SequenceTypeInfoAttribute.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Text; using System.Collections.ObjectModel; namespace IronPython.Runtime { @@ -12,13 +14,13 @@ namespace IronPython.Runtime { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments"), AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, AllowMultiple = false)] public sealed class SequenceTypeInfoAttribute : Attribute { private readonly ReadOnlyCollection _types; - + public SequenceTypeInfoAttribute(params Type[] types) { _types = new ReadOnlyCollection(types); } public ReadOnlyCollection Types { - get { + get{ return _types; } } diff --git a/src/ipy/IronPython/Runtime/SetStorage.cs b/src/ipy/IronPython/Runtime/SetStorage.cs index 966a0621c..10ec4eb01 100644 --- a/src/ipy/IronPython/Runtime/SetStorage.cs +++ b/src/ipy/IronPython/Runtime/SetStorage.cs @@ -9,12 +9,14 @@ using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Text; +using System.Threading; + +using Microsoft.Scripting; +using Microsoft.Scripting.Utils; using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting.Utils; - namespace IronPython.Runtime { /// /// General-purpose storage used for Python sets and frozensets. @@ -187,7 +189,7 @@ private static bool AddWorker( private void AddOrRemoveWorker(object/*!*/ item, int hashCode) { Debug.Assert(_buckets != null); Debug.Assert(item != null); - + for (int index = hashCode & (_buckets.Length - 1); ; ProbeNext(_buckets, ref index)) { Bucket bucket = _buckets[index]; if (bucket.Item == null) { @@ -316,7 +318,7 @@ public bool ContainsAlwaysHash(object item) { hashCode = _genericHash(item); eqFunc = _genericEquals; } - + return _count > 0 && ContainsWorker(_buckets, item, hashCode, eqFunc); } @@ -533,7 +535,7 @@ public bool IsDisjoint(SetStorage other) { public static bool IsDisjoint(SetStorage self, SetStorage other) { SortBySize(ref self, ref other); - + if (self._hasNull && other._hasNull) { return false; } @@ -623,7 +625,7 @@ public void UnionUpdate(SetStorage other) { Bucket[] otherBuckets = other._buckets; UpdateHelperFunctions(other); - + for (int i = 0; i < otherBuckets.Length; i++) { Bucket bucket = otherBuckets[i]; if (bucket.Item != null && bucket.Item != Removed) { @@ -709,7 +711,7 @@ public void DifferenceUpdate(SetStorage other) { Bucket bucket = buckets[i]; if (bucket.Item != null && bucket.Item != Removed && ContainsWorker(otherBuckets, bucket.Item, bucket.HashCode, eqFunc)) { - RemoveWorker(bucket.Item, bucket.HashCode, eqFunc); + RemoveWorker(bucket.Item, bucket.HashCode, eqFunc); } } } else { @@ -835,7 +837,7 @@ public static bool Equals(SetStorage x, SetStorage y, IEqualityComparer comparer if (object.ReferenceEquals(x, y)) { return true; } - + if (x._count != y._count || (x._hasNull ^ y._hasNull)) { return false; } @@ -1136,9 +1138,9 @@ private static Func GetEqFunc(SetStorage self, SetStorage internal static void SortBySize(ref SetStorage x, ref SetStorage y) { if (x._count > 0 && ((y._count > 0 && x._buckets.Length > y._buckets.Length) || y._count == 0)) { - SetStorage temp = x; - x = y; - y = temp; + SetStorage temp = x; + x = y; + y = temp; } } diff --git a/src/ipy/IronPython/Runtime/Slice.cs b/src/ipy/IronPython/Runtime/Slice.cs index af8102f70..c242caeb1 100644 --- a/src/ipy/IronPython/Runtime/Slice.cs +++ b/src/ipy/IronPython/Runtime/Slice.cs @@ -91,9 +91,9 @@ public int __hash__() { public bool __ne__([NotNone] Slice other) => !Equals(other); - public static object? operator >([NotNone] Slice self, [NotNone] Slice other) => self.ToTuple() < other.ToTuple(); + public static object? operator >([NotNone] Slice self, [NotNone] Slice other)=> self.ToTuple() < other.ToTuple(); - public static object? operator <([NotNone] Slice self, [NotNone] Slice other) => self.ToTuple() < other.ToTuple(); + public static object? operator <([NotNone] Slice self, [NotNone] Slice other)=> self.ToTuple() < other.ToTuple(); public static object? operator >=([NotNone] Slice self, [NotNone] Slice other) => self.ToTuple() >= other.ToTuple(); diff --git a/src/ipy/IronPython/Runtime/StringDictionaryStorage.cs b/src/ipy/IronPython/Runtime/StringDictionaryStorage.cs index f1824b1ad..2bde1c38f 100644 --- a/src/ipy/IronPython/Runtime/StringDictionaryStorage.cs +++ b/src/ipy/IronPython/Runtime/StringDictionaryStorage.cs @@ -9,6 +9,7 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using Microsoft.Scripting; using Microsoft.Scripting.Runtime; namespace IronPython.Runtime { @@ -201,6 +202,6 @@ private void EnsureData() { private object ToNonNullKey(object? key) => key is null ? _nullkey : key; - private object? FromNonNullKey(object key) => key == _nullkey ? null : key; + private object? FromNonNullKey(object key) => key == _nullkey? null : key; } } diff --git a/src/ipy/IronPython/Runtime/StringFormatSpec.cs b/src/ipy/IronPython/Runtime/StringFormatSpec.cs index 27e2161c0..054ac58c9 100644 --- a/src/ipy/IronPython/Runtime/StringFormatSpec.cs +++ b/src/ipy/IronPython/Runtime/StringFormatSpec.cs @@ -3,11 +3,15 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; +using System.Text; +using System.Diagnostics; -using IronPython.Runtime.Operations; - +using Microsoft.Scripting; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Operations; + namespace IronPython.Runtime { /// /// Provides a representation and parsing for the default formatting specification. This is used @@ -309,7 +313,7 @@ private StringFormatSpec(char? fill, char? alignment, char? sign, int? width, bo text = FinishText(text, sign, type); } - + return text; } diff --git a/src/ipy/IronPython/Runtime/Super.cs b/src/ipy/IronPython/Runtime/Super.cs index 6997b4696..85ee282c6 100644 --- a/src/ipy/IronPython/Runtime/Super.cs +++ b/src/ipy/IronPython/Runtime/Super.cs @@ -10,11 +10,12 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; +using Microsoft.Scripting; +using Microsoft.Scripting.Runtime; + using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting.Runtime; - namespace IronPython.Runtime { [PythonType("super")] public class Super : PythonTypeSlot, ICodeFormattable { @@ -116,7 +117,7 @@ public object? __self_class__ { } #endregion - + #region Custom member access [SpecialName] @@ -150,7 +151,7 @@ public object GetCustomMember(CodeContext context, [NotNone] string name) { // above us until we get a hit. lookupType++; while (lookupType < mro.Count) { - + if (TryLookupInBase(context, mro[lookupType], name, self, out value)) return value; @@ -188,7 +189,7 @@ private bool TryLookupInBase(CodeContext context, PythonType pt, string name, ob private PythonType? DescriptorContext { get { if (!DynamicHelpers.GetPythonType(_self).IsSubclassOf(_thisClass)) { - if (_self == _selfClass) // Using @classmethod + if(_self == _selfClass) // Using @classmethod return _selfClass as PythonType ?? _thisClass; return _thisClass; } diff --git a/src/ipy/IronPython/Runtime/ThrowingErrorSink.cs b/src/ipy/IronPython/Runtime/ThrowingErrorSink.cs index 8bb8d4329..a2ea488f0 100644 --- a/src/ipy/IronPython/Runtime/ThrowingErrorSink.cs +++ b/src/ipy/IronPython/Runtime/ThrowingErrorSink.cs @@ -2,10 +2,10 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using IronPython.Runtime.Operations; - using Microsoft.Scripting; +using IronPython.Runtime.Operations; + namespace IronPython.Runtime { internal class ThrowingErrorSink : ErrorSink { public static new readonly ThrowingErrorSink/*!*/ Default = new ThrowingErrorSink(); diff --git a/src/ipy/IronPython/Runtime/TypecodeOps.cs b/src/ipy/IronPython/Runtime/TypecodeOps.cs index 4fc708b79..e11e97ae1 100644 --- a/src/ipy/IronPython/Runtime/TypecodeOps.cs +++ b/src/ipy/IronPython/Runtime/TypecodeOps.cs @@ -10,6 +10,7 @@ using System.Runtime.InteropServices; using IronPython.Runtime.Operations; +using Microsoft.Scripting.Utils; namespace IronPython.Runtime { internal static class TypecodeOps { @@ -80,7 +81,7 @@ public static int GetTypecodeWidth(char typecode) { } } - public static bool TryGetFromBytes(char typecode, ReadOnlySpan bytes, [NotNullWhen(true)] out object? result) { + public static bool TryGetFromBytes(char typecode, ReadOnlySpan bytes, [NotNullWhen(true)]out object? result) { switch (typecode) { case 'c': result = Bytes.FromByte(bytes[0]); diff --git a/src/ipy/IronPython/Runtime/Types/BuiltinFunction.cs b/src/ipy/IronPython/Runtime/Types/BuiltinFunction.cs index 6553ac951..aa3abf12c 100644 --- a/src/ipy/IronPython/Runtime/Types/BuiltinFunction.cs +++ b/src/ipy/IronPython/Runtime/Types/BuiltinFunction.cs @@ -2,26 +2,27 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; -using System.Dynamic; -using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; +using System.Dynamic; using System.Text; using System.Threading; -using IronPython.Runtime.Binding; -using IronPython.Runtime.Operations; - using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Actions.Calls; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Binding; +using IronPython.Runtime.Operations; + namespace IronPython.Runtime.Types { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; diff --git a/src/ipy/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs b/src/ipy/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs index bebb7021a..bdacd5e3b 100644 --- a/src/ipy/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs +++ b/src/ipy/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs @@ -7,10 +7,10 @@ using System.Reflection; using System.Threading; -using IronPython.Runtime.Operations; - using Microsoft.Scripting.Runtime; +using IronPython.Runtime.Operations; + namespace IronPython.Runtime.Types { // Used to map signatures to specific targets on the embedded reflected method. @@ -62,7 +62,7 @@ private object GetOverload(Type[] sig, IList targets, bool wrapCtors if (wrapCtors) { return GetTargetFunction(bf); - } + } return bf; } diff --git a/src/ipy/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs b/src/ipy/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs index 4a08dd651..e9d4f07c1 100644 --- a/src/ipy/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs +++ b/src/ipy/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs @@ -2,17 +2,19 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; using System.Collections.Generic; using System.Dynamic; -using System.Linq.Expressions; using System.Runtime.CompilerServices; -using IronPython.Runtime.Binding; -using IronPython.Runtime.Operations; - using Microsoft.Scripting; using Microsoft.Scripting.Generation; +using Microsoft.Scripting.Utils; + +using IronPython.Runtime.Binding; +using IronPython.Runtime.Operations; namespace IronPython.Runtime.Types { using Ast = Expression; @@ -101,7 +103,7 @@ private void CheckSelf(CodeContext/*!*/ context, object self) { } #endregion - + #region Public Python API public string __name__ { @@ -116,7 +118,7 @@ public string __doc__ { } } - public object __call__(CodeContext context, SiteLocalStorage, object>>> storage, [ParamDictionary] IDictionary dictArgs, params object[] args) { + public object __call__(CodeContext context, SiteLocalStorage, object>>> storage, [ParamDictionary]IDictionary dictArgs, params object[] args) { return _template.__call__(context, storage, dictArgs, args); } diff --git a/src/ipy/IronPython/Runtime/Types/CachedNewTypeInfo.cs b/src/ipy/IronPython/Runtime/Types/CachedNewTypeInfo.cs index 570ecd3c2..b3f1d7337 100644 --- a/src/ipy/IronPython/Runtime/Types/CachedNewTypeInfo.cs +++ b/src/ipy/IronPython/Runtime/Types/CachedNewTypeInfo.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; - +using System.Text; using Microsoft.Scripting.Utils; namespace IronPython.Runtime.Types { diff --git a/src/ipy/IronPython/Runtime/Types/ConstructorFunction.cs b/src/ipy/IronPython/Runtime/Types/ConstructorFunction.cs index b1bc94f4b..37e936e9a 100644 --- a/src/ipy/IronPython/Runtime/Types/ConstructorFunction.cs +++ b/src/ipy/IronPython/Runtime/Types/ConstructorFunction.cs @@ -4,9 +4,10 @@ using System.Collections.Generic; using System.Reflection; -using System.Text; - using Microsoft.Scripting.Utils; +using System.Text; +using IronPython.Runtime.Operations; +using Microsoft.Scripting; namespace IronPython.Runtime.Types { [PythonType("builtin_function_or_method")] diff --git a/src/ipy/IronPython/Runtime/Types/CustomAttributeTracker.cs b/src/ipy/IronPython/Runtime/Types/CustomAttributeTracker.cs index f244b1785..e211d2514 100644 --- a/src/ipy/IronPython/Runtime/Types/CustomAttributeTracker.cs +++ b/src/ipy/IronPython/Runtime/Types/CustomAttributeTracker.cs @@ -2,19 +2,21 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; using System.Collections.Generic; using System.Diagnostics; using System.Dynamic; -using System.Linq.Expressions; using System.Reflection; -using IronPython.Runtime.Binding; -using IronPython.Runtime.Operations; - +using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Actions.Calls; +using IronPython.Runtime.Binding; +using IronPython.Runtime.Operations; + namespace IronPython.Runtime.Types { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -129,10 +131,10 @@ public override Type DeclaringType { internal class ClassMethodTracker : PythonCustomTracker { private MethodTracker/*!*/[]/*!*/ _trackers; - + public ClassMethodTracker(MemberGroup/*!*/ group) { List trackers = new List(group.Count); - + foreach (MethodTracker mt in group) { trackers.Add(mt); } @@ -183,8 +185,8 @@ public OperatorTracker(Type/*!*/ declaringType, string/*!*/ name, bool reversed, _reversed = reversed; _trackers = members; _name = name; - } - + } + public override PythonTypeSlot/*!*/ GetSlot() { List meths = new List(); foreach (MethodTracker mt in _trackers) { @@ -207,7 +209,7 @@ public OperatorTracker(Type/*!*/ declaringType, string/*!*/ name, bool reversed, } } - return PythonTypeOps.GetFinalSlotForFunction(PythonTypeOps.GetBuiltinFunction(DeclaringType, + return PythonTypeOps.GetFinalSlotForFunction(PythonTypeOps.GetBuiltinFunction(DeclaringType, Name, ft, meths.ToArray() diff --git a/src/ipy/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs b/src/ipy/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs index 4b052e7cd..1048c8d17 100644 --- a/src/ipy/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs +++ b/src/ipy/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs @@ -6,10 +6,10 @@ using System; using System.Collections.Generic; -using System.Threading; - +using System.Diagnostics; using Microsoft.Scripting; using Microsoft.Scripting.Runtime; +using System.Threading; namespace IronPython.Runtime.Types { /// @@ -113,7 +113,7 @@ public override bool TryGetValue(object? key, out object? value) { } public override int Count { - get { + get { int count = base.Count; foreach (object? o in _values) { if (o != Uninitialized.Instance) { @@ -171,7 +171,7 @@ public int FindKey(string key) { public bool TryGetValue(int index, out object? value) { value = _values[index]; return value != Uninitialized.Instance; - } + } public void SetExtraValue(int index, object? value) { _values[index] = value; diff --git a/src/ipy/IronPython/Runtime/Types/DocBuilder.cs b/src/ipy/IronPython/Runtime/Types/DocBuilder.cs index 4fc0ac47b..e2aca6332 100644 --- a/src/ipy/IronPython/Runtime/Types/DocBuilder.cs +++ b/src/ipy/IronPython/Runtime/Types/DocBuilder.cs @@ -9,11 +9,12 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Text; - +using System.Threading; using Microsoft.Scripting; using Microsoft.Scripting.Hosting; using Microsoft.Scripting.Runtime; @@ -21,7 +22,7 @@ namespace IronPython.Runtime.Types { internal static class DocBuilder { - + internal static string GetDefaultDocumentation(string methodName) { switch (methodName) { case "__abs__": return "x.__abs__() <==> abs(x)"; @@ -155,8 +156,8 @@ public static string CreateAutoDoc(Type t) { summary = String.Concat( summary, - Environment.NewLine, Environment.NewLine, - "enum ", t.IsDefined(typeof(FlagsAttribute), false) ? "(flags) " : "", GetPythonTypeName(t), ", values: ", + Environment.NewLine, Environment.NewLine, + "enum ", t.IsDefined(typeof(FlagsAttribute), false) ? "(flags) ": "", GetPythonTypeName(t), ", values: ", String.Join(", ", names)); } return summary; @@ -219,7 +220,7 @@ public static OverloadDoc GetOverloadDoc(MethodBase info, string name, int endPa name = mi.Name.Substring(0, hashIndex); } } - } else if (name == null) { + } else if(name == null) { name = "__new__"; } @@ -309,11 +310,11 @@ public static OverloadDoc GetOverloadDoc(MethodBase info, string name, int endPa ) ); } - + if (returnCount > 1) { retType.Append(')'); } - + ParameterDoc retDoc = new ParameterDoc(String.Empty, retType.ToString(), returns); return new OverloadDoc( @@ -474,7 +475,7 @@ private static string GetXmlName(MethodBase info) { /// Converts a Type object into a string suitable for lookup in the help file. All generic types are /// converted down to their generic type definition. /// - private static void AppendTypeFormat(Type curType, StringBuilder res, ParameterInfo pi = null) { + private static void AppendTypeFormat(Type curType, StringBuilder res, ParameterInfo pi=null) { if (curType.IsGenericType) { curType = curType.GetGenericTypeDefinition(); } @@ -503,7 +504,7 @@ private static void AppendTypeFormat(Type curType, StringBuilder res, ParameterI res.Append('}'); } else { if (pi != null) { - if ((pi.IsOut || pi.ParameterType.IsByRef) && curType.FullName.EndsWith('&')) { + if((pi.IsOut || pi.ParameterType.IsByRef) && curType.FullName.EndsWith('&')) { res.Append(curType.FullName.Replace("&", "@")); } else { res.Append(curType.FullName); @@ -571,7 +572,7 @@ private static XPathDocument GetXPathDocument(Assembly asm) { // for 64-bit processes, we need to look in Program Files (x86) xml = Path.Combine( Path.Combine( - Environment.GetFolderPath(Environment.Is64BitProcess ? Environment.SpecialFolder.ProgramFilesX86 : Environment.SpecialFolder.ProgramFiles), + Environment.GetFolderPath(Environment.Is64BitProcess ? Environment.SpecialFolder.ProgramFilesX86 : Environment.SpecialFolder.ProgramFiles), _frameworkReferencePath ), baseFile @@ -673,7 +674,7 @@ private static void GetXmlDoc(Type type, out string summary) { case "summary": summary = XmlToString(iter); break; } } - } + } /// /// Gets the Xml documentation for the specified Field. diff --git a/src/ipy/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs b/src/ipy/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs index 7c63b5065..07f78895e 100644 --- a/src/ipy/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs +++ b/src/ipy/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs @@ -16,7 +16,7 @@ namespace IronPython.Runtime.Types { /// Dictionary-based storage needs to be provided for setting individual members /// Virtual methods exposed to Python need to support checking the types dictionary for invocations /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] + [AttributeUsage(AttributeTargets.Class, AllowMultiple=false, Inherited=true)] internal sealed class DynamicBaseTypeAttribute : Attribute { } } diff --git a/src/ipy/IronPython/Runtime/Types/EmptyType.cs b/src/ipy/IronPython/Runtime/Types/EmptyType.cs index df9508408..bb93fd268 100644 --- a/src/ipy/IronPython/Runtime/Types/EmptyType.cs +++ b/src/ipy/IronPython/Runtime/Types/EmptyType.cs @@ -15,7 +15,7 @@ namespace IronPython.Runtime.Types { [PythonType("ellipsis"), Documentation(null)] public sealed class Ellipsis : ICodeFormattable { private static Ellipsis? _instance; - + private Ellipsis() { } internal static Ellipsis Value { @@ -50,9 +50,9 @@ public int __hash__() { [PythonType("NotImplementedType"), Documentation(null)] public sealed class NotImplementedType : ICodeFormattable { private static NotImplementedType? _instance; - + private NotImplementedType() { } - + internal static NotImplementedType Value { get { if (_instance == null) { diff --git a/src/ipy/IronPython/Runtime/Types/ExtensionPropertyInfo.cs b/src/ipy/IronPython/Runtime/Types/ExtensionPropertyInfo.cs index 0b0562f2b..25829373e 100644 --- a/src/ipy/IronPython/Runtime/Types/ExtensionPropertyInfo.cs +++ b/src/ipy/IronPython/Runtime/Types/ExtensionPropertyInfo.cs @@ -26,9 +26,9 @@ public ExtensionPropertyInfo(Type logicalDeclaringType, MethodInfo mi) { if (methodName.StartsWith("Get", StringComparison.Ordinal) || methodName.StartsWith("Set", StringComparison.Ordinal)) { GetPropertyMethods(mi, methodName, prefix, "Get", "Set", "Delete"); - } else if (methodName.StartsWith("get_", StringComparison.Ordinal) || methodName.StartsWith("set_", StringComparison.Ordinal)) { + } else if(methodName.StartsWith("get_", StringComparison.Ordinal) || methodName.StartsWith("set_", StringComparison.Ordinal)) { GetPropertyMethods(mi, methodName, prefix, "get_", "set_", null); - } + } #if FEATURE_REFEMIT else if (methodName.StartsWith(NewTypeMaker.FieldGetterPrefix, StringComparison.Ordinal) || methodName.StartsWith(NewTypeMaker.FieldSetterPrefix, StringComparison.Ordinal)) { GetPropertyMethods(mi, methodName, prefix, NewTypeMaker.FieldGetterPrefix, NewTypeMaker.FieldSetterPrefix, null); diff --git a/src/ipy/IronPython/Runtime/Types/IPythonObject.cs b/src/ipy/IronPython/Runtime/Types/IPythonObject.cs index 3a2cdb5d0..ddb80f12f 100644 --- a/src/ipy/IronPython/Runtime/Types/IPythonObject.cs +++ b/src/ipy/IronPython/Runtime/Types/IPythonObject.cs @@ -2,6 +2,9 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; +using Microsoft.Scripting; + namespace IronPython.Runtime.Types { /// /// This interface is used for implementing parts of the IronPython type system. It diff --git a/src/ipy/IronPython/Runtime/Types/InstanceCreator.cs b/src/ipy/IronPython/Runtime/Types/InstanceCreator.cs index d668e2ab6..db81d2a18 100644 --- a/src/ipy/IronPython/Runtime/Types/InstanceCreator.cs +++ b/src/ipy/IronPython/Runtime/Types/InstanceCreator.cs @@ -5,9 +5,8 @@ using System; using System.Runtime.CompilerServices; using System.Threading; - +using IronPython.Runtime.Binding; using IronPython.Runtime.Operations; - using Microsoft.Scripting.Actions; using Microsoft.Scripting.Utils; diff --git a/src/ipy/IronPython/Runtime/Types/NameConverter.cs b/src/ipy/IronPython/Runtime/Types/NameConverter.cs index aa0eff0af..430862243 100644 --- a/src/ipy/IronPython/Runtime/Types/NameConverter.cs +++ b/src/ipy/IronPython/Runtime/Types/NameConverter.cs @@ -4,12 +4,12 @@ using System; using System.Reflection; -using System.Text; - -using IronPython.Runtime.Binding; - using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using System.Text; +using IronPython.Runtime; +using IronPython.Runtime.Binding; +using IronPython.Runtime.Types; namespace IronPython.Runtime.Types { /// @@ -21,7 +21,7 @@ public static NameType TryGetName(PythonType dt, MethodInfo mi, out string name) return GetNameFromMethod(dt, mi, NameType.Method, ref name); } - + public static NameType TryGetName(PythonType dt, EventInfo ei, MethodInfo eventMethod, out string name) { name = ei.Name; NameType res = dt.IsPythonType ? NameType.PythonEvent : NameType.Event; @@ -63,7 +63,7 @@ public static string GetTypeName(Type t) { sb.Append(GetTypeName(tof)); } sb.Append(']'); - name = sb.ToString(); + name = sb.ToString(); } return name; } diff --git a/src/ipy/IronPython/Runtime/Types/NewTypeInfo.cs b/src/ipy/IronPython/Runtime/Types/NewTypeInfo.cs index 71a9dc06c..6fb52bc34 100644 --- a/src/ipy/IronPython/Runtime/Types/NewTypeInfo.cs +++ b/src/ipy/IronPython/Runtime/Types/NewTypeInfo.cs @@ -3,10 +3,10 @@ // See the LICENSE file in the project root for more information. using System; +using System.Reflection; using System.Collections.Generic; using IronPython.Runtime.Operations; - using Microsoft.Scripting.Utils; namespace IronPython.Runtime.Types { @@ -159,6 +159,6 @@ public override bool Equals(object obj) { return true; } return false; - } + } } } diff --git a/src/ipy/IronPython/Runtime/Types/NewTypeMaker.cs b/src/ipy/IronPython/Runtime/Types/NewTypeMaker.cs index 012267f89..ab32c8de0 100644 --- a/src/ipy/IronPython/Runtime/Types/NewTypeMaker.cs +++ b/src/ipy/IronPython/Runtime/Types/NewTypeMaker.cs @@ -6,20 +6,20 @@ using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; -using System.Dynamic; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; +using System.Dynamic; using System.Text; -using IronPython.Runtime.Binding; -using IronPython.Runtime.Operations; - using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Binding; +using IronPython.Runtime.Operations; + namespace IronPython.Runtime.Types { /// /// Python class hierarchy is represented using the __class__ field in the object. It does not @@ -44,7 +44,7 @@ internal sealed class NewTypeMaker { private FieldInfo _dictField; private FieldInfo _slotsField; private FieldInfo _explicitMO; - + private ILGen _cctor; private int _site; @@ -70,7 +70,7 @@ internal sealed class NewTypeMaker { private static readonly Dictionary>> _overriddenMethods = new Dictionary>>(); [MultiRuntimeAware] private static readonly Dictionary>> _overriddenProperties = new Dictionary>>(); - + private NewTypeMaker(NewTypeInfo typeInfo) { _baseType = typeInfo.BaseType; @@ -105,7 +105,7 @@ private NewTypeMaker(NewTypeInfo typeInfo) { // creation code return new NewTypeMaker(typeInfo).CreateNewType(); }); - + return ret; } @@ -118,7 +118,7 @@ public static void SaveNewTypes(string assemblyName, IList types) { MethodBuilder mb = tb.DefineMethod(_constructorMethodName, MethodAttributes.Public | MethodAttributes.Static, typeof(CachedNewTypeInfo[]), ReflectionUtils.EmptyTypes); ILGenerator ilg = mb.GetILGenerator(); - + // new CachedTypeInfo[types.Count] // we leave this on the stack (duping it) and storing into it. EmitInt(ilg, types.Count); @@ -127,7 +127,7 @@ public static void SaveNewTypes(string assemblyName, IList types) { foreach (var v in types) { NewTypeInfo nti = NewTypeInfo.GetTypeInfo(String.Empty, v); - + var typeInfos = new NewTypeMaker(nti).SaveType(ag, "Python" + _typeCount++ + "$" + nti.BaseType.Name); // prepare for storing the element into our final array @@ -138,14 +138,14 @@ public static void SaveNewTypes(string assemblyName, IList types) { // load the type ilg.Emit(OpCodes.Ldtoken, typeInfos.Key); - ilg.Emit(OpCodes.Call, typeof(Type).GetMethod("GetTypeFromHandle")); + ilg.Emit(OpCodes.Call, typeof(Type).GetMethod("GetTypeFromHandle")); // create the dictionary of special names ilg.Emit(OpCodes.Newobj, typeof(Dictionary).GetConstructor(Array.Empty())); foreach (var specialName in typeInfos.Value) { // dup dict ilg.Emit(OpCodes.Dup); - + // emit key ilg.Emit(OpCodes.Ldstr, specialName.Key); @@ -161,7 +161,7 @@ public static void SaveNewTypes(string assemblyName, IList types) { } // assign to dict - ilg.Emit(OpCodes.Call, typeof(Dictionary).GetMethod("set_Item")); + ilg.Emit(OpCodes.Call, typeof(Dictionary).GetMethod("set_Item")); } // emit the interface types (if any) @@ -465,7 +465,7 @@ private void OverrideConstructor(ConstructorInfo parentConstructor) { MethodInfo init = typeof(PythonOps).GetMethod(nameof(PythonOps.InitializeUserTypeSlots)); il.EmitLoadArg(0); - + il.EmitLoadArg(typeArg); il.EmitCall(init); @@ -564,7 +564,7 @@ private bool NeedsPythonObject { private void ImplementDynamicObject() { // true if the user has explicitly included IDynamicMetaObjectProvider in the list of interfaces - bool explicitDynamicObject = false; + bool explicitDynamicObject = false; foreach (Type t in _interfaceTypes) { if (t == typeof(IDynamicMetaObjectProvider)) { explicitDynamicObject = true; @@ -634,7 +634,7 @@ private void ImplementDynamicObject() { il.Emit(OpCodes.Dup); il.Emit(OpCodes.Ldnull); il.Emit(OpCodes.Beq, retNull); - + // store the local value il.Emit(OpCodes.Stloc_S, retVal.LocalIndex); @@ -644,7 +644,7 @@ private void ImplementDynamicObject() { // user returned null, fallback to base impl il.MarkLabel(retNull); il.Emit(OpCodes.Pop); - + // no override exists il.MarkLabel(noOverride); @@ -665,7 +665,7 @@ private void ImplementDynamicObject() { il.EmitLoadArg(0); // this il.EmitLoadArg(1); // parameter - + // baseMetaObject if (baseIdo) { InterfaceMapping imap = _baseType.GetInterfaceMap(typeof(IDynamicMetaObjectProvider)); @@ -736,7 +736,7 @@ private void ImplementIPythonObject() { il.Emit(OpCodes.Ret); _tg.DefineMethodOverride(impl, decl); } - + // Types w/ DynamicBaseType attribute still need new slots implementation _slotsField = _tg.DefineField(SlotsAndWeakRefFieldName, typeof(object[]), FieldAttributes.Public); @@ -805,7 +805,7 @@ private void ImplementProtectedFieldAccessors(Dictionary speci // we need to create public helper methods that expose them. These methods are // used by the IDynamicMetaObjectProvider implementation (in MetaUserObject) - foreach (FieldInfo fi in _baseType.GetInheritedFields(flattenHierarchy: true)) { + foreach (FieldInfo fi in _baseType.GetInheritedFields(flattenHierarchy: true)) { if (!fi.IsProtected()) { continue; } @@ -901,13 +901,13 @@ private void OverrideMethods(Type type, Dictionary specialName added[key] = mi; } } - + if (type.IsAbstract && !type.IsInterface) { // abstract types can define interfaces w/o implementations foreach (Type iface in type.GetInterfaces()) { InterfaceMapping mapping = type.GetInterfaceMap(iface); for (int i = 0; i < mapping.TargetMethods.Length; i++) { - + if (mapping.TargetMethods[i] == null) { MethodInfo mi = mapping.InterfaceMethods[i]; @@ -1150,7 +1150,7 @@ private LocalBuilder EmitBaseClassCallCheckForProperties(ILGen il, MethodInfo ba // we're accessing a property return callTarget; } - + private MethodBuilder CreateVTableGetterOverride(MethodInfo mi, string name) { MethodBuilder impl; ILGen il; @@ -1274,7 +1274,7 @@ private MethodBuilder CreateVTableMethodOverride(MethodInfo mi, string name) { DefineVTableMethodOverride(mi, out impl, out il); //CompilerHelpers.GetArgumentNames(parameters)); TODO: Set names - LocalBuilder callTarget = EmitNonInheritedMethodLookup(name, il); + LocalBuilder callTarget = EmitNonInheritedMethodLookup(name, il); Label instanceCall = il.DefineLabel(); il.Emit(OpCodes.Brtrue, instanceCall); @@ -1603,7 +1603,7 @@ private static void AddBaseMethods(Type finishedType, Dictionary diff --git a/src/ipy/IronPython/Runtime/Types/PythonAssemblyOps.cs b/src/ipy/IronPython/Runtime/Types/PythonAssemblyOps.cs index 75695e2b2..c9afd3a8e 100644 --- a/src/ipy/IronPython/Runtime/Types/PythonAssemblyOps.cs +++ b/src/ipy/IronPython/Runtime/Types/PythonAssemblyOps.cs @@ -6,9 +6,7 @@ using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; - using IronPython.Runtime.Types; - using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Runtime; @@ -75,5 +73,5 @@ private static TopNamespaceTracker GetReflectedAssembly(CodeContext/*!*/ context return reflectedAssembly; } } - } + } } diff --git a/src/ipy/IronPython/Runtime/Types/PythonSiteCache.cs b/src/ipy/IronPython/Runtime/Types/PythonSiteCache.cs index 5820386ac..cbd0c8567 100644 --- a/src/ipy/IronPython/Runtime/Types/PythonSiteCache.cs +++ b/src/ipy/IronPython/Runtime/Types/PythonSiteCache.cs @@ -7,9 +7,11 @@ using System.Runtime.CompilerServices; using System.Threading; -using IronPython.Runtime.Operations; - +using Microsoft.Scripting; using Microsoft.Scripting.Actions; +using Microsoft.Scripting.Utils; + +using IronPython.Runtime.Operations; namespace IronPython.Runtime.Types { /// diff --git a/src/ipy/IronPython/Runtime/Types/PythonType.cs b/src/ipy/IronPython/Runtime/Types/PythonType.cs index c01703ada..77e70c573 100644 --- a/src/ipy/IronPython/Runtime/Types/PythonType.cs +++ b/src/ipy/IronPython/Runtime/Types/PythonType.cs @@ -504,7 +504,7 @@ public object __call__(CodeContext context, params object[] args) { return PythonTypeOps.CallParams(context, this, args); } - public object __call__(CodeContext context, [ParamDictionary] IDictionary kwArgs, params object[] args) { + public object __call__(CodeContext context, [ParamDictionary]IDictionary kwArgs, params object[] args) { return PythonTypeOps.CallWorker(context, this, kwArgs, args); } @@ -575,8 +575,8 @@ public object this[string member] { public static object Get__module__(CodeContext/*!*/ context, PythonType self) { PythonTypeSlot pts; object res; - if (self._dict != null && - self._dict.TryGetValue("__module__", out pts) && + if (self._dict != null && + self._dict.TryGetValue("__module__", out pts) && pts.TryGetValue(context, self, DynamicHelpers.GetPythonType(self), out res)) { return res; } @@ -638,7 +638,7 @@ public static void Set__qualname__(PythonType type, string name) { type.QualName = name; } - public static PythonDictionary __prepare__([ParamDictionary] IDictionary kwargs, params object[] args) + public static PythonDictionary __prepare__([ParamDictionary]IDictionary kwargs, params object[] args) => new PythonDictionary(); public string/*!*/ __repr__(CodeContext/*!*/ context) { @@ -789,13 +789,13 @@ internal IList ResolutionOrder { /// internal static PythonType/*!*/ GetPythonType(Type type) { object res; - + if (!_pythonTypes.TryGetValue(type, out res)) { lock (_pythonTypes) { if (!_pythonTypes.TryGetValue(type, out res)) { res = new PythonType(type); - _pythonTypes.Add(type, res); + _pythonTypes.Add(type, res); } } } @@ -873,7 +873,7 @@ internal object CreateInstance(CodeContext context, params object[] args) { case 1: return _instanceCtor.CreateInstance(context, args[0]); case 2: return _instanceCtor.CreateInstance(context, args[0], args[1]); case 3: return _instanceCtor.CreateInstance(context, args[0], args[1], args[2]); - default: + default: return _instanceCtor.CreateInstance(context, args); } } @@ -908,7 +908,7 @@ internal bool TryGetLength(CodeContext context, object o, out int length) { PythonTypeSlot lenSlot = _lenSlot; if (lenSlot == null && !PythonOps.TryResolveTypeSlot(context, this, "__len__", out lenSlot)) { length = 0; - return false; + return false; } object func; @@ -973,7 +973,7 @@ internal CallSite> HashSite { } private void EnsureHashSite() { - if (_hashSite == null) { + if(_hashSite == null) { Interlocked.CompareExchange( ref _hashSite, CallSite>.Create( @@ -1169,7 +1169,7 @@ internal bool IsHiddenMember(string name) { return !TryResolveSlot(DefaultContext.Default, name, out _) && TryResolveSlot(DefaultContext.DefaultCLS, name, out _); } - + internal LateBoundInitBinder GetLateBoundInitBinder(CallSignature signature) { Debug.Assert(!IsSystemType); // going to hold onto a PythonContext, shouldn't ever be a system type Debug.Assert(_pythonContext != null); @@ -1178,7 +1178,7 @@ internal LateBoundInitBinder GetLateBoundInitBinder(CallSignature signature) { Interlocked.CompareExchange(ref _lateBoundInitBinders, new Dictionary(), null); } - lock (_lateBoundInitBinders) { + lock(_lateBoundInitBinders) { LateBoundInitBinder res; if (!_lateBoundInitBinders.TryGetValue(signature, out res)) { _lateBoundInitBinders[signature] = res = new LateBoundInitBinder(this, signature); @@ -1242,7 +1242,7 @@ internal bool TryResolveSlot(CodeContext context, string name, out PythonTypeSlo if (UnderlyingSystemType.IsInterface) { return TypeCache.Object.TryResolveSlot(context, name, out slot); } - + slot = null; return false; @@ -1339,7 +1339,7 @@ internal static PythonTypeSlot ToTypeSlot(object value) { } // We could do more checks for things which aren't descriptors - if (value != null) { + if (value != null) { return new PythonTypeUserDescriptorSlot(value); } @@ -1484,7 +1484,7 @@ internal bool TryGetNonCustomMember(CodeContext context, object instance, string PythonDictionary dict = sdo.Dict; hasValue = dict != null && dict.TryGetValue(name, out value); - } + } // then check through all the descriptors. If we have a data // descriptor it takes priority over the value we found in the @@ -1497,7 +1497,7 @@ internal bool TryGetNonCustomMember(CodeContext context, object instance, string if (!hasValue || slot.IsSetDescriptor(context, this)) { if (slot.TryGetValue(context, instance, this, out object newValue)) value = newValue; - return true; + return true; } } } @@ -1611,7 +1611,7 @@ internal bool TrySetMember(CodeContext context, object instance, string name, ob } setAttrSite.Target(setAttrSite, context, setattr, instance, name, value); - return true; + return true; } return TrySetNonCustomMember(context, instance, name, value); @@ -1641,7 +1641,8 @@ internal bool TrySetNonCustomMember(CodeContext context, object instance, string if ((iac = sdo.SetDict(iac)) == null) { return false; } - } else { + } + else { return false; } } @@ -1851,14 +1852,14 @@ private void InitializeUserType(CodeContext/*!*/ context, string name, PythonTup // if we directly inherit from 2 types with slots then the indexes would // conflict so inheritance isn't allowed. int slotCount = pt.GetUsedSlotCount(); - + if (slotCount != 0) { if (hasSlots) { throw PythonOps.TypeError("multiple bases have instance lay-out conflict"); } hasSlots = true; } - + pt.AddSubType(this); } @@ -1917,7 +1918,7 @@ private void InitializeUserType(CodeContext/*!*/ context, string name, PythonTup bool isPythonType = false; foreach (ConstructorInfo ci in ctors) { ParameterInfo[] pis = ci.GetParameters(); - if ((pis.Length > 1 && pis[0].ParameterType == typeof(CodeContext) && pis[1].ParameterType == typeof(PythonType)) || + if((pis.Length > 1 && pis[0].ParameterType == typeof(CodeContext) && pis[1].ParameterType == typeof(PythonType)) || (pis.Length > 0 && pis[0].ParameterType == typeof(PythonType))) { isPythonType = true; break; @@ -2033,7 +2034,7 @@ private void UpdateObjectNewAndInit(CodeContext context) { Debug.Assert(pt._objectInit != null && pt._objectNew != null); if (!pt._objectNew.Value) { - _objectNew = false; + _objectNew = false; } if (!pt._objectInit.Value) { @@ -2091,7 +2092,7 @@ private void PopulateDictionary(CodeContext/*!*/ context, string name, PythonTup if (slots != null) { slots.Remove("__classcell__"); _slots = slots.ToArray(); - + int index = _originalSlotCount; string typeName = IronPython.Compiler.Parser.GetPrivatePrefix(name); @@ -2117,7 +2118,7 @@ private void PopulateDictionary(CodeContext/*!*/ context, string name, PythonTup if (CheckForSlotWithDefault(context, _resolutionOrder, slots, "__dict__")) { _attrs |= PythonTypeAttributes.HasDictionary; bool inheritsDict = false; - for (int i = 1; i < _resolutionOrder.Count; i++) { + for (int i = 1; i<_resolutionOrder.Count; i++) { PythonType pt = _resolutionOrder[i]; if (pt.TryResolveSlot(context, "__dict__", out _)) { inheritsDict = true; @@ -2227,7 +2228,7 @@ private static void EnsureModule(CodeContext context, PythonDictionary dict) { } } } - + #endregion #region System type initialization @@ -2279,7 +2280,7 @@ private void AddSystemBases() { Type newType; if (TryReplaceExtensibleWithBase(curType, out newType)) { mro.Add(DynamicHelpers.GetPythonTypeFromType(newType)); - } else if (!curType.IsDefined(typeof(PythonHiddenBaseClassAttribute), false)) { + } else if(!curType.IsDefined(typeof(PythonHiddenBaseClassAttribute), false)) { mro.Add(DynamicHelpers.GetPythonTypeFromType(curType)); } curType = curType.BaseType; @@ -2316,7 +2317,7 @@ private void AddSystemInterfaces(List mro) { mro.Add(DynamicHelpers.GetPythonTypeFromType(typeof(ICollection))); mro.Add(DynamicHelpers.GetPythonTypeFromType(typeof(IEnumerable))); return; - } + } Type[] interfaces = _underlyingSystemType.GetInterfaces(); Dictionary methodMap = new Dictionary(); @@ -2325,7 +2326,7 @@ private void AddSystemInterfaces(List mro) { PythonType[] bases = new PythonType[_bases.Length + interfaces.Length]; Array.Copy(_bases, bases, _bases.Length); - for (int i = 0; i < interfaces.Length; i++) { + for(int i = 0; i < interfaces.Length; i++) { bases[i + _bases.Length] = PythonType.GetPythonType(interfaces[i]); } @@ -2353,11 +2354,11 @@ private void AddSystemInterfaces(List mro) { #endif InterfaceMapping mapping = _underlyingSystemType.GetInterfaceMap(iface); - + // grab all the interface methods which would hide other members for (int i = 0; i < mapping.TargetMethods.Length; i++) { MethodInfo target = mapping.TargetMethods[i]; - + if (target == null) { continue; } @@ -2393,7 +2394,7 @@ private void AddSystemInterfaces(List mro) { // no collisions so far... methodMap[iTarget.Name] = iface; } - } + } } } } @@ -2491,7 +2492,7 @@ private void EnsureDict() { null); } } - + /// /// Internal helper function to add a subtype /// @@ -2547,7 +2548,7 @@ private enum PythonTypeAttributes { /// The type has a ctor which does not accept PythonTypes. This is used /// for user defined types which implement __clrtype__ /// - SystemCtor = 0x20 + SystemCtor = 0x20 } #endregion @@ -2606,7 +2607,7 @@ internal WeakReferenceProxy(PythonContext context, PythonType type) { } public WeakRefTracker GetWeakRef() { - if (type.IsSystemType) { + if(type.IsSystemType) { return context.GetSystemPythonTypeWeakRef(type); } @@ -2615,7 +2616,7 @@ public WeakRefTracker GetWeakRef() { } public void SetFinalizer(WeakRefTracker value) { - if (type.IsSystemType) { + if(type.IsSystemType) { context.SetSystemPythonTypeFinalizer(type, value); } else { IWeakReferenceable weakref = (IWeakReferenceable)type; @@ -2624,10 +2625,10 @@ public void SetFinalizer(WeakRefTracker value) { } public bool SetWeakRef(WeakRefTracker value) { - if (type.IsSystemType) { + if(type.IsSystemType) { return context.SetSystemPythonTypeWeakRef(type, value); } - + IWeakReferenceable weakref = (IWeakReferenceable)type; return weakref.SetWeakRef(value); } @@ -2650,7 +2651,7 @@ public bool SetWeakRef(WeakRefTracker value) { /// internal WeakReference/*!*/ GetSharedWeakReference() { if (_weakRef == null) { - _weakRef = new WeakReference(this); + _weakRef = new WeakReference(this); } return _weakRef; @@ -2666,7 +2667,7 @@ T IFastSettable.MakeSetBinding(CallSite site, PythonSetMemberBinder binder if (!IsSystemType && !TryGetCustomSetAttr(Context.SharedContext, out _)) { CodeContext context = PythonContext.GetPythonContext(binder).SharedContext; string name = binder.Name; - + // optimized versions for possible literals that can show up in code. Type setType = typeof(T); if (setType == typeof(Func)) { @@ -2725,7 +2726,7 @@ internal class DebugProxy { public DebugProxy(PythonType type) { _type = type; } - + public PythonType[] __bases__ { get { return ArrayUtils.ToArray(_type.BaseTypes); @@ -2834,8 +2835,8 @@ public GetMemberDelegates(OptimizedGetKind getKind, PythonType type, PythonGetMe _fallback = fallback; _isNoThrow = binder.IsNoThrow; _extMethods = extMethods; - var optNames = type.GetOptimizedInstanceNames(); - + var optNames = type.GetOptimizedInstanceNames(); + switch (getKind) { case OptimizedGetKind.SlotDict: if (optNames != null) { @@ -2844,7 +2845,7 @@ public GetMemberDelegates(OptimizedGetKind getKind, PythonType type, PythonGetMe if (optNames != null && _dictIndex != -1) { _func = SlotDictOptimized; - _dictVersion = type.GetOptimizedInstanceVersion(); + _dictVersion = type.GetOptimizedInstanceVersion(); } else { _func = SlotDict; } @@ -2867,13 +2868,13 @@ public GetMemberDelegates(OptimizedGetKind getKind, PythonType type, PythonGetMe _func = UserSlotDictGetAttr; } else { _func = UserSlotDict; - } + } break; case OptimizedGetKind.UserSlotOnly: if (_getattrSlot != null) { _func = UserSlotOnlyGetAttr; } else { - _func = UserSlotOnly; + _func = UserSlotOnly; } break; default: throw new InvalidOperationException(); @@ -3097,7 +3098,7 @@ internal class SetMemberDelegates : FastSetBase { private readonly CodeContext _context; private readonly int _index, _keysVersion; - public SetMemberDelegates(CodeContext context, PythonType type, OptimizedSetKind kind, string name, int version, PythonTypeSlot slot, SlotSetValue slotFunc) + public SetMemberDelegates(CodeContext context, PythonType type, OptimizedSetKind kind, string name, int version, PythonTypeSlot slot, SlotSetValue slotFunc) : base(version) { _slot = slot; _name = name; @@ -3146,7 +3147,7 @@ public object SetDictOptimized(CallSite site, object self, TValue value) { return Update(site, self, value); } - + public object SetDict(CallSite site, object self, TValue value) { if (self is IPythonObject ipo && ipo.PythonType.Version == _version && ShouldUseNonOptimizedSite) { _hitCount++; @@ -3437,7 +3438,7 @@ public override bool Equals(CachedGetKey other) { if (!(other is CachedGetIdWeakRefExtensionMethod obj)) { return false; } - return obj._extMethodSet.Target == _extMethodSet.Target && + return obj._extMethodSet.Target == _extMethodSet.Target && obj.Name == Name; } diff --git a/src/ipy/IronPython/Runtime/Types/PythonTypeDataSlot.cs b/src/ipy/IronPython/Runtime/Types/PythonTypeDataSlot.cs index dc0952f7d..a17d1ee9a 100644 --- a/src/ipy/IronPython/Runtime/Types/PythonTypeDataSlot.cs +++ b/src/ipy/IronPython/Runtime/Types/PythonTypeDataSlot.cs @@ -2,6 +2,10 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; +using System.Collections.Generic; +using System.Text; + using IronPython.Runtime.Operations; namespace IronPython.Runtime.Types { diff --git a/src/ipy/IronPython/Runtime/Types/PythonTypeDictSlot.cs b/src/ipy/IronPython/Runtime/Types/PythonTypeDictSlot.cs index 551058431..22b3c3459 100644 --- a/src/ipy/IronPython/Runtime/Types/PythonTypeDictSlot.cs +++ b/src/ipy/IronPython/Runtime/Types/PythonTypeDictSlot.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using Microsoft.Scripting; using IronPython.Runtime.Operations; @@ -64,7 +65,7 @@ internal override bool IsSetDescriptor(CodeContext context, PythonType owner) { internal override bool TryDeleteValue(CodeContext context, object instance, PythonType owner) { if (instance is IPythonObject sdo) { - if (!sdo.PythonType.HasDictionary) { + if(!sdo.PythonType.HasDictionary) { return false; } diff --git a/src/ipy/IronPython/Runtime/Types/PythonTypeInfo.cs b/src/ipy/IronPython/Runtime/Types/PythonTypeInfo.cs index 5d4866fd6..87c537fd7 100644 --- a/src/ipy/IronPython/Runtime/Types/PythonTypeInfo.cs +++ b/src/ipy/IronPython/Runtime/Types/PythonTypeInfo.cs @@ -11,15 +11,15 @@ using System.Numerics; using System.Reflection; -using IronPython.Runtime.Binding; -using IronPython.Runtime.Operations; - using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Binding; +using IronPython.Runtime.Operations; + namespace IronPython.Runtime.Types { /// /// Helpers for interacting w/ .NET types. This includes: @@ -409,7 +409,8 @@ private class OperatorResolver : MemberResolver { if ((opInfo.Operator & PythonOperationKind.Comparison) != 0) { // we override these with our own comparisons continue; - } else if (opInfo.Operator == PythonOperationKind.TrueDivide) { + } + else if (opInfo.Operator == PythonOperationKind.TrueDivide) { // we override this with our own division PythonOperationKind which is different from .NET Complex. continue; } @@ -661,7 +662,7 @@ private class ProtectedMemberResolver : MemberResolver { EqualityResolver.Instance, new ComparisonResolver(typeof(IStructuralComparable), "StructuralComparable"), - + new OneOffResolver("__all__", AllResolver), new OneOffResolver("__contains__", ContainsResolver), new OneOffResolver("__dir__", DirResolver), @@ -1010,7 +1011,7 @@ internal static MemberGroup GetExtensionMemberGroup(Type type, MemberInfo[] news return GetInstanceOpsMethod(type, nameof(InstanceOps.IterMethodForEnumerator)); } } - + return MemberGroup.EmptyGroup; } @@ -1029,7 +1030,7 @@ internal static MemberGroup GetExtensionMemberGroup(Type type, MemberInfo[] news } MemberGroup res = binder.GetMember(type, "GetMemberNames"); - if (res == MemberGroup.EmptyGroup && + if (res == MemberGroup.EmptyGroup && !typeof(IPythonObject).IsAssignableFrom(type) && typeof(IDynamicMetaObjectProvider).IsAssignableFrom(type)) { res = GetInstanceOpsMethod(type, nameof(InstanceOps.DynamicDir)); @@ -1652,7 +1653,7 @@ private static string[] GetCastNames(Type fromType, Type toType) { /// Helper for creating a typecast resolver /// private static Func/*!*/ MakeConversionResolver(List castPrec) { - return delegate (MemberBinder/*!*/ binder, Type/*!*/ type) { + return delegate(MemberBinder/*!*/ binder, Type/*!*/ type) { MethodInfo cast = FindCastMethod(binder, type, castPrec); if (cast != null) { MethodTracker tracker = (MethodTracker)MemberTracker.FromMemberInfo(cast, type); @@ -1667,7 +1668,7 @@ private static string[] GetCastNames(Type fromType, Type toType) { /// /// false for a getter, true for a setter private static Func/*!*/ MakeIndexerResolver(bool set) { - return delegate (MemberBinder/*!*/ binder, Type/*!*/ type) { + return delegate(MemberBinder/*!*/ binder, Type/*!*/ type) { List members = null; foreach (MemberInfo member in type.GetDefaultMembers()) { @@ -2001,7 +2002,7 @@ static bool FilterProperty(MemberRequestKind action, PropertyInfo property) { return group; } - private static bool IsPropertyWithParameters(MethodTracker/*!*/ meth) { + private static bool IsPropertyWithParameters(MethodTracker/*!*/ meth) { if (meth.Method.Name.StartsWith("get_", StringComparison.Ordinal)) { if (!IsMethodDefaultMember(meth)) { ParameterInfo[] args = meth.Method.GetParameters(); @@ -2045,7 +2046,7 @@ private static bool IsPythonRecognizedOperator(string name) { if (oi != null) { EnsureOperatorTable(); - if (_pythonOperatorTable.ContainsValue(oi.Operator)) { + if(_pythonOperatorTable.ContainsValue(oi.Operator)) { isPythonRecognizedOperator = true; } } @@ -2081,7 +2082,7 @@ private static List MakeListWithPreviousMembers(MemberGroup group } return mts; } - + private static MethodInfo[] GetMethodSet(string name, int expected) { MethodInfo[] methods = typeof(InstanceOps).GetMethods(); MethodInfo[] filtered = new MethodInfo[expected]; diff --git a/src/ipy/IronPython/Runtime/Types/PythonTypeSlot.cs b/src/ipy/IronPython/Runtime/Types/PythonTypeSlot.cs index 797dcdeaa..5123fb104 100644 --- a/src/ipy/IronPython/Runtime/Types/PythonTypeSlot.cs +++ b/src/ipy/IronPython/Runtime/Types/PythonTypeSlot.cs @@ -2,12 +2,15 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Dynamic; using System.Linq.Expressions; +using System.Dynamic; +using System.Runtime.InteropServices; + using IronPython.Runtime.Binding; using IronPython.Runtime.Operations; +using Microsoft.Scripting.Utils; using AstUtils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Runtime.Types { @@ -41,7 +44,7 @@ internal virtual bool TrySetValue(CodeContext context, object instance, PythonTy /// Deletes the value stored in the slot from the instance. /// /// true if the value was deleted, false if it can't be deleted - internal virtual bool TryDeleteValue(CodeContext context, object instance, PythonType owner) { + internal virtual bool TryDeleteValue(CodeContext context, object instance, PythonType owner) { return false; } @@ -88,7 +91,7 @@ internal virtual void MakeGetExpression(PythonBinder/*!*/ binder, Expression/*!* builder.FinishCondition(Ast.Block(call, tmp)); } } - + /// /// True if TryGetValue will always succeed, false if it may fail. /// @@ -104,7 +107,7 @@ internal virtual bool IsSetDescriptor(CodeContext context, PythonType owner) { return false; } - public virtual object __get__(CodeContext/*!*/ context, object instance, object typeContext = null) { + public virtual object __get__(CodeContext/*!*/ context, object instance, object typeContext=null) { PythonType dt = typeContext as PythonType; object res; diff --git a/src/ipy/IronPython/Runtime/Types/PythonTypeTypeSlot.cs b/src/ipy/IronPython/Runtime/Types/PythonTypeTypeSlot.cs index 49d6e6258..3c18fcfbe 100644 --- a/src/ipy/IronPython/Runtime/Types/PythonTypeTypeSlot.cs +++ b/src/ipy/IronPython/Runtime/Types/PythonTypeTypeSlot.cs @@ -40,7 +40,7 @@ internal override bool TrySetValue(CodeContext context, object instance, PythonT if (!(value is PythonType dt)) throw PythonOps.TypeError("__class__ must be set to a class, not '{0}' object", PythonOps.GetPythonTypeName(value)); - if (dt.UnderlyingSystemType != DynamicHelpers.GetPythonType(instance).UnderlyingSystemType) + if(dt.UnderlyingSystemType != DynamicHelpers.GetPythonType(instance).UnderlyingSystemType) throw PythonOps.TypeErrorForIncompatibleObjectLayout("__class__ assignment", DynamicHelpers.GetPythonType(instance), dt.UnderlyingSystemType); sdo.SetPythonType(dt); diff --git a/src/ipy/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs b/src/ipy/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs index 7a3d16947..c3fffe03b 100644 --- a/src/ipy/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs +++ b/src/ipy/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs @@ -4,7 +4,6 @@ using System; using System.Diagnostics; - using IronPython.Runtime.Operations; namespace IronPython.Runtime.Types { @@ -17,7 +16,7 @@ public sealed class PythonTypeUserDescriptorSlot : PythonTypeSlot { internal PythonTypeUserDescriptorSlot(object value) { Value = value; } - + internal PythonTypeUserDescriptorSlot(object value, bool isntDescriptor) { Value = value; if (isntDescriptor) { diff --git a/src/ipy/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs b/src/ipy/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs index 467af40c7..4b69d5ed1 100644 --- a/src/ipy/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs +++ b/src/ipy/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs @@ -47,7 +47,7 @@ internal override bool TrySetValue(CodeContext context, object instance, PythonT internal override bool TryDeleteValue(CodeContext context, object instance, PythonType owner) { throw PythonOps.TypeError("__weakref__ attribute cannot be deleted"); } - + public override string ToString() { return $""; } diff --git a/src/ipy/IronPython/Runtime/Types/ReflectedEvent.cs b/src/ipy/IronPython/Runtime/Types/ReflectedEvent.cs index dc6f28038..db5c04d99 100644 --- a/src/ipy/IronPython/Runtime/Types/ReflectedEvent.cs +++ b/src/ipy/IronPython/Runtime/Types/ReflectedEvent.cs @@ -5,10 +5,8 @@ using System; using System.Reflection; using System.Runtime.CompilerServices; - using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; - using Microsoft.Scripting.Actions; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Utils; @@ -66,7 +64,7 @@ internal override bool TrySetValue(CodeContext/*!*/ context, object instance, Py } private bool EventInfosDiffer(BoundEvent et) { - + // if they're the same object they're the same... if (et.Event.Info == Info) { return false; diff --git a/src/ipy/IronPython/Runtime/Types/ReflectedExtensionProperty.cs b/src/ipy/IronPython/Runtime/Types/ReflectedExtensionProperty.cs index 89ebd3c7b..8e879de9b 100644 --- a/src/ipy/IronPython/Runtime/Types/ReflectedExtensionProperty.cs +++ b/src/ipy/IronPython/Runtime/Types/ReflectedExtensionProperty.cs @@ -4,10 +4,8 @@ using System; using System.Reflection; - -using IronPython.Runtime.Operations; - using Microsoft.Scripting.Utils; +using IronPython.Runtime.Operations; namespace IronPython.Runtime.Types { /// diff --git a/src/ipy/IronPython/Runtime/Types/ReflectedField.cs b/src/ipy/IronPython/Runtime/Types/ReflectedField.cs index 131b71c29..b40d725ab 100644 --- a/src/ipy/IronPython/Runtime/Types/ReflectedField.cs +++ b/src/ipy/IronPython/Runtime/Types/ReflectedField.cs @@ -2,20 +2,22 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; using System.Diagnostics; using System.Dynamic; -using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; +using Microsoft.Scripting; +using Microsoft.Scripting.Actions; +using Microsoft.Scripting.Utils; + using IronPython.Runtime.Binding; using IronPython.Runtime.Exceptions; using IronPython.Runtime.Operations; -using Microsoft.Scripting; -using Microsoft.Scripting.Actions; - namespace IronPython.Runtime.Types { using Ast = Expression; using AstUtils = Microsoft.Scripting.Ast.Utils; @@ -41,8 +43,8 @@ public ReflectedField(FieldInfo/*!*/ info) public FieldInfo Info { [PythonHidden] - get { - return _info; + get { + return _info; } } @@ -71,7 +73,7 @@ public object GetValue(CodeContext context, object instance) { public void SetValue(CodeContext context, object instance, object value) { if (!TrySetValueWorker(context, instance, DynamicHelpers.GetPythonType(instance), value, true)) { throw new InvalidOperationException("cannot set field"); - } + } } public void __set__(CodeContext/*!*/ context, object instance, object value) { diff --git a/src/ipy/IronPython/Runtime/Types/ReflectedGetterSetter.cs b/src/ipy/IronPython/Runtime/Types/ReflectedGetterSetter.cs index d1967d63a..f96efc635 100644 --- a/src/ipy/IronPython/Runtime/Types/ReflectedGetterSetter.cs +++ b/src/ipy/IronPython/Runtime/Types/ReflectedGetterSetter.cs @@ -7,9 +7,8 @@ using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; - using IronPython.Runtime.Operations; - +using Microsoft.Scripting.Generation; using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; @@ -137,8 +136,8 @@ internal static bool NeedToReturnProperty(object instance, MethodInfo[] mis) { } foreach (MethodInfo mi in mis) { - if (!mi.IsStatic || - (mi.IsDefined(typeof(PropertyMethodAttribute), true) && + if (!mi.IsStatic || + (mi.IsDefined(typeof(PropertyMethodAttribute), true) && !mi.IsDefined(typeof(StaticExtensionMethodAttribute), true)) && !mi.IsDefined(typeof(WrapperDescriptorAttribute), true)) { return true; @@ -164,7 +163,7 @@ internal bool CallSetter(CodeContext context, SiteLocalStorage @@ -26,7 +28,7 @@ public sealed class ReflectedIndexer : ReflectedGetterSetter { public ReflectedIndexer(PropertyInfo/*!*/ info, NameType nt, bool privateBinding) : base(new MethodInfo[] { info.GetGetMethod(privateBinding) }, new MethodInfo[] { info.GetSetMethod(privateBinding) }, nt) { Debug.Assert(info != null); - + _info = info; } diff --git a/src/ipy/IronPython/Runtime/Types/ReflectedProperty.cs b/src/ipy/IronPython/Runtime/Types/ReflectedProperty.cs index 7816a23db..558b172a6 100644 --- a/src/ipy/IronPython/Runtime/Types/ReflectedProperty.cs +++ b/src/ipy/IronPython/Runtime/Types/ReflectedProperty.cs @@ -2,21 +2,22 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Linq.Expressions; + using System; using System.Diagnostics; using System.Dynamic; -using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; -using IronPython.Runtime.Binding; -using IronPython.Runtime.Operations; - using Microsoft.Scripting; using Microsoft.Scripting.Actions; using Microsoft.Scripting.Generation; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Binding; +using IronPython.Runtime.Operations; + using AstUtils = Microsoft.Scripting.Ast.Utils; namespace IronPython.Runtime.Types { @@ -54,7 +55,7 @@ internal override bool TrySetValue(CodeContext context, object instance, PythonT if (instance == null) { foreach (MethodInfo mi in Setter) { - if (mi.IsStatic && DeclaringType != owner.UnderlyingSystemType) { + if(mi.IsStatic && DeclaringType != owner.UnderlyingSystemType) { return false; } else if (mi.IsProtected()) { throw PythonOps.TypeErrorForProtectedMember(owner.UnderlyingSystemType, _info.Name); @@ -197,7 +198,7 @@ internal override void MakeGetExpression(PythonBinder/*!*/ binder, Expression/*! ).Expression, typeof(object) ) - ); + ); } } diff --git a/src/ipy/IronPython/Runtime/Types/ReflectedSlotProperty.cs b/src/ipy/IronPython/Runtime/Types/ReflectedSlotProperty.cs index 94e5e5cee..bf568d6af 100644 --- a/src/ipy/IronPython/Runtime/Types/ReflectedSlotProperty.cs +++ b/src/ipy/IronPython/Runtime/Types/ReflectedSlotProperty.cs @@ -5,13 +5,13 @@ using System; using System.Collections.Generic; -using IronPython.Runtime.Operations; - using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Utils; -namespace IronPython.Runtime.Types { +using IronPython.Runtime.Operations; +namespace IronPython.Runtime.Types { + /// /// Represents a member of a user-defined type which defines __slots__. The names listed in /// __slots__ have storage allocated for them with the type and provide fast get/set access. @@ -19,7 +19,7 @@ namespace IronPython.Runtime.Types { [PythonType("member_descriptor")] internal class ReflectedSlotProperty : PythonTypeDataSlot, ICodeFormattable { private readonly string/*!*/ _name, _typeName; - private readonly int/*!*/ _index; + private readonly int/*!*/ _index; private static readonly Dictionary _methods = new Dictionary(); @@ -124,5 +124,5 @@ private class SlotValue { } internal delegate object SlotGetValue(object instance); - internal delegate void SlotSetValue(object instance, object value); + internal delegate void SlotSetValue(object instance, object value); } diff --git a/src/ipy/IronPython/Runtime/WeakRef.cs b/src/ipy/IronPython/Runtime/WeakRef.cs index ddd4f0b48..5c73b7fa1 100644 --- a/src/ipy/IronPython/Runtime/WeakRef.cs +++ b/src/ipy/IronPython/Runtime/WeakRef.cs @@ -8,11 +8,11 @@ using System.Linq; using System.Threading; -using IronPython.Runtime.Operations; - using Microsoft.Scripting.Actions; using Microsoft.Scripting.Utils; +using IronPython.Runtime.Operations; + namespace IronPython.Runtime { /// @@ -26,7 +26,7 @@ private readonly struct CallbackInfo { private readonly object _callback; private readonly WeakHandle _longRef; private readonly WeakHandle _shortRef; - + public CallbackInfo(object callback, object weakRef) { _callback = callback; // we need a short ref & a long ref to deal with the case diff --git a/src/ipy/IronPython/Runtime/WrapperDictionary.cs b/src/ipy/IronPython/Runtime/WrapperDictionary.cs index 617cf8a67..727a8cc2b 100644 --- a/src/ipy/IronPython/Runtime/WrapperDictionary.cs +++ b/src/ipy/IronPython/Runtime/WrapperDictionary.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; - +using Microsoft.Scripting; using Microsoft.Scripting.Actions; namespace IronPython.Runtime { @@ -15,7 +15,7 @@ internal class WrapperDictionaryStorage : DictionaryStorage { public WrapperDictionaryStorage(TopNamespaceTracker/*!*/ data) { _data = data; } - + public override void Add(ref DictionaryStorage storage, object key, object value) { throw CannotModifyNamespaceDict(); } diff --git a/src/ipy/IronPython/Runtime/Zip.cs b/src/ipy/IronPython/Runtime/Zip.cs index cf7801f4d..24a5a7988 100644 --- a/src/ipy/IronPython/Runtime/Zip.cs +++ b/src/ipy/IronPython/Runtime/Zip.cs @@ -7,11 +7,11 @@ using System; using System.Collections; +using Microsoft.Scripting.Runtime; + using IronPython.Runtime.Operations; using IronPython.Runtime.Types; -using Microsoft.Scripting.Runtime; - namespace IronPython.Runtime { [PythonType("zip")] diff --git a/src/roslyn/IronPython.DiagnosticAnalyzer/Analyzer.cs b/src/roslyn/IronPython.DiagnosticAnalyzer/Analyzer.cs index 5060e974f..a5e0db35b 100644 --- a/src/roslyn/IronPython.DiagnosticAnalyzer/Analyzer.cs +++ b/src/roslyn/IronPython.DiagnosticAnalyzer/Analyzer.cs @@ -2,10 +2,14 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; +using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; - +using System.Threading; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Operations; diff --git a/tests/ironpython/AttrInjectorTest.cs b/tests/ironpython/AttrInjectorTest.cs index 5dccf794e..ee2aa0746 100644 --- a/tests/ironpython/AttrInjectorTest.cs +++ b/tests/ironpython/AttrInjectorTest.cs @@ -5,9 +5,9 @@ using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Xml; - +using IronPython.Runtime; using IronPython.Runtime.Types; - +using Microsoft.Scripting; using Microsoft.Scripting.Runtime; [assembly: ExtensionType(typeof(XmlElement), typeof(IronPythonTest.AttrInjectorTest.SimpleXmlAttrInjector))] diff --git a/tests/ironpython/BindTest.cs b/tests/ironpython/BindTest.cs index c4adcb248..f7c87ebf1 100644 --- a/tests/ironpython/BindTest.cs +++ b/tests/ironpython/BindTest.cs @@ -8,11 +8,12 @@ using System.Numerics; using System.Runtime.InteropServices; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; + using IronPython.Runtime; using IronPython.Runtime.Types; -using Microsoft.Scripting.Runtime; - namespace IronPythonTest { [Flags] public enum BindResult { @@ -274,7 +275,7 @@ public void M98(string a, string b, string c, string d, out int x, ref Dispatch Flag = 198; } - + public Single P01 { get; set; } @@ -463,55 +464,55 @@ public enum BigEnum : long { } public class DefaultValueTest { - public BindResult Test_Enum(BindResult param = BindResult.Bool) { + public BindResult Test_Enum(BindResult param=BindResult.Bool) { return param; } - public BigEnum Test_BigEnum(BigEnum param = BigEnum.BigValue) { + public BigEnum Test_BigEnum(BigEnum param=BigEnum.BigValue) { return param; } - public string Test_String(string param = "Hello World") { + public string Test_String(string param="Hello World") { return param; } - public int Test_Int(int param = 5) { + public int Test_Int(int param=5) { return param; } - public uint Test_UInt(uint param = uint.MaxValue) { + public uint Test_UInt(uint param=uint.MaxValue) { return param; } - public bool Test_Bool(bool param = true) { + public bool Test_Bool(bool param=true) { return param; } - public char Test_Char(char param = 'A') { + public char Test_Char(char param='A') { return param; } - public byte Test_Byte(byte param = 2) { + public byte Test_Byte(byte param=2) { return param; } - public sbyte Test_SByte(sbyte param = 2) { + public sbyte Test_SByte(sbyte param=2) { return param; } - public short Test_Short(short param = 2) { + public short Test_Short(short param=2) { return param; } - public ushort Test_UShort(ushort param = 2) { + public ushort Test_UShort(ushort param=2) { return param; } - public long Test_Long(long param = long.MaxValue) { + public long Test_Long(long param=long.MaxValue) { return param; } - public ulong Test_ULong(ulong param = ulong.MaxValue) { + public ulong Test_ULong(ulong param=ulong.MaxValue) { return param; } @@ -525,7 +526,7 @@ public string Test_Default_ValueType([DefaultParameterValue(1)] object o) { return o == null ? "(null)" : o.ToString(); } - public string Test_Default_Cast([Optional, DefaultParameterValue(1)] ref object o) { + public string Test_Default_Cast([Optional, DefaultParameterValue(1)]ref object o) { return o == null ? "(null)" : o.ToString(); } } @@ -882,7 +883,7 @@ public static PythonType M17(T x, IEnumerable y) { return DynamicHelpers.GetPythonTypeFromType(typeof(T)); } - + public static PythonType M18(T x) where T : IEnumerable { return DynamicHelpers.GetPythonTypeFromType(typeof(T)); } diff --git a/tests/ironpython/BinderTest.cs b/tests/ironpython/BinderTest.cs index 901bbf8a5..80b86733a 100644 --- a/tests/ironpython/BinderTest.cs +++ b/tests/ironpython/BinderTest.cs @@ -115,8 +115,8 @@ public class CNoOverloads { public void M706(out BigInteger arg) { arg = 2; Flag.Value = 706; } // Default Value - public void M710(Int32 arg = 10) { Flag.Value = 710; } - public void M715(Int32 arg, Int32 arg2 = 10) { Flag.Value = 715; } + public void M710(Int32 arg=10) { Flag.Value = 710; } + public void M715(Int32 arg, Int32 arg2=10) { Flag.Value = 715; } } @@ -147,7 +147,7 @@ public void M300(params C1[] args) { public void M402(Int32 arg3, ref Int32 arg1, out Int32 arg2) { arg1 = arg2 = arg3; } // default value does get used - public void M450(Int32 arg = 80) { Flag.Value = arg; } + public void M450(Int32 arg=80) { Flag.Value = arg; } // 8 args public void M500(Int32 arg1, Int32 arg2, Int32 arg3, Int32 arg4, Int32 arg5, Int32 arg6, Int32 arg7, Int32 arg8) { @@ -245,7 +245,7 @@ public class COtherOverloadConcern { // If 2 instances of a Python subclass of C3 that implements __int__ are passed as arguments this // the first overload should be preferred. public void M140(C3 a, int b) { Flag.Value = 140; } - public void M140(int a, int b) { Flag.Value = 240; } + public void M140(int a, int b) { Flag.Value = 240; } } public interface I1 { void M(); } @@ -322,18 +322,18 @@ public class COverloads_NoArgNecessary { public void M100(out Int32 arg) { arg = 1; Flag.Value = 200; } public void M101() { Flag.Value = 101; } - public void M101(Int32 arg = 1) { Flag.Value = 201; } + public void M101(Int32 arg=1) { Flag.Value = 201; } public void M102() { Flag.Value = 102; } public void M102(params Int32[] arg) { Flag.Value = 202; } public void M103(out Int32 arg) { arg = 1; Flag.Value = 103; } - public void M103(Int32 arg = 1) { Flag.Value = 203; } + public void M103(Int32 arg=1) { Flag.Value = 203; } public void M104(out Int32 arg) { arg = 1; Flag.Value = 104; } public void M104(params Int32[] arg) { Flag.Value = 204; } - public void M105(Int32 arg = 1) { Flag.Value = 105; } + public void M105(Int32 arg=1) { Flag.Value = 105; } public void M105(params Int32[] arg) { Flag.Value = 205; } public void M106(Int32 arg) { Flag.Value = 106; } @@ -364,7 +364,7 @@ public class COverloads_OneArg_NormalArg { public void M106(out Int32 arg, ref Int32 arg2) { arg = 1; Flag.Value = 206; } public void M107(Int32 arg) { Flag.Value = 107; } - public void M107(Int32 arg, Int32 arg2 = 1) { Flag.Value = 207; } + public void M107(Int32 arg, Int32 arg2=1) { Flag.Value = 207; } public void M108(Int32 arg) { Flag.Value = 108; } public void M108(Int32 arg, params Int32[] arg2) { Flag.Value = 208; } @@ -395,7 +395,7 @@ public class COverloads_OneArg_RefArg { public void M105(out Int32 arg, ref Int32 arg2) { arg = 1; Flag.Value = 205; } public void M106(ref Int32 arg) { Flag.Value = 106; } - public void M106(Int32 arg, Int32 arg2 = 1) { Flag.Value = 206; } + public void M106(Int32 arg, Int32 arg2=1) { Flag.Value = 206; } public void M107(ref Int32 arg) { Flag.Value = 107; } public void M107(Int32 arg, params Int32[] arg2) { Flag.Value = 207; } @@ -423,7 +423,7 @@ public class COverloads_OneArg_NullableArg { public void M104(out Int32 arg, ref Int32 arg2) { arg = 1; Flag.Value = 204; } public void M105(Int32? arg) { Flag.Value = 105; } - public void M105(Int32 arg, Int32 arg2 = 1) { Flag.Value = 205; } + public void M105(Int32 arg, Int32 arg2=1) { Flag.Value = 205; } public void M106(Int32? arg) { Flag.Value = 106; } public void M106(Int32 arg, params Int32[] arg2) { Flag.Value = 206; } @@ -467,7 +467,7 @@ public class COverloads_OneArg_NormalOut { public void M102(out Int32 arg, ref Int32 arg2) { arg = 1; Flag.Value = 202; } public void M103(Int32 arg1, out Int32 arg) { arg = 1; Flag.Value = 103; } - public void M103(Int32 arg, Int32 arg2 = 1) { Flag.Value = 203; } + public void M103(Int32 arg, Int32 arg2=1) { Flag.Value = 203; } public void M104(Int32 arg1, out Int32 arg) { arg = 1; Flag.Value = 104; } public void M104(Int32 arg, params Int32[] arg2) { Flag.Value = 204; } @@ -483,7 +483,7 @@ public class COverloads_OneArg_RefOut { public void M100(out Int32 arg, Int32 arg2) { arg = 1; Flag.Value = 200; } public void M101(ref Int32 arg1, out Int32 arg) { arg = 1; Flag.Value = 101; } - public void M101(Int32 arg, Int32 arg2 = 1) { Flag.Value = 201; } + public void M101(Int32 arg, Int32 arg2=1) { Flag.Value = 201; } public void M102(ref Int32 arg1, out Int32 arg) { arg = 1; Flag.Value = 102; } public void M102(Int32 arg, params Int32[] arg2) { Flag.Value = 202; } @@ -499,7 +499,7 @@ public class COverloads_OneArg_OutNormal { public void M100(out Int32 arg, ref Int32 arg2) { arg = 1; Flag.Value = 200; } public void M101(out Int32 arg, Int32 arg2) { arg = 1; Flag.Value = 101; } - public void M101(Int32 arg, Int32 arg2 = 1) { Flag.Value = 201; } + public void M101(Int32 arg, Int32 arg2=1) { Flag.Value = 201; } public void M102(out Int32 arg, Int32 arg2) { arg = 1; Flag.Value = 102; } public void M102(Int32 arg, params Int32[] arg2) { Flag.Value = 202; } @@ -512,7 +512,7 @@ public class COverloads_OneArg_OutNormal { public class COverloads_OneArg_OutRef { #region generated codes public void M100(out Int32 arg, ref Int32 arg2) { arg = 1; Flag.Value = 100; } - public void M100(Int32 arg, Int32 arg2 = 1) { Flag.Value = 200; } + public void M100(Int32 arg, Int32 arg2=1) { Flag.Value = 200; } public void M101(out Int32 arg, ref Int32 arg2) { arg = 1; Flag.Value = 101; } public void M101(Int32 arg, params Int32[] arg2) { Flag.Value = 201; } @@ -524,10 +524,10 @@ public class COverloads_OneArg_OutRef { } public class COverloads_OneArg_NormalDefault { #region generated codes - public void M100(Int32 arg, Int32 arg2 = 1) { Flag.Value = 100; } + public void M100(Int32 arg, Int32 arg2=1) { Flag.Value = 100; } public void M100(Int32 arg, params Int32[] arg2) { Flag.Value = 200; } - public void M101(Int32 arg, Int32 arg2 = 1) { Flag.Value = 101; } + public void M101(Int32 arg, Int32 arg2=1) { Flag.Value = 101; } public void M101(Int32 arg, Int32[] arg2) { Flag.Value = 201; } #endregion @@ -959,7 +959,7 @@ public interface IPublicInterface { public class InterfaceOnlyTest { public static IPublicInterface PrivateClass { get { - return new PrivateClass(); + return new PrivateClass(); } } } @@ -1001,7 +1001,7 @@ public void M() { } #endregion - + } internal class DerivedClassWithInterface : BaseClassNoInterface, I1 { diff --git a/tests/ironpython/Cases/CPythonCases.cs b/tests/ironpython/Cases/CPythonCases.cs index 395765c2f..f3d568064 100644 --- a/tests/ironpython/Cases/CPythonCases.cs +++ b/tests/ironpython/Cases/CPythonCases.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; - using NUnit.Framework; namespace IronPythonTest.Cases { @@ -20,7 +19,7 @@ public override int Test(TestInfo testcase) { internal class CPythonCaseGenerator : CommonCaseGenerator { protected override IEnumerable GetTests() { var libFolder = Path.Combine("Src", "StdLib", "Lib"); - return GetFilenames(new[] { + return GetFilenames(new [] { System.Tuple.Create(category, Path.Combine(libFolder, "test")), System.Tuple.Create($"{category}.ctypes", Path.Combine(libFolder, "ctypes", "test")), System.Tuple.Create($"{category}.distutils", Path.Combine(libFolder, "distutils", "tests")), diff --git a/tests/ironpython/Cases/CaseExecuter.cs b/tests/ironpython/Cases/CaseExecuter.cs index 6bd56cc0e..d75cbc047 100644 --- a/tests/ironpython/Cases/CaseExecuter.cs +++ b/tests/ironpython/Cases/CaseExecuter.cs @@ -8,6 +8,7 @@ using System.IO; using System.Linq; using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -17,11 +18,11 @@ using IronPython.Runtime; using IronPython.Runtime.Exceptions; -using IronPythonTest.Util; - using Microsoft.Scripting; using Microsoft.Scripting.Hosting; +using IronPythonTest.Util; + namespace IronPythonTest.Cases { internal class CaseExecuter { private static string Executable { diff --git a/tests/ironpython/Cases/CaseGenerator.cs b/tests/ironpython/Cases/CaseGenerator.cs index 23acb7af5..fea1754ed 100644 --- a/tests/ironpython/Cases/CaseGenerator.cs +++ b/tests/ironpython/Cases/CaseGenerator.cs @@ -10,7 +10,6 @@ using System.Runtime.InteropServices; using IronPython; - using IronPythonTest.Util; using NUnit.Framework; diff --git a/tests/ironpython/Cases/IronPythonCases.cs b/tests/ironpython/Cases/IronPythonCases.cs index 34760546f..2cd431625 100644 --- a/tests/ironpython/Cases/IronPythonCases.cs +++ b/tests/ironpython/Cases/IronPythonCases.cs @@ -5,12 +5,11 @@ using System.Collections.Generic; using System.IO; using System.Linq; - using NUnit.Framework; namespace IronPythonTest.Cases { [TestFixture(Category = "IronPython")] - public class IronPythonCases : CommonCases { + public class IronPythonCases : CommonCases { [Test, TestCaseSource(typeof(IronPythonCaseGenerator))] public override int Test(TestInfo testcase) { return TestImpl(testcase); diff --git a/tests/ironpython/ClrType.cs b/tests/ironpython/ClrType.cs index 25fdcee73..787a4b42c 100644 --- a/tests/ironpython/ClrType.cs +++ b/tests/ironpython/ClrType.cs @@ -3,10 +3,10 @@ // See the LICENSE file in the project root for more information. using System; - -using IronPython.Runtime; -using IronPython.Runtime.Exceptions; using IronPython.Runtime.Types; +using Microsoft.Scripting; +using IronPython.Runtime.Exceptions; +using IronPython.Runtime; namespace IronPythonTest.interop.net.type.clrtype { diff --git a/tests/ironpython/Conversions.cs b/tests/ironpython/Conversions.cs index 4ac0b339c..ee1b94372 100644 --- a/tests/ironpython/Conversions.cs +++ b/tests/ironpython/Conversions.cs @@ -2,11 +2,10 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using IronPython.Runtime; using System.Collections; using System.Collections.Generic; -using IronPython.Runtime; - namespace IronPythonTest { /// /// Base used for implicit operator tests where the operator is defined diff --git a/tests/ironpython/DynamicRegressions.cs b/tests/ironpython/DynamicRegressions.cs index e3133421c..8bc731024 100644 --- a/tests/ironpython/DynamicRegressions.cs +++ b/tests/ironpython/DynamicRegressions.cs @@ -6,8 +6,8 @@ namespace IronPythonTest { public static class DynamicRegressions { - - public static string cp24117(dynamic inputObj) { + + public static string cp24117(dynamic inputObj){ return inputObj.ToString(); } @@ -21,9 +21,12 @@ public static void cp24118(dynamic pythonCode) { } private static void NamedMethod01(dynamic testObj) { - try { + try + { System.Console.WriteLine("1)-1 Exp=33, Act={0}", testObj.Normal01(a: 11, b: 22)); - } catch (System.Exception e) { + } + catch (System.Exception e) + { System.Console.WriteLine("1) a:v, b:v => {0}", e); System.Console.WriteLine("====================================="); } @@ -35,32 +38,39 @@ private static void NamedMethod01(dynamic testObj) { private static void NamedMethod02(dynamic testObj) { // b=1 System.Console.WriteLine("2)-1 Exp=11, Act={0}", testObj.Optional01(a: 10)); // OK - try { + try + { System.Console.WriteLine("2)-2 Exp=33, Act={0}", testObj.Optional01(a: 11, b: 22)); - } catch (System.Exception e) { + } + catch (System.Exception e) + { System.Console.WriteLine("2) a:v, b:v => {0}", e); System.Console.WriteLine("====================================="); } System.Console.WriteLine("2)-3 Exp=38, Act={0}", testObj.Optional01(b: 33, a: 5)); // OK } - + public static void cp24115(dynamic testObj) { try { testObj.x(); throw new Exception("Invoking non-existent method 'x' should have thrown"); - } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex) { + } + catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex) + { if (!ex.Message.Contains("'x'")) { throw new Exception("Error message didn't contain 'x'", ex); } } } - public static bool cp24111(dynamic testObj) { + public static bool cp24111(dynamic testObj) + { return !testObj; } - public static void cp24088(dynamic testObj) { + public static void cp24088(dynamic testObj) + { testObj += 3; } } diff --git a/tests/ironpython/EncodingTest.cs b/tests/ironpython/EncodingTest.cs index 46884269d..7864f0a12 100644 --- a/tests/ironpython/EncodingTest.cs +++ b/tests/ironpython/EncodingTest.cs @@ -4,13 +4,11 @@ #pragma warning disable SYSLIB0001 // UTF-7 code paths are obsolete in .NET 5 -using System.Linq; -using System.Text; - using IronPython.Runtime; using IronPython.Runtime.Operations; - using NUnit.Framework; +using System.Linq; +using System.Text; namespace IronPythonTest { diff --git a/tests/ironpython/EngineTest.cs b/tests/ironpython/EngineTest.cs index 22d686332..f6cd8b21f 100644 --- a/tests/ironpython/EngineTest.cs +++ b/tests/ironpython/EngineTest.cs @@ -8,8 +8,10 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Diagnostics; using System.Dynamic; using System.IO; +using System.Reflection; using System.Runtime.CompilerServices; using System.Security; #if FEATURE_REMOTING @@ -26,6 +28,7 @@ using Microsoft.Scripting.Hosting; using Microsoft.Scripting.Runtime; +using IronPython; using IronPython.Hosting; using IronPython.Runtime; using IronPython.Runtime.Exceptions; diff --git a/tests/ironpython/Events.cs b/tests/ironpython/Events.cs index f834ee97c..d765c7b85 100644 --- a/tests/ironpython/Events.cs +++ b/tests/ironpython/Events.cs @@ -37,7 +37,7 @@ public static void CallOtherStatic(object sender, EventArgs args) { private bool _marker = false; - public bool Marker { + public bool Marker { get { return _marker; } set { _marker = value; } } diff --git a/tests/ironpython/ExtensionMethodTest.cs b/tests/ironpython/ExtensionMethodTest.cs index 458ff6250..8526e7411 100644 --- a/tests/ironpython/ExtensionMethodTest.cs +++ b/tests/ironpython/ExtensionMethodTest.cs @@ -2,11 +2,13 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Collections; +using System; using System.Collections.Generic; -using System.Numerics; - +using System.Linq; +using System.Text; using IronPython.Runtime; +using System.Collections; +using System.Numerics; namespace IronPythonTest.ExtensionMethodTest { namespace LinqCollision { diff --git a/tests/ironpython/Indexable.cs b/tests/ironpython/Indexable.cs index 30c82ba39..3c5681e67 100644 --- a/tests/ironpython/Indexable.cs +++ b/tests/ironpython/Indexable.cs @@ -590,7 +590,7 @@ public IEnumerator GetEnumerator() { yield return 3; } } - + public class UsePythonDictAsHashtable { private Hashtable table; diff --git a/tests/ironpython/InheritTest.cs b/tests/ironpython/InheritTest.cs index 1e19ed30e..28096c872 100644 --- a/tests/ironpython/InheritTest.cs +++ b/tests/ironpython/InheritTest.cs @@ -8,15 +8,14 @@ using System.Numerics; using System.Runtime.CompilerServices; using System.Text; - using IronPython.Runtime; namespace IronPythonTest { public interface IOverrideTestInterface { - object x { get; set; } + object x { get;set;} string Method(); - string y { get; set; } + string y { get;set;} string MethodOverridden(); object this[int index] { @@ -28,9 +27,9 @@ object this[int index] { public class OverrideTestDerivedClass : IOverrideTestInterface { public static string Value; - object IOverrideTestInterface.x { get { return "IOverrideTestInterface.x invoked"; } set { Value = value.ToString() + "x"; } } + object IOverrideTestInterface.x { get { return "IOverrideTestInterface.x invoked"; } set { Value = value.ToString() + "x"; } } string IOverrideTestInterface.Method() { return "IOverrideTestInterface.method() invoked"; } - string IOverrideTestInterface.y { get { return "IOverrideTestInterface.y invoked"; } set { Value = value.ToString() + "y"; } } + string IOverrideTestInterface.y { get { return "IOverrideTestInterface.y invoked"; } set { Value = value.ToString() + "y"; } } public string y { get { return "OverrideTestDerivedClass.y invoked"; } } string IOverrideTestInterface.MethodOverridden() { return "IOverrideTestInterface.MethodOverridden() invoked"; } public string MethodOverridden() { return "OverrideTestDerivedClass.MethodOverridden() invoked"; } @@ -183,7 +182,7 @@ public NewClass(int width, int height) : base(-1, -1) { public new virtual MySize Size { get { - return new MySize(size.width + 1, size.height + 1); + return new MySize(size.width+1, size.height+1); } set { size = value; @@ -192,19 +191,19 @@ public NewClass(int width, int height) : base(-1, -1) { public new virtual int Height { get { - return size.height * 2 + 1; + return size.height*2 + 1; } set { - size.height = value / 2 + 1; + size.height = value/2 + 1; } } public new virtual int Width { get { - return size.width * 2 + 1; + return size.width*2 + 1; } set { - size.width = value / 2 + 1; + size.width = value/2 + 1; } } } @@ -933,7 +932,7 @@ public object CallParamsWithContext(CodeContext context, params object[] arg) { return ParamsMethodWithContext(context, arg); } - public object CallIntParamsWithContext(CodeContext context, params int[] arg) { + public object CallIntParamsWithContext(CodeContext context, params int[] arg) { return ParamsIntMethodWithContext(context, arg); } } @@ -1128,7 +1127,7 @@ public static object[] GoWildBig(IGenericMethods i, bool first, string second, I public class FamilyOrAssembly { private object _value; - + protected internal int Method() { return 42; } diff --git a/tests/ironpython/IronMath.cs b/tests/ironpython/IronMath.cs index 63ffaa0fc..d824bc05e 100644 --- a/tests/ironpython/IronMath.cs +++ b/tests/ironpython/IronMath.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Numerics; - using Microsoft.Scripting.Utils; namespace IronPythonTest { diff --git a/tests/ironpython/MemberMappingTests.cs b/tests/ironpython/MemberMappingTests.cs index 7540da5da..8d635a116 100644 --- a/tests/ironpython/MemberMappingTests.cs +++ b/tests/ironpython/MemberMappingTests.cs @@ -2,9 +2,10 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Collections; +using System; using System.Collections.Generic; - +using System.Text; +using System.Collections; using IronPython.Runtime.Operations; // Includes tests for mapping from .NET interfaces & known types to various Python protocol methods. diff --git a/tests/ironpython/MemberOverloadTest.cs b/tests/ironpython/MemberOverloadTest.cs index 25fb56b66..cbe04f170 100644 --- a/tests/ironpython/MemberOverloadTest.cs +++ b/tests/ironpython/MemberOverloadTest.cs @@ -1,5 +1,4 @@ using System; - using IronPython.Runtime; namespace IronPythonTest { @@ -21,7 +20,7 @@ public void SetMember(string name, object value) { public void SetMember(CodeContext context, string name, object value) { throw new InvalidOperationException("Do not call SetMember1"); } - + public object GetBoundMember(string name) { throw new InvalidOperationException("Do not call GetBoundMember0"); } @@ -29,7 +28,7 @@ public object GetBoundMember(string name) { public object GetBoundMember(CodeContext context, string name) { throw new InvalidOperationException("Do not call GetBoundMember1"); } - + public object GetCustomMember(string name) { throw new InvalidOperationException("Do not call GetCustomMember0"); } @@ -37,7 +36,7 @@ public object GetCustomMember(string name) { public object GetCustomMember(CodeContext context, string name) { throw new InvalidOperationException("Do not call GetCustomMember1"); } - + public void DeleteMember(string name) { throw new InvalidOperationException("Do not call DeleteMember0"); } diff --git a/tests/ironpython/MethodParametersStubs.cs b/tests/ironpython/MethodParametersStubs.cs index e24f62914..3b9f3a13c 100644 --- a/tests/ironpython/MethodParametersStubs.cs +++ b/tests/ironpython/MethodParametersStubs.cs @@ -5,14 +5,16 @@ using System.Collections; using System.Collections.Generic; using System.ComponentModel; +using System.Net.NetworkInformation; +using System.Runtime.InteropServices; using Microsoft.Scripting; namespace IronPythonTest { public static class DefaultParams { - public static int FuncWithDefaults(int x = 1, - int y = 2, - int z = 3) { + public static int FuncWithDefaults(int x=1, + int y=2, + int z=3) { return x + y + z; } } diff --git a/tests/ironpython/NullableTest.cs b/tests/ironpython/NullableTest.cs index 3c82e4fea..3bca6fb90 100644 --- a/tests/ironpython/NullableTest.cs +++ b/tests/ironpython/NullableTest.cs @@ -4,8 +4,8 @@ namespace IronPythonTest { public class NullableTest { - public enum NullableEnums { NE1 = 1, NE3 = 3 }; - + public enum NullableEnums { NE1=1, NE3=3 }; + private double? _dvalue; private long? _lvalue; private bool? _bvalue; @@ -16,17 +16,20 @@ public double? DProperty { set { _dvalue = value; } } - public long? LProperty { + public long? LProperty + { get { return _lvalue; } set { _lvalue = value; } } - public bool? BProperty { + public bool? BProperty + { get { return _bvalue; } set { _bvalue = value; } } - public NullableEnums? EProperty { + public NullableEnums? EProperty + { get { return _evalue; } set { _evalue = value; } } diff --git a/tests/ironpython/OperatorTest.cs b/tests/ironpython/OperatorTest.cs index 757964cb6..dc6694f0e 100644 --- a/tests/ironpython/OperatorTest.cs +++ b/tests/ironpython/OperatorTest.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; - using Microsoft.Scripting.Runtime; [assembly: ExtensionType(typeof(IronPythonTest.ExtendedClass), typeof(IronPythonTest.ExtensionClass))] diff --git a/tests/ironpython/ProtocolTest.cs b/tests/ironpython/ProtocolTest.cs index c14c7a648..43649545e 100644 --- a/tests/ironpython/ProtocolTest.cs +++ b/tests/ironpython/ProtocolTest.cs @@ -5,7 +5,6 @@ using System; using System.Collections; using System.Runtime.CompilerServices; - using NUnit.Framework; namespace IronPythonTest { diff --git a/tests/ironpython/StaticTest.cs b/tests/ironpython/StaticTest.cs index 1a2e2d415..67a356824 100644 --- a/tests/ironpython/StaticTest.cs +++ b/tests/ironpython/StaticTest.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Runtime.InteropServices; + namespace IronPythonTest.StaticTest { public class B { } public class D : B { } @@ -75,10 +77,10 @@ public class GB { public static string M4() { return "GB.M4-A"; } public static string M4(ref T arg) { return "GB.M4-B"; } - public static string M21(int arg1, int arg2 = 100) { return "GB.M21"; } + public static string M21(int arg1, int arg2=100) { return "GB.M21"; } public static string M22(int arg1) { return "GB.M22"; } - public static string M23(int arg = 100) { return "GB.M23"; } - public static string M24(int arg = 100) { return "GB.M24"; } + public static string M23(int arg=100) { return "GB.M23"; } + public static string M24(int arg=100) { return "GB.M24"; } public static string M25() { return "GB.M25"; } } @@ -90,10 +92,10 @@ public class GD : GB { public static string M4(ref int arg) { return "GD.M4"; } public static string M21(int arg1) { return "GD.M21"; } - public static string M22(int arg1, int arg2 = 100) { return "GD.M22"; } + public static string M22(int arg1, int arg2=100) { return "GD.M22"; } public static new string M23(int arg1) { return "GD.M23"; } public static string M24() { return "GD.M24"; } - public static string M25(int arg = 100) { return "GD.M25"; } + public static string M25(int arg=100) { return "GD.M25"; } } public class KB { diff --git a/tests/ironpython/Stress/Engine.cs b/tests/ironpython/Stress/Engine.cs index 7acebb3eb..f44c3a842 100644 --- a/tests/ironpython/Stress/Engine.cs +++ b/tests/ironpython/Stress/Engine.cs @@ -15,7 +15,7 @@ namespace IronPythonTest.Stress { - [TestFixture(Category = "IronPython")] + [TestFixture(Category="IronPython")] public class Engine #if FEATURE_REMOTING : MarshalByRefObject @@ -63,7 +63,8 @@ public void ScenarioXGC() { const long memoryThreshold = 100000; bool emitsUncollectibleCode = Snippets.Shared.SaveSnippets || _env.Setup.DebugMode; - if (!emitsUncollectibleCode) { + if (!emitsUncollectibleCode) + { System.Console.WriteLine("ScenarioGC used {0} bytes of memory.", memoryUsed); if (memoryUsed > memoryThreshold) { if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { diff --git a/tests/ironpython/StringDictionaryStorage.cs b/tests/ironpython/StringDictionaryStorage.cs index 5c7936cf2..2efd51d12 100644 --- a/tests/ironpython/StringDictionaryStorage.cs +++ b/tests/ironpython/StringDictionaryStorage.cs @@ -3,13 +3,14 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections; using System.Collections.Generic; using System.Threading; -using IronPython.Runtime; - using Microsoft.Scripting.Runtime; +using IronPython.Runtime; + namespace IronPythonTest { [Serializable] internal class StringDictionaryStorage : DictionaryStorage { @@ -119,7 +120,7 @@ public override List> GetItems() { } return res; } - + public override DictionaryStorage Clone() { lock (this) { IDictionary dict; @@ -142,7 +143,7 @@ public override DictionaryStorage Clone() { private void EnsureObjectDictionary() { if (_objDict == null) { Interlocked.CompareExchange>(ref _objDict, new Dictionary(DefaultContext.DefaultPythonContext.EqualityComparer), null); - } + } } } } diff --git a/tests/ironpython/TestBuiltinModule.cs b/tests/ironpython/TestBuiltinModule.cs index 201e307cf..d5c2b0899 100644 --- a/tests/ironpython/TestBuiltinModule.cs +++ b/tests/ironpython/TestBuiltinModule.cs @@ -2,10 +2,12 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; using System.Collections.Generic; - -using IronPython.Compiler; +using System.Linq; +using System.Text; using IronPython.Runtime; +using IronPython.Compiler; [assembly: PythonModule("test_new_module", typeof(IronPythonTest.TestBuiltinModule))] namespace IronPythonTest { diff --git a/tests/ironpython/TypeDescriptor.cs b/tests/ironpython/TypeDescriptor.cs index 158a65dc2..1d56536ea 100644 --- a/tests/ironpython/TypeDescriptor.cs +++ b/tests/ironpython/TypeDescriptor.cs @@ -105,7 +105,7 @@ public object CallCanConvertToForInt(object totest) { public interface IClassFactory { [return: MarshalAs(UnmanagedType.Interface)] object CreateInstance( - [MarshalAs(UnmanagedType.IUnknown)] object pOuterUnk, + [MarshalAs(UnmanagedType.IUnknown)]object pOuterUnk, ref Guid iid); void LockServer(bool Lock); diff --git a/tests/ironpython/Util/IniParser.cs b/tests/ironpython/Util/IniParser.cs index d4dca59a4..a5101dfc1 100644 --- a/tests/ironpython/Util/IniParser.cs +++ b/tests/ironpython/Util/IniParser.cs @@ -7,8 +7,8 @@ using System.IO; namespace IronPythonTest.Util { - using OptionStore = Dictionary>; using Section = Dictionary; + using OptionStore = Dictionary>; public class IniParser { private OptionStore options; @@ -68,7 +68,7 @@ private static OptionStore Parse(IEnumerable lines) { Section currentSection = new Section(); OptionStore options = new OptionStore(StringComparer.OrdinalIgnoreCase) { { "DEFAULT", currentSection } }; foreach (var rawline in lines) { - string line = rawline.Split(new[] { ';', '#' }, 2)[0].Trim(); + string line = rawline.Split(new [] { ';', '#' }, 2)[0].Trim(); if (string.IsNullOrEmpty(line)) continue; @@ -78,9 +78,9 @@ private static OptionStore Parse(IEnumerable lines) { if (!options.TryGetValue(sectionName, out currentSection)) { currentSection = new Section(); options.Add(sectionName, currentSection); - } + } } else { - var result = line.Split(new[] { '=' }, 2); + var result = line.Split(new [] {'='}, 2); var key = result[0].Trim(); var value = result.Length > 1 ? result[1] : "1"; @@ -122,7 +122,7 @@ public static bool AsBool(this string s) { } public static int AsInt(this string s) { - if (s == null) { + if(s == null) { throw new ArgumentNullException(nameof(s)); } diff --git a/tests/ironpython/Util/TestManifest.cs b/tests/ironpython/Util/TestManifest.cs index 313560f5b..af01c800e 100644 --- a/tests/ironpython/Util/TestManifest.cs +++ b/tests/ironpython/Util/TestManifest.cs @@ -3,6 +3,10 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; namespace IronPythonTest.Util { public class TestManifest { From 3a11995144dfb9c9d27872b02bbe2d04cea7b90e Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:01:06 +0000 Subject: [PATCH 41/84] Initial rename of core folder --- src/{ipy => core}/CTypes/Makefile | 0 src/{ipy => core}/CTypes/_ctypes_test.c | 0 src/{ipy => core}/CTypes/_ctypes_test.sln | 0 src/{ipy => core}/CTypes/_ctypes_test.vcxproj | 0 .../IronPython.CompilerServices/AssemblyResolver.cs | 0 .../IronPython.CompilerServices/Config.cs | 0 .../IronPython.CompilerServices/ConsoleOps.cs | 0 .../IronPython.CompilerServices.csproj | 0 .../IronPython.CompilerServices/Program.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../IronPython.CompilerServices/README.md | 0 .../IronPython.Modules/IronPython.Modules.csproj | 0 src/{ipy => core}/IronPython.Modules/IterTools.cs | 0 src/{ipy => core}/IronPython.Modules/ModuleOps.cs | 0 .../IronPython.Modules/NtSignalState.cs | 0 .../IronPython.Modules/Properties/AssemblyInfo.cs | 0 .../IronPython.Modules/ResourceMetaPathImporter.cs | 0 .../IronPython.Modules/SimpleSignalState.cs | 0 src/{ipy => core}/IronPython.Modules/_bisect.cs | 0 src/{ipy => core}/IronPython.Modules/_codecs.cs | 0 src/{ipy => core}/IronPython.Modules/_codecs_cn.cs | 0 .../IronPython.Modules/_collections.cs | 0 src/{ipy => core}/IronPython.Modules/_csv.cs | 0 .../IronPython.Modules/_ctypes/Array.cs | 0 .../IronPython.Modules/_ctypes/ArrayType.cs | 0 .../IronPython.Modules/_ctypes/CData.cs | 0 .../IronPython.Modules/_ctypes/CFuncPtr.cs | 0 .../IronPython.Modules/_ctypes/CFuncPtrType.cs | 0 .../IronPython.Modules/_ctypes/Extensions.cs | 0 .../IronPython.Modules/_ctypes/Field.cs | 0 .../IronPython.Modules/_ctypes/INativeType.cs | 0 .../IronPython.Modules/_ctypes/LocalOrArg.cs | 0 .../IronPython.Modules/_ctypes/MarshalCleanup.cs | 0 .../IronPython.Modules/_ctypes/MemoryHolder.cs | 0 .../IronPython.Modules/_ctypes/NativeArgument.cs | 0 .../IronPython.Modules/_ctypes/NativeFunctions.cs | 0 .../IronPython.Modules/_ctypes/Pointer.cs | 0 .../IronPython.Modules/_ctypes/PointerType.cs | 0 .../IronPython.Modules/_ctypes/SimpleCData.cs | 0 .../IronPython.Modules/_ctypes/SimpleType.cs | 0 .../IronPython.Modules/_ctypes/SimpleTypeKind.cs | 0 .../IronPython.Modules/_ctypes/StructType.cs | 0 .../IronPython.Modules/_ctypes/Structure.cs | 0 .../IronPython.Modules/_ctypes/Union.cs | 0 .../IronPython.Modules/_ctypes/UnionType.cs | 0 .../IronPython.Modules/_ctypes/_ctypes.cs | 0 .../IronPython.Modules/_ctypes_test.cs | 0 src/{ipy => core}/IronPython.Modules/_datetime.cs | 0 src/{ipy => core}/IronPython.Modules/_functools.cs | 0 src/{ipy => core}/IronPython.Modules/_heapq.cs | 0 .../IronPython.Modules/_multibytecodec.cs | 0 .../IronPython.Modules/_multiprocessing.cs | 0 src/{ipy => core}/IronPython.Modules/_opcode.cs | 0 src/{ipy => core}/IronPython.Modules/_operator.cs | 0 src/{ipy => core}/IronPython.Modules/_overlapped.cs | 0 src/{ipy => core}/IronPython.Modules/_pickle.cs | 0 .../IronPython.Modules/_posixsubprocess.cs | 0 .../IronPython.Modules/_random.RandomGen.cs | 0 src/{ipy => core}/IronPython.Modules/_random.cs | 0 src/{ipy => core}/IronPython.Modules/_socket.cs | 0 src/{ipy => core}/IronPython.Modules/_sre.cs | 0 src/{ipy => core}/IronPython.Modules/_ssl.cs | 0 src/{ipy => core}/IronPython.Modules/_string.cs | 0 src/{ipy => core}/IronPython.Modules/_struct.cs | 0 .../IronPython.Modules/_sysconfigdata.cs | 0 src/{ipy => core}/IronPython.Modules/_thread.cs | 0 src/{ipy => core}/IronPython.Modules/_warnings.cs | 0 .../IronPython.Modules/_weakref.Generated.cs | 0 src/{ipy => core}/IronPython.Modules/_weakref.cs | 0 src/{ipy => core}/IronPython.Modules/_winapi.cs | 0 src/{ipy => core}/IronPython.Modules/array.cs | 0 src/{ipy => core}/IronPython.Modules/atexit.cs | 0 src/{ipy => core}/IronPython.Modules/audioop.cs | 0 src/{ipy => core}/IronPython.Modules/binascii.cs | 0 .../IronPython.Modules/bz2/BZ2Compressor.cs | 0 .../IronPython.Modules/bz2/BZ2Decompressor.cs | 0 .../IronPython.Modules/bz2/BZ2Module.cs | 0 .../bz2/dotnetzip/BZip2/BZip2Compressor.cs | 0 .../bz2/dotnetzip/BZip2/BZip2InputStream.cs | 0 .../bz2/dotnetzip/BZip2/BZip2OutputStream.cs | 0 .../bz2/dotnetzip/BZip2/BitWriter.cs | 0 .../IronPython.Modules/bz2/dotnetzip/BZip2/CRC32.cs | 0 .../dotnetzip/BZip2/ParallelBZip2OutputStream.cs | 0 .../IronPython.Modules/bz2/dotnetzip/BZip2/Rand.cs | 0 .../IronPython.Modules/bz2/dotnetzip/source.txt | 0 src/{ipy => core}/IronPython.Modules/cmath.cs | 0 src/{ipy => core}/IronPython.Modules/errno.cs | 0 .../IronPython.Modules/faulthandler.cs | 0 src/{ipy => core}/IronPython.Modules/fcntl.cs | 0 src/{ipy => core}/IronPython.Modules/gc.cs | 0 src/{ipy => core}/IronPython.Modules/grp.cs | 0 .../hashlib/MD5CryptoServiceProvider.cs | 0 .../hashlib/SHA1CryptoServiceProvider.cs | 0 .../IronPython.Modules/hashlib/SHA224.cs | 0 .../IronPython.Modules/hashlib/SHA224Managed.cs | 0 .../IronPython.Modules/hashlib/SHA256Managed.cs | 0 .../IronPython.Modules/hashlib/SHA384Managed.cs | 0 .../IronPython.Modules/hashlib/SHA512Managed.cs | 0 .../IronPython.Modules/hashlib/SHAConstants.cs | 0 .../IronPython.Modules/hashlib/_hashlib.cs | 0 .../IronPython.Modules/hashlib/_md5.cs | 0 .../IronPython.Modules/hashlib/_sha1.cs | 0 .../IronPython.Modules/hashlib/_sha256.cs | 0 .../IronPython.Modules/hashlib/_sha512.cs | 0 src/{ipy => core}/IronPython.Modules/marshal.cs | 0 .../IronPython.Modules/math.Generated.cs | 0 src/{ipy => core}/IronPython.Modules/math.cs | 0 src/{ipy => core}/IronPython.Modules/mmap.cs | 0 src/{ipy => core}/IronPython.Modules/msvcrt.cs | 0 src/{ipy => core}/IronPython.Modules/nt.cs | 0 .../policy.IronPython.Modules.config | 0 src/{ipy => core}/IronPython.Modules/pwd.cs | 0 src/{ipy => core}/IronPython.Modules/pyexpat.cs | 0 src/{ipy => core}/IronPython.Modules/re.cs | 0 src/{ipy => core}/IronPython.Modules/resource.cs | 0 src/{ipy => core}/IronPython.Modules/select.cs | 0 src/{ipy => core}/IronPython.Modules/signal.cs | 0 src/{ipy => core}/IronPython.Modules/spwd.cs | 0 src/{ipy => core}/IronPython.Modules/time.cs | 0 src/{ipy => core}/IronPython.Modules/winreg.cs | 0 src/{ipy => core}/IronPython.Modules/winsound.cs | 0 src/{ipy => core}/IronPython.Modules/xxsubtype.cs | 0 src/{ipy => core}/IronPython.Modules/zipimport.cs | 0 .../IronPython.Modules/zlib/Compress.cs | 0 .../IronPython.Modules/zlib/Decompress.cs | 0 .../IronPython.Modules/zlib/ZlibModule.cs | 0 .../IronPython.Modules/zlib/zlib.net/Adler32.cs | 0 .../IronPython.Modules/zlib/zlib.net/Deflate.cs | 0 .../IronPython.Modules/zlib/zlib.net/InfBlocks.cs | 0 .../IronPython.Modules/zlib/zlib.net/InfCodes.cs | 0 .../IronPython.Modules/zlib/zlib.net/InfTree.cs | 0 .../IronPython.Modules/zlib/zlib.net/Inflate.cs | 0 .../IronPython.Modules/zlib/zlib.net/StaticTree.cs | 0 .../IronPython.Modules/zlib/zlib.net/Tree.cs | 0 .../IronPython.Modules/zlib/zlib.net/ZStream.cs | 0 .../zlib/zlib.net/ZStreamException.cs | 0 .../IronPython.Modules/zlib/zlib.net/Zlib.cs | 0 .../IronPython.Modules/zlib/zlib.net/history.txt | 0 .../IronPython.Modules/zlib/zlib.net/license.txt | 0 .../IronPython.Modules/zlib/zlib.net/readme.txt | 0 .../IronPython/Compiler/Ast/AndExpression.cs | 0 .../Compiler/Ast/AnnotatedAssignStatement.cs | 0 .../IronPython/Compiler/Ast/AssertStatement.cs | 0 .../IronPython/Compiler/Ast/AssignmentStatement.cs | 0 .../IronPython/Compiler/Ast/AstMethods.cs | 0 .../IronPython/Compiler/Ast/AsyncStatement.cs | 0 .../Compiler/Ast/AugmentedAssignStatement.cs | 0 .../Compiler/Ast/BinaryExpression.Generated.cs | 0 .../IronPython/Compiler/Ast/BinaryExpression.cs | 0 .../IronPython/Compiler/Ast/BreakStatement.cs | 0 .../IronPython/Compiler/Ast/CallExpression.cs | 0 .../IronPython/Compiler/Ast/ClassDefinition.cs | 0 .../IronPython/Compiler/Ast/Comprehension.cs | 0 .../IronPython/Compiler/Ast/ComprehensionFor.cs | 0 .../IronPython/Compiler/Ast/ComprehensionIf.cs | 0 .../Compiler/Ast/ConditionalExpression.cs | 0 .../IronPython/Compiler/Ast/ConstantExpression.cs | 0 .../IronPython/Compiler/Ast/ContinueStatement.cs | 0 .../IronPython/Compiler/Ast/DelStatement.cs | 0 .../IronPython/Compiler/Ast/DictionaryExpression.cs | 0 .../IronPython/Compiler/Ast/DottedName.cs | 0 .../Compiler/Ast/DynamicConvertExpression.cs | 0 .../Compiler/Ast/DynamicGetMemberExpression.cs | 0 .../IronPython/Compiler/Ast/EmptyStatement.cs | 0 .../IronPython/Compiler/Ast/ErrorExpression.cs | 0 .../IronPython/Compiler/Ast/Expression.cs | 0 .../IronPython/Compiler/Ast/ExpressionStatement.cs | 0 .../IronPython/Compiler/Ast/FlowChecker.cs | 0 .../IronPython/Compiler/Ast/ForStatement.cs | 0 .../Compiler/Ast/FormattedValueExpression.cs | 0 .../IronPython/Compiler/Ast/FromImportStatement.cs | 0 .../IronPython/Compiler/Ast/FunctionDefinition.cs | 0 .../IronPython/Compiler/Ast/GeneratorExpression.cs | 0 .../Compiler/Ast/GetGlobalContextExpression.cs | 0 .../Ast/GetParentContextFromFunctionExpression.cs | 0 .../IronPython/Compiler/Ast/GlobalStatement.cs | 0 .../IronPython/Compiler/Ast/ILoopStatement.cs | 0 .../IronPython/Compiler/Ast/IfStatement.cs | 0 .../IronPython/Compiler/Ast/IfStatementTest.cs | 0 .../IronPython/Compiler/Ast/ImportStatement.cs | 0 .../IronPython/Compiler/Ast/IndexExpression.cs | 0 .../Compiler/Ast/JoinedStringExpression.cs | 0 .../IronPython/Compiler/Ast/Keyword.cs | 0 .../IronPython/Compiler/Ast/LambdaExpression.cs | 0 .../IronPython/Compiler/Ast/ListExpression.cs | 0 .../IronPython/Compiler/Ast/MemberExpression.cs | 0 .../IronPython/Compiler/Ast/ModuleName.cs | 0 .../IronPython/Compiler/Ast/NameExpression.cs | 0 src/{ipy => core}/IronPython/Compiler/Ast/Node.cs | 0 .../IronPython/Compiler/Ast/NonlocalStatement.cs | 0 .../IronPython/Compiler/Ast/OrExpression.cs | 0 .../IronPython/Compiler/Ast/Parameter.cs | 0 .../Compiler/Ast/ParenthesisExpression.cs | 0 .../IronPython/Compiler/Ast/PythonAst.cs | 0 .../Compiler/Ast/PythonConstantExpression.cs | 0 .../IronPython/Compiler/Ast/PythonNameBinder.cs | 0 .../IronPython/Compiler/Ast/PythonReference.cs | 0 .../IronPython/Compiler/Ast/PythonVariable.cs | 0 .../Compiler/Ast/PythonWalker.Generated.cs | 0 .../IronPython/Compiler/Ast/RaiseStatement.cs | 0 .../IronPython/Compiler/Ast/RelativeModuleName.cs | 0 .../IronPython/Compiler/Ast/ReturnStatement.cs | 0 .../IronPython/Compiler/Ast/ScopeStatement.cs | 0 .../IronPython/Compiler/Ast/SequenceExpression.cs | 0 .../Compiler/Ast/SerializedScopeStatement.cs | 0 .../IronPython/Compiler/Ast/SetExpression.cs | 0 .../IronPython/Compiler/Ast/SliceExpression.cs | 0 .../IronPython/Compiler/Ast/StarredExpression.cs | 0 .../IronPython/Compiler/Ast/Statement.cs | 0 .../IronPython/Compiler/Ast/SuiteStatement.cs | 0 .../IronPython/Compiler/Ast/TryStatement.cs | 0 .../IronPython/Compiler/Ast/TupleExpression.cs | 0 .../IronPython/Compiler/Ast/UnaryExpression.cs | 0 .../IronPython/Compiler/Ast/VariableKind.cs | 0 .../IronPython/Compiler/Ast/WhileStatement.cs | 0 .../IronPython/Compiler/Ast/WithStatement.cs | 0 .../IronPython/Compiler/Ast/YieldExpression.cs | 0 .../IronPython/Compiler/Ast/YieldFromExpression.cs | 0 .../IronPython/Compiler/ClosureExpression.cs | 0 .../IronPython/Compiler/ClosureInfo.cs | 0 .../Compiler/CollectableCompilationMode.cs | 0 .../IronPython/Compiler/CompilationMode.cs | 0 .../IronPython/Compiler/GeneratorRewriter.cs | 0 src/{ipy => core}/IronPython/Compiler/LazyCode.cs | 0 .../IronPython/Compiler/LookupCompilationMode.cs | 0 .../IronPython/Compiler/OnDiskScriptCode.cs | 0 src/{ipy => core}/IronPython/Compiler/Parser.cs | 0 .../IronPython/Compiler/PythonCallTargets.cs | 0 .../IronPython/Compiler/PythonCompilerOptions.cs | 0 .../IronPython/Compiler/PythonDynamicExpression.cs | 0 .../IronPython/Compiler/PythonGlobal.cs | 0 .../Compiler/PythonGlobalVariableExpression.cs | 0 .../IronPython/Compiler/PythonOperator.cs | 0 .../IronPython/Compiler/PythonSavableScriptCode.cs | 0 .../IronPython/Compiler/PythonScriptCode.cs | 0 .../Compiler/ReducableDynamicExpression.cs | 0 .../IronPython/Compiler/RunnableScriptCode.cs | 0 .../IronPython/Compiler/RuntimeScriptCode.cs | 0 .../IronPython/Compiler/ToDiskCompilationMode.cs | 0 src/{ipy => core}/IronPython/Compiler/Token.cs | 0 .../IronPython/Compiler/TokenKind.Generated.cs | 0 .../IronPython/Compiler/Tokenizer.Generated.cs | 0 src/{ipy => core}/IronPython/Compiler/Tokenizer.cs | 0 .../UncollectableCompilationMode.Generated.cs | 0 .../Compiler/UncollectableCompilationMode.cs | 0 src/{ipy => core}/IronPython/FakeInteropServices.cs | 0 src/{ipy => core}/IronPython/Hosting/Python.cs | 0 .../IronPython/Hosting/PythonCodeDomCodeGen.cs | 0 .../IronPython/Hosting/PythonCommandLine.cs | 0 .../IronPython/Hosting/PythonConsoleOptions.cs | 0 .../IronPython/Hosting/PythonOptionsParser.cs | 0 .../IronPython/Hosting/PythonService.cs | 0 .../IronPython/Interop/Windows/Interop.Libraries.cs | 0 .../Windows/Kernel32/Interop.GetWindowsExW.cs | 0 .../Windows/Kernel32/Interop.OSVERSIONINFOEX.cs | 0 .../Interop/Windows/NtDll/Interop.RtlGetVersion.cs | 0 .../Interop/Windows/Ucrtbase/Interop.strerror.cs | 0 src/{ipy => core}/IronPython/IronPython.csproj | 0 src/{ipy => core}/IronPython/Lib/iptest/__init__.py | 0 .../IronPython/Lib/iptest/cominterop_util.py | 0 .../IronPython/Lib/iptest/console_util.py | 0 .../IronPython/Lib/iptest/file_util.py | 0 .../IronPython/Lib/iptest/ipunittest.py | 0 .../IronPython/Lib/iptest/misc_util.py | 0 .../IronPython/Lib/iptest/process_util.py | 0 src/{ipy => core}/IronPython/Lib/iptest/runner.py | 0 src/{ipy => core}/IronPython/Lib/iptest/test_env.py | 0 .../IronPython/Lib/iptest/type_util.py | 0 .../IronPython/Modules/Builtin.Generated.cs | 0 src/{ipy => core}/IronPython/Modules/Builtin.cs | 0 src/{ipy => core}/IronPython/Modules/_ast.cs | 0 src/{ipy => core}/IronPython/Modules/_fileio.cs | 0 src/{ipy => core}/IronPython/Modules/_imp.cs | 0 src/{ipy => core}/IronPython/Modules/_io.cs | 0 src/{ipy => core}/IronPython/Modules/_io/BytesIO.cs | 0 .../IronPython/Modules/_io/StringIO.cs | 0 src/{ipy => core}/IronPython/Modules/_locale.cs | 0 src/{ipy => core}/IronPython/Modules/sys.cs | 0 src/{ipy => core}/IronPython/Modules/unicodedata.cs | 0 .../IronPython/Modules/unicodedata/CaseFolding.txt | 0 .../Modules/unicodedata/EastAsianWidth-3.2.0.txt | 0 .../Modules/unicodedata/EastAsianWidth.txt | 0 .../Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz | Bin .../Modules/unicodedata/IPyUnicodeData.txt.gz | Bin .../IronPython/Modules/unicodedata/NameAliases.txt | 0 .../Modules/unicodedata/UnicodeData-3.2.0.txt | 0 .../IronPython/Modules/unicodedata/UnicodeData.txt | 0 .../Modules/unicodedata/genunicodedata.py | 0 .../IronPython/Modules/unicodedata/license.txt | 0 .../IronPython/Properties/AssemblyInfo.cs | 0 src/{ipy => core}/IronPython/Resources.Designer.cs | 0 src/{ipy => core}/IronPython/Resources.resx | 0 src/{ipy => core}/IronPython/Runtime/ArrayData.cs | 0 .../Binding/BinaryRetTypeBinder.Generated.cs | 0 .../Runtime/Binding/BinaryRetTypeBinder.cs | 0 .../IronPython/Runtime/Binding/Binders.cs | 0 .../IronPython/Runtime/Binding/BindingHelpers.cs | 0 .../IronPython/Runtime/Binding/BindingWarnings.cs | 0 .../Runtime/Binding/CompatibilityInvokeBinder.cs | 0 .../Runtime/Binding/ConditionalBuilder.cs | 0 .../IronPython/Runtime/Binding/ContextArgBuilder.cs | 0 .../IronPython/Runtime/Binding/ConversionBinder.cs | 0 .../Runtime/Binding/CreateFallbackBinder.cs | 0 .../IronPython/Runtime/Binding/FastBindResult.cs | 0 .../IronPython/Runtime/Binding/FastGetBase.cs | 0 .../IronPython/Runtime/Binding/FastSetBase.cs | 0 .../IronPython/Runtime/Binding/IComConvertible.cs | 0 .../IronPython/Runtime/Binding/IFastGettable.cs | 0 .../IronPython/Runtime/Binding/IFastInvokable.cs | 0 .../IronPython/Runtime/Binding/IFastSettable.cs | 0 .../Runtime/Binding/IPythonConvertible.cs | 0 .../IronPython/Runtime/Binding/IPythonExpandable.cs | 0 .../IronPython/Runtime/Binding/IPythonGetable.cs | 0 .../IronPython/Runtime/Binding/IPythonInvokable.cs | 0 .../IronPython/Runtime/Binding/IPythonOperable.cs | 0 .../IronPython/Runtime/Binding/IPythonSite.cs | 0 .../Runtime/Binding/MetaBuiltinFunction.cs | 0 .../Runtime/Binding/MetaBuiltinMethodDescriptor.cs | 0 .../IronPython/Runtime/Binding/MetaMethod.cs | 0 .../Runtime/Binding/MetaPythonFunction.cs | 0 .../IronPython/Runtime/Binding/MetaPythonObject.cs | 0 .../Runtime/Binding/MetaPythonType.Calls.cs | 0 .../Runtime/Binding/MetaPythonType.Members.cs | 0 .../IronPython/Runtime/Binding/MetaPythonType.cs | 0 .../Runtime/Binding/MetaUserObject.Members.cs | 0 .../IronPython/Runtime/Binding/MetaUserObject.cs | 0 .../Runtime/Binding/PythonBinaryOperationBinder.cs | 0 .../Runtime/Binding/PythonBinder.Create.cs | 0 .../IronPython/Runtime/Binding/PythonBinder.cs | 0 .../Runtime/Binding/PythonDeleteIndexBinder.cs | 0 .../Runtime/Binding/PythonDeleteMemberBinder.cs | 0 .../Runtime/Binding/PythonDeleteSliceBinder.cs | 0 .../Runtime/Binding/PythonExtensionBinder.cs | 0 .../Runtime/Binding/PythonGetIndexBinder.cs | 0 .../Runtime/Binding/PythonGetMemberBinder.cs | 0 .../Runtime/Binding/PythonGetSliceBinder.cs | 0 .../IronPython/Runtime/Binding/PythonIndexType.cs | 0 .../Runtime/Binding/PythonInvokeBinder.cs | 0 .../Runtime/Binding/PythonOperationBinder.cs | 0 .../Runtime/Binding/PythonOperationKind.cs | 0 .../Runtime/Binding/PythonOverloadResolver.cs | 0 .../Runtime/Binding/PythonProtocol.Operations.cs | 0 .../IronPython/Runtime/Binding/PythonProtocol.cs | 0 .../Runtime/Binding/PythonSetIndexBinder.cs | 0 .../Runtime/Binding/PythonSetMemberBinder.cs | 0 .../Runtime/Binding/PythonSetSliceBinder.cs | 0 .../Runtime/Binding/PythonUnaryOperationBinder.cs | 0 .../Runtime/Binding/SiteLocalStorageBuilder.cs | 0 .../IronPython/Runtime/Binding/SlotOrFunction.cs | 0 .../IronPython/Runtime/Binding/WarningInfo.cs | 0 .../IronPython/Runtime/BufferProtocol.cs | 0 .../IronPython/Runtime/BuiltinPythonModule.cs | 0 .../IronPython/Runtime/BuiltinsDictionaryStorage.cs | 0 src/{ipy => core}/IronPython/Runtime/ByteArray.cs | 0 .../IronPython/Runtime/ByteArrayIterator.cs | 0 src/{ipy => core}/IronPython/Runtime/Bytes.cs | 0 .../IronPython/Runtime/BytesIterator.cs | 0 .../IronPython/Runtime/BytesLikeAttribute.cs | 0 .../IronPython/Runtime/ClassMethodAttribute.cs | 0 .../IronPython/Runtime/ClassMethodDescriptor.cs | 0 src/{ipy => core}/IronPython/Runtime/ClrModule.cs | 0 src/{ipy => core}/IronPython/Runtime/CodeContext.cs | 0 .../IronPython/Runtime/CollectionDebugView.cs | 0 .../IronPython/Runtime/CommonDictionaryStorage.cs | 0 src/{ipy => core}/IronPython/Runtime/CompareUtil.cs | 0 .../IronPython/Runtime/CompileFlags.cs | 0 .../IronPython/Runtime/CompiledLoader.cs | 0 .../IronPython/Runtime/ConstantDictionaryStorage.cs | 0 .../IronPython/Runtime/ConversionWrappers.cs | 0 src/{ipy => core}/IronPython/Runtime/Converter.cs | 0 .../IronPython/Runtime/CustomDictionaryStorage.cs | 0 .../IronPython/Runtime/DebuggerDictionaryStorage.cs | 0 .../IronPython/Runtime/DefaultContext.cs | 0 src/{ipy => core}/IronPython/Runtime/Descriptors.cs | 0 .../IronPython/Runtime/DictionaryOps.cs | 0 .../IronPython/Runtime/DictionaryStorage.cs | 0 .../Runtime/DictionaryTypeInfoAttribute.cs | 0 .../Runtime/DontMapGetMemberNamesToDirAttribute.cs | 0 .../Runtime/DontMapICollectionToLenAttribute.cs | 0 .../DontMapIDisposableToContextManagerAttribute.cs | 0 .../DontMapIEnumerableToContainsAttribute.cs | 0 .../Runtime/DontMapIEnumerableToIterAttribute.cs | 0 .../IronPython/Runtime/EmptyDictionaryStorage.cs | 0 src/{ipy => core}/IronPython/Runtime/Enumerate.cs | 0 src/{ipy => core}/IronPython/Runtime/ErrorCodes.cs | 0 .../Exceptions/AssertionException.Generated.cs | 0 .../Runtime/Exceptions/AttributeErrorException.cs | 0 .../Exceptions/BlockingIOException.Generated.cs | 0 .../Exceptions/BrokenPipeException.Generated.cs | 0 .../Runtime/Exceptions/BufferException.Generated.cs | 0 .../Exceptions/BytesWarningException.Generated.cs | 0 .../Exceptions/ChildProcessException.Generated.cs | 0 .../ConnectionAbortedException.Generated.cs | 0 .../Exceptions/ConnectionException.Generated.cs | 0 .../ConnectionRefusedException.Generated.cs | 0 .../ConnectionResetException.Generated.cs | 0 .../DeprecationWarningException.Generated.cs | 0 .../Exceptions/FileExistsException.Generated.cs | 0 .../Exceptions/FloatingPointException.Generated.cs | 0 .../Exceptions/FutureWarningException.Generated.cs | 0 .../Runtime/Exceptions/GeneratorExitException.cs | 0 .../Runtime/Exceptions/ImportException.Generated.cs | 0 .../Exceptions/ImportWarningException.Generated.cs | 0 .../Runtime/Exceptions/IndentationException.cs | 0 .../Exceptions/InterruptedException.Generated.cs | 0 .../Exceptions/IsADirectoryException.Generated.cs | 0 .../Runtime/Exceptions/LookupException.Generated.cs | 0 .../Runtime/Exceptions/ModuleNotFoundException.cs | 0 .../Exceptions/NotADirectoryException.Generated.cs | 0 .../Runtime/Exceptions/OSException.Generated.cs | 0 .../PendingDeprecationWarningException.Generated.cs | 0 .../Exceptions/ProcessLookupException.Generated.cs | 0 .../Runtime/Exceptions/PythonException.cs | 0 .../Exceptions/PythonExceptions.BaseException.cs | 0 .../Exceptions/PythonExceptions.Generated.cs | 0 .../Runtime/Exceptions/PythonExceptions.cs | 0 .../Exceptions/RecursionException.Generated.cs | 0 .../Exceptions/ReferenceException.Generated.cs | 0 .../ResourceWarningException.Generated.cs | 0 .../Exceptions/RuntimeException.Generated.cs | 0 .../Exceptions/RuntimeWarningException.Generated.cs | 0 .../StopAsyncIterationException.Generated.cs | 0 .../Exceptions/StopIterationException.Generated.cs | 0 .../Exceptions/SyntaxWarningException.Generated.cs | 0 .../Runtime/Exceptions/SystemExitException.cs | 0 .../IronPython/Runtime/Exceptions/TabException.cs | 0 .../IronPython/Runtime/Exceptions/TraceBack.cs | 0 .../Runtime/Exceptions/TypeErrorException.cs | 0 .../Exceptions/UnicodeException.Generated.cs | 0 .../UnicodeTranslateException.Generated.cs | 0 .../Exceptions/UnicodeWarningException.Generated.cs | 0 .../Exceptions/UserWarningException.Generated.cs | 0 .../Runtime/Exceptions/ValueErrorException.cs | 0 .../IronPython/Runtime/ExtensionMethodSet.cs | 0 src/{ipy => core}/IronPython/Runtime/Filter.cs | 0 .../IronPython/Runtime/FormattingHelper.cs | 0 .../IronPython/Runtime/FunctionAttributes.cs | 0 .../IronPython/Runtime/FunctionCode.cs | 0 src/{ipy => core}/IronPython/Runtime/Generator.cs | 0 .../IronPython/Runtime/GlobalDictionaryStorage.cs | 0 .../IronPython/Runtime/IParameterSequence.cs | 0 .../IronPython/Runtime/Implementation.cs | 0 src/{ipy => core}/IronPython/Runtime/Importer.cs | 0 src/{ipy => core}/IronPython/Runtime/Index.cs | 0 .../Runtime/InstancedModuleDictionaryStorage.cs | 0 src/{ipy => core}/IronPython/Runtime/Interfaces.cs | 0 src/{ipy => core}/IronPython/Runtime/KwCallInfo.cs | 0 .../IronPython/Runtime/LiteralParser.cs | 0 src/{ipy => core}/IronPython/Runtime/Map.cs | 0 .../Runtime/MaybeNotImplementedAttribute.cs | 0 .../Runtime/MemoryStreamContentProvider.cs | 0 src/{ipy => core}/IronPython/Runtime/MemoryView.cs | 0 .../IronPython/Runtime/Method.Generated.cs | 0 src/{ipy => core}/IronPython/Runtime/Method.cs | 0 .../IronPython/Runtime/MissingParameter.cs | 0 .../IronPython/Runtime/ModuleContext.cs | 0 .../IronPython/Runtime/ModuleDictionaryStorage.cs | 0 .../IronPython/Runtime/ModuleGlobalCache.cs | 0 .../IronPython/Runtime/ModuleLoader.cs | 0 .../IronPython/Runtime/ModuleOptions.cs | 0 src/{ipy => core}/IronPython/Runtime/NameType.cs | 0 .../IronPython/Runtime/NewStringFormatter.cs | 0 .../IronPython/Runtime/ObjectAttributesAdapter.cs | 0 .../IronPython/Runtime/ObjectDebugView.cs | 0 .../IronPython/Runtime/Operations/ArrayOps.cs | 0 .../IronPython/Runtime/Operations/BigIntegerOps.cs | 0 .../IronPython/Runtime/Operations/BoolOps.cs | 0 .../IronPython/Runtime/Operations/ByteOps.cs | 0 .../IronPython/Runtime/Operations/CharOps.cs | 0 .../IronPython/Runtime/Operations/ComOps.cs | 0 .../IronPython/Runtime/Operations/ComplexOps.cs | 0 .../Runtime/Operations/CustomTypeDescHelpers.cs | 0 .../IronPython/Runtime/Operations/DBNullOps.cs | 0 .../IronPython/Runtime/Operations/DateTimeOps.cs | 0 .../IronPython/Runtime/Operations/DecimalOps.cs | 0 .../IronPython/Runtime/Operations/DelegateOps.cs | 0 .../Runtime/Operations/DictionaryOfTOps.cs | 0 .../IronPython/Runtime/Operations/EnumOps.cs | 0 .../Runtime/Operations/FloatOps.Generated.cs | 0 .../IronPython/Runtime/Operations/FloatOps.cs | 0 .../IronPython/Runtime/Operations/IListOfByteOps.cs | 0 .../IronPython/Runtime/Operations/InstanceOps.cs | 0 .../Runtime/Operations/IntOps.Generated.cs | 0 .../IronPython/Runtime/Operations/IntOps.cs | 0 .../IronPython/Runtime/Operations/IntPtrOps.cs | 0 .../IronPython/Runtime/Operations/ListOfTOps.cs | 0 .../IronPython/Runtime/Operations/MarshalOps.cs | 0 .../Runtime/Operations/NamespaceTrackerOps.cs | 0 .../IronPython/Runtime/Operations/ObjectOps.cs | 0 .../IronPython/Runtime/Operations/PythonCalls.cs | 0 .../Runtime/Operations/PythonOps.Generated.cs | 0 .../IronPython/Runtime/Operations/PythonOps.cs | 0 .../IronPython/Runtime/Operations/PythonTypeOps.cs | 0 .../Runtime/Operations/StringOps.Generated.cs | 0 .../IronPython/Runtime/Operations/StringOps.cs | 0 .../IronPython/Runtime/Operations/TypeGroupOps.cs | 0 .../IronPython/Runtime/Operations/TypeTrackerOps.cs | 0 .../IronPython/Runtime/Operations/UIntPtrOps.cs | 0 .../IronPython/Runtime/Operations/UserTypeOps.cs | 0 .../IronPython/Runtime/OutputWriter.cs | 0 .../IronPython/Runtime/PlatformsAttribute.cs | 0 src/{ipy => core}/IronPython/Runtime/Profiler.cs | 0 .../IronPython/Runtime/PythonContext.Generated.cs | 0 .../IronPython/Runtime/PythonContext.cs | 0 .../IronPython/Runtime/PythonDictionary.cs | 0 .../Runtime/PythonDocumentationProvider.cs | 0 .../IronPython/Runtime/PythonDynamicStackFrame.cs | 0 .../IronPython/Runtime/PythonEncoding.cs | 0 .../IronPython/Runtime/PythonFileManager.cs | 0 .../IronPython/Runtime/PythonFunction.Generated.cs | 0 .../IronPython/Runtime/PythonFunction.cs | 0 .../IronPython/Runtime/PythonHiddenAttribute.cs | 0 .../Runtime/PythonHiddenBaseClassAttribute.cs | 0 src/{ipy => core}/IronPython/Runtime/PythonList.cs | 0 .../IronPython/Runtime/PythonModule.cs | 0 .../IronPython/Runtime/PythonModuleAttribute.cs | 0 .../IronPython/Runtime/PythonNarrowing.cs | 0 .../IronPython/Runtime/PythonOptions.cs | 0 src/{ipy => core}/IronPython/Runtime/PythonRange.cs | 0 .../IronPython/Runtime/PythonScopeExtension.cs | 0 .../IronPython/Runtime/PythonStrIterator.cs | 0 .../IronPython/Runtime/PythonTracebackListener.cs | 0 src/{ipy => core}/IronPython/Runtime/PythonTuple.cs | 0 .../IronPython/Runtime/PythonTypeAttribute.cs | 0 src/{ipy => core}/IronPython/Runtime/Reversed.cs | 0 .../Runtime/RuntimeVariablesDictionaryStorage.cs | 0 .../IronPython/Runtime/ScopeDictionaryStorage.cs | 0 .../IronPython/Runtime/SequenceTypeInfoAttribute.cs | 0 src/{ipy => core}/IronPython/Runtime/Set.cs | 0 src/{ipy => core}/IronPython/Runtime/SetStorage.cs | 0 .../IronPython/Runtime/SimpleNamespace.cs | 0 .../IronPython/Runtime/SiteLocalStorage.cs | 0 src/{ipy => core}/IronPython/Runtime/Slice.cs | 0 .../IronPython/Runtime/StringDictionaryStorage.cs | 0 .../IronPython/Runtime/StringFormatSpec.cs | 0 .../IronPython/Runtime/StringFormatter.cs | 0 src/{ipy => core}/IronPython/Runtime/Super.cs | 0 .../IronPython/Runtime/Symbols.Generated.cs | 0 .../IronPython/Runtime/ThrowingErrorSink.cs | 0 src/{ipy => core}/IronPython/Runtime/TypecodeOps.cs | 0 .../IronPython/Runtime/Types/BuiltinFunction.cs | 0 .../Runtime/Types/BuiltinFunctionOverloadMapper.cs | 0 .../Runtime/Types/BuiltinMethodDescriptor.cs | 0 .../IronPython/Runtime/Types/CachedNewTypeInfo.cs | 0 .../IronPython/Runtime/Types/ConstructorFunction.cs | 0 .../Runtime/Types/CustomAttributeTracker.cs | 0 .../Types/CustomInstanceDictionaryStorage.cs | 0 .../IronPython/Runtime/Types/DocBuilder.cs | 0 .../Runtime/Types/DynamicBaseTypeAttribute.cs | 0 .../IronPython/Runtime/Types/DynamicHelpers.cs | 0 .../IronPython/Runtime/Types/EmptyType.cs | 0 .../Runtime/Types/ExtensionPropertyInfo.cs | 0 .../IronPython/Runtime/Types/FunctionType.cs | 0 .../IronPython/Runtime/Types/IPythonObject.cs | 0 .../IronPython/Runtime/Types/InstanceCreator.cs | 0 .../IronPython/Runtime/Types/MappingProxy.cs | 0 src/{ipy => core}/IronPython/Runtime/Types/Mro.cs | 0 .../IronPython/Runtime/Types/NameConverter.cs | 0 .../IronPython/Runtime/Types/NewTypeInfo.cs | 0 .../IronPython/Runtime/Types/NewTypeMaker.cs | 0 .../IronPython/Runtime/Types/OperatorMapping.cs | 0 .../Runtime/Types/ParameterInfoWrapper.cs | 0 .../IronPython/Runtime/Types/PythonAssemblyOps.cs | 0 .../IronPython/Runtime/Types/PythonSiteCache.cs | 0 .../Runtime/Types/PythonType.Generated.cs | 0 .../IronPython/Runtime/Types/PythonType.cs | 0 .../IronPython/Runtime/Types/PythonTypeDataSlot.cs | 0 .../IronPython/Runtime/Types/PythonTypeDictSlot.cs | 0 .../Runtime/Types/PythonTypeInfo.Generated.cs | 0 .../IronPython/Runtime/Types/PythonTypeInfo.cs | 0 .../IronPython/Runtime/Types/PythonTypeSlot.cs | 0 .../IronPython/Runtime/Types/PythonTypeTypeSlot.cs | 0 .../Runtime/Types/PythonTypeUserDescriptorSlot.cs | 0 .../Runtime/Types/PythonTypeWeakRefSlot.cs | 0 .../IronPython/Runtime/Types/ReflectedEvent.cs | 0 .../Runtime/Types/ReflectedExtensionProperty.cs | 0 .../IronPython/Runtime/Types/ReflectedField.cs | 0 .../Runtime/Types/ReflectedGetterSetter.cs | 0 .../IronPython/Runtime/Types/ReflectedIndexer.cs | 0 .../IronPython/Runtime/Types/ReflectedProperty.cs | 0 .../Runtime/Types/ReflectedSlotProperty.cs | 0 .../IronPython/Runtime/Types/ResolvedMember.cs | 0 .../IronPython/Runtime/Types/SlotFieldAttribute.cs | 0 .../Runtime/Types/StaticUnderlyingSystemType.cs | 0 .../IronPython/Runtime/Types/TypeCache.Generated.cs | 0 .../IronPython/Runtime/UnboundNameException.cs | 0 src/{ipy => core}/IronPython/Runtime/WeakRef.cs | 0 .../Runtime/WrapperDescriptorAttribute.cs | 0 .../IronPython/Runtime/WrapperDictionary.cs | 0 src/{ipy => core}/IronPython/Runtime/Zip.cs | 0 src/{ipy => core}/IronPython/SerializationStubs.cs | 0 src/{ipy => core}/IronPython/StringExtensions.cs | 0 .../IronPython/SystemRuntimeVersioning.cs | 0 .../IronPython/policy.IronPython.config | 0 src/{ipy => core}/README.md | 0 595 files changed, 0 insertions(+), 0 deletions(-) rename src/{ipy => core}/CTypes/Makefile (100%) rename src/{ipy => core}/CTypes/_ctypes_test.c (100%) rename src/{ipy => core}/CTypes/_ctypes_test.sln (100%) rename src/{ipy => core}/CTypes/_ctypes_test.vcxproj (100%) rename src/{ipy => core}/IronPython.CompilerServices/AssemblyResolver.cs (100%) rename src/{ipy => core}/IronPython.CompilerServices/Config.cs (100%) rename src/{ipy => core}/IronPython.CompilerServices/ConsoleOps.cs (100%) rename src/{ipy => core}/IronPython.CompilerServices/IronPython.CompilerServices.csproj (100%) rename src/{ipy => core}/IronPython.CompilerServices/Program.cs (100%) rename src/{ipy => core}/IronPython.CompilerServices/Properties/AssemblyInfo.cs (100%) rename src/{ipy => core}/IronPython.CompilerServices/README.md (100%) rename src/{ipy => core}/IronPython.Modules/IronPython.Modules.csproj (100%) rename src/{ipy => core}/IronPython.Modules/IterTools.cs (100%) rename src/{ipy => core}/IronPython.Modules/ModuleOps.cs (100%) rename src/{ipy => core}/IronPython.Modules/NtSignalState.cs (100%) rename src/{ipy => core}/IronPython.Modules/Properties/AssemblyInfo.cs (100%) rename src/{ipy => core}/IronPython.Modules/ResourceMetaPathImporter.cs (100%) rename src/{ipy => core}/IronPython.Modules/SimpleSignalState.cs (100%) rename src/{ipy => core}/IronPython.Modules/_bisect.cs (100%) rename src/{ipy => core}/IronPython.Modules/_codecs.cs (100%) rename src/{ipy => core}/IronPython.Modules/_codecs_cn.cs (100%) rename src/{ipy => core}/IronPython.Modules/_collections.cs (100%) rename src/{ipy => core}/IronPython.Modules/_csv.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/Array.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/ArrayType.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/CData.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/CFuncPtr.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/CFuncPtrType.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/Extensions.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/Field.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/INativeType.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/LocalOrArg.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/MarshalCleanup.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/MemoryHolder.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/NativeArgument.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/NativeFunctions.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/Pointer.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/PointerType.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/SimpleCData.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/SimpleType.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/SimpleTypeKind.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/StructType.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/Structure.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/Union.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/UnionType.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes/_ctypes.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ctypes_test.cs (100%) rename src/{ipy => core}/IronPython.Modules/_datetime.cs (100%) rename src/{ipy => core}/IronPython.Modules/_functools.cs (100%) rename src/{ipy => core}/IronPython.Modules/_heapq.cs (100%) rename src/{ipy => core}/IronPython.Modules/_multibytecodec.cs (100%) rename src/{ipy => core}/IronPython.Modules/_multiprocessing.cs (100%) rename src/{ipy => core}/IronPython.Modules/_opcode.cs (100%) rename src/{ipy => core}/IronPython.Modules/_operator.cs (100%) rename src/{ipy => core}/IronPython.Modules/_overlapped.cs (100%) rename src/{ipy => core}/IronPython.Modules/_pickle.cs (100%) rename src/{ipy => core}/IronPython.Modules/_posixsubprocess.cs (100%) rename src/{ipy => core}/IronPython.Modules/_random.RandomGen.cs (100%) rename src/{ipy => core}/IronPython.Modules/_random.cs (100%) rename src/{ipy => core}/IronPython.Modules/_socket.cs (100%) rename src/{ipy => core}/IronPython.Modules/_sre.cs (100%) rename src/{ipy => core}/IronPython.Modules/_ssl.cs (100%) rename src/{ipy => core}/IronPython.Modules/_string.cs (100%) rename src/{ipy => core}/IronPython.Modules/_struct.cs (100%) rename src/{ipy => core}/IronPython.Modules/_sysconfigdata.cs (100%) rename src/{ipy => core}/IronPython.Modules/_thread.cs (100%) rename src/{ipy => core}/IronPython.Modules/_warnings.cs (100%) rename src/{ipy => core}/IronPython.Modules/_weakref.Generated.cs (100%) rename src/{ipy => core}/IronPython.Modules/_weakref.cs (100%) rename src/{ipy => core}/IronPython.Modules/_winapi.cs (100%) rename src/{ipy => core}/IronPython.Modules/array.cs (100%) rename src/{ipy => core}/IronPython.Modules/atexit.cs (100%) rename src/{ipy => core}/IronPython.Modules/audioop.cs (100%) rename src/{ipy => core}/IronPython.Modules/binascii.cs (100%) rename src/{ipy => core}/IronPython.Modules/bz2/BZ2Compressor.cs (100%) rename src/{ipy => core}/IronPython.Modules/bz2/BZ2Decompressor.cs (100%) rename src/{ipy => core}/IronPython.Modules/bz2/BZ2Module.cs (100%) rename src/{ipy => core}/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs (100%) rename src/{ipy => core}/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs (100%) rename src/{ipy => core}/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs (100%) rename src/{ipy => core}/IronPython.Modules/bz2/dotnetzip/BZip2/BitWriter.cs (100%) rename src/{ipy => core}/IronPython.Modules/bz2/dotnetzip/BZip2/CRC32.cs (100%) rename src/{ipy => core}/IronPython.Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs (100%) rename src/{ipy => core}/IronPython.Modules/bz2/dotnetzip/BZip2/Rand.cs (100%) rename src/{ipy => core}/IronPython.Modules/bz2/dotnetzip/source.txt (100%) rename src/{ipy => core}/IronPython.Modules/cmath.cs (100%) rename src/{ipy => core}/IronPython.Modules/errno.cs (100%) rename src/{ipy => core}/IronPython.Modules/faulthandler.cs (100%) rename src/{ipy => core}/IronPython.Modules/fcntl.cs (100%) rename src/{ipy => core}/IronPython.Modules/gc.cs (100%) rename src/{ipy => core}/IronPython.Modules/grp.cs (100%) rename src/{ipy => core}/IronPython.Modules/hashlib/MD5CryptoServiceProvider.cs (100%) rename src/{ipy => core}/IronPython.Modules/hashlib/SHA1CryptoServiceProvider.cs (100%) rename src/{ipy => core}/IronPython.Modules/hashlib/SHA224.cs (100%) rename src/{ipy => core}/IronPython.Modules/hashlib/SHA224Managed.cs (100%) rename src/{ipy => core}/IronPython.Modules/hashlib/SHA256Managed.cs (100%) rename src/{ipy => core}/IronPython.Modules/hashlib/SHA384Managed.cs (100%) rename src/{ipy => core}/IronPython.Modules/hashlib/SHA512Managed.cs (100%) rename src/{ipy => core}/IronPython.Modules/hashlib/SHAConstants.cs (100%) rename src/{ipy => core}/IronPython.Modules/hashlib/_hashlib.cs (100%) rename src/{ipy => core}/IronPython.Modules/hashlib/_md5.cs (100%) rename src/{ipy => core}/IronPython.Modules/hashlib/_sha1.cs (100%) rename src/{ipy => core}/IronPython.Modules/hashlib/_sha256.cs (100%) rename src/{ipy => core}/IronPython.Modules/hashlib/_sha512.cs (100%) rename src/{ipy => core}/IronPython.Modules/marshal.cs (100%) rename src/{ipy => core}/IronPython.Modules/math.Generated.cs (100%) rename src/{ipy => core}/IronPython.Modules/math.cs (100%) rename src/{ipy => core}/IronPython.Modules/mmap.cs (100%) rename src/{ipy => core}/IronPython.Modules/msvcrt.cs (100%) rename src/{ipy => core}/IronPython.Modules/nt.cs (100%) rename src/{ipy => core}/IronPython.Modules/policy.IronPython.Modules.config (100%) rename src/{ipy => core}/IronPython.Modules/pwd.cs (100%) rename src/{ipy => core}/IronPython.Modules/pyexpat.cs (100%) rename src/{ipy => core}/IronPython.Modules/re.cs (100%) rename src/{ipy => core}/IronPython.Modules/resource.cs (100%) rename src/{ipy => core}/IronPython.Modules/select.cs (100%) rename src/{ipy => core}/IronPython.Modules/signal.cs (100%) rename src/{ipy => core}/IronPython.Modules/spwd.cs (100%) rename src/{ipy => core}/IronPython.Modules/time.cs (100%) rename src/{ipy => core}/IronPython.Modules/winreg.cs (100%) rename src/{ipy => core}/IronPython.Modules/winsound.cs (100%) rename src/{ipy => core}/IronPython.Modules/xxsubtype.cs (100%) rename src/{ipy => core}/IronPython.Modules/zipimport.cs (100%) rename src/{ipy => core}/IronPython.Modules/zlib/Compress.cs (100%) rename src/{ipy => core}/IronPython.Modules/zlib/Decompress.cs (100%) rename src/{ipy => core}/IronPython.Modules/zlib/ZlibModule.cs (100%) rename src/{ipy => core}/IronPython.Modules/zlib/zlib.net/Adler32.cs (100%) rename src/{ipy => core}/IronPython.Modules/zlib/zlib.net/Deflate.cs (100%) rename src/{ipy => core}/IronPython.Modules/zlib/zlib.net/InfBlocks.cs (100%) rename src/{ipy => core}/IronPython.Modules/zlib/zlib.net/InfCodes.cs (100%) rename src/{ipy => core}/IronPython.Modules/zlib/zlib.net/InfTree.cs (100%) rename src/{ipy => core}/IronPython.Modules/zlib/zlib.net/Inflate.cs (100%) rename src/{ipy => core}/IronPython.Modules/zlib/zlib.net/StaticTree.cs (100%) rename src/{ipy => core}/IronPython.Modules/zlib/zlib.net/Tree.cs (100%) rename src/{ipy => core}/IronPython.Modules/zlib/zlib.net/ZStream.cs (100%) rename src/{ipy => core}/IronPython.Modules/zlib/zlib.net/ZStreamException.cs (100%) rename src/{ipy => core}/IronPython.Modules/zlib/zlib.net/Zlib.cs (100%) rename src/{ipy => core}/IronPython.Modules/zlib/zlib.net/history.txt (100%) rename src/{ipy => core}/IronPython.Modules/zlib/zlib.net/license.txt (100%) rename src/{ipy => core}/IronPython.Modules/zlib/zlib.net/readme.txt (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/AndExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/AssertStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/AssignmentStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/AstMethods.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/AsyncStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/AugmentedAssignStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/BinaryExpression.Generated.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/BinaryExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/BreakStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/CallExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/ClassDefinition.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/Comprehension.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/ComprehensionFor.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/ComprehensionIf.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/ConditionalExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/ConstantExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/ContinueStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/DelStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/DictionaryExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/DottedName.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/DynamicConvertExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/EmptyStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/ErrorExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/Expression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/ExpressionStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/FlowChecker.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/ForStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/FormattedValueExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/FromImportStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/FunctionDefinition.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/GeneratorExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/GetGlobalContextExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/GlobalStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/ILoopStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/IfStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/IfStatementTest.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/ImportStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/IndexExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/JoinedStringExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/Keyword.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/LambdaExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/ListExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/MemberExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/ModuleName.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/NameExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/Node.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/NonlocalStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/OrExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/Parameter.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/ParenthesisExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/PythonAst.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/PythonConstantExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/PythonNameBinder.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/PythonReference.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/PythonVariable.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/PythonWalker.Generated.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/RaiseStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/RelativeModuleName.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/ReturnStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/ScopeStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/SequenceExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/SerializedScopeStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/SetExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/SliceExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/StarredExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/Statement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/SuiteStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/TryStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/TupleExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/UnaryExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/VariableKind.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/WhileStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/WithStatement.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/YieldExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Ast/YieldFromExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/ClosureExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/ClosureInfo.cs (100%) rename src/{ipy => core}/IronPython/Compiler/CollectableCompilationMode.cs (100%) rename src/{ipy => core}/IronPython/Compiler/CompilationMode.cs (100%) rename src/{ipy => core}/IronPython/Compiler/GeneratorRewriter.cs (100%) rename src/{ipy => core}/IronPython/Compiler/LazyCode.cs (100%) rename src/{ipy => core}/IronPython/Compiler/LookupCompilationMode.cs (100%) rename src/{ipy => core}/IronPython/Compiler/OnDiskScriptCode.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Parser.cs (100%) rename src/{ipy => core}/IronPython/Compiler/PythonCallTargets.cs (100%) rename src/{ipy => core}/IronPython/Compiler/PythonCompilerOptions.cs (100%) rename src/{ipy => core}/IronPython/Compiler/PythonDynamicExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/PythonGlobal.cs (100%) rename src/{ipy => core}/IronPython/Compiler/PythonGlobalVariableExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/PythonOperator.cs (100%) rename src/{ipy => core}/IronPython/Compiler/PythonSavableScriptCode.cs (100%) rename src/{ipy => core}/IronPython/Compiler/PythonScriptCode.cs (100%) rename src/{ipy => core}/IronPython/Compiler/ReducableDynamicExpression.cs (100%) rename src/{ipy => core}/IronPython/Compiler/RunnableScriptCode.cs (100%) rename src/{ipy => core}/IronPython/Compiler/RuntimeScriptCode.cs (100%) rename src/{ipy => core}/IronPython/Compiler/ToDiskCompilationMode.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Token.cs (100%) rename src/{ipy => core}/IronPython/Compiler/TokenKind.Generated.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Tokenizer.Generated.cs (100%) rename src/{ipy => core}/IronPython/Compiler/Tokenizer.cs (100%) rename src/{ipy => core}/IronPython/Compiler/UncollectableCompilationMode.Generated.cs (100%) rename src/{ipy => core}/IronPython/Compiler/UncollectableCompilationMode.cs (100%) rename src/{ipy => core}/IronPython/FakeInteropServices.cs (100%) rename src/{ipy => core}/IronPython/Hosting/Python.cs (100%) rename src/{ipy => core}/IronPython/Hosting/PythonCodeDomCodeGen.cs (100%) rename src/{ipy => core}/IronPython/Hosting/PythonCommandLine.cs (100%) rename src/{ipy => core}/IronPython/Hosting/PythonConsoleOptions.cs (100%) rename src/{ipy => core}/IronPython/Hosting/PythonOptionsParser.cs (100%) rename src/{ipy => core}/IronPython/Hosting/PythonService.cs (100%) rename src/{ipy => core}/IronPython/Interop/Windows/Interop.Libraries.cs (100%) rename src/{ipy => core}/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs (100%) rename src/{ipy => core}/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs (100%) rename src/{ipy => core}/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs (100%) rename src/{ipy => core}/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs (100%) rename src/{ipy => core}/IronPython/IronPython.csproj (100%) rename src/{ipy => core}/IronPython/Lib/iptest/__init__.py (100%) rename src/{ipy => core}/IronPython/Lib/iptest/cominterop_util.py (100%) rename src/{ipy => core}/IronPython/Lib/iptest/console_util.py (100%) rename src/{ipy => core}/IronPython/Lib/iptest/file_util.py (100%) rename src/{ipy => core}/IronPython/Lib/iptest/ipunittest.py (100%) rename src/{ipy => core}/IronPython/Lib/iptest/misc_util.py (100%) rename src/{ipy => core}/IronPython/Lib/iptest/process_util.py (100%) rename src/{ipy => core}/IronPython/Lib/iptest/runner.py (100%) rename src/{ipy => core}/IronPython/Lib/iptest/test_env.py (100%) rename src/{ipy => core}/IronPython/Lib/iptest/type_util.py (100%) rename src/{ipy => core}/IronPython/Modules/Builtin.Generated.cs (100%) rename src/{ipy => core}/IronPython/Modules/Builtin.cs (100%) rename src/{ipy => core}/IronPython/Modules/_ast.cs (100%) rename src/{ipy => core}/IronPython/Modules/_fileio.cs (100%) rename src/{ipy => core}/IronPython/Modules/_imp.cs (100%) rename src/{ipy => core}/IronPython/Modules/_io.cs (100%) rename src/{ipy => core}/IronPython/Modules/_io/BytesIO.cs (100%) rename src/{ipy => core}/IronPython/Modules/_io/StringIO.cs (100%) rename src/{ipy => core}/IronPython/Modules/_locale.cs (100%) rename src/{ipy => core}/IronPython/Modules/sys.cs (100%) rename src/{ipy => core}/IronPython/Modules/unicodedata.cs (100%) rename src/{ipy => core}/IronPython/Modules/unicodedata/CaseFolding.txt (100%) rename src/{ipy => core}/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt (100%) rename src/{ipy => core}/IronPython/Modules/unicodedata/EastAsianWidth.txt (100%) rename src/{ipy => core}/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz (100%) rename src/{ipy => core}/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz (100%) rename src/{ipy => core}/IronPython/Modules/unicodedata/NameAliases.txt (100%) rename src/{ipy => core}/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt (100%) rename src/{ipy => core}/IronPython/Modules/unicodedata/UnicodeData.txt (100%) rename src/{ipy => core}/IronPython/Modules/unicodedata/genunicodedata.py (100%) rename src/{ipy => core}/IronPython/Modules/unicodedata/license.txt (100%) rename src/{ipy => core}/IronPython/Properties/AssemblyInfo.cs (100%) rename src/{ipy => core}/IronPython/Resources.Designer.cs (100%) rename src/{ipy => core}/IronPython/Resources.resx (100%) rename src/{ipy => core}/IronPython/Runtime/ArrayData.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/Binders.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/BindingHelpers.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/BindingWarnings.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/ConditionalBuilder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/ContextArgBuilder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/ConversionBinder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/CreateFallbackBinder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/FastBindResult.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/FastGetBase.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/FastSetBase.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/IComConvertible.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/IFastGettable.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/IFastInvokable.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/IFastSettable.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/IPythonConvertible.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/IPythonExpandable.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/IPythonGetable.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/IPythonInvokable.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/IPythonOperable.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/IPythonSite.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/MetaBuiltinFunction.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/MetaMethod.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/MetaPythonFunction.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/MetaPythonObject.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/MetaPythonType.Calls.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/MetaPythonType.Members.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/MetaPythonType.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/MetaUserObject.Members.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/MetaUserObject.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/PythonBinder.Create.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/PythonBinder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/PythonExtensionBinder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/PythonGetIndexBinder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/PythonGetMemberBinder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/PythonGetSliceBinder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/PythonIndexType.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/PythonInvokeBinder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/PythonOperationBinder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/PythonOperationKind.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/PythonOverloadResolver.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/PythonProtocol.Operations.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/PythonProtocol.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/PythonSetIndexBinder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/PythonSetMemberBinder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/PythonSetSliceBinder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/SlotOrFunction.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Binding/WarningInfo.cs (100%) rename src/{ipy => core}/IronPython/Runtime/BufferProtocol.cs (100%) rename src/{ipy => core}/IronPython/Runtime/BuiltinPythonModule.cs (100%) rename src/{ipy => core}/IronPython/Runtime/BuiltinsDictionaryStorage.cs (100%) rename src/{ipy => core}/IronPython/Runtime/ByteArray.cs (100%) rename src/{ipy => core}/IronPython/Runtime/ByteArrayIterator.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Bytes.cs (100%) rename src/{ipy => core}/IronPython/Runtime/BytesIterator.cs (100%) rename src/{ipy => core}/IronPython/Runtime/BytesLikeAttribute.cs (100%) rename src/{ipy => core}/IronPython/Runtime/ClassMethodAttribute.cs (100%) rename src/{ipy => core}/IronPython/Runtime/ClassMethodDescriptor.cs (100%) rename src/{ipy => core}/IronPython/Runtime/ClrModule.cs (100%) rename src/{ipy => core}/IronPython/Runtime/CodeContext.cs (100%) rename src/{ipy => core}/IronPython/Runtime/CollectionDebugView.cs (100%) rename src/{ipy => core}/IronPython/Runtime/CommonDictionaryStorage.cs (100%) rename src/{ipy => core}/IronPython/Runtime/CompareUtil.cs (100%) rename src/{ipy => core}/IronPython/Runtime/CompileFlags.cs (100%) rename src/{ipy => core}/IronPython/Runtime/CompiledLoader.cs (100%) rename src/{ipy => core}/IronPython/Runtime/ConstantDictionaryStorage.cs (100%) rename src/{ipy => core}/IronPython/Runtime/ConversionWrappers.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Converter.cs (100%) rename src/{ipy => core}/IronPython/Runtime/CustomDictionaryStorage.cs (100%) rename src/{ipy => core}/IronPython/Runtime/DebuggerDictionaryStorage.cs (100%) rename src/{ipy => core}/IronPython/Runtime/DefaultContext.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Descriptors.cs (100%) rename src/{ipy => core}/IronPython/Runtime/DictionaryOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/DictionaryStorage.cs (100%) rename src/{ipy => core}/IronPython/Runtime/DictionaryTypeInfoAttribute.cs (100%) rename src/{ipy => core}/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs (100%) rename src/{ipy => core}/IronPython/Runtime/DontMapICollectionToLenAttribute.cs (100%) rename src/{ipy => core}/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs (100%) rename src/{ipy => core}/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs (100%) rename src/{ipy => core}/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs (100%) rename src/{ipy => core}/IronPython/Runtime/EmptyDictionaryStorage.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Enumerate.cs (100%) rename src/{ipy => core}/IronPython/Runtime/ErrorCodes.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/AssertionException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/AttributeErrorException.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/BufferException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/GeneratorExitException.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/ImportException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/IndentationException.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/LookupException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/OSException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/PythonException.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/PythonExceptions.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/RecursionException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/SystemExitException.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/TabException.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/TraceBack.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/TypeErrorException.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Exceptions/ValueErrorException.cs (100%) rename src/{ipy => core}/IronPython/Runtime/ExtensionMethodSet.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Filter.cs (100%) rename src/{ipy => core}/IronPython/Runtime/FormattingHelper.cs (100%) rename src/{ipy => core}/IronPython/Runtime/FunctionAttributes.cs (100%) rename src/{ipy => core}/IronPython/Runtime/FunctionCode.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Generator.cs (100%) rename src/{ipy => core}/IronPython/Runtime/GlobalDictionaryStorage.cs (100%) rename src/{ipy => core}/IronPython/Runtime/IParameterSequence.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Implementation.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Importer.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Index.cs (100%) rename src/{ipy => core}/IronPython/Runtime/InstancedModuleDictionaryStorage.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Interfaces.cs (100%) rename src/{ipy => core}/IronPython/Runtime/KwCallInfo.cs (100%) rename src/{ipy => core}/IronPython/Runtime/LiteralParser.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Map.cs (100%) rename src/{ipy => core}/IronPython/Runtime/MaybeNotImplementedAttribute.cs (100%) rename src/{ipy => core}/IronPython/Runtime/MemoryStreamContentProvider.cs (100%) rename src/{ipy => core}/IronPython/Runtime/MemoryView.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Method.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Method.cs (100%) rename src/{ipy => core}/IronPython/Runtime/MissingParameter.cs (100%) rename src/{ipy => core}/IronPython/Runtime/ModuleContext.cs (100%) rename src/{ipy => core}/IronPython/Runtime/ModuleDictionaryStorage.cs (100%) rename src/{ipy => core}/IronPython/Runtime/ModuleGlobalCache.cs (100%) rename src/{ipy => core}/IronPython/Runtime/ModuleLoader.cs (100%) rename src/{ipy => core}/IronPython/Runtime/ModuleOptions.cs (100%) rename src/{ipy => core}/IronPython/Runtime/NameType.cs (100%) rename src/{ipy => core}/IronPython/Runtime/NewStringFormatter.cs (100%) rename src/{ipy => core}/IronPython/Runtime/ObjectAttributesAdapter.cs (100%) rename src/{ipy => core}/IronPython/Runtime/ObjectDebugView.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/ArrayOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/BigIntegerOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/BoolOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/ByteOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/CharOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/ComOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/ComplexOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/DBNullOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/DateTimeOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/DecimalOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/DelegateOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/DictionaryOfTOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/EnumOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/FloatOps.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/FloatOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/IListOfByteOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/InstanceOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/IntOps.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/IntOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/IntPtrOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/ListOfTOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/MarshalOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/NamespaceTrackerOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/ObjectOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/PythonCalls.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/PythonOps.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/PythonOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/PythonTypeOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/StringOps.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/StringOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/TypeGroupOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/TypeTrackerOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/UIntPtrOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Operations/UserTypeOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/OutputWriter.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PlatformsAttribute.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Profiler.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonContext.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonContext.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonDictionary.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonDocumentationProvider.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonDynamicStackFrame.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonEncoding.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonFileManager.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonFunction.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonFunction.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonHiddenAttribute.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonList.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonModule.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonModuleAttribute.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonNarrowing.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonOptions.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonRange.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonScopeExtension.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonStrIterator.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonTracebackListener.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonTuple.cs (100%) rename src/{ipy => core}/IronPython/Runtime/PythonTypeAttribute.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Reversed.cs (100%) rename src/{ipy => core}/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs (100%) rename src/{ipy => core}/IronPython/Runtime/ScopeDictionaryStorage.cs (100%) rename src/{ipy => core}/IronPython/Runtime/SequenceTypeInfoAttribute.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Set.cs (100%) rename src/{ipy => core}/IronPython/Runtime/SetStorage.cs (100%) rename src/{ipy => core}/IronPython/Runtime/SimpleNamespace.cs (100%) rename src/{ipy => core}/IronPython/Runtime/SiteLocalStorage.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Slice.cs (100%) rename src/{ipy => core}/IronPython/Runtime/StringDictionaryStorage.cs (100%) rename src/{ipy => core}/IronPython/Runtime/StringFormatSpec.cs (100%) rename src/{ipy => core}/IronPython/Runtime/StringFormatter.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Super.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Symbols.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/ThrowingErrorSink.cs (100%) rename src/{ipy => core}/IronPython/Runtime/TypecodeOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/BuiltinFunction.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/CachedNewTypeInfo.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/ConstructorFunction.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/CustomAttributeTracker.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/DocBuilder.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/DynamicHelpers.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/EmptyType.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/ExtensionPropertyInfo.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/FunctionType.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/IPythonObject.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/InstanceCreator.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/MappingProxy.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/Mro.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/NameConverter.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/NewTypeInfo.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/NewTypeMaker.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/OperatorMapping.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/ParameterInfoWrapper.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/PythonAssemblyOps.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/PythonSiteCache.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/PythonType.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/PythonType.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/PythonTypeDataSlot.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/PythonTypeDictSlot.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/PythonTypeInfo.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/PythonTypeSlot.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/PythonTypeTypeSlot.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/ReflectedEvent.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/ReflectedExtensionProperty.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/ReflectedField.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/ReflectedGetterSetter.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/ReflectedIndexer.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/ReflectedProperty.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/ReflectedSlotProperty.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/ResolvedMember.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/SlotFieldAttribute.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Types/TypeCache.Generated.cs (100%) rename src/{ipy => core}/IronPython/Runtime/UnboundNameException.cs (100%) rename src/{ipy => core}/IronPython/Runtime/WeakRef.cs (100%) rename src/{ipy => core}/IronPython/Runtime/WrapperDescriptorAttribute.cs (100%) rename src/{ipy => core}/IronPython/Runtime/WrapperDictionary.cs (100%) rename src/{ipy => core}/IronPython/Runtime/Zip.cs (100%) rename src/{ipy => core}/IronPython/SerializationStubs.cs (100%) rename src/{ipy => core}/IronPython/StringExtensions.cs (100%) rename src/{ipy => core}/IronPython/SystemRuntimeVersioning.cs (100%) rename src/{ipy => core}/IronPython/policy.IronPython.config (100%) rename src/{ipy => core}/README.md (100%) diff --git a/src/ipy/CTypes/Makefile b/src/core/CTypes/Makefile similarity index 100% rename from src/ipy/CTypes/Makefile rename to src/core/CTypes/Makefile diff --git a/src/ipy/CTypes/_ctypes_test.c b/src/core/CTypes/_ctypes_test.c similarity index 100% rename from src/ipy/CTypes/_ctypes_test.c rename to src/core/CTypes/_ctypes_test.c diff --git a/src/ipy/CTypes/_ctypes_test.sln b/src/core/CTypes/_ctypes_test.sln similarity index 100% rename from src/ipy/CTypes/_ctypes_test.sln rename to src/core/CTypes/_ctypes_test.sln diff --git a/src/ipy/CTypes/_ctypes_test.vcxproj b/src/core/CTypes/_ctypes_test.vcxproj similarity index 100% rename from src/ipy/CTypes/_ctypes_test.vcxproj rename to src/core/CTypes/_ctypes_test.vcxproj diff --git a/src/ipy/IronPython.CompilerServices/AssemblyResolver.cs b/src/core/IronPython.CompilerServices/AssemblyResolver.cs similarity index 100% rename from src/ipy/IronPython.CompilerServices/AssemblyResolver.cs rename to src/core/IronPython.CompilerServices/AssemblyResolver.cs diff --git a/src/ipy/IronPython.CompilerServices/Config.cs b/src/core/IronPython.CompilerServices/Config.cs similarity index 100% rename from src/ipy/IronPython.CompilerServices/Config.cs rename to src/core/IronPython.CompilerServices/Config.cs diff --git a/src/ipy/IronPython.CompilerServices/ConsoleOps.cs b/src/core/IronPython.CompilerServices/ConsoleOps.cs similarity index 100% rename from src/ipy/IronPython.CompilerServices/ConsoleOps.cs rename to src/core/IronPython.CompilerServices/ConsoleOps.cs diff --git a/src/ipy/IronPython.CompilerServices/IronPython.CompilerServices.csproj b/src/core/IronPython.CompilerServices/IronPython.CompilerServices.csproj similarity index 100% rename from src/ipy/IronPython.CompilerServices/IronPython.CompilerServices.csproj rename to src/core/IronPython.CompilerServices/IronPython.CompilerServices.csproj diff --git a/src/ipy/IronPython.CompilerServices/Program.cs b/src/core/IronPython.CompilerServices/Program.cs similarity index 100% rename from src/ipy/IronPython.CompilerServices/Program.cs rename to src/core/IronPython.CompilerServices/Program.cs diff --git a/src/ipy/IronPython.CompilerServices/Properties/AssemblyInfo.cs b/src/core/IronPython.CompilerServices/Properties/AssemblyInfo.cs similarity index 100% rename from src/ipy/IronPython.CompilerServices/Properties/AssemblyInfo.cs rename to src/core/IronPython.CompilerServices/Properties/AssemblyInfo.cs diff --git a/src/ipy/IronPython.CompilerServices/README.md b/src/core/IronPython.CompilerServices/README.md similarity index 100% rename from src/ipy/IronPython.CompilerServices/README.md rename to src/core/IronPython.CompilerServices/README.md diff --git a/src/ipy/IronPython.Modules/IronPython.Modules.csproj b/src/core/IronPython.Modules/IronPython.Modules.csproj similarity index 100% rename from src/ipy/IronPython.Modules/IronPython.Modules.csproj rename to src/core/IronPython.Modules/IronPython.Modules.csproj diff --git a/src/ipy/IronPython.Modules/IterTools.cs b/src/core/IronPython.Modules/IterTools.cs similarity index 100% rename from src/ipy/IronPython.Modules/IterTools.cs rename to src/core/IronPython.Modules/IterTools.cs diff --git a/src/ipy/IronPython.Modules/ModuleOps.cs b/src/core/IronPython.Modules/ModuleOps.cs similarity index 100% rename from src/ipy/IronPython.Modules/ModuleOps.cs rename to src/core/IronPython.Modules/ModuleOps.cs diff --git a/src/ipy/IronPython.Modules/NtSignalState.cs b/src/core/IronPython.Modules/NtSignalState.cs similarity index 100% rename from src/ipy/IronPython.Modules/NtSignalState.cs rename to src/core/IronPython.Modules/NtSignalState.cs diff --git a/src/ipy/IronPython.Modules/Properties/AssemblyInfo.cs b/src/core/IronPython.Modules/Properties/AssemblyInfo.cs similarity index 100% rename from src/ipy/IronPython.Modules/Properties/AssemblyInfo.cs rename to src/core/IronPython.Modules/Properties/AssemblyInfo.cs diff --git a/src/ipy/IronPython.Modules/ResourceMetaPathImporter.cs b/src/core/IronPython.Modules/ResourceMetaPathImporter.cs similarity index 100% rename from src/ipy/IronPython.Modules/ResourceMetaPathImporter.cs rename to src/core/IronPython.Modules/ResourceMetaPathImporter.cs diff --git a/src/ipy/IronPython.Modules/SimpleSignalState.cs b/src/core/IronPython.Modules/SimpleSignalState.cs similarity index 100% rename from src/ipy/IronPython.Modules/SimpleSignalState.cs rename to src/core/IronPython.Modules/SimpleSignalState.cs diff --git a/src/ipy/IronPython.Modules/_bisect.cs b/src/core/IronPython.Modules/_bisect.cs similarity index 100% rename from src/ipy/IronPython.Modules/_bisect.cs rename to src/core/IronPython.Modules/_bisect.cs diff --git a/src/ipy/IronPython.Modules/_codecs.cs b/src/core/IronPython.Modules/_codecs.cs similarity index 100% rename from src/ipy/IronPython.Modules/_codecs.cs rename to src/core/IronPython.Modules/_codecs.cs diff --git a/src/ipy/IronPython.Modules/_codecs_cn.cs b/src/core/IronPython.Modules/_codecs_cn.cs similarity index 100% rename from src/ipy/IronPython.Modules/_codecs_cn.cs rename to src/core/IronPython.Modules/_codecs_cn.cs diff --git a/src/ipy/IronPython.Modules/_collections.cs b/src/core/IronPython.Modules/_collections.cs similarity index 100% rename from src/ipy/IronPython.Modules/_collections.cs rename to src/core/IronPython.Modules/_collections.cs diff --git a/src/ipy/IronPython.Modules/_csv.cs b/src/core/IronPython.Modules/_csv.cs similarity index 100% rename from src/ipy/IronPython.Modules/_csv.cs rename to src/core/IronPython.Modules/_csv.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/Array.cs b/src/core/IronPython.Modules/_ctypes/Array.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/Array.cs rename to src/core/IronPython.Modules/_ctypes/Array.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/ArrayType.cs b/src/core/IronPython.Modules/_ctypes/ArrayType.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/ArrayType.cs rename to src/core/IronPython.Modules/_ctypes/ArrayType.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/CData.cs b/src/core/IronPython.Modules/_ctypes/CData.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/CData.cs rename to src/core/IronPython.Modules/_ctypes/CData.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/CFuncPtr.cs b/src/core/IronPython.Modules/_ctypes/CFuncPtr.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/CFuncPtr.cs rename to src/core/IronPython.Modules/_ctypes/CFuncPtr.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/CFuncPtrType.cs b/src/core/IronPython.Modules/_ctypes/CFuncPtrType.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/CFuncPtrType.cs rename to src/core/IronPython.Modules/_ctypes/CFuncPtrType.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/Extensions.cs b/src/core/IronPython.Modules/_ctypes/Extensions.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/Extensions.cs rename to src/core/IronPython.Modules/_ctypes/Extensions.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/Field.cs b/src/core/IronPython.Modules/_ctypes/Field.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/Field.cs rename to src/core/IronPython.Modules/_ctypes/Field.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/INativeType.cs b/src/core/IronPython.Modules/_ctypes/INativeType.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/INativeType.cs rename to src/core/IronPython.Modules/_ctypes/INativeType.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/LocalOrArg.cs b/src/core/IronPython.Modules/_ctypes/LocalOrArg.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/LocalOrArg.cs rename to src/core/IronPython.Modules/_ctypes/LocalOrArg.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/MarshalCleanup.cs b/src/core/IronPython.Modules/_ctypes/MarshalCleanup.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/MarshalCleanup.cs rename to src/core/IronPython.Modules/_ctypes/MarshalCleanup.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/MemoryHolder.cs b/src/core/IronPython.Modules/_ctypes/MemoryHolder.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/MemoryHolder.cs rename to src/core/IronPython.Modules/_ctypes/MemoryHolder.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/NativeArgument.cs b/src/core/IronPython.Modules/_ctypes/NativeArgument.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/NativeArgument.cs rename to src/core/IronPython.Modules/_ctypes/NativeArgument.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/NativeFunctions.cs b/src/core/IronPython.Modules/_ctypes/NativeFunctions.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/NativeFunctions.cs rename to src/core/IronPython.Modules/_ctypes/NativeFunctions.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/Pointer.cs b/src/core/IronPython.Modules/_ctypes/Pointer.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/Pointer.cs rename to src/core/IronPython.Modules/_ctypes/Pointer.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/PointerType.cs b/src/core/IronPython.Modules/_ctypes/PointerType.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/PointerType.cs rename to src/core/IronPython.Modules/_ctypes/PointerType.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/SimpleCData.cs b/src/core/IronPython.Modules/_ctypes/SimpleCData.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/SimpleCData.cs rename to src/core/IronPython.Modules/_ctypes/SimpleCData.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/SimpleType.cs b/src/core/IronPython.Modules/_ctypes/SimpleType.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/SimpleType.cs rename to src/core/IronPython.Modules/_ctypes/SimpleType.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/SimpleTypeKind.cs b/src/core/IronPython.Modules/_ctypes/SimpleTypeKind.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/SimpleTypeKind.cs rename to src/core/IronPython.Modules/_ctypes/SimpleTypeKind.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/StructType.cs b/src/core/IronPython.Modules/_ctypes/StructType.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/StructType.cs rename to src/core/IronPython.Modules/_ctypes/StructType.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/Structure.cs b/src/core/IronPython.Modules/_ctypes/Structure.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/Structure.cs rename to src/core/IronPython.Modules/_ctypes/Structure.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/Union.cs b/src/core/IronPython.Modules/_ctypes/Union.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/Union.cs rename to src/core/IronPython.Modules/_ctypes/Union.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/UnionType.cs b/src/core/IronPython.Modules/_ctypes/UnionType.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/UnionType.cs rename to src/core/IronPython.Modules/_ctypes/UnionType.cs diff --git a/src/ipy/IronPython.Modules/_ctypes/_ctypes.cs b/src/core/IronPython.Modules/_ctypes/_ctypes.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes/_ctypes.cs rename to src/core/IronPython.Modules/_ctypes/_ctypes.cs diff --git a/src/ipy/IronPython.Modules/_ctypes_test.cs b/src/core/IronPython.Modules/_ctypes_test.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ctypes_test.cs rename to src/core/IronPython.Modules/_ctypes_test.cs diff --git a/src/ipy/IronPython.Modules/_datetime.cs b/src/core/IronPython.Modules/_datetime.cs similarity index 100% rename from src/ipy/IronPython.Modules/_datetime.cs rename to src/core/IronPython.Modules/_datetime.cs diff --git a/src/ipy/IronPython.Modules/_functools.cs b/src/core/IronPython.Modules/_functools.cs similarity index 100% rename from src/ipy/IronPython.Modules/_functools.cs rename to src/core/IronPython.Modules/_functools.cs diff --git a/src/ipy/IronPython.Modules/_heapq.cs b/src/core/IronPython.Modules/_heapq.cs similarity index 100% rename from src/ipy/IronPython.Modules/_heapq.cs rename to src/core/IronPython.Modules/_heapq.cs diff --git a/src/ipy/IronPython.Modules/_multibytecodec.cs b/src/core/IronPython.Modules/_multibytecodec.cs similarity index 100% rename from src/ipy/IronPython.Modules/_multibytecodec.cs rename to src/core/IronPython.Modules/_multibytecodec.cs diff --git a/src/ipy/IronPython.Modules/_multiprocessing.cs b/src/core/IronPython.Modules/_multiprocessing.cs similarity index 100% rename from src/ipy/IronPython.Modules/_multiprocessing.cs rename to src/core/IronPython.Modules/_multiprocessing.cs diff --git a/src/ipy/IronPython.Modules/_opcode.cs b/src/core/IronPython.Modules/_opcode.cs similarity index 100% rename from src/ipy/IronPython.Modules/_opcode.cs rename to src/core/IronPython.Modules/_opcode.cs diff --git a/src/ipy/IronPython.Modules/_operator.cs b/src/core/IronPython.Modules/_operator.cs similarity index 100% rename from src/ipy/IronPython.Modules/_operator.cs rename to src/core/IronPython.Modules/_operator.cs diff --git a/src/ipy/IronPython.Modules/_overlapped.cs b/src/core/IronPython.Modules/_overlapped.cs similarity index 100% rename from src/ipy/IronPython.Modules/_overlapped.cs rename to src/core/IronPython.Modules/_overlapped.cs diff --git a/src/ipy/IronPython.Modules/_pickle.cs b/src/core/IronPython.Modules/_pickle.cs similarity index 100% rename from src/ipy/IronPython.Modules/_pickle.cs rename to src/core/IronPython.Modules/_pickle.cs diff --git a/src/ipy/IronPython.Modules/_posixsubprocess.cs b/src/core/IronPython.Modules/_posixsubprocess.cs similarity index 100% rename from src/ipy/IronPython.Modules/_posixsubprocess.cs rename to src/core/IronPython.Modules/_posixsubprocess.cs diff --git a/src/ipy/IronPython.Modules/_random.RandomGen.cs b/src/core/IronPython.Modules/_random.RandomGen.cs similarity index 100% rename from src/ipy/IronPython.Modules/_random.RandomGen.cs rename to src/core/IronPython.Modules/_random.RandomGen.cs diff --git a/src/ipy/IronPython.Modules/_random.cs b/src/core/IronPython.Modules/_random.cs similarity index 100% rename from src/ipy/IronPython.Modules/_random.cs rename to src/core/IronPython.Modules/_random.cs diff --git a/src/ipy/IronPython.Modules/_socket.cs b/src/core/IronPython.Modules/_socket.cs similarity index 100% rename from src/ipy/IronPython.Modules/_socket.cs rename to src/core/IronPython.Modules/_socket.cs diff --git a/src/ipy/IronPython.Modules/_sre.cs b/src/core/IronPython.Modules/_sre.cs similarity index 100% rename from src/ipy/IronPython.Modules/_sre.cs rename to src/core/IronPython.Modules/_sre.cs diff --git a/src/ipy/IronPython.Modules/_ssl.cs b/src/core/IronPython.Modules/_ssl.cs similarity index 100% rename from src/ipy/IronPython.Modules/_ssl.cs rename to src/core/IronPython.Modules/_ssl.cs diff --git a/src/ipy/IronPython.Modules/_string.cs b/src/core/IronPython.Modules/_string.cs similarity index 100% rename from src/ipy/IronPython.Modules/_string.cs rename to src/core/IronPython.Modules/_string.cs diff --git a/src/ipy/IronPython.Modules/_struct.cs b/src/core/IronPython.Modules/_struct.cs similarity index 100% rename from src/ipy/IronPython.Modules/_struct.cs rename to src/core/IronPython.Modules/_struct.cs diff --git a/src/ipy/IronPython.Modules/_sysconfigdata.cs b/src/core/IronPython.Modules/_sysconfigdata.cs similarity index 100% rename from src/ipy/IronPython.Modules/_sysconfigdata.cs rename to src/core/IronPython.Modules/_sysconfigdata.cs diff --git a/src/ipy/IronPython.Modules/_thread.cs b/src/core/IronPython.Modules/_thread.cs similarity index 100% rename from src/ipy/IronPython.Modules/_thread.cs rename to src/core/IronPython.Modules/_thread.cs diff --git a/src/ipy/IronPython.Modules/_warnings.cs b/src/core/IronPython.Modules/_warnings.cs similarity index 100% rename from src/ipy/IronPython.Modules/_warnings.cs rename to src/core/IronPython.Modules/_warnings.cs diff --git a/src/ipy/IronPython.Modules/_weakref.Generated.cs b/src/core/IronPython.Modules/_weakref.Generated.cs similarity index 100% rename from src/ipy/IronPython.Modules/_weakref.Generated.cs rename to src/core/IronPython.Modules/_weakref.Generated.cs diff --git a/src/ipy/IronPython.Modules/_weakref.cs b/src/core/IronPython.Modules/_weakref.cs similarity index 100% rename from src/ipy/IronPython.Modules/_weakref.cs rename to src/core/IronPython.Modules/_weakref.cs diff --git a/src/ipy/IronPython.Modules/_winapi.cs b/src/core/IronPython.Modules/_winapi.cs similarity index 100% rename from src/ipy/IronPython.Modules/_winapi.cs rename to src/core/IronPython.Modules/_winapi.cs diff --git a/src/ipy/IronPython.Modules/array.cs b/src/core/IronPython.Modules/array.cs similarity index 100% rename from src/ipy/IronPython.Modules/array.cs rename to src/core/IronPython.Modules/array.cs diff --git a/src/ipy/IronPython.Modules/atexit.cs b/src/core/IronPython.Modules/atexit.cs similarity index 100% rename from src/ipy/IronPython.Modules/atexit.cs rename to src/core/IronPython.Modules/atexit.cs diff --git a/src/ipy/IronPython.Modules/audioop.cs b/src/core/IronPython.Modules/audioop.cs similarity index 100% rename from src/ipy/IronPython.Modules/audioop.cs rename to src/core/IronPython.Modules/audioop.cs diff --git a/src/ipy/IronPython.Modules/binascii.cs b/src/core/IronPython.Modules/binascii.cs similarity index 100% rename from src/ipy/IronPython.Modules/binascii.cs rename to src/core/IronPython.Modules/binascii.cs diff --git a/src/ipy/IronPython.Modules/bz2/BZ2Compressor.cs b/src/core/IronPython.Modules/bz2/BZ2Compressor.cs similarity index 100% rename from src/ipy/IronPython.Modules/bz2/BZ2Compressor.cs rename to src/core/IronPython.Modules/bz2/BZ2Compressor.cs diff --git a/src/ipy/IronPython.Modules/bz2/BZ2Decompressor.cs b/src/core/IronPython.Modules/bz2/BZ2Decompressor.cs similarity index 100% rename from src/ipy/IronPython.Modules/bz2/BZ2Decompressor.cs rename to src/core/IronPython.Modules/bz2/BZ2Decompressor.cs diff --git a/src/ipy/IronPython.Modules/bz2/BZ2Module.cs b/src/core/IronPython.Modules/bz2/BZ2Module.cs similarity index 100% rename from src/ipy/IronPython.Modules/bz2/BZ2Module.cs rename to src/core/IronPython.Modules/bz2/BZ2Module.cs diff --git a/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs b/src/core/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs similarity index 100% rename from src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs rename to src/core/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2Compressor.cs diff --git a/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs b/src/core/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs similarity index 100% rename from src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs rename to src/core/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2InputStream.cs diff --git a/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs b/src/core/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs similarity index 100% rename from src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs rename to src/core/IronPython.Modules/bz2/dotnetzip/BZip2/BZip2OutputStream.cs diff --git a/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BitWriter.cs b/src/core/IronPython.Modules/bz2/dotnetzip/BZip2/BitWriter.cs similarity index 100% rename from src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/BitWriter.cs rename to src/core/IronPython.Modules/bz2/dotnetzip/BZip2/BitWriter.cs diff --git a/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/CRC32.cs b/src/core/IronPython.Modules/bz2/dotnetzip/BZip2/CRC32.cs similarity index 100% rename from src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/CRC32.cs rename to src/core/IronPython.Modules/bz2/dotnetzip/BZip2/CRC32.cs diff --git a/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs b/src/core/IronPython.Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs similarity index 100% rename from src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs rename to src/core/IronPython.Modules/bz2/dotnetzip/BZip2/ParallelBZip2OutputStream.cs diff --git a/src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/Rand.cs b/src/core/IronPython.Modules/bz2/dotnetzip/BZip2/Rand.cs similarity index 100% rename from src/ipy/IronPython.Modules/bz2/dotnetzip/BZip2/Rand.cs rename to src/core/IronPython.Modules/bz2/dotnetzip/BZip2/Rand.cs diff --git a/src/ipy/IronPython.Modules/bz2/dotnetzip/source.txt b/src/core/IronPython.Modules/bz2/dotnetzip/source.txt similarity index 100% rename from src/ipy/IronPython.Modules/bz2/dotnetzip/source.txt rename to src/core/IronPython.Modules/bz2/dotnetzip/source.txt diff --git a/src/ipy/IronPython.Modules/cmath.cs b/src/core/IronPython.Modules/cmath.cs similarity index 100% rename from src/ipy/IronPython.Modules/cmath.cs rename to src/core/IronPython.Modules/cmath.cs diff --git a/src/ipy/IronPython.Modules/errno.cs b/src/core/IronPython.Modules/errno.cs similarity index 100% rename from src/ipy/IronPython.Modules/errno.cs rename to src/core/IronPython.Modules/errno.cs diff --git a/src/ipy/IronPython.Modules/faulthandler.cs b/src/core/IronPython.Modules/faulthandler.cs similarity index 100% rename from src/ipy/IronPython.Modules/faulthandler.cs rename to src/core/IronPython.Modules/faulthandler.cs diff --git a/src/ipy/IronPython.Modules/fcntl.cs b/src/core/IronPython.Modules/fcntl.cs similarity index 100% rename from src/ipy/IronPython.Modules/fcntl.cs rename to src/core/IronPython.Modules/fcntl.cs diff --git a/src/ipy/IronPython.Modules/gc.cs b/src/core/IronPython.Modules/gc.cs similarity index 100% rename from src/ipy/IronPython.Modules/gc.cs rename to src/core/IronPython.Modules/gc.cs diff --git a/src/ipy/IronPython.Modules/grp.cs b/src/core/IronPython.Modules/grp.cs similarity index 100% rename from src/ipy/IronPython.Modules/grp.cs rename to src/core/IronPython.Modules/grp.cs diff --git a/src/ipy/IronPython.Modules/hashlib/MD5CryptoServiceProvider.cs b/src/core/IronPython.Modules/hashlib/MD5CryptoServiceProvider.cs similarity index 100% rename from src/ipy/IronPython.Modules/hashlib/MD5CryptoServiceProvider.cs rename to src/core/IronPython.Modules/hashlib/MD5CryptoServiceProvider.cs diff --git a/src/ipy/IronPython.Modules/hashlib/SHA1CryptoServiceProvider.cs b/src/core/IronPython.Modules/hashlib/SHA1CryptoServiceProvider.cs similarity index 100% rename from src/ipy/IronPython.Modules/hashlib/SHA1CryptoServiceProvider.cs rename to src/core/IronPython.Modules/hashlib/SHA1CryptoServiceProvider.cs diff --git a/src/ipy/IronPython.Modules/hashlib/SHA224.cs b/src/core/IronPython.Modules/hashlib/SHA224.cs similarity index 100% rename from src/ipy/IronPython.Modules/hashlib/SHA224.cs rename to src/core/IronPython.Modules/hashlib/SHA224.cs diff --git a/src/ipy/IronPython.Modules/hashlib/SHA224Managed.cs b/src/core/IronPython.Modules/hashlib/SHA224Managed.cs similarity index 100% rename from src/ipy/IronPython.Modules/hashlib/SHA224Managed.cs rename to src/core/IronPython.Modules/hashlib/SHA224Managed.cs diff --git a/src/ipy/IronPython.Modules/hashlib/SHA256Managed.cs b/src/core/IronPython.Modules/hashlib/SHA256Managed.cs similarity index 100% rename from src/ipy/IronPython.Modules/hashlib/SHA256Managed.cs rename to src/core/IronPython.Modules/hashlib/SHA256Managed.cs diff --git a/src/ipy/IronPython.Modules/hashlib/SHA384Managed.cs b/src/core/IronPython.Modules/hashlib/SHA384Managed.cs similarity index 100% rename from src/ipy/IronPython.Modules/hashlib/SHA384Managed.cs rename to src/core/IronPython.Modules/hashlib/SHA384Managed.cs diff --git a/src/ipy/IronPython.Modules/hashlib/SHA512Managed.cs b/src/core/IronPython.Modules/hashlib/SHA512Managed.cs similarity index 100% rename from src/ipy/IronPython.Modules/hashlib/SHA512Managed.cs rename to src/core/IronPython.Modules/hashlib/SHA512Managed.cs diff --git a/src/ipy/IronPython.Modules/hashlib/SHAConstants.cs b/src/core/IronPython.Modules/hashlib/SHAConstants.cs similarity index 100% rename from src/ipy/IronPython.Modules/hashlib/SHAConstants.cs rename to src/core/IronPython.Modules/hashlib/SHAConstants.cs diff --git a/src/ipy/IronPython.Modules/hashlib/_hashlib.cs b/src/core/IronPython.Modules/hashlib/_hashlib.cs similarity index 100% rename from src/ipy/IronPython.Modules/hashlib/_hashlib.cs rename to src/core/IronPython.Modules/hashlib/_hashlib.cs diff --git a/src/ipy/IronPython.Modules/hashlib/_md5.cs b/src/core/IronPython.Modules/hashlib/_md5.cs similarity index 100% rename from src/ipy/IronPython.Modules/hashlib/_md5.cs rename to src/core/IronPython.Modules/hashlib/_md5.cs diff --git a/src/ipy/IronPython.Modules/hashlib/_sha1.cs b/src/core/IronPython.Modules/hashlib/_sha1.cs similarity index 100% rename from src/ipy/IronPython.Modules/hashlib/_sha1.cs rename to src/core/IronPython.Modules/hashlib/_sha1.cs diff --git a/src/ipy/IronPython.Modules/hashlib/_sha256.cs b/src/core/IronPython.Modules/hashlib/_sha256.cs similarity index 100% rename from src/ipy/IronPython.Modules/hashlib/_sha256.cs rename to src/core/IronPython.Modules/hashlib/_sha256.cs diff --git a/src/ipy/IronPython.Modules/hashlib/_sha512.cs b/src/core/IronPython.Modules/hashlib/_sha512.cs similarity index 100% rename from src/ipy/IronPython.Modules/hashlib/_sha512.cs rename to src/core/IronPython.Modules/hashlib/_sha512.cs diff --git a/src/ipy/IronPython.Modules/marshal.cs b/src/core/IronPython.Modules/marshal.cs similarity index 100% rename from src/ipy/IronPython.Modules/marshal.cs rename to src/core/IronPython.Modules/marshal.cs diff --git a/src/ipy/IronPython.Modules/math.Generated.cs b/src/core/IronPython.Modules/math.Generated.cs similarity index 100% rename from src/ipy/IronPython.Modules/math.Generated.cs rename to src/core/IronPython.Modules/math.Generated.cs diff --git a/src/ipy/IronPython.Modules/math.cs b/src/core/IronPython.Modules/math.cs similarity index 100% rename from src/ipy/IronPython.Modules/math.cs rename to src/core/IronPython.Modules/math.cs diff --git a/src/ipy/IronPython.Modules/mmap.cs b/src/core/IronPython.Modules/mmap.cs similarity index 100% rename from src/ipy/IronPython.Modules/mmap.cs rename to src/core/IronPython.Modules/mmap.cs diff --git a/src/ipy/IronPython.Modules/msvcrt.cs b/src/core/IronPython.Modules/msvcrt.cs similarity index 100% rename from src/ipy/IronPython.Modules/msvcrt.cs rename to src/core/IronPython.Modules/msvcrt.cs diff --git a/src/ipy/IronPython.Modules/nt.cs b/src/core/IronPython.Modules/nt.cs similarity index 100% rename from src/ipy/IronPython.Modules/nt.cs rename to src/core/IronPython.Modules/nt.cs diff --git a/src/ipy/IronPython.Modules/policy.IronPython.Modules.config b/src/core/IronPython.Modules/policy.IronPython.Modules.config similarity index 100% rename from src/ipy/IronPython.Modules/policy.IronPython.Modules.config rename to src/core/IronPython.Modules/policy.IronPython.Modules.config diff --git a/src/ipy/IronPython.Modules/pwd.cs b/src/core/IronPython.Modules/pwd.cs similarity index 100% rename from src/ipy/IronPython.Modules/pwd.cs rename to src/core/IronPython.Modules/pwd.cs diff --git a/src/ipy/IronPython.Modules/pyexpat.cs b/src/core/IronPython.Modules/pyexpat.cs similarity index 100% rename from src/ipy/IronPython.Modules/pyexpat.cs rename to src/core/IronPython.Modules/pyexpat.cs diff --git a/src/ipy/IronPython.Modules/re.cs b/src/core/IronPython.Modules/re.cs similarity index 100% rename from src/ipy/IronPython.Modules/re.cs rename to src/core/IronPython.Modules/re.cs diff --git a/src/ipy/IronPython.Modules/resource.cs b/src/core/IronPython.Modules/resource.cs similarity index 100% rename from src/ipy/IronPython.Modules/resource.cs rename to src/core/IronPython.Modules/resource.cs diff --git a/src/ipy/IronPython.Modules/select.cs b/src/core/IronPython.Modules/select.cs similarity index 100% rename from src/ipy/IronPython.Modules/select.cs rename to src/core/IronPython.Modules/select.cs diff --git a/src/ipy/IronPython.Modules/signal.cs b/src/core/IronPython.Modules/signal.cs similarity index 100% rename from src/ipy/IronPython.Modules/signal.cs rename to src/core/IronPython.Modules/signal.cs diff --git a/src/ipy/IronPython.Modules/spwd.cs b/src/core/IronPython.Modules/spwd.cs similarity index 100% rename from src/ipy/IronPython.Modules/spwd.cs rename to src/core/IronPython.Modules/spwd.cs diff --git a/src/ipy/IronPython.Modules/time.cs b/src/core/IronPython.Modules/time.cs similarity index 100% rename from src/ipy/IronPython.Modules/time.cs rename to src/core/IronPython.Modules/time.cs diff --git a/src/ipy/IronPython.Modules/winreg.cs b/src/core/IronPython.Modules/winreg.cs similarity index 100% rename from src/ipy/IronPython.Modules/winreg.cs rename to src/core/IronPython.Modules/winreg.cs diff --git a/src/ipy/IronPython.Modules/winsound.cs b/src/core/IronPython.Modules/winsound.cs similarity index 100% rename from src/ipy/IronPython.Modules/winsound.cs rename to src/core/IronPython.Modules/winsound.cs diff --git a/src/ipy/IronPython.Modules/xxsubtype.cs b/src/core/IronPython.Modules/xxsubtype.cs similarity index 100% rename from src/ipy/IronPython.Modules/xxsubtype.cs rename to src/core/IronPython.Modules/xxsubtype.cs diff --git a/src/ipy/IronPython.Modules/zipimport.cs b/src/core/IronPython.Modules/zipimport.cs similarity index 100% rename from src/ipy/IronPython.Modules/zipimport.cs rename to src/core/IronPython.Modules/zipimport.cs diff --git a/src/ipy/IronPython.Modules/zlib/Compress.cs b/src/core/IronPython.Modules/zlib/Compress.cs similarity index 100% rename from src/ipy/IronPython.Modules/zlib/Compress.cs rename to src/core/IronPython.Modules/zlib/Compress.cs diff --git a/src/ipy/IronPython.Modules/zlib/Decompress.cs b/src/core/IronPython.Modules/zlib/Decompress.cs similarity index 100% rename from src/ipy/IronPython.Modules/zlib/Decompress.cs rename to src/core/IronPython.Modules/zlib/Decompress.cs diff --git a/src/ipy/IronPython.Modules/zlib/ZlibModule.cs b/src/core/IronPython.Modules/zlib/ZlibModule.cs similarity index 100% rename from src/ipy/IronPython.Modules/zlib/ZlibModule.cs rename to src/core/IronPython.Modules/zlib/ZlibModule.cs diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/Adler32.cs b/src/core/IronPython.Modules/zlib/zlib.net/Adler32.cs similarity index 100% rename from src/ipy/IronPython.Modules/zlib/zlib.net/Adler32.cs rename to src/core/IronPython.Modules/zlib/zlib.net/Adler32.cs diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/Deflate.cs b/src/core/IronPython.Modules/zlib/zlib.net/Deflate.cs similarity index 100% rename from src/ipy/IronPython.Modules/zlib/zlib.net/Deflate.cs rename to src/core/IronPython.Modules/zlib/zlib.net/Deflate.cs diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/InfBlocks.cs b/src/core/IronPython.Modules/zlib/zlib.net/InfBlocks.cs similarity index 100% rename from src/ipy/IronPython.Modules/zlib/zlib.net/InfBlocks.cs rename to src/core/IronPython.Modules/zlib/zlib.net/InfBlocks.cs diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/InfCodes.cs b/src/core/IronPython.Modules/zlib/zlib.net/InfCodes.cs similarity index 100% rename from src/ipy/IronPython.Modules/zlib/zlib.net/InfCodes.cs rename to src/core/IronPython.Modules/zlib/zlib.net/InfCodes.cs diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/InfTree.cs b/src/core/IronPython.Modules/zlib/zlib.net/InfTree.cs similarity index 100% rename from src/ipy/IronPython.Modules/zlib/zlib.net/InfTree.cs rename to src/core/IronPython.Modules/zlib/zlib.net/InfTree.cs diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/Inflate.cs b/src/core/IronPython.Modules/zlib/zlib.net/Inflate.cs similarity index 100% rename from src/ipy/IronPython.Modules/zlib/zlib.net/Inflate.cs rename to src/core/IronPython.Modules/zlib/zlib.net/Inflate.cs diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/StaticTree.cs b/src/core/IronPython.Modules/zlib/zlib.net/StaticTree.cs similarity index 100% rename from src/ipy/IronPython.Modules/zlib/zlib.net/StaticTree.cs rename to src/core/IronPython.Modules/zlib/zlib.net/StaticTree.cs diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/Tree.cs b/src/core/IronPython.Modules/zlib/zlib.net/Tree.cs similarity index 100% rename from src/ipy/IronPython.Modules/zlib/zlib.net/Tree.cs rename to src/core/IronPython.Modules/zlib/zlib.net/Tree.cs diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/ZStream.cs b/src/core/IronPython.Modules/zlib/zlib.net/ZStream.cs similarity index 100% rename from src/ipy/IronPython.Modules/zlib/zlib.net/ZStream.cs rename to src/core/IronPython.Modules/zlib/zlib.net/ZStream.cs diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/ZStreamException.cs b/src/core/IronPython.Modules/zlib/zlib.net/ZStreamException.cs similarity index 100% rename from src/ipy/IronPython.Modules/zlib/zlib.net/ZStreamException.cs rename to src/core/IronPython.Modules/zlib/zlib.net/ZStreamException.cs diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/Zlib.cs b/src/core/IronPython.Modules/zlib/zlib.net/Zlib.cs similarity index 100% rename from src/ipy/IronPython.Modules/zlib/zlib.net/Zlib.cs rename to src/core/IronPython.Modules/zlib/zlib.net/Zlib.cs diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/history.txt b/src/core/IronPython.Modules/zlib/zlib.net/history.txt similarity index 100% rename from src/ipy/IronPython.Modules/zlib/zlib.net/history.txt rename to src/core/IronPython.Modules/zlib/zlib.net/history.txt diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/license.txt b/src/core/IronPython.Modules/zlib/zlib.net/license.txt similarity index 100% rename from src/ipy/IronPython.Modules/zlib/zlib.net/license.txt rename to src/core/IronPython.Modules/zlib/zlib.net/license.txt diff --git a/src/ipy/IronPython.Modules/zlib/zlib.net/readme.txt b/src/core/IronPython.Modules/zlib/zlib.net/readme.txt similarity index 100% rename from src/ipy/IronPython.Modules/zlib/zlib.net/readme.txt rename to src/core/IronPython.Modules/zlib/zlib.net/readme.txt diff --git a/src/ipy/IronPython/Compiler/Ast/AndExpression.cs b/src/core/IronPython/Compiler/Ast/AndExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/AndExpression.cs rename to src/core/IronPython/Compiler/Ast/AndExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs b/src/core/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs rename to src/core/IronPython/Compiler/Ast/AnnotatedAssignStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/AssertStatement.cs b/src/core/IronPython/Compiler/Ast/AssertStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/AssertStatement.cs rename to src/core/IronPython/Compiler/Ast/AssertStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/AssignmentStatement.cs b/src/core/IronPython/Compiler/Ast/AssignmentStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/AssignmentStatement.cs rename to src/core/IronPython/Compiler/Ast/AssignmentStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/AstMethods.cs b/src/core/IronPython/Compiler/Ast/AstMethods.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/AstMethods.cs rename to src/core/IronPython/Compiler/Ast/AstMethods.cs diff --git a/src/ipy/IronPython/Compiler/Ast/AsyncStatement.cs b/src/core/IronPython/Compiler/Ast/AsyncStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/AsyncStatement.cs rename to src/core/IronPython/Compiler/Ast/AsyncStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/AugmentedAssignStatement.cs b/src/core/IronPython/Compiler/Ast/AugmentedAssignStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/AugmentedAssignStatement.cs rename to src/core/IronPython/Compiler/Ast/AugmentedAssignStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/BinaryExpression.Generated.cs b/src/core/IronPython/Compiler/Ast/BinaryExpression.Generated.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/BinaryExpression.Generated.cs rename to src/core/IronPython/Compiler/Ast/BinaryExpression.Generated.cs diff --git a/src/ipy/IronPython/Compiler/Ast/BinaryExpression.cs b/src/core/IronPython/Compiler/Ast/BinaryExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/BinaryExpression.cs rename to src/core/IronPython/Compiler/Ast/BinaryExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/BreakStatement.cs b/src/core/IronPython/Compiler/Ast/BreakStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/BreakStatement.cs rename to src/core/IronPython/Compiler/Ast/BreakStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/CallExpression.cs b/src/core/IronPython/Compiler/Ast/CallExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/CallExpression.cs rename to src/core/IronPython/Compiler/Ast/CallExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/ClassDefinition.cs b/src/core/IronPython/Compiler/Ast/ClassDefinition.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/ClassDefinition.cs rename to src/core/IronPython/Compiler/Ast/ClassDefinition.cs diff --git a/src/ipy/IronPython/Compiler/Ast/Comprehension.cs b/src/core/IronPython/Compiler/Ast/Comprehension.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/Comprehension.cs rename to src/core/IronPython/Compiler/Ast/Comprehension.cs diff --git a/src/ipy/IronPython/Compiler/Ast/ComprehensionFor.cs b/src/core/IronPython/Compiler/Ast/ComprehensionFor.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/ComprehensionFor.cs rename to src/core/IronPython/Compiler/Ast/ComprehensionFor.cs diff --git a/src/ipy/IronPython/Compiler/Ast/ComprehensionIf.cs b/src/core/IronPython/Compiler/Ast/ComprehensionIf.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/ComprehensionIf.cs rename to src/core/IronPython/Compiler/Ast/ComprehensionIf.cs diff --git a/src/ipy/IronPython/Compiler/Ast/ConditionalExpression.cs b/src/core/IronPython/Compiler/Ast/ConditionalExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/ConditionalExpression.cs rename to src/core/IronPython/Compiler/Ast/ConditionalExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/ConstantExpression.cs b/src/core/IronPython/Compiler/Ast/ConstantExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/ConstantExpression.cs rename to src/core/IronPython/Compiler/Ast/ConstantExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/ContinueStatement.cs b/src/core/IronPython/Compiler/Ast/ContinueStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/ContinueStatement.cs rename to src/core/IronPython/Compiler/Ast/ContinueStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/DelStatement.cs b/src/core/IronPython/Compiler/Ast/DelStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/DelStatement.cs rename to src/core/IronPython/Compiler/Ast/DelStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/DictionaryExpression.cs b/src/core/IronPython/Compiler/Ast/DictionaryExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/DictionaryExpression.cs rename to src/core/IronPython/Compiler/Ast/DictionaryExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/DottedName.cs b/src/core/IronPython/Compiler/Ast/DottedName.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/DottedName.cs rename to src/core/IronPython/Compiler/Ast/DottedName.cs diff --git a/src/ipy/IronPython/Compiler/Ast/DynamicConvertExpression.cs b/src/core/IronPython/Compiler/Ast/DynamicConvertExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/DynamicConvertExpression.cs rename to src/core/IronPython/Compiler/Ast/DynamicConvertExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs b/src/core/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs rename to src/core/IronPython/Compiler/Ast/DynamicGetMemberExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/EmptyStatement.cs b/src/core/IronPython/Compiler/Ast/EmptyStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/EmptyStatement.cs rename to src/core/IronPython/Compiler/Ast/EmptyStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/ErrorExpression.cs b/src/core/IronPython/Compiler/Ast/ErrorExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/ErrorExpression.cs rename to src/core/IronPython/Compiler/Ast/ErrorExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/Expression.cs b/src/core/IronPython/Compiler/Ast/Expression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/Expression.cs rename to src/core/IronPython/Compiler/Ast/Expression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/ExpressionStatement.cs b/src/core/IronPython/Compiler/Ast/ExpressionStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/ExpressionStatement.cs rename to src/core/IronPython/Compiler/Ast/ExpressionStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/FlowChecker.cs b/src/core/IronPython/Compiler/Ast/FlowChecker.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/FlowChecker.cs rename to src/core/IronPython/Compiler/Ast/FlowChecker.cs diff --git a/src/ipy/IronPython/Compiler/Ast/ForStatement.cs b/src/core/IronPython/Compiler/Ast/ForStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/ForStatement.cs rename to src/core/IronPython/Compiler/Ast/ForStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/FormattedValueExpression.cs b/src/core/IronPython/Compiler/Ast/FormattedValueExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/FormattedValueExpression.cs rename to src/core/IronPython/Compiler/Ast/FormattedValueExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/FromImportStatement.cs b/src/core/IronPython/Compiler/Ast/FromImportStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/FromImportStatement.cs rename to src/core/IronPython/Compiler/Ast/FromImportStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/FunctionDefinition.cs b/src/core/IronPython/Compiler/Ast/FunctionDefinition.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/FunctionDefinition.cs rename to src/core/IronPython/Compiler/Ast/FunctionDefinition.cs diff --git a/src/ipy/IronPython/Compiler/Ast/GeneratorExpression.cs b/src/core/IronPython/Compiler/Ast/GeneratorExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/GeneratorExpression.cs rename to src/core/IronPython/Compiler/Ast/GeneratorExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/GetGlobalContextExpression.cs b/src/core/IronPython/Compiler/Ast/GetGlobalContextExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/GetGlobalContextExpression.cs rename to src/core/IronPython/Compiler/Ast/GetGlobalContextExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs b/src/core/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs rename to src/core/IronPython/Compiler/Ast/GetParentContextFromFunctionExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/GlobalStatement.cs b/src/core/IronPython/Compiler/Ast/GlobalStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/GlobalStatement.cs rename to src/core/IronPython/Compiler/Ast/GlobalStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/ILoopStatement.cs b/src/core/IronPython/Compiler/Ast/ILoopStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/ILoopStatement.cs rename to src/core/IronPython/Compiler/Ast/ILoopStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/IfStatement.cs b/src/core/IronPython/Compiler/Ast/IfStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/IfStatement.cs rename to src/core/IronPython/Compiler/Ast/IfStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/IfStatementTest.cs b/src/core/IronPython/Compiler/Ast/IfStatementTest.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/IfStatementTest.cs rename to src/core/IronPython/Compiler/Ast/IfStatementTest.cs diff --git a/src/ipy/IronPython/Compiler/Ast/ImportStatement.cs b/src/core/IronPython/Compiler/Ast/ImportStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/ImportStatement.cs rename to src/core/IronPython/Compiler/Ast/ImportStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/IndexExpression.cs b/src/core/IronPython/Compiler/Ast/IndexExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/IndexExpression.cs rename to src/core/IronPython/Compiler/Ast/IndexExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/JoinedStringExpression.cs b/src/core/IronPython/Compiler/Ast/JoinedStringExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/JoinedStringExpression.cs rename to src/core/IronPython/Compiler/Ast/JoinedStringExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/Keyword.cs b/src/core/IronPython/Compiler/Ast/Keyword.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/Keyword.cs rename to src/core/IronPython/Compiler/Ast/Keyword.cs diff --git a/src/ipy/IronPython/Compiler/Ast/LambdaExpression.cs b/src/core/IronPython/Compiler/Ast/LambdaExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/LambdaExpression.cs rename to src/core/IronPython/Compiler/Ast/LambdaExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/ListExpression.cs b/src/core/IronPython/Compiler/Ast/ListExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/ListExpression.cs rename to src/core/IronPython/Compiler/Ast/ListExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/MemberExpression.cs b/src/core/IronPython/Compiler/Ast/MemberExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/MemberExpression.cs rename to src/core/IronPython/Compiler/Ast/MemberExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/ModuleName.cs b/src/core/IronPython/Compiler/Ast/ModuleName.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/ModuleName.cs rename to src/core/IronPython/Compiler/Ast/ModuleName.cs diff --git a/src/ipy/IronPython/Compiler/Ast/NameExpression.cs b/src/core/IronPython/Compiler/Ast/NameExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/NameExpression.cs rename to src/core/IronPython/Compiler/Ast/NameExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/Node.cs b/src/core/IronPython/Compiler/Ast/Node.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/Node.cs rename to src/core/IronPython/Compiler/Ast/Node.cs diff --git a/src/ipy/IronPython/Compiler/Ast/NonlocalStatement.cs b/src/core/IronPython/Compiler/Ast/NonlocalStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/NonlocalStatement.cs rename to src/core/IronPython/Compiler/Ast/NonlocalStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/OrExpression.cs b/src/core/IronPython/Compiler/Ast/OrExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/OrExpression.cs rename to src/core/IronPython/Compiler/Ast/OrExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/Parameter.cs b/src/core/IronPython/Compiler/Ast/Parameter.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/Parameter.cs rename to src/core/IronPython/Compiler/Ast/Parameter.cs diff --git a/src/ipy/IronPython/Compiler/Ast/ParenthesisExpression.cs b/src/core/IronPython/Compiler/Ast/ParenthesisExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/ParenthesisExpression.cs rename to src/core/IronPython/Compiler/Ast/ParenthesisExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/PythonAst.cs b/src/core/IronPython/Compiler/Ast/PythonAst.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/PythonAst.cs rename to src/core/IronPython/Compiler/Ast/PythonAst.cs diff --git a/src/ipy/IronPython/Compiler/Ast/PythonConstantExpression.cs b/src/core/IronPython/Compiler/Ast/PythonConstantExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/PythonConstantExpression.cs rename to src/core/IronPython/Compiler/Ast/PythonConstantExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/PythonNameBinder.cs b/src/core/IronPython/Compiler/Ast/PythonNameBinder.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/PythonNameBinder.cs rename to src/core/IronPython/Compiler/Ast/PythonNameBinder.cs diff --git a/src/ipy/IronPython/Compiler/Ast/PythonReference.cs b/src/core/IronPython/Compiler/Ast/PythonReference.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/PythonReference.cs rename to src/core/IronPython/Compiler/Ast/PythonReference.cs diff --git a/src/ipy/IronPython/Compiler/Ast/PythonVariable.cs b/src/core/IronPython/Compiler/Ast/PythonVariable.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/PythonVariable.cs rename to src/core/IronPython/Compiler/Ast/PythonVariable.cs diff --git a/src/ipy/IronPython/Compiler/Ast/PythonWalker.Generated.cs b/src/core/IronPython/Compiler/Ast/PythonWalker.Generated.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/PythonWalker.Generated.cs rename to src/core/IronPython/Compiler/Ast/PythonWalker.Generated.cs diff --git a/src/ipy/IronPython/Compiler/Ast/RaiseStatement.cs b/src/core/IronPython/Compiler/Ast/RaiseStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/RaiseStatement.cs rename to src/core/IronPython/Compiler/Ast/RaiseStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/RelativeModuleName.cs b/src/core/IronPython/Compiler/Ast/RelativeModuleName.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/RelativeModuleName.cs rename to src/core/IronPython/Compiler/Ast/RelativeModuleName.cs diff --git a/src/ipy/IronPython/Compiler/Ast/ReturnStatement.cs b/src/core/IronPython/Compiler/Ast/ReturnStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/ReturnStatement.cs rename to src/core/IronPython/Compiler/Ast/ReturnStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/ScopeStatement.cs b/src/core/IronPython/Compiler/Ast/ScopeStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/ScopeStatement.cs rename to src/core/IronPython/Compiler/Ast/ScopeStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/SequenceExpression.cs b/src/core/IronPython/Compiler/Ast/SequenceExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/SequenceExpression.cs rename to src/core/IronPython/Compiler/Ast/SequenceExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/SerializedScopeStatement.cs b/src/core/IronPython/Compiler/Ast/SerializedScopeStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/SerializedScopeStatement.cs rename to src/core/IronPython/Compiler/Ast/SerializedScopeStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/SetExpression.cs b/src/core/IronPython/Compiler/Ast/SetExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/SetExpression.cs rename to src/core/IronPython/Compiler/Ast/SetExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/SliceExpression.cs b/src/core/IronPython/Compiler/Ast/SliceExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/SliceExpression.cs rename to src/core/IronPython/Compiler/Ast/SliceExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/StarredExpression.cs b/src/core/IronPython/Compiler/Ast/StarredExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/StarredExpression.cs rename to src/core/IronPython/Compiler/Ast/StarredExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/Statement.cs b/src/core/IronPython/Compiler/Ast/Statement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/Statement.cs rename to src/core/IronPython/Compiler/Ast/Statement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/SuiteStatement.cs b/src/core/IronPython/Compiler/Ast/SuiteStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/SuiteStatement.cs rename to src/core/IronPython/Compiler/Ast/SuiteStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/TryStatement.cs b/src/core/IronPython/Compiler/Ast/TryStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/TryStatement.cs rename to src/core/IronPython/Compiler/Ast/TryStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/TupleExpression.cs b/src/core/IronPython/Compiler/Ast/TupleExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/TupleExpression.cs rename to src/core/IronPython/Compiler/Ast/TupleExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/UnaryExpression.cs b/src/core/IronPython/Compiler/Ast/UnaryExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/UnaryExpression.cs rename to src/core/IronPython/Compiler/Ast/UnaryExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/VariableKind.cs b/src/core/IronPython/Compiler/Ast/VariableKind.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/VariableKind.cs rename to src/core/IronPython/Compiler/Ast/VariableKind.cs diff --git a/src/ipy/IronPython/Compiler/Ast/WhileStatement.cs b/src/core/IronPython/Compiler/Ast/WhileStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/WhileStatement.cs rename to src/core/IronPython/Compiler/Ast/WhileStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/WithStatement.cs b/src/core/IronPython/Compiler/Ast/WithStatement.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/WithStatement.cs rename to src/core/IronPython/Compiler/Ast/WithStatement.cs diff --git a/src/ipy/IronPython/Compiler/Ast/YieldExpression.cs b/src/core/IronPython/Compiler/Ast/YieldExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/YieldExpression.cs rename to src/core/IronPython/Compiler/Ast/YieldExpression.cs diff --git a/src/ipy/IronPython/Compiler/Ast/YieldFromExpression.cs b/src/core/IronPython/Compiler/Ast/YieldFromExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Ast/YieldFromExpression.cs rename to src/core/IronPython/Compiler/Ast/YieldFromExpression.cs diff --git a/src/ipy/IronPython/Compiler/ClosureExpression.cs b/src/core/IronPython/Compiler/ClosureExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/ClosureExpression.cs rename to src/core/IronPython/Compiler/ClosureExpression.cs diff --git a/src/ipy/IronPython/Compiler/ClosureInfo.cs b/src/core/IronPython/Compiler/ClosureInfo.cs similarity index 100% rename from src/ipy/IronPython/Compiler/ClosureInfo.cs rename to src/core/IronPython/Compiler/ClosureInfo.cs diff --git a/src/ipy/IronPython/Compiler/CollectableCompilationMode.cs b/src/core/IronPython/Compiler/CollectableCompilationMode.cs similarity index 100% rename from src/ipy/IronPython/Compiler/CollectableCompilationMode.cs rename to src/core/IronPython/Compiler/CollectableCompilationMode.cs diff --git a/src/ipy/IronPython/Compiler/CompilationMode.cs b/src/core/IronPython/Compiler/CompilationMode.cs similarity index 100% rename from src/ipy/IronPython/Compiler/CompilationMode.cs rename to src/core/IronPython/Compiler/CompilationMode.cs diff --git a/src/ipy/IronPython/Compiler/GeneratorRewriter.cs b/src/core/IronPython/Compiler/GeneratorRewriter.cs similarity index 100% rename from src/ipy/IronPython/Compiler/GeneratorRewriter.cs rename to src/core/IronPython/Compiler/GeneratorRewriter.cs diff --git a/src/ipy/IronPython/Compiler/LazyCode.cs b/src/core/IronPython/Compiler/LazyCode.cs similarity index 100% rename from src/ipy/IronPython/Compiler/LazyCode.cs rename to src/core/IronPython/Compiler/LazyCode.cs diff --git a/src/ipy/IronPython/Compiler/LookupCompilationMode.cs b/src/core/IronPython/Compiler/LookupCompilationMode.cs similarity index 100% rename from src/ipy/IronPython/Compiler/LookupCompilationMode.cs rename to src/core/IronPython/Compiler/LookupCompilationMode.cs diff --git a/src/ipy/IronPython/Compiler/OnDiskScriptCode.cs b/src/core/IronPython/Compiler/OnDiskScriptCode.cs similarity index 100% rename from src/ipy/IronPython/Compiler/OnDiskScriptCode.cs rename to src/core/IronPython/Compiler/OnDiskScriptCode.cs diff --git a/src/ipy/IronPython/Compiler/Parser.cs b/src/core/IronPython/Compiler/Parser.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Parser.cs rename to src/core/IronPython/Compiler/Parser.cs diff --git a/src/ipy/IronPython/Compiler/PythonCallTargets.cs b/src/core/IronPython/Compiler/PythonCallTargets.cs similarity index 100% rename from src/ipy/IronPython/Compiler/PythonCallTargets.cs rename to src/core/IronPython/Compiler/PythonCallTargets.cs diff --git a/src/ipy/IronPython/Compiler/PythonCompilerOptions.cs b/src/core/IronPython/Compiler/PythonCompilerOptions.cs similarity index 100% rename from src/ipy/IronPython/Compiler/PythonCompilerOptions.cs rename to src/core/IronPython/Compiler/PythonCompilerOptions.cs diff --git a/src/ipy/IronPython/Compiler/PythonDynamicExpression.cs b/src/core/IronPython/Compiler/PythonDynamicExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/PythonDynamicExpression.cs rename to src/core/IronPython/Compiler/PythonDynamicExpression.cs diff --git a/src/ipy/IronPython/Compiler/PythonGlobal.cs b/src/core/IronPython/Compiler/PythonGlobal.cs similarity index 100% rename from src/ipy/IronPython/Compiler/PythonGlobal.cs rename to src/core/IronPython/Compiler/PythonGlobal.cs diff --git a/src/ipy/IronPython/Compiler/PythonGlobalVariableExpression.cs b/src/core/IronPython/Compiler/PythonGlobalVariableExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/PythonGlobalVariableExpression.cs rename to src/core/IronPython/Compiler/PythonGlobalVariableExpression.cs diff --git a/src/ipy/IronPython/Compiler/PythonOperator.cs b/src/core/IronPython/Compiler/PythonOperator.cs similarity index 100% rename from src/ipy/IronPython/Compiler/PythonOperator.cs rename to src/core/IronPython/Compiler/PythonOperator.cs diff --git a/src/ipy/IronPython/Compiler/PythonSavableScriptCode.cs b/src/core/IronPython/Compiler/PythonSavableScriptCode.cs similarity index 100% rename from src/ipy/IronPython/Compiler/PythonSavableScriptCode.cs rename to src/core/IronPython/Compiler/PythonSavableScriptCode.cs diff --git a/src/ipy/IronPython/Compiler/PythonScriptCode.cs b/src/core/IronPython/Compiler/PythonScriptCode.cs similarity index 100% rename from src/ipy/IronPython/Compiler/PythonScriptCode.cs rename to src/core/IronPython/Compiler/PythonScriptCode.cs diff --git a/src/ipy/IronPython/Compiler/ReducableDynamicExpression.cs b/src/core/IronPython/Compiler/ReducableDynamicExpression.cs similarity index 100% rename from src/ipy/IronPython/Compiler/ReducableDynamicExpression.cs rename to src/core/IronPython/Compiler/ReducableDynamicExpression.cs diff --git a/src/ipy/IronPython/Compiler/RunnableScriptCode.cs b/src/core/IronPython/Compiler/RunnableScriptCode.cs similarity index 100% rename from src/ipy/IronPython/Compiler/RunnableScriptCode.cs rename to src/core/IronPython/Compiler/RunnableScriptCode.cs diff --git a/src/ipy/IronPython/Compiler/RuntimeScriptCode.cs b/src/core/IronPython/Compiler/RuntimeScriptCode.cs similarity index 100% rename from src/ipy/IronPython/Compiler/RuntimeScriptCode.cs rename to src/core/IronPython/Compiler/RuntimeScriptCode.cs diff --git a/src/ipy/IronPython/Compiler/ToDiskCompilationMode.cs b/src/core/IronPython/Compiler/ToDiskCompilationMode.cs similarity index 100% rename from src/ipy/IronPython/Compiler/ToDiskCompilationMode.cs rename to src/core/IronPython/Compiler/ToDiskCompilationMode.cs diff --git a/src/ipy/IronPython/Compiler/Token.cs b/src/core/IronPython/Compiler/Token.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Token.cs rename to src/core/IronPython/Compiler/Token.cs diff --git a/src/ipy/IronPython/Compiler/TokenKind.Generated.cs b/src/core/IronPython/Compiler/TokenKind.Generated.cs similarity index 100% rename from src/ipy/IronPython/Compiler/TokenKind.Generated.cs rename to src/core/IronPython/Compiler/TokenKind.Generated.cs diff --git a/src/ipy/IronPython/Compiler/Tokenizer.Generated.cs b/src/core/IronPython/Compiler/Tokenizer.Generated.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Tokenizer.Generated.cs rename to src/core/IronPython/Compiler/Tokenizer.Generated.cs diff --git a/src/ipy/IronPython/Compiler/Tokenizer.cs b/src/core/IronPython/Compiler/Tokenizer.cs similarity index 100% rename from src/ipy/IronPython/Compiler/Tokenizer.cs rename to src/core/IronPython/Compiler/Tokenizer.cs diff --git a/src/ipy/IronPython/Compiler/UncollectableCompilationMode.Generated.cs b/src/core/IronPython/Compiler/UncollectableCompilationMode.Generated.cs similarity index 100% rename from src/ipy/IronPython/Compiler/UncollectableCompilationMode.Generated.cs rename to src/core/IronPython/Compiler/UncollectableCompilationMode.Generated.cs diff --git a/src/ipy/IronPython/Compiler/UncollectableCompilationMode.cs b/src/core/IronPython/Compiler/UncollectableCompilationMode.cs similarity index 100% rename from src/ipy/IronPython/Compiler/UncollectableCompilationMode.cs rename to src/core/IronPython/Compiler/UncollectableCompilationMode.cs diff --git a/src/ipy/IronPython/FakeInteropServices.cs b/src/core/IronPython/FakeInteropServices.cs similarity index 100% rename from src/ipy/IronPython/FakeInteropServices.cs rename to src/core/IronPython/FakeInteropServices.cs diff --git a/src/ipy/IronPython/Hosting/Python.cs b/src/core/IronPython/Hosting/Python.cs similarity index 100% rename from src/ipy/IronPython/Hosting/Python.cs rename to src/core/IronPython/Hosting/Python.cs diff --git a/src/ipy/IronPython/Hosting/PythonCodeDomCodeGen.cs b/src/core/IronPython/Hosting/PythonCodeDomCodeGen.cs similarity index 100% rename from src/ipy/IronPython/Hosting/PythonCodeDomCodeGen.cs rename to src/core/IronPython/Hosting/PythonCodeDomCodeGen.cs diff --git a/src/ipy/IronPython/Hosting/PythonCommandLine.cs b/src/core/IronPython/Hosting/PythonCommandLine.cs similarity index 100% rename from src/ipy/IronPython/Hosting/PythonCommandLine.cs rename to src/core/IronPython/Hosting/PythonCommandLine.cs diff --git a/src/ipy/IronPython/Hosting/PythonConsoleOptions.cs b/src/core/IronPython/Hosting/PythonConsoleOptions.cs similarity index 100% rename from src/ipy/IronPython/Hosting/PythonConsoleOptions.cs rename to src/core/IronPython/Hosting/PythonConsoleOptions.cs diff --git a/src/ipy/IronPython/Hosting/PythonOptionsParser.cs b/src/core/IronPython/Hosting/PythonOptionsParser.cs similarity index 100% rename from src/ipy/IronPython/Hosting/PythonOptionsParser.cs rename to src/core/IronPython/Hosting/PythonOptionsParser.cs diff --git a/src/ipy/IronPython/Hosting/PythonService.cs b/src/core/IronPython/Hosting/PythonService.cs similarity index 100% rename from src/ipy/IronPython/Hosting/PythonService.cs rename to src/core/IronPython/Hosting/PythonService.cs diff --git a/src/ipy/IronPython/Interop/Windows/Interop.Libraries.cs b/src/core/IronPython/Interop/Windows/Interop.Libraries.cs similarity index 100% rename from src/ipy/IronPython/Interop/Windows/Interop.Libraries.cs rename to src/core/IronPython/Interop/Windows/Interop.Libraries.cs diff --git a/src/ipy/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs b/src/core/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs similarity index 100% rename from src/ipy/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs rename to src/core/IronPython/Interop/Windows/Kernel32/Interop.GetWindowsExW.cs diff --git a/src/ipy/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs b/src/core/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs similarity index 100% rename from src/ipy/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs rename to src/core/IronPython/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs diff --git a/src/ipy/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs b/src/core/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs similarity index 100% rename from src/ipy/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs rename to src/core/IronPython/Interop/Windows/NtDll/Interop.RtlGetVersion.cs diff --git a/src/ipy/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs b/src/core/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs similarity index 100% rename from src/ipy/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs rename to src/core/IronPython/Interop/Windows/Ucrtbase/Interop.strerror.cs diff --git a/src/ipy/IronPython/IronPython.csproj b/src/core/IronPython/IronPython.csproj similarity index 100% rename from src/ipy/IronPython/IronPython.csproj rename to src/core/IronPython/IronPython.csproj diff --git a/src/ipy/IronPython/Lib/iptest/__init__.py b/src/core/IronPython/Lib/iptest/__init__.py similarity index 100% rename from src/ipy/IronPython/Lib/iptest/__init__.py rename to src/core/IronPython/Lib/iptest/__init__.py diff --git a/src/ipy/IronPython/Lib/iptest/cominterop_util.py b/src/core/IronPython/Lib/iptest/cominterop_util.py similarity index 100% rename from src/ipy/IronPython/Lib/iptest/cominterop_util.py rename to src/core/IronPython/Lib/iptest/cominterop_util.py diff --git a/src/ipy/IronPython/Lib/iptest/console_util.py b/src/core/IronPython/Lib/iptest/console_util.py similarity index 100% rename from src/ipy/IronPython/Lib/iptest/console_util.py rename to src/core/IronPython/Lib/iptest/console_util.py diff --git a/src/ipy/IronPython/Lib/iptest/file_util.py b/src/core/IronPython/Lib/iptest/file_util.py similarity index 100% rename from src/ipy/IronPython/Lib/iptest/file_util.py rename to src/core/IronPython/Lib/iptest/file_util.py diff --git a/src/ipy/IronPython/Lib/iptest/ipunittest.py b/src/core/IronPython/Lib/iptest/ipunittest.py similarity index 100% rename from src/ipy/IronPython/Lib/iptest/ipunittest.py rename to src/core/IronPython/Lib/iptest/ipunittest.py diff --git a/src/ipy/IronPython/Lib/iptest/misc_util.py b/src/core/IronPython/Lib/iptest/misc_util.py similarity index 100% rename from src/ipy/IronPython/Lib/iptest/misc_util.py rename to src/core/IronPython/Lib/iptest/misc_util.py diff --git a/src/ipy/IronPython/Lib/iptest/process_util.py b/src/core/IronPython/Lib/iptest/process_util.py similarity index 100% rename from src/ipy/IronPython/Lib/iptest/process_util.py rename to src/core/IronPython/Lib/iptest/process_util.py diff --git a/src/ipy/IronPython/Lib/iptest/runner.py b/src/core/IronPython/Lib/iptest/runner.py similarity index 100% rename from src/ipy/IronPython/Lib/iptest/runner.py rename to src/core/IronPython/Lib/iptest/runner.py diff --git a/src/ipy/IronPython/Lib/iptest/test_env.py b/src/core/IronPython/Lib/iptest/test_env.py similarity index 100% rename from src/ipy/IronPython/Lib/iptest/test_env.py rename to src/core/IronPython/Lib/iptest/test_env.py diff --git a/src/ipy/IronPython/Lib/iptest/type_util.py b/src/core/IronPython/Lib/iptest/type_util.py similarity index 100% rename from src/ipy/IronPython/Lib/iptest/type_util.py rename to src/core/IronPython/Lib/iptest/type_util.py diff --git a/src/ipy/IronPython/Modules/Builtin.Generated.cs b/src/core/IronPython/Modules/Builtin.Generated.cs similarity index 100% rename from src/ipy/IronPython/Modules/Builtin.Generated.cs rename to src/core/IronPython/Modules/Builtin.Generated.cs diff --git a/src/ipy/IronPython/Modules/Builtin.cs b/src/core/IronPython/Modules/Builtin.cs similarity index 100% rename from src/ipy/IronPython/Modules/Builtin.cs rename to src/core/IronPython/Modules/Builtin.cs diff --git a/src/ipy/IronPython/Modules/_ast.cs b/src/core/IronPython/Modules/_ast.cs similarity index 100% rename from src/ipy/IronPython/Modules/_ast.cs rename to src/core/IronPython/Modules/_ast.cs diff --git a/src/ipy/IronPython/Modules/_fileio.cs b/src/core/IronPython/Modules/_fileio.cs similarity index 100% rename from src/ipy/IronPython/Modules/_fileio.cs rename to src/core/IronPython/Modules/_fileio.cs diff --git a/src/ipy/IronPython/Modules/_imp.cs b/src/core/IronPython/Modules/_imp.cs similarity index 100% rename from src/ipy/IronPython/Modules/_imp.cs rename to src/core/IronPython/Modules/_imp.cs diff --git a/src/ipy/IronPython/Modules/_io.cs b/src/core/IronPython/Modules/_io.cs similarity index 100% rename from src/ipy/IronPython/Modules/_io.cs rename to src/core/IronPython/Modules/_io.cs diff --git a/src/ipy/IronPython/Modules/_io/BytesIO.cs b/src/core/IronPython/Modules/_io/BytesIO.cs similarity index 100% rename from src/ipy/IronPython/Modules/_io/BytesIO.cs rename to src/core/IronPython/Modules/_io/BytesIO.cs diff --git a/src/ipy/IronPython/Modules/_io/StringIO.cs b/src/core/IronPython/Modules/_io/StringIO.cs similarity index 100% rename from src/ipy/IronPython/Modules/_io/StringIO.cs rename to src/core/IronPython/Modules/_io/StringIO.cs diff --git a/src/ipy/IronPython/Modules/_locale.cs b/src/core/IronPython/Modules/_locale.cs similarity index 100% rename from src/ipy/IronPython/Modules/_locale.cs rename to src/core/IronPython/Modules/_locale.cs diff --git a/src/ipy/IronPython/Modules/sys.cs b/src/core/IronPython/Modules/sys.cs similarity index 100% rename from src/ipy/IronPython/Modules/sys.cs rename to src/core/IronPython/Modules/sys.cs diff --git a/src/ipy/IronPython/Modules/unicodedata.cs b/src/core/IronPython/Modules/unicodedata.cs similarity index 100% rename from src/ipy/IronPython/Modules/unicodedata.cs rename to src/core/IronPython/Modules/unicodedata.cs diff --git a/src/ipy/IronPython/Modules/unicodedata/CaseFolding.txt b/src/core/IronPython/Modules/unicodedata/CaseFolding.txt similarity index 100% rename from src/ipy/IronPython/Modules/unicodedata/CaseFolding.txt rename to src/core/IronPython/Modules/unicodedata/CaseFolding.txt diff --git a/src/ipy/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt b/src/core/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt similarity index 100% rename from src/ipy/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt rename to src/core/IronPython/Modules/unicodedata/EastAsianWidth-3.2.0.txt diff --git a/src/ipy/IronPython/Modules/unicodedata/EastAsianWidth.txt b/src/core/IronPython/Modules/unicodedata/EastAsianWidth.txt similarity index 100% rename from src/ipy/IronPython/Modules/unicodedata/EastAsianWidth.txt rename to src/core/IronPython/Modules/unicodedata/EastAsianWidth.txt diff --git a/src/ipy/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz b/src/core/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz similarity index 100% rename from src/ipy/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz rename to src/core/IronPython/Modules/unicodedata/IPyUnicodeData-3.2.0.txt.gz diff --git a/src/ipy/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz b/src/core/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz similarity index 100% rename from src/ipy/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz rename to src/core/IronPython/Modules/unicodedata/IPyUnicodeData.txt.gz diff --git a/src/ipy/IronPython/Modules/unicodedata/NameAliases.txt b/src/core/IronPython/Modules/unicodedata/NameAliases.txt similarity index 100% rename from src/ipy/IronPython/Modules/unicodedata/NameAliases.txt rename to src/core/IronPython/Modules/unicodedata/NameAliases.txt diff --git a/src/ipy/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt b/src/core/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt similarity index 100% rename from src/ipy/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt rename to src/core/IronPython/Modules/unicodedata/UnicodeData-3.2.0.txt diff --git a/src/ipy/IronPython/Modules/unicodedata/UnicodeData.txt b/src/core/IronPython/Modules/unicodedata/UnicodeData.txt similarity index 100% rename from src/ipy/IronPython/Modules/unicodedata/UnicodeData.txt rename to src/core/IronPython/Modules/unicodedata/UnicodeData.txt diff --git a/src/ipy/IronPython/Modules/unicodedata/genunicodedata.py b/src/core/IronPython/Modules/unicodedata/genunicodedata.py similarity index 100% rename from src/ipy/IronPython/Modules/unicodedata/genunicodedata.py rename to src/core/IronPython/Modules/unicodedata/genunicodedata.py diff --git a/src/ipy/IronPython/Modules/unicodedata/license.txt b/src/core/IronPython/Modules/unicodedata/license.txt similarity index 100% rename from src/ipy/IronPython/Modules/unicodedata/license.txt rename to src/core/IronPython/Modules/unicodedata/license.txt diff --git a/src/ipy/IronPython/Properties/AssemblyInfo.cs b/src/core/IronPython/Properties/AssemblyInfo.cs similarity index 100% rename from src/ipy/IronPython/Properties/AssemblyInfo.cs rename to src/core/IronPython/Properties/AssemblyInfo.cs diff --git a/src/ipy/IronPython/Resources.Designer.cs b/src/core/IronPython/Resources.Designer.cs similarity index 100% rename from src/ipy/IronPython/Resources.Designer.cs rename to src/core/IronPython/Resources.Designer.cs diff --git a/src/ipy/IronPython/Resources.resx b/src/core/IronPython/Resources.resx similarity index 100% rename from src/ipy/IronPython/Resources.resx rename to src/core/IronPython/Resources.resx diff --git a/src/ipy/IronPython/Runtime/ArrayData.cs b/src/core/IronPython/Runtime/ArrayData.cs similarity index 100% rename from src/ipy/IronPython/Runtime/ArrayData.cs rename to src/core/IronPython/Runtime/ArrayData.cs diff --git a/src/ipy/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs b/src/core/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs rename to src/core/IronPython/Runtime/Binding/BinaryRetTypeBinder.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs b/src/core/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs rename to src/core/IronPython/Runtime/Binding/BinaryRetTypeBinder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/Binders.cs b/src/core/IronPython/Runtime/Binding/Binders.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/Binders.cs rename to src/core/IronPython/Runtime/Binding/Binders.cs diff --git a/src/ipy/IronPython/Runtime/Binding/BindingHelpers.cs b/src/core/IronPython/Runtime/Binding/BindingHelpers.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/BindingHelpers.cs rename to src/core/IronPython/Runtime/Binding/BindingHelpers.cs diff --git a/src/ipy/IronPython/Runtime/Binding/BindingWarnings.cs b/src/core/IronPython/Runtime/Binding/BindingWarnings.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/BindingWarnings.cs rename to src/core/IronPython/Runtime/Binding/BindingWarnings.cs diff --git a/src/ipy/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs b/src/core/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs rename to src/core/IronPython/Runtime/Binding/CompatibilityInvokeBinder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/ConditionalBuilder.cs b/src/core/IronPython/Runtime/Binding/ConditionalBuilder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/ConditionalBuilder.cs rename to src/core/IronPython/Runtime/Binding/ConditionalBuilder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/ContextArgBuilder.cs b/src/core/IronPython/Runtime/Binding/ContextArgBuilder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/ContextArgBuilder.cs rename to src/core/IronPython/Runtime/Binding/ContextArgBuilder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/ConversionBinder.cs b/src/core/IronPython/Runtime/Binding/ConversionBinder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/ConversionBinder.cs rename to src/core/IronPython/Runtime/Binding/ConversionBinder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/CreateFallbackBinder.cs b/src/core/IronPython/Runtime/Binding/CreateFallbackBinder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/CreateFallbackBinder.cs rename to src/core/IronPython/Runtime/Binding/CreateFallbackBinder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/FastBindResult.cs b/src/core/IronPython/Runtime/Binding/FastBindResult.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/FastBindResult.cs rename to src/core/IronPython/Runtime/Binding/FastBindResult.cs diff --git a/src/ipy/IronPython/Runtime/Binding/FastGetBase.cs b/src/core/IronPython/Runtime/Binding/FastGetBase.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/FastGetBase.cs rename to src/core/IronPython/Runtime/Binding/FastGetBase.cs diff --git a/src/ipy/IronPython/Runtime/Binding/FastSetBase.cs b/src/core/IronPython/Runtime/Binding/FastSetBase.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/FastSetBase.cs rename to src/core/IronPython/Runtime/Binding/FastSetBase.cs diff --git a/src/ipy/IronPython/Runtime/Binding/IComConvertible.cs b/src/core/IronPython/Runtime/Binding/IComConvertible.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/IComConvertible.cs rename to src/core/IronPython/Runtime/Binding/IComConvertible.cs diff --git a/src/ipy/IronPython/Runtime/Binding/IFastGettable.cs b/src/core/IronPython/Runtime/Binding/IFastGettable.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/IFastGettable.cs rename to src/core/IronPython/Runtime/Binding/IFastGettable.cs diff --git a/src/ipy/IronPython/Runtime/Binding/IFastInvokable.cs b/src/core/IronPython/Runtime/Binding/IFastInvokable.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/IFastInvokable.cs rename to src/core/IronPython/Runtime/Binding/IFastInvokable.cs diff --git a/src/ipy/IronPython/Runtime/Binding/IFastSettable.cs b/src/core/IronPython/Runtime/Binding/IFastSettable.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/IFastSettable.cs rename to src/core/IronPython/Runtime/Binding/IFastSettable.cs diff --git a/src/ipy/IronPython/Runtime/Binding/IPythonConvertible.cs b/src/core/IronPython/Runtime/Binding/IPythonConvertible.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/IPythonConvertible.cs rename to src/core/IronPython/Runtime/Binding/IPythonConvertible.cs diff --git a/src/ipy/IronPython/Runtime/Binding/IPythonExpandable.cs b/src/core/IronPython/Runtime/Binding/IPythonExpandable.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/IPythonExpandable.cs rename to src/core/IronPython/Runtime/Binding/IPythonExpandable.cs diff --git a/src/ipy/IronPython/Runtime/Binding/IPythonGetable.cs b/src/core/IronPython/Runtime/Binding/IPythonGetable.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/IPythonGetable.cs rename to src/core/IronPython/Runtime/Binding/IPythonGetable.cs diff --git a/src/ipy/IronPython/Runtime/Binding/IPythonInvokable.cs b/src/core/IronPython/Runtime/Binding/IPythonInvokable.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/IPythonInvokable.cs rename to src/core/IronPython/Runtime/Binding/IPythonInvokable.cs diff --git a/src/ipy/IronPython/Runtime/Binding/IPythonOperable.cs b/src/core/IronPython/Runtime/Binding/IPythonOperable.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/IPythonOperable.cs rename to src/core/IronPython/Runtime/Binding/IPythonOperable.cs diff --git a/src/ipy/IronPython/Runtime/Binding/IPythonSite.cs b/src/core/IronPython/Runtime/Binding/IPythonSite.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/IPythonSite.cs rename to src/core/IronPython/Runtime/Binding/IPythonSite.cs diff --git a/src/ipy/IronPython/Runtime/Binding/MetaBuiltinFunction.cs b/src/core/IronPython/Runtime/Binding/MetaBuiltinFunction.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/MetaBuiltinFunction.cs rename to src/core/IronPython/Runtime/Binding/MetaBuiltinFunction.cs diff --git a/src/ipy/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs b/src/core/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs rename to src/core/IronPython/Runtime/Binding/MetaBuiltinMethodDescriptor.cs diff --git a/src/ipy/IronPython/Runtime/Binding/MetaMethod.cs b/src/core/IronPython/Runtime/Binding/MetaMethod.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/MetaMethod.cs rename to src/core/IronPython/Runtime/Binding/MetaMethod.cs diff --git a/src/ipy/IronPython/Runtime/Binding/MetaPythonFunction.cs b/src/core/IronPython/Runtime/Binding/MetaPythonFunction.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/MetaPythonFunction.cs rename to src/core/IronPython/Runtime/Binding/MetaPythonFunction.cs diff --git a/src/ipy/IronPython/Runtime/Binding/MetaPythonObject.cs b/src/core/IronPython/Runtime/Binding/MetaPythonObject.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/MetaPythonObject.cs rename to src/core/IronPython/Runtime/Binding/MetaPythonObject.cs diff --git a/src/ipy/IronPython/Runtime/Binding/MetaPythonType.Calls.cs b/src/core/IronPython/Runtime/Binding/MetaPythonType.Calls.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/MetaPythonType.Calls.cs rename to src/core/IronPython/Runtime/Binding/MetaPythonType.Calls.cs diff --git a/src/ipy/IronPython/Runtime/Binding/MetaPythonType.Members.cs b/src/core/IronPython/Runtime/Binding/MetaPythonType.Members.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/MetaPythonType.Members.cs rename to src/core/IronPython/Runtime/Binding/MetaPythonType.Members.cs diff --git a/src/ipy/IronPython/Runtime/Binding/MetaPythonType.cs b/src/core/IronPython/Runtime/Binding/MetaPythonType.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/MetaPythonType.cs rename to src/core/IronPython/Runtime/Binding/MetaPythonType.cs diff --git a/src/ipy/IronPython/Runtime/Binding/MetaUserObject.Members.cs b/src/core/IronPython/Runtime/Binding/MetaUserObject.Members.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/MetaUserObject.Members.cs rename to src/core/IronPython/Runtime/Binding/MetaUserObject.Members.cs diff --git a/src/ipy/IronPython/Runtime/Binding/MetaUserObject.cs b/src/core/IronPython/Runtime/Binding/MetaUserObject.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/MetaUserObject.cs rename to src/core/IronPython/Runtime/Binding/MetaUserObject.cs diff --git a/src/ipy/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs b/src/core/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs rename to src/core/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/PythonBinder.Create.cs b/src/core/IronPython/Runtime/Binding/PythonBinder.Create.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/PythonBinder.Create.cs rename to src/core/IronPython/Runtime/Binding/PythonBinder.Create.cs diff --git a/src/ipy/IronPython/Runtime/Binding/PythonBinder.cs b/src/core/IronPython/Runtime/Binding/PythonBinder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/PythonBinder.cs rename to src/core/IronPython/Runtime/Binding/PythonBinder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs b/src/core/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs rename to src/core/IronPython/Runtime/Binding/PythonDeleteIndexBinder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs b/src/core/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs rename to src/core/IronPython/Runtime/Binding/PythonDeleteMemberBinder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs b/src/core/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs rename to src/core/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/PythonExtensionBinder.cs b/src/core/IronPython/Runtime/Binding/PythonExtensionBinder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/PythonExtensionBinder.cs rename to src/core/IronPython/Runtime/Binding/PythonExtensionBinder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/PythonGetIndexBinder.cs b/src/core/IronPython/Runtime/Binding/PythonGetIndexBinder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/PythonGetIndexBinder.cs rename to src/core/IronPython/Runtime/Binding/PythonGetIndexBinder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/PythonGetMemberBinder.cs b/src/core/IronPython/Runtime/Binding/PythonGetMemberBinder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/PythonGetMemberBinder.cs rename to src/core/IronPython/Runtime/Binding/PythonGetMemberBinder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/PythonGetSliceBinder.cs b/src/core/IronPython/Runtime/Binding/PythonGetSliceBinder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/PythonGetSliceBinder.cs rename to src/core/IronPython/Runtime/Binding/PythonGetSliceBinder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/PythonIndexType.cs b/src/core/IronPython/Runtime/Binding/PythonIndexType.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/PythonIndexType.cs rename to src/core/IronPython/Runtime/Binding/PythonIndexType.cs diff --git a/src/ipy/IronPython/Runtime/Binding/PythonInvokeBinder.cs b/src/core/IronPython/Runtime/Binding/PythonInvokeBinder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/PythonInvokeBinder.cs rename to src/core/IronPython/Runtime/Binding/PythonInvokeBinder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/PythonOperationBinder.cs b/src/core/IronPython/Runtime/Binding/PythonOperationBinder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/PythonOperationBinder.cs rename to src/core/IronPython/Runtime/Binding/PythonOperationBinder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/PythonOperationKind.cs b/src/core/IronPython/Runtime/Binding/PythonOperationKind.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/PythonOperationKind.cs rename to src/core/IronPython/Runtime/Binding/PythonOperationKind.cs diff --git a/src/ipy/IronPython/Runtime/Binding/PythonOverloadResolver.cs b/src/core/IronPython/Runtime/Binding/PythonOverloadResolver.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/PythonOverloadResolver.cs rename to src/core/IronPython/Runtime/Binding/PythonOverloadResolver.cs diff --git a/src/ipy/IronPython/Runtime/Binding/PythonProtocol.Operations.cs b/src/core/IronPython/Runtime/Binding/PythonProtocol.Operations.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/PythonProtocol.Operations.cs rename to src/core/IronPython/Runtime/Binding/PythonProtocol.Operations.cs diff --git a/src/ipy/IronPython/Runtime/Binding/PythonProtocol.cs b/src/core/IronPython/Runtime/Binding/PythonProtocol.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/PythonProtocol.cs rename to src/core/IronPython/Runtime/Binding/PythonProtocol.cs diff --git a/src/ipy/IronPython/Runtime/Binding/PythonSetIndexBinder.cs b/src/core/IronPython/Runtime/Binding/PythonSetIndexBinder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/PythonSetIndexBinder.cs rename to src/core/IronPython/Runtime/Binding/PythonSetIndexBinder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/PythonSetMemberBinder.cs b/src/core/IronPython/Runtime/Binding/PythonSetMemberBinder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/PythonSetMemberBinder.cs rename to src/core/IronPython/Runtime/Binding/PythonSetMemberBinder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/PythonSetSliceBinder.cs b/src/core/IronPython/Runtime/Binding/PythonSetSliceBinder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/PythonSetSliceBinder.cs rename to src/core/IronPython/Runtime/Binding/PythonSetSliceBinder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs b/src/core/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs rename to src/core/IronPython/Runtime/Binding/PythonUnaryOperationBinder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs b/src/core/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs rename to src/core/IronPython/Runtime/Binding/SiteLocalStorageBuilder.cs diff --git a/src/ipy/IronPython/Runtime/Binding/SlotOrFunction.cs b/src/core/IronPython/Runtime/Binding/SlotOrFunction.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/SlotOrFunction.cs rename to src/core/IronPython/Runtime/Binding/SlotOrFunction.cs diff --git a/src/ipy/IronPython/Runtime/Binding/WarningInfo.cs b/src/core/IronPython/Runtime/Binding/WarningInfo.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Binding/WarningInfo.cs rename to src/core/IronPython/Runtime/Binding/WarningInfo.cs diff --git a/src/ipy/IronPython/Runtime/BufferProtocol.cs b/src/core/IronPython/Runtime/BufferProtocol.cs similarity index 100% rename from src/ipy/IronPython/Runtime/BufferProtocol.cs rename to src/core/IronPython/Runtime/BufferProtocol.cs diff --git a/src/ipy/IronPython/Runtime/BuiltinPythonModule.cs b/src/core/IronPython/Runtime/BuiltinPythonModule.cs similarity index 100% rename from src/ipy/IronPython/Runtime/BuiltinPythonModule.cs rename to src/core/IronPython/Runtime/BuiltinPythonModule.cs diff --git a/src/ipy/IronPython/Runtime/BuiltinsDictionaryStorage.cs b/src/core/IronPython/Runtime/BuiltinsDictionaryStorage.cs similarity index 100% rename from src/ipy/IronPython/Runtime/BuiltinsDictionaryStorage.cs rename to src/core/IronPython/Runtime/BuiltinsDictionaryStorage.cs diff --git a/src/ipy/IronPython/Runtime/ByteArray.cs b/src/core/IronPython/Runtime/ByteArray.cs similarity index 100% rename from src/ipy/IronPython/Runtime/ByteArray.cs rename to src/core/IronPython/Runtime/ByteArray.cs diff --git a/src/ipy/IronPython/Runtime/ByteArrayIterator.cs b/src/core/IronPython/Runtime/ByteArrayIterator.cs similarity index 100% rename from src/ipy/IronPython/Runtime/ByteArrayIterator.cs rename to src/core/IronPython/Runtime/ByteArrayIterator.cs diff --git a/src/ipy/IronPython/Runtime/Bytes.cs b/src/core/IronPython/Runtime/Bytes.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Bytes.cs rename to src/core/IronPython/Runtime/Bytes.cs diff --git a/src/ipy/IronPython/Runtime/BytesIterator.cs b/src/core/IronPython/Runtime/BytesIterator.cs similarity index 100% rename from src/ipy/IronPython/Runtime/BytesIterator.cs rename to src/core/IronPython/Runtime/BytesIterator.cs diff --git a/src/ipy/IronPython/Runtime/BytesLikeAttribute.cs b/src/core/IronPython/Runtime/BytesLikeAttribute.cs similarity index 100% rename from src/ipy/IronPython/Runtime/BytesLikeAttribute.cs rename to src/core/IronPython/Runtime/BytesLikeAttribute.cs diff --git a/src/ipy/IronPython/Runtime/ClassMethodAttribute.cs b/src/core/IronPython/Runtime/ClassMethodAttribute.cs similarity index 100% rename from src/ipy/IronPython/Runtime/ClassMethodAttribute.cs rename to src/core/IronPython/Runtime/ClassMethodAttribute.cs diff --git a/src/ipy/IronPython/Runtime/ClassMethodDescriptor.cs b/src/core/IronPython/Runtime/ClassMethodDescriptor.cs similarity index 100% rename from src/ipy/IronPython/Runtime/ClassMethodDescriptor.cs rename to src/core/IronPython/Runtime/ClassMethodDescriptor.cs diff --git a/src/ipy/IronPython/Runtime/ClrModule.cs b/src/core/IronPython/Runtime/ClrModule.cs similarity index 100% rename from src/ipy/IronPython/Runtime/ClrModule.cs rename to src/core/IronPython/Runtime/ClrModule.cs diff --git a/src/ipy/IronPython/Runtime/CodeContext.cs b/src/core/IronPython/Runtime/CodeContext.cs similarity index 100% rename from src/ipy/IronPython/Runtime/CodeContext.cs rename to src/core/IronPython/Runtime/CodeContext.cs diff --git a/src/ipy/IronPython/Runtime/CollectionDebugView.cs b/src/core/IronPython/Runtime/CollectionDebugView.cs similarity index 100% rename from src/ipy/IronPython/Runtime/CollectionDebugView.cs rename to src/core/IronPython/Runtime/CollectionDebugView.cs diff --git a/src/ipy/IronPython/Runtime/CommonDictionaryStorage.cs b/src/core/IronPython/Runtime/CommonDictionaryStorage.cs similarity index 100% rename from src/ipy/IronPython/Runtime/CommonDictionaryStorage.cs rename to src/core/IronPython/Runtime/CommonDictionaryStorage.cs diff --git a/src/ipy/IronPython/Runtime/CompareUtil.cs b/src/core/IronPython/Runtime/CompareUtil.cs similarity index 100% rename from src/ipy/IronPython/Runtime/CompareUtil.cs rename to src/core/IronPython/Runtime/CompareUtil.cs diff --git a/src/ipy/IronPython/Runtime/CompileFlags.cs b/src/core/IronPython/Runtime/CompileFlags.cs similarity index 100% rename from src/ipy/IronPython/Runtime/CompileFlags.cs rename to src/core/IronPython/Runtime/CompileFlags.cs diff --git a/src/ipy/IronPython/Runtime/CompiledLoader.cs b/src/core/IronPython/Runtime/CompiledLoader.cs similarity index 100% rename from src/ipy/IronPython/Runtime/CompiledLoader.cs rename to src/core/IronPython/Runtime/CompiledLoader.cs diff --git a/src/ipy/IronPython/Runtime/ConstantDictionaryStorage.cs b/src/core/IronPython/Runtime/ConstantDictionaryStorage.cs similarity index 100% rename from src/ipy/IronPython/Runtime/ConstantDictionaryStorage.cs rename to src/core/IronPython/Runtime/ConstantDictionaryStorage.cs diff --git a/src/ipy/IronPython/Runtime/ConversionWrappers.cs b/src/core/IronPython/Runtime/ConversionWrappers.cs similarity index 100% rename from src/ipy/IronPython/Runtime/ConversionWrappers.cs rename to src/core/IronPython/Runtime/ConversionWrappers.cs diff --git a/src/ipy/IronPython/Runtime/Converter.cs b/src/core/IronPython/Runtime/Converter.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Converter.cs rename to src/core/IronPython/Runtime/Converter.cs diff --git a/src/ipy/IronPython/Runtime/CustomDictionaryStorage.cs b/src/core/IronPython/Runtime/CustomDictionaryStorage.cs similarity index 100% rename from src/ipy/IronPython/Runtime/CustomDictionaryStorage.cs rename to src/core/IronPython/Runtime/CustomDictionaryStorage.cs diff --git a/src/ipy/IronPython/Runtime/DebuggerDictionaryStorage.cs b/src/core/IronPython/Runtime/DebuggerDictionaryStorage.cs similarity index 100% rename from src/ipy/IronPython/Runtime/DebuggerDictionaryStorage.cs rename to src/core/IronPython/Runtime/DebuggerDictionaryStorage.cs diff --git a/src/ipy/IronPython/Runtime/DefaultContext.cs b/src/core/IronPython/Runtime/DefaultContext.cs similarity index 100% rename from src/ipy/IronPython/Runtime/DefaultContext.cs rename to src/core/IronPython/Runtime/DefaultContext.cs diff --git a/src/ipy/IronPython/Runtime/Descriptors.cs b/src/core/IronPython/Runtime/Descriptors.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Descriptors.cs rename to src/core/IronPython/Runtime/Descriptors.cs diff --git a/src/ipy/IronPython/Runtime/DictionaryOps.cs b/src/core/IronPython/Runtime/DictionaryOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/DictionaryOps.cs rename to src/core/IronPython/Runtime/DictionaryOps.cs diff --git a/src/ipy/IronPython/Runtime/DictionaryStorage.cs b/src/core/IronPython/Runtime/DictionaryStorage.cs similarity index 100% rename from src/ipy/IronPython/Runtime/DictionaryStorage.cs rename to src/core/IronPython/Runtime/DictionaryStorage.cs diff --git a/src/ipy/IronPython/Runtime/DictionaryTypeInfoAttribute.cs b/src/core/IronPython/Runtime/DictionaryTypeInfoAttribute.cs similarity index 100% rename from src/ipy/IronPython/Runtime/DictionaryTypeInfoAttribute.cs rename to src/core/IronPython/Runtime/DictionaryTypeInfoAttribute.cs diff --git a/src/ipy/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs b/src/core/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs similarity index 100% rename from src/ipy/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs rename to src/core/IronPython/Runtime/DontMapGetMemberNamesToDirAttribute.cs diff --git a/src/ipy/IronPython/Runtime/DontMapICollectionToLenAttribute.cs b/src/core/IronPython/Runtime/DontMapICollectionToLenAttribute.cs similarity index 100% rename from src/ipy/IronPython/Runtime/DontMapICollectionToLenAttribute.cs rename to src/core/IronPython/Runtime/DontMapICollectionToLenAttribute.cs diff --git a/src/ipy/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs b/src/core/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs similarity index 100% rename from src/ipy/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs rename to src/core/IronPython/Runtime/DontMapIDisposableToContextManagerAttribute.cs diff --git a/src/ipy/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs b/src/core/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs similarity index 100% rename from src/ipy/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs rename to src/core/IronPython/Runtime/DontMapIEnumerableToContainsAttribute.cs diff --git a/src/ipy/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs b/src/core/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs similarity index 100% rename from src/ipy/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs rename to src/core/IronPython/Runtime/DontMapIEnumerableToIterAttribute.cs diff --git a/src/ipy/IronPython/Runtime/EmptyDictionaryStorage.cs b/src/core/IronPython/Runtime/EmptyDictionaryStorage.cs similarity index 100% rename from src/ipy/IronPython/Runtime/EmptyDictionaryStorage.cs rename to src/core/IronPython/Runtime/EmptyDictionaryStorage.cs diff --git a/src/ipy/IronPython/Runtime/Enumerate.cs b/src/core/IronPython/Runtime/Enumerate.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Enumerate.cs rename to src/core/IronPython/Runtime/Enumerate.cs diff --git a/src/ipy/IronPython/Runtime/ErrorCodes.cs b/src/core/IronPython/Runtime/ErrorCodes.cs similarity index 100% rename from src/ipy/IronPython/Runtime/ErrorCodes.cs rename to src/core/IronPython/Runtime/ErrorCodes.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/AssertionException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/AssertionException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/AssertionException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/AssertionException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/AttributeErrorException.cs b/src/core/IronPython/Runtime/Exceptions/AttributeErrorException.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/AttributeErrorException.cs rename to src/core/IronPython/Runtime/Exceptions/AttributeErrorException.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/BlockingIOException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/BrokenPipeException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/BufferException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/BufferException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/BufferException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/BufferException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/BytesWarningException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/ChildProcessException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/ConnectionAbortedException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/ConnectionException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/ConnectionRefusedException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/ConnectionResetException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/DeprecationWarningException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/FileExistsException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/FloatingPointException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/FutureWarningException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/GeneratorExitException.cs b/src/core/IronPython/Runtime/Exceptions/GeneratorExitException.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/GeneratorExitException.cs rename to src/core/IronPython/Runtime/Exceptions/GeneratorExitException.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/ImportException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/ImportException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/ImportException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/ImportException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/ImportWarningException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/IndentationException.cs b/src/core/IronPython/Runtime/Exceptions/IndentationException.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/IndentationException.cs rename to src/core/IronPython/Runtime/Exceptions/IndentationException.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/InterruptedException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/IsADirectoryException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/LookupException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/LookupException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/LookupException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/LookupException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs b/src/core/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs rename to src/core/IronPython/Runtime/Exceptions/ModuleNotFoundException.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/NotADirectoryException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/OSException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/OSException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/OSException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/OSException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/PendingDeprecationWarningException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/ProcessLookupException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/PythonException.cs b/src/core/IronPython/Runtime/Exceptions/PythonException.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/PythonException.cs rename to src/core/IronPython/Runtime/Exceptions/PythonException.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs b/src/core/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs rename to src/core/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs b/src/core/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/PythonExceptions.cs b/src/core/IronPython/Runtime/Exceptions/PythonExceptions.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/PythonExceptions.cs rename to src/core/IronPython/Runtime/Exceptions/PythonExceptions.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/RecursionException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/RecursionException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/RecursionException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/RecursionException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/ReferenceException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/ResourceWarningException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/RuntimeException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/RuntimeWarningException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/StopAsyncIterationException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/StopIterationException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/SyntaxWarningException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/SystemExitException.cs b/src/core/IronPython/Runtime/Exceptions/SystemExitException.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/SystemExitException.cs rename to src/core/IronPython/Runtime/Exceptions/SystemExitException.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/TabException.cs b/src/core/IronPython/Runtime/Exceptions/TabException.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/TabException.cs rename to src/core/IronPython/Runtime/Exceptions/TabException.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/TraceBack.cs b/src/core/IronPython/Runtime/Exceptions/TraceBack.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/TraceBack.cs rename to src/core/IronPython/Runtime/Exceptions/TraceBack.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/TypeErrorException.cs b/src/core/IronPython/Runtime/Exceptions/TypeErrorException.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/TypeErrorException.cs rename to src/core/IronPython/Runtime/Exceptions/TypeErrorException.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/UnicodeException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/UnicodeTranslateException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/UnicodeWarningException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs b/src/core/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs rename to src/core/IronPython/Runtime/Exceptions/UserWarningException.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Exceptions/ValueErrorException.cs b/src/core/IronPython/Runtime/Exceptions/ValueErrorException.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Exceptions/ValueErrorException.cs rename to src/core/IronPython/Runtime/Exceptions/ValueErrorException.cs diff --git a/src/ipy/IronPython/Runtime/ExtensionMethodSet.cs b/src/core/IronPython/Runtime/ExtensionMethodSet.cs similarity index 100% rename from src/ipy/IronPython/Runtime/ExtensionMethodSet.cs rename to src/core/IronPython/Runtime/ExtensionMethodSet.cs diff --git a/src/ipy/IronPython/Runtime/Filter.cs b/src/core/IronPython/Runtime/Filter.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Filter.cs rename to src/core/IronPython/Runtime/Filter.cs diff --git a/src/ipy/IronPython/Runtime/FormattingHelper.cs b/src/core/IronPython/Runtime/FormattingHelper.cs similarity index 100% rename from src/ipy/IronPython/Runtime/FormattingHelper.cs rename to src/core/IronPython/Runtime/FormattingHelper.cs diff --git a/src/ipy/IronPython/Runtime/FunctionAttributes.cs b/src/core/IronPython/Runtime/FunctionAttributes.cs similarity index 100% rename from src/ipy/IronPython/Runtime/FunctionAttributes.cs rename to src/core/IronPython/Runtime/FunctionAttributes.cs diff --git a/src/ipy/IronPython/Runtime/FunctionCode.cs b/src/core/IronPython/Runtime/FunctionCode.cs similarity index 100% rename from src/ipy/IronPython/Runtime/FunctionCode.cs rename to src/core/IronPython/Runtime/FunctionCode.cs diff --git a/src/ipy/IronPython/Runtime/Generator.cs b/src/core/IronPython/Runtime/Generator.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Generator.cs rename to src/core/IronPython/Runtime/Generator.cs diff --git a/src/ipy/IronPython/Runtime/GlobalDictionaryStorage.cs b/src/core/IronPython/Runtime/GlobalDictionaryStorage.cs similarity index 100% rename from src/ipy/IronPython/Runtime/GlobalDictionaryStorage.cs rename to src/core/IronPython/Runtime/GlobalDictionaryStorage.cs diff --git a/src/ipy/IronPython/Runtime/IParameterSequence.cs b/src/core/IronPython/Runtime/IParameterSequence.cs similarity index 100% rename from src/ipy/IronPython/Runtime/IParameterSequence.cs rename to src/core/IronPython/Runtime/IParameterSequence.cs diff --git a/src/ipy/IronPython/Runtime/Implementation.cs b/src/core/IronPython/Runtime/Implementation.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Implementation.cs rename to src/core/IronPython/Runtime/Implementation.cs diff --git a/src/ipy/IronPython/Runtime/Importer.cs b/src/core/IronPython/Runtime/Importer.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Importer.cs rename to src/core/IronPython/Runtime/Importer.cs diff --git a/src/ipy/IronPython/Runtime/Index.cs b/src/core/IronPython/Runtime/Index.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Index.cs rename to src/core/IronPython/Runtime/Index.cs diff --git a/src/ipy/IronPython/Runtime/InstancedModuleDictionaryStorage.cs b/src/core/IronPython/Runtime/InstancedModuleDictionaryStorage.cs similarity index 100% rename from src/ipy/IronPython/Runtime/InstancedModuleDictionaryStorage.cs rename to src/core/IronPython/Runtime/InstancedModuleDictionaryStorage.cs diff --git a/src/ipy/IronPython/Runtime/Interfaces.cs b/src/core/IronPython/Runtime/Interfaces.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Interfaces.cs rename to src/core/IronPython/Runtime/Interfaces.cs diff --git a/src/ipy/IronPython/Runtime/KwCallInfo.cs b/src/core/IronPython/Runtime/KwCallInfo.cs similarity index 100% rename from src/ipy/IronPython/Runtime/KwCallInfo.cs rename to src/core/IronPython/Runtime/KwCallInfo.cs diff --git a/src/ipy/IronPython/Runtime/LiteralParser.cs b/src/core/IronPython/Runtime/LiteralParser.cs similarity index 100% rename from src/ipy/IronPython/Runtime/LiteralParser.cs rename to src/core/IronPython/Runtime/LiteralParser.cs diff --git a/src/ipy/IronPython/Runtime/Map.cs b/src/core/IronPython/Runtime/Map.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Map.cs rename to src/core/IronPython/Runtime/Map.cs diff --git a/src/ipy/IronPython/Runtime/MaybeNotImplementedAttribute.cs b/src/core/IronPython/Runtime/MaybeNotImplementedAttribute.cs similarity index 100% rename from src/ipy/IronPython/Runtime/MaybeNotImplementedAttribute.cs rename to src/core/IronPython/Runtime/MaybeNotImplementedAttribute.cs diff --git a/src/ipy/IronPython/Runtime/MemoryStreamContentProvider.cs b/src/core/IronPython/Runtime/MemoryStreamContentProvider.cs similarity index 100% rename from src/ipy/IronPython/Runtime/MemoryStreamContentProvider.cs rename to src/core/IronPython/Runtime/MemoryStreamContentProvider.cs diff --git a/src/ipy/IronPython/Runtime/MemoryView.cs b/src/core/IronPython/Runtime/MemoryView.cs similarity index 100% rename from src/ipy/IronPython/Runtime/MemoryView.cs rename to src/core/IronPython/Runtime/MemoryView.cs diff --git a/src/ipy/IronPython/Runtime/Method.Generated.cs b/src/core/IronPython/Runtime/Method.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Method.Generated.cs rename to src/core/IronPython/Runtime/Method.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Method.cs b/src/core/IronPython/Runtime/Method.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Method.cs rename to src/core/IronPython/Runtime/Method.cs diff --git a/src/ipy/IronPython/Runtime/MissingParameter.cs b/src/core/IronPython/Runtime/MissingParameter.cs similarity index 100% rename from src/ipy/IronPython/Runtime/MissingParameter.cs rename to src/core/IronPython/Runtime/MissingParameter.cs diff --git a/src/ipy/IronPython/Runtime/ModuleContext.cs b/src/core/IronPython/Runtime/ModuleContext.cs similarity index 100% rename from src/ipy/IronPython/Runtime/ModuleContext.cs rename to src/core/IronPython/Runtime/ModuleContext.cs diff --git a/src/ipy/IronPython/Runtime/ModuleDictionaryStorage.cs b/src/core/IronPython/Runtime/ModuleDictionaryStorage.cs similarity index 100% rename from src/ipy/IronPython/Runtime/ModuleDictionaryStorage.cs rename to src/core/IronPython/Runtime/ModuleDictionaryStorage.cs diff --git a/src/ipy/IronPython/Runtime/ModuleGlobalCache.cs b/src/core/IronPython/Runtime/ModuleGlobalCache.cs similarity index 100% rename from src/ipy/IronPython/Runtime/ModuleGlobalCache.cs rename to src/core/IronPython/Runtime/ModuleGlobalCache.cs diff --git a/src/ipy/IronPython/Runtime/ModuleLoader.cs b/src/core/IronPython/Runtime/ModuleLoader.cs similarity index 100% rename from src/ipy/IronPython/Runtime/ModuleLoader.cs rename to src/core/IronPython/Runtime/ModuleLoader.cs diff --git a/src/ipy/IronPython/Runtime/ModuleOptions.cs b/src/core/IronPython/Runtime/ModuleOptions.cs similarity index 100% rename from src/ipy/IronPython/Runtime/ModuleOptions.cs rename to src/core/IronPython/Runtime/ModuleOptions.cs diff --git a/src/ipy/IronPython/Runtime/NameType.cs b/src/core/IronPython/Runtime/NameType.cs similarity index 100% rename from src/ipy/IronPython/Runtime/NameType.cs rename to src/core/IronPython/Runtime/NameType.cs diff --git a/src/ipy/IronPython/Runtime/NewStringFormatter.cs b/src/core/IronPython/Runtime/NewStringFormatter.cs similarity index 100% rename from src/ipy/IronPython/Runtime/NewStringFormatter.cs rename to src/core/IronPython/Runtime/NewStringFormatter.cs diff --git a/src/ipy/IronPython/Runtime/ObjectAttributesAdapter.cs b/src/core/IronPython/Runtime/ObjectAttributesAdapter.cs similarity index 100% rename from src/ipy/IronPython/Runtime/ObjectAttributesAdapter.cs rename to src/core/IronPython/Runtime/ObjectAttributesAdapter.cs diff --git a/src/ipy/IronPython/Runtime/ObjectDebugView.cs b/src/core/IronPython/Runtime/ObjectDebugView.cs similarity index 100% rename from src/ipy/IronPython/Runtime/ObjectDebugView.cs rename to src/core/IronPython/Runtime/ObjectDebugView.cs diff --git a/src/ipy/IronPython/Runtime/Operations/ArrayOps.cs b/src/core/IronPython/Runtime/Operations/ArrayOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/ArrayOps.cs rename to src/core/IronPython/Runtime/Operations/ArrayOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/BigIntegerOps.cs b/src/core/IronPython/Runtime/Operations/BigIntegerOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/BigIntegerOps.cs rename to src/core/IronPython/Runtime/Operations/BigIntegerOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/BoolOps.cs b/src/core/IronPython/Runtime/Operations/BoolOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/BoolOps.cs rename to src/core/IronPython/Runtime/Operations/BoolOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/ByteOps.cs b/src/core/IronPython/Runtime/Operations/ByteOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/ByteOps.cs rename to src/core/IronPython/Runtime/Operations/ByteOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/CharOps.cs b/src/core/IronPython/Runtime/Operations/CharOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/CharOps.cs rename to src/core/IronPython/Runtime/Operations/CharOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/ComOps.cs b/src/core/IronPython/Runtime/Operations/ComOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/ComOps.cs rename to src/core/IronPython/Runtime/Operations/ComOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/ComplexOps.cs b/src/core/IronPython/Runtime/Operations/ComplexOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/ComplexOps.cs rename to src/core/IronPython/Runtime/Operations/ComplexOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs b/src/core/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs rename to src/core/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs diff --git a/src/ipy/IronPython/Runtime/Operations/DBNullOps.cs b/src/core/IronPython/Runtime/Operations/DBNullOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/DBNullOps.cs rename to src/core/IronPython/Runtime/Operations/DBNullOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/DateTimeOps.cs b/src/core/IronPython/Runtime/Operations/DateTimeOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/DateTimeOps.cs rename to src/core/IronPython/Runtime/Operations/DateTimeOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/DecimalOps.cs b/src/core/IronPython/Runtime/Operations/DecimalOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/DecimalOps.cs rename to src/core/IronPython/Runtime/Operations/DecimalOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/DelegateOps.cs b/src/core/IronPython/Runtime/Operations/DelegateOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/DelegateOps.cs rename to src/core/IronPython/Runtime/Operations/DelegateOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/DictionaryOfTOps.cs b/src/core/IronPython/Runtime/Operations/DictionaryOfTOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/DictionaryOfTOps.cs rename to src/core/IronPython/Runtime/Operations/DictionaryOfTOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/EnumOps.cs b/src/core/IronPython/Runtime/Operations/EnumOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/EnumOps.cs rename to src/core/IronPython/Runtime/Operations/EnumOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/FloatOps.Generated.cs b/src/core/IronPython/Runtime/Operations/FloatOps.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/FloatOps.Generated.cs rename to src/core/IronPython/Runtime/Operations/FloatOps.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Operations/FloatOps.cs b/src/core/IronPython/Runtime/Operations/FloatOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/FloatOps.cs rename to src/core/IronPython/Runtime/Operations/FloatOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/IListOfByteOps.cs b/src/core/IronPython/Runtime/Operations/IListOfByteOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/IListOfByteOps.cs rename to src/core/IronPython/Runtime/Operations/IListOfByteOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/InstanceOps.cs b/src/core/IronPython/Runtime/Operations/InstanceOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/InstanceOps.cs rename to src/core/IronPython/Runtime/Operations/InstanceOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/IntOps.Generated.cs b/src/core/IronPython/Runtime/Operations/IntOps.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/IntOps.Generated.cs rename to src/core/IronPython/Runtime/Operations/IntOps.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Operations/IntOps.cs b/src/core/IronPython/Runtime/Operations/IntOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/IntOps.cs rename to src/core/IronPython/Runtime/Operations/IntOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/IntPtrOps.cs b/src/core/IronPython/Runtime/Operations/IntPtrOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/IntPtrOps.cs rename to src/core/IronPython/Runtime/Operations/IntPtrOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/ListOfTOps.cs b/src/core/IronPython/Runtime/Operations/ListOfTOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/ListOfTOps.cs rename to src/core/IronPython/Runtime/Operations/ListOfTOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/MarshalOps.cs b/src/core/IronPython/Runtime/Operations/MarshalOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/MarshalOps.cs rename to src/core/IronPython/Runtime/Operations/MarshalOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/NamespaceTrackerOps.cs b/src/core/IronPython/Runtime/Operations/NamespaceTrackerOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/NamespaceTrackerOps.cs rename to src/core/IronPython/Runtime/Operations/NamespaceTrackerOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/ObjectOps.cs b/src/core/IronPython/Runtime/Operations/ObjectOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/ObjectOps.cs rename to src/core/IronPython/Runtime/Operations/ObjectOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/PythonCalls.cs b/src/core/IronPython/Runtime/Operations/PythonCalls.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/PythonCalls.cs rename to src/core/IronPython/Runtime/Operations/PythonCalls.cs diff --git a/src/ipy/IronPython/Runtime/Operations/PythonOps.Generated.cs b/src/core/IronPython/Runtime/Operations/PythonOps.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/PythonOps.Generated.cs rename to src/core/IronPython/Runtime/Operations/PythonOps.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Operations/PythonOps.cs b/src/core/IronPython/Runtime/Operations/PythonOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/PythonOps.cs rename to src/core/IronPython/Runtime/Operations/PythonOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/PythonTypeOps.cs b/src/core/IronPython/Runtime/Operations/PythonTypeOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/PythonTypeOps.cs rename to src/core/IronPython/Runtime/Operations/PythonTypeOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/StringOps.Generated.cs b/src/core/IronPython/Runtime/Operations/StringOps.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/StringOps.Generated.cs rename to src/core/IronPython/Runtime/Operations/StringOps.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Operations/StringOps.cs b/src/core/IronPython/Runtime/Operations/StringOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/StringOps.cs rename to src/core/IronPython/Runtime/Operations/StringOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/TypeGroupOps.cs b/src/core/IronPython/Runtime/Operations/TypeGroupOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/TypeGroupOps.cs rename to src/core/IronPython/Runtime/Operations/TypeGroupOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/TypeTrackerOps.cs b/src/core/IronPython/Runtime/Operations/TypeTrackerOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/TypeTrackerOps.cs rename to src/core/IronPython/Runtime/Operations/TypeTrackerOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/UIntPtrOps.cs b/src/core/IronPython/Runtime/Operations/UIntPtrOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/UIntPtrOps.cs rename to src/core/IronPython/Runtime/Operations/UIntPtrOps.cs diff --git a/src/ipy/IronPython/Runtime/Operations/UserTypeOps.cs b/src/core/IronPython/Runtime/Operations/UserTypeOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Operations/UserTypeOps.cs rename to src/core/IronPython/Runtime/Operations/UserTypeOps.cs diff --git a/src/ipy/IronPython/Runtime/OutputWriter.cs b/src/core/IronPython/Runtime/OutputWriter.cs similarity index 100% rename from src/ipy/IronPython/Runtime/OutputWriter.cs rename to src/core/IronPython/Runtime/OutputWriter.cs diff --git a/src/ipy/IronPython/Runtime/PlatformsAttribute.cs b/src/core/IronPython/Runtime/PlatformsAttribute.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PlatformsAttribute.cs rename to src/core/IronPython/Runtime/PlatformsAttribute.cs diff --git a/src/ipy/IronPython/Runtime/Profiler.cs b/src/core/IronPython/Runtime/Profiler.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Profiler.cs rename to src/core/IronPython/Runtime/Profiler.cs diff --git a/src/ipy/IronPython/Runtime/PythonContext.Generated.cs b/src/core/IronPython/Runtime/PythonContext.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonContext.Generated.cs rename to src/core/IronPython/Runtime/PythonContext.Generated.cs diff --git a/src/ipy/IronPython/Runtime/PythonContext.cs b/src/core/IronPython/Runtime/PythonContext.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonContext.cs rename to src/core/IronPython/Runtime/PythonContext.cs diff --git a/src/ipy/IronPython/Runtime/PythonDictionary.cs b/src/core/IronPython/Runtime/PythonDictionary.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonDictionary.cs rename to src/core/IronPython/Runtime/PythonDictionary.cs diff --git a/src/ipy/IronPython/Runtime/PythonDocumentationProvider.cs b/src/core/IronPython/Runtime/PythonDocumentationProvider.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonDocumentationProvider.cs rename to src/core/IronPython/Runtime/PythonDocumentationProvider.cs diff --git a/src/ipy/IronPython/Runtime/PythonDynamicStackFrame.cs b/src/core/IronPython/Runtime/PythonDynamicStackFrame.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonDynamicStackFrame.cs rename to src/core/IronPython/Runtime/PythonDynamicStackFrame.cs diff --git a/src/ipy/IronPython/Runtime/PythonEncoding.cs b/src/core/IronPython/Runtime/PythonEncoding.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonEncoding.cs rename to src/core/IronPython/Runtime/PythonEncoding.cs diff --git a/src/ipy/IronPython/Runtime/PythonFileManager.cs b/src/core/IronPython/Runtime/PythonFileManager.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonFileManager.cs rename to src/core/IronPython/Runtime/PythonFileManager.cs diff --git a/src/ipy/IronPython/Runtime/PythonFunction.Generated.cs b/src/core/IronPython/Runtime/PythonFunction.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonFunction.Generated.cs rename to src/core/IronPython/Runtime/PythonFunction.Generated.cs diff --git a/src/ipy/IronPython/Runtime/PythonFunction.cs b/src/core/IronPython/Runtime/PythonFunction.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonFunction.cs rename to src/core/IronPython/Runtime/PythonFunction.cs diff --git a/src/ipy/IronPython/Runtime/PythonHiddenAttribute.cs b/src/core/IronPython/Runtime/PythonHiddenAttribute.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonHiddenAttribute.cs rename to src/core/IronPython/Runtime/PythonHiddenAttribute.cs diff --git a/src/ipy/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs b/src/core/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs rename to src/core/IronPython/Runtime/PythonHiddenBaseClassAttribute.cs diff --git a/src/ipy/IronPython/Runtime/PythonList.cs b/src/core/IronPython/Runtime/PythonList.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonList.cs rename to src/core/IronPython/Runtime/PythonList.cs diff --git a/src/ipy/IronPython/Runtime/PythonModule.cs b/src/core/IronPython/Runtime/PythonModule.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonModule.cs rename to src/core/IronPython/Runtime/PythonModule.cs diff --git a/src/ipy/IronPython/Runtime/PythonModuleAttribute.cs b/src/core/IronPython/Runtime/PythonModuleAttribute.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonModuleAttribute.cs rename to src/core/IronPython/Runtime/PythonModuleAttribute.cs diff --git a/src/ipy/IronPython/Runtime/PythonNarrowing.cs b/src/core/IronPython/Runtime/PythonNarrowing.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonNarrowing.cs rename to src/core/IronPython/Runtime/PythonNarrowing.cs diff --git a/src/ipy/IronPython/Runtime/PythonOptions.cs b/src/core/IronPython/Runtime/PythonOptions.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonOptions.cs rename to src/core/IronPython/Runtime/PythonOptions.cs diff --git a/src/ipy/IronPython/Runtime/PythonRange.cs b/src/core/IronPython/Runtime/PythonRange.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonRange.cs rename to src/core/IronPython/Runtime/PythonRange.cs diff --git a/src/ipy/IronPython/Runtime/PythonScopeExtension.cs b/src/core/IronPython/Runtime/PythonScopeExtension.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonScopeExtension.cs rename to src/core/IronPython/Runtime/PythonScopeExtension.cs diff --git a/src/ipy/IronPython/Runtime/PythonStrIterator.cs b/src/core/IronPython/Runtime/PythonStrIterator.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonStrIterator.cs rename to src/core/IronPython/Runtime/PythonStrIterator.cs diff --git a/src/ipy/IronPython/Runtime/PythonTracebackListener.cs b/src/core/IronPython/Runtime/PythonTracebackListener.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonTracebackListener.cs rename to src/core/IronPython/Runtime/PythonTracebackListener.cs diff --git a/src/ipy/IronPython/Runtime/PythonTuple.cs b/src/core/IronPython/Runtime/PythonTuple.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonTuple.cs rename to src/core/IronPython/Runtime/PythonTuple.cs diff --git a/src/ipy/IronPython/Runtime/PythonTypeAttribute.cs b/src/core/IronPython/Runtime/PythonTypeAttribute.cs similarity index 100% rename from src/ipy/IronPython/Runtime/PythonTypeAttribute.cs rename to src/core/IronPython/Runtime/PythonTypeAttribute.cs diff --git a/src/ipy/IronPython/Runtime/Reversed.cs b/src/core/IronPython/Runtime/Reversed.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Reversed.cs rename to src/core/IronPython/Runtime/Reversed.cs diff --git a/src/ipy/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs b/src/core/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs similarity index 100% rename from src/ipy/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs rename to src/core/IronPython/Runtime/RuntimeVariablesDictionaryStorage.cs diff --git a/src/ipy/IronPython/Runtime/ScopeDictionaryStorage.cs b/src/core/IronPython/Runtime/ScopeDictionaryStorage.cs similarity index 100% rename from src/ipy/IronPython/Runtime/ScopeDictionaryStorage.cs rename to src/core/IronPython/Runtime/ScopeDictionaryStorage.cs diff --git a/src/ipy/IronPython/Runtime/SequenceTypeInfoAttribute.cs b/src/core/IronPython/Runtime/SequenceTypeInfoAttribute.cs similarity index 100% rename from src/ipy/IronPython/Runtime/SequenceTypeInfoAttribute.cs rename to src/core/IronPython/Runtime/SequenceTypeInfoAttribute.cs diff --git a/src/ipy/IronPython/Runtime/Set.cs b/src/core/IronPython/Runtime/Set.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Set.cs rename to src/core/IronPython/Runtime/Set.cs diff --git a/src/ipy/IronPython/Runtime/SetStorage.cs b/src/core/IronPython/Runtime/SetStorage.cs similarity index 100% rename from src/ipy/IronPython/Runtime/SetStorage.cs rename to src/core/IronPython/Runtime/SetStorage.cs diff --git a/src/ipy/IronPython/Runtime/SimpleNamespace.cs b/src/core/IronPython/Runtime/SimpleNamespace.cs similarity index 100% rename from src/ipy/IronPython/Runtime/SimpleNamespace.cs rename to src/core/IronPython/Runtime/SimpleNamespace.cs diff --git a/src/ipy/IronPython/Runtime/SiteLocalStorage.cs b/src/core/IronPython/Runtime/SiteLocalStorage.cs similarity index 100% rename from src/ipy/IronPython/Runtime/SiteLocalStorage.cs rename to src/core/IronPython/Runtime/SiteLocalStorage.cs diff --git a/src/ipy/IronPython/Runtime/Slice.cs b/src/core/IronPython/Runtime/Slice.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Slice.cs rename to src/core/IronPython/Runtime/Slice.cs diff --git a/src/ipy/IronPython/Runtime/StringDictionaryStorage.cs b/src/core/IronPython/Runtime/StringDictionaryStorage.cs similarity index 100% rename from src/ipy/IronPython/Runtime/StringDictionaryStorage.cs rename to src/core/IronPython/Runtime/StringDictionaryStorage.cs diff --git a/src/ipy/IronPython/Runtime/StringFormatSpec.cs b/src/core/IronPython/Runtime/StringFormatSpec.cs similarity index 100% rename from src/ipy/IronPython/Runtime/StringFormatSpec.cs rename to src/core/IronPython/Runtime/StringFormatSpec.cs diff --git a/src/ipy/IronPython/Runtime/StringFormatter.cs b/src/core/IronPython/Runtime/StringFormatter.cs similarity index 100% rename from src/ipy/IronPython/Runtime/StringFormatter.cs rename to src/core/IronPython/Runtime/StringFormatter.cs diff --git a/src/ipy/IronPython/Runtime/Super.cs b/src/core/IronPython/Runtime/Super.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Super.cs rename to src/core/IronPython/Runtime/Super.cs diff --git a/src/ipy/IronPython/Runtime/Symbols.Generated.cs b/src/core/IronPython/Runtime/Symbols.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Symbols.Generated.cs rename to src/core/IronPython/Runtime/Symbols.Generated.cs diff --git a/src/ipy/IronPython/Runtime/ThrowingErrorSink.cs b/src/core/IronPython/Runtime/ThrowingErrorSink.cs similarity index 100% rename from src/ipy/IronPython/Runtime/ThrowingErrorSink.cs rename to src/core/IronPython/Runtime/ThrowingErrorSink.cs diff --git a/src/ipy/IronPython/Runtime/TypecodeOps.cs b/src/core/IronPython/Runtime/TypecodeOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/TypecodeOps.cs rename to src/core/IronPython/Runtime/TypecodeOps.cs diff --git a/src/ipy/IronPython/Runtime/Types/BuiltinFunction.cs b/src/core/IronPython/Runtime/Types/BuiltinFunction.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/BuiltinFunction.cs rename to src/core/IronPython/Runtime/Types/BuiltinFunction.cs diff --git a/src/ipy/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs b/src/core/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs rename to src/core/IronPython/Runtime/Types/BuiltinFunctionOverloadMapper.cs diff --git a/src/ipy/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs b/src/core/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs rename to src/core/IronPython/Runtime/Types/BuiltinMethodDescriptor.cs diff --git a/src/ipy/IronPython/Runtime/Types/CachedNewTypeInfo.cs b/src/core/IronPython/Runtime/Types/CachedNewTypeInfo.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/CachedNewTypeInfo.cs rename to src/core/IronPython/Runtime/Types/CachedNewTypeInfo.cs diff --git a/src/ipy/IronPython/Runtime/Types/ConstructorFunction.cs b/src/core/IronPython/Runtime/Types/ConstructorFunction.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/ConstructorFunction.cs rename to src/core/IronPython/Runtime/Types/ConstructorFunction.cs diff --git a/src/ipy/IronPython/Runtime/Types/CustomAttributeTracker.cs b/src/core/IronPython/Runtime/Types/CustomAttributeTracker.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/CustomAttributeTracker.cs rename to src/core/IronPython/Runtime/Types/CustomAttributeTracker.cs diff --git a/src/ipy/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs b/src/core/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs rename to src/core/IronPython/Runtime/Types/CustomInstanceDictionaryStorage.cs diff --git a/src/ipy/IronPython/Runtime/Types/DocBuilder.cs b/src/core/IronPython/Runtime/Types/DocBuilder.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/DocBuilder.cs rename to src/core/IronPython/Runtime/Types/DocBuilder.cs diff --git a/src/ipy/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs b/src/core/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs rename to src/core/IronPython/Runtime/Types/DynamicBaseTypeAttribute.cs diff --git a/src/ipy/IronPython/Runtime/Types/DynamicHelpers.cs b/src/core/IronPython/Runtime/Types/DynamicHelpers.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/DynamicHelpers.cs rename to src/core/IronPython/Runtime/Types/DynamicHelpers.cs diff --git a/src/ipy/IronPython/Runtime/Types/EmptyType.cs b/src/core/IronPython/Runtime/Types/EmptyType.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/EmptyType.cs rename to src/core/IronPython/Runtime/Types/EmptyType.cs diff --git a/src/ipy/IronPython/Runtime/Types/ExtensionPropertyInfo.cs b/src/core/IronPython/Runtime/Types/ExtensionPropertyInfo.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/ExtensionPropertyInfo.cs rename to src/core/IronPython/Runtime/Types/ExtensionPropertyInfo.cs diff --git a/src/ipy/IronPython/Runtime/Types/FunctionType.cs b/src/core/IronPython/Runtime/Types/FunctionType.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/FunctionType.cs rename to src/core/IronPython/Runtime/Types/FunctionType.cs diff --git a/src/ipy/IronPython/Runtime/Types/IPythonObject.cs b/src/core/IronPython/Runtime/Types/IPythonObject.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/IPythonObject.cs rename to src/core/IronPython/Runtime/Types/IPythonObject.cs diff --git a/src/ipy/IronPython/Runtime/Types/InstanceCreator.cs b/src/core/IronPython/Runtime/Types/InstanceCreator.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/InstanceCreator.cs rename to src/core/IronPython/Runtime/Types/InstanceCreator.cs diff --git a/src/ipy/IronPython/Runtime/Types/MappingProxy.cs b/src/core/IronPython/Runtime/Types/MappingProxy.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/MappingProxy.cs rename to src/core/IronPython/Runtime/Types/MappingProxy.cs diff --git a/src/ipy/IronPython/Runtime/Types/Mro.cs b/src/core/IronPython/Runtime/Types/Mro.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/Mro.cs rename to src/core/IronPython/Runtime/Types/Mro.cs diff --git a/src/ipy/IronPython/Runtime/Types/NameConverter.cs b/src/core/IronPython/Runtime/Types/NameConverter.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/NameConverter.cs rename to src/core/IronPython/Runtime/Types/NameConverter.cs diff --git a/src/ipy/IronPython/Runtime/Types/NewTypeInfo.cs b/src/core/IronPython/Runtime/Types/NewTypeInfo.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/NewTypeInfo.cs rename to src/core/IronPython/Runtime/Types/NewTypeInfo.cs diff --git a/src/ipy/IronPython/Runtime/Types/NewTypeMaker.cs b/src/core/IronPython/Runtime/Types/NewTypeMaker.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/NewTypeMaker.cs rename to src/core/IronPython/Runtime/Types/NewTypeMaker.cs diff --git a/src/ipy/IronPython/Runtime/Types/OperatorMapping.cs b/src/core/IronPython/Runtime/Types/OperatorMapping.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/OperatorMapping.cs rename to src/core/IronPython/Runtime/Types/OperatorMapping.cs diff --git a/src/ipy/IronPython/Runtime/Types/ParameterInfoWrapper.cs b/src/core/IronPython/Runtime/Types/ParameterInfoWrapper.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/ParameterInfoWrapper.cs rename to src/core/IronPython/Runtime/Types/ParameterInfoWrapper.cs diff --git a/src/ipy/IronPython/Runtime/Types/PythonAssemblyOps.cs b/src/core/IronPython/Runtime/Types/PythonAssemblyOps.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/PythonAssemblyOps.cs rename to src/core/IronPython/Runtime/Types/PythonAssemblyOps.cs diff --git a/src/ipy/IronPython/Runtime/Types/PythonSiteCache.cs b/src/core/IronPython/Runtime/Types/PythonSiteCache.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/PythonSiteCache.cs rename to src/core/IronPython/Runtime/Types/PythonSiteCache.cs diff --git a/src/ipy/IronPython/Runtime/Types/PythonType.Generated.cs b/src/core/IronPython/Runtime/Types/PythonType.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/PythonType.Generated.cs rename to src/core/IronPython/Runtime/Types/PythonType.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Types/PythonType.cs b/src/core/IronPython/Runtime/Types/PythonType.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/PythonType.cs rename to src/core/IronPython/Runtime/Types/PythonType.cs diff --git a/src/ipy/IronPython/Runtime/Types/PythonTypeDataSlot.cs b/src/core/IronPython/Runtime/Types/PythonTypeDataSlot.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/PythonTypeDataSlot.cs rename to src/core/IronPython/Runtime/Types/PythonTypeDataSlot.cs diff --git a/src/ipy/IronPython/Runtime/Types/PythonTypeDictSlot.cs b/src/core/IronPython/Runtime/Types/PythonTypeDictSlot.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/PythonTypeDictSlot.cs rename to src/core/IronPython/Runtime/Types/PythonTypeDictSlot.cs diff --git a/src/ipy/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs b/src/core/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs rename to src/core/IronPython/Runtime/Types/PythonTypeInfo.Generated.cs diff --git a/src/ipy/IronPython/Runtime/Types/PythonTypeInfo.cs b/src/core/IronPython/Runtime/Types/PythonTypeInfo.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/PythonTypeInfo.cs rename to src/core/IronPython/Runtime/Types/PythonTypeInfo.cs diff --git a/src/ipy/IronPython/Runtime/Types/PythonTypeSlot.cs b/src/core/IronPython/Runtime/Types/PythonTypeSlot.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/PythonTypeSlot.cs rename to src/core/IronPython/Runtime/Types/PythonTypeSlot.cs diff --git a/src/ipy/IronPython/Runtime/Types/PythonTypeTypeSlot.cs b/src/core/IronPython/Runtime/Types/PythonTypeTypeSlot.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/PythonTypeTypeSlot.cs rename to src/core/IronPython/Runtime/Types/PythonTypeTypeSlot.cs diff --git a/src/ipy/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs b/src/core/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs rename to src/core/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs diff --git a/src/ipy/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs b/src/core/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs rename to src/core/IronPython/Runtime/Types/PythonTypeWeakRefSlot.cs diff --git a/src/ipy/IronPython/Runtime/Types/ReflectedEvent.cs b/src/core/IronPython/Runtime/Types/ReflectedEvent.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/ReflectedEvent.cs rename to src/core/IronPython/Runtime/Types/ReflectedEvent.cs diff --git a/src/ipy/IronPython/Runtime/Types/ReflectedExtensionProperty.cs b/src/core/IronPython/Runtime/Types/ReflectedExtensionProperty.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/ReflectedExtensionProperty.cs rename to src/core/IronPython/Runtime/Types/ReflectedExtensionProperty.cs diff --git a/src/ipy/IronPython/Runtime/Types/ReflectedField.cs b/src/core/IronPython/Runtime/Types/ReflectedField.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/ReflectedField.cs rename to src/core/IronPython/Runtime/Types/ReflectedField.cs diff --git a/src/ipy/IronPython/Runtime/Types/ReflectedGetterSetter.cs b/src/core/IronPython/Runtime/Types/ReflectedGetterSetter.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/ReflectedGetterSetter.cs rename to src/core/IronPython/Runtime/Types/ReflectedGetterSetter.cs diff --git a/src/ipy/IronPython/Runtime/Types/ReflectedIndexer.cs b/src/core/IronPython/Runtime/Types/ReflectedIndexer.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/ReflectedIndexer.cs rename to src/core/IronPython/Runtime/Types/ReflectedIndexer.cs diff --git a/src/ipy/IronPython/Runtime/Types/ReflectedProperty.cs b/src/core/IronPython/Runtime/Types/ReflectedProperty.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/ReflectedProperty.cs rename to src/core/IronPython/Runtime/Types/ReflectedProperty.cs diff --git a/src/ipy/IronPython/Runtime/Types/ReflectedSlotProperty.cs b/src/core/IronPython/Runtime/Types/ReflectedSlotProperty.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/ReflectedSlotProperty.cs rename to src/core/IronPython/Runtime/Types/ReflectedSlotProperty.cs diff --git a/src/ipy/IronPython/Runtime/Types/ResolvedMember.cs b/src/core/IronPython/Runtime/Types/ResolvedMember.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/ResolvedMember.cs rename to src/core/IronPython/Runtime/Types/ResolvedMember.cs diff --git a/src/ipy/IronPython/Runtime/Types/SlotFieldAttribute.cs b/src/core/IronPython/Runtime/Types/SlotFieldAttribute.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/SlotFieldAttribute.cs rename to src/core/IronPython/Runtime/Types/SlotFieldAttribute.cs diff --git a/src/ipy/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs b/src/core/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs rename to src/core/IronPython/Runtime/Types/StaticUnderlyingSystemType.cs diff --git a/src/ipy/IronPython/Runtime/Types/TypeCache.Generated.cs b/src/core/IronPython/Runtime/Types/TypeCache.Generated.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Types/TypeCache.Generated.cs rename to src/core/IronPython/Runtime/Types/TypeCache.Generated.cs diff --git a/src/ipy/IronPython/Runtime/UnboundNameException.cs b/src/core/IronPython/Runtime/UnboundNameException.cs similarity index 100% rename from src/ipy/IronPython/Runtime/UnboundNameException.cs rename to src/core/IronPython/Runtime/UnboundNameException.cs diff --git a/src/ipy/IronPython/Runtime/WeakRef.cs b/src/core/IronPython/Runtime/WeakRef.cs similarity index 100% rename from src/ipy/IronPython/Runtime/WeakRef.cs rename to src/core/IronPython/Runtime/WeakRef.cs diff --git a/src/ipy/IronPython/Runtime/WrapperDescriptorAttribute.cs b/src/core/IronPython/Runtime/WrapperDescriptorAttribute.cs similarity index 100% rename from src/ipy/IronPython/Runtime/WrapperDescriptorAttribute.cs rename to src/core/IronPython/Runtime/WrapperDescriptorAttribute.cs diff --git a/src/ipy/IronPython/Runtime/WrapperDictionary.cs b/src/core/IronPython/Runtime/WrapperDictionary.cs similarity index 100% rename from src/ipy/IronPython/Runtime/WrapperDictionary.cs rename to src/core/IronPython/Runtime/WrapperDictionary.cs diff --git a/src/ipy/IronPython/Runtime/Zip.cs b/src/core/IronPython/Runtime/Zip.cs similarity index 100% rename from src/ipy/IronPython/Runtime/Zip.cs rename to src/core/IronPython/Runtime/Zip.cs diff --git a/src/ipy/IronPython/SerializationStubs.cs b/src/core/IronPython/SerializationStubs.cs similarity index 100% rename from src/ipy/IronPython/SerializationStubs.cs rename to src/core/IronPython/SerializationStubs.cs diff --git a/src/ipy/IronPython/StringExtensions.cs b/src/core/IronPython/StringExtensions.cs similarity index 100% rename from src/ipy/IronPython/StringExtensions.cs rename to src/core/IronPython/StringExtensions.cs diff --git a/src/ipy/IronPython/SystemRuntimeVersioning.cs b/src/core/IronPython/SystemRuntimeVersioning.cs similarity index 100% rename from src/ipy/IronPython/SystemRuntimeVersioning.cs rename to src/core/IronPython/SystemRuntimeVersioning.cs diff --git a/src/ipy/IronPython/policy.IronPython.config b/src/core/IronPython/policy.IronPython.config similarity index 100% rename from src/ipy/IronPython/policy.IronPython.config rename to src/core/IronPython/policy.IronPython.config diff --git a/src/ipy/README.md b/src/core/README.md similarity index 100% rename from src/ipy/README.md rename to src/core/README.md From f1a07186ec0a1c312b267c42d765751e099a5bcc Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:04:36 +0000 Subject: [PATCH 42/84] Fix project references due to core folder rename --- IronPython.sln | 6 +++--- .../IronPython.Console.Host/IronPython.Console.Host.csproj | 2 +- src/console/IronPython.Console/IronPython.Console.csproj | 4 ++-- .../IronPython.Console32.Host.csproj | 2 +- .../IronPython.Console32/IronPython.Console32.csproj | 4 ++-- src/extensions/IronPython.SQLite/IronPython.SQLite.csproj | 2 +- src/extensions/IronPython.Wpf/IronPython.Wpf.csproj | 2 +- tests/ironpython/IronPython.Tests.csproj | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/IronPython.sln b/IronPython.sln index 8fe4806ab..9a678e2d5 100644 --- a/IronPython.sln +++ b/IronPython.sln @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.9.34714.143 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython", "src\ipy\IronPython\IronPython.csproj", "{95289EA9-5778-489D-AB48-F81F2CE2DA32}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython", "src\core\IronPython\IronPython.csproj", "{95289EA9-5778-489D-AB48-F81F2CE2DA32}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Modules", "src\ipy\IronPython.Modules\IronPython.Modules.csproj", "{155CE436-1669-4A48-8095-410F2430237F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Modules", "src\core\IronPython.Modules\IronPython.Modules.csproj", "{155CE436-1669-4A48-8095-410F2430237F}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Wpf", "src\extensions\IronPython.Wpf\IronPython.Wpf.csproj", "{65E997B7-E99B-4C83-B29E-9951429BB293}" EndProject @@ -44,7 +44,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "eng", "eng", "{17737ACB-40C eng\Tasks.Targets = eng\Tasks.Targets EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.CompilerServices", "src\ipy\IronPython.CompilerServices\IronPython.CompilerServices.csproj", "{3DFB096E-AC09-4E7A-9288-7F7C33C288C7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.CompilerServices", "src\core\IronPython.CompilerServices\IronPython.CompilerServices.csproj", "{3DFB096E-AC09-4E7A-9288-7F7C33C288C7}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "runtime", "runtime", "{AC38EFB1-820D-4E90-BF40-BEF3AC825542}" EndProject diff --git a/src/console/IronPython.Console.Host/IronPython.Console.Host.csproj b/src/console/IronPython.Console.Host/IronPython.Console.Host.csproj index 5c01d2c9d..0e7966081 100644 --- a/src/console/IronPython.Console.Host/IronPython.Console.Host.csproj +++ b/src/console/IronPython.Console.Host/IronPython.Console.Host.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/console/IronPython.Console/IronPython.Console.csproj b/src/console/IronPython.Console/IronPython.Console.csproj index 02060e127..2aee6ce80 100644 --- a/src/console/IronPython.Console/IronPython.Console.csproj +++ b/src/console/IronPython.Console/IronPython.Console.csproj @@ -14,8 +14,8 @@ - - + + false Content PreserveNewest diff --git a/src/console/IronPython.Console32.Host/IronPython.Console32.Host.csproj b/src/console/IronPython.Console32.Host/IronPython.Console32.Host.csproj index c420e54f4..d7ede7abb 100644 --- a/src/console/IronPython.Console32.Host/IronPython.Console32.Host.csproj +++ b/src/console/IronPython.Console32.Host/IronPython.Console32.Host.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/console/IronPython.Console32/IronPython.Console32.csproj b/src/console/IronPython.Console32/IronPython.Console32.csproj index de107bb20..34c727c57 100644 --- a/src/console/IronPython.Console32/IronPython.Console32.csproj +++ b/src/console/IronPython.Console32/IronPython.Console32.csproj @@ -11,8 +11,8 @@ - - + + false diff --git a/src/extensions/IronPython.SQLite/IronPython.SQLite.csproj b/src/extensions/IronPython.SQLite/IronPython.SQLite.csproj index 5d18e0c4c..1fab72dfa 100644 --- a/src/extensions/IronPython.SQLite/IronPython.SQLite.csproj +++ b/src/extensions/IronPython.SQLite/IronPython.SQLite.csproj @@ -24,7 +24,7 @@ - + diff --git a/src/extensions/IronPython.Wpf/IronPython.Wpf.csproj b/src/extensions/IronPython.Wpf/IronPython.Wpf.csproj index 4ba14fde3..b8c193499 100644 --- a/src/extensions/IronPython.Wpf/IronPython.Wpf.csproj +++ b/src/extensions/IronPython.Wpf/IronPython.Wpf.csproj @@ -13,7 +13,7 @@ - + diff --git a/tests/ironpython/IronPython.Tests.csproj b/tests/ironpython/IronPython.Tests.csproj index f4fa85996..12a85875a 100644 --- a/tests/ironpython/IronPython.Tests.csproj +++ b/tests/ironpython/IronPython.Tests.csproj @@ -8,7 +8,7 @@ - + From 717d826e45e50f445b8b5d5c9cbf0db46342926f Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:19:19 +0000 Subject: [PATCH 43/84] Move CTypes to tests directory --- {src/core/CTypes => tests/ctypes}/Makefile | 0 {src/core/CTypes => tests/ctypes}/_ctypes_test.c | 0 {src/core/CTypes => tests/ctypes}/_ctypes_test.sln | 0 {src/core/CTypes => tests/ctypes}/_ctypes_test.vcxproj | 0 tests/ctypes/_ctypes_test.vcxproj.user | 4 ++++ 5 files changed, 4 insertions(+) rename {src/core/CTypes => tests/ctypes}/Makefile (100%) rename {src/core/CTypes => tests/ctypes}/_ctypes_test.c (100%) rename {src/core/CTypes => tests/ctypes}/_ctypes_test.sln (100%) rename {src/core/CTypes => tests/ctypes}/_ctypes_test.vcxproj (100%) create mode 100644 tests/ctypes/_ctypes_test.vcxproj.user diff --git a/src/core/CTypes/Makefile b/tests/ctypes/Makefile similarity index 100% rename from src/core/CTypes/Makefile rename to tests/ctypes/Makefile diff --git a/src/core/CTypes/_ctypes_test.c b/tests/ctypes/_ctypes_test.c similarity index 100% rename from src/core/CTypes/_ctypes_test.c rename to tests/ctypes/_ctypes_test.c diff --git a/src/core/CTypes/_ctypes_test.sln b/tests/ctypes/_ctypes_test.sln similarity index 100% rename from src/core/CTypes/_ctypes_test.sln rename to tests/ctypes/_ctypes_test.sln diff --git a/src/core/CTypes/_ctypes_test.vcxproj b/tests/ctypes/_ctypes_test.vcxproj similarity index 100% rename from src/core/CTypes/_ctypes_test.vcxproj rename to tests/ctypes/_ctypes_test.vcxproj diff --git a/tests/ctypes/_ctypes_test.vcxproj.user b/tests/ctypes/_ctypes_test.vcxproj.user new file mode 100644 index 000000000..88a550947 --- /dev/null +++ b/tests/ctypes/_ctypes_test.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From fc68d5a2dcc3710e4e33cfe5b4867c069c78b920 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:20:26 +0000 Subject: [PATCH 44/84] Rename CTypes test --- IronPython.sln | 139 ++++++++++++++++++++++++++++++ tests/ctypes/_ctypes_test.vcxproj | 1 + 2 files changed, 140 insertions(+) diff --git a/IronPython.sln b/IronPython.sln index 9a678e2d5..32f1c93b7 100644 --- a/IronPython.sln +++ b/IronPython.sln @@ -115,72 +115,210 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "roslyn", "roslyn", "{426817 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{26425961-0A4E-4CFA-9F45-9072AD6FA6F1}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ctypes_test", "tests\ctypes\_ctypes_test.vcxproj", "{0BDA76B0-44BF-47B7-AA21-C247F83FAF73}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {95289EA9-5778-489D-AB48-F81F2CE2DA32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {95289EA9-5778-489D-AB48-F81F2CE2DA32}.Debug|Any CPU.Build.0 = Debug|Any CPU + {95289EA9-5778-489D-AB48-F81F2CE2DA32}.Debug|x64.ActiveCfg = Debug|Any CPU + {95289EA9-5778-489D-AB48-F81F2CE2DA32}.Debug|x64.Build.0 = Debug|Any CPU + {95289EA9-5778-489D-AB48-F81F2CE2DA32}.Debug|x86.ActiveCfg = Debug|Any CPU + {95289EA9-5778-489D-AB48-F81F2CE2DA32}.Debug|x86.Build.0 = Debug|Any CPU {95289EA9-5778-489D-AB48-F81F2CE2DA32}.Release|Any CPU.ActiveCfg = Release|Any CPU {95289EA9-5778-489D-AB48-F81F2CE2DA32}.Release|Any CPU.Build.0 = Release|Any CPU + {95289EA9-5778-489D-AB48-F81F2CE2DA32}.Release|x64.ActiveCfg = Release|Any CPU + {95289EA9-5778-489D-AB48-F81F2CE2DA32}.Release|x64.Build.0 = Release|Any CPU + {95289EA9-5778-489D-AB48-F81F2CE2DA32}.Release|x86.ActiveCfg = Release|Any CPU + {95289EA9-5778-489D-AB48-F81F2CE2DA32}.Release|x86.Build.0 = Release|Any CPU {155CE436-1669-4A48-8095-410F2430237F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {155CE436-1669-4A48-8095-410F2430237F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {155CE436-1669-4A48-8095-410F2430237F}.Debug|x64.ActiveCfg = Debug|Any CPU + {155CE436-1669-4A48-8095-410F2430237F}.Debug|x64.Build.0 = Debug|Any CPU + {155CE436-1669-4A48-8095-410F2430237F}.Debug|x86.ActiveCfg = Debug|Any CPU + {155CE436-1669-4A48-8095-410F2430237F}.Debug|x86.Build.0 = Debug|Any CPU {155CE436-1669-4A48-8095-410F2430237F}.Release|Any CPU.ActiveCfg = Release|Any CPU {155CE436-1669-4A48-8095-410F2430237F}.Release|Any CPU.Build.0 = Release|Any CPU + {155CE436-1669-4A48-8095-410F2430237F}.Release|x64.ActiveCfg = Release|Any CPU + {155CE436-1669-4A48-8095-410F2430237F}.Release|x64.Build.0 = Release|Any CPU + {155CE436-1669-4A48-8095-410F2430237F}.Release|x86.ActiveCfg = Release|Any CPU + {155CE436-1669-4A48-8095-410F2430237F}.Release|x86.Build.0 = Release|Any CPU {65E997B7-E99B-4C83-B29E-9951429BB293}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {65E997B7-E99B-4C83-B29E-9951429BB293}.Debug|Any CPU.Build.0 = Debug|Any CPU + {65E997B7-E99B-4C83-B29E-9951429BB293}.Debug|x64.ActiveCfg = Debug|Any CPU + {65E997B7-E99B-4C83-B29E-9951429BB293}.Debug|x64.Build.0 = Debug|Any CPU + {65E997B7-E99B-4C83-B29E-9951429BB293}.Debug|x86.ActiveCfg = Debug|Any CPU + {65E997B7-E99B-4C83-B29E-9951429BB293}.Debug|x86.Build.0 = Debug|Any CPU {65E997B7-E99B-4C83-B29E-9951429BB293}.Release|Any CPU.ActiveCfg = Release|Any CPU {65E997B7-E99B-4C83-B29E-9951429BB293}.Release|Any CPU.Build.0 = Release|Any CPU + {65E997B7-E99B-4C83-B29E-9951429BB293}.Release|x64.ActiveCfg = Release|Any CPU + {65E997B7-E99B-4C83-B29E-9951429BB293}.Release|x64.Build.0 = Release|Any CPU + {65E997B7-E99B-4C83-B29E-9951429BB293}.Release|x86.ActiveCfg = Release|Any CPU + {65E997B7-E99B-4C83-B29E-9951429BB293}.Release|x86.Build.0 = Release|Any CPU {811AC32C-11F3-4ED8-92A7-A7E39C2BB704}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {811AC32C-11F3-4ED8-92A7-A7E39C2BB704}.Debug|Any CPU.Build.0 = Debug|Any CPU + {811AC32C-11F3-4ED8-92A7-A7E39C2BB704}.Debug|x64.ActiveCfg = Debug|Any CPU + {811AC32C-11F3-4ED8-92A7-A7E39C2BB704}.Debug|x64.Build.0 = Debug|Any CPU + {811AC32C-11F3-4ED8-92A7-A7E39C2BB704}.Debug|x86.ActiveCfg = Debug|Any CPU + {811AC32C-11F3-4ED8-92A7-A7E39C2BB704}.Debug|x86.Build.0 = Debug|Any CPU {811AC32C-11F3-4ED8-92A7-A7E39C2BB704}.Release|Any CPU.ActiveCfg = Release|Any CPU {811AC32C-11F3-4ED8-92A7-A7E39C2BB704}.Release|Any CPU.Build.0 = Release|Any CPU + {811AC32C-11F3-4ED8-92A7-A7E39C2BB704}.Release|x64.ActiveCfg = Release|Any CPU + {811AC32C-11F3-4ED8-92A7-A7E39C2BB704}.Release|x64.Build.0 = Release|Any CPU + {811AC32C-11F3-4ED8-92A7-A7E39C2BB704}.Release|x86.ActiveCfg = Release|Any CPU + {811AC32C-11F3-4ED8-92A7-A7E39C2BB704}.Release|x86.Build.0 = Release|Any CPU {B6B42537-07F8-4F6C-A99A-B155CAEB124E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B6B42537-07F8-4F6C-A99A-B155CAEB124E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B6B42537-07F8-4F6C-A99A-B155CAEB124E}.Debug|x64.ActiveCfg = Debug|Any CPU + {B6B42537-07F8-4F6C-A99A-B155CAEB124E}.Debug|x64.Build.0 = Debug|Any CPU + {B6B42537-07F8-4F6C-A99A-B155CAEB124E}.Debug|x86.ActiveCfg = Debug|Any CPU + {B6B42537-07F8-4F6C-A99A-B155CAEB124E}.Debug|x86.Build.0 = Debug|Any CPU {B6B42537-07F8-4F6C-A99A-B155CAEB124E}.Release|Any CPU.ActiveCfg = Release|Any CPU {B6B42537-07F8-4F6C-A99A-B155CAEB124E}.Release|Any CPU.Build.0 = Release|Any CPU + {B6B42537-07F8-4F6C-A99A-B155CAEB124E}.Release|x64.ActiveCfg = Release|Any CPU + {B6B42537-07F8-4F6C-A99A-B155CAEB124E}.Release|x64.Build.0 = Release|Any CPU + {B6B42537-07F8-4F6C-A99A-B155CAEB124E}.Release|x86.ActiveCfg = Release|Any CPU + {B6B42537-07F8-4F6C-A99A-B155CAEB124E}.Release|x86.Build.0 = Release|Any CPU {81DA19C7-4FEC-47E7-981B-D9310D549F95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {81DA19C7-4FEC-47E7-981B-D9310D549F95}.Debug|Any CPU.Build.0 = Debug|Any CPU + {81DA19C7-4FEC-47E7-981B-D9310D549F95}.Debug|x64.ActiveCfg = Debug|Any CPU + {81DA19C7-4FEC-47E7-981B-D9310D549F95}.Debug|x64.Build.0 = Debug|Any CPU + {81DA19C7-4FEC-47E7-981B-D9310D549F95}.Debug|x86.ActiveCfg = Debug|Any CPU + {81DA19C7-4FEC-47E7-981B-D9310D549F95}.Debug|x86.Build.0 = Debug|Any CPU {81DA19C7-4FEC-47E7-981B-D9310D549F95}.Release|Any CPU.ActiveCfg = Release|Any CPU {81DA19C7-4FEC-47E7-981B-D9310D549F95}.Release|Any CPU.Build.0 = Release|Any CPU + {81DA19C7-4FEC-47E7-981B-D9310D549F95}.Release|x64.ActiveCfg = Release|Any CPU + {81DA19C7-4FEC-47E7-981B-D9310D549F95}.Release|x64.Build.0 = Release|Any CPU + {81DA19C7-4FEC-47E7-981B-D9310D549F95}.Release|x86.ActiveCfg = Release|Any CPU + {81DA19C7-4FEC-47E7-981B-D9310D549F95}.Release|x86.Build.0 = Release|Any CPU {3DFB096E-AC09-4E7A-9288-7F7C33C288C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3DFB096E-AC09-4E7A-9288-7F7C33C288C7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3DFB096E-AC09-4E7A-9288-7F7C33C288C7}.Debug|x64.ActiveCfg = Debug|Any CPU + {3DFB096E-AC09-4E7A-9288-7F7C33C288C7}.Debug|x64.Build.0 = Debug|Any CPU + {3DFB096E-AC09-4E7A-9288-7F7C33C288C7}.Debug|x86.ActiveCfg = Debug|Any CPU + {3DFB096E-AC09-4E7A-9288-7F7C33C288C7}.Debug|x86.Build.0 = Debug|Any CPU {3DFB096E-AC09-4E7A-9288-7F7C33C288C7}.Release|Any CPU.ActiveCfg = Release|Any CPU {3DFB096E-AC09-4E7A-9288-7F7C33C288C7}.Release|Any CPU.Build.0 = Release|Any CPU + {3DFB096E-AC09-4E7A-9288-7F7C33C288C7}.Release|x64.ActiveCfg = Release|Any CPU + {3DFB096E-AC09-4E7A-9288-7F7C33C288C7}.Release|x64.Build.0 = Release|Any CPU + {3DFB096E-AC09-4E7A-9288-7F7C33C288C7}.Release|x86.ActiveCfg = Release|Any CPU + {3DFB096E-AC09-4E7A-9288-7F7C33C288C7}.Release|x86.Build.0 = Release|Any CPU {EB66B766-6354-4208-A3D4-AACBDCB5C3B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EB66B766-6354-4208-A3D4-AACBDCB5C3B3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EB66B766-6354-4208-A3D4-AACBDCB5C3B3}.Debug|x64.ActiveCfg = Debug|Any CPU + {EB66B766-6354-4208-A3D4-AACBDCB5C3B3}.Debug|x64.Build.0 = Debug|Any CPU + {EB66B766-6354-4208-A3D4-AACBDCB5C3B3}.Debug|x86.ActiveCfg = Debug|Any CPU + {EB66B766-6354-4208-A3D4-AACBDCB5C3B3}.Debug|x86.Build.0 = Debug|Any CPU {EB66B766-6354-4208-A3D4-AACBDCB5C3B3}.Release|Any CPU.ActiveCfg = Release|Any CPU {EB66B766-6354-4208-A3D4-AACBDCB5C3B3}.Release|Any CPU.Build.0 = Release|Any CPU + {EB66B766-6354-4208-A3D4-AACBDCB5C3B3}.Release|x64.ActiveCfg = Release|Any CPU + {EB66B766-6354-4208-A3D4-AACBDCB5C3B3}.Release|x64.Build.0 = Release|Any CPU + {EB66B766-6354-4208-A3D4-AACBDCB5C3B3}.Release|x86.ActiveCfg = Release|Any CPU + {EB66B766-6354-4208-A3D4-AACBDCB5C3B3}.Release|x86.Build.0 = Release|Any CPU {02FF0909-F5AD-48CF-A86A-345E721B7E40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {02FF0909-F5AD-48CF-A86A-345E721B7E40}.Debug|Any CPU.Build.0 = Debug|Any CPU + {02FF0909-F5AD-48CF-A86A-345E721B7E40}.Debug|x64.ActiveCfg = Debug|Any CPU + {02FF0909-F5AD-48CF-A86A-345E721B7E40}.Debug|x64.Build.0 = Debug|Any CPU + {02FF0909-F5AD-48CF-A86A-345E721B7E40}.Debug|x86.ActiveCfg = Debug|Any CPU + {02FF0909-F5AD-48CF-A86A-345E721B7E40}.Debug|x86.Build.0 = Debug|Any CPU {02FF0909-F5AD-48CF-A86A-345E721B7E40}.Release|Any CPU.ActiveCfg = Release|Any CPU {02FF0909-F5AD-48CF-A86A-345E721B7E40}.Release|Any CPU.Build.0 = Release|Any CPU + {02FF0909-F5AD-48CF-A86A-345E721B7E40}.Release|x64.ActiveCfg = Release|Any CPU + {02FF0909-F5AD-48CF-A86A-345E721B7E40}.Release|x64.Build.0 = Release|Any CPU + {02FF0909-F5AD-48CF-A86A-345E721B7E40}.Release|x86.ActiveCfg = Release|Any CPU + {02FF0909-F5AD-48CF-A86A-345E721B7E40}.Release|x86.Build.0 = Release|Any CPU {ACDD9B9E-8FE6-439C-9521-1CCBA47F6143}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {ACDD9B9E-8FE6-439C-9521-1CCBA47F6143}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ACDD9B9E-8FE6-439C-9521-1CCBA47F6143}.Debug|x64.ActiveCfg = Debug|Any CPU + {ACDD9B9E-8FE6-439C-9521-1CCBA47F6143}.Debug|x64.Build.0 = Debug|Any CPU + {ACDD9B9E-8FE6-439C-9521-1CCBA47F6143}.Debug|x86.ActiveCfg = Debug|Any CPU + {ACDD9B9E-8FE6-439C-9521-1CCBA47F6143}.Debug|x86.Build.0 = Debug|Any CPU {ACDD9B9E-8FE6-439C-9521-1CCBA47F6143}.Release|Any CPU.ActiveCfg = Release|Any CPU {ACDD9B9E-8FE6-439C-9521-1CCBA47F6143}.Release|Any CPU.Build.0 = Release|Any CPU + {ACDD9B9E-8FE6-439C-9521-1CCBA47F6143}.Release|x64.ActiveCfg = Release|Any CPU + {ACDD9B9E-8FE6-439C-9521-1CCBA47F6143}.Release|x64.Build.0 = Release|Any CPU + {ACDD9B9E-8FE6-439C-9521-1CCBA47F6143}.Release|x86.ActiveCfg = Release|Any CPU + {ACDD9B9E-8FE6-439C-9521-1CCBA47F6143}.Release|x86.Build.0 = Release|Any CPU {BEE737B9-18D5-48D9-8672-9A896213C98B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BEE737B9-18D5-48D9-8672-9A896213C98B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BEE737B9-18D5-48D9-8672-9A896213C98B}.Debug|x64.ActiveCfg = Debug|Any CPU + {BEE737B9-18D5-48D9-8672-9A896213C98B}.Debug|x64.Build.0 = Debug|Any CPU + {BEE737B9-18D5-48D9-8672-9A896213C98B}.Debug|x86.ActiveCfg = Debug|Any CPU + {BEE737B9-18D5-48D9-8672-9A896213C98B}.Debug|x86.Build.0 = Debug|Any CPU {BEE737B9-18D5-48D9-8672-9A896213C98B}.Release|Any CPU.ActiveCfg = Release|Any CPU {BEE737B9-18D5-48D9-8672-9A896213C98B}.Release|Any CPU.Build.0 = Release|Any CPU + {BEE737B9-18D5-48D9-8672-9A896213C98B}.Release|x64.ActiveCfg = Release|Any CPU + {BEE737B9-18D5-48D9-8672-9A896213C98B}.Release|x64.Build.0 = Release|Any CPU + {BEE737B9-18D5-48D9-8672-9A896213C98B}.Release|x86.ActiveCfg = Release|Any CPU + {BEE737B9-18D5-48D9-8672-9A896213C98B}.Release|x86.Build.0 = Release|Any CPU {AD21022F-E7C1-4B74-97C1-0A0E48EFF992}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AD21022F-E7C1-4B74-97C1-0A0E48EFF992}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AD21022F-E7C1-4B74-97C1-0A0E48EFF992}.Debug|x64.ActiveCfg = Debug|Any CPU + {AD21022F-E7C1-4B74-97C1-0A0E48EFF992}.Debug|x64.Build.0 = Debug|Any CPU + {AD21022F-E7C1-4B74-97C1-0A0E48EFF992}.Debug|x86.ActiveCfg = Debug|Any CPU + {AD21022F-E7C1-4B74-97C1-0A0E48EFF992}.Debug|x86.Build.0 = Debug|Any CPU {AD21022F-E7C1-4B74-97C1-0A0E48EFF992}.Release|Any CPU.ActiveCfg = Release|Any CPU {AD21022F-E7C1-4B74-97C1-0A0E48EFF992}.Release|Any CPU.Build.0 = Release|Any CPU + {AD21022F-E7C1-4B74-97C1-0A0E48EFF992}.Release|x64.ActiveCfg = Release|Any CPU + {AD21022F-E7C1-4B74-97C1-0A0E48EFF992}.Release|x64.Build.0 = Release|Any CPU + {AD21022F-E7C1-4B74-97C1-0A0E48EFF992}.Release|x86.ActiveCfg = Release|Any CPU + {AD21022F-E7C1-4B74-97C1-0A0E48EFF992}.Release|x86.Build.0 = Release|Any CPU {8F177DC2-9822-45BD-AB05-1F40FCA86168}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8F177DC2-9822-45BD-AB05-1F40FCA86168}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8F177DC2-9822-45BD-AB05-1F40FCA86168}.Debug|x64.ActiveCfg = Debug|Any CPU + {8F177DC2-9822-45BD-AB05-1F40FCA86168}.Debug|x64.Build.0 = Debug|Any CPU + {8F177DC2-9822-45BD-AB05-1F40FCA86168}.Debug|x86.ActiveCfg = Debug|Any CPU + {8F177DC2-9822-45BD-AB05-1F40FCA86168}.Debug|x86.Build.0 = Debug|Any CPU {8F177DC2-9822-45BD-AB05-1F40FCA86168}.Release|Any CPU.ActiveCfg = Release|Any CPU {8F177DC2-9822-45BD-AB05-1F40FCA86168}.Release|Any CPU.Build.0 = Release|Any CPU + {8F177DC2-9822-45BD-AB05-1F40FCA86168}.Release|x64.ActiveCfg = Release|Any CPU + {8F177DC2-9822-45BD-AB05-1F40FCA86168}.Release|x64.Build.0 = Release|Any CPU + {8F177DC2-9822-45BD-AB05-1F40FCA86168}.Release|x86.ActiveCfg = Release|Any CPU + {8F177DC2-9822-45BD-AB05-1F40FCA86168}.Release|x86.Build.0 = Release|Any CPU {2DFE89D7-0C39-44E9-94CD-496CC985DFC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2DFE89D7-0C39-44E9-94CD-496CC985DFC3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2DFE89D7-0C39-44E9-94CD-496CC985DFC3}.Debug|x64.ActiveCfg = Debug|Any CPU + {2DFE89D7-0C39-44E9-94CD-496CC985DFC3}.Debug|x64.Build.0 = Debug|Any CPU + {2DFE89D7-0C39-44E9-94CD-496CC985DFC3}.Debug|x86.ActiveCfg = Debug|Any CPU + {2DFE89D7-0C39-44E9-94CD-496CC985DFC3}.Debug|x86.Build.0 = Debug|Any CPU {2DFE89D7-0C39-44E9-94CD-496CC985DFC3}.Release|Any CPU.ActiveCfg = Release|Any CPU {2DFE89D7-0C39-44E9-94CD-496CC985DFC3}.Release|Any CPU.Build.0 = Release|Any CPU + {2DFE89D7-0C39-44E9-94CD-496CC985DFC3}.Release|x64.ActiveCfg = Release|Any CPU + {2DFE89D7-0C39-44E9-94CD-496CC985DFC3}.Release|x64.Build.0 = Release|Any CPU + {2DFE89D7-0C39-44E9-94CD-496CC985DFC3}.Release|x86.ActiveCfg = Release|Any CPU + {2DFE89D7-0C39-44E9-94CD-496CC985DFC3}.Release|x86.Build.0 = Release|Any CPU {2F1071BF-891C-42A3-8A82-6B8A168BDE64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2F1071BF-891C-42A3-8A82-6B8A168BDE64}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F1071BF-891C-42A3-8A82-6B8A168BDE64}.Debug|x64.ActiveCfg = Debug|Any CPU + {2F1071BF-891C-42A3-8A82-6B8A168BDE64}.Debug|x64.Build.0 = Debug|Any CPU + {2F1071BF-891C-42A3-8A82-6B8A168BDE64}.Debug|x86.ActiveCfg = Debug|Any CPU + {2F1071BF-891C-42A3-8A82-6B8A168BDE64}.Debug|x86.Build.0 = Debug|Any CPU {2F1071BF-891C-42A3-8A82-6B8A168BDE64}.Release|Any CPU.ActiveCfg = Release|Any CPU {2F1071BF-891C-42A3-8A82-6B8A168BDE64}.Release|Any CPU.Build.0 = Release|Any CPU + {2F1071BF-891C-42A3-8A82-6B8A168BDE64}.Release|x64.ActiveCfg = Release|Any CPU + {2F1071BF-891C-42A3-8A82-6B8A168BDE64}.Release|x64.Build.0 = Release|Any CPU + {2F1071BF-891C-42A3-8A82-6B8A168BDE64}.Release|x86.ActiveCfg = Release|Any CPU + {2F1071BF-891C-42A3-8A82-6B8A168BDE64}.Release|x86.Build.0 = Release|Any CPU + {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Debug|Any CPU.ActiveCfg = Debug|x64 + {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Debug|Any CPU.Build.0 = Debug|x64 + {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Debug|x64.ActiveCfg = Debug|x64 + {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Debug|x64.Build.0 = Debug|x64 + {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Debug|x86.ActiveCfg = Debug|Win32 + {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Debug|x86.Build.0 = Debug|Win32 + {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Release|Any CPU.ActiveCfg = Release|x64 + {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Release|Any CPU.Build.0 = Release|x64 + {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Release|x64.ActiveCfg = Release|x64 + {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Release|x64.Build.0 = Release|x64 + {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Release|x86.ActiveCfg = Release|Win32 + {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -213,6 +351,7 @@ Global {B8A5415F-9DF1-4BE3-AE4C-B3423764C6DC} = {18794F51-C0FB-4F30-AC4A-39BCE6937DD9} {11738435-FAB8-4E7A-BCD8-0D5D53302181} = {18794F51-C0FB-4F30-AC4A-39BCE6937DD9} {426817C8-2747-49E6-8060-245E05FFAEC0} = {18794F51-C0FB-4F30-AC4A-39BCE6937DD9} + {0BDA76B0-44BF-47B7-AA21-C247F83FAF73} = {26425961-0A4E-4CFA-9F45-9072AD6FA6F1} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {981EA700-AB4F-462F-96D7-F35FAAAA7E89} diff --git a/tests/ctypes/_ctypes_test.vcxproj b/tests/ctypes/_ctypes_test.vcxproj index d7fd2b3e3..367bef970 100644 --- a/tests/ctypes/_ctypes_test.vcxproj +++ b/tests/ctypes/_ctypes_test.vcxproj @@ -24,6 +24,7 @@ Win32Proj ctypestest 10.0.17134.0 + IronPython.Tests.CTypes From d4ea59c978c52ac1c567afe7b51ba2978f5eaa86 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:22:02 +0000 Subject: [PATCH 45/84] Retarget CTypes project to latest platform toolset --- tests/ctypes/_ctypes_test.vcxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/ctypes/_ctypes_test.vcxproj b/tests/ctypes/_ctypes_test.vcxproj index 367bef970..b8025b8c0 100644 --- a/tests/ctypes/_ctypes_test.vcxproj +++ b/tests/ctypes/_ctypes_test.vcxproj @@ -30,26 +30,26 @@ DynamicLibrary true - v141 + v143 Unicode DynamicLibrary false - v141 + v143 true Unicode DynamicLibrary true - v141 + v143 Unicode DynamicLibrary false - v141 + v143 true Unicode From 928006e6edfc719c1a68b75d193b84af85e666d0 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:23:17 +0000 Subject: [PATCH 46/84] Rename CTypes project why did it not actually rename --- IronPython.sln | 3 +- ...cxproj => IronPython.Tests.CTypes.vcxproj} | 0 .../IronPython.Tests.CTypes.vcxproj.user | 4 +++ tests/ctypes/_ctypes_test.sln | 31 ------------------- 4 files changed, 5 insertions(+), 33 deletions(-) rename tests/ctypes/{_ctypes_test.vcxproj => IronPython.Tests.CTypes.vcxproj} (100%) create mode 100644 tests/ctypes/IronPython.Tests.CTypes.vcxproj.user delete mode 100644 tests/ctypes/_ctypes_test.sln diff --git a/IronPython.sln b/IronPython.sln index 32f1c93b7..57b7123de 100644 --- a/IronPython.sln +++ b/IronPython.sln @@ -115,7 +115,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "roslyn", "roslyn", "{426817 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{26425961-0A4E-4CFA-9F45-9072AD6FA6F1}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ctypes_test", "tests\ctypes\_ctypes_test.vcxproj", "{0BDA76B0-44BF-47B7-AA21-C247F83FAF73}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IronPython.Tests.CTypes", "tests\ctypes\IronPython.Tests.CTypes.vcxproj", "{0BDA76B0-44BF-47B7-AA21-C247F83FAF73}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -351,7 +351,6 @@ Global {B8A5415F-9DF1-4BE3-AE4C-B3423764C6DC} = {18794F51-C0FB-4F30-AC4A-39BCE6937DD9} {11738435-FAB8-4E7A-BCD8-0D5D53302181} = {18794F51-C0FB-4F30-AC4A-39BCE6937DD9} {426817C8-2747-49E6-8060-245E05FFAEC0} = {18794F51-C0FB-4F30-AC4A-39BCE6937DD9} - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73} = {26425961-0A4E-4CFA-9F45-9072AD6FA6F1} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {981EA700-AB4F-462F-96D7-F35FAAAA7E89} diff --git a/tests/ctypes/_ctypes_test.vcxproj b/tests/ctypes/IronPython.Tests.CTypes.vcxproj similarity index 100% rename from tests/ctypes/_ctypes_test.vcxproj rename to tests/ctypes/IronPython.Tests.CTypes.vcxproj diff --git a/tests/ctypes/IronPython.Tests.CTypes.vcxproj.user b/tests/ctypes/IronPython.Tests.CTypes.vcxproj.user new file mode 100644 index 000000000..88a550947 --- /dev/null +++ b/tests/ctypes/IronPython.Tests.CTypes.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/tests/ctypes/_ctypes_test.sln b/tests/ctypes/_ctypes_test.sln deleted file mode 100644 index 1c9000c93..000000000 --- a/tests/ctypes/_ctypes_test.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27703.2000 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ctypes_test", "_ctypes_test.vcxproj", "{0BDA76B0-44BF-47B7-AA21-C247F83FAF73}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Debug|x64.ActiveCfg = Debug|x64 - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Debug|x64.Build.0 = Debug|x64 - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Debug|x86.ActiveCfg = Debug|Win32 - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Debug|x86.Build.0 = Debug|Win32 - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Release|x64.ActiveCfg = Release|x64 - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Release|x64.Build.0 = Release|x64 - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Release|x86.ActiveCfg = Release|Win32 - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {D6D984C3-CAF5-4D08-9E0F-3691152F7691} - EndGlobalSection -EndGlobal From 976ad6e7b3362fffe7ae0f5252cf28626a24dbb9 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:25:52 +0000 Subject: [PATCH 47/84] Initial rename of platforms folder --- .../IronPython.Console.Host.csproj | 0 .../IronPython.Console.Host/IronPythonWindow.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../IronPython.Console.Host/ipyw.ico | Bin .../IronPython.Console/Console.cs | 0 .../IronPython.Console/IronPython.Console.csproj | 0 .../IronPython.Console/Properties/AssemblyInfo.cs | 0 .../IronPython.Console/app.manifest | 0 .../IronPython.Console/ipy-mono.sh | 0 .../IronPython.Console/ipy.ico | Bin .../IronPython.Console/ipy.sh | 0 .../IronPython.Console/runtimeconfig.template.json | 0 .../IronPython.Console32.Host.csproj | 0 .../IronPython.Console32.csproj | 0 src/{console => platforms}/README.md | 0 15 files changed, 0 insertions(+), 0 deletions(-) rename src/{console => platforms}/IronPython.Console.Host/IronPython.Console.Host.csproj (100%) rename src/{console => platforms}/IronPython.Console.Host/IronPythonWindow.cs (100%) rename src/{console => platforms}/IronPython.Console.Host/Properties/AssemblyInfo.cs (100%) rename src/{console => platforms}/IronPython.Console.Host/ipyw.ico (100%) rename src/{console => platforms}/IronPython.Console/Console.cs (100%) rename src/{console => platforms}/IronPython.Console/IronPython.Console.csproj (100%) rename src/{console => platforms}/IronPython.Console/Properties/AssemblyInfo.cs (100%) rename src/{console => platforms}/IronPython.Console/app.manifest (100%) rename src/{console => platforms}/IronPython.Console/ipy-mono.sh (100%) rename src/{console => platforms}/IronPython.Console/ipy.ico (100%) rename src/{console => platforms}/IronPython.Console/ipy.sh (100%) rename src/{console => platforms}/IronPython.Console/runtimeconfig.template.json (100%) rename src/{console => platforms}/IronPython.Console32.Host/IronPython.Console32.Host.csproj (100%) rename src/{console => platforms}/IronPython.Console32/IronPython.Console32.csproj (100%) rename src/{console => platforms}/README.md (100%) diff --git a/src/console/IronPython.Console.Host/IronPython.Console.Host.csproj b/src/platforms/IronPython.Console.Host/IronPython.Console.Host.csproj similarity index 100% rename from src/console/IronPython.Console.Host/IronPython.Console.Host.csproj rename to src/platforms/IronPython.Console.Host/IronPython.Console.Host.csproj diff --git a/src/console/IronPython.Console.Host/IronPythonWindow.cs b/src/platforms/IronPython.Console.Host/IronPythonWindow.cs similarity index 100% rename from src/console/IronPython.Console.Host/IronPythonWindow.cs rename to src/platforms/IronPython.Console.Host/IronPythonWindow.cs diff --git a/src/console/IronPython.Console.Host/Properties/AssemblyInfo.cs b/src/platforms/IronPython.Console.Host/Properties/AssemblyInfo.cs similarity index 100% rename from src/console/IronPython.Console.Host/Properties/AssemblyInfo.cs rename to src/platforms/IronPython.Console.Host/Properties/AssemblyInfo.cs diff --git a/src/console/IronPython.Console.Host/ipyw.ico b/src/platforms/IronPython.Console.Host/ipyw.ico similarity index 100% rename from src/console/IronPython.Console.Host/ipyw.ico rename to src/platforms/IronPython.Console.Host/ipyw.ico diff --git a/src/console/IronPython.Console/Console.cs b/src/platforms/IronPython.Console/Console.cs similarity index 100% rename from src/console/IronPython.Console/Console.cs rename to src/platforms/IronPython.Console/Console.cs diff --git a/src/console/IronPython.Console/IronPython.Console.csproj b/src/platforms/IronPython.Console/IronPython.Console.csproj similarity index 100% rename from src/console/IronPython.Console/IronPython.Console.csproj rename to src/platforms/IronPython.Console/IronPython.Console.csproj diff --git a/src/console/IronPython.Console/Properties/AssemblyInfo.cs b/src/platforms/IronPython.Console/Properties/AssemblyInfo.cs similarity index 100% rename from src/console/IronPython.Console/Properties/AssemblyInfo.cs rename to src/platforms/IronPython.Console/Properties/AssemblyInfo.cs diff --git a/src/console/IronPython.Console/app.manifest b/src/platforms/IronPython.Console/app.manifest similarity index 100% rename from src/console/IronPython.Console/app.manifest rename to src/platforms/IronPython.Console/app.manifest diff --git a/src/console/IronPython.Console/ipy-mono.sh b/src/platforms/IronPython.Console/ipy-mono.sh similarity index 100% rename from src/console/IronPython.Console/ipy-mono.sh rename to src/platforms/IronPython.Console/ipy-mono.sh diff --git a/src/console/IronPython.Console/ipy.ico b/src/platforms/IronPython.Console/ipy.ico similarity index 100% rename from src/console/IronPython.Console/ipy.ico rename to src/platforms/IronPython.Console/ipy.ico diff --git a/src/console/IronPython.Console/ipy.sh b/src/platforms/IronPython.Console/ipy.sh similarity index 100% rename from src/console/IronPython.Console/ipy.sh rename to src/platforms/IronPython.Console/ipy.sh diff --git a/src/console/IronPython.Console/runtimeconfig.template.json b/src/platforms/IronPython.Console/runtimeconfig.template.json similarity index 100% rename from src/console/IronPython.Console/runtimeconfig.template.json rename to src/platforms/IronPython.Console/runtimeconfig.template.json diff --git a/src/console/IronPython.Console32.Host/IronPython.Console32.Host.csproj b/src/platforms/IronPython.Console32.Host/IronPython.Console32.Host.csproj similarity index 100% rename from src/console/IronPython.Console32.Host/IronPython.Console32.Host.csproj rename to src/platforms/IronPython.Console32.Host/IronPython.Console32.Host.csproj diff --git a/src/console/IronPython.Console32/IronPython.Console32.csproj b/src/platforms/IronPython.Console32/IronPython.Console32.csproj similarity index 100% rename from src/console/IronPython.Console32/IronPython.Console32.csproj rename to src/platforms/IronPython.Console32/IronPython.Console32.csproj diff --git a/src/console/README.md b/src/platforms/README.md similarity index 100% rename from src/console/README.md rename to src/platforms/README.md From de79b5d24e7b658c0d4e333e22147ac0cc5bb624 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:27:16 +0000 Subject: [PATCH 48/84] Fix project reference in solution --- IronPython.sln | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/IronPython.sln b/IronPython.sln index 57b7123de..0ec662003 100644 --- a/IronPython.sln +++ b/IronPython.sln @@ -9,11 +9,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Modules", "src\c EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Wpf", "src\extensions\IronPython.Wpf\IronPython.Wpf.csproj", "{65E997B7-E99B-4C83-B29E-9951429BB293}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console", "src\console\IronPython.Console\IronPython.Console.csproj", "{811AC32C-11F3-4ED8-92A7-A7E39C2BB704}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console", "src\platforms\IronPython.Console\IronPython.Console.csproj", "{811AC32C-11F3-4ED8-92A7-A7E39C2BB704}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Tests", "tests\ironpython\IronPython.Tests.csproj", "{B6B42537-07F8-4F6C-A99A-B155CAEB124E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console.Host", "src\console\IronPython.Console.Host\IronPython.Console.Host.csproj", "{81DA19C7-4FEC-47E7-981B-D9310D549F95}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console.Host", "src\platforms\IronPython.Console.Host\IronPython.Console.Host.csproj", "{81DA19C7-4FEC-47E7-981B-D9310D549F95}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{3A14D070-628F-44EF-92DD-47C8BE5C33CD}" ProjectSection(SolutionItems) = preProject @@ -64,7 +64,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nuget", "nuget", "{EE77D917 eng\nuget\IronPython.StdLib.nuspec = eng\nuget\IronPython.StdLib.nuspec EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32", "src\console\IronPython.Console32\IronPython.Console32.csproj", "{AD21022F-E7C1-4B74-97C1-0A0E48EFF992}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32", "src\platforms\IronPython.Console32\IronPython.Console32.csproj", "{AD21022F-E7C1-4B74-97C1-0A0E48EFF992}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "choco", "choco", "{EA550FD8-2241-4131-8292-619D009E0199}" ProjectSection(SolutionItems) = preProject @@ -97,7 +97,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "msi", "msi", "{450F93D5-DF0 eng\msi\Version.wxi = eng\msi\Version.wxi EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32.Host", "src\console\IronPython.Console32.Host\IronPython.Console32.Host.csproj", "{8F177DC2-9822-45BD-AB05-1F40FCA86168}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console32.Host", "src\platforms\IronPython.Console32.Host\IronPython.Console32.Host.csproj", "{8F177DC2-9822-45BD-AB05-1F40FCA86168}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronPython.DiagnosticAnalyzer", "src\roslyn\IronPython.DiagnosticAnalyzer\IronPython.DiagnosticAnalyzer.csproj", "{2DFE89D7-0C39-44E9-94CD-496CC985DFC3}" EndProject From d2ad1fc53fc117fe973d01ad63196bc35e86d504 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:28:25 +0000 Subject: [PATCH 49/84] Rename solution folders --- IronPython.sln | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/IronPython.sln b/IronPython.sln index 0ec662003..66e388a61 100644 --- a/IronPython.sln +++ b/IronPython.sln @@ -105,9 +105,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronPython.SQLite", "src\ex EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{18794F51-C0FB-4F30-AC4A-39BCE6937DD9}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "console", "console", "{9DC5996F-F2AB-41AA-9B17-C004CB3AB288}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "platforms", "platforms", "{9DC5996F-F2AB-41AA-9B17-C004CB3AB288}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ipy", "ipy", "{B8A5415F-9DF1-4BE3-AE4C-B3423764C6DC}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "core", "core", "{B8A5415F-9DF1-4BE3-AE4C-B3423764C6DC}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "extensions", "extensions", "{11738435-FAB8-4E7A-BCD8-0D5D53302181}" EndProject @@ -351,6 +351,7 @@ Global {B8A5415F-9DF1-4BE3-AE4C-B3423764C6DC} = {18794F51-C0FB-4F30-AC4A-39BCE6937DD9} {11738435-FAB8-4E7A-BCD8-0D5D53302181} = {18794F51-C0FB-4F30-AC4A-39BCE6937DD9} {426817C8-2747-49E6-8060-245E05FFAEC0} = {18794F51-C0FB-4F30-AC4A-39BCE6937DD9} + {0BDA76B0-44BF-47B7-AA21-C247F83FAF73} = {26425961-0A4E-4CFA-9F45-9072AD6FA6F1} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {981EA700-AB4F-462F-96D7-F35FAAAA7E89} From 1b307a032ff5bc18c7bbefc719e934d6962a8a1c Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:30:05 +0000 Subject: [PATCH 50/84] Move compiler project to slozier's request --- .../IronPython.CompilerServices/AssemblyResolver.cs | 0 src/{core => platforms}/IronPython.CompilerServices/Config.cs | 0 src/{core => platforms}/IronPython.CompilerServices/ConsoleOps.cs | 0 .../IronPython.CompilerServices.csproj | 0 src/{core => platforms}/IronPython.CompilerServices/Program.cs | 0 .../IronPython.CompilerServices/Properties/AssemblyInfo.cs | 0 src/{core => platforms}/IronPython.CompilerServices/README.md | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename src/{core => platforms}/IronPython.CompilerServices/AssemblyResolver.cs (100%) rename src/{core => platforms}/IronPython.CompilerServices/Config.cs (100%) rename src/{core => platforms}/IronPython.CompilerServices/ConsoleOps.cs (100%) rename src/{core => platforms}/IronPython.CompilerServices/IronPython.CompilerServices.csproj (100%) rename src/{core => platforms}/IronPython.CompilerServices/Program.cs (100%) rename src/{core => platforms}/IronPython.CompilerServices/Properties/AssemblyInfo.cs (100%) rename src/{core => platforms}/IronPython.CompilerServices/README.md (100%) diff --git a/src/core/IronPython.CompilerServices/AssemblyResolver.cs b/src/platforms/IronPython.CompilerServices/AssemblyResolver.cs similarity index 100% rename from src/core/IronPython.CompilerServices/AssemblyResolver.cs rename to src/platforms/IronPython.CompilerServices/AssemblyResolver.cs diff --git a/src/core/IronPython.CompilerServices/Config.cs b/src/platforms/IronPython.CompilerServices/Config.cs similarity index 100% rename from src/core/IronPython.CompilerServices/Config.cs rename to src/platforms/IronPython.CompilerServices/Config.cs diff --git a/src/core/IronPython.CompilerServices/ConsoleOps.cs b/src/platforms/IronPython.CompilerServices/ConsoleOps.cs similarity index 100% rename from src/core/IronPython.CompilerServices/ConsoleOps.cs rename to src/platforms/IronPython.CompilerServices/ConsoleOps.cs diff --git a/src/core/IronPython.CompilerServices/IronPython.CompilerServices.csproj b/src/platforms/IronPython.CompilerServices/IronPython.CompilerServices.csproj similarity index 100% rename from src/core/IronPython.CompilerServices/IronPython.CompilerServices.csproj rename to src/platforms/IronPython.CompilerServices/IronPython.CompilerServices.csproj diff --git a/src/core/IronPython.CompilerServices/Program.cs b/src/platforms/IronPython.CompilerServices/Program.cs similarity index 100% rename from src/core/IronPython.CompilerServices/Program.cs rename to src/platforms/IronPython.CompilerServices/Program.cs diff --git a/src/core/IronPython.CompilerServices/Properties/AssemblyInfo.cs b/src/platforms/IronPython.CompilerServices/Properties/AssemblyInfo.cs similarity index 100% rename from src/core/IronPython.CompilerServices/Properties/AssemblyInfo.cs rename to src/platforms/IronPython.CompilerServices/Properties/AssemblyInfo.cs diff --git a/src/core/IronPython.CompilerServices/README.md b/src/platforms/IronPython.CompilerServices/README.md similarity index 100% rename from src/core/IronPython.CompilerServices/README.md rename to src/platforms/IronPython.CompilerServices/README.md From 2094fb5a6acd032a40c08eee7ef177b4b4c7f474 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:34:01 +0000 Subject: [PATCH 51/84] Fix project references --- IronPython.sln | 2 +- .../IronPython.CompilerServices.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/IronPython.sln b/IronPython.sln index 66e388a61..d076a649b 100644 --- a/IronPython.sln +++ b/IronPython.sln @@ -44,7 +44,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "eng", "eng", "{17737ACB-40C eng\Tasks.Targets = eng\Tasks.Targets EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.CompilerServices", "src\core\IronPython.CompilerServices\IronPython.CompilerServices.csproj", "{3DFB096E-AC09-4E7A-9288-7F7C33C288C7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.CompilerServices", "src\platforms\IronPython.CompilerServices\IronPython.CompilerServices.csproj", "{3DFB096E-AC09-4E7A-9288-7F7C33C288C7}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "runtime", "runtime", "{AC38EFB1-820D-4E90-BF40-BEF3AC825542}" EndProject diff --git a/src/platforms/IronPython.CompilerServices/IronPython.CompilerServices.csproj b/src/platforms/IronPython.CompilerServices/IronPython.CompilerServices.csproj index f0704e5b5..6a0776309 100644 --- a/src/platforms/IronPython.CompilerServices/IronPython.CompilerServices.csproj +++ b/src/platforms/IronPython.CompilerServices/IronPython.CompilerServices.csproj @@ -10,7 +10,7 @@ - + From 2dbfd7b74afc1ed9ce1717a0f833c8ec4fd8131c Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:34:38 +0000 Subject: [PATCH 52/84] Remove CTypes project from solution why I added it wasn't clear in the first place brilliant that I don't know the tiniest bit of C --- IronPython.sln | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/IronPython.sln b/IronPython.sln index d076a649b..93cdb4c66 100644 --- a/IronPython.sln +++ b/IronPython.sln @@ -115,8 +115,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "roslyn", "roslyn", "{426817 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{26425961-0A4E-4CFA-9F45-9072AD6FA6F1}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IronPython.Tests.CTypes", "tests\ctypes\IronPython.Tests.CTypes.vcxproj", "{0BDA76B0-44BF-47B7-AA21-C247F83FAF73}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -307,18 +305,6 @@ Global {2F1071BF-891C-42A3-8A82-6B8A168BDE64}.Release|x64.Build.0 = Release|Any CPU {2F1071BF-891C-42A3-8A82-6B8A168BDE64}.Release|x86.ActiveCfg = Release|Any CPU {2F1071BF-891C-42A3-8A82-6B8A168BDE64}.Release|x86.Build.0 = Release|Any CPU - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Debug|Any CPU.ActiveCfg = Debug|x64 - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Debug|Any CPU.Build.0 = Debug|x64 - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Debug|x64.ActiveCfg = Debug|x64 - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Debug|x64.Build.0 = Debug|x64 - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Debug|x86.ActiveCfg = Debug|Win32 - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Debug|x86.Build.0 = Debug|Win32 - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Release|Any CPU.ActiveCfg = Release|x64 - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Release|Any CPU.Build.0 = Release|x64 - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Release|x64.ActiveCfg = Release|x64 - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Release|x64.Build.0 = Release|x64 - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Release|x86.ActiveCfg = Release|Win32 - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -351,7 +337,6 @@ Global {B8A5415F-9DF1-4BE3-AE4C-B3423764C6DC} = {18794F51-C0FB-4F30-AC4A-39BCE6937DD9} {11738435-FAB8-4E7A-BCD8-0D5D53302181} = {18794F51-C0FB-4F30-AC4A-39BCE6937DD9} {426817C8-2747-49E6-8060-245E05FFAEC0} = {18794F51-C0FB-4F30-AC4A-39BCE6937DD9} - {0BDA76B0-44BF-47B7-AA21-C247F83FAF73} = {26425961-0A4E-4CFA-9F45-9072AD6FA6F1} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {981EA700-AB4F-462F-96D7-F35FAAAA7E89} From 3a2e84add6135262dc929dae3acf760758b96726 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:38:30 +0000 Subject: [PATCH 53/84] Fix references to documentation won't matter after #1812 --- CONTRIBUTING.md | 6 +++--- README.md | 10 +++++----- docs/installing.md | 2 +- eng/choco/README.md | 4 ++-- eng/dotnettool/IronPython.Console.csproj | 2 +- eng/dotnettool/README.md | 4 ++-- eng/nuget/IronPython.StdLib.nuspec | 2 +- eng/nuget/IronPython.nuspec | 2 +- eng/nuget/README.md | 4 ++-- eng/zip/README.md | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 03064d297..8d7e2bb80 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,9 +2,9 @@ The steps to contribute a change are: -1. Fork the IronPython3 repository. For more information see [Getting the Sources](Documentation/getting-the-sources.md). -2. Build the repository. For more information see [Building](Documentation/building.md). -1. Make your changes on your machine, ensure ```make.ps1 test-all``` runs successfully, and commit your changes. For more information see [Modifying the Sources](Documentation/modifying-the-sources.md). +1. Fork the IronPython3 repository. For more information see [Getting the Sources](docs/getting-the-sources.md). +2. Build the repository. For more information see [Building](docs/building.md). +1. Make your changes on your machine, ensure ```make.ps1 test-all``` runs successfully, and commit your changes. For more information see [Modifying the Sources](docs/modifying-the-sources.md). 1. Push the commits to your fork. This way your name will be the author of the commit in the main IronPython3 tree (once the commits are pulled into the main tree). 1. Create a pull request on Github, this will initiate a code review and CLA signing request 1. The IronPython team will review, and possibly request changes, to your PR diff --git a/README.md b/README.md index 6d53eb37c..a88ad569c 100644 --- a/README.md +++ b/README.md @@ -71,19 +71,19 @@ See the following lists for features from each version of CPython that have been For details on contributing see the [Contributing](CONTRIBUTING.md) article. ## Upgrading from IronPython 2 -For details on upgrading from IronPython 2 to 3 see the [Upgrading from IronPython 2 to 3](Documentation/upgrading-from-ipy2.md) article. +For details on upgrading from IronPython 2 to 3 see the [Upgrading from IronPython 2 to 3](docs/upgrading-from-ipy2.md) article. ## Differences with CPython -While compatibility with CPython is one of our main goals with IronPython 3, there are still some differences that may cause issues. See [Differences from CPython](Documentation/differences-from-c-python.md) for details. +While compatibility with CPython is one of our main goals with IronPython 3, there are still some differences that may cause issues. See [Differences from CPython](docs/differences-from-c-python.md) for details. ## Package compatibility -See the [Package compatibility](Documentation/package-compatibility.md) document for information on compatibility with popular packages. +See the [Package compatibility](docs/package-compatibility.md) document for information on compatibility with popular packages. ## Installation -Binaries of IronPython 3 can be downloaded from the [release page](https://github.com/IronLanguages/ironpython3/releases/latest), available in various formats: `.msi`, `.zip`, `.deb`, `.pkg`. The IronPython package is also available on [NuGet](https://www.nuget.org/packages/IronPython/3.4.0). See the [installation document](Documentation/installing.md) for detailed instructions on how to install a standalone IronPython interpreter on various operating systems and .NET frameworks. +Binaries of IronPython 3 can be downloaded from the [release page](https://github.com/IronLanguages/ironpython3/releases/latest), available in various formats: `.msi`, `.zip`, `.deb`, `.pkg`. The IronPython package is also available on [NuGet](https://www.nuget.org/packages/IronPython/3.4.0). See the [installation document](docs/installing.md) for detailed instructions on how to install a standalone IronPython interpreter on various operating systems and .NET frameworks. ## Build -See the [building document](Documentation/building.md). Since the main development is on Windows, bugs on other platforms may inadvertently be introduced - please report them! +See the [building document](docs/building.md). Since the main development is on Windows, bugs on other platforms may inadvertently be introduced - please report them! ## Supported Platforms IronPython 3 targets .NET Framework 4.6.2, .NET Standard 2.0 and .NET 6.0. The support for .NET and .NET Core follow the lifecycle defined on [.NET and .NET Core Support Policy](https://dotnet.microsoft.com/platform/support/policy/dotnet-core). diff --git a/docs/installing.md b/docs/installing.md index 7371f20c5..48c7f7c4f 100644 --- a/docs/installing.md +++ b/docs/installing.md @@ -158,7 +158,7 @@ Go to the project's [_Actions_ page](https://github.com/IronLanguages/ironpython # Installing from Sources -To build and install IronPython from sources, first follow instructions in [_Getting the Sources_](https://github.com/IronLanguages/ironpython3/blob/main/Documentation/getting-the-sources.md) and [_Building IronPython3_](https://github.com/IronLanguages/ironpython3/blob/main/Documentation/building.md). +To build and install IronPython from sources, first follow instructions in [_Getting the Sources_](https://github.com/IronLanguages/ironpython3/blob/main/docs/getting-the-sources.md) and [_Building IronPython3_](https://github.com/IronLanguages/ironpython3/blob/main/docs/building.md). When the command `./make.ps1 debug` completes successfully, runnable and usable `ipy` executables are available in subdirectories of `./bin/Debug`. To run executables from the release configuration (produced by a successful run of `./make.ps1`), first set environment variable `IRONPYTHONPATH`. diff --git a/eng/choco/README.md b/eng/choco/README.md index fbd5d23a1..a7d3adba0 100644 --- a/eng/choco/README.md +++ b/eng/choco/README.md @@ -9,7 +9,7 @@ The current target is Python 3.4, although features and behaviors from later ver ## Differences with CPython -While compatibility with CPython is one of our main goals with IronPython 3, there are still some differences that may cause issues. See [Differences from CPython](https://github.com/IronLanguages/ironpython3/blob/main/Documentation/differences-from-c-python.md) for details. +While compatibility with CPython is one of our main goals with IronPython 3, there are still some differences that may cause issues. See [Differences from CPython](https://github.com/IronLanguages/ironpython3/blob/main/docs/differences-from-c-python.md) for details. ## Package compatibility -See the [Package compatibility](https://github.com/IronLanguages/ironpython3/blob/main/Documentation/package-compatibility.md) document for information on compatibility with popular Python packages. +See the [Package compatibility](https://github.com/IronLanguages/ironpython3/blob/main/docs/package-compatibility.md) document for information on compatibility with popular Python packages. diff --git a/eng/dotnettool/IronPython.Console.csproj b/eng/dotnettool/IronPython.Console.csproj index 9fb8878c3..526bc7097 100644 --- a/eng/dotnettool/IronPython.Console.csproj +++ b/eng/dotnettool/IronPython.Console.csproj @@ -55,7 +55,7 @@ This package contains a standalone Python interpreter, invokable from the comman - + diff --git a/eng/dotnettool/README.md b/eng/dotnettool/README.md index f6e7118d2..690f64324 100644 --- a/eng/dotnettool/README.md +++ b/eng/dotnettool/README.md @@ -9,8 +9,8 @@ The current target is Python 3.4, although features and behaviors from later ver ## Differences with CPython -While compatibility with CPython is one of our main goals with IronPython 3, there are still some differences that may cause issues. See [Differences from CPython](https://github.com/IronLanguages/ironpython3/blob/main/Documentation/differences-from-c-python.md) for details. +While compatibility with CPython is one of our main goals with IronPython 3, there are still some differences that may cause issues. See [Differences from CPython](https://github.com/IronLanguages/ironpython3/blob/main/docs/differences-from-c-python.md) for details. ## Package compatibility -See the [Package compatibility](https://github.com/IronLanguages/ironpython3/blob/main/Documentation/package-compatibility.md) document for information on compatibility with popular Python packages. +See the [Package compatibility](https://github.com/IronLanguages/ironpython3/blob/main/docs/package-compatibility.md) document for information on compatibility with popular Python packages. diff --git a/eng/nuget/IronPython.StdLib.nuspec b/eng/nuget/IronPython.StdLib.nuspec index f62df7e74..b3b8ce2c3 100644 --- a/eng/nuget/IronPython.StdLib.nuspec +++ b/eng/nuget/IronPython.StdLib.nuspec @@ -24,6 +24,6 @@ - + diff --git a/eng/nuget/IronPython.nuspec b/eng/nuget/IronPython.nuspec index 8711f555a..0799d41fe 100644 --- a/eng/nuget/IronPython.nuspec +++ b/eng/nuget/IronPython.nuspec @@ -45,6 +45,6 @@ This package contains the IronPython interpreter engine. - + diff --git a/eng/nuget/README.md b/eng/nuget/README.md index 0365dcb75..afcc1f187 100644 --- a/eng/nuget/README.md +++ b/eng/nuget/README.md @@ -22,8 +22,8 @@ System.Console.WriteLine(greetings("world")); ## Differences with CPython -While compatibility with CPython is one of our main goals with IronPython 3, there are still some differences that may cause issues. See [Differences from CPython](https://github.com/IronLanguages/ironpython3/blob/main/Documentation/differences-from-c-python.md) for details. +While compatibility with CPython is one of our main goals with IronPython 3, there are still some differences that may cause issues. See [Differences from CPython](https://github.com/IronLanguages/ironpython3/blob/main/docs/differences-from-c-python.md) for details. ## Package compatibility -See the [Package compatibility](https://github.com/IronLanguages/ironpython3/blob/main/Documentation/package-compatibility.md) document for information on compatibility with popular Python packages. Note that to run most packages, IronPython Standard Library must be present. +See the [Package compatibility](https://github.com/IronLanguages/ironpython3/blob/main/docs/package-compatibility.md) document for information on compatibility with popular Python packages. Note that to run most packages, IronPython Standard Library must be present. diff --git a/eng/zip/README.md b/eng/zip/README.md index a39ca5ec6..e245c0305 100644 --- a/eng/zip/README.md +++ b/eng/zip/README.md @@ -50,8 +50,8 @@ System.Console.WriteLine(greetings("world")); ## Differences with CPython -While compatibility with CPython is one of our main goals with IronPython 3, there are still some differences that may cause issues. See [Differences from CPython](https://github.com/IronLanguages/ironpython3/blob/main/Documentation/differences-from-c-python.md) for details. +While compatibility with CPython is one of our main goals with IronPython 3, there are still some differences that may cause issues. See [Differences from CPython](https://github.com/IronLanguages/ironpython3/blob/main/docs/differences-from-c-python.md) for details. ## Package compatibility -See the [Package compatibility](https://github.com/IronLanguages/ironpython3/blob/main/Documentation/package-compatibility.md) document for information on compatibility with popular packages. Note that to run most packages, IronPython Standard Library must be present. +See the [Package compatibility](https://github.com/IronLanguages/ironpython3/blob/main/docs/package-compatibility.md) document for information on compatibility with popular packages. Note that to run most packages, IronPython Standard Library must be present. From 7aa1e90dd4f6915c97ba0a658c20fdf36a63c8fa Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:40:43 +0000 Subject: [PATCH 54/84] Simplify compiler project name --- IronPython.sln | 2 +- .../AssemblyResolver.cs | 0 .../Config.cs | 0 .../ConsoleOps.cs | 0 .../IronPython.Compiler.csproj} | 0 .../Program.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../README.md | 0 8 files changed, 1 insertion(+), 1 deletion(-) rename src/platforms/{IronPython.CompilerServices => IronPython.Compiler}/AssemblyResolver.cs (100%) rename src/platforms/{IronPython.CompilerServices => IronPython.Compiler}/Config.cs (100%) rename src/platforms/{IronPython.CompilerServices => IronPython.Compiler}/ConsoleOps.cs (100%) rename src/platforms/{IronPython.CompilerServices/IronPython.CompilerServices.csproj => IronPython.Compiler/IronPython.Compiler.csproj} (100%) rename src/platforms/{IronPython.CompilerServices => IronPython.Compiler}/Program.cs (100%) rename src/platforms/{IronPython.CompilerServices => IronPython.Compiler}/Properties/AssemblyInfo.cs (100%) rename src/platforms/{IronPython.CompilerServices => IronPython.Compiler}/README.md (100%) diff --git a/IronPython.sln b/IronPython.sln index 93cdb4c66..8eac9bc6f 100644 --- a/IronPython.sln +++ b/IronPython.sln @@ -44,7 +44,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "eng", "eng", "{17737ACB-40C eng\Tasks.Targets = eng\Tasks.Targets EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.CompilerServices", "src\platforms\IronPython.CompilerServices\IronPython.CompilerServices.csproj", "{3DFB096E-AC09-4E7A-9288-7F7C33C288C7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Compiler", "src\platforms\IronPython.Compiler\IronPython.Compiler.csproj", "{3DFB096E-AC09-4E7A-9288-7F7C33C288C7}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "runtime", "runtime", "{AC38EFB1-820D-4E90-BF40-BEF3AC825542}" EndProject diff --git a/src/platforms/IronPython.CompilerServices/AssemblyResolver.cs b/src/platforms/IronPython.Compiler/AssemblyResolver.cs similarity index 100% rename from src/platforms/IronPython.CompilerServices/AssemblyResolver.cs rename to src/platforms/IronPython.Compiler/AssemblyResolver.cs diff --git a/src/platforms/IronPython.CompilerServices/Config.cs b/src/platforms/IronPython.Compiler/Config.cs similarity index 100% rename from src/platforms/IronPython.CompilerServices/Config.cs rename to src/platforms/IronPython.Compiler/Config.cs diff --git a/src/platforms/IronPython.CompilerServices/ConsoleOps.cs b/src/platforms/IronPython.Compiler/ConsoleOps.cs similarity index 100% rename from src/platforms/IronPython.CompilerServices/ConsoleOps.cs rename to src/platforms/IronPython.Compiler/ConsoleOps.cs diff --git a/src/platforms/IronPython.CompilerServices/IronPython.CompilerServices.csproj b/src/platforms/IronPython.Compiler/IronPython.Compiler.csproj similarity index 100% rename from src/platforms/IronPython.CompilerServices/IronPython.CompilerServices.csproj rename to src/platforms/IronPython.Compiler/IronPython.Compiler.csproj diff --git a/src/platforms/IronPython.CompilerServices/Program.cs b/src/platforms/IronPython.Compiler/Program.cs similarity index 100% rename from src/platforms/IronPython.CompilerServices/Program.cs rename to src/platforms/IronPython.Compiler/Program.cs diff --git a/src/platforms/IronPython.CompilerServices/Properties/AssemblyInfo.cs b/src/platforms/IronPython.Compiler/Properties/AssemblyInfo.cs similarity index 100% rename from src/platforms/IronPython.CompilerServices/Properties/AssemblyInfo.cs rename to src/platforms/IronPython.Compiler/Properties/AssemblyInfo.cs diff --git a/src/platforms/IronPython.CompilerServices/README.md b/src/platforms/IronPython.Compiler/README.md similarity index 100% rename from src/platforms/IronPython.CompilerServices/README.md rename to src/platforms/IronPython.Compiler/README.md From 571ed1a9ceb04f480a91340e402fd9c67aae4593 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:41:21 +0000 Subject: [PATCH 55/84] Move compiler project in solution context --- IronPython.sln | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IronPython.sln b/IronPython.sln index 8eac9bc6f..d829ee7ae 100644 --- a/IronPython.sln +++ b/IronPython.sln @@ -316,7 +316,7 @@ Global {811AC32C-11F3-4ED8-92A7-A7E39C2BB704} = {9DC5996F-F2AB-41AA-9B17-C004CB3AB288} {B6B42537-07F8-4F6C-A99A-B155CAEB124E} = {26425961-0A4E-4CFA-9F45-9072AD6FA6F1} {81DA19C7-4FEC-47E7-981B-D9310D549F95} = {9DC5996F-F2AB-41AA-9B17-C004CB3AB288} - {3DFB096E-AC09-4E7A-9288-7F7C33C288C7} = {B8A5415F-9DF1-4BE3-AE4C-B3423764C6DC} + {3DFB096E-AC09-4E7A-9288-7F7C33C288C7} = {9DC5996F-F2AB-41AA-9B17-C004CB3AB288} {AC38EFB1-820D-4E90-BF40-BEF3AC825542} = {18794F51-C0FB-4F30-AC4A-39BCE6937DD9} {EB66B766-6354-4208-A3D4-AACBDCB5C3B3} = {AC38EFB1-820D-4E90-BF40-BEF3AC825542} {02FF0909-F5AD-48CF-A86A-345E721B7E40} = {AC38EFB1-820D-4E90-BF40-BEF3AC825542} From 119eae328106117f9bdd6dc1ff827f7a6f3af58f Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:53:48 +0000 Subject: [PATCH 56/84] Mark more classes and constructors as public this is tiring --- src/core/IronPython/Runtime/PythonDictionary.cs | 12 ++++++------ src/core/IronPython/Runtime/Types/EmptyType.cs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/IronPython/Runtime/PythonDictionary.cs b/src/core/IronPython/Runtime/PythonDictionary.cs index 8a6033482..bea24ec5b 100644 --- a/src/core/IronPython/Runtime/PythonDictionary.cs +++ b/src/core/IronPython/Runtime/PythonDictionary.cs @@ -36,11 +36,11 @@ public PythonDictionary() { _storage = EmptyDictionaryStorage.Instance; } - internal PythonDictionary(DictionaryStorage storage) { + public PythonDictionary(DictionaryStorage storage) { _storage = storage; } - internal PythonDictionary(IDictionary dict) { + public PythonDictionary(IDictionary dict) { var storage = new CommonDictionaryStorage(); foreach (DictionaryEntry de in dict) { @@ -49,7 +49,7 @@ internal PythonDictionary(IDictionary dict) { _storage = storage; } - internal PythonDictionary(IDictionary dict) { + public PythonDictionary(IDictionary dict) { var storage = new CommonDictionaryStorage(); foreach (var pair in dict) { @@ -58,16 +58,16 @@ internal PythonDictionary(IDictionary dict) { _storage = storage; } - internal PythonDictionary(PythonDictionary dict) { + public PythonDictionary(PythonDictionary dict) { _storage = dict._storage.Clone(); } - internal PythonDictionary(CodeContext/*!*/ context, object o) + public PythonDictionary(CodeContext/*!*/ context, object o) : this() { update(context, o); } - internal PythonDictionary(int size) { + public PythonDictionary(int size) { _storage = size == 0 ? (DictionaryStorage)EmptyDictionaryStorage.Instance : new CommonDictionaryStorage(size); } diff --git a/src/core/IronPython/Runtime/Types/EmptyType.cs b/src/core/IronPython/Runtime/Types/EmptyType.cs index bb93fd268..41cf4c3fb 100644 --- a/src/core/IronPython/Runtime/Types/EmptyType.cs +++ b/src/core/IronPython/Runtime/Types/EmptyType.cs @@ -53,7 +53,7 @@ public sealed class NotImplementedType : ICodeFormattable { private NotImplementedType() { } - internal static NotImplementedType Value { + public static NotImplementedType Value { get { if (_instance == null) { Interlocked.CompareExchange(ref _instance, new NotImplementedType(), null); From 31e7105961f02838db5fb7e121eaa46ce14cf5fa Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:54:38 +0000 Subject: [PATCH 57/84] Add `!NETFRAMEWORK` compiler statement to test method due to unavailable dependency System.Runtime.InteropServices --- tests/ironpython/Stress/Engine.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/ironpython/Stress/Engine.cs b/tests/ironpython/Stress/Engine.cs index f44c3a842..9bd4f8362 100644 --- a/tests/ironpython/Stress/Engine.cs +++ b/tests/ironpython/Stress/Engine.cs @@ -42,6 +42,7 @@ private static long GetTotalMemory() { } #if FEATURE_REFEMIT +#if !NETFRAMEWORK [Test] public void ScenarioXGC() { long initialMemory = GetTotalMemory(); @@ -79,6 +80,7 @@ public void ScenarioXGC() { System.Console.WriteLine("Skipping memory usage test under SaveSnippets and/or Debug mode."); } } +#endif #endif } } From 6f2f009de3b2e08d984ad01016b7d6235afbdd68 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Tue, 26 Nov 2024 19:02:56 +0000 Subject: [PATCH 58/84] More public declarations --- src/core/IronPython/Runtime/PythonList.cs | 2 +- src/core/IronPython/Runtime/Types/PythonType.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/IronPython/Runtime/PythonList.cs b/src/core/IronPython/Runtime/PythonList.cs index 6c491ba2f..72a7c5ad0 100644 --- a/src/core/IronPython/Runtime/PythonList.cs +++ b/src/core/IronPython/Runtime/PythonList.cs @@ -220,7 +220,7 @@ internal static PythonList FromEnumerable(IEnumerable items) { /// onto and may be mutated in the future by the list. /// /// params array to use for lists storage - internal static PythonList FromArrayNoCopy(params object[] data) + public static PythonList FromArrayNoCopy(params object[] data) => new PythonList(data); #endregion diff --git a/src/core/IronPython/Runtime/Types/PythonType.cs b/src/core/IronPython/Runtime/Types/PythonType.cs index 77e70c573..e3ecc2690 100644 --- a/src/core/IronPython/Runtime/Types/PythonType.cs +++ b/src/core/IronPython/Runtime/Types/PythonType.cs @@ -749,7 +749,7 @@ internal int SlotCount { /// /// Gets the name of the dynamic type /// - internal string Name { get; set; } + public string Name { get; set; } internal string QualName { get; set; } From 27b61603b73df119a95dc723d4845f845870b651 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Wed, 27 Nov 2024 17:52:32 +0000 Subject: [PATCH 59/84] Fix `InternalsVisibleToAttribute` --- src/core/IronPython/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/IronPython/Properties/AssemblyInfo.cs b/src/core/IronPython/Properties/AssemblyInfo.cs index 3c7aa8cfe..68cc47625 100644 --- a/src/core/IronPython/Properties/AssemblyInfo.cs +++ b/src/core/IronPython/Properties/AssemblyInfo.cs @@ -44,6 +44,6 @@ #endif [assembly: InternalsVisibleTo("IronPython.Modules, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c10ce00dd2e0ce5046d68183d3ad035b47e92bf0ce7bcf8a03a217ca5d0b0c7db973fdf97579b52b502a23d4069dbf043389e1ab65a1d6c508a9837f3e2350f15e05cc63c0fc4b0410867a51919090e4c33f80203e9b0035b21c32bae20f98b068f90d99a50133a5336480d94039b176519f5fd8524765f33be43da65c4b68ba")] -[assembly: InternalsVisibleTo("IronPythonTest, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c10ce00dd2e0ce5046d68183d3ad035b47e92bf0ce7bcf8a03a217ca5d0b0c7db973fdf97579b52b502a23d4069dbf043389e1ab65a1d6c508a9837f3e2350f15e05cc63c0fc4b0410867a51919090e4c33f80203e9b0035b21c32bae20f98b068f90d99a50133a5336480d94039b176519f5fd8524765f33be43da65c4b68ba")] +[assembly: InternalsVisibleTo("IronPython.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c10ce00dd2e0ce5046d68183d3ad035b47e92bf0ce7bcf8a03a217ca5d0b0c7db973fdf97579b52b502a23d4069dbf043389e1ab65a1d6c508a9837f3e2350f15e05cc63c0fc4b0410867a51919090e4c33f80203e9b0035b21c32bae20f98b068f90d99a50133a5336480d94039b176519f5fd8524765f33be43da65c4b68ba")] [assembly: AllowPartiallyTrustedCallers] From 33702739d58957cdf970ef375c085dffa744c3ff Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Wed, 27 Nov 2024 17:53:45 +0000 Subject: [PATCH 60/84] Less public declarations This reverts commit 6f2f009de3b2e08d984ad01016b7d6235afbdd68. --- src/core/IronPython/Runtime/PythonList.cs | 2 +- src/core/IronPython/Runtime/Types/PythonType.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/IronPython/Runtime/PythonList.cs b/src/core/IronPython/Runtime/PythonList.cs index 72a7c5ad0..6c491ba2f 100644 --- a/src/core/IronPython/Runtime/PythonList.cs +++ b/src/core/IronPython/Runtime/PythonList.cs @@ -220,7 +220,7 @@ internal static PythonList FromEnumerable(IEnumerable items) { /// onto and may be mutated in the future by the list. /// /// params array to use for lists storage - public static PythonList FromArrayNoCopy(params object[] data) + internal static PythonList FromArrayNoCopy(params object[] data) => new PythonList(data); #endregion diff --git a/src/core/IronPython/Runtime/Types/PythonType.cs b/src/core/IronPython/Runtime/Types/PythonType.cs index e3ecc2690..77e70c573 100644 --- a/src/core/IronPython/Runtime/Types/PythonType.cs +++ b/src/core/IronPython/Runtime/Types/PythonType.cs @@ -749,7 +749,7 @@ internal int SlotCount { /// /// Gets the name of the dynamic type /// - public string Name { get; set; } + internal string Name { get; set; } internal string QualName { get; set; } From 32ac9c96677e0d560dab1083caeb9d96685032d4 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Wed, 27 Nov 2024 17:53:53 +0000 Subject: [PATCH 61/84] Remove `!NETFRAMEWORK` compiler statement from test method This reverts commit 31e7105961f02838db5fb7e121eaa46ce14cf5fa. --- tests/ironpython/Stress/Engine.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/ironpython/Stress/Engine.cs b/tests/ironpython/Stress/Engine.cs index 9bd4f8362..f44c3a842 100644 --- a/tests/ironpython/Stress/Engine.cs +++ b/tests/ironpython/Stress/Engine.cs @@ -42,7 +42,6 @@ private static long GetTotalMemory() { } #if FEATURE_REFEMIT -#if !NETFRAMEWORK [Test] public void ScenarioXGC() { long initialMemory = GetTotalMemory(); @@ -80,7 +79,6 @@ public void ScenarioXGC() { System.Console.WriteLine("Skipping memory usage test under SaveSnippets and/or Debug mode."); } } -#endif #endif } } From da4f72a719ab3e6940fd52b6baec6bda379ed22d Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Wed, 27 Nov 2024 17:54:09 +0000 Subject: [PATCH 62/84] Mark less classes and constructors as public This reverts commit 119eae328106117f9bdd6dc1ff827f7a6f3af58f. --- src/core/IronPython/Runtime/PythonDictionary.cs | 12 ++++++------ src/core/IronPython/Runtime/Types/EmptyType.cs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/IronPython/Runtime/PythonDictionary.cs b/src/core/IronPython/Runtime/PythonDictionary.cs index bea24ec5b..8a6033482 100644 --- a/src/core/IronPython/Runtime/PythonDictionary.cs +++ b/src/core/IronPython/Runtime/PythonDictionary.cs @@ -36,11 +36,11 @@ public PythonDictionary() { _storage = EmptyDictionaryStorage.Instance; } - public PythonDictionary(DictionaryStorage storage) { + internal PythonDictionary(DictionaryStorage storage) { _storage = storage; } - public PythonDictionary(IDictionary dict) { + internal PythonDictionary(IDictionary dict) { var storage = new CommonDictionaryStorage(); foreach (DictionaryEntry de in dict) { @@ -49,7 +49,7 @@ public PythonDictionary(IDictionary dict) { _storage = storage; } - public PythonDictionary(IDictionary dict) { + internal PythonDictionary(IDictionary dict) { var storage = new CommonDictionaryStorage(); foreach (var pair in dict) { @@ -58,16 +58,16 @@ public PythonDictionary(IDictionary dict) { _storage = storage; } - public PythonDictionary(PythonDictionary dict) { + internal PythonDictionary(PythonDictionary dict) { _storage = dict._storage.Clone(); } - public PythonDictionary(CodeContext/*!*/ context, object o) + internal PythonDictionary(CodeContext/*!*/ context, object o) : this() { update(context, o); } - public PythonDictionary(int size) { + internal PythonDictionary(int size) { _storage = size == 0 ? (DictionaryStorage)EmptyDictionaryStorage.Instance : new CommonDictionaryStorage(size); } diff --git a/src/core/IronPython/Runtime/Types/EmptyType.cs b/src/core/IronPython/Runtime/Types/EmptyType.cs index 41cf4c3fb..bb93fd268 100644 --- a/src/core/IronPython/Runtime/Types/EmptyType.cs +++ b/src/core/IronPython/Runtime/Types/EmptyType.cs @@ -53,7 +53,7 @@ public sealed class NotImplementedType : ICodeFormattable { private NotImplementedType() { } - public static NotImplementedType Value { + internal static NotImplementedType Value { get { if (_instance == null) { Interlocked.CompareExchange(ref _instance, new NotImplementedType(), null); From a87f9af8c20609fd0d18b7982ff30c2d4d484949 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Wed, 27 Nov 2024 17:54:34 +0000 Subject: [PATCH 63/84] Replace more `public` statements with `internal` ones This reverts commit a562f6143d9879ab8cd22ce0822fade7f1ca58e0. --- src/core/IronPython/Runtime/Operations/StringOps.cs | 2 +- src/core/IronPython/Runtime/PythonEncoding.cs | 6 +++--- src/core/IronPython/Runtime/PythonTuple.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/IronPython/Runtime/Operations/StringOps.cs b/src/core/IronPython/Runtime/Operations/StringOps.cs index 7f2ffb457..9a3e98a7c 100644 --- a/src/core/IronPython/Runtime/Operations/StringOps.cs +++ b/src/core/IronPython/Runtime/Operations/StringOps.cs @@ -155,7 +155,7 @@ public virtual bool __contains__(object? value) { /// defined in the CLS System.String type. /// public static partial class StringOps { - public static Encoding Latin1Encoding => _latin1 ??= Encoding.GetEncoding(28591, new EncoderExceptionFallback(), new DecoderExceptionFallback()); // ISO-8859-1 + internal static Encoding Latin1Encoding => _latin1 ??= Encoding.GetEncoding(28591, new EncoderExceptionFallback(), new DecoderExceptionFallback()); // ISO-8859-1 [DisallowNull] private static Encoding? _latin1; internal static object FastNew(CodeContext/*!*/ context, object? x) { diff --git a/src/core/IronPython/Runtime/PythonEncoding.cs b/src/core/IronPython/Runtime/PythonEncoding.cs index 7aca2e6a7..da40a4bb9 100644 --- a/src/core/IronPython/Runtime/PythonEncoding.cs +++ b/src/core/IronPython/Runtime/PythonEncoding.cs @@ -39,7 +39,7 @@ namespace IronPython.Runtime { /// to the constructor. Also, the fallbacks have to be of type /// and , which implement the extended fallback protocol. /// - public class PythonEncoding : Encoding { + internal class PythonEncoding : Encoding { // The following two must be different from each other and be pass-through characters for UTF-7 private const char Pass1Marker = '?'; private const char Pass2Marker = '-'; @@ -931,7 +931,7 @@ public override void Reset() { } - public class PythonSurrogateEscapeEncoding : PythonEncoding { + internal class PythonSurrogateEscapeEncoding : PythonEncoding { // Defined in PEP 383 private const ushort LoneSurrogateBase = 0xdc00; @@ -1007,7 +1007,7 @@ public override ReadOnlyMemory GetFallbackChars(byte[] bytesUnknown, int i } } - public class PythonSurrogatePassEncoding : PythonEncoding { + internal class PythonSurrogatePassEncoding : PythonEncoding { private const ushort SurrogateRangeStart = 0xd800; private const ushort SurrogateRangeEnd = 0xdfff; private const byte Utf8LeadByte = 0b_1110_0000; diff --git a/src/core/IronPython/Runtime/PythonTuple.cs b/src/core/IronPython/Runtime/PythonTuple.cs index ad5f35e63..bdc5fd887 100644 --- a/src/core/IronPython/Runtime/PythonTuple.cs +++ b/src/core/IronPython/Runtime/PythonTuple.cs @@ -113,12 +113,12 @@ public int count(object? obj) { #endregion - public static PythonTuple Make(object o) { + internal static PythonTuple Make(object o) { if (o is PythonTuple t) return t; return new PythonTuple(o); } - public static PythonTuple MakeTuple(params object?[] items) { + internal static PythonTuple MakeTuple(params object?[] items) { if (items.Length == 0) return EMPTY; return new PythonTuple(items); } From 11d5dc4c6b84b0fc6e65b4194b3f22cdc74daa3c Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Wed, 27 Nov 2024 17:54:52 +0000 Subject: [PATCH 64/84] Add internal declaration to built-in module test method This reverts commit 99a35c78967d72cbb6dd7b7ad21d8f27723f6bf7. --- tests/ironpython/TestBuiltinModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ironpython/TestBuiltinModule.cs b/tests/ironpython/TestBuiltinModule.cs index d5c2b0899..61aab573d 100644 --- a/tests/ironpython/TestBuiltinModule.cs +++ b/tests/ironpython/TestBuiltinModule.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. @@ -19,13 +19,13 @@ public TestBuiltinModule(PythonContext context) : base(context) { } - protected override void Initialize(CodeContext codeContext, Dictionary globals) { + protected internal override void Initialize(CodeContext codeContext, Dictionary globals) { _test_attr = globals["test_attr"]; _test_min = globals["min"]; base.Initialize(codeContext, globals); } - protected override IEnumerable GetGlobalVariableNames() { + protected internal override IEnumerable GetGlobalVariableNames() { return new string[] { "test_attr", "test_overlap_method", "test_overlap_type", "min" }; } From 57ebcae0307106407706dac1bba95b76b7911362 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Wed, 27 Nov 2024 17:54:57 +0000 Subject: [PATCH 65/84] Undo fix to assembly component reference errors This reverts commit 10a679ee2d92b7c25c4d3ff075e1375e7c50cf5e. --- src/core/IronPython/Runtime/CommonDictionaryStorage.cs | 2 +- src/core/IronPython/Runtime/ConstantDictionaryStorage.cs | 2 +- src/core/IronPython/Runtime/DictionaryStorage.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/IronPython/Runtime/CommonDictionaryStorage.cs b/src/core/IronPython/Runtime/CommonDictionaryStorage.cs index 22a3c0de1..dba8f9af8 100644 --- a/src/core/IronPython/Runtime/CommonDictionaryStorage.cs +++ b/src/core/IronPython/Runtime/CommonDictionaryStorage.cs @@ -37,7 +37,7 @@ namespace IronPython.Runtime { /// array to ensure that readers are not seeing multiple bucket arrays. /// [Serializable] - public class CommonDictionaryStorage : DictionaryStorage, ISerializable, IDeserializationCallback { + internal class CommonDictionaryStorage : DictionaryStorage, ISerializable, IDeserializationCallback { protected Bucket[] _buckets; private int _count; private int _version; diff --git a/src/core/IronPython/Runtime/ConstantDictionaryStorage.cs b/src/core/IronPython/Runtime/ConstantDictionaryStorage.cs index 215cde859..c5fc42eb6 100644 --- a/src/core/IronPython/Runtime/ConstantDictionaryStorage.cs +++ b/src/core/IronPython/Runtime/ConstantDictionaryStorage.cs @@ -17,7 +17,7 @@ namespace IronPython.Runtime { /// Copy on write constant dictionary storage used for dictionaries created with constant items. /// [Serializable] - public class ConstantDictionaryStorage : DictionaryStorage, IExpressionSerializable { + internal class ConstantDictionaryStorage : DictionaryStorage, IExpressionSerializable { private readonly CommonDictionaryStorage _storage; public ConstantDictionaryStorage(CommonDictionaryStorage storage) { diff --git a/src/core/IronPython/Runtime/DictionaryStorage.cs b/src/core/IronPython/Runtime/DictionaryStorage.cs index c5751eb58..60f081e04 100644 --- a/src/core/IronPython/Runtime/DictionaryStorage.cs +++ b/src/core/IronPython/Runtime/DictionaryStorage.cs @@ -24,7 +24,7 @@ namespace IronPython.Runtime { /// around large operations and call lock free functions. /// [Serializable] - public abstract class DictionaryStorage { + internal abstract class DictionaryStorage { public abstract void Add(ref DictionaryStorage storage, object? key, object? value); public virtual void AddNoLock(ref DictionaryStorage storage, object? key, object? value) { From 84321ca743dca5932ca536d41b3f778f8ef9f692 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Wed, 27 Nov 2024 18:02:29 +0000 Subject: [PATCH 66/84] Move `utils` to `eng` --- Build.proj | 4 ++-- Directory.Build.props | 4 ++-- {utils => eng/utils}/NuGet/nuget.exe | Bin .../References/IKVM/IKVM.Reflection.License.txt | 0 .../utils}/References/IKVM/IKVM.Reflection.dll | Bin {utils => eng/utils}/References/Mono.Posix.dll | Bin .../IronPython.Modules/IronPython.Modules.csproj | 2 +- src/core/IronPython/IronPython.csproj | 2 +- .../IronPython.Compiler/IronPython.Compiler.csproj | 4 ++-- 9 files changed, 8 insertions(+), 8 deletions(-) rename {utils => eng/utils}/NuGet/nuget.exe (100%) rename {utils => eng/utils}/References/IKVM/IKVM.Reflection.License.txt (100%) rename {utils => eng/utils}/References/IKVM/IKVM.Reflection.dll (100%) rename {utils => eng/utils}/References/Mono.Posix.dll (100%) diff --git a/Build.proj b/Build.proj index 8554e497d..30d3fd487 100644 --- a/Build.proj +++ b/Build.proj @@ -9,8 +9,8 @@ $(MSBuildThisFileDirectory) $(RootDir)IronPython.sln - $(RootDir)utils - $(RootDir)utils\References + $(RootDir)eng\utils + $(RootDir)eng\utils\References $(RootDir)bin $(RootDir)eng diff --git a/Directory.Build.props b/Directory.Build.props index ab7ff87de..89ac1857d 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -6,10 +6,10 @@ $(MSBuildThisFileDirectory) $(RootDir)eng - $(RootDir)utils\References + $(RootDir)eng\utils\References true - + true diff --git a/utils/NuGet/nuget.exe b/eng/utils/NuGet/nuget.exe similarity index 100% rename from utils/NuGet/nuget.exe rename to eng/utils/NuGet/nuget.exe diff --git a/utils/References/IKVM/IKVM.Reflection.License.txt b/eng/utils/References/IKVM/IKVM.Reflection.License.txt similarity index 100% rename from utils/References/IKVM/IKVM.Reflection.License.txt rename to eng/utils/References/IKVM/IKVM.Reflection.License.txt diff --git a/utils/References/IKVM/IKVM.Reflection.dll b/eng/utils/References/IKVM/IKVM.Reflection.dll similarity index 100% rename from utils/References/IKVM/IKVM.Reflection.dll rename to eng/utils/References/IKVM/IKVM.Reflection.dll diff --git a/utils/References/Mono.Posix.dll b/eng/utils/References/Mono.Posix.dll similarity index 100% rename from utils/References/Mono.Posix.dll rename to eng/utils/References/Mono.Posix.dll diff --git a/src/core/IronPython.Modules/IronPython.Modules.csproj b/src/core/IronPython.Modules/IronPython.Modules.csproj index e6baefc59..bbdf32345 100644 --- a/src/core/IronPython.Modules/IronPython.Modules.csproj +++ b/src/core/IronPython.Modules/IronPython.Modules.csproj @@ -10,7 +10,7 @@ True - ..\..\..\utils\References\Mono.Posix.dll + ..\..\..\eng\utils\References\Mono.Posix.dll diff --git a/src/core/IronPython/IronPython.csproj b/src/core/IronPython/IronPython.csproj index c5e954dac..4e2918ab2 100644 --- a/src/core/IronPython/IronPython.csproj +++ b/src/core/IronPython/IronPython.csproj @@ -23,7 +23,7 @@ True - ..\..\..\utils\References\Mono.Posix.dll + ..\..\..\eng\utils\References\Mono.Posix.dll diff --git a/src/platforms/IronPython.Compiler/IronPython.Compiler.csproj b/src/platforms/IronPython.Compiler/IronPython.Compiler.csproj index 6a0776309..f053ca71e 100644 --- a/src/platforms/IronPython.Compiler/IronPython.Compiler.csproj +++ b/src/platforms/IronPython.Compiler/IronPython.Compiler.csproj @@ -15,12 +15,12 @@ - + - ..\..\..\utils\References\IKVM\IKVM.Reflection.dll + ..\..\..\eng\utils\References\IKVM\IKVM.Reflection.dll From 3790dd403251fa8c74254ca329d3539cc238ea87 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Wed, 27 Nov 2024 18:09:48 +0000 Subject: [PATCH 67/84] Update reference to build directory in choco targets --- eng/choco/Choco.Packaging.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/choco/Choco.Packaging.targets b/eng/choco/Choco.Packaging.targets index 6aa617ce3..5227da618 100644 --- a/eng/choco/Choco.Packaging.targets +++ b/eng/choco/Choco.Packaging.targets @@ -6,7 +6,7 @@ 0.10.8 - + From ef14b6ef6ee8256add85c80b138291ec3a5ea827 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Wed, 27 Nov 2024 18:14:22 +0000 Subject: [PATCH 68/84] Fix ignores --- .gitignore | 409 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 408 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index a4159815e..8f48bf2ad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ +## This file is used to ignore files and directories when using IronPython with Git. +## It is based on the VisualStudio.gitignore file from the GitHub gitignore repository, +## as well as the legacy .gitignore file from the IronPython repository on CodePlex. +## +## For more information, visit: https://docs.github.com/en/github/using-git/ignoring-files + # Visual Studio .vs/ .vscode/ @@ -10,7 +16,7 @@ launchSettings.json # Build results obj/ bin/ -Package/Release/ +eng/Release/ *.binlog # NuGet Packages @@ -26,3 +32,404 @@ Src/IronPythonTest/runsettings.*.xml # created by CPython tests Src/StdLib/Lib/lib2to3/Grammar*.pickle Src/StdLib/Lib/lib2to3/PatternGrammar*.pickle + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +# but not Directory.Build.rsp, as it configures directory-level build defaults +!Directory.Build.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml From d20ca2cd3a41d0f6d7da7c6a44dfd10abf4fd059 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Wed, 27 Nov 2024 18:16:52 +0000 Subject: [PATCH 69/84] Move scripts directory desperately to anywhere else than root --- {scripts => tests/scripts}/CompareDirs.py | 0 {scripts => tests/scripts}/Enter-IronPythonEnvironment.ps1 | 0 {scripts => tests/scripts}/Install-IronPython.ps1 | 0 {scripts => tests/scripts}/clean.py | 0 {scripts => tests/scripts}/copyrights.py | 0 {scripts => tests/scripts}/generate.py | 0 .../scripts}/generate_UncollectableCompilationMode.py | 0 {scripts => tests/scripts}/generate_alltypes.py | 0 {scripts => tests/scripts}/generate_calls.py | 0 {scripts => tests/scripts}/generate_casts.py | 0 {scripts => tests/scripts}/generate_comdispatch.py | 0 {scripts => tests/scripts}/generate_dict_views.py | 0 {scripts => tests/scripts}/generate_dynamic_instructions.py | 0 {scripts => tests/scripts}/generate_dynsites.py | 0 {scripts => tests/scripts}/generate_encoding_aliases.py | 0 {scripts => tests/scripts}/generate_exception_factory.py | 0 {scripts => tests/scripts}/generate_exceptions.py | 0 {scripts => tests/scripts}/generate_indicestest.py | 0 {scripts => tests/scripts}/generate_math.py | 0 {scripts => tests/scripts}/generate_ops.py | 0 {scripts => tests/scripts}/generate_os_codes.py | 0 {scripts => tests/scripts}/generate_reflected_calls.py | 0 {scripts => tests/scripts}/generate_set.py | 0 {scripts => tests/scripts}/generate_tuples.py | 0 {scripts => tests/scripts}/generate_typecache.py | 0 {scripts => tests/scripts}/generate_walker.py | 0 {scripts => tests/scripts}/ipcom.ps1 | 0 {scripts => tests/scripts}/make_meta1.py | 0 {scripts => tests/scripts}/radix_generator.py | 0 {scripts => tests/scripts}/run_compiled.py | 0 {scripts => tests/scripts}/run_interactive.py | 0 {scripts => tests/scripts}/smtpmailer.py | 0 {scripts => tests/scripts}/test_builder.py | 0 {scripts => tests/scripts}/test_cgcheck.py | 0 {scripts => tests/scripts}/test_parrot.py | 0 {scripts => tests/scripts}/test_pystone.py | 0 36 files changed, 0 insertions(+), 0 deletions(-) rename {scripts => tests/scripts}/CompareDirs.py (100%) rename {scripts => tests/scripts}/Enter-IronPythonEnvironment.ps1 (100%) rename {scripts => tests/scripts}/Install-IronPython.ps1 (100%) rename {scripts => tests/scripts}/clean.py (100%) rename {scripts => tests/scripts}/copyrights.py (100%) rename {scripts => tests/scripts}/generate.py (100%) rename {scripts => tests/scripts}/generate_UncollectableCompilationMode.py (100%) rename {scripts => tests/scripts}/generate_alltypes.py (100%) rename {scripts => tests/scripts}/generate_calls.py (100%) rename {scripts => tests/scripts}/generate_casts.py (100%) rename {scripts => tests/scripts}/generate_comdispatch.py (100%) rename {scripts => tests/scripts}/generate_dict_views.py (100%) rename {scripts => tests/scripts}/generate_dynamic_instructions.py (100%) rename {scripts => tests/scripts}/generate_dynsites.py (100%) rename {scripts => tests/scripts}/generate_encoding_aliases.py (100%) rename {scripts => tests/scripts}/generate_exception_factory.py (100%) rename {scripts => tests/scripts}/generate_exceptions.py (100%) rename {scripts => tests/scripts}/generate_indicestest.py (100%) rename {scripts => tests/scripts}/generate_math.py (100%) rename {scripts => tests/scripts}/generate_ops.py (100%) rename {scripts => tests/scripts}/generate_os_codes.py (100%) rename {scripts => tests/scripts}/generate_reflected_calls.py (100%) rename {scripts => tests/scripts}/generate_set.py (100%) rename {scripts => tests/scripts}/generate_tuples.py (100%) rename {scripts => tests/scripts}/generate_typecache.py (100%) rename {scripts => tests/scripts}/generate_walker.py (100%) rename {scripts => tests/scripts}/ipcom.ps1 (100%) rename {scripts => tests/scripts}/make_meta1.py (100%) rename {scripts => tests/scripts}/radix_generator.py (100%) rename {scripts => tests/scripts}/run_compiled.py (100%) rename {scripts => tests/scripts}/run_interactive.py (100%) rename {scripts => tests/scripts}/smtpmailer.py (100%) rename {scripts => tests/scripts}/test_builder.py (100%) rename {scripts => tests/scripts}/test_cgcheck.py (100%) rename {scripts => tests/scripts}/test_parrot.py (100%) rename {scripts => tests/scripts}/test_pystone.py (100%) diff --git a/scripts/CompareDirs.py b/tests/scripts/CompareDirs.py similarity index 100% rename from scripts/CompareDirs.py rename to tests/scripts/CompareDirs.py diff --git a/scripts/Enter-IronPythonEnvironment.ps1 b/tests/scripts/Enter-IronPythonEnvironment.ps1 similarity index 100% rename from scripts/Enter-IronPythonEnvironment.ps1 rename to tests/scripts/Enter-IronPythonEnvironment.ps1 diff --git a/scripts/Install-IronPython.ps1 b/tests/scripts/Install-IronPython.ps1 similarity index 100% rename from scripts/Install-IronPython.ps1 rename to tests/scripts/Install-IronPython.ps1 diff --git a/scripts/clean.py b/tests/scripts/clean.py similarity index 100% rename from scripts/clean.py rename to tests/scripts/clean.py diff --git a/scripts/copyrights.py b/tests/scripts/copyrights.py similarity index 100% rename from scripts/copyrights.py rename to tests/scripts/copyrights.py diff --git a/scripts/generate.py b/tests/scripts/generate.py similarity index 100% rename from scripts/generate.py rename to tests/scripts/generate.py diff --git a/scripts/generate_UncollectableCompilationMode.py b/tests/scripts/generate_UncollectableCompilationMode.py similarity index 100% rename from scripts/generate_UncollectableCompilationMode.py rename to tests/scripts/generate_UncollectableCompilationMode.py diff --git a/scripts/generate_alltypes.py b/tests/scripts/generate_alltypes.py similarity index 100% rename from scripts/generate_alltypes.py rename to tests/scripts/generate_alltypes.py diff --git a/scripts/generate_calls.py b/tests/scripts/generate_calls.py similarity index 100% rename from scripts/generate_calls.py rename to tests/scripts/generate_calls.py diff --git a/scripts/generate_casts.py b/tests/scripts/generate_casts.py similarity index 100% rename from scripts/generate_casts.py rename to tests/scripts/generate_casts.py diff --git a/scripts/generate_comdispatch.py b/tests/scripts/generate_comdispatch.py similarity index 100% rename from scripts/generate_comdispatch.py rename to tests/scripts/generate_comdispatch.py diff --git a/scripts/generate_dict_views.py b/tests/scripts/generate_dict_views.py similarity index 100% rename from scripts/generate_dict_views.py rename to tests/scripts/generate_dict_views.py diff --git a/scripts/generate_dynamic_instructions.py b/tests/scripts/generate_dynamic_instructions.py similarity index 100% rename from scripts/generate_dynamic_instructions.py rename to tests/scripts/generate_dynamic_instructions.py diff --git a/scripts/generate_dynsites.py b/tests/scripts/generate_dynsites.py similarity index 100% rename from scripts/generate_dynsites.py rename to tests/scripts/generate_dynsites.py diff --git a/scripts/generate_encoding_aliases.py b/tests/scripts/generate_encoding_aliases.py similarity index 100% rename from scripts/generate_encoding_aliases.py rename to tests/scripts/generate_encoding_aliases.py diff --git a/scripts/generate_exception_factory.py b/tests/scripts/generate_exception_factory.py similarity index 100% rename from scripts/generate_exception_factory.py rename to tests/scripts/generate_exception_factory.py diff --git a/scripts/generate_exceptions.py b/tests/scripts/generate_exceptions.py similarity index 100% rename from scripts/generate_exceptions.py rename to tests/scripts/generate_exceptions.py diff --git a/scripts/generate_indicestest.py b/tests/scripts/generate_indicestest.py similarity index 100% rename from scripts/generate_indicestest.py rename to tests/scripts/generate_indicestest.py diff --git a/scripts/generate_math.py b/tests/scripts/generate_math.py similarity index 100% rename from scripts/generate_math.py rename to tests/scripts/generate_math.py diff --git a/scripts/generate_ops.py b/tests/scripts/generate_ops.py similarity index 100% rename from scripts/generate_ops.py rename to tests/scripts/generate_ops.py diff --git a/scripts/generate_os_codes.py b/tests/scripts/generate_os_codes.py similarity index 100% rename from scripts/generate_os_codes.py rename to tests/scripts/generate_os_codes.py diff --git a/scripts/generate_reflected_calls.py b/tests/scripts/generate_reflected_calls.py similarity index 100% rename from scripts/generate_reflected_calls.py rename to tests/scripts/generate_reflected_calls.py diff --git a/scripts/generate_set.py b/tests/scripts/generate_set.py similarity index 100% rename from scripts/generate_set.py rename to tests/scripts/generate_set.py diff --git a/scripts/generate_tuples.py b/tests/scripts/generate_tuples.py similarity index 100% rename from scripts/generate_tuples.py rename to tests/scripts/generate_tuples.py diff --git a/scripts/generate_typecache.py b/tests/scripts/generate_typecache.py similarity index 100% rename from scripts/generate_typecache.py rename to tests/scripts/generate_typecache.py diff --git a/scripts/generate_walker.py b/tests/scripts/generate_walker.py similarity index 100% rename from scripts/generate_walker.py rename to tests/scripts/generate_walker.py diff --git a/scripts/ipcom.ps1 b/tests/scripts/ipcom.ps1 similarity index 100% rename from scripts/ipcom.ps1 rename to tests/scripts/ipcom.ps1 diff --git a/scripts/make_meta1.py b/tests/scripts/make_meta1.py similarity index 100% rename from scripts/make_meta1.py rename to tests/scripts/make_meta1.py diff --git a/scripts/radix_generator.py b/tests/scripts/radix_generator.py similarity index 100% rename from scripts/radix_generator.py rename to tests/scripts/radix_generator.py diff --git a/scripts/run_compiled.py b/tests/scripts/run_compiled.py similarity index 100% rename from scripts/run_compiled.py rename to tests/scripts/run_compiled.py diff --git a/scripts/run_interactive.py b/tests/scripts/run_interactive.py similarity index 100% rename from scripts/run_interactive.py rename to tests/scripts/run_interactive.py diff --git a/scripts/smtpmailer.py b/tests/scripts/smtpmailer.py similarity index 100% rename from scripts/smtpmailer.py rename to tests/scripts/smtpmailer.py diff --git a/scripts/test_builder.py b/tests/scripts/test_builder.py similarity index 100% rename from scripts/test_builder.py rename to tests/scripts/test_builder.py diff --git a/scripts/test_cgcheck.py b/tests/scripts/test_cgcheck.py similarity index 100% rename from scripts/test_cgcheck.py rename to tests/scripts/test_cgcheck.py diff --git a/scripts/test_parrot.py b/tests/scripts/test_parrot.py similarity index 100% rename from scripts/test_parrot.py rename to tests/scripts/test_parrot.py diff --git a/scripts/test_pystone.py b/tests/scripts/test_pystone.py similarity index 100% rename from scripts/test_pystone.py rename to tests/scripts/test_pystone.py From d875546387a227fb2e2ca0797f3bbc1f58730431 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Wed, 27 Nov 2024 18:22:01 +0000 Subject: [PATCH 70/84] Fix directory references in packaging targets --- eng/choco/IronPython.nuspec | 2 +- eng/deb/Deb.Packaging.targets | 2 +- eng/msi/IronPython.Installer.wixproj | 2 +- eng/msi/Msi.Packaging.targets | 4 ++-- eng/msi/Product.wxs | 2 +- eng/zip/Zip.Packaging.targets | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/eng/choco/IronPython.nuspec b/eng/choco/IronPython.nuspec index 6a616379f..be33e9a46 100644 --- a/eng/choco/IronPython.nuspec +++ b/eng/choco/IronPython.nuspec @@ -5,7 +5,7 @@ ironpython 3.4.0 - https://github.com/IronLanguages/ironpython3/tree/main/Package/choco + https://github.com/IronLanguages/ironpython3/tree/main/eng/choco IronPython IronPython Contributors, Microsoft © IronPython Contributors diff --git a/eng/deb/Deb.Packaging.targets b/eng/deb/Deb.Packaging.targets index 184aadb9b..3d4729ecb 100644 --- a/eng/deb/Deb.Packaging.targets +++ b/eng/deb/Deb.Packaging.targets @@ -3,7 +3,7 @@ temp - Package/deb + eng/deb $(PackageDebFolder)/$(TempFolder) diff --git a/eng/msi/IronPython.Installer.wixproj b/eng/msi/IronPython.Installer.wixproj index e122f51c8..2aaec9d52 100644 --- a/eng/msi/IronPython.Installer.wixproj +++ b/eng/msi/IronPython.Installer.wixproj @@ -6,7 +6,7 @@ true 5151 ICE61 - $(RootDir)Package\$(Configuration)\Stage\IronPython-$(DisplayVersion) + $(RootDir)eng\$(Configuration)\Stage\IronPython-$(DisplayVersion) $(RootDir)bin\$(Configuration) $(MajorVersion).$(MinorVersion).$(MicroVersion).$(AssemblyFileRevision) True diff --git a/eng/msi/Msi.Packaging.targets b/eng/msi/Msi.Packaging.targets index 87cfe329c..8253a7fd1 100644 --- a/eng/msi/Msi.Packaging.targets +++ b/eng/msi/Msi.Packaging.targets @@ -1,9 +1,9 @@ - + diff --git a/eng/msi/Product.wxs b/eng/msi/Product.wxs index 243f17fd6..43b8756e6 100644 --- a/eng/msi/Product.wxs +++ b/eng/msi/Product.wxs @@ -19,7 +19,7 @@ WHEN PERFORMING MAJOR IP UPGRADES (e.g., 2.5 => 2.6): - + diff --git a/eng/zip/Zip.Packaging.targets b/eng/zip/Zip.Packaging.targets index bec14c1fa..60930f0a0 100644 --- a/eng/zip/Zip.Packaging.targets +++ b/eng/zip/Zip.Packaging.targets @@ -6,8 +6,8 @@ - - + + From a18b76efc872745957e434cf5a147dd05c6a914c Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Wed, 27 Nov 2024 18:24:41 +0000 Subject: [PATCH 71/84] Fix references in ignore --- .gitignore | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 8f48bf2ad..89450abbb 100644 --- a/.gitignore +++ b/.gitignore @@ -26,12 +26,12 @@ packages/ __pycache__/ # Generated files -Src/IronPythonTest/TestResults/ -Src/IronPythonTest/runsettings.*.xml +tests/ironpython/TestResults/ +tests/ironpython/runsettings.*.xml # created by CPython tests -Src/StdLib/Lib/lib2to3/Grammar*.pickle -Src/StdLib/Lib/lib2to3/PatternGrammar*.pickle +src/core/IronPython.StdLib/Lib/lib2to3/Grammar*.pickle +src/core/IronPython.StdLib/Lib/lib2to3/PatternGrammar*.pickle ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. From 8e37d84c527137ce4e89df0ce6ccfbaa3fc161a0 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Wed, 27 Nov 2024 18:33:54 +0000 Subject: [PATCH 72/84] Move scripts folder (again) --- {tests => eng}/scripts/CompareDirs.py | 0 {tests => eng}/scripts/Enter-IronPythonEnvironment.ps1 | 0 {tests => eng}/scripts/Install-IronPython.ps1 | 0 {tests => eng}/scripts/clean.py | 0 {tests => eng}/scripts/copyrights.py | 0 {tests => eng}/scripts/generate.py | 0 .../scripts/generate_UncollectableCompilationMode.py | 0 {tests => eng}/scripts/generate_alltypes.py | 0 {tests => eng}/scripts/generate_calls.py | 0 {tests => eng}/scripts/generate_casts.py | 0 {tests => eng}/scripts/generate_comdispatch.py | 0 {tests => eng}/scripts/generate_dict_views.py | 0 {tests => eng}/scripts/generate_dynamic_instructions.py | 0 {tests => eng}/scripts/generate_dynsites.py | 0 {tests => eng}/scripts/generate_encoding_aliases.py | 0 {tests => eng}/scripts/generate_exception_factory.py | 0 {tests => eng}/scripts/generate_exceptions.py | 0 {tests => eng}/scripts/generate_indicestest.py | 0 {tests => eng}/scripts/generate_math.py | 0 {tests => eng}/scripts/generate_ops.py | 0 {tests => eng}/scripts/generate_os_codes.py | 0 {tests => eng}/scripts/generate_reflected_calls.py | 0 {tests => eng}/scripts/generate_set.py | 0 {tests => eng}/scripts/generate_tuples.py | 0 {tests => eng}/scripts/generate_typecache.py | 0 {tests => eng}/scripts/generate_walker.py | 0 {tests => eng}/scripts/ipcom.ps1 | 0 {tests => eng}/scripts/make_meta1.py | 0 {tests => eng}/scripts/radix_generator.py | 0 {tests => eng}/scripts/run_compiled.py | 0 {tests => eng}/scripts/run_interactive.py | 0 {tests => eng}/scripts/smtpmailer.py | 0 {tests => eng}/scripts/test_builder.py | 0 {tests => eng}/scripts/test_cgcheck.py | 0 {tests => eng}/scripts/test_parrot.py | 0 {tests => eng}/scripts/test_pystone.py | 0 eng/zip/Zip.Packaging.targets | 4 ++-- 37 files changed, 2 insertions(+), 2 deletions(-) rename {tests => eng}/scripts/CompareDirs.py (100%) rename {tests => eng}/scripts/Enter-IronPythonEnvironment.ps1 (100%) rename {tests => eng}/scripts/Install-IronPython.ps1 (100%) rename {tests => eng}/scripts/clean.py (100%) rename {tests => eng}/scripts/copyrights.py (100%) rename {tests => eng}/scripts/generate.py (100%) rename {tests => eng}/scripts/generate_UncollectableCompilationMode.py (100%) rename {tests => eng}/scripts/generate_alltypes.py (100%) rename {tests => eng}/scripts/generate_calls.py (100%) rename {tests => eng}/scripts/generate_casts.py (100%) rename {tests => eng}/scripts/generate_comdispatch.py (100%) rename {tests => eng}/scripts/generate_dict_views.py (100%) rename {tests => eng}/scripts/generate_dynamic_instructions.py (100%) rename {tests => eng}/scripts/generate_dynsites.py (100%) rename {tests => eng}/scripts/generate_encoding_aliases.py (100%) rename {tests => eng}/scripts/generate_exception_factory.py (100%) rename {tests => eng}/scripts/generate_exceptions.py (100%) rename {tests => eng}/scripts/generate_indicestest.py (100%) rename {tests => eng}/scripts/generate_math.py (100%) rename {tests => eng}/scripts/generate_ops.py (100%) rename {tests => eng}/scripts/generate_os_codes.py (100%) rename {tests => eng}/scripts/generate_reflected_calls.py (100%) rename {tests => eng}/scripts/generate_set.py (100%) rename {tests => eng}/scripts/generate_tuples.py (100%) rename {tests => eng}/scripts/generate_typecache.py (100%) rename {tests => eng}/scripts/generate_walker.py (100%) rename {tests => eng}/scripts/ipcom.ps1 (100%) rename {tests => eng}/scripts/make_meta1.py (100%) rename {tests => eng}/scripts/radix_generator.py (100%) rename {tests => eng}/scripts/run_compiled.py (100%) rename {tests => eng}/scripts/run_interactive.py (100%) rename {tests => eng}/scripts/smtpmailer.py (100%) rename {tests => eng}/scripts/test_builder.py (100%) rename {tests => eng}/scripts/test_cgcheck.py (100%) rename {tests => eng}/scripts/test_parrot.py (100%) rename {tests => eng}/scripts/test_pystone.py (100%) diff --git a/tests/scripts/CompareDirs.py b/eng/scripts/CompareDirs.py similarity index 100% rename from tests/scripts/CompareDirs.py rename to eng/scripts/CompareDirs.py diff --git a/tests/scripts/Enter-IronPythonEnvironment.ps1 b/eng/scripts/Enter-IronPythonEnvironment.ps1 similarity index 100% rename from tests/scripts/Enter-IronPythonEnvironment.ps1 rename to eng/scripts/Enter-IronPythonEnvironment.ps1 diff --git a/tests/scripts/Install-IronPython.ps1 b/eng/scripts/Install-IronPython.ps1 similarity index 100% rename from tests/scripts/Install-IronPython.ps1 rename to eng/scripts/Install-IronPython.ps1 diff --git a/tests/scripts/clean.py b/eng/scripts/clean.py similarity index 100% rename from tests/scripts/clean.py rename to eng/scripts/clean.py diff --git a/tests/scripts/copyrights.py b/eng/scripts/copyrights.py similarity index 100% rename from tests/scripts/copyrights.py rename to eng/scripts/copyrights.py diff --git a/tests/scripts/generate.py b/eng/scripts/generate.py similarity index 100% rename from tests/scripts/generate.py rename to eng/scripts/generate.py diff --git a/tests/scripts/generate_UncollectableCompilationMode.py b/eng/scripts/generate_UncollectableCompilationMode.py similarity index 100% rename from tests/scripts/generate_UncollectableCompilationMode.py rename to eng/scripts/generate_UncollectableCompilationMode.py diff --git a/tests/scripts/generate_alltypes.py b/eng/scripts/generate_alltypes.py similarity index 100% rename from tests/scripts/generate_alltypes.py rename to eng/scripts/generate_alltypes.py diff --git a/tests/scripts/generate_calls.py b/eng/scripts/generate_calls.py similarity index 100% rename from tests/scripts/generate_calls.py rename to eng/scripts/generate_calls.py diff --git a/tests/scripts/generate_casts.py b/eng/scripts/generate_casts.py similarity index 100% rename from tests/scripts/generate_casts.py rename to eng/scripts/generate_casts.py diff --git a/tests/scripts/generate_comdispatch.py b/eng/scripts/generate_comdispatch.py similarity index 100% rename from tests/scripts/generate_comdispatch.py rename to eng/scripts/generate_comdispatch.py diff --git a/tests/scripts/generate_dict_views.py b/eng/scripts/generate_dict_views.py similarity index 100% rename from tests/scripts/generate_dict_views.py rename to eng/scripts/generate_dict_views.py diff --git a/tests/scripts/generate_dynamic_instructions.py b/eng/scripts/generate_dynamic_instructions.py similarity index 100% rename from tests/scripts/generate_dynamic_instructions.py rename to eng/scripts/generate_dynamic_instructions.py diff --git a/tests/scripts/generate_dynsites.py b/eng/scripts/generate_dynsites.py similarity index 100% rename from tests/scripts/generate_dynsites.py rename to eng/scripts/generate_dynsites.py diff --git a/tests/scripts/generate_encoding_aliases.py b/eng/scripts/generate_encoding_aliases.py similarity index 100% rename from tests/scripts/generate_encoding_aliases.py rename to eng/scripts/generate_encoding_aliases.py diff --git a/tests/scripts/generate_exception_factory.py b/eng/scripts/generate_exception_factory.py similarity index 100% rename from tests/scripts/generate_exception_factory.py rename to eng/scripts/generate_exception_factory.py diff --git a/tests/scripts/generate_exceptions.py b/eng/scripts/generate_exceptions.py similarity index 100% rename from tests/scripts/generate_exceptions.py rename to eng/scripts/generate_exceptions.py diff --git a/tests/scripts/generate_indicestest.py b/eng/scripts/generate_indicestest.py similarity index 100% rename from tests/scripts/generate_indicestest.py rename to eng/scripts/generate_indicestest.py diff --git a/tests/scripts/generate_math.py b/eng/scripts/generate_math.py similarity index 100% rename from tests/scripts/generate_math.py rename to eng/scripts/generate_math.py diff --git a/tests/scripts/generate_ops.py b/eng/scripts/generate_ops.py similarity index 100% rename from tests/scripts/generate_ops.py rename to eng/scripts/generate_ops.py diff --git a/tests/scripts/generate_os_codes.py b/eng/scripts/generate_os_codes.py similarity index 100% rename from tests/scripts/generate_os_codes.py rename to eng/scripts/generate_os_codes.py diff --git a/tests/scripts/generate_reflected_calls.py b/eng/scripts/generate_reflected_calls.py similarity index 100% rename from tests/scripts/generate_reflected_calls.py rename to eng/scripts/generate_reflected_calls.py diff --git a/tests/scripts/generate_set.py b/eng/scripts/generate_set.py similarity index 100% rename from tests/scripts/generate_set.py rename to eng/scripts/generate_set.py diff --git a/tests/scripts/generate_tuples.py b/eng/scripts/generate_tuples.py similarity index 100% rename from tests/scripts/generate_tuples.py rename to eng/scripts/generate_tuples.py diff --git a/tests/scripts/generate_typecache.py b/eng/scripts/generate_typecache.py similarity index 100% rename from tests/scripts/generate_typecache.py rename to eng/scripts/generate_typecache.py diff --git a/tests/scripts/generate_walker.py b/eng/scripts/generate_walker.py similarity index 100% rename from tests/scripts/generate_walker.py rename to eng/scripts/generate_walker.py diff --git a/tests/scripts/ipcom.ps1 b/eng/scripts/ipcom.ps1 similarity index 100% rename from tests/scripts/ipcom.ps1 rename to eng/scripts/ipcom.ps1 diff --git a/tests/scripts/make_meta1.py b/eng/scripts/make_meta1.py similarity index 100% rename from tests/scripts/make_meta1.py rename to eng/scripts/make_meta1.py diff --git a/tests/scripts/radix_generator.py b/eng/scripts/radix_generator.py similarity index 100% rename from tests/scripts/radix_generator.py rename to eng/scripts/radix_generator.py diff --git a/tests/scripts/run_compiled.py b/eng/scripts/run_compiled.py similarity index 100% rename from tests/scripts/run_compiled.py rename to eng/scripts/run_compiled.py diff --git a/tests/scripts/run_interactive.py b/eng/scripts/run_interactive.py similarity index 100% rename from tests/scripts/run_interactive.py rename to eng/scripts/run_interactive.py diff --git a/tests/scripts/smtpmailer.py b/eng/scripts/smtpmailer.py similarity index 100% rename from tests/scripts/smtpmailer.py rename to eng/scripts/smtpmailer.py diff --git a/tests/scripts/test_builder.py b/eng/scripts/test_builder.py similarity index 100% rename from tests/scripts/test_builder.py rename to eng/scripts/test_builder.py diff --git a/tests/scripts/test_cgcheck.py b/eng/scripts/test_cgcheck.py similarity index 100% rename from tests/scripts/test_cgcheck.py rename to eng/scripts/test_cgcheck.py diff --git a/tests/scripts/test_parrot.py b/eng/scripts/test_parrot.py similarity index 100% rename from tests/scripts/test_parrot.py rename to eng/scripts/test_parrot.py diff --git a/tests/scripts/test_pystone.py b/eng/scripts/test_pystone.py similarity index 100% rename from tests/scripts/test_pystone.py rename to eng/scripts/test_pystone.py diff --git a/eng/zip/Zip.Packaging.targets b/eng/zip/Zip.Packaging.targets index 60930f0a0..4bd225584 100644 --- a/eng/zip/Zip.Packaging.targets +++ b/eng/zip/Zip.Packaging.targets @@ -6,8 +6,8 @@ - - + + From 86369be2f51068231ac9313100a263b2d7076ce3 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Thu, 28 Nov 2024 18:34:10 +0000 Subject: [PATCH 73/84] Move standard library --- Build.proj | 2 +- .../IronPython.StdLib}/.gitattributes | 0 .../IronPython.StdLib/IronPython.StdLib.pyproj} | 0 .../IronPython.StdLib}/Lib/__future__.py | 0 .../IronPython.StdLib}/Lib/__phello__.foo.py | 0 .../IronPython.StdLib}/Lib/_bootlocale.py | 0 .../IronPython.StdLib}/Lib/_collections_abc.py | 0 .../IronPython.StdLib}/Lib/_compat_pickle.py | 0 .../IronPython.StdLib}/Lib/_dummy_thread.py | 0 .../IronPython.StdLib}/Lib/_markupbase.py | 0 .../IronPython.StdLib}/Lib/_osx_support.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/_pyio.py | 0 .../IronPython.StdLib}/Lib/_sitebuiltins.py | 0 .../IronPython.StdLib}/Lib/_strptime.py | 0 .../IronPython.StdLib}/Lib/_threading_local.py | 0 .../IronPython.StdLib}/Lib/_weakrefset.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/abc.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/aifc.py | 0 .../IronPython.StdLib}/Lib/antigravity.py | 0 .../IronPython.StdLib}/Lib/argparse.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/ast.py | 0 .../IronPython.StdLib}/Lib/asynchat.py | 0 .../IronPython.StdLib}/Lib/asyncio/__init__.py | 0 .../IronPython.StdLib}/Lib/asyncio/base_events.py | 0 .../Lib/asyncio/base_subprocess.py | 0 .../IronPython.StdLib}/Lib/asyncio/compat.py | 0 .../IronPython.StdLib}/Lib/asyncio/constants.py | 0 .../IronPython.StdLib}/Lib/asyncio/coroutines.py | 0 .../IronPython.StdLib}/Lib/asyncio/events.py | 0 .../IronPython.StdLib}/Lib/asyncio/futures.py | 0 .../IronPython.StdLib}/Lib/asyncio/locks.py | 0 .../IronPython.StdLib}/Lib/asyncio/log.py | 0 .../Lib/asyncio/proactor_events.py | 0 .../IronPython.StdLib}/Lib/asyncio/protocols.py | 0 .../IronPython.StdLib}/Lib/asyncio/queues.py | 0 .../Lib/asyncio/selector_events.py | 0 .../IronPython.StdLib}/Lib/asyncio/sslproto.py | 0 .../IronPython.StdLib}/Lib/asyncio/streams.py | 0 .../IronPython.StdLib}/Lib/asyncio/subprocess.py | 0 .../IronPython.StdLib}/Lib/asyncio/tasks.py | 0 .../IronPython.StdLib}/Lib/asyncio/test_utils.py | 0 .../IronPython.StdLib}/Lib/asyncio/transports.py | 0 .../IronPython.StdLib}/Lib/asyncio/unix_events.py | 0 .../Lib/asyncio/windows_events.py | 0 .../IronPython.StdLib}/Lib/asyncio/windows_utils.py | 0 .../IronPython.StdLib}/Lib/asyncore.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/base64.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/bdb.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/binhex.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/bisect.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/bz2.py | 0 .../IronPython.StdLib}/Lib/cProfile.py | 0 .../IronPython.StdLib}/Lib/calendar.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/cgi.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/cgitb.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/chunk.py | 0 .../IronPython.StdLib}/Lib/clrtype.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/cmd.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/code.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/codecs.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/codeop.py | 0 .../IronPython.StdLib}/Lib/collections/__init__.py | 0 .../IronPython.StdLib}/Lib/collections/__main__.py | 0 .../IronPython.StdLib}/Lib/collections/abc.py | 0 .../IronPython.StdLib}/Lib/colorsys.py | 0 .../IronPython.StdLib}/Lib/compileall.py | 0 .../IronPython.StdLib}/Lib/concurrent/__init__.py | 0 .../Lib/concurrent/futures/__init__.py | 0 .../Lib/concurrent/futures/_base.py | 0 .../Lib/concurrent/futures/process.py | 0 .../Lib/concurrent/futures/thread.py | 0 .../IronPython.StdLib}/Lib/configparser.py | 0 .../IronPython.StdLib}/Lib/contextlib.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/copy.py | 0 .../IronPython.StdLib}/Lib/copyreg.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/crypt.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/csv.py | 0 .../IronPython.StdLib}/Lib/ctypes/__init__.py | 0 .../IronPython.StdLib}/Lib/ctypes/_endian.py | 0 .../Lib/ctypes/macholib/README.ctypes | 0 .../Lib/ctypes/macholib/__init__.py | 0 .../IronPython.StdLib}/Lib/ctypes/macholib/dyld.py | 0 .../IronPython.StdLib}/Lib/ctypes/macholib/dylib.py | 0 .../Lib/ctypes/macholib/fetch_macholib | 0 .../Lib/ctypes/macholib/fetch_macholib.bat | 0 .../Lib/ctypes/macholib/framework.py | 0 .../IronPython.StdLib}/Lib/ctypes/test/__init__.py | 0 .../IronPython.StdLib}/Lib/ctypes/test/__main__.py | 0 .../IronPython.StdLib}/Lib/ctypes/test/test_anon.py | 0 .../Lib/ctypes/test/test_array_in_pointer.py | 0 .../Lib/ctypes/test/test_arrays.py | 0 .../Lib/ctypes/test/test_as_parameter.py | 0 .../Lib/ctypes/test/test_bitfields.py | 0 .../Lib/ctypes/test/test_buffers.py | 0 .../Lib/ctypes/test/test_bytes.py | 0 .../Lib/ctypes/test/test_byteswap.py | 0 .../Lib/ctypes/test/test_callbacks.py | 0 .../IronPython.StdLib}/Lib/ctypes/test/test_cast.py | 0 .../Lib/ctypes/test/test_cfuncs.py | 0 .../Lib/ctypes/test/test_checkretval.py | 0 .../Lib/ctypes/test/test_delattr.py | 0 .../Lib/ctypes/test/test_errno.py | 0 .../IronPython.StdLib}/Lib/ctypes/test/test_find.py | 0 .../Lib/ctypes/test/test_frombuffer.py | 0 .../Lib/ctypes/test/test_funcptr.py | 0 .../Lib/ctypes/test/test_functions.py | 0 .../Lib/ctypes/test/test_incomplete.py | 0 .../IronPython.StdLib}/Lib/ctypes/test/test_init.py | 0 .../Lib/ctypes/test/test_internals.py | 0 .../Lib/ctypes/test/test_keeprefs.py | 0 .../IronPython.StdLib}/Lib/ctypes/test/test_libc.py | 0 .../Lib/ctypes/test/test_loading.py | 0 .../Lib/ctypes/test/test_macholib.py | 0 .../Lib/ctypes/test/test_memfunctions.py | 0 .../Lib/ctypes/test/test_numbers.py | 0 .../Lib/ctypes/test/test_objects.py | 0 .../Lib/ctypes/test/test_parameters.py | 0 .../Lib/ctypes/test/test_pep3118.py | 0 .../Lib/ctypes/test/test_pickling.py | 0 .../Lib/ctypes/test/test_pointers.py | 0 .../Lib/ctypes/test/test_prototypes.py | 0 .../Lib/ctypes/test/test_python_api.py | 0 .../Lib/ctypes/test/test_random_things.py | 0 .../Lib/ctypes/test/test_refcounts.py | 0 .../IronPython.StdLib}/Lib/ctypes/test/test_repr.py | 0 .../Lib/ctypes/test/test_returnfuncptrs.py | 0 .../Lib/ctypes/test/test_simplesubclasses.py | 0 .../Lib/ctypes/test/test_sizes.py | 0 .../Lib/ctypes/test/test_slicing.py | 0 .../Lib/ctypes/test/test_stringptr.py | 0 .../Lib/ctypes/test/test_strings.py | 0 .../Lib/ctypes/test/test_struct_fields.py | 0 .../Lib/ctypes/test/test_structures.py | 0 .../Lib/ctypes/test/test_unaligned_structures.py | 0 .../Lib/ctypes/test/test_unicode.py | 0 .../Lib/ctypes/test/test_values.py | 0 .../Lib/ctypes/test/test_varsize_struct.py | 0 .../Lib/ctypes/test/test_win32.py | 0 .../Lib/ctypes/test/test_wintypes.py | 0 .../IronPython.StdLib}/Lib/ctypes/util.py | 0 .../IronPython.StdLib}/Lib/ctypes/wintypes.py | 0 .../IronPython.StdLib}/Lib/curses/__init__.py | 0 .../IronPython.StdLib}/Lib/curses/ascii.py | 0 .../IronPython.StdLib}/Lib/curses/has_key.py | 0 .../IronPython.StdLib}/Lib/curses/panel.py | 0 .../IronPython.StdLib}/Lib/curses/textpad.py | 0 .../IronPython.StdLib}/Lib/datetime.py | 0 .../IronPython.StdLib}/Lib/dbm/__init__.py | 0 .../IronPython.StdLib}/Lib/dbm/dumb.py | 0 .../IronPython.StdLib}/Lib/dbm/gnu.py | 0 .../IronPython.StdLib}/Lib/dbm/ndbm.py | 0 .../IronPython.StdLib}/Lib/decimal.py | 0 .../IronPython.StdLib}/Lib/difflib.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/dis.py | 0 .../IronPython.StdLib}/Lib/distutils/README | 0 .../IronPython.StdLib}/Lib/distutils/__init__.py | 0 .../Lib/distutils/archive_util.py | 0 .../Lib/distutils/bcppcompiler.py | 0 .../IronPython.StdLib}/Lib/distutils/ccompiler.py | 0 .../IronPython.StdLib}/Lib/distutils/cmd.py | 0 .../Lib/distutils/command/__init__.py | 0 .../Lib/distutils/command/bdist.py | 0 .../Lib/distutils/command/bdist_dumb.py | 0 .../Lib/distutils/command/bdist_msi.py | 0 .../Lib/distutils/command/bdist_rpm.py | 0 .../Lib/distutils/command/bdist_wininst.py | 0 .../Lib/distutils/command/build.py | 0 .../Lib/distutils/command/build_clib.py | 0 .../Lib/distutils/command/build_ext.py | 0 .../Lib/distutils/command/build_py.py | 0 .../Lib/distutils/command/build_scripts.py | 0 .../Lib/distutils/command/check.py | 0 .../Lib/distutils/command/clean.py | 0 .../Lib/distutils/command/command_template | 0 .../Lib/distutils/command/config.py | 0 .../Lib/distutils/command/install.py | 0 .../Lib/distutils/command/install_data.py | 0 .../Lib/distutils/command/install_egg_info.py | 0 .../Lib/distutils/command/install_headers.py | 0 .../Lib/distutils/command/install_lib.py | 0 .../Lib/distutils/command/install_scripts.py | 0 .../Lib/distutils/command/register.py | 0 .../Lib/distutils/command/sdist.py | 0 .../Lib/distutils/command/upload.py | 0 .../Lib/distutils/command/wininst-10.0-amd64.exe | Bin .../Lib/distutils/command/wininst-10.0.exe | Bin .../Lib/distutils/command/wininst-6.0.exe | Bin .../Lib/distutils/command/wininst-7.1.exe | Bin .../Lib/distutils/command/wininst-8.0.exe | Bin .../Lib/distutils/command/wininst-9.0-amd64.exe | Bin .../Lib/distutils/command/wininst-9.0.exe | Bin .../IronPython.StdLib}/Lib/distutils/config.py | 0 .../IronPython.StdLib}/Lib/distutils/core.py | 0 .../Lib/distutils/cygwinccompiler.py | 0 .../IronPython.StdLib}/Lib/distutils/debug.py | 0 .../IronPython.StdLib}/Lib/distutils/dep_util.py | 0 .../IronPython.StdLib}/Lib/distutils/dir_util.py | 0 .../IronPython.StdLib}/Lib/distutils/dist.py | 0 .../IronPython.StdLib}/Lib/distutils/errors.py | 0 .../IronPython.StdLib}/Lib/distutils/extension.py | 0 .../Lib/distutils/fancy_getopt.py | 0 .../IronPython.StdLib}/Lib/distutils/file_util.py | 0 .../IronPython.StdLib}/Lib/distutils/filelist.py | 0 .../IronPython.StdLib}/Lib/distutils/log.py | 0 .../Lib/distutils/msvc9compiler.py | 0 .../Lib/distutils/msvccompiler.py | 0 .../IronPython.StdLib}/Lib/distutils/spawn.py | 0 .../IronPython.StdLib}/Lib/distutils/sysconfig.py | 0 .../Lib/distutils/tests/Setup.sample | 0 .../Lib/distutils/tests/__init__.py | 0 .../Lib/distutils/tests/support.py | 0 .../Lib/distutils/tests/test_archive_util.py | 0 .../Lib/distutils/tests/test_bdist.py | 0 .../Lib/distutils/tests/test_bdist_dumb.py | 0 .../Lib/distutils/tests/test_bdist_msi.py | 0 .../Lib/distutils/tests/test_bdist_rpm.py | 0 .../Lib/distutils/tests/test_bdist_wininst.py | 0 .../Lib/distutils/tests/test_build.py | 0 .../Lib/distutils/tests/test_build_clib.py | 0 .../Lib/distutils/tests/test_build_ext.py | 0 .../Lib/distutils/tests/test_build_py.py | 0 .../Lib/distutils/tests/test_build_scripts.py | 0 .../Lib/distutils/tests/test_check.py | 0 .../Lib/distutils/tests/test_clean.py | 0 .../Lib/distutils/tests/test_cmd.py | 0 .../Lib/distutils/tests/test_config.py | 0 .../Lib/distutils/tests/test_config_cmd.py | 0 .../Lib/distutils/tests/test_core.py | 0 .../Lib/distutils/tests/test_cygwinccompiler.py | 0 .../Lib/distutils/tests/test_dep_util.py | 0 .../Lib/distutils/tests/test_dir_util.py | 0 .../Lib/distutils/tests/test_dist.py | 0 .../Lib/distutils/tests/test_extension.py | 0 .../Lib/distutils/tests/test_file_util.py | 0 .../Lib/distutils/tests/test_filelist.py | 0 .../Lib/distutils/tests/test_install.py | 0 .../Lib/distutils/tests/test_install_data.py | 0 .../Lib/distutils/tests/test_install_headers.py | 0 .../Lib/distutils/tests/test_install_lib.py | 0 .../Lib/distutils/tests/test_install_scripts.py | 0 .../Lib/distutils/tests/test_log.py | 0 .../Lib/distutils/tests/test_msvc9compiler.py | 0 .../Lib/distutils/tests/test_register.py | 0 .../Lib/distutils/tests/test_sdist.py | 0 .../Lib/distutils/tests/test_spawn.py | 0 .../Lib/distutils/tests/test_sysconfig.py | 0 .../Lib/distutils/tests/test_text_file.py | 0 .../Lib/distutils/tests/test_unixccompiler.py | 0 .../Lib/distutils/tests/test_upload.py | 0 .../Lib/distutils/tests/test_util.py | 0 .../Lib/distutils/tests/test_version.py | 0 .../Lib/distutils/tests/test_versionpredicate.py | 0 .../IronPython.StdLib}/Lib/distutils/text_file.py | 0 .../Lib/distutils/unixccompiler.py | 0 .../IronPython.StdLib}/Lib/distutils/util.py | 0 .../IronPython.StdLib}/Lib/distutils/version.py | 0 .../Lib/distutils/versionpredicate.py | 0 .../IronPython.StdLib}/Lib/doctest.py | 0 .../IronPython.StdLib}/Lib/dummy_threading.py | 0 .../IronPython.StdLib}/Lib/email/__init__.py | 0 .../IronPython.StdLib}/Lib/email/_encoded_words.py | 0 .../Lib/email/_header_value_parser.py | 0 .../IronPython.StdLib}/Lib/email/_parseaddr.py | 0 .../IronPython.StdLib}/Lib/email/_policybase.py | 0 .../IronPython.StdLib}/Lib/email/architecture.rst | 0 .../IronPython.StdLib}/Lib/email/base64mime.py | 0 .../IronPython.StdLib}/Lib/email/charset.py | 0 .../IronPython.StdLib}/Lib/email/contentmanager.py | 0 .../IronPython.StdLib}/Lib/email/encoders.py | 0 .../IronPython.StdLib}/Lib/email/errors.py | 0 .../IronPython.StdLib}/Lib/email/feedparser.py | 0 .../IronPython.StdLib}/Lib/email/generator.py | 0 .../IronPython.StdLib}/Lib/email/header.py | 0 .../IronPython.StdLib}/Lib/email/headerregistry.py | 0 .../IronPython.StdLib}/Lib/email/iterators.py | 0 .../IronPython.StdLib}/Lib/email/message.py | 0 .../IronPython.StdLib}/Lib/email/mime/__init__.py | 0 .../Lib/email/mime/application.py | 0 .../IronPython.StdLib}/Lib/email/mime/audio.py | 0 .../IronPython.StdLib}/Lib/email/mime/base.py | 0 .../IronPython.StdLib}/Lib/email/mime/image.py | 0 .../IronPython.StdLib}/Lib/email/mime/message.py | 0 .../IronPython.StdLib}/Lib/email/mime/multipart.py | 0 .../Lib/email/mime/nonmultipart.py | 0 .../IronPython.StdLib}/Lib/email/mime/text.py | 0 .../IronPython.StdLib}/Lib/email/parser.py | 0 .../IronPython.StdLib}/Lib/email/policy.py | 0 .../IronPython.StdLib}/Lib/email/quoprimime.py | 0 .../IronPython.StdLib}/Lib/email/utils.py | 0 .../IronPython.StdLib}/Lib/encodings/__init__.py | 0 .../IronPython.StdLib}/Lib/encodings/aliases.py | 0 .../IronPython.StdLib}/Lib/encodings/ascii.py | 0 .../Lib/encodings/base64_codec.py | 0 .../IronPython.StdLib}/Lib/encodings/big5.py | 0 .../IronPython.StdLib}/Lib/encodings/big5hkscs.py | 0 .../IronPython.StdLib}/Lib/encodings/bz2_codec.py | 0 .../IronPython.StdLib}/Lib/encodings/charmap.py | 0 .../IronPython.StdLib}/Lib/encodings/cp037.py | 0 .../IronPython.StdLib}/Lib/encodings/cp1006.py | 0 .../IronPython.StdLib}/Lib/encodings/cp1026.py | 0 .../IronPython.StdLib}/Lib/encodings/cp1125.py | 0 .../IronPython.StdLib}/Lib/encodings/cp1140.py | 0 .../IronPython.StdLib}/Lib/encodings/cp1250.py | 0 .../IronPython.StdLib}/Lib/encodings/cp1251.py | 0 .../IronPython.StdLib}/Lib/encodings/cp1252.py | 0 .../IronPython.StdLib}/Lib/encodings/cp1253.py | 0 .../IronPython.StdLib}/Lib/encodings/cp1254.py | 0 .../IronPython.StdLib}/Lib/encodings/cp1255.py | 0 .../IronPython.StdLib}/Lib/encodings/cp1256.py | 0 .../IronPython.StdLib}/Lib/encodings/cp1257.py | 0 .../IronPython.StdLib}/Lib/encodings/cp1258.py | 0 .../IronPython.StdLib}/Lib/encodings/cp273.py | 0 .../IronPython.StdLib}/Lib/encodings/cp424.py | 0 .../IronPython.StdLib}/Lib/encodings/cp437.py | 0 .../IronPython.StdLib}/Lib/encodings/cp500.py | 0 .../IronPython.StdLib}/Lib/encodings/cp65001.py | 0 .../IronPython.StdLib}/Lib/encodings/cp720.py | 0 .../IronPython.StdLib}/Lib/encodings/cp737.py | 0 .../IronPython.StdLib}/Lib/encodings/cp775.py | 0 .../IronPython.StdLib}/Lib/encodings/cp850.py | 0 .../IronPython.StdLib}/Lib/encodings/cp852.py | 0 .../IronPython.StdLib}/Lib/encodings/cp855.py | 0 .../IronPython.StdLib}/Lib/encodings/cp856.py | 0 .../IronPython.StdLib}/Lib/encodings/cp857.py | 0 .../IronPython.StdLib}/Lib/encodings/cp858.py | 0 .../IronPython.StdLib}/Lib/encodings/cp860.py | 0 .../IronPython.StdLib}/Lib/encodings/cp861.py | 0 .../IronPython.StdLib}/Lib/encodings/cp862.py | 0 .../IronPython.StdLib}/Lib/encodings/cp863.py | 0 .../IronPython.StdLib}/Lib/encodings/cp864.py | 0 .../IronPython.StdLib}/Lib/encodings/cp865.py | 0 .../IronPython.StdLib}/Lib/encodings/cp866.py | 0 .../IronPython.StdLib}/Lib/encodings/cp869.py | 0 .../IronPython.StdLib}/Lib/encodings/cp874.py | 0 .../IronPython.StdLib}/Lib/encodings/cp875.py | 0 .../IronPython.StdLib}/Lib/encodings/cp932.py | 0 .../IronPython.StdLib}/Lib/encodings/cp949.py | 0 .../IronPython.StdLib}/Lib/encodings/cp950.py | 0 .../Lib/encodings/euc_jis_2004.py | 0 .../Lib/encodings/euc_jisx0213.py | 0 .../IronPython.StdLib}/Lib/encodings/euc_jp.py | 0 .../IronPython.StdLib}/Lib/encodings/euc_kr.py | 0 .../IronPython.StdLib}/Lib/encodings/gb18030.py | 0 .../IronPython.StdLib}/Lib/encodings/gb2312.py | 0 .../IronPython.StdLib}/Lib/encodings/gbk.py | 0 .../IronPython.StdLib}/Lib/encodings/hex_codec.py | 0 .../IronPython.StdLib}/Lib/encodings/hp_roman8.py | 0 .../IronPython.StdLib}/Lib/encodings/hz.py | 0 .../IronPython.StdLib}/Lib/encodings/idna.py | 0 .../IronPython.StdLib}/Lib/encodings/iso2022_jp.py | 0 .../Lib/encodings/iso2022_jp_1.py | 0 .../Lib/encodings/iso2022_jp_2.py | 0 .../Lib/encodings/iso2022_jp_2004.py | 0 .../Lib/encodings/iso2022_jp_3.py | 0 .../Lib/encodings/iso2022_jp_ext.py | 0 .../IronPython.StdLib}/Lib/encodings/iso2022_kr.py | 0 .../IronPython.StdLib}/Lib/encodings/iso8859_1.py | 0 .../IronPython.StdLib}/Lib/encodings/iso8859_10.py | 0 .../IronPython.StdLib}/Lib/encodings/iso8859_11.py | 0 .../IronPython.StdLib}/Lib/encodings/iso8859_13.py | 0 .../IronPython.StdLib}/Lib/encodings/iso8859_14.py | 0 .../IronPython.StdLib}/Lib/encodings/iso8859_15.py | 0 .../IronPython.StdLib}/Lib/encodings/iso8859_16.py | 0 .../IronPython.StdLib}/Lib/encodings/iso8859_2.py | 0 .../IronPython.StdLib}/Lib/encodings/iso8859_3.py | 0 .../IronPython.StdLib}/Lib/encodings/iso8859_4.py | 0 .../IronPython.StdLib}/Lib/encodings/iso8859_5.py | 0 .../IronPython.StdLib}/Lib/encodings/iso8859_6.py | 0 .../IronPython.StdLib}/Lib/encodings/iso8859_7.py | 0 .../IronPython.StdLib}/Lib/encodings/iso8859_8.py | 0 .../IronPython.StdLib}/Lib/encodings/iso8859_9.py | 0 .../IronPython.StdLib}/Lib/encodings/johab.py | 0 .../IronPython.StdLib}/Lib/encodings/koi8_r.py | 0 .../IronPython.StdLib}/Lib/encodings/koi8_u.py | 0 .../IronPython.StdLib}/Lib/encodings/latin_1.py | 0 .../IronPython.StdLib}/Lib/encodings/mac_arabic.py | 0 .../Lib/encodings/mac_centeuro.py | 0 .../Lib/encodings/mac_croatian.py | 0 .../Lib/encodings/mac_cyrillic.py | 0 .../IronPython.StdLib}/Lib/encodings/mac_farsi.py | 0 .../IronPython.StdLib}/Lib/encodings/mac_greek.py | 0 .../IronPython.StdLib}/Lib/encodings/mac_iceland.py | 0 .../IronPython.StdLib}/Lib/encodings/mac_latin2.py | 0 .../IronPython.StdLib}/Lib/encodings/mac_roman.py | 0 .../Lib/encodings/mac_romanian.py | 0 .../IronPython.StdLib}/Lib/encodings/mac_turkish.py | 0 .../IronPython.StdLib}/Lib/encodings/mbcs.py | 0 .../IronPython.StdLib}/Lib/encodings/palmos.py | 0 .../IronPython.StdLib}/Lib/encodings/ptcp154.py | 0 .../IronPython.StdLib}/Lib/encodings/punycode.py | 0 .../Lib/encodings/quopri_codec.py | 0 .../Lib/encodings/raw_unicode_escape.py | 0 .../IronPython.StdLib}/Lib/encodings/rot_13.py | 0 .../IronPython.StdLib}/Lib/encodings/shift_jis.py | 0 .../Lib/encodings/shift_jis_2004.py | 0 .../Lib/encodings/shift_jisx0213.py | 0 .../IronPython.StdLib}/Lib/encodings/tis_620.py | 0 .../IronPython.StdLib}/Lib/encodings/undefined.py | 0 .../Lib/encodings/unicode_escape.py | 0 .../Lib/encodings/unicode_internal.py | 0 .../IronPython.StdLib}/Lib/encodings/utf_16.py | 0 .../IronPython.StdLib}/Lib/encodings/utf_16_be.py | 0 .../IronPython.StdLib}/Lib/encodings/utf_16_le.py | 0 .../IronPython.StdLib}/Lib/encodings/utf_32.py | 0 .../IronPython.StdLib}/Lib/encodings/utf_32_be.py | 0 .../IronPython.StdLib}/Lib/encodings/utf_32_le.py | 0 .../IronPython.StdLib}/Lib/encodings/utf_7.py | 0 .../IronPython.StdLib}/Lib/encodings/utf_8.py | 0 .../IronPython.StdLib}/Lib/encodings/utf_8_sig.py | 0 .../IronPython.StdLib}/Lib/encodings/uu_codec.py | 0 .../IronPython.StdLib}/Lib/encodings/zlib_codec.py | 0 .../IronPython.StdLib}/Lib/ensurepip/__init__.py | 0 .../IronPython.StdLib}/Lib/ensurepip/__main__.py | 0 .../_bundled/pip-18.1-py2.py3-none-any.whl | Bin .../_bundled/setuptools-40.6.2-py2.py3-none-any.whl | Bin .../IronPython.StdLib}/Lib/ensurepip/_uninstall.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/enum.py | 0 .../IronPython.StdLib}/Lib/filecmp.py | 0 .../IronPython.StdLib}/Lib/fileinput.py | 0 .../IronPython.StdLib}/Lib/fnmatch.py | 0 .../IronPython.StdLib}/Lib/formatter.py | 0 .../IronPython.StdLib}/Lib/fractions.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/ftplib.py | 0 .../IronPython.StdLib}/Lib/functools.py | 0 .../IronPython.StdLib}/Lib/genericpath.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/getopt.py | 0 .../IronPython.StdLib}/Lib/getpass.py | 0 .../IronPython.StdLib}/Lib/gettext.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/glob.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/gzip.py | 0 .../IronPython.StdLib}/Lib/hashlib.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/heapq.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/hmac.py | 0 .../IronPython.StdLib}/Lib/html/__init__.py | 0 .../IronPython.StdLib}/Lib/html/entities.py | 0 .../IronPython.StdLib}/Lib/html/parser.py | 0 .../IronPython.StdLib}/Lib/http/__init__.py | 0 .../IronPython.StdLib}/Lib/http/client.py | 0 .../IronPython.StdLib}/Lib/http/cookiejar.py | 0 .../IronPython.StdLib}/Lib/http/cookies.py | 0 .../IronPython.StdLib}/Lib/http/server.py | 0 .../IronPython.StdLib}/Lib/idlelib/AutoComplete.py | 0 .../Lib/idlelib/AutoCompleteWindow.py | 0 .../IronPython.StdLib}/Lib/idlelib/AutoExpand.py | 0 .../IronPython.StdLib}/Lib/idlelib/Bindings.py | 0 .../IronPython.StdLib}/Lib/idlelib/CREDITS.txt | 0 .../IronPython.StdLib}/Lib/idlelib/CallTipWindow.py | 0 .../IronPython.StdLib}/Lib/idlelib/CallTips.py | 0 .../IronPython.StdLib}/Lib/idlelib/ChangeLog | 0 .../IronPython.StdLib}/Lib/idlelib/ClassBrowser.py | 0 .../IronPython.StdLib}/Lib/idlelib/CodeContext.py | 0 .../Lib/idlelib/ColorDelegator.py | 0 .../IronPython.StdLib}/Lib/idlelib/Debugger.py | 0 .../IronPython.StdLib}/Lib/idlelib/Delegator.py | 0 .../IronPython.StdLib}/Lib/idlelib/EditorWindow.py | 0 .../IronPython.StdLib}/Lib/idlelib/FileList.py | 0 .../Lib/idlelib/FormatParagraph.py | 0 .../IronPython.StdLib}/Lib/idlelib/GrepDialog.py | 0 .../IronPython.StdLib}/Lib/idlelib/HISTORY.txt | 0 .../IronPython.StdLib}/Lib/idlelib/HyperParser.py | 0 .../IronPython.StdLib}/Lib/idlelib/IOBinding.py | 0 .../IronPython.StdLib}/Lib/idlelib/Icons/folder.gif | Bin .../IronPython.StdLib}/Lib/idlelib/Icons/idle.icns | Bin .../IronPython.StdLib}/Lib/idlelib/Icons/idle.ico | Bin .../Lib/idlelib/Icons/idle_16.gif | Bin .../Lib/idlelib/Icons/idle_16.png | Bin .../Lib/idlelib/Icons/idle_32.gif | Bin .../Lib/idlelib/Icons/idle_32.png | Bin .../Lib/idlelib/Icons/idle_48.gif | Bin .../Lib/idlelib/Icons/idle_48.png | Bin .../Lib/idlelib/Icons/minusnode.gif | Bin .../Lib/idlelib/Icons/openfolder.gif | Bin .../Lib/idlelib/Icons/plusnode.gif | Bin .../IronPython.StdLib}/Lib/idlelib/Icons/python.gif | Bin .../IronPython.StdLib}/Lib/idlelib/Icons/tk.gif | Bin .../IronPython.StdLib}/Lib/idlelib/IdleHistory.py | 0 .../IronPython.StdLib}/Lib/idlelib/MultiCall.py | 0 .../Lib/idlelib/MultiStatusBar.py | 0 .../IronPython.StdLib}/Lib/idlelib/NEWS.txt | 0 .../IronPython.StdLib}/Lib/idlelib/ObjectBrowser.py | 0 .../IronPython.StdLib}/Lib/idlelib/OutputWindow.py | 0 .../IronPython.StdLib}/Lib/idlelib/ParenMatch.py | 0 .../IronPython.StdLib}/Lib/idlelib/PathBrowser.py | 0 .../IronPython.StdLib}/Lib/idlelib/Percolator.py | 0 .../IronPython.StdLib}/Lib/idlelib/PyParse.py | 0 .../IronPython.StdLib}/Lib/idlelib/PyShell.py | 0 .../IronPython.StdLib}/Lib/idlelib/README.txt | 0 .../Lib/idlelib/RemoteDebugger.py | 0 .../Lib/idlelib/RemoteObjectBrowser.py | 0 .../IronPython.StdLib}/Lib/idlelib/ReplaceDialog.py | 0 .../Lib/idlelib/RstripExtension.py | 0 .../IronPython.StdLib}/Lib/idlelib/ScriptBinding.py | 0 .../IronPython.StdLib}/Lib/idlelib/ScrolledList.py | 0 .../IronPython.StdLib}/Lib/idlelib/SearchDialog.py | 0 .../Lib/idlelib/SearchDialogBase.py | 0 .../IronPython.StdLib}/Lib/idlelib/SearchEngine.py | 0 .../IronPython.StdLib}/Lib/idlelib/StackViewer.py | 0 .../IronPython.StdLib}/Lib/idlelib/TODO.txt | 0 .../IronPython.StdLib}/Lib/idlelib/ToolTip.py | 0 .../IronPython.StdLib}/Lib/idlelib/TreeWidget.py | 0 .../IronPython.StdLib}/Lib/idlelib/UndoDelegator.py | 0 .../Lib/idlelib/WidgetRedirector.py | 0 .../IronPython.StdLib}/Lib/idlelib/WindowList.py | 0 .../IronPython.StdLib}/Lib/idlelib/ZoomHeight.py | 0 .../IronPython.StdLib}/Lib/idlelib/__init__.py | 0 .../IronPython.StdLib}/Lib/idlelib/__main__.py | 0 .../IronPython.StdLib}/Lib/idlelib/aboutDialog.py | 0 .../Lib/idlelib/config-extensions.def | 0 .../Lib/idlelib/config-highlight.def | 0 .../IronPython.StdLib}/Lib/idlelib/config-keys.def | 0 .../IronPython.StdLib}/Lib/idlelib/config-main.def | 0 .../IronPython.StdLib}/Lib/idlelib/configDialog.py | 0 .../IronPython.StdLib}/Lib/idlelib/configHandler.py | 0 .../Lib/idlelib/configHelpSourceEdit.py | 0 .../Lib/idlelib/configSectionNameDialog.py | 0 .../Lib/idlelib/dynOptionMenuWidget.py | 0 .../IronPython.StdLib}/Lib/idlelib/extend.txt | 0 .../IronPython.StdLib}/Lib/idlelib/help.html | 0 .../IronPython.StdLib}/Lib/idlelib/help.py | 0 .../IronPython.StdLib}/Lib/idlelib/help.txt | 0 .../IronPython.StdLib}/Lib/idlelib/idle.bat | 0 .../IronPython.StdLib}/Lib/idlelib/idle.py | 0 .../IronPython.StdLib}/Lib/idlelib/idle.pyw | 0 .../Lib/idlelib/idle_test/README.txt | 0 .../Lib/idlelib/idle_test/__init__.py | 0 .../Lib/idlelib/idle_test/htest.py | 0 .../Lib/idlelib/idle_test/mock_idle.py | 0 .../Lib/idlelib/idle_test/mock_tk.py | 0 .../Lib/idlelib/idle_test/test_autocomplete.py | 0 .../Lib/idlelib/idle_test/test_autoexpand.py | 0 .../Lib/idlelib/idle_test/test_calltips.py | 0 .../Lib/idlelib/idle_test/test_config_name.py | 0 .../Lib/idlelib/idle_test/test_configdialog.py | 0 .../Lib/idlelib/idle_test/test_delegator.py | 0 .../Lib/idlelib/idle_test/test_editor.py | 0 .../Lib/idlelib/idle_test/test_formatparagraph.py | 0 .../Lib/idlelib/idle_test/test_grep.py | 0 .../Lib/idlelib/idle_test/test_hyperparser.py | 0 .../Lib/idlelib/idle_test/test_idlehistory.py | 0 .../Lib/idlelib/idle_test/test_io.py | 0 .../Lib/idlelib/idle_test/test_parenmatch.py | 0 .../Lib/idlelib/idle_test/test_pathbrowser.py | 0 .../Lib/idlelib/idle_test/test_rstrip.py | 0 .../Lib/idlelib/idle_test/test_searchdialogbase.py | 0 .../Lib/idlelib/idle_test/test_searchengine.py | 0 .../Lib/idlelib/idle_test/test_text.py | 0 .../Lib/idlelib/idle_test/test_textview.py | 0 .../Lib/idlelib/idle_test/test_warning.py | 0 .../Lib/idlelib/idle_test/test_widgetredir.py | 0 .../IronPython.StdLib}/Lib/idlelib/idlever.py | 0 .../Lib/idlelib/keybindingDialog.py | 0 .../IronPython.StdLib}/Lib/idlelib/macosxSupport.py | 0 .../IronPython.StdLib}/Lib/idlelib/rpc.py | 0 .../IronPython.StdLib}/Lib/idlelib/run.py | 0 .../IronPython.StdLib}/Lib/idlelib/tabbedpages.py | 0 .../IronPython.StdLib}/Lib/idlelib/textView.py | 0 .../IronPython.StdLib}/Lib/imaplib.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/imghdr.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/imp.py | 0 .../IronPython.StdLib}/Lib/importlib/__init__.py | 0 .../IronPython.StdLib}/Lib/importlib/_bootstrap.py | 0 .../IronPython.StdLib}/Lib/importlib/abc.py | 0 .../IronPython.StdLib}/Lib/importlib/machinery.py | 0 .../IronPython.StdLib}/Lib/importlib/util.py | 0 .../IronPython.StdLib}/Lib/inspect.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/io.py | 0 .../IronPython.StdLib}/Lib/ipaddress.py | 0 .../IronPython.StdLib}/Lib/json/__init__.py | 0 .../IronPython.StdLib}/Lib/json/decoder.py | 0 .../IronPython.StdLib}/Lib/json/encoder.py | 0 .../IronPython.StdLib}/Lib/json/scanner.py | 0 .../IronPython.StdLib}/Lib/json/tool.py | 0 .../IronPython.StdLib}/Lib/keyword.py | 0 .../IronPython.StdLib}/Lib/lib2to3/Grammar.txt | 0 .../Lib/lib2to3/PatternGrammar.txt | 0 .../IronPython.StdLib}/Lib/lib2to3/__init__.py | 0 .../IronPython.StdLib}/Lib/lib2to3/__main__.py | 0 .../IronPython.StdLib}/Lib/lib2to3/btm_matcher.py | 0 .../IronPython.StdLib}/Lib/lib2to3/btm_utils.py | 0 .../IronPython.StdLib}/Lib/lib2to3/fixer_base.py | 0 .../IronPython.StdLib}/Lib/lib2to3/fixer_util.py | 0 .../Lib/lib2to3/fixes/__init__.py | 0 .../Lib/lib2to3/fixes/fix_apply.py | 0 .../Lib/lib2to3/fixes/fix_asserts.py | 0 .../Lib/lib2to3/fixes/fix_basestring.py | 0 .../Lib/lib2to3/fixes/fix_buffer.py | 0 .../Lib/lib2to3/fixes/fix_callable.py | 0 .../Lib/lib2to3/fixes/fix_dict.py | 0 .../Lib/lib2to3/fixes/fix_except.py | 0 .../Lib/lib2to3/fixes/fix_exec.py | 0 .../Lib/lib2to3/fixes/fix_execfile.py | 0 .../Lib/lib2to3/fixes/fix_exitfunc.py | 0 .../Lib/lib2to3/fixes/fix_filter.py | 0 .../Lib/lib2to3/fixes/fix_funcattrs.py | 0 .../Lib/lib2to3/fixes/fix_future.py | 0 .../Lib/lib2to3/fixes/fix_getcwdu.py | 0 .../Lib/lib2to3/fixes/fix_has_key.py | 0 .../Lib/lib2to3/fixes/fix_idioms.py | 0 .../Lib/lib2to3/fixes/fix_import.py | 0 .../Lib/lib2to3/fixes/fix_imports.py | 0 .../Lib/lib2to3/fixes/fix_imports2.py | 0 .../Lib/lib2to3/fixes/fix_input.py | 0 .../Lib/lib2to3/fixes/fix_intern.py | 0 .../Lib/lib2to3/fixes/fix_isinstance.py | 0 .../Lib/lib2to3/fixes/fix_itertools.py | 0 .../Lib/lib2to3/fixes/fix_itertools_imports.py | 0 .../Lib/lib2to3/fixes/fix_long.py | 0 .../IronPython.StdLib}/Lib/lib2to3/fixes/fix_map.py | 0 .../Lib/lib2to3/fixes/fix_metaclass.py | 0 .../Lib/lib2to3/fixes/fix_methodattrs.py | 0 .../IronPython.StdLib}/Lib/lib2to3/fixes/fix_ne.py | 0 .../Lib/lib2to3/fixes/fix_next.py | 0 .../Lib/lib2to3/fixes/fix_nonzero.py | 0 .../Lib/lib2to3/fixes/fix_numliterals.py | 0 .../Lib/lib2to3/fixes/fix_operator.py | 0 .../Lib/lib2to3/fixes/fix_paren.py | 0 .../Lib/lib2to3/fixes/fix_print.py | 0 .../Lib/lib2to3/fixes/fix_raise.py | 0 .../Lib/lib2to3/fixes/fix_raw_input.py | 0 .../Lib/lib2to3/fixes/fix_reduce.py | 0 .../Lib/lib2to3/fixes/fix_reload.py | 0 .../Lib/lib2to3/fixes/fix_renames.py | 0 .../Lib/lib2to3/fixes/fix_repr.py | 0 .../Lib/lib2to3/fixes/fix_set_literal.py | 0 .../Lib/lib2to3/fixes/fix_standarderror.py | 0 .../Lib/lib2to3/fixes/fix_sys_exc.py | 0 .../Lib/lib2to3/fixes/fix_throw.py | 0 .../Lib/lib2to3/fixes/fix_tuple_params.py | 0 .../Lib/lib2to3/fixes/fix_types.py | 0 .../Lib/lib2to3/fixes/fix_unicode.py | 0 .../Lib/lib2to3/fixes/fix_urllib.py | 0 .../Lib/lib2to3/fixes/fix_ws_comma.py | 0 .../Lib/lib2to3/fixes/fix_xrange.py | 0 .../Lib/lib2to3/fixes/fix_xreadlines.py | 0 .../IronPython.StdLib}/Lib/lib2to3/fixes/fix_zip.py | 0 .../IronPython.StdLib}/Lib/lib2to3/main.py | 0 .../IronPython.StdLib}/Lib/lib2to3/patcomp.py | 0 .../Lib/lib2to3/pgen2/__init__.py | 0 .../IronPython.StdLib}/Lib/lib2to3/pgen2/conv.py | 0 .../IronPython.StdLib}/Lib/lib2to3/pgen2/driver.py | 0 .../IronPython.StdLib}/Lib/lib2to3/pgen2/grammar.py | 0 .../Lib/lib2to3/pgen2/literals.py | 0 .../IronPython.StdLib}/Lib/lib2to3/pgen2/parse.py | 0 .../IronPython.StdLib}/Lib/lib2to3/pgen2/pgen.py | 0 .../IronPython.StdLib}/Lib/lib2to3/pgen2/token.py | 0 .../Lib/lib2to3/pgen2/tokenize.py | 0 .../IronPython.StdLib}/Lib/lib2to3/pygram.py | 0 .../IronPython.StdLib}/Lib/lib2to3/pytree.py | 0 .../IronPython.StdLib}/Lib/lib2to3/refactor.py | 0 .../Lib/lib2to3/tests/__init__.py | 0 .../Lib/lib2to3/tests/__main__.py | 0 .../Lib/lib2to3/tests/data/README | 0 .../Lib/lib2to3/tests/data/bom.py | 0 .../Lib/lib2to3/tests/data/crlf.py | 0 .../Lib/lib2to3/tests/data/different_encoding.py | 0 .../Lib/lib2to3/tests/data/false_encoding.py | 0 .../Lib/lib2to3/tests/data/fixers/bad_order.py | 0 .../lib2to3/tests/data/fixers/myfixes/__init__.py | 0 .../tests/data/fixers/myfixes/fix_explicit.py | 0 .../lib2to3/tests/data/fixers/myfixes/fix_first.py | 0 .../lib2to3/tests/data/fixers/myfixes/fix_last.py | 0 .../lib2to3/tests/data/fixers/myfixes/fix_parrot.py | 0 .../tests/data/fixers/myfixes/fix_preorder.py | 0 .../Lib/lib2to3/tests/data/fixers/no_fixer_cls.py | 0 .../Lib/lib2to3/tests/data/fixers/parrot_example.py | 0 .../Lib/lib2to3/tests/data/infinite_recursion.py | 0 .../Lib/lib2to3/tests/data/py2_test_grammar.py | 0 .../Lib/lib2to3/tests/data/py3_test_grammar.py | 0 .../Lib/lib2to3/tests/pytree_idempotency.py | 0 .../IronPython.StdLib}/Lib/lib2to3/tests/support.py | 0 .../Lib/lib2to3/tests/test_all_fixers.py | 0 .../Lib/lib2to3/tests/test_fixers.py | 0 .../Lib/lib2to3/tests/test_main.py | 0 .../Lib/lib2to3/tests/test_parser.py | 0 .../Lib/lib2to3/tests/test_pytree.py | 0 .../Lib/lib2to3/tests/test_refactor.py | 0 .../Lib/lib2to3/tests/test_util.py | 0 .../IronPython.StdLib}/Lib/linecache.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/locale.py | 0 .../IronPython.StdLib}/Lib/logging/__init__.py | 0 .../IronPython.StdLib}/Lib/logging/config.py | 0 .../IronPython.StdLib}/Lib/logging/handlers.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/lzma.py | 0 .../IronPython.StdLib}/Lib/macpath.py | 0 .../IronPython.StdLib}/Lib/macurl2path.py | 0 .../IronPython.StdLib}/Lib/mailbox.py | 0 .../IronPython.StdLib}/Lib/mailcap.py | 0 .../IronPython.StdLib}/Lib/mimetypes.py | 0 .../IronPython.StdLib}/Lib/modulefinder.py | 0 .../IronPython.StdLib}/Lib/msilib/__init__.py | 0 .../IronPython.StdLib}/Lib/msilib/schema.py | 0 .../IronPython.StdLib}/Lib/msilib/sequence.py | 0 .../IronPython.StdLib}/Lib/msilib/text.py | 0 .../Lib/multiprocessing/__init__.py | 0 .../Lib/multiprocessing/connection.py | 0 .../Lib/multiprocessing/context.py | 0 .../Lib/multiprocessing/dummy/__init__.py | 0 .../Lib/multiprocessing/dummy/connection.py | 0 .../Lib/multiprocessing/forkserver.py | 0 .../IronPython.StdLib}/Lib/multiprocessing/heap.py | 0 .../Lib/multiprocessing/managers.py | 0 .../IronPython.StdLib}/Lib/multiprocessing/pool.py | 0 .../Lib/multiprocessing/popen_fork.py | 0 .../Lib/multiprocessing/popen_forkserver.py | 0 .../Lib/multiprocessing/popen_spawn_posix.py | 0 .../Lib/multiprocessing/popen_spawn_win32.py | 0 .../Lib/multiprocessing/process.py | 0 .../Lib/multiprocessing/queues.py | 0 .../Lib/multiprocessing/reduction.py | 0 .../Lib/multiprocessing/resource_sharer.py | 0 .../Lib/multiprocessing/semaphore_tracker.py | 0 .../Lib/multiprocessing/sharedctypes.py | 0 .../IronPython.StdLib}/Lib/multiprocessing/spawn.py | 0 .../Lib/multiprocessing/synchronize.py | 0 .../IronPython.StdLib}/Lib/multiprocessing/util.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/netrc.py | 0 .../IronPython.StdLib}/Lib/nntplib.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/ntpath.py | 0 .../IronPython.StdLib}/Lib/nturl2path.py | 0 .../IronPython.StdLib}/Lib/numbers.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/opcode.py | 0 .../IronPython.StdLib}/Lib/operator.py | 0 .../IronPython.StdLib}/Lib/optparse.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/os.py | 0 .../IronPython.StdLib}/Lib/pathlib.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/pdb.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/pickle.py | 0 .../IronPython.StdLib}/Lib/pickletools.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/pipes.py | 0 .../IronPython.StdLib}/Lib/pkgutil.py | 0 .../IronPython.StdLib}/Lib/platform.py | 0 .../IronPython.StdLib}/Lib/plistlib.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/poplib.py | 0 .../IronPython.StdLib}/Lib/posixpath.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/pprint.py | 0 .../IronPython.StdLib}/Lib/profile.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/pstats.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/pty.py | 0 .../IronPython.StdLib}/Lib/py_compile.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/pyclbr.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/pydoc.py | 0 .../IronPython.StdLib}/Lib/pydoc_data/__init__.py | 0 .../IronPython.StdLib}/Lib/pydoc_data/_pydoc.css | 0 .../IronPython.StdLib}/Lib/pydoc_data/topics.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/queue.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/quopri.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/random.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/re.py | 0 .../IronPython.StdLib}/Lib/reprlib.py | 0 .../IronPython.StdLib}/Lib/rlcompleter.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/runpy.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/sched.py | 0 .../IronPython.StdLib}/Lib/selectors.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/shelve.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/shlex.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/shutil.py | 0 .../IronPython.StdLib}/Lib/site-packages/README | 0 .../StdLib => core/IronPython.StdLib}/Lib/site.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/smtpd.py | 0 .../IronPython.StdLib}/Lib/smtplib.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/sndhdr.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/socket.py | 0 .../IronPython.StdLib}/Lib/socketserver.py | 0 .../IronPython.StdLib}/Lib/sqlite3/__init__.py | 0 .../IronPython.StdLib}/Lib/sqlite3/dbapi2.py | 0 .../IronPython.StdLib}/Lib/sqlite3/dump.py | 0 .../IronPython.StdLib}/Lib/sqlite3/test/__init__.py | 0 .../IronPython.StdLib}/Lib/sqlite3/test/dbapi.py | 0 .../IronPython.StdLib}/Lib/sqlite3/test/dump.py | 0 .../IronPython.StdLib}/Lib/sqlite3/test/factory.py | 0 .../IronPython.StdLib}/Lib/sqlite3/test/hooks.py | 0 .../Lib/sqlite3/test/regression.py | 0 .../Lib/sqlite3/test/transactions.py | 0 .../IronPython.StdLib}/Lib/sqlite3/test/types.py | 0 .../Lib/sqlite3/test/userfunctions.py | 0 .../IronPython.StdLib}/Lib/sre_compile.py | 0 .../IronPython.StdLib}/Lib/sre_constants.py | 0 .../IronPython.StdLib}/Lib/sre_parse.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/ssl.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/stat.py | 0 .../IronPython.StdLib}/Lib/statistics.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/string.py | 0 .../IronPython.StdLib}/Lib/stringprep.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/struct.py | 0 .../IronPython.StdLib}/Lib/subprocess.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/sunau.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/symbol.py | 0 .../IronPython.StdLib}/Lib/symtable.py | 0 .../IronPython.StdLib}/Lib/sysconfig.py | 0 .../IronPython.StdLib}/Lib/tabnanny.py | 0 .../IronPython.StdLib}/Lib/tarfile.py | 0 .../IronPython.StdLib}/Lib/telnetlib.py | 0 .../IronPython.StdLib}/Lib/tempfile.py | 0 .../IronPython.StdLib}/Lib/test/185test.db | Bin .../Lib/test/Sine-1000Hz-300ms.aif | Bin .../IronPython.StdLib}/Lib/test/__init__.py | 0 .../IronPython.StdLib}/Lib/test/__main__.py | 0 .../Lib/test/_test_multiprocessing.py | 0 .../Lib/test/audiodata/pluck-alaw.aifc | Bin .../Lib/test/audiodata/pluck-pcm16.aiff | Bin .../Lib/test/audiodata/pluck-pcm16.au | Bin .../Lib/test/audiodata/pluck-pcm16.wav | Bin .../Lib/test/audiodata/pluck-pcm24.aiff | Bin .../Lib/test/audiodata/pluck-pcm24.au | Bin .../Lib/test/audiodata/pluck-pcm24.wav | Bin .../Lib/test/audiodata/pluck-pcm32.aiff | Bin .../Lib/test/audiodata/pluck-pcm32.au | Bin .../Lib/test/audiodata/pluck-pcm32.wav | Bin .../Lib/test/audiodata/pluck-pcm8.aiff | Bin .../Lib/test/audiodata/pluck-pcm8.au | Bin .../Lib/test/audiodata/pluck-pcm8.wav | Bin .../Lib/test/audiodata/pluck-ulaw.aifc | Bin .../Lib/test/audiodata/pluck-ulaw.au | Bin .../IronPython.StdLib}/Lib/test/audiotest.au | Bin .../IronPython.StdLib}/Lib/test/audiotests.py | 0 .../IronPython.StdLib}/Lib/test/autotest.py | 0 .../IronPython.StdLib}/Lib/test/bad_coding.py | 0 .../IronPython.StdLib}/Lib/test/bad_coding2.py | 0 .../IronPython.StdLib}/Lib/test/badcert.pem | 0 .../IronPython.StdLib}/Lib/test/badkey.pem | 0 .../IronPython.StdLib}/Lib/test/badsyntax_3131.py | 0 .../Lib/test/badsyntax_future10.py | 0 .../Lib/test/badsyntax_future3.py | 0 .../Lib/test/badsyntax_future4.py | 0 .../Lib/test/badsyntax_future5.py | 0 .../Lib/test/badsyntax_future6.py | 0 .../Lib/test/badsyntax_future7.py | 0 .../Lib/test/badsyntax_future8.py | 0 .../Lib/test/badsyntax_future9.py | 0 .../Lib/test/badsyntax_pep3120.py | 0 .../IronPython.StdLib}/Lib/test/buffer_tests.py | 0 .../IronPython.StdLib}/Lib/test/bytecode_helper.py | 0 .../IronPython.StdLib}/Lib/test/capath/0e4015b9.0 | 0 .../IronPython.StdLib}/Lib/test/capath/4e1295a3.0 | 0 .../IronPython.StdLib}/Lib/test/capath/5ed36f99.0 | 0 .../IronPython.StdLib}/Lib/test/capath/6e88d7b8.0 | 0 .../IronPython.StdLib}/Lib/test/capath/99d0fa06.0 | 0 .../IronPython.StdLib}/Lib/test/capath/ce7b8643.0 | 0 .../IronPython.StdLib}/Lib/test/cfgparser.1 | 0 .../IronPython.StdLib}/Lib/test/cfgparser.2 | 0 .../IronPython.StdLib}/Lib/test/cfgparser.3 | 0 .../IronPython.StdLib}/Lib/test/check_soundcard.vbs | 0 .../Lib/test/cjkencodings/big5-utf8.txt | 0 .../Lib/test/cjkencodings/big5.txt | 0 .../Lib/test/cjkencodings/big5hkscs-utf8.txt | 0 .../Lib/test/cjkencodings/big5hkscs.txt | 0 .../Lib/test/cjkencodings/cp949-utf8.txt | 0 .../Lib/test/cjkencodings/cp949.txt | 0 .../Lib/test/cjkencodings/euc_jisx0213-utf8.txt | 0 .../Lib/test/cjkencodings/euc_jisx0213.txt | 0 .../Lib/test/cjkencodings/euc_jp-utf8.txt | 0 .../Lib/test/cjkencodings/euc_jp.txt | 0 .../Lib/test/cjkencodings/euc_kr-utf8.txt | 0 .../Lib/test/cjkencodings/euc_kr.txt | 0 .../Lib/test/cjkencodings/gb18030-utf8.txt | 0 .../Lib/test/cjkencodings/gb18030.txt | 0 .../Lib/test/cjkencodings/gb2312-utf8.txt | 0 .../Lib/test/cjkencodings/gb2312.txt | 0 .../Lib/test/cjkencodings/gbk-utf8.txt | 0 .../Lib/test/cjkencodings/gbk.txt | 0 .../Lib/test/cjkencodings/hz-utf8.txt | 0 .../IronPython.StdLib}/Lib/test/cjkencodings/hz.txt | 0 .../Lib/test/cjkencodings/iso2022_jp-utf8.txt | 0 .../Lib/test/cjkencodings/iso2022_jp.txt | 0 .../Lib/test/cjkencodings/iso2022_kr-utf8.txt | 0 .../Lib/test/cjkencodings/iso2022_kr.txt | 0 .../Lib/test/cjkencodings/johab-utf8.txt | 0 .../Lib/test/cjkencodings/johab.txt | 0 .../Lib/test/cjkencodings/shift_jis-utf8.txt | 0 .../Lib/test/cjkencodings/shift_jis.txt | 0 .../Lib/test/cjkencodings/shift_jisx0213-utf8.txt | 0 .../Lib/test/cjkencodings/shift_jisx0213.txt | 0 .../IronPython.StdLib}/Lib/test/cmath_testcases.txt | 0 .../IronPython.StdLib}/Lib/test/coding20731.py | 0 .../IronPython.StdLib}/Lib/test/crashers/README | 0 .../Lib/test/crashers/bogus_code_obj.py | 0 .../Lib/test/crashers/gc_inspection.py | 0 .../Lib/test/crashers/infinite_loop_re.py | 0 .../Lib/test/crashers/mutation_inside_cyclegc.py | 0 .../Lib/test/crashers/recursive_call.py | 0 .../Lib/test/crashers/trace_at_recursion_limit.py | 0 .../Lib/test/crashers/underlying_dict.py | 0 .../IronPython.StdLib}/Lib/test/curses_tests.py | 0 .../IronPython.StdLib}/Lib/test/data/README | 0 .../IronPython.StdLib}/Lib/test/datetimetester.py | 0 .../Lib/test/decimaltestdata/abs.decTest | 0 .../Lib/test/decimaltestdata/add.decTest | 0 .../Lib/test/decimaltestdata/and.decTest | 0 .../Lib/test/decimaltestdata/base.decTest | 0 .../Lib/test/decimaltestdata/clamp.decTest | 0 .../Lib/test/decimaltestdata/class.decTest | 0 .../Lib/test/decimaltestdata/compare.decTest | 0 .../Lib/test/decimaltestdata/comparetotal.decTest | 0 .../Lib/test/decimaltestdata/comparetotmag.decTest | 0 .../Lib/test/decimaltestdata/copy.decTest | 0 .../Lib/test/decimaltestdata/copyabs.decTest | 0 .../Lib/test/decimaltestdata/copynegate.decTest | 0 .../Lib/test/decimaltestdata/copysign.decTest | 0 .../Lib/test/decimaltestdata/ddAbs.decTest | 0 .../Lib/test/decimaltestdata/ddAdd.decTest | 0 .../Lib/test/decimaltestdata/ddAnd.decTest | 0 .../Lib/test/decimaltestdata/ddBase.decTest | 0 .../Lib/test/decimaltestdata/ddCanonical.decTest | 0 .../Lib/test/decimaltestdata/ddClass.decTest | 0 .../Lib/test/decimaltestdata/ddCompare.decTest | 0 .../Lib/test/decimaltestdata/ddCompareSig.decTest | 0 .../Lib/test/decimaltestdata/ddCompareTotal.decTest | 0 .../test/decimaltestdata/ddCompareTotalMag.decTest | 0 .../Lib/test/decimaltestdata/ddCopy.decTest | 0 .../Lib/test/decimaltestdata/ddCopyAbs.decTest | 0 .../Lib/test/decimaltestdata/ddCopyNegate.decTest | 0 .../Lib/test/decimaltestdata/ddCopySign.decTest | 0 .../Lib/test/decimaltestdata/ddDivide.decTest | 0 .../Lib/test/decimaltestdata/ddDivideInt.decTest | 0 .../Lib/test/decimaltestdata/ddEncode.decTest | 0 .../Lib/test/decimaltestdata/ddFMA.decTest | 0 .../Lib/test/decimaltestdata/ddInvert.decTest | 0 .../Lib/test/decimaltestdata/ddLogB.decTest | 0 .../Lib/test/decimaltestdata/ddMax.decTest | 0 .../Lib/test/decimaltestdata/ddMaxMag.decTest | 0 .../Lib/test/decimaltestdata/ddMin.decTest | 0 .../Lib/test/decimaltestdata/ddMinMag.decTest | 0 .../Lib/test/decimaltestdata/ddMinus.decTest | 0 .../Lib/test/decimaltestdata/ddMultiply.decTest | 0 .../Lib/test/decimaltestdata/ddNextMinus.decTest | 0 .../Lib/test/decimaltestdata/ddNextPlus.decTest | 0 .../Lib/test/decimaltestdata/ddNextToward.decTest | 0 .../Lib/test/decimaltestdata/ddOr.decTest | 0 .../Lib/test/decimaltestdata/ddPlus.decTest | 0 .../Lib/test/decimaltestdata/ddQuantize.decTest | 0 .../Lib/test/decimaltestdata/ddReduce.decTest | 0 .../Lib/test/decimaltestdata/ddRemainder.decTest | 0 .../test/decimaltestdata/ddRemainderNear.decTest | 0 .../Lib/test/decimaltestdata/ddRotate.decTest | 0 .../Lib/test/decimaltestdata/ddSameQuantum.decTest | 0 .../Lib/test/decimaltestdata/ddScaleB.decTest | 0 .../Lib/test/decimaltestdata/ddShift.decTest | 0 .../Lib/test/decimaltestdata/ddSubtract.decTest | 0 .../Lib/test/decimaltestdata/ddToIntegral.decTest | 0 .../Lib/test/decimaltestdata/ddXor.decTest | 0 .../Lib/test/decimaltestdata/decDouble.decTest | 0 .../Lib/test/decimaltestdata/decQuad.decTest | 0 .../Lib/test/decimaltestdata/decSingle.decTest | 0 .../Lib/test/decimaltestdata/divide.decTest | 0 .../Lib/test/decimaltestdata/divideint.decTest | 0 .../Lib/test/decimaltestdata/dqAbs.decTest | 0 .../Lib/test/decimaltestdata/dqAdd.decTest | 0 .../Lib/test/decimaltestdata/dqAnd.decTest | 0 .../Lib/test/decimaltestdata/dqBase.decTest | 0 .../Lib/test/decimaltestdata/dqCanonical.decTest | 0 .../Lib/test/decimaltestdata/dqClass.decTest | 0 .../Lib/test/decimaltestdata/dqCompare.decTest | 0 .../Lib/test/decimaltestdata/dqCompareSig.decTest | 0 .../Lib/test/decimaltestdata/dqCompareTotal.decTest | 0 .../test/decimaltestdata/dqCompareTotalMag.decTest | 0 .../Lib/test/decimaltestdata/dqCopy.decTest | 0 .../Lib/test/decimaltestdata/dqCopyAbs.decTest | 0 .../Lib/test/decimaltestdata/dqCopyNegate.decTest | 0 .../Lib/test/decimaltestdata/dqCopySign.decTest | 0 .../Lib/test/decimaltestdata/dqDivide.decTest | 0 .../Lib/test/decimaltestdata/dqDivideInt.decTest | 0 .../Lib/test/decimaltestdata/dqEncode.decTest | 0 .../Lib/test/decimaltestdata/dqFMA.decTest | 0 .../Lib/test/decimaltestdata/dqInvert.decTest | 0 .../Lib/test/decimaltestdata/dqLogB.decTest | 0 .../Lib/test/decimaltestdata/dqMax.decTest | 0 .../Lib/test/decimaltestdata/dqMaxMag.decTest | 0 .../Lib/test/decimaltestdata/dqMin.decTest | 0 .../Lib/test/decimaltestdata/dqMinMag.decTest | 0 .../Lib/test/decimaltestdata/dqMinus.decTest | 0 .../Lib/test/decimaltestdata/dqMultiply.decTest | 0 .../Lib/test/decimaltestdata/dqNextMinus.decTest | 0 .../Lib/test/decimaltestdata/dqNextPlus.decTest | 0 .../Lib/test/decimaltestdata/dqNextToward.decTest | 0 .../Lib/test/decimaltestdata/dqOr.decTest | 0 .../Lib/test/decimaltestdata/dqPlus.decTest | 0 .../Lib/test/decimaltestdata/dqQuantize.decTest | 0 .../Lib/test/decimaltestdata/dqReduce.decTest | 0 .../Lib/test/decimaltestdata/dqRemainder.decTest | 0 .../test/decimaltestdata/dqRemainderNear.decTest | 0 .../Lib/test/decimaltestdata/dqRotate.decTest | 0 .../Lib/test/decimaltestdata/dqSameQuantum.decTest | 0 .../Lib/test/decimaltestdata/dqScaleB.decTest | 0 .../Lib/test/decimaltestdata/dqShift.decTest | 0 .../Lib/test/decimaltestdata/dqSubtract.decTest | 0 .../Lib/test/decimaltestdata/dqToIntegral.decTest | 0 .../Lib/test/decimaltestdata/dqXor.decTest | 0 .../Lib/test/decimaltestdata/dsBase.decTest | 0 .../Lib/test/decimaltestdata/dsEncode.decTest | 0 .../Lib/test/decimaltestdata/exp.decTest | 0 .../Lib/test/decimaltestdata/extra.decTest | 0 .../Lib/test/decimaltestdata/fma.decTest | 0 .../Lib/test/decimaltestdata/inexact.decTest | 0 .../Lib/test/decimaltestdata/invert.decTest | 0 .../Lib/test/decimaltestdata/ln.decTest | 0 .../Lib/test/decimaltestdata/log10.decTest | 0 .../Lib/test/decimaltestdata/logb.decTest | 0 .../Lib/test/decimaltestdata/max.decTest | 0 .../Lib/test/decimaltestdata/maxmag.decTest | 0 .../Lib/test/decimaltestdata/min.decTest | 0 .../Lib/test/decimaltestdata/minmag.decTest | 0 .../Lib/test/decimaltestdata/minus.decTest | 0 .../Lib/test/decimaltestdata/multiply.decTest | 0 .../Lib/test/decimaltestdata/nextminus.decTest | 0 .../Lib/test/decimaltestdata/nextplus.decTest | 0 .../Lib/test/decimaltestdata/nexttoward.decTest | 0 .../Lib/test/decimaltestdata/or.decTest | 0 .../Lib/test/decimaltestdata/plus.decTest | 0 .../Lib/test/decimaltestdata/power.decTest | 0 .../Lib/test/decimaltestdata/powersqrt.decTest | 0 .../Lib/test/decimaltestdata/quantize.decTest | 0 .../Lib/test/decimaltestdata/randomBound32.decTest | 0 .../Lib/test/decimaltestdata/randoms.decTest | 0 .../Lib/test/decimaltestdata/reduce.decTest | 0 .../Lib/test/decimaltestdata/remainder.decTest | 0 .../Lib/test/decimaltestdata/remainderNear.decTest | 0 .../Lib/test/decimaltestdata/rescale.decTest | 0 .../Lib/test/decimaltestdata/rotate.decTest | 0 .../Lib/test/decimaltestdata/rounding.decTest | 0 .../Lib/test/decimaltestdata/samequantum.decTest | 0 .../Lib/test/decimaltestdata/scaleb.decTest | 0 .../Lib/test/decimaltestdata/shift.decTest | 0 .../Lib/test/decimaltestdata/squareroot.decTest | 0 .../Lib/test/decimaltestdata/subtract.decTest | 0 .../Lib/test/decimaltestdata/testall.decTest | 0 .../Lib/test/decimaltestdata/tointegral.decTest | 0 .../Lib/test/decimaltestdata/tointegralx.decTest | 0 .../Lib/test/decimaltestdata/xor.decTest | 0 .../IronPython.StdLib}/Lib/test/dh1024.pem | 0 .../IronPython.StdLib}/Lib/test/dis_module.py | 0 .../IronPython.StdLib}/Lib/test/doctest_aliases.py | 0 .../IronPython.StdLib}/Lib/test/double_const.py | 0 .../IronPython.StdLib}/Lib/test/empty.vbs | 0 .../Lib/test/encoded_modules/__init__.py | 0 .../Lib/test/encoded_modules/module_iso_8859_1.py | 0 .../Lib/test/encoded_modules/module_koi8_r.py | 0 .../Lib/test/exception_hierarchy.txt | 0 .../IronPython.StdLib}/Lib/test/final_a.py | 0 .../IronPython.StdLib}/Lib/test/final_b.py | 0 .../IronPython.StdLib}/Lib/test/floating_points.txt | 0 .../IronPython.StdLib}/Lib/test/fork_wait.py | 0 .../Lib/test/formatfloat_testcases.txt | 0 .../IronPython.StdLib}/Lib/test/future_test1.py | 0 .../IronPython.StdLib}/Lib/test/future_test2.py | 0 .../IronPython.StdLib}/Lib/test/gdb_sample.py | 0 .../IronPython.StdLib}/Lib/test/ieee754.txt | 0 .../Lib/test/imghdrdata/python.bmp | Bin .../Lib/test/imghdrdata/python.gif | Bin .../Lib/test/imghdrdata/python.jpg | Bin .../Lib/test/imghdrdata/python.pbm | 0 .../Lib/test/imghdrdata/python.pgm | Bin .../Lib/test/imghdrdata/python.png | Bin .../Lib/test/imghdrdata/python.ppm | Bin .../Lib/test/imghdrdata/python.ras | Bin .../Lib/test/imghdrdata/python.sgi | Bin .../Lib/test/imghdrdata/python.tiff | Bin .../Lib/test/imghdrdata/python.xbm | 0 .../IronPython.StdLib}/Lib/test/inspect_fodder.py | 0 .../IronPython.StdLib}/Lib/test/inspect_fodder2.py | 0 .../IronPython.StdLib}/Lib/test/keycert.passwd.pem | 0 .../IronPython.StdLib}/Lib/test/keycert.pem | 0 .../IronPython.StdLib}/Lib/test/keycert2.pem | 0 .../IronPython.StdLib}/Lib/test/keycert3.pem | 0 .../IronPython.StdLib}/Lib/test/keycert4.pem | 0 .../IronPython.StdLib}/Lib/test/leakers/README.txt | 0 .../IronPython.StdLib}/Lib/test/leakers/__init__.py | 0 .../Lib/test/leakers/test_ctypes.py | 0 .../Lib/test/leakers/test_selftype.py | 0 .../IronPython.StdLib}/Lib/test/list_tests.py | 0 .../IronPython.StdLib}/Lib/test/lock_tests.py | 0 .../IronPython.StdLib}/Lib/test/mailcap.txt | 0 .../IronPython.StdLib}/Lib/test/make_ssl_certs.py | 0 .../IronPython.StdLib}/Lib/test/mapping_tests.py | 0 .../IronPython.StdLib}/Lib/test/math_testcases.txt | 0 .../IronPython.StdLib}/Lib/test/memory_watchdog.py | 0 .../IronPython.StdLib}/Lib/test/mime.types | 0 .../IronPython.StdLib}/Lib/test/mock_socket.py | 0 .../Lib/test/mod_generics_cache.py | 0 .../IronPython.StdLib}/Lib/test/mp_fork_bomb.py | 0 .../Lib/test/multibytecodec_support.py | 0 .../IronPython.StdLib}/Lib/test/nokia.pem | 0 .../IronPython.StdLib}/Lib/test/nullbytecert.pem | 0 .../IronPython.StdLib}/Lib/test/nullcert.pem | 0 .../IronPython.StdLib}/Lib/test/outstanding_bugs.py | 0 .../IronPython.StdLib}/Lib/test/pickletester.py | 0 .../IronPython.StdLib}/Lib/test/profilee.py | 0 .../IronPython.StdLib}/Lib/test/pstats.pck | Bin .../IronPython.StdLib}/Lib/test/pycacert.pem | 0 .../IronPython.StdLib}/Lib/test/pycakey.pem | 0 .../IronPython.StdLib}/Lib/test/pyclbr_input.py | 0 .../IronPython.StdLib}/Lib/test/pydoc_mod.py | 0 .../IronPython.StdLib}/Lib/test/pydocfodder.py | 0 .../IronPython.StdLib}/Lib/test/pystone.py | 0 .../IronPython.StdLib}/Lib/test/randv2_32.pck | 0 .../IronPython.StdLib}/Lib/test/randv2_64.pck | 0 .../IronPython.StdLib}/Lib/test/randv3.pck | 0 .../IronPython.StdLib}/Lib/test/re_tests.py | 0 .../IronPython.StdLib}/Lib/test/regrtest.py | 0 .../IronPython.StdLib}/Lib/test/relimport.py | 0 .../IronPython.StdLib}/Lib/test/reperf.py | 0 .../IronPython.StdLib}/Lib/test/revocation.crl | 0 .../IronPython.StdLib}/Lib/test/sample_doctest.py | 0 .../Lib/test/sample_doctest_no_docstrings.py | 0 .../Lib/test/sample_doctest_no_doctests.py | 0 .../IronPython.StdLib}/Lib/test/script_helper.py | 0 .../Lib/test/selfsigned_pythontestdotnet.pem | 0 .../IronPython.StdLib}/Lib/test/seq_tests.py | 0 .../IronPython.StdLib}/Lib/test/sgml_input.html | 0 .../IronPython.StdLib}/Lib/test/sha256.pem | 0 .../IronPython.StdLib}/Lib/test/sndhdrdata/README | 0 .../Lib/test/sndhdrdata/sndhdr.8svx | Bin .../Lib/test/sndhdrdata/sndhdr.aifc | Bin .../Lib/test/sndhdrdata/sndhdr.aiff | Bin .../Lib/test/sndhdrdata/sndhdr.au | Bin .../Lib/test/sndhdrdata/sndhdr.hcom | Bin .../Lib/test/sndhdrdata/sndhdr.sndt | Bin .../Lib/test/sndhdrdata/sndhdr.voc | Bin .../Lib/test/sndhdrdata/sndhdr.wav | Bin .../IronPython.StdLib}/Lib/test/sortperf.py | 0 .../IronPython.StdLib}/Lib/test/ssl_cert.pem | 0 .../IronPython.StdLib}/Lib/test/ssl_key.passwd.pem | 0 .../IronPython.StdLib}/Lib/test/ssl_key.pem | 0 .../IronPython.StdLib}/Lib/test/ssl_servers.py | 0 .../IronPython.StdLib}/Lib/test/ssltests.py | 0 .../IronPython.StdLib}/Lib/test/string_tests.py | 0 .../Lib/test/subprocessdata/fd_status.py | 0 .../Lib/test/subprocessdata/input_reader.py | 0 .../Lib/test/subprocessdata/qcat.py | 0 .../Lib/test/subprocessdata/qgrep.py | 0 .../Lib/test/subprocessdata/sigchild_ignore.py | 0 .../IronPython.StdLib}/Lib/test/support/__init__.py | 0 .../IronPython.StdLib}/Lib/test/talos-2019-0758.pem | 0 .../IronPython.StdLib}/Lib/test/test___all__.py | 0 .../IronPython.StdLib}/Lib/test/test___future__.py | 0 .../IronPython.StdLib}/Lib/test/test__locale.py | 0 .../IronPython.StdLib}/Lib/test/test__opcode.py | 0 .../Lib/test/test__osx_support.py | 0 .../IronPython.StdLib}/Lib/test/test_abc.py | 0 .../Lib/test/test_abstract_numbers.py | 0 .../IronPython.StdLib}/Lib/test/test_aifc.py | 0 .../IronPython.StdLib}/Lib/test/test_argparse.py | 0 .../IronPython.StdLib}/Lib/test/test_array.py | 0 .../IronPython.StdLib}/Lib/test/test_ast.py | 0 .../IronPython.StdLib}/Lib/test/test_asynchat.py | 0 .../Lib/test/test_asyncio/__init__.py | 0 .../Lib/test/test_asyncio/__main__.py | 0 .../Lib/test/test_asyncio/echo.py | 0 .../Lib/test/test_asyncio/echo2.py | 0 .../Lib/test/test_asyncio/echo3.py | 0 .../Lib/test/test_asyncio/keycert3.pem | 0 .../Lib/test/test_asyncio/pycacert.pem | 0 .../Lib/test/test_asyncio/ssl_cert.pem | 0 .../Lib/test/test_asyncio/ssl_key.pem | 0 .../Lib/test/test_asyncio/test_base_events.py | 0 .../Lib/test/test_asyncio/test_events.py | 0 .../Lib/test/test_asyncio/test_futures.py | 0 .../Lib/test/test_asyncio/test_locks.py | 0 .../Lib/test/test_asyncio/test_proactor_events.py | 0 .../Lib/test/test_asyncio/test_queues.py | 0 .../Lib/test/test_asyncio/test_selector_events.py | 0 .../Lib/test/test_asyncio/test_sslproto.py | 0 .../Lib/test/test_asyncio/test_streams.py | 0 .../Lib/test/test_asyncio/test_subprocess.py | 0 .../Lib/test/test_asyncio/test_tasks.py | 0 .../Lib/test/test_asyncio/test_transports.py | 0 .../Lib/test/test_asyncio/test_unix_events.py | 0 .../Lib/test/test_asyncio/test_windows_events.py | 0 .../Lib/test/test_asyncio/test_windows_utils.py | 0 .../IronPython.StdLib}/Lib/test/test_asyncore.py | 0 .../IronPython.StdLib}/Lib/test/test_atexit.py | 0 .../IronPython.StdLib}/Lib/test/test_audioop.py | 0 .../IronPython.StdLib}/Lib/test/test_augassign.py | 0 .../IronPython.StdLib}/Lib/test/test_base64.py | 0 .../Lib/test/test_bigaddrspace.py | 0 .../IronPython.StdLib}/Lib/test/test_bigmem.py | 0 .../IronPython.StdLib}/Lib/test/test_binascii.py | 0 .../IronPython.StdLib}/Lib/test/test_binhex.py | 0 .../IronPython.StdLib}/Lib/test/test_binop.py | 0 .../IronPython.StdLib}/Lib/test/test_bisect.py | 0 .../IronPython.StdLib}/Lib/test/test_bool.py | 0 .../IronPython.StdLib}/Lib/test/test_buffer.py | 0 .../IronPython.StdLib}/Lib/test/test_bufio.py | 0 .../IronPython.StdLib}/Lib/test/test_builtin.py | 0 .../IronPython.StdLib}/Lib/test/test_bytes.py | 0 .../IronPython.StdLib}/Lib/test/test_bz2.py | 0 .../IronPython.StdLib}/Lib/test/test_calendar.py | 0 .../IronPython.StdLib}/Lib/test/test_call.py | 0 .../IronPython.StdLib}/Lib/test/test_capi.py | 0 .../IronPython.StdLib}/Lib/test/test_cgi.py | 0 .../IronPython.StdLib}/Lib/test/test_cgitb.py | 0 .../Lib/test/test_charmapcodec.py | 0 .../IronPython.StdLib}/Lib/test/test_class.py | 0 .../IronPython.StdLib}/Lib/test/test_cmath.py | 0 .../IronPython.StdLib}/Lib/test/test_cmd.py | 0 .../IronPython.StdLib}/Lib/test/test_cmd_line.py | 0 .../Lib/test/test_cmd_line_script.py | 0 .../IronPython.StdLib}/Lib/test/test_code.py | 0 .../IronPython.StdLib}/Lib/test/test_code_module.py | 0 .../Lib/test/test_codeccallbacks.py | 0 .../Lib/test/test_codecencodings_cn.py | 0 .../Lib/test/test_codecencodings_hk.py | 0 .../Lib/test/test_codecencodings_iso2022.py | 0 .../Lib/test/test_codecencodings_jp.py | 0 .../Lib/test/test_codecencodings_kr.py | 0 .../Lib/test/test_codecencodings_tw.py | 0 .../Lib/test/test_codecmaps_cn.py | 0 .../Lib/test/test_codecmaps_hk.py | 0 .../Lib/test/test_codecmaps_jp.py | 0 .../Lib/test/test_codecmaps_kr.py | 0 .../Lib/test/test_codecmaps_tw.py | 0 .../IronPython.StdLib}/Lib/test/test_codecs.py | 0 .../IronPython.StdLib}/Lib/test/test_codeop.py | 0 .../IronPython.StdLib}/Lib/test/test_collections.py | 0 .../IronPython.StdLib}/Lib/test/test_colorsys.py | 0 .../IronPython.StdLib}/Lib/test/test_compare.py | 0 .../IronPython.StdLib}/Lib/test/test_compile.py | 0 .../IronPython.StdLib}/Lib/test/test_compileall.py | 0 .../IronPython.StdLib}/Lib/test/test_complex.py | 0 .../Lib/test/test_concurrent_futures.py | 0 .../Lib/test/test_configparser.py | 0 .../IronPython.StdLib}/Lib/test/test_contains.py | 0 .../IronPython.StdLib}/Lib/test/test_contextlib.py | 0 .../IronPython.StdLib}/Lib/test/test_copy.py | 0 .../IronPython.StdLib}/Lib/test/test_copyreg.py | 0 .../IronPython.StdLib}/Lib/test/test_cprofile.py | 0 .../IronPython.StdLib}/Lib/test/test_crashers.py | 0 .../IronPython.StdLib}/Lib/test/test_crypt.py | 0 .../IronPython.StdLib}/Lib/test/test_csv.py | 0 .../IronPython.StdLib}/Lib/test/test_ctypes.py | 0 .../IronPython.StdLib}/Lib/test/test_curses.py | 0 .../IronPython.StdLib}/Lib/test/test_datetime.py | 0 .../IronPython.StdLib}/Lib/test/test_dbm.py | 0 .../IronPython.StdLib}/Lib/test/test_dbm_dumb.py | 0 .../IronPython.StdLib}/Lib/test/test_dbm_gnu.py | 0 .../IronPython.StdLib}/Lib/test/test_dbm_ndbm.py | 0 .../IronPython.StdLib}/Lib/test/test_decimal.py | 0 .../IronPython.StdLib}/Lib/test/test_decorators.py | 0 .../IronPython.StdLib}/Lib/test/test_defaultdict.py | 0 .../IronPython.StdLib}/Lib/test/test_deque.py | 0 .../IronPython.StdLib}/Lib/test/test_descr.py | 0 .../IronPython.StdLib}/Lib/test/test_descrtut.py | 0 .../IronPython.StdLib}/Lib/test/test_devpoll.py | 0 .../IronPython.StdLib}/Lib/test/test_dict.py | 0 .../IronPython.StdLib}/Lib/test/test_dictcomps.py | 0 .../IronPython.StdLib}/Lib/test/test_dictviews.py | 0 .../IronPython.StdLib}/Lib/test/test_difflib.py | 0 .../Lib/test/test_difflib_expect.html | 0 .../IronPython.StdLib}/Lib/test/test_dis.py | 0 .../IronPython.StdLib}/Lib/test/test_distutils.py | 0 .../IronPython.StdLib}/Lib/test/test_doctest.py | 0 .../IronPython.StdLib}/Lib/test/test_doctest.txt | 0 .../IronPython.StdLib}/Lib/test/test_doctest2.py | 0 .../IronPython.StdLib}/Lib/test/test_doctest2.txt | 0 .../IronPython.StdLib}/Lib/test/test_doctest3.txt | 0 .../IronPython.StdLib}/Lib/test/test_doctest4.txt | 0 .../IronPython.StdLib}/Lib/test/test_docxmlrpc.py | 0 .../Lib/test/test_dummy_thread.py | 0 .../Lib/test/test_dummy_threading.py | 0 .../IronPython.StdLib}/Lib/test/test_dynamic.py | 0 .../Lib/test/test_dynamicclassattribute.py | 0 .../Lib/test/test_email/__init__.py | 0 .../Lib/test/test_email/__main__.py | 0 .../Lib/test/test_email/data/PyBanner048.gif | Bin .../Lib/test/test_email/data/audiotest.au | Bin .../Lib/test/test_email/data/msg_01.txt | 0 .../Lib/test/test_email/data/msg_02.txt | 0 .../Lib/test/test_email/data/msg_03.txt | 0 .../Lib/test/test_email/data/msg_04.txt | 0 .../Lib/test/test_email/data/msg_05.txt | 0 .../Lib/test/test_email/data/msg_06.txt | 0 .../Lib/test/test_email/data/msg_07.txt | 0 .../Lib/test/test_email/data/msg_08.txt | 0 .../Lib/test/test_email/data/msg_09.txt | 0 .../Lib/test/test_email/data/msg_10.txt | 0 .../Lib/test/test_email/data/msg_11.txt | 0 .../Lib/test/test_email/data/msg_12.txt | 0 .../Lib/test/test_email/data/msg_12a.txt | 0 .../Lib/test/test_email/data/msg_13.txt | 0 .../Lib/test/test_email/data/msg_14.txt | 0 .../Lib/test/test_email/data/msg_15.txt | 0 .../Lib/test/test_email/data/msg_16.txt | 0 .../Lib/test/test_email/data/msg_17.txt | 0 .../Lib/test/test_email/data/msg_18.txt | 0 .../Lib/test/test_email/data/msg_19.txt | 0 .../Lib/test/test_email/data/msg_20.txt | 0 .../Lib/test/test_email/data/msg_21.txt | 0 .../Lib/test/test_email/data/msg_22.txt | 0 .../Lib/test/test_email/data/msg_23.txt | 0 .../Lib/test/test_email/data/msg_24.txt | 0 .../Lib/test/test_email/data/msg_25.txt | 0 .../Lib/test/test_email/data/msg_26.txt | 0 .../Lib/test/test_email/data/msg_27.txt | 0 .../Lib/test/test_email/data/msg_28.txt | 0 .../Lib/test/test_email/data/msg_29.txt | 0 .../Lib/test/test_email/data/msg_30.txt | 0 .../Lib/test/test_email/data/msg_31.txt | 0 .../Lib/test/test_email/data/msg_32.txt | 0 .../Lib/test/test_email/data/msg_33.txt | 0 .../Lib/test/test_email/data/msg_34.txt | 0 .../Lib/test/test_email/data/msg_35.txt | 0 .../Lib/test/test_email/data/msg_36.txt | 0 .../Lib/test/test_email/data/msg_37.txt | 0 .../Lib/test/test_email/data/msg_38.txt | 0 .../Lib/test/test_email/data/msg_39.txt | 0 .../Lib/test/test_email/data/msg_40.txt | 0 .../Lib/test/test_email/data/msg_41.txt | 0 .../Lib/test/test_email/data/msg_42.txt | 0 .../Lib/test/test_email/data/msg_43.txt | 0 .../Lib/test/test_email/data/msg_44.txt | 0 .../Lib/test/test_email/data/msg_45.txt | 0 .../Lib/test/test_email/data/msg_46.txt | 0 .../Lib/test/test_email/test__encoded_words.py | 0 .../test/test_email/test__header_value_parser.py | 0 .../Lib/test/test_email/test_asian_codecs.py | 0 .../Lib/test/test_email/test_contentmanager.py | 0 .../Lib/test/test_email/test_defect_handling.py | 0 .../Lib/test/test_email/test_email.py | 0 .../Lib/test/test_email/test_generator.py | 0 .../Lib/test/test_email/test_headerregistry.py | 0 .../Lib/test/test_email/test_inversion.py | 0 .../Lib/test/test_email/test_message.py | 0 .../Lib/test/test_email/test_parser.py | 0 .../Lib/test/test_email/test_pickleable.py | 0 .../Lib/test/test_email/test_policy.py | 0 .../Lib/test/test_email/test_utils.py | 0 .../Lib/test/test_email/torture_test.py | 0 .../IronPython.StdLib}/Lib/test/test_ensurepip.py | 0 .../IronPython.StdLib}/Lib/test/test_enum.py | 0 .../IronPython.StdLib}/Lib/test/test_enumerate.py | 0 .../IronPython.StdLib}/Lib/test/test_eof.py | 0 .../IronPython.StdLib}/Lib/test/test_epoll.py | 0 .../IronPython.StdLib}/Lib/test/test_errno.py | 0 .../Lib/test/test_exception_variations.py | 0 .../IronPython.StdLib}/Lib/test/test_exceptions.py | 0 .../IronPython.StdLib}/Lib/test/test_extcall.py | 0 .../Lib/test/test_faulthandler.py | 0 .../IronPython.StdLib}/Lib/test/test_fcntl.py | 0 .../IronPython.StdLib}/Lib/test/test_file.py | 0 .../IronPython.StdLib}/Lib/test/test_file_eintr.py | 0 .../IronPython.StdLib}/Lib/test/test_filecmp.py | 0 .../IronPython.StdLib}/Lib/test/test_fileinput.py | 0 .../IronPython.StdLib}/Lib/test/test_fileio.py | 0 .../Lib/test/test_finalization.py | 0 .../IronPython.StdLib}/Lib/test/test_float.py | 0 .../IronPython.StdLib}/Lib/test/test_flufl.py | 0 .../IronPython.StdLib}/Lib/test/test_fnmatch.py | 0 .../IronPython.StdLib}/Lib/test/test_fork1.py | 0 .../IronPython.StdLib}/Lib/test/test_format.py | 0 .../IronPython.StdLib}/Lib/test/test_fractions.py | 0 .../IronPython.StdLib}/Lib/test/test_frame.py | 0 .../IronPython.StdLib}/Lib/test/test_fstring.py | 0 .../IronPython.StdLib}/Lib/test/test_ftplib.py | 0 .../IronPython.StdLib}/Lib/test/test_funcattrs.py | 0 .../IronPython.StdLib}/Lib/test/test_functools.py | 0 .../IronPython.StdLib}/Lib/test/test_future.py | 0 .../IronPython.StdLib}/Lib/test/test_future3.py | 0 .../IronPython.StdLib}/Lib/test/test_future4.py | 0 .../IronPython.StdLib}/Lib/test/test_future5.py | 0 .../IronPython.StdLib}/Lib/test/test_gc.py | 0 .../IronPython.StdLib}/Lib/test/test_gdb.py | 0 .../IronPython.StdLib}/Lib/test/test_generators.py | 0 .../IronPython.StdLib}/Lib/test/test_genericpath.py | 0 .../IronPython.StdLib}/Lib/test/test_genexps.py | 0 .../IronPython.StdLib}/Lib/test/test_getargs2.py | 0 .../IronPython.StdLib}/Lib/test/test_getopt.py | 0 .../IronPython.StdLib}/Lib/test/test_getpass.py | 0 .../IronPython.StdLib}/Lib/test/test_gettext.py | 0 .../IronPython.StdLib}/Lib/test/test_glob.py | 0 .../IronPython.StdLib}/Lib/test/test_global.py | 0 .../IronPython.StdLib}/Lib/test/test_grammar.py | 0 .../IronPython.StdLib}/Lib/test/test_grp.py | 0 .../IronPython.StdLib}/Lib/test/test_gzip.py | 0 .../IronPython.StdLib}/Lib/test/test_hash.py | 0 .../IronPython.StdLib}/Lib/test/test_hashlib.py | 0 .../IronPython.StdLib}/Lib/test/test_heapq.py | 0 .../IronPython.StdLib}/Lib/test/test_hmac.py | 0 .../IronPython.StdLib}/Lib/test/test_html.py | 0 .../IronPython.StdLib}/Lib/test/test_htmlparser.py | 0 .../Lib/test/test_http_cookiejar.py | 0 .../Lib/test/test_http_cookies.py | 0 .../IronPython.StdLib}/Lib/test/test_httplib.py | 0 .../IronPython.StdLib}/Lib/test/test_httpservers.py | 0 .../IronPython.StdLib}/Lib/test/test_idle.py | 0 .../IronPython.StdLib}/Lib/test/test_imaplib.py | 0 .../IronPython.StdLib}/Lib/test/test_imghdr.py | 0 .../IronPython.StdLib}/Lib/test/test_imp.py | 0 .../IronPython.StdLib}/Lib/test/test_import.py | 0 .../Lib/test/test_importlib/__init__.py | 0 .../Lib/test/test_importlib/__main__.py | 0 .../Lib/test/test_importlib/abc.py | 0 .../Lib/test/test_importlib/builtin/__init__.py | 0 .../Lib/test/test_importlib/builtin/__main__.py | 0 .../Lib/test/test_importlib/builtin/test_finder.py | 0 .../Lib/test/test_importlib/builtin/test_loader.py | 0 .../Lib/test/test_importlib/builtin/util.py | 0 .../Lib/test/test_importlib/extension/__init__.py | 0 .../Lib/test/test_importlib/extension/__main__.py | 0 .../extension/test_case_sensitivity.py | 0 .../test/test_importlib/extension/test_finder.py | 0 .../test/test_importlib/extension/test_loader.py | 0 .../test/test_importlib/extension/test_path_hook.py | 0 .../Lib/test/test_importlib/extension/util.py | 0 .../Lib/test/test_importlib/frozen/__init__.py | 0 .../Lib/test/test_importlib/frozen/__main__.py | 0 .../Lib/test/test_importlib/frozen/test_finder.py | 0 .../Lib/test/test_importlib/frozen/test_loader.py | 0 .../Lib/test/test_importlib/import_/__init__.py | 0 .../Lib/test/test_importlib/import_/__main__.py | 0 .../test/test_importlib/import_/test___loader__.py | 0 .../test/test_importlib/import_/test___package__.py | 0 .../Lib/test/test_importlib/import_/test_api.py | 0 .../Lib/test/test_importlib/import_/test_caching.py | 0 .../test/test_importlib/import_/test_fromlist.py | 0 .../test/test_importlib/import_/test_meta_path.py | 0 .../test/test_importlib/import_/test_packages.py | 0 .../Lib/test/test_importlib/import_/test_path.py | 0 .../test_importlib/import_/test_relative_imports.py | 0 .../Lib/test/test_importlib/import_/util.py | 0 .../namespace_pkgs/both_portions/foo/one.py | 0 .../namespace_pkgs/both_portions/foo/two.py | 0 .../namespace_pkgs/missing_directory.zip | Bin .../module_and_namespace_package/a_test.py | 0 .../module_and_namespace_package/a_test/empty | 0 .../namespace_pkgs/nested_portion1.zip | Bin .../not_a_namespace_pkg/foo/__init__.py | 0 .../namespace_pkgs/not_a_namespace_pkg/foo/one.py | 0 .../namespace_pkgs/portion1/foo/one.py | 0 .../namespace_pkgs/portion2/foo/two.py | 0 .../namespace_pkgs/project1/parent/child/one.py | 0 .../namespace_pkgs/project2/parent/child/two.py | 0 .../namespace_pkgs/project3/parent/child/three.py | 0 .../namespace_pkgs/top_level_portion1.zip | Bin .../Lib/test/test_importlib/regrtest.py | 0 .../Lib/test/test_importlib/source/__init__.py | 0 .../Lib/test/test_importlib/source/__main__.py | 0 .../test_importlib/source/test_case_sensitivity.py | 0 .../test/test_importlib/source/test_file_loader.py | 0 .../Lib/test/test_importlib/source/test_finder.py | 0 .../test/test_importlib/source/test_path_hook.py | 0 .../test_importlib/source/test_source_encoding.py | 0 .../Lib/test/test_importlib/source/util.py | 0 .../Lib/test/test_importlib/test_abc.py | 0 .../Lib/test/test_importlib/test_api.py | 0 .../Lib/test/test_importlib/test_locks.py | 0 .../Lib/test/test_importlib/test_namespace_pkgs.py | 0 .../Lib/test/test_importlib/test_spec.py | 0 .../Lib/test/test_importlib/test_util.py | 0 .../Lib/test/test_importlib/test_windows.py | 0 .../Lib/test/test_importlib/util.py | 0 .../IronPython.StdLib}/Lib/test/test_index.py | 0 .../IronPython.StdLib}/Lib/test/test_inspect.py | 0 .../IronPython.StdLib}/Lib/test/test_int.py | 0 .../IronPython.StdLib}/Lib/test/test_int_literal.py | 0 .../IronPython.StdLib}/Lib/test/test_io.py | 0 .../IronPython.StdLib}/Lib/test/test_ioctl.py | 0 .../IronPython.StdLib}/Lib/test/test_ipaddress.py | 0 .../IronPython.StdLib}/Lib/test/test_isinstance.py | 0 .../IronPython.StdLib}/Lib/test/test_iter.py | 0 .../IronPython.StdLib}/Lib/test/test_iterlen.py | 0 .../IronPython.StdLib}/Lib/test/test_itertools.py | 0 .../Lib/test/test_json/__init__.py | 0 .../Lib/test/test_json/__main__.py | 0 .../Lib/test/test_json/test_decode.py | 0 .../Lib/test/test_json/test_default.py | 0 .../Lib/test/test_json/test_dump.py | 0 .../test/test_json/test_encode_basestring_ascii.py | 0 .../Lib/test/test_json/test_enum.py | 0 .../Lib/test/test_json/test_fail.py | 0 .../Lib/test/test_json/test_float.py | 0 .../Lib/test/test_json/test_indent.py | 0 .../Lib/test/test_json/test_pass1.py | 0 .../Lib/test/test_json/test_pass2.py | 0 .../Lib/test/test_json/test_pass3.py | 0 .../Lib/test/test_json/test_recursion.py | 0 .../Lib/test/test_json/test_scanstring.py | 0 .../Lib/test/test_json/test_separators.py | 0 .../Lib/test/test_json/test_speedups.py | 0 .../Lib/test/test_json/test_tool.py | 0 .../Lib/test/test_json/test_unicode.py | 0 .../IronPython.StdLib}/Lib/test/test_keyword.py | 0 .../Lib/test/test_keywordonlyarg.py | 0 .../IronPython.StdLib}/Lib/test/test_kqueue.py | 0 .../IronPython.StdLib}/Lib/test/test_largefile.py | 0 .../IronPython.StdLib}/Lib/test/test_lib2to3.py | 0 .../IronPython.StdLib}/Lib/test/test_linecache.py | 0 .../IronPython.StdLib}/Lib/test/test_list.py | 0 .../IronPython.StdLib}/Lib/test/test_listcomps.py | 0 .../IronPython.StdLib}/Lib/test/test_locale.py | 0 .../IronPython.StdLib}/Lib/test/test_logging.py | 0 .../IronPython.StdLib}/Lib/test/test_long.py | 0 .../IronPython.StdLib}/Lib/test/test_longexp.py | 0 .../IronPython.StdLib}/Lib/test/test_lzma.py | 0 .../IronPython.StdLib}/Lib/test/test_macpath.py | 0 .../IronPython.StdLib}/Lib/test/test_macurl2path.py | 0 .../IronPython.StdLib}/Lib/test/test_mailbox.py | 0 .../IronPython.StdLib}/Lib/test/test_mailcap.py | 0 .../IronPython.StdLib}/Lib/test/test_marshal.py | 0 .../IronPython.StdLib}/Lib/test/test_math.py | 0 .../IronPython.StdLib}/Lib/test/test_memoryio.py | 0 .../IronPython.StdLib}/Lib/test/test_memoryview.py | 0 .../IronPython.StdLib}/Lib/test/test_metaclass.py | 0 .../IronPython.StdLib}/Lib/test/test_mimetypes.py | 0 .../IronPython.StdLib}/Lib/test/test_minidom.py | 0 .../IronPython.StdLib}/Lib/test/test_mmap.py | 0 .../IronPython.StdLib}/Lib/test/test_module.py | 0 .../Lib/test/test_modulefinder.py | 0 .../IronPython.StdLib}/Lib/test/test_msilib.py | 0 .../Lib/test/test_multibytecodec.py | 0 .../Lib/test/test_multiprocessing_fork.py | 0 .../Lib/test/test_multiprocessing_forkserver.py | 0 .../Lib/test/test_multiprocessing_main_handling.py | 0 .../Lib/test/test_multiprocessing_spawn.py | 0 .../IronPython.StdLib}/Lib/test/test_netrc.py | 0 .../IronPython.StdLib}/Lib/test/test_nis.py | 0 .../IronPython.StdLib}/Lib/test/test_nntplib.py | 0 .../Lib/test/test_normalization.py | 0 .../IronPython.StdLib}/Lib/test/test_ntpath.py | 0 .../Lib/test/test_numeric_tower.py | 0 .../IronPython.StdLib}/Lib/test/test_opcodes.py | 0 .../IronPython.StdLib}/Lib/test/test_openpty.py | 0 .../IronPython.StdLib}/Lib/test/test_operator.py | 0 .../IronPython.StdLib}/Lib/test/test_optparse.py | 0 .../Lib/test/test_ordered_dict.py | 0 .../IronPython.StdLib}/Lib/test/test_os.py | 0 .../IronPython.StdLib}/Lib/test/test_ossaudiodev.py | 0 .../IronPython.StdLib}/Lib/test/test_osx_env.py | 0 .../IronPython.StdLib}/Lib/test/test_parser.py | 0 .../IronPython.StdLib}/Lib/test/test_pathlib.py | 0 .../IronPython.StdLib}/Lib/test/test_pdb.py | 0 .../IronPython.StdLib}/Lib/test/test_peepholer.py | 0 .../IronPython.StdLib}/Lib/test/test_pep247.py | 0 .../IronPython.StdLib}/Lib/test/test_pep277.py | 0 .../IronPython.StdLib}/Lib/test/test_pep292.py | 0 .../IronPython.StdLib}/Lib/test/test_pep3120.py | 0 .../IronPython.StdLib}/Lib/test/test_pep3131.py | 0 .../IronPython.StdLib}/Lib/test/test_pep3151.py | 0 .../IronPython.StdLib}/Lib/test/test_pep352.py | 0 .../IronPython.StdLib}/Lib/test/test_pep380.py | 0 .../IronPython.StdLib}/Lib/test/test_pep479.py | 0 .../IronPython.StdLib}/Lib/test/test_pickle.py | 0 .../IronPython.StdLib}/Lib/test/test_pickletools.py | 0 .../IronPython.StdLib}/Lib/test/test_pipes.py | 0 .../IronPython.StdLib}/Lib/test/test_pkg.py | 0 .../IronPython.StdLib}/Lib/test/test_pkgimport.py | 0 .../IronPython.StdLib}/Lib/test/test_pkgutil.py | 0 .../IronPython.StdLib}/Lib/test/test_platform.py | 0 .../IronPython.StdLib}/Lib/test/test_plistlib.py | 0 .../IronPython.StdLib}/Lib/test/test_poll.py | 0 .../IronPython.StdLib}/Lib/test/test_popen.py | 0 .../IronPython.StdLib}/Lib/test/test_poplib.py | 0 .../IronPython.StdLib}/Lib/test/test_posix.py | 0 .../IronPython.StdLib}/Lib/test/test_posixpath.py | 0 .../IronPython.StdLib}/Lib/test/test_pow.py | 0 .../IronPython.StdLib}/Lib/test/test_pprint.py | 0 .../IronPython.StdLib}/Lib/test/test_print.py | 0 .../IronPython.StdLib}/Lib/test/test_profile.py | 0 .../IronPython.StdLib}/Lib/test/test_property.py | 0 .../IronPython.StdLib}/Lib/test/test_pstats.py | 0 .../IronPython.StdLib}/Lib/test/test_pty.py | 0 .../IronPython.StdLib}/Lib/test/test_pulldom.py | 0 .../IronPython.StdLib}/Lib/test/test_pwd.py | 0 .../IronPython.StdLib}/Lib/test/test_py_compile.py | 0 .../IronPython.StdLib}/Lib/test/test_pyclbr.py | 0 .../IronPython.StdLib}/Lib/test/test_pydoc.py | 0 .../IronPython.StdLib}/Lib/test/test_pyexpat.py | 0 .../IronPython.StdLib}/Lib/test/test_queue.py | 0 .../IronPython.StdLib}/Lib/test/test_quopri.py | 0 .../IronPython.StdLib}/Lib/test/test_raise.py | 0 .../IronPython.StdLib}/Lib/test/test_random.py | 0 .../IronPython.StdLib}/Lib/test/test_range.py | 0 .../IronPython.StdLib}/Lib/test/test_re.py | 0 .../IronPython.StdLib}/Lib/test/test_readline.py | 0 .../IronPython.StdLib}/Lib/test/test_regrtest.py | 0 .../IronPython.StdLib}/Lib/test/test_reprlib.py | 0 .../IronPython.StdLib}/Lib/test/test_resource.py | 0 .../IronPython.StdLib}/Lib/test/test_richcmp.py | 0 .../IronPython.StdLib}/Lib/test/test_rlcompleter.py | 0 .../IronPython.StdLib}/Lib/test/test_robotparser.py | 0 .../IronPython.StdLib}/Lib/test/test_runpy.py | 0 .../IronPython.StdLib}/Lib/test/test_sax.py | 0 .../IronPython.StdLib}/Lib/test/test_sched.py | 0 .../IronPython.StdLib}/Lib/test/test_scope.py | 0 .../Lib/test/test_script_helper.py | 0 .../IronPython.StdLib}/Lib/test/test_select.py | 0 .../IronPython.StdLib}/Lib/test/test_selectors.py | 0 .../IronPython.StdLib}/Lib/test/test_set.py | 0 .../IronPython.StdLib}/Lib/test/test_setcomps.py | 0 .../IronPython.StdLib}/Lib/test/test_shelve.py | 0 .../IronPython.StdLib}/Lib/test/test_shlex.py | 0 .../IronPython.StdLib}/Lib/test/test_shutil.py | 0 .../IronPython.StdLib}/Lib/test/test_signal.py | 0 .../IronPython.StdLib}/Lib/test/test_site.py | 0 .../IronPython.StdLib}/Lib/test/test_slice.py | 0 .../IronPython.StdLib}/Lib/test/test_smtpd.py | 0 .../IronPython.StdLib}/Lib/test/test_smtplib.py | 0 .../IronPython.StdLib}/Lib/test/test_smtpnet.py | 0 .../IronPython.StdLib}/Lib/test/test_sndhdr.py | 0 .../IronPython.StdLib}/Lib/test/test_socket.py | 0 .../Lib/test/test_socketserver.py | 0 .../IronPython.StdLib}/Lib/test/test_sort.py | 0 .../Lib/test/test_source_encoding.py | 0 .../IronPython.StdLib}/Lib/test/test_spwd.py | 0 .../IronPython.StdLib}/Lib/test/test_sqlite.py | 0 .../IronPython.StdLib}/Lib/test/test_ssl.py | 0 .../IronPython.StdLib}/Lib/test/test_startfile.py | 0 .../IronPython.StdLib}/Lib/test/test_stat.py | 0 .../IronPython.StdLib}/Lib/test/test_statistics.py | 0 .../IronPython.StdLib}/Lib/test/test_strftime.py | 0 .../IronPython.StdLib}/Lib/test/test_string.py | 0 .../IronPython.StdLib}/Lib/test/test_stringprep.py | 0 .../IronPython.StdLib}/Lib/test/test_strlit.py | 0 .../IronPython.StdLib}/Lib/test/test_strptime.py | 0 .../IronPython.StdLib}/Lib/test/test_strtod.py | 0 .../IronPython.StdLib}/Lib/test/test_struct.py | 0 .../Lib/test/test_structmembers.py | 0 .../IronPython.StdLib}/Lib/test/test_structseq.py | 0 .../IronPython.StdLib}/Lib/test/test_subprocess.py | 0 .../IronPython.StdLib}/Lib/test/test_sunau.py | 0 .../IronPython.StdLib}/Lib/test/test_sundry.py | 0 .../IronPython.StdLib}/Lib/test/test_super.py | 0 .../IronPython.StdLib}/Lib/test/test_support.py | 0 .../IronPython.StdLib}/Lib/test/test_symtable.py | 0 .../IronPython.StdLib}/Lib/test/test_syntax.py | 0 .../IronPython.StdLib}/Lib/test/test_sys.py | 0 .../Lib/test/test_sys_setprofile.py | 0 .../Lib/test/test_sys_settrace.py | 0 .../IronPython.StdLib}/Lib/test/test_sysconfig.py | 0 .../IronPython.StdLib}/Lib/test/test_syslog.py | 0 .../IronPython.StdLib}/Lib/test/test_tarfile.py | 0 .../IronPython.StdLib}/Lib/test/test_tcl.py | 0 .../IronPython.StdLib}/Lib/test/test_telnetlib.py | 0 .../IronPython.StdLib}/Lib/test/test_tempfile.py | 0 .../IronPython.StdLib}/Lib/test/test_textwrap.py | 0 .../IronPython.StdLib}/Lib/test/test_thread.py | 0 .../Lib/test/test_threaded_import.py | 0 .../Lib/test/test_threadedtempfile.py | 0 .../IronPython.StdLib}/Lib/test/test_threading.py | 0 .../Lib/test/test_threading_local.py | 0 .../Lib/test/test_threadsignals.py | 0 .../IronPython.StdLib}/Lib/test/test_time.py | 0 .../IronPython.StdLib}/Lib/test/test_timeit.py | 0 .../IronPython.StdLib}/Lib/test/test_timeout.py | 0 .../IronPython.StdLib}/Lib/test/test_tk.py | 0 .../IronPython.StdLib}/Lib/test/test_tokenize.py | 0 .../Lib/test/test_tools/__init__.py | 0 .../Lib/test/test_tools/__main__.py | 0 .../Lib/test/test_tools/test_gprof2html.py | 0 .../Lib/test/test_tools/test_md5sum.py | 0 .../Lib/test/test_tools/test_pdeps.py | 0 .../Lib/test/test_tools/test_pindent.py | 0 .../Lib/test/test_tools/test_reindent.py | 0 .../Lib/test/test_tools/test_sundry.py | 0 .../Lib/test/test_tools/test_unparse.py | 0 .../IronPython.StdLib}/Lib/test/test_trace.py | 0 .../IronPython.StdLib}/Lib/test/test_traceback.py | 0 .../IronPython.StdLib}/Lib/test/test_tracemalloc.py | 0 .../IronPython.StdLib}/Lib/test/test_ttk_guionly.py | 0 .../Lib/test/test_ttk_textonly.py | 0 .../IronPython.StdLib}/Lib/test/test_tuple.py | 0 .../IronPython.StdLib}/Lib/test/test_typechecks.py | 0 .../IronPython.StdLib}/Lib/test/test_types.py | 0 .../IronPython.StdLib}/Lib/test/test_typing.py | 0 .../IronPython.StdLib}/Lib/test/test_ucn.py | 0 .../IronPython.StdLib}/Lib/test/test_unary.py | 0 .../IronPython.StdLib}/Lib/test/test_unicode.py | 0 .../Lib/test/test_unicode_file.py | 0 .../IronPython.StdLib}/Lib/test/test_unicodedata.py | 0 .../IronPython.StdLib}/Lib/test/test_unittest.py | 0 .../Lib/test/test_univnewlines.py | 0 .../IronPython.StdLib}/Lib/test/test_unpack.py | 0 .../IronPython.StdLib}/Lib/test/test_unpack_ex.py | 0 .../IronPython.StdLib}/Lib/test/test_urllib.py | 0 .../IronPython.StdLib}/Lib/test/test_urllib2.py | 0 .../Lib/test/test_urllib2_localnet.py | 0 .../IronPython.StdLib}/Lib/test/test_urllib2net.py | 0 .../Lib/test/test_urllib_response.py | 0 .../IronPython.StdLib}/Lib/test/test_urllibnet.py | 0 .../IronPython.StdLib}/Lib/test/test_urlparse.py | 0 .../IronPython.StdLib}/Lib/test/test_userdict.py | 0 .../IronPython.StdLib}/Lib/test/test_userlist.py | 0 .../IronPython.StdLib}/Lib/test/test_userstring.py | 0 .../IronPython.StdLib}/Lib/test/test_utf8_mode.py | 0 .../IronPython.StdLib}/Lib/test/test_uu.py | 0 .../IronPython.StdLib}/Lib/test/test_uuid.py | 0 .../IronPython.StdLib}/Lib/test/test_venv.py | 0 .../IronPython.StdLib}/Lib/test/test_wait3.py | 0 .../IronPython.StdLib}/Lib/test/test_wait4.py | 0 .../IronPython.StdLib}/Lib/test/test_warnings.py | 0 .../IronPython.StdLib}/Lib/test/test_wave.py | 0 .../IronPython.StdLib}/Lib/test/test_weakref.py | 0 .../IronPython.StdLib}/Lib/test/test_weakset.py | 0 .../IronPython.StdLib}/Lib/test/test_webbrowser.py | 0 .../IronPython.StdLib}/Lib/test/test_winreg.py | 0 .../IronPython.StdLib}/Lib/test/test_winsound.py | 0 .../IronPython.StdLib}/Lib/test/test_with.py | 0 .../IronPython.StdLib}/Lib/test/test_wsgiref.py | 0 .../IronPython.StdLib}/Lib/test/test_xdrlib.py | 0 .../Lib/test/test_xml_dom_minicompat.py | 0 .../IronPython.StdLib}/Lib/test/test_xml_etree.py | 0 .../IronPython.StdLib}/Lib/test/test_xml_etree_c.py | 0 .../IronPython.StdLib}/Lib/test/test_xmlrpc.py | 0 .../IronPython.StdLib}/Lib/test/test_xmlrpc_net.py | 0 .../IronPython.StdLib}/Lib/test/test_zipfile.py | 0 .../IronPython.StdLib}/Lib/test/test_zipfile64.py | 0 .../IronPython.StdLib}/Lib/test/test_zipimport.py | 0 .../Lib/test/test_zipimport_support.py | 0 .../IronPython.StdLib}/Lib/test/test_zlib.py | 0 .../IronPython.StdLib}/Lib/test/testcodec.py | 0 .../IronPython.StdLib}/Lib/test/testtar.tar | Bin .../IronPython.StdLib}/Lib/test/tf_inherit_check.py | 0 .../Lib/test/threaded_import_hangers.py | 0 .../IronPython.StdLib}/Lib/test/time_hashlib.py | 0 ..._tests-latin1-coding-cookie-and-utf8-bom-sig.txt | 0 ...tests-no-coding-cookie-and-utf8-bom-sig-only.txt | 0 ...tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt | 0 ...ze_tests-utf8-coding-cookie-and-utf8-bom-sig.txt | 0 .../IronPython.StdLib}/Lib/test/tokenize_tests.txt | 0 .../Lib/test/tracedmodules/__init__.py | 0 .../Lib/test/tracedmodules/testmod.py | 0 .../IronPython.StdLib}/Lib/test/warning_tests.py | 0 .../Lib/test/win_console_handler.py | 0 .../Lib/test/xmltestdata/simple-ns.xml | 0 .../Lib/test/xmltestdata/simple.xml | 0 .../Lib/test/xmltestdata/test.xml | 0 .../Lib/test/xmltestdata/test.xml.out | 0 .../IronPython.StdLib}/Lib/test/xmltests.py | 0 .../Lib/test/zip_cp437_header.zip | Bin .../IronPython.StdLib}/Lib/test/zipdir.zip | Bin .../IronPython.StdLib}/Lib/textwrap.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/this.py | 0 .../IronPython.StdLib}/Lib/threading.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/timeit.py | 0 .../IronPython.StdLib}/Lib/tkinter/__init__.py | 0 .../IronPython.StdLib}/Lib/tkinter/__main__.py | 0 .../IronPython.StdLib}/Lib/tkinter/_fix.py | 0 .../IronPython.StdLib}/Lib/tkinter/colorchooser.py | 0 .../IronPython.StdLib}/Lib/tkinter/commondialog.py | 0 .../IronPython.StdLib}/Lib/tkinter/constants.py | 0 .../IronPython.StdLib}/Lib/tkinter/dialog.py | 0 .../IronPython.StdLib}/Lib/tkinter/dnd.py | 0 .../IronPython.StdLib}/Lib/tkinter/filedialog.py | 0 .../IronPython.StdLib}/Lib/tkinter/font.py | 0 .../IronPython.StdLib}/Lib/tkinter/messagebox.py | 0 .../IronPython.StdLib}/Lib/tkinter/scrolledtext.py | 0 .../IronPython.StdLib}/Lib/tkinter/simpledialog.py | 0 .../IronPython.StdLib}/Lib/tkinter/test/README | 0 .../IronPython.StdLib}/Lib/tkinter/test/__init__.py | 0 .../Lib/tkinter/test/runtktests.py | 0 .../IronPython.StdLib}/Lib/tkinter/test/support.py | 0 .../Lib/tkinter/test/test_tkinter/__init__.py | 0 .../Lib/tkinter/test/test_tkinter/test_font.py | 0 .../test/test_tkinter/test_geometry_managers.py | 0 .../Lib/tkinter/test/test_tkinter/test_images.py | 0 .../Lib/tkinter/test/test_tkinter/test_loadtk.py | 0 .../Lib/tkinter/test/test_tkinter/test_misc.py | 0 .../Lib/tkinter/test/test_tkinter/test_text.py | 0 .../Lib/tkinter/test/test_tkinter/test_variables.py | 0 .../Lib/tkinter/test/test_tkinter/test_widgets.py | 0 .../Lib/tkinter/test/test_ttk/__init__.py | 0 .../Lib/tkinter/test/test_ttk/test_extensions.py | 0 .../Lib/tkinter/test/test_ttk/test_functions.py | 0 .../Lib/tkinter/test/test_ttk/test_style.py | 0 .../Lib/tkinter/test/test_ttk/test_widgets.py | 0 .../Lib/tkinter/test/widget_tests.py | 0 .../IronPython.StdLib}/Lib/tkinter/tix.py | 0 .../IronPython.StdLib}/Lib/tkinter/ttk.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/token.py | 0 .../IronPython.StdLib}/Lib/tokenize.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/trace.py | 0 .../IronPython.StdLib}/Lib/traceback.py | 0 .../IronPython.StdLib}/Lib/tracemalloc.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/tty.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/turtle.py | 0 .../IronPython.StdLib}/Lib/turtledemo/__init__.py | 0 .../IronPython.StdLib}/Lib/turtledemo/__main__.py | 0 .../IronPython.StdLib}/Lib/turtledemo/bytedesign.py | 0 .../IronPython.StdLib}/Lib/turtledemo/chaos.py | 0 .../IronPython.StdLib}/Lib/turtledemo/clock.py | 0 .../IronPython.StdLib}/Lib/turtledemo/colormixer.py | 0 .../IronPython.StdLib}/Lib/turtledemo/forest.py | 0 .../Lib/turtledemo/fractalcurves.py | 0 .../Lib/turtledemo/lindenmayer.py | 0 .../Lib/turtledemo/minimal_hanoi.py | 0 .../IronPython.StdLib}/Lib/turtledemo/nim.py | 0 .../IronPython.StdLib}/Lib/turtledemo/paint.py | 0 .../IronPython.StdLib}/Lib/turtledemo/peace.py | 0 .../IronPython.StdLib}/Lib/turtledemo/penrose.py | 0 .../Lib/turtledemo/planet_and_moon.py | 0 .../Lib/turtledemo/round_dance.py | 0 .../IronPython.StdLib}/Lib/turtledemo/tree.py | 0 .../IronPython.StdLib}/Lib/turtledemo/turtle.cfg | 0 .../Lib/turtledemo/two_canvases.py | 0 .../IronPython.StdLib}/Lib/turtledemo/wikipedia.py | 0 .../IronPython.StdLib}/Lib/turtledemo/yinyang.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/types.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/typing.py | 0 .../IronPython.StdLib}/Lib/unittest/__init__.py | 0 .../IronPython.StdLib}/Lib/unittest/__main__.py | 0 .../IronPython.StdLib}/Lib/unittest/case.py | 0 .../IronPython.StdLib}/Lib/unittest/loader.py | 0 .../IronPython.StdLib}/Lib/unittest/main.py | 0 .../IronPython.StdLib}/Lib/unittest/mock.py | 0 .../IronPython.StdLib}/Lib/unittest/result.py | 0 .../IronPython.StdLib}/Lib/unittest/runner.py | 0 .../IronPython.StdLib}/Lib/unittest/signals.py | 0 .../IronPython.StdLib}/Lib/unittest/suite.py | 0 .../Lib/unittest/test/__init__.py | 0 .../Lib/unittest/test/__main__.py | 0 .../Lib/unittest/test/_test_warnings.py | 0 .../IronPython.StdLib}/Lib/unittest/test/dummy.py | 0 .../IronPython.StdLib}/Lib/unittest/test/support.py | 0 .../Lib/unittest/test/test_assertions.py | 0 .../Lib/unittest/test/test_break.py | 0 .../Lib/unittest/test/test_case.py | 0 .../Lib/unittest/test/test_discovery.py | 0 .../Lib/unittest/test/test_functiontestcase.py | 0 .../Lib/unittest/test/test_loader.py | 0 .../Lib/unittest/test/test_program.py | 0 .../Lib/unittest/test/test_result.py | 0 .../Lib/unittest/test/test_runner.py | 0 .../Lib/unittest/test/test_setups.py | 0 .../Lib/unittest/test/test_skipping.py | 0 .../Lib/unittest/test/test_suite.py | 0 .../Lib/unittest/test/testmock/__init__.py | 0 .../Lib/unittest/test/testmock/__main__.py | 0 .../Lib/unittest/test/testmock/support.py | 0 .../Lib/unittest/test/testmock/testcallable.py | 0 .../Lib/unittest/test/testmock/testhelpers.py | 0 .../Lib/unittest/test/testmock/testmagicmethods.py | 0 .../Lib/unittest/test/testmock/testmock.py | 0 .../Lib/unittest/test/testmock/testpatch.py | 0 .../Lib/unittest/test/testmock/testsentinel.py | 0 .../Lib/unittest/test/testmock/testwith.py | 0 .../IronPython.StdLib}/Lib/unittest/util.py | 0 .../IronPython.StdLib}/Lib/urllib/__init__.py | 0 .../IronPython.StdLib}/Lib/urllib/error.py | 0 .../IronPython.StdLib}/Lib/urllib/parse.py | 0 .../IronPython.StdLib}/Lib/urllib/request.py | 0 .../IronPython.StdLib}/Lib/urllib/response.py | 0 .../IronPython.StdLib}/Lib/urllib/robotparser.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/uu.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/uuid.py | 0 .../IronPython.StdLib}/Lib/venv/__init__.py | 0 .../IronPython.StdLib}/Lib/venv/__main__.py | 0 .../Lib/venv/scripts/nt/Activate.ps1 | 0 .../Lib/venv/scripts/nt/activate.bat | 0 .../Lib/venv/scripts/nt/deactivate.bat | 0 .../Lib/venv/scripts/posix/activate | 0 .../Lib/venv/scripts/posix/activate.csh | 0 .../Lib/venv/scripts/posix/activate.fish | 0 .../IronPython.StdLib}/Lib/warnings.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/wave.py | 0 .../IronPython.StdLib}/Lib/weakref.py | 0 .../IronPython.StdLib}/Lib/webbrowser.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/wpf.py | 0 .../IronPython.StdLib}/Lib/wsgiref/__init__.py | 0 .../IronPython.StdLib}/Lib/wsgiref/handlers.py | 0 .../IronPython.StdLib}/Lib/wsgiref/headers.py | 0 .../IronPython.StdLib}/Lib/wsgiref/simple_server.py | 0 .../IronPython.StdLib}/Lib/wsgiref/util.py | 0 .../IronPython.StdLib}/Lib/wsgiref/validate.py | 0 .../StdLib => core/IronPython.StdLib}/Lib/xdrlib.py | 0 .../IronPython.StdLib}/Lib/xml/__init__.py | 0 .../IronPython.StdLib}/Lib/xml/dom/NodeFilter.py | 0 .../IronPython.StdLib}/Lib/xml/dom/__init__.py | 0 .../IronPython.StdLib}/Lib/xml/dom/domreg.py | 0 .../IronPython.StdLib}/Lib/xml/dom/expatbuilder.py | 0 .../IronPython.StdLib}/Lib/xml/dom/minicompat.py | 0 .../IronPython.StdLib}/Lib/xml/dom/minidom.py | 0 .../IronPython.StdLib}/Lib/xml/dom/pulldom.py | 0 .../IronPython.StdLib}/Lib/xml/dom/xmlbuilder.py | 0 .../Lib/xml/etree/ElementInclude.py | 0 .../IronPython.StdLib}/Lib/xml/etree/ElementPath.py | 0 .../IronPython.StdLib}/Lib/xml/etree/ElementTree.py | 0 .../IronPython.StdLib}/Lib/xml/etree/__init__.py | 0 .../Lib/xml/etree/cElementTree.py | 0 .../IronPython.StdLib}/Lib/xml/parsers/__init__.py | 0 .../IronPython.StdLib}/Lib/xml/parsers/expat.py | 0 .../IronPython.StdLib}/Lib/xml/sax/__init__.py | 0 .../IronPython.StdLib}/Lib/xml/sax/_exceptions.py | 0 .../IronPython.StdLib}/Lib/xml/sax/expatreader.py | 0 .../IronPython.StdLib}/Lib/xml/sax/handler.py | 0 .../IronPython.StdLib}/Lib/xml/sax/saxutils.py | 0 .../IronPython.StdLib}/Lib/xml/sax/xmlreader.py | 0 .../IronPython.StdLib}/Lib/xmlrpc/__init__.py | 0 .../IronPython.StdLib}/Lib/xmlrpc/client.py | 0 .../IronPython.StdLib}/Lib/xmlrpc/server.py | 0 .../IronPython.StdLib}/Lib/zipfile.py | 0 .../IronPython.StdLib}/StdLib.License.txt | 0 .../IronPython.StdLib}/stdlib-upgrade.txt | 0 .../IronPython.StdLib}/update-stdlib.cmd | 0 .../IronPython.StdLib}/update-stdlib.sh | 0 1892 files changed, 1 insertion(+), 1 deletion(-) rename src/{extensions/StdLib => core/IronPython.StdLib}/.gitattributes (100%) rename src/{extensions/StdLib/StdLib.pyproj => core/IronPython.StdLib/IronPython.StdLib.pyproj} (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/__future__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/__phello__.foo.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/_bootlocale.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/_collections_abc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/_compat_pickle.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/_dummy_thread.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/_markupbase.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/_osx_support.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/_pyio.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/_sitebuiltins.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/_strptime.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/_threading_local.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/_weakrefset.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/abc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/aifc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/antigravity.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/argparse.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ast.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asynchat.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/base_events.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/base_subprocess.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/compat.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/constants.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/coroutines.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/events.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/futures.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/locks.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/log.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/proactor_events.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/protocols.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/queues.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/selector_events.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/sslproto.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/streams.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/subprocess.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/tasks.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/test_utils.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/transports.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/unix_events.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/windows_events.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncio/windows_utils.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/asyncore.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/base64.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/bdb.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/binhex.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/bisect.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/bz2.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/cProfile.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/calendar.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/cgi.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/cgitb.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/chunk.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/clrtype.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/cmd.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/code.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/codecs.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/codeop.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/collections/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/collections/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/collections/abc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/colorsys.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/compileall.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/concurrent/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/concurrent/futures/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/concurrent/futures/_base.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/concurrent/futures/process.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/concurrent/futures/thread.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/configparser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/contextlib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/copy.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/copyreg.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/crypt.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/csv.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/_endian.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/macholib/README.ctypes (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/macholib/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/macholib/dyld.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/macholib/dylib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/macholib/fetch_macholib (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/macholib/fetch_macholib.bat (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/macholib/framework.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_anon.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_array_in_pointer.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_arrays.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_as_parameter.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_bitfields.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_buffers.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_bytes.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_byteswap.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_callbacks.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_cast.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_cfuncs.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_checkretval.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_delattr.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_errno.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_find.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_frombuffer.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_funcptr.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_functions.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_incomplete.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_init.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_internals.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_keeprefs.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_libc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_loading.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_macholib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_memfunctions.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_numbers.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_objects.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_parameters.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_pep3118.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_pickling.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_pointers.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_prototypes.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_python_api.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_random_things.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_refcounts.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_repr.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_returnfuncptrs.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_simplesubclasses.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_sizes.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_slicing.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_stringptr.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_strings.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_struct_fields.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_structures.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_unaligned_structures.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_unicode.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_values.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_varsize_struct.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_win32.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/test/test_wintypes.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ctypes/wintypes.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/curses/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/curses/ascii.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/curses/has_key.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/curses/panel.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/curses/textpad.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/datetime.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/dbm/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/dbm/dumb.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/dbm/gnu.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/dbm/ndbm.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/decimal.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/difflib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/dis.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/README (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/archive_util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/bcppcompiler.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/ccompiler.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/cmd.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/bdist.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/bdist_dumb.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/bdist_msi.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/bdist_rpm.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/bdist_wininst.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/build.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/build_clib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/build_ext.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/build_py.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/build_scripts.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/check.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/clean.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/command_template (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/config.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/install.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/install_data.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/install_egg_info.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/install_headers.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/install_lib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/install_scripts.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/register.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/sdist.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/upload.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/wininst-10.0-amd64.exe (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/wininst-10.0.exe (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/wininst-6.0.exe (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/wininst-7.1.exe (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/wininst-8.0.exe (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/wininst-9.0-amd64.exe (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/command/wininst-9.0.exe (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/config.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/core.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/cygwinccompiler.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/debug.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/dep_util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/dir_util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/dist.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/errors.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/extension.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/fancy_getopt.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/file_util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/filelist.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/log.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/msvc9compiler.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/msvccompiler.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/spawn.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/sysconfig.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/Setup.sample (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/support.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_archive_util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_bdist.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_bdist_dumb.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_bdist_msi.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_bdist_rpm.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_bdist_wininst.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_build.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_build_clib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_build_ext.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_build_py.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_build_scripts.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_check.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_clean.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_cmd.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_config.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_config_cmd.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_core.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_cygwinccompiler.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_dep_util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_dir_util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_dist.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_extension.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_file_util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_filelist.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_install.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_install_data.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_install_headers.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_install_lib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_install_scripts.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_log.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_msvc9compiler.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_register.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_sdist.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_spawn.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_sysconfig.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_text_file.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_unixccompiler.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_upload.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_version.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/tests/test_versionpredicate.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/text_file.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/unixccompiler.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/version.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/distutils/versionpredicate.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/doctest.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/dummy_threading.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/_encoded_words.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/_header_value_parser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/_parseaddr.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/_policybase.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/architecture.rst (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/base64mime.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/charset.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/contentmanager.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/encoders.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/errors.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/feedparser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/generator.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/header.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/headerregistry.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/iterators.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/message.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/mime/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/mime/application.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/mime/audio.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/mime/base.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/mime/image.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/mime/message.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/mime/multipart.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/mime/nonmultipart.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/mime/text.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/parser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/policy.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/quoprimime.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/email/utils.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/aliases.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/ascii.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/base64_codec.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/big5.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/big5hkscs.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/bz2_codec.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/charmap.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp037.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp1006.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp1026.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp1125.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp1140.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp1250.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp1251.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp1252.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp1253.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp1254.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp1255.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp1256.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp1257.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp1258.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp273.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp424.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp437.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp500.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp65001.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp720.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp737.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp775.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp850.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp852.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp855.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp856.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp857.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp858.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp860.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp861.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp862.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp863.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp864.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp865.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp866.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp869.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp874.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp875.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp932.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp949.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/cp950.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/euc_jis_2004.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/euc_jisx0213.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/euc_jp.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/euc_kr.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/gb18030.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/gb2312.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/gbk.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/hex_codec.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/hp_roman8.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/hz.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/idna.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso2022_jp.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso2022_jp_1.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso2022_jp_2.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso2022_jp_2004.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso2022_jp_3.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso2022_jp_ext.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso2022_kr.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso8859_1.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso8859_10.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso8859_11.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso8859_13.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso8859_14.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso8859_15.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso8859_16.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso8859_2.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso8859_3.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso8859_4.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso8859_5.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso8859_6.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso8859_7.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso8859_8.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/iso8859_9.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/johab.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/koi8_r.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/koi8_u.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/latin_1.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/mac_arabic.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/mac_centeuro.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/mac_croatian.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/mac_cyrillic.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/mac_farsi.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/mac_greek.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/mac_iceland.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/mac_latin2.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/mac_roman.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/mac_romanian.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/mac_turkish.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/mbcs.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/palmos.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/ptcp154.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/punycode.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/quopri_codec.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/raw_unicode_escape.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/rot_13.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/shift_jis.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/shift_jis_2004.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/shift_jisx0213.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/tis_620.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/undefined.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/unicode_escape.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/unicode_internal.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/utf_16.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/utf_16_be.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/utf_16_le.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/utf_32.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/utf_32_be.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/utf_32_le.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/utf_7.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/utf_8.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/utf_8_sig.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/uu_codec.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/encodings/zlib_codec.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ensurepip/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ensurepip/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ensurepip/_uninstall.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/enum.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/filecmp.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/fileinput.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/fnmatch.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/formatter.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/fractions.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ftplib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/functools.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/genericpath.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/getopt.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/getpass.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/gettext.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/glob.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/gzip.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/hashlib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/heapq.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/hmac.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/html/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/html/entities.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/html/parser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/http/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/http/client.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/http/cookiejar.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/http/cookies.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/http/server.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/AutoComplete.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/AutoCompleteWindow.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/AutoExpand.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/Bindings.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/CREDITS.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/CallTipWindow.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/CallTips.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/ChangeLog (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/ClassBrowser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/CodeContext.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/ColorDelegator.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/Debugger.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/Delegator.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/EditorWindow.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/FileList.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/FormatParagraph.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/GrepDialog.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/HISTORY.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/HyperParser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/IOBinding.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/Icons/folder.gif (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/Icons/idle.icns (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/Icons/idle.ico (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/Icons/idle_16.gif (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/Icons/idle_16.png (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/Icons/idle_32.gif (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/Icons/idle_32.png (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/Icons/idle_48.gif (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/Icons/idle_48.png (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/Icons/minusnode.gif (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/Icons/openfolder.gif (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/Icons/plusnode.gif (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/Icons/python.gif (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/Icons/tk.gif (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/IdleHistory.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/MultiCall.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/MultiStatusBar.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/NEWS.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/ObjectBrowser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/OutputWindow.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/ParenMatch.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/PathBrowser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/Percolator.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/PyParse.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/PyShell.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/README.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/RemoteDebugger.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/RemoteObjectBrowser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/ReplaceDialog.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/RstripExtension.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/ScriptBinding.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/ScrolledList.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/SearchDialog.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/SearchDialogBase.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/SearchEngine.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/StackViewer.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/TODO.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/ToolTip.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/TreeWidget.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/UndoDelegator.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/WidgetRedirector.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/WindowList.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/ZoomHeight.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/aboutDialog.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/config-extensions.def (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/config-highlight.def (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/config-keys.def (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/config-main.def (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/configDialog.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/configHandler.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/configHelpSourceEdit.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/configSectionNameDialog.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/dynOptionMenuWidget.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/extend.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/help.html (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/help.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/help.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle.bat (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle.pyw (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/README.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/htest.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/mock_idle.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/mock_tk.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/test_autocomplete.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/test_autoexpand.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/test_calltips.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/test_config_name.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/test_configdialog.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/test_delegator.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/test_editor.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/test_formatparagraph.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/test_grep.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/test_hyperparser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/test_idlehistory.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/test_io.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/test_parenmatch.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/test_pathbrowser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/test_rstrip.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/test_searchdialogbase.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/test_searchengine.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/test_text.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/test_textview.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/test_warning.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idle_test/test_widgetredir.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/idlever.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/keybindingDialog.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/macosxSupport.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/rpc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/run.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/tabbedpages.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/idlelib/textView.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/imaplib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/imghdr.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/imp.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/importlib/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/importlib/_bootstrap.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/importlib/abc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/importlib/machinery.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/importlib/util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/inspect.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/io.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ipaddress.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/json/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/json/decoder.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/json/encoder.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/json/scanner.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/json/tool.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/keyword.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/Grammar.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/PatternGrammar.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/btm_matcher.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/btm_utils.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixer_base.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixer_util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_apply.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_asserts.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_basestring.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_buffer.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_callable.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_dict.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_except.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_exec.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_execfile.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_exitfunc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_filter.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_funcattrs.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_future.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_getcwdu.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_has_key.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_idioms.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_import.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_imports.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_imports2.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_input.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_intern.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_isinstance.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_itertools.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_itertools_imports.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_long.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_map.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_metaclass.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_methodattrs.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_ne.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_next.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_nonzero.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_numliterals.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_operator.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_paren.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_print.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_raise.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_raw_input.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_reduce.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_reload.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_renames.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_repr.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_set_literal.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_standarderror.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_sys_exc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_throw.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_tuple_params.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_types.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_unicode.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_urllib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_ws_comma.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_xrange.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_xreadlines.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/fixes/fix_zip.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/main.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/patcomp.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/pgen2/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/pgen2/conv.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/pgen2/driver.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/pgen2/grammar.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/pgen2/literals.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/pgen2/parse.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/pgen2/pgen.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/pgen2/token.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/pgen2/tokenize.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/pygram.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/pytree.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/refactor.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/data/README (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/data/bom.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/data/crlf.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/data/different_encoding.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/data/false_encoding.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/data/fixers/bad_order.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/data/fixers/parrot_example.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/data/infinite_recursion.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/data/py2_test_grammar.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/data/py3_test_grammar.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/pytree_idempotency.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/support.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/test_all_fixers.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/test_fixers.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/test_main.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/test_parser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/test_pytree.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/test_refactor.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lib2to3/tests/test_util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/linecache.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/locale.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/logging/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/logging/config.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/logging/handlers.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/lzma.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/macpath.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/macurl2path.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/mailbox.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/mailcap.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/mimetypes.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/modulefinder.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/msilib/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/msilib/schema.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/msilib/sequence.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/msilib/text.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/connection.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/context.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/dummy/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/dummy/connection.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/forkserver.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/heap.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/managers.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/pool.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/popen_fork.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/popen_forkserver.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/popen_spawn_posix.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/popen_spawn_win32.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/process.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/queues.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/reduction.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/resource_sharer.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/semaphore_tracker.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/sharedctypes.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/spawn.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/synchronize.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/multiprocessing/util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/netrc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/nntplib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ntpath.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/nturl2path.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/numbers.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/opcode.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/operator.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/optparse.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/os.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/pathlib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/pdb.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/pickle.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/pickletools.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/pipes.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/pkgutil.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/platform.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/plistlib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/poplib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/posixpath.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/pprint.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/profile.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/pstats.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/pty.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/py_compile.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/pyclbr.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/pydoc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/pydoc_data/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/pydoc_data/_pydoc.css (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/pydoc_data/topics.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/queue.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/quopri.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/random.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/re.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/reprlib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/rlcompleter.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/runpy.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/sched.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/selectors.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/shelve.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/shlex.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/shutil.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/site-packages/README (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/site.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/smtpd.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/smtplib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/sndhdr.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/socket.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/socketserver.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/sqlite3/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/sqlite3/dbapi2.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/sqlite3/dump.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/sqlite3/test/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/sqlite3/test/dbapi.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/sqlite3/test/dump.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/sqlite3/test/factory.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/sqlite3/test/hooks.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/sqlite3/test/regression.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/sqlite3/test/transactions.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/sqlite3/test/types.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/sqlite3/test/userfunctions.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/sre_compile.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/sre_constants.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/sre_parse.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/ssl.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/stat.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/statistics.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/string.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/stringprep.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/struct.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/subprocess.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/sunau.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/symbol.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/symtable.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/sysconfig.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tabnanny.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tarfile.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/telnetlib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tempfile.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/185test.db (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/Sine-1000Hz-300ms.aif (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/_test_multiprocessing.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/audiodata/pluck-alaw.aifc (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/audiodata/pluck-pcm16.aiff (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/audiodata/pluck-pcm16.au (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/audiodata/pluck-pcm16.wav (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/audiodata/pluck-pcm24.aiff (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/audiodata/pluck-pcm24.au (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/audiodata/pluck-pcm24.wav (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/audiodata/pluck-pcm32.aiff (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/audiodata/pluck-pcm32.au (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/audiodata/pluck-pcm32.wav (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/audiodata/pluck-pcm8.aiff (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/audiodata/pluck-pcm8.au (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/audiodata/pluck-pcm8.wav (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/audiodata/pluck-ulaw.aifc (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/audiodata/pluck-ulaw.au (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/audiotest.au (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/audiotests.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/autotest.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/bad_coding.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/bad_coding2.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/badcert.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/badkey.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/badsyntax_3131.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/badsyntax_future10.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/badsyntax_future3.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/badsyntax_future4.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/badsyntax_future5.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/badsyntax_future6.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/badsyntax_future7.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/badsyntax_future8.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/badsyntax_future9.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/badsyntax_pep3120.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/buffer_tests.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/bytecode_helper.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/capath/0e4015b9.0 (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/capath/4e1295a3.0 (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/capath/5ed36f99.0 (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/capath/6e88d7b8.0 (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/capath/99d0fa06.0 (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/capath/ce7b8643.0 (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cfgparser.1 (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cfgparser.2 (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cfgparser.3 (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/check_soundcard.vbs (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/big5-utf8.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/big5.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/big5hkscs-utf8.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/big5hkscs.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/cp949-utf8.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/cp949.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/euc_jisx0213-utf8.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/euc_jisx0213.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/euc_jp-utf8.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/euc_jp.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/euc_kr-utf8.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/euc_kr.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/gb18030-utf8.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/gb18030.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/gb2312-utf8.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/gb2312.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/gbk-utf8.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/gbk.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/hz-utf8.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/hz.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/iso2022_jp-utf8.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/iso2022_jp.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/iso2022_kr-utf8.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/iso2022_kr.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/johab-utf8.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/johab.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/shift_jis-utf8.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/shift_jis.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/shift_jisx0213-utf8.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cjkencodings/shift_jisx0213.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/cmath_testcases.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/coding20731.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/crashers/README (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/crashers/bogus_code_obj.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/crashers/gc_inspection.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/crashers/infinite_loop_re.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/crashers/mutation_inside_cyclegc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/crashers/recursive_call.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/crashers/trace_at_recursion_limit.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/crashers/underlying_dict.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/curses_tests.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/data/README (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/datetimetester.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/abs.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/add.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/and.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/base.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/clamp.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/class.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/compare.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/comparetotal.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/comparetotmag.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/copy.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/copyabs.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/copynegate.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/copysign.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddAbs.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddAdd.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddAnd.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddBase.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddCanonical.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddClass.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddCompare.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddCompareSig.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddCompareTotal.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddCompareTotalMag.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddCopy.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddCopyAbs.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddCopyNegate.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddCopySign.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddDivide.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddDivideInt.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddEncode.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddFMA.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddInvert.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddLogB.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddMax.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddMaxMag.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddMin.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddMinMag.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddMinus.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddMultiply.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddNextMinus.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddNextPlus.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddNextToward.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddOr.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddPlus.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddQuantize.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddReduce.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddRemainder.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddRemainderNear.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddRotate.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddSameQuantum.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddScaleB.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddShift.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddSubtract.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddToIntegral.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ddXor.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/decDouble.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/decQuad.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/decSingle.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/divide.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/divideint.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqAbs.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqAdd.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqAnd.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqBase.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqCanonical.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqClass.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqCompare.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqCompareSig.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqCompareTotal.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqCompareTotalMag.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqCopy.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqCopyAbs.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqCopyNegate.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqCopySign.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqDivide.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqDivideInt.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqEncode.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqFMA.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqInvert.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqLogB.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqMax.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqMaxMag.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqMin.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqMinMag.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqMinus.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqMultiply.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqNextMinus.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqNextPlus.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqNextToward.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqOr.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqPlus.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqQuantize.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqReduce.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqRemainder.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqRemainderNear.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqRotate.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqSameQuantum.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqScaleB.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqShift.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqSubtract.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqToIntegral.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dqXor.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dsBase.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/dsEncode.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/exp.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/extra.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/fma.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/inexact.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/invert.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/ln.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/log10.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/logb.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/max.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/maxmag.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/min.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/minmag.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/minus.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/multiply.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/nextminus.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/nextplus.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/nexttoward.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/or.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/plus.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/power.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/powersqrt.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/quantize.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/randomBound32.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/randoms.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/reduce.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/remainder.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/remainderNear.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/rescale.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/rotate.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/rounding.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/samequantum.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/scaleb.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/shift.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/squareroot.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/subtract.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/testall.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/tointegral.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/tointegralx.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/decimaltestdata/xor.decTest (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/dh1024.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/dis_module.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/doctest_aliases.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/double_const.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/empty.vbs (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/encoded_modules/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/encoded_modules/module_iso_8859_1.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/encoded_modules/module_koi8_r.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/exception_hierarchy.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/final_a.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/final_b.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/floating_points.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/fork_wait.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/formatfloat_testcases.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/future_test1.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/future_test2.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/gdb_sample.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/ieee754.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/imghdrdata/python.bmp (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/imghdrdata/python.gif (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/imghdrdata/python.jpg (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/imghdrdata/python.pbm (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/imghdrdata/python.pgm (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/imghdrdata/python.png (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/imghdrdata/python.ppm (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/imghdrdata/python.ras (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/imghdrdata/python.sgi (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/imghdrdata/python.tiff (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/imghdrdata/python.xbm (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/inspect_fodder.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/inspect_fodder2.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/keycert.passwd.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/keycert.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/keycert2.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/keycert3.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/keycert4.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/leakers/README.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/leakers/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/leakers/test_ctypes.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/leakers/test_selftype.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/list_tests.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/lock_tests.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/mailcap.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/make_ssl_certs.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/mapping_tests.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/math_testcases.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/memory_watchdog.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/mime.types (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/mock_socket.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/mod_generics_cache.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/mp_fork_bomb.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/multibytecodec_support.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/nokia.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/nullbytecert.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/nullcert.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/outstanding_bugs.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/pickletester.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/profilee.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/pstats.pck (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/pycacert.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/pycakey.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/pyclbr_input.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/pydoc_mod.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/pydocfodder.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/pystone.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/randv2_32.pck (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/randv2_64.pck (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/randv3.pck (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/re_tests.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/regrtest.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/relimport.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/reperf.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/revocation.crl (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/sample_doctest.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/sample_doctest_no_docstrings.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/sample_doctest_no_doctests.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/script_helper.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/selfsigned_pythontestdotnet.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/seq_tests.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/sgml_input.html (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/sha256.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/sndhdrdata/README (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/sndhdrdata/sndhdr.8svx (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/sndhdrdata/sndhdr.aifc (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/sndhdrdata/sndhdr.aiff (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/sndhdrdata/sndhdr.au (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/sndhdrdata/sndhdr.hcom (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/sndhdrdata/sndhdr.sndt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/sndhdrdata/sndhdr.voc (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/sndhdrdata/sndhdr.wav (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/sortperf.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/ssl_cert.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/ssl_key.passwd.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/ssl_key.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/ssl_servers.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/ssltests.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/string_tests.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/subprocessdata/fd_status.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/subprocessdata/input_reader.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/subprocessdata/qcat.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/subprocessdata/qgrep.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/subprocessdata/sigchild_ignore.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/support/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/talos-2019-0758.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test___all__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test___future__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test__locale.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test__opcode.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test__osx_support.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_abc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_abstract_numbers.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_aifc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_argparse.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_array.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_ast.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asynchat.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/echo.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/echo2.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/echo3.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/keycert3.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/pycacert.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/ssl_cert.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/ssl_key.pem (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/test_base_events.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/test_events.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/test_futures.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/test_locks.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/test_proactor_events.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/test_queues.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/test_selector_events.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/test_sslproto.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/test_streams.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/test_subprocess.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/test_tasks.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/test_transports.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/test_unix_events.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/test_windows_events.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncio/test_windows_utils.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_asyncore.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_atexit.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_audioop.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_augassign.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_base64.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_bigaddrspace.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_bigmem.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_binascii.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_binhex.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_binop.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_bisect.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_bool.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_buffer.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_bufio.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_builtin.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_bytes.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_bz2.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_calendar.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_call.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_capi.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_cgi.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_cgitb.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_charmapcodec.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_class.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_cmath.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_cmd.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_cmd_line.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_cmd_line_script.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_code.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_code_module.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_codeccallbacks.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_codecencodings_cn.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_codecencodings_hk.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_codecencodings_iso2022.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_codecencodings_jp.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_codecencodings_kr.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_codecencodings_tw.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_codecmaps_cn.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_codecmaps_hk.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_codecmaps_jp.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_codecmaps_kr.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_codecmaps_tw.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_codecs.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_codeop.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_collections.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_colorsys.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_compare.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_compile.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_compileall.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_complex.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_concurrent_futures.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_configparser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_contains.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_contextlib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_copy.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_copyreg.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_cprofile.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_crashers.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_crypt.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_csv.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_ctypes.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_curses.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_datetime.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_dbm.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_dbm_dumb.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_dbm_gnu.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_dbm_ndbm.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_decimal.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_decorators.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_defaultdict.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_deque.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_descr.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_descrtut.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_devpoll.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_dict.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_dictcomps.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_dictviews.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_difflib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_difflib_expect.html (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_dis.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_distutils.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_doctest.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_doctest.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_doctest2.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_doctest2.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_doctest3.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_doctest4.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_docxmlrpc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_dummy_thread.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_dummy_threading.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_dynamic.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_dynamicclassattribute.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/PyBanner048.gif (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/audiotest.au (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_01.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_02.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_03.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_04.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_05.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_06.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_07.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_08.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_09.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_10.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_11.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_12.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_12a.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_13.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_14.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_15.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_16.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_17.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_18.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_19.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_20.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_21.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_22.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_23.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_24.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_25.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_26.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_27.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_28.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_29.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_30.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_31.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_32.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_33.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_34.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_35.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_36.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_37.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_38.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_39.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_40.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_41.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_42.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_43.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_44.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_45.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/data/msg_46.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/test__encoded_words.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/test__header_value_parser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/test_asian_codecs.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/test_contentmanager.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/test_defect_handling.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/test_email.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/test_generator.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/test_headerregistry.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/test_inversion.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/test_message.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/test_parser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/test_pickleable.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/test_policy.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/test_utils.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_email/torture_test.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_ensurepip.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_enum.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_enumerate.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_eof.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_epoll.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_errno.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_exception_variations.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_exceptions.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_extcall.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_faulthandler.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_fcntl.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_file.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_file_eintr.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_filecmp.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_fileinput.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_fileio.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_finalization.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_float.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_flufl.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_fnmatch.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_fork1.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_format.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_fractions.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_frame.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_fstring.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_ftplib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_funcattrs.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_functools.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_future.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_future3.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_future4.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_future5.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_gc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_gdb.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_generators.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_genericpath.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_genexps.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_getargs2.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_getopt.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_getpass.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_gettext.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_glob.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_global.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_grammar.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_grp.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_gzip.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_hash.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_hashlib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_heapq.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_hmac.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_html.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_htmlparser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_http_cookiejar.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_http_cookies.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_httplib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_httpservers.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_idle.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_imaplib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_imghdr.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_imp.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_import.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/abc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/builtin/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/builtin/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/builtin/test_finder.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/builtin/test_loader.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/builtin/util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/extension/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/extension/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/extension/test_case_sensitivity.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/extension/test_finder.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/extension/test_loader.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/extension/test_path_hook.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/extension/util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/frozen/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/frozen/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/frozen/test_finder.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/frozen/test_loader.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/import_/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/import_/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/import_/test___loader__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/import_/test___package__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/import_/test_api.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/import_/test_caching.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/import_/test_fromlist.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/import_/test_meta_path.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/import_/test_packages.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/import_/test_path.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/import_/test_relative_imports.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/import_/util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/regrtest.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/source/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/source/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/source/test_case_sensitivity.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/source/test_file_loader.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/source/test_finder.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/source/test_path_hook.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/source/test_source_encoding.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/source/util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/test_abc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/test_api.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/test_locks.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/test_namespace_pkgs.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/test_spec.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/test_util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/test_windows.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_importlib/util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_index.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_inspect.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_int.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_int_literal.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_io.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_ioctl.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_ipaddress.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_isinstance.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_iter.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_iterlen.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_itertools.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_json/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_json/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_json/test_decode.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_json/test_default.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_json/test_dump.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_json/test_encode_basestring_ascii.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_json/test_enum.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_json/test_fail.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_json/test_float.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_json/test_indent.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_json/test_pass1.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_json/test_pass2.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_json/test_pass3.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_json/test_recursion.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_json/test_scanstring.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_json/test_separators.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_json/test_speedups.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_json/test_tool.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_json/test_unicode.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_keyword.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_keywordonlyarg.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_kqueue.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_largefile.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_lib2to3.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_linecache.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_list.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_listcomps.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_locale.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_logging.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_long.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_longexp.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_lzma.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_macpath.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_macurl2path.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_mailbox.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_mailcap.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_marshal.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_math.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_memoryio.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_memoryview.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_metaclass.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_mimetypes.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_minidom.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_mmap.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_module.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_modulefinder.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_msilib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_multibytecodec.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_multiprocessing_fork.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_multiprocessing_forkserver.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_multiprocessing_main_handling.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_multiprocessing_spawn.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_netrc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_nis.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_nntplib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_normalization.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_ntpath.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_numeric_tower.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_opcodes.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_openpty.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_operator.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_optparse.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_ordered_dict.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_os.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_ossaudiodev.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_osx_env.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_parser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pathlib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pdb.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_peepholer.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pep247.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pep277.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pep292.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pep3120.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pep3131.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pep3151.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pep352.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pep380.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pep479.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pickle.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pickletools.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pipes.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pkg.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pkgimport.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pkgutil.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_platform.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_plistlib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_poll.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_popen.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_poplib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_posix.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_posixpath.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pow.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pprint.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_print.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_profile.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_property.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pstats.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pty.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pulldom.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pwd.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_py_compile.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pyclbr.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pydoc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_pyexpat.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_queue.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_quopri.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_raise.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_random.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_range.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_re.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_readline.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_regrtest.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_reprlib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_resource.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_richcmp.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_rlcompleter.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_robotparser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_runpy.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_sax.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_sched.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_scope.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_script_helper.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_select.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_selectors.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_set.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_setcomps.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_shelve.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_shlex.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_shutil.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_signal.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_site.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_slice.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_smtpd.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_smtplib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_smtpnet.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_sndhdr.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_socket.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_socketserver.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_sort.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_source_encoding.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_spwd.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_sqlite.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_ssl.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_startfile.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_stat.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_statistics.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_strftime.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_string.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_stringprep.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_strlit.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_strptime.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_strtod.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_struct.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_structmembers.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_structseq.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_subprocess.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_sunau.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_sundry.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_super.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_support.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_symtable.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_syntax.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_sys.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_sys_setprofile.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_sys_settrace.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_sysconfig.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_syslog.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_tarfile.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_tcl.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_telnetlib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_tempfile.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_textwrap.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_thread.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_threaded_import.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_threadedtempfile.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_threading.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_threading_local.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_threadsignals.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_time.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_timeit.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_timeout.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_tk.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_tokenize.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_tools/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_tools/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_tools/test_gprof2html.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_tools/test_md5sum.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_tools/test_pdeps.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_tools/test_pindent.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_tools/test_reindent.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_tools/test_sundry.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_tools/test_unparse.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_trace.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_traceback.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_tracemalloc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_ttk_guionly.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_ttk_textonly.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_tuple.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_typechecks.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_types.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_typing.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_ucn.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_unary.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_unicode.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_unicode_file.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_unicodedata.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_unittest.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_univnewlines.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_unpack.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_unpack_ex.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_urllib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_urllib2.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_urllib2_localnet.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_urllib2net.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_urllib_response.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_urllibnet.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_urlparse.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_userdict.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_userlist.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_userstring.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_utf8_mode.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_uu.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_uuid.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_venv.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_wait3.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_wait4.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_warnings.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_wave.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_weakref.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_weakset.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_webbrowser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_winreg.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_winsound.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_with.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_wsgiref.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_xdrlib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_xml_dom_minicompat.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_xml_etree.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_xml_etree_c.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_xmlrpc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_xmlrpc_net.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_zipfile.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_zipfile64.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_zipimport.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_zipimport_support.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/test_zlib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/testcodec.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/testtar.tar (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/tf_inherit_check.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/threaded_import_hangers.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/time_hashlib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/tokenize_tests.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/tracedmodules/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/tracedmodules/testmod.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/warning_tests.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/win_console_handler.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/xmltestdata/simple-ns.xml (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/xmltestdata/simple.xml (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/xmltestdata/test.xml (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/xmltestdata/test.xml.out (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/xmltests.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/zip_cp437_header.zip (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/test/zipdir.zip (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/textwrap.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/this.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/threading.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/timeit.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/_fix.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/colorchooser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/commondialog.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/constants.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/dialog.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/dnd.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/filedialog.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/font.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/messagebox.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/scrolledtext.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/simpledialog.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/test/README (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/test/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/test/runtktests.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/test/support.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/test/test_tkinter/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/test/test_tkinter/test_font.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/test/test_tkinter/test_geometry_managers.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/test/test_tkinter/test_images.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/test/test_tkinter/test_loadtk.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/test/test_tkinter/test_misc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/test/test_tkinter/test_text.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/test/test_tkinter/test_variables.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/test/test_tkinter/test_widgets.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/test/test_ttk/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/test/test_ttk/test_extensions.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/test/test_ttk/test_functions.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/test/test_ttk/test_style.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/test/test_ttk/test_widgets.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/test/widget_tests.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/tix.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tkinter/ttk.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/token.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tokenize.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/trace.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/traceback.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tracemalloc.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/tty.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtle.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtledemo/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtledemo/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtledemo/bytedesign.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtledemo/chaos.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtledemo/clock.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtledemo/colormixer.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtledemo/forest.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtledemo/fractalcurves.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtledemo/lindenmayer.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtledemo/minimal_hanoi.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtledemo/nim.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtledemo/paint.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtledemo/peace.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtledemo/penrose.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtledemo/planet_and_moon.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtledemo/round_dance.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtledemo/tree.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtledemo/turtle.cfg (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtledemo/two_canvases.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtledemo/wikipedia.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/turtledemo/yinyang.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/types.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/typing.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/case.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/loader.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/main.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/mock.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/result.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/runner.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/signals.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/suite.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/_test_warnings.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/dummy.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/support.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/test_assertions.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/test_break.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/test_case.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/test_discovery.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/test_functiontestcase.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/test_loader.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/test_program.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/test_result.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/test_runner.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/test_setups.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/test_skipping.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/test_suite.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/testmock/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/testmock/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/testmock/support.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/testmock/testcallable.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/testmock/testhelpers.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/testmock/testmagicmethods.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/testmock/testmock.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/testmock/testpatch.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/testmock/testsentinel.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/test/testmock/testwith.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/unittest/util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/urllib/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/urllib/error.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/urllib/parse.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/urllib/request.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/urllib/response.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/urllib/robotparser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/uu.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/uuid.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/venv/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/venv/__main__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/venv/scripts/nt/Activate.ps1 (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/venv/scripts/nt/activate.bat (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/venv/scripts/nt/deactivate.bat (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/venv/scripts/posix/activate (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/venv/scripts/posix/activate.csh (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/venv/scripts/posix/activate.fish (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/warnings.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/wave.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/weakref.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/webbrowser.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/wpf.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/wsgiref/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/wsgiref/handlers.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/wsgiref/headers.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/wsgiref/simple_server.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/wsgiref/util.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/wsgiref/validate.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xdrlib.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/dom/NodeFilter.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/dom/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/dom/domreg.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/dom/expatbuilder.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/dom/minicompat.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/dom/minidom.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/dom/pulldom.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/dom/xmlbuilder.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/etree/ElementInclude.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/etree/ElementPath.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/etree/ElementTree.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/etree/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/etree/cElementTree.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/parsers/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/parsers/expat.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/sax/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/sax/_exceptions.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/sax/expatreader.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/sax/handler.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/sax/saxutils.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xml/sax/xmlreader.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xmlrpc/__init__.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xmlrpc/client.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/xmlrpc/server.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/Lib/zipfile.py (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/StdLib.License.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/stdlib-upgrade.txt (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/update-stdlib.cmd (100%) rename src/{extensions/StdLib => core/IronPython.StdLib}/update-stdlib.sh (100%) diff --git a/Build.proj b/Build.proj index 30d3fd487..9ff463c60 100644 --- a/Build.proj +++ b/Build.proj @@ -117,7 +117,7 @@ - diff --git a/src/extensions/StdLib/.gitattributes b/src/core/IronPython.StdLib/.gitattributes similarity index 100% rename from src/extensions/StdLib/.gitattributes rename to src/core/IronPython.StdLib/.gitattributes diff --git a/src/extensions/StdLib/StdLib.pyproj b/src/core/IronPython.StdLib/IronPython.StdLib.pyproj similarity index 100% rename from src/extensions/StdLib/StdLib.pyproj rename to src/core/IronPython.StdLib/IronPython.StdLib.pyproj diff --git a/src/extensions/StdLib/Lib/__future__.py b/src/core/IronPython.StdLib/Lib/__future__.py similarity index 100% rename from src/extensions/StdLib/Lib/__future__.py rename to src/core/IronPython.StdLib/Lib/__future__.py diff --git a/src/extensions/StdLib/Lib/__phello__.foo.py b/src/core/IronPython.StdLib/Lib/__phello__.foo.py similarity index 100% rename from src/extensions/StdLib/Lib/__phello__.foo.py rename to src/core/IronPython.StdLib/Lib/__phello__.foo.py diff --git a/src/extensions/StdLib/Lib/_bootlocale.py b/src/core/IronPython.StdLib/Lib/_bootlocale.py similarity index 100% rename from src/extensions/StdLib/Lib/_bootlocale.py rename to src/core/IronPython.StdLib/Lib/_bootlocale.py diff --git a/src/extensions/StdLib/Lib/_collections_abc.py b/src/core/IronPython.StdLib/Lib/_collections_abc.py similarity index 100% rename from src/extensions/StdLib/Lib/_collections_abc.py rename to src/core/IronPython.StdLib/Lib/_collections_abc.py diff --git a/src/extensions/StdLib/Lib/_compat_pickle.py b/src/core/IronPython.StdLib/Lib/_compat_pickle.py similarity index 100% rename from src/extensions/StdLib/Lib/_compat_pickle.py rename to src/core/IronPython.StdLib/Lib/_compat_pickle.py diff --git a/src/extensions/StdLib/Lib/_dummy_thread.py b/src/core/IronPython.StdLib/Lib/_dummy_thread.py similarity index 100% rename from src/extensions/StdLib/Lib/_dummy_thread.py rename to src/core/IronPython.StdLib/Lib/_dummy_thread.py diff --git a/src/extensions/StdLib/Lib/_markupbase.py b/src/core/IronPython.StdLib/Lib/_markupbase.py similarity index 100% rename from src/extensions/StdLib/Lib/_markupbase.py rename to src/core/IronPython.StdLib/Lib/_markupbase.py diff --git a/src/extensions/StdLib/Lib/_osx_support.py b/src/core/IronPython.StdLib/Lib/_osx_support.py similarity index 100% rename from src/extensions/StdLib/Lib/_osx_support.py rename to src/core/IronPython.StdLib/Lib/_osx_support.py diff --git a/src/extensions/StdLib/Lib/_pyio.py b/src/core/IronPython.StdLib/Lib/_pyio.py similarity index 100% rename from src/extensions/StdLib/Lib/_pyio.py rename to src/core/IronPython.StdLib/Lib/_pyio.py diff --git a/src/extensions/StdLib/Lib/_sitebuiltins.py b/src/core/IronPython.StdLib/Lib/_sitebuiltins.py similarity index 100% rename from src/extensions/StdLib/Lib/_sitebuiltins.py rename to src/core/IronPython.StdLib/Lib/_sitebuiltins.py diff --git a/src/extensions/StdLib/Lib/_strptime.py b/src/core/IronPython.StdLib/Lib/_strptime.py similarity index 100% rename from src/extensions/StdLib/Lib/_strptime.py rename to src/core/IronPython.StdLib/Lib/_strptime.py diff --git a/src/extensions/StdLib/Lib/_threading_local.py b/src/core/IronPython.StdLib/Lib/_threading_local.py similarity index 100% rename from src/extensions/StdLib/Lib/_threading_local.py rename to src/core/IronPython.StdLib/Lib/_threading_local.py diff --git a/src/extensions/StdLib/Lib/_weakrefset.py b/src/core/IronPython.StdLib/Lib/_weakrefset.py similarity index 100% rename from src/extensions/StdLib/Lib/_weakrefset.py rename to src/core/IronPython.StdLib/Lib/_weakrefset.py diff --git a/src/extensions/StdLib/Lib/abc.py b/src/core/IronPython.StdLib/Lib/abc.py similarity index 100% rename from src/extensions/StdLib/Lib/abc.py rename to src/core/IronPython.StdLib/Lib/abc.py diff --git a/src/extensions/StdLib/Lib/aifc.py b/src/core/IronPython.StdLib/Lib/aifc.py similarity index 100% rename from src/extensions/StdLib/Lib/aifc.py rename to src/core/IronPython.StdLib/Lib/aifc.py diff --git a/src/extensions/StdLib/Lib/antigravity.py b/src/core/IronPython.StdLib/Lib/antigravity.py similarity index 100% rename from src/extensions/StdLib/Lib/antigravity.py rename to src/core/IronPython.StdLib/Lib/antigravity.py diff --git a/src/extensions/StdLib/Lib/argparse.py b/src/core/IronPython.StdLib/Lib/argparse.py similarity index 100% rename from src/extensions/StdLib/Lib/argparse.py rename to src/core/IronPython.StdLib/Lib/argparse.py diff --git a/src/extensions/StdLib/Lib/ast.py b/src/core/IronPython.StdLib/Lib/ast.py similarity index 100% rename from src/extensions/StdLib/Lib/ast.py rename to src/core/IronPython.StdLib/Lib/ast.py diff --git a/src/extensions/StdLib/Lib/asynchat.py b/src/core/IronPython.StdLib/Lib/asynchat.py similarity index 100% rename from src/extensions/StdLib/Lib/asynchat.py rename to src/core/IronPython.StdLib/Lib/asynchat.py diff --git a/src/extensions/StdLib/Lib/asyncio/__init__.py b/src/core/IronPython.StdLib/Lib/asyncio/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/__init__.py rename to src/core/IronPython.StdLib/Lib/asyncio/__init__.py diff --git a/src/extensions/StdLib/Lib/asyncio/base_events.py b/src/core/IronPython.StdLib/Lib/asyncio/base_events.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/base_events.py rename to src/core/IronPython.StdLib/Lib/asyncio/base_events.py diff --git a/src/extensions/StdLib/Lib/asyncio/base_subprocess.py b/src/core/IronPython.StdLib/Lib/asyncio/base_subprocess.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/base_subprocess.py rename to src/core/IronPython.StdLib/Lib/asyncio/base_subprocess.py diff --git a/src/extensions/StdLib/Lib/asyncio/compat.py b/src/core/IronPython.StdLib/Lib/asyncio/compat.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/compat.py rename to src/core/IronPython.StdLib/Lib/asyncio/compat.py diff --git a/src/extensions/StdLib/Lib/asyncio/constants.py b/src/core/IronPython.StdLib/Lib/asyncio/constants.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/constants.py rename to src/core/IronPython.StdLib/Lib/asyncio/constants.py diff --git a/src/extensions/StdLib/Lib/asyncio/coroutines.py b/src/core/IronPython.StdLib/Lib/asyncio/coroutines.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/coroutines.py rename to src/core/IronPython.StdLib/Lib/asyncio/coroutines.py diff --git a/src/extensions/StdLib/Lib/asyncio/events.py b/src/core/IronPython.StdLib/Lib/asyncio/events.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/events.py rename to src/core/IronPython.StdLib/Lib/asyncio/events.py diff --git a/src/extensions/StdLib/Lib/asyncio/futures.py b/src/core/IronPython.StdLib/Lib/asyncio/futures.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/futures.py rename to src/core/IronPython.StdLib/Lib/asyncio/futures.py diff --git a/src/extensions/StdLib/Lib/asyncio/locks.py b/src/core/IronPython.StdLib/Lib/asyncio/locks.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/locks.py rename to src/core/IronPython.StdLib/Lib/asyncio/locks.py diff --git a/src/extensions/StdLib/Lib/asyncio/log.py b/src/core/IronPython.StdLib/Lib/asyncio/log.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/log.py rename to src/core/IronPython.StdLib/Lib/asyncio/log.py diff --git a/src/extensions/StdLib/Lib/asyncio/proactor_events.py b/src/core/IronPython.StdLib/Lib/asyncio/proactor_events.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/proactor_events.py rename to src/core/IronPython.StdLib/Lib/asyncio/proactor_events.py diff --git a/src/extensions/StdLib/Lib/asyncio/protocols.py b/src/core/IronPython.StdLib/Lib/asyncio/protocols.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/protocols.py rename to src/core/IronPython.StdLib/Lib/asyncio/protocols.py diff --git a/src/extensions/StdLib/Lib/asyncio/queues.py b/src/core/IronPython.StdLib/Lib/asyncio/queues.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/queues.py rename to src/core/IronPython.StdLib/Lib/asyncio/queues.py diff --git a/src/extensions/StdLib/Lib/asyncio/selector_events.py b/src/core/IronPython.StdLib/Lib/asyncio/selector_events.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/selector_events.py rename to src/core/IronPython.StdLib/Lib/asyncio/selector_events.py diff --git a/src/extensions/StdLib/Lib/asyncio/sslproto.py b/src/core/IronPython.StdLib/Lib/asyncio/sslproto.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/sslproto.py rename to src/core/IronPython.StdLib/Lib/asyncio/sslproto.py diff --git a/src/extensions/StdLib/Lib/asyncio/streams.py b/src/core/IronPython.StdLib/Lib/asyncio/streams.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/streams.py rename to src/core/IronPython.StdLib/Lib/asyncio/streams.py diff --git a/src/extensions/StdLib/Lib/asyncio/subprocess.py b/src/core/IronPython.StdLib/Lib/asyncio/subprocess.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/subprocess.py rename to src/core/IronPython.StdLib/Lib/asyncio/subprocess.py diff --git a/src/extensions/StdLib/Lib/asyncio/tasks.py b/src/core/IronPython.StdLib/Lib/asyncio/tasks.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/tasks.py rename to src/core/IronPython.StdLib/Lib/asyncio/tasks.py diff --git a/src/extensions/StdLib/Lib/asyncio/test_utils.py b/src/core/IronPython.StdLib/Lib/asyncio/test_utils.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/test_utils.py rename to src/core/IronPython.StdLib/Lib/asyncio/test_utils.py diff --git a/src/extensions/StdLib/Lib/asyncio/transports.py b/src/core/IronPython.StdLib/Lib/asyncio/transports.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/transports.py rename to src/core/IronPython.StdLib/Lib/asyncio/transports.py diff --git a/src/extensions/StdLib/Lib/asyncio/unix_events.py b/src/core/IronPython.StdLib/Lib/asyncio/unix_events.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/unix_events.py rename to src/core/IronPython.StdLib/Lib/asyncio/unix_events.py diff --git a/src/extensions/StdLib/Lib/asyncio/windows_events.py b/src/core/IronPython.StdLib/Lib/asyncio/windows_events.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/windows_events.py rename to src/core/IronPython.StdLib/Lib/asyncio/windows_events.py diff --git a/src/extensions/StdLib/Lib/asyncio/windows_utils.py b/src/core/IronPython.StdLib/Lib/asyncio/windows_utils.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncio/windows_utils.py rename to src/core/IronPython.StdLib/Lib/asyncio/windows_utils.py diff --git a/src/extensions/StdLib/Lib/asyncore.py b/src/core/IronPython.StdLib/Lib/asyncore.py similarity index 100% rename from src/extensions/StdLib/Lib/asyncore.py rename to src/core/IronPython.StdLib/Lib/asyncore.py diff --git a/src/extensions/StdLib/Lib/base64.py b/src/core/IronPython.StdLib/Lib/base64.py similarity index 100% rename from src/extensions/StdLib/Lib/base64.py rename to src/core/IronPython.StdLib/Lib/base64.py diff --git a/src/extensions/StdLib/Lib/bdb.py b/src/core/IronPython.StdLib/Lib/bdb.py similarity index 100% rename from src/extensions/StdLib/Lib/bdb.py rename to src/core/IronPython.StdLib/Lib/bdb.py diff --git a/src/extensions/StdLib/Lib/binhex.py b/src/core/IronPython.StdLib/Lib/binhex.py similarity index 100% rename from src/extensions/StdLib/Lib/binhex.py rename to src/core/IronPython.StdLib/Lib/binhex.py diff --git a/src/extensions/StdLib/Lib/bisect.py b/src/core/IronPython.StdLib/Lib/bisect.py similarity index 100% rename from src/extensions/StdLib/Lib/bisect.py rename to src/core/IronPython.StdLib/Lib/bisect.py diff --git a/src/extensions/StdLib/Lib/bz2.py b/src/core/IronPython.StdLib/Lib/bz2.py similarity index 100% rename from src/extensions/StdLib/Lib/bz2.py rename to src/core/IronPython.StdLib/Lib/bz2.py diff --git a/src/extensions/StdLib/Lib/cProfile.py b/src/core/IronPython.StdLib/Lib/cProfile.py similarity index 100% rename from src/extensions/StdLib/Lib/cProfile.py rename to src/core/IronPython.StdLib/Lib/cProfile.py diff --git a/src/extensions/StdLib/Lib/calendar.py b/src/core/IronPython.StdLib/Lib/calendar.py similarity index 100% rename from src/extensions/StdLib/Lib/calendar.py rename to src/core/IronPython.StdLib/Lib/calendar.py diff --git a/src/extensions/StdLib/Lib/cgi.py b/src/core/IronPython.StdLib/Lib/cgi.py similarity index 100% rename from src/extensions/StdLib/Lib/cgi.py rename to src/core/IronPython.StdLib/Lib/cgi.py diff --git a/src/extensions/StdLib/Lib/cgitb.py b/src/core/IronPython.StdLib/Lib/cgitb.py similarity index 100% rename from src/extensions/StdLib/Lib/cgitb.py rename to src/core/IronPython.StdLib/Lib/cgitb.py diff --git a/src/extensions/StdLib/Lib/chunk.py b/src/core/IronPython.StdLib/Lib/chunk.py similarity index 100% rename from src/extensions/StdLib/Lib/chunk.py rename to src/core/IronPython.StdLib/Lib/chunk.py diff --git a/src/extensions/StdLib/Lib/clrtype.py b/src/core/IronPython.StdLib/Lib/clrtype.py similarity index 100% rename from src/extensions/StdLib/Lib/clrtype.py rename to src/core/IronPython.StdLib/Lib/clrtype.py diff --git a/src/extensions/StdLib/Lib/cmd.py b/src/core/IronPython.StdLib/Lib/cmd.py similarity index 100% rename from src/extensions/StdLib/Lib/cmd.py rename to src/core/IronPython.StdLib/Lib/cmd.py diff --git a/src/extensions/StdLib/Lib/code.py b/src/core/IronPython.StdLib/Lib/code.py similarity index 100% rename from src/extensions/StdLib/Lib/code.py rename to src/core/IronPython.StdLib/Lib/code.py diff --git a/src/extensions/StdLib/Lib/codecs.py b/src/core/IronPython.StdLib/Lib/codecs.py similarity index 100% rename from src/extensions/StdLib/Lib/codecs.py rename to src/core/IronPython.StdLib/Lib/codecs.py diff --git a/src/extensions/StdLib/Lib/codeop.py b/src/core/IronPython.StdLib/Lib/codeop.py similarity index 100% rename from src/extensions/StdLib/Lib/codeop.py rename to src/core/IronPython.StdLib/Lib/codeop.py diff --git a/src/extensions/StdLib/Lib/collections/__init__.py b/src/core/IronPython.StdLib/Lib/collections/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/collections/__init__.py rename to src/core/IronPython.StdLib/Lib/collections/__init__.py diff --git a/src/extensions/StdLib/Lib/collections/__main__.py b/src/core/IronPython.StdLib/Lib/collections/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/collections/__main__.py rename to src/core/IronPython.StdLib/Lib/collections/__main__.py diff --git a/src/extensions/StdLib/Lib/collections/abc.py b/src/core/IronPython.StdLib/Lib/collections/abc.py similarity index 100% rename from src/extensions/StdLib/Lib/collections/abc.py rename to src/core/IronPython.StdLib/Lib/collections/abc.py diff --git a/src/extensions/StdLib/Lib/colorsys.py b/src/core/IronPython.StdLib/Lib/colorsys.py similarity index 100% rename from src/extensions/StdLib/Lib/colorsys.py rename to src/core/IronPython.StdLib/Lib/colorsys.py diff --git a/src/extensions/StdLib/Lib/compileall.py b/src/core/IronPython.StdLib/Lib/compileall.py similarity index 100% rename from src/extensions/StdLib/Lib/compileall.py rename to src/core/IronPython.StdLib/Lib/compileall.py diff --git a/src/extensions/StdLib/Lib/concurrent/__init__.py b/src/core/IronPython.StdLib/Lib/concurrent/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/concurrent/__init__.py rename to src/core/IronPython.StdLib/Lib/concurrent/__init__.py diff --git a/src/extensions/StdLib/Lib/concurrent/futures/__init__.py b/src/core/IronPython.StdLib/Lib/concurrent/futures/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/concurrent/futures/__init__.py rename to src/core/IronPython.StdLib/Lib/concurrent/futures/__init__.py diff --git a/src/extensions/StdLib/Lib/concurrent/futures/_base.py b/src/core/IronPython.StdLib/Lib/concurrent/futures/_base.py similarity index 100% rename from src/extensions/StdLib/Lib/concurrent/futures/_base.py rename to src/core/IronPython.StdLib/Lib/concurrent/futures/_base.py diff --git a/src/extensions/StdLib/Lib/concurrent/futures/process.py b/src/core/IronPython.StdLib/Lib/concurrent/futures/process.py similarity index 100% rename from src/extensions/StdLib/Lib/concurrent/futures/process.py rename to src/core/IronPython.StdLib/Lib/concurrent/futures/process.py diff --git a/src/extensions/StdLib/Lib/concurrent/futures/thread.py b/src/core/IronPython.StdLib/Lib/concurrent/futures/thread.py similarity index 100% rename from src/extensions/StdLib/Lib/concurrent/futures/thread.py rename to src/core/IronPython.StdLib/Lib/concurrent/futures/thread.py diff --git a/src/extensions/StdLib/Lib/configparser.py b/src/core/IronPython.StdLib/Lib/configparser.py similarity index 100% rename from src/extensions/StdLib/Lib/configparser.py rename to src/core/IronPython.StdLib/Lib/configparser.py diff --git a/src/extensions/StdLib/Lib/contextlib.py b/src/core/IronPython.StdLib/Lib/contextlib.py similarity index 100% rename from src/extensions/StdLib/Lib/contextlib.py rename to src/core/IronPython.StdLib/Lib/contextlib.py diff --git a/src/extensions/StdLib/Lib/copy.py b/src/core/IronPython.StdLib/Lib/copy.py similarity index 100% rename from src/extensions/StdLib/Lib/copy.py rename to src/core/IronPython.StdLib/Lib/copy.py diff --git a/src/extensions/StdLib/Lib/copyreg.py b/src/core/IronPython.StdLib/Lib/copyreg.py similarity index 100% rename from src/extensions/StdLib/Lib/copyreg.py rename to src/core/IronPython.StdLib/Lib/copyreg.py diff --git a/src/extensions/StdLib/Lib/crypt.py b/src/core/IronPython.StdLib/Lib/crypt.py similarity index 100% rename from src/extensions/StdLib/Lib/crypt.py rename to src/core/IronPython.StdLib/Lib/crypt.py diff --git a/src/extensions/StdLib/Lib/csv.py b/src/core/IronPython.StdLib/Lib/csv.py similarity index 100% rename from src/extensions/StdLib/Lib/csv.py rename to src/core/IronPython.StdLib/Lib/csv.py diff --git a/src/extensions/StdLib/Lib/ctypes/__init__.py b/src/core/IronPython.StdLib/Lib/ctypes/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/__init__.py rename to src/core/IronPython.StdLib/Lib/ctypes/__init__.py diff --git a/src/extensions/StdLib/Lib/ctypes/_endian.py b/src/core/IronPython.StdLib/Lib/ctypes/_endian.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/_endian.py rename to src/core/IronPython.StdLib/Lib/ctypes/_endian.py diff --git a/src/extensions/StdLib/Lib/ctypes/macholib/README.ctypes b/src/core/IronPython.StdLib/Lib/ctypes/macholib/README.ctypes similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/macholib/README.ctypes rename to src/core/IronPython.StdLib/Lib/ctypes/macholib/README.ctypes diff --git a/src/extensions/StdLib/Lib/ctypes/macholib/__init__.py b/src/core/IronPython.StdLib/Lib/ctypes/macholib/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/macholib/__init__.py rename to src/core/IronPython.StdLib/Lib/ctypes/macholib/__init__.py diff --git a/src/extensions/StdLib/Lib/ctypes/macholib/dyld.py b/src/core/IronPython.StdLib/Lib/ctypes/macholib/dyld.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/macholib/dyld.py rename to src/core/IronPython.StdLib/Lib/ctypes/macholib/dyld.py diff --git a/src/extensions/StdLib/Lib/ctypes/macholib/dylib.py b/src/core/IronPython.StdLib/Lib/ctypes/macholib/dylib.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/macholib/dylib.py rename to src/core/IronPython.StdLib/Lib/ctypes/macholib/dylib.py diff --git a/src/extensions/StdLib/Lib/ctypes/macholib/fetch_macholib b/src/core/IronPython.StdLib/Lib/ctypes/macholib/fetch_macholib similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/macholib/fetch_macholib rename to src/core/IronPython.StdLib/Lib/ctypes/macholib/fetch_macholib diff --git a/src/extensions/StdLib/Lib/ctypes/macholib/fetch_macholib.bat b/src/core/IronPython.StdLib/Lib/ctypes/macholib/fetch_macholib.bat similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/macholib/fetch_macholib.bat rename to src/core/IronPython.StdLib/Lib/ctypes/macholib/fetch_macholib.bat diff --git a/src/extensions/StdLib/Lib/ctypes/macholib/framework.py b/src/core/IronPython.StdLib/Lib/ctypes/macholib/framework.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/macholib/framework.py rename to src/core/IronPython.StdLib/Lib/ctypes/macholib/framework.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/__init__.py b/src/core/IronPython.StdLib/Lib/ctypes/test/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/__init__.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/__init__.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/__main__.py b/src/core/IronPython.StdLib/Lib/ctypes/test/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/__main__.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/__main__.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_anon.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_anon.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_anon.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_anon.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_array_in_pointer.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_array_in_pointer.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_array_in_pointer.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_array_in_pointer.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_arrays.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_arrays.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_arrays.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_arrays.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_as_parameter.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_as_parameter.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_as_parameter.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_as_parameter.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_bitfields.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_bitfields.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_bitfields.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_bitfields.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_buffers.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_buffers.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_buffers.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_buffers.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_bytes.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_bytes.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_bytes.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_bytes.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_byteswap.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_byteswap.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_byteswap.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_byteswap.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_callbacks.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_callbacks.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_callbacks.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_callbacks.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_cast.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_cast.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_cast.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_cast.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_cfuncs.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_cfuncs.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_cfuncs.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_cfuncs.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_checkretval.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_checkretval.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_checkretval.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_checkretval.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_delattr.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_delattr.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_delattr.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_delattr.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_errno.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_errno.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_errno.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_errno.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_find.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_find.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_find.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_find.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_frombuffer.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_frombuffer.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_frombuffer.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_frombuffer.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_funcptr.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_funcptr.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_funcptr.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_funcptr.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_functions.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_functions.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_functions.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_functions.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_incomplete.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_incomplete.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_incomplete.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_incomplete.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_init.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_init.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_init.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_init.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_internals.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_internals.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_internals.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_internals.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_keeprefs.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_keeprefs.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_keeprefs.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_keeprefs.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_libc.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_libc.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_libc.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_libc.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_loading.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_loading.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_loading.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_loading.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_macholib.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_macholib.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_macholib.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_macholib.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_memfunctions.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_memfunctions.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_memfunctions.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_memfunctions.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_numbers.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_numbers.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_numbers.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_numbers.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_objects.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_objects.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_objects.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_objects.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_parameters.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_parameters.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_parameters.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_parameters.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_pep3118.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_pep3118.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_pep3118.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_pep3118.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_pickling.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_pickling.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_pickling.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_pickling.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_pointers.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_pointers.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_pointers.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_pointers.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_prototypes.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_prototypes.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_prototypes.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_prototypes.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_python_api.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_python_api.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_python_api.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_python_api.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_random_things.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_random_things.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_random_things.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_random_things.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_refcounts.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_refcounts.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_refcounts.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_refcounts.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_repr.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_repr.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_repr.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_repr.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_returnfuncptrs.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_returnfuncptrs.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_returnfuncptrs.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_returnfuncptrs.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_simplesubclasses.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_simplesubclasses.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_simplesubclasses.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_simplesubclasses.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_sizes.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_sizes.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_sizes.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_sizes.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_slicing.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_slicing.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_slicing.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_slicing.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_stringptr.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_stringptr.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_stringptr.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_stringptr.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_strings.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_strings.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_strings.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_strings.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_struct_fields.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_struct_fields.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_struct_fields.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_struct_fields.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_structures.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_structures.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_structures.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_structures.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_unaligned_structures.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_unaligned_structures.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_unaligned_structures.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_unaligned_structures.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_unicode.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_unicode.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_unicode.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_unicode.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_values.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_values.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_values.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_values.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_varsize_struct.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_varsize_struct.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_varsize_struct.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_varsize_struct.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_win32.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_win32.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_win32.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_win32.py diff --git a/src/extensions/StdLib/Lib/ctypes/test/test_wintypes.py b/src/core/IronPython.StdLib/Lib/ctypes/test/test_wintypes.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/test/test_wintypes.py rename to src/core/IronPython.StdLib/Lib/ctypes/test/test_wintypes.py diff --git a/src/extensions/StdLib/Lib/ctypes/util.py b/src/core/IronPython.StdLib/Lib/ctypes/util.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/util.py rename to src/core/IronPython.StdLib/Lib/ctypes/util.py diff --git a/src/extensions/StdLib/Lib/ctypes/wintypes.py b/src/core/IronPython.StdLib/Lib/ctypes/wintypes.py similarity index 100% rename from src/extensions/StdLib/Lib/ctypes/wintypes.py rename to src/core/IronPython.StdLib/Lib/ctypes/wintypes.py diff --git a/src/extensions/StdLib/Lib/curses/__init__.py b/src/core/IronPython.StdLib/Lib/curses/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/curses/__init__.py rename to src/core/IronPython.StdLib/Lib/curses/__init__.py diff --git a/src/extensions/StdLib/Lib/curses/ascii.py b/src/core/IronPython.StdLib/Lib/curses/ascii.py similarity index 100% rename from src/extensions/StdLib/Lib/curses/ascii.py rename to src/core/IronPython.StdLib/Lib/curses/ascii.py diff --git a/src/extensions/StdLib/Lib/curses/has_key.py b/src/core/IronPython.StdLib/Lib/curses/has_key.py similarity index 100% rename from src/extensions/StdLib/Lib/curses/has_key.py rename to src/core/IronPython.StdLib/Lib/curses/has_key.py diff --git a/src/extensions/StdLib/Lib/curses/panel.py b/src/core/IronPython.StdLib/Lib/curses/panel.py similarity index 100% rename from src/extensions/StdLib/Lib/curses/panel.py rename to src/core/IronPython.StdLib/Lib/curses/panel.py diff --git a/src/extensions/StdLib/Lib/curses/textpad.py b/src/core/IronPython.StdLib/Lib/curses/textpad.py similarity index 100% rename from src/extensions/StdLib/Lib/curses/textpad.py rename to src/core/IronPython.StdLib/Lib/curses/textpad.py diff --git a/src/extensions/StdLib/Lib/datetime.py b/src/core/IronPython.StdLib/Lib/datetime.py similarity index 100% rename from src/extensions/StdLib/Lib/datetime.py rename to src/core/IronPython.StdLib/Lib/datetime.py diff --git a/src/extensions/StdLib/Lib/dbm/__init__.py b/src/core/IronPython.StdLib/Lib/dbm/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/dbm/__init__.py rename to src/core/IronPython.StdLib/Lib/dbm/__init__.py diff --git a/src/extensions/StdLib/Lib/dbm/dumb.py b/src/core/IronPython.StdLib/Lib/dbm/dumb.py similarity index 100% rename from src/extensions/StdLib/Lib/dbm/dumb.py rename to src/core/IronPython.StdLib/Lib/dbm/dumb.py diff --git a/src/extensions/StdLib/Lib/dbm/gnu.py b/src/core/IronPython.StdLib/Lib/dbm/gnu.py similarity index 100% rename from src/extensions/StdLib/Lib/dbm/gnu.py rename to src/core/IronPython.StdLib/Lib/dbm/gnu.py diff --git a/src/extensions/StdLib/Lib/dbm/ndbm.py b/src/core/IronPython.StdLib/Lib/dbm/ndbm.py similarity index 100% rename from src/extensions/StdLib/Lib/dbm/ndbm.py rename to src/core/IronPython.StdLib/Lib/dbm/ndbm.py diff --git a/src/extensions/StdLib/Lib/decimal.py b/src/core/IronPython.StdLib/Lib/decimal.py similarity index 100% rename from src/extensions/StdLib/Lib/decimal.py rename to src/core/IronPython.StdLib/Lib/decimal.py diff --git a/src/extensions/StdLib/Lib/difflib.py b/src/core/IronPython.StdLib/Lib/difflib.py similarity index 100% rename from src/extensions/StdLib/Lib/difflib.py rename to src/core/IronPython.StdLib/Lib/difflib.py diff --git a/src/extensions/StdLib/Lib/dis.py b/src/core/IronPython.StdLib/Lib/dis.py similarity index 100% rename from src/extensions/StdLib/Lib/dis.py rename to src/core/IronPython.StdLib/Lib/dis.py diff --git a/src/extensions/StdLib/Lib/distutils/README b/src/core/IronPython.StdLib/Lib/distutils/README similarity index 100% rename from src/extensions/StdLib/Lib/distutils/README rename to src/core/IronPython.StdLib/Lib/distutils/README diff --git a/src/extensions/StdLib/Lib/distutils/__init__.py b/src/core/IronPython.StdLib/Lib/distutils/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/__init__.py rename to src/core/IronPython.StdLib/Lib/distutils/__init__.py diff --git a/src/extensions/StdLib/Lib/distutils/archive_util.py b/src/core/IronPython.StdLib/Lib/distutils/archive_util.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/archive_util.py rename to src/core/IronPython.StdLib/Lib/distutils/archive_util.py diff --git a/src/extensions/StdLib/Lib/distutils/bcppcompiler.py b/src/core/IronPython.StdLib/Lib/distutils/bcppcompiler.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/bcppcompiler.py rename to src/core/IronPython.StdLib/Lib/distutils/bcppcompiler.py diff --git a/src/extensions/StdLib/Lib/distutils/ccompiler.py b/src/core/IronPython.StdLib/Lib/distutils/ccompiler.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/ccompiler.py rename to src/core/IronPython.StdLib/Lib/distutils/ccompiler.py diff --git a/src/extensions/StdLib/Lib/distutils/cmd.py b/src/core/IronPython.StdLib/Lib/distutils/cmd.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/cmd.py rename to src/core/IronPython.StdLib/Lib/distutils/cmd.py diff --git a/src/extensions/StdLib/Lib/distutils/command/__init__.py b/src/core/IronPython.StdLib/Lib/distutils/command/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/__init__.py rename to src/core/IronPython.StdLib/Lib/distutils/command/__init__.py diff --git a/src/extensions/StdLib/Lib/distutils/command/bdist.py b/src/core/IronPython.StdLib/Lib/distutils/command/bdist.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/bdist.py rename to src/core/IronPython.StdLib/Lib/distutils/command/bdist.py diff --git a/src/extensions/StdLib/Lib/distutils/command/bdist_dumb.py b/src/core/IronPython.StdLib/Lib/distutils/command/bdist_dumb.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/bdist_dumb.py rename to src/core/IronPython.StdLib/Lib/distutils/command/bdist_dumb.py diff --git a/src/extensions/StdLib/Lib/distutils/command/bdist_msi.py b/src/core/IronPython.StdLib/Lib/distutils/command/bdist_msi.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/bdist_msi.py rename to src/core/IronPython.StdLib/Lib/distutils/command/bdist_msi.py diff --git a/src/extensions/StdLib/Lib/distutils/command/bdist_rpm.py b/src/core/IronPython.StdLib/Lib/distutils/command/bdist_rpm.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/bdist_rpm.py rename to src/core/IronPython.StdLib/Lib/distutils/command/bdist_rpm.py diff --git a/src/extensions/StdLib/Lib/distutils/command/bdist_wininst.py b/src/core/IronPython.StdLib/Lib/distutils/command/bdist_wininst.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/bdist_wininst.py rename to src/core/IronPython.StdLib/Lib/distutils/command/bdist_wininst.py diff --git a/src/extensions/StdLib/Lib/distutils/command/build.py b/src/core/IronPython.StdLib/Lib/distutils/command/build.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/build.py rename to src/core/IronPython.StdLib/Lib/distutils/command/build.py diff --git a/src/extensions/StdLib/Lib/distutils/command/build_clib.py b/src/core/IronPython.StdLib/Lib/distutils/command/build_clib.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/build_clib.py rename to src/core/IronPython.StdLib/Lib/distutils/command/build_clib.py diff --git a/src/extensions/StdLib/Lib/distutils/command/build_ext.py b/src/core/IronPython.StdLib/Lib/distutils/command/build_ext.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/build_ext.py rename to src/core/IronPython.StdLib/Lib/distutils/command/build_ext.py diff --git a/src/extensions/StdLib/Lib/distutils/command/build_py.py b/src/core/IronPython.StdLib/Lib/distutils/command/build_py.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/build_py.py rename to src/core/IronPython.StdLib/Lib/distutils/command/build_py.py diff --git a/src/extensions/StdLib/Lib/distutils/command/build_scripts.py b/src/core/IronPython.StdLib/Lib/distutils/command/build_scripts.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/build_scripts.py rename to src/core/IronPython.StdLib/Lib/distutils/command/build_scripts.py diff --git a/src/extensions/StdLib/Lib/distutils/command/check.py b/src/core/IronPython.StdLib/Lib/distutils/command/check.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/check.py rename to src/core/IronPython.StdLib/Lib/distutils/command/check.py diff --git a/src/extensions/StdLib/Lib/distutils/command/clean.py b/src/core/IronPython.StdLib/Lib/distutils/command/clean.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/clean.py rename to src/core/IronPython.StdLib/Lib/distutils/command/clean.py diff --git a/src/extensions/StdLib/Lib/distutils/command/command_template b/src/core/IronPython.StdLib/Lib/distutils/command/command_template similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/command_template rename to src/core/IronPython.StdLib/Lib/distutils/command/command_template diff --git a/src/extensions/StdLib/Lib/distutils/command/config.py b/src/core/IronPython.StdLib/Lib/distutils/command/config.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/config.py rename to src/core/IronPython.StdLib/Lib/distutils/command/config.py diff --git a/src/extensions/StdLib/Lib/distutils/command/install.py b/src/core/IronPython.StdLib/Lib/distutils/command/install.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/install.py rename to src/core/IronPython.StdLib/Lib/distutils/command/install.py diff --git a/src/extensions/StdLib/Lib/distutils/command/install_data.py b/src/core/IronPython.StdLib/Lib/distutils/command/install_data.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/install_data.py rename to src/core/IronPython.StdLib/Lib/distutils/command/install_data.py diff --git a/src/extensions/StdLib/Lib/distutils/command/install_egg_info.py b/src/core/IronPython.StdLib/Lib/distutils/command/install_egg_info.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/install_egg_info.py rename to src/core/IronPython.StdLib/Lib/distutils/command/install_egg_info.py diff --git a/src/extensions/StdLib/Lib/distutils/command/install_headers.py b/src/core/IronPython.StdLib/Lib/distutils/command/install_headers.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/install_headers.py rename to src/core/IronPython.StdLib/Lib/distutils/command/install_headers.py diff --git a/src/extensions/StdLib/Lib/distutils/command/install_lib.py b/src/core/IronPython.StdLib/Lib/distutils/command/install_lib.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/install_lib.py rename to src/core/IronPython.StdLib/Lib/distutils/command/install_lib.py diff --git a/src/extensions/StdLib/Lib/distutils/command/install_scripts.py b/src/core/IronPython.StdLib/Lib/distutils/command/install_scripts.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/install_scripts.py rename to src/core/IronPython.StdLib/Lib/distutils/command/install_scripts.py diff --git a/src/extensions/StdLib/Lib/distutils/command/register.py b/src/core/IronPython.StdLib/Lib/distutils/command/register.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/register.py rename to src/core/IronPython.StdLib/Lib/distutils/command/register.py diff --git a/src/extensions/StdLib/Lib/distutils/command/sdist.py b/src/core/IronPython.StdLib/Lib/distutils/command/sdist.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/sdist.py rename to src/core/IronPython.StdLib/Lib/distutils/command/sdist.py diff --git a/src/extensions/StdLib/Lib/distutils/command/upload.py b/src/core/IronPython.StdLib/Lib/distutils/command/upload.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/upload.py rename to src/core/IronPython.StdLib/Lib/distutils/command/upload.py diff --git a/src/extensions/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe b/src/core/IronPython.StdLib/Lib/distutils/command/wininst-10.0-amd64.exe similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/wininst-10.0-amd64.exe rename to src/core/IronPython.StdLib/Lib/distutils/command/wininst-10.0-amd64.exe diff --git a/src/extensions/StdLib/Lib/distutils/command/wininst-10.0.exe b/src/core/IronPython.StdLib/Lib/distutils/command/wininst-10.0.exe similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/wininst-10.0.exe rename to src/core/IronPython.StdLib/Lib/distutils/command/wininst-10.0.exe diff --git a/src/extensions/StdLib/Lib/distutils/command/wininst-6.0.exe b/src/core/IronPython.StdLib/Lib/distutils/command/wininst-6.0.exe similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/wininst-6.0.exe rename to src/core/IronPython.StdLib/Lib/distutils/command/wininst-6.0.exe diff --git a/src/extensions/StdLib/Lib/distutils/command/wininst-7.1.exe b/src/core/IronPython.StdLib/Lib/distutils/command/wininst-7.1.exe similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/wininst-7.1.exe rename to src/core/IronPython.StdLib/Lib/distutils/command/wininst-7.1.exe diff --git a/src/extensions/StdLib/Lib/distutils/command/wininst-8.0.exe b/src/core/IronPython.StdLib/Lib/distutils/command/wininst-8.0.exe similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/wininst-8.0.exe rename to src/core/IronPython.StdLib/Lib/distutils/command/wininst-8.0.exe diff --git a/src/extensions/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe b/src/core/IronPython.StdLib/Lib/distutils/command/wininst-9.0-amd64.exe similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/wininst-9.0-amd64.exe rename to src/core/IronPython.StdLib/Lib/distutils/command/wininst-9.0-amd64.exe diff --git a/src/extensions/StdLib/Lib/distutils/command/wininst-9.0.exe b/src/core/IronPython.StdLib/Lib/distutils/command/wininst-9.0.exe similarity index 100% rename from src/extensions/StdLib/Lib/distutils/command/wininst-9.0.exe rename to src/core/IronPython.StdLib/Lib/distutils/command/wininst-9.0.exe diff --git a/src/extensions/StdLib/Lib/distutils/config.py b/src/core/IronPython.StdLib/Lib/distutils/config.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/config.py rename to src/core/IronPython.StdLib/Lib/distutils/config.py diff --git a/src/extensions/StdLib/Lib/distutils/core.py b/src/core/IronPython.StdLib/Lib/distutils/core.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/core.py rename to src/core/IronPython.StdLib/Lib/distutils/core.py diff --git a/src/extensions/StdLib/Lib/distutils/cygwinccompiler.py b/src/core/IronPython.StdLib/Lib/distutils/cygwinccompiler.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/cygwinccompiler.py rename to src/core/IronPython.StdLib/Lib/distutils/cygwinccompiler.py diff --git a/src/extensions/StdLib/Lib/distutils/debug.py b/src/core/IronPython.StdLib/Lib/distutils/debug.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/debug.py rename to src/core/IronPython.StdLib/Lib/distutils/debug.py diff --git a/src/extensions/StdLib/Lib/distutils/dep_util.py b/src/core/IronPython.StdLib/Lib/distutils/dep_util.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/dep_util.py rename to src/core/IronPython.StdLib/Lib/distutils/dep_util.py diff --git a/src/extensions/StdLib/Lib/distutils/dir_util.py b/src/core/IronPython.StdLib/Lib/distutils/dir_util.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/dir_util.py rename to src/core/IronPython.StdLib/Lib/distutils/dir_util.py diff --git a/src/extensions/StdLib/Lib/distutils/dist.py b/src/core/IronPython.StdLib/Lib/distutils/dist.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/dist.py rename to src/core/IronPython.StdLib/Lib/distutils/dist.py diff --git a/src/extensions/StdLib/Lib/distutils/errors.py b/src/core/IronPython.StdLib/Lib/distutils/errors.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/errors.py rename to src/core/IronPython.StdLib/Lib/distutils/errors.py diff --git a/src/extensions/StdLib/Lib/distutils/extension.py b/src/core/IronPython.StdLib/Lib/distutils/extension.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/extension.py rename to src/core/IronPython.StdLib/Lib/distutils/extension.py diff --git a/src/extensions/StdLib/Lib/distutils/fancy_getopt.py b/src/core/IronPython.StdLib/Lib/distutils/fancy_getopt.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/fancy_getopt.py rename to src/core/IronPython.StdLib/Lib/distutils/fancy_getopt.py diff --git a/src/extensions/StdLib/Lib/distutils/file_util.py b/src/core/IronPython.StdLib/Lib/distutils/file_util.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/file_util.py rename to src/core/IronPython.StdLib/Lib/distutils/file_util.py diff --git a/src/extensions/StdLib/Lib/distutils/filelist.py b/src/core/IronPython.StdLib/Lib/distutils/filelist.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/filelist.py rename to src/core/IronPython.StdLib/Lib/distutils/filelist.py diff --git a/src/extensions/StdLib/Lib/distutils/log.py b/src/core/IronPython.StdLib/Lib/distutils/log.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/log.py rename to src/core/IronPython.StdLib/Lib/distutils/log.py diff --git a/src/extensions/StdLib/Lib/distutils/msvc9compiler.py b/src/core/IronPython.StdLib/Lib/distutils/msvc9compiler.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/msvc9compiler.py rename to src/core/IronPython.StdLib/Lib/distutils/msvc9compiler.py diff --git a/src/extensions/StdLib/Lib/distutils/msvccompiler.py b/src/core/IronPython.StdLib/Lib/distutils/msvccompiler.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/msvccompiler.py rename to src/core/IronPython.StdLib/Lib/distutils/msvccompiler.py diff --git a/src/extensions/StdLib/Lib/distutils/spawn.py b/src/core/IronPython.StdLib/Lib/distutils/spawn.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/spawn.py rename to src/core/IronPython.StdLib/Lib/distutils/spawn.py diff --git a/src/extensions/StdLib/Lib/distutils/sysconfig.py b/src/core/IronPython.StdLib/Lib/distutils/sysconfig.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/sysconfig.py rename to src/core/IronPython.StdLib/Lib/distutils/sysconfig.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/Setup.sample b/src/core/IronPython.StdLib/Lib/distutils/tests/Setup.sample similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/Setup.sample rename to src/core/IronPython.StdLib/Lib/distutils/tests/Setup.sample diff --git a/src/extensions/StdLib/Lib/distutils/tests/__init__.py b/src/core/IronPython.StdLib/Lib/distutils/tests/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/__init__.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/__init__.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/support.py b/src/core/IronPython.StdLib/Lib/distutils/tests/support.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/support.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/support.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_archive_util.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_archive_util.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_archive_util.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_archive_util.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_bdist.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_bdist.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_bdist.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_bdist.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_bdist_dumb.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_bdist_dumb.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_bdist_dumb.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_bdist_dumb.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_bdist_msi.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_bdist_msi.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_bdist_msi.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_bdist_msi.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_bdist_rpm.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_bdist_rpm.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_bdist_rpm.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_bdist_rpm.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_bdist_wininst.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_bdist_wininst.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_bdist_wininst.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_bdist_wininst.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_build.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_build.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_build.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_build.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_build_clib.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_build_clib.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_build_clib.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_build_clib.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_build_ext.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_build_ext.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_build_ext.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_build_ext.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_build_py.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_build_py.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_build_py.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_build_py.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_build_scripts.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_build_scripts.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_build_scripts.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_build_scripts.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_check.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_check.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_check.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_check.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_clean.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_clean.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_clean.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_clean.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_cmd.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_cmd.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_cmd.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_cmd.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_config.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_config.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_config.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_config.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_config_cmd.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_config_cmd.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_config_cmd.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_config_cmd.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_core.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_core.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_core.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_core.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_cygwinccompiler.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_cygwinccompiler.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_cygwinccompiler.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_cygwinccompiler.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_dep_util.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_dep_util.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_dep_util.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_dep_util.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_dir_util.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_dir_util.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_dir_util.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_dir_util.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_dist.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_dist.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_dist.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_dist.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_extension.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_extension.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_extension.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_extension.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_file_util.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_file_util.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_file_util.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_file_util.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_filelist.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_filelist.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_filelist.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_filelist.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_install.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_install.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_install.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_install.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_install_data.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_install_data.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_install_data.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_install_data.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_install_headers.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_install_headers.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_install_headers.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_install_headers.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_install_lib.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_install_lib.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_install_lib.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_install_lib.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_install_scripts.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_install_scripts.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_install_scripts.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_install_scripts.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_log.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_log.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_log.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_log.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_msvc9compiler.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_msvc9compiler.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_msvc9compiler.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_msvc9compiler.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_register.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_register.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_register.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_register.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_sdist.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_sdist.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_sdist.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_sdist.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_spawn.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_spawn.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_spawn.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_spawn.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_sysconfig.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_sysconfig.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_sysconfig.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_sysconfig.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_text_file.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_text_file.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_text_file.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_text_file.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_unixccompiler.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_unixccompiler.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_unixccompiler.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_unixccompiler.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_upload.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_upload.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_upload.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_upload.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_util.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_util.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_util.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_util.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_version.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_version.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_version.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_version.py diff --git a/src/extensions/StdLib/Lib/distutils/tests/test_versionpredicate.py b/src/core/IronPython.StdLib/Lib/distutils/tests/test_versionpredicate.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/tests/test_versionpredicate.py rename to src/core/IronPython.StdLib/Lib/distutils/tests/test_versionpredicate.py diff --git a/src/extensions/StdLib/Lib/distutils/text_file.py b/src/core/IronPython.StdLib/Lib/distutils/text_file.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/text_file.py rename to src/core/IronPython.StdLib/Lib/distutils/text_file.py diff --git a/src/extensions/StdLib/Lib/distutils/unixccompiler.py b/src/core/IronPython.StdLib/Lib/distutils/unixccompiler.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/unixccompiler.py rename to src/core/IronPython.StdLib/Lib/distutils/unixccompiler.py diff --git a/src/extensions/StdLib/Lib/distutils/util.py b/src/core/IronPython.StdLib/Lib/distutils/util.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/util.py rename to src/core/IronPython.StdLib/Lib/distutils/util.py diff --git a/src/extensions/StdLib/Lib/distutils/version.py b/src/core/IronPython.StdLib/Lib/distutils/version.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/version.py rename to src/core/IronPython.StdLib/Lib/distutils/version.py diff --git a/src/extensions/StdLib/Lib/distutils/versionpredicate.py b/src/core/IronPython.StdLib/Lib/distutils/versionpredicate.py similarity index 100% rename from src/extensions/StdLib/Lib/distutils/versionpredicate.py rename to src/core/IronPython.StdLib/Lib/distutils/versionpredicate.py diff --git a/src/extensions/StdLib/Lib/doctest.py b/src/core/IronPython.StdLib/Lib/doctest.py similarity index 100% rename from src/extensions/StdLib/Lib/doctest.py rename to src/core/IronPython.StdLib/Lib/doctest.py diff --git a/src/extensions/StdLib/Lib/dummy_threading.py b/src/core/IronPython.StdLib/Lib/dummy_threading.py similarity index 100% rename from src/extensions/StdLib/Lib/dummy_threading.py rename to src/core/IronPython.StdLib/Lib/dummy_threading.py diff --git a/src/extensions/StdLib/Lib/email/__init__.py b/src/core/IronPython.StdLib/Lib/email/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/email/__init__.py rename to src/core/IronPython.StdLib/Lib/email/__init__.py diff --git a/src/extensions/StdLib/Lib/email/_encoded_words.py b/src/core/IronPython.StdLib/Lib/email/_encoded_words.py similarity index 100% rename from src/extensions/StdLib/Lib/email/_encoded_words.py rename to src/core/IronPython.StdLib/Lib/email/_encoded_words.py diff --git a/src/extensions/StdLib/Lib/email/_header_value_parser.py b/src/core/IronPython.StdLib/Lib/email/_header_value_parser.py similarity index 100% rename from src/extensions/StdLib/Lib/email/_header_value_parser.py rename to src/core/IronPython.StdLib/Lib/email/_header_value_parser.py diff --git a/src/extensions/StdLib/Lib/email/_parseaddr.py b/src/core/IronPython.StdLib/Lib/email/_parseaddr.py similarity index 100% rename from src/extensions/StdLib/Lib/email/_parseaddr.py rename to src/core/IronPython.StdLib/Lib/email/_parseaddr.py diff --git a/src/extensions/StdLib/Lib/email/_policybase.py b/src/core/IronPython.StdLib/Lib/email/_policybase.py similarity index 100% rename from src/extensions/StdLib/Lib/email/_policybase.py rename to src/core/IronPython.StdLib/Lib/email/_policybase.py diff --git a/src/extensions/StdLib/Lib/email/architecture.rst b/src/core/IronPython.StdLib/Lib/email/architecture.rst similarity index 100% rename from src/extensions/StdLib/Lib/email/architecture.rst rename to src/core/IronPython.StdLib/Lib/email/architecture.rst diff --git a/src/extensions/StdLib/Lib/email/base64mime.py b/src/core/IronPython.StdLib/Lib/email/base64mime.py similarity index 100% rename from src/extensions/StdLib/Lib/email/base64mime.py rename to src/core/IronPython.StdLib/Lib/email/base64mime.py diff --git a/src/extensions/StdLib/Lib/email/charset.py b/src/core/IronPython.StdLib/Lib/email/charset.py similarity index 100% rename from src/extensions/StdLib/Lib/email/charset.py rename to src/core/IronPython.StdLib/Lib/email/charset.py diff --git a/src/extensions/StdLib/Lib/email/contentmanager.py b/src/core/IronPython.StdLib/Lib/email/contentmanager.py similarity index 100% rename from src/extensions/StdLib/Lib/email/contentmanager.py rename to src/core/IronPython.StdLib/Lib/email/contentmanager.py diff --git a/src/extensions/StdLib/Lib/email/encoders.py b/src/core/IronPython.StdLib/Lib/email/encoders.py similarity index 100% rename from src/extensions/StdLib/Lib/email/encoders.py rename to src/core/IronPython.StdLib/Lib/email/encoders.py diff --git a/src/extensions/StdLib/Lib/email/errors.py b/src/core/IronPython.StdLib/Lib/email/errors.py similarity index 100% rename from src/extensions/StdLib/Lib/email/errors.py rename to src/core/IronPython.StdLib/Lib/email/errors.py diff --git a/src/extensions/StdLib/Lib/email/feedparser.py b/src/core/IronPython.StdLib/Lib/email/feedparser.py similarity index 100% rename from src/extensions/StdLib/Lib/email/feedparser.py rename to src/core/IronPython.StdLib/Lib/email/feedparser.py diff --git a/src/extensions/StdLib/Lib/email/generator.py b/src/core/IronPython.StdLib/Lib/email/generator.py similarity index 100% rename from src/extensions/StdLib/Lib/email/generator.py rename to src/core/IronPython.StdLib/Lib/email/generator.py diff --git a/src/extensions/StdLib/Lib/email/header.py b/src/core/IronPython.StdLib/Lib/email/header.py similarity index 100% rename from src/extensions/StdLib/Lib/email/header.py rename to src/core/IronPython.StdLib/Lib/email/header.py diff --git a/src/extensions/StdLib/Lib/email/headerregistry.py b/src/core/IronPython.StdLib/Lib/email/headerregistry.py similarity index 100% rename from src/extensions/StdLib/Lib/email/headerregistry.py rename to src/core/IronPython.StdLib/Lib/email/headerregistry.py diff --git a/src/extensions/StdLib/Lib/email/iterators.py b/src/core/IronPython.StdLib/Lib/email/iterators.py similarity index 100% rename from src/extensions/StdLib/Lib/email/iterators.py rename to src/core/IronPython.StdLib/Lib/email/iterators.py diff --git a/src/extensions/StdLib/Lib/email/message.py b/src/core/IronPython.StdLib/Lib/email/message.py similarity index 100% rename from src/extensions/StdLib/Lib/email/message.py rename to src/core/IronPython.StdLib/Lib/email/message.py diff --git a/src/extensions/StdLib/Lib/email/mime/__init__.py b/src/core/IronPython.StdLib/Lib/email/mime/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/email/mime/__init__.py rename to src/core/IronPython.StdLib/Lib/email/mime/__init__.py diff --git a/src/extensions/StdLib/Lib/email/mime/application.py b/src/core/IronPython.StdLib/Lib/email/mime/application.py similarity index 100% rename from src/extensions/StdLib/Lib/email/mime/application.py rename to src/core/IronPython.StdLib/Lib/email/mime/application.py diff --git a/src/extensions/StdLib/Lib/email/mime/audio.py b/src/core/IronPython.StdLib/Lib/email/mime/audio.py similarity index 100% rename from src/extensions/StdLib/Lib/email/mime/audio.py rename to src/core/IronPython.StdLib/Lib/email/mime/audio.py diff --git a/src/extensions/StdLib/Lib/email/mime/base.py b/src/core/IronPython.StdLib/Lib/email/mime/base.py similarity index 100% rename from src/extensions/StdLib/Lib/email/mime/base.py rename to src/core/IronPython.StdLib/Lib/email/mime/base.py diff --git a/src/extensions/StdLib/Lib/email/mime/image.py b/src/core/IronPython.StdLib/Lib/email/mime/image.py similarity index 100% rename from src/extensions/StdLib/Lib/email/mime/image.py rename to src/core/IronPython.StdLib/Lib/email/mime/image.py diff --git a/src/extensions/StdLib/Lib/email/mime/message.py b/src/core/IronPython.StdLib/Lib/email/mime/message.py similarity index 100% rename from src/extensions/StdLib/Lib/email/mime/message.py rename to src/core/IronPython.StdLib/Lib/email/mime/message.py diff --git a/src/extensions/StdLib/Lib/email/mime/multipart.py b/src/core/IronPython.StdLib/Lib/email/mime/multipart.py similarity index 100% rename from src/extensions/StdLib/Lib/email/mime/multipart.py rename to src/core/IronPython.StdLib/Lib/email/mime/multipart.py diff --git a/src/extensions/StdLib/Lib/email/mime/nonmultipart.py b/src/core/IronPython.StdLib/Lib/email/mime/nonmultipart.py similarity index 100% rename from src/extensions/StdLib/Lib/email/mime/nonmultipart.py rename to src/core/IronPython.StdLib/Lib/email/mime/nonmultipart.py diff --git a/src/extensions/StdLib/Lib/email/mime/text.py b/src/core/IronPython.StdLib/Lib/email/mime/text.py similarity index 100% rename from src/extensions/StdLib/Lib/email/mime/text.py rename to src/core/IronPython.StdLib/Lib/email/mime/text.py diff --git a/src/extensions/StdLib/Lib/email/parser.py b/src/core/IronPython.StdLib/Lib/email/parser.py similarity index 100% rename from src/extensions/StdLib/Lib/email/parser.py rename to src/core/IronPython.StdLib/Lib/email/parser.py diff --git a/src/extensions/StdLib/Lib/email/policy.py b/src/core/IronPython.StdLib/Lib/email/policy.py similarity index 100% rename from src/extensions/StdLib/Lib/email/policy.py rename to src/core/IronPython.StdLib/Lib/email/policy.py diff --git a/src/extensions/StdLib/Lib/email/quoprimime.py b/src/core/IronPython.StdLib/Lib/email/quoprimime.py similarity index 100% rename from src/extensions/StdLib/Lib/email/quoprimime.py rename to src/core/IronPython.StdLib/Lib/email/quoprimime.py diff --git a/src/extensions/StdLib/Lib/email/utils.py b/src/core/IronPython.StdLib/Lib/email/utils.py similarity index 100% rename from src/extensions/StdLib/Lib/email/utils.py rename to src/core/IronPython.StdLib/Lib/email/utils.py diff --git a/src/extensions/StdLib/Lib/encodings/__init__.py b/src/core/IronPython.StdLib/Lib/encodings/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/__init__.py rename to src/core/IronPython.StdLib/Lib/encodings/__init__.py diff --git a/src/extensions/StdLib/Lib/encodings/aliases.py b/src/core/IronPython.StdLib/Lib/encodings/aliases.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/aliases.py rename to src/core/IronPython.StdLib/Lib/encodings/aliases.py diff --git a/src/extensions/StdLib/Lib/encodings/ascii.py b/src/core/IronPython.StdLib/Lib/encodings/ascii.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/ascii.py rename to src/core/IronPython.StdLib/Lib/encodings/ascii.py diff --git a/src/extensions/StdLib/Lib/encodings/base64_codec.py b/src/core/IronPython.StdLib/Lib/encodings/base64_codec.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/base64_codec.py rename to src/core/IronPython.StdLib/Lib/encodings/base64_codec.py diff --git a/src/extensions/StdLib/Lib/encodings/big5.py b/src/core/IronPython.StdLib/Lib/encodings/big5.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/big5.py rename to src/core/IronPython.StdLib/Lib/encodings/big5.py diff --git a/src/extensions/StdLib/Lib/encodings/big5hkscs.py b/src/core/IronPython.StdLib/Lib/encodings/big5hkscs.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/big5hkscs.py rename to src/core/IronPython.StdLib/Lib/encodings/big5hkscs.py diff --git a/src/extensions/StdLib/Lib/encodings/bz2_codec.py b/src/core/IronPython.StdLib/Lib/encodings/bz2_codec.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/bz2_codec.py rename to src/core/IronPython.StdLib/Lib/encodings/bz2_codec.py diff --git a/src/extensions/StdLib/Lib/encodings/charmap.py b/src/core/IronPython.StdLib/Lib/encodings/charmap.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/charmap.py rename to src/core/IronPython.StdLib/Lib/encodings/charmap.py diff --git a/src/extensions/StdLib/Lib/encodings/cp037.py b/src/core/IronPython.StdLib/Lib/encodings/cp037.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp037.py rename to src/core/IronPython.StdLib/Lib/encodings/cp037.py diff --git a/src/extensions/StdLib/Lib/encodings/cp1006.py b/src/core/IronPython.StdLib/Lib/encodings/cp1006.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp1006.py rename to src/core/IronPython.StdLib/Lib/encodings/cp1006.py diff --git a/src/extensions/StdLib/Lib/encodings/cp1026.py b/src/core/IronPython.StdLib/Lib/encodings/cp1026.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp1026.py rename to src/core/IronPython.StdLib/Lib/encodings/cp1026.py diff --git a/src/extensions/StdLib/Lib/encodings/cp1125.py b/src/core/IronPython.StdLib/Lib/encodings/cp1125.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp1125.py rename to src/core/IronPython.StdLib/Lib/encodings/cp1125.py diff --git a/src/extensions/StdLib/Lib/encodings/cp1140.py b/src/core/IronPython.StdLib/Lib/encodings/cp1140.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp1140.py rename to src/core/IronPython.StdLib/Lib/encodings/cp1140.py diff --git a/src/extensions/StdLib/Lib/encodings/cp1250.py b/src/core/IronPython.StdLib/Lib/encodings/cp1250.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp1250.py rename to src/core/IronPython.StdLib/Lib/encodings/cp1250.py diff --git a/src/extensions/StdLib/Lib/encodings/cp1251.py b/src/core/IronPython.StdLib/Lib/encodings/cp1251.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp1251.py rename to src/core/IronPython.StdLib/Lib/encodings/cp1251.py diff --git a/src/extensions/StdLib/Lib/encodings/cp1252.py b/src/core/IronPython.StdLib/Lib/encodings/cp1252.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp1252.py rename to src/core/IronPython.StdLib/Lib/encodings/cp1252.py diff --git a/src/extensions/StdLib/Lib/encodings/cp1253.py b/src/core/IronPython.StdLib/Lib/encodings/cp1253.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp1253.py rename to src/core/IronPython.StdLib/Lib/encodings/cp1253.py diff --git a/src/extensions/StdLib/Lib/encodings/cp1254.py b/src/core/IronPython.StdLib/Lib/encodings/cp1254.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp1254.py rename to src/core/IronPython.StdLib/Lib/encodings/cp1254.py diff --git a/src/extensions/StdLib/Lib/encodings/cp1255.py b/src/core/IronPython.StdLib/Lib/encodings/cp1255.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp1255.py rename to src/core/IronPython.StdLib/Lib/encodings/cp1255.py diff --git a/src/extensions/StdLib/Lib/encodings/cp1256.py b/src/core/IronPython.StdLib/Lib/encodings/cp1256.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp1256.py rename to src/core/IronPython.StdLib/Lib/encodings/cp1256.py diff --git a/src/extensions/StdLib/Lib/encodings/cp1257.py b/src/core/IronPython.StdLib/Lib/encodings/cp1257.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp1257.py rename to src/core/IronPython.StdLib/Lib/encodings/cp1257.py diff --git a/src/extensions/StdLib/Lib/encodings/cp1258.py b/src/core/IronPython.StdLib/Lib/encodings/cp1258.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp1258.py rename to src/core/IronPython.StdLib/Lib/encodings/cp1258.py diff --git a/src/extensions/StdLib/Lib/encodings/cp273.py b/src/core/IronPython.StdLib/Lib/encodings/cp273.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp273.py rename to src/core/IronPython.StdLib/Lib/encodings/cp273.py diff --git a/src/extensions/StdLib/Lib/encodings/cp424.py b/src/core/IronPython.StdLib/Lib/encodings/cp424.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp424.py rename to src/core/IronPython.StdLib/Lib/encodings/cp424.py diff --git a/src/extensions/StdLib/Lib/encodings/cp437.py b/src/core/IronPython.StdLib/Lib/encodings/cp437.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp437.py rename to src/core/IronPython.StdLib/Lib/encodings/cp437.py diff --git a/src/extensions/StdLib/Lib/encodings/cp500.py b/src/core/IronPython.StdLib/Lib/encodings/cp500.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp500.py rename to src/core/IronPython.StdLib/Lib/encodings/cp500.py diff --git a/src/extensions/StdLib/Lib/encodings/cp65001.py b/src/core/IronPython.StdLib/Lib/encodings/cp65001.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp65001.py rename to src/core/IronPython.StdLib/Lib/encodings/cp65001.py diff --git a/src/extensions/StdLib/Lib/encodings/cp720.py b/src/core/IronPython.StdLib/Lib/encodings/cp720.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp720.py rename to src/core/IronPython.StdLib/Lib/encodings/cp720.py diff --git a/src/extensions/StdLib/Lib/encodings/cp737.py b/src/core/IronPython.StdLib/Lib/encodings/cp737.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp737.py rename to src/core/IronPython.StdLib/Lib/encodings/cp737.py diff --git a/src/extensions/StdLib/Lib/encodings/cp775.py b/src/core/IronPython.StdLib/Lib/encodings/cp775.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp775.py rename to src/core/IronPython.StdLib/Lib/encodings/cp775.py diff --git a/src/extensions/StdLib/Lib/encodings/cp850.py b/src/core/IronPython.StdLib/Lib/encodings/cp850.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp850.py rename to src/core/IronPython.StdLib/Lib/encodings/cp850.py diff --git a/src/extensions/StdLib/Lib/encodings/cp852.py b/src/core/IronPython.StdLib/Lib/encodings/cp852.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp852.py rename to src/core/IronPython.StdLib/Lib/encodings/cp852.py diff --git a/src/extensions/StdLib/Lib/encodings/cp855.py b/src/core/IronPython.StdLib/Lib/encodings/cp855.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp855.py rename to src/core/IronPython.StdLib/Lib/encodings/cp855.py diff --git a/src/extensions/StdLib/Lib/encodings/cp856.py b/src/core/IronPython.StdLib/Lib/encodings/cp856.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp856.py rename to src/core/IronPython.StdLib/Lib/encodings/cp856.py diff --git a/src/extensions/StdLib/Lib/encodings/cp857.py b/src/core/IronPython.StdLib/Lib/encodings/cp857.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp857.py rename to src/core/IronPython.StdLib/Lib/encodings/cp857.py diff --git a/src/extensions/StdLib/Lib/encodings/cp858.py b/src/core/IronPython.StdLib/Lib/encodings/cp858.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp858.py rename to src/core/IronPython.StdLib/Lib/encodings/cp858.py diff --git a/src/extensions/StdLib/Lib/encodings/cp860.py b/src/core/IronPython.StdLib/Lib/encodings/cp860.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp860.py rename to src/core/IronPython.StdLib/Lib/encodings/cp860.py diff --git a/src/extensions/StdLib/Lib/encodings/cp861.py b/src/core/IronPython.StdLib/Lib/encodings/cp861.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp861.py rename to src/core/IronPython.StdLib/Lib/encodings/cp861.py diff --git a/src/extensions/StdLib/Lib/encodings/cp862.py b/src/core/IronPython.StdLib/Lib/encodings/cp862.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp862.py rename to src/core/IronPython.StdLib/Lib/encodings/cp862.py diff --git a/src/extensions/StdLib/Lib/encodings/cp863.py b/src/core/IronPython.StdLib/Lib/encodings/cp863.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp863.py rename to src/core/IronPython.StdLib/Lib/encodings/cp863.py diff --git a/src/extensions/StdLib/Lib/encodings/cp864.py b/src/core/IronPython.StdLib/Lib/encodings/cp864.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp864.py rename to src/core/IronPython.StdLib/Lib/encodings/cp864.py diff --git a/src/extensions/StdLib/Lib/encodings/cp865.py b/src/core/IronPython.StdLib/Lib/encodings/cp865.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp865.py rename to src/core/IronPython.StdLib/Lib/encodings/cp865.py diff --git a/src/extensions/StdLib/Lib/encodings/cp866.py b/src/core/IronPython.StdLib/Lib/encodings/cp866.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp866.py rename to src/core/IronPython.StdLib/Lib/encodings/cp866.py diff --git a/src/extensions/StdLib/Lib/encodings/cp869.py b/src/core/IronPython.StdLib/Lib/encodings/cp869.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp869.py rename to src/core/IronPython.StdLib/Lib/encodings/cp869.py diff --git a/src/extensions/StdLib/Lib/encodings/cp874.py b/src/core/IronPython.StdLib/Lib/encodings/cp874.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp874.py rename to src/core/IronPython.StdLib/Lib/encodings/cp874.py diff --git a/src/extensions/StdLib/Lib/encodings/cp875.py b/src/core/IronPython.StdLib/Lib/encodings/cp875.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp875.py rename to src/core/IronPython.StdLib/Lib/encodings/cp875.py diff --git a/src/extensions/StdLib/Lib/encodings/cp932.py b/src/core/IronPython.StdLib/Lib/encodings/cp932.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp932.py rename to src/core/IronPython.StdLib/Lib/encodings/cp932.py diff --git a/src/extensions/StdLib/Lib/encodings/cp949.py b/src/core/IronPython.StdLib/Lib/encodings/cp949.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp949.py rename to src/core/IronPython.StdLib/Lib/encodings/cp949.py diff --git a/src/extensions/StdLib/Lib/encodings/cp950.py b/src/core/IronPython.StdLib/Lib/encodings/cp950.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/cp950.py rename to src/core/IronPython.StdLib/Lib/encodings/cp950.py diff --git a/src/extensions/StdLib/Lib/encodings/euc_jis_2004.py b/src/core/IronPython.StdLib/Lib/encodings/euc_jis_2004.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/euc_jis_2004.py rename to src/core/IronPython.StdLib/Lib/encodings/euc_jis_2004.py diff --git a/src/extensions/StdLib/Lib/encodings/euc_jisx0213.py b/src/core/IronPython.StdLib/Lib/encodings/euc_jisx0213.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/euc_jisx0213.py rename to src/core/IronPython.StdLib/Lib/encodings/euc_jisx0213.py diff --git a/src/extensions/StdLib/Lib/encodings/euc_jp.py b/src/core/IronPython.StdLib/Lib/encodings/euc_jp.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/euc_jp.py rename to src/core/IronPython.StdLib/Lib/encodings/euc_jp.py diff --git a/src/extensions/StdLib/Lib/encodings/euc_kr.py b/src/core/IronPython.StdLib/Lib/encodings/euc_kr.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/euc_kr.py rename to src/core/IronPython.StdLib/Lib/encodings/euc_kr.py diff --git a/src/extensions/StdLib/Lib/encodings/gb18030.py b/src/core/IronPython.StdLib/Lib/encodings/gb18030.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/gb18030.py rename to src/core/IronPython.StdLib/Lib/encodings/gb18030.py diff --git a/src/extensions/StdLib/Lib/encodings/gb2312.py b/src/core/IronPython.StdLib/Lib/encodings/gb2312.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/gb2312.py rename to src/core/IronPython.StdLib/Lib/encodings/gb2312.py diff --git a/src/extensions/StdLib/Lib/encodings/gbk.py b/src/core/IronPython.StdLib/Lib/encodings/gbk.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/gbk.py rename to src/core/IronPython.StdLib/Lib/encodings/gbk.py diff --git a/src/extensions/StdLib/Lib/encodings/hex_codec.py b/src/core/IronPython.StdLib/Lib/encodings/hex_codec.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/hex_codec.py rename to src/core/IronPython.StdLib/Lib/encodings/hex_codec.py diff --git a/src/extensions/StdLib/Lib/encodings/hp_roman8.py b/src/core/IronPython.StdLib/Lib/encodings/hp_roman8.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/hp_roman8.py rename to src/core/IronPython.StdLib/Lib/encodings/hp_roman8.py diff --git a/src/extensions/StdLib/Lib/encodings/hz.py b/src/core/IronPython.StdLib/Lib/encodings/hz.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/hz.py rename to src/core/IronPython.StdLib/Lib/encodings/hz.py diff --git a/src/extensions/StdLib/Lib/encodings/idna.py b/src/core/IronPython.StdLib/Lib/encodings/idna.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/idna.py rename to src/core/IronPython.StdLib/Lib/encodings/idna.py diff --git a/src/extensions/StdLib/Lib/encodings/iso2022_jp.py b/src/core/IronPython.StdLib/Lib/encodings/iso2022_jp.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso2022_jp.py rename to src/core/IronPython.StdLib/Lib/encodings/iso2022_jp.py diff --git a/src/extensions/StdLib/Lib/encodings/iso2022_jp_1.py b/src/core/IronPython.StdLib/Lib/encodings/iso2022_jp_1.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso2022_jp_1.py rename to src/core/IronPython.StdLib/Lib/encodings/iso2022_jp_1.py diff --git a/src/extensions/StdLib/Lib/encodings/iso2022_jp_2.py b/src/core/IronPython.StdLib/Lib/encodings/iso2022_jp_2.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso2022_jp_2.py rename to src/core/IronPython.StdLib/Lib/encodings/iso2022_jp_2.py diff --git a/src/extensions/StdLib/Lib/encodings/iso2022_jp_2004.py b/src/core/IronPython.StdLib/Lib/encodings/iso2022_jp_2004.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso2022_jp_2004.py rename to src/core/IronPython.StdLib/Lib/encodings/iso2022_jp_2004.py diff --git a/src/extensions/StdLib/Lib/encodings/iso2022_jp_3.py b/src/core/IronPython.StdLib/Lib/encodings/iso2022_jp_3.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso2022_jp_3.py rename to src/core/IronPython.StdLib/Lib/encodings/iso2022_jp_3.py diff --git a/src/extensions/StdLib/Lib/encodings/iso2022_jp_ext.py b/src/core/IronPython.StdLib/Lib/encodings/iso2022_jp_ext.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso2022_jp_ext.py rename to src/core/IronPython.StdLib/Lib/encodings/iso2022_jp_ext.py diff --git a/src/extensions/StdLib/Lib/encodings/iso2022_kr.py b/src/core/IronPython.StdLib/Lib/encodings/iso2022_kr.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso2022_kr.py rename to src/core/IronPython.StdLib/Lib/encodings/iso2022_kr.py diff --git a/src/extensions/StdLib/Lib/encodings/iso8859_1.py b/src/core/IronPython.StdLib/Lib/encodings/iso8859_1.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso8859_1.py rename to src/core/IronPython.StdLib/Lib/encodings/iso8859_1.py diff --git a/src/extensions/StdLib/Lib/encodings/iso8859_10.py b/src/core/IronPython.StdLib/Lib/encodings/iso8859_10.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso8859_10.py rename to src/core/IronPython.StdLib/Lib/encodings/iso8859_10.py diff --git a/src/extensions/StdLib/Lib/encodings/iso8859_11.py b/src/core/IronPython.StdLib/Lib/encodings/iso8859_11.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso8859_11.py rename to src/core/IronPython.StdLib/Lib/encodings/iso8859_11.py diff --git a/src/extensions/StdLib/Lib/encodings/iso8859_13.py b/src/core/IronPython.StdLib/Lib/encodings/iso8859_13.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso8859_13.py rename to src/core/IronPython.StdLib/Lib/encodings/iso8859_13.py diff --git a/src/extensions/StdLib/Lib/encodings/iso8859_14.py b/src/core/IronPython.StdLib/Lib/encodings/iso8859_14.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso8859_14.py rename to src/core/IronPython.StdLib/Lib/encodings/iso8859_14.py diff --git a/src/extensions/StdLib/Lib/encodings/iso8859_15.py b/src/core/IronPython.StdLib/Lib/encodings/iso8859_15.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso8859_15.py rename to src/core/IronPython.StdLib/Lib/encodings/iso8859_15.py diff --git a/src/extensions/StdLib/Lib/encodings/iso8859_16.py b/src/core/IronPython.StdLib/Lib/encodings/iso8859_16.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso8859_16.py rename to src/core/IronPython.StdLib/Lib/encodings/iso8859_16.py diff --git a/src/extensions/StdLib/Lib/encodings/iso8859_2.py b/src/core/IronPython.StdLib/Lib/encodings/iso8859_2.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso8859_2.py rename to src/core/IronPython.StdLib/Lib/encodings/iso8859_2.py diff --git a/src/extensions/StdLib/Lib/encodings/iso8859_3.py b/src/core/IronPython.StdLib/Lib/encodings/iso8859_3.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso8859_3.py rename to src/core/IronPython.StdLib/Lib/encodings/iso8859_3.py diff --git a/src/extensions/StdLib/Lib/encodings/iso8859_4.py b/src/core/IronPython.StdLib/Lib/encodings/iso8859_4.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso8859_4.py rename to src/core/IronPython.StdLib/Lib/encodings/iso8859_4.py diff --git a/src/extensions/StdLib/Lib/encodings/iso8859_5.py b/src/core/IronPython.StdLib/Lib/encodings/iso8859_5.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso8859_5.py rename to src/core/IronPython.StdLib/Lib/encodings/iso8859_5.py diff --git a/src/extensions/StdLib/Lib/encodings/iso8859_6.py b/src/core/IronPython.StdLib/Lib/encodings/iso8859_6.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso8859_6.py rename to src/core/IronPython.StdLib/Lib/encodings/iso8859_6.py diff --git a/src/extensions/StdLib/Lib/encodings/iso8859_7.py b/src/core/IronPython.StdLib/Lib/encodings/iso8859_7.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso8859_7.py rename to src/core/IronPython.StdLib/Lib/encodings/iso8859_7.py diff --git a/src/extensions/StdLib/Lib/encodings/iso8859_8.py b/src/core/IronPython.StdLib/Lib/encodings/iso8859_8.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso8859_8.py rename to src/core/IronPython.StdLib/Lib/encodings/iso8859_8.py diff --git a/src/extensions/StdLib/Lib/encodings/iso8859_9.py b/src/core/IronPython.StdLib/Lib/encodings/iso8859_9.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/iso8859_9.py rename to src/core/IronPython.StdLib/Lib/encodings/iso8859_9.py diff --git a/src/extensions/StdLib/Lib/encodings/johab.py b/src/core/IronPython.StdLib/Lib/encodings/johab.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/johab.py rename to src/core/IronPython.StdLib/Lib/encodings/johab.py diff --git a/src/extensions/StdLib/Lib/encodings/koi8_r.py b/src/core/IronPython.StdLib/Lib/encodings/koi8_r.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/koi8_r.py rename to src/core/IronPython.StdLib/Lib/encodings/koi8_r.py diff --git a/src/extensions/StdLib/Lib/encodings/koi8_u.py b/src/core/IronPython.StdLib/Lib/encodings/koi8_u.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/koi8_u.py rename to src/core/IronPython.StdLib/Lib/encodings/koi8_u.py diff --git a/src/extensions/StdLib/Lib/encodings/latin_1.py b/src/core/IronPython.StdLib/Lib/encodings/latin_1.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/latin_1.py rename to src/core/IronPython.StdLib/Lib/encodings/latin_1.py diff --git a/src/extensions/StdLib/Lib/encodings/mac_arabic.py b/src/core/IronPython.StdLib/Lib/encodings/mac_arabic.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/mac_arabic.py rename to src/core/IronPython.StdLib/Lib/encodings/mac_arabic.py diff --git a/src/extensions/StdLib/Lib/encodings/mac_centeuro.py b/src/core/IronPython.StdLib/Lib/encodings/mac_centeuro.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/mac_centeuro.py rename to src/core/IronPython.StdLib/Lib/encodings/mac_centeuro.py diff --git a/src/extensions/StdLib/Lib/encodings/mac_croatian.py b/src/core/IronPython.StdLib/Lib/encodings/mac_croatian.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/mac_croatian.py rename to src/core/IronPython.StdLib/Lib/encodings/mac_croatian.py diff --git a/src/extensions/StdLib/Lib/encodings/mac_cyrillic.py b/src/core/IronPython.StdLib/Lib/encodings/mac_cyrillic.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/mac_cyrillic.py rename to src/core/IronPython.StdLib/Lib/encodings/mac_cyrillic.py diff --git a/src/extensions/StdLib/Lib/encodings/mac_farsi.py b/src/core/IronPython.StdLib/Lib/encodings/mac_farsi.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/mac_farsi.py rename to src/core/IronPython.StdLib/Lib/encodings/mac_farsi.py diff --git a/src/extensions/StdLib/Lib/encodings/mac_greek.py b/src/core/IronPython.StdLib/Lib/encodings/mac_greek.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/mac_greek.py rename to src/core/IronPython.StdLib/Lib/encodings/mac_greek.py diff --git a/src/extensions/StdLib/Lib/encodings/mac_iceland.py b/src/core/IronPython.StdLib/Lib/encodings/mac_iceland.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/mac_iceland.py rename to src/core/IronPython.StdLib/Lib/encodings/mac_iceland.py diff --git a/src/extensions/StdLib/Lib/encodings/mac_latin2.py b/src/core/IronPython.StdLib/Lib/encodings/mac_latin2.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/mac_latin2.py rename to src/core/IronPython.StdLib/Lib/encodings/mac_latin2.py diff --git a/src/extensions/StdLib/Lib/encodings/mac_roman.py b/src/core/IronPython.StdLib/Lib/encodings/mac_roman.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/mac_roman.py rename to src/core/IronPython.StdLib/Lib/encodings/mac_roman.py diff --git a/src/extensions/StdLib/Lib/encodings/mac_romanian.py b/src/core/IronPython.StdLib/Lib/encodings/mac_romanian.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/mac_romanian.py rename to src/core/IronPython.StdLib/Lib/encodings/mac_romanian.py diff --git a/src/extensions/StdLib/Lib/encodings/mac_turkish.py b/src/core/IronPython.StdLib/Lib/encodings/mac_turkish.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/mac_turkish.py rename to src/core/IronPython.StdLib/Lib/encodings/mac_turkish.py diff --git a/src/extensions/StdLib/Lib/encodings/mbcs.py b/src/core/IronPython.StdLib/Lib/encodings/mbcs.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/mbcs.py rename to src/core/IronPython.StdLib/Lib/encodings/mbcs.py diff --git a/src/extensions/StdLib/Lib/encodings/palmos.py b/src/core/IronPython.StdLib/Lib/encodings/palmos.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/palmos.py rename to src/core/IronPython.StdLib/Lib/encodings/palmos.py diff --git a/src/extensions/StdLib/Lib/encodings/ptcp154.py b/src/core/IronPython.StdLib/Lib/encodings/ptcp154.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/ptcp154.py rename to src/core/IronPython.StdLib/Lib/encodings/ptcp154.py diff --git a/src/extensions/StdLib/Lib/encodings/punycode.py b/src/core/IronPython.StdLib/Lib/encodings/punycode.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/punycode.py rename to src/core/IronPython.StdLib/Lib/encodings/punycode.py diff --git a/src/extensions/StdLib/Lib/encodings/quopri_codec.py b/src/core/IronPython.StdLib/Lib/encodings/quopri_codec.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/quopri_codec.py rename to src/core/IronPython.StdLib/Lib/encodings/quopri_codec.py diff --git a/src/extensions/StdLib/Lib/encodings/raw_unicode_escape.py b/src/core/IronPython.StdLib/Lib/encodings/raw_unicode_escape.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/raw_unicode_escape.py rename to src/core/IronPython.StdLib/Lib/encodings/raw_unicode_escape.py diff --git a/src/extensions/StdLib/Lib/encodings/rot_13.py b/src/core/IronPython.StdLib/Lib/encodings/rot_13.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/rot_13.py rename to src/core/IronPython.StdLib/Lib/encodings/rot_13.py diff --git a/src/extensions/StdLib/Lib/encodings/shift_jis.py b/src/core/IronPython.StdLib/Lib/encodings/shift_jis.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/shift_jis.py rename to src/core/IronPython.StdLib/Lib/encodings/shift_jis.py diff --git a/src/extensions/StdLib/Lib/encodings/shift_jis_2004.py b/src/core/IronPython.StdLib/Lib/encodings/shift_jis_2004.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/shift_jis_2004.py rename to src/core/IronPython.StdLib/Lib/encodings/shift_jis_2004.py diff --git a/src/extensions/StdLib/Lib/encodings/shift_jisx0213.py b/src/core/IronPython.StdLib/Lib/encodings/shift_jisx0213.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/shift_jisx0213.py rename to src/core/IronPython.StdLib/Lib/encodings/shift_jisx0213.py diff --git a/src/extensions/StdLib/Lib/encodings/tis_620.py b/src/core/IronPython.StdLib/Lib/encodings/tis_620.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/tis_620.py rename to src/core/IronPython.StdLib/Lib/encodings/tis_620.py diff --git a/src/extensions/StdLib/Lib/encodings/undefined.py b/src/core/IronPython.StdLib/Lib/encodings/undefined.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/undefined.py rename to src/core/IronPython.StdLib/Lib/encodings/undefined.py diff --git a/src/extensions/StdLib/Lib/encodings/unicode_escape.py b/src/core/IronPython.StdLib/Lib/encodings/unicode_escape.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/unicode_escape.py rename to src/core/IronPython.StdLib/Lib/encodings/unicode_escape.py diff --git a/src/extensions/StdLib/Lib/encodings/unicode_internal.py b/src/core/IronPython.StdLib/Lib/encodings/unicode_internal.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/unicode_internal.py rename to src/core/IronPython.StdLib/Lib/encodings/unicode_internal.py diff --git a/src/extensions/StdLib/Lib/encodings/utf_16.py b/src/core/IronPython.StdLib/Lib/encodings/utf_16.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/utf_16.py rename to src/core/IronPython.StdLib/Lib/encodings/utf_16.py diff --git a/src/extensions/StdLib/Lib/encodings/utf_16_be.py b/src/core/IronPython.StdLib/Lib/encodings/utf_16_be.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/utf_16_be.py rename to src/core/IronPython.StdLib/Lib/encodings/utf_16_be.py diff --git a/src/extensions/StdLib/Lib/encodings/utf_16_le.py b/src/core/IronPython.StdLib/Lib/encodings/utf_16_le.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/utf_16_le.py rename to src/core/IronPython.StdLib/Lib/encodings/utf_16_le.py diff --git a/src/extensions/StdLib/Lib/encodings/utf_32.py b/src/core/IronPython.StdLib/Lib/encodings/utf_32.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/utf_32.py rename to src/core/IronPython.StdLib/Lib/encodings/utf_32.py diff --git a/src/extensions/StdLib/Lib/encodings/utf_32_be.py b/src/core/IronPython.StdLib/Lib/encodings/utf_32_be.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/utf_32_be.py rename to src/core/IronPython.StdLib/Lib/encodings/utf_32_be.py diff --git a/src/extensions/StdLib/Lib/encodings/utf_32_le.py b/src/core/IronPython.StdLib/Lib/encodings/utf_32_le.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/utf_32_le.py rename to src/core/IronPython.StdLib/Lib/encodings/utf_32_le.py diff --git a/src/extensions/StdLib/Lib/encodings/utf_7.py b/src/core/IronPython.StdLib/Lib/encodings/utf_7.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/utf_7.py rename to src/core/IronPython.StdLib/Lib/encodings/utf_7.py diff --git a/src/extensions/StdLib/Lib/encodings/utf_8.py b/src/core/IronPython.StdLib/Lib/encodings/utf_8.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/utf_8.py rename to src/core/IronPython.StdLib/Lib/encodings/utf_8.py diff --git a/src/extensions/StdLib/Lib/encodings/utf_8_sig.py b/src/core/IronPython.StdLib/Lib/encodings/utf_8_sig.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/utf_8_sig.py rename to src/core/IronPython.StdLib/Lib/encodings/utf_8_sig.py diff --git a/src/extensions/StdLib/Lib/encodings/uu_codec.py b/src/core/IronPython.StdLib/Lib/encodings/uu_codec.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/uu_codec.py rename to src/core/IronPython.StdLib/Lib/encodings/uu_codec.py diff --git a/src/extensions/StdLib/Lib/encodings/zlib_codec.py b/src/core/IronPython.StdLib/Lib/encodings/zlib_codec.py similarity index 100% rename from src/extensions/StdLib/Lib/encodings/zlib_codec.py rename to src/core/IronPython.StdLib/Lib/encodings/zlib_codec.py diff --git a/src/extensions/StdLib/Lib/ensurepip/__init__.py b/src/core/IronPython.StdLib/Lib/ensurepip/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/ensurepip/__init__.py rename to src/core/IronPython.StdLib/Lib/ensurepip/__init__.py diff --git a/src/extensions/StdLib/Lib/ensurepip/__main__.py b/src/core/IronPython.StdLib/Lib/ensurepip/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/ensurepip/__main__.py rename to src/core/IronPython.StdLib/Lib/ensurepip/__main__.py diff --git a/src/extensions/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl b/src/core/IronPython.StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl similarity index 100% rename from src/extensions/StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl rename to src/core/IronPython.StdLib/Lib/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl diff --git a/src/extensions/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl b/src/core/IronPython.StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl similarity index 100% rename from src/extensions/StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl rename to src/core/IronPython.StdLib/Lib/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl diff --git a/src/extensions/StdLib/Lib/ensurepip/_uninstall.py b/src/core/IronPython.StdLib/Lib/ensurepip/_uninstall.py similarity index 100% rename from src/extensions/StdLib/Lib/ensurepip/_uninstall.py rename to src/core/IronPython.StdLib/Lib/ensurepip/_uninstall.py diff --git a/src/extensions/StdLib/Lib/enum.py b/src/core/IronPython.StdLib/Lib/enum.py similarity index 100% rename from src/extensions/StdLib/Lib/enum.py rename to src/core/IronPython.StdLib/Lib/enum.py diff --git a/src/extensions/StdLib/Lib/filecmp.py b/src/core/IronPython.StdLib/Lib/filecmp.py similarity index 100% rename from src/extensions/StdLib/Lib/filecmp.py rename to src/core/IronPython.StdLib/Lib/filecmp.py diff --git a/src/extensions/StdLib/Lib/fileinput.py b/src/core/IronPython.StdLib/Lib/fileinput.py similarity index 100% rename from src/extensions/StdLib/Lib/fileinput.py rename to src/core/IronPython.StdLib/Lib/fileinput.py diff --git a/src/extensions/StdLib/Lib/fnmatch.py b/src/core/IronPython.StdLib/Lib/fnmatch.py similarity index 100% rename from src/extensions/StdLib/Lib/fnmatch.py rename to src/core/IronPython.StdLib/Lib/fnmatch.py diff --git a/src/extensions/StdLib/Lib/formatter.py b/src/core/IronPython.StdLib/Lib/formatter.py similarity index 100% rename from src/extensions/StdLib/Lib/formatter.py rename to src/core/IronPython.StdLib/Lib/formatter.py diff --git a/src/extensions/StdLib/Lib/fractions.py b/src/core/IronPython.StdLib/Lib/fractions.py similarity index 100% rename from src/extensions/StdLib/Lib/fractions.py rename to src/core/IronPython.StdLib/Lib/fractions.py diff --git a/src/extensions/StdLib/Lib/ftplib.py b/src/core/IronPython.StdLib/Lib/ftplib.py similarity index 100% rename from src/extensions/StdLib/Lib/ftplib.py rename to src/core/IronPython.StdLib/Lib/ftplib.py diff --git a/src/extensions/StdLib/Lib/functools.py b/src/core/IronPython.StdLib/Lib/functools.py similarity index 100% rename from src/extensions/StdLib/Lib/functools.py rename to src/core/IronPython.StdLib/Lib/functools.py diff --git a/src/extensions/StdLib/Lib/genericpath.py b/src/core/IronPython.StdLib/Lib/genericpath.py similarity index 100% rename from src/extensions/StdLib/Lib/genericpath.py rename to src/core/IronPython.StdLib/Lib/genericpath.py diff --git a/src/extensions/StdLib/Lib/getopt.py b/src/core/IronPython.StdLib/Lib/getopt.py similarity index 100% rename from src/extensions/StdLib/Lib/getopt.py rename to src/core/IronPython.StdLib/Lib/getopt.py diff --git a/src/extensions/StdLib/Lib/getpass.py b/src/core/IronPython.StdLib/Lib/getpass.py similarity index 100% rename from src/extensions/StdLib/Lib/getpass.py rename to src/core/IronPython.StdLib/Lib/getpass.py diff --git a/src/extensions/StdLib/Lib/gettext.py b/src/core/IronPython.StdLib/Lib/gettext.py similarity index 100% rename from src/extensions/StdLib/Lib/gettext.py rename to src/core/IronPython.StdLib/Lib/gettext.py diff --git a/src/extensions/StdLib/Lib/glob.py b/src/core/IronPython.StdLib/Lib/glob.py similarity index 100% rename from src/extensions/StdLib/Lib/glob.py rename to src/core/IronPython.StdLib/Lib/glob.py diff --git a/src/extensions/StdLib/Lib/gzip.py b/src/core/IronPython.StdLib/Lib/gzip.py similarity index 100% rename from src/extensions/StdLib/Lib/gzip.py rename to src/core/IronPython.StdLib/Lib/gzip.py diff --git a/src/extensions/StdLib/Lib/hashlib.py b/src/core/IronPython.StdLib/Lib/hashlib.py similarity index 100% rename from src/extensions/StdLib/Lib/hashlib.py rename to src/core/IronPython.StdLib/Lib/hashlib.py diff --git a/src/extensions/StdLib/Lib/heapq.py b/src/core/IronPython.StdLib/Lib/heapq.py similarity index 100% rename from src/extensions/StdLib/Lib/heapq.py rename to src/core/IronPython.StdLib/Lib/heapq.py diff --git a/src/extensions/StdLib/Lib/hmac.py b/src/core/IronPython.StdLib/Lib/hmac.py similarity index 100% rename from src/extensions/StdLib/Lib/hmac.py rename to src/core/IronPython.StdLib/Lib/hmac.py diff --git a/src/extensions/StdLib/Lib/html/__init__.py b/src/core/IronPython.StdLib/Lib/html/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/html/__init__.py rename to src/core/IronPython.StdLib/Lib/html/__init__.py diff --git a/src/extensions/StdLib/Lib/html/entities.py b/src/core/IronPython.StdLib/Lib/html/entities.py similarity index 100% rename from src/extensions/StdLib/Lib/html/entities.py rename to src/core/IronPython.StdLib/Lib/html/entities.py diff --git a/src/extensions/StdLib/Lib/html/parser.py b/src/core/IronPython.StdLib/Lib/html/parser.py similarity index 100% rename from src/extensions/StdLib/Lib/html/parser.py rename to src/core/IronPython.StdLib/Lib/html/parser.py diff --git a/src/extensions/StdLib/Lib/http/__init__.py b/src/core/IronPython.StdLib/Lib/http/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/http/__init__.py rename to src/core/IronPython.StdLib/Lib/http/__init__.py diff --git a/src/extensions/StdLib/Lib/http/client.py b/src/core/IronPython.StdLib/Lib/http/client.py similarity index 100% rename from src/extensions/StdLib/Lib/http/client.py rename to src/core/IronPython.StdLib/Lib/http/client.py diff --git a/src/extensions/StdLib/Lib/http/cookiejar.py b/src/core/IronPython.StdLib/Lib/http/cookiejar.py similarity index 100% rename from src/extensions/StdLib/Lib/http/cookiejar.py rename to src/core/IronPython.StdLib/Lib/http/cookiejar.py diff --git a/src/extensions/StdLib/Lib/http/cookies.py b/src/core/IronPython.StdLib/Lib/http/cookies.py similarity index 100% rename from src/extensions/StdLib/Lib/http/cookies.py rename to src/core/IronPython.StdLib/Lib/http/cookies.py diff --git a/src/extensions/StdLib/Lib/http/server.py b/src/core/IronPython.StdLib/Lib/http/server.py similarity index 100% rename from src/extensions/StdLib/Lib/http/server.py rename to src/core/IronPython.StdLib/Lib/http/server.py diff --git a/src/extensions/StdLib/Lib/idlelib/AutoComplete.py b/src/core/IronPython.StdLib/Lib/idlelib/AutoComplete.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/AutoComplete.py rename to src/core/IronPython.StdLib/Lib/idlelib/AutoComplete.py diff --git a/src/extensions/StdLib/Lib/idlelib/AutoCompleteWindow.py b/src/core/IronPython.StdLib/Lib/idlelib/AutoCompleteWindow.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/AutoCompleteWindow.py rename to src/core/IronPython.StdLib/Lib/idlelib/AutoCompleteWindow.py diff --git a/src/extensions/StdLib/Lib/idlelib/AutoExpand.py b/src/core/IronPython.StdLib/Lib/idlelib/AutoExpand.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/AutoExpand.py rename to src/core/IronPython.StdLib/Lib/idlelib/AutoExpand.py diff --git a/src/extensions/StdLib/Lib/idlelib/Bindings.py b/src/core/IronPython.StdLib/Lib/idlelib/Bindings.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/Bindings.py rename to src/core/IronPython.StdLib/Lib/idlelib/Bindings.py diff --git a/src/extensions/StdLib/Lib/idlelib/CREDITS.txt b/src/core/IronPython.StdLib/Lib/idlelib/CREDITS.txt similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/CREDITS.txt rename to src/core/IronPython.StdLib/Lib/idlelib/CREDITS.txt diff --git a/src/extensions/StdLib/Lib/idlelib/CallTipWindow.py b/src/core/IronPython.StdLib/Lib/idlelib/CallTipWindow.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/CallTipWindow.py rename to src/core/IronPython.StdLib/Lib/idlelib/CallTipWindow.py diff --git a/src/extensions/StdLib/Lib/idlelib/CallTips.py b/src/core/IronPython.StdLib/Lib/idlelib/CallTips.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/CallTips.py rename to src/core/IronPython.StdLib/Lib/idlelib/CallTips.py diff --git a/src/extensions/StdLib/Lib/idlelib/ChangeLog b/src/core/IronPython.StdLib/Lib/idlelib/ChangeLog similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/ChangeLog rename to src/core/IronPython.StdLib/Lib/idlelib/ChangeLog diff --git a/src/extensions/StdLib/Lib/idlelib/ClassBrowser.py b/src/core/IronPython.StdLib/Lib/idlelib/ClassBrowser.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/ClassBrowser.py rename to src/core/IronPython.StdLib/Lib/idlelib/ClassBrowser.py diff --git a/src/extensions/StdLib/Lib/idlelib/CodeContext.py b/src/core/IronPython.StdLib/Lib/idlelib/CodeContext.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/CodeContext.py rename to src/core/IronPython.StdLib/Lib/idlelib/CodeContext.py diff --git a/src/extensions/StdLib/Lib/idlelib/ColorDelegator.py b/src/core/IronPython.StdLib/Lib/idlelib/ColorDelegator.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/ColorDelegator.py rename to src/core/IronPython.StdLib/Lib/idlelib/ColorDelegator.py diff --git a/src/extensions/StdLib/Lib/idlelib/Debugger.py b/src/core/IronPython.StdLib/Lib/idlelib/Debugger.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/Debugger.py rename to src/core/IronPython.StdLib/Lib/idlelib/Debugger.py diff --git a/src/extensions/StdLib/Lib/idlelib/Delegator.py b/src/core/IronPython.StdLib/Lib/idlelib/Delegator.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/Delegator.py rename to src/core/IronPython.StdLib/Lib/idlelib/Delegator.py diff --git a/src/extensions/StdLib/Lib/idlelib/EditorWindow.py b/src/core/IronPython.StdLib/Lib/idlelib/EditorWindow.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/EditorWindow.py rename to src/core/IronPython.StdLib/Lib/idlelib/EditorWindow.py diff --git a/src/extensions/StdLib/Lib/idlelib/FileList.py b/src/core/IronPython.StdLib/Lib/idlelib/FileList.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/FileList.py rename to src/core/IronPython.StdLib/Lib/idlelib/FileList.py diff --git a/src/extensions/StdLib/Lib/idlelib/FormatParagraph.py b/src/core/IronPython.StdLib/Lib/idlelib/FormatParagraph.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/FormatParagraph.py rename to src/core/IronPython.StdLib/Lib/idlelib/FormatParagraph.py diff --git a/src/extensions/StdLib/Lib/idlelib/GrepDialog.py b/src/core/IronPython.StdLib/Lib/idlelib/GrepDialog.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/GrepDialog.py rename to src/core/IronPython.StdLib/Lib/idlelib/GrepDialog.py diff --git a/src/extensions/StdLib/Lib/idlelib/HISTORY.txt b/src/core/IronPython.StdLib/Lib/idlelib/HISTORY.txt similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/HISTORY.txt rename to src/core/IronPython.StdLib/Lib/idlelib/HISTORY.txt diff --git a/src/extensions/StdLib/Lib/idlelib/HyperParser.py b/src/core/IronPython.StdLib/Lib/idlelib/HyperParser.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/HyperParser.py rename to src/core/IronPython.StdLib/Lib/idlelib/HyperParser.py diff --git a/src/extensions/StdLib/Lib/idlelib/IOBinding.py b/src/core/IronPython.StdLib/Lib/idlelib/IOBinding.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/IOBinding.py rename to src/core/IronPython.StdLib/Lib/idlelib/IOBinding.py diff --git a/src/extensions/StdLib/Lib/idlelib/Icons/folder.gif b/src/core/IronPython.StdLib/Lib/idlelib/Icons/folder.gif similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/Icons/folder.gif rename to src/core/IronPython.StdLib/Lib/idlelib/Icons/folder.gif diff --git a/src/extensions/StdLib/Lib/idlelib/Icons/idle.icns b/src/core/IronPython.StdLib/Lib/idlelib/Icons/idle.icns similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/Icons/idle.icns rename to src/core/IronPython.StdLib/Lib/idlelib/Icons/idle.icns diff --git a/src/extensions/StdLib/Lib/idlelib/Icons/idle.ico b/src/core/IronPython.StdLib/Lib/idlelib/Icons/idle.ico similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/Icons/idle.ico rename to src/core/IronPython.StdLib/Lib/idlelib/Icons/idle.ico diff --git a/src/extensions/StdLib/Lib/idlelib/Icons/idle_16.gif b/src/core/IronPython.StdLib/Lib/idlelib/Icons/idle_16.gif similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/Icons/idle_16.gif rename to src/core/IronPython.StdLib/Lib/idlelib/Icons/idle_16.gif diff --git a/src/extensions/StdLib/Lib/idlelib/Icons/idle_16.png b/src/core/IronPython.StdLib/Lib/idlelib/Icons/idle_16.png similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/Icons/idle_16.png rename to src/core/IronPython.StdLib/Lib/idlelib/Icons/idle_16.png diff --git a/src/extensions/StdLib/Lib/idlelib/Icons/idle_32.gif b/src/core/IronPython.StdLib/Lib/idlelib/Icons/idle_32.gif similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/Icons/idle_32.gif rename to src/core/IronPython.StdLib/Lib/idlelib/Icons/idle_32.gif diff --git a/src/extensions/StdLib/Lib/idlelib/Icons/idle_32.png b/src/core/IronPython.StdLib/Lib/idlelib/Icons/idle_32.png similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/Icons/idle_32.png rename to src/core/IronPython.StdLib/Lib/idlelib/Icons/idle_32.png diff --git a/src/extensions/StdLib/Lib/idlelib/Icons/idle_48.gif b/src/core/IronPython.StdLib/Lib/idlelib/Icons/idle_48.gif similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/Icons/idle_48.gif rename to src/core/IronPython.StdLib/Lib/idlelib/Icons/idle_48.gif diff --git a/src/extensions/StdLib/Lib/idlelib/Icons/idle_48.png b/src/core/IronPython.StdLib/Lib/idlelib/Icons/idle_48.png similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/Icons/idle_48.png rename to src/core/IronPython.StdLib/Lib/idlelib/Icons/idle_48.png diff --git a/src/extensions/StdLib/Lib/idlelib/Icons/minusnode.gif b/src/core/IronPython.StdLib/Lib/idlelib/Icons/minusnode.gif similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/Icons/minusnode.gif rename to src/core/IronPython.StdLib/Lib/idlelib/Icons/minusnode.gif diff --git a/src/extensions/StdLib/Lib/idlelib/Icons/openfolder.gif b/src/core/IronPython.StdLib/Lib/idlelib/Icons/openfolder.gif similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/Icons/openfolder.gif rename to src/core/IronPython.StdLib/Lib/idlelib/Icons/openfolder.gif diff --git a/src/extensions/StdLib/Lib/idlelib/Icons/plusnode.gif b/src/core/IronPython.StdLib/Lib/idlelib/Icons/plusnode.gif similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/Icons/plusnode.gif rename to src/core/IronPython.StdLib/Lib/idlelib/Icons/plusnode.gif diff --git a/src/extensions/StdLib/Lib/idlelib/Icons/python.gif b/src/core/IronPython.StdLib/Lib/idlelib/Icons/python.gif similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/Icons/python.gif rename to src/core/IronPython.StdLib/Lib/idlelib/Icons/python.gif diff --git a/src/extensions/StdLib/Lib/idlelib/Icons/tk.gif b/src/core/IronPython.StdLib/Lib/idlelib/Icons/tk.gif similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/Icons/tk.gif rename to src/core/IronPython.StdLib/Lib/idlelib/Icons/tk.gif diff --git a/src/extensions/StdLib/Lib/idlelib/IdleHistory.py b/src/core/IronPython.StdLib/Lib/idlelib/IdleHistory.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/IdleHistory.py rename to src/core/IronPython.StdLib/Lib/idlelib/IdleHistory.py diff --git a/src/extensions/StdLib/Lib/idlelib/MultiCall.py b/src/core/IronPython.StdLib/Lib/idlelib/MultiCall.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/MultiCall.py rename to src/core/IronPython.StdLib/Lib/idlelib/MultiCall.py diff --git a/src/extensions/StdLib/Lib/idlelib/MultiStatusBar.py b/src/core/IronPython.StdLib/Lib/idlelib/MultiStatusBar.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/MultiStatusBar.py rename to src/core/IronPython.StdLib/Lib/idlelib/MultiStatusBar.py diff --git a/src/extensions/StdLib/Lib/idlelib/NEWS.txt b/src/core/IronPython.StdLib/Lib/idlelib/NEWS.txt similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/NEWS.txt rename to src/core/IronPython.StdLib/Lib/idlelib/NEWS.txt diff --git a/src/extensions/StdLib/Lib/idlelib/ObjectBrowser.py b/src/core/IronPython.StdLib/Lib/idlelib/ObjectBrowser.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/ObjectBrowser.py rename to src/core/IronPython.StdLib/Lib/idlelib/ObjectBrowser.py diff --git a/src/extensions/StdLib/Lib/idlelib/OutputWindow.py b/src/core/IronPython.StdLib/Lib/idlelib/OutputWindow.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/OutputWindow.py rename to src/core/IronPython.StdLib/Lib/idlelib/OutputWindow.py diff --git a/src/extensions/StdLib/Lib/idlelib/ParenMatch.py b/src/core/IronPython.StdLib/Lib/idlelib/ParenMatch.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/ParenMatch.py rename to src/core/IronPython.StdLib/Lib/idlelib/ParenMatch.py diff --git a/src/extensions/StdLib/Lib/idlelib/PathBrowser.py b/src/core/IronPython.StdLib/Lib/idlelib/PathBrowser.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/PathBrowser.py rename to src/core/IronPython.StdLib/Lib/idlelib/PathBrowser.py diff --git a/src/extensions/StdLib/Lib/idlelib/Percolator.py b/src/core/IronPython.StdLib/Lib/idlelib/Percolator.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/Percolator.py rename to src/core/IronPython.StdLib/Lib/idlelib/Percolator.py diff --git a/src/extensions/StdLib/Lib/idlelib/PyParse.py b/src/core/IronPython.StdLib/Lib/idlelib/PyParse.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/PyParse.py rename to src/core/IronPython.StdLib/Lib/idlelib/PyParse.py diff --git a/src/extensions/StdLib/Lib/idlelib/PyShell.py b/src/core/IronPython.StdLib/Lib/idlelib/PyShell.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/PyShell.py rename to src/core/IronPython.StdLib/Lib/idlelib/PyShell.py diff --git a/src/extensions/StdLib/Lib/idlelib/README.txt b/src/core/IronPython.StdLib/Lib/idlelib/README.txt similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/README.txt rename to src/core/IronPython.StdLib/Lib/idlelib/README.txt diff --git a/src/extensions/StdLib/Lib/idlelib/RemoteDebugger.py b/src/core/IronPython.StdLib/Lib/idlelib/RemoteDebugger.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/RemoteDebugger.py rename to src/core/IronPython.StdLib/Lib/idlelib/RemoteDebugger.py diff --git a/src/extensions/StdLib/Lib/idlelib/RemoteObjectBrowser.py b/src/core/IronPython.StdLib/Lib/idlelib/RemoteObjectBrowser.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/RemoteObjectBrowser.py rename to src/core/IronPython.StdLib/Lib/idlelib/RemoteObjectBrowser.py diff --git a/src/extensions/StdLib/Lib/idlelib/ReplaceDialog.py b/src/core/IronPython.StdLib/Lib/idlelib/ReplaceDialog.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/ReplaceDialog.py rename to src/core/IronPython.StdLib/Lib/idlelib/ReplaceDialog.py diff --git a/src/extensions/StdLib/Lib/idlelib/RstripExtension.py b/src/core/IronPython.StdLib/Lib/idlelib/RstripExtension.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/RstripExtension.py rename to src/core/IronPython.StdLib/Lib/idlelib/RstripExtension.py diff --git a/src/extensions/StdLib/Lib/idlelib/ScriptBinding.py b/src/core/IronPython.StdLib/Lib/idlelib/ScriptBinding.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/ScriptBinding.py rename to src/core/IronPython.StdLib/Lib/idlelib/ScriptBinding.py diff --git a/src/extensions/StdLib/Lib/idlelib/ScrolledList.py b/src/core/IronPython.StdLib/Lib/idlelib/ScrolledList.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/ScrolledList.py rename to src/core/IronPython.StdLib/Lib/idlelib/ScrolledList.py diff --git a/src/extensions/StdLib/Lib/idlelib/SearchDialog.py b/src/core/IronPython.StdLib/Lib/idlelib/SearchDialog.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/SearchDialog.py rename to src/core/IronPython.StdLib/Lib/idlelib/SearchDialog.py diff --git a/src/extensions/StdLib/Lib/idlelib/SearchDialogBase.py b/src/core/IronPython.StdLib/Lib/idlelib/SearchDialogBase.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/SearchDialogBase.py rename to src/core/IronPython.StdLib/Lib/idlelib/SearchDialogBase.py diff --git a/src/extensions/StdLib/Lib/idlelib/SearchEngine.py b/src/core/IronPython.StdLib/Lib/idlelib/SearchEngine.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/SearchEngine.py rename to src/core/IronPython.StdLib/Lib/idlelib/SearchEngine.py diff --git a/src/extensions/StdLib/Lib/idlelib/StackViewer.py b/src/core/IronPython.StdLib/Lib/idlelib/StackViewer.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/StackViewer.py rename to src/core/IronPython.StdLib/Lib/idlelib/StackViewer.py diff --git a/src/extensions/StdLib/Lib/idlelib/TODO.txt b/src/core/IronPython.StdLib/Lib/idlelib/TODO.txt similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/TODO.txt rename to src/core/IronPython.StdLib/Lib/idlelib/TODO.txt diff --git a/src/extensions/StdLib/Lib/idlelib/ToolTip.py b/src/core/IronPython.StdLib/Lib/idlelib/ToolTip.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/ToolTip.py rename to src/core/IronPython.StdLib/Lib/idlelib/ToolTip.py diff --git a/src/extensions/StdLib/Lib/idlelib/TreeWidget.py b/src/core/IronPython.StdLib/Lib/idlelib/TreeWidget.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/TreeWidget.py rename to src/core/IronPython.StdLib/Lib/idlelib/TreeWidget.py diff --git a/src/extensions/StdLib/Lib/idlelib/UndoDelegator.py b/src/core/IronPython.StdLib/Lib/idlelib/UndoDelegator.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/UndoDelegator.py rename to src/core/IronPython.StdLib/Lib/idlelib/UndoDelegator.py diff --git a/src/extensions/StdLib/Lib/idlelib/WidgetRedirector.py b/src/core/IronPython.StdLib/Lib/idlelib/WidgetRedirector.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/WidgetRedirector.py rename to src/core/IronPython.StdLib/Lib/idlelib/WidgetRedirector.py diff --git a/src/extensions/StdLib/Lib/idlelib/WindowList.py b/src/core/IronPython.StdLib/Lib/idlelib/WindowList.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/WindowList.py rename to src/core/IronPython.StdLib/Lib/idlelib/WindowList.py diff --git a/src/extensions/StdLib/Lib/idlelib/ZoomHeight.py b/src/core/IronPython.StdLib/Lib/idlelib/ZoomHeight.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/ZoomHeight.py rename to src/core/IronPython.StdLib/Lib/idlelib/ZoomHeight.py diff --git a/src/extensions/StdLib/Lib/idlelib/__init__.py b/src/core/IronPython.StdLib/Lib/idlelib/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/__init__.py rename to src/core/IronPython.StdLib/Lib/idlelib/__init__.py diff --git a/src/extensions/StdLib/Lib/idlelib/__main__.py b/src/core/IronPython.StdLib/Lib/idlelib/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/__main__.py rename to src/core/IronPython.StdLib/Lib/idlelib/__main__.py diff --git a/src/extensions/StdLib/Lib/idlelib/aboutDialog.py b/src/core/IronPython.StdLib/Lib/idlelib/aboutDialog.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/aboutDialog.py rename to src/core/IronPython.StdLib/Lib/idlelib/aboutDialog.py diff --git a/src/extensions/StdLib/Lib/idlelib/config-extensions.def b/src/core/IronPython.StdLib/Lib/idlelib/config-extensions.def similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/config-extensions.def rename to src/core/IronPython.StdLib/Lib/idlelib/config-extensions.def diff --git a/src/extensions/StdLib/Lib/idlelib/config-highlight.def b/src/core/IronPython.StdLib/Lib/idlelib/config-highlight.def similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/config-highlight.def rename to src/core/IronPython.StdLib/Lib/idlelib/config-highlight.def diff --git a/src/extensions/StdLib/Lib/idlelib/config-keys.def b/src/core/IronPython.StdLib/Lib/idlelib/config-keys.def similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/config-keys.def rename to src/core/IronPython.StdLib/Lib/idlelib/config-keys.def diff --git a/src/extensions/StdLib/Lib/idlelib/config-main.def b/src/core/IronPython.StdLib/Lib/idlelib/config-main.def similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/config-main.def rename to src/core/IronPython.StdLib/Lib/idlelib/config-main.def diff --git a/src/extensions/StdLib/Lib/idlelib/configDialog.py b/src/core/IronPython.StdLib/Lib/idlelib/configDialog.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/configDialog.py rename to src/core/IronPython.StdLib/Lib/idlelib/configDialog.py diff --git a/src/extensions/StdLib/Lib/idlelib/configHandler.py b/src/core/IronPython.StdLib/Lib/idlelib/configHandler.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/configHandler.py rename to src/core/IronPython.StdLib/Lib/idlelib/configHandler.py diff --git a/src/extensions/StdLib/Lib/idlelib/configHelpSourceEdit.py b/src/core/IronPython.StdLib/Lib/idlelib/configHelpSourceEdit.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/configHelpSourceEdit.py rename to src/core/IronPython.StdLib/Lib/idlelib/configHelpSourceEdit.py diff --git a/src/extensions/StdLib/Lib/idlelib/configSectionNameDialog.py b/src/core/IronPython.StdLib/Lib/idlelib/configSectionNameDialog.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/configSectionNameDialog.py rename to src/core/IronPython.StdLib/Lib/idlelib/configSectionNameDialog.py diff --git a/src/extensions/StdLib/Lib/idlelib/dynOptionMenuWidget.py b/src/core/IronPython.StdLib/Lib/idlelib/dynOptionMenuWidget.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/dynOptionMenuWidget.py rename to src/core/IronPython.StdLib/Lib/idlelib/dynOptionMenuWidget.py diff --git a/src/extensions/StdLib/Lib/idlelib/extend.txt b/src/core/IronPython.StdLib/Lib/idlelib/extend.txt similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/extend.txt rename to src/core/IronPython.StdLib/Lib/idlelib/extend.txt diff --git a/src/extensions/StdLib/Lib/idlelib/help.html b/src/core/IronPython.StdLib/Lib/idlelib/help.html similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/help.html rename to src/core/IronPython.StdLib/Lib/idlelib/help.html diff --git a/src/extensions/StdLib/Lib/idlelib/help.py b/src/core/IronPython.StdLib/Lib/idlelib/help.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/help.py rename to src/core/IronPython.StdLib/Lib/idlelib/help.py diff --git a/src/extensions/StdLib/Lib/idlelib/help.txt b/src/core/IronPython.StdLib/Lib/idlelib/help.txt similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/help.txt rename to src/core/IronPython.StdLib/Lib/idlelib/help.txt diff --git a/src/extensions/StdLib/Lib/idlelib/idle.bat b/src/core/IronPython.StdLib/Lib/idlelib/idle.bat similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle.bat rename to src/core/IronPython.StdLib/Lib/idlelib/idle.bat diff --git a/src/extensions/StdLib/Lib/idlelib/idle.py b/src/core/IronPython.StdLib/Lib/idlelib/idle.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle.pyw b/src/core/IronPython.StdLib/Lib/idlelib/idle.pyw similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle.pyw rename to src/core/IronPython.StdLib/Lib/idlelib/idle.pyw diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/README.txt b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/README.txt similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/README.txt rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/README.txt diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/__init__.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/__init__.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/__init__.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/htest.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/htest.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/htest.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/htest.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/mock_idle.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/mock_idle.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/mock_idle.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/mock_idle.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/mock_tk.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/mock_tk.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/mock_tk.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/mock_tk.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/test_autocomplete.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_autocomplete.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/test_autocomplete.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_autocomplete.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/test_autoexpand.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_autoexpand.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/test_autoexpand.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_autoexpand.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/test_calltips.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_calltips.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/test_calltips.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_calltips.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/test_config_name.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_config_name.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/test_config_name.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_config_name.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/test_configdialog.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_configdialog.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/test_configdialog.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_configdialog.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/test_delegator.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_delegator.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/test_delegator.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_delegator.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/test_editor.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_editor.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/test_editor.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_editor.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_formatparagraph.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/test_formatparagraph.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_formatparagraph.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/test_grep.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_grep.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/test_grep.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_grep.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/test_hyperparser.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_hyperparser.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/test_hyperparser.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_hyperparser.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/test_idlehistory.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_idlehistory.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/test_idlehistory.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_idlehistory.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/test_io.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_io.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/test_io.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_io.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/test_parenmatch.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_parenmatch.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/test_parenmatch.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_parenmatch.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_pathbrowser.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/test_pathbrowser.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_pathbrowser.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/test_rstrip.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_rstrip.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/test_rstrip.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_rstrip.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_searchdialogbase.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/test_searchengine.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_searchengine.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/test_searchengine.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_searchengine.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/test_text.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_text.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/test_text.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_text.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/test_textview.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_textview.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/test_textview.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_textview.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/test_warning.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_warning.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/test_warning.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_warning.py diff --git a/src/extensions/StdLib/Lib/idlelib/idle_test/test_widgetredir.py b/src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_widgetredir.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idle_test/test_widgetredir.py rename to src/core/IronPython.StdLib/Lib/idlelib/idle_test/test_widgetredir.py diff --git a/src/extensions/StdLib/Lib/idlelib/idlever.py b/src/core/IronPython.StdLib/Lib/idlelib/idlever.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/idlever.py rename to src/core/IronPython.StdLib/Lib/idlelib/idlever.py diff --git a/src/extensions/StdLib/Lib/idlelib/keybindingDialog.py b/src/core/IronPython.StdLib/Lib/idlelib/keybindingDialog.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/keybindingDialog.py rename to src/core/IronPython.StdLib/Lib/idlelib/keybindingDialog.py diff --git a/src/extensions/StdLib/Lib/idlelib/macosxSupport.py b/src/core/IronPython.StdLib/Lib/idlelib/macosxSupport.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/macosxSupport.py rename to src/core/IronPython.StdLib/Lib/idlelib/macosxSupport.py diff --git a/src/extensions/StdLib/Lib/idlelib/rpc.py b/src/core/IronPython.StdLib/Lib/idlelib/rpc.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/rpc.py rename to src/core/IronPython.StdLib/Lib/idlelib/rpc.py diff --git a/src/extensions/StdLib/Lib/idlelib/run.py b/src/core/IronPython.StdLib/Lib/idlelib/run.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/run.py rename to src/core/IronPython.StdLib/Lib/idlelib/run.py diff --git a/src/extensions/StdLib/Lib/idlelib/tabbedpages.py b/src/core/IronPython.StdLib/Lib/idlelib/tabbedpages.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/tabbedpages.py rename to src/core/IronPython.StdLib/Lib/idlelib/tabbedpages.py diff --git a/src/extensions/StdLib/Lib/idlelib/textView.py b/src/core/IronPython.StdLib/Lib/idlelib/textView.py similarity index 100% rename from src/extensions/StdLib/Lib/idlelib/textView.py rename to src/core/IronPython.StdLib/Lib/idlelib/textView.py diff --git a/src/extensions/StdLib/Lib/imaplib.py b/src/core/IronPython.StdLib/Lib/imaplib.py similarity index 100% rename from src/extensions/StdLib/Lib/imaplib.py rename to src/core/IronPython.StdLib/Lib/imaplib.py diff --git a/src/extensions/StdLib/Lib/imghdr.py b/src/core/IronPython.StdLib/Lib/imghdr.py similarity index 100% rename from src/extensions/StdLib/Lib/imghdr.py rename to src/core/IronPython.StdLib/Lib/imghdr.py diff --git a/src/extensions/StdLib/Lib/imp.py b/src/core/IronPython.StdLib/Lib/imp.py similarity index 100% rename from src/extensions/StdLib/Lib/imp.py rename to src/core/IronPython.StdLib/Lib/imp.py diff --git a/src/extensions/StdLib/Lib/importlib/__init__.py b/src/core/IronPython.StdLib/Lib/importlib/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/importlib/__init__.py rename to src/core/IronPython.StdLib/Lib/importlib/__init__.py diff --git a/src/extensions/StdLib/Lib/importlib/_bootstrap.py b/src/core/IronPython.StdLib/Lib/importlib/_bootstrap.py similarity index 100% rename from src/extensions/StdLib/Lib/importlib/_bootstrap.py rename to src/core/IronPython.StdLib/Lib/importlib/_bootstrap.py diff --git a/src/extensions/StdLib/Lib/importlib/abc.py b/src/core/IronPython.StdLib/Lib/importlib/abc.py similarity index 100% rename from src/extensions/StdLib/Lib/importlib/abc.py rename to src/core/IronPython.StdLib/Lib/importlib/abc.py diff --git a/src/extensions/StdLib/Lib/importlib/machinery.py b/src/core/IronPython.StdLib/Lib/importlib/machinery.py similarity index 100% rename from src/extensions/StdLib/Lib/importlib/machinery.py rename to src/core/IronPython.StdLib/Lib/importlib/machinery.py diff --git a/src/extensions/StdLib/Lib/importlib/util.py b/src/core/IronPython.StdLib/Lib/importlib/util.py similarity index 100% rename from src/extensions/StdLib/Lib/importlib/util.py rename to src/core/IronPython.StdLib/Lib/importlib/util.py diff --git a/src/extensions/StdLib/Lib/inspect.py b/src/core/IronPython.StdLib/Lib/inspect.py similarity index 100% rename from src/extensions/StdLib/Lib/inspect.py rename to src/core/IronPython.StdLib/Lib/inspect.py diff --git a/src/extensions/StdLib/Lib/io.py b/src/core/IronPython.StdLib/Lib/io.py similarity index 100% rename from src/extensions/StdLib/Lib/io.py rename to src/core/IronPython.StdLib/Lib/io.py diff --git a/src/extensions/StdLib/Lib/ipaddress.py b/src/core/IronPython.StdLib/Lib/ipaddress.py similarity index 100% rename from src/extensions/StdLib/Lib/ipaddress.py rename to src/core/IronPython.StdLib/Lib/ipaddress.py diff --git a/src/extensions/StdLib/Lib/json/__init__.py b/src/core/IronPython.StdLib/Lib/json/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/json/__init__.py rename to src/core/IronPython.StdLib/Lib/json/__init__.py diff --git a/src/extensions/StdLib/Lib/json/decoder.py b/src/core/IronPython.StdLib/Lib/json/decoder.py similarity index 100% rename from src/extensions/StdLib/Lib/json/decoder.py rename to src/core/IronPython.StdLib/Lib/json/decoder.py diff --git a/src/extensions/StdLib/Lib/json/encoder.py b/src/core/IronPython.StdLib/Lib/json/encoder.py similarity index 100% rename from src/extensions/StdLib/Lib/json/encoder.py rename to src/core/IronPython.StdLib/Lib/json/encoder.py diff --git a/src/extensions/StdLib/Lib/json/scanner.py b/src/core/IronPython.StdLib/Lib/json/scanner.py similarity index 100% rename from src/extensions/StdLib/Lib/json/scanner.py rename to src/core/IronPython.StdLib/Lib/json/scanner.py diff --git a/src/extensions/StdLib/Lib/json/tool.py b/src/core/IronPython.StdLib/Lib/json/tool.py similarity index 100% rename from src/extensions/StdLib/Lib/json/tool.py rename to src/core/IronPython.StdLib/Lib/json/tool.py diff --git a/src/extensions/StdLib/Lib/keyword.py b/src/core/IronPython.StdLib/Lib/keyword.py similarity index 100% rename from src/extensions/StdLib/Lib/keyword.py rename to src/core/IronPython.StdLib/Lib/keyword.py diff --git a/src/extensions/StdLib/Lib/lib2to3/Grammar.txt b/src/core/IronPython.StdLib/Lib/lib2to3/Grammar.txt similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/Grammar.txt rename to src/core/IronPython.StdLib/Lib/lib2to3/Grammar.txt diff --git a/src/extensions/StdLib/Lib/lib2to3/PatternGrammar.txt b/src/core/IronPython.StdLib/Lib/lib2to3/PatternGrammar.txt similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/PatternGrammar.txt rename to src/core/IronPython.StdLib/Lib/lib2to3/PatternGrammar.txt diff --git a/src/extensions/StdLib/Lib/lib2to3/__init__.py b/src/core/IronPython.StdLib/Lib/lib2to3/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/__init__.py rename to src/core/IronPython.StdLib/Lib/lib2to3/__init__.py diff --git a/src/extensions/StdLib/Lib/lib2to3/__main__.py b/src/core/IronPython.StdLib/Lib/lib2to3/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/__main__.py rename to src/core/IronPython.StdLib/Lib/lib2to3/__main__.py diff --git a/src/extensions/StdLib/Lib/lib2to3/btm_matcher.py b/src/core/IronPython.StdLib/Lib/lib2to3/btm_matcher.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/btm_matcher.py rename to src/core/IronPython.StdLib/Lib/lib2to3/btm_matcher.py diff --git a/src/extensions/StdLib/Lib/lib2to3/btm_utils.py b/src/core/IronPython.StdLib/Lib/lib2to3/btm_utils.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/btm_utils.py rename to src/core/IronPython.StdLib/Lib/lib2to3/btm_utils.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixer_base.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixer_base.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixer_base.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixer_base.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixer_util.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixer_util.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixer_util.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixer_util.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/__init__.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/__init__.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/__init__.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_apply.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_apply.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_apply.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_apply.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_asserts.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_asserts.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_asserts.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_asserts.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_basestring.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_basestring.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_basestring.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_basestring.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_buffer.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_buffer.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_buffer.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_buffer.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_callable.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_callable.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_callable.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_callable.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_dict.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_dict.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_dict.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_dict.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_except.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_except.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_except.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_except.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_exec.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_exec.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_exec.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_exec.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_execfile.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_execfile.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_execfile.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_execfile.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_exitfunc.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_exitfunc.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_exitfunc.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_filter.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_filter.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_filter.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_filter.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_funcattrs.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_funcattrs.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_funcattrs.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_future.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_future.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_future.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_future.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_getcwdu.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_getcwdu.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_getcwdu.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_has_key.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_has_key.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_has_key.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_has_key.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_idioms.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_idioms.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_idioms.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_idioms.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_import.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_import.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_import.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_import.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_imports.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_imports.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_imports.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_imports.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_imports2.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_imports2.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_imports2.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_imports2.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_input.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_input.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_input.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_input.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_intern.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_intern.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_intern.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_intern.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_isinstance.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_isinstance.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_isinstance.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_isinstance.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_itertools.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_itertools.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_itertools.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_itertools.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_itertools_imports.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_long.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_long.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_long.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_long.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_map.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_map.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_map.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_map.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_metaclass.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_metaclass.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_metaclass.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_metaclass.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_methodattrs.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_methodattrs.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_methodattrs.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_ne.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_ne.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_ne.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_ne.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_next.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_next.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_next.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_next.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_nonzero.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_nonzero.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_nonzero.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_nonzero.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_numliterals.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_numliterals.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_numliterals.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_numliterals.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_operator.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_operator.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_operator.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_operator.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_paren.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_paren.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_paren.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_paren.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_print.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_print.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_print.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_print.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_raise.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_raise.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_raise.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_raise.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_raw_input.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_raw_input.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_raw_input.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_raw_input.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_reduce.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_reduce.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_reduce.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_reduce.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_reload.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_reload.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_reload.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_reload.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_renames.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_renames.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_renames.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_renames.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_repr.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_repr.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_repr.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_repr.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_set_literal.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_set_literal.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_set_literal.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_set_literal.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_standarderror.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_standarderror.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_standarderror.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_standarderror.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_sys_exc.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_sys_exc.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_sys_exc.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_throw.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_throw.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_throw.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_throw.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_tuple_params.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_tuple_params.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_tuple_params.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_types.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_types.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_types.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_types.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_unicode.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_unicode.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_unicode.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_unicode.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_urllib.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_urllib.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_urllib.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_urllib.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_ws_comma.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_ws_comma.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_ws_comma.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_xrange.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_xrange.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_xrange.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_xrange.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_xreadlines.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_xreadlines.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_xreadlines.py diff --git a/src/extensions/StdLib/Lib/lib2to3/fixes/fix_zip.py b/src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_zip.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/fixes/fix_zip.py rename to src/core/IronPython.StdLib/Lib/lib2to3/fixes/fix_zip.py diff --git a/src/extensions/StdLib/Lib/lib2to3/main.py b/src/core/IronPython.StdLib/Lib/lib2to3/main.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/main.py rename to src/core/IronPython.StdLib/Lib/lib2to3/main.py diff --git a/src/extensions/StdLib/Lib/lib2to3/patcomp.py b/src/core/IronPython.StdLib/Lib/lib2to3/patcomp.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/patcomp.py rename to src/core/IronPython.StdLib/Lib/lib2to3/patcomp.py diff --git a/src/extensions/StdLib/Lib/lib2to3/pgen2/__init__.py b/src/core/IronPython.StdLib/Lib/lib2to3/pgen2/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/pgen2/__init__.py rename to src/core/IronPython.StdLib/Lib/lib2to3/pgen2/__init__.py diff --git a/src/extensions/StdLib/Lib/lib2to3/pgen2/conv.py b/src/core/IronPython.StdLib/Lib/lib2to3/pgen2/conv.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/pgen2/conv.py rename to src/core/IronPython.StdLib/Lib/lib2to3/pgen2/conv.py diff --git a/src/extensions/StdLib/Lib/lib2to3/pgen2/driver.py b/src/core/IronPython.StdLib/Lib/lib2to3/pgen2/driver.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/pgen2/driver.py rename to src/core/IronPython.StdLib/Lib/lib2to3/pgen2/driver.py diff --git a/src/extensions/StdLib/Lib/lib2to3/pgen2/grammar.py b/src/core/IronPython.StdLib/Lib/lib2to3/pgen2/grammar.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/pgen2/grammar.py rename to src/core/IronPython.StdLib/Lib/lib2to3/pgen2/grammar.py diff --git a/src/extensions/StdLib/Lib/lib2to3/pgen2/literals.py b/src/core/IronPython.StdLib/Lib/lib2to3/pgen2/literals.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/pgen2/literals.py rename to src/core/IronPython.StdLib/Lib/lib2to3/pgen2/literals.py diff --git a/src/extensions/StdLib/Lib/lib2to3/pgen2/parse.py b/src/core/IronPython.StdLib/Lib/lib2to3/pgen2/parse.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/pgen2/parse.py rename to src/core/IronPython.StdLib/Lib/lib2to3/pgen2/parse.py diff --git a/src/extensions/StdLib/Lib/lib2to3/pgen2/pgen.py b/src/core/IronPython.StdLib/Lib/lib2to3/pgen2/pgen.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/pgen2/pgen.py rename to src/core/IronPython.StdLib/Lib/lib2to3/pgen2/pgen.py diff --git a/src/extensions/StdLib/Lib/lib2to3/pgen2/token.py b/src/core/IronPython.StdLib/Lib/lib2to3/pgen2/token.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/pgen2/token.py rename to src/core/IronPython.StdLib/Lib/lib2to3/pgen2/token.py diff --git a/src/extensions/StdLib/Lib/lib2to3/pgen2/tokenize.py b/src/core/IronPython.StdLib/Lib/lib2to3/pgen2/tokenize.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/pgen2/tokenize.py rename to src/core/IronPython.StdLib/Lib/lib2to3/pgen2/tokenize.py diff --git a/src/extensions/StdLib/Lib/lib2to3/pygram.py b/src/core/IronPython.StdLib/Lib/lib2to3/pygram.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/pygram.py rename to src/core/IronPython.StdLib/Lib/lib2to3/pygram.py diff --git a/src/extensions/StdLib/Lib/lib2to3/pytree.py b/src/core/IronPython.StdLib/Lib/lib2to3/pytree.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/pytree.py rename to src/core/IronPython.StdLib/Lib/lib2to3/pytree.py diff --git a/src/extensions/StdLib/Lib/lib2to3/refactor.py b/src/core/IronPython.StdLib/Lib/lib2to3/refactor.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/refactor.py rename to src/core/IronPython.StdLib/Lib/lib2to3/refactor.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/__init__.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/__init__.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/__init__.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/__main__.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/__main__.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/__main__.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/data/README b/src/core/IronPython.StdLib/Lib/lib2to3/tests/data/README similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/data/README rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/data/README diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/data/bom.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/data/bom.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/data/bom.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/data/bom.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/data/crlf.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/data/crlf.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/data/crlf.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/data/crlf.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/data/different_encoding.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/data/different_encoding.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/data/different_encoding.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/data/different_encoding.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/data/false_encoding.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/data/false_encoding.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/data/false_encoding.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/data/false_encoding.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/data/fixers/bad_order.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_last.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/data/fixers/no_fixer_cls.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/data/fixers/parrot_example.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/data/infinite_recursion.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/data/infinite_recursion.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/data/infinite_recursion.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/data/py2_test_grammar.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/data/py3_test_grammar.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/pytree_idempotency.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/pytree_idempotency.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/pytree_idempotency.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/pytree_idempotency.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/support.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/support.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/support.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/support.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/test_all_fixers.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/test_all_fixers.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/test_all_fixers.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/test_all_fixers.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/test_fixers.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/test_fixers.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/test_fixers.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/test_fixers.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/test_main.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/test_main.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/test_main.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/test_main.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/test_parser.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/test_parser.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/test_parser.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/test_parser.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/test_pytree.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/test_pytree.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/test_pytree.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/test_pytree.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/test_refactor.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/test_refactor.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/test_refactor.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/test_refactor.py diff --git a/src/extensions/StdLib/Lib/lib2to3/tests/test_util.py b/src/core/IronPython.StdLib/Lib/lib2to3/tests/test_util.py similarity index 100% rename from src/extensions/StdLib/Lib/lib2to3/tests/test_util.py rename to src/core/IronPython.StdLib/Lib/lib2to3/tests/test_util.py diff --git a/src/extensions/StdLib/Lib/linecache.py b/src/core/IronPython.StdLib/Lib/linecache.py similarity index 100% rename from src/extensions/StdLib/Lib/linecache.py rename to src/core/IronPython.StdLib/Lib/linecache.py diff --git a/src/extensions/StdLib/Lib/locale.py b/src/core/IronPython.StdLib/Lib/locale.py similarity index 100% rename from src/extensions/StdLib/Lib/locale.py rename to src/core/IronPython.StdLib/Lib/locale.py diff --git a/src/extensions/StdLib/Lib/logging/__init__.py b/src/core/IronPython.StdLib/Lib/logging/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/logging/__init__.py rename to src/core/IronPython.StdLib/Lib/logging/__init__.py diff --git a/src/extensions/StdLib/Lib/logging/config.py b/src/core/IronPython.StdLib/Lib/logging/config.py similarity index 100% rename from src/extensions/StdLib/Lib/logging/config.py rename to src/core/IronPython.StdLib/Lib/logging/config.py diff --git a/src/extensions/StdLib/Lib/logging/handlers.py b/src/core/IronPython.StdLib/Lib/logging/handlers.py similarity index 100% rename from src/extensions/StdLib/Lib/logging/handlers.py rename to src/core/IronPython.StdLib/Lib/logging/handlers.py diff --git a/src/extensions/StdLib/Lib/lzma.py b/src/core/IronPython.StdLib/Lib/lzma.py similarity index 100% rename from src/extensions/StdLib/Lib/lzma.py rename to src/core/IronPython.StdLib/Lib/lzma.py diff --git a/src/extensions/StdLib/Lib/macpath.py b/src/core/IronPython.StdLib/Lib/macpath.py similarity index 100% rename from src/extensions/StdLib/Lib/macpath.py rename to src/core/IronPython.StdLib/Lib/macpath.py diff --git a/src/extensions/StdLib/Lib/macurl2path.py b/src/core/IronPython.StdLib/Lib/macurl2path.py similarity index 100% rename from src/extensions/StdLib/Lib/macurl2path.py rename to src/core/IronPython.StdLib/Lib/macurl2path.py diff --git a/src/extensions/StdLib/Lib/mailbox.py b/src/core/IronPython.StdLib/Lib/mailbox.py similarity index 100% rename from src/extensions/StdLib/Lib/mailbox.py rename to src/core/IronPython.StdLib/Lib/mailbox.py diff --git a/src/extensions/StdLib/Lib/mailcap.py b/src/core/IronPython.StdLib/Lib/mailcap.py similarity index 100% rename from src/extensions/StdLib/Lib/mailcap.py rename to src/core/IronPython.StdLib/Lib/mailcap.py diff --git a/src/extensions/StdLib/Lib/mimetypes.py b/src/core/IronPython.StdLib/Lib/mimetypes.py similarity index 100% rename from src/extensions/StdLib/Lib/mimetypes.py rename to src/core/IronPython.StdLib/Lib/mimetypes.py diff --git a/src/extensions/StdLib/Lib/modulefinder.py b/src/core/IronPython.StdLib/Lib/modulefinder.py similarity index 100% rename from src/extensions/StdLib/Lib/modulefinder.py rename to src/core/IronPython.StdLib/Lib/modulefinder.py diff --git a/src/extensions/StdLib/Lib/msilib/__init__.py b/src/core/IronPython.StdLib/Lib/msilib/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/msilib/__init__.py rename to src/core/IronPython.StdLib/Lib/msilib/__init__.py diff --git a/src/extensions/StdLib/Lib/msilib/schema.py b/src/core/IronPython.StdLib/Lib/msilib/schema.py similarity index 100% rename from src/extensions/StdLib/Lib/msilib/schema.py rename to src/core/IronPython.StdLib/Lib/msilib/schema.py diff --git a/src/extensions/StdLib/Lib/msilib/sequence.py b/src/core/IronPython.StdLib/Lib/msilib/sequence.py similarity index 100% rename from src/extensions/StdLib/Lib/msilib/sequence.py rename to src/core/IronPython.StdLib/Lib/msilib/sequence.py diff --git a/src/extensions/StdLib/Lib/msilib/text.py b/src/core/IronPython.StdLib/Lib/msilib/text.py similarity index 100% rename from src/extensions/StdLib/Lib/msilib/text.py rename to src/core/IronPython.StdLib/Lib/msilib/text.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/__init__.py b/src/core/IronPython.StdLib/Lib/multiprocessing/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/__init__.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/__init__.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/connection.py b/src/core/IronPython.StdLib/Lib/multiprocessing/connection.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/connection.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/connection.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/context.py b/src/core/IronPython.StdLib/Lib/multiprocessing/context.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/context.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/context.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/dummy/__init__.py b/src/core/IronPython.StdLib/Lib/multiprocessing/dummy/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/dummy/__init__.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/dummy/__init__.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/dummy/connection.py b/src/core/IronPython.StdLib/Lib/multiprocessing/dummy/connection.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/dummy/connection.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/dummy/connection.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/forkserver.py b/src/core/IronPython.StdLib/Lib/multiprocessing/forkserver.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/forkserver.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/forkserver.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/heap.py b/src/core/IronPython.StdLib/Lib/multiprocessing/heap.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/heap.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/heap.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/managers.py b/src/core/IronPython.StdLib/Lib/multiprocessing/managers.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/managers.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/managers.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/pool.py b/src/core/IronPython.StdLib/Lib/multiprocessing/pool.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/pool.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/pool.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/popen_fork.py b/src/core/IronPython.StdLib/Lib/multiprocessing/popen_fork.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/popen_fork.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/popen_fork.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/popen_forkserver.py b/src/core/IronPython.StdLib/Lib/multiprocessing/popen_forkserver.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/popen_forkserver.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/popen_forkserver.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/popen_spawn_posix.py b/src/core/IronPython.StdLib/Lib/multiprocessing/popen_spawn_posix.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/popen_spawn_posix.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/popen_spawn_posix.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/popen_spawn_win32.py b/src/core/IronPython.StdLib/Lib/multiprocessing/popen_spawn_win32.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/popen_spawn_win32.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/popen_spawn_win32.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/process.py b/src/core/IronPython.StdLib/Lib/multiprocessing/process.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/process.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/process.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/queues.py b/src/core/IronPython.StdLib/Lib/multiprocessing/queues.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/queues.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/queues.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/reduction.py b/src/core/IronPython.StdLib/Lib/multiprocessing/reduction.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/reduction.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/reduction.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/resource_sharer.py b/src/core/IronPython.StdLib/Lib/multiprocessing/resource_sharer.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/resource_sharer.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/resource_sharer.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/semaphore_tracker.py b/src/core/IronPython.StdLib/Lib/multiprocessing/semaphore_tracker.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/semaphore_tracker.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/semaphore_tracker.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/sharedctypes.py b/src/core/IronPython.StdLib/Lib/multiprocessing/sharedctypes.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/sharedctypes.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/sharedctypes.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/spawn.py b/src/core/IronPython.StdLib/Lib/multiprocessing/spawn.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/spawn.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/spawn.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/synchronize.py b/src/core/IronPython.StdLib/Lib/multiprocessing/synchronize.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/synchronize.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/synchronize.py diff --git a/src/extensions/StdLib/Lib/multiprocessing/util.py b/src/core/IronPython.StdLib/Lib/multiprocessing/util.py similarity index 100% rename from src/extensions/StdLib/Lib/multiprocessing/util.py rename to src/core/IronPython.StdLib/Lib/multiprocessing/util.py diff --git a/src/extensions/StdLib/Lib/netrc.py b/src/core/IronPython.StdLib/Lib/netrc.py similarity index 100% rename from src/extensions/StdLib/Lib/netrc.py rename to src/core/IronPython.StdLib/Lib/netrc.py diff --git a/src/extensions/StdLib/Lib/nntplib.py b/src/core/IronPython.StdLib/Lib/nntplib.py similarity index 100% rename from src/extensions/StdLib/Lib/nntplib.py rename to src/core/IronPython.StdLib/Lib/nntplib.py diff --git a/src/extensions/StdLib/Lib/ntpath.py b/src/core/IronPython.StdLib/Lib/ntpath.py similarity index 100% rename from src/extensions/StdLib/Lib/ntpath.py rename to src/core/IronPython.StdLib/Lib/ntpath.py diff --git a/src/extensions/StdLib/Lib/nturl2path.py b/src/core/IronPython.StdLib/Lib/nturl2path.py similarity index 100% rename from src/extensions/StdLib/Lib/nturl2path.py rename to src/core/IronPython.StdLib/Lib/nturl2path.py diff --git a/src/extensions/StdLib/Lib/numbers.py b/src/core/IronPython.StdLib/Lib/numbers.py similarity index 100% rename from src/extensions/StdLib/Lib/numbers.py rename to src/core/IronPython.StdLib/Lib/numbers.py diff --git a/src/extensions/StdLib/Lib/opcode.py b/src/core/IronPython.StdLib/Lib/opcode.py similarity index 100% rename from src/extensions/StdLib/Lib/opcode.py rename to src/core/IronPython.StdLib/Lib/opcode.py diff --git a/src/extensions/StdLib/Lib/operator.py b/src/core/IronPython.StdLib/Lib/operator.py similarity index 100% rename from src/extensions/StdLib/Lib/operator.py rename to src/core/IronPython.StdLib/Lib/operator.py diff --git a/src/extensions/StdLib/Lib/optparse.py b/src/core/IronPython.StdLib/Lib/optparse.py similarity index 100% rename from src/extensions/StdLib/Lib/optparse.py rename to src/core/IronPython.StdLib/Lib/optparse.py diff --git a/src/extensions/StdLib/Lib/os.py b/src/core/IronPython.StdLib/Lib/os.py similarity index 100% rename from src/extensions/StdLib/Lib/os.py rename to src/core/IronPython.StdLib/Lib/os.py diff --git a/src/extensions/StdLib/Lib/pathlib.py b/src/core/IronPython.StdLib/Lib/pathlib.py similarity index 100% rename from src/extensions/StdLib/Lib/pathlib.py rename to src/core/IronPython.StdLib/Lib/pathlib.py diff --git a/src/extensions/StdLib/Lib/pdb.py b/src/core/IronPython.StdLib/Lib/pdb.py similarity index 100% rename from src/extensions/StdLib/Lib/pdb.py rename to src/core/IronPython.StdLib/Lib/pdb.py diff --git a/src/extensions/StdLib/Lib/pickle.py b/src/core/IronPython.StdLib/Lib/pickle.py similarity index 100% rename from src/extensions/StdLib/Lib/pickle.py rename to src/core/IronPython.StdLib/Lib/pickle.py diff --git a/src/extensions/StdLib/Lib/pickletools.py b/src/core/IronPython.StdLib/Lib/pickletools.py similarity index 100% rename from src/extensions/StdLib/Lib/pickletools.py rename to src/core/IronPython.StdLib/Lib/pickletools.py diff --git a/src/extensions/StdLib/Lib/pipes.py b/src/core/IronPython.StdLib/Lib/pipes.py similarity index 100% rename from src/extensions/StdLib/Lib/pipes.py rename to src/core/IronPython.StdLib/Lib/pipes.py diff --git a/src/extensions/StdLib/Lib/pkgutil.py b/src/core/IronPython.StdLib/Lib/pkgutil.py similarity index 100% rename from src/extensions/StdLib/Lib/pkgutil.py rename to src/core/IronPython.StdLib/Lib/pkgutil.py diff --git a/src/extensions/StdLib/Lib/platform.py b/src/core/IronPython.StdLib/Lib/platform.py similarity index 100% rename from src/extensions/StdLib/Lib/platform.py rename to src/core/IronPython.StdLib/Lib/platform.py diff --git a/src/extensions/StdLib/Lib/plistlib.py b/src/core/IronPython.StdLib/Lib/plistlib.py similarity index 100% rename from src/extensions/StdLib/Lib/plistlib.py rename to src/core/IronPython.StdLib/Lib/plistlib.py diff --git a/src/extensions/StdLib/Lib/poplib.py b/src/core/IronPython.StdLib/Lib/poplib.py similarity index 100% rename from src/extensions/StdLib/Lib/poplib.py rename to src/core/IronPython.StdLib/Lib/poplib.py diff --git a/src/extensions/StdLib/Lib/posixpath.py b/src/core/IronPython.StdLib/Lib/posixpath.py similarity index 100% rename from src/extensions/StdLib/Lib/posixpath.py rename to src/core/IronPython.StdLib/Lib/posixpath.py diff --git a/src/extensions/StdLib/Lib/pprint.py b/src/core/IronPython.StdLib/Lib/pprint.py similarity index 100% rename from src/extensions/StdLib/Lib/pprint.py rename to src/core/IronPython.StdLib/Lib/pprint.py diff --git a/src/extensions/StdLib/Lib/profile.py b/src/core/IronPython.StdLib/Lib/profile.py similarity index 100% rename from src/extensions/StdLib/Lib/profile.py rename to src/core/IronPython.StdLib/Lib/profile.py diff --git a/src/extensions/StdLib/Lib/pstats.py b/src/core/IronPython.StdLib/Lib/pstats.py similarity index 100% rename from src/extensions/StdLib/Lib/pstats.py rename to src/core/IronPython.StdLib/Lib/pstats.py diff --git a/src/extensions/StdLib/Lib/pty.py b/src/core/IronPython.StdLib/Lib/pty.py similarity index 100% rename from src/extensions/StdLib/Lib/pty.py rename to src/core/IronPython.StdLib/Lib/pty.py diff --git a/src/extensions/StdLib/Lib/py_compile.py b/src/core/IronPython.StdLib/Lib/py_compile.py similarity index 100% rename from src/extensions/StdLib/Lib/py_compile.py rename to src/core/IronPython.StdLib/Lib/py_compile.py diff --git a/src/extensions/StdLib/Lib/pyclbr.py b/src/core/IronPython.StdLib/Lib/pyclbr.py similarity index 100% rename from src/extensions/StdLib/Lib/pyclbr.py rename to src/core/IronPython.StdLib/Lib/pyclbr.py diff --git a/src/extensions/StdLib/Lib/pydoc.py b/src/core/IronPython.StdLib/Lib/pydoc.py similarity index 100% rename from src/extensions/StdLib/Lib/pydoc.py rename to src/core/IronPython.StdLib/Lib/pydoc.py diff --git a/src/extensions/StdLib/Lib/pydoc_data/__init__.py b/src/core/IronPython.StdLib/Lib/pydoc_data/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/pydoc_data/__init__.py rename to src/core/IronPython.StdLib/Lib/pydoc_data/__init__.py diff --git a/src/extensions/StdLib/Lib/pydoc_data/_pydoc.css b/src/core/IronPython.StdLib/Lib/pydoc_data/_pydoc.css similarity index 100% rename from src/extensions/StdLib/Lib/pydoc_data/_pydoc.css rename to src/core/IronPython.StdLib/Lib/pydoc_data/_pydoc.css diff --git a/src/extensions/StdLib/Lib/pydoc_data/topics.py b/src/core/IronPython.StdLib/Lib/pydoc_data/topics.py similarity index 100% rename from src/extensions/StdLib/Lib/pydoc_data/topics.py rename to src/core/IronPython.StdLib/Lib/pydoc_data/topics.py diff --git a/src/extensions/StdLib/Lib/queue.py b/src/core/IronPython.StdLib/Lib/queue.py similarity index 100% rename from src/extensions/StdLib/Lib/queue.py rename to src/core/IronPython.StdLib/Lib/queue.py diff --git a/src/extensions/StdLib/Lib/quopri.py b/src/core/IronPython.StdLib/Lib/quopri.py similarity index 100% rename from src/extensions/StdLib/Lib/quopri.py rename to src/core/IronPython.StdLib/Lib/quopri.py diff --git a/src/extensions/StdLib/Lib/random.py b/src/core/IronPython.StdLib/Lib/random.py similarity index 100% rename from src/extensions/StdLib/Lib/random.py rename to src/core/IronPython.StdLib/Lib/random.py diff --git a/src/extensions/StdLib/Lib/re.py b/src/core/IronPython.StdLib/Lib/re.py similarity index 100% rename from src/extensions/StdLib/Lib/re.py rename to src/core/IronPython.StdLib/Lib/re.py diff --git a/src/extensions/StdLib/Lib/reprlib.py b/src/core/IronPython.StdLib/Lib/reprlib.py similarity index 100% rename from src/extensions/StdLib/Lib/reprlib.py rename to src/core/IronPython.StdLib/Lib/reprlib.py diff --git a/src/extensions/StdLib/Lib/rlcompleter.py b/src/core/IronPython.StdLib/Lib/rlcompleter.py similarity index 100% rename from src/extensions/StdLib/Lib/rlcompleter.py rename to src/core/IronPython.StdLib/Lib/rlcompleter.py diff --git a/src/extensions/StdLib/Lib/runpy.py b/src/core/IronPython.StdLib/Lib/runpy.py similarity index 100% rename from src/extensions/StdLib/Lib/runpy.py rename to src/core/IronPython.StdLib/Lib/runpy.py diff --git a/src/extensions/StdLib/Lib/sched.py b/src/core/IronPython.StdLib/Lib/sched.py similarity index 100% rename from src/extensions/StdLib/Lib/sched.py rename to src/core/IronPython.StdLib/Lib/sched.py diff --git a/src/extensions/StdLib/Lib/selectors.py b/src/core/IronPython.StdLib/Lib/selectors.py similarity index 100% rename from src/extensions/StdLib/Lib/selectors.py rename to src/core/IronPython.StdLib/Lib/selectors.py diff --git a/src/extensions/StdLib/Lib/shelve.py b/src/core/IronPython.StdLib/Lib/shelve.py similarity index 100% rename from src/extensions/StdLib/Lib/shelve.py rename to src/core/IronPython.StdLib/Lib/shelve.py diff --git a/src/extensions/StdLib/Lib/shlex.py b/src/core/IronPython.StdLib/Lib/shlex.py similarity index 100% rename from src/extensions/StdLib/Lib/shlex.py rename to src/core/IronPython.StdLib/Lib/shlex.py diff --git a/src/extensions/StdLib/Lib/shutil.py b/src/core/IronPython.StdLib/Lib/shutil.py similarity index 100% rename from src/extensions/StdLib/Lib/shutil.py rename to src/core/IronPython.StdLib/Lib/shutil.py diff --git a/src/extensions/StdLib/Lib/site-packages/README b/src/core/IronPython.StdLib/Lib/site-packages/README similarity index 100% rename from src/extensions/StdLib/Lib/site-packages/README rename to src/core/IronPython.StdLib/Lib/site-packages/README diff --git a/src/extensions/StdLib/Lib/site.py b/src/core/IronPython.StdLib/Lib/site.py similarity index 100% rename from src/extensions/StdLib/Lib/site.py rename to src/core/IronPython.StdLib/Lib/site.py diff --git a/src/extensions/StdLib/Lib/smtpd.py b/src/core/IronPython.StdLib/Lib/smtpd.py similarity index 100% rename from src/extensions/StdLib/Lib/smtpd.py rename to src/core/IronPython.StdLib/Lib/smtpd.py diff --git a/src/extensions/StdLib/Lib/smtplib.py b/src/core/IronPython.StdLib/Lib/smtplib.py similarity index 100% rename from src/extensions/StdLib/Lib/smtplib.py rename to src/core/IronPython.StdLib/Lib/smtplib.py diff --git a/src/extensions/StdLib/Lib/sndhdr.py b/src/core/IronPython.StdLib/Lib/sndhdr.py similarity index 100% rename from src/extensions/StdLib/Lib/sndhdr.py rename to src/core/IronPython.StdLib/Lib/sndhdr.py diff --git a/src/extensions/StdLib/Lib/socket.py b/src/core/IronPython.StdLib/Lib/socket.py similarity index 100% rename from src/extensions/StdLib/Lib/socket.py rename to src/core/IronPython.StdLib/Lib/socket.py diff --git a/src/extensions/StdLib/Lib/socketserver.py b/src/core/IronPython.StdLib/Lib/socketserver.py similarity index 100% rename from src/extensions/StdLib/Lib/socketserver.py rename to src/core/IronPython.StdLib/Lib/socketserver.py diff --git a/src/extensions/StdLib/Lib/sqlite3/__init__.py b/src/core/IronPython.StdLib/Lib/sqlite3/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/sqlite3/__init__.py rename to src/core/IronPython.StdLib/Lib/sqlite3/__init__.py diff --git a/src/extensions/StdLib/Lib/sqlite3/dbapi2.py b/src/core/IronPython.StdLib/Lib/sqlite3/dbapi2.py similarity index 100% rename from src/extensions/StdLib/Lib/sqlite3/dbapi2.py rename to src/core/IronPython.StdLib/Lib/sqlite3/dbapi2.py diff --git a/src/extensions/StdLib/Lib/sqlite3/dump.py b/src/core/IronPython.StdLib/Lib/sqlite3/dump.py similarity index 100% rename from src/extensions/StdLib/Lib/sqlite3/dump.py rename to src/core/IronPython.StdLib/Lib/sqlite3/dump.py diff --git a/src/extensions/StdLib/Lib/sqlite3/test/__init__.py b/src/core/IronPython.StdLib/Lib/sqlite3/test/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/sqlite3/test/__init__.py rename to src/core/IronPython.StdLib/Lib/sqlite3/test/__init__.py diff --git a/src/extensions/StdLib/Lib/sqlite3/test/dbapi.py b/src/core/IronPython.StdLib/Lib/sqlite3/test/dbapi.py similarity index 100% rename from src/extensions/StdLib/Lib/sqlite3/test/dbapi.py rename to src/core/IronPython.StdLib/Lib/sqlite3/test/dbapi.py diff --git a/src/extensions/StdLib/Lib/sqlite3/test/dump.py b/src/core/IronPython.StdLib/Lib/sqlite3/test/dump.py similarity index 100% rename from src/extensions/StdLib/Lib/sqlite3/test/dump.py rename to src/core/IronPython.StdLib/Lib/sqlite3/test/dump.py diff --git a/src/extensions/StdLib/Lib/sqlite3/test/factory.py b/src/core/IronPython.StdLib/Lib/sqlite3/test/factory.py similarity index 100% rename from src/extensions/StdLib/Lib/sqlite3/test/factory.py rename to src/core/IronPython.StdLib/Lib/sqlite3/test/factory.py diff --git a/src/extensions/StdLib/Lib/sqlite3/test/hooks.py b/src/core/IronPython.StdLib/Lib/sqlite3/test/hooks.py similarity index 100% rename from src/extensions/StdLib/Lib/sqlite3/test/hooks.py rename to src/core/IronPython.StdLib/Lib/sqlite3/test/hooks.py diff --git a/src/extensions/StdLib/Lib/sqlite3/test/regression.py b/src/core/IronPython.StdLib/Lib/sqlite3/test/regression.py similarity index 100% rename from src/extensions/StdLib/Lib/sqlite3/test/regression.py rename to src/core/IronPython.StdLib/Lib/sqlite3/test/regression.py diff --git a/src/extensions/StdLib/Lib/sqlite3/test/transactions.py b/src/core/IronPython.StdLib/Lib/sqlite3/test/transactions.py similarity index 100% rename from src/extensions/StdLib/Lib/sqlite3/test/transactions.py rename to src/core/IronPython.StdLib/Lib/sqlite3/test/transactions.py diff --git a/src/extensions/StdLib/Lib/sqlite3/test/types.py b/src/core/IronPython.StdLib/Lib/sqlite3/test/types.py similarity index 100% rename from src/extensions/StdLib/Lib/sqlite3/test/types.py rename to src/core/IronPython.StdLib/Lib/sqlite3/test/types.py diff --git a/src/extensions/StdLib/Lib/sqlite3/test/userfunctions.py b/src/core/IronPython.StdLib/Lib/sqlite3/test/userfunctions.py similarity index 100% rename from src/extensions/StdLib/Lib/sqlite3/test/userfunctions.py rename to src/core/IronPython.StdLib/Lib/sqlite3/test/userfunctions.py diff --git a/src/extensions/StdLib/Lib/sre_compile.py b/src/core/IronPython.StdLib/Lib/sre_compile.py similarity index 100% rename from src/extensions/StdLib/Lib/sre_compile.py rename to src/core/IronPython.StdLib/Lib/sre_compile.py diff --git a/src/extensions/StdLib/Lib/sre_constants.py b/src/core/IronPython.StdLib/Lib/sre_constants.py similarity index 100% rename from src/extensions/StdLib/Lib/sre_constants.py rename to src/core/IronPython.StdLib/Lib/sre_constants.py diff --git a/src/extensions/StdLib/Lib/sre_parse.py b/src/core/IronPython.StdLib/Lib/sre_parse.py similarity index 100% rename from src/extensions/StdLib/Lib/sre_parse.py rename to src/core/IronPython.StdLib/Lib/sre_parse.py diff --git a/src/extensions/StdLib/Lib/ssl.py b/src/core/IronPython.StdLib/Lib/ssl.py similarity index 100% rename from src/extensions/StdLib/Lib/ssl.py rename to src/core/IronPython.StdLib/Lib/ssl.py diff --git a/src/extensions/StdLib/Lib/stat.py b/src/core/IronPython.StdLib/Lib/stat.py similarity index 100% rename from src/extensions/StdLib/Lib/stat.py rename to src/core/IronPython.StdLib/Lib/stat.py diff --git a/src/extensions/StdLib/Lib/statistics.py b/src/core/IronPython.StdLib/Lib/statistics.py similarity index 100% rename from src/extensions/StdLib/Lib/statistics.py rename to src/core/IronPython.StdLib/Lib/statistics.py diff --git a/src/extensions/StdLib/Lib/string.py b/src/core/IronPython.StdLib/Lib/string.py similarity index 100% rename from src/extensions/StdLib/Lib/string.py rename to src/core/IronPython.StdLib/Lib/string.py diff --git a/src/extensions/StdLib/Lib/stringprep.py b/src/core/IronPython.StdLib/Lib/stringprep.py similarity index 100% rename from src/extensions/StdLib/Lib/stringprep.py rename to src/core/IronPython.StdLib/Lib/stringprep.py diff --git a/src/extensions/StdLib/Lib/struct.py b/src/core/IronPython.StdLib/Lib/struct.py similarity index 100% rename from src/extensions/StdLib/Lib/struct.py rename to src/core/IronPython.StdLib/Lib/struct.py diff --git a/src/extensions/StdLib/Lib/subprocess.py b/src/core/IronPython.StdLib/Lib/subprocess.py similarity index 100% rename from src/extensions/StdLib/Lib/subprocess.py rename to src/core/IronPython.StdLib/Lib/subprocess.py diff --git a/src/extensions/StdLib/Lib/sunau.py b/src/core/IronPython.StdLib/Lib/sunau.py similarity index 100% rename from src/extensions/StdLib/Lib/sunau.py rename to src/core/IronPython.StdLib/Lib/sunau.py diff --git a/src/extensions/StdLib/Lib/symbol.py b/src/core/IronPython.StdLib/Lib/symbol.py similarity index 100% rename from src/extensions/StdLib/Lib/symbol.py rename to src/core/IronPython.StdLib/Lib/symbol.py diff --git a/src/extensions/StdLib/Lib/symtable.py b/src/core/IronPython.StdLib/Lib/symtable.py similarity index 100% rename from src/extensions/StdLib/Lib/symtable.py rename to src/core/IronPython.StdLib/Lib/symtable.py diff --git a/src/extensions/StdLib/Lib/sysconfig.py b/src/core/IronPython.StdLib/Lib/sysconfig.py similarity index 100% rename from src/extensions/StdLib/Lib/sysconfig.py rename to src/core/IronPython.StdLib/Lib/sysconfig.py diff --git a/src/extensions/StdLib/Lib/tabnanny.py b/src/core/IronPython.StdLib/Lib/tabnanny.py similarity index 100% rename from src/extensions/StdLib/Lib/tabnanny.py rename to src/core/IronPython.StdLib/Lib/tabnanny.py diff --git a/src/extensions/StdLib/Lib/tarfile.py b/src/core/IronPython.StdLib/Lib/tarfile.py similarity index 100% rename from src/extensions/StdLib/Lib/tarfile.py rename to src/core/IronPython.StdLib/Lib/tarfile.py diff --git a/src/extensions/StdLib/Lib/telnetlib.py b/src/core/IronPython.StdLib/Lib/telnetlib.py similarity index 100% rename from src/extensions/StdLib/Lib/telnetlib.py rename to src/core/IronPython.StdLib/Lib/telnetlib.py diff --git a/src/extensions/StdLib/Lib/tempfile.py b/src/core/IronPython.StdLib/Lib/tempfile.py similarity index 100% rename from src/extensions/StdLib/Lib/tempfile.py rename to src/core/IronPython.StdLib/Lib/tempfile.py diff --git a/src/extensions/StdLib/Lib/test/185test.db b/src/core/IronPython.StdLib/Lib/test/185test.db similarity index 100% rename from src/extensions/StdLib/Lib/test/185test.db rename to src/core/IronPython.StdLib/Lib/test/185test.db diff --git a/src/extensions/StdLib/Lib/test/Sine-1000Hz-300ms.aif b/src/core/IronPython.StdLib/Lib/test/Sine-1000Hz-300ms.aif similarity index 100% rename from src/extensions/StdLib/Lib/test/Sine-1000Hz-300ms.aif rename to src/core/IronPython.StdLib/Lib/test/Sine-1000Hz-300ms.aif diff --git a/src/extensions/StdLib/Lib/test/__init__.py b/src/core/IronPython.StdLib/Lib/test/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/__init__.py rename to src/core/IronPython.StdLib/Lib/test/__init__.py diff --git a/src/extensions/StdLib/Lib/test/__main__.py b/src/core/IronPython.StdLib/Lib/test/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/__main__.py rename to src/core/IronPython.StdLib/Lib/test/__main__.py diff --git a/src/extensions/StdLib/Lib/test/_test_multiprocessing.py b/src/core/IronPython.StdLib/Lib/test/_test_multiprocessing.py similarity index 100% rename from src/extensions/StdLib/Lib/test/_test_multiprocessing.py rename to src/core/IronPython.StdLib/Lib/test/_test_multiprocessing.py diff --git a/src/extensions/StdLib/Lib/test/audiodata/pluck-alaw.aifc b/src/core/IronPython.StdLib/Lib/test/audiodata/pluck-alaw.aifc similarity index 100% rename from src/extensions/StdLib/Lib/test/audiodata/pluck-alaw.aifc rename to src/core/IronPython.StdLib/Lib/test/audiodata/pluck-alaw.aifc diff --git a/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm16.aiff b/src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm16.aiff similarity index 100% rename from src/extensions/StdLib/Lib/test/audiodata/pluck-pcm16.aiff rename to src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm16.aiff diff --git a/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm16.au b/src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm16.au similarity index 100% rename from src/extensions/StdLib/Lib/test/audiodata/pluck-pcm16.au rename to src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm16.au diff --git a/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm16.wav b/src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm16.wav similarity index 100% rename from src/extensions/StdLib/Lib/test/audiodata/pluck-pcm16.wav rename to src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm16.wav diff --git a/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm24.aiff b/src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm24.aiff similarity index 100% rename from src/extensions/StdLib/Lib/test/audiodata/pluck-pcm24.aiff rename to src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm24.aiff diff --git a/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm24.au b/src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm24.au similarity index 100% rename from src/extensions/StdLib/Lib/test/audiodata/pluck-pcm24.au rename to src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm24.au diff --git a/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm24.wav b/src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm24.wav similarity index 100% rename from src/extensions/StdLib/Lib/test/audiodata/pluck-pcm24.wav rename to src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm24.wav diff --git a/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm32.aiff b/src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm32.aiff similarity index 100% rename from src/extensions/StdLib/Lib/test/audiodata/pluck-pcm32.aiff rename to src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm32.aiff diff --git a/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm32.au b/src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm32.au similarity index 100% rename from src/extensions/StdLib/Lib/test/audiodata/pluck-pcm32.au rename to src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm32.au diff --git a/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm32.wav b/src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm32.wav similarity index 100% rename from src/extensions/StdLib/Lib/test/audiodata/pluck-pcm32.wav rename to src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm32.wav diff --git a/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm8.aiff b/src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm8.aiff similarity index 100% rename from src/extensions/StdLib/Lib/test/audiodata/pluck-pcm8.aiff rename to src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm8.aiff diff --git a/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm8.au b/src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm8.au similarity index 100% rename from src/extensions/StdLib/Lib/test/audiodata/pluck-pcm8.au rename to src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm8.au diff --git a/src/extensions/StdLib/Lib/test/audiodata/pluck-pcm8.wav b/src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm8.wav similarity index 100% rename from src/extensions/StdLib/Lib/test/audiodata/pluck-pcm8.wav rename to src/core/IronPython.StdLib/Lib/test/audiodata/pluck-pcm8.wav diff --git a/src/extensions/StdLib/Lib/test/audiodata/pluck-ulaw.aifc b/src/core/IronPython.StdLib/Lib/test/audiodata/pluck-ulaw.aifc similarity index 100% rename from src/extensions/StdLib/Lib/test/audiodata/pluck-ulaw.aifc rename to src/core/IronPython.StdLib/Lib/test/audiodata/pluck-ulaw.aifc diff --git a/src/extensions/StdLib/Lib/test/audiodata/pluck-ulaw.au b/src/core/IronPython.StdLib/Lib/test/audiodata/pluck-ulaw.au similarity index 100% rename from src/extensions/StdLib/Lib/test/audiodata/pluck-ulaw.au rename to src/core/IronPython.StdLib/Lib/test/audiodata/pluck-ulaw.au diff --git a/src/extensions/StdLib/Lib/test/audiotest.au b/src/core/IronPython.StdLib/Lib/test/audiotest.au similarity index 100% rename from src/extensions/StdLib/Lib/test/audiotest.au rename to src/core/IronPython.StdLib/Lib/test/audiotest.au diff --git a/src/extensions/StdLib/Lib/test/audiotests.py b/src/core/IronPython.StdLib/Lib/test/audiotests.py similarity index 100% rename from src/extensions/StdLib/Lib/test/audiotests.py rename to src/core/IronPython.StdLib/Lib/test/audiotests.py diff --git a/src/extensions/StdLib/Lib/test/autotest.py b/src/core/IronPython.StdLib/Lib/test/autotest.py similarity index 100% rename from src/extensions/StdLib/Lib/test/autotest.py rename to src/core/IronPython.StdLib/Lib/test/autotest.py diff --git a/src/extensions/StdLib/Lib/test/bad_coding.py b/src/core/IronPython.StdLib/Lib/test/bad_coding.py similarity index 100% rename from src/extensions/StdLib/Lib/test/bad_coding.py rename to src/core/IronPython.StdLib/Lib/test/bad_coding.py diff --git a/src/extensions/StdLib/Lib/test/bad_coding2.py b/src/core/IronPython.StdLib/Lib/test/bad_coding2.py similarity index 100% rename from src/extensions/StdLib/Lib/test/bad_coding2.py rename to src/core/IronPython.StdLib/Lib/test/bad_coding2.py diff --git a/src/extensions/StdLib/Lib/test/badcert.pem b/src/core/IronPython.StdLib/Lib/test/badcert.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/badcert.pem rename to src/core/IronPython.StdLib/Lib/test/badcert.pem diff --git a/src/extensions/StdLib/Lib/test/badkey.pem b/src/core/IronPython.StdLib/Lib/test/badkey.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/badkey.pem rename to src/core/IronPython.StdLib/Lib/test/badkey.pem diff --git a/src/extensions/StdLib/Lib/test/badsyntax_3131.py b/src/core/IronPython.StdLib/Lib/test/badsyntax_3131.py similarity index 100% rename from src/extensions/StdLib/Lib/test/badsyntax_3131.py rename to src/core/IronPython.StdLib/Lib/test/badsyntax_3131.py diff --git a/src/extensions/StdLib/Lib/test/badsyntax_future10.py b/src/core/IronPython.StdLib/Lib/test/badsyntax_future10.py similarity index 100% rename from src/extensions/StdLib/Lib/test/badsyntax_future10.py rename to src/core/IronPython.StdLib/Lib/test/badsyntax_future10.py diff --git a/src/extensions/StdLib/Lib/test/badsyntax_future3.py b/src/core/IronPython.StdLib/Lib/test/badsyntax_future3.py similarity index 100% rename from src/extensions/StdLib/Lib/test/badsyntax_future3.py rename to src/core/IronPython.StdLib/Lib/test/badsyntax_future3.py diff --git a/src/extensions/StdLib/Lib/test/badsyntax_future4.py b/src/core/IronPython.StdLib/Lib/test/badsyntax_future4.py similarity index 100% rename from src/extensions/StdLib/Lib/test/badsyntax_future4.py rename to src/core/IronPython.StdLib/Lib/test/badsyntax_future4.py diff --git a/src/extensions/StdLib/Lib/test/badsyntax_future5.py b/src/core/IronPython.StdLib/Lib/test/badsyntax_future5.py similarity index 100% rename from src/extensions/StdLib/Lib/test/badsyntax_future5.py rename to src/core/IronPython.StdLib/Lib/test/badsyntax_future5.py diff --git a/src/extensions/StdLib/Lib/test/badsyntax_future6.py b/src/core/IronPython.StdLib/Lib/test/badsyntax_future6.py similarity index 100% rename from src/extensions/StdLib/Lib/test/badsyntax_future6.py rename to src/core/IronPython.StdLib/Lib/test/badsyntax_future6.py diff --git a/src/extensions/StdLib/Lib/test/badsyntax_future7.py b/src/core/IronPython.StdLib/Lib/test/badsyntax_future7.py similarity index 100% rename from src/extensions/StdLib/Lib/test/badsyntax_future7.py rename to src/core/IronPython.StdLib/Lib/test/badsyntax_future7.py diff --git a/src/extensions/StdLib/Lib/test/badsyntax_future8.py b/src/core/IronPython.StdLib/Lib/test/badsyntax_future8.py similarity index 100% rename from src/extensions/StdLib/Lib/test/badsyntax_future8.py rename to src/core/IronPython.StdLib/Lib/test/badsyntax_future8.py diff --git a/src/extensions/StdLib/Lib/test/badsyntax_future9.py b/src/core/IronPython.StdLib/Lib/test/badsyntax_future9.py similarity index 100% rename from src/extensions/StdLib/Lib/test/badsyntax_future9.py rename to src/core/IronPython.StdLib/Lib/test/badsyntax_future9.py diff --git a/src/extensions/StdLib/Lib/test/badsyntax_pep3120.py b/src/core/IronPython.StdLib/Lib/test/badsyntax_pep3120.py similarity index 100% rename from src/extensions/StdLib/Lib/test/badsyntax_pep3120.py rename to src/core/IronPython.StdLib/Lib/test/badsyntax_pep3120.py diff --git a/src/extensions/StdLib/Lib/test/buffer_tests.py b/src/core/IronPython.StdLib/Lib/test/buffer_tests.py similarity index 100% rename from src/extensions/StdLib/Lib/test/buffer_tests.py rename to src/core/IronPython.StdLib/Lib/test/buffer_tests.py diff --git a/src/extensions/StdLib/Lib/test/bytecode_helper.py b/src/core/IronPython.StdLib/Lib/test/bytecode_helper.py similarity index 100% rename from src/extensions/StdLib/Lib/test/bytecode_helper.py rename to src/core/IronPython.StdLib/Lib/test/bytecode_helper.py diff --git a/src/extensions/StdLib/Lib/test/capath/0e4015b9.0 b/src/core/IronPython.StdLib/Lib/test/capath/0e4015b9.0 similarity index 100% rename from src/extensions/StdLib/Lib/test/capath/0e4015b9.0 rename to src/core/IronPython.StdLib/Lib/test/capath/0e4015b9.0 diff --git a/src/extensions/StdLib/Lib/test/capath/4e1295a3.0 b/src/core/IronPython.StdLib/Lib/test/capath/4e1295a3.0 similarity index 100% rename from src/extensions/StdLib/Lib/test/capath/4e1295a3.0 rename to src/core/IronPython.StdLib/Lib/test/capath/4e1295a3.0 diff --git a/src/extensions/StdLib/Lib/test/capath/5ed36f99.0 b/src/core/IronPython.StdLib/Lib/test/capath/5ed36f99.0 similarity index 100% rename from src/extensions/StdLib/Lib/test/capath/5ed36f99.0 rename to src/core/IronPython.StdLib/Lib/test/capath/5ed36f99.0 diff --git a/src/extensions/StdLib/Lib/test/capath/6e88d7b8.0 b/src/core/IronPython.StdLib/Lib/test/capath/6e88d7b8.0 similarity index 100% rename from src/extensions/StdLib/Lib/test/capath/6e88d7b8.0 rename to src/core/IronPython.StdLib/Lib/test/capath/6e88d7b8.0 diff --git a/src/extensions/StdLib/Lib/test/capath/99d0fa06.0 b/src/core/IronPython.StdLib/Lib/test/capath/99d0fa06.0 similarity index 100% rename from src/extensions/StdLib/Lib/test/capath/99d0fa06.0 rename to src/core/IronPython.StdLib/Lib/test/capath/99d0fa06.0 diff --git a/src/extensions/StdLib/Lib/test/capath/ce7b8643.0 b/src/core/IronPython.StdLib/Lib/test/capath/ce7b8643.0 similarity index 100% rename from src/extensions/StdLib/Lib/test/capath/ce7b8643.0 rename to src/core/IronPython.StdLib/Lib/test/capath/ce7b8643.0 diff --git a/src/extensions/StdLib/Lib/test/cfgparser.1 b/src/core/IronPython.StdLib/Lib/test/cfgparser.1 similarity index 100% rename from src/extensions/StdLib/Lib/test/cfgparser.1 rename to src/core/IronPython.StdLib/Lib/test/cfgparser.1 diff --git a/src/extensions/StdLib/Lib/test/cfgparser.2 b/src/core/IronPython.StdLib/Lib/test/cfgparser.2 similarity index 100% rename from src/extensions/StdLib/Lib/test/cfgparser.2 rename to src/core/IronPython.StdLib/Lib/test/cfgparser.2 diff --git a/src/extensions/StdLib/Lib/test/cfgparser.3 b/src/core/IronPython.StdLib/Lib/test/cfgparser.3 similarity index 100% rename from src/extensions/StdLib/Lib/test/cfgparser.3 rename to src/core/IronPython.StdLib/Lib/test/cfgparser.3 diff --git a/src/extensions/StdLib/Lib/test/check_soundcard.vbs b/src/core/IronPython.StdLib/Lib/test/check_soundcard.vbs similarity index 100% rename from src/extensions/StdLib/Lib/test/check_soundcard.vbs rename to src/core/IronPython.StdLib/Lib/test/check_soundcard.vbs diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/big5-utf8.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/big5-utf8.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/big5-utf8.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/big5-utf8.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/big5.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/big5.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/big5.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/big5.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/big5hkscs-utf8.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/big5hkscs.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/big5hkscs.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/big5hkscs.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/big5hkscs.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/cp949-utf8.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/cp949-utf8.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/cp949-utf8.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/cp949-utf8.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/cp949.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/cp949.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/cp949.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/cp949.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/euc_jisx0213-utf8.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/euc_jisx0213.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/euc_jisx0213.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/euc_jisx0213.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/euc_jp-utf8.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/euc_jp.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/euc_jp.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/euc_jp.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/euc_jp.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/euc_kr-utf8.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/euc_kr.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/euc_kr.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/euc_kr.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/euc_kr.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/gb18030-utf8.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/gb18030-utf8.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/gb18030-utf8.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/gb18030.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/gb18030.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/gb18030.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/gb18030.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/gb2312-utf8.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/gb2312-utf8.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/gb2312-utf8.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/gb2312.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/gb2312.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/gb2312.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/gb2312.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/gbk-utf8.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/gbk-utf8.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/gbk-utf8.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/gbk-utf8.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/gbk.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/gbk.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/gbk.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/gbk.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/hz-utf8.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/hz-utf8.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/hz-utf8.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/hz-utf8.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/hz.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/hz.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/hz.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/hz.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/iso2022_jp-utf8.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/iso2022_jp.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/iso2022_jp.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/iso2022_jp.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/iso2022_jp.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/iso2022_kr-utf8.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/iso2022_kr.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/iso2022_kr.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/iso2022_kr.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/iso2022_kr.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/johab-utf8.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/johab-utf8.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/johab-utf8.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/johab-utf8.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/johab.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/johab.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/johab.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/johab.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/shift_jis-utf8.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/shift_jis.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/shift_jis.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/shift_jis.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/shift_jis.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/shift_jisx0213-utf8.txt diff --git a/src/extensions/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt b/src/core/IronPython.StdLib/Lib/test/cjkencodings/shift_jisx0213.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cjkencodings/shift_jisx0213.txt rename to src/core/IronPython.StdLib/Lib/test/cjkencodings/shift_jisx0213.txt diff --git a/src/extensions/StdLib/Lib/test/cmath_testcases.txt b/src/core/IronPython.StdLib/Lib/test/cmath_testcases.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/cmath_testcases.txt rename to src/core/IronPython.StdLib/Lib/test/cmath_testcases.txt diff --git a/src/extensions/StdLib/Lib/test/coding20731.py b/src/core/IronPython.StdLib/Lib/test/coding20731.py similarity index 100% rename from src/extensions/StdLib/Lib/test/coding20731.py rename to src/core/IronPython.StdLib/Lib/test/coding20731.py diff --git a/src/extensions/StdLib/Lib/test/crashers/README b/src/core/IronPython.StdLib/Lib/test/crashers/README similarity index 100% rename from src/extensions/StdLib/Lib/test/crashers/README rename to src/core/IronPython.StdLib/Lib/test/crashers/README diff --git a/src/extensions/StdLib/Lib/test/crashers/bogus_code_obj.py b/src/core/IronPython.StdLib/Lib/test/crashers/bogus_code_obj.py similarity index 100% rename from src/extensions/StdLib/Lib/test/crashers/bogus_code_obj.py rename to src/core/IronPython.StdLib/Lib/test/crashers/bogus_code_obj.py diff --git a/src/extensions/StdLib/Lib/test/crashers/gc_inspection.py b/src/core/IronPython.StdLib/Lib/test/crashers/gc_inspection.py similarity index 100% rename from src/extensions/StdLib/Lib/test/crashers/gc_inspection.py rename to src/core/IronPython.StdLib/Lib/test/crashers/gc_inspection.py diff --git a/src/extensions/StdLib/Lib/test/crashers/infinite_loop_re.py b/src/core/IronPython.StdLib/Lib/test/crashers/infinite_loop_re.py similarity index 100% rename from src/extensions/StdLib/Lib/test/crashers/infinite_loop_re.py rename to src/core/IronPython.StdLib/Lib/test/crashers/infinite_loop_re.py diff --git a/src/extensions/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py b/src/core/IronPython.StdLib/Lib/test/crashers/mutation_inside_cyclegc.py similarity index 100% rename from src/extensions/StdLib/Lib/test/crashers/mutation_inside_cyclegc.py rename to src/core/IronPython.StdLib/Lib/test/crashers/mutation_inside_cyclegc.py diff --git a/src/extensions/StdLib/Lib/test/crashers/recursive_call.py b/src/core/IronPython.StdLib/Lib/test/crashers/recursive_call.py similarity index 100% rename from src/extensions/StdLib/Lib/test/crashers/recursive_call.py rename to src/core/IronPython.StdLib/Lib/test/crashers/recursive_call.py diff --git a/src/extensions/StdLib/Lib/test/crashers/trace_at_recursion_limit.py b/src/core/IronPython.StdLib/Lib/test/crashers/trace_at_recursion_limit.py similarity index 100% rename from src/extensions/StdLib/Lib/test/crashers/trace_at_recursion_limit.py rename to src/core/IronPython.StdLib/Lib/test/crashers/trace_at_recursion_limit.py diff --git a/src/extensions/StdLib/Lib/test/crashers/underlying_dict.py b/src/core/IronPython.StdLib/Lib/test/crashers/underlying_dict.py similarity index 100% rename from src/extensions/StdLib/Lib/test/crashers/underlying_dict.py rename to src/core/IronPython.StdLib/Lib/test/crashers/underlying_dict.py diff --git a/src/extensions/StdLib/Lib/test/curses_tests.py b/src/core/IronPython.StdLib/Lib/test/curses_tests.py similarity index 100% rename from src/extensions/StdLib/Lib/test/curses_tests.py rename to src/core/IronPython.StdLib/Lib/test/curses_tests.py diff --git a/src/extensions/StdLib/Lib/test/data/README b/src/core/IronPython.StdLib/Lib/test/data/README similarity index 100% rename from src/extensions/StdLib/Lib/test/data/README rename to src/core/IronPython.StdLib/Lib/test/data/README diff --git a/src/extensions/StdLib/Lib/test/datetimetester.py b/src/core/IronPython.StdLib/Lib/test/datetimetester.py similarity index 100% rename from src/extensions/StdLib/Lib/test/datetimetester.py rename to src/core/IronPython.StdLib/Lib/test/datetimetester.py diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/abs.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/abs.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/abs.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/abs.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/add.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/add.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/add.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/add.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/and.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/and.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/and.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/and.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/base.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/base.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/base.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/base.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/clamp.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/clamp.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/clamp.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/clamp.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/class.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/class.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/class.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/class.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/compare.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/compare.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/compare.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/compare.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/comparetotal.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/comparetotal.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/comparetotal.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/comparetotal.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/comparetotmag.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/comparetotmag.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/comparetotmag.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/copy.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/copy.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/copy.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/copy.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/copyabs.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/copyabs.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/copyabs.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/copyabs.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/copynegate.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/copynegate.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/copynegate.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/copynegate.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/copysign.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/copysign.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/copysign.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/copysign.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddAbs.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddAbs.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddAbs.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddAbs.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddAdd.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddAdd.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddAdd.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddAdd.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddAnd.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddAnd.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddAnd.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddAnd.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddBase.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddBase.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddBase.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddBase.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddCanonical.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddCanonical.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddCanonical.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddClass.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddClass.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddClass.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddClass.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddCompare.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddCompare.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddCompare.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddCompare.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddCompareSig.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddCompareTotal.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddCompareTotalMag.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddCopy.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddCopy.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddCopy.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddCopy.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddCopyAbs.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddCopyNegate.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddCopySign.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddCopySign.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddCopySign.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddDivide.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddDivide.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddDivide.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddDivide.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddDivideInt.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddEncode.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddEncode.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddEncode.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddEncode.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddFMA.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddFMA.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddFMA.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddFMA.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddInvert.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddInvert.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddInvert.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddInvert.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddLogB.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddLogB.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddLogB.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddLogB.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddMax.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddMax.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddMax.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddMax.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddMaxMag.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddMin.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddMin.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddMin.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddMin.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddMinMag.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddMinMag.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddMinMag.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddMinus.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddMinus.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddMinus.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddMinus.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddMultiply.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddMultiply.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddMultiply.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddNextMinus.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddNextPlus.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddNextToward.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddNextToward.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddNextToward.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddOr.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddOr.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddOr.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddOr.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddPlus.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddPlus.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddPlus.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddPlus.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddQuantize.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddQuantize.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddQuantize.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddReduce.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddReduce.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddReduce.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddReduce.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddRemainder.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddRemainder.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddRemainder.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddRemainderNear.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddRotate.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddRotate.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddRotate.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddRotate.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddSameQuantum.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddScaleB.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddScaleB.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddScaleB.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddShift.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddShift.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddShift.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddShift.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddSubtract.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddSubtract.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddSubtract.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddToIntegral.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ddXor.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddXor.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ddXor.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ddXor.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/decDouble.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/decDouble.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/decDouble.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/decDouble.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/decQuad.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/decQuad.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/decQuad.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/decQuad.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/decSingle.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/decSingle.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/decSingle.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/decSingle.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/divide.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/divide.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/divide.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/divide.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/divideint.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/divideint.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/divideint.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/divideint.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqAbs.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqAbs.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqAbs.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqAbs.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqAdd.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqAdd.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqAdd.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqAdd.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqAnd.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqAnd.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqAnd.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqAnd.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqBase.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqBase.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqBase.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqBase.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqCanonical.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqCanonical.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqCanonical.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqClass.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqClass.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqClass.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqClass.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqCompare.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqCompare.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqCompare.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqCompare.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqCompareSig.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqCompareTotal.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqCompareTotalMag.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqCopy.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqCopy.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqCopy.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqCopy.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqCopyAbs.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqCopyNegate.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqCopySign.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqCopySign.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqCopySign.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqDivide.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqDivide.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqDivide.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqDivide.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqDivideInt.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqEncode.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqEncode.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqEncode.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqEncode.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqFMA.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqFMA.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqFMA.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqFMA.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqInvert.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqInvert.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqInvert.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqInvert.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqLogB.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqLogB.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqLogB.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqLogB.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqMax.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqMax.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqMax.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqMax.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqMaxMag.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqMin.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqMin.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqMin.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqMin.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqMinMag.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqMinMag.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqMinMag.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqMinus.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqMinus.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqMinus.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqMinus.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqMultiply.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqMultiply.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqMultiply.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqNextMinus.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqNextPlus.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqNextToward.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqNextToward.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqNextToward.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqOr.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqOr.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqOr.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqOr.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqPlus.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqPlus.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqPlus.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqPlus.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqQuantize.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqQuantize.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqQuantize.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqReduce.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqReduce.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqReduce.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqReduce.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqRemainder.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqRemainder.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqRemainder.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqRemainderNear.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqRotate.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqRotate.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqRotate.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqRotate.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqSameQuantum.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqScaleB.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqScaleB.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqScaleB.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqShift.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqShift.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqShift.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqShift.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqSubtract.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqSubtract.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqSubtract.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqToIntegral.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dqXor.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqXor.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dqXor.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dqXor.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dsBase.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dsBase.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dsBase.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dsBase.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/dsEncode.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/dsEncode.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/dsEncode.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/dsEncode.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/exp.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/exp.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/exp.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/exp.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/extra.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/extra.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/extra.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/extra.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/fma.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/fma.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/fma.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/fma.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/inexact.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/inexact.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/inexact.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/inexact.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/invert.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/invert.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/invert.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/invert.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/ln.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/ln.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/ln.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/ln.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/log10.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/log10.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/log10.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/log10.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/logb.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/logb.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/logb.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/logb.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/max.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/max.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/max.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/max.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/maxmag.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/maxmag.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/maxmag.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/maxmag.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/min.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/min.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/min.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/min.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/minmag.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/minmag.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/minmag.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/minmag.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/minus.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/minus.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/minus.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/minus.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/multiply.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/multiply.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/multiply.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/multiply.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/nextminus.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/nextminus.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/nextminus.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/nextminus.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/nextplus.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/nextplus.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/nextplus.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/nextplus.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/nexttoward.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/nexttoward.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/nexttoward.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/nexttoward.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/or.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/or.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/or.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/or.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/plus.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/plus.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/plus.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/plus.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/power.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/power.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/power.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/power.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/powersqrt.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/powersqrt.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/powersqrt.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/powersqrt.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/quantize.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/quantize.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/quantize.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/quantize.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/randomBound32.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/randomBound32.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/randomBound32.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/randomBound32.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/randoms.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/randoms.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/randoms.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/randoms.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/reduce.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/reduce.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/reduce.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/reduce.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/remainder.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/remainder.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/remainder.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/remainder.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/remainderNear.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/remainderNear.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/remainderNear.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/remainderNear.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/rescale.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/rescale.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/rescale.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/rescale.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/rotate.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/rotate.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/rotate.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/rotate.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/rounding.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/rounding.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/rounding.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/rounding.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/samequantum.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/samequantum.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/samequantum.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/samequantum.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/scaleb.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/scaleb.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/scaleb.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/scaleb.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/shift.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/shift.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/shift.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/shift.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/squareroot.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/squareroot.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/squareroot.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/squareroot.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/subtract.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/subtract.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/subtract.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/subtract.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/testall.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/testall.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/testall.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/testall.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/tointegral.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/tointegral.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/tointegral.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/tointegral.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/tointegralx.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/tointegralx.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/tointegralx.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/tointegralx.decTest diff --git a/src/extensions/StdLib/Lib/test/decimaltestdata/xor.decTest b/src/core/IronPython.StdLib/Lib/test/decimaltestdata/xor.decTest similarity index 100% rename from src/extensions/StdLib/Lib/test/decimaltestdata/xor.decTest rename to src/core/IronPython.StdLib/Lib/test/decimaltestdata/xor.decTest diff --git a/src/extensions/StdLib/Lib/test/dh1024.pem b/src/core/IronPython.StdLib/Lib/test/dh1024.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/dh1024.pem rename to src/core/IronPython.StdLib/Lib/test/dh1024.pem diff --git a/src/extensions/StdLib/Lib/test/dis_module.py b/src/core/IronPython.StdLib/Lib/test/dis_module.py similarity index 100% rename from src/extensions/StdLib/Lib/test/dis_module.py rename to src/core/IronPython.StdLib/Lib/test/dis_module.py diff --git a/src/extensions/StdLib/Lib/test/doctest_aliases.py b/src/core/IronPython.StdLib/Lib/test/doctest_aliases.py similarity index 100% rename from src/extensions/StdLib/Lib/test/doctest_aliases.py rename to src/core/IronPython.StdLib/Lib/test/doctest_aliases.py diff --git a/src/extensions/StdLib/Lib/test/double_const.py b/src/core/IronPython.StdLib/Lib/test/double_const.py similarity index 100% rename from src/extensions/StdLib/Lib/test/double_const.py rename to src/core/IronPython.StdLib/Lib/test/double_const.py diff --git a/src/extensions/StdLib/Lib/test/empty.vbs b/src/core/IronPython.StdLib/Lib/test/empty.vbs similarity index 100% rename from src/extensions/StdLib/Lib/test/empty.vbs rename to src/core/IronPython.StdLib/Lib/test/empty.vbs diff --git a/src/extensions/StdLib/Lib/test/encoded_modules/__init__.py b/src/core/IronPython.StdLib/Lib/test/encoded_modules/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/encoded_modules/__init__.py rename to src/core/IronPython.StdLib/Lib/test/encoded_modules/__init__.py diff --git a/src/extensions/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py b/src/core/IronPython.StdLib/Lib/test/encoded_modules/module_iso_8859_1.py similarity index 100% rename from src/extensions/StdLib/Lib/test/encoded_modules/module_iso_8859_1.py rename to src/core/IronPython.StdLib/Lib/test/encoded_modules/module_iso_8859_1.py diff --git a/src/extensions/StdLib/Lib/test/encoded_modules/module_koi8_r.py b/src/core/IronPython.StdLib/Lib/test/encoded_modules/module_koi8_r.py similarity index 100% rename from src/extensions/StdLib/Lib/test/encoded_modules/module_koi8_r.py rename to src/core/IronPython.StdLib/Lib/test/encoded_modules/module_koi8_r.py diff --git a/src/extensions/StdLib/Lib/test/exception_hierarchy.txt b/src/core/IronPython.StdLib/Lib/test/exception_hierarchy.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/exception_hierarchy.txt rename to src/core/IronPython.StdLib/Lib/test/exception_hierarchy.txt diff --git a/src/extensions/StdLib/Lib/test/final_a.py b/src/core/IronPython.StdLib/Lib/test/final_a.py similarity index 100% rename from src/extensions/StdLib/Lib/test/final_a.py rename to src/core/IronPython.StdLib/Lib/test/final_a.py diff --git a/src/extensions/StdLib/Lib/test/final_b.py b/src/core/IronPython.StdLib/Lib/test/final_b.py similarity index 100% rename from src/extensions/StdLib/Lib/test/final_b.py rename to src/core/IronPython.StdLib/Lib/test/final_b.py diff --git a/src/extensions/StdLib/Lib/test/floating_points.txt b/src/core/IronPython.StdLib/Lib/test/floating_points.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/floating_points.txt rename to src/core/IronPython.StdLib/Lib/test/floating_points.txt diff --git a/src/extensions/StdLib/Lib/test/fork_wait.py b/src/core/IronPython.StdLib/Lib/test/fork_wait.py similarity index 100% rename from src/extensions/StdLib/Lib/test/fork_wait.py rename to src/core/IronPython.StdLib/Lib/test/fork_wait.py diff --git a/src/extensions/StdLib/Lib/test/formatfloat_testcases.txt b/src/core/IronPython.StdLib/Lib/test/formatfloat_testcases.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/formatfloat_testcases.txt rename to src/core/IronPython.StdLib/Lib/test/formatfloat_testcases.txt diff --git a/src/extensions/StdLib/Lib/test/future_test1.py b/src/core/IronPython.StdLib/Lib/test/future_test1.py similarity index 100% rename from src/extensions/StdLib/Lib/test/future_test1.py rename to src/core/IronPython.StdLib/Lib/test/future_test1.py diff --git a/src/extensions/StdLib/Lib/test/future_test2.py b/src/core/IronPython.StdLib/Lib/test/future_test2.py similarity index 100% rename from src/extensions/StdLib/Lib/test/future_test2.py rename to src/core/IronPython.StdLib/Lib/test/future_test2.py diff --git a/src/extensions/StdLib/Lib/test/gdb_sample.py b/src/core/IronPython.StdLib/Lib/test/gdb_sample.py similarity index 100% rename from src/extensions/StdLib/Lib/test/gdb_sample.py rename to src/core/IronPython.StdLib/Lib/test/gdb_sample.py diff --git a/src/extensions/StdLib/Lib/test/ieee754.txt b/src/core/IronPython.StdLib/Lib/test/ieee754.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/ieee754.txt rename to src/core/IronPython.StdLib/Lib/test/ieee754.txt diff --git a/src/extensions/StdLib/Lib/test/imghdrdata/python.bmp b/src/core/IronPython.StdLib/Lib/test/imghdrdata/python.bmp similarity index 100% rename from src/extensions/StdLib/Lib/test/imghdrdata/python.bmp rename to src/core/IronPython.StdLib/Lib/test/imghdrdata/python.bmp diff --git a/src/extensions/StdLib/Lib/test/imghdrdata/python.gif b/src/core/IronPython.StdLib/Lib/test/imghdrdata/python.gif similarity index 100% rename from src/extensions/StdLib/Lib/test/imghdrdata/python.gif rename to src/core/IronPython.StdLib/Lib/test/imghdrdata/python.gif diff --git a/src/extensions/StdLib/Lib/test/imghdrdata/python.jpg b/src/core/IronPython.StdLib/Lib/test/imghdrdata/python.jpg similarity index 100% rename from src/extensions/StdLib/Lib/test/imghdrdata/python.jpg rename to src/core/IronPython.StdLib/Lib/test/imghdrdata/python.jpg diff --git a/src/extensions/StdLib/Lib/test/imghdrdata/python.pbm b/src/core/IronPython.StdLib/Lib/test/imghdrdata/python.pbm similarity index 100% rename from src/extensions/StdLib/Lib/test/imghdrdata/python.pbm rename to src/core/IronPython.StdLib/Lib/test/imghdrdata/python.pbm diff --git a/src/extensions/StdLib/Lib/test/imghdrdata/python.pgm b/src/core/IronPython.StdLib/Lib/test/imghdrdata/python.pgm similarity index 100% rename from src/extensions/StdLib/Lib/test/imghdrdata/python.pgm rename to src/core/IronPython.StdLib/Lib/test/imghdrdata/python.pgm diff --git a/src/extensions/StdLib/Lib/test/imghdrdata/python.png b/src/core/IronPython.StdLib/Lib/test/imghdrdata/python.png similarity index 100% rename from src/extensions/StdLib/Lib/test/imghdrdata/python.png rename to src/core/IronPython.StdLib/Lib/test/imghdrdata/python.png diff --git a/src/extensions/StdLib/Lib/test/imghdrdata/python.ppm b/src/core/IronPython.StdLib/Lib/test/imghdrdata/python.ppm similarity index 100% rename from src/extensions/StdLib/Lib/test/imghdrdata/python.ppm rename to src/core/IronPython.StdLib/Lib/test/imghdrdata/python.ppm diff --git a/src/extensions/StdLib/Lib/test/imghdrdata/python.ras b/src/core/IronPython.StdLib/Lib/test/imghdrdata/python.ras similarity index 100% rename from src/extensions/StdLib/Lib/test/imghdrdata/python.ras rename to src/core/IronPython.StdLib/Lib/test/imghdrdata/python.ras diff --git a/src/extensions/StdLib/Lib/test/imghdrdata/python.sgi b/src/core/IronPython.StdLib/Lib/test/imghdrdata/python.sgi similarity index 100% rename from src/extensions/StdLib/Lib/test/imghdrdata/python.sgi rename to src/core/IronPython.StdLib/Lib/test/imghdrdata/python.sgi diff --git a/src/extensions/StdLib/Lib/test/imghdrdata/python.tiff b/src/core/IronPython.StdLib/Lib/test/imghdrdata/python.tiff similarity index 100% rename from src/extensions/StdLib/Lib/test/imghdrdata/python.tiff rename to src/core/IronPython.StdLib/Lib/test/imghdrdata/python.tiff diff --git a/src/extensions/StdLib/Lib/test/imghdrdata/python.xbm b/src/core/IronPython.StdLib/Lib/test/imghdrdata/python.xbm similarity index 100% rename from src/extensions/StdLib/Lib/test/imghdrdata/python.xbm rename to src/core/IronPython.StdLib/Lib/test/imghdrdata/python.xbm diff --git a/src/extensions/StdLib/Lib/test/inspect_fodder.py b/src/core/IronPython.StdLib/Lib/test/inspect_fodder.py similarity index 100% rename from src/extensions/StdLib/Lib/test/inspect_fodder.py rename to src/core/IronPython.StdLib/Lib/test/inspect_fodder.py diff --git a/src/extensions/StdLib/Lib/test/inspect_fodder2.py b/src/core/IronPython.StdLib/Lib/test/inspect_fodder2.py similarity index 100% rename from src/extensions/StdLib/Lib/test/inspect_fodder2.py rename to src/core/IronPython.StdLib/Lib/test/inspect_fodder2.py diff --git a/src/extensions/StdLib/Lib/test/keycert.passwd.pem b/src/core/IronPython.StdLib/Lib/test/keycert.passwd.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/keycert.passwd.pem rename to src/core/IronPython.StdLib/Lib/test/keycert.passwd.pem diff --git a/src/extensions/StdLib/Lib/test/keycert.pem b/src/core/IronPython.StdLib/Lib/test/keycert.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/keycert.pem rename to src/core/IronPython.StdLib/Lib/test/keycert.pem diff --git a/src/extensions/StdLib/Lib/test/keycert2.pem b/src/core/IronPython.StdLib/Lib/test/keycert2.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/keycert2.pem rename to src/core/IronPython.StdLib/Lib/test/keycert2.pem diff --git a/src/extensions/StdLib/Lib/test/keycert3.pem b/src/core/IronPython.StdLib/Lib/test/keycert3.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/keycert3.pem rename to src/core/IronPython.StdLib/Lib/test/keycert3.pem diff --git a/src/extensions/StdLib/Lib/test/keycert4.pem b/src/core/IronPython.StdLib/Lib/test/keycert4.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/keycert4.pem rename to src/core/IronPython.StdLib/Lib/test/keycert4.pem diff --git a/src/extensions/StdLib/Lib/test/leakers/README.txt b/src/core/IronPython.StdLib/Lib/test/leakers/README.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/leakers/README.txt rename to src/core/IronPython.StdLib/Lib/test/leakers/README.txt diff --git a/src/extensions/StdLib/Lib/test/leakers/__init__.py b/src/core/IronPython.StdLib/Lib/test/leakers/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/leakers/__init__.py rename to src/core/IronPython.StdLib/Lib/test/leakers/__init__.py diff --git a/src/extensions/StdLib/Lib/test/leakers/test_ctypes.py b/src/core/IronPython.StdLib/Lib/test/leakers/test_ctypes.py similarity index 100% rename from src/extensions/StdLib/Lib/test/leakers/test_ctypes.py rename to src/core/IronPython.StdLib/Lib/test/leakers/test_ctypes.py diff --git a/src/extensions/StdLib/Lib/test/leakers/test_selftype.py b/src/core/IronPython.StdLib/Lib/test/leakers/test_selftype.py similarity index 100% rename from src/extensions/StdLib/Lib/test/leakers/test_selftype.py rename to src/core/IronPython.StdLib/Lib/test/leakers/test_selftype.py diff --git a/src/extensions/StdLib/Lib/test/list_tests.py b/src/core/IronPython.StdLib/Lib/test/list_tests.py similarity index 100% rename from src/extensions/StdLib/Lib/test/list_tests.py rename to src/core/IronPython.StdLib/Lib/test/list_tests.py diff --git a/src/extensions/StdLib/Lib/test/lock_tests.py b/src/core/IronPython.StdLib/Lib/test/lock_tests.py similarity index 100% rename from src/extensions/StdLib/Lib/test/lock_tests.py rename to src/core/IronPython.StdLib/Lib/test/lock_tests.py diff --git a/src/extensions/StdLib/Lib/test/mailcap.txt b/src/core/IronPython.StdLib/Lib/test/mailcap.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/mailcap.txt rename to src/core/IronPython.StdLib/Lib/test/mailcap.txt diff --git a/src/extensions/StdLib/Lib/test/make_ssl_certs.py b/src/core/IronPython.StdLib/Lib/test/make_ssl_certs.py similarity index 100% rename from src/extensions/StdLib/Lib/test/make_ssl_certs.py rename to src/core/IronPython.StdLib/Lib/test/make_ssl_certs.py diff --git a/src/extensions/StdLib/Lib/test/mapping_tests.py b/src/core/IronPython.StdLib/Lib/test/mapping_tests.py similarity index 100% rename from src/extensions/StdLib/Lib/test/mapping_tests.py rename to src/core/IronPython.StdLib/Lib/test/mapping_tests.py diff --git a/src/extensions/StdLib/Lib/test/math_testcases.txt b/src/core/IronPython.StdLib/Lib/test/math_testcases.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/math_testcases.txt rename to src/core/IronPython.StdLib/Lib/test/math_testcases.txt diff --git a/src/extensions/StdLib/Lib/test/memory_watchdog.py b/src/core/IronPython.StdLib/Lib/test/memory_watchdog.py similarity index 100% rename from src/extensions/StdLib/Lib/test/memory_watchdog.py rename to src/core/IronPython.StdLib/Lib/test/memory_watchdog.py diff --git a/src/extensions/StdLib/Lib/test/mime.types b/src/core/IronPython.StdLib/Lib/test/mime.types similarity index 100% rename from src/extensions/StdLib/Lib/test/mime.types rename to src/core/IronPython.StdLib/Lib/test/mime.types diff --git a/src/extensions/StdLib/Lib/test/mock_socket.py b/src/core/IronPython.StdLib/Lib/test/mock_socket.py similarity index 100% rename from src/extensions/StdLib/Lib/test/mock_socket.py rename to src/core/IronPython.StdLib/Lib/test/mock_socket.py diff --git a/src/extensions/StdLib/Lib/test/mod_generics_cache.py b/src/core/IronPython.StdLib/Lib/test/mod_generics_cache.py similarity index 100% rename from src/extensions/StdLib/Lib/test/mod_generics_cache.py rename to src/core/IronPython.StdLib/Lib/test/mod_generics_cache.py diff --git a/src/extensions/StdLib/Lib/test/mp_fork_bomb.py b/src/core/IronPython.StdLib/Lib/test/mp_fork_bomb.py similarity index 100% rename from src/extensions/StdLib/Lib/test/mp_fork_bomb.py rename to src/core/IronPython.StdLib/Lib/test/mp_fork_bomb.py diff --git a/src/extensions/StdLib/Lib/test/multibytecodec_support.py b/src/core/IronPython.StdLib/Lib/test/multibytecodec_support.py similarity index 100% rename from src/extensions/StdLib/Lib/test/multibytecodec_support.py rename to src/core/IronPython.StdLib/Lib/test/multibytecodec_support.py diff --git a/src/extensions/StdLib/Lib/test/nokia.pem b/src/core/IronPython.StdLib/Lib/test/nokia.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/nokia.pem rename to src/core/IronPython.StdLib/Lib/test/nokia.pem diff --git a/src/extensions/StdLib/Lib/test/nullbytecert.pem b/src/core/IronPython.StdLib/Lib/test/nullbytecert.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/nullbytecert.pem rename to src/core/IronPython.StdLib/Lib/test/nullbytecert.pem diff --git a/src/extensions/StdLib/Lib/test/nullcert.pem b/src/core/IronPython.StdLib/Lib/test/nullcert.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/nullcert.pem rename to src/core/IronPython.StdLib/Lib/test/nullcert.pem diff --git a/src/extensions/StdLib/Lib/test/outstanding_bugs.py b/src/core/IronPython.StdLib/Lib/test/outstanding_bugs.py similarity index 100% rename from src/extensions/StdLib/Lib/test/outstanding_bugs.py rename to src/core/IronPython.StdLib/Lib/test/outstanding_bugs.py diff --git a/src/extensions/StdLib/Lib/test/pickletester.py b/src/core/IronPython.StdLib/Lib/test/pickletester.py similarity index 100% rename from src/extensions/StdLib/Lib/test/pickletester.py rename to src/core/IronPython.StdLib/Lib/test/pickletester.py diff --git a/src/extensions/StdLib/Lib/test/profilee.py b/src/core/IronPython.StdLib/Lib/test/profilee.py similarity index 100% rename from src/extensions/StdLib/Lib/test/profilee.py rename to src/core/IronPython.StdLib/Lib/test/profilee.py diff --git a/src/extensions/StdLib/Lib/test/pstats.pck b/src/core/IronPython.StdLib/Lib/test/pstats.pck similarity index 100% rename from src/extensions/StdLib/Lib/test/pstats.pck rename to src/core/IronPython.StdLib/Lib/test/pstats.pck diff --git a/src/extensions/StdLib/Lib/test/pycacert.pem b/src/core/IronPython.StdLib/Lib/test/pycacert.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/pycacert.pem rename to src/core/IronPython.StdLib/Lib/test/pycacert.pem diff --git a/src/extensions/StdLib/Lib/test/pycakey.pem b/src/core/IronPython.StdLib/Lib/test/pycakey.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/pycakey.pem rename to src/core/IronPython.StdLib/Lib/test/pycakey.pem diff --git a/src/extensions/StdLib/Lib/test/pyclbr_input.py b/src/core/IronPython.StdLib/Lib/test/pyclbr_input.py similarity index 100% rename from src/extensions/StdLib/Lib/test/pyclbr_input.py rename to src/core/IronPython.StdLib/Lib/test/pyclbr_input.py diff --git a/src/extensions/StdLib/Lib/test/pydoc_mod.py b/src/core/IronPython.StdLib/Lib/test/pydoc_mod.py similarity index 100% rename from src/extensions/StdLib/Lib/test/pydoc_mod.py rename to src/core/IronPython.StdLib/Lib/test/pydoc_mod.py diff --git a/src/extensions/StdLib/Lib/test/pydocfodder.py b/src/core/IronPython.StdLib/Lib/test/pydocfodder.py similarity index 100% rename from src/extensions/StdLib/Lib/test/pydocfodder.py rename to src/core/IronPython.StdLib/Lib/test/pydocfodder.py diff --git a/src/extensions/StdLib/Lib/test/pystone.py b/src/core/IronPython.StdLib/Lib/test/pystone.py similarity index 100% rename from src/extensions/StdLib/Lib/test/pystone.py rename to src/core/IronPython.StdLib/Lib/test/pystone.py diff --git a/src/extensions/StdLib/Lib/test/randv2_32.pck b/src/core/IronPython.StdLib/Lib/test/randv2_32.pck similarity index 100% rename from src/extensions/StdLib/Lib/test/randv2_32.pck rename to src/core/IronPython.StdLib/Lib/test/randv2_32.pck diff --git a/src/extensions/StdLib/Lib/test/randv2_64.pck b/src/core/IronPython.StdLib/Lib/test/randv2_64.pck similarity index 100% rename from src/extensions/StdLib/Lib/test/randv2_64.pck rename to src/core/IronPython.StdLib/Lib/test/randv2_64.pck diff --git a/src/extensions/StdLib/Lib/test/randv3.pck b/src/core/IronPython.StdLib/Lib/test/randv3.pck similarity index 100% rename from src/extensions/StdLib/Lib/test/randv3.pck rename to src/core/IronPython.StdLib/Lib/test/randv3.pck diff --git a/src/extensions/StdLib/Lib/test/re_tests.py b/src/core/IronPython.StdLib/Lib/test/re_tests.py similarity index 100% rename from src/extensions/StdLib/Lib/test/re_tests.py rename to src/core/IronPython.StdLib/Lib/test/re_tests.py diff --git a/src/extensions/StdLib/Lib/test/regrtest.py b/src/core/IronPython.StdLib/Lib/test/regrtest.py similarity index 100% rename from src/extensions/StdLib/Lib/test/regrtest.py rename to src/core/IronPython.StdLib/Lib/test/regrtest.py diff --git a/src/extensions/StdLib/Lib/test/relimport.py b/src/core/IronPython.StdLib/Lib/test/relimport.py similarity index 100% rename from src/extensions/StdLib/Lib/test/relimport.py rename to src/core/IronPython.StdLib/Lib/test/relimport.py diff --git a/src/extensions/StdLib/Lib/test/reperf.py b/src/core/IronPython.StdLib/Lib/test/reperf.py similarity index 100% rename from src/extensions/StdLib/Lib/test/reperf.py rename to src/core/IronPython.StdLib/Lib/test/reperf.py diff --git a/src/extensions/StdLib/Lib/test/revocation.crl b/src/core/IronPython.StdLib/Lib/test/revocation.crl similarity index 100% rename from src/extensions/StdLib/Lib/test/revocation.crl rename to src/core/IronPython.StdLib/Lib/test/revocation.crl diff --git a/src/extensions/StdLib/Lib/test/sample_doctest.py b/src/core/IronPython.StdLib/Lib/test/sample_doctest.py similarity index 100% rename from src/extensions/StdLib/Lib/test/sample_doctest.py rename to src/core/IronPython.StdLib/Lib/test/sample_doctest.py diff --git a/src/extensions/StdLib/Lib/test/sample_doctest_no_docstrings.py b/src/core/IronPython.StdLib/Lib/test/sample_doctest_no_docstrings.py similarity index 100% rename from src/extensions/StdLib/Lib/test/sample_doctest_no_docstrings.py rename to src/core/IronPython.StdLib/Lib/test/sample_doctest_no_docstrings.py diff --git a/src/extensions/StdLib/Lib/test/sample_doctest_no_doctests.py b/src/core/IronPython.StdLib/Lib/test/sample_doctest_no_doctests.py similarity index 100% rename from src/extensions/StdLib/Lib/test/sample_doctest_no_doctests.py rename to src/core/IronPython.StdLib/Lib/test/sample_doctest_no_doctests.py diff --git a/src/extensions/StdLib/Lib/test/script_helper.py b/src/core/IronPython.StdLib/Lib/test/script_helper.py similarity index 100% rename from src/extensions/StdLib/Lib/test/script_helper.py rename to src/core/IronPython.StdLib/Lib/test/script_helper.py diff --git a/src/extensions/StdLib/Lib/test/selfsigned_pythontestdotnet.pem b/src/core/IronPython.StdLib/Lib/test/selfsigned_pythontestdotnet.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/selfsigned_pythontestdotnet.pem rename to src/core/IronPython.StdLib/Lib/test/selfsigned_pythontestdotnet.pem diff --git a/src/extensions/StdLib/Lib/test/seq_tests.py b/src/core/IronPython.StdLib/Lib/test/seq_tests.py similarity index 100% rename from src/extensions/StdLib/Lib/test/seq_tests.py rename to src/core/IronPython.StdLib/Lib/test/seq_tests.py diff --git a/src/extensions/StdLib/Lib/test/sgml_input.html b/src/core/IronPython.StdLib/Lib/test/sgml_input.html similarity index 100% rename from src/extensions/StdLib/Lib/test/sgml_input.html rename to src/core/IronPython.StdLib/Lib/test/sgml_input.html diff --git a/src/extensions/StdLib/Lib/test/sha256.pem b/src/core/IronPython.StdLib/Lib/test/sha256.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/sha256.pem rename to src/core/IronPython.StdLib/Lib/test/sha256.pem diff --git a/src/extensions/StdLib/Lib/test/sndhdrdata/README b/src/core/IronPython.StdLib/Lib/test/sndhdrdata/README similarity index 100% rename from src/extensions/StdLib/Lib/test/sndhdrdata/README rename to src/core/IronPython.StdLib/Lib/test/sndhdrdata/README diff --git a/src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.8svx b/src/core/IronPython.StdLib/Lib/test/sndhdrdata/sndhdr.8svx similarity index 100% rename from src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.8svx rename to src/core/IronPython.StdLib/Lib/test/sndhdrdata/sndhdr.8svx diff --git a/src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.aifc b/src/core/IronPython.StdLib/Lib/test/sndhdrdata/sndhdr.aifc similarity index 100% rename from src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.aifc rename to src/core/IronPython.StdLib/Lib/test/sndhdrdata/sndhdr.aifc diff --git a/src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.aiff b/src/core/IronPython.StdLib/Lib/test/sndhdrdata/sndhdr.aiff similarity index 100% rename from src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.aiff rename to src/core/IronPython.StdLib/Lib/test/sndhdrdata/sndhdr.aiff diff --git a/src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.au b/src/core/IronPython.StdLib/Lib/test/sndhdrdata/sndhdr.au similarity index 100% rename from src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.au rename to src/core/IronPython.StdLib/Lib/test/sndhdrdata/sndhdr.au diff --git a/src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.hcom b/src/core/IronPython.StdLib/Lib/test/sndhdrdata/sndhdr.hcom similarity index 100% rename from src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.hcom rename to src/core/IronPython.StdLib/Lib/test/sndhdrdata/sndhdr.hcom diff --git a/src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.sndt b/src/core/IronPython.StdLib/Lib/test/sndhdrdata/sndhdr.sndt similarity index 100% rename from src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.sndt rename to src/core/IronPython.StdLib/Lib/test/sndhdrdata/sndhdr.sndt diff --git a/src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.voc b/src/core/IronPython.StdLib/Lib/test/sndhdrdata/sndhdr.voc similarity index 100% rename from src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.voc rename to src/core/IronPython.StdLib/Lib/test/sndhdrdata/sndhdr.voc diff --git a/src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.wav b/src/core/IronPython.StdLib/Lib/test/sndhdrdata/sndhdr.wav similarity index 100% rename from src/extensions/StdLib/Lib/test/sndhdrdata/sndhdr.wav rename to src/core/IronPython.StdLib/Lib/test/sndhdrdata/sndhdr.wav diff --git a/src/extensions/StdLib/Lib/test/sortperf.py b/src/core/IronPython.StdLib/Lib/test/sortperf.py similarity index 100% rename from src/extensions/StdLib/Lib/test/sortperf.py rename to src/core/IronPython.StdLib/Lib/test/sortperf.py diff --git a/src/extensions/StdLib/Lib/test/ssl_cert.pem b/src/core/IronPython.StdLib/Lib/test/ssl_cert.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/ssl_cert.pem rename to src/core/IronPython.StdLib/Lib/test/ssl_cert.pem diff --git a/src/extensions/StdLib/Lib/test/ssl_key.passwd.pem b/src/core/IronPython.StdLib/Lib/test/ssl_key.passwd.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/ssl_key.passwd.pem rename to src/core/IronPython.StdLib/Lib/test/ssl_key.passwd.pem diff --git a/src/extensions/StdLib/Lib/test/ssl_key.pem b/src/core/IronPython.StdLib/Lib/test/ssl_key.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/ssl_key.pem rename to src/core/IronPython.StdLib/Lib/test/ssl_key.pem diff --git a/src/extensions/StdLib/Lib/test/ssl_servers.py b/src/core/IronPython.StdLib/Lib/test/ssl_servers.py similarity index 100% rename from src/extensions/StdLib/Lib/test/ssl_servers.py rename to src/core/IronPython.StdLib/Lib/test/ssl_servers.py diff --git a/src/extensions/StdLib/Lib/test/ssltests.py b/src/core/IronPython.StdLib/Lib/test/ssltests.py similarity index 100% rename from src/extensions/StdLib/Lib/test/ssltests.py rename to src/core/IronPython.StdLib/Lib/test/ssltests.py diff --git a/src/extensions/StdLib/Lib/test/string_tests.py b/src/core/IronPython.StdLib/Lib/test/string_tests.py similarity index 100% rename from src/extensions/StdLib/Lib/test/string_tests.py rename to src/core/IronPython.StdLib/Lib/test/string_tests.py diff --git a/src/extensions/StdLib/Lib/test/subprocessdata/fd_status.py b/src/core/IronPython.StdLib/Lib/test/subprocessdata/fd_status.py similarity index 100% rename from src/extensions/StdLib/Lib/test/subprocessdata/fd_status.py rename to src/core/IronPython.StdLib/Lib/test/subprocessdata/fd_status.py diff --git a/src/extensions/StdLib/Lib/test/subprocessdata/input_reader.py b/src/core/IronPython.StdLib/Lib/test/subprocessdata/input_reader.py similarity index 100% rename from src/extensions/StdLib/Lib/test/subprocessdata/input_reader.py rename to src/core/IronPython.StdLib/Lib/test/subprocessdata/input_reader.py diff --git a/src/extensions/StdLib/Lib/test/subprocessdata/qcat.py b/src/core/IronPython.StdLib/Lib/test/subprocessdata/qcat.py similarity index 100% rename from src/extensions/StdLib/Lib/test/subprocessdata/qcat.py rename to src/core/IronPython.StdLib/Lib/test/subprocessdata/qcat.py diff --git a/src/extensions/StdLib/Lib/test/subprocessdata/qgrep.py b/src/core/IronPython.StdLib/Lib/test/subprocessdata/qgrep.py similarity index 100% rename from src/extensions/StdLib/Lib/test/subprocessdata/qgrep.py rename to src/core/IronPython.StdLib/Lib/test/subprocessdata/qgrep.py diff --git a/src/extensions/StdLib/Lib/test/subprocessdata/sigchild_ignore.py b/src/core/IronPython.StdLib/Lib/test/subprocessdata/sigchild_ignore.py similarity index 100% rename from src/extensions/StdLib/Lib/test/subprocessdata/sigchild_ignore.py rename to src/core/IronPython.StdLib/Lib/test/subprocessdata/sigchild_ignore.py diff --git a/src/extensions/StdLib/Lib/test/support/__init__.py b/src/core/IronPython.StdLib/Lib/test/support/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/support/__init__.py rename to src/core/IronPython.StdLib/Lib/test/support/__init__.py diff --git a/src/extensions/StdLib/Lib/test/talos-2019-0758.pem b/src/core/IronPython.StdLib/Lib/test/talos-2019-0758.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/talos-2019-0758.pem rename to src/core/IronPython.StdLib/Lib/test/talos-2019-0758.pem diff --git a/src/extensions/StdLib/Lib/test/test___all__.py b/src/core/IronPython.StdLib/Lib/test/test___all__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test___all__.py rename to src/core/IronPython.StdLib/Lib/test/test___all__.py diff --git a/src/extensions/StdLib/Lib/test/test___future__.py b/src/core/IronPython.StdLib/Lib/test/test___future__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test___future__.py rename to src/core/IronPython.StdLib/Lib/test/test___future__.py diff --git a/src/extensions/StdLib/Lib/test/test__locale.py b/src/core/IronPython.StdLib/Lib/test/test__locale.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test__locale.py rename to src/core/IronPython.StdLib/Lib/test/test__locale.py diff --git a/src/extensions/StdLib/Lib/test/test__opcode.py b/src/core/IronPython.StdLib/Lib/test/test__opcode.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test__opcode.py rename to src/core/IronPython.StdLib/Lib/test/test__opcode.py diff --git a/src/extensions/StdLib/Lib/test/test__osx_support.py b/src/core/IronPython.StdLib/Lib/test/test__osx_support.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test__osx_support.py rename to src/core/IronPython.StdLib/Lib/test/test__osx_support.py diff --git a/src/extensions/StdLib/Lib/test/test_abc.py b/src/core/IronPython.StdLib/Lib/test/test_abc.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_abc.py rename to src/core/IronPython.StdLib/Lib/test/test_abc.py diff --git a/src/extensions/StdLib/Lib/test/test_abstract_numbers.py b/src/core/IronPython.StdLib/Lib/test/test_abstract_numbers.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_abstract_numbers.py rename to src/core/IronPython.StdLib/Lib/test/test_abstract_numbers.py diff --git a/src/extensions/StdLib/Lib/test/test_aifc.py b/src/core/IronPython.StdLib/Lib/test/test_aifc.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_aifc.py rename to src/core/IronPython.StdLib/Lib/test/test_aifc.py diff --git a/src/extensions/StdLib/Lib/test/test_argparse.py b/src/core/IronPython.StdLib/Lib/test/test_argparse.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_argparse.py rename to src/core/IronPython.StdLib/Lib/test/test_argparse.py diff --git a/src/extensions/StdLib/Lib/test/test_array.py b/src/core/IronPython.StdLib/Lib/test/test_array.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_array.py rename to src/core/IronPython.StdLib/Lib/test/test_array.py diff --git a/src/extensions/StdLib/Lib/test/test_ast.py b/src/core/IronPython.StdLib/Lib/test/test_ast.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_ast.py rename to src/core/IronPython.StdLib/Lib/test/test_ast.py diff --git a/src/extensions/StdLib/Lib/test/test_asynchat.py b/src/core/IronPython.StdLib/Lib/test/test_asynchat.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asynchat.py rename to src/core/IronPython.StdLib/Lib/test/test_asynchat.py diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/__init__.py b/src/core/IronPython.StdLib/Lib/test/test_asyncio/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/__init__.py rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/__init__.py diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/__main__.py b/src/core/IronPython.StdLib/Lib/test/test_asyncio/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/__main__.py rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/__main__.py diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/echo.py b/src/core/IronPython.StdLib/Lib/test/test_asyncio/echo.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/echo.py rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/echo.py diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/echo2.py b/src/core/IronPython.StdLib/Lib/test/test_asyncio/echo2.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/echo2.py rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/echo2.py diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/echo3.py b/src/core/IronPython.StdLib/Lib/test/test_asyncio/echo3.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/echo3.py rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/echo3.py diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/keycert3.pem b/src/core/IronPython.StdLib/Lib/test/test_asyncio/keycert3.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/keycert3.pem rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/keycert3.pem diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/pycacert.pem b/src/core/IronPython.StdLib/Lib/test/test_asyncio/pycacert.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/pycacert.pem rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/pycacert.pem diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/ssl_cert.pem b/src/core/IronPython.StdLib/Lib/test/test_asyncio/ssl_cert.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/ssl_cert.pem rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/ssl_cert.pem diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/ssl_key.pem b/src/core/IronPython.StdLib/Lib/test/test_asyncio/ssl_key.pem similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/ssl_key.pem rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/ssl_key.pem diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/test_base_events.py b/src/core/IronPython.StdLib/Lib/test/test_asyncio/test_base_events.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/test_base_events.py rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/test_base_events.py diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/test_events.py b/src/core/IronPython.StdLib/Lib/test/test_asyncio/test_events.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/test_events.py rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/test_events.py diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/test_futures.py b/src/core/IronPython.StdLib/Lib/test/test_asyncio/test_futures.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/test_futures.py rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/test_futures.py diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/test_locks.py b/src/core/IronPython.StdLib/Lib/test/test_asyncio/test_locks.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/test_locks.py rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/test_locks.py diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/test_proactor_events.py b/src/core/IronPython.StdLib/Lib/test/test_asyncio/test_proactor_events.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/test_proactor_events.py rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/test_proactor_events.py diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/test_queues.py b/src/core/IronPython.StdLib/Lib/test/test_asyncio/test_queues.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/test_queues.py rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/test_queues.py diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/test_selector_events.py b/src/core/IronPython.StdLib/Lib/test/test_asyncio/test_selector_events.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/test_selector_events.py rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/test_selector_events.py diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/test_sslproto.py b/src/core/IronPython.StdLib/Lib/test/test_asyncio/test_sslproto.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/test_sslproto.py rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/test_sslproto.py diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/test_streams.py b/src/core/IronPython.StdLib/Lib/test/test_asyncio/test_streams.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/test_streams.py rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/test_streams.py diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/test_subprocess.py b/src/core/IronPython.StdLib/Lib/test/test_asyncio/test_subprocess.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/test_subprocess.py rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/test_subprocess.py diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/test_tasks.py b/src/core/IronPython.StdLib/Lib/test/test_asyncio/test_tasks.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/test_tasks.py rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/test_tasks.py diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/test_transports.py b/src/core/IronPython.StdLib/Lib/test/test_asyncio/test_transports.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/test_transports.py rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/test_transports.py diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/test_unix_events.py b/src/core/IronPython.StdLib/Lib/test/test_asyncio/test_unix_events.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/test_unix_events.py rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/test_unix_events.py diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/test_windows_events.py b/src/core/IronPython.StdLib/Lib/test/test_asyncio/test_windows_events.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/test_windows_events.py rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/test_windows_events.py diff --git a/src/extensions/StdLib/Lib/test/test_asyncio/test_windows_utils.py b/src/core/IronPython.StdLib/Lib/test/test_asyncio/test_windows_utils.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncio/test_windows_utils.py rename to src/core/IronPython.StdLib/Lib/test/test_asyncio/test_windows_utils.py diff --git a/src/extensions/StdLib/Lib/test/test_asyncore.py b/src/core/IronPython.StdLib/Lib/test/test_asyncore.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_asyncore.py rename to src/core/IronPython.StdLib/Lib/test/test_asyncore.py diff --git a/src/extensions/StdLib/Lib/test/test_atexit.py b/src/core/IronPython.StdLib/Lib/test/test_atexit.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_atexit.py rename to src/core/IronPython.StdLib/Lib/test/test_atexit.py diff --git a/src/extensions/StdLib/Lib/test/test_audioop.py b/src/core/IronPython.StdLib/Lib/test/test_audioop.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_audioop.py rename to src/core/IronPython.StdLib/Lib/test/test_audioop.py diff --git a/src/extensions/StdLib/Lib/test/test_augassign.py b/src/core/IronPython.StdLib/Lib/test/test_augassign.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_augassign.py rename to src/core/IronPython.StdLib/Lib/test/test_augassign.py diff --git a/src/extensions/StdLib/Lib/test/test_base64.py b/src/core/IronPython.StdLib/Lib/test/test_base64.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_base64.py rename to src/core/IronPython.StdLib/Lib/test/test_base64.py diff --git a/src/extensions/StdLib/Lib/test/test_bigaddrspace.py b/src/core/IronPython.StdLib/Lib/test/test_bigaddrspace.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_bigaddrspace.py rename to src/core/IronPython.StdLib/Lib/test/test_bigaddrspace.py diff --git a/src/extensions/StdLib/Lib/test/test_bigmem.py b/src/core/IronPython.StdLib/Lib/test/test_bigmem.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_bigmem.py rename to src/core/IronPython.StdLib/Lib/test/test_bigmem.py diff --git a/src/extensions/StdLib/Lib/test/test_binascii.py b/src/core/IronPython.StdLib/Lib/test/test_binascii.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_binascii.py rename to src/core/IronPython.StdLib/Lib/test/test_binascii.py diff --git a/src/extensions/StdLib/Lib/test/test_binhex.py b/src/core/IronPython.StdLib/Lib/test/test_binhex.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_binhex.py rename to src/core/IronPython.StdLib/Lib/test/test_binhex.py diff --git a/src/extensions/StdLib/Lib/test/test_binop.py b/src/core/IronPython.StdLib/Lib/test/test_binop.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_binop.py rename to src/core/IronPython.StdLib/Lib/test/test_binop.py diff --git a/src/extensions/StdLib/Lib/test/test_bisect.py b/src/core/IronPython.StdLib/Lib/test/test_bisect.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_bisect.py rename to src/core/IronPython.StdLib/Lib/test/test_bisect.py diff --git a/src/extensions/StdLib/Lib/test/test_bool.py b/src/core/IronPython.StdLib/Lib/test/test_bool.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_bool.py rename to src/core/IronPython.StdLib/Lib/test/test_bool.py diff --git a/src/extensions/StdLib/Lib/test/test_buffer.py b/src/core/IronPython.StdLib/Lib/test/test_buffer.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_buffer.py rename to src/core/IronPython.StdLib/Lib/test/test_buffer.py diff --git a/src/extensions/StdLib/Lib/test/test_bufio.py b/src/core/IronPython.StdLib/Lib/test/test_bufio.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_bufio.py rename to src/core/IronPython.StdLib/Lib/test/test_bufio.py diff --git a/src/extensions/StdLib/Lib/test/test_builtin.py b/src/core/IronPython.StdLib/Lib/test/test_builtin.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_builtin.py rename to src/core/IronPython.StdLib/Lib/test/test_builtin.py diff --git a/src/extensions/StdLib/Lib/test/test_bytes.py b/src/core/IronPython.StdLib/Lib/test/test_bytes.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_bytes.py rename to src/core/IronPython.StdLib/Lib/test/test_bytes.py diff --git a/src/extensions/StdLib/Lib/test/test_bz2.py b/src/core/IronPython.StdLib/Lib/test/test_bz2.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_bz2.py rename to src/core/IronPython.StdLib/Lib/test/test_bz2.py diff --git a/src/extensions/StdLib/Lib/test/test_calendar.py b/src/core/IronPython.StdLib/Lib/test/test_calendar.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_calendar.py rename to src/core/IronPython.StdLib/Lib/test/test_calendar.py diff --git a/src/extensions/StdLib/Lib/test/test_call.py b/src/core/IronPython.StdLib/Lib/test/test_call.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_call.py rename to src/core/IronPython.StdLib/Lib/test/test_call.py diff --git a/src/extensions/StdLib/Lib/test/test_capi.py b/src/core/IronPython.StdLib/Lib/test/test_capi.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_capi.py rename to src/core/IronPython.StdLib/Lib/test/test_capi.py diff --git a/src/extensions/StdLib/Lib/test/test_cgi.py b/src/core/IronPython.StdLib/Lib/test/test_cgi.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_cgi.py rename to src/core/IronPython.StdLib/Lib/test/test_cgi.py diff --git a/src/extensions/StdLib/Lib/test/test_cgitb.py b/src/core/IronPython.StdLib/Lib/test/test_cgitb.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_cgitb.py rename to src/core/IronPython.StdLib/Lib/test/test_cgitb.py diff --git a/src/extensions/StdLib/Lib/test/test_charmapcodec.py b/src/core/IronPython.StdLib/Lib/test/test_charmapcodec.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_charmapcodec.py rename to src/core/IronPython.StdLib/Lib/test/test_charmapcodec.py diff --git a/src/extensions/StdLib/Lib/test/test_class.py b/src/core/IronPython.StdLib/Lib/test/test_class.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_class.py rename to src/core/IronPython.StdLib/Lib/test/test_class.py diff --git a/src/extensions/StdLib/Lib/test/test_cmath.py b/src/core/IronPython.StdLib/Lib/test/test_cmath.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_cmath.py rename to src/core/IronPython.StdLib/Lib/test/test_cmath.py diff --git a/src/extensions/StdLib/Lib/test/test_cmd.py b/src/core/IronPython.StdLib/Lib/test/test_cmd.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_cmd.py rename to src/core/IronPython.StdLib/Lib/test/test_cmd.py diff --git a/src/extensions/StdLib/Lib/test/test_cmd_line.py b/src/core/IronPython.StdLib/Lib/test/test_cmd_line.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_cmd_line.py rename to src/core/IronPython.StdLib/Lib/test/test_cmd_line.py diff --git a/src/extensions/StdLib/Lib/test/test_cmd_line_script.py b/src/core/IronPython.StdLib/Lib/test/test_cmd_line_script.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_cmd_line_script.py rename to src/core/IronPython.StdLib/Lib/test/test_cmd_line_script.py diff --git a/src/extensions/StdLib/Lib/test/test_code.py b/src/core/IronPython.StdLib/Lib/test/test_code.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_code.py rename to src/core/IronPython.StdLib/Lib/test/test_code.py diff --git a/src/extensions/StdLib/Lib/test/test_code_module.py b/src/core/IronPython.StdLib/Lib/test/test_code_module.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_code_module.py rename to src/core/IronPython.StdLib/Lib/test/test_code_module.py diff --git a/src/extensions/StdLib/Lib/test/test_codeccallbacks.py b/src/core/IronPython.StdLib/Lib/test/test_codeccallbacks.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_codeccallbacks.py rename to src/core/IronPython.StdLib/Lib/test/test_codeccallbacks.py diff --git a/src/extensions/StdLib/Lib/test/test_codecencodings_cn.py b/src/core/IronPython.StdLib/Lib/test/test_codecencodings_cn.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_codecencodings_cn.py rename to src/core/IronPython.StdLib/Lib/test/test_codecencodings_cn.py diff --git a/src/extensions/StdLib/Lib/test/test_codecencodings_hk.py b/src/core/IronPython.StdLib/Lib/test/test_codecencodings_hk.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_codecencodings_hk.py rename to src/core/IronPython.StdLib/Lib/test/test_codecencodings_hk.py diff --git a/src/extensions/StdLib/Lib/test/test_codecencodings_iso2022.py b/src/core/IronPython.StdLib/Lib/test/test_codecencodings_iso2022.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_codecencodings_iso2022.py rename to src/core/IronPython.StdLib/Lib/test/test_codecencodings_iso2022.py diff --git a/src/extensions/StdLib/Lib/test/test_codecencodings_jp.py b/src/core/IronPython.StdLib/Lib/test/test_codecencodings_jp.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_codecencodings_jp.py rename to src/core/IronPython.StdLib/Lib/test/test_codecencodings_jp.py diff --git a/src/extensions/StdLib/Lib/test/test_codecencodings_kr.py b/src/core/IronPython.StdLib/Lib/test/test_codecencodings_kr.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_codecencodings_kr.py rename to src/core/IronPython.StdLib/Lib/test/test_codecencodings_kr.py diff --git a/src/extensions/StdLib/Lib/test/test_codecencodings_tw.py b/src/core/IronPython.StdLib/Lib/test/test_codecencodings_tw.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_codecencodings_tw.py rename to src/core/IronPython.StdLib/Lib/test/test_codecencodings_tw.py diff --git a/src/extensions/StdLib/Lib/test/test_codecmaps_cn.py b/src/core/IronPython.StdLib/Lib/test/test_codecmaps_cn.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_codecmaps_cn.py rename to src/core/IronPython.StdLib/Lib/test/test_codecmaps_cn.py diff --git a/src/extensions/StdLib/Lib/test/test_codecmaps_hk.py b/src/core/IronPython.StdLib/Lib/test/test_codecmaps_hk.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_codecmaps_hk.py rename to src/core/IronPython.StdLib/Lib/test/test_codecmaps_hk.py diff --git a/src/extensions/StdLib/Lib/test/test_codecmaps_jp.py b/src/core/IronPython.StdLib/Lib/test/test_codecmaps_jp.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_codecmaps_jp.py rename to src/core/IronPython.StdLib/Lib/test/test_codecmaps_jp.py diff --git a/src/extensions/StdLib/Lib/test/test_codecmaps_kr.py b/src/core/IronPython.StdLib/Lib/test/test_codecmaps_kr.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_codecmaps_kr.py rename to src/core/IronPython.StdLib/Lib/test/test_codecmaps_kr.py diff --git a/src/extensions/StdLib/Lib/test/test_codecmaps_tw.py b/src/core/IronPython.StdLib/Lib/test/test_codecmaps_tw.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_codecmaps_tw.py rename to src/core/IronPython.StdLib/Lib/test/test_codecmaps_tw.py diff --git a/src/extensions/StdLib/Lib/test/test_codecs.py b/src/core/IronPython.StdLib/Lib/test/test_codecs.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_codecs.py rename to src/core/IronPython.StdLib/Lib/test/test_codecs.py diff --git a/src/extensions/StdLib/Lib/test/test_codeop.py b/src/core/IronPython.StdLib/Lib/test/test_codeop.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_codeop.py rename to src/core/IronPython.StdLib/Lib/test/test_codeop.py diff --git a/src/extensions/StdLib/Lib/test/test_collections.py b/src/core/IronPython.StdLib/Lib/test/test_collections.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_collections.py rename to src/core/IronPython.StdLib/Lib/test/test_collections.py diff --git a/src/extensions/StdLib/Lib/test/test_colorsys.py b/src/core/IronPython.StdLib/Lib/test/test_colorsys.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_colorsys.py rename to src/core/IronPython.StdLib/Lib/test/test_colorsys.py diff --git a/src/extensions/StdLib/Lib/test/test_compare.py b/src/core/IronPython.StdLib/Lib/test/test_compare.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_compare.py rename to src/core/IronPython.StdLib/Lib/test/test_compare.py diff --git a/src/extensions/StdLib/Lib/test/test_compile.py b/src/core/IronPython.StdLib/Lib/test/test_compile.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_compile.py rename to src/core/IronPython.StdLib/Lib/test/test_compile.py diff --git a/src/extensions/StdLib/Lib/test/test_compileall.py b/src/core/IronPython.StdLib/Lib/test/test_compileall.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_compileall.py rename to src/core/IronPython.StdLib/Lib/test/test_compileall.py diff --git a/src/extensions/StdLib/Lib/test/test_complex.py b/src/core/IronPython.StdLib/Lib/test/test_complex.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_complex.py rename to src/core/IronPython.StdLib/Lib/test/test_complex.py diff --git a/src/extensions/StdLib/Lib/test/test_concurrent_futures.py b/src/core/IronPython.StdLib/Lib/test/test_concurrent_futures.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_concurrent_futures.py rename to src/core/IronPython.StdLib/Lib/test/test_concurrent_futures.py diff --git a/src/extensions/StdLib/Lib/test/test_configparser.py b/src/core/IronPython.StdLib/Lib/test/test_configparser.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_configparser.py rename to src/core/IronPython.StdLib/Lib/test/test_configparser.py diff --git a/src/extensions/StdLib/Lib/test/test_contains.py b/src/core/IronPython.StdLib/Lib/test/test_contains.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_contains.py rename to src/core/IronPython.StdLib/Lib/test/test_contains.py diff --git a/src/extensions/StdLib/Lib/test/test_contextlib.py b/src/core/IronPython.StdLib/Lib/test/test_contextlib.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_contextlib.py rename to src/core/IronPython.StdLib/Lib/test/test_contextlib.py diff --git a/src/extensions/StdLib/Lib/test/test_copy.py b/src/core/IronPython.StdLib/Lib/test/test_copy.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_copy.py rename to src/core/IronPython.StdLib/Lib/test/test_copy.py diff --git a/src/extensions/StdLib/Lib/test/test_copyreg.py b/src/core/IronPython.StdLib/Lib/test/test_copyreg.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_copyreg.py rename to src/core/IronPython.StdLib/Lib/test/test_copyreg.py diff --git a/src/extensions/StdLib/Lib/test/test_cprofile.py b/src/core/IronPython.StdLib/Lib/test/test_cprofile.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_cprofile.py rename to src/core/IronPython.StdLib/Lib/test/test_cprofile.py diff --git a/src/extensions/StdLib/Lib/test/test_crashers.py b/src/core/IronPython.StdLib/Lib/test/test_crashers.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_crashers.py rename to src/core/IronPython.StdLib/Lib/test/test_crashers.py diff --git a/src/extensions/StdLib/Lib/test/test_crypt.py b/src/core/IronPython.StdLib/Lib/test/test_crypt.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_crypt.py rename to src/core/IronPython.StdLib/Lib/test/test_crypt.py diff --git a/src/extensions/StdLib/Lib/test/test_csv.py b/src/core/IronPython.StdLib/Lib/test/test_csv.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_csv.py rename to src/core/IronPython.StdLib/Lib/test/test_csv.py diff --git a/src/extensions/StdLib/Lib/test/test_ctypes.py b/src/core/IronPython.StdLib/Lib/test/test_ctypes.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_ctypes.py rename to src/core/IronPython.StdLib/Lib/test/test_ctypes.py diff --git a/src/extensions/StdLib/Lib/test/test_curses.py b/src/core/IronPython.StdLib/Lib/test/test_curses.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_curses.py rename to src/core/IronPython.StdLib/Lib/test/test_curses.py diff --git a/src/extensions/StdLib/Lib/test/test_datetime.py b/src/core/IronPython.StdLib/Lib/test/test_datetime.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_datetime.py rename to src/core/IronPython.StdLib/Lib/test/test_datetime.py diff --git a/src/extensions/StdLib/Lib/test/test_dbm.py b/src/core/IronPython.StdLib/Lib/test/test_dbm.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_dbm.py rename to src/core/IronPython.StdLib/Lib/test/test_dbm.py diff --git a/src/extensions/StdLib/Lib/test/test_dbm_dumb.py b/src/core/IronPython.StdLib/Lib/test/test_dbm_dumb.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_dbm_dumb.py rename to src/core/IronPython.StdLib/Lib/test/test_dbm_dumb.py diff --git a/src/extensions/StdLib/Lib/test/test_dbm_gnu.py b/src/core/IronPython.StdLib/Lib/test/test_dbm_gnu.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_dbm_gnu.py rename to src/core/IronPython.StdLib/Lib/test/test_dbm_gnu.py diff --git a/src/extensions/StdLib/Lib/test/test_dbm_ndbm.py b/src/core/IronPython.StdLib/Lib/test/test_dbm_ndbm.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_dbm_ndbm.py rename to src/core/IronPython.StdLib/Lib/test/test_dbm_ndbm.py diff --git a/src/extensions/StdLib/Lib/test/test_decimal.py b/src/core/IronPython.StdLib/Lib/test/test_decimal.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_decimal.py rename to src/core/IronPython.StdLib/Lib/test/test_decimal.py diff --git a/src/extensions/StdLib/Lib/test/test_decorators.py b/src/core/IronPython.StdLib/Lib/test/test_decorators.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_decorators.py rename to src/core/IronPython.StdLib/Lib/test/test_decorators.py diff --git a/src/extensions/StdLib/Lib/test/test_defaultdict.py b/src/core/IronPython.StdLib/Lib/test/test_defaultdict.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_defaultdict.py rename to src/core/IronPython.StdLib/Lib/test/test_defaultdict.py diff --git a/src/extensions/StdLib/Lib/test/test_deque.py b/src/core/IronPython.StdLib/Lib/test/test_deque.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_deque.py rename to src/core/IronPython.StdLib/Lib/test/test_deque.py diff --git a/src/extensions/StdLib/Lib/test/test_descr.py b/src/core/IronPython.StdLib/Lib/test/test_descr.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_descr.py rename to src/core/IronPython.StdLib/Lib/test/test_descr.py diff --git a/src/extensions/StdLib/Lib/test/test_descrtut.py b/src/core/IronPython.StdLib/Lib/test/test_descrtut.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_descrtut.py rename to src/core/IronPython.StdLib/Lib/test/test_descrtut.py diff --git a/src/extensions/StdLib/Lib/test/test_devpoll.py b/src/core/IronPython.StdLib/Lib/test/test_devpoll.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_devpoll.py rename to src/core/IronPython.StdLib/Lib/test/test_devpoll.py diff --git a/src/extensions/StdLib/Lib/test/test_dict.py b/src/core/IronPython.StdLib/Lib/test/test_dict.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_dict.py rename to src/core/IronPython.StdLib/Lib/test/test_dict.py diff --git a/src/extensions/StdLib/Lib/test/test_dictcomps.py b/src/core/IronPython.StdLib/Lib/test/test_dictcomps.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_dictcomps.py rename to src/core/IronPython.StdLib/Lib/test/test_dictcomps.py diff --git a/src/extensions/StdLib/Lib/test/test_dictviews.py b/src/core/IronPython.StdLib/Lib/test/test_dictviews.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_dictviews.py rename to src/core/IronPython.StdLib/Lib/test/test_dictviews.py diff --git a/src/extensions/StdLib/Lib/test/test_difflib.py b/src/core/IronPython.StdLib/Lib/test/test_difflib.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_difflib.py rename to src/core/IronPython.StdLib/Lib/test/test_difflib.py diff --git a/src/extensions/StdLib/Lib/test/test_difflib_expect.html b/src/core/IronPython.StdLib/Lib/test/test_difflib_expect.html similarity index 100% rename from src/extensions/StdLib/Lib/test/test_difflib_expect.html rename to src/core/IronPython.StdLib/Lib/test/test_difflib_expect.html diff --git a/src/extensions/StdLib/Lib/test/test_dis.py b/src/core/IronPython.StdLib/Lib/test/test_dis.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_dis.py rename to src/core/IronPython.StdLib/Lib/test/test_dis.py diff --git a/src/extensions/StdLib/Lib/test/test_distutils.py b/src/core/IronPython.StdLib/Lib/test/test_distutils.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_distutils.py rename to src/core/IronPython.StdLib/Lib/test/test_distutils.py diff --git a/src/extensions/StdLib/Lib/test/test_doctest.py b/src/core/IronPython.StdLib/Lib/test/test_doctest.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_doctest.py rename to src/core/IronPython.StdLib/Lib/test/test_doctest.py diff --git a/src/extensions/StdLib/Lib/test/test_doctest.txt b/src/core/IronPython.StdLib/Lib/test/test_doctest.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_doctest.txt rename to src/core/IronPython.StdLib/Lib/test/test_doctest.txt diff --git a/src/extensions/StdLib/Lib/test/test_doctest2.py b/src/core/IronPython.StdLib/Lib/test/test_doctest2.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_doctest2.py rename to src/core/IronPython.StdLib/Lib/test/test_doctest2.py diff --git a/src/extensions/StdLib/Lib/test/test_doctest2.txt b/src/core/IronPython.StdLib/Lib/test/test_doctest2.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_doctest2.txt rename to src/core/IronPython.StdLib/Lib/test/test_doctest2.txt diff --git a/src/extensions/StdLib/Lib/test/test_doctest3.txt b/src/core/IronPython.StdLib/Lib/test/test_doctest3.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_doctest3.txt rename to src/core/IronPython.StdLib/Lib/test/test_doctest3.txt diff --git a/src/extensions/StdLib/Lib/test/test_doctest4.txt b/src/core/IronPython.StdLib/Lib/test/test_doctest4.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_doctest4.txt rename to src/core/IronPython.StdLib/Lib/test/test_doctest4.txt diff --git a/src/extensions/StdLib/Lib/test/test_docxmlrpc.py b/src/core/IronPython.StdLib/Lib/test/test_docxmlrpc.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_docxmlrpc.py rename to src/core/IronPython.StdLib/Lib/test/test_docxmlrpc.py diff --git a/src/extensions/StdLib/Lib/test/test_dummy_thread.py b/src/core/IronPython.StdLib/Lib/test/test_dummy_thread.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_dummy_thread.py rename to src/core/IronPython.StdLib/Lib/test/test_dummy_thread.py diff --git a/src/extensions/StdLib/Lib/test/test_dummy_threading.py b/src/core/IronPython.StdLib/Lib/test/test_dummy_threading.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_dummy_threading.py rename to src/core/IronPython.StdLib/Lib/test/test_dummy_threading.py diff --git a/src/extensions/StdLib/Lib/test/test_dynamic.py b/src/core/IronPython.StdLib/Lib/test/test_dynamic.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_dynamic.py rename to src/core/IronPython.StdLib/Lib/test/test_dynamic.py diff --git a/src/extensions/StdLib/Lib/test/test_dynamicclassattribute.py b/src/core/IronPython.StdLib/Lib/test/test_dynamicclassattribute.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_dynamicclassattribute.py rename to src/core/IronPython.StdLib/Lib/test/test_dynamicclassattribute.py diff --git a/src/extensions/StdLib/Lib/test/test_email/__init__.py b/src/core/IronPython.StdLib/Lib/test/test_email/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/__init__.py rename to src/core/IronPython.StdLib/Lib/test/test_email/__init__.py diff --git a/src/extensions/StdLib/Lib/test/test_email/__main__.py b/src/core/IronPython.StdLib/Lib/test/test_email/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/__main__.py rename to src/core/IronPython.StdLib/Lib/test/test_email/__main__.py diff --git a/src/extensions/StdLib/Lib/test/test_email/data/PyBanner048.gif b/src/core/IronPython.StdLib/Lib/test/test_email/data/PyBanner048.gif similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/PyBanner048.gif rename to src/core/IronPython.StdLib/Lib/test/test_email/data/PyBanner048.gif diff --git a/src/extensions/StdLib/Lib/test/test_email/data/audiotest.au b/src/core/IronPython.StdLib/Lib/test/test_email/data/audiotest.au similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/audiotest.au rename to src/core/IronPython.StdLib/Lib/test/test_email/data/audiotest.au diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_01.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_01.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_01.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_01.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_02.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_02.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_02.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_02.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_03.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_03.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_03.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_03.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_04.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_04.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_04.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_04.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_05.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_05.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_05.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_05.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_06.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_06.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_06.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_06.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_07.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_07.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_07.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_07.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_08.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_08.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_08.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_08.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_09.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_09.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_09.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_09.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_10.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_10.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_10.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_10.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_11.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_11.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_11.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_11.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_12.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_12.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_12.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_12.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_12a.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_12a.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_12a.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_12a.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_13.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_13.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_13.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_13.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_14.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_14.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_14.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_14.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_15.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_15.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_15.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_15.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_16.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_16.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_16.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_16.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_17.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_17.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_17.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_17.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_18.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_18.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_18.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_18.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_19.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_19.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_19.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_19.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_20.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_20.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_20.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_20.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_21.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_21.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_21.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_21.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_22.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_22.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_22.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_22.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_23.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_23.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_23.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_23.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_24.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_24.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_24.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_24.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_25.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_25.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_25.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_25.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_26.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_26.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_26.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_26.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_27.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_27.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_27.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_27.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_28.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_28.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_28.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_28.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_29.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_29.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_29.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_29.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_30.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_30.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_30.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_30.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_31.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_31.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_31.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_31.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_32.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_32.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_32.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_32.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_33.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_33.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_33.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_33.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_34.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_34.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_34.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_34.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_35.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_35.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_35.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_35.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_36.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_36.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_36.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_36.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_37.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_37.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_37.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_37.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_38.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_38.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_38.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_38.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_39.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_39.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_39.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_39.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_40.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_40.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_40.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_40.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_41.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_41.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_41.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_41.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_42.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_42.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_42.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_42.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_43.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_43.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_43.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_43.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_44.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_44.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_44.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_44.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_45.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_45.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_45.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_45.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/data/msg_46.txt b/src/core/IronPython.StdLib/Lib/test/test_email/data/msg_46.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/data/msg_46.txt rename to src/core/IronPython.StdLib/Lib/test/test_email/data/msg_46.txt diff --git a/src/extensions/StdLib/Lib/test/test_email/test__encoded_words.py b/src/core/IronPython.StdLib/Lib/test/test_email/test__encoded_words.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/test__encoded_words.py rename to src/core/IronPython.StdLib/Lib/test/test_email/test__encoded_words.py diff --git a/src/extensions/StdLib/Lib/test/test_email/test__header_value_parser.py b/src/core/IronPython.StdLib/Lib/test/test_email/test__header_value_parser.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/test__header_value_parser.py rename to src/core/IronPython.StdLib/Lib/test/test_email/test__header_value_parser.py diff --git a/src/extensions/StdLib/Lib/test/test_email/test_asian_codecs.py b/src/core/IronPython.StdLib/Lib/test/test_email/test_asian_codecs.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/test_asian_codecs.py rename to src/core/IronPython.StdLib/Lib/test/test_email/test_asian_codecs.py diff --git a/src/extensions/StdLib/Lib/test/test_email/test_contentmanager.py b/src/core/IronPython.StdLib/Lib/test/test_email/test_contentmanager.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/test_contentmanager.py rename to src/core/IronPython.StdLib/Lib/test/test_email/test_contentmanager.py diff --git a/src/extensions/StdLib/Lib/test/test_email/test_defect_handling.py b/src/core/IronPython.StdLib/Lib/test/test_email/test_defect_handling.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/test_defect_handling.py rename to src/core/IronPython.StdLib/Lib/test/test_email/test_defect_handling.py diff --git a/src/extensions/StdLib/Lib/test/test_email/test_email.py b/src/core/IronPython.StdLib/Lib/test/test_email/test_email.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/test_email.py rename to src/core/IronPython.StdLib/Lib/test/test_email/test_email.py diff --git a/src/extensions/StdLib/Lib/test/test_email/test_generator.py b/src/core/IronPython.StdLib/Lib/test/test_email/test_generator.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/test_generator.py rename to src/core/IronPython.StdLib/Lib/test/test_email/test_generator.py diff --git a/src/extensions/StdLib/Lib/test/test_email/test_headerregistry.py b/src/core/IronPython.StdLib/Lib/test/test_email/test_headerregistry.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/test_headerregistry.py rename to src/core/IronPython.StdLib/Lib/test/test_email/test_headerregistry.py diff --git a/src/extensions/StdLib/Lib/test/test_email/test_inversion.py b/src/core/IronPython.StdLib/Lib/test/test_email/test_inversion.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/test_inversion.py rename to src/core/IronPython.StdLib/Lib/test/test_email/test_inversion.py diff --git a/src/extensions/StdLib/Lib/test/test_email/test_message.py b/src/core/IronPython.StdLib/Lib/test/test_email/test_message.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/test_message.py rename to src/core/IronPython.StdLib/Lib/test/test_email/test_message.py diff --git a/src/extensions/StdLib/Lib/test/test_email/test_parser.py b/src/core/IronPython.StdLib/Lib/test/test_email/test_parser.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/test_parser.py rename to src/core/IronPython.StdLib/Lib/test/test_email/test_parser.py diff --git a/src/extensions/StdLib/Lib/test/test_email/test_pickleable.py b/src/core/IronPython.StdLib/Lib/test/test_email/test_pickleable.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/test_pickleable.py rename to src/core/IronPython.StdLib/Lib/test/test_email/test_pickleable.py diff --git a/src/extensions/StdLib/Lib/test/test_email/test_policy.py b/src/core/IronPython.StdLib/Lib/test/test_email/test_policy.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/test_policy.py rename to src/core/IronPython.StdLib/Lib/test/test_email/test_policy.py diff --git a/src/extensions/StdLib/Lib/test/test_email/test_utils.py b/src/core/IronPython.StdLib/Lib/test/test_email/test_utils.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/test_utils.py rename to src/core/IronPython.StdLib/Lib/test/test_email/test_utils.py diff --git a/src/extensions/StdLib/Lib/test/test_email/torture_test.py b/src/core/IronPython.StdLib/Lib/test/test_email/torture_test.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_email/torture_test.py rename to src/core/IronPython.StdLib/Lib/test/test_email/torture_test.py diff --git a/src/extensions/StdLib/Lib/test/test_ensurepip.py b/src/core/IronPython.StdLib/Lib/test/test_ensurepip.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_ensurepip.py rename to src/core/IronPython.StdLib/Lib/test/test_ensurepip.py diff --git a/src/extensions/StdLib/Lib/test/test_enum.py b/src/core/IronPython.StdLib/Lib/test/test_enum.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_enum.py rename to src/core/IronPython.StdLib/Lib/test/test_enum.py diff --git a/src/extensions/StdLib/Lib/test/test_enumerate.py b/src/core/IronPython.StdLib/Lib/test/test_enumerate.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_enumerate.py rename to src/core/IronPython.StdLib/Lib/test/test_enumerate.py diff --git a/src/extensions/StdLib/Lib/test/test_eof.py b/src/core/IronPython.StdLib/Lib/test/test_eof.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_eof.py rename to src/core/IronPython.StdLib/Lib/test/test_eof.py diff --git a/src/extensions/StdLib/Lib/test/test_epoll.py b/src/core/IronPython.StdLib/Lib/test/test_epoll.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_epoll.py rename to src/core/IronPython.StdLib/Lib/test/test_epoll.py diff --git a/src/extensions/StdLib/Lib/test/test_errno.py b/src/core/IronPython.StdLib/Lib/test/test_errno.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_errno.py rename to src/core/IronPython.StdLib/Lib/test/test_errno.py diff --git a/src/extensions/StdLib/Lib/test/test_exception_variations.py b/src/core/IronPython.StdLib/Lib/test/test_exception_variations.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_exception_variations.py rename to src/core/IronPython.StdLib/Lib/test/test_exception_variations.py diff --git a/src/extensions/StdLib/Lib/test/test_exceptions.py b/src/core/IronPython.StdLib/Lib/test/test_exceptions.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_exceptions.py rename to src/core/IronPython.StdLib/Lib/test/test_exceptions.py diff --git a/src/extensions/StdLib/Lib/test/test_extcall.py b/src/core/IronPython.StdLib/Lib/test/test_extcall.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_extcall.py rename to src/core/IronPython.StdLib/Lib/test/test_extcall.py diff --git a/src/extensions/StdLib/Lib/test/test_faulthandler.py b/src/core/IronPython.StdLib/Lib/test/test_faulthandler.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_faulthandler.py rename to src/core/IronPython.StdLib/Lib/test/test_faulthandler.py diff --git a/src/extensions/StdLib/Lib/test/test_fcntl.py b/src/core/IronPython.StdLib/Lib/test/test_fcntl.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_fcntl.py rename to src/core/IronPython.StdLib/Lib/test/test_fcntl.py diff --git a/src/extensions/StdLib/Lib/test/test_file.py b/src/core/IronPython.StdLib/Lib/test/test_file.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_file.py rename to src/core/IronPython.StdLib/Lib/test/test_file.py diff --git a/src/extensions/StdLib/Lib/test/test_file_eintr.py b/src/core/IronPython.StdLib/Lib/test/test_file_eintr.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_file_eintr.py rename to src/core/IronPython.StdLib/Lib/test/test_file_eintr.py diff --git a/src/extensions/StdLib/Lib/test/test_filecmp.py b/src/core/IronPython.StdLib/Lib/test/test_filecmp.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_filecmp.py rename to src/core/IronPython.StdLib/Lib/test/test_filecmp.py diff --git a/src/extensions/StdLib/Lib/test/test_fileinput.py b/src/core/IronPython.StdLib/Lib/test/test_fileinput.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_fileinput.py rename to src/core/IronPython.StdLib/Lib/test/test_fileinput.py diff --git a/src/extensions/StdLib/Lib/test/test_fileio.py b/src/core/IronPython.StdLib/Lib/test/test_fileio.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_fileio.py rename to src/core/IronPython.StdLib/Lib/test/test_fileio.py diff --git a/src/extensions/StdLib/Lib/test/test_finalization.py b/src/core/IronPython.StdLib/Lib/test/test_finalization.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_finalization.py rename to src/core/IronPython.StdLib/Lib/test/test_finalization.py diff --git a/src/extensions/StdLib/Lib/test/test_float.py b/src/core/IronPython.StdLib/Lib/test/test_float.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_float.py rename to src/core/IronPython.StdLib/Lib/test/test_float.py diff --git a/src/extensions/StdLib/Lib/test/test_flufl.py b/src/core/IronPython.StdLib/Lib/test/test_flufl.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_flufl.py rename to src/core/IronPython.StdLib/Lib/test/test_flufl.py diff --git a/src/extensions/StdLib/Lib/test/test_fnmatch.py b/src/core/IronPython.StdLib/Lib/test/test_fnmatch.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_fnmatch.py rename to src/core/IronPython.StdLib/Lib/test/test_fnmatch.py diff --git a/src/extensions/StdLib/Lib/test/test_fork1.py b/src/core/IronPython.StdLib/Lib/test/test_fork1.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_fork1.py rename to src/core/IronPython.StdLib/Lib/test/test_fork1.py diff --git a/src/extensions/StdLib/Lib/test/test_format.py b/src/core/IronPython.StdLib/Lib/test/test_format.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_format.py rename to src/core/IronPython.StdLib/Lib/test/test_format.py diff --git a/src/extensions/StdLib/Lib/test/test_fractions.py b/src/core/IronPython.StdLib/Lib/test/test_fractions.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_fractions.py rename to src/core/IronPython.StdLib/Lib/test/test_fractions.py diff --git a/src/extensions/StdLib/Lib/test/test_frame.py b/src/core/IronPython.StdLib/Lib/test/test_frame.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_frame.py rename to src/core/IronPython.StdLib/Lib/test/test_frame.py diff --git a/src/extensions/StdLib/Lib/test/test_fstring.py b/src/core/IronPython.StdLib/Lib/test/test_fstring.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_fstring.py rename to src/core/IronPython.StdLib/Lib/test/test_fstring.py diff --git a/src/extensions/StdLib/Lib/test/test_ftplib.py b/src/core/IronPython.StdLib/Lib/test/test_ftplib.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_ftplib.py rename to src/core/IronPython.StdLib/Lib/test/test_ftplib.py diff --git a/src/extensions/StdLib/Lib/test/test_funcattrs.py b/src/core/IronPython.StdLib/Lib/test/test_funcattrs.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_funcattrs.py rename to src/core/IronPython.StdLib/Lib/test/test_funcattrs.py diff --git a/src/extensions/StdLib/Lib/test/test_functools.py b/src/core/IronPython.StdLib/Lib/test/test_functools.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_functools.py rename to src/core/IronPython.StdLib/Lib/test/test_functools.py diff --git a/src/extensions/StdLib/Lib/test/test_future.py b/src/core/IronPython.StdLib/Lib/test/test_future.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_future.py rename to src/core/IronPython.StdLib/Lib/test/test_future.py diff --git a/src/extensions/StdLib/Lib/test/test_future3.py b/src/core/IronPython.StdLib/Lib/test/test_future3.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_future3.py rename to src/core/IronPython.StdLib/Lib/test/test_future3.py diff --git a/src/extensions/StdLib/Lib/test/test_future4.py b/src/core/IronPython.StdLib/Lib/test/test_future4.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_future4.py rename to src/core/IronPython.StdLib/Lib/test/test_future4.py diff --git a/src/extensions/StdLib/Lib/test/test_future5.py b/src/core/IronPython.StdLib/Lib/test/test_future5.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_future5.py rename to src/core/IronPython.StdLib/Lib/test/test_future5.py diff --git a/src/extensions/StdLib/Lib/test/test_gc.py b/src/core/IronPython.StdLib/Lib/test/test_gc.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_gc.py rename to src/core/IronPython.StdLib/Lib/test/test_gc.py diff --git a/src/extensions/StdLib/Lib/test/test_gdb.py b/src/core/IronPython.StdLib/Lib/test/test_gdb.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_gdb.py rename to src/core/IronPython.StdLib/Lib/test/test_gdb.py diff --git a/src/extensions/StdLib/Lib/test/test_generators.py b/src/core/IronPython.StdLib/Lib/test/test_generators.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_generators.py rename to src/core/IronPython.StdLib/Lib/test/test_generators.py diff --git a/src/extensions/StdLib/Lib/test/test_genericpath.py b/src/core/IronPython.StdLib/Lib/test/test_genericpath.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_genericpath.py rename to src/core/IronPython.StdLib/Lib/test/test_genericpath.py diff --git a/src/extensions/StdLib/Lib/test/test_genexps.py b/src/core/IronPython.StdLib/Lib/test/test_genexps.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_genexps.py rename to src/core/IronPython.StdLib/Lib/test/test_genexps.py diff --git a/src/extensions/StdLib/Lib/test/test_getargs2.py b/src/core/IronPython.StdLib/Lib/test/test_getargs2.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_getargs2.py rename to src/core/IronPython.StdLib/Lib/test/test_getargs2.py diff --git a/src/extensions/StdLib/Lib/test/test_getopt.py b/src/core/IronPython.StdLib/Lib/test/test_getopt.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_getopt.py rename to src/core/IronPython.StdLib/Lib/test/test_getopt.py diff --git a/src/extensions/StdLib/Lib/test/test_getpass.py b/src/core/IronPython.StdLib/Lib/test/test_getpass.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_getpass.py rename to src/core/IronPython.StdLib/Lib/test/test_getpass.py diff --git a/src/extensions/StdLib/Lib/test/test_gettext.py b/src/core/IronPython.StdLib/Lib/test/test_gettext.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_gettext.py rename to src/core/IronPython.StdLib/Lib/test/test_gettext.py diff --git a/src/extensions/StdLib/Lib/test/test_glob.py b/src/core/IronPython.StdLib/Lib/test/test_glob.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_glob.py rename to src/core/IronPython.StdLib/Lib/test/test_glob.py diff --git a/src/extensions/StdLib/Lib/test/test_global.py b/src/core/IronPython.StdLib/Lib/test/test_global.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_global.py rename to src/core/IronPython.StdLib/Lib/test/test_global.py diff --git a/src/extensions/StdLib/Lib/test/test_grammar.py b/src/core/IronPython.StdLib/Lib/test/test_grammar.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_grammar.py rename to src/core/IronPython.StdLib/Lib/test/test_grammar.py diff --git a/src/extensions/StdLib/Lib/test/test_grp.py b/src/core/IronPython.StdLib/Lib/test/test_grp.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_grp.py rename to src/core/IronPython.StdLib/Lib/test/test_grp.py diff --git a/src/extensions/StdLib/Lib/test/test_gzip.py b/src/core/IronPython.StdLib/Lib/test/test_gzip.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_gzip.py rename to src/core/IronPython.StdLib/Lib/test/test_gzip.py diff --git a/src/extensions/StdLib/Lib/test/test_hash.py b/src/core/IronPython.StdLib/Lib/test/test_hash.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_hash.py rename to src/core/IronPython.StdLib/Lib/test/test_hash.py diff --git a/src/extensions/StdLib/Lib/test/test_hashlib.py b/src/core/IronPython.StdLib/Lib/test/test_hashlib.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_hashlib.py rename to src/core/IronPython.StdLib/Lib/test/test_hashlib.py diff --git a/src/extensions/StdLib/Lib/test/test_heapq.py b/src/core/IronPython.StdLib/Lib/test/test_heapq.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_heapq.py rename to src/core/IronPython.StdLib/Lib/test/test_heapq.py diff --git a/src/extensions/StdLib/Lib/test/test_hmac.py b/src/core/IronPython.StdLib/Lib/test/test_hmac.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_hmac.py rename to src/core/IronPython.StdLib/Lib/test/test_hmac.py diff --git a/src/extensions/StdLib/Lib/test/test_html.py b/src/core/IronPython.StdLib/Lib/test/test_html.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_html.py rename to src/core/IronPython.StdLib/Lib/test/test_html.py diff --git a/src/extensions/StdLib/Lib/test/test_htmlparser.py b/src/core/IronPython.StdLib/Lib/test/test_htmlparser.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_htmlparser.py rename to src/core/IronPython.StdLib/Lib/test/test_htmlparser.py diff --git a/src/extensions/StdLib/Lib/test/test_http_cookiejar.py b/src/core/IronPython.StdLib/Lib/test/test_http_cookiejar.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_http_cookiejar.py rename to src/core/IronPython.StdLib/Lib/test/test_http_cookiejar.py diff --git a/src/extensions/StdLib/Lib/test/test_http_cookies.py b/src/core/IronPython.StdLib/Lib/test/test_http_cookies.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_http_cookies.py rename to src/core/IronPython.StdLib/Lib/test/test_http_cookies.py diff --git a/src/extensions/StdLib/Lib/test/test_httplib.py b/src/core/IronPython.StdLib/Lib/test/test_httplib.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_httplib.py rename to src/core/IronPython.StdLib/Lib/test/test_httplib.py diff --git a/src/extensions/StdLib/Lib/test/test_httpservers.py b/src/core/IronPython.StdLib/Lib/test/test_httpservers.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_httpservers.py rename to src/core/IronPython.StdLib/Lib/test/test_httpservers.py diff --git a/src/extensions/StdLib/Lib/test/test_idle.py b/src/core/IronPython.StdLib/Lib/test/test_idle.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_idle.py rename to src/core/IronPython.StdLib/Lib/test/test_idle.py diff --git a/src/extensions/StdLib/Lib/test/test_imaplib.py b/src/core/IronPython.StdLib/Lib/test/test_imaplib.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_imaplib.py rename to src/core/IronPython.StdLib/Lib/test/test_imaplib.py diff --git a/src/extensions/StdLib/Lib/test/test_imghdr.py b/src/core/IronPython.StdLib/Lib/test/test_imghdr.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_imghdr.py rename to src/core/IronPython.StdLib/Lib/test/test_imghdr.py diff --git a/src/extensions/StdLib/Lib/test/test_imp.py b/src/core/IronPython.StdLib/Lib/test/test_imp.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_imp.py rename to src/core/IronPython.StdLib/Lib/test/test_imp.py diff --git a/src/extensions/StdLib/Lib/test/test_import.py b/src/core/IronPython.StdLib/Lib/test/test_import.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_import.py rename to src/core/IronPython.StdLib/Lib/test/test_import.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/__init__.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/__init__.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/__init__.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/__main__.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/__main__.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/__main__.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/abc.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/abc.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/abc.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/abc.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/builtin/__init__.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/builtin/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/builtin/__init__.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/builtin/__init__.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/builtin/__main__.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/builtin/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/builtin/__main__.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/builtin/__main__.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/builtin/test_finder.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/builtin/test_finder.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/builtin/test_finder.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/builtin/test_finder.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/builtin/test_loader.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/builtin/test_loader.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/builtin/test_loader.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/builtin/test_loader.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/builtin/util.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/builtin/util.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/builtin/util.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/builtin/util.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/extension/__init__.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/extension/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/extension/__init__.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/extension/__init__.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/extension/__main__.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/extension/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/extension/__main__.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/extension/__main__.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/extension/test_case_sensitivity.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/extension/test_finder.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/extension/test_finder.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/extension/test_finder.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/extension/test_finder.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/extension/test_loader.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/extension/test_loader.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/extension/test_loader.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/extension/test_loader.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/extension/test_path_hook.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/extension/test_path_hook.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/extension/test_path_hook.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/extension/test_path_hook.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/extension/util.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/extension/util.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/extension/util.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/extension/util.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/frozen/__init__.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/frozen/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/frozen/__init__.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/frozen/__init__.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/frozen/__main__.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/frozen/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/frozen/__main__.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/frozen/__main__.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/frozen/test_finder.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/frozen/test_finder.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/frozen/test_finder.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/frozen/test_finder.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/frozen/test_loader.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/frozen/test_loader.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/frozen/test_loader.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/frozen/test_loader.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/import_/__init__.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/import_/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/import_/__init__.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/import_/__init__.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/import_/__main__.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/import_/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/import_/__main__.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/import_/__main__.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/import_/test___loader__.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/import_/test___loader__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/import_/test___loader__.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/import_/test___loader__.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/import_/test___package__.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/import_/test___package__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/import_/test___package__.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/import_/test___package__.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/import_/test_api.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/import_/test_api.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/import_/test_api.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/import_/test_api.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/import_/test_caching.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/import_/test_caching.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/import_/test_caching.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/import_/test_caching.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/import_/test_fromlist.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/import_/test_fromlist.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/import_/test_fromlist.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/import_/test_fromlist.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/import_/test_meta_path.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/import_/test_meta_path.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/import_/test_meta_path.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/import_/test_meta_path.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/import_/test_packages.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/import_/test_packages.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/import_/test_packages.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/import_/test_packages.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/import_/test_path.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/import_/test_path.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/import_/test_path.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/import_/test_path.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/import_/test_relative_imports.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/import_/test_relative_imports.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/import_/test_relative_imports.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/import_/util.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/import_/util.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/import_/util.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/import_/util.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/one.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/both_portions/foo/two.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip b/src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip rename to src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/missing_directory.zip diff --git a/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty b/src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty rename to src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test/empty diff --git a/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip b/src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip rename to src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/nested_portion1.zip diff --git a/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/__init__.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo/one.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/portion1/foo/one.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/portion2/foo/two.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/project1/parent/child/one.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/project2/parent/child/two.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/project3/parent/child/three.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip b/src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip rename to src/core/IronPython.StdLib/Lib/test/test_importlib/namespace_pkgs/top_level_portion1.zip diff --git a/src/extensions/StdLib/Lib/test/test_importlib/regrtest.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/regrtest.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/regrtest.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/regrtest.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/source/__init__.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/source/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/source/__init__.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/source/__init__.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/source/__main__.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/source/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/source/__main__.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/source/__main__.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/source/test_case_sensitivity.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/source/test_file_loader.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/source/test_file_loader.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/source/test_file_loader.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/source/test_file_loader.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/source/test_finder.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/source/test_finder.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/source/test_finder.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/source/test_finder.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/source/test_path_hook.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/source/test_path_hook.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/source/test_path_hook.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/source/test_path_hook.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/source/test_source_encoding.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/source/test_source_encoding.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/source/test_source_encoding.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/source/test_source_encoding.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/source/util.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/source/util.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/source/util.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/source/util.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/test_abc.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/test_abc.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/test_abc.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/test_abc.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/test_api.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/test_api.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/test_api.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/test_api.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/test_locks.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/test_locks.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/test_locks.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/test_locks.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/test_namespace_pkgs.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/test_namespace_pkgs.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/test_namespace_pkgs.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/test_spec.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/test_spec.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/test_spec.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/test_spec.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/test_util.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/test_util.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/test_util.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/test_util.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/test_windows.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/test_windows.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/test_windows.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/test_windows.py diff --git a/src/extensions/StdLib/Lib/test/test_importlib/util.py b/src/core/IronPython.StdLib/Lib/test/test_importlib/util.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_importlib/util.py rename to src/core/IronPython.StdLib/Lib/test/test_importlib/util.py diff --git a/src/extensions/StdLib/Lib/test/test_index.py b/src/core/IronPython.StdLib/Lib/test/test_index.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_index.py rename to src/core/IronPython.StdLib/Lib/test/test_index.py diff --git a/src/extensions/StdLib/Lib/test/test_inspect.py b/src/core/IronPython.StdLib/Lib/test/test_inspect.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_inspect.py rename to src/core/IronPython.StdLib/Lib/test/test_inspect.py diff --git a/src/extensions/StdLib/Lib/test/test_int.py b/src/core/IronPython.StdLib/Lib/test/test_int.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_int.py rename to src/core/IronPython.StdLib/Lib/test/test_int.py diff --git a/src/extensions/StdLib/Lib/test/test_int_literal.py b/src/core/IronPython.StdLib/Lib/test/test_int_literal.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_int_literal.py rename to src/core/IronPython.StdLib/Lib/test/test_int_literal.py diff --git a/src/extensions/StdLib/Lib/test/test_io.py b/src/core/IronPython.StdLib/Lib/test/test_io.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_io.py rename to src/core/IronPython.StdLib/Lib/test/test_io.py diff --git a/src/extensions/StdLib/Lib/test/test_ioctl.py b/src/core/IronPython.StdLib/Lib/test/test_ioctl.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_ioctl.py rename to src/core/IronPython.StdLib/Lib/test/test_ioctl.py diff --git a/src/extensions/StdLib/Lib/test/test_ipaddress.py b/src/core/IronPython.StdLib/Lib/test/test_ipaddress.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_ipaddress.py rename to src/core/IronPython.StdLib/Lib/test/test_ipaddress.py diff --git a/src/extensions/StdLib/Lib/test/test_isinstance.py b/src/core/IronPython.StdLib/Lib/test/test_isinstance.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_isinstance.py rename to src/core/IronPython.StdLib/Lib/test/test_isinstance.py diff --git a/src/extensions/StdLib/Lib/test/test_iter.py b/src/core/IronPython.StdLib/Lib/test/test_iter.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_iter.py rename to src/core/IronPython.StdLib/Lib/test/test_iter.py diff --git a/src/extensions/StdLib/Lib/test/test_iterlen.py b/src/core/IronPython.StdLib/Lib/test/test_iterlen.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_iterlen.py rename to src/core/IronPython.StdLib/Lib/test/test_iterlen.py diff --git a/src/extensions/StdLib/Lib/test/test_itertools.py b/src/core/IronPython.StdLib/Lib/test/test_itertools.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_itertools.py rename to src/core/IronPython.StdLib/Lib/test/test_itertools.py diff --git a/src/extensions/StdLib/Lib/test/test_json/__init__.py b/src/core/IronPython.StdLib/Lib/test/test_json/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_json/__init__.py rename to src/core/IronPython.StdLib/Lib/test/test_json/__init__.py diff --git a/src/extensions/StdLib/Lib/test/test_json/__main__.py b/src/core/IronPython.StdLib/Lib/test/test_json/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_json/__main__.py rename to src/core/IronPython.StdLib/Lib/test/test_json/__main__.py diff --git a/src/extensions/StdLib/Lib/test/test_json/test_decode.py b/src/core/IronPython.StdLib/Lib/test/test_json/test_decode.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_json/test_decode.py rename to src/core/IronPython.StdLib/Lib/test/test_json/test_decode.py diff --git a/src/extensions/StdLib/Lib/test/test_json/test_default.py b/src/core/IronPython.StdLib/Lib/test/test_json/test_default.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_json/test_default.py rename to src/core/IronPython.StdLib/Lib/test/test_json/test_default.py diff --git a/src/extensions/StdLib/Lib/test/test_json/test_dump.py b/src/core/IronPython.StdLib/Lib/test/test_json/test_dump.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_json/test_dump.py rename to src/core/IronPython.StdLib/Lib/test/test_json/test_dump.py diff --git a/src/extensions/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py b/src/core/IronPython.StdLib/Lib/test/test_json/test_encode_basestring_ascii.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_json/test_encode_basestring_ascii.py rename to src/core/IronPython.StdLib/Lib/test/test_json/test_encode_basestring_ascii.py diff --git a/src/extensions/StdLib/Lib/test/test_json/test_enum.py b/src/core/IronPython.StdLib/Lib/test/test_json/test_enum.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_json/test_enum.py rename to src/core/IronPython.StdLib/Lib/test/test_json/test_enum.py diff --git a/src/extensions/StdLib/Lib/test/test_json/test_fail.py b/src/core/IronPython.StdLib/Lib/test/test_json/test_fail.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_json/test_fail.py rename to src/core/IronPython.StdLib/Lib/test/test_json/test_fail.py diff --git a/src/extensions/StdLib/Lib/test/test_json/test_float.py b/src/core/IronPython.StdLib/Lib/test/test_json/test_float.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_json/test_float.py rename to src/core/IronPython.StdLib/Lib/test/test_json/test_float.py diff --git a/src/extensions/StdLib/Lib/test/test_json/test_indent.py b/src/core/IronPython.StdLib/Lib/test/test_json/test_indent.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_json/test_indent.py rename to src/core/IronPython.StdLib/Lib/test/test_json/test_indent.py diff --git a/src/extensions/StdLib/Lib/test/test_json/test_pass1.py b/src/core/IronPython.StdLib/Lib/test/test_json/test_pass1.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_json/test_pass1.py rename to src/core/IronPython.StdLib/Lib/test/test_json/test_pass1.py diff --git a/src/extensions/StdLib/Lib/test/test_json/test_pass2.py b/src/core/IronPython.StdLib/Lib/test/test_json/test_pass2.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_json/test_pass2.py rename to src/core/IronPython.StdLib/Lib/test/test_json/test_pass2.py diff --git a/src/extensions/StdLib/Lib/test/test_json/test_pass3.py b/src/core/IronPython.StdLib/Lib/test/test_json/test_pass3.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_json/test_pass3.py rename to src/core/IronPython.StdLib/Lib/test/test_json/test_pass3.py diff --git a/src/extensions/StdLib/Lib/test/test_json/test_recursion.py b/src/core/IronPython.StdLib/Lib/test/test_json/test_recursion.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_json/test_recursion.py rename to src/core/IronPython.StdLib/Lib/test/test_json/test_recursion.py diff --git a/src/extensions/StdLib/Lib/test/test_json/test_scanstring.py b/src/core/IronPython.StdLib/Lib/test/test_json/test_scanstring.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_json/test_scanstring.py rename to src/core/IronPython.StdLib/Lib/test/test_json/test_scanstring.py diff --git a/src/extensions/StdLib/Lib/test/test_json/test_separators.py b/src/core/IronPython.StdLib/Lib/test/test_json/test_separators.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_json/test_separators.py rename to src/core/IronPython.StdLib/Lib/test/test_json/test_separators.py diff --git a/src/extensions/StdLib/Lib/test/test_json/test_speedups.py b/src/core/IronPython.StdLib/Lib/test/test_json/test_speedups.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_json/test_speedups.py rename to src/core/IronPython.StdLib/Lib/test/test_json/test_speedups.py diff --git a/src/extensions/StdLib/Lib/test/test_json/test_tool.py b/src/core/IronPython.StdLib/Lib/test/test_json/test_tool.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_json/test_tool.py rename to src/core/IronPython.StdLib/Lib/test/test_json/test_tool.py diff --git a/src/extensions/StdLib/Lib/test/test_json/test_unicode.py b/src/core/IronPython.StdLib/Lib/test/test_json/test_unicode.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_json/test_unicode.py rename to src/core/IronPython.StdLib/Lib/test/test_json/test_unicode.py diff --git a/src/extensions/StdLib/Lib/test/test_keyword.py b/src/core/IronPython.StdLib/Lib/test/test_keyword.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_keyword.py rename to src/core/IronPython.StdLib/Lib/test/test_keyword.py diff --git a/src/extensions/StdLib/Lib/test/test_keywordonlyarg.py b/src/core/IronPython.StdLib/Lib/test/test_keywordonlyarg.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_keywordonlyarg.py rename to src/core/IronPython.StdLib/Lib/test/test_keywordonlyarg.py diff --git a/src/extensions/StdLib/Lib/test/test_kqueue.py b/src/core/IronPython.StdLib/Lib/test/test_kqueue.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_kqueue.py rename to src/core/IronPython.StdLib/Lib/test/test_kqueue.py diff --git a/src/extensions/StdLib/Lib/test/test_largefile.py b/src/core/IronPython.StdLib/Lib/test/test_largefile.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_largefile.py rename to src/core/IronPython.StdLib/Lib/test/test_largefile.py diff --git a/src/extensions/StdLib/Lib/test/test_lib2to3.py b/src/core/IronPython.StdLib/Lib/test/test_lib2to3.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_lib2to3.py rename to src/core/IronPython.StdLib/Lib/test/test_lib2to3.py diff --git a/src/extensions/StdLib/Lib/test/test_linecache.py b/src/core/IronPython.StdLib/Lib/test/test_linecache.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_linecache.py rename to src/core/IronPython.StdLib/Lib/test/test_linecache.py diff --git a/src/extensions/StdLib/Lib/test/test_list.py b/src/core/IronPython.StdLib/Lib/test/test_list.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_list.py rename to src/core/IronPython.StdLib/Lib/test/test_list.py diff --git a/src/extensions/StdLib/Lib/test/test_listcomps.py b/src/core/IronPython.StdLib/Lib/test/test_listcomps.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_listcomps.py rename to src/core/IronPython.StdLib/Lib/test/test_listcomps.py diff --git a/src/extensions/StdLib/Lib/test/test_locale.py b/src/core/IronPython.StdLib/Lib/test/test_locale.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_locale.py rename to src/core/IronPython.StdLib/Lib/test/test_locale.py diff --git a/src/extensions/StdLib/Lib/test/test_logging.py b/src/core/IronPython.StdLib/Lib/test/test_logging.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_logging.py rename to src/core/IronPython.StdLib/Lib/test/test_logging.py diff --git a/src/extensions/StdLib/Lib/test/test_long.py b/src/core/IronPython.StdLib/Lib/test/test_long.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_long.py rename to src/core/IronPython.StdLib/Lib/test/test_long.py diff --git a/src/extensions/StdLib/Lib/test/test_longexp.py b/src/core/IronPython.StdLib/Lib/test/test_longexp.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_longexp.py rename to src/core/IronPython.StdLib/Lib/test/test_longexp.py diff --git a/src/extensions/StdLib/Lib/test/test_lzma.py b/src/core/IronPython.StdLib/Lib/test/test_lzma.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_lzma.py rename to src/core/IronPython.StdLib/Lib/test/test_lzma.py diff --git a/src/extensions/StdLib/Lib/test/test_macpath.py b/src/core/IronPython.StdLib/Lib/test/test_macpath.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_macpath.py rename to src/core/IronPython.StdLib/Lib/test/test_macpath.py diff --git a/src/extensions/StdLib/Lib/test/test_macurl2path.py b/src/core/IronPython.StdLib/Lib/test/test_macurl2path.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_macurl2path.py rename to src/core/IronPython.StdLib/Lib/test/test_macurl2path.py diff --git a/src/extensions/StdLib/Lib/test/test_mailbox.py b/src/core/IronPython.StdLib/Lib/test/test_mailbox.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_mailbox.py rename to src/core/IronPython.StdLib/Lib/test/test_mailbox.py diff --git a/src/extensions/StdLib/Lib/test/test_mailcap.py b/src/core/IronPython.StdLib/Lib/test/test_mailcap.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_mailcap.py rename to src/core/IronPython.StdLib/Lib/test/test_mailcap.py diff --git a/src/extensions/StdLib/Lib/test/test_marshal.py b/src/core/IronPython.StdLib/Lib/test/test_marshal.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_marshal.py rename to src/core/IronPython.StdLib/Lib/test/test_marshal.py diff --git a/src/extensions/StdLib/Lib/test/test_math.py b/src/core/IronPython.StdLib/Lib/test/test_math.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_math.py rename to src/core/IronPython.StdLib/Lib/test/test_math.py diff --git a/src/extensions/StdLib/Lib/test/test_memoryio.py b/src/core/IronPython.StdLib/Lib/test/test_memoryio.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_memoryio.py rename to src/core/IronPython.StdLib/Lib/test/test_memoryio.py diff --git a/src/extensions/StdLib/Lib/test/test_memoryview.py b/src/core/IronPython.StdLib/Lib/test/test_memoryview.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_memoryview.py rename to src/core/IronPython.StdLib/Lib/test/test_memoryview.py diff --git a/src/extensions/StdLib/Lib/test/test_metaclass.py b/src/core/IronPython.StdLib/Lib/test/test_metaclass.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_metaclass.py rename to src/core/IronPython.StdLib/Lib/test/test_metaclass.py diff --git a/src/extensions/StdLib/Lib/test/test_mimetypes.py b/src/core/IronPython.StdLib/Lib/test/test_mimetypes.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_mimetypes.py rename to src/core/IronPython.StdLib/Lib/test/test_mimetypes.py diff --git a/src/extensions/StdLib/Lib/test/test_minidom.py b/src/core/IronPython.StdLib/Lib/test/test_minidom.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_minidom.py rename to src/core/IronPython.StdLib/Lib/test/test_minidom.py diff --git a/src/extensions/StdLib/Lib/test/test_mmap.py b/src/core/IronPython.StdLib/Lib/test/test_mmap.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_mmap.py rename to src/core/IronPython.StdLib/Lib/test/test_mmap.py diff --git a/src/extensions/StdLib/Lib/test/test_module.py b/src/core/IronPython.StdLib/Lib/test/test_module.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_module.py rename to src/core/IronPython.StdLib/Lib/test/test_module.py diff --git a/src/extensions/StdLib/Lib/test/test_modulefinder.py b/src/core/IronPython.StdLib/Lib/test/test_modulefinder.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_modulefinder.py rename to src/core/IronPython.StdLib/Lib/test/test_modulefinder.py diff --git a/src/extensions/StdLib/Lib/test/test_msilib.py b/src/core/IronPython.StdLib/Lib/test/test_msilib.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_msilib.py rename to src/core/IronPython.StdLib/Lib/test/test_msilib.py diff --git a/src/extensions/StdLib/Lib/test/test_multibytecodec.py b/src/core/IronPython.StdLib/Lib/test/test_multibytecodec.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_multibytecodec.py rename to src/core/IronPython.StdLib/Lib/test/test_multibytecodec.py diff --git a/src/extensions/StdLib/Lib/test/test_multiprocessing_fork.py b/src/core/IronPython.StdLib/Lib/test/test_multiprocessing_fork.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_multiprocessing_fork.py rename to src/core/IronPython.StdLib/Lib/test/test_multiprocessing_fork.py diff --git a/src/extensions/StdLib/Lib/test/test_multiprocessing_forkserver.py b/src/core/IronPython.StdLib/Lib/test/test_multiprocessing_forkserver.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_multiprocessing_forkserver.py rename to src/core/IronPython.StdLib/Lib/test/test_multiprocessing_forkserver.py diff --git a/src/extensions/StdLib/Lib/test/test_multiprocessing_main_handling.py b/src/core/IronPython.StdLib/Lib/test/test_multiprocessing_main_handling.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_multiprocessing_main_handling.py rename to src/core/IronPython.StdLib/Lib/test/test_multiprocessing_main_handling.py diff --git a/src/extensions/StdLib/Lib/test/test_multiprocessing_spawn.py b/src/core/IronPython.StdLib/Lib/test/test_multiprocessing_spawn.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_multiprocessing_spawn.py rename to src/core/IronPython.StdLib/Lib/test/test_multiprocessing_spawn.py diff --git a/src/extensions/StdLib/Lib/test/test_netrc.py b/src/core/IronPython.StdLib/Lib/test/test_netrc.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_netrc.py rename to src/core/IronPython.StdLib/Lib/test/test_netrc.py diff --git a/src/extensions/StdLib/Lib/test/test_nis.py b/src/core/IronPython.StdLib/Lib/test/test_nis.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_nis.py rename to src/core/IronPython.StdLib/Lib/test/test_nis.py diff --git a/src/extensions/StdLib/Lib/test/test_nntplib.py b/src/core/IronPython.StdLib/Lib/test/test_nntplib.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_nntplib.py rename to src/core/IronPython.StdLib/Lib/test/test_nntplib.py diff --git a/src/extensions/StdLib/Lib/test/test_normalization.py b/src/core/IronPython.StdLib/Lib/test/test_normalization.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_normalization.py rename to src/core/IronPython.StdLib/Lib/test/test_normalization.py diff --git a/src/extensions/StdLib/Lib/test/test_ntpath.py b/src/core/IronPython.StdLib/Lib/test/test_ntpath.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_ntpath.py rename to src/core/IronPython.StdLib/Lib/test/test_ntpath.py diff --git a/src/extensions/StdLib/Lib/test/test_numeric_tower.py b/src/core/IronPython.StdLib/Lib/test/test_numeric_tower.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_numeric_tower.py rename to src/core/IronPython.StdLib/Lib/test/test_numeric_tower.py diff --git a/src/extensions/StdLib/Lib/test/test_opcodes.py b/src/core/IronPython.StdLib/Lib/test/test_opcodes.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_opcodes.py rename to src/core/IronPython.StdLib/Lib/test/test_opcodes.py diff --git a/src/extensions/StdLib/Lib/test/test_openpty.py b/src/core/IronPython.StdLib/Lib/test/test_openpty.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_openpty.py rename to src/core/IronPython.StdLib/Lib/test/test_openpty.py diff --git a/src/extensions/StdLib/Lib/test/test_operator.py b/src/core/IronPython.StdLib/Lib/test/test_operator.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_operator.py rename to src/core/IronPython.StdLib/Lib/test/test_operator.py diff --git a/src/extensions/StdLib/Lib/test/test_optparse.py b/src/core/IronPython.StdLib/Lib/test/test_optparse.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_optparse.py rename to src/core/IronPython.StdLib/Lib/test/test_optparse.py diff --git a/src/extensions/StdLib/Lib/test/test_ordered_dict.py b/src/core/IronPython.StdLib/Lib/test/test_ordered_dict.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_ordered_dict.py rename to src/core/IronPython.StdLib/Lib/test/test_ordered_dict.py diff --git a/src/extensions/StdLib/Lib/test/test_os.py b/src/core/IronPython.StdLib/Lib/test/test_os.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_os.py rename to src/core/IronPython.StdLib/Lib/test/test_os.py diff --git a/src/extensions/StdLib/Lib/test/test_ossaudiodev.py b/src/core/IronPython.StdLib/Lib/test/test_ossaudiodev.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_ossaudiodev.py rename to src/core/IronPython.StdLib/Lib/test/test_ossaudiodev.py diff --git a/src/extensions/StdLib/Lib/test/test_osx_env.py b/src/core/IronPython.StdLib/Lib/test/test_osx_env.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_osx_env.py rename to src/core/IronPython.StdLib/Lib/test/test_osx_env.py diff --git a/src/extensions/StdLib/Lib/test/test_parser.py b/src/core/IronPython.StdLib/Lib/test/test_parser.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_parser.py rename to src/core/IronPython.StdLib/Lib/test/test_parser.py diff --git a/src/extensions/StdLib/Lib/test/test_pathlib.py b/src/core/IronPython.StdLib/Lib/test/test_pathlib.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pathlib.py rename to src/core/IronPython.StdLib/Lib/test/test_pathlib.py diff --git a/src/extensions/StdLib/Lib/test/test_pdb.py b/src/core/IronPython.StdLib/Lib/test/test_pdb.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pdb.py rename to src/core/IronPython.StdLib/Lib/test/test_pdb.py diff --git a/src/extensions/StdLib/Lib/test/test_peepholer.py b/src/core/IronPython.StdLib/Lib/test/test_peepholer.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_peepholer.py rename to src/core/IronPython.StdLib/Lib/test/test_peepholer.py diff --git a/src/extensions/StdLib/Lib/test/test_pep247.py b/src/core/IronPython.StdLib/Lib/test/test_pep247.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pep247.py rename to src/core/IronPython.StdLib/Lib/test/test_pep247.py diff --git a/src/extensions/StdLib/Lib/test/test_pep277.py b/src/core/IronPython.StdLib/Lib/test/test_pep277.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pep277.py rename to src/core/IronPython.StdLib/Lib/test/test_pep277.py diff --git a/src/extensions/StdLib/Lib/test/test_pep292.py b/src/core/IronPython.StdLib/Lib/test/test_pep292.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pep292.py rename to src/core/IronPython.StdLib/Lib/test/test_pep292.py diff --git a/src/extensions/StdLib/Lib/test/test_pep3120.py b/src/core/IronPython.StdLib/Lib/test/test_pep3120.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pep3120.py rename to src/core/IronPython.StdLib/Lib/test/test_pep3120.py diff --git a/src/extensions/StdLib/Lib/test/test_pep3131.py b/src/core/IronPython.StdLib/Lib/test/test_pep3131.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pep3131.py rename to src/core/IronPython.StdLib/Lib/test/test_pep3131.py diff --git a/src/extensions/StdLib/Lib/test/test_pep3151.py b/src/core/IronPython.StdLib/Lib/test/test_pep3151.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pep3151.py rename to src/core/IronPython.StdLib/Lib/test/test_pep3151.py diff --git a/src/extensions/StdLib/Lib/test/test_pep352.py b/src/core/IronPython.StdLib/Lib/test/test_pep352.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pep352.py rename to src/core/IronPython.StdLib/Lib/test/test_pep352.py diff --git a/src/extensions/StdLib/Lib/test/test_pep380.py b/src/core/IronPython.StdLib/Lib/test/test_pep380.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pep380.py rename to src/core/IronPython.StdLib/Lib/test/test_pep380.py diff --git a/src/extensions/StdLib/Lib/test/test_pep479.py b/src/core/IronPython.StdLib/Lib/test/test_pep479.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pep479.py rename to src/core/IronPython.StdLib/Lib/test/test_pep479.py diff --git a/src/extensions/StdLib/Lib/test/test_pickle.py b/src/core/IronPython.StdLib/Lib/test/test_pickle.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pickle.py rename to src/core/IronPython.StdLib/Lib/test/test_pickle.py diff --git a/src/extensions/StdLib/Lib/test/test_pickletools.py b/src/core/IronPython.StdLib/Lib/test/test_pickletools.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pickletools.py rename to src/core/IronPython.StdLib/Lib/test/test_pickletools.py diff --git a/src/extensions/StdLib/Lib/test/test_pipes.py b/src/core/IronPython.StdLib/Lib/test/test_pipes.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pipes.py rename to src/core/IronPython.StdLib/Lib/test/test_pipes.py diff --git a/src/extensions/StdLib/Lib/test/test_pkg.py b/src/core/IronPython.StdLib/Lib/test/test_pkg.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pkg.py rename to src/core/IronPython.StdLib/Lib/test/test_pkg.py diff --git a/src/extensions/StdLib/Lib/test/test_pkgimport.py b/src/core/IronPython.StdLib/Lib/test/test_pkgimport.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pkgimport.py rename to src/core/IronPython.StdLib/Lib/test/test_pkgimport.py diff --git a/src/extensions/StdLib/Lib/test/test_pkgutil.py b/src/core/IronPython.StdLib/Lib/test/test_pkgutil.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pkgutil.py rename to src/core/IronPython.StdLib/Lib/test/test_pkgutil.py diff --git a/src/extensions/StdLib/Lib/test/test_platform.py b/src/core/IronPython.StdLib/Lib/test/test_platform.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_platform.py rename to src/core/IronPython.StdLib/Lib/test/test_platform.py diff --git a/src/extensions/StdLib/Lib/test/test_plistlib.py b/src/core/IronPython.StdLib/Lib/test/test_plistlib.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_plistlib.py rename to src/core/IronPython.StdLib/Lib/test/test_plistlib.py diff --git a/src/extensions/StdLib/Lib/test/test_poll.py b/src/core/IronPython.StdLib/Lib/test/test_poll.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_poll.py rename to src/core/IronPython.StdLib/Lib/test/test_poll.py diff --git a/src/extensions/StdLib/Lib/test/test_popen.py b/src/core/IronPython.StdLib/Lib/test/test_popen.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_popen.py rename to src/core/IronPython.StdLib/Lib/test/test_popen.py diff --git a/src/extensions/StdLib/Lib/test/test_poplib.py b/src/core/IronPython.StdLib/Lib/test/test_poplib.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_poplib.py rename to src/core/IronPython.StdLib/Lib/test/test_poplib.py diff --git a/src/extensions/StdLib/Lib/test/test_posix.py b/src/core/IronPython.StdLib/Lib/test/test_posix.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_posix.py rename to src/core/IronPython.StdLib/Lib/test/test_posix.py diff --git a/src/extensions/StdLib/Lib/test/test_posixpath.py b/src/core/IronPython.StdLib/Lib/test/test_posixpath.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_posixpath.py rename to src/core/IronPython.StdLib/Lib/test/test_posixpath.py diff --git a/src/extensions/StdLib/Lib/test/test_pow.py b/src/core/IronPython.StdLib/Lib/test/test_pow.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pow.py rename to src/core/IronPython.StdLib/Lib/test/test_pow.py diff --git a/src/extensions/StdLib/Lib/test/test_pprint.py b/src/core/IronPython.StdLib/Lib/test/test_pprint.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pprint.py rename to src/core/IronPython.StdLib/Lib/test/test_pprint.py diff --git a/src/extensions/StdLib/Lib/test/test_print.py b/src/core/IronPython.StdLib/Lib/test/test_print.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_print.py rename to src/core/IronPython.StdLib/Lib/test/test_print.py diff --git a/src/extensions/StdLib/Lib/test/test_profile.py b/src/core/IronPython.StdLib/Lib/test/test_profile.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_profile.py rename to src/core/IronPython.StdLib/Lib/test/test_profile.py diff --git a/src/extensions/StdLib/Lib/test/test_property.py b/src/core/IronPython.StdLib/Lib/test/test_property.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_property.py rename to src/core/IronPython.StdLib/Lib/test/test_property.py diff --git a/src/extensions/StdLib/Lib/test/test_pstats.py b/src/core/IronPython.StdLib/Lib/test/test_pstats.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pstats.py rename to src/core/IronPython.StdLib/Lib/test/test_pstats.py diff --git a/src/extensions/StdLib/Lib/test/test_pty.py b/src/core/IronPython.StdLib/Lib/test/test_pty.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pty.py rename to src/core/IronPython.StdLib/Lib/test/test_pty.py diff --git a/src/extensions/StdLib/Lib/test/test_pulldom.py b/src/core/IronPython.StdLib/Lib/test/test_pulldom.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pulldom.py rename to src/core/IronPython.StdLib/Lib/test/test_pulldom.py diff --git a/src/extensions/StdLib/Lib/test/test_pwd.py b/src/core/IronPython.StdLib/Lib/test/test_pwd.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pwd.py rename to src/core/IronPython.StdLib/Lib/test/test_pwd.py diff --git a/src/extensions/StdLib/Lib/test/test_py_compile.py b/src/core/IronPython.StdLib/Lib/test/test_py_compile.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_py_compile.py rename to src/core/IronPython.StdLib/Lib/test/test_py_compile.py diff --git a/src/extensions/StdLib/Lib/test/test_pyclbr.py b/src/core/IronPython.StdLib/Lib/test/test_pyclbr.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pyclbr.py rename to src/core/IronPython.StdLib/Lib/test/test_pyclbr.py diff --git a/src/extensions/StdLib/Lib/test/test_pydoc.py b/src/core/IronPython.StdLib/Lib/test/test_pydoc.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pydoc.py rename to src/core/IronPython.StdLib/Lib/test/test_pydoc.py diff --git a/src/extensions/StdLib/Lib/test/test_pyexpat.py b/src/core/IronPython.StdLib/Lib/test/test_pyexpat.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_pyexpat.py rename to src/core/IronPython.StdLib/Lib/test/test_pyexpat.py diff --git a/src/extensions/StdLib/Lib/test/test_queue.py b/src/core/IronPython.StdLib/Lib/test/test_queue.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_queue.py rename to src/core/IronPython.StdLib/Lib/test/test_queue.py diff --git a/src/extensions/StdLib/Lib/test/test_quopri.py b/src/core/IronPython.StdLib/Lib/test/test_quopri.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_quopri.py rename to src/core/IronPython.StdLib/Lib/test/test_quopri.py diff --git a/src/extensions/StdLib/Lib/test/test_raise.py b/src/core/IronPython.StdLib/Lib/test/test_raise.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_raise.py rename to src/core/IronPython.StdLib/Lib/test/test_raise.py diff --git a/src/extensions/StdLib/Lib/test/test_random.py b/src/core/IronPython.StdLib/Lib/test/test_random.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_random.py rename to src/core/IronPython.StdLib/Lib/test/test_random.py diff --git a/src/extensions/StdLib/Lib/test/test_range.py b/src/core/IronPython.StdLib/Lib/test/test_range.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_range.py rename to src/core/IronPython.StdLib/Lib/test/test_range.py diff --git a/src/extensions/StdLib/Lib/test/test_re.py b/src/core/IronPython.StdLib/Lib/test/test_re.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_re.py rename to src/core/IronPython.StdLib/Lib/test/test_re.py diff --git a/src/extensions/StdLib/Lib/test/test_readline.py b/src/core/IronPython.StdLib/Lib/test/test_readline.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_readline.py rename to src/core/IronPython.StdLib/Lib/test/test_readline.py diff --git a/src/extensions/StdLib/Lib/test/test_regrtest.py b/src/core/IronPython.StdLib/Lib/test/test_regrtest.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_regrtest.py rename to src/core/IronPython.StdLib/Lib/test/test_regrtest.py diff --git a/src/extensions/StdLib/Lib/test/test_reprlib.py b/src/core/IronPython.StdLib/Lib/test/test_reprlib.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_reprlib.py rename to src/core/IronPython.StdLib/Lib/test/test_reprlib.py diff --git a/src/extensions/StdLib/Lib/test/test_resource.py b/src/core/IronPython.StdLib/Lib/test/test_resource.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_resource.py rename to src/core/IronPython.StdLib/Lib/test/test_resource.py diff --git a/src/extensions/StdLib/Lib/test/test_richcmp.py b/src/core/IronPython.StdLib/Lib/test/test_richcmp.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_richcmp.py rename to src/core/IronPython.StdLib/Lib/test/test_richcmp.py diff --git a/src/extensions/StdLib/Lib/test/test_rlcompleter.py b/src/core/IronPython.StdLib/Lib/test/test_rlcompleter.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_rlcompleter.py rename to src/core/IronPython.StdLib/Lib/test/test_rlcompleter.py diff --git a/src/extensions/StdLib/Lib/test/test_robotparser.py b/src/core/IronPython.StdLib/Lib/test/test_robotparser.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_robotparser.py rename to src/core/IronPython.StdLib/Lib/test/test_robotparser.py diff --git a/src/extensions/StdLib/Lib/test/test_runpy.py b/src/core/IronPython.StdLib/Lib/test/test_runpy.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_runpy.py rename to src/core/IronPython.StdLib/Lib/test/test_runpy.py diff --git a/src/extensions/StdLib/Lib/test/test_sax.py b/src/core/IronPython.StdLib/Lib/test/test_sax.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_sax.py rename to src/core/IronPython.StdLib/Lib/test/test_sax.py diff --git a/src/extensions/StdLib/Lib/test/test_sched.py b/src/core/IronPython.StdLib/Lib/test/test_sched.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_sched.py rename to src/core/IronPython.StdLib/Lib/test/test_sched.py diff --git a/src/extensions/StdLib/Lib/test/test_scope.py b/src/core/IronPython.StdLib/Lib/test/test_scope.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_scope.py rename to src/core/IronPython.StdLib/Lib/test/test_scope.py diff --git a/src/extensions/StdLib/Lib/test/test_script_helper.py b/src/core/IronPython.StdLib/Lib/test/test_script_helper.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_script_helper.py rename to src/core/IronPython.StdLib/Lib/test/test_script_helper.py diff --git a/src/extensions/StdLib/Lib/test/test_select.py b/src/core/IronPython.StdLib/Lib/test/test_select.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_select.py rename to src/core/IronPython.StdLib/Lib/test/test_select.py diff --git a/src/extensions/StdLib/Lib/test/test_selectors.py b/src/core/IronPython.StdLib/Lib/test/test_selectors.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_selectors.py rename to src/core/IronPython.StdLib/Lib/test/test_selectors.py diff --git a/src/extensions/StdLib/Lib/test/test_set.py b/src/core/IronPython.StdLib/Lib/test/test_set.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_set.py rename to src/core/IronPython.StdLib/Lib/test/test_set.py diff --git a/src/extensions/StdLib/Lib/test/test_setcomps.py b/src/core/IronPython.StdLib/Lib/test/test_setcomps.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_setcomps.py rename to src/core/IronPython.StdLib/Lib/test/test_setcomps.py diff --git a/src/extensions/StdLib/Lib/test/test_shelve.py b/src/core/IronPython.StdLib/Lib/test/test_shelve.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_shelve.py rename to src/core/IronPython.StdLib/Lib/test/test_shelve.py diff --git a/src/extensions/StdLib/Lib/test/test_shlex.py b/src/core/IronPython.StdLib/Lib/test/test_shlex.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_shlex.py rename to src/core/IronPython.StdLib/Lib/test/test_shlex.py diff --git a/src/extensions/StdLib/Lib/test/test_shutil.py b/src/core/IronPython.StdLib/Lib/test/test_shutil.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_shutil.py rename to src/core/IronPython.StdLib/Lib/test/test_shutil.py diff --git a/src/extensions/StdLib/Lib/test/test_signal.py b/src/core/IronPython.StdLib/Lib/test/test_signal.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_signal.py rename to src/core/IronPython.StdLib/Lib/test/test_signal.py diff --git a/src/extensions/StdLib/Lib/test/test_site.py b/src/core/IronPython.StdLib/Lib/test/test_site.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_site.py rename to src/core/IronPython.StdLib/Lib/test/test_site.py diff --git a/src/extensions/StdLib/Lib/test/test_slice.py b/src/core/IronPython.StdLib/Lib/test/test_slice.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_slice.py rename to src/core/IronPython.StdLib/Lib/test/test_slice.py diff --git a/src/extensions/StdLib/Lib/test/test_smtpd.py b/src/core/IronPython.StdLib/Lib/test/test_smtpd.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_smtpd.py rename to src/core/IronPython.StdLib/Lib/test/test_smtpd.py diff --git a/src/extensions/StdLib/Lib/test/test_smtplib.py b/src/core/IronPython.StdLib/Lib/test/test_smtplib.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_smtplib.py rename to src/core/IronPython.StdLib/Lib/test/test_smtplib.py diff --git a/src/extensions/StdLib/Lib/test/test_smtpnet.py b/src/core/IronPython.StdLib/Lib/test/test_smtpnet.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_smtpnet.py rename to src/core/IronPython.StdLib/Lib/test/test_smtpnet.py diff --git a/src/extensions/StdLib/Lib/test/test_sndhdr.py b/src/core/IronPython.StdLib/Lib/test/test_sndhdr.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_sndhdr.py rename to src/core/IronPython.StdLib/Lib/test/test_sndhdr.py diff --git a/src/extensions/StdLib/Lib/test/test_socket.py b/src/core/IronPython.StdLib/Lib/test/test_socket.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_socket.py rename to src/core/IronPython.StdLib/Lib/test/test_socket.py diff --git a/src/extensions/StdLib/Lib/test/test_socketserver.py b/src/core/IronPython.StdLib/Lib/test/test_socketserver.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_socketserver.py rename to src/core/IronPython.StdLib/Lib/test/test_socketserver.py diff --git a/src/extensions/StdLib/Lib/test/test_sort.py b/src/core/IronPython.StdLib/Lib/test/test_sort.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_sort.py rename to src/core/IronPython.StdLib/Lib/test/test_sort.py diff --git a/src/extensions/StdLib/Lib/test/test_source_encoding.py b/src/core/IronPython.StdLib/Lib/test/test_source_encoding.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_source_encoding.py rename to src/core/IronPython.StdLib/Lib/test/test_source_encoding.py diff --git a/src/extensions/StdLib/Lib/test/test_spwd.py b/src/core/IronPython.StdLib/Lib/test/test_spwd.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_spwd.py rename to src/core/IronPython.StdLib/Lib/test/test_spwd.py diff --git a/src/extensions/StdLib/Lib/test/test_sqlite.py b/src/core/IronPython.StdLib/Lib/test/test_sqlite.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_sqlite.py rename to src/core/IronPython.StdLib/Lib/test/test_sqlite.py diff --git a/src/extensions/StdLib/Lib/test/test_ssl.py b/src/core/IronPython.StdLib/Lib/test/test_ssl.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_ssl.py rename to src/core/IronPython.StdLib/Lib/test/test_ssl.py diff --git a/src/extensions/StdLib/Lib/test/test_startfile.py b/src/core/IronPython.StdLib/Lib/test/test_startfile.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_startfile.py rename to src/core/IronPython.StdLib/Lib/test/test_startfile.py diff --git a/src/extensions/StdLib/Lib/test/test_stat.py b/src/core/IronPython.StdLib/Lib/test/test_stat.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_stat.py rename to src/core/IronPython.StdLib/Lib/test/test_stat.py diff --git a/src/extensions/StdLib/Lib/test/test_statistics.py b/src/core/IronPython.StdLib/Lib/test/test_statistics.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_statistics.py rename to src/core/IronPython.StdLib/Lib/test/test_statistics.py diff --git a/src/extensions/StdLib/Lib/test/test_strftime.py b/src/core/IronPython.StdLib/Lib/test/test_strftime.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_strftime.py rename to src/core/IronPython.StdLib/Lib/test/test_strftime.py diff --git a/src/extensions/StdLib/Lib/test/test_string.py b/src/core/IronPython.StdLib/Lib/test/test_string.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_string.py rename to src/core/IronPython.StdLib/Lib/test/test_string.py diff --git a/src/extensions/StdLib/Lib/test/test_stringprep.py b/src/core/IronPython.StdLib/Lib/test/test_stringprep.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_stringprep.py rename to src/core/IronPython.StdLib/Lib/test/test_stringprep.py diff --git a/src/extensions/StdLib/Lib/test/test_strlit.py b/src/core/IronPython.StdLib/Lib/test/test_strlit.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_strlit.py rename to src/core/IronPython.StdLib/Lib/test/test_strlit.py diff --git a/src/extensions/StdLib/Lib/test/test_strptime.py b/src/core/IronPython.StdLib/Lib/test/test_strptime.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_strptime.py rename to src/core/IronPython.StdLib/Lib/test/test_strptime.py diff --git a/src/extensions/StdLib/Lib/test/test_strtod.py b/src/core/IronPython.StdLib/Lib/test/test_strtod.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_strtod.py rename to src/core/IronPython.StdLib/Lib/test/test_strtod.py diff --git a/src/extensions/StdLib/Lib/test/test_struct.py b/src/core/IronPython.StdLib/Lib/test/test_struct.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_struct.py rename to src/core/IronPython.StdLib/Lib/test/test_struct.py diff --git a/src/extensions/StdLib/Lib/test/test_structmembers.py b/src/core/IronPython.StdLib/Lib/test/test_structmembers.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_structmembers.py rename to src/core/IronPython.StdLib/Lib/test/test_structmembers.py diff --git a/src/extensions/StdLib/Lib/test/test_structseq.py b/src/core/IronPython.StdLib/Lib/test/test_structseq.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_structseq.py rename to src/core/IronPython.StdLib/Lib/test/test_structseq.py diff --git a/src/extensions/StdLib/Lib/test/test_subprocess.py b/src/core/IronPython.StdLib/Lib/test/test_subprocess.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_subprocess.py rename to src/core/IronPython.StdLib/Lib/test/test_subprocess.py diff --git a/src/extensions/StdLib/Lib/test/test_sunau.py b/src/core/IronPython.StdLib/Lib/test/test_sunau.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_sunau.py rename to src/core/IronPython.StdLib/Lib/test/test_sunau.py diff --git a/src/extensions/StdLib/Lib/test/test_sundry.py b/src/core/IronPython.StdLib/Lib/test/test_sundry.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_sundry.py rename to src/core/IronPython.StdLib/Lib/test/test_sundry.py diff --git a/src/extensions/StdLib/Lib/test/test_super.py b/src/core/IronPython.StdLib/Lib/test/test_super.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_super.py rename to src/core/IronPython.StdLib/Lib/test/test_super.py diff --git a/src/extensions/StdLib/Lib/test/test_support.py b/src/core/IronPython.StdLib/Lib/test/test_support.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_support.py rename to src/core/IronPython.StdLib/Lib/test/test_support.py diff --git a/src/extensions/StdLib/Lib/test/test_symtable.py b/src/core/IronPython.StdLib/Lib/test/test_symtable.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_symtable.py rename to src/core/IronPython.StdLib/Lib/test/test_symtable.py diff --git a/src/extensions/StdLib/Lib/test/test_syntax.py b/src/core/IronPython.StdLib/Lib/test/test_syntax.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_syntax.py rename to src/core/IronPython.StdLib/Lib/test/test_syntax.py diff --git a/src/extensions/StdLib/Lib/test/test_sys.py b/src/core/IronPython.StdLib/Lib/test/test_sys.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_sys.py rename to src/core/IronPython.StdLib/Lib/test/test_sys.py diff --git a/src/extensions/StdLib/Lib/test/test_sys_setprofile.py b/src/core/IronPython.StdLib/Lib/test/test_sys_setprofile.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_sys_setprofile.py rename to src/core/IronPython.StdLib/Lib/test/test_sys_setprofile.py diff --git a/src/extensions/StdLib/Lib/test/test_sys_settrace.py b/src/core/IronPython.StdLib/Lib/test/test_sys_settrace.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_sys_settrace.py rename to src/core/IronPython.StdLib/Lib/test/test_sys_settrace.py diff --git a/src/extensions/StdLib/Lib/test/test_sysconfig.py b/src/core/IronPython.StdLib/Lib/test/test_sysconfig.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_sysconfig.py rename to src/core/IronPython.StdLib/Lib/test/test_sysconfig.py diff --git a/src/extensions/StdLib/Lib/test/test_syslog.py b/src/core/IronPython.StdLib/Lib/test/test_syslog.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_syslog.py rename to src/core/IronPython.StdLib/Lib/test/test_syslog.py diff --git a/src/extensions/StdLib/Lib/test/test_tarfile.py b/src/core/IronPython.StdLib/Lib/test/test_tarfile.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_tarfile.py rename to src/core/IronPython.StdLib/Lib/test/test_tarfile.py diff --git a/src/extensions/StdLib/Lib/test/test_tcl.py b/src/core/IronPython.StdLib/Lib/test/test_tcl.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_tcl.py rename to src/core/IronPython.StdLib/Lib/test/test_tcl.py diff --git a/src/extensions/StdLib/Lib/test/test_telnetlib.py b/src/core/IronPython.StdLib/Lib/test/test_telnetlib.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_telnetlib.py rename to src/core/IronPython.StdLib/Lib/test/test_telnetlib.py diff --git a/src/extensions/StdLib/Lib/test/test_tempfile.py b/src/core/IronPython.StdLib/Lib/test/test_tempfile.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_tempfile.py rename to src/core/IronPython.StdLib/Lib/test/test_tempfile.py diff --git a/src/extensions/StdLib/Lib/test/test_textwrap.py b/src/core/IronPython.StdLib/Lib/test/test_textwrap.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_textwrap.py rename to src/core/IronPython.StdLib/Lib/test/test_textwrap.py diff --git a/src/extensions/StdLib/Lib/test/test_thread.py b/src/core/IronPython.StdLib/Lib/test/test_thread.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_thread.py rename to src/core/IronPython.StdLib/Lib/test/test_thread.py diff --git a/src/extensions/StdLib/Lib/test/test_threaded_import.py b/src/core/IronPython.StdLib/Lib/test/test_threaded_import.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_threaded_import.py rename to src/core/IronPython.StdLib/Lib/test/test_threaded_import.py diff --git a/src/extensions/StdLib/Lib/test/test_threadedtempfile.py b/src/core/IronPython.StdLib/Lib/test/test_threadedtempfile.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_threadedtempfile.py rename to src/core/IronPython.StdLib/Lib/test/test_threadedtempfile.py diff --git a/src/extensions/StdLib/Lib/test/test_threading.py b/src/core/IronPython.StdLib/Lib/test/test_threading.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_threading.py rename to src/core/IronPython.StdLib/Lib/test/test_threading.py diff --git a/src/extensions/StdLib/Lib/test/test_threading_local.py b/src/core/IronPython.StdLib/Lib/test/test_threading_local.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_threading_local.py rename to src/core/IronPython.StdLib/Lib/test/test_threading_local.py diff --git a/src/extensions/StdLib/Lib/test/test_threadsignals.py b/src/core/IronPython.StdLib/Lib/test/test_threadsignals.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_threadsignals.py rename to src/core/IronPython.StdLib/Lib/test/test_threadsignals.py diff --git a/src/extensions/StdLib/Lib/test/test_time.py b/src/core/IronPython.StdLib/Lib/test/test_time.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_time.py rename to src/core/IronPython.StdLib/Lib/test/test_time.py diff --git a/src/extensions/StdLib/Lib/test/test_timeit.py b/src/core/IronPython.StdLib/Lib/test/test_timeit.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_timeit.py rename to src/core/IronPython.StdLib/Lib/test/test_timeit.py diff --git a/src/extensions/StdLib/Lib/test/test_timeout.py b/src/core/IronPython.StdLib/Lib/test/test_timeout.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_timeout.py rename to src/core/IronPython.StdLib/Lib/test/test_timeout.py diff --git a/src/extensions/StdLib/Lib/test/test_tk.py b/src/core/IronPython.StdLib/Lib/test/test_tk.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_tk.py rename to src/core/IronPython.StdLib/Lib/test/test_tk.py diff --git a/src/extensions/StdLib/Lib/test/test_tokenize.py b/src/core/IronPython.StdLib/Lib/test/test_tokenize.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_tokenize.py rename to src/core/IronPython.StdLib/Lib/test/test_tokenize.py diff --git a/src/extensions/StdLib/Lib/test/test_tools/__init__.py b/src/core/IronPython.StdLib/Lib/test/test_tools/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_tools/__init__.py rename to src/core/IronPython.StdLib/Lib/test/test_tools/__init__.py diff --git a/src/extensions/StdLib/Lib/test/test_tools/__main__.py b/src/core/IronPython.StdLib/Lib/test/test_tools/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_tools/__main__.py rename to src/core/IronPython.StdLib/Lib/test/test_tools/__main__.py diff --git a/src/extensions/StdLib/Lib/test/test_tools/test_gprof2html.py b/src/core/IronPython.StdLib/Lib/test/test_tools/test_gprof2html.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_tools/test_gprof2html.py rename to src/core/IronPython.StdLib/Lib/test/test_tools/test_gprof2html.py diff --git a/src/extensions/StdLib/Lib/test/test_tools/test_md5sum.py b/src/core/IronPython.StdLib/Lib/test/test_tools/test_md5sum.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_tools/test_md5sum.py rename to src/core/IronPython.StdLib/Lib/test/test_tools/test_md5sum.py diff --git a/src/extensions/StdLib/Lib/test/test_tools/test_pdeps.py b/src/core/IronPython.StdLib/Lib/test/test_tools/test_pdeps.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_tools/test_pdeps.py rename to src/core/IronPython.StdLib/Lib/test/test_tools/test_pdeps.py diff --git a/src/extensions/StdLib/Lib/test/test_tools/test_pindent.py b/src/core/IronPython.StdLib/Lib/test/test_tools/test_pindent.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_tools/test_pindent.py rename to src/core/IronPython.StdLib/Lib/test/test_tools/test_pindent.py diff --git a/src/extensions/StdLib/Lib/test/test_tools/test_reindent.py b/src/core/IronPython.StdLib/Lib/test/test_tools/test_reindent.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_tools/test_reindent.py rename to src/core/IronPython.StdLib/Lib/test/test_tools/test_reindent.py diff --git a/src/extensions/StdLib/Lib/test/test_tools/test_sundry.py b/src/core/IronPython.StdLib/Lib/test/test_tools/test_sundry.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_tools/test_sundry.py rename to src/core/IronPython.StdLib/Lib/test/test_tools/test_sundry.py diff --git a/src/extensions/StdLib/Lib/test/test_tools/test_unparse.py b/src/core/IronPython.StdLib/Lib/test/test_tools/test_unparse.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_tools/test_unparse.py rename to src/core/IronPython.StdLib/Lib/test/test_tools/test_unparse.py diff --git a/src/extensions/StdLib/Lib/test/test_trace.py b/src/core/IronPython.StdLib/Lib/test/test_trace.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_trace.py rename to src/core/IronPython.StdLib/Lib/test/test_trace.py diff --git a/src/extensions/StdLib/Lib/test/test_traceback.py b/src/core/IronPython.StdLib/Lib/test/test_traceback.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_traceback.py rename to src/core/IronPython.StdLib/Lib/test/test_traceback.py diff --git a/src/extensions/StdLib/Lib/test/test_tracemalloc.py b/src/core/IronPython.StdLib/Lib/test/test_tracemalloc.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_tracemalloc.py rename to src/core/IronPython.StdLib/Lib/test/test_tracemalloc.py diff --git a/src/extensions/StdLib/Lib/test/test_ttk_guionly.py b/src/core/IronPython.StdLib/Lib/test/test_ttk_guionly.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_ttk_guionly.py rename to src/core/IronPython.StdLib/Lib/test/test_ttk_guionly.py diff --git a/src/extensions/StdLib/Lib/test/test_ttk_textonly.py b/src/core/IronPython.StdLib/Lib/test/test_ttk_textonly.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_ttk_textonly.py rename to src/core/IronPython.StdLib/Lib/test/test_ttk_textonly.py diff --git a/src/extensions/StdLib/Lib/test/test_tuple.py b/src/core/IronPython.StdLib/Lib/test/test_tuple.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_tuple.py rename to src/core/IronPython.StdLib/Lib/test/test_tuple.py diff --git a/src/extensions/StdLib/Lib/test/test_typechecks.py b/src/core/IronPython.StdLib/Lib/test/test_typechecks.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_typechecks.py rename to src/core/IronPython.StdLib/Lib/test/test_typechecks.py diff --git a/src/extensions/StdLib/Lib/test/test_types.py b/src/core/IronPython.StdLib/Lib/test/test_types.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_types.py rename to src/core/IronPython.StdLib/Lib/test/test_types.py diff --git a/src/extensions/StdLib/Lib/test/test_typing.py b/src/core/IronPython.StdLib/Lib/test/test_typing.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_typing.py rename to src/core/IronPython.StdLib/Lib/test/test_typing.py diff --git a/src/extensions/StdLib/Lib/test/test_ucn.py b/src/core/IronPython.StdLib/Lib/test/test_ucn.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_ucn.py rename to src/core/IronPython.StdLib/Lib/test/test_ucn.py diff --git a/src/extensions/StdLib/Lib/test/test_unary.py b/src/core/IronPython.StdLib/Lib/test/test_unary.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_unary.py rename to src/core/IronPython.StdLib/Lib/test/test_unary.py diff --git a/src/extensions/StdLib/Lib/test/test_unicode.py b/src/core/IronPython.StdLib/Lib/test/test_unicode.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_unicode.py rename to src/core/IronPython.StdLib/Lib/test/test_unicode.py diff --git a/src/extensions/StdLib/Lib/test/test_unicode_file.py b/src/core/IronPython.StdLib/Lib/test/test_unicode_file.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_unicode_file.py rename to src/core/IronPython.StdLib/Lib/test/test_unicode_file.py diff --git a/src/extensions/StdLib/Lib/test/test_unicodedata.py b/src/core/IronPython.StdLib/Lib/test/test_unicodedata.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_unicodedata.py rename to src/core/IronPython.StdLib/Lib/test/test_unicodedata.py diff --git a/src/extensions/StdLib/Lib/test/test_unittest.py b/src/core/IronPython.StdLib/Lib/test/test_unittest.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_unittest.py rename to src/core/IronPython.StdLib/Lib/test/test_unittest.py diff --git a/src/extensions/StdLib/Lib/test/test_univnewlines.py b/src/core/IronPython.StdLib/Lib/test/test_univnewlines.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_univnewlines.py rename to src/core/IronPython.StdLib/Lib/test/test_univnewlines.py diff --git a/src/extensions/StdLib/Lib/test/test_unpack.py b/src/core/IronPython.StdLib/Lib/test/test_unpack.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_unpack.py rename to src/core/IronPython.StdLib/Lib/test/test_unpack.py diff --git a/src/extensions/StdLib/Lib/test/test_unpack_ex.py b/src/core/IronPython.StdLib/Lib/test/test_unpack_ex.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_unpack_ex.py rename to src/core/IronPython.StdLib/Lib/test/test_unpack_ex.py diff --git a/src/extensions/StdLib/Lib/test/test_urllib.py b/src/core/IronPython.StdLib/Lib/test/test_urllib.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_urllib.py rename to src/core/IronPython.StdLib/Lib/test/test_urllib.py diff --git a/src/extensions/StdLib/Lib/test/test_urllib2.py b/src/core/IronPython.StdLib/Lib/test/test_urllib2.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_urllib2.py rename to src/core/IronPython.StdLib/Lib/test/test_urllib2.py diff --git a/src/extensions/StdLib/Lib/test/test_urllib2_localnet.py b/src/core/IronPython.StdLib/Lib/test/test_urllib2_localnet.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_urllib2_localnet.py rename to src/core/IronPython.StdLib/Lib/test/test_urllib2_localnet.py diff --git a/src/extensions/StdLib/Lib/test/test_urllib2net.py b/src/core/IronPython.StdLib/Lib/test/test_urllib2net.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_urllib2net.py rename to src/core/IronPython.StdLib/Lib/test/test_urllib2net.py diff --git a/src/extensions/StdLib/Lib/test/test_urllib_response.py b/src/core/IronPython.StdLib/Lib/test/test_urllib_response.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_urllib_response.py rename to src/core/IronPython.StdLib/Lib/test/test_urllib_response.py diff --git a/src/extensions/StdLib/Lib/test/test_urllibnet.py b/src/core/IronPython.StdLib/Lib/test/test_urllibnet.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_urllibnet.py rename to src/core/IronPython.StdLib/Lib/test/test_urllibnet.py diff --git a/src/extensions/StdLib/Lib/test/test_urlparse.py b/src/core/IronPython.StdLib/Lib/test/test_urlparse.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_urlparse.py rename to src/core/IronPython.StdLib/Lib/test/test_urlparse.py diff --git a/src/extensions/StdLib/Lib/test/test_userdict.py b/src/core/IronPython.StdLib/Lib/test/test_userdict.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_userdict.py rename to src/core/IronPython.StdLib/Lib/test/test_userdict.py diff --git a/src/extensions/StdLib/Lib/test/test_userlist.py b/src/core/IronPython.StdLib/Lib/test/test_userlist.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_userlist.py rename to src/core/IronPython.StdLib/Lib/test/test_userlist.py diff --git a/src/extensions/StdLib/Lib/test/test_userstring.py b/src/core/IronPython.StdLib/Lib/test/test_userstring.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_userstring.py rename to src/core/IronPython.StdLib/Lib/test/test_userstring.py diff --git a/src/extensions/StdLib/Lib/test/test_utf8_mode.py b/src/core/IronPython.StdLib/Lib/test/test_utf8_mode.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_utf8_mode.py rename to src/core/IronPython.StdLib/Lib/test/test_utf8_mode.py diff --git a/src/extensions/StdLib/Lib/test/test_uu.py b/src/core/IronPython.StdLib/Lib/test/test_uu.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_uu.py rename to src/core/IronPython.StdLib/Lib/test/test_uu.py diff --git a/src/extensions/StdLib/Lib/test/test_uuid.py b/src/core/IronPython.StdLib/Lib/test/test_uuid.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_uuid.py rename to src/core/IronPython.StdLib/Lib/test/test_uuid.py diff --git a/src/extensions/StdLib/Lib/test/test_venv.py b/src/core/IronPython.StdLib/Lib/test/test_venv.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_venv.py rename to src/core/IronPython.StdLib/Lib/test/test_venv.py diff --git a/src/extensions/StdLib/Lib/test/test_wait3.py b/src/core/IronPython.StdLib/Lib/test/test_wait3.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_wait3.py rename to src/core/IronPython.StdLib/Lib/test/test_wait3.py diff --git a/src/extensions/StdLib/Lib/test/test_wait4.py b/src/core/IronPython.StdLib/Lib/test/test_wait4.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_wait4.py rename to src/core/IronPython.StdLib/Lib/test/test_wait4.py diff --git a/src/extensions/StdLib/Lib/test/test_warnings.py b/src/core/IronPython.StdLib/Lib/test/test_warnings.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_warnings.py rename to src/core/IronPython.StdLib/Lib/test/test_warnings.py diff --git a/src/extensions/StdLib/Lib/test/test_wave.py b/src/core/IronPython.StdLib/Lib/test/test_wave.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_wave.py rename to src/core/IronPython.StdLib/Lib/test/test_wave.py diff --git a/src/extensions/StdLib/Lib/test/test_weakref.py b/src/core/IronPython.StdLib/Lib/test/test_weakref.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_weakref.py rename to src/core/IronPython.StdLib/Lib/test/test_weakref.py diff --git a/src/extensions/StdLib/Lib/test/test_weakset.py b/src/core/IronPython.StdLib/Lib/test/test_weakset.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_weakset.py rename to src/core/IronPython.StdLib/Lib/test/test_weakset.py diff --git a/src/extensions/StdLib/Lib/test/test_webbrowser.py b/src/core/IronPython.StdLib/Lib/test/test_webbrowser.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_webbrowser.py rename to src/core/IronPython.StdLib/Lib/test/test_webbrowser.py diff --git a/src/extensions/StdLib/Lib/test/test_winreg.py b/src/core/IronPython.StdLib/Lib/test/test_winreg.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_winreg.py rename to src/core/IronPython.StdLib/Lib/test/test_winreg.py diff --git a/src/extensions/StdLib/Lib/test/test_winsound.py b/src/core/IronPython.StdLib/Lib/test/test_winsound.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_winsound.py rename to src/core/IronPython.StdLib/Lib/test/test_winsound.py diff --git a/src/extensions/StdLib/Lib/test/test_with.py b/src/core/IronPython.StdLib/Lib/test/test_with.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_with.py rename to src/core/IronPython.StdLib/Lib/test/test_with.py diff --git a/src/extensions/StdLib/Lib/test/test_wsgiref.py b/src/core/IronPython.StdLib/Lib/test/test_wsgiref.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_wsgiref.py rename to src/core/IronPython.StdLib/Lib/test/test_wsgiref.py diff --git a/src/extensions/StdLib/Lib/test/test_xdrlib.py b/src/core/IronPython.StdLib/Lib/test/test_xdrlib.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_xdrlib.py rename to src/core/IronPython.StdLib/Lib/test/test_xdrlib.py diff --git a/src/extensions/StdLib/Lib/test/test_xml_dom_minicompat.py b/src/core/IronPython.StdLib/Lib/test/test_xml_dom_minicompat.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_xml_dom_minicompat.py rename to src/core/IronPython.StdLib/Lib/test/test_xml_dom_minicompat.py diff --git a/src/extensions/StdLib/Lib/test/test_xml_etree.py b/src/core/IronPython.StdLib/Lib/test/test_xml_etree.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_xml_etree.py rename to src/core/IronPython.StdLib/Lib/test/test_xml_etree.py diff --git a/src/extensions/StdLib/Lib/test/test_xml_etree_c.py b/src/core/IronPython.StdLib/Lib/test/test_xml_etree_c.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_xml_etree_c.py rename to src/core/IronPython.StdLib/Lib/test/test_xml_etree_c.py diff --git a/src/extensions/StdLib/Lib/test/test_xmlrpc.py b/src/core/IronPython.StdLib/Lib/test/test_xmlrpc.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_xmlrpc.py rename to src/core/IronPython.StdLib/Lib/test/test_xmlrpc.py diff --git a/src/extensions/StdLib/Lib/test/test_xmlrpc_net.py b/src/core/IronPython.StdLib/Lib/test/test_xmlrpc_net.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_xmlrpc_net.py rename to src/core/IronPython.StdLib/Lib/test/test_xmlrpc_net.py diff --git a/src/extensions/StdLib/Lib/test/test_zipfile.py b/src/core/IronPython.StdLib/Lib/test/test_zipfile.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_zipfile.py rename to src/core/IronPython.StdLib/Lib/test/test_zipfile.py diff --git a/src/extensions/StdLib/Lib/test/test_zipfile64.py b/src/core/IronPython.StdLib/Lib/test/test_zipfile64.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_zipfile64.py rename to src/core/IronPython.StdLib/Lib/test/test_zipfile64.py diff --git a/src/extensions/StdLib/Lib/test/test_zipimport.py b/src/core/IronPython.StdLib/Lib/test/test_zipimport.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_zipimport.py rename to src/core/IronPython.StdLib/Lib/test/test_zipimport.py diff --git a/src/extensions/StdLib/Lib/test/test_zipimport_support.py b/src/core/IronPython.StdLib/Lib/test/test_zipimport_support.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_zipimport_support.py rename to src/core/IronPython.StdLib/Lib/test/test_zipimport_support.py diff --git a/src/extensions/StdLib/Lib/test/test_zlib.py b/src/core/IronPython.StdLib/Lib/test/test_zlib.py similarity index 100% rename from src/extensions/StdLib/Lib/test/test_zlib.py rename to src/core/IronPython.StdLib/Lib/test/test_zlib.py diff --git a/src/extensions/StdLib/Lib/test/testcodec.py b/src/core/IronPython.StdLib/Lib/test/testcodec.py similarity index 100% rename from src/extensions/StdLib/Lib/test/testcodec.py rename to src/core/IronPython.StdLib/Lib/test/testcodec.py diff --git a/src/extensions/StdLib/Lib/test/testtar.tar b/src/core/IronPython.StdLib/Lib/test/testtar.tar similarity index 100% rename from src/extensions/StdLib/Lib/test/testtar.tar rename to src/core/IronPython.StdLib/Lib/test/testtar.tar diff --git a/src/extensions/StdLib/Lib/test/tf_inherit_check.py b/src/core/IronPython.StdLib/Lib/test/tf_inherit_check.py similarity index 100% rename from src/extensions/StdLib/Lib/test/tf_inherit_check.py rename to src/core/IronPython.StdLib/Lib/test/tf_inherit_check.py diff --git a/src/extensions/StdLib/Lib/test/threaded_import_hangers.py b/src/core/IronPython.StdLib/Lib/test/threaded_import_hangers.py similarity index 100% rename from src/extensions/StdLib/Lib/test/threaded_import_hangers.py rename to src/core/IronPython.StdLib/Lib/test/threaded_import_hangers.py diff --git a/src/extensions/StdLib/Lib/test/time_hashlib.py b/src/core/IronPython.StdLib/Lib/test/time_hashlib.py similarity index 100% rename from src/extensions/StdLib/Lib/test/time_hashlib.py rename to src/core/IronPython.StdLib/Lib/test/time_hashlib.py diff --git a/src/extensions/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt b/src/core/IronPython.StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt rename to src/core/IronPython.StdLib/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt diff --git a/src/extensions/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt b/src/core/IronPython.StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt rename to src/core/IronPython.StdLib/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt diff --git a/src/extensions/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt b/src/core/IronPython.StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt rename to src/core/IronPython.StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt diff --git a/src/extensions/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt b/src/core/IronPython.StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt rename to src/core/IronPython.StdLib/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt diff --git a/src/extensions/StdLib/Lib/test/tokenize_tests.txt b/src/core/IronPython.StdLib/Lib/test/tokenize_tests.txt similarity index 100% rename from src/extensions/StdLib/Lib/test/tokenize_tests.txt rename to src/core/IronPython.StdLib/Lib/test/tokenize_tests.txt diff --git a/src/extensions/StdLib/Lib/test/tracedmodules/__init__.py b/src/core/IronPython.StdLib/Lib/test/tracedmodules/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/test/tracedmodules/__init__.py rename to src/core/IronPython.StdLib/Lib/test/tracedmodules/__init__.py diff --git a/src/extensions/StdLib/Lib/test/tracedmodules/testmod.py b/src/core/IronPython.StdLib/Lib/test/tracedmodules/testmod.py similarity index 100% rename from src/extensions/StdLib/Lib/test/tracedmodules/testmod.py rename to src/core/IronPython.StdLib/Lib/test/tracedmodules/testmod.py diff --git a/src/extensions/StdLib/Lib/test/warning_tests.py b/src/core/IronPython.StdLib/Lib/test/warning_tests.py similarity index 100% rename from src/extensions/StdLib/Lib/test/warning_tests.py rename to src/core/IronPython.StdLib/Lib/test/warning_tests.py diff --git a/src/extensions/StdLib/Lib/test/win_console_handler.py b/src/core/IronPython.StdLib/Lib/test/win_console_handler.py similarity index 100% rename from src/extensions/StdLib/Lib/test/win_console_handler.py rename to src/core/IronPython.StdLib/Lib/test/win_console_handler.py diff --git a/src/extensions/StdLib/Lib/test/xmltestdata/simple-ns.xml b/src/core/IronPython.StdLib/Lib/test/xmltestdata/simple-ns.xml similarity index 100% rename from src/extensions/StdLib/Lib/test/xmltestdata/simple-ns.xml rename to src/core/IronPython.StdLib/Lib/test/xmltestdata/simple-ns.xml diff --git a/src/extensions/StdLib/Lib/test/xmltestdata/simple.xml b/src/core/IronPython.StdLib/Lib/test/xmltestdata/simple.xml similarity index 100% rename from src/extensions/StdLib/Lib/test/xmltestdata/simple.xml rename to src/core/IronPython.StdLib/Lib/test/xmltestdata/simple.xml diff --git a/src/extensions/StdLib/Lib/test/xmltestdata/test.xml b/src/core/IronPython.StdLib/Lib/test/xmltestdata/test.xml similarity index 100% rename from src/extensions/StdLib/Lib/test/xmltestdata/test.xml rename to src/core/IronPython.StdLib/Lib/test/xmltestdata/test.xml diff --git a/src/extensions/StdLib/Lib/test/xmltestdata/test.xml.out b/src/core/IronPython.StdLib/Lib/test/xmltestdata/test.xml.out similarity index 100% rename from src/extensions/StdLib/Lib/test/xmltestdata/test.xml.out rename to src/core/IronPython.StdLib/Lib/test/xmltestdata/test.xml.out diff --git a/src/extensions/StdLib/Lib/test/xmltests.py b/src/core/IronPython.StdLib/Lib/test/xmltests.py similarity index 100% rename from src/extensions/StdLib/Lib/test/xmltests.py rename to src/core/IronPython.StdLib/Lib/test/xmltests.py diff --git a/src/extensions/StdLib/Lib/test/zip_cp437_header.zip b/src/core/IronPython.StdLib/Lib/test/zip_cp437_header.zip similarity index 100% rename from src/extensions/StdLib/Lib/test/zip_cp437_header.zip rename to src/core/IronPython.StdLib/Lib/test/zip_cp437_header.zip diff --git a/src/extensions/StdLib/Lib/test/zipdir.zip b/src/core/IronPython.StdLib/Lib/test/zipdir.zip similarity index 100% rename from src/extensions/StdLib/Lib/test/zipdir.zip rename to src/core/IronPython.StdLib/Lib/test/zipdir.zip diff --git a/src/extensions/StdLib/Lib/textwrap.py b/src/core/IronPython.StdLib/Lib/textwrap.py similarity index 100% rename from src/extensions/StdLib/Lib/textwrap.py rename to src/core/IronPython.StdLib/Lib/textwrap.py diff --git a/src/extensions/StdLib/Lib/this.py b/src/core/IronPython.StdLib/Lib/this.py similarity index 100% rename from src/extensions/StdLib/Lib/this.py rename to src/core/IronPython.StdLib/Lib/this.py diff --git a/src/extensions/StdLib/Lib/threading.py b/src/core/IronPython.StdLib/Lib/threading.py similarity index 100% rename from src/extensions/StdLib/Lib/threading.py rename to src/core/IronPython.StdLib/Lib/threading.py diff --git a/src/extensions/StdLib/Lib/timeit.py b/src/core/IronPython.StdLib/Lib/timeit.py similarity index 100% rename from src/extensions/StdLib/Lib/timeit.py rename to src/core/IronPython.StdLib/Lib/timeit.py diff --git a/src/extensions/StdLib/Lib/tkinter/__init__.py b/src/core/IronPython.StdLib/Lib/tkinter/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/__init__.py rename to src/core/IronPython.StdLib/Lib/tkinter/__init__.py diff --git a/src/extensions/StdLib/Lib/tkinter/__main__.py b/src/core/IronPython.StdLib/Lib/tkinter/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/__main__.py rename to src/core/IronPython.StdLib/Lib/tkinter/__main__.py diff --git a/src/extensions/StdLib/Lib/tkinter/_fix.py b/src/core/IronPython.StdLib/Lib/tkinter/_fix.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/_fix.py rename to src/core/IronPython.StdLib/Lib/tkinter/_fix.py diff --git a/src/extensions/StdLib/Lib/tkinter/colorchooser.py b/src/core/IronPython.StdLib/Lib/tkinter/colorchooser.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/colorchooser.py rename to src/core/IronPython.StdLib/Lib/tkinter/colorchooser.py diff --git a/src/extensions/StdLib/Lib/tkinter/commondialog.py b/src/core/IronPython.StdLib/Lib/tkinter/commondialog.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/commondialog.py rename to src/core/IronPython.StdLib/Lib/tkinter/commondialog.py diff --git a/src/extensions/StdLib/Lib/tkinter/constants.py b/src/core/IronPython.StdLib/Lib/tkinter/constants.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/constants.py rename to src/core/IronPython.StdLib/Lib/tkinter/constants.py diff --git a/src/extensions/StdLib/Lib/tkinter/dialog.py b/src/core/IronPython.StdLib/Lib/tkinter/dialog.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/dialog.py rename to src/core/IronPython.StdLib/Lib/tkinter/dialog.py diff --git a/src/extensions/StdLib/Lib/tkinter/dnd.py b/src/core/IronPython.StdLib/Lib/tkinter/dnd.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/dnd.py rename to src/core/IronPython.StdLib/Lib/tkinter/dnd.py diff --git a/src/extensions/StdLib/Lib/tkinter/filedialog.py b/src/core/IronPython.StdLib/Lib/tkinter/filedialog.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/filedialog.py rename to src/core/IronPython.StdLib/Lib/tkinter/filedialog.py diff --git a/src/extensions/StdLib/Lib/tkinter/font.py b/src/core/IronPython.StdLib/Lib/tkinter/font.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/font.py rename to src/core/IronPython.StdLib/Lib/tkinter/font.py diff --git a/src/extensions/StdLib/Lib/tkinter/messagebox.py b/src/core/IronPython.StdLib/Lib/tkinter/messagebox.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/messagebox.py rename to src/core/IronPython.StdLib/Lib/tkinter/messagebox.py diff --git a/src/extensions/StdLib/Lib/tkinter/scrolledtext.py b/src/core/IronPython.StdLib/Lib/tkinter/scrolledtext.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/scrolledtext.py rename to src/core/IronPython.StdLib/Lib/tkinter/scrolledtext.py diff --git a/src/extensions/StdLib/Lib/tkinter/simpledialog.py b/src/core/IronPython.StdLib/Lib/tkinter/simpledialog.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/simpledialog.py rename to src/core/IronPython.StdLib/Lib/tkinter/simpledialog.py diff --git a/src/extensions/StdLib/Lib/tkinter/test/README b/src/core/IronPython.StdLib/Lib/tkinter/test/README similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/test/README rename to src/core/IronPython.StdLib/Lib/tkinter/test/README diff --git a/src/extensions/StdLib/Lib/tkinter/test/__init__.py b/src/core/IronPython.StdLib/Lib/tkinter/test/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/test/__init__.py rename to src/core/IronPython.StdLib/Lib/tkinter/test/__init__.py diff --git a/src/extensions/StdLib/Lib/tkinter/test/runtktests.py b/src/core/IronPython.StdLib/Lib/tkinter/test/runtktests.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/test/runtktests.py rename to src/core/IronPython.StdLib/Lib/tkinter/test/runtktests.py diff --git a/src/extensions/StdLib/Lib/tkinter/test/support.py b/src/core/IronPython.StdLib/Lib/tkinter/test/support.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/test/support.py rename to src/core/IronPython.StdLib/Lib/tkinter/test/support.py diff --git a/src/extensions/StdLib/Lib/tkinter/test/test_tkinter/__init__.py b/src/core/IronPython.StdLib/Lib/tkinter/test/test_tkinter/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/test/test_tkinter/__init__.py rename to src/core/IronPython.StdLib/Lib/tkinter/test/test_tkinter/__init__.py diff --git a/src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_font.py b/src/core/IronPython.StdLib/Lib/tkinter/test/test_tkinter/test_font.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_font.py rename to src/core/IronPython.StdLib/Lib/tkinter/test/test_tkinter/test_font.py diff --git a/src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py b/src/core/IronPython.StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py rename to src/core/IronPython.StdLib/Lib/tkinter/test/test_tkinter/test_geometry_managers.py diff --git a/src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_images.py b/src/core/IronPython.StdLib/Lib/tkinter/test/test_tkinter/test_images.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_images.py rename to src/core/IronPython.StdLib/Lib/tkinter/test/test_tkinter/test_images.py diff --git a/src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py b/src/core/IronPython.StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py rename to src/core/IronPython.StdLib/Lib/tkinter/test/test_tkinter/test_loadtk.py diff --git a/src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py b/src/core/IronPython.StdLib/Lib/tkinter/test/test_tkinter/test_misc.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_misc.py rename to src/core/IronPython.StdLib/Lib/tkinter/test/test_tkinter/test_misc.py diff --git a/src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_text.py b/src/core/IronPython.StdLib/Lib/tkinter/test/test_tkinter/test_text.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_text.py rename to src/core/IronPython.StdLib/Lib/tkinter/test/test_tkinter/test_text.py diff --git a/src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py b/src/core/IronPython.StdLib/Lib/tkinter/test/test_tkinter/test_variables.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_variables.py rename to src/core/IronPython.StdLib/Lib/tkinter/test/test_tkinter/test_variables.py diff --git a/src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py b/src/core/IronPython.StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py rename to src/core/IronPython.StdLib/Lib/tkinter/test/test_tkinter/test_widgets.py diff --git a/src/extensions/StdLib/Lib/tkinter/test/test_ttk/__init__.py b/src/core/IronPython.StdLib/Lib/tkinter/test/test_ttk/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/test/test_ttk/__init__.py rename to src/core/IronPython.StdLib/Lib/tkinter/test/test_ttk/__init__.py diff --git a/src/extensions/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py b/src/core/IronPython.StdLib/Lib/tkinter/test/test_ttk/test_extensions.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/test/test_ttk/test_extensions.py rename to src/core/IronPython.StdLib/Lib/tkinter/test/test_ttk/test_extensions.py diff --git a/src/extensions/StdLib/Lib/tkinter/test/test_ttk/test_functions.py b/src/core/IronPython.StdLib/Lib/tkinter/test/test_ttk/test_functions.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/test/test_ttk/test_functions.py rename to src/core/IronPython.StdLib/Lib/tkinter/test/test_ttk/test_functions.py diff --git a/src/extensions/StdLib/Lib/tkinter/test/test_ttk/test_style.py b/src/core/IronPython.StdLib/Lib/tkinter/test/test_ttk/test_style.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/test/test_ttk/test_style.py rename to src/core/IronPython.StdLib/Lib/tkinter/test/test_ttk/test_style.py diff --git a/src/extensions/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py b/src/core/IronPython.StdLib/Lib/tkinter/test/test_ttk/test_widgets.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/test/test_ttk/test_widgets.py rename to src/core/IronPython.StdLib/Lib/tkinter/test/test_ttk/test_widgets.py diff --git a/src/extensions/StdLib/Lib/tkinter/test/widget_tests.py b/src/core/IronPython.StdLib/Lib/tkinter/test/widget_tests.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/test/widget_tests.py rename to src/core/IronPython.StdLib/Lib/tkinter/test/widget_tests.py diff --git a/src/extensions/StdLib/Lib/tkinter/tix.py b/src/core/IronPython.StdLib/Lib/tkinter/tix.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/tix.py rename to src/core/IronPython.StdLib/Lib/tkinter/tix.py diff --git a/src/extensions/StdLib/Lib/tkinter/ttk.py b/src/core/IronPython.StdLib/Lib/tkinter/ttk.py similarity index 100% rename from src/extensions/StdLib/Lib/tkinter/ttk.py rename to src/core/IronPython.StdLib/Lib/tkinter/ttk.py diff --git a/src/extensions/StdLib/Lib/token.py b/src/core/IronPython.StdLib/Lib/token.py similarity index 100% rename from src/extensions/StdLib/Lib/token.py rename to src/core/IronPython.StdLib/Lib/token.py diff --git a/src/extensions/StdLib/Lib/tokenize.py b/src/core/IronPython.StdLib/Lib/tokenize.py similarity index 100% rename from src/extensions/StdLib/Lib/tokenize.py rename to src/core/IronPython.StdLib/Lib/tokenize.py diff --git a/src/extensions/StdLib/Lib/trace.py b/src/core/IronPython.StdLib/Lib/trace.py similarity index 100% rename from src/extensions/StdLib/Lib/trace.py rename to src/core/IronPython.StdLib/Lib/trace.py diff --git a/src/extensions/StdLib/Lib/traceback.py b/src/core/IronPython.StdLib/Lib/traceback.py similarity index 100% rename from src/extensions/StdLib/Lib/traceback.py rename to src/core/IronPython.StdLib/Lib/traceback.py diff --git a/src/extensions/StdLib/Lib/tracemalloc.py b/src/core/IronPython.StdLib/Lib/tracemalloc.py similarity index 100% rename from src/extensions/StdLib/Lib/tracemalloc.py rename to src/core/IronPython.StdLib/Lib/tracemalloc.py diff --git a/src/extensions/StdLib/Lib/tty.py b/src/core/IronPython.StdLib/Lib/tty.py similarity index 100% rename from src/extensions/StdLib/Lib/tty.py rename to src/core/IronPython.StdLib/Lib/tty.py diff --git a/src/extensions/StdLib/Lib/turtle.py b/src/core/IronPython.StdLib/Lib/turtle.py similarity index 100% rename from src/extensions/StdLib/Lib/turtle.py rename to src/core/IronPython.StdLib/Lib/turtle.py diff --git a/src/extensions/StdLib/Lib/turtledemo/__init__.py b/src/core/IronPython.StdLib/Lib/turtledemo/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/turtledemo/__init__.py rename to src/core/IronPython.StdLib/Lib/turtledemo/__init__.py diff --git a/src/extensions/StdLib/Lib/turtledemo/__main__.py b/src/core/IronPython.StdLib/Lib/turtledemo/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/turtledemo/__main__.py rename to src/core/IronPython.StdLib/Lib/turtledemo/__main__.py diff --git a/src/extensions/StdLib/Lib/turtledemo/bytedesign.py b/src/core/IronPython.StdLib/Lib/turtledemo/bytedesign.py similarity index 100% rename from src/extensions/StdLib/Lib/turtledemo/bytedesign.py rename to src/core/IronPython.StdLib/Lib/turtledemo/bytedesign.py diff --git a/src/extensions/StdLib/Lib/turtledemo/chaos.py b/src/core/IronPython.StdLib/Lib/turtledemo/chaos.py similarity index 100% rename from src/extensions/StdLib/Lib/turtledemo/chaos.py rename to src/core/IronPython.StdLib/Lib/turtledemo/chaos.py diff --git a/src/extensions/StdLib/Lib/turtledemo/clock.py b/src/core/IronPython.StdLib/Lib/turtledemo/clock.py similarity index 100% rename from src/extensions/StdLib/Lib/turtledemo/clock.py rename to src/core/IronPython.StdLib/Lib/turtledemo/clock.py diff --git a/src/extensions/StdLib/Lib/turtledemo/colormixer.py b/src/core/IronPython.StdLib/Lib/turtledemo/colormixer.py similarity index 100% rename from src/extensions/StdLib/Lib/turtledemo/colormixer.py rename to src/core/IronPython.StdLib/Lib/turtledemo/colormixer.py diff --git a/src/extensions/StdLib/Lib/turtledemo/forest.py b/src/core/IronPython.StdLib/Lib/turtledemo/forest.py similarity index 100% rename from src/extensions/StdLib/Lib/turtledemo/forest.py rename to src/core/IronPython.StdLib/Lib/turtledemo/forest.py diff --git a/src/extensions/StdLib/Lib/turtledemo/fractalcurves.py b/src/core/IronPython.StdLib/Lib/turtledemo/fractalcurves.py similarity index 100% rename from src/extensions/StdLib/Lib/turtledemo/fractalcurves.py rename to src/core/IronPython.StdLib/Lib/turtledemo/fractalcurves.py diff --git a/src/extensions/StdLib/Lib/turtledemo/lindenmayer.py b/src/core/IronPython.StdLib/Lib/turtledemo/lindenmayer.py similarity index 100% rename from src/extensions/StdLib/Lib/turtledemo/lindenmayer.py rename to src/core/IronPython.StdLib/Lib/turtledemo/lindenmayer.py diff --git a/src/extensions/StdLib/Lib/turtledemo/minimal_hanoi.py b/src/core/IronPython.StdLib/Lib/turtledemo/minimal_hanoi.py similarity index 100% rename from src/extensions/StdLib/Lib/turtledemo/minimal_hanoi.py rename to src/core/IronPython.StdLib/Lib/turtledemo/minimal_hanoi.py diff --git a/src/extensions/StdLib/Lib/turtledemo/nim.py b/src/core/IronPython.StdLib/Lib/turtledemo/nim.py similarity index 100% rename from src/extensions/StdLib/Lib/turtledemo/nim.py rename to src/core/IronPython.StdLib/Lib/turtledemo/nim.py diff --git a/src/extensions/StdLib/Lib/turtledemo/paint.py b/src/core/IronPython.StdLib/Lib/turtledemo/paint.py similarity index 100% rename from src/extensions/StdLib/Lib/turtledemo/paint.py rename to src/core/IronPython.StdLib/Lib/turtledemo/paint.py diff --git a/src/extensions/StdLib/Lib/turtledemo/peace.py b/src/core/IronPython.StdLib/Lib/turtledemo/peace.py similarity index 100% rename from src/extensions/StdLib/Lib/turtledemo/peace.py rename to src/core/IronPython.StdLib/Lib/turtledemo/peace.py diff --git a/src/extensions/StdLib/Lib/turtledemo/penrose.py b/src/core/IronPython.StdLib/Lib/turtledemo/penrose.py similarity index 100% rename from src/extensions/StdLib/Lib/turtledemo/penrose.py rename to src/core/IronPython.StdLib/Lib/turtledemo/penrose.py diff --git a/src/extensions/StdLib/Lib/turtledemo/planet_and_moon.py b/src/core/IronPython.StdLib/Lib/turtledemo/planet_and_moon.py similarity index 100% rename from src/extensions/StdLib/Lib/turtledemo/planet_and_moon.py rename to src/core/IronPython.StdLib/Lib/turtledemo/planet_and_moon.py diff --git a/src/extensions/StdLib/Lib/turtledemo/round_dance.py b/src/core/IronPython.StdLib/Lib/turtledemo/round_dance.py similarity index 100% rename from src/extensions/StdLib/Lib/turtledemo/round_dance.py rename to src/core/IronPython.StdLib/Lib/turtledemo/round_dance.py diff --git a/src/extensions/StdLib/Lib/turtledemo/tree.py b/src/core/IronPython.StdLib/Lib/turtledemo/tree.py similarity index 100% rename from src/extensions/StdLib/Lib/turtledemo/tree.py rename to src/core/IronPython.StdLib/Lib/turtledemo/tree.py diff --git a/src/extensions/StdLib/Lib/turtledemo/turtle.cfg b/src/core/IronPython.StdLib/Lib/turtledemo/turtle.cfg similarity index 100% rename from src/extensions/StdLib/Lib/turtledemo/turtle.cfg rename to src/core/IronPython.StdLib/Lib/turtledemo/turtle.cfg diff --git a/src/extensions/StdLib/Lib/turtledemo/two_canvases.py b/src/core/IronPython.StdLib/Lib/turtledemo/two_canvases.py similarity index 100% rename from src/extensions/StdLib/Lib/turtledemo/two_canvases.py rename to src/core/IronPython.StdLib/Lib/turtledemo/two_canvases.py diff --git a/src/extensions/StdLib/Lib/turtledemo/wikipedia.py b/src/core/IronPython.StdLib/Lib/turtledemo/wikipedia.py similarity index 100% rename from src/extensions/StdLib/Lib/turtledemo/wikipedia.py rename to src/core/IronPython.StdLib/Lib/turtledemo/wikipedia.py diff --git a/src/extensions/StdLib/Lib/turtledemo/yinyang.py b/src/core/IronPython.StdLib/Lib/turtledemo/yinyang.py similarity index 100% rename from src/extensions/StdLib/Lib/turtledemo/yinyang.py rename to src/core/IronPython.StdLib/Lib/turtledemo/yinyang.py diff --git a/src/extensions/StdLib/Lib/types.py b/src/core/IronPython.StdLib/Lib/types.py similarity index 100% rename from src/extensions/StdLib/Lib/types.py rename to src/core/IronPython.StdLib/Lib/types.py diff --git a/src/extensions/StdLib/Lib/typing.py b/src/core/IronPython.StdLib/Lib/typing.py similarity index 100% rename from src/extensions/StdLib/Lib/typing.py rename to src/core/IronPython.StdLib/Lib/typing.py diff --git a/src/extensions/StdLib/Lib/unittest/__init__.py b/src/core/IronPython.StdLib/Lib/unittest/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/__init__.py rename to src/core/IronPython.StdLib/Lib/unittest/__init__.py diff --git a/src/extensions/StdLib/Lib/unittest/__main__.py b/src/core/IronPython.StdLib/Lib/unittest/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/__main__.py rename to src/core/IronPython.StdLib/Lib/unittest/__main__.py diff --git a/src/extensions/StdLib/Lib/unittest/case.py b/src/core/IronPython.StdLib/Lib/unittest/case.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/case.py rename to src/core/IronPython.StdLib/Lib/unittest/case.py diff --git a/src/extensions/StdLib/Lib/unittest/loader.py b/src/core/IronPython.StdLib/Lib/unittest/loader.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/loader.py rename to src/core/IronPython.StdLib/Lib/unittest/loader.py diff --git a/src/extensions/StdLib/Lib/unittest/main.py b/src/core/IronPython.StdLib/Lib/unittest/main.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/main.py rename to src/core/IronPython.StdLib/Lib/unittest/main.py diff --git a/src/extensions/StdLib/Lib/unittest/mock.py b/src/core/IronPython.StdLib/Lib/unittest/mock.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/mock.py rename to src/core/IronPython.StdLib/Lib/unittest/mock.py diff --git a/src/extensions/StdLib/Lib/unittest/result.py b/src/core/IronPython.StdLib/Lib/unittest/result.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/result.py rename to src/core/IronPython.StdLib/Lib/unittest/result.py diff --git a/src/extensions/StdLib/Lib/unittest/runner.py b/src/core/IronPython.StdLib/Lib/unittest/runner.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/runner.py rename to src/core/IronPython.StdLib/Lib/unittest/runner.py diff --git a/src/extensions/StdLib/Lib/unittest/signals.py b/src/core/IronPython.StdLib/Lib/unittest/signals.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/signals.py rename to src/core/IronPython.StdLib/Lib/unittest/signals.py diff --git a/src/extensions/StdLib/Lib/unittest/suite.py b/src/core/IronPython.StdLib/Lib/unittest/suite.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/suite.py rename to src/core/IronPython.StdLib/Lib/unittest/suite.py diff --git a/src/extensions/StdLib/Lib/unittest/test/__init__.py b/src/core/IronPython.StdLib/Lib/unittest/test/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/__init__.py rename to src/core/IronPython.StdLib/Lib/unittest/test/__init__.py diff --git a/src/extensions/StdLib/Lib/unittest/test/__main__.py b/src/core/IronPython.StdLib/Lib/unittest/test/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/__main__.py rename to src/core/IronPython.StdLib/Lib/unittest/test/__main__.py diff --git a/src/extensions/StdLib/Lib/unittest/test/_test_warnings.py b/src/core/IronPython.StdLib/Lib/unittest/test/_test_warnings.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/_test_warnings.py rename to src/core/IronPython.StdLib/Lib/unittest/test/_test_warnings.py diff --git a/src/extensions/StdLib/Lib/unittest/test/dummy.py b/src/core/IronPython.StdLib/Lib/unittest/test/dummy.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/dummy.py rename to src/core/IronPython.StdLib/Lib/unittest/test/dummy.py diff --git a/src/extensions/StdLib/Lib/unittest/test/support.py b/src/core/IronPython.StdLib/Lib/unittest/test/support.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/support.py rename to src/core/IronPython.StdLib/Lib/unittest/test/support.py diff --git a/src/extensions/StdLib/Lib/unittest/test/test_assertions.py b/src/core/IronPython.StdLib/Lib/unittest/test/test_assertions.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/test_assertions.py rename to src/core/IronPython.StdLib/Lib/unittest/test/test_assertions.py diff --git a/src/extensions/StdLib/Lib/unittest/test/test_break.py b/src/core/IronPython.StdLib/Lib/unittest/test/test_break.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/test_break.py rename to src/core/IronPython.StdLib/Lib/unittest/test/test_break.py diff --git a/src/extensions/StdLib/Lib/unittest/test/test_case.py b/src/core/IronPython.StdLib/Lib/unittest/test/test_case.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/test_case.py rename to src/core/IronPython.StdLib/Lib/unittest/test/test_case.py diff --git a/src/extensions/StdLib/Lib/unittest/test/test_discovery.py b/src/core/IronPython.StdLib/Lib/unittest/test/test_discovery.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/test_discovery.py rename to src/core/IronPython.StdLib/Lib/unittest/test/test_discovery.py diff --git a/src/extensions/StdLib/Lib/unittest/test/test_functiontestcase.py b/src/core/IronPython.StdLib/Lib/unittest/test/test_functiontestcase.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/test_functiontestcase.py rename to src/core/IronPython.StdLib/Lib/unittest/test/test_functiontestcase.py diff --git a/src/extensions/StdLib/Lib/unittest/test/test_loader.py b/src/core/IronPython.StdLib/Lib/unittest/test/test_loader.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/test_loader.py rename to src/core/IronPython.StdLib/Lib/unittest/test/test_loader.py diff --git a/src/extensions/StdLib/Lib/unittest/test/test_program.py b/src/core/IronPython.StdLib/Lib/unittest/test/test_program.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/test_program.py rename to src/core/IronPython.StdLib/Lib/unittest/test/test_program.py diff --git a/src/extensions/StdLib/Lib/unittest/test/test_result.py b/src/core/IronPython.StdLib/Lib/unittest/test/test_result.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/test_result.py rename to src/core/IronPython.StdLib/Lib/unittest/test/test_result.py diff --git a/src/extensions/StdLib/Lib/unittest/test/test_runner.py b/src/core/IronPython.StdLib/Lib/unittest/test/test_runner.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/test_runner.py rename to src/core/IronPython.StdLib/Lib/unittest/test/test_runner.py diff --git a/src/extensions/StdLib/Lib/unittest/test/test_setups.py b/src/core/IronPython.StdLib/Lib/unittest/test/test_setups.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/test_setups.py rename to src/core/IronPython.StdLib/Lib/unittest/test/test_setups.py diff --git a/src/extensions/StdLib/Lib/unittest/test/test_skipping.py b/src/core/IronPython.StdLib/Lib/unittest/test/test_skipping.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/test_skipping.py rename to src/core/IronPython.StdLib/Lib/unittest/test/test_skipping.py diff --git a/src/extensions/StdLib/Lib/unittest/test/test_suite.py b/src/core/IronPython.StdLib/Lib/unittest/test/test_suite.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/test_suite.py rename to src/core/IronPython.StdLib/Lib/unittest/test/test_suite.py diff --git a/src/extensions/StdLib/Lib/unittest/test/testmock/__init__.py b/src/core/IronPython.StdLib/Lib/unittest/test/testmock/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/testmock/__init__.py rename to src/core/IronPython.StdLib/Lib/unittest/test/testmock/__init__.py diff --git a/src/extensions/StdLib/Lib/unittest/test/testmock/__main__.py b/src/core/IronPython.StdLib/Lib/unittest/test/testmock/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/testmock/__main__.py rename to src/core/IronPython.StdLib/Lib/unittest/test/testmock/__main__.py diff --git a/src/extensions/StdLib/Lib/unittest/test/testmock/support.py b/src/core/IronPython.StdLib/Lib/unittest/test/testmock/support.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/testmock/support.py rename to src/core/IronPython.StdLib/Lib/unittest/test/testmock/support.py diff --git a/src/extensions/StdLib/Lib/unittest/test/testmock/testcallable.py b/src/core/IronPython.StdLib/Lib/unittest/test/testmock/testcallable.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/testmock/testcallable.py rename to src/core/IronPython.StdLib/Lib/unittest/test/testmock/testcallable.py diff --git a/src/extensions/StdLib/Lib/unittest/test/testmock/testhelpers.py b/src/core/IronPython.StdLib/Lib/unittest/test/testmock/testhelpers.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/testmock/testhelpers.py rename to src/core/IronPython.StdLib/Lib/unittest/test/testmock/testhelpers.py diff --git a/src/extensions/StdLib/Lib/unittest/test/testmock/testmagicmethods.py b/src/core/IronPython.StdLib/Lib/unittest/test/testmock/testmagicmethods.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/testmock/testmagicmethods.py rename to src/core/IronPython.StdLib/Lib/unittest/test/testmock/testmagicmethods.py diff --git a/src/extensions/StdLib/Lib/unittest/test/testmock/testmock.py b/src/core/IronPython.StdLib/Lib/unittest/test/testmock/testmock.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/testmock/testmock.py rename to src/core/IronPython.StdLib/Lib/unittest/test/testmock/testmock.py diff --git a/src/extensions/StdLib/Lib/unittest/test/testmock/testpatch.py b/src/core/IronPython.StdLib/Lib/unittest/test/testmock/testpatch.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/testmock/testpatch.py rename to src/core/IronPython.StdLib/Lib/unittest/test/testmock/testpatch.py diff --git a/src/extensions/StdLib/Lib/unittest/test/testmock/testsentinel.py b/src/core/IronPython.StdLib/Lib/unittest/test/testmock/testsentinel.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/testmock/testsentinel.py rename to src/core/IronPython.StdLib/Lib/unittest/test/testmock/testsentinel.py diff --git a/src/extensions/StdLib/Lib/unittest/test/testmock/testwith.py b/src/core/IronPython.StdLib/Lib/unittest/test/testmock/testwith.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/test/testmock/testwith.py rename to src/core/IronPython.StdLib/Lib/unittest/test/testmock/testwith.py diff --git a/src/extensions/StdLib/Lib/unittest/util.py b/src/core/IronPython.StdLib/Lib/unittest/util.py similarity index 100% rename from src/extensions/StdLib/Lib/unittest/util.py rename to src/core/IronPython.StdLib/Lib/unittest/util.py diff --git a/src/extensions/StdLib/Lib/urllib/__init__.py b/src/core/IronPython.StdLib/Lib/urllib/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/urllib/__init__.py rename to src/core/IronPython.StdLib/Lib/urllib/__init__.py diff --git a/src/extensions/StdLib/Lib/urllib/error.py b/src/core/IronPython.StdLib/Lib/urllib/error.py similarity index 100% rename from src/extensions/StdLib/Lib/urllib/error.py rename to src/core/IronPython.StdLib/Lib/urllib/error.py diff --git a/src/extensions/StdLib/Lib/urllib/parse.py b/src/core/IronPython.StdLib/Lib/urllib/parse.py similarity index 100% rename from src/extensions/StdLib/Lib/urllib/parse.py rename to src/core/IronPython.StdLib/Lib/urllib/parse.py diff --git a/src/extensions/StdLib/Lib/urllib/request.py b/src/core/IronPython.StdLib/Lib/urllib/request.py similarity index 100% rename from src/extensions/StdLib/Lib/urllib/request.py rename to src/core/IronPython.StdLib/Lib/urllib/request.py diff --git a/src/extensions/StdLib/Lib/urllib/response.py b/src/core/IronPython.StdLib/Lib/urllib/response.py similarity index 100% rename from src/extensions/StdLib/Lib/urllib/response.py rename to src/core/IronPython.StdLib/Lib/urllib/response.py diff --git a/src/extensions/StdLib/Lib/urllib/robotparser.py b/src/core/IronPython.StdLib/Lib/urllib/robotparser.py similarity index 100% rename from src/extensions/StdLib/Lib/urllib/robotparser.py rename to src/core/IronPython.StdLib/Lib/urllib/robotparser.py diff --git a/src/extensions/StdLib/Lib/uu.py b/src/core/IronPython.StdLib/Lib/uu.py similarity index 100% rename from src/extensions/StdLib/Lib/uu.py rename to src/core/IronPython.StdLib/Lib/uu.py diff --git a/src/extensions/StdLib/Lib/uuid.py b/src/core/IronPython.StdLib/Lib/uuid.py similarity index 100% rename from src/extensions/StdLib/Lib/uuid.py rename to src/core/IronPython.StdLib/Lib/uuid.py diff --git a/src/extensions/StdLib/Lib/venv/__init__.py b/src/core/IronPython.StdLib/Lib/venv/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/venv/__init__.py rename to src/core/IronPython.StdLib/Lib/venv/__init__.py diff --git a/src/extensions/StdLib/Lib/venv/__main__.py b/src/core/IronPython.StdLib/Lib/venv/__main__.py similarity index 100% rename from src/extensions/StdLib/Lib/venv/__main__.py rename to src/core/IronPython.StdLib/Lib/venv/__main__.py diff --git a/src/extensions/StdLib/Lib/venv/scripts/nt/Activate.ps1 b/src/core/IronPython.StdLib/Lib/venv/scripts/nt/Activate.ps1 similarity index 100% rename from src/extensions/StdLib/Lib/venv/scripts/nt/Activate.ps1 rename to src/core/IronPython.StdLib/Lib/venv/scripts/nt/Activate.ps1 diff --git a/src/extensions/StdLib/Lib/venv/scripts/nt/activate.bat b/src/core/IronPython.StdLib/Lib/venv/scripts/nt/activate.bat similarity index 100% rename from src/extensions/StdLib/Lib/venv/scripts/nt/activate.bat rename to src/core/IronPython.StdLib/Lib/venv/scripts/nt/activate.bat diff --git a/src/extensions/StdLib/Lib/venv/scripts/nt/deactivate.bat b/src/core/IronPython.StdLib/Lib/venv/scripts/nt/deactivate.bat similarity index 100% rename from src/extensions/StdLib/Lib/venv/scripts/nt/deactivate.bat rename to src/core/IronPython.StdLib/Lib/venv/scripts/nt/deactivate.bat diff --git a/src/extensions/StdLib/Lib/venv/scripts/posix/activate b/src/core/IronPython.StdLib/Lib/venv/scripts/posix/activate similarity index 100% rename from src/extensions/StdLib/Lib/venv/scripts/posix/activate rename to src/core/IronPython.StdLib/Lib/venv/scripts/posix/activate diff --git a/src/extensions/StdLib/Lib/venv/scripts/posix/activate.csh b/src/core/IronPython.StdLib/Lib/venv/scripts/posix/activate.csh similarity index 100% rename from src/extensions/StdLib/Lib/venv/scripts/posix/activate.csh rename to src/core/IronPython.StdLib/Lib/venv/scripts/posix/activate.csh diff --git a/src/extensions/StdLib/Lib/venv/scripts/posix/activate.fish b/src/core/IronPython.StdLib/Lib/venv/scripts/posix/activate.fish similarity index 100% rename from src/extensions/StdLib/Lib/venv/scripts/posix/activate.fish rename to src/core/IronPython.StdLib/Lib/venv/scripts/posix/activate.fish diff --git a/src/extensions/StdLib/Lib/warnings.py b/src/core/IronPython.StdLib/Lib/warnings.py similarity index 100% rename from src/extensions/StdLib/Lib/warnings.py rename to src/core/IronPython.StdLib/Lib/warnings.py diff --git a/src/extensions/StdLib/Lib/wave.py b/src/core/IronPython.StdLib/Lib/wave.py similarity index 100% rename from src/extensions/StdLib/Lib/wave.py rename to src/core/IronPython.StdLib/Lib/wave.py diff --git a/src/extensions/StdLib/Lib/weakref.py b/src/core/IronPython.StdLib/Lib/weakref.py similarity index 100% rename from src/extensions/StdLib/Lib/weakref.py rename to src/core/IronPython.StdLib/Lib/weakref.py diff --git a/src/extensions/StdLib/Lib/webbrowser.py b/src/core/IronPython.StdLib/Lib/webbrowser.py similarity index 100% rename from src/extensions/StdLib/Lib/webbrowser.py rename to src/core/IronPython.StdLib/Lib/webbrowser.py diff --git a/src/extensions/StdLib/Lib/wpf.py b/src/core/IronPython.StdLib/Lib/wpf.py similarity index 100% rename from src/extensions/StdLib/Lib/wpf.py rename to src/core/IronPython.StdLib/Lib/wpf.py diff --git a/src/extensions/StdLib/Lib/wsgiref/__init__.py b/src/core/IronPython.StdLib/Lib/wsgiref/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/wsgiref/__init__.py rename to src/core/IronPython.StdLib/Lib/wsgiref/__init__.py diff --git a/src/extensions/StdLib/Lib/wsgiref/handlers.py b/src/core/IronPython.StdLib/Lib/wsgiref/handlers.py similarity index 100% rename from src/extensions/StdLib/Lib/wsgiref/handlers.py rename to src/core/IronPython.StdLib/Lib/wsgiref/handlers.py diff --git a/src/extensions/StdLib/Lib/wsgiref/headers.py b/src/core/IronPython.StdLib/Lib/wsgiref/headers.py similarity index 100% rename from src/extensions/StdLib/Lib/wsgiref/headers.py rename to src/core/IronPython.StdLib/Lib/wsgiref/headers.py diff --git a/src/extensions/StdLib/Lib/wsgiref/simple_server.py b/src/core/IronPython.StdLib/Lib/wsgiref/simple_server.py similarity index 100% rename from src/extensions/StdLib/Lib/wsgiref/simple_server.py rename to src/core/IronPython.StdLib/Lib/wsgiref/simple_server.py diff --git a/src/extensions/StdLib/Lib/wsgiref/util.py b/src/core/IronPython.StdLib/Lib/wsgiref/util.py similarity index 100% rename from src/extensions/StdLib/Lib/wsgiref/util.py rename to src/core/IronPython.StdLib/Lib/wsgiref/util.py diff --git a/src/extensions/StdLib/Lib/wsgiref/validate.py b/src/core/IronPython.StdLib/Lib/wsgiref/validate.py similarity index 100% rename from src/extensions/StdLib/Lib/wsgiref/validate.py rename to src/core/IronPython.StdLib/Lib/wsgiref/validate.py diff --git a/src/extensions/StdLib/Lib/xdrlib.py b/src/core/IronPython.StdLib/Lib/xdrlib.py similarity index 100% rename from src/extensions/StdLib/Lib/xdrlib.py rename to src/core/IronPython.StdLib/Lib/xdrlib.py diff --git a/src/extensions/StdLib/Lib/xml/__init__.py b/src/core/IronPython.StdLib/Lib/xml/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/__init__.py rename to src/core/IronPython.StdLib/Lib/xml/__init__.py diff --git a/src/extensions/StdLib/Lib/xml/dom/NodeFilter.py b/src/core/IronPython.StdLib/Lib/xml/dom/NodeFilter.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/dom/NodeFilter.py rename to src/core/IronPython.StdLib/Lib/xml/dom/NodeFilter.py diff --git a/src/extensions/StdLib/Lib/xml/dom/__init__.py b/src/core/IronPython.StdLib/Lib/xml/dom/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/dom/__init__.py rename to src/core/IronPython.StdLib/Lib/xml/dom/__init__.py diff --git a/src/extensions/StdLib/Lib/xml/dom/domreg.py b/src/core/IronPython.StdLib/Lib/xml/dom/domreg.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/dom/domreg.py rename to src/core/IronPython.StdLib/Lib/xml/dom/domreg.py diff --git a/src/extensions/StdLib/Lib/xml/dom/expatbuilder.py b/src/core/IronPython.StdLib/Lib/xml/dom/expatbuilder.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/dom/expatbuilder.py rename to src/core/IronPython.StdLib/Lib/xml/dom/expatbuilder.py diff --git a/src/extensions/StdLib/Lib/xml/dom/minicompat.py b/src/core/IronPython.StdLib/Lib/xml/dom/minicompat.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/dom/minicompat.py rename to src/core/IronPython.StdLib/Lib/xml/dom/minicompat.py diff --git a/src/extensions/StdLib/Lib/xml/dom/minidom.py b/src/core/IronPython.StdLib/Lib/xml/dom/minidom.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/dom/minidom.py rename to src/core/IronPython.StdLib/Lib/xml/dom/minidom.py diff --git a/src/extensions/StdLib/Lib/xml/dom/pulldom.py b/src/core/IronPython.StdLib/Lib/xml/dom/pulldom.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/dom/pulldom.py rename to src/core/IronPython.StdLib/Lib/xml/dom/pulldom.py diff --git a/src/extensions/StdLib/Lib/xml/dom/xmlbuilder.py b/src/core/IronPython.StdLib/Lib/xml/dom/xmlbuilder.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/dom/xmlbuilder.py rename to src/core/IronPython.StdLib/Lib/xml/dom/xmlbuilder.py diff --git a/src/extensions/StdLib/Lib/xml/etree/ElementInclude.py b/src/core/IronPython.StdLib/Lib/xml/etree/ElementInclude.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/etree/ElementInclude.py rename to src/core/IronPython.StdLib/Lib/xml/etree/ElementInclude.py diff --git a/src/extensions/StdLib/Lib/xml/etree/ElementPath.py b/src/core/IronPython.StdLib/Lib/xml/etree/ElementPath.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/etree/ElementPath.py rename to src/core/IronPython.StdLib/Lib/xml/etree/ElementPath.py diff --git a/src/extensions/StdLib/Lib/xml/etree/ElementTree.py b/src/core/IronPython.StdLib/Lib/xml/etree/ElementTree.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/etree/ElementTree.py rename to src/core/IronPython.StdLib/Lib/xml/etree/ElementTree.py diff --git a/src/extensions/StdLib/Lib/xml/etree/__init__.py b/src/core/IronPython.StdLib/Lib/xml/etree/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/etree/__init__.py rename to src/core/IronPython.StdLib/Lib/xml/etree/__init__.py diff --git a/src/extensions/StdLib/Lib/xml/etree/cElementTree.py b/src/core/IronPython.StdLib/Lib/xml/etree/cElementTree.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/etree/cElementTree.py rename to src/core/IronPython.StdLib/Lib/xml/etree/cElementTree.py diff --git a/src/extensions/StdLib/Lib/xml/parsers/__init__.py b/src/core/IronPython.StdLib/Lib/xml/parsers/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/parsers/__init__.py rename to src/core/IronPython.StdLib/Lib/xml/parsers/__init__.py diff --git a/src/extensions/StdLib/Lib/xml/parsers/expat.py b/src/core/IronPython.StdLib/Lib/xml/parsers/expat.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/parsers/expat.py rename to src/core/IronPython.StdLib/Lib/xml/parsers/expat.py diff --git a/src/extensions/StdLib/Lib/xml/sax/__init__.py b/src/core/IronPython.StdLib/Lib/xml/sax/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/sax/__init__.py rename to src/core/IronPython.StdLib/Lib/xml/sax/__init__.py diff --git a/src/extensions/StdLib/Lib/xml/sax/_exceptions.py b/src/core/IronPython.StdLib/Lib/xml/sax/_exceptions.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/sax/_exceptions.py rename to src/core/IronPython.StdLib/Lib/xml/sax/_exceptions.py diff --git a/src/extensions/StdLib/Lib/xml/sax/expatreader.py b/src/core/IronPython.StdLib/Lib/xml/sax/expatreader.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/sax/expatreader.py rename to src/core/IronPython.StdLib/Lib/xml/sax/expatreader.py diff --git a/src/extensions/StdLib/Lib/xml/sax/handler.py b/src/core/IronPython.StdLib/Lib/xml/sax/handler.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/sax/handler.py rename to src/core/IronPython.StdLib/Lib/xml/sax/handler.py diff --git a/src/extensions/StdLib/Lib/xml/sax/saxutils.py b/src/core/IronPython.StdLib/Lib/xml/sax/saxutils.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/sax/saxutils.py rename to src/core/IronPython.StdLib/Lib/xml/sax/saxutils.py diff --git a/src/extensions/StdLib/Lib/xml/sax/xmlreader.py b/src/core/IronPython.StdLib/Lib/xml/sax/xmlreader.py similarity index 100% rename from src/extensions/StdLib/Lib/xml/sax/xmlreader.py rename to src/core/IronPython.StdLib/Lib/xml/sax/xmlreader.py diff --git a/src/extensions/StdLib/Lib/xmlrpc/__init__.py b/src/core/IronPython.StdLib/Lib/xmlrpc/__init__.py similarity index 100% rename from src/extensions/StdLib/Lib/xmlrpc/__init__.py rename to src/core/IronPython.StdLib/Lib/xmlrpc/__init__.py diff --git a/src/extensions/StdLib/Lib/xmlrpc/client.py b/src/core/IronPython.StdLib/Lib/xmlrpc/client.py similarity index 100% rename from src/extensions/StdLib/Lib/xmlrpc/client.py rename to src/core/IronPython.StdLib/Lib/xmlrpc/client.py diff --git a/src/extensions/StdLib/Lib/xmlrpc/server.py b/src/core/IronPython.StdLib/Lib/xmlrpc/server.py similarity index 100% rename from src/extensions/StdLib/Lib/xmlrpc/server.py rename to src/core/IronPython.StdLib/Lib/xmlrpc/server.py diff --git a/src/extensions/StdLib/Lib/zipfile.py b/src/core/IronPython.StdLib/Lib/zipfile.py similarity index 100% rename from src/extensions/StdLib/Lib/zipfile.py rename to src/core/IronPython.StdLib/Lib/zipfile.py diff --git a/src/extensions/StdLib/StdLib.License.txt b/src/core/IronPython.StdLib/StdLib.License.txt similarity index 100% rename from src/extensions/StdLib/StdLib.License.txt rename to src/core/IronPython.StdLib/StdLib.License.txt diff --git a/src/extensions/StdLib/stdlib-upgrade.txt b/src/core/IronPython.StdLib/stdlib-upgrade.txt similarity index 100% rename from src/extensions/StdLib/stdlib-upgrade.txt rename to src/core/IronPython.StdLib/stdlib-upgrade.txt diff --git a/src/extensions/StdLib/update-stdlib.cmd b/src/core/IronPython.StdLib/update-stdlib.cmd similarity index 100% rename from src/extensions/StdLib/update-stdlib.cmd rename to src/core/IronPython.StdLib/update-stdlib.cmd diff --git a/src/extensions/StdLib/update-stdlib.sh b/src/core/IronPython.StdLib/update-stdlib.sh similarity index 100% rename from src/extensions/StdLib/update-stdlib.sh rename to src/core/IronPython.StdLib/update-stdlib.sh From 99a51012013fd5ea055fade5a53401127cad3d16 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Thu, 28 Nov 2024 18:38:28 +0000 Subject: [PATCH 74/84] Update copyright in places i must have missed in #1813 --- eng/nuget/IronPython.StdLib.nuspec | 2 +- eng/nuget/IronPython.nuspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/nuget/IronPython.StdLib.nuspec b/eng/nuget/IronPython.StdLib.nuspec index b3b8ce2c3..3058f2683 100644 --- a/eng/nuget/IronPython.StdLib.nuspec +++ b/eng/nuget/IronPython.StdLib.nuspec @@ -5,7 +5,7 @@ IronPython Standard Library 3.4.0 IronPython Contributors, Python Contributors - © IronPython Contributors + © .NET Foundation https://ironpython.net StdLib.License.txt false diff --git a/eng/nuget/IronPython.nuspec b/eng/nuget/IronPython.nuspec index 0799d41fe..779ce0c53 100644 --- a/eng/nuget/IronPython.nuspec +++ b/eng/nuget/IronPython.nuspec @@ -5,7 +5,7 @@ IronPython 3.4.0 IronPython Contributors, Microsoft - © IronPython Contributors + © .NET Foundation https://ironpython.net Apache-2.0 From cd928ec12431b4f13671e79cfb748ea36f78076e Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Thu, 28 Nov 2024 18:40:22 +0000 Subject: [PATCH 75/84] Fix references to standard library --- src/core/IronPython/IronPython.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/IronPython/IronPython.csproj b/src/core/IronPython/IronPython.csproj index 4e2918ab2..ea18137d0 100644 --- a/src/core/IronPython/IronPython.csproj +++ b/src/core/IronPython/IronPython.csproj @@ -38,7 +38,7 @@ PreserveNewest - + PreserveNewest @@ -46,7 +46,7 @@ - + From dc95e6dc729146640ef0c90e5a199156d6eb4ff1 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Thu, 28 Nov 2024 18:45:35 +0000 Subject: [PATCH 76/84] Fix all other references to structure manual.... --- docs/building.md | 2 +- docs/installing.md | 6 +++--- docs/modifying-the-sources.md | 6 +++--- eng/scripts/Install-IronPython.ps1 | 6 +++--- eng/scripts/generate.py | 8 ++++---- eng/scripts/generate_exception_factory.py | 2 +- src/core/IronPython/Lib/iptest/ipunittest.py | 2 +- tests/ironpython/Cases/CPythonCases.cs | 2 +- tests/ironpython/Cases/CaseExecuter.cs | 8 ++++---- tests/ironpython/Cases/IronPythonCases.cs | 4 ++-- tests/ironpython/EngineTest.cs | 4 ++-- tests/python/gen_stdlib_test.py | 2 +- tests/python/test_exceptions_generated.py | 4 ++-- 13 files changed, 28 insertions(+), 28 deletions(-) diff --git a/docs/building.md b/docs/building.md index 3a8879a29..e3aab4100 100644 --- a/docs/building.md +++ b/docs/building.md @@ -45,6 +45,6 @@ If the build is successful the binaries are stored in `ironpython3/bin/{Configur ## Running -The standard library is not copied over to the `bin` folder during the build process, it lives in `Src/StdLib/Lib`. +The standard library is not copied over to the `bin` folder during the build process, it lives in `src/IronPython.StdLib/Lib`. - When running the `Release` configuration executable, you should set the environment variable `IRONPYTHONPATH` to this folder. - When running the `Debug` configuration executable, this folder is automatically added to `sys.path`. diff --git a/docs/installing.md b/docs/installing.md index 48c7f7c4f..1c217ab5e 100644 --- a/docs/installing.md +++ b/docs/installing.md @@ -87,7 +87,7 @@ Use Powershell's `help` command on the script for information about available op The script is also available online, so it can be downloaded and invoked without unzipping the archive first. ``` -PS> Invoke-WebRequest https://raw.githubusercontent.com/IronLanguages/ironpython3/main/Src/Scripts/Install-IronPython.ps1 -OutFile ./Install-IronPython.ps1 +PS> Invoke-WebRequest https://raw.githubusercontent.com/IronLanguages/ironpython3/main/src/Scripts/Install-IronPython.ps1 -OutFile ./Install-IronPython.ps1 PS> ./Install-IronPython ~/ipyenv ~/Downloads/IronPython.3.X.Y.zip PS> ~/ipyenv/Enter-IronPythonEnvironment «ipyenv» PS> ipy @@ -170,10 +170,10 @@ If those executables test out successfully, the binaries can be installed outsid The artifacts are placed in directory `./Package/Release/Packages/IronPython-3.X.Y`. Pick a package suitable for your installation target and follow instructions above for the officially released packages. -Note: as a convenience, if you run `Install-IronPython.ps1` directly from directory `./Src/Scripts` to install IronPython from the zip file, there is no need to pass the location to the zip file; the script finds it automatically using the relative path. +Note: as a convenience, if you run `Install-IronPython.ps1` directly from directory `./src/Scripts` to install IronPython from the zip file, there is no need to pass the location to the zip file; the script finds it automatically using the relative path. Installation example: ``` -./Src/Scripts/Install-IronPython.ps1 /path/to/install/directory -framework net462 +./src/Scripts/Install-IronPython.ps1 /path/to/install/directory -framework net462 ``` diff --git a/docs/modifying-the-sources.md b/docs/modifying-the-sources.md index 7016f075d..b9c9caefb 100644 --- a/docs/modifying-the-sources.md +++ b/docs/modifying-the-sources.md @@ -1,6 +1,6 @@ # TDD -Bug fixes should be accompanied by a test that shows that the bug has been fixed. If the bug fix is fixing something that is covered by a test in the C Python test suite (Src\StdLib\Lib\test) and that test is not currently enabled, try enabling the test in Src\IronPythonTest\Cases\*.ini depending on the type of test it is. +Bug fixes should be accompanied by a test that shows that the bug has been fixed. If the bug fix is fixing something that is covered by a test in the C Python test suite (src\StdLib\Lib\test) and that test is not currently enabled, try enabling the test in src\IronPythonTest\Cases\*.ini depending on the type of test it is. Most PR's will not be accepted if there is not a test included. @@ -9,7 +9,7 @@ Most PR's will not be accepted if there is not a test included. * We have a .editorconfig file with the coding conventions used in the project. Please use an editor that honors these settings. * Use [.NET Framework conventions for all identifiers](https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/naming-guidelines). - * There is no specific guideline for naming private fields in this document; we prefix field names with underscores (e.g. private string _fooBar;) so that use of the fields is easily distinguishable as a field access as opposed to a local variable access. + * There is no specific guideline for naming private fields in this document; we prefix field names with underscores (e.g. private string _fooBar;) so that use of the fields is easily distinguishable as a field access as opposed to a local variable access. * If you're not sure about some convention, try to find out in the rest of the IronPython code or ask in the list. * Use `/*!*/` for method parameters and instance fields that should never be null. [Spec# annotations](http://research.microsoft.com/specsharp). * Do not use public fields (Base::algorithm, buffer). Use properties if it is necessary to expose the field or private/internal visibility otherwise. @@ -23,4 +23,4 @@ The following commands will build and run all the tests that are required to pas ``` ./make.ps1 test-all -``` \ No newline at end of file +``` diff --git a/eng/scripts/Install-IronPython.ps1 b/eng/scripts/Install-IronPython.ps1 index 030d93f3f..85e25c743 100644 --- a/eng/scripts/Install-IronPython.ps1 +++ b/eng/scripts/Install-IronPython.ps1 @@ -30,7 +30,7 @@ PS>./make PS>./make package - PS>./Src/Scripts/Install-IronPython.ps1 env + PS>./eng/scripts/Install-IronPython.ps1 env These commands should be issued on a Powershell prompt with the current directory set to the project root. The project is first built, then packaged, and finally the script uses the zipfile produced during packaging to install IronPython in directory "env". @@ -60,11 +60,11 @@ if (-not $ZipFile) { if ($splitPSScriptRoot[-1] -eq "scripts" -and (Test-Path (Join-Path (Split-Path $PSScriptRoot) "lib"))) { # Script run from within already expanded zip file $unzipDir = $PSScriptRoot | Split-Path - } elseif ($splitPSScriptRoot[-2] -eq "Src" -and $splitPSScriptRoot[-1] -eq "Scripts") { + } elseif ($splitPSScriptRoot[-2] -eq "eng" -and $splitPSScriptRoot[-1] -eq "scripts") { # Script run from within a checked out code base # Locate the zip archive in the standard location of the package target $projectRoot = $PSScriptRoot | Split-Path | Split-Path - $zipFiles = @(Resolve-Path (Join-Path $projectRoot "Package/Release/Packages/IronPython-*/IronPython.3.*.zip")) + $zipFiles = @(Resolve-Path (Join-Path $projectRoot "eng/Release/Packages/IronPython-*/IronPython.3.*.zip")) if ($zipFiles.Count -gt 1) { Write-Error (@("Ambiguous implicit project zip files:") + $zipFiles -join "`n") } elseif ($zipFiles.Count -lt 1) { diff --git a/eng/scripts/generate.py b/eng/scripts/generate.py index 6b7ac5b2f..765de2948 100644 --- a/eng/scripts/generate.py +++ b/eng/scripts/generate.py @@ -15,13 +15,13 @@ def get_root_dir(): root_dir = get_root_dir() source_directories = [ - os.path.join(root_dir, "Src"), - os.path.join(root_dir, "Src", "DLR", "Src"), + os.path.join(root_dir, "src"), + os.path.join(root_dir, "src", "runtime", "Src"), ] exclude_directories = [ - os.path.join(root_dir, "Src", "DLR"), - os.path.join(root_dir, "Src", "StdLib"), + os.path.join(root_dir, "src", "runtime"), + os.path.join(root_dir, "src", "core", "IronPython.StdLib"), ] START_COMMON = "#region Generated" diff --git a/eng/scripts/generate_exception_factory.py b/eng/scripts/generate_exception_factory.py index ec1e4e4f8..25d2ee73c 100644 --- a/eng/scripts/generate_exception_factory.py +++ b/eng/scripts/generate_exception_factory.py @@ -172,7 +172,7 @@ def gen_expr_factory_com(cw): gen_expr_factory(cw, generate.root_dir + "\\..\\..\\ndp\\fx\\src\\Dynamic\\System\\Dynamic\\System.Dynamic.txt") def gen_expr_factory_scripting(cw): - gen_expr_factory(cw, generate.root_dir + "\\Src\\DLR\\Src\\Microsoft.Dynamic\\Microsoft.Scripting.txt") + gen_expr_factory(cw, generate.root_dir + "\\src\\runtime\\Src\\Microsoft.Dynamic\\Microsoft.Scripting.txt") def main(): return generate.generate( diff --git a/src/core/IronPython/Lib/iptest/ipunittest.py b/src/core/IronPython/Lib/iptest/ipunittest.py index ca990a35a..58f618688 100644 --- a/src/core/IronPython/Lib/iptest/ipunittest.py +++ b/src/core/IronPython/Lib/iptest/ipunittest.py @@ -85,7 +85,7 @@ def t(*args, **kwargs): return t def _find_root(): - test_dirs = ['Src', 'Build', 'Package', 'Tests', 'Util'] + test_dirs = ['src', 'eng', 'tests'] root = os.getcwd() test = all([os.path.exists(os.path.join(root, x)) for x in test_dirs]) while not test: diff --git a/tests/ironpython/Cases/CPythonCases.cs b/tests/ironpython/Cases/CPythonCases.cs index f3d568064..4120dbf30 100644 --- a/tests/ironpython/Cases/CPythonCases.cs +++ b/tests/ironpython/Cases/CPythonCases.cs @@ -18,7 +18,7 @@ public override int Test(TestInfo testcase) { internal class CPythonCaseGenerator : CommonCaseGenerator { protected override IEnumerable GetTests() { - var libFolder = Path.Combine("Src", "StdLib", "Lib"); + var libFolder = Path.Combine("src", "core", "IronPython.StdLib", "Lib"); return GetFilenames(new [] { System.Tuple.Create(category, Path.Combine(libFolder, "test")), System.Tuple.Create($"{category}.ctypes", Path.Combine(libFolder, "ctypes", "test")), diff --git a/tests/ironpython/Cases/CaseExecuter.cs b/tests/ironpython/Cases/CaseExecuter.cs index d75cbc047..c2a8290f2 100644 --- a/tests/ironpython/Cases/CaseExecuter.cs +++ b/tests/ironpython/Cases/CaseExecuter.cs @@ -65,11 +65,11 @@ public static ScriptEngine CreateEngine(TestOptions options) { } internal static string FindRoot() { - // we start at the current directory and look up until we find the "Src" directory + // we start at the current directory and look up until we find the "src" directory var current = System.Reflection.Assembly.GetExecutingAssembly().Location; var found = false; while (!found && !string.IsNullOrEmpty(current)) { - var test = Path.Combine(current, "Src", "StdLib", "Lib"); + var test = Path.Combine(current, "src", "core", "IronPython.StdLib", "Lib"); if (Directory.Exists(test)) { return current; } @@ -84,7 +84,7 @@ private static void AddSearchPaths(ScriptEngine engine) { if (!paths.Any(x => x.Contains("stdlib", StringComparison.OrdinalIgnoreCase))) { var root = FindRoot(); if (!string.IsNullOrEmpty(root)) { - paths.Insert(0, Path.Combine(root, "Src", "StdLib", "Lib")); + paths.Insert(0, Path.Combine(root, "src", "core", "IronPython.StdLib", "Lib")); } } engine.SetSearchPaths(paths); @@ -140,7 +140,7 @@ public string FormatException(Exception ex) { } private static string GetIronPythonPath() { - var path = Path.Combine(FindRoot(), "Src", "StdLib", "Lib"); + var path = Path.Combine(FindRoot(), "src", "core", "IronPython.StdLib", "Lib"); if (Directory.Exists(path)) { return path; } diff --git a/tests/ironpython/Cases/IronPythonCases.cs b/tests/ironpython/Cases/IronPythonCases.cs index 2cd431625..7245b2c42 100644 --- a/tests/ironpython/Cases/IronPythonCases.cs +++ b/tests/ironpython/Cases/IronPythonCases.cs @@ -9,7 +9,7 @@ namespace IronPythonTest.Cases { [TestFixture(Category = "IronPython")] - public class IronPythonCases : CommonCases { + public class IronPythonCases : CommonCases { [Test, TestCaseSource(typeof(IronPythonCaseGenerator))] public override int Test(TestInfo testcase) { return TestImpl(testcase); @@ -20,7 +20,7 @@ internal class IronPythonCaseGenerator : CommonCaseGenerator { protected override IEnumerable GetTests() { return GetFilenames(new[] { System.Tuple.Create(category, "Tests"), - System.Tuple.Create($"{category}.scripts", Path.Combine("Src", "Scripts")), + System.Tuple.Create($"{category}.scripts", Path.Combine("src", "Scripts")), }) .OrderBy(testcase => testcase.Name); diff --git a/tests/ironpython/EngineTest.cs b/tests/ironpython/EngineTest.cs index f6cd8b21f..afa84ac01 100644 --- a/tests/ironpython/EngineTest.cs +++ b/tests/ironpython/EngineTest.cs @@ -58,11 +58,11 @@ static Common() { } private static string FindRoot() { - // we start at the current directory and look up until we find the "Src" directory + // we start at the current directory and look up until we find the "src" directory var current = System.Reflection.Assembly.GetExecutingAssembly().Location; var found = false; while (!found && !string.IsNullOrEmpty(current)) { - var test = Path.Combine(current, "Src", "StdLib", "Lib"); + var test = Path.Combine(current, "src", "core", "IronPython.StdLib", "Lib"); if (Directory.Exists(test)) { return current; } diff --git a/tests/python/gen_stdlib_test.py b/tests/python/gen_stdlib_test.py index b8180dea5..a03c6a6ac 100644 --- a/tests/python/gen_stdlib_test.py +++ b/tests/python/gen_stdlib_test.py @@ -51,7 +51,7 @@ def load_tests(loader, standard_tests, pattern): filepath = os.path.join(location, name + ("_" + package if package else "") + "_stdlib.py") - sys.path.insert(0, os.path.abspath(os.path.join(__file__, "../../Src/StdLib/Lib"))) + sys.path.insert(0, os.path.abspath(os.path.join(__file__, "../../src/core/IronPython.StdLib/Lib"))) module = importlib.import_module("{package}test.{name}".format(name=name, package=package + "." if package else "")) tests = [] diff --git a/tests/python/test_exceptions_generated.py b/tests/python/test_exceptions_generated.py index 079224089..49963060f 100644 --- a/tests/python/test_exceptions_generated.py +++ b/tests/python/test_exceptions_generated.py @@ -30,7 +30,7 @@ def setUp(self): clr.AddReference("IronPython") if is_cli: - with path_modifier(os.path.join(source_root(), 'Src', 'Scripts')): + with path_modifier(os.path.join(source_root(), 'eng', 'scripts')): from generate_exceptions import pythonExcs as test_cases test_cases = [x.replace('Error', '') + 'Exception' for x in test_cases] for exc_name in test_cases: @@ -38,4 +38,4 @@ def setUp(self): test = gen_testcase(exc_name) setattr(ExceptionsGeneratedTest, test_name, test) -run_test(__name__) \ No newline at end of file +run_test(__name__) From f915c58e71355c60efa035fce46a7c82e3a56d9a Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Fri, 29 Nov 2024 16:55:30 +0000 Subject: [PATCH 77/84] Update references to artifacts directory --- .github/workflows/main.yml | 2 +- docs/installing.md | 2 +- eng/steps.yml | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8bd164487..71b302fb9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -44,7 +44,7 @@ jobs: - uses: actions/upload-artifact@v4 with: name: packages-${{ matrix.os }} - path: Package/Release/Packages + path: eng/Release/Packages - name: Test (net462) run: ./make.ps1 -frameworks net462 test-all shell: pwsh diff --git a/docs/installing.md b/docs/installing.md index 1c217ab5e..8f58b3719 100644 --- a/docs/installing.md +++ b/docs/installing.md @@ -168,7 +168,7 @@ If those executables test out successfully, the binaries can be installed outsid ./make.ps1 package ``` -The artifacts are placed in directory `./Package/Release/Packages/IronPython-3.X.Y`. Pick a package suitable for your installation target and follow instructions above for the officially released packages. +The artifacts are placed in directory `./eng/Release/Packages/IronPython-3.X.Y`. Pick a package suitable for your installation target and follow instructions above for the officially released packages. Note: as a convenience, if you run `Install-IronPython.ps1` directly from directory `./src/Scripts` to install IronPython from the zip file, there is no need to pass the location to the zip file; the script finds it automatically using the relative path. diff --git a/eng/steps.yml b/eng/steps.yml index 12a52759c..bce59ef2e 100644 --- a/eng/steps.yml +++ b/eng/steps.yml @@ -97,7 +97,7 @@ steps: - task: CopyFiles@2 displayName: Copy NuGet and Zip Packages inputs: - SourceFolder: '$(Build.Repository.LocalPath)/Package/Release/Packages' + SourceFolder: '$(Build.Repository.LocalPath)/eng/Release/Packages' Contents: | **/*.nupkg **/*.snupkg @@ -109,7 +109,7 @@ steps: - task: CopyFiles@2 displayName: Copy MSI Installer inputs: - SourceFolder: '$(Build.Repository.LocalPath)/Package/Release/Packages' + SourceFolder: '$(Build.Repository.LocalPath)/eng/Release/Packages' Contents: '**/*.msi' TargetFolder: '$(Build.ArtifactStagingDirectory)' condition: and(succeededOrFailed(), eq(variables['system.pullrequest.isfork'], false)) @@ -118,7 +118,7 @@ steps: - task: CopyFiles@2 displayName: Copy Deb Installer inputs: - SourceFolder: '$(Build.Repository.LocalPath)/Package/Release/Packages' + SourceFolder: '$(Build.Repository.LocalPath)/eng/Release/Packages' Contents: '**/*.deb' TargetFolder: '$(Build.ArtifactStagingDirectory)' condition: and(succeededOrFailed(), eq(variables['system.pullrequest.isfork'], false)) @@ -127,7 +127,7 @@ steps: - task: CopyFiles@2 displayName: Copy Pkg Installer inputs: - SourceFolder: '$(Build.Repository.LocalPath)/Package/Release/Packages' + SourceFolder: '$(Build.Repository.LocalPath)/eng/Release/Packages' Contents: '**/*.pkg' TargetFolder: '$(Build.ArtifactStagingDirectory)' condition: and(succeededOrFailed(), eq(variables['system.pullrequest.isfork'], false)) From c9ea6d00a87a739541bc58b5e3828b818291f3bd Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Fri, 29 Nov 2024 16:57:13 +0000 Subject: [PATCH 78/84] Update submodule Absolutely no change whatsoever --- src/runtime | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime b/src/runtime index fe26cf45d..ccc60e511 160000 --- a/src/runtime +++ b/src/runtime @@ -1 +1 @@ -Subproject commit fe26cf45d383be65a56f0d4b964644eff89e01a8 +Subproject commit ccc60e511c08a701e79540a43298212ecd8c57d3 From 512976c057f0d65e9f945d04032a4d42f93a0648 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Fri, 29 Nov 2024 17:33:02 +0000 Subject: [PATCH 79/84] Attempt to fix tests directory references MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit doesn't make a difference 😕 --- tests/ironpython/Cases/IronPythonCases.cs | 2 +- tests/ironpython/EngineTest.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ironpython/Cases/IronPythonCases.cs b/tests/ironpython/Cases/IronPythonCases.cs index 7245b2c42..7ce53424a 100644 --- a/tests/ironpython/Cases/IronPythonCases.cs +++ b/tests/ironpython/Cases/IronPythonCases.cs @@ -20,7 +20,7 @@ internal class IronPythonCaseGenerator : CommonCaseGenerator { protected override IEnumerable GetTests() { return GetFilenames(new[] { System.Tuple.Create(category, "Tests"), - System.Tuple.Create($"{category}.scripts", Path.Combine("src", "Scripts")), + System.Tuple.Create($"{category}.scripts", Path.Combine("eng", "scripts")), }) .OrderBy(testcase => testcase.Name); diff --git a/tests/ironpython/EngineTest.cs b/tests/ironpython/EngineTest.cs index afa84ac01..b45469a8e 100644 --- a/tests/ironpython/EngineTest.cs +++ b/tests/ironpython/EngineTest.cs @@ -53,8 +53,8 @@ internal class Common { static Common() { RuntimeDirectory = Path.GetDirectoryName(typeof(PythonContext).Assembly.Location); RootDirectory = FindRoot(); - ScriptTestDirectory = Path.Combine(RootDirectory, "Tests"); - InputTestDirectory = Path.Combine(ScriptTestDirectory, "Inputs"); + ScriptTestDirectory = Path.Combine(RootDirectory, "tests", "python"); + InputTestDirectory = Path.Combine(ScriptTestDirectory, "inputs"); } private static string FindRoot() { From e3d47bd140aa97c34c97d4d5cf7356771266aaa3 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Fri, 29 Nov 2024 17:42:20 +0000 Subject: [PATCH 80/84] Fix typo in directory name --- tests/ironpython/EngineTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ironpython/EngineTest.cs b/tests/ironpython/EngineTest.cs index b45469a8e..e90f83ae1 100644 --- a/tests/ironpython/EngineTest.cs +++ b/tests/ironpython/EngineTest.cs @@ -54,7 +54,7 @@ static Common() { RuntimeDirectory = Path.GetDirectoryName(typeof(PythonContext).Assembly.Location); RootDirectory = FindRoot(); ScriptTestDirectory = Path.Combine(RootDirectory, "tests", "python"); - InputTestDirectory = Path.Combine(ScriptTestDirectory, "inputs"); + InputTestDirectory = Path.Combine(ScriptTestDirectory, "Inputs"); } private static string FindRoot() { From 92120660f406bff1429b8ed60e868135b6142182 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Fri, 29 Nov 2024 20:23:48 +0000 Subject: [PATCH 81/84] Fix tests Slozier is smart --- tests/ironpython/Cases/IronPythonCases.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ironpython/Cases/IronPythonCases.cs b/tests/ironpython/Cases/IronPythonCases.cs index 7ce53424a..60078dca3 100644 --- a/tests/ironpython/Cases/IronPythonCases.cs +++ b/tests/ironpython/Cases/IronPythonCases.cs @@ -19,7 +19,7 @@ public override int Test(TestInfo testcase) { internal class IronPythonCaseGenerator : CommonCaseGenerator { protected override IEnumerable GetTests() { return GetFilenames(new[] { - System.Tuple.Create(category, "Tests"), + System.Tuple.Create(category, Path.Combine("tests", "python")), System.Tuple.Create($"{category}.scripts", Path.Combine("eng", "scripts")), }) .OrderBy(testcase => testcase.Name); From f72cdc341f7090341b821603cd3e1058450271be Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Sat, 30 Nov 2024 08:16:55 +0000 Subject: [PATCH 82/84] Prune ignore --- .gitignore | 231 +---------------------------------------------------- 1 file changed, 1 insertion(+), 230 deletions(-) diff --git a/.gitignore b/.gitignore index 89450abbb..39cb6a129 100644 --- a/.gitignore +++ b/.gitignore @@ -4,20 +4,11 @@ ## ## For more information, visit: https://docs.github.com/en/github/using-git/ignoring-files -# Visual Studio -.vs/ -.vscode/ - # Temporary VS files -*.suo -*.csproj.user launchSettings.json # Build results -obj/ -bin/ eng/Release/ -*.binlog # NuGet Packages packages/ @@ -29,7 +20,7 @@ __pycache__/ tests/ironpython/TestResults/ tests/ironpython/runsettings.*.xml -# created by CPython tests +# Created by CPython tests src/core/IronPython.StdLib/Lib/lib2to3/Grammar*.pickle src/core/IronPython.StdLib/Lib/lib2to3/PatternGrammar*.pickle @@ -45,9 +36,6 @@ src/core/IronPython.StdLib/Lib/lib2to3/PatternGrammar*.pickle *.userosscache *.sln.docstates -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - # Mono auto generated files mono_crash.* @@ -69,8 +57,6 @@ bld/ # Visual Studio 2015/2017 cache/options directory .vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ # Visual Studio 2017 auto generated files Generated\ Files/ @@ -84,25 +70,6 @@ Generated\ Files/ TestResult.xml nunit-*.xml -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - -# ASP.NET Scaffolding -ScaffoldingReadMe.txt - -# StyleCop -StyleCopReport.xml - # Files built by Visual Studio *_i.c *_p.c @@ -135,9 +102,6 @@ StyleCopReport.xml *.svclog *.scc -# Chutzpah Test files -_Chutzpah* - # Visual C++ cache files ipch/ *.aps @@ -149,86 +113,18 @@ ipch/ *.VC.db *.VC.VC.opendb -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - # ReSharper is a .NET coding add-in _ReSharper*/ *.[Rr]e[Ss]harper *.DotSettings.user -# TeamCity is a build add-in -_TeamCity* - # DotCover is a Code Coverage Tool *.dotCover -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Coverlet is a free, cross platform Code Coverage Tool -coverage*.json -coverage*.xml -coverage*.info - # Visual Studio code coverage results *.coverage *.coveragexml -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - # NuGet Packages *.nupkg # NuGet Symbol Packages @@ -247,10 +143,6 @@ PublishScripts/ csx/ *.build.csdef -# Microsoft Azure Emulator -ecf/ -rcf/ - # Windows Store app package directories and files AppPackages/ BundleArtifacts/ @@ -266,28 +158,6 @@ _pkginfo.txt # but keep track of directories ending in .cache !?*.[Cc]ache/ -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - # Backup & report files from converting an old project file # to a newer Visual Studio version. Backup files are not needed, # because we have git ;-) @@ -298,121 +168,22 @@ UpgradeLog*.htm ServiceFabricBackup/ *.rptproj.bak -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser -*- [Bb]ackup.rdl -*- [Bb]ackup ([0-9]).rdl -*- [Bb]ackup ([0-9][0-9]).rdl - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio 6 auto-generated project file (contains which files were open etc.) -*.vbp - -# Visual Studio 6 workspace and project file (working project files containing files to include in project) -*.dsw -*.dsp - -# Visual Studio 6 technical files -*.ncb -*.aps - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# CodeRush personal settings -.cr/personal - # Python Tools for Visual Studio (PTVS) __pycache__/ *.pyc -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - # MSBuild Binary and Structured Log *.binlog -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - # Local History for Visual Studio .localhistory/ # Visual Studio History (VSHistory) files .vshistory/ -# BeatPulse healthcheck temp database -healthchecksdb - # Backup folder for Package Reference Convert tool in Visual Studio 2017 MigrationBackup/ -# Ionide (cross platform F# VS Code tools) working folder -.ionide/ - -# Fody - auto-generated XML schema -FodyWeavers.xsd - # VS Code files for those working on multiple tools .vscode/* !.vscode/settings.json From 335224299c013a9c54b7a2619dce933149249b19 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Sun, 19 Jan 2025 15:10:44 +0000 Subject: [PATCH 83/84] Fix namespace reference in TestManifest constructor --- tests/ironpython/Util/TestManifest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ironpython/Util/TestManifest.cs b/tests/ironpython/Util/TestManifest.cs index af01c800e..890ece9e8 100644 --- a/tests/ironpython/Util/TestManifest.cs +++ b/tests/ironpython/Util/TestManifest.cs @@ -13,7 +13,7 @@ public class TestManifest { private IniParser manifest; public TestManifest(Type parent) { - var file = parent.Assembly.GetManifestResourceStream($"IronPythonTest.Cases.{parent.Name}Manifest.ini"); + var file = parent.Assembly.GetManifestResourceStream($"IronPython.Tests.Cases.{parent.Name}Manifest.ini"); this.manifest = new IniParser(file); } From f5ddbcf0d98add6347dcfccc58a49579e1acae58 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Sun, 19 Jan 2025 16:01:27 +0000 Subject: [PATCH 84/84] Rename `tests/ironpython` to `tests/IronPython.Tests` --- .gitignore | 4 ++-- IronPython.sln | 2 +- make.ps1 | 4 ++-- tests/{ironpython => IronPython.Tests}/AssemblyInfo.cs | 0 tests/{ironpython => IronPython.Tests}/AttrInjectorTest.cs | 0 tests/{ironpython => IronPython.Tests}/BindTest.cs | 0 tests/{ironpython => IronPython.Tests}/BinderTest.cs | 0 tests/{ironpython => IronPython.Tests}/Cases/CPythonCases.cs | 0 .../Cases/CPythonCasesManifest.ini | 0 tests/{ironpython => IronPython.Tests}/Cases/CaseExecuter.cs | 0 tests/{ironpython => IronPython.Tests}/Cases/CaseGenerator.cs | 0 tests/{ironpython => IronPython.Tests}/Cases/CommonCases.cs | 0 .../{ironpython => IronPython.Tests}/Cases/IronPythonCases.cs | 0 .../Cases/IronPythonCasesManifest.ini | 0 tests/{ironpython => IronPython.Tests}/ClrType.cs | 0 tests/{ironpython => IronPython.Tests}/Cmplx.cs | 0 tests/{ironpython => IronPython.Tests}/Conversions.cs | 0 tests/{ironpython => IronPython.Tests}/DeTest.cs | 0 tests/{ironpython => IronPython.Tests}/DelegateTest.cs | 0 tests/{ironpython => IronPython.Tests}/DynamicRegressions.cs | 0 tests/{ironpython => IronPython.Tests}/EncodingTest.cs | 0 tests/{ironpython => IronPython.Tests}/EngineTest.cs | 0 tests/{ironpython => IronPython.Tests}/Enums.cs | 0 tests/{ironpython => IronPython.Tests}/Events.cs | 0 tests/{ironpython => IronPython.Tests}/ExceptionConverter.cs | 0 tests/{ironpython => IronPython.Tests}/Exceptions.cs | 0 tests/{ironpython => IronPython.Tests}/Explicit.cs | 0 tests/{ironpython => IronPython.Tests}/ExtensionMethodTest.cs | 0 tests/{ironpython => IronPython.Tests}/GenMeth.cs | 0 tests/{ironpython => IronPython.Tests}/Indexable.cs | 0 tests/{ironpython => IronPython.Tests}/InheritTest.cs | 0 tests/{ironpython => IronPython.Tests}/IntegerTest.cs | 0 tests/{ironpython => IronPython.Tests}/IronMath.cs | 0 .../{ironpython => IronPython.Tests}/IronPython.Tests.csproj | 0 tests/{ironpython => IronPython.Tests}/LoadTest.cs | 0 tests/{ironpython => IronPython.Tests}/MemberMappingTests.cs | 0 tests/{ironpython => IronPython.Tests}/MemberOverloadTest.cs | 0 .../{ironpython => IronPython.Tests}/MethodParametersStubs.cs | 0 tests/{ironpython => IronPython.Tests}/NestedClass.cs | 0 tests/{ironpython => IronPython.Tests}/NullableTest.cs | 0 tests/{ironpython => IronPython.Tests}/OperatorTest.cs | 0 tests/{ironpython => IronPython.Tests}/ProtocolTest.cs | 0 tests/{ironpython => IronPython.Tests}/StaticTest.cs | 0 tests/{ironpython => IronPython.Tests}/Stress/Engine.cs | 0 .../StringDictionaryStorage.cs | 0 tests/{ironpython => IronPython.Tests}/TestBuiltinModule.cs | 0 tests/{ironpython => IronPython.Tests}/TypeDescriptor.cs | 0 tests/{ironpython => IronPython.Tests}/Util/IniParser.cs | 0 tests/{ironpython => IronPython.Tests}/Util/TestManifest.cs | 0 49 files changed, 5 insertions(+), 5 deletions(-) rename tests/{ironpython => IronPython.Tests}/AssemblyInfo.cs (100%) rename tests/{ironpython => IronPython.Tests}/AttrInjectorTest.cs (100%) rename tests/{ironpython => IronPython.Tests}/BindTest.cs (100%) rename tests/{ironpython => IronPython.Tests}/BinderTest.cs (100%) rename tests/{ironpython => IronPython.Tests}/Cases/CPythonCases.cs (100%) rename tests/{ironpython => IronPython.Tests}/Cases/CPythonCasesManifest.ini (100%) rename tests/{ironpython => IronPython.Tests}/Cases/CaseExecuter.cs (100%) rename tests/{ironpython => IronPython.Tests}/Cases/CaseGenerator.cs (100%) rename tests/{ironpython => IronPython.Tests}/Cases/CommonCases.cs (100%) rename tests/{ironpython => IronPython.Tests}/Cases/IronPythonCases.cs (100%) rename tests/{ironpython => IronPython.Tests}/Cases/IronPythonCasesManifest.ini (100%) rename tests/{ironpython => IronPython.Tests}/ClrType.cs (100%) rename tests/{ironpython => IronPython.Tests}/Cmplx.cs (100%) rename tests/{ironpython => IronPython.Tests}/Conversions.cs (100%) rename tests/{ironpython => IronPython.Tests}/DeTest.cs (100%) rename tests/{ironpython => IronPython.Tests}/DelegateTest.cs (100%) rename tests/{ironpython => IronPython.Tests}/DynamicRegressions.cs (100%) rename tests/{ironpython => IronPython.Tests}/EncodingTest.cs (100%) rename tests/{ironpython => IronPython.Tests}/EngineTest.cs (100%) rename tests/{ironpython => IronPython.Tests}/Enums.cs (100%) rename tests/{ironpython => IronPython.Tests}/Events.cs (100%) rename tests/{ironpython => IronPython.Tests}/ExceptionConverter.cs (100%) rename tests/{ironpython => IronPython.Tests}/Exceptions.cs (100%) rename tests/{ironpython => IronPython.Tests}/Explicit.cs (100%) rename tests/{ironpython => IronPython.Tests}/ExtensionMethodTest.cs (100%) rename tests/{ironpython => IronPython.Tests}/GenMeth.cs (100%) rename tests/{ironpython => IronPython.Tests}/Indexable.cs (100%) rename tests/{ironpython => IronPython.Tests}/InheritTest.cs (100%) rename tests/{ironpython => IronPython.Tests}/IntegerTest.cs (100%) rename tests/{ironpython => IronPython.Tests}/IronMath.cs (100%) rename tests/{ironpython => IronPython.Tests}/IronPython.Tests.csproj (100%) rename tests/{ironpython => IronPython.Tests}/LoadTest.cs (100%) rename tests/{ironpython => IronPython.Tests}/MemberMappingTests.cs (100%) rename tests/{ironpython => IronPython.Tests}/MemberOverloadTest.cs (100%) rename tests/{ironpython => IronPython.Tests}/MethodParametersStubs.cs (100%) rename tests/{ironpython => IronPython.Tests}/NestedClass.cs (100%) rename tests/{ironpython => IronPython.Tests}/NullableTest.cs (100%) rename tests/{ironpython => IronPython.Tests}/OperatorTest.cs (100%) rename tests/{ironpython => IronPython.Tests}/ProtocolTest.cs (100%) rename tests/{ironpython => IronPython.Tests}/StaticTest.cs (100%) rename tests/{ironpython => IronPython.Tests}/Stress/Engine.cs (100%) rename tests/{ironpython => IronPython.Tests}/StringDictionaryStorage.cs (100%) rename tests/{ironpython => IronPython.Tests}/TestBuiltinModule.cs (100%) rename tests/{ironpython => IronPython.Tests}/TypeDescriptor.cs (100%) rename tests/{ironpython => IronPython.Tests}/Util/IniParser.cs (100%) rename tests/{ironpython => IronPython.Tests}/Util/TestManifest.cs (100%) diff --git a/.gitignore b/.gitignore index 39cb6a129..516b9c987 100644 --- a/.gitignore +++ b/.gitignore @@ -17,8 +17,8 @@ packages/ __pycache__/ # Generated files -tests/ironpython/TestResults/ -tests/ironpython/runsettings.*.xml +tests/IronPython.Tests/TestResults/ +tests/IronPython.Tests/runsettings.*.xml # Created by CPython tests src/core/IronPython.StdLib/Lib/lib2to3/Grammar*.pickle diff --git a/IronPython.sln b/IronPython.sln index 45742b73b..a8e888ed1 100644 --- a/IronPython.sln +++ b/IronPython.sln @@ -11,7 +11,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Wpf", "src\exten EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console", "src\platforms\IronPython.Console\IronPython.Console.csproj", "{811AC32C-11F3-4ED8-92A7-A7E39C2BB704}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Tests", "tests\ironpython\IronPython.Tests.csproj", "{B6B42537-07F8-4F6C-A99A-B155CAEB124E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Tests", "tests\IronPython.Tests\IronPython.Tests.csproj", "{B6B42537-07F8-4F6C-A99A-B155CAEB124E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPython.Console.Host", "src\platforms\IronPython.Console.Host\IronPython.Console.Host.csproj", "{81DA19C7-4FEC-47E7-981B-D9310D549F95}" EndProject diff --git a/make.ps1 b/make.ps1 index 0dc845017..940348264 100755 --- a/make.ps1 +++ b/make.ps1 @@ -75,7 +75,7 @@ function GenerateRunSettings([String] $framework, [String] $platform, [String] $ $doc.AppendChild($dec) | Out-Null $runSettings = $doc.CreateElement("RunSettings") - + $runConfiguration = $doc.CreateElement("RunConfiguration") $runSettings.AppendChild($runConfiguration) | Out-Null if ($platform) { @@ -182,7 +182,7 @@ function Test([String] $target, [String] $configuration, [String[]] $frameworks, $runSettings = GenerateRunSettings $framework $platform $configuration $runIgnored function createTask($filtername, $filter) { - [Object[]] $args = @("$_BASEDIR/tests/ironpython/IronPython.Tests.csproj", '-f', "$framework", '-o', "$_BASEDIR/bin/$configuration/$framework", '-c', "$configuration", '--no-build', '-v', 'n', '-l', "trx;LogFileName=$filtername-$framework-$configuration-result.trx", '-s', "$runSettings", "--filter=$filter"); + [Object[]] $args = @("$_BASEDIR/tests/IronPython.Tests/IronPython.Tests.csproj", '-f', "$framework", '-o', "$_BASEDIR/bin/$configuration/$framework", '-c', "$configuration", '--no-build', '-v', 'n', '-l', "trx;LogFileName=$filtername-$framework-$configuration-result.trx", '-s', "$runSettings", "--filter=$filter"); Write-Host "Enqueue [$framework $filtername]:" Write-Host "dotnet test $args" Write-Host diff --git a/tests/ironpython/AssemblyInfo.cs b/tests/IronPython.Tests/AssemblyInfo.cs similarity index 100% rename from tests/ironpython/AssemblyInfo.cs rename to tests/IronPython.Tests/AssemblyInfo.cs diff --git a/tests/ironpython/AttrInjectorTest.cs b/tests/IronPython.Tests/AttrInjectorTest.cs similarity index 100% rename from tests/ironpython/AttrInjectorTest.cs rename to tests/IronPython.Tests/AttrInjectorTest.cs diff --git a/tests/ironpython/BindTest.cs b/tests/IronPython.Tests/BindTest.cs similarity index 100% rename from tests/ironpython/BindTest.cs rename to tests/IronPython.Tests/BindTest.cs diff --git a/tests/ironpython/BinderTest.cs b/tests/IronPython.Tests/BinderTest.cs similarity index 100% rename from tests/ironpython/BinderTest.cs rename to tests/IronPython.Tests/BinderTest.cs diff --git a/tests/ironpython/Cases/CPythonCases.cs b/tests/IronPython.Tests/Cases/CPythonCases.cs similarity index 100% rename from tests/ironpython/Cases/CPythonCases.cs rename to tests/IronPython.Tests/Cases/CPythonCases.cs diff --git a/tests/ironpython/Cases/CPythonCasesManifest.ini b/tests/IronPython.Tests/Cases/CPythonCasesManifest.ini similarity index 100% rename from tests/ironpython/Cases/CPythonCasesManifest.ini rename to tests/IronPython.Tests/Cases/CPythonCasesManifest.ini diff --git a/tests/ironpython/Cases/CaseExecuter.cs b/tests/IronPython.Tests/Cases/CaseExecuter.cs similarity index 100% rename from tests/ironpython/Cases/CaseExecuter.cs rename to tests/IronPython.Tests/Cases/CaseExecuter.cs diff --git a/tests/ironpython/Cases/CaseGenerator.cs b/tests/IronPython.Tests/Cases/CaseGenerator.cs similarity index 100% rename from tests/ironpython/Cases/CaseGenerator.cs rename to tests/IronPython.Tests/Cases/CaseGenerator.cs diff --git a/tests/ironpython/Cases/CommonCases.cs b/tests/IronPython.Tests/Cases/CommonCases.cs similarity index 100% rename from tests/ironpython/Cases/CommonCases.cs rename to tests/IronPython.Tests/Cases/CommonCases.cs diff --git a/tests/ironpython/Cases/IronPythonCases.cs b/tests/IronPython.Tests/Cases/IronPythonCases.cs similarity index 100% rename from tests/ironpython/Cases/IronPythonCases.cs rename to tests/IronPython.Tests/Cases/IronPythonCases.cs diff --git a/tests/ironpython/Cases/IronPythonCasesManifest.ini b/tests/IronPython.Tests/Cases/IronPythonCasesManifest.ini similarity index 100% rename from tests/ironpython/Cases/IronPythonCasesManifest.ini rename to tests/IronPython.Tests/Cases/IronPythonCasesManifest.ini diff --git a/tests/ironpython/ClrType.cs b/tests/IronPython.Tests/ClrType.cs similarity index 100% rename from tests/ironpython/ClrType.cs rename to tests/IronPython.Tests/ClrType.cs diff --git a/tests/ironpython/Cmplx.cs b/tests/IronPython.Tests/Cmplx.cs similarity index 100% rename from tests/ironpython/Cmplx.cs rename to tests/IronPython.Tests/Cmplx.cs diff --git a/tests/ironpython/Conversions.cs b/tests/IronPython.Tests/Conversions.cs similarity index 100% rename from tests/ironpython/Conversions.cs rename to tests/IronPython.Tests/Conversions.cs diff --git a/tests/ironpython/DeTest.cs b/tests/IronPython.Tests/DeTest.cs similarity index 100% rename from tests/ironpython/DeTest.cs rename to tests/IronPython.Tests/DeTest.cs diff --git a/tests/ironpython/DelegateTest.cs b/tests/IronPython.Tests/DelegateTest.cs similarity index 100% rename from tests/ironpython/DelegateTest.cs rename to tests/IronPython.Tests/DelegateTest.cs diff --git a/tests/ironpython/DynamicRegressions.cs b/tests/IronPython.Tests/DynamicRegressions.cs similarity index 100% rename from tests/ironpython/DynamicRegressions.cs rename to tests/IronPython.Tests/DynamicRegressions.cs diff --git a/tests/ironpython/EncodingTest.cs b/tests/IronPython.Tests/EncodingTest.cs similarity index 100% rename from tests/ironpython/EncodingTest.cs rename to tests/IronPython.Tests/EncodingTest.cs diff --git a/tests/ironpython/EngineTest.cs b/tests/IronPython.Tests/EngineTest.cs similarity index 100% rename from tests/ironpython/EngineTest.cs rename to tests/IronPython.Tests/EngineTest.cs diff --git a/tests/ironpython/Enums.cs b/tests/IronPython.Tests/Enums.cs similarity index 100% rename from tests/ironpython/Enums.cs rename to tests/IronPython.Tests/Enums.cs diff --git a/tests/ironpython/Events.cs b/tests/IronPython.Tests/Events.cs similarity index 100% rename from tests/ironpython/Events.cs rename to tests/IronPython.Tests/Events.cs diff --git a/tests/ironpython/ExceptionConverter.cs b/tests/IronPython.Tests/ExceptionConverter.cs similarity index 100% rename from tests/ironpython/ExceptionConverter.cs rename to tests/IronPython.Tests/ExceptionConverter.cs diff --git a/tests/ironpython/Exceptions.cs b/tests/IronPython.Tests/Exceptions.cs similarity index 100% rename from tests/ironpython/Exceptions.cs rename to tests/IronPython.Tests/Exceptions.cs diff --git a/tests/ironpython/Explicit.cs b/tests/IronPython.Tests/Explicit.cs similarity index 100% rename from tests/ironpython/Explicit.cs rename to tests/IronPython.Tests/Explicit.cs diff --git a/tests/ironpython/ExtensionMethodTest.cs b/tests/IronPython.Tests/ExtensionMethodTest.cs similarity index 100% rename from tests/ironpython/ExtensionMethodTest.cs rename to tests/IronPython.Tests/ExtensionMethodTest.cs diff --git a/tests/ironpython/GenMeth.cs b/tests/IronPython.Tests/GenMeth.cs similarity index 100% rename from tests/ironpython/GenMeth.cs rename to tests/IronPython.Tests/GenMeth.cs diff --git a/tests/ironpython/Indexable.cs b/tests/IronPython.Tests/Indexable.cs similarity index 100% rename from tests/ironpython/Indexable.cs rename to tests/IronPython.Tests/Indexable.cs diff --git a/tests/ironpython/InheritTest.cs b/tests/IronPython.Tests/InheritTest.cs similarity index 100% rename from tests/ironpython/InheritTest.cs rename to tests/IronPython.Tests/InheritTest.cs diff --git a/tests/ironpython/IntegerTest.cs b/tests/IronPython.Tests/IntegerTest.cs similarity index 100% rename from tests/ironpython/IntegerTest.cs rename to tests/IronPython.Tests/IntegerTest.cs diff --git a/tests/ironpython/IronMath.cs b/tests/IronPython.Tests/IronMath.cs similarity index 100% rename from tests/ironpython/IronMath.cs rename to tests/IronPython.Tests/IronMath.cs diff --git a/tests/ironpython/IronPython.Tests.csproj b/tests/IronPython.Tests/IronPython.Tests.csproj similarity index 100% rename from tests/ironpython/IronPython.Tests.csproj rename to tests/IronPython.Tests/IronPython.Tests.csproj diff --git a/tests/ironpython/LoadTest.cs b/tests/IronPython.Tests/LoadTest.cs similarity index 100% rename from tests/ironpython/LoadTest.cs rename to tests/IronPython.Tests/LoadTest.cs diff --git a/tests/ironpython/MemberMappingTests.cs b/tests/IronPython.Tests/MemberMappingTests.cs similarity index 100% rename from tests/ironpython/MemberMappingTests.cs rename to tests/IronPython.Tests/MemberMappingTests.cs diff --git a/tests/ironpython/MemberOverloadTest.cs b/tests/IronPython.Tests/MemberOverloadTest.cs similarity index 100% rename from tests/ironpython/MemberOverloadTest.cs rename to tests/IronPython.Tests/MemberOverloadTest.cs diff --git a/tests/ironpython/MethodParametersStubs.cs b/tests/IronPython.Tests/MethodParametersStubs.cs similarity index 100% rename from tests/ironpython/MethodParametersStubs.cs rename to tests/IronPython.Tests/MethodParametersStubs.cs diff --git a/tests/ironpython/NestedClass.cs b/tests/IronPython.Tests/NestedClass.cs similarity index 100% rename from tests/ironpython/NestedClass.cs rename to tests/IronPython.Tests/NestedClass.cs diff --git a/tests/ironpython/NullableTest.cs b/tests/IronPython.Tests/NullableTest.cs similarity index 100% rename from tests/ironpython/NullableTest.cs rename to tests/IronPython.Tests/NullableTest.cs diff --git a/tests/ironpython/OperatorTest.cs b/tests/IronPython.Tests/OperatorTest.cs similarity index 100% rename from tests/ironpython/OperatorTest.cs rename to tests/IronPython.Tests/OperatorTest.cs diff --git a/tests/ironpython/ProtocolTest.cs b/tests/IronPython.Tests/ProtocolTest.cs similarity index 100% rename from tests/ironpython/ProtocolTest.cs rename to tests/IronPython.Tests/ProtocolTest.cs diff --git a/tests/ironpython/StaticTest.cs b/tests/IronPython.Tests/StaticTest.cs similarity index 100% rename from tests/ironpython/StaticTest.cs rename to tests/IronPython.Tests/StaticTest.cs diff --git a/tests/ironpython/Stress/Engine.cs b/tests/IronPython.Tests/Stress/Engine.cs similarity index 100% rename from tests/ironpython/Stress/Engine.cs rename to tests/IronPython.Tests/Stress/Engine.cs diff --git a/tests/ironpython/StringDictionaryStorage.cs b/tests/IronPython.Tests/StringDictionaryStorage.cs similarity index 100% rename from tests/ironpython/StringDictionaryStorage.cs rename to tests/IronPython.Tests/StringDictionaryStorage.cs diff --git a/tests/ironpython/TestBuiltinModule.cs b/tests/IronPython.Tests/TestBuiltinModule.cs similarity index 100% rename from tests/ironpython/TestBuiltinModule.cs rename to tests/IronPython.Tests/TestBuiltinModule.cs diff --git a/tests/ironpython/TypeDescriptor.cs b/tests/IronPython.Tests/TypeDescriptor.cs similarity index 100% rename from tests/ironpython/TypeDescriptor.cs rename to tests/IronPython.Tests/TypeDescriptor.cs diff --git a/tests/ironpython/Util/IniParser.cs b/tests/IronPython.Tests/Util/IniParser.cs similarity index 100% rename from tests/ironpython/Util/IniParser.cs rename to tests/IronPython.Tests/Util/IniParser.cs diff --git a/tests/ironpython/Util/TestManifest.cs b/tests/IronPython.Tests/Util/TestManifest.cs similarity index 100% rename from tests/ironpython/Util/TestManifest.cs rename to tests/IronPython.Tests/Util/TestManifest.cs